Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/astyle.bat17
-rw-r--r--include/IBitRateInfo.h4
-rw-r--r--include/IBufferInfo.h6
-rw-r--r--include/IChapterInfo.h50
-rw-r--r--include/IFilterVersion.h2
-rw-r--r--include/IKeyFrameInfo.h4
-rw-r--r--include/ITrackInfo.h74
-rw-r--r--include/dsm/dsm.h20
-rw-r--r--include/moreuuids.h580
-rw-r--r--src/CmdUI/CmdUI.cpp202
-rw-r--r--src/CmdUI/CmdUI.h30
-rw-r--r--src/CmdUI/stdafx.h8
-rw-r--r--src/DSUtil/AudioParser.cpp522
-rw-r--r--src/DSUtil/AudioParser.h12
-rw-r--r--src/DSUtil/DSMPropertyBag.cpp446
-rw-r--r--src/DSUtil/DSMPropertyBag.h228
-rw-r--r--src/DSUtil/DSUtil.cpp4760
-rw-r--r--src/DSUtil/DSUtil.h74
-rw-r--r--src/DSUtil/FontInstaller.cpp130
-rw-r--r--src/DSUtil/FontInstaller.h28
-rw-r--r--src/DSUtil/GolombBuffer.cpp84
-rw-r--r--src/DSUtil/GolombBuffer.h46
-rw-r--r--src/DSUtil/H264Nalu.cpp108
-rw-r--r--src/DSUtil/H264Nalu.h76
-rw-r--r--src/DSUtil/HdmvClipInfo.cpp747
-rw-r--r--src/DSUtil/HdmvClipInfo.h204
-rw-r--r--src/DSUtil/MediaTypeEx.cpp1323
-rw-r--r--src/DSUtil/MediaTypeEx.h18
-rw-r--r--src/DSUtil/MediaTypes.cpp654
-rw-r--r--src/DSUtil/MediaTypes.h16
-rw-r--r--src/DSUtil/Mpeg2Def.h250
-rw-r--r--src/DSUtil/NullRenderers.cpp546
-rw-r--r--src/DSUtil/NullRenderers.h54
-rw-r--r--src/DSUtil/SysVersion.cpp8
-rw-r--r--src/DSUtil/SysVersion.h24
-rw-r--r--src/DSUtil/WinAPIUtils.cpp376
-rw-r--r--src/DSUtil/WinAPIUtils.h4
-rw-r--r--src/DSUtil/text.cpp260
-rw-r--r--src/DSUtil/text.h64
-rw-r--r--src/MPCTestAPI/MPCTestAPI.cpp50
-rw-r--r--src/MPCTestAPI/MPCTestAPI.h24
-rw-r--r--src/MPCTestAPI/MPCTestAPIDlg.cpp430
-rw-r--r--src/MPCTestAPI/MPCTestAPIDlg.h62
-rw-r--r--src/SubPic/CoordGeom.cpp500
-rw-r--r--src/SubPic/CoordGeom.h172
-rw-r--r--src/SubPic/DX7SubPic.cpp420
-rw-r--r--src/SubPic/DX7SubPic.h34
-rw-r--r--src/SubPic/DX9SubPic.cpp730
-rw-r--r--src/SubPic/DX9SubPic.h108
-rw-r--r--src/SubPic/ISubPic.h166
-rw-r--r--src/SubPic/ISubRender.h24
-rw-r--r--src/SubPic/MemSubPic.cpp968
-rw-r--r--src/SubPic/MemSubPic.h32
-rw-r--r--src/SubPic/SubPicAllocatorPresenterImpl.cpp222
-rw-r--r--src/SubPic/SubPicAllocatorPresenterImpl.h132
-rw-r--r--src/SubPic/SubPicImpl.cpp228
-rw-r--r--src/SubPic/SubPicImpl.h166
-rw-r--r--src/SubPic/SubPicProviderImpl.cpp14
-rw-r--r--src/SubPic/SubPicProviderImpl.h32
-rw-r--r--src/SubPic/SubPicQueueImpl.cpp922
-rw-r--r--src/SubPic/SubPicQueueImpl.h110
-rw-r--r--src/SubPic/stdafx.h8
-rw-r--r--src/Subtitles/BaseSub.cpp2
-rw-r--r--src/Subtitles/BaseSub.h28
-rw-r--r--src/Subtitles/CCDecoder.cpp664
-rw-r--r--src/Subtitles/CCDecoder.h34
-rw-r--r--src/Subtitles/CompositionObject.cpp534
-rw-r--r--src/Subtitles/CompositionObject.h96
-rw-r--r--src/Subtitles/DVBSub.cpp918
-rw-r--r--src/Subtitles/DVBSub.h358
-rw-r--r--src/Subtitles/GFN.cpp258
-rw-r--r--src/Subtitles/GFN.h2
-rw-r--r--src/Subtitles/HdmvSub.cpp540
-rw-r--r--src/Subtitles/HdmvSub.h152
-rw-r--r--src/Subtitles/RTS.cpp4675
-rw-r--r--src/Subtitles/RTS.h290
-rw-r--r--src/Subtitles/Rasterizer.cpp2551
-rw-r--r--src/Subtitles/Rasterizer.h152
-rw-r--r--src/Subtitles/RealTextParser.cpp956
-rw-r--r--src/Subtitles/RealTextParser.h96
-rw-r--r--src/Subtitles/RenderedHdmvSubtitle.cpp136
-rw-r--r--src/Subtitles/RenderedHdmvSubtitle.h56
-rw-r--r--src/Subtitles/STS.cpp5192
-rw-r--r--src/Subtitles/STS.h260
-rw-r--r--src/Subtitles/SeparableFilter.h174
-rw-r--r--src/Subtitles/SubtitleInputPin.cpp540
-rw-r--r--src/Subtitles/SubtitleInputPin.h36
-rw-r--r--src/Subtitles/TextFile.cpp782
-rw-r--r--src/Subtitles/TextFile.h58
-rw-r--r--src/Subtitles/USFSubtitles.cpp1268
-rw-r--r--src/Subtitles/USFSubtitles.h76
-rw-r--r--src/Subtitles/VobSubFile.cpp4148
-rw-r--r--src/Subtitles/VobSubFile.h240
-rw-r--r--src/Subtitles/VobSubFileRipper.cpp2076
-rw-r--r--src/Subtitles/VobSubFileRipper.h194
-rw-r--r--src/Subtitles/VobSubImage.cpp2272
-rw-r--r--src/Subtitles/VobSubImage.h110
-rw-r--r--src/Subtitles/stdafx.h8
-rw-r--r--src/filters/FilterApp.cpp16
-rw-r--r--src/filters/FilterApp.h8
-rw-r--r--src/filters/InternalPropertyPage.cpp360
-rw-r--r--src/filters/InternalPropertyPage.h154
-rw-r--r--src/filters/PinInfoWnd.cpp328
-rw-r--r--src/filters/PinInfoWnd.h50
-rw-r--r--src/filters/muxer/BaseMuxer/BaseMuxer.cpp556
-rw-r--r--src/filters/muxer/BaseMuxer/BaseMuxer.h136
-rw-r--r--src/filters/muxer/BaseMuxer/BaseMuxerInputPin.cpp328
-rw-r--r--src/filters/muxer/BaseMuxer/BaseMuxerInputPin.h120
-rw-r--r--src/filters/muxer/BaseMuxer/BaseMuxerOutputPin.cpp774
-rw-r--r--src/filters/muxer/BaseMuxer/BaseMuxerOutputPin.h44
-rw-r--r--src/filters/muxer/BaseMuxer/BaseMuxerRelatedPin.cpp6
-rw-r--r--src/filters/muxer/BaseMuxer/BaseMuxerRelatedPin.h16
-rw-r--r--src/filters/muxer/BaseMuxer/BitStream.cpp152
-rw-r--r--src/filters/muxer/BaseMuxer/BitStream.h42
-rw-r--r--src/filters/muxer/BaseMuxer/stdafx.h8
-rw-r--r--src/filters/muxer/DSMMuxer/DSMMuxer.cpp652
-rw-r--r--src/filters/muxer/DSMMuxer/DSMMuxer.h54
-rw-r--r--src/filters/muxer/MatroskaMuxer/MatroskaFile.cpp1176
-rw-r--r--src/filters/muxer/MatroskaMuxer/MatroskaFile.h782
-rw-r--r--src/filters/muxer/MatroskaMuxer/MatroskaMuxer.cpp2164
-rw-r--r--src/filters/muxer/MatroskaMuxer/MatroskaMuxer.h162
-rw-r--r--src/filters/muxer/WavDest/WavDest.cpp320
-rw-r--r--src/filters/muxer/WavDest/WavDest.h40
-rw-r--r--src/filters/parser/AviSplitter/AviFile.cpp1126
-rw-r--r--src/filters/parser/AviSplitter/AviFile.h100
-rw-r--r--src/filters/parser/AviSplitter/AviReportWnd.cpp568
-rw-r--r--src/filters/parser/AviSplitter/AviReportWnd.h46
-rw-r--r--src/filters/parser/AviSplitter/AviSplitter.cpp1418
-rw-r--r--src/filters/parser/AviSplitter/AviSplitter.h66
-rw-r--r--src/filters/parser/BaseSplitter/AsyncReader.cpp290
-rw-r--r--src/filters/parser/BaseSplitter/AsyncReader.h128
-rw-r--r--src/filters/parser/BaseSplitter/BaseSplitter.cpp1937
-rw-r--r--src/filters/parser/BaseSplitter/BaseSplitter.h656
-rw-r--r--src/filters/parser/BaseSplitter/BaseSplitterFile.cpp304
-rw-r--r--src/filters/parser/BaseSplitter/BaseSplitterFile.h52
-rw-r--r--src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp3933
-rw-r--r--src/filters/parser/BaseSplitter/BaseSplitterFileEx.h802
-rw-r--r--src/filters/parser/BaseSplitter/MultiFiles.cpp238
-rw-r--r--src/filters/parser/BaseSplitter/MultiFiles.h108
-rw-r--r--src/filters/parser/DSMSplitter/DSMSplitter.cpp332
-rw-r--r--src/filters/parser/DSMSplitter/DSMSplitter.h30
-rw-r--r--src/filters/parser/DSMSplitter/DSMSplitterFile.cpp658
-rw-r--r--src/filters/parser/DSMSplitter/DSMSplitterFile.h54
-rw-r--r--src/filters/parser/FLVSplitter/FLVSplitter.cpp1472
-rw-r--r--src/filters/parser/FLVSplitter/FLVSplitter.h82
-rw-r--r--src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.cpp74
-rw-r--r--src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.h30
-rw-r--r--src/filters/parser/MP4Splitter/MP4Splitter.cpp3686
-rw-r--r--src/filters/parser/MP4Splitter/MP4Splitter.h76
-rw-r--r--src/filters/parser/MP4Splitter/MP4SplitterFile.cpp32
-rw-r--r--src/filters/parser/MP4Splitter/MP4SplitterFile.h10
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaFile.cpp2026
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaFile.h1146
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp2856
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaSplitter.h118
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitter.cpp236
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitter.h30
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitterFile.cpp745
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitterFile.h54
-rw-r--r--src/filters/parser/MpegSplitter/IMpegSplitterFilter.h36
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitter.cpp3578
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitter.h150
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitterFile.cpp1997
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitterFile.h276
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.cpp182
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.h84
-rw-r--r--src/filters/parser/OggSplitter/OggFile.cpp106
-rw-r--r--src/filters/parser/OggSplitter/OggFile.h86
-rw-r--r--src/filters/parser/OggSplitter/OggSplitter.cpp2012
-rw-r--r--src/filters/parser/OggSplitter/OggSplitter.h186
-rw-r--r--src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp4400
-rw-r--r--src/filters/parser/RealMediaSplitter/RealMediaSplitter.h470
-rw-r--r--src/filters/parser/StreamDriveThru/StreamDriveThru.cpp558
-rw-r--r--src/filters/parser/StreamDriveThru/StreamDriveThru.h132
-rw-r--r--src/filters/reader/CDDAReader/CDDAReader.cpp544
-rw-r--r--src/filters/reader/CDDAReader/CDDAReader.h130
-rw-r--r--src/filters/reader/CDXAReader/CDXAReader.cpp746
-rw-r--r--src/filters/reader/CDXAReader/CDXAReader.h76
-rw-r--r--src/filters/reader/UDPReader/UDPReader.cpp552
-rw-r--r--src/filters/reader/UDPReader/UDPReader.h92
-rw-r--r--src/filters/reader/VTSReader/VTSReader.cpp200
-rw-r--r--src/filters/reader/VTSReader/VTSReader.h80
-rw-r--r--src/filters/renderer/MpcAudioRenderer/IMpcAudioRendererFilter.h14
-rw-r--r--src/filters/renderer/MpcAudioRenderer/MpcAudioRenderer.cpp2098
-rw-r--r--src/filters/renderer/MpcAudioRenderer/MpcAudioRenderer.h196
-rw-r--r--src/filters/renderer/MpcAudioRenderer/MpcAudioRendererSettingsWnd.cpp155
-rw-r--r--src/filters/renderer/MpcAudioRenderer/MpcAudioRendererSettingsWnd.h54
-rw-r--r--src/filters/renderer/SyncClock/Interfaces.h8
-rw-r--r--src/filters/renderer/SyncClock/SyncClock.cpp100
-rw-r--r--src/filters/renderer/SyncClock/SyncClock.h60
-rw-r--r--src/filters/renderer/SyncClock/stdafx.h6
-rw-r--r--src/filters/renderer/VideoRenderers/AllocatorCommon.cpp518
-rw-r--r--src/filters/renderer/VideoRenderers/AllocatorCommon.h18
-rw-r--r--src/filters/renderer/VideoRenderers/AllocatorCommon7.cpp57
-rw-r--r--src/filters/renderer/VideoRenderers/AllocatorCommon7.h6
-rw-r--r--src/filters/renderer/VideoRenderers/D3DFont.cpp1394
-rw-r--r--src/filters/renderer/VideoRenderers/D3DFont.h66
-rw-r--r--src/filters/renderer/VideoRenderers/DX7AllocatorPresenter.cpp778
-rw-r--r--src/filters/renderer/VideoRenderers/DX7AllocatorPresenter.h50
-rw-r--r--src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp4366
-rw-r--r--src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.h554
-rw-r--r--src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp2843
-rw-r--r--src/filters/renderer/VideoRenderers/DX9RenderingEngine.h292
-rw-r--r--src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.cpp330
-rw-r--r--src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.h138
-rw-r--r--src/filters/renderer/VideoRenderers/Dither.cpp128
-rw-r--r--src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.cpp4120
-rw-r--r--src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.h494
-rw-r--r--src/filters/renderer/VideoRenderers/IPinHook.cpp2328
-rw-r--r--src/filters/renderer/VideoRenderers/IPinHook.h238
-rw-r--r--src/filters/renderer/VideoRenderers/IQTVideoSurface.h4
-rw-r--r--src/filters/renderer/VideoRenderers/MacrovisionKicker.cpp54
-rw-r--r--src/filters/renderer/VideoRenderers/MacrovisionKicker.h24
-rw-r--r--src/filters/renderer/VideoRenderers/OuterEVR.cpp267
-rw-r--r--src/filters/renderer/VideoRenderers/OuterEVR.h124
-rw-r--r--src/filters/renderer/VideoRenderers/OuterVMR.cpp212
-rw-r--r--src/filters/renderer/VideoRenderers/OuterVMR.h630
-rw-r--r--src/filters/renderer/VideoRenderers/PixelShaderCompiler.cpp134
-rw-r--r--src/filters/renderer/VideoRenderers/PixelShaderCompiler.h58
-rw-r--r--src/filters/renderer/VideoRenderers/QT7AllocatorPresenter.cpp194
-rw-r--r--src/filters/renderer/VideoRenderers/QT7AllocatorPresenter.h40
-rw-r--r--src/filters/renderer/VideoRenderers/QT9AllocatorPresenter.cpp152
-rw-r--r--src/filters/renderer/VideoRenderers/QT9AllocatorPresenter.h32
-rw-r--r--src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.cpp384
-rw-r--r--src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.h46
-rw-r--r--src/filters/renderer/VideoRenderers/RM9AllocatorPresenter.cpp332
-rw-r--r--src/filters/renderer/VideoRenderers/RM9AllocatorPresenter.h56
-rw-r--r--src/filters/renderer/VideoRenderers/RenderersSettings.cpp168
-rw-r--r--src/filters/renderer/VideoRenderers/RenderersSettings.h202
-rw-r--r--src/filters/renderer/VideoRenderers/SyncAllocatorPresenter.h2
-rw-r--r--src/filters/renderer/VideoRenderers/SyncRenderer.cpp7551
-rw-r--r--src/filters/renderer/VideoRenderers/SyncRenderer.h1198
-rw-r--r--src/filters/renderer/VideoRenderers/VMR7AllocatorPresenter.cpp436
-rw-r--r--src/filters/renderer/VideoRenderers/VMR7AllocatorPresenter.h88
-rw-r--r--src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.cpp780
-rw-r--r--src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.h88
-rw-r--r--src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.cpp347
-rw-r--r--src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.h146
-rw-r--r--src/filters/renderer/VideoRenderers/stdafx.h2
-rw-r--r--src/filters/source/BaseSource/BaseSource.cpp178
-rw-r--r--src/filters/source/BaseSource/BaseSource.h172
-rw-r--r--src/filters/source/BaseSource/stdafx.h8
-rw-r--r--src/filters/source/D2VSource/D2VSource.cpp336
-rw-r--r--src/filters/source/D2VSource/D2VSource.h32
-rw-r--r--src/filters/source/DTSAC3Source/DTSAC3Source.cpp1006
-rw-r--r--src/filters/source/DTSAC3Source/DTSAC3Source.h58
-rw-r--r--src/filters/source/FLACSource/FLACSource.cpp408
-rw-r--r--src/filters/source/FLACSource/FLACSource.h52
-rw-r--r--src/filters/source/FLICSource/FLICSource.cpp1032
-rw-r--r--src/filters/source/FLICSource/FLICSource.h216
-rw-r--r--src/filters/source/ShoutcastSource/ShoutcastSource.cpp954
-rw-r--r--src/filters/source/ShoutcastSource/ShoutcastSource.h300
-rw-r--r--src/filters/source/SubtitleSource/SubtitleSource.cpp978
-rw-r--r--src/filters/source/SubtitleSource/SubtitleSource.h120
-rw-r--r--src/filters/switcher/AudioSwitcher/Audio.cpp424
-rw-r--r--src/filters/switcher/AudioSwitcher/Audio.h32
-rw-r--r--src/filters/switcher/AudioSwitcher/AudioSwitcher.cpp930
-rw-r--r--src/filters/switcher/AudioSwitcher/AudioSwitcher.h92
-rw-r--r--src/filters/switcher/AudioSwitcher/StreamSwitcher.cpp1636
-rw-r--r--src/filters/switcher/AudioSwitcher/StreamSwitcher.h368
-rw-r--r--src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.cpp792
-rw-r--r--src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.h36
-rw-r--r--src/filters/transform/BaseVideoFilter/BaseVideoFilter.cpp1162
-rw-r--r--src/filters/transform/BaseVideoFilter/BaseVideoFilter.h82
-rw-r--r--src/filters/transform/BufferFilter/BufferFilter.cpp384
-rw-r--r--src/filters/transform/BufferFilter/BufferFilter.h108
-rw-r--r--src/filters/transform/DeCSSFilter/DeCSSFilter.cpp308
-rw-r--r--src/filters/transform/DeCSSFilter/DeCSSFilter.h18
-rw-r--r--src/filters/transform/MPCVideoDec/CpuId.cpp303
-rw-r--r--src/filters/transform/MPCVideoDec/CpuId.h44
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoder.cpp1152
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoder.h220
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp587
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoderH264.h56
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.cpp404
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.h50
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoderVC1.cpp442
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoderVC1.h134
-rw-r--r--src/filters/transform/MPCVideoDec/FfmpegContext.cpp1335
-rw-r--r--src/filters/transform/MPCVideoDec/FfmpegContext.h66
-rw-r--r--src/filters/transform/MPCVideoDec/IMPCVideoDecFilter.h80
-rw-r--r--src/filters/transform/MPCVideoDec/MPCFfmpegDec.cpp16
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp4107
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDecFilter.h498
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.cpp542
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.h144
-rw-r--r--src/filters/transform/MPCVideoDec/TlibavcodecExt.cpp40
-rw-r--r--src/filters/transform/MPCVideoDec/TlibavcodecExt.h28
-rw-r--r--src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.cpp262
-rw-r--r--src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.h66
-rw-r--r--src/filters/transform/MPCVideoDec/VideoDecOutputPin.cpp154
-rw-r--r--src/filters/transform/MPCVideoDec/VideoDecOutputPin.h30
-rw-r--r--src/filters/transform/MPCVideoDec/stdafx.cpp24
-rw-r--r--src/filters/transform/MpaDecFilter/IMpaDecFilter.h28
-rw-r--r--src/filters/transform/MpaDecFilter/MpaDecFilter.cpp3927
-rw-r--r--src/filters/transform/MpaDecFilter/MpaDecFilter.h196
-rw-r--r--src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.cpp280
-rw-r--r--src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.h94
-rw-r--r--src/filters/transform/Mpeg2DecFilter/IMpeg2DecFilter.h58
-rw-r--r--src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp3412
-rw-r--r--src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.h468
-rw-r--r--src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.cpp316
-rw-r--r--src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.h102
-rw-r--r--src/filters/transform/Mpeg2DecFilter/idct_sse2.cpp512
-rw-r--r--src/filters/transform/Mpeg2DecFilter/mc_sse2.cpp758
-rw-r--r--src/filters/transform/VSFilter/AvgLines.cpp406
-rw-r--r--src/filters/transform/VSFilter/AvgLines.h26
-rw-r--r--src/filters/transform/VSFilter/Copy.cpp332
-rw-r--r--src/filters/transform/VSFilter/DirectVobSub.cpp860
-rw-r--r--src/filters/transform/VSFilter/DirectVobSub.h202
-rw-r--r--src/filters/transform/VSFilter/DirectVobSubFilter.cpp2684
-rw-r--r--src/filters/transform/VSFilter/DirectVobSubFilter.h250
-rw-r--r--src/filters/transform/VSFilter/DirectVobSubPropPage.cpp1744
-rw-r--r--src/filters/transform/VSFilter/DirectVobSubPropPage.h204
-rw-r--r--src/filters/transform/VSFilter/IDirectVobSub.h550
-rw-r--r--src/filters/transform/VSFilter/Scale2x.cpp632
-rw-r--r--src/filters/transform/VSFilter/StyleEditorDialog.cpp370
-rw-r--r--src/filters/transform/VSFilter/StyleEditorDialog.h122
-rw-r--r--src/filters/transform/VSFilter/Systray.cpp576
-rw-r--r--src/filters/transform/VSFilter/Systray.h70
-rw-r--r--src/filters/transform/VSFilter/TextInputPin.cpp10
-rw-r--r--src/filters/transform/VSFilter/TextInputPin.h10
-rw-r--r--src/filters/transform/VSFilter/VSFilter.cpp138
-rw-r--r--src/filters/transform/VSFilter/VSFilter.h12
-rw-r--r--src/filters/transform/VSFilter/csri.h544
-rw-r--r--src/filters/transform/VSFilter/csriapi.cpp312
-rw-r--r--src/filters/transform/VSFilter/plugins.cpp2021
-rw-r--r--src/filters/transform/VSFilter/vfr.cpp272
-rw-r--r--src/filters/transform/VSFilter/vfr.h4
-rw-r--r--src/mpc-hc/AboutDlg.cpp110
-rw-r--r--src/mpc-hc/AboutDlg.h46
-rw-r--r--src/mpc-hc/AppSettings.cpp3485
-rw-r--r--src/mpc-hc/AppSettings.h932
-rw-r--r--src/mpc-hc/AuthDlg.cpp172
-rw-r--r--src/mpc-hc/AuthDlg.h34
-rw-r--r--src/mpc-hc/BaseGraph.cpp456
-rw-r--r--src/mpc-hc/BaseGraph.h378
-rw-r--r--src/mpc-hc/CShockwaveFlash.h690
-rw-r--r--src/mpc-hc/ChildView.cpp468
-rw-r--r--src/mpc-hc/ChildView.h50
-rw-r--r--src/mpc-hc/ComPropertyPage.cpp64
-rw-r--r--src/mpc-hc/ComPropertyPage.h26
-rw-r--r--src/mpc-hc/ComPropertySheet.cpp332
-rw-r--r--src/mpc-hc/ComPropertySheet.h40
-rw-r--r--src/mpc-hc/DVBChannel.cpp214
-rw-r--r--src/mpc-hc/DVBChannel.h306
-rw-r--r--src/mpc-hc/DeinterlacerFilter.cpp214
-rw-r--r--src/mpc-hc/DeinterlacerFilter.h16
-rw-r--r--src/mpc-hc/EditListEditor.cpp876
-rw-r--r--src/mpc-hc/EditListEditor.h160
-rw-r--r--src/mpc-hc/EditWithButton.cpp459
-rw-r--r--src/mpc-hc/EditWithButton.h136
-rw-r--r--src/mpc-hc/FGFilter.cpp946
-rw-r--r--src/mpc-hc/FGFilter.h172
-rw-r--r--src/mpc-hc/FGManager.cpp4254
-rw-r--r--src/mpc-hc/FGManager.h178
-rw-r--r--src/mpc-hc/FGManagerBDA.cpp1324
-rw-r--r--src/mpc-hc/FGManagerBDA.h296
-rw-r--r--src/mpc-hc/FakeFilterMapper2.cpp1020
-rw-r--r--src/mpc-hc/FakeFilterMapper2.h138
-rw-r--r--src/mpc-hc/FavoriteAddDlg.cpp66
-rw-r--r--src/mpc-hc/FavoriteAddDlg.h30
-rw-r--r--src/mpc-hc/FavoriteOrganizeDlg.cpp502
-rw-r--r--src/mpc-hc/FavoriteOrganizeDlg.h66
-rw-r--r--src/mpc-hc/FileDropTarget.cpp20
-rw-r--r--src/mpc-hc/FileDropTarget.h56
-rw-r--r--src/mpc-hc/FilterEnum.h138
-rw-r--r--src/mpc-hc/FloatEdit.cpp142
-rw-r--r--src/mpc-hc/FloatEdit.h30
-rw-r--r--src/mpc-hc/FullscreenWnd.cpp114
-rw-r--r--src/mpc-hc/FullscreenWnd.h28
-rw-r--r--src/mpc-hc/GoToDlg.cpp240
-rw-r--r--src/mpc-hc/GoToDlg.h38
-rw-r--r--src/mpc-hc/IGraphBuilder2.h48
-rw-r--r--src/mpc-hc/ISDb.cpp130
-rw-r--r--src/mpc-hc/ISDb.h52
-rw-r--r--src/mpc-hc/Ifo.cpp252
-rw-r--r--src/mpc-hc/Ifo.h232
-rw-r--r--src/mpc-hc/KeyProvider.cpp32
-rw-r--r--src/mpc-hc/KeyProvider.h14
-rw-r--r--src/mpc-hc/LcdSupport.cpp548
-rw-r--r--src/mpc-hc/LcdSupport.h58
-rw-r--r--src/mpc-hc/MPCPngImage.cpp134
-rw-r--r--src/mpc-hc/MPCPngImage.h34
-rw-r--r--src/mpc-hc/MainFrm.cpp26338
-rw-r--r--src/mpc-hc/MainFrm.h1536
-rw-r--r--src/mpc-hc/MediaFormats.cpp520
-rw-r--r--src/mpc-hc/MediaFormats.h100
-rw-r--r--src/mpc-hc/MediaTypesDlg.cpp158
-rw-r--r--src/mpc-hc/MediaTypesDlg.h32
-rw-r--r--src/mpc-hc/MiniDump.cpp218
-rw-r--r--src/mpc-hc/MiniDump.h12
-rw-r--r--src/mpc-hc/Monitors.cpp150
-rw-r--r--src/mpc-hc/Monitors.h88
-rw-r--r--src/mpc-hc/MpcApi.h340
-rw-r--r--src/mpc-hc/Mpeg2SectionData.cpp992
-rw-r--r--src/mpc-hc/Mpeg2SectionData.h88
-rw-r--r--src/mpc-hc/MultiMonitor.cpp204
-rw-r--r--src/mpc-hc/MultiMonitor.h72
-rw-r--r--src/mpc-hc/OpenDirHelper.cpp154
-rw-r--r--src/mpc-hc/OpenDirHelper.h16
-rw-r--r--src/mpc-hc/OpenDlg.cpp276
-rw-r--r--src/mpc-hc/OpenDlg.h42
-rw-r--r--src/mpc-hc/OpenFileDlg.cpp174
-rw-r--r--src/mpc-hc/OpenFileDlg.h36
-rw-r--r--src/mpc-hc/PPageAccelTbl.cpp3332
-rw-r--r--src/mpc-hc/PPageAccelTbl.h90
-rw-r--r--src/mpc-hc/PPageAudioSwitcher.cpp536
-rw-r--r--src/mpc-hc/PPageAudioSwitcher.h80
-rw-r--r--src/mpc-hc/PPageBase.cpp62
-rw-r--r--src/mpc-hc/PPageBase.h22
-rw-r--r--src/mpc-hc/PPageCapture.cpp1002
-rw-r--r--src/mpc-hc/PPageCapture.h38
-rw-r--r--src/mpc-hc/PPageDVD.cpp514
-rw-r--r--src/mpc-hc/PPageDVD.h50
-rw-r--r--src/mpc-hc/PPageExternalFilters.cpp1114
-rw-r--r--src/mpc-hc/PPageExternalFilters.h86
-rw-r--r--src/mpc-hc/PPageFileInfoClip.cpp236
-rw-r--r--src/mpc-hc/PPageFileInfoClip.h48
-rw-r--r--src/mpc-hc/PPageFileInfoDetails.cpp476
-rw-r--r--src/mpc-hc/PPageFileInfoDetails.h44
-rw-r--r--src/mpc-hc/PPageFileInfoRes.cpp178
-rw-r--r--src/mpc-hc/PPageFileInfoRes.h34
-rw-r--r--src/mpc-hc/PPageFileInfoSheet.cpp108
-rw-r--r--src/mpc-hc/PPageFileInfoSheet.h24
-rw-r--r--src/mpc-hc/PPageFileMediaInfo.cpp174
-rw-r--r--src/mpc-hc/PPageFileMediaInfo.h30
-rw-r--r--src/mpc-hc/PPageFormats.cpp1802
-rw-r--r--src/mpc-hc/PPageFormats.h112
-rw-r--r--src/mpc-hc/PPageFullscreen.cpp1176
-rw-r--r--src/mpc-hc/PPageFullscreen.h108
-rw-r--r--src/mpc-hc/PPageInternalFilters.cpp668
-rw-r--r--src/mpc-hc/PPageInternalFilters.h70
-rw-r--r--src/mpc-hc/PPageLogo.cpp198
-rw-r--r--src/mpc-hc/PPageLogo.h42
-rw-r--r--src/mpc-hc/PPageMisc.cpp257
-rw-r--r--src/mpc-hc/PPageMisc.h68
-rw-r--r--src/mpc-hc/PPageOutput.cpp680
-rw-r--r--src/mpc-hc/PPageOutput.h66
-rw-r--r--src/mpc-hc/PPagePlayback.cpp314
-rw-r--r--src/mpc-hc/PPagePlayback.h70
-rw-r--r--src/mpc-hc/PPagePlayer.cpp240
-rw-r--r--src/mpc-hc/PPagePlayer.h58
-rw-r--r--src/mpc-hc/PPageSheet.cpp110
-rw-r--r--src/mpc-hc/PPageSheet.h66
-rw-r--r--src/mpc-hc/PPageSubMisc.cpp112
-rw-r--r--src/mpc-hc/PPageSubMisc.h36
-rw-r--r--src/mpc-hc/PPageSubStyle.cpp416
-rw-r--r--src/mpc-hc/PPageSubStyle.h134
-rw-r--r--src/mpc-hc/PPageSubtitles.cpp262
-rw-r--r--src/mpc-hc/PPageSubtitles.h50
-rw-r--r--src/mpc-hc/PPageSync.cpp172
-rw-r--r--src/mpc-hc/PPageSync.h42
-rw-r--r--src/mpc-hc/PPageTweaks.cpp316
-rw-r--r--src/mpc-hc/PPageTweaks.h56
-rw-r--r--src/mpc-hc/PPageWebServer.cpp374
-rw-r--r--src/mpc-hc/PPageWebServer.h56
-rw-r--r--src/mpc-hc/PlayerBar.cpp96
-rw-r--r--src/mpc-hc/PlayerBar.h18
-rw-r--r--src/mpc-hc/PlayerCaptureBar.cpp38
-rw-r--r--src/mpc-hc/PlayerCaptureBar.h14
-rw-r--r--src/mpc-hc/PlayerCaptureDialog.cpp2732
-rw-r--r--src/mpc-hc/PlayerCaptureDialog.h782
-rw-r--r--src/mpc-hc/PlayerInfoBar.cpp218
-rw-r--r--src/mpc-hc/PlayerInfoBar.h36
-rw-r--r--src/mpc-hc/PlayerListCtrl.cpp1380
-rw-r--r--src/mpc-hc/PlayerListCtrl.h178
-rw-r--r--src/mpc-hc/PlayerNavigationBar.cpp122
-rw-r--r--src/mpc-hc/PlayerNavigationBar.h22
-rw-r--r--src/mpc-hc/PlayerNavigationDialog.cpp240
-rw-r--r--src/mpc-hc/PlayerNavigationDialog.h56
-rw-r--r--src/mpc-hc/PlayerPlaylistBar.cpp2308
-rw-r--r--src/mpc-hc/PlayerPlaylistBar.h150
-rw-r--r--src/mpc-hc/PlayerSeekBar.cpp624
-rw-r--r--src/mpc-hc/PlayerSeekBar.h98
-rw-r--r--src/mpc-hc/PlayerShaderEditorBar.cpp62
-rw-r--r--src/mpc-hc/PlayerShaderEditorBar.h16
-rw-r--r--src/mpc-hc/PlayerStatusBar.cpp540
-rw-r--r--src/mpc-hc/PlayerStatusBar.h64
-rw-r--r--src/mpc-hc/PlayerSubresyncBar.cpp2302
-rw-r--r--src/mpc-hc/PlayerSubresyncBar.h108
-rw-r--r--src/mpc-hc/PlayerToolBar.cpp448
-rw-r--r--src/mpc-hc/PlayerToolBar.h68
-rw-r--r--src/mpc-hc/Playlist.cpp550
-rw-r--r--src/mpc-hc/Playlist.h60
-rw-r--r--src/mpc-hc/PnSPresetsDlg.cpp284
-rw-r--r--src/mpc-hc/PnSPresetsDlg.h58
-rw-r--r--src/mpc-hc/QuicktimeGraph.cpp908
-rw-r--r--src/mpc-hc/QuicktimeGraph.h140
-rw-r--r--src/mpc-hc/RealMediaGraph.cpp910
-rw-r--r--src/mpc-hc/RealMediaGraph.h352
-rw-r--r--src/mpc-hc/RealMediaWindowlessSite.cpp744
-rw-r--r--src/mpc-hc/RealMediaWindowlessSite.h300
-rw-r--r--src/mpc-hc/RegFilterChooserDlg.cpp168
-rw-r--r--src/mpc-hc/RegFilterChooserDlg.h34
-rw-r--r--src/mpc-hc/SaveDlg.cpp356
-rw-r--r--src/mpc-hc/SaveDlg.h42
-rw-r--r--src/mpc-hc/SaveTextFileDialog.cpp68
-rw-r--r--src/mpc-hc/SaveTextFileDialog.h32
-rw-r--r--src/mpc-hc/SaveThumbnailsDialog.cpp50
-rw-r--r--src/mpc-hc/SaveThumbnailsDialog.h28
-rw-r--r--src/mpc-hc/SelectMediaType.cpp54
-rw-r--r--src/mpc-hc/SelectMediaType.h30
-rw-r--r--src/mpc-hc/SettingsDefines.h432
-rw-r--r--src/mpc-hc/ShaderAutoCompleteDlg.cpp260
-rw-r--r--src/mpc-hc/ShaderAutoCompleteDlg.h30
-rw-r--r--src/mpc-hc/ShaderCombineDlg.cpp372
-rw-r--r--src/mpc-hc/ShaderCombineDlg.h54
-rw-r--r--src/mpc-hc/ShaderEditorDlg.cpp648
-rw-r--r--src/mpc-hc/ShaderEditorDlg.h82
-rw-r--r--src/mpc-hc/ShockwaveGraph.cpp316
-rw-r--r--src/mpc-hc/ShockwaveGraph.h94
-rw-r--r--src/mpc-hc/StaticLink.cpp118
-rw-r--r--src/mpc-hc/StaticLink.h66
-rw-r--r--src/mpc-hc/StatusLabel.cpp83
-rw-r--r--src/mpc-hc/StatusLabel.h18
-rw-r--r--src/mpc-hc/SubtitleDlDlg.cpp546
-rw-r--r--src/mpc-hc/SubtitleDlDlg.h110
-rw-r--r--src/mpc-hc/TextPassThruFilter.cpp258
-rw-r--r--src/mpc-hc/TextPassThruFilter.h24
-rw-r--r--src/mpc-hc/TunerScanDlg.cpp272
-rw-r--r--src/mpc-hc/TunerScanDlg.h66
-rw-r--r--src/mpc-hc/UpdateChecker.cpp258
-rw-r--r--src/mpc-hc/UpdateChecker.h63
-rw-r--r--src/mpc-hc/UpdateCheckerDlg.cpp140
-rw-r--r--src/mpc-hc/UpdateCheckerDlg.h32
-rw-r--r--src/mpc-hc/VMROSD.cpp758
-rw-r--r--src/mpc-hc/VMROSD.h174
-rw-r--r--src/mpc-hc/VolumeCtrl.cpp236
-rw-r--r--src/mpc-hc/VolumeCtrl.h28
-rw-r--r--src/mpc-hc/WebClientSocket.cpp1588
-rw-r--r--src/mpc-hc/WebClientSocket.h62
-rw-r--r--src/mpc-hc/WebServer.cpp1172
-rw-r--r--src/mpc-hc/WebServer.h44
-rw-r--r--src/mpc-hc/WebServerSocket.cpp14
-rw-r--r--src/mpc-hc/WebServerSocket.h8
-rw-r--r--src/mpc-hc/WinHotkeyCtrl.cpp344
-rw-r--r--src/mpc-hc/WinHotkeyCtrl.h52
-rw-r--r--src/mpc-hc/mpciconlib/mpciconlib.cpp452
-rw-r--r--src/mpc-hc/mplayerc.cpp3381
-rw-r--r--src/mpc-hc/mplayerc.h167
-rw-r--r--src/mpc-hc/vkCodes.cpp586
542 files changed, 139519 insertions, 139581 deletions
diff --git a/docs/astyle.bat b/docs/astyle.bat
index 27ee2755c..42d74a639 100644
--- a/docs/astyle.bat
+++ b/docs/astyle.bat
@@ -15,10 +15,10 @@ IF %ERRORLEVEL% NEQ 0 (
rem current command
astyle.exe^
- --indent=force-tab --indent-switches --indent-namespaces --indent-col1-comments^
- --pad-header --lineend=windows --preserve-date^
- --keep-one-line-blocks --keep-one-line-statements^
- --suffix=none --ignore-exclude-errors --ignore-exclude-errors-x --recursive^
+ --indent=spaces=4 --style=kr --indent-switches --indent-namespaces --indent-col1-comments^
+ --pad-header --pad-oper --unpad-paren --align-pointer=type --align-reference=type^
+ --add-brackets --lineend=windows --preserve-date --keep-one-line-blocks --keep-one-line-statements^
+ --convert-tabs --suffix=none --ignore-exclude-errors --ignore-exclude-errors-x --recursive^
--exclude=FileVersionInfo.cpp --exclude=FileVersionInfo.h --exclude=LineNumberEdit.cpp^
--exclude=LineNumberEdit.h --exclude=Struct.h --exclude=atl --exclude=avisynth^
--exclude=detours --exclude=dx --exclude=lglcd --exclude=ogg --exclude=qt^
@@ -32,14 +32,7 @@ astyle.exe^
--exclude=H264RandomAccess.cpp --exclude=H264RandomAccess.h --exclude=array_allocator.h^
--exclude=char_t.h --exclude=HScrollListBox.cpp --exclude=HScrollListBox.h ..\*.h ..\*.cpp
-rem TODO: --indent=spaces=4 --style=kr --add-brackets --pad-header --pad-oper --convert-tabs
-rem maybe TODO: --align-pointer=type --align-reference=type: there is a problem when the type isn't known like *dump
-rem --unpad-paren: HANDLE ()-> HANDLE() while the space should be kept
-
-IF %ERRORLEVEL% NEQ 0 (
- ECHO.
- ECHO ERROR: Something went wrong!
-)
+IF %ERRORLEVEL% NEQ 0 ECHO. & ECHO ERROR: Something went wrong!
:END
POPD
diff --git a/include/IBitRateInfo.h b/include/IBitRateInfo.h
index 8e2a79d23..fe0db49b3 100644
--- a/include/IBitRateInfo.h
+++ b/include/IBitRateInfo.h
@@ -26,6 +26,6 @@
interface __declspec(uuid("EB2CD9E6-BA08-4acb-AA0F-3D8D0DD521CA"))
IBitRateInfo :
public IUnknown {
- STDMETHOD_(DWORD, GetCurrentBitRate) () = 0;
- STDMETHOD_(DWORD, GetAverageBitRate) () = 0;
+ STDMETHOD_(DWORD, GetCurrentBitRate)() = 0;
+ STDMETHOD_(DWORD, GetAverageBitRate)() = 0;
};
diff --git a/include/IBufferInfo.h b/include/IBufferInfo.h
index 2e9f62980..504873ee8 100644
--- a/include/IBufferInfo.h
+++ b/include/IBufferInfo.h
@@ -26,7 +26,7 @@
interface __declspec(uuid("46070104-1318-4A82-8822-E99AB7CD15C1"))
IBufferInfo :
public IUnknown {
- STDMETHOD_(int, GetCount()) = 0;
- STDMETHOD(GetStatus(int i, int& samples, int& size)) = 0;
- STDMETHOD_(DWORD, GetPriority()) = 0;
+ STDMETHOD_(int, GetCount()) = 0;
+ STDMETHOD(GetStatus(int i, int & samples, int & size)) = 0;
+ STDMETHOD_(DWORD, GetPriority()) = 0;
};
diff --git a/include/IChapterInfo.h b/include/IChapterInfo.h
index f0dfaa6dc..f94eb1d6a 100644
--- a/include/IChapterInfo.h
+++ b/include/IChapterInfo.h
@@ -24,46 +24,46 @@
#pragma once
typedef enum ChapterType {
- AtomicChapter = 0, // only contain one element
- SubChapter = 1, // contain a list of elements
+ AtomicChapter = 0, // only contain one element
+ SubChapter = 1, // contain a list of elements
};
#pragma pack(push, 1)
struct ChapterElement {
- WORD Size; // size of this structure
- BYTE Type; // see ChapterType
- UINT ChapterId; // unique identifier for this element
- REFERENCE_TIME rtStart; // REFERENCE_TIME in 100ns
- REFERENCE_TIME rtStop; // REFERENCE_TIME in 100ns
- struct ChapterElement() {
- Size = sizeof(*this);
- }
+ WORD Size; // size of this structure
+ BYTE Type; // see ChapterType
+ UINT ChapterId; // unique identifier for this element
+ REFERENCE_TIME rtStart; // REFERENCE_TIME in 100ns
+ REFERENCE_TIME rtStop; // REFERENCE_TIME in 100ns
+ struct ChapterElement() {
+ Size = sizeof(*this);
+ }
};
struct ChapterElement2 : ChapterElement {
- BOOL bDisabled;
- struct ChapterElement2() {
- Size = sizeof(*this);
- }
+ BOOL bDisabled;
+ struct ChapterElement2() {
+ Size = sizeof(*this);
+ }
};
#pragma pack(pop)
interface __declspec(uuid("8E128709-3DC8-4e49-B632-380FCF496B6D"))
IChapterInfo :
public IUnknown {
-#define CHAPTER_BAD_ID 0xFFFFFFFF
-#define CHAPTER_ROOT_ID 0
+#define CHAPTER_BAD_ID 0xFFFFFFFF
+#define CHAPTER_ROOT_ID 0
- // \param aChapterID is 0 for the top level one
- STDMETHOD_(UINT, GetChapterCount) (UINT aChapterID) = 0;
+ // \param aChapterID is 0 for the top level one
+ STDMETHOD_(UINT, GetChapterCount)(UINT aChapterID) = 0;
- // \param aIndex start from 1 to GetChapterCount( aParentChapterId )
- STDMETHOD_(UINT, GetChapterId) (UINT aParentChapterId, UINT aIndex) = 0;
+ // \param aIndex start from 1 to GetChapterCount( aParentChapterId )
+ STDMETHOD_(UINT, GetChapterId)(UINT aParentChapterId, UINT aIndex) = 0;
- STDMETHOD_(UINT, GetChapterCurrentId) () = 0;
+ STDMETHOD_(UINT, GetChapterCurrentId)() = 0;
- STDMETHOD_(BOOL, GetChapterInfo) (UINT aChapterID, struct ChapterElement* pStructureToFill) = 0;
+ STDMETHOD_(BOOL, GetChapterInfo)(UINT aChapterID, struct ChapterElement * pStructureToFill) = 0;
- // \param PreferredLanguage Language code as in ISO-639-2 (3 chars)
- // \param CountryCode Country code as in internet domains
- STDMETHOD_(BSTR, GetChapterStringInfo) (UINT aChapterID, CHAR PreferredLanguage[3], CHAR CountryCode[2]) = 0;
+ // \param PreferredLanguage Language code as in ISO-639-2 (3 chars)
+ // \param CountryCode Country code as in internet domains
+ STDMETHOD_(BSTR, GetChapterStringInfo)(UINT aChapterID, CHAR PreferredLanguage[3], CHAR CountryCode[2]) = 0;
};
diff --git a/include/IFilterVersion.h b/include/IFilterVersion.h
index 5a2925fc8..b6ec523d7 100644
--- a/include/IFilterVersion.h
+++ b/include/IFilterVersion.h
@@ -26,5 +26,5 @@
interface __declspec(uuid("A0DD28E1-61C0-4539-A7E6-14544AFF092E"))
IFilterVersion :
public IUnknown {
- STDMETHOD_(DWORD, GetFilterVersion) () = 0;
+ STDMETHOD_(DWORD, GetFilterVersion)() = 0;
};
diff --git a/include/IKeyFrameInfo.h b/include/IKeyFrameInfo.h
index ba183857e..7e9164cb9 100644
--- a/include/IKeyFrameInfo.h
+++ b/include/IKeyFrameInfo.h
@@ -26,6 +26,6 @@
interface __declspec(uuid("01A5BBD3-FE71-487C-A2EC-F585918A8724"))
IKeyFrameInfo :
public IUnknown {
- STDMETHOD (GetKeyFrameCount) (UINT& nKFs) = 0; // returns S_FALSE when every frame is a keyframe
- STDMETHOD (GetKeyFrames) (const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs /* in, out*/) = 0;
+ STDMETHOD(GetKeyFrameCount)(UINT & nKFs) = 0; // returns S_FALSE when every frame is a keyframe
+ STDMETHOD(GetKeyFrames)(const GUID * pFormat, REFERENCE_TIME * pKFs, UINT& nKFs /* in, out*/) = 0;
};
diff --git a/include/ITrackInfo.h b/include/ITrackInfo.h
index 68c9c437a..5ebe6646b 100644
--- a/include/ITrackInfo.h
+++ b/include/ITrackInfo.h
@@ -24,44 +24,44 @@
#pragma once
typedef enum TrackType {
- TypeVideo = 1,
- TypeAudio = 2,
- TypeComplex = 3,
- TypeLogo = 0x10,
- TypeSubtitle = 0x11,
- TypeControl = 0x20
+ TypeVideo = 1,
+ TypeAudio = 2,
+ TypeComplex = 3,
+ TypeLogo = 0x10,
+ TypeSubtitle = 0x11,
+ TypeControl = 0x20
};
#pragma pack(push, 1)
struct TrackElement {
- WORD Size; // Size of this structure
- BYTE Type; // See TrackType
- BOOL FlagDefault; // Set if the track is the default for its TrackType.
- BOOL FlagForced; // Set if that track MUST be used during playback.
- BOOL FlagLacing; // Set if the track may contain blocks using lacing.
- UINT MinCache; // The minimum number of frames a player should be able to cache during playback.
- UINT MaxCache; // The maximum cache size required to store referenced frames in and the current frame. 0 means no cache is needed.
- CHAR Language[4]; // Specifies the language of the track, in the ISO-639-2 form. (end with '\0')
+ WORD Size; // Size of this structure
+ BYTE Type; // See TrackType
+ BOOL FlagDefault; // Set if the track is the default for its TrackType.
+ BOOL FlagForced; // Set if that track MUST be used during playback.
+ BOOL FlagLacing; // Set if the track may contain blocks using lacing.
+ UINT MinCache; // The minimum number of frames a player should be able to cache during playback.
+ UINT MaxCache; // The maximum cache size required to store referenced frames in and the current frame. 0 means no cache is needed.
+ CHAR Language[4]; // Specifies the language of the track, in the ISO-639-2 form. (end with '\0')
};
struct TrackExtendedInfoVideo {
- WORD Size; // Size of this structure
- BOOL Interlaced; // Set if the video is interlaced.
- UINT PixelWidth; // Width of the encoded video frames in pixels.
- UINT PixelHeight; // Height of the encoded video frames in pixels.
- UINT DisplayWidth; // Width of the video frames to display.
- UINT DisplayHeight; // Height of the video frames to display.
- BYTE DisplayUnit; // Type of the unit for DisplayWidth/Height (0: pixels, 1: centimeters, 2: inches).
- BYTE AspectRatioType; // Specify the possible modifications to the aspect ratio (0: free resizing, 1: keep aspect ratio, 2: fixed).
+ WORD Size; // Size of this structure
+ BOOL Interlaced; // Set if the video is interlaced.
+ UINT PixelWidth; // Width of the encoded video frames in pixels.
+ UINT PixelHeight; // Height of the encoded video frames in pixels.
+ UINT DisplayWidth; // Width of the video frames to display.
+ UINT DisplayHeight; // Height of the video frames to display.
+ BYTE DisplayUnit; // Type of the unit for DisplayWidth/Height (0: pixels, 1: centimeters, 2: inches).
+ BYTE AspectRatioType; // Specify the possible modifications to the aspect ratio (0: free resizing, 1: keep aspect ratio, 2: fixed).
};
struct TrackExtendedInfoAudio {
- WORD Size; // Size of this structure
- FLOAT SamplingFreq; // Sampling frequency in Hz.
- FLOAT OutputSamplingFrequency; // Real output sampling frequency in Hz (used for SBR techniques).
- UINT Channels; // Numbers of channels in the track.
- UINT BitDepth; // Bits per sample, mostly used for PCM.
+ WORD Size; // Size of this structure
+ FLOAT SamplingFreq; // Sampling frequency in Hz.
+ FLOAT OutputSamplingFrequency; // Real output sampling frequency in Hz (used for SBR techniques).
+ UINT Channels; // Numbers of channels in the track.
+ UINT BitDepth; // Bits per sample, mostly used for PCM.
};
#pragma pack(pop)
@@ -69,17 +69,17 @@ struct TrackExtendedInfoAudio {
interface __declspec(uuid("03E98D51-DDE7-43aa-B70C-42EF84A3A23D"))
ITrackInfo :
public IUnknown {
- STDMETHOD_(UINT, GetTrackCount) () = 0;
+ STDMETHOD_(UINT, GetTrackCount)() = 0;
- // \param aTrackIdx the track index (from 0 to GetTrackCount()-1)
- STDMETHOD_(BOOL, GetTrackInfo) (UINT aTrackIdx, struct TrackElement* pStructureToFill) = 0;
+ // \param aTrackIdx the track index (from 0 to GetTrackCount()-1)
+ STDMETHOD_(BOOL, GetTrackInfo)(UINT aTrackIdx, struct TrackElement * pStructureToFill) = 0;
- // Get an extended information struct relative to the track type
- STDMETHOD_(BOOL, GetTrackExtendedInfo) (UINT aTrackIdx, void* pStructureToFill) = 0;
+ // Get an extended information struct relative to the track type
+ STDMETHOD_(BOOL, GetTrackExtendedInfo)(UINT aTrackIdx, void * pStructureToFill) = 0;
- STDMETHOD_(BSTR, GetTrackCodecID) (UINT aTrackIdx) = 0;
- STDMETHOD_(BSTR, GetTrackName) (UINT aTrackIdx) = 0;
- STDMETHOD_(BSTR, GetTrackCodecName) (UINT aTrackIdx) = 0;
- STDMETHOD_(BSTR, GetTrackCodecInfoURL) (UINT aTrackIdx) = 0;
- STDMETHOD_(BSTR, GetTrackCodecDownloadURL) (UINT aTrackIdx) = 0;
+ STDMETHOD_(BSTR, GetTrackCodecID)(UINT aTrackIdx) = 0;
+ STDMETHOD_(BSTR, GetTrackName)(UINT aTrackIdx) = 0;
+ STDMETHOD_(BSTR, GetTrackCodecName)(UINT aTrackIdx) = 0;
+ STDMETHOD_(BSTR, GetTrackCodecInfoURL)(UINT aTrackIdx) = 0;
+ STDMETHOD_(BSTR, GetTrackCodecDownloadURL)(UINT aTrackIdx) = 0;
};
diff --git a/include/dsm/dsm.h b/include/dsm/dsm.h
index c3ddb7889..c68036ad8 100644
--- a/include/dsm/dsm.h
+++ b/include/dsm/dsm.h
@@ -23,17 +23,17 @@
#pragma once
-#define DSMF_VERSION 0x01
+#define DSMF_VERSION 0x01
-#define DSMSW 0x44534D53ui64
-#define DSMSW_SIZE 4
+#define DSMSW 0x44534D53ui64
+#define DSMSW_SIZE 4
enum dsmp_t {
- DSMP_FILEINFO = 0,
- DSMP_STREAMINFO = 1,
- DSMP_MEDIATYPE = 2,
- DSMP_CHAPTERS = 3,
- DSMP_SAMPLE = 4,
- DSMP_SYNCPOINTS = 5,
- DSMP_RESOURCE = 6
+ DSMP_FILEINFO = 0,
+ DSMP_STREAMINFO = 1,
+ DSMP_MEDIATYPE = 2,
+ DSMP_CHAPTERS = 3,
+ DSMP_SAMPLE = 4,
+ DSMP_SYNCPOINTS = 5,
+ DSMP_RESOURCE = 6
};
diff --git a/include/moreuuids.h b/include/moreuuids.h
index d8480cd10..26c3ec14c 100644
--- a/include/moreuuids.h
+++ b/include/moreuuids.h
@@ -27,209 +27,209 @@
// 30323449-0000-0010-8000-00AA00389B71 'I420' == MEDIASUBTYPE_I420
DEFINE_GUID(MEDIASUBTYPE_I420,
- 0x30323449, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ 0x30323449, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
#define WAVE_FORMAT_DOLBY_AC3 0x2000
// {00002000-0000-0010-8000-00aa00389b71}
DEFINE_GUID(MEDIASUBTYPE_WAVE_DOLBY_AC3,
- WAVE_FORMAT_DOLBY_AC3, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ WAVE_FORMAT_DOLBY_AC3, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
#define WAVE_FORMAT_DVD_DTS 0x2001 // WAVE_FORMAT_DTS2
// {00002001-0000-0010-8000-00aa00389b71}
DEFINE_GUID(MEDIASUBTYPE_WAVE_DTS, // MEDIASUBTYPE_DTS2
- WAVE_FORMAT_DVD_DTS, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ WAVE_FORMAT_DVD_DTS, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
// Be compatible with 3ivx
#define WAVE_FORMAT_AAC 0x00FF // WAVE_FORMAT_RAW_AAC1
// {000000FF-0000-0010-8000-00AA00389B71}
DEFINE_GUID(MEDIASUBTYPE_AAC, // MEDIASUBTYPE_RAW_AAC1
- WAVE_FORMAT_AAC, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ WAVE_FORMAT_AAC, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
#define WAVE_FORMAT_LATM_AAC 0x01FF
// {000001FF-0000-0010-8000-00AA00389B71}
DEFINE_GUID(MEDIASUBTYPE_LATM_AAC,
- WAVE_FORMAT_LATM_AAC, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ WAVE_FORMAT_LATM_AAC, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
// {53544441-0000-0010-8000-00AA00389B71} AAC-ADTS LAVF/LAVC specific
#define WAVE_FORMAT_AAC_ADTS mmioFOURCC('A','D','T','S')
DEFINE_GUID(MEDIASUBTYPE_AAC_ADTS,
- WAVE_FORMAT_AAC_ADTS, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ WAVE_FORMAT_AAC_ADTS, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
// ... and also compatible with nero
// btw, older nero parsers use a lower-case fourcc, newer upper-case (why can't it just offer both?)
// {4134504D-0000-0010-8000-00AA00389B71}
DEFINE_GUID(MEDIASUBTYPE_MP4A,
- 0x4134504D, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ 0x4134504D, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
// {6134706D-0000-0010-8000-00AA00389B71}
DEFINE_GUID(MEDIASUBTYPE_mp4a,
- 0x6134706D, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ 0x6134706D, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
#define WAVE_FORMAT_MP3 0x0055
// 00000055-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_MP3,
- WAVE_FORMAT_MP3, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ WAVE_FORMAT_MP3, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
#define WAVE_FORMAT_FLAC 0xF1AC
// 0000F1AC-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_FLAC,
- WAVE_FORMAT_FLAC, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ WAVE_FORMAT_FLAC, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
// {1541C5C0-CDDF-477d-BC0A-86F8AE7F8354}
DEFINE_GUID(MEDIASUBTYPE_FLAC_FRAMED,
- 0x1541c5c0, 0xcddf, 0x477d, 0xbc, 0xa, 0x86, 0xf8, 0xae, 0x7f, 0x83, 0x54);
+ 0x1541c5c0, 0xcddf, 0x477d, 0xbc, 0xa, 0x86, 0xf8, 0xae, 0x7f, 0x83, 0x54);
#define WAVE_FORMAT_TTA1 0x77A1
// {000077A1-0000-0010-8000-00AA00389B71}
DEFINE_GUID(MEDIASUBTYPE_TTA1,
- WAVE_FORMAT_TTA1, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ WAVE_FORMAT_TTA1, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
#define WAVE_FORMAT_WAVPACK4 0x5756
// {00005756-0000-0010-8000-00AA00389B71}
DEFINE_GUID(MEDIASUBTYPE_WAVPACK4,
- WAVE_FORMAT_WAVPACK4, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ WAVE_FORMAT_WAVPACK4, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
DEFINE_GUID(MEDIASUBTYPE_AMR,
- 0x000000FE, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ 0x000000FE, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
// {726D6173-0000-0010-8000-00AA00389B71}
DEFINE_GUID(MEDIASUBTYPE_SAMR,
- 0x726D6173, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ 0x726D6173, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
DEFINE_GUID(MEDIASUBTYPE_VP80 ,
- 0x30385056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ 0x30385056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
DEFINE_GUID(MEDIASUBTYPE_IMA4,
- 0x34616D69, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ 0x34616D69, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
// {34616D69-0000-0010-8000-00AA00389B71}
DEFINE_GUID(MEDIASUBTYPE_SAWB,
- 0x62776173, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ 0x62776173, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
// {DA5B82EE-6BD2-426f-BF1E-30112DA78AE1}
DEFINE_GUID(MEDIASUBTYPE_SVCD_SUBPICTURE,
- 0xda5b82ee, 0x6bd2, 0x426f, 0xbf, 0x1e, 0x30, 0x11, 0x2d, 0xa7, 0x8a, 0xe1);
+ 0xda5b82ee, 0x6bd2, 0x426f, 0xbf, 0x1e, 0x30, 0x11, 0x2d, 0xa7, 0x8a, 0xe1);
// {7B57308F-5154-4c36-B903-52FE76E184FC}
DEFINE_GUID(MEDIASUBTYPE_CVD_SUBPICTURE,
- 0x7b57308f, 0x5154, 0x4c36, 0xb9, 0x3, 0x52, 0xfe, 0x76, 0xe1, 0x84, 0xfc);
+ 0x7b57308f, 0x5154, 0x4c36, 0xb9, 0x3, 0x52, 0xfe, 0x76, 0xe1, 0x84, 0xfc);
// {0E3A2342-F6E2-4c91-BDAE-87C71EAD0D63}
DEFINE_GUID(MEDIASUBTYPE_MPEG2_PVA,
- 0xe3a2342, 0xf6e2, 0x4c91, 0xbd, 0xae, 0x87, 0xc7, 0x1e, 0xad, 0xd, 0x63);
+ 0xe3a2342, 0xf6e2, 0x4c91, 0xbd, 0xae, 0x87, 0xc7, 0x1e, 0xad, 0xd, 0x63);
// {6B6D0800-9ADA-11d0-A520-00A0D10129C0}
DEFINE_GUID(CLSID_NetShowSource,
- 0x6b6d0800, 0x9ada, 0x11d0, 0xa5, 0x20, 0x0, 0xa0, 0xd1, 0x1, 0x29, 0xc0);
+ 0x6b6d0800, 0x9ada, 0x11d0, 0xa5, 0x20, 0x0, 0xa0, 0xd1, 0x1, 0x29, 0xc0);
// DirectShowMedia
// {5E9C9EE0-2E4A-4f22-9906-7BBBB75AA2B6}
DEFINE_GUID(MEDIASUBTYPE_DirectShowMedia,
- 0x5e9c9ee0, 0x2e4a, 0x4f22, 0x99, 0x6, 0x7b, 0xbb, 0xb7, 0x5a, 0xa2, 0xb6);
+ 0x5e9c9ee0, 0x2e4a, 0x4f22, 0x99, 0x6, 0x7b, 0xbb, 0xb7, 0x5a, 0xa2, 0xb6);
// Dirac
// {A29DA00F-A22B-40ea-98DE-2F7FECADA5DE}
DEFINE_GUID(MEDIASUBTYPE_Dirac,
- 0xa29da00f, 0xa22b, 0x40ea, 0x98, 0xde, 0x2f, 0x7f, 0xec, 0xad, 0xa5, 0xde);
+ 0xa29da00f, 0xa22b, 0x40ea, 0x98, 0xde, 0x2f, 0x7f, 0xec, 0xad, 0xa5, 0xde);
// {64726376-0000-0010-8000-00AA00389B71}
DEFINE_GUID(MEDIASUBTYPE_DiracVideo,
- 0x64726376, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ 0x64726376, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
// {D2667A7E-4055-4244-A65F-DDDDF2B74BD7}
DEFINE_GUID(FORMAT_DiracVideoInfo,
- 0xd2667a7e, 0x4055, 0x4244, 0xa6, 0x5f, 0xdd, 0xdd, 0xf2, 0xb7, 0x4b, 0xd7);
+ 0xd2667a7e, 0x4055, 0x4244, 0xa6, 0x5f, 0xdd, 0xdd, 0xf2, 0xb7, 0x4b, 0xd7);
struct DIRACINFOHEADER {
- VIDEOINFOHEADER2 hdr;
- DWORD cbSequenceHeader;
- DWORD dwSequenceHeader[1];
+ VIDEOINFOHEADER2 hdr;
+ DWORD cbSequenceHeader;
+ DWORD dwSequenceHeader[1];
};
// MP4
// {08E22ADA-B715-45ed-9D20-7B87750301D4}
DEFINE_GUID(MEDIASUBTYPE_MP4,
- 0x8e22ada, 0xb715, 0x45ed, 0x9d, 0x20, 0x7b, 0x87, 0x75, 0x3, 0x1, 0xd4);
+ 0x8e22ada, 0xb715, 0x45ed, 0x9d, 0x20, 0x7b, 0x87, 0x75, 0x3, 0x1, 0xd4);
// FLV
// {F2FAC0F1-3852-4670-AAC0-9051D400AC54}
DEFINE_GUID(MEDIASUBTYPE_FLV,
- 0xf2fac0f1, 0x3852, 0x4670, 0xaa, 0xc0, 0x90, 0x51, 0xd4, 0x0, 0xac, 0x54);
+ 0xf2fac0f1, 0x3852, 0x4670, 0xaa, 0xc0, 0x90, 0x51, 0xd4, 0x0, 0xac, 0x54);
// 31564C46-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_FLV1,
- 0x31564C46, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x31564C46, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 31766C66-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_flv1,
- 0x31766C66, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x31766C66, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 34564C46-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_FLV4,
- 0x34564C46, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x34564C46, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 34766C66-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_flv4,
- 0x34766C66, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x34766C66, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 30365056-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_VP30,
- 0x30335056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x30335056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 30365056-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_VP31,
- 0x31335056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x31335056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 30355056-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_VP50,
- 0x30355056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x30355056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 30357076-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_vp50,
- 0x30357076, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x30357076, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 30365056-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_VP60,
- 0x30365056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x30365056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 30367076-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_vp60,
- 0x30367076, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x30367076, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 31365056-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_VP61,
- 0x31365056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x31365056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 31367076-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_vp61,
- 0x31367076, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x31367076, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 32365056-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_VP62,
- 0x32365056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x32365056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 32367076-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_vp62,
- 0x32367076, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x32367076, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 41365056-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_VP6A,
- 0x41365056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x41365056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 61367076-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_vp6a,
- 0x61367076, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x61367076, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 46365056-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_VP6F,
- 0x46365056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x46365056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 66367076-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_vp6f,
- 0x66367076, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x66367076, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
//
// RealMedia
@@ -237,119 +237,119 @@ DEFINE_GUID(MEDIASUBTYPE_vp6f,
// {57428EC6-C2B2-44a2-AA9C-28F0B6A5C48E}
DEFINE_GUID(MEDIASUBTYPE_RealMedia,
- 0x57428ec6, 0xc2b2, 0x44a2, 0xaa, 0x9c, 0x28, 0xf0, 0xb6, 0xa5, 0xc4, 0x8e);
+ 0x57428ec6, 0xc2b2, 0x44a2, 0xaa, 0x9c, 0x28, 0xf0, 0xb6, 0xa5, 0xc4, 0x8e);
// 30315652-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_RV10,
- 0x30315652, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x30315652, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 30325652-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_RV20,
- 0x30325652, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x30325652, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 30335652-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_RV30,
- 0x30335652, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x30335652, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 30345652-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_RV40,
- 0x30345652, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x30345652, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 31345652-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_RV41,
- 0x31345652, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x31345652, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 345f3431-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_14_4,
- 0x345f3431, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x345f3431, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 385f3832-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_28_8,
- 0x385f3832, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x385f3832, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 43525441-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_ATRC,
- 0x43525441, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x43525441, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 4b4f4f43-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_COOK,
- 0x4b4f4f43, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x4b4f4f43, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 54454e44-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_DNET,
- 0x54454e44, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x54454e44, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 52504953-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_SIPR,
- 0x52504953, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x52504953, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 43414152-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_RAAC,
- 0x43414152, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x43414152, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 50434152-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_RACP,
- 0x50434152, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x50434152, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// QuickTime PCM
// 454E4F4E-0000-0010-8000-00AA00389B71 (unsigned 8-bit)
DEFINE_GUID(MEDIASUBTYPE_PCM_NONE,
- 0x454E4F4E, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x454E4F4E, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 20776172-0000-0010-8000-00AA00389B71 (unsigned 8-bit, signed big-endian 16 bit)
DEFINE_GUID(MEDIASUBTYPE_PCM_RAW,
- 0x20776172, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x20776172, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 736f7774-0000-0010-8000-00AA00389B71 (signed 8-bit, signed big-endian 16-bit)
DEFINE_GUID(MEDIASUBTYPE_PCM_TWOS,
- 0x736f7774, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x736f7774, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 74776f73-0000-0010-8000-00AA00389B71 (signed 8-bit, signed little-endian 16-bit)
DEFINE_GUID(MEDIASUBTYPE_PCM_SOWT,
- 0x74776f73, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x74776f73, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 34326E69-0000-0010-8000-00AA00389B71 (signed big-endian int24)
DEFINE_GUID(MEDIASUBTYPE_PCM_IN24,
- 0x34326E69, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x34326E69, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 32336E69-0000-0010-8000-00AA00389B71 (signed big-endian int32)
DEFINE_GUID(MEDIASUBTYPE_PCM_IN32,
- 0x32336E69, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x32336E69, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 32336C66-0000-0010-8000-00AA00389B71 (signed big-endian float32)
DEFINE_GUID(MEDIASUBTYPE_PCM_FL32,
- 0x32336C66, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x32336C66, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 34366C66-0000-0010-8000-00AA00389B71 (signed big-endian float64)
DEFINE_GUID(MEDIASUBTYPE_PCM_FL64,
- 0x34366C66, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x34366C66, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
/*
// Reverse GUIDs for little-endian 'in24', 'in32', 'fl32', 'fl64'
// 696E3234-0000-0010-8000-00AA00389B71 (signed little-endian int24, reverse 'in24')
DEFINE_GUID(MEDIASUBTYPE_PCM_IN24_le,
- 0x696E3234, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x696E3234, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 696E3332-0000-0010-8000-00AA00389B71 (signed little-endian int32, reverse 'in32')
DEFINE_GUID(MEDIASUBTYPE_PCM_IN32_le,
- 0x696E3332, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x696E3332, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 666C3332-0000-0010-8000-00AA00389B71 (signed little-endian float32, reverse 'fl32')
DEFINE_GUID(MEDIASUBTYPE_PCM_FL32_le,
- 0x666C3332, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x666C3332, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 666C3634-0000-0010-8000-00AA00389B71 (signed little-endian float64, reverse 'fl64')
DEFINE_GUID(MEDIASUBTYPE_PCM_FL64_le,
- 0x666C3634, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x666C3634, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
*/
enum {
- WAVE_FORMAT_14_4 = 0x2002,
- WAVE_FORMAT_28_8 = 0x2003,
- WAVE_FORMAT_ATRC = 0x0270, //WAVE_FORMAT_SONY_SCX,
- WAVE_FORMAT_COOK = 0x2004,
- WAVE_FORMAT_DNET = 0x2005,
- WAVE_FORMAT_RAAC = 0x2006,
- WAVE_FORMAT_RACP = 0x2007,
- WAVE_FORMAT_SIPR = 0x0130, //WAVE_FORMAT_SIPROLAB_ACEPLNET,
+ WAVE_FORMAT_14_4 = 0x2002,
+ WAVE_FORMAT_28_8 = 0x2003,
+ WAVE_FORMAT_ATRC = 0x0270, //WAVE_FORMAT_SONY_SCX,
+ WAVE_FORMAT_COOK = 0x2004,
+ WAVE_FORMAT_DNET = 0x2005,
+ WAVE_FORMAT_RAAC = 0x2006,
+ WAVE_FORMAT_RACP = 0x2007,
+ WAVE_FORMAT_SIPR = 0x0130, //WAVE_FORMAT_SIPROLAB_ACEPLNET,
};
//
@@ -359,44 +359,44 @@ enum {
#define WAVE_FORMAT_PS2_PCM 0xF521
// 0000F521-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_PS2_PCM,
- WAVE_FORMAT_PS2_PCM, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ WAVE_FORMAT_PS2_PCM, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
#define WAVE_FORMAT_PS2_ADPCM 0xF522
// 0000F522-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_PS2_ADPCM,
- WAVE_FORMAT_PS2_ADPCM, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ WAVE_FORMAT_PS2_ADPCM, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
#define WAVE_FORMAT_ADPCM_SWF 0x5346
// 00005346-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_ADPCM_SWF,
- WAVE_FORMAT_ADPCM_SWF, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ WAVE_FORMAT_ADPCM_SWF, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
// 00005346-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_ADPCM_AMV,
- 0x41564D41, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ 0x41564D41, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
struct WAVEFORMATEXPS2 : public WAVEFORMATEX {
- DWORD dwInterleave;
+ DWORD dwInterleave;
- struct WAVEFORMATEXPS2() {
- memset(this, 0, sizeof(*this));
- cbSize = sizeof(WAVEFORMATEXPS2) - sizeof(WAVEFORMATEX);
- }
+ struct WAVEFORMATEXPS2() {
+ memset(this, 0, sizeof(*this));
+ cbSize = sizeof(WAVEFORMATEXPS2) - sizeof(WAVEFORMATEX);
+ }
};
// {4F3D3D21-6D7C-4f73-AA05-E397B5EAE0AA}
DEFINE_GUID(MEDIASUBTYPE_PS2_SUB,
- 0x4f3d3d21, 0x6d7c, 0x4f73, 0xaa, 0x5, 0xe3, 0x97, 0xb5, 0xea, 0xe0, 0xaa);
+ 0x4f3d3d21, 0x6d7c, 0x4f73, 0xaa, 0x5, 0xe3, 0x97, 0xb5, 0xea, 0xe0, 0xaa);
// Haali's video renderer
// {760A8F35-97E7-479d-AAF5-DA9EFF95D751}
DEFINE_GUID(CLSID_DXR,
- 0x760a8f35, 0x97e7, 0x479d, 0xaa, 0xf5, 0xda, 0x9e, 0xff, 0x95, 0xd7, 0x51);
+ 0x760a8f35, 0x97e7, 0x479d, 0xaa, 0xf5, 0xda, 0x9e, 0xff, 0x95, 0xd7, 0x51);
DEFINE_GUID(CLSID_madVR,
- 0xe1a8b82a, 0x32ce, 0x4b0d, 0xbe, 0x0d, 0xaa, 0x68, 0xc7, 0x72, 0xe4, 0x23);
+ 0xe1a8b82a, 0x32ce, 0x4b0d, 0xbe, 0x0d, 0xaa, 0x68, 0xc7, 0x72, 0xe4, 0x23);
//
// Ogg
@@ -404,71 +404,71 @@ DEFINE_GUID(CLSID_madVR,
// f07e245f-5a1f-4d1e-8bff-dc31d84a55ab
DEFINE_GUID(CLSID_OggSplitter,
- 0xf07e245f, 0x5a1f, 0x4d1e, 0x8b, 0xff, 0xdc, 0x31, 0xd8, 0x4a, 0x55, 0xab);
+ 0xf07e245f, 0x5a1f, 0x4d1e, 0x8b, 0xff, 0xdc, 0x31, 0xd8, 0x4a, 0x55, 0xab);
// {078C3DAA-9E58-4d42-9E1C-7C8EE79539C5}
DEFINE_GUID(CLSID_OggSplitPropPage,
- 0x78c3daa, 0x9e58, 0x4d42, 0x9e, 0x1c, 0x7c, 0x8e, 0xe7, 0x95, 0x39, 0xc5);
+ 0x78c3daa, 0x9e58, 0x4d42, 0x9e, 0x1c, 0x7c, 0x8e, 0xe7, 0x95, 0x39, 0xc5);
// 8cae96b7-85b1-4605-b23c-17ff5262b296
DEFINE_GUID(CLSID_OggMux,
- 0x8cae96b7, 0x85b1, 0x4605, 0xb2, 0x3c, 0x17, 0xff, 0x52, 0x62, 0xb2, 0x96);
+ 0x8cae96b7, 0x85b1, 0x4605, 0xb2, 0x3c, 0x17, 0xff, 0x52, 0x62, 0xb2, 0x96);
// {AB97AFC3-D08E-4e2d-98E0-AEE6D4634BA4}
DEFINE_GUID(CLSID_OggMuxPropPage,
- 0xab97afc3, 0xd08e, 0x4e2d, 0x98, 0xe0, 0xae, 0xe6, 0xd4, 0x63, 0x4b, 0xa4);
+ 0xab97afc3, 0xd08e, 0x4e2d, 0x98, 0xe0, 0xae, 0xe6, 0xd4, 0x63, 0x4b, 0xa4);
// {889EF574-0656-4B52-9091-072E52BB1B80}
DEFINE_GUID(CLSID_VorbisEnc,
- 0x889ef574, 0x0656, 0x4b52, 0x90, 0x91, 0x07, 0x2e, 0x52, 0xbb, 0x1b, 0x80);
+ 0x889ef574, 0x0656, 0x4b52, 0x90, 0x91, 0x07, 0x2e, 0x52, 0xbb, 0x1b, 0x80);
// {c5379125-fd36-4277-a7cd-fab469ef3a2f}
DEFINE_GUID(CLSID_VorbisEncPropPage,
- 0xc5379125, 0xfd36, 0x4277, 0xa7, 0xcd, 0xfa, 0xb4, 0x69, 0xef, 0x3a, 0x2f);
+ 0xc5379125, 0xfd36, 0x4277, 0xa7, 0xcd, 0xfa, 0xb4, 0x69, 0xef, 0x3a, 0x2f);
// 02391f44-2767-4e6a-a484-9b47b506f3a4
DEFINE_GUID(CLSID_VorbisDec,
- 0x02391f44, 0x2767, 0x4e6a, 0xa4, 0x84, 0x9b, 0x47, 0xb5, 0x06, 0xf3, 0xa4);
+ 0x02391f44, 0x2767, 0x4e6a, 0xa4, 0x84, 0x9b, 0x47, 0xb5, 0x06, 0xf3, 0xa4);
// 77983549-ffda-4a88-b48f-b924e8d1f01c
DEFINE_GUID(CLSID_OggDSAboutPage,
- 0x77983549, 0xffda, 0x4a88, 0xb4, 0x8f, 0xb9, 0x24, 0xe8, 0xd1, 0xf0, 0x1c);
+ 0x77983549, 0xffda, 0x4a88, 0xb4, 0x8f, 0xb9, 0x24, 0xe8, 0xd1, 0xf0, 0x1c);
// {D2855FA9-61A7-4db0-B979-71F297C17A04}
DEFINE_GUID(MEDIASUBTYPE_Ogg,
- 0xd2855fa9, 0x61a7, 0x4db0, 0xb9, 0x79, 0x71, 0xf2, 0x97, 0xc1, 0x7a, 0x4);
+ 0xd2855fa9, 0x61a7, 0x4db0, 0xb9, 0x79, 0x71, 0xf2, 0x97, 0xc1, 0x7a, 0x4);
// cddca2d5-6d75-4f98-840e-737bedd5c63b
DEFINE_GUID(MEDIASUBTYPE_Vorbis,
- 0xcddca2d5, 0x6d75, 0x4f98, 0x84, 0x0e, 0x73, 0x7b, 0xed, 0xd5, 0xc6, 0x3b);
+ 0xcddca2d5, 0x6d75, 0x4f98, 0x84, 0x0e, 0x73, 0x7b, 0xed, 0xd5, 0xc6, 0x3b);
// 6bddfa7e-9f22-46a9-ab5e-884eff294d9f
DEFINE_GUID(FORMAT_VorbisFormat,
- 0x6bddfa7e, 0x9f22, 0x46a9, 0xab, 0x5e, 0x88, 0x4e, 0xff, 0x29, 0x4d, 0x9f);
+ 0x6bddfa7e, 0x9f22, 0x46a9, 0xab, 0x5e, 0x88, 0x4e, 0xff, 0x29, 0x4d, 0x9f);
typedef struct tagVORBISFORMAT {
- WORD nChannels;
- DWORD nSamplesPerSec;
- DWORD nMinBitsPerSec;
- DWORD nAvgBitsPerSec;
- DWORD nMaxBitsPerSec;
- float fQuality;
-} VORBISFORMAT, *PVORBISFORMAT, FAR *LPVORBISFORMAT;
+ WORD nChannels;
+ DWORD nSamplesPerSec;
+ DWORD nMinBitsPerSec;
+ DWORD nAvgBitsPerSec;
+ DWORD nMaxBitsPerSec;
+ float fQuality;
+} VORBISFORMAT, *PVORBISFORMAT, FAR* LPVORBISFORMAT;
// {8D2FD10B-5841-4a6b-8905-588FEC1ADED9}
DEFINE_GUID(MEDIASUBTYPE_Vorbis2,
- 0x8d2fd10b, 0x5841, 0x4a6b, 0x89, 0x5, 0x58, 0x8f, 0xec, 0x1a, 0xde, 0xd9);
+ 0x8d2fd10b, 0x5841, 0x4a6b, 0x89, 0x5, 0x58, 0x8f, 0xec, 0x1a, 0xde, 0xd9);
// {B36E107F-A938-4387-93C7-55E966757473}
DEFINE_GUID(FORMAT_VorbisFormat2,
- 0xb36e107f, 0xa938, 0x4387, 0x93, 0xc7, 0x55, 0xe9, 0x66, 0x75, 0x74, 0x73);
+ 0xb36e107f, 0xa938, 0x4387, 0x93, 0xc7, 0x55, 0xe9, 0x66, 0x75, 0x74, 0x73);
typedef struct tagVORBISFORMAT2 {
- DWORD Channels;
- DWORD SamplesPerSec;
- DWORD BitsPerSample;
- DWORD HeaderSize[3]; // 0: Identification, 1: Comment, 2: Setup
-} VORBISFORMAT2, *PVORBISFORMAT2, FAR *LPVORBISFORMAT2;
+ DWORD Channels;
+ DWORD SamplesPerSec;
+ DWORD BitsPerSample;
+ DWORD HeaderSize[3]; // 0: Identification, 1: Comment, 2: Setup
+} VORBISFORMAT2, *PVORBISFORMAT2, FAR* LPVORBISFORMAT2;
//
// Matroska
@@ -476,53 +476,53 @@ typedef struct tagVORBISFORMAT2 {
// {1AC0BEBD-4D2B-45ad-BCEB-F2C41C5E3788}
DEFINE_GUID(MEDIASUBTYPE_Matroska,
- 0x1ac0bebd, 0x4d2b, 0x45ad, 0xbc, 0xeb, 0xf2, 0xc4, 0x1c, 0x5e, 0x37, 0x88);
+ 0x1ac0bebd, 0x4d2b, 0x45ad, 0xbc, 0xeb, 0xf2, 0xc4, 0x1c, 0x5e, 0x37, 0x88);
// {E487EB08-6B26-4be9-9DD3-993434D313FD}
DEFINE_GUID(MEDIATYPE_Subtitle,
- 0xe487eb08, 0x6b26, 0x4be9, 0x9d, 0xd3, 0x99, 0x34, 0x34, 0xd3, 0x13, 0xfd);
+ 0xe487eb08, 0x6b26, 0x4be9, 0x9d, 0xd3, 0x99, 0x34, 0x34, 0xd3, 0x13, 0xfd);
// {87C0B230-03A8-4fdf-8010-B27A5848200D}
DEFINE_GUID(MEDIASUBTYPE_UTF8,
- 0x87c0b230, 0x3a8, 0x4fdf, 0x80, 0x10, 0xb2, 0x7a, 0x58, 0x48, 0x20, 0xd);
+ 0x87c0b230, 0x3a8, 0x4fdf, 0x80, 0x10, 0xb2, 0x7a, 0x58, 0x48, 0x20, 0xd);
// {3020560F-255A-4ddc-806E-6C5CC6DCD70A}
DEFINE_GUID(MEDIASUBTYPE_SSA,
- 0x3020560f, 0x255a, 0x4ddc, 0x80, 0x6e, 0x6c, 0x5c, 0xc6, 0xdc, 0xd7, 0xa);
+ 0x3020560f, 0x255a, 0x4ddc, 0x80, 0x6e, 0x6c, 0x5c, 0xc6, 0xdc, 0xd7, 0xa);
// {326444F7-686F-47ff-A4B2-C8C96307B4C2}
DEFINE_GUID(MEDIASUBTYPE_ASS,
- 0x326444f7, 0x686f, 0x47ff, 0xa4, 0xb2, 0xc8, 0xc9, 0x63, 0x7, 0xb4, 0xc2);
+ 0x326444f7, 0x686f, 0x47ff, 0xa4, 0xb2, 0xc8, 0xc9, 0x63, 0x7, 0xb4, 0xc2);
// {370689E7-B226-4f67-978D-F10BC1A9C6AE}
DEFINE_GUID(MEDIASUBTYPE_ASS2,
- 0x370689e7, 0xb226, 0x4f67, 0x97, 0x8d, 0xf1, 0xb, 0xc1, 0xa9, 0xc6, 0xae);
+ 0x370689e7, 0xb226, 0x4f67, 0x97, 0x8d, 0xf1, 0xb, 0xc1, 0xa9, 0xc6, 0xae);
// {76C421C4-DB89-42ec-936E-A9FBC1794714}
DEFINE_GUID(MEDIASUBTYPE_SSF,
- 0x76c421c4, 0xdb89, 0x42ec, 0x93, 0x6e, 0xa9, 0xfb, 0xc1, 0x79, 0x47, 0x14);
+ 0x76c421c4, 0xdb89, 0x42ec, 0x93, 0x6e, 0xa9, 0xfb, 0xc1, 0x79, 0x47, 0x14);
// {B753B29A-0A96-45be-985F-68351D9CAB90}
DEFINE_GUID(MEDIASUBTYPE_USF,
- 0xb753b29a, 0xa96, 0x45be, 0x98, 0x5f, 0x68, 0x35, 0x1d, 0x9c, 0xab, 0x90);
+ 0xb753b29a, 0xa96, 0x45be, 0x98, 0x5f, 0x68, 0x35, 0x1d, 0x9c, 0xab, 0x90);
// {F7239E31-9599-4e43-8DD5-FBAF75CF37F1}
DEFINE_GUID(MEDIASUBTYPE_VOBSUB,
- 0xf7239e31, 0x9599, 0x4e43, 0x8d, 0xd5, 0xfb, 0xaf, 0x75, 0xcf, 0x37, 0xf1);
+ 0xf7239e31, 0x9599, 0x4e43, 0x8d, 0xd5, 0xfb, 0xaf, 0x75, 0xcf, 0x37, 0xf1);
// {A33D2F7D-96BC-4337-B23B-A8B9FBC295E9}
DEFINE_GUID(FORMAT_SubtitleInfo,
- 0xa33d2f7d, 0x96bc, 0x4337, 0xb2, 0x3b, 0xa8, 0xb9, 0xfb, 0xc2, 0x95, 0xe9);
+ 0xa33d2f7d, 0x96bc, 0x4337, 0xb2, 0x3b, 0xa8, 0xb9, 0xfb, 0xc2, 0x95, 0xe9);
// {04EBA53E-9330-436c-9133-553EC87031DC}
DEFINE_GUID(MEDIASUBTYPE_HDMVSUB,
- 0x4eba53e, 0x9330, 0x436c, 0x91, 0x33, 0x55, 0x3e, 0xc8, 0x70, 0x31, 0xdc);
+ 0x4eba53e, 0x9330, 0x436c, 0x91, 0x33, 0x55, 0x3e, 0xc8, 0x70, 0x31, 0xdc);
#pragma pack(push, 1)
typedef struct {
- DWORD dwOffset;
- CHAR IsoLang[4]; // three letter lang code + terminating zero
- WCHAR TrackName[256]; // 256 chars ought to be enough for everyone :)
+ DWORD dwOffset;
+ CHAR IsoLang[4]; // three letter lang code + terminating zero
+ WCHAR TrackName[256]; // 256 chars ought to be enough for everyone :)
} SUBTITLEINFO;
#pragma pack(pop)
@@ -580,18 +580,18 @@ typedef struct {
// Matroska CodecID mappings
// ------------------------
//
-// S_TEXT/ASCII <-> MEDIATYPE_Text MEDIASUBTYPE_NULL FORMAT_None
-// S_TEXT/UTF8 <-> MEDIATYPE_Subtitle MEDIASUBTYPE_UTF8 FORMAT_SubtitleInfo
-// S_TEXT/SSA <-> MEDIATYPE_Subtitle MEDIASUBTYPE_SSA FORMAT_SubtitleInfo
-// S_TEXT/ASS <-> MEDIATYPE_Subtitle MEDIASUBTYPE_ASS FORMAT_SubtitleInfo
-// S_TEXT/USF <-> MEDIATYPE_Subtitle MEDIASUBTYPE_USF FORMAT_SubtitleInfo
-// S_VOBSUB <-> MEDIATYPE_Subtitle MEDIASUBTYPE_VOBSUB FORMAT_SubtitleInfo
-// S_VOBSUB/ZLIB<-> MEDIATYPE_Subtitle MEDIASUBTYPE_VOBSUB FORMAT_SubtitleInfo
+// S_TEXT/ASCII <-> MEDIATYPE_Text MEDIASUBTYPE_NULL FORMAT_None
+// S_TEXT/UTF8 <-> MEDIATYPE_Subtitle MEDIASUBTYPE_UTF8 FORMAT_SubtitleInfo
+// S_TEXT/SSA <-> MEDIATYPE_Subtitle MEDIASUBTYPE_SSA FORMAT_SubtitleInfo
+// S_TEXT/ASS <-> MEDIATYPE_Subtitle MEDIASUBTYPE_ASS FORMAT_SubtitleInfo
+// S_TEXT/USF <-> MEDIATYPE_Subtitle MEDIASUBTYPE_USF FORMAT_SubtitleInfo
+// S_VOBSUB <-> MEDIATYPE_Subtitle MEDIASUBTYPE_VOBSUB FORMAT_SubtitleInfo
+// S_VOBSUB/ZLIB<-> MEDIATYPE_Subtitle MEDIASUBTYPE_VOBSUB FORMAT_SubtitleInfo
//
/*
DEFINE_GUID( MEDIATYPE_MPEG2_SECTIONS,
- 0x455f176c, 0x4b06, 0x47ce, 0x9a, 0xef, 0x8c, 0xae, 0xf7, 0x3d, 0xf7, 0xb5);
+ 0x455f176c, 0x4b06, 0x47ce, 0x9a, 0xef, 0x8c, 0xae, 0xf7, 0x3d, 0xf7, 0xb5);
DEFINE_GUID(MEDIASUBTYPE_ATSC_SI,
0xb3c7397c, 0xd303, 0x414d, 0xb3, 0x3c, 0x4e, 0xd2, 0xc9, 0xd2, 0x97, 0x33);
@@ -613,560 +613,558 @@ DEFINE_GUID(MEDIASUBTYPE_MPEG2DATA,
// 34363268-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_h264,
- 0x34363268, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x34363268, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 34363258-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_X264,
- 0x34363258, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x34363258, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 34363278-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_x264,
- 0x34363278, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x34363278, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 6F29D2AD-E130-45AA-B42F-F623AD354A90
DEFINE_GUID(MEDIASUBTYPE_ArcsoftH264,
- 0x6F29D2AD, 0xE130, 0x45AA, 0xB4, 0x2F, 0xF6, 0x23, 0xAD, 0x35, 0x4A, 0x90);
+ 0x6F29D2AD, 0xE130, 0x45AA, 0xB4, 0x2F, 0xF6, 0x23, 0xAD, 0x35, 0x4A, 0x90);
// 48535356-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_VSSH,
- 0x48535356, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x48535356, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 68737376-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_vssh,
- 0x68737376, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x68737376, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 43564144-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_DAVC,
- 0x43564144, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x43564144, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 63766164-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_davc,
- 0x63766164, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x63766164, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 43564150-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_PAVC,
- 0x43564150, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x43564150, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 63766170-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_pavc,
- 0x63766170, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x63766170, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 31435641-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_AVC1,
- 0x31435641, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x31435641, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 31637661-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_avc1,
- 0x31637661, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x31637661, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 31564343-0000-0010-8000-00AA00389B71 (custom H.264 FourCC used by Haali Media Splitter)
DEFINE_GUID(MEDIASUBTYPE_CCV1,
- 0x31564343, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x31564343, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
-// 8D2D71CB-243F-45E3-B2D8-5FD7967EC09B <= Used by MediaPortal for example...
+// 8D2D71CB-243F-45E3-B2D8-5FD7967EC09B <= Used by MediaPortal for example...
DEFINE_GUID(MEDIASUBTYPE_H264_bis,
- 0x8D2D71CB, 0x243F, 0x45E3, 0xB2, 0xD8, 0x5F, 0xD7, 0x96, 0x7E, 0xC0, 0x9B);
+ 0x8D2D71CB, 0x243F, 0x45E3, 0xB2, 0xD8, 0x5F, 0xD7, 0x96, 0x7E, 0xC0, 0x9B);
// 33515653-0000-0010-8000-00aa00389b71
DEFINE_GUID(MEDIASUBTYPE_SVQ3,
- 0x33515653, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x33515653, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 56564D41-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_XVID,
- 0x44495658, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x44495658, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 56564D41-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_xvid,
- 0x64697678, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x64697678, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 30355844-0000-0010-8000-00aa00389b71
DEFINE_GUID(MEDIASUBTYPE_DX50,
- 0x30355844, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x30355844, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 30357864-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_dx50,
- 0x30357864, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x30357864, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 56564D41-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_DIVX,
- 0x58564944, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x58564944, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 78766964-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_divx,
- 0x78766964, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x78766964, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 5634504d-0000-0010-8000-00aa00389b71
DEFINE_GUID(MEDIASUBTYPE_MP4V,
- 0x5634504d, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x5634504d, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 7634706D-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_mp4v,
- 0x7634706D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x7634706D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 3273346d-0000-0010-8000-00aa00389b71
DEFINE_GUID(MEDIASUBTYPE_M4S2,
- 0x3273346d, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x3273346d, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 3273346D-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_m4s2,
- 0x3273346D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x3273346D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 5334504D-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_MP4S,
- 0x5334504D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x5334504D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 7334706D-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_mp4s,
- 0x7334706D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x7334706D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 31564933-0000-0010-8000-00aa00389b71
DEFINE_GUID(MEDIASUBTYPE_3IV1,
- 0x31564933, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x31564933, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 31766933-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_3iv1,
- 0x31766933, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x31766933, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 32564933-0000-0010-8000-00aa00389b71
DEFINE_GUID(MEDIASUBTYPE_3IV2,
- 0x32564933, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x32564933, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 32766933-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_3iv2,
- 0x32766933, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x32766933, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 58564933-0000-0010-8000-00aa00389b71
DEFINE_GUID(MEDIASUBTYPE_3IVX,
- 0x58564933, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x58564933, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 78766933-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_3ivx,
- 0x78766933, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x78766933, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 305A4C42-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_BLZ0,
- 0x305A4C42, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x305A4C42, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 307A6C62-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_blz0,
- 0x307A6C62, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x307A6C62, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 56344D44-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_DM4V,
- 0x56344D44, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x56344D44, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 76346D64-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_dm4v,
- 0x76346D64, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x76346D64, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 4D475844-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_DXGM,
- 0x4D475844, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x4D475844, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 6D677864-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_dxgm,
- 0x6D677864, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x6D677864, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 53444646-0000-0010-8000-00aa00389b71
DEFINE_GUID(MEDIASUBTYPE_FFDS,
- 0x53444646, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x53444646, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 73646666-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_ffds,
- 0x73646666, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x73646666, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 57465646-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_FVFW,
- 0x57465646, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x57465646, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 77667666-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_fvfw,
- 0x77667666, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x77667666, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 34504D46-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_FMP4,
- 0x34504D46, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x34504D46, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 34706D66-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_fmp4,
- 0x34706D66, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x34706D66, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 34584448-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_HDX4,
- 0x34584448, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x34584448, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 34786468-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_hdx4,
- 0x34786468, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x34786468, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 34504D4C-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_LMP4,
- 0x34504D4C, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x34504D4C, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 34706D6C-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_lmp4,
- 0x34706D6C, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x34706D6C, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 4749444E-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_NDIG,
- 0x4749444E, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x4749444E, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 6769646E-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_ndig,
- 0x6769646E, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x6769646E, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 34504D52-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_RMP4,
- 0x34504D52, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x34504D52, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 34706D72-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_rmp4,
- 0x34706D72, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x34706D72, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 34504D53-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_SMP4,
- 0x34504D53, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x34504D53, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 34706D73-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_smp4,
- 0x34706D73, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x34706D73, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 47444553-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_SEDG,
- 0x47444553, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x47444553, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 67646573-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_sedg,
- 0x67646573, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x67646573, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 34504D55-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_UMP4,
- 0x34504D55, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x34504D55, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 34706D75-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_ump4,
- 0x34706D75, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x34706D75, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 46315657-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_WV1F,
- 0x46315657, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x46315657, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 66317677-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_wv1f,
- 0x66317677, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x66317677, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 58495658-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_XVIX,
- 0x58495658, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x58495658, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 78697678-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_xvix,
- 0x78697678, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x78697678, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 31564D57-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_WMV1,
- 0x31564D57, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x31564D57, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 31766D77-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_wmv1,
- 0x31766D77, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x31766D77, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 32564D57-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_WMV2,
- 0x32564D57, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x32564D57, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 32766D77-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_wmv2,
- 0x32766D77, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x32766D77, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 31564D57-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_WMV3,
- 0x33564D57, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x33564D57, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 33766D77-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_wmv3,
- 0x33766D77, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x33766D77, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 31515653-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_SVQ1,
- 0x31515653, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x31515653, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 33363248-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_H263,
- 0x33363248, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x33363248, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 33363268-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_h263,
- 0x33363268, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x33363268, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
DEFINE_GUID(MEDIASUBTYPE_S263,
- 0x33363273, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x33363273, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 33363273-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_s263,
- 0x33363273, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x33363273, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 56564D41-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_AMVV,
- 0x56564D41, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x56564D41, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 31435657-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_WVC1,
- 0x31435657, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x31435657, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// D979F77B-DBEA-4BF6-9E6D-1D7E57FBAD53
DEFINE_GUID(MEDIASUBTYPE_WVC1_CYBERLINK,
- 0xD979F77B, 0xDBEA, 0x4BF6, 0x9E, 0x6D, 0x1D, 0x7E, 0x57, 0xFB, 0xAD, 0x53);
+ 0xD979F77B, 0xDBEA, 0x4BF6, 0x9E, 0x6D, 0x1D, 0x7E, 0x57, 0xFB, 0xAD, 0x53);
// 629B40AD-AD74-4EF4-A985-F0C8D92E5ECA
DEFINE_GUID(MEDIASUBTYPE_WVC1_ARCSOFT,
- 0x629B40AD, 0xAD74, 0x4EF4, 0xA9, 0x85, 0xF0, 0xC8, 0xD9, 0x2E, 0x5E, 0xCA);
+ 0x629B40AD, 0xAD74, 0x4EF4, 0xA9, 0x85, 0xF0, 0xC8, 0xD9, 0x2E, 0x5E, 0xCA);
// 31637677-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_wvc1,
- 0x31637677, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x31637677, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 3334504D-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_MP43,
- 0x3334504D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x3334504D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 3334706D-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_mp43,
- 0x3334706D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x3334706D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 33585644-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_DVX3,
- 0x33585644, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x33585644, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 33787664-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_dvx3,
- 0x33787664, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x33787664, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 33564944-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_DIV3,
- 0x33564944, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x33564944, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 33766964-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_div3,
- 0x33766964, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x33766964, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 314C4F43-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_COL1,
- 0x314C4F43, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x314C4F43, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 316C6F63-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_col1,
- 0x316C6F63, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x316C6F63, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 34564944-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_DIV4,
- 0x34564944, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x34564944, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 34766964-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_div4,
- 0x34766964, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x34766964, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 35564944-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_DIV5,
- 0x35564944, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x35564944, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 35766964-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_div5,
- 0x35766964, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x35766964, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 36564944-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_DIV6,
- 0x36564944, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x36564944, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 36766964-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_div6,
- 0x36766964, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x36766964, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 31345041-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_AP41,
- 0x31345041, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x31345041, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 31347061-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_ap41,
- 0x31347061, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x31347061, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 3347504D-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_MPG3,
- 0x3347504D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x3347504D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 3367706D-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_mpg3,
- 0x3367706D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x3367706D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 3234504D-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_MP42,
- 0x3234504D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x3234504D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 3234706D-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_mp42,
- 0x3234706D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x3234706D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 32564944-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_DIV2,
- 0x32564944, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x32564944, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 32766964-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_div2,
- 0x32766964, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x32766964, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 3447504D-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_MPG4,
- 0x3447504D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x3447504D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 3467706D-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_mpg4,
- 0x3467706D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x3467706D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 31564944-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_DIV1,
- 0x31564944, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x31564944, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 31766964-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_div1,
- 0x31766964, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x31766964, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 3134504D-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_MP41,
- 0x3134504D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x3134504D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 3134706D-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_mp41,
- 0x3134706D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x3134706D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 4F454854-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_THEORA,
- 0x4F454854, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x4F454854, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 6F656874-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_theora,
- 0x6F656874, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x6F656874, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
DEFINE_GUID(FORMAT_RLTheora,
- 0xe69b30d1, 0x7d65, 0x4166, 0xb9, 0x90, 0x10, 0x3d, 0xa8, 0xc9, 0x11, 0xe3 );
+ 0xe69b30d1, 0x7d65, 0x4166, 0xb9, 0x90, 0x10, 0x3d, 0xa8, 0xc9, 0x11, 0xe3);
// 63637374-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_TSCC,
- 0x63637374, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x63637374, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 30355649-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_IV50,
- 0x30355649, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x30355649, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 31345649-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_IV41,
- 0x31345649, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x31345649, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 31335649-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_IV31,
- 0x31335649, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x31335649, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 32335649-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_IV32,
- 0x32335649, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x32335649, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 61706A6D-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_MJPA,
- 0x61706A6D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x61706A6D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// 62706A6D-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_MJPB,
- 0x62706A6D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x62706A6D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// {3267706D-0000-0010-8000-00AA00389B71}
DEFINE_GUID(MEDIASUBTYPE_MPG2,
- 0x3267706D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ 0x3267706D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// Audio codecs
// 41564D41-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_IMA_AMV,
- 0x41564D41, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ 0x41564D41, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
// 4C4C454E-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_NELLYMOSER,
- 0x4C4C454E, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ 0x4C4C454E, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
// 63616C61-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_ALAC,
- 0x63616C61, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ 0x63616C61, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
// 20534C41-0000-0010-8000-00AA00389B71
DEFINE_GUID(MEDIASUBTYPE_ALS,
- 0x20534C41, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ 0x20534C41, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
-// {949F97FD-56F6-4527-B4AE-DDEB375AB80F} Mpc-hc specific !
+// {949F97FD-56F6-4527-B4AE-DDEB375AB80F} Mpc-hc specific !
DEFINE_GUID(MEDIASUBTYPE_HDMV_LPCM_AUDIO,
- 0x949f97fd, 0x56f6, 0x4527, 0xb4, 0xae, 0xdd, 0xeb, 0x37, 0x5a, 0xb8, 0xf);
+ 0x949f97fd, 0x56f6, 0x4527, 0xb4, 0xae, 0xdd, 0xeb, 0x37, 0x5a, 0xb8, 0xf);
struct WAVEFORMATEX_HDMV_LPCM : public WAVEFORMATEX {
- BYTE channel_conf;
+ BYTE channel_conf;
- struct WAVEFORMATEX_HDMV_LPCM() {
- memset(this, 0, sizeof(*this));
- cbSize = sizeof(WAVEFORMATEX_HDMV_LPCM) - sizeof(WAVEFORMATEX);
- }
+ struct WAVEFORMATEX_HDMV_LPCM() {
+ memset(this, 0, sizeof(*this));
+ cbSize = sizeof(WAVEFORMATEX_HDMV_LPCM) - sizeof(WAVEFORMATEX);
+ }
};
#define WAVE_FORMAT_MLP mmioFOURCC('M','L','P',' ')
// {20504C4D-0000-0010-8000-00AA00389B71}
DEFINE_GUID(MEDIASUBTYPE_MLP,
- WAVE_FORMAT_MLP, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
+ WAVE_FORMAT_MLP, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
// {AFBC2343-3DCB-4047-9655-E1E62A61B1C5}
DEFINE_GUID(MEDIASUBTYPE_FFMPEG_AUDIO,
- 0xafbc2343, 0x3dcb, 0x4047, 0x96, 0x55, 0xe1, 0xe6, 0x2a, 0x61, 0xb1, 0xc5);
+ 0xafbc2343, 0x3dcb, 0x4047, 0x96, 0x55, 0xe1, 0xe6, 0x2a, 0x61, 0xb1, 0xc5);
// {35189950-CAC9-4C8D-819D-B6FAEE15DD9D}
DEFINE_GUID(FORMAT_WaveFormatExFFMPEG,
- 0x35189950, 0xcac9, 0x4c8d, 0x81, 0x9d, 0xb6, 0xfa, 0xee, 0x15, 0xdd, 0x9d);
+ 0x35189950, 0xcac9, 0x4c8d, 0x81, 0x9d, 0xb6, 0xfa, 0xee, 0x15, 0xdd, 0x9d);
-struct WAVEFORMATEXFFMPEG
-{
- int nCodecId;
- WAVEFORMATEX wfex;
+struct WAVEFORMATEXFFMPEG {
+ int nCodecId;
+ WAVEFORMATEX wfex;
- struct WAVEFORMATEXFFMPEG()
- {
- nCodecId = 0;
- }
+ struct WAVEFORMATEXFFMPEG() {
+ nCodecId = 0;
+ }
};
// Guid from wmcodecdsp.h (Windows SDK)
//DEFINE_GUID(MEDIASUBTYPE_RAW_AAC1,
-// 0x000000FF, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+// 0x000000FF, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
//DEFINE_GUID(MEDIASUBTYPE_DTS2,
-// 0x00002001, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+// 0x00002001, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
DEFINE_GUID(MEDIASUBTYPE_DOLBY_DDPLUS,
- 0xa7fb87af, 0x2d02, 0x42fb, 0xa4, 0xd4, 0x5, 0xcd, 0x93, 0x84, 0x3b, 0xdd);
+ 0xa7fb87af, 0x2d02, 0x42fb, 0xa4, 0xd4, 0x5, 0xcd, 0x93, 0x84, 0x3b, 0xdd);
DEFINE_GUID(MEDIASUBTYPE_DOLBY_TRUEHD,
- 0xeb27cec4, 0x163e, 0x4ca3, 0x8b, 0x74, 0x8e, 0x25, 0xf9, 0x1b, 0x51, 0x7e);
+ 0xeb27cec4, 0x163e, 0x4ca3, 0x8b, 0x74, 0x8e, 0x25, 0xf9, 0x1b, 0x51, 0x7e);
DEFINE_GUID(MEDIASUBTYPE_DTS_HD,
- 0xa2e58eb7, 0xfa9, 0x48bb, 0xa4, 0xc, 0xfa, 0xe, 0x15, 0x6d, 0x6, 0x45);
+ 0xa2e58eb7, 0xfa9, 0x48bb, 0xa4, 0xc, 0xfa, 0xe, 0x15, 0x6d, 0x6, 0x45);
// Additionnal DXVA GUIDs
// Intel ClearVideo VC1 bitstream decoder
-DEFINE_GUID(DXVA_Intel_VC1_ClearVideo, 0xBCC5DB6D, 0xA2B6,0x4AF0,0xAC,0xE4,0xAD,0xB1,0xF7,0x87,0xBC,0x89);
+DEFINE_GUID(DXVA_Intel_VC1_ClearVideo, 0xBCC5DB6D, 0xA2B6, 0x4AF0, 0xAC, 0xE4, 0xAD, 0xB1, 0xF7, 0x87, 0xBC, 0x89);
// Intel ClearVideo H264 bitstream decoder
-DEFINE_GUID(DXVA_Intel_H264_ClearVideo, 0x604F8E68, 0x4951,0x4C54,0x88,0xFE,0xAB,0xD2,0x5C,0x15,0xB3,0xD6);
+DEFINE_GUID(DXVA_Intel_H264_ClearVideo, 0x604F8E68, 0x4951, 0x4C54, 0x88, 0xFE, 0xAB, 0xD2, 0x5C, 0x15, 0xB3, 0xD6);
// Nvidia MPEG-4 ASP bitstream decoder
// 9947EC6F-689B-11DC-A320-0019DBBC4184
-DEFINE_GUID(DXVA_MPEG4_ASP, 0x9947EC6F, 0x689B,0x11DC,0xA3,0x20,0x00,0x19,0xDB,0xBC,0x41,0x84);
+DEFINE_GUID(DXVA_MPEG4_ASP, 0x9947EC6F, 0x689B, 0x11DC, 0xA3, 0x20, 0x00, 0x19, 0xDB, 0xBC, 0x41, 0x84);
DEFINE_GUID(CLSID_AC3Filter, 0xA753A1EC, 0x973E, 0x4718, 0xAF, 0x8E, 0xA3, 0xF5, 0x54, 0xD4, 0x5C, 0x44);
diff --git a/src/CmdUI/CmdUI.cpp b/src/CmdUI/CmdUI.cpp
index 50e3e5e71..e9e76ebc8 100644
--- a/src/CmdUI/CmdUI.cpp
+++ b/src/CmdUI/CmdUI.cpp
@@ -37,12 +37,12 @@ CCmdUIDialog::CCmdUIDialog()
}
CCmdUIDialog::CCmdUIDialog(UINT nIDTemplate, CWnd* pParent /*=NULL*/)
- : CDialog(nIDTemplate, pParent)
+ : CDialog(nIDTemplate, pParent)
{
}
CCmdUIDialog::CCmdUIDialog(LPCTSTR lpszTemplateName, CWnd* pParentWnd)
- : CDialog(lpszTemplateName, pParentWnd)
+ : CDialog(lpszTemplateName, pParentWnd)
{
}
@@ -52,18 +52,18 @@ CCmdUIDialog::~CCmdUIDialog()
LRESULT CCmdUIDialog::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
- LRESULT ret = __super::DefWindowProc(message, wParam, lParam);
+ LRESULT ret = __super::DefWindowProc(message, wParam, lParam);
- if (message == WM_INITDIALOG) {
- SendMessage(WM_KICKIDLE);
- }
+ if (message == WM_INITDIALOG) {
+ SendMessage(WM_KICKIDLE);
+ }
- return ret;
+ return ret;
}
BEGIN_MESSAGE_MAP(CCmdUIDialog, CDialog)
- ON_MESSAGE_VOID(WM_KICKIDLE, OnKickIdle)
- ON_WM_INITMENUPOPUP()
+ ON_MESSAGE_VOID(WM_KICKIDLE, OnKickIdle)
+ ON_WM_INITMENUPOPUP()
END_MESSAGE_MAP()
@@ -71,89 +71,89 @@ END_MESSAGE_MAP()
void CCmdUIDialog::OnKickIdle()
{
- UpdateDialogControls(this, false);
+ UpdateDialogControls(this, false);
- // TODO: maybe we should send this call to modeless child cdialogs too
+ // TODO: maybe we should send this call to modeless child cdialogs too
}
// Q242577
-void CCmdUIDialog::OnInitMenuPopup(CMenu *pPopupMenu, UINT /*nIndex*/, BOOL /*bSysMenu*/)
+void CCmdUIDialog::OnInitMenuPopup(CMenu* pPopupMenu, UINT /*nIndex*/, BOOL /*bSysMenu*/)
{
- ASSERT(pPopupMenu != NULL);
- // Check the enabled state of various menu items.
-
- CCmdUI state;
- state.m_pMenu = pPopupMenu;
- ASSERT(state.m_pOther == NULL);
- ASSERT(state.m_pParentMenu == NULL);
-
- // Determine if menu is popup in top-level menu and set m_pOther to
- // it if so (m_pParentMenu == NULL indicates that it is secondary popup).
- HMENU hParentMenu;
- if (AfxGetThreadState()->m_hTrackingMenu == pPopupMenu->m_hMenu) {
- state.m_pParentMenu = pPopupMenu; // Parent == child for tracking popup.
- } else if ((hParentMenu = ::GetMenu(m_hWnd)) != NULL) {
- CWnd* pParent = this;
- // Child windows don't have menus--need to go to the top!
- if (pParent != NULL &&
- (hParentMenu = ::GetMenu(pParent->m_hWnd)) != NULL) {
- int nIndexMax = ::GetMenuItemCount(hParentMenu);
- for (int nIndex = 0; nIndex < nIndexMax; nIndex++) {
- if (::GetSubMenu(hParentMenu, nIndex) == pPopupMenu->m_hMenu) {
- // When popup is found, m_pParentMenu is containing menu.
- state.m_pParentMenu = CMenu::FromHandle(hParentMenu);
- break;
- }
- }
- }
- }
-
- state.m_nIndexMax = pPopupMenu->GetMenuItemCount();
- for (state.m_nIndex = 0; state.m_nIndex < state.m_nIndexMax;
- state.m_nIndex++) {
- state.m_nID = pPopupMenu->GetMenuItemID(state.m_nIndex);
- if (state.m_nID == 0) {
- continue; // Menu separator or invalid cmd - ignore it.
- }
-
- ASSERT(state.m_pOther == NULL);
- ASSERT(state.m_pMenu != NULL);
- if (state.m_nID == (UINT)-1) {
- // Possibly a popup menu, route to first item of that popup.
- state.m_pSubMenu = pPopupMenu->GetSubMenu(state.m_nIndex);
- if (state.m_pSubMenu == NULL ||
- (state.m_nID = state.m_pSubMenu->GetMenuItemID(0)) == 0 ||
- state.m_nID == (UINT)-1) {
- continue; // First item of popup can't be routed to.
- }
- state.DoUpdate(this, TRUE); // Popups are never auto disabled.
- } else {
- // Normal menu item.
- // Auto enable/disable if frame window has m_bAutoMenuEnable
- // set and command is _not_ a system command.
- state.m_pSubMenu = NULL;
- state.DoUpdate(this, FALSE);
- }
-
- // Adjust for menu deletions and additions.
- UINT nCount = pPopupMenu->GetMenuItemCount();
- if (nCount < state.m_nIndexMax) {
- state.m_nIndex -= (state.m_nIndexMax - nCount);
- while (state.m_nIndex < nCount &&
- pPopupMenu->GetMenuItemID(state.m_nIndex) == state.m_nID) {
- state.m_nIndex++;
- }
- }
- state.m_nIndexMax = nCount;
- }
+ ASSERT(pPopupMenu != NULL);
+ // Check the enabled state of various menu items.
+
+ CCmdUI state;
+ state.m_pMenu = pPopupMenu;
+ ASSERT(state.m_pOther == NULL);
+ ASSERT(state.m_pParentMenu == NULL);
+
+ // Determine if menu is popup in top-level menu and set m_pOther to
+ // it if so (m_pParentMenu == NULL indicates that it is secondary popup).
+ HMENU hParentMenu;
+ if (AfxGetThreadState()->m_hTrackingMenu == pPopupMenu->m_hMenu) {
+ state.m_pParentMenu = pPopupMenu; // Parent == child for tracking popup.
+ } else if ((hParentMenu = ::GetMenu(m_hWnd)) != NULL) {
+ CWnd* pParent = this;
+ // Child windows don't have menus--need to go to the top!
+ if (pParent != NULL &&
+ (hParentMenu = ::GetMenu(pParent->m_hWnd)) != NULL) {
+ int nIndexMax = ::GetMenuItemCount(hParentMenu);
+ for (int nIndex = 0; nIndex < nIndexMax; nIndex++) {
+ if (::GetSubMenu(hParentMenu, nIndex) == pPopupMenu->m_hMenu) {
+ // When popup is found, m_pParentMenu is containing menu.
+ state.m_pParentMenu = CMenu::FromHandle(hParentMenu);
+ break;
+ }
+ }
+ }
+ }
+
+ state.m_nIndexMax = pPopupMenu->GetMenuItemCount();
+ for (state.m_nIndex = 0; state.m_nIndex < state.m_nIndexMax;
+ state.m_nIndex++) {
+ state.m_nID = pPopupMenu->GetMenuItemID(state.m_nIndex);
+ if (state.m_nID == 0) {
+ continue; // Menu separator or invalid cmd - ignore it.
+ }
+
+ ASSERT(state.m_pOther == NULL);
+ ASSERT(state.m_pMenu != NULL);
+ if (state.m_nID == (UINT) - 1) {
+ // Possibly a popup menu, route to first item of that popup.
+ state.m_pSubMenu = pPopupMenu->GetSubMenu(state.m_nIndex);
+ if (state.m_pSubMenu == NULL ||
+ (state.m_nID = state.m_pSubMenu->GetMenuItemID(0)) == 0 ||
+ state.m_nID == (UINT) - 1) {
+ continue; // First item of popup can't be routed to.
+ }
+ state.DoUpdate(this, TRUE); // Popups are never auto disabled.
+ } else {
+ // Normal menu item.
+ // Auto enable/disable if frame window has m_bAutoMenuEnable
+ // set and command is _not_ a system command.
+ state.m_pSubMenu = NULL;
+ state.DoUpdate(this, FALSE);
+ }
+
+ // Adjust for menu deletions and additions.
+ UINT nCount = pPopupMenu->GetMenuItemCount();
+ if (nCount < state.m_nIndexMax) {
+ state.m_nIndex -= (state.m_nIndexMax - nCount);
+ while (state.m_nIndex < nCount &&
+ pPopupMenu->GetMenuItemID(state.m_nIndex) == state.m_nID) {
+ state.m_nIndex++;
+ }
+ }
+ state.m_nIndexMax = nCount;
+ }
}
// CCmdUIPropertyPage
IMPLEMENT_DYNAMIC(CCmdUIPropertyPage, CPropertyPage)
CCmdUIPropertyPage::CCmdUIPropertyPage(UINT nIDTemplate, UINT nIDCaption)
- : CPropertyPage(nIDTemplate, nIDCaption)
+ : CPropertyPage(nIDTemplate, nIDCaption)
{
}
@@ -163,28 +163,28 @@ CCmdUIPropertyPage::~CCmdUIPropertyPage()
LRESULT CCmdUIPropertyPage::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
- if (message == WM_COMMAND) {
- switch (HIWORD(wParam)) {
- case BN_CLICKED:
- case CBN_SELCHANGE:
- case EN_CHANGE:
- SetModified();
- default:
- ;
- }
- }
-
- LRESULT ret = __super::DefWindowProc(message, wParam, lParam);
-
- if (message == WM_INITDIALOG) {
- SendMessage(WM_KICKIDLE);
- }
-
- return ret;
+ if (message == WM_COMMAND) {
+ switch (HIWORD(wParam)) {
+ case BN_CLICKED:
+ case CBN_SELCHANGE:
+ case EN_CHANGE:
+ SetModified();
+ default:
+ ;
+ }
+ }
+
+ LRESULT ret = __super::DefWindowProc(message, wParam, lParam);
+
+ if (message == WM_INITDIALOG) {
+ SendMessage(WM_KICKIDLE);
+ }
+
+ return ret;
}
BEGIN_MESSAGE_MAP(CCmdUIPropertyPage, CPropertyPage)
- ON_MESSAGE_VOID(WM_KICKIDLE, OnKickIdle)
+ ON_MESSAGE_VOID(WM_KICKIDLE, OnKickIdle)
END_MESSAGE_MAP()
@@ -192,7 +192,7 @@ END_MESSAGE_MAP()
void CCmdUIPropertyPage::OnKickIdle()
{
- UpdateDialogControls(this, false);
+ UpdateDialogControls(this, false);
- // TODO: maybe we should send this call to modeless child cPropertyPages too
+ // TODO: maybe we should send this call to modeless child cPropertyPages too
}
diff --git a/src/CmdUI/CmdUI.h b/src/CmdUI/CmdUI.h
index 7376bdee3..cc2bd8098 100644
--- a/src/CmdUI/CmdUI.h
+++ b/src/CmdUI/CmdUI.h
@@ -29,22 +29,22 @@
class CCmdUIDialog : public CDialog
{
- DECLARE_DYNAMIC(CCmdUIDialog)
+ DECLARE_DYNAMIC(CCmdUIDialog)
public:
- CCmdUIDialog();
- CCmdUIDialog(UINT nIDTemplate, CWnd* pParent = NULL);
- CCmdUIDialog(LPCTSTR lpszTemplateName, CWnd* pParent = NULL);
- virtual ~CCmdUIDialog();
+ CCmdUIDialog();
+ CCmdUIDialog(UINT nIDTemplate, CWnd* pParent = NULL);
+ CCmdUIDialog(LPCTSTR lpszTemplateName, CWnd* pParent = NULL);
+ virtual ~CCmdUIDialog();
protected:
- virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
+ virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnKickIdle();
- afx_msg void OnInitMenuPopup(CMenu *pPopupMenu, UINT nIndex,BOOL bSysMenu);
+ afx_msg void OnKickIdle();
+ afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
};
@@ -52,17 +52,17 @@ public:
class CCmdUIPropertyPage : public CPropertyPage
{
- DECLARE_DYNAMIC(CCmdUIPropertyPage)
+ DECLARE_DYNAMIC(CCmdUIPropertyPage)
public:
- CCmdUIPropertyPage(UINT nIDTemplate, UINT nIDCaption = 0); // standard constructor
- virtual ~CCmdUIPropertyPage();
+ CCmdUIPropertyPage(UINT nIDTemplate, UINT nIDCaption = 0); // standard constructor
+ virtual ~CCmdUIPropertyPage();
protected:
- virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
+ virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnKickIdle();
+ afx_msg void OnKickIdle();
};
diff --git a/src/CmdUI/stdafx.h b/src/CmdUI/stdafx.h
index 80c1682e7..8e8a43bc5 100644
--- a/src/CmdUI/stdafx.h
+++ b/src/CmdUI/stdafx.h
@@ -24,13 +24,13 @@
#pragma once
#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#endif
-#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
#ifndef VC_EXTRALEAN
-#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
+#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
#include <afx.h>
-#include <afxwin.h> // MFC core and standard components
+#include <afxwin.h> // MFC core and standard components
diff --git a/src/DSUtil/AudioParser.cpp b/src/DSUtil/AudioParser.cpp
index 8d7a0e7e4..f8246db81 100644
--- a/src/DSUtil/AudioParser.cpp
+++ b/src/DSUtil/AudioParser.cpp
@@ -39,293 +39,303 @@
#define AC3_CHANNEL_MASK 15
#define AC3_LFE 16
-int GetAC3FrameSize(const BYTE *buf)
+int GetAC3FrameSize(const BYTE* buf)
{
- if (*(WORD*)buf != AC3_SYNC_WORD) // syncword
- return 0;
-
- int frame_size;
-
- if (buf[5] >> 3 <= 10) { // Normal AC-3
- static const int rates[] = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 512, 576, 640};
-
- int frmsizecod = buf[4] & 0x3F;
- if (frmsizecod >= 38)
- return 0;
-
- int rate = rates[frmsizecod >> 1];
- switch (buf[4] & 0xc0) {
- case 0:
- frame_size = 4 * rate;
- break;
- case 0x40:
- frame_size = 2 * (320 * rate / 147 + (frmsizecod & 1));
- break;
- case 0x80:
- frame_size = 6 * rate;
- break;
- default:
- return 0;
- }
- } else { /// Enhanced AC-3
- frame_size = (((buf[2] & 0x03) << 8) + buf[3] + 1) * 2;
- }
- return frame_size;
+ if (*(WORD*)buf != AC3_SYNC_WORD) { // syncword
+ return 0;
+ }
+
+ int frame_size;
+
+ if (buf[5] >> 3 <= 10) { // Normal AC-3
+ static const int rates[] = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 512, 576, 640};
+
+ int frmsizecod = buf[4] & 0x3F;
+ if (frmsizecod >= 38) {
+ return 0;
+ }
+
+ int rate = rates[frmsizecod >> 1];
+ switch (buf[4] & 0xc0) {
+ case 0:
+ frame_size = 4 * rate;
+ break;
+ case 0x40:
+ frame_size = 2 * (320 * rate / 147 + (frmsizecod & 1));
+ break;
+ case 0x80:
+ frame_size = 6 * rate;
+ break;
+ default:
+ return 0;
+ }
+ } else { /// Enhanced AC-3
+ frame_size = (((buf[2] & 0x03) << 8) + buf[3] + 1) * 2;
+ }
+ return frame_size;
}
-int GetMLPFrameSize(const BYTE *buf)
+int GetMLPFrameSize(const BYTE* buf)
{
- DWORD sync = *(DWORD*)(buf+4);
- if (sync == TRUEHD_SYNC_WORD || sync == MLP_SYNC_WORD) {
- return (((buf[0] << 8) | buf[1]) & 0xfff) * 2;
- }
- return 0;
+ DWORD sync = *(DWORD*)(buf + 4);
+ if (sync == TRUEHD_SYNC_WORD || sync == MLP_SYNC_WORD) {
+ return (((buf[0] << 8) | buf[1]) & 0xfff) * 2;
+ }
+ return 0;
}
-int ParseAC3Header(const BYTE *buf, int *samplerate, int *channels, int *framelength, int *bitrate)
+int ParseAC3Header(const BYTE* buf, int* samplerate, int* channels, int* framelength, int* bitrate)
{
- if (*(WORD*)buf != AC3_SYNC_WORD) // syncword
- return 0;
-
- if (buf[5] >> 3 >= 11) // bsid
- return 0;
-
- static const int rates[] = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 512, 576, 640};
- static const unsigned char lfeon[8] = {0x10, 0x10, 0x04, 0x04, 0x04, 0x01, 0x04, 0x01};
- static const unsigned char halfrate[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3};
-
- int frmsizecod = buf[4] & 0x3F;
- if (frmsizecod >= 38)
- return 0;
-
- int half = halfrate[buf[5] >> 3];
- int rate = rates[frmsizecod >> 1];
- *bitrate = (rate * 1000) >> half;
- int frame_size;
- switch (buf[4] & 0xc0) {
- case 0:
- *samplerate = 48000 >> half;
- frame_size = 4 * rate;
- break;
- case 0x40:
- *samplerate = 44100 >> half;
- frame_size = 2 * (320 * rate / 147 + (frmsizecod & 1));
- break;
- case 0x80:
- *samplerate = 32000 >> half;
- frame_size = 6 * rate;
- break;
- default:
- return 0;
- }
-
- unsigned char acmod = buf[6] >> 5;
- unsigned char flags = ((((buf[6] & 0xf8) == 0x50) ? AC3_DOLBY : acmod) | ((buf[6] & lfeon[acmod]) ? AC3_LFE : 0));
- switch (flags & AC3_CHANNEL_MASK) {
- case AC3_MONO:
- *channels = 1;
- break;
- case AC3_CHANNEL:
- case AC3_STEREO:
- case AC3_CHANNEL1:
- case AC3_CHANNEL2:
- case AC3_DOLBY:
- *channels = 2;
- break;
- case AC3_2F1R:
- case AC3_3F:
- *channels = 3;
- break;
- case AC3_3F1R:
- case AC3_2F2R:
- *channels = 4;
- break;
- case AC3_3F2R:
- *channels = 5;
- break;
- }
- if (flags & AC3_LFE) (*channels)++;
-
- *framelength = 1536;
- return frame_size;
+ if (*(WORD*)buf != AC3_SYNC_WORD) { // syncword
+ return 0;
+ }
+
+ if (buf[5] >> 3 >= 11) { // bsid
+ return 0;
+ }
+
+ static const int rates[] = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 512, 576, 640};
+ static const unsigned char lfeon[8] = {0x10, 0x10, 0x04, 0x04, 0x04, 0x01, 0x04, 0x01};
+ static const unsigned char halfrate[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3};
+
+ int frmsizecod = buf[4] & 0x3F;
+ if (frmsizecod >= 38) {
+ return 0;
+ }
+
+ int half = halfrate[buf[5] >> 3];
+ int rate = rates[frmsizecod >> 1];
+ *bitrate = (rate * 1000) >> half;
+ int frame_size;
+ switch (buf[4] & 0xc0) {
+ case 0:
+ *samplerate = 48000 >> half;
+ frame_size = 4 * rate;
+ break;
+ case 0x40:
+ *samplerate = 44100 >> half;
+ frame_size = 2 * (320 * rate / 147 + (frmsizecod & 1));
+ break;
+ case 0x80:
+ *samplerate = 32000 >> half;
+ frame_size = 6 * rate;
+ break;
+ default:
+ return 0;
+ }
+
+ unsigned char acmod = buf[6] >> 5;
+ unsigned char flags = ((((buf[6] & 0xf8) == 0x50) ? AC3_DOLBY : acmod) | ((buf[6] & lfeon[acmod]) ? AC3_LFE : 0));
+ switch (flags & AC3_CHANNEL_MASK) {
+ case AC3_MONO:
+ *channels = 1;
+ break;
+ case AC3_CHANNEL:
+ case AC3_STEREO:
+ case AC3_CHANNEL1:
+ case AC3_CHANNEL2:
+ case AC3_DOLBY:
+ *channels = 2;
+ break;
+ case AC3_2F1R:
+ case AC3_3F:
+ *channels = 3;
+ break;
+ case AC3_3F1R:
+ case AC3_2F2R:
+ *channels = 4;
+ break;
+ case AC3_3F2R:
+ *channels = 5;
+ break;
+ }
+ if (flags & AC3_LFE) { (*channels)++; }
+
+ *framelength = 1536;
+ return frame_size;
}
-int ParseEAC3Header(const BYTE *buf, int *samplerate, int *channels, int *framelength, int *frametype)
+int ParseEAC3Header(const BYTE* buf, int* samplerate, int* channels, int* framelength, int* frametype)
{
- if (*(WORD*)buf != AC3_SYNC_WORD) // syncword
- return 0;
+ if (*(WORD*)buf != AC3_SYNC_WORD) { // syncword
+ return 0;
+ }
- if (buf[5] >> 3 <= 10) // bsid
- return 0;
+ if (buf[5] >> 3 <= 10) { // bsid
+ return 0;
+ }
- static const int sample_rates[] = { 48000, 44100, 32000, 24000, 22050, 16000 };
- static const int channels_tbl[] = { 2, 1, 2, 3, 3, 4, 4, 5 };
- static const int samples_tbl[] = { 256, 512, 768, 1536 };
+ static const int sample_rates[] = { 48000, 44100, 32000, 24000, 22050, 16000 };
+ static const int channels_tbl[] = { 2, 1, 2, 3, 3, 4, 4, 5 };
+ static const int samples_tbl[] = { 256, 512, 768, 1536 };
- int frame_size = (((buf[2] & 0x03) << 8) + buf[3] + 1) * 2;
+ int frame_size = (((buf[2] & 0x03) << 8) + buf[3] + 1) * 2;
- int fscod = buf[4] >> 6;
- int fscod2 = (buf[4] >> 4) & 0x03;
+ int fscod = buf[4] >> 6;
+ int fscod2 = (buf[4] >> 4) & 0x03;
- if (fscod == 0x03 && fscod2 == 0x03)
- return 0;
+ if (fscod == 0x03 && fscod2 == 0x03) {
+ return 0;
+ }
- int acmod = (buf[4] >> 1) & 0x07;
- int lfeon = buf[4] & 0x01;
+ int acmod = (buf[4] >> 1) & 0x07;
+ int lfeon = buf[4] & 0x01;
- *frametype = (buf[2] >> 6) & 0x03;
- if (*frametype == EAC3_FRAME_TYPE_RESERVED)
- return 0;
- //int sub_stream_id = (buf[2] >> 3) & 0x07;
- *samplerate = sample_rates[fscod == 0x03 ? 3 + fscod2 : fscod];
- *channels = channels_tbl[acmod] + lfeon;
- *framelength = (fscod == 0x03) ? 1536 : samples_tbl[fscod2];
+ *frametype = (buf[2] >> 6) & 0x03;
+ if (*frametype == EAC3_FRAME_TYPE_RESERVED) {
+ return 0;
+ }
+ //int sub_stream_id = (buf[2] >> 3) & 0x07;
+ *samplerate = sample_rates[fscod == 0x03 ? 3 + fscod2 : fscod];
+ *channels = channels_tbl[acmod] + lfeon;
+ *framelength = (fscod == 0x03) ? 1536 : samples_tbl[fscod2];
- return frame_size;
+ return frame_size;
}
-int ParseMLPHeader(const BYTE *buf, int *samplerate, int *channels, int *framelength, WORD *bitdepth, bool *isTrueHD)
+int ParseMLPHeader(const BYTE* buf, int* samplerate, int* channels, int* framelength, WORD* bitdepth, bool* isTrueHD)
{
- static const int sampling_rates[] = { 48000, 96000, 192000, 0, 0, 0, 0, 0, 44100, 88200, 176400, 0, 0, 0, 0, 0 };
- static const unsigned char mlp_quants[16] = { 16, 20, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- static const unsigned char mlp_channels[32] = { 1, 2, 3, 4, 3, 4, 5, 3, 4, 5, 4, 5, 6, 4, 5, 4,
- 5, 6, 5, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- };
- static const int channel_count[13] = {// LR C LFE LRs LRvh LRc LRrs Cs Ts LRsd LRw Cvh LFE2
- 2, 1, 1, 2, 2, 2, 2, 1, 1, 2, 2, 1, 1
- };
-
- DWORD sync = *(DWORD*)(buf+4);
- if (sync == TRUEHD_SYNC_WORD) {
- *isTrueHD = true;
- } else if (sync == MLP_SYNC_WORD) {
- *isTrueHD = false;
- } else {
- return 0;
- }
-
- int frame_size = (((buf[0] << 8) | buf[1]) & 0xfff) * 2;
-
- if (*isTrueHD) {
- *bitdepth = 24;
- *samplerate = sampling_rates[buf[8] >> 4];
- *framelength = 40 << ((buf[8] >> 4) & 0x07);
- int chanmap_substream_1 = ((buf[ 9] & 0x0f) << 1) | (buf[10] >> 7);
- int chanmap_substream_2 = ((buf[10] & 0x1f) << 8) | buf[11];
- int channel_map = chanmap_substream_2 ? chanmap_substream_2 : chanmap_substream_1;
- *channels = 0;
- for (int i = 0; i < 13; ++i)
- *channels += channel_count[i] * ((channel_map >> i) & 1);
- } else {
- *bitdepth = mlp_quants[buf[8] >> 4];
- *samplerate = sampling_rates[buf[9] >> 4];
- *framelength = 40 << ((buf[9] >> 4) & 0x07);
- *channels = mlp_channels[buf[11] & 0x1f];
- }
-
- return frame_size;
+ static const int sampling_rates[] = { 48000, 96000, 192000, 0, 0, 0, 0, 0, 44100, 88200, 176400, 0, 0, 0, 0, 0 };
+ static const unsigned char mlp_quants[16] = { 16, 20, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ static const unsigned char mlp_channels[32] = { 1, 2, 3, 4, 3, 4, 5, 3, 4, 5, 4, 5, 6, 4, 5, 4,
+ 5, 6, 5, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ };
+ static const int channel_count[13] = {// LR C LFE LRs LRvh LRc LRrs Cs Ts LRsd LRw Cvh LFE2
+ 2, 1, 1, 2, 2, 2, 2, 1, 1, 2, 2, 1, 1
+ };
+
+ DWORD sync = *(DWORD*)(buf + 4);
+ if (sync == TRUEHD_SYNC_WORD) {
+ *isTrueHD = true;
+ } else if (sync == MLP_SYNC_WORD) {
+ *isTrueHD = false;
+ } else {
+ return 0;
+ }
+
+ int frame_size = (((buf[0] << 8) | buf[1]) & 0xfff) * 2;
+
+ if (*isTrueHD) {
+ *bitdepth = 24;
+ *samplerate = sampling_rates[buf[8] >> 4];
+ *framelength = 40 << ((buf[8] >> 4) & 0x07);
+ int chanmap_substream_1 = ((buf[ 9] & 0x0f) << 1) | (buf[10] >> 7);
+ int chanmap_substream_2 = ((buf[10] & 0x1f) << 8) | buf[11];
+ int channel_map = chanmap_substream_2 ? chanmap_substream_2 : chanmap_substream_1;
+ *channels = 0;
+ for (int i = 0; i < 13; ++i) {
+ *channels += channel_count[i] * ((channel_map >> i) & 1);
+ }
+ } else {
+ *bitdepth = mlp_quants[buf[8] >> 4];
+ *samplerate = sampling_rates[buf[9] >> 4];
+ *framelength = 40 << ((buf[9] >> 4) & 0x07);
+ *channels = mlp_channels[buf[11] & 0x1f];
+ }
+
+ return frame_size;
}
-int ParseHdmvLPCMHeader(const BYTE *buf, int *samplerate, int *channels)
+int ParseHdmvLPCMHeader(const BYTE* buf, int* samplerate, int* channels)
{
- *samplerate = 0;
- *channels = 0;
-
- int frame_size = buf[0] << 8 | buf[1];
- frame_size += 4; // add header size;
-
- static int channels_layout[] = {0, 1, 0, 2, 3, 3, 4, 4, 5, 6, 7, 8, 0, 0, 0, 0};
- BYTE channel_layout = buf[2] >> 4;
- *channels = channels_layout[channel_layout];
- if (!*channels) {
- return 0;
- }
-
- static int bitspersample[] = {0, 16, 20, 24};
- int bits_per_sample = bitspersample[buf[3] >> 6];
- if (!(bits_per_sample == 16 || bits_per_sample == 24)) {
- return 0;
- }
-
- static int freq[] = {0, 48000, 0, 0, 96000, 192000};
- *samplerate = freq[buf[2] & 0x0f];
- if (!(*samplerate == 48000 || *samplerate == 96000 || *samplerate == 192000)) {
- return 0;
- }
-
- return frame_size;
+ *samplerate = 0;
+ *channels = 0;
+
+ int frame_size = buf[0] << 8 | buf[1];
+ frame_size += 4; // add header size;
+
+ static int channels_layout[] = {0, 1, 0, 2, 3, 3, 4, 4, 5, 6, 7, 8, 0, 0, 0, 0};
+ BYTE channel_layout = buf[2] >> 4;
+ *channels = channels_layout[channel_layout];
+ if (!*channels) {
+ return 0;
+ }
+
+ static int bitspersample[] = {0, 16, 20, 24};
+ int bits_per_sample = bitspersample[buf[3] >> 6];
+ if (!(bits_per_sample == 16 || bits_per_sample == 24)) {
+ return 0;
+ }
+
+ static int freq[] = {0, 48000, 0, 0, 96000, 192000};
+ *samplerate = freq[buf[2] & 0x0f];
+ if (!(*samplerate == 48000 || *samplerate == 96000 || *samplerate == 192000)) {
+ return 0;
+ }
+
+ return frame_size;
}
DWORD GetDefChannelMask(WORD nChannels)
{
- switch (nChannels) {
- case 1: // 1.0 Mono (KSAUDIO_SPEAKER_MONO)
- return SPEAKER_FRONT_CENTER;
- case 2: // 2.0 Stereo (KSAUDIO_SPEAKER_STEREO)
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT;
- case 3: // 2.1 Stereo
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY;
- case 4: // 4.0 Quad (KSAUDIO_SPEAKER_QUAD)
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT
- | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT;
- case 5: // 5.0
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
- | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT;
- case 6: // 5.1 Side (KSAUDIO_SPEAKER_5POINT1_SURROUND)
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
- | SPEAKER_LOW_FREQUENCY | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT;
- case 7: // 6.1 Side
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
- | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_CENTER
- | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT;
- case 8: // 7.1 Surround (KSAUDIO_SPEAKER_7POINT1_SURROUND)
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
- | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT
- | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT;
- case 10: // 9.1 Surround
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
- | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT
- | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT
- | SPEAKER_TOP_FRONT_LEFT | SPEAKER_TOP_FRONT_RIGHT;
- default:
- return 0;
- }
+ switch (nChannels) {
+ case 1: // 1.0 Mono (KSAUDIO_SPEAKER_MONO)
+ return SPEAKER_FRONT_CENTER;
+ case 2: // 2.0 Stereo (KSAUDIO_SPEAKER_STEREO)
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT;
+ case 3: // 2.1 Stereo
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY;
+ case 4: // 4.0 Quad (KSAUDIO_SPEAKER_QUAD)
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT
+ | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT;
+ case 5: // 5.0
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
+ | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT;
+ case 6: // 5.1 Side (KSAUDIO_SPEAKER_5POINT1_SURROUND)
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
+ | SPEAKER_LOW_FREQUENCY | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT;
+ case 7: // 6.1 Side
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
+ | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_CENTER
+ | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT;
+ case 8: // 7.1 Surround (KSAUDIO_SPEAKER_7POINT1_SURROUND)
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
+ | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT
+ | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT;
+ case 10: // 9.1 Surround
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
+ | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT
+ | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT
+ | SPEAKER_TOP_FRONT_LEFT | SPEAKER_TOP_FRONT_RIGHT;
+ default:
+ return 0;
+ }
}
DWORD GetVorbisChannelMask(WORD nChannels)
{
- // for Vorbis and FLAC
- // http://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-800004.3.9
- // http://flac.sourceforge.net/format.html#frame_header
- switch (nChannels) {
- case 1: // 1.0 Mono (KSAUDIO_SPEAKER_MONO)
- return SPEAKER_FRONT_CENTER;
- case 2: // 2.0 Stereo (KSAUDIO_SPEAKER_STEREO)
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT;
- case 3: // 3.0
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_CENTER | SPEAKER_FRONT_RIGHT;
- case 4: // 4.0 Quad (KSAUDIO_SPEAKER_QUAD)
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT
- | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT;
- case 5: // 5.0
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_CENTER | SPEAKER_FRONT_RIGHT
- | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT;
- case 6: // 5.1 (KSAUDIO_SPEAKER_5POINT1)
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_CENTER | SPEAKER_FRONT_RIGHT
- | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT
- | SPEAKER_LOW_FREQUENCY;
- case 7: // 6.1 Side
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_CENTER | SPEAKER_FRONT_RIGHT
- | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT
- | SPEAKER_BACK_CENTER
- | SPEAKER_LOW_FREQUENCY;
- case 8: // 7.1 Surround (KSAUDIO_SPEAKER_7POINT1_SURROUND)
- return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_CENTER | SPEAKER_FRONT_RIGHT
- | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT
- | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT
- | SPEAKER_LOW_FREQUENCY;
- default:
- return 0;
- }
+ // for Vorbis and FLAC
+ // http://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-800004.3.9
+ // http://flac.sourceforge.net/format.html#frame_header
+ switch (nChannels) {
+ case 1: // 1.0 Mono (KSAUDIO_SPEAKER_MONO)
+ return SPEAKER_FRONT_CENTER;
+ case 2: // 2.0 Stereo (KSAUDIO_SPEAKER_STEREO)
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT;
+ case 3: // 3.0
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_CENTER | SPEAKER_FRONT_RIGHT;
+ case 4: // 4.0 Quad (KSAUDIO_SPEAKER_QUAD)
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT
+ | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT;
+ case 5: // 5.0
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_CENTER | SPEAKER_FRONT_RIGHT
+ | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT;
+ case 6: // 5.1 (KSAUDIO_SPEAKER_5POINT1)
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_CENTER | SPEAKER_FRONT_RIGHT
+ | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT
+ | SPEAKER_LOW_FREQUENCY;
+ case 7: // 6.1 Side
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_CENTER | SPEAKER_FRONT_RIGHT
+ | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT
+ | SPEAKER_BACK_CENTER
+ | SPEAKER_LOW_FREQUENCY;
+ case 8: // 7.1 Surround (KSAUDIO_SPEAKER_7POINT1_SURROUND)
+ return SPEAKER_FRONT_LEFT | SPEAKER_FRONT_CENTER | SPEAKER_FRONT_RIGHT
+ | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT
+ | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT
+ | SPEAKER_LOW_FREQUENCY;
+ default:
+ return 0;
+ }
}
diff --git a/src/DSUtil/AudioParser.h b/src/DSUtil/AudioParser.h
index 5213a8a3f..7b67fa098 100644
--- a/src/DSUtil/AudioParser.h
+++ b/src/DSUtil/AudioParser.h
@@ -39,13 +39,13 @@
#define EAC3_FRAME_TYPE_AC3_CONVERT 2
#define EAC3_FRAME_TYPE_RESERVED 3
-int GetAC3FrameSize(const BYTE *buf); // for AC3 and E-AC3
-int GetMLPFrameSize(const BYTE *buf); // for TrueHD and MLP
+int GetAC3FrameSize(const BYTE* buf); // for AC3 and E-AC3
+int GetMLPFrameSize(const BYTE* buf); // for TrueHD and MLP
-int ParseAC3Header (const BYTE *buf, int *samplerate, int *channels, int *framelength, int *bitrate);
-int ParseEAC3Header (const BYTE *buf, int *samplerate, int *channels, int *framelength, int *frametype);
-int ParseMLPHeader (const BYTE *buf, int *samplerate, int *channels, int *framelength, WORD *bitdepth, bool *isTrueHD); // for TrueHD and MLP
-int ParseHdmvLPCMHeader(const BYTE *buf, int *samplerate, int *channels);
+int ParseAC3Header(const BYTE* buf, int* samplerate, int* channels, int* framelength, int* bitrate);
+int ParseEAC3Header(const BYTE* buf, int* samplerate, int* channels, int* framelength, int* frametype);
+int ParseMLPHeader(const BYTE* buf, int* samplerate, int* channels, int* framelength, WORD* bitdepth, bool* isTrueHD); // for TrueHD and MLP
+int ParseHdmvLPCMHeader(const BYTE* buf, int* samplerate, int* channels);
DWORD GetDefChannelMask(WORD nChannels);
DWORD GetVorbisChannelMask(WORD nChannels);
diff --git a/src/DSUtil/DSMPropertyBag.cpp b/src/DSUtil/DSMPropertyBag.cpp
index 2ed13abfa..c292cf282 100644
--- a/src/DSUtil/DSMPropertyBag.cpp
+++ b/src/DSUtil/DSMPropertyBag.cpp
@@ -41,118 +41,118 @@ IDSMPropertyBagImpl::~IDSMPropertyBagImpl()
STDMETHODIMP IDSMPropertyBagImpl::Read(LPCOLESTR pszPropName, VARIANT* pVar, IErrorLog* pErrorLog)
{
- CheckPointer(pVar, E_POINTER);
- if (pVar->vt != VT_EMPTY) {
- return E_INVALIDARG;
- }
- CStringW value = Lookup(pszPropName);
- if (value.IsEmpty()) {
- return E_FAIL;
- }
- CComVariant(value).Detach(pVar);
- return S_OK;
+ CheckPointer(pVar, E_POINTER);
+ if (pVar->vt != VT_EMPTY) {
+ return E_INVALIDARG;
+ }
+ CStringW value = Lookup(pszPropName);
+ if (value.IsEmpty()) {
+ return E_FAIL;
+ }
+ CComVariant(value).Detach(pVar);
+ return S_OK;
}
STDMETHODIMP IDSMPropertyBagImpl::Write(LPCOLESTR pszPropName, VARIANT* pVar)
{
- return SetProperty(pszPropName, pVar);
+ return SetProperty(pszPropName, pVar);
}
// IPropertyBag2
STDMETHODIMP IDSMPropertyBagImpl::Read(ULONG cProperties, PROPBAG2* pPropBag, IErrorLog* pErrLog, VARIANT* pvarValue, HRESULT* phrError)
{
- CheckPointer(pPropBag, E_POINTER);
- CheckPointer(pvarValue, E_POINTER);
- CheckPointer(phrError, E_POINTER);
- for (ULONG i = 0; i < cProperties; phrError[i] = S_OK, i++) {
- CComVariant(Lookup(pPropBag[i].pstrName)).Detach(pvarValue);
- }
- return S_OK;
+ CheckPointer(pPropBag, E_POINTER);
+ CheckPointer(pvarValue, E_POINTER);
+ CheckPointer(phrError, E_POINTER);
+ for (ULONG i = 0; i < cProperties; phrError[i] = S_OK, i++) {
+ CComVariant(Lookup(pPropBag[i].pstrName)).Detach(pvarValue);
+ }
+ return S_OK;
}
STDMETHODIMP IDSMPropertyBagImpl::Write(ULONG cProperties, PROPBAG2* pPropBag, VARIANT* pvarValue)
{
- CheckPointer(pPropBag, E_POINTER);
- CheckPointer(pvarValue, E_POINTER);
- for (ULONG i = 0; i < cProperties; i++) {
- SetProperty(pPropBag[i].pstrName, &pvarValue[i]);
- }
- return S_OK;
+ CheckPointer(pPropBag, E_POINTER);
+ CheckPointer(pvarValue, E_POINTER);
+ for (ULONG i = 0; i < cProperties; i++) {
+ SetProperty(pPropBag[i].pstrName, &pvarValue[i]);
+ }
+ return S_OK;
}
STDMETHODIMP IDSMPropertyBagImpl::CountProperties(ULONG* pcProperties)
{
- CheckPointer(pcProperties, E_POINTER);
- *pcProperties = GetSize();
- return S_OK;
+ CheckPointer(pcProperties, E_POINTER);
+ *pcProperties = GetSize();
+ return S_OK;
}
STDMETHODIMP IDSMPropertyBagImpl::GetPropertyInfo(ULONG iProperty, ULONG cProperties, PROPBAG2* pPropBag, ULONG* pcProperties)
{
- CheckPointer(pPropBag, E_POINTER);
- CheckPointer(pcProperties, E_POINTER);
- for (ULONG i = 0; i < cProperties; i++, iProperty++, (*pcProperties)++) {
- CStringW key = GetKeyAt(iProperty);
- pPropBag[i].pstrName = (BSTR)CoTaskMemAlloc((key.GetLength()+1)*sizeof(WCHAR));
- if (!pPropBag[i].pstrName) {
- return E_FAIL;
- }
- wcscpy_s(pPropBag[i].pstrName, key.GetLength()+1, key);
- }
- return S_OK;
+ CheckPointer(pPropBag, E_POINTER);
+ CheckPointer(pcProperties, E_POINTER);
+ for (ULONG i = 0; i < cProperties; i++, iProperty++, (*pcProperties)++) {
+ CStringW key = GetKeyAt(iProperty);
+ pPropBag[i].pstrName = (BSTR)CoTaskMemAlloc((key.GetLength() + 1) * sizeof(WCHAR));
+ if (!pPropBag[i].pstrName) {
+ return E_FAIL;
+ }
+ wcscpy_s(pPropBag[i].pstrName, key.GetLength() + 1, key);
+ }
+ return S_OK;
}
STDMETHODIMP IDSMPropertyBagImpl::LoadObject(LPCOLESTR pstrName, DWORD dwHint, IUnknown* pUnkObject, IErrorLog* pErrLog)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IDSMProperyBag
HRESULT IDSMPropertyBagImpl::SetProperty(LPCWSTR key, LPCWSTR value)
{
- CheckPointer(key, E_POINTER);
- CheckPointer(value, E_POINTER);
- if (!Lookup(key).IsEmpty()) {
- SetAt(key, value);
- } else {
- Add(key, value);
- }
- return S_OK;
+ CheckPointer(key, E_POINTER);
+ CheckPointer(value, E_POINTER);
+ if (!Lookup(key).IsEmpty()) {
+ SetAt(key, value);
+ } else {
+ Add(key, value);
+ }
+ return S_OK;
}
HRESULT IDSMPropertyBagImpl::SetProperty(LPCWSTR key, VARIANT* var)
{
- CheckPointer(key, E_POINTER);
- CheckPointer(var, E_POINTER);
- if ((var->vt & (VT_BSTR | VT_BYREF)) != VT_BSTR) {
- return E_INVALIDARG;
- }
- return SetProperty(key, var->bstrVal);
+ CheckPointer(key, E_POINTER);
+ CheckPointer(var, E_POINTER);
+ if ((var->vt & (VT_BSTR | VT_BYREF)) != VT_BSTR) {
+ return E_INVALIDARG;
+ }
+ return SetProperty(key, var->bstrVal);
}
HRESULT IDSMPropertyBagImpl::GetProperty(LPCWSTR key, BSTR* value)
{
- CheckPointer(key, E_POINTER);
- CheckPointer(value, E_POINTER);
- int i = FindKey(key);
- if (i < 0) {
- return E_FAIL;
- }
- *value = GetValueAt(i).AllocSysString();
- return S_OK;
+ CheckPointer(key, E_POINTER);
+ CheckPointer(value, E_POINTER);
+ int i = FindKey(key);
+ if (i < 0) {
+ return E_FAIL;
+ }
+ *value = GetValueAt(i).AllocSysString();
+ return S_OK;
}
HRESULT IDSMPropertyBagImpl::DelAllProperties()
{
- RemoveAll();
- return S_OK;
+ RemoveAll();
+ return S_OK;
}
HRESULT IDSMPropertyBagImpl::DelProperty(LPCWSTR key)
{
- return Remove(key) ? S_OK : S_FALSE;
+ return Remove(key) ? S_OK : S_FALSE;
}
//
@@ -163,50 +163,50 @@ CCritSec CDSMResource::m_csResources;
CAtlMap<uintptr_t, CDSMResource*> CDSMResource::m_resources;
CDSMResource::CDSMResource()
- : mime(_T("application/octet-stream"))
- , tag(0)
+ : mime(_T("application/octet-stream"))
+ , tag(0)
{
- CAutoLock cAutoLock(&m_csResources);
- m_resources.SetAt(reinterpret_cast<uintptr_t>(this), this);
+ CAutoLock cAutoLock(&m_csResources);
+ m_resources.SetAt(reinterpret_cast<uintptr_t>(this), this);
}
CDSMResource::CDSMResource(const CDSMResource& r)
{
- *this = r;
+ *this = r;
- CAutoLock cAutoLock(&m_csResources);
- m_resources.SetAt(reinterpret_cast<uintptr_t>(this), this);
+ CAutoLock cAutoLock(&m_csResources);
+ m_resources.SetAt(reinterpret_cast<uintptr_t>(this), this);
}
CDSMResource::CDSMResource(LPCWSTR name, LPCWSTR desc, LPCWSTR mime, BYTE* pData, int len, DWORD_PTR tag)
{
- this->name = name;
- this->desc = desc;
- this->mime = mime;
- data.SetCount(len);
- memcpy(data.GetData(), pData, data.GetCount());
- this->tag = tag;
+ this->name = name;
+ this->desc = desc;
+ this->mime = mime;
+ data.SetCount(len);
+ memcpy(data.GetData(), pData, data.GetCount());
+ this->tag = tag;
- CAutoLock cAutoLock(&m_csResources);
- m_resources.SetAt(reinterpret_cast<uintptr_t>(this), this);
+ CAutoLock cAutoLock(&m_csResources);
+ m_resources.SetAt(reinterpret_cast<uintptr_t>(this), this);
}
CDSMResource::~CDSMResource()
{
- CAutoLock cAutoLock(&m_csResources);
- m_resources.RemoveKey(reinterpret_cast<uintptr_t>(this));
+ CAutoLock cAutoLock(&m_csResources);
+ m_resources.RemoveKey(reinterpret_cast<uintptr_t>(this));
}
CDSMResource& CDSMResource::operator = (const CDSMResource& r)
{
- if ( this != &r ) {
- tag = r.tag;
- name = r.name;
- desc = r.desc;
- mime = r.mime;
- data.Copy(r.data);
- }
- return *this;
+ if (this != &r) {
+ tag = r.tag;
+ name = r.name;
+ desc = r.desc;
+ mime = r.mime;
+ data.Copy(r.data);
+ }
+ return *this;
}
//
@@ -221,97 +221,97 @@ IDSMResourceBagImpl::IDSMResourceBagImpl()
STDMETHODIMP_(DWORD) IDSMResourceBagImpl::ResGetCount()
{
- return (DWORD)m_resources.GetCount();
+ return (DWORD)m_resources.GetCount();
}
STDMETHODIMP IDSMResourceBagImpl::ResGet(DWORD iIndex, BSTR* ppName, BSTR* ppDesc, BSTR* ppMime, BYTE** ppData, DWORD* pDataLen, DWORD_PTR* pTag)
{
- if (ppData) {
- CheckPointer(pDataLen, E_POINTER);
- }
+ if (ppData) {
+ CheckPointer(pDataLen, E_POINTER);
+ }
- if (iIndex >= m_resources.GetCount()) {
- return E_INVALIDARG;
- }
+ if (iIndex >= m_resources.GetCount()) {
+ return E_INVALIDARG;
+ }
- CDSMResource& r = m_resources[iIndex];
+ CDSMResource& r = m_resources[iIndex];
- if (ppName) {
- *ppName = r.name.AllocSysString();
- }
- if (ppDesc) {
- *ppDesc = r.desc.AllocSysString();
- }
- if (ppMime) {
- *ppMime = r.mime.AllocSysString();
- }
- if (ppData) {
- *pDataLen = (DWORD)r.data.GetCount();
- memcpy(*ppData = (BYTE*)CoTaskMemAlloc(*pDataLen), r.data.GetData(), *pDataLen);
- }
- if (pTag) {
- *pTag = r.tag;
- }
+ if (ppName) {
+ *ppName = r.name.AllocSysString();
+ }
+ if (ppDesc) {
+ *ppDesc = r.desc.AllocSysString();
+ }
+ if (ppMime) {
+ *ppMime = r.mime.AllocSysString();
+ }
+ if (ppData) {
+ *pDataLen = (DWORD)r.data.GetCount();
+ memcpy(*ppData = (BYTE*)CoTaskMemAlloc(*pDataLen), r.data.GetData(), *pDataLen);
+ }
+ if (pTag) {
+ *pTag = r.tag;
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP IDSMResourceBagImpl::ResSet(DWORD iIndex, LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag)
{
- if (iIndex >= m_resources.GetCount()) {
- return E_INVALIDARG;
- }
+ if (iIndex >= m_resources.GetCount()) {
+ return E_INVALIDARG;
+ }
- CDSMResource& r = m_resources[iIndex];
+ CDSMResource& r = m_resources[iIndex];
- if (pName) {
- r.name = pName;
- }
- if (pDesc) {
- r.desc = pDesc;
- }
- if (pMime) {
- r.mime = pMime;
- }
- if (pData || len == 0) {
- r.data.SetCount(len);
- if (pData) {
- memcpy(r.data.GetData(), pData, r.data.GetCount());
- }
- }
- r.tag = tag;
+ if (pName) {
+ r.name = pName;
+ }
+ if (pDesc) {
+ r.desc = pDesc;
+ }
+ if (pMime) {
+ r.mime = pMime;
+ }
+ if (pData || len == 0) {
+ r.data.SetCount(len);
+ if (pData) {
+ memcpy(r.data.GetData(), pData, r.data.GetCount());
+ }
+ }
+ r.tag = tag;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP IDSMResourceBagImpl::ResAppend(LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag)
{
- return ResSet((DWORD)m_resources.Add(CDSMResource()), pName, pDesc, pMime, pData, len, tag);
+ return ResSet((DWORD)m_resources.Add(CDSMResource()), pName, pDesc, pMime, pData, len, tag);
}
STDMETHODIMP IDSMResourceBagImpl::ResRemoveAt(DWORD iIndex)
{
- if (iIndex >= m_resources.GetCount()) {
- return E_INVALIDARG;
- }
+ if (iIndex >= m_resources.GetCount()) {
+ return E_INVALIDARG;
+ }
- m_resources.RemoveAt(iIndex);
+ m_resources.RemoveAt(iIndex);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP IDSMResourceBagImpl::ResRemoveAll(DWORD_PTR tag)
{
- if (tag) {
- for (ptrdiff_t i = m_resources.GetCount() - 1; i >= 0; i--)
- if (m_resources[i].tag == tag) {
- m_resources.RemoveAt(i);
- }
- } else {
- m_resources.RemoveAll();
- }
+ if (tag) {
+ for (ptrdiff_t i = m_resources.GetCount() - 1; i >= 0; i--)
+ if (m_resources[i].tag == tag) {
+ m_resources.RemoveAt(i);
+ }
+ } else {
+ m_resources.RemoveAll();
+ }
- return S_OK;
+ return S_OK;
}
//
@@ -320,41 +320,41 @@ STDMETHODIMP IDSMResourceBagImpl::ResRemoveAll(DWORD_PTR tag)
CDSMChapter::CDSMChapter()
{
- order = counter++;
- rt = 0;
+ order = counter++;
+ rt = 0;
}
CDSMChapter::CDSMChapter(REFERENCE_TIME rt, LPCWSTR name)
{
- order = counter++;
- this->rt = rt;
- this->name = name;
+ order = counter++;
+ this->rt = rt;
+ this->name = name;
}
CDSMChapter& CDSMChapter::operator = (const CDSMChapter& c)
{
- if ( this != &c ) {
- order = c.counter;
- rt = c.rt;
- name = c.name;
- }
- return *this;
+ if (this != &c) {
+ order = c.counter;
+ rt = c.rt;
+ name = c.name;
+ }
+ return *this;
}
int CDSMChapter::counter = 0;
int CDSMChapter::Compare(const void* a, const void* b)
{
- const CDSMChapter* ca = static_cast<const CDSMChapter*>(a);
- const CDSMChapter* cb = static_cast<const CDSMChapter*>(b);
+ const CDSMChapter* ca = static_cast<const CDSMChapter*>(a);
+ const CDSMChapter* cb = static_cast<const CDSMChapter*>(b);
- if (ca->rt > cb->rt) {
- return 1;
- } else if (ca->rt < cb->rt) {
- return -1;
- }
+ if (ca->rt > cb->rt) {
+ return 1;
+ } else if (ca->rt < cb->rt) {
+ return -1;
+ }
- return ca->order - cb->order;
+ return ca->order - cb->order;
}
//
@@ -363,104 +363,104 @@ int CDSMChapter::Compare(const void* a, const void* b)
IDSMChapterBagImpl::IDSMChapterBagImpl()
{
- m_fSorted = false;
+ m_fSorted = false;
}
// IDSMRChapterBag
STDMETHODIMP_(DWORD) IDSMChapterBagImpl::ChapGetCount()
{
- return (DWORD)m_chapters.GetCount();
+ return (DWORD)m_chapters.GetCount();
}
STDMETHODIMP IDSMChapterBagImpl::ChapGet(DWORD iIndex, REFERENCE_TIME* prt, BSTR* ppName)
{
- if (iIndex >= m_chapters.GetCount()) {
- return E_INVALIDARG;
- }
+ if (iIndex >= m_chapters.GetCount()) {
+ return E_INVALIDARG;
+ }
- CDSMChapter& c = m_chapters[iIndex];
+ CDSMChapter& c = m_chapters[iIndex];
- if (prt) {
- *prt = c.rt;
- }
- if (ppName) {
- *ppName = c.name.AllocSysString();
- }
+ if (prt) {
+ *prt = c.rt;
+ }
+ if (ppName) {
+ *ppName = c.name.AllocSysString();
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP IDSMChapterBagImpl::ChapSet(DWORD iIndex, REFERENCE_TIME rt, LPCWSTR pName)
{
- if (iIndex >= m_chapters.GetCount()) {
- return E_INVALIDARG;
- }
+ if (iIndex >= m_chapters.GetCount()) {
+ return E_INVALIDARG;
+ }
- CDSMChapter& c = m_chapters[iIndex];
+ CDSMChapter& c = m_chapters[iIndex];
- c.rt = rt;
- if (pName) {
- c.name = pName;
- }
+ c.rt = rt;
+ if (pName) {
+ c.name = pName;
+ }
- m_fSorted = false;
+ m_fSorted = false;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP IDSMChapterBagImpl::ChapAppend(REFERENCE_TIME rt, LPCWSTR pName)
{
- return ChapSet((DWORD)m_chapters.Add(CDSMChapter()), rt, pName);
+ return ChapSet((DWORD)m_chapters.Add(CDSMChapter()), rt, pName);
}
STDMETHODIMP IDSMChapterBagImpl::ChapRemoveAt(DWORD iIndex)
{
- if (iIndex >= m_chapters.GetCount()) {
- return E_INVALIDARG;
- }
+ if (iIndex >= m_chapters.GetCount()) {
+ return E_INVALIDARG;
+ }
- m_chapters.RemoveAt(iIndex);
+ m_chapters.RemoveAt(iIndex);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP IDSMChapterBagImpl::ChapRemoveAll()
{
- m_chapters.RemoveAll();
+ m_chapters.RemoveAll();
- m_fSorted = false;
+ m_fSorted = false;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP_(long) IDSMChapterBagImpl::ChapLookup(REFERENCE_TIME* prt, BSTR* ppName)
{
- CheckPointer(prt, -1);
+ CheckPointer(prt, -1);
- ChapSort();
+ ChapSort();
- ptrdiff_t i = range_bsearch(m_chapters, *prt);
- if (i < 0) {
- return -1;
- }
+ ptrdiff_t i = range_bsearch(m_chapters, *prt);
+ if (i < 0) {
+ return -1;
+ }
- *prt = m_chapters[i].rt;
- if (ppName) {
- *ppName = m_chapters[i].name.AllocSysString();
- }
+ *prt = m_chapters[i].rt;
+ if (ppName) {
+ *ppName = m_chapters[i].name.AllocSysString();
+ }
- return (long)i;
+ return (long)i;
}
STDMETHODIMP IDSMChapterBagImpl::ChapSort()
{
- if (m_fSorted) {
- return S_FALSE;
- }
- qsort(m_chapters.GetData(), m_chapters.GetCount(), sizeof(CDSMChapter), CDSMChapter::Compare);
- m_fSorted = true;
- return S_OK;
+ if (m_fSorted) {
+ return S_FALSE;
+ }
+ qsort(m_chapters.GetData(), m_chapters.GetCount(), sizeof(CDSMChapter), CDSMChapter::Compare);
+ m_fSorted = true;
+ return S_OK;
}
//
@@ -468,15 +468,15 @@ STDMETHODIMP IDSMChapterBagImpl::ChapSort()
//
CDSMChapterBag::CDSMChapterBag(LPUNKNOWN pUnk, HRESULT* phr)
- : CUnknown(_T("CDSMChapterBag"), NULL)
+ : CUnknown(_T("CDSMChapterBag"), NULL)
{
}
STDMETHODIMP CDSMChapterBag::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- QI(IDSMChapterBag)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IDSMChapterBag)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
diff --git a/src/DSUtil/DSMPropertyBag.h b/src/DSUtil/DSMPropertyBag.h
index 3a6e5c825..61f97a37f 100644
--- a/src/DSUtil/DSMPropertyBag.h
+++ b/src/DSUtil/DSMPropertyBag.h
@@ -30,46 +30,46 @@
interface __declspec(uuid("232FD5D2-4954-41E7-BF9B-09E1257B1A95"))
IDSMPropertyBag :
public IPropertyBag2 {
- STDMETHOD(SetProperty) (LPCWSTR key, LPCWSTR value) = 0;
- STDMETHOD(SetProperty) (LPCWSTR key, VARIANT* var) = 0;
- STDMETHOD(GetProperty) (LPCWSTR key, BSTR* value) = 0;
- STDMETHOD(DelAllProperties) () = 0;
- STDMETHOD(DelProperty) (LPCWSTR key) = 0;
+ STDMETHOD(SetProperty)(LPCWSTR key, LPCWSTR value) = 0;
+ STDMETHOD(SetProperty)(LPCWSTR key, VARIANT * var) = 0;
+ STDMETHOD(GetProperty)(LPCWSTR key, BSTR * value) = 0;
+ STDMETHOD(DelAllProperties)() = 0;
+ STDMETHOD(DelProperty)(LPCWSTR key) = 0;
};
class IDSMPropertyBagImpl : public ATL::CSimpleMap<CStringW, CStringW>, public IDSMPropertyBag, public IPropertyBag
{
- BOOL Add(const CStringW& key, const CStringW& val) {
- return __super::Add(key, val);
- }
- BOOL SetAt(const CStringW& key, const CStringW& val) {
- return __super::SetAt(key, val);
- }
+ BOOL Add(const CStringW& key, const CStringW& val) {
+ return __super::Add(key, val);
+ }
+ BOOL SetAt(const CStringW& key, const CStringW& val) {
+ return __super::SetAt(key, val);
+ }
public:
- IDSMPropertyBagImpl();
- virtual ~IDSMPropertyBagImpl();
+ IDSMPropertyBagImpl();
+ virtual ~IDSMPropertyBagImpl();
- // IPropertyBag
+ // IPropertyBag
- STDMETHODIMP Read(LPCOLESTR pszPropName, VARIANT* pVar, IErrorLog* pErrorLog);
- STDMETHODIMP Write(LPCOLESTR pszPropName, VARIANT* pVar);
+ STDMETHODIMP Read(LPCOLESTR pszPropName, VARIANT* pVar, IErrorLog* pErrorLog);
+ STDMETHODIMP Write(LPCOLESTR pszPropName, VARIANT* pVar);
- // IPropertyBag2
+ // IPropertyBag2
- STDMETHODIMP Read(ULONG cProperties, PROPBAG2* pPropBag, IErrorLog* pErrLog, VARIANT* pvarValue, HRESULT* phrError);
- STDMETHODIMP Write(ULONG cProperties, PROPBAG2* pPropBag, VARIANT* pvarValue);
- STDMETHODIMP CountProperties(ULONG* pcProperties);
- STDMETHODIMP GetPropertyInfo(ULONG iProperty, ULONG cProperties, PROPBAG2* pPropBag, ULONG* pcProperties);
- STDMETHODIMP LoadObject(LPCOLESTR pstrName, DWORD dwHint, IUnknown* pUnkObject, IErrorLog* pErrLog);
+ STDMETHODIMP Read(ULONG cProperties, PROPBAG2* pPropBag, IErrorLog* pErrLog, VARIANT* pvarValue, HRESULT* phrError);
+ STDMETHODIMP Write(ULONG cProperties, PROPBAG2* pPropBag, VARIANT* pvarValue);
+ STDMETHODIMP CountProperties(ULONG* pcProperties);
+ STDMETHODIMP GetPropertyInfo(ULONG iProperty, ULONG cProperties, PROPBAG2* pPropBag, ULONG* pcProperties);
+ STDMETHODIMP LoadObject(LPCOLESTR pstrName, DWORD dwHint, IUnknown* pUnkObject, IErrorLog* pErrLog);
- // IDSMPropertyBag
+ // IDSMPropertyBag
- STDMETHODIMP SetProperty(LPCWSTR key, LPCWSTR value);
- STDMETHODIMP SetProperty(LPCWSTR key, VARIANT* var);
- STDMETHODIMP GetProperty(LPCWSTR key, BSTR* value);
- STDMETHODIMP DelAllProperties();
- STDMETHODIMP DelProperty(LPCWSTR key);
+ STDMETHODIMP SetProperty(LPCWSTR key, LPCWSTR value);
+ STDMETHODIMP SetProperty(LPCWSTR key, VARIANT* var);
+ STDMETHODIMP GetProperty(LPCWSTR key, BSTR* value);
+ STDMETHODIMP DelAllProperties();
+ STDMETHODIMP DelProperty(LPCWSTR key);
};
// IDSMResourceBag
@@ -77,49 +77,49 @@ public:
interface __declspec(uuid("EBAFBCBE-BDE0-489A-9789-05D5692E3A93"))
IDSMResourceBag :
public IUnknown {
- STDMETHOD_(DWORD, ResGetCount) () = 0;
- STDMETHOD(ResGet) (DWORD iIndex, BSTR* ppName, BSTR* ppDesc, BSTR* ppMime, BYTE** ppData, DWORD* pDataLen, DWORD_PTR* pTag) = 0;
- STDMETHOD(ResSet) (DWORD iIndex, LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag) = 0;
- STDMETHOD(ResAppend) (LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag) = 0;
- STDMETHOD(ResRemoveAt) (DWORD iIndex) = 0;
- STDMETHOD(ResRemoveAll) (DWORD_PTR tag) = 0;
+ STDMETHOD_(DWORD, ResGetCount)() = 0;
+ STDMETHOD(ResGet)(DWORD iIndex, BSTR * ppName, BSTR * ppDesc, BSTR * ppMime, BYTE** ppData, DWORD * pDataLen, DWORD_PTR * pTag) = 0;
+ STDMETHOD(ResSet)(DWORD iIndex, LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE * pData, DWORD len, DWORD_PTR tag) = 0;
+ STDMETHOD(ResAppend)(LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE * pData, DWORD len, DWORD_PTR tag) = 0;
+ STDMETHOD(ResRemoveAt)(DWORD iIndex) = 0;
+ STDMETHOD(ResRemoveAll)(DWORD_PTR tag) = 0;
};
class CDSMResource
{
public:
- DWORD_PTR tag;
- CStringW name, desc, mime;
- CAtlArray<BYTE> data;
- CDSMResource();
- CDSMResource(const CDSMResource& r);
- CDSMResource(LPCWSTR name, LPCWSTR desc, LPCWSTR mime, BYTE* pData, int len, DWORD_PTR tag = 0);
- virtual ~CDSMResource();
- CDSMResource& operator = (const CDSMResource& r);
-
- // global access to all resources
- static CCritSec m_csResources;
- static CAtlMap<uintptr_t, CDSMResource*> m_resources;
+ DWORD_PTR tag;
+ CStringW name, desc, mime;
+ CAtlArray<BYTE> data;
+ CDSMResource();
+ CDSMResource(const CDSMResource& r);
+ CDSMResource(LPCWSTR name, LPCWSTR desc, LPCWSTR mime, BYTE* pData, int len, DWORD_PTR tag = 0);
+ virtual ~CDSMResource();
+ CDSMResource& operator = (const CDSMResource& r);
+
+ // global access to all resources
+ static CCritSec m_csResources;
+ static CAtlMap<uintptr_t, CDSMResource*> m_resources;
};
class IDSMResourceBagImpl : public IDSMResourceBag
{
protected:
- CAtlArray<CDSMResource> m_resources;
+ CAtlArray<CDSMResource> m_resources;
public:
- IDSMResourceBagImpl();
+ IDSMResourceBagImpl();
- void operator += (const CDSMResource& r) { m_resources.Add(r); }
+ void operator += (const CDSMResource& r) { m_resources.Add(r); }
- // IDSMResourceBag
+ // IDSMResourceBag
- STDMETHODIMP_(DWORD) ResGetCount();
- STDMETHODIMP ResGet(DWORD iIndex, BSTR* ppName, BSTR* ppDesc, BSTR* ppMime, BYTE** ppData, DWORD* pDataLen, DWORD_PTR* pTag = NULL);
- STDMETHODIMP ResSet(DWORD iIndex, LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag = 0);
- STDMETHODIMP ResAppend(LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag = 0);
- STDMETHODIMP ResRemoveAt(DWORD iIndex);
- STDMETHODIMP ResRemoveAll(DWORD_PTR tag = 0);
+ STDMETHODIMP_(DWORD) ResGetCount();
+ STDMETHODIMP ResGet(DWORD iIndex, BSTR* ppName, BSTR* ppDesc, BSTR* ppMime, BYTE** ppData, DWORD* pDataLen, DWORD_PTR* pTag = NULL);
+ STDMETHODIMP ResSet(DWORD iIndex, LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag = 0);
+ STDMETHODIMP ResAppend(LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag = 0);
+ STDMETHODIMP ResRemoveAt(DWORD iIndex);
+ STDMETHODIMP ResRemoveAll(DWORD_PTR tag = 0);
};
// IDSMChapterBag
@@ -127,88 +127,88 @@ public:
interface __declspec(uuid("2D0EBE73-BA82-4E90-859B-C7C48ED3650F"))
IDSMChapterBag :
public IUnknown {
- STDMETHOD_(DWORD, ChapGetCount) () = 0;
- STDMETHOD(ChapGet) (DWORD iIndex, REFERENCE_TIME* prt, BSTR* ppName) = 0;
- STDMETHOD(ChapSet) (DWORD iIndex, REFERENCE_TIME rt, LPCWSTR pName) = 0;
- STDMETHOD(ChapAppend) (REFERENCE_TIME rt, LPCWSTR pName) = 0;
- STDMETHOD(ChapRemoveAt) (DWORD iIndex) = 0;
- STDMETHOD(ChapRemoveAll) () = 0;
- STDMETHOD_(long, ChapLookup) (REFERENCE_TIME* prt, BSTR* ppName) = 0;
- STDMETHOD(ChapSort) () = 0;
+ STDMETHOD_(DWORD, ChapGetCount)() = 0;
+ STDMETHOD(ChapGet)(DWORD iIndex, REFERENCE_TIME * prt, BSTR * ppName) = 0;
+ STDMETHOD(ChapSet)(DWORD iIndex, REFERENCE_TIME rt, LPCWSTR pName) = 0;
+ STDMETHOD(ChapAppend)(REFERENCE_TIME rt, LPCWSTR pName) = 0;
+ STDMETHOD(ChapRemoveAt)(DWORD iIndex) = 0;
+ STDMETHOD(ChapRemoveAll)() = 0;
+ STDMETHOD_(long, ChapLookup)(REFERENCE_TIME * prt, BSTR * ppName) = 0;
+ STDMETHOD(ChapSort)() = 0;
};
class CDSMChapter
{
- static int counter;
- int order;
+ static int counter;
+ int order;
public:
- REFERENCE_TIME rt;
- CStringW name;
- CDSMChapter();
- CDSMChapter(REFERENCE_TIME rt, LPCWSTR name);
- CDSMChapter& operator = (const CDSMChapter& c);
- static int Compare(const void* a, const void* b);
+ REFERENCE_TIME rt;
+ CStringW name;
+ CDSMChapter();
+ CDSMChapter(REFERENCE_TIME rt, LPCWSTR name);
+ CDSMChapter& operator = (const CDSMChapter& c);
+ static int Compare(const void* a, const void* b);
};
class IDSMChapterBagImpl : public IDSMChapterBag
{
protected:
- CAtlArray<CDSMChapter> m_chapters;
- bool m_fSorted;
+ CAtlArray<CDSMChapter> m_chapters;
+ bool m_fSorted;
public:
- IDSMChapterBagImpl();
+ IDSMChapterBagImpl();
- void operator += (const CDSMChapter& c) { m_chapters.Add(c); m_fSorted = false; }
+ void operator += (const CDSMChapter& c) { m_chapters.Add(c); m_fSorted = false; }
- // IDSMChapterBag
+ // IDSMChapterBag
- STDMETHODIMP_(DWORD) ChapGetCount();
- STDMETHODIMP ChapGet(DWORD iIndex, REFERENCE_TIME* prt, BSTR* ppName = NULL);
- STDMETHODIMP ChapSet(DWORD iIndex, REFERENCE_TIME rt, LPCWSTR pName);
- STDMETHODIMP ChapAppend(REFERENCE_TIME rt, LPCWSTR pName);
- STDMETHODIMP ChapRemoveAt(DWORD iIndex);
- STDMETHODIMP ChapRemoveAll();
- STDMETHODIMP_(long) ChapLookup(REFERENCE_TIME* prt, BSTR* ppName = NULL);
- STDMETHODIMP ChapSort();
+ STDMETHODIMP_(DWORD) ChapGetCount();
+ STDMETHODIMP ChapGet(DWORD iIndex, REFERENCE_TIME* prt, BSTR* ppName = NULL);
+ STDMETHODIMP ChapSet(DWORD iIndex, REFERENCE_TIME rt, LPCWSTR pName);
+ STDMETHODIMP ChapAppend(REFERENCE_TIME rt, LPCWSTR pName);
+ STDMETHODIMP ChapRemoveAt(DWORD iIndex);
+ STDMETHODIMP ChapRemoveAll();
+ STDMETHODIMP_(long) ChapLookup(REFERENCE_TIME* prt, BSTR* ppName = NULL);
+ STDMETHODIMP ChapSort();
};
class CDSMChapterBag : public CUnknown, public IDSMChapterBagImpl
{
public:
- CDSMChapterBag(LPUNKNOWN pUnk, HRESULT* phr);
+ CDSMChapterBag(LPUNKNOWN pUnk, HRESULT* phr);
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
};
template<class T>
-ptrdiff_t range_bsearch(CAtlArray<T> const &tArray, REFERENCE_TIME rt)
+ptrdiff_t range_bsearch(CAtlArray<T> const& tArray, REFERENCE_TIME rt)
{
- ptrdiff_t i = 0, j = tArray.GetCount() - 1, ret = -1;
- if (j >= 0 && rt >= tArray[j].rt) {
- return j;
- }
- while (i < j) {
- size_t mid = static_cast<size_t>(i + j) >> 1;
- REFERENCE_TIME midrt = tArray[mid].rt;
- if (rt == midrt) {
- ret = mid;
- break;
- } else if (rt < midrt) {
- ret = -1;
- if (j == mid) {
- --mid;
- }
- j = mid;
- } else if (rt > midrt) {
- ret = mid;
- if (i == mid) {
- ++mid;
- }
- i = mid;
- }
- }
- return ret;// in general, the return is unsigned, only when tArray is empty, the return will be -1 for status invalid
+ ptrdiff_t i = 0, j = tArray.GetCount() - 1, ret = -1;
+ if (j >= 0 && rt >= tArray[j].rt) {
+ return j;
+ }
+ while (i < j) {
+ size_t mid = static_cast<size_t>(i + j) >> 1;
+ REFERENCE_TIME midrt = tArray[mid].rt;
+ if (rt == midrt) {
+ ret = mid;
+ break;
+ } else if (rt < midrt) {
+ ret = -1;
+ if (j == mid) {
+ --mid;
+ }
+ j = mid;
+ } else if (rt > midrt) {
+ ret = mid;
+ if (i == mid) {
+ ++mid;
+ }
+ i = mid;
+ }
+ }
+ return ret;// in general, the return is unsigned, only when tArray is empty, the return will be -1 for status invalid
}
diff --git a/src/DSUtil/DSUtil.cpp b/src/DSUtil/DSUtil.cpp
index e5231f3c5..d9ab6bd08 100644
--- a/src/DSUtil/DSUtil.cpp
+++ b/src/DSUtil/DSUtil.cpp
@@ -38,2594 +38,2577 @@
void DumpStreamConfig(TCHAR* fn, IAMStreamConfig* pAMVSCCap)
{
- CString s;
- CStdioFile f;
- if (!f.Open(fn, CFile::modeCreate|CFile::modeWrite|CFile::typeText)) {
- return;
- }
-
- int cnt = 0, size = 0;
- if (FAILED(pAMVSCCap->GetNumberOfCapabilities(&cnt, &size))) {
- return;
- }
-
- s.Format(_T("cnt %d, size %d\n"), cnt, size);
- f.WriteString(s);
-
- if (size == sizeof(VIDEO_STREAM_CONFIG_CAPS)) {
- for (int i = 0; i < cnt; i++) {
- AM_MEDIA_TYPE* pmt = NULL;
-
- VIDEO_STREAM_CONFIG_CAPS caps;
- memset(&caps, 0, sizeof(caps));
-
- s.Format(_T("%d\n"), i);
- f.WriteString(s);
-
- if (FAILED(pAMVSCCap->GetStreamCaps(i, &pmt, (BYTE*)&caps))) {
- continue;
- }
-
- {
- s = _T("VIDEO_STREAM_CONFIG_CAPS\n");
- s.AppendFormat(_T("\tVideoStandard 0x%08x\n"), caps.VideoStandard);
- s.AppendFormat(_T("\tInputSize %dx%d\n"), caps.InputSize);
- s.AppendFormat(_T("\tCroppingSize %dx%d - %dx%d\n"), caps.MinCroppingSize, caps.MaxCroppingSize);
- s.AppendFormat(_T("\tCropGranularity %d, %d\n"), caps.CropGranularityX, caps.CropGranularityY);
- s.AppendFormat(_T("\tCropAlign %d, %d\n"), caps.CropAlignX, caps.CropAlignY);
- s.AppendFormat(_T("\tOutputSize %dx%d - %dx%d\n"), caps.MinOutputSize, caps.MaxOutputSize);
- s.AppendFormat(_T("\tOutputGranularity %d, %d\n"), caps.OutputGranularityX, caps.OutputGranularityY);
- s.AppendFormat(_T("\tStretchTaps %d, %d\n"), caps.StretchTapsX, caps.StretchTapsY);
- s.AppendFormat(_T("\tShrinkTaps %d, %d\n"), caps.ShrinkTapsX, caps.ShrinkTapsY);
- s.AppendFormat(_T("\tFrameInterval %I64d, %I64d (%.4f, %.4f)\n"),
- caps.MinFrameInterval, caps.MaxFrameInterval,
- (float)10000000/caps.MinFrameInterval, (float)10000000/caps.MaxFrameInterval);
- s.AppendFormat(_T("\tBitsPerSecond %d - %d\n"), caps.MinBitsPerSecond, caps.MaxBitsPerSecond);
- f.WriteString(s);
- }
-
- BITMAPINFOHEADER* pbh;
- if (pmt->formattype == FORMAT_VideoInfo) {
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
- pbh = &vih->bmiHeader;
-
- s = _T("FORMAT_VideoInfo\n");
- s.AppendFormat(_T("\tAvgTimePerFrame %I64d, %.4f\n"), vih->AvgTimePerFrame, (float)10000000/vih->AvgTimePerFrame);
- s.AppendFormat(_T("\trcSource %d,%d,%d,%d\n"), vih->rcSource);
- s.AppendFormat(_T("\trcTarget %d,%d,%d,%d\n"), vih->rcTarget);
- f.WriteString(s);
- } else if (pmt->formattype == FORMAT_VideoInfo2) {
- VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pmt->pbFormat;
- pbh = &vih->bmiHeader;
-
- s = _T("FORMAT_VideoInfo2\n");
- s.AppendFormat(_T("\tAvgTimePerFrame %I64d, %.4f\n"), vih->AvgTimePerFrame, (float)10000000/vih->AvgTimePerFrame);
- s.AppendFormat(_T("\trcSource %d,%d,%d,%d\n"), vih->rcSource);
- s.AppendFormat(_T("\trcTarget %d,%d,%d,%d\n"), vih->rcTarget);
- s.AppendFormat(_T("\tdwInterlaceFlags 0x%x\n"), vih->dwInterlaceFlags);
- s.AppendFormat(_T("\tdwPictAspectRatio %d:%d\n"), vih->dwPictAspectRatioX, vih->dwPictAspectRatioY);
- f.WriteString(s);
- } else {
- DeleteMediaType(pmt);
- continue;
- }
-
- s = _T("BITMAPINFOHEADER\n");
- s.AppendFormat(_T("\tbiCompression %x\n"), pbh->biCompression);
- s.AppendFormat(_T("\tbiWidth %d\n"), pbh->biWidth);
- s.AppendFormat(_T("\tbiHeight %d\n"), pbh->biHeight);
- s.AppendFormat(_T("\tbiBitCount %d\n"), pbh->biBitCount);
- s.AppendFormat(_T("\tbiPlanes %d\n"), pbh->biPlanes);
- s.AppendFormat(_T("\tbiSizeImage %d\n"), pbh->biSizeImage);
- f.WriteString(s);
-
- DeleteMediaType(pmt);
- }
- } else if (size == sizeof(AUDIO_STREAM_CONFIG_CAPS)) {
- // TODO
- }
+ CString s;
+ CStdioFile f;
+ if (!f.Open(fn, CFile::modeCreate | CFile::modeWrite | CFile::typeText)) {
+ return;
+ }
+
+ int cnt = 0, size = 0;
+ if (FAILED(pAMVSCCap->GetNumberOfCapabilities(&cnt, &size))) {
+ return;
+ }
+
+ s.Format(_T("cnt %d, size %d\n"), cnt, size);
+ f.WriteString(s);
+
+ if (size == sizeof(VIDEO_STREAM_CONFIG_CAPS)) {
+ for (int i = 0; i < cnt; i++) {
+ AM_MEDIA_TYPE* pmt = NULL;
+
+ VIDEO_STREAM_CONFIG_CAPS caps;
+ memset(&caps, 0, sizeof(caps));
+
+ s.Format(_T("%d\n"), i);
+ f.WriteString(s);
+
+ if (FAILED(pAMVSCCap->GetStreamCaps(i, &pmt, (BYTE*)&caps))) {
+ continue;
+ }
+
+ {
+ s = _T("VIDEO_STREAM_CONFIG_CAPS\n");
+ s.AppendFormat(_T("\tVideoStandard 0x%08x\n"), caps.VideoStandard);
+ s.AppendFormat(_T("\tInputSize %dx%d\n"), caps.InputSize);
+ s.AppendFormat(_T("\tCroppingSize %dx%d - %dx%d\n"), caps.MinCroppingSize, caps.MaxCroppingSize);
+ s.AppendFormat(_T("\tCropGranularity %d, %d\n"), caps.CropGranularityX, caps.CropGranularityY);
+ s.AppendFormat(_T("\tCropAlign %d, %d\n"), caps.CropAlignX, caps.CropAlignY);
+ s.AppendFormat(_T("\tOutputSize %dx%d - %dx%d\n"), caps.MinOutputSize, caps.MaxOutputSize);
+ s.AppendFormat(_T("\tOutputGranularity %d, %d\n"), caps.OutputGranularityX, caps.OutputGranularityY);
+ s.AppendFormat(_T("\tStretchTaps %d, %d\n"), caps.StretchTapsX, caps.StretchTapsY);
+ s.AppendFormat(_T("\tShrinkTaps %d, %d\n"), caps.ShrinkTapsX, caps.ShrinkTapsY);
+ s.AppendFormat(_T("\tFrameInterval %I64d, %I64d (%.4f, %.4f)\n"),
+ caps.MinFrameInterval, caps.MaxFrameInterval,
+ (float)10000000 / caps.MinFrameInterval, (float)10000000 / caps.MaxFrameInterval);
+ s.AppendFormat(_T("\tBitsPerSecond %d - %d\n"), caps.MinBitsPerSecond, caps.MaxBitsPerSecond);
+ f.WriteString(s);
+ }
+
+ BITMAPINFOHEADER* pbh;
+ if (pmt->formattype == FORMAT_VideoInfo) {
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
+ pbh = &vih->bmiHeader;
+
+ s = _T("FORMAT_VideoInfo\n");
+ s.AppendFormat(_T("\tAvgTimePerFrame %I64d, %.4f\n"), vih->AvgTimePerFrame, (float)10000000 / vih->AvgTimePerFrame);
+ s.AppendFormat(_T("\trcSource %d,%d,%d,%d\n"), vih->rcSource);
+ s.AppendFormat(_T("\trcTarget %d,%d,%d,%d\n"), vih->rcTarget);
+ f.WriteString(s);
+ } else if (pmt->formattype == FORMAT_VideoInfo2) {
+ VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pmt->pbFormat;
+ pbh = &vih->bmiHeader;
+
+ s = _T("FORMAT_VideoInfo2\n");
+ s.AppendFormat(_T("\tAvgTimePerFrame %I64d, %.4f\n"), vih->AvgTimePerFrame, (float)10000000 / vih->AvgTimePerFrame);
+ s.AppendFormat(_T("\trcSource %d,%d,%d,%d\n"), vih->rcSource);
+ s.AppendFormat(_T("\trcTarget %d,%d,%d,%d\n"), vih->rcTarget);
+ s.AppendFormat(_T("\tdwInterlaceFlags 0x%x\n"), vih->dwInterlaceFlags);
+ s.AppendFormat(_T("\tdwPictAspectRatio %d:%d\n"), vih->dwPictAspectRatioX, vih->dwPictAspectRatioY);
+ f.WriteString(s);
+ } else {
+ DeleteMediaType(pmt);
+ continue;
+ }
+
+ s = _T("BITMAPINFOHEADER\n");
+ s.AppendFormat(_T("\tbiCompression %x\n"), pbh->biCompression);
+ s.AppendFormat(_T("\tbiWidth %d\n"), pbh->biWidth);
+ s.AppendFormat(_T("\tbiHeight %d\n"), pbh->biHeight);
+ s.AppendFormat(_T("\tbiBitCount %d\n"), pbh->biBitCount);
+ s.AppendFormat(_T("\tbiPlanes %d\n"), pbh->biPlanes);
+ s.AppendFormat(_T("\tbiSizeImage %d\n"), pbh->biSizeImage);
+ f.WriteString(s);
+
+ DeleteMediaType(pmt);
+ }
+ } else if (size == sizeof(AUDIO_STREAM_CONFIG_CAPS)) {
+ // TODO
+ }
}
int CountPins(IBaseFilter* pBF, int& nIn, int& nOut, int& nInC, int& nOutC)
{
- nIn = nOut = 0;
- nInC = nOutC = 0;
-
- BeginEnumPins(pBF, pEP, pPin) {
- PIN_DIRECTION dir;
- if (SUCCEEDED(pPin->QueryDirection(&dir))) {
- CComPtr<IPin> pPinConnectedTo;
- pPin->ConnectedTo(&pPinConnectedTo);
-
- if (dir == PINDIR_INPUT) {
- nIn++;
- if (pPinConnectedTo) {
- nInC++;
- }
- } else if (dir == PINDIR_OUTPUT) {
- nOut++;
- if (pPinConnectedTo) {
- nOutC++;
- }
- }
- }
- }
- EndEnumPins
-
- return (nIn + nOut);
+ nIn = nOut = 0;
+ nInC = nOutC = 0;
+
+ BeginEnumPins(pBF, pEP, pPin) {
+ PIN_DIRECTION dir;
+ if (SUCCEEDED(pPin->QueryDirection(&dir))) {
+ CComPtr<IPin> pPinConnectedTo;
+ pPin->ConnectedTo(&pPinConnectedTo);
+
+ if (dir == PINDIR_INPUT) {
+ nIn++;
+ if (pPinConnectedTo) {
+ nInC++;
+ }
+ } else if (dir == PINDIR_OUTPUT) {
+ nOut++;
+ if (pPinConnectedTo) {
+ nOutC++;
+ }
+ }
+ }
+ }
+ EndEnumPins
+
+ return (nIn + nOut);
}
bool IsSplitter(IBaseFilter* pBF, bool fCountConnectedOnly)
{
- int nIn, nOut, nInC, nOutC;
- CountPins(pBF, nIn, nOut, nInC, nOutC);
- return (fCountConnectedOnly ? nOutC > 1 : nOut > 1);
+ int nIn, nOut, nInC, nOutC;
+ CountPins(pBF, nIn, nOut, nInC, nOutC);
+ return (fCountConnectedOnly ? nOutC > 1 : nOut > 1);
}
bool IsMultiplexer(IBaseFilter* pBF, bool fCountConnectedOnly)
{
- int nIn, nOut, nInC, nOutC;
- CountPins(pBF, nIn, nOut, nInC, nOutC);
- return (fCountConnectedOnly ? nInC > 1 : nIn > 1);
+ int nIn, nOut, nInC, nOutC;
+ CountPins(pBF, nIn, nOut, nInC, nOutC);
+ return (fCountConnectedOnly ? nInC > 1 : nIn > 1);
}
bool IsStreamStart(IBaseFilter* pBF)
{
- CComQIPtr<IAMFilterMiscFlags> pAMMF(pBF);
- if (pAMMF && pAMMF->GetMiscFlags()&AM_FILTER_MISC_FLAGS_IS_SOURCE) {
- return true;
- }
+ CComQIPtr<IAMFilterMiscFlags> pAMMF(pBF);
+ if (pAMMF && pAMMF->GetMiscFlags()&AM_FILTER_MISC_FLAGS_IS_SOURCE) {
+ return true;
+ }
- int nIn, nOut, nInC, nOutC;
- CountPins(pBF, nIn, nOut, nInC, nOutC);
- AM_MEDIA_TYPE mt;
- CComPtr<IPin> pIn = GetFirstPin(pBF);
- return ((nOut > 1)
- || (nOut > 0 && nIn == 1 && pIn && SUCCEEDED(pIn->ConnectionMediaType(&mt)) && mt.majortype == MEDIATYPE_Stream));
+ int nIn, nOut, nInC, nOutC;
+ CountPins(pBF, nIn, nOut, nInC, nOutC);
+ AM_MEDIA_TYPE mt;
+ CComPtr<IPin> pIn = GetFirstPin(pBF);
+ return ((nOut > 1)
+ || (nOut > 0 && nIn == 1 && pIn && SUCCEEDED(pIn->ConnectionMediaType(&mt)) && mt.majortype == MEDIATYPE_Stream));
}
bool IsStreamEnd(IBaseFilter* pBF)
{
- int nIn, nOut, nInC, nOutC;
- CountPins(pBF, nIn, nOut, nInC, nOutC);
- return (nOut == 0);
+ int nIn, nOut, nInC, nOutC;
+ CountPins(pBF, nIn, nOut, nInC, nOutC);
+ return (nOut == 0);
}
bool IsVideoRenderer(IBaseFilter* pBF)
{
- int nIn, nOut, nInC, nOutC;
- CountPins(pBF, nIn, nOut, nInC, nOutC);
+ int nIn, nOut, nInC, nOutC;
+ CountPins(pBF, nIn, nOut, nInC, nOutC);
- if (nInC > 0 && nOut == 0) {
- BeginEnumPins(pBF, pEP, pPin) {
- AM_MEDIA_TYPE mt;
- if (S_OK != pPin->ConnectionMediaType(&mt)) {
- continue;
- }
+ if (nInC > 0 && nOut == 0) {
+ BeginEnumPins(pBF, pEP, pPin) {
+ AM_MEDIA_TYPE mt;
+ if (S_OK != pPin->ConnectionMediaType(&mt)) {
+ continue;
+ }
- FreeMediaType(mt);
+ FreeMediaType(mt);
- return !!(mt.majortype == MEDIATYPE_Video);
- /*&& (mt.formattype == FORMAT_VideoInfo || mt.formattype == FORMAT_VideoInfo2));*/
- }
- EndEnumPins
- }
+ return !!(mt.majortype == MEDIATYPE_Video);
+ /*&& (mt.formattype == FORMAT_VideoInfo || mt.formattype == FORMAT_VideoInfo2));*/
+ }
+ EndEnumPins
+ }
- CLSID clsid;
- memcpy(&clsid, &GUID_NULL, sizeof(clsid));
- pBF->GetClassID(&clsid);
+ CLSID clsid;
+ memcpy(&clsid, &GUID_NULL, sizeof(clsid));
+ pBF->GetClassID(&clsid);
- return (clsid == CLSID_VideoRenderer || clsid == CLSID_VideoRendererDefault);
+ return (clsid == CLSID_VideoRenderer || clsid == CLSID_VideoRendererDefault);
}
DEFINE_GUID(CLSID_ReClock,
- 0x9dc15360, 0x914c, 0x46b8, 0xb9, 0xdf, 0xbf, 0xe6, 0x7f, 0xd3, 0x6c, 0x6a);
+ 0x9dc15360, 0x914c, 0x46b8, 0xb9, 0xdf, 0xbf, 0xe6, 0x7f, 0xd3, 0x6c, 0x6a);
bool IsAudioWaveRenderer(IBaseFilter* pBF)
{
- int nIn, nOut, nInC, nOutC;
- CountPins(pBF, nIn, nOut, nInC, nOutC);
+ int nIn, nOut, nInC, nOutC;
+ CountPins(pBF, nIn, nOut, nInC, nOutC);
- if (nInC > 0 && nOut == 0 && CComQIPtr<IBasicAudio>(pBF)) {
- BeginEnumPins(pBF, pEP, pPin) {
- AM_MEDIA_TYPE mt;
- if (S_OK != pPin->ConnectionMediaType(&mt)) {
- continue;
- }
+ if (nInC > 0 && nOut == 0 && CComQIPtr<IBasicAudio>(pBF)) {
+ BeginEnumPins(pBF, pEP, pPin) {
+ AM_MEDIA_TYPE mt;
+ if (S_OK != pPin->ConnectionMediaType(&mt)) {
+ continue;
+ }
- FreeMediaType(mt);
+ FreeMediaType(mt);
- return !!(mt.majortype == MEDIATYPE_Audio);
- /*&& mt.formattype == FORMAT_WaveFormatEx);*/
- }
- EndEnumPins
- }
+ return !!(mt.majortype == MEDIATYPE_Audio);
+ /*&& mt.formattype == FORMAT_WaveFormatEx);*/
+ }
+ EndEnumPins
+ }
- CLSID clsid;
- memcpy(&clsid, &GUID_NULL, sizeof(clsid));
- pBF->GetClassID(&clsid);
+ CLSID clsid;
+ memcpy(&clsid, &GUID_NULL, sizeof(clsid));
+ pBF->GetClassID(&clsid);
- return (clsid == CLSID_DSoundRender || clsid == CLSID_AudioRender || clsid == CLSID_ReClock
- || clsid == __uuidof(CNullAudioRenderer) || clsid == __uuidof(CNullUAudioRenderer));
+ return (clsid == CLSID_DSoundRender || clsid == CLSID_AudioRender || clsid == CLSID_ReClock
+ || clsid == __uuidof(CNullAudioRenderer) || clsid == __uuidof(CNullUAudioRenderer));
}
IBaseFilter* GetUpStreamFilter(IBaseFilter* pBF, IPin* pInputPin)
{
- return GetFilterFromPin(GetUpStreamPin(pBF, pInputPin));
+ return GetFilterFromPin(GetUpStreamPin(pBF, pInputPin));
}
IPin* GetUpStreamPin(IBaseFilter* pBF, IPin* pInputPin)
{
- BeginEnumPins(pBF, pEP, pPin) {
- if (pInputPin && pInputPin != pPin) {
- continue;
- }
+ BeginEnumPins(pBF, pEP, pPin) {
+ if (pInputPin && pInputPin != pPin) {
+ continue;
+ }
- PIN_DIRECTION dir;
- CComPtr<IPin> pPinConnectedTo;
- if (SUCCEEDED(pPin->QueryDirection(&dir)) && dir == PINDIR_INPUT
- && SUCCEEDED(pPin->ConnectedTo(&pPinConnectedTo))) {
- IPin* pRet = pPinConnectedTo.Detach();
- pRet->Release();
- return pRet;
- }
- }
- EndEnumPins
+ PIN_DIRECTION dir;
+ CComPtr<IPin> pPinConnectedTo;
+ if (SUCCEEDED(pPin->QueryDirection(&dir)) && dir == PINDIR_INPUT
+ && SUCCEEDED(pPin->ConnectedTo(&pPinConnectedTo))) {
+ IPin* pRet = pPinConnectedTo.Detach();
+ pRet->Release();
+ return pRet;
+ }
+ }
+ EndEnumPins
- return NULL;
+ return NULL;
}
IPin* GetFirstPin(IBaseFilter* pBF, PIN_DIRECTION dir)
{
- if (!pBF) {
- return NULL;
- }
+ if (!pBF) {
+ return NULL;
+ }
- BeginEnumPins(pBF, pEP, pPin) {
- PIN_DIRECTION dir2;
- pPin->QueryDirection(&dir2);
- if (dir == dir2) {
- IPin* pRet = pPin.Detach();
- pRet->Release();
- return pRet;
- }
- }
- EndEnumPins
+ BeginEnumPins(pBF, pEP, pPin) {
+ PIN_DIRECTION dir2;
+ pPin->QueryDirection(&dir2);
+ if (dir == dir2) {
+ IPin* pRet = pPin.Detach();
+ pRet->Release();
+ return pRet;
+ }
+ }
+ EndEnumPins
- return NULL;
+ return NULL;
}
IPin* GetFirstDisconnectedPin(IBaseFilter* pBF, PIN_DIRECTION dir)
{
- if (!pBF) {
- return NULL;
- }
+ if (!pBF) {
+ return NULL;
+ }
- BeginEnumPins(pBF, pEP, pPin) {
- PIN_DIRECTION dir2;
- pPin->QueryDirection(&dir2);
- CComPtr<IPin> pPinTo;
- if (dir == dir2 && (S_OK != pPin->ConnectedTo(&pPinTo))) {
- IPin* pRet = pPin.Detach();
- pRet->Release();
- return pRet;
- }
- }
- EndEnumPins
+ BeginEnumPins(pBF, pEP, pPin) {
+ PIN_DIRECTION dir2;
+ pPin->QueryDirection(&dir2);
+ CComPtr<IPin> pPinTo;
+ if (dir == dir2 && (S_OK != pPin->ConnectedTo(&pPinTo))) {
+ IPin* pRet = pPin.Detach();
+ pRet->Release();
+ return pRet;
+ }
+ }
+ EndEnumPins
- return NULL;
+ return NULL;
}
IBaseFilter* FindFilter(LPCWSTR clsid, IFilterGraph* pFG)
{
- CLSID clsid2;
- CLSIDFromString(CComBSTR(clsid), &clsid2);
- return FindFilter(clsid2, pFG);
+ CLSID clsid2;
+ CLSIDFromString(CComBSTR(clsid), &clsid2);
+ return FindFilter(clsid2, pFG);
}
IBaseFilter* FindFilter(const CLSID& clsid, IFilterGraph* pFG)
{
- BeginEnumFilters(pFG, pEF, pBF) {
- CLSID clsid2;
- if (SUCCEEDED(pBF->GetClassID(&clsid2)) && clsid == clsid2) {
- return pBF;
- }
- }
- EndEnumFilters
+ BeginEnumFilters(pFG, pEF, pBF) {
+ CLSID clsid2;
+ if (SUCCEEDED(pBF->GetClassID(&clsid2)) && clsid == clsid2) {
+ return pBF;
+ }
+ }
+ EndEnumFilters
- return NULL;
+ return NULL;
}
IPin* FindPin(IBaseFilter* pBF, PIN_DIRECTION direction, const AM_MEDIA_TYPE* pRequestedMT)
{
- PIN_DIRECTION pindir;
- BeginEnumPins(pBF, pEP, pPin) {
- CComPtr<IPin> pFellow;
-
- if (SUCCEEDED (pPin->QueryDirection(&pindir)) &&
- pindir == direction &&
- pPin->ConnectedTo(&pFellow) == VFW_E_NOT_CONNECTED) {
- BeginEnumMediaTypes(pPin, pEM, pmt) {
- if (pmt->majortype == pRequestedMT->majortype && pmt->subtype == pRequestedMT->subtype) {
- return (pPin);
- }
- }
- EndEnumMediaTypes(pmt)
- }
- }
- EndEnumPins
- return NULL;
+ PIN_DIRECTION pindir;
+ BeginEnumPins(pBF, pEP, pPin) {
+ CComPtr<IPin> pFellow;
+
+ if (SUCCEEDED(pPin->QueryDirection(&pindir)) &&
+ pindir == direction &&
+ pPin->ConnectedTo(&pFellow) == VFW_E_NOT_CONNECTED) {
+ BeginEnumMediaTypes(pPin, pEM, pmt) {
+ if (pmt->majortype == pRequestedMT->majortype && pmt->subtype == pRequestedMT->subtype) {
+ return (pPin);
+ }
+ }
+ EndEnumMediaTypes(pmt)
+ }
+ }
+ EndEnumPins
+ return NULL;
}
CStringW GetFilterName(IBaseFilter* pBF)
{
- CStringW name = _T("");
-
- if (pBF) {
- CLSID clsid = GetCLSID(pBF);
- if (clsid == CLSID_AsyncReader) {
- name = _T("File Source (Async.)");
- } else if (clsid == CLSID_URLReader) {
- name = _T("File Source (URL)");
- } else if (clsid == CLSID_WMAsfReader) {
- name = _T("WM ASF Reader");
- } else if (clsid == GUIDFromCString(_T("{D8980E15-E1F6-4916-A10F-D7EB4E9E10B8}"))) {
- name = _T("AV Source");
- } else if (clsid == GUIDFromCString(_T("{B98D13E7-55DB-4385-A33D-09FD1BA26338}"))) {
- name = _T("LAV Splitter Source");
- } else if (clsid == GUIDFromCString(_T("{55DA30FC-F16B-49FC-BAA5-AE59FC65F82D}"))) {
- name = _T("Haali Media Source");
- } else {
- CFilterInfo fi;
- if (SUCCEEDED(pBF->QueryFilterInfo(&fi))) {
- name = fi.achName;
- }
- }
- }
-
- return name;
+ CStringW name = _T("");
+
+ if (pBF) {
+ CLSID clsid = GetCLSID(pBF);
+ if (clsid == CLSID_AsyncReader) {
+ name = _T("File Source (Async.)");
+ } else if (clsid == CLSID_URLReader) {
+ name = _T("File Source (URL)");
+ } else if (clsid == CLSID_WMAsfReader) {
+ name = _T("WM ASF Reader");
+ } else if (clsid == GUIDFromCString(_T("{D8980E15-E1F6-4916-A10F-D7EB4E9E10B8}"))) {
+ name = _T("AV Source");
+ } else if (clsid == GUIDFromCString(_T("{B98D13E7-55DB-4385-A33D-09FD1BA26338}"))) {
+ name = _T("LAV Splitter Source");
+ } else if (clsid == GUIDFromCString(_T("{55DA30FC-F16B-49FC-BAA5-AE59FC65F82D}"))) {
+ name = _T("Haali Media Source");
+ } else {
+ CFilterInfo fi;
+ if (SUCCEEDED(pBF->QueryFilterInfo(&fi))) {
+ name = fi.achName;
+ }
+ }
+ }
+
+ return name;
}
CStringW GetPinName(IPin* pPin)
{
- CStringW name;
- CPinInfo pi;
- if (pPin && SUCCEEDED(pPin->QueryPinInfo(&pi))) {
- name = pi.achName;
- }
+ CStringW name;
+ CPinInfo pi;
+ if (pPin && SUCCEEDED(pPin->QueryPinInfo(&pi))) {
+ name = pi.achName;
+ }
- return name;
+ return name;
}
IFilterGraph* GetGraphFromFilter(IBaseFilter* pBF)
{
- if (!pBF) {
- return NULL;
- }
- IFilterGraph* pGraph = NULL;
- CFilterInfo fi;
- if (pBF && SUCCEEDED(pBF->QueryFilterInfo(&fi))) {
- pGraph = fi.pGraph;
- }
- return pGraph;
+ if (!pBF) {
+ return NULL;
+ }
+ IFilterGraph* pGraph = NULL;
+ CFilterInfo fi;
+ if (pBF && SUCCEEDED(pBF->QueryFilterInfo(&fi))) {
+ pGraph = fi.pGraph;
+ }
+ return pGraph;
}
IBaseFilter* GetFilterFromPin(IPin* pPin)
{
- if (!pPin) {
- return NULL;
- }
- IBaseFilter* pBF = NULL;
- CPinInfo pi;
- if (pPin && SUCCEEDED(pPin->QueryPinInfo(&pi))) {
- pBF = pi.pFilter;
- }
- return pBF;
+ if (!pPin) {
+ return NULL;
+ }
+ IBaseFilter* pBF = NULL;
+ CPinInfo pi;
+ if (pPin && SUCCEEDED(pPin->QueryPinInfo(&pi))) {
+ pBF = pi.pFilter;
+ }
+ return pBF;
}
IPin* AppendFilter(IPin* pPin, CString DisplayName, IGraphBuilder* pGB)
{
- IPin* pRet = pPin;
-
- CInterfaceList<IBaseFilter> pFilters;
-
- do {
- if (!pPin || DisplayName.IsEmpty() || !pGB) {
- break;
- }
-
- CComPtr<IPin> pPinTo;
- PIN_DIRECTION dir;
- if (FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_OUTPUT || SUCCEEDED(pPin->ConnectedTo(&pPinTo))) {
- break;
- }
-
- CComPtr<IBindCtx> pBindCtx;
- CreateBindCtx(0, &pBindCtx);
-
- CComPtr<IMoniker> pMoniker;
- ULONG chEaten;
- if (S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker)) {
- break;
- }
-
- CComPtr<IBaseFilter> pBF;
- if (FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF) {
- break;
- }
-
- CComPtr<IPropertyBag> pPB;
- if (FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))) {
- break;
- }
-
- CComVariant var;
- if (FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
- break;
- }
-
- pFilters.AddTail(pBF);
- BeginEnumFilters(pGB, pEnum, pBF2)
- pFilters.AddTail(pBF2);
- EndEnumFilters
-
- if (FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal)))) {
- break;
- }
-
- BeginEnumFilters(pGB, pEnum, pBF2)
- if (!pFilters.Find(pBF2) && SUCCEEDED(pGB->RemoveFilter(pBF2))) {
- pEnum->Reset();
- }
- EndEnumFilters
-
- pPinTo = GetFirstPin(pBF, PINDIR_INPUT);
- if (!pPinTo) {
- pGB->RemoveFilter(pBF);
- break;
- }
-
- HRESULT hr;
- if (FAILED(hr = pGB->ConnectDirect(pPin, pPinTo, NULL))) {
- hr = pGB->Connect(pPin, pPinTo);
- pGB->RemoveFilter(pBF);
- break;
- }
-
- BeginEnumFilters(pGB, pEnum, pBF2)
- if (!pFilters.Find(pBF2) && SUCCEEDED(pGB->RemoveFilter(pBF2))) {
- pEnum->Reset();
- }
- EndEnumFilters
-
- pRet = GetFirstPin(pBF, PINDIR_OUTPUT);
- if (!pRet) {
- pRet = pPin;
- pGB->RemoveFilter(pBF);
- break;
- }
- } while (false);
-
- return pRet;
+ IPin* pRet = pPin;
+
+ CInterfaceList<IBaseFilter> pFilters;
+
+ do {
+ if (!pPin || DisplayName.IsEmpty() || !pGB) {
+ break;
+ }
+
+ CComPtr<IPin> pPinTo;
+ PIN_DIRECTION dir;
+ if (FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_OUTPUT || SUCCEEDED(pPin->ConnectedTo(&pPinTo))) {
+ break;
+ }
+
+ CComPtr<IBindCtx> pBindCtx;
+ CreateBindCtx(0, &pBindCtx);
+
+ CComPtr<IMoniker> pMoniker;
+ ULONG chEaten;
+ if (S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker)) {
+ break;
+ }
+
+ CComPtr<IBaseFilter> pBF;
+ if (FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF) {
+ break;
+ }
+
+ CComPtr<IPropertyBag> pPB;
+ if (FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))) {
+ break;
+ }
+
+ CComVariant var;
+ if (FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
+ break;
+ }
+
+ pFilters.AddTail(pBF);
+ BeginEnumFilters(pGB, pEnum, pBF2)
+ pFilters.AddTail(pBF2);
+ EndEnumFilters
+
+ if (FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal)))) {
+ break;
+ }
+
+ BeginEnumFilters(pGB, pEnum, pBF2)
+ if (!pFilters.Find(pBF2) && SUCCEEDED(pGB->RemoveFilter(pBF2))) {
+ pEnum->Reset();
+ }
+ EndEnumFilters
+
+ pPinTo = GetFirstPin(pBF, PINDIR_INPUT);
+ if (!pPinTo) {
+ pGB->RemoveFilter(pBF);
+ break;
+ }
+
+ HRESULT hr;
+ if (FAILED(hr = pGB->ConnectDirect(pPin, pPinTo, NULL))) {
+ hr = pGB->Connect(pPin, pPinTo);
+ pGB->RemoveFilter(pBF);
+ break;
+ }
+
+ BeginEnumFilters(pGB, pEnum, pBF2)
+ if (!pFilters.Find(pBF2) && SUCCEEDED(pGB->RemoveFilter(pBF2))) {
+ pEnum->Reset();
+ }
+ EndEnumFilters
+
+ pRet = GetFirstPin(pBF, PINDIR_OUTPUT);
+ if (!pRet) {
+ pRet = pPin;
+ pGB->RemoveFilter(pBF);
+ break;
+ }
+ } while (false);
+
+ return pRet;
}
IPin* InsertFilter(IPin* pPin, CString DisplayName, IGraphBuilder* pGB)
{
- do {
- if (!pPin || DisplayName.IsEmpty() || !pGB) {
- break;
- }
-
- PIN_DIRECTION dir;
- if (FAILED(pPin->QueryDirection(&dir))) {
- break;
- }
-
- CComPtr<IPin> pFrom, pTo;
-
- if (dir == PINDIR_INPUT) {
- pPin->ConnectedTo(&pFrom);
- pTo = pPin;
- } else if (dir == PINDIR_OUTPUT) {
- pFrom = pPin;
- pPin->ConnectedTo(&pTo);
- }
-
- if (!pFrom || !pTo) {
- break;
- }
-
- CComPtr<IBindCtx> pBindCtx;
- CreateBindCtx(0, &pBindCtx);
-
- CComPtr<IMoniker> pMoniker;
- ULONG chEaten;
- if (S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker)) {
- break;
- }
-
- CComPtr<IBaseFilter> pBF;
- if (FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF) {
- break;
- }
-
- CComPtr<IPropertyBag> pPB;
- if (FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))) {
- break;
- }
-
- CComVariant var;
- if (FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
- break;
- }
-
- if (FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal)))) {
- break;
- }
-
- CComPtr<IPin> pFromTo = GetFirstPin(pBF, PINDIR_INPUT);
- if (!pFromTo) {
- pGB->RemoveFilter(pBF);
- break;
- }
-
- if (FAILED(pGB->Disconnect(pFrom)) || FAILED(pGB->Disconnect(pTo))) {
- pGB->RemoveFilter(pBF);
- pGB->ConnectDirect(pFrom, pTo, NULL);
- break;
- }
-
- HRESULT hr;
- if (FAILED(hr = pGB->ConnectDirect(pFrom, pFromTo, NULL))) {
- pGB->RemoveFilter(pBF);
- pGB->ConnectDirect(pFrom, pTo, NULL);
- break;
- }
-
- CComPtr<IPin> pToFrom = GetFirstPin(pBF, PINDIR_OUTPUT);
- if (!pToFrom) {
- pGB->RemoveFilter(pBF);
- pGB->ConnectDirect(pFrom, pTo, NULL);
- break;
- }
-
- if (FAILED(pGB->ConnectDirect(pToFrom, pTo, NULL))) {
- pGB->RemoveFilter(pBF);
- pGB->ConnectDirect(pFrom, pTo, NULL);
- break;
- }
-
- pPin = pToFrom;
- } while (false);
-
- return pPin;
+ do {
+ if (!pPin || DisplayName.IsEmpty() || !pGB) {
+ break;
+ }
+
+ PIN_DIRECTION dir;
+ if (FAILED(pPin->QueryDirection(&dir))) {
+ break;
+ }
+
+ CComPtr<IPin> pFrom, pTo;
+
+ if (dir == PINDIR_INPUT) {
+ pPin->ConnectedTo(&pFrom);
+ pTo = pPin;
+ } else if (dir == PINDIR_OUTPUT) {
+ pFrom = pPin;
+ pPin->ConnectedTo(&pTo);
+ }
+
+ if (!pFrom || !pTo) {
+ break;
+ }
+
+ CComPtr<IBindCtx> pBindCtx;
+ CreateBindCtx(0, &pBindCtx);
+
+ CComPtr<IMoniker> pMoniker;
+ ULONG chEaten;
+ if (S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker)) {
+ break;
+ }
+
+ CComPtr<IBaseFilter> pBF;
+ if (FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF) {
+ break;
+ }
+
+ CComPtr<IPropertyBag> pPB;
+ if (FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))) {
+ break;
+ }
+
+ CComVariant var;
+ if (FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
+ break;
+ }
+
+ if (FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal)))) {
+ break;
+ }
+
+ CComPtr<IPin> pFromTo = GetFirstPin(pBF, PINDIR_INPUT);
+ if (!pFromTo) {
+ pGB->RemoveFilter(pBF);
+ break;
+ }
+
+ if (FAILED(pGB->Disconnect(pFrom)) || FAILED(pGB->Disconnect(pTo))) {
+ pGB->RemoveFilter(pBF);
+ pGB->ConnectDirect(pFrom, pTo, NULL);
+ break;
+ }
+
+ HRESULT hr;
+ if (FAILED(hr = pGB->ConnectDirect(pFrom, pFromTo, NULL))) {
+ pGB->RemoveFilter(pBF);
+ pGB->ConnectDirect(pFrom, pTo, NULL);
+ break;
+ }
+
+ CComPtr<IPin> pToFrom = GetFirstPin(pBF, PINDIR_OUTPUT);
+ if (!pToFrom) {
+ pGB->RemoveFilter(pBF);
+ pGB->ConnectDirect(pFrom, pTo, NULL);
+ break;
+ }
+
+ if (FAILED(pGB->ConnectDirect(pToFrom, pTo, NULL))) {
+ pGB->RemoveFilter(pBF);
+ pGB->ConnectDirect(pFrom, pTo, NULL);
+ break;
+ }
+
+ pPin = pToFrom;
+ } while (false);
+
+ return pPin;
}
void ExtractMediaTypes(IPin* pPin, CAtlArray<GUID>& types)
{
- types.RemoveAll();
+ types.RemoveAll();
- BeginEnumMediaTypes(pPin, pEM, pmt) {
- bool fFound = false;
+ BeginEnumMediaTypes(pPin, pEM, pmt) {
+ bool fFound = false;
- for (ptrdiff_t i = 0; !fFound && i < (int)types.GetCount(); i += 2) {
- if (types[i] == pmt->majortype && types[i+1] == pmt->subtype) {
- fFound = true;
- }
- }
+ for (ptrdiff_t i = 0; !fFound && i < (int)types.GetCount(); i += 2) {
+ if (types[i] == pmt->majortype && types[i + 1] == pmt->subtype) {
+ fFound = true;
+ }
+ }
- if (!fFound) {
- types.Add(pmt->majortype);
- types.Add(pmt->subtype);
- }
- }
- EndEnumMediaTypes(pmt)
+ if (!fFound) {
+ types.Add(pmt->majortype);
+ types.Add(pmt->subtype);
+ }
+ }
+ EndEnumMediaTypes(pmt)
}
void ExtractMediaTypes(IPin* pPin, CAtlList<CMediaType>& mts)
{
- mts.RemoveAll();
+ mts.RemoveAll();
- BeginEnumMediaTypes(pPin, pEM, pmt) {
- bool fFound = false;
+ BeginEnumMediaTypes(pPin, pEM, pmt) {
+ bool fFound = false;
- POSITION pos = mts.GetHeadPosition();
- while (!fFound && pos) {
- CMediaType& mt = mts.GetNext(pos);
- if (mt.majortype == pmt->majortype && mt.subtype == pmt->subtype) {
- fFound = true;
- }
- }
+ POSITION pos = mts.GetHeadPosition();
+ while (!fFound && pos) {
+ CMediaType& mt = mts.GetNext(pos);
+ if (mt.majortype == pmt->majortype && mt.subtype == pmt->subtype) {
+ fFound = true;
+ }
+ }
- if (!fFound) {
- mts.AddTail(CMediaType(*pmt));
- }
- }
- EndEnumMediaTypes(pmt)
+ if (!fFound) {
+ mts.AddTail(CMediaType(*pmt));
+ }
+ }
+ EndEnumMediaTypes(pmt)
}
int Eval_Exception(int n_except)
{
- if (n_except == STATUS_ACCESS_VIOLATION) {
- AfxMessageBox(_T("The property page of this filter has just caused a\nmemory access violation. The application will gently die now :)"));
- }
+ if (n_except == STATUS_ACCESS_VIOLATION) {
+ AfxMessageBox(_T("The property page of this filter has just caused a\nmemory access violation. The application will gently die now :)"));
+ }
- return EXCEPTION_CONTINUE_SEARCH;
+ return EXCEPTION_CONTINUE_SEARCH;
}
void MyOleCreatePropertyFrame(HWND hwndOwner, UINT x, UINT y, LPCOLESTR lpszCaption, ULONG cObjects, LPUNKNOWN FAR* lplpUnk, ULONG cPages, LPCLSID lpPageClsID, LCID lcid, DWORD dwReserved, LPVOID lpvReserved)
{
- __try {
- OleCreatePropertyFrame(hwndOwner, x, y, lpszCaption, cObjects, lplpUnk, cPages, lpPageClsID, lcid, dwReserved, lpvReserved);
- }
- __except (Eval_Exception(GetExceptionCode())) {
- // No code; this block never executed.
- }
+ __try {
+ OleCreatePropertyFrame(hwndOwner, x, y, lpszCaption, cObjects, lplpUnk, cPages, lpPageClsID, lcid, dwReserved, lpvReserved);
+ } __except (Eval_Exception(GetExceptionCode())) {
+ // No code; this block never executed.
+ }
}
void ShowPPage(CString DisplayName, HWND hParentWnd)
{
- CComPtr<IBindCtx> pBindCtx;
- CreateBindCtx(0, &pBindCtx);
+ CComPtr<IBindCtx> pBindCtx;
+ CreateBindCtx(0, &pBindCtx);
- CComPtr<IMoniker> pMoniker;
- ULONG chEaten;
- if (S_OK != MkParseDisplayName(pBindCtx, CStringW(DisplayName), &chEaten, &pMoniker)) {
- return;
- }
+ CComPtr<IMoniker> pMoniker;
+ ULONG chEaten;
+ if (S_OK != MkParseDisplayName(pBindCtx, CStringW(DisplayName), &chEaten, &pMoniker)) {
+ return;
+ }
- CComPtr<IBaseFilter> pBF;
- if (FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF) {
- return;
- }
+ CComPtr<IBaseFilter> pBF;
+ if (FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF) {
+ return;
+ }
- ShowPPage(pBF, hParentWnd);
+ ShowPPage(pBF, hParentWnd);
}
void ShowPPage(IUnknown* pUnk, HWND hParentWnd)
{
- CComQIPtr<ISpecifyPropertyPages> pSPP = pUnk;
- if (!pSPP) {
- return;
- }
-
- CString str;
-
- CComQIPtr<IBaseFilter> pBF = pSPP;
- CFilterInfo fi;
- CComQIPtr<IPin> pPin = pSPP;
- CPinInfo pi;
- if (pBF && SUCCEEDED(pBF->QueryFilterInfo(&fi))) {
- str = fi.achName;
- } else if (pPin && SUCCEEDED(pPin->QueryPinInfo(&pi))) {
- str = pi.achName;
- }
-
- CAUUID caGUID;
- caGUID.pElems = NULL;
- if (SUCCEEDED(pSPP->GetPages(&caGUID))) {
- IUnknown* lpUnk = NULL;
- pSPP.QueryInterface(&lpUnk);
- MyOleCreatePropertyFrame(
- hParentWnd, 0, 0, CStringW(str),
- 1, (IUnknown**)&lpUnk,
- caGUID.cElems, caGUID.pElems,
- 0, 0, NULL);
- lpUnk->Release();
-
- if (caGUID.pElems) {
- CoTaskMemFree(caGUID.pElems);
- }
- }
+ CComQIPtr<ISpecifyPropertyPages> pSPP = pUnk;
+ if (!pSPP) {
+ return;
+ }
+
+ CString str;
+
+ CComQIPtr<IBaseFilter> pBF = pSPP;
+ CFilterInfo fi;
+ CComQIPtr<IPin> pPin = pSPP;
+ CPinInfo pi;
+ if (pBF && SUCCEEDED(pBF->QueryFilterInfo(&fi))) {
+ str = fi.achName;
+ } else if (pPin && SUCCEEDED(pPin->QueryPinInfo(&pi))) {
+ str = pi.achName;
+ }
+
+ CAUUID caGUID;
+ caGUID.pElems = NULL;
+ if (SUCCEEDED(pSPP->GetPages(&caGUID))) {
+ IUnknown* lpUnk = NULL;
+ pSPP.QueryInterface(&lpUnk);
+ MyOleCreatePropertyFrame(
+ hParentWnd, 0, 0, CStringW(str),
+ 1, (IUnknown**)&lpUnk,
+ caGUID.cElems, caGUID.pElems,
+ 0, 0, NULL);
+ lpUnk->Release();
+
+ if (caGUID.pElems) {
+ CoTaskMemFree(caGUID.pElems);
+ }
+ }
}
CLSID GetCLSID(IBaseFilter* pBF)
{
- CLSID clsid = GUID_NULL;
- if (pBF) {
- pBF->GetClassID(&clsid);
- }
- return clsid;
+ CLSID clsid = GUID_NULL;
+ if (pBF) {
+ pBF->GetClassID(&clsid);
+ }
+ return clsid;
}
CLSID GetCLSID(IPin* pPin)
{
- return GetCLSID(GetFilterFromPin(pPin));
+ return GetCLSID(GetFilterFromPin(pPin));
}
bool IsCLSIDRegistered(LPCTSTR clsid)
{
- CString rootkey1(_T("CLSID\\"));
- CString rootkey2(_T("CLSID\\{083863F1-70DE-11d0-BD40-00A0C911CE86}\\Instance\\"));
+ CString rootkey1(_T("CLSID\\"));
+ CString rootkey2(_T("CLSID\\{083863F1-70DE-11d0-BD40-00A0C911CE86}\\Instance\\"));
- return ERROR_SUCCESS == CRegKey().Open(HKEY_CLASSES_ROOT, rootkey1 + clsid, KEY_READ)
- || ERROR_SUCCESS == CRegKey().Open(HKEY_CLASSES_ROOT, rootkey2 + clsid, KEY_READ);
+ return ERROR_SUCCESS == CRegKey().Open(HKEY_CLASSES_ROOT, rootkey1 + clsid, KEY_READ)
+ || ERROR_SUCCESS == CRegKey().Open(HKEY_CLASSES_ROOT, rootkey2 + clsid, KEY_READ);
}
bool IsCLSIDRegistered(const CLSID& clsid)
{
- bool fRet = false;
+ bool fRet = false;
- LPOLESTR pStr = NULL;
- if (S_OK == StringFromCLSID(clsid, &pStr) && pStr) {
- fRet = IsCLSIDRegistered(CString(pStr));
- CoTaskMemFree(pStr);
- }
+ LPOLESTR pStr = NULL;
+ if (S_OK == StringFromCLSID(clsid, &pStr) && pStr) {
+ fRet = IsCLSIDRegistered(CString(pStr));
+ CoTaskMemFree(pStr);
+ }
- return fRet;
+ return fRet;
}
void CStringToBin(CString str, CAtlArray<BYTE>& data)
{
- str.Trim();
- ASSERT((str.GetLength()&1) == 0);
- data.SetCount(str.GetLength()/2);
-
- BYTE b = 0;
-
- str.MakeUpper();
- for (int i = 0, j = str.GetLength(); i < j; i++) {
- TCHAR c = str[i];
- if (c >= _T('0') && c <= _T('9')) {
- if (!(i&1)) {
- b = ((char(c-_T('0'))<<4)&0xf0)|(b&0x0f);
- } else {
- b = (char(c-_T('0'))&0x0f)|(b&0xf0);
- }
- } else if (c >= _T('A') && c <= _T('F')) {
- if (!(i&1)) {
- b = ((char(c-_T('A')+10)<<4)&0xf0)|(b&0x0f);
- } else {
- b = (char(c-_T('A')+10)&0x0f)|(b&0xf0);
- }
- } else {
- break;
- }
-
- if (i&1) {
- data[i>>1] = b;
- b = 0;
- }
- }
+ str.Trim();
+ ASSERT((str.GetLength() & 1) == 0);
+ data.SetCount(str.GetLength() / 2);
+
+ BYTE b = 0;
+
+ str.MakeUpper();
+ for (int i = 0, j = str.GetLength(); i < j; i++) {
+ TCHAR c = str[i];
+ if (c >= _T('0') && c <= _T('9')) {
+ if (!(i & 1)) {
+ b = ((char(c - _T('0')) << 4) & 0xf0) | (b & 0x0f);
+ } else {
+ b = (char(c - _T('0')) & 0x0f) | (b & 0xf0);
+ }
+ } else if (c >= _T('A') && c <= _T('F')) {
+ if (!(i & 1)) {
+ b = ((char(c - _T('A') + 10) << 4) & 0xf0) | (b & 0x0f);
+ } else {
+ b = (char(c - _T('A') + 10) & 0x0f) | (b & 0xf0);
+ }
+ } else {
+ break;
+ }
+
+ if (i & 1) {
+ data[i >> 1] = b;
+ b = 0;
+ }
+ }
}
CString BinToCString(const BYTE* ptr, size_t len)
{
- CString ret;
- TCHAR high, low;
+ CString ret;
+ TCHAR high, low;
- while (len-- > 0) {
- high = (*ptr>>4) >= 10 ? (*ptr>>4)-10 + _T('A') : (*ptr>>4) + _T('0');
- low = (*ptr&0xf) >= 10 ? (*ptr&0xf)-10 + _T('A') : (*ptr&0xf) + _T('0');
+ while (len-- > 0) {
+ high = (*ptr >> 4) >= 10 ? (*ptr >> 4) - 10 + _T('A') : (*ptr >> 4) + _T('0');
+ low = (*ptr & 0xf) >= 10 ? (*ptr & 0xf) - 10 + _T('A') : (*ptr & 0xf) + _T('0');
- ret.AppendFormat(_T("%c%c"), high, low);
+ ret.AppendFormat(_T("%c%c"), high, low);
- ptr++;
- }
+ ptr++;
+ }
- return ret;
+ return ret;
}
static void FindFiles(CString fn, CAtlList<CString>& files)
{
- CString path = fn;
- path.Replace('/', '\\');
- path = path.Left(path.ReverseFind('\\')+1);
+ CString path = fn;
+ path.Replace('/', '\\');
+ path = path.Left(path.ReverseFind('\\') + 1);
- WIN32_FIND_DATA findData;
- HANDLE h = FindFirstFile(fn, &findData);
- if (h != INVALID_HANDLE_VALUE) {
- do {
- files.AddTail(path + findData.cFileName);
- } while (FindNextFile(h, &findData));
+ WIN32_FIND_DATA findData;
+ HANDLE h = FindFirstFile(fn, &findData);
+ if (h != INVALID_HANDLE_VALUE) {
+ do {
+ files.AddTail(path + findData.cFileName);
+ } while (FindNextFile(h, &findData));
- FindClose(h);
- }
+ FindClose(h);
+ }
}
cdrom_t GetCDROMType(TCHAR drive, CAtlList<CString>& files)
{
- files.RemoveAll();
-
- CString path;
- path.Format(_T("%c:"), drive);
-
- if (GetDriveType(path + _T("\\")) == DRIVE_CDROM) {
- // CDROM_VideoCD
- FindFiles(path + _T("\\mpegav\\avseq??.dat"), files);
- FindFiles(path + _T("\\mpegav\\avseq??.mpg"), files);
- FindFiles(path + _T("\\mpeg2\\avseq??.dat"), files);
- FindFiles(path + _T("\\mpeg2\\avseq??.mpg"), files);
- FindFiles(path + _T("\\mpegav\\music??.dat"), files);
- FindFiles(path + _T("\\mpegav\\music??.mpg"), files);
- FindFiles(path + _T("\\mpeg2\\music??.dat"), files);
- FindFiles(path + _T("\\mpeg2\\music??.mpg"), files);
- if (files.GetCount() > 0) {
- return CDROM_VideoCD;
- }
-
- // CDROM_DVDVideo
- FindFiles(path + _T("\\VIDEO_TS\\video_ts.ifo"), files);
- if (files.GetCount() > 0) {
- return CDROM_DVDVideo;
- }
-
- // CDROM_Audio
- HANDLE hDrive = CreateFile(CString(_T("\\\\.\\")) + path, GENERIC_READ, FILE_SHARE_READ, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE)NULL);
- if (hDrive != INVALID_HANDLE_VALUE) {
- DWORD BytesReturned;
- CDROM_TOC TOC;
- if (DeviceIoControl(hDrive, IOCTL_CDROM_READ_TOC, NULL, 0, &TOC, sizeof(TOC), &BytesReturned, 0)) {
- for (ptrdiff_t i = TOC.FirstTrack; i <= TOC.LastTrack; i++) {
- // MMC-3 Draft Revision 10g: Table 222 - Q Sub-channel control field
- TOC.TrackData[i-1].Control &= 5;
- if (TOC.TrackData[i-1].Control == 0 || TOC.TrackData[i-1].Control == 1) {
- CString fn;
- fn.Format(_T("%s\\track%02d.cda"), path, i);
- files.AddTail(fn);
- }
- }
- }
-
- CloseHandle(hDrive);
- }
- if (files.GetCount() > 0) {
- return CDROM_Audio;
- }
-
- // it is a cdrom but nothing special
- return CDROM_Unknown;
- }
-
- return CDROM_NotFound;
+ files.RemoveAll();
+
+ CString path;
+ path.Format(_T("%c:"), drive);
+
+ if (GetDriveType(path + _T("\\")) == DRIVE_CDROM) {
+ // CDROM_VideoCD
+ FindFiles(path + _T("\\mpegav\\avseq??.dat"), files);
+ FindFiles(path + _T("\\mpegav\\avseq??.mpg"), files);
+ FindFiles(path + _T("\\mpeg2\\avseq??.dat"), files);
+ FindFiles(path + _T("\\mpeg2\\avseq??.mpg"), files);
+ FindFiles(path + _T("\\mpegav\\music??.dat"), files);
+ FindFiles(path + _T("\\mpegav\\music??.mpg"), files);
+ FindFiles(path + _T("\\mpeg2\\music??.dat"), files);
+ FindFiles(path + _T("\\mpeg2\\music??.mpg"), files);
+ if (files.GetCount() > 0) {
+ return CDROM_VideoCD;
+ }
+
+ // CDROM_DVDVideo
+ FindFiles(path + _T("\\VIDEO_TS\\video_ts.ifo"), files);
+ if (files.GetCount() > 0) {
+ return CDROM_DVDVideo;
+ }
+
+ // CDROM_Audio
+ HANDLE hDrive = CreateFile(CString(_T("\\\\.\\")) + path, GENERIC_READ, FILE_SHARE_READ, NULL,
+ OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE)NULL);
+ if (hDrive != INVALID_HANDLE_VALUE) {
+ DWORD BytesReturned;
+ CDROM_TOC TOC;
+ if (DeviceIoControl(hDrive, IOCTL_CDROM_READ_TOC, NULL, 0, &TOC, sizeof(TOC), &BytesReturned, 0)) {
+ for (ptrdiff_t i = TOC.FirstTrack; i <= TOC.LastTrack; i++) {
+ // MMC-3 Draft Revision 10g: Table 222 - Q Sub-channel control field
+ TOC.TrackData[i - 1].Control &= 5;
+ if (TOC.TrackData[i - 1].Control == 0 || TOC.TrackData[i - 1].Control == 1) {
+ CString fn;
+ fn.Format(_T("%s\\track%02d.cda"), path, i);
+ files.AddTail(fn);
+ }
+ }
+ }
+
+ CloseHandle(hDrive);
+ }
+ if (files.GetCount() > 0) {
+ return CDROM_Audio;
+ }
+
+ // it is a cdrom but nothing special
+ return CDROM_Unknown;
+ }
+
+ return CDROM_NotFound;
}
CString GetDriveLabel(TCHAR drive)
{
- CString label;
+ CString label;
- CString path;
- path.Format(_T("%c:\\"), drive);
- TCHAR VolumeNameBuffer[_MAX_PATH], FileSystemNameBuffer[_MAX_PATH];
- DWORD VolumeSerialNumber, MaximumComponentLength, FileSystemFlags;
- if (GetVolumeInformation(path,
- VolumeNameBuffer, _MAX_PATH, &VolumeSerialNumber, &MaximumComponentLength,
- &FileSystemFlags, FileSystemNameBuffer, _MAX_PATH)) {
- label = VolumeNameBuffer;
- }
+ CString path;
+ path.Format(_T("%c:\\"), drive);
+ TCHAR VolumeNameBuffer[_MAX_PATH], FileSystemNameBuffer[_MAX_PATH];
+ DWORD VolumeSerialNumber, MaximumComponentLength, FileSystemFlags;
+ if (GetVolumeInformation(path,
+ VolumeNameBuffer, _MAX_PATH, &VolumeSerialNumber, &MaximumComponentLength,
+ &FileSystemFlags, FileSystemNameBuffer, _MAX_PATH)) {
+ label = VolumeNameBuffer;
+ }
- return label;
+ return label;
}
bool GetKeyFrames(CString fn, CUIntArray& kfs)
{
- kfs.RemoveAll();
+ kfs.RemoveAll();
- CString fn2 = CString(fn).MakeLower();
- if (fn2.Mid(fn2.ReverseFind('.')+1) == _T("avi")) {
- AVIFileInit();
+ CString fn2 = CString(fn).MakeLower();
+ if (fn2.Mid(fn2.ReverseFind('.') + 1) == _T("avi")) {
+ AVIFileInit();
- PAVIFILE pfile;
- if (AVIFileOpen(&pfile, fn, OF_SHARE_DENY_WRITE, 0L) == 0) {
- AVIFILEINFO afi;
- memset(&afi, 0, sizeof(afi));
- AVIFileInfo(pfile, &afi, sizeof(AVIFILEINFO));
+ PAVIFILE pfile;
+ if (AVIFileOpen(&pfile, fn, OF_SHARE_DENY_WRITE, 0L) == 0) {
+ AVIFILEINFO afi;
+ memset(&afi, 0, sizeof(afi));
+ AVIFileInfo(pfile, &afi, sizeof(AVIFILEINFO));
- CComPtr<IAVIStream> pavi;
- if (AVIFileGetStream(pfile, &pavi, streamtypeVIDEO, 0) == AVIERR_OK) {
- AVISTREAMINFO si;
- AVIStreamInfo(pavi, &si, sizeof(si));
+ CComPtr<IAVIStream> pavi;
+ if (AVIFileGetStream(pfile, &pavi, streamtypeVIDEO, 0) == AVIERR_OK) {
+ AVISTREAMINFO si;
+ AVIStreamInfo(pavi, &si, sizeof(si));
- if (afi.dwCaps&AVIFILECAPS_ALLKEYFRAMES) {
- kfs.SetSize(si.dwLength);
- for (DWORD kf = 0; kf < si.dwLength; kf++) {
- kfs[kf] = kf;
- }
- } else {
- for (LONG kf = 0; ; kf++) {
- kf = pavi->FindSample(kf, FIND_KEY|FIND_NEXT);
- if (kf < 0 || kfs.GetCount() > 0 && kfs[kfs.GetCount()-1] >= (UINT)kf) {
- break;
- }
- kfs.Add(kf);
- }
+ if (afi.dwCaps & AVIFILECAPS_ALLKEYFRAMES) {
+ kfs.SetSize(si.dwLength);
+ for (DWORD kf = 0; kf < si.dwLength; kf++) {
+ kfs[kf] = kf;
+ }
+ } else {
+ for (LONG kf = 0; ; kf++) {
+ kf = pavi->FindSample(kf, FIND_KEY | FIND_NEXT);
+ if (kf < 0 || kfs.GetCount() > 0 && kfs[kfs.GetCount() - 1] >= (UINT)kf) {
+ break;
+ }
+ kfs.Add(kf);
+ }
- if (kfs.GetCount() > 0 && kfs[kfs.GetCount()-1] < si.dwLength-1) {
- kfs.Add(si.dwLength-1);
- }
- }
- }
+ if (kfs.GetCount() > 0 && kfs[kfs.GetCount() - 1] < si.dwLength - 1) {
+ kfs.Add(si.dwLength - 1);
+ }
+ }
+ }
- AVIFileRelease(pfile);
- }
+ AVIFileRelease(pfile);
+ }
- AVIFileExit();
- }
+ AVIFileExit();
+ }
- return (kfs.GetCount() > 0);
+ return (kfs.GetCount() > 0);
}
DVD_HMSF_TIMECODE RT2HMSF(REFERENCE_TIME rt, double fps) // use to remember the current position
{
- DVD_HMSF_TIMECODE hmsf = {
- (BYTE)((rt/10000000/60/60)),
- (BYTE)((rt/10000000/60)%60),
- (BYTE)((rt/10000000)%60),
- (BYTE)(1.0*((rt/10000)%1000) * fps / 1000)
- };
+ DVD_HMSF_TIMECODE hmsf = {
+ (BYTE)((rt / 10000000 / 60 / 60)),
+ (BYTE)((rt / 10000000 / 60) % 60),
+ (BYTE)((rt / 10000000) % 60),
+ (BYTE)(1.0 * ((rt / 10000) % 1000) * fps / 1000)
+ };
- return hmsf;
+ return hmsf;
}
DVD_HMSF_TIMECODE RT2HMS_r(REFERENCE_TIME rt) // use only for information (for display on the screen)
{
- rt = (rt + 5000000) / 10000000;
- DVD_HMSF_TIMECODE hmsf = {
- (BYTE)(rt / 3600),
- (BYTE)(rt / 60 % 60),
- (BYTE)(rt % 60),
- 0
- };
+ rt = (rt + 5000000) / 10000000;
+ DVD_HMSF_TIMECODE hmsf = {
+ (BYTE)(rt / 3600),
+ (BYTE)(rt / 60 % 60),
+ (BYTE)(rt % 60),
+ 0
+ };
- return hmsf;
+ return hmsf;
}
REFERENCE_TIME HMSF2RT(DVD_HMSF_TIMECODE hmsf, double fps)
{
- if (fps == 0) {
- hmsf.bFrames = 0;
- fps = 1;
- }
- return (REFERENCE_TIME)((((REFERENCE_TIME)hmsf.bHours*60+hmsf.bMinutes)*60+hmsf.bSeconds)*1000+1.0*hmsf.bFrames*1000/fps)*10000;
+ if (fps == 0) {
+ hmsf.bFrames = 0;
+ fps = 1;
+ }
+ return (REFERENCE_TIME)((((REFERENCE_TIME)hmsf.bHours * 60 + hmsf.bMinutes) * 60 + hmsf.bSeconds) * 1000 + 1.0 * hmsf.bFrames * 1000 / fps) * 10000;
}
void memsetd(void* dst, unsigned int c, size_t nbytes)
{
#ifndef _WIN64
- if (!(g_cpuid.m_flags & g_cpuid.sse2)) {
- __asm {
- mov eax, c
- mov ecx, nbytes
- shr ecx, 2
- mov edi, dst
- cld
- rep stosd
- }
- return;
- }
+ if (!(g_cpuid.m_flags & g_cpuid.sse2)) {
+ __asm {
+ mov eax, c
+ mov ecx, nbytes
+ shr ecx, 2
+ mov edi, dst
+ cld
+ rep stosd
+ }
+ return;
+ }
#endif
- size_t n = nbytes / 4;
- size_t o = n - (n % 4);
-
- __m128i val = _mm_set1_epi32 ( (int)c );
- if (((uintptr_t)dst & 0x0F) == 0) { // 16-byte aligned
- for (size_t i = 0; i < o; i+=4) {
- _mm_store_si128( (__m128i*)&(((DWORD*)dst)[i]), val );
- }
- } else {
- for (size_t i = 0; i < o; i+=4) {
- _mm_storeu_si128( (__m128i*)&(((DWORD*)dst)[i]), val );
- }
- }
-
- switch (n - o) {
- case 3:
- ((DWORD*)dst)[o + 2] = c;
- case 2:
- ((DWORD*)dst)[o + 1] = c;
- case 1:
- ((DWORD*)dst)[o + 0] = c;
- }
+ size_t n = nbytes / 4;
+ size_t o = n - (n % 4);
+
+ __m128i val = _mm_set1_epi32((int)c);
+ if (((uintptr_t)dst & 0x0F) == 0) { // 16-byte aligned
+ for (size_t i = 0; i < o; i += 4) {
+ _mm_store_si128((__m128i*) & (((DWORD*)dst)[i]), val);
+ }
+ } else {
+ for (size_t i = 0; i < o; i += 4) {
+ _mm_storeu_si128((__m128i*) & (((DWORD*)dst)[i]), val);
+ }
+ }
+
+ switch (n - o) {
+ case 3:
+ ((DWORD*)dst)[o + 2] = c;
+ case 2:
+ ((DWORD*)dst)[o + 1] = c;
+ case 1:
+ ((DWORD*)dst)[o + 0] = c;
+ }
}
void memsetw(void* dst, unsigned short c, size_t nbytes)
{
- memsetd(dst, c << 16 | c, nbytes);
+ memsetd(dst, c << 16 | c, nbytes);
- size_t n = nbytes / 2;
- size_t o = (n / 2) * 2;
- if ((n - o) == 1) {
- ((WORD*)dst)[o] = c;
- }
+ size_t n = nbytes / 2;
+ size_t o = (n / 2) * 2;
+ if ((n - o) == 1) {
+ ((WORD*)dst)[o] = c;
+ }
}
bool ExtractBIH(const AM_MEDIA_TYPE* pmt, BITMAPINFOHEADER* bih)
{
- if (pmt && bih) {
- memset(bih, 0, sizeof(*bih));
-
- if (pmt->formattype == FORMAT_VideoInfo) {
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
- memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
- return true;
- } else if (pmt->formattype == FORMAT_VideoInfo2) {
- VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pmt->pbFormat;
- memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
- return true;
- } else if (pmt->formattype == FORMAT_MPEGVideo) {
- VIDEOINFOHEADER* vih = &((MPEG1VIDEOINFO*)pmt->pbFormat)->hdr;
- memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
- return true;
- } else if (pmt->formattype == FORMAT_MPEG2_VIDEO) {
- VIDEOINFOHEADER2* vih = &((MPEG2VIDEOINFO*)pmt->pbFormat)->hdr;
- memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
- return true;
- } else if (pmt->formattype == FORMAT_DiracVideoInfo) {
- VIDEOINFOHEADER2* vih = &((DIRACINFOHEADER*)pmt->pbFormat)->hdr;
- memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
- return true;
- }
- }
-
- return false;
+ if (pmt && bih) {
+ memset(bih, 0, sizeof(*bih));
+
+ if (pmt->formattype == FORMAT_VideoInfo) {
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
+ memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
+ return true;
+ } else if (pmt->formattype == FORMAT_VideoInfo2) {
+ VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pmt->pbFormat;
+ memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
+ return true;
+ } else if (pmt->formattype == FORMAT_MPEGVideo) {
+ VIDEOINFOHEADER* vih = &((MPEG1VIDEOINFO*)pmt->pbFormat)->hdr;
+ memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
+ return true;
+ } else if (pmt->formattype == FORMAT_MPEG2_VIDEO) {
+ VIDEOINFOHEADER2* vih = &((MPEG2VIDEOINFO*)pmt->pbFormat)->hdr;
+ memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
+ return true;
+ } else if (pmt->formattype == FORMAT_DiracVideoInfo) {
+ VIDEOINFOHEADER2* vih = &((DIRACINFOHEADER*)pmt->pbFormat)->hdr;
+ memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
+ return true;
+ }
+ }
+
+ return false;
}
bool ExtractAvgTimePerFrame(const AM_MEDIA_TYPE* pmt, REFERENCE_TIME& rtAvgTimePerFrame)
{
- if (pmt->formattype==FORMAT_VideoInfo) {
- rtAvgTimePerFrame = ((VIDEOINFOHEADER*)pmt->pbFormat)->AvgTimePerFrame;
- } else if (pmt->formattype==FORMAT_VideoInfo2) {
- rtAvgTimePerFrame = ((VIDEOINFOHEADER2*)pmt->pbFormat)->AvgTimePerFrame;
- } else if (pmt->formattype==FORMAT_MPEGVideo) {
- rtAvgTimePerFrame = ((MPEG1VIDEOINFO*)pmt->pbFormat)->hdr.AvgTimePerFrame;
- } else if (pmt->formattype==FORMAT_MPEG2Video) {
- rtAvgTimePerFrame = ((MPEG2VIDEOINFO*)pmt->pbFormat)->hdr.AvgTimePerFrame;
- } else {
- return false;
- }
+ if (pmt->formattype == FORMAT_VideoInfo) {
+ rtAvgTimePerFrame = ((VIDEOINFOHEADER*)pmt->pbFormat)->AvgTimePerFrame;
+ } else if (pmt->formattype == FORMAT_VideoInfo2) {
+ rtAvgTimePerFrame = ((VIDEOINFOHEADER2*)pmt->pbFormat)->AvgTimePerFrame;
+ } else if (pmt->formattype == FORMAT_MPEGVideo) {
+ rtAvgTimePerFrame = ((MPEG1VIDEOINFO*)pmt->pbFormat)->hdr.AvgTimePerFrame;
+ } else if (pmt->formattype == FORMAT_MPEG2Video) {
+ rtAvgTimePerFrame = ((MPEG2VIDEOINFO*)pmt->pbFormat)->hdr.AvgTimePerFrame;
+ } else {
+ return false;
+ }
- return true;
+ return true;
}
bool ExtractBIH(IMediaSample* pMS, BITMAPINFOHEADER* bih)
{
- AM_MEDIA_TYPE* pmt = NULL;
- pMS->GetMediaType(&pmt);
- if (pmt) {
- bool fRet = ExtractBIH(pmt, bih);
- DeleteMediaType(pmt);
- return fRet;
- }
+ AM_MEDIA_TYPE* pmt = NULL;
+ pMS->GetMediaType(&pmt);
+ if (pmt) {
+ bool fRet = ExtractBIH(pmt, bih);
+ DeleteMediaType(pmt);
+ return fRet;
+ }
- return false;
+ return false;
}
bool ExtractDim(const AM_MEDIA_TYPE* pmt, int& w, int& h, int& arx, int& ary)
{
- w = h = arx = ary = 0;
-
- if (pmt->formattype == FORMAT_VideoInfo || pmt->formattype == FORMAT_MPEGVideo) {
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
- w = vih->bmiHeader.biWidth;
- h = abs(vih->bmiHeader.biHeight);
- arx = w * vih->bmiHeader.biYPelsPerMeter;
- ary = h * vih->bmiHeader.biXPelsPerMeter;
- } else if (pmt->formattype == FORMAT_VideoInfo2 || pmt->formattype == FORMAT_MPEG2_VIDEO || pmt->formattype == FORMAT_DiracVideoInfo) {
- VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pmt->pbFormat;
- w = vih->bmiHeader.biWidth;
- h = abs(vih->bmiHeader.biHeight);
- arx = vih->dwPictAspectRatioX;
- ary = vih->dwPictAspectRatioY;
- } else {
- return false;
- }
-
- if (!arx || !ary) {
- BYTE* ptr = NULL;
- DWORD len = 0;
-
- if (pmt->formattype == FORMAT_MPEGVideo) {
- ptr = ((MPEG1VIDEOINFO*)pmt->pbFormat)->bSequenceHeader;
- len = ((MPEG1VIDEOINFO*)pmt->pbFormat)->cbSequenceHeader;
-
- if (ptr && len >= 8 && *(DWORD*)ptr == 0xb3010000) {
- w = (ptr[4]<<4)|(ptr[5]>>4);
- h = ((ptr[5]&0xf)<<8)|ptr[6];
- float ar[] = {
- 1.0000f,1.0000f,0.6735f,0.7031f,
- 0.7615f,0.8055f,0.8437f,0.8935f,
- 0.9157f,0.9815f,1.0255f,1.0695f,
- 1.0950f,1.1575f,1.2015f,1.0000f,
- };
- arx = (int)((float)w / ar[ptr[7]>>4] + 0.5);
- ary = h;
- }
- } else if (pmt->formattype == FORMAT_MPEG2_VIDEO) {
- ptr = (BYTE*)((MPEG2VIDEOINFO*)pmt->pbFormat)->dwSequenceHeader;
- len = ((MPEG2VIDEOINFO*)pmt->pbFormat)->cbSequenceHeader;
-
- if (ptr && len >= 8 && *(DWORD*)ptr == 0xb3010000) {
- w = (ptr[4]<<4)|(ptr[5]>>4);
- h = ((ptr[5]&0xf)<<8)|ptr[6];
- struct {
- int x, y;
- } ar[] = {{w,h},{4,3},{16,9},{221,100},{w,h}};
- int i = min(max(ptr[7]>>4, 1), 5)-1;
- arx = ar[i].x;
- ary = ar[i].y;
- }
- }
- }
-
- if (!arx || !ary) {
- arx = w;
- ary = h;
- }
-
- DWORD a = arx, b = ary;
- while (a) {
- int tmp = a;
- a = b % tmp;
- b = tmp;
- }
- if (b) {
- arx /= b, ary /= b;
- }
-
- return true;
+ w = h = arx = ary = 0;
+
+ if (pmt->formattype == FORMAT_VideoInfo || pmt->formattype == FORMAT_MPEGVideo) {
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
+ w = vih->bmiHeader.biWidth;
+ h = abs(vih->bmiHeader.biHeight);
+ arx = w * vih->bmiHeader.biYPelsPerMeter;
+ ary = h * vih->bmiHeader.biXPelsPerMeter;
+ } else if (pmt->formattype == FORMAT_VideoInfo2 || pmt->formattype == FORMAT_MPEG2_VIDEO || pmt->formattype == FORMAT_DiracVideoInfo) {
+ VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pmt->pbFormat;
+ w = vih->bmiHeader.biWidth;
+ h = abs(vih->bmiHeader.biHeight);
+ arx = vih->dwPictAspectRatioX;
+ ary = vih->dwPictAspectRatioY;
+ } else {
+ return false;
+ }
+
+ if (!arx || !ary) {
+ BYTE* ptr = NULL;
+ DWORD len = 0;
+
+ if (pmt->formattype == FORMAT_MPEGVideo) {
+ ptr = ((MPEG1VIDEOINFO*)pmt->pbFormat)->bSequenceHeader;
+ len = ((MPEG1VIDEOINFO*)pmt->pbFormat)->cbSequenceHeader;
+
+ if (ptr && len >= 8 && *(DWORD*)ptr == 0xb3010000) {
+ w = (ptr[4] << 4) | (ptr[5] >> 4);
+ h = ((ptr[5] & 0xf) << 8) | ptr[6];
+ float ar[] = {
+ 1.0000f, 1.0000f, 0.6735f, 0.7031f,
+ 0.7615f, 0.8055f, 0.8437f, 0.8935f,
+ 0.9157f, 0.9815f, 1.0255f, 1.0695f,
+ 1.0950f, 1.1575f, 1.2015f, 1.0000f,
+ };
+ arx = (int)((float)w / ar[ptr[7] >> 4] + 0.5);
+ ary = h;
+ }
+ } else if (pmt->formattype == FORMAT_MPEG2_VIDEO) {
+ ptr = (BYTE*)((MPEG2VIDEOINFO*)pmt->pbFormat)->dwSequenceHeader;
+ len = ((MPEG2VIDEOINFO*)pmt->pbFormat)->cbSequenceHeader;
+
+ if (ptr && len >= 8 && *(DWORD*)ptr == 0xb3010000) {
+ w = (ptr[4] << 4) | (ptr[5] >> 4);
+ h = ((ptr[5] & 0xf) << 8) | ptr[6];
+ struct {
+ int x, y;
+ } ar[] = {{w, h}, {4, 3}, {16, 9}, {221, 100}, {w, h}};
+ int i = min(max(ptr[7] >> 4, 1), 5) - 1;
+ arx = ar[i].x;
+ ary = ar[i].y;
+ }
+ }
+ }
+
+ if (!arx || !ary) {
+ arx = w;
+ ary = h;
+ }
+
+ DWORD a = arx, b = ary;
+ while (a) {
+ int tmp = a;
+ a = b % tmp;
+ b = tmp;
+ }
+ if (b) {
+ arx /= b, ary /= b;
+ }
+
+ return true;
}
bool MakeMPEG2MediaType(CMediaType& mt, BYTE* seqhdr, DWORD len, int w, int h)
{
- if (len < 4 || *(DWORD*)seqhdr != 0xb3010000) {
- mt = CMediaType();
+ if (len < 4 || *(DWORD*)seqhdr != 0xb3010000) {
+ mt = CMediaType();
- mt.majortype = MEDIATYPE_Video;
- mt.subtype = MEDIASUBTYPE_MPEG2_VIDEO;
- mt.formattype = FORMAT_MPEG2Video;
+ mt.majortype = MEDIATYPE_Video;
+ mt.subtype = MEDIASUBTYPE_MPEG2_VIDEO;
+ mt.formattype = FORMAT_MPEG2Video;
- MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader));
- memset(mt.Format(), 0, mt.FormatLength());
- vih->hdr.bmiHeader.biSize = sizeof(vih->hdr.bmiHeader);
- vih->hdr.bmiHeader.biWidth = w;
- vih->hdr.bmiHeader.biHeight = h;
+ MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader));
+ memset(mt.Format(), 0, mt.FormatLength());
+ vih->hdr.bmiHeader.biSize = sizeof(vih->hdr.bmiHeader);
+ vih->hdr.bmiHeader.biWidth = w;
+ vih->hdr.bmiHeader.biHeight = h;
- vih->cbSequenceHeader = 0;
+ vih->cbSequenceHeader = 0;
- return true;
- }
+ return true;
+ }
- BYTE* seqhdr_ext = NULL;
+ BYTE* seqhdr_ext = NULL;
- BYTE* seqhdr_end = seqhdr + 7;
+ BYTE* seqhdr_end = seqhdr + 7;
- while (seqhdr_end < (seqhdr + len - 6)) {
- if (*(DWORD*)seqhdr_end == 0xb5010000) {
- seqhdr_ext = seqhdr_end;
- seqhdr_end += 10;
- len = (DWORD)(seqhdr_end - seqhdr);
- break;
- }
- seqhdr_end++;
- }
+ while (seqhdr_end < (seqhdr + len - 6)) {
+ if (*(DWORD*)seqhdr_end == 0xb5010000) {
+ seqhdr_ext = seqhdr_end;
+ seqhdr_end += 10;
+ len = (DWORD)(seqhdr_end - seqhdr);
+ break;
+ }
+ seqhdr_end++;
+ }
- mt = CMediaType();
+ mt = CMediaType();
- mt.majortype = MEDIATYPE_Video;
- mt.subtype = MEDIASUBTYPE_MPEG2_VIDEO;
- mt.formattype = FORMAT_MPEG2Video;
+ mt.majortype = MEDIATYPE_Video;
+ mt.subtype = MEDIASUBTYPE_MPEG2_VIDEO;
+ mt.formattype = FORMAT_MPEG2Video;
- MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + len);
- memset(mt.Format(), 0, mt.FormatLength());
- vih->hdr.bmiHeader.biSize = sizeof(vih->hdr.bmiHeader);
- vih->hdr.bmiHeader.biWidth = w;
- vih->hdr.bmiHeader.biHeight = h;
+ MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + len);
+ memset(mt.Format(), 0, mt.FormatLength());
+ vih->hdr.bmiHeader.biSize = sizeof(vih->hdr.bmiHeader);
+ vih->hdr.bmiHeader.biWidth = w;
+ vih->hdr.bmiHeader.biHeight = h;
- BYTE* pSequenceHeader = (BYTE*)vih->dwSequenceHeader;
- memcpy(pSequenceHeader, seqhdr, len);
- vih->cbSequenceHeader = len;
+ BYTE* pSequenceHeader = (BYTE*)vih->dwSequenceHeader;
+ memcpy(pSequenceHeader, seqhdr, len);
+ vih->cbSequenceHeader = len;
- static char profile[8] = {
- 0, AM_MPEG2Profile_High, AM_MPEG2Profile_SpatiallyScalable, AM_MPEG2Profile_SNRScalable,
- AM_MPEG2Profile_Main, AM_MPEG2Profile_Simple, 0, 0
- };
+ static char profile[8] = {
+ 0, AM_MPEG2Profile_High, AM_MPEG2Profile_SpatiallyScalable, AM_MPEG2Profile_SNRScalable,
+ AM_MPEG2Profile_Main, AM_MPEG2Profile_Simple, 0, 0
+ };
- static char level[16] = {
- 0, 0, 0, 0,
- AM_MPEG2Level_High, 0, AM_MPEG2Level_High1440, 0,
- AM_MPEG2Level_Main, 0, AM_MPEG2Level_Low, 0,
- 0, 0, 0, 0
- };
+ static char level[16] = {
+ 0, 0, 0, 0,
+ AM_MPEG2Level_High, 0, AM_MPEG2Level_High1440, 0,
+ AM_MPEG2Level_Main, 0, AM_MPEG2Level_Low, 0,
+ 0, 0, 0, 0
+ };
- if (seqhdr_ext && (seqhdr_ext[4] & 0xf0) == 0x10) {
- vih->dwProfile = profile[seqhdr_ext[4] & 0x07];
- vih->dwLevel = level[seqhdr_ext[5] >> 4];
- }
+ if (seqhdr_ext && (seqhdr_ext[4] & 0xf0) == 0x10) {
+ vih->dwProfile = profile[seqhdr_ext[4] & 0x07];
+ vih->dwLevel = level[seqhdr_ext[5] >> 4];
+ }
- return true;
+ return true;
}
unsigned __int64 GetFileVersion(LPCTSTR fn)
{
- unsigned __int64 ret = 0;
+ unsigned __int64 ret = 0;
- DWORD buff[4];
- VS_FIXEDFILEINFO* pvsf = (VS_FIXEDFILEINFO*)buff;
- DWORD d; // a variable that GetFileVersionInfoSize sets to zero (but why is it needed ?????????????????????????????? :)
- DWORD len = GetFileVersionInfoSize((TCHAR*)fn, &d);
+ DWORD buff[4];
+ VS_FIXEDFILEINFO* pvsf = (VS_FIXEDFILEINFO*)buff;
+ DWORD d; // a variable that GetFileVersionInfoSize sets to zero (but why is it needed ?????????????????????????????? :)
+ DWORD len = GetFileVersionInfoSize((TCHAR*)fn, &d);
- if (len) {
- TCHAR* b1 = DNew TCHAR[len];
- if (b1) {
- UINT uLen;
- if (GetFileVersionInfo((TCHAR*)fn, 0, len, b1) && VerQueryValue(b1, _T("\\"), (void**)&pvsf, &uLen)) {
- ret = ((unsigned __int64)pvsf->dwFileVersionMS<<32) | pvsf->dwFileVersionLS;
- }
+ if (len) {
+ TCHAR* b1 = DNew TCHAR[len];
+ if (b1) {
+ UINT uLen;
+ if (GetFileVersionInfo((TCHAR*)fn, 0, len, b1) && VerQueryValue(b1, _T("\\"), (void**)&pvsf, &uLen)) {
+ ret = ((unsigned __int64)pvsf->dwFileVersionMS << 32) | pvsf->dwFileVersionLS;
+ }
- delete [] b1;
- }
- }
+ delete [] b1;
+ }
+ }
- return ret;
+ return ret;
}
bool CreateFilter(CStringW DisplayName, IBaseFilter** ppBF, CStringW& FriendlyName)
{
- if (!ppBF) {
- return false;
- }
+ if (!ppBF) {
+ return false;
+ }
- *ppBF = NULL;
- FriendlyName.Empty();
+ *ppBF = NULL;
+ FriendlyName.Empty();
- CComPtr<IBindCtx> pBindCtx;
- CreateBindCtx(0, &pBindCtx);
+ CComPtr<IBindCtx> pBindCtx;
+ CreateBindCtx(0, &pBindCtx);
- CComPtr<IMoniker> pMoniker;
- ULONG chEaten;
- if (S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker)) {
- return false;
- }
+ CComPtr<IMoniker> pMoniker;
+ ULONG chEaten;
+ if (S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker)) {
+ return false;
+ }
- if (FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)ppBF)) || !*ppBF) {
- return false;
- }
+ if (FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)ppBF)) || !*ppBF) {
+ return false;
+ }
- CComPtr<IPropertyBag> pPB;
- CComVariant var;
- if (SUCCEEDED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))
- && SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
- FriendlyName = var.bstrVal;
- }
+ CComPtr<IPropertyBag> pPB;
+ CComVariant var;
+ if (SUCCEEDED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))
+ && SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
+ FriendlyName = var.bstrVal;
+ }
- return true;
+ return true;
}
IBaseFilter* AppendFilter(IPin* pPin, IMoniker* pMoniker, IGraphBuilder* pGB)
{
- do {
- if (!pPin || !pMoniker || !pGB) {
- break;
- }
+ do {
+ if (!pPin || !pMoniker || !pGB) {
+ break;
+ }
- CComPtr<IPin> pPinTo;
- PIN_DIRECTION dir;
- if (FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_OUTPUT || SUCCEEDED(pPin->ConnectedTo(&pPinTo))) {
- break;
- }
+ CComPtr<IPin> pPinTo;
+ PIN_DIRECTION dir;
+ if (FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_OUTPUT || SUCCEEDED(pPin->ConnectedTo(&pPinTo))) {
+ break;
+ }
- CComPtr<IBindCtx> pBindCtx;
- CreateBindCtx(0, &pBindCtx);
+ CComPtr<IBindCtx> pBindCtx;
+ CreateBindCtx(0, &pBindCtx);
- CComPtr<IPropertyBag> pPB;
- if (FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))) {
- break;
- }
+ CComPtr<IPropertyBag> pPB;
+ if (FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))) {
+ break;
+ }
- CComVariant var;
- if (FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
- break;
- }
+ CComVariant var;
+ if (FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
+ break;
+ }
- CComPtr<IBaseFilter> pBF;
- if (FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF) {
- break;
- }
+ CComPtr<IBaseFilter> pBF;
+ if (FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF) {
+ break;
+ }
- if (FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal)))) {
- break;
- }
+ if (FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal)))) {
+ break;
+ }
- BeginEnumPins(pBF, pEP, pPinTo) {
- PIN_DIRECTION dir;
- if (FAILED(pPinTo->QueryDirection(&dir)) || dir != PINDIR_INPUT) {
- continue;
- }
+ BeginEnumPins(pBF, pEP, pPinTo) {
+ PIN_DIRECTION dir;
+ if (FAILED(pPinTo->QueryDirection(&dir)) || dir != PINDIR_INPUT) {
+ continue;
+ }
- if (SUCCEEDED(pGB->ConnectDirect(pPin, pPinTo, NULL))) {
- return pBF;
- }
- }
- EndEnumFilters
+ if (SUCCEEDED(pGB->ConnectDirect(pPin, pPinTo, NULL))) {
+ return pBF;
+ }
+ }
+ EndEnumFilters
- pGB->RemoveFilter(pBF);
- } while (false);
+ pGB->RemoveFilter(pBF);
+ } while (false);
- return NULL;
+ return NULL;
}
CStringW GetFriendlyName(CStringW DisplayName)
{
- CStringW FriendlyName;
+ CStringW FriendlyName;
- CComPtr<IBindCtx> pBindCtx;
- CreateBindCtx(0, &pBindCtx);
+ CComPtr<IBindCtx> pBindCtx;
+ CreateBindCtx(0, &pBindCtx);
- CComPtr<IMoniker> pMoniker;
- ULONG chEaten;
- if (S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker)) {
- return false;
- }
+ CComPtr<IMoniker> pMoniker;
+ ULONG chEaten;
+ if (S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker)) {
+ return false;
+ }
- CComPtr<IPropertyBag> pPB;
- CComVariant var;
- if (SUCCEEDED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))
- && SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
- FriendlyName = var.bstrVal;
- }
+ CComPtr<IPropertyBag> pPB;
+ CComVariant var;
+ if (SUCCEEDED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))
+ && SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
+ FriendlyName = var.bstrVal;
+ }
- return FriendlyName;
+ return FriendlyName;
}
typedef struct {
- CString path;
- HINSTANCE hInst;
- CLSID clsid;
+ CString path;
+ HINSTANCE hInst;
+ CLSID clsid;
} ExternalObject;
static CAtlList<ExternalObject> s_extobjs;
HRESULT LoadExternalObject(LPCTSTR path, REFCLSID clsid, REFIID iid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- CString fullpath = MakeFullPath(path);
+ CString fullpath = MakeFullPath(path);
- HINSTANCE hInst = NULL;
- bool fFound = false;
+ HINSTANCE hInst = NULL;
+ bool fFound = false;
- POSITION pos = s_extobjs.GetHeadPosition();
- while (pos) {
- ExternalObject& eo = s_extobjs.GetNext(pos);
- if (!eo.path.CompareNoCase(fullpath)) {
- hInst = eo.hInst;
- fFound = true;
- break;
- }
- }
+ POSITION pos = s_extobjs.GetHeadPosition();
+ while (pos) {
+ ExternalObject& eo = s_extobjs.GetNext(pos);
+ if (!eo.path.CompareNoCase(fullpath)) {
+ hInst = eo.hInst;
+ fFound = true;
+ break;
+ }
+ }
- HRESULT hr = E_FAIL;
+ HRESULT hr = E_FAIL;
- if (!hInst) {
- hInst = CoLoadLibrary(CComBSTR(fullpath), TRUE);
- }
- if (hInst) {
- typedef HRESULT (__stdcall * PDllGetClassObject)(REFCLSID rclsid, REFIID riid, LPVOID* ppv);
- PDllGetClassObject p = (PDllGetClassObject)GetProcAddress(hInst, "DllGetClassObject");
+ if (!hInst) {
+ hInst = CoLoadLibrary(CComBSTR(fullpath), TRUE);
+ }
+ if (hInst) {
+ typedef HRESULT(__stdcall * PDllGetClassObject)(REFCLSID rclsid, REFIID riid, LPVOID * ppv);
+ PDllGetClassObject p = (PDllGetClassObject)GetProcAddress(hInst, "DllGetClassObject");
- if (p && FAILED(hr = p(clsid, iid, ppv))) {
- CComPtr<IClassFactory> pCF;
- if (SUCCEEDED(hr = p(clsid, __uuidof(IClassFactory), (void**)&pCF))) {
- hr = pCF->CreateInstance(NULL, iid, ppv);
- }
- }
- }
+ if (p && FAILED(hr = p(clsid, iid, ppv))) {
+ CComPtr<IClassFactory> pCF;
+ if (SUCCEEDED(hr = p(clsid, __uuidof(IClassFactory), (void**)&pCF))) {
+ hr = pCF->CreateInstance(NULL, iid, ppv);
+ }
+ }
+ }
- if (FAILED(hr) && hInst && !fFound) {
- CoFreeLibrary(hInst);
- return hr;
- }
+ if (FAILED(hr) && hInst && !fFound) {
+ CoFreeLibrary(hInst);
+ return hr;
+ }
- if (hInst && !fFound) {
- ExternalObject eo;
- eo.path = fullpath;
- eo.hInst = hInst;
- eo.clsid = clsid;
- s_extobjs.AddTail(eo);
- }
+ if (hInst && !fFound) {
+ ExternalObject eo;
+ eo.path = fullpath;
+ eo.hInst = hInst;
+ eo.clsid = clsid;
+ s_extobjs.AddTail(eo);
+ }
- return hr;
+ return hr;
}
HRESULT LoadExternalFilter(LPCTSTR path, REFCLSID clsid, IBaseFilter** ppBF)
{
- return LoadExternalObject(path, clsid, __uuidof(IBaseFilter), (void**)ppBF);
+ return LoadExternalObject(path, clsid, __uuidof(IBaseFilter), (void**)ppBF);
}
HRESULT LoadExternalPropertyPage(IPersist* pP, REFCLSID clsid, IPropertyPage** ppPP)
{
- CLSID clsid2 = GUID_NULL;
- if (FAILED(pP->GetClassID(&clsid2))) {
- return E_FAIL;
- }
+ CLSID clsid2 = GUID_NULL;
+ if (FAILED(pP->GetClassID(&clsid2))) {
+ return E_FAIL;
+ }
- POSITION pos = s_extobjs.GetHeadPosition();
- while (pos) {
- ExternalObject& eo = s_extobjs.GetNext(pos);
- if (eo.clsid == clsid2) {
- return LoadExternalObject(eo.path, clsid, __uuidof(IPropertyPage), (void**)ppPP);
- }
- }
+ POSITION pos = s_extobjs.GetHeadPosition();
+ while (pos) {
+ ExternalObject& eo = s_extobjs.GetNext(pos);
+ if (eo.clsid == clsid2) {
+ return LoadExternalObject(eo.path, clsid, __uuidof(IPropertyPage), (void**)ppPP);
+ }
+ }
- return E_FAIL;
+ return E_FAIL;
}
void UnloadExternalObjects()
{
- POSITION pos = s_extobjs.GetHeadPosition();
- while (pos) {
- ExternalObject& eo = s_extobjs.GetNext(pos);
- CoFreeLibrary(eo.hInst);
- }
- s_extobjs.RemoveAll();
+ POSITION pos = s_extobjs.GetHeadPosition();
+ while (pos) {
+ ExternalObject& eo = s_extobjs.GetNext(pos);
+ CoFreeLibrary(eo.hInst);
+ }
+ s_extobjs.RemoveAll();
}
CString MakeFullPath(LPCTSTR path)
{
- CString full(path);
- full.Replace('/', '\\');
+ CString full(path);
+ full.Replace('/', '\\');
- CString fn;
- fn.ReleaseBuffer(GetModuleFileName(AfxGetInstanceHandle(), fn.GetBuffer(_MAX_PATH), _MAX_PATH));
- CPath p(fn);
+ CString fn;
+ fn.ReleaseBuffer(GetModuleFileName(AfxGetInstanceHandle(), fn.GetBuffer(_MAX_PATH), _MAX_PATH));
+ CPath p(fn);
- if (full.GetLength() >= 2 && full[0] == '\\' && full[1] != '\\') {
- p.StripToRoot();
- full = CString(p) + full.Mid(1);
- } else if (full.Find(_T(":\\")) < 0) {
- p.RemoveFileSpec();
- p.AddBackslash();
- full = CString(p) + full;
- }
+ if (full.GetLength() >= 2 && full[0] == '\\' && full[1] != '\\') {
+ p.StripToRoot();
+ full = CString(p) + full.Mid(1);
+ } else if (full.Find(_T(":\\")) < 0) {
+ p.RemoveFileSpec();
+ p.AddBackslash();
+ full = CString(p) + full;
+ }
- CPath c(full);
- c.Canonicalize();
- return CString(c);
+ CPath c(full);
+ c.Canonicalize();
+ return CString(c);
}
//
CString GetMediaTypeName(const GUID& guid)
{
- CString ret = guid == GUID_NULL
- ? _T("Any type")
- : CString(GuidNames[guid]);
+ CString ret = guid == GUID_NULL
+ ? _T("Any type")
+ : CString(GuidNames[guid]);
- if (ret == _T("FOURCC GUID")) {
- CString str;
- if (guid.Data1 >= 0x10000) {
- str.Format(_T("Video: %c%c%c%c"), (guid.Data1>>0)&0xff, (guid.Data1>>8)&0xff, (guid.Data1>>16)&0xff, (guid.Data1>>24)&0xff);
- } else {
- str.Format(_T("Audio: 0x%08x"), guid.Data1);
- }
- ret = str;
- } else if (ret == _T("Unknown GUID Name")) {
- WCHAR null[128] = {0}, buff[128];
- StringFromGUID2(GUID_NULL, null, 127);
- ret = CString(CStringW(StringFromGUID2(guid, buff, 127) ? buff : null));
- }
+ if (ret == _T("FOURCC GUID")) {
+ CString str;
+ if (guid.Data1 >= 0x10000) {
+ str.Format(_T("Video: %c%c%c%c"), (guid.Data1 >> 0) & 0xff, (guid.Data1 >> 8) & 0xff, (guid.Data1 >> 16) & 0xff, (guid.Data1 >> 24) & 0xff);
+ } else {
+ str.Format(_T("Audio: 0x%08x"), guid.Data1);
+ }
+ ret = str;
+ } else if (ret == _T("Unknown GUID Name")) {
+ WCHAR null[128] = {0}, buff[128];
+ StringFromGUID2(GUID_NULL, null, 127);
+ ret = CString(CStringW(StringFromGUID2(guid, buff, 127) ? buff : null));
+ }
- return ret;
+ return ret;
}
GUID GUIDFromCString(CString str)
{
- GUID guid = GUID_NULL;
- HRESULT hr = CLSIDFromString(CComBSTR(str), &guid);
- ASSERT(SUCCEEDED(hr));
- UNREFERENCED_PARAMETER(hr);
- return guid;
+ GUID guid = GUID_NULL;
+ HRESULT hr = CLSIDFromString(CComBSTR(str), &guid);
+ ASSERT(SUCCEEDED(hr));
+ UNREFERENCED_PARAMETER(hr);
+ return guid;
}
HRESULT GUIDFromCString(CString str, GUID& guid)
{
- guid = GUID_NULL;
- return CLSIDFromString(CComBSTR(str), &guid);
+ guid = GUID_NULL;
+ return CLSIDFromString(CComBSTR(str), &guid);
}
CString CStringFromGUID(const GUID& guid)
{
- WCHAR null[128] = {0}, buff[128];
- StringFromGUID2(GUID_NULL, null, 127);
- return CString(StringFromGUID2(guid, buff, 127) > 0 ? buff : null);
+ WCHAR null[128] = {0}, buff[128];
+ StringFromGUID2(GUID_NULL, null, 127);
+ return CString(StringFromGUID2(guid, buff, 127) > 0 ? buff : null);
}
CStringW UTF8To16(LPCSTR utf8)
{
- CStringW str;
- int n = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL, 0)-1;
- if (n < 0) {
- return str;
- }
- str.ReleaseBuffer(MultiByteToWideChar(CP_UTF8, 0, utf8, -1, str.GetBuffer(n), n+1)-1);
- return str;
+ CStringW str;
+ int n = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL, 0) - 1;
+ if (n < 0) {
+ return str;
+ }
+ str.ReleaseBuffer(MultiByteToWideChar(CP_UTF8, 0, utf8, -1, str.GetBuffer(n), n + 1) - 1);
+ return str;
}
CStringA UTF16To8(LPCWSTR utf16)
{
- CStringA str;
- int n = WideCharToMultiByte(CP_UTF8, 0, utf16, -1, NULL, 0, NULL, NULL)-1;
- if (n < 0) {
- return str;
- }
- str.ReleaseBuffer(WideCharToMultiByte(CP_UTF8, 0, utf16, -1, str.GetBuffer(n), n+1, NULL, NULL)-1);
- return str;
+ CStringA str;
+ int n = WideCharToMultiByte(CP_UTF8, 0, utf16, -1, NULL, 0, NULL, NULL) - 1;
+ if (n < 0) {
+ return str;
+ }
+ str.ReleaseBuffer(WideCharToMultiByte(CP_UTF8, 0, utf16, -1, str.GetBuffer(n), n + 1, NULL, NULL) - 1);
+ return str;
}
CStringW UTF8ToStringW(const char* S)
{
- CStringW str;
- if (S==NULL) {
- return str;
- }
-
- // Don't use MultiByteToWideChar(), some characters are not well decoded
- const unsigned char* Z = (const unsigned char*)S;
- while (*Z) //0 is end
- {
- //1 byte
- if (*Z<0x80)
- {
- str += (wchar_t)(*Z);
- Z++;
- }
- //2 bytes
- else if ((*Z&0xE0)==0xC0)
- {
- if ((*(Z+1)&0xC0)==0x80)
- {
- str += (wchar_t)((((wchar_t)(*Z&0x1F))<<6)|(*(Z+1)&0x3F));
- Z+=2;
- }
- else
- {
- str.Empty();
- return str; //Bad character
- }
- }
- //3 bytes
- else if ((*Z&0xF0)==0xE0)
- {
- if ((*(Z+1)&0xC0)==0x80 && (*(Z+2)&0xC0)==0x80)
- {
- str += (wchar_t)((((wchar_t)(*Z&0x0F))<<12)|((*(Z+1)&0x3F)<<6)|(*(Z+2)&0x3F));
- Z+=3;
- }
- else
- {
- str.Empty();
- return str; //Bad character
- }
- }
- //4 bytes
- else if ((*Z&0xF8)==0xF0)
- {
- if ((*(Z+1)&0xC0)==0x80 && (*(Z+2)&0xC0)==0x80 && (*(Z+3)&0xC0)==0x80)
- {
- str += (wchar_t)((((wchar_t)(*Z&0x0F))<<18)|((*(Z+1)&0x3F)<<12)||((*(Z+2)&0x3F)<<6)|(*(Z+3)&0x3F));
- Z+=4;
- }
- else
- {
- str.Empty();
- return str; //Bad character
- }
- }
- else
- {
- str.Empty();
- return str; //Bad character
- }
- }
- return str;
+ CStringW str;
+ if (S == NULL) {
+ return str;
+ }
+
+ // Don't use MultiByteToWideChar(), some characters are not well decoded
+ const unsigned char* Z = (const unsigned char*)S;
+ while (*Z) { //0 is end
+ //1 byte
+ if (*Z < 0x80) {
+ str += (wchar_t)(*Z);
+ Z++;
+ }
+ //2 bytes
+ else if ((*Z & 0xE0) == 0xC0) {
+ if ((*(Z + 1) & 0xC0) == 0x80) {
+ str += (wchar_t)((((wchar_t)(*Z & 0x1F)) << 6) | (*(Z + 1) & 0x3F));
+ Z += 2;
+ } else {
+ str.Empty();
+ return str; //Bad character
+ }
+ }
+ //3 bytes
+ else if ((*Z & 0xF0) == 0xE0) {
+ if ((*(Z + 1) & 0xC0) == 0x80 && (*(Z + 2) & 0xC0) == 0x80) {
+ str += (wchar_t)((((wchar_t)(*Z & 0x0F)) << 12) | ((*(Z + 1) & 0x3F) << 6) | (*(Z + 2) & 0x3F));
+ Z += 3;
+ } else {
+ str.Empty();
+ return str; //Bad character
+ }
+ }
+ //4 bytes
+ else if ((*Z & 0xF8) == 0xF0) {
+ if ((*(Z + 1) & 0xC0) == 0x80 && (*(Z + 2) & 0xC0) == 0x80 && (*(Z + 3) & 0xC0) == 0x80) {
+ str += (wchar_t)((((wchar_t)(*Z & 0x0F)) << 18) | ((*(Z + 1) & 0x3F) << 12) || ((*(Z + 2) & 0x3F) << 6) | (*(Z + 3) & 0x3F));
+ Z += 4;
+ } else {
+ str.Empty();
+ return str; //Bad character
+ }
+ } else {
+ str.Empty();
+ return str; //Bad character
+ }
+ }
+ return str;
}
CStringW LocalToStringW(const char* S)
{
- CStringW str;
- if (S==NULL) {
- return str;
- }
+ CStringW str;
+ if (S == NULL) {
+ return str;
+ }
- int Size = MultiByteToWideChar(CP_ACP, 0, S, -1, NULL, 0);
- if (Size!=0) {
- str.ReleaseBuffer(MultiByteToWideChar(CP_ACP, 0, S, -1, str.GetBuffer(Size), Size+1)-1);
- }
- return str;
+ int Size = MultiByteToWideChar(CP_ACP, 0, S, -1, NULL, 0);
+ if (Size != 0) {
+ str.ReleaseBuffer(MultiByteToWideChar(CP_ACP, 0, S, -1, str.GetBuffer(Size), Size + 1) - 1);
+ }
+ return str;
}
static struct {
- LPCSTR name, iso6392, iso6391;
- LCID lcid;
-} s_isolangs[] = { // TODO : fill LCID !!!
- {"Abkhazian", "abk", "ab"},
- {"Achinese", "ace", ""},
- {"Acoli", "ach", ""},
- {"Adangme", "ada", ""},
- {"Afar", "aar", "aa"},
- {"Afrihili", "afh", ""},
- {"Afrikaans", "afr", "af", MAKELCID( MAKELANGID(LANG_AFRIKAANS, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Afro-Asiatic (Other)", "afa", ""},
- {"Akan", "aka", "ak"},
- {"Akkadian", "akk", ""},
- {"Albanian", "alb", "sq"},
- {"Albanian", "sqi", "sq", MAKELCID( MAKELANGID(LANG_ALBANIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Aleut", "ale", ""},
- {"Algonquian languages", "alg", ""},
- {"Altaic (Other)", "tut", ""},
- {"Amharic", "amh", "am"},
- {"Apache languages", "apa", ""},
- {"Arabic", "ara", "ar", MAKELCID( MAKELANGID(LANG_ARABIC, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Aragonese", "arg", "an"},
- {"Aramaic", "arc", ""},
- {"Arapaho", "arp", ""},
- {"Araucanian", "arn", ""},
- {"Arawak", "arw", ""},
- {"Armenian", "arm", "hy", MAKELCID( MAKELANGID(LANG_ARMENIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Armenian", "hye", "hy", MAKELCID( MAKELANGID(LANG_ARMENIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Artificial (Other)", "art", ""},
- {"Assamese", "asm", "as", MAKELCID( MAKELANGID(LANG_ASSAMESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Asturian; Bable", "ast", ""},
- {"Athapascan languages", "ath", ""},
- {"Australian languages", "aus", ""},
- {"Austronesian (Other)", "map", ""},
- {"Avaric", "ava", "av"},
- {"Avestan", "ave", "ae"},
- {"Awadhi", "awa", ""},
- {"Aymara", "aym", "ay"},
- {"Azerbaijani", "aze", "az", MAKELCID( MAKELANGID(LANG_AZERI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Bable; Asturian", "ast", ""},
- {"Balinese", "ban", ""},
- {"Baltic (Other)", "bat", ""},
- {"Baluchi", "bal", ""},
- {"Bambara", "bam", "bm"},
- {"Bamileke languages", "bai", ""},
- {"Banda", "bad", ""},
- {"Bantu (Other)", "bnt", ""},
- {"Basa", "bas", ""},
- {"Bashkir", "bak", "ba", MAKELCID( MAKELANGID(LANG_BASHKIR, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Basque", "baq", "eu", MAKELCID( MAKELANGID(LANG_BASQUE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Basque", "eus", "eu", MAKELCID( MAKELANGID(LANG_BASQUE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Batak (Indonesia)", "btk", ""},
- {"Beja", "bej", ""},
- {"Belarusian", "bel", "be", MAKELCID( MAKELANGID(LANG_BELARUSIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Bemba", "bem", ""},
- {"Bengali", "ben", "bn", MAKELCID( MAKELANGID(LANG_BENGALI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Berber (Other)", "ber", ""},
- {"Bhojpuri", "bho", ""},
- {"Bihari", "bih", "bh"},
- {"Bikol", "bik", ""},
- {"Bini", "bin", ""},
- {"Bislama", "bis", "bi"},
- {"Bokmål, Norwegian; Norwegian Bokmål", "nob", "nb"},
- {"Bosnian", "bos", "bs"},
- {"Braj", "bra", ""},
- {"Breton", "bre", "br", MAKELCID( MAKELANGID(LANG_BRETON, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Buginese", "bug", ""},
- {"Bulgarian", "bul", "bg", MAKELCID( MAKELANGID(LANG_BULGARIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Buriat", "bua", ""},
- {"Burmese", "bur", "my"},
- {"Burmese", "mya", "my"},
- {"Caddo", "cad", ""},
- {"Carib", "car", ""},
- {"Spanish; Castilian", "spa", "es", MAKELCID( MAKELANGID(LANG_SPANISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Catalan", "cat", "ca", MAKELCID( MAKELANGID(LANG_CATALAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Caucasian (Other)", "cau", ""},
- {"Cebuano", "ceb", ""},
- {"Celtic (Other)", "cel", ""},
- {"Central American Indian (Other)", "cai", ""},
- {"Chagatai", "chg", ""},
- {"Chamic languages", "cmc", ""},
- {"Chamorro", "cha", "ch"},
- {"Chechen", "che", "ce"},
- {"Cherokee", "chr", ""},
- {"Chewa; Chichewa; Nyanja", "nya", "ny"},
- {"Cheyenne", "chy", ""},
- {"Chibcha", "chb", ""},
- {"Chichewa; Chewa; Nyanja", "nya", "ny"},
- {"Chinese", "chi", "zh", MAKELCID( MAKELANGID(LANG_CHINESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Chinese", "zho", "zh"},
- {"Chinook jargon", "chn", ""},
- {"Chipewyan", "chp", ""},
- {"Choctaw", "cho", ""},
- {"Chuang; Zhuang", "zha", "za"},
- {"Church Slavic; Old Church Slavonic", "chu", "cu"},
- {"Old Church Slavonic; Old Slavonic; ", "chu", "cu"},
- {"Church Slavonic; Old Bulgarian; Church Slavic;", "chu", "cu"},
- {"Old Slavonic; Church Slavonic; Old Bulgarian;", "chu", "cu"},
- {"Church Slavic; Old Church Slavonic", "chu", "cu"},
- {"Chuukese", "chk", ""},
- {"Chuvash", "chv", "cv"},
- {"Coptic", "cop", ""},
- {"Cornish", "cor", "kw"},
- {"Corsican", "cos", "co", MAKELCID( MAKELANGID(LANG_CORSICAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Cree", "cre", "cr"},
- {"Creek", "mus", ""},
- {"Creoles and pidgins (Other)", "crp", ""},
- {"Creoles and pidgins,", "cpe", ""},
- // {"English-based (Other)", "", ""},
- {"Creoles and pidgins,", "cpf", ""},
- // {"French-based (Other)", "", ""},
- {"Creoles and pidgins,", "cpp", ""},
- // {"Portuguese-based (Other)", "", ""},
- {"Croatian", "scr", "hr", MAKELCID( MAKELANGID(LANG_CROATIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Croatian", "hrv", "hr", MAKELCID( MAKELANGID(LANG_CROATIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Cushitic (Other)", "cus", ""},
- {"Czech", "cze", "cs", MAKELCID( MAKELANGID(LANG_CZECH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Czech", "ces", "cs", MAKELCID( MAKELANGID(LANG_CZECH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Dakota", "dak", ""},
- {"Danish", "dan", "da", MAKELCID( MAKELANGID(LANG_DANISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Dargwa", "dar", ""},
- {"Dayak", "day", ""},
- {"Delaware", "del", ""},
- {"Dinka", "din", ""},
- {"Divehi", "div", "dv", MAKELCID( MAKELANGID(LANG_DIVEHI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Dogri", "doi", ""},
- {"Dogrib", "dgr", ""},
- {"Dravidian (Other)", "dra", ""},
- {"Duala", "dua", ""},
- {"Dutch; Flemish", "dut", "nl", MAKELCID( MAKELANGID(LANG_DUTCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Dutch; Flemish", "nld", "nl", MAKELCID( MAKELANGID(LANG_DUTCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Dutch, Middle (ca. 1050-1350)", "dum", ""},
- {"Dyula", "dyu", ""},
- {"Dzongkha", "dzo", "dz"},
- {"Efik", "efi", ""},
- {"Egyptian (Ancient)", "egy", ""},
- {"Ekajuk", "eka", ""},
- {"Elamite", "elx", ""},
- {"English", "eng", "en", MAKELCID( MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"English, Middle (1100-1500)", "enm", ""},
- {"English, Old (ca.450-1100)", "ang", ""},
- {"Esperanto", "epo", "eo"},
- {"Estonian", "est", "et", MAKELCID( MAKELANGID(LANG_ESTONIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Ewe", "ewe", "ee"},
- {"Ewondo", "ewo", ""},
- {"Fang", "fan", ""},
- {"Fanti", "fat", ""},
- {"Faroese", "fao", "fo", MAKELCID( MAKELANGID(LANG_FAEROESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Fijian", "fij", "fj"},
- {"Finnish", "fin", "fi", MAKELCID( MAKELANGID(LANG_FINNISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Finno-Ugrian (Other)", "fiu", ""},
- {"Flemish; Dutch", "dut", "nl"},
- {"Flemish; Dutch", "nld", "nl"},
- {"Fon", "fon", ""},
- {"French", "fre", "fr", MAKELCID( MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"French", "fra*", "fr", MAKELCID( MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"French", "fra", "fr", MAKELCID( MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"French, Middle (ca.1400-1600)", "frm", ""},
- {"French, Old (842-ca.1400)", "fro", ""},
- {"Frisian", "fry", "fy", MAKELCID( MAKELANGID(LANG_FRISIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Friulian", "fur", ""},
- {"Fulah", "ful", "ff"},
- {"Ga", "gaa", ""},
- {"Gaelic; Scottish Gaelic", "gla", "gd", MAKELCID( MAKELANGID(LANG_GALICIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Gallegan", "glg", "gl"},
- {"Ganda", "lug", "lg"},
- {"Gayo", "gay", ""},
- {"Gbaya", "gba", ""},
- {"Geez", "gez", ""},
- {"Georgian", "geo", "ka", MAKELCID( MAKELANGID(LANG_GEORGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Georgian", "kat", "ka", MAKELCID( MAKELANGID(LANG_GEORGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"German", "ger", "de", MAKELCID( MAKELANGID(LANG_GERMAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"German", "deu", "de", MAKELCID( MAKELANGID(LANG_GERMAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"German, Low; Saxon, Low; Low German; Low Saxon", "nds", ""},
- {"German, Middle High (ca.1050-1500)", "gmh", ""},
- {"German, Old High (ca.750-1050)", "goh", ""},
- {"Germanic (Other)", "gem", ""},
- {"Gikuyu; Kikuyu", "kik", "ki"},
- {"Gilbertese", "gil", ""},
- {"Gondi", "gon", ""},
- {"Gorontalo", "gor", ""},
- {"Gothic", "got", ""},
- {"Grebo", "grb", ""},
- {"Greek, Ancient (to 1453)", "grc", "", MAKELCID( MAKELANGID(LANG_GREEK, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Greek, Modern (1453-)", "gre", "el", MAKELCID( MAKELANGID(LANG_GREEK, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Greek, Modern (1453-)", "ell", "el", MAKELCID( MAKELANGID(LANG_GREEK, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Greenlandic; Kalaallisut", "kal", "kl", MAKELCID( MAKELANGID(LANG_GREENLANDIC, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Guarani", "grn", "gn"},
- {"Gujarati", "guj", "gu", MAKELCID( MAKELANGID(LANG_GUJARATI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Gwich’in", "gwi", ""},
- {"Haida", "hai", ""},
- {"Hausa", "hau", "ha", MAKELCID( MAKELANGID(LANG_HAUSA, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Hawaiian", "haw", ""},
- {"Hebrew", "heb", "he", MAKELCID( MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Herero", "her", "hz"},
- {"Hiligaynon", "hil", ""},
- {"Himachali", "him", ""},
- {"Hindi", "hin", "hi", MAKELCID( MAKELANGID(LANG_HINDI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Hiri Motu", "hmo", "ho"},
- {"Hittite", "hit", ""},
- {"Hmong", "hmn", ""},
- {"Hungarian", "hun", "hu", MAKELCID( MAKELANGID(LANG_HUNGARIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Hupa", "hup", ""},
- {"Iban", "iba", ""},
- {"Icelandic", "ice", "is", MAKELCID( MAKELANGID(LANG_ICELANDIC, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Icelandic", "isl", "is", MAKELCID( MAKELANGID(LANG_ICELANDIC, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Ido", "ido", "io"},
- {"Igbo", "ibo", "ig", MAKELCID( MAKELANGID(LANG_IGBO, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Ijo", "ijo", ""},
- {"Iloko", "ilo", ""},
- {"Inari Sami", "smn", ""},
- {"Indic (Other)", "inc", ""},
- {"Indo-European (Other)", "ine", ""},
- {"Indonesian", "ind", "id", MAKELCID( MAKELANGID(LANG_INDONESIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Ingush", "inh", ""},
- {"Interlingua (International", "ina", "ia"},
- // {"Auxiliary Language Association)", "", ""},
- {"Interlingue", "ile", "ie"},
- {"Inuktitut", "iku", "iu", MAKELCID( MAKELANGID(LANG_INUKTITUT, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Inupiaq", "ipk", "ik"},
- {"Iranian (Other)", "ira", ""},
- {"Irish", "gle", "ga", MAKELCID( MAKELANGID(LANG_IRISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Irish, Middle (900-1200)", "mga", "", MAKELCID( MAKELANGID(LANG_IRISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Irish, Old (to 900)", "sga", "", MAKELCID( MAKELANGID(LANG_IRISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Iroquoian languages", "iro", ""},
- {"Italian", "ita", "it", MAKELCID( MAKELANGID(LANG_ITALIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Japanese", "jpn", "ja", MAKELCID( MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Javanese", "jav", "jv"},
- {"Judeo-Arabic", "jrb", ""},
- {"Judeo-Persian", "jpr", ""},
- {"Kabardian", "kbd", ""},
- {"Kabyle", "kab", ""},
- {"Kachin", "kac", ""},
- {"Kalaallisut; Greenlandic", "kal", "kl"},
- {"Kamba", "kam", ""},
- {"Kannada", "kan", "kn", MAKELCID( MAKELANGID(LANG_KANNADA, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Kanuri", "kau", "kr"},
- {"Kara-Kalpak", "kaa", ""},
- {"Karen", "kar", ""},
- {"Kashmiri", "kas", "ks", MAKELCID( MAKELANGID(LANG_KASHMIRI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Kawi", "kaw", ""},
- {"Kazakh", "kaz", "kk", MAKELCID( MAKELANGID(LANG_KAZAK, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Khasi", "kha", ""},
- {"Khmer", "khm", "km", MAKELCID( MAKELANGID(LANG_KHMER, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Khoisan (Other)", "khi", ""},
- {"Khotanese", "kho", ""},
- {"Kikuyu; Gikuyu", "kik", "ki"},
- {"Kimbundu", "kmb", ""},
- {"Kinyarwanda", "kin", "rw", MAKELCID( MAKELANGID(LANG_KINYARWANDA, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Kirghiz", "kir", "ky"},
- {"Komi", "kom", "kv"},
- {"Kongo", "kon", "kg"},
- {"Konkani", "kok", "", MAKELCID( MAKELANGID(LANG_KONKANI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Korean", "kor", "ko", MAKELCID( MAKELANGID(LANG_KOREAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Kosraean", "kos", ""},
- {"Kpelle", "kpe", ""},
- {"Kru", "kro", ""},
- {"Kuanyama; Kwanyama", "kua", "kj"},
- {"Kumyk", "kum", ""},
- {"Kurdish", "kur", "ku"},
- {"Kurukh", "kru", ""},
- {"Kutenai", "kut", ""},
- {"Kwanyama, Kuanyama", "kua", "kj"},
- {"Ladino", "lad", ""},
- {"Lahnda", "lah", ""},
- {"Lamba", "lam", ""},
- {"Lao", "lao", "lo", MAKELCID( MAKELANGID(LANG_LAO, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Latin", "lat", "la"},
- {"Latvian", "lav", "lv", MAKELCID( MAKELANGID(LANG_LATVIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Letzeburgesch; Luxembourgish", "ltz", "lb"},
- {"Lezghian", "lez", ""},
- {"Limburgan; Limburger; Limburgish", "lim", "li"},
- {"Limburger; Limburgan; Limburgish;", "lim", "li"},
- {"Limburgish; Limburger; Limburgan", "lim", "li"},
- {"Lingala", "lin", "ln"},
- {"Lithuanian", "lit", "lt", MAKELCID( MAKELANGID(LANG_LITHUANIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Low German; Low Saxon; German, Low; Saxon, Low", "nds", ""},
- {"Low Saxon; Low German; Saxon, Low; German, Low", "nds", ""},
- {"Lozi", "loz", ""},
- {"Luba-Katanga", "lub", "lu"},
- {"Luba-Lulua", "lua", ""},
- {"Luiseno", "lui", ""},
- {"Lule Sami", "smj", ""},
- {"Lunda", "lun", ""},
- {"Luo (Kenya and Tanzania)", "luo", ""},
- {"Lushai", "lus", ""},
- {"Luxembourgish; Letzeburgesch", "ltz", "lb", MAKELCID( MAKELANGID(LANG_LUXEMBOURGISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Macedonian", "mac", "mk", MAKELCID( MAKELANGID(LANG_MACEDONIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Macedonian", "mkd", "mk", MAKELCID( MAKELANGID(LANG_MACEDONIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Madurese", "mad", ""},
- {"Magahi", "mag", ""},
- {"Maithili", "mai", ""},
- {"Makasar", "mak", ""},
- {"Malagasy", "mlg", "mg"},
- {"Malay", "may", "ms", MAKELCID( MAKELANGID(LANG_MALAY, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Malay", "msa", "ms", MAKELCID( MAKELANGID(LANG_MALAY, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Malayalam", "mal", "ml", MAKELCID( MAKELANGID(LANG_MALAYALAM, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Maltese", "mlt", "mt", MAKELCID( MAKELANGID(LANG_MALTESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Manchu", "mnc", ""},
- {"Mandar", "mdr", ""},
- {"Mandingo", "man", ""},
- {"Manipuri", "mni", "", MAKELCID( MAKELANGID(LANG_MANIPURI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Manobo languages", "mno", ""},
- {"Manx", "glv", "gv"},
- {"Maori", "mao", "mi", MAKELCID( MAKELANGID(LANG_MAORI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Maori", "mri", "mi", MAKELCID( MAKELANGID(LANG_MAORI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Marathi", "mar", "mr", MAKELCID( MAKELANGID(LANG_MARATHI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Mari", "chm", ""},
- {"Marshallese", "mah", "mh"},
- {"Marwari", "mwr", ""},
- {"Masai", "mas", ""},
- {"Mayan languages", "myn", ""},
- {"Mende", "men", ""},
- {"Micmac", "mic", ""},
- {"Minangkabau", "min", ""},
- {"Miscellaneous languages", "mis", ""},
- {"Mohawk", "moh", "", MAKELCID( MAKELANGID(LANG_MOHAWK, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Moldavian", "mol", "mo"},
- {"Mon-Khmer (Other)", "mkh", ""},
- {"Mongo", "lol", ""},
- {"Mongolian", "mon", "mn", MAKELCID( MAKELANGID(LANG_MONGOLIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Mossi", "mos", ""},
- {"Multiple languages", "mul", ""},
- {"Munda languages", "mun", ""},
- {"Nahuatl", "nah", ""},
- {"Nauru", "nau", "na"},
- {"Navaho, Navajo", "nav", "nv"},
- {"Navajo; Navaho", "nav", "nv"},
- {"Ndebele, North", "nde", "nd"},
- {"Ndebele, South", "nbl", "nr"},
- {"Ndonga", "ndo", "ng"},
- {"Neapolitan", "nap", ""},
- {"Nepali", "nep", "ne", MAKELCID( MAKELANGID(LANG_NEPALI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Newari", "new", ""},
- {"Nias", "nia", ""},
- {"Niger-Kordofanian (Other)", "nic", ""},
- {"Nilo-Saharan (Other)", "ssa", ""},
- {"Niuean", "niu", ""},
- {"Norse, Old", "non", ""},
- {"North American Indian (Other)", "nai", ""},
- {"Northern Sami", "sme", "se"},
- {"North Ndebele", "nde", "nd"},
- {"Norwegian", "nor", "no", MAKELCID( MAKELANGID(LANG_NORWEGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Norwegian Bokmål; Bokmål, Norwegian", "nob", "nb", MAKELCID( MAKELANGID(LANG_NORWEGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Norwegian Nynorsk; Nynorsk, Norwegian", "nno", "nn", MAKELCID( MAKELANGID(LANG_NORWEGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Nubian languages", "nub", ""},
- {"Nyamwezi", "nym", ""},
- {"Nyanja; Chichewa; Chewa", "nya", "ny"},
- {"Nyankole", "nyn", ""},
- {"Nynorsk, Norwegian; Norwegian Nynorsk", "nno", "nn"},
- {"Nyoro", "nyo", ""},
- {"Nzima", "nzi", ""},
- {"Occitan (post 1500},; Provençal", "oci", "oc", MAKELCID( MAKELANGID(LANG_OCCITAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Ojibwa", "oji", "oj"},
- {"Old Bulgarian; Old Slavonic; Church Slavonic;", "chu", "cu"},
- {"Oriya", "ori", "or"},
- {"Oromo", "orm", "om"},
- {"Osage", "osa", ""},
- {"Ossetian; Ossetic", "oss", "os"},
- {"Ossetic; Ossetian", "oss", "os"},
- {"Otomian languages", "oto", ""},
- {"Pahlavi", "pal", ""},
- {"Palauan", "pau", ""},
- {"Pali", "pli", "pi"},
- {"Pampanga", "pam", ""},
- {"Pangasinan", "pag", ""},
- {"Panjabi", "pan", "pa"},
- {"Papiamento", "pap", ""},
- {"Papuan (Other)", "paa", ""},
- {"Persian", "per", "fa", MAKELCID( MAKELANGID(LANG_PERSIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Persian", "fas", "fa", MAKELCID( MAKELANGID(LANG_PERSIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Persian, Old (ca.600-400 B.C.)", "peo", ""},
- {"Philippine (Other)", "phi", ""},
- {"Phoenician", "phn", ""},
- {"Pohnpeian", "pon", ""},
- {"Polish", "pol", "pl", MAKELCID( MAKELANGID(LANG_POLISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Portuguese", "por", "pt", MAKELCID( MAKELANGID(LANG_PORTUGUESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Prakrit languages", "pra", ""},
- {"Provençal; Occitan (post 1500)", "oci", "oc"},
- {"Provençal, Old (to 1500)", "pro", ""},
- {"Pushto", "pus", "ps"},
- {"Quechua", "que", "qu", MAKELCID( MAKELANGID(LANG_QUECHUA, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Raeto-Romance", "roh", "rm"},
- {"Rajasthani", "raj", ""},
- {"Rapanui", "rap", ""},
- {"Rarotongan", "rar", ""},
- {"Reserved for local use", "qaa-qtz", ""},
- {"Romance (Other)", "roa", ""},
- {"Romanian", "rum", "ro", MAKELCID( MAKELANGID(LANG_ROMANIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Romanian", "ron", "ro", MAKELCID( MAKELANGID(LANG_ROMANIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Romany", "rom", ""},
- {"Rundi", "run", "rn"},
- {"Russian", "rus", "ru", MAKELCID( MAKELANGID(LANG_RUSSIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Salishan languages", "sal", ""},
- {"Samaritan Aramaic", "sam", ""},
- {"Sami languages (Other)", "smi", ""},
- {"Samoan", "smo", "sm"},
- {"Sandawe", "sad", ""},
- {"Sango", "sag", "sg"},
- {"Sanskrit", "san", "sa", MAKELCID( MAKELANGID(LANG_SANSKRIT, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Santali", "sat", ""},
- {"Sardinian", "srd", "sc"},
- {"Sasak", "sas", ""},
- {"Saxon, Low; German, Low; Low Saxon; Low German", "nds", ""},
- {"Scots", "sco", ""},
- {"Scottish Gaelic; Gaelic", "gla", "gd"},
- {"Selkup", "sel", ""},
- {"Semitic (Other)", "sem", ""},
- {"Serbian", "scc", "sr", MAKELCID( MAKELANGID(LANG_SERBIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Serbian", "srp", "sr", MAKELCID( MAKELANGID(LANG_SERBIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Serer", "srr", ""},
- {"Shan", "shn", ""},
- {"Shona", "sna", "sn"},
- {"Sichuan Yi", "iii", "ii"},
- {"Sidamo", "sid", ""},
- {"Sign languages", "sgn", ""},
- {"Siksika", "bla", ""},
- {"Sindhi", "snd", "sd", MAKELCID( MAKELANGID(LANG_SINDHI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Sinhalese", "sin", "si", MAKELCID( MAKELANGID(LANG_SINHALESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Sino-Tibetan (Other)", "sit", ""},
- {"Siouan languages", "sio", ""},
- {"Skolt Sami", "sms", ""},
- {"Slave (Athapascan)", "den", ""},
- {"Slavic (Other)", "sla", ""},
- {"Slovak", "slo", "sk", MAKELCID( MAKELANGID(LANG_SLOVAK, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Slovak", "slk", "sk", MAKELCID( MAKELANGID(LANG_SLOVAK, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Slovenian", "slv", "sl", MAKELCID( MAKELANGID(LANG_SLOVENIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Sogdian", "sog", ""},
- {"Somali", "som", "so"},
- {"Songhai", "son", ""},
- {"Soninke", "snk", ""},
- {"Sorbian languages", "wen", ""},
- {"Sotho, Northern", "nso", "", MAKELCID( MAKELANGID(LANG_SOTHO, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Sotho, Southern", "sot", "st", MAKELCID( MAKELANGID(LANG_SOTHO, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"South American Indian (Other)", "sai", ""},
- {"Southern Sami", "sma", ""},
- {"South Ndebele", "nbl", "nr"},
- {"Spanish; Castilian", "spa", "es", MAKELCID( MAKELANGID(LANG_SPANISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Sukuma", "suk", ""},
- {"Sumerian", "sux", ""},
- {"Sundanese", "sun", "su"},
- {"Susu", "sus", ""},
- {"Swahili", "swa", "sw", MAKELCID( MAKELANGID(LANG_SWAHILI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Swati", "ssw", "ss"},
- {"Swedish", "swe", "sv", MAKELCID( MAKELANGID(LANG_SWEDISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Syriac", "syr", "", MAKELCID( MAKELANGID(LANG_SYRIAC, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Tagalog", "tgl", "tl"},
- {"Tahitian", "tah", "ty"},
- {"Tai (Other)", "tai", ""},
- {"Tajik", "tgk", "tg", MAKELCID( MAKELANGID(LANG_TAJIK, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Tamashek", "tmh", ""},
- {"Tamil", "tam", "ta", MAKELCID( MAKELANGID(LANG_TAMIL, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Tatar", "tat", "tt", MAKELCID( MAKELANGID(LANG_TATAR, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Telugu", "tel", "te", MAKELCID( MAKELANGID(LANG_TELUGU, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Tereno", "ter", ""},
- {"Tetum", "tet", ""},
- {"Thai", "tha", "th", MAKELCID( MAKELANGID(LANG_THAI, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Tibetan", "tib", "bo", MAKELCID( MAKELANGID(LANG_TIBETAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Tibetan", "bod", "bo", MAKELCID( MAKELANGID(LANG_TIBETAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Tigre", "tig", ""},
- {"Tigrinya", "tir", "ti", MAKELCID( MAKELANGID(LANG_TIGRIGNA, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Timne", "tem", ""},
- {"Tiv", "tiv", ""},
- {"Tlingit", "tli", ""},
- {"Tok Pisin", "tpi", ""},
- {"Tokelau", "tkl", ""},
- {"Tonga (Nyasa)", "tog", ""},
- {"Tonga (Tonga Islands)", "ton", "to"},
- {"Tsimshian", "tsi", ""},
- {"Tsonga", "tso", "ts"},
- {"Tswana", "tsn", "tn", MAKELCID( MAKELANGID(LANG_TSWANA, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Tumbuka", "tum", ""},
- {"Tupi languages", "tup", ""},
- {"Turkish", "tur", "tr", MAKELCID( MAKELANGID(LANG_TURKISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Turkish, Ottoman (1500-1928)", "ota", "", MAKELCID( MAKELANGID(LANG_TURKISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Turkmen", "tuk", "tk", MAKELCID( MAKELANGID(LANG_TURKMEN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Tuvalu", "tvl", ""},
- {"Tuvinian", "tyv", ""},
- {"Twi", "twi", "tw"},
- {"Ugaritic", "uga", ""},
- {"Uighur", "uig", "ug", MAKELCID( MAKELANGID(LANG_UIGHUR, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Ukrainian", "ukr", "uk", MAKELCID( MAKELANGID(LANG_UKRAINIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Umbundu", "umb", ""},
- {"Undetermined", "und", ""},
- {"Urdu", "urd", "ur", MAKELCID( MAKELANGID(LANG_URDU, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Uzbek", "uzb", "uz", MAKELCID( MAKELANGID(LANG_UZBEK, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Vai", "vai", ""},
- {"Venda", "ven", "ve"},
- {"Vietnamese", "vie", "vi", MAKELCID( MAKELANGID(LANG_VIETNAMESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Volapuk", "vol", "vo"},
- {"Votic", "vot", ""},
- {"Wakashan languages", "wak", ""},
- {"Walamo", "wal", ""},
- {"Walloon", "wln", "wa"},
- {"Waray", "war", ""},
- {"Washo", "was", ""},
- {"Welsh", "wel", "cy", MAKELCID( MAKELANGID(LANG_WELSH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Welsh", "cym", "cy", MAKELCID( MAKELANGID(LANG_WELSH, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Wolof", "wol", "wo", MAKELCID( MAKELANGID(LANG_WOLOF, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Xhosa", "xho", "xh", MAKELCID( MAKELANGID(LANG_XHOSA, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Yakut", "sah", "", MAKELCID( MAKELANGID(LANG_YAKUT, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Yao", "yao", ""},
- {"Yapese", "yap", ""},
- {"Yiddish", "yid", "yi"},
- {"Yoruba", "yor", "yo", MAKELCID( MAKELANGID(LANG_YORUBA, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Yupik languages", "ypk", ""},
- {"Zande", "znd", ""},
- {"Zapotec", "zap", ""},
- {"Zenaga", "zen", ""},
- {"Zhuang; Chuang", "zha", "za"},
- {"Zulu", "zul", "zu", MAKELCID( MAKELANGID(LANG_ZULU, SUBLANG_DEFAULT), SORT_DEFAULT)},
- {"Zuni", "zun", ""},
- {"Classical Newari", "nwc", ""},
- {"Klingon", "tlh", ""},
- {"Blin", "byn", ""},
- {"Lojban", "jbo", ""},
- {"Lower Sorbian", "dsb", ""},
- {"Upper Sorbian", "hsb", ""},
- {"Kashubian", "csb", ""},
- {"Crimean Turkish", "crh", ""},
- {"Erzya", "myv", ""},
- {"Moksha", "mdf", ""},
- {"Karachay-Balkar", "krc", ""},
- {"Adyghe", "ady", ""},
- {"Udmurt", "udm", ""},
- {"Dargwa", "dar", ""},
- {"Ingush", "inh", ""},
- {"Nogai", "nog", ""},
- {"Haitian", "hat", "ht"},
- {"Kalmyk", "xal", ""},
- {"", "", ""},
- {"No subtitles", "---", "", (LCID)LCID_NOSUBTITLES},
+ LPCSTR name, iso6392, iso6391;
+ LCID lcid;
+} s_isolangs[] = { // TODO : fill LCID !!!
+ {"Abkhazian", "abk", "ab"},
+ {"Achinese", "ace", ""},
+ {"Acoli", "ach", ""},
+ {"Adangme", "ada", ""},
+ {"Afar", "aar", "aa"},
+ {"Afrihili", "afh", ""},
+ {"Afrikaans", "afr", "af", MAKELCID(MAKELANGID(LANG_AFRIKAANS, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Afro-Asiatic (Other)", "afa", ""},
+ {"Akan", "aka", "ak"},
+ {"Akkadian", "akk", ""},
+ {"Albanian", "alb", "sq"},
+ {"Albanian", "sqi", "sq", MAKELCID(MAKELANGID(LANG_ALBANIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Aleut", "ale", ""},
+ {"Algonquian languages", "alg", ""},
+ {"Altaic (Other)", "tut", ""},
+ {"Amharic", "amh", "am"},
+ {"Apache languages", "apa", ""},
+ {"Arabic", "ara", "ar", MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Aragonese", "arg", "an"},
+ {"Aramaic", "arc", ""},
+ {"Arapaho", "arp", ""},
+ {"Araucanian", "arn", ""},
+ {"Arawak", "arw", ""},
+ {"Armenian", "arm", "hy", MAKELCID(MAKELANGID(LANG_ARMENIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Armenian", "hye", "hy", MAKELCID(MAKELANGID(LANG_ARMENIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Artificial (Other)", "art", ""},
+ {"Assamese", "asm", "as", MAKELCID(MAKELANGID(LANG_ASSAMESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Asturian; Bable", "ast", ""},
+ {"Athapascan languages", "ath", ""},
+ {"Australian languages", "aus", ""},
+ {"Austronesian (Other)", "map", ""},
+ {"Avaric", "ava", "av"},
+ {"Avestan", "ave", "ae"},
+ {"Awadhi", "awa", ""},
+ {"Aymara", "aym", "ay"},
+ {"Azerbaijani", "aze", "az", MAKELCID(MAKELANGID(LANG_AZERI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Bable; Asturian", "ast", ""},
+ {"Balinese", "ban", ""},
+ {"Baltic (Other)", "bat", ""},
+ {"Baluchi", "bal", ""},
+ {"Bambara", "bam", "bm"},
+ {"Bamileke languages", "bai", ""},
+ {"Banda", "bad", ""},
+ {"Bantu (Other)", "bnt", ""},
+ {"Basa", "bas", ""},
+ {"Bashkir", "bak", "ba", MAKELCID(MAKELANGID(LANG_BASHKIR, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Basque", "baq", "eu", MAKELCID(MAKELANGID(LANG_BASQUE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Basque", "eus", "eu", MAKELCID(MAKELANGID(LANG_BASQUE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Batak (Indonesia)", "btk", ""},
+ {"Beja", "bej", ""},
+ {"Belarusian", "bel", "be", MAKELCID(MAKELANGID(LANG_BELARUSIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Bemba", "bem", ""},
+ {"Bengali", "ben", "bn", MAKELCID(MAKELANGID(LANG_BENGALI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Berber (Other)", "ber", ""},
+ {"Bhojpuri", "bho", ""},
+ {"Bihari", "bih", "bh"},
+ {"Bikol", "bik", ""},
+ {"Bini", "bin", ""},
+ {"Bislama", "bis", "bi"},
+ {"Bokmål, Norwegian; Norwegian Bokmål", "nob", "nb"},
+ {"Bosnian", "bos", "bs"},
+ {"Braj", "bra", ""},
+ {"Breton", "bre", "br", MAKELCID(MAKELANGID(LANG_BRETON, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Buginese", "bug", ""},
+ {"Bulgarian", "bul", "bg", MAKELCID(MAKELANGID(LANG_BULGARIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Buriat", "bua", ""},
+ {"Burmese", "bur", "my"},
+ {"Burmese", "mya", "my"},
+ {"Caddo", "cad", ""},
+ {"Carib", "car", ""},
+ {"Spanish; Castilian", "spa", "es", MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Catalan", "cat", "ca", MAKELCID(MAKELANGID(LANG_CATALAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Caucasian (Other)", "cau", ""},
+ {"Cebuano", "ceb", ""},
+ {"Celtic (Other)", "cel", ""},
+ {"Central American Indian (Other)", "cai", ""},
+ {"Chagatai", "chg", ""},
+ {"Chamic languages", "cmc", ""},
+ {"Chamorro", "cha", "ch"},
+ {"Chechen", "che", "ce"},
+ {"Cherokee", "chr", ""},
+ {"Chewa; Chichewa; Nyanja", "nya", "ny"},
+ {"Cheyenne", "chy", ""},
+ {"Chibcha", "chb", ""},
+ {"Chichewa; Chewa; Nyanja", "nya", "ny"},
+ {"Chinese", "chi", "zh", MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Chinese", "zho", "zh"},
+ {"Chinook jargon", "chn", ""},
+ {"Chipewyan", "chp", ""},
+ {"Choctaw", "cho", ""},
+ {"Chuang; Zhuang", "zha", "za"},
+ {"Church Slavic; Old Church Slavonic", "chu", "cu"},
+ {"Old Church Slavonic; Old Slavonic; ", "chu", "cu"},
+ {"Church Slavonic; Old Bulgarian; Church Slavic;", "chu", "cu"},
+ {"Old Slavonic; Church Slavonic; Old Bulgarian;", "chu", "cu"},
+ {"Church Slavic; Old Church Slavonic", "chu", "cu"},
+ {"Chuukese", "chk", ""},
+ {"Chuvash", "chv", "cv"},
+ {"Coptic", "cop", ""},
+ {"Cornish", "cor", "kw"},
+ {"Corsican", "cos", "co", MAKELCID(MAKELANGID(LANG_CORSICAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Cree", "cre", "cr"},
+ {"Creek", "mus", ""},
+ {"Creoles and pidgins (Other)", "crp", ""},
+ {"Creoles and pidgins,", "cpe", ""},
+ // {"English-based (Other)", "", ""},
+ {"Creoles and pidgins,", "cpf", ""},
+ // {"French-based (Other)", "", ""},
+ {"Creoles and pidgins,", "cpp", ""},
+ // {"Portuguese-based (Other)", "", ""},
+ {"Croatian", "scr", "hr", MAKELCID(MAKELANGID(LANG_CROATIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Croatian", "hrv", "hr", MAKELCID(MAKELANGID(LANG_CROATIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Cushitic (Other)", "cus", ""},
+ {"Czech", "cze", "cs", MAKELCID(MAKELANGID(LANG_CZECH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Czech", "ces", "cs", MAKELCID(MAKELANGID(LANG_CZECH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Dakota", "dak", ""},
+ {"Danish", "dan", "da", MAKELCID(MAKELANGID(LANG_DANISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Dargwa", "dar", ""},
+ {"Dayak", "day", ""},
+ {"Delaware", "del", ""},
+ {"Dinka", "din", ""},
+ {"Divehi", "div", "dv", MAKELCID(MAKELANGID(LANG_DIVEHI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Dogri", "doi", ""},
+ {"Dogrib", "dgr", ""},
+ {"Dravidian (Other)", "dra", ""},
+ {"Duala", "dua", ""},
+ {"Dutch; Flemish", "dut", "nl", MAKELCID(MAKELANGID(LANG_DUTCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Dutch; Flemish", "nld", "nl", MAKELCID(MAKELANGID(LANG_DUTCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Dutch, Middle (ca. 1050-1350)", "dum", ""},
+ {"Dyula", "dyu", ""},
+ {"Dzongkha", "dzo", "dz"},
+ {"Efik", "efi", ""},
+ {"Egyptian (Ancient)", "egy", ""},
+ {"Ekajuk", "eka", ""},
+ {"Elamite", "elx", ""},
+ {"English", "eng", "en", MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"English, Middle (1100-1500)", "enm", ""},
+ {"English, Old (ca.450-1100)", "ang", ""},
+ {"Esperanto", "epo", "eo"},
+ {"Estonian", "est", "et", MAKELCID(MAKELANGID(LANG_ESTONIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Ewe", "ewe", "ee"},
+ {"Ewondo", "ewo", ""},
+ {"Fang", "fan", ""},
+ {"Fanti", "fat", ""},
+ {"Faroese", "fao", "fo", MAKELCID(MAKELANGID(LANG_FAEROESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Fijian", "fij", "fj"},
+ {"Finnish", "fin", "fi", MAKELCID(MAKELANGID(LANG_FINNISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Finno-Ugrian (Other)", "fiu", ""},
+ {"Flemish; Dutch", "dut", "nl"},
+ {"Flemish; Dutch", "nld", "nl"},
+ {"Fon", "fon", ""},
+ {"French", "fre", "fr", MAKELCID(MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"French", "fra*", "fr", MAKELCID(MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"French", "fra", "fr", MAKELCID(MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"French, Middle (ca.1400-1600)", "frm", ""},
+ {"French, Old (842-ca.1400)", "fro", ""},
+ {"Frisian", "fry", "fy", MAKELCID(MAKELANGID(LANG_FRISIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Friulian", "fur", ""},
+ {"Fulah", "ful", "ff"},
+ {"Ga", "gaa", ""},
+ {"Gaelic; Scottish Gaelic", "gla", "gd", MAKELCID(MAKELANGID(LANG_GALICIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Gallegan", "glg", "gl"},
+ {"Ganda", "lug", "lg"},
+ {"Gayo", "gay", ""},
+ {"Gbaya", "gba", ""},
+ {"Geez", "gez", ""},
+ {"Georgian", "geo", "ka", MAKELCID(MAKELANGID(LANG_GEORGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Georgian", "kat", "ka", MAKELCID(MAKELANGID(LANG_GEORGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"German", "ger", "de", MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"German", "deu", "de", MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"German, Low; Saxon, Low; Low German; Low Saxon", "nds", ""},
+ {"German, Middle High (ca.1050-1500)", "gmh", ""},
+ {"German, Old High (ca.750-1050)", "goh", ""},
+ {"Germanic (Other)", "gem", ""},
+ {"Gikuyu; Kikuyu", "kik", "ki"},
+ {"Gilbertese", "gil", ""},
+ {"Gondi", "gon", ""},
+ {"Gorontalo", "gor", ""},
+ {"Gothic", "got", ""},
+ {"Grebo", "grb", ""},
+ {"Greek, Ancient (to 1453)", "grc", "", MAKELCID(MAKELANGID(LANG_GREEK, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Greek, Modern (1453-)", "gre", "el", MAKELCID(MAKELANGID(LANG_GREEK, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Greek, Modern (1453-)", "ell", "el", MAKELCID(MAKELANGID(LANG_GREEK, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Greenlandic; Kalaallisut", "kal", "kl", MAKELCID(MAKELANGID(LANG_GREENLANDIC, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Guarani", "grn", "gn"},
+ {"Gujarati", "guj", "gu", MAKELCID(MAKELANGID(LANG_GUJARATI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Gwich’in", "gwi", ""},
+ {"Haida", "hai", ""},
+ {"Hausa", "hau", "ha", MAKELCID(MAKELANGID(LANG_HAUSA, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Hawaiian", "haw", ""},
+ {"Hebrew", "heb", "he", MAKELCID(MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Herero", "her", "hz"},
+ {"Hiligaynon", "hil", ""},
+ {"Himachali", "him", ""},
+ {"Hindi", "hin", "hi", MAKELCID(MAKELANGID(LANG_HINDI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Hiri Motu", "hmo", "ho"},
+ {"Hittite", "hit", ""},
+ {"Hmong", "hmn", ""},
+ {"Hungarian", "hun", "hu", MAKELCID(MAKELANGID(LANG_HUNGARIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Hupa", "hup", ""},
+ {"Iban", "iba", ""},
+ {"Icelandic", "ice", "is", MAKELCID(MAKELANGID(LANG_ICELANDIC, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Icelandic", "isl", "is", MAKELCID(MAKELANGID(LANG_ICELANDIC, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Ido", "ido", "io"},
+ {"Igbo", "ibo", "ig", MAKELCID(MAKELANGID(LANG_IGBO, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Ijo", "ijo", ""},
+ {"Iloko", "ilo", ""},
+ {"Inari Sami", "smn", ""},
+ {"Indic (Other)", "inc", ""},
+ {"Indo-European (Other)", "ine", ""},
+ {"Indonesian", "ind", "id", MAKELCID(MAKELANGID(LANG_INDONESIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Ingush", "inh", ""},
+ {"Interlingua (International", "ina", "ia"},
+ // {"Auxiliary Language Association)", "", ""},
+ {"Interlingue", "ile", "ie"},
+ {"Inuktitut", "iku", "iu", MAKELCID(MAKELANGID(LANG_INUKTITUT, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Inupiaq", "ipk", "ik"},
+ {"Iranian (Other)", "ira", ""},
+ {"Irish", "gle", "ga", MAKELCID(MAKELANGID(LANG_IRISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Irish, Middle (900-1200)", "mga", "", MAKELCID(MAKELANGID(LANG_IRISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Irish, Old (to 900)", "sga", "", MAKELCID(MAKELANGID(LANG_IRISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Iroquoian languages", "iro", ""},
+ {"Italian", "ita", "it", MAKELCID(MAKELANGID(LANG_ITALIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Japanese", "jpn", "ja", MAKELCID(MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Javanese", "jav", "jv"},
+ {"Judeo-Arabic", "jrb", ""},
+ {"Judeo-Persian", "jpr", ""},
+ {"Kabardian", "kbd", ""},
+ {"Kabyle", "kab", ""},
+ {"Kachin", "kac", ""},
+ {"Kalaallisut; Greenlandic", "kal", "kl"},
+ {"Kamba", "kam", ""},
+ {"Kannada", "kan", "kn", MAKELCID(MAKELANGID(LANG_KANNADA, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Kanuri", "kau", "kr"},
+ {"Kara-Kalpak", "kaa", ""},
+ {"Karen", "kar", ""},
+ {"Kashmiri", "kas", "ks", MAKELCID(MAKELANGID(LANG_KASHMIRI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Kawi", "kaw", ""},
+ {"Kazakh", "kaz", "kk", MAKELCID(MAKELANGID(LANG_KAZAK, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Khasi", "kha", ""},
+ {"Khmer", "khm", "km", MAKELCID(MAKELANGID(LANG_KHMER, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Khoisan (Other)", "khi", ""},
+ {"Khotanese", "kho", ""},
+ {"Kikuyu; Gikuyu", "kik", "ki"},
+ {"Kimbundu", "kmb", ""},
+ {"Kinyarwanda", "kin", "rw", MAKELCID(MAKELANGID(LANG_KINYARWANDA, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Kirghiz", "kir", "ky"},
+ {"Komi", "kom", "kv"},
+ {"Kongo", "kon", "kg"},
+ {"Konkani", "kok", "", MAKELCID(MAKELANGID(LANG_KONKANI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Korean", "kor", "ko", MAKELCID(MAKELANGID(LANG_KOREAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Kosraean", "kos", ""},
+ {"Kpelle", "kpe", ""},
+ {"Kru", "kro", ""},
+ {"Kuanyama; Kwanyama", "kua", "kj"},
+ {"Kumyk", "kum", ""},
+ {"Kurdish", "kur", "ku"},
+ {"Kurukh", "kru", ""},
+ {"Kutenai", "kut", ""},
+ {"Kwanyama, Kuanyama", "kua", "kj"},
+ {"Ladino", "lad", ""},
+ {"Lahnda", "lah", ""},
+ {"Lamba", "lam", ""},
+ {"Lao", "lao", "lo", MAKELCID(MAKELANGID(LANG_LAO, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Latin", "lat", "la"},
+ {"Latvian", "lav", "lv", MAKELCID(MAKELANGID(LANG_LATVIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Letzeburgesch; Luxembourgish", "ltz", "lb"},
+ {"Lezghian", "lez", ""},
+ {"Limburgan; Limburger; Limburgish", "lim", "li"},
+ {"Limburger; Limburgan; Limburgish;", "lim", "li"},
+ {"Limburgish; Limburger; Limburgan", "lim", "li"},
+ {"Lingala", "lin", "ln"},
+ {"Lithuanian", "lit", "lt", MAKELCID(MAKELANGID(LANG_LITHUANIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Low German; Low Saxon; German, Low; Saxon, Low", "nds", ""},
+ {"Low Saxon; Low German; Saxon, Low; German, Low", "nds", ""},
+ {"Lozi", "loz", ""},
+ {"Luba-Katanga", "lub", "lu"},
+ {"Luba-Lulua", "lua", ""},
+ {"Luiseno", "lui", ""},
+ {"Lule Sami", "smj", ""},
+ {"Lunda", "lun", ""},
+ {"Luo (Kenya and Tanzania)", "luo", ""},
+ {"Lushai", "lus", ""},
+ {"Luxembourgish; Letzeburgesch", "ltz", "lb", MAKELCID(MAKELANGID(LANG_LUXEMBOURGISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Macedonian", "mac", "mk", MAKELCID(MAKELANGID(LANG_MACEDONIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Macedonian", "mkd", "mk", MAKELCID(MAKELANGID(LANG_MACEDONIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Madurese", "mad", ""},
+ {"Magahi", "mag", ""},
+ {"Maithili", "mai", ""},
+ {"Makasar", "mak", ""},
+ {"Malagasy", "mlg", "mg"},
+ {"Malay", "may", "ms", MAKELCID(MAKELANGID(LANG_MALAY, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Malay", "msa", "ms", MAKELCID(MAKELANGID(LANG_MALAY, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Malayalam", "mal", "ml", MAKELCID(MAKELANGID(LANG_MALAYALAM, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Maltese", "mlt", "mt", MAKELCID(MAKELANGID(LANG_MALTESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Manchu", "mnc", ""},
+ {"Mandar", "mdr", ""},
+ {"Mandingo", "man", ""},
+ {"Manipuri", "mni", "", MAKELCID(MAKELANGID(LANG_MANIPURI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Manobo languages", "mno", ""},
+ {"Manx", "glv", "gv"},
+ {"Maori", "mao", "mi", MAKELCID(MAKELANGID(LANG_MAORI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Maori", "mri", "mi", MAKELCID(MAKELANGID(LANG_MAORI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Marathi", "mar", "mr", MAKELCID(MAKELANGID(LANG_MARATHI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Mari", "chm", ""},
+ {"Marshallese", "mah", "mh"},
+ {"Marwari", "mwr", ""},
+ {"Masai", "mas", ""},
+ {"Mayan languages", "myn", ""},
+ {"Mende", "men", ""},
+ {"Micmac", "mic", ""},
+ {"Minangkabau", "min", ""},
+ {"Miscellaneous languages", "mis", ""},
+ {"Mohawk", "moh", "", MAKELCID(MAKELANGID(LANG_MOHAWK, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Moldavian", "mol", "mo"},
+ {"Mon-Khmer (Other)", "mkh", ""},
+ {"Mongo", "lol", ""},
+ {"Mongolian", "mon", "mn", MAKELCID(MAKELANGID(LANG_MONGOLIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Mossi", "mos", ""},
+ {"Multiple languages", "mul", ""},
+ {"Munda languages", "mun", ""},
+ {"Nahuatl", "nah", ""},
+ {"Nauru", "nau", "na"},
+ {"Navaho, Navajo", "nav", "nv"},
+ {"Navajo; Navaho", "nav", "nv"},
+ {"Ndebele, North", "nde", "nd"},
+ {"Ndebele, South", "nbl", "nr"},
+ {"Ndonga", "ndo", "ng"},
+ {"Neapolitan", "nap", ""},
+ {"Nepali", "nep", "ne", MAKELCID(MAKELANGID(LANG_NEPALI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Newari", "new", ""},
+ {"Nias", "nia", ""},
+ {"Niger-Kordofanian (Other)", "nic", ""},
+ {"Nilo-Saharan (Other)", "ssa", ""},
+ {"Niuean", "niu", ""},
+ {"Norse, Old", "non", ""},
+ {"North American Indian (Other)", "nai", ""},
+ {"Northern Sami", "sme", "se"},
+ {"North Ndebele", "nde", "nd"},
+ {"Norwegian", "nor", "no", MAKELCID(MAKELANGID(LANG_NORWEGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Norwegian Bokmål; Bokmål, Norwegian", "nob", "nb", MAKELCID(MAKELANGID(LANG_NORWEGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Norwegian Nynorsk; Nynorsk, Norwegian", "nno", "nn", MAKELCID(MAKELANGID(LANG_NORWEGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Nubian languages", "nub", ""},
+ {"Nyamwezi", "nym", ""},
+ {"Nyanja; Chichewa; Chewa", "nya", "ny"},
+ {"Nyankole", "nyn", ""},
+ {"Nynorsk, Norwegian; Norwegian Nynorsk", "nno", "nn"},
+ {"Nyoro", "nyo", ""},
+ {"Nzima", "nzi", ""},
+ {"Occitan (post 1500},; Provençal", "oci", "oc", MAKELCID(MAKELANGID(LANG_OCCITAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Ojibwa", "oji", "oj"},
+ {"Old Bulgarian; Old Slavonic; Church Slavonic;", "chu", "cu"},
+ {"Oriya", "ori", "or"},
+ {"Oromo", "orm", "om"},
+ {"Osage", "osa", ""},
+ {"Ossetian; Ossetic", "oss", "os"},
+ {"Ossetic; Ossetian", "oss", "os"},
+ {"Otomian languages", "oto", ""},
+ {"Pahlavi", "pal", ""},
+ {"Palauan", "pau", ""},
+ {"Pali", "pli", "pi"},
+ {"Pampanga", "pam", ""},
+ {"Pangasinan", "pag", ""},
+ {"Panjabi", "pan", "pa"},
+ {"Papiamento", "pap", ""},
+ {"Papuan (Other)", "paa", ""},
+ {"Persian", "per", "fa", MAKELCID(MAKELANGID(LANG_PERSIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Persian", "fas", "fa", MAKELCID(MAKELANGID(LANG_PERSIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Persian, Old (ca.600-400 B.C.)", "peo", ""},
+ {"Philippine (Other)", "phi", ""},
+ {"Phoenician", "phn", ""},
+ {"Pohnpeian", "pon", ""},
+ {"Polish", "pol", "pl", MAKELCID(MAKELANGID(LANG_POLISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Portuguese", "por", "pt", MAKELCID(MAKELANGID(LANG_PORTUGUESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Prakrit languages", "pra", ""},
+ {"Provençal; Occitan (post 1500)", "oci", "oc"},
+ {"Provençal, Old (to 1500)", "pro", ""},
+ {"Pushto", "pus", "ps"},
+ {"Quechua", "que", "qu", MAKELCID(MAKELANGID(LANG_QUECHUA, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Raeto-Romance", "roh", "rm"},
+ {"Rajasthani", "raj", ""},
+ {"Rapanui", "rap", ""},
+ {"Rarotongan", "rar", ""},
+ {"Reserved for local use", "qaa-qtz", ""},
+ {"Romance (Other)", "roa", ""},
+ {"Romanian", "rum", "ro", MAKELCID(MAKELANGID(LANG_ROMANIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Romanian", "ron", "ro", MAKELCID(MAKELANGID(LANG_ROMANIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Romany", "rom", ""},
+ {"Rundi", "run", "rn"},
+ {"Russian", "rus", "ru", MAKELCID(MAKELANGID(LANG_RUSSIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Salishan languages", "sal", ""},
+ {"Samaritan Aramaic", "sam", ""},
+ {"Sami languages (Other)", "smi", ""},
+ {"Samoan", "smo", "sm"},
+ {"Sandawe", "sad", ""},
+ {"Sango", "sag", "sg"},
+ {"Sanskrit", "san", "sa", MAKELCID(MAKELANGID(LANG_SANSKRIT, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Santali", "sat", ""},
+ {"Sardinian", "srd", "sc"},
+ {"Sasak", "sas", ""},
+ {"Saxon, Low; German, Low; Low Saxon; Low German", "nds", ""},
+ {"Scots", "sco", ""},
+ {"Scottish Gaelic; Gaelic", "gla", "gd"},
+ {"Selkup", "sel", ""},
+ {"Semitic (Other)", "sem", ""},
+ {"Serbian", "scc", "sr", MAKELCID(MAKELANGID(LANG_SERBIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Serbian", "srp", "sr", MAKELCID(MAKELANGID(LANG_SERBIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Serer", "srr", ""},
+ {"Shan", "shn", ""},
+ {"Shona", "sna", "sn"},
+ {"Sichuan Yi", "iii", "ii"},
+ {"Sidamo", "sid", ""},
+ {"Sign languages", "sgn", ""},
+ {"Siksika", "bla", ""},
+ {"Sindhi", "snd", "sd", MAKELCID(MAKELANGID(LANG_SINDHI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Sinhalese", "sin", "si", MAKELCID(MAKELANGID(LANG_SINHALESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Sino-Tibetan (Other)", "sit", ""},
+ {"Siouan languages", "sio", ""},
+ {"Skolt Sami", "sms", ""},
+ {"Slave (Athapascan)", "den", ""},
+ {"Slavic (Other)", "sla", ""},
+ {"Slovak", "slo", "sk", MAKELCID(MAKELANGID(LANG_SLOVAK, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Slovak", "slk", "sk", MAKELCID(MAKELANGID(LANG_SLOVAK, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Slovenian", "slv", "sl", MAKELCID(MAKELANGID(LANG_SLOVENIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Sogdian", "sog", ""},
+ {"Somali", "som", "so"},
+ {"Songhai", "son", ""},
+ {"Soninke", "snk", ""},
+ {"Sorbian languages", "wen", ""},
+ {"Sotho, Northern", "nso", "", MAKELCID(MAKELANGID(LANG_SOTHO, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Sotho, Southern", "sot", "st", MAKELCID(MAKELANGID(LANG_SOTHO, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"South American Indian (Other)", "sai", ""},
+ {"Southern Sami", "sma", ""},
+ {"South Ndebele", "nbl", "nr"},
+ {"Spanish; Castilian", "spa", "es", MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Sukuma", "suk", ""},
+ {"Sumerian", "sux", ""},
+ {"Sundanese", "sun", "su"},
+ {"Susu", "sus", ""},
+ {"Swahili", "swa", "sw", MAKELCID(MAKELANGID(LANG_SWAHILI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Swati", "ssw", "ss"},
+ {"Swedish", "swe", "sv", MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Syriac", "syr", "", MAKELCID(MAKELANGID(LANG_SYRIAC, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Tagalog", "tgl", "tl"},
+ {"Tahitian", "tah", "ty"},
+ {"Tai (Other)", "tai", ""},
+ {"Tajik", "tgk", "tg", MAKELCID(MAKELANGID(LANG_TAJIK, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Tamashek", "tmh", ""},
+ {"Tamil", "tam", "ta", MAKELCID(MAKELANGID(LANG_TAMIL, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Tatar", "tat", "tt", MAKELCID(MAKELANGID(LANG_TATAR, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Telugu", "tel", "te", MAKELCID(MAKELANGID(LANG_TELUGU, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Tereno", "ter", ""},
+ {"Tetum", "tet", ""},
+ {"Thai", "tha", "th", MAKELCID(MAKELANGID(LANG_THAI, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Tibetan", "tib", "bo", MAKELCID(MAKELANGID(LANG_TIBETAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Tibetan", "bod", "bo", MAKELCID(MAKELANGID(LANG_TIBETAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Tigre", "tig", ""},
+ {"Tigrinya", "tir", "ti", MAKELCID(MAKELANGID(LANG_TIGRIGNA, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Timne", "tem", ""},
+ {"Tiv", "tiv", ""},
+ {"Tlingit", "tli", ""},
+ {"Tok Pisin", "tpi", ""},
+ {"Tokelau", "tkl", ""},
+ {"Tonga (Nyasa)", "tog", ""},
+ {"Tonga (Tonga Islands)", "ton", "to"},
+ {"Tsimshian", "tsi", ""},
+ {"Tsonga", "tso", "ts"},
+ {"Tswana", "tsn", "tn", MAKELCID(MAKELANGID(LANG_TSWANA, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Tumbuka", "tum", ""},
+ {"Tupi languages", "tup", ""},
+ {"Turkish", "tur", "tr", MAKELCID(MAKELANGID(LANG_TURKISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Turkish, Ottoman (1500-1928)", "ota", "", MAKELCID(MAKELANGID(LANG_TURKISH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Turkmen", "tuk", "tk", MAKELCID(MAKELANGID(LANG_TURKMEN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Tuvalu", "tvl", ""},
+ {"Tuvinian", "tyv", ""},
+ {"Twi", "twi", "tw"},
+ {"Ugaritic", "uga", ""},
+ {"Uighur", "uig", "ug", MAKELCID(MAKELANGID(LANG_UIGHUR, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Ukrainian", "ukr", "uk", MAKELCID(MAKELANGID(LANG_UKRAINIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Umbundu", "umb", ""},
+ {"Undetermined", "und", ""},
+ {"Urdu", "urd", "ur", MAKELCID(MAKELANGID(LANG_URDU, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Uzbek", "uzb", "uz", MAKELCID(MAKELANGID(LANG_UZBEK, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Vai", "vai", ""},
+ {"Venda", "ven", "ve"},
+ {"Vietnamese", "vie", "vi", MAKELCID(MAKELANGID(LANG_VIETNAMESE, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Volapuk", "vol", "vo"},
+ {"Votic", "vot", ""},
+ {"Wakashan languages", "wak", ""},
+ {"Walamo", "wal", ""},
+ {"Walloon", "wln", "wa"},
+ {"Waray", "war", ""},
+ {"Washo", "was", ""},
+ {"Welsh", "wel", "cy", MAKELCID(MAKELANGID(LANG_WELSH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Welsh", "cym", "cy", MAKELCID(MAKELANGID(LANG_WELSH, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Wolof", "wol", "wo", MAKELCID(MAKELANGID(LANG_WOLOF, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Xhosa", "xho", "xh", MAKELCID(MAKELANGID(LANG_XHOSA, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Yakut", "sah", "", MAKELCID(MAKELANGID(LANG_YAKUT, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Yao", "yao", ""},
+ {"Yapese", "yap", ""},
+ {"Yiddish", "yid", "yi"},
+ {"Yoruba", "yor", "yo", MAKELCID(MAKELANGID(LANG_YORUBA, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Yupik languages", "ypk", ""},
+ {"Zande", "znd", ""},
+ {"Zapotec", "zap", ""},
+ {"Zenaga", "zen", ""},
+ {"Zhuang; Chuang", "zha", "za"},
+ {"Zulu", "zul", "zu", MAKELCID(MAKELANGID(LANG_ZULU, SUBLANG_DEFAULT), SORT_DEFAULT)},
+ {"Zuni", "zun", ""},
+ {"Classical Newari", "nwc", ""},
+ {"Klingon", "tlh", ""},
+ {"Blin", "byn", ""},
+ {"Lojban", "jbo", ""},
+ {"Lower Sorbian", "dsb", ""},
+ {"Upper Sorbian", "hsb", ""},
+ {"Kashubian", "csb", ""},
+ {"Crimean Turkish", "crh", ""},
+ {"Erzya", "myv", ""},
+ {"Moksha", "mdf", ""},
+ {"Karachay-Balkar", "krc", ""},
+ {"Adyghe", "ady", ""},
+ {"Udmurt", "udm", ""},
+ {"Dargwa", "dar", ""},
+ {"Ingush", "inh", ""},
+ {"Nogai", "nog", ""},
+ {"Haitian", "hat", "ht"},
+ {"Kalmyk", "xal", ""},
+ {"", "", ""},
+ {"No subtitles", "---", "", (LCID)LCID_NOSUBTITLES},
};
CString ISO6391ToLanguage(LPCSTR code)
{
- CHAR tmp[2+1];
- strncpy_s(tmp, code, 2);
- tmp[2] = 0;
- _strlwr_s(tmp);
- for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++)
- if (!strcmp(s_isolangs[i].iso6391, tmp)) {
- CString ret = CString(CStringA(s_isolangs[i].name));
- int i = ret.Find(';');
- if (i > 0) {
- ret = ret.Left(i);
- }
- return ret;
- }
- return _T("");
+ CHAR tmp[2 + 1];
+ strncpy_s(tmp, code, 2);
+ tmp[2] = 0;
+ _strlwr_s(tmp);
+ for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++)
+ if (!strcmp(s_isolangs[i].iso6391, tmp)) {
+ CString ret = CString(CStringA(s_isolangs[i].name));
+ int i = ret.Find(';');
+ if (i > 0) {
+ ret = ret.Left(i);
+ }
+ return ret;
+ }
+ return _T("");
}
CString ISO6392ToLanguage(LPCSTR code)
{
- CHAR tmp[3+1];
- strncpy_s(tmp, code, 3);
- tmp[3] = 0;
- _strlwr_s(tmp);
- for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++) {
- if (!strcmp(s_isolangs[i].iso6392, tmp)) {
- CString ret = CString(CStringA(s_isolangs[i].name));
- int i = ret.Find(';');
- if (i > 0) {
- ret = ret.Left(i);
- }
- return ret;
- }
- }
- return CString(code);
+ CHAR tmp[3 + 1];
+ strncpy_s(tmp, code, 3);
+ tmp[3] = 0;
+ _strlwr_s(tmp);
+ for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++) {
+ if (!strcmp(s_isolangs[i].iso6392, tmp)) {
+ CString ret = CString(CStringA(s_isolangs[i].name));
+ int i = ret.Find(';');
+ if (i > 0) {
+ ret = ret.Left(i);
+ }
+ return ret;
+ }
+ }
+ return CString(code);
}
LCID ISO6391ToLcid(LPCSTR code)
{
- CHAR tmp[3+1];
- strncpy_s(tmp, code, 3);
- tmp[3] = 0;
- _strlwr_s(tmp);
- for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++) {
- if (!strcmp(s_isolangs[i].iso6391, code)) {
- return s_isolangs[i].lcid;
- }
- }
- return 0;
+ CHAR tmp[3 + 1];
+ strncpy_s(tmp, code, 3);
+ tmp[3] = 0;
+ _strlwr_s(tmp);
+ for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++) {
+ if (!strcmp(s_isolangs[i].iso6391, code)) {
+ return s_isolangs[i].lcid;
+ }
+ }
+ return 0;
}
LCID ISO6392ToLcid(LPCSTR code)
{
- CHAR tmp[3+1];
- strncpy_s(tmp, code, 3);
- tmp[3] = 0;
- _strlwr_s(tmp);
- for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++) {
- if (!strcmp(s_isolangs[i].iso6392, tmp)) {
- return s_isolangs[i].lcid;
- }
- }
- return 0;
+ CHAR tmp[3 + 1];
+ strncpy_s(tmp, code, 3);
+ tmp[3] = 0;
+ _strlwr_s(tmp);
+ for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++) {
+ if (!strcmp(s_isolangs[i].iso6392, tmp)) {
+ return s_isolangs[i].lcid;
+ }
+ }
+ return 0;
}
CString ISO6391To6392(LPCSTR code)
{
- CHAR tmp[2+1];
- strncpy_s(tmp, code, 2);
- tmp[2] = 0;
- _strlwr_s(tmp);
- for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++)
- if (!strcmp(s_isolangs[i].iso6391, tmp)) {
- return CString(CStringA(s_isolangs[i].iso6392));
- }
- return _T("");
+ CHAR tmp[2 + 1];
+ strncpy_s(tmp, code, 2);
+ tmp[2] = 0;
+ _strlwr_s(tmp);
+ for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++)
+ if (!strcmp(s_isolangs[i].iso6391, tmp)) {
+ return CString(CStringA(s_isolangs[i].iso6392));
+ }
+ return _T("");
}
CString ISO6392To6391(LPCSTR code)
{
- CHAR tmp[3+1];
- strncpy_s(tmp, code, 3);
- tmp[3] = 0;
- _strlwr_s(tmp);
- for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++)
- if (!strcmp(s_isolangs[i].iso6392, tmp)) {
- return CString(CStringA(s_isolangs[i].iso6391));
- }
- return _T("");
+ CHAR tmp[3 + 1];
+ strncpy_s(tmp, code, 3);
+ tmp[3] = 0;
+ _strlwr_s(tmp);
+ for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++)
+ if (!strcmp(s_isolangs[i].iso6392, tmp)) {
+ return CString(CStringA(s_isolangs[i].iso6391));
+ }
+ return _T("");
}
CString LanguageToISO6392(LPCTSTR lang)
{
- CString str = lang;
- str.MakeLower();
- for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++) {
- CAtlList<CString> sl;
- Explode(CString(s_isolangs[i].name), sl, ';');
- POSITION pos = sl.GetHeadPosition();
- while (pos) {
- if (!str.CompareNoCase(sl.GetNext(pos))) {
- return CString(s_isolangs[i].iso6392);
- }
- }
- }
- return _T("");
+ CString str = lang;
+ str.MakeLower();
+ for (ptrdiff_t i = 0, j = _countof(s_isolangs); i < j; i++) {
+ CAtlList<CString> sl;
+ Explode(CString(s_isolangs[i].name), sl, ';');
+ POSITION pos = sl.GetHeadPosition();
+ while (pos) {
+ if (!str.CompareNoCase(sl.GetNext(pos))) {
+ return CString(s_isolangs[i].iso6392);
+ }
+ }
+ }
+ return _T("");
}
int MakeAACInitData(BYTE* pData, int profile, int freq, int channels)
{
- int srate_idx;
-
- if (92017 <= freq) {
- srate_idx = 0;
- } else if (75132 <= freq) {
- srate_idx = 1;
- } else if (55426 <= freq) {
- srate_idx = 2;
- } else if (46009 <= freq) {
- srate_idx = 3;
- } else if (37566 <= freq) {
- srate_idx = 4;
- } else if (27713 <= freq) {
- srate_idx = 5;
- } else if (23004 <= freq) {
- srate_idx = 6;
- } else if (18783 <= freq) {
- srate_idx = 7;
- } else if (13856 <= freq) {
- srate_idx = 8;
- } else if (11502 <= freq) {
- srate_idx = 9;
- } else if (9391 <= freq) {
- srate_idx = 10;
- } else {
- srate_idx = 11;
- }
-
- pData[0] = ((abs(profile) + 1) << 3) | ((srate_idx & 0xe) >> 1);
- pData[1] = ((srate_idx & 0x1) << 7) | (channels << 3);
-
- int ret = 2;
-
- if (profile < 0) {
- freq *= 2;
-
- if (92017 <= freq) {
- srate_idx = 0;
- } else if (75132 <= freq) {
- srate_idx = 1;
- } else if (55426 <= freq) {
- srate_idx = 2;
- } else if (46009 <= freq) {
- srate_idx = 3;
- } else if (37566 <= freq) {
- srate_idx = 4;
- } else if (27713 <= freq) {
- srate_idx = 5;
- } else if (23004 <= freq) {
- srate_idx = 6;
- } else if (18783 <= freq) {
- srate_idx = 7;
- } else if (13856 <= freq) {
- srate_idx = 8;
- } else if (11502 <= freq) {
- srate_idx = 9;
- } else if (9391 <= freq) {
- srate_idx = 10;
- } else {
- srate_idx = 11;
- }
-
- pData[2] = 0x2B7>>3;
- pData[3] = (BYTE)((0x2B7<<5) | 5);
- pData[4] = (1<<7) | (srate_idx<<3);
-
- ret = 5;
- }
-
- return ret;
+ int srate_idx;
+
+ if (92017 <= freq) {
+ srate_idx = 0;
+ } else if (75132 <= freq) {
+ srate_idx = 1;
+ } else if (55426 <= freq) {
+ srate_idx = 2;
+ } else if (46009 <= freq) {
+ srate_idx = 3;
+ } else if (37566 <= freq) {
+ srate_idx = 4;
+ } else if (27713 <= freq) {
+ srate_idx = 5;
+ } else if (23004 <= freq) {
+ srate_idx = 6;
+ } else if (18783 <= freq) {
+ srate_idx = 7;
+ } else if (13856 <= freq) {
+ srate_idx = 8;
+ } else if (11502 <= freq) {
+ srate_idx = 9;
+ } else if (9391 <= freq) {
+ srate_idx = 10;
+ } else {
+ srate_idx = 11;
+ }
+
+ pData[0] = ((abs(profile) + 1) << 3) | ((srate_idx & 0xe) >> 1);
+ pData[1] = ((srate_idx & 0x1) << 7) | (channels << 3);
+
+ int ret = 2;
+
+ if (profile < 0) {
+ freq *= 2;
+
+ if (92017 <= freq) {
+ srate_idx = 0;
+ } else if (75132 <= freq) {
+ srate_idx = 1;
+ } else if (55426 <= freq) {
+ srate_idx = 2;
+ } else if (46009 <= freq) {
+ srate_idx = 3;
+ } else if (37566 <= freq) {
+ srate_idx = 4;
+ } else if (27713 <= freq) {
+ srate_idx = 5;
+ } else if (23004 <= freq) {
+ srate_idx = 6;
+ } else if (18783 <= freq) {
+ srate_idx = 7;
+ } else if (13856 <= freq) {
+ srate_idx = 8;
+ } else if (11502 <= freq) {
+ srate_idx = 9;
+ } else if (9391 <= freq) {
+ srate_idx = 10;
+ } else {
+ srate_idx = 11;
+ }
+
+ pData[2] = 0x2B7 >> 3;
+ pData[3] = (BYTE)((0x2B7 << 5) | 5);
+ pData[4] = (1 << 7) | (srate_idx << 3);
+
+ ret = 5;
+ }
+
+ return ret;
}
BOOL CFileGetStatus(LPCTSTR lpszFileName, CFileStatus& status)
{
- try {
- return CFile::GetStatus(lpszFileName, status);
- } catch (CException* e) {
- // MFCBUG: E_INVALIDARG / "Parameter is incorrect" is thrown for certain cds (vs2003)
- // http://groups.google.co.uk/groups?hl=en&lr=&ie=UTF-8&threadm=OZuXYRzWDHA.536%40TK2MSFTNGP10.phx.gbl&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DISO-8859-1
- TRACE(_T("CFile::GetStatus has thrown an exception\n"));
- e->Delete();
- return false;
- }
+ try {
+ return CFile::GetStatus(lpszFileName, status);
+ } catch (CException* e) {
+ // MFCBUG: E_INVALIDARG / "Parameter is incorrect" is thrown for certain cds (vs2003)
+ // http://groups.google.co.uk/groups?hl=en&lr=&ie=UTF-8&threadm=OZuXYRzWDHA.536%40TK2MSFTNGP10.phx.gbl&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DISO-8859-1
+ TRACE(_T("CFile::GetStatus has thrown an exception\n"));
+ e->Delete();
+ return false;
+ }
}
// filter registration helpers
bool DeleteRegKey(LPCTSTR pszKey, LPCTSTR pszSubkey)
{
- bool bOK = false;
+ bool bOK = false;
- HKEY hKey;
- LONG ec = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, pszKey, 0, KEY_ALL_ACCESS, &hKey);
- if (ec == ERROR_SUCCESS) {
- if (pszSubkey != 0) {
- ec = ::RegDeleteKey(hKey, pszSubkey);
- }
+ HKEY hKey;
+ LONG ec = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, pszKey, 0, KEY_ALL_ACCESS, &hKey);
+ if (ec == ERROR_SUCCESS) {
+ if (pszSubkey != 0) {
+ ec = ::RegDeleteKey(hKey, pszSubkey);
+ }
- bOK = (ec == ERROR_SUCCESS);
+ bOK = (ec == ERROR_SUCCESS);
- ::RegCloseKey(hKey);
- }
+ ::RegCloseKey(hKey);
+ }
- return bOK;
+ return bOK;
}
bool SetRegKeyValue(LPCTSTR pszKey, LPCTSTR pszSubkey, LPCTSTR pszValueName, LPCTSTR pszValue)
{
- bool bOK = false;
+ bool bOK = false;
- CString szKey(pszKey);
- if (pszSubkey != 0) {
- szKey += CString(_T("\\")) + pszSubkey;
- }
+ CString szKey(pszKey);
+ if (pszSubkey != 0) {
+ szKey += CString(_T("\\")) + pszSubkey;
+ }
- HKEY hKey;
- LONG ec = ::RegCreateKeyEx(HKEY_CLASSES_ROOT, szKey, 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hKey, 0);
- if (ec == ERROR_SUCCESS) {
- if (pszValue != 0) {
- ec = ::RegSetValueEx(hKey, pszValueName, 0, REG_SZ,
- reinterpret_cast<BYTE*>(const_cast<LPTSTR>(pszValue)),
- (DWORD)(_tcslen(pszValue) + 1) * sizeof(TCHAR));
- }
+ HKEY hKey;
+ LONG ec = ::RegCreateKeyEx(HKEY_CLASSES_ROOT, szKey, 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hKey, 0);
+ if (ec == ERROR_SUCCESS) {
+ if (pszValue != 0) {
+ ec = ::RegSetValueEx(hKey, pszValueName, 0, REG_SZ,
+ reinterpret_cast<BYTE*>(const_cast<LPTSTR>(pszValue)),
+ (DWORD)(_tcslen(pszValue) + 1) * sizeof(TCHAR));
+ }
- bOK = (ec == ERROR_SUCCESS);
+ bOK = (ec == ERROR_SUCCESS);
- ::RegCloseKey(hKey);
- }
+ ::RegCloseKey(hKey);
+ }
- return bOK;
+ return bOK;
}
bool SetRegKeyValue(LPCTSTR pszKey, LPCTSTR pszSubkey, LPCTSTR pszValue)
{
- return SetRegKeyValue(pszKey, pszSubkey, 0, pszValue);
+ return SetRegKeyValue(pszKey, pszSubkey, 0, pszValue);
}
void RegisterSourceFilter(const CLSID& clsid, const GUID& subtype2, LPCTSTR chkbytes, LPCTSTR ext, ...)
{
- CString null = CStringFromGUID(GUID_NULL);
- CString majortype = CStringFromGUID(MEDIATYPE_Stream);
- CString subtype = CStringFromGUID(subtype2);
+ CString null = CStringFromGUID(GUID_NULL);
+ CString majortype = CStringFromGUID(MEDIATYPE_Stream);
+ CString subtype = CStringFromGUID(subtype2);
- SetRegKeyValue(_T("Media Type\\") + majortype, subtype, _T("0"), chkbytes);
- SetRegKeyValue(_T("Media Type\\") + majortype, subtype, _T("Source Filter"), CStringFromGUID(clsid));
+ SetRegKeyValue(_T("Media Type\\") + majortype, subtype, _T("0"), chkbytes);
+ SetRegKeyValue(_T("Media Type\\") + majortype, subtype, _T("Source Filter"), CStringFromGUID(clsid));
- DeleteRegKey(_T("Media Type\\") + null, subtype);
+ DeleteRegKey(_T("Media Type\\") + null, subtype);
- va_list marker;
- va_start(marker, ext);
- for (; ext; ext = va_arg(marker, LPCTSTR)) {
- DeleteRegKey(_T("Media Type\\Extensions"), ext);
- }
- va_end(marker);
+ va_list marker;
+ va_start(marker, ext);
+ for (; ext; ext = va_arg(marker, LPCTSTR)) {
+ DeleteRegKey(_T("Media Type\\Extensions"), ext);
+ }
+ va_end(marker);
}
void RegisterSourceFilter(const CLSID& clsid, const GUID& subtype2, const CAtlList<CString>& chkbytes, LPCTSTR ext, ...)
{
- CString null = CStringFromGUID(GUID_NULL);
- CString majortype = CStringFromGUID(MEDIATYPE_Stream);
- CString subtype = CStringFromGUID(subtype2);
+ CString null = CStringFromGUID(GUID_NULL);
+ CString majortype = CStringFromGUID(MEDIATYPE_Stream);
+ CString subtype = CStringFromGUID(subtype2);
- POSITION pos = chkbytes.GetHeadPosition();
- for (ptrdiff_t i = 0; pos; i++) {
- CString idx;
- idx.Format(_T("%d"), i);
- SetRegKeyValue(_T("Media Type\\") + majortype, subtype, idx, chkbytes.GetNext(pos));
- }
+ POSITION pos = chkbytes.GetHeadPosition();
+ for (ptrdiff_t i = 0; pos; i++) {
+ CString idx;
+ idx.Format(_T("%d"), i);
+ SetRegKeyValue(_T("Media Type\\") + majortype, subtype, idx, chkbytes.GetNext(pos));
+ }
- SetRegKeyValue(_T("Media Type\\") + majortype, subtype, _T("Source Filter"), CStringFromGUID(clsid));
+ SetRegKeyValue(_T("Media Type\\") + majortype, subtype, _T("Source Filter"), CStringFromGUID(clsid));
- DeleteRegKey(_T("Media Type\\") + null, subtype);
+ DeleteRegKey(_T("Media Type\\") + null, subtype);
- va_list marker;
- va_start(marker, ext);
- for (; ext; ext = va_arg(marker, LPCTSTR)) {
- DeleteRegKey(_T("Media Type\\Extensions"), ext);
- }
- va_end(marker);
+ va_list marker;
+ va_start(marker, ext);
+ for (; ext; ext = va_arg(marker, LPCTSTR)) {
+ DeleteRegKey(_T("Media Type\\Extensions"), ext);
+ }
+ va_end(marker);
}
void UnRegisterSourceFilter(const GUID& subtype)
{
- DeleteRegKey(_T("Media Type\\") + CStringFromGUID(MEDIATYPE_Stream), CStringFromGUID(subtype));
+ DeleteRegKey(_T("Media Type\\") + CStringFromGUID(MEDIATYPE_Stream), CStringFromGUID(subtype));
}
typedef struct {
- const GUID* Guid;
- const LPCTSTR Description;
+ const GUID* Guid;
+ const LPCTSTR Description;
} DXVA2_DECODER;
static const DXVA2_DECODER DXVA2Decoder[] = {
- {&GUID_NULL, _T("Unknown")},
- {&GUID_NULL, _T("Not using DXVA")},
- {&DXVA_Intel_H264_ClearVideo, _T("H.264 bitstream decoder, ClearVideo(tm)")}, // Intel ClearVideo H264 bitstream decoder
- {&DXVA_Intel_VC1_ClearVideo, _T("VC-1 bitstream decoder, ClearVideo(tm)")}, // Intel ClearVideo VC-1 bitstream decoder
- {&DXVA_MPEG4_ASP, _T("MPEG-4 ASP bitstream decoder")}, // Nvidia MPEG-4 ASP bitstream decoder
- {&DXVA_ModeNone, _T("Mode none")},
- {&DXVA_ModeH261_A, _T("H.261 A, post processing")},
- {&DXVA_ModeH261_B, _T("H.261 B, deblocking")},
- {&DXVA_ModeH263_A, _T("H.263 A, motion compensation, no FGT")},
- {&DXVA_ModeH263_B, _T("H.263 B, motion compensation, FGT")},
- {&DXVA_ModeH263_C, _T("H.263 C, IDCT, no FGT")},
- {&DXVA_ModeH263_D, _T("H.263 D, IDCT, FGT")},
- {&DXVA_ModeH263_E, _T("H.263 E, bitstream decoder, no FGT")},
- {&DXVA_ModeH263_F, _T("H.263 F, bitstream decoder, FGT")},
- {&DXVA_ModeMPEG1_A, _T("MPEG-1 A, post processing")},
- {&DXVA_ModeMPEG2_A, _T("MPEG-2 A, motion compensation")},
- {&DXVA_ModeMPEG2_B, _T("MPEG-2 B, motion compensation + blending")},
- {&DXVA_ModeMPEG2_C, _T("MPEG-2 C, IDCT")},
- {&DXVA_ModeMPEG2_D, _T("MPEG-2 D, IDCT + blending")},
- {&DXVA_ModeH264_A, _T("H.264 A, motion compensation, no FGT")},
- {&DXVA_ModeH264_B, _T("H.264 B, motion compensation, FGT")},
- {&DXVA_ModeH264_C, _T("H.264 C, IDCT, no FGT")},
- {&DXVA_ModeH264_D, _T("H.264 D, IDCT, FGT")},
- {&DXVA_ModeH264_E, _T("H.264 E, bitstream decoder, no FGT")},
- {&DXVA_ModeH264_F, _T("H.264 F, bitstream decoder, FGT")},
- {&DXVA_ModeWMV8_A, _T("WMV8 A, post processing")},
- {&DXVA_ModeWMV8_B, _T("WMV8 B, motion compensation")},
- {&DXVA_ModeWMV9_A, _T("WMV9 A, post processing")},
- {&DXVA_ModeWMV9_B, _T("WMV9 B, motion compensation")},
- {&DXVA_ModeWMV9_C, _T("WMV9 C, IDCT")},
- {&DXVA_ModeVC1_A, _T("VC-1 A, post processing")},
- {&DXVA_ModeVC1_B, _T("VC-1 B, motion compensation")},
- {&DXVA_ModeVC1_C, _T("VC-1 C, IDCT")},
- {&DXVA_ModeVC1_D, _T("VC-1 D, bitstream decoder")},
- {&DXVA_NoEncrypt, _T("No encryption")},
- {&DXVA2_ModeMPEG2_MoComp, _T("MPEG-2 motion compensation")},
- {&DXVA2_ModeMPEG2_IDCT, _T("MPEG-2 IDCT")},
- {&DXVA2_ModeMPEG2_VLD, _T("MPEG-2 variable-length decoder")},
- {&DXVA2_ModeH264_A, _T("H.264 A, motion compensation, no FGT")},
- {&DXVA2_ModeH264_B, _T("H.264 B, motion compensation, FGT")},
- {&DXVA2_ModeH264_C, _T("H.264 C, IDCT, no FGT")},
- {&DXVA2_ModeH264_D, _T("H.264 D, IDCT, FGT")},
- {&DXVA2_ModeH264_E, _T("H.264 E, bitstream decoder, no FGT")},
- {&DXVA2_ModeH264_F, _T("H.264 F, bitstream decoder, FGT")},
- {&DXVA2_ModeWMV8_A, _T("WMV8 A, post processing")},
- {&DXVA2_ModeWMV8_B, _T("WMV8 B, motion compensation")},
- {&DXVA2_ModeWMV9_A, _T("WMV9 A, post processing")},
- {&DXVA2_ModeWMV9_B, _T("WMV9 B, motion compensation")},
- {&DXVA2_ModeWMV9_C, _T("WMV9 C, IDCT")},
- {&DXVA2_ModeVC1_A, _T("VC-1 A, post processing")},
- {&DXVA2_ModeVC1_B, _T("VC-1 B, motion compensation")},
- {&DXVA2_ModeVC1_C, _T("VC-1 C, IDCT")},
- {&DXVA2_ModeVC1_D, _T("VC-1 D, bitstream decoder")},
- {&DXVA2_NoEncrypt, _T("No encryption")},
- {&DXVA2_VideoProcProgressiveDevice, _T("Progressive scan")},
- {&DXVA2_VideoProcBobDevice, _T("Bob deinterlacing")},
- {&DXVA2_VideoProcSoftwareDevice, _T("Software processing")}
+ {&GUID_NULL, _T("Unknown")},
+ {&GUID_NULL, _T("Not using DXVA")},
+ {&DXVA_Intel_H264_ClearVideo, _T("H.264 bitstream decoder, ClearVideo(tm)")}, // Intel ClearVideo H264 bitstream decoder
+ {&DXVA_Intel_VC1_ClearVideo, _T("VC-1 bitstream decoder, ClearVideo(tm)")}, // Intel ClearVideo VC-1 bitstream decoder
+ {&DXVA_MPEG4_ASP, _T("MPEG-4 ASP bitstream decoder")}, // Nvidia MPEG-4 ASP bitstream decoder
+ {&DXVA_ModeNone, _T("Mode none")},
+ {&DXVA_ModeH261_A, _T("H.261 A, post processing")},
+ {&DXVA_ModeH261_B, _T("H.261 B, deblocking")},
+ {&DXVA_ModeH263_A, _T("H.263 A, motion compensation, no FGT")},
+ {&DXVA_ModeH263_B, _T("H.263 B, motion compensation, FGT")},
+ {&DXVA_ModeH263_C, _T("H.263 C, IDCT, no FGT")},
+ {&DXVA_ModeH263_D, _T("H.263 D, IDCT, FGT")},
+ {&DXVA_ModeH263_E, _T("H.263 E, bitstream decoder, no FGT")},
+ {&DXVA_ModeH263_F, _T("H.263 F, bitstream decoder, FGT")},
+ {&DXVA_ModeMPEG1_A, _T("MPEG-1 A, post processing")},
+ {&DXVA_ModeMPEG2_A, _T("MPEG-2 A, motion compensation")},
+ {&DXVA_ModeMPEG2_B, _T("MPEG-2 B, motion compensation + blending")},
+ {&DXVA_ModeMPEG2_C, _T("MPEG-2 C, IDCT")},
+ {&DXVA_ModeMPEG2_D, _T("MPEG-2 D, IDCT + blending")},
+ {&DXVA_ModeH264_A, _T("H.264 A, motion compensation, no FGT")},
+ {&DXVA_ModeH264_B, _T("H.264 B, motion compensation, FGT")},
+ {&DXVA_ModeH264_C, _T("H.264 C, IDCT, no FGT")},
+ {&DXVA_ModeH264_D, _T("H.264 D, IDCT, FGT")},
+ {&DXVA_ModeH264_E, _T("H.264 E, bitstream decoder, no FGT")},
+ {&DXVA_ModeH264_F, _T("H.264 F, bitstream decoder, FGT")},
+ {&DXVA_ModeWMV8_A, _T("WMV8 A, post processing")},
+ {&DXVA_ModeWMV8_B, _T("WMV8 B, motion compensation")},
+ {&DXVA_ModeWMV9_A, _T("WMV9 A, post processing")},
+ {&DXVA_ModeWMV9_B, _T("WMV9 B, motion compensation")},
+ {&DXVA_ModeWMV9_C, _T("WMV9 C, IDCT")},
+ {&DXVA_ModeVC1_A, _T("VC-1 A, post processing")},
+ {&DXVA_ModeVC1_B, _T("VC-1 B, motion compensation")},
+ {&DXVA_ModeVC1_C, _T("VC-1 C, IDCT")},
+ {&DXVA_ModeVC1_D, _T("VC-1 D, bitstream decoder")},
+ {&DXVA_NoEncrypt, _T("No encryption")},
+ {&DXVA2_ModeMPEG2_MoComp, _T("MPEG-2 motion compensation")},
+ {&DXVA2_ModeMPEG2_IDCT, _T("MPEG-2 IDCT")},
+ {&DXVA2_ModeMPEG2_VLD, _T("MPEG-2 variable-length decoder")},
+ {&DXVA2_ModeH264_A, _T("H.264 A, motion compensation, no FGT")},
+ {&DXVA2_ModeH264_B, _T("H.264 B, motion compensation, FGT")},
+ {&DXVA2_ModeH264_C, _T("H.264 C, IDCT, no FGT")},
+ {&DXVA2_ModeH264_D, _T("H.264 D, IDCT, FGT")},
+ {&DXVA2_ModeH264_E, _T("H.264 E, bitstream decoder, no FGT")},
+ {&DXVA2_ModeH264_F, _T("H.264 F, bitstream decoder, FGT")},
+ {&DXVA2_ModeWMV8_A, _T("WMV8 A, post processing")},
+ {&DXVA2_ModeWMV8_B, _T("WMV8 B, motion compensation")},
+ {&DXVA2_ModeWMV9_A, _T("WMV9 A, post processing")},
+ {&DXVA2_ModeWMV9_B, _T("WMV9 B, motion compensation")},
+ {&DXVA2_ModeWMV9_C, _T("WMV9 C, IDCT")},
+ {&DXVA2_ModeVC1_A, _T("VC-1 A, post processing")},
+ {&DXVA2_ModeVC1_B, _T("VC-1 B, motion compensation")},
+ {&DXVA2_ModeVC1_C, _T("VC-1 C, IDCT")},
+ {&DXVA2_ModeVC1_D, _T("VC-1 D, bitstream decoder")},
+ {&DXVA2_NoEncrypt, _T("No encryption")},
+ {&DXVA2_VideoProcProgressiveDevice, _T("Progressive scan")},
+ {&DXVA2_VideoProcBobDevice, _T("Bob deinterlacing")},
+ {&DXVA2_VideoProcSoftwareDevice, _T("Software processing")}
};
LPCTSTR GetDXVAMode(const GUID* guidDecoder)
{
- int nPos = 0;
+ int nPos = 0;
- for (int i=1; i<_countof(DXVA2Decoder); i++) {
- if (*guidDecoder == *DXVA2Decoder[i].Guid) {
- nPos = i;
- break;
- }
- }
+ for (int i = 1; i < _countof(DXVA2Decoder); i++) {
+ if (*guidDecoder == *DXVA2Decoder[i].Guid) {
+ nPos = i;
+ break;
+ }
+ }
- return DXVA2Decoder[nPos].Description;
+ return DXVA2Decoder[nPos].Description;
}
void DumpBuffer(BYTE* pBuffer, int nSize)
{
- CString strMsg;
- int nPos = 0;
- strMsg.AppendFormat (L"Size : %d\n", nSize);
- for (int i=0; i<3; i++) {
- for (int j=0; j<32; j++) {
- nPos = i*32 + j;
- if (nPos >= nSize) {
- break;
- }
- strMsg.AppendFormat (L"%02x ", pBuffer[nPos]);
- }
- if (nPos >= nSize) {
- break;
- }
- strMsg.Append(L"\n");
- }
-
- if (nSize > 32*3) {
- strMsg.Append(L".../...\n");
- for (int j=32; j>0; j--) {
- strMsg.AppendFormat (L"%02x ", pBuffer[nSize - j]);
- }
- }
- strMsg.AppendFormat(L"\n");
-
- TRACE (strMsg);
+ CString strMsg;
+ int nPos = 0;
+ strMsg.AppendFormat(L"Size : %d\n", nSize);
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j < 32; j++) {
+ nPos = i * 32 + j;
+ if (nPos >= nSize) {
+ break;
+ }
+ strMsg.AppendFormat(L"%02x ", pBuffer[nPos]);
+ }
+ if (nPos >= nSize) {
+ break;
+ }
+ strMsg.Append(L"\n");
+ }
+
+ if (nSize > 32 * 3) {
+ strMsg.Append(L".../...\n");
+ for (int j = 32; j > 0; j--) {
+ strMsg.AppendFormat(L"%02x ", pBuffer[nSize - j]);
+ }
+ }
+ strMsg.AppendFormat(L"\n");
+
+ TRACE(strMsg);
}
// hour, minute, second, millisec
CString ReftimeToString(const REFERENCE_TIME& rtVal)
{
- CString strTemp;
- LONGLONG llTotalMs = ConvertToMilliseconds (rtVal);
- int lHour = (int)(llTotalMs / (1000*60*60));
- int lMinute = (llTotalMs / (1000*60)) % 60;
- int lSecond = (llTotalMs / 1000) % 60;
- int lMillisec = llTotalMs % 1000;
+ CString strTemp;
+ LONGLONG llTotalMs = ConvertToMilliseconds(rtVal);
+ int lHour = (int)(llTotalMs / (1000 * 60 * 60));
+ int lMinute = (llTotalMs / (1000 * 60)) % 60;
+ int lSecond = (llTotalMs / 1000) % 60;
+ int lMillisec = llTotalMs % 1000;
- strTemp.Format (_T("%02d:%02d:%02d,%03d"), lHour, lMinute, lSecond, lMillisec);
- return strTemp;
+ strTemp.Format(_T("%02d:%02d:%02d,%03d"), lHour, lMinute, lSecond, lMillisec);
+ return strTemp;
}
// hour, minute, second (round)
CString ReftimeToString2(const REFERENCE_TIME& rtVal)
{
- CString strTemp;
- LONGLONG seconds = (rtVal + 5000000) / 10000000;
- int lHour = (int)(seconds / 3600);
- int lMinute = (int)(seconds / 60 % 60);
- int lSecond = (int)(seconds % 60);
+ CString strTemp;
+ LONGLONG seconds = (rtVal + 5000000) / 10000000;
+ int lHour = (int)(seconds / 3600);
+ int lMinute = (int)(seconds / 60 % 60);
+ int lSecond = (int)(seconds % 60);
- strTemp.Format (_T("%02d:%02d:%02d"), lHour, lMinute, lSecond);
- return strTemp;
+ strTemp.Format(_T("%02d:%02d:%02d"), lHour, lMinute, lSecond);
+ return strTemp;
}
CString DVDtimeToString(const DVD_HMSF_TIMECODE& rtVal, bool bAlwaysShowHours)
{
- CString strTemp;
- if (rtVal.bHours > 0 || bAlwaysShowHours) {
- strTemp.Format(_T("%02d:%02d:%02d"), rtVal.bHours, rtVal.bMinutes, rtVal.bSeconds);
- } else {
- strTemp.Format(_T("%02d:%02d"), rtVal.bMinutes, rtVal.bSeconds);
- }
- return strTemp;
+ CString strTemp;
+ if (rtVal.bHours > 0 || bAlwaysShowHours) {
+ strTemp.Format(_T("%02d:%02d:%02d"), rtVal.bHours, rtVal.bMinutes, rtVal.bSeconds);
+ } else {
+ strTemp.Format(_T("%02d:%02d"), rtVal.bMinutes, rtVal.bSeconds);
+ }
+ return strTemp;
}
REFERENCE_TIME StringToReftime(LPCTSTR strVal)
{
- REFERENCE_TIME rt = 0;
- int lHour = 0;
- int lMinute = 0;
- int lSecond = 0;
- int lMillisec = 0;
+ REFERENCE_TIME rt = 0;
+ int lHour = 0;
+ int lMinute = 0;
+ int lSecond = 0;
+ int lMillisec = 0;
- if (_stscanf_s (strVal, _T("%02d:%02d:%02d,%03d"), &lHour, &lMinute, &lSecond, &lMillisec) == 4) {
- rt = ( (((lHour*24)+lMinute)*60 + lSecond) * MILLISECONDS + lMillisec ) * (UNITS/MILLISECONDS);
- }
+ if (_stscanf_s(strVal, _T("%02d:%02d:%02d,%03d"), &lHour, &lMinute, &lSecond, &lMillisec) == 4) {
+ rt = ((((lHour * 24) + lMinute) * 60 + lSecond) * MILLISECONDS + lMillisec) * (UNITS / MILLISECONDS);
+ }
- return rt;
+ return rt;
}
const double Rec601_Kr = 0.299;
@@ -2634,21 +2617,21 @@ const double Rec601_Kg = 0.587;
COLORREF YCrCbToRGB_Rec601(BYTE Y, BYTE Cr, BYTE Cb)
{
- double rp = Y + 2*(Cr-128)*(1.0-Rec601_Kr);
- double gp = Y - 2*(Cb-128)*(1.0-Rec601_Kb)*Rec601_Kb/Rec601_Kg - 2*(Cr-128)*(1.0-Rec601_Kr)*Rec601_Kr/Rec601_Kg;
- double bp = Y + 2*(Cb-128)*(1.0-Rec601_Kb);
+ double rp = Y + 2 * (Cr - 128) * (1.0 - Rec601_Kr);
+ double gp = Y - 2 * (Cb - 128) * (1.0 - Rec601_Kb) * Rec601_Kb / Rec601_Kg - 2 * (Cr - 128) * (1.0 - Rec601_Kr) * Rec601_Kr / Rec601_Kg;
+ double bp = Y + 2 * (Cb - 128) * (1.0 - Rec601_Kb);
- return RGB (fabs(rp), fabs(gp), fabs(bp));
+ return RGB(fabs(rp), fabs(gp), fabs(bp));
}
DWORD YCrCbToRGB_Rec601(BYTE A, BYTE Y, BYTE Cr, BYTE Cb)
{
- double rp = Y + 2*(Cr-128)*(1.0-Rec601_Kr);
- double gp = Y - 2*(Cb-128)*(1.0-Rec601_Kb)*Rec601_Kb/Rec601_Kg - 2*(Cr-128)*(1.0-Rec601_Kr)*Rec601_Kr/Rec601_Kg;
- double bp = Y + 2*(Cb-128)*(1.0-Rec601_Kb);
+ double rp = Y + 2 * (Cr - 128) * (1.0 - Rec601_Kr);
+ double gp = Y - 2 * (Cb - 128) * (1.0 - Rec601_Kb) * Rec601_Kb / Rec601_Kg - 2 * (Cr - 128) * (1.0 - Rec601_Kr) * Rec601_Kr / Rec601_Kg;
+ double bp = Y + 2 * (Cb - 128) * (1.0 - Rec601_Kb);
- return D3DCOLOR_ARGB(A, (BYTE)fabs(rp), (BYTE)fabs(gp), (BYTE)fabs(bp));
+ return D3DCOLOR_ARGB(A, (BYTE)fabs(rp), (BYTE)fabs(gp), (BYTE)fabs(bp));
}
@@ -2659,319 +2642,326 @@ const double Rec709_Kg = 0.7154;
COLORREF YCrCbToRGB_Rec709(BYTE Y, BYTE Cr, BYTE Cb)
{
- double rp = Y + 2*(Cr-128)*(1.0-Rec709_Kr);
- double gp = Y - 2*(Cb-128)*(1.0-Rec709_Kb)*Rec709_Kb/Rec709_Kg - 2*(Cr-128)*(1.0-Rec709_Kr)*Rec709_Kr/Rec709_Kg;
- double bp = Y + 2*(Cb-128)*(1.0-Rec709_Kb);
+ double rp = Y + 2 * (Cr - 128) * (1.0 - Rec709_Kr);
+ double gp = Y - 2 * (Cb - 128) * (1.0 - Rec709_Kb) * Rec709_Kb / Rec709_Kg - 2 * (Cr - 128) * (1.0 - Rec709_Kr) * Rec709_Kr / Rec709_Kg;
+ double bp = Y + 2 * (Cb - 128) * (1.0 - Rec709_Kb);
- return RGB (fabs(rp), fabs(gp), fabs(bp));
+ return RGB(fabs(rp), fabs(gp), fabs(bp));
}
DWORD YCrCbToRGB_Rec709(BYTE A, BYTE Y, BYTE Cr, BYTE Cb)
{
- double rp = Y + 2*(Cr-128)*(1.0-Rec709_Kr);
- double gp = Y - 2*(Cb-128)*(1.0-Rec709_Kb)*Rec709_Kb/Rec709_Kg - 2*(Cr-128)*(1.0-Rec709_Kr)*Rec709_Kr/Rec709_Kg;
- double bp = Y + 2*(Cb-128)*(1.0-Rec709_Kb);
+ double rp = Y + 2 * (Cr - 128) * (1.0 - Rec709_Kr);
+ double gp = Y - 2 * (Cb - 128) * (1.0 - Rec709_Kb) * Rec709_Kb / Rec709_Kg - 2 * (Cr - 128) * (1.0 - Rec709_Kr) * Rec709_Kr / Rec709_Kg;
+ double bp = Y + 2 * (Cb - 128) * (1.0 - Rec709_Kb);
- return D3DCOLOR_ARGB (A, (BYTE)fabs(rp), (BYTE)fabs(gp), (BYTE)fabs(bp));
+ return D3DCOLOR_ARGB(A, (BYTE)fabs(rp), (BYTE)fabs(gp), (BYTE)fabs(bp));
}
void TraceFilterInfo(IBaseFilter* pBF)
{
- FILTER_INFO Info;
- if (SUCCEEDED (pBF->QueryFilterInfo(&Info))) {
- TRACE (" === Filter info : %S\n", Info.achName);
- BeginEnumPins(pBF, pEnum, pPin) {
- TracePinInfo(pPin);
- }
+ FILTER_INFO Info;
+ if (SUCCEEDED(pBF->QueryFilterInfo(&Info))) {
+ TRACE(" === Filter info : %S\n", Info.achName);
+ BeginEnumPins(pBF, pEnum, pPin) {
+ TracePinInfo(pPin);
+ }
- EndEnumPins
- Info.pGraph->Release();
- }
+ EndEnumPins
+ Info.pGraph->Release();
+ }
}
void TracePinInfo(IPin* pPin)
{
- PIN_INFO PinInfo;
- FILTER_INFO ConnectedFilterInfo;
- PIN_INFO ConnectedInfo;
- CComPtr<IPin> pConnected;
- memset (&ConnectedInfo, 0, sizeof(ConnectedInfo));
- memset (&ConnectedFilterInfo, 0, sizeof(ConnectedFilterInfo));
- if (SUCCEEDED (pPin->ConnectedTo (&pConnected))) {
- pConnected->QueryPinInfo (&ConnectedInfo);
- ConnectedInfo.pFilter->QueryFilterInfo(&ConnectedFilterInfo);
- ConnectedInfo.pFilter->Release();
- ConnectedFilterInfo.pGraph->Release();
- }
- pPin->QueryPinInfo (&PinInfo);
- TRACE(" %S (%S) -> %S (Filter %S)\n",
- PinInfo.achName,
- PinInfo.dir == PINDIR_OUTPUT ? _T("Out") : _T("In"),
- ConnectedInfo.achName,
- ConnectedFilterInfo.achName);
- PinInfo.pFilter->Release();
-}
-
-const wchar_t *StreamTypeToName(PES_STREAM_TYPE _Type)
-{
- switch (_Type) {
- case VIDEO_STREAM_MPEG1:
- return L"MPEG-1";
- case VIDEO_STREAM_MPEG2:
- return L"MPEG-2";
- case AUDIO_STREAM_MPEG1:
- return L"MPEG-1";
- case AUDIO_STREAM_MPEG2:
- return L"MPEG-2";
- case VIDEO_STREAM_H264:
- return L"H264";
- case AUDIO_STREAM_LPCM:
- return L"LPCM";
- case AUDIO_STREAM_AC3:
- return L"Dolby Digital";
- case AUDIO_STREAM_DTS:
- return L"DTS";
- case AUDIO_STREAM_AC3_TRUE_HD:
- return L"Dolby TrueHD";
- case AUDIO_STREAM_AC3_PLUS:
- return L"Dolby Digital Plus";
- case AUDIO_STREAM_DTS_HD:
- return L"DTS-HD High Resolution Audio";
- case AUDIO_STREAM_DTS_HD_MASTER_AUDIO:
- return L"DTS-HD Master Audio";
- case PRESENTATION_GRAPHICS_STREAM:
- return L"Presentation Graphics Stream";
- case INTERACTIVE_GRAPHICS_STREAM:
- return L"Interactive Graphics Stream";
- case SUBTITLE_STREAM:
- return L"Subtitle";
- case SECONDARY_AUDIO_AC3_PLUS:
- return L"Secondary Dolby Digital Plus";
- case SECONDARY_AUDIO_DTS_HD:
- return L"Secondary DTS-HD High Resolution Audio";
- case VIDEO_STREAM_VC1:
- return L"VC-1";
- }
- return NULL;
+ PIN_INFO PinInfo;
+ FILTER_INFO ConnectedFilterInfo;
+ PIN_INFO ConnectedInfo;
+ CComPtr<IPin> pConnected;
+ memset(&ConnectedInfo, 0, sizeof(ConnectedInfo));
+ memset(&ConnectedFilterInfo, 0, sizeof(ConnectedFilterInfo));
+ if (SUCCEEDED(pPin->ConnectedTo(&pConnected))) {
+ pConnected->QueryPinInfo(&ConnectedInfo);
+ ConnectedInfo.pFilter->QueryFilterInfo(&ConnectedFilterInfo);
+ ConnectedInfo.pFilter->Release();
+ ConnectedFilterInfo.pGraph->Release();
+ }
+ pPin->QueryPinInfo(&PinInfo);
+ TRACE(" %S (%S) -> %S (Filter %S)\n",
+ PinInfo.achName,
+ PinInfo.dir == PINDIR_OUTPUT ? _T("Out") : _T("In"),
+ ConnectedInfo.achName,
+ ConnectedFilterInfo.achName);
+ PinInfo.pFilter->Release();
+}
+
+const wchar_t* StreamTypeToName(PES_STREAM_TYPE _Type)
+{
+ switch (_Type) {
+ case VIDEO_STREAM_MPEG1:
+ return L"MPEG-1";
+ case VIDEO_STREAM_MPEG2:
+ return L"MPEG-2";
+ case AUDIO_STREAM_MPEG1:
+ return L"MPEG-1";
+ case AUDIO_STREAM_MPEG2:
+ return L"MPEG-2";
+ case VIDEO_STREAM_H264:
+ return L"H264";
+ case AUDIO_STREAM_LPCM:
+ return L"LPCM";
+ case AUDIO_STREAM_AC3:
+ return L"Dolby Digital";
+ case AUDIO_STREAM_DTS:
+ return L"DTS";
+ case AUDIO_STREAM_AC3_TRUE_HD:
+ return L"Dolby TrueHD";
+ case AUDIO_STREAM_AC3_PLUS:
+ return L"Dolby Digital Plus";
+ case AUDIO_STREAM_DTS_HD:
+ return L"DTS-HD High Resolution Audio";
+ case AUDIO_STREAM_DTS_HD_MASTER_AUDIO:
+ return L"DTS-HD Master Audio";
+ case PRESENTATION_GRAPHICS_STREAM:
+ return L"Presentation Graphics Stream";
+ case INTERACTIVE_GRAPHICS_STREAM:
+ return L"Interactive Graphics Stream";
+ case SUBTITLE_STREAM:
+ return L"Subtitle";
+ case SECONDARY_AUDIO_AC3_PLUS:
+ return L"Secondary Dolby Digital Plus";
+ case SECONDARY_AUDIO_DTS_HD:
+ return L"Secondary DTS-HD High Resolution Audio";
+ case VIDEO_STREAM_VC1:
+ return L"VC-1";
+ }
+ return NULL;
}
//
// Usage: SetThreadName (-1, "MainThread");
//
typedef struct tagTHREADNAME_INFO {
- DWORD dwType; // must be 0x1000
- LPCSTR szName; // pointer to name (in user addr space)
- DWORD dwThreadID; // thread ID (-1 caller thread)
- DWORD dwFlags; // reserved for future use, must be zero
+ DWORD dwType; // must be 0x1000
+ LPCSTR szName; // pointer to name (in user addr space)
+ DWORD dwThreadID; // thread ID (-1 caller thread)
+ DWORD dwFlags; // reserved for future use, must be zero
} THREADNAME_INFO;
void SetThreadName(DWORD dwThreadID, LPCSTR szThreadName)
{
- THREADNAME_INFO info;
- info.dwType = 0x1000;
- info.szName = szThreadName;
- info.dwThreadID = dwThreadID;
- info.dwFlags = 0;
+ THREADNAME_INFO info;
+ info.dwType = 0x1000;
+ info.szName = szThreadName;
+ info.dwThreadID = dwThreadID;
+ info.dwFlags = 0;
- __try {
- RaiseException(0x406D1388, 0, sizeof(info)/sizeof(DWORD), (ULONG_PTR*)&info);
- }
- __except (EXCEPTION_CONTINUE_EXECUTION) {
- }
+ __try {
+ RaiseException(0x406D1388, 0, sizeof(info) / sizeof(DWORD), (ULONG_PTR*)&info);
+ } __except (EXCEPTION_CONTINUE_EXECUTION) {
+ }
}
void HexDump(CString fileName, BYTE* buf, int size)
{
- if (size<=0) {
- return;
- }
-
- CString dump_str;
- dump_str.Format(_T("Dump size = %d\n"), size);
- int len, i, j, c;
-
- for (i=0; i<size; i+=16) {
- len = size - i;
- if (len > 16) {
- len = 16;
- }
- dump_str.AppendFormat(_T("%08x "), i);
- for (j=0; j<16; j++) {
- if (j < len) {
- dump_str.AppendFormat(_T(" %02x"), buf[i+j]);
- }
- else {
- dump_str.Append(_T(" "));
- }
- }
- dump_str.Append(_T(" "));
- for (j=0; j<len; j++) {
- c = buf[i+j];
- if (c < ' ' || c > '~') {
- c = '.';
- }
- dump_str.AppendFormat(_T("%c"), c);
- }
- dump_str.Append(_T("\n"));
- }
- dump_str.Append(_T("\n"));
-
- if (!fileName.IsEmpty()) {
- CStdioFile file;
- if (file.Open(fileName, CFile::modeCreate|CFile::modeWrite)) {
- file.WriteString(dump_str);
- file.Close();
- }
- }
- else {
- TRACE(dump_str);
- }
+ if (size <= 0) {
+ return;
+ }
+
+ CString dump_str;
+ dump_str.Format(_T("Dump size = %d\n"), size);
+ int len, i, j, c;
+
+ for (i = 0; i < size; i += 16) {
+ len = size - i;
+ if (len > 16) {
+ len = 16;
+ }
+ dump_str.AppendFormat(_T("%08x "), i);
+ for (j = 0; j < 16; j++) {
+ if (j < len) {
+ dump_str.AppendFormat(_T(" %02x"), buf[i + j]);
+ } else {
+ dump_str.Append(_T(" "));
+ }
+ }
+ dump_str.Append(_T(" "));
+ for (j = 0; j < len; j++) {
+ c = buf[i + j];
+ if (c < ' ' || c > '~') {
+ c = '.';
+ }
+ dump_str.AppendFormat(_T("%c"), c);
+ }
+ dump_str.Append(_T("\n"));
+ }
+ dump_str.Append(_T("\n"));
+
+ if (!fileName.IsEmpty()) {
+ CStdioFile file;
+ if (file.Open(fileName, CFile::modeCreate | CFile::modeWrite)) {
+ file.WriteString(dump_str);
+ file.Close();
+ }
+ } else {
+ TRACE(dump_str);
+ }
}
void CorrectComboListWidth(CComboBox& m_pComboBox)
{
- // Find the longest string in the combo box.
- if (m_pComboBox.GetCount() <=0 )
- return;
-
- CString str;
- CSize sz;
- int dx = 0;
- TEXTMETRIC tm;
- CDC* pDC = m_pComboBox.GetDC();
- CFont* pFont = m_pComboBox.GetFont();
-
- // Select the listbox font, save the old font
- CFont* pOldFont = pDC->SelectObject(pFont);
- // Get the text metrics for avg char width
- pDC->GetTextMetrics(&tm);
-
- for (int i = 0; i < m_pComboBox.GetCount(); i++)
- {
- m_pComboBox.GetLBText(i, str);
- sz = pDC->GetTextExtent(str);
-
- // Add the avg width to prevent clipping
- sz.cx += tm.tmAveCharWidth;
-
- if (sz.cx > dx)
- dx = sz.cx;
- }
- // Select the old font back into the DC
- pDC->SelectObject(pOldFont);
- m_pComboBox.ReleaseDC(pDC);
-
- // Get the scrollbar width if it exists
- int min_visible = m_pComboBox.GetMinVisible();
- int scroll_width = (m_pComboBox.GetCount() > min_visible) ?
- ::GetSystemMetrics(SM_CXVSCROLL) : 0;
-
- // Adjust the width for the vertical scroll bar and the left and right border.
- dx += scroll_width + 2*::GetSystemMetrics(SM_CXEDGE);
-
- // Set the width of the list box so that every item is completely visible.
- m_pComboBox.SetDroppedWidth(dx);
-}
-
-unsigned int lav_xiphlacing(unsigned char *s, unsigned int v)
-{
- unsigned int n = 0;
-
- while (v >= 0xff) {
- *s++ = 0xff;
- v -= 0xff;
- n++;
- }
- *s = v;
- n++;
- return n;
-}
-
-void getExtraData(const BYTE *format, const GUID *formattype, const size_t formatlen, BYTE *extra, unsigned int *extralen)
-{
- // code from LAV ...
- const BYTE *extraposition = NULL;
- size_t extralength = 0;
- if (*formattype == FORMAT_WaveFormatEx) {
- //WAVEFORMATEX *wfex = (WAVEFORMATEX *)format;
- extraposition = format + sizeof(WAVEFORMATEX);
- // Protected against over-reads
- extralength = formatlen - sizeof(WAVEFORMATEX);
- } else if (*formattype == FORMAT_VorbisFormat2) {
- VORBISFORMAT2 *vf2 = (VORBISFORMAT2 *)format;
- unsigned offset = 1;
- if (extra) {
- *extra = 2;
- offset += lav_xiphlacing(extra+offset, vf2->HeaderSize[0]);
- offset += lav_xiphlacing(extra+offset, vf2->HeaderSize[1]);
- extra += offset;
- } else {
- BYTE dummy[100];
- offset += lav_xiphlacing(dummy, vf2->HeaderSize[0]);
- offset += lav_xiphlacing(dummy, vf2->HeaderSize[1]);
- }
- extralength = vf2->HeaderSize[0] + vf2->HeaderSize[1] + vf2->HeaderSize[2];
- extralength = min(extralength, formatlen - sizeof(VORBISFORMAT2));
-
- if (extra && extralength)
- memcpy(extra, format + sizeof(VORBISFORMAT2), extralength);
- if (extralen)
- *extralen = (unsigned int)extralength + offset;
-
- return;
- } else if (*formattype == FORMAT_VideoInfo) {
- extraposition = format + sizeof(VIDEOINFOHEADER);
- extralength = formatlen - sizeof(VIDEOINFOHEADER);
- } else if (*formattype == FORMAT_VideoInfo2) {
- extraposition = format + sizeof(VIDEOINFOHEADER2);
- extralength = formatlen - sizeof(VIDEOINFOHEADER2);
- } else if (*formattype == FORMAT_MPEGVideo) {
- MPEG1VIDEOINFO *mp1vi = (MPEG1VIDEOINFO *)format;
- extraposition = (BYTE *)mp1vi->bSequenceHeader;
- extralength = min(mp1vi->cbSequenceHeader, formatlen - FIELD_OFFSET(MPEG1VIDEOINFO, bSequenceHeader[0]));
- } else if (*formattype == FORMAT_MPEG2Video) {
- MPEG2VIDEOINFO *mp2vi = (MPEG2VIDEOINFO *)format;
- extraposition = (BYTE *)mp2vi->dwSequenceHeader;
- extralength = min(mp2vi->cbSequenceHeader, formatlen - FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader[0]));
- }
-
- if (extra && extralength)
- memcpy(extra, extraposition, extralength);
- if (extralen)
- *extralen = (unsigned int)extralength;
-}
-
-void audioFormatTypeHandler(const BYTE *format, const GUID *formattype, DWORD *pnSamples, WORD *pnChannels, WORD *pnBitsPerSample, WORD *pnBlockAlign, DWORD *pnBytesPerSec)
-{
- DWORD nSamples = 0;
- WORD nChannels = 0;
- WORD nBitsPerSample = 0;
- WORD nBlockAlign = 0;
- DWORD nBytesPerSec = 0;
-
- if (*formattype == FORMAT_WaveFormatEx) {
- WAVEFORMATEX *wfex = (WAVEFORMATEX *)format;
- nSamples = wfex->nSamplesPerSec;
- nChannels = wfex->nChannels;
- nBitsPerSample = wfex->wBitsPerSample;
- nBlockAlign = wfex->nBlockAlign;
- nBytesPerSec = wfex->nAvgBytesPerSec;
- } else if (*formattype == FORMAT_VorbisFormat2) {
- VORBISFORMAT2 *vf2 = (VORBISFORMAT2 *)format;
- nSamples = vf2->SamplesPerSec;
- nChannels = (WORD)vf2->Channels;
- nBitsPerSample = (WORD)vf2->BitsPerSample;
- }
-
- if (pnSamples)
- *pnSamples = nSamples;
- if (pnChannels)
- *pnChannels = nChannels;
- if (pnBitsPerSample)
- *pnBitsPerSample = nBitsPerSample;
- if (pnBlockAlign)
- *pnBlockAlign = nBlockAlign;
- if (pnBytesPerSec)
- *pnBytesPerSec = nBytesPerSec;
+ // Find the longest string in the combo box.
+ if (m_pComboBox.GetCount() <= 0) {
+ return;
+ }
+
+ CString str;
+ CSize sz;
+ int dx = 0;
+ TEXTMETRIC tm;
+ CDC* pDC = m_pComboBox.GetDC();
+ CFont* pFont = m_pComboBox.GetFont();
+
+ // Select the listbox font, save the old font
+ CFont* pOldFont = pDC->SelectObject(pFont);
+ // Get the text metrics for avg char width
+ pDC->GetTextMetrics(&tm);
+
+ for (int i = 0; i < m_pComboBox.GetCount(); i++) {
+ m_pComboBox.GetLBText(i, str);
+ sz = pDC->GetTextExtent(str);
+
+ // Add the avg width to prevent clipping
+ sz.cx += tm.tmAveCharWidth;
+
+ if (sz.cx > dx) {
+ dx = sz.cx;
+ }
+ }
+ // Select the old font back into the DC
+ pDC->SelectObject(pOldFont);
+ m_pComboBox.ReleaseDC(pDC);
+
+ // Get the scrollbar width if it exists
+ int min_visible = m_pComboBox.GetMinVisible();
+ int scroll_width = (m_pComboBox.GetCount() > min_visible) ?
+ ::GetSystemMetrics(SM_CXVSCROLL) : 0;
+
+ // Adjust the width for the vertical scroll bar and the left and right border.
+ dx += scroll_width + 2 *::GetSystemMetrics(SM_CXEDGE);
+
+ // Set the width of the list box so that every item is completely visible.
+ m_pComboBox.SetDroppedWidth(dx);
+}
+
+unsigned int lav_xiphlacing(unsigned char* s, unsigned int v)
+{
+ unsigned int n = 0;
+
+ while (v >= 0xff) {
+ *s++ = 0xff;
+ v -= 0xff;
+ n++;
+ }
+ *s = v;
+ n++;
+ return n;
+}
+
+void getExtraData(const BYTE* format, const GUID* formattype, const size_t formatlen, BYTE* extra, unsigned int* extralen)
+{
+ // code from LAV ...
+ const BYTE* extraposition = NULL;
+ size_t extralength = 0;
+ if (*formattype == FORMAT_WaveFormatEx) {
+ //WAVEFORMATEX *wfex = (WAVEFORMATEX *)format;
+ extraposition = format + sizeof(WAVEFORMATEX);
+ // Protected against over-reads
+ extralength = formatlen - sizeof(WAVEFORMATEX);
+ } else if (*formattype == FORMAT_VorbisFormat2) {
+ VORBISFORMAT2* vf2 = (VORBISFORMAT2*)format;
+ unsigned offset = 1;
+ if (extra) {
+ *extra = 2;
+ offset += lav_xiphlacing(extra + offset, vf2->HeaderSize[0]);
+ offset += lav_xiphlacing(extra + offset, vf2->HeaderSize[1]);
+ extra += offset;
+ } else {
+ BYTE dummy[100];
+ offset += lav_xiphlacing(dummy, vf2->HeaderSize[0]);
+ offset += lav_xiphlacing(dummy, vf2->HeaderSize[1]);
+ }
+ extralength = vf2->HeaderSize[0] + vf2->HeaderSize[1] + vf2->HeaderSize[2];
+ extralength = min(extralength, formatlen - sizeof(VORBISFORMAT2));
+
+ if (extra && extralength) {
+ memcpy(extra, format + sizeof(VORBISFORMAT2), extralength);
+ }
+ if (extralen) {
+ *extralen = (unsigned int)extralength + offset;
+ }
+
+ return;
+ } else if (*formattype == FORMAT_VideoInfo) {
+ extraposition = format + sizeof(VIDEOINFOHEADER);
+ extralength = formatlen - sizeof(VIDEOINFOHEADER);
+ } else if (*formattype == FORMAT_VideoInfo2) {
+ extraposition = format + sizeof(VIDEOINFOHEADER2);
+ extralength = formatlen - sizeof(VIDEOINFOHEADER2);
+ } else if (*formattype == FORMAT_MPEGVideo) {
+ MPEG1VIDEOINFO* mp1vi = (MPEG1VIDEOINFO*)format;
+ extraposition = (BYTE*)mp1vi->bSequenceHeader;
+ extralength = min(mp1vi->cbSequenceHeader, formatlen - FIELD_OFFSET(MPEG1VIDEOINFO, bSequenceHeader[0]));
+ } else if (*formattype == FORMAT_MPEG2Video) {
+ MPEG2VIDEOINFO* mp2vi = (MPEG2VIDEOINFO*)format;
+ extraposition = (BYTE*)mp2vi->dwSequenceHeader;
+ extralength = min(mp2vi->cbSequenceHeader, formatlen - FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader[0]));
+ }
+
+ if (extra && extralength) {
+ memcpy(extra, extraposition, extralength);
+ }
+ if (extralen) {
+ *extralen = (unsigned int)extralength;
+ }
+}
+
+void audioFormatTypeHandler(const BYTE* format, const GUID* formattype, DWORD* pnSamples, WORD* pnChannels, WORD* pnBitsPerSample, WORD* pnBlockAlign, DWORD* pnBytesPerSec)
+{
+ DWORD nSamples = 0;
+ WORD nChannels = 0;
+ WORD nBitsPerSample = 0;
+ WORD nBlockAlign = 0;
+ DWORD nBytesPerSec = 0;
+
+ if (*formattype == FORMAT_WaveFormatEx) {
+ WAVEFORMATEX* wfex = (WAVEFORMATEX*)format;
+ nSamples = wfex->nSamplesPerSec;
+ nChannels = wfex->nChannels;
+ nBitsPerSample = wfex->wBitsPerSample;
+ nBlockAlign = wfex->nBlockAlign;
+ nBytesPerSec = wfex->nAvgBytesPerSec;
+ } else if (*formattype == FORMAT_VorbisFormat2) {
+ VORBISFORMAT2* vf2 = (VORBISFORMAT2*)format;
+ nSamples = vf2->SamplesPerSec;
+ nChannels = (WORD)vf2->Channels;
+ nBitsPerSample = (WORD)vf2->BitsPerSample;
+ }
+
+ if (pnSamples) {
+ *pnSamples = nSamples;
+ }
+ if (pnChannels) {
+ *pnChannels = nChannels;
+ }
+ if (pnBitsPerSample) {
+ *pnBitsPerSample = nBitsPerSample;
+ }
+ if (pnBlockAlign) {
+ *pnBlockAlign = nBlockAlign;
+ }
+ if (pnBytesPerSec) {
+ *pnBytesPerSec = nBytesPerSec;
+ }
}
diff --git a/src/DSUtil/DSUtil.h b/src/DSUtil/DSUtil.h
index 5a9caef3d..2b6dc26ea 100644
--- a/src/DSUtil/DSUtil.h
+++ b/src/DSUtil/DSUtil.h
@@ -116,40 +116,40 @@ extern LPCTSTR GetDXVAMode(const GUID* guidDecoder);
extern void DumpBuffer(BYTE* pBuffer, int nSize);
extern CString ReftimeToString(const REFERENCE_TIME& rtVal);
extern CString ReftimeToString2(const REFERENCE_TIME& rtVal);
-extern CString DVDtimeToString(const DVD_HMSF_TIMECODE& rtVal, bool bAlwaysShowHours=false);
+extern CString DVDtimeToString(const DVD_HMSF_TIMECODE& rtVal, bool bAlwaysShowHours = false);
extern REFERENCE_TIME StringToReftime(LPCTSTR strVal);
extern COLORREF YCrCbToRGB_Rec601(BYTE Y, BYTE Cr, BYTE Cb);
extern COLORREF YCrCbToRGB_Rec709(BYTE Y, BYTE Cr, BYTE Cb);
-extern DWORD YCrCbToRGB_Rec601(BYTE A, BYTE Y, BYTE Cr, BYTE Cb);
-extern DWORD YCrCbToRGB_Rec709(BYTE A, BYTE Y, BYTE Cr, BYTE Cb);
-extern void TraceFilterInfo(IBaseFilter* pBF);
-extern void TracePinInfo(IPin* pPin);
-extern void SetThreadName( DWORD dwThreadID, LPCSTR szThreadName);
-extern void HexDump(CString fName, BYTE* buf, int size);
-extern void CorrectComboListWidth(CComboBox& m_pComboBox);
+extern DWORD YCrCbToRGB_Rec601(BYTE A, BYTE Y, BYTE Cr, BYTE Cb);
+extern DWORD YCrCbToRGB_Rec709(BYTE A, BYTE Y, BYTE Cr, BYTE Cb);
+extern void TraceFilterInfo(IBaseFilter* pBF);
+extern void TracePinInfo(IPin* pPin);
+extern void SetThreadName(DWORD dwThreadID, LPCSTR szThreadName);
+extern void HexDump(CString fName, BYTE* buf, int size);
+extern void CorrectComboListWidth(CComboBox& m_pComboBox);
-extern void getExtraData(const BYTE *format, const GUID *formattype, const size_t formatlen, BYTE *extra, unsigned int *extralen);
-extern void audioFormatTypeHandler(const BYTE *format, const GUID *formattype, DWORD *pnSamples, WORD *pnChannels, WORD *pnBitsPerSample, WORD *pnBlockAlign, DWORD *pnBytesPerSec);
+extern void getExtraData(const BYTE* format, const GUID* formattype, const size_t formatlen, BYTE* extra, unsigned int* extralen);
+extern void audioFormatTypeHandler(const BYTE* format, const GUID* formattype, DWORD* pnSamples, WORD* pnChannels, WORD* pnBitsPerSample, WORD* pnBlockAlign, DWORD* pnBytesPerSec);
typedef enum {
- PICT_NONE,
- PICT_TOP_FIELD,
- PICT_BOTTOM_FIELD,
- PICT_FRAME
+ PICT_NONE,
+ PICT_TOP_FIELD,
+ PICT_BOTTOM_FIELD,
+ PICT_FRAME
} FF_FIELD_TYPE;
class CPinInfo : public PIN_INFO
{
public:
- CPinInfo() { pFilter = NULL; }
- ~CPinInfo() { if (pFilter) { pFilter->Release(); } }
+ CPinInfo() { pFilter = NULL; }
+ ~CPinInfo() { if (pFilter) { pFilter->Release(); } }
};
class CFilterInfo : public FILTER_INFO
{
public:
- CFilterInfo() { pGraph = NULL; }
- ~CFilterInfo() { if (pGraph) { pGraph->Release(); } }
+ CFilterInfo() { pGraph = NULL; }
+ ~CFilterInfo() { if (pGraph) { pGraph->Release(); } }
};
#define BeginEnumFilters(pFilterGraph, pEnumFilters, pBaseFilter) \
@@ -206,8 +206,8 @@ public:
template <typename T> __inline void INITDDSTRUCT(T& dd)
{
- ZeroMemory(&dd, sizeof(dd));
- dd.dwSize = sizeof(dd);
+ ZeroMemory(&dd, sizeof(dd));
+ dd.dwSize = sizeof(dd);
}
#ifndef _countof
@@ -217,12 +217,12 @@ template <typename T> __inline void INITDDSTRUCT(T& dd)
template <class T>
static CUnknown* WINAPI CreateInstance(LPUNKNOWN lpunk, HRESULT* phr)
{
- *phr = S_OK;
- CUnknown* punk = DNew T(lpunk, phr);
- if (punk == NULL) {
- *phr = E_OUTOFMEMORY;
- }
- return punk;
+ *phr = S_OK;
+ CUnknown* punk = DNew T(lpunk, phr);
+ if (punk == NULL) {
+ *phr = E_OUTOFMEMORY;
+ }
+ return punk;
}
#define SAFE_DELETE(p) { if (p) { delete (p); (p) = NULL; } }
@@ -231,15 +231,15 @@ static CUnknown* WINAPI CreateInstance(LPUNKNOWN lpunk, HRESULT* phr)
inline int LNKO(int a, int b)
{
- if (a == 0 || b == 0) {
- return 1;
- }
- while (a != b) {
- if (a < b) {
- b -= a;
- } else if (a > b) {
- a -= b;
- }
- }
- return a;
+ if (a == 0 || b == 0) {
+ return 1;
+ }
+ while (a != b) {
+ if (a < b) {
+ b -= a;
+ } else if (a > b) {
+ a -= b;
+ }
+ }
+ return a;
}
diff --git a/src/DSUtil/FontInstaller.cpp b/src/DSUtil/FontInstaller.cpp
index 64ad859b6..efbe25b23 100644
--- a/src/DSUtil/FontInstaller.cpp
+++ b/src/DSUtil/FontInstaller.cpp
@@ -26,93 +26,93 @@
CFontInstaller::CFontInstaller()
{
- if (HMODULE hGdi = GetModuleHandle(_T("gdi32.dll"))) {
- pAddFontMemResourceEx = (HANDLE (WINAPI *)(PVOID,DWORD,PVOID,DWORD*))GetProcAddress(hGdi, "AddFontMemResourceEx");
- pAddFontResourceEx = (int (WINAPI *)(LPCTSTR,DWORD,PVOID))GetProcAddress(hGdi, "AddFontResourceExW");
- pRemoveFontMemResourceEx = (BOOL (WINAPI *)(HANDLE))GetProcAddress(hGdi, "RemoveFontMemResourceEx");
- pRemoveFontResourceEx = (BOOL (WINAPI *)(LPCTSTR,DWORD,PVOID))GetProcAddress(hGdi, "RemoveFontResourceExW");
- }
-
- if (HMODULE hGdi = GetModuleHandle(_T("kernel32.dll"))) {
- pMoveFileEx = (BOOL (WINAPI *)(LPCTSTR, LPCTSTR, DWORD))GetProcAddress(hGdi, "MoveFileExW");
- }
+ if (HMODULE hGdi = GetModuleHandle(_T("gdi32.dll"))) {
+ pAddFontMemResourceEx = (HANDLE(WINAPI*)(PVOID, DWORD, PVOID, DWORD*))GetProcAddress(hGdi, "AddFontMemResourceEx");
+ pAddFontResourceEx = (int (WINAPI*)(LPCTSTR, DWORD, PVOID))GetProcAddress(hGdi, "AddFontResourceExW");
+ pRemoveFontMemResourceEx = (BOOL (WINAPI*)(HANDLE))GetProcAddress(hGdi, "RemoveFontMemResourceEx");
+ pRemoveFontResourceEx = (BOOL (WINAPI*)(LPCTSTR, DWORD, PVOID))GetProcAddress(hGdi, "RemoveFontResourceExW");
+ }
+
+ if (HMODULE hGdi = GetModuleHandle(_T("kernel32.dll"))) {
+ pMoveFileEx = (BOOL (WINAPI*)(LPCTSTR, LPCTSTR, DWORD))GetProcAddress(hGdi, "MoveFileExW");
+ }
}
CFontInstaller::~CFontInstaller()
{
- UninstallFonts();
+ UninstallFonts();
}
bool CFontInstaller::InstallFont(const CAtlArray<BYTE>& data)
{
- return InstallFont(data.GetData(), (UINT)data.GetCount());
+ return InstallFont(data.GetData(), (UINT)data.GetCount());
}
bool CFontInstaller::InstallFont(const void* pData, UINT len)
{
- return InstallFontFile(pData, len) || InstallFontMemory(pData, len);
+ return InstallFontFile(pData, len) || InstallFontMemory(pData, len);
}
void CFontInstaller::UninstallFonts()
{
- if (pRemoveFontMemResourceEx) {
- POSITION pos = m_fonts.GetHeadPosition();
- while (pos) {
- pRemoveFontMemResourceEx(m_fonts.GetNext(pos));
- }
- m_fonts.RemoveAll();
- }
-
- if (pRemoveFontResourceEx) {
- POSITION pos = m_files.GetHeadPosition();
- while (pos) {
- CString fn = m_files.GetNext(pos);
- pRemoveFontResourceEx(fn, FR_PRIVATE, 0);
- if (!DeleteFile(fn) && pMoveFileEx) {
- pMoveFileEx(fn, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
- }
- }
-
- m_files.RemoveAll();
- }
+ if (pRemoveFontMemResourceEx) {
+ POSITION pos = m_fonts.GetHeadPosition();
+ while (pos) {
+ pRemoveFontMemResourceEx(m_fonts.GetNext(pos));
+ }
+ m_fonts.RemoveAll();
+ }
+
+ if (pRemoveFontResourceEx) {
+ POSITION pos = m_files.GetHeadPosition();
+ while (pos) {
+ CString fn = m_files.GetNext(pos);
+ pRemoveFontResourceEx(fn, FR_PRIVATE, 0);
+ if (!DeleteFile(fn) && pMoveFileEx) {
+ pMoveFileEx(fn, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
+ }
+ }
+
+ m_files.RemoveAll();
+ }
}
bool CFontInstaller::InstallFontMemory(const void* pData, UINT len)
{
- if (!pAddFontMemResourceEx) {
- return false;
- }
-
- DWORD nFonts = 0;
- HANDLE hFont = pAddFontMemResourceEx((PVOID)pData, len, NULL, &nFonts);
- if (hFont && nFonts > 0) {
- m_fonts.AddTail(hFont);
- }
- return hFont && nFonts > 0;
+ if (!pAddFontMemResourceEx) {
+ return false;
+ }
+
+ DWORD nFonts = 0;
+ HANDLE hFont = pAddFontMemResourceEx((PVOID)pData, len, NULL, &nFonts);
+ if (hFont && nFonts > 0) {
+ m_fonts.AddTail(hFont);
+ }
+ return hFont && nFonts > 0;
}
bool CFontInstaller::InstallFontFile(const void* pData, UINT len)
{
- if (!pAddFontResourceEx) {
- return false;
- }
-
- CFile f;
- TCHAR path[_MAX_PATH], fn[_MAX_PATH];
- if (!GetTempPath(_MAX_PATH, path) || !GetTempFileName(path, _T("g_font"), 0, fn)) {
- return false;
- }
-
- if (f.Open(fn, CFile::modeWrite)) {
- f.Write(pData, len);
- f.Close();
-
- if (pAddFontResourceEx(fn, FR_PRIVATE, 0) > 0) {
- m_files.AddTail(fn);
- return true;
- }
- }
-
- DeleteFile(fn);
- return false;
+ if (!pAddFontResourceEx) {
+ return false;
+ }
+
+ CFile f;
+ TCHAR path[_MAX_PATH], fn[_MAX_PATH];
+ if (!GetTempPath(_MAX_PATH, path) || !GetTempFileName(path, _T("g_font"), 0, fn)) {
+ return false;
+ }
+
+ if (f.Open(fn, CFile::modeWrite)) {
+ f.Write(pData, len);
+ f.Close();
+
+ if (pAddFontResourceEx(fn, FR_PRIVATE, 0) > 0) {
+ m_files.AddTail(fn);
+ return true;
+ }
+ }
+
+ DeleteFile(fn);
+ return false;
}
diff --git a/src/DSUtil/FontInstaller.h b/src/DSUtil/FontInstaller.h
index 092317785..1114ed90a 100644
--- a/src/DSUtil/FontInstaller.h
+++ b/src/DSUtil/FontInstaller.h
@@ -27,22 +27,22 @@
class CFontInstaller
{
- HANDLE (WINAPI *pAddFontMemResourceEx)(PVOID,DWORD,PVOID,DWORD*);
- BOOL (WINAPI *pRemoveFontMemResourceEx)(HANDLE);
- int (WINAPI *pAddFontResourceEx)(LPCTSTR,DWORD,PVOID);
- BOOL (WINAPI *pRemoveFontResourceEx)(LPCTSTR,DWORD,PVOID);
- BOOL (WINAPI *pMoveFileEx)(LPCTSTR, LPCTSTR,DWORD);
+ HANDLE(WINAPI* pAddFontMemResourceEx)(PVOID, DWORD, PVOID, DWORD*);
+ BOOL (WINAPI* pRemoveFontMemResourceEx)(HANDLE);
+ int (WINAPI* pAddFontResourceEx)(LPCTSTR, DWORD, PVOID);
+ BOOL (WINAPI* pRemoveFontResourceEx)(LPCTSTR, DWORD, PVOID);
+ BOOL (WINAPI* pMoveFileEx)(LPCTSTR, LPCTSTR, DWORD);
- CAtlList<HANDLE> m_fonts;
- CAtlList<CString> m_files;
- bool InstallFontFile(const void* pData, UINT len);
+ CAtlList<HANDLE> m_fonts;
+ CAtlList<CString> m_files;
+ bool InstallFontFile(const void* pData, UINT len);
public:
- CFontInstaller();
- virtual ~CFontInstaller();
+ CFontInstaller();
+ virtual ~CFontInstaller();
- bool InstallFont(const CAtlArray<BYTE>& data);
- bool InstallFont(const void* pData, UINT len);
- bool InstallFontMemory(const void* pData, UINT len);
- void UninstallFonts();
+ bool InstallFont(const CAtlArray<BYTE>& data);
+ bool InstallFont(const void* pData, UINT len);
+ bool InstallFontMemory(const void* pData, UINT len);
+ void UninstallFonts();
};
diff --git a/src/DSUtil/GolombBuffer.cpp b/src/DSUtil/GolombBuffer.cpp
index 5eeb9ffb1..1edb0167b 100644
--- a/src/DSUtil/GolombBuffer.cpp
+++ b/src/DSUtil/GolombBuffer.cpp
@@ -25,92 +25,92 @@
CGolombBuffer::CGolombBuffer(BYTE* pBuffer, int nSize)
{
- m_pBuffer = pBuffer;
- m_nSize = nSize;
+ m_pBuffer = pBuffer;
+ m_nSize = nSize;
- Reset();
+ Reset();
}
UINT64 CGolombBuffer::BitRead(int nBits, bool fPeek)
{
- // ASSERT(nBits >= 0 && nBits <= 64);
+ // ASSERT(nBits >= 0 && nBits <= 64);
- while (m_bitlen < nBits) {
- m_bitbuff <<= 8;
+ while (m_bitlen < nBits) {
+ m_bitbuff <<= 8;
- if (m_nBitPos >= m_nSize) {
- return 0;
- }
+ if (m_nBitPos >= m_nSize) {
+ return 0;
+ }
- *(BYTE*)&m_bitbuff = m_pBuffer[m_nBitPos++];
- m_bitlen += 8;
- }
+ *(BYTE*)&m_bitbuff = m_pBuffer[m_nBitPos++];
+ m_bitlen += 8;
+ }
- int bitlen = m_bitlen - nBits;
+ int bitlen = m_bitlen - nBits;
- UINT64 ret = (m_bitbuff >> bitlen) & ((1ui64 << nBits) - 1);
+ UINT64 ret = (m_bitbuff >> bitlen) & ((1ui64 << nBits) - 1);
- if (!fPeek) {
- m_bitbuff &= ((1ui64 << bitlen) - 1);
- m_bitlen = bitlen;
- }
+ if (!fPeek) {
+ m_bitbuff &= ((1ui64 << bitlen) - 1);
+ m_bitlen = bitlen;
+ }
- return ret;
+ return ret;
}
UINT64 CGolombBuffer::UExpGolombRead()
{
- int n = -1;
- for (BYTE b = 0; !b; n++) {
- b = (BYTE)BitRead(1);
- }
- return (1ui64 << n) - 1 + BitRead(n);
+ int n = -1;
+ for (BYTE b = 0; !b; n++) {
+ b = (BYTE)BitRead(1);
+ }
+ return (1ui64 << n) - 1 + BitRead(n);
}
INT64 CGolombBuffer::SExpGolombRead()
{
- UINT64 k = UExpGolombRead();
- return ((k&1) ? 1 : -1) * ((k + 1) >> 1);
+ UINT64 k = UExpGolombRead();
+ return ((k & 1) ? 1 : -1) * ((k + 1) >> 1);
}
void CGolombBuffer::BitByteAlign()
{
- m_bitlen &= ~7;
+ m_bitlen &= ~7;
}
int CGolombBuffer::GetPos()
{
- return m_nBitPos - (m_bitlen>>3);
+ return m_nBitPos - (m_bitlen >> 3);
}
void CGolombBuffer::ReadBuffer(BYTE* pDest, int nSize)
{
- ASSERT (m_nBitPos + nSize <= m_nSize);
- ASSERT (m_bitlen == 0);
- nSize = min (nSize, m_nSize - m_nBitPos);
+ ASSERT(m_nBitPos + nSize <= m_nSize);
+ ASSERT(m_bitlen == 0);
+ nSize = min(nSize, m_nSize - m_nBitPos);
- memcpy (pDest, m_pBuffer+m_nBitPos, nSize);
- m_nBitPos += nSize;
+ memcpy(pDest, m_pBuffer + m_nBitPos, nSize);
+ m_nBitPos += nSize;
}
void CGolombBuffer::Reset()
{
- m_nBitPos = 0;
- m_bitlen = 0;
- m_bitbuff = 0;
+ m_nBitPos = 0;
+ m_bitlen = 0;
+ m_bitbuff = 0;
}
void CGolombBuffer::Reset(BYTE* pNewBuffer, int nNewSize)
{
- m_pBuffer = pNewBuffer;
- m_nSize = nNewSize;
+ m_pBuffer = pNewBuffer;
+ m_nSize = nNewSize;
- Reset();
+ Reset();
}
void CGolombBuffer::SkipBytes(int nCount)
{
- m_nBitPos += nCount;
- m_bitlen = 0;
- m_bitbuff = 0;
+ m_nBitPos += nCount;
+ m_bitlen = 0;
+ m_bitbuff = 0;
}
diff --git a/src/DSUtil/GolombBuffer.h b/src/DSUtil/GolombBuffer.h
index c151fb1d2..655afb856 100644
--- a/src/DSUtil/GolombBuffer.h
+++ b/src/DSUtil/GolombBuffer.h
@@ -25,34 +25,34 @@
class CGolombBuffer
{
public:
- CGolombBuffer(BYTE* pBuffer, int nSize);
+ CGolombBuffer(BYTE* pBuffer, int nSize);
- UINT64 BitRead(int nBits, bool fPeek = false);
- UINT64 UExpGolombRead();
- INT64 SExpGolombRead();
- void BitByteAlign();
+ UINT64 BitRead(int nBits, bool fPeek = false);
+ UINT64 UExpGolombRead();
+ INT64 SExpGolombRead();
+ void BitByteAlign();
- inline BYTE ReadByte() { return (BYTE)BitRead (8); };
- inline SHORT ReadShort() { return (SHORT)BitRead (16); };
- inline DWORD ReadDword() { return (DWORD)BitRead (32); };
- void ReadBuffer(BYTE* pDest, int nSize);
+ inline BYTE ReadByte() { return (BYTE)BitRead(8); };
+ inline SHORT ReadShort() { return (SHORT)BitRead(16); };
+ inline DWORD ReadDword() { return (DWORD)BitRead(32); };
+ void ReadBuffer(BYTE* pDest, int nSize);
- void Reset();
- void Reset(BYTE* pNewBuffer, int nNewSize);
+ void Reset();
+ void Reset(BYTE* pNewBuffer, int nNewSize);
- void SetSize(int nValue) { m_nSize = nValue; };
- int GetSize() const { return m_nSize; };
- int RemainingSize() const { return m_nSize - m_nBitPos; };
- bool IsEOF() const { return m_nBitPos >= m_nSize; };
- int GetPos();
- BYTE* GetBufferPos() { return m_pBuffer + m_nBitPos; };
+ void SetSize(int nValue) { m_nSize = nValue; };
+ int GetSize() const { return m_nSize; };
+ int RemainingSize() const { return m_nSize - m_nBitPos; };
+ bool IsEOF() const { return m_nBitPos >= m_nSize; };
+ int GetPos();
+ BYTE* GetBufferPos() { return m_pBuffer + m_nBitPos; };
- void SkipBytes(int nCount);
+ void SkipBytes(int nCount);
private :
- BYTE* m_pBuffer;
- int m_nSize;
- int m_nBitPos;
- int m_bitlen;
- INT64 m_bitbuff;
+ BYTE* m_pBuffer;
+ int m_nSize;
+ int m_nBitPos;
+ int m_bitlen;
+ INT64 m_bitbuff;
};
diff --git a/src/DSUtil/H264Nalu.cpp b/src/DSUtil/H264Nalu.cpp
index 7f5015b57..8286ce9b8 100644
--- a/src/DSUtil/H264Nalu.cpp
+++ b/src/DSUtil/H264Nalu.cpp
@@ -25,79 +25,79 @@
void CH264Nalu::SetBuffer(BYTE* pBuffer, int nSize, int nNALSize)
{
- m_pBuffer = pBuffer;
- m_nSize = nSize;
- m_nNALSize = nNALSize;
- m_nCurPos = 0;
- m_nNextRTP = 0;
+ m_pBuffer = pBuffer;
+ m_nSize = nSize;
+ m_nNALSize = nNALSize;
+ m_nCurPos = 0;
+ m_nNextRTP = 0;
- m_nNALStartPos = 0;
- m_nNALDataPos = 0;
+ m_nNALStartPos = 0;
+ m_nNALDataPos = 0;
- if (!nNALSize && nSize) {
- MoveToNextAnnexBStartcode();
- }
+ if (!nNALSize && nSize) {
+ MoveToNextAnnexBStartcode();
+ }
}
bool CH264Nalu::MoveToNextAnnexBStartcode()
{
- int nBuffEnd = m_nSize - 4;
+ int nBuffEnd = m_nSize - 4;
- for (int i=m_nCurPos; i<nBuffEnd; i++) {
- if ((*((DWORD*)(m_pBuffer+i)) & 0x00FFFFFF) == 0x00010000) {
- // Find next AnnexB Nal
- m_nCurPos = i;
- return true;
- }
- }
+ for (int i = m_nCurPos; i < nBuffEnd; i++) {
+ if ((*((DWORD*)(m_pBuffer + i)) & 0x00FFFFFF) == 0x00010000) {
+ // Find next AnnexB Nal
+ m_nCurPos = i;
+ return true;
+ }
+ }
- m_nCurPos = m_nSize;
- return false;
+ m_nCurPos = m_nSize;
+ return false;
}
bool CH264Nalu::MoveToNextRTPStartcode()
{
- if (m_nNextRTP < m_nSize) {
- m_nCurPos = m_nNextRTP;
- return true;
- }
+ if (m_nNextRTP < m_nSize) {
+ m_nCurPos = m_nNextRTP;
+ return true;
+ }
- m_nCurPos = m_nSize;
- return false;
+ m_nCurPos = m_nSize;
+ return false;
}
bool CH264Nalu::ReadNext()
{
- if ((m_nCurPos >= m_nSize) || (m_nCurPos<0)) {
- return false;
- }
+ if ((m_nCurPos >= m_nSize) || (m_nCurPos < 0)) {
+ return false;
+ }
- if ((m_nNALSize != 0) && (m_nCurPos == m_nNextRTP)) {
- // RTP Nalu type : (XX XX) XX XX NAL..., with XX XX XX XX or XX XX equal to NAL size
- m_nNALStartPos = m_nCurPos;
- m_nNALDataPos = m_nCurPos + m_nNALSize;
- unsigned nTemp = 0;
- for (int i=0; i<m_nNALSize; i++) {
- nTemp = (nTemp << 8) + m_pBuffer[m_nCurPos++];
- }
- m_nNextRTP += nTemp + m_nNALSize;
- MoveToNextRTPStartcode();
- } else {
- // Remove trailing bits
- while (m_pBuffer[m_nCurPos]==0x00 && ((*((DWORD*)(m_pBuffer+m_nCurPos)) & 0x00FFFFFF) != 0x00010000)) {
- m_nCurPos++;
- }
+ if ((m_nNALSize != 0) && (m_nCurPos == m_nNextRTP)) {
+ // RTP Nalu type : (XX XX) XX XX NAL..., with XX XX XX XX or XX XX equal to NAL size
+ m_nNALStartPos = m_nCurPos;
+ m_nNALDataPos = m_nCurPos + m_nNALSize;
+ unsigned nTemp = 0;
+ for (int i = 0; i < m_nNALSize; i++) {
+ nTemp = (nTemp << 8) + m_pBuffer[m_nCurPos++];
+ }
+ m_nNextRTP += nTemp + m_nNALSize;
+ MoveToNextRTPStartcode();
+ } else {
+ // Remove trailing bits
+ while (m_pBuffer[m_nCurPos] == 0x00 && ((*((DWORD*)(m_pBuffer + m_nCurPos)) & 0x00FFFFFF) != 0x00010000)) {
+ m_nCurPos++;
+ }
- // AnnexB Nalu : 00 00 01 NAL...
- m_nNALStartPos = m_nCurPos;
- m_nCurPos += 3;
- m_nNALDataPos = m_nCurPos;
- MoveToNextAnnexBStartcode();
- }
+ // AnnexB Nalu : 00 00 01 NAL...
+ m_nNALStartPos = m_nCurPos;
+ m_nCurPos += 3;
+ m_nNALDataPos = m_nCurPos;
+ MoveToNextAnnexBStartcode();
+ }
- forbidden_bit = (m_pBuffer[m_nNALDataPos]>>7) & 1;
- nal_reference_idc = (m_pBuffer[m_nNALDataPos]>>5) & 3;
- nal_unit_type = (NALU_TYPE) (m_pBuffer[m_nNALDataPos] & 0x1f);
+ forbidden_bit = (m_pBuffer[m_nNALDataPos] >> 7) & 1;
+ nal_reference_idc = (m_pBuffer[m_nNALDataPos] >> 5) & 3;
+ nal_unit_type = (NALU_TYPE)(m_pBuffer[m_nNALDataPos] & 0x1f);
- return true;
+ return true;
}
diff --git a/src/DSUtil/H264Nalu.h b/src/DSUtil/H264Nalu.h
index d64f22dac..a00d12294 100644
--- a/src/DSUtil/H264Nalu.h
+++ b/src/DSUtil/H264Nalu.h
@@ -23,56 +23,56 @@
#pragma once
typedef enum {
- NALU_TYPE_SLICE = 1,
- NALU_TYPE_DPA = 2,
- NALU_TYPE_DPB = 3,
- NALU_TYPE_DPC = 4,
- NALU_TYPE_IDR = 5,
- NALU_TYPE_SEI = 6,
- NALU_TYPE_SPS = 7,
- NALU_TYPE_PPS = 8,
- NALU_TYPE_AUD = 9,
- NALU_TYPE_EOSEQ = 10,
- NALU_TYPE_EOSTREAM = 11,
- NALU_TYPE_FILL = 12
+ NALU_TYPE_SLICE = 1,
+ NALU_TYPE_DPA = 2,
+ NALU_TYPE_DPB = 3,
+ NALU_TYPE_DPC = 4,
+ NALU_TYPE_IDR = 5,
+ NALU_TYPE_SEI = 6,
+ NALU_TYPE_SPS = 7,
+ NALU_TYPE_PPS = 8,
+ NALU_TYPE_AUD = 9,
+ NALU_TYPE_EOSEQ = 10,
+ NALU_TYPE_EOSTREAM = 11,
+ NALU_TYPE_FILL = 12
} NALU_TYPE;
class CH264Nalu
{
private :
- int forbidden_bit; //! should be always FALSE
- int nal_reference_idc; //! NALU_PRIORITY_xxxx
- NALU_TYPE nal_unit_type; //! NALU_TYPE_xxxx
+ int forbidden_bit; //! should be always FALSE
+ int nal_reference_idc; //! NALU_PRIORITY_xxxx
+ NALU_TYPE nal_unit_type; //! NALU_TYPE_xxxx
- int m_nNALStartPos; //! NALU start (including startcode / size)
- int m_nNALDataPos; //! Useful part
+ int m_nNALStartPos; //! NALU start (including startcode / size)
+ int m_nNALDataPos; //! Useful part
- BYTE* m_pBuffer;
- int m_nCurPos;
- int m_nNextRTP;
- int m_nSize;
- int m_nNALSize;
+ BYTE* m_pBuffer;
+ int m_nCurPos;
+ int m_nNextRTP;
+ int m_nSize;
+ int m_nNALSize;
- bool MoveToNextAnnexBStartcode();
- bool MoveToNextRTPStartcode();
+ bool MoveToNextAnnexBStartcode();
+ bool MoveToNextRTPStartcode();
public :
- CH264Nalu() { SetBuffer(NULL, 0, 0); }
+ CH264Nalu() { SetBuffer(NULL, 0, 0); }
- NALU_TYPE GetType() const { return nal_unit_type; };
- bool IsRefFrame() const { return (nal_reference_idc != 0); };
+ NALU_TYPE GetType() const { return nal_unit_type; };
+ bool IsRefFrame() const { return (nal_reference_idc != 0); };
- int GetDataLength() const { return m_nCurPos - m_nNALDataPos; };
- BYTE* GetDataBuffer() { return m_pBuffer + m_nNALDataPos; };
- int GetRoundedDataLength() const {
- int nSize = m_nCurPos - m_nNALDataPos;
- return nSize + 128 - (nSize %128);
- }
+ int GetDataLength() const { return m_nCurPos - m_nNALDataPos; };
+ BYTE* GetDataBuffer() { return m_pBuffer + m_nNALDataPos; };
+ int GetRoundedDataLength() const {
+ int nSize = m_nCurPos - m_nNALDataPos;
+ return nSize + 128 - (nSize % 128);
+ }
- int GetLength() const { return m_nCurPos - m_nNALStartPos; };
- BYTE* GetNALBuffer() { return m_pBuffer + m_nNALStartPos; };
- bool IsEOF() const { return m_nCurPos >= m_nSize; };
+ int GetLength() const { return m_nCurPos - m_nNALStartPos; };
+ BYTE* GetNALBuffer() { return m_pBuffer + m_nNALStartPos; };
+ bool IsEOF() const { return m_nCurPos >= m_nSize; };
- void SetBuffer(BYTE* pBuffer, int nSize, int nNALSize);
- bool ReadNext();
+ void SetBuffer(BYTE* pBuffer, int nSize, int nNALSize);
+ bool ReadNext();
};
diff --git a/src/DSUtil/HdmvClipInfo.cpp b/src/DSUtil/HdmvClipInfo.cpp
index ecf95afc6..81ace7d83 100644
--- a/src/DSUtil/HdmvClipInfo.cpp
+++ b/src/DSUtil/HdmvClipInfo.cpp
@@ -28,443 +28,440 @@ extern LCID ISO6392ToLcid(LPCSTR code);
CHdmvClipInfo::CHdmvClipInfo(void)
{
- m_hFile = INVALID_HANDLE_VALUE;
- m_bIsHdmv = false;
+ m_hFile = INVALID_HANDLE_VALUE;
+ m_bIsHdmv = false;
}
CHdmvClipInfo::~CHdmvClipInfo()
{
- CloseFile(S_OK);
+ CloseFile(S_OK);
}
HRESULT CHdmvClipInfo::CloseFile(HRESULT hr)
{
- if (m_hFile != INVALID_HANDLE_VALUE) {
- CloseHandle(m_hFile);
- m_hFile = INVALID_HANDLE_VALUE;
- }
- return hr;
+ if (m_hFile != INVALID_HANDLE_VALUE) {
+ CloseHandle(m_hFile);
+ m_hFile = INVALID_HANDLE_VALUE;
+ }
+ return hr;
}
DWORD CHdmvClipInfo::ReadDword()
{
- return ReadByte()<<24 | ReadByte()<<16 | ReadByte()<<8 | ReadByte();
+ return ReadByte() << 24 | ReadByte() << 16 | ReadByte() << 8 | ReadByte();
}
SHORT CHdmvClipInfo::ReadShort()
{
- return ReadByte()<<8 | ReadByte();
+ return ReadByte() << 8 | ReadByte();
}
BYTE CHdmvClipInfo::ReadByte()
{
- BYTE bVal;
- DWORD dwRead;
- ReadFile (m_hFile, &bVal, sizeof(bVal), &dwRead, NULL);
+ BYTE bVal;
+ DWORD dwRead;
+ ReadFile(m_hFile, &bVal, sizeof(bVal), &dwRead, NULL);
- return bVal;
+ return bVal;
}
void CHdmvClipInfo::ReadBuffer(BYTE* pBuff, DWORD nLen)
{
- DWORD dwRead;
- ReadFile (m_hFile, pBuff, nLen, &dwRead, NULL);
+ DWORD dwRead;
+ ReadFile(m_hFile, pBuff, nLen, &dwRead, NULL);
}
HRESULT CHdmvClipInfo::ReadProgramInfo()
{
- BYTE number_of_program_sequences;
- BYTE number_of_streams_in_ps;
- LARGE_INTEGER Pos;
-
- m_Streams.RemoveAll();
- Pos.QuadPart = ProgramInfo_start_address;
- SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
-
- ReadDword(); //length
- ReadByte(); //reserved_for_word_align
- number_of_program_sequences = (BYTE)ReadByte();
- int iStream = 0;
- for (size_t i=0; i<number_of_program_sequences; i++) {
- ReadDword(); //SPN_program_sequence_start
- ReadShort(); //program_map_PID
- number_of_streams_in_ps = (BYTE)ReadByte(); //number_of_streams_in_ps
- ReadByte(); //reserved_for_future_use
-
- for (size_t stream_index=0; stream_index<number_of_streams_in_ps; stream_index++) {
- m_Streams.SetCount(iStream + 1);
- m_Streams[iStream].m_PID = ReadShort(); // stream_PID
-
- // == StreamCodingInfo
- Pos.QuadPart = 0;
- SetFilePointerEx(m_hFile, Pos, &Pos, FILE_CURRENT);
- Pos.QuadPart += ReadByte() + 1; // length
- m_Streams[iStream].m_Type = (PES_STREAM_TYPE)ReadByte();
-
- switch (m_Streams[iStream].m_Type) {
- case VIDEO_STREAM_MPEG1:
- case VIDEO_STREAM_MPEG2:
- case VIDEO_STREAM_H264:
- case VIDEO_STREAM_VC1: {
- uint8 Temp = ReadByte();
- BDVM_VideoFormat VideoFormat = (BDVM_VideoFormat)(Temp >> 4);
- BDVM_FrameRate FrameRate = (BDVM_FrameRate)(Temp & 0xf);
- Temp = ReadByte();
- BDVM_AspectRatio AspectRatio = (BDVM_AspectRatio)(Temp >> 4);
-
- m_Streams[iStream].m_VideoFormat = VideoFormat;
- m_Streams[iStream].m_FrameRate = FrameRate;
- m_Streams[iStream].m_AspectRatio = AspectRatio;
- }
- break;
- case AUDIO_STREAM_MPEG1:
- case AUDIO_STREAM_MPEG2:
- case AUDIO_STREAM_LPCM:
- case AUDIO_STREAM_AC3:
- case AUDIO_STREAM_DTS:
- case AUDIO_STREAM_AC3_TRUE_HD:
- case AUDIO_STREAM_AC3_PLUS:
- case AUDIO_STREAM_DTS_HD:
- case AUDIO_STREAM_DTS_HD_MASTER_AUDIO:
- case SECONDARY_AUDIO_AC3_PLUS:
- case SECONDARY_AUDIO_DTS_HD: {
- uint8 Temp = ReadByte();
- BDVM_ChannelLayout ChannelLayout = (BDVM_ChannelLayout)(Temp >> 4);
- BDVM_SampleRate SampleRate = (BDVM_SampleRate)(Temp & 0xF);
-
- ReadBuffer((BYTE*)m_Streams[iStream].m_LanguageCode, 3);
- m_Streams[iStream].m_LCID = ISO6392ToLcid (m_Streams[iStream].m_LanguageCode);
- m_Streams[iStream].m_ChannelLayout = ChannelLayout;
- m_Streams[iStream].m_SampleRate = SampleRate;
- }
- break;
- case PRESENTATION_GRAPHICS_STREAM:
- case INTERACTIVE_GRAPHICS_STREAM: {
- ReadBuffer((BYTE*)m_Streams[iStream].m_LanguageCode, 3);
- m_Streams[iStream].m_LCID = ISO6392ToLcid (m_Streams[iStream].m_LanguageCode);
- }
- break;
- case SUBTITLE_STREAM: {
- ReadByte(); // Should this really be here?
- ReadBuffer((BYTE*)m_Streams[iStream].m_LanguageCode, 3);
- m_Streams[iStream].m_LCID = ISO6392ToLcid (m_Streams[iStream].m_LanguageCode);
- }
- break;
- default :
- break;
- }
-
- iStream++;
- SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
- }
- }
- return S_OK;
+ BYTE number_of_program_sequences;
+ BYTE number_of_streams_in_ps;
+ LARGE_INTEGER Pos;
+
+ m_Streams.RemoveAll();
+ Pos.QuadPart = ProgramInfo_start_address;
+ SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
+
+ ReadDword(); //length
+ ReadByte(); //reserved_for_word_align
+ number_of_program_sequences = (BYTE)ReadByte();
+ int iStream = 0;
+ for (size_t i = 0; i < number_of_program_sequences; i++) {
+ ReadDword(); //SPN_program_sequence_start
+ ReadShort(); //program_map_PID
+ number_of_streams_in_ps = (BYTE)ReadByte(); //number_of_streams_in_ps
+ ReadByte(); //reserved_for_future_use
+
+ for (size_t stream_index = 0; stream_index < number_of_streams_in_ps; stream_index++) {
+ m_Streams.SetCount(iStream + 1);
+ m_Streams[iStream].m_PID = ReadShort(); // stream_PID
+
+ // == StreamCodingInfo
+ Pos.QuadPart = 0;
+ SetFilePointerEx(m_hFile, Pos, &Pos, FILE_CURRENT);
+ Pos.QuadPart += ReadByte() + 1; // length
+ m_Streams[iStream].m_Type = (PES_STREAM_TYPE)ReadByte();
+
+ switch (m_Streams[iStream].m_Type) {
+ case VIDEO_STREAM_MPEG1:
+ case VIDEO_STREAM_MPEG2:
+ case VIDEO_STREAM_H264:
+ case VIDEO_STREAM_VC1: {
+ uint8 Temp = ReadByte();
+ BDVM_VideoFormat VideoFormat = (BDVM_VideoFormat)(Temp >> 4);
+ BDVM_FrameRate FrameRate = (BDVM_FrameRate)(Temp & 0xf);
+ Temp = ReadByte();
+ BDVM_AspectRatio AspectRatio = (BDVM_AspectRatio)(Temp >> 4);
+
+ m_Streams[iStream].m_VideoFormat = VideoFormat;
+ m_Streams[iStream].m_FrameRate = FrameRate;
+ m_Streams[iStream].m_AspectRatio = AspectRatio;
+ }
+ break;
+ case AUDIO_STREAM_MPEG1:
+ case AUDIO_STREAM_MPEG2:
+ case AUDIO_STREAM_LPCM:
+ case AUDIO_STREAM_AC3:
+ case AUDIO_STREAM_DTS:
+ case AUDIO_STREAM_AC3_TRUE_HD:
+ case AUDIO_STREAM_AC3_PLUS:
+ case AUDIO_STREAM_DTS_HD:
+ case AUDIO_STREAM_DTS_HD_MASTER_AUDIO:
+ case SECONDARY_AUDIO_AC3_PLUS:
+ case SECONDARY_AUDIO_DTS_HD: {
+ uint8 Temp = ReadByte();
+ BDVM_ChannelLayout ChannelLayout = (BDVM_ChannelLayout)(Temp >> 4);
+ BDVM_SampleRate SampleRate = (BDVM_SampleRate)(Temp & 0xF);
+
+ ReadBuffer((BYTE*)m_Streams[iStream].m_LanguageCode, 3);
+ m_Streams[iStream].m_LCID = ISO6392ToLcid(m_Streams[iStream].m_LanguageCode);
+ m_Streams[iStream].m_ChannelLayout = ChannelLayout;
+ m_Streams[iStream].m_SampleRate = SampleRate;
+ }
+ break;
+ case PRESENTATION_GRAPHICS_STREAM:
+ case INTERACTIVE_GRAPHICS_STREAM: {
+ ReadBuffer((BYTE*)m_Streams[iStream].m_LanguageCode, 3);
+ m_Streams[iStream].m_LCID = ISO6392ToLcid(m_Streams[iStream].m_LanguageCode);
+ }
+ break;
+ case SUBTITLE_STREAM: {
+ ReadByte(); // Should this really be here?
+ ReadBuffer((BYTE*)m_Streams[iStream].m_LanguageCode, 3);
+ m_Streams[iStream].m_LCID = ISO6392ToLcid(m_Streams[iStream].m_LanguageCode);
+ }
+ break;
+ default :
+ break;
+ }
+
+ iStream++;
+ SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
+ }
+ }
+ return S_OK;
}
HRESULT CHdmvClipInfo::ReadInfo(LPCTSTR strFile)
{
- BYTE Buff[100];
+ BYTE Buff[100];
- m_bIsHdmv = false;
- m_hFile = CreateFile(strFile, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_READONLY|FILE_FLAG_SEQUENTIAL_SCAN, NULL);
+ m_bIsHdmv = false;
+ m_hFile = CreateFile(strFile, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
+ OPEN_EXISTING, FILE_ATTRIBUTE_READONLY | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
- if (m_hFile != INVALID_HANDLE_VALUE) {
- ReadBuffer(Buff, 4);
- if (memcmp (Buff, "HDMV", 4)) {
- return CloseFile(VFW_E_INVALID_FILE_FORMAT);
- }
+ if (m_hFile != INVALID_HANDLE_VALUE) {
+ ReadBuffer(Buff, 4);
+ if (memcmp(Buff, "HDMV", 4)) {
+ return CloseFile(VFW_E_INVALID_FILE_FORMAT);
+ }
- ReadBuffer(Buff, 4);
- if ((memcmp (Buff, "0200", 4)!=0) && (memcmp (Buff, "0100", 4)!=0)) {
- return CloseFile (VFW_E_INVALID_FILE_FORMAT);
- }
+ ReadBuffer(Buff, 4);
+ if ((memcmp(Buff, "0200", 4) != 0) && (memcmp(Buff, "0100", 4) != 0)) {
+ return CloseFile(VFW_E_INVALID_FILE_FORMAT);
+ }
- SequenceInfo_start_address = ReadDword();
- ProgramInfo_start_address = ReadDword();
+ SequenceInfo_start_address = ReadDword();
+ ProgramInfo_start_address = ReadDword();
- ReadProgramInfo();
+ ReadProgramInfo();
- m_bIsHdmv = true;
+ m_bIsHdmv = true;
- return CloseFile(S_OK);
- }
+ return CloseFile(S_OK);
+ }
- return AmHresultFromWin32(GetLastError());
+ return AmHresultFromWin32(GetLastError());
}
CHdmvClipInfo::Stream* CHdmvClipInfo::FindStream(SHORT wPID)
{
- size_t nStreams = m_Streams.GetCount();
- for (size_t i=0; i<nStreams; i++) {
- if (m_Streams[i].m_PID == wPID) {
- return &m_Streams[i];
- }
- }
-
- return NULL;
+ size_t nStreams = m_Streams.GetCount();
+ for (size_t i = 0; i < nStreams; i++) {
+ if (m_Streams[i].m_PID == wPID) {
+ return &m_Streams[i];
+ }
+ }
+
+ return NULL;
}
LPCTSTR CHdmvClipInfo::Stream::Format()
{
- switch (m_Type) {
- case VIDEO_STREAM_MPEG1:
- return _T("Mpeg1");
- case VIDEO_STREAM_MPEG2:
- return _T("Mpeg2");
- case VIDEO_STREAM_H264:
- return _T("H264");
- case VIDEO_STREAM_VC1:
- return _T("VC1");
- case AUDIO_STREAM_MPEG1:
- return _T("MPEG1");
- case AUDIO_STREAM_MPEG2:
- return _T("MPEG2");
- case AUDIO_STREAM_LPCM:
- return _T("LPCM");
- case AUDIO_STREAM_AC3:
- return _T("AC3");
- case AUDIO_STREAM_DTS:
- return _T("DTS");
- case AUDIO_STREAM_AC3_TRUE_HD:
- return _T("MLP");
- case AUDIO_STREAM_AC3_PLUS:
- return _T("DD+");
- case AUDIO_STREAM_DTS_HD:
- return _T("DTS-HD");
- case AUDIO_STREAM_DTS_HD_MASTER_AUDIO:
- return _T("DTS-HD XLL");
- case SECONDARY_AUDIO_AC3_PLUS:
- return _T("Sec DD+");
- case SECONDARY_AUDIO_DTS_HD:
- return _T("Sec DTS-HD");
- case PRESENTATION_GRAPHICS_STREAM :
- return _T("PG");
- case INTERACTIVE_GRAPHICS_STREAM :
- return _T("IG");
- case SUBTITLE_STREAM :
- return _T("Text");
- default :
- return _T("Unknown");
- }
+ switch (m_Type) {
+ case VIDEO_STREAM_MPEG1:
+ return _T("Mpeg1");
+ case VIDEO_STREAM_MPEG2:
+ return _T("Mpeg2");
+ case VIDEO_STREAM_H264:
+ return _T("H264");
+ case VIDEO_STREAM_VC1:
+ return _T("VC1");
+ case AUDIO_STREAM_MPEG1:
+ return _T("MPEG1");
+ case AUDIO_STREAM_MPEG2:
+ return _T("MPEG2");
+ case AUDIO_STREAM_LPCM:
+ return _T("LPCM");
+ case AUDIO_STREAM_AC3:
+ return _T("AC3");
+ case AUDIO_STREAM_DTS:
+ return _T("DTS");
+ case AUDIO_STREAM_AC3_TRUE_HD:
+ return _T("MLP");
+ case AUDIO_STREAM_AC3_PLUS:
+ return _T("DD+");
+ case AUDIO_STREAM_DTS_HD:
+ return _T("DTS-HD");
+ case AUDIO_STREAM_DTS_HD_MASTER_AUDIO:
+ return _T("DTS-HD XLL");
+ case SECONDARY_AUDIO_AC3_PLUS:
+ return _T("Sec DD+");
+ case SECONDARY_AUDIO_DTS_HD:
+ return _T("Sec DTS-HD");
+ case PRESENTATION_GRAPHICS_STREAM :
+ return _T("PG");
+ case INTERACTIVE_GRAPHICS_STREAM :
+ return _T("IG");
+ case SUBTITLE_STREAM :
+ return _T("Text");
+ default :
+ return _T("Unknown");
+ }
}
HRESULT CHdmvClipInfo::ReadPlaylist(CString strPlaylistFile, REFERENCE_TIME& rtDuration, CAtlList<PlaylistItem>& Playlist)
{
- BYTE Buff[100];
- CPath Path (strPlaylistFile);
- bool bDuplicate = false;
- rtDuration = 0;
-
- // Get BDMV folder
- Path.RemoveFileSpec();
- Path.RemoveFileSpec();
-
- m_hFile = CreateFile(strPlaylistFile, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_READONLY|FILE_FLAG_SEQUENTIAL_SCAN, NULL);
-
- if (m_hFile != INVALID_HANDLE_VALUE) {
- ReadBuffer(Buff, 4);
- if (memcmp (Buff, "MPLS", 4)) {
- return CloseFile(VFW_E_INVALID_FILE_FORMAT);
- }
-
- ReadBuffer(Buff, 4);
- if ((memcmp (Buff, "0200", 4)!=0) && (memcmp (Buff, "0100", 4)!=0)) {
- return CloseFile(VFW_E_INVALID_FILE_FORMAT);
- }
-
- LARGE_INTEGER Pos;
- DWORD dwTemp;
- USHORT nPlaylistItems;
-
- Pos.QuadPart = ReadDword(); // PlayList_start_address
- ReadDword(); // PlayListMark_start_address
-
- // PlayList()
- SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
- ReadDword(); // length
- ReadShort(); // reserved_for_future_use
- nPlaylistItems = ReadShort(); // number_of_PlayItems
- ReadShort(); // number_of_SubPaths
-
- Pos.QuadPart += 10;
- for (size_t i=0; i<nPlaylistItems; i++) {
- PlaylistItem Item;
- SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
- Pos.QuadPart += ReadShort() + 2;
- ReadBuffer(Buff, 5);
- Item.m_strFileName.Format(_T("%s\\STREAM\\%c%c%c%c%c.M2TS"), Path, Buff[0], Buff[1], Buff[2], Buff[3], Buff[4]);
-
- ReadBuffer(Buff, 4);
- if (memcmp (Buff, "M2TS", 4)) {
- return CloseFile(VFW_E_INVALID_FILE_FORMAT);
- }
- ReadBuffer(Buff, 3);
-
- dwTemp = ReadDword();
- Item.m_rtIn = 20000i64*dwTemp/90; // Carefull : 32->33 bits!
-
- dwTemp = ReadDword();
- Item.m_rtOut = 20000i64*dwTemp/90; // Carefull : 32->33 bits!
-
- rtDuration += (Item.m_rtOut - Item.m_rtIn);
-
- if (Playlist.Find(Item) != NULL) {
- bDuplicate = true;
- }
- Playlist.AddTail (Item);
-
- //TRACE ("File : %S, Duration : %S, Total duration : %S\n", strTemp, ReftimeToString (rtOut - rtIn), ReftimeToString (rtDuration));
- }
-
- CloseFile (S_OK);
- return bDuplicate ? S_FALSE : S_OK;
- }
-
- return AmHresultFromWin32(GetLastError());
+ BYTE Buff[100];
+ CPath Path(strPlaylistFile);
+ bool bDuplicate = false;
+ rtDuration = 0;
+
+ // Get BDMV folder
+ Path.RemoveFileSpec();
+ Path.RemoveFileSpec();
+
+ m_hFile = CreateFile(strPlaylistFile, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
+ OPEN_EXISTING, FILE_ATTRIBUTE_READONLY | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
+
+ if (m_hFile != INVALID_HANDLE_VALUE) {
+ ReadBuffer(Buff, 4);
+ if (memcmp(Buff, "MPLS", 4)) {
+ return CloseFile(VFW_E_INVALID_FILE_FORMAT);
+ }
+
+ ReadBuffer(Buff, 4);
+ if ((memcmp(Buff, "0200", 4) != 0) && (memcmp(Buff, "0100", 4) != 0)) {
+ return CloseFile(VFW_E_INVALID_FILE_FORMAT);
+ }
+
+ LARGE_INTEGER Pos;
+ DWORD dwTemp;
+ USHORT nPlaylistItems;
+
+ Pos.QuadPart = ReadDword(); // PlayList_start_address
+ ReadDword(); // PlayListMark_start_address
+
+ // PlayList()
+ SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
+ ReadDword(); // length
+ ReadShort(); // reserved_for_future_use
+ nPlaylistItems = ReadShort(); // number_of_PlayItems
+ ReadShort(); // number_of_SubPaths
+
+ Pos.QuadPart += 10;
+ for (size_t i = 0; i < nPlaylistItems; i++) {
+ PlaylistItem Item;
+ SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
+ Pos.QuadPart += ReadShort() + 2;
+ ReadBuffer(Buff, 5);
+ Item.m_strFileName.Format(_T("%s\\STREAM\\%c%c%c%c%c.M2TS"), Path, Buff[0], Buff[1], Buff[2], Buff[3], Buff[4]);
+
+ ReadBuffer(Buff, 4);
+ if (memcmp(Buff, "M2TS", 4)) {
+ return CloseFile(VFW_E_INVALID_FILE_FORMAT);
+ }
+ ReadBuffer(Buff, 3);
+
+ dwTemp = ReadDword();
+ Item.m_rtIn = 20000i64 * dwTemp / 90; // Carefull : 32->33 bits!
+
+ dwTemp = ReadDword();
+ Item.m_rtOut = 20000i64 * dwTemp / 90; // Carefull : 32->33 bits!
+
+ rtDuration += (Item.m_rtOut - Item.m_rtIn);
+
+ if (Playlist.Find(Item) != NULL) {
+ bDuplicate = true;
+ }
+ Playlist.AddTail(Item);
+
+ //TRACE ("File : %S, Duration : %S, Total duration : %S\n", strTemp, ReftimeToString (rtOut - rtIn), ReftimeToString (rtDuration));
+ }
+
+ CloseFile(S_OK);
+ return bDuplicate ? S_FALSE : S_OK;
+ }
+
+ return AmHresultFromWin32(GetLastError());
}
HRESULT CHdmvClipInfo::ReadChapters(CString strPlaylistFile, CAtlList<CHdmvClipInfo::PlaylistItem>& PlaylistItems, CAtlList<PlaylistChapter>& Chapters)
{
- BYTE Buff[100];
- CPath Path (strPlaylistFile);
- bool bDuplicate = false;
-
- // Get BDMV folder
- Path.RemoveFileSpec();
- Path.RemoveFileSpec();
-
- m_hFile = CreateFile(strPlaylistFile, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_READONLY|FILE_FLAG_SEQUENTIAL_SCAN, NULL);
-
- if (m_hFile != INVALID_HANDLE_VALUE)
- {
- REFERENCE_TIME* rtOffset = new REFERENCE_TIME[PlaylistItems.GetCount()];
- REFERENCE_TIME rtSum = 0;
- int nIndex = 0;
-
- POSITION pos = PlaylistItems.GetHeadPosition();
- while (pos)
- {
- CHdmvClipInfo::PlaylistItem& PI = PlaylistItems.GetNext(pos);
-
- rtOffset[nIndex] = rtSum - PI.m_rtIn;
- rtSum = rtSum + PI.Duration();
- nIndex++;
- }
-
- ReadBuffer(Buff, 4);
- if (memcmp (Buff, "MPLS", 4)) {
- SAFE_DELETE_ARRAY(rtOffset);
- return CloseFile(VFW_E_INVALID_FILE_FORMAT);
- }
-
- ReadBuffer(Buff, 4);
- if ((memcmp (Buff, "0200", 4)!=0) && (memcmp (Buff, "0100", 4)!=0)) {
- SAFE_DELETE_ARRAY(rtOffset);
- return CloseFile(VFW_E_INVALID_FILE_FORMAT);
- }
-
- LARGE_INTEGER Pos;
- USHORT nMarkCount;
-
- ReadDword(); // PlayList_start_address
- Pos.QuadPart = ReadDword(); // PlayListMark_start_address
-
- // PlayListMark()
- SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
- ReadDword(); // length
- nMarkCount = ReadShort(); // number_of_PlayList_marks
- for (size_t i=0; i<nMarkCount; i++)
- {
- PlaylistChapter Chapter;
-
- ReadByte(); // reserved_for_future_use
- Chapter.m_nMarkType = (PlaylistMarkType)ReadByte(); // mark_type
- Chapter.m_nPlayItemId = ReadShort(); // ref_to_PlayItem_id
- Chapter.m_rtTimestamp = 20000i64*ReadDword()/90 + rtOffset[Chapter.m_nPlayItemId]; // mark_time_stamp
- Chapter.m_nEntryPID = ReadShort(); // entry_ES_PID
- Chapter.m_rtDuration = 20000i64*ReadDword()/90; // duration
-
- Chapters.AddTail (Chapter);
-
- // TRACE ("Chapter %d : %S\n", i, ReftimeToString (Chapter.m_rtTimestamp));
- }
-
- CloseFile (S_OK);
- SAFE_DELETE_ARRAY(rtOffset);
- return bDuplicate ? S_FALSE : S_OK;
- }
-
- return AmHresultFromWin32(GetLastError());
+ BYTE Buff[100];
+ CPath Path(strPlaylistFile);
+ bool bDuplicate = false;
+
+ // Get BDMV folder
+ Path.RemoveFileSpec();
+ Path.RemoveFileSpec();
+
+ m_hFile = CreateFile(strPlaylistFile, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
+ OPEN_EXISTING, FILE_ATTRIBUTE_READONLY | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
+
+ if (m_hFile != INVALID_HANDLE_VALUE) {
+ REFERENCE_TIME* rtOffset = new REFERENCE_TIME[PlaylistItems.GetCount()];
+ REFERENCE_TIME rtSum = 0;
+ int nIndex = 0;
+
+ POSITION pos = PlaylistItems.GetHeadPosition();
+ while (pos) {
+ CHdmvClipInfo::PlaylistItem& PI = PlaylistItems.GetNext(pos);
+
+ rtOffset[nIndex] = rtSum - PI.m_rtIn;
+ rtSum = rtSum + PI.Duration();
+ nIndex++;
+ }
+
+ ReadBuffer(Buff, 4);
+ if (memcmp(Buff, "MPLS", 4)) {
+ SAFE_DELETE_ARRAY(rtOffset);
+ return CloseFile(VFW_E_INVALID_FILE_FORMAT);
+ }
+
+ ReadBuffer(Buff, 4);
+ if ((memcmp(Buff, "0200", 4) != 0) && (memcmp(Buff, "0100", 4) != 0)) {
+ SAFE_DELETE_ARRAY(rtOffset);
+ return CloseFile(VFW_E_INVALID_FILE_FORMAT);
+ }
+
+ LARGE_INTEGER Pos;
+ USHORT nMarkCount;
+
+ ReadDword(); // PlayList_start_address
+ Pos.QuadPart = ReadDword(); // PlayListMark_start_address
+
+ // PlayListMark()
+ SetFilePointerEx(m_hFile, Pos, NULL, FILE_BEGIN);
+ ReadDword(); // length
+ nMarkCount = ReadShort(); // number_of_PlayList_marks
+ for (size_t i = 0; i < nMarkCount; i++) {
+ PlaylistChapter Chapter;
+
+ ReadByte(); // reserved_for_future_use
+ Chapter.m_nMarkType = (PlaylistMarkType)ReadByte(); // mark_type
+ Chapter.m_nPlayItemId = ReadShort(); // ref_to_PlayItem_id
+ Chapter.m_rtTimestamp = 20000i64 * ReadDword() / 90 + rtOffset[Chapter.m_nPlayItemId]; // mark_time_stamp
+ Chapter.m_nEntryPID = ReadShort(); // entry_ES_PID
+ Chapter.m_rtDuration = 20000i64 * ReadDword() / 90; // duration
+
+ Chapters.AddTail(Chapter);
+
+ // TRACE ("Chapter %d : %S\n", i, ReftimeToString (Chapter.m_rtTimestamp));
+ }
+
+ CloseFile(S_OK);
+ SAFE_DELETE_ARRAY(rtOffset);
+ return bDuplicate ? S_FALSE : S_OK;
+ }
+
+ return AmHresultFromWin32(GetLastError());
}
#define MIN_LIMIT 3
HRESULT CHdmvClipInfo::FindMainMovie(LPCTSTR strFolder, CString& strPlaylistFile, CAtlList<PlaylistItem>& MainPlaylist, CAtlList<PlaylistItem>& MPLSPlaylists)
{
- HRESULT hr = E_FAIL;
-
- CString strPath (strFolder);
- CString strFilter;
-
- MPLSPlaylists.RemoveAll();
-
- CAtlList<PlaylistItem> Playlist;
- WIN32_FIND_DATA fd = {0};
-
- strPath.Replace(_T("\\PLAYLIST\\"), _T("\\"));
- strPath.Replace(_T("\\STREAM\\"), _T("\\"));
- strPath += _T("\\BDMV\\");
- strFilter.Format (_T("%sPLAYLIST\\*.mpls"), strPath);
-
- HANDLE hFind = FindFirstFile(strFilter, &fd);
- if (hFind != INVALID_HANDLE_VALUE) {
- REFERENCE_TIME rtMax = 0;
- REFERENCE_TIME rtCurrent;
- CString strCurrentPlaylist;
- do {
- strCurrentPlaylist.Format(_T("%sPLAYLIST\\%s"), strPath, fd.cFileName);
- Playlist.RemoveAll();
-
- // Main movie shouldn't have duplicate M2TS filename...
- if (ReadPlaylist(strCurrentPlaylist, rtCurrent, Playlist) == S_OK) {
- if (rtCurrent > rtMax) {
- rtMax = rtCurrent;
- strPlaylistFile = strCurrentPlaylist;
- MainPlaylist.RemoveAll();
- POSITION pos = Playlist.GetHeadPosition();
- while (pos) {
- MainPlaylist.AddTail(Playlist.GetNext(pos));
- }
- hr = S_OK;
- }
- if (rtCurrent >= (REFERENCE_TIME)MIN_LIMIT*600000000) {
- PlaylistItem Item;
- Item.m_strFileName = strCurrentPlaylist;
- Item.m_rtIn = 0;
- Item.m_rtOut = rtCurrent;
- MPLSPlaylists.AddTail(Item);
- }
-
- }
- } while (FindNextFile(hFind, &fd));
-
- FindClose(hFind);
- }
-
- if (MPLSPlaylists.GetCount() > 1) {
- // bubble sort
- for (size_t j=0; j<MPLSPlaylists.GetCount(); j++) {
- for (size_t i=0; i<MPLSPlaylists.GetCount()-1; i++) {
- if (MPLSPlaylists.GetAt(MPLSPlaylists.FindIndex(i)).Duration() < MPLSPlaylists.GetAt(MPLSPlaylists.FindIndex(i+1)).Duration()) {
- MPLSPlaylists.SwapElements(MPLSPlaylists.FindIndex(i), MPLSPlaylists.FindIndex(i+1));
- }
- }
- }
- }
-
- return hr;
+ HRESULT hr = E_FAIL;
+
+ CString strPath(strFolder);
+ CString strFilter;
+
+ MPLSPlaylists.RemoveAll();
+
+ CAtlList<PlaylistItem> Playlist;
+ WIN32_FIND_DATA fd = {0};
+
+ strPath.Replace(_T("\\PLAYLIST\\"), _T("\\"));
+ strPath.Replace(_T("\\STREAM\\"), _T("\\"));
+ strPath += _T("\\BDMV\\");
+ strFilter.Format(_T("%sPLAYLIST\\*.mpls"), strPath);
+
+ HANDLE hFind = FindFirstFile(strFilter, &fd);
+ if (hFind != INVALID_HANDLE_VALUE) {
+ REFERENCE_TIME rtMax = 0;
+ REFERENCE_TIME rtCurrent;
+ CString strCurrentPlaylist;
+ do {
+ strCurrentPlaylist.Format(_T("%sPLAYLIST\\%s"), strPath, fd.cFileName);
+ Playlist.RemoveAll();
+
+ // Main movie shouldn't have duplicate M2TS filename...
+ if (ReadPlaylist(strCurrentPlaylist, rtCurrent, Playlist) == S_OK) {
+ if (rtCurrent > rtMax) {
+ rtMax = rtCurrent;
+ strPlaylistFile = strCurrentPlaylist;
+ MainPlaylist.RemoveAll();
+ POSITION pos = Playlist.GetHeadPosition();
+ while (pos) {
+ MainPlaylist.AddTail(Playlist.GetNext(pos));
+ }
+ hr = S_OK;
+ }
+ if (rtCurrent >= (REFERENCE_TIME)MIN_LIMIT * 600000000) {
+ PlaylistItem Item;
+ Item.m_strFileName = strCurrentPlaylist;
+ Item.m_rtIn = 0;
+ Item.m_rtOut = rtCurrent;
+ MPLSPlaylists.AddTail(Item);
+ }
+
+ }
+ } while (FindNextFile(hFind, &fd));
+
+ FindClose(hFind);
+ }
+
+ if (MPLSPlaylists.GetCount() > 1) {
+ // bubble sort
+ for (size_t j = 0; j < MPLSPlaylists.GetCount(); j++) {
+ for (size_t i = 0; i < MPLSPlaylists.GetCount() - 1; i++) {
+ if (MPLSPlaylists.GetAt(MPLSPlaylists.FindIndex(i)).Duration() < MPLSPlaylists.GetAt(MPLSPlaylists.FindIndex(i + 1)).Duration()) {
+ MPLSPlaylists.SwapElements(MPLSPlaylists.FindIndex(i), MPLSPlaylists.FindIndex(i + 1));
+ }
+ }
+ }
+ }
+
+ return hr;
}
diff --git a/src/DSUtil/HdmvClipInfo.h b/src/DSUtil/HdmvClipInfo.h
index 11136f1a6..a262fb954 100644
--- a/src/DSUtil/HdmvClipInfo.h
+++ b/src/DSUtil/HdmvClipInfo.h
@@ -25,48 +25,48 @@
#include "Mpeg2Def.h"
enum BDVM_VideoFormat {
- BDVM_VideoFormat_Unknown = 0,
- BDVM_VideoFormat_480i = 1,
- BDVM_VideoFormat_576i = 2,
- BDVM_VideoFormat_480p = 3,
- BDVM_VideoFormat_1080i = 4,
- BDVM_VideoFormat_720p = 5,
- BDVM_VideoFormat_1080p = 6,
- BDVM_VideoFormat_576p = 7,
+ BDVM_VideoFormat_Unknown = 0,
+ BDVM_VideoFormat_480i = 1,
+ BDVM_VideoFormat_576i = 2,
+ BDVM_VideoFormat_480p = 3,
+ BDVM_VideoFormat_1080i = 4,
+ BDVM_VideoFormat_720p = 5,
+ BDVM_VideoFormat_1080p = 6,
+ BDVM_VideoFormat_576p = 7,
};
enum BDVM_FrameRate {
- BDVM_FrameRate_Unknown = 0,
- BDVM_FrameRate_23_976 = 1,
- BDVM_FrameRate_24 = 2,
- BDVM_FrameRate_25 = 3,
- BDVM_FrameRate_29_97 = 4,
- BDVM_FrameRate_50 = 6,
- BDVM_FrameRate_59_94 = 7
+ BDVM_FrameRate_Unknown = 0,
+ BDVM_FrameRate_23_976 = 1,
+ BDVM_FrameRate_24 = 2,
+ BDVM_FrameRate_25 = 3,
+ BDVM_FrameRate_29_97 = 4,
+ BDVM_FrameRate_50 = 6,
+ BDVM_FrameRate_59_94 = 7
};
enum BDVM_AspectRatio {
- BDVM_AspectRatio_Unknown = 0,
- BDVM_AspectRatio_4_3 = 2,
- BDVM_AspectRatio_16_9 = 3,
- BDVM_AspectRatio_2_21 = 4
+ BDVM_AspectRatio_Unknown = 0,
+ BDVM_AspectRatio_4_3 = 2,
+ BDVM_AspectRatio_16_9 = 3,
+ BDVM_AspectRatio_2_21 = 4
};
enum BDVM_ChannelLayout {
- BDVM_ChannelLayout_Unknown = 0,
- BDVM_ChannelLayout_MONO = 1,
- BDVM_ChannelLayout_STEREO = 3,
- BDVM_ChannelLayout_MULTI = 6,
- BDVM_ChannelLayout_COMBO = 12
+ BDVM_ChannelLayout_Unknown = 0,
+ BDVM_ChannelLayout_MONO = 1,
+ BDVM_ChannelLayout_STEREO = 3,
+ BDVM_ChannelLayout_MULTI = 6,
+ BDVM_ChannelLayout_COMBO = 12
};
enum BDVM_SampleRate {
- BDVM_SampleRate_Unknown = 0,
- BDVM_SampleRate_48 = 1,
- BDVM_SampleRate_96 = 4,
- BDVM_SampleRate_192 = 5,
- BDVM_SampleRate_48_192 = 12,
- BDVM_SampleRate_48_96 = 14
+ BDVM_SampleRate_Unknown = 0,
+ BDVM_SampleRate_48 = 1,
+ BDVM_SampleRate_96 = 4,
+ BDVM_SampleRate_192 = 5,
+ BDVM_SampleRate_48_192 = 12,
+ BDVM_SampleRate_48_96 = 14
};
typedef unsigned char uint8;
@@ -83,83 +83,81 @@ class CHdmvClipInfo
{
public:
- struct Stream {
- Stream() {
- memset(this, 0, sizeof(*this));
- }
- SHORT m_PID;
- PES_STREAM_TYPE m_Type;
- char m_LanguageCode[4];
- LCID m_LCID;
-
- // Valid for video types
- BDVM_VideoFormat m_VideoFormat;
- BDVM_FrameRate m_FrameRate;
- BDVM_AspectRatio m_AspectRatio;
- // Valid for audio types
- BDVM_ChannelLayout m_ChannelLayout;
- BDVM_SampleRate m_SampleRate;
-
- LPCTSTR Format();
- };
-
- struct PlaylistItem {
- CString m_strFileName;
- REFERENCE_TIME m_rtIn;
- REFERENCE_TIME m_rtOut;
-
- REFERENCE_TIME Duration() const {
- return m_rtOut - m_rtIn;
- }
-
- bool operator == (const PlaylistItem& pi) const {
- return pi.m_strFileName == m_strFileName;
- }
- };
-
- enum PlaylistMarkType
- {
- Reserved = 0x00,
- EntryMark = 0x01,
- LinkPoint = 0x02
- };
-
- struct PlaylistChapter
- {
- SHORT m_nPlayItemId;
- PlaylistMarkType m_nMarkType;
- REFERENCE_TIME m_rtTimestamp;
- SHORT m_nEntryPID;
- REFERENCE_TIME m_rtDuration;
- };
-
- CHdmvClipInfo(void);
- ~CHdmvClipInfo();
-
- HRESULT ReadInfo(LPCTSTR strFile);
- Stream* FindStream(SHORT wPID);
- bool IsHdmv() const { return m_bIsHdmv; };
- size_t GetStreamNumber() { return m_Streams.GetCount(); };
- Stream* GetStreamByIndex(size_t nIndex) {return (nIndex < m_Streams.GetCount()) ? &m_Streams[nIndex] : NULL; };
-
- HRESULT FindMainMovie(LPCTSTR strFolder, CString& strPlaylistFile, CAtlList<PlaylistItem>& MainPlaylist, CAtlList<PlaylistItem>& MPLSPlaylists);
- HRESULT ReadPlaylist(CString strPlaylistFile, REFERENCE_TIME& rtDuration, CAtlList<PlaylistItem>& Playlist);
- HRESULT ReadChapters(CString strPlaylistFile, CAtlList<CHdmvClipInfo::PlaylistItem>& PlaylistItems, CAtlList<PlaylistChapter>& Chapters);
+ struct Stream {
+ Stream() {
+ memset(this, 0, sizeof(*this));
+ }
+ SHORT m_PID;
+ PES_STREAM_TYPE m_Type;
+ char m_LanguageCode[4];
+ LCID m_LCID;
+
+ // Valid for video types
+ BDVM_VideoFormat m_VideoFormat;
+ BDVM_FrameRate m_FrameRate;
+ BDVM_AspectRatio m_AspectRatio;
+ // Valid for audio types
+ BDVM_ChannelLayout m_ChannelLayout;
+ BDVM_SampleRate m_SampleRate;
+
+ LPCTSTR Format();
+ };
+
+ struct PlaylistItem {
+ CString m_strFileName;
+ REFERENCE_TIME m_rtIn;
+ REFERENCE_TIME m_rtOut;
+
+ REFERENCE_TIME Duration() const {
+ return m_rtOut - m_rtIn;
+ }
+
+ bool operator == (const PlaylistItem& pi) const {
+ return pi.m_strFileName == m_strFileName;
+ }
+ };
+
+ enum PlaylistMarkType {
+ Reserved = 0x00,
+ EntryMark = 0x01,
+ LinkPoint = 0x02
+ };
+
+ struct PlaylistChapter {
+ SHORT m_nPlayItemId;
+ PlaylistMarkType m_nMarkType;
+ REFERENCE_TIME m_rtTimestamp;
+ SHORT m_nEntryPID;
+ REFERENCE_TIME m_rtDuration;
+ };
+
+ CHdmvClipInfo(void);
+ ~CHdmvClipInfo();
+
+ HRESULT ReadInfo(LPCTSTR strFile);
+ Stream* FindStream(SHORT wPID);
+ bool IsHdmv() const { return m_bIsHdmv; };
+ size_t GetStreamNumber() { return m_Streams.GetCount(); };
+ Stream* GetStreamByIndex(size_t nIndex) {return (nIndex < m_Streams.GetCount()) ? &m_Streams[nIndex] : NULL; };
+
+ HRESULT FindMainMovie(LPCTSTR strFolder, CString& strPlaylistFile, CAtlList<PlaylistItem>& MainPlaylist, CAtlList<PlaylistItem>& MPLSPlaylists);
+ HRESULT ReadPlaylist(CString strPlaylistFile, REFERENCE_TIME& rtDuration, CAtlList<PlaylistItem>& Playlist);
+ HRESULT ReadChapters(CString strPlaylistFile, CAtlList<CHdmvClipInfo::PlaylistItem>& PlaylistItems, CAtlList<PlaylistChapter>& Chapters);
private :
- DWORD SequenceInfo_start_address;
- DWORD ProgramInfo_start_address;
+ DWORD SequenceInfo_start_address;
+ DWORD ProgramInfo_start_address;
- HANDLE m_hFile;
+ HANDLE m_hFile;
- CAtlArray<Stream> m_Streams;
- bool m_bIsHdmv;
+ CAtlArray<Stream> m_Streams;
+ bool m_bIsHdmv;
- DWORD ReadDword();
- SHORT ReadShort();
- BYTE ReadByte();
- void ReadBuffer(BYTE* pBuff, DWORD nLen);
+ DWORD ReadDword();
+ SHORT ReadShort();
+ BYTE ReadByte();
+ void ReadBuffer(BYTE* pBuff, DWORD nLen);
- HRESULT ReadProgramInfo();
- HRESULT CloseFile(HRESULT hr);
+ HRESULT ReadProgramInfo();
+ HRESULT CloseFile(HRESULT hr);
};
diff --git a/src/DSUtil/MediaTypeEx.cpp b/src/DSUtil/MediaTypeEx.cpp
index e34a425f6..36c40d9b2 100644
--- a/src/DSUtil/MediaTypeEx.cpp
+++ b/src/DSUtil/MediaTypeEx.cpp
@@ -31,12 +31,12 @@
#pragma pack(push, 1)
typedef struct {
- WAVEFORMATEX Format;
- BYTE bBigEndian;
- BYTE bsid;
- BYTE lfeon;
- BYTE copyrightb;
- BYTE nAuxBitsCode; // Aux bits per frame
+ WAVEFORMATEX Format;
+ BYTE bBigEndian;
+ BYTE bsid;
+ BYTE lfeon;
+ BYTE copyrightb;
+ BYTE nAuxBitsCode; // Aux bits per frame
} DOLBYAC3WAVEFORMAT;
#pragma pack(pop)
@@ -46,680 +46,681 @@ CMediaTypeEx::CMediaTypeEx()
CString CMediaTypeEx::ToString(IPin* pPin)
{
- CString packing, type, codec, dim, rate, dur;
-
- // TODO
-
- if (majortype == MEDIATYPE_DVD_ENCRYPTED_PACK) {
- packing = _T("Encrypted MPEG2 Pack");
- } else if (majortype == MEDIATYPE_MPEG2_PACK) {
- packing = _T("MPEG2 Pack");
- } else if (majortype == MEDIATYPE_MPEG2_PES) {
- packing = _T("MPEG2 PES");
- }
-
- if (majortype == MEDIATYPE_Video) {
- type = _T("Video");
-
- BITMAPINFOHEADER bih;
- bool fBIH = ExtractBIH(this, &bih);
-
- int w, h, arx, ary;
- bool fDim = ExtractDim(this, w, h, arx, ary);
-
- if (fBIH) {
- codec = GetVideoCodecName(subtype, bih.biCompression);
- }
-
- if (codec.IsEmpty()) {
- if (formattype == FORMAT_MPEGVideo) {
- codec = _T("MPEG1 Video");
- } else if (formattype == FORMAT_MPEG2_VIDEO) {
- codec = _T("MPEG2 Video");
- } else if (formattype == FORMAT_DiracVideoInfo) {
- codec = _T("Dirac Video");
- }
- }
-
- if (fDim) {
- dim.Format(_T("%dx%d"), w, h);
- if (w*ary != h*arx) {
- dim.AppendFormat(_T(" (%d:%d)"), arx, ary);
- }
- }
-
- if (formattype == FORMAT_VideoInfo || formattype == FORMAT_MPEGVideo) {
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pbFormat;
- if (vih->AvgTimePerFrame) {
- rate.Format(_T("%0.3f"), 10000000.0f / vih->AvgTimePerFrame);
- rate.TrimRight(_T('0')); // remove trailing zeros
- rate.TrimRight(_T('.')); // remove the trailing dot
- rate += _T("fps ");
- }
- if (vih->dwBitRate) {
- rate.AppendFormat(_T("%dkbps"), vih->dwBitRate/1000);
- }
- } else if (formattype == FORMAT_VideoInfo2 || formattype == FORMAT_MPEG2_VIDEO || formattype == FORMAT_DiracVideoInfo) {
- VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pbFormat;
- if (vih->AvgTimePerFrame) {
- rate.Format(_T("%0.3f"), 10000000.0f / vih->AvgTimePerFrame);
- rate.TrimRight(_T('0')); // remove trailing zeros
- rate.TrimRight(_T('.')); // remove the trailing dot
- rate += _T("fps ");
- }
- if (vih->dwBitRate) {
- rate.AppendFormat(_T("%dkbps"), vih->dwBitRate/1000);
- }
- }
-
- rate.TrimRight();
-
- if (subtype == MEDIASUBTYPE_DVD_SUBPICTURE) {
- type = _T("Subtitle");
- codec = _T("DVD Subpicture");
- }
- } else if (majortype == MEDIATYPE_Audio) {
- type = _T("Audio");
-
- if (formattype == FORMAT_WaveFormatEx) {
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)Format();
-
- if (wfe->wFormatTag/* > WAVE_FORMAT_PCM && wfe->wFormatTag < WAVE_FORMAT_EXTENSIBLE
- && wfe->wFormatTag != WAVE_FORMAT_IEEE_FLOAT*/
- || subtype != GUID_NULL) {
- codec = GetAudioCodecName(subtype, wfe->wFormatTag);
- dim.Format(_T("%dHz"), wfe->nSamplesPerSec);
- if (wfe->nChannels == 1) {
- dim += _T(" mono");
- } else if (wfe->nChannels == 2) {
- dim += _T(" stereo");
- } else {
- dim.AppendFormat(_T(" %dch"), wfe->nChannels);
- }
- if (wfe->nAvgBytesPerSec) {
- rate.Format(_T("%dkbps"), wfe->nAvgBytesPerSec*8/1000);
- }
- }
- } else if (formattype == FORMAT_VorbisFormat) {
- VORBISFORMAT* vf = (VORBISFORMAT*)Format();
-
- codec = GetAudioCodecName(subtype, 0);
- dim.Format(_T("%dHz"), vf->nSamplesPerSec);
- if (vf->nChannels == 1) {
- dim += _T(" mono");
- } else if (vf->nChannels == 2) {
- dim += _T(" stereo");
- } else {
- dim.AppendFormat(_T(" %dch"), vf->nChannels);
- }
- if (vf->nAvgBitsPerSec) {
- rate.Format(_T("%dkbps"), vf->nAvgBitsPerSec/1000);
- }
- } else if (formattype == FORMAT_VorbisFormat2) {
- VORBISFORMAT2* vf = (VORBISFORMAT2*)Format();
-
- codec = GetAudioCodecName(subtype, 0);
- dim.Format(_T("%dHz"), vf->SamplesPerSec);
- if (vf->Channels == 1) {
- dim += _T(" mono");
- } else if (vf->Channels == 2) {
- dim += _T(" stereo");
- } else {
- dim.AppendFormat(_T(" %dch"), vf->Channels);
- }
- }
- } else if (majortype == MEDIATYPE_Text) {
- type = _T("Text");
- } else if (majortype == MEDIATYPE_Subtitle) {
- type = _T("Subtitle");
- codec = GetSubtitleCodecName(subtype);
- } else {
- type = _T("Unknown");
- }
-
- if (CComQIPtr<IMediaSeeking> pMS = pPin) {
- REFERENCE_TIME rtDur = 0;
- if (SUCCEEDED(pMS->GetDuration(&rtDur)) && rtDur) {
- rtDur /= 10000000;
- int s = rtDur%60;
- rtDur /= 60;
- int m = rtDur%60;
- rtDur /= 60;
- int h = (int)rtDur;
- if (h) {
- dur.Format(_T("%d:%02d:%02d"), h, m, s);
- } else if (m) {
- dur.Format(_T("%02d:%02d"), m, s);
- } else if (s) {
- dur.Format(_T("%ds"), s);
- }
- }
- }
-
- CString str;
- if (!codec.IsEmpty()) {
- str += codec + _T(" ");
- }
- if (!dim.IsEmpty()) {
- str += dim + _T(" ");
- }
- if (!rate.IsEmpty()) {
- str += rate + _T(" ");
- }
- if (!dur.IsEmpty()) {
- str += dur + _T(" ");
- }
- str.Trim(_T(" ,"));
-
- if (!str.IsEmpty()) {
- str = type + _T(": ") + str;
- } else {
- str = type;
- }
-
- return str;
+ CString packing, type, codec, dim, rate, dur;
+
+ // TODO
+
+ if (majortype == MEDIATYPE_DVD_ENCRYPTED_PACK) {
+ packing = _T("Encrypted MPEG2 Pack");
+ } else if (majortype == MEDIATYPE_MPEG2_PACK) {
+ packing = _T("MPEG2 Pack");
+ } else if (majortype == MEDIATYPE_MPEG2_PES) {
+ packing = _T("MPEG2 PES");
+ }
+
+ if (majortype == MEDIATYPE_Video) {
+ type = _T("Video");
+
+ BITMAPINFOHEADER bih;
+ bool fBIH = ExtractBIH(this, &bih);
+
+ int w, h, arx, ary;
+ bool fDim = ExtractDim(this, w, h, arx, ary);
+
+ if (fBIH) {
+ codec = GetVideoCodecName(subtype, bih.biCompression);
+ }
+
+ if (codec.IsEmpty()) {
+ if (formattype == FORMAT_MPEGVideo) {
+ codec = _T("MPEG1 Video");
+ } else if (formattype == FORMAT_MPEG2_VIDEO) {
+ codec = _T("MPEG2 Video");
+ } else if (formattype == FORMAT_DiracVideoInfo) {
+ codec = _T("Dirac Video");
+ }
+ }
+
+ if (fDim) {
+ dim.Format(_T("%dx%d"), w, h);
+ if (w * ary != h * arx) {
+ dim.AppendFormat(_T(" (%d:%d)"), arx, ary);
+ }
+ }
+
+ if (formattype == FORMAT_VideoInfo || formattype == FORMAT_MPEGVideo) {
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pbFormat;
+ if (vih->AvgTimePerFrame) {
+ rate.Format(_T("%0.3f"), 10000000.0f / vih->AvgTimePerFrame);
+ rate.TrimRight(_T('0')); // remove trailing zeros
+ rate.TrimRight(_T('.')); // remove the trailing dot
+ rate += _T("fps ");
+ }
+ if (vih->dwBitRate) {
+ rate.AppendFormat(_T("%dkbps"), vih->dwBitRate / 1000);
+ }
+ } else if (formattype == FORMAT_VideoInfo2 || formattype == FORMAT_MPEG2_VIDEO || formattype == FORMAT_DiracVideoInfo) {
+ VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pbFormat;
+ if (vih->AvgTimePerFrame) {
+ rate.Format(_T("%0.3f"), 10000000.0f / vih->AvgTimePerFrame);
+ rate.TrimRight(_T('0')); // remove trailing zeros
+ rate.TrimRight(_T('.')); // remove the trailing dot
+ rate += _T("fps ");
+ }
+ if (vih->dwBitRate) {
+ rate.AppendFormat(_T("%dkbps"), vih->dwBitRate / 1000);
+ }
+ }
+
+ rate.TrimRight();
+
+ if (subtype == MEDIASUBTYPE_DVD_SUBPICTURE) {
+ type = _T("Subtitle");
+ codec = _T("DVD Subpicture");
+ }
+ } else if (majortype == MEDIATYPE_Audio) {
+ type = _T("Audio");
+
+ if (formattype == FORMAT_WaveFormatEx) {
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)Format();
+
+ if (wfe->wFormatTag/* > WAVE_FORMAT_PCM && wfe->wFormatTag < WAVE_FORMAT_EXTENSIBLE
+ && wfe->wFormatTag != WAVE_FORMAT_IEEE_FLOAT*/
+ || subtype != GUID_NULL) {
+ codec = GetAudioCodecName(subtype, wfe->wFormatTag);
+ dim.Format(_T("%dHz"), wfe->nSamplesPerSec);
+ if (wfe->nChannels == 1) {
+ dim += _T(" mono");
+ } else if (wfe->nChannels == 2) {
+ dim += _T(" stereo");
+ } else {
+ dim.AppendFormat(_T(" %dch"), wfe->nChannels);
+ }
+ if (wfe->nAvgBytesPerSec) {
+ rate.Format(_T("%dkbps"), wfe->nAvgBytesPerSec * 8 / 1000);
+ }
+ }
+ } else if (formattype == FORMAT_VorbisFormat) {
+ VORBISFORMAT* vf = (VORBISFORMAT*)Format();
+
+ codec = GetAudioCodecName(subtype, 0);
+ dim.Format(_T("%dHz"), vf->nSamplesPerSec);
+ if (vf->nChannels == 1) {
+ dim += _T(" mono");
+ } else if (vf->nChannels == 2) {
+ dim += _T(" stereo");
+ } else {
+ dim.AppendFormat(_T(" %dch"), vf->nChannels);
+ }
+ if (vf->nAvgBitsPerSec) {
+ rate.Format(_T("%dkbps"), vf->nAvgBitsPerSec / 1000);
+ }
+ } else if (formattype == FORMAT_VorbisFormat2) {
+ VORBISFORMAT2* vf = (VORBISFORMAT2*)Format();
+
+ codec = GetAudioCodecName(subtype, 0);
+ dim.Format(_T("%dHz"), vf->SamplesPerSec);
+ if (vf->Channels == 1) {
+ dim += _T(" mono");
+ } else if (vf->Channels == 2) {
+ dim += _T(" stereo");
+ } else {
+ dim.AppendFormat(_T(" %dch"), vf->Channels);
+ }
+ }
+ } else if (majortype == MEDIATYPE_Text) {
+ type = _T("Text");
+ } else if (majortype == MEDIATYPE_Subtitle) {
+ type = _T("Subtitle");
+ codec = GetSubtitleCodecName(subtype);
+ } else {
+ type = _T("Unknown");
+ }
+
+ if (CComQIPtr<IMediaSeeking> pMS = pPin) {
+ REFERENCE_TIME rtDur = 0;
+ if (SUCCEEDED(pMS->GetDuration(&rtDur)) && rtDur) {
+ rtDur /= 10000000;
+ int s = rtDur % 60;
+ rtDur /= 60;
+ int m = rtDur % 60;
+ rtDur /= 60;
+ int h = (int)rtDur;
+ if (h) {
+ dur.Format(_T("%d:%02d:%02d"), h, m, s);
+ } else if (m) {
+ dur.Format(_T("%02d:%02d"), m, s);
+ } else if (s) {
+ dur.Format(_T("%ds"), s);
+ }
+ }
+ }
+
+ CString str;
+ if (!codec.IsEmpty()) {
+ str += codec + _T(" ");
+ }
+ if (!dim.IsEmpty()) {
+ str += dim + _T(" ");
+ }
+ if (!rate.IsEmpty()) {
+ str += rate + _T(" ");
+ }
+ if (!dur.IsEmpty()) {
+ str += dur + _T(" ");
+ }
+ str.Trim(_T(" ,"));
+
+ if (!str.IsEmpty()) {
+ str = type + _T(": ") + str;
+ } else {
+ str = type;
+ }
+
+ return str;
}
CString CMediaTypeEx::GetVideoCodecName(const GUID& subtype, DWORD biCompression)
{
- CString str = _T("");
-
- static CAtlMap<DWORD, CString> names;
-
- if (names.IsEmpty()) {
- names['WMV1'] = _T("Windows Media Video 7");
- names['WMV2'] = _T("Windows Media Video 8");
- names['WMV3'] = _T("Windows Media Video 9");
- names['DIV3'] = _T("DivX 3");
- names['MP43'] = _T("MSMPEG4v3");
- names['MP42'] = _T("MSMPEG4v2");
- names['MP41'] = _T("MSMPEG4v1");
- names['DX50'] = _T("DivX 5");
- names['DIVX'] = _T("DivX 6");
- names['XVID'] = _T("Xvid");
- names['MP4V'] = _T("MPEG4 Video");
- names['AVC1'] = _T("MPEG4 Video (H264)");
- names['H264'] = _T("MPEG4 Video (H264)");
- names['RV10'] = _T("RealVideo 1");
- names['RV20'] = _T("RealVideo 2");
- names['RV30'] = _T("RealVideo 3");
- names['RV40'] = _T("RealVideo 4");
- names['FLV1'] = _T("Flash Video 1");
- names['FLV4'] = _T("Flash Video 4");
- names['VP50'] = _T("On2 VP5");
- names['VP60'] = _T("On2 VP6");
- names['SVQ3'] = _T("SVQ3");
- names['SVQ1'] = _T("SVQ1");
- names['H263'] = _T("H263");
- // names[''] = _T("");
- }
-
- if (biCompression) {
- BYTE* b = (BYTE*)&biCompression;
-
- for (ptrdiff_t i = 0; i < 4; i++)
- if (b[i] >= 'a' && b[i] <= 'z') {
- b[i] = toupper(b[i]);
- }
-
- if (!names.Lookup(MAKEFOURCC(b[3], b[2], b[1], b[0]), str)) {
- if (subtype == MEDIASUBTYPE_DiracVideo) {
- str = _T("Dirac Video");
- }
- // else if (subtype == ) str = _T("");
- else if (biCompression < 256) {
- str.Format(_T("%d"), biCompression);
- } else {
- str.Format(_T("%4.4hs"), &biCompression);
- }
- }
- } else {
- if (subtype == MEDIASUBTYPE_RGB32)
- str = _T("RGB32");
- else if (subtype == MEDIASUBTYPE_RGB24)
- str = _T("RGB24");
- else if (subtype == MEDIASUBTYPE_RGB555)
- str = _T("RGB555");
- else if (subtype == MEDIASUBTYPE_RGB565)
- str = _T("RGB565");
- }
-
- return str;
+ CString str = _T("");
+
+ static CAtlMap<DWORD, CString> names;
+
+ if (names.IsEmpty()) {
+ names['WMV1'] = _T("Windows Media Video 7");
+ names['WMV2'] = _T("Windows Media Video 8");
+ names['WMV3'] = _T("Windows Media Video 9");
+ names['DIV3'] = _T("DivX 3");
+ names['MP43'] = _T("MSMPEG4v3");
+ names['MP42'] = _T("MSMPEG4v2");
+ names['MP41'] = _T("MSMPEG4v1");
+ names['DX50'] = _T("DivX 5");
+ names['DIVX'] = _T("DivX 6");
+ names['XVID'] = _T("Xvid");
+ names['MP4V'] = _T("MPEG4 Video");
+ names['AVC1'] = _T("MPEG4 Video (H264)");
+ names['H264'] = _T("MPEG4 Video (H264)");
+ names['RV10'] = _T("RealVideo 1");
+ names['RV20'] = _T("RealVideo 2");
+ names['RV30'] = _T("RealVideo 3");
+ names['RV40'] = _T("RealVideo 4");
+ names['FLV1'] = _T("Flash Video 1");
+ names['FLV4'] = _T("Flash Video 4");
+ names['VP50'] = _T("On2 VP5");
+ names['VP60'] = _T("On2 VP6");
+ names['SVQ3'] = _T("SVQ3");
+ names['SVQ1'] = _T("SVQ1");
+ names['H263'] = _T("H263");
+ // names[''] = _T("");
+ }
+
+ if (biCompression) {
+ BYTE* b = (BYTE*)&biCompression;
+
+ for (ptrdiff_t i = 0; i < 4; i++)
+ if (b[i] >= 'a' && b[i] <= 'z') {
+ b[i] = toupper(b[i]);
+ }
+
+ if (!names.Lookup(MAKEFOURCC(b[3], b[2], b[1], b[0]), str)) {
+ if (subtype == MEDIASUBTYPE_DiracVideo) {
+ str = _T("Dirac Video");
+ }
+ // else if (subtype == ) str = _T("");
+ else if (biCompression < 256) {
+ str.Format(_T("%d"), biCompression);
+ } else {
+ str.Format(_T("%4.4hs"), &biCompression);
+ }
+ }
+ } else {
+ if (subtype == MEDIASUBTYPE_RGB32) {
+ str = _T("RGB32");
+ } else if (subtype == MEDIASUBTYPE_RGB24) {
+ str = _T("RGB24");
+ } else if (subtype == MEDIASUBTYPE_RGB555) {
+ str = _T("RGB555");
+ } else if (subtype == MEDIASUBTYPE_RGB565) {
+ str = _T("RGB565");
+ }
+ }
+
+ return str;
}
CString CMediaTypeEx::GetAudioCodecName(const GUID& subtype, WORD wFormatTag)
{
- CString str;
-
- static CAtlMap<WORD, CString> names;
-
- if (names.IsEmpty()) {
- names[WAVE_FORMAT_PCM] = _T("PCM");
- names[WAVE_FORMAT_EXTENSIBLE] = _T("WAVE_FORMAT_EXTENSIBLE");
- names[WAVE_FORMAT_IEEE_FLOAT] = _T("IEEE Float");
- names[WAVE_FORMAT_ADPCM] = _T("MS ADPCM");
- names[WAVE_FORMAT_ALAW] = _T("aLaw");
- names[WAVE_FORMAT_MULAW] = _T("muLaw");
- names[WAVE_FORMAT_DRM] = _T("DRM");
- names[WAVE_FORMAT_OKI_ADPCM] = _T("OKI ADPCM");
- names[WAVE_FORMAT_DVI_ADPCM] = _T("DVI ADPCM");
- names[WAVE_FORMAT_IMA_ADPCM] = _T("IMA ADPCM");
- names[WAVE_FORMAT_MEDIASPACE_ADPCM] = _T("Mediaspace ADPCM");
- names[WAVE_FORMAT_SIERRA_ADPCM] = _T("Sierra ADPCM");
- names[WAVE_FORMAT_G723_ADPCM] = _T("G723 ADPCM");
- names[WAVE_FORMAT_DIALOGIC_OKI_ADPCM] = _T("Dialogic OKI ADPCM");
- names[WAVE_FORMAT_MEDIAVISION_ADPCM] = _T("Media Vision ADPCM");
- names[WAVE_FORMAT_YAMAHA_ADPCM] = _T("Yamaha ADPCM");
- names[WAVE_FORMAT_DSPGROUP_TRUESPEECH] = _T("DSP Group Truespeech");
- names[WAVE_FORMAT_DOLBY_AC2] = _T("Dolby AC2");
- names[WAVE_FORMAT_GSM610] = _T("GSM610");
- names[WAVE_FORMAT_MSNAUDIO] = _T("MSN Audio");
- names[WAVE_FORMAT_ANTEX_ADPCME] = _T("Antex ADPCME");
- names[WAVE_FORMAT_CS_IMAADPCM] = _T("Crystal Semiconductor IMA ADPCM");
- names[WAVE_FORMAT_ROCKWELL_ADPCM] = _T("Rockwell ADPCM");
- names[WAVE_FORMAT_ROCKWELL_DIGITALK] = _T("Rockwell Digitalk");
- names[WAVE_FORMAT_G721_ADPCM] = _T("G721");
- names[WAVE_FORMAT_G728_CELP] = _T("G728");
- names[WAVE_FORMAT_MSG723] = _T("MSG723");
- names[WAVE_FORMAT_MPEG] = _T("MPEG Audio");
- names[WAVE_FORMAT_MPEGLAYER3] = _T("MPEG Audio Layer 3");
- names[WAVE_FORMAT_LUCENT_G723] = _T("Lucent G723");
- names[WAVE_FORMAT_VOXWARE] = _T("Voxware");
- names[WAVE_FORMAT_G726_ADPCM] = _T("G726");
- names[WAVE_FORMAT_G722_ADPCM] = _T("G722");
- names[WAVE_FORMAT_G729A] = _T("G729A");
- names[WAVE_FORMAT_MEDIASONIC_G723] = _T("MediaSonic G723");
- names[WAVE_FORMAT_ZYXEL_ADPCM] = _T("ZyXEL ADPCM");
- names[WAVE_FORMAT_RHETOREX_ADPCM] = _T("Rhetorex ADPCM");
- names[WAVE_FORMAT_VIVO_G723] = _T("Vivo G723");
- names[WAVE_FORMAT_VIVO_SIREN] = _T("Vivo Siren");
- names[WAVE_FORMAT_DIGITAL_G723] = _T("Digital G723");
- names[WAVE_FORMAT_SANYO_LD_ADPCM] = _T("Sanyo LD ADPCM");
- names[WAVE_FORMAT_CREATIVE_ADPCM] = _T("Creative ADPCM");
- names[WAVE_FORMAT_CREATIVE_FASTSPEECH8] = _T("Creative Fastspeech 8");
- names[WAVE_FORMAT_CREATIVE_FASTSPEECH10] = _T("Creative Fastspeech 10");
- names[WAVE_FORMAT_UHER_ADPCM] = _T("UHER ADPCM");
- names[WAVE_FORMAT_DOLBY_AC3] = _T("Dolby AC3");
- names[WAVE_FORMAT_DVD_DTS] = _T("DTS");
- names[WAVE_FORMAT_AAC] = _T("AAC");
- names[WAVE_FORMAT_LATM_AAC] = _T("AAC(LATM)");
- names[WAVE_FORMAT_FLAC] = _T("FLAC");
- names[WAVE_FORMAT_TTA1] = _T("TTA");
- names[WAVE_FORMAT_14_4] = _T("RealAudio 14.4");
- names[WAVE_FORMAT_28_8] = _T("RealAudio 28.8");
- names[WAVE_FORMAT_ATRC] = _T("RealAudio ATRC");
- names[WAVE_FORMAT_COOK] = _T("RealAudio COOK");
- names[WAVE_FORMAT_DNET] = _T("RealAudio DNET");
- names[WAVE_FORMAT_RAAC] = _T("RealAudio RAAC");
- names[WAVE_FORMAT_RACP] = _T("RealAudio RACP");
- names[WAVE_FORMAT_SIPR] = _T("RealAudio SIPR");
- names[WAVE_FORMAT_PS2_PCM] = _T("PS2 PCM");
- names[WAVE_FORMAT_PS2_ADPCM] = _T("PS2 ADPCM");
- names[0x0160] = _T("Windows Media Audio");
- names[0x0161] = _T("Windows Media Audio");
- names[0x0162] = _T("Windows Media Audio");
- names[0x0163] = _T("Windows Media Audio");
- names[0x6173] = _T("AMR");
- // names[] = _T("");
- }
-
- if (!names.Lookup(wFormatTag, str)) {
- if (subtype == MEDIASUBTYPE_Vorbis) {
- str = _T("Vorbis (deprecated)");
- } else if (subtype == MEDIASUBTYPE_Vorbis2) {
- str = _T("Vorbis");
- } else if (subtype == MEDIASUBTYPE_MP4A) {
- str = _T("MPEG4 Audio");
- } else if (subtype == MEDIASUBTYPE_FLAC_FRAMED) {
- str = _T("FLAC (framed)");
- } else if (subtype == MEDIASUBTYPE_DOLBY_AC3) {
- str += _T("Dolby AC3");
- } else if (subtype == MEDIASUBTYPE_DTS) {
- str += _T("DTS");
- } else if (subtype == MEDIASUBTYPE_PCM_NONE || subtype == MEDIASUBTYPE_PCM_RAW ||
- subtype == MEDIASUBTYPE_PCM_TWOS || subtype == MEDIASUBTYPE_PCM_SOWT ||
- subtype == MEDIASUBTYPE_PCM_IN24 || subtype == MEDIASUBTYPE_PCM_IN32 ||
- subtype == MEDIASUBTYPE_PCM_FL32 || subtype == MEDIASUBTYPE_PCM_FL64) {
- str += _T("PCM");
- } else if (subtype == MEDIASUBTYPE_IMA4 ||
- subtype == MEDIASUBTYPE_ADPCM_SWF ||
- subtype == MEDIASUBTYPE_ADPCM_AMV) {
- str += _T("ADPCM");
- } else if (subtype == MEDIASUBTYPE_ALAC) {
- str += _T("Alac");
- } else if (subtype == MEDIASUBTYPE_ALS) {
- str += _T("ALS");
- } else {
- str.Format(_T("0x%04x"), wFormatTag);
- }
- }
-
- if (wFormatTag == WAVE_FORMAT_PCM) {
- if (subtype == MEDIASUBTYPE_DOLBY_AC3) {
- str += _T(" (AC3)");
- } else if (subtype == MEDIASUBTYPE_DTS) {
- str += _T(" (DTS)");
- }
- }
-
- return str;
+ CString str;
+
+ static CAtlMap<WORD, CString> names;
+
+ if (names.IsEmpty()) {
+ names[WAVE_FORMAT_PCM] = _T("PCM");
+ names[WAVE_FORMAT_EXTENSIBLE] = _T("WAVE_FORMAT_EXTENSIBLE");
+ names[WAVE_FORMAT_IEEE_FLOAT] = _T("IEEE Float");
+ names[WAVE_FORMAT_ADPCM] = _T("MS ADPCM");
+ names[WAVE_FORMAT_ALAW] = _T("aLaw");
+ names[WAVE_FORMAT_MULAW] = _T("muLaw");
+ names[WAVE_FORMAT_DRM] = _T("DRM");
+ names[WAVE_FORMAT_OKI_ADPCM] = _T("OKI ADPCM");
+ names[WAVE_FORMAT_DVI_ADPCM] = _T("DVI ADPCM");
+ names[WAVE_FORMAT_IMA_ADPCM] = _T("IMA ADPCM");
+ names[WAVE_FORMAT_MEDIASPACE_ADPCM] = _T("Mediaspace ADPCM");
+ names[WAVE_FORMAT_SIERRA_ADPCM] = _T("Sierra ADPCM");
+ names[WAVE_FORMAT_G723_ADPCM] = _T("G723 ADPCM");
+ names[WAVE_FORMAT_DIALOGIC_OKI_ADPCM] = _T("Dialogic OKI ADPCM");
+ names[WAVE_FORMAT_MEDIAVISION_ADPCM] = _T("Media Vision ADPCM");
+ names[WAVE_FORMAT_YAMAHA_ADPCM] = _T("Yamaha ADPCM");
+ names[WAVE_FORMAT_DSPGROUP_TRUESPEECH] = _T("DSP Group Truespeech");
+ names[WAVE_FORMAT_DOLBY_AC2] = _T("Dolby AC2");
+ names[WAVE_FORMAT_GSM610] = _T("GSM610");
+ names[WAVE_FORMAT_MSNAUDIO] = _T("MSN Audio");
+ names[WAVE_FORMAT_ANTEX_ADPCME] = _T("Antex ADPCME");
+ names[WAVE_FORMAT_CS_IMAADPCM] = _T("Crystal Semiconductor IMA ADPCM");
+ names[WAVE_FORMAT_ROCKWELL_ADPCM] = _T("Rockwell ADPCM");
+ names[WAVE_FORMAT_ROCKWELL_DIGITALK] = _T("Rockwell Digitalk");
+ names[WAVE_FORMAT_G721_ADPCM] = _T("G721");
+ names[WAVE_FORMAT_G728_CELP] = _T("G728");
+ names[WAVE_FORMAT_MSG723] = _T("MSG723");
+ names[WAVE_FORMAT_MPEG] = _T("MPEG Audio");
+ names[WAVE_FORMAT_MPEGLAYER3] = _T("MPEG Audio Layer 3");
+ names[WAVE_FORMAT_LUCENT_G723] = _T("Lucent G723");
+ names[WAVE_FORMAT_VOXWARE] = _T("Voxware");
+ names[WAVE_FORMAT_G726_ADPCM] = _T("G726");
+ names[WAVE_FORMAT_G722_ADPCM] = _T("G722");
+ names[WAVE_FORMAT_G729A] = _T("G729A");
+ names[WAVE_FORMAT_MEDIASONIC_G723] = _T("MediaSonic G723");
+ names[WAVE_FORMAT_ZYXEL_ADPCM] = _T("ZyXEL ADPCM");
+ names[WAVE_FORMAT_RHETOREX_ADPCM] = _T("Rhetorex ADPCM");
+ names[WAVE_FORMAT_VIVO_G723] = _T("Vivo G723");
+ names[WAVE_FORMAT_VIVO_SIREN] = _T("Vivo Siren");
+ names[WAVE_FORMAT_DIGITAL_G723] = _T("Digital G723");
+ names[WAVE_FORMAT_SANYO_LD_ADPCM] = _T("Sanyo LD ADPCM");
+ names[WAVE_FORMAT_CREATIVE_ADPCM] = _T("Creative ADPCM");
+ names[WAVE_FORMAT_CREATIVE_FASTSPEECH8] = _T("Creative Fastspeech 8");
+ names[WAVE_FORMAT_CREATIVE_FASTSPEECH10] = _T("Creative Fastspeech 10");
+ names[WAVE_FORMAT_UHER_ADPCM] = _T("UHER ADPCM");
+ names[WAVE_FORMAT_DOLBY_AC3] = _T("Dolby AC3");
+ names[WAVE_FORMAT_DVD_DTS] = _T("DTS");
+ names[WAVE_FORMAT_AAC] = _T("AAC");
+ names[WAVE_FORMAT_LATM_AAC] = _T("AAC(LATM)");
+ names[WAVE_FORMAT_FLAC] = _T("FLAC");
+ names[WAVE_FORMAT_TTA1] = _T("TTA");
+ names[WAVE_FORMAT_14_4] = _T("RealAudio 14.4");
+ names[WAVE_FORMAT_28_8] = _T("RealAudio 28.8");
+ names[WAVE_FORMAT_ATRC] = _T("RealAudio ATRC");
+ names[WAVE_FORMAT_COOK] = _T("RealAudio COOK");
+ names[WAVE_FORMAT_DNET] = _T("RealAudio DNET");
+ names[WAVE_FORMAT_RAAC] = _T("RealAudio RAAC");
+ names[WAVE_FORMAT_RACP] = _T("RealAudio RACP");
+ names[WAVE_FORMAT_SIPR] = _T("RealAudio SIPR");
+ names[WAVE_FORMAT_PS2_PCM] = _T("PS2 PCM");
+ names[WAVE_FORMAT_PS2_ADPCM] = _T("PS2 ADPCM");
+ names[0x0160] = _T("Windows Media Audio");
+ names[0x0161] = _T("Windows Media Audio");
+ names[0x0162] = _T("Windows Media Audio");
+ names[0x0163] = _T("Windows Media Audio");
+ names[0x6173] = _T("AMR");
+ // names[] = _T("");
+ }
+
+ if (!names.Lookup(wFormatTag, str)) {
+ if (subtype == MEDIASUBTYPE_Vorbis) {
+ str = _T("Vorbis (deprecated)");
+ } else if (subtype == MEDIASUBTYPE_Vorbis2) {
+ str = _T("Vorbis");
+ } else if (subtype == MEDIASUBTYPE_MP4A) {
+ str = _T("MPEG4 Audio");
+ } else if (subtype == MEDIASUBTYPE_FLAC_FRAMED) {
+ str = _T("FLAC (framed)");
+ } else if (subtype == MEDIASUBTYPE_DOLBY_AC3) {
+ str += _T("Dolby AC3");
+ } else if (subtype == MEDIASUBTYPE_DTS) {
+ str += _T("DTS");
+ } else if (subtype == MEDIASUBTYPE_PCM_NONE || subtype == MEDIASUBTYPE_PCM_RAW ||
+ subtype == MEDIASUBTYPE_PCM_TWOS || subtype == MEDIASUBTYPE_PCM_SOWT ||
+ subtype == MEDIASUBTYPE_PCM_IN24 || subtype == MEDIASUBTYPE_PCM_IN32 ||
+ subtype == MEDIASUBTYPE_PCM_FL32 || subtype == MEDIASUBTYPE_PCM_FL64) {
+ str += _T("PCM");
+ } else if (subtype == MEDIASUBTYPE_IMA4 ||
+ subtype == MEDIASUBTYPE_ADPCM_SWF ||
+ subtype == MEDIASUBTYPE_ADPCM_AMV) {
+ str += _T("ADPCM");
+ } else if (subtype == MEDIASUBTYPE_ALAC) {
+ str += _T("Alac");
+ } else if (subtype == MEDIASUBTYPE_ALS) {
+ str += _T("ALS");
+ } else {
+ str.Format(_T("0x%04x"), wFormatTag);
+ }
+ }
+
+ if (wFormatTag == WAVE_FORMAT_PCM) {
+ if (subtype == MEDIASUBTYPE_DOLBY_AC3) {
+ str += _T(" (AC3)");
+ } else if (subtype == MEDIASUBTYPE_DTS) {
+ str += _T(" (DTS)");
+ }
+ }
+
+ return str;
}
CString CMediaTypeEx::GetSubtitleCodecName(const GUID& subtype)
{
- CString str;
+ CString str;
- static CAtlMap<GUID, CString> names;
+ static CAtlMap<GUID, CString> names;
- if (names.IsEmpty()) {
- names[MEDIASUBTYPE_UTF8] = _T("UTF-8");
- names[MEDIASUBTYPE_SSA] = _T("SubStation Alpha");
- names[MEDIASUBTYPE_ASS] = _T("Advanced SubStation Alpha");
- names[MEDIASUBTYPE_ASS2] = _T("Advanced SubStation Alpha");
- names[MEDIASUBTYPE_USF] = _T("Universal Subtitle Format");
- names[MEDIASUBTYPE_VOBSUB] = _T("VobSub");
- // names[''] = _T("");
- }
+ if (names.IsEmpty()) {
+ names[MEDIASUBTYPE_UTF8] = _T("UTF-8");
+ names[MEDIASUBTYPE_SSA] = _T("SubStation Alpha");
+ names[MEDIASUBTYPE_ASS] = _T("Advanced SubStation Alpha");
+ names[MEDIASUBTYPE_ASS2] = _T("Advanced SubStation Alpha");
+ names[MEDIASUBTYPE_USF] = _T("Universal Subtitle Format");
+ names[MEDIASUBTYPE_VOBSUB] = _T("VobSub");
+ // names[''] = _T("");
+ }
- if (names.Lookup(subtype, str)) {
+ if (names.Lookup(subtype, str)) {
- }
+ }
- return str;
+ return str;
}
void CMediaTypeEx::Dump(CAtlList<CString>& sl)
{
- CString str;
-
- sl.RemoveAll();
-
- int fmtsize = 0;
-
- CString major = CStringFromGUID(majortype);
- CString sub = CStringFromGUID(subtype);
- CString format = CStringFromGUID(formattype);
-
- sl.AddTail(ToString() + _T("\n"));
-
- sl.AddTail(_T("AM_MEDIA_TYPE: "));
- str.Format(_T("majortype: %s %s"), CString(GuidNames[majortype]), major);
- sl.AddTail(str);
- str.Format(_T("subtype: %s %s"), CString(GuidNames[subtype]), sub);
- sl.AddTail(str);
- str.Format(_T("formattype: %s %s"), CString(GuidNames[formattype]), format);
- sl.AddTail(str);
- str.Format(_T("bFixedSizeSamples: %d"), bFixedSizeSamples);
- sl.AddTail(str);
- str.Format(_T("bTemporalCompression: %d"), bTemporalCompression);
- sl.AddTail(str);
- str.Format(_T("lSampleSize: %d"), lSampleSize);
- sl.AddTail(str);
- str.Format(_T("cbFormat: %d"), cbFormat);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
-
- if (formattype == FORMAT_VideoInfo || formattype == FORMAT_VideoInfo2
- || formattype == FORMAT_MPEGVideo || formattype == FORMAT_MPEG2_VIDEO) {
- fmtsize =
- formattype == FORMAT_VideoInfo ? sizeof(VIDEOINFOHEADER) :
- formattype == FORMAT_VideoInfo2 ? sizeof(VIDEOINFOHEADER2) :
- formattype == FORMAT_MPEGVideo ? sizeof(MPEG1VIDEOINFO)-1 :
- formattype == FORMAT_MPEG2_VIDEO ? sizeof(MPEG2VIDEOINFO)-4 :
- 0;
-
- VIDEOINFOHEADER& vih = *(VIDEOINFOHEADER*)pbFormat;
- BITMAPINFOHEADER* bih = &vih.bmiHeader;
-
- sl.AddTail(_T("VIDEOINFOHEADER:"));
- str.Format(_T("rcSource: (%d,%d)-(%d,%d)"), vih.rcSource.left, vih.rcSource.top, vih.rcSource.right, vih.rcSource.bottom);
- sl.AddTail(str);
- str.Format(_T("rcTarget: (%d,%d)-(%d,%d)"), vih.rcTarget.left, vih.rcTarget.top, vih.rcTarget.right, vih.rcTarget.bottom);
- sl.AddTail(str);
- str.Format(_T("dwBitRate: %d"), vih.dwBitRate);
- sl.AddTail(str);
- str.Format(_T("dwBitErrorRate: %d"), vih.dwBitErrorRate);
- sl.AddTail(str);
- str.Format(_T("AvgTimePerFrame: %I64d"), vih.AvgTimePerFrame);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
-
- if (formattype == FORMAT_VideoInfo2 || formattype == FORMAT_MPEG2_VIDEO) {
- VIDEOINFOHEADER2& vih = *(VIDEOINFOHEADER2*)pbFormat;
- bih = &vih.bmiHeader;
-
- sl.AddTail(_T("VIDEOINFOHEADER2:"));
- str.Format(_T("dwInterlaceFlags: 0x%08x"), vih.dwInterlaceFlags);
- sl.AddTail(str);
- str.Format(_T("dwCopyProtectFlags: 0x%08x"), vih.dwCopyProtectFlags);
- sl.AddTail(str);
- str.Format(_T("dwPictAspectRatioX: %d"), vih.dwPictAspectRatioX);
- sl.AddTail(str);
- str.Format(_T("dwPictAspectRatioY: %d"), vih.dwPictAspectRatioY);
- sl.AddTail(str);
- str.Format(_T("dwControlFlags: 0x%08x"), vih.dwControlFlags);
- sl.AddTail(str);
- str.Format(_T("dwReserved2: 0x%08x"), vih.dwReserved2);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
- }
-
- if (formattype == FORMAT_MPEGVideo) {
- MPEG1VIDEOINFO& mvih = *(MPEG1VIDEOINFO*)pbFormat;
-
- sl.AddTail(_T("MPEG1VIDEOINFO:"));
- str.Format(_T("dwStartTimeCode: %d"), mvih.dwStartTimeCode);
- sl.AddTail(str);
- str.Format(_T("cbSequenceHeader: %d"), mvih.cbSequenceHeader);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
- } else if (formattype == FORMAT_MPEG2_VIDEO) {
- MPEG2VIDEOINFO& mvih = *(MPEG2VIDEOINFO*)pbFormat;
-
- sl.AddTail(_T("MPEG2VIDEOINFO:"));
- str.Format(_T("dwStartTimeCode: %d"), mvih.dwStartTimeCode);
- sl.AddTail(str);
- str.Format(_T("cbSequenceHeader: %d"), mvih.cbSequenceHeader);
- sl.AddTail(str);
- str.Format(_T("dwProfile: 0x%08x"), mvih.dwProfile);
- sl.AddTail(str);
- str.Format(_T("dwLevel: 0x%08x"), mvih.dwLevel);
- sl.AddTail(str);
- str.Format(_T("dwFlags: 0x%08x"), mvih.dwFlags);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
- }
-
- sl.AddTail(_T("BITMAPINFOHEADER:"));
- str.Format(_T("biSize: %d"), bih->biSize);
- sl.AddTail(str);
- str.Format(_T("biWidth: %d"), bih->biWidth);
- sl.AddTail(str);
- str.Format(_T("biHeight: %d"), bih->biHeight);
- sl.AddTail(str);
- str.Format(_T("biPlanes: %d"), bih->biPlanes);
- sl.AddTail(str);
- str.Format(_T("biBitCount: %d"), bih->biBitCount);
- sl.AddTail(str);
- if (bih->biCompression < 256) {
- str.Format(_T("biCompression: %d"), bih->biCompression);
- } else {
- str.Format(_T("biCompression: %4.4hs"), &bih->biCompression);
- }
- sl.AddTail(str);
- str.Format(_T("biSizeImage: %d"), bih->biSizeImage);
- sl.AddTail(str);
- str.Format(_T("biXPelsPerMeter: %d"), bih->biXPelsPerMeter);
- sl.AddTail(str);
- str.Format(_T("biYPelsPerMeter: %d"), bih->biYPelsPerMeter);
- sl.AddTail(str);
- str.Format(_T("biClrUsed: %d"), bih->biClrUsed);
- sl.AddTail(str);
- str.Format(_T("biClrImportant: %d"), bih->biClrImportant);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
- } else if (formattype == FORMAT_WaveFormatEx || formattype == FORMAT_WaveFormatExFFMPEG) {
- WAVEFORMATEX *pWfe = NULL;
- if (formattype == FORMAT_WaveFormatExFFMPEG) {
- fmtsize = sizeof(WAVEFORMATEXFFMPEG);
-
- WAVEFORMATEXFFMPEG *wfeff = (WAVEFORMATEXFFMPEG*)pbFormat;
- pWfe = &wfeff->wfex;
-
- sl.AddTail(_T("WAVEFORMATEXFFMPEG:"));
- str.Format(_T("nCodecId: 0x%04x"), wfeff->nCodecId);
- sl.AddTail(str);
- sl.AddTail(_T(""));
- } else {
- fmtsize = sizeof(WAVEFORMATEX);
- pWfe = (WAVEFORMATEX*)pbFormat;
- }
-
- WAVEFORMATEX& wfe = *pWfe;
-
- sl.AddTail(_T("WAVEFORMATEX:"));
- str.Format(_T("wFormatTag: 0x%04x"), wfe.wFormatTag);
- sl.AddTail(str);
- str.Format(_T("nChannels: %d"), wfe.nChannels);
- sl.AddTail(str);
- str.Format(_T("nSamplesPerSec: %d"), wfe.nSamplesPerSec);
- sl.AddTail(str);
- str.Format(_T("nAvgBytesPerSec: %d"), wfe.nAvgBytesPerSec);
- sl.AddTail(str);
- str.Format(_T("nBlockAlign: %d"), wfe.nBlockAlign);
- sl.AddTail(str);
- str.Format(_T("wBitsPerSample: %d"), wfe.wBitsPerSample);
- sl.AddTail(str);
- str.Format(_T("cbSize: %d (extra bytes)"), wfe.cbSize);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
-
- if (wfe.wFormatTag != WAVE_FORMAT_PCM && wfe.cbSize > 0 && formattype == FORMAT_WaveFormatEx) {
- if (wfe.wFormatTag == WAVE_FORMAT_EXTENSIBLE && wfe.cbSize == sizeof(WAVEFORMATEXTENSIBLE)-sizeof(WAVEFORMATEX)) {
- fmtsize = sizeof(WAVEFORMATEXTENSIBLE);
-
- WAVEFORMATEXTENSIBLE& wfe = *(WAVEFORMATEXTENSIBLE*)pbFormat;
-
- sl.AddTail(_T("WAVEFORMATEXTENSIBLE:"));
- if (wfe.Format.wBitsPerSample != 0) {
- str.Format(_T("wValidBitsPerSample: %d"), wfe.Samples.wValidBitsPerSample);
- } else {
- str.Format(_T("wSamplesPerBlock: %d"), wfe.Samples.wSamplesPerBlock);
- }
- sl.AddTail(str);
- str.Format(_T("dwChannelMask: 0x%08x"), wfe.dwChannelMask);
- sl.AddTail(str);
- str.Format(_T("SubFormat: %s"), CStringFromGUID(wfe.SubFormat));
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
- } else if (wfe.wFormatTag == WAVE_FORMAT_DOLBY_AC3 && wfe.cbSize == sizeof(DOLBYAC3WAVEFORMAT)-sizeof(WAVEFORMATEX)) {
- fmtsize = sizeof(DOLBYAC3WAVEFORMAT);
-
- DOLBYAC3WAVEFORMAT& wfe = *(DOLBYAC3WAVEFORMAT*)pbFormat;
-
- sl.AddTail(_T("DOLBYAC3WAVEFORMAT:"));
- str.Format(_T("bBigEndian: %d"), wfe.bBigEndian);
- sl.AddTail(str);
- str.Format(_T("bsid: %d"), wfe.bsid);
- sl.AddTail(str);
- str.Format(_T("lfeon: %d"), wfe.lfeon);
- sl.AddTail(str);
- str.Format(_T("copyrightb: %d"), wfe.copyrightb);
- sl.AddTail(str);
- str.Format(_T("nAuxBitsCode: %d"), wfe.nAuxBitsCode);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
- }
- }
- } else if (formattype == FORMAT_VorbisFormat) {
- fmtsize = sizeof(VORBISFORMAT);
-
- VORBISFORMAT& vf = *(VORBISFORMAT*)pbFormat;
-
- sl.AddTail(_T("VORBISFORMAT:"));
- str.Format(_T("nChannels: %d"), vf.nChannels);
- sl.AddTail(str);
- str.Format(_T("nSamplesPerSec: %d"), vf.nSamplesPerSec);
- sl.AddTail(str);
- str.Format(_T("nMinBitsPerSec: %d"), vf.nMinBitsPerSec);
- sl.AddTail(str);
- str.Format(_T("nAvgBitsPerSec: %d"), vf.nAvgBitsPerSec);
- sl.AddTail(str);
- str.Format(_T("nMaxBitsPerSec: %d"), vf.nMaxBitsPerSec);
- sl.AddTail(str);
- str.Format(_T("fQuality: %.3f"), vf.fQuality);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
- } else if (formattype == FORMAT_VorbisFormat2) {
- fmtsize = sizeof(VORBISFORMAT2);
-
- VORBISFORMAT2& vf = *(VORBISFORMAT2*)pbFormat;
-
- sl.AddTail(_T("VORBISFORMAT:"));
- str.Format(_T("Channels: %d"), vf.Channels);
- sl.AddTail(str);
- str.Format(_T("SamplesPerSec: %d"), vf.SamplesPerSec);
- sl.AddTail(str);
- str.Format(_T("BitsPerSample: %d"), vf.BitsPerSample);
- sl.AddTail(str);
- str.Format(_T("HeaderSize: {%d, %d, %d}"), vf.HeaderSize[0], vf.HeaderSize[1], vf.HeaderSize[2]);
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
- } else if (formattype == FORMAT_SubtitleInfo) {
- fmtsize = sizeof(SUBTITLEINFO);
-
- SUBTITLEINFO& si = *(SUBTITLEINFO*)pbFormat;
-
- sl.AddTail(_T("SUBTITLEINFO:"));
- str.Format(_T("dwOffset: %d"), si.dwOffset);
- sl.AddTail(str);
- str.Format(_T("IsoLang: %s"), CString(CStringA(si.IsoLang, sizeof(si.IsoLang)-1)));
- sl.AddTail(str);
- str.Format(_T("TrackName: %s"), CString(CStringW(si.TrackName, sizeof(si.TrackName)-1)));
- sl.AddTail(str);
-
- sl.AddTail(_T(""));
- }
-
- if (cbFormat > 0) {
- sl.AddTail(_T("pbFormat:"));
-
- for (ptrdiff_t i = 0, j = (cbFormat + 15) & ~15; i < j; i += 16) {
- str.Format(_T("%04x:"), i);
-
- for (ptrdiff_t k = i, l = min(i + 16, (int)cbFormat); k < l; k++) {
- CString byte;
- byte.Format(_T("%c%02x"), fmtsize > 0 && fmtsize == k ? '|' : ' ', pbFormat[k]);
- str += byte;
- }
-
- for (ptrdiff_t k = min(i + 16, (int)cbFormat), l = i + 16; k < l; k++) {
- str += _T(" ");
- }
-
- str += ' ';
-
- for (ptrdiff_t k = i, l = min(i + 16, (int)cbFormat); k < l; k++) {
- unsigned char c = (unsigned char)pbFormat[k];
- CStringA ch;
- ch.Format("%c", c >= 0x20 ? c : '.');
- str += ch;
- }
-
- sl.AddTail(str);
- }
-
- sl.AddTail(_T(""));
- }
+ CString str;
+
+ sl.RemoveAll();
+
+ int fmtsize = 0;
+
+ CString major = CStringFromGUID(majortype);
+ CString sub = CStringFromGUID(subtype);
+ CString format = CStringFromGUID(formattype);
+
+ sl.AddTail(ToString() + _T("\n"));
+
+ sl.AddTail(_T("AM_MEDIA_TYPE: "));
+ str.Format(_T("majortype: %s %s"), CString(GuidNames[majortype]), major);
+ sl.AddTail(str);
+ str.Format(_T("subtype: %s %s"), CString(GuidNames[subtype]), sub);
+ sl.AddTail(str);
+ str.Format(_T("formattype: %s %s"), CString(GuidNames[formattype]), format);
+ sl.AddTail(str);
+ str.Format(_T("bFixedSizeSamples: %d"), bFixedSizeSamples);
+ sl.AddTail(str);
+ str.Format(_T("bTemporalCompression: %d"), bTemporalCompression);
+ sl.AddTail(str);
+ str.Format(_T("lSampleSize: %d"), lSampleSize);
+ sl.AddTail(str);
+ str.Format(_T("cbFormat: %d"), cbFormat);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+
+ if (formattype == FORMAT_VideoInfo || formattype == FORMAT_VideoInfo2
+ || formattype == FORMAT_MPEGVideo || formattype == FORMAT_MPEG2_VIDEO) {
+ fmtsize =
+ formattype == FORMAT_VideoInfo ? sizeof(VIDEOINFOHEADER) :
+ formattype == FORMAT_VideoInfo2 ? sizeof(VIDEOINFOHEADER2) :
+ formattype == FORMAT_MPEGVideo ? sizeof(MPEG1VIDEOINFO) - 1 :
+ formattype == FORMAT_MPEG2_VIDEO ? sizeof(MPEG2VIDEOINFO) - 4 :
+ 0;
+
+ VIDEOINFOHEADER& vih = *(VIDEOINFOHEADER*)pbFormat;
+ BITMAPINFOHEADER* bih = &vih.bmiHeader;
+
+ sl.AddTail(_T("VIDEOINFOHEADER:"));
+ str.Format(_T("rcSource: (%d,%d)-(%d,%d)"), vih.rcSource.left, vih.rcSource.top, vih.rcSource.right, vih.rcSource.bottom);
+ sl.AddTail(str);
+ str.Format(_T("rcTarget: (%d,%d)-(%d,%d)"), vih.rcTarget.left, vih.rcTarget.top, vih.rcTarget.right, vih.rcTarget.bottom);
+ sl.AddTail(str);
+ str.Format(_T("dwBitRate: %d"), vih.dwBitRate);
+ sl.AddTail(str);
+ str.Format(_T("dwBitErrorRate: %d"), vih.dwBitErrorRate);
+ sl.AddTail(str);
+ str.Format(_T("AvgTimePerFrame: %I64d"), vih.AvgTimePerFrame);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+
+ if (formattype == FORMAT_VideoInfo2 || formattype == FORMAT_MPEG2_VIDEO) {
+ VIDEOINFOHEADER2& vih = *(VIDEOINFOHEADER2*)pbFormat;
+ bih = &vih.bmiHeader;
+
+ sl.AddTail(_T("VIDEOINFOHEADER2:"));
+ str.Format(_T("dwInterlaceFlags: 0x%08x"), vih.dwInterlaceFlags);
+ sl.AddTail(str);
+ str.Format(_T("dwCopyProtectFlags: 0x%08x"), vih.dwCopyProtectFlags);
+ sl.AddTail(str);
+ str.Format(_T("dwPictAspectRatioX: %d"), vih.dwPictAspectRatioX);
+ sl.AddTail(str);
+ str.Format(_T("dwPictAspectRatioY: %d"), vih.dwPictAspectRatioY);
+ sl.AddTail(str);
+ str.Format(_T("dwControlFlags: 0x%08x"), vih.dwControlFlags);
+ sl.AddTail(str);
+ str.Format(_T("dwReserved2: 0x%08x"), vih.dwReserved2);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+ }
+
+ if (formattype == FORMAT_MPEGVideo) {
+ MPEG1VIDEOINFO& mvih = *(MPEG1VIDEOINFO*)pbFormat;
+
+ sl.AddTail(_T("MPEG1VIDEOINFO:"));
+ str.Format(_T("dwStartTimeCode: %d"), mvih.dwStartTimeCode);
+ sl.AddTail(str);
+ str.Format(_T("cbSequenceHeader: %d"), mvih.cbSequenceHeader);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+ } else if (formattype == FORMAT_MPEG2_VIDEO) {
+ MPEG2VIDEOINFO& mvih = *(MPEG2VIDEOINFO*)pbFormat;
+
+ sl.AddTail(_T("MPEG2VIDEOINFO:"));
+ str.Format(_T("dwStartTimeCode: %d"), mvih.dwStartTimeCode);
+ sl.AddTail(str);
+ str.Format(_T("cbSequenceHeader: %d"), mvih.cbSequenceHeader);
+ sl.AddTail(str);
+ str.Format(_T("dwProfile: 0x%08x"), mvih.dwProfile);
+ sl.AddTail(str);
+ str.Format(_T("dwLevel: 0x%08x"), mvih.dwLevel);
+ sl.AddTail(str);
+ str.Format(_T("dwFlags: 0x%08x"), mvih.dwFlags);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+ }
+
+ sl.AddTail(_T("BITMAPINFOHEADER:"));
+ str.Format(_T("biSize: %d"), bih->biSize);
+ sl.AddTail(str);
+ str.Format(_T("biWidth: %d"), bih->biWidth);
+ sl.AddTail(str);
+ str.Format(_T("biHeight: %d"), bih->biHeight);
+ sl.AddTail(str);
+ str.Format(_T("biPlanes: %d"), bih->biPlanes);
+ sl.AddTail(str);
+ str.Format(_T("biBitCount: %d"), bih->biBitCount);
+ sl.AddTail(str);
+ if (bih->biCompression < 256) {
+ str.Format(_T("biCompression: %d"), bih->biCompression);
+ } else {
+ str.Format(_T("biCompression: %4.4hs"), &bih->biCompression);
+ }
+ sl.AddTail(str);
+ str.Format(_T("biSizeImage: %d"), bih->biSizeImage);
+ sl.AddTail(str);
+ str.Format(_T("biXPelsPerMeter: %d"), bih->biXPelsPerMeter);
+ sl.AddTail(str);
+ str.Format(_T("biYPelsPerMeter: %d"), bih->biYPelsPerMeter);
+ sl.AddTail(str);
+ str.Format(_T("biClrUsed: %d"), bih->biClrUsed);
+ sl.AddTail(str);
+ str.Format(_T("biClrImportant: %d"), bih->biClrImportant);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+ } else if (formattype == FORMAT_WaveFormatEx || formattype == FORMAT_WaveFormatExFFMPEG) {
+ WAVEFORMATEX* pWfe = NULL;
+ if (formattype == FORMAT_WaveFormatExFFMPEG) {
+ fmtsize = sizeof(WAVEFORMATEXFFMPEG);
+
+ WAVEFORMATEXFFMPEG* wfeff = (WAVEFORMATEXFFMPEG*)pbFormat;
+ pWfe = &wfeff->wfex;
+
+ sl.AddTail(_T("WAVEFORMATEXFFMPEG:"));
+ str.Format(_T("nCodecId: 0x%04x"), wfeff->nCodecId);
+ sl.AddTail(str);
+ sl.AddTail(_T(""));
+ } else {
+ fmtsize = sizeof(WAVEFORMATEX);
+ pWfe = (WAVEFORMATEX*)pbFormat;
+ }
+
+ WAVEFORMATEX& wfe = *pWfe;
+
+ sl.AddTail(_T("WAVEFORMATEX:"));
+ str.Format(_T("wFormatTag: 0x%04x"), wfe.wFormatTag);
+ sl.AddTail(str);
+ str.Format(_T("nChannels: %d"), wfe.nChannels);
+ sl.AddTail(str);
+ str.Format(_T("nSamplesPerSec: %d"), wfe.nSamplesPerSec);
+ sl.AddTail(str);
+ str.Format(_T("nAvgBytesPerSec: %d"), wfe.nAvgBytesPerSec);
+ sl.AddTail(str);
+ str.Format(_T("nBlockAlign: %d"), wfe.nBlockAlign);
+ sl.AddTail(str);
+ str.Format(_T("wBitsPerSample: %d"), wfe.wBitsPerSample);
+ sl.AddTail(str);
+ str.Format(_T("cbSize: %d (extra bytes)"), wfe.cbSize);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+
+ if (wfe.wFormatTag != WAVE_FORMAT_PCM && wfe.cbSize > 0 && formattype == FORMAT_WaveFormatEx) {
+ if (wfe.wFormatTag == WAVE_FORMAT_EXTENSIBLE && wfe.cbSize == sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX)) {
+ fmtsize = sizeof(WAVEFORMATEXTENSIBLE);
+
+ WAVEFORMATEXTENSIBLE& wfe = *(WAVEFORMATEXTENSIBLE*)pbFormat;
+
+ sl.AddTail(_T("WAVEFORMATEXTENSIBLE:"));
+ if (wfe.Format.wBitsPerSample != 0) {
+ str.Format(_T("wValidBitsPerSample: %d"), wfe.Samples.wValidBitsPerSample);
+ } else {
+ str.Format(_T("wSamplesPerBlock: %d"), wfe.Samples.wSamplesPerBlock);
+ }
+ sl.AddTail(str);
+ str.Format(_T("dwChannelMask: 0x%08x"), wfe.dwChannelMask);
+ sl.AddTail(str);
+ str.Format(_T("SubFormat: %s"), CStringFromGUID(wfe.SubFormat));
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+ } else if (wfe.wFormatTag == WAVE_FORMAT_DOLBY_AC3 && wfe.cbSize == sizeof(DOLBYAC3WAVEFORMAT) - sizeof(WAVEFORMATEX)) {
+ fmtsize = sizeof(DOLBYAC3WAVEFORMAT);
+
+ DOLBYAC3WAVEFORMAT& wfe = *(DOLBYAC3WAVEFORMAT*)pbFormat;
+
+ sl.AddTail(_T("DOLBYAC3WAVEFORMAT:"));
+ str.Format(_T("bBigEndian: %d"), wfe.bBigEndian);
+ sl.AddTail(str);
+ str.Format(_T("bsid: %d"), wfe.bsid);
+ sl.AddTail(str);
+ str.Format(_T("lfeon: %d"), wfe.lfeon);
+ sl.AddTail(str);
+ str.Format(_T("copyrightb: %d"), wfe.copyrightb);
+ sl.AddTail(str);
+ str.Format(_T("nAuxBitsCode: %d"), wfe.nAuxBitsCode);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+ }
+ }
+ } else if (formattype == FORMAT_VorbisFormat) {
+ fmtsize = sizeof(VORBISFORMAT);
+
+ VORBISFORMAT& vf = *(VORBISFORMAT*)pbFormat;
+
+ sl.AddTail(_T("VORBISFORMAT:"));
+ str.Format(_T("nChannels: %d"), vf.nChannels);
+ sl.AddTail(str);
+ str.Format(_T("nSamplesPerSec: %d"), vf.nSamplesPerSec);
+ sl.AddTail(str);
+ str.Format(_T("nMinBitsPerSec: %d"), vf.nMinBitsPerSec);
+ sl.AddTail(str);
+ str.Format(_T("nAvgBitsPerSec: %d"), vf.nAvgBitsPerSec);
+ sl.AddTail(str);
+ str.Format(_T("nMaxBitsPerSec: %d"), vf.nMaxBitsPerSec);
+ sl.AddTail(str);
+ str.Format(_T("fQuality: %.3f"), vf.fQuality);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+ } else if (formattype == FORMAT_VorbisFormat2) {
+ fmtsize = sizeof(VORBISFORMAT2);
+
+ VORBISFORMAT2& vf = *(VORBISFORMAT2*)pbFormat;
+
+ sl.AddTail(_T("VORBISFORMAT:"));
+ str.Format(_T("Channels: %d"), vf.Channels);
+ sl.AddTail(str);
+ str.Format(_T("SamplesPerSec: %d"), vf.SamplesPerSec);
+ sl.AddTail(str);
+ str.Format(_T("BitsPerSample: %d"), vf.BitsPerSample);
+ sl.AddTail(str);
+ str.Format(_T("HeaderSize: {%d, %d, %d}"), vf.HeaderSize[0], vf.HeaderSize[1], vf.HeaderSize[2]);
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+ } else if (formattype == FORMAT_SubtitleInfo) {
+ fmtsize = sizeof(SUBTITLEINFO);
+
+ SUBTITLEINFO& si = *(SUBTITLEINFO*)pbFormat;
+
+ sl.AddTail(_T("SUBTITLEINFO:"));
+ str.Format(_T("dwOffset: %d"), si.dwOffset);
+ sl.AddTail(str);
+ str.Format(_T("IsoLang: %s"), CString(CStringA(si.IsoLang, sizeof(si.IsoLang) - 1)));
+ sl.AddTail(str);
+ str.Format(_T("TrackName: %s"), CString(CStringW(si.TrackName, sizeof(si.TrackName) - 1)));
+ sl.AddTail(str);
+
+ sl.AddTail(_T(""));
+ }
+
+ if (cbFormat > 0) {
+ sl.AddTail(_T("pbFormat:"));
+
+ for (ptrdiff_t i = 0, j = (cbFormat + 15) & ~15; i < j; i += 16) {
+ str.Format(_T("%04x:"), i);
+
+ for (ptrdiff_t k = i, l = min(i + 16, (int)cbFormat); k < l; k++) {
+ CString byte;
+ byte.Format(_T("%c%02x"), fmtsize > 0 && fmtsize == k ? '|' : ' ', pbFormat[k]);
+ str += byte;
+ }
+
+ for (ptrdiff_t k = min(i + 16, (int)cbFormat), l = i + 16; k < l; k++) {
+ str += _T(" ");
+ }
+
+ str += ' ';
+
+ for (ptrdiff_t k = i, l = min(i + 16, (int)cbFormat); k < l; k++) {
+ unsigned char c = (unsigned char)pbFormat[k];
+ CStringA ch;
+ ch.Format("%c", c >= 0x20 ? c : '.');
+ str += ch;
+ }
+
+ sl.AddTail(str);
+ }
+
+ sl.AddTail(_T(""));
+ }
}
diff --git a/src/DSUtil/MediaTypeEx.h b/src/DSUtil/MediaTypeEx.h
index 6e79756c5..bf9d09449 100644
--- a/src/DSUtil/MediaTypeEx.h
+++ b/src/DSUtil/MediaTypeEx.h
@@ -26,16 +26,16 @@
class CMediaTypeEx : public CMediaType
{
public:
- CMediaTypeEx();
- CMediaTypeEx(const CMediaType& mt) {
- CMediaType::operator = (mt);
- }
+ CMediaTypeEx();
+ CMediaTypeEx(const CMediaType& mt) {
+ CMediaType::operator = (mt);
+ }
- CString ToString(IPin* pPin = NULL);
+ CString ToString(IPin* pPin = NULL);
- static CString GetVideoCodecName(const GUID& subtype, DWORD biCompression);
- static CString GetAudioCodecName(const GUID& subtype, WORD wFormatTag);
- static CString GetSubtitleCodecName(const GUID& subtype);
+ static CString GetVideoCodecName(const GUID& subtype, DWORD biCompression);
+ static CString GetAudioCodecName(const GUID& subtype, WORD wFormatTag);
+ static CString GetSubtitleCodecName(const GUID& subtype);
- void Dump(CAtlList<CString>& sl);
+ void Dump(CAtlList<CString>& sl);
};
diff --git a/src/DSUtil/MediaTypes.cpp b/src/DSUtil/MediaTypes.cpp
index bd0004d15..f01b69918 100644
--- a/src/DSUtil/MediaTypes.cpp
+++ b/src/DSUtil/MediaTypes.cpp
@@ -34,353 +34,353 @@
#define BIH_SIZE (sizeof(BITMAPINFOHEADER))
VIH vihs[] = {
- // YUY2
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, mmioFOURCC('Y','U','Y','2'), 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH_NORMAL, // size
- &MEDIASUBTYPE_YUY2 // subtype
- },
- // YV12
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('Y','V','1','2'), 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH_NORMAL, // size
- &MEDIASUBTYPE_YV12 // subtype
- },
- // I420
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I','4','2','0'), 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH_NORMAL, // size
- &MEDIASUBTYPE_I420 // subtype
- },
- // IYUV
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I','Y','U','V'), 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH_NORMAL, // size
- &MEDIASUBTYPE_IYUV // subtype
- },
- // 8888 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH_NORMAL, // size
- &MEDIASUBTYPE_RGB32 // subtype
- },
- // 8888 bitf
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
- VIH_BITFIELDS, // size
- &MEDIASUBTYPE_RGB32 // subtype
- },
- // A888 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH_NORMAL, // size
- &MEDIASUBTYPE_ARGB32 // subtype
- },
- // A888 bitf (I'm not sure if this exist...)
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
- VIH_BITFIELDS, // size
- &MEDIASUBTYPE_ARGB32 // subtype
- },
- // 888 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 24, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH_NORMAL, // size
- &MEDIASUBTYPE_RGB24 // subtype
- },
- // 888 bitf
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 24, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
- VIH_BITFIELDS, // size
- &MEDIASUBTYPE_RGB24 // subtype
- },
- // 565 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH_NORMAL, // size
- &MEDIASUBTYPE_RGB565 // subtype
- },
- // 565 bitf
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0xF800, 0x07E0, 0x001F}, // mask[3]
- VIH_BITFIELDS, // size
- &MEDIASUBTYPE_RGB565 // subtype
- },
- // 555 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH_NORMAL, // size
- &MEDIASUBTYPE_RGB555 // subtype
- },
- // 555 bitf
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0x7C00, 0x03E0, 0x001F}, // mask[3]
- VIH_BITFIELDS, // size
- &MEDIASUBTYPE_RGB555 // subtype
- },
+ // YUY2
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, mmioFOURCC('Y', 'U', 'Y', '2'), 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH_NORMAL, // size
+ &MEDIASUBTYPE_YUY2 // subtype
+ },
+ // YV12
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('Y', 'V', '1', '2'), 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH_NORMAL, // size
+ &MEDIASUBTYPE_YV12 // subtype
+ },
+ // I420
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I', '4', '2', '0'), 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH_NORMAL, // size
+ &MEDIASUBTYPE_I420 // subtype
+ },
+ // IYUV
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I', 'Y', 'U', 'V'), 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH_NORMAL, // size
+ &MEDIASUBTYPE_IYUV // subtype
+ },
+ // 8888 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH_NORMAL, // size
+ &MEDIASUBTYPE_RGB32 // subtype
+ },
+ // 8888 bitf
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
+ VIH_BITFIELDS, // size
+ &MEDIASUBTYPE_RGB32 // subtype
+ },
+ // A888 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH_NORMAL, // size
+ &MEDIASUBTYPE_ARGB32 // subtype
+ },
+ // A888 bitf (I'm not sure if this exist...)
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
+ VIH_BITFIELDS, // size
+ &MEDIASUBTYPE_ARGB32 // subtype
+ },
+ // 888 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 24, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH_NORMAL, // size
+ &MEDIASUBTYPE_RGB24 // subtype
+ },
+ // 888 bitf
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 24, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
+ VIH_BITFIELDS, // size
+ &MEDIASUBTYPE_RGB24 // subtype
+ },
+ // 565 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH_NORMAL, // size
+ &MEDIASUBTYPE_RGB565 // subtype
+ },
+ // 565 bitf
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0xF800, 0x07E0, 0x001F}, // mask[3]
+ VIH_BITFIELDS, // size
+ &MEDIASUBTYPE_RGB565 // subtype
+ },
+ // 555 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH_NORMAL, // size
+ &MEDIASUBTYPE_RGB555 // subtype
+ },
+ // 555 bitf
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0x7C00, 0x03E0, 0x001F}, // mask[3]
+ VIH_BITFIELDS, // size
+ &MEDIASUBTYPE_RGB555 // subtype
+ },
};
VIH2 vih2s[] = {
- // YUY2
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, mmioFOURCC('Y','U','Y','2'), 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH2_NORMAL, // size
- &MEDIASUBTYPE_YUY2 // subtype
- },
- // YV12
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('Y','V','1','2'), 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH2_NORMAL, // size
- &MEDIASUBTYPE_YV12 // subtype
- },
- // I420
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I','4','2','0'), 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH2_NORMAL, // size
- &MEDIASUBTYPE_I420 // subtype
- },
- // IYUV
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I','Y','U','V'), 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH2_NORMAL, // size
- &MEDIASUBTYPE_IYUV // subtype
- },
- // 8888 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH2_NORMAL, // size
- &MEDIASUBTYPE_RGB32 // subtype
- },
- // 8888 bitf
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
- VIH2_BITFIELDS, // size
- &MEDIASUBTYPE_RGB32 // subtype
- },
- // A888 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH2_NORMAL, // size
- &MEDIASUBTYPE_ARGB32 // subtype
- },
- // A888 bitf (I'm not sure if this exist...)
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
- VIH2_BITFIELDS, // size
- &MEDIASUBTYPE_ARGB32 // subtype
- },
- // 888 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 24, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH2_NORMAL, // size
- &MEDIASUBTYPE_RGB24 // subtype
- },
- // 888 bitf
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 24, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
- VIH2_BITFIELDS, // size
- &MEDIASUBTYPE_RGB24 // subtype
- },
- // 565 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH2_NORMAL, // size
- &MEDIASUBTYPE_RGB565 // subtype
- },
- // 565 bitf
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0xF800, 0x07E0, 0x001F}, // mask[3]
- VIH2_BITFIELDS, // size
- &MEDIASUBTYPE_RGB565 // subtype
- },
- // 555 normal
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0, 0, 0}, // mask[3]
- VIH2_NORMAL, // size
- &MEDIASUBTYPE_RGB555 // subtype
- },
- // 555 bitf
- {
- {
- {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
- },
- {0x7C00, 0x03E0, 0x001F}, // mask[3]
- VIH2_BITFIELDS, // size
- &MEDIASUBTYPE_RGB555 // subtype
- },
+ // YUY2
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, mmioFOURCC('Y', 'U', 'Y', '2'), 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH2_NORMAL, // size
+ &MEDIASUBTYPE_YUY2 // subtype
+ },
+ // YV12
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('Y', 'V', '1', '2'), 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH2_NORMAL, // size
+ &MEDIASUBTYPE_YV12 // subtype
+ },
+ // I420
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I', '4', '2', '0'), 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH2_NORMAL, // size
+ &MEDIASUBTYPE_I420 // subtype
+ },
+ // IYUV
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 12, mmioFOURCC('I', 'Y', 'U', 'V'), 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH2_NORMAL, // size
+ &MEDIASUBTYPE_IYUV // subtype
+ },
+ // 8888 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH2_NORMAL, // size
+ &MEDIASUBTYPE_RGB32 // subtype
+ },
+ // 8888 bitf
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
+ VIH2_BITFIELDS, // size
+ &MEDIASUBTYPE_RGB32 // subtype
+ },
+ // A888 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 32, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH2_NORMAL, // size
+ &MEDIASUBTYPE_ARGB32 // subtype
+ },
+ // A888 bitf (I'm not sure if this exist...)
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
+ VIH2_BITFIELDS, // size
+ &MEDIASUBTYPE_ARGB32 // subtype
+ },
+ // 888 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 24, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH2_NORMAL, // size
+ &MEDIASUBTYPE_RGB24 // subtype
+ },
+ // 888 bitf
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 24, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0xFF0000, 0x00FF00, 0x0000FF}, // mask[3]
+ VIH2_BITFIELDS, // size
+ &MEDIASUBTYPE_RGB24 // subtype
+ },
+ // 565 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH2_NORMAL, // size
+ &MEDIASUBTYPE_RGB565 // subtype
+ },
+ // 565 bitf
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0xF800, 0x07E0, 0x001F}, // mask[3]
+ VIH2_BITFIELDS, // size
+ &MEDIASUBTYPE_RGB565 // subtype
+ },
+ // 555 normal
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, BI_RGB, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0, 0, 0}, // mask[3]
+ VIH2_NORMAL, // size
+ &MEDIASUBTYPE_RGB555 // subtype
+ },
+ // 555 bitf
+ {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ {BIH_SIZE, 0, 0, 1, 16, BI_BITFIELDS, 0, 0, 0, 0, 0} // bmiHeader
+ },
+ {0x7C00, 0x03E0, 0x001F}, // mask[3]
+ VIH2_BITFIELDS, // size
+ &MEDIASUBTYPE_RGB555 // subtype
+ },
};
UINT VIHSIZE = _countof(vihs);
CString VIH2String(int i)
{
- CString ret = CString(GuidNames[*vihs[i].subtype]);
- if (!ret.Left(13).CompareNoCase(_T("MEDIASUBTYPE_"))) {
- ret = ret.Mid(13);
- }
- if (vihs[i].vih.bmiHeader.biCompression == 3) {
- ret += _T(" BITF");
- }
- if (*vihs[i].subtype == MEDIASUBTYPE_I420) {
- ret = _T("I420"); // FIXME
- }
- return ret;
+ CString ret = CString(GuidNames[*vihs[i].subtype]);
+ if (!ret.Left(13).CompareNoCase(_T("MEDIASUBTYPE_"))) {
+ ret = ret.Mid(13);
+ }
+ if (vihs[i].vih.bmiHeader.biCompression == 3) {
+ ret += _T(" BITF");
+ }
+ if (*vihs[i].subtype == MEDIASUBTYPE_I420) {
+ ret = _T("I420"); // FIXME
+ }
+ return ret;
}
CString Subtype2String(const GUID& subtype)
{
- CString ret = CString(GuidNames[subtype]);
- if (!ret.Left(13).CompareNoCase(_T("MEDIASUBTYPE_"))) {
- ret = ret.Mid(13);
- }
- if (subtype == MEDIASUBTYPE_I420) {
- ret = _T("I420"); // FIXME
- }
- return ret;
+ CString ret = CString(GuidNames[subtype]);
+ if (!ret.Left(13).CompareNoCase(_T("MEDIASUBTYPE_"))) {
+ ret = ret.Mid(13);
+ }
+ if (subtype == MEDIASUBTYPE_I420) {
+ ret = _T("I420"); // FIXME
+ }
+ return ret;
}
void CorrectMediaType(AM_MEDIA_TYPE* pmt)
{
- if (!pmt) {
- return;
- }
+ if (!pmt) {
+ return;
+ }
- CMediaType mt(*pmt);
+ CMediaType mt(*pmt);
- if (mt.formattype == FORMAT_VideoInfo) {
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mt.pbFormat;
+ if (mt.formattype == FORMAT_VideoInfo) {
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mt.pbFormat;
- for (UINT i = 0; i < VIHSIZE; i++) {
- if (mt.subtype == *vihs[i].subtype
- && vih->bmiHeader.biCompression == vihs[i].vih.bmiHeader.biCompression) {
- mt.AllocFormatBuffer(vihs[i].size);
- memcpy(mt.pbFormat, &vihs[i], vihs[i].size);
- memcpy(mt.pbFormat, pmt->pbFormat, sizeof(VIDEOINFOHEADER));
- break;
- }
- }
- } else if (mt.formattype == FORMAT_VideoInfo2) {
- VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.pbFormat;
+ for (UINT i = 0; i < VIHSIZE; i++) {
+ if (mt.subtype == *vihs[i].subtype
+ && vih->bmiHeader.biCompression == vihs[i].vih.bmiHeader.biCompression) {
+ mt.AllocFormatBuffer(vihs[i].size);
+ memcpy(mt.pbFormat, &vihs[i], vihs[i].size);
+ memcpy(mt.pbFormat, pmt->pbFormat, sizeof(VIDEOINFOHEADER));
+ break;
+ }
+ }
+ } else if (mt.formattype == FORMAT_VideoInfo2) {
+ VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.pbFormat;
- for (UINT i = 0; i < VIHSIZE; i++) {
- if (mt.subtype == *vih2s[i].subtype
- && vih2->bmiHeader.biCompression == vih2s[i].vih.bmiHeader.biCompression) {
- mt.AllocFormatBuffer(vih2s[i].size);
- memcpy(mt.pbFormat, &vih2s[i], vih2s[i].size);
- memcpy(mt.pbFormat, pmt->pbFormat, sizeof(VIDEOINFOHEADER2));
- break;
- }
- }
- }
+ for (UINT i = 0; i < VIHSIZE; i++) {
+ if (mt.subtype == *vih2s[i].subtype
+ && vih2->bmiHeader.biCompression == vih2s[i].vih.bmiHeader.biCompression) {
+ mt.AllocFormatBuffer(vih2s[i].size);
+ memcpy(mt.pbFormat, &vih2s[i], vih2s[i].size);
+ memcpy(mt.pbFormat, pmt->pbFormat, sizeof(VIDEOINFOHEADER2));
+ break;
+ }
+ }
+ }
- CopyMediaType(pmt, &mt);
+ CopyMediaType(pmt, &mt);
}
diff --git a/src/DSUtil/MediaTypes.h b/src/DSUtil/MediaTypes.h
index d08e0d3ba..784f574ee 100644
--- a/src/DSUtil/MediaTypes.h
+++ b/src/DSUtil/MediaTypes.h
@@ -25,17 +25,17 @@
#pragma pack(1)
struct VIH {
- VIDEOINFOHEADER vih;
- UINT mask[3];
- int size;
- const GUID* subtype;
+ VIDEOINFOHEADER vih;
+ UINT mask[3];
+ int size;
+ const GUID* subtype;
};
struct VIH2 {
- VIDEOINFOHEADER2 vih;
- UINT mask[3];
- int size;
- const GUID* subtype;
+ VIDEOINFOHEADER2 vih;
+ UINT mask[3];
+ int size;
+ const GUID* subtype;
};
#pragma pack()
diff --git a/src/DSUtil/Mpeg2Def.h b/src/DSUtil/Mpeg2Def.h
index 886c949b1..97e77f58c 100644
--- a/src/DSUtil/Mpeg2Def.h
+++ b/src/DSUtil/Mpeg2Def.h
@@ -23,142 +23,142 @@
#pragma once
enum PES_STREAM_TYPE {
- INVALID = 0,
- VIDEO_STREAM_MPEG1 = 0x01,
- VIDEO_STREAM_MPEG2 = 0x02, // ITU-T Rec. H.262 | ISO/IEC 13818-2 Video or ISO/IEC 11172-2 constrained parameter video stream
- AUDIO_STREAM_MPEG1 = 0x03, // all layers including mp3 (ISO/IEC 11172-3 Audio)
- AUDIO_STREAM_MPEG2 = 0x04, // ISO/IEC 13818-3 Audio
- PRIVATE = 0x05, // ITU-T Rec. H.222.0 | ISO/IEC 13818-1 private_sections
- PES_PRIVATE = 0x06, // ITU-T Rec. H.222.0 | ISO/IEC 13818-1 PES packets containing private data
- PES_07 = 0x07, // ISO/IEC 13522 MHEG
- PES_08 = 0x08, // ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Annex A DSM-CC
- PES_09 = 0x09, // ITU-T Rec. H.222.1
- PES_0a = 0x0a, // ISO/IEC 13818-6 type A
- PES_0b = 0x0b, // ISO/IEC 13818-6 type B
- PES_0c = 0x0c, // ISO/IEC 13818-6 type C
- PES_0d = 0x0d, // ISO/IEC 13818-6 type D
- PES_0e = 0x0e, // ITU-T Rec. H.222.0 | ISO/IEC 13818-1 auxiliary
- AUDIO_STREAM_AAC = 0x0f, // ISO/IEC 13818-7 Audio with ADTS transport syntax
- PES_10 = 0x10, // ISO/IEC 14496-2 Visual
- AUDIO_STREAM_AAC_LATM = 0x11, // ISO/IEC 14496-3 Audio with the LATM transport syntax as defined in ISO/IEC 14496-3 / AMD 1
- PES_12 = 0x12, // ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried in PES packets
- PES_13 = 0x13, // ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried in ISO/IEC14496_sections.
- PES_14 = 0x14, // ISO/IEC 13818-6 Synchronized Download Protocol
- METADATA_PES_PACKETS = 0x15, // Metadata carried in PES packets
- METADATA_SECTIONS = 0X16, // Metadata carried in metadata_sections
- DATA_CAROUSEL = 0x17, // Metadata carried in ISO/IEC 13818-6 Data Carousel
- OBJECT_CAROUSEL = 0x18, // Metadata carried in ISO/IEC 13818-6 Object Carousel
- SYNCHRONIZED_DOWNLOAD = 0x19, // Metadata carried in ISO/IEC 13818-6 Synchronized Download Protocol
- IPMP = 0x1A, // IPMP stream (defined in ISO/IEC 13818-11, MPEG-2 IPMP)
- VIDEO_STREAM_H264 = 0x1B, // AVC video stream conforming to one or more profiles defined in Annex A of ITU-T Rec. H.264
- PES_1C = 0x1C, // ISO/IEC 14496-3 Audio, without using any additional transport syntax, such as DST, ALS and SLS
- TEXT = 0x1D, // ISO/IEC 14496-17 Text
- AUXILIARY_VIDEO_STREAM = 0x1E, // Auxiliary video stream as defined in ISO/IEC 23002-3
- SVC_H264 = 0x1F, // SVC video sub-bitstream of an AVC video stream conforming to one or more profiles defined in Annex G of ITU-T Rec. H.264 | ISO/IEC 14496-10
- MVC_H264 = 0x20, // MVC video sub-bitstream of an AVC video stream conforming to one or more profiles defined in Annex H of ITU-T Rec. H.264 | ISO/IEC 14496-10
- AUDIO_STREAM_LPCM = 0x80,
- AUDIO_STREAM_AC3 = 0x81,
- AUDIO_STREAM_DTS = 0x82,
- AUDIO_STREAM_AC3_TRUE_HD = 0x83,
- AUDIO_STREAM_AC3_PLUS = 0x84,
- AUDIO_STREAM_DTS_HD = 0x85,
- AUDIO_STREAM_DTS_HD_MASTER_AUDIO = 0x86,
- PRESENTATION_GRAPHICS_STREAM = 0x90,
- INTERACTIVE_GRAPHICS_STREAM = 0x91,
- SUBTITLE_STREAM = 0x92,
- SECONDARY_AUDIO_AC3_PLUS = 0xa1,
- SECONDARY_AUDIO_DTS_HD = 0xa2,
- VIDEO_STREAM_VC1 = 0xea
+ INVALID = 0,
+ VIDEO_STREAM_MPEG1 = 0x01,
+ VIDEO_STREAM_MPEG2 = 0x02, // ITU-T Rec. H.262 | ISO/IEC 13818-2 Video or ISO/IEC 11172-2 constrained parameter video stream
+ AUDIO_STREAM_MPEG1 = 0x03, // all layers including mp3 (ISO/IEC 11172-3 Audio)
+ AUDIO_STREAM_MPEG2 = 0x04, // ISO/IEC 13818-3 Audio
+ PRIVATE = 0x05, // ITU-T Rec. H.222.0 | ISO/IEC 13818-1 private_sections
+ PES_PRIVATE = 0x06, // ITU-T Rec. H.222.0 | ISO/IEC 13818-1 PES packets containing private data
+ PES_07 = 0x07, // ISO/IEC 13522 MHEG
+ PES_08 = 0x08, // ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Annex A DSM-CC
+ PES_09 = 0x09, // ITU-T Rec. H.222.1
+ PES_0a = 0x0a, // ISO/IEC 13818-6 type A
+ PES_0b = 0x0b, // ISO/IEC 13818-6 type B
+ PES_0c = 0x0c, // ISO/IEC 13818-6 type C
+ PES_0d = 0x0d, // ISO/IEC 13818-6 type D
+ PES_0e = 0x0e, // ITU-T Rec. H.222.0 | ISO/IEC 13818-1 auxiliary
+ AUDIO_STREAM_AAC = 0x0f, // ISO/IEC 13818-7 Audio with ADTS transport syntax
+ PES_10 = 0x10, // ISO/IEC 14496-2 Visual
+ AUDIO_STREAM_AAC_LATM = 0x11, // ISO/IEC 14496-3 Audio with the LATM transport syntax as defined in ISO/IEC 14496-3 / AMD 1
+ PES_12 = 0x12, // ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried in PES packets
+ PES_13 = 0x13, // ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried in ISO/IEC14496_sections.
+ PES_14 = 0x14, // ISO/IEC 13818-6 Synchronized Download Protocol
+ METADATA_PES_PACKETS = 0x15, // Metadata carried in PES packets
+ METADATA_SECTIONS = 0X16, // Metadata carried in metadata_sections
+ DATA_CAROUSEL = 0x17, // Metadata carried in ISO/IEC 13818-6 Data Carousel
+ OBJECT_CAROUSEL = 0x18, // Metadata carried in ISO/IEC 13818-6 Object Carousel
+ SYNCHRONIZED_DOWNLOAD = 0x19, // Metadata carried in ISO/IEC 13818-6 Synchronized Download Protocol
+ IPMP = 0x1A, // IPMP stream (defined in ISO/IEC 13818-11, MPEG-2 IPMP)
+ VIDEO_STREAM_H264 = 0x1B, // AVC video stream conforming to one or more profiles defined in Annex A of ITU-T Rec. H.264
+ PES_1C = 0x1C, // ISO/IEC 14496-3 Audio, without using any additional transport syntax, such as DST, ALS and SLS
+ TEXT = 0x1D, // ISO/IEC 14496-17 Text
+ AUXILIARY_VIDEO_STREAM = 0x1E, // Auxiliary video stream as defined in ISO/IEC 23002-3
+ SVC_H264 = 0x1F, // SVC video sub-bitstream of an AVC video stream conforming to one or more profiles defined in Annex G of ITU-T Rec. H.264 | ISO/IEC 14496-10
+ MVC_H264 = 0x20, // MVC video sub-bitstream of an AVC video stream conforming to one or more profiles defined in Annex H of ITU-T Rec. H.264 | ISO/IEC 14496-10
+ AUDIO_STREAM_LPCM = 0x80,
+ AUDIO_STREAM_AC3 = 0x81,
+ AUDIO_STREAM_DTS = 0x82,
+ AUDIO_STREAM_AC3_TRUE_HD = 0x83,
+ AUDIO_STREAM_AC3_PLUS = 0x84,
+ AUDIO_STREAM_DTS_HD = 0x85,
+ AUDIO_STREAM_DTS_HD_MASTER_AUDIO = 0x86,
+ PRESENTATION_GRAPHICS_STREAM = 0x90,
+ INTERACTIVE_GRAPHICS_STREAM = 0x91,
+ SUBTITLE_STREAM = 0x92,
+ SECONDARY_AUDIO_AC3_PLUS = 0xa1,
+ SECONDARY_AUDIO_DTS_HD = 0xa2,
+ VIDEO_STREAM_VC1 = 0xea
};
enum MPEG2_PID {
- PID_PAT = 0x000, // Program Association Table
- PID_CAT = 0x001, // Conditional Access Table
- PID_TSDT = 0x002, // Transport Stream Description Table
- PID_NIT = 0x010, // Network Identification Table
- PID_BAT = 0x011, // Bouquet Association Table ou ...
- PID_SDT = 0x011, // Service Description Table
- PID_EIT = 0x012, // Event Information Table
- PID_RST = 0x013, // Running Status Tection
- PID_TDT = 0x014, // Time and Date Table ou ...
- PID_TOT = 0x014, // Time Offset Table
- PID_SFN = 0x015, // SFN/MIP synchronisation
- PID_DIT = 0x01e,
- PID_SIT = 0x01f,
- PID_NULL = 0x1fff // Null packet
+ PID_PAT = 0x000, // Program Association Table
+ PID_CAT = 0x001, // Conditional Access Table
+ PID_TSDT = 0x002, // Transport Stream Description Table
+ PID_NIT = 0x010, // Network Identification Table
+ PID_BAT = 0x011, // Bouquet Association Table ou ...
+ PID_SDT = 0x011, // Service Description Table
+ PID_EIT = 0x012, // Event Information Table
+ PID_RST = 0x013, // Running Status Tection
+ PID_TDT = 0x014, // Time and Date Table ou ...
+ PID_TOT = 0x014, // Time Offset Table
+ PID_SFN = 0x015, // SFN/MIP synchronisation
+ PID_DIT = 0x01e,
+ PID_SIT = 0x01f,
+ PID_NULL = 0x1fff // Null packet
};
enum DVB_SI {
- SI_undef = -1,
- SI_PAT = 0x00,
- SI_CAT = 0x01,
- SI_PMT = 0x02,
- SI_DSMCC_a = 0x3a,
- SI_DSMCC_b = 0x3b,
- SI_DSMCC_c = 0x3c,
- SI_DSMCC_d = 0x3d,
- SI_DSMCC_e = 0x3e,
- SI_DSMCC_f = 0x3f,
- SI_NIT = 0x40,
- SI_SDT = 0x42,
- SI_EIT_act = 0x4e,
- SI_EIT_oth = 0x4f,
- SI_EIT_as0, SI_EIT_as1, SI_EIT_as2, SI_EIT_as3, SI_EIT_as4, SI_EIT_as5, SI_EIT_as6, SI_EIT_as7,
- SI_EIT_as8, SI_EIT_as9, SI_EIT_asa, SI_EIT_asb, SI_EIT_asc, SI_EIT_asd, SI_EIT_ase, SI_EIT_asf,
- SI_EIT_os0, SI_EIT_os1, SI_EIT_os2, SI_EIT_os3, SI_EIT_os4, SI_EIT_os5, SI_EIT_os6, SI_EIT_os7,
- SI_EIT_os8, SI_EIT_os9, SI_EIT_osa, SI_EIT_osb, SI_EIT_osc, SI_EIT_osd, SI_EIT_ose, SI_EIT_osf
+ SI_undef = -1,
+ SI_PAT = 0x00,
+ SI_CAT = 0x01,
+ SI_PMT = 0x02,
+ SI_DSMCC_a = 0x3a,
+ SI_DSMCC_b = 0x3b,
+ SI_DSMCC_c = 0x3c,
+ SI_DSMCC_d = 0x3d,
+ SI_DSMCC_e = 0x3e,
+ SI_DSMCC_f = 0x3f,
+ SI_NIT = 0x40,
+ SI_SDT = 0x42,
+ SI_EIT_act = 0x4e,
+ SI_EIT_oth = 0x4f,
+ SI_EIT_as0, SI_EIT_as1, SI_EIT_as2, SI_EIT_as3, SI_EIT_as4, SI_EIT_as5, SI_EIT_as6, SI_EIT_as7,
+ SI_EIT_as8, SI_EIT_as9, SI_EIT_asa, SI_EIT_asb, SI_EIT_asc, SI_EIT_asd, SI_EIT_ase, SI_EIT_asf,
+ SI_EIT_os0, SI_EIT_os1, SI_EIT_os2, SI_EIT_os3, SI_EIT_os4, SI_EIT_os5, SI_EIT_os6, SI_EIT_os7,
+ SI_EIT_os8, SI_EIT_os9, SI_EIT_osa, SI_EIT_osb, SI_EIT_osc, SI_EIT_osd, SI_EIT_ose, SI_EIT_osf
};
enum MPEG2_DESCRIPTOR {
- // http://www.coolstf.com/tsreader/descriptors.html
- DT_VIDEO_STREAM = 0x02,
- DT_AUDIO_STREAM = 0x03,
- DT_HIERARCHY = 0x04,
- DT_REGISTRATION = 0x05,
- DT_DATA_STREAM_ALIGNMENT = 0x06,
- DT_TARGET_BACKGROUND_GRID = 0x07,
- DT_VIDEO_WINDOW = 0x08,
- DT_CONDITIONAL_ACCESS = 0x09,
- DT_ISO_639_LANGUAGE = 0x0a,
- DT_SYSTEM_CLOCK = 0x0b,
- DT_MULTIPLEX_BUFFER_UTIL = 0x0c,
- DT_COPYRIGHT_DESCRIPTOR = 0x0d,
- DT_MAXIMUM_BITRATE = 0x0e,
- DT_PRIVATE_DATA_INDICATOR = 0x0f,
- DT_SMOOTHING_BUFFER = 0x10,
- DT_STD = 0x11, // System Target Decoder ?
- DT_IBP = 0x12,
- DT_NETWORK_NAME = 0x40,
- DT_SERVICE_LIST = 0x41,
- DT_VBI_DATA = 0x45,
- DT_SERVICE = 0x48,
- DT_LINKAGE = 0x4a,
- DT_SHORT_EVENT = 0x4d,
- DT_EXTENDED_EVENT = 0x4e,
- DT_COMPONENT = 0x50,
- DT_STREAM_IDENTIFIER = 0x52,
- DT_CONTENT = 0x54,
- DT_PARENTAL_RATING = 0x55,
- DT_TELETEXT = 0x56,
- DT_SUBTITLING = 0x59,
- DT_TERRESTRIAL_DELIV_SYS = 0x5a,
- DT_PRIVATE_DATA = 0x5f,
- //
- DT_DATA_BROADCAST_ID = 0x66,
- DT_AC3_AUDIO = 0x6a, // DVB
- DT_EXTENDED_AC3_AUDIO = 0x7a,
- //
- DT_AC3_AUDIO__2 = 0x81, // DCII ou ATSC
- DT_LOGICAL_CHANNEL = 0x83,
- DT_HD_SIMCAST_LOG_CHANNEL = 0x88
+ // http://www.coolstf.com/tsreader/descriptors.html
+ DT_VIDEO_STREAM = 0x02,
+ DT_AUDIO_STREAM = 0x03,
+ DT_HIERARCHY = 0x04,
+ DT_REGISTRATION = 0x05,
+ DT_DATA_STREAM_ALIGNMENT = 0x06,
+ DT_TARGET_BACKGROUND_GRID = 0x07,
+ DT_VIDEO_WINDOW = 0x08,
+ DT_CONDITIONAL_ACCESS = 0x09,
+ DT_ISO_639_LANGUAGE = 0x0a,
+ DT_SYSTEM_CLOCK = 0x0b,
+ DT_MULTIPLEX_BUFFER_UTIL = 0x0c,
+ DT_COPYRIGHT_DESCRIPTOR = 0x0d,
+ DT_MAXIMUM_BITRATE = 0x0e,
+ DT_PRIVATE_DATA_INDICATOR = 0x0f,
+ DT_SMOOTHING_BUFFER = 0x10,
+ DT_STD = 0x11, // System Target Decoder ?
+ DT_IBP = 0x12,
+ DT_NETWORK_NAME = 0x40,
+ DT_SERVICE_LIST = 0x41,
+ DT_VBI_DATA = 0x45,
+ DT_SERVICE = 0x48,
+ DT_LINKAGE = 0x4a,
+ DT_SHORT_EVENT = 0x4d,
+ DT_EXTENDED_EVENT = 0x4e,
+ DT_COMPONENT = 0x50,
+ DT_STREAM_IDENTIFIER = 0x52,
+ DT_CONTENT = 0x54,
+ DT_PARENTAL_RATING = 0x55,
+ DT_TELETEXT = 0x56,
+ DT_SUBTITLING = 0x59,
+ DT_TERRESTRIAL_DELIV_SYS = 0x5a,
+ DT_PRIVATE_DATA = 0x5f,
+ //
+ DT_DATA_BROADCAST_ID = 0x66,
+ DT_AC3_AUDIO = 0x6a, // DVB
+ DT_EXTENDED_AC3_AUDIO = 0x7a,
+ //
+ DT_AC3_AUDIO__2 = 0x81, // DCII ou ATSC
+ DT_LOGICAL_CHANNEL = 0x83,
+ DT_HD_SIMCAST_LOG_CHANNEL = 0x88
};
enum MPEG_TYPES {
- mpeg_us,
- mpeg_ps,
- mpeg_ts,
- mpeg_es,
- mpeg_pva
+ mpeg_us,
+ mpeg_ps,
+ mpeg_ts,
+ mpeg_es,
+ mpeg_pva
};
-extern const wchar_t *StreamTypeToName(PES_STREAM_TYPE _Type);
+extern const wchar_t* StreamTypeToName(PES_STREAM_TYPE _Type);
diff --git a/src/DSUtil/NullRenderers.cpp b/src/DSUtil/NullRenderers.cpp
index 9419ccd94..f005d2eb9 100644
--- a/src/DSUtil/NullRenderers.cpp
+++ b/src/DSUtil/NullRenderers.cpp
@@ -31,246 +31,246 @@
#include <d3d9.h>
#include <dxva.h>
-#include <dxva2api.h> // DXVA2
+#include <dxva2api.h> // DXVA2
#include <evr.h>
-#include <mfapi.h> // API Media Foundation
+#include <mfapi.h> // API Media Foundation
#include <Mferror.h>
// dxva.dll
-typedef HRESULT (__stdcall *PTR_DXVA2CreateDirect3DDeviceManager9)(UINT* pResetToken, IDirect3DDeviceManager9** ppDeviceManager);
-typedef HRESULT (__stdcall *PTR_DXVA2CreateVideoService)(IDirect3DDevice9* pDD, REFIID riid, void** ppService);
+typedef HRESULT(__stdcall* PTR_DXVA2CreateDirect3DDeviceManager9)(UINT* pResetToken, IDirect3DDeviceManager9** ppDeviceManager);
+typedef HRESULT(__stdcall* PTR_DXVA2CreateVideoService)(IDirect3DDevice9* pDD, REFIID riid, void** ppService);
class CNullVideoRendererInputPin : public CRendererInputPin,
- public IMFGetService,
- public IDirectXVideoMemoryConfiguration,
- public IMFVideoDisplayControl
+ public IMFGetService,
+ public IDirectXVideoMemoryConfiguration,
+ public IMFVideoDisplayControl
{
public :
- CNullVideoRendererInputPin(CBaseRenderer *pRenderer, HRESULT *phr, LPCWSTR Name);
- ~CNullVideoRendererInputPin() {
- if (m_pD3DDeviceManager) {
- if (m_hDevice != INVALID_HANDLE_VALUE) {
- m_pD3DDeviceManager->CloseDeviceHandle(m_hDevice);
- m_hDevice = INVALID_HANDLE_VALUE;
- }
- m_pD3DDeviceManager = NULL;
- }
- if (m_pD3DDev) {
- m_pD3DDev = NULL;
- }
- if (m_hDXVA2Lib) {
- FreeLibrary(m_hDXVA2Lib);
- }
- }
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- STDMETHODIMP GetAllocator(IMemAllocator **ppAllocator) {
- // Renderer shouldn't manage allocator for DXVA
- return E_NOTIMPL;
- }
-
- STDMETHODIMP GetAllocatorRequirements(ALLOCATOR_PROPERTIES* pProps) {
- // 1 buffer required
- memset (pProps, 0, sizeof(ALLOCATOR_PROPERTIES));
- pProps->cbBuffer = 1;
- return S_OK;
- }
-
-
- // IMFGetService
- STDMETHODIMP GetService(REFGUID guidService, REFIID riid, LPVOID *ppvObject);
-
- // IDirectXVideoMemoryConfiguration
- STDMETHODIMP GetAvailableSurfaceTypeByIndex(DWORD dwTypeIndex, DXVA2_SurfaceType *pdwType);
- STDMETHODIMP SetSurfaceType(DXVA2_SurfaceType dwType);
-
-
- // IMFVideoDisplayControl
- STDMETHODIMP GetNativeVideoSize(SIZE *pszVideo, SIZE *pszARVideo) {
- return E_NOTIMPL;
- };
- STDMETHODIMP GetIdealVideoSize(SIZE *pszMin, SIZE *pszMax) {
- return E_NOTIMPL;
- };
- STDMETHODIMP SetVideoPosition(const MFVideoNormalizedRect *pnrcSource, const LPRECT prcDest) {
- return E_NOTIMPL;
- };
- STDMETHODIMP GetVideoPosition(MFVideoNormalizedRect *pnrcSource, LPRECT prcDest) {
- return E_NOTIMPL;
- };
- STDMETHODIMP SetAspectRatioMode(DWORD dwAspectRatioMode) {
- return E_NOTIMPL;
- };
- STDMETHODIMP GetAspectRatioMode(DWORD *pdwAspectRatioMode) {
- return E_NOTIMPL;
- };
- STDMETHODIMP SetVideoWindow(HWND hwndVideo) {
- return E_NOTIMPL;
- };
- STDMETHODIMP GetVideoWindow(HWND *phwndVideo);
- STDMETHODIMP RepaintVideo( void) {
- return E_NOTIMPL;
- };
- STDMETHODIMP GetCurrentImage(BITMAPINFOHEADER *pBih, BYTE **pDib, DWORD *pcbDib, LONGLONG *pTimeStamp) {
- return E_NOTIMPL;
- };
- STDMETHODIMP SetBorderColor(COLORREF Clr) {
- return E_NOTIMPL;
- };
- STDMETHODIMP GetBorderColor(COLORREF *pClr) {
- return E_NOTIMPL;
- };
- STDMETHODIMP SetRenderingPrefs(DWORD dwRenderFlags) {
- return E_NOTIMPL;
- };
- STDMETHODIMP GetRenderingPrefs(DWORD *pdwRenderFlags) {
- return E_NOTIMPL;
- };
- STDMETHODIMP SetFullscreen(BOOL fFullscreen) {
- return E_NOTIMPL;
- };
- STDMETHODIMP GetFullscreen(BOOL *pfFullscreen) {
- return E_NOTIMPL;
- };
+ CNullVideoRendererInputPin(CBaseRenderer* pRenderer, HRESULT* phr, LPCWSTR Name);
+ ~CNullVideoRendererInputPin() {
+ if (m_pD3DDeviceManager) {
+ if (m_hDevice != INVALID_HANDLE_VALUE) {
+ m_pD3DDeviceManager->CloseDeviceHandle(m_hDevice);
+ m_hDevice = INVALID_HANDLE_VALUE;
+ }
+ m_pD3DDeviceManager = NULL;
+ }
+ if (m_pD3DDev) {
+ m_pD3DDev = NULL;
+ }
+ if (m_hDXVA2Lib) {
+ FreeLibrary(m_hDXVA2Lib);
+ }
+ }
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ STDMETHODIMP GetAllocator(IMemAllocator** ppAllocator) {
+ // Renderer shouldn't manage allocator for DXVA
+ return E_NOTIMPL;
+ }
+
+ STDMETHODIMP GetAllocatorRequirements(ALLOCATOR_PROPERTIES* pProps) {
+ // 1 buffer required
+ memset(pProps, 0, sizeof(ALLOCATOR_PROPERTIES));
+ pProps->cbBuffer = 1;
+ return S_OK;
+ }
+
+
+ // IMFGetService
+ STDMETHODIMP GetService(REFGUID guidService, REFIID riid, LPVOID* ppvObject);
+
+ // IDirectXVideoMemoryConfiguration
+ STDMETHODIMP GetAvailableSurfaceTypeByIndex(DWORD dwTypeIndex, DXVA2_SurfaceType* pdwType);
+ STDMETHODIMP SetSurfaceType(DXVA2_SurfaceType dwType);
+
+
+ // IMFVideoDisplayControl
+ STDMETHODIMP GetNativeVideoSize(SIZE* pszVideo, SIZE* pszARVideo) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP GetIdealVideoSize(SIZE* pszMin, SIZE* pszMax) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP SetVideoPosition(const MFVideoNormalizedRect* pnrcSource, const LPRECT prcDest) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP GetVideoPosition(MFVideoNormalizedRect* pnrcSource, LPRECT prcDest) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP SetAspectRatioMode(DWORD dwAspectRatioMode) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP GetAspectRatioMode(DWORD* pdwAspectRatioMode) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP SetVideoWindow(HWND hwndVideo) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP GetVideoWindow(HWND* phwndVideo);
+ STDMETHODIMP RepaintVideo(void) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP GetCurrentImage(BITMAPINFOHEADER* pBih, BYTE** pDib, DWORD* pcbDib, LONGLONG* pTimeStamp) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP SetBorderColor(COLORREF Clr) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP GetBorderColor(COLORREF* pClr) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP SetRenderingPrefs(DWORD dwRenderFlags) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP GetRenderingPrefs(DWORD* pdwRenderFlags) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP SetFullscreen(BOOL fFullscreen) {
+ return E_NOTIMPL;
+ };
+ STDMETHODIMP GetFullscreen(BOOL* pfFullscreen) {
+ return E_NOTIMPL;
+ };
private :
- HMODULE m_hDXVA2Lib;
- PTR_DXVA2CreateDirect3DDeviceManager9 pfDXVA2CreateDirect3DDeviceManager9;
- PTR_DXVA2CreateVideoService pfDXVA2CreateVideoService;
-
- CComPtr<IDirect3D9> m_pD3D;
- CComPtr<IDirect3DDevice9> m_pD3DDev;
- CComPtr<IDirect3DDeviceManager9> m_pD3DDeviceManager;
- UINT m_nResetTocken;
- HANDLE m_hDevice;
- HWND m_hWnd;
-
- void CreateSurface();
+ HMODULE m_hDXVA2Lib;
+ PTR_DXVA2CreateDirect3DDeviceManager9 pfDXVA2CreateDirect3DDeviceManager9;
+ PTR_DXVA2CreateVideoService pfDXVA2CreateVideoService;
+
+ CComPtr<IDirect3D9> m_pD3D;
+ CComPtr<IDirect3DDevice9> m_pD3DDev;
+ CComPtr<IDirect3DDeviceManager9> m_pD3DDeviceManager;
+ UINT m_nResetTocken;
+ HANDLE m_hDevice;
+ HWND m_hWnd;
+
+ void CreateSurface();
};
-CNullVideoRendererInputPin::CNullVideoRendererInputPin(CBaseRenderer *pRenderer, HRESULT *phr, LPCWSTR Name)
- : CRendererInputPin(pRenderer, phr, Name)
- , m_hDXVA2Lib(NULL)
- , m_pD3DDev(NULL)
- , m_pD3DDeviceManager(NULL)
- , m_hDevice(INVALID_HANDLE_VALUE)
+CNullVideoRendererInputPin::CNullVideoRendererInputPin(CBaseRenderer* pRenderer, HRESULT* phr, LPCWSTR Name)
+ : CRendererInputPin(pRenderer, phr, Name)
+ , m_hDXVA2Lib(NULL)
+ , m_pD3DDev(NULL)
+ , m_pD3DDeviceManager(NULL)
+ , m_hDevice(INVALID_HANDLE_VALUE)
{
- CreateSurface();
-
- m_hDXVA2Lib = LoadLibrary(L"dxva2.dll");
- if (m_hDXVA2Lib) {
- pfDXVA2CreateDirect3DDeviceManager9 = reinterpret_cast<PTR_DXVA2CreateDirect3DDeviceManager9>(GetProcAddress(m_hDXVA2Lib, "DXVA2CreateDirect3DDeviceManager9"));
- pfDXVA2CreateVideoService = reinterpret_cast<PTR_DXVA2CreateVideoService>(GetProcAddress(m_hDXVA2Lib, "DXVA2CreateVideoService"));
- pfDXVA2CreateDirect3DDeviceManager9(&m_nResetTocken, &m_pD3DDeviceManager);
- }
-
- // Initialize Device Manager with DX surface
- if (m_pD3DDev) {
- HRESULT hr;
- hr = m_pD3DDeviceManager->ResetDevice (m_pD3DDev, m_nResetTocken);
- hr = m_pD3DDeviceManager->OpenDeviceHandle(&m_hDevice);
- }
+ CreateSurface();
+
+ m_hDXVA2Lib = LoadLibrary(L"dxva2.dll");
+ if (m_hDXVA2Lib) {
+ pfDXVA2CreateDirect3DDeviceManager9 = reinterpret_cast<PTR_DXVA2CreateDirect3DDeviceManager9>(GetProcAddress(m_hDXVA2Lib, "DXVA2CreateDirect3DDeviceManager9"));
+ pfDXVA2CreateVideoService = reinterpret_cast<PTR_DXVA2CreateVideoService>(GetProcAddress(m_hDXVA2Lib, "DXVA2CreateVideoService"));
+ pfDXVA2CreateDirect3DDeviceManager9(&m_nResetTocken, &m_pD3DDeviceManager);
+ }
+
+ // Initialize Device Manager with DX surface
+ if (m_pD3DDev) {
+ HRESULT hr;
+ hr = m_pD3DDeviceManager->ResetDevice(m_pD3DDev, m_nResetTocken);
+ hr = m_pD3DDeviceManager->OpenDeviceHandle(&m_hDevice);
+ }
}
void CNullVideoRendererInputPin::CreateSurface()
{
- HRESULT hr;
- m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
- if (!m_pD3D) {
- m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
- }
-
- m_hWnd = NULL; // TODO : put true window
-
- D3DDISPLAYMODE d3ddm;
- ZeroMemory(&d3ddm, sizeof(d3ddm));
- m_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm);
-
- D3DPRESENT_PARAMETERS pp;
- ZeroMemory(&pp, sizeof(pp));
-
- pp.Windowed = TRUE;
- pp.hDeviceWindow = m_hWnd;
- pp.SwapEffect = D3DSWAPEFFECT_COPY;
- pp.Flags = D3DPRESENTFLAG_VIDEO;
- pp.BackBufferCount = 1;
- pp.BackBufferWidth = d3ddm.Width;
- pp.BackBufferHeight = d3ddm.Height;
- pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
-
- hr = m_pD3D->CreateDevice(
- D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_hWnd,
- D3DCREATE_SOFTWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
- &pp, &m_pD3DDev);
+ HRESULT hr;
+ m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
+ if (!m_pD3D) {
+ m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
+ }
+
+ m_hWnd = NULL; // TODO : put true window
+
+ D3DDISPLAYMODE d3ddm;
+ ZeroMemory(&d3ddm, sizeof(d3ddm));
+ m_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm);
+
+ D3DPRESENT_PARAMETERS pp;
+ ZeroMemory(&pp, sizeof(pp));
+
+ pp.Windowed = TRUE;
+ pp.hDeviceWindow = m_hWnd;
+ pp.SwapEffect = D3DSWAPEFFECT_COPY;
+ pp.Flags = D3DPRESENTFLAG_VIDEO;
+ pp.BackBufferCount = 1;
+ pp.BackBufferWidth = d3ddm.Width;
+ pp.BackBufferHeight = d3ddm.Height;
+ pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
+
+ hr = m_pD3D->CreateDevice(
+ D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_hWnd,
+ D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
+ &pp, &m_pD3DDev);
}
STDMETHODIMP CNullVideoRendererInputPin::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- (riid == __uuidof(IMFGetService)) ? GetInterface((IMFGetService*)this, ppv) :
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ (riid == __uuidof(IMFGetService)) ? GetInterface((IMFGetService*)this, ppv) :
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
-STDMETHODIMP CNullVideoRendererInputPin::GetService(REFGUID guidService, REFIID riid, LPVOID *ppvObject)
+STDMETHODIMP CNullVideoRendererInputPin::GetService(REFGUID guidService, REFIID riid, LPVOID* ppvObject)
{
- if (m_pD3DDeviceManager != NULL && guidService == MR_VIDEO_ACCELERATION_SERVICE) {
- if (riid == __uuidof(IDirect3DDeviceManager9)) {
- return m_pD3DDeviceManager->QueryInterface (riid, ppvObject);
- } else if (riid == __uuidof(IDirectXVideoDecoderService) || riid == __uuidof(IDirectXVideoProcessorService) ) {
- return m_pD3DDeviceManager->GetVideoService (m_hDevice, riid, ppvObject);
- } else if (riid == __uuidof(IDirectXVideoAccelerationService)) {
- // TODO : to be tested....
- return pfDXVA2CreateVideoService(m_pD3DDev, riid, ppvObject);
- } else if (riid == __uuidof(IDirectXVideoMemoryConfiguration)) {
- GetInterface ((IDirectXVideoMemoryConfiguration*)this, ppvObject);
- return S_OK;
- }
- } else if (guidService == MR_VIDEO_RENDER_SERVICE) {
- if (riid == __uuidof(IMFVideoDisplayControl)) {
- GetInterface ((IMFVideoDisplayControl*)this, ppvObject);
- return S_OK;
- }
- }
- //else if (guidService == MR_VIDEO_MIXER_SERVICE)
- //{
- // if (riid == __uuidof(IMFVideoMixerBitmap))
- // {
- // GetInterface ((IMFVideoMixerBitmap*)this, ppvObject);
- // return S_OK;
- // }
- //}
- return E_NOINTERFACE;
+ if (m_pD3DDeviceManager != NULL && guidService == MR_VIDEO_ACCELERATION_SERVICE) {
+ if (riid == __uuidof(IDirect3DDeviceManager9)) {
+ return m_pD3DDeviceManager->QueryInterface(riid, ppvObject);
+ } else if (riid == __uuidof(IDirectXVideoDecoderService) || riid == __uuidof(IDirectXVideoProcessorService)) {
+ return m_pD3DDeviceManager->GetVideoService(m_hDevice, riid, ppvObject);
+ } else if (riid == __uuidof(IDirectXVideoAccelerationService)) {
+ // TODO : to be tested....
+ return pfDXVA2CreateVideoService(m_pD3DDev, riid, ppvObject);
+ } else if (riid == __uuidof(IDirectXVideoMemoryConfiguration)) {
+ GetInterface((IDirectXVideoMemoryConfiguration*)this, ppvObject);
+ return S_OK;
+ }
+ } else if (guidService == MR_VIDEO_RENDER_SERVICE) {
+ if (riid == __uuidof(IMFVideoDisplayControl)) {
+ GetInterface((IMFVideoDisplayControl*)this, ppvObject);
+ return S_OK;
+ }
+ }
+ //else if (guidService == MR_VIDEO_MIXER_SERVICE)
+ //{
+ // if (riid == __uuidof(IMFVideoMixerBitmap))
+ // {
+ // GetInterface ((IMFVideoMixerBitmap*)this, ppvObject);
+ // return S_OK;
+ // }
+ //}
+ return E_NOINTERFACE;
}
-STDMETHODIMP CNullVideoRendererInputPin::GetAvailableSurfaceTypeByIndex(DWORD dwTypeIndex, DXVA2_SurfaceType *pdwType)
+STDMETHODIMP CNullVideoRendererInputPin::GetAvailableSurfaceTypeByIndex(DWORD dwTypeIndex, DXVA2_SurfaceType* pdwType)
{
- if (dwTypeIndex == 0) {
- *pdwType = DXVA2_SurfaceType_DecoderRenderTarget;
- return S_OK;
- } else {
- return MF_E_NO_MORE_TYPES;
- }
+ if (dwTypeIndex == 0) {
+ *pdwType = DXVA2_SurfaceType_DecoderRenderTarget;
+ return S_OK;
+ } else {
+ return MF_E_NO_MORE_TYPES;
+ }
}
STDMETHODIMP CNullVideoRendererInputPin::SetSurfaceType(DXVA2_SurfaceType dwType)
{
- return S_OK;
+ return S_OK;
}
-STDMETHODIMP CNullVideoRendererInputPin::GetVideoWindow(HWND *phwndVideo)
+STDMETHODIMP CNullVideoRendererInputPin::GetVideoWindow(HWND* phwndVideo)
{
- CheckPointer(phwndVideo, E_POINTER);
- *phwndVideo = m_hWnd; // Important to implement this method (used by mpc)
- return S_OK;
+ CheckPointer(phwndVideo, E_POINTER);
+ *phwndVideo = m_hWnd; // Important to implement this method (used by mpc)
+ return S_OK;
}
@@ -281,7 +281,7 @@ STDMETHODIMP CNullVideoRendererInputPin::GetVideoWindow(HWND *phwndVideo)
//
CNullRenderer::CNullRenderer(REFCLSID clsid, TCHAR* pName, LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseRenderer(clsid, pName, pUnk, phr)
+ : CBaseRenderer(clsid, pName, pUnk, phr)
{
}
@@ -290,16 +290,16 @@ CNullRenderer::CNullRenderer(REFCLSID clsid, TCHAR* pName, LPUNKNOWN pUnk, HRESU
//
CNullVideoRenderer::CNullVideoRenderer(LPUNKNOWN pUnk, HRESULT* phr)
- : CNullRenderer(__uuidof(this), NAME("Null Video Renderer"), pUnk, phr)
+ : CNullRenderer(__uuidof(this), NAME("Null Video Renderer"), pUnk, phr)
{
}
HRESULT CNullVideoRenderer::CheckMediaType(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Video
- || pmt->subtype == MEDIASUBTYPE_MPEG2_VIDEO
- ? S_OK
- : E_FAIL;
+ return pmt->majortype == MEDIATYPE_Video
+ || pmt->subtype == MEDIASUBTYPE_MPEG2_VIDEO
+ ? S_OK
+ : E_FAIL;
}
//
@@ -307,55 +307,55 @@ HRESULT CNullVideoRenderer::CheckMediaType(const CMediaType* pmt)
//
CNullUVideoRenderer::CNullUVideoRenderer(LPUNKNOWN pUnk, HRESULT* phr)
- : CNullRenderer(__uuidof(this), NAME("Null Video Renderer (Uncompressed)"), pUnk, phr)
+ : CNullRenderer(__uuidof(this), NAME("Null Video Renderer (Uncompressed)"), pUnk, phr)
{
#ifdef USE_DXVA
- m_pInputPin = new CNullVideoRendererInputPin(this,phr,L"In");
+ m_pInputPin = new CNullVideoRendererInputPin(this, phr, L"In");
#endif
}
HRESULT CNullUVideoRenderer::CheckMediaType(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Video
- && (pmt->subtype == MEDIASUBTYPE_YV12
- || pmt->subtype == MEDIASUBTYPE_I420
- || pmt->subtype == MEDIASUBTYPE_YUYV
- || pmt->subtype == MEDIASUBTYPE_IYUV
- || pmt->subtype == MEDIASUBTYPE_YVU9
- || pmt->subtype == MEDIASUBTYPE_Y411
- || pmt->subtype == MEDIASUBTYPE_Y41P
- || pmt->subtype == MEDIASUBTYPE_YUY2
- || pmt->subtype == MEDIASUBTYPE_YVYU
- || pmt->subtype == MEDIASUBTYPE_UYVY
- || pmt->subtype == MEDIASUBTYPE_Y211
- || pmt->subtype == MEDIASUBTYPE_RGB1
- || pmt->subtype == MEDIASUBTYPE_RGB4
- || pmt->subtype == MEDIASUBTYPE_RGB8
- || pmt->subtype == MEDIASUBTYPE_RGB565
- || pmt->subtype == MEDIASUBTYPE_RGB555
- || pmt->subtype == MEDIASUBTYPE_RGB24
- || pmt->subtype == MEDIASUBTYPE_RGB32
- || pmt->subtype == MEDIASUBTYPE_ARGB1555
- || pmt->subtype == MEDIASUBTYPE_ARGB4444
- || pmt->subtype == MEDIASUBTYPE_ARGB32
- || pmt->subtype == MEDIASUBTYPE_A2R10G10B10
- || pmt->subtype == MEDIASUBTYPE_A2B10G10R10)
- ? S_OK
- : E_FAIL;
+ return pmt->majortype == MEDIATYPE_Video
+ && (pmt->subtype == MEDIASUBTYPE_YV12
+ || pmt->subtype == MEDIASUBTYPE_I420
+ || pmt->subtype == MEDIASUBTYPE_YUYV
+ || pmt->subtype == MEDIASUBTYPE_IYUV
+ || pmt->subtype == MEDIASUBTYPE_YVU9
+ || pmt->subtype == MEDIASUBTYPE_Y411
+ || pmt->subtype == MEDIASUBTYPE_Y41P
+ || pmt->subtype == MEDIASUBTYPE_YUY2
+ || pmt->subtype == MEDIASUBTYPE_YVYU
+ || pmt->subtype == MEDIASUBTYPE_UYVY
+ || pmt->subtype == MEDIASUBTYPE_Y211
+ || pmt->subtype == MEDIASUBTYPE_RGB1
+ || pmt->subtype == MEDIASUBTYPE_RGB4
+ || pmt->subtype == MEDIASUBTYPE_RGB8
+ || pmt->subtype == MEDIASUBTYPE_RGB565
+ || pmt->subtype == MEDIASUBTYPE_RGB555
+ || pmt->subtype == MEDIASUBTYPE_RGB24
+ || pmt->subtype == MEDIASUBTYPE_RGB32
+ || pmt->subtype == MEDIASUBTYPE_ARGB1555
+ || pmt->subtype == MEDIASUBTYPE_ARGB4444
+ || pmt->subtype == MEDIASUBTYPE_ARGB32
+ || pmt->subtype == MEDIASUBTYPE_A2R10G10B10
+ || pmt->subtype == MEDIASUBTYPE_A2B10G10R10)
+ ? S_OK
+ : E_FAIL;
}
HRESULT CNullUVideoRenderer::DoRenderSample(IMediaSample* pSample)
{
#ifdef USE_DXVA
- CComQIPtr<IMFGetService> pService = pSample;
- if (pService != NULL) {
- CComPtr<IDirect3DSurface9> pSurface;
- pService->GetService (MR_BUFFER_SERVICE, __uuidof(IDirect3DSurface9), (void**)&pSurface);
- // TODO : render surface...
- }
+ CComQIPtr<IMFGetService> pService = pSample;
+ if (pService != NULL) {
+ CComPtr<IDirect3DSurface9> pSurface;
+ pService->GetService(MR_BUFFER_SERVICE, __uuidof(IDirect3DSurface9), (void**)&pSurface);
+ // TODO : render surface...
+ }
#endif
- return S_OK;
+ return S_OK;
}
//
@@ -363,23 +363,23 @@ HRESULT CNullUVideoRenderer::DoRenderSample(IMediaSample* pSample)
//
CNullAudioRenderer::CNullAudioRenderer(LPUNKNOWN pUnk, HRESULT* phr)
- : CNullRenderer(__uuidof(this), NAME("Null Audio Renderer"), pUnk, phr)
+ : CNullRenderer(__uuidof(this), NAME("Null Audio Renderer"), pUnk, phr)
{
}
HRESULT CNullAudioRenderer::CheckMediaType(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Audio
- || pmt->majortype == MEDIATYPE_Midi
- || pmt->subtype == MEDIASUBTYPE_MPEG2_AUDIO
- || pmt->subtype == MEDIASUBTYPE_DOLBY_AC3
- || pmt->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO
- || pmt->subtype == MEDIASUBTYPE_DTS
- || pmt->subtype == MEDIASUBTYPE_SDDS
- || pmt->subtype == MEDIASUBTYPE_MPEG1AudioPayload
- || pmt->subtype == MEDIASUBTYPE_MPEG1Audio
- ? S_OK
- : E_FAIL;
+ return pmt->majortype == MEDIATYPE_Audio
+ || pmt->majortype == MEDIATYPE_Midi
+ || pmt->subtype == MEDIASUBTYPE_MPEG2_AUDIO
+ || pmt->subtype == MEDIASUBTYPE_DOLBY_AC3
+ || pmt->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO
+ || pmt->subtype == MEDIASUBTYPE_DTS
+ || pmt->subtype == MEDIASUBTYPE_SDDS
+ || pmt->subtype == MEDIASUBTYPE_MPEG1AudioPayload
+ || pmt->subtype == MEDIASUBTYPE_MPEG1Audio
+ ? S_OK
+ : E_FAIL;
}
//
@@ -387,21 +387,21 @@ HRESULT CNullAudioRenderer::CheckMediaType(const CMediaType* pmt)
//
CNullUAudioRenderer::CNullUAudioRenderer(LPUNKNOWN pUnk, HRESULT* phr)
- : CNullRenderer(__uuidof(this), NAME("Null Audio Renderer (Uncompressed)"), pUnk, phr)
+ : CNullRenderer(__uuidof(this), NAME("Null Audio Renderer (Uncompressed)"), pUnk, phr)
{
}
HRESULT CNullUAudioRenderer::CheckMediaType(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Audio
- && (pmt->subtype == MEDIASUBTYPE_PCM
- || pmt->subtype == MEDIASUBTYPE_IEEE_FLOAT
- || pmt->subtype == MEDIASUBTYPE_DRM_Audio
- || pmt->subtype == MEDIASUBTYPE_DOLBY_AC3_SPDIF
- || pmt->subtype == MEDIASUBTYPE_RAW_SPORT
- || pmt->subtype == MEDIASUBTYPE_SPDIF_TAG_241h)
- ? S_OK
- : E_FAIL;
+ return pmt->majortype == MEDIATYPE_Audio
+ && (pmt->subtype == MEDIASUBTYPE_PCM
+ || pmt->subtype == MEDIASUBTYPE_IEEE_FLOAT
+ || pmt->subtype == MEDIASUBTYPE_DRM_Audio
+ || pmt->subtype == MEDIASUBTYPE_DOLBY_AC3_SPDIF
+ || pmt->subtype == MEDIASUBTYPE_RAW_SPORT
+ || pmt->subtype == MEDIASUBTYPE_SPDIF_TAG_241h)
+ ? S_OK
+ : E_FAIL;
}
//
@@ -410,18 +410,18 @@ HRESULT CNullUAudioRenderer::CheckMediaType(const CMediaType* pmt)
HRESULT CNullTextRenderer::CTextInputPin::CheckMediaType(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Text
- || pmt->majortype == MEDIATYPE_ScriptCommand
- || pmt->majortype == MEDIATYPE_Subtitle
- || pmt->subtype == MEDIASUBTYPE_DVD_SUBPICTURE
- || pmt->subtype == MEDIASUBTYPE_CVD_SUBPICTURE
- || pmt->subtype == MEDIASUBTYPE_SVCD_SUBPICTURE
- ? S_OK
- : E_FAIL;
+ return pmt->majortype == MEDIATYPE_Text
+ || pmt->majortype == MEDIATYPE_ScriptCommand
+ || pmt->majortype == MEDIATYPE_Subtitle
+ || pmt->subtype == MEDIASUBTYPE_DVD_SUBPICTURE
+ || pmt->subtype == MEDIASUBTYPE_CVD_SUBPICTURE
+ || pmt->subtype == MEDIASUBTYPE_SVCD_SUBPICTURE
+ ? S_OK
+ : E_FAIL;
}
CNullTextRenderer::CNullTextRenderer(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseFilter(NAME("CNullTextRenderer"), pUnk, this, __uuidof(this), phr)
+ : CBaseFilter(NAME("CNullTextRenderer"), pUnk, this, __uuidof(this), phr)
{
- m_pInput.Attach(DNew CTextInputPin(this, this, phr));
+ m_pInput.Attach(DNew CTextInputPin(this, this, phr));
}
diff --git a/src/DSUtil/NullRenderers.h b/src/DSUtil/NullRenderers.h
index c7d083354..f56c14112 100644
--- a/src/DSUtil/NullRenderers.h
+++ b/src/DSUtil/NullRenderers.h
@@ -29,68 +29,68 @@
class CNullRenderer : public CBaseRenderer
{
protected:
- virtual HRESULT DoRenderSample(IMediaSample* pSample) { return S_OK; }
+ virtual HRESULT DoRenderSample(IMediaSample* pSample) { return S_OK; }
public:
- CNullRenderer(REFCLSID clsid, TCHAR* pName, LPUNKNOWN pUnk, HRESULT* phr);
+ CNullRenderer(REFCLSID clsid, TCHAR* pName, LPUNKNOWN pUnk, HRESULT* phr);
};
class __declspec(uuid("579883A0-4E2D-481F-9436-467AAFAB7DE8"))
- CNullVideoRenderer : public CNullRenderer
+ CNullVideoRenderer : public CNullRenderer
{
protected:
- HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT CheckMediaType(const CMediaType* pmt);
public:
- CNullVideoRenderer(LPUNKNOWN pUnk, HRESULT* phr);
+ CNullVideoRenderer(LPUNKNOWN pUnk, HRESULT* phr);
};
class __declspec(uuid("DD9ED57D-6ABF-42E8-89A2-11D04798DC58"))
- CNullUVideoRenderer : public CNullRenderer
+ CNullUVideoRenderer : public CNullRenderer
{
protected:
- HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT CheckMediaType(const CMediaType* pmt);
public:
- CNullUVideoRenderer(LPUNKNOWN pUnk, HRESULT* phr);
- virtual HRESULT DoRenderSample(IMediaSample* pSample);
+ CNullUVideoRenderer(LPUNKNOWN pUnk, HRESULT* phr);
+ virtual HRESULT DoRenderSample(IMediaSample* pSample);
};
class __declspec(uuid("0C38BDFD-8C17-4E00-A344-F89397D3E22A"))
- CNullAudioRenderer : public CNullRenderer
+ CNullAudioRenderer : public CNullRenderer
{
protected:
- HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT CheckMediaType(const CMediaType* pmt);
public:
- CNullAudioRenderer(LPUNKNOWN pUnk, HRESULT* phr);
+ CNullAudioRenderer(LPUNKNOWN pUnk, HRESULT* phr);
};
class __declspec(uuid("64A45125-7343-4772-9DA4-179FAC9D462C"))
- CNullUAudioRenderer : public CNullRenderer
+ CNullUAudioRenderer : public CNullRenderer
{
protected:
- HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT CheckMediaType(const CMediaType* pmt);
public:
- CNullUAudioRenderer(LPUNKNOWN pUnk, HRESULT* phr);
+ CNullUAudioRenderer(LPUNKNOWN pUnk, HRESULT* phr);
};
class __declspec(uuid("655D7613-C26C-4A25-BBBD-3C9C516122CC"))
- CNullTextRenderer : public CBaseFilter, public CCritSec
+ CNullTextRenderer : public CBaseFilter, public CCritSec
{
- class CTextInputPin : public CBaseInputPin
- {
- public:
- CTextInputPin(CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseInputPin(NAME("CTextInputPin"), pFilter, pLock, phr, L"In") {}
- HRESULT CheckMediaType(const CMediaType* pmt);
- };
+ class CTextInputPin : public CBaseInputPin
+ {
+ public:
+ CTextInputPin(CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
+ : CBaseInputPin(NAME("CTextInputPin"), pFilter, pLock, phr, L"In") {}
+ HRESULT CheckMediaType(const CMediaType* pmt);
+ };
- CAutoPtr<CTextInputPin> m_pInput;
+ CAutoPtr<CTextInputPin> m_pInput;
public:
- CNullTextRenderer(LPUNKNOWN pUnk, HRESULT* phr);
- int GetPinCount() { return (int)!!m_pInput; }
- CBasePin* GetPin(int n) { return n == 0 ? (CBasePin*)m_pInput : NULL; }
+ CNullTextRenderer(LPUNKNOWN pUnk, HRESULT* phr);
+ int GetPinCount() { return (int)!!m_pInput; }
+ CBasePin* GetPin(int n) { return n == 0 ? (CBasePin*)m_pInput : NULL; }
};
diff --git a/src/DSUtil/SysVersion.cpp b/src/DSUtil/SysVersion.cpp
index 82c18ef40..f6f30f9b9 100644
--- a/src/DSUtil/SysVersion.cpp
+++ b/src/DSUtil/SysVersion.cpp
@@ -29,9 +29,9 @@ const DWORD SysVersion::version = MAKEWORD(fullVersion.dwMinorVersion, fullVersi
OSVERSIONINFOEX SysVersion::InitFullVersion()
{
- OSVERSIONINFOEX fullVersion = {0};
- fullVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
- GetVersionEx((LPOSVERSIONINFO)&fullVersion);
+ OSVERSIONINFOEX fullVersion = {0};
+ fullVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+ GetVersionEx((LPOSVERSIONINFO)&fullVersion);
- return fullVersion;
+ return fullVersion;
}
diff --git a/src/DSUtil/SysVersion.h b/src/DSUtil/SysVersion.h
index 231db4e6d..a7d3e7235 100644
--- a/src/DSUtil/SysVersion.h
+++ b/src/DSUtil/SysVersion.h
@@ -26,21 +26,21 @@
class SysVersion
{
- SysVersion() {};
+ SysVersion() {};
- static OSVERSIONINFOEX InitFullVersion();
+ static OSVERSIONINFOEX InitFullVersion();
- static const OSVERSIONINFOEX fullVersion;
- static const DWORD version;
+ static const OSVERSIONINFOEX fullVersion;
+ static const DWORD version;
public:
- static OSVERSIONINFOEX GetFullVersion() { return fullVersion; }
- static DWORD GetVersion() { return version; }
+ static OSVERSIONINFOEX GetFullVersion() { return fullVersion; }
+ static DWORD GetVersion() { return version; }
- static bool IsXPOrLater() { return (version >= 0x0501); }
- static bool IsVista() { return (version == 0x0600); }
- static bool IsVistaOrLater() { return (version >= 0x0600); }
- static bool Is7() { return (version == 0x0601); }
- static bool Is7OrLater() { return (version >= 0x0601); }
- //static bool Is8() { return (version == 0x0602); }
+ static bool IsXPOrLater() { return (version >= 0x0501); }
+ static bool IsVista() { return (version == 0x0600); }
+ static bool IsVistaOrLater() { return (version >= 0x0600); }
+ static bool Is7() { return (version == 0x0601); }
+ static bool Is7OrLater() { return (version >= 0x0601); }
+ //static bool Is8() { return (version == 0x0602); }
};
diff --git a/src/DSUtil/WinAPIUtils.cpp b/src/DSUtil/WinAPIUtils.cpp
index 4c6080823..61cde7bb6 100644
--- a/src/DSUtil/WinAPIUtils.cpp
+++ b/src/DSUtil/WinAPIUtils.cpp
@@ -28,234 +28,234 @@
bool SetPrivilege(LPCTSTR privilege, bool bEnable)
{
- HANDLE hToken;
- TOKEN_PRIVILEGES tkp;
+ HANDLE hToken;
+ TOKEN_PRIVILEGES tkp;
- SetThreadExecutionState (ES_CONTINUOUS);
+ SetThreadExecutionState(ES_CONTINUOUS);
- // Get a token for this process.
- if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) {
- return false;
- }
+ // Get a token for this process.
+ if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) {
+ return false;
+ }
- // Get the LUID for the privilege.
- LookupPrivilegeValue(NULL, privilege, &tkp.Privileges[0].Luid);
+ // Get the LUID for the privilege.
+ LookupPrivilegeValue(NULL, privilege, &tkp.Privileges[0].Luid);
- tkp.PrivilegeCount = 1; // one privilege to set
- tkp.Privileges[0].Attributes = bEnable ? SE_PRIVILEGE_ENABLED : 0;
+ tkp.PrivilegeCount = 1; // one privilege to set
+ tkp.Privileges[0].Attributes = bEnable ? SE_PRIVILEGE_ENABLED : 0;
- // Set the privilege for this process.
- AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
+ // Set the privilege for this process.
+ AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
- return (GetLastError() == ERROR_SUCCESS);
+ return (GetLastError() == ERROR_SUCCESS);
}
CString GetHiveName(HKEY hive)
{
- switch ((ULONG_PTR)hive) {
- case (ULONG_PTR)HKEY_CLASSES_ROOT:
- return _T("HKEY_CLASSES_ROOT");
- case (ULONG_PTR)HKEY_CURRENT_USER:
- return _T("HKEY_CURRENT_USER");
- case (ULONG_PTR)HKEY_LOCAL_MACHINE:
- return _T("HKEY_LOCAL_MACHINE");
- case (ULONG_PTR)HKEY_USERS:
- return _T("HKEY_USERS");
- case (ULONG_PTR)HKEY_PERFORMANCE_DATA:
- return _T("HKEY_PERFORMANCE_DATA");
- case (ULONG_PTR)HKEY_CURRENT_CONFIG:
- return _T("HKEY_CURRENT_CONFIG");
- case (ULONG_PTR)HKEY_DYN_DATA:
- return _T("HKEY_DYN_DATA");
- case (ULONG_PTR)HKEY_PERFORMANCE_TEXT:
- return _T("HKEY_PERFORMANCE_TEXT");
- case (ULONG_PTR)HKEY_PERFORMANCE_NLSTEXT:
- return _T("HKEY_PERFORMANCE_NLSTEXT");
- default:
- return _T("");
- }
+ switch ((ULONG_PTR)hive) {
+ case (ULONG_PTR)HKEY_CLASSES_ROOT:
+ return _T("HKEY_CLASSES_ROOT");
+ case (ULONG_PTR)HKEY_CURRENT_USER:
+ return _T("HKEY_CURRENT_USER");
+ case (ULONG_PTR)HKEY_LOCAL_MACHINE:
+ return _T("HKEY_LOCAL_MACHINE");
+ case (ULONG_PTR)HKEY_USERS:
+ return _T("HKEY_USERS");
+ case (ULONG_PTR)HKEY_PERFORMANCE_DATA:
+ return _T("HKEY_PERFORMANCE_DATA");
+ case (ULONG_PTR)HKEY_CURRENT_CONFIG:
+ return _T("HKEY_CURRENT_CONFIG");
+ case (ULONG_PTR)HKEY_DYN_DATA:
+ return _T("HKEY_DYN_DATA");
+ case (ULONG_PTR)HKEY_PERFORMANCE_TEXT:
+ return _T("HKEY_PERFORMANCE_TEXT");
+ case (ULONG_PTR)HKEY_PERFORMANCE_NLSTEXT:
+ return _T("HKEY_PERFORMANCE_NLSTEXT");
+ default:
+ return _T("");
+ }
}
bool ExportRegistryKey(CStdioFile& file, HKEY hKeyRoot, CString keyName)
{
- HKEY hKey = NULL;
- if (RegOpenKeyEx(hKeyRoot, keyName, 0, KEY_READ, &hKey) != ERROR_SUCCESS) {
- return false;
- }
-
- DWORD subKeysCount = 0, maxSubKeyLen = 0;
- DWORD valuesCount = 0, maxValueNameLen = 0, maxValueDataLen = 0;
- if (RegQueryInfoKey(hKey, NULL, NULL, NULL, &subKeysCount, &maxSubKeyLen, NULL, &valuesCount, &maxValueNameLen, &maxValueDataLen, NULL, NULL) != ERROR_SUCCESS) {
- return false;
- }
- maxSubKeyLen += 1;
- maxValueNameLen += 1;
-
- CString buffer;
-
- buffer.Format(_T("[%s\\%s]\n"), GetHiveName(hKeyRoot), keyName);
- file.WriteString(buffer);
-
- CString valueName;
- DWORD valueNameLen, valueDataLen, type;
- BYTE* data = DNew BYTE[maxValueDataLen];
-
- for (DWORD indexValue=0; indexValue < valuesCount; indexValue++) {
- valueNameLen = maxValueNameLen;
- valueDataLen = maxValueDataLen;
-
- if (RegEnumValue(hKey, indexValue, valueName.GetBuffer(maxValueNameLen), &valueNameLen, NULL, &type, data, &valueDataLen) != ERROR_SUCCESS) {
- return false;
- }
-
- switch (type) {
- case REG_SZ:
- {
- CString str((TCHAR*)data);
- str.Replace(_T("\\"), _T("\\\\"));
- str.Replace(_T("\""), _T("\\\""));
- buffer.Format(_T("\"%s\"=\"%s\"\n"), valueName, str);
- file.WriteString(buffer);
- }
- break;
- case REG_BINARY:
- buffer.Format(_T("\"%s\"=hex:%02x"), valueName, data[0]);
- file.WriteString(buffer);
- for (DWORD i=1; i < valueDataLen; i++) {
- buffer.Format(_T(",%02x"), data[i]);
- file.WriteString(buffer);
- }
- file.WriteString(_T("\n"));
- break;
- case REG_DWORD:
- buffer.Format(_T("\"%s\"=dword:%08x\n"), valueName, *((DWORD*)data));
- file.WriteString(buffer);
- break;
- default:
- {
- CString msg;
- msg.Format(_T("The value \"%s\\%s\\%s\" has an unsupported type and has been ignored.\nPlease report this error to the developers."),
- GetHiveName(hKeyRoot), keyName, valueName);
- AfxMessageBox(msg, MB_ICONERROR | MB_OK);
- }
- delete[] data;
- return false;
- }
- }
-
- delete[] data;
-
- file.WriteString(_T("\n"));
-
- CString subKeyName;
- DWORD subKeyLen;
-
- for (DWORD indexSubKey=0; indexSubKey < subKeysCount; indexSubKey++) {
- subKeyLen = maxSubKeyLen;
-
- if (RegEnumKeyEx(hKey, indexSubKey, subKeyName.GetBuffer(maxSubKeyLen), &subKeyLen, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) {
- return false;
- }
-
- buffer.Format(_T("%s\\%s"), keyName, subKeyName);
-
- if (!ExportRegistryKey(file, hKeyRoot, buffer)) {
- return false;
- }
- }
-
- RegCloseKey(hKey);
-
- return true;
+ HKEY hKey = NULL;
+ if (RegOpenKeyEx(hKeyRoot, keyName, 0, KEY_READ, &hKey) != ERROR_SUCCESS) {
+ return false;
+ }
+
+ DWORD subKeysCount = 0, maxSubKeyLen = 0;
+ DWORD valuesCount = 0, maxValueNameLen = 0, maxValueDataLen = 0;
+ if (RegQueryInfoKey(hKey, NULL, NULL, NULL, &subKeysCount, &maxSubKeyLen, NULL, &valuesCount, &maxValueNameLen, &maxValueDataLen, NULL, NULL) != ERROR_SUCCESS) {
+ return false;
+ }
+ maxSubKeyLen += 1;
+ maxValueNameLen += 1;
+
+ CString buffer;
+
+ buffer.Format(_T("[%s\\%s]\n"), GetHiveName(hKeyRoot), keyName);
+ file.WriteString(buffer);
+
+ CString valueName;
+ DWORD valueNameLen, valueDataLen, type;
+ BYTE* data = DNew BYTE[maxValueDataLen];
+
+ for (DWORD indexValue = 0; indexValue < valuesCount; indexValue++) {
+ valueNameLen = maxValueNameLen;
+ valueDataLen = maxValueDataLen;
+
+ if (RegEnumValue(hKey, indexValue, valueName.GetBuffer(maxValueNameLen), &valueNameLen, NULL, &type, data, &valueDataLen) != ERROR_SUCCESS) {
+ return false;
+ }
+
+ switch (type) {
+ case REG_SZ: {
+ CString str((TCHAR*)data);
+ str.Replace(_T("\\"), _T("\\\\"));
+ str.Replace(_T("\""), _T("\\\""));
+ buffer.Format(_T("\"%s\"=\"%s\"\n"), valueName, str);
+ file.WriteString(buffer);
+ }
+ break;
+ case REG_BINARY:
+ buffer.Format(_T("\"%s\"=hex:%02x"), valueName, data[0]);
+ file.WriteString(buffer);
+ for (DWORD i = 1; i < valueDataLen; i++) {
+ buffer.Format(_T(",%02x"), data[i]);
+ file.WriteString(buffer);
+ }
+ file.WriteString(_T("\n"));
+ break;
+ case REG_DWORD:
+ buffer.Format(_T("\"%s\"=dword:%08x\n"), valueName, *((DWORD*)data));
+ file.WriteString(buffer);
+ break;
+ default: {
+ CString msg;
+ msg.Format(_T("The value \"%s\\%s\\%s\" has an unsupported type and has been ignored.\nPlease report this error to the developers."),
+ GetHiveName(hKeyRoot), keyName, valueName);
+ AfxMessageBox(msg, MB_ICONERROR | MB_OK);
+ }
+ delete[] data;
+ return false;
+ }
+ }
+
+ delete[] data;
+
+ file.WriteString(_T("\n"));
+
+ CString subKeyName;
+ DWORD subKeyLen;
+
+ for (DWORD indexSubKey = 0; indexSubKey < subKeysCount; indexSubKey++) {
+ subKeyLen = maxSubKeyLen;
+
+ if (RegEnumKeyEx(hKey, indexSubKey, subKeyName.GetBuffer(maxSubKeyLen), &subKeyLen, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) {
+ return false;
+ }
+
+ buffer.Format(_T("%s\\%s"), keyName, subKeyName);
+
+ if (!ExportRegistryKey(file, hKeyRoot, buffer)) {
+ return false;
+ }
+ }
+
+ RegCloseKey(hKey);
+
+ return true;
}
UINT GetAdapter(IDirect3D9* pD3D, HWND hWnd)
{
- if (hWnd == NULL || pD3D == NULL) {
- return D3DADAPTER_DEFAULT;
- }
-
- HMONITOR hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
- if (hMonitor == NULL) {
- return D3DADAPTER_DEFAULT;
- }
-
- for (UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp) {
- HMONITOR hAdpMon = pD3D->GetAdapterMonitor(adp);
- if (hAdpMon == hMonitor) {
- return adp;
- }
- }
-
- return D3DADAPTER_DEFAULT;
+ if (hWnd == NULL || pD3D == NULL) {
+ return D3DADAPTER_DEFAULT;
+ }
+
+ HMONITOR hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
+ if (hMonitor == NULL) {
+ return D3DADAPTER_DEFAULT;
+ }
+
+ for (UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp) {
+ HMONITOR hAdpMon = pD3D->GetAdapterMonitor(adp);
+ if (hAdpMon == hMonitor) {
+ return adp;
+ }
+ }
+
+ return D3DADAPTER_DEFAULT;
}
int CALLBACK EnumFontFamExProc(ENUMLOGFONTEX* /*lpelfe*/, NEWTEXTMETRICEX* /*lpntme*/, int /*FontType*/, LPARAM lParam)
{
- LPARAM* l = (LPARAM*)lParam;
- *l = TRUE;
- return TRUE;
+ LPARAM* l = (LPARAM*)lParam;
+ *l = TRUE;
+ return TRUE;
}
void GetMessageFont(LOGFONT* lf)
{
- SecureZeroMemory(lf, sizeof(LOGFONT));
- NONCLIENTMETRICS ncm;
- ncm.cbSize = sizeof(NONCLIENTMETRICS);
- if (!SysVersion::IsVistaOrLater())
- ncm.cbSize -= sizeof(ncm.iPaddedBorderWidth);
-
- SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0);
- *lf = ncm.lfMessageFont;
+ SecureZeroMemory(lf, sizeof(LOGFONT));
+ NONCLIENTMETRICS ncm;
+ ncm.cbSize = sizeof(NONCLIENTMETRICS);
+ if (!SysVersion::IsVistaOrLater()) {
+ ncm.cbSize -= sizeof(ncm.iPaddedBorderWidth);
+ }
+
+ SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0);
+ *lf = ncm.lfMessageFont;
}
void GetStatusFont(LOGFONT* lf)
{
- SecureZeroMemory(lf, sizeof(LOGFONT));
- NONCLIENTMETRICS ncm;
- ncm.cbSize = sizeof(NONCLIENTMETRICS);
- if (!SysVersion::IsVistaOrLater())
- ncm.cbSize -= sizeof(ncm.iPaddedBorderWidth);
-
- SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0);
- *lf = ncm.lfStatusFont;
+ SecureZeroMemory(lf, sizeof(LOGFONT));
+ NONCLIENTMETRICS ncm;
+ ncm.cbSize = sizeof(NONCLIENTMETRICS);
+ if (!SysVersion::IsVistaOrLater()) {
+ ncm.cbSize -= sizeof(ncm.iPaddedBorderWidth);
+ }
+
+ SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0);
+ *lf = ncm.lfStatusFont;
}
bool IsFontInstalled(LPCTSTR lpszFont)
{
- // Get the screen DC
- CDC dc;
- if (!dc.CreateCompatibleDC(NULL)) {
- return false;
- }
-
- LOGFONT lf = {0};
- // Any character set will do
- lf.lfCharSet = DEFAULT_CHARSET;
- // Set the facename to check for
- _tcscpy_s(lf.lfFaceName, lpszFont);
- LPARAM lParam = 0;
- // Enumerate fonts
- EnumFontFamiliesEx(dc.GetSafeHdc(), &lf, (FONTENUMPROC)EnumFontFamExProc, (LPARAM)&lParam, 0);
-
- return lParam ? true : false;
+ // Get the screen DC
+ CDC dc;
+ if (!dc.CreateCompatibleDC(NULL)) {
+ return false;
+ }
+
+ LOGFONT lf = {0};
+ // Any character set will do
+ lf.lfCharSet = DEFAULT_CHARSET;
+ // Set the facename to check for
+ _tcscpy_s(lf.lfFaceName, lpszFont);
+ LPARAM lParam = 0;
+ // Enumerate fonts
+ EnumFontFamiliesEx(dc.GetSafeHdc(), &lf, (FONTENUMPROC)EnumFontFamExProc, (LPARAM)&lParam, 0);
+
+ return lParam ? true : false;
}
bool ExploreToFile(CString path)
{
- bool success = false;
- HRESULT res = CoInitialize(NULL);
+ bool success = false;
+ HRESULT res = CoInitialize(NULL);
- if (res == S_OK || res == S_FALSE) {
- PIDLIST_ABSOLUTE pidl;
+ if (res == S_OK || res == S_FALSE) {
+ PIDLIST_ABSOLUTE pidl;
- if (SHParseDisplayName(path, NULL, &pidl, 0, NULL) == S_OK) {
- success = SUCCEEDED(SHOpenFolderAndSelectItems(pidl, 0, NULL, 0));
- CoTaskMemFree(pidl);
- }
+ if (SHParseDisplayName(path, NULL, &pidl, 0, NULL) == S_OK) {
+ success = SUCCEEDED(SHOpenFolderAndSelectItems(pidl, 0, NULL, 0));
+ CoTaskMemFree(pidl);
+ }
- CoUninitialize();
- }
+ CoUninitialize();
+ }
- return success;
+ return success;
}
diff --git a/src/DSUtil/WinAPIUtils.h b/src/DSUtil/WinAPIUtils.h
index 33231f878..918480ff6 100644
--- a/src/DSUtil/WinAPIUtils.h
+++ b/src/DSUtil/WinAPIUtils.h
@@ -27,9 +27,9 @@
struct IDirect3D9;
-bool SetPrivilege(LPCTSTR privilege, bool bEnable=true);
+bool SetPrivilege(LPCTSTR privilege, bool bEnable = true);
-bool ExportRegistryKey(CStdioFile& file, HKEY hKeyRoot, CString keyName=_T(""));
+bool ExportRegistryKey(CStdioFile& file, HKEY hKeyRoot, CString keyName = _T(""));
UINT GetAdapter(IDirect3D9* pD3D, HWND hWnd);
diff --git a/src/DSUtil/text.cpp b/src/DSUtil/text.cpp
index 99ce76aa5..3df2726cb 100644
--- a/src/DSUtil/text.cpp
+++ b/src/DSUtil/text.cpp
@@ -26,164 +26,164 @@
DWORD CharSetToCodePage(DWORD dwCharSet)
{
- if (dwCharSet == CP_UTF8) {
- return CP_UTF8;
- }
- if (dwCharSet == CP_UTF7) {
- return CP_UTF7;
- }
- CHARSETINFO cs= {0};
- ::TranslateCharsetInfo((DWORD *)dwCharSet, &cs, TCI_SRCCHARSET);
- return cs.ciACP;
+ if (dwCharSet == CP_UTF8) {
+ return CP_UTF8;
+ }
+ if (dwCharSet == CP_UTF7) {
+ return CP_UTF7;
+ }
+ CHARSETINFO cs = {0};
+ ::TranslateCharsetInfo((DWORD*)dwCharSet, &cs, TCI_SRCCHARSET);
+ return cs.ciACP;
}
CStringA ConvertMBCS(CStringA str, DWORD SrcCharSet, DWORD DstCharSet)
{
- WCHAR* utf16 = DNew WCHAR[str.GetLength()+1];
- memset(utf16, 0, (str.GetLength()+1)*sizeof(WCHAR));
+ WCHAR* utf16 = DNew WCHAR[str.GetLength() + 1];
+ memset(utf16, 0, (str.GetLength() + 1)*sizeof(WCHAR));
- CHAR* mbcs = DNew CHAR[str.GetLength()*6+1];
- memset(mbcs, 0, str.GetLength()*6+1);
+ CHAR* mbcs = DNew CHAR[str.GetLength() * 6 + 1];
+ memset(mbcs, 0, str.GetLength() * 6 + 1);
- int len = MultiByteToWideChar(
- CharSetToCodePage(SrcCharSet), 0,
- str, -1, // null terminated string
- utf16, str.GetLength()+1);
+ int len = MultiByteToWideChar(
+ CharSetToCodePage(SrcCharSet), 0,
+ str, -1, // null terminated string
+ utf16, str.GetLength() + 1);
- len = WideCharToMultiByte(
- CharSetToCodePage(DstCharSet), 0,
- utf16, len,
- mbcs, str.GetLength()*6,
- NULL, NULL);
+ len = WideCharToMultiByte(
+ CharSetToCodePage(DstCharSet), 0,
+ utf16, len,
+ mbcs, str.GetLength() * 6,
+ NULL, NULL);
- str = mbcs;
+ str = mbcs;
- delete [] utf16;
- delete [] mbcs;
+ delete [] utf16;
+ delete [] mbcs;
- return str;
+ return str;
}
CStringA UrlEncode(CStringA str, bool fRaw)
{
- CStringA urlstr;
-
- for (int i = 0; i < str.GetLength(); i++) {
- CHAR c = str[i];
- if (fRaw && c == '+') {
- urlstr += "%2B";
- } else if (c > 0x20 && c < 0x7f && c != '&') {
- urlstr += c;
- } else if (c == 0x20) {
- urlstr += fRaw ? ' ' : '+';
- } else {
- CStringA tmp;
- tmp.Format("%%%02x", (BYTE)c);
- urlstr += tmp;
- }
- }
-
- return urlstr;
+ CStringA urlstr;
+
+ for (int i = 0; i < str.GetLength(); i++) {
+ CHAR c = str[i];
+ if (fRaw && c == '+') {
+ urlstr += "%2B";
+ } else if (c > 0x20 && c < 0x7f && c != '&') {
+ urlstr += c;
+ } else if (c == 0x20) {
+ urlstr += fRaw ? ' ' : '+';
+ } else {
+ CStringA tmp;
+ tmp.Format("%%%02x", (BYTE)c);
+ urlstr += tmp;
+ }
+ }
+
+ return urlstr;
}
CStringA UrlDecode(CStringA str, bool fRaw)
{
- str.Replace("&amp;", "&");
-
- CHAR* s = str.GetBuffer(str.GetLength());
- CHAR* e = s + str.GetLength();
- CHAR* s1 = s;
- CHAR* s2 = s;
- while (s1 < e) {
- CHAR s11 = (s1 < e-1) ? (__isascii(s1[1]) && isupper(s1[1]) ? tolower(s1[1]) : s1[1]) : 0;
- CHAR s12 = (s1 < e-2) ? (__isascii(s1[2]) && isupper(s1[2]) ? tolower(s1[2]) : s1[2]) : 0;
-
- if (*s1 == '%' && s1 < e-2
- && (s1[1] >= '0' && s1[1] <= '9' || s11 >= 'a' && s11 <= 'f')
- && (s1[2] >= '0' && s1[2] <= '9' || s12 >= 'a' && s12 <= 'f')) {
- s1[1] = s11;
- s1[2] = s12;
- *s2 = 0;
- if (s1[1] >= '0' && s1[1] <= '9') {
- *s2 |= s1[1]-'0';
- } else if (s1[1] >= 'a' && s1[1] <= 'f') {
- *s2 |= s1[1]-'a'+10;
- }
- *s2 <<= 4;
- if (s1[2] >= '0' && s1[2] <= '9') {
- *s2 |= s1[2]-'0';
- } else if (s1[2] >= 'a' && s1[2] <= 'f') {
- *s2 |= s1[2]-'a'+10;
- }
- s1 += 2;
- } else {
- *s2 = *s1 == '+' && !fRaw ? ' ' : *s1;
- }
-
- s1++;
- s2++;
- }
-
- str.ReleaseBuffer(int(s2 - s));
-
- return str;
+ str.Replace("&amp;", "&");
+
+ CHAR* s = str.GetBuffer(str.GetLength());
+ CHAR* e = s + str.GetLength();
+ CHAR* s1 = s;
+ CHAR* s2 = s;
+ while (s1 < e) {
+ CHAR s11 = (s1 < e - 1) ? (__isascii(s1[1]) && isupper(s1[1]) ? tolower(s1[1]) : s1[1]) : 0;
+ CHAR s12 = (s1 < e - 2) ? (__isascii(s1[2]) && isupper(s1[2]) ? tolower(s1[2]) : s1[2]) : 0;
+
+ if (*s1 == '%' && s1 < e - 2
+ && (s1[1] >= '0' && s1[1] <= '9' || s11 >= 'a' && s11 <= 'f')
+ && (s1[2] >= '0' && s1[2] <= '9' || s12 >= 'a' && s12 <= 'f')) {
+ s1[1] = s11;
+ s1[2] = s12;
+ *s2 = 0;
+ if (s1[1] >= '0' && s1[1] <= '9') {
+ *s2 |= s1[1] - '0';
+ } else if (s1[1] >= 'a' && s1[1] <= 'f') {
+ *s2 |= s1[1] - 'a' + 10;
+ }
+ *s2 <<= 4;
+ if (s1[2] >= '0' && s1[2] <= '9') {
+ *s2 |= s1[2] - '0';
+ } else if (s1[2] >= 'a' && s1[2] <= 'f') {
+ *s2 |= s1[2] - 'a' + 10;
+ }
+ s1 += 2;
+ } else {
+ *s2 = *s1 == '+' && !fRaw ? ' ' : *s1;
+ }
+
+ s1++;
+ s2++;
+ }
+
+ str.ReleaseBuffer(int(s2 - s));
+
+ return str;
}
CString ExtractTag(CString tag, CMapStringToString& attribs, bool& fClosing)
{
- tag.Trim();
- attribs.RemoveAll();
-
- fClosing = !tag.IsEmpty() ? tag[0] == '/' : false;
- tag.TrimLeft('/');
-
- int i = tag.Find(' ');
- if (i < 0) {
- i = tag.GetLength();
- }
- CString type = tag.Left(i).MakeLower();
- tag = tag.Mid(i).Trim();
-
- while ((i = tag.Find('=')) > 0) {
- CString attrib = tag.Left(i).Trim().MakeLower();
- tag = tag.Mid(i+1);
- for (i = 0; i < tag.GetLength() && _istspace(tag[i]); i++) {
- ;
- }
- tag = i < tag.GetLength() ? tag.Mid(i) : _T("");
- if (!tag.IsEmpty() && tag[0] == '\"') {
- tag = tag.Mid(1);
- i = tag.Find('\"');
- } else {
- i = tag.Find(' ');
- }
- if (i < 0) {
- i = tag.GetLength();
- }
- CString param = tag.Left(i).Trim();
- if (!param.IsEmpty()) {
- attribs[attrib] = param;
- }
- tag = i+1 < tag.GetLength() ? tag.Mid(i+1) : _T("");
- }
-
- return type;
+ tag.Trim();
+ attribs.RemoveAll();
+
+ fClosing = !tag.IsEmpty() ? tag[0] == '/' : false;
+ tag.TrimLeft('/');
+
+ int i = tag.Find(' ');
+ if (i < 0) {
+ i = tag.GetLength();
+ }
+ CString type = tag.Left(i).MakeLower();
+ tag = tag.Mid(i).Trim();
+
+ while ((i = tag.Find('=')) > 0) {
+ CString attrib = tag.Left(i).Trim().MakeLower();
+ tag = tag.Mid(i + 1);
+ for (i = 0; i < tag.GetLength() && _istspace(tag[i]); i++) {
+ ;
+ }
+ tag = i < tag.GetLength() ? tag.Mid(i) : _T("");
+ if (!tag.IsEmpty() && tag[0] == '\"') {
+ tag = tag.Mid(1);
+ i = tag.Find('\"');
+ } else {
+ i = tag.Find(' ');
+ }
+ if (i < 0) {
+ i = tag.GetLength();
+ }
+ CString param = tag.Left(i).Trim();
+ if (!param.IsEmpty()) {
+ attribs[attrib] = param;
+ }
+ tag = i + 1 < tag.GetLength() ? tag.Mid(i + 1) : _T("");
+ }
+
+ return type;
}
CAtlList<CString>& MakeLower(CAtlList<CString>& sl)
{
- POSITION pos = sl.GetHeadPosition();
- while (pos) {
- sl.GetNext(pos).MakeLower();
- }
- return sl;
+ POSITION pos = sl.GetHeadPosition();
+ while (pos) {
+ sl.GetNext(pos).MakeLower();
+ }
+ return sl;
}
CAtlList<CString>& MakeUpper(CAtlList<CString>& sl)
{
- POSITION pos = sl.GetHeadPosition();
- while (pos) {
- sl.GetNext(pos).MakeUpper();
- }
- return sl;
+ POSITION pos = sl.GetHeadPosition();
+ while (pos) {
+ sl.GetNext(pos).MakeUpper();
+ }
+ return sl;
}
diff --git a/src/DSUtil/text.h b/src/DSUtil/text.h
index 5752f8ff3..87aa16e0c 100644
--- a/src/DSUtil/text.h
+++ b/src/DSUtil/text.h
@@ -28,52 +28,52 @@
template<class T, typename SEP>
T Explode(const T& str, CAtlList<T>& sl, SEP sep, size_t limit = 0)
{
- sl.RemoveAll();
+ sl.RemoveAll();
- for (int i = 0, j = 0; ; i = j+1) {
- j = str.Find(sep, i);
+ for (int i = 0, j = 0; ; i = j + 1) {
+ j = str.Find(sep, i);
- if (j < 0 || sl.GetCount() == limit-1) {
- sl.AddTail(str.Mid(i).Trim());
- break;
- } else {
- sl.AddTail(str.Mid(i, j-i).Trim());
- }
- }
+ if (j < 0 || sl.GetCount() == limit - 1) {
+ sl.AddTail(str.Mid(i).Trim());
+ break;
+ } else {
+ sl.AddTail(str.Mid(i, j - i).Trim());
+ }
+ }
- return sl.GetHead();
+ return sl.GetHead();
}
template<class T, typename SEP>
T ExplodeMin(const T& str, CAtlList<T>& sl, SEP sep, size_t limit = 0)
{
- Explode(str, sl, sep, limit);
- POSITION pos = sl.GetHeadPosition();
- while (pos) {
- POSITION tmp = pos;
- if (sl.GetNext(pos).IsEmpty()) {
- sl.RemoveAt(tmp);
- }
- }
- if (sl.IsEmpty()) {
- sl.AddTail(T()); // eh
- }
+ Explode(str, sl, sep, limit);
+ POSITION pos = sl.GetHeadPosition();
+ while (pos) {
+ POSITION tmp = pos;
+ if (sl.GetNext(pos).IsEmpty()) {
+ sl.RemoveAt(tmp);
+ }
+ }
+ if (sl.IsEmpty()) {
+ sl.AddTail(T()); // eh
+ }
- return sl.GetHead();
+ return sl.GetHead();
}
template<class T, typename SEP>
T Implode(const CAtlList<T>& sl, SEP sep)
{
- T ret;
- POSITION pos = sl.GetHeadPosition();
- while (pos) {
- ret += sl.GetNext(pos);
- if (pos) {
- ret += sep;
- }
- }
- return ret;
+ T ret;
+ POSITION pos = sl.GetHeadPosition();
+ while (pos) {
+ ret += sl.GetNext(pos);
+ if (pos) {
+ ret += sep;
+ }
+ }
+ return ret;
}
extern CString ExtractTag(CString tag, CMapStringToString& attribs, bool& fClosing);
diff --git a/src/MPCTestAPI/MPCTestAPI.cpp b/src/MPCTestAPI/MPCTestAPI.cpp
index 564c92ed3..250d12da4 100644
--- a/src/MPCTestAPI/MPCTestAPI.cpp
+++ b/src/MPCTestAPI/MPCTestAPI.cpp
@@ -32,11 +32,11 @@
// CRegisterCopyDataApp
BEGIN_MESSAGE_MAP(CRegisterCopyDataApp, CWinApp)
- //{{AFX_MSG_MAP(CRegisterCopyDataApp)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- // DO NOT EDIT what you see in these blocks of generated code!
- //}}AFX_MSG
- ON_COMMAND(ID_HELP, CWinApp::OnHelp)
+ //{{AFX_MSG_MAP(CRegisterCopyDataApp)
+ // NOTE - the ClassWizard will add and remove mapping macros here.
+ // DO NOT EDIT what you see in these blocks of generated code!
+ //}}AFX_MSG
+ ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
@@ -44,8 +44,8 @@ END_MESSAGE_MAP()
CRegisterCopyDataApp::CRegisterCopyDataApp()
{
- // TODO: add construction code here,
- // Place all significant initialization in InitInstance
+ // TODO: add construction code here,
+ // Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
@@ -58,26 +58,26 @@ CRegisterCopyDataApp theApp;
BOOL CRegisterCopyDataApp::InitInstance()
{
- AfxEnableControlContainer();
+ AfxEnableControlContainer();
- // Standard initialization
- // If you are not using these features and wish to reduce the size
- // of your final executable, you should remove from the following
- // the specific initialization routines you do not need.
+ // Standard initialization
+ // If you are not using these features and wish to reduce the size
+ // of your final executable, you should remove from the following
+ // the specific initialization routines you do not need.
- CRegisterCopyDataDlg dlg;
- m_pMainWnd = &dlg;
- INT_PTR nResponse = dlg.DoModal();
+ CRegisterCopyDataDlg dlg;
+ m_pMainWnd = &dlg;
+ INT_PTR nResponse = dlg.DoModal();
- if (nResponse == IDOK) {
- // TODO: Place code here to handle when the dialog is
- // dismissed with OK
- } else if (nResponse == IDCANCEL) {
- // TODO: Place code here to handle when the dialog is
- // dismissed with Cancel
- }
+ if (nResponse == IDOK) {
+ // TODO: Place code here to handle when the dialog is
+ // dismissed with OK
+ } else if (nResponse == IDCANCEL) {
+ // TODO: Place code here to handle when the dialog is
+ // dismissed with Cancel
+ }
- // Since the dialog has been closed, return FALSE so that we exit the
- // application, rather than start the application's message pump.
- return FALSE;
+ // Since the dialog has been closed, return FALSE so that we exit the
+ // application, rather than start the application's message pump.
+ return FALSE;
}
diff --git a/src/MPCTestAPI/MPCTestAPI.h b/src/MPCTestAPI/MPCTestAPI.h
index c3991fbbf..358bf34a5 100644
--- a/src/MPCTestAPI/MPCTestAPI.h
+++ b/src/MPCTestAPI/MPCTestAPI.h
@@ -34,20 +34,20 @@
class CRegisterCopyDataApp : public CWinApp
{
public:
- CRegisterCopyDataApp();
+ CRegisterCopyDataApp();
- // Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CRegisterCopyDataApp)
+ // Overrides
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CRegisterCopyDataApp)
public:
- virtual BOOL InitInstance();
- //}}AFX_VIRTUAL
+ virtual BOOL InitInstance();
+ //}}AFX_VIRTUAL
- // Implementation
+ // Implementation
- //{{AFX_MSG(CRegisterCopyDataApp)
- // NOTE - the ClassWizard will add and remove member functions here.
- // DO NOT EDIT what you see in these blocks of generated code !
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
+ //{{AFX_MSG(CRegisterCopyDataApp)
+ // NOTE - the ClassWizard will add and remove member functions here.
+ // DO NOT EDIT what you see in these blocks of generated code !
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
};
diff --git a/src/MPCTestAPI/MPCTestAPIDlg.cpp b/src/MPCTestAPI/MPCTestAPIDlg.cpp
index 261497224..cbaa6ed25 100644
--- a/src/MPCTestAPI/MPCTestAPIDlg.cpp
+++ b/src/MPCTestAPI/MPCTestAPIDlg.cpp
@@ -31,24 +31,24 @@
LPCTSTR GetMPCCommandName(MPCAPI_COMMAND nCmd)
{
- switch (nCmd) {
- case CMD_CONNECT :
- return _T("CMD_CONNECT");
- case CMD_STATE :
- return _T("CMD_STATE");
- case CMD_PLAYMODE :
- return _T("CMD_PLAYMODE");
- case CMD_NOWPLAYING :
- return _T("CMD_NOWPLAYING");
- case CMD_LISTSUBTITLETRACKS :
- return _T("CMD_LISTSUBTITLETRACKS");
- case CMD_LISTAUDIOTRACKS :
- return _T("CMD_LISTAUDIOTRACKS");
- case CMD_PLAYLIST :
- return _T("CMD_PLAYLIST");
- default :
- return _T("CMD_UNK");
- }
+ switch (nCmd) {
+ case CMD_CONNECT :
+ return _T("CMD_CONNECT");
+ case CMD_STATE :
+ return _T("CMD_STATE");
+ case CMD_PLAYMODE :
+ return _T("CMD_PLAYMODE");
+ case CMD_NOWPLAYING :
+ return _T("CMD_NOWPLAYING");
+ case CMD_LISTSUBTITLETRACKS :
+ return _T("CMD_LISTSUBTITLETRACKS");
+ case CMD_LISTAUDIOTRACKS :
+ return _T("CMD_LISTAUDIOTRACKS");
+ case CMD_PLAYLIST :
+ return _T("CMD_PLAYLIST");
+ default :
+ return _T("CMD_UNK");
+ }
}
/////////////////////////////////////////////////////////////////////////////
@@ -57,45 +57,45 @@ LPCTSTR GetMPCCommandName(MPCAPI_COMMAND nCmd)
class CAboutDlg : public CDialog
{
public:
- CAboutDlg();
+ CAboutDlg();
- // Dialog Data
- //{{AFX_DATA(CAboutDlg)
- enum { IDD = IDD_ABOUTBOX };
- //}}AFX_DATA
+ // Dialog Data
+ //{{AFX_DATA(CAboutDlg)
+ enum { IDD = IDD_ABOUTBOX };
+ //}}AFX_DATA
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CAboutDlg)
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CAboutDlg)
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- //}}AFX_VIRTUAL
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ //}}AFX_VIRTUAL
- // Implementation
+ // Implementation
protected:
- //{{AFX_MSG(CAboutDlg)
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
+ //{{AFX_MSG(CAboutDlg)
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
- //{{AFX_DATA_INIT(CAboutDlg)
- //}}AFX_DATA_INIT
+ //{{AFX_DATA_INIT(CAboutDlg)
+ //}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAboutDlg)
- //}}AFX_DATA_MAP
+ CDialog::DoDataExchange(pDX);
+ //{{AFX_DATA_MAP(CAboutDlg)
+ //}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- //{{AFX_MSG_MAP(CAboutDlg)
- // No message handlers
- //}}AFX_MSG_MAP
+ //{{AFX_MSG_MAP(CAboutDlg)
+ // No message handlers
+ //}}AFX_MSG_MAP
END_MESSAGE_MAP()
@@ -104,41 +104,41 @@ END_MESSAGE_MAP()
// CRegisterCopyDataDlg dialog
CRegisterCopyDataDlg::CRegisterCopyDataDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CRegisterCopyDataDlg::IDD, pParent)
- , m_strMPCPath(_T(""))
- , m_txtCommand(_T(""))
- , m_nCommandType(0)
- , m_hWndMPC(NULL)
+ : CDialog(CRegisterCopyDataDlg::IDD, pParent)
+ , m_strMPCPath(_T(""))
+ , m_txtCommand(_T(""))
+ , m_nCommandType(0)
+ , m_hWndMPC(NULL)
{
- //{{AFX_DATA_INIT(CRegisterCopyDataDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
+ //{{AFX_DATA_INIT(CRegisterCopyDataDlg)
+ // NOTE: the ClassWizard will add member initialization here
+ //}}AFX_DATA_INIT
+ // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
+ m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CRegisterCopyDataDlg::DoDataExchange(CDataExchange* pDX)
{
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CRegisterCopyDataDlg)
- // NOTE: the ClassWizard will add DDX and DDV calls here
- //}}AFX_DATA_MAP
- DDX_Text(pDX, IDC_EDIT1, m_strMPCPath);
- DDX_Control(pDX, IDC_LOGLIST, m_listBox);
- DDX_Text(pDX, IDC_EDIT2, m_txtCommand);
- DDX_CBIndex(pDX, IDC_COMBO1, m_nCommandType);
+ CDialog::DoDataExchange(pDX);
+ //{{AFX_DATA_MAP(CRegisterCopyDataDlg)
+ // NOTE: the ClassWizard will add DDX and DDV calls here
+ //}}AFX_DATA_MAP
+ DDX_Text(pDX, IDC_EDIT1, m_strMPCPath);
+ DDX_Control(pDX, IDC_LOGLIST, m_listBox);
+ DDX_Text(pDX, IDC_EDIT2, m_txtCommand);
+ DDX_CBIndex(pDX, IDC_COMBO1, m_nCommandType);
}
BEGIN_MESSAGE_MAP(CRegisterCopyDataDlg, CDialog)
- //{{AFX_MSG_MAP(CRegisterCopyDataDlg)
- ON_WM_SYSCOMMAND()
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- ON_BN_CLICKED(IDC_BUTTON_FINDWINDOW, OnButtonFindwindow)
- ON_WM_COPYDATA()
- //}}AFX_MSG_MAP
- ON_BN_CLICKED(IDC_BUTTON_SENDCOMMAND, &CRegisterCopyDataDlg::OnBnClickedButtonSendcommand)
+ //{{AFX_MSG_MAP(CRegisterCopyDataDlg)
+ ON_WM_SYSCOMMAND()
+ ON_WM_PAINT()
+ ON_WM_QUERYDRAGICON()
+ ON_BN_CLICKED(IDC_BUTTON_FINDWINDOW, OnButtonFindwindow)
+ ON_WM_COPYDATA()
+ //}}AFX_MSG_MAP
+ ON_BN_CLICKED(IDC_BUTTON_SENDCOMMAND, &CRegisterCopyDataDlg::OnBnClickedButtonSendcommand)
END_MESSAGE_MAP()
@@ -147,64 +147,64 @@ END_MESSAGE_MAP()
BOOL CRegisterCopyDataDlg::OnInitDialog()
{
- CDialog::OnInitDialog();
+ CDialog::OnInitDialog();
- // Add "About..." menu item to system menu.
+ // Add "About..." menu item to system menu.
- // IDM_ABOUTBOX must be in the system command range.
- ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
- ASSERT(IDM_ABOUTBOX < 0xF000);
+ // IDM_ABOUTBOX must be in the system command range.
+ ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
+ ASSERT(IDM_ABOUTBOX < 0xF000);
- CMenu* pSysMenu = GetSystemMenu(FALSE);
- if (pSysMenu != NULL) {
- CString strAboutMenu;
- strAboutMenu.LoadString(IDS_ABOUTBOX);
- if (!strAboutMenu.IsEmpty()) {
- pSysMenu->AppendMenu(MF_SEPARATOR);
- pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
- }
- }
+ CMenu* pSysMenu = GetSystemMenu(FALSE);
+ if (pSysMenu != NULL) {
+ CString strAboutMenu;
+ strAboutMenu.LoadString(IDS_ABOUTBOX);
+ if (!strAboutMenu.IsEmpty()) {
+ pSysMenu->AppendMenu(MF_SEPARATOR);
+ pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
+ }
+ }
- // Set the icon for this dialog. The framework does this automatically
- // when the application's main window is not a dialog
- SetIcon(m_hIcon, TRUE); // Set big icon
- SetIcon(m_hIcon, FALSE); // Set small icon
+ // Set the icon for this dialog. The framework does this automatically
+ // when the application's main window is not a dialog
+ SetIcon(m_hIcon, TRUE); // Set big icon
+ SetIcon(m_hIcon, FALSE); // Set small icon
- // TODO: Add extra initialization here
- m_strMPCPath = _T("..\\..\\..\\..\\bin\\");
+ // TODO: Add extra initialization here
+ m_strMPCPath = _T("..\\..\\..\\..\\bin\\");
#if defined(_WIN64)
- m_strMPCPath += _T("mpc-hc_x64");
+ m_strMPCPath += _T("mpc-hc_x64");
#else
- m_strMPCPath += _T("mpc-hc_x86");
+ m_strMPCPath += _T("mpc-hc_x86");
#endif // _WIN64
#if defined(_DEBUG)
- m_strMPCPath += _T("_Debug\\");
+ m_strMPCPath += _T("_Debug\\");
#else
- m_strMPCPath += _T("\\");
+ m_strMPCPath += _T("\\");
#endif // _DEBUG
#if defined(_WIN64)
- m_strMPCPath += _T("mpc-hc64.exe");
+ m_strMPCPath += _T("mpc-hc64.exe");
#else
- m_strMPCPath += _T("mpc-hc.exe");
+ m_strMPCPath += _T("mpc-hc.exe");
#endif // _WIN64
- UpdateData(FALSE);
+ UpdateData(FALSE);
- return TRUE; // return TRUE unless you set the focus to a control
+ return TRUE; // return TRUE unless you set the focus to a control
}
void CRegisterCopyDataDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
- if ((nID & 0xFFF0) == IDM_ABOUTBOX) {
- CAboutDlg dlgAbout;
- dlgAbout.DoModal();
- } else {
- CDialog::OnSysCommand(nID, lParam);
- }
+ if ((nID & 0xFFF0) == IDM_ABOUTBOX) {
+ CAboutDlg dlgAbout;
+ dlgAbout.DoModal();
+ } else {
+ CDialog::OnSysCommand(nID, lParam);
+ }
}
// If you add a minimize button to your dialog, you will need the code below
@@ -213,24 +213,24 @@ void CRegisterCopyDataDlg::OnSysCommand(UINT nID, LPARAM lParam)
void CRegisterCopyDataDlg::OnPaint()
{
- if (IsIconic()) {
- CPaintDC dc(this); // device context for painting
-
- SendMessage(WM_ICONERASEBKGND, (WPARAM)dc.GetSafeHdc(), 0);
-
- // Center icon in client rectangle
- int cxIcon = GetSystemMetrics(SM_CXICON);
- int cyIcon = GetSystemMetrics(SM_CYICON);
- CRect rect;
- GetClientRect(&rect);
- int x = (rect.Width() - cxIcon + 1) / 2;
- int y = (rect.Height() - cyIcon + 1) / 2;
-
- // Draw the icon
- dc.DrawIcon(x, y, m_hIcon);
- } else {
- CDialog::OnPaint();
- }
+ if (IsIconic()) {
+ CPaintDC dc(this); // device context for painting
+
+ SendMessage(WM_ICONERASEBKGND, (WPARAM)dc.GetSafeHdc(), 0);
+
+ // Center icon in client rectangle
+ int cxIcon = GetSystemMetrics(SM_CXICON);
+ int cyIcon = GetSystemMetrics(SM_CYICON);
+ CRect rect;
+ GetClientRect(&rect);
+ int x = (rect.Width() - cxIcon + 1) / 2;
+ int y = (rect.Height() - cyIcon + 1) / 2;
+
+ // Draw the icon
+ dc.DrawIcon(x, y, m_hIcon);
+ } else {
+ CDialog::OnPaint();
+ }
}
@@ -238,128 +238,128 @@ void CRegisterCopyDataDlg::OnPaint()
// the minimized window.
HCURSOR CRegisterCopyDataDlg::OnQueryDragIcon()
{
- return (HCURSOR) m_hIcon;
+ return (HCURSOR) m_hIcon;
}
void CRegisterCopyDataDlg::OnButtonFindwindow()
{
- CString strExec;
- STARTUPINFO StartupInfo;
- PROCESS_INFORMATION ProcessInfo;
+ CString strExec;
+ STARTUPINFO StartupInfo;
+ PROCESS_INFORMATION ProcessInfo;
- strExec.Format(_T("%s /slave %d"), m_strMPCPath, GetSafeHwnd());
- UpdateData(TRUE);
+ strExec.Format(_T("%s /slave %d"), m_strMPCPath, GetSafeHwnd());
+ UpdateData(TRUE);
- memset(&StartupInfo, 0, sizeof(StartupInfo));
- StartupInfo.cb = sizeof(StartupInfo);
- GetStartupInfo(&StartupInfo);
- CreateProcess(NULL, (LPTSTR)(LPCTSTR)strExec, NULL, NULL, FALSE, 0, NULL, NULL, &StartupInfo, &ProcessInfo);
+ memset(&StartupInfo, 0, sizeof(StartupInfo));
+ StartupInfo.cb = sizeof(StartupInfo);
+ GetStartupInfo(&StartupInfo);
+ CreateProcess(NULL, (LPTSTR)(LPCTSTR)strExec, NULL, NULL, FALSE, 0, NULL, NULL, &StartupInfo, &ProcessInfo);
}
void CRegisterCopyDataDlg::Senddata(MPCAPI_COMMAND nCmd, LPCTSTR strCommand)
{
- if (m_hWndMPC) {
- COPYDATASTRUCT MyCDS;
+ if (m_hWndMPC) {
+ COPYDATASTRUCT MyCDS;
- MyCDS.dwData = nCmd;
- MyCDS.cbData = (DWORD)(_tcslen(strCommand) + 1) * sizeof(TCHAR);
- MyCDS.lpData = (LPVOID) strCommand;
+ MyCDS.dwData = nCmd;
+ MyCDS.cbData = (DWORD)(_tcslen(strCommand) + 1) * sizeof(TCHAR);
+ MyCDS.lpData = (LPVOID) strCommand;
- ::SendMessage(m_hWndMPC, WM_COPYDATA, (WPARAM)GetSafeHwnd(), (LPARAM)&MyCDS);
- }
+ ::SendMessage(m_hWndMPC, WM_COPYDATA, (WPARAM)GetSafeHwnd(), (LPARAM)&MyCDS);
+ }
}
BOOL CRegisterCopyDataDlg::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct)
{
- CString strMsg;
+ CString strMsg;
- if (pCopyDataStruct->dwData == CMD_CONNECT) {
- m_hWndMPC = (HWND)_wtol((LPCTSTR)pCopyDataStruct->lpData);
- }
+ if (pCopyDataStruct->dwData == CMD_CONNECT) {
+ m_hWndMPC = (HWND)_wtol((LPCTSTR)pCopyDataStruct->lpData);
+ }
- strMsg.Format(_T("%s : %s"), GetMPCCommandName((MPCAPI_COMMAND)pCopyDataStruct->dwData), (LPCTSTR)pCopyDataStruct->lpData);
- m_listBox.InsertString(0, strMsg);
- return CDialog::OnCopyData(pWnd, pCopyDataStruct);
+ strMsg.Format(_T("%s : %s"), GetMPCCommandName((MPCAPI_COMMAND)pCopyDataStruct->dwData), (LPCTSTR)pCopyDataStruct->lpData);
+ m_listBox.InsertString(0, strMsg);
+ return CDialog::OnCopyData(pWnd, pCopyDataStruct);
}
void CRegisterCopyDataDlg::OnBnClickedButtonSendcommand()
{
- CString strEmpty(_T(""));
- UpdateData(TRUE);
-
- switch (m_nCommandType) {
- case 0 :
- Senddata(CMD_OPENFILE, m_txtCommand);
- break;
- case 1 :
- Senddata(CMD_STOP, strEmpty);
- break;
- case 2 :
- Senddata(CMD_CLOSEFILE, strEmpty);
- break;
- case 3 :
- Senddata(CMD_PLAYPAUSE, strEmpty);
- break;
- case 4 :
- Senddata(CMD_ADDTOPLAYLIST, m_txtCommand);
- break;
- case 5 :
- Senddata(CMD_STARTPLAYLIST, strEmpty);
- break;
- case 6 :
- Senddata(CMD_CLEARPLAYLIST, strEmpty);
- break;
- case 7 :
- Senddata(CMD_SETPOSITION, m_txtCommand);
- break;
- case 8 :
- Senddata(CMD_SETAUDIODELAY, m_txtCommand);
- break;
- case 9 :
- Senddata(CMD_SETSUBTITLEDELAY, m_txtCommand);
- break;
- case 10 :
- Senddata(CMD_GETAUDIOTRACKS, strEmpty);
- break;
- case 11 :
- Senddata(CMD_GETSUBTITLETRACKS, strEmpty);
- break;
- case 12 :
- Senddata(CMD_GETPLAYLIST, strEmpty);
- break;
- case 13 :
- Senddata(CMD_SETINDEXPLAYLIST, m_txtCommand);
- break;
- case 14 :
- Senddata(CMD_SETAUDIOTRACK, m_txtCommand);
- break;
- case 15 :
- Senddata(CMD_SETSUBTITLETRACK, m_txtCommand);
- break;
- case 16 :
- Senddata(CMD_TOGGLEFULLSCREEN, m_txtCommand);
- break;
- case 17 :
- Senddata(CMD_JUMPFORWARDMED, m_txtCommand);
- break;
- case 18 :
- Senddata(CMD_JUMPBACKWARDMED, m_txtCommand);
- break;
- case 19 :
- Senddata(CMD_INCREASEVOLUME, m_txtCommand);
- break;
- case 20 :
- Senddata(CMD_DECREASEVOLUME, m_txtCommand);
- break;
- case 21 :
- Senddata(CMD_SHADER_TOGGLE, m_txtCommand);
- break;
- case 22 :
- Senddata(CMD_CLOSEAPP, m_txtCommand);
- break;
- }
+ CString strEmpty(_T(""));
+ UpdateData(TRUE);
+
+ switch (m_nCommandType) {
+ case 0 :
+ Senddata(CMD_OPENFILE, m_txtCommand);
+ break;
+ case 1 :
+ Senddata(CMD_STOP, strEmpty);
+ break;
+ case 2 :
+ Senddata(CMD_CLOSEFILE, strEmpty);
+ break;
+ case 3 :
+ Senddata(CMD_PLAYPAUSE, strEmpty);
+ break;
+ case 4 :
+ Senddata(CMD_ADDTOPLAYLIST, m_txtCommand);
+ break;
+ case 5 :
+ Senddata(CMD_STARTPLAYLIST, strEmpty);
+ break;
+ case 6 :
+ Senddata(CMD_CLEARPLAYLIST, strEmpty);
+ break;
+ case 7 :
+ Senddata(CMD_SETPOSITION, m_txtCommand);
+ break;
+ case 8 :
+ Senddata(CMD_SETAUDIODELAY, m_txtCommand);
+ break;
+ case 9 :
+ Senddata(CMD_SETSUBTITLEDELAY, m_txtCommand);
+ break;
+ case 10 :
+ Senddata(CMD_GETAUDIOTRACKS, strEmpty);
+ break;
+ case 11 :
+ Senddata(CMD_GETSUBTITLETRACKS, strEmpty);
+ break;
+ case 12 :
+ Senddata(CMD_GETPLAYLIST, strEmpty);
+ break;
+ case 13 :
+ Senddata(CMD_SETINDEXPLAYLIST, m_txtCommand);
+ break;
+ case 14 :
+ Senddata(CMD_SETAUDIOTRACK, m_txtCommand);
+ break;
+ case 15 :
+ Senddata(CMD_SETSUBTITLETRACK, m_txtCommand);
+ break;
+ case 16 :
+ Senddata(CMD_TOGGLEFULLSCREEN, m_txtCommand);
+ break;
+ case 17 :
+ Senddata(CMD_JUMPFORWARDMED, m_txtCommand);
+ break;
+ case 18 :
+ Senddata(CMD_JUMPBACKWARDMED, m_txtCommand);
+ break;
+ case 19 :
+ Senddata(CMD_INCREASEVOLUME, m_txtCommand);
+ break;
+ case 20 :
+ Senddata(CMD_DECREASEVOLUME, m_txtCommand);
+ break;
+ case 21 :
+ Senddata(CMD_SHADER_TOGGLE, m_txtCommand);
+ break;
+ case 22 :
+ Senddata(CMD_CLOSEAPP, m_txtCommand);
+ break;
+ }
}
diff --git a/src/MPCTestAPI/MPCTestAPIDlg.h b/src/MPCTestAPI/MPCTestAPIDlg.h
index 855342331..1d12c08be 100644
--- a/src/MPCTestAPI/MPCTestAPIDlg.h
+++ b/src/MPCTestAPI/MPCTestAPIDlg.h
@@ -33,43 +33,43 @@
class CRegisterCopyDataDlg : public CDialog
{
- // Construction
+ // Construction
public:
- HWND m_RemoteWindow;
- CRegisterCopyDataDlg(CWnd* pParent = NULL); // standard constructor
+ HWND m_RemoteWindow;
+ CRegisterCopyDataDlg(CWnd* pParent = NULL); // standard constructor
- // Dialog Data
- //{{AFX_DATA(CRegisterCopyDataDlg)
- enum { IDD = IDD_REGISTERCOPYDATA_DIALOG };
- // NOTE: the ClassWizard will add data members here
- //}}AFX_DATA
+ // Dialog Data
+ //{{AFX_DATA(CRegisterCopyDataDlg)
+ enum { IDD = IDD_REGISTERCOPYDATA_DIALOG };
+ // NOTE: the ClassWizard will add data members here
+ //}}AFX_DATA
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CRegisterCopyDataDlg)
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CRegisterCopyDataDlg)
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- //}}AFX_VIRTUAL
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ //}}AFX_VIRTUAL
- // Implementation
+ // Implementation
protected:
- HICON m_hIcon;
- HWND m_hWndMPC;
+ HICON m_hIcon;
+ HWND m_hWndMPC;
- // Generated message map functions
- //{{AFX_MSG(CRegisterCopyDataDlg)
- virtual BOOL OnInitDialog();
- afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
- afx_msg void OnPaint();
- afx_msg HCURSOR OnQueryDragIcon();
- afx_msg void OnButtonFindwindow();
- afx_msg BOOL OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct);
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
+ // Generated message map functions
+ //{{AFX_MSG(CRegisterCopyDataDlg)
+ virtual BOOL OnInitDialog();
+ afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
+ afx_msg void OnPaint();
+ afx_msg HCURSOR OnQueryDragIcon();
+ afx_msg void OnButtonFindwindow();
+ afx_msg BOOL OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct);
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
public:
- CString m_strMPCPath;
- CHScrollListBox m_listBox;
- CString m_txtCommand;
- int m_nCommandType;
- afx_msg void OnBnClickedButtonSendcommand();
- void Senddata(MPCAPI_COMMAND nCmd, LPCTSTR strCommand);
+ CString m_strMPCPath;
+ CHScrollListBox m_listBox;
+ CString m_txtCommand;
+ int m_nCommandType;
+ afx_msg void OnBnClickedButtonSendcommand();
+ void Senddata(MPCAPI_COMMAND nCmd, LPCTSTR strCommand);
};
diff --git a/src/SubPic/CoordGeom.cpp b/src/SubPic/CoordGeom.cpp
index 2c43f10f6..073255c15 100644
--- a/src/SubPic/CoordGeom.cpp
+++ b/src/SubPic/CoordGeom.cpp
@@ -31,319 +31,319 @@
Vector::Vector(float x, float y, float z)
{
- this->x = x;
- this->y = y;
- this->z = z;
+ this->x = x;
+ this->y = y;
+ this->z = z;
}
void Vector::Set(float x, float y, float z)
{
- this->x = x;
- this->y = y;
- this->z = z;
+ this->x = x;
+ this->y = y;
+ this->z = z;
}
float Vector::Length()
{
- return sqrt(x * x + y * y + z * z);
+ return sqrt(x * x + y * y + z * z);
}
float Vector::Sum()
{
- return (x + y + z);
+ return (x + y + z);
}
float Vector::CrossSum()
{
- return (x*y + x*z + y*z);
+ return (x * y + x * z + y * z);
}
Vector Vector::Cross()
{
- return Vector(x*y, x*z, y*z);
+ return Vector(x * y, x * z, y * z);
}
Vector Vector::Pow(float exp)
{
- return (exp == 0 ? Vector(1, 1, 1) : exp == 1 ? *this : Vector(pow(x, exp), pow(y, exp), pow(z, exp)));
+ return (exp == 0 ? Vector(1, 1, 1) : exp == 1 ? *this : Vector(pow(x, exp), pow(y, exp), pow(z, exp)));
}
Vector Vector::Unit()
{
- float l = Length();
- if (!l || l == 1) {
- return *this;
- }
- return (*this * (1 / l));
+ float l = Length();
+ if (!l || l == 1) {
+ return *this;
+ }
+ return (*this * (1 / l));
}
Vector& Vector::Unitalize()
{
- return (*this = Unit());
+ return (*this = Unit());
}
Vector Vector::Normal(Vector& a, Vector& b)
{
- return ((a - *this) % (b - a));
+ return ((a - *this) % (b - a));
}
float Vector::Angle(Vector& a, Vector& b)
{
- return (((a - *this).Unit()).Angle((b - *this).Unit()));
+ return (((a - *this).Unit()).Angle((b - *this).Unit()));
}
float Vector::Angle(Vector& a)
{
- float angle = *this | a;
- return ((angle > 1) ? 0 : (angle < -1) ? (float)M_PI : acos(angle));
+ float angle = *this | a;
+ return ((angle > 1) ? 0 : (angle < -1) ? (float)M_PI : acos(angle));
}
void Vector::Angle(float& u, float& v)
{
- Vector n = Unit();
+ Vector n = Unit();
- u = asin(n.y);
+ u = asin(n.y);
- if (IsZero(n.z)) {
- v = (float)M_PI_2 * Sgn(n.x);
- } else if (n.z > 0) {
- v = atan(n.x / n.z);
- } else if (n.z < 0) {
- v = IsZero(n.x) ? (float)M_PI : ((float)M_PI * Sgn(n.x) + atan(n.x / n.z));
- }
+ if (IsZero(n.z)) {
+ v = (float)M_PI_2 * Sgn(n.x);
+ } else if (n.z > 0) {
+ v = atan(n.x / n.z);
+ } else if (n.z < 0) {
+ v = IsZero(n.x) ? (float)M_PI : ((float)M_PI * Sgn(n.x) + atan(n.x / n.z));
+ }
}
Vector Vector::Angle()
{
- Vector ret;
- Angle(ret.x, ret.y);
- ret.z = 0;
- return ret;
+ Vector ret;
+ Angle(ret.x, ret.y);
+ ret.z = 0;
+ return ret;
}
Vector& Vector::Min(Vector& a)
{
- x = (x < a.x) ? x : a.x;
- y = (y < a.y) ? y : a.y;
- z = (z < a.z) ? z : a.z;
- return *this;
+ x = (x < a.x) ? x : a.x;
+ y = (y < a.y) ? y : a.y;
+ z = (z < a.z) ? z : a.z;
+ return *this;
}
Vector& Vector::Max(Vector& a)
{
- x = (x > a.x) ? x : a.x;
- y = (y > a.y) ? y : a.y;
- z = (z > a.z) ? z : a.z;
- return *this;
+ x = (x > a.x) ? x : a.x;
+ y = (y > a.y) ? y : a.y;
+ z = (z > a.z) ? z : a.z;
+ return *this;
}
Vector Vector::Abs()
{
- return Vector(fabs(x), fabs(y), fabs(z));
+ return Vector(fabs(x), fabs(y), fabs(z));
}
Vector Vector::Reflect(Vector& n)
{
- return (n * ((-*this) | n) * 2 - (-*this));
+ return (n * ((-*this) | n) * 2 - (-*this));
}
Vector Vector::Refract(Vector& N, float nFront, float nBack, float* nOut)
{
- Vector D = -*this;
+ Vector D = -*this;
- float N_dot_D = (N | D);
- float n = N_dot_D >= 0 ? (nFront / nBack) : (nBack / nFront);
+ float N_dot_D = (N | D);
+ float n = N_dot_D >= 0 ? (nFront / nBack) : (nBack / nFront);
- Vector cos_D = N * N_dot_D;
- Vector sin_T = (cos_D - D) * n;
+ Vector cos_D = N * N_dot_D;
+ Vector sin_T = (cos_D - D) * n;
- float len_sin_T = sin_T | sin_T;
+ float len_sin_T = sin_T | sin_T;
- if (len_sin_T > 1) {
- if (nOut) {
- *nOut = N_dot_D >= 0 ? nFront : nBack;
- }
- return this->Reflect(N);
- }
+ if (len_sin_T > 1) {
+ if (nOut) {
+ *nOut = N_dot_D >= 0 ? nFront : nBack;
+ }
+ return this->Reflect(N);
+ }
- float N_dot_T = (float)sqrt(1.0 - len_sin_T);
- if (N_dot_D < 0) {
- N_dot_T = -N_dot_T;
- }
+ float N_dot_T = (float)sqrt(1.0 - len_sin_T);
+ if (N_dot_D < 0) {
+ N_dot_T = -N_dot_T;
+ }
- if (nOut) {
- *nOut = N_dot_D >= 0 ? nBack : nFront;
- }
+ if (nOut) {
+ *nOut = N_dot_D >= 0 ? nBack : nFront;
+ }
- return (sin_T - (N * N_dot_T));
+ return (sin_T - (N * N_dot_T));
}
Vector Vector::Refract2(Vector& N, float nFrom, float nTo, float* nOut)
{
- Vector D = -*this;
+ Vector D = -*this;
- float N_dot_D = (N | D);
- float n = nFrom / nTo;
+ float N_dot_D = (N | D);
+ float n = nFrom / nTo;
- Vector cos_D = N * N_dot_D;
- Vector sin_T = (cos_D - D) * n;
+ Vector cos_D = N * N_dot_D;
+ Vector sin_T = (cos_D - D) * n;
- float len_sin_T = sin_T | sin_T;
+ float len_sin_T = sin_T | sin_T;
- if (len_sin_T > 1) {
- if (nOut) {
- *nOut = nFrom;
- }
- return this->Reflect(N);
- }
+ if (len_sin_T > 1) {
+ if (nOut) {
+ *nOut = nFrom;
+ }
+ return this->Reflect(N);
+ }
- float N_dot_T = (float)sqrt(1.0 - len_sin_T);
- if (N_dot_D < 0) {
- N_dot_T = -N_dot_T;
- }
+ float N_dot_T = (float)sqrt(1.0 - len_sin_T);
+ if (N_dot_D < 0) {
+ N_dot_T = -N_dot_T;
+ }
- if (nOut) {
- *nOut = nTo;
- }
+ if (nOut) {
+ *nOut = nTo;
+ }
- return (sin_T - (N * N_dot_T));
+ return (sin_T - (N * N_dot_T));
}
float Vector::operator | (Vector& v)
{
- return (x * v.x + y * v.y + z * v.z);
+ return (x * v.x + y * v.y + z * v.z);
}
Vector Vector::operator % (Vector& v)
{
- return Vector(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x);
+ return Vector(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x);
}
-float& Vector::operator [] (size_t i)
+float& Vector::operator [](size_t i)
{
- return (!i ? x : (i == 1) ? y : z);
+ return (!i ? x : (i == 1) ? y : z);
}
Vector Vector::operator - ()
{
- return Vector(-x, -y, -z);
+ return Vector(-x, -y, -z);
}
bool Vector::operator == (const Vector& v) const
{
- if (IsZero(x - v.x) && IsZero(y - v.y) && IsZero(z - v.z)) {
- return true;
- }
- return false;
+ if (IsZero(x - v.x) && IsZero(y - v.y) && IsZero(z - v.z)) {
+ return true;
+ }
+ return false;
}
bool Vector::operator != (const Vector& v) const
{
- return ((*this == v) ? false : true);
+ return ((*this == v) ? false : true);
}
Vector Vector::operator + (float d)
{
- return Vector(x + d, y + d, z + d);
+ return Vector(x + d, y + d, z + d);
}
Vector Vector::operator + (Vector& v)
{
- return Vector(x + v.x, y + v.y, z + v.z);
+ return Vector(x + v.x, y + v.y, z + v.z);
}
Vector Vector::operator - (float d)
{
- return Vector(x - d, y - d, z - d);
+ return Vector(x - d, y - d, z - d);
}
Vector Vector::operator - (Vector& v)
{
- return Vector(x - v.x, y - v.y, z - v.z);
+ return Vector(x - v.x, y - v.y, z - v.z);
}
Vector Vector::operator * (float d)
{
- return Vector(x * d, y * d, z * d);
+ return Vector(x * d, y * d, z * d);
}
Vector Vector::operator * (Vector& v)
{
- return Vector(x * v.x, y * v.y, z * v.z);
+ return Vector(x * v.x, y * v.y, z * v.z);
}
Vector Vector::operator / (float d)
{
- return Vector(x / d, y / d, z / d);
+ return Vector(x / d, y / d, z / d);
}
Vector Vector::operator / (Vector& v)
{
- return Vector(x / v.x, y / v.y, z / v.z);
+ return Vector(x / v.x, y / v.y, z / v.z);
}
Vector& Vector::operator += (float d)
{
- x += d;
- y += d;
- z += d;
- return *this;
+ x += d;
+ y += d;
+ z += d;
+ return *this;
}
Vector& Vector::operator += (Vector& v)
{
- x += v.x;
- y += v.y;
- z += v.z;
- return *this;
+ x += v.x;
+ y += v.y;
+ z += v.z;
+ return *this;
}
Vector& Vector::operator -= (float d)
{
- x -= d;
- y -= d;
- z -= d;
- return *this;
+ x -= d;
+ y -= d;
+ z -= d;
+ return *this;
}
Vector& Vector::operator -= (Vector& v)
{
- x -= v.x;
- y -= v.y;
- z -= v.z;
- return *this;
+ x -= v.x;
+ y -= v.y;
+ z -= v.z;
+ return *this;
}
Vector& Vector::operator *= (float d)
{
- x *= d;
- y *= d;
- z *= d;
- return *this;
+ x *= d;
+ y *= d;
+ z *= d;
+ return *this;
}
Vector& Vector::operator *= (Vector& v)
{
- x *= v.x;
- y *= v.y;
- z *= v.z;
- return *this;
+ x *= v.x;
+ y *= v.y;
+ z *= v.z;
+ return *this;
}
Vector& Vector::operator /= (float d)
{
- x /= d;
- y /= d;
- z /= d;
- return *this;
+ x /= d;
+ y /= d;
+ z /= d;
+ return *this;
}
Vector& Vector::operator /= (Vector& v)
{
- x /= v.x;
- y /= v.y;
- z /= v.z;
- return *this;
+ x /= v.x;
+ y /= v.y;
+ z /= v.z;
+ return *this;
}
//
@@ -352,34 +352,34 @@ Vector& Vector::operator /= (Vector& v)
Ray::Ray(Vector& p, Vector& d)
{
- this->p = p;
- this->d = d;
+ this->p = p;
+ this->d = d;
}
void Ray::Set(Vector& p, Vector& d)
{
- this->p = p;
- this->d = d;
+ this->p = p;
+ this->d = d;
}
float Ray::GetDistanceFrom(Ray& r)
{
- float t = (d | r.d);
- if (IsZero(t)) {
- return -BIGNUMBER; // plane is paralell to the ray, return -infinite
- }
- return (((r.p - p) | r.d) / t);
+ float t = (d | r.d);
+ if (IsZero(t)) {
+ return -BIGNUMBER; // plane is paralell to the ray, return -infinite
+ }
+ return (((r.p - p) | r.d) / t);
}
float Ray::GetDistanceFrom(Vector& v)
{
- float t = ((v - p) | d) / (d | d);
- return ((p + d*t) - v).Length();
+ float t = ((v - p) | d) / (d | d);
+ return ((p + d * t) - v).Length();
}
-Vector Ray::operator [] (float t)
+Vector Ray::operator [](float t)
{
- return (p + d*t);
+ return (p + d * t);
}
//
@@ -388,131 +388,131 @@ Vector Ray::operator [] (float t)
XForm::XForm(Ray& r, Vector& s, bool isWorldToLocal)
{
- Initalize(r, s, isWorldToLocal);
+ Initalize(r, s, isWorldToLocal);
}
void XForm::Initalize()
{
- m.Initalize();
+ m.Initalize();
}
void XForm::Initalize(Ray& r, Vector& s, bool isWorldToLocal)
{
- Initalize();
+ Initalize();
- m_isWorldToLocal = isWorldToLocal;
- if (isWorldToLocal) {
- *this -= r.p;
- *this >>= r.d;
- *this /= s;
+ m_isWorldToLocal = isWorldToLocal;
+ if (isWorldToLocal) {
+ *this -= r.p;
+ *this >>= r.d;
+ *this /= s;
- } else {
- *this *= s;
- *this <<= r.d;
- *this += r.p;
- }
+ } else {
+ *this *= s;
+ *this <<= r.d;
+ *this += r.p;
+ }
}
void XForm::operator *= (Vector& v)
{
- Matrix s;
- s.mat[0][0] = v.x;
- s.mat[1][1] = v.y;
- s.mat[2][2] = v.z;
- m *= s;
+ Matrix s;
+ s.mat[0][0] = v.x;
+ s.mat[1][1] = v.y;
+ s.mat[2][2] = v.z;
+ m *= s;
}
void XForm::operator += (Vector& v)
{
- Matrix t;
- t.mat[3][0] = v.x;
- t.mat[3][1] = v.y;
- t.mat[3][2] = v.z;
- m *= t;
+ Matrix t;
+ t.mat[3][0] = v.x;
+ t.mat[3][1] = v.y;
+ t.mat[3][2] = v.z;
+ m *= t;
}
void XForm::operator <<= (Vector& v)
{
- Matrix x;
- x.mat[1][1] = cos(v.x);
- x.mat[1][2] = -sin(v.x);
- x.mat[2][1] = sin(v.x);
- x.mat[2][2] = cos(v.x);
+ Matrix x;
+ x.mat[1][1] = cos(v.x);
+ x.mat[1][2] = -sin(v.x);
+ x.mat[2][1] = sin(v.x);
+ x.mat[2][2] = cos(v.x);
- Matrix y;
- y.mat[0][0] = cos(v.y);
- y.mat[0][2] = -sin(v.y);
- y.mat[2][0] = sin(v.y);
- y.mat[2][2] = cos(v.y);
+ Matrix y;
+ y.mat[0][0] = cos(v.y);
+ y.mat[0][2] = -sin(v.y);
+ y.mat[2][0] = sin(v.y);
+ y.mat[2][2] = cos(v.y);
- Matrix z;
- z.mat[0][0] = cos(v.z);
- z.mat[0][1] = -sin(v.z);
- z.mat[1][0] = sin(v.z);
- z.mat[1][1] = cos(v.z);
+ Matrix z;
+ z.mat[0][0] = cos(v.z);
+ z.mat[0][1] = -sin(v.z);
+ z.mat[1][0] = sin(v.z);
+ z.mat[1][1] = cos(v.z);
- m = m_isWorldToLocal ? (m * y * x * z) : (m * z * x * y);
+ m = m_isWorldToLocal ? (m * y * x * z) : (m * z * x * y);
}
void XForm::operator /= (Vector& v)
{
- Vector s;
- s.x = IsZero(v.x) ? 0 : 1 / v.x;
- s.y = IsZero(v.y) ? 0 : 1 / v.y;
- s.z = IsZero(v.z) ? 0 : 1 / v.z;
- *this *= s;
+ Vector s;
+ s.x = IsZero(v.x) ? 0 : 1 / v.x;
+ s.y = IsZero(v.y) ? 0 : 1 / v.y;
+ s.z = IsZero(v.z) ? 0 : 1 / v.z;
+ *this *= s;
}
void XForm::operator -= (Vector& v)
{
- *this += -v;
+ *this += -v;
}
void XForm::operator >>= (Vector& v)
{
- *this <<= -v;
+ *this <<= -v;
}
Vector XForm::operator < (Vector& n)
{
- Vector ret;
+ Vector ret;
- ret.x = n.x * m.mat[0][0] +
- n.y * m.mat[1][0] +
- n.z * m.mat[2][0];
- ret.y = n.x * m.mat[0][1] +
- n.y * m.mat[1][1] +
- n.z * m.mat[2][1];
- ret.z = n.x * m.mat[0][2] +
- n.y * m.mat[1][2] +
- n.z * m.mat[2][2];
+ ret.x = n.x * m.mat[0][0] +
+ n.y * m.mat[1][0] +
+ n.z * m.mat[2][0];
+ ret.y = n.x * m.mat[0][1] +
+ n.y * m.mat[1][1] +
+ n.z * m.mat[2][1];
+ ret.z = n.x * m.mat[0][2] +
+ n.y * m.mat[1][2] +
+ n.z * m.mat[2][2];
- return ret;
+ return ret;
}
Vector XForm::operator << (Vector& v)
{
- Vector ret;
+ Vector ret;
- ret.x = v.x * m.mat[0][0] +
- v.y * m.mat[1][0] +
- v.z * m.mat[2][0] +
- m.mat[3][0];
- ret.y = v.x * m.mat[0][1] +
- v.y * m.mat[1][1] +
- v.z * m.mat[2][1] +
- m.mat[3][1];
- ret.z = v.x * m.mat[0][2] +
- v.y * m.mat[1][2] +
- v.z * m.mat[2][2] +
- m.mat[3][2];
+ ret.x = v.x * m.mat[0][0] +
+ v.y * m.mat[1][0] +
+ v.z * m.mat[2][0] +
+ m.mat[3][0];
+ ret.y = v.x * m.mat[0][1] +
+ v.y * m.mat[1][1] +
+ v.z * m.mat[2][1] +
+ m.mat[3][1];
+ ret.z = v.x * m.mat[0][2] +
+ v.y * m.mat[1][2] +
+ v.z * m.mat[2][2] +
+ m.mat[3][2];
- return ret;
+ return ret;
}
Ray XForm::operator << (Ray& r)
{
- return Ray(*this << r.p, *this < r.d);
+ return Ray(*this << r.p, *this < r.d);
}
//
@@ -521,50 +521,50 @@ Ray XForm::operator << (Ray& r)
XForm::Matrix::Matrix()
{
- Initalize();
+ Initalize();
}
void XForm::Matrix::Initalize()
{
- mat[0][0] = 1;
- mat[0][1] = 0;
- mat[0][2] = 0;
- mat[0][3] = 0;
- mat[1][0] = 0;
- mat[1][1] = 1;
- mat[1][2] = 0;
- mat[1][3] = 0;
- mat[2][0] = 0;
- mat[2][1] = 0;
- mat[2][2] = 1;
- mat[2][3] = 0;
- mat[3][0] = 0;
- mat[3][1] = 0;
- mat[3][2] = 0;
- mat[3][3] = 1;
+ mat[0][0] = 1;
+ mat[0][1] = 0;
+ mat[0][2] = 0;
+ mat[0][3] = 0;
+ mat[1][0] = 0;
+ mat[1][1] = 1;
+ mat[1][2] = 0;
+ mat[1][3] = 0;
+ mat[2][0] = 0;
+ mat[2][1] = 0;
+ mat[2][2] = 1;
+ mat[2][3] = 0;
+ mat[3][0] = 0;
+ mat[3][1] = 0;
+ mat[3][2] = 0;
+ mat[3][3] = 1;
}
XForm::Matrix XForm::Matrix::operator * (Matrix& m)
{
- Matrix ret;
+ Matrix ret;
- for (ptrdiff_t i = 0; i < 4; i++) {
- for (ptrdiff_t j = 0; j < 4; j++) {
- ret.mat[i][j] = mat[i][0] * m.mat[0][j] +
- mat[i][1] * m.mat[1][j] +
- mat[i][2] * m.mat[2][j] +
- mat[i][3] * m.mat[3][j];
+ for (ptrdiff_t i = 0; i < 4; i++) {
+ for (ptrdiff_t j = 0; j < 4; j++) {
+ ret.mat[i][j] = mat[i][0] * m.mat[0][j] +
+ mat[i][1] * m.mat[1][j] +
+ mat[i][2] * m.mat[2][j] +
+ mat[i][3] * m.mat[3][j];
- if (IsZero(ret.mat[i][j])) {
- ret.mat[i][j] = 0;
- }
- }
- }
+ if (IsZero(ret.mat[i][j])) {
+ ret.mat[i][j] = 0;
+ }
+ }
+ }
- return ret;
+ return ret;
}
XForm::Matrix& XForm::Matrix::operator *= (XForm::Matrix& m)
{
- return (*this = *this * m);
+ return (*this = *this * m);
}
diff --git a/src/SubPic/CoordGeom.h b/src/SubPic/CoordGeom.h
index 64bdf9996..5d6df7bf2 100644
--- a/src/SubPic/CoordGeom.h
+++ b/src/SubPic/CoordGeom.h
@@ -38,111 +38,111 @@
class Vector
{
public:
- float x, y, z;
-
- Vector() { x = y = z = 0; }
- Vector(float x, float y, float z);
- void Set(float x, float y, float z);
-
- Vector Normal(Vector& a, Vector& b);
- float Angle(Vector& a, Vector& b);
- float Angle(Vector& a);
- void Angle(float& u, float& v); // returns spherical coords in radian, -M_PI_2 <= u <= M_PI_2, -M_PI <= v <= M_PI
- Vector Angle(); // does like prev., returns 'u' in 'ret.x', and 'v' in 'ret.y'
-
- Vector Unit();
- Vector& Unitalize();
- float Length();
- float Sum(); // x + y + z
- float CrossSum(); // xy + xz + yz
- Vector Cross(); // xy, xz, yz
- Vector Pow(float exp);
-
- Vector& Min(Vector& a);
- Vector& Max(Vector& a);
- Vector Abs();
-
- Vector Reflect(Vector& n);
- Vector Refract(Vector& n, float nFront, float nBack, float* nOut = NULL);
- Vector Refract2(Vector& n, float nFrom, float nTo, float* nOut = NULL);
-
- Vector operator - ();
- float& operator [] (size_t i);
-
- float operator | (Vector& v); // dot
- Vector operator % (Vector& v); // cross
-
- bool operator == (const Vector& v) const;
- bool operator != (const Vector& v) const;
-
- Vector operator + (float d);
- Vector operator + (Vector& v);
- Vector operator - (float d);
- Vector operator - (Vector& v);
- Vector operator * (float d);
- Vector operator * (Vector& v);
- Vector operator / (float d);
- Vector operator / (Vector& v);
- Vector& operator += (float d);
- Vector& operator += (Vector& v);
- Vector& operator -= (float d);
- Vector& operator -= (Vector& v);
- Vector& operator *= (float d);
- Vector& operator *= (Vector& v);
- Vector& operator /= (float d);
- Vector& operator /= (Vector& v);
-
- template<typename T> static float DegToRad(T angle) { return (float)(angle * M_PI / 180); }
+ float x, y, z;
+
+ Vector() { x = y = z = 0; }
+ Vector(float x, float y, float z);
+ void Set(float x, float y, float z);
+
+ Vector Normal(Vector& a, Vector& b);
+ float Angle(Vector& a, Vector& b);
+ float Angle(Vector& a);
+ void Angle(float& u, float& v); // returns spherical coords in radian, -M_PI_2 <= u <= M_PI_2, -M_PI <= v <= M_PI
+ Vector Angle(); // does like prev., returns 'u' in 'ret.x', and 'v' in 'ret.y'
+
+ Vector Unit();
+ Vector& Unitalize();
+ float Length();
+ float Sum(); // x + y + z
+ float CrossSum(); // xy + xz + yz
+ Vector Cross(); // xy, xz, yz
+ Vector Pow(float exp);
+
+ Vector& Min(Vector& a);
+ Vector& Max(Vector& a);
+ Vector Abs();
+
+ Vector Reflect(Vector& n);
+ Vector Refract(Vector& n, float nFront, float nBack, float* nOut = NULL);
+ Vector Refract2(Vector& n, float nFrom, float nTo, float* nOut = NULL);
+
+ Vector operator - ();
+ float& operator [](size_t i);
+
+ float operator | (Vector& v); // dot
+ Vector operator % (Vector& v); // cross
+
+ bool operator == (const Vector& v) const;
+ bool operator != (const Vector& v) const;
+
+ Vector operator + (float d);
+ Vector operator + (Vector& v);
+ Vector operator - (float d);
+ Vector operator - (Vector& v);
+ Vector operator * (float d);
+ Vector operator * (Vector& v);
+ Vector operator / (float d);
+ Vector operator / (Vector& v);
+ Vector& operator += (float d);
+ Vector& operator += (Vector& v);
+ Vector& operator -= (float d);
+ Vector& operator -= (Vector& v);
+ Vector& operator *= (float d);
+ Vector& operator *= (Vector& v);
+ Vector& operator /= (float d);
+ Vector& operator /= (Vector& v);
+
+ template<typename T> static float DegToRad(T angle) { return (float)(angle * M_PI / 180); }
};
class Ray
{
public:
- Vector p, d;
+ Vector p, d;
- Ray() {}
- Ray(Vector& p, Vector& d);
- void Set(Vector& p, Vector& d);
+ Ray() {}
+ Ray(Vector& p, Vector& d);
+ void Set(Vector& p, Vector& d);
- float GetDistanceFrom(Ray& r); // r = plane
- float GetDistanceFrom(Vector& v); // v = point
+ float GetDistanceFrom(Ray& r); // r = plane
+ float GetDistanceFrom(Vector& v); // v = point
- Vector operator [] (float t);
+ Vector operator [](float t);
};
class XForm
{
- class Matrix
- {
- public:
- float mat[4][4];
+ class Matrix
+ {
+ public:
+ float mat[4][4];
- Matrix();
- void Initalize();
+ Matrix();
+ void Initalize();
- Matrix operator * (Matrix& m);
- Matrix& operator *= (Matrix& m);
- } m;
+ Matrix operator * (Matrix& m);
+ Matrix& operator *= (Matrix& m);
+ } m;
- bool m_isWorldToLocal;
+ bool m_isWorldToLocal;
public:
- XForm() : m_isWorldToLocal(true) {}
- XForm(Ray& r, Vector& s, bool isWorldToLocal = true);
+ XForm() : m_isWorldToLocal(true) {}
+ XForm(Ray& r, Vector& s, bool isWorldToLocal = true);
- void Initalize();
- void Initalize(Ray& r, Vector& s, bool isWorldToLocal = true);
+ void Initalize();
+ void Initalize(Ray& r, Vector& s, bool isWorldToLocal = true);
- void operator *= (Vector& s); // scale
- void operator += (Vector& t); // translate
- void operator <<= (Vector& r); // rotate
+ void operator *= (Vector& s); // scale
+ void operator += (Vector& t); // translate
+ void operator <<= (Vector& r); // rotate
- void operator /= (Vector& s); // scale
- void operator -= (Vector& t); // translate
- void operator >>= (Vector& r); // rotate
+ void operator /= (Vector& s); // scale
+ void operator -= (Vector& t); // translate
+ void operator >>= (Vector& r); // rotate
- // transformations
- Vector operator < (Vector& n); // normal
- Vector operator << (Vector& v); // vector
- Ray operator << (Ray& r); // ray
+ // transformations
+ Vector operator < (Vector& n); // normal
+ Vector operator << (Vector& v); // vector
+ Ray operator << (Ray& r); // ray
};
diff --git a/src/SubPic/DX7SubPic.cpp b/src/SubPic/DX7SubPic.cpp
index 62772cc63..bb8bb1200 100644
--- a/src/SubPic/DX7SubPic.cpp
+++ b/src/SubPic/DX7SubPic.cpp
@@ -30,193 +30,193 @@
//
CDX7SubPic::CDX7SubPic(IDirect3DDevice7* pD3DDev, IDirectDrawSurface7* pSurface)
- : m_pSurface(pSurface)
- , m_pD3DDev(pD3DDev)
+ : m_pSurface(pSurface)
+ , m_pD3DDev(pD3DDev)
{
- DDSURFACEDESC2 ddsd;
- INITDDSTRUCT(ddsd);
- if (SUCCEEDED(m_pSurface->GetSurfaceDesc(&ddsd))) {
- m_maxsize.SetSize(ddsd.dwWidth, ddsd.dwHeight);
- m_rcDirty.SetRect(0, 0, ddsd.dwWidth, ddsd.dwHeight);
- }
+ DDSURFACEDESC2 ddsd;
+ INITDDSTRUCT(ddsd);
+ if (SUCCEEDED(m_pSurface->GetSurfaceDesc(&ddsd))) {
+ m_maxsize.SetSize(ddsd.dwWidth, ddsd.dwHeight);
+ m_rcDirty.SetRect(0, 0, ddsd.dwWidth, ddsd.dwHeight);
+ }
}
// ISubPic
STDMETHODIMP_(void*) CDX7SubPic::GetObject()
{
- return (void*)(IDirectDrawSurface7*)m_pSurface;
+ return (void*)(IDirectDrawSurface7*)m_pSurface;
}
STDMETHODIMP CDX7SubPic::GetDesc(SubPicDesc& spd)
{
- DDSURFACEDESC2 ddsd;
- INITDDSTRUCT(ddsd);
- if (FAILED(m_pSurface->GetSurfaceDesc(&ddsd))) {
- return E_FAIL;
- }
-
- spd.type = 0;
- spd.w = m_size.cx;
- spd.h = m_size.cy;
- spd.bpp = (WORD)ddsd.ddpfPixelFormat.dwRGBBitCount;
- spd.pitch = ddsd.lPitch;
- spd.bits = ddsd.lpSurface; // should be NULL
- spd.vidrect = m_vidrect;
-
- return S_OK;
+ DDSURFACEDESC2 ddsd;
+ INITDDSTRUCT(ddsd);
+ if (FAILED(m_pSurface->GetSurfaceDesc(&ddsd))) {
+ return E_FAIL;
+ }
+
+ spd.type = 0;
+ spd.w = m_size.cx;
+ spd.h = m_size.cy;
+ spd.bpp = (WORD)ddsd.ddpfPixelFormat.dwRGBBitCount;
+ spd.pitch = ddsd.lPitch;
+ spd.bits = ddsd.lpSurface; // should be NULL
+ spd.vidrect = m_vidrect;
+
+ return S_OK;
}
STDMETHODIMP CDX7SubPic::CopyTo(ISubPic* pSubPic)
{
- HRESULT hr;
- if (FAILED(hr = __super::CopyTo(pSubPic))) {
- return hr;
- }
+ HRESULT hr;
+ if (FAILED(hr = __super::CopyTo(pSubPic))) {
+ return hr;
+ }
- CPoint p = m_rcDirty.TopLeft();
- hr = m_pD3DDev->Load((IDirectDrawSurface7*)pSubPic->GetObject(), &p, (IDirectDrawSurface7*)GetObject(), m_rcDirty, 0);
+ CPoint p = m_rcDirty.TopLeft();
+ hr = m_pD3DDev->Load((IDirectDrawSurface7*)pSubPic->GetObject(), &p, (IDirectDrawSurface7*)GetObject(), m_rcDirty, 0);
- return SUCCEEDED(hr) ? S_OK : E_FAIL;
+ return SUCCEEDED(hr) ? S_OK : E_FAIL;
}
STDMETHODIMP CDX7SubPic::ClearDirtyRect(DWORD color)
{
- if (m_rcDirty.IsRectEmpty()) {
- return S_FALSE;
- }
+ if (m_rcDirty.IsRectEmpty()) {
+ return S_FALSE;
+ }
- DDBLTFX fx;
- INITDDSTRUCT(fx);
- fx.dwFillColor = color;
- m_pSurface->Blt(&m_rcDirty, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
+ DDBLTFX fx;
+ INITDDSTRUCT(fx);
+ fx.dwFillColor = color;
+ m_pSurface->Blt(&m_rcDirty, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx);
- m_rcDirty.SetRectEmpty();
+ m_rcDirty.SetRectEmpty();
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDX7SubPic::Lock(SubPicDesc& spd)
{
- DDSURFACEDESC2 ddsd;
- INITDDSTRUCT(ddsd);
- if (FAILED(m_pSurface->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR|DDLOCK_WAIT, NULL))) {
- return E_FAIL;
- }
-
- spd.type = 0;
- spd.w = m_size.cx;
- spd.h = m_size.cy;
- spd.bpp = (WORD)ddsd.ddpfPixelFormat.dwRGBBitCount;
- spd.pitch = ddsd.lPitch;
- spd.bits = ddsd.lpSurface;
- spd.vidrect = m_vidrect;
-
- return S_OK;
+ DDSURFACEDESC2 ddsd;
+ INITDDSTRUCT(ddsd);
+ if (FAILED(m_pSurface->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL))) {
+ return E_FAIL;
+ }
+
+ spd.type = 0;
+ spd.w = m_size.cx;
+ spd.h = m_size.cy;
+ spd.bpp = (WORD)ddsd.ddpfPixelFormat.dwRGBBitCount;
+ spd.pitch = ddsd.lPitch;
+ spd.bits = ddsd.lpSurface;
+ spd.vidrect = m_vidrect;
+
+ return S_OK;
}
STDMETHODIMP CDX7SubPic::Unlock(RECT* pDirtyRect)
{
- m_pSurface->Unlock(NULL);
+ m_pSurface->Unlock(NULL);
- if (pDirtyRect) {
- m_rcDirty = *pDirtyRect;
- m_rcDirty.InflateRect(1, 1);
- m_rcDirty &= CRect(CPoint(0, 0), m_size);
- } else {
- m_rcDirty = CRect(CPoint(0, 0), m_size);
- }
+ if (pDirtyRect) {
+ m_rcDirty = *pDirtyRect;
+ m_rcDirty.InflateRect(1, 1);
+ m_rcDirty &= CRect(CPoint(0, 0), m_size);
+ } else {
+ m_rcDirty = CRect(CPoint(0, 0), m_size);
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDX7SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
{
- ASSERT(pTarget == NULL);
-
- if (!m_pD3DDev || !m_pSurface || !pSrc || !pDst) {
- return E_POINTER;
- }
-
- CRect src(*pSrc), dst(*pDst);
-
- HRESULT hr;
-
- do {
- DDSURFACEDESC2 ddsd;
- INITDDSTRUCT(ddsd);
- if (FAILED(hr = m_pSurface->GetSurfaceDesc(&ddsd))) {
- break;
- }
-
- float w = (float)ddsd.dwWidth;
- float h = (float)ddsd.dwHeight;
-
- struct {
- float x, y, z, rhw;
- float tu, tv;
- }
- pVertices[] = {
- {(float)dst.left, (float)dst.top, 0.5f, 2.0f, (float)src.left / w, (float)src.top / h},
- {(float)dst.right, (float)dst.top, 0.5f, 2.0f, (float)src.right / w, (float)src.top / h},
- {(float)dst.left, (float)dst.bottom, 0.5f, 2.0f, (float)src.left / w, (float)src.bottom / h},
- {(float)dst.right, (float)dst.bottom, 0.5f, 2.0f, (float)src.right / w, (float)src.bottom / h},
- };
- /*
- for (ptrdiff_t i = 0; i < _countof(pVertices); i++)
- {
- pVertices[i].x -= 0.5;
- pVertices[i].y -= 0.5;
- }
- */
- hr = m_pD3DDev->SetTexture(0, m_pSurface);
-
- m_pD3DDev->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
- m_pD3DDev->SetRenderState(D3DRENDERSTATE_LIGHTING, FALSE);
- m_pD3DDev->SetRenderState(D3DRENDERSTATE_BLENDENABLE, TRUE);
- m_pD3DDev->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); // pre-multiplied src and ...
- m_pD3DDev->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA); // ... inverse alpha channel for dst
-
- m_pD3DDev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
- m_pD3DDev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
- m_pD3DDev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
-
- m_pD3DDev->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTFG_LINEAR);
- m_pD3DDev->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTFN_LINEAR);
- m_pD3DDev->SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTFP_LINEAR);
-
- m_pD3DDev->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP);
-
- /*//
-
- D3DDEVICEDESC7 d3ddevdesc;
- m_pD3DDev->GetCaps(&d3ddevdesc);
- if (d3ddevdesc.dpcTriCaps.dwAlphaCmpCaps & D3DPCMPCAPS_LESS)
- {
- m_pD3DDev->SetRenderState(D3DRENDERSTATE_ALPHAREF, (DWORD)0x000000FE);
- m_pD3DDev->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, TRUE);
- m_pD3DDev->SetRenderState(D3DRENDERSTATE_ALPHAFUNC, D3DPCMPCAPS_LESS);
- }
-
- *///
-
- if (FAILED(hr = m_pD3DDev->BeginScene())) {
- break;
- }
-
- hr = m_pD3DDev->DrawPrimitive(D3DPT_TRIANGLESTRIP,
- D3DFVF_XYZRHW | D3DFVF_TEX1,
- pVertices, 4, D3DDP_WAIT);
- m_pD3DDev->EndScene();
-
- //
-
- m_pD3DDev->SetTexture(0, NULL);
-
- return S_OK;
- } while (0);
-
- return E_FAIL;
+ ASSERT(pTarget == NULL);
+
+ if (!m_pD3DDev || !m_pSurface || !pSrc || !pDst) {
+ return E_POINTER;
+ }
+
+ CRect src(*pSrc), dst(*pDst);
+
+ HRESULT hr;
+
+ do {
+ DDSURFACEDESC2 ddsd;
+ INITDDSTRUCT(ddsd);
+ if (FAILED(hr = m_pSurface->GetSurfaceDesc(&ddsd))) {
+ break;
+ }
+
+ float w = (float)ddsd.dwWidth;
+ float h = (float)ddsd.dwHeight;
+
+ struct {
+ float x, y, z, rhw;
+ float tu, tv;
+ }
+ pVertices[] = {
+ {(float)dst.left, (float)dst.top, 0.5f, 2.0f, (float)src.left / w, (float)src.top / h},
+ {(float)dst.right, (float)dst.top, 0.5f, 2.0f, (float)src.right / w, (float)src.top / h},
+ {(float)dst.left, (float)dst.bottom, 0.5f, 2.0f, (float)src.left / w, (float)src.bottom / h},
+ {(float)dst.right, (float)dst.bottom, 0.5f, 2.0f, (float)src.right / w, (float)src.bottom / h},
+ };
+ /*
+ for (ptrdiff_t i = 0; i < _countof(pVertices); i++)
+ {
+ pVertices[i].x -= 0.5;
+ pVertices[i].y -= 0.5;
+ }
+ */
+ hr = m_pD3DDev->SetTexture(0, m_pSurface);
+
+ m_pD3DDev->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
+ m_pD3DDev->SetRenderState(D3DRENDERSTATE_LIGHTING, FALSE);
+ m_pD3DDev->SetRenderState(D3DRENDERSTATE_BLENDENABLE, TRUE);
+ m_pD3DDev->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); // pre-multiplied src and ...
+ m_pD3DDev->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA); // ... inverse alpha channel for dst
+
+ m_pD3DDev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
+ m_pD3DDev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+ m_pD3DDev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
+
+ m_pD3DDev->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTFG_LINEAR);
+ m_pD3DDev->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTFN_LINEAR);
+ m_pD3DDev->SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTFP_LINEAR);
+
+ m_pD3DDev->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP);
+
+ /*//
+
+ D3DDEVICEDESC7 d3ddevdesc;
+ m_pD3DDev->GetCaps(&d3ddevdesc);
+ if (d3ddevdesc.dpcTriCaps.dwAlphaCmpCaps & D3DPCMPCAPS_LESS)
+ {
+ m_pD3DDev->SetRenderState(D3DRENDERSTATE_ALPHAREF, (DWORD)0x000000FE);
+ m_pD3DDev->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, TRUE);
+ m_pD3DDev->SetRenderState(D3DRENDERSTATE_ALPHAFUNC, D3DPCMPCAPS_LESS);
+ }
+
+ *///
+
+ if (FAILED(hr = m_pD3DDev->BeginScene())) {
+ break;
+ }
+
+ hr = m_pD3DDev->DrawPrimitive(D3DPT_TRIANGLESTRIP,
+ D3DFVF_XYZRHW | D3DFVF_TEX1,
+ pVertices, 4, D3DDP_WAIT);
+ m_pD3DDev->EndScene();
+
+ //
+
+ m_pD3DDev->SetTexture(0, NULL);
+
+ return S_OK;
+ } while (0);
+
+ return E_FAIL;
}
//
@@ -224,9 +224,9 @@ STDMETHODIMP CDX7SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
//
CDX7SubPicAllocator::CDX7SubPicAllocator(IDirect3DDevice7* pD3DDev, SIZE maxsize, bool fPow2Textures)
- : CSubPicAllocatorImpl(maxsize, true, fPow2Textures)
- , m_pD3DDev(pD3DDev)
- , m_maxsize(maxsize)
+ : CSubPicAllocatorImpl(maxsize, true, fPow2Textures)
+ , m_pD3DDev(pD3DDev)
+ , m_maxsize(maxsize)
{
}
@@ -234,70 +234,70 @@ CDX7SubPicAllocator::CDX7SubPicAllocator(IDirect3DDevice7* pD3DDev, SIZE maxsize
STDMETHODIMP CDX7SubPicAllocator::ChangeDevice(IUnknown* pDev)
{
- CComQIPtr<IDirect3DDevice7, &IID_IDirect3DDevice7> pD3DDev = pDev;
- if (!pD3DDev) {
- return E_NOINTERFACE;
- }
+ CComQIPtr<IDirect3DDevice7, &IID_IDirect3DDevice7> pD3DDev = pDev;
+ if (!pD3DDev) {
+ return E_NOINTERFACE;
+ }
- CAutoLock cAutoLock(this);
- m_pD3DDev = pD3DDev;
+ CAutoLock cAutoLock(this);
+ m_pD3DDev = pD3DDev;
- return __super::ChangeDevice(pDev);
+ return __super::ChangeDevice(pDev);
}
// ISubPicAllocatorImpl
bool CDX7SubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic)
{
- if (!ppSubPic) {
- return false;
- }
-
- CAutoLock cAutoLock(this);
-
- DDSURFACEDESC2 ddsd;
- INITDDSTRUCT(ddsd);
- ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT;
- ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | (fStatic ? DDSCAPS_SYSTEMMEMORY : 0);
- ddsd.ddsCaps.dwCaps2 = fStatic ? 0 : (DDSCAPS2_TEXTUREMANAGE|DDSCAPS2_HINTSTATIC);
- ddsd.dwWidth = m_maxsize.cx;
- ddsd.dwHeight = m_maxsize.cy;
- ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
- ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB|DDPF_ALPHAPIXELS;
- ddsd.ddpfPixelFormat.dwRGBBitCount = 32;
- ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = 0xFF000000;
- ddsd.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
- ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
- ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
-
- if (m_fPow2Textures && ddsd.dwWidth < 1024 && ddsd.dwHeight < 1024) {
- ddsd.dwWidth = ddsd.dwHeight = 1;
- while (ddsd.dwWidth < (DWORD)m_maxsize.cx) {
- ddsd.dwWidth <<= 1;
- }
- while (ddsd.dwHeight < (DWORD)m_maxsize.cy) {
- ddsd.dwHeight <<= 1;
- }
- }
-
-
- CComPtr<IDirect3D7> pD3D;
- CComQIPtr<IDirectDraw7, &IID_IDirectDraw7> pDD;
- if (FAILED(m_pD3DDev->GetDirect3D(&pD3D)) || !pD3D || !(pDD = pD3D)) {
- return false;
- }
-
- CComPtr<IDirectDrawSurface7> pSurface;
- if (FAILED(pDD->CreateSurface(&ddsd, &pSurface, NULL))) {
- return false;
- }
-
- *ppSubPic = DNew CDX7SubPic(m_pD3DDev, pSurface);
- if (!(*ppSubPic)) {
- return false;
- }
-
- (*ppSubPic)->AddRef();
-
- return true;
+ if (!ppSubPic) {
+ return false;
+ }
+
+ CAutoLock cAutoLock(this);
+
+ DDSURFACEDESC2 ddsd;
+ INITDDSTRUCT(ddsd);
+ ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | (fStatic ? DDSCAPS_SYSTEMMEMORY : 0);
+ ddsd.ddsCaps.dwCaps2 = fStatic ? 0 : (DDSCAPS2_TEXTUREMANAGE | DDSCAPS2_HINTSTATIC);
+ ddsd.dwWidth = m_maxsize.cx;
+ ddsd.dwHeight = m_maxsize.cy;
+ ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
+ ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
+ ddsd.ddpfPixelFormat.dwRGBBitCount = 32;
+ ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = 0xFF000000;
+ ddsd.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
+ ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
+ ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
+
+ if (m_fPow2Textures && ddsd.dwWidth < 1024 && ddsd.dwHeight < 1024) {
+ ddsd.dwWidth = ddsd.dwHeight = 1;
+ while (ddsd.dwWidth < (DWORD)m_maxsize.cx) {
+ ddsd.dwWidth <<= 1;
+ }
+ while (ddsd.dwHeight < (DWORD)m_maxsize.cy) {
+ ddsd.dwHeight <<= 1;
+ }
+ }
+
+
+ CComPtr<IDirect3D7> pD3D;
+ CComQIPtr<IDirectDraw7, &IID_IDirectDraw7> pDD;
+ if (FAILED(m_pD3DDev->GetDirect3D(&pD3D)) || !pD3D || !(pDD = pD3D)) {
+ return false;
+ }
+
+ CComPtr<IDirectDrawSurface7> pSurface;
+ if (FAILED(pDD->CreateSurface(&ddsd, &pSurface, NULL))) {
+ return false;
+ }
+
+ *ppSubPic = DNew CDX7SubPic(m_pD3DDev, pSurface);
+ if (!(*ppSubPic)) {
+ return false;
+ }
+
+ (*ppSubPic)->AddRef();
+
+ return true;
}
diff --git a/src/SubPic/DX7SubPic.h b/src/SubPic/DX7SubPic.h
index 45177e8af..e19cc52b3 100644
--- a/src/SubPic/DX7SubPic.h
+++ b/src/SubPic/DX7SubPic.h
@@ -31,36 +31,36 @@
class CDX7SubPic : public CSubPicImpl
{
- CComPtr<IDirect3DDevice7> m_pD3DDev;
- CComPtr<IDirectDrawSurface7> m_pSurface;
+ CComPtr<IDirect3DDevice7> m_pD3DDev;
+ CComPtr<IDirectDrawSurface7> m_pSurface;
protected:
- STDMETHODIMP_(void*) GetObject(); // returns IDirectDrawSurface7*
+ STDMETHODIMP_(void*) GetObject(); // returns IDirectDrawSurface7*
public:
- CDX7SubPic(IDirect3DDevice7* pD3DDev, IDirectDrawSurface7* pSurface);
+ CDX7SubPic(IDirect3DDevice7* pD3DDev, IDirectDrawSurface7* pSurface);
- // ISubPic
- STDMETHODIMP GetDesc(SubPicDesc& spd);
- STDMETHODIMP CopyTo(ISubPic* pSubPic);
- STDMETHODIMP ClearDirtyRect(DWORD color);
- STDMETHODIMP Lock(SubPicDesc& spd);
- STDMETHODIMP Unlock(RECT* pDirtyRect);
- STDMETHODIMP AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget);
+ // ISubPic
+ STDMETHODIMP GetDesc(SubPicDesc& spd);
+ STDMETHODIMP CopyTo(ISubPic* pSubPic);
+ STDMETHODIMP ClearDirtyRect(DWORD color);
+ STDMETHODIMP Lock(SubPicDesc& spd);
+ STDMETHODIMP Unlock(RECT* pDirtyRect);
+ STDMETHODIMP AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget);
};
// CDX7SubPicAllocator
class CDX7SubPicAllocator : public CSubPicAllocatorImpl, public CCritSec
{
- CComPtr<IDirect3DDevice7> m_pD3DDev;
- CSize m_maxsize;
+ CComPtr<IDirect3DDevice7> m_pD3DDev;
+ CSize m_maxsize;
- bool Alloc(bool fStatic, ISubPic** ppSubPic);
+ bool Alloc(bool fStatic, ISubPic** ppSubPic);
public:
- CDX7SubPicAllocator(IDirect3DDevice7* pD3DDev, SIZE maxsize, bool fPow2Textures);
+ CDX7SubPicAllocator(IDirect3DDevice7* pD3DDev, SIZE maxsize, bool fPow2Textures);
- // ISubPicAllocator
- STDMETHODIMP ChangeDevice(IUnknown* pDev);
+ // ISubPicAllocator
+ STDMETHODIMP ChangeDevice(IUnknown* pDev);
};
diff --git a/src/SubPic/DX9SubPic.cpp b/src/SubPic/DX9SubPic.cpp
index b6de4bdff..92c74ec91 100644
--- a/src/SubPic/DX9SubPic.cpp
+++ b/src/SubPic/DX9SubPic.cpp
@@ -29,34 +29,34 @@
// CDX9SubPic
//
-CDX9SubPic::CDX9SubPic(IDirect3DSurface9* pSurface, CDX9SubPicAllocator *pAllocator, bool bExternalRenderer)
- : m_pSurface(pSurface), m_pAllocator(pAllocator), m_bExternalRenderer(bExternalRenderer)
+CDX9SubPic::CDX9SubPic(IDirect3DSurface9* pSurface, CDX9SubPicAllocator* pAllocator, bool bExternalRenderer)
+ : m_pSurface(pSurface), m_pAllocator(pAllocator), m_bExternalRenderer(bExternalRenderer)
{
- D3DSURFACE_DESC d3dsd;
- ZeroMemory(&d3dsd, sizeof(d3dsd));
- if (SUCCEEDED(m_pSurface->GetDesc(&d3dsd))) {
- m_maxsize.SetSize(d3dsd.Width, d3dsd.Height);
- m_rcDirty.SetRect(0, 0, d3dsd.Width, d3dsd.Height);
- }
+ D3DSURFACE_DESC d3dsd;
+ ZeroMemory(&d3dsd, sizeof(d3dsd));
+ if (SUCCEEDED(m_pSurface->GetDesc(&d3dsd))) {
+ m_maxsize.SetSize(d3dsd.Width, d3dsd.Height);
+ m_rcDirty.SetRect(0, 0, d3dsd.Width, d3dsd.Height);
+ }
}
CDX9SubPic::~CDX9SubPic()
{
- {
- CAutoLock Lock(&CDX9SubPicAllocator::ms_SurfaceQueueLock);
- // Add surface to cache
- if (m_pAllocator) {
- for (POSITION pos = m_pAllocator->m_AllocatedSurfaces.GetHeadPosition(); pos; ) {
- POSITION ThisPos = pos;
- CDX9SubPic *pSubPic = m_pAllocator->m_AllocatedSurfaces.GetNext(pos);
- if (pSubPic == this) {
- m_pAllocator->m_AllocatedSurfaces.RemoveAt(ThisPos);
- break;
- }
- }
- m_pAllocator->m_FreeSurfaces.AddTail(m_pSurface);
- }
- }
+ {
+ CAutoLock Lock(&CDX9SubPicAllocator::ms_SurfaceQueueLock);
+ // Add surface to cache
+ if (m_pAllocator) {
+ for (POSITION pos = m_pAllocator->m_AllocatedSurfaces.GetHeadPosition(); pos;) {
+ POSITION ThisPos = pos;
+ CDX9SubPic* pSubPic = m_pAllocator->m_AllocatedSurfaces.GetNext(pos);
+ if (pSubPic == this) {
+ m_pAllocator->m_AllocatedSurfaces.RemoveAt(ThisPos);
+ break;
+ }
+ }
+ m_pAllocator->m_FreeSurfaces.AddTail(m_pSurface);
+ }
+ }
}
@@ -64,285 +64,289 @@ CDX9SubPic::~CDX9SubPic()
STDMETHODIMP_(void*) CDX9SubPic::GetObject()
{
- CComPtr<IDirect3DTexture9> pTexture;
- if (SUCCEEDED(m_pSurface->GetContainer(IID_IDirect3DTexture9, (void**)&pTexture))) {
- return (void*)(IDirect3DTexture9*)pTexture;
- }
+ CComPtr<IDirect3DTexture9> pTexture;
+ if (SUCCEEDED(m_pSurface->GetContainer(IID_IDirect3DTexture9, (void**)&pTexture))) {
+ return (void*)(IDirect3DTexture9*)pTexture;
+ }
- return NULL;
+ return NULL;
}
STDMETHODIMP CDX9SubPic::GetDesc(SubPicDesc& spd)
{
- D3DSURFACE_DESC d3dsd;
- ZeroMemory(&d3dsd, sizeof(d3dsd));
- if (FAILED(m_pSurface->GetDesc(&d3dsd))) {
- return E_FAIL;
- }
-
- spd.type = 0;
- spd.w = m_size.cx;
- spd.h = m_size.cy;
- spd.bpp =
- d3dsd.Format == D3DFMT_A8R8G8B8 ? 32 :
- d3dsd.Format == D3DFMT_A4R4G4B4 ? 16 : 0;
- spd.pitch = 0;
- spd.bits = NULL;
- spd.vidrect = m_vidrect;
-
- return S_OK;
+ D3DSURFACE_DESC d3dsd;
+ ZeroMemory(&d3dsd, sizeof(d3dsd));
+ if (FAILED(m_pSurface->GetDesc(&d3dsd))) {
+ return E_FAIL;
+ }
+
+ spd.type = 0;
+ spd.w = m_size.cx;
+ spd.h = m_size.cy;
+ spd.bpp =
+ d3dsd.Format == D3DFMT_A8R8G8B8 ? 32 :
+ d3dsd.Format == D3DFMT_A4R4G4B4 ? 16 : 0;
+ spd.pitch = 0;
+ spd.bits = NULL;
+ spd.vidrect = m_vidrect;
+
+ return S_OK;
}
STDMETHODIMP CDX9SubPic::CopyTo(ISubPic* pSubPic)
{
- HRESULT hr;
- if (FAILED(hr = __super::CopyTo(pSubPic))) {
- return hr;
- }
-
- if (m_rcDirty.IsRectEmpty()) {
- return S_FALSE;
- }
-
- CComPtr<IDirect3DDevice9> pD3DDev;
- if (!m_pSurface || FAILED(m_pSurface->GetDevice(&pD3DDev)) || !pD3DDev) {
- return E_FAIL;
- }
-
- IDirect3DTexture9* pSrcTex = (IDirect3DTexture9*)GetObject();
- CComPtr<IDirect3DSurface9> pSrcSurf;
- pSrcTex->GetSurfaceLevel(0, &pSrcSurf);
- D3DSURFACE_DESC srcDesc;
- pSrcSurf->GetDesc(&srcDesc);
-
- IDirect3DTexture9* pDstTex = (IDirect3DTexture9*)pSubPic->GetObject();
- CComPtr<IDirect3DSurface9> pDstSurf;
- pDstTex->GetSurfaceLevel(0, &pDstSurf);
- D3DSURFACE_DESC dstDesc;
- pDstSurf->GetDesc(&dstDesc);
-
- RECT r;
- SetRect(&r, 0, 0, min(srcDesc.Width, dstDesc.Width), min(srcDesc.Height, dstDesc.Height));
- POINT p = { 0, 0 };
- hr = pD3DDev->UpdateSurface(pSrcSurf, &r, pDstSurf, &p);
- // ASSERT (SUCCEEDED (hr));
-
- return SUCCEEDED(hr) ? S_OK : E_FAIL;
+ HRESULT hr;
+ if (FAILED(hr = __super::CopyTo(pSubPic))) {
+ return hr;
+ }
+
+ if (m_rcDirty.IsRectEmpty()) {
+ return S_FALSE;
+ }
+
+ CComPtr<IDirect3DDevice9> pD3DDev;
+ if (!m_pSurface || FAILED(m_pSurface->GetDevice(&pD3DDev)) || !pD3DDev) {
+ return E_FAIL;
+ }
+
+ IDirect3DTexture9* pSrcTex = (IDirect3DTexture9*)GetObject();
+ CComPtr<IDirect3DSurface9> pSrcSurf;
+ pSrcTex->GetSurfaceLevel(0, &pSrcSurf);
+ D3DSURFACE_DESC srcDesc;
+ pSrcSurf->GetDesc(&srcDesc);
+
+ IDirect3DTexture9* pDstTex = (IDirect3DTexture9*)pSubPic->GetObject();
+ CComPtr<IDirect3DSurface9> pDstSurf;
+ pDstTex->GetSurfaceLevel(0, &pDstSurf);
+ D3DSURFACE_DESC dstDesc;
+ pDstSurf->GetDesc(&dstDesc);
+
+ RECT r;
+ SetRect(&r, 0, 0, min(srcDesc.Width, dstDesc.Width), min(srcDesc.Height, dstDesc.Height));
+ POINT p = { 0, 0 };
+ hr = pD3DDev->UpdateSurface(pSrcSurf, &r, pDstSurf, &p);
+ // ASSERT (SUCCEEDED (hr));
+
+ return SUCCEEDED(hr) ? S_OK : E_FAIL;
}
STDMETHODIMP CDX9SubPic::ClearDirtyRect(DWORD color)
{
- if (m_rcDirty.IsRectEmpty()) {
- return S_FALSE;
- }
-
- CComPtr<IDirect3DDevice9> pD3DDev;
- if (!m_pSurface || FAILED(m_pSurface->GetDevice(&pD3DDev)) || !pD3DDev) {
- return E_FAIL;
- }
-
- SubPicDesc spd;
- if (SUCCEEDED(Lock(spd))) {
- int h = m_rcDirty.Height();
-
- BYTE* ptr = (BYTE*)spd.bits + spd.pitch*m_rcDirty.top + (m_rcDirty.left*spd.bpp>>3);
-
- if (spd.bpp == 16) {
- while (h-- > 0) {
- memsetw(ptr, (unsigned short)color, 2 * m_rcDirty.Width());
- ptr += spd.pitch;
- }
- } else if (spd.bpp == 32) {
- while (h-- > 0) {
- memsetd(ptr, color, 4 * m_rcDirty.Width());
- ptr += spd.pitch;
- }
- }
- /*
- DWORD* ptr = (DWORD*)bm.bits;
- DWORD* end = ptr + bm.h*bm.wBytes/4;
- while (ptr < end) *ptr++ = color;
- */
- Unlock(NULL);
- }
-
- // HRESULT hr = pD3DDev->ColorFill(m_pSurface, m_rcDirty, color);
-
- m_rcDirty.SetRectEmpty();
-
- return S_OK;
+ if (m_rcDirty.IsRectEmpty()) {
+ return S_FALSE;
+ }
+
+ CComPtr<IDirect3DDevice9> pD3DDev;
+ if (!m_pSurface || FAILED(m_pSurface->GetDevice(&pD3DDev)) || !pD3DDev) {
+ return E_FAIL;
+ }
+
+ SubPicDesc spd;
+ if (SUCCEEDED(Lock(spd))) {
+ int h = m_rcDirty.Height();
+
+ BYTE* ptr = (BYTE*)spd.bits + spd.pitch * m_rcDirty.top + (m_rcDirty.left * spd.bpp >> 3);
+
+ if (spd.bpp == 16) {
+ while (h-- > 0) {
+ memsetw(ptr, (unsigned short)color, 2 * m_rcDirty.Width());
+ ptr += spd.pitch;
+ }
+ } else if (spd.bpp == 32) {
+ while (h-- > 0) {
+ memsetd(ptr, color, 4 * m_rcDirty.Width());
+ ptr += spd.pitch;
+ }
+ }
+ /*
+ DWORD* ptr = (DWORD*)bm.bits;
+ DWORD* end = ptr + bm.h*bm.wBytes/4;
+ while (ptr < end) *ptr++ = color;
+ */
+ Unlock(NULL);
+ }
+
+ // HRESULT hr = pD3DDev->ColorFill(m_pSurface, m_rcDirty, color);
+
+ m_rcDirty.SetRectEmpty();
+
+ return S_OK;
}
STDMETHODIMP CDX9SubPic::Lock(SubPicDesc& spd)
{
- D3DSURFACE_DESC d3dsd;
- ZeroMemory(&d3dsd, sizeof(d3dsd));
- if (FAILED(m_pSurface->GetDesc(&d3dsd))) {
- return E_FAIL;
- }
-
- D3DLOCKED_RECT LockedRect;
- ZeroMemory(&LockedRect, sizeof(LockedRect));
- if (FAILED(m_pSurface->LockRect(&LockedRect, NULL, D3DLOCK_NO_DIRTY_UPDATE|D3DLOCK_NOSYSLOCK))) {
- return E_FAIL;
- }
-
- spd.type = 0;
- spd.w = m_size.cx;
- spd.h = m_size.cy;
- spd.bpp =
- d3dsd.Format == D3DFMT_A8R8G8B8 ? 32 :
- d3dsd.Format == D3DFMT_A4R4G4B4 ? 16 : 0;
- spd.pitch = LockedRect.Pitch;
- spd.bits = LockedRect.pBits;
- spd.vidrect = m_vidrect;
-
- return S_OK;
+ D3DSURFACE_DESC d3dsd;
+ ZeroMemory(&d3dsd, sizeof(d3dsd));
+ if (FAILED(m_pSurface->GetDesc(&d3dsd))) {
+ return E_FAIL;
+ }
+
+ D3DLOCKED_RECT LockedRect;
+ ZeroMemory(&LockedRect, sizeof(LockedRect));
+ if (FAILED(m_pSurface->LockRect(&LockedRect, NULL, D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_NOSYSLOCK))) {
+ return E_FAIL;
+ }
+
+ spd.type = 0;
+ spd.w = m_size.cx;
+ spd.h = m_size.cy;
+ spd.bpp =
+ d3dsd.Format == D3DFMT_A8R8G8B8 ? 32 :
+ d3dsd.Format == D3DFMT_A4R4G4B4 ? 16 : 0;
+ spd.pitch = LockedRect.Pitch;
+ spd.bits = LockedRect.pBits;
+ spd.vidrect = m_vidrect;
+
+ return S_OK;
}
STDMETHODIMP CDX9SubPic::Unlock(RECT* pDirtyRect)
{
- HRESULT hr = m_pSurface->UnlockRect();
-
- if (pDirtyRect) {
- m_rcDirty = *pDirtyRect;
- if (!((CRect*)pDirtyRect)->IsRectEmpty()) {
- m_rcDirty.InflateRect(1, 1);
- m_rcDirty.left &= ~127;
- m_rcDirty.top &= ~63;
- m_rcDirty.right = (m_rcDirty.right + 127) & ~127;
- m_rcDirty.bottom = (m_rcDirty.bottom + 63) & ~63;
- m_rcDirty &= CRect(CPoint(0, 0), m_size);
- }
- } else {
- m_rcDirty = CRect(CPoint(0, 0), m_size);
- }
-
- CComPtr<IDirect3DTexture9> pTexture = (IDirect3DTexture9*)GetObject();
- if (pTexture && !((CRect*)pDirtyRect)->IsRectEmpty()) {
- hr = pTexture->AddDirtyRect(&m_rcDirty);
- }
-
- return S_OK;
+ HRESULT hr = m_pSurface->UnlockRect();
+
+ if (pDirtyRect) {
+ m_rcDirty = *pDirtyRect;
+ if (!((CRect*)pDirtyRect)->IsRectEmpty()) {
+ m_rcDirty.InflateRect(1, 1);
+ m_rcDirty.left &= ~127;
+ m_rcDirty.top &= ~63;
+ m_rcDirty.right = (m_rcDirty.right + 127) & ~127;
+ m_rcDirty.bottom = (m_rcDirty.bottom + 63) & ~63;
+ m_rcDirty &= CRect(CPoint(0, 0), m_size);
+ }
+ } else {
+ m_rcDirty = CRect(CPoint(0, 0), m_size);
+ }
+
+ CComPtr<IDirect3DTexture9> pTexture = (IDirect3DTexture9*)GetObject();
+ if (pTexture && !((CRect*)pDirtyRect)->IsRectEmpty()) {
+ hr = pTexture->AddDirtyRect(&m_rcDirty);
+ }
+
+ return S_OK;
}
STDMETHODIMP CDX9SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
{
- ASSERT(pTarget == NULL);
-
- if (!pSrc || !pDst) {
- return E_POINTER;
- }
-
- CRect src(*pSrc), dst(*pDst);
-
- CComPtr<IDirect3DDevice9> pD3DDev;
- CComPtr<IDirect3DTexture9> pTexture = (IDirect3DTexture9*)GetObject();
- if (!pTexture || FAILED(pTexture->GetDevice(&pD3DDev)) || !pD3DDev) {
- return E_NOINTERFACE;
- }
-
- HRESULT hr;
-
- do {
- D3DSURFACE_DESC d3dsd;
- ZeroMemory(&d3dsd, sizeof(d3dsd));
- if (FAILED(pTexture->GetLevelDesc(0, &d3dsd)) /*|| d3dsd.Type != D3DRTYPE_TEXTURE*/) {
- break;
- }
-
- float w = (float)d3dsd.Width;
- float h = (float)d3dsd.Height;
-
- struct {
- float x, y, z, rhw;
- float tu, tv;
- }
- pVertices[] = {
- {(float)dst.left, (float)dst.top, 0.5f, 2.0f, (float)src.left / w, (float)src.top / h},
- {(float)dst.right, (float)dst.top, 0.5f, 2.0f, (float)src.right / w, (float)src.top / h},
- {(float)dst.left, (float)dst.bottom, 0.5f, 2.0f, (float)src.left / w, (float)src.bottom / h},
- {(float)dst.right, (float)dst.bottom, 0.5f, 2.0f, (float)src.right / w, (float)src.bottom / h},
- };
-
- for (ptrdiff_t i = 0; i < _countof(pVertices); i++) {
- pVertices[i].x -= 0.5;
- pVertices[i].y -= 0.5;
- }
-
- hr = pD3DDev->SetTexture(0, pTexture);
-
- // GetRenderState fails for devices created with D3DCREATE_PUREDEVICE
- // so we need to provide default values in case GetRenderState fails
- DWORD abe, sb, db;
- if (FAILED(pD3DDev->GetRenderState(D3DRS_ALPHABLENDENABLE, &abe)))
- abe = FALSE;
- if (FAILED(pD3DDev->GetRenderState(D3DRS_SRCBLEND, &sb)))
- sb = D3DBLEND_ONE;
- if (FAILED(pD3DDev->GetRenderState(D3DRS_DESTBLEND, &db)))
- db = D3DBLEND_ZERO;
-
- hr = pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
- hr = pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- hr = pD3DDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); // pre-multiplied src and ...
- hr = pD3DDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_SRCALPHA); // ... inverse alpha channel for dst
-
- hr = pD3DDev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
- hr = pD3DDev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
- hr = pD3DDev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
-
- if (pSrc == pDst) {
- hr = pD3DDev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
- hr = pD3DDev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
- }
- else {
- hr = pD3DDev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
- hr = pD3DDev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
- }
- hr = pD3DDev->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
-
- hr = pD3DDev->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER);
- hr = pD3DDev->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER);
- hr = pD3DDev->SetSamplerState(0, D3DSAMP_BORDERCOLOR, 0xFF000000);
-
- /*//
-
- D3DCAPS9 d3dcaps9;
- hr = pD3DDev->GetDeviceCaps(&d3dcaps9);
- if (d3dcaps9.AlphaCmpCaps & D3DPCMPCAPS_LESS)
- {
- hr = pD3DDev->SetRenderState(D3DRS_ALPHAREF, (DWORD)0x000000FE);
- hr = pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
- hr = pD3DDev->SetRenderState(D3DRS_ALPHAFUNC, D3DPCMPCAPS_LESS);
- }
-
- *///
-
- hr = pD3DDev->SetPixelShader(NULL);
-
- if ((m_bExternalRenderer) && (FAILED(hr = pD3DDev->BeginScene())))
- break;
-
- hr = pD3DDev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
- hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pVertices, sizeof(pVertices[0]));
-
- if (m_bExternalRenderer)
- hr = pD3DDev->EndScene();
-
- //
-
- pD3DDev->SetTexture(0, NULL);
-
- pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, abe);
- pD3DDev->SetRenderState(D3DRS_SRCBLEND, sb);
- pD3DDev->SetRenderState(D3DRS_DESTBLEND, db);
-
- return S_OK;
- } while (0);
-
- return E_FAIL;
+ ASSERT(pTarget == NULL);
+
+ if (!pSrc || !pDst) {
+ return E_POINTER;
+ }
+
+ CRect src(*pSrc), dst(*pDst);
+
+ CComPtr<IDirect3DDevice9> pD3DDev;
+ CComPtr<IDirect3DTexture9> pTexture = (IDirect3DTexture9*)GetObject();
+ if (!pTexture || FAILED(pTexture->GetDevice(&pD3DDev)) || !pD3DDev) {
+ return E_NOINTERFACE;
+ }
+
+ HRESULT hr;
+
+ do {
+ D3DSURFACE_DESC d3dsd;
+ ZeroMemory(&d3dsd, sizeof(d3dsd));
+ if (FAILED(pTexture->GetLevelDesc(0, &d3dsd)) /*|| d3dsd.Type != D3DRTYPE_TEXTURE*/) {
+ break;
+ }
+
+ float w = (float)d3dsd.Width;
+ float h = (float)d3dsd.Height;
+
+ struct {
+ float x, y, z, rhw;
+ float tu, tv;
+ }
+ pVertices[] = {
+ {(float)dst.left, (float)dst.top, 0.5f, 2.0f, (float)src.left / w, (float)src.top / h},
+ {(float)dst.right, (float)dst.top, 0.5f, 2.0f, (float)src.right / w, (float)src.top / h},
+ {(float)dst.left, (float)dst.bottom, 0.5f, 2.0f, (float)src.left / w, (float)src.bottom / h},
+ {(float)dst.right, (float)dst.bottom, 0.5f, 2.0f, (float)src.right / w, (float)src.bottom / h},
+ };
+
+ for (ptrdiff_t i = 0; i < _countof(pVertices); i++) {
+ pVertices[i].x -= 0.5;
+ pVertices[i].y -= 0.5;
+ }
+
+ hr = pD3DDev->SetTexture(0, pTexture);
+
+ // GetRenderState fails for devices created with D3DCREATE_PUREDEVICE
+ // so we need to provide default values in case GetRenderState fails
+ DWORD abe, sb, db;
+ if (FAILED(pD3DDev->GetRenderState(D3DRS_ALPHABLENDENABLE, &abe))) {
+ abe = FALSE;
+ }
+ if (FAILED(pD3DDev->GetRenderState(D3DRS_SRCBLEND, &sb))) {
+ sb = D3DBLEND_ONE;
+ }
+ if (FAILED(pD3DDev->GetRenderState(D3DRS_DESTBLEND, &db))) {
+ db = D3DBLEND_ZERO;
+ }
+
+ hr = pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
+ hr = pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ hr = pD3DDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); // pre-multiplied src and ...
+ hr = pD3DDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_SRCALPHA); // ... inverse alpha channel for dst
+
+ hr = pD3DDev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
+ hr = pD3DDev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+ hr = pD3DDev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
+
+ if (pSrc == pDst) {
+ hr = pD3DDev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
+ hr = pD3DDev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
+ } else {
+ hr = pD3DDev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
+ hr = pD3DDev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
+ }
+ hr = pD3DDev->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
+
+ hr = pD3DDev->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER);
+ hr = pD3DDev->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER);
+ hr = pD3DDev->SetSamplerState(0, D3DSAMP_BORDERCOLOR, 0xFF000000);
+
+ /*//
+
+ D3DCAPS9 d3dcaps9;
+ hr = pD3DDev->GetDeviceCaps(&d3dcaps9);
+ if (d3dcaps9.AlphaCmpCaps & D3DPCMPCAPS_LESS)
+ {
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHAREF, (DWORD)0x000000FE);
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHAFUNC, D3DPCMPCAPS_LESS);
+ }
+
+ *///
+
+ hr = pD3DDev->SetPixelShader(NULL);
+
+ if ((m_bExternalRenderer) && (FAILED(hr = pD3DDev->BeginScene()))) {
+ break;
+ }
+
+ hr = pD3DDev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
+ hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pVertices, sizeof(pVertices[0]));
+
+ if (m_bExternalRenderer) {
+ hr = pD3DDev->EndScene();
+ }
+
+ //
+
+ pD3DDev->SetTexture(0, NULL);
+
+ pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, abe);
+ pD3DDev->SetRenderState(D3DRS_SRCBLEND, sb);
+ pD3DDev->SetRenderState(D3DRS_DESTBLEND, db);
+
+ return S_OK;
+ } while (0);
+
+ return E_FAIL;
}
//
@@ -350,10 +354,10 @@ STDMETHODIMP CDX9SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
//
CDX9SubPicAllocator::CDX9SubPicAllocator(IDirect3DDevice9* pD3DDev, SIZE maxsize, bool fPow2Textures, bool bExternalRenderer)
- : CSubPicAllocatorImpl(maxsize, true, fPow2Textures)
- , m_pD3DDev(pD3DDev)
- , m_maxsize(maxsize)
- , m_bExternalRenderer(bExternalRenderer)
+ : CSubPicAllocatorImpl(maxsize, true, fPow2Textures)
+ , m_pD3DDev(pD3DDev)
+ , m_maxsize(maxsize)
+ , m_bExternalRenderer(bExternalRenderer)
{
}
@@ -361,111 +365,111 @@ CCritSec CDX9SubPicAllocator::ms_SurfaceQueueLock;
CDX9SubPicAllocator::~CDX9SubPicAllocator()
{
- ClearCache();
+ ClearCache();
}
-void CDX9SubPicAllocator::GetStats(int &_nFree, int &_nAlloc)
+void CDX9SubPicAllocator::GetStats(int& _nFree, int& _nAlloc)
{
- CAutoLock Lock(&ms_SurfaceQueueLock);
- _nFree = (int)m_FreeSurfaces.GetCount();
- _nAlloc = (int)m_AllocatedSurfaces.GetCount();
+ CAutoLock Lock(&ms_SurfaceQueueLock);
+ _nFree = (int)m_FreeSurfaces.GetCount();
+ _nAlloc = (int)m_AllocatedSurfaces.GetCount();
}
void CDX9SubPicAllocator::ClearCache()
{
- {
- // Clear the allocator of any remaining subpics
- CAutoLock Lock(&ms_SurfaceQueueLock);
- for (POSITION pos = m_AllocatedSurfaces.GetHeadPosition(); pos; ) {
- CDX9SubPic *pSubPic = m_AllocatedSurfaces.GetNext(pos);
- pSubPic->m_pAllocator = NULL;
- }
- m_AllocatedSurfaces.RemoveAll();
- m_FreeSurfaces.RemoveAll();
- }
+ {
+ // Clear the allocator of any remaining subpics
+ CAutoLock Lock(&ms_SurfaceQueueLock);
+ for (POSITION pos = m_AllocatedSurfaces.GetHeadPosition(); pos;) {
+ CDX9SubPic* pSubPic = m_AllocatedSurfaces.GetNext(pos);
+ pSubPic->m_pAllocator = NULL;
+ }
+ m_AllocatedSurfaces.RemoveAll();
+ m_FreeSurfaces.RemoveAll();
+ }
}
// ISubPicAllocator
STDMETHODIMP CDX9SubPicAllocator::ChangeDevice(IUnknown* pDev)
{
- ClearCache();
- CComQIPtr<IDirect3DDevice9> pD3DDev = pDev;
- if (!pD3DDev) {
- return E_NOINTERFACE;
- }
+ ClearCache();
+ CComQIPtr<IDirect3DDevice9> pD3DDev = pDev;
+ if (!pD3DDev) {
+ return E_NOINTERFACE;
+ }
- CAutoLock cAutoLock(this);
- m_pD3DDev = pD3DDev;
+ CAutoLock cAutoLock(this);
+ m_pD3DDev = pD3DDev;
- return __super::ChangeDevice(pDev);
+ return __super::ChangeDevice(pDev);
}
STDMETHODIMP CDX9SubPicAllocator::SetMaxTextureSize(SIZE MaxTextureSize)
{
- ClearCache();
- m_maxsize = MaxTextureSize;
- SetCurSize(MaxTextureSize);
- return S_OK;
+ ClearCache();
+ m_maxsize = MaxTextureSize;
+ SetCurSize(MaxTextureSize);
+ return S_OK;
}
// ISubPicAllocatorImpl
bool CDX9SubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic)
{
- if (!ppSubPic) {
- return false;
- }
-
- CAutoLock cAutoLock(this);
-
- *ppSubPic = NULL;
-
- CComPtr<IDirect3DSurface9> pSurface;
-
- int Width = m_maxsize.cx;
- int Height = m_maxsize.cy;
-
- if (m_fPow2Textures && Width < 1024 && Height < 1024) {
- Width = Height = 1;
- while (Width < m_maxsize.cx) {
- Width <<= 1;
- }
- while (Height < m_maxsize.cy) {
- Height <<= 1;
- }
- }
- if (!fStatic) {
- CAutoLock cAutoLock(&ms_SurfaceQueueLock);
- POSITION FreeSurf = m_FreeSurfaces.GetHeadPosition();
- if (FreeSurf) {
- pSurface = m_FreeSurfaces.GetHead();
- m_FreeSurfaces.RemoveHead();
- }
- }
-
- if (!pSurface) {
- CComPtr<IDirect3DTexture9> pTexture;
- if (FAILED(m_pD3DDev->CreateTexture(Width, Height, 1, 0, D3DFMT_A8R8G8B8, fStatic?D3DPOOL_SYSTEMMEM:D3DPOOL_DEFAULT, &pTexture, NULL))) {
- return false;
- }
-
- if (FAILED(pTexture->GetSurfaceLevel(0, &pSurface))) {
- return false;
- }
- }
-
- *ppSubPic = DNew CDX9SubPic(pSurface, fStatic ? 0 : this, m_bExternalRenderer);
- if (!(*ppSubPic)) {
- return false;
- }
-
- (*ppSubPic)->AddRef();
-
- if (!fStatic) {
- CAutoLock cAutoLock(&ms_SurfaceQueueLock);
- m_AllocatedSurfaces.AddHead((CDX9SubPic *)*ppSubPic);
- }
-
- return true;
+ if (!ppSubPic) {
+ return false;
+ }
+
+ CAutoLock cAutoLock(this);
+
+ *ppSubPic = NULL;
+
+ CComPtr<IDirect3DSurface9> pSurface;
+
+ int Width = m_maxsize.cx;
+ int Height = m_maxsize.cy;
+
+ if (m_fPow2Textures && Width < 1024 && Height < 1024) {
+ Width = Height = 1;
+ while (Width < m_maxsize.cx) {
+ Width <<= 1;
+ }
+ while (Height < m_maxsize.cy) {
+ Height <<= 1;
+ }
+ }
+ if (!fStatic) {
+ CAutoLock cAutoLock(&ms_SurfaceQueueLock);
+ POSITION FreeSurf = m_FreeSurfaces.GetHeadPosition();
+ if (FreeSurf) {
+ pSurface = m_FreeSurfaces.GetHead();
+ m_FreeSurfaces.RemoveHead();
+ }
+ }
+
+ if (!pSurface) {
+ CComPtr<IDirect3DTexture9> pTexture;
+ if (FAILED(m_pD3DDev->CreateTexture(Width, Height, 1, 0, D3DFMT_A8R8G8B8, fStatic ? D3DPOOL_SYSTEMMEM : D3DPOOL_DEFAULT, &pTexture, NULL))) {
+ return false;
+ }
+
+ if (FAILED(pTexture->GetSurfaceLevel(0, &pSurface))) {
+ return false;
+ }
+ }
+
+ *ppSubPic = DNew CDX9SubPic(pSurface, fStatic ? 0 : this, m_bExternalRenderer);
+ if (!(*ppSubPic)) {
+ return false;
+ }
+
+ (*ppSubPic)->AddRef();
+
+ if (!fStatic) {
+ CAutoLock cAutoLock(&ms_SurfaceQueueLock);
+ m_AllocatedSurfaces.AddHead((CDX9SubPic*)*ppSubPic);
+ }
+
+ return true;
}
diff --git a/src/SubPic/DX9SubPic.h b/src/SubPic/DX9SubPic.h
index e0f33705c..f092a7686 100644
--- a/src/SubPic/DX9SubPic.h
+++ b/src/SubPic/DX9SubPic.h
@@ -32,86 +32,86 @@
class CVirtualLock
{
public:
- virtual void Lock() = 0;
- virtual void Unlock() = 0;
+ virtual void Lock() = 0;
+ virtual void Unlock() = 0;
};
-typedef void (FLock)(void *_pLock);
+typedef void (FLock)(void* _pLock);
class CScopeLock
{
- void *m_pLock;
- FLock *m_pUnlockFunc;
+ void* m_pLock;
+ FLock* m_pUnlockFunc;
public:
- CScopeLock() {}; // let's make cppcheck happy
-
- template <typename t_Lock>
- class TCLocker
- {
- public:
- static void fs_Locker(void *_pLock) {
- ((t_Lock *)_pLock)->Unlock();
- }
- };
-
- template <typename t_Lock>
- CScopeLock(t_Lock &_Lock) {
- _Lock.Lock();
- m_pLock = &_Lock;
- m_pUnlockFunc = TCLocker<t_Lock>::fs_Locker;
- }
-
- ~CScopeLock() {
- m_pUnlockFunc(m_pLock);
- }
+ CScopeLock() {}; // let's make cppcheck happy
+
+ template <typename t_Lock>
+ class TCLocker
+ {
+ public:
+ static void fs_Locker(void* _pLock) {
+ ((t_Lock*)_pLock)->Unlock();
+ }
+ };
+
+ template <typename t_Lock>
+ CScopeLock(t_Lock& _Lock) {
+ _Lock.Lock();
+ m_pLock = &_Lock;
+ m_pUnlockFunc = TCLocker<t_Lock>::fs_Locker;
+ }
+
+ ~CScopeLock() {
+ m_pUnlockFunc(m_pLock);
+ }
};
class CDX9SubPicAllocator;
class CDX9SubPic : public CSubPicImpl
{
- CComPtr<IDirect3DSurface9> m_pSurface;
+ CComPtr<IDirect3DSurface9> m_pSurface;
protected:
- STDMETHODIMP_(void*) GetObject(); // returns IDirect3DTexture9*
+ STDMETHODIMP_(void*) GetObject(); // returns IDirect3DTexture9*
public:
- CDX9SubPicAllocator *m_pAllocator;
- bool m_bExternalRenderer;
- CDX9SubPic(IDirect3DSurface9* pSurface, CDX9SubPicAllocator *pAllocator, bool bExternalRenderer);
- ~CDX9SubPic();
-
- // ISubPic
- STDMETHODIMP GetDesc(SubPicDesc& spd);
- STDMETHODIMP CopyTo(ISubPic* pSubPic);
- STDMETHODIMP ClearDirtyRect(DWORD color);
- STDMETHODIMP Lock(SubPicDesc& spd);
- STDMETHODIMP Unlock(RECT* pDirtyRect);
- STDMETHODIMP AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget);
+ CDX9SubPicAllocator* m_pAllocator;
+ bool m_bExternalRenderer;
+ CDX9SubPic(IDirect3DSurface9* pSurface, CDX9SubPicAllocator* pAllocator, bool bExternalRenderer);
+ ~CDX9SubPic();
+
+ // ISubPic
+ STDMETHODIMP GetDesc(SubPicDesc& spd);
+ STDMETHODIMP CopyTo(ISubPic* pSubPic);
+ STDMETHODIMP ClearDirtyRect(DWORD color);
+ STDMETHODIMP Lock(SubPicDesc& spd);
+ STDMETHODIMP Unlock(RECT* pDirtyRect);
+ STDMETHODIMP AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget);
};
// CDX9SubPicAllocator
class CDX9SubPicAllocator : public CSubPicAllocatorImpl, public CCritSec
{
- CComPtr<IDirect3DDevice9> m_pD3DDev;
- CSize m_maxsize;
- bool m_bExternalRenderer;
+ CComPtr<IDirect3DDevice9> m_pD3DDev;
+ CSize m_maxsize;
+ bool m_bExternalRenderer;
- bool Alloc(bool fStatic, ISubPic** ppSubPic);
+ bool Alloc(bool fStatic, ISubPic** ppSubPic);
public:
- static CCritSec ms_SurfaceQueueLock;
- CAtlList<CComPtr<IDirect3DSurface9> > m_FreeSurfaces;
- CAtlList<CDX9SubPic *> m_AllocatedSurfaces;
+ static CCritSec ms_SurfaceQueueLock;
+ CAtlList<CComPtr<IDirect3DSurface9> > m_FreeSurfaces;
+ CAtlList<CDX9SubPic*> m_AllocatedSurfaces;
- void GetStats(int &_nFree, int &_nAlloc);
+ void GetStats(int& _nFree, int& _nAlloc);
- CDX9SubPicAllocator(IDirect3DDevice9* pD3DDev, SIZE maxsize, bool fPow2Textures, bool bExternalRenderer);
- ~CDX9SubPicAllocator();
- void ClearCache();
+ CDX9SubPicAllocator(IDirect3DDevice9* pD3DDev, SIZE maxsize, bool fPow2Textures, bool bExternalRenderer);
+ ~CDX9SubPicAllocator();
+ void ClearCache();
- // ISubPicAllocator
- STDMETHODIMP ChangeDevice(IUnknown* pDev);
- STDMETHODIMP SetMaxTextureSize(SIZE MaxTextureSize);
+ // ISubPicAllocator
+ STDMETHODIMP ChangeDevice(IUnknown* pDev);
+ STDMETHODIMP SetMaxTextureSize(SIZE MaxTextureSize);
};
diff --git a/src/SubPic/ISubPic.h b/src/SubPic/ISubPic.h
index 29be3d94e..618dc4602 100644
--- a/src/SubPic/ISubPic.h
+++ b/src/SubPic/ISubPic.h
@@ -29,19 +29,19 @@
#pragma pack(push, 1)
struct SubPicDesc {
- int type;
- int w, h, bpp, pitch, pitchUV;
- void* bits;
- BYTE* bitsU;
- BYTE* bitsV;
- RECT vidrect; // video rectangle
-
- struct SubPicDesc() {
- type = 0;
- w = h = bpp = pitch = pitchUV = 0;
- bits = NULL;
- bitsU = bitsV = NULL;
- }
+ int type;
+ int w, h, bpp, pitch, pitchUV;
+ void* bits;
+ BYTE* bitsU;
+ BYTE* bitsV;
+ RECT vidrect; // video rectangle
+
+ struct SubPicDesc() {
+ type = 0;
+ w = h = bpp = pitch = pitchUV = 0;
+ bits = NULL;
+ bitsU = bitsV = NULL;
+ }
};
#pragma pack(pop)
@@ -52,34 +52,34 @@ struct SubPicDesc {
interface __declspec(uuid("449E11F3-52D1-4a27-AA61-E2733AC92CC0"))
ISubPic :
public IUnknown {
- STDMETHOD_(void*, GetObject) () PURE;
+ STDMETHOD_(void*, GetObject)() PURE;
- STDMETHOD_(REFERENCE_TIME, GetStart) () PURE;
- STDMETHOD_(REFERENCE_TIME, GetStop) () PURE;
- STDMETHOD_(void, SetStart) (REFERENCE_TIME rtStart) PURE;
- STDMETHOD_(void, SetStop) (REFERENCE_TIME rtStop) PURE;
+ STDMETHOD_(REFERENCE_TIME, GetStart)() PURE;
+ STDMETHOD_(REFERENCE_TIME, GetStop)() PURE;
+ STDMETHOD_(void, SetStart)(REFERENCE_TIME rtStart) PURE;
+ STDMETHOD_(void, SetStop)(REFERENCE_TIME rtStop) PURE;
- STDMETHOD (GetDesc) (SubPicDesc& spd /*[out]*/) PURE;
- STDMETHOD (CopyTo) (ISubPic* pSubPic /*[in]*/) PURE;
+ STDMETHOD(GetDesc)(SubPicDesc& spd /*[out]*/) PURE;
+ STDMETHOD(CopyTo)(ISubPic* pSubPic /*[in]*/) PURE;
- STDMETHOD (ClearDirtyRect) (DWORD color /*[in]*/) PURE;
- STDMETHOD (GetDirtyRect) (RECT* pDirtyRect /*[out]*/) PURE;
- STDMETHOD (SetDirtyRect) (RECT* pDirtyRect /*[in]*/) PURE;
+ STDMETHOD(ClearDirtyRect)(DWORD color /*[in]*/) PURE;
+ STDMETHOD(GetDirtyRect)(RECT* pDirtyRect /*[out]*/) PURE;
+ STDMETHOD(SetDirtyRect)(RECT* pDirtyRect /*[in]*/) PURE;
- STDMETHOD (GetMaxSize) (SIZE* pMaxSize /*[out]*/) PURE;
- STDMETHOD (SetSize) (SIZE pSize /*[in]*/, RECT vidrect /*[in]*/) PURE;
+ STDMETHOD(GetMaxSize)(SIZE* pMaxSize /*[out]*/) PURE;
+ STDMETHOD(SetSize)(SIZE pSize /*[in]*/, RECT vidrect /*[in]*/) PURE;
- STDMETHOD (Lock) (SubPicDesc& spd /*[out]*/) PURE;
- STDMETHOD (Unlock) (RECT* pDirtyRect /*[in]*/) PURE;
+ STDMETHOD(Lock)(SubPicDesc& spd /*[out]*/) PURE;
+ STDMETHOD(Unlock)(RECT* pDirtyRect /*[in]*/) PURE;
- STDMETHOD (AlphaBlt) (RECT* pSrc, RECT* pDst, SubPicDesc* pTarget = NULL /*[in]*/) PURE;
- STDMETHOD (GetSourceAndDest) (SIZE* pSize /*[in]*/, RECT* pRcSource /*[out]*/, RECT* pRcDest /*[out]*/) PURE;
- STDMETHOD (SetVirtualTextureSize) (const SIZE pSize, const POINT pTopLeft) PURE;
+ STDMETHOD(AlphaBlt)(RECT * pSrc, RECT * pDst, SubPicDesc* pTarget = NULL /*[in]*/) PURE;
+ STDMETHOD(GetSourceAndDest)(SIZE* pSize /*[in]*/, RECT* pRcSource /*[out]*/, RECT* pRcDest /*[out]*/) PURE;
+ STDMETHOD(SetVirtualTextureSize)(const SIZE pSize, const POINT pTopLeft) PURE;
- STDMETHOD_(REFERENCE_TIME, GetSegmentStart) () PURE;
- STDMETHOD_(REFERENCE_TIME, GetSegmentStop) () PURE;
- STDMETHOD_(void, SetSegmentStart) (REFERENCE_TIME rtStart) PURE;
- STDMETHOD_(void, SetSegmentStop) (REFERENCE_TIME rtStop) PURE;
+ STDMETHOD_(REFERENCE_TIME, GetSegmentStart)() PURE;
+ STDMETHOD_(REFERENCE_TIME, GetSegmentStop)() PURE;
+ STDMETHOD_(void, SetSegmentStart)(REFERENCE_TIME rtStart) PURE;
+ STDMETHOD_(void, SetSegmentStop)(REFERENCE_TIME rtStop) PURE;
};
@@ -90,16 +90,16 @@ public IUnknown {
interface __declspec(uuid("CF7C3C23-6392-4a42-9E72-0736CFF793CB"))
ISubPicAllocator :
public IUnknown {
- STDMETHOD (SetCurSize) (SIZE size /*[in]*/) PURE;
- STDMETHOD (SetCurVidRect) (RECT curvidrect) PURE;
+ STDMETHOD(SetCurSize)(SIZE size /*[in]*/) PURE;
+ STDMETHOD(SetCurVidRect)(RECT curvidrect) PURE;
- STDMETHOD (GetStatic) (ISubPic** ppSubPic /*[out]*/) PURE;
- STDMETHOD (AllocDynamic) (ISubPic** ppSubPic /*[out]*/) PURE;
+ STDMETHOD(GetStatic)(ISubPic** ppSubPic /*[out]*/) PURE;
+ STDMETHOD(AllocDynamic)(ISubPic** ppSubPic /*[out]*/) PURE;
- STDMETHOD_(bool, IsDynamicWriteOnly) () PURE;
+ STDMETHOD_(bool, IsDynamicWriteOnly)() PURE;
- STDMETHOD (ChangeDevice) (IUnknown* pDev) PURE;
- STDMETHOD (SetMaxTextureSize) (SIZE MaxTextureSize) PURE;
+ STDMETHOD(ChangeDevice)(IUnknown * pDev) PURE;
+ STDMETHOD(SetMaxTextureSize)(SIZE MaxTextureSize) PURE;
};
@@ -110,19 +110,19 @@ public IUnknown {
interface __declspec(uuid("D62B9A1A-879A-42db-AB04-88AA8F243CFD"))
ISubPicProvider :
public IUnknown {
- STDMETHOD (Lock) () PURE;
- STDMETHOD (Unlock) () PURE;
+ STDMETHOD(Lock)() PURE;
+ STDMETHOD(Unlock)() PURE;
- STDMETHOD_(POSITION, GetStartPosition) (REFERENCE_TIME rt, double fps) PURE;
- STDMETHOD_(POSITION, GetNext) (POSITION pos) PURE;
+ STDMETHOD_(POSITION, GetStartPosition)(REFERENCE_TIME rt, double fps) PURE;
+ STDMETHOD_(POSITION, GetNext)(POSITION pos) PURE;
- STDMETHOD_(REFERENCE_TIME, GetStart) (POSITION pos, double fps) PURE;
- STDMETHOD_(REFERENCE_TIME, GetStop) (POSITION pos, double fps) PURE;
+ STDMETHOD_(REFERENCE_TIME, GetStart)(POSITION pos, double fps) PURE;
+ STDMETHOD_(REFERENCE_TIME, GetStop)(POSITION pos, double fps) PURE;
- STDMETHOD_(bool, IsAnimated) (POSITION pos) PURE;
+ STDMETHOD_(bool, IsAnimated)(POSITION pos) PURE;
- STDMETHOD (Render) (SubPicDesc& spd, REFERENCE_TIME rt, double fps, RECT& bbox) PURE;
- STDMETHOD (GetTextureSize) (POSITION pos, SIZE& MaxTextureSize, SIZE& VirtualSize, POINT& VirtualTopLeft) PURE;
+ STDMETHOD(Render)(SubPicDesc & spd, REFERENCE_TIME rt, double fps, RECT & bbox) PURE;
+ STDMETHOD(GetTextureSize)(POSITION pos, SIZE & MaxTextureSize, SIZE & VirtualSize, POINT & VirtualTopLeft) PURE;
};
@@ -133,17 +133,17 @@ public IUnknown {
interface __declspec(uuid("C8334466-CD1E-4ad1-9D2D-8EE8519BD180"))
ISubPicQueue :
public IUnknown {
- STDMETHOD (SetSubPicProvider) (ISubPicProvider* pSubPicProvider /*[in]*/) PURE;
- STDMETHOD (GetSubPicProvider) (ISubPicProvider** pSubPicProvider /*[out]*/) PURE;
+ STDMETHOD(SetSubPicProvider)(ISubPicProvider* pSubPicProvider /*[in]*/) PURE;
+ STDMETHOD(GetSubPicProvider)(ISubPicProvider** pSubPicProvider /*[out]*/) PURE;
- STDMETHOD (SetFPS) (double fps /*[in]*/) PURE;
- STDMETHOD (SetTime) (REFERENCE_TIME rtNow /*[in]*/) PURE;
+ STDMETHOD(SetFPS)(double fps /*[in]*/) PURE;
+ STDMETHOD(SetTime)(REFERENCE_TIME rtNow /*[in]*/) PURE;
- STDMETHOD (Invalidate) (REFERENCE_TIME rtInvalidate = -1) PURE;
- STDMETHOD_(bool, LookupSubPic) (REFERENCE_TIME rtNow /*[in]*/, CComPtr<ISubPic> &pSubPic /*[out]*/) PURE;
+ STDMETHOD(Invalidate)(REFERENCE_TIME rtInvalidate = -1) PURE;
+ STDMETHOD_(bool, LookupSubPic)(REFERENCE_TIME rtNow /*[in]*/, CComPtr<ISubPic>& pSubPic /*[out]*/) PURE;
- STDMETHOD (GetStats) (int& nSubPics, REFERENCE_TIME& rtNow, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop /*[out]*/) PURE;
- STDMETHOD (GetStats) (int nSubPic /*[in]*/, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop /*[out]*/) PURE;
+ STDMETHOD(GetStats)(int & nSubPics, REFERENCE_TIME & rtNow, REFERENCE_TIME & rtStart, REFERENCE_TIME& rtStop /*[out]*/) PURE;
+ STDMETHOD(GetStats)(int nSubPic /*[in]*/, REFERENCE_TIME & rtStart, REFERENCE_TIME& rtStop /*[out]*/) PURE;
};
@@ -154,35 +154,35 @@ public IUnknown {
interface __declspec(uuid("CF75B1F0-535C-4074-8869-B15F177F944E"))
ISubPicAllocatorPresenter :
public IUnknown {
- STDMETHOD (CreateRenderer) (IUnknown** ppRenderer) PURE;
+ STDMETHOD(CreateRenderer)(IUnknown** ppRenderer) PURE;
- STDMETHOD_(SIZE, GetVideoSize) (bool fCorrectAR = true) PURE;
- STDMETHOD_(void, SetPosition) (RECT w, RECT v) PURE;
- STDMETHOD_(bool, Paint) (bool fAll) PURE;
+ STDMETHOD_(SIZE, GetVideoSize)(bool fCorrectAR = true) PURE;
+ STDMETHOD_(void, SetPosition)(RECT w, RECT v) PURE;
+ STDMETHOD_(bool, Paint)(bool fAll) PURE;
- STDMETHOD_(void, SetTime) (REFERENCE_TIME rtNow) PURE;
- STDMETHOD_(void, SetSubtitleDelay) (int delay_ms) PURE;
- STDMETHOD_(int, GetSubtitleDelay) () PURE;
- STDMETHOD_(double, GetFPS) () PURE;
+ STDMETHOD_(void, SetTime)(REFERENCE_TIME rtNow) PURE;
+ STDMETHOD_(void, SetSubtitleDelay)(int delay_ms) PURE;
+ STDMETHOD_(int, GetSubtitleDelay)() PURE;
+ STDMETHOD_(double, GetFPS)() PURE;
- STDMETHOD_(void, SetSubPicProvider) (ISubPicProvider* pSubPicProvider) PURE;
- STDMETHOD_(void, Invalidate) (REFERENCE_TIME rtInvalidate = -1) PURE;
+ STDMETHOD_(void, SetSubPicProvider)(ISubPicProvider * pSubPicProvider) PURE;
+ STDMETHOD_(void, Invalidate)(REFERENCE_TIME rtInvalidate = -1) PURE;
- STDMETHOD (GetDIB) (BYTE* lpDib, DWORD* size) PURE;
+ STDMETHOD(GetDIB)(BYTE * lpDib, DWORD * size) PURE;
- STDMETHOD (SetVideoAngle) (Vector v, bool fRepaint = true) PURE;
- STDMETHOD (SetPixelShader) (LPCSTR pSrcData, LPCSTR pTarget) PURE;
+ STDMETHOD(SetVideoAngle)(Vector v, bool fRepaint = true) PURE;
+ STDMETHOD(SetPixelShader)(LPCSTR pSrcData, LPCSTR pTarget) PURE;
- STDMETHOD_(bool, ResetDevice) () PURE;
+ STDMETHOD_(bool, ResetDevice)() PURE;
- STDMETHOD_(bool, DisplayChange) () PURE;
+ STDMETHOD_(bool, DisplayChange)() PURE;
};
interface __declspec(uuid("767AEBA8-A084-488a-89C8-F6B74E53A90F"))
ISubPicAllocatorPresenter2 :
public ISubPicAllocatorPresenter {
- STDMETHOD (SetPixelShader2) (LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace) PURE;
- STDMETHOD_(SIZE, GetVisibleVideoSize) () PURE;
+ STDMETHOD(SetPixelShader2)(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace) PURE;
+ STDMETHOD_(SIZE, GetVisibleVideoSize)() PURE;
};
@@ -193,12 +193,12 @@ public ISubPicAllocatorPresenter {
interface __declspec(uuid("DE11E2FB-02D3-45e4-A174-6B7CE2783BDB"))
ISubStream :
public IPersist {
- STDMETHOD_(int, GetStreamCount) () PURE;
- STDMETHOD (GetStreamInfo) (int i, WCHAR** ppName, LCID* pLCID) PURE;
- STDMETHOD_(int, GetStream) () PURE;
- STDMETHOD (SetStream) (int iStream) PURE;
- STDMETHOD (Reload) () PURE;
-
- // TODO: get rid of IPersist to identify type and use only
- // interface functions to modify the settings of the substream
+ STDMETHOD_(int, GetStreamCount)() PURE;
+ STDMETHOD(GetStreamInfo)(int i, WCHAR** ppName, LCID * pLCID) PURE;
+ STDMETHOD_(int, GetStream)() PURE;
+ STDMETHOD(SetStream)(int iStream) PURE;
+ STDMETHOD(Reload)() PURE;
+
+ // TODO: get rid of IPersist to identify type and use only
+ // interface functions to modify the settings of the substream
};
diff --git a/src/SubPic/ISubRender.h b/src/SubPic/ISubRender.h
index 4a3ac01d7..5689f50eb 100644
--- a/src/SubPic/ISubRender.h
+++ b/src/SubPic/ISubRender.h
@@ -28,27 +28,27 @@
interface __declspec(uuid("CD6D2AA5-20D3-4ebe-A8A9-34D3B00CC253"))
ISubRenderCallback :
public IUnknown {
- // NULL means release current device, textures and other resources
- STDMETHOD(SetDevice)(IDirect3DDevice9 *dev) = 0;
+ // NULL means release current device, textures and other resources
+ STDMETHOD(SetDevice)(IDirect3DDevice9 * dev) = 0;
- // destination video rectangle, will be inside (0, 0)-(width, height)
- // width,height is the size of the entire output window
- STDMETHOD(Render)(REFERENCE_TIME rtStart,
- int left, int top, int bottom, int right,
- int width, int height) = 0;
+ // destination video rectangle, will be inside (0, 0)-(width, height)
+ // width,height is the size of the entire output window
+ STDMETHOD(Render)(REFERENCE_TIME rtStart,
+ int left, int top, int bottom, int right,
+ int width, int height) = 0;
};
interface __declspec(uuid("E602585E-C05A-4828-AC69-AF92997F2E0C"))
ISubRenderCallback2 :
public ISubRenderCallback {
- STDMETHOD(RenderEx)(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop,
- REFERENCE_TIME AvgTimePerFrame,
- int left, int top, int right, int bottom,
- int width, int height) = 0;
+ STDMETHOD(RenderEx)(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop,
+ REFERENCE_TIME AvgTimePerFrame,
+ int left, int top, int right, int bottom,
+ int width, int height) = 0;
};
interface __declspec(uuid("9CC7F9F7-3ED1-493c-AF65-527EA1D9947F"))
ISubRender :
public IUnknown {
- STDMETHOD(SetCallback)(ISubRenderCallback *cb) = 0;
+ STDMETHOD(SetCallback)(ISubRenderCallback * cb) = 0;
};
diff --git a/src/SubPic/MemSubPic.cpp b/src/SubPic/MemSubPic.cpp
index a40a4baec..d726deede 100644
--- a/src/SubPic/MemSubPic.cpp
+++ b/src/SubPic/MemSubPic.cpp
@@ -30,59 +30,59 @@
// color conv
-unsigned char Clip_base[256*3];
+unsigned char Clip_base[256 * 3];
unsigned char* Clip = Clip_base + 256;
-const int c2y_cyb = int(0.114*219/255*65536+0.5);
-const int c2y_cyg = int(0.587*219/255*65536+0.5);
-const int c2y_cyr = int(0.299*219/255*65536+0.5);
-const int c2y_cu = int(1.0/2.018*1024+0.5);
-const int c2y_cv = int(1.0/1.596*1024+0.5);
+const int c2y_cyb = int(0.114 * 219 / 255 * 65536 + 0.5);
+const int c2y_cyg = int(0.587 * 219 / 255 * 65536 + 0.5);
+const int c2y_cyr = int(0.299 * 219 / 255 * 65536 + 0.5);
+const int c2y_cu = int(1.0 / 2.018 * 1024 + 0.5);
+const int c2y_cv = int(1.0 / 1.596 * 1024 + 0.5);
int c2y_yb[256];
int c2y_yg[256];
int c2y_yr[256];
-const int y2c_cbu = int(2.018*65536+0.5);
-const int y2c_cgu = int(0.391*65536+0.5);
-const int y2c_cgv = int(0.813*65536+0.5);
-const int y2c_crv = int(1.596*65536+0.5);
+const int y2c_cbu = int(2.018 * 65536 + 0.5);
+const int y2c_cgu = int(0.391 * 65536 + 0.5);
+const int y2c_cgv = int(0.813 * 65536 + 0.5);
+const int y2c_crv = int(1.596 * 65536 + 0.5);
int y2c_bu[256];
int y2c_gu[256];
int y2c_gv[256];
int y2c_rv[256];
-const int cy_cy = int(255.0/219.0*65536+0.5);
-const int cy_cy2 = int(255.0/219.0*32768+0.5);
+const int cy_cy = int(255.0 / 219.0 * 65536 + 0.5);
+const int cy_cy2 = int(255.0 / 219.0 * 32768 + 0.5);
bool fColorConvInitOK = false;
void ColorConvInit()
{
- if (fColorConvInitOK) {
- return;
- }
-
- int i;
-
- for (i = 0; i < 256; i++) {
- Clip_base[i] = 0;
- Clip_base[i+256] = i;
- Clip_base[i+512] = 255;
- }
-
- for (i = 0; i < 256; i++) {
- c2y_yb[i] = c2y_cyb*i;
- c2y_yg[i] = c2y_cyg*i;
- c2y_yr[i] = c2y_cyr*i;
-
- y2c_bu[i] = y2c_cbu*(i-128);
- y2c_gu[i] = y2c_cgu*(i-128);
- y2c_gv[i] = y2c_cgv*(i-128);
- y2c_rv[i] = y2c_crv*(i-128);
- }
-
- fColorConvInitOK = true;
+ if (fColorConvInitOK) {
+ return;
+ }
+
+ int i;
+
+ for (i = 0; i < 256; i++) {
+ Clip_base[i] = 0;
+ Clip_base[i + 256] = i;
+ Clip_base[i + 512] = 255;
+ }
+
+ for (i = 0; i < 256; i++) {
+ c2y_yb[i] = c2y_cyb * i;
+ c2y_yg[i] = c2y_cyg * i;
+ c2y_yr[i] = c2y_cyr * i;
+
+ y2c_bu[i] = y2c_cbu * (i - 128);
+ y2c_gu[i] = y2c_cgu * (i - 128);
+ y2c_gv[i] = y2c_cgv * (i - 128);
+ y2c_rv[i] = y2c_crv * (i - 128);
+ }
+
+ fColorConvInitOK = true;
}
#define rgb2yuv(r1,g1,b1,r2,g2,b2) \
@@ -99,504 +99,504 @@ void ColorConvInit()
//
CMemSubPic::CMemSubPic(SubPicDesc& spd)
- : m_spd(spd)
+ : m_spd(spd)
{
- m_maxsize.SetSize(spd.w, spd.h);
- m_rcDirty.SetRect(0, 0, spd.w, spd.h);
+ m_maxsize.SetSize(spd.w, spd.h);
+ m_rcDirty.SetRect(0, 0, spd.w, spd.h);
}
CMemSubPic::~CMemSubPic()
{
- delete [] m_spd.bits, m_spd.bits = NULL;
+ delete [] m_spd.bits, m_spd.bits = NULL;
}
// ISubPic
STDMETHODIMP_(void*) CMemSubPic::GetObject()
{
- return (void*)&m_spd;
+ return (void*)&m_spd;
}
STDMETHODIMP CMemSubPic::GetDesc(SubPicDesc& spd)
{
- spd.type = m_spd.type;
- spd.w = m_size.cx;
- spd.h = m_size.cy;
- spd.bpp = m_spd.bpp;
- spd.pitch = m_spd.pitch;
- spd.bits = m_spd.bits;
- spd.bitsU = m_spd.bitsU;
- spd.bitsV = m_spd.bitsV;
- spd.vidrect = m_vidrect;
-
- return S_OK;
+ spd.type = m_spd.type;
+ spd.w = m_size.cx;
+ spd.h = m_size.cy;
+ spd.bpp = m_spd.bpp;
+ spd.pitch = m_spd.pitch;
+ spd.bits = m_spd.bits;
+ spd.bitsU = m_spd.bitsU;
+ spd.bitsV = m_spd.bitsV;
+ spd.vidrect = m_vidrect;
+
+ return S_OK;
}
STDMETHODIMP CMemSubPic::CopyTo(ISubPic* pSubPic)
{
- HRESULT hr;
- if (FAILED(hr = __super::CopyTo(pSubPic))) {
- return hr;
- }
+ HRESULT hr;
+ if (FAILED(hr = __super::CopyTo(pSubPic))) {
+ return hr;
+ }
- SubPicDesc src, dst;
- if (FAILED(GetDesc(src)) || FAILED(pSubPic->GetDesc(dst))) {
- return E_FAIL;
- }
+ SubPicDesc src, dst;
+ if (FAILED(GetDesc(src)) || FAILED(pSubPic->GetDesc(dst))) {
+ return E_FAIL;
+ }
- int w = m_rcDirty.Width(), h = m_rcDirty.Height();
+ int w = m_rcDirty.Width(), h = m_rcDirty.Height();
- BYTE* s = (BYTE*)src.bits + src.pitch*m_rcDirty.top + m_rcDirty.left*4;
- BYTE* d = (BYTE*)dst.bits + dst.pitch*m_rcDirty.top + m_rcDirty.left*4;
+ BYTE* s = (BYTE*)src.bits + src.pitch * m_rcDirty.top + m_rcDirty.left * 4;
+ BYTE* d = (BYTE*)dst.bits + dst.pitch * m_rcDirty.top + m_rcDirty.left * 4;
- for (ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
- memcpy(d, s, w*4);
- }
+ for (ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
+ memcpy(d, s, w * 4);
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CMemSubPic::ClearDirtyRect(DWORD color)
{
- if (m_rcDirty.IsRectEmpty()) {
- return S_FALSE;
- }
+ if (m_rcDirty.IsRectEmpty()) {
+ return S_FALSE;
+ }
- BYTE* p = (BYTE*)m_spd.bits + m_spd.pitch*m_rcDirty.top + m_rcDirty.left*(m_spd.bpp>>3);
- for (ptrdiff_t j = 0, h = m_rcDirty.Height(); j < h; j++, p += m_spd.pitch) {
- int w = m_rcDirty.Width();
+ BYTE* p = (BYTE*)m_spd.bits + m_spd.pitch * m_rcDirty.top + m_rcDirty.left * (m_spd.bpp >> 3);
+ for (ptrdiff_t j = 0, h = m_rcDirty.Height(); j < h; j++, p += m_spd.pitch) {
+ int w = m_rcDirty.Width();
#ifdef _WIN64
- memsetd(p, color, w*4); // nya
+ memsetd(p, color, w * 4); // nya
#else
- __asm {
- mov eax, color
- mov ecx, w
- mov edi, p
- cld
- rep stosd
- }
+ __asm {
+ mov eax, color
+ mov ecx, w
+ mov edi, p
+ cld
+ rep stosd
+ }
#endif
- }
+ }
- m_rcDirty.SetRectEmpty();
+ m_rcDirty.SetRectEmpty();
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CMemSubPic::Lock(SubPicDesc& spd)
{
- return GetDesc(spd);
+ return GetDesc(spd);
}
STDMETHODIMP CMemSubPic::Unlock(RECT* pDirtyRect)
{
- m_rcDirty = pDirtyRect ? *pDirtyRect : CRect(0,0,m_spd.w,m_spd.h);
-
- if (m_rcDirty.IsRectEmpty()) {
- return S_OK;
- }
-
- if (m_spd.type == MSP_YUY2 || m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV || m_spd.type == MSP_AYUV) {
- ColorConvInit();
-
- if (m_spd.type == MSP_YUY2 || m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV) {
- m_rcDirty.left &= ~1;
- m_rcDirty.right = (m_rcDirty.right+1)&~1;
-
- if (m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV) {
- m_rcDirty.top &= ~1;
- m_rcDirty.bottom = (m_rcDirty.bottom+1)&~1;
- }
- }
- }
-
- int w = m_rcDirty.Width(), h = m_rcDirty.Height();
-
- BYTE* top = (BYTE*)m_spd.bits + m_spd.pitch*m_rcDirty.top + m_rcDirty.left*4;
- BYTE* bottom = top + m_spd.pitch*h;
-
- if (m_spd.type == MSP_RGB16) {
- for (; top < bottom ; top += m_spd.pitch) {
- DWORD* s = (DWORD*)top;
- DWORD* e = s + w;
- for (; s < e; s++) {
- *s = ((*s>>3)&0x1f000000)|((*s>>8)&0xf800)|((*s>>5)&0x07e0)|((*s>>3)&0x001f);
- // *s = (*s&0xff000000)|((*s>>8)&0xf800)|((*s>>5)&0x07e0)|((*s>>3)&0x001f);
- }
- }
- } else if (m_spd.type == MSP_RGB15) {
- for (; top < bottom; top += m_spd.pitch) {
- DWORD* s = (DWORD*)top;
- DWORD* e = s + w;
- for (; s < e; s++) {
- *s = ((*s>>3)&0x1f000000)|((*s>>9)&0x7c00)|((*s>>6)&0x03e0)|((*s>>3)&0x001f);
- // *s = (*s&0xff000000)|((*s>>9)&0x7c00)|((*s>>6)&0x03e0)|((*s>>3)&0x001f);
- }
- }
- } else if (m_spd.type == MSP_YUY2 || m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV) {
- for (; top < bottom ; top += m_spd.pitch) {
- BYTE* s = top;
- BYTE* e = s + w*4;
- for (; s < e; s+=8) { // ARGB ARGB -> AxYU AxYV
- if ((s[3]+s[7]) < 0x1fe) {
- s[1] = (c2y_yb[s[0]] + c2y_yg[s[1]] + c2y_yr[s[2]] + 0x108000) >> 16;
- s[5] = (c2y_yb[s[4]] + c2y_yg[s[5]] + c2y_yr[s[6]] + 0x108000) >> 16;
-
- int scaled_y = (s[1]+s[5]-32) * cy_cy2;
-
- s[0] = Clip[(((((s[0]+s[4])<<15) - scaled_y) >> 10) * c2y_cu + 0x800000 + 0x8000) >> 16];
- s[4] = Clip[(((((s[2]+s[6])<<15) - scaled_y) >> 10) * c2y_cv + 0x800000 + 0x8000) >> 16];
- } else {
- s[1] = s[5] = 0x10;
- s[0] = s[4] = 0x80;
- }
- }
- }
- } else if (m_spd.type == MSP_AYUV) {
- for (; top < bottom ; top += m_spd.pitch) {
- BYTE* s = top;
- BYTE* e = s + w*4;
- for (; s < e; s+=4) { // ARGB -> AYUV
- if (s[3] < 0xff) {
- int y = (c2y_yb[s[0]] + c2y_yg[s[1]] + c2y_yr[s[2]] + 0x108000) >> 16;
- int scaled_y = (y-32) * cy_cy;
- s[1] = Clip[((((s[0]<<16) - scaled_y) >> 10) * c2y_cu + 0x800000 + 0x8000) >> 16];
- s[0] = Clip[((((s[2]<<16) - scaled_y) >> 10) * c2y_cv + 0x800000 + 0x8000) >> 16];
- s[2] = y;
- } else {
- s[0] = s[1] = 0x80;
- s[2] = 0x10;
- }
- }
- }
- }
-
- return S_OK;
+ m_rcDirty = pDirtyRect ? *pDirtyRect : CRect(0, 0, m_spd.w, m_spd.h);
+
+ if (m_rcDirty.IsRectEmpty()) {
+ return S_OK;
+ }
+
+ if (m_spd.type == MSP_YUY2 || m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV || m_spd.type == MSP_AYUV) {
+ ColorConvInit();
+
+ if (m_spd.type == MSP_YUY2 || m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV) {
+ m_rcDirty.left &= ~1;
+ m_rcDirty.right = (m_rcDirty.right + 1)&~1;
+
+ if (m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV) {
+ m_rcDirty.top &= ~1;
+ m_rcDirty.bottom = (m_rcDirty.bottom + 1)&~1;
+ }
+ }
+ }
+
+ int w = m_rcDirty.Width(), h = m_rcDirty.Height();
+
+ BYTE* top = (BYTE*)m_spd.bits + m_spd.pitch * m_rcDirty.top + m_rcDirty.left * 4;
+ BYTE* bottom = top + m_spd.pitch * h;
+
+ if (m_spd.type == MSP_RGB16) {
+ for (; top < bottom ; top += m_spd.pitch) {
+ DWORD* s = (DWORD*)top;
+ DWORD* e = s + w;
+ for (; s < e; s++) {
+ *s = ((*s >> 3) & 0x1f000000) | ((*s >> 8) & 0xf800) | ((*s >> 5) & 0x07e0) | ((*s >> 3) & 0x001f);
+ // *s = (*s&0xff000000)|((*s>>8)&0xf800)|((*s>>5)&0x07e0)|((*s>>3)&0x001f);
+ }
+ }
+ } else if (m_spd.type == MSP_RGB15) {
+ for (; top < bottom; top += m_spd.pitch) {
+ DWORD* s = (DWORD*)top;
+ DWORD* e = s + w;
+ for (; s < e; s++) {
+ *s = ((*s >> 3) & 0x1f000000) | ((*s >> 9) & 0x7c00) | ((*s >> 6) & 0x03e0) | ((*s >> 3) & 0x001f);
+ // *s = (*s&0xff000000)|((*s>>9)&0x7c00)|((*s>>6)&0x03e0)|((*s>>3)&0x001f);
+ }
+ }
+ } else if (m_spd.type == MSP_YUY2 || m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV) {
+ for (; top < bottom ; top += m_spd.pitch) {
+ BYTE* s = top;
+ BYTE* e = s + w * 4;
+ for (; s < e; s += 8) { // ARGB ARGB -> AxYU AxYV
+ if ((s[3] + s[7]) < 0x1fe) {
+ s[1] = (c2y_yb[s[0]] + c2y_yg[s[1]] + c2y_yr[s[2]] + 0x108000) >> 16;
+ s[5] = (c2y_yb[s[4]] + c2y_yg[s[5]] + c2y_yr[s[6]] + 0x108000) >> 16;
+
+ int scaled_y = (s[1] + s[5] - 32) * cy_cy2;
+
+ s[0] = Clip[(((((s[0] + s[4]) << 15) - scaled_y) >> 10) * c2y_cu + 0x800000 + 0x8000) >> 16];
+ s[4] = Clip[(((((s[2] + s[6]) << 15) - scaled_y) >> 10) * c2y_cv + 0x800000 + 0x8000) >> 16];
+ } else {
+ s[1] = s[5] = 0x10;
+ s[0] = s[4] = 0x80;
+ }
+ }
+ }
+ } else if (m_spd.type == MSP_AYUV) {
+ for (; top < bottom ; top += m_spd.pitch) {
+ BYTE* s = top;
+ BYTE* e = s + w * 4;
+ for (; s < e; s += 4) { // ARGB -> AYUV
+ if (s[3] < 0xff) {
+ int y = (c2y_yb[s[0]] + c2y_yg[s[1]] + c2y_yr[s[2]] + 0x108000) >> 16;
+ int scaled_y = (y - 32) * cy_cy;
+ s[1] = Clip[((((s[0] << 16) - scaled_y) >> 10) * c2y_cu + 0x800000 + 0x8000) >> 16];
+ s[0] = Clip[((((s[2] << 16) - scaled_y) >> 10) * c2y_cv + 0x800000 + 0x8000) >> 16];
+ s[2] = y;
+ } else {
+ s[0] = s[1] = 0x80;
+ s[2] = 0x10;
+ }
+ }
+ }
+ }
+
+ return S_OK;
}
#ifdef _WIN64
void AlphaBlt_YUY2_SSE2(int w, int h, BYTE* d, int dstpitch, BYTE* s, int srcpitch)
{
- unsigned int ia;
- DWORD* d2 = (DWORD*)d;
-
- BYTE* s2 = s;
- BYTE* s2end = s2 + w*4;
- static const __int64 _8181 = 0x0080001000800010i64;
-
- for (ptrdiff_t j = 0; j < h; j++, s += srcpitch, d += dstpitch) {
- for (; s2 < s2end; s2 += 8, d2++) {
- ia = (s2[3]+s2[7])>>1;
- if (ia < 0xff) {
- unsigned int c = (s2[4]<<24)|(s2[5]<<16)|(s2[0]<<8)|s2[1]; // (v<<24)|(y2<<16)|(u<<8)|y1;
-
- ia = (ia<<24)|(s2[7]<<16)|(ia<<8)|s2[3];
- // SSE2
- __m128i mm_zero = _mm_setzero_si128();
- __m128i mm_8181 = _mm_move_epi64(_mm_cvtsi64_si128(_8181));
- __m128i mm_c = _mm_cvtsi32_si128(c);
- mm_c = _mm_unpacklo_epi8(mm_c, mm_zero);
- __m128i mm_d = _mm_cvtsi32_si128(*d2);
- mm_d = _mm_unpacklo_epi8(mm_d, mm_zero);
- __m128i mm_a = _mm_cvtsi32_si128(ia);
- mm_a = _mm_unpacklo_epi8(mm_a, mm_zero);
- mm_a = _mm_srli_epi16(mm_a,1);
- mm_d = _mm_sub_epi16(mm_d,mm_8181);
- mm_d = _mm_mullo_epi16(mm_d,mm_a);
- mm_d = _mm_srai_epi16(mm_d,7);
- mm_d = _mm_adds_epi16(mm_d,mm_c);
- mm_d = _mm_packus_epi16(mm_d,mm_d);
- *d2 = (DWORD)_mm_cvtsi128_si32(mm_d);
- }
- }
- }
+ unsigned int ia;
+ DWORD* d2 = (DWORD*)d;
+
+ BYTE* s2 = s;
+ BYTE* s2end = s2 + w * 4;
+ static const __int64 _8181 = 0x0080001000800010i64;
+
+ for (ptrdiff_t j = 0; j < h; j++, s += srcpitch, d += dstpitch) {
+ for (; s2 < s2end; s2 += 8, d2++) {
+ ia = (s2[3] + s2[7]) >> 1;
+ if (ia < 0xff) {
+ unsigned int c = (s2[4] << 24) | (s2[5] << 16) | (s2[0] << 8) | s2[1]; // (v<<24)|(y2<<16)|(u<<8)|y1;
+
+ ia = (ia << 24) | (s2[7] << 16) | (ia << 8) | s2[3];
+ // SSE2
+ __m128i mm_zero = _mm_setzero_si128();
+ __m128i mm_8181 = _mm_move_epi64(_mm_cvtsi64_si128(_8181));
+ __m128i mm_c = _mm_cvtsi32_si128(c);
+ mm_c = _mm_unpacklo_epi8(mm_c, mm_zero);
+ __m128i mm_d = _mm_cvtsi32_si128(*d2);
+ mm_d = _mm_unpacklo_epi8(mm_d, mm_zero);
+ __m128i mm_a = _mm_cvtsi32_si128(ia);
+ mm_a = _mm_unpacklo_epi8(mm_a, mm_zero);
+ mm_a = _mm_srli_epi16(mm_a, 1);
+ mm_d = _mm_sub_epi16(mm_d, mm_8181);
+ mm_d = _mm_mullo_epi16(mm_d, mm_a);
+ mm_d = _mm_srai_epi16(mm_d, 7);
+ mm_d = _mm_adds_epi16(mm_d, mm_c);
+ mm_d = _mm_packus_epi16(mm_d, mm_d);
+ *d2 = (DWORD)_mm_cvtsi128_si32(mm_d);
+ }
+ }
+ }
}
#endif
#ifndef _WIN64
void AlphaBlt_YUY2_MMX(int w, int h, BYTE* d, int dstpitch, BYTE* s, int srcpitch)
{
- unsigned int ia;
- DWORD* d2 = (DWORD*)d;
-
- BYTE* s2 = s;
- BYTE* s2end = s2 + w*4;
- static const __int64 _8181 = 0x0080001000800010i64;
-
-
- for (ptrdiff_t j = 0; j < h; j++, s += srcpitch, d += dstpitch) {
- for (; s2 < s2end; s2 += 8, d2++) {
- ia = (s2[3]+s2[7])>>1;
- if (ia < 0xff) {
- unsigned int c = (s2[4]<<24)|(s2[5]<<16)|(s2[0]<<8)|s2[1]; // (v<<24)|(y2<<16)|(u<<8)|y1;
- ia = (ia<<24)|(s2[7]<<16)|(ia<<8)|s2[3];
- __asm {
- mov esi, s2
- mov edi, d2
- pxor mm0, mm0
- movq mm1, _8181
- movd mm2, c
- punpcklbw mm2, mm0
- movd mm3, [edi]
- punpcklbw mm3, mm0
- movd mm4, ia
- punpcklbw mm4, mm0
- psrlw mm4, 1
- psubsw mm3, mm1
- pmullw mm3, mm4
- psraw mm3, 7
- paddsw mm3, mm2
- packuswb mm3, mm3
- movd [edi], mm3
- };
- }
- }
- }
+ unsigned int ia;
+ DWORD* d2 = (DWORD*)d;
+
+ BYTE* s2 = s;
+ BYTE* s2end = s2 + w * 4;
+ static const __int64 _8181 = 0x0080001000800010i64;
+
+
+ for (ptrdiff_t j = 0; j < h; j++, s += srcpitch, d += dstpitch) {
+ for (; s2 < s2end; s2 += 8, d2++) {
+ ia = (s2[3] + s2[7]) >> 1;
+ if (ia < 0xff) {
+ unsigned int c = (s2[4] << 24) | (s2[5] << 16) | (s2[0] << 8) | s2[1]; // (v<<24)|(y2<<16)|(u<<8)|y1;
+ ia = (ia << 24) | (s2[7] << 16) | (ia << 8) | s2[3];
+ __asm {
+ mov esi, s2
+ mov edi, d2
+ pxor mm0, mm0
+ movq mm1, _8181
+ movd mm2, c
+ punpcklbw mm2, mm0
+ movd mm3, [edi]
+ punpcklbw mm3, mm0
+ movd mm4, ia
+ punpcklbw mm4, mm0
+ psrlw mm4, 1
+ psubsw mm3, mm1
+ pmullw mm3, mm4
+ psraw mm3, 7
+ paddsw mm3, mm2
+ packuswb mm3, mm3
+ movd [edi], mm3
+ };
+ }
+ }
+ }
}
#endif
void AlphaBlt_YUY2_C(int w, int h, BYTE* d, int dstpitch, BYTE* s, int srcpitch)
{
- unsigned int ia;
- DWORD* d2 = (DWORD*)d;
-
- BYTE* s2 = s;
- BYTE* s2end = s2 + w*4;
- static const __int64 _8181 = 0x0080001000800010i64;
-
- for (ptrdiff_t j = 0; j < h; j++, s += srcpitch, d += dstpitch) {
- for (; s2 < s2end; s2 += 8, d2++) {
- ia = (s2[3]+s2[7])>>1;
- if (ia < 0xff) {
- //unsigned int c = (s2[4]<<24)|(s2[5]<<16)|(s2[0]<<8)|s2[1]; // (v<<24)|(y2<<16)|(u<<8)|y1;
-
- // YUY2 colorspace fix. rewritten from sse2 asm
- DWORD y1 = (DWORD)(((((*d2&0xff)-0x10)*(s2[3]>>1))>>7)+s2[1])&0xff; // y1
- DWORD uu = (DWORD)((((((*d2>>8)&0xff)-0x80)*(ia>>1))>>7)+s2[0])&0xff; // u
- DWORD y2 = (DWORD)((((((*d2>>16)&0xff)-0x10)*(s2[7]>>1))>>7)+s2[5])&0xff; // y2
- DWORD vv = (DWORD)((((((*d2>>24)&0xff)-0x80)*(ia>>1))>>7)+s2[4])&0xff; // v
- *d2 = (y1)|(uu<<8)|(y2<<16)|(vv<<24);
- }
- }
- }
+ unsigned int ia;
+ DWORD* d2 = (DWORD*)d;
+
+ BYTE* s2 = s;
+ BYTE* s2end = s2 + w * 4;
+ static const __int64 _8181 = 0x0080001000800010i64;
+
+ for (ptrdiff_t j = 0; j < h; j++, s += srcpitch, d += dstpitch) {
+ for (; s2 < s2end; s2 += 8, d2++) {
+ ia = (s2[3] + s2[7]) >> 1;
+ if (ia < 0xff) {
+ //unsigned int c = (s2[4]<<24)|(s2[5]<<16)|(s2[0]<<8)|s2[1]; // (v<<24)|(y2<<16)|(u<<8)|y1;
+
+ // YUY2 colorspace fix. rewritten from sse2 asm
+ DWORD y1 = (DWORD)(((((*d2 & 0xff) - 0x10) * (s2[3] >> 1)) >> 7) + s2[1]) & 0xff; // y1
+ DWORD uu = (DWORD)((((((*d2 >> 8) & 0xff) - 0x80) * (ia >> 1)) >> 7) + s2[0]) & 0xff; // u
+ DWORD y2 = (DWORD)((((((*d2 >> 16) & 0xff) - 0x10) * (s2[7] >> 1)) >> 7) + s2[5]) & 0xff; // y2
+ DWORD vv = (DWORD)((((((*d2 >> 24) & 0xff) - 0x80) * (ia >> 1)) >> 7) + s2[4]) & 0xff; // v
+ *d2 = (y1) | (uu << 8) | (y2 << 16) | (vv << 24);
+ }
+ }
+ }
}
STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
{
- ASSERT(pTarget);
-
- if (!pSrc || !pDst || !pTarget) {
- return E_POINTER;
- }
-
- const SubPicDesc& src = m_spd;
- SubPicDesc dst = *pTarget; // copy, because we might modify it
-
- if (src.type != dst.type) {
- return E_INVALIDARG;
- }
-
- CRect rs(*pSrc), rd(*pDst);
-
- if (dst.h < 0) {
- dst.h = -dst.h;
- rd.bottom = dst.h - rd.bottom;
- rd.top = dst.h - rd.top;
- }
-
- if (rs.Width() != rd.Width() || rs.Height() != abs(rd.Height())) {
- return E_INVALIDARG;
- }
-
- int w = rs.Width(), h = rs.Height();
-
- BYTE* s = (BYTE*)src.bits + src.pitch*rs.top + rs.left*4;
- BYTE* d = (BYTE*)dst.bits + dst.pitch*rd.top + ((rd.left*dst.bpp)>>3);
-
- if (rd.top > rd.bottom) {
- if (dst.type == MSP_RGB32 || dst.type == MSP_RGB24
- || dst.type == MSP_RGB16 || dst.type == MSP_RGB15
- || dst.type == MSP_YUY2 || dst.type == MSP_AYUV) {
- d = (BYTE*)dst.bits + dst.pitch*(rd.top-1) + (rd.left*dst.bpp>>3);
- } else if (dst.type == MSP_YV12 || dst.type == MSP_IYUV) {
- d = (BYTE*)dst.bits + dst.pitch*(rd.top-1) + (rd.left*8>>3);
- } else {
- return E_NOTIMPL;
- }
-
- dst.pitch = -dst.pitch;
- }
-
- switch (dst.type) {
- case MSP_RGBA:
- for (ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
- BYTE* s2 = s;
- BYTE* s2end = s2 + w*4;
- DWORD* d2 = (DWORD*)d;
- for (; s2 < s2end; s2 += 4, d2++) {
- if (s2[3] < 0xff) {
- DWORD bd =0x00000100 -( (DWORD) s2[3]);
- DWORD B = ((*((DWORD*)s2)&0x000000ff)<<8)/bd;
- DWORD V = ((*((DWORD*)s2)&0x0000ff00)/bd)<<8;
- DWORD R = (((*((DWORD*)s2)&0x00ff0000)>>8)/bd)<<16;
- *d2 = B | V | R
- | (0xff000000-(*((DWORD*)s2)&0xff000000))&0xff000000;
- }
- }
- }
- break;
- case MSP_RGB32:
- case MSP_AYUV:
- for (ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
- BYTE* s2 = s;
- BYTE* s2end = s2 + w*4;
-
- DWORD* d2 = (DWORD*)d;
- for (; s2 < s2end; s2 += 4, d2++) {
+ ASSERT(pTarget);
+
+ if (!pSrc || !pDst || !pTarget) {
+ return E_POINTER;
+ }
+
+ const SubPicDesc& src = m_spd;
+ SubPicDesc dst = *pTarget; // copy, because we might modify it
+
+ if (src.type != dst.type) {
+ return E_INVALIDARG;
+ }
+
+ CRect rs(*pSrc), rd(*pDst);
+
+ if (dst.h < 0) {
+ dst.h = -dst.h;
+ rd.bottom = dst.h - rd.bottom;
+ rd.top = dst.h - rd.top;
+ }
+
+ if (rs.Width() != rd.Width() || rs.Height() != abs(rd.Height())) {
+ return E_INVALIDARG;
+ }
+
+ int w = rs.Width(), h = rs.Height();
+
+ BYTE* s = (BYTE*)src.bits + src.pitch * rs.top + rs.left * 4;
+ BYTE* d = (BYTE*)dst.bits + dst.pitch * rd.top + ((rd.left * dst.bpp) >> 3);
+
+ if (rd.top > rd.bottom) {
+ if (dst.type == MSP_RGB32 || dst.type == MSP_RGB24
+ || dst.type == MSP_RGB16 || dst.type == MSP_RGB15
+ || dst.type == MSP_YUY2 || dst.type == MSP_AYUV) {
+ d = (BYTE*)dst.bits + dst.pitch * (rd.top - 1) + (rd.left * dst.bpp >> 3);
+ } else if (dst.type == MSP_YV12 || dst.type == MSP_IYUV) {
+ d = (BYTE*)dst.bits + dst.pitch * (rd.top - 1) + (rd.left * 8 >> 3);
+ } else {
+ return E_NOTIMPL;
+ }
+
+ dst.pitch = -dst.pitch;
+ }
+
+ switch (dst.type) {
+ case MSP_RGBA:
+ for (ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
+ BYTE* s2 = s;
+ BYTE* s2end = s2 + w * 4;
+ DWORD* d2 = (DWORD*)d;
+ for (; s2 < s2end; s2 += 4, d2++) {
+ if (s2[3] < 0xff) {
+ DWORD bd = 0x00000100 - ((DWORD) s2[3]);
+ DWORD B = ((*((DWORD*)s2) & 0x000000ff) << 8) / bd;
+ DWORD V = ((*((DWORD*)s2) & 0x0000ff00) / bd) << 8;
+ DWORD R = (((*((DWORD*)s2) & 0x00ff0000) >> 8) / bd) << 16;
+ *d2 = B | V | R
+ | (0xff000000 - (*((DWORD*)s2) & 0xff000000)) & 0xff000000;
+ }
+ }
+ }
+ break;
+ case MSP_RGB32:
+ case MSP_AYUV:
+ for (ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
+ BYTE* s2 = s;
+ BYTE* s2end = s2 + w * 4;
+
+ DWORD* d2 = (DWORD*)d;
+ for (; s2 < s2end; s2 += 4, d2++) {
#ifdef _WIN64
- DWORD ia = 256-s2[3];
- if (s2[3] < 0xff) {
- *d2 = ((((*d2&0x00ff00ff)*s2[3])>>8) + (((*((DWORD*)s2)&0x00ff00ff)*ia)>>8)&0x00ff00ff)
- | ((((*d2&0x0000ff00)*s2[3])>>8) + (((*((DWORD*)s2)&0x0000ff00)*ia)>>8)&0x0000ff00);
- }
+ DWORD ia = 256 - s2[3];
+ if (s2[3] < 0xff) {
+ *d2 = ((((*d2 & 0x00ff00ff) * s2[3]) >> 8) + (((*((DWORD*)s2) & 0x00ff00ff) * ia) >> 8) & 0x00ff00ff)
+ | ((((*d2 & 0x0000ff00) * s2[3]) >> 8) + (((*((DWORD*)s2) & 0x0000ff00) * ia) >> 8) & 0x0000ff00);
+ }
#else
- if (s2[3] < 0xff) {
- *d2 = ((((*d2&0x00ff00ff)*s2[3])>>8) + (*((DWORD*)s2)&0x00ff00ff)&0x00ff00ff)
- | ((((*d2&0x0000ff00)*s2[3])>>8) + (*((DWORD*)s2)&0x0000ff00)&0x0000ff00);
- }
+ if (s2[3] < 0xff) {
+ *d2 = ((((*d2 & 0x00ff00ff) * s2[3]) >> 8) + (*((DWORD*)s2) & 0x00ff00ff) & 0x00ff00ff)
+ | ((((*d2 & 0x0000ff00) * s2[3]) >> 8) + (*((DWORD*)s2) & 0x0000ff00) & 0x0000ff00);
+ }
#endif
- }
- }
- break;
- case MSP_RGB24:
- for (ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
- BYTE* s2 = s;
- BYTE* s2end = s2 + w*4;
- BYTE* d2 = d;
- for (; s2 < s2end; s2 += 4, d2 += 3) {
- if (s2[3] < 0xff) {
- d2[0] = ((d2[0]*s2[3])>>8) + s2[0];
- d2[1] = ((d2[1]*s2[3])>>8) + s2[1];
- d2[2] = ((d2[2]*s2[3])>>8) + s2[2];
- }
- }
- }
- break;
- case MSP_RGB16:
- for (ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
- BYTE* s2 = s;
- BYTE* s2end = s2 + w*4;
- WORD* d2 = (WORD*)d;
- for (; s2 < s2end; s2 += 4, d2++) {
- if (s2[3] < 0x1f) {
-
- *d2 = (WORD)((((((*d2&0xf81f)*s2[3])>>5) + (*(DWORD*)s2&0xf81f))&0xf81f)
- | (((((*d2&0x07e0)*s2[3])>>5) + (*(DWORD*)s2&0x07e0))&0x07e0));
- }
- }
- }
- break;
- case MSP_RGB15:
- for (ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
- BYTE* s2 = s;
- BYTE* s2end = s2 + w*4;
- WORD* d2 = (WORD*)d;
- for (; s2 < s2end; s2 += 4, d2++) {
- if (s2[3] < 0x1f) {
- *d2 = (WORD)((((((*d2&0x7c1f)*s2[3])>>5) + (*(DWORD*)s2&0x7c1f))&0x7c1f)
- | (((((*d2&0x03e0)*s2[3])>>5) + (*(DWORD*)s2&0x03e0))&0x03e0));
- }
- }
- }
- break;
- case MSP_YUY2: {
- void (*alphablt_func)(int w, int h, BYTE* d, int dstpitch, BYTE* s, int srcpitch);
+ }
+ }
+ break;
+ case MSP_RGB24:
+ for (ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
+ BYTE* s2 = s;
+ BYTE* s2end = s2 + w * 4;
+ BYTE* d2 = d;
+ for (; s2 < s2end; s2 += 4, d2 += 3) {
+ if (s2[3] < 0xff) {
+ d2[0] = ((d2[0] * s2[3]) >> 8) + s2[0];
+ d2[1] = ((d2[1] * s2[3]) >> 8) + s2[1];
+ d2[2] = ((d2[2] * s2[3]) >> 8) + s2[2];
+ }
+ }
+ }
+ break;
+ case MSP_RGB16:
+ for (ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
+ BYTE* s2 = s;
+ BYTE* s2end = s2 + w * 4;
+ WORD* d2 = (WORD*)d;
+ for (; s2 < s2end; s2 += 4, d2++) {
+ if (s2[3] < 0x1f) {
+
+ *d2 = (WORD)((((((*d2 & 0xf81f) * s2[3]) >> 5) + (*(DWORD*)s2 & 0xf81f)) & 0xf81f)
+ | (((((*d2 & 0x07e0) * s2[3]) >> 5) + (*(DWORD*)s2 & 0x07e0)) & 0x07e0));
+ }
+ }
+ }
+ break;
+ case MSP_RGB15:
+ for (ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
+ BYTE* s2 = s;
+ BYTE* s2end = s2 + w * 4;
+ WORD* d2 = (WORD*)d;
+ for (; s2 < s2end; s2 += 4, d2++) {
+ if (s2[3] < 0x1f) {
+ *d2 = (WORD)((((((*d2 & 0x7c1f) * s2[3]) >> 5) + (*(DWORD*)s2 & 0x7c1f)) & 0x7c1f)
+ | (((((*d2 & 0x03e0) * s2[3]) >> 5) + (*(DWORD*)s2 & 0x03e0)) & 0x03e0));
+ }
+ }
+ }
+ break;
+ case MSP_YUY2: {
+ void (*alphablt_func)(int w, int h, BYTE * d, int dstpitch, BYTE * s, int srcpitch);
#ifdef _WIN64
- alphablt_func = AlphaBlt_YUY2_SSE2;
+ alphablt_func = AlphaBlt_YUY2_SSE2;
#else
- alphablt_func = AlphaBlt_YUY2_MMX;
+ alphablt_func = AlphaBlt_YUY2_MMX;
#endif
- //alphablt_func = AlphaBlt_YUY2_C;
-
- alphablt_func(w, h, d, dst.pitch, s, src.pitch);
- }
- break;
- case MSP_YV12:
- case MSP_IYUV:
- for (ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
- BYTE* s2 = s;
- BYTE* s2end = s2 + w*4;
- BYTE* d2 = d;
- for (; s2 < s2end; s2 += 4, d2++) {
- if (s2[3] < 0xff) {
- d2[0] = (((d2[0]-0x10)*s2[3])>>8) + s2[1];
- }
- }
- }
- break;
- default:
- return E_NOTIMPL;
- }
-
- dst.pitch = abs(dst.pitch);
-
- if (dst.type == MSP_YV12 || dst.type == MSP_IYUV) {
- int h2 = h/2;
-
- if (!dst.pitchUV) {
- dst.pitchUV = dst.pitch/2;
- }
-
- BYTE* ss[2];
- ss[0] = (BYTE*)src.bits + src.pitch*rs.top + rs.left*4;
- ss[1] = ss[0] + 4;
-
- if (!dst.bitsU || !dst.bitsV) {
- dst.bitsU = (BYTE*)dst.bits + dst.pitch*dst.h;
- dst.bitsV = dst.bitsU + dst.pitchUV*dst.h/2;
-
- if (dst.type == MSP_YV12) {
- BYTE* p = dst.bitsU;
- dst.bitsU = dst.bitsV;
- dst.bitsV = p;
- }
- }
-
- BYTE* dd[2];
- dd[0] = dst.bitsU + dst.pitchUV*rd.top/2 + rd.left/2;
- dd[1] = dst.bitsV + dst.pitchUV*rd.top/2 + rd.left/2;
-
- if (rd.top > rd.bottom) {
- dd[0] = dst.bitsU + dst.pitchUV*(rd.top/2-1) + rd.left/2;
- dd[1] = dst.bitsV + dst.pitchUV*(rd.top/2-1) + rd.left/2;
- dst.pitchUV = -dst.pitchUV;
- }
-
- for (ptrdiff_t i = 0; i < 2; i++) {
- s = ss[i];
- d = dd[i];
- BYTE* is = ss[1-i];
- for (ptrdiff_t j = 0; j < h2; j++, s += src.pitch*2, d += dst.pitchUV, is += src.pitch*2) {
- BYTE* s2 = s;
- BYTE* s2end = s2 + w*4;
- BYTE* d2 = d;
- BYTE* is2 = is;
- for (; s2 < s2end; s2 += 8, d2++, is2 += 8) {
- unsigned int ia = (s2[3]+s2[3+src.pitch]+is2[3]+is2[3+src.pitch])>>2;
- if (ia < 0xff) {
- *d2 = (((*d2-0x80)*ia)>>8) + ((s2[0]+s2[src.pitch])>>1);
- }
- }
- }
- }
- }
+ //alphablt_func = AlphaBlt_YUY2_C;
+
+ alphablt_func(w, h, d, dst.pitch, s, src.pitch);
+ }
+ break;
+ case MSP_YV12:
+ case MSP_IYUV:
+ for (ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
+ BYTE* s2 = s;
+ BYTE* s2end = s2 + w * 4;
+ BYTE* d2 = d;
+ for (; s2 < s2end; s2 += 4, d2++) {
+ if (s2[3] < 0xff) {
+ d2[0] = (((d2[0] - 0x10) * s2[3]) >> 8) + s2[1];
+ }
+ }
+ }
+ break;
+ default:
+ return E_NOTIMPL;
+ }
+
+ dst.pitch = abs(dst.pitch);
+
+ if (dst.type == MSP_YV12 || dst.type == MSP_IYUV) {
+ int h2 = h / 2;
+
+ if (!dst.pitchUV) {
+ dst.pitchUV = dst.pitch / 2;
+ }
+
+ BYTE* ss[2];
+ ss[0] = (BYTE*)src.bits + src.pitch * rs.top + rs.left * 4;
+ ss[1] = ss[0] + 4;
+
+ if (!dst.bitsU || !dst.bitsV) {
+ dst.bitsU = (BYTE*)dst.bits + dst.pitch * dst.h;
+ dst.bitsV = dst.bitsU + dst.pitchUV * dst.h / 2;
+
+ if (dst.type == MSP_YV12) {
+ BYTE* p = dst.bitsU;
+ dst.bitsU = dst.bitsV;
+ dst.bitsV = p;
+ }
+ }
+
+ BYTE* dd[2];
+ dd[0] = dst.bitsU + dst.pitchUV * rd.top / 2 + rd.left / 2;
+ dd[1] = dst.bitsV + dst.pitchUV * rd.top / 2 + rd.left / 2;
+
+ if (rd.top > rd.bottom) {
+ dd[0] = dst.bitsU + dst.pitchUV * (rd.top / 2 - 1) + rd.left / 2;
+ dd[1] = dst.bitsV + dst.pitchUV * (rd.top / 2 - 1) + rd.left / 2;
+ dst.pitchUV = -dst.pitchUV;
+ }
+
+ for (ptrdiff_t i = 0; i < 2; i++) {
+ s = ss[i];
+ d = dd[i];
+ BYTE* is = ss[1 - i];
+ for (ptrdiff_t j = 0; j < h2; j++, s += src.pitch * 2, d += dst.pitchUV, is += src.pitch * 2) {
+ BYTE* s2 = s;
+ BYTE* s2end = s2 + w * 4;
+ BYTE* d2 = d;
+ BYTE* is2 = is;
+ for (; s2 < s2end; s2 += 8, d2++, is2 += 8) {
+ unsigned int ia = (s2[3] + s2[3 + src.pitch] + is2[3] + is2[3 + src.pitch]) >> 2;
+ if (ia < 0xff) {
+ *d2 = (((*d2 - 0x80) * ia) >> 8) + ((s2[0] + s2[src.pitch]) >> 1);
+ }
+ }
+ }
+ }
+ }
#ifndef _WIN64
- __asm emms;
+ __asm emms;
#endif
- return S_OK;
+ return S_OK;
}
//
@@ -614,27 +614,27 @@ CMemSubPicAllocator::CMemSubPicAllocator(int type, SIZE maxsize)
bool CMemSubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic)
{
- if (!ppSubPic) {
- return false;
- }
-
- SubPicDesc spd;
- spd.w = m_maxsize.cx;
- spd.h = m_maxsize.cy;
- spd.bpp = 32;
- spd.pitch = (spd.w*spd.bpp)>>3;
- spd.type = m_type;
- spd.bits = DNew BYTE[spd.pitch*spd.h];
- if (!spd.bits) {
- return false;
- }
-
- *ppSubPic = DNew CMemSubPic(spd);
- if (!(*ppSubPic)) {
- return false;
- }
-
- (*ppSubPic)->AddRef();
-
- return true;
+ if (!ppSubPic) {
+ return false;
+ }
+
+ SubPicDesc spd;
+ spd.w = m_maxsize.cx;
+ spd.h = m_maxsize.cy;
+ spd.bpp = 32;
+ spd.pitch = (spd.w * spd.bpp) >> 3;
+ spd.type = m_type;
+ spd.bits = DNew BYTE[spd.pitch * spd.h];
+ if (!spd.bits) {
+ return false;
+ }
+
+ *ppSubPic = DNew CMemSubPic(spd);
+ if (!(*ppSubPic)) {
+ return false;
+ }
+
+ (*ppSubPic)->AddRef();
+
+ return true;
}
diff --git a/src/SubPic/MemSubPic.h b/src/SubPic/MemSubPic.h
index 720f55255..b38d9f3b1 100644
--- a/src/SubPic/MemSubPic.h
+++ b/src/SubPic/MemSubPic.h
@@ -25,40 +25,40 @@
#include "SubPicImpl.h"
-enum {MSP_RGB32,MSP_RGB24,MSP_RGB16,MSP_RGB15,MSP_YUY2,MSP_YV12,MSP_IYUV,MSP_AYUV,MSP_RGBA};
+enum {MSP_RGB32, MSP_RGB24, MSP_RGB16, MSP_RGB15, MSP_YUY2, MSP_YV12, MSP_IYUV, MSP_AYUV, MSP_RGBA};
// CMemSubPic
class CMemSubPic : public CSubPicImpl
{
#pragma warning(disable: 4799)
- SubPicDesc m_spd;
+ SubPicDesc m_spd;
protected:
- STDMETHODIMP_(void*) GetObject(); // returns SubPicDesc*
+ STDMETHODIMP_(void*) GetObject(); // returns SubPicDesc*
public:
- CMemSubPic(SubPicDesc& spd);
- virtual ~CMemSubPic();
+ CMemSubPic(SubPicDesc& spd);
+ virtual ~CMemSubPic();
- // ISubPic
- STDMETHODIMP GetDesc(SubPicDesc& spd);
- STDMETHODIMP CopyTo(ISubPic* pSubPic);
- STDMETHODIMP ClearDirtyRect(DWORD color);
- STDMETHODIMP Lock(SubPicDesc& spd);
- STDMETHODIMP Unlock(RECT* pDirtyRect);
- STDMETHODIMP AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget);
+ // ISubPic
+ STDMETHODIMP GetDesc(SubPicDesc& spd);
+ STDMETHODIMP CopyTo(ISubPic* pSubPic);
+ STDMETHODIMP ClearDirtyRect(DWORD color);
+ STDMETHODIMP Lock(SubPicDesc& spd);
+ STDMETHODIMP Unlock(RECT* pDirtyRect);
+ STDMETHODIMP AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget);
};
// CMemSubPicAllocator
class CMemSubPicAllocator : public CSubPicAllocatorImpl
{
- int m_type;
- CSize m_maxsize;
+ int m_type;
+ CSize m_maxsize;
- bool Alloc(bool fStatic, ISubPic** ppSubPic);
+ bool Alloc(bool fStatic, ISubPic** ppSubPic);
public:
- CMemSubPicAllocator(int type, SIZE maxsize);
+ CMemSubPicAllocator(int type, SIZE maxsize);
};
diff --git a/src/SubPic/SubPicAllocatorPresenterImpl.cpp b/src/SubPic/SubPicAllocatorPresenterImpl.cpp
index 655080a16..5c7391bbf 100644
--- a/src/SubPic/SubPicAllocatorPresenterImpl.cpp
+++ b/src/SubPic/SubPicAllocatorPresenterImpl.cpp
@@ -25,26 +25,26 @@
#include "SubPicAllocatorPresenterImpl.h"
#include "../DSUtil/DSUtil.h"
-CSubPicAllocatorPresenterImpl::CSubPicAllocatorPresenterImpl(HWND hWnd, HRESULT& hr, CString *_pError)
- : CUnknown(NAME("CSubPicAllocatorPresenterImpl"), NULL)
- , m_hWnd(hWnd)
- , m_NativeVideoSize(0, 0), m_AspectRatio(0, 0)
- , m_VideoRect(0, 0, 0, 0), m_WindowRect(0, 0, 0, 0)
- , m_fps(25.0)
- , m_rtSubtitleDelay(0)
- , m_bDeviceResetRequested(false)
- , m_bPendingResetDevice(false)
+CSubPicAllocatorPresenterImpl::CSubPicAllocatorPresenterImpl(HWND hWnd, HRESULT& hr, CString* _pError)
+ : CUnknown(NAME("CSubPicAllocatorPresenterImpl"), NULL)
+ , m_hWnd(hWnd)
+ , m_NativeVideoSize(0, 0), m_AspectRatio(0, 0)
+ , m_VideoRect(0, 0, 0, 0), m_WindowRect(0, 0, 0, 0)
+ , m_fps(25.0)
+ , m_rtSubtitleDelay(0)
+ , m_bDeviceResetRequested(false)
+ , m_bPendingResetDevice(false)
{
- if (!IsWindow(m_hWnd)) {
- hr = E_INVALIDARG;
- if (_pError) {
- *_pError += "Invalid window handle in ISubPicAllocatorPresenterImpl\n";
- }
- return;
- }
- GetWindowRect(m_hWnd, &m_WindowRect);
- SetVideoAngle(Vector(), false);
- hr = S_OK;
+ if (!IsWindow(m_hWnd)) {
+ hr = E_INVALIDARG;
+ if (_pError) {
+ *_pError += "Invalid window handle in ISubPicAllocatorPresenterImpl\n";
+ }
+ return;
+ }
+ GetWindowRect(m_hWnd, &m_WindowRect);
+ SetVideoAngle(Vector(), false);
+ hr = S_OK;
}
CSubPicAllocatorPresenterImpl::~CSubPicAllocatorPresenterImpl()
@@ -54,153 +54,153 @@ CSubPicAllocatorPresenterImpl::~CSubPicAllocatorPresenterImpl()
STDMETHODIMP CSubPicAllocatorPresenterImpl::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- return
- QI(ISubPicAllocatorPresenter)
- QI(ISubPicAllocatorPresenter2)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(ISubPicAllocatorPresenter)
+ QI(ISubPicAllocatorPresenter2)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
void CSubPicAllocatorPresenterImpl::AlphaBltSubPic(CSize size, SubPicDesc* pTarget)
{
- CComPtr<ISubPic> pSubPic;
- if (m_pSubPicQueue->LookupSubPic(m_rtNow, pSubPic)) {
- CRect rcSource, rcDest;
- if (SUCCEEDED (pSubPic->GetSourceAndDest(&size, rcSource, rcDest))) {
- pSubPic->AlphaBlt(rcSource, rcDest, pTarget);
- }
- /* SubPicDesc spd;
- pSubPic->GetDesc(spd);
-
- if (spd.w > 0 && spd.h > 0)
- {
- CRect r;
- pSubPic->GetDirtyRect(r);
-
- // FIXME
- r.DeflateRect(1, 1);
-
- CRect rDstText(
- r.left * size.cx / spd.w,
- r.top * size.cy / spd.h,
- r.right * size.cx / spd.w,
- r.bottom * size.cy / spd.h);
-
- pSubPic->AlphaBlt(r, rDstText, pTarget);
- }
- */
- }
+ CComPtr<ISubPic> pSubPic;
+ if (m_pSubPicQueue->LookupSubPic(m_rtNow, pSubPic)) {
+ CRect rcSource, rcDest;
+ if (SUCCEEDED(pSubPic->GetSourceAndDest(&size, rcSource, rcDest))) {
+ pSubPic->AlphaBlt(rcSource, rcDest, pTarget);
+ }
+ /* SubPicDesc spd;
+ pSubPic->GetDesc(spd);
+
+ if (spd.w > 0 && spd.h > 0)
+ {
+ CRect r;
+ pSubPic->GetDirtyRect(r);
+
+ // FIXME
+ r.DeflateRect(1, 1);
+
+ CRect rDstText(
+ r.left * size.cx / spd.w,
+ r.top * size.cy / spd.h,
+ r.right * size.cx / spd.w,
+ r.bottom * size.cy / spd.h);
+
+ pSubPic->AlphaBlt(r, rDstText, pTarget);
+ }
+ */
+ }
}
// ISubPicAllocatorPresenter
STDMETHODIMP_(SIZE) CSubPicAllocatorPresenterImpl::GetVideoSize(bool fCorrectAR)
{
- CSize VideoSize(GetVisibleVideoSize());
+ CSize VideoSize(GetVisibleVideoSize());
- if (fCorrectAR && m_AspectRatio.cx > 0 && m_AspectRatio.cy > 0) {
- VideoSize.cx = (LONGLONG(VideoSize.cy)*LONGLONG(m_AspectRatio.cx))/LONGLONG(m_AspectRatio.cy);
- }
+ if (fCorrectAR && m_AspectRatio.cx > 0 && m_AspectRatio.cy > 0) {
+ VideoSize.cx = (LONGLONG(VideoSize.cy) * LONGLONG(m_AspectRatio.cx)) / LONGLONG(m_AspectRatio.cy);
+ }
- return VideoSize;
+ return VideoSize;
}
STDMETHODIMP_(void) CSubPicAllocatorPresenterImpl::SetPosition(RECT w, RECT v)
{
- bool fWindowPosChanged = !!(m_WindowRect != w);
- bool fWindowSizeChanged = !!(m_WindowRect.Size() != CRect(w).Size());
+ bool fWindowPosChanged = !!(m_WindowRect != w);
+ bool fWindowSizeChanged = !!(m_WindowRect.Size() != CRect(w).Size());
- m_WindowRect = w;
+ m_WindowRect = w;
- bool fVideoRectChanged = !!(m_VideoRect != v);
+ bool fVideoRectChanged = !!(m_VideoRect != v);
- m_VideoRect = v;
+ m_VideoRect = v;
- if (fWindowSizeChanged || fVideoRectChanged) {
- if (m_pAllocator) {
- m_pAllocator->SetCurSize(m_WindowRect.Size());
- m_pAllocator->SetCurVidRect(m_VideoRect);
- }
+ if (fWindowSizeChanged || fVideoRectChanged) {
+ if (m_pAllocator) {
+ m_pAllocator->SetCurSize(m_WindowRect.Size());
+ m_pAllocator->SetCurVidRect(m_VideoRect);
+ }
- if (m_pSubPicQueue) {
- m_pSubPicQueue->Invalidate();
- }
- }
+ if (m_pSubPicQueue) {
+ m_pSubPicQueue->Invalidate();
+ }
+ }
- if (fWindowPosChanged || fVideoRectChanged) {
- Paint(fWindowSizeChanged || fVideoRectChanged);
- }
+ if (fWindowPosChanged || fVideoRectChanged) {
+ Paint(fWindowSizeChanged || fVideoRectChanged);
+ }
}
STDMETHODIMP_(void) CSubPicAllocatorPresenterImpl::SetTime(REFERENCE_TIME rtNow)
{
- /*
- if (m_rtNow <= rtNow && rtNow <= m_rtNow + 1000000)
- return;
- */
- m_rtNow = rtNow - m_rtSubtitleDelay;
-
- if (m_pSubPicQueue) {
- m_pSubPicQueue->SetTime(m_rtNow);
- }
+ /*
+ if (m_rtNow <= rtNow && rtNow <= m_rtNow + 1000000)
+ return;
+ */
+ m_rtNow = rtNow - m_rtSubtitleDelay;
+
+ if (m_pSubPicQueue) {
+ m_pSubPicQueue->SetTime(m_rtNow);
+ }
}
STDMETHODIMP_(void) CSubPicAllocatorPresenterImpl::SetSubtitleDelay(int delay_ms)
{
- m_rtSubtitleDelay = delay_ms*10000i64;
+ m_rtSubtitleDelay = delay_ms * 10000i64;
}
STDMETHODIMP_(int) CSubPicAllocatorPresenterImpl::GetSubtitleDelay()
{
- return (int)(m_rtSubtitleDelay/10000);
+ return (int)(m_rtSubtitleDelay / 10000);
}
STDMETHODIMP_(double) CSubPicAllocatorPresenterImpl::GetFPS()
{
- return m_fps;
+ return m_fps;
}
STDMETHODIMP_(void) CSubPicAllocatorPresenterImpl::SetSubPicProvider(ISubPicProvider* pSubPicProvider)
{
- m_SubPicProvider = pSubPicProvider;
+ m_SubPicProvider = pSubPicProvider;
- if (m_pSubPicQueue) {
- m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
- }
+ if (m_pSubPicQueue) {
+ m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
+ }
}
STDMETHODIMP_(void) CSubPicAllocatorPresenterImpl::Invalidate(REFERENCE_TIME rtInvalidate)
{
- if (m_pSubPicQueue) {
- m_pSubPicQueue->Invalidate(rtInvalidate);
- }
+ if (m_pSubPicQueue) {
+ m_pSubPicQueue->Invalidate(rtInvalidate);
+ }
}
#include <math.h>
void CSubPicAllocatorPresenterImpl::Transform(CRect r, Vector v[4])
{
- v[0] = Vector((float)r.left, (float)r.top, 0);
- v[1] = Vector((float)r.right, (float)r.top, 0);
- v[2] = Vector((float)r.left, (float)r.bottom, 0);
- v[3] = Vector((float)r.right, (float)r.bottom, 0);
-
- Vector center((float)r.CenterPoint().x, (float)r.CenterPoint().y, 0);
- int l = (int)(Vector((float)r.Size().cx, (float)r.Size().cy, 0).Length()*1.5f)+1;
-
- for (size_t i = 0; i < 4; i++) {
- v[i] = m_xform << (v[i] - center);
- v[i].z = v[i].z / l + 0.5f;
- v[i].x /= v[i].z*2;
- v[i].y /= v[i].z*2;
- v[i] += center;
- }
+ v[0] = Vector((float)r.left, (float)r.top, 0);
+ v[1] = Vector((float)r.right, (float)r.top, 0);
+ v[2] = Vector((float)r.left, (float)r.bottom, 0);
+ v[3] = Vector((float)r.right, (float)r.bottom, 0);
+
+ Vector center((float)r.CenterPoint().x, (float)r.CenterPoint().y, 0);
+ int l = (int)(Vector((float)r.Size().cx, (float)r.Size().cy, 0).Length() * 1.5f) + 1;
+
+ for (size_t i = 0; i < 4; i++) {
+ v[i] = m_xform << (v[i] - center);
+ v[i].z = v[i].z / l + 0.5f;
+ v[i].x /= v[i].z * 2;
+ v[i].y /= v[i].z * 2;
+ v[i] += center;
+ }
}
STDMETHODIMP CSubPicAllocatorPresenterImpl::SetVideoAngle(Vector v, bool fRepaint)
{
- m_xform = XForm(Ray(Vector(0, 0, 0), v), Vector(1, 1, 1), false);
- if (fRepaint) {
- Paint(true);
- }
- return S_OK;
+ m_xform = XForm(Ray(Vector(0, 0, 0), v), Vector(1, 1, 1), false);
+ if (fRepaint) {
+ Paint(true);
+ }
+ return S_OK;
}
diff --git a/src/SubPic/SubPicAllocatorPresenterImpl.h b/src/SubPic/SubPicAllocatorPresenterImpl.h
index 1576283b2..0c027555f 100644
--- a/src/SubPic/SubPicAllocatorPresenterImpl.h
+++ b/src/SubPic/SubPicAllocatorPresenterImpl.h
@@ -29,81 +29,81 @@
#include "CoordGeom.h"
class CSubPicAllocatorPresenterImpl
- : public CUnknown
- , public CCritSec
- , public ISubPicAllocatorPresenter2
+ : public CUnknown
+ , public CCritSec
+ , public ISubPicAllocatorPresenter2
{
protected:
- HWND m_hWnd;
- CSize m_spMaxSize; // TODO:
- int m_spMaxQueued; // TODO:
- REFERENCE_TIME m_rtSubtitleDelay;
+ HWND m_hWnd;
+ CSize m_spMaxSize; // TODO:
+ int m_spMaxQueued; // TODO:
+ REFERENCE_TIME m_rtSubtitleDelay;
- CSize m_NativeVideoSize, m_AspectRatio;
- CRect m_VideoRect, m_WindowRect;
+ CSize m_NativeVideoSize, m_AspectRatio;
+ CRect m_VideoRect, m_WindowRect;
- REFERENCE_TIME m_rtNow;
- double m_fps;
+ REFERENCE_TIME m_rtNow;
+ double m_fps;
- CComPtr<ISubPicProvider> m_SubPicProvider;
- CComPtr<ISubPicAllocator> m_pAllocator;
- CComPtr<ISubPicQueue> m_pSubPicQueue;
+ CComPtr<ISubPicProvider> m_SubPicProvider;
+ CComPtr<ISubPicAllocator> m_pAllocator;
+ CComPtr<ISubPicQueue> m_pSubPicQueue;
- bool m_bDeviceResetRequested;
- bool m_bPendingResetDevice;
+ bool m_bDeviceResetRequested;
+ bool m_bPendingResetDevice;
- void AlphaBltSubPic(CSize size, SubPicDesc* pTarget = NULL);
+ void AlphaBltSubPic(CSize size, SubPicDesc* pTarget = NULL);
- XForm m_xform;
- void Transform(CRect r, Vector v[4]);
+ XForm m_xform;
+ void Transform(CRect r, Vector v[4]);
public:
- CSubPicAllocatorPresenterImpl(HWND hWnd, HRESULT& hr, CString *_pError);
- virtual ~CSubPicAllocatorPresenterImpl();
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // ISubPicAllocatorPresenter
-
- STDMETHODIMP CreateRenderer(IUnknown** ppRenderer) = 0;
-
- STDMETHODIMP_(SIZE) GetVideoSize(bool fCorrectAR = true);
- STDMETHODIMP_(SIZE) GetVisibleVideoSize() {
- return m_NativeVideoSize;
- };
- STDMETHODIMP_(void) SetPosition(RECT w, RECT v);
- STDMETHODIMP_(bool) Paint(bool fAll) = 0;
-
- STDMETHODIMP_(void) SetTime(REFERENCE_TIME rtNow);
- STDMETHODIMP_(void) SetSubtitleDelay(int delay_ms);
- STDMETHODIMP_(int) GetSubtitleDelay();
- STDMETHODIMP_(double) GetFPS();
-
- STDMETHODIMP_(void) SetSubPicProvider(ISubPicProvider* pSubPicProvider);
- STDMETHODIMP_(void) Invalidate(REFERENCE_TIME rtInvalidate = -1);
-
- STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size) {
- return E_NOTIMPL;
- }
-
- STDMETHODIMP_(bool) ResetDevice() {
- return false;
- }
-
- STDMETHODIMP_(bool) DisplayChange() {
- return false;
- }
-
- STDMETHODIMP SetVideoAngle(Vector v, bool fRepaint = true);
- STDMETHODIMP SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget) {
- return E_NOTIMPL;
- }
- STDMETHODIMP SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace) {
- if (!bScreenSpace) {
- return SetPixelShader(pSrcData, pTarget);
- }
- return E_NOTIMPL;
- }
+ CSubPicAllocatorPresenterImpl(HWND hWnd, HRESULT& hr, CString* _pError);
+ virtual ~CSubPicAllocatorPresenterImpl();
+
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ // ISubPicAllocatorPresenter
+
+ STDMETHODIMP CreateRenderer(IUnknown** ppRenderer) = 0;
+
+ STDMETHODIMP_(SIZE) GetVideoSize(bool fCorrectAR = true);
+ STDMETHODIMP_(SIZE) GetVisibleVideoSize() {
+ return m_NativeVideoSize;
+ };
+ STDMETHODIMP_(void) SetPosition(RECT w, RECT v);
+ STDMETHODIMP_(bool) Paint(bool fAll) = 0;
+
+ STDMETHODIMP_(void) SetTime(REFERENCE_TIME rtNow);
+ STDMETHODIMP_(void) SetSubtitleDelay(int delay_ms);
+ STDMETHODIMP_(int) GetSubtitleDelay();
+ STDMETHODIMP_(double) GetFPS();
+
+ STDMETHODIMP_(void) SetSubPicProvider(ISubPicProvider* pSubPicProvider);
+ STDMETHODIMP_(void) Invalidate(REFERENCE_TIME rtInvalidate = -1);
+
+ STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size) {
+ return E_NOTIMPL;
+ }
+
+ STDMETHODIMP_(bool) ResetDevice() {
+ return false;
+ }
+
+ STDMETHODIMP_(bool) DisplayChange() {
+ return false;
+ }
+
+ STDMETHODIMP SetVideoAngle(Vector v, bool fRepaint = true);
+ STDMETHODIMP SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace) {
+ if (!bScreenSpace) {
+ return SetPixelShader(pSrcData, pTarget);
+ }
+ return E_NOTIMPL;
+ }
};
diff --git a/src/SubPic/SubPicImpl.cpp b/src/SubPic/SubPicImpl.cpp
index 30ca96ff0..0ba293c6a 100644
--- a/src/SubPic/SubPicImpl.cpp
+++ b/src/SubPic/SubPicImpl.cpp
@@ -30,160 +30,160 @@
//
CSubPicImpl::CSubPicImpl()
- : CUnknown(NAME("CSubPicImpl"), NULL)
- , m_rtStart(0), m_rtStop(0)
- , m_rtSegmentStart(0), m_rtSegmentStop(0)
- , m_rcDirty(0, 0, 0, 0), m_maxsize(0, 0), m_size(0, 0), m_vidrect(0, 0, 0, 0)
- , m_VirtualTextureSize(0, 0), m_VirtualTextureTopLeft (0, 0)
+ : CUnknown(NAME("CSubPicImpl"), NULL)
+ , m_rtStart(0), m_rtStop(0)
+ , m_rtSegmentStart(0), m_rtSegmentStop(0)
+ , m_rcDirty(0, 0, 0, 0), m_maxsize(0, 0), m_size(0, 0), m_vidrect(0, 0, 0, 0)
+ , m_VirtualTextureSize(0, 0), m_VirtualTextureTopLeft(0, 0)
{
}
STDMETHODIMP CSubPicImpl::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- return
- QI(ISubPic)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(ISubPic)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// ISubPic
STDMETHODIMP_(REFERENCE_TIME) CSubPicImpl::GetStart()
{
- return m_rtStart;
+ return m_rtStart;
}
STDMETHODIMP_(REFERENCE_TIME) CSubPicImpl::GetStop()
{
- return m_rtStop;
+ return m_rtStop;
}
STDMETHODIMP_(REFERENCE_TIME) CSubPicImpl::GetSegmentStart()
{
- if (m_rtSegmentStart) {
- return m_rtSegmentStart;
- }
- return m_rtStart;
+ if (m_rtSegmentStart) {
+ return m_rtSegmentStart;
+ }
+ return m_rtStart;
}
STDMETHODIMP_(REFERENCE_TIME) CSubPicImpl::GetSegmentStop()
{
- if (m_rtSegmentStop) {
- return m_rtSegmentStop;
- }
- return m_rtStop;
+ if (m_rtSegmentStop) {
+ return m_rtSegmentStop;
+ }
+ return m_rtStop;
}
STDMETHODIMP_(void) CSubPicImpl::SetSegmentStart(REFERENCE_TIME rtStart)
{
- m_rtSegmentStart = rtStart;
+ m_rtSegmentStart = rtStart;
}
STDMETHODIMP_(void) CSubPicImpl::SetSegmentStop(REFERENCE_TIME rtStop)
{
- m_rtSegmentStop = rtStop;
+ m_rtSegmentStop = rtStop;
}
STDMETHODIMP_(void) CSubPicImpl::SetStart(REFERENCE_TIME rtStart)
{
- m_rtStart = rtStart;
+ m_rtStart = rtStart;
}
STDMETHODIMP_(void) CSubPicImpl::SetStop(REFERENCE_TIME rtStop)
{
- m_rtStop = rtStop;
+ m_rtStop = rtStop;
}
STDMETHODIMP CSubPicImpl::CopyTo(ISubPic* pSubPic)
{
- if (!pSubPic) {
- return E_POINTER;
- }
-
- pSubPic->SetStart(m_rtStart);
- pSubPic->SetStop(m_rtStop);
- pSubPic->SetSegmentStart(m_rtSegmentStart);
- pSubPic->SetSegmentStop(m_rtSegmentStop);
- pSubPic->SetDirtyRect(m_rcDirty);
- pSubPic->SetSize(m_size, m_vidrect);
- pSubPic->SetVirtualTextureSize(m_VirtualTextureSize, m_VirtualTextureTopLeft);
-
- return S_OK;
+ if (!pSubPic) {
+ return E_POINTER;
+ }
+
+ pSubPic->SetStart(m_rtStart);
+ pSubPic->SetStop(m_rtStop);
+ pSubPic->SetSegmentStart(m_rtSegmentStart);
+ pSubPic->SetSegmentStop(m_rtSegmentStop);
+ pSubPic->SetDirtyRect(m_rcDirty);
+ pSubPic->SetSize(m_size, m_vidrect);
+ pSubPic->SetVirtualTextureSize(m_VirtualTextureSize, m_VirtualTextureTopLeft);
+
+ return S_OK;
}
STDMETHODIMP CSubPicImpl::GetDirtyRect(RECT* pDirtyRect)
{
- return pDirtyRect ? *pDirtyRect = m_rcDirty, S_OK : E_POINTER;
+ return pDirtyRect ? *pDirtyRect = m_rcDirty, S_OK : E_POINTER;
}
STDMETHODIMP CSubPicImpl::GetSourceAndDest(SIZE* pSize, RECT* pRcSource, RECT* pRcDest)
{
- CheckPointer (pRcSource, E_POINTER);
- CheckPointer (pRcDest, E_POINTER);
+ CheckPointer(pRcSource, E_POINTER);
+ CheckPointer(pRcDest, E_POINTER);
- if (m_size.cx > 0 && m_size.cy > 0) {
- CRect rcTemp = m_rcDirty;
+ if (m_size.cx > 0 && m_size.cy > 0) {
+ CRect rcTemp = m_rcDirty;
- // FIXME
- rcTemp.DeflateRect(1, 1);
+ // FIXME
+ rcTemp.DeflateRect(1, 1);
- *pRcSource = rcTemp;
+ *pRcSource = rcTemp;
- rcTemp.OffsetRect (m_VirtualTextureTopLeft);
- *pRcDest = CRect (rcTemp.left * pSize->cx / m_VirtualTextureSize.cx,
- rcTemp.top * pSize->cy / m_VirtualTextureSize.cy,
- rcTemp.right * pSize->cx / m_VirtualTextureSize.cx,
- rcTemp.bottom * pSize->cy / m_VirtualTextureSize.cy);
+ rcTemp.OffsetRect(m_VirtualTextureTopLeft);
+ *pRcDest = CRect(rcTemp.left * pSize->cx / m_VirtualTextureSize.cx,
+ rcTemp.top * pSize->cy / m_VirtualTextureSize.cy,
+ rcTemp.right * pSize->cx / m_VirtualTextureSize.cx,
+ rcTemp.bottom * pSize->cy / m_VirtualTextureSize.cy);
- return S_OK;
- } else {
- return E_INVALIDARG;
- }
+ return S_OK;
+ } else {
+ return E_INVALIDARG;
+ }
}
STDMETHODIMP CSubPicImpl::SetDirtyRect(RECT* pDirtyRect)
{
- return pDirtyRect ? m_rcDirty = *pDirtyRect, S_OK : E_POINTER;
+ return pDirtyRect ? m_rcDirty = *pDirtyRect, S_OK : E_POINTER;
}
STDMETHODIMP CSubPicImpl::GetMaxSize(SIZE* pMaxSize)
{
- return pMaxSize ? *pMaxSize = m_maxsize, S_OK : E_POINTER;
+ return pMaxSize ? *pMaxSize = m_maxsize, S_OK : E_POINTER;
}
STDMETHODIMP CSubPicImpl::SetSize(SIZE size, RECT vidrect)
{
- m_size = size;
- m_vidrect = vidrect;
-
- if (m_size.cx > m_maxsize.cx) {
- m_size.cy = MulDiv(m_size.cy, m_maxsize.cx, m_size.cx);
- m_size.cx = m_maxsize.cx;
- }
-
- if (m_size.cy > m_maxsize.cy) {
- m_size.cx = MulDiv(m_size.cx, m_maxsize.cy, m_size.cy);
- m_size.cy = m_maxsize.cy;
- }
-
- if (m_size.cx != size.cx || m_size.cy != size.cy) {
- m_vidrect.top = MulDiv(m_vidrect.top, m_size.cx, size.cx);
- m_vidrect.bottom = MulDiv(m_vidrect.bottom, m_size.cx, size.cx);
- m_vidrect.left = MulDiv(m_vidrect.left, m_size.cy, size.cy);
- m_vidrect.right = MulDiv(m_vidrect.right, m_size.cy, size.cy);
- }
- m_VirtualTextureSize = m_size;
-
- return S_OK;
+ m_size = size;
+ m_vidrect = vidrect;
+
+ if (m_size.cx > m_maxsize.cx) {
+ m_size.cy = MulDiv(m_size.cy, m_maxsize.cx, m_size.cx);
+ m_size.cx = m_maxsize.cx;
+ }
+
+ if (m_size.cy > m_maxsize.cy) {
+ m_size.cx = MulDiv(m_size.cx, m_maxsize.cy, m_size.cy);
+ m_size.cy = m_maxsize.cy;
+ }
+
+ if (m_size.cx != size.cx || m_size.cy != size.cy) {
+ m_vidrect.top = MulDiv(m_vidrect.top, m_size.cx, size.cx);
+ m_vidrect.bottom = MulDiv(m_vidrect.bottom, m_size.cx, size.cx);
+ m_vidrect.left = MulDiv(m_vidrect.left, m_size.cy, size.cy);
+ m_vidrect.right = MulDiv(m_vidrect.right, m_size.cy, size.cy);
+ }
+ m_VirtualTextureSize = m_size;
+
+ return S_OK;
}
-STDMETHODIMP CSubPicImpl::SetVirtualTextureSize (const SIZE pSize, const POINT pTopLeft)
+STDMETHODIMP CSubPicImpl::SetVirtualTextureSize(const SIZE pSize, const POINT pTopLeft)
{
- m_VirtualTextureSize.SetSize (pSize.cx, pSize.cy);
- m_VirtualTextureTopLeft.SetPoint (pTopLeft.x, pTopLeft.y);
+ m_VirtualTextureSize.SetSize(pSize.cx, pSize.cy);
+ m_VirtualTextureTopLeft.SetPoint(pTopLeft.x, pTopLeft.y);
- return S_OK;
+ return S_OK;
}
//
@@ -191,76 +191,76 @@ STDMETHODIMP CSubPicImpl::SetVirtualTextureSize (const SIZE pSize, const POINT p
//
CSubPicAllocatorImpl::CSubPicAllocatorImpl(SIZE cursize, bool fDynamicWriteOnly, bool fPow2Textures)
- : CUnknown(NAME("ISubPicAllocatorImpl"), NULL)
- , m_cursize(cursize)
- , m_fDynamicWriteOnly(fDynamicWriteOnly)
- , m_fPow2Textures(fPow2Textures)
+ : CUnknown(NAME("ISubPicAllocatorImpl"), NULL)
+ , m_cursize(cursize)
+ , m_fDynamicWriteOnly(fDynamicWriteOnly)
+ , m_fPow2Textures(fPow2Textures)
{
- m_curvidrect = CRect(CPoint(0,0), m_cursize);
+ m_curvidrect = CRect(CPoint(0, 0), m_cursize);
}
STDMETHODIMP CSubPicAllocatorImpl::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- return
- QI(ISubPicAllocator)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(ISubPicAllocator)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// ISubPicAllocator
STDMETHODIMP CSubPicAllocatorImpl::SetCurSize(SIZE cursize)
{
- m_cursize = cursize;
- return S_OK;
+ m_cursize = cursize;
+ return S_OK;
}
STDMETHODIMP CSubPicAllocatorImpl::SetCurVidRect(RECT curvidrect)
{
- m_curvidrect = curvidrect;
- return S_OK;
+ m_curvidrect = curvidrect;
+ return S_OK;
}
STDMETHODIMP CSubPicAllocatorImpl::GetStatic(ISubPic** ppSubPic)
{
- if (!ppSubPic) {
- return E_POINTER;
- }
+ if (!ppSubPic) {
+ return E_POINTER;
+ }
- if (!m_pStatic) {
- if (!Alloc(true, &m_pStatic) || !m_pStatic) {
- return E_OUTOFMEMORY;
- }
- }
+ if (!m_pStatic) {
+ if (!Alloc(true, &m_pStatic) || !m_pStatic) {
+ return E_OUTOFMEMORY;
+ }
+ }
- m_pStatic->SetSize(m_cursize, m_curvidrect);
+ m_pStatic->SetSize(m_cursize, m_curvidrect);
- (*ppSubPic = m_pStatic)->AddRef();
+ (*ppSubPic = m_pStatic)->AddRef();
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CSubPicAllocatorImpl::AllocDynamic(ISubPic** ppSubPic)
{
- if (!ppSubPic) {
- return E_POINTER;
- }
+ if (!ppSubPic) {
+ return E_POINTER;
+ }
- if (!Alloc(false, ppSubPic) || !*ppSubPic) {
- return E_OUTOFMEMORY;
- }
+ if (!Alloc(false, ppSubPic) || !*ppSubPic) {
+ return E_OUTOFMEMORY;
+ }
- (*ppSubPic)->SetSize(m_cursize, m_curvidrect);
+ (*ppSubPic)->SetSize(m_cursize, m_curvidrect);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP_(bool) CSubPicAllocatorImpl::IsDynamicWriteOnly()
{
- return m_fDynamicWriteOnly;
+ return m_fDynamicWriteOnly;
}
STDMETHODIMP CSubPicAllocatorImpl::ChangeDevice(IUnknown* pDev)
{
- m_pStatic = NULL;
- return S_OK;
+ m_pStatic = NULL;
+ return S_OK;
}
diff --git a/src/SubPic/SubPicImpl.h b/src/SubPic/SubPicImpl.h
index ae8ea3bbd..fd976fc57 100644
--- a/src/SubPic/SubPicImpl.h
+++ b/src/SubPic/SubPicImpl.h
@@ -28,114 +28,114 @@
class CSubPicImpl : public CUnknown, public ISubPic
{
protected:
- REFERENCE_TIME m_rtStart, m_rtStop;
- REFERENCE_TIME m_rtSegmentStart, m_rtSegmentStop;
- CRect m_rcDirty;
- CSize m_maxsize;
- CSize m_size;
- CRect m_vidrect;
- CSize m_VirtualTextureSize;
- CPoint m_VirtualTextureTopLeft;
-
- /*
-
- Texture
- +-------+---------------------------------+
- | . | .
- | . m_maxsize | .
- TextureTopLeft .<=============================== |======> . Video
- | . . . +-------------------------------- | -----+ +-----------------------------------+
- | | . | | | m_vidrect |
- | | . | | | |
- | | . | | | |
- | | +-----------+ . | | | |
- | | | m_rcDirty | . | | | |
- | | | | . | | | |
- | | +-----------+ . | | | |
- | +-------------------------------- | -----+ | |
- | m_size | | |
- | <=========================> | | |
- | | | |
- | | +-----------------------------------+
- | | .
- | | .
- | | .
- +-----------------------------------------+
- m_VirtualTextureSize
- <=========================================>
-
- */
+ REFERENCE_TIME m_rtStart, m_rtStop;
+ REFERENCE_TIME m_rtSegmentStart, m_rtSegmentStop;
+ CRect m_rcDirty;
+ CSize m_maxsize;
+ CSize m_size;
+ CRect m_vidrect;
+ CSize m_VirtualTextureSize;
+ CPoint m_VirtualTextureTopLeft;
+
+ /*
+
+ Texture
+ +-------+---------------------------------+
+ | . | .
+ | . m_maxsize | .
+ TextureTopLeft .<=============================== |======> . Video
+ | . . . +-------------------------------- | -----+ +-----------------------------------+
+ | | . | | | m_vidrect |
+ | | . | | | |
+ | | . | | | |
+ | | +-----------+ . | | | |
+ | | | m_rcDirty | . | | | |
+ | | | | . | | | |
+ | | +-----------+ . | | | |
+ | +-------------------------------- | -----+ | |
+ | m_size | | |
+ | <=========================> | | |
+ | | | |
+ | | +-----------------------------------+
+ | | .
+ | | .
+ | | .
+ +-----------------------------------------+
+ m_VirtualTextureSize
+ <=========================================>
+
+ */
public:
- CSubPicImpl();
+ CSubPicImpl();
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // ISubPic
+ // ISubPic
- STDMETHODIMP_(REFERENCE_TIME) GetStart();
- STDMETHODIMP_(REFERENCE_TIME) GetStop();
- STDMETHODIMP_(void) SetStart(REFERENCE_TIME rtStart);
- STDMETHODIMP_(void) SetStop(REFERENCE_TIME rtStop);
+ STDMETHODIMP_(REFERENCE_TIME) GetStart();
+ STDMETHODIMP_(REFERENCE_TIME) GetStop();
+ STDMETHODIMP_(void) SetStart(REFERENCE_TIME rtStart);
+ STDMETHODIMP_(void) SetStop(REFERENCE_TIME rtStop);
- STDMETHODIMP GetDesc(SubPicDesc& spd) = 0;
- STDMETHODIMP CopyTo(ISubPic* pSubPic);
+ STDMETHODIMP GetDesc(SubPicDesc& spd) = 0;
+ STDMETHODIMP CopyTo(ISubPic* pSubPic);
- STDMETHODIMP ClearDirtyRect(DWORD color) = 0;
- STDMETHODIMP GetDirtyRect(RECT* pDirtyRect);
- STDMETHODIMP SetDirtyRect(RECT* pDirtyRect);
+ STDMETHODIMP ClearDirtyRect(DWORD color) = 0;
+ STDMETHODIMP GetDirtyRect(RECT* pDirtyRect);
+ STDMETHODIMP SetDirtyRect(RECT* pDirtyRect);
- STDMETHODIMP GetMaxSize(SIZE* pMaxSize);
- STDMETHODIMP SetSize(SIZE size, RECT vidrect);
+ STDMETHODIMP GetMaxSize(SIZE* pMaxSize);
+ STDMETHODIMP SetSize(SIZE size, RECT vidrect);
- STDMETHODIMP Lock(SubPicDesc& spd) = 0;
- STDMETHODIMP Unlock(RECT* pDirtyRect) = 0;
+ STDMETHODIMP Lock(SubPicDesc& spd) = 0;
+ STDMETHODIMP Unlock(RECT* pDirtyRect) = 0;
- STDMETHODIMP AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) = 0;
+ STDMETHODIMP AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) = 0;
- STDMETHODIMP SetVirtualTextureSize (const SIZE pSize, const POINT pTopLeft);
- STDMETHODIMP GetSourceAndDest(SIZE* pSize, RECT* pRcSource, RECT* pRcDest);
+ STDMETHODIMP SetVirtualTextureSize(const SIZE pSize, const POINT pTopLeft);
+ STDMETHODIMP GetSourceAndDest(SIZE* pSize, RECT* pRcSource, RECT* pRcDest);
- STDMETHODIMP_(REFERENCE_TIME) GetSegmentStart();
- STDMETHODIMP_(REFERENCE_TIME) GetSegmentStop();
- STDMETHODIMP_(void) SetSegmentStart(REFERENCE_TIME rtStart);
- STDMETHODIMP_(void) SetSegmentStop(REFERENCE_TIME rtStop);
+ STDMETHODIMP_(REFERENCE_TIME) GetSegmentStart();
+ STDMETHODIMP_(REFERENCE_TIME) GetSegmentStop();
+ STDMETHODIMP_(void) SetSegmentStart(REFERENCE_TIME rtStart);
+ STDMETHODIMP_(void) SetSegmentStop(REFERENCE_TIME rtStop);
};
class CSubPicAllocatorImpl : public CUnknown, public ISubPicAllocator
{
- CComPtr<ISubPic> m_pStatic;
+ CComPtr<ISubPic> m_pStatic;
private:
- CSize m_cursize;
- CRect m_curvidrect;
- bool m_fDynamicWriteOnly;
+ CSize m_cursize;
+ CRect m_curvidrect;
+ bool m_fDynamicWriteOnly;
- virtual bool Alloc(bool fStatic, ISubPic** ppSubPic) = 0;
+ virtual bool Alloc(bool fStatic, ISubPic** ppSubPic) = 0;
protected:
- bool m_fPow2Textures;
+ bool m_fPow2Textures;
public:
- CSubPicAllocatorImpl(SIZE cursize, bool fDynamicWriteOnly, bool fPow2Textures);
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // ISubPicAllocator
-
- STDMETHODIMP SetCurSize(SIZE cursize);
- STDMETHODIMP SetCurVidRect(RECT curvidrect);
- STDMETHODIMP GetStatic(ISubPic** ppSubPic);
- STDMETHODIMP AllocDynamic(ISubPic** ppSubPic);
- STDMETHODIMP_(bool) IsDynamicWriteOnly();
- STDMETHODIMP ChangeDevice(IUnknown* pDev);
- STDMETHODIMP SetMaxTextureSize(SIZE MaxTextureSize) {
- return E_NOTIMPL;
- };
+ CSubPicAllocatorImpl(SIZE cursize, bool fDynamicWriteOnly, bool fPow2Textures);
+
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ // ISubPicAllocator
+
+ STDMETHODIMP SetCurSize(SIZE cursize);
+ STDMETHODIMP SetCurVidRect(RECT curvidrect);
+ STDMETHODIMP GetStatic(ISubPic** ppSubPic);
+ STDMETHODIMP AllocDynamic(ISubPic** ppSubPic);
+ STDMETHODIMP_(bool) IsDynamicWriteOnly();
+ STDMETHODIMP ChangeDevice(IUnknown* pDev);
+ STDMETHODIMP SetMaxTextureSize(SIZE MaxTextureSize) {
+ return E_NOTIMPL;
+ };
};
diff --git a/src/SubPic/SubPicProviderImpl.cpp b/src/SubPic/SubPicProviderImpl.cpp
index 81e62f93f..2af04d485 100644
--- a/src/SubPic/SubPicProviderImpl.cpp
+++ b/src/SubPic/SubPicProviderImpl.cpp
@@ -26,8 +26,8 @@
#include "../DSUtil/DSUtil.h"
CSubPicProviderImpl::CSubPicProviderImpl(CCritSec* pLock)
- : CUnknown(NAME("CSubPicProviderImpl"), NULL)
- , m_pLock(pLock)
+ : CUnknown(NAME("CSubPicProviderImpl"), NULL)
+ , m_pLock(pLock)
{
}
@@ -37,19 +37,19 @@ CSubPicProviderImpl::~CSubPicProviderImpl()
STDMETHODIMP CSubPicProviderImpl::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- return
- QI(ISubPicProvider)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(ISubPicProvider)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// CSubPicProviderImpl
STDMETHODIMP CSubPicProviderImpl::Lock()
{
- return m_pLock ? m_pLock->Lock(), S_OK : E_FAIL;
+ return m_pLock ? m_pLock->Lock(), S_OK : E_FAIL;
}
STDMETHODIMP CSubPicProviderImpl::Unlock()
{
- return m_pLock ? m_pLock->Unlock(), S_OK : E_FAIL;
+ return m_pLock ? m_pLock->Unlock(), S_OK : E_FAIL;
}
diff --git a/src/SubPic/SubPicProviderImpl.h b/src/SubPic/SubPicProviderImpl.h
index a9fc30b34..99fb7dfb6 100644
--- a/src/SubPic/SubPicProviderImpl.h
+++ b/src/SubPic/SubPicProviderImpl.h
@@ -28,29 +28,29 @@
class CSubPicProviderImpl : public CUnknown, public ISubPicProvider
{
protected:
- CCritSec* m_pLock;
+ CCritSec* m_pLock;
public:
- CSubPicProviderImpl(CCritSec* pLock);
- virtual ~CSubPicProviderImpl();
+ CSubPicProviderImpl(CCritSec* pLock);
+ virtual ~CSubPicProviderImpl();
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // ISubPicProvider
+ // ISubPicProvider
- STDMETHODIMP Lock();
- STDMETHODIMP Unlock();
+ STDMETHODIMP Lock();
+ STDMETHODIMP Unlock();
- STDMETHODIMP_(POSITION) GetStartPosition(REFERENCE_TIME rt, double fps) = 0;
- STDMETHODIMP_(POSITION) GetNext(POSITION pos) = 0;
+ STDMETHODIMP_(POSITION) GetStartPosition(REFERENCE_TIME rt, double fps) = 0;
+ STDMETHODIMP_(POSITION) GetNext(POSITION pos) = 0;
- STDMETHODIMP_(REFERENCE_TIME) GetStart(POSITION pos, double fps) = 0;
- STDMETHODIMP_(REFERENCE_TIME) GetStop(POSITION pos, double fps) = 0;
+ STDMETHODIMP_(REFERENCE_TIME) GetStart(POSITION pos, double fps) = 0;
+ STDMETHODIMP_(REFERENCE_TIME) GetStop(POSITION pos, double fps) = 0;
- STDMETHODIMP Render(SubPicDesc& spd, REFERENCE_TIME rt, double fps, RECT& bbox) = 0;
- STDMETHODIMP GetTextureSize (POSITION pos, SIZE& MaxTextureSize, SIZE& VirtualSize, POINT& VirtualTopLeft) {
- return E_NOTIMPL;
- };
+ STDMETHODIMP Render(SubPicDesc& spd, REFERENCE_TIME rt, double fps, RECT& bbox) = 0;
+ STDMETHODIMP GetTextureSize(POSITION pos, SIZE& MaxTextureSize, SIZE& VirtualSize, POINT& VirtualTopLeft) {
+ return E_NOTIMPL;
+ };
};
diff --git a/src/SubPic/SubPicQueueImpl.cpp b/src/SubPic/SubPicQueueImpl.cpp
index f4ccb82a4..ec323787d 100644
--- a/src/SubPic/SubPicQueueImpl.cpp
+++ b/src/SubPic/SubPicQueueImpl.cpp
@@ -30,22 +30,22 @@
//
CSubPicQueueImpl::CSubPicQueueImpl(ISubPicAllocator* pAllocator, HRESULT* phr)
- : CUnknown(NAME("CSubPicQueueImpl"), NULL)
- , m_pAllocator(pAllocator)
- , m_rtNow(0)
- , m_rtNowLast(0)
- , m_fps(25.0)
+ : CUnknown(NAME("CSubPicQueueImpl"), NULL)
+ , m_pAllocator(pAllocator)
+ , m_rtNow(0)
+ , m_rtNowLast(0)
+ , m_fps(25.0)
{
- if (phr) {
- *phr = S_OK;
- }
-
- if (!m_pAllocator) {
- if (phr) {
- *phr = E_FAIL;
- }
- return;
- }
+ if (phr) {
+ *phr = S_OK;
+ }
+
+ if (!m_pAllocator) {
+ if (phr) {
+ *phr = E_FAIL;
+ }
+ return;
+ }
}
CSubPicQueueImpl::~CSubPicQueueImpl()
@@ -54,88 +54,88 @@ CSubPicQueueImpl::~CSubPicQueueImpl()
STDMETHODIMP CSubPicQueueImpl::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- return
- QI(ISubPicQueue)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(ISubPicQueue)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// ISubPicQueue
STDMETHODIMP CSubPicQueueImpl::SetSubPicProvider(ISubPicProvider* pSubPicProvider)
{
- CAutoLock cAutoLock(&m_csSubPicProvider);
+ CAutoLock cAutoLock(&m_csSubPicProvider);
- // if (m_pSubPicProvider != pSubPicProvider)
- {
- m_pSubPicProvider = pSubPicProvider;
+ // if (m_pSubPicProvider != pSubPicProvider)
+ {
+ m_pSubPicProvider = pSubPicProvider;
- Invalidate();
- }
+ Invalidate();
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CSubPicQueueImpl::GetSubPicProvider(ISubPicProvider** pSubPicProvider)
{
- if (!pSubPicProvider) {
- return E_POINTER;
- }
+ if (!pSubPicProvider) {
+ return E_POINTER;
+ }
- CAutoLock cAutoLock(&m_csSubPicProvider);
+ CAutoLock cAutoLock(&m_csSubPicProvider);
- if (m_pSubPicProvider) {
- *pSubPicProvider = m_pSubPicProvider;
- (*pSubPicProvider)->AddRef();
- }
+ if (m_pSubPicProvider) {
+ *pSubPicProvider = m_pSubPicProvider;
+ (*pSubPicProvider)->AddRef();
+ }
- return !!*pSubPicProvider ? S_OK : E_FAIL;
+ return !!*pSubPicProvider ? S_OK : E_FAIL;
}
STDMETHODIMP CSubPicQueueImpl::SetFPS(double fps)
{
- m_fps = fps;
+ m_fps = fps;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CSubPicQueueImpl::SetTime(REFERENCE_TIME rtNow)
{
- m_rtNow = rtNow;
+ m_rtNow = rtNow;
- return S_OK;
+ return S_OK;
}
// private
HRESULT CSubPicQueueImpl::RenderTo(ISubPic* pSubPic, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, double fps, BOOL bIsAnimated)
{
- HRESULT hr = E_FAIL;
+ HRESULT hr = E_FAIL;
- if (!pSubPic) {
- return hr;
- }
+ if (!pSubPic) {
+ return hr;
+ }
- CComPtr<ISubPicProvider> pSubPicProvider;
- if (FAILED(GetSubPicProvider(&pSubPicProvider)) || !pSubPicProvider) {
- return hr;
- }
+ CComPtr<ISubPicProvider> pSubPicProvider;
+ if (FAILED(GetSubPicProvider(&pSubPicProvider)) || !pSubPicProvider) {
+ return hr;
+ }
- SubPicDesc spd;
- hr = pSubPic->ClearDirtyRect(0xFF000000);
- if (SUCCEEDED(hr)) {
- hr = pSubPic->Lock(spd);
- }
- if (SUCCEEDED(hr)) {
- CRect r(0,0,0,0);
- hr = pSubPicProvider->Render(spd, bIsAnimated ? rtStart : ((rtStart+rtStop)/2), fps, r);
+ SubPicDesc spd;
+ hr = pSubPic->ClearDirtyRect(0xFF000000);
+ if (SUCCEEDED(hr)) {
+ hr = pSubPic->Lock(spd);
+ }
+ if (SUCCEEDED(hr)) {
+ CRect r(0, 0, 0, 0);
+ hr = pSubPicProvider->Render(spd, bIsAnimated ? rtStart : ((rtStart + rtStop) / 2), fps, r);
- pSubPic->SetStart(rtStart);
- pSubPic->SetStop(rtStop);
+ pSubPic->SetStart(rtStart);
+ pSubPic->SetStop(rtStop);
- pSubPic->Unlock(r);
- }
+ pSubPic->Unlock(r);
+ }
- return hr;
+ return hr;
}
//
@@ -143,421 +143,421 @@ HRESULT CSubPicQueueImpl::RenderTo(ISubPic* pSubPic, REFERENCE_TIME rtStart, REF
//
CSubPicQueue::CSubPicQueue(int nMaxSubPic, BOOL bDisableAnim, ISubPicAllocator* pAllocator, HRESULT* phr)
- : CSubPicQueueImpl(pAllocator, phr)
- , m_nMaxSubPic(nMaxSubPic)
- , m_bDisableAnim(bDisableAnim)
- ,m_rtQueueMin(0)
- ,m_rtQueueMax(0)
+ : CSubPicQueueImpl(pAllocator, phr)
+ , m_nMaxSubPic(nMaxSubPic)
+ , m_bDisableAnim(bDisableAnim)
+ , m_rtQueueMin(0)
+ , m_rtQueueMax(0)
{
- if (phr && FAILED(*phr)) {
- return;
- }
-
- if (m_nMaxSubPic < 1) {
- if (phr) {
- *phr = E_INVALIDARG;
- }
- return;
- }
-
- m_fBreakBuffering = false;
- for (ptrdiff_t i = 0; i < EVENT_COUNT; i++) {
- m_ThreadEvents[i] = CreateEvent(NULL, FALSE, FALSE, NULL);
- }
- CAMThread::Create();
+ if (phr && FAILED(*phr)) {
+ return;
+ }
+
+ if (m_nMaxSubPic < 1) {
+ if (phr) {
+ *phr = E_INVALIDARG;
+ }
+ return;
+ }
+
+ m_fBreakBuffering = false;
+ for (ptrdiff_t i = 0; i < EVENT_COUNT; i++) {
+ m_ThreadEvents[i] = CreateEvent(NULL, FALSE, FALSE, NULL);
+ }
+ CAMThread::Create();
}
CSubPicQueue::~CSubPicQueue()
{
- m_fBreakBuffering = true;
- SetEvent(m_ThreadEvents[EVENT_EXIT]);
- CAMThread::Close();
- for (ptrdiff_t i = 0; i < EVENT_COUNT; i++) {
- CloseHandle(m_ThreadEvents[i]);
- }
+ m_fBreakBuffering = true;
+ SetEvent(m_ThreadEvents[EVENT_EXIT]);
+ CAMThread::Close();
+ for (ptrdiff_t i = 0; i < EVENT_COUNT; i++) {
+ CloseHandle(m_ThreadEvents[i]);
+ }
}
// ISubPicQueue
STDMETHODIMP CSubPicQueue::SetFPS(double fps)
{
- HRESULT hr = __super::SetFPS(fps);
- if (FAILED(hr)) {
- return hr;
- }
+ HRESULT hr = __super::SetFPS(fps);
+ if (FAILED(hr)) {
+ return hr;
+ }
- SetEvent(m_ThreadEvents[EVENT_TIME]);
+ SetEvent(m_ThreadEvents[EVENT_TIME]);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CSubPicQueue::SetTime(REFERENCE_TIME rtNow)
{
- HRESULT hr = __super::SetTime(rtNow);
- if (FAILED(hr)) {
- return hr;
- }
+ HRESULT hr = __super::SetTime(rtNow);
+ if (FAILED(hr)) {
+ return hr;
+ }
- SetEvent(m_ThreadEvents[EVENT_TIME]);
+ SetEvent(m_ThreadEvents[EVENT_TIME]);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CSubPicQueue::Invalidate(REFERENCE_TIME rtInvalidate)
{
- {
- // CAutoLock cQueueLock(&m_csQueueLock);
- // RemoveAll();
+ {
+ // CAutoLock cQueueLock(&m_csQueueLock);
+ // RemoveAll();
- m_rtInvalidate = rtInvalidate;
- m_fBreakBuffering = true;
+ m_rtInvalidate = rtInvalidate;
+ m_fBreakBuffering = true;
#if DSubPicTraceLevel > 0
- TRACE(_T("Invalidate: %f\n"), double(rtInvalidate) / 10000000.0);
+ TRACE(_T("Invalidate: %f\n"), double(rtInvalidate) / 10000000.0);
#endif
- SetEvent(m_ThreadEvents[EVENT_TIME]);
- }
+ SetEvent(m_ThreadEvents[EVENT_TIME]);
+ }
- return S_OK;
+ return S_OK;
}
-STDMETHODIMP_(bool) CSubPicQueue::LookupSubPic(REFERENCE_TIME rtNow, CComPtr<ISubPic> &ppSubPic)
+STDMETHODIMP_(bool) CSubPicQueue::LookupSubPic(REFERENCE_TIME rtNow, CComPtr<ISubPic>& ppSubPic)
{
- CAutoLock cQueueLock(&m_csQueueLock);
+ CAutoLock cQueueLock(&m_csQueueLock);
- REFERENCE_TIME rtBestStop = 0x7fffffffffffffffi64;
- POSITION pos = m_Queue.GetHeadPosition();
+ REFERENCE_TIME rtBestStop = 0x7fffffffffffffffi64;
+ POSITION pos = m_Queue.GetHeadPosition();
#if DSubPicTraceLevel > 2
- TRACE("Find: ");
+ TRACE("Find: ");
#endif
- while (pos) {
- CComPtr<ISubPic> pSubPic = m_Queue.GetNext(pos);
- REFERENCE_TIME rtStart = pSubPic->GetStart();
- REFERENCE_TIME rtStop = pSubPic->GetStop();
- REFERENCE_TIME rtSegmentStop = pSubPic->GetSegmentStop();
- if (rtNow >= rtStart && rtNow < rtSegmentStop) {
- REFERENCE_TIME Diff = rtNow - rtStop;
- if (Diff < rtBestStop) {
- rtBestStop = Diff;
- // TRACE(" %f->%f", double(Diff) / 10000000.0, double(rtStop) / 10000000.0);
- ppSubPic = pSubPic;
- }
+ while (pos) {
+ CComPtr<ISubPic> pSubPic = m_Queue.GetNext(pos);
+ REFERENCE_TIME rtStart = pSubPic->GetStart();
+ REFERENCE_TIME rtStop = pSubPic->GetStop();
+ REFERENCE_TIME rtSegmentStop = pSubPic->GetSegmentStop();
+ if (rtNow >= rtStart && rtNow < rtSegmentStop) {
+ REFERENCE_TIME Diff = rtNow - rtStop;
+ if (Diff < rtBestStop) {
+ rtBestStop = Diff;
+ // TRACE(" %f->%f", double(Diff) / 10000000.0, double(rtStop) / 10000000.0);
+ ppSubPic = pSubPic;
+ }
#if DSubPicTraceLevel > 2
- else {
- TRACE(" !%f->%f", double(Diff) / 10000000.0, double(rtStop) / 10000000.0);
- }
+ else {
+ TRACE(" !%f->%f", double(Diff) / 10000000.0, double(rtStop) / 10000000.0);
+ }
#endif
- }
+ }
#if DSubPicTraceLevel > 2
- else {
- TRACE(" !!%f->%f", double(rtStart) / 10000000.0, double(rtSegmentStop) / 10000000.0);
- }
+ else {
+ TRACE(" !!%f->%f", double(rtStart) / 10000000.0, double(rtSegmentStop) / 10000000.0);
+ }
#endif
- }
+ }
#if DSubPicTraceLevel > 2
- TRACE("\n");
+ TRACE("\n");
#endif
- if (!ppSubPic) {
+ if (!ppSubPic) {
#if DSubPicTraceLevel > 1
- TRACE("NO Display: %f\n", double(rtNow) / 10000000.0);
+ TRACE("NO Display: %f\n", double(rtNow) / 10000000.0);
#endif
- } else {
+ } else {
#if DSubPicTraceLevel > 0
- REFERENCE_TIME rtStart = (ppSubPic)->GetStart();
- REFERENCE_TIME rtSegmentStop = (ppSubPic)->GetSegmentStop();
- CRect r;
- (ppSubPic)->GetDirtyRect(&r);
- TRACE("Display: %f->%f %f %dx%d\n", double(rtStart) / 10000000.0, double(rtSegmentStop) / 10000000.0, double(rtNow) / 10000000.0, r.Width(), r.Height());
+ REFERENCE_TIME rtStart = (ppSubPic)->GetStart();
+ REFERENCE_TIME rtSegmentStop = (ppSubPic)->GetSegmentStop();
+ CRect r;
+ (ppSubPic)->GetDirtyRect(&r);
+ TRACE("Display: %f->%f %f %dx%d\n", double(rtStart) / 10000000.0, double(rtSegmentStop) / 10000000.0, double(rtNow) / 10000000.0, r.Width(), r.Height());
#endif
- }
+ }
- return !!ppSubPic;
+ return !!ppSubPic;
}
STDMETHODIMP CSubPicQueue::GetStats(int& nSubPics, REFERENCE_TIME& rtNow, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop)
{
- CAutoLock cQueueLock(&m_csQueueLock);
-
- nSubPics = (int)m_Queue.GetCount();
- rtNow = m_rtNow;
- rtStart = m_rtQueueMin;
- if (rtStart == 0x7fffffffffffffffi64) {
- rtStart = 0;
- }
- rtStop = m_rtQueueMax;
- if (rtStop == 0xffffffffffffffffi64) {
- rtStop = 0;
- }
-
- return S_OK;
+ CAutoLock cQueueLock(&m_csQueueLock);
+
+ nSubPics = (int)m_Queue.GetCount();
+ rtNow = m_rtNow;
+ rtStart = m_rtQueueMin;
+ if (rtStart == 0x7fffffffffffffffi64) {
+ rtStart = 0;
+ }
+ rtStop = m_rtQueueMax;
+ if (rtStop == 0xffffffffffffffffi64) {
+ rtStop = 0;
+ }
+
+ return S_OK;
}
STDMETHODIMP CSubPicQueue::GetStats(int nSubPic, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop)
{
- CAutoLock cQueueLock(&m_csQueueLock);
+ CAutoLock cQueueLock(&m_csQueueLock);
- rtStart = rtStop = -1;
+ rtStart = rtStop = -1;
- if (nSubPic >= 0 && nSubPic < (int)m_Queue.GetCount()) {
- if (POSITION pos = m_Queue.FindIndex(nSubPic)) {
- rtStart = m_Queue.GetAt(pos)->GetStart();
- rtStop = m_Queue.GetAt(pos)->GetStop();
- }
- } else {
- return E_INVALIDARG;
- }
+ if (nSubPic >= 0 && nSubPic < (int)m_Queue.GetCount()) {
+ if (POSITION pos = m_Queue.FindIndex(nSubPic)) {
+ rtStart = m_Queue.GetAt(pos)->GetStart();
+ rtStop = m_Queue.GetAt(pos)->GetStop();
+ }
+ } else {
+ return E_INVALIDARG;
+ }
- return S_OK;
+ return S_OK;
}
// private
REFERENCE_TIME CSubPicQueue::UpdateQueue()
{
- CAutoLock cQueueLock(&m_csQueueLock);
-
- REFERENCE_TIME rtNow = m_rtNow;
- REFERENCE_TIME rtNowCompare = rtNow;
-
- if (rtNow < m_rtNowLast) {
- m_Queue.RemoveAll();
- m_rtNowLast = rtNow;
- } else {
- m_rtNowLast = rtNow;
-
- m_rtQueueMin = 0x7fffffffffffffffi64;
- m_rtQueueMax = 0xffffffffffffffffi64;
-
- POSITION SavePos = 0;
- {
- POSITION Iter = m_Queue.GetHeadPosition();
- REFERENCE_TIME rtBestStop = 0x7fffffffffffffffi64;
- while (Iter) {
- POSITION ThisPos = Iter;
- ISubPic *pSubPic = m_Queue.GetNext(Iter);
- REFERENCE_TIME rtStart = pSubPic->GetStart();
- REFERENCE_TIME rtStop = pSubPic->GetStop();
- REFERENCE_TIME rtSegmentStop = pSubPic->GetSegmentStop();
- if (rtNow >= rtStart && rtNow < rtSegmentStop) {
- REFERENCE_TIME Diff = rtNow - rtStop;
- if (Diff < rtBestStop) {
- rtBestStop = Diff;
- SavePos = ThisPos;
- }
- }
- }
- }
+ CAutoLock cQueueLock(&m_csQueueLock);
+
+ REFERENCE_TIME rtNow = m_rtNow;
+ REFERENCE_TIME rtNowCompare = rtNow;
+
+ if (rtNow < m_rtNowLast) {
+ m_Queue.RemoveAll();
+ m_rtNowLast = rtNow;
+ } else {
+ m_rtNowLast = rtNow;
+
+ m_rtQueueMin = 0x7fffffffffffffffi64;
+ m_rtQueueMax = 0xffffffffffffffffi64;
+
+ POSITION SavePos = 0;
+ {
+ POSITION Iter = m_Queue.GetHeadPosition();
+ REFERENCE_TIME rtBestStop = 0x7fffffffffffffffi64;
+ while (Iter) {
+ POSITION ThisPos = Iter;
+ ISubPic* pSubPic = m_Queue.GetNext(Iter);
+ REFERENCE_TIME rtStart = pSubPic->GetStart();
+ REFERENCE_TIME rtStop = pSubPic->GetStop();
+ REFERENCE_TIME rtSegmentStop = pSubPic->GetSegmentStop();
+ if (rtNow >= rtStart && rtNow < rtSegmentStop) {
+ REFERENCE_TIME Diff = rtNow - rtStop;
+ if (Diff < rtBestStop) {
+ rtBestStop = Diff;
+ SavePos = ThisPos;
+ }
+ }
+ }
+ }
#if DSubPicTraceLevel > 3
- if (SavePos) {
- ISubPic *pSubPic = GetAt(SavePos);
- REFERENCE_TIME rtStart = pSubPic->GetStart();
- REFERENCE_TIME rtStop = pSubPic->GetStop();
- TRACE("Save: %f->%f\n", double(rtStart) / 10000000.0, double(rtStop) / 10000000.0);
- }
+ if (SavePos) {
+ ISubPic* pSubPic = GetAt(SavePos);
+ REFERENCE_TIME rtStart = pSubPic->GetStart();
+ REFERENCE_TIME rtStop = pSubPic->GetStop();
+ TRACE("Save: %f->%f\n", double(rtStart) / 10000000.0, double(rtStop) / 10000000.0);
+ }
#endif
- {
- POSITION Iter = m_Queue.GetHeadPosition();
- while (Iter) {
- POSITION ThisPos = Iter;
- ISubPic *pSubPic = m_Queue.GetNext(Iter);
+ {
+ POSITION Iter = m_Queue.GetHeadPosition();
+ while (Iter) {
+ POSITION ThisPos = Iter;
+ ISubPic* pSubPic = m_Queue.GetNext(Iter);
- REFERENCE_TIME rtStart = pSubPic->GetStart();
- REFERENCE_TIME rtStop = pSubPic->GetStop();
+ REFERENCE_TIME rtStart = pSubPic->GetStart();
+ REFERENCE_TIME rtStop = pSubPic->GetStop();
- if (rtStop <= rtNowCompare && ThisPos != SavePos) {
+ if (rtStop <= rtNowCompare && ThisPos != SavePos) {
#if DSubPicTraceLevel > 0
- TRACE("Remove: %f->%f\n", double(rtStart) / 10000000.0, double(rtStop) / 10000000.0);
+ TRACE("Remove: %f->%f\n", double(rtStart) / 10000000.0, double(rtStop) / 10000000.0);
#endif
- m_Queue.RemoveAt(ThisPos);
- continue;
- }
- if (rtStop > rtNow) {
- rtNow = rtStop;
- }
- m_rtQueueMin = min(m_rtQueueMin, rtStart);
- m_rtQueueMax = max(m_rtQueueMax, rtStop);
- }
- }
- }
-
- return rtNow;
+ m_Queue.RemoveAt(ThisPos);
+ continue;
+ }
+ if (rtStop > rtNow) {
+ rtNow = rtStop;
+ }
+ m_rtQueueMin = min(m_rtQueueMin, rtStart);
+ m_rtQueueMax = max(m_rtQueueMax, rtStop);
+ }
+ }
+ }
+
+ return rtNow;
}
int CSubPicQueue::GetQueueCount()
{
- CAutoLock cQueueLock(&m_csQueueLock);
+ CAutoLock cQueueLock(&m_csQueueLock);
- return (int)m_Queue.GetCount();
+ return (int)m_Queue.GetCount();
}
void CSubPicQueue::AppendQueue(ISubPic* pSubPic)
{
- CAutoLock cQueueLock(&m_csQueueLock);
+ CAutoLock cQueueLock(&m_csQueueLock);
- m_Queue.AddTail(pSubPic);
+ m_Queue.AddTail(pSubPic);
}
// overrides
DWORD CSubPicQueue::ThreadProc()
{
- BOOL bDisableAnim = m_bDisableAnim;
- SetThreadPriority(m_hThread, bDisableAnim ? THREAD_PRIORITY_LOWEST : THREAD_PRIORITY_ABOVE_NORMAL/*THREAD_PRIORITY_BELOW_NORMAL*/);
-
- bool bAgain = true;
- for (;;) {
- DWORD Ret = WaitForMultipleObjects(EVENT_COUNT, m_ThreadEvents, FALSE, bAgain ? 0 : INFINITE);
- bAgain = false;
-
- if (Ret == WAIT_TIMEOUT) {
- ;
- } else if ((Ret - WAIT_OBJECT_0) != EVENT_TIME) {
- break;
- }
- double fps = m_fps;
- REFERENCE_TIME rtTimePerFrame = (REFERENCE_TIME)(10000000.0/fps);
- REFERENCE_TIME rtNow = UpdateQueue();
-
- int nMaxSubPic = m_nMaxSubPic;
-
- CComPtr<ISubPicProvider> pSubPicProvider;
- if (SUCCEEDED(GetSubPicProvider(&pSubPicProvider)) && pSubPicProvider
- && SUCCEEDED(pSubPicProvider->Lock())) {
- for (POSITION pos = pSubPicProvider->GetStartPosition(rtNow, fps);
- pos && !m_fBreakBuffering && GetQueueCount() < nMaxSubPic;
- pos = pSubPicProvider->GetNext(pos)) {
- REFERENCE_TIME rtStart = pSubPicProvider->GetStart(pos, fps);
- REFERENCE_TIME rtStop = pSubPicProvider->GetStop(pos, fps);
-
- if (m_rtNow >= rtStart) {
- // m_fBufferUnderrun = true;
- if (m_rtNow >= rtStop) {
- continue;
- }
- }
-
- if (rtStart >= m_rtNow + 60*10000000i64) { // we are already one minute ahead, this should be enough
- break;
- }
-
- if (rtNow < rtStop) {
- REFERENCE_TIME rtCurrent = max(rtNow, rtStart);
- bool bIsAnimated = pSubPicProvider->IsAnimated(pos) && !bDisableAnim;
- while (rtCurrent < rtStop) {
-
- SIZE MaxTextureSize, VirtualSize;
- POINT VirtualTopLeft;
- HRESULT hr2;
- if (SUCCEEDED (hr2 = pSubPicProvider->GetTextureSize(pos, MaxTextureSize, VirtualSize, VirtualTopLeft))) {
- m_pAllocator->SetMaxTextureSize(MaxTextureSize);
- }
-
- CComPtr<ISubPic> pStatic;
- if (FAILED(m_pAllocator->GetStatic(&pStatic))) {
- break;
- }
-
- HRESULT hr;
- if (bIsAnimated) {
- if (rtCurrent < m_rtNow + rtTimePerFrame) {
- rtCurrent = min(m_rtNow + rtTimePerFrame, rtStop-1);
- }
-
- REFERENCE_TIME rtEndThis = min(rtCurrent + rtTimePerFrame, rtStop);
- hr = RenderTo(pStatic, rtCurrent, rtEndThis, fps, bIsAnimated);
- pStatic->SetSegmentStart(rtStart);
- pStatic->SetSegmentStop(rtStop);
+ BOOL bDisableAnim = m_bDisableAnim;
+ SetThreadPriority(m_hThread, bDisableAnim ? THREAD_PRIORITY_LOWEST : THREAD_PRIORITY_ABOVE_NORMAL/*THREAD_PRIORITY_BELOW_NORMAL*/);
+
+ bool bAgain = true;
+ for (;;) {
+ DWORD Ret = WaitForMultipleObjects(EVENT_COUNT, m_ThreadEvents, FALSE, bAgain ? 0 : INFINITE);
+ bAgain = false;
+
+ if (Ret == WAIT_TIMEOUT) {
+ ;
+ } else if ((Ret - WAIT_OBJECT_0) != EVENT_TIME) {
+ break;
+ }
+ double fps = m_fps;
+ REFERENCE_TIME rtTimePerFrame = (REFERENCE_TIME)(10000000.0 / fps);
+ REFERENCE_TIME rtNow = UpdateQueue();
+
+ int nMaxSubPic = m_nMaxSubPic;
+
+ CComPtr<ISubPicProvider> pSubPicProvider;
+ if (SUCCEEDED(GetSubPicProvider(&pSubPicProvider)) && pSubPicProvider
+ && SUCCEEDED(pSubPicProvider->Lock())) {
+ for (POSITION pos = pSubPicProvider->GetStartPosition(rtNow, fps);
+ pos && !m_fBreakBuffering && GetQueueCount() < nMaxSubPic;
+ pos = pSubPicProvider->GetNext(pos)) {
+ REFERENCE_TIME rtStart = pSubPicProvider->GetStart(pos, fps);
+ REFERENCE_TIME rtStop = pSubPicProvider->GetStop(pos, fps);
+
+ if (m_rtNow >= rtStart) {
+ // m_fBufferUnderrun = true;
+ if (m_rtNow >= rtStop) {
+ continue;
+ }
+ }
+
+ if (rtStart >= m_rtNow + 60 * 10000000i64) { // we are already one minute ahead, this should be enough
+ break;
+ }
+
+ if (rtNow < rtStop) {
+ REFERENCE_TIME rtCurrent = max(rtNow, rtStart);
+ bool bIsAnimated = pSubPicProvider->IsAnimated(pos) && !bDisableAnim;
+ while (rtCurrent < rtStop) {
+
+ SIZE MaxTextureSize, VirtualSize;
+ POINT VirtualTopLeft;
+ HRESULT hr2;
+ if (SUCCEEDED(hr2 = pSubPicProvider->GetTextureSize(pos, MaxTextureSize, VirtualSize, VirtualTopLeft))) {
+ m_pAllocator->SetMaxTextureSize(MaxTextureSize);
+ }
+
+ CComPtr<ISubPic> pStatic;
+ if (FAILED(m_pAllocator->GetStatic(&pStatic))) {
+ break;
+ }
+
+ HRESULT hr;
+ if (bIsAnimated) {
+ if (rtCurrent < m_rtNow + rtTimePerFrame) {
+ rtCurrent = min(m_rtNow + rtTimePerFrame, rtStop - 1);
+ }
+
+ REFERENCE_TIME rtEndThis = min(rtCurrent + rtTimePerFrame, rtStop);
+ hr = RenderTo(pStatic, rtCurrent, rtEndThis, fps, bIsAnimated);
+ pStatic->SetSegmentStart(rtStart);
+ pStatic->SetSegmentStop(rtStop);
#if DSubPicTraceLevel > 0
- CRect r;
- pStatic->GetDirtyRect(&r);
- TRACE("Render: %f->%f %f->%f %dx%d\n", double(rtCurrent) / 10000000.0, double(rtEndThis) / 10000000.0, double(rtStart) / 10000000.0, double(rtStop) / 10000000.0, r.Width(), r.Height());
+ CRect r;
+ pStatic->GetDirtyRect(&r);
+ TRACE("Render: %f->%f %f->%f %dx%d\n", double(rtCurrent) / 10000000.0, double(rtEndThis) / 10000000.0, double(rtStart) / 10000000.0, double(rtStop) / 10000000.0, r.Width(), r.Height());
#endif
- rtCurrent = rtEndThis;
+ rtCurrent = rtEndThis;
- } else {
- hr = RenderTo(pStatic, rtStart, rtStop, fps, bIsAnimated);
- rtCurrent = rtStop;
- }
+ } else {
+ hr = RenderTo(pStatic, rtStart, rtStop, fps, bIsAnimated);
+ rtCurrent = rtStop;
+ }
#if DSubPicTraceLevel > 0
- if (m_rtNow > rtCurrent) {
- TRACE("BEHIND\n");
- }
+ if (m_rtNow > rtCurrent) {
+ TRACE("BEHIND\n");
+ }
#endif
- if (FAILED(hr)) {
- break;
- }
+ if (FAILED(hr)) {
+ break;
+ }
- if (S_OK != hr) { // subpic was probably empty
- continue;
- }
+ if (S_OK != hr) { // subpic was probably empty
+ continue;
+ }
- CComPtr<ISubPic> pDynamic;
- if (FAILED(m_pAllocator->AllocDynamic(&pDynamic))
- || FAILED(pStatic->CopyTo(pDynamic))) {
- break;
- }
+ CComPtr<ISubPic> pDynamic;
+ if (FAILED(m_pAllocator->AllocDynamic(&pDynamic))
+ || FAILED(pStatic->CopyTo(pDynamic))) {
+ break;
+ }
- if (SUCCEEDED (hr2)) {
- pDynamic->SetVirtualTextureSize (VirtualSize, VirtualTopLeft);
- }
+ if (SUCCEEDED(hr2)) {
+ pDynamic->SetVirtualTextureSize(VirtualSize, VirtualTopLeft);
+ }
- AppendQueue(pDynamic);
- bAgain = true;
+ AppendQueue(pDynamic);
+ bAgain = true;
- if (GetQueueCount() >= nMaxSubPic) {
- break;
- }
- }
- }
- }
+ if (GetQueueCount() >= nMaxSubPic) {
+ break;
+ }
+ }
+ }
+ }
- pSubPicProvider->Unlock();
- }
+ pSubPicProvider->Unlock();
+ }
- if (m_fBreakBuffering) {
- bAgain = true;
- CAutoLock cQueueLock(&m_csQueueLock);
+ if (m_fBreakBuffering) {
+ bAgain = true;
+ CAutoLock cQueueLock(&m_csQueueLock);
- REFERENCE_TIME rtInvalidate = m_rtInvalidate;
+ REFERENCE_TIME rtInvalidate = m_rtInvalidate;
- POSITION Iter = m_Queue.GetHeadPosition();
- while (Iter) {
- POSITION ThisPos = Iter;
- ISubPic *pSubPic = m_Queue.GetNext(Iter);
+ POSITION Iter = m_Queue.GetHeadPosition();
+ while (Iter) {
+ POSITION ThisPos = Iter;
+ ISubPic* pSubPic = m_Queue.GetNext(Iter);
- REFERENCE_TIME rtStart = pSubPic->GetStart();
- REFERENCE_TIME rtStop = pSubPic->GetStop();
+ REFERENCE_TIME rtStart = pSubPic->GetStart();
+ REFERENCE_TIME rtStop = pSubPic->GetStop();
- if (rtStop > rtInvalidate) {
+ if (rtStop > rtInvalidate) {
#if DSubPicTraceLevel >= 0
- TRACE(_T("Removed subtitle because of invalidation: %f->%f\n"), double(rtStart) / 10000000.0, double(rtStop) / 10000000.0);
+ TRACE(_T("Removed subtitle because of invalidation: %f->%f\n"), double(rtStart) / 10000000.0, double(rtStop) / 10000000.0);
#endif
- m_Queue.RemoveAt(ThisPos);
- continue;
- }
- }
-
- /*
- while (GetCount() && GetTail()->GetStop() > rtInvalidate)
- {
- if (GetTail()->GetStart() < rtInvalidate) GetTail()->SetStop(rtInvalidate);
- else
- {
- RemoveTail();
- }
- }
- */
-
- m_fBreakBuffering = false;
- }
- }
-
- return 0;
+ m_Queue.RemoveAt(ThisPos);
+ continue;
+ }
+ }
+
+ /*
+ while (GetCount() && GetTail()->GetStop() > rtInvalidate)
+ {
+ if (GetTail()->GetStart() < rtInvalidate) GetTail()->SetStop(rtInvalidate);
+ else
+ {
+ RemoveTail();
+ }
+ }
+ */
+
+ m_fBreakBuffering = false;
+ }
+ }
+
+ return 0;
}
//
@@ -565,7 +565,7 @@ DWORD CSubPicQueue::ThreadProc()
//
CSubPicQueueNoThread::CSubPicQueueNoThread(ISubPicAllocator* pAllocator, HRESULT* phr)
- : CSubPicQueueImpl(pAllocator, phr)
+ : CSubPicQueueImpl(pAllocator, phr)
{
}
@@ -577,116 +577,116 @@ CSubPicQueueNoThread::~CSubPicQueueNoThread()
STDMETHODIMP CSubPicQueueNoThread::Invalidate(REFERENCE_TIME rtInvalidate)
{
- CAutoLock cQueueLock(&m_csLock);
+ CAutoLock cQueueLock(&m_csLock);
- m_pSubPic = NULL;
+ m_pSubPic = NULL;
- return S_OK;
+ return S_OK;
}
-STDMETHODIMP_(bool) CSubPicQueueNoThread::LookupSubPic(REFERENCE_TIME rtNow, CComPtr<ISubPic> &ppSubPic)
+STDMETHODIMP_(bool) CSubPicQueueNoThread::LookupSubPic(REFERENCE_TIME rtNow, CComPtr<ISubPic>& ppSubPic)
{
- CComPtr<ISubPic> pSubPic;
-
- {
- CAutoLock cAutoLock(&m_csLock);
-
- if (!m_pSubPic) {
- if (FAILED(m_pAllocator->AllocDynamic(&m_pSubPic))) {
- return false;
- }
- }
-
- pSubPic = m_pSubPic;
- }
-
- if (pSubPic->GetStart() <= rtNow && rtNow < pSubPic->GetStop()) {
- ppSubPic = pSubPic;
- } else {
- CComPtr<ISubPicProvider> pSubPicProvider;
- GetSubPicProvider(&pSubPicProvider);
- if (pSubPicProvider) {
- double fps = m_fps;
-
- POSITION pos = pSubPicProvider->GetStartPosition(rtNow, fps);
- if (pos != 0) {
- REFERENCE_TIME rtStart = pSubPicProvider->GetStart(pos, fps);
- REFERENCE_TIME rtStop = pSubPicProvider->GetStop(pos, fps);
-
- if (pSubPicProvider->IsAnimated(pos)) {
- rtStart = rtNow;
- rtStop = rtNow+1;
- }
-
- if (rtStart <= rtNow && rtNow < rtStop) {
- SIZE MaxTextureSize, VirtualSize;
- POINT VirtualTopLeft;
- HRESULT hr2;
- if (SUCCEEDED (hr2 = pSubPicProvider->GetTextureSize(pos, MaxTextureSize, VirtualSize, VirtualTopLeft))) {
- m_pAllocator->SetMaxTextureSize(MaxTextureSize);
- }
-
- if (m_pAllocator->IsDynamicWriteOnly()) {
- CComPtr<ISubPic> pStatic;
- HRESULT hr = m_pAllocator->GetStatic(&pStatic);
- if (SUCCEEDED(hr)) {
- hr = RenderTo(pStatic, rtStart, rtStop, fps, false);
- }
- if (SUCCEEDED(hr)) {
- hr = pStatic->CopyTo(pSubPic);
- }
- if (SUCCEEDED(hr)) {
- ppSubPic = pSubPic;
- }
- } else {
- if (SUCCEEDED(RenderTo(m_pSubPic, rtStart, rtStop, fps, false))) {
- ppSubPic = pSubPic;
- }
- }
- if (SUCCEEDED(hr2)) {
- pSubPic->SetVirtualTextureSize (VirtualSize, VirtualTopLeft);
- }
- }
- }
-
- if (ppSubPic) {
- CAutoLock cAutoLock(&m_csLock);
-
- m_pSubPic = ppSubPic;
- }
- }
- }
-
- return !!ppSubPic;
+ CComPtr<ISubPic> pSubPic;
+
+ {
+ CAutoLock cAutoLock(&m_csLock);
+
+ if (!m_pSubPic) {
+ if (FAILED(m_pAllocator->AllocDynamic(&m_pSubPic))) {
+ return false;
+ }
+ }
+
+ pSubPic = m_pSubPic;
+ }
+
+ if (pSubPic->GetStart() <= rtNow && rtNow < pSubPic->GetStop()) {
+ ppSubPic = pSubPic;
+ } else {
+ CComPtr<ISubPicProvider> pSubPicProvider;
+ GetSubPicProvider(&pSubPicProvider);
+ if (pSubPicProvider) {
+ double fps = m_fps;
+
+ POSITION pos = pSubPicProvider->GetStartPosition(rtNow, fps);
+ if (pos != 0) {
+ REFERENCE_TIME rtStart = pSubPicProvider->GetStart(pos, fps);
+ REFERENCE_TIME rtStop = pSubPicProvider->GetStop(pos, fps);
+
+ if (pSubPicProvider->IsAnimated(pos)) {
+ rtStart = rtNow;
+ rtStop = rtNow + 1;
+ }
+
+ if (rtStart <= rtNow && rtNow < rtStop) {
+ SIZE MaxTextureSize, VirtualSize;
+ POINT VirtualTopLeft;
+ HRESULT hr2;
+ if (SUCCEEDED(hr2 = pSubPicProvider->GetTextureSize(pos, MaxTextureSize, VirtualSize, VirtualTopLeft))) {
+ m_pAllocator->SetMaxTextureSize(MaxTextureSize);
+ }
+
+ if (m_pAllocator->IsDynamicWriteOnly()) {
+ CComPtr<ISubPic> pStatic;
+ HRESULT hr = m_pAllocator->GetStatic(&pStatic);
+ if (SUCCEEDED(hr)) {
+ hr = RenderTo(pStatic, rtStart, rtStop, fps, false);
+ }
+ if (SUCCEEDED(hr)) {
+ hr = pStatic->CopyTo(pSubPic);
+ }
+ if (SUCCEEDED(hr)) {
+ ppSubPic = pSubPic;
+ }
+ } else {
+ if (SUCCEEDED(RenderTo(m_pSubPic, rtStart, rtStop, fps, false))) {
+ ppSubPic = pSubPic;
+ }
+ }
+ if (SUCCEEDED(hr2)) {
+ pSubPic->SetVirtualTextureSize(VirtualSize, VirtualTopLeft);
+ }
+ }
+ }
+
+ if (ppSubPic) {
+ CAutoLock cAutoLock(&m_csLock);
+
+ m_pSubPic = ppSubPic;
+ }
+ }
+ }
+
+ return !!ppSubPic;
}
STDMETHODIMP CSubPicQueueNoThread::GetStats(int& nSubPics, REFERENCE_TIME& rtNow, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop)
{
- CAutoLock cAutoLock(&m_csLock);
+ CAutoLock cAutoLock(&m_csLock);
- nSubPics = 0;
- rtNow = m_rtNow;
- rtStart = rtStop = 0;
+ nSubPics = 0;
+ rtNow = m_rtNow;
+ rtStart = rtStop = 0;
- if (m_pSubPic) {
- nSubPics = 1;
- rtStart = m_pSubPic->GetStart();
- rtStop = m_pSubPic->GetStop();
- }
+ if (m_pSubPic) {
+ nSubPics = 1;
+ rtStart = m_pSubPic->GetStart();
+ rtStop = m_pSubPic->GetStop();
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CSubPicQueueNoThread::GetStats(int nSubPic, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop)
{
- CAutoLock cAutoLock(&m_csLock);
+ CAutoLock cAutoLock(&m_csLock);
- if (!m_pSubPic || nSubPic != 0) {
- return E_INVALIDARG;
- }
+ if (!m_pSubPic || nSubPic != 0) {
+ return E_INVALIDARG;
+ }
- rtStart = m_pSubPic->GetStart();
- rtStop = m_pSubPic->GetStop();
+ rtStart = m_pSubPic->GetStart();
+ rtStop = m_pSubPic->GetStop();
- return S_OK;
+ return S_OK;
}
diff --git a/src/SubPic/SubPicQueueImpl.h b/src/SubPic/SubPicQueueImpl.h
index e31a4e744..6dc50381c 100644
--- a/src/SubPic/SubPicQueueImpl.h
+++ b/src/SubPic/SubPicQueueImpl.h
@@ -27,94 +27,94 @@
class CSubPicQueueImpl : public CUnknown, public ISubPicQueue
{
- CCritSec m_csSubPicProvider;
- CComPtr<ISubPicProvider> m_pSubPicProvider;
+ CCritSec m_csSubPicProvider;
+ CComPtr<ISubPicProvider> m_pSubPicProvider;
protected:
- double m_fps;
- REFERENCE_TIME m_rtNow;
- REFERENCE_TIME m_rtNowLast;
+ double m_fps;
+ REFERENCE_TIME m_rtNow;
+ REFERENCE_TIME m_rtNowLast;
- CComPtr<ISubPicAllocator> m_pAllocator;
+ CComPtr<ISubPicAllocator> m_pAllocator;
- HRESULT RenderTo(ISubPic* pSubPic, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, double fps, BOOL bIsAnimated);
+ HRESULT RenderTo(ISubPic* pSubPic, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, double fps, BOOL bIsAnimated);
public:
- CSubPicQueueImpl(ISubPicAllocator* pAllocator, HRESULT* phr);
- virtual ~CSubPicQueueImpl();
+ CSubPicQueueImpl(ISubPicAllocator* pAllocator, HRESULT* phr);
+ virtual ~CSubPicQueueImpl();
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // ISubPicQueue
+ // ISubPicQueue
- STDMETHODIMP SetSubPicProvider(ISubPicProvider* pSubPicProvider);
- STDMETHODIMP GetSubPicProvider(ISubPicProvider** pSubPicProvider);
+ STDMETHODIMP SetSubPicProvider(ISubPicProvider* pSubPicProvider);
+ STDMETHODIMP GetSubPicProvider(ISubPicProvider** pSubPicProvider);
- STDMETHODIMP SetFPS(double fps);
- STDMETHODIMP SetTime(REFERENCE_TIME rtNow);
- /*
- STDMETHODIMP Invalidate(REFERENCE_TIME rtInvalidate = -1) = 0;
- STDMETHODIMP_(bool) LookupSubPic(REFERENCE_TIME rtNow, ISubPic** ppSubPic) = 0;
+ STDMETHODIMP SetFPS(double fps);
+ STDMETHODIMP SetTime(REFERENCE_TIME rtNow);
+ /*
+ STDMETHODIMP Invalidate(REFERENCE_TIME rtInvalidate = -1) = 0;
+ STDMETHODIMP_(bool) LookupSubPic(REFERENCE_TIME rtNow, ISubPic** ppSubPic) = 0;
- STDMETHODIMP GetStats(int& nSubPics, REFERENCE_TIME& rtNow, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop) = 0;
- STDMETHODIMP GetStats(int nSubPics, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop) = 0;
- */
+ STDMETHODIMP GetStats(int& nSubPics, REFERENCE_TIME& rtNow, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop) = 0;
+ STDMETHODIMP GetStats(int nSubPics, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop) = 0;
+ */
};
class CSubPicQueue : public CSubPicQueueImpl, private CAMThread
{
- int m_nMaxSubPic;
- BOOL m_bDisableAnim;
+ int m_nMaxSubPic;
+ BOOL m_bDisableAnim;
- CInterfaceList<ISubPic> m_Queue;
+ CInterfaceList<ISubPic> m_Queue;
- CCritSec m_csQueueLock; // for protecting CInterfaceList<ISubPic>
- REFERENCE_TIME UpdateQueue();
- void AppendQueue(ISubPic* pSubPic);
- int GetQueueCount();
+ CCritSec m_csQueueLock; // for protecting CInterfaceList<ISubPic>
+ REFERENCE_TIME UpdateQueue();
+ void AppendQueue(ISubPic* pSubPic);
+ int GetQueueCount();
- REFERENCE_TIME m_rtQueueMin;
- REFERENCE_TIME m_rtQueueMax;
- REFERENCE_TIME m_rtInvalidate;
+ REFERENCE_TIME m_rtQueueMin;
+ REFERENCE_TIME m_rtQueueMax;
+ REFERENCE_TIME m_rtInvalidate;
- // CAMThread
+ // CAMThread
- bool m_fBreakBuffering;
- enum {EVENT_EXIT, EVENT_TIME, EVENT_COUNT}; // IMPORTANT: _EXIT must come before _TIME if we want to exit fast from the destructor
- HANDLE m_ThreadEvents[EVENT_COUNT];
- DWORD ThreadProc();
+ bool m_fBreakBuffering;
+ enum {EVENT_EXIT, EVENT_TIME, EVENT_COUNT}; // IMPORTANT: _EXIT must come before _TIME if we want to exit fast from the destructor
+ HANDLE m_ThreadEvents[EVENT_COUNT];
+ DWORD ThreadProc();
public:
- CSubPicQueue(int nMaxSubPic, BOOL bDisableAnim, ISubPicAllocator* pAllocator, HRESULT* phr);
- virtual ~CSubPicQueue();
+ CSubPicQueue(int nMaxSubPic, BOOL bDisableAnim, ISubPicAllocator* pAllocator, HRESULT* phr);
+ virtual ~CSubPicQueue();
- // ISubPicQueue
+ // ISubPicQueue
- STDMETHODIMP SetFPS(double fps);
- STDMETHODIMP SetTime(REFERENCE_TIME rtNow);
+ STDMETHODIMP SetFPS(double fps);
+ STDMETHODIMP SetTime(REFERENCE_TIME rtNow);
- STDMETHODIMP Invalidate(REFERENCE_TIME rtInvalidate = -1);
- STDMETHODIMP_(bool) LookupSubPic(REFERENCE_TIME rtNow, CComPtr<ISubPic> &pSubPic);
+ STDMETHODIMP Invalidate(REFERENCE_TIME rtInvalidate = -1);
+ STDMETHODIMP_(bool) LookupSubPic(REFERENCE_TIME rtNow, CComPtr<ISubPic>& pSubPic);
- STDMETHODIMP GetStats(int& nSubPics, REFERENCE_TIME& rtNow, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
- STDMETHODIMP GetStats(int nSubPic, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
+ STDMETHODIMP GetStats(int& nSubPics, REFERENCE_TIME& rtNow, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
+ STDMETHODIMP GetStats(int nSubPic, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
};
class CSubPicQueueNoThread : public CSubPicQueueImpl
{
- CCritSec m_csLock;
- CComPtr<ISubPic> m_pSubPic;
+ CCritSec m_csLock;
+ CComPtr<ISubPic> m_pSubPic;
public:
- CSubPicQueueNoThread(ISubPicAllocator* pAllocator, HRESULT* phr);
- virtual ~CSubPicQueueNoThread();
+ CSubPicQueueNoThread(ISubPicAllocator* pAllocator, HRESULT* phr);
+ virtual ~CSubPicQueueNoThread();
- // ISubPicQueue
+ // ISubPicQueue
- STDMETHODIMP Invalidate(REFERENCE_TIME rtInvalidate = -1);
- STDMETHODIMP_(bool) LookupSubPic(REFERENCE_TIME rtNow, CComPtr<ISubPic> &pSubPic);
+ STDMETHODIMP Invalidate(REFERENCE_TIME rtInvalidate = -1);
+ STDMETHODIMP_(bool) LookupSubPic(REFERENCE_TIME rtNow, CComPtr<ISubPic>& pSubPic);
- STDMETHODIMP GetStats(int& nSubPics, REFERENCE_TIME& rtNow, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
- STDMETHODIMP GetStats(int nSubPic, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
+ STDMETHODIMP GetStats(int& nSubPics, REFERENCE_TIME& rtNow, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
+ STDMETHODIMP GetStats(int nSubPic, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
};
diff --git a/src/SubPic/stdafx.h b/src/SubPic/stdafx.h
index 335547389..2cd56ad19 100644
--- a/src/SubPic/stdafx.h
+++ b/src/SubPic/stdafx.h
@@ -26,16 +26,16 @@
#include "../DSUtil/SharedInclude.h"
#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#endif
-#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
#ifndef VC_EXTRALEAN
-#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
+#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
#include <afx.h>
-#include <afxwin.h> // MFC core and standard components
+#include <afxwin.h> // MFC core and standard components
#include <BaseClasses/streams.h>
#include <dvdmedia.h>
diff --git a/src/Subtitles/BaseSub.cpp b/src/Subtitles/BaseSub.cpp
index 8966767fc..a1f891041 100644
--- a/src/Subtitles/BaseSub.cpp
+++ b/src/Subtitles/BaseSub.cpp
@@ -24,7 +24,7 @@
#include "BaseSub.h"
CBaseSub::CBaseSub(SUBTITLE_TYPE nType)
- : m_nType(nType)
+ : m_nType(nType)
{
}
diff --git a/src/Subtitles/BaseSub.h b/src/Subtitles/BaseSub.h
index a54ab3b40..f94680443 100644
--- a/src/Subtitles/BaseSub.h
+++ b/src/Subtitles/BaseSub.h
@@ -25,28 +25,28 @@
#include "CompositionObject.h"
enum SUBTITLE_TYPE {
- ST_DVB,
- ST_HDMV
+ ST_DVB,
+ ST_HDMV
};
class CBaseSub
{
public:
- static const REFERENCE_TIME INVALID_TIME = _I64_MIN;
+ static const REFERENCE_TIME INVALID_TIME = _I64_MIN;
- CBaseSub(SUBTITLE_TYPE nType);
- virtual ~CBaseSub();
+ CBaseSub(SUBTITLE_TYPE nType);
+ virtual ~CBaseSub();
- virtual HRESULT ParseSample (IMediaSample* pSample) = NULL;
- virtual void Reset() = NULL;
- virtual POSITION GetStartPosition(REFERENCE_TIME rt, double fps) = NULL;
- virtual POSITION GetNext(POSITION pos) = NULL;
- virtual REFERENCE_TIME GetStart(POSITION nPos) = NULL;
- virtual REFERENCE_TIME GetStop(POSITION nPos) = NULL;
- virtual void Render(SubPicDesc& spd, REFERENCE_TIME rt, RECT& bbox) = NULL;
- virtual HRESULT GetTextureSize (POSITION pos, SIZE& MaxTextureSize, SIZE& VideoSize, POINT& VideoTopLeft) = NULL;
+ virtual HRESULT ParseSample(IMediaSample* pSample) = NULL;
+ virtual void Reset() = NULL;
+ virtual POSITION GetStartPosition(REFERENCE_TIME rt, double fps) = NULL;
+ virtual POSITION GetNext(POSITION pos) = NULL;
+ virtual REFERENCE_TIME GetStart(POSITION nPos) = NULL;
+ virtual REFERENCE_TIME GetStop(POSITION nPos) = NULL;
+ virtual void Render(SubPicDesc& spd, REFERENCE_TIME rt, RECT& bbox) = NULL;
+ virtual HRESULT GetTextureSize(POSITION pos, SIZE& MaxTextureSize, SIZE& VideoSize, POINT& VideoTopLeft) = NULL;
protected :
- SUBTITLE_TYPE m_nType;
+ SUBTITLE_TYPE m_nType;
};
diff --git a/src/Subtitles/CCDecoder.cpp b/src/Subtitles/CCDecoder.cpp
index 2e42809bf..afba0620b 100644
--- a/src/Subtitles/CCDecoder.cpp
+++ b/src/Subtitles/CCDecoder.cpp
@@ -26,366 +26,366 @@
CCDecoder::CCDecoder(CString fn, CString rawfn) : m_fn(fn), m_rawfn(rawfn)
{
- m_sts.CreateDefaultStyle(ANSI_CHARSET);
+ m_sts.CreateDefaultStyle(ANSI_CHARSET);
- m_time = 0;
- m_fEndOfCaption = false;
- memset(m_buff, 0, sizeof(m_buff));
- memset(m_disp, 0, sizeof(m_disp));
- m_cursor = CPoint(0, 0);
+ m_time = 0;
+ m_fEndOfCaption = false;
+ memset(m_buff, 0, sizeof(m_buff));
+ memset(m_disp, 0, sizeof(m_disp));
+ m_cursor = CPoint(0, 0);
- if (!m_rawfn.IsEmpty()) {
- _tremove(m_rawfn);
- }
+ if (!m_rawfn.IsEmpty()) {
+ _tremove(m_rawfn);
+ }
}
CCDecoder::~CCDecoder()
{
- if (!m_sts.IsEmpty() && !m_fn.IsEmpty()) {
- m_sts.Sort();
- m_sts.SaveAs(m_fn, EXTSRT, -1, CTextFile::ASCII);
- m_sts.SaveAs(m_fn.Left(m_fn.ReverseFind('.')+1) + _T("utf8.srt"), EXTSRT, -1, CTextFile::UTF8);
- m_sts.SaveAs(m_fn.Left(m_fn.ReverseFind('.')+1) + _T("utf16le.srt"), EXTSRT, -1, CTextFile::LE16);
- m_sts.SaveAs(m_fn.Left(m_fn.ReverseFind('.')+1) + _T("utf16be.srt"), EXTSRT, -1, CTextFile::BE16);
- }
+ if (!m_sts.IsEmpty() && !m_fn.IsEmpty()) {
+ m_sts.Sort();
+ m_sts.SaveAs(m_fn, EXTSRT, -1, CTextFile::ASCII);
+ m_sts.SaveAs(m_fn.Left(m_fn.ReverseFind('.') + 1) + _T("utf8.srt"), EXTSRT, -1, CTextFile::UTF8);
+ m_sts.SaveAs(m_fn.Left(m_fn.ReverseFind('.') + 1) + _T("utf16le.srt"), EXTSRT, -1, CTextFile::LE16);
+ m_sts.SaveAs(m_fn.Left(m_fn.ReverseFind('.') + 1) + _T("utf16be.srt"), EXTSRT, -1, CTextFile::BE16);
+ }
}
void CCDecoder::MoveCursor(int x, int y)
{
- m_cursor = CPoint(x, y);
- if (m_cursor.x < 0) {
- m_cursor.x = 0;
- }
- if (m_cursor.y < 0) {
- m_cursor.y = 0;
- }
- if (m_cursor.x >= 32) {
- m_cursor.x = 0, m_cursor.y++;
- }
- if (m_cursor.y >= 16) {
- m_cursor.y = 0;
- }
+ m_cursor = CPoint(x, y);
+ if (m_cursor.x < 0) {
+ m_cursor.x = 0;
+ }
+ if (m_cursor.y < 0) {
+ m_cursor.y = 0;
+ }
+ if (m_cursor.x >= 32) {
+ m_cursor.x = 0, m_cursor.y++;
+ }
+ if (m_cursor.y >= 16) {
+ m_cursor.y = 0;
+ }
}
void CCDecoder::OffsetCursor(int x, int y)
{
- MoveCursor(m_cursor.x + x, m_cursor.y + y);
+ MoveCursor(m_cursor.x + x, m_cursor.y + y);
}
void CCDecoder::PutChar(WCHAR c)
{
- m_buff[m_cursor.y][m_cursor.x] = c;
- OffsetCursor(1, 0);
+ m_buff[m_cursor.y][m_cursor.x] = c;
+ OffsetCursor(1, 0);
}
void CCDecoder::SaveDisp(__int64 time)
{
- CStringW str;
-
- for (size_t row = 0; row < 16; row++) {
- bool fNonEmptyRow = false;
-
- for (size_t col = 0; col < 32; col++) {
- if (m_disp[row][col]) {
- CStringW str2(&m_disp[row][col]);
- if (fNonEmptyRow) {
- str += ' ';
- }
- str += str2;
- col += str2.GetLength();
- fNonEmptyRow = true;
- }
- }
-
- if (fNonEmptyRow) {
- str += '\n';
- }
- }
-
- if (str.IsEmpty()) {
- return;
- }
-
- m_sts.Add(str, true, (int)m_time, (int)time);
+ CStringW str;
+
+ for (size_t row = 0; row < 16; row++) {
+ bool fNonEmptyRow = false;
+
+ for (size_t col = 0; col < 32; col++) {
+ if (m_disp[row][col]) {
+ CStringW str2(&m_disp[row][col]);
+ if (fNonEmptyRow) {
+ str += ' ';
+ }
+ str += str2;
+ col += str2.GetLength();
+ fNonEmptyRow = true;
+ }
+ }
+
+ if (fNonEmptyRow) {
+ str += '\n';
+ }
+ }
+
+ if (str.IsEmpty()) {
+ return;
+ }
+
+ m_sts.Add(str, true, (int)m_time, (int)time);
}
void CCDecoder::DecodeCC(BYTE* buff, int len, __int64 time)
{
- if (!m_rawfn.IsEmpty()) {
- FILE* f = NULL;
- if (!_tfopen_s(&f, m_rawfn, _T("at"))) {
- _ftprintf_s(f, _T("%02d:%02d:%02d.%03d\n"),
- (int)(time/1000/60/60),
- (int)((time/1000/60)%60),
- (int)((time/1000)%60),
- (int)(time%1000));
-
- for (ptrdiff_t i = 0; i < len; i++) {
- _ftprintf_s(f, _T("%02x"), buff[i]);
- if (i < len-1) {
- _ftprintf_s(f, _T(" "));
- }
- if (i > 0 && (i&15)==15) {
- _ftprintf_s(f, _T("\n"));
- }
- }
- if (len > 0) {
- _ftprintf_s(f, _T("\n\n"));
- }
- fclose(f);
- }
- }
-
- for (ptrdiff_t i = 0; i < len; i++) {
- BYTE c = buff[i]&0x7f;
- if (c >= 0x20) {
- static WCHAR charmap[0x60] = {
- ' ','!','"','#','$','%','&','\'','(',')',0xE1,'+',',','-','.','/',
- '0','1','2','3','4','5','6','7','8','9',':',';','<','=','>',0x3F,
- '@','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O',
- 'P','Q','R','S','T','U','V','W','X','Y','Z','[',0xE9,']',0xED,0xF3,
- 0xFA,'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o',
- 'p','q','r','s','t','u','v','w','x','y','z',0xE7,0xF7,'N','n',0x3F
- };
-
- PutChar(charmap[c - 0x20]);
- } else if (buff[i] != 0x80 && i < len-1) {
- // codes and special characters are supposed to be doubled
- if (i < len-3 && buff[i] == buff[i+2] && buff[i+1] == buff[i+3]) {
- i += 2;
- }
-
- c = buff[i+1]&0x7f;
- if (buff[i] == 0x91 && c >= 0x20 && c < 0x30) { // formating
- // TODO
- } else if (buff[i] == 0x91 && c == 0x39) { // transparent space
- OffsetCursor(1, 0);
- } else if (buff[i] == 0x91 && c >= 0x30 && c < 0x40) { // special characters
- static WCHAR charmap[0x10] = {
- 0x00ae, // (r)egistered
- 0x00b0, // degree
- 0x00bd, // 1/2
- 0x00bf, // inverted question mark
- 0x2122, // trade mark
- 0x00a2, // cent
- 0x00a3, // pound
- 0x266a, // music
- 0x00e0, // a`
- 0x00ff, // transparent space, handled above
- 0x00e8, // e`
- 0x00e2, // a^
- 0x00ea, // e^
- 0x00ee, // i^
- 0x00f4, // o^
- 0x00fb, // u^
- };
-
- PutChar(charmap[c - 0x30]);
- } else if (buff[i] == 0x92 && c >= 0x20 && c < 0x40) { // extended characters
- static WCHAR charmap[0x20] = {
- 0x00c0, // A'
- 0x00c9, // E'
- 0x00d3, // O'
- 0x00da, // U'
- 0x00dc, // U:
- 0x00fc, // u:
- 0x2018, // `
- 0x00a1, // inverted !
- 0x002a, // *
- 0x2019, // '
- 0x002d, // -
- 0x00a9, // (c)opyright
- 0x2120, // SM
- 0x00b7, // . (dot in the middle)
- 0x201c, // inverted "
- 0x201d, // "
-
- 0x00c1, // A`
- 0x00c2, // A^
- 0x00c7, // C,
- 0x00c8, // E`
- 0x00ca, // E^
- 0x00cb, // E:
- 0x00eb, // e:
- 0x00ce, // I^
- 0x00cf, // I:
- 0x00ef, // i:
- 0x00d4, // O^
- 0x00d9, // U`
- 0x00f9, // u`
- 0x00db, // U^
- 0x00ab, // <<
- 0x00bb, // >>
- };
-
- PutChar(charmap[c - 0x20]);
- } else if (buff[i] == 0x13 && c >= 0x20 && c < 0x40) { // more extended characters
- static WCHAR charmap[0x20] = {
- 0x00c3, // A~
- 0x00e3, // a~
- 0x00cd, // I'
- 0x00cc, // I`
- 0x00ec, // i`
- 0x00d2, // O`
- 0x00f2, // o`
- 0x00d5, // O~
- 0x00f5, // o~
- 0x007b, // {
- 0x007d, // }
- 0x005c, // /* \ */
- 0x005e, // ^
- 0x005f, // _
- 0x00a6, // |
- 0x007e, // ~
-
- 0x00c4, // A:
- 0x00e4, // a:
- 0x00d6, // O:
- 0x00f6, // o:
- 0x00df, // B (ss in german)
- 0x00a5, // Y=
- 0x00a4, // ox
- 0x007c, // |
- 0x00c5, // Ao
- 0x00e5, // ao
- 0x00d8, // O/
- 0x00f8, // o/
- 0x250c, // |-
- 0x2510, // -|
- 0x2514, // |_
- 0x2518, // _|
- };
-
- PutChar(charmap[c - 0x20]);
- } else if (buff[i] == 0x94 && buff[i+1] == 0xae) { // Erase Non-displayed [buffer] Memory
- memset(m_buff, 0, sizeof(m_buff));
- } else if (buff[i] == 0x94 && buff[i+1] == 0x20) { // Resume Caption Loading
- memset(m_buff, 0, sizeof(m_buff));
- } else if (buff[i] == 0x94 && buff[i+1] == 0x2f) { // End Of Caption
- if (memcmp(m_disp, m_buff, sizeof(m_disp)) != 0) {
- if (m_fEndOfCaption) {
- SaveDisp(time + (i/2)*1000/30);
- }
-
- m_fEndOfCaption = true;
- memcpy(m_disp, m_buff, sizeof(m_disp));
- m_time = time + (i/2)*1000/30;
- }
- } else if (buff[i] == 0x94 && buff[i+1] == 0x2c) { // Erase Displayed Memory
- if (m_fEndOfCaption) {
- m_fEndOfCaption = false;
- SaveDisp(time + (i/2)*1000/30);
- }
-
- memset(m_disp, 0, sizeof(m_disp));
- } else if (buff[i] == 0x97 && (buff[i+1] == 0xa1 || buff[i+1] == 0xa2 || buff[i+1] == 0x23)) { // Tab Over
- OffsetCursor(buff[i+1]&3, 0);
- } else if (buff[i] == 0x91 || buff[i] == 0x92 || buff[i] == 0x15 || buff[i] == 0x16
- || buff[i] == 0x97 || buff[i] == 0x10 || buff[i] == 0x13 || buff[i] == 0x94) { // curpos, color, underline
- int row = 0;
- switch (buff[i]) {
- default:
- case 0x91:
- row = 0;
- break;
- case 0x92:
- row = 2;
- break;
- case 0x15:
- row = 4;
- break;
- case 0x16:
- row = 6;
- break;
- case 0x97:
- row = 8;
- break;
- case 0x10:
- row = 10;
- break;
- case 0x13:
- row = 12;
- break;
- case 0x94:
- row = 14;
- break;
- }
- if (buff[i+1]&0x20) {
- row++;
- }
-
- int col = buff[i+1]&0xe;
- if (col == 0 || (col > 0 && !(buff[i+1]&0x10))) {
- col = 0;
- } else {
- col <<= 1;
- }
-
- MoveCursor(col, row);
- }
-
- i++;
- }
- }
+ if (!m_rawfn.IsEmpty()) {
+ FILE* f = NULL;
+ if (!_tfopen_s(&f, m_rawfn, _T("at"))) {
+ _ftprintf_s(f, _T("%02d:%02d:%02d.%03d\n"),
+ (int)(time / 1000 / 60 / 60),
+ (int)((time / 1000 / 60) % 60),
+ (int)((time / 1000) % 60),
+ (int)(time % 1000));
+
+ for (ptrdiff_t i = 0; i < len; i++) {
+ _ftprintf_s(f, _T("%02x"), buff[i]);
+ if (i < len - 1) {
+ _ftprintf_s(f, _T(" "));
+ }
+ if (i > 0 && (i & 15) == 15) {
+ _ftprintf_s(f, _T("\n"));
+ }
+ }
+ if (len > 0) {
+ _ftprintf_s(f, _T("\n\n"));
+ }
+ fclose(f);
+ }
+ }
+
+ for (ptrdiff_t i = 0; i < len; i++) {
+ BYTE c = buff[i] & 0x7f;
+ if (c >= 0x20) {
+ static WCHAR charmap[0x60] = {
+ ' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', 0xE1, '+', ',', '-', '.', '/',
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', 0x3F,
+ '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', 0xE9, ']', 0xED, 0xF3,
+ 0xFA, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0xE7, 0xF7, 'N', 'n', 0x3F
+ };
+
+ PutChar(charmap[c - 0x20]);
+ } else if (buff[i] != 0x80 && i < len - 1) {
+ // codes and special characters are supposed to be doubled
+ if (i < len - 3 && buff[i] == buff[i + 2] && buff[i + 1] == buff[i + 3]) {
+ i += 2;
+ }
+
+ c = buff[i + 1] & 0x7f;
+ if (buff[i] == 0x91 && c >= 0x20 && c < 0x30) { // formating
+ // TODO
+ } else if (buff[i] == 0x91 && c == 0x39) { // transparent space
+ OffsetCursor(1, 0);
+ } else if (buff[i] == 0x91 && c >= 0x30 && c < 0x40) { // special characters
+ static WCHAR charmap[0x10] = {
+ 0x00ae, // (r)egistered
+ 0x00b0, // degree
+ 0x00bd, // 1/2
+ 0x00bf, // inverted question mark
+ 0x2122, // trade mark
+ 0x00a2, // cent
+ 0x00a3, // pound
+ 0x266a, // music
+ 0x00e0, // a`
+ 0x00ff, // transparent space, handled above
+ 0x00e8, // e`
+ 0x00e2, // a^
+ 0x00ea, // e^
+ 0x00ee, // i^
+ 0x00f4, // o^
+ 0x00fb, // u^
+ };
+
+ PutChar(charmap[c - 0x30]);
+ } else if (buff[i] == 0x92 && c >= 0x20 && c < 0x40) { // extended characters
+ static WCHAR charmap[0x20] = {
+ 0x00c0, // A'
+ 0x00c9, // E'
+ 0x00d3, // O'
+ 0x00da, // U'
+ 0x00dc, // U:
+ 0x00fc, // u:
+ 0x2018, // `
+ 0x00a1, // inverted !
+ 0x002a, // *
+ 0x2019, // '
+ 0x002d, // -
+ 0x00a9, // (c)opyright
+ 0x2120, // SM
+ 0x00b7, // . (dot in the middle)
+ 0x201c, // inverted "
+ 0x201d, // "
+
+ 0x00c1, // A`
+ 0x00c2, // A^
+ 0x00c7, // C,
+ 0x00c8, // E`
+ 0x00ca, // E^
+ 0x00cb, // E:
+ 0x00eb, // e:
+ 0x00ce, // I^
+ 0x00cf, // I:
+ 0x00ef, // i:
+ 0x00d4, // O^
+ 0x00d9, // U`
+ 0x00f9, // u`
+ 0x00db, // U^
+ 0x00ab, // <<
+ 0x00bb, // >>
+ };
+
+ PutChar(charmap[c - 0x20]);
+ } else if (buff[i] == 0x13 && c >= 0x20 && c < 0x40) { // more extended characters
+ static WCHAR charmap[0x20] = {
+ 0x00c3, // A~
+ 0x00e3, // a~
+ 0x00cd, // I'
+ 0x00cc, // I`
+ 0x00ec, // i`
+ 0x00d2, // O`
+ 0x00f2, // o`
+ 0x00d5, // O~
+ 0x00f5, // o~
+ 0x007b, // {
+ 0x007d, // }
+ 0x005c, // /* \ */
+ 0x005e, // ^
+ 0x005f, // _
+ 0x00a6, // |
+ 0x007e, // ~
+
+ 0x00c4, // A:
+ 0x00e4, // a:
+ 0x00d6, // O:
+ 0x00f6, // o:
+ 0x00df, // B (ss in german)
+ 0x00a5, // Y=
+ 0x00a4, // ox
+ 0x007c, // |
+ 0x00c5, // Ao
+ 0x00e5, // ao
+ 0x00d8, // O/
+ 0x00f8, // o/
+ 0x250c, // |-
+ 0x2510, // -|
+ 0x2514, // |_
+ 0x2518, // _|
+ };
+
+ PutChar(charmap[c - 0x20]);
+ } else if (buff[i] == 0x94 && buff[i + 1] == 0xae) { // Erase Non-displayed [buffer] Memory
+ memset(m_buff, 0, sizeof(m_buff));
+ } else if (buff[i] == 0x94 && buff[i + 1] == 0x20) { // Resume Caption Loading
+ memset(m_buff, 0, sizeof(m_buff));
+ } else if (buff[i] == 0x94 && buff[i + 1] == 0x2f) { // End Of Caption
+ if (memcmp(m_disp, m_buff, sizeof(m_disp)) != 0) {
+ if (m_fEndOfCaption) {
+ SaveDisp(time + (i / 2) * 1000 / 30);
+ }
+
+ m_fEndOfCaption = true;
+ memcpy(m_disp, m_buff, sizeof(m_disp));
+ m_time = time + (i / 2) * 1000 / 30;
+ }
+ } else if (buff[i] == 0x94 && buff[i + 1] == 0x2c) { // Erase Displayed Memory
+ if (m_fEndOfCaption) {
+ m_fEndOfCaption = false;
+ SaveDisp(time + (i / 2) * 1000 / 30);
+ }
+
+ memset(m_disp, 0, sizeof(m_disp));
+ } else if (buff[i] == 0x97 && (buff[i + 1] == 0xa1 || buff[i + 1] == 0xa2 || buff[i + 1] == 0x23)) { // Tab Over
+ OffsetCursor(buff[i + 1] & 3, 0);
+ } else if (buff[i] == 0x91 || buff[i] == 0x92 || buff[i] == 0x15 || buff[i] == 0x16
+ || buff[i] == 0x97 || buff[i] == 0x10 || buff[i] == 0x13 || buff[i] == 0x94) { // curpos, color, underline
+ int row = 0;
+ switch (buff[i]) {
+ default:
+ case 0x91:
+ row = 0;
+ break;
+ case 0x92:
+ row = 2;
+ break;
+ case 0x15:
+ row = 4;
+ break;
+ case 0x16:
+ row = 6;
+ break;
+ case 0x97:
+ row = 8;
+ break;
+ case 0x10:
+ row = 10;
+ break;
+ case 0x13:
+ row = 12;
+ break;
+ case 0x94:
+ row = 14;
+ break;
+ }
+ if (buff[i + 1] & 0x20) {
+ row++;
+ }
+
+ int col = buff[i + 1] & 0xe;
+ if (col == 0 || (col > 0 && !(buff[i + 1] & 0x10))) {
+ col = 0;
+ } else {
+ col <<= 1;
+ }
+
+ MoveCursor(col, row);
+ }
+
+ i++;
+ }
+ }
}
void CCDecoder::ExtractCC(BYTE* buff, int len, __int64 time)
{
- for (ptrdiff_t i = 0; i < len-9; i++) {
- if (*(DWORD*)&buff[i] == 0xb2010000 && *(DWORD*)&buff[i+4] == 0xf8014343) {
- i += 8;
- int nBytes = buff[i++]&0x3f;
- if (nBytes > 0) {
- nBytes = (nBytes+1)&~1;
-
- BYTE* pData1 = DNew BYTE[nBytes];
- BYTE* pData2 = DNew BYTE[nBytes];
-
- if (pData1 && pData2) {
- int nBytes1 = 0, nBytes2 = 0;
-
- for (ptrdiff_t j = 0; j < nBytes && i < 0x800;) {
- if (buff[i++] == 0xff) {
- pData1[nBytes1++] = buff[i++];
- pData1[nBytes1++] = buff[i++];
- } else {
- i+=2;
- }
-
- j++;
-
- if (j >= nBytes) {
- break;
- }
-
- if (buff[i++] == 0xff) {
- pData2[nBytes2++] = buff[i++];
- pData2[nBytes2++] = buff[i++];
- } else {
- i+=2;
- }
-
- j++;
- }
-
- if (nBytes1 > 0) {
- DecodeCC(pData1, nBytes1, time);
- }
-
- if (nBytes2 > 0) {
- DecodeCC(pData2, nBytes2, time);
- }
- }
-
- if (pData1) {
- delete [] pData1;
- }
- if (pData2) {
- delete [] pData2;
- }
- }
-
- break;
- }
- }
+ for (ptrdiff_t i = 0; i < len - 9; i++) {
+ if (*(DWORD*)&buff[i] == 0xb2010000 && *(DWORD*)&buff[i + 4] == 0xf8014343) {
+ i += 8;
+ int nBytes = buff[i++] & 0x3f;
+ if (nBytes > 0) {
+ nBytes = (nBytes + 1)&~1;
+
+ BYTE* pData1 = DNew BYTE[nBytes];
+ BYTE* pData2 = DNew BYTE[nBytes];
+
+ if (pData1 && pData2) {
+ int nBytes1 = 0, nBytes2 = 0;
+
+ for (ptrdiff_t j = 0; j < nBytes && i < 0x800;) {
+ if (buff[i++] == 0xff) {
+ pData1[nBytes1++] = buff[i++];
+ pData1[nBytes1++] = buff[i++];
+ } else {
+ i += 2;
+ }
+
+ j++;
+
+ if (j >= nBytes) {
+ break;
+ }
+
+ if (buff[i++] == 0xff) {
+ pData2[nBytes2++] = buff[i++];
+ pData2[nBytes2++] = buff[i++];
+ } else {
+ i += 2;
+ }
+
+ j++;
+ }
+
+ if (nBytes1 > 0) {
+ DecodeCC(pData1, nBytes1, time);
+ }
+
+ if (nBytes2 > 0) {
+ DecodeCC(pData2, nBytes2, time);
+ }
+ }
+
+ if (pData1) {
+ delete [] pData1;
+ }
+ if (pData2) {
+ delete [] pData2;
+ }
+ }
+
+ break;
+ }
+ }
}
diff --git a/src/Subtitles/CCDecoder.h b/src/Subtitles/CCDecoder.h
index b6373edca..8e18cb902 100644
--- a/src/Subtitles/CCDecoder.h
+++ b/src/Subtitles/CCDecoder.h
@@ -27,24 +27,24 @@
class CCDecoder
{
- CSimpleTextSubtitle m_sts;
- CString m_fn, m_rawfn;
- __int64 m_time;
- bool m_fEndOfCaption;
- WCHAR m_buff[16][33], m_disp[16][33];
- CPoint m_cursor;
+ CSimpleTextSubtitle m_sts;
+ CString m_fn, m_rawfn;
+ __int64 m_time;
+ bool m_fEndOfCaption;
+ WCHAR m_buff[16][33], m_disp[16][33];
+ CPoint m_cursor;
- void SaveDisp(__int64 time);
- void MoveCursor(int x, int y);
- void OffsetCursor(int x, int y);
- void PutChar(WCHAR c);
+ void SaveDisp(__int64 time);
+ void MoveCursor(int x, int y);
+ void OffsetCursor(int x, int y);
+ void PutChar(WCHAR c);
public:
- CCDecoder(CString fn = _T(""), CString rawfn = _T(""));
- virtual ~CCDecoder();
- void DecodeCC(BYTE* buff, int len, __int64 time);
- void ExtractCC(BYTE* buff, int len, __int64 time);
- CSimpleTextSubtitle& GetSTS() {
- return m_sts;
- }
+ CCDecoder(CString fn = _T(""), CString rawfn = _T(""));
+ virtual ~CCDecoder();
+ void DecodeCC(BYTE* buff, int len, __int64 time);
+ void ExtractCC(BYTE* buff, int len, __int64 time);
+ CSimpleTextSubtitle& GetSTS() {
+ return m_sts;
+ }
};
diff --git a/src/Subtitles/CompositionObject.cpp b/src/Subtitles/CompositionObject.cpp
index e836288d2..327b8d68c 100644
--- a/src/Subtitles/CompositionObject.cpp
+++ b/src/Subtitles/CompositionObject.cpp
@@ -27,324 +27,324 @@
CompositionObject::CompositionObject()
{
- m_rtStart = 0;
- m_rtStop = 0;
- m_pRLEData = NULL;
- m_nRLEDataSize = 0;
- m_nRLEPos = 0;
- m_nColorNumber = 0;
- memsetd (m_Colors, 0xFF000000, sizeof(m_Colors));
+ m_rtStart = 0;
+ m_rtStop = 0;
+ m_pRLEData = NULL;
+ m_nRLEDataSize = 0;
+ m_nRLEPos = 0;
+ m_nColorNumber = 0;
+ memsetd(m_Colors, 0xFF000000, sizeof(m_Colors));
}
CompositionObject::~CompositionObject()
{
- delete[] m_pRLEData;
+ delete[] m_pRLEData;
}
-void CompositionObject::SetPalette (int nNbEntry, HDMV_PALETTE* pPalette, bool bIsHD)
+void CompositionObject::SetPalette(int nNbEntry, HDMV_PALETTE* pPalette, bool bIsHD)
{
- m_nColorNumber = nNbEntry;
- for (int i=0; i<nNbEntry; i++) {
- if (bIsHD) {
- m_Colors[pPalette[i].entry_id] = YCrCbToRGB_Rec709 (pPalette[i].T, pPalette[i].Y, pPalette[i].Cr, pPalette[i].Cb);
- } else {
- m_Colors[pPalette[i].entry_id] = YCrCbToRGB_Rec601 (pPalette[i].T, pPalette[i].Y, pPalette[i].Cr, pPalette[i].Cb);
- }
- }
+ m_nColorNumber = nNbEntry;
+ for (int i = 0; i < nNbEntry; i++) {
+ if (bIsHD) {
+ m_Colors[pPalette[i].entry_id] = YCrCbToRGB_Rec709(pPalette[i].T, pPalette[i].Y, pPalette[i].Cr, pPalette[i].Cb);
+ } else {
+ m_Colors[pPalette[i].entry_id] = YCrCbToRGB_Rec601(pPalette[i].T, pPalette[i].Y, pPalette[i].Cr, pPalette[i].Cb);
+ }
+ }
}
void CompositionObject::SetRLEData(BYTE* pBuffer, int nSize, int nTotalSize)
{
- delete[] m_pRLEData;
- m_pRLEData = DNew BYTE[nTotalSize];
- m_nRLEDataSize = nTotalSize;
- m_nRLEPos = nSize;
+ delete[] m_pRLEData;
+ m_pRLEData = DNew BYTE[nTotalSize];
+ m_nRLEDataSize = nTotalSize;
+ m_nRLEPos = nSize;
- memcpy (m_pRLEData, pBuffer, nSize);
+ memcpy(m_pRLEData, pBuffer, nSize);
}
void CompositionObject::AppendRLEData(BYTE* pBuffer, int nSize)
{
- ASSERT (m_nRLEPos+nSize <= m_nRLEDataSize);
- if (m_nRLEPos+nSize <= m_nRLEDataSize) {
- memcpy (m_pRLEData+m_nRLEPos, pBuffer, nSize);
- m_nRLEPos += nSize;
- }
+ ASSERT(m_nRLEPos + nSize <= m_nRLEDataSize);
+ if (m_nRLEPos + nSize <= m_nRLEDataSize) {
+ memcpy(m_pRLEData + m_nRLEPos, pBuffer, nSize);
+ m_nRLEPos += nSize;
+ }
}
void CompositionObject::RenderHdmv(SubPicDesc& spd)
{
- if (!m_pRLEData) {
- return;
- }
-
- CGolombBuffer GBuffer (m_pRLEData, m_nRLEDataSize);
- BYTE bTemp;
- BYTE bSwitch;
-
- BYTE nPaletteIndex = 0;
- SHORT nCount;
- SHORT nX = m_horizontal_position;
- SHORT nY = m_vertical_position;
-
- while ((nY < (m_vertical_position + m_height)) && !GBuffer.IsEOF()) {
- bTemp = GBuffer.ReadByte();
- if (bTemp != 0) {
- nPaletteIndex = bTemp;
- nCount = 1;
- } else {
- bSwitch = GBuffer.ReadByte();
- if (!(bSwitch & 0x80)) {
- if (!(bSwitch & 0x40)) {
- nCount = bSwitch & 0x3F;
- if (nCount > 0) {
- nPaletteIndex = 0;
- }
- } else {
- nCount = (bSwitch&0x3F) <<8 | (SHORT)GBuffer.ReadByte();
- nPaletteIndex = 0;
- }
- } else {
- if (!(bSwitch & 0x40)) {
- nCount = bSwitch & 0x3F;
- nPaletteIndex = GBuffer.ReadByte();
- } else {
- nCount = (bSwitch&0x3F) <<8 | (SHORT)GBuffer.ReadByte();
- nPaletteIndex = GBuffer.ReadByte();
- }
- }
- }
-
- if (nCount>0) {
- if (nPaletteIndex != 0xFF) { // Fully transparent (§9.14.4.2.2.1.1)
- FillSolidRect (spd, nX, nY, nCount, 1, m_Colors[nPaletteIndex]);
- }
- nX += nCount;
- } else {
- nY++;
- nX = m_horizontal_position;
- }
- }
+ if (!m_pRLEData) {
+ return;
+ }
+
+ CGolombBuffer GBuffer(m_pRLEData, m_nRLEDataSize);
+ BYTE bTemp;
+ BYTE bSwitch;
+
+ BYTE nPaletteIndex = 0;
+ SHORT nCount;
+ SHORT nX = m_horizontal_position;
+ SHORT nY = m_vertical_position;
+
+ while ((nY < (m_vertical_position + m_height)) && !GBuffer.IsEOF()) {
+ bTemp = GBuffer.ReadByte();
+ if (bTemp != 0) {
+ nPaletteIndex = bTemp;
+ nCount = 1;
+ } else {
+ bSwitch = GBuffer.ReadByte();
+ if (!(bSwitch & 0x80)) {
+ if (!(bSwitch & 0x40)) {
+ nCount = bSwitch & 0x3F;
+ if (nCount > 0) {
+ nPaletteIndex = 0;
+ }
+ } else {
+ nCount = (bSwitch & 0x3F) << 8 | (SHORT)GBuffer.ReadByte();
+ nPaletteIndex = 0;
+ }
+ } else {
+ if (!(bSwitch & 0x40)) {
+ nCount = bSwitch & 0x3F;
+ nPaletteIndex = GBuffer.ReadByte();
+ } else {
+ nCount = (bSwitch & 0x3F) << 8 | (SHORT)GBuffer.ReadByte();
+ nPaletteIndex = GBuffer.ReadByte();
+ }
+ }
+ }
+
+ if (nCount > 0) {
+ if (nPaletteIndex != 0xFF) { // Fully transparent (§9.14.4.2.2.1.1)
+ FillSolidRect(spd, nX, nY, nCount, 1, m_Colors[nPaletteIndex]);
+ }
+ nX += nCount;
+ } else {
+ nY++;
+ nX = m_horizontal_position;
+ }
+ }
}
void CompositionObject::RenderDvb(SubPicDesc& spd, SHORT nX, SHORT nY)
{
- if (!m_pRLEData) {
- return;
- }
+ if (!m_pRLEData) {
+ return;
+ }
- CGolombBuffer gb (m_pRLEData, m_nRLEDataSize);
- SHORT sTopFieldLength;
- SHORT sBottomFieldLength;
+ CGolombBuffer gb(m_pRLEData, m_nRLEDataSize);
+ SHORT sTopFieldLength;
+ SHORT sBottomFieldLength;
- sTopFieldLength = gb.ReadShort();
- sBottomFieldLength = gb.ReadShort();
+ sTopFieldLength = gb.ReadShort();
+ sBottomFieldLength = gb.ReadShort();
- DvbRenderField (spd, gb, nX, nY, sTopFieldLength);
- DvbRenderField (spd, gb, nX, nY+1, sBottomFieldLength);
+ DvbRenderField(spd, gb, nX, nY, sTopFieldLength);
+ DvbRenderField(spd, gb, nX, nY + 1, sBottomFieldLength);
}
void CompositionObject::DvbRenderField(SubPicDesc& spd, CGolombBuffer& gb, SHORT nXStart, SHORT nYStart, SHORT nLength)
{
- //FillSolidRect (spd, 0, 0, 300, 10, 0xFFFF0000); // Red opaque
- //FillSolidRect (spd, 0, 10, 300, 10, 0xCC00FF00); // Green 80%
- //FillSolidRect (spd, 0, 20, 300, 10, 0x100000FF); // Blue 60%
- //return;
- SHORT nX = nXStart;
- SHORT nY = nYStart;
- int nEnd = gb.GetPos()+nLength;
- while (gb.GetPos() < nEnd) {
- BYTE bType = gb.ReadByte();
- switch (bType) {
- case 0x10 :
- Dvb2PixelsCodeString(spd, gb, nX, nY);
- break;
- case 0x11 :
- Dvb4PixelsCodeString(spd, gb, nX, nY);
- break;
- case 0x12 :
- Dvb8PixelsCodeString(spd, gb, nX, nY);
- break;
- case 0x20 :
- gb.SkipBytes (2);
- break;
- case 0x21 :
- gb.SkipBytes (4);
- break;
- case 0x22 :
- gb.SkipBytes (16);
- break;
- case 0xF0 :
- nX = nXStart;
- nY += 2;
- break;
- default :
- ASSERT(FALSE);
- break;
- }
- }
+ //FillSolidRect (spd, 0, 0, 300, 10, 0xFFFF0000); // Red opaque
+ //FillSolidRect (spd, 0, 10, 300, 10, 0xCC00FF00); // Green 80%
+ //FillSolidRect (spd, 0, 20, 300, 10, 0x100000FF); // Blue 60%
+ //return;
+ SHORT nX = nXStart;
+ SHORT nY = nYStart;
+ int nEnd = gb.GetPos() + nLength;
+ while (gb.GetPos() < nEnd) {
+ BYTE bType = gb.ReadByte();
+ switch (bType) {
+ case 0x10 :
+ Dvb2PixelsCodeString(spd, gb, nX, nY);
+ break;
+ case 0x11 :
+ Dvb4PixelsCodeString(spd, gb, nX, nY);
+ break;
+ case 0x12 :
+ Dvb8PixelsCodeString(spd, gb, nX, nY);
+ break;
+ case 0x20 :
+ gb.SkipBytes(2);
+ break;
+ case 0x21 :
+ gb.SkipBytes(4);
+ break;
+ case 0x22 :
+ gb.SkipBytes(16);
+ break;
+ case 0xF0 :
+ nX = nXStart;
+ nY += 2;
+ break;
+ default :
+ ASSERT(FALSE);
+ break;
+ }
+ }
}
void CompositionObject::Dvb2PixelsCodeString(SubPicDesc& spd, CGolombBuffer& gb, SHORT& nX, SHORT& nY)
{
- BYTE bTemp;
- BYTE nPaletteIndex = 0;
- SHORT nCount;
- bool bQuit = false;
-
- while (!bQuit && !gb.IsEOF()) {
- nCount = 0;
- nPaletteIndex = 0;
- bTemp = (BYTE)gb.BitRead(2);
- if (bTemp != 0) {
- nPaletteIndex = bTemp;
- nCount = 1;
- } else {
- if (gb.BitRead(1) == 1) { // switch_1
- nCount = 3 + (SHORT)gb.BitRead(3); // run_length_3-9
- nPaletteIndex = (BYTE)gb.BitRead(2);
- } else {
- if (gb.BitRead(1) == 0) { // switch_2
- switch (gb.BitRead(2)) { // switch_3
- case 0 :
- bQuit = true;
- break;
- case 1 :
- nCount = 2;
- break;
- case 2 : // if (switch_3 == '10')
- nCount = 12 + (SHORT)gb.BitRead(4); // run_length_12-27
- nPaletteIndex = (BYTE)gb.BitRead(2); // 4-bit_pixel-code
- break;
- case 3 :
- nCount = 29 + gb.ReadByte(); // run_length_29-284
- nPaletteIndex = (BYTE)gb.BitRead(2); // 4-bit_pixel-code
- break;
- }
- } else {
- nCount = 1;
- }
- }
- }
-
- if (nX+nCount > m_width) {
- ASSERT (FALSE);
- break;
- }
-
- if (nCount>0) {
- FillSolidRect (spd, nX, nY, nCount, 1, m_Colors[nPaletteIndex]);
- nX += nCount;
- }
- }
-
- gb.BitByteAlign();
+ BYTE bTemp;
+ BYTE nPaletteIndex = 0;
+ SHORT nCount;
+ bool bQuit = false;
+
+ while (!bQuit && !gb.IsEOF()) {
+ nCount = 0;
+ nPaletteIndex = 0;
+ bTemp = (BYTE)gb.BitRead(2);
+ if (bTemp != 0) {
+ nPaletteIndex = bTemp;
+ nCount = 1;
+ } else {
+ if (gb.BitRead(1) == 1) { // switch_1
+ nCount = 3 + (SHORT)gb.BitRead(3); // run_length_3-9
+ nPaletteIndex = (BYTE)gb.BitRead(2);
+ } else {
+ if (gb.BitRead(1) == 0) { // switch_2
+ switch (gb.BitRead(2)) { // switch_3
+ case 0 :
+ bQuit = true;
+ break;
+ case 1 :
+ nCount = 2;
+ break;
+ case 2 : // if (switch_3 == '10')
+ nCount = 12 + (SHORT)gb.BitRead(4); // run_length_12-27
+ nPaletteIndex = (BYTE)gb.BitRead(2); // 4-bit_pixel-code
+ break;
+ case 3 :
+ nCount = 29 + gb.ReadByte(); // run_length_29-284
+ nPaletteIndex = (BYTE)gb.BitRead(2); // 4-bit_pixel-code
+ break;
+ }
+ } else {
+ nCount = 1;
+ }
+ }
+ }
+
+ if (nX + nCount > m_width) {
+ ASSERT(FALSE);
+ break;
+ }
+
+ if (nCount > 0) {
+ FillSolidRect(spd, nX, nY, nCount, 1, m_Colors[nPaletteIndex]);
+ nX += nCount;
+ }
+ }
+
+ gb.BitByteAlign();
}
void CompositionObject::Dvb4PixelsCodeString(SubPicDesc& spd, CGolombBuffer& gb, SHORT& nX, SHORT& nY)
{
- BYTE bTemp;
- BYTE nPaletteIndex = 0;
- SHORT nCount;
- bool bQuit = false;
-
- while (!bQuit && !gb.IsEOF()) {
- nCount = 0;
- nPaletteIndex = 0;
- bTemp = (BYTE)gb.BitRead(4);
- if (bTemp != 0) {
- nPaletteIndex = bTemp;
- nCount = 1;
- } else {
- if (gb.BitRead(1) == 0) { // switch_1
- nCount = (SHORT)gb.BitRead(3); // run_length_3-9
- if (nCount != 0) {
- nCount += 2;
- } else {
- bQuit = true;
- }
- } else {
- if (gb.BitRead(1) == 0) { // switch_2
- nCount = 4 + (SHORT)gb.BitRead(2); // run_length_4-7
- nPaletteIndex = (BYTE)gb.BitRead(4); // 4-bit_pixel-code
- } else {
- switch (gb.BitRead(2)) { // switch_3
- case 0 :
- nCount = 1;
- break;
- case 1 :
- nCount = 2;
- break;
- case 2 : // if (switch_3 == '10')
- nCount = 9 + (SHORT)gb.BitRead(4); // run_length_9-24
- nPaletteIndex = (BYTE)gb.BitRead(4); // 4-bit_pixel-code
- break;
- case 3 :
- nCount = 25 + gb.ReadByte(); // run_length_25-280
- nPaletteIndex = (BYTE)gb.BitRead(4); // 4-bit_pixel-code
- break;
- }
- }
- }
- }
+ BYTE bTemp;
+ BYTE nPaletteIndex = 0;
+ SHORT nCount;
+ bool bQuit = false;
+
+ while (!bQuit && !gb.IsEOF()) {
+ nCount = 0;
+ nPaletteIndex = 0;
+ bTemp = (BYTE)gb.BitRead(4);
+ if (bTemp != 0) {
+ nPaletteIndex = bTemp;
+ nCount = 1;
+ } else {
+ if (gb.BitRead(1) == 0) { // switch_1
+ nCount = (SHORT)gb.BitRead(3); // run_length_3-9
+ if (nCount != 0) {
+ nCount += 2;
+ } else {
+ bQuit = true;
+ }
+ } else {
+ if (gb.BitRead(1) == 0) { // switch_2
+ nCount = 4 + (SHORT)gb.BitRead(2); // run_length_4-7
+ nPaletteIndex = (BYTE)gb.BitRead(4); // 4-bit_pixel-code
+ } else {
+ switch (gb.BitRead(2)) { // switch_3
+ case 0 :
+ nCount = 1;
+ break;
+ case 1 :
+ nCount = 2;
+ break;
+ case 2 : // if (switch_3 == '10')
+ nCount = 9 + (SHORT)gb.BitRead(4); // run_length_9-24
+ nPaletteIndex = (BYTE)gb.BitRead(4); // 4-bit_pixel-code
+ break;
+ case 3 :
+ nCount = 25 + gb.ReadByte(); // run_length_25-280
+ nPaletteIndex = (BYTE)gb.BitRead(4); // 4-bit_pixel-code
+ break;
+ }
+ }
+ }
+ }
#if 0
- if (nX+nCount > m_width) {
- ASSERT (FALSE);
- break;
- }
+ if (nX + nCount > m_width) {
+ ASSERT(FALSE);
+ break;
+ }
#endif
- if (nCount>0) {
- FillSolidRect (spd, nX, nY, nCount, 1, m_Colors[nPaletteIndex]);
- nX += nCount;
- }
- }
+ if (nCount > 0) {
+ FillSolidRect(spd, nX, nY, nCount, 1, m_Colors[nPaletteIndex]);
+ nX += nCount;
+ }
+ }
- gb.BitByteAlign();
+ gb.BitByteAlign();
}
void CompositionObject::Dvb8PixelsCodeString(SubPicDesc& spd, CGolombBuffer& gb, SHORT& nX, SHORT& nY)
{
- BYTE bTemp;
- BYTE nPaletteIndex = 0;
- SHORT nCount;
- bool bQuit = false;
-
- while (!bQuit && !gb.IsEOF()) {
- nCount = 0;
- nPaletteIndex = 0;
- bTemp = gb.ReadByte();
- if (bTemp != 0) {
- nPaletteIndex = bTemp;
- nCount = 1;
- } else {
- if (gb.BitRead(1) == 0) { // switch_1
- nCount = (SHORT)gb.BitRead(7); // run_length_1-127
- if (nCount == 0) {
- bQuit = true;
- }
- } else {
- nCount = (SHORT)gb.BitRead(7); // run_length_3-127
- nPaletteIndex = gb.ReadByte();
- }
- }
-
- if (nX+nCount > m_width) {
- ASSERT (FALSE);
- break;
- }
-
- if (nCount>0) {
- FillSolidRect (spd, nX, nY, nCount, 1, m_Colors[nPaletteIndex]);
- nX += nCount;
- }
- }
-
- gb.BitByteAlign();
+ BYTE bTemp;
+ BYTE nPaletteIndex = 0;
+ SHORT nCount;
+ bool bQuit = false;
+
+ while (!bQuit && !gb.IsEOF()) {
+ nCount = 0;
+ nPaletteIndex = 0;
+ bTemp = gb.ReadByte();
+ if (bTemp != 0) {
+ nPaletteIndex = bTemp;
+ nCount = 1;
+ } else {
+ if (gb.BitRead(1) == 0) { // switch_1
+ nCount = (SHORT)gb.BitRead(7); // run_length_1-127
+ if (nCount == 0) {
+ bQuit = true;
+ }
+ } else {
+ nCount = (SHORT)gb.BitRead(7); // run_length_3-127
+ nPaletteIndex = gb.ReadByte();
+ }
+ }
+
+ if (nX + nCount > m_width) {
+ ASSERT(FALSE);
+ break;
+ }
+
+ if (nCount > 0) {
+ FillSolidRect(spd, nX, nY, nCount, 1, m_Colors[nPaletteIndex]);
+ nX += nCount;
+ }
+ }
+
+ gb.BitByteAlign();
}
diff --git a/src/Subtitles/CompositionObject.h b/src/Subtitles/CompositionObject.h
index df5360621..16969ebc7 100644
--- a/src/Subtitles/CompositionObject.h
+++ b/src/Subtitles/CompositionObject.h
@@ -26,11 +26,11 @@
struct HDMV_PALETTE {
- BYTE entry_id;
- BYTE Y;
- BYTE Cr;
- BYTE Cb;
- BYTE T; // HDMV rule : 0 transparent, 255 opaque (compatible DirectX)
+ BYTE entry_id;
+ BYTE Y;
+ BYTE Cr;
+ BYTE Cb;
+ BYTE T; // HDMV rule : 0 transparent, 255 opaque (compatible DirectX)
};
class CGolombBuffer;
@@ -38,55 +38,55 @@ class CGolombBuffer;
class CompositionObject : Rasterizer
{
public :
- SHORT m_object_id_ref;
- BYTE m_window_id_ref;
- bool m_object_cropped_flag;
- bool m_forced_on_flag;
- BYTE m_version_number;
- BYTE m_nObjectNumber;
+ SHORT m_object_id_ref;
+ BYTE m_window_id_ref;
+ bool m_object_cropped_flag;
+ bool m_forced_on_flag;
+ BYTE m_version_number;
+ BYTE m_nObjectNumber;
- SHORT m_horizontal_position;
- SHORT m_vertical_position;
- SHORT m_width;
- SHORT m_height;
+ SHORT m_horizontal_position;
+ SHORT m_vertical_position;
+ SHORT m_width;
+ SHORT m_height;
- SHORT m_cropping_horizontal_position;
- SHORT m_cropping_vertical_position;
- SHORT m_cropping_width;
- SHORT m_cropping_height;
+ SHORT m_cropping_horizontal_position;
+ SHORT m_cropping_vertical_position;
+ SHORT m_cropping_width;
+ SHORT m_cropping_height;
- REFERENCE_TIME m_rtStart;
- REFERENCE_TIME m_rtStop;
+ REFERENCE_TIME m_rtStart;
+ REFERENCE_TIME m_rtStop;
- CompositionObject();
- ~CompositionObject();
+ CompositionObject();
+ ~CompositionObject();
- void SetRLEData(BYTE* pBuffer, int nSize, int nTotalSize);
- void AppendRLEData(BYTE* pBuffer, int nSize);
- int GetRLEDataSize() {
- return m_nRLEDataSize;
- };
- bool IsRLEComplete() {
- return m_nRLEPos >= m_nRLEDataSize;
- };
- void RenderHdmv(SubPicDesc& spd);
- void RenderDvb(SubPicDesc& spd, SHORT nX, SHORT nY);
- void WriteSeg (SubPicDesc& spd, SHORT nX, SHORT nY, SHORT nCount, SHORT nPaletteIndex);
- void SetPalette (int nNbEntry, HDMV_PALETTE* pPalette, bool bIsHD);
- void SetPalette (int nNbEntry, DWORD* dwColors);
- bool HavePalette() {
- return m_nColorNumber>0;
- };
+ void SetRLEData(BYTE* pBuffer, int nSize, int nTotalSize);
+ void AppendRLEData(BYTE* pBuffer, int nSize);
+ int GetRLEDataSize() {
+ return m_nRLEDataSize;
+ };
+ bool IsRLEComplete() {
+ return m_nRLEPos >= m_nRLEDataSize;
+ };
+ void RenderHdmv(SubPicDesc& spd);
+ void RenderDvb(SubPicDesc& spd, SHORT nX, SHORT nY);
+ void WriteSeg(SubPicDesc& spd, SHORT nX, SHORT nY, SHORT nCount, SHORT nPaletteIndex);
+ void SetPalette(int nNbEntry, HDMV_PALETTE* pPalette, bool bIsHD);
+ void SetPalette(int nNbEntry, DWORD* dwColors);
+ bool HavePalette() {
+ return m_nColorNumber > 0;
+ };
private :
- BYTE* m_pRLEData;
- int m_nRLEDataSize;
- int m_nRLEPos;
- int m_nColorNumber;
- DWORD m_Colors[256];
+ BYTE* m_pRLEData;
+ int m_nRLEDataSize;
+ int m_nRLEPos;
+ int m_nColorNumber;
+ DWORD m_Colors[256];
- void DvbRenderField(SubPicDesc& spd, CGolombBuffer& gb, SHORT nXStart, SHORT nYStart, SHORT nLength);
- void Dvb2PixelsCodeString(SubPicDesc& spd, CGolombBuffer& gb, SHORT& nX, SHORT& nY);
- void Dvb4PixelsCodeString(SubPicDesc& spd, CGolombBuffer& gb, SHORT& nX, SHORT& nY);
- void Dvb8PixelsCodeString(SubPicDesc& spd, CGolombBuffer& gb, SHORT& nX, SHORT& nY);
+ void DvbRenderField(SubPicDesc& spd, CGolombBuffer& gb, SHORT nXStart, SHORT nYStart, SHORT nLength);
+ void Dvb2PixelsCodeString(SubPicDesc& spd, CGolombBuffer& gb, SHORT& nX, SHORT& nY);
+ void Dvb4PixelsCodeString(SubPicDesc& spd, CGolombBuffer& gb, SHORT& nX, SHORT& nY);
+ void Dvb8PixelsCodeString(SubPicDesc& spd, CGolombBuffer& gb, SHORT& nX, SHORT& nY);
};
diff --git a/src/Subtitles/DVBSub.cpp b/src/Subtitles/DVBSub.cpp
index e755222d4..00e1703bd 100644
--- a/src/Subtitles/DVBSub.cpp
+++ b/src/Subtitles/DVBSub.cpp
@@ -25,571 +25,571 @@
#include "DVBSub.h"
#include "../DSUtil/GolombBuffer.h"
-#if (0) // Set to 1 to activate DVB subtitles traces
-#define TRACE_DVB TRACE
+#if (0) // Set to 1 to activate DVB subtitles traces
+#define TRACE_DVB TRACE
#else
#define TRACE_DVB
#endif
-#define BUFFER_CHUNK_GROW 0x1000
+#define BUFFER_CHUNK_GROW 0x1000
CDVBSub::CDVBSub(void)
- : CBaseSub(ST_DVB)
+ : CBaseSub(ST_DVB)
{
- m_nBufferReadPos = 0;
- m_nBufferWritePos = 0;
- m_nBufferSize = 0;
- m_pBuffer = NULL;
+ m_nBufferReadPos = 0;
+ m_nBufferWritePos = 0;
+ m_nBufferSize = 0;
+ m_pBuffer = NULL;
}
CDVBSub::~CDVBSub(void)
{
- Reset();
- SAFE_DELETE(m_pBuffer);
+ Reset();
+ SAFE_DELETE(m_pBuffer);
}
CDVBSub::DVB_PAGE* CDVBSub::FindPage(REFERENCE_TIME rt)
{
- POSITION pos = m_Pages.GetHeadPosition();
+ POSITION pos = m_Pages.GetHeadPosition();
- while (pos) {
- DVB_PAGE* pPage = m_Pages.GetAt (pos);
+ while (pos) {
+ DVB_PAGE* pPage = m_Pages.GetAt(pos);
- if (rt >= pPage->rtStart && rt < pPage->rtStop) {
- return pPage;
- }
+ if (rt >= pPage->rtStart && rt < pPage->rtStop) {
+ return pPage;
+ }
- m_Pages.GetNext(pos);
- }
+ m_Pages.GetNext(pos);
+ }
- return NULL;
+ return NULL;
}
CDVBSub::DVB_REGION* CDVBSub::FindRegion(DVB_PAGE* pPage, BYTE bRegionId)
{
- if (pPage != NULL) {
- for (int i=0; i<pPage->RegionCount; i++) {
- if (pPage->Regions[i].Id == bRegionId) {
- return &pPage->Regions[i];
- }
- }
- }
- return NULL;
+ if (pPage != NULL) {
+ for (int i = 0; i < pPage->RegionCount; i++) {
+ if (pPage->Regions[i].Id == bRegionId) {
+ return &pPage->Regions[i];
+ }
+ }
+ }
+ return NULL;
}
CDVBSub::DVB_CLUT* CDVBSub::FindClut(DVB_PAGE* pPage, BYTE bClutId)
{
- if (pPage != NULL) {
- for (int i=0; i<pPage->RegionCount; i++) {
- if (pPage->Regions[i].CLUT_id == bClutId) {
- return &pPage->Regions[i].Clut;
- }
- }
- }
- return NULL;
+ if (pPage != NULL) {
+ for (int i = 0; i < pPage->RegionCount; i++) {
+ if (pPage->Regions[i].CLUT_id == bClutId) {
+ return &pPage->Regions[i].Clut;
+ }
+ }
+ }
+ return NULL;
}
CompositionObject* CDVBSub::FindObject(DVB_PAGE* pPage, SHORT sObjectId)
{
- if (pPage != NULL) {
- POSITION pos = pPage->Objects.GetHeadPosition();
+ if (pPage != NULL) {
+ POSITION pos = pPage->Objects.GetHeadPosition();
- while (pos) {
- CompositionObject* pObject = pPage->Objects.GetAt (pos);
+ while (pos) {
+ CompositionObject* pObject = pPage->Objects.GetAt(pos);
- if (pObject->m_object_id_ref == sObjectId) {
- return pObject;
- }
+ if (pObject->m_object_id_ref == sObjectId) {
+ return pObject;
+ }
- pPage->Objects.GetNext(pos);
- }
- }
- return NULL;
+ pPage->Objects.GetNext(pos);
+ }
+ }
+ return NULL;
}
HRESULT CDVBSub::AddToBuffer(BYTE* pData, int nSize)
{
- bool bFirstChunk = (*((LONG*)pData) & 0x00FFFFFF) == 0x000f0020; // DVB sub start with 0x20 0x00 0x0F ...
-
- if (m_nBufferWritePos > 0 || bFirstChunk) {
- if (bFirstChunk) {
- m_nBufferWritePos = 0;
- m_nBufferReadPos = 0;
- }
-
- if (m_nBufferWritePos+nSize > m_nBufferSize) {
- if (m_nBufferWritePos+nSize > 20*BUFFER_CHUNK_GROW) {
- // Too big to be a DVB sub !
- TRACE_DVB ("DVB - Too much data receive...\n");
- ASSERT (FALSE);
-
- Reset();
- return E_INVALIDARG;
- }
-
- BYTE* pPrev = m_pBuffer;
- m_nBufferSize = max (m_nBufferWritePos+nSize, m_nBufferSize+BUFFER_CHUNK_GROW);
- m_pBuffer = DNew BYTE[m_nBufferSize];
- if (pPrev != NULL) {
- memcpy_s (m_pBuffer, m_nBufferSize, pPrev, m_nBufferWritePos);
- SAFE_DELETE (pPrev);
- }
- }
- memcpy_s (m_pBuffer+m_nBufferWritePos, m_nBufferSize, pData, nSize);
- m_nBufferWritePos += nSize;
- return S_OK;
- }
- return S_FALSE;
+ bool bFirstChunk = (*((LONG*)pData) & 0x00FFFFFF) == 0x000f0020; // DVB sub start with 0x20 0x00 0x0F ...
+
+ if (m_nBufferWritePos > 0 || bFirstChunk) {
+ if (bFirstChunk) {
+ m_nBufferWritePos = 0;
+ m_nBufferReadPos = 0;
+ }
+
+ if (m_nBufferWritePos + nSize > m_nBufferSize) {
+ if (m_nBufferWritePos + nSize > 20 * BUFFER_CHUNK_GROW) {
+ // Too big to be a DVB sub !
+ TRACE_DVB("DVB - Too much data receive...\n");
+ ASSERT(FALSE);
+
+ Reset();
+ return E_INVALIDARG;
+ }
+
+ BYTE* pPrev = m_pBuffer;
+ m_nBufferSize = max(m_nBufferWritePos + nSize, m_nBufferSize + BUFFER_CHUNK_GROW);
+ m_pBuffer = DNew BYTE[m_nBufferSize];
+ if (pPrev != NULL) {
+ memcpy_s(m_pBuffer, m_nBufferSize, pPrev, m_nBufferWritePos);
+ SAFE_DELETE(pPrev);
+ }
+ }
+ memcpy_s(m_pBuffer + m_nBufferWritePos, m_nBufferSize, pData, nSize);
+ m_nBufferWritePos += nSize;
+ return S_OK;
+ }
+ return S_FALSE;
}
#define MARKER if (gb.BitRead(1) != 1) {ASSERT(0); return E_FAIL;}
HRESULT CDVBSub::ParseSample(IMediaSample* pSample)
{
- CheckPointer (pSample, E_POINTER);
- HRESULT hr;
- BYTE* pData = NULL;
- int nSize;
- DVB_SEGMENT_TYPE nCurSegment;
-
- hr = pSample->GetPointer(&pData);
- if (FAILED(hr) || pData == NULL) {
- return hr;
- }
- nSize = pSample->GetActualDataLength();
-
- if (*((LONG*)pData) == 0xBD010000) {
- CGolombBuffer gb (pData, nSize);
-
- gb.SkipBytes(4);
- WORD wLength = (WORD)gb.BitRead(16);
- UNREFERENCED_PARAMETER(wLength);
-
- if (gb.BitRead(2) != 2) {
- return E_FAIL; // type
- }
-
- gb.BitRead(2); // scrambling
- gb.BitRead(1); // priority
- gb.BitRead(1); // alignment
- gb.BitRead(1); // copyright
- gb.BitRead(1); // original
- BYTE fpts = (BYTE)gb.BitRead(1); // fpts
- BYTE fdts = (BYTE)gb.BitRead(1); // fdts
- gb.BitRead(1); // escr
- gb.BitRead(1); // esrate
- gb.BitRead(1); // dsmtrickmode
- gb.BitRead(1); // morecopyright
- gb.BitRead(1); // crc
- gb.BitRead(1); // extension
- gb.BitRead(8); // hdrlen
-
- if (fpts) {
- BYTE b = (BYTE)gb.BitRead(4);
- if (!(fdts && b == 3 || !fdts && b == 2)) {
- ASSERT(0);
- return E_FAIL;
- }
-
- REFERENCE_TIME pts = 0;
- pts |= gb.BitRead(3) << 30;
- MARKER; // 32..30
- pts |= gb.BitRead(15) << 15;
- MARKER; // 29..15
- pts |= gb.BitRead(15);
- MARKER; // 14..0
- pts = 10000*pts/90;
-
- m_rtStart = pts;
- m_rtStop = pts+1;
- } else {
- m_rtStart = INVALID_TIME;
- m_rtStop = INVALID_TIME;
- }
-
- nSize -= 14;
- pData += 14;
- pSample->GetTime(&m_rtStart, &m_rtStop);
- pSample->GetMediaTime(&m_rtStart, &m_rtStop);
- } else if (SUCCEEDED (pSample->GetTime(&m_rtStart, &m_rtStop))) {
- pSample->SetTime(&m_rtStart, &m_rtStop);
- }
-
- //FILE* hFile = fopen ("D:\\Sources\\mpc-hc\\A garder\\TestSubRip\\dvbsub.dat", "ab");
- //if (hFile != NULL)
- //{
- // //BYTE Buff[5] = {48};
-
- // //*((DWORD*)(Buff+1)) = lSampleLen;
- // //fwrite (Buff, 1, sizeof(Buff), hFile);
- // fwrite (pData, 1, lSampleLen, hFile);
- // fclose(hFile);
- //}
-
- if (AddToBuffer (pData, nSize) == S_OK) {
- CGolombBuffer gb (m_pBuffer+m_nBufferReadPos, m_nBufferWritePos-m_nBufferReadPos);
- int nLastPos = 0;
-
- while (!gb.IsEOF()) {
- if (gb.ReadByte() == 0x0F) {
- TRACE_DVB ("DVB - ParseSample\n");
-
- WORD wPageId;
- WORD wSegLength;
-
- nCurSegment = (DVB_SEGMENT_TYPE) gb.ReadByte();
- wPageId = gb.ReadShort();
- wSegLength = gb.ReadShort();
-
- if (gb.RemainingSize() < wSegLength) {
- hr = S_FALSE;
- break;
- }
-
- switch (nCurSegment) {
- case PAGE : {
- CAutoPtr<DVB_PAGE> pPage;
- ParsePage(gb, wSegLength, pPage);
-
- if (pPage->PageState == DPS_ACQUISITION) {
- if (m_pCurrentPage != NULL) {
- m_pCurrentPage->rtStop = max(m_pCurrentPage->rtStop, m_rtStart);
- m_Pages.AddTail (m_pCurrentPage.Detach());
- }
- UpdateTimeStamp(m_rtStart);
-
- m_pCurrentPage = pPage;
- m_pCurrentPage->rtStart = m_rtStart;
- m_pCurrentPage->rtStop = m_pCurrentPage->rtStart + m_pCurrentPage->PageTimeOut * 1000000;
-
- TRACE_DVB ("DVB - Page started %S, TimeOut = %d\n", ReftimeToString(m_rtStart), m_pCurrentPage->PageTimeOut);
- } else {
- TRACE_DVB ("DVB - Page update\n");
-
- if (m_pCurrentPage && !m_pCurrentPage->RegionCount) {
- m_pCurrentPage = pPage;
- m_pCurrentPage->rtStart = m_rtStart;
- m_pCurrentPage->rtStop = m_pCurrentPage->rtStart + m_pCurrentPage->PageTimeOut * 1000000;
-
- TRACE_DVB ("DVB - Page started[update] %S, TimeOut = %d\n", ReftimeToString(m_rtStart), m_pCurrentPage->PageTimeOut);
- }
- }
- }
- break;
- case REGION :
- ParseRegion(gb, wSegLength);
- TRACE_DVB ("DVB - Region\n");
- break;
- case CLUT :
- ParseClut(gb, wSegLength);
- TRACE_DVB ("DVB - Clut\n");
- break;
- case OBJECT :
- ParseObject(gb, wSegLength);
- TRACE_DVB ("DVB - Object\n");
- break;
- case DISPLAY :
- ParseDisplay(gb, wSegLength);
- TRACE_DVB ("DVB - Display\n");
- break;
- case END_OF_DISPLAY :
- if (m_pCurrentPage != NULL && (m_pCurrentPage->rtStart != m_rtStart)) {
- m_pCurrentPage->rtStop = max(m_pCurrentPage->rtStop, m_rtStart);
- TRACE_DVB ("DVB - End display %S - %S\n", ReftimeToString(m_pCurrentPage->rtStart), ReftimeToString(m_pCurrentPage->rtStop));
- m_Pages.AddTail (m_pCurrentPage.Detach());
- }
- break;
- default :
- break;
- }
- nLastPos = gb.GetPos();
- }
- }
- m_nBufferReadPos += nLastPos;
- }
-
- return hr;
+ CheckPointer(pSample, E_POINTER);
+ HRESULT hr;
+ BYTE* pData = NULL;
+ int nSize;
+ DVB_SEGMENT_TYPE nCurSegment;
+
+ hr = pSample->GetPointer(&pData);
+ if (FAILED(hr) || pData == NULL) {
+ return hr;
+ }
+ nSize = pSample->GetActualDataLength();
+
+ if (*((LONG*)pData) == 0xBD010000) {
+ CGolombBuffer gb(pData, nSize);
+
+ gb.SkipBytes(4);
+ WORD wLength = (WORD)gb.BitRead(16);
+ UNREFERENCED_PARAMETER(wLength);
+
+ if (gb.BitRead(2) != 2) {
+ return E_FAIL; // type
+ }
+
+ gb.BitRead(2); // scrambling
+ gb.BitRead(1); // priority
+ gb.BitRead(1); // alignment
+ gb.BitRead(1); // copyright
+ gb.BitRead(1); // original
+ BYTE fpts = (BYTE)gb.BitRead(1); // fpts
+ BYTE fdts = (BYTE)gb.BitRead(1); // fdts
+ gb.BitRead(1); // escr
+ gb.BitRead(1); // esrate
+ gb.BitRead(1); // dsmtrickmode
+ gb.BitRead(1); // morecopyright
+ gb.BitRead(1); // crc
+ gb.BitRead(1); // extension
+ gb.BitRead(8); // hdrlen
+
+ if (fpts) {
+ BYTE b = (BYTE)gb.BitRead(4);
+ if (!(fdts && b == 3 || !fdts && b == 2)) {
+ ASSERT(0);
+ return E_FAIL;
+ }
+
+ REFERENCE_TIME pts = 0;
+ pts |= gb.BitRead(3) << 30;
+ MARKER; // 32..30
+ pts |= gb.BitRead(15) << 15;
+ MARKER; // 29..15
+ pts |= gb.BitRead(15);
+ MARKER; // 14..0
+ pts = 10000 * pts / 90;
+
+ m_rtStart = pts;
+ m_rtStop = pts + 1;
+ } else {
+ m_rtStart = INVALID_TIME;
+ m_rtStop = INVALID_TIME;
+ }
+
+ nSize -= 14;
+ pData += 14;
+ pSample->GetTime(&m_rtStart, &m_rtStop);
+ pSample->GetMediaTime(&m_rtStart, &m_rtStop);
+ } else if (SUCCEEDED(pSample->GetTime(&m_rtStart, &m_rtStop))) {
+ pSample->SetTime(&m_rtStart, &m_rtStop);
+ }
+
+ //FILE* hFile = fopen ("D:\\Sources\\mpc-hc\\A garder\\TestSubRip\\dvbsub.dat", "ab");
+ //if (hFile != NULL)
+ //{
+ // //BYTE Buff[5] = {48};
+
+ // //*((DWORD*)(Buff+1)) = lSampleLen;
+ // //fwrite (Buff, 1, sizeof(Buff), hFile);
+ // fwrite (pData, 1, lSampleLen, hFile);
+ // fclose(hFile);
+ //}
+
+ if (AddToBuffer(pData, nSize) == S_OK) {
+ CGolombBuffer gb(m_pBuffer + m_nBufferReadPos, m_nBufferWritePos - m_nBufferReadPos);
+ int nLastPos = 0;
+
+ while (!gb.IsEOF()) {
+ if (gb.ReadByte() == 0x0F) {
+ TRACE_DVB("DVB - ParseSample\n");
+
+ WORD wPageId;
+ WORD wSegLength;
+
+ nCurSegment = (DVB_SEGMENT_TYPE) gb.ReadByte();
+ wPageId = gb.ReadShort();
+ wSegLength = gb.ReadShort();
+
+ if (gb.RemainingSize() < wSegLength) {
+ hr = S_FALSE;
+ break;
+ }
+
+ switch (nCurSegment) {
+ case PAGE : {
+ CAutoPtr<DVB_PAGE> pPage;
+ ParsePage(gb, wSegLength, pPage);
+
+ if (pPage->PageState == DPS_ACQUISITION) {
+ if (m_pCurrentPage != NULL) {
+ m_pCurrentPage->rtStop = max(m_pCurrentPage->rtStop, m_rtStart);
+ m_Pages.AddTail(m_pCurrentPage.Detach());
+ }
+ UpdateTimeStamp(m_rtStart);
+
+ m_pCurrentPage = pPage;
+ m_pCurrentPage->rtStart = m_rtStart;
+ m_pCurrentPage->rtStop = m_pCurrentPage->rtStart + m_pCurrentPage->PageTimeOut * 1000000;
+
+ TRACE_DVB("DVB - Page started %S, TimeOut = %d\n", ReftimeToString(m_rtStart), m_pCurrentPage->PageTimeOut);
+ } else {
+ TRACE_DVB("DVB - Page update\n");
+
+ if (m_pCurrentPage && !m_pCurrentPage->RegionCount) {
+ m_pCurrentPage = pPage;
+ m_pCurrentPage->rtStart = m_rtStart;
+ m_pCurrentPage->rtStop = m_pCurrentPage->rtStart + m_pCurrentPage->PageTimeOut * 1000000;
+
+ TRACE_DVB("DVB - Page started[update] %S, TimeOut = %d\n", ReftimeToString(m_rtStart), m_pCurrentPage->PageTimeOut);
+ }
+ }
+ }
+ break;
+ case REGION :
+ ParseRegion(gb, wSegLength);
+ TRACE_DVB("DVB - Region\n");
+ break;
+ case CLUT :
+ ParseClut(gb, wSegLength);
+ TRACE_DVB("DVB - Clut\n");
+ break;
+ case OBJECT :
+ ParseObject(gb, wSegLength);
+ TRACE_DVB("DVB - Object\n");
+ break;
+ case DISPLAY :
+ ParseDisplay(gb, wSegLength);
+ TRACE_DVB("DVB - Display\n");
+ break;
+ case END_OF_DISPLAY :
+ if (m_pCurrentPage != NULL && (m_pCurrentPage->rtStart != m_rtStart)) {
+ m_pCurrentPage->rtStop = max(m_pCurrentPage->rtStop, m_rtStart);
+ TRACE_DVB("DVB - End display %S - %S\n", ReftimeToString(m_pCurrentPage->rtStart), ReftimeToString(m_pCurrentPage->rtStop));
+ m_Pages.AddTail(m_pCurrentPage.Detach());
+ }
+ break;
+ default :
+ break;
+ }
+ nLastPos = gb.GetPos();
+ }
+ }
+ m_nBufferReadPos += nLastPos;
+ }
+
+ return hr;
}
void CDVBSub::Render(SubPicDesc& spd, REFERENCE_TIME rt, RECT& bbox)
{
- DVB_PAGE* pPage = FindPage (rt);
-
- if (pPage != NULL) {
- pPage->Rendered = true;
- for (int i=0; i<pPage->RegionCount; i++) {
- CDVBSub::DVB_REGION* pRegion = &pPage->Regions[i];
- for (int j=0; j<pRegion->ObjectCount; j++) {
- CompositionObject* pObject = FindObject (pPage, pRegion->Objects[j].object_id);
- if (pObject) {
- SHORT nX, nY;
- nX = pRegion->HorizAddr + pRegion->Objects[j].object_horizontal_position;
- nY = pRegion->VertAddr + pRegion->Objects[j].object_vertical_position;
- pObject->m_width = pRegion->width;
- pObject->m_height = pRegion->height;
- pObject->SetPalette(pRegion->Clut.Size, pRegion->Clut.Palette, m_Display.width > 720);
- pObject->RenderDvb(spd, nX, nY);
- }
- }
- }
-
- bbox.left = 0;
- bbox.top = 0;
- bbox.right = m_Display.width;
- bbox.bottom = m_Display.height;
-
- }
+ DVB_PAGE* pPage = FindPage(rt);
+
+ if (pPage != NULL) {
+ pPage->Rendered = true;
+ for (int i = 0; i < pPage->RegionCount; i++) {
+ CDVBSub::DVB_REGION* pRegion = &pPage->Regions[i];
+ for (int j = 0; j < pRegion->ObjectCount; j++) {
+ CompositionObject* pObject = FindObject(pPage, pRegion->Objects[j].object_id);
+ if (pObject) {
+ SHORT nX, nY;
+ nX = pRegion->HorizAddr + pRegion->Objects[j].object_horizontal_position;
+ nY = pRegion->VertAddr + pRegion->Objects[j].object_vertical_position;
+ pObject->m_width = pRegion->width;
+ pObject->m_height = pRegion->height;
+ pObject->SetPalette(pRegion->Clut.Size, pRegion->Clut.Palette, m_Display.width > 720);
+ pObject->RenderDvb(spd, nX, nY);
+ }
+ }
+ }
+
+ bbox.left = 0;
+ bbox.top = 0;
+ bbox.right = m_Display.width;
+ bbox.bottom = m_Display.height;
+
+ }
}
HRESULT CDVBSub::GetTextureSize(POSITION pos, SIZE& MaxTextureSize, SIZE& VideoSize, POINT& VideoTopLeft)
{
- MaxTextureSize.cx = VideoSize.cx = m_Display.width;
- MaxTextureSize.cy = VideoSize.cy = m_Display.height;
+ MaxTextureSize.cx = VideoSize.cx = m_Display.width;
+ MaxTextureSize.cy = VideoSize.cy = m_Display.height;
- VideoTopLeft.x = 0;
- VideoTopLeft.y = 0;
+ VideoTopLeft.x = 0;
+ VideoTopLeft.y = 0;
- return S_OK;
+ return S_OK;
}
POSITION CDVBSub::GetStartPosition(REFERENCE_TIME rt, double fps)
{
- DVB_PAGE* pPage;
-
- // Cleanup old PG
- while (m_Pages.GetCount()>0) {
- pPage = m_Pages.GetHead();
- if (pPage->rtStop < rt) {
- if (!pPage->Rendered) {
- TRACE_DVB ("DVB - remove unrendered object, %S - %S\n", ReftimeToString(pPage->rtStart), ReftimeToString(pPage->rtStop));
- }
- m_Pages.RemoveHead();
- delete pPage;
- } else {
- break;
- }
- }
-
- return m_Pages.GetHeadPosition();
+ DVB_PAGE* pPage;
+
+ // Cleanup old PG
+ while (m_Pages.GetCount() > 0) {
+ pPage = m_Pages.GetHead();
+ if (pPage->rtStop < rt) {
+ if (!pPage->Rendered) {
+ TRACE_DVB("DVB - remove unrendered object, %S - %S\n", ReftimeToString(pPage->rtStart), ReftimeToString(pPage->rtStop));
+ }
+ m_Pages.RemoveHead();
+ delete pPage;
+ } else {
+ break;
+ }
+ }
+
+ return m_Pages.GetHeadPosition();
}
POSITION CDVBSub::GetNext(POSITION pos)
{
- m_Pages.GetNext(pos);
- return pos;
+ m_Pages.GetNext(pos);
+ return pos;
}
REFERENCE_TIME CDVBSub::GetStart(POSITION nPos)
{
- DVB_PAGE* pPage = m_Pages.GetAt(nPos);
- return pPage!=NULL ? pPage->rtStart : INVALID_TIME;
+ DVB_PAGE* pPage = m_Pages.GetAt(nPos);
+ return pPage != NULL ? pPage->rtStart : INVALID_TIME;
}
REFERENCE_TIME CDVBSub::GetStop(POSITION nPos)
{
- DVB_PAGE* pPage = m_Pages.GetAt(nPos);
- return pPage!=NULL ? pPage->rtStop : INVALID_TIME;
+ DVB_PAGE* pPage = m_Pages.GetAt(nPos);
+ return pPage != NULL ? pPage->rtStop : INVALID_TIME;
}
void CDVBSub::Reset()
{
- m_nBufferReadPos = 0;
- m_nBufferWritePos = 0;
- m_pCurrentPage.Free();
+ m_nBufferReadPos = 0;
+ m_nBufferWritePos = 0;
+ m_pCurrentPage.Free();
- DVB_PAGE* pPage;
- while (m_Pages.GetCount() > 0) {
- pPage = m_Pages.RemoveHead();
- delete pPage;
- }
+ DVB_PAGE* pPage;
+ while (m_Pages.GetCount() > 0) {
+ pPage = m_Pages.RemoveHead();
+ delete pPage;
+ }
}
HRESULT CDVBSub::ParsePage(CGolombBuffer& gb, WORD wSegLength, CAutoPtr<DVB_PAGE>& pPage)
{
- int nEnd = gb.GetPos() + wSegLength;
- int nPos = 0;
-
- pPage.Attach (DNew DVB_PAGE());
- pPage->PageTimeOut = gb.ReadByte();
- pPage->PageVersionNumber = (BYTE)gb.BitRead(4);
- pPage->PageState = (BYTE)gb.BitRead(2);
- pPage->RegionCount = 0;
- gb.BitRead(2); // Reserved
- while (gb.GetPos() < nEnd) {
- if (nPos < MAX_REGIONS) {
- pPage->Regions[nPos].Id = gb.ReadByte();
- gb.ReadByte(); // Reserved
- pPage->Regions[nPos].HorizAddr = gb.ReadShort();
- pPage->Regions[nPos].VertAddr = gb.ReadShort();
- pPage->RegionCount++;
- }
- nPos++;
- }
-
- return S_OK;
+ int nEnd = gb.GetPos() + wSegLength;
+ int nPos = 0;
+
+ pPage.Attach(DNew DVB_PAGE());
+ pPage->PageTimeOut = gb.ReadByte();
+ pPage->PageVersionNumber = (BYTE)gb.BitRead(4);
+ pPage->PageState = (BYTE)gb.BitRead(2);
+ pPage->RegionCount = 0;
+ gb.BitRead(2); // Reserved
+ while (gb.GetPos() < nEnd) {
+ if (nPos < MAX_REGIONS) {
+ pPage->Regions[nPos].Id = gb.ReadByte();
+ gb.ReadByte(); // Reserved
+ pPage->Regions[nPos].HorizAddr = gb.ReadShort();
+ pPage->Regions[nPos].VertAddr = gb.ReadShort();
+ pPage->RegionCount++;
+ }
+ nPos++;
+ }
+
+ return S_OK;
}
HRESULT CDVBSub::ParseDisplay(CGolombBuffer& gb, WORD wSegLength)
{
- m_Display.version_number = (BYTE)gb.BitRead (4);
- m_Display.display_window_flag = (BYTE)gb.BitRead (1);
- gb.BitRead(3); // reserved
- m_Display.width = gb.ReadShort();
- m_Display.height = gb.ReadShort();
- if (m_Display.display_window_flag) {
- m_Display.horizontal_position_minimun = gb.ReadShort();
- m_Display.horizontal_position_maximum = gb.ReadShort();
- m_Display.vertical_position_minimun = gb.ReadShort();
- m_Display.vertical_position_maximum = gb.ReadShort();
- }
-
- return S_OK;
+ m_Display.version_number = (BYTE)gb.BitRead(4);
+ m_Display.display_window_flag = (BYTE)gb.BitRead(1);
+ gb.BitRead(3); // reserved
+ m_Display.width = gb.ReadShort();
+ m_Display.height = gb.ReadShort();
+ if (m_Display.display_window_flag) {
+ m_Display.horizontal_position_minimun = gb.ReadShort();
+ m_Display.horizontal_position_maximum = gb.ReadShort();
+ m_Display.vertical_position_minimun = gb.ReadShort();
+ m_Display.vertical_position_maximum = gb.ReadShort();
+ }
+
+ return S_OK;
}
HRESULT CDVBSub::ParseRegion(CGolombBuffer& gb, WORD wSegLength)
{
- int nEnd = gb.GetPos() + wSegLength;
- CDVBSub::DVB_REGION* pRegion;
- CDVBSub::DVB_REGION DummyRegion;
-
- pRegion = FindRegion (m_pCurrentPage, gb.ReadByte());
-
- if (pRegion == NULL) {
- pRegion = &DummyRegion;
- }
-
- if (pRegion != NULL) {
- pRegion->version_number = (BYTE)gb.BitRead(4);
- pRegion->fill_flag = (BYTE)gb.BitRead(1);
- gb.BitRead(3); // Reserved
- pRegion->width = gb.ReadShort();
- pRegion->height = gb.ReadShort();
- pRegion->level_of_compatibility = (BYTE)gb.BitRead(3);
- pRegion->depth = (BYTE)gb.BitRead(3);
- gb.BitRead(2); // Reserved
- pRegion->CLUT_id = gb.ReadByte();
- pRegion->_8_bit_pixel_code = gb.ReadByte();
- pRegion->_4_bit_pixel_code = (BYTE)gb.BitRead(4);
- pRegion->_2_bit_pixel_code = (BYTE)gb.BitRead(2);
- gb.BitRead(2); // Reserved
-
- pRegion->ObjectCount = 0;
- while (gb.GetPos() < nEnd) {
- DVB_OBJECT* pObject = &pRegion->Objects[pRegion->ObjectCount];
- pObject->object_id = gb.ReadShort();
- pObject->object_type = (BYTE)gb.BitRead(2);
- pObject->object_provider_flag = (BYTE)gb.BitRead(2);
- pObject->object_horizontal_position = (SHORT)gb.BitRead(12);
- gb.BitRead(4); // Reserved
- pObject->object_vertical_position = (SHORT)gb.BitRead(12);
- if (pObject->object_type == 0x01 || pObject->object_type == 0x02) {
- pObject->foreground_pixel_code = gb.ReadByte();
- pObject->background_pixel_code = gb.ReadByte();
- }
- pRegion->ObjectCount++;
- }
- } else {
- gb.SkipBytes (wSegLength-1);
- }
-
- return S_OK;
+ int nEnd = gb.GetPos() + wSegLength;
+ CDVBSub::DVB_REGION* pRegion;
+ CDVBSub::DVB_REGION DummyRegion;
+
+ pRegion = FindRegion(m_pCurrentPage, gb.ReadByte());
+
+ if (pRegion == NULL) {
+ pRegion = &DummyRegion;
+ }
+
+ if (pRegion != NULL) {
+ pRegion->version_number = (BYTE)gb.BitRead(4);
+ pRegion->fill_flag = (BYTE)gb.BitRead(1);
+ gb.BitRead(3); // Reserved
+ pRegion->width = gb.ReadShort();
+ pRegion->height = gb.ReadShort();
+ pRegion->level_of_compatibility = (BYTE)gb.BitRead(3);
+ pRegion->depth = (BYTE)gb.BitRead(3);
+ gb.BitRead(2); // Reserved
+ pRegion->CLUT_id = gb.ReadByte();
+ pRegion->_8_bit_pixel_code = gb.ReadByte();
+ pRegion->_4_bit_pixel_code = (BYTE)gb.BitRead(4);
+ pRegion->_2_bit_pixel_code = (BYTE)gb.BitRead(2);
+ gb.BitRead(2); // Reserved
+
+ pRegion->ObjectCount = 0;
+ while (gb.GetPos() < nEnd) {
+ DVB_OBJECT* pObject = &pRegion->Objects[pRegion->ObjectCount];
+ pObject->object_id = gb.ReadShort();
+ pObject->object_type = (BYTE)gb.BitRead(2);
+ pObject->object_provider_flag = (BYTE)gb.BitRead(2);
+ pObject->object_horizontal_position = (SHORT)gb.BitRead(12);
+ gb.BitRead(4); // Reserved
+ pObject->object_vertical_position = (SHORT)gb.BitRead(12);
+ if (pObject->object_type == 0x01 || pObject->object_type == 0x02) {
+ pObject->foreground_pixel_code = gb.ReadByte();
+ pObject->background_pixel_code = gb.ReadByte();
+ }
+ pRegion->ObjectCount++;
+ }
+ } else {
+ gb.SkipBytes(wSegLength - 1);
+ }
+
+ return S_OK;
}
HRESULT CDVBSub::ParseClut(CGolombBuffer& gb, WORD wSegLength)
{
- HRESULT hr = S_OK;
- int nEnd = gb.GetPos() + wSegLength;
- CDVBSub::DVB_CLUT* pClut;
-
- pClut = FindClut (m_pCurrentPage, gb.ReadByte());
- // ASSERT (pClut != NULL);
- if (pClut != NULL) {
- pClut->version_number = (BYTE)gb.BitRead(4);
- gb.BitRead(4); // Reserved
-
- pClut->Size = 0;
- while (gb.GetPos() < nEnd) {
- BYTE entry_id = gb.ReadByte();
- BYTE _2_bit = (BYTE)gb.BitRead(1);
- BYTE _4_bit = (BYTE)gb.BitRead(1);
- BYTE _8_bit = (BYTE)gb.BitRead(1);
- UNREFERENCED_PARAMETER(_2_bit);
- UNREFERENCED_PARAMETER(_4_bit);
- UNREFERENCED_PARAMETER(_8_bit);
- gb.BitRead(4); // Reserved
-
- pClut->Palette[entry_id].entry_id = entry_id;
- if (gb.BitRead(1)) {
- pClut->Palette[entry_id].Y = gb.ReadByte();
- pClut->Palette[entry_id].Cr = gb.ReadByte();
- pClut->Palette[entry_id].Cb = gb.ReadByte();
- pClut->Palette[entry_id].T = 0xff-gb.ReadByte();
- } else {
- pClut->Palette[entry_id].Y = (BYTE)gb.BitRead(6)<<2;
- pClut->Palette[entry_id].Cr = (BYTE)gb.BitRead(4)<<4;
- pClut->Palette[entry_id].Cb = (BYTE)gb.BitRead(4)<<4;
- pClut->Palette[entry_id].T = 0xff-((BYTE)gb.BitRead(2)<<6);
- }
- if (!pClut->Palette[entry_id].Y) {
- pClut->Palette[entry_id].Cr = 0;
- pClut->Palette[entry_id].Cb = 0;
- pClut->Palette[entry_id].T = 0;
- }
-
- if (pClut->Size <= entry_id) {
- pClut->Size = entry_id+1;
- }
- }
- }
-
- return hr;
+ HRESULT hr = S_OK;
+ int nEnd = gb.GetPos() + wSegLength;
+ CDVBSub::DVB_CLUT* pClut;
+
+ pClut = FindClut(m_pCurrentPage, gb.ReadByte());
+ // ASSERT (pClut != NULL);
+ if (pClut != NULL) {
+ pClut->version_number = (BYTE)gb.BitRead(4);
+ gb.BitRead(4); // Reserved
+
+ pClut->Size = 0;
+ while (gb.GetPos() < nEnd) {
+ BYTE entry_id = gb.ReadByte();
+ BYTE _2_bit = (BYTE)gb.BitRead(1);
+ BYTE _4_bit = (BYTE)gb.BitRead(1);
+ BYTE _8_bit = (BYTE)gb.BitRead(1);
+ UNREFERENCED_PARAMETER(_2_bit);
+ UNREFERENCED_PARAMETER(_4_bit);
+ UNREFERENCED_PARAMETER(_8_bit);
+ gb.BitRead(4); // Reserved
+
+ pClut->Palette[entry_id].entry_id = entry_id;
+ if (gb.BitRead(1)) {
+ pClut->Palette[entry_id].Y = gb.ReadByte();
+ pClut->Palette[entry_id].Cr = gb.ReadByte();
+ pClut->Palette[entry_id].Cb = gb.ReadByte();
+ pClut->Palette[entry_id].T = 0xff - gb.ReadByte();
+ } else {
+ pClut->Palette[entry_id].Y = (BYTE)gb.BitRead(6) << 2;
+ pClut->Palette[entry_id].Cr = (BYTE)gb.BitRead(4) << 4;
+ pClut->Palette[entry_id].Cb = (BYTE)gb.BitRead(4) << 4;
+ pClut->Palette[entry_id].T = 0xff - ((BYTE)gb.BitRead(2) << 6);
+ }
+ if (!pClut->Palette[entry_id].Y) {
+ pClut->Palette[entry_id].Cr = 0;
+ pClut->Palette[entry_id].Cb = 0;
+ pClut->Palette[entry_id].T = 0;
+ }
+
+ if (pClut->Size <= entry_id) {
+ pClut->Size = entry_id + 1;
+ }
+ }
+ }
+
+ return hr;
}
HRESULT CDVBSub::ParseObject(CGolombBuffer& gb, WORD wSegLength)
{
- HRESULT hr = E_FAIL;
+ HRESULT hr = E_FAIL;
- if (m_pCurrentPage && wSegLength > 2) {
- CompositionObject* pObject = DNew CompositionObject();
- BYTE object_coding_method;
+ if (m_pCurrentPage && wSegLength > 2) {
+ CompositionObject* pObject = DNew CompositionObject();
+ BYTE object_coding_method;
- pObject->m_object_id_ref = gb.ReadShort();
- pObject->m_version_number = (BYTE)gb.BitRead(4);
+ pObject->m_object_id_ref = gb.ReadShort();
+ pObject->m_version_number = (BYTE)gb.BitRead(4);
- object_coding_method = (BYTE)gb.BitRead(2); // object_coding_method
- gb.BitRead(1); // non_modifying_colour_flag
- gb.BitRead(1); // reserved
+ object_coding_method = (BYTE)gb.BitRead(2); // object_coding_method
+ gb.BitRead(1); // non_modifying_colour_flag
+ gb.BitRead(1); // reserved
- if (object_coding_method == 0x00) {
- pObject->SetRLEData (gb.GetBufferPos(), wSegLength-3, wSegLength-3);
- gb.SkipBytes(wSegLength-3);
- m_pCurrentPage->Objects.AddTail (pObject);
- hr = S_OK;
- } else {
- delete pObject;
- hr = E_NOTIMPL;
- }
- }
+ if (object_coding_method == 0x00) {
+ pObject->SetRLEData(gb.GetBufferPos(), wSegLength - 3, wSegLength - 3);
+ gb.SkipBytes(wSegLength - 3);
+ m_pCurrentPage->Objects.AddTail(pObject);
+ hr = S_OK;
+ } else {
+ delete pObject;
+ hr = E_NOTIMPL;
+ }
+ }
- return hr;
+ return hr;
}
HRESULT CDVBSub::UpdateTimeStamp(REFERENCE_TIME rtStop)
{
- HRESULT hr = E_FAIL;
- POSITION pos = m_Pages.GetHeadPosition();
- while (pos) {
- DVB_PAGE* pPage = m_Pages.GetAt (pos);
- if (pPage->rtStop > rtStop) {
- pPage->rtStop = rtStop;
- hr = S_OK;
- }
- m_Pages.GetNext(pos);
- }
-
- return hr;
+ HRESULT hr = E_FAIL;
+ POSITION pos = m_Pages.GetHeadPosition();
+ while (pos) {
+ DVB_PAGE* pPage = m_Pages.GetAt(pos);
+ if (pPage->rtStop > rtStop) {
+ pPage->rtStop = rtStop;
+ hr = S_OK;
+ }
+ m_Pages.GetNext(pos);
+ }
+
+ return hr;
} \ No newline at end of file
diff --git a/src/Subtitles/DVBSub.h b/src/Subtitles/DVBSub.h
index 626bb8493..489b17cf8 100644
--- a/src/Subtitles/DVBSub.h
+++ b/src/Subtitles/DVBSub.h
@@ -24,192 +24,192 @@
#include "BaseSub.h"
-#define MAX_REGIONS 10
-#define MAX_OBJECTS 10 // Max number of objects per region
+#define MAX_REGIONS 10
+#define MAX_OBJECTS 10 // Max number of objects per region
class CGolombBuffer;
class CDVBSub : public CBaseSub
{
public:
- CDVBSub(void);
- ~CDVBSub(void);
-
- virtual HRESULT ParseSample (IMediaSample* pSample);
- virtual void Render(SubPicDesc& spd, REFERENCE_TIME rt, RECT& bbox);
- virtual HRESULT GetTextureSize (POSITION pos, SIZE& MaxTextureSize, SIZE& VideoSize, POINT& VideoTopLeft);
- virtual POSITION GetStartPosition(REFERENCE_TIME rt, double fps);
- virtual POSITION GetNext(POSITION pos);
- virtual REFERENCE_TIME GetStart(POSITION nPos);
- virtual REFERENCE_TIME GetStop(POSITION nPos);
- virtual void Reset();
-
- // EN 300-743, table 2
- enum DVB_SEGMENT_TYPE {
- NO_SEGMENT = 0xFFFF,
- PAGE = 0x10,
- REGION = 0x11,
- CLUT = 0x12,
- OBJECT = 0x13,
- DISPLAY = 0x14,
- END_OF_DISPLAY = 0x80
- };
-
- // EN 300-743, table 6
- enum DVB_OBJECT_TYPE {
- OT_BASIC_BITMAP = 0x00,
- OT_BASIC_CHAR = 0x01,
- OT_COMPOSITE_STRING = 0x02
- };
-
- enum DVB_PAGE_STATE {
- DPS_NORMAL = 0x00,
- DPS_ACQUISITION = 0x01,
- DPS_MODE = 0x02,
- DPS_RESERVED = 0x03
- };
-
- struct DVB_CLUT {
- BYTE id;
- BYTE version_number;
- BYTE Size;
-
- HDMV_PALETTE Palette[256];
-
- DVB_CLUT() {
- memset (Palette, 0, sizeof(Palette));
- }
- };
-
- struct DVB_DISPLAY {
- BYTE version_number;
- BYTE display_window_flag;
- SHORT width;
- SHORT height;
- SHORT horizontal_position_minimun;
- SHORT horizontal_position_maximum;
- SHORT vertical_position_minimun;
- SHORT vertical_position_maximum;
-
- DVB_DISPLAY() {
- // Default value (§5.1.3)
- version_number = 0;
- width = 720;
- height = 576;
- }
- };
-
- struct DVB_OBJECT {
- SHORT object_id;
- BYTE object_type;
- BYTE object_provider_flag;
- SHORT object_horizontal_position;
- SHORT object_vertical_position;
- BYTE foreground_pixel_code;
- BYTE background_pixel_code;
-
- DVB_OBJECT() {
- object_id = 0xFF;
- object_type = 0;
- object_provider_flag = 0;
- object_horizontal_position = 0;
- object_vertical_position = 0;
- foreground_pixel_code = 0;
- background_pixel_code = 0;
- }
- };
-
- struct DVB_REGION {
- BYTE Id;
- WORD HorizAddr;
- WORD VertAddr;
- BYTE version_number;
- BYTE fill_flag;
- WORD width;
- WORD height;
- BYTE level_of_compatibility;
- BYTE depth;
- BYTE CLUT_id;
- BYTE _8_bit_pixel_code;
- BYTE _4_bit_pixel_code;
- BYTE _2_bit_pixel_code;
- int ObjectCount;
- DVB_OBJECT Objects[MAX_OBJECTS];
-
- DVB_CLUT Clut;
-
- DVB_REGION() {
- Id = 0;
- HorizAddr = 0;
- VertAddr = 0;
- version_number = 0;
- fill_flag = 0;
- width = 0;
- height = 0;
- level_of_compatibility = 0;
- depth = 0;
- CLUT_id = 0;
- _8_bit_pixel_code = 0;
- _4_bit_pixel_code = 0;
- _2_bit_pixel_code = 0;
- }
- };
-
- class DVB_PAGE
- {
- public :
- REFERENCE_TIME rtStart;
- REFERENCE_TIME rtStop;
- BYTE PageTimeOut;
- BYTE PageVersionNumber;
- BYTE PageState;
- int RegionCount;
- DVB_REGION Regions[MAX_REGIONS];
- CAtlList<CompositionObject*> Objects;
- bool Rendered;
-
- DVB_PAGE() {
- PageTimeOut = 0;
- PageVersionNumber = 0;
- PageState = 0;
- RegionCount = 0;
- Rendered = false;
- }
-
- ~DVB_PAGE() {
- CompositionObject* pPage;
- while (Objects.GetCount() > 0) {
- pPage = Objects.RemoveHead();
- delete pPage;
- }
- }
- };
+ CDVBSub(void);
+ ~CDVBSub(void);
+
+ virtual HRESULT ParseSample(IMediaSample* pSample);
+ virtual void Render(SubPicDesc& spd, REFERENCE_TIME rt, RECT& bbox);
+ virtual HRESULT GetTextureSize(POSITION pos, SIZE& MaxTextureSize, SIZE& VideoSize, POINT& VideoTopLeft);
+ virtual POSITION GetStartPosition(REFERENCE_TIME rt, double fps);
+ virtual POSITION GetNext(POSITION pos);
+ virtual REFERENCE_TIME GetStart(POSITION nPos);
+ virtual REFERENCE_TIME GetStop(POSITION nPos);
+ virtual void Reset();
+
+ // EN 300-743, table 2
+ enum DVB_SEGMENT_TYPE {
+ NO_SEGMENT = 0xFFFF,
+ PAGE = 0x10,
+ REGION = 0x11,
+ CLUT = 0x12,
+ OBJECT = 0x13,
+ DISPLAY = 0x14,
+ END_OF_DISPLAY = 0x80
+ };
+
+ // EN 300-743, table 6
+ enum DVB_OBJECT_TYPE {
+ OT_BASIC_BITMAP = 0x00,
+ OT_BASIC_CHAR = 0x01,
+ OT_COMPOSITE_STRING = 0x02
+ };
+
+ enum DVB_PAGE_STATE {
+ DPS_NORMAL = 0x00,
+ DPS_ACQUISITION = 0x01,
+ DPS_MODE = 0x02,
+ DPS_RESERVED = 0x03
+ };
+
+ struct DVB_CLUT {
+ BYTE id;
+ BYTE version_number;
+ BYTE Size;
+
+ HDMV_PALETTE Palette[256];
+
+ DVB_CLUT() {
+ memset(Palette, 0, sizeof(Palette));
+ }
+ };
+
+ struct DVB_DISPLAY {
+ BYTE version_number;
+ BYTE display_window_flag;
+ SHORT width;
+ SHORT height;
+ SHORT horizontal_position_minimun;
+ SHORT horizontal_position_maximum;
+ SHORT vertical_position_minimun;
+ SHORT vertical_position_maximum;
+
+ DVB_DISPLAY() {
+ // Default value (§5.1.3)
+ version_number = 0;
+ width = 720;
+ height = 576;
+ }
+ };
+
+ struct DVB_OBJECT {
+ SHORT object_id;
+ BYTE object_type;
+ BYTE object_provider_flag;
+ SHORT object_horizontal_position;
+ SHORT object_vertical_position;
+ BYTE foreground_pixel_code;
+ BYTE background_pixel_code;
+
+ DVB_OBJECT() {
+ object_id = 0xFF;
+ object_type = 0;
+ object_provider_flag = 0;
+ object_horizontal_position = 0;
+ object_vertical_position = 0;
+ foreground_pixel_code = 0;
+ background_pixel_code = 0;
+ }
+ };
+
+ struct DVB_REGION {
+ BYTE Id;
+ WORD HorizAddr;
+ WORD VertAddr;
+ BYTE version_number;
+ BYTE fill_flag;
+ WORD width;
+ WORD height;
+ BYTE level_of_compatibility;
+ BYTE depth;
+ BYTE CLUT_id;
+ BYTE _8_bit_pixel_code;
+ BYTE _4_bit_pixel_code;
+ BYTE _2_bit_pixel_code;
+ int ObjectCount;
+ DVB_OBJECT Objects[MAX_OBJECTS];
+
+ DVB_CLUT Clut;
+
+ DVB_REGION() {
+ Id = 0;
+ HorizAddr = 0;
+ VertAddr = 0;
+ version_number = 0;
+ fill_flag = 0;
+ width = 0;
+ height = 0;
+ level_of_compatibility = 0;
+ depth = 0;
+ CLUT_id = 0;
+ _8_bit_pixel_code = 0;
+ _4_bit_pixel_code = 0;
+ _2_bit_pixel_code = 0;
+ }
+ };
+
+ class DVB_PAGE
+ {
+ public :
+ REFERENCE_TIME rtStart;
+ REFERENCE_TIME rtStop;
+ BYTE PageTimeOut;
+ BYTE PageVersionNumber;
+ BYTE PageState;
+ int RegionCount;
+ DVB_REGION Regions[MAX_REGIONS];
+ CAtlList<CompositionObject*> Objects;
+ bool Rendered;
+
+ DVB_PAGE() {
+ PageTimeOut = 0;
+ PageVersionNumber = 0;
+ PageState = 0;
+ RegionCount = 0;
+ Rendered = false;
+ }
+
+ ~DVB_PAGE() {
+ CompositionObject* pPage;
+ while (Objects.GetCount() > 0) {
+ pPage = Objects.RemoveHead();
+ delete pPage;
+ }
+ }
+ };
private:
- static const REFERENCE_TIME INVALID_TIME = _I64_MIN;
-
- int m_nBufferSize;
- int m_nBufferReadPos;
- int m_nBufferWritePos;
- BYTE* m_pBuffer;
- CAtlList<DVB_PAGE*> m_Pages;
- CAutoPtr<DVB_PAGE> m_pCurrentPage;
- DVB_DISPLAY m_Display;
- REFERENCE_TIME m_rtStart;
- REFERENCE_TIME m_rtStop;
-
- HRESULT AddToBuffer(BYTE* pData, int nSize);
- DVB_PAGE* FindPage(REFERENCE_TIME rt);
- DVB_REGION* FindRegion(DVB_PAGE* pPage, BYTE bRegionId);
- DVB_CLUT* FindClut(DVB_PAGE* pPage, BYTE bClutId);
- CompositionObject* FindObject(DVB_PAGE* pPage, SHORT sObjectId);
-
- HRESULT ParsePage(CGolombBuffer& gb, WORD wSegLength, CAutoPtr<DVB_PAGE>& pPage);
- HRESULT ParseDisplay(CGolombBuffer& gb, WORD wSegLength);
- HRESULT ParseRegion(CGolombBuffer& gb, WORD wSegLength);
- HRESULT ParseClut(CGolombBuffer& gb, WORD wSegLength);
- HRESULT ParseObject(CGolombBuffer& gb, WORD wSegLength);
-
- HRESULT UpdateTimeStamp(REFERENCE_TIME rtStop);
+ static const REFERENCE_TIME INVALID_TIME = _I64_MIN;
+
+ int m_nBufferSize;
+ int m_nBufferReadPos;
+ int m_nBufferWritePos;
+ BYTE* m_pBuffer;
+ CAtlList<DVB_PAGE*> m_Pages;
+ CAutoPtr<DVB_PAGE> m_pCurrentPage;
+ DVB_DISPLAY m_Display;
+ REFERENCE_TIME m_rtStart;
+ REFERENCE_TIME m_rtStop;
+
+ HRESULT AddToBuffer(BYTE* pData, int nSize);
+ DVB_PAGE* FindPage(REFERENCE_TIME rt);
+ DVB_REGION* FindRegion(DVB_PAGE* pPage, BYTE bRegionId);
+ DVB_CLUT* FindClut(DVB_PAGE* pPage, BYTE bClutId);
+ CompositionObject* FindObject(DVB_PAGE* pPage, SHORT sObjectId);
+
+ HRESULT ParsePage(CGolombBuffer& gb, WORD wSegLength, CAutoPtr<DVB_PAGE>& pPage);
+ HRESULT ParseDisplay(CGolombBuffer& gb, WORD wSegLength);
+ HRESULT ParseRegion(CGolombBuffer& gb, WORD wSegLength);
+ HRESULT ParseClut(CGolombBuffer& gb, WORD wSegLength);
+ HRESULT ParseObject(CGolombBuffer& gb, WORD wSegLength);
+
+ HRESULT UpdateTimeStamp(REFERENCE_TIME rtStop);
};
diff --git a/src/Subtitles/GFN.cpp b/src/Subtitles/GFN.cpp
index 5fe78babb..d7ae3818b 100644
--- a/src/Subtitles/GFN.cpp
+++ b/src/Subtitles/GFN.cpp
@@ -27,146 +27,146 @@
#include "GFN.h"
TCHAR* exttypestr[] = {
- _T("srt"), _T("sub"), _T("smi"), _T("psb"),
- _T("ssa"), _T("ass"), _T("idx"), _T("usf"),
- _T("xss"), _T("txt"), _T("rt"), _T("sup")
+ _T("srt"), _T("sub"), _T("smi"), _T("psb"),
+ _T("ssa"), _T("ass"), _T("idx"), _T("usf"),
+ _T("xss"), _T("txt"), _T("rt"), _T("sup")
};
static TCHAR* ext[3][_countof(exttypestr)] = {
- {
- _T(".srt"), _T(".sub"), _T(".smi"), _T(".psb"),
- _T(".ssa"), _T(".ass"), _T(".idx"), _T(".usf"),
- _T(".xss"), _T(".txt"), _T(".rt"), _T(".sup")
- },
- {
- _T(".*.srt"), _T(".*.sub"), _T(".*.smi"), _T(".*.psb"),
- _T(".*.ssa"), _T(".*.ass"), _T(".*.dummyidx"), _T(".*.usf"),
- _T(".*.xss"), _T(".*.txt"), _T(".*.rt"), _T(".*.sup")
- },
- {
- _T("-*.srt"), _T("-*.sub"), _T("-*.smi"), _T("-*.psb"),
- _T("-*.ssa"), _T("-*.ass"), _T("-*.dummyidx"), _T("-*.usf"),
- _T("-*.xss"), _T("-*.txt"), _T("-*.rt"), _T("-*.sup")
- },
+ {
+ _T(".srt"), _T(".sub"), _T(".smi"), _T(".psb"),
+ _T(".ssa"), _T(".ass"), _T(".idx"), _T(".usf"),
+ _T(".xss"), _T(".txt"), _T(".rt"), _T(".sup")
+ },
+ {
+ _T(".*.srt"), _T(".*.sub"), _T(".*.smi"), _T(".*.psb"),
+ _T(".*.ssa"), _T(".*.ass"), _T(".*.dummyidx"), _T(".*.usf"),
+ _T(".*.xss"), _T(".*.txt"), _T(".*.rt"), _T(".*.sup")
+ },
+ {
+ _T("-*.srt"), _T("-*.sub"), _T("-*.smi"), _T("-*.psb"),
+ _T("-*.ssa"), _T("-*.ass"), _T("-*.dummyidx"), _T("-*.usf"),
+ _T("-*.xss"), _T("-*.txt"), _T("-*.rt"), _T("-*.sup")
+ },
};
#define WEBSUBEXT _T(".wse")
static int SubFileCompare(const void* elem1, const void* elem2)
{
- return ((SubFile*)elem1)->fn.CompareNoCase(((SubFile*)elem2)->fn);
+ return ((SubFile*)elem1)->fn.CompareNoCase(((SubFile*)elem2)->fn);
}
void GetSubFileNames(CString fn, CAtlArray<CString>& paths, CAtlArray<SubFile>& ret)
{
- ret.RemoveAll();
-
- int extlistnum = _countof(ext);
- int extsubnum = _countof(ext[0]);
-
- fn.Replace('\\', '/');
-
- bool fWeb = false;
- {
- // int i = fn.Find(_T("://"));
- int i = fn.Find(_T("http://"));
- if (i > 0) {
- fn = _T("http") + fn.Mid(i);
- fWeb = true;
- }
- }
-
- int l = fn.GetLength(), l2 = l;
- l2 = fn.ReverseFind('.');
- l = fn.ReverseFind('/') + 1;
- if (l2 < l) {
- l2 = l;
- }
-
- CString orgpath = fn.Left(l);
- CString title = fn.Mid(l, l2-l);
- CString filename = title + _T(".nooneexpectsthespanishinquisition");
-
- if (!fWeb) {
- // struct _tfinddata_t file, file2;
- // long hFile, hFile2 = 0;
-
- WIN32_FIND_DATA wfd, wfd2;
- HANDLE hFile, hFile2;
-
- for (size_t k = 0; k < paths.GetCount(); k++) {
- CString path = paths[k];
- path.Replace('\\', '/');
-
- l = path.GetLength();
- if (l > 0 && path[l-1] != '/') {
- path += '/';
- }
-
- if (path.Find(':') == -1 && path.Find(_T("\\\\")) != 0) {
- path = orgpath + path;
- }
-
- path.Replace(_T("/./"), _T("/"));
- path.Replace('/', '\\');
-
- // CAtlList<CString> sl;
-
- bool fEmpty = true;
-
- if ((hFile = FindFirstFile(path + title + _T("*"), &wfd)) != INVALID_HANDLE_VALUE) {
- do {
- if (filename.CompareNoCase(wfd.cFileName) != 0) {
- fEmpty = false;
- // sl.AddTail(path + file.name);
- }
- } while (FindNextFile(hFile, &wfd));
-
- FindClose(hFile);
- }
-
- // TODO: use 'sl' in the next step to find files (already a nice speedup as it is now...)
- if (fEmpty) {
- continue;
- }
-
- for (ptrdiff_t j = 0; j < extlistnum; j++) {
- for (ptrdiff_t i = 0; i < extsubnum; i++) {
- if ((hFile = FindFirstFile(path + title + ext[j][i], &wfd)) != INVALID_HANDLE_VALUE) {
- do {
- CString fn = path + wfd.cFileName;
-
- hFile2 = INVALID_HANDLE_VALUE;
-
- if (j == 0 || (hFile2 = FindFirstFile(fn.Left(fn.ReverseFind('.')) + _T(".avi"), &wfd2)) == INVALID_HANDLE_VALUE) {
- SubFile f;
- f.fn = fn;
- ret.Add(f);
- }
-
- if (hFile2 != INVALID_HANDLE_VALUE) {
- FindClose(hFile2);
- }
- } while (FindNextFile(hFile, &wfd));
-
- FindClose(hFile);
- }
- }
- }
- }
- } else if (l > 7) {
- CWebTextFile wtf; // :)
- if (wtf.Open(orgpath + title + WEBSUBEXT)) {
- CString fn;
- while (wtf.ReadString(fn) && fn.Find(_T("://")) >= 0) {
- SubFile f;
- f.fn = fn;
- ret.Add(f);
- }
- }
- }
-
- // sort files, this way the user can define the order (movie.00.English.srt, movie.01.Hungarian.srt, etc)
-
- qsort(ret.GetData(), ret.GetCount(), sizeof(SubFile), SubFileCompare);
+ ret.RemoveAll();
+
+ int extlistnum = _countof(ext);
+ int extsubnum = _countof(ext[0]);
+
+ fn.Replace('\\', '/');
+
+ bool fWeb = false;
+ {
+ // int i = fn.Find(_T("://"));
+ int i = fn.Find(_T("http://"));
+ if (i > 0) {
+ fn = _T("http") + fn.Mid(i);
+ fWeb = true;
+ }
+ }
+
+ int l = fn.GetLength(), l2 = l;
+ l2 = fn.ReverseFind('.');
+ l = fn.ReverseFind('/') + 1;
+ if (l2 < l) {
+ l2 = l;
+ }
+
+ CString orgpath = fn.Left(l);
+ CString title = fn.Mid(l, l2 - l);
+ CString filename = title + _T(".nooneexpectsthespanishinquisition");
+
+ if (!fWeb) {
+ // struct _tfinddata_t file, file2;
+ // long hFile, hFile2 = 0;
+
+ WIN32_FIND_DATA wfd, wfd2;
+ HANDLE hFile, hFile2;
+
+ for (size_t k = 0; k < paths.GetCount(); k++) {
+ CString path = paths[k];
+ path.Replace('\\', '/');
+
+ l = path.GetLength();
+ if (l > 0 && path[l - 1] != '/') {
+ path += '/';
+ }
+
+ if (path.Find(':') == -1 && path.Find(_T("\\\\")) != 0) {
+ path = orgpath + path;
+ }
+
+ path.Replace(_T("/./"), _T("/"));
+ path.Replace('/', '\\');
+
+ // CAtlList<CString> sl;
+
+ bool fEmpty = true;
+
+ if ((hFile = FindFirstFile(path + title + _T("*"), &wfd)) != INVALID_HANDLE_VALUE) {
+ do {
+ if (filename.CompareNoCase(wfd.cFileName) != 0) {
+ fEmpty = false;
+ // sl.AddTail(path + file.name);
+ }
+ } while (FindNextFile(hFile, &wfd));
+
+ FindClose(hFile);
+ }
+
+ // TODO: use 'sl' in the next step to find files (already a nice speedup as it is now...)
+ if (fEmpty) {
+ continue;
+ }
+
+ for (ptrdiff_t j = 0; j < extlistnum; j++) {
+ for (ptrdiff_t i = 0; i < extsubnum; i++) {
+ if ((hFile = FindFirstFile(path + title + ext[j][i], &wfd)) != INVALID_HANDLE_VALUE) {
+ do {
+ CString fn = path + wfd.cFileName;
+
+ hFile2 = INVALID_HANDLE_VALUE;
+
+ if (j == 0 || (hFile2 = FindFirstFile(fn.Left(fn.ReverseFind('.')) + _T(".avi"), &wfd2)) == INVALID_HANDLE_VALUE) {
+ SubFile f;
+ f.fn = fn;
+ ret.Add(f);
+ }
+
+ if (hFile2 != INVALID_HANDLE_VALUE) {
+ FindClose(hFile2);
+ }
+ } while (FindNextFile(hFile, &wfd));
+
+ FindClose(hFile);
+ }
+ }
+ }
+ }
+ } else if (l > 7) {
+ CWebTextFile wtf; // :)
+ if (wtf.Open(orgpath + title + WEBSUBEXT)) {
+ CString fn;
+ while (wtf.ReadString(fn) && fn.Find(_T("://")) >= 0) {
+ SubFile f;
+ f.fn = fn;
+ ret.Add(f);
+ }
+ }
+ }
+
+ // sort files, this way the user can define the order (movie.00.English.srt, movie.01.Hungarian.srt, etc)
+
+ qsort(ret.GetData(), ret.GetCount(), sizeof(SubFile), SubFileCompare);
}
diff --git a/src/Subtitles/GFN.h b/src/Subtitles/GFN.h
index b150b99ff..6bca46634 100644
--- a/src/Subtitles/GFN.h
+++ b/src/Subtitles/GFN.h
@@ -30,7 +30,7 @@ extern TCHAR* exttypestr[];
typedef struct {
- CString fn; /*exttype ext;*/
+ CString fn; /*exttype ext;*/
} SubFile;
diff --git a/src/Subtitles/HdmvSub.cpp b/src/Subtitles/HdmvSub.cpp
index 6ec2cc1ef..0b030e487 100644
--- a/src/Subtitles/HdmvSub.cpp
+++ b/src/Subtitles/HdmvSub.cpp
@@ -24,349 +24,349 @@
#include "HdmvSub.h"
#include "../DSUtil/GolombBuffer.h"
-#if (0) // Set to 1 to activate HDMV subtitles traces
-#define TRACE_HDMVSUB TRACE
+#if (0) // Set to 1 to activate HDMV subtitles traces
+#define TRACE_HDMVSUB TRACE
#else
#define TRACE_HDMVSUB
#endif
CHdmvSub::CHdmvSub(void)
- : CBaseSub(ST_HDMV)
+ : CBaseSub(ST_HDMV)
{
- m_nColorNumber = 0;
-
- m_nCurSegment = NO_SEGMENT;
- m_pSegBuffer = NULL;
- m_nTotalSegBuffer = 0;
- m_nSegBufferPos = 0;
- m_nSegSize = 0;
- m_pCurrentObject = NULL;
- m_pDefaultPalette = NULL;
- m_nDefaultPaletteNbEntry = 0;
-
- memset (&m_VideoDescriptor, 0, sizeof(VIDEO_DESCRIPTOR));
+ m_nColorNumber = 0;
+
+ m_nCurSegment = NO_SEGMENT;
+ m_pSegBuffer = NULL;
+ m_nTotalSegBuffer = 0;
+ m_nSegBufferPos = 0;
+ m_nSegSize = 0;
+ m_pCurrentObject = NULL;
+ m_pDefaultPalette = NULL;
+ m_nDefaultPaletteNbEntry = 0;
+
+ memset(&m_VideoDescriptor, 0, sizeof(VIDEO_DESCRIPTOR));
}
CHdmvSub::~CHdmvSub()
{
- Reset();
+ Reset();
- delete[] m_pSegBuffer;
- delete[] m_pDefaultPalette;
- delete m_pCurrentObject;
+ delete[] m_pSegBuffer;
+ delete[] m_pDefaultPalette;
+ delete m_pCurrentObject;
}
void CHdmvSub::AllocSegment(int nSize)
{
- if (nSize > m_nTotalSegBuffer) {
- delete[] m_pSegBuffer;
- m_pSegBuffer = DNew BYTE[nSize];
- m_nTotalSegBuffer = nSize;
- }
- m_nSegBufferPos = 0;
- m_nSegSize = nSize;
+ if (nSize > m_nTotalSegBuffer) {
+ delete[] m_pSegBuffer;
+ m_pSegBuffer = DNew BYTE[nSize];
+ m_nTotalSegBuffer = nSize;
+ }
+ m_nSegBufferPos = 0;
+ m_nSegSize = nSize;
}
POSITION CHdmvSub::GetStartPosition(REFERENCE_TIME rt, double fps)
{
- CompositionObject* pObject;
-
- // Cleanup old PG
- while (m_pObjects.GetCount()>0) {
- pObject = m_pObjects.GetHead();
- if (pObject->m_rtStop < rt) {
- TRACE_HDMVSUB ("CHdmvSub:HDMV remove object %d %S => %S (rt=%S)\n", pObject->GetRLEDataSize(),
- ReftimeToString (pObject->m_rtStart), ReftimeToString(pObject->m_rtStop), ReftimeToString(rt));
- m_pObjects.RemoveHead();
- delete pObject;
- } else {
- break;
- }
- }
-
- return m_pObjects.GetHeadPosition();
+ CompositionObject* pObject;
+
+ // Cleanup old PG
+ while (m_pObjects.GetCount() > 0) {
+ pObject = m_pObjects.GetHead();
+ if (pObject->m_rtStop < rt) {
+ TRACE_HDMVSUB("CHdmvSub:HDMV remove object %d %S => %S (rt=%S)\n", pObject->GetRLEDataSize(),
+ ReftimeToString(pObject->m_rtStart), ReftimeToString(pObject->m_rtStop), ReftimeToString(rt));
+ m_pObjects.RemoveHead();
+ delete pObject;
+ } else {
+ break;
+ }
+ }
+
+ return m_pObjects.GetHeadPosition();
}
HRESULT CHdmvSub::ParseSample(IMediaSample* pSample)
{
- CheckPointer (pSample, E_POINTER);
- HRESULT hr;
- REFERENCE_TIME rtStart = INVALID_TIME, rtStop = INVALID_TIME;
- BYTE* pData = NULL;
- int lSampleLen;
-
- hr = pSample->GetPointer(&pData);
- if (FAILED(hr) || pData == NULL) {
- return hr;
- }
- lSampleLen = pSample->GetActualDataLength();
-
- pSample->GetTime(&rtStart, &rtStop);
- if (pData) {
- CGolombBuffer SampleBuffer (pData, lSampleLen);
-
- while (!SampleBuffer.IsEOF()) {
- if (m_nCurSegment == NO_SEGMENT) {
- HDMV_SEGMENT_TYPE nSegType = (HDMV_SEGMENT_TYPE)SampleBuffer.ReadByte();
- USHORT nUnitSize = SampleBuffer.ReadShort();
- lSampleLen -=3;
-
- switch (nSegType) {
- case PALETTE :
- case OBJECT :
- case PRESENTATION_SEG :
- case END_OF_DISPLAY :
- m_nCurSegment = nSegType;
- AllocSegment (nUnitSize);
- break;
-
- case WINDOW_DEF :
- case INTERACTIVE_SEG :
- case HDMV_SUB1 :
- case HDMV_SUB2 :
- // Ignored stuff...
- SampleBuffer.SkipBytes(nUnitSize);
- break;
- default :
- return VFW_E_SAMPLE_REJECTED;
- }
- }
-
- if (m_nCurSegment != NO_SEGMENT) {
- if (m_nSegBufferPos < m_nSegSize) {
- int nSize = min (m_nSegSize-m_nSegBufferPos, lSampleLen);
- SampleBuffer.ReadBuffer (m_pSegBuffer+m_nSegBufferPos, nSize);
- m_nSegBufferPos += nSize;
- }
-
- if (m_nSegBufferPos >= m_nSegSize) {
- CGolombBuffer SegmentBuffer (m_pSegBuffer, m_nSegSize);
-
- switch (m_nCurSegment) {
- case PALETTE :
- TRACE_HDMVSUB ("CHdmvSub:PALETTE rtStart=%10I64d\n", rtStart);
- ParsePalette(&SegmentBuffer, m_nSegSize);
- break;
- case OBJECT :
- TRACE_HDMVSUB ("CHdmvSub:OBJECT %S\n", ReftimeToString(rtStart));
- ParseObject(&SegmentBuffer, m_nSegSize);
- break;
- case PRESENTATION_SEG :
- TRACE_HDMVSUB ("CHdmvSub:PRESENTATION_SEG %S (size=%d)\n", ReftimeToString(rtStart), m_nSegSize);
-
- if (m_pCurrentObject) {
- TRACE_HDMVSUB ("CHdmvSub:PRESENTATION_SEG %d\n", m_pCurrentObject->m_nObjectNumber);
- if (m_pCurrentObject->m_nObjectNumber > 1) {
- m_pCurrentObject->m_nObjectNumber--;
- break;
- }
- m_pCurrentObject->m_rtStop = rtStart;
- m_pObjects.AddTail (m_pCurrentObject);
- TRACE_HDMVSUB ("CHdmvSub:HDMV : %S => %S\n", ReftimeToString (m_pCurrentObject->m_rtStart), ReftimeToString(rtStart));
- m_pCurrentObject = NULL;
- }
-
- if (ParsePresentationSegment(&SegmentBuffer) > 0) {
- m_pCurrentObject->m_rtStart = rtStart;
- m_pCurrentObject->m_rtStop = _I64_MAX;
- }
- break;
- case WINDOW_DEF :
- // TRACE_HDMVSUB ("CHdmvSub:WINDOW_DEF %S\n", ReftimeToString(rtStart));
- break;
- case END_OF_DISPLAY :
- // TRACE_HDMVSUB ("CHdmvSub:END_OF_DISPLAY %S\n", ReftimeToString(rtStart));
- break;
- default :
- TRACE_HDMVSUB ("CHdmvSub:UNKNOWN Seg %d rtStart=0x%10dd\n", m_nCurSegment, rtStart);
- }
-
- m_nCurSegment = NO_SEGMENT;
- }
- }
- }
- }
-
- return hr;
+ CheckPointer(pSample, E_POINTER);
+ HRESULT hr;
+ REFERENCE_TIME rtStart = INVALID_TIME, rtStop = INVALID_TIME;
+ BYTE* pData = NULL;
+ int lSampleLen;
+
+ hr = pSample->GetPointer(&pData);
+ if (FAILED(hr) || pData == NULL) {
+ return hr;
+ }
+ lSampleLen = pSample->GetActualDataLength();
+
+ pSample->GetTime(&rtStart, &rtStop);
+ if (pData) {
+ CGolombBuffer SampleBuffer(pData, lSampleLen);
+
+ while (!SampleBuffer.IsEOF()) {
+ if (m_nCurSegment == NO_SEGMENT) {
+ HDMV_SEGMENT_TYPE nSegType = (HDMV_SEGMENT_TYPE)SampleBuffer.ReadByte();
+ USHORT nUnitSize = SampleBuffer.ReadShort();
+ lSampleLen -= 3;
+
+ switch (nSegType) {
+ case PALETTE :
+ case OBJECT :
+ case PRESENTATION_SEG :
+ case END_OF_DISPLAY :
+ m_nCurSegment = nSegType;
+ AllocSegment(nUnitSize);
+ break;
+
+ case WINDOW_DEF :
+ case INTERACTIVE_SEG :
+ case HDMV_SUB1 :
+ case HDMV_SUB2 :
+ // Ignored stuff...
+ SampleBuffer.SkipBytes(nUnitSize);
+ break;
+ default :
+ return VFW_E_SAMPLE_REJECTED;
+ }
+ }
+
+ if (m_nCurSegment != NO_SEGMENT) {
+ if (m_nSegBufferPos < m_nSegSize) {
+ int nSize = min(m_nSegSize - m_nSegBufferPos, lSampleLen);
+ SampleBuffer.ReadBuffer(m_pSegBuffer + m_nSegBufferPos, nSize);
+ m_nSegBufferPos += nSize;
+ }
+
+ if (m_nSegBufferPos >= m_nSegSize) {
+ CGolombBuffer SegmentBuffer(m_pSegBuffer, m_nSegSize);
+
+ switch (m_nCurSegment) {
+ case PALETTE :
+ TRACE_HDMVSUB("CHdmvSub:PALETTE rtStart=%10I64d\n", rtStart);
+ ParsePalette(&SegmentBuffer, m_nSegSize);
+ break;
+ case OBJECT :
+ TRACE_HDMVSUB("CHdmvSub:OBJECT %S\n", ReftimeToString(rtStart));
+ ParseObject(&SegmentBuffer, m_nSegSize);
+ break;
+ case PRESENTATION_SEG :
+ TRACE_HDMVSUB("CHdmvSub:PRESENTATION_SEG %S (size=%d)\n", ReftimeToString(rtStart), m_nSegSize);
+
+ if (m_pCurrentObject) {
+ TRACE_HDMVSUB("CHdmvSub:PRESENTATION_SEG %d\n", m_pCurrentObject->m_nObjectNumber);
+ if (m_pCurrentObject->m_nObjectNumber > 1) {
+ m_pCurrentObject->m_nObjectNumber--;
+ break;
+ }
+ m_pCurrentObject->m_rtStop = rtStart;
+ m_pObjects.AddTail(m_pCurrentObject);
+ TRACE_HDMVSUB("CHdmvSub:HDMV : %S => %S\n", ReftimeToString(m_pCurrentObject->m_rtStart), ReftimeToString(rtStart));
+ m_pCurrentObject = NULL;
+ }
+
+ if (ParsePresentationSegment(&SegmentBuffer) > 0) {
+ m_pCurrentObject->m_rtStart = rtStart;
+ m_pCurrentObject->m_rtStop = _I64_MAX;
+ }
+ break;
+ case WINDOW_DEF :
+ // TRACE_HDMVSUB ("CHdmvSub:WINDOW_DEF %S\n", ReftimeToString(rtStart));
+ break;
+ case END_OF_DISPLAY :
+ // TRACE_HDMVSUB ("CHdmvSub:END_OF_DISPLAY %S\n", ReftimeToString(rtStart));
+ break;
+ default :
+ TRACE_HDMVSUB("CHdmvSub:UNKNOWN Seg %d rtStart=0x%10dd\n", m_nCurSegment, rtStart);
+ }
+
+ m_nCurSegment = NO_SEGMENT;
+ }
+ }
+ }
+ }
+
+ return hr;
}
int CHdmvSub::ParsePresentationSegment(CGolombBuffer* pGBuffer)
{
- COMPOSITION_DESCRIPTOR CompositionDescriptor;
- BYTE nObjectNumber;
- //bool palette_update_flag;
- //BYTE palette_id_ref;
-
- ParseVideoDescriptor(pGBuffer, &m_VideoDescriptor);
- ParseCompositionDescriptor(pGBuffer, &CompositionDescriptor);
- pGBuffer->ReadByte(); //palette_update_flag = !!(pGBuffer->ReadByte() & 0x80);
- pGBuffer->ReadByte(); //palette_id_ref = pGBuffer->ReadByte();
- nObjectNumber = pGBuffer->ReadByte();
-
- TRACE_HDMVSUB( "CHdmvSub::ParsePresentationSegment Size = %d, nObjectNumber = %d\n", pGBuffer->GetSize(), nObjectNumber);
-
- if (nObjectNumber > 0) {
- delete m_pCurrentObject;
- m_pCurrentObject = DNew CompositionObject();
- m_pCurrentObject->m_nObjectNumber = nObjectNumber;
- for (int i=0; i<nObjectNumber; i++) {
- ParseCompositionObject (pGBuffer, m_pCurrentObject);
- }
- }
-
- return nObjectNumber;
+ COMPOSITION_DESCRIPTOR CompositionDescriptor;
+ BYTE nObjectNumber;
+ //bool palette_update_flag;
+ //BYTE palette_id_ref;
+
+ ParseVideoDescriptor(pGBuffer, &m_VideoDescriptor);
+ ParseCompositionDescriptor(pGBuffer, &CompositionDescriptor);
+ pGBuffer->ReadByte(); //palette_update_flag = !!(pGBuffer->ReadByte() & 0x80);
+ pGBuffer->ReadByte(); //palette_id_ref = pGBuffer->ReadByte();
+ nObjectNumber = pGBuffer->ReadByte();
+
+ TRACE_HDMVSUB("CHdmvSub::ParsePresentationSegment Size = %d, nObjectNumber = %d\n", pGBuffer->GetSize(), nObjectNumber);
+
+ if (nObjectNumber > 0) {
+ delete m_pCurrentObject;
+ m_pCurrentObject = DNew CompositionObject();
+ m_pCurrentObject->m_nObjectNumber = nObjectNumber;
+ for (int i = 0; i < nObjectNumber; i++) {
+ ParseCompositionObject(pGBuffer, m_pCurrentObject);
+ }
+ }
+
+ return nObjectNumber;
}
-void CHdmvSub::ParsePalette(CGolombBuffer* pGBuffer, USHORT nSize) // #497
+void CHdmvSub::ParsePalette(CGolombBuffer* pGBuffer, USHORT nSize) // #497
{
- int nNbEntry;
- BYTE palette_id = pGBuffer->ReadByte();
- BYTE palette_version_number = pGBuffer->ReadByte();
- UNREFERENCED_PARAMETER(palette_id);
- UNREFERENCED_PARAMETER(palette_version_number);
-
- ASSERT ((nSize-2) % sizeof(HDMV_PALETTE) == 0);
- nNbEntry = (nSize-2) / sizeof(HDMV_PALETTE);
- HDMV_PALETTE* pPalette = (HDMV_PALETTE*)pGBuffer->GetBufferPos();
-
- if (m_pDefaultPalette == NULL || m_nDefaultPaletteNbEntry != nNbEntry) {
- delete[] m_pDefaultPalette;
- m_pDefaultPalette = DNew HDMV_PALETTE[nNbEntry];
- m_nDefaultPaletteNbEntry = nNbEntry;
- }
- memcpy (m_pDefaultPalette, pPalette, nNbEntry*sizeof(HDMV_PALETTE));
-
- if (m_pCurrentObject) {
- m_pCurrentObject->SetPalette (nNbEntry, pPalette, m_VideoDescriptor.nVideoWidth > 720);
- }
+ int nNbEntry;
+ BYTE palette_id = pGBuffer->ReadByte();
+ BYTE palette_version_number = pGBuffer->ReadByte();
+ UNREFERENCED_PARAMETER(palette_id);
+ UNREFERENCED_PARAMETER(palette_version_number);
+
+ ASSERT((nSize - 2) % sizeof(HDMV_PALETTE) == 0);
+ nNbEntry = (nSize - 2) / sizeof(HDMV_PALETTE);
+ HDMV_PALETTE* pPalette = (HDMV_PALETTE*)pGBuffer->GetBufferPos();
+
+ if (m_pDefaultPalette == NULL || m_nDefaultPaletteNbEntry != nNbEntry) {
+ delete[] m_pDefaultPalette;
+ m_pDefaultPalette = DNew HDMV_PALETTE[nNbEntry];
+ m_nDefaultPaletteNbEntry = nNbEntry;
+ }
+ memcpy(m_pDefaultPalette, pPalette, nNbEntry * sizeof(HDMV_PALETTE));
+
+ if (m_pCurrentObject) {
+ m_pCurrentObject->SetPalette(nNbEntry, pPalette, m_VideoDescriptor.nVideoWidth > 720);
+ }
}
-void CHdmvSub::ParseObject(CGolombBuffer* pGBuffer, USHORT nUnitSize) // #498
+void CHdmvSub::ParseObject(CGolombBuffer* pGBuffer, USHORT nUnitSize) // #498
{
- SHORT object_id = pGBuffer->ReadShort();
- UNREFERENCED_PARAMETER(object_id);
- BYTE m_sequence_desc;
+ SHORT object_id = pGBuffer->ReadShort();
+ UNREFERENCED_PARAMETER(object_id);
+ BYTE m_sequence_desc;
- ASSERT (m_pCurrentObject != NULL);
- if (m_pCurrentObject) { // && m_pCurrentObject->m_object_id_ref == object_id)
- m_pCurrentObject->m_version_number = pGBuffer->ReadByte();
- m_sequence_desc = pGBuffer->ReadByte();
+ ASSERT(m_pCurrentObject != NULL);
+ if (m_pCurrentObject) { // && m_pCurrentObject->m_object_id_ref == object_id)
+ m_pCurrentObject->m_version_number = pGBuffer->ReadByte();
+ m_sequence_desc = pGBuffer->ReadByte();
- if (m_sequence_desc & 0x80) {
- DWORD object_data_length = (DWORD)pGBuffer->BitRead(24);
+ if (m_sequence_desc & 0x80) {
+ DWORD object_data_length = (DWORD)pGBuffer->BitRead(24);
- m_pCurrentObject->m_width = pGBuffer->ReadShort();
- m_pCurrentObject->m_height = pGBuffer->ReadShort();
+ m_pCurrentObject->m_width = pGBuffer->ReadShort();
+ m_pCurrentObject->m_height = pGBuffer->ReadShort();
- m_pCurrentObject->SetRLEData (pGBuffer->GetBufferPos(), nUnitSize-11, object_data_length-4);
+ m_pCurrentObject->SetRLEData(pGBuffer->GetBufferPos(), nUnitSize - 11, object_data_length - 4);
- TRACE_HDMVSUB ("CHdmvSub:NewObject size=%ld, total obj=%d, %dx%d\n", object_data_length, m_pObjects.GetCount(),
- m_pCurrentObject->m_width, m_pCurrentObject->m_height);
- } else {
- m_pCurrentObject->AppendRLEData (pGBuffer->GetBufferPos(), nUnitSize-4);
- }
- }
+ TRACE_HDMVSUB("CHdmvSub:NewObject size=%ld, total obj=%d, %dx%d\n", object_data_length, m_pObjects.GetCount(),
+ m_pCurrentObject->m_width, m_pCurrentObject->m_height);
+ } else {
+ m_pCurrentObject->AppendRLEData(pGBuffer->GetBufferPos(), nUnitSize - 4);
+ }
+ }
}
void CHdmvSub::ParseCompositionObject(CGolombBuffer* pGBuffer, CompositionObject* pCompositionObject)
{
- BYTE bTemp;
- pCompositionObject->m_object_id_ref = pGBuffer->ReadShort();
- pCompositionObject->m_window_id_ref = pGBuffer->ReadByte();
- bTemp = pGBuffer->ReadByte();
- pCompositionObject->m_object_cropped_flag = !!(bTemp & 0x80);
- pCompositionObject->m_forced_on_flag = !!(bTemp & 0x40);
- pCompositionObject->m_horizontal_position = pGBuffer->ReadShort();
- pCompositionObject->m_vertical_position = pGBuffer->ReadShort();
-
- if (pCompositionObject->m_object_cropped_flag) {
- pCompositionObject->m_cropping_horizontal_position = pGBuffer->ReadShort();
- pCompositionObject->m_cropping_vertical_position = pGBuffer->ReadShort();
- pCompositionObject->m_cropping_width = pGBuffer->ReadShort();
- pCompositionObject->m_cropping_height = pGBuffer->ReadShort();
- }
+ BYTE bTemp;
+ pCompositionObject->m_object_id_ref = pGBuffer->ReadShort();
+ pCompositionObject->m_window_id_ref = pGBuffer->ReadByte();
+ bTemp = pGBuffer->ReadByte();
+ pCompositionObject->m_object_cropped_flag = !!(bTemp & 0x80);
+ pCompositionObject->m_forced_on_flag = !!(bTemp & 0x40);
+ pCompositionObject->m_horizontal_position = pGBuffer->ReadShort();
+ pCompositionObject->m_vertical_position = pGBuffer->ReadShort();
+
+ if (pCompositionObject->m_object_cropped_flag) {
+ pCompositionObject->m_cropping_horizontal_position = pGBuffer->ReadShort();
+ pCompositionObject->m_cropping_vertical_position = pGBuffer->ReadShort();
+ pCompositionObject->m_cropping_width = pGBuffer->ReadShort();
+ pCompositionObject->m_cropping_height = pGBuffer->ReadShort();
+ }
}
void CHdmvSub::ParseVideoDescriptor(CGolombBuffer* pGBuffer, VIDEO_DESCRIPTOR* pVideoDescriptor)
{
- pVideoDescriptor->nVideoWidth = pGBuffer->ReadShort();
- pVideoDescriptor->nVideoHeight = pGBuffer->ReadShort();
- pVideoDescriptor->bFrameRate = pGBuffer->ReadByte();
+ pVideoDescriptor->nVideoWidth = pGBuffer->ReadShort();
+ pVideoDescriptor->nVideoHeight = pGBuffer->ReadShort();
+ pVideoDescriptor->bFrameRate = pGBuffer->ReadByte();
}
void CHdmvSub::ParseCompositionDescriptor(CGolombBuffer* pGBuffer, COMPOSITION_DESCRIPTOR* pCompositionDescriptor)
{
- pCompositionDescriptor->nNumber = pGBuffer->ReadShort();
- pCompositionDescriptor->bState = pGBuffer->ReadByte();
+ pCompositionDescriptor->nNumber = pGBuffer->ReadShort();
+ pCompositionDescriptor->bState = pGBuffer->ReadByte();
}
void CHdmvSub::Render(SubPicDesc& spd, REFERENCE_TIME rt, RECT& bbox)
{
- CompositionObject* pObject = FindObject (rt);
-
- ASSERT (pObject!=NULL && spd.w >= (pObject->m_horizontal_position + pObject->m_width) && spd.h >= (pObject->m_vertical_position + pObject->m_height));
-
- if (pObject && pObject->GetRLEDataSize() && pObject->m_width > 0 && pObject->m_height > 0 &&
- spd.w >= (pObject->m_horizontal_position + pObject->m_width) &&
- spd.h >= (pObject->m_vertical_position + pObject->m_height)) {
- if (!pObject->HavePalette()) {
- pObject->SetPalette (m_nDefaultPaletteNbEntry, m_pDefaultPalette, m_VideoDescriptor.nVideoWidth>720);
- }
-
- TRACE_HDMVSUB ("CHdmvSub:Render size=%ld, ObjRes=%dx%d, SPDRes=%dx%d\n", pObject->GetRLEDataSize(),
- pObject->m_width, pObject->m_height, spd.w, spd.h);
- pObject->RenderHdmv(spd);
-
- bbox.left = pObject->m_horizontal_position;
- bbox.top = pObject->m_vertical_position;
- bbox.right = bbox.left + pObject->m_width;
- bbox.bottom = bbox.top + pObject->m_height;
- }
+ CompositionObject* pObject = FindObject(rt);
+
+ ASSERT(pObject != NULL && spd.w >= (pObject->m_horizontal_position + pObject->m_width) && spd.h >= (pObject->m_vertical_position + pObject->m_height));
+
+ if (pObject && pObject->GetRLEDataSize() && pObject->m_width > 0 && pObject->m_height > 0 &&
+ spd.w >= (pObject->m_horizontal_position + pObject->m_width) &&
+ spd.h >= (pObject->m_vertical_position + pObject->m_height)) {
+ if (!pObject->HavePalette()) {
+ pObject->SetPalette(m_nDefaultPaletteNbEntry, m_pDefaultPalette, m_VideoDescriptor.nVideoWidth > 720);
+ }
+
+ TRACE_HDMVSUB("CHdmvSub:Render size=%ld, ObjRes=%dx%d, SPDRes=%dx%d\n", pObject->GetRLEDataSize(),
+ pObject->m_width, pObject->m_height, spd.w, spd.h);
+ pObject->RenderHdmv(spd);
+
+ bbox.left = pObject->m_horizontal_position;
+ bbox.top = pObject->m_vertical_position;
+ bbox.right = bbox.left + pObject->m_width;
+ bbox.bottom = bbox.top + pObject->m_height;
+ }
}
HRESULT CHdmvSub::GetTextureSize(POSITION pos, SIZE& MaxTextureSize, SIZE& VideoSize, POINT& VideoTopLeft)
{
- CompositionObject* pObject = m_pObjects.GetAt (pos);
- if (pObject) {
- MaxTextureSize.cx = VideoSize.cx = m_VideoDescriptor.nVideoWidth;
- MaxTextureSize.cy = VideoSize.cy = m_VideoDescriptor.nVideoHeight;
+ CompositionObject* pObject = m_pObjects.GetAt(pos);
+ if (pObject) {
+ MaxTextureSize.cx = VideoSize.cx = m_VideoDescriptor.nVideoWidth;
+ MaxTextureSize.cy = VideoSize.cy = m_VideoDescriptor.nVideoHeight;
- // The subs will be directly rendered into the proper position!
- VideoTopLeft.x = 0; //pObject->m_horizontal_position;
- VideoTopLeft.y = 0; //pObject->m_vertical_position;
+ // The subs will be directly rendered into the proper position!
+ VideoTopLeft.x = 0; //pObject->m_horizontal_position;
+ VideoTopLeft.y = 0; //pObject->m_vertical_position;
- return S_OK;
- }
+ return S_OK;
+ }
- ASSERT (FALSE);
- return E_INVALIDARG;
+ ASSERT(FALSE);
+ return E_INVALIDARG;
}
void CHdmvSub::Reset()
{
- CompositionObject* pObject;
- while (m_pObjects.GetCount() > 0) {
- pObject = m_pObjects.RemoveHead();
- delete pObject;
- }
+ CompositionObject* pObject;
+ while (m_pObjects.GetCount() > 0) {
+ pObject = m_pObjects.RemoveHead();
+ delete pObject;
+ }
}
-CompositionObject* CHdmvSub::FindObject(REFERENCE_TIME rt)
+CompositionObject* CHdmvSub::FindObject(REFERENCE_TIME rt)
{
- POSITION pos = m_pObjects.GetHeadPosition();
+ POSITION pos = m_pObjects.GetHeadPosition();
- while (pos) {
- CompositionObject* pObject = m_pObjects.GetAt (pos);
+ while (pos) {
+ CompositionObject* pObject = m_pObjects.GetAt(pos);
- if (rt >= pObject->m_rtStart && rt < pObject->m_rtStop) {
- return pObject;
- }
+ if (rt >= pObject->m_rtStart && rt < pObject->m_rtStop) {
+ return pObject;
+ }
- m_pObjects.GetNext(pos);
- }
+ m_pObjects.GetNext(pos);
+ }
- return NULL;
+ return NULL;
}
diff --git a/src/Subtitles/HdmvSub.h b/src/Subtitles/HdmvSub.h
index 6de22ff1c..828d05c40 100644
--- a/src/Subtitles/HdmvSub.h
+++ b/src/Subtitles/HdmvSub.h
@@ -30,92 +30,92 @@ class CHdmvSub : public CBaseSub
{
public:
- static const REFERENCE_TIME INVALID_TIME = _I64_MIN;
-
- enum HDMV_SEGMENT_TYPE {
- NO_SEGMENT = 0xFFFF,
- PALETTE = 0x14,
- OBJECT = 0x15,
- PRESENTATION_SEG = 0x16,
- WINDOW_DEF = 0x17,
- INTERACTIVE_SEG = 0x18,
- END_OF_DISPLAY = 0x80,
- HDMV_SUB1 = 0x81,
- HDMV_SUB2 = 0x82
- };
-
-
- struct VIDEO_DESCRIPTOR {
- SHORT nVideoWidth;
- SHORT nVideoHeight;
- BYTE bFrameRate; // <= Frame rate here!
- };
-
- struct COMPOSITION_DESCRIPTOR {
- SHORT nNumber;
- BYTE bState;
- };
-
- struct SEQUENCE_DESCRIPTOR {
- BYTE bFirstIn : 1;
- BYTE bLastIn : 1;
- BYTE bReserved : 8;
- };
-
- CHdmvSub();
- ~CHdmvSub();
-
- HRESULT ParseSample (IMediaSample* pSample);
-
-
- POSITION GetStartPosition(REFERENCE_TIME rt, double fps);
- POSITION GetNext(POSITION pos) {
- m_pObjects.GetNext(pos);
- return pos;
- };
-
-
- virtual REFERENCE_TIME GetStart(POSITION nPos) {
- CompositionObject* pObject = m_pObjects.GetAt(nPos);
- return pObject!=NULL ? pObject->m_rtStart : INVALID_TIME;
- };
- virtual REFERENCE_TIME GetStop(POSITION nPos) {
- CompositionObject* pObject = m_pObjects.GetAt(nPos);
- return pObject!=NULL ? pObject->m_rtStop : INVALID_TIME;
- };
-
- void Render(SubPicDesc& spd, REFERENCE_TIME rt, RECT& bbox);
- HRESULT GetTextureSize (POSITION pos, SIZE& MaxTextureSize, SIZE& VideoSize, POINT& VideoTopLeft);
- void Reset();
+ static const REFERENCE_TIME INVALID_TIME = _I64_MIN;
+
+ enum HDMV_SEGMENT_TYPE {
+ NO_SEGMENT = 0xFFFF,
+ PALETTE = 0x14,
+ OBJECT = 0x15,
+ PRESENTATION_SEG = 0x16,
+ WINDOW_DEF = 0x17,
+ INTERACTIVE_SEG = 0x18,
+ END_OF_DISPLAY = 0x80,
+ HDMV_SUB1 = 0x81,
+ HDMV_SUB2 = 0x82
+ };
+
+
+ struct VIDEO_DESCRIPTOR {
+ SHORT nVideoWidth;
+ SHORT nVideoHeight;
+ BYTE bFrameRate; // <= Frame rate here!
+ };
+
+ struct COMPOSITION_DESCRIPTOR {
+ SHORT nNumber;
+ BYTE bState;
+ };
+
+ struct SEQUENCE_DESCRIPTOR {
+ BYTE bFirstIn : 1;
+ BYTE bLastIn : 1;
+ BYTE bReserved : 8;
+ };
+
+ CHdmvSub();
+ ~CHdmvSub();
+
+ HRESULT ParseSample(IMediaSample* pSample);
+
+
+ POSITION GetStartPosition(REFERENCE_TIME rt, double fps);
+ POSITION GetNext(POSITION pos) {
+ m_pObjects.GetNext(pos);
+ return pos;
+ };
+
+
+ virtual REFERENCE_TIME GetStart(POSITION nPos) {
+ CompositionObject* pObject = m_pObjects.GetAt(nPos);
+ return pObject != NULL ? pObject->m_rtStart : INVALID_TIME;
+ };
+ virtual REFERENCE_TIME GetStop(POSITION nPos) {
+ CompositionObject* pObject = m_pObjects.GetAt(nPos);
+ return pObject != NULL ? pObject->m_rtStop : INVALID_TIME;
+ };
+
+ void Render(SubPicDesc& spd, REFERENCE_TIME rt, RECT& bbox);
+ HRESULT GetTextureSize(POSITION pos, SIZE& MaxTextureSize, SIZE& VideoSize, POINT& VideoTopLeft);
+ void Reset();
private :
- HDMV_SEGMENT_TYPE m_nCurSegment;
- BYTE* m_pSegBuffer;
- int m_nTotalSegBuffer;
- int m_nSegBufferPos;
- int m_nSegSize;
+ HDMV_SEGMENT_TYPE m_nCurSegment;
+ BYTE* m_pSegBuffer;
+ int m_nTotalSegBuffer;
+ int m_nSegBufferPos;
+ int m_nSegSize;
- VIDEO_DESCRIPTOR m_VideoDescriptor;
+ VIDEO_DESCRIPTOR m_VideoDescriptor;
- CompositionObject* m_pCurrentObject;
- CAtlList<CompositionObject*> m_pObjects;
+ CompositionObject* m_pCurrentObject;
+ CAtlList<CompositionObject*> m_pObjects;
- HDMV_PALETTE* m_pDefaultPalette;
- int m_nDefaultPaletteNbEntry;
+ HDMV_PALETTE* m_pDefaultPalette;
+ int m_nDefaultPaletteNbEntry;
- int m_nColorNumber;
+ int m_nColorNumber;
- int ParsePresentationSegment(CGolombBuffer* pGBuffer);
- void ParsePalette(CGolombBuffer* pGBuffer, USHORT nSize);
- void ParseObject(CGolombBuffer* pGBuffer, USHORT nUnitSize);
+ int ParsePresentationSegment(CGolombBuffer* pGBuffer);
+ void ParsePalette(CGolombBuffer* pGBuffer, USHORT nSize);
+ void ParseObject(CGolombBuffer* pGBuffer, USHORT nUnitSize);
- void ParseVideoDescriptor(CGolombBuffer* pGBuffer, VIDEO_DESCRIPTOR* pVideoDescriptor);
- void ParseCompositionDescriptor(CGolombBuffer* pGBuffer, COMPOSITION_DESCRIPTOR* pCompositionDescriptor);
- void ParseCompositionObject(CGolombBuffer* pGBuffer, CompositionObject* pCompositionObject);
+ void ParseVideoDescriptor(CGolombBuffer* pGBuffer, VIDEO_DESCRIPTOR* pVideoDescriptor);
+ void ParseCompositionDescriptor(CGolombBuffer* pGBuffer, COMPOSITION_DESCRIPTOR* pCompositionDescriptor);
+ void ParseCompositionObject(CGolombBuffer* pGBuffer, CompositionObject* pCompositionObject);
- void AllocSegment(int nSize);
+ void AllocSegment(int nSize);
- CompositionObject* FindObject(REFERENCE_TIME rt);
+ CompositionObject* FindObject(REFERENCE_TIME rt);
};
diff --git a/src/Subtitles/RTS.cpp b/src/Subtitles/RTS.cpp
index 6105cbae1..d84364669 100644
--- a/src/Subtitles/RTS.cpp
+++ b/src/Subtitles/RTS.cpp
@@ -33,7 +33,7 @@ static int g_hDC_refcnt = 0;
static long revcolor(long c)
{
- return ((c&0xff0000)>>16) + (c&0xff00) + ((c&0xff)<<16);
+ return ((c & 0xff0000) >> 16) + (c & 0xff00) + ((c & 0xff) << 16);
}
//////////////////////////////////////////////////////////////////////////////////////////////
@@ -42,460 +42,460 @@ static long revcolor(long c)
CMyFont::CMyFont(STSStyle& style)
{
- LOGFONT lf;
- memset(&lf, 0, sizeof(lf));
- lf <<= style;
- lf.lfHeight = (LONG)(style.fontSize+0.5);
- lf.lfOutPrecision = OUT_TT_PRECIS;
- lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
- lf.lfQuality = ANTIALIASED_QUALITY;
- lf.lfPitchAndFamily = DEFAULT_PITCH|FF_DONTCARE;
+ LOGFONT lf;
+ memset(&lf, 0, sizeof(lf));
+ lf <<= style;
+ lf.lfHeight = (LONG)(style.fontSize + 0.5);
+ lf.lfOutPrecision = OUT_TT_PRECIS;
+ lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
+ lf.lfQuality = ANTIALIASED_QUALITY;
+ lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
- if (!CreateFontIndirect(&lf)) {
- _tcscpy_s(lf.lfFaceName, _T("Arial"));
- CreateFontIndirect(&lf);
- }
+ if (!CreateFontIndirect(&lf)) {
+ _tcscpy_s(lf.lfFaceName, _T("Arial"));
+ CreateFontIndirect(&lf);
+ }
- HFONT hOldFont = SelectFont(g_hDC, *this);
- TEXTMETRIC tm;
- GetTextMetrics(g_hDC, &tm);
- m_ascent = ((tm.tmAscent + 4) >> 3);
- m_descent = ((tm.tmDescent + 4) >> 3);
- SelectFont(g_hDC, hOldFont);
+ HFONT hOldFont = SelectFont(g_hDC, *this);
+ TEXTMETRIC tm;
+ GetTextMetrics(g_hDC, &tm);
+ m_ascent = ((tm.tmAscent + 4) >> 3);
+ m_descent = ((tm.tmDescent + 4) >> 3);
+ SelectFont(g_hDC, hOldFont);
}
// CWord
CWord::CWord(STSStyle& style, CStringW str, int ktype, int kstart, int kend)
- : m_style(style), m_str(str)
- , m_width(0), m_ascent(0), m_descent(0)
- , m_ktype(ktype), m_kstart(kstart), m_kend(kend)
- , m_fDrawn(false), m_p(INT_MAX, INT_MAX)
- , m_fLineBreak(false), m_fWhiteSpaceChar(false)
- , m_pOpaqueBox(NULL)
+ : m_style(style), m_str(str)
+ , m_width(0), m_ascent(0), m_descent(0)
+ , m_ktype(ktype), m_kstart(kstart), m_kend(kend)
+ , m_fDrawn(false), m_p(INT_MAX, INT_MAX)
+ , m_fLineBreak(false), m_fWhiteSpaceChar(false)
+ , m_pOpaqueBox(NULL)
{
- if (str.IsEmpty()) {
- m_fWhiteSpaceChar = m_fLineBreak = true;
- }
+ if (str.IsEmpty()) {
+ m_fWhiteSpaceChar = m_fLineBreak = true;
+ }
- CMyFont font(m_style);
- m_ascent = (int)(m_style.fontScaleY/100*font.m_ascent);
- m_descent = (int)(m_style.fontScaleY/100*font.m_descent);
- m_width = 0;
+ CMyFont font(m_style);
+ m_ascent = (int)(m_style.fontScaleY / 100 * font.m_ascent);
+ m_descent = (int)(m_style.fontScaleY / 100 * font.m_descent);
+ m_width = 0;
}
CWord::~CWord()
{
- if (m_pOpaqueBox) {
- delete m_pOpaqueBox;
- }
+ if (m_pOpaqueBox) {
+ delete m_pOpaqueBox;
+ }
}
bool CWord::Append(CWord* w)
{
- if (!(m_style == w->m_style)
- || m_fLineBreak || w->m_fLineBreak
- || w->m_kstart != w->m_kend || m_ktype != w->m_ktype) {
- return false;
- }
+ if (!(m_style == w->m_style)
+ || m_fLineBreak || w->m_fLineBreak
+ || w->m_kstart != w->m_kend || m_ktype != w->m_ktype) {
+ return false;
+ }
- m_fWhiteSpaceChar = m_fWhiteSpaceChar && w->m_fWhiteSpaceChar;
- m_str += w->m_str;
- m_width += w->m_width;
+ m_fWhiteSpaceChar = m_fWhiteSpaceChar && w->m_fWhiteSpaceChar;
+ m_str += w->m_str;
+ m_width += w->m_width;
- m_fDrawn = false;
- m_p = CPoint(INT_MAX, INT_MAX);
+ m_fDrawn = false;
+ m_p = CPoint(INT_MAX, INT_MAX);
- return true;
+ return true;
}
void CWord::Paint(CPoint p, CPoint org)
{
- if (!m_str) {
- return;
- }
+ if (!m_str) {
+ return;
+ }
- if (!m_fDrawn) {
- if (!CreatePath()) {
- return;
- }
+ if (!m_fDrawn) {
+ if (!CreatePath()) {
+ return;
+ }
- Transform(CPoint((org.x-p.x)*8, (org.y-p.y)*8));
+ Transform(CPoint((org.x - p.x) * 8, (org.y - p.y) * 8));
- __try {
- if (!ScanConvert()) return;
- } __except (EXCEPTION_EXECUTE_HANDLER) {
- return;
- }
+ __try {
+ if (!ScanConvert()) { return; }
+ } __except (EXCEPTION_EXECUTE_HANDLER) {
+ return;
+ }
- if (m_style.borderStyle == 0 && (m_style.outlineWidthX+m_style.outlineWidthY > 0)) {
- if (!CreateWidenedRegion((int)(m_style.outlineWidthX+0.5), (int)(m_style.outlineWidthY+0.5))) {
- return;
- }
- } else if (m_style.borderStyle == 1) {
- if (!CreateOpaqueBox()) {
- return;
- }
- }
+ if (m_style.borderStyle == 0 && (m_style.outlineWidthX + m_style.outlineWidthY > 0)) {
+ if (!CreateWidenedRegion((int)(m_style.outlineWidthX + 0.5), (int)(m_style.outlineWidthY + 0.5))) {
+ return;
+ }
+ } else if (m_style.borderStyle == 1) {
+ if (!CreateOpaqueBox()) {
+ return;
+ }
+ }
- m_fDrawn = true;
+ m_fDrawn = true;
- if (!Rasterize(p.x&7, p.y&7, m_style.fBlur, m_style.fGaussianBlur)) {
- return;
- }
- } else if ((m_p.x&7) != (p.x&7) || (m_p.y&7) != (p.y&7)) {
- Rasterize(p.x&7, p.y&7, m_style.fBlur, m_style.fGaussianBlur);
- }
+ if (!Rasterize(p.x & 7, p.y & 7, m_style.fBlur, m_style.fGaussianBlur)) {
+ return;
+ }
+ } else if ((m_p.x & 7) != (p.x & 7) || (m_p.y & 7) != (p.y & 7)) {
+ Rasterize(p.x & 7, p.y & 7, m_style.fBlur, m_style.fGaussianBlur);
+ }
- m_p = p;
+ m_p = p;
- if (m_pOpaqueBox) {
- m_pOpaqueBox->Paint(p, org);
- }
+ if (m_pOpaqueBox) {
+ m_pOpaqueBox->Paint(p, org);
+ }
}
void CWord::Transform(CPoint org)
{
#ifdef _VSMOD
- // CPUID from VDub
- bool fSSE2 = !!(g_cpuid.m_flags & CCpuID::sse2);
+ // CPUID from VDub
+ bool fSSE2 = !!(g_cpuid.m_flags & CCpuID::sse2);
- if (fSSE2) { // SSE code
- Transform_SSE2(org);
- } else // C-code
+ if (fSSE2) { // SSE code
+ Transform_SSE2(org);
+ } else // C-code
#endif
- Transform_C(org);
+ Transform_C(org);
}
bool CWord::CreateOpaqueBox()
{
- if (m_pOpaqueBox) {
- return true;
- }
+ if (m_pOpaqueBox) {
+ return true;
+ }
- STSStyle style = m_style;
- style.borderStyle = 0;
- style.outlineWidthX = style.outlineWidthY = 0;
- style.colors[0] = m_style.colors[2];
- style.alpha[0] = m_style.alpha[2];
+ STSStyle style = m_style;
+ style.borderStyle = 0;
+ style.outlineWidthX = style.outlineWidthY = 0;
+ style.colors[0] = m_style.colors[2];
+ style.alpha[0] = m_style.alpha[2];
- int w = (int)(m_style.outlineWidthX + 0.5);
- int h = (int)(m_style.outlineWidthY + 0.5);
+ int w = (int)(m_style.outlineWidthX + 0.5);
+ int h = (int)(m_style.outlineWidthY + 0.5);
- CStringW str;
- str.Format(L"m %d %d l %d %d %d %d %d %d",
- -w, -h,
- m_width+w, -h,
- m_width+w, m_ascent+m_descent+h,
- -w, m_ascent+m_descent+h);
+ CStringW str;
+ str.Format(L"m %d %d l %d %d %d %d %d %d",
+ -w, -h,
+ m_width + w, -h,
+ m_width + w, m_ascent + m_descent + h,
+ -w, m_ascent + m_descent + h);
- m_pOpaqueBox = DNew CPolygon(style, str, 0, 0, 0, 1.0/8, 1.0/8, 0);
+ m_pOpaqueBox = DNew CPolygon(style, str, 0, 0, 0, 1.0 / 8, 1.0 / 8, 0);
- return !!m_pOpaqueBox;
+ return !!m_pOpaqueBox;
}
-void CWord::Transform_C( CPoint &org )
+void CWord::Transform_C(CPoint& org)
{
- double scalex = m_style.fontScaleX/100;
- double scaley = m_style.fontScaleY/100;
+ double scalex = m_style.fontScaleX / 100;
+ double scaley = m_style.fontScaleY / 100;
- double caz = cos((3.1415/180)*m_style.fontAngleZ);
- double saz = sin((3.1415/180)*m_style.fontAngleZ);
- double cax = cos((3.1415/180)*m_style.fontAngleX);
- double sax = sin((3.1415/180)*m_style.fontAngleX);
- double cay = cos((3.1415/180)*m_style.fontAngleY);
- double say = sin((3.1415/180)*m_style.fontAngleY);
+ double caz = cos((3.1415 / 180) * m_style.fontAngleZ);
+ double saz = sin((3.1415 / 180) * m_style.fontAngleZ);
+ double cax = cos((3.1415 / 180) * m_style.fontAngleX);
+ double sax = sin((3.1415 / 180) * m_style.fontAngleX);
+ double cay = cos((3.1415 / 180) * m_style.fontAngleY);
+ double say = sin((3.1415 / 180) * m_style.fontAngleY);
- for (ptrdiff_t i = 0; i < mPathPoints; i++) {
- double x, y, z, xx, yy, zz;
+ for (ptrdiff_t i = 0; i < mPathPoints; i++) {
+ double x, y, z, xx, yy, zz;
- x = mpPathPoints[i].x;
- y = mpPathPoints[i].y;
- z = 0;
+ x = mpPathPoints[i].x;
+ y = mpPathPoints[i].y;
+ z = 0;
- double _x = x;
- x = scalex * (x + m_style.fontShiftX * y) - org.x;
- y = scaley * (y + m_style.fontShiftY * _x) - org.y;
+ double _x = x;
+ x = scalex * (x + m_style.fontShiftX * y) - org.x;
+ y = scaley * (y + m_style.fontShiftY * _x) - org.y;
- xx = x*caz + y*saz;
- yy = -(x*saz - y*caz);
- zz = z;
+ xx = x * caz + y * saz;
+ yy = -(x * saz - y * caz);
+ zz = z;
- x = xx;
- y = yy*cax + zz*sax;
- z = yy*sax - zz*cax;
+ x = xx;
+ y = yy * cax + zz * sax;
+ z = yy * sax - zz * cax;
- xx = x*cay + z*say;
- yy = y;
- zz = x*say - z*cay;
+ xx = x * cay + z * say;
+ yy = y;
+ zz = x * say - z * cay;
- zz = max(zz, -19000);
+ zz = max(zz, -19000);
- x = (xx * 20000) / (zz + 20000);
- y = (yy * 20000) / (zz + 20000);
+ x = (xx * 20000) / (zz + 20000);
+ y = (yy * 20000) / (zz + 20000);
- mpPathPoints[i].x = (LONG)(x + org.x + 0.5);
- mpPathPoints[i].y = (LONG)(y + org.y + 0.5);
- }
+ mpPathPoints[i].x = (LONG)(x + org.x + 0.5);
+ mpPathPoints[i].y = (LONG)(y + org.y + 0.5);
+ }
}
-void CWord::Transform_SSE2( CPoint &org )
+void CWord::Transform_SSE2(CPoint& org)
{
- // __m128 union data type currently not supported with Intel C++ Compiler, so just call C version
+ // __m128 union data type currently not supported with Intel C++ Compiler, so just call C version
#ifdef __INTEL_COMPILER
- Transform_C(org);
+ Transform_C(org);
#else
- // SSE code
- // speed up ~1.5-1.7x
- double scalex = m_style.fontScaleX/100;
- double scaley = m_style.fontScaleY/100;
-
- double caz = cos((3.1415/180)*m_style.fontAngleZ);
- double saz = sin((3.1415/180)*m_style.fontAngleZ);
- double cax = cos((3.1415/180)*m_style.fontAngleX);
- double sax = sin((3.1415/180)*m_style.fontAngleX);
- double cay = cos((3.1415/180)*m_style.fontAngleY);
- double say = sin((3.1415/180)*m_style.fontAngleY);
-
- __m128 __xshift = _mm_set_ps1((float)m_style.fontShiftX);
- __m128 __yshift = _mm_set_ps1((float)m_style.fontShiftY);
-
- __m128 __xorg = _mm_set_ps1((float)org.x);
- __m128 __yorg = _mm_set_ps1((float)org.y);
-
- __m128 __xscale = _mm_set_ps1((float)scalex);
- __m128 __yscale = _mm_set_ps1((float)scaley);
-
- __m128 __caz = _mm_set_ps1((float)caz);
- __m128 __saz = _mm_set_ps1((float)saz);
- __m128 __cax = _mm_set_ps1((float)cax);
- __m128 __sax = _mm_set_ps1((float)sax);
- __m128 __cay = _mm_set_ps1((float)cay);
- __m128 __say = _mm_set_ps1((float)say);
-
- // this can be paralleled for openmp
- int mPathPointsD4 = mPathPoints / 4;
- int mPathPointsM4 = mPathPoints % 4;
-
- for (ptrdiff_t i = 0; i < mPathPointsD4 + 1; i++) {
- __m128 __pointx, __pointy;
- // we can't use load .-.
- if (i != mPathPointsD4) {
- __pointx = _mm_set_ps((float)mpPathPoints[4 * i + 0].x, (float)mpPathPoints[4 * i + 1].x, (float)mpPathPoints[4 * i + 2].x, (float)mpPathPoints[4 * i + 3].x);
- __pointy = _mm_set_ps((float)mpPathPoints[4 * i + 0].y, (float)mpPathPoints[4 * i + 1].y, (float)mpPathPoints[4 * i + 2].y, (float)mpPathPoints[4 * i + 3].y);
- } else { // last cycle
- switch (mPathPointsM4) {
- default:
- case 0:
- continue;
- case 1:
- __pointx = _mm_set_ps((float)mpPathPoints[4 * i + 0].x, 0, 0, 0);
- __pointy = _mm_set_ps((float)mpPathPoints[4 * i + 0].y, 0, 0, 0);
- break;
- case 2:
- __pointx = _mm_set_ps((float)mpPathPoints[4 * i + 0].x, (float)mpPathPoints[4 * i + 1].x, 0, 0);
- __pointy = _mm_set_ps((float)mpPathPoints[4 * i + 0].y, (float)mpPathPoints[4 * i + 1].y, 0, 0);
- break;
- case 3:
- __pointx = _mm_set_ps((float)mpPathPoints[4 * i + 0].x, (float)mpPathPoints[4 * i + 1].x, (float)mpPathPoints[4 * i + 2].x, 0);
- __pointy = _mm_set_ps((float)mpPathPoints[4 * i + 0].y, (float)mpPathPoints[4 * i + 1].y, (float)mpPathPoints[4 * i + 2].y, 0);
- break;
- }
- }
-
- __m128 __pointz = _mm_set_ps1(0);
-
- // scale and shift
- __m128 __tmpx;
- if (m_style.fontShiftX!=0) {
- __tmpx = _mm_mul_ps(__xshift, __pointy);
- __tmpx = _mm_add_ps(__tmpx, __pointx);
- } else {
- __tmpx = __pointx;
- }
- __tmpx = _mm_mul_ps(__tmpx, __xscale);
- __tmpx = _mm_sub_ps(__tmpx, __xorg);
-
- __m128 __tmpy;
- if (m_style.fontShiftY!=0) {
- __tmpy = _mm_mul_ps(__yshift, __pointx);
- __tmpy = _mm_add_ps(__tmpy, __pointy);
- } else {
- __tmpy = __pointy;
- }
- __tmpy = _mm_mul_ps(__tmpy, __yscale);
- __tmpy = _mm_sub_ps(__tmpy, __yorg);
-
- // rotate
- __m128 __xx = _mm_mul_ps(__tmpx, __caz);
- __m128 __yy = _mm_mul_ps(__tmpy, __saz);
- __pointx = _mm_add_ps(__xx, __yy);
- __xx = _mm_mul_ps(__tmpx, __saz);
- __yy = _mm_mul_ps(__tmpy, __caz);
- __pointy = _mm_sub_ps(__yy, __xx);
-
- __m128 __zz = _mm_mul_ps(__pointz, __sax);
- __yy = _mm_mul_ps(__pointy, __cax);
- __pointy = _mm_add_ps(__yy, __zz);
- __zz = _mm_mul_ps(__pointz, __cax);
- __yy = _mm_mul_ps(__pointy, __sax);
- __pointz = _mm_sub_ps(__zz, __yy);
-
- __xx = _mm_mul_ps(__pointx, __cay);
- __zz = _mm_mul_ps(__pointz, __say);
- __pointx = _mm_add_ps(__xx, __zz);
- __xx = _mm_mul_ps(__pointx, __say);
- __zz = _mm_mul_ps(__pointz, __cay);
- __pointz = _mm_sub_ps(__xx, __zz);
-
- __zz = _mm_set_ps1(-19000);
- __pointz = _mm_max_ps(__pointz, __zz);
-
- __m128 __20000 = _mm_set_ps1(20000);
- __zz = _mm_add_ps(__pointz, __20000);
- __zz = _mm_rcp_ps(__zz);
-
- __pointx = _mm_mul_ps(__pointx, __20000);
- __pointx = _mm_mul_ps(__pointx, __zz);
-
- __pointy = _mm_mul_ps(__pointy, __20000);
- __pointy = _mm_mul_ps(__pointy, __zz);
-
- __pointx = _mm_add_ps(__pointx, __xorg);
- __pointy = _mm_add_ps(__pointy, __yorg);
-
- __m128 __05 = _mm_set_ps1(0.5);
-
- __pointx = _mm_add_ps(__pointx, __05);
- __pointy = _mm_add_ps(__pointy, __05);
-
- if (i == mPathPointsD4) { // last cycle
- for (int k=0; k<mPathPointsM4; k++) {
- mpPathPoints[i*4+k].x = static_cast<LONG>(__pointx.m128_f32[3-k]);
- mpPathPoints[i*4+k].y = static_cast<LONG>(__pointy.m128_f32[3-k]);
- }
- } else {
- for (int k=0; k<4; k++) {
- mpPathPoints[i*4+k].x = static_cast<LONG>(__pointx.m128_f32[3-k]);
- mpPathPoints[i*4+k].y = static_cast<LONG>(__pointy.m128_f32[3-k]);
- }
- }
- }
+ // SSE code
+ // speed up ~1.5-1.7x
+ double scalex = m_style.fontScaleX / 100;
+ double scaley = m_style.fontScaleY / 100;
+
+ double caz = cos((3.1415 / 180) * m_style.fontAngleZ);
+ double saz = sin((3.1415 / 180) * m_style.fontAngleZ);
+ double cax = cos((3.1415 / 180) * m_style.fontAngleX);
+ double sax = sin((3.1415 / 180) * m_style.fontAngleX);
+ double cay = cos((3.1415 / 180) * m_style.fontAngleY);
+ double say = sin((3.1415 / 180) * m_style.fontAngleY);
+
+ __m128 __xshift = _mm_set_ps1((float)m_style.fontShiftX);
+ __m128 __yshift = _mm_set_ps1((float)m_style.fontShiftY);
+
+ __m128 __xorg = _mm_set_ps1((float)org.x);
+ __m128 __yorg = _mm_set_ps1((float)org.y);
+
+ __m128 __xscale = _mm_set_ps1((float)scalex);
+ __m128 __yscale = _mm_set_ps1((float)scaley);
+
+ __m128 __caz = _mm_set_ps1((float)caz);
+ __m128 __saz = _mm_set_ps1((float)saz);
+ __m128 __cax = _mm_set_ps1((float)cax);
+ __m128 __sax = _mm_set_ps1((float)sax);
+ __m128 __cay = _mm_set_ps1((float)cay);
+ __m128 __say = _mm_set_ps1((float)say);
+
+ // this can be paralleled for openmp
+ int mPathPointsD4 = mPathPoints / 4;
+ int mPathPointsM4 = mPathPoints % 4;
+
+ for (ptrdiff_t i = 0; i < mPathPointsD4 + 1; i++) {
+ __m128 __pointx, __pointy;
+ // we can't use load .-.
+ if (i != mPathPointsD4) {
+ __pointx = _mm_set_ps((float)mpPathPoints[4 * i + 0].x, (float)mpPathPoints[4 * i + 1].x, (float)mpPathPoints[4 * i + 2].x, (float)mpPathPoints[4 * i + 3].x);
+ __pointy = _mm_set_ps((float)mpPathPoints[4 * i + 0].y, (float)mpPathPoints[4 * i + 1].y, (float)mpPathPoints[4 * i + 2].y, (float)mpPathPoints[4 * i + 3].y);
+ } else { // last cycle
+ switch (mPathPointsM4) {
+ default:
+ case 0:
+ continue;
+ case 1:
+ __pointx = _mm_set_ps((float)mpPathPoints[4 * i + 0].x, 0, 0, 0);
+ __pointy = _mm_set_ps((float)mpPathPoints[4 * i + 0].y, 0, 0, 0);
+ break;
+ case 2:
+ __pointx = _mm_set_ps((float)mpPathPoints[4 * i + 0].x, (float)mpPathPoints[4 * i + 1].x, 0, 0);
+ __pointy = _mm_set_ps((float)mpPathPoints[4 * i + 0].y, (float)mpPathPoints[4 * i + 1].y, 0, 0);
+ break;
+ case 3:
+ __pointx = _mm_set_ps((float)mpPathPoints[4 * i + 0].x, (float)mpPathPoints[4 * i + 1].x, (float)mpPathPoints[4 * i + 2].x, 0);
+ __pointy = _mm_set_ps((float)mpPathPoints[4 * i + 0].y, (float)mpPathPoints[4 * i + 1].y, (float)mpPathPoints[4 * i + 2].y, 0);
+ break;
+ }
+ }
+
+ __m128 __pointz = _mm_set_ps1(0);
+
+ // scale and shift
+ __m128 __tmpx;
+ if (m_style.fontShiftX != 0) {
+ __tmpx = _mm_mul_ps(__xshift, __pointy);
+ __tmpx = _mm_add_ps(__tmpx, __pointx);
+ } else {
+ __tmpx = __pointx;
+ }
+ __tmpx = _mm_mul_ps(__tmpx, __xscale);
+ __tmpx = _mm_sub_ps(__tmpx, __xorg);
+
+ __m128 __tmpy;
+ if (m_style.fontShiftY != 0) {
+ __tmpy = _mm_mul_ps(__yshift, __pointx);
+ __tmpy = _mm_add_ps(__tmpy, __pointy);
+ } else {
+ __tmpy = __pointy;
+ }
+ __tmpy = _mm_mul_ps(__tmpy, __yscale);
+ __tmpy = _mm_sub_ps(__tmpy, __yorg);
+
+ // rotate
+ __m128 __xx = _mm_mul_ps(__tmpx, __caz);
+ __m128 __yy = _mm_mul_ps(__tmpy, __saz);
+ __pointx = _mm_add_ps(__xx, __yy);
+ __xx = _mm_mul_ps(__tmpx, __saz);
+ __yy = _mm_mul_ps(__tmpy, __caz);
+ __pointy = _mm_sub_ps(__yy, __xx);
+
+ __m128 __zz = _mm_mul_ps(__pointz, __sax);
+ __yy = _mm_mul_ps(__pointy, __cax);
+ __pointy = _mm_add_ps(__yy, __zz);
+ __zz = _mm_mul_ps(__pointz, __cax);
+ __yy = _mm_mul_ps(__pointy, __sax);
+ __pointz = _mm_sub_ps(__zz, __yy);
+
+ __xx = _mm_mul_ps(__pointx, __cay);
+ __zz = _mm_mul_ps(__pointz, __say);
+ __pointx = _mm_add_ps(__xx, __zz);
+ __xx = _mm_mul_ps(__pointx, __say);
+ __zz = _mm_mul_ps(__pointz, __cay);
+ __pointz = _mm_sub_ps(__xx, __zz);
+
+ __zz = _mm_set_ps1(-19000);
+ __pointz = _mm_max_ps(__pointz, __zz);
+
+ __m128 __20000 = _mm_set_ps1(20000);
+ __zz = _mm_add_ps(__pointz, __20000);
+ __zz = _mm_rcp_ps(__zz);
+
+ __pointx = _mm_mul_ps(__pointx, __20000);
+ __pointx = _mm_mul_ps(__pointx, __zz);
+
+ __pointy = _mm_mul_ps(__pointy, __20000);
+ __pointy = _mm_mul_ps(__pointy, __zz);
+
+ __pointx = _mm_add_ps(__pointx, __xorg);
+ __pointy = _mm_add_ps(__pointy, __yorg);
+
+ __m128 __05 = _mm_set_ps1(0.5);
+
+ __pointx = _mm_add_ps(__pointx, __05);
+ __pointy = _mm_add_ps(__pointy, __05);
+
+ if (i == mPathPointsD4) { // last cycle
+ for (int k = 0; k < mPathPointsM4; k++) {
+ mpPathPoints[i * 4 + k].x = static_cast<LONG>(__pointx.m128_f32[3 - k]);
+ mpPathPoints[i * 4 + k].y = static_cast<LONG>(__pointy.m128_f32[3 - k]);
+ }
+ } else {
+ for (int k = 0; k < 4; k++) {
+ mpPathPoints[i * 4 + k].x = static_cast<LONG>(__pointx.m128_f32[3 - k]);
+ mpPathPoints[i * 4 + k].y = static_cast<LONG>(__pointy.m128_f32[3 - k]);
+ }
+ }
+ }
#endif // __INTEL_COMPILER
}
// CText
CText::CText(STSStyle& style, CStringW str, int ktype, int kstart, int kend)
- : CWord(style, str, ktype, kstart, kend)
-{
- if (m_str == L" ") {
- m_fWhiteSpaceChar = true;
- }
-
- CMyFont font(m_style);
-
- HFONT hOldFont = SelectFont(g_hDC, font);
-
- if (m_style.fontSpacing || (long)GetVersion() < 0) {
- for (LPCWSTR s = m_str; *s; s++) {
- CSize extent;
- if (!GetTextExtentPoint32W(g_hDC, s, 1, &extent)) {
- SelectFont(g_hDC, hOldFont);
- ASSERT(0);
- return;
- }
- m_width += extent.cx + (int)m_style.fontSpacing;
- }
- // m_width -= (int)m_style.fontSpacing; // TODO: subtract only at the end of the line
- } else {
- CSize extent;
- if (!GetTextExtentPoint32W(g_hDC, m_str, (int)wcslen(str), &extent)) {
- SelectFont(g_hDC, hOldFont);
- ASSERT(0);
- return;
- }
- m_width += extent.cx;
- }
-
- m_width = (int)(m_style.fontScaleX/100*m_width + 4) >> 3;
-
- SelectFont(g_hDC, hOldFont);
+ : CWord(style, str, ktype, kstart, kend)
+{
+ if (m_str == L" ") {
+ m_fWhiteSpaceChar = true;
+ }
+
+ CMyFont font(m_style);
+
+ HFONT hOldFont = SelectFont(g_hDC, font);
+
+ if (m_style.fontSpacing || (long)GetVersion() < 0) {
+ for (LPCWSTR s = m_str; *s; s++) {
+ CSize extent;
+ if (!GetTextExtentPoint32W(g_hDC, s, 1, &extent)) {
+ SelectFont(g_hDC, hOldFont);
+ ASSERT(0);
+ return;
+ }
+ m_width += extent.cx + (int)m_style.fontSpacing;
+ }
+ // m_width -= (int)m_style.fontSpacing; // TODO: subtract only at the end of the line
+ } else {
+ CSize extent;
+ if (!GetTextExtentPoint32W(g_hDC, m_str, (int)wcslen(str), &extent)) {
+ SelectFont(g_hDC, hOldFont);
+ ASSERT(0);
+ return;
+ }
+ m_width += extent.cx;
+ }
+
+ m_width = (int)(m_style.fontScaleX / 100 * m_width + 4) >> 3;
+
+ SelectFont(g_hDC, hOldFont);
}
CWord* CText::Copy()
{
- return DNew CText(*this);
+ return DNew CText(*this);
}
bool CText::Append(CWord* w)
{
- return (dynamic_cast<CText*>(w) && CWord::Append(w));
+ return (dynamic_cast<CText*>(w) && CWord::Append(w));
}
bool CText::CreatePath()
{
- CMyFont font(m_style);
+ CMyFont font(m_style);
- HFONT hOldFont = SelectFont(g_hDC, font);
+ HFONT hOldFont = SelectFont(g_hDC, font);
- if (m_style.fontSpacing || (long)GetVersion() < 0) {
- int width = 0;
- bool bFirstPath = true;
+ if (m_style.fontSpacing || (long)GetVersion() < 0) {
+ int width = 0;
+ bool bFirstPath = true;
- for (LPCWSTR s = m_str; *s; s++) {
- CSize extent;
- if (!GetTextExtentPoint32W(g_hDC, s, 1, &extent)) {
- SelectFont(g_hDC, hOldFont);
- ASSERT(0);
- return false;
- }
+ for (LPCWSTR s = m_str; *s; s++) {
+ CSize extent;
+ if (!GetTextExtentPoint32W(g_hDC, s, 1, &extent)) {
+ SelectFont(g_hDC, hOldFont);
+ ASSERT(0);
+ return false;
+ }
- PartialBeginPath(g_hDC, bFirstPath);
- bFirstPath = false;
- TextOutW(g_hDC, 0, 0, s, 1);
- PartialEndPath(g_hDC, width, 0);
+ PartialBeginPath(g_hDC, bFirstPath);
+ bFirstPath = false;
+ TextOutW(g_hDC, 0, 0, s, 1);
+ PartialEndPath(g_hDC, width, 0);
- width += extent.cx + (int)m_style.fontSpacing;
- }
- } else {
- CSize extent;
- if (!GetTextExtentPoint32W(g_hDC, m_str, m_str.GetLength(), &extent)) {
- SelectFont(g_hDC, hOldFont);
- ASSERT(0);
- return false;
- }
+ width += extent.cx + (int)m_style.fontSpacing;
+ }
+ } else {
+ CSize extent;
+ if (!GetTextExtentPoint32W(g_hDC, m_str, m_str.GetLength(), &extent)) {
+ SelectFont(g_hDC, hOldFont);
+ ASSERT(0);
+ return false;
+ }
- BeginPath(g_hDC);
- TextOutW(g_hDC, 0, 0, m_str, m_str.GetLength());
- EndPath(g_hDC);
- }
+ BeginPath(g_hDC);
+ TextOutW(g_hDC, 0, 0, m_str, m_str.GetLength());
+ EndPath(g_hDC);
+ }
- SelectFont(g_hDC, hOldFont);
+ SelectFont(g_hDC, hOldFont);
- return true;
+ return true;
}
// CPolygon
CPolygon::CPolygon(STSStyle& style, CStringW str, int ktype, int kstart, int kend, double scalex, double scaley, int baseline)
- : CWord(style, str, ktype, kstart, kend)
- , m_scalex(scalex), m_scaley(scaley), m_baseline(baseline)
+ : CWord(style, str, ktype, kstart, kend)
+ , m_scalex(scalex), m_scaley(scaley), m_baseline(baseline)
{
- ParseStr();
+ ParseStr();
}
CPolygon::CPolygon(CPolygon& src) : CWord(src.m_style, src.m_str, src.m_ktype, src.m_kstart, src.m_kend)
{
- m_scalex = src.m_scalex;
- m_scaley = src.m_scaley;
- m_baseline = src.m_baseline;
- m_width = src.m_width;
- m_ascent = src.m_ascent;
- m_descent = src.m_descent;
+ m_scalex = src.m_scalex;
+ m_scaley = src.m_scaley;
+ m_baseline = src.m_baseline;
+ m_width = src.m_width;
+ m_ascent = src.m_ascent;
+ m_descent = src.m_descent;
- m_pathTypesOrg.Copy(src.m_pathTypesOrg);
- m_pathPointsOrg.Copy(src.m_pathPointsOrg);
+ m_pathTypesOrg.Copy(src.m_pathTypesOrg);
+ m_pathPointsOrg.Copy(src.m_pathPointsOrg);
}
CPolygon::~CPolygon()
@@ -504,523 +504,523 @@ CPolygon::~CPolygon()
CWord* CPolygon::Copy()
{
- return (DNew CPolygon(*this));
+ return (DNew CPolygon(*this));
}
bool CPolygon::Append(CWord* w)
{
- CPolygon* p = dynamic_cast<CPolygon*>(w);
- if (!p) {
- return false;
- }
+ CPolygon* p = dynamic_cast<CPolygon*>(w);
+ if (!p) {
+ return false;
+ }
- // TODO
- return false;
+ // TODO
+ return false;
- //return true;
+ //return true;
}
bool CPolygon::GetLONG(CStringW& str, LONG& ret)
{
- LPWSTR s = (LPWSTR)(LPCWSTR)str, e = s;
- ret = wcstol(str, &e, 10);
- str.Delete(0,int(e-s));
- return (e > s);
+ LPWSTR s = (LPWSTR)(LPCWSTR)str, e = s;
+ ret = wcstol(str, &e, 10);
+ str.Delete(0, int(e - s));
+ return (e > s);
}
bool CPolygon::GetPOINT(CStringW& str, POINT& ret)
{
- return (GetLONG(str, ret.x) && GetLONG(str, ret.y));
+ return (GetLONG(str, ret.x) && GetLONG(str, ret.y));
}
bool CPolygon::ParseStr()
{
- if (m_pathTypesOrg.GetCount() > 0) {
- return true;
- }
-
- CPoint p;
- int i, j, lastsplinestart = -1, firstmoveto = -1, lastmoveto = -1;
-
- CStringW str = m_str;
- str.SpanIncluding(L"mnlbspc 0123456789");
- str.Replace(L"m", L"*m");
- str.Replace(L"n", L"*n");
- str.Replace(L"l", L"*l");
- str.Replace(L"b", L"*b");
- str.Replace(L"s", L"*s");
- str.Replace(L"p", L"*p");
- str.Replace(L"c", L"*c");
-
- int k = 0;
- for (CStringW s = str.Tokenize(L"*", k); !s.IsEmpty(); s = str.Tokenize(L"*", k)) {
- WCHAR c = s[0];
- s.TrimLeft(L"mnlbspc ");
- switch (c) {
- case 'm':
- lastmoveto = (int)m_pathTypesOrg.GetCount();
- if (firstmoveto == -1) {
- firstmoveto = lastmoveto;
- }
- while (GetPOINT(s, p)) {
- m_pathTypesOrg.Add(PT_MOVETO);
- m_pathPointsOrg.Add(p);
- }
- break;
- case 'n':
- while (GetPOINT(s, p)) {
- m_pathTypesOrg.Add(PT_MOVETONC);
- m_pathPointsOrg.Add(p);
- }
- break;
- case 'l':
- if (m_pathPointsOrg.GetCount() < 1) {
- break;
- }
- while (GetPOINT(s, p)) {
- m_pathTypesOrg.Add(PT_LINETO);
- m_pathPointsOrg.Add(p);
- }
- break;
- case 'b':
- j = (int)m_pathTypesOrg.GetCount();
- if (j < 1) {
- break;
- }
- while (GetPOINT(s, p)) {
- m_pathTypesOrg.Add(PT_BEZIERTO);
- m_pathPointsOrg.Add(p);
- j++;
- }
- j = (int)(m_pathTypesOrg.GetCount() - ((m_pathTypesOrg.GetCount() - j) % 3));
- m_pathTypesOrg.SetCount(j);
- m_pathPointsOrg.SetCount(j);
- break;
- case 's':
- if (m_pathPointsOrg.GetCount() < 1) {
- break;
- }
- j = lastsplinestart = (int)m_pathTypesOrg.GetCount();
- i = 3;
- while (i-- && GetPOINT(s, p)) {
- m_pathTypesOrg.Add(PT_BSPLINETO);
- m_pathPointsOrg.Add(p);
- j++;
- }
- if (m_pathTypesOrg.GetCount() - lastsplinestart < 3) {
- m_pathTypesOrg.SetCount(lastsplinestart);
- m_pathPointsOrg.SetCount(lastsplinestart);
- lastsplinestart = -1;
- }
- // no break here
- case 'p':
- if (m_pathPointsOrg.GetCount() < 3) {
- break;
- }
- while (GetPOINT(s, p)) {
- m_pathTypesOrg.Add(PT_BSPLINEPATCHTO);
- m_pathPointsOrg.Add(p);
- }
- break;
- case 'c':
- if (lastsplinestart > 0) {
- m_pathTypesOrg.Add(PT_BSPLINEPATCHTO);
- m_pathTypesOrg.Add(PT_BSPLINEPATCHTO);
- m_pathTypesOrg.Add(PT_BSPLINEPATCHTO);
- p = m_pathPointsOrg[lastsplinestart-1]; // we need p for temp storage, because operator [] will return a reference to CPoint and Add() may reallocate its internal buffer (this is true for MFC 7.0 but not for 6.0, hehe)
- m_pathPointsOrg.Add(p);
- p = m_pathPointsOrg[lastsplinestart];
- m_pathPointsOrg.Add(p);
- p = m_pathPointsOrg[lastsplinestart+1];
- m_pathPointsOrg.Add(p);
- lastsplinestart = -1;
- }
- break;
- default:
- break;
- }
- }
-
- if (lastmoveto == -1 || firstmoveto > 0) {
- m_pathTypesOrg.RemoveAll();
- m_pathPointsOrg.RemoveAll();
- return false;
- }
-
- int minx = INT_MAX, miny = INT_MAX, maxx = -INT_MAX, maxy = -INT_MAX;
-
- for (size_t k = 0; k < m_pathTypesOrg.GetCount(); k++) {
- m_pathPointsOrg[k].x = (int)(64 * m_scalex * m_pathPointsOrg[k].x);
- m_pathPointsOrg[k].y = (int)(64 * m_scaley * m_pathPointsOrg[k].y);
- if (minx > m_pathPointsOrg[k].x) {
- minx = m_pathPointsOrg[k].x;
- }
- if (miny > m_pathPointsOrg[k].y) {
- miny = m_pathPointsOrg[k].y;
- }
- if (maxx < m_pathPointsOrg[k].x) {
- maxx = m_pathPointsOrg[k].x;
- }
- if (maxy < m_pathPointsOrg[k].y) {
- maxy = m_pathPointsOrg[k].y;
- }
- }
-
- m_width = max(maxx - minx, 0);
- m_ascent = max(maxy - miny, 0);
-
- int baseline = (int)(64 * m_scaley * m_baseline);
- m_descent = baseline;
- m_ascent -= baseline;
-
- m_width = ((int)(m_style.fontScaleX/100 * m_width) + 4) >> 3;
- m_ascent = ((int)(m_style.fontScaleY/100 * m_ascent) + 4) >> 3;
- m_descent = ((int)(m_style.fontScaleY/100 * m_descent) + 4) >> 3;
-
- return true;
+ if (m_pathTypesOrg.GetCount() > 0) {
+ return true;
+ }
+
+ CPoint p;
+ int i, j, lastsplinestart = -1, firstmoveto = -1, lastmoveto = -1;
+
+ CStringW str = m_str;
+ str.SpanIncluding(L"mnlbspc 0123456789");
+ str.Replace(L"m", L"*m");
+ str.Replace(L"n", L"*n");
+ str.Replace(L"l", L"*l");
+ str.Replace(L"b", L"*b");
+ str.Replace(L"s", L"*s");
+ str.Replace(L"p", L"*p");
+ str.Replace(L"c", L"*c");
+
+ int k = 0;
+ for (CStringW s = str.Tokenize(L"*", k); !s.IsEmpty(); s = str.Tokenize(L"*", k)) {
+ WCHAR c = s[0];
+ s.TrimLeft(L"mnlbspc ");
+ switch (c) {
+ case 'm':
+ lastmoveto = (int)m_pathTypesOrg.GetCount();
+ if (firstmoveto == -1) {
+ firstmoveto = lastmoveto;
+ }
+ while (GetPOINT(s, p)) {
+ m_pathTypesOrg.Add(PT_MOVETO);
+ m_pathPointsOrg.Add(p);
+ }
+ break;
+ case 'n':
+ while (GetPOINT(s, p)) {
+ m_pathTypesOrg.Add(PT_MOVETONC);
+ m_pathPointsOrg.Add(p);
+ }
+ break;
+ case 'l':
+ if (m_pathPointsOrg.GetCount() < 1) {
+ break;
+ }
+ while (GetPOINT(s, p)) {
+ m_pathTypesOrg.Add(PT_LINETO);
+ m_pathPointsOrg.Add(p);
+ }
+ break;
+ case 'b':
+ j = (int)m_pathTypesOrg.GetCount();
+ if (j < 1) {
+ break;
+ }
+ while (GetPOINT(s, p)) {
+ m_pathTypesOrg.Add(PT_BEZIERTO);
+ m_pathPointsOrg.Add(p);
+ j++;
+ }
+ j = (int)(m_pathTypesOrg.GetCount() - ((m_pathTypesOrg.GetCount() - j) % 3));
+ m_pathTypesOrg.SetCount(j);
+ m_pathPointsOrg.SetCount(j);
+ break;
+ case 's':
+ if (m_pathPointsOrg.GetCount() < 1) {
+ break;
+ }
+ j = lastsplinestart = (int)m_pathTypesOrg.GetCount();
+ i = 3;
+ while (i-- && GetPOINT(s, p)) {
+ m_pathTypesOrg.Add(PT_BSPLINETO);
+ m_pathPointsOrg.Add(p);
+ j++;
+ }
+ if (m_pathTypesOrg.GetCount() - lastsplinestart < 3) {
+ m_pathTypesOrg.SetCount(lastsplinestart);
+ m_pathPointsOrg.SetCount(lastsplinestart);
+ lastsplinestart = -1;
+ }
+ // no break here
+ case 'p':
+ if (m_pathPointsOrg.GetCount() < 3) {
+ break;
+ }
+ while (GetPOINT(s, p)) {
+ m_pathTypesOrg.Add(PT_BSPLINEPATCHTO);
+ m_pathPointsOrg.Add(p);
+ }
+ break;
+ case 'c':
+ if (lastsplinestart > 0) {
+ m_pathTypesOrg.Add(PT_BSPLINEPATCHTO);
+ m_pathTypesOrg.Add(PT_BSPLINEPATCHTO);
+ m_pathTypesOrg.Add(PT_BSPLINEPATCHTO);
+ p = m_pathPointsOrg[lastsplinestart - 1]; // we need p for temp storage, because operator [] will return a reference to CPoint and Add() may reallocate its internal buffer (this is true for MFC 7.0 but not for 6.0, hehe)
+ m_pathPointsOrg.Add(p);
+ p = m_pathPointsOrg[lastsplinestart];
+ m_pathPointsOrg.Add(p);
+ p = m_pathPointsOrg[lastsplinestart + 1];
+ m_pathPointsOrg.Add(p);
+ lastsplinestart = -1;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (lastmoveto == -1 || firstmoveto > 0) {
+ m_pathTypesOrg.RemoveAll();
+ m_pathPointsOrg.RemoveAll();
+ return false;
+ }
+
+ int minx = INT_MAX, miny = INT_MAX, maxx = -INT_MAX, maxy = -INT_MAX;
+
+ for (size_t k = 0; k < m_pathTypesOrg.GetCount(); k++) {
+ m_pathPointsOrg[k].x = (int)(64 * m_scalex * m_pathPointsOrg[k].x);
+ m_pathPointsOrg[k].y = (int)(64 * m_scaley * m_pathPointsOrg[k].y);
+ if (minx > m_pathPointsOrg[k].x) {
+ minx = m_pathPointsOrg[k].x;
+ }
+ if (miny > m_pathPointsOrg[k].y) {
+ miny = m_pathPointsOrg[k].y;
+ }
+ if (maxx < m_pathPointsOrg[k].x) {
+ maxx = m_pathPointsOrg[k].x;
+ }
+ if (maxy < m_pathPointsOrg[k].y) {
+ maxy = m_pathPointsOrg[k].y;
+ }
+ }
+
+ m_width = max(maxx - minx, 0);
+ m_ascent = max(maxy - miny, 0);
+
+ int baseline = (int)(64 * m_scaley * m_baseline);
+ m_descent = baseline;
+ m_ascent -= baseline;
+
+ m_width = ((int)(m_style.fontScaleX / 100 * m_width) + 4) >> 3;
+ m_ascent = ((int)(m_style.fontScaleY / 100 * m_ascent) + 4) >> 3;
+ m_descent = ((int)(m_style.fontScaleY / 100 * m_descent) + 4) >> 3;
+
+ return true;
}
bool CPolygon::CreatePath()
{
- size_t len = m_pathTypesOrg.GetCount();
- if (len == 0) {
- return false;
- }
+ size_t len = m_pathTypesOrg.GetCount();
+ if (len == 0) {
+ return false;
+ }
- if (mPathPoints != len) {
- mpPathTypes = (BYTE*)realloc(mpPathTypes, len*sizeof(BYTE));
- mpPathPoints = (POINT*)realloc(mpPathPoints, len*sizeof(POINT));
- if (!mpPathTypes || !mpPathPoints) {
- return false;
- }
- mPathPoints = (int)len;
- }
+ if (mPathPoints != len) {
+ mpPathTypes = (BYTE*)realloc(mpPathTypes, len * sizeof(BYTE));
+ mpPathPoints = (POINT*)realloc(mpPathPoints, len * sizeof(POINT));
+ if (!mpPathTypes || !mpPathPoints) {
+ return false;
+ }
+ mPathPoints = (int)len;
+ }
- memcpy(mpPathTypes, m_pathTypesOrg.GetData(), len*sizeof(BYTE));
- memcpy(mpPathPoints, m_pathPointsOrg.GetData(), len*sizeof(POINT));
+ memcpy(mpPathTypes, m_pathTypesOrg.GetData(), len * sizeof(BYTE));
+ memcpy(mpPathPoints, m_pathPointsOrg.GetData(), len * sizeof(POINT));
- return true;
+ return true;
}
// CClipper
CClipper::CClipper(CStringW str, CSize size, double scalex, double scaley, bool inverse, CPoint cpOffset)
- : CPolygon(STSStyle(), str, 0, 0, 0, scalex, scaley, 0)
-{
- m_size.cx = m_size.cy = 0;
- m_pAlphaMask = NULL;
-
- if (size.cx < 0 || size.cy < 0) {
- return;
- }
-
- m_pAlphaMask = DNew BYTE[size.cx*size.cy];
- if (!m_pAlphaMask) {
- return;
- }
-
- m_size = size;
- m_inverse = inverse;
- m_cpOffset = cpOffset;
-
- memset(m_pAlphaMask, 0, size.cx*size.cy);
-
- Paint(CPoint(0, 0), CPoint(0, 0));
-
- int w = mOverlayWidth, h = mOverlayHeight;
-
- int x = (mOffsetX+cpOffset.x+4)>>3, y = (mOffsetY+cpOffset.y+4)>>3;
- int xo = 0, yo = 0;
-
- if (x < 0) {
- xo = -x;
- w -= -x;
- x = 0;
- }
- if (y < 0) {
- yo = -y;
- h -= -y;
- y = 0;
- }
- if (x+w > m_size.cx) {
- w = m_size.cx-x;
- }
- if (y+h > m_size.cy) {
- h = m_size.cy-y;
- }
-
- if (w <= 0 || h <= 0) {
- return;
- }
-
- const BYTE* src = mpOverlayBuffer + 2*(mOverlayWidth * yo + xo);
- BYTE* dst = m_pAlphaMask + m_size.cx * y + x;
-
- while (h--) {
- for (ptrdiff_t wt=0; wt<w; ++wt) {
- dst[wt] = src[wt*2];
- }
-
- src += 2*mOverlayWidth;
- dst += m_size.cx;
- }
-
- if (inverse) {
- BYTE* dst = m_pAlphaMask;
- for (ptrdiff_t i = size.cx*size.cy; i>0; --i, ++dst) {
- *dst = 0x40 - *dst; // mask is 6 bit
- }
- }
+ : CPolygon(STSStyle(), str, 0, 0, 0, scalex, scaley, 0)
+{
+ m_size.cx = m_size.cy = 0;
+ m_pAlphaMask = NULL;
+
+ if (size.cx < 0 || size.cy < 0) {
+ return;
+ }
+
+ m_pAlphaMask = DNew BYTE[size.cx * size.cy];
+ if (!m_pAlphaMask) {
+ return;
+ }
+
+ m_size = size;
+ m_inverse = inverse;
+ m_cpOffset = cpOffset;
+
+ memset(m_pAlphaMask, 0, size.cx * size.cy);
+
+ Paint(CPoint(0, 0), CPoint(0, 0));
+
+ int w = mOverlayWidth, h = mOverlayHeight;
+
+ int x = (mOffsetX + cpOffset.x + 4) >> 3, y = (mOffsetY + cpOffset.y + 4) >> 3;
+ int xo = 0, yo = 0;
+
+ if (x < 0) {
+ xo = -x;
+ w -= -x;
+ x = 0;
+ }
+ if (y < 0) {
+ yo = -y;
+ h -= -y;
+ y = 0;
+ }
+ if (x + w > m_size.cx) {
+ w = m_size.cx - x;
+ }
+ if (y + h > m_size.cy) {
+ h = m_size.cy - y;
+ }
+
+ if (w <= 0 || h <= 0) {
+ return;
+ }
+
+ const BYTE* src = mpOverlayBuffer + 2 * (mOverlayWidth * yo + xo);
+ BYTE* dst = m_pAlphaMask + m_size.cx * y + x;
+
+ while (h--) {
+ for (ptrdiff_t wt = 0; wt < w; ++wt) {
+ dst[wt] = src[wt * 2];
+ }
+
+ src += 2 * mOverlayWidth;
+ dst += m_size.cx;
+ }
+
+ if (inverse) {
+ BYTE* dst = m_pAlphaMask;
+ for (ptrdiff_t i = size.cx * size.cy; i > 0; --i, ++dst) {
+ *dst = 0x40 - *dst; // mask is 6 bit
+ }
+ }
}
CClipper::~CClipper()
{
- if (m_pAlphaMask) {
- delete [] m_pAlphaMask;
- }
- m_pAlphaMask = NULL;
+ if (m_pAlphaMask) {
+ delete [] m_pAlphaMask;
+ }
+ m_pAlphaMask = NULL;
}
CWord* CClipper::Copy()
{
- return DNew CClipper(m_str, m_size, m_scalex, m_scaley, m_inverse, m_cpOffset);
+ return DNew CClipper(m_str, m_size, m_scalex, m_scaley, m_inverse, m_cpOffset);
}
bool CClipper::Append(CWord* w)
{
- return false;
+ return false;
}
// CLine
CLine::~CLine()
{
- POSITION pos = GetHeadPosition();
- while (pos) {
- delete GetNext(pos);
- }
+ POSITION pos = GetHeadPosition();
+ while (pos) {
+ delete GetNext(pos);
+ }
}
void CLine::Compact()
{
- POSITION pos = GetHeadPosition();
- while (pos) {
- CWord* w = GetNext(pos);
- if (!w->m_fWhiteSpaceChar) {
- break;
- }
-
- m_width -= w->m_width;
- delete w;
- RemoveHead();
- }
-
- pos = GetTailPosition();
- while (pos) {
- CWord* w = GetPrev(pos);
- if (!w->m_fWhiteSpaceChar) {
- break;
- }
-
- m_width -= w->m_width;
- delete w;
- RemoveTail();
- }
-
- if (IsEmpty()) {
- return;
- }
-
- CLine l;
- l.AddTailList(this);
- RemoveAll();
-
- CWord* last = NULL;
-
- pos = l.GetHeadPosition();
- while (pos) {
- CWord* w = l.GetNext(pos);
-
- if (!last || !last->Append(w)) {
- AddTail(last = w->Copy());
- }
- }
-
- m_ascent = m_descent = m_borderX = m_borderY = 0;
-
- pos = GetHeadPosition();
- while (pos) {
- CWord* w = GetNext(pos);
-
- if (m_ascent < w->m_ascent) {
- m_ascent = w->m_ascent;
- }
- if (m_descent < w->m_descent) {
- m_descent = w->m_descent;
- }
- if (m_borderX < w->m_style.outlineWidthX) {
- m_borderX = (int)(w->m_style.outlineWidthX+0.5);
- }
- if (m_borderY < w->m_style.outlineWidthY) {
- m_borderY = (int)(w->m_style.outlineWidthY+0.5);
- }
- }
+ POSITION pos = GetHeadPosition();
+ while (pos) {
+ CWord* w = GetNext(pos);
+ if (!w->m_fWhiteSpaceChar) {
+ break;
+ }
+
+ m_width -= w->m_width;
+ delete w;
+ RemoveHead();
+ }
+
+ pos = GetTailPosition();
+ while (pos) {
+ CWord* w = GetPrev(pos);
+ if (!w->m_fWhiteSpaceChar) {
+ break;
+ }
+
+ m_width -= w->m_width;
+ delete w;
+ RemoveTail();
+ }
+
+ if (IsEmpty()) {
+ return;
+ }
+
+ CLine l;
+ l.AddTailList(this);
+ RemoveAll();
+
+ CWord* last = NULL;
+
+ pos = l.GetHeadPosition();
+ while (pos) {
+ CWord* w = l.GetNext(pos);
+
+ if (!last || !last->Append(w)) {
+ AddTail(last = w->Copy());
+ }
+ }
+
+ m_ascent = m_descent = m_borderX = m_borderY = 0;
+
+ pos = GetHeadPosition();
+ while (pos) {
+ CWord* w = GetNext(pos);
+
+ if (m_ascent < w->m_ascent) {
+ m_ascent = w->m_ascent;
+ }
+ if (m_descent < w->m_descent) {
+ m_descent = w->m_descent;
+ }
+ if (m_borderX < w->m_style.outlineWidthX) {
+ m_borderX = (int)(w->m_style.outlineWidthX + 0.5);
+ }
+ if (m_borderY < w->m_style.outlineWidthY) {
+ m_borderY = (int)(w->m_style.outlineWidthY + 0.5);
+ }
+ }
}
CRect CLine::PaintShadow(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoint p, CPoint org, int time, int alpha)
{
- CRect bbox(0, 0, 0, 0);
+ CRect bbox(0, 0, 0, 0);
- POSITION pos = GetHeadPosition();
- while (pos) {
- CWord* w = GetNext(pos);
+ POSITION pos = GetHeadPosition();
+ while (pos) {
+ CWord* w = GetNext(pos);
- if (w->m_fLineBreak) {
- return bbox; // should not happen since this class is just a line of text without any breaks
- }
+ if (w->m_fLineBreak) {
+ return bbox; // should not happen since this class is just a line of text without any breaks
+ }
- if (w->m_style.shadowDepthX != 0 || w->m_style.shadowDepthY != 0) {
- int x = p.x + (int)(w->m_style.shadowDepthX+0.5);
- int y = p.y + m_ascent - w->m_ascent + (int)(w->m_style.shadowDepthY+0.5);
+ if (w->m_style.shadowDepthX != 0 || w->m_style.shadowDepthY != 0) {
+ int x = p.x + (int)(w->m_style.shadowDepthX + 0.5);
+ int y = p.y + m_ascent - w->m_ascent + (int)(w->m_style.shadowDepthY + 0.5);
- DWORD a = 0xff - w->m_style.alpha[3];
- if (alpha > 0) {
- a = a*(0xff-static_cast<DWORD>(alpha))/0xff;
- }
- COLORREF shadow = revcolor(w->m_style.colors[3]) | (a<<24);
- DWORD sw[6] = {shadow, 0xffffffff};
+ DWORD a = 0xff - w->m_style.alpha[3];
+ if (alpha > 0) {
+ a = a * (0xff - static_cast<DWORD>(alpha)) / 0xff;
+ }
+ COLORREF shadow = revcolor(w->m_style.colors[3]) | (a << 24);
+ DWORD sw[6] = {shadow, 0xffffffff};
- w->Paint(CPoint(x, y), org);
+ w->Paint(CPoint(x, y), org);
- if (w->m_style.borderStyle == 0) {
- bbox |= w->Draw(spd, clipRect, pAlphaMask, x, y, sw,
- w->m_ktype > 0 || w->m_style.alpha[0] < 0xff,
- (w->m_style.outlineWidthX+w->m_style.outlineWidthY > 0) && !(w->m_ktype == 2 && time < w->m_kstart));
- } else if (w->m_style.borderStyle == 1 && w->m_pOpaqueBox) {
- bbox |= w->m_pOpaqueBox->Draw(spd, clipRect, pAlphaMask, x, y, sw, true, false);
- }
- }
+ if (w->m_style.borderStyle == 0) {
+ bbox |= w->Draw(spd, clipRect, pAlphaMask, x, y, sw,
+ w->m_ktype > 0 || w->m_style.alpha[0] < 0xff,
+ (w->m_style.outlineWidthX + w->m_style.outlineWidthY > 0) && !(w->m_ktype == 2 && time < w->m_kstart));
+ } else if (w->m_style.borderStyle == 1 && w->m_pOpaqueBox) {
+ bbox |= w->m_pOpaqueBox->Draw(spd, clipRect, pAlphaMask, x, y, sw, true, false);
+ }
+ }
- p.x += w->m_width;
- }
+ p.x += w->m_width;
+ }
- return bbox;
+ return bbox;
}
CRect CLine::PaintOutline(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoint p, CPoint org, int time, int alpha)
{
- CRect bbox(0, 0, 0, 0);
+ CRect bbox(0, 0, 0, 0);
- POSITION pos = GetHeadPosition();
- while (pos) {
- CWord* w = GetNext(pos);
+ POSITION pos = GetHeadPosition();
+ while (pos) {
+ CWord* w = GetNext(pos);
- if (w->m_fLineBreak) {
- return bbox; // should not happen since this class is just a line of text without any breaks
- }
+ if (w->m_fLineBreak) {
+ return bbox; // should not happen since this class is just a line of text without any breaks
+ }
- if (w->m_style.outlineWidthX+w->m_style.outlineWidthY > 0 && !(w->m_ktype == 2 && time < w->m_kstart)) {
- int x = p.x;
- int y = p.y + m_ascent - w->m_ascent;
- DWORD aoutline = w->m_style.alpha[2];
- if (alpha > 0) {
- aoutline += alpha*(0xff-w->m_style.alpha[2])/0xff;
- }
- COLORREF outline = revcolor(w->m_style.colors[2]) | ((0xff-aoutline)<<24);
- DWORD sw[6] = {outline, (DWORD)-1};
+ if (w->m_style.outlineWidthX + w->m_style.outlineWidthY > 0 && !(w->m_ktype == 2 && time < w->m_kstart)) {
+ int x = p.x;
+ int y = p.y + m_ascent - w->m_ascent;
+ DWORD aoutline = w->m_style.alpha[2];
+ if (alpha > 0) {
+ aoutline += alpha * (0xff - w->m_style.alpha[2]) / 0xff;
+ }
+ COLORREF outline = revcolor(w->m_style.colors[2]) | ((0xff - aoutline) << 24);
+ DWORD sw[6] = {outline, (DWORD) - 1};
- w->Paint(CPoint(x, y), org);
+ w->Paint(CPoint(x, y), org);
- if (w->m_style.borderStyle == 0) {
- bbox |= w->Draw(spd, clipRect, pAlphaMask, x, y, sw, !w->m_style.alpha[0] && !w->m_style.alpha[1] && !alpha, true);
- } else if (w->m_style.borderStyle == 1 && w->m_pOpaqueBox) {
- bbox |= w->m_pOpaqueBox->Draw(spd, clipRect, pAlphaMask, x, y, sw, true, false);
- }
- }
+ if (w->m_style.borderStyle == 0) {
+ bbox |= w->Draw(spd, clipRect, pAlphaMask, x, y, sw, !w->m_style.alpha[0] && !w->m_style.alpha[1] && !alpha, true);
+ } else if (w->m_style.borderStyle == 1 && w->m_pOpaqueBox) {
+ bbox |= w->m_pOpaqueBox->Draw(spd, clipRect, pAlphaMask, x, y, sw, true, false);
+ }
+ }
- p.x += w->m_width;
- }
+ p.x += w->m_width;
+ }
- return bbox;
+ return bbox;
}
CRect CLine::PaintBody(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoint p, CPoint org, int time, int alpha)
{
- CRect bbox(0, 0, 0, 0);
+ CRect bbox(0, 0, 0, 0);
- POSITION pos = GetHeadPosition();
- while (pos) {
- CWord* w = GetNext(pos);
+ POSITION pos = GetHeadPosition();
+ while (pos) {
+ CWord* w = GetNext(pos);
- if (w->m_fLineBreak) {
- return bbox; // should not happen since this class is just a line of text without any breaks
- }
+ if (w->m_fLineBreak) {
+ return bbox; // should not happen since this class is just a line of text without any breaks
+ }
- int x = p.x;
- int y = p.y + m_ascent - w->m_ascent;
- // colors
+ int x = p.x;
+ int y = p.y + m_ascent - w->m_ascent;
+ // colors
- DWORD aprimary = w->m_style.alpha[0];
- DWORD asecondary = w->m_style.alpha[1];
- if (alpha > 0) {
- aprimary += alpha*(0xff-w->m_style.alpha[0])/0xff;
- asecondary += alpha*(0xff-w->m_style.alpha[1])/0xff;
- }
- COLORREF primary = revcolor(w->m_style.colors[0]) | ((0xff-aprimary)<<24);
- COLORREF secondary = revcolor(w->m_style.colors[1]) | ((0xff-asecondary)<<24);
+ DWORD aprimary = w->m_style.alpha[0];
+ DWORD asecondary = w->m_style.alpha[1];
+ if (alpha > 0) {
+ aprimary += alpha * (0xff - w->m_style.alpha[0]) / 0xff;
+ asecondary += alpha * (0xff - w->m_style.alpha[1]) / 0xff;
+ }
+ COLORREF primary = revcolor(w->m_style.colors[0]) | ((0xff - aprimary) << 24);
+ COLORREF secondary = revcolor(w->m_style.colors[1]) | ((0xff - asecondary) << 24);
- DWORD sw[6] = {primary, 0, secondary};
+ DWORD sw[6] = {primary, 0, secondary};
- // karaoke
+ // karaoke
- double t;
+ double t;
- if (w->m_ktype == 0 || w->m_ktype == 2) {
- t = time < w->m_kstart ? 0 : 1;
- } else if (w->m_ktype == 1) {
- if (time < w->m_kstart) {
- t = 0;
- } else if (time < w->m_kend) {
- t = 1.0 * (time - w->m_kstart) / (w->m_kend - w->m_kstart);
+ if (w->m_ktype == 0 || w->m_ktype == 2) {
+ t = time < w->m_kstart ? 0 : 1;
+ } else if (w->m_ktype == 1) {
+ if (time < w->m_kstart) {
+ t = 0;
+ } else if (time < w->m_kend) {
+ t = 1.0 * (time - w->m_kstart) / (w->m_kend - w->m_kstart);
- double angle = fmod(w->m_style.fontAngleZ, 360.0);
- if (angle > 90 && angle < 270) {
- t = 1-t;
- COLORREF tmp = sw[0];
- sw[0] = sw[2];
- sw[2] = tmp;
- }
- } else {
- t = 1.0;
- }
- }
+ double angle = fmod(w->m_style.fontAngleZ, 360.0);
+ if (angle > 90 && angle < 270) {
+ t = 1 - t;
+ COLORREF tmp = sw[0];
+ sw[0] = sw[2];
+ sw[2] = tmp;
+ }
+ } else {
+ t = 1.0;
+ }
+ }
- if (t >= 1) {
- sw[1] = 0xFFFFFFF;
- }
+ if (t >= 1) {
+ sw[1] = 0xFFFFFFF;
+ }
- // move dividerpoint
- int bluradjust = 0;
- if (w->m_style.fGaussianBlur > 0) {
- bluradjust += (int)(w->m_style.fGaussianBlur*3*8 + 0.5) | 1;
- }
- if (w->m_style.fBlur) {
- bluradjust += 8;
- }
- double tx = w->m_style.fontAngleZ;
- UNREFERENCED_PARAMETER(tx);
- sw[4] = sw[2];
- sw[5] = 0x00ffffff;
+ // move dividerpoint
+ int bluradjust = 0;
+ if (w->m_style.fGaussianBlur > 0) {
+ bluradjust += (int)(w->m_style.fGaussianBlur * 3 * 8 + 0.5) | 1;
+ }
+ if (w->m_style.fBlur) {
+ bluradjust += 8;
+ }
+ double tx = w->m_style.fontAngleZ;
+ UNREFERENCED_PARAMETER(tx);
+ sw[4] = sw[2];
+ sw[5] = 0x00ffffff;
- w->Paint(CPoint(x, y), org);
+ w->Paint(CPoint(x, y), org);
- sw[3] = (int)(w->m_style.outlineWidthX + t*w->getOverlayWidth() + t*bluradjust) >> 3;
+ sw[3] = (int)(w->m_style.outlineWidthX + t * w->getOverlayWidth() + t * bluradjust) >> 3;
- bbox |= w->Draw(spd, clipRect, pAlphaMask, x, y, sw, true, false);
- p.x += w->m_width;
- }
+ bbox |= w->Draw(spd, clipRect, pAlphaMask, x, y, sw, true, false);
+ p.x += w->m_width;
+ }
- return bbox;
+ return bbox;
}
@@ -1028,1839 +1028,1824 @@ CRect CLine::PaintBody(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoin
CSubtitle::CSubtitle()
{
- memset(m_effects, 0, sizeof(Effect*)*EF_NUMBEROFEFFECTS);
- m_pClipper = NULL;
- m_clipInverse = false;
- m_scalex = m_scaley = 1;
+ memset(m_effects, 0, sizeof(Effect*)*EF_NUMBEROFEFFECTS);
+ m_pClipper = NULL;
+ m_clipInverse = false;
+ m_scalex = m_scaley = 1;
}
CSubtitle::~CSubtitle()
{
- Empty();
+ Empty();
}
void CSubtitle::Empty()
{
- POSITION pos = GetHeadPosition();
- while (pos) {
- delete GetNext(pos);
- }
+ POSITION pos = GetHeadPosition();
+ while (pos) {
+ delete GetNext(pos);
+ }
- pos = m_words.GetHeadPosition();
- while (pos) {
- delete m_words.GetNext(pos);
- }
+ pos = m_words.GetHeadPosition();
+ while (pos) {
+ delete m_words.GetNext(pos);
+ }
- EmptyEffects();
+ EmptyEffects();
- if (m_pClipper) {
- delete m_pClipper;
- }
- m_pClipper = NULL;
+ if (m_pClipper) {
+ delete m_pClipper;
+ }
+ m_pClipper = NULL;
}
void CSubtitle::EmptyEffects()
{
- for (ptrdiff_t i = 0; i < EF_NUMBEROFEFFECTS; i++) {
- if (m_effects[i]) {
- delete m_effects[i];
- }
- }
- memset(m_effects, 0, sizeof(Effect*)*EF_NUMBEROFEFFECTS);
+ for (ptrdiff_t i = 0; i < EF_NUMBEROFEFFECTS; i++) {
+ if (m_effects[i]) {
+ delete m_effects[i];
+ }
+ }
+ memset(m_effects, 0, sizeof(Effect*)*EF_NUMBEROFEFFECTS);
}
int CSubtitle::GetFullWidth()
{
- int width = 0;
+ int width = 0;
- POSITION pos = m_words.GetHeadPosition();
- while (pos) {
- width += m_words.GetNext(pos)->m_width;
- }
+ POSITION pos = m_words.GetHeadPosition();
+ while (pos) {
+ width += m_words.GetNext(pos)->m_width;
+ }
- return width;
+ return width;
}
int CSubtitle::GetFullLineWidth(POSITION pos)
{
- int width = 0;
+ int width = 0;
- while (pos) {
- CWord* w = m_words.GetNext(pos);
- if (w->m_fLineBreak) {
- break;
- }
- width += w->m_width;
- }
+ while (pos) {
+ CWord* w = m_words.GetNext(pos);
+ if (w->m_fLineBreak) {
+ break;
+ }
+ width += w->m_width;
+ }
- return width;
+ return width;
}
int CSubtitle::GetWrapWidth(POSITION pos, int maxwidth)
{
- if (m_wrapStyle == 0 || m_wrapStyle == 3) {
- if (maxwidth > 0) {
- // int fullwidth = GetFullWidth();
- int fullwidth = GetFullLineWidth(pos);
+ if (m_wrapStyle == 0 || m_wrapStyle == 3) {
+ if (maxwidth > 0) {
+ // int fullwidth = GetFullWidth();
+ int fullwidth = GetFullLineWidth(pos);
- int minwidth = fullwidth / ((abs(fullwidth) / maxwidth) + 1);
+ int minwidth = fullwidth / ((abs(fullwidth) / maxwidth) + 1);
- int width = 0, wordwidth = 0;
+ int width = 0, wordwidth = 0;
- while (pos && width < minwidth) {
- CWord* w = m_words.GetNext(pos);
- wordwidth = w->m_width;
- if (abs(width + wordwidth) < abs(maxwidth)) {
- width += wordwidth;
- }
- }
+ while (pos && width < minwidth) {
+ CWord* w = m_words.GetNext(pos);
+ wordwidth = w->m_width;
+ if (abs(width + wordwidth) < abs(maxwidth)) {
+ width += wordwidth;
+ }
+ }
- maxwidth = width;
+ maxwidth = width;
- if (m_wrapStyle == 3 && pos) {
- maxwidth -= wordwidth;
- }
- }
- } else if (m_wrapStyle == 1) {
- // maxwidth = maxwidth;
- } else if (m_wrapStyle == 2) {
- maxwidth = INT_MAX;
- }
+ if (m_wrapStyle == 3 && pos) {
+ maxwidth -= wordwidth;
+ }
+ }
+ } else if (m_wrapStyle == 1) {
+ // maxwidth = maxwidth;
+ } else if (m_wrapStyle == 2) {
+ maxwidth = INT_MAX;
+ }
- return maxwidth;
+ return maxwidth;
}
CLine* CSubtitle::GetNextLine(POSITION& pos, int maxwidth)
{
- if (pos == NULL) {
- return NULL;
- }
+ if (pos == NULL) {
+ return NULL;
+ }
- CLine* ret = DNew CLine();
- if (!ret) {
- return NULL;
- }
+ CLine* ret = DNew CLine();
+ if (!ret) {
+ return NULL;
+ }
- ret->m_width = ret->m_ascent = ret->m_descent = ret->m_borderX = ret->m_borderY = 0;
+ ret->m_width = ret->m_ascent = ret->m_descent = ret->m_borderX = ret->m_borderY = 0;
- maxwidth = GetWrapWidth(pos, maxwidth);
+ maxwidth = GetWrapWidth(pos, maxwidth);
- bool fEmptyLine = true;
+ bool fEmptyLine = true;
- while (pos) {
- CWord* w = m_words.GetNext(pos);
+ while (pos) {
+ CWord* w = m_words.GetNext(pos);
- if (ret->m_ascent < w->m_ascent) {
- ret->m_ascent = w->m_ascent;
- }
- if (ret->m_descent < w->m_descent) {
- ret->m_descent = w->m_descent;
- }
- if (ret->m_borderX < w->m_style.outlineWidthX) {
- ret->m_borderX = (int)(w->m_style.outlineWidthX+0.5);
- }
- if (ret->m_borderY < w->m_style.outlineWidthY) {
- ret->m_borderY = (int)(w->m_style.outlineWidthY+0.5);
- }
+ if (ret->m_ascent < w->m_ascent) {
+ ret->m_ascent = w->m_ascent;
+ }
+ if (ret->m_descent < w->m_descent) {
+ ret->m_descent = w->m_descent;
+ }
+ if (ret->m_borderX < w->m_style.outlineWidthX) {
+ ret->m_borderX = (int)(w->m_style.outlineWidthX + 0.5);
+ }
+ if (ret->m_borderY < w->m_style.outlineWidthY) {
+ ret->m_borderY = (int)(w->m_style.outlineWidthY + 0.5);
+ }
- if (w->m_fLineBreak) {
- if (fEmptyLine) {
- ret->m_ascent /= 2;
- ret->m_descent /= 2;
- ret->m_borderX = ret->m_borderY = 0;
- }
+ if (w->m_fLineBreak) {
+ if (fEmptyLine) {
+ ret->m_ascent /= 2;
+ ret->m_descent /= 2;
+ ret->m_borderX = ret->m_borderY = 0;
+ }
- ret->Compact();
+ ret->Compact();
- return ret;
- }
+ return ret;
+ }
- fEmptyLine = false;
+ fEmptyLine = false;
- bool fWSC = w->m_fWhiteSpaceChar;
+ bool fWSC = w->m_fWhiteSpaceChar;
- int width = w->m_width;
- POSITION pos2 = pos;
- while (pos2) {
- if (m_words.GetAt(pos2)->m_fWhiteSpaceChar != fWSC
- || m_words.GetAt(pos2)->m_fLineBreak) {
- break;
- }
+ int width = w->m_width;
+ POSITION pos2 = pos;
+ while (pos2) {
+ if (m_words.GetAt(pos2)->m_fWhiteSpaceChar != fWSC
+ || m_words.GetAt(pos2)->m_fLineBreak) {
+ break;
+ }
- CWord* w2 = m_words.GetNext(pos2);
- width += w2->m_width;
- }
+ CWord* w2 = m_words.GetNext(pos2);
+ width += w2->m_width;
+ }
- if ((ret->m_width += width) <= maxwidth || ret->IsEmpty()) {
- ret->AddTail(w->Copy());
+ if ((ret->m_width += width) <= maxwidth || ret->IsEmpty()) {
+ ret->AddTail(w->Copy());
- while (pos != pos2) {
- ret->AddTail(m_words.GetNext(pos)->Copy());
- }
+ while (pos != pos2) {
+ ret->AddTail(m_words.GetNext(pos)->Copy());
+ }
- pos = pos2;
- } else {
- if (pos) {
- m_words.GetPrev(pos);
- } else {
- pos = m_words.GetTailPosition();
- }
+ pos = pos2;
+ } else {
+ if (pos) {
+ m_words.GetPrev(pos);
+ } else {
+ pos = m_words.GetTailPosition();
+ }
- ret->m_width -= width;
+ ret->m_width -= width;
- break;
- }
- }
+ break;
+ }
+ }
- ret->Compact();
+ ret->Compact();
- return ret;
+ return ret;
}
void CSubtitle::CreateClippers(CSize size)
{
- size.cx >>= 3;
- size.cy >>= 3;
-
- if (m_effects[EF_BANNER] && m_effects[EF_BANNER]->param[2]) {
- int width = m_effects[EF_BANNER]->param[2];
-
- int w = size.cx, h = size.cy;
-
- if (!m_pClipper) {
- CStringW str;
- str.Format(L"m %d %d l %d %d %d %d %d %d", 0, 0, w, 0, w, h, 0, h);
- m_pClipper = DNew CClipper(str, size, 1, 1, false, CPoint(0,0));
- if (!m_pClipper) {
- return;
- }
- }
-
- int da = (64<<8)/width;
- BYTE* am = m_pClipper->m_pAlphaMask;
-
- for (ptrdiff_t j = 0; j < h; j++, am += w) {
- int a = 0;
- int k = min(width, w);
-
- for (ptrdiff_t i = 0; i < k; i++, a += da) {
- am[i] = (am[i]*a)>>14;
- }
-
- a = 0x40<<8;
- k = w-width;
-
- if (k < 0) {
- a -= -k*da;
- k = 0;
- }
-
- for (ptrdiff_t i = k; i < w; i++, a -= da) {
- am[i] = (am[i]*a)>>14;
- }
- }
- } else if (m_effects[EF_SCROLL] && m_effects[EF_SCROLL]->param[4]) {
- int height = m_effects[EF_SCROLL]->param[4];
-
- int w = size.cx, h = size.cy;
-
- if (!m_pClipper) {
- CStringW str;
- str.Format(L"m %d %d l %d %d %d %d %d %d", 0, 0, w, 0, w, h, 0, h);
- m_pClipper = DNew CClipper(str, size, 1, 1, false, CPoint(0,0));
- if (!m_pClipper) {
- return;
- }
- }
-
- int da = (64<<8)/height;
- int a = 0;
- int k = m_effects[EF_SCROLL]->param[0]>>3;
- int l = k+height;
- if (k < 0) {
- a += -k*da;
- k = 0;
- }
- if (l > h) {
- l = h;
- }
-
- if (k < h) {
- BYTE* am = &m_pClipper->m_pAlphaMask[k*w];
-
- memset(m_pClipper->m_pAlphaMask, 0, am - m_pClipper->m_pAlphaMask);
-
- for (ptrdiff_t j = k; j < l; j++, a += da) {
- for (ptrdiff_t i = 0; i < w; i++, am++) {
- *am = ((*am)*a)>>14;
- }
- }
- }
-
- da = -(64<<8)/height;
- a = 0x40<<8;
- l = m_effects[EF_SCROLL]->param[1]>>3;
- k = l-height;
- if (k < 0) {
- a += -k*da;
- k = 0;
- }
- if (l > h) {
- l = h;
- }
-
- if (k < h) {
- BYTE* am = &m_pClipper->m_pAlphaMask[k*w];
-
- int j = k;
- for (; j < l; j++, a += da) {
- for (ptrdiff_t i = 0; i < w; i++, am++) {
- *am = ((*am)*a)>>14;
- }
- }
-
- memset(am, 0, (h-j)*w);
- }
- }
+ size.cx >>= 3;
+ size.cy >>= 3;
+
+ if (m_effects[EF_BANNER] && m_effects[EF_BANNER]->param[2]) {
+ int width = m_effects[EF_BANNER]->param[2];
+
+ int w = size.cx, h = size.cy;
+
+ if (!m_pClipper) {
+ CStringW str;
+ str.Format(L"m %d %d l %d %d %d %d %d %d", 0, 0, w, 0, w, h, 0, h);
+ m_pClipper = DNew CClipper(str, size, 1, 1, false, CPoint(0, 0));
+ if (!m_pClipper) {
+ return;
+ }
+ }
+
+ int da = (64 << 8) / width;
+ BYTE* am = m_pClipper->m_pAlphaMask;
+
+ for (ptrdiff_t j = 0; j < h; j++, am += w) {
+ int a = 0;
+ int k = min(width, w);
+
+ for (ptrdiff_t i = 0; i < k; i++, a += da) {
+ am[i] = (am[i] * a) >> 14;
+ }
+
+ a = 0x40 << 8;
+ k = w - width;
+
+ if (k < 0) {
+ a -= -k * da;
+ k = 0;
+ }
+
+ for (ptrdiff_t i = k; i < w; i++, a -= da) {
+ am[i] = (am[i] * a) >> 14;
+ }
+ }
+ } else if (m_effects[EF_SCROLL] && m_effects[EF_SCROLL]->param[4]) {
+ int height = m_effects[EF_SCROLL]->param[4];
+
+ int w = size.cx, h = size.cy;
+
+ if (!m_pClipper) {
+ CStringW str;
+ str.Format(L"m %d %d l %d %d %d %d %d %d", 0, 0, w, 0, w, h, 0, h);
+ m_pClipper = DNew CClipper(str, size, 1, 1, false, CPoint(0, 0));
+ if (!m_pClipper) {
+ return;
+ }
+ }
+
+ int da = (64 << 8) / height;
+ int a = 0;
+ int k = m_effects[EF_SCROLL]->param[0] >> 3;
+ int l = k + height;
+ if (k < 0) {
+ a += -k * da;
+ k = 0;
+ }
+ if (l > h) {
+ l = h;
+ }
+
+ if (k < h) {
+ BYTE* am = &m_pClipper->m_pAlphaMask[k * w];
+
+ memset(m_pClipper->m_pAlphaMask, 0, am - m_pClipper->m_pAlphaMask);
+
+ for (ptrdiff_t j = k; j < l; j++, a += da) {
+ for (ptrdiff_t i = 0; i < w; i++, am++) {
+ *am = ((*am) * a) >> 14;
+ }
+ }
+ }
+
+ da = -(64 << 8) / height;
+ a = 0x40 << 8;
+ l = m_effects[EF_SCROLL]->param[1] >> 3;
+ k = l - height;
+ if (k < 0) {
+ a += -k * da;
+ k = 0;
+ }
+ if (l > h) {
+ l = h;
+ }
+
+ if (k < h) {
+ BYTE* am = &m_pClipper->m_pAlphaMask[k * w];
+
+ int j = k;
+ for (; j < l; j++, a += da) {
+ for (ptrdiff_t i = 0; i < w; i++, am++) {
+ *am = ((*am) * a) >> 14;
+ }
+ }
+
+ memset(am, 0, (h - j)*w);
+ }
+ }
}
void CSubtitle::MakeLines(CSize size, CRect marginRect)
{
- CSize spaceNeeded(0, 0);
+ CSize spaceNeeded(0, 0);
- bool fFirstLine = true;
+ bool fFirstLine = true;
- m_topborder = m_bottomborder = 0;
+ m_topborder = m_bottomborder = 0;
- CLine* l = NULL;
+ CLine* l = NULL;
- POSITION pos = m_words.GetHeadPosition();
- while (pos) {
- l = GetNextLine(pos, size.cx - marginRect.left - marginRect.right);
- if (!l) {
- break;
- }
+ POSITION pos = m_words.GetHeadPosition();
+ while (pos) {
+ l = GetNextLine(pos, size.cx - marginRect.left - marginRect.right);
+ if (!l) {
+ break;
+ }
- if (fFirstLine) {
- m_topborder = l->m_borderY;
- fFirstLine = false;
- }
+ if (fFirstLine) {
+ m_topborder = l->m_borderY;
+ fFirstLine = false;
+ }
- spaceNeeded.cx = max(l->m_width+l->m_borderX, spaceNeeded.cx);
- spaceNeeded.cy += l->m_ascent + l->m_descent;
+ spaceNeeded.cx = max(l->m_width + l->m_borderX, spaceNeeded.cx);
+ spaceNeeded.cy += l->m_ascent + l->m_descent;
- AddTail(l);
- }
+ AddTail(l);
+ }
- if (l) {
- m_bottomborder = l->m_borderY;
- }
+ if (l) {
+ m_bottomborder = l->m_borderY;
+ }
- m_rect = CRect(
- CPoint((m_scrAlignment%3) == 1 ? marginRect.left
- : (m_scrAlignment%3) == 2 ? (marginRect.left + (size.cx - marginRect.right) - spaceNeeded.cx + 1) / 2
- : (size.cx - marginRect.right - spaceNeeded.cx),
- m_scrAlignment <= 3 ? (size.cy - marginRect.bottom - spaceNeeded.cy)
- : m_scrAlignment <= 6 ? (marginRect.top + (size.cy - marginRect.bottom) - spaceNeeded.cy + 1) / 2
- : marginRect.top),
- spaceNeeded);
+ m_rect = CRect(
+ CPoint((m_scrAlignment % 3) == 1 ? marginRect.left
+ : (m_scrAlignment % 3) == 2 ? (marginRect.left + (size.cx - marginRect.right) - spaceNeeded.cx + 1) / 2
+ : (size.cx - marginRect.right - spaceNeeded.cx),
+ m_scrAlignment <= 3 ? (size.cy - marginRect.bottom - spaceNeeded.cy)
+ : m_scrAlignment <= 6 ? (marginRect.top + (size.cy - marginRect.bottom) - spaceNeeded.cy + 1) / 2
+ : marginRect.top),
+ spaceNeeded);
}
// CScreenLayoutAllocator
void CScreenLayoutAllocator::Empty()
{
- m_subrects.RemoveAll();
+ m_subrects.RemoveAll();
}
void CScreenLayoutAllocator::AdvanceToSegment(int segment, const CAtlArray<int>& sa)
{
- POSITION pos = m_subrects.GetHeadPosition();
- while (pos) {
- POSITION prev = pos;
+ POSITION pos = m_subrects.GetHeadPosition();
+ while (pos) {
+ POSITION prev = pos;
- SubRect& sr = m_subrects.GetNext(pos);
+ SubRect& sr = m_subrects.GetNext(pos);
- bool fFound = false;
+ bool fFound = false;
- if (abs(sr.segment - segment) <= 1) { // using abs() makes it possible to play the subs backwards, too :)
- for (size_t i = 0; i < sa.GetCount() && !fFound; i++) {
- if (sa[i] == sr.entry) {
- sr.segment = segment;
- fFound = true;
- }
- }
- }
+ if (abs(sr.segment - segment) <= 1) { // using abs() makes it possible to play the subs backwards, too :)
+ for (size_t i = 0; i < sa.GetCount() && !fFound; i++) {
+ if (sa[i] == sr.entry) {
+ sr.segment = segment;
+ fFound = true;
+ }
+ }
+ }
- if (!fFound) {
- m_subrects.RemoveAt(prev);
- }
- }
+ if (!fFound) {
+ m_subrects.RemoveAt(prev);
+ }
+ }
}
CRect CScreenLayoutAllocator::AllocRect(CSubtitle* s, int segment, int entry, int layer, int collisions)
{
- // TODO: handle collisions == 1 (reversed collisions)
+ // TODO: handle collisions == 1 (reversed collisions)
- POSITION pos = m_subrects.GetHeadPosition();
- while (pos) {
- SubRect& sr = m_subrects.GetNext(pos);
- if (sr.segment == segment && sr.entry == entry) {
- return (sr.r + CRect(0, -s->m_topborder, 0, -s->m_bottomborder));
- }
- }
+ POSITION pos = m_subrects.GetHeadPosition();
+ while (pos) {
+ SubRect& sr = m_subrects.GetNext(pos);
+ if (sr.segment == segment && sr.entry == entry) {
+ return (sr.r + CRect(0, -s->m_topborder, 0, -s->m_bottomborder));
+ }
+ }
- CRect r = s->m_rect + CRect(0, s->m_topborder, 0, s->m_bottomborder);
+ CRect r = s->m_rect + CRect(0, s->m_topborder, 0, s->m_bottomborder);
- bool fSearchDown = s->m_scrAlignment > 3;
+ bool fSearchDown = s->m_scrAlignment > 3;
- bool fOK;
+ bool fOK;
- do {
- fOK = true;
+ do {
+ fOK = true;
- pos = m_subrects.GetHeadPosition();
- while (pos) {
- SubRect& sr = m_subrects.GetNext(pos);
+ pos = m_subrects.GetHeadPosition();
+ while (pos) {
+ SubRect& sr = m_subrects.GetNext(pos);
- if (layer == sr.layer && !(r & sr.r).IsRectEmpty()) {
- if (fSearchDown) {
- r.bottom = sr.r.bottom + r.Height();
- r.top = sr.r.bottom;
- } else {
- r.top = sr.r.top - r.Height();
- r.bottom = sr.r.top;
- }
+ if (layer == sr.layer && !(r & sr.r).IsRectEmpty()) {
+ if (fSearchDown) {
+ r.bottom = sr.r.bottom + r.Height();
+ r.top = sr.r.bottom;
+ } else {
+ r.top = sr.r.top - r.Height();
+ r.bottom = sr.r.top;
+ }
- fOK = false;
- }
- }
- } while (!fOK);
+ fOK = false;
+ }
+ }
+ } while (!fOK);
- SubRect sr;
- sr.r = r;
- sr.segment = segment;
- sr.entry = entry;
- sr.layer = layer;
- m_subrects.AddTail(sr);
+ SubRect sr;
+ sr.r = r;
+ sr.segment = segment;
+ sr.entry = entry;
+ sr.layer = layer;
+ m_subrects.AddTail(sr);
- return (sr.r + CRect(0, -s->m_topborder, 0, -s->m_bottomborder));
+ return (sr.r + CRect(0, -s->m_topborder, 0, -s->m_bottomborder));
}
// CRenderedTextSubtitle
-CRenderedTextSubtitle::CRenderedTextSubtitle(CCritSec* pLock, STSStyle *styleOverride, bool doOverride)
- : CSubPicProviderImpl(pLock), m_doOverrideStyle(doOverride), m_pStyleOverride(styleOverride)
+CRenderedTextSubtitle::CRenderedTextSubtitle(CCritSec* pLock, STSStyle* styleOverride, bool doOverride)
+ : CSubPicProviderImpl(pLock), m_doOverrideStyle(doOverride), m_pStyleOverride(styleOverride)
{
- m_size = CSize(0, 0);
+ m_size = CSize(0, 0);
- if (g_hDC_refcnt == 0) {
- g_hDC = CreateCompatibleDC(NULL);
- SetBkMode(g_hDC, TRANSPARENT);
- SetTextColor(g_hDC, 0xffffff);
- SetMapMode(g_hDC, MM_TEXT);
- }
+ if (g_hDC_refcnt == 0) {
+ g_hDC = CreateCompatibleDC(NULL);
+ SetBkMode(g_hDC, TRANSPARENT);
+ SetTextColor(g_hDC, 0xffffff);
+ SetMapMode(g_hDC, MM_TEXT);
+ }
- g_hDC_refcnt++;
+ g_hDC_refcnt++;
}
CRenderedTextSubtitle::~CRenderedTextSubtitle()
{
- Deinit();
+ Deinit();
- g_hDC_refcnt--;
- if (g_hDC_refcnt == 0) {
- DeleteDC(g_hDC);
- }
+ g_hDC_refcnt--;
+ if (g_hDC_refcnt == 0) {
+ DeleteDC(g_hDC);
+ }
}
void CRenderedTextSubtitle::Copy(CSimpleTextSubtitle& sts)
{
- __super::Copy(sts);
+ __super::Copy(sts);
- m_size = CSize(0, 0);
+ m_size = CSize(0, 0);
- if (CRenderedTextSubtitle* pRTS = dynamic_cast<CRenderedTextSubtitle*>(&sts)) {
- m_size = pRTS->m_size;
- }
+ if (CRenderedTextSubtitle* pRTS = dynamic_cast<CRenderedTextSubtitle*>(&sts)) {
+ m_size = pRTS->m_size;
+ }
}
void CRenderedTextSubtitle::Empty()
{
- Deinit();
+ Deinit();
- __super::Empty();
+ __super::Empty();
}
void CRenderedTextSubtitle::OnChanged()
{
- __super::OnChanged();
+ __super::OnChanged();
- POSITION pos = m_subtitleCache.GetStartPosition();
- while (pos) {
- int i;
- CSubtitle* s;
- m_subtitleCache.GetNextAssoc(pos, i, s);
- delete s;
- }
+ POSITION pos = m_subtitleCache.GetStartPosition();
+ while (pos) {
+ int i;
+ CSubtitle* s;
+ m_subtitleCache.GetNextAssoc(pos, i, s);
+ delete s;
+ }
- m_subtitleCache.RemoveAll();
+ m_subtitleCache.RemoveAll();
- m_sla.Empty();
+ m_sla.Empty();
}
bool CRenderedTextSubtitle::Init(CSize size, CRect vidrect)
{
- Deinit();
+ Deinit();
- m_size = CSize(size.cx*8, size.cy*8);
- m_vidrect = CRect(vidrect.left*8, vidrect.top*8, vidrect.right*8, vidrect.bottom*8);
+ m_size = CSize(size.cx * 8, size.cy * 8);
+ m_vidrect = CRect(vidrect.left * 8, vidrect.top * 8, vidrect.right * 8, vidrect.bottom * 8);
- m_sla.Empty();
+ m_sla.Empty();
- return true;
+ return true;
}
void CRenderedTextSubtitle::Deinit()
{
- POSITION pos = m_subtitleCache.GetStartPosition();
- while (pos) {
- int i;
- CSubtitle* s;
- m_subtitleCache.GetNextAssoc(pos, i, s);
- delete s;
- }
+ POSITION pos = m_subtitleCache.GetStartPosition();
+ while (pos) {
+ int i;
+ CSubtitle* s;
+ m_subtitleCache.GetNextAssoc(pos, i, s);
+ delete s;
+ }
- m_subtitleCache.RemoveAll();
+ m_subtitleCache.RemoveAll();
- m_sla.Empty();
+ m_sla.Empty();
- m_size = CSize(0, 0);
- m_vidrect.SetRectEmpty();
+ m_size = CSize(0, 0);
+ m_vidrect.SetRectEmpty();
}
void CRenderedTextSubtitle::ParseEffect(CSubtitle* sub, CString str)
{
- str.Trim();
- if (!sub || str.IsEmpty()) {
- return;
- }
-
- const TCHAR* s = _tcschr(str, ';');
- if (!s) {
- s = (LPTSTR)(LPCTSTR)str;
- s += str.GetLength() - 1;
- }
- s++;
- CString effect = str.Left(int(s - str));
-
- if (!effect.CompareNoCase(_T("Banner;"))) {
- int delay, lefttoright = 0, fadeawaywidth = 0;
- if (_stscanf_s(s, _T("%d;%d;%d"), &delay, &lefttoright, &fadeawaywidth) < 1) {
- return;
- }
-
- Effect* e = DNew Effect;
- if (!e) {
- return;
- }
-
- sub->m_effects[e->type = EF_BANNER] = e;
- e->param[0] = (int)(max(1.0*delay/sub->m_scalex, 1));
- e->param[1] = lefttoright;
- e->param[2] = (int)(sub->m_scalex*fadeawaywidth);
-
- sub->m_wrapStyle = 2;
- } else if (!effect.CompareNoCase(_T("Scroll up;")) || !effect.CompareNoCase(_T("Scroll down;"))) {
- int top, bottom, delay, fadeawayheight = 0;
- if (_stscanf_s(s, _T("%d;%d;%d;%d"), &top, &bottom, &delay, &fadeawayheight) < 3) {
- return;
- }
-
- if (top > bottom) {
- int tmp = top;
- top = bottom;
- bottom = tmp;
- }
-
- Effect* e = DNew Effect;
- if (!e) {
- return;
- }
-
- sub->m_effects[e->type = EF_SCROLL] = e;
- e->param[0] = (int)(sub->m_scaley*top*8);
- e->param[1] = (int)(sub->m_scaley*bottom*8);
- e->param[2] = (int)(max(1.0*delay/sub->m_scaley, 1));
- e->param[3] = (effect.GetLength() == 12);
- e->param[4] = (int)(sub->m_scaley*fadeawayheight);
- }
+ str.Trim();
+ if (!sub || str.IsEmpty()) {
+ return;
+ }
+
+ const TCHAR* s = _tcschr(str, ';');
+ if (!s) {
+ s = (LPTSTR)(LPCTSTR)str;
+ s += str.GetLength() - 1;
+ }
+ s++;
+ CString effect = str.Left(int(s - str));
+
+ if (!effect.CompareNoCase(_T("Banner;"))) {
+ int delay, lefttoright = 0, fadeawaywidth = 0;
+ if (_stscanf_s(s, _T("%d;%d;%d"), &delay, &lefttoright, &fadeawaywidth) < 1) {
+ return;
+ }
+
+ Effect* e = DNew Effect;
+ if (!e) {
+ return;
+ }
+
+ sub->m_effects[e->type = EF_BANNER] = e;
+ e->param[0] = (int)(max(1.0 * delay / sub->m_scalex, 1));
+ e->param[1] = lefttoright;
+ e->param[2] = (int)(sub->m_scalex * fadeawaywidth);
+
+ sub->m_wrapStyle = 2;
+ } else if (!effect.CompareNoCase(_T("Scroll up;")) || !effect.CompareNoCase(_T("Scroll down;"))) {
+ int top, bottom, delay, fadeawayheight = 0;
+ if (_stscanf_s(s, _T("%d;%d;%d;%d"), &top, &bottom, &delay, &fadeawayheight) < 3) {
+ return;
+ }
+
+ if (top > bottom) {
+ int tmp = top;
+ top = bottom;
+ bottom = tmp;
+ }
+
+ Effect* e = DNew Effect;
+ if (!e) {
+ return;
+ }
+
+ sub->m_effects[e->type = EF_SCROLL] = e;
+ e->param[0] = (int)(sub->m_scaley * top * 8);
+ e->param[1] = (int)(sub->m_scaley * bottom * 8);
+ e->param[2] = (int)(max(1.0 * delay / sub->m_scaley, 1));
+ e->param[3] = (effect.GetLength() == 12);
+ e->param[4] = (int)(sub->m_scaley * fadeawayheight);
+ }
}
void CRenderedTextSubtitle::ParseString(CSubtitle* sub, CStringW str, STSStyle& style)
{
- if (!sub) {
- return;
- }
+ if (!sub) {
+ return;
+ }
- str.Replace(L"\\N", L"\n");
- str.Replace(L"\\n", (sub->m_wrapStyle < 2 || sub->m_wrapStyle == 3) ? L" " : L"\n");
- str.Replace(L"\\h", L"\x00A0");
+ str.Replace(L"\\N", L"\n");
+ str.Replace(L"\\n", (sub->m_wrapStyle < 2 || sub->m_wrapStyle == 3) ? L" " : L"\n");
+ str.Replace(L"\\h", L"\x00A0");
- for (int i = 0, j = 0, len = str.GetLength(); j <= len; j++) {
- WCHAR c = str[j];
+ for (int i = 0, j = 0, len = str.GetLength(); j <= len; j++) {
+ WCHAR c = str[j];
- if (c != L'\n' && c != L' ' && c != L'\x00A0' && c != 0) {
- continue;
- }
+ if (c != L'\n' && c != L' ' && c != L'\x00A0' && c != 0) {
+ continue;
+ }
- if (i < j) {
- if (CWord* w = DNew CText(style, str.Mid(i, j-i), m_ktype, m_kstart, m_kend)) {
- sub->m_words.AddTail(w);
- m_kstart = m_kend;
- }
- }
+ if (i < j) {
+ if (CWord* w = DNew CText(style, str.Mid(i, j - i), m_ktype, m_kstart, m_kend)) {
+ sub->m_words.AddTail(w);
+ m_kstart = m_kend;
+ }
+ }
- if (c == L'\n') {
- if (CWord* w = DNew CText(style, CStringW(), m_ktype, m_kstart, m_kend)) {
- sub->m_words.AddTail(w);
- m_kstart = m_kend;
- }
- } else if (c == L' ' || c == L'\x00A0') {
- if (CWord* w = DNew CText(style, CStringW(c), m_ktype, m_kstart, m_kend)) {
- sub->m_words.AddTail(w);
- m_kstart = m_kend;
- }
- }
+ if (c == L'\n') {
+ if (CWord* w = DNew CText(style, CStringW(), m_ktype, m_kstart, m_kend)) {
+ sub->m_words.AddTail(w);
+ m_kstart = m_kend;
+ }
+ } else if (c == L' ' || c == L'\x00A0') {
+ if (CWord* w = DNew CText(style, CStringW(c), m_ktype, m_kstart, m_kend)) {
+ sub->m_words.AddTail(w);
+ m_kstart = m_kend;
+ }
+ }
- i = j+1;
- }
+ i = j + 1;
+ }
- return;
+ return;
}
void CRenderedTextSubtitle::ParsePolygon(CSubtitle* sub, CStringW str, STSStyle& style)
{
- if (!sub || !str.GetLength() || !m_nPolygon) {
- return;
- }
+ if (!sub || !str.GetLength() || !m_nPolygon) {
+ return;
+ }
- if (CWord* w = DNew CPolygon(style, str, m_ktype, m_kstart, m_kend, sub->m_scalex/(1<<(m_nPolygon-1)), sub->m_scaley/(1<<(m_nPolygon-1)), m_polygonBaselineOffset)) {
- sub->m_words.AddTail(w);
- m_kstart = m_kend;
- }
+ if (CWord* w = DNew CPolygon(style, str, m_ktype, m_kstart, m_kend, sub->m_scalex / (1 << (m_nPolygon - 1)), sub->m_scaley / (1 << (m_nPolygon - 1)), m_polygonBaselineOffset)) {
+ sub->m_words.AddTail(w);
+ m_kstart = m_kend;
+ }
}
bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& style, STSStyle& org, bool fAnimate)
{
- if (!sub) {
- return false;
- }
-
- int nTags = 0, nUnrecognizedTags = 0;
-
- for (int i = 0, j; (j = str.Find('\\', i)) >= 0; i = j) {
- CStringW cmd;
- for (WCHAR c = str[++j]; c && c != '(' && c != '\\'; cmd += c, c = str[++j]) {
- ;
- }
- cmd.Trim();
- if (cmd.IsEmpty()) {
- continue;
- }
-
- CAtlArray<CStringW> params;
-
- if (str[j] == '(') {
- CStringW param;
- // complex tags search
- int br = 1; // 1 bracket
- for (WCHAR c = str[++j]; c && br>0; param += c, c = str[++j]) {
- if (c=='(') {
- br++;
- }
- if (c==')') {
- br--;
- }
- if (br==0) {
- break;
- }
- }
- param.Trim();
-
- while (!param.IsEmpty()) {
- int i = param.Find(','), j = param.Find('\\');
-
- if (i >= 0 && (j < 0 || i < j)) {
- CStringW s = param.Left(i).Trim();
- if (!s.IsEmpty()) {
- params.Add(s);
- }
- param = i+1 < param.GetLength() ? param.Mid(i+1) : L"";
- } else {
- param.Trim();
- if (!param.IsEmpty()) {
- params.Add(param);
- }
- param.Empty();
- }
- }
- }
-
- if (!cmd.Find(L"1c") || !cmd.Find(L"2c") || !cmd.Find(L"3c") || !cmd.Find(L"4c")) {
- params.Add(cmd.Mid(2).Trim(L"&H")), cmd = cmd.Left(2);
- } else if (!cmd.Find(L"1a") || !cmd.Find(L"2a") || !cmd.Find(L"3a") || !cmd.Find(L"4a")) {
- params.Add(cmd.Mid(2).Trim(L"&H")), cmd = cmd.Left(2);
- }
- else if (!cmd.Find(L"alpha")) {
- params.Add(cmd.Mid(5).Trim(L"&H")), cmd = cmd.Left(5);
- } else if (!cmd.Find(L"an")) {
- params.Add(cmd.Mid(2)), cmd = cmd.Left(2);
- } else if (!cmd.Find(L"a")) {
- params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
- } else if (!cmd.Find(L"blur")) {
- params.Add(cmd.Mid(4)), cmd = cmd.Left(4);
- } else if (!cmd.Find(L"bord")) {
- params.Add(cmd.Mid(4)), cmd = cmd.Left(4);
- } else if (!cmd.Find(L"be")) {
- params.Add(cmd.Mid(2)), cmd = cmd.Left(2);
- } else if (!cmd.Find(L"b")) {
- params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
- } else if (!cmd.Find(L"clip")) {
- ;
- } else if (!cmd.Find(L"c")) {
- params.Add(cmd.Mid(1).Trim(L"&H")), cmd = cmd.Left(1);
- }
- else if (!cmd.Find(L"fade")) {
- ;
- } else if (!cmd.Find(L"fe")) {
- params.Add(cmd.Mid(2)), cmd = cmd.Left(2);
- } else if (!cmd.Find(L"fn")) {
- params.Add(cmd.Mid(2)), cmd = cmd.Left(2);
- } else if (!cmd.Find(L"frx") || !cmd.Find(L"fry") || !cmd.Find(L"frz")) {
- params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
- }
- else if (!cmd.Find(L"fax") || !cmd.Find(L"fay")) {
- params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
- } else if (!cmd.Find(L"fr")) {
- params.Add(cmd.Mid(2)), cmd = cmd.Left(2);
- } else if (!cmd.Find(L"fscx") || !cmd.Find(L"fscy")) {
- params.Add(cmd.Mid(4)), cmd = cmd.Left(4);
- } else if (!cmd.Find(L"fsc")) {
- params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
- } else if (!cmd.Find(L"fsp")) {
- params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
- }
- else if (!cmd.Find(L"fs")) {
- params.Add(cmd.Mid(2)), cmd = cmd.Left(2);
- } else if (!cmd.Find(L"iclip")) {
- ;
- } else if (!cmd.Find(L"i")) {
- params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
- }
- else if (!cmd.Find(L"kt") || !cmd.Find(L"kf") || !cmd.Find(L"ko")) {
- params.Add(cmd.Mid(2)), cmd = cmd.Left(2);
- } else if (!cmd.Find(L"k") || !cmd.Find(L"K")) {
- params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
- }
- else if (!cmd.Find(L"move")) {
- ;
- } else if (!cmd.Find(L"org")) {
- ;
- } else if (!cmd.Find(L"pbo")) {
- params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
- } else if (!cmd.Find(L"pos")) {
- ;
- } else if (!cmd.Find(L"p")) {
- params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
- } else if (!cmd.Find(L"q")) {
- params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
- }
- else if (!cmd.Find(L"r")) {
- params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
- } else if (!cmd.Find(L"shad")) {
- params.Add(cmd.Mid(4)), cmd = cmd.Left(4);
- } else if (!cmd.Find(L"s")) {
- params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
- } else if (!cmd.Find(L"t")) {
- ;
- } else if (!cmd.Find(L"u")) {
- params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
- } else if (!cmd.Find(L"xbord")) {
- params.Add(cmd.Mid(5)), cmd = cmd.Left(5);
- } else if (!cmd.Find(L"xshad")) {
- params.Add(cmd.Mid(5)), cmd = cmd.Left(5);
- } else if (!cmd.Find(L"ybord")) {
- params.Add(cmd.Mid(5)), cmd = cmd.Left(5);
- } else if (!cmd.Find(L"yshad")) {
- params.Add(cmd.Mid(5)), cmd = cmd.Left(5);
- }
- else {
- nUnrecognizedTags++;
- }
-
- nTags++;
-
- // TODO: call ParseStyleModifier(cmd, params, ..) and move the rest there
-
- CStringW p = params.GetCount() > 0 ? params[0] : L"";
-
- if (cmd == "1c" || cmd == L"2c" || cmd == L"3c" || cmd == L"4c") {
- int i = cmd[0] - '1';
-
- DWORD c = wcstol(p, NULL, 16);
- style.colors[i] = !p.IsEmpty()
- ? (((int)CalcAnimation(c&0xff, style.colors[i]&0xff, fAnimate))&0xff
- |((int)CalcAnimation(c&0xff00, style.colors[i]&0xff00, fAnimate))&0xff00
- |((int)CalcAnimation(c&0xff0000, style.colors[i]&0xff0000, fAnimate))&0xff0000)
- : org.colors[i];
- } else if (cmd == L"1a" || cmd == L"2a" || cmd == L"3a" || cmd == L"4a") {
- DWORD al = wcstol(p, NULL, 16)&0xff;
- int i = cmd[0] - '1';
-
- style.alpha[i] = !p.IsEmpty()
- ? (BYTE)CalcAnimation(al, style.alpha[i], fAnimate)
- : org.alpha[i];
- }
- else if (cmd == L"alpha") {
- for (ptrdiff_t i = 0; i < 4; i++) {
- DWORD al = wcstol(p, NULL, 16)&0xff;
- style.alpha[i] = !p.IsEmpty()
- ? (BYTE)CalcAnimation(al, style.alpha[i], fAnimate)
- : org.alpha[i];
- }
- } else if (cmd == L"an") {
- int n = wcstol(p, NULL, 10);
- if (sub->m_scrAlignment < 0) {
- sub->m_scrAlignment = (n > 0 && n < 10) ? n : org.scrAlignment;
- }
- } else if (cmd == L"a") {
- int n = wcstol(p, NULL, 10);
- if (sub->m_scrAlignment < 0) {
- sub->m_scrAlignment = (n > 0 && n < 12) ? ((((n-1)&3)+1)+((n&4)?6:0)+((n&8)?3:0)) : org.scrAlignment;
- }
- } else if (cmd == L"blur") {
- double n = CalcAnimation(wcstod(p, NULL), style.fGaussianBlur, fAnimate);
- style.fGaussianBlur = !p.IsEmpty()
- ? (n < 0 ? 0 : n)
- : org.fGaussianBlur;
- } else if (cmd == L"bord") {
- double dst = wcstod(p, NULL);
- double nx = CalcAnimation(dst, style.outlineWidthX, fAnimate);
- style.outlineWidthX = !p.IsEmpty()
- ? (nx < 0 ? 0 : nx)
- : org.outlineWidthX;
- double ny = CalcAnimation(dst, style.outlineWidthY, fAnimate);
- style.outlineWidthY = !p.IsEmpty()
- ? (ny < 0 ? 0 : ny)
- : org.outlineWidthY;
- } else if (cmd == L"be") {
- int n = (int)(CalcAnimation(wcstol(p, NULL, 10), style.fBlur, fAnimate)+0.5);
- style.fBlur = !p.IsEmpty()
- ? n
- : org.fBlur;
- } else if (cmd == L"b") {
- int n = wcstol(p, NULL, 10);
- style.fontWeight = !p.IsEmpty()
- ? (n == 0 ? FW_NORMAL : n == 1 ? FW_BOLD : n >= 100 ? n : org.fontWeight)
- : org.fontWeight;
- } else if (cmd == L"clip" || cmd == L"iclip") {
- bool invert = (cmd == L"iclip");
-
- if (params.GetCount() == 1 && !sub->m_pClipper) {
- sub->m_pClipper = DNew CClipper(params[0], CSize(m_size.cx>>3, m_size.cy>>3), sub->m_scalex, sub->m_scaley, invert, (sub->m_relativeTo == 1)? CPoint(m_vidrect.left, m_vidrect.top) : CPoint(0, 0));
- } else if (params.GetCount() == 2 && !sub->m_pClipper) {
- long scale = wcstol(p, NULL, 10);
- if (scale < 1) scale = 1;
- sub->m_pClipper = DNew CClipper(params[1], CSize(m_size.cx>>3, m_size.cy>>3), sub->m_scalex/(1<<(scale-1)), sub->m_scaley/(1<<(scale-1)), invert, (sub->m_relativeTo == 1)? CPoint(m_vidrect.left, m_vidrect.top) : CPoint(0, 0));
- } else if (params.GetCount() == 4) {
- CRect r;
-
- sub->m_clipInverse = invert;
-
- r.SetRect(
- wcstol(params[0], NULL, 10),
- wcstol(params[1], NULL, 10),
- wcstol(params[2], NULL, 10),
- wcstol(params[3], NULL, 10));
-
- double dLeft = sub->m_scalex*static_cast<double>(r.left), dTop = sub->m_scaley*static_cast<double>(r.top), dRight = sub->m_scalex*static_cast<double>(r.right), dBottom = sub->m_scaley*static_cast<double>(r.bottom);
- if (sub->m_relativeTo == 1) {
- double dOffsetX = static_cast<double>(m_vidrect.left)*0.125;
- double dOffsetY = static_cast<double>(m_vidrect.top)*0.125;
- dLeft += dOffsetX;
- dTop += dOffsetY;
- dRight += dOffsetX;
- dBottom += dOffsetY;
- }
-
- sub->m_clip.SetRect(
- static_cast<int>(CalcAnimation(dLeft, sub->m_clip.left, fAnimate)),
- static_cast<int>(CalcAnimation(dTop, sub->m_clip.top, fAnimate)),
- static_cast<int>(CalcAnimation(dRight, sub->m_clip.right, fAnimate)),
- static_cast<int>(CalcAnimation(dBottom, sub->m_clip.bottom, fAnimate)));
- }
- } else if (cmd == L"c") {
- DWORD c = wcstol(p, NULL, 16);
- style.colors[0] = !p.IsEmpty()
- ? (((int)CalcAnimation(c&0xff, style.colors[0]&0xff, fAnimate))&0xff
- |((int)CalcAnimation(c&0xff00, style.colors[0]&0xff00, fAnimate))&0xff00
- |((int)CalcAnimation(c&0xff0000, style.colors[0]&0xff0000, fAnimate))&0xff0000)
- : org.colors[0];
- }
- else if (cmd == L"fade" || cmd == L"fad") {
- if (params.GetCount() == 7 && !sub->m_effects[EF_FADE]) { // {\fade(a1=param[0], a2=param[1], a3=param[2], t1=t[0], t2=t[1], t3=t[2], t4=t[3])
- if (Effect* e = DNew Effect) {
- for (ptrdiff_t i = 0; i < 3; i++) {
- e->param[i] = wcstol(params[i], NULL, 10);
- }
- for (ptrdiff_t i = 0; i < 4; i++) {
- e->t[i] = wcstol(params[3+i], NULL, 10);
- }
-
- sub->m_effects[EF_FADE] = e;
- }
- } else if (params.GetCount() == 2 && !sub->m_effects[EF_FADE]) { // {\fad(t1=t[1], t2=t[2])
- if (Effect* e = DNew Effect) {
- e->param[0] = e->param[2] = 0xff;
- e->param[1] = 0x00;
- for (ptrdiff_t i = 1; i < 3; i++) {
- e->t[i] = wcstol(params[i-1], NULL, 10);
- }
- e->t[0] = e->t[3] = -1; // will be substituted with "start" and "end"
-
- sub->m_effects[EF_FADE] = e;
- }
- }
- } else if (cmd == L"fax") {
- style.fontShiftX = !p.IsEmpty()
- ? CalcAnimation(wcstod(p, NULL), style.fontShiftX, fAnimate)
- : org.fontShiftX;
- } else if (cmd == L"fay") {
- style.fontShiftY = !p.IsEmpty()
- ? CalcAnimation(wcstod(p, NULL), style.fontShiftY, fAnimate)
- : org.fontShiftY;
- } else if (cmd == L"fe") {
- int n = wcstol(p, NULL, 10);
- style.charSet = !p.IsEmpty()
- ? n
- : org.charSet;
- } else if (cmd == L"fn") {
- style.fontName = (!p.IsEmpty() && p != '0')
- ? CString(p).Trim()
- : org.fontName;
- }
- else if (cmd == L"frx") {
- style.fontAngleX = !p.IsEmpty()
- ? CalcAnimation(wcstod(p, NULL), style.fontAngleX, fAnimate)
- : org.fontAngleX;
- } else if (cmd == L"fry") {
- style.fontAngleY = !p.IsEmpty()
- ? CalcAnimation(wcstod(p, NULL), style.fontAngleY, fAnimate)
- : org.fontAngleY;
- } else if (cmd == L"frz" || cmd == L"fr") {
- style.fontAngleZ = !p.IsEmpty()
- ? CalcAnimation(wcstod(p, NULL), style.fontAngleZ, fAnimate)
- : org.fontAngleZ;
- } else if (cmd == L"fscx") {
- double n = CalcAnimation(wcstol(p, NULL, 10), style.fontScaleX, fAnimate);
- style.fontScaleX = !p.IsEmpty()
- ? ((n < 0) ? 0 : n)
- : org.fontScaleX;
- } else if (cmd == L"fscy") {
- double n = CalcAnimation(wcstol(p, NULL, 10), style.fontScaleY, fAnimate);
- style.fontScaleY = !p.IsEmpty()
- ? ((n < 0) ? 0 : n)
- : org.fontScaleY;
- } else if (cmd == L"fsc") {
- style.fontScaleX = org.fontScaleX;
- style.fontScaleY = org.fontScaleY;
- } else if (cmd == L"fsp") {
- style.fontSpacing = !p.IsEmpty()
- ? CalcAnimation(wcstod(p, NULL), style.fontSpacing, fAnimate)
- : org.fontSpacing;
- }
- else if (cmd == L"fs") {
- if (!p.IsEmpty()) {
- if (p[0] == '-' || p[0] == '+') {
- double n = CalcAnimation(style.fontSize + style.fontSize*wcstol(p, NULL, 10)/10, style.fontSize, fAnimate);
- style.fontSize = (n > 0) ? n : org.fontSize;
- } else {
- double n = CalcAnimation(wcstol(p, NULL, 10), style.fontSize, fAnimate);
- style.fontSize = (n > 0) ? n : org.fontSize;
- }
- } else {
- style.fontSize = org.fontSize;
- }
- } else if (cmd == L"i") {
- int n = wcstol(p, NULL, 10);
- style.fItalic = !p.IsEmpty()
- ? (n == 0 ? false : n == 1 ? true : org.fItalic)
- : org.fItalic;
- }
- else if (cmd == L"kt") {
- m_kstart = !p.IsEmpty()
- ? wcstol(p, NULL, 10)*10
- : 0;
- m_kend = m_kstart;
- } else if (cmd == L"kf" || cmd == L"K") {
- m_ktype = 1;
- m_kstart = m_kend;
- m_kend += !p.IsEmpty()
- ? wcstol(p, NULL, 10)*10
- : 1000;
- } else if (cmd == L"ko") {
- m_ktype = 2;
- m_kstart = m_kend;
- m_kend += !p.IsEmpty()
- ? wcstol(p, NULL, 10)*10
- : 1000;
- } else if (cmd == L"k") {
- m_ktype = 0;
- m_kstart = m_kend;
- m_kend += !p.IsEmpty()
- ? wcstol(p, NULL, 10)*10
- : 1000;
- }
- else if (cmd == L"move") { // {\move(x1=param[0], y1=param[1], x2=param[2], y2=param[3][, t1=t[0], t2=t[1]])}
- if ((params.GetCount() == 4 || params.GetCount() == 6) && !sub->m_effects[EF_MOVE]) {
- if (Effect* e = DNew Effect) {
- e->param[0] = (int)(sub->m_scalex*wcstod(params[0], NULL)*8);
- e->param[1] = (int)(sub->m_scaley*wcstod(params[1], NULL)*8);
- e->param[2] = (int)(sub->m_scalex*wcstod(params[2], NULL)*8);
- e->param[3] = (int)(sub->m_scaley*wcstod(params[3], NULL)*8);
- e->t[0] = e->t[1] = -1;
-
- if (params.GetCount() == 6) {
- for (ptrdiff_t i = 0; i < 2; i++) {
- e->t[i] = wcstol(params[4+i], NULL, 10);
- }
- }
-
- sub->m_effects[EF_MOVE] = e;
- }
- }
- } else if (cmd == L"org") { // {\org(x=param[0], y=param[1])}
- size_t uNumParams = params.GetCount();
- if (uNumParams == 2 && !sub->m_effects[EF_ORG]) {
- if (Effect* e = DNew Effect) {
- e->param[0] = (int)(sub->m_scalex*wcstod(params[0], NULL)*8.0);
- e->param[1] = (int)(sub->m_scaley*wcstod(params[1], NULL)*8.0);
-
- if (sub->m_relativeTo == 1) {
- e->param[0] += m_vidrect.left;
- e->param[1] += m_vidrect.top;
- }
-
- sub->m_effects[EF_ORG] = e;
- }
- }
- } else if (cmd == L"pbo") {
- m_polygonBaselineOffset = wcstol(p, NULL, 10);
- } else if (cmd == L"pos") {
- if (params.GetCount() == 2 && !sub->m_effects[EF_MOVE]) {
- if (Effect* e = DNew Effect) {
- e->param[0] = e->param[2] = (int)(sub->m_scalex*wcstod(params[0], NULL)*8);
- e->param[1] = e->param[3] = (int)(sub->m_scaley*wcstod(params[1], NULL)*8);
- e->t[0] = e->t[1] = 0;
-
- sub->m_effects[EF_MOVE] = e;
- }
- }
- } else if (cmd == L"p") {
- int n = wcstol(p, NULL, 10);
- m_nPolygon = (n <= 0 ? 0 : n);
- } else if (cmd == L"q") {
- int n = wcstol(p, NULL, 10);
- sub->m_wrapStyle = !p.IsEmpty() && (0 <= n && n <= 3)
- ? n
- : m_defaultWrapStyle;
- }
- else if (cmd == L"r") {
- STSStyle* val;
- style = (!p.IsEmpty() && m_styles.Lookup(CString(p), val) && val) ? *val : org;
- } else if (cmd == L"shad") {
- double dst = wcstod(p, NULL);
- double nx = CalcAnimation(dst, style.shadowDepthX, fAnimate);
- style.shadowDepthX = !p.IsEmpty()
- ? (nx < 0 ? 0 : nx)
- : org.shadowDepthX;
- double ny = CalcAnimation(dst, style.shadowDepthY, fAnimate);
- style.shadowDepthY = !p.IsEmpty()
- ? (ny < 0 ? 0 : ny)
- : org.shadowDepthY;
- } else if (cmd == L"s") {
- int n = wcstol(p, NULL, 10);
- style.fStrikeOut = !p.IsEmpty()
- ? (n == 0 ? false : n == 1 ? true : org.fStrikeOut)
- : org.fStrikeOut;
- } else if (cmd == L"t") { // \t([<t1>,<t2>,][<accel>,]<style modifiers>)
- p.Empty();
-
- m_animStart = m_animEnd = 0;
- m_animAccel = 1;
-
- if (params.GetCount() == 1) {
- p = params[0];
- } else if (params.GetCount() == 2) {
- m_animAccel = wcstod(params[0], NULL);
- p = params[1];
- } else if (params.GetCount() == 3) {
- m_animStart = (int)wcstod(params[0], NULL);
- m_animEnd = (int)wcstod(params[1], NULL);
- p = params[2];
- } else if (params.GetCount() == 4) {
- m_animStart = wcstol(params[0], NULL, 10);
- m_animEnd = wcstol(params[1], NULL, 10);
- m_animAccel = wcstod(params[2], NULL);
- p = params[3];
- }
-
- ParseSSATag(sub, p, style, org, true);
-
- sub->m_fAnimated = true;
- } else if (cmd == L"u") {
- int n = wcstol(p, NULL, 10);
- style.fUnderline = !p.IsEmpty()
- ? (n == 0 ? false : n == 1 ? true : org.fUnderline)
- : org.fUnderline;
- } else if (cmd == L"xbord") {
- double dst = wcstod(p, NULL);
- double nx = CalcAnimation(dst, style.outlineWidthX, fAnimate);
- style.outlineWidthX = !p.IsEmpty()
- ? (nx < 0 ? 0 : nx)
- : org.outlineWidthX;
- } else if (cmd == L"xshad") {
- double dst = wcstod(p, NULL);
- double nx = CalcAnimation(dst, style.shadowDepthX, fAnimate);
- style.shadowDepthX = !p.IsEmpty()
- ? nx
- : org.shadowDepthX;
- } else if (cmd == L"ybord") {
- double dst = wcstod(p, NULL);
- double ny = CalcAnimation(dst, style.outlineWidthY, fAnimate);
- style.outlineWidthY = !p.IsEmpty()
- ? (ny < 0 ? 0 : ny)
- : org.outlineWidthY;
- } else if (cmd == L"yshad") {
- double dst = wcstod(p, NULL);
- double ny = CalcAnimation(dst, style.shadowDepthY, fAnimate);
- style.shadowDepthY = !p.IsEmpty()
- ? ny
- : org.shadowDepthY;
- }
- }
-
- //return (nUnrecognizedTags < nTags);
- return true; // there are people keeping comments inside {}, lets make them happy now
+ if (!sub) {
+ return false;
+ }
+
+ int nTags = 0, nUnrecognizedTags = 0;
+
+ for (int i = 0, j; (j = str.Find('\\', i)) >= 0; i = j) {
+ CStringW cmd;
+ for (WCHAR c = str[++j]; c && c != '(' && c != '\\'; cmd += c, c = str[++j]) {
+ ;
+ }
+ cmd.Trim();
+ if (cmd.IsEmpty()) {
+ continue;
+ }
+
+ CAtlArray<CStringW> params;
+
+ if (str[j] == '(') {
+ CStringW param;
+ // complex tags search
+ int br = 1; // 1 bracket
+ for (WCHAR c = str[++j]; c && br > 0; param += c, c = str[++j]) {
+ if (c == '(') {
+ br++;
+ }
+ if (c == ')') {
+ br--;
+ }
+ if (br == 0) {
+ break;
+ }
+ }
+ param.Trim();
+
+ while (!param.IsEmpty()) {
+ int i = param.Find(','), j = param.Find('\\');
+
+ if (i >= 0 && (j < 0 || i < j)) {
+ CStringW s = param.Left(i).Trim();
+ if (!s.IsEmpty()) {
+ params.Add(s);
+ }
+ param = i + 1 < param.GetLength() ? param.Mid(i + 1) : L"";
+ } else {
+ param.Trim();
+ if (!param.IsEmpty()) {
+ params.Add(param);
+ }
+ param.Empty();
+ }
+ }
+ }
+
+ if (!cmd.Find(L"1c") || !cmd.Find(L"2c") || !cmd.Find(L"3c") || !cmd.Find(L"4c")) {
+ params.Add(cmd.Mid(2).Trim(L"&H")), cmd = cmd.Left(2);
+ } else if (!cmd.Find(L"1a") || !cmd.Find(L"2a") || !cmd.Find(L"3a") || !cmd.Find(L"4a")) {
+ params.Add(cmd.Mid(2).Trim(L"&H")), cmd = cmd.Left(2);
+ } else if (!cmd.Find(L"alpha")) {
+ params.Add(cmd.Mid(5).Trim(L"&H")), cmd = cmd.Left(5);
+ } else if (!cmd.Find(L"an")) {
+ params.Add(cmd.Mid(2)), cmd = cmd.Left(2);
+ } else if (!cmd.Find(L"a")) {
+ params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
+ } else if (!cmd.Find(L"blur")) {
+ params.Add(cmd.Mid(4)), cmd = cmd.Left(4);
+ } else if (!cmd.Find(L"bord")) {
+ params.Add(cmd.Mid(4)), cmd = cmd.Left(4);
+ } else if (!cmd.Find(L"be")) {
+ params.Add(cmd.Mid(2)), cmd = cmd.Left(2);
+ } else if (!cmd.Find(L"b")) {
+ params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
+ } else if (!cmd.Find(L"clip")) {
+ ;
+ } else if (!cmd.Find(L"c")) {
+ params.Add(cmd.Mid(1).Trim(L"&H")), cmd = cmd.Left(1);
+ } else if (!cmd.Find(L"fade")) {
+ ;
+ } else if (!cmd.Find(L"fe")) {
+ params.Add(cmd.Mid(2)), cmd = cmd.Left(2);
+ } else if (!cmd.Find(L"fn")) {
+ params.Add(cmd.Mid(2)), cmd = cmd.Left(2);
+ } else if (!cmd.Find(L"frx") || !cmd.Find(L"fry") || !cmd.Find(L"frz")) {
+ params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
+ } else if (!cmd.Find(L"fax") || !cmd.Find(L"fay")) {
+ params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
+ } else if (!cmd.Find(L"fr")) {
+ params.Add(cmd.Mid(2)), cmd = cmd.Left(2);
+ } else if (!cmd.Find(L"fscx") || !cmd.Find(L"fscy")) {
+ params.Add(cmd.Mid(4)), cmd = cmd.Left(4);
+ } else if (!cmd.Find(L"fsc")) {
+ params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
+ } else if (!cmd.Find(L"fsp")) {
+ params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
+ } else if (!cmd.Find(L"fs")) {
+ params.Add(cmd.Mid(2)), cmd = cmd.Left(2);
+ } else if (!cmd.Find(L"iclip")) {
+ ;
+ } else if (!cmd.Find(L"i")) {
+ params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
+ } else if (!cmd.Find(L"kt") || !cmd.Find(L"kf") || !cmd.Find(L"ko")) {
+ params.Add(cmd.Mid(2)), cmd = cmd.Left(2);
+ } else if (!cmd.Find(L"k") || !cmd.Find(L"K")) {
+ params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
+ } else if (!cmd.Find(L"move")) {
+ ;
+ } else if (!cmd.Find(L"org")) {
+ ;
+ } else if (!cmd.Find(L"pbo")) {
+ params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
+ } else if (!cmd.Find(L"pos")) {
+ ;
+ } else if (!cmd.Find(L"p")) {
+ params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
+ } else if (!cmd.Find(L"q")) {
+ params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
+ } else if (!cmd.Find(L"r")) {
+ params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
+ } else if (!cmd.Find(L"shad")) {
+ params.Add(cmd.Mid(4)), cmd = cmd.Left(4);
+ } else if (!cmd.Find(L"s")) {
+ params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
+ } else if (!cmd.Find(L"t")) {
+ ;
+ } else if (!cmd.Find(L"u")) {
+ params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
+ } else if (!cmd.Find(L"xbord")) {
+ params.Add(cmd.Mid(5)), cmd = cmd.Left(5);
+ } else if (!cmd.Find(L"xshad")) {
+ params.Add(cmd.Mid(5)), cmd = cmd.Left(5);
+ } else if (!cmd.Find(L"ybord")) {
+ params.Add(cmd.Mid(5)), cmd = cmd.Left(5);
+ } else if (!cmd.Find(L"yshad")) {
+ params.Add(cmd.Mid(5)), cmd = cmd.Left(5);
+ } else {
+ nUnrecognizedTags++;
+ }
+
+ nTags++;
+
+ // TODO: call ParseStyleModifier(cmd, params, ..) and move the rest there
+
+ CStringW p = params.GetCount() > 0 ? params[0] : L"";
+
+ if (cmd == "1c" || cmd == L"2c" || cmd == L"3c" || cmd == L"4c") {
+ int i = cmd[0] - '1';
+
+ DWORD c = wcstol(p, NULL, 16);
+ style.colors[i] = !p.IsEmpty()
+ ? (((int)CalcAnimation(c & 0xff, style.colors[i] & 0xff, fAnimate)) & 0xff
+ | ((int)CalcAnimation(c & 0xff00, style.colors[i] & 0xff00, fAnimate)) & 0xff00
+ | ((int)CalcAnimation(c & 0xff0000, style.colors[i] & 0xff0000, fAnimate)) & 0xff0000)
+ : org.colors[i];
+ } else if (cmd == L"1a" || cmd == L"2a" || cmd == L"3a" || cmd == L"4a") {
+ DWORD al = wcstol(p, NULL, 16) & 0xff;
+ int i = cmd[0] - '1';
+
+ style.alpha[i] = !p.IsEmpty()
+ ? (BYTE)CalcAnimation(al, style.alpha[i], fAnimate)
+ : org.alpha[i];
+ } else if (cmd == L"alpha") {
+ for (ptrdiff_t i = 0; i < 4; i++) {
+ DWORD al = wcstol(p, NULL, 16) & 0xff;
+ style.alpha[i] = !p.IsEmpty()
+ ? (BYTE)CalcAnimation(al, style.alpha[i], fAnimate)
+ : org.alpha[i];
+ }
+ } else if (cmd == L"an") {
+ int n = wcstol(p, NULL, 10);
+ if (sub->m_scrAlignment < 0) {
+ sub->m_scrAlignment = (n > 0 && n < 10) ? n : org.scrAlignment;
+ }
+ } else if (cmd == L"a") {
+ int n = wcstol(p, NULL, 10);
+ if (sub->m_scrAlignment < 0) {
+ sub->m_scrAlignment = (n > 0 && n < 12) ? ((((n - 1) & 3) + 1) + ((n & 4) ? 6 : 0) + ((n & 8) ? 3 : 0)) : org.scrAlignment;
+ }
+ } else if (cmd == L"blur") {
+ double n = CalcAnimation(wcstod(p, NULL), style.fGaussianBlur, fAnimate);
+ style.fGaussianBlur = !p.IsEmpty()
+ ? (n < 0 ? 0 : n)
+ : org.fGaussianBlur;
+ } else if (cmd == L"bord") {
+ double dst = wcstod(p, NULL);
+ double nx = CalcAnimation(dst, style.outlineWidthX, fAnimate);
+ style.outlineWidthX = !p.IsEmpty()
+ ? (nx < 0 ? 0 : nx)
+ : org.outlineWidthX;
+ double ny = CalcAnimation(dst, style.outlineWidthY, fAnimate);
+ style.outlineWidthY = !p.IsEmpty()
+ ? (ny < 0 ? 0 : ny)
+ : org.outlineWidthY;
+ } else if (cmd == L"be") {
+ int n = (int)(CalcAnimation(wcstol(p, NULL, 10), style.fBlur, fAnimate) + 0.5);
+ style.fBlur = !p.IsEmpty()
+ ? n
+ : org.fBlur;
+ } else if (cmd == L"b") {
+ int n = wcstol(p, NULL, 10);
+ style.fontWeight = !p.IsEmpty()
+ ? (n == 0 ? FW_NORMAL : n == 1 ? FW_BOLD : n >= 100 ? n : org.fontWeight)
+ : org.fontWeight;
+ } else if (cmd == L"clip" || cmd == L"iclip") {
+ bool invert = (cmd == L"iclip");
+
+ if (params.GetCount() == 1 && !sub->m_pClipper) {
+ sub->m_pClipper = DNew CClipper(params[0], CSize(m_size.cx >> 3, m_size.cy >> 3), sub->m_scalex, sub->m_scaley, invert, (sub->m_relativeTo == 1) ? CPoint(m_vidrect.left, m_vidrect.top) : CPoint(0, 0));
+ } else if (params.GetCount() == 2 && !sub->m_pClipper) {
+ long scale = wcstol(p, NULL, 10);
+ if (scale < 1) { scale = 1; }
+ sub->m_pClipper = DNew CClipper(params[1], CSize(m_size.cx >> 3, m_size.cy >> 3), sub->m_scalex / (1 << (scale - 1)), sub->m_scaley / (1 << (scale - 1)), invert, (sub->m_relativeTo == 1) ? CPoint(m_vidrect.left, m_vidrect.top) : CPoint(0, 0));
+ } else if (params.GetCount() == 4) {
+ CRect r;
+
+ sub->m_clipInverse = invert;
+
+ r.SetRect(
+ wcstol(params[0], NULL, 10),
+ wcstol(params[1], NULL, 10),
+ wcstol(params[2], NULL, 10),
+ wcstol(params[3], NULL, 10));
+
+ double dLeft = sub->m_scalex * static_cast<double>(r.left), dTop = sub->m_scaley * static_cast<double>(r.top), dRight = sub->m_scalex * static_cast<double>(r.right), dBottom = sub->m_scaley * static_cast<double>(r.bottom);
+ if (sub->m_relativeTo == 1) {
+ double dOffsetX = static_cast<double>(m_vidrect.left) * 0.125;
+ double dOffsetY = static_cast<double>(m_vidrect.top) * 0.125;
+ dLeft += dOffsetX;
+ dTop += dOffsetY;
+ dRight += dOffsetX;
+ dBottom += dOffsetY;
+ }
+
+ sub->m_clip.SetRect(
+ static_cast<int>(CalcAnimation(dLeft, sub->m_clip.left, fAnimate)),
+ static_cast<int>(CalcAnimation(dTop, sub->m_clip.top, fAnimate)),
+ static_cast<int>(CalcAnimation(dRight, sub->m_clip.right, fAnimate)),
+ static_cast<int>(CalcAnimation(dBottom, sub->m_clip.bottom, fAnimate)));
+ }
+ } else if (cmd == L"c") {
+ DWORD c = wcstol(p, NULL, 16);
+ style.colors[0] = !p.IsEmpty()
+ ? (((int)CalcAnimation(c & 0xff, style.colors[0] & 0xff, fAnimate)) & 0xff
+ | ((int)CalcAnimation(c & 0xff00, style.colors[0] & 0xff00, fAnimate)) & 0xff00
+ | ((int)CalcAnimation(c & 0xff0000, style.colors[0] & 0xff0000, fAnimate)) & 0xff0000)
+ : org.colors[0];
+ } else if (cmd == L"fade" || cmd == L"fad") {
+ if (params.GetCount() == 7 && !sub->m_effects[EF_FADE]) { // {\fade(a1=param[0], a2=param[1], a3=param[2], t1=t[0], t2=t[1], t3=t[2], t4=t[3])
+ if (Effect* e = DNew Effect) {
+ for (ptrdiff_t i = 0; i < 3; i++) {
+ e->param[i] = wcstol(params[i], NULL, 10);
+ }
+ for (ptrdiff_t i = 0; i < 4; i++) {
+ e->t[i] = wcstol(params[3 + i], NULL, 10);
+ }
+
+ sub->m_effects[EF_FADE] = e;
+ }
+ } else if (params.GetCount() == 2 && !sub->m_effects[EF_FADE]) { // {\fad(t1=t[1], t2=t[2])
+ if (Effect* e = DNew Effect) {
+ e->param[0] = e->param[2] = 0xff;
+ e->param[1] = 0x00;
+ for (ptrdiff_t i = 1; i < 3; i++) {
+ e->t[i] = wcstol(params[i - 1], NULL, 10);
+ }
+ e->t[0] = e->t[3] = -1; // will be substituted with "start" and "end"
+
+ sub->m_effects[EF_FADE] = e;
+ }
+ }
+ } else if (cmd == L"fax") {
+ style.fontShiftX = !p.IsEmpty()
+ ? CalcAnimation(wcstod(p, NULL), style.fontShiftX, fAnimate)
+ : org.fontShiftX;
+ } else if (cmd == L"fay") {
+ style.fontShiftY = !p.IsEmpty()
+ ? CalcAnimation(wcstod(p, NULL), style.fontShiftY, fAnimate)
+ : org.fontShiftY;
+ } else if (cmd == L"fe") {
+ int n = wcstol(p, NULL, 10);
+ style.charSet = !p.IsEmpty()
+ ? n
+ : org.charSet;
+ } else if (cmd == L"fn") {
+ style.fontName = (!p.IsEmpty() && p != '0')
+ ? CString(p).Trim()
+ : org.fontName;
+ } else if (cmd == L"frx") {
+ style.fontAngleX = !p.IsEmpty()
+ ? CalcAnimation(wcstod(p, NULL), style.fontAngleX, fAnimate)
+ : org.fontAngleX;
+ } else if (cmd == L"fry") {
+ style.fontAngleY = !p.IsEmpty()
+ ? CalcAnimation(wcstod(p, NULL), style.fontAngleY, fAnimate)
+ : org.fontAngleY;
+ } else if (cmd == L"frz" || cmd == L"fr") {
+ style.fontAngleZ = !p.IsEmpty()
+ ? CalcAnimation(wcstod(p, NULL), style.fontAngleZ, fAnimate)
+ : org.fontAngleZ;
+ } else if (cmd == L"fscx") {
+ double n = CalcAnimation(wcstol(p, NULL, 10), style.fontScaleX, fAnimate);
+ style.fontScaleX = !p.IsEmpty()
+ ? ((n < 0) ? 0 : n)
+ : org.fontScaleX;
+ } else if (cmd == L"fscy") {
+ double n = CalcAnimation(wcstol(p, NULL, 10), style.fontScaleY, fAnimate);
+ style.fontScaleY = !p.IsEmpty()
+ ? ((n < 0) ? 0 : n)
+ : org.fontScaleY;
+ } else if (cmd == L"fsc") {
+ style.fontScaleX = org.fontScaleX;
+ style.fontScaleY = org.fontScaleY;
+ } else if (cmd == L"fsp") {
+ style.fontSpacing = !p.IsEmpty()
+ ? CalcAnimation(wcstod(p, NULL), style.fontSpacing, fAnimate)
+ : org.fontSpacing;
+ } else if (cmd == L"fs") {
+ if (!p.IsEmpty()) {
+ if (p[0] == '-' || p[0] == '+') {
+ double n = CalcAnimation(style.fontSize + style.fontSize * wcstol(p, NULL, 10) / 10, style.fontSize, fAnimate);
+ style.fontSize = (n > 0) ? n : org.fontSize;
+ } else {
+ double n = CalcAnimation(wcstol(p, NULL, 10), style.fontSize, fAnimate);
+ style.fontSize = (n > 0) ? n : org.fontSize;
+ }
+ } else {
+ style.fontSize = org.fontSize;
+ }
+ } else if (cmd == L"i") {
+ int n = wcstol(p, NULL, 10);
+ style.fItalic = !p.IsEmpty()
+ ? (n == 0 ? false : n == 1 ? true : org.fItalic)
+ : org.fItalic;
+ } else if (cmd == L"kt") {
+ m_kstart = !p.IsEmpty()
+ ? wcstol(p, NULL, 10) * 10
+ : 0;
+ m_kend = m_kstart;
+ } else if (cmd == L"kf" || cmd == L"K") {
+ m_ktype = 1;
+ m_kstart = m_kend;
+ m_kend += !p.IsEmpty()
+ ? wcstol(p, NULL, 10) * 10
+ : 1000;
+ } else if (cmd == L"ko") {
+ m_ktype = 2;
+ m_kstart = m_kend;
+ m_kend += !p.IsEmpty()
+ ? wcstol(p, NULL, 10) * 10
+ : 1000;
+ } else if (cmd == L"k") {
+ m_ktype = 0;
+ m_kstart = m_kend;
+ m_kend += !p.IsEmpty()
+ ? wcstol(p, NULL, 10) * 10
+ : 1000;
+ } else if (cmd == L"move") { // {\move(x1=param[0], y1=param[1], x2=param[2], y2=param[3][, t1=t[0], t2=t[1]])}
+ if ((params.GetCount() == 4 || params.GetCount() == 6) && !sub->m_effects[EF_MOVE]) {
+ if (Effect* e = DNew Effect) {
+ e->param[0] = (int)(sub->m_scalex * wcstod(params[0], NULL) * 8);
+ e->param[1] = (int)(sub->m_scaley * wcstod(params[1], NULL) * 8);
+ e->param[2] = (int)(sub->m_scalex * wcstod(params[2], NULL) * 8);
+ e->param[3] = (int)(sub->m_scaley * wcstod(params[3], NULL) * 8);
+ e->t[0] = e->t[1] = -1;
+
+ if (params.GetCount() == 6) {
+ for (ptrdiff_t i = 0; i < 2; i++) {
+ e->t[i] = wcstol(params[4 + i], NULL, 10);
+ }
+ }
+
+ sub->m_effects[EF_MOVE] = e;
+ }
+ }
+ } else if (cmd == L"org") { // {\org(x=param[0], y=param[1])}
+ size_t uNumParams = params.GetCount();
+ if (uNumParams == 2 && !sub->m_effects[EF_ORG]) {
+ if (Effect* e = DNew Effect) {
+ e->param[0] = (int)(sub->m_scalex * wcstod(params[0], NULL) * 8.0);
+ e->param[1] = (int)(sub->m_scaley * wcstod(params[1], NULL) * 8.0);
+
+ if (sub->m_relativeTo == 1) {
+ e->param[0] += m_vidrect.left;
+ e->param[1] += m_vidrect.top;
+ }
+
+ sub->m_effects[EF_ORG] = e;
+ }
+ }
+ } else if (cmd == L"pbo") {
+ m_polygonBaselineOffset = wcstol(p, NULL, 10);
+ } else if (cmd == L"pos") {
+ if (params.GetCount() == 2 && !sub->m_effects[EF_MOVE]) {
+ if (Effect* e = DNew Effect) {
+ e->param[0] = e->param[2] = (int)(sub->m_scalex * wcstod(params[0], NULL) * 8);
+ e->param[1] = e->param[3] = (int)(sub->m_scaley * wcstod(params[1], NULL) * 8);
+ e->t[0] = e->t[1] = 0;
+
+ sub->m_effects[EF_MOVE] = e;
+ }
+ }
+ } else if (cmd == L"p") {
+ int n = wcstol(p, NULL, 10);
+ m_nPolygon = (n <= 0 ? 0 : n);
+ } else if (cmd == L"q") {
+ int n = wcstol(p, NULL, 10);
+ sub->m_wrapStyle = !p.IsEmpty() && (0 <= n && n <= 3)
+ ? n
+ : m_defaultWrapStyle;
+ } else if (cmd == L"r") {
+ STSStyle* val;
+ style = (!p.IsEmpty() && m_styles.Lookup(CString(p), val) && val) ? *val : org;
+ } else if (cmd == L"shad") {
+ double dst = wcstod(p, NULL);
+ double nx = CalcAnimation(dst, style.shadowDepthX, fAnimate);
+ style.shadowDepthX = !p.IsEmpty()
+ ? (nx < 0 ? 0 : nx)
+ : org.shadowDepthX;
+ double ny = CalcAnimation(dst, style.shadowDepthY, fAnimate);
+ style.shadowDepthY = !p.IsEmpty()
+ ? (ny < 0 ? 0 : ny)
+ : org.shadowDepthY;
+ } else if (cmd == L"s") {
+ int n = wcstol(p, NULL, 10);
+ style.fStrikeOut = !p.IsEmpty()
+ ? (n == 0 ? false : n == 1 ? true : org.fStrikeOut)
+ : org.fStrikeOut;
+ } else if (cmd == L"t") { // \t([<t1>,<t2>,][<accel>,]<style modifiers>)
+ p.Empty();
+
+ m_animStart = m_animEnd = 0;
+ m_animAccel = 1;
+
+ if (params.GetCount() == 1) {
+ p = params[0];
+ } else if (params.GetCount() == 2) {
+ m_animAccel = wcstod(params[0], NULL);
+ p = params[1];
+ } else if (params.GetCount() == 3) {
+ m_animStart = (int)wcstod(params[0], NULL);
+ m_animEnd = (int)wcstod(params[1], NULL);
+ p = params[2];
+ } else if (params.GetCount() == 4) {
+ m_animStart = wcstol(params[0], NULL, 10);
+ m_animEnd = wcstol(params[1], NULL, 10);
+ m_animAccel = wcstod(params[2], NULL);
+ p = params[3];
+ }
+
+ ParseSSATag(sub, p, style, org, true);
+
+ sub->m_fAnimated = true;
+ } else if (cmd == L"u") {
+ int n = wcstol(p, NULL, 10);
+ style.fUnderline = !p.IsEmpty()
+ ? (n == 0 ? false : n == 1 ? true : org.fUnderline)
+ : org.fUnderline;
+ } else if (cmd == L"xbord") {
+ double dst = wcstod(p, NULL);
+ double nx = CalcAnimation(dst, style.outlineWidthX, fAnimate);
+ style.outlineWidthX = !p.IsEmpty()
+ ? (nx < 0 ? 0 : nx)
+ : org.outlineWidthX;
+ } else if (cmd == L"xshad") {
+ double dst = wcstod(p, NULL);
+ double nx = CalcAnimation(dst, style.shadowDepthX, fAnimate);
+ style.shadowDepthX = !p.IsEmpty()
+ ? nx
+ : org.shadowDepthX;
+ } else if (cmd == L"ybord") {
+ double dst = wcstod(p, NULL);
+ double ny = CalcAnimation(dst, style.outlineWidthY, fAnimate);
+ style.outlineWidthY = !p.IsEmpty()
+ ? (ny < 0 ? 0 : ny)
+ : org.outlineWidthY;
+ } else if (cmd == L"yshad") {
+ double dst = wcstod(p, NULL);
+ double ny = CalcAnimation(dst, style.shadowDepthY, fAnimate);
+ style.shadowDepthY = !p.IsEmpty()
+ ? ny
+ : org.shadowDepthY;
+ }
+ }
+
+ //return (nUnrecognizedTags < nTags);
+ return true; // there are people keeping comments inside {}, lets make them happy now
}
bool CRenderedTextSubtitle::ParseHtmlTag(CSubtitle* sub, CStringW str, STSStyle& style, STSStyle& org)
{
- if (str.Find(L"!--") == 0) {
- return true;
- }
-
- bool fClosing = str[0] == '/';
- str.Trim(L" /");
-
- int i = str.Find(' ');
- if (i < 0) {
- i = str.GetLength();
- }
-
- CStringW tag = str.Left(i).MakeLower();
- str = str.Mid(i).Trim();
-
- CAtlArray<CStringW> attribs, params;
- while ((i = str.Find('=')) > 0) {
- attribs.Add(str.Left(i).Trim().MakeLower());
- str = str.Mid(i+1);
- for (i = 0; _istspace(str[i]); i++) {
- ;
- }
- str = str.Mid(i);
- if (str[0] == '\"') {
- str = str.Mid(1);
- i = str.Find('\"');
- } else {
- i = str.Find(' ');
- }
- if (i < 0) {
- i = str.GetLength();
- }
- params.Add(str.Left(i).Trim().MakeLower());
- str = str.Mid(i+1);
- }
-
- if (tag == L"text") {
- ;
- } else if (tag == L"b" || tag == L"strong") {
- style.fontWeight = !fClosing ? FW_BOLD : org.fontWeight;
- } else if (tag == L"i" || tag == L"em") {
- style.fItalic = !fClosing ? true : org.fItalic;
- } else if (tag == L"u") {
- style.fUnderline = !fClosing ? true : org.fUnderline;
- } else if (tag == L"s" || tag == L"strike" || tag == L"del") {
- style.fStrikeOut = !fClosing ? true : org.fStrikeOut;
- } else if (tag == L"font") {
- if (!fClosing) {
- for (size_t i = 0; i < attribs.GetCount(); i++) {
- if (params[i].IsEmpty()) {
- continue;
- }
-
- int nColor = -1;
-
- if (attribs[i] == L"face") {
- style.fontName = params[i];
- } else if (attribs[i] == L"size") {
- if (params[i][0] == '+') {
- style.fontSize += wcstol(params[i], NULL, 10);
- } else if (params[i][0] == '-') {
- style.fontSize -= wcstol(params[i], NULL, 10);
- } else {
- style.fontSize = wcstol(params[i], NULL, 10);
- }
- } else if (attribs[i] == L"color") {
- nColor = 0;
- } else if (attribs[i] == L"outline-color") {
- nColor = 2;
- } else if (attribs[i] == L"outline-level") {
- style.outlineWidthX = style.outlineWidthY = wcstol(params[i], NULL, 10);
- } else if (attribs[i] == L"shadow-color") {
- nColor = 3;
- } else if (attribs[i] == L"shadow-level") {
- style.shadowDepthX = style.shadowDepthY = wcstol(params[i], NULL, 10);
- }
-
- if (nColor >= 0 && nColor < 4) {
- CString key = WToT(params[i]).TrimLeft('#');
- DWORD val;
- if (g_colors.Lookup(key, val)) {
- style.colors[nColor] = val;
- } else if ((style.colors[nColor] = _tcstol(key, NULL, 16)) == 0) {
- style.colors[nColor] = 0x00ffffff; // default is white
- }
- style.colors[nColor] = ((style.colors[nColor]>>16)&0xff)|((style.colors[nColor]&0xff)<<16)|(style.colors[nColor]&0x00ff00);
- }
- }
- } else {
- style.fontName = org.fontName;
- style.fontSize = org.fontSize;
- memcpy(style.colors, org.colors, sizeof(style.colors));
- }
- } else if (tag == L"k" && attribs.GetCount() == 1 && attribs[0] == L"t") {
- m_ktype = 1;
- m_kstart = m_kend;
- m_kend += wcstol(params[0], NULL, 10);
- } else {
- return false;
- }
-
- return true;
+ if (str.Find(L"!--") == 0) {
+ return true;
+ }
+
+ bool fClosing = str[0] == '/';
+ str.Trim(L" /");
+
+ int i = str.Find(' ');
+ if (i < 0) {
+ i = str.GetLength();
+ }
+
+ CStringW tag = str.Left(i).MakeLower();
+ str = str.Mid(i).Trim();
+
+ CAtlArray<CStringW> attribs, params;
+ while ((i = str.Find('=')) > 0) {
+ attribs.Add(str.Left(i).Trim().MakeLower());
+ str = str.Mid(i + 1);
+ for (i = 0; _istspace(str[i]); i++) {
+ ;
+ }
+ str = str.Mid(i);
+ if (str[0] == '\"') {
+ str = str.Mid(1);
+ i = str.Find('\"');
+ } else {
+ i = str.Find(' ');
+ }
+ if (i < 0) {
+ i = str.GetLength();
+ }
+ params.Add(str.Left(i).Trim().MakeLower());
+ str = str.Mid(i + 1);
+ }
+
+ if (tag == L"text") {
+ ;
+ } else if (tag == L"b" || tag == L"strong") {
+ style.fontWeight = !fClosing ? FW_BOLD : org.fontWeight;
+ } else if (tag == L"i" || tag == L"em") {
+ style.fItalic = !fClosing ? true : org.fItalic;
+ } else if (tag == L"u") {
+ style.fUnderline = !fClosing ? true : org.fUnderline;
+ } else if (tag == L"s" || tag == L"strike" || tag == L"del") {
+ style.fStrikeOut = !fClosing ? true : org.fStrikeOut;
+ } else if (tag == L"font") {
+ if (!fClosing) {
+ for (size_t i = 0; i < attribs.GetCount(); i++) {
+ if (params[i].IsEmpty()) {
+ continue;
+ }
+
+ int nColor = -1;
+
+ if (attribs[i] == L"face") {
+ style.fontName = params[i];
+ } else if (attribs[i] == L"size") {
+ if (params[i][0] == '+') {
+ style.fontSize += wcstol(params[i], NULL, 10);
+ } else if (params[i][0] == '-') {
+ style.fontSize -= wcstol(params[i], NULL, 10);
+ } else {
+ style.fontSize = wcstol(params[i], NULL, 10);
+ }
+ } else if (attribs[i] == L"color") {
+ nColor = 0;
+ } else if (attribs[i] == L"outline-color") {
+ nColor = 2;
+ } else if (attribs[i] == L"outline-level") {
+ style.outlineWidthX = style.outlineWidthY = wcstol(params[i], NULL, 10);
+ } else if (attribs[i] == L"shadow-color") {
+ nColor = 3;
+ } else if (attribs[i] == L"shadow-level") {
+ style.shadowDepthX = style.shadowDepthY = wcstol(params[i], NULL, 10);
+ }
+
+ if (nColor >= 0 && nColor < 4) {
+ CString key = WToT(params[i]).TrimLeft('#');
+ DWORD val;
+ if (g_colors.Lookup(key, val)) {
+ style.colors[nColor] = val;
+ } else if ((style.colors[nColor] = _tcstol(key, NULL, 16)) == 0) {
+ style.colors[nColor] = 0x00ffffff; // default is white
+ }
+ style.colors[nColor] = ((style.colors[nColor] >> 16) & 0xff) | ((style.colors[nColor] & 0xff) << 16) | (style.colors[nColor] & 0x00ff00);
+ }
+ }
+ } else {
+ style.fontName = org.fontName;
+ style.fontSize = org.fontSize;
+ memcpy(style.colors, org.colors, sizeof(style.colors));
+ }
+ } else if (tag == L"k" && attribs.GetCount() == 1 && attribs[0] == L"t") {
+ m_ktype = 1;
+ m_kstart = m_kend;
+ m_kend += wcstol(params[0], NULL, 10);
+ } else {
+ return false;
+ }
+
+ return true;
}
double CRenderedTextSubtitle::CalcAnimation(double dst, double src, bool fAnimate)
{
- int s = m_animStart ? m_animStart : 0;
- int e = m_animEnd ? m_animEnd : m_delay;
+ int s = m_animStart ? m_animStart : 0;
+ int e = m_animEnd ? m_animEnd : m_delay;
- if (fabs(dst-src) >= 0.0001 && fAnimate) {
- if (m_time < s) {
- dst = src;
- } else if (s <= m_time && m_time < e) {
- double t = pow(1.0 * (m_time - s) / (e - s), m_animAccel);
- dst = (1 - t) * src + t * dst;
- }
- // else dst = dst;
- }
+ if (fabs(dst - src) >= 0.0001 && fAnimate) {
+ if (m_time < s) {
+ dst = src;
+ } else if (s <= m_time && m_time < e) {
+ double t = pow(1.0 * (m_time - s) / (e - s), m_animAccel);
+ dst = (1 - t) * src + t * dst;
+ }
+ // else dst = dst;
+ }
- return dst;
+ return dst;
}
CSubtitle* CRenderedTextSubtitle::GetSubtitle(int entry)
{
- CSubtitle* sub;
- if (m_subtitleCache.Lookup(entry, sub)) {
- if (sub->m_fAnimated) {
- delete sub;
- sub = NULL;
- } else {
- return sub;
- }
- }
-
- sub = DNew CSubtitle();
- if (!sub) {
- return NULL;
- }
-
- CStringW str = GetStrW(entry, true);
-
- STSStyle stss, orgstss;
- if (m_doOverrideStyle && m_pStyleOverride != NULL) {
- // this RTS has been signaled to ignore embedded styles, use the built-in one
- stss = *m_pStyleOverride;
- } else {
- // find the appropriate embedded style
- GetStyle(entry, stss);
- }
- if (m_ePARCompensationType == EPCTUpscale) {
- if (stss.fontScaleX / stss.fontScaleY == 1.0 && m_dPARCompensation != 1.0) {
- if (m_dPARCompensation < 1.0) {
- stss.fontScaleY /= m_dPARCompensation;
- } else {
- stss.fontScaleX *= m_dPARCompensation;
- }
- }
- } else if (m_ePARCompensationType == EPCTDownscale) {
- if (stss.fontScaleX / stss.fontScaleY == 1.0 && m_dPARCompensation != 1.0) {
- if (m_dPARCompensation < 1.0) {
- stss.fontScaleX *= m_dPARCompensation;
- } else {
- stss.fontScaleY /= m_dPARCompensation;
- }
- }
- } else if (m_ePARCompensationType == EPCTAccurateSize) {
- if (stss.fontScaleX / stss.fontScaleY == 1.0 && m_dPARCompensation != 1.0) {
- stss.fontScaleX *= m_dPARCompensation;
- }
- }
-
- orgstss = stss;
-
- sub->m_clip.SetRect(0, 0, m_size.cx>>3, m_size.cy>>3);
- sub->m_scrAlignment = -stss.scrAlignment;
- sub->m_wrapStyle = m_defaultWrapStyle;
- sub->m_fAnimated = false;
- sub->m_relativeTo = stss.relativeTo;
- // this whole conditional is a work-around for what happens in STS.cpp:
- // in CSimpleTextSubtitle::Open, we have m_dstScreenSize = CSize(384, 288)
- // now, files containing embedded subtitles (and with styles) set m_dstScreenSize to a correct value
- // but where no style is given, those defaults are taken - 384, 288
- if (m_doOverrideStyle && m_pStyleOverride) {
- // so mind the default values, stated here to increase comprehension
- sub->m_scalex = m_size.cx / (384 * 8);
- sub->m_scaley = m_size.cy / (288 * 8);
- } else {
- sub->m_scalex = m_dstScreenSize.cx > 0 ? 1.0 * (stss.relativeTo == 1 ? m_vidrect.Width() : m_size.cx) / (m_dstScreenSize.cx*8) : 1.0;
- sub->m_scaley = m_dstScreenSize.cy > 0 ? 1.0 * (stss.relativeTo == 1 ? m_vidrect.Height() : m_size.cy) / (m_dstScreenSize.cy*8) : 1.0;
- }
-
- m_animStart = m_animEnd = 0;
- m_animAccel = 1;
- m_ktype = m_kstart = m_kend = 0;
- m_nPolygon = 0;
- m_polygonBaselineOffset = 0;
- ParseEffect(sub, GetAt(entry).effect);
-
- while (!str.IsEmpty()) {
- bool fParsed = false;
-
- int i;
-
- if (str[0] == '{' && (i = str.Find(L'}')) > 0) {
- fParsed = ParseSSATag(sub, str.Mid(1, i-1), stss, orgstss);
- if (fParsed) {
- str = str.Mid(i+1);
- }
- } else if (str[0] == '<' && (i = str.Find(L'>')) > 0) {
- fParsed = ParseHtmlTag(sub, str.Mid(1, i-1), stss, orgstss);
- if (fParsed) {
- str = str.Mid(i+1);
- }
- }
-
- if (fParsed) {
- i = str.FindOneOf(L"{<");
- if (i < 0) {
- i = str.GetLength();
- }
- if (i == 0) {
- continue;
- }
- } else {
- i = str.Mid(1).FindOneOf(L"{<");
- if (i < 0) {
- i = str.GetLength()-1;
- }
- i++;
- }
-
- STSStyle tmp;
-
- tmp = stss;
-
- tmp.fontSize = sub->m_scaley*tmp.fontSize*64;
- tmp.fontSpacing = sub->m_scalex*tmp.fontSpacing*64;
- tmp.outlineWidthX *= (m_fScaledBAS ? sub->m_scalex : 1) * 8;
- tmp.outlineWidthY *= (m_fScaledBAS ? sub->m_scaley : 1) * 8;
- tmp.shadowDepthX *= (m_fScaledBAS ? sub->m_scalex : 1) * 8;
- tmp.shadowDepthY *= (m_fScaledBAS ? sub->m_scaley : 1) * 8;
-
- if (m_nPolygon) {
- ParsePolygon(sub, str.Left(i), tmp);
- } else {
- ParseString(sub, str.Left(i), tmp);
- }
-
- str = str.Mid(i);
- }
-
- if (m_doOverrideStyle && m_pStyleOverride != NULL) {
- sub->EmptyEffects();
- }
-
- // just a "work-around" solution... in most cases nobody will want to use \org together with moving but without rotating the subs
- if (sub->m_effects[EF_ORG] && (sub->m_effects[EF_MOVE] || sub->m_effects[EF_BANNER] || sub->m_effects[EF_SCROLL])) {
- sub->m_fAnimated = true;
- }
-
- sub->m_scrAlignment = abs(sub->m_scrAlignment);
-
- STSEntry stse = GetAt(entry);
- CRect marginRect = stse.marginRect;
- if (marginRect.left == 0) {
- marginRect.left = orgstss.marginRect.left;
- }
- if (marginRect.top == 0) {
- marginRect.top = orgstss.marginRect.top;
- }
- if (marginRect.right == 0) {
- marginRect.right = orgstss.marginRect.right;
- }
- if (marginRect.bottom == 0) {
- marginRect.bottom = orgstss.marginRect.bottom;
- }
- marginRect.left = (int)(sub->m_scalex*marginRect.left*8);
- marginRect.top = (int)(sub->m_scaley*marginRect.top*8);
- marginRect.right = (int)(sub->m_scalex*marginRect.right*8);
- marginRect.bottom = (int)(sub->m_scaley*marginRect.bottom*8);
-
- if (stss.relativeTo == 1) {
- marginRect.left += m_vidrect.left;
- marginRect.top += m_vidrect.top;
- marginRect.right += m_size.cx - m_vidrect.right;
- marginRect.bottom += m_size.cy - m_vidrect.bottom;
- }
-
- sub->CreateClippers(m_size);
-
- sub->MakeLines(m_size, marginRect);
-
- m_subtitleCache[entry] = sub;
-
- return sub;
+ CSubtitle* sub;
+ if (m_subtitleCache.Lookup(entry, sub)) {
+ if (sub->m_fAnimated) {
+ delete sub;
+ sub = NULL;
+ } else {
+ return sub;
+ }
+ }
+
+ sub = DNew CSubtitle();
+ if (!sub) {
+ return NULL;
+ }
+
+ CStringW str = GetStrW(entry, true);
+
+ STSStyle stss, orgstss;
+ if (m_doOverrideStyle && m_pStyleOverride != NULL) {
+ // this RTS has been signaled to ignore embedded styles, use the built-in one
+ stss = *m_pStyleOverride;
+ } else {
+ // find the appropriate embedded style
+ GetStyle(entry, stss);
+ }
+ if (m_ePARCompensationType == EPCTUpscale) {
+ if (stss.fontScaleX / stss.fontScaleY == 1.0 && m_dPARCompensation != 1.0) {
+ if (m_dPARCompensation < 1.0) {
+ stss.fontScaleY /= m_dPARCompensation;
+ } else {
+ stss.fontScaleX *= m_dPARCompensation;
+ }
+ }
+ } else if (m_ePARCompensationType == EPCTDownscale) {
+ if (stss.fontScaleX / stss.fontScaleY == 1.0 && m_dPARCompensation != 1.0) {
+ if (m_dPARCompensation < 1.0) {
+ stss.fontScaleX *= m_dPARCompensation;
+ } else {
+ stss.fontScaleY /= m_dPARCompensation;
+ }
+ }
+ } else if (m_ePARCompensationType == EPCTAccurateSize) {
+ if (stss.fontScaleX / stss.fontScaleY == 1.0 && m_dPARCompensation != 1.0) {
+ stss.fontScaleX *= m_dPARCompensation;
+ }
+ }
+
+ orgstss = stss;
+
+ sub->m_clip.SetRect(0, 0, m_size.cx >> 3, m_size.cy >> 3);
+ sub->m_scrAlignment = -stss.scrAlignment;
+ sub->m_wrapStyle = m_defaultWrapStyle;
+ sub->m_fAnimated = false;
+ sub->m_relativeTo = stss.relativeTo;
+ // this whole conditional is a work-around for what happens in STS.cpp:
+ // in CSimpleTextSubtitle::Open, we have m_dstScreenSize = CSize(384, 288)
+ // now, files containing embedded subtitles (and with styles) set m_dstScreenSize to a correct value
+ // but where no style is given, those defaults are taken - 384, 288
+ if (m_doOverrideStyle && m_pStyleOverride) {
+ // so mind the default values, stated here to increase comprehension
+ sub->m_scalex = m_size.cx / (384 * 8);
+ sub->m_scaley = m_size.cy / (288 * 8);
+ } else {
+ sub->m_scalex = m_dstScreenSize.cx > 0 ? 1.0 * (stss.relativeTo == 1 ? m_vidrect.Width() : m_size.cx) / (m_dstScreenSize.cx * 8) : 1.0;
+ sub->m_scaley = m_dstScreenSize.cy > 0 ? 1.0 * (stss.relativeTo == 1 ? m_vidrect.Height() : m_size.cy) / (m_dstScreenSize.cy * 8) : 1.0;
+ }
+
+ m_animStart = m_animEnd = 0;
+ m_animAccel = 1;
+ m_ktype = m_kstart = m_kend = 0;
+ m_nPolygon = 0;
+ m_polygonBaselineOffset = 0;
+ ParseEffect(sub, GetAt(entry).effect);
+
+ while (!str.IsEmpty()) {
+ bool fParsed = false;
+
+ int i;
+
+ if (str[0] == '{' && (i = str.Find(L'}')) > 0) {
+ fParsed = ParseSSATag(sub, str.Mid(1, i - 1), stss, orgstss);
+ if (fParsed) {
+ str = str.Mid(i + 1);
+ }
+ } else if (str[0] == '<' && (i = str.Find(L'>')) > 0) {
+ fParsed = ParseHtmlTag(sub, str.Mid(1, i - 1), stss, orgstss);
+ if (fParsed) {
+ str = str.Mid(i + 1);
+ }
+ }
+
+ if (fParsed) {
+ i = str.FindOneOf(L"{<");
+ if (i < 0) {
+ i = str.GetLength();
+ }
+ if (i == 0) {
+ continue;
+ }
+ } else {
+ i = str.Mid(1).FindOneOf(L"{<");
+ if (i < 0) {
+ i = str.GetLength() - 1;
+ }
+ i++;
+ }
+
+ STSStyle tmp;
+
+ tmp = stss;
+
+ tmp.fontSize = sub->m_scaley * tmp.fontSize * 64;
+ tmp.fontSpacing = sub->m_scalex * tmp.fontSpacing * 64;
+ tmp.outlineWidthX *= (m_fScaledBAS ? sub->m_scalex : 1) * 8;
+ tmp.outlineWidthY *= (m_fScaledBAS ? sub->m_scaley : 1) * 8;
+ tmp.shadowDepthX *= (m_fScaledBAS ? sub->m_scalex : 1) * 8;
+ tmp.shadowDepthY *= (m_fScaledBAS ? sub->m_scaley : 1) * 8;
+
+ if (m_nPolygon) {
+ ParsePolygon(sub, str.Left(i), tmp);
+ } else {
+ ParseString(sub, str.Left(i), tmp);
+ }
+
+ str = str.Mid(i);
+ }
+
+ if (m_doOverrideStyle && m_pStyleOverride != NULL) {
+ sub->EmptyEffects();
+ }
+
+ // just a "work-around" solution... in most cases nobody will want to use \org together with moving but without rotating the subs
+ if (sub->m_effects[EF_ORG] && (sub->m_effects[EF_MOVE] || sub->m_effects[EF_BANNER] || sub->m_effects[EF_SCROLL])) {
+ sub->m_fAnimated = true;
+ }
+
+ sub->m_scrAlignment = abs(sub->m_scrAlignment);
+
+ STSEntry stse = GetAt(entry);
+ CRect marginRect = stse.marginRect;
+ if (marginRect.left == 0) {
+ marginRect.left = orgstss.marginRect.left;
+ }
+ if (marginRect.top == 0) {
+ marginRect.top = orgstss.marginRect.top;
+ }
+ if (marginRect.right == 0) {
+ marginRect.right = orgstss.marginRect.right;
+ }
+ if (marginRect.bottom == 0) {
+ marginRect.bottom = orgstss.marginRect.bottom;
+ }
+ marginRect.left = (int)(sub->m_scalex * marginRect.left * 8);
+ marginRect.top = (int)(sub->m_scaley * marginRect.top * 8);
+ marginRect.right = (int)(sub->m_scalex * marginRect.right * 8);
+ marginRect.bottom = (int)(sub->m_scaley * marginRect.bottom * 8);
+
+ if (stss.relativeTo == 1) {
+ marginRect.left += m_vidrect.left;
+ marginRect.top += m_vidrect.top;
+ marginRect.right += m_size.cx - m_vidrect.right;
+ marginRect.bottom += m_size.cy - m_vidrect.bottom;
+ }
+
+ sub->CreateClippers(m_size);
+
+ sub->MakeLines(m_size, marginRect);
+
+ m_subtitleCache[entry] = sub;
+
+ return sub;
}
//
STDMETHODIMP CRenderedTextSubtitle::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
- *ppv = NULL;
+ CheckPointer(ppv, E_POINTER);
+ *ppv = NULL;
- return
- QI(IPersist)
- QI(ISubStream)
- QI(ISubPicProvider)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IPersist)
+ QI(ISubStream)
+ QI(ISubPicProvider)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// ISubPicProvider
STDMETHODIMP_(POSITION) CRenderedTextSubtitle::GetStartPosition(REFERENCE_TIME rt, double fps)
{
- int iSegment = -1;
- SearchSubs((int)(rt/10000), fps, &iSegment, NULL);
+ int iSegment = -1;
+ SearchSubs((int)(rt / 10000), fps, &iSegment, NULL);
- if (iSegment < 0) {
- iSegment = 0;
- }
+ if (iSegment < 0) {
+ iSegment = 0;
+ }
- return GetNext((POSITION)iSegment);
+ return GetNext((POSITION)iSegment);
}
STDMETHODIMP_(POSITION) CRenderedTextSubtitle::GetNext(POSITION pos)
{
- int iSegment = (int)pos;
+ int iSegment = (int)pos;
- const STSSegment* stss = GetSegment(iSegment);
- while (stss && stss->subs.GetCount() == 0) {
- iSegment++;
- stss = GetSegment(iSegment);
- }
+ const STSSegment* stss = GetSegment(iSegment);
+ while (stss && stss->subs.GetCount() == 0) {
+ iSegment++;
+ stss = GetSegment(iSegment);
+ }
- return (stss ? (POSITION)(iSegment+1) : NULL);
+ return (stss ? (POSITION)(iSegment + 1) : NULL);
}
STDMETHODIMP_(REFERENCE_TIME) CRenderedTextSubtitle::GetStart(POSITION pos, double fps)
{
- return (10000i64 * TranslateSegmentStart((int)pos-1, fps));
+ return (10000i64 * TranslateSegmentStart((int)pos - 1, fps));
}
STDMETHODIMP_(REFERENCE_TIME) CRenderedTextSubtitle::GetStop(POSITION pos, double fps)
{
- return (10000i64 * TranslateSegmentEnd((int)pos-1, fps));
+ return (10000i64 * TranslateSegmentEnd((int)pos - 1, fps));
}
STDMETHODIMP_(bool) CRenderedTextSubtitle::IsAnimated(POSITION pos)
{
- return true;
+ return true;
}
struct LSub {
- int idx, layer, readorder;
+ int idx, layer, readorder;
};
static int lscomp(const void* ls1, const void* ls2)
{
- int ret = ((LSub*)ls1)->layer - ((LSub*)ls2)->layer;
- if (!ret) {
- ret = ((LSub*)ls1)->readorder - ((LSub*)ls2)->readorder;
- }
- return ret;
+ int ret = ((LSub*)ls1)->layer - ((LSub*)ls2)->layer;
+ if (!ret) {
+ ret = ((LSub*)ls1)->readorder - ((LSub*)ls2)->readorder;
+ }
+ return ret;
}
STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, double fps, RECT& bbox)
{
- CRect bbox2(0,0,0,0);
+ CRect bbox2(0, 0, 0, 0);
- if (m_size != CSize(spd.w*8, spd.h*8) || m_vidrect != CRect(spd.vidrect.left*8, spd.vidrect.top*8, spd.vidrect.right*8, spd.vidrect.bottom*8)) {
- Init(CSize(spd.w, spd.h), spd.vidrect);
- }
-
- int t = (int)(rt / 10000);
-
- int segment;
- const STSSegment* stss = SearchSubs(t, fps, &segment);
- if (!stss) {
- return S_FALSE;
- }
-
- // clear any cached subs not in the range of +/-30secs measured from the segment's bounds
- {
- POSITION pos = m_subtitleCache.GetStartPosition();
- while (pos) {
- int key;
- CSubtitle* value;
- m_subtitleCache.GetNextAssoc(pos, key, value);
-
- STSEntry& stse = GetAt(key);
- if (stse.end <= (t-30000) || stse.start > (t+30000)) {
- delete value;
- m_subtitleCache.RemoveKey(key);
- pos = m_subtitleCache.GetStartPosition();
- }
- }
- }
-
- m_sla.AdvanceToSegment(segment, stss->subs);
-
- CAtlArray<LSub> subs;
-
- for (ptrdiff_t i = 0, j = stss->subs.GetCount(); i < j; i++) {
- LSub ls;
- ls.idx = stss->subs[i];
- ls.layer = GetAt(stss->subs[i]).layer;
- ls.readorder = GetAt(stss->subs[i]).readorder;
- subs.Add(ls);
- }
-
- qsort(subs.GetData(), subs.GetCount(), sizeof(LSub), lscomp);
-
- for (ptrdiff_t i = 0, j = subs.GetCount(); i < j; i++) {
- int entry = subs[i].idx;
-
- STSEntry stse = GetAt(entry);
-
- {
- int start = TranslateStart(entry, fps);
- m_time = t - start;
- m_delay = TranslateEnd(entry, fps) - start;
- }
-
- CSubtitle* s = GetSubtitle(entry);
- if (!s) {
- continue;
- }
-
- CRect clipRect = s->m_clip;
- CRect r = s->m_rect;
- CSize spaceNeeded = r.Size();
-
- // apply the effects
-
- bool fPosOverride = false, fOrgOverride = false;
-
- int alpha = 0x00;
-
- CPoint org2;
-
- BYTE* pAlphaMask = s->m_pClipper?s->m_pClipper->m_pAlphaMask:NULL;
-
- for (int k = 0; k < EF_NUMBEROFEFFECTS; k++) {
- if (!s->m_effects[k]) {
- continue;
- }
-
- switch (k) {
- case EF_MOVE: { // {\move(x1=param[0], y1=param[1], x2=param[2], y2=param[3], t1=t[0], t2=t[1])}
- CPoint p;
- CPoint p1(s->m_effects[k]->param[0], s->m_effects[k]->param[1]);
- CPoint p2(s->m_effects[k]->param[2], s->m_effects[k]->param[3]);
- int t1 = s->m_effects[k]->t[0];
- int t2 = s->m_effects[k]->t[1];
-
- if (t2 < t1) {
- int t = t1;
- t1 = t2;
- t2 = t;
- }
-
- if (t1 <= 0 && t2 <= 0) {
- t1 = 0;
- t2 = m_delay;
- }
-
- if (m_time <= t1) {
- p = p1;
- } else if (p1 == p2) {
- p = p1;
- } else if (t1 < m_time && m_time < t2) {
- double t = 1.0*(m_time-t1)/(t2-t1);
- p.x = (int)((1-t)*p1.x + t*p2.x);
- p.y = (int)((1-t)*p1.y + t*p2.y);
- } else {
- p = p2;
- }
- r = CRect(
- CPoint((s->m_scrAlignment%3) == 1 ? p.x : (s->m_scrAlignment%3) == 0 ? p.x - spaceNeeded.cx : p.x - (spaceNeeded.cx+1)/2,
- s->m_scrAlignment <= 3 ? p.y - spaceNeeded.cy : s->m_scrAlignment <= 6 ? p.y - (spaceNeeded.cy+1)/2 : p.y),
- spaceNeeded);
-
- if (s->m_relativeTo == 1) {
- r.OffsetRect(m_vidrect.TopLeft());
- }
- fPosOverride = true;
- }
- break;
- case EF_ORG: { // {\org(x=param[0], y=param[1])}
- org2 = CPoint(s->m_effects[k]->param[0], s->m_effects[k]->param[1]);
- fOrgOverride = true;
- }
- break;
- case EF_FADE: { // {\fade(a1=param[0], a2=param[1], a3=param[2], t1=t[0], t2=t[1], t3=t[2], t4=t[3]) or {\fad(t1=t[1], t2=t[2])
- int t1 = s->m_effects[k]->t[0];
- int t2 = s->m_effects[k]->t[1];
- int t3 = s->m_effects[k]->t[2];
- int t4 = s->m_effects[k]->t[3];
-
- if (t1 == -1 && t4 == -1) {
- t1 = 0;
- t3 = m_delay - t3;
- t4 = m_delay;
- }
-
- if (m_time < t1) {
- alpha = s->m_effects[k]->param[0];
- } else if (m_time >= t1 && m_time < t2) {
- double t = 1.0 * (m_time - t1) / (t2 - t1);
- alpha = (int)(s->m_effects[k]->param[0]*(1-t) + s->m_effects[k]->param[1]*t);
- } else if (m_time >= t2 && m_time < t3) {
- alpha = s->m_effects[k]->param[1];
- } else if (m_time >= t3 && m_time < t4) {
- double t = 1.0 * (m_time - t3) / (t4 - t3);
- alpha = (int)(s->m_effects[k]->param[1]*(1-t) + s->m_effects[k]->param[2]*t);
- } else if (m_time >= t4) {
- alpha = s->m_effects[k]->param[2];
- }
- }
- break;
- case EF_BANNER: { // Banner;delay=param[0][;leftoright=param[1];fadeawaywidth=param[2]]
- int left = s->m_relativeTo == 1 ? m_vidrect.left : 0,
- right = s->m_relativeTo == 1 ? m_vidrect.right : m_size.cx;
-
- r.left = !!s->m_effects[k]->param[1]
- ? (left/*marginRect.left*/ - spaceNeeded.cx) + (int)(m_time*8.0/s->m_effects[k]->param[0])
- : (right /*- marginRect.right*/) - (int)(m_time*8.0/s->m_effects[k]->param[0]);
-
- r.right = r.left + spaceNeeded.cx;
-
- clipRect &= CRect(left>>3, clipRect.top, right>>3, clipRect.bottom);
-
- fPosOverride = true;
- }
- break;
- case EF_SCROLL: { // Scroll up/down(toptobottom=param[3]);top=param[0];bottom=param[1];delay=param[2][;fadeawayheight=param[4]]
- r.top = !!s->m_effects[k]->param[3]
- ? s->m_effects[k]->param[0] + (int)(m_time*8.0/s->m_effects[k]->param[2]) - spaceNeeded.cy
- : s->m_effects[k]->param[1] - (int)(m_time*8.0/s->m_effects[k]->param[2]);
-
- r.bottom = r.top + spaceNeeded.cy;
-
- CRect cr(0, (s->m_effects[k]->param[0] + 4) >> 3, spd.w, (s->m_effects[k]->param[1] + 4) >> 3);
-
- if (s->m_relativeTo == 1)
- r.top += m_vidrect.top,
- r.bottom += m_vidrect.top,
- cr.top += m_vidrect.top>>3,
- cr.bottom += m_vidrect.top>>3;
-
- clipRect &= cr;
-
- fPosOverride = true;
- }
- break;
- default:
- break;
- }
- }
-
- if (!fPosOverride && !fOrgOverride && !s->m_fAnimated) {
- r = m_sla.AllocRect(s, segment, entry, stse.layer, m_collisions);
- }
-
- CPoint org;
- org.x = (s->m_scrAlignment%3) == 1 ? r.left : (s->m_scrAlignment%3) == 2 ? r.CenterPoint().x : r.right;
- org.y = s->m_scrAlignment <= 3 ? r.bottom : s->m_scrAlignment <= 6 ? r.CenterPoint().y : r.top;
-
- if (!fOrgOverride) {
- org2 = org;
- }
-
- CPoint p, p2(0, r.top);
-
- POSITION pos;
-
- p = p2;
-
- // Rectangles for inverse clip
- CRect iclipRect[4];
- iclipRect[0] = CRect(0, 0, spd.w, clipRect.top);
- iclipRect[1] = CRect(0, clipRect.top, clipRect.left, clipRect.bottom);
- iclipRect[2] = CRect(clipRect.right, clipRect.top, spd.w, clipRect.bottom);
- iclipRect[3] = CRect(0, clipRect.bottom, spd.w, spd.h);
-
- pos = s->GetHeadPosition();
- while (pos) {
- CLine* l = s->GetNext(pos);
-
- p.x = (s->m_scrAlignment%3) == 1 ? org.x
- : (s->m_scrAlignment%3) == 0 ? org.x - l->m_width
- : org.x - (l->m_width/2);
- if (s->m_clipInverse) {
- bbox2 |= l->PaintShadow(spd, iclipRect[0], pAlphaMask, p, org2, m_time, alpha);
- bbox2 |= l->PaintShadow(spd, iclipRect[1], pAlphaMask, p, org2, m_time, alpha);
- bbox2 |= l->PaintShadow(spd, iclipRect[2], pAlphaMask, p, org2, m_time, alpha);
- bbox2 |= l->PaintShadow(spd, iclipRect[3], pAlphaMask, p, org2, m_time, alpha);
- } else {
- bbox2 |= l->PaintShadow(spd, clipRect, pAlphaMask, p, org2, m_time, alpha);
- }
- p.y += l->m_ascent + l->m_descent;
- }
-
- p = p2;
-
- pos = s->GetHeadPosition();
- while (pos) {
- CLine* l = s->GetNext(pos);
-
- p.x = (s->m_scrAlignment%3) == 1 ? org.x
- : (s->m_scrAlignment%3) == 0 ? org.x - l->m_width
- : org.x - (l->m_width/2);
- if (s->m_clipInverse) {
- bbox2 |= l->PaintOutline(spd, iclipRect[0], pAlphaMask, p, org2, m_time, alpha);
- bbox2 |= l->PaintOutline(spd, iclipRect[1], pAlphaMask, p, org2, m_time, alpha);
- bbox2 |= l->PaintOutline(spd, iclipRect[2], pAlphaMask, p, org2, m_time, alpha);
- bbox2 |= l->PaintOutline(spd, iclipRect[3], pAlphaMask, p, org2, m_time, alpha);
- } else {
- bbox2 |= l->PaintOutline(spd, clipRect, pAlphaMask, p, org2, m_time, alpha);
- }
- p.y += l->m_ascent + l->m_descent;
- }
-
- p = p2;
-
- pos = s->GetHeadPosition();
- while (pos) {
- CLine* l = s->GetNext(pos);
-
- p.x = (s->m_scrAlignment%3) == 1 ? org.x
- : (s->m_scrAlignment%3) == 0 ? org.x - l->m_width
- : org.x - (l->m_width/2);
- if (s->m_clipInverse) {
- bbox2 |= l->PaintBody(spd, iclipRect[0], pAlphaMask, p, org2, m_time, alpha);
- bbox2 |= l->PaintBody(spd, iclipRect[1], pAlphaMask, p, org2, m_time, alpha);
- bbox2 |= l->PaintBody(spd, iclipRect[2], pAlphaMask, p, org2, m_time, alpha);
- bbox2 |= l->PaintBody(spd, iclipRect[3], pAlphaMask, p, org2, m_time, alpha);
- } else {
- bbox2 |= l->PaintBody(spd, clipRect, pAlphaMask, p, org2, m_time, alpha);
- }
- p.y += l->m_ascent + l->m_descent;
- }
- }
-
- bbox = bbox2;
-
- return (subs.GetCount() && !bbox2.IsRectEmpty()) ? S_OK : S_FALSE;
+ if (m_size != CSize(spd.w * 8, spd.h * 8) || m_vidrect != CRect(spd.vidrect.left * 8, spd.vidrect.top * 8, spd.vidrect.right * 8, spd.vidrect.bottom * 8)) {
+ Init(CSize(spd.w, spd.h), spd.vidrect);
+ }
+
+ int t = (int)(rt / 10000);
+
+ int segment;
+ const STSSegment* stss = SearchSubs(t, fps, &segment);
+ if (!stss) {
+ return S_FALSE;
+ }
+
+ // clear any cached subs not in the range of +/-30secs measured from the segment's bounds
+ {
+ POSITION pos = m_subtitleCache.GetStartPosition();
+ while (pos) {
+ int key;
+ CSubtitle* value;
+ m_subtitleCache.GetNextAssoc(pos, key, value);
+
+ STSEntry& stse = GetAt(key);
+ if (stse.end <= (t - 30000) || stse.start > (t + 30000)) {
+ delete value;
+ m_subtitleCache.RemoveKey(key);
+ pos = m_subtitleCache.GetStartPosition();
+ }
+ }
+ }
+
+ m_sla.AdvanceToSegment(segment, stss->subs);
+
+ CAtlArray<LSub> subs;
+
+ for (ptrdiff_t i = 0, j = stss->subs.GetCount(); i < j; i++) {
+ LSub ls;
+ ls.idx = stss->subs[i];
+ ls.layer = GetAt(stss->subs[i]).layer;
+ ls.readorder = GetAt(stss->subs[i]).readorder;
+ subs.Add(ls);
+ }
+
+ qsort(subs.GetData(), subs.GetCount(), sizeof(LSub), lscomp);
+
+ for (ptrdiff_t i = 0, j = subs.GetCount(); i < j; i++) {
+ int entry = subs[i].idx;
+
+ STSEntry stse = GetAt(entry);
+
+ {
+ int start = TranslateStart(entry, fps);
+ m_time = t - start;
+ m_delay = TranslateEnd(entry, fps) - start;
+ }
+
+ CSubtitle* s = GetSubtitle(entry);
+ if (!s) {
+ continue;
+ }
+
+ CRect clipRect = s->m_clip;
+ CRect r = s->m_rect;
+ CSize spaceNeeded = r.Size();
+
+ // apply the effects
+
+ bool fPosOverride = false, fOrgOverride = false;
+
+ int alpha = 0x00;
+
+ CPoint org2;
+
+ BYTE* pAlphaMask = s->m_pClipper ? s->m_pClipper->m_pAlphaMask : NULL;
+
+ for (int k = 0; k < EF_NUMBEROFEFFECTS; k++) {
+ if (!s->m_effects[k]) {
+ continue;
+ }
+
+ switch (k) {
+ case EF_MOVE: { // {\move(x1=param[0], y1=param[1], x2=param[2], y2=param[3], t1=t[0], t2=t[1])}
+ CPoint p;
+ CPoint p1(s->m_effects[k]->param[0], s->m_effects[k]->param[1]);
+ CPoint p2(s->m_effects[k]->param[2], s->m_effects[k]->param[3]);
+ int t1 = s->m_effects[k]->t[0];
+ int t2 = s->m_effects[k]->t[1];
+
+ if (t2 < t1) {
+ int t = t1;
+ t1 = t2;
+ t2 = t;
+ }
+
+ if (t1 <= 0 && t2 <= 0) {
+ t1 = 0;
+ t2 = m_delay;
+ }
+
+ if (m_time <= t1) {
+ p = p1;
+ } else if (p1 == p2) {
+ p = p1;
+ } else if (t1 < m_time && m_time < t2) {
+ double t = 1.0 * (m_time - t1) / (t2 - t1);
+ p.x = (int)((1 - t) * p1.x + t * p2.x);
+ p.y = (int)((1 - t) * p1.y + t * p2.y);
+ } else {
+ p = p2;
+ }
+ r = CRect(
+ CPoint((s->m_scrAlignment % 3) == 1 ? p.x : (s->m_scrAlignment % 3) == 0 ? p.x - spaceNeeded.cx : p.x - (spaceNeeded.cx + 1) / 2,
+ s->m_scrAlignment <= 3 ? p.y - spaceNeeded.cy : s->m_scrAlignment <= 6 ? p.y - (spaceNeeded.cy + 1) / 2 : p.y),
+ spaceNeeded);
+
+ if (s->m_relativeTo == 1) {
+ r.OffsetRect(m_vidrect.TopLeft());
+ }
+ fPosOverride = true;
+ }
+ break;
+ case EF_ORG: { // {\org(x=param[0], y=param[1])}
+ org2 = CPoint(s->m_effects[k]->param[0], s->m_effects[k]->param[1]);
+ fOrgOverride = true;
+ }
+ break;
+ case EF_FADE: { // {\fade(a1=param[0], a2=param[1], a3=param[2], t1=t[0], t2=t[1], t3=t[2], t4=t[3]) or {\fad(t1=t[1], t2=t[2])
+ int t1 = s->m_effects[k]->t[0];
+ int t2 = s->m_effects[k]->t[1];
+ int t3 = s->m_effects[k]->t[2];
+ int t4 = s->m_effects[k]->t[3];
+
+ if (t1 == -1 && t4 == -1) {
+ t1 = 0;
+ t3 = m_delay - t3;
+ t4 = m_delay;
+ }
+
+ if (m_time < t1) {
+ alpha = s->m_effects[k]->param[0];
+ } else if (m_time >= t1 && m_time < t2) {
+ double t = 1.0 * (m_time - t1) / (t2 - t1);
+ alpha = (int)(s->m_effects[k]->param[0] * (1 - t) + s->m_effects[k]->param[1] * t);
+ } else if (m_time >= t2 && m_time < t3) {
+ alpha = s->m_effects[k]->param[1];
+ } else if (m_time >= t3 && m_time < t4) {
+ double t = 1.0 * (m_time - t3) / (t4 - t3);
+ alpha = (int)(s->m_effects[k]->param[1] * (1 - t) + s->m_effects[k]->param[2] * t);
+ } else if (m_time >= t4) {
+ alpha = s->m_effects[k]->param[2];
+ }
+ }
+ break;
+ case EF_BANNER: { // Banner;delay=param[0][;leftoright=param[1];fadeawaywidth=param[2]]
+ int left = s->m_relativeTo == 1 ? m_vidrect.left : 0,
+ right = s->m_relativeTo == 1 ? m_vidrect.right : m_size.cx;
+
+ r.left = !!s->m_effects[k]->param[1]
+ ? (left/*marginRect.left*/ - spaceNeeded.cx) + (int)(m_time * 8.0 / s->m_effects[k]->param[0])
+ : (right /*- marginRect.right*/) - (int)(m_time * 8.0 / s->m_effects[k]->param[0]);
+
+ r.right = r.left + spaceNeeded.cx;
+
+ clipRect &= CRect(left >> 3, clipRect.top, right >> 3, clipRect.bottom);
+
+ fPosOverride = true;
+ }
+ break;
+ case EF_SCROLL: { // Scroll up/down(toptobottom=param[3]);top=param[0];bottom=param[1];delay=param[2][;fadeawayheight=param[4]]
+ r.top = !!s->m_effects[k]->param[3]
+ ? s->m_effects[k]->param[0] + (int)(m_time * 8.0 / s->m_effects[k]->param[2]) - spaceNeeded.cy
+ : s->m_effects[k]->param[1] - (int)(m_time * 8.0 / s->m_effects[k]->param[2]);
+
+ r.bottom = r.top + spaceNeeded.cy;
+
+ CRect cr(0, (s->m_effects[k]->param[0] + 4) >> 3, spd.w, (s->m_effects[k]->param[1] + 4) >> 3);
+
+ if (s->m_relativeTo == 1)
+ r.top += m_vidrect.top,
+ r.bottom += m_vidrect.top,
+ cr.top += m_vidrect.top >> 3,
+ cr.bottom += m_vidrect.top >> 3;
+
+ clipRect &= cr;
+
+ fPosOverride = true;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (!fPosOverride && !fOrgOverride && !s->m_fAnimated) {
+ r = m_sla.AllocRect(s, segment, entry, stse.layer, m_collisions);
+ }
+
+ CPoint org;
+ org.x = (s->m_scrAlignment % 3) == 1 ? r.left : (s->m_scrAlignment % 3) == 2 ? r.CenterPoint().x : r.right;
+ org.y = s->m_scrAlignment <= 3 ? r.bottom : s->m_scrAlignment <= 6 ? r.CenterPoint().y : r.top;
+
+ if (!fOrgOverride) {
+ org2 = org;
+ }
+
+ CPoint p, p2(0, r.top);
+
+ POSITION pos;
+
+ p = p2;
+
+ // Rectangles for inverse clip
+ CRect iclipRect[4];
+ iclipRect[0] = CRect(0, 0, spd.w, clipRect.top);
+ iclipRect[1] = CRect(0, clipRect.top, clipRect.left, clipRect.bottom);
+ iclipRect[2] = CRect(clipRect.right, clipRect.top, spd.w, clipRect.bottom);
+ iclipRect[3] = CRect(0, clipRect.bottom, spd.w, spd.h);
+
+ pos = s->GetHeadPosition();
+ while (pos) {
+ CLine* l = s->GetNext(pos);
+
+ p.x = (s->m_scrAlignment % 3) == 1 ? org.x
+ : (s->m_scrAlignment % 3) == 0 ? org.x - l->m_width
+ : org.x - (l->m_width / 2);
+ if (s->m_clipInverse) {
+ bbox2 |= l->PaintShadow(spd, iclipRect[0], pAlphaMask, p, org2, m_time, alpha);
+ bbox2 |= l->PaintShadow(spd, iclipRect[1], pAlphaMask, p, org2, m_time, alpha);
+ bbox2 |= l->PaintShadow(spd, iclipRect[2], pAlphaMask, p, org2, m_time, alpha);
+ bbox2 |= l->PaintShadow(spd, iclipRect[3], pAlphaMask, p, org2, m_time, alpha);
+ } else {
+ bbox2 |= l->PaintShadow(spd, clipRect, pAlphaMask, p, org2, m_time, alpha);
+ }
+ p.y += l->m_ascent + l->m_descent;
+ }
+
+ p = p2;
+
+ pos = s->GetHeadPosition();
+ while (pos) {
+ CLine* l = s->GetNext(pos);
+
+ p.x = (s->m_scrAlignment % 3) == 1 ? org.x
+ : (s->m_scrAlignment % 3) == 0 ? org.x - l->m_width
+ : org.x - (l->m_width / 2);
+ if (s->m_clipInverse) {
+ bbox2 |= l->PaintOutline(spd, iclipRect[0], pAlphaMask, p, org2, m_time, alpha);
+ bbox2 |= l->PaintOutline(spd, iclipRect[1], pAlphaMask, p, org2, m_time, alpha);
+ bbox2 |= l->PaintOutline(spd, iclipRect[2], pAlphaMask, p, org2, m_time, alpha);
+ bbox2 |= l->PaintOutline(spd, iclipRect[3], pAlphaMask, p, org2, m_time, alpha);
+ } else {
+ bbox2 |= l->PaintOutline(spd, clipRect, pAlphaMask, p, org2, m_time, alpha);
+ }
+ p.y += l->m_ascent + l->m_descent;
+ }
+
+ p = p2;
+
+ pos = s->GetHeadPosition();
+ while (pos) {
+ CLine* l = s->GetNext(pos);
+
+ p.x = (s->m_scrAlignment % 3) == 1 ? org.x
+ : (s->m_scrAlignment % 3) == 0 ? org.x - l->m_width
+ : org.x - (l->m_width / 2);
+ if (s->m_clipInverse) {
+ bbox2 |= l->PaintBody(spd, iclipRect[0], pAlphaMask, p, org2, m_time, alpha);
+ bbox2 |= l->PaintBody(spd, iclipRect[1], pAlphaMask, p, org2, m_time, alpha);
+ bbox2 |= l->PaintBody(spd, iclipRect[2], pAlphaMask, p, org2, m_time, alpha);
+ bbox2 |= l->PaintBody(spd, iclipRect[3], pAlphaMask, p, org2, m_time, alpha);
+ } else {
+ bbox2 |= l->PaintBody(spd, clipRect, pAlphaMask, p, org2, m_time, alpha);
+ }
+ p.y += l->m_ascent + l->m_descent;
+ }
+ }
+
+ bbox = bbox2;
+
+ return (subs.GetCount() && !bbox2.IsRectEmpty()) ? S_OK : S_FALSE;
}
// IPersist
STDMETHODIMP CRenderedTextSubtitle::GetClassID(CLSID* pClassID)
{
- return pClassID ? *pClassID = __uuidof(this), S_OK : E_POINTER;
+ return pClassID ? *pClassID = __uuidof(this), S_OK : E_POINTER;
}
// ISubStream
STDMETHODIMP_(int) CRenderedTextSubtitle::GetStreamCount()
{
- return 1;
+ return 1;
}
STDMETHODIMP CRenderedTextSubtitle::GetStreamInfo(int iStream, WCHAR** ppName, LCID* pLCID)
{
- if (iStream != 0) {
- return E_INVALIDARG;
- }
+ if (iStream != 0) {
+ return E_INVALIDARG;
+ }
- if (ppName) {
- *ppName = (WCHAR*)CoTaskMemAlloc((m_name.GetLength()+1)*sizeof(WCHAR));
- if (!(*ppName)) {
- return E_OUTOFMEMORY;
- }
+ if (ppName) {
+ *ppName = (WCHAR*)CoTaskMemAlloc((m_name.GetLength() + 1) * sizeof(WCHAR));
+ if (!(*ppName)) {
+ return E_OUTOFMEMORY;
+ }
- wcscpy_s(*ppName, m_name.GetLength() + 1, CStringW(m_name));
+ wcscpy_s(*ppName, m_name.GetLength() + 1, CStringW(m_name));
- if (pLCID) {
- *pLCID = ISO6391ToLcid(CW2A(*ppName));
- if (*pLCID == 0) {
- *pLCID = ISO6392ToLcid(CW2A(*ppName));
- }
- }
- }
+ if (pLCID) {
+ *pLCID = ISO6391ToLcid(CW2A(*ppName));
+ if (*pLCID == 0) {
+ *pLCID = ISO6392ToLcid(CW2A(*ppName));
+ }
+ }
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP_(int) CRenderedTextSubtitle::GetStream()
{
- return 0;
+ return 0;
}
STDMETHODIMP CRenderedTextSubtitle::SetStream(int iStream)
{
- return iStream == 0 ? S_OK : E_FAIL;
+ return iStream == 0 ? S_OK : E_FAIL;
}
STDMETHODIMP CRenderedTextSubtitle::Reload()
{
- CFileStatus s;
- if (!CFile::GetStatus(m_path, s)) {
- return E_FAIL;
- }
- return !m_path.IsEmpty() && Open(m_path, DEFAULT_CHARSET) ? S_OK : E_FAIL;
+ CFileStatus s;
+ if (!CFile::GetStatus(m_path, s)) {
+ return E_FAIL;
+ }
+ return !m_path.IsEmpty() && Open(m_path, DEFAULT_CHARSET) ? S_OK : E_FAIL;
}
diff --git a/src/Subtitles/RTS.h b/src/Subtitles/RTS.h
index 3c943b42c..8787f667d 100644
--- a/src/Subtitles/RTS.h
+++ b/src/Subtitles/RTS.h
@@ -30,121 +30,121 @@
class CMyFont : public CFont
{
public:
- int m_ascent, m_descent;
+ int m_ascent, m_descent;
- CMyFont(STSStyle& style);
+ CMyFont(STSStyle& style);
};
class CPolygon;
class CWord : public Rasterizer
{
- bool m_fDrawn;
- CPoint m_p;
+ bool m_fDrawn;
+ CPoint m_p;
- void Transform(CPoint org);
+ void Transform(CPoint org);
- void Transform_C( CPoint &org );
- void Transform_SSE2( CPoint &org );
- bool CreateOpaqueBox();
+ void Transform_C(CPoint& org);
+ void Transform_SSE2(CPoint& org);
+ bool CreateOpaqueBox();
protected:
- CStringW m_str;
+ CStringW m_str;
- virtual bool CreatePath() = 0;
+ virtual bool CreatePath() = 0;
public:
- bool m_fWhiteSpaceChar, m_fLineBreak;
+ bool m_fWhiteSpaceChar, m_fLineBreak;
- STSStyle m_style;
+ STSStyle m_style;
- CPolygon* m_pOpaqueBox;
+ CPolygon* m_pOpaqueBox;
- int m_ktype, m_kstart, m_kend;
+ int m_ktype, m_kstart, m_kend;
- int m_width, m_ascent, m_descent;
+ int m_width, m_ascent, m_descent;
- CWord(STSStyle& style, CStringW str, int ktype, int kstart, int kend); // str[0] = 0 -> m_fLineBreak = true (in this case we only need and use the height of m_font from the whole class)
- virtual ~CWord();
+ CWord(STSStyle& style, CStringW str, int ktype, int kstart, int kend); // str[0] = 0 -> m_fLineBreak = true (in this case we only need and use the height of m_font from the whole class)
+ virtual ~CWord();
- virtual CWord* Copy() = 0;
- virtual bool Append(CWord* w);
+ virtual CWord* Copy() = 0;
+ virtual bool Append(CWord* w);
- void Paint(CPoint p, CPoint org);
+ void Paint(CPoint p, CPoint org);
};
class CText : public CWord
{
protected:
- virtual bool CreatePath();
+ virtual bool CreatePath();
public:
- CText(STSStyle& style, CStringW str, int ktype, int kstart, int kend);
+ CText(STSStyle& style, CStringW str, int ktype, int kstart, int kend);
- virtual CWord* Copy();
- virtual bool Append(CWord* w);
+ virtual CWord* Copy();
+ virtual bool Append(CWord* w);
};
class CPolygon : public CWord
{
- bool GetLONG(CStringW& str, LONG& ret);
- bool GetPOINT(CStringW& str, POINT& ret);
- bool ParseStr();
+ bool GetLONG(CStringW& str, LONG& ret);
+ bool GetPOINT(CStringW& str, POINT& ret);
+ bool ParseStr();
protected:
- double m_scalex, m_scaley;
- int m_baseline;
+ double m_scalex, m_scaley;
+ int m_baseline;
- CAtlArray<BYTE> m_pathTypesOrg;
- CAtlArray<CPoint> m_pathPointsOrg;
+ CAtlArray<BYTE> m_pathTypesOrg;
+ CAtlArray<CPoint> m_pathPointsOrg;
- virtual bool CreatePath();
+ virtual bool CreatePath();
public:
- CPolygon(STSStyle& style, CStringW str, int ktype, int kstart, int kend, double scalex, double scaley, int baseline);
- CPolygon(CPolygon&); // can't use a const reference because we need to use CAtlArray::Copy which expects a non-const reference
- virtual ~CPolygon();
+ CPolygon(STSStyle& style, CStringW str, int ktype, int kstart, int kend, double scalex, double scaley, int baseline);
+ CPolygon(CPolygon&); // can't use a const reference because we need to use CAtlArray::Copy which expects a non-const reference
+ virtual ~CPolygon();
- virtual CWord* Copy();
- virtual bool Append(CWord* w);
+ virtual CWord* Copy();
+ virtual bool Append(CWord* w);
};
class CClipper : public CPolygon
{
private:
- CWord* Copy();
- virtual bool Append(CWord* w);
+ CWord* Copy();
+ virtual bool Append(CWord* w);
public:
- CClipper(CStringW str, CSize size, double scalex, double scaley, bool inverse, CPoint cpOffset);
- virtual ~CClipper();
+ CClipper(CStringW str, CSize size, double scalex, double scaley, bool inverse, CPoint cpOffset);
+ virtual ~CClipper();
- CSize m_size;
- bool m_inverse;
- CPoint m_cpOffset;
- BYTE* m_pAlphaMask;
+ CSize m_size;
+ bool m_inverse;
+ CPoint m_cpOffset;
+ BYTE* m_pAlphaMask;
};
class CLine : public CAtlList<CWord*>
{
public:
- int m_width, m_ascent, m_descent, m_borderX, m_borderY;
+ int m_width, m_ascent, m_descent, m_borderX, m_borderY;
- virtual ~CLine();
+ virtual ~CLine();
- void Compact();
+ void Compact();
- CRect PaintShadow(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoint p, CPoint org, int time, int alpha);
- CRect PaintOutline(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoint p, CPoint org, int time, int alpha);
- CRect PaintBody(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoint p, CPoint org, int time, int alpha);
+ CRect PaintShadow(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoint p, CPoint org, int time, int alpha);
+ CRect PaintOutline(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoint p, CPoint org, int time, int alpha);
+ CRect PaintBody(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoint p, CPoint org, int time, int alpha);
};
enum eftype {
- EF_MOVE = 0, // {\move(x1=param[0], y1=param[1], x2=param[2], y2=param[3], t1=t[0], t2=t[1])} or {\pos(x=param[0], y=param[1])}
- EF_ORG, // {\org(x=param[0], y=param[1])}
- EF_FADE, // {\fade(a1=param[0], a2=param[1], a3=param[2], t1=t[0], t2=t[1], t3=t[2], t4=t[3])} or {\fad(t1=t[1], t2=t[2])
- EF_BANNER, // Banner;delay=param[0][;lefttoright=param[1];fadeawaywidth=param[2]]
- EF_SCROLL, // Scroll up/down=param[3];top=param[0];bottom=param[1];delay=param[2][;fadeawayheight=param[4]]
+ EF_MOVE = 0, // {\move(x1=param[0], y1=param[1], x2=param[2], y2=param[3], t1=t[0], t2=t[1])} or {\pos(x=param[0], y=param[1])}
+ EF_ORG, // {\org(x=param[0], y=param[1])}
+ EF_FADE, // {\fade(a1=param[0], a2=param[1], a3=param[2], t1=t[0], t2=t[1], t3=t[2], t4=t[3])} or {\fad(t1=t[1], t2=t[2])
+ EF_BANNER, // Banner;delay=param[0][;lefttoright=param[1];fadeawaywidth=param[2]]
+ EF_SCROLL, // Scroll up/down=param[3];top=param[0];bottom=param[1];delay=param[2][;fadeawayheight=param[4]]
};
#define EF_NUMBEROFEFFECTS 5
@@ -152,134 +152,134 @@ enum eftype {
class Effect
{
public:
- enum eftype type;
- int param[9];
- int t[4];
+ enum eftype type;
+ int param[9];
+ int t[4];
};
class CSubtitle : public CAtlList<CLine*>
{
- int GetFullWidth();
- int GetFullLineWidth(POSITION pos);
- int GetWrapWidth(POSITION pos, int maxwidth);
- CLine* GetNextLine(POSITION& pos, int maxwidth);
+ int GetFullWidth();
+ int GetFullLineWidth(POSITION pos);
+ int GetWrapWidth(POSITION pos, int maxwidth);
+ CLine* GetNextLine(POSITION& pos, int maxwidth);
public:
- int m_scrAlignment;
- int m_wrapStyle;
- bool m_fAnimated;
- int m_relativeTo;
+ int m_scrAlignment;
+ int m_wrapStyle;
+ bool m_fAnimated;
+ int m_relativeTo;
- Effect* m_effects[EF_NUMBEROFEFFECTS];
+ Effect* m_effects[EF_NUMBEROFEFFECTS];
- CAtlList<CWord*> m_words;
+ CAtlList<CWord*> m_words;
- CClipper* m_pClipper;
+ CClipper* m_pClipper;
- CRect m_rect, m_clip;
- int m_topborder, m_bottomborder;
- bool m_clipInverse;
+ CRect m_rect, m_clip;
+ int m_topborder, m_bottomborder;
+ bool m_clipInverse;
- double m_scalex, m_scaley;
+ double m_scalex, m_scaley;
public:
- CSubtitle();
- virtual ~CSubtitle();
- virtual void Empty();
- void EmptyEffects();
+ CSubtitle();
+ virtual ~CSubtitle();
+ virtual void Empty();
+ void EmptyEffects();
- void CreateClippers(CSize size);
+ void CreateClippers(CSize size);
- void MakeLines(CSize size, CRect marginRect);
+ void MakeLines(CSize size, CRect marginRect);
};
class CScreenLayoutAllocator
{
- typedef struct {
- CRect r;
- int segment, entry, layer;
- } SubRect;
+ typedef struct {
+ CRect r;
+ int segment, entry, layer;
+ } SubRect;
- CAtlList<SubRect> m_subrects;
+ CAtlList<SubRect> m_subrects;
public:
- /*virtual*/
- void Empty();
+ /*virtual*/
+ void Empty();
- void AdvanceToSegment(int segment, const CAtlArray<int>& sa);
- CRect AllocRect(CSubtitle* s, int segment, int entry, int layer, int collisions);
+ void AdvanceToSegment(int segment, const CAtlArray<int>& sa);
+ CRect AllocRect(CSubtitle* s, int segment, int entry, int layer, int collisions);
};
class __declspec(uuid("537DCACA-2812-4a4f-B2C6-1A34C17ADEB0"))
- CRenderedTextSubtitle : public CSimpleTextSubtitle, public CSubPicProviderImpl, public ISubStream
+ CRenderedTextSubtitle : public CSimpleTextSubtitle, public CSubPicProviderImpl, public ISubStream
{
- CAtlMap<int, CSubtitle*> m_subtitleCache;
+ CAtlMap<int, CSubtitle*> m_subtitleCache;
- CScreenLayoutAllocator m_sla;
+ CScreenLayoutAllocator m_sla;
- CSize m_size;
- CRect m_vidrect;
+ CSize m_size;
+ CRect m_vidrect;
- // temp variables, used when parsing the script
- int m_time, m_delay;
- int m_animStart, m_animEnd;
- double m_animAccel;
- int m_ktype, m_kstart, m_kend;
- int m_nPolygon;
- int m_polygonBaselineOffset;
- STSStyle *m_pStyleOverride; // the app can decide to use this style instead of a built-in one
- bool m_doOverrideStyle;
+ // temp variables, used when parsing the script
+ int m_time, m_delay;
+ int m_animStart, m_animEnd;
+ double m_animAccel;
+ int m_ktype, m_kstart, m_kend;
+ int m_nPolygon;
+ int m_polygonBaselineOffset;
+ STSStyle* m_pStyleOverride; // the app can decide to use this style instead of a built-in one
+ bool m_doOverrideStyle;
- void ParseEffect(CSubtitle* sub, CString str);
- void ParseString(CSubtitle* sub, CStringW str, STSStyle& style);
- void ParsePolygon(CSubtitle* sub, CStringW str, STSStyle& style);
- bool ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& style, STSStyle& org, bool fAnimate = false);
- bool ParseHtmlTag(CSubtitle* sub, CStringW str, STSStyle& style, STSStyle& org);
+ void ParseEffect(CSubtitle* sub, CString str);
+ void ParseString(CSubtitle* sub, CStringW str, STSStyle& style);
+ void ParsePolygon(CSubtitle* sub, CStringW str, STSStyle& style);
+ bool ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& style, STSStyle& org, bool fAnimate = false);
+ bool ParseHtmlTag(CSubtitle* sub, CStringW str, STSStyle& style, STSStyle& org);
- double CalcAnimation(double dst, double src, bool fAnimate);
+ double CalcAnimation(double dst, double src, bool fAnimate);
- CSubtitle* GetSubtitle(int entry);
+ CSubtitle* GetSubtitle(int entry);
protected:
- virtual void OnChanged();
+ virtual void OnChanged();
public:
- CRenderedTextSubtitle(CCritSec* pLock, STSStyle *styleOverride = NULL, bool doOverride = false);
- virtual ~CRenderedTextSubtitle();
+ CRenderedTextSubtitle(CCritSec* pLock, STSStyle* styleOverride = NULL, bool doOverride = false);
+ virtual ~CRenderedTextSubtitle();
- virtual void Copy(CSimpleTextSubtitle& sts);
- virtual void Empty();
+ virtual void Copy(CSimpleTextSubtitle& sts);
+ virtual void Empty();
- // call to signal this RTS to ignore any of the styles and apply the given override style
- void SetOverride(bool doOverride = true, STSStyle *styleOverride = NULL) {
- m_doOverrideStyle = doOverride;
- if (styleOverride != NULL) {
- m_pStyleOverride = styleOverride;
- }
- }
+ // call to signal this RTS to ignore any of the styles and apply the given override style
+ void SetOverride(bool doOverride = true, STSStyle* styleOverride = NULL) {
+ m_doOverrideStyle = doOverride;
+ if (styleOverride != NULL) {
+ m_pStyleOverride = styleOverride;
+ }
+ }
public:
- bool Init(CSize size, CRect vidrect); // will call Deinit()
- void Deinit();
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // ISubPicProvider
- STDMETHODIMP_(POSITION) GetStartPosition(REFERENCE_TIME rt, double fps);
- STDMETHODIMP_(POSITION) GetNext(POSITION pos);
- STDMETHODIMP_(REFERENCE_TIME) GetStart(POSITION pos, double fps);
- STDMETHODIMP_(REFERENCE_TIME) GetStop(POSITION pos, double fps);
- STDMETHODIMP_(bool) IsAnimated(POSITION pos);
- STDMETHODIMP Render(SubPicDesc& spd, REFERENCE_TIME rt, double fps, RECT& bbox);
-
- // IPersist
- STDMETHODIMP GetClassID(CLSID* pClassID);
-
- // ISubStream
- STDMETHODIMP_(int) GetStreamCount();
- STDMETHODIMP GetStreamInfo(int i, WCHAR** ppName, LCID* pLCID);
- STDMETHODIMP_(int) GetStream();
- STDMETHODIMP SetStream(int iStream);
- STDMETHODIMP Reload();
+ bool Init(CSize size, CRect vidrect); // will call Deinit()
+ void Deinit();
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ // ISubPicProvider
+ STDMETHODIMP_(POSITION) GetStartPosition(REFERENCE_TIME rt, double fps);
+ STDMETHODIMP_(POSITION) GetNext(POSITION pos);
+ STDMETHODIMP_(REFERENCE_TIME) GetStart(POSITION pos, double fps);
+ STDMETHODIMP_(REFERENCE_TIME) GetStop(POSITION pos, double fps);
+ STDMETHODIMP_(bool) IsAnimated(POSITION pos);
+ STDMETHODIMP Render(SubPicDesc& spd, REFERENCE_TIME rt, double fps, RECT& bbox);
+
+ // IPersist
+ STDMETHODIMP GetClassID(CLSID* pClassID);
+
+ // ISubStream
+ STDMETHODIMP_(int) GetStreamCount();
+ STDMETHODIMP GetStreamInfo(int i, WCHAR** ppName, LCID* pLCID);
+ STDMETHODIMP_(int) GetStream();
+ STDMETHODIMP SetStream(int iStream);
+ STDMETHODIMP Reload();
};
diff --git a/src/Subtitles/Rasterizer.cpp b/src/Subtitles/Rasterizer.cpp
index 32d54e32a..f6e727c5d 100644
--- a/src/Subtitles/Rasterizer.cpp
+++ b/src/Subtitles/Rasterizer.cpp
@@ -33,8 +33,8 @@
#include "SeparableFilter.h"
#include "../DSUtil/vd.h" // For CPUID usage in Rasterizer::Draw
-#ifndef _MAX /* avoid collision with common (nonconforming) macros */
-#define _MAX (std::max)
+#ifndef _MAX /* avoid collision with common (nonconforming) macros */
+#define _MAX (std::max)
#endif
// Statics constants for use by alpha_blend_sse2
@@ -49,1002 +49,1002 @@ static __m128i zero = _mm_setzero_si128();
int Rasterizer::getOverlayWidth()
{
- return mOverlayWidth*8;
+ return mOverlayWidth * 8;
}
Rasterizer::Rasterizer() : mpPathTypes(NULL), mpPathPoints(NULL), mPathPoints(0), mpOverlayBuffer(NULL)
{
- mOverlayWidth = mOverlayHeight = 0;
- mPathOffsetX = mPathOffsetY = 0;
- mOffsetX = mOffsetY = 0;
+ mOverlayWidth = mOverlayHeight = 0;
+ mPathOffsetX = mPathOffsetY = 0;
+ mOffsetX = mOffsetY = 0;
}
Rasterizer::~Rasterizer()
{
- _TrashPath();
- _TrashOverlay();
+ _TrashPath();
+ _TrashOverlay();
}
void Rasterizer::_TrashPath()
{
- delete [] mpPathTypes;
- delete [] mpPathPoints;
- mpPathTypes = NULL;
- mpPathPoints = NULL;
- mPathPoints = 0;
+ delete [] mpPathTypes;
+ delete [] mpPathPoints;
+ mpPathTypes = NULL;
+ mpPathPoints = NULL;
+ mPathPoints = 0;
}
void Rasterizer::_TrashOverlay()
{
- if (mpOverlayBuffer) {
- _aligned_free(mpOverlayBuffer);
- }
- mpOverlayBuffer = NULL;
+ if (mpOverlayBuffer) {
+ _aligned_free(mpOverlayBuffer);
+ }
+ mpOverlayBuffer = NULL;
}
void Rasterizer::_ReallocEdgeBuffer(int edges)
{
- mEdgeHeapSize = edges;
- mpEdgeBuffer = (Edge*)realloc(mpEdgeBuffer, sizeof(Edge)*edges);
+ mEdgeHeapSize = edges;
+ mpEdgeBuffer = (Edge*)realloc(mpEdgeBuffer, sizeof(Edge) * edges);
}
void Rasterizer::_EvaluateBezier(int ptbase, bool fBSpline)
{
- const POINT* pt0 = mpPathPoints + ptbase;
- const POINT* pt1 = mpPathPoints + ptbase + 1;
- const POINT* pt2 = mpPathPoints + ptbase + 2;
- const POINT* pt3 = mpPathPoints + ptbase + 3;
-
- double x0 = pt0->x;
- double x1 = pt1->x;
- double x2 = pt2->x;
- double x3 = pt3->x;
- double y0 = pt0->y;
- double y1 = pt1->y;
- double y2 = pt2->y;
- double y3 = pt3->y;
-
- double cx3, cx2, cx1, cx0, cy3, cy2, cy1, cy0;
-
- if (fBSpline) {
- // 1 [-1 +3 -3 +1]
- // - * [+3 -6 +3 0]
- // 6 [-3 0 +3 0]
- // [+1 +4 +1 0]
-
- double _1div6 = 1.0/6.0;
-
- cx3 = _1div6*(- x0+3*x1-3*x2+x3);
- cx2 = _1div6*( 3*x0-6*x1+3*x2);
- cx1 = _1div6*(-3*x0 +3*x2);
- cx0 = _1div6*( x0+4*x1+1*x2);
-
- cy3 = _1div6*(- y0+3*y1-3*y2+y3);
- cy2 = _1div6*( 3*y0-6*y1+3*y2);
- cy1 = _1div6*(-3*y0 +3*y2);
- cy0 = _1div6*( y0+4*y1+1*y2);
- } else { // bezier
- // [-1 +3 -3 +1]
- // [+3 -6 +3 0]
- // [-3 +3 0 0]
- // [+1 0 0 0]
-
- cx3 = - x0+3*x1-3*x2+x3;
- cx2 = 3*x0-6*x1+3*x2;
- cx1 = -3*x0+3*x1;
- cx0 = x0;
-
- cy3 = - y0+3*y1-3*y2+y3;
- cy2 = 3*y0-6*y1+3*y2;
- cy1 = -3*y0+3*y1;
- cy0 = y0;
- }
-
- //
- // This equation is from Graphics Gems I.
- //
- // The idea is that since we're approximating a cubic curve with lines,
- // any error we incur is due to the curvature of the line, which we can
- // estimate by calculating the maximum acceleration of the curve. For
- // a cubic, the acceleration (second derivative) is a line, meaning that
- // the absolute maximum acceleration must occur at either the beginning
- // (|c2|) or the end (|c2+c3|). Our bounds here are a little more
- // conservative than that, but that's okay.
- //
- // If the acceleration of the parametric formula is zero (c2 = c3 = 0),
- // that component of the curve is linear and does not incur any error.
- // If a=0 for both X and Y, the curve is a line segment and we can
- // use a step size of 1.
-
- double maxaccel1 = fabs(2*cy2) + fabs(6*cy3);
- double maxaccel2 = fabs(2*cx2) + fabs(6*cx3);
-
- double maxaccel = maxaccel1 > maxaccel2 ? maxaccel1 : maxaccel2;
- double h = 1.0;
-
- if (maxaccel > 8.0) {
- h = sqrt(8.0 / maxaccel);
- }
-
- if (!fFirstSet) {
- firstp.x = (LONG)cx0;
- firstp.y = (LONG)cy0;
- lastp = firstp;
- fFirstSet = true;
- }
-
- for (double t = 0; t < 1.0; t += h) {
- double x = cx0 + t*(cx1 + t*(cx2 + t*cx3));
- double y = cy0 + t*(cy1 + t*(cy2 + t*cy3));
- _EvaluateLine(lastp.x, lastp.y, (int)x, (int)y);
- }
-
- double x = cx0 + cx1 + cx2 + cx3;
- double y = cy0 + cy1 + cy2 + cy3;
- _EvaluateLine(lastp.x, lastp.y, (int)x, (int)y);
+ const POINT* pt0 = mpPathPoints + ptbase;
+ const POINT* pt1 = mpPathPoints + ptbase + 1;
+ const POINT* pt2 = mpPathPoints + ptbase + 2;
+ const POINT* pt3 = mpPathPoints + ptbase + 3;
+
+ double x0 = pt0->x;
+ double x1 = pt1->x;
+ double x2 = pt2->x;
+ double x3 = pt3->x;
+ double y0 = pt0->y;
+ double y1 = pt1->y;
+ double y2 = pt2->y;
+ double y3 = pt3->y;
+
+ double cx3, cx2, cx1, cx0, cy3, cy2, cy1, cy0;
+
+ if (fBSpline) {
+ // 1 [-1 +3 -3 +1]
+ // - * [+3 -6 +3 0]
+ // 6 [-3 0 +3 0]
+ // [+1 +4 +1 0]
+
+ double _1div6 = 1.0 / 6.0;
+
+ cx3 = _1div6 * (- x0 + 3 * x1 - 3 * x2 + x3);
+ cx2 = _1div6 * (3 * x0 - 6 * x1 + 3 * x2);
+ cx1 = _1div6 * (-3 * x0 + 3 * x2);
+ cx0 = _1div6 * (x0 + 4 * x1 + 1 * x2);
+
+ cy3 = _1div6 * (- y0 + 3 * y1 - 3 * y2 + y3);
+ cy2 = _1div6 * (3 * y0 - 6 * y1 + 3 * y2);
+ cy1 = _1div6 * (-3 * y0 + 3 * y2);
+ cy0 = _1div6 * (y0 + 4 * y1 + 1 * y2);
+ } else { // bezier
+ // [-1 +3 -3 +1]
+ // [+3 -6 +3 0]
+ // [-3 +3 0 0]
+ // [+1 0 0 0]
+
+ cx3 = - x0 + 3 * x1 - 3 * x2 + x3;
+ cx2 = 3 * x0 - 6 * x1 + 3 * x2;
+ cx1 = -3 * x0 + 3 * x1;
+ cx0 = x0;
+
+ cy3 = - y0 + 3 * y1 - 3 * y2 + y3;
+ cy2 = 3 * y0 - 6 * y1 + 3 * y2;
+ cy1 = -3 * y0 + 3 * y1;
+ cy0 = y0;
+ }
+
+ //
+ // This equation is from Graphics Gems I.
+ //
+ // The idea is that since we're approximating a cubic curve with lines,
+ // any error we incur is due to the curvature of the line, which we can
+ // estimate by calculating the maximum acceleration of the curve. For
+ // a cubic, the acceleration (second derivative) is a line, meaning that
+ // the absolute maximum acceleration must occur at either the beginning
+ // (|c2|) or the end (|c2+c3|). Our bounds here are a little more
+ // conservative than that, but that's okay.
+ //
+ // If the acceleration of the parametric formula is zero (c2 = c3 = 0),
+ // that component of the curve is linear and does not incur any error.
+ // If a=0 for both X and Y, the curve is a line segment and we can
+ // use a step size of 1.
+
+ double maxaccel1 = fabs(2 * cy2) + fabs(6 * cy3);
+ double maxaccel2 = fabs(2 * cx2) + fabs(6 * cx3);
+
+ double maxaccel = maxaccel1 > maxaccel2 ? maxaccel1 : maxaccel2;
+ double h = 1.0;
+
+ if (maxaccel > 8.0) {
+ h = sqrt(8.0 / maxaccel);
+ }
+
+ if (!fFirstSet) {
+ firstp.x = (LONG)cx0;
+ firstp.y = (LONG)cy0;
+ lastp = firstp;
+ fFirstSet = true;
+ }
+
+ for (double t = 0; t < 1.0; t += h) {
+ double x = cx0 + t * (cx1 + t * (cx2 + t * cx3));
+ double y = cy0 + t * (cy1 + t * (cy2 + t * cy3));
+ _EvaluateLine(lastp.x, lastp.y, (int)x, (int)y);
+ }
+
+ double x = cx0 + cx1 + cx2 + cx3;
+ double y = cy0 + cy1 + cy2 + cy3;
+ _EvaluateLine(lastp.x, lastp.y, (int)x, (int)y);
}
void Rasterizer::_EvaluateLine(int pt1idx, int pt2idx)
{
- const POINT* pt1 = mpPathPoints + pt1idx;
- const POINT* pt2 = mpPathPoints + pt2idx;
+ const POINT* pt1 = mpPathPoints + pt1idx;
+ const POINT* pt2 = mpPathPoints + pt2idx;
- _EvaluateLine(pt1->x, pt1->y, pt2->x, pt2->y);
+ _EvaluateLine(pt1->x, pt1->y, pt2->x, pt2->y);
}
void Rasterizer::_EvaluateLine(int x0, int y0, int x1, int y1)
{
- if (lastp.x != x0 || lastp.y != y0) {
- _EvaluateLine(lastp.x, lastp.y, x0, y0);
- }
+ if (lastp.x != x0 || lastp.y != y0) {
+ _EvaluateLine(lastp.x, lastp.y, x0, y0);
+ }
- if (!fFirstSet) {
- firstp.x = x0;
- firstp.y = y0;
- fFirstSet = true;
- }
- lastp.x = x1;
- lastp.y = y1;
+ if (!fFirstSet) {
+ firstp.x = x0;
+ firstp.y = y0;
+ fFirstSet = true;
+ }
+ lastp.x = x1;
+ lastp.y = y1;
- if (y1 > y0) { // down
- __int64 xacc = (__int64)x0 << 13;
+ if (y1 > y0) { // down
+ __int64 xacc = (__int64)x0 << 13;
- // prestep y0 down
+ // prestep y0 down
- int dy = y1 - y0;
- int y = ((y0 + 3)&~7) + 4;
- int iy = y >> 3;
+ int dy = y1 - y0;
+ int y = ((y0 + 3)&~7) + 4;
+ int iy = y >> 3;
- y1 = (y1 - 5) >> 3;
+ y1 = (y1 - 5) >> 3;
- if (iy <= y1) {
- __int64 invslope = (__int64(x1 - x0) << 16) / dy;
+ if (iy <= y1) {
+ __int64 invslope = (__int64(x1 - x0) << 16) / dy;
- while (mEdgeNext + y1 + 1 - iy > mEdgeHeapSize) {
- _ReallocEdgeBuffer(mEdgeHeapSize*2);
- }
+ while (mEdgeNext + y1 + 1 - iy > mEdgeHeapSize) {
+ _ReallocEdgeBuffer(mEdgeHeapSize * 2);
+ }
- xacc += (invslope * (y - y0)) >> 3;
+ xacc += (invslope * (y - y0)) >> 3;
- while (iy <= y1) {
- int ix = (int)((xacc + 32768) >> 16);
+ while (iy <= y1) {
+ int ix = (int)((xacc + 32768) >> 16);
- mpEdgeBuffer[mEdgeNext].next = mpScanBuffer[iy];
- mpEdgeBuffer[mEdgeNext].posandflag = ix*2 + 1;
+ mpEdgeBuffer[mEdgeNext].next = mpScanBuffer[iy];
+ mpEdgeBuffer[mEdgeNext].posandflag = ix * 2 + 1;
- mpScanBuffer[iy] = mEdgeNext++;
+ mpScanBuffer[iy] = mEdgeNext++;
- ++iy;
- xacc += invslope;
- }
- }
- } else if (y1 < y0) { // up
- __int64 xacc = (__int64)x1 << 13;
+ ++iy;
+ xacc += invslope;
+ }
+ }
+ } else if (y1 < y0) { // up
+ __int64 xacc = (__int64)x1 << 13;
- // prestep y1 down
+ // prestep y1 down
- int dy = y0 - y1;
- int y = ((y1 + 3)&~7) + 4;
- int iy = y >> 3;
+ int dy = y0 - y1;
+ int y = ((y1 + 3)&~7) + 4;
+ int iy = y >> 3;
- y0 = (y0 - 5) >> 3;
+ y0 = (y0 - 5) >> 3;
- if (iy <= y0) {
- __int64 invslope = (__int64(x0 - x1) << 16) / dy;
+ if (iy <= y0) {
+ __int64 invslope = (__int64(x0 - x1) << 16) / dy;
- while (mEdgeNext + y0 + 1 - iy > mEdgeHeapSize) {
- _ReallocEdgeBuffer(mEdgeHeapSize*2);
- }
+ while (mEdgeNext + y0 + 1 - iy > mEdgeHeapSize) {
+ _ReallocEdgeBuffer(mEdgeHeapSize * 2);
+ }
- xacc += (invslope * (y - y1)) >> 3;
+ xacc += (invslope * (y - y1)) >> 3;
- while (iy <= y0) {
- int ix = (int)((xacc + 32768) >> 16);
+ while (iy <= y0) {
+ int ix = (int)((xacc + 32768) >> 16);
- mpEdgeBuffer[mEdgeNext].next = mpScanBuffer[iy];
- mpEdgeBuffer[mEdgeNext].posandflag = ix*2;
+ mpEdgeBuffer[mEdgeNext].next = mpScanBuffer[iy];
+ mpEdgeBuffer[mEdgeNext].posandflag = ix * 2;
- mpScanBuffer[iy] = mEdgeNext++;
+ mpScanBuffer[iy] = mEdgeNext++;
- ++iy;
- xacc += invslope;
- }
- }
- }
+ ++iy;
+ xacc += invslope;
+ }
+ }
+ }
}
bool Rasterizer::BeginPath(HDC hdc)
{
- _TrashPath();
+ _TrashPath();
- return !!::BeginPath(hdc);
+ return !!::BeginPath(hdc);
}
bool Rasterizer::EndPath(HDC hdc)
{
- ::CloseFigure(hdc);
+ ::CloseFigure(hdc);
- if (::EndPath(hdc)) {
- mPathPoints = GetPath(hdc, NULL, NULL, 0);
+ if (::EndPath(hdc)) {
+ mPathPoints = GetPath(hdc, NULL, NULL, 0);
- if (!mPathPoints) {
- return true;
- }
+ if (!mPathPoints) {
+ return true;
+ }
- mpPathTypes = (BYTE*)malloc(sizeof(BYTE) * mPathPoints);
- mpPathPoints = (POINT*)malloc(sizeof(POINT) * mPathPoints);
+ mpPathTypes = (BYTE*)malloc(sizeof(BYTE) * mPathPoints);
+ mpPathPoints = (POINT*)malloc(sizeof(POINT) * mPathPoints);
- if (mPathPoints == GetPath(hdc, mpPathPoints, mpPathTypes, mPathPoints)) {
- return true;
- }
- }
+ if (mPathPoints == GetPath(hdc, mpPathPoints, mpPathTypes, mPathPoints)) {
+ return true;
+ }
+ }
- ::AbortPath(hdc);
+ ::AbortPath(hdc);
- return false;
+ return false;
}
bool Rasterizer::PartialBeginPath(HDC hdc, bool bClearPath)
{
- if (bClearPath) {
- _TrashPath();
- }
+ if (bClearPath) {
+ _TrashPath();
+ }
- return !!::BeginPath(hdc);
+ return !!::BeginPath(hdc);
}
bool Rasterizer::PartialEndPath(HDC hdc, long dx, long dy)
{
- ::CloseFigure(hdc);
+ ::CloseFigure(hdc);
- if (::EndPath(hdc)) {
- int nPoints;
- BYTE* pNewTypes;
- POINT* pNewPoints;
+ if (::EndPath(hdc)) {
+ int nPoints;
+ BYTE* pNewTypes;
+ POINT* pNewPoints;
- nPoints = GetPath(hdc, NULL, NULL, 0);
+ nPoints = GetPath(hdc, NULL, NULL, 0);
- if (!nPoints) {
- return true;
- }
+ if (!nPoints) {
+ return true;
+ }
- pNewTypes = (BYTE*)realloc(mpPathTypes, (mPathPoints + nPoints) * sizeof(BYTE));
- pNewPoints = (POINT*)realloc(mpPathPoints, (mPathPoints + nPoints) * sizeof(POINT));
+ pNewTypes = (BYTE*)realloc(mpPathTypes, (mPathPoints + nPoints) * sizeof(BYTE));
+ pNewPoints = (POINT*)realloc(mpPathPoints, (mPathPoints + nPoints) * sizeof(POINT));
- if (pNewTypes) {
- mpPathTypes = pNewTypes;
- }
+ if (pNewTypes) {
+ mpPathTypes = pNewTypes;
+ }
- if (pNewPoints) {
- mpPathPoints = pNewPoints;
- }
+ if (pNewPoints) {
+ mpPathPoints = pNewPoints;
+ }
- BYTE* pTypes = DNew BYTE[nPoints];
- POINT* pPoints = DNew POINT[nPoints];
+ BYTE* pTypes = DNew BYTE[nPoints];
+ POINT* pPoints = DNew POINT[nPoints];
- if (pNewTypes && pNewPoints && nPoints == GetPath(hdc, pPoints, pTypes, nPoints)) {
- for (ptrdiff_t i = 0; i < nPoints; ++i) {
- mpPathPoints[mPathPoints + i].x = pPoints[i].x + dx;
- mpPathPoints[mPathPoints + i].y = pPoints[i].y + dy;
- mpPathTypes[mPathPoints + i] = pTypes[i];
- }
+ if (pNewTypes && pNewPoints && nPoints == GetPath(hdc, pPoints, pTypes, nPoints)) {
+ for (ptrdiff_t i = 0; i < nPoints; ++i) {
+ mpPathPoints[mPathPoints + i].x = pPoints[i].x + dx;
+ mpPathPoints[mPathPoints + i].y = pPoints[i].y + dy;
+ mpPathTypes[mPathPoints + i] = pTypes[i];
+ }
- mPathPoints += nPoints;
+ mPathPoints += nPoints;
- delete[] pTypes;
- delete[] pPoints;
- return true;
- } else {
- DebugBreak();
- }
+ delete[] pTypes;
+ delete[] pPoints;
+ return true;
+ } else {
+ DebugBreak();
+ }
- delete[] pTypes;
- delete[] pPoints;
- }
+ delete[] pTypes;
+ delete[] pPoints;
+ }
- ::AbortPath(hdc);
+ ::AbortPath(hdc);
- return false;
+ return false;
}
bool Rasterizer::ScanConvert()
{
- int lastmoveto = INT_MAX;
- int i;
-
- // Drop any outlines we may have.
-
- mOutline.clear();
- mWideOutline.clear();
- mWideBorder = 0;
-
- // Determine bounding box
-
- if (!mPathPoints) {
- mPathOffsetX = mPathOffsetY = 0;
- mWidth = mHeight = 0;
- return 0;
- }
-
- int minx = INT_MAX;
- int miny = INT_MAX;
- int maxx = INT_MIN;
- int maxy = INT_MIN;
-
- for (i=0; i<mPathPoints; ++i) {
- int ix = mpPathPoints[i].x;
- int iy = mpPathPoints[i].y;
-
- if (ix < minx) {
- minx = ix;
- }
- if (ix > maxx) {
- maxx = ix;
- }
- if (iy < miny) {
- miny = iy;
- }
- if (iy > maxy) {
- maxy = iy;
- }
- }
-
- minx = (minx >> 3) & ~7;
- miny = (miny >> 3) & ~7;
- maxx = (maxx + 7) >> 3;
- maxy = (maxy + 7) >> 3;
-
- for (i=0; i<mPathPoints; ++i) {
- mpPathPoints[i].x -= minx*8;
- mpPathPoints[i].y -= miny*8;
- }
-
- if (minx > maxx || miny > maxy) {
- mWidth = mHeight = 0;
- mPathOffsetX = mPathOffsetY = 0;
- _TrashPath();
- return true;
- }
-
- mWidth = maxx + 1 - minx;
- mHeight = maxy + 1 - miny;
-
- mPathOffsetX = minx;
- mPathOffsetY = miny;
-
- // Initialize edge buffer. We use edge 0 as a sentinel.
-
- mEdgeNext = 1;
- mEdgeHeapSize = 2048;
- mpEdgeBuffer = (Edge*)malloc(sizeof(Edge)*mEdgeHeapSize);
-
- // Initialize scanline list.
-
- mpScanBuffer = DNew unsigned int[mHeight];
- memset(mpScanBuffer, 0, mHeight*sizeof(unsigned int));
-
- // Scan convert the outline. Yuck, Bezier curves....
-
- // Unfortunately, Windows 95/98 GDI has a bad habit of giving us text
- // paths with all but the first figure left open, so we can't rely
- // on the PT_CLOSEFIGURE flag being used appropriately.
-
- fFirstSet = false;
- firstp.x = firstp.y = 0;
- lastp.x = lastp.y = 0;
-
- for (i=0; i<mPathPoints; ++i) {
- BYTE t = mpPathTypes[i] & ~PT_CLOSEFIGURE;
-
- switch (t) {
- case PT_MOVETO:
- if (lastmoveto >= 0 && firstp != lastp) {
- _EvaluateLine(lastp.x, lastp.y, firstp.x, firstp.y);
- }
- lastmoveto = i;
- fFirstSet = false;
- lastp = mpPathPoints[i];
- break;
- case PT_MOVETONC:
- break;
- case PT_LINETO:
- if (mPathPoints - (i-1) >= 2) {
- _EvaluateLine(i-1, i);
- }
- break;
- case PT_BEZIERTO:
- if (mPathPoints - (i-1) >= 4) {
- _EvaluateBezier(i-1, false);
- }
- i += 2;
- break;
- case PT_BSPLINETO:
- if (mPathPoints - (i-1) >= 4) {
- _EvaluateBezier(i-1, true);
- }
- i += 2;
- break;
- case PT_BSPLINEPATCHTO:
- if (mPathPoints - (i-3) >= 4) {
- _EvaluateBezier(i-3, true);
- }
- break;
- }
- }
-
- if (lastmoveto >= 0 && firstp != lastp) {
- _EvaluateLine(lastp.x, lastp.y, firstp.x, firstp.y);
- }
-
- // Free the path since we don't need it anymore.
-
- _TrashPath();
-
- // Convert the edges to spans. We couldn't do this before because some of
- // the regions may have winding numbers >+1 and it would have been a pain
- // to try to adjust the spans on the fly. We use one heap to detangle
- // a scanline's worth of edges from the singly-linked lists, and another
- // to collect the actual scans.
-
- std::vector<int> heap;
-
- mOutline.reserve(mEdgeNext / 2);
-
- __int64 y = 0;
-
- for (y=0; y<mHeight; ++y) {
- int count = 0;
-
- // Detangle scanline into edge heap.
-
- for (size_t ptr = (mpScanBuffer[y]&(unsigned int)(-1)); ptr; ptr = mpEdgeBuffer[ptr].next) {
- heap.push_back(mpEdgeBuffer[ptr].posandflag);
- }
-
- // Sort edge heap. Note that we conveniently made the opening edges
- // one more than closing edges at the same spot, so we won't have any
- // problems with abutting spans.
+ int lastmoveto = INT_MAX;
+ int i;
+
+ // Drop any outlines we may have.
+
+ mOutline.clear();
+ mWideOutline.clear();
+ mWideBorder = 0;
+
+ // Determine bounding box
+
+ if (!mPathPoints) {
+ mPathOffsetX = mPathOffsetY = 0;
+ mWidth = mHeight = 0;
+ return 0;
+ }
+
+ int minx = INT_MAX;
+ int miny = INT_MAX;
+ int maxx = INT_MIN;
+ int maxy = INT_MIN;
+
+ for (i = 0; i < mPathPoints; ++i) {
+ int ix = mpPathPoints[i].x;
+ int iy = mpPathPoints[i].y;
+
+ if (ix < minx) {
+ minx = ix;
+ }
+ if (ix > maxx) {
+ maxx = ix;
+ }
+ if (iy < miny) {
+ miny = iy;
+ }
+ if (iy > maxy) {
+ maxy = iy;
+ }
+ }
+
+ minx = (minx >> 3) & ~7;
+ miny = (miny >> 3) & ~7;
+ maxx = (maxx + 7) >> 3;
+ maxy = (maxy + 7) >> 3;
+
+ for (i = 0; i < mPathPoints; ++i) {
+ mpPathPoints[i].x -= minx * 8;
+ mpPathPoints[i].y -= miny * 8;
+ }
+
+ if (minx > maxx || miny > maxy) {
+ mWidth = mHeight = 0;
+ mPathOffsetX = mPathOffsetY = 0;
+ _TrashPath();
+ return true;
+ }
+
+ mWidth = maxx + 1 - minx;
+ mHeight = maxy + 1 - miny;
+
+ mPathOffsetX = minx;
+ mPathOffsetY = miny;
+
+ // Initialize edge buffer. We use edge 0 as a sentinel.
+
+ mEdgeNext = 1;
+ mEdgeHeapSize = 2048;
+ mpEdgeBuffer = (Edge*)malloc(sizeof(Edge) * mEdgeHeapSize);
+
+ // Initialize scanline list.
+
+ mpScanBuffer = DNew unsigned int[mHeight];
+ memset(mpScanBuffer, 0, mHeight * sizeof(unsigned int));
+
+ // Scan convert the outline. Yuck, Bezier curves....
+
+ // Unfortunately, Windows 95/98 GDI has a bad habit of giving us text
+ // paths with all but the first figure left open, so we can't rely
+ // on the PT_CLOSEFIGURE flag being used appropriately.
+
+ fFirstSet = false;
+ firstp.x = firstp.y = 0;
+ lastp.x = lastp.y = 0;
+
+ for (i = 0; i < mPathPoints; ++i) {
+ BYTE t = mpPathTypes[i] & ~PT_CLOSEFIGURE;
+
+ switch (t) {
+ case PT_MOVETO:
+ if (lastmoveto >= 0 && firstp != lastp) {
+ _EvaluateLine(lastp.x, lastp.y, firstp.x, firstp.y);
+ }
+ lastmoveto = i;
+ fFirstSet = false;
+ lastp = mpPathPoints[i];
+ break;
+ case PT_MOVETONC:
+ break;
+ case PT_LINETO:
+ if (mPathPoints - (i - 1) >= 2) {
+ _EvaluateLine(i - 1, i);
+ }
+ break;
+ case PT_BEZIERTO:
+ if (mPathPoints - (i - 1) >= 4) {
+ _EvaluateBezier(i - 1, false);
+ }
+ i += 2;
+ break;
+ case PT_BSPLINETO:
+ if (mPathPoints - (i - 1) >= 4) {
+ _EvaluateBezier(i - 1, true);
+ }
+ i += 2;
+ break;
+ case PT_BSPLINEPATCHTO:
+ if (mPathPoints - (i - 3) >= 4) {
+ _EvaluateBezier(i - 3, true);
+ }
+ break;
+ }
+ }
+
+ if (lastmoveto >= 0 && firstp != lastp) {
+ _EvaluateLine(lastp.x, lastp.y, firstp.x, firstp.y);
+ }
+
+ // Free the path since we don't need it anymore.
+
+ _TrashPath();
+
+ // Convert the edges to spans. We couldn't do this before because some of
+ // the regions may have winding numbers >+1 and it would have been a pain
+ // to try to adjust the spans on the fly. We use one heap to detangle
+ // a scanline's worth of edges from the singly-linked lists, and another
+ // to collect the actual scans.
+
+ std::vector<int> heap;
+
+ mOutline.reserve(mEdgeNext / 2);
+
+ __int64 y = 0;
+
+ for (y = 0; y < mHeight; ++y) {
+ int count = 0;
+
+ // Detangle scanline into edge heap.
+
+ for (size_t ptr = (mpScanBuffer[y] & (unsigned int)(-1)); ptr; ptr = mpEdgeBuffer[ptr].next) {
+ heap.push_back(mpEdgeBuffer[ptr].posandflag);
+ }
+
+ // Sort edge heap. Note that we conveniently made the opening edges
+ // one more than closing edges at the same spot, so we won't have any
+ // problems with abutting spans.
- std::sort(heap.begin(), heap.end()/*begin() + heap.size()*/);
+ std::sort(heap.begin(), heap.end()/*begin() + heap.size()*/);
- // Process edges and add spans. Since we only check for a non-zero
- // winding number, it doesn't matter which way the outlines go!
-
- std::vector<int>::iterator itX1 = heap.begin();
- std::vector<int>::iterator itX2 = heap.end(); // begin() + heap.size();
-
- size_t x1 = 0;
- size_t x2;
-
- for (; itX1 != itX2; ++itX1) {
- size_t x = *itX1;
-
- if (!count) {
- x1 = (x>>1);
- }
-
- if (x&1) {
- ++count;
- } else {
- --count;
- }
-
- if (!count) {
- x2 = (x>>1);
-
- if (x2>x1) {
- mOutline.push_back(std::pair<__int64,__int64>((y<<32)+x1+0x4000000040000000i64, (y<<32)+x2+0x4000000040000000i64)); // G: damn Avery, this is evil! :)
- }
- }
- }
-
- heap.clear();
- }
-
- // Dump the edge and scan buffers, since we no longer need them.
-
- free(mpEdgeBuffer);
- delete [] mpScanBuffer;
-
- // All done!
+ // Process edges and add spans. Since we only check for a non-zero
+ // winding number, it doesn't matter which way the outlines go!
+
+ std::vector<int>::iterator itX1 = heap.begin();
+ std::vector<int>::iterator itX2 = heap.end(); // begin() + heap.size();
+
+ size_t x1 = 0;
+ size_t x2;
+
+ for (; itX1 != itX2; ++itX1) {
+ size_t x = *itX1;
+
+ if (!count) {
+ x1 = (x >> 1);
+ }
+
+ if (x & 1) {
+ ++count;
+ } else {
+ --count;
+ }
+
+ if (!count) {
+ x2 = (x >> 1);
+
+ if (x2 > x1) {
+ mOutline.push_back(std::pair<__int64, __int64>((y << 32) + x1 + 0x4000000040000000i64, (y << 32) + x2 + 0x4000000040000000i64)); // G: damn Avery, this is evil! :)
+ }
+ }
+ }
+
+ heap.clear();
+ }
+
+ // Dump the edge and scan buffers, since we no longer need them.
+
+ free(mpEdgeBuffer);
+ delete [] mpScanBuffer;
+
+ // All done!
- return true;
+ return true;
}
void Rasterizer::_OverlapRegion(tSpanBuffer& dst, tSpanBuffer& src, int dx, int dy)
{
- tSpanBuffer temp;
+ tSpanBuffer temp;
- temp.reserve(dst.size() + src.size());
+ temp.reserve(dst.size() + src.size());
- dst.swap(temp);
+ dst.swap(temp);
- tSpanBuffer::iterator itA = temp.begin();
- tSpanBuffer::iterator itAE = temp.end();
- tSpanBuffer::iterator itB = src.begin();
- tSpanBuffer::iterator itBE = src.end();
+ tSpanBuffer::iterator itA = temp.begin();
+ tSpanBuffer::iterator itAE = temp.end();
+ tSpanBuffer::iterator itB = src.begin();
+ tSpanBuffer::iterator itBE = src.end();
- // Don't worry -- even if dy<0 this will still work! // G: hehe, the evil twin :)
+ // Don't worry -- even if dy<0 this will still work! // G: hehe, the evil twin :)
- unsigned __int64 offset1 = (((__int64)dy)<<32) - dx;
- unsigned __int64 offset2 = (((__int64)dy)<<32) + dx;
+ unsigned __int64 offset1 = (((__int64)dy) << 32) - dx;
+ unsigned __int64 offset2 = (((__int64)dy) << 32) + dx;
- while (itA != itAE && itB != itBE) {
- if ((*itB).first + offset1 < (*itA).first) {
- // B span is earlier. Use it.
+ while (itA != itAE && itB != itBE) {
+ if ((*itB).first + offset1 < (*itA).first) {
+ // B span is earlier. Use it.
- unsigned __int64 x1 = (*itB).first + offset1;
- unsigned __int64 x2 = (*itB).second + offset2;
+ unsigned __int64 x1 = (*itB).first + offset1;
+ unsigned __int64 x2 = (*itB).second + offset2;
- ++itB;
+ ++itB;
- // B spans don't overlap, so begin merge loop with A first.
+ // B spans don't overlap, so begin merge loop with A first.
- for (;;) {
- // If we run out of A spans or the A span doesn't overlap,
- // then the next B span can't either (because B spans don't
- // overlap) and we exit.
+ for (;;) {
+ // If we run out of A spans or the A span doesn't overlap,
+ // then the next B span can't either (because B spans don't
+ // overlap) and we exit.
- if (itA == itAE || (*itA).first > x2) {
- break;
- }
+ if (itA == itAE || (*itA).first > x2) {
+ break;
+ }
- do {
- x2 = _MAX(x2, (*itA++).second);
- } while (itA != itAE && (*itA).first <= x2);
+ do {
+ x2 = _MAX(x2, (*itA++).second);
+ } while (itA != itAE && (*itA).first <= x2);
- // If we run out of B spans or the B span doesn't overlap,
- // then the next A span can't either (because A spans don't
- // overlap) and we exit.
+ // If we run out of B spans or the B span doesn't overlap,
+ // then the next A span can't either (because A spans don't
+ // overlap) and we exit.
- if (itB == itBE || (*itB).first + offset1 > x2) {
- break;
- }
+ if (itB == itBE || (*itB).first + offset1 > x2) {
+ break;
+ }
- do {
- x2 = _MAX(x2, (*itB++).second + offset2);
- } while (itB != itBE && (*itB).first + offset1 <= x2);
- }
+ do {
+ x2 = _MAX(x2, (*itB++).second + offset2);
+ } while (itB != itBE && (*itB).first + offset1 <= x2);
+ }
- // Flush span.
+ // Flush span.
- dst.push_back(tSpan(x1, x2));
- } else {
- // A span is earlier. Use it.
+ dst.push_back(tSpan(x1, x2));
+ } else {
+ // A span is earlier. Use it.
- unsigned __int64 x1 = (*itA).first;
- unsigned __int64 x2 = (*itA).second;
+ unsigned __int64 x1 = (*itA).first;
+ unsigned __int64 x2 = (*itA).second;
- ++itA;
+ ++itA;
- // A spans don't overlap, so begin merge loop with B first.
+ // A spans don't overlap, so begin merge loop with B first.
- for (;;) {
- // If we run out of B spans or the B span doesn't overlap,
- // then the next A span can't either (because A spans don't
- // overlap) and we exit.
+ for (;;) {
+ // If we run out of B spans or the B span doesn't overlap,
+ // then the next A span can't either (because A spans don't
+ // overlap) and we exit.
- if (itB == itBE || (*itB).first + offset1 > x2) {
- break;
- }
+ if (itB == itBE || (*itB).first + offset1 > x2) {
+ break;
+ }
- do {
- x2 = _MAX(x2, (*itB++).second + offset2);
- } while (itB != itBE && (*itB).first + offset1 <= x2);
+ do {
+ x2 = _MAX(x2, (*itB++).second + offset2);
+ } while (itB != itBE && (*itB).first + offset1 <= x2);
- // If we run out of A spans or the A span doesn't overlap,
- // then the next B span can't either (because B spans don't
- // overlap) and we exit.
+ // If we run out of A spans or the A span doesn't overlap,
+ // then the next B span can't either (because B spans don't
+ // overlap) and we exit.
- if (itA == itAE || (*itA).first > x2) {
- break;
- }
+ if (itA == itAE || (*itA).first > x2) {
+ break;
+ }
- do {
- x2 = _MAX(x2, (*itA++).second);
- } while (itA != itAE && (*itA).first <= x2);
- }
+ do {
+ x2 = _MAX(x2, (*itA++).second);
+ } while (itA != itAE && (*itA).first <= x2);
+ }
- // Flush span.
+ // Flush span.
- dst.push_back(tSpan(x1, x2));
- }
- }
+ dst.push_back(tSpan(x1, x2));
+ }
+ }
- // Copy over leftover spans.
+ // Copy over leftover spans.
- while (itA != itAE) {
- dst.push_back(*itA++);
- }
+ while (itA != itAE) {
+ dst.push_back(*itA++);
+ }
- while (itB != itBE) {
- dst.push_back(tSpan((*itB).first + offset1, (*itB).second + offset2));
- ++itB;
- }
+ while (itB != itBE) {
+ dst.push_back(tSpan((*itB).first + offset1, (*itB).second + offset2));
+ ++itB;
+ }
}
bool Rasterizer::CreateWidenedRegion(int rx, int ry)
{
- if (rx < 0) {
- rx = 0;
- }
- if (ry < 0) {
- ry = 0;
- }
-
- mWideBorder = max(rx,ry);
-
- if (ry > 0) {
- // Do a half circle.
- // _OverlapRegion mirrors this so both halves are done.
- for (int y = -ry; y <= ry; ++y) {
- int x = (int)(0.5 + sqrt(float(ry*ry - y*y)) * float(rx)/float(ry));
-
- _OverlapRegion(mWideOutline, mOutline, x, y);
- }
- } else if (ry == 0 && rx > 0) {
- // There are artifacts if we don't make at least two overlaps of the line, even at same Y coord
- _OverlapRegion(mWideOutline, mOutline, rx, 0);
- _OverlapRegion(mWideOutline, mOutline, rx, 0);
- }
-
- return true;
+ if (rx < 0) {
+ rx = 0;
+ }
+ if (ry < 0) {
+ ry = 0;
+ }
+
+ mWideBorder = max(rx, ry);
+
+ if (ry > 0) {
+ // Do a half circle.
+ // _OverlapRegion mirrors this so both halves are done.
+ for (int y = -ry; y <= ry; ++y) {
+ int x = (int)(0.5 + sqrt(float(ry * ry - y * y)) * float(rx) / float(ry));
+
+ _OverlapRegion(mWideOutline, mOutline, x, y);
+ }
+ } else if (ry == 0 && rx > 0) {
+ // There are artifacts if we don't make at least two overlaps of the line, even at same Y coord
+ _OverlapRegion(mWideOutline, mOutline, rx, 0);
+ _OverlapRegion(mWideOutline, mOutline, rx, 0);
+ }
+
+ return true;
}
void Rasterizer::DeleteOutlines()
{
- mWideOutline.clear();
- mOutline.clear();
+ mWideOutline.clear();
+ mOutline.clear();
}
bool Rasterizer::Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur)
{
- _TrashOverlay();
+ _TrashOverlay();
- if (!mWidth || !mHeight) {
- mOverlayWidth = mOverlayHeight = 0;
- return true;
- }
+ if (!mWidth || !mHeight) {
+ mOverlayWidth = mOverlayHeight = 0;
+ return true;
+ }
- xsub &= 7;
- ysub &= 7;
+ xsub &= 7;
+ ysub &= 7;
- int width = mWidth + xsub;
- int height = mHeight;// + ysub
+ int width = mWidth + xsub;
+ int height = mHeight;// + ysub
- mOffsetX = mPathOffsetX - xsub;
- mOffsetY = mPathOffsetY - ysub;
+ mOffsetX = mPathOffsetX - xsub;
+ mOffsetY = mPathOffsetY - ysub;
- mWideBorder = (mWideBorder+7)&~7;
+ mWideBorder = (mWideBorder + 7)&~7;
- if (!mWideOutline.empty() || fBlur || fGaussianBlur > 0) {
- int bluradjust = 0;
- if (fGaussianBlur > 0) {
- bluradjust += (int)(fGaussianBlur*3*8 + 0.5) | 1;
- }
- if (fBlur) {
- bluradjust += 8;
- }
+ if (!mWideOutline.empty() || fBlur || fGaussianBlur > 0) {
+ int bluradjust = 0;
+ if (fGaussianBlur > 0) {
+ bluradjust += (int)(fGaussianBlur * 3 * 8 + 0.5) | 1;
+ }
+ if (fBlur) {
+ bluradjust += 8;
+ }
- // Expand the buffer a bit when we're blurring, since that can also widen the borders a bit
- bluradjust = (bluradjust+7)&~7;
+ // Expand the buffer a bit when we're blurring, since that can also widen the borders a bit
+ bluradjust = (bluradjust + 7)&~7;
- width += 2*mWideBorder + bluradjust*2;
- height += 2*mWideBorder + bluradjust*2;
+ width += 2 * mWideBorder + bluradjust * 2;
+ height += 2 * mWideBorder + bluradjust * 2;
- xsub += mWideBorder + bluradjust;
- ysub += mWideBorder + bluradjust;
+ xsub += mWideBorder + bluradjust;
+ ysub += mWideBorder + bluradjust;
- mOffsetX -= mWideBorder + bluradjust;
- mOffsetY -= mWideBorder + bluradjust;
- }
+ mOffsetX -= mWideBorder + bluradjust;
+ mOffsetY -= mWideBorder + bluradjust;
+ }
- mOverlayWidth = ((width+7)>>3) + 1;
- // fixed image height
- mOverlayHeight=((height+14)>>3) + 1;
+ mOverlayWidth = ((width + 7) >> 3) + 1;
+ // fixed image height
+ mOverlayHeight = ((height + 14) >> 3) + 1;
- mpOverlayBuffer = (byte*)_aligned_malloc(2 * mOverlayWidth * mOverlayHeight, 16);
- if (!mpOverlayBuffer) {
- return false;
- }
+ mpOverlayBuffer = (byte*)_aligned_malloc(2 * mOverlayWidth * mOverlayHeight, 16);
+ if (!mpOverlayBuffer) {
+ return false;
+ }
- memset(mpOverlayBuffer, 0, 2 * mOverlayWidth * mOverlayHeight);
+ memset(mpOverlayBuffer, 0, 2 * mOverlayWidth * mOverlayHeight);
- // Are we doing a border?
+ // Are we doing a border?
- tSpanBuffer* pOutline[2] = {&mOutline, &mWideOutline};
+ tSpanBuffer* pOutline[2] = {&mOutline, &mWideOutline};
- for (ptrdiff_t i = _countof(pOutline)-1; i >= 0; i--) {
- tSpanBuffer::iterator it = pOutline[i]->begin();
- tSpanBuffer::iterator itEnd = pOutline[i]->end();
+ for (ptrdiff_t i = _countof(pOutline) - 1; i >= 0; i--) {
+ tSpanBuffer::iterator it = pOutline[i]->begin();
+ tSpanBuffer::iterator itEnd = pOutline[i]->end();
- for (; it!=itEnd; ++it) {
- unsigned __int64 f = (*it).first;
- unsigned int y = (f >> 32) - 0x40000000 + ysub;
- unsigned int x1 = (f & 0xffffffff) - 0x40000000 + xsub;
+ for (; it != itEnd; ++it) {
+ unsigned __int64 f = (*it).first;
+ unsigned int y = (f >> 32) - 0x40000000 + ysub;
+ unsigned int x1 = (f & 0xffffffff) - 0x40000000 + xsub;
- unsigned __int64 s = (*it).second;
- unsigned int x2 = (s & 0xffffffff) - 0x40000000 + xsub;
+ unsigned __int64 s = (*it).second;
+ unsigned int x2 = (s & 0xffffffff) - 0x40000000 + xsub;
- if (x2 > x1) {
- unsigned int first = x1>>3;
- unsigned int last = (x2-1)>>3;
- byte* dst = mpOverlayBuffer + 2*(mOverlayWidth*(y>>3) + first) + i;
+ if (x2 > x1) {
+ unsigned int first = x1 >> 3;
+ unsigned int last = (x2 - 1) >> 3;
+ byte* dst = mpOverlayBuffer + 2 * (mOverlayWidth * (y >> 3) + first) + i;
- if (first == last) {
- *dst += x2-x1;
- } else {
- *dst += ((first+1)<<3) - x1;
- dst += 2;
+ if (first == last) {
+ *dst += x2 - x1;
+ } else {
+ *dst += ((first + 1) << 3) - x1;
+ dst += 2;
- while (++first < last) {
- *dst += 0x08;
- dst += 2;
- }
+ while (++first < last) {
+ *dst += 0x08;
+ dst += 2;
+ }
- *dst += x2 - (last<<3);
- }
- }
- }
- }
+ *dst += x2 - (last << 3);
+ }
+ }
+ }
+ }
- // Do some gaussian blur magic
- if (fGaussianBlur > 0) {
- GaussianKernel filter(fGaussianBlur);
- if (mOverlayWidth >= filter.width && mOverlayHeight >= filter.width) {
- size_t pitch = mOverlayWidth*2;
+ // Do some gaussian blur magic
+ if (fGaussianBlur > 0) {
+ GaussianKernel filter(fGaussianBlur);
+ if (mOverlayWidth >= filter.width && mOverlayHeight >= filter.width) {
+ size_t pitch = mOverlayWidth * 2;
- byte *tmp = DNew byte[pitch*mOverlayHeight];
- if (!tmp) {
- return false;
- }
+ byte* tmp = DNew byte[pitch * mOverlayHeight];
+ if (!tmp) {
+ return false;
+ }
- int border = !mWideOutline.empty() ? 1 : 0;
+ int border = !mWideOutline.empty() ? 1 : 0;
- byte *src = mpOverlayBuffer + border;
+ byte* src = mpOverlayBuffer + border;
- SeparableFilterX<2>(src, tmp, mOverlayWidth, mOverlayHeight, pitch, filter.kernel, filter.width, filter.divisor);
- SeparableFilterY<2>(tmp, src, mOverlayWidth, mOverlayHeight, pitch, filter.kernel, filter.width, filter.divisor);
+ SeparableFilterX<2>(src, tmp, mOverlayWidth, mOverlayHeight, pitch, filter.kernel, filter.width, filter.divisor);
+ SeparableFilterY<2>(tmp, src, mOverlayWidth, mOverlayHeight, pitch, filter.kernel, filter.width, filter.divisor);
- delete[] tmp;
- }
- }
+ delete[] tmp;
+ }
+ }
- // If we're blurring, do a 3x3 box blur
- // Can't do it on subpictures smaller than 3x3 pixels
- for (int pass = 0; pass < fBlur; pass++) {
- if (mOverlayWidth >= 3 && mOverlayHeight >= 3) {
- int pitch = mOverlayWidth*2;
+ // If we're blurring, do a 3x3 box blur
+ // Can't do it on subpictures smaller than 3x3 pixels
+ for (int pass = 0; pass < fBlur; pass++) {
+ if (mOverlayWidth >= 3 && mOverlayHeight >= 3) {
+ int pitch = mOverlayWidth * 2;
- byte* tmp = DNew byte[pitch*mOverlayHeight];
- if (!tmp) {
- return false;
- }
+ byte* tmp = DNew byte[pitch * mOverlayHeight];
+ if (!tmp) {
+ return false;
+ }
- memcpy(tmp, mpOverlayBuffer, pitch*mOverlayHeight);
+ memcpy(tmp, mpOverlayBuffer, pitch * mOverlayHeight);
- int border = !mWideOutline.empty() ? 1 : 0;
+ int border = !mWideOutline.empty() ? 1 : 0;
- // This could be done in a separated way and win some speed
- for (ptrdiff_t j = 1; j < mOverlayHeight-1; j++) {
- byte* src = tmp + pitch*j + 2 + border;
- byte* dst = mpOverlayBuffer + pitch*j + 2 + border;
+ // This could be done in a separated way and win some speed
+ for (ptrdiff_t j = 1; j < mOverlayHeight - 1; j++) {
+ byte* src = tmp + pitch * j + 2 + border;
+ byte* dst = mpOverlayBuffer + pitch * j + 2 + border;
- for (ptrdiff_t i = 1; i < mOverlayWidth-1; i++, src+=2, dst+=2) {
- *dst = (src[-2-pitch] + (src[-pitch]<<1) + src[+2-pitch]
- + (src[-2]<<1) + (src[0]<<2) + (src[+2]<<1)
- + src[-2+pitch] + (src[+pitch]<<1) + src[+2+pitch]) >> 4;
- }
- }
+ for (ptrdiff_t i = 1; i < mOverlayWidth - 1; i++, src += 2, dst += 2) {
+ *dst = (src[-2 - pitch] + (src[-pitch] << 1) + src[+2 - pitch]
+ + (src[-2] << 1) + (src[0] << 2) + (src[+2] << 1)
+ + src[-2 + pitch] + (src[+pitch] << 1) + src[+2 + pitch]) >> 4;
+ }
+ }
- delete [] tmp;
- }
- }
+ delete [] tmp;
+ }
+ }
- return true;
+ return true;
}
///////////////////////////////////////////////////////////////////////////
-static __forceinline void pixmix(DWORD *dst, DWORD color, DWORD alpha)
+static __forceinline void pixmix(DWORD* dst, DWORD color, DWORD alpha)
{
- DWORD a = (((alpha)*(color>>24))>>6)&0xff;
- DWORD ia = 256-a;
- a+=1;
-
- DWORD tmp = (((((*dst>>8)&0x00ff0000)*ia)&0xff000000)>>24)&0xFF;
- UNREFERENCED_PARAMETER(tmp);
- *dst = ((((*dst&0x00ff00ff)*ia + (color&0x00ff00ff)*a)&0xff00ff00)>>8)
- | ((((*dst&0x0000ff00)*ia + (color&0x0000ff00)*a)&0x00ff0000)>>8)
- | ((((*dst>>8)&0x00ff0000)*ia)&0xff000000);
+ DWORD a = (((alpha) * (color >> 24)) >> 6) & 0xff;
+ DWORD ia = 256 - a;
+ a += 1;
+
+ DWORD tmp = (((((*dst >> 8) & 0x00ff0000) * ia) & 0xff000000) >> 24) & 0xFF;
+ UNREFERENCED_PARAMETER(tmp);
+ *dst = ((((*dst & 0x00ff00ff) * ia + (color & 0x00ff00ff) * a) & 0xff00ff00) >> 8)
+ | ((((*dst & 0x0000ff00) * ia + (color & 0x0000ff00) * a) & 0x00ff0000) >> 8)
+ | ((((*dst >> 8) & 0x00ff0000) * ia) & 0xff000000);
}
-static __forceinline void pixmix2(DWORD *dst, DWORD color, DWORD shapealpha, DWORD clipalpha)
+static __forceinline void pixmix2(DWORD* dst, DWORD color, DWORD shapealpha, DWORD clipalpha)
{
- DWORD a = (((shapealpha)*(clipalpha)*(color>>24))>>12)&0xff;
- DWORD ia = 256-a;
- a+=1;
+ DWORD a = (((shapealpha) * (clipalpha) * (color >> 24)) >> 12) & 0xff;
+ DWORD ia = 256 - a;
+ a += 1;
- *dst = ((((*dst&0x00ff00ff)*ia + (color&0x00ff00ff)*a)&0xff00ff00)>>8)
- | ((((*dst&0x0000ff00)*ia + (color&0x0000ff00)*a)&0x00ff0000)>>8)
- | ((((*dst>>8)&0x00ff0000)*ia)&0xff000000);
+ *dst = ((((*dst & 0x00ff00ff) * ia + (color & 0x00ff00ff) * a) & 0xff00ff00) >> 8)
+ | ((((*dst & 0x0000ff00) * ia + (color & 0x0000ff00) * a) & 0x00ff0000) >> 8)
+ | ((((*dst >> 8) & 0x00ff0000) * ia) & 0xff000000);
}
// Alpha blend 8 pixels at once. This is just pixmix_sse2, but done in a more vectorized manner.
static __forceinline void alpha_blend_sse2(DWORD* dst, DWORD original_color, BYTE* s, int wt)
{
- __m128i srcR = _mm_set1_epi32(original_color & 0xFF);
- __m128i srcG = _mm_set1_epi32((original_color & 0xFF00) >> 8);
- __m128i srcB = _mm_set1_epi32((original_color & 0xFF0000) >> 16);
- __m128i src_alpha = _mm_set1_epi16((original_color & 0xFF000000) >> 24);
-
- __m128i alpha_mask = _mm_loadu_si128((__m128i*)&s[wt*2]);
-
- // Zero upper 8 bits of alpha mask since we don't need it
- alpha_mask = _mm_and_si128(alpha_mask, low_mask);
-
- alpha_mask = _mm_mullo_epi16(alpha_mask, src_alpha);
-
- alpha_mask = _mm_srli_epi16(alpha_mask, 6);
- alpha_mask = _mm_and_si128(alpha_mask, low_mask);
-
- __m128i inv_alpha = _mm_sub_epi16(inv_one, alpha_mask);
-
- alpha_mask = _mm_add_epi16(alpha_mask, one);
-
- __m128i dst_xmm = _mm_loadu_si128((__m128i*)&dst[wt]);
- __m128i dst2_xmm = _mm_loadu_si128((__m128i*)&dst[wt+4]);
-
- __m128i alpha_mask_hi = _mm_unpackhi_epi16(alpha_mask,zero);
- __m128i inv_alpha_hi = _mm_unpackhi_epi16(inv_alpha,zero);
-
- alpha_mask = _mm_unpacklo_epi16(alpha_mask, zero);
- inv_alpha = _mm_unpacklo_epi16(inv_alpha, zero);
-
- __m128i red = _mm_and_si128(dst_xmm, red_mask);
- red = _mm_mullo_epi16(red, inv_alpha);
- red = _mm_add_epi16(red, _mm_mullo_epi16(srcR, alpha_mask));
- red = _mm_srli_epi16(red, 8);
-
- __m128i green = _mm_and_si128(dst_xmm, green_mask);
- green = _mm_srli_epi32(green, 8);
- green = _mm_mullo_epi16(green, inv_alpha);
- green = _mm_add_epi16(green, _mm_mullo_epi16(srcG, alpha_mask));
- green = _mm_srli_epi32(green, 8);
- green = _mm_slli_epi32(green, 8);
-
- __m128i blue = _mm_and_si128(dst_xmm, blue_mask);
- blue = _mm_srli_epi32(blue, 16);
- blue = _mm_mullo_epi16(blue, inv_alpha);
- blue = _mm_add_epi16(blue, _mm_mullo_epi16(srcB, alpha_mask));
- blue = _mm_srli_epi32(blue, 8);
- blue = _mm_slli_epi32(blue, 16);
-
- __m128i alpha = _mm_and_si128(dst_xmm, alpha_bit_mask);
- alpha = _mm_srli_epi32(alpha, 24);
- alpha = _mm_mullo_epi16(alpha, inv_alpha);
- alpha = _mm_srli_epi32(alpha, 8);
- alpha = _mm_slli_epi32(alpha, 24);
-
- dst_xmm = _mm_or_si128(red, green);
- dst_xmm = _mm_or_si128(dst_xmm, blue);
- dst_xmm = _mm_or_si128(dst_xmm, alpha);
-
- // Next 4 pixels
- red = _mm_and_si128(dst2_xmm, red_mask);
- red = _mm_mullo_epi16(red, inv_alpha_hi);
- red = _mm_add_epi16(red, _mm_mullo_epi16(srcR, alpha_mask_hi));
- red = _mm_srli_epi16(red, 8);
-
- green = _mm_and_si128(dst2_xmm, green_mask);
- green = _mm_srli_epi32(green, 8);
- green = _mm_mullo_epi16(green, inv_alpha_hi);
- green = _mm_add_epi16(green, _mm_mullo_epi16(srcG, alpha_mask_hi));
- green = _mm_srli_epi32(green, 8);
- green = _mm_slli_epi32(green, 8);
-
- blue = _mm_and_si128(dst2_xmm, blue_mask);
- blue = _mm_srli_epi32(blue, 16);
- blue = _mm_mullo_epi16(blue, inv_alpha_hi);
- blue = _mm_add_epi16(blue, _mm_mullo_epi16(srcB, alpha_mask_hi));
- blue = _mm_srli_epi32(blue, 8);
- blue = _mm_slli_epi32(blue, 16);
-
- alpha = _mm_and_si128(dst2_xmm, alpha_bit_mask);
- alpha = _mm_srli_epi32(alpha, 24);
- alpha = _mm_mullo_epi16(alpha, inv_alpha_hi);
- alpha = _mm_srli_epi32(alpha, 8);
- alpha = _mm_slli_epi32(alpha, 24);
-
- dst2_xmm = _mm_or_si128(red, green);
- dst2_xmm = _mm_or_si128(dst2_xmm, blue);
- dst2_xmm = _mm_or_si128(dst2_xmm, alpha);
-
- _mm_storeu_si128((__m128i*)&dst[wt], dst_xmm);
- _mm_storeu_si128((__m128i*)&dst[wt+4], dst2_xmm);
+ __m128i srcR = _mm_set1_epi32(original_color & 0xFF);
+ __m128i srcG = _mm_set1_epi32((original_color & 0xFF00) >> 8);
+ __m128i srcB = _mm_set1_epi32((original_color & 0xFF0000) >> 16);
+ __m128i src_alpha = _mm_set1_epi16((original_color & 0xFF000000) >> 24);
+
+ __m128i alpha_mask = _mm_loadu_si128((__m128i*)&s[wt * 2]);
+
+ // Zero upper 8 bits of alpha mask since we don't need it
+ alpha_mask = _mm_and_si128(alpha_mask, low_mask);
+
+ alpha_mask = _mm_mullo_epi16(alpha_mask, src_alpha);
+
+ alpha_mask = _mm_srli_epi16(alpha_mask, 6);
+ alpha_mask = _mm_and_si128(alpha_mask, low_mask);
+
+ __m128i inv_alpha = _mm_sub_epi16(inv_one, alpha_mask);
+
+ alpha_mask = _mm_add_epi16(alpha_mask, one);
+
+ __m128i dst_xmm = _mm_loadu_si128((__m128i*)&dst[wt]);
+ __m128i dst2_xmm = _mm_loadu_si128((__m128i*)&dst[wt + 4]);
+
+ __m128i alpha_mask_hi = _mm_unpackhi_epi16(alpha_mask, zero);
+ __m128i inv_alpha_hi = _mm_unpackhi_epi16(inv_alpha, zero);
+
+ alpha_mask = _mm_unpacklo_epi16(alpha_mask, zero);
+ inv_alpha = _mm_unpacklo_epi16(inv_alpha, zero);
+
+ __m128i red = _mm_and_si128(dst_xmm, red_mask);
+ red = _mm_mullo_epi16(red, inv_alpha);
+ red = _mm_add_epi16(red, _mm_mullo_epi16(srcR, alpha_mask));
+ red = _mm_srli_epi16(red, 8);
+
+ __m128i green = _mm_and_si128(dst_xmm, green_mask);
+ green = _mm_srli_epi32(green, 8);
+ green = _mm_mullo_epi16(green, inv_alpha);
+ green = _mm_add_epi16(green, _mm_mullo_epi16(srcG, alpha_mask));
+ green = _mm_srli_epi32(green, 8);
+ green = _mm_slli_epi32(green, 8);
+
+ __m128i blue = _mm_and_si128(dst_xmm, blue_mask);
+ blue = _mm_srli_epi32(blue, 16);
+ blue = _mm_mullo_epi16(blue, inv_alpha);
+ blue = _mm_add_epi16(blue, _mm_mullo_epi16(srcB, alpha_mask));
+ blue = _mm_srli_epi32(blue, 8);
+ blue = _mm_slli_epi32(blue, 16);
+
+ __m128i alpha = _mm_and_si128(dst_xmm, alpha_bit_mask);
+ alpha = _mm_srli_epi32(alpha, 24);
+ alpha = _mm_mullo_epi16(alpha, inv_alpha);
+ alpha = _mm_srli_epi32(alpha, 8);
+ alpha = _mm_slli_epi32(alpha, 24);
+
+ dst_xmm = _mm_or_si128(red, green);
+ dst_xmm = _mm_or_si128(dst_xmm, blue);
+ dst_xmm = _mm_or_si128(dst_xmm, alpha);
+
+ // Next 4 pixels
+ red = _mm_and_si128(dst2_xmm, red_mask);
+ red = _mm_mullo_epi16(red, inv_alpha_hi);
+ red = _mm_add_epi16(red, _mm_mullo_epi16(srcR, alpha_mask_hi));
+ red = _mm_srli_epi16(red, 8);
+
+ green = _mm_and_si128(dst2_xmm, green_mask);
+ green = _mm_srli_epi32(green, 8);
+ green = _mm_mullo_epi16(green, inv_alpha_hi);
+ green = _mm_add_epi16(green, _mm_mullo_epi16(srcG, alpha_mask_hi));
+ green = _mm_srli_epi32(green, 8);
+ green = _mm_slli_epi32(green, 8);
+
+ blue = _mm_and_si128(dst2_xmm, blue_mask);
+ blue = _mm_srli_epi32(blue, 16);
+ blue = _mm_mullo_epi16(blue, inv_alpha_hi);
+ blue = _mm_add_epi16(blue, _mm_mullo_epi16(srcB, alpha_mask_hi));
+ blue = _mm_srli_epi32(blue, 8);
+ blue = _mm_slli_epi32(blue, 16);
+
+ alpha = _mm_and_si128(dst2_xmm, alpha_bit_mask);
+ alpha = _mm_srli_epi32(alpha, 24);
+ alpha = _mm_mullo_epi16(alpha, inv_alpha_hi);
+ alpha = _mm_srli_epi32(alpha, 8);
+ alpha = _mm_slli_epi32(alpha, 24);
+
+ dst2_xmm = _mm_or_si128(red, green);
+ dst2_xmm = _mm_or_si128(dst2_xmm, blue);
+ dst2_xmm = _mm_or_si128(dst2_xmm, alpha);
+
+ _mm_storeu_si128((__m128i*)&dst[wt], dst_xmm);
+ _mm_storeu_si128((__m128i*)&dst[wt + 4], dst2_xmm);
}
static __forceinline void pixmix_sse2(DWORD* dst, DWORD color, DWORD alpha)
{
- alpha = (((alpha) * (color>>24)) >> 6) & 0xff;
- color &= 0xffffff;
+ alpha = (((alpha) * (color >> 24)) >> 6) & 0xff;
+ color &= 0xffffff;
- __m128i zero = _mm_setzero_si128();
- __m128i a = _mm_set1_epi32(((alpha+1) << 16) | (0x100 - alpha));
- __m128i d = _mm_unpacklo_epi8(_mm_cvtsi32_si128(*dst), zero);
- __m128i s = _mm_unpacklo_epi8(_mm_cvtsi32_si128(color), zero);
- __m128i r = _mm_unpacklo_epi16(d, s);
+ __m128i zero = _mm_setzero_si128();
+ __m128i a = _mm_set1_epi32(((alpha + 1) << 16) | (0x100 - alpha));
+ __m128i d = _mm_unpacklo_epi8(_mm_cvtsi32_si128(*dst), zero);
+ __m128i s = _mm_unpacklo_epi8(_mm_cvtsi32_si128(color), zero);
+ __m128i r = _mm_unpacklo_epi16(d, s);
- r = _mm_madd_epi16(r, a);
- r = _mm_srli_epi32(r, 8);
- r = _mm_packs_epi32(r, r);
- r = _mm_packus_epi16(r, r);
+ r = _mm_madd_epi16(r, a);
+ r = _mm_srli_epi32(r, 8);
+ r = _mm_packs_epi32(r, r);
+ r = _mm_packus_epi16(r, r);
- *dst = (DWORD)_mm_cvtsi128_si32(r);
+ *dst = (DWORD)_mm_cvtsi128_si32(r);
}
static __forceinline void pixmix2_sse2(DWORD* dst, DWORD color, DWORD shapealpha, DWORD clipalpha)
{
- DWORD alpha = (((shapealpha)*(clipalpha)*(color>>24))>>12)&0xff;
- color &= 0xffffff;
+ DWORD alpha = (((shapealpha) * (clipalpha) * (color >> 24)) >> 12) & 0xff;
+ color &= 0xffffff;
- __m128i zero = _mm_setzero_si128();
- __m128i a = _mm_set1_epi32(((alpha+1) << 16) | (0x100 - alpha));
- __m128i d = _mm_unpacklo_epi8(_mm_cvtsi32_si128(*dst), zero);
- __m128i s = _mm_unpacklo_epi8(_mm_cvtsi32_si128(color), zero);
- __m128i r = _mm_unpacklo_epi16(d, s);
+ __m128i zero = _mm_setzero_si128();
+ __m128i a = _mm_set1_epi32(((alpha + 1) << 16) | (0x100 - alpha));
+ __m128i d = _mm_unpacklo_epi8(_mm_cvtsi32_si128(*dst), zero);
+ __m128i s = _mm_unpacklo_epi8(_mm_cvtsi32_si128(color), zero);
+ __m128i r = _mm_unpacklo_epi16(d, s);
- r = _mm_madd_epi16(r, a);
- r = _mm_srli_epi32(r, 8);
- r = _mm_packs_epi32(r, r);
- r = _mm_packus_epi16(r, r);
+ r = _mm_madd_epi16(r, a);
+ r = _mm_srli_epi32(r, 8);
+ r = _mm_packs_epi32(r, r);
+ r = _mm_packus_epi16(r, r);
- *dst = (DWORD)_mm_cvtsi128_si32(r);
+ *dst = (DWORD)_mm_cvtsi128_si32(r);
}
// Calculate a - b clamping to 0 instead of underflowing
static __forceinline DWORD safe_subtract(DWORD a, DWORD b)
{
#ifndef _WIN64
- __m64 ap = _mm_cvtsi32_si64(a);
- __m64 bp = _mm_cvtsi32_si64(b);
- __m64 rp = _mm_subs_pu16(ap, bp);
- DWORD r = (DWORD)_mm_cvtsi64_si32(rp);
- _mm_empty();
- return r;
+ __m64 ap = _mm_cvtsi32_si64(a);
+ __m64 bp = _mm_cvtsi32_si64(b);
+ __m64 rp = _mm_subs_pu16(ap, bp);
+ DWORD r = (DWORD)_mm_cvtsi64_si32(rp);
+ _mm_empty();
+ return r;
#else
- // For whatever reason Microsoft's x64 compiler doesn't support MMX intrinsics
- return (b > a) ? 0 : a - b;
+ // For whatever reason Microsoft's x64 compiler doesn't support MMX intrinsics
+ return (b > a) ? 0 : a - b;
#endif
}
static __forceinline DWORD safe_subtract_sse2(DWORD a, DWORD b)
{
- __m128i ap = _mm_cvtsi32_si128(a);
- __m128i bp = _mm_cvtsi32_si128(b);
- __m128i rp = _mm_subs_epu16(ap, bp);
+ __m128i ap = _mm_cvtsi32_si128(a);
+ __m128i bp = _mm_cvtsi32_si128(b);
+ __m128i rp = _mm_subs_epu16(ap, bp);
- return (DWORD)_mm_cvtsi128_si32(rp);
+ return (DWORD)_mm_cvtsi128_si32(rp);
}
static const __int64 _00ff00ff00ff00ff = 0x00ff00ff00ff00ffi64;
@@ -1052,383 +1052,382 @@ static const __int64 _00ff00ff00ff00ff = 0x00ff00ff00ff00ffi64;
// some helper procedures (Draw is so big)
void Rasterizer::Draw_noAlpha_spFF_Body_0(RasterizerNfo& rnfo)
{
- int h = rnfo.h;
- int color = rnfo.color;
-
- byte* s = rnfo.s;
- DWORD* dst = rnfo.dst;
- // The <<6 is due to pixmix expecting the alpha parameter to be
- // the multiplication of two 6-bit unsigned numbers but we
- // only have one here. (No alpha mask.)
- while (h--) {
- for (int wt=0; wt<rnfo.w; ++wt) {
- pixmix(&dst[wt], color, s[wt*2]);
- }
- s += 2*rnfo.overlayp;
- dst = (DWORD*)((char *)dst + rnfo.pitch);
- }
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+ byte* s = rnfo.s;
+ DWORD* dst = rnfo.dst;
+ // The <<6 is due to pixmix expecting the alpha parameter to be
+ // the multiplication of two 6-bit unsigned numbers but we
+ // only have one here. (No alpha mask.)
+ while (h--) {
+ for (int wt = 0; wt < rnfo.w; ++wt) {
+ pixmix(&dst[wt], color, s[wt * 2]);
+ }
+ s += 2 * rnfo.overlayp;
+ dst = (DWORD*)((char*)dst + rnfo.pitch);
+ }
}
void Rasterizer::Draw_noAlpha_spFF_noBody_0(RasterizerNfo& rnfo)
{
- int h = rnfo.h;
- int color = rnfo.color;
-
- byte* src = rnfo.src;
- DWORD* dst = rnfo.dst;
- // src contains two different bitmaps, interlaced per pixel.
- // The first stored is the fill, the second is the widened
- // fill region created by CreateWidenedRegion().
- // Since we're drawing only the border, we must otain that
- // by subtracting the fill from the widened region. The
- // subtraction must be saturating since the widened region
- // pixel value can be smaller than the fill value.
- // This happens when blur edges is used.
- while (h--) {
- for (int wt=0; wt<rnfo.w; ++wt) {
- pixmix(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]));
- }
- src += 2*rnfo.overlayp;
-
- dst = (DWORD*)((char *)dst + rnfo.pitch);
- }
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+ byte* src = rnfo.src;
+ DWORD* dst = rnfo.dst;
+ // src contains two different bitmaps, interlaced per pixel.
+ // The first stored is the fill, the second is the widened
+ // fill region created by CreateWidenedRegion().
+ // Since we're drawing only the border, we must otain that
+ // by subtracting the fill from the widened region. The
+ // subtraction must be saturating since the widened region
+ // pixel value can be smaller than the fill value.
+ // This happens when blur edges is used.
+ while (h--) {
+ for (int wt = 0; wt < rnfo.w; ++wt) {
+ pixmix(&dst[wt], color, safe_subtract(src[wt * 2 + 1], src[wt * 2]));
+ }
+ src += 2 * rnfo.overlayp;
+
+ dst = (DWORD*)((char*)dst + rnfo.pitch);
+ }
}
void Rasterizer::Draw_noAlpha_sp_Body_0(RasterizerNfo& rnfo)
{
- int h = rnfo.h;
- int color = rnfo.color;
-
-
- byte* s = rnfo.s;
- DWORD* dst = rnfo.dst;
- // xo is the offset (usually negative) we have moved into the image
- // So if we have passed the switchpoint (?) switch to another colour
- // (So switchpts stores both colours *and* coordinates?)
- int gran = min((int)rnfo.sw[3]+1-rnfo.xo,rnfo.w);
- int color2 = rnfo.sw[2];
- while (h--) {
- for (int wt=0; wt<gran; ++wt) {
- pixmix(&dst[wt], color, s[wt*2]);
- }
- for (int wt=gran; wt<rnfo.w; ++wt) {
- pixmix(&dst[wt], color2, s[wt*2]);
- }
- s += 2*rnfo.overlayp;
- dst = (DWORD*)((char *)dst + rnfo.pitch);
- }
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+
+ byte* s = rnfo.s;
+ DWORD* dst = rnfo.dst;
+ // xo is the offset (usually negative) we have moved into the image
+ // So if we have passed the switchpoint (?) switch to another colour
+ // (So switchpts stores both colours *and* coordinates?)
+ int gran = min((int)rnfo.sw[3] + 1 - rnfo.xo, rnfo.w);
+ int color2 = rnfo.sw[2];
+ while (h--) {
+ for (int wt = 0; wt < gran; ++wt) {
+ pixmix(&dst[wt], color, s[wt * 2]);
+ }
+ for (int wt = gran; wt < rnfo.w; ++wt) {
+ pixmix(&dst[wt], color2, s[wt * 2]);
+ }
+ s += 2 * rnfo.overlayp;
+ dst = (DWORD*)((char*)dst + rnfo.pitch);
+ }
}
void Rasterizer::Draw_noAlpha_sp_noBody_0(RasterizerNfo& rnfo)
{
- int h = rnfo.h;
- int color = rnfo.color;
-
- byte* src = rnfo.src;
- DWORD* dst = rnfo.dst;
-
- int gran = min((int)rnfo.sw[3]+1-rnfo.xo,rnfo.w);
- int color2 = rnfo.sw[2];
- while (h--) {
- for (int wt=0; wt<gran; ++wt) {
- pixmix(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]));
- }
- for (int wt=gran; wt<rnfo.w; ++wt) {
- pixmix(&dst[wt], color2, safe_subtract(src[wt*2+1], src[wt*2]));
- }
- src += 2*rnfo.overlayp;
- dst = (DWORD*)((char *)dst + rnfo.pitch);
- }
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+ byte* src = rnfo.src;
+ DWORD* dst = rnfo.dst;
+
+ int gran = min((int)rnfo.sw[3] + 1 - rnfo.xo, rnfo.w);
+ int color2 = rnfo.sw[2];
+ while (h--) {
+ for (int wt = 0; wt < gran; ++wt) {
+ pixmix(&dst[wt], color, safe_subtract(src[wt * 2 + 1], src[wt * 2]));
+ }
+ for (int wt = gran; wt < rnfo.w; ++wt) {
+ pixmix(&dst[wt], color2, safe_subtract(src[wt * 2 + 1], src[wt * 2]));
+ }
+ src += 2 * rnfo.overlayp;
+ dst = (DWORD*)((char*)dst + rnfo.pitch);
+ }
}
void Rasterizer::Draw_Alpha_spFF_Body_0(RasterizerNfo& rnfo)
{
- byte* am = rnfo.am;
- int h = rnfo.h;
- int color = rnfo.color;
-
- byte* s = rnfo.s;
- DWORD* dst = rnfo.dst;
- // Both s and am contain 6-bit bitmaps of two different
- // alpha masks; s is the subtitle shape and am is the
- // clipping mask.
- // Multiplying them together yields a 12-bit number.
- // I think some imprecision is introduced here??
- while (h--) {
- for (int wt=0; wt<rnfo.w; ++wt)
- pixmix2(&dst[wt], color, s[wt*2], am[wt]);
- am += rnfo.spdw;
- s += 2*rnfo.overlayp;
- dst = (DWORD*)((char *)dst + rnfo.pitch);
- }
+ byte* am = rnfo.am;
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+ byte* s = rnfo.s;
+ DWORD* dst = rnfo.dst;
+ // Both s and am contain 6-bit bitmaps of two different
+ // alpha masks; s is the subtitle shape and am is the
+ // clipping mask.
+ // Multiplying them together yields a 12-bit number.
+ // I think some imprecision is introduced here??
+ while (h--) {
+ for (int wt = 0; wt < rnfo.w; ++wt) {
+ pixmix2(&dst[wt], color, s[wt * 2], am[wt]);
+ }
+ am += rnfo.spdw;
+ s += 2 * rnfo.overlayp;
+ dst = (DWORD*)((char*)dst + rnfo.pitch);
+ }
}
void Rasterizer::Draw_Alpha_spFF_noBody_0(RasterizerNfo& rnfo)
{
- byte* am = rnfo.am;
- int h = rnfo.h;
- int color = rnfo.color;
-
- byte* src = rnfo.src;
- DWORD* dst = rnfo.dst;
-
- int gran = min((int)rnfo.sw[3]+1-rnfo.xo,rnfo.w);
- int color2 = rnfo.sw[2];
- while (h--) {
- for (int wt=0; wt<gran; ++wt) {
- pixmix2(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]), am[wt]);
- }
- for (int wt=gran; wt<rnfo.w; ++wt) {
- pixmix2(&dst[wt], color2, safe_subtract(src[wt*2+1], src[wt*2]), am[wt]);
- }
- am += rnfo.spdw;
- src += 2*rnfo.overlayp;
- dst = (DWORD*)((char *)dst + rnfo.pitch);
- }
+ byte* am = rnfo.am;
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+ byte* src = rnfo.src;
+ DWORD* dst = rnfo.dst;
+
+ int gran = min((int)rnfo.sw[3] + 1 - rnfo.xo, rnfo.w);
+ int color2 = rnfo.sw[2];
+ while (h--) {
+ for (int wt = 0; wt < gran; ++wt) {
+ pixmix2(&dst[wt], color, safe_subtract(src[wt * 2 + 1], src[wt * 2]), am[wt]);
+ }
+ for (int wt = gran; wt < rnfo.w; ++wt) {
+ pixmix2(&dst[wt], color2, safe_subtract(src[wt * 2 + 1], src[wt * 2]), am[wt]);
+ }
+ am += rnfo.spdw;
+ src += 2 * rnfo.overlayp;
+ dst = (DWORD*)((char*)dst + rnfo.pitch);
+ }
}
void Rasterizer::Draw_Alpha_sp_Body_0(RasterizerNfo& rnfo)
{
- byte* am = rnfo.am;
- int h = rnfo.h;
- int color = rnfo.color;
-
-
- byte* s = rnfo.s;
- DWORD* dst = rnfo.dst;
- while (h--) {
- for (int wt=0; wt<rnfo.w; ++wt) {
- pixmix2(&dst[wt], color, s[wt*2], am[wt]);
- }
- am += rnfo.spdw;
- s += 2*rnfo.overlayp;
- dst = (DWORD*)((char *)dst + rnfo.pitch);
- }
+ byte* am = rnfo.am;
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+
+ byte* s = rnfo.s;
+ DWORD* dst = rnfo.dst;
+ while (h--) {
+ for (int wt = 0; wt < rnfo.w; ++wt) {
+ pixmix2(&dst[wt], color, s[wt * 2], am[wt]);
+ }
+ am += rnfo.spdw;
+ s += 2 * rnfo.overlayp;
+ dst = (DWORD*)((char*)dst + rnfo.pitch);
+ }
}
void Rasterizer::Draw_Alpha_sp_noBody_0(RasterizerNfo& rnfo)
{
- byte* am = rnfo.am;
- int h = rnfo.h;
- int color = rnfo.color;
-
-
- byte* src = rnfo.src;
- DWORD* dst = rnfo.dst;
- int gran = min((int)rnfo.sw[3]+1-rnfo.xo,rnfo.w);
- int color2 = rnfo.sw[2];
- while (h--) {
- for (int wt=0; wt<gran; ++wt) {
- pixmix2(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]), am[wt]);
- }
- for (int wt=gran; wt<rnfo.w; ++wt) {
- pixmix2(&dst[wt], color2, safe_subtract(src[wt*2+1], src[wt*2]), am[wt]);
- }
- am += rnfo.spdw;
- src += 2*rnfo.overlayp;
- dst = (DWORD*)((char *)dst + rnfo.pitch);
- }
+ byte* am = rnfo.am;
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+
+ byte* src = rnfo.src;
+ DWORD* dst = rnfo.dst;
+ int gran = min((int)rnfo.sw[3] + 1 - rnfo.xo, rnfo.w);
+ int color2 = rnfo.sw[2];
+ while (h--) {
+ for (int wt = 0; wt < gran; ++wt) {
+ pixmix2(&dst[wt], color, safe_subtract(src[wt * 2 + 1], src[wt * 2]), am[wt]);
+ }
+ for (int wt = gran; wt < rnfo.w; ++wt) {
+ pixmix2(&dst[wt], color2, safe_subtract(src[wt * 2 + 1], src[wt * 2]), am[wt]);
+ }
+ am += rnfo.spdw;
+ src += 2 * rnfo.overlayp;
+ dst = (DWORD*)((char*)dst + rnfo.pitch);
+ }
}//Draw_Alpha_sp_noBody_0(w,h,xo,spd.w,color,spd.pitch,dst,src,sw,am);
// == SSE2 func ==
void Rasterizer::Draw_noAlpha_spFF_Body_sse2(RasterizerNfo& rnfo)
{
- int h = rnfo.h;
- int color = rnfo.color;
-
- byte* s = rnfo.s;
- DWORD* dst = rnfo.dst;
- // The <<6 is due to pixmix expecting the alpha parameter to be
- // the multiplication of two 6-bit unsigned numbers but we
- // only have one here. (No alpha mask.)
- int w = rnfo.w;
- int end_w = ((w-1)/8)*8;
- while (h--) {
- for (int wt = 0; wt < end_w; wt+=8)
- {
- alpha_blend_sse2(dst, color, s, wt);
- }
- for (int wt=end_w; wt<w; ++wt) {
- pixmix_sse2(&dst[wt], color, s[wt*2]);
- }
- s += 2*rnfo.overlayp;
- dst = (DWORD*)((char *)dst + rnfo.pitch);
- }
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+ byte* s = rnfo.s;
+ DWORD* dst = rnfo.dst;
+ // The <<6 is due to pixmix expecting the alpha parameter to be
+ // the multiplication of two 6-bit unsigned numbers but we
+ // only have one here. (No alpha mask.)
+ int w = rnfo.w;
+ int end_w = ((w - 1) / 8) * 8;
+ while (h--) {
+ for (int wt = 0; wt < end_w; wt += 8) {
+ alpha_blend_sse2(dst, color, s, wt);
+ }
+ for (int wt = end_w; wt < w; ++wt) {
+ pixmix_sse2(&dst[wt], color, s[wt * 2]);
+ }
+ s += 2 * rnfo.overlayp;
+ dst = (DWORD*)((char*)dst + rnfo.pitch);
+ }
}//Draw_noAlpha_spFF_Body_sse2(w,h,color,spd.pitch,dst,s);
void Rasterizer::Draw_noAlpha_spFF_noBody_sse2(RasterizerNfo& rnfo)
{
- int h = rnfo.h;
- int color = rnfo.color;
-
- byte* src = rnfo.src;
- DWORD* dst = rnfo.dst;
- // src contains two different bitmaps, interlaced per pixel.
- // The first stored is the fill, the second is the widened
- // fill region created by CreateWidenedRegion().
- // Since we're drawing only the border, we must otain that
- // by subtracting the fill from the widened region. The
- // subtraction must be saturating since the widened region
- // pixel value can be smaller than the fill value.
- // This happens when blur edges is used.
- while (h--) {
- for (int wt=0; wt<rnfo.w; ++wt) {
- pixmix_sse2(&dst[wt], color, safe_subtract_sse2(src[wt*2+1], src[wt*2]));
- }
- src += 2*rnfo.overlayp;
-
- dst = (DWORD*)((char *)dst + rnfo.pitch);
- }
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+ byte* src = rnfo.src;
+ DWORD* dst = rnfo.dst;
+ // src contains two different bitmaps, interlaced per pixel.
+ // The first stored is the fill, the second is the widened
+ // fill region created by CreateWidenedRegion().
+ // Since we're drawing only the border, we must otain that
+ // by subtracting the fill from the widened region. The
+ // subtraction must be saturating since the widened region
+ // pixel value can be smaller than the fill value.
+ // This happens when blur edges is used.
+ while (h--) {
+ for (int wt = 0; wt < rnfo.w; ++wt) {
+ pixmix_sse2(&dst[wt], color, safe_subtract_sse2(src[wt * 2 + 1], src[wt * 2]));
+ }
+ src += 2 * rnfo.overlayp;
+
+ dst = (DWORD*)((char*)dst + rnfo.pitch);
+ }
}//Draw_noAlpha_spFF_noBody_sse2(w,h,color,spd.pitch,dst,src);
void Rasterizer::Draw_noAlpha_sp_Body_sse2(RasterizerNfo& rnfo)
{
- int h = rnfo.h;
-
- int color = rnfo.color;
-
- byte* s = rnfo.s;
- DWORD* dst = rnfo.dst;
- // xo is the offset (usually negative) we have moved into the image
- // So if we have passed the switchpoint (?) switch to another colour
- // (So switchpts stores both colours *and* coordinates?)
- int gran = min((int)rnfo.sw[3]+1-rnfo.xo,rnfo.w);
- int end_gran = ((gran-1)/8)*8;
- int end_w = gran+((rnfo.w-gran-1)/8)*8;
- int color2 = rnfo.sw[2];
- while (h--) {
- for (int wt=0; wt < end_gran; wt+=8)
- {
- alpha_blend_sse2(dst, color, s, wt);
- }
- for (int wt=end_gran; wt<gran; ++wt) {
- pixmix_sse2(&dst[wt], color, s[wt*2]);
- }
- for (int wt=gran; wt<end_w; wt+=8)
- {
- alpha_blend_sse2(dst, color2, s, wt);
- }
- for (int wt=end_w; wt<rnfo.w; wt++)
- {
- pixmix_sse2(&dst[wt], color2, s[wt*2]);
- }
- s += 2*rnfo.overlayp;
- dst = (DWORD*)((char *)dst + rnfo.pitch);
- }
+ int h = rnfo.h;
+
+ int color = rnfo.color;
+
+ byte* s = rnfo.s;
+ DWORD* dst = rnfo.dst;
+ // xo is the offset (usually negative) we have moved into the image
+ // So if we have passed the switchpoint (?) switch to another colour
+ // (So switchpts stores both colours *and* coordinates?)
+ int gran = min((int)rnfo.sw[3] + 1 - rnfo.xo, rnfo.w);
+ int end_gran = ((gran - 1) / 8) * 8;
+ int end_w = gran + ((rnfo.w - gran - 1) / 8) * 8;
+ int color2 = rnfo.sw[2];
+ while (h--) {
+ for (int wt = 0; wt < end_gran; wt += 8) {
+ alpha_blend_sse2(dst, color, s, wt);
+ }
+ for (int wt = end_gran; wt < gran; ++wt) {
+ pixmix_sse2(&dst[wt], color, s[wt * 2]);
+ }
+ for (int wt = gran; wt < end_w; wt += 8) {
+ alpha_blend_sse2(dst, color2, s, wt);
+ }
+ for (int wt = end_w; wt < rnfo.w; wt++) {
+ pixmix_sse2(&dst[wt], color2, s[wt * 2]);
+ }
+ s += 2 * rnfo.overlayp;
+ dst = (DWORD*)((char*)dst + rnfo.pitch);
+ }
}
void Rasterizer::Draw_noAlpha_sp_noBody_sse2(RasterizerNfo& rnfo)
{
- int h = rnfo.h;
- int color = rnfo.color;
-
-
- byte* src = rnfo.src;
- DWORD* dst = rnfo.dst;
- int gran = min((int)rnfo.sw[3]+1-rnfo.xo,rnfo.w);
- int color2 = rnfo.sw[2];
- while (h--) {
- for (int wt=0; wt<gran; ++wt) {
- pixmix_sse2(&dst[wt], color, safe_subtract_sse2(src[wt*2+1], src[wt*2]));
- }
- for (int wt=gran; wt<rnfo.w; ++wt) {
- pixmix_sse2(&dst[wt], color2, safe_subtract_sse2(src[wt*2+1], src[wt*2]));
- }
- src += 2*rnfo.overlayp;
- dst = (DWORD*)((char *)dst + rnfo.pitch);
- }
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+
+ byte* src = rnfo.src;
+ DWORD* dst = rnfo.dst;
+ int gran = min((int)rnfo.sw[3] + 1 - rnfo.xo, rnfo.w);
+ int color2 = rnfo.sw[2];
+ while (h--) {
+ for (int wt = 0; wt < gran; ++wt) {
+ pixmix_sse2(&dst[wt], color, safe_subtract_sse2(src[wt * 2 + 1], src[wt * 2]));
+ }
+ for (int wt = gran; wt < rnfo.w; ++wt) {
+ pixmix_sse2(&dst[wt], color2, safe_subtract_sse2(src[wt * 2 + 1], src[wt * 2]));
+ }
+ src += 2 * rnfo.overlayp;
+ dst = (DWORD*)((char*)dst + rnfo.pitch);
+ }
}
void Rasterizer::Draw_Alpha_spFF_Body_sse2(RasterizerNfo& rnfo)
{
- byte* am = rnfo.am;
- int h = rnfo.h;
- int color = rnfo.color;
-
- byte* s = rnfo.s;
- DWORD* dst = rnfo.dst;
- // Both s and am contain 6-bit bitmaps of two different
- // alpha masks; s is the subtitle shape and am is the
- // clipping mask.
- // Multiplying them together yields a 12-bit number.
- // I think some imprecision is introduced here??
- while (h--) {
- for (int wt=0; wt<rnfo.w; ++wt)
- pixmix2_sse2(&dst[wt], color, s[wt*2], am[wt]);
- am += rnfo.spdw;
- s += 2*rnfo.overlayp;
- dst = (DWORD*)((char *)dst + rnfo.pitch);
- }
+ byte* am = rnfo.am;
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+ byte* s = rnfo.s;
+ DWORD* dst = rnfo.dst;
+ // Both s and am contain 6-bit bitmaps of two different
+ // alpha masks; s is the subtitle shape and am is the
+ // clipping mask.
+ // Multiplying them together yields a 12-bit number.
+ // I think some imprecision is introduced here??
+ while (h--) {
+ for (int wt = 0; wt < rnfo.w; ++wt) {
+ pixmix2_sse2(&dst[wt], color, s[wt * 2], am[wt]);
+ }
+ am += rnfo.spdw;
+ s += 2 * rnfo.overlayp;
+ dst = (DWORD*)((char*)dst + rnfo.pitch);
+ }
}
void Rasterizer::Draw_Alpha_spFF_noBody_sse2(RasterizerNfo& rnfo)
{
- byte* am = rnfo.am;
- int h = rnfo.h;
- int color = rnfo.color;
-
- byte* src = rnfo.src;
- DWORD* dst = rnfo.dst;
-
- while (h--) {
- for (int wt=0; wt<rnfo.w; ++wt)
- pixmix2_sse2(&dst[wt], color, safe_subtract_sse2(src[wt*2+1], src[wt*2]), am[wt]);
- am += rnfo.spdw;
- src += 2*rnfo.overlayp;
- dst = (DWORD*)((char *)dst + rnfo.pitch);
- }
+ byte* am = rnfo.am;
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+ byte* src = rnfo.src;
+ DWORD* dst = rnfo.dst;
+
+ while (h--) {
+ for (int wt = 0; wt < rnfo.w; ++wt) {
+ pixmix2_sse2(&dst[wt], color, safe_subtract_sse2(src[wt * 2 + 1], src[wt * 2]), am[wt]);
+ }
+ am += rnfo.spdw;
+ src += 2 * rnfo.overlayp;
+ dst = (DWORD*)((char*)dst + rnfo.pitch);
+ }
}
void Rasterizer::Draw_Alpha_sp_Body_sse2(RasterizerNfo& rnfo)
{
- byte* am = rnfo.am;
- int h = rnfo.h;
- int color = rnfo.color;
-
-
- byte* s = rnfo.s;
- DWORD* dst = rnfo.dst;
-
- int gran = min((int)rnfo.sw[3]+1-rnfo.xo,rnfo.w);
- int color2 = rnfo.sw[2];
- while (h--) {
- for (int wt=0; wt<gran; ++wt) {
- pixmix2_sse2(&dst[wt], color, s[wt*2], am[wt]);
- }
- for (int wt=gran; wt<rnfo.w; ++wt) {
- pixmix2_sse2(&dst[wt], color2, s[wt*2], am[wt]);
- }
- am += rnfo.spdw;
- s += 2*rnfo.overlayp;
- dst = (DWORD*)((char *)dst + rnfo.pitch);
- }
+ byte* am = rnfo.am;
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+
+ byte* s = rnfo.s;
+ DWORD* dst = rnfo.dst;
+
+ int gran = min((int)rnfo.sw[3] + 1 - rnfo.xo, rnfo.w);
+ int color2 = rnfo.sw[2];
+ while (h--) {
+ for (int wt = 0; wt < gran; ++wt) {
+ pixmix2_sse2(&dst[wt], color, s[wt * 2], am[wt]);
+ }
+ for (int wt = gran; wt < rnfo.w; ++wt) {
+ pixmix2_sse2(&dst[wt], color2, s[wt * 2], am[wt]);
+ }
+ am += rnfo.spdw;
+ s += 2 * rnfo.overlayp;
+ dst = (DWORD*)((char*)dst + rnfo.pitch);
+ }
}
void Rasterizer::Draw_Alpha_sp_noBody_sse2(RasterizerNfo& rnfo)
{
- byte* am = rnfo.am;
- int h = rnfo.h;
-
- DWORD color = rnfo.color;
-
- byte* src = rnfo.src;
- DWORD* dst = rnfo.dst;
-
- int gran = min((int)rnfo.sw[3]+1-rnfo.xo,rnfo.w);
- int color2 = rnfo.sw[2];
- UNREFERENCED_PARAMETER(color2);
-
- while (h--) {
- for (int wt=0; wt<gran; ++wt) {
- pixmix2_sse2(&dst[wt], color, safe_subtract_sse2(src[wt*2+1], src[wt*2]), am[wt]);
- }
- for (int wt=gran; wt<rnfo.w; ++wt) {
- pixmix2_sse2(&dst[wt], color, safe_subtract_sse2(src[wt*2+1], src[wt*2]), am[wt]);
- }
- am += rnfo.spdw;
- src += 2*rnfo.overlayp;
- dst = (DWORD*)((char *)dst + rnfo.pitch);
- }
+ byte* am = rnfo.am;
+ int h = rnfo.h;
+
+ DWORD color = rnfo.color;
+
+ byte* src = rnfo.src;
+ DWORD* dst = rnfo.dst;
+
+ int gran = min((int)rnfo.sw[3] + 1 - rnfo.xo, rnfo.w);
+ int color2 = rnfo.sw[2];
+ UNREFERENCED_PARAMETER(color2);
+
+ while (h--) {
+ for (int wt = 0; wt < gran; ++wt) {
+ pixmix2_sse2(&dst[wt], color, safe_subtract_sse2(src[wt * 2 + 1], src[wt * 2]), am[wt]);
+ }
+ for (int wt = gran; wt < rnfo.w; ++wt) {
+ pixmix2_sse2(&dst[wt], color, safe_subtract_sse2(src[wt * 2 + 1], src[wt * 2]), am[wt]);
+ }
+ am += rnfo.spdw;
+ src += 2 * rnfo.overlayp;
+ dst = (DWORD*)((char*)dst + rnfo.pitch);
+ }
}
// Render a subpicture onto a surface.
@@ -1441,198 +1440,198 @@ void Rasterizer::Draw_Alpha_sp_noBody_sse2(RasterizerNfo& rnfo)
// fBody tells whether to render the body of the subs.
// fBorder tells whether to render the border of the subs.
CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int xsub, int ysub,
- const DWORD* switchpts, bool fBody, bool fBorder)
+ const DWORD* switchpts, bool fBody, bool fBorder)
{
- CRect bbox(0, 0, 0, 0);
-
- if (!switchpts || !fBody && !fBorder) {
- return bbox;
- }
-
- // Limit drawn area to intersection of rendering surface and rectangular clip area
- CRect r(0, 0, spd.w, spd.h);
- r &= clipRect;
-
- // Remember that all subtitle coordinates are specified in 1/8 pixels
- // (x+4)>>3 rounds to nearest whole pixel.
- // ??? What is xsub, ysub, mOffsetX and mOffsetY ?
- int x = (xsub + mOffsetX + 4)>>3;
- int y = (ysub + mOffsetY + 4)>>3;
- int w = mOverlayWidth;
- int h = mOverlayHeight;
- int xo = 0, yo = 0;
-
- // Again, limiting?
- if (x < r.left) {
- xo = r.left-x;
- w -= r.left-x;
- x = r.left;
- }
- if (y < r.top) {
- yo = r.top-y;
- h -= r.top-y;
- y = r.top;
- }
- if (x+w > r.right) {
- w = r.right-x;
- }
- if (y+h > r.bottom) {
- h = r.bottom-y;
- }
-
- // Check if there's actually anything to render
- if (w <= 0 || h <= 0) {
- return bbox;
- }
-
- bbox.SetRect(x, y, x+w, y+h);
- bbox &= CRect(0, 0, spd.w, spd.h);
-
- // CPUID from VDub
- bool fSSE2 = !!(g_cpuid.m_flags & CCpuID::sse2);
-
- // fill rasterize info
- RasterizerNfo rnfo;
- // Grab the first colour
- rnfo.color = switchpts[0];
- // How would this differ from src?
- rnfo.dst = (DWORD*)((char *)spd.bits + (spd.pitch * y)) + x;
- rnfo.sw = switchpts;
-
- rnfo.w = w;
- rnfo.h = h;
- rnfo.xo = xo;
- rnfo.yo = yo;
- rnfo.overlayp = mOverlayWidth;
- rnfo.pitch = spd.pitch;
- rnfo.spdw = spd.w;
- // The alpha bitmap of the subtitles?
- rnfo.src = mpOverlayBuffer + 2*(mOverlayWidth * yo + xo);
- // s points to what the "body" to use is
- // If we're rendering body fill and border, src+1 points to the array of
- // widened regions which contain both border and fill in one.
- rnfo.s = fBorder ? (rnfo.src+1) : rnfo.src;
- // The complex "vector clip mask" I think.
- rnfo.am = pAlphaMask + spd.w * y + x;
- // Every remaining line in the bitmap to be rendered...
- // Basic case of no complex clipping mask
- if (!pAlphaMask) {
- // If the first colour switching coordinate is at "infinite" we're
- // never switching and can use some simpler code.
- // ??? Is this optimisation really worth the extra readability issues it adds?
- if (switchpts[1] == 0xFFFFFFFF) {
- // fBody is true if we're rendering a fill or a shadow.
- if (fBody) {
- if (fSSE2) {
- Draw_noAlpha_spFF_Body_sse2(rnfo);
- } else {
- Draw_noAlpha_spFF_Body_0(rnfo);
- }
- }
- // Not painting body, ie. painting border without fill in it
- else {
- if (fSSE2) {
- Draw_noAlpha_spFF_noBody_sse2(rnfo);
- } else {
- Draw_noAlpha_spFF_noBody_0(rnfo);
- }
- }
- }
- // not (switchpts[1] == 0xFFFFFFFF)
- else {
- // switchpts plays an important rule here
- //const long *sw = switchpts;
-
- if (fBody) {
- if (fSSE2) {
- Draw_noAlpha_sp_Body_sse2(rnfo);
- } else {
- Draw_noAlpha_sp_Body_0(rnfo);
- }
- }
- // Not body
- else {
- if (fSSE2) {
- Draw_noAlpha_sp_noBody_sse2(rnfo);
- } else {
- Draw_noAlpha_sp_noBody_0(rnfo);
- }
- }
- }
- }
- // Here we *do* have an alpha mask
- else {
- if (switchpts[1] == 0xFFFFFFFF) {
- if (fBody) {
- if (fSSE2) {
- Draw_Alpha_spFF_Body_sse2(rnfo);
- } else {
- Draw_Alpha_spFF_Body_0(rnfo);
- }
- } else {
- if (fSSE2) {
- Draw_Alpha_spFF_noBody_sse2(rnfo);
- } else {
- Draw_Alpha_spFF_noBody_0(rnfo);
- }
- }
- } else {
- //const long *sw = switchpts;
-
- if (fBody) {
- if (fSSE2) {
- Draw_Alpha_sp_Body_sse2(rnfo);
- } else {
- Draw_Alpha_sp_Body_0(rnfo);
- }
- } else {
- if (fSSE2) {
- Draw_Alpha_sp_noBody_sse2(rnfo);
- } else {
- Draw_Alpha_sp_noBody_0(rnfo);
- }
- }
- }
- }
- // Remember to EMMS!
- // Rendering fails in funny ways if we don't do this.
- _mm_empty();
-
- return bbox;
+ CRect bbox(0, 0, 0, 0);
+
+ if (!switchpts || !fBody && !fBorder) {
+ return bbox;
+ }
+
+ // Limit drawn area to intersection of rendering surface and rectangular clip area
+ CRect r(0, 0, spd.w, spd.h);
+ r &= clipRect;
+
+ // Remember that all subtitle coordinates are specified in 1/8 pixels
+ // (x+4)>>3 rounds to nearest whole pixel.
+ // ??? What is xsub, ysub, mOffsetX and mOffsetY ?
+ int x = (xsub + mOffsetX + 4) >> 3;
+ int y = (ysub + mOffsetY + 4) >> 3;
+ int w = mOverlayWidth;
+ int h = mOverlayHeight;
+ int xo = 0, yo = 0;
+
+ // Again, limiting?
+ if (x < r.left) {
+ xo = r.left - x;
+ w -= r.left - x;
+ x = r.left;
+ }
+ if (y < r.top) {
+ yo = r.top - y;
+ h -= r.top - y;
+ y = r.top;
+ }
+ if (x + w > r.right) {
+ w = r.right - x;
+ }
+ if (y + h > r.bottom) {
+ h = r.bottom - y;
+ }
+
+ // Check if there's actually anything to render
+ if (w <= 0 || h <= 0) {
+ return bbox;
+ }
+
+ bbox.SetRect(x, y, x + w, y + h);
+ bbox &= CRect(0, 0, spd.w, spd.h);
+
+ // CPUID from VDub
+ bool fSSE2 = !!(g_cpuid.m_flags & CCpuID::sse2);
+
+ // fill rasterize info
+ RasterizerNfo rnfo;
+ // Grab the first colour
+ rnfo.color = switchpts[0];
+ // How would this differ from src?
+ rnfo.dst = (DWORD*)((char*)spd.bits + (spd.pitch * y)) + x;
+ rnfo.sw = switchpts;
+
+ rnfo.w = w;
+ rnfo.h = h;
+ rnfo.xo = xo;
+ rnfo.yo = yo;
+ rnfo.overlayp = mOverlayWidth;
+ rnfo.pitch = spd.pitch;
+ rnfo.spdw = spd.w;
+ // The alpha bitmap of the subtitles?
+ rnfo.src = mpOverlayBuffer + 2 * (mOverlayWidth * yo + xo);
+ // s points to what the "body" to use is
+ // If we're rendering body fill and border, src+1 points to the array of
+ // widened regions which contain both border and fill in one.
+ rnfo.s = fBorder ? (rnfo.src + 1) : rnfo.src;
+ // The complex "vector clip mask" I think.
+ rnfo.am = pAlphaMask + spd.w * y + x;
+ // Every remaining line in the bitmap to be rendered...
+ // Basic case of no complex clipping mask
+ if (!pAlphaMask) {
+ // If the first colour switching coordinate is at "infinite" we're
+ // never switching and can use some simpler code.
+ // ??? Is this optimisation really worth the extra readability issues it adds?
+ if (switchpts[1] == 0xFFFFFFFF) {
+ // fBody is true if we're rendering a fill or a shadow.
+ if (fBody) {
+ if (fSSE2) {
+ Draw_noAlpha_spFF_Body_sse2(rnfo);
+ } else {
+ Draw_noAlpha_spFF_Body_0(rnfo);
+ }
+ }
+ // Not painting body, ie. painting border without fill in it
+ else {
+ if (fSSE2) {
+ Draw_noAlpha_spFF_noBody_sse2(rnfo);
+ } else {
+ Draw_noAlpha_spFF_noBody_0(rnfo);
+ }
+ }
+ }
+ // not (switchpts[1] == 0xFFFFFFFF)
+ else {
+ // switchpts plays an important rule here
+ //const long *sw = switchpts;
+
+ if (fBody) {
+ if (fSSE2) {
+ Draw_noAlpha_sp_Body_sse2(rnfo);
+ } else {
+ Draw_noAlpha_sp_Body_0(rnfo);
+ }
+ }
+ // Not body
+ else {
+ if (fSSE2) {
+ Draw_noAlpha_sp_noBody_sse2(rnfo);
+ } else {
+ Draw_noAlpha_sp_noBody_0(rnfo);
+ }
+ }
+ }
+ }
+ // Here we *do* have an alpha mask
+ else {
+ if (switchpts[1] == 0xFFFFFFFF) {
+ if (fBody) {
+ if (fSSE2) {
+ Draw_Alpha_spFF_Body_sse2(rnfo);
+ } else {
+ Draw_Alpha_spFF_Body_0(rnfo);
+ }
+ } else {
+ if (fSSE2) {
+ Draw_Alpha_spFF_noBody_sse2(rnfo);
+ } else {
+ Draw_Alpha_spFF_noBody_0(rnfo);
+ }
+ }
+ } else {
+ //const long *sw = switchpts;
+
+ if (fBody) {
+ if (fSSE2) {
+ Draw_Alpha_sp_Body_sse2(rnfo);
+ } else {
+ Draw_Alpha_sp_Body_0(rnfo);
+ }
+ } else {
+ if (fSSE2) {
+ Draw_Alpha_sp_noBody_sse2(rnfo);
+ } else {
+ Draw_Alpha_sp_noBody_0(rnfo);
+ }
+ }
+ }
+ }
+ // Remember to EMMS!
+ // Rendering fails in funny ways if we don't do this.
+ _mm_empty();
+
+ return bbox;
}
void Rasterizer::FillSolidRect(SubPicDesc& spd, int x, int y, int nWidth, int nHeight, DWORD lColor)
{
- bool fSSE2 = !!(g_cpuid.m_flags & CCpuID::sse2);
-
- for (int wy=y; wy<y+nHeight; wy++) {
- DWORD* dst = (DWORD*)((BYTE*)spd.bits + spd.pitch * wy) + x;
- for (int wt=0; wt<nWidth; ++wt) {
- if (fSSE2) {
- pixmix_sse2(&dst[wt], lColor, 0x40); // 0x40 because >> 6 in pixmix (to preserve tranparency)
- } else {
- pixmix(&dst[wt], lColor, 0x40);
- }
- }
- }
+ bool fSSE2 = !!(g_cpuid.m_flags & CCpuID::sse2);
+
+ for (int wy = y; wy < y + nHeight; wy++) {
+ DWORD* dst = (DWORD*)((BYTE*)spd.bits + spd.pitch * wy) + x;
+ for (int wt = 0; wt < nWidth; ++wt) {
+ if (fSSE2) {
+ pixmix_sse2(&dst[wt], lColor, 0x40); // 0x40 because >> 6 in pixmix (to preserve tranparency)
+ } else {
+ pixmix(&dst[wt], lColor, 0x40);
+ }
+ }
+ }
}
RasterizerNfo::RasterizerNfo()
{
- /*
- w = 0;
- h = 0;
- spdw = 0;
- overlayp = 0;
- typ = 0;
- pitch = 0;
- color = 0;
-
- xo = 0;
-
- sw = NULL;
- s = NULL;
- src = NULL;
- dst = NULL;
- */
+ /*
+ w = 0;
+ h = 0;
+ spdw = 0;
+ overlayp = 0;
+ typ = 0;
+ pitch = 0;
+ color = 0;
+
+ xo = 0;
+
+ sw = NULL;
+ s = NULL;
+ src = NULL;
+ dst = NULL;
+ */
}
diff --git a/src/Subtitles/Rasterizer.h b/src/Subtitles/Rasterizer.h
index 5531f463e..c324a4ecd 100644
--- a/src/Subtitles/Rasterizer.h
+++ b/src/Subtitles/Rasterizer.h
@@ -33,103 +33,103 @@
class RasterizerNfo
{
public:
- int w;
- int h;
- int spdw;
- int overlayp;
- int pitch;
- DWORD color;
+ int w;
+ int h;
+ int spdw;
+ int overlayp;
+ int pitch;
+ DWORD color;
- int xo;
- int yo;
+ int xo;
+ int yo;
- const DWORD* sw;
- byte* s;
- byte* src;
- DWORD* dst;
+ const DWORD* sw;
+ byte* s;
+ byte* src;
+ DWORD* dst;
- byte* am;
+ byte* am;
- RasterizerNfo();
+ RasterizerNfo();
};
class Rasterizer
{
- bool fFirstSet;
- CPoint firstp, lastp;
+ bool fFirstSet;
+ CPoint firstp, lastp;
protected:
- BYTE* mpPathTypes;
- POINT* mpPathPoints;
- int mPathPoints;
+ BYTE* mpPathTypes;
+ POINT* mpPathPoints;
+ int mPathPoints;
private:
- int mWidth, mHeight;
+ int mWidth, mHeight;
- typedef std::pair<unsigned __int64, unsigned __int64> tSpan;
- typedef std::vector<tSpan> tSpanBuffer;
+ typedef std::pair<unsigned __int64, unsigned __int64> tSpan;
+ typedef std::vector<tSpan> tSpanBuffer;
- tSpanBuffer mOutline;
- tSpanBuffer mWideOutline;
- int mWideBorder;
+ tSpanBuffer mOutline;
+ tSpanBuffer mWideOutline;
+ int mWideBorder;
- struct Edge {
- int next;
- int posandflag;
- } *mpEdgeBuffer;
- unsigned int mEdgeHeapSize;
- unsigned int mEdgeNext;
+ struct Edge {
+ int next;
+ int posandflag;
+ }* mpEdgeBuffer;
+ unsigned int mEdgeHeapSize;
+ unsigned int mEdgeNext;
- unsigned int* mpScanBuffer;
+ unsigned int* mpScanBuffer;
- typedef unsigned char byte;
+ typedef unsigned char byte;
protected:
- int mPathOffsetX, mPathOffsetY;
- int mOffsetX, mOffsetY;
- int mOverlayWidth, mOverlayHeight;
- byte *mpOverlayBuffer;
+ int mPathOffsetX, mPathOffsetY;
+ int mOffsetX, mOffsetY;
+ int mOverlayWidth, mOverlayHeight;
+ byte* mpOverlayBuffer;
private:
- void _TrashPath();
- void _TrashOverlay();
- void _ReallocEdgeBuffer(int edges);
- void _EvaluateBezier(int ptbase, bool fBSpline);
- void _EvaluateLine(int pt1idx, int pt2idx);
- void _EvaluateLine(int x0, int y0, int x1, int y1);
- static void _OverlapRegion(tSpanBuffer& dst, tSpanBuffer& src, int dx, int dy);
- // helpers
- void Draw_noAlpha_spFF_Body_0(RasterizerNfo& rnfo);
- void Draw_noAlpha_spFF_noBody_0(RasterizerNfo& rnfo);
- void Draw_noAlpha_sp_Body_0(RasterizerNfo& rnfo);
- void Draw_noAlpha_sp_noBody_0(RasterizerNfo& rnfo);
- void Draw_noAlpha_spFF_Body_sse2(RasterizerNfo& rnfo);
- void Draw_noAlpha_spFF_noBody_sse2(RasterizerNfo& rnfo);
- void Draw_noAlpha_sp_Body_sse2(RasterizerNfo& rnfo);
- void Draw_noAlpha_sp_noBody_sse2(RasterizerNfo& rnfo);
- void Draw_Alpha_spFF_Body_0(RasterizerNfo& rnfo);
- void Draw_Alpha_spFF_noBody_0(RasterizerNfo& rnfo);
- void Draw_Alpha_sp_Body_0(RasterizerNfo& rnfo);
- void Draw_Alpha_sp_noBody_0(RasterizerNfo& rnfo);
- void Draw_Alpha_spFF_Body_sse2(RasterizerNfo& rnfo);
- void Draw_Alpha_spFF_noBody_sse2(RasterizerNfo& rnfo);
- void Draw_Alpha_sp_Body_sse2(RasterizerNfo& rnfo);
- void Draw_Alpha_sp_noBody_sse2(RasterizerNfo& rnfo);
+ void _TrashPath();
+ void _TrashOverlay();
+ void _ReallocEdgeBuffer(int edges);
+ void _EvaluateBezier(int ptbase, bool fBSpline);
+ void _EvaluateLine(int pt1idx, int pt2idx);
+ void _EvaluateLine(int x0, int y0, int x1, int y1);
+ static void _OverlapRegion(tSpanBuffer& dst, tSpanBuffer& src, int dx, int dy);
+ // helpers
+ void Draw_noAlpha_spFF_Body_0(RasterizerNfo& rnfo);
+ void Draw_noAlpha_spFF_noBody_0(RasterizerNfo& rnfo);
+ void Draw_noAlpha_sp_Body_0(RasterizerNfo& rnfo);
+ void Draw_noAlpha_sp_noBody_0(RasterizerNfo& rnfo);
+ void Draw_noAlpha_spFF_Body_sse2(RasterizerNfo& rnfo);
+ void Draw_noAlpha_spFF_noBody_sse2(RasterizerNfo& rnfo);
+ void Draw_noAlpha_sp_Body_sse2(RasterizerNfo& rnfo);
+ void Draw_noAlpha_sp_noBody_sse2(RasterizerNfo& rnfo);
+ void Draw_Alpha_spFF_Body_0(RasterizerNfo& rnfo);
+ void Draw_Alpha_spFF_noBody_0(RasterizerNfo& rnfo);
+ void Draw_Alpha_sp_Body_0(RasterizerNfo& rnfo);
+ void Draw_Alpha_sp_noBody_0(RasterizerNfo& rnfo);
+ void Draw_Alpha_spFF_Body_sse2(RasterizerNfo& rnfo);
+ void Draw_Alpha_spFF_noBody_sse2(RasterizerNfo& rnfo);
+ void Draw_Alpha_sp_Body_sse2(RasterizerNfo& rnfo);
+ void Draw_Alpha_sp_noBody_sse2(RasterizerNfo& rnfo);
public:
- Rasterizer();
- virtual ~Rasterizer();
-
- bool BeginPath(HDC hdc);
- bool EndPath(HDC hdc);
- bool PartialBeginPath(HDC hdc, bool bClearPath);
- bool PartialEndPath(HDC hdc, long dx, long dy);
- bool ScanConvert();
- bool CreateWidenedRegion(int borderX, int borderY);
- void DeleteOutlines();
- bool Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur);
- int getOverlayWidth();
-
- CRect Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int xsub, int ysub, const DWORD* switchpts, bool fBody, bool fBorder);
- void FillSolidRect(SubPicDesc& spd, int x, int y, int nWidth, int nHeight, DWORD lColor);
+ Rasterizer();
+ virtual ~Rasterizer();
+
+ bool BeginPath(HDC hdc);
+ bool EndPath(HDC hdc);
+ bool PartialBeginPath(HDC hdc, bool bClearPath);
+ bool PartialEndPath(HDC hdc, long dx, long dy);
+ bool ScanConvert();
+ bool CreateWidenedRegion(int borderX, int borderY);
+ void DeleteOutlines();
+ bool Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur);
+ int getOverlayWidth();
+
+ CRect Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int xsub, int ysub, const DWORD* switchpts, bool fBody, bool fBorder);
+ void FillSolidRect(SubPicDesc& spd, int x, int y, int nWidth, int nHeight, DWORD lColor);
};
diff --git a/src/Subtitles/RealTextParser.cpp b/src/Subtitles/RealTextParser.cpp
index 92b9d5303..fd1de557d 100644
--- a/src/Subtitles/RealTextParser.cpp
+++ b/src/Subtitles/RealTextParser.cpp
@@ -24,15 +24,15 @@
#include "RealTextParser.h"
CRealTextParser::CRealTextParser(void):
- m_bIgnoreFont(false),
- m_bIgnoreFontSize(false),
- m_bIgnoreFontColor(false),
- m_bIgnoreFontWeight(false),
- m_bIgnoreFontFace(false),
- m_iMinFontSize(14),
- m_iMaxFontSize(25),
- m_iDefaultSubtitleDurationInMillisecs(4000),
- m_bTryToIgnoreErrors(true)
+ m_bIgnoreFont(false),
+ m_bIgnoreFontSize(false),
+ m_bIgnoreFontColor(false),
+ m_bIgnoreFontWeight(false),
+ m_bIgnoreFontFace(false),
+ m_iMinFontSize(14),
+ m_iMaxFontSize(25),
+ m_iDefaultSubtitleDurationInMillisecs(4000),
+ m_bTryToIgnoreErrors(true)
{
}
@@ -42,549 +42,549 @@ CRealTextParser::~CRealTextParser(void)
bool CRealTextParser::ParseRealText(wstring p_szFile)
{
- vector<int> vStartTimecodes;
- vector<int> vEndTimecodes;
- bool bPrevEndTimeMissing(false);
- list<Tag> listTags;
- list<Tag> listPreviousOpenTags;
-
- while (p_szFile.length() > 0) {
- if (p_szFile.at(0) == '<') {
- Tag oTag;
- if (!ExtractTag(p_szFile, oTag)) {
- return false;
- }
-
- if (oTag.m_bComment) {
- continue;
- }
-
- if (oTag.m_szName == L"time") {
- int iStartTimecode = GetTimecode(oTag.m_mapAttributes[L"begin"]);
- int iEndTimecode = GetTimecode(oTag.m_mapAttributes[L"end"]);
-
- // FilterReduntantTags(listTags);
- wstring szLine = RenderTags(listTags);
-
- if (bPrevEndTimeMissing) {
- pair<int, int> pairTimecodes(vStartTimecodes.back(), iStartTimecode);
-
- // Fix issues where the next time code isn't valid end time code for the previous subtitle
- if (pairTimecodes.first >= pairTimecodes.second) {
- pairTimecodes.second = pairTimecodes.first + m_iDefaultSubtitleDurationInMillisecs;
- }
-
- if (szLine.length() > 0) {
- m_RealText.m_mapLines[pairTimecodes] = szLine;
- }
-
- bPrevEndTimeMissing = false;
- } else if (!vStartTimecodes.empty() && !vEndTimecodes.empty()) {
- pair<int, int> pairTimecodes(vStartTimecodes.back(), vEndTimecodes.back());
-
- if (szLine.length() > 0) {
- m_RealText.m_mapLines[pairTimecodes] = szLine;
- }
-
- }
-
- vStartTimecodes.push_back(iStartTimecode);
- if (iEndTimecode <= 0) {
- bPrevEndTimeMissing = true;
- } else {
- vEndTimecodes.push_back(iEndTimecode);
- }
- } else if (oTag.m_szName == L"b" || oTag.m_szName == L"i" || oTag.m_szName == L"font") {
- if (oTag.m_bOpen) {
- listPreviousOpenTags.push_back(oTag);
- }
-
- if (oTag.m_bClose) {
- PopTag(listPreviousOpenTags, oTag.m_szName);
- }
-
- listTags.push_back(oTag);
- } else if (oTag.m_szName == L"clear") {
- listTags.clear();
-
- // set existing tags
- listTags.insert(listTags.end(), listPreviousOpenTags.begin(), listPreviousOpenTags.end());
- } else if (oTag.m_szName == L"window") {
- if (oTag.m_bOpen) {
- m_RealText.m_WindowTag = oTag;
- }
-
- // Ignore close
- } else if (oTag.m_szName == L"center") {
- m_RealText.m_bCenter = true;
- } else if (oTag.m_szName == L"required") {
- // Ignore
- } else if (oTag.m_szName == L"") {
- // Ignore
- } else {
- // assume formating tag (handled later)
- listTags.push_back(oTag);
- }
- } else {
- Tag oTextTag;
- if (!ExtractTextTag(p_szFile, oTextTag)) {
- return false;
- }
-
- listTags.push_back(oTextTag);
- }
- }
-
- // Handle final line
- // FilterReduntantTags(listTags);
- wstring szLine = RenderTags(listTags);
-
- if (bPrevEndTimeMissing) {
- pair<int, int> pairTimecodes(vStartTimecodes.back(), vStartTimecodes.back() + m_iDefaultSubtitleDurationInMillisecs);
-
- if (szLine.length() > 0) {
- m_RealText.m_mapLines[pairTimecodes] = szLine;
- }
-
- bPrevEndTimeMissing = false;
- } else if (!vStartTimecodes.empty() && !vEndTimecodes.empty()) {
- pair<int, int> pairTimecodes(vStartTimecodes.back(), vEndTimecodes.back());
-
- if (szLine.length() > 0) {
- m_RealText.m_mapLines[pairTimecodes] = szLine;
- }
-
- }
-
- return true;
+ vector<int> vStartTimecodes;
+ vector<int> vEndTimecodes;
+ bool bPrevEndTimeMissing(false);
+ list<Tag> listTags;
+ list<Tag> listPreviousOpenTags;
+
+ while (p_szFile.length() > 0) {
+ if (p_szFile.at(0) == '<') {
+ Tag oTag;
+ if (!ExtractTag(p_szFile, oTag)) {
+ return false;
+ }
+
+ if (oTag.m_bComment) {
+ continue;
+ }
+
+ if (oTag.m_szName == L"time") {
+ int iStartTimecode = GetTimecode(oTag.m_mapAttributes[L"begin"]);
+ int iEndTimecode = GetTimecode(oTag.m_mapAttributes[L"end"]);
+
+ // FilterReduntantTags(listTags);
+ wstring szLine = RenderTags(listTags);
+
+ if (bPrevEndTimeMissing) {
+ pair<int, int> pairTimecodes(vStartTimecodes.back(), iStartTimecode);
+
+ // Fix issues where the next time code isn't valid end time code for the previous subtitle
+ if (pairTimecodes.first >= pairTimecodes.second) {
+ pairTimecodes.second = pairTimecodes.first + m_iDefaultSubtitleDurationInMillisecs;
+ }
+
+ if (szLine.length() > 0) {
+ m_RealText.m_mapLines[pairTimecodes] = szLine;
+ }
+
+ bPrevEndTimeMissing = false;
+ } else if (!vStartTimecodes.empty() && !vEndTimecodes.empty()) {
+ pair<int, int> pairTimecodes(vStartTimecodes.back(), vEndTimecodes.back());
+
+ if (szLine.length() > 0) {
+ m_RealText.m_mapLines[pairTimecodes] = szLine;
+ }
+
+ }
+
+ vStartTimecodes.push_back(iStartTimecode);
+ if (iEndTimecode <= 0) {
+ bPrevEndTimeMissing = true;
+ } else {
+ vEndTimecodes.push_back(iEndTimecode);
+ }
+ } else if (oTag.m_szName == L"b" || oTag.m_szName == L"i" || oTag.m_szName == L"font") {
+ if (oTag.m_bOpen) {
+ listPreviousOpenTags.push_back(oTag);
+ }
+
+ if (oTag.m_bClose) {
+ PopTag(listPreviousOpenTags, oTag.m_szName);
+ }
+
+ listTags.push_back(oTag);
+ } else if (oTag.m_szName == L"clear") {
+ listTags.clear();
+
+ // set existing tags
+ listTags.insert(listTags.end(), listPreviousOpenTags.begin(), listPreviousOpenTags.end());
+ } else if (oTag.m_szName == L"window") {
+ if (oTag.m_bOpen) {
+ m_RealText.m_WindowTag = oTag;
+ }
+
+ // Ignore close
+ } else if (oTag.m_szName == L"center") {
+ m_RealText.m_bCenter = true;
+ } else if (oTag.m_szName == L"required") {
+ // Ignore
+ } else if (oTag.m_szName == L"") {
+ // Ignore
+ } else {
+ // assume formating tag (handled later)
+ listTags.push_back(oTag);
+ }
+ } else {
+ Tag oTextTag;
+ if (!ExtractTextTag(p_szFile, oTextTag)) {
+ return false;
+ }
+
+ listTags.push_back(oTextTag);
+ }
+ }
+
+ // Handle final line
+ // FilterReduntantTags(listTags);
+ wstring szLine = RenderTags(listTags);
+
+ if (bPrevEndTimeMissing) {
+ pair<int, int> pairTimecodes(vStartTimecodes.back(), vStartTimecodes.back() + m_iDefaultSubtitleDurationInMillisecs);
+
+ if (szLine.length() > 0) {
+ m_RealText.m_mapLines[pairTimecodes] = szLine;
+ }
+
+ bPrevEndTimeMissing = false;
+ } else if (!vStartTimecodes.empty() && !vEndTimecodes.empty()) {
+ pair<int, int> pairTimecodes(vStartTimecodes.back(), vEndTimecodes.back());
+
+ if (szLine.length() > 0) {
+ m_RealText.m_mapLines[pairTimecodes] = szLine;
+ }
+
+ }
+
+ return true;
}
const CRealTextParser::Subtitles& CRealTextParser::GetParsedSubtitles()
{
- return m_RealText;
+ return m_RealText;
}
bool CRealTextParser::ExtractTag(wstring& p_rszLine, Tag& p_rTag)
{
- if (p_rszLine.length() < 2 || p_rszLine.at(0) != '<') {
- if (m_bTryToIgnoreErrors) {
- size_t iTempPos = p_rszLine.find_first_of('<');
-
- if (iTempPos != wstring::npos) {
- p_rszLine = p_rszLine.substr(iTempPos);
-
- if (p_rszLine.length() < 2) {
- return false;
- }
- }
-
- } else {
- return false;
- }
- }
-
- unsigned int iPos = 1;
-
- // skip comments
- if (p_rszLine.at(iPos) == '!') {
- p_rTag.m_bComment = true;
-
- wstring szComment;
- GetString(p_rszLine, iPos, szComment, L">");
- p_rTag.m_szName = szComment;
-
- ++iPos; // Skip >
- p_rszLine = p_rszLine.substr(iPos);
- return true;
- } else {
- p_rTag.m_bComment = false;
- }
-
- if (!SkipSpaces(p_rszLine, iPos)) {
- return false;
- }
-
- if (p_rszLine.at(iPos) == '/') {
- p_rTag.m_bOpen = false;
- p_rTag.m_bClose = true;
- ++iPos;
- } else {
- p_rTag.m_bOpen = true;
- p_rTag.m_bClose = false;
- }
-
- if (!GetString(p_rszLine, iPos, p_rTag.m_szName, L"\r\n\t />")) {
- return false;
- }
-
- p_rTag.m_szName = StringToLower(p_rTag.m_szName);
-
- if (!GetAttributes(p_rszLine, iPos, p_rTag.m_mapAttributes)) {
- return false;
- }
-
- if (p_rszLine.at(iPos) == '/') {
- ++iPos;
- p_rTag.m_bClose = true;
- }
-
- if (p_rszLine.at(iPos) == '>') {
- ++iPos;
- p_rszLine = p_rszLine.substr(iPos);
- return true;
- } else {
- if (m_bTryToIgnoreErrors) {
- size_t iTempPos = p_rszLine.find_first_of('>');
-
- if (iTempPos != wstring::npos) {
- if (iTempPos - 1 >= p_rszLine.length()) {
- return false;
- }
-
- p_rszLine = p_rszLine.substr(iTempPos + 1);
- return true;
- } else {
- return false;
- }
-
- } else {
- return false;
- }
- }
+ if (p_rszLine.length() < 2 || p_rszLine.at(0) != '<') {
+ if (m_bTryToIgnoreErrors) {
+ size_t iTempPos = p_rszLine.find_first_of('<');
+
+ if (iTempPos != wstring::npos) {
+ p_rszLine = p_rszLine.substr(iTempPos);
+
+ if (p_rszLine.length() < 2) {
+ return false;
+ }
+ }
+
+ } else {
+ return false;
+ }
+ }
+
+ unsigned int iPos = 1;
+
+ // skip comments
+ if (p_rszLine.at(iPos) == '!') {
+ p_rTag.m_bComment = true;
+
+ wstring szComment;
+ GetString(p_rszLine, iPos, szComment, L">");
+ p_rTag.m_szName = szComment;
+
+ ++iPos; // Skip >
+ p_rszLine = p_rszLine.substr(iPos);
+ return true;
+ } else {
+ p_rTag.m_bComment = false;
+ }
+
+ if (!SkipSpaces(p_rszLine, iPos)) {
+ return false;
+ }
+
+ if (p_rszLine.at(iPos) == '/') {
+ p_rTag.m_bOpen = false;
+ p_rTag.m_bClose = true;
+ ++iPos;
+ } else {
+ p_rTag.m_bOpen = true;
+ p_rTag.m_bClose = false;
+ }
+
+ if (!GetString(p_rszLine, iPos, p_rTag.m_szName, L"\r\n\t />")) {
+ return false;
+ }
+
+ p_rTag.m_szName = StringToLower(p_rTag.m_szName);
+
+ if (!GetAttributes(p_rszLine, iPos, p_rTag.m_mapAttributes)) {
+ return false;
+ }
+
+ if (p_rszLine.at(iPos) == '/') {
+ ++iPos;
+ p_rTag.m_bClose = true;
+ }
+
+ if (p_rszLine.at(iPos) == '>') {
+ ++iPos;
+ p_rszLine = p_rszLine.substr(iPos);
+ return true;
+ } else {
+ if (m_bTryToIgnoreErrors) {
+ size_t iTempPos = p_rszLine.find_first_of('>');
+
+ if (iTempPos != wstring::npos) {
+ if (iTempPos - 1 >= p_rszLine.length()) {
+ return false;
+ }
+
+ p_rszLine = p_rszLine.substr(iTempPos + 1);
+ return true;
+ } else {
+ return false;
+ }
+
+ } else {
+ return false;
+ }
+ }
}
bool CRealTextParser::ExtractTextTag(wstring& p_rszLine, Tag& p_rTag)
{
- p_rTag.m_bText = true;
- return ExtractString(p_rszLine, p_rTag.m_szName);
+ p_rTag.m_bText = true;
+ return ExtractString(p_rszLine, p_rTag.m_szName);
}
bool CRealTextParser::ExtractString(wstring& p_rszLine, wstring& p_rszString)
{
- if (p_rszLine.length() == 0 || p_rszLine.at(0) == '<') {
- if (m_bTryToIgnoreErrors) {
- p_rszString = L"";
- return true;
- } else {
- return false;
- }
- }
-
- unsigned int iPos = 0;
-
- if (!SkipSpaces(p_rszLine, iPos)) {
- return false;
- }
-
- if (!GetString(p_rszLine, iPos, p_rszString, L"<")) {
- return false;
- }
-
- p_rszLine = p_rszLine.substr(iPos);
- return true;
+ if (p_rszLine.length() == 0 || p_rszLine.at(0) == '<') {
+ if (m_bTryToIgnoreErrors) {
+ p_rszString = L"";
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ unsigned int iPos = 0;
+
+ if (!SkipSpaces(p_rszLine, iPos)) {
+ return false;
+ }
+
+ if (!GetString(p_rszLine, iPos, p_rszString, L"<")) {
+ return false;
+ }
+
+ p_rszLine = p_rszLine.substr(iPos);
+ return true;
}
bool CRealTextParser::SkipSpaces(wstring& p_rszLine, unsigned int& p_riPos)
{
- while (p_rszLine.length() > p_riPos && iswspace(p_rszLine.at(p_riPos))) {
- ++p_riPos;
- }
+ while (p_rszLine.length() > p_riPos && iswspace(p_rszLine.at(p_riPos))) {
+ ++p_riPos;
+ }
- return p_rszLine.length() > p_riPos;
+ return p_rszLine.length() > p_riPos;
}
bool CRealTextParser::GetString(wstring& p_rszLine, unsigned int& p_riPos, wstring& p_rszString, const wstring& p_crszEndChars)
{
- while (p_rszLine.length() > p_riPos && p_crszEndChars.find(p_rszLine.at(p_riPos)) == wstring::npos) {
- p_rszString += p_rszLine.at(p_riPos);
- ++p_riPos;
- }
+ while (p_rszLine.length() > p_riPos && p_crszEndChars.find(p_rszLine.at(p_riPos)) == wstring::npos) {
+ p_rszString += p_rszLine.at(p_riPos);
+ ++p_riPos;
+ }
- return p_rszLine.length() > p_riPos;
+ return p_rszLine.length() > p_riPos;
}
bool CRealTextParser::GetAttributes(wstring& p_rszLine, unsigned int& p_riPos, map<wstring, wstring>& p_rmapAttributes)
{
- if (!SkipSpaces(p_rszLine, p_riPos)) {
- return false;
- }
-
- while (p_riPos>p_rszLine.length() && p_rszLine.at(p_riPos) != '/' && p_rszLine.at(p_riPos) != '>') {
- wstring szName;
- if (!GetString(p_rszLine, p_riPos, szName, L"\r\n\t =")) {
- return false;
- }
-
- if (!SkipSpaces(p_rszLine, p_riPos)) {
- return false;
- }
-
- if (p_rszLine.at(p_riPos) != '=') {
- if (m_bTryToIgnoreErrors) {
- p_riPos = (unsigned int)p_rszLine.find_first_of('=', p_riPos);
- if (p_riPos == wstring::npos) {
- return false;
- }
- } else {
- return false;
- }
- }
-
- ++p_riPos;
-
- if (!SkipSpaces(p_rszLine, p_riPos)) {
- return false;
- }
-
- bool bUsesQuotes(false);
- if (p_rszLine.at(p_riPos) == '\'' || p_rszLine.at(p_riPos) == '\"') {
- ++p_riPos;
- bUsesQuotes = true;
- }
-
- if (!SkipSpaces(p_rszLine, p_riPos)) {
- return false;
- }
-
- wstring szValue;
- if (bUsesQuotes) {
- if (!GetString(p_rszLine, p_riPos, szValue, L"\"\'/>")) {
- return false;
- }
- } else {
- if (!GetString(p_rszLine, p_riPos, szValue, L" \t/>")) {
- return false;
- }
- }
-
- p_rmapAttributes[StringToLower(szName)] = szValue;
-
- if (!SkipSpaces(p_rszLine, p_riPos)) {
- return false;
- }
-
- if (p_rszLine.at(p_riPos) == '\'' || p_rszLine.at(p_riPos) == '\"') {
- ++p_riPos;
- }
-
- if (!SkipSpaces(p_rszLine, p_riPos)) {
- return false;
- }
- }
-
- return p_rszLine.length() > p_riPos;
+ if (!SkipSpaces(p_rszLine, p_riPos)) {
+ return false;
+ }
+
+ while (p_riPos > p_rszLine.length() && p_rszLine.at(p_riPos) != '/' && p_rszLine.at(p_riPos) != '>') {
+ wstring szName;
+ if (!GetString(p_rszLine, p_riPos, szName, L"\r\n\t =")) {
+ return false;
+ }
+
+ if (!SkipSpaces(p_rszLine, p_riPos)) {
+ return false;
+ }
+
+ if (p_rszLine.at(p_riPos) != '=') {
+ if (m_bTryToIgnoreErrors) {
+ p_riPos = (unsigned int)p_rszLine.find_first_of('=', p_riPos);
+ if (p_riPos == wstring::npos) {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ ++p_riPos;
+
+ if (!SkipSpaces(p_rszLine, p_riPos)) {
+ return false;
+ }
+
+ bool bUsesQuotes(false);
+ if (p_rszLine.at(p_riPos) == '\'' || p_rszLine.at(p_riPos) == '\"') {
+ ++p_riPos;
+ bUsesQuotes = true;
+ }
+
+ if (!SkipSpaces(p_rszLine, p_riPos)) {
+ return false;
+ }
+
+ wstring szValue;
+ if (bUsesQuotes) {
+ if (!GetString(p_rszLine, p_riPos, szValue, L"\"\'/>")) {
+ return false;
+ }
+ } else {
+ if (!GetString(p_rszLine, p_riPos, szValue, L" \t/>")) {
+ return false;
+ }
+ }
+
+ p_rmapAttributes[StringToLower(szName)] = szValue;
+
+ if (!SkipSpaces(p_rszLine, p_riPos)) {
+ return false;
+ }
+
+ if (p_rszLine.at(p_riPos) == '\'' || p_rszLine.at(p_riPos) == '\"') {
+ ++p_riPos;
+ }
+
+ if (!SkipSpaces(p_rszLine, p_riPos)) {
+ return false;
+ }
+ }
+
+ return p_rszLine.length() > p_riPos;
}
int CRealTextParser::GetTimecode(const wstring& p_crszTimecode)
{
- int iTimecode(0);
- int iMultiplier(1);
+ int iTimecode(0);
+ int iMultiplier(1);
- // Exception: if the timecode doesn't contain any separators, assume the time code is in seconds (and change multiplier to reflect that)
- if (p_crszTimecode.find_first_of('.') == wstring::npos && p_crszTimecode.find_first_of(':') == wstring::npos) {
- iMultiplier = 1000;
- }
+ // Exception: if the timecode doesn't contain any separators, assume the time code is in seconds (and change multiplier to reflect that)
+ if (p_crszTimecode.find_first_of('.') == wstring::npos && p_crszTimecode.find_first_of(':') == wstring::npos) {
+ iMultiplier = 1000;
+ }
- wstring szCurrentPart;
+ wstring szCurrentPart;
- for (ptrdiff_t i = p_crszTimecode.length() - 1; i >= 0; --i) {
- if (p_crszTimecode.at(i) == '.' || p_crszTimecode.at(i) == ':') {
- if (iMultiplier == 1) {
- while (szCurrentPart.length() < 3) {
- szCurrentPart += L"0";
- }
- }
+ for (ptrdiff_t i = p_crszTimecode.length() - 1; i >= 0; --i) {
+ if (p_crszTimecode.at(i) == '.' || p_crszTimecode.at(i) == ':') {
+ if (iMultiplier == 1) {
+ while (szCurrentPart.length() < 3) {
+ szCurrentPart += L"0";
+ }
+ }
- iTimecode += iMultiplier * ::_wtoi(szCurrentPart.c_str());
+ iTimecode += iMultiplier * ::_wtoi(szCurrentPart.c_str());
- if (iMultiplier == 1) {
- iMultiplier = 1000;
- } else {
- iMultiplier *= 60;
- }
+ if (iMultiplier == 1) {
+ iMultiplier = 1000;
+ } else {
+ iMultiplier *= 60;
+ }
- szCurrentPart = L"";
- } else {
- szCurrentPart = p_crszTimecode.substr(i, 1) + szCurrentPart;
- }
- }
+ szCurrentPart = L"";
+ } else {
+ szCurrentPart = p_crszTimecode.substr(i, 1) + szCurrentPart;
+ }
+ }
- iTimecode += iMultiplier * ::_wtoi(szCurrentPart.c_str());
+ iTimecode += iMultiplier * ::_wtoi(szCurrentPart.c_str());
- return iTimecode;
+ return iTimecode;
}
wstring CRealTextParser::FormatTimecode(int iTimecode,
- int iMillisecondPrecision/* = 3*/,
- bool p_bPadZeroes/* = true*/,
- const wstring& p_crszSeparator/* = ":"*/,
- const wstring& p_crszMillisecondSeparator/* = "."*/)
+ int iMillisecondPrecision/* = 3*/,
+ bool p_bPadZeroes/* = true*/,
+ const wstring& p_crszSeparator/* = ":"*/,
+ const wstring& p_crszMillisecondSeparator/* = "."*/)
{
- wostringstream ossTimecode;
+ wostringstream ossTimecode;
- int iHours = iTimecode / 1000 / 60 / 60;
+ int iHours = iTimecode / 1000 / 60 / 60;
- ossTimecode << iHours;
+ ossTimecode << iHours;
- int iMinutes = (iTimecode / 1000 / 60) % 60;
+ int iMinutes = (iTimecode / 1000 / 60) % 60;
- ossTimecode << p_crszSeparator;
- ossTimecode << iMinutes;
+ ossTimecode << p_crszSeparator;
+ ossTimecode << iMinutes;
- int iSeconds = (iTimecode / 1000) % 60;
+ int iSeconds = (iTimecode / 1000) % 60;
- ossTimecode << p_crszSeparator;
- ossTimecode << iSeconds;
+ ossTimecode << p_crszSeparator;
+ ossTimecode << iSeconds;
- int iMilliSeconds = iTimecode % 1000;
+ int iMilliSeconds = iTimecode % 1000;
- if (iMillisecondPrecision < 3) {
- iMilliSeconds /= 10 * (3 - iMillisecondPrecision);
- }
+ if (iMillisecondPrecision < 3) {
+ iMilliSeconds /= 10 * (3 - iMillisecondPrecision);
+ }
- ossTimecode << p_crszMillisecondSeparator;
- ossTimecode << iMilliSeconds;
+ ossTimecode << p_crszMillisecondSeparator;
+ ossTimecode << iMilliSeconds;
- return ossTimecode.str();
+ return ossTimecode.str();
}
wstring CRealTextParser::StringToLower(const wstring& p_crszString)
{
- wstring szLowercaseString;
- for (unsigned int i=0; i < p_crszString.length(); ++i) {
- szLowercaseString += towlower(p_crszString.at(i));
- }
- return szLowercaseString;
+ wstring szLowercaseString;
+ for (unsigned int i = 0; i < p_crszString.length(); ++i) {
+ szLowercaseString += towlower(p_crszString.at(i));
+ }
+ return szLowercaseString;
}
wstring CRealTextParser::RenderTags(const list<Tag>& p_crlTags)
{
- bool bEmpty(true);
- wstring szString;
-
- for (list<Tag>::const_iterator iter = p_crlTags.begin(); iter != p_crlTags.end(); ++iter) {
- Tag oTag(*iter);
-
- if (oTag.m_szName == L"br") {
- szString += L"\n";
- } else if (oTag.m_szName == L"b") {
- if (!m_bIgnoreFontWeight) {
- if (oTag.m_bOpen) {
- szString += L"<b>";
- } else if (oTag.m_bClose) {
- szString += L"</b>";
- }
- }
- } else if (oTag.m_szName == L"i") {
- if (!m_bIgnoreFontWeight) {
- if (oTag.m_bOpen) {
- szString += L"<i>";
- } else if (oTag.m_bClose) {
- szString += L"</i>";
- }
- }
- } else if (oTag.m_szName == L"font") {
- if (!m_bIgnoreFont) {
- if (oTag.m_bOpen) {
- szString += L"<font";
- for (map<wstring, wstring>:: iterator i = oTag.m_mapAttributes.begin(); i != oTag.m_mapAttributes.end(); ++i) {
- if (m_bIgnoreFontSize && i->first == L"size") {
- continue;
- }
-
- if (m_bIgnoreFontColor && i->first == L"color") {
- continue;
- }
-
- if (m_bIgnoreFontFace && i->first == L"face") {
- continue;
- }
-
- if (i->first == L"size" && i->second.length() > 0 && ::iswdigit(i->second.at(0))) {
- int iSize = ::_wtoi(i->second.c_str());
-
- if (iSize > 0 && iSize < m_iMinFontSize) {
- continue;
- }
-
- if (iSize > m_iMaxFontSize) {
- continue;
- }
- }
-
- szString += L" ";
- szString += i->first;
- szString += L"=\"";
- szString += i->second;
- szString += L"\"";
- }
- szString += L">";
- }
-
- if (oTag.m_bClose) {
- szString += L"</font>";
- }
- }
- } else if (oTag.m_bText) {
- szString += oTag.m_szName;
-
- if (!oTag.m_szName.empty()) {
- bEmpty = false;
- }
- } else {
- //AfxMessageBox(CString(_T("Unknown RealText-tag: ")) + oTag.m_szName.c_str());
- }
- }
-
- if (bEmpty) {
- return L"";
- } else {
- return szString;
- }
+ bool bEmpty(true);
+ wstring szString;
+
+ for (list<Tag>::const_iterator iter = p_crlTags.begin(); iter != p_crlTags.end(); ++iter) {
+ Tag oTag(*iter);
+
+ if (oTag.m_szName == L"br") {
+ szString += L"\n";
+ } else if (oTag.m_szName == L"b") {
+ if (!m_bIgnoreFontWeight) {
+ if (oTag.m_bOpen) {
+ szString += L"<b>";
+ } else if (oTag.m_bClose) {
+ szString += L"</b>";
+ }
+ }
+ } else if (oTag.m_szName == L"i") {
+ if (!m_bIgnoreFontWeight) {
+ if (oTag.m_bOpen) {
+ szString += L"<i>";
+ } else if (oTag.m_bClose) {
+ szString += L"</i>";
+ }
+ }
+ } else if (oTag.m_szName == L"font") {
+ if (!m_bIgnoreFont) {
+ if (oTag.m_bOpen) {
+ szString += L"<font";
+ for (map<wstring, wstring>:: iterator i = oTag.m_mapAttributes.begin(); i != oTag.m_mapAttributes.end(); ++i) {
+ if (m_bIgnoreFontSize && i->first == L"size") {
+ continue;
+ }
+
+ if (m_bIgnoreFontColor && i->first == L"color") {
+ continue;
+ }
+
+ if (m_bIgnoreFontFace && i->first == L"face") {
+ continue;
+ }
+
+ if (i->first == L"size" && i->second.length() > 0 && ::iswdigit(i->second.at(0))) {
+ int iSize = ::_wtoi(i->second.c_str());
+
+ if (iSize > 0 && iSize < m_iMinFontSize) {
+ continue;
+ }
+
+ if (iSize > m_iMaxFontSize) {
+ continue;
+ }
+ }
+
+ szString += L" ";
+ szString += i->first;
+ szString += L"=\"";
+ szString += i->second;
+ szString += L"\"";
+ }
+ szString += L">";
+ }
+
+ if (oTag.m_bClose) {
+ szString += L"</font>";
+ }
+ }
+ } else if (oTag.m_bText) {
+ szString += oTag.m_szName;
+
+ if (!oTag.m_szName.empty()) {
+ bEmpty = false;
+ }
+ } else {
+ //AfxMessageBox(CString(_T("Unknown RealText-tag: ")) + oTag.m_szName.c_str());
+ }
+ }
+
+ if (bEmpty) {
+ return L"";
+ } else {
+ return szString;
+ }
}
bool CRealTextParser::OutputSRT(wostream& p_rOutput)
{
- int iCounter(1);
- for (map<pair<int, int>, wstring>::const_iterator i = m_RealText.m_mapLines.begin();
- i != m_RealText.m_mapLines.end();
- ++i) {
- p_rOutput << iCounter++;
- p_rOutput << endl;
-
- p_rOutput << FormatTimecode(i->first.first);
- p_rOutput << L" --> ";
- p_rOutput << FormatTimecode(i->first.second);
- p_rOutput << endl;
-
- p_rOutput << i->second;
- p_rOutput << endl;
- p_rOutput << endl;
- }
-
- return true;
+ int iCounter(1);
+ for (map<pair<int, int>, wstring>::const_iterator i = m_RealText.m_mapLines.begin();
+ i != m_RealText.m_mapLines.end();
+ ++i) {
+ p_rOutput << iCounter++;
+ p_rOutput << endl;
+
+ p_rOutput << FormatTimecode(i->first.first);
+ p_rOutput << L" --> ";
+ p_rOutput << FormatTimecode(i->first.second);
+ p_rOutput << endl;
+
+ p_rOutput << i->second;
+ p_rOutput << endl;
+ p_rOutput << endl;
+ }
+
+ return true;
}
void CRealTextParser::PopTag(list<Tag>& p_rlistTags, const wstring& p_crszTagName)
{
- for (list<Tag>::reverse_iterator riter = p_rlistTags.rbegin(); riter != p_rlistTags.rend(); ++riter) {
- if (riter->m_szName == p_crszTagName) {
- p_rlistTags.erase((++riter).base());
- return;
- }
- }
+ for (list<Tag>::reverse_iterator riter = p_rlistTags.rbegin(); riter != p_rlistTags.rend(); ++riter) {
+ if (riter->m_szName == p_crszTagName) {
+ p_rlistTags.erase((++riter).base());
+ return;
+ }
+ }
}
void CRealTextParser::FilterReduntantTags(list<Tag>& p_rlistTags)
{
- list<Tag>::iterator iterPrev;
- for (list<Tag>::iterator iterCurrent = p_rlistTags.begin(); iterCurrent != p_rlistTags.end(); ++iterCurrent) {
- if (iterCurrent != p_rlistTags.begin()) {
- if (iterPrev->m_szName == L"font" && iterCurrent->m_szName == L"font" &&
- iterPrev->m_bOpen && iterCurrent->m_bOpen) {
- p_rlistTags.erase(iterPrev);
- }
- }
- iterPrev = iterCurrent;
- }
+ list<Tag>::iterator iterPrev;
+ for (list<Tag>::iterator iterCurrent = p_rlistTags.begin(); iterCurrent != p_rlistTags.end(); ++iterCurrent) {
+ if (iterCurrent != p_rlistTags.begin()) {
+ if (iterPrev->m_szName == L"font" && iterCurrent->m_szName == L"font" &&
+ iterPrev->m_bOpen && iterCurrent->m_bOpen) {
+ p_rlistTags.erase(iterPrev);
+ }
+ }
+ iterPrev = iterCurrent;
+ }
}
diff --git a/src/Subtitles/RealTextParser.h b/src/Subtitles/RealTextParser.h
index 9420974c4..650c3cf8e 100644
--- a/src/Subtitles/RealTextParser.h
+++ b/src/Subtitles/RealTextParser.h
@@ -46,77 +46,77 @@ using std::towlower;
class CRealTextParser
{
public:
- CRealTextParser();
- virtual ~CRealTextParser(void);
+ CRealTextParser();
+ virtual ~CRealTextParser(void);
- struct Tag {
- Tag(): m_bOpen(false), m_bClose(false), m_bComment(false), m_bText(false) {}
+ struct Tag {
+ Tag(): m_bOpen(false), m_bClose(false), m_bComment(false), m_bText(false) {}
- wstring m_szName;
+ wstring m_szName;
- bool m_bOpen;
- bool m_bClose;
+ bool m_bOpen;
+ bool m_bClose;
- bool m_bComment;
- bool m_bText;
+ bool m_bComment;
+ bool m_bText;
- map<wstring, wstring> m_mapAttributes;
- };
+ map<wstring, wstring> m_mapAttributes;
+ };
- struct Subtitles {
- Subtitles(): m_WindowTag(), m_FontTag(), m_bCenter(false) {}
+ struct Subtitles {
+ Subtitles(): m_WindowTag(), m_FontTag(), m_bCenter(false) {}
- Tag m_WindowTag;
- Tag m_FontTag;
+ Tag m_WindowTag;
+ Tag m_FontTag;
- bool m_bCenter;
+ bool m_bCenter;
- map<pair<int, int>, wstring> m_mapLines;
- };
+ map<pair<int, int>, wstring> m_mapLines;
+ };
- bool ParseRealText(wstring p_szFile);
+ bool ParseRealText(wstring p_szFile);
- const Subtitles& GetParsedSubtitles();
+ const Subtitles& GetParsedSubtitles();
- bool OutputSRT(wostream& p_rOutput);
+ bool OutputSRT(wostream& p_rOutput);
private:
- bool ExtractTag(wstring& p_rszLine, Tag& p_rTag);
- bool ExtractTextTag(wstring& p_rszLine, Tag& p_rTag);
- bool ExtractString(wstring& p_rszLine, wstring& p_rszString);
- bool SkipSpaces(wstring& p_rszLine, unsigned int& p_riPos);
- bool GetString(wstring& p_rszLine, unsigned int& p_riPos, wstring& p_rszString, const wstring& p_crszEndChars);
- bool GetAttributes(wstring& p_rszLine, unsigned int& p_riPos, map<wstring, wstring>& p_rmapAttributes);
+ bool ExtractTag(wstring& p_rszLine, Tag& p_rTag);
+ bool ExtractTextTag(wstring& p_rszLine, Tag& p_rTag);
+ bool ExtractString(wstring& p_rszLine, wstring& p_rszString);
+ bool SkipSpaces(wstring& p_rszLine, unsigned int& p_riPos);
+ bool GetString(wstring& p_rszLine, unsigned int& p_riPos, wstring& p_rszString, const wstring& p_crszEndChars);
+ bool GetAttributes(wstring& p_rszLine, unsigned int& p_riPos, map<wstring, wstring>& p_rmapAttributes);
- int GetTimecode(const wstring& p_crszTimecode);
- wstring FormatTimecode(int iTimecode,
- int iMillisecondPrecision = 3,
- bool p_bPadZeroes = true,
- const wstring& p_crszSeparator = L":",
- const wstring& p_crszMillisecondSeparator = L".");
+ int GetTimecode(const wstring& p_crszTimecode);
+ wstring FormatTimecode(int iTimecode,
+ int iMillisecondPrecision = 3,
+ bool p_bPadZeroes = true,
+ const wstring& p_crszSeparator = L":",
+ const wstring& p_crszMillisecondSeparator = L".");
- wstring StringToLower(const wstring& p_crszString);
+ wstring StringToLower(const wstring& p_crszString);
- wstring RenderTags(const list<Tag>& p_crlTags);
+ wstring RenderTags(const list<Tag>& p_crlTags);
- void PopTag(list<Tag>& p_rlistTags, const wstring& p_crszTagName);
+ void PopTag(list<Tag>& p_rlistTags, const wstring& p_crszTagName);
- // Filter out for example multiple font tags opened previously (font tags are not always terminated properly in realtext and can build up)
- void FilterReduntantTags(list<Tag>& p_rlistTags);
+ // Filter out for example multiple font tags opened previously (font tags are not always terminated properly in realtext and can build up)
+ void FilterReduntantTags(list<Tag>& p_rlistTags);
- Subtitles m_RealText;
+ Subtitles m_RealText;
- bool m_bIgnoreFont;
- bool m_bIgnoreFontSize;
- bool m_bIgnoreFontColor;
- bool m_bIgnoreFontWeight;
- bool m_bIgnoreFontFace;
+ bool m_bIgnoreFont;
+ bool m_bIgnoreFontSize;
+ bool m_bIgnoreFontColor;
+ bool m_bIgnoreFontWeight;
+ bool m_bIgnoreFontFace;
- int m_iMinFontSize;
- int m_iMaxFontSize;
+ int m_iMinFontSize;
+ int m_iMaxFontSize;
- int m_iDefaultSubtitleDurationInMillisecs;
+ int m_iDefaultSubtitleDurationInMillisecs;
- bool m_bTryToIgnoreErrors;
+ bool m_bTryToIgnoreErrors;
};
diff --git a/src/Subtitles/RenderedHdmvSubtitle.cpp b/src/Subtitles/RenderedHdmvSubtitle.cpp
index 01d1be959..360e1c77b 100644
--- a/src/Subtitles/RenderedHdmvSubtitle.cpp
+++ b/src/Subtitles/RenderedHdmvSubtitle.cpp
@@ -26,152 +26,152 @@
#include "RenderedHdmvSubtitle.h"
CRenderedHdmvSubtitle::CRenderedHdmvSubtitle(CCritSec* pLock, SUBTITLE_TYPE nType, const CString& name, LCID lcid)
- : CSubPicProviderImpl(pLock), m_name(name), m_lcid(lcid)
-{
- switch (nType) {
- case ST_DVB :
- m_pSub = DNew CDVBSub();
- if (name.IsEmpty() || (name == _T("Unknown"))) m_name = "DVB Embedded Subtitle";
- break;
- case ST_HDMV :
- m_pSub = DNew CHdmvSub();
- if (name.IsEmpty() || (name == _T("Unknown"))) m_name = "HDMV Embedded Subtitle";
- break;
- default :
- ASSERT (FALSE);
- m_pSub = NULL;
- }
- m_rtStart = 0;
+ : CSubPicProviderImpl(pLock), m_name(name), m_lcid(lcid)
+{
+ switch (nType) {
+ case ST_DVB :
+ m_pSub = DNew CDVBSub();
+ if (name.IsEmpty() || (name == _T("Unknown"))) { m_name = "DVB Embedded Subtitle"; }
+ break;
+ case ST_HDMV :
+ m_pSub = DNew CHdmvSub();
+ if (name.IsEmpty() || (name == _T("Unknown"))) { m_name = "HDMV Embedded Subtitle"; }
+ break;
+ default :
+ ASSERT(FALSE);
+ m_pSub = NULL;
+ }
+ m_rtStart = 0;
}
CRenderedHdmvSubtitle::~CRenderedHdmvSubtitle(void)
{
- delete m_pSub;
+ delete m_pSub;
}
STDMETHODIMP CRenderedHdmvSubtitle::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
- *ppv = NULL;
+ CheckPointer(ppv, E_POINTER);
+ *ppv = NULL;
- return
- QI(IPersist)
- QI(ISubStream)
- QI(ISubPicProvider)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IPersist)
+ QI(ISubStream)
+ QI(ISubPicProvider)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// ISubPicProvider
STDMETHODIMP_(POSITION) CRenderedHdmvSubtitle::GetStartPosition(REFERENCE_TIME rt, double fps)
{
- CAutoLock cAutoLock(&m_csCritSec);
- return m_pSub->GetStartPosition(rt - m_rtStart, fps);
+ CAutoLock cAutoLock(&m_csCritSec);
+ return m_pSub->GetStartPosition(rt - m_rtStart, fps);
}
STDMETHODIMP_(POSITION) CRenderedHdmvSubtitle::GetNext(POSITION pos)
{
- CAutoLock cAutoLock(&m_csCritSec);
- return m_pSub->GetNext (pos);
+ CAutoLock cAutoLock(&m_csCritSec);
+ return m_pSub->GetNext(pos);
}
STDMETHODIMP_(REFERENCE_TIME) CRenderedHdmvSubtitle::GetStart(POSITION pos, double fps)
{
- CAutoLock cAutoLock(&m_csCritSec);
- return m_pSub->GetStart(pos) + m_rtStart;
+ CAutoLock cAutoLock(&m_csCritSec);
+ return m_pSub->GetStart(pos) + m_rtStart;
}
STDMETHODIMP_(REFERENCE_TIME) CRenderedHdmvSubtitle::GetStop(POSITION pos, double fps)
{
- CAutoLock cAutoLock(&m_csCritSec);
- return m_pSub->GetStop(pos) + m_rtStart;
+ CAutoLock cAutoLock(&m_csCritSec);
+ return m_pSub->GetStop(pos) + m_rtStart;
}
STDMETHODIMP_(bool) CRenderedHdmvSubtitle::IsAnimated(POSITION pos)
{
- return false;
+ return false;
}
STDMETHODIMP CRenderedHdmvSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, double fps, RECT& bbox)
{
- CAutoLock cAutoLock(&m_csCritSec);
- m_pSub->Render (spd, rt - m_rtStart, bbox);
+ CAutoLock cAutoLock(&m_csCritSec);
+ m_pSub->Render(spd, rt - m_rtStart, bbox);
- return S_OK;
+ return S_OK;
}
-STDMETHODIMP CRenderedHdmvSubtitle::GetTextureSize (POSITION pos, SIZE& MaxTextureSize, SIZE& VideoSize, POINT& VideoTopLeft)
+STDMETHODIMP CRenderedHdmvSubtitle::GetTextureSize(POSITION pos, SIZE& MaxTextureSize, SIZE& VideoSize, POINT& VideoTopLeft)
{
- CAutoLock cAutoLock(&m_csCritSec);
- HRESULT hr = m_pSub->GetTextureSize(pos, MaxTextureSize, VideoSize, VideoTopLeft);
- return hr;
+ CAutoLock cAutoLock(&m_csCritSec);
+ HRESULT hr = m_pSub->GetTextureSize(pos, MaxTextureSize, VideoSize, VideoTopLeft);
+ return hr;
};
// IPersist
STDMETHODIMP CRenderedHdmvSubtitle::GetClassID(CLSID* pClassID)
{
- return pClassID ? *pClassID = __uuidof(this), S_OK : E_POINTER;
+ return pClassID ? *pClassID = __uuidof(this), S_OK : E_POINTER;
}
// ISubStream
STDMETHODIMP_(int) CRenderedHdmvSubtitle::GetStreamCount()
{
- return 1;
+ return 1;
}
STDMETHODIMP CRenderedHdmvSubtitle::GetStreamInfo(int iStream, WCHAR** ppName, LCID* pLCID)
{
- if (iStream != 0) {
- return E_INVALIDARG;
- }
+ if (iStream != 0) {
+ return E_INVALIDARG;
+ }
- if (ppName) {
- *ppName = (WCHAR*)CoTaskMemAlloc((m_name.GetLength()+1)*sizeof(WCHAR));
- if (!(*ppName)) {
- return E_OUTOFMEMORY;
- }
+ if (ppName) {
+ *ppName = (WCHAR*)CoTaskMemAlloc((m_name.GetLength() + 1) * sizeof(WCHAR));
+ if (!(*ppName)) {
+ return E_OUTOFMEMORY;
+ }
- wcscpy_s (*ppName, m_name.GetLength()+1, CStringW(m_name));
- }
+ wcscpy_s(*ppName, m_name.GetLength() + 1, CStringW(m_name));
+ }
- if (pLCID) {
- *pLCID = m_lcid;
- }
+ if (pLCID) {
+ *pLCID = m_lcid;
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP_(int) CRenderedHdmvSubtitle::GetStream()
{
- return 0;
+ return 0;
}
STDMETHODIMP CRenderedHdmvSubtitle::SetStream(int iStream)
{
- return iStream == 0 ? S_OK : E_FAIL;
+ return iStream == 0 ? S_OK : E_FAIL;
}
STDMETHODIMP CRenderedHdmvSubtitle::Reload()
{
- return S_OK;
+ return S_OK;
}
-HRESULT CRenderedHdmvSubtitle::ParseSample (IMediaSample* pSample)
+HRESULT CRenderedHdmvSubtitle::ParseSample(IMediaSample* pSample)
{
- CAutoLock cAutoLock(&m_csCritSec);
- HRESULT hr;
+ CAutoLock cAutoLock(&m_csCritSec);
+ HRESULT hr;
- hr = m_pSub->ParseSample (pSample);
- return hr;
+ hr = m_pSub->ParseSample(pSample);
+ return hr;
}
HRESULT CRenderedHdmvSubtitle::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- CAutoLock cAutoLock(&m_csCritSec);
+ CAutoLock cAutoLock(&m_csCritSec);
- m_pSub->Reset();
- m_rtStart = tStart;
- return S_OK;
+ m_pSub->Reset();
+ m_rtStart = tStart;
+ return S_OK;
}
diff --git a/src/Subtitles/RenderedHdmvSubtitle.h b/src/Subtitles/RenderedHdmvSubtitle.h
index 4db2f59ad..6662d1252 100644
--- a/src/Subtitles/RenderedHdmvSubtitle.h
+++ b/src/Subtitles/RenderedHdmvSubtitle.h
@@ -29,42 +29,42 @@
class __declspec(uuid("FCA68599-C83E-4ea5-94A3-C2E1B0E326B9"))
- CRenderedHdmvSubtitle : public CSubPicProviderImpl, public ISubStream
+ CRenderedHdmvSubtitle : public CSubPicProviderImpl, public ISubStream
{
public:
- CRenderedHdmvSubtitle(CCritSec* pLock, SUBTITLE_TYPE nType, const CString& name, LCID lcid);
- ~CRenderedHdmvSubtitle(void);
+ CRenderedHdmvSubtitle(CCritSec* pLock, SUBTITLE_TYPE nType, const CString& name, LCID lcid);
+ ~CRenderedHdmvSubtitle(void);
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // ISubPicProvider
- STDMETHODIMP_(POSITION) GetStartPosition(REFERENCE_TIME rt, double fps);
- STDMETHODIMP_(POSITION) GetNext(POSITION pos);
- STDMETHODIMP_(REFERENCE_TIME) GetStart(POSITION pos, double fps);
- STDMETHODIMP_(REFERENCE_TIME) GetStop(POSITION pos, double fps);
- STDMETHODIMP_(bool) IsAnimated(POSITION pos);
- STDMETHODIMP Render(SubPicDesc& spd, REFERENCE_TIME rt, double fps, RECT& bbox);
- STDMETHODIMP GetTextureSize (POSITION pos, SIZE& MaxTextureSize, SIZE& VirtualSize, POINT& VirtualTopLeft);
+ // ISubPicProvider
+ STDMETHODIMP_(POSITION) GetStartPosition(REFERENCE_TIME rt, double fps);
+ STDMETHODIMP_(POSITION) GetNext(POSITION pos);
+ STDMETHODIMP_(REFERENCE_TIME) GetStart(POSITION pos, double fps);
+ STDMETHODIMP_(REFERENCE_TIME) GetStop(POSITION pos, double fps);
+ STDMETHODIMP_(bool) IsAnimated(POSITION pos);
+ STDMETHODIMP Render(SubPicDesc& spd, REFERENCE_TIME rt, double fps, RECT& bbox);
+ STDMETHODIMP GetTextureSize(POSITION pos, SIZE& MaxTextureSize, SIZE& VirtualSize, POINT& VirtualTopLeft);
- // IPersist
- STDMETHODIMP GetClassID(CLSID* pClassID);
+ // IPersist
+ STDMETHODIMP GetClassID(CLSID* pClassID);
- // ISubStream
- STDMETHODIMP_(int) GetStreamCount();
- STDMETHODIMP GetStreamInfo(int i, WCHAR** ppName, LCID* pLCID);
- STDMETHODIMP_(int) GetStream();
- STDMETHODIMP SetStream(int iStream);
- STDMETHODIMP Reload();
+ // ISubStream
+ STDMETHODIMP_(int) GetStreamCount();
+ STDMETHODIMP GetStreamInfo(int i, WCHAR** ppName, LCID* pLCID);
+ STDMETHODIMP_(int) GetStream();
+ STDMETHODIMP SetStream(int iStream);
+ STDMETHODIMP Reload();
- HRESULT ParseSample (IMediaSample* pSample);
- HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ HRESULT ParseSample(IMediaSample* pSample);
+ HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
private :
- CString m_name;
- LCID m_lcid;
- REFERENCE_TIME m_rtStart;
+ CString m_name;
+ LCID m_lcid;
+ REFERENCE_TIME m_rtStart;
- CBaseSub* m_pSub;
- CCritSec m_csCritSec;
+ CBaseSub* m_pSub;
+ CCritSec m_csCritSec;
};
diff --git a/src/Subtitles/STS.cpp b/src/Subtitles/STS.cpp
index 688becde1..522c9329a 100644
--- a/src/Subtitles/STS.cpp
+++ b/src/Subtitles/STS.cpp
@@ -32,160 +32,160 @@
// gathered from http://www.netwave.or.jp/~shikai/shikai/shcolor.htm
struct htmlcolor {
- TCHAR* name;
- DWORD color;
+ TCHAR* name;
+ DWORD color;
} hmtlcolors[] = {
- {_T("white"), 0xffffff},
- {_T("whitesmoke"), 0xf5f5f5},
- {_T("ghostwhite"), 0xf8f8ff},
- {_T("snow"), 0xfffafa},
- {_T("gainsboro"), 0xdcdcdc},
- {_T("lightgrey"), 0xd3d3d3},
- {_T("silver"), 0xc0c0c0},
- {_T("darkgray"), 0xa9a9a9},
- {_T("gray"), 0x808080},
- {_T("dimgray"), 0x696969},
- {_T("lightslategray"), 0x778899},
- {_T("slategray"), 0x708090},
- {_T("darkslategray"), 0x2f4f4f},
- {_T("black"), 0x000000},
-
- {_T("azure"), 0xf0ffff},
- {_T("aliceblue"), 0xf0f8ff},
- {_T("mintcream"), 0xf5fffa},
- {_T("honeydew"), 0xf0fff0},
- {_T("lightcyan"), 0xe0ffff},
- {_T("paleturqoise"), 0xafeeee},
- {_T("powderblue"), 0xb0e0e6},
- {_T("lightblue"), 0xadd8ed},
- {_T("lightsteelblue"), 0xb0c4de},
- {_T("skyblue"), 0x87ceeb},
- {_T("lightskyblue"), 0x87cefa},
- {_T("cyan"), 0x00ffff},
- {_T("aqua"), 0x00ff80},
- {_T("deepskyblue"), 0x00bfff},
- {_T("aquamarine"), 0x7fffd4},
- {_T("turquoise"), 0x40e0d0},
- {_T("darkturquoise"), 0x00ced1},
- {_T("lightseagreen"), 0x20b2aa},
- {_T("mediumturquoise"), 0x40e0dd},
- {_T("mediumaquamarine"), 0x66cdaa},
- {_T("cadetblue"), 0x5f9ea0},
- {_T("teal"), 0x008080},
- {_T("darkcyan"), 0x008b8b},
- {_T("comflowerblue"), 0x6495ed},
- {_T("dodgerblue"), 0x1e90ff},
- {_T("steelblue"), 0x4682b4},
- {_T("royalblue"), 0x4169e1},
- {_T("blue"), 0x0000ff},
- {_T("mediumblue"), 0x0000cd},
- {_T("mediumslateblue"), 0x7b68ee},
- {_T("slateblue"), 0x6a5acd},
- {_T("darkslateblue"), 0x483d8b},
- {_T("darkblue"), 0x00008b},
- {_T("midnightblue"), 0x191970},
- {_T("navy"), 0x000080},
-
- {_T("palegreen"), 0x98fb98},
- {_T("lightgreen"), 0x90ee90},
- {_T("mediumspringgreen"), 0x00fa9a},
- {_T("springgreen"), 0x00ff7f},
- {_T("chartreuse"), 0x7fff00},
- {_T("lawngreen"), 0x7cfc00},
- {_T("lime"), 0x00ff00},
- {_T("limegreen"), 0x32cd32},
- {_T("greenyellow"), 0xadff2f},
- {_T("yellowgreen"), 0x9acd32},
- {_T("darkseagreen"), 0x8fbc8f},
- {_T("mediumseagreen"), 0x3cb371},
- {_T("seagreen"), 0x2e8b57},
- {_T("olivedrab"), 0x6b8e23},
- {_T("forestgreen"), 0x228b22},
- {_T("green"), 0x008000},
- {_T("darkkhaki"), 0xbdb76b},
- {_T("olive"), 0x808000},
- {_T("darkolivegreen"), 0x556b2f},
- {_T("darkgreen"), 0x006400},
-
- {_T("floralwhite"), 0xfffaf0},
- {_T("seashell"), 0xfff5ee},
- {_T("ivory"), 0xfffff0},
- {_T("beige"), 0xf5f5dc},
- {_T("cornsilk"), 0xfff8dc},
- {_T("lemonchiffon"), 0xfffacd},
- {_T("lightyellow"), 0xffffe0},
- {_T("lightgoldenrodyellow"), 0xfafad2},
- {_T("papayawhip"), 0xffefd5},
- {_T("blanchedalmond"), 0xffedcd},
- {_T("palegoldenrod"), 0xeee8aa},
- {_T("khaki"), 0xf0eb8c},
- {_T("bisque"), 0xffe4c4},
- {_T("moccasin"), 0xffe4b5},
- {_T("navajowhite"), 0xffdead},
- {_T("peachpuff"), 0xffdab9},
- {_T("yellow"), 0xffff00},
- {_T("gold"), 0xffd700},
- {_T("wheat"), 0xf5deb3},
- {_T("orange"), 0xffa500},
- {_T("darkorange"), 0xff8c00},
-
- {_T("oldlace"), 0xfdf5e6},
- {_T("linen"), 0xfaf0e6},
- {_T("antiquewhite"), 0xfaebd7},
- {_T("lightsalmon"), 0xffa07a},
- {_T("darksalmon"), 0xe9967a},
- {_T("salmon"), 0xfa8072},
- {_T("lightcoral"), 0xf08080},
- {_T("indianred"), 0xcd5c5c},
- {_T("coral"), 0xff7f50},
- {_T("tomato"), 0xff6347},
- {_T("orangered"), 0xff4500},
- {_T("red"), 0xff0000},
- {_T("crimson"), 0xdc143c},
- {_T("firebrick"), 0xb22222},
- {_T("maroon"), 0x800000},
- {_T("darkred"), 0x8b0000},
-
- {_T("lavender"), 0xe6e6fe},
- {_T("lavenderblush"), 0xfff0f5},
- {_T("mistyrose"), 0xffe4e1},
- {_T("thistle"), 0xd8bfd8},
- {_T("pink"), 0xffc0cb},
- {_T("lightpink"), 0xffb6c1},
- {_T("palevioletred"), 0xdb7093},
- {_T("hotpink"), 0xff69b4},
- {_T("fuchsia"), 0xff00ee},
- {_T("magenta"), 0xff00ff},
- {_T("mediumvioletred"), 0xc71585},
- {_T("deeppink"), 0xff1493},
- {_T("plum"), 0xdda0dd},
- {_T("violet"), 0xee82ee},
- {_T("orchid"), 0xda70d6},
- {_T("mediumorchid"), 0xba55d3},
- {_T("mediumpurple"), 0x9370db},
- {_T("purple"), 0x9370db},
- {_T("blueviolet"), 0x8a2be2},
- {_T("darkviolet"), 0x9400d3},
- {_T("darkorchid"), 0x9932cc},
-
- {_T("tan"), 0xd2b48c},
- {_T("burlywood"), 0xdeb887},
- {_T("sandybrown"), 0xf4a460},
- {_T("peru"), 0xcd853f},
- {_T("goldenrod"), 0xdaa520},
- {_T("darkgoldenrod"), 0xb8860b},
- {_T("chocolate"), 0xd2691e},
- {_T("rosybrown"), 0xbc8f8f},
- {_T("sienna"), 0xa0522d},
- {_T("saddlebrown"), 0x8b4513},
- {_T("brown"), 0xa52a2a},
+ {_T("white"), 0xffffff},
+ {_T("whitesmoke"), 0xf5f5f5},
+ {_T("ghostwhite"), 0xf8f8ff},
+ {_T("snow"), 0xfffafa},
+ {_T("gainsboro"), 0xdcdcdc},
+ {_T("lightgrey"), 0xd3d3d3},
+ {_T("silver"), 0xc0c0c0},
+ {_T("darkgray"), 0xa9a9a9},
+ {_T("gray"), 0x808080},
+ {_T("dimgray"), 0x696969},
+ {_T("lightslategray"), 0x778899},
+ {_T("slategray"), 0x708090},
+ {_T("darkslategray"), 0x2f4f4f},
+ {_T("black"), 0x000000},
+
+ {_T("azure"), 0xf0ffff},
+ {_T("aliceblue"), 0xf0f8ff},
+ {_T("mintcream"), 0xf5fffa},
+ {_T("honeydew"), 0xf0fff0},
+ {_T("lightcyan"), 0xe0ffff},
+ {_T("paleturqoise"), 0xafeeee},
+ {_T("powderblue"), 0xb0e0e6},
+ {_T("lightblue"), 0xadd8ed},
+ {_T("lightsteelblue"), 0xb0c4de},
+ {_T("skyblue"), 0x87ceeb},
+ {_T("lightskyblue"), 0x87cefa},
+ {_T("cyan"), 0x00ffff},
+ {_T("aqua"), 0x00ff80},
+ {_T("deepskyblue"), 0x00bfff},
+ {_T("aquamarine"), 0x7fffd4},
+ {_T("turquoise"), 0x40e0d0},
+ {_T("darkturquoise"), 0x00ced1},
+ {_T("lightseagreen"), 0x20b2aa},
+ {_T("mediumturquoise"), 0x40e0dd},
+ {_T("mediumaquamarine"), 0x66cdaa},
+ {_T("cadetblue"), 0x5f9ea0},
+ {_T("teal"), 0x008080},
+ {_T("darkcyan"), 0x008b8b},
+ {_T("comflowerblue"), 0x6495ed},
+ {_T("dodgerblue"), 0x1e90ff},
+ {_T("steelblue"), 0x4682b4},
+ {_T("royalblue"), 0x4169e1},
+ {_T("blue"), 0x0000ff},
+ {_T("mediumblue"), 0x0000cd},
+ {_T("mediumslateblue"), 0x7b68ee},
+ {_T("slateblue"), 0x6a5acd},
+ {_T("darkslateblue"), 0x483d8b},
+ {_T("darkblue"), 0x00008b},
+ {_T("midnightblue"), 0x191970},
+ {_T("navy"), 0x000080},
+
+ {_T("palegreen"), 0x98fb98},
+ {_T("lightgreen"), 0x90ee90},
+ {_T("mediumspringgreen"), 0x00fa9a},
+ {_T("springgreen"), 0x00ff7f},
+ {_T("chartreuse"), 0x7fff00},
+ {_T("lawngreen"), 0x7cfc00},
+ {_T("lime"), 0x00ff00},
+ {_T("limegreen"), 0x32cd32},
+ {_T("greenyellow"), 0xadff2f},
+ {_T("yellowgreen"), 0x9acd32},
+ {_T("darkseagreen"), 0x8fbc8f},
+ {_T("mediumseagreen"), 0x3cb371},
+ {_T("seagreen"), 0x2e8b57},
+ {_T("olivedrab"), 0x6b8e23},
+ {_T("forestgreen"), 0x228b22},
+ {_T("green"), 0x008000},
+ {_T("darkkhaki"), 0xbdb76b},
+ {_T("olive"), 0x808000},
+ {_T("darkolivegreen"), 0x556b2f},
+ {_T("darkgreen"), 0x006400},
+
+ {_T("floralwhite"), 0xfffaf0},
+ {_T("seashell"), 0xfff5ee},
+ {_T("ivory"), 0xfffff0},
+ {_T("beige"), 0xf5f5dc},
+ {_T("cornsilk"), 0xfff8dc},
+ {_T("lemonchiffon"), 0xfffacd},
+ {_T("lightyellow"), 0xffffe0},
+ {_T("lightgoldenrodyellow"), 0xfafad2},
+ {_T("papayawhip"), 0xffefd5},
+ {_T("blanchedalmond"), 0xffedcd},
+ {_T("palegoldenrod"), 0xeee8aa},
+ {_T("khaki"), 0xf0eb8c},
+ {_T("bisque"), 0xffe4c4},
+ {_T("moccasin"), 0xffe4b5},
+ {_T("navajowhite"), 0xffdead},
+ {_T("peachpuff"), 0xffdab9},
+ {_T("yellow"), 0xffff00},
+ {_T("gold"), 0xffd700},
+ {_T("wheat"), 0xf5deb3},
+ {_T("orange"), 0xffa500},
+ {_T("darkorange"), 0xff8c00},
+
+ {_T("oldlace"), 0xfdf5e6},
+ {_T("linen"), 0xfaf0e6},
+ {_T("antiquewhite"), 0xfaebd7},
+ {_T("lightsalmon"), 0xffa07a},
+ {_T("darksalmon"), 0xe9967a},
+ {_T("salmon"), 0xfa8072},
+ {_T("lightcoral"), 0xf08080},
+ {_T("indianred"), 0xcd5c5c},
+ {_T("coral"), 0xff7f50},
+ {_T("tomato"), 0xff6347},
+ {_T("orangered"), 0xff4500},
+ {_T("red"), 0xff0000},
+ {_T("crimson"), 0xdc143c},
+ {_T("firebrick"), 0xb22222},
+ {_T("maroon"), 0x800000},
+ {_T("darkred"), 0x8b0000},
+
+ {_T("lavender"), 0xe6e6fe},
+ {_T("lavenderblush"), 0xfff0f5},
+ {_T("mistyrose"), 0xffe4e1},
+ {_T("thistle"), 0xd8bfd8},
+ {_T("pink"), 0xffc0cb},
+ {_T("lightpink"), 0xffb6c1},
+ {_T("palevioletred"), 0xdb7093},
+ {_T("hotpink"), 0xff69b4},
+ {_T("fuchsia"), 0xff00ee},
+ {_T("magenta"), 0xff00ff},
+ {_T("mediumvioletred"), 0xc71585},
+ {_T("deeppink"), 0xff1493},
+ {_T("plum"), 0xdda0dd},
+ {_T("violet"), 0xee82ee},
+ {_T("orchid"), 0xda70d6},
+ {_T("mediumorchid"), 0xba55d3},
+ {_T("mediumpurple"), 0x9370db},
+ {_T("purple"), 0x9370db},
+ {_T("blueviolet"), 0x8a2be2},
+ {_T("darkviolet"), 0x9400d3},
+ {_T("darkorchid"), 0x9932cc},
+
+ {_T("tan"), 0xd2b48c},
+ {_T("burlywood"), 0xdeb887},
+ {_T("sandybrown"), 0xf4a460},
+ {_T("peru"), 0xcd853f},
+ {_T("goldenrod"), 0xdaa520},
+ {_T("darkgoldenrod"), 0xb8860b},
+ {_T("chocolate"), 0xd2691e},
+ {_T("rosybrown"), 0xbc8f8f},
+ {_T("sienna"), 0xa0522d},
+ {_T("saddlebrown"), 0x8b4513},
+ {_T("brown"), 0xa52a2a},
};
CHtmlColorMap::CHtmlColorMap()
{
- for (size_t i = 0; i < _countof(hmtlcolors); i++) {
- SetAt(hmtlcolors[i].name, hmtlcolors[i].color);
- }
+ for (size_t i = 0; i < _countof(hmtlcolors); i++) {
+ SetAt(hmtlcolors[i].name, hmtlcolors[i].color);
+ }
}
CHtmlColorMap g_colors;
@@ -193,49 +193,49 @@ CHtmlColorMap g_colors;
//
BYTE CharSetList[] = {
- ANSI_CHARSET,
- DEFAULT_CHARSET,
- SYMBOL_CHARSET,
- SHIFTJIS_CHARSET,
- HANGEUL_CHARSET,
- HANGUL_CHARSET,
- GB2312_CHARSET,
- CHINESEBIG5_CHARSET,
- OEM_CHARSET,
- JOHAB_CHARSET,
- HEBREW_CHARSET,
- ARABIC_CHARSET,
- GREEK_CHARSET,
- TURKISH_CHARSET,
- VIETNAMESE_CHARSET,
- THAI_CHARSET,
- EASTEUROPE_CHARSET,
- RUSSIAN_CHARSET,
- MAC_CHARSET,
- BALTIC_CHARSET
+ ANSI_CHARSET,
+ DEFAULT_CHARSET,
+ SYMBOL_CHARSET,
+ SHIFTJIS_CHARSET,
+ HANGEUL_CHARSET,
+ HANGUL_CHARSET,
+ GB2312_CHARSET,
+ CHINESEBIG5_CHARSET,
+ OEM_CHARSET,
+ JOHAB_CHARSET,
+ HEBREW_CHARSET,
+ ARABIC_CHARSET,
+ GREEK_CHARSET,
+ TURKISH_CHARSET,
+ VIETNAMESE_CHARSET,
+ THAI_CHARSET,
+ EASTEUROPE_CHARSET,
+ RUSSIAN_CHARSET,
+ MAC_CHARSET,
+ BALTIC_CHARSET
};
TCHAR* CharSetNames[] = {
- _T("ANSI"),
- _T("DEFAULT"),
- _T("SYMBOL"),
- _T("SHIFTJIS"),
- _T("HANGEUL"),
- _T("HANGUL"),
- _T("GB2312"),
- _T("CHINESEBIG5"),
- _T("OEM"),
- _T("JOHAB"),
- _T("HEBREW"),
- _T("ARABIC"),
- _T("GREEK"),
- _T("TURKISH"),
- _T("VIETNAMESE"),
- _T("THAI"),
- _T("EASTEUROPE"),
- _T("RUSSIAN"),
- _T("MAC"),
- _T("BALTIC"),
+ _T("ANSI"),
+ _T("DEFAULT"),
+ _T("SYMBOL"),
+ _T("SHIFTJIS"),
+ _T("HANGEUL"),
+ _T("HANGUL"),
+ _T("GB2312"),
+ _T("CHINESEBIG5"),
+ _T("OEM"),
+ _T("JOHAB"),
+ _T("HEBREW"),
+ _T("ARABIC"),
+ _T("GREEK"),
+ _T("TURKISH"),
+ _T("VIETNAMESE"),
+ _T("THAI"),
+ _T("EASTEUROPE"),
+ _T("RUSSIAN"),
+ _T("MAC"),
+ _T("BALTIC"),
};
int CharSetLen = _countof(CharSetList);
@@ -244,1588 +244,1588 @@ int CharSetLen = _countof(CharSetList);
static DWORD CharSetToCodePage(DWORD dwCharSet)
{
- CHARSETINFO cs= {0};
- ::TranslateCharsetInfo((DWORD *)dwCharSet, &cs, TCI_SRCCHARSET);
- return cs.ciACP;
+ CHARSETINFO cs = {0};
+ ::TranslateCharsetInfo((DWORD*)dwCharSet, &cs, TCI_SRCCHARSET);
+ return cs.ciACP;
}
int FindChar(CStringW str, WCHAR c, int pos, bool fUnicode, int CharSet)
{
- if (fUnicode) {
- return str.Find(c, pos);
- }
-
- int fStyleMod = 0;
-
- DWORD cp = CharSetToCodePage(CharSet);
- int OrgCharSet = CharSet;
-
- for (int i = 0, j = str.GetLength(), k; i < j; i++) {
- WCHAR c2 = str[i];
-
- if (IsDBCSLeadByteEx(cp, (BYTE)c2)) {
- i++;
- } else if (i >= pos) {
- if (c2 == c) {
- return i;
- }
- }
-
- if (c2 == '{') {
- fStyleMod++;
- } else if (fStyleMod > 0) {
- if (c2 == '}') {
- fStyleMod--;
- } else if (c2 == 'e' && i >= 3 && i < j-1 && str.Mid(i-2, 3) == L"\\fe") {
- CharSet = 0;
- for (k = i+1; _istdigit(str[k]); k++) {
- CharSet = CharSet*10 + (str[k] - '0');
- }
- if (k == i+1) {
- CharSet = OrgCharSet;
- }
-
- cp = CharSetToCodePage(CharSet);
- }
- }
- }
-
- return -1;
+ if (fUnicode) {
+ return str.Find(c, pos);
+ }
+
+ int fStyleMod = 0;
+
+ DWORD cp = CharSetToCodePage(CharSet);
+ int OrgCharSet = CharSet;
+
+ for (int i = 0, j = str.GetLength(), k; i < j; i++) {
+ WCHAR c2 = str[i];
+
+ if (IsDBCSLeadByteEx(cp, (BYTE)c2)) {
+ i++;
+ } else if (i >= pos) {
+ if (c2 == c) {
+ return i;
+ }
+ }
+
+ if (c2 == '{') {
+ fStyleMod++;
+ } else if (fStyleMod > 0) {
+ if (c2 == '}') {
+ fStyleMod--;
+ } else if (c2 == 'e' && i >= 3 && i < j - 1 && str.Mid(i - 2, 3) == L"\\fe") {
+ CharSet = 0;
+ for (k = i + 1; _istdigit(str[k]); k++) {
+ CharSet = CharSet * 10 + (str[k] - '0');
+ }
+ if (k == i + 1) {
+ CharSet = OrgCharSet;
+ }
+
+ cp = CharSetToCodePage(CharSet);
+ }
+ }
+ }
+
+ return -1;
}
/*
int FindChar(CStringA str, char c, int pos, bool fUnicode, int CharSet)
{
- ASSERT(!fUnicode);
+ ASSERT(!fUnicode);
- return FindChar(AToW(str), c, pos, false, CharSet);
+ return FindChar(AToW(str), c, pos, false, CharSet);
}
*/
static CStringW ToMBCS(CStringW str, DWORD CharSet)
{
- CStringW ret;
+ CStringW ret;
- DWORD cp = CharSetToCodePage(CharSet);
+ DWORD cp = CharSetToCodePage(CharSet);
- for (int i = 0, j = str.GetLength(); i < j; i++) {
- WCHAR wc = str.GetAt(i);
- char c[8];
+ for (int i = 0, j = str.GetLength(); i < j; i++) {
+ WCHAR wc = str.GetAt(i);
+ char c[8];
- int len;
- if ((len = WideCharToMultiByte(cp, 0, &wc, 1, c, 8, NULL, NULL)) > 0) {
- for (ptrdiff_t k = 0; k < len; k++) {
- ret += (WCHAR)(BYTE)c[k];
- }
- } else {
- ret += '?';
- }
- }
+ int len;
+ if ((len = WideCharToMultiByte(cp, 0, &wc, 1, c, 8, NULL, NULL)) > 0) {
+ for (ptrdiff_t k = 0; k < len; k++) {
+ ret += (WCHAR)(BYTE)c[k];
+ }
+ } else {
+ ret += '?';
+ }
+ }
- return ret;
+ return ret;
}
static CStringW UnicodeSSAToMBCS(CStringW str, DWORD CharSet)
{
- CStringW ret;
-
- int OrgCharSet = CharSet;
-
- for (int j = 0; j < str.GetLength(); ) {
- j = str.Find('{', j);
- if (j >= 0) {
- ret += ToMBCS(str.Left(j), CharSet);
- str = str.Mid(j);
-
- j = str.Find('}');
- if (j < 0) {
- ret += ToMBCS(str, CharSet);
- break;
- } else {
- int k = str.Find(L"\\fe");
- if (k >= 0 && k < j) {
- CharSet = 0;
- int l = k+3;
- for (; _istdigit(str[l]); l++) {
- CharSet = CharSet*10 + (str[l] - '0');
- }
- if (l == k+3) {
- CharSet = OrgCharSet;
- }
- }
-
- j++;
-
- ret += ToMBCS(str.Left(j), OrgCharSet);
- str = str.Mid(j);
- j = 0;
- }
- } else {
- ret += ToMBCS(str, CharSet);
- break;
- }
- }
-
- return ret;
+ CStringW ret;
+
+ int OrgCharSet = CharSet;
+
+ for (int j = 0; j < str.GetLength();) {
+ j = str.Find('{', j);
+ if (j >= 0) {
+ ret += ToMBCS(str.Left(j), CharSet);
+ str = str.Mid(j);
+
+ j = str.Find('}');
+ if (j < 0) {
+ ret += ToMBCS(str, CharSet);
+ break;
+ } else {
+ int k = str.Find(L"\\fe");
+ if (k >= 0 && k < j) {
+ CharSet = 0;
+ int l = k + 3;
+ for (; _istdigit(str[l]); l++) {
+ CharSet = CharSet * 10 + (str[l] - '0');
+ }
+ if (l == k + 3) {
+ CharSet = OrgCharSet;
+ }
+ }
+
+ j++;
+
+ ret += ToMBCS(str.Left(j), OrgCharSet);
+ str = str.Mid(j);
+ j = 0;
+ }
+ } else {
+ ret += ToMBCS(str, CharSet);
+ break;
+ }
+ }
+
+ return ret;
}
static CStringW ToUnicode(CStringW str, DWORD CharSet)
{
- CStringW ret;
+ CStringW ret;
- DWORD cp = CharSetToCodePage(CharSet);
+ DWORD cp = CharSetToCodePage(CharSet);
- for (int i = 0, j = str.GetLength(); i < j; i++) {
- WCHAR wc = str.GetAt(i);
- char c = wc&0xff;
+ for (int i = 0, j = str.GetLength(); i < j; i++) {
+ WCHAR wc = str.GetAt(i);
+ char c = wc & 0xff;
- if (IsDBCSLeadByteEx(cp, (BYTE)wc)) {
- i++;
+ if (IsDBCSLeadByteEx(cp, (BYTE)wc)) {
+ i++;
- if (i < j) {
- char cc[2];
- cc[0] = c;
- cc[1] = (char)str.GetAt(i);
+ if (i < j) {
+ char cc[2];
+ cc[0] = c;
+ cc[1] = (char)str.GetAt(i);
- MultiByteToWideChar(cp, 0, cc, 2, &wc, 1);
- }
- } else {
- MultiByteToWideChar(cp, 0, &c, 1, &wc, 1);
- }
+ MultiByteToWideChar(cp, 0, cc, 2, &wc, 1);
+ }
+ } else {
+ MultiByteToWideChar(cp, 0, &c, 1, &wc, 1);
+ }
- ret += wc;
- }
+ ret += wc;
+ }
- return ret;
+ return ret;
}
static CStringW MBCSSSAToUnicode(CStringW str, int CharSet)
{
- CStringW ret;
+ CStringW ret;
- int OrgCharSet = CharSet;
+ int OrgCharSet = CharSet;
- for (int j = 0; j < str.GetLength(); ) {
- j = FindChar(str, '{', 0, false, CharSet);
+ for (int j = 0; j < str.GetLength();) {
+ j = FindChar(str, '{', 0, false, CharSet);
- if (j >= 0) {
- ret += ToUnicode(str.Left(j), CharSet);
- str = str.Mid(j);
+ if (j >= 0) {
+ ret += ToUnicode(str.Left(j), CharSet);
+ str = str.Mid(j);
- j = FindChar(str, '}', 0, false, CharSet);
+ j = FindChar(str, '}', 0, false, CharSet);
- if (j < 0) {
- ret += ToUnicode(str, CharSet);
- break;
- } else {
- int k = str.Find(L"\\fe");
- if (k >= 0 && k < j) {
- CharSet = 0;
- int l = k+3;
- for (; _istdigit(str[l]); l++) {
- CharSet = CharSet*10 + (str[l] - '0');
- }
- if (l == k+3) {
- CharSet = OrgCharSet;
- }
- }
+ if (j < 0) {
+ ret += ToUnicode(str, CharSet);
+ break;
+ } else {
+ int k = str.Find(L"\\fe");
+ if (k >= 0 && k < j) {
+ CharSet = 0;
+ int l = k + 3;
+ for (; _istdigit(str[l]); l++) {
+ CharSet = CharSet * 10 + (str[l] - '0');
+ }
+ if (l == k + 3) {
+ CharSet = OrgCharSet;
+ }
+ }
- j++;
+ j++;
- ret += ToUnicode(str.Left(j), OrgCharSet);
- str = str.Mid(j);
- j = 0;
- }
- } else {
- ret += ToUnicode(str, CharSet);
- break;
- }
- }
+ ret += ToUnicode(str.Left(j), OrgCharSet);
+ str = str.Mid(j);
+ j = 0;
+ }
+ } else {
+ ret += ToUnicode(str, CharSet);
+ break;
+ }
+ }
- return ret;
+ return ret;
}
CStringW RemoveSSATags(CStringW str, bool fUnicode, int CharSet)
{
- str.Replace (L"{\\i1}", L"<i>");
- str.Replace (L"{\\i}", L"</i>");
+ str.Replace(L"{\\i1}", L"<i>");
+ str.Replace(L"{\\i}", L"</i>");
- for (int i = 0, j; i < str.GetLength(); ) {
- if ((i = FindChar(str, '{', i, fUnicode, CharSet)) < 0) {
- break;
- }
- if ((j = FindChar(str, '}', i, fUnicode, CharSet)) < 0) {
- break;
- }
- str.Delete(i, j-i+1);
- }
+ for (int i = 0, j; i < str.GetLength();) {
+ if ((i = FindChar(str, '{', i, fUnicode, CharSet)) < 0) {
+ break;
+ }
+ if ((j = FindChar(str, '}', i, fUnicode, CharSet)) < 0) {
+ break;
+ }
+ str.Delete(i, j - i + 1);
+ }
- str.Replace(L"\\N", L"\n");
- str.Replace(L"\\n", L"\n");
- str.Replace(L"\\h", L" ");
+ str.Replace(L"\\N", L"\n");
+ str.Replace(L"\\n", L"\n");
+ str.Replace(L"\\h", L" ");
- return str;
+ return str;
}
//
static CStringW SubRipper2SSA(CStringW str, int CharSet)
{
- str.Replace(L"<i>", L"{\\i1}");
- str.Replace(L"</i>", L"{\\i}");
- str.Replace(L"<b>", L"{\\b1}");
- str.Replace(L"</b>", L"{\\b}");
- str.Replace(L"<u>", L"{\\u1}");
- str.Replace(L"</u>", L"{\\u}");
+ str.Replace(L"<i>", L"{\\i1}");
+ str.Replace(L"</i>", L"{\\i}");
+ str.Replace(L"<b>", L"{\\b1}");
+ str.Replace(L"</b>", L"{\\b}");
+ str.Replace(L"<u>", L"{\\u1}");
+ str.Replace(L"</u>", L"{\\u}");
- return str;
+ return str;
}
static bool OpenSubRipper(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
{
- CStringW buff;
- while (file->ReadString(buff)) {
- buff.Trim();
- if (buff.IsEmpty()) {
- continue;
- }
-
- WCHAR sep;
- int num = 0; // This one isn't really used just assigned a new value
- int hh1, mm1, ss1, ms1, hh2, mm2, ss2, ms2;
- int c = swscanf_s(buff, L"%d%c%d%c%d%c%d --> %d%c%d%c%d%c%d\n",
- &hh1, &sep, sizeof(WCHAR), &mm1, &sep, sizeof(WCHAR),
- &ss1, &sep, sizeof(WCHAR), &ms1, &hh2, &sep, sizeof(WCHAR),
- &mm2, &sep, sizeof(WCHAR), &ss2, &sep, sizeof(WCHAR), &ms2);
-
- if (c == 1) { // numbering
- num = hh1;
- } else if (c == 14) { // time info
- CStringW str, tmp;
-
- bool fFoundEmpty = false;
-
- while (file->ReadString(tmp)) {
- tmp.Trim();
- if (tmp.IsEmpty()) {
- fFoundEmpty = true;
- }
-
- int num2;
- WCHAR c;
- if (swscanf_s(tmp, L"%d%c", &num2, &c, sizeof(WCHAR)) == 1 && fFoundEmpty) {
- num = num2;
- break;
- }
-
- str += tmp + '\n';
- }
-
- ret.Add(
- SubRipper2SSA(str, CharSet),
- file->IsUnicode(),
- (((hh1*60 + mm1)*60) + ss1)*1000 + ms1,
- (((hh2*60 + mm2)*60) + ss2)*1000 + ms2);
- } else if (c != EOF) { // might be another format
- return false;
- }
- }
-
- return (ret.GetCount() > 0);
+ CStringW buff;
+ while (file->ReadString(buff)) {
+ buff.Trim();
+ if (buff.IsEmpty()) {
+ continue;
+ }
+
+ WCHAR sep;
+ int num = 0; // This one isn't really used just assigned a new value
+ int hh1, mm1, ss1, ms1, hh2, mm2, ss2, ms2;
+ int c = swscanf_s(buff, L"%d%c%d%c%d%c%d --> %d%c%d%c%d%c%d\n",
+ &hh1, &sep, sizeof(WCHAR), &mm1, &sep, sizeof(WCHAR),
+ &ss1, &sep, sizeof(WCHAR), &ms1, &hh2, &sep, sizeof(WCHAR),
+ &mm2, &sep, sizeof(WCHAR), &ss2, &sep, sizeof(WCHAR), &ms2);
+
+ if (c == 1) { // numbering
+ num = hh1;
+ } else if (c == 14) { // time info
+ CStringW str, tmp;
+
+ bool fFoundEmpty = false;
+
+ while (file->ReadString(tmp)) {
+ tmp.Trim();
+ if (tmp.IsEmpty()) {
+ fFoundEmpty = true;
+ }
+
+ int num2;
+ WCHAR c;
+ if (swscanf_s(tmp, L"%d%c", &num2, &c, sizeof(WCHAR)) == 1 && fFoundEmpty) {
+ num = num2;
+ break;
+ }
+
+ str += tmp + '\n';
+ }
+
+ ret.Add(
+ SubRipper2SSA(str, CharSet),
+ file->IsUnicode(),
+ (((hh1 * 60 + mm1) * 60) + ss1) * 1000 + ms1,
+ (((hh2 * 60 + mm2) * 60) + ss2) * 1000 + ms2);
+ } else if (c != EOF) { // might be another format
+ return false;
+ }
+ }
+
+ return (ret.GetCount() > 0);
}
static bool OpenOldSubRipper(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
{
- CStringW buff;
- while (file->ReadString(buff)) {
- buff.Trim();
- if (buff.IsEmpty()) {
- continue;
- }
-
- for (int i = 0; i < buff.GetLength(); i++) {
- if ((i = FindChar(buff, '|', i, file->IsUnicode(), CharSet)) < 0) {
- break;
- }
- buff.SetAt(i, '\n');
- }
-
- int hh1, mm1, ss1, hh2, mm2, ss2;
- int c = swscanf_s(buff, L"{%d:%d:%d}{%d:%d:%d}", &hh1, &mm1, &ss1, &hh2, &mm2, &ss2);
-
- if (c == 6) {
- ret.Add(
- buff.Mid(buff.Find('}', buff.Find('}')+1)+1),
- file->IsUnicode(),
- (((hh1*60 + mm1)*60) + ss1)*1000,
- (((hh2*60 + mm2)*60) + ss2)*1000);
- } else if (c != EOF) { // might be another format
- return false;
- }
- }
-
- return (ret.GetCount() > 0);
+ CStringW buff;
+ while (file->ReadString(buff)) {
+ buff.Trim();
+ if (buff.IsEmpty()) {
+ continue;
+ }
+
+ for (int i = 0; i < buff.GetLength(); i++) {
+ if ((i = FindChar(buff, '|', i, file->IsUnicode(), CharSet)) < 0) {
+ break;
+ }
+ buff.SetAt(i, '\n');
+ }
+
+ int hh1, mm1, ss1, hh2, mm2, ss2;
+ int c = swscanf_s(buff, L"{%d:%d:%d}{%d:%d:%d}", &hh1, &mm1, &ss1, &hh2, &mm2, &ss2);
+
+ if (c == 6) {
+ ret.Add(
+ buff.Mid(buff.Find('}', buff.Find('}') + 1) + 1),
+ file->IsUnicode(),
+ (((hh1 * 60 + mm1) * 60) + ss1) * 1000,
+ (((hh2 * 60 + mm2) * 60) + ss2) * 1000);
+ } else if (c != EOF) { // might be another format
+ return false;
+ }
+ }
+
+ return (ret.GetCount() > 0);
}
static bool OpenSubViewer(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
{
- STSStyle def;
- CStringW font, color, size;
- bool fBold = false;
- bool fItalic = false;
- bool fStriked = false;
- bool fUnderline = false;
-
- CStringW buff;
- while (file->ReadString(buff)) {
- buff.Trim();
- if (buff.IsEmpty()) {
- continue;
- }
-
- if (buff[0] == '[') {
- for (int i = 0; i < buff.GetLength() && buff[i]== '['; ) {
- int j = buff.Find(']', ++i);
- if (j < i) {
- break;
- }
-
- CStringW tag = buff.Mid(i,j-i);
- tag.Trim();
- tag.MakeLower();
-
- i += j-i;
-
- j = buff.Find('[', ++i);
- if (j < 0) {
- j = buff.GetLength();
- }
-
- CStringW param = buff.Mid(i,j-i);
- param.Trim(L" \\t,");
-
- i = j;
-
- if (tag == L"font") {
- font = def.fontName.CompareNoCase(WToT(param)) ? param : L"";
- } else if (tag == L"colf") {
- color = def.colors[0] != (DWORD)wcstol(((LPCWSTR)param)+2, 0, 16) ? param : L"";
- } else if (tag == L"size") {
- size = def.fontSize != (double)wcstol(param, 0, 10) ? param : L"";
- } else if (tag == L"style") {
- if (param.Find(L"no") >= 0) {
- fBold = fItalic = fStriked = fUnderline = false;
- } else {
- fBold = def.fontWeight < FW_BOLD && param.Find(L"bd") >= 0;
- fItalic = def.fItalic && param.Find(L"it") >= 0;
- fStriked = def.fStrikeOut && param.Find(L"st") >= 0;
- fUnderline = def.fUnderline && param.Find(L"ud") >= 0;
- }
- }
- }
-
- continue;
- }
-
- WCHAR sep;
- int hh1, mm1, ss1, hs1, hh2, mm2, ss2, hs2;
- int c = swscanf_s(buff, L"%d:%d:%d%c%d,%d:%d:%d%c%d\n",
- &hh1, &mm1, &ss1, &sep, sizeof(WCHAR),
- &hs1, &hh2, &mm2, &ss2, &sep, sizeof(WCHAR), &hs2);
-
- if (c == 10) {
- CStringW str;
- file->ReadString(str);
-
- str.Replace(L"[br]", L"\\N");
-
- CStringW prefix;
- if (!font.IsEmpty()) {
- prefix += L"\\fn" + font;
- }
- if (!color.IsEmpty()) {
- prefix += L"\\c" + color;
- }
- if (!size.IsEmpty()) {
- prefix += L"\\fs" + size;
- }
- if (fBold) {
- prefix += L"\\b1";
- }
- if (fItalic) {
- prefix += L"\\i1";
- }
- if (fStriked) {
- prefix += L"\\s1";
- }
- if (fUnderline) {
- prefix += L"\\u1";
- }
- if (!prefix.IsEmpty()) {
- str = L"{" + prefix + L"}" + str;
- }
-
- ret.Add(str,
- file->IsUnicode(),
- (((hh1*60 + mm1)*60) + ss1)*1000 + hs1*10,
- (((hh2*60 + mm2)*60) + ss2)*1000 + hs2*10);
- } else if (c != EOF) { // might be another format
- return false;
- }
- }
-
- return (ret.GetCount() > 0);
+ STSStyle def;
+ CStringW font, color, size;
+ bool fBold = false;
+ bool fItalic = false;
+ bool fStriked = false;
+ bool fUnderline = false;
+
+ CStringW buff;
+ while (file->ReadString(buff)) {
+ buff.Trim();
+ if (buff.IsEmpty()) {
+ continue;
+ }
+
+ if (buff[0] == '[') {
+ for (int i = 0; i < buff.GetLength() && buff[i] == '[';) {
+ int j = buff.Find(']', ++i);
+ if (j < i) {
+ break;
+ }
+
+ CStringW tag = buff.Mid(i, j - i);
+ tag.Trim();
+ tag.MakeLower();
+
+ i += j - i;
+
+ j = buff.Find('[', ++i);
+ if (j < 0) {
+ j = buff.GetLength();
+ }
+
+ CStringW param = buff.Mid(i, j - i);
+ param.Trim(L" \\t,");
+
+ i = j;
+
+ if (tag == L"font") {
+ font = def.fontName.CompareNoCase(WToT(param)) ? param : L"";
+ } else if (tag == L"colf") {
+ color = def.colors[0] != (DWORD)wcstol(((LPCWSTR)param) + 2, 0, 16) ? param : L"";
+ } else if (tag == L"size") {
+ size = def.fontSize != (double)wcstol(param, 0, 10) ? param : L"";
+ } else if (tag == L"style") {
+ if (param.Find(L"no") >= 0) {
+ fBold = fItalic = fStriked = fUnderline = false;
+ } else {
+ fBold = def.fontWeight < FW_BOLD && param.Find(L"bd") >= 0;
+ fItalic = def.fItalic && param.Find(L"it") >= 0;
+ fStriked = def.fStrikeOut && param.Find(L"st") >= 0;
+ fUnderline = def.fUnderline && param.Find(L"ud") >= 0;
+ }
+ }
+ }
+
+ continue;
+ }
+
+ WCHAR sep;
+ int hh1, mm1, ss1, hs1, hh2, mm2, ss2, hs2;
+ int c = swscanf_s(buff, L"%d:%d:%d%c%d,%d:%d:%d%c%d\n",
+ &hh1, &mm1, &ss1, &sep, sizeof(WCHAR),
+ &hs1, &hh2, &mm2, &ss2, &sep, sizeof(WCHAR), &hs2);
+
+ if (c == 10) {
+ CStringW str;
+ file->ReadString(str);
+
+ str.Replace(L"[br]", L"\\N");
+
+ CStringW prefix;
+ if (!font.IsEmpty()) {
+ prefix += L"\\fn" + font;
+ }
+ if (!color.IsEmpty()) {
+ prefix += L"\\c" + color;
+ }
+ if (!size.IsEmpty()) {
+ prefix += L"\\fs" + size;
+ }
+ if (fBold) {
+ prefix += L"\\b1";
+ }
+ if (fItalic) {
+ prefix += L"\\i1";
+ }
+ if (fStriked) {
+ prefix += L"\\s1";
+ }
+ if (fUnderline) {
+ prefix += L"\\u1";
+ }
+ if (!prefix.IsEmpty()) {
+ str = L"{" + prefix + L"}" + str;
+ }
+
+ ret.Add(str,
+ file->IsUnicode(),
+ (((hh1 * 60 + mm1) * 60) + ss1) * 1000 + hs1 * 10,
+ (((hh2 * 60 + mm2) * 60) + ss2) * 1000 + hs2 * 10);
+ } else if (c != EOF) { // might be another format
+ return false;
+ }
+ }
+
+ return (ret.GetCount() > 0);
}
static STSStyle* GetMicroDVDStyle(CString str, int CharSet)
{
- STSStyle* ret = DNew STSStyle();
- if (!ret) {
- return NULL;
- }
-
- for (int i = 0, len = str.GetLength(); i < len; i++) {
- int j = str.Find('{', i);
- if (j < 0) {
- j = len;
- }
-
- if (j >= len) {
- break;
- }
-
- int k = str.Find('}', j);
- if (k < 0) {
- k = len;
- }
-
- CString code = str.Mid(j, k-j);
- if (code.GetLength() > 2) {
- code.SetAt(1, (TCHAR)towlower(code[1]));
- }
-
- if (!_tcsnicmp(code, _T("{c:$"), 4)) {
- _stscanf_s(code, _T("{c:$%x"), &ret->colors[0]);
- } else if (!_tcsnicmp(code, _T("{f:"), 3)) {
- ret->fontName = code.Mid(3);
- } else if (!_tcsnicmp(code, _T("{s:"), 3)) {
- double f;
- if (1 == _stscanf_s(code, _T("{s:%lf"), &f)) {
- ret->fontSize = f;
- }
- } else if (!_tcsnicmp(code, _T("{h:"), 3)) {
- _stscanf_s(code, _T("{h:%d"), &ret->charSet);
- } else if (!_tcsnicmp(code, _T("{y:"), 3)) {
- code.MakeLower();
- if (code.Find('b') >= 0) {
- ret->fontWeight = FW_BOLD;
- }
- if (code.Find('i') >= 0) {
- ret->fItalic = true;
- }
- if (code.Find('u') >= 0) {
- ret->fUnderline = true;
- }
- if (code.Find('s') >= 0) {
- ret->fStrikeOut = true;
- }
- } else if (!_tcsnicmp(code, _T("{p:"), 3)) {
- int p;
- _stscanf_s(code, _T("{p:%d"), &p);
- ret->scrAlignment = (p == 0) ? 8 : 2;
- }
-
- i = k;
- }
-
- return ret;
+ STSStyle* ret = DNew STSStyle();
+ if (!ret) {
+ return NULL;
+ }
+
+ for (int i = 0, len = str.GetLength(); i < len; i++) {
+ int j = str.Find('{', i);
+ if (j < 0) {
+ j = len;
+ }
+
+ if (j >= len) {
+ break;
+ }
+
+ int k = str.Find('}', j);
+ if (k < 0) {
+ k = len;
+ }
+
+ CString code = str.Mid(j, k - j);
+ if (code.GetLength() > 2) {
+ code.SetAt(1, (TCHAR)towlower(code[1]));
+ }
+
+ if (!_tcsnicmp(code, _T("{c:$"), 4)) {
+ _stscanf_s(code, _T("{c:$%x"), &ret->colors[0]);
+ } else if (!_tcsnicmp(code, _T("{f:"), 3)) {
+ ret->fontName = code.Mid(3);
+ } else if (!_tcsnicmp(code, _T("{s:"), 3)) {
+ double f;
+ if (1 == _stscanf_s(code, _T("{s:%lf"), &f)) {
+ ret->fontSize = f;
+ }
+ } else if (!_tcsnicmp(code, _T("{h:"), 3)) {
+ _stscanf_s(code, _T("{h:%d"), &ret->charSet);
+ } else if (!_tcsnicmp(code, _T("{y:"), 3)) {
+ code.MakeLower();
+ if (code.Find('b') >= 0) {
+ ret->fontWeight = FW_BOLD;
+ }
+ if (code.Find('i') >= 0) {
+ ret->fItalic = true;
+ }
+ if (code.Find('u') >= 0) {
+ ret->fUnderline = true;
+ }
+ if (code.Find('s') >= 0) {
+ ret->fStrikeOut = true;
+ }
+ } else if (!_tcsnicmp(code, _T("{p:"), 3)) {
+ int p;
+ _stscanf_s(code, _T("{p:%d"), &p);
+ ret->scrAlignment = (p == 0) ? 8 : 2;
+ }
+
+ i = k;
+ }
+
+ return ret;
}
static CStringW MicroDVD2SSA(CStringW str, bool fUnicode, int CharSet)
{
- CStringW ret;
-
- enum {COLOR=0, FONTNAME, FONTSIZE, FONTCHARSET, BOLD, ITALIC, UNDERLINE, STRIKEOUT};
- bool fRestore[8];
- int fRestoreLen = 8;
- memset(fRestore, 0, sizeof(bool)*fRestoreLen);
-
- for (int pos = 0, eol; pos < str.GetLength(); pos++) {
- if ((eol = FindChar(str, '|', pos, fUnicode, CharSet)) < 0) {
- eol = str.GetLength();
- }
-
- CStringW line = str.Mid(pos, eol-pos);
-
- pos = eol;
-
- for (int i = 0, j, k, len = line.GetLength(); i < len; i++) {
- if ((j = FindChar(line, '{', i, fUnicode, CharSet)) < 0) {
- j = str.GetLength();
- }
-
- ret += line.Mid(i, j-i);
-
- if (j >= len) {
- break;
- }
-
- if ((k = FindChar(line, '}', j, fUnicode, CharSet)) < 0) {
- k = len;
- }
-
- {
- CStringW code = line.Mid(j, k-j);
-
- if (!_wcsnicmp(code, L"{c:$", 4)) {
- fRestore[COLOR] = (iswupper(code[1]) == 0);
- code.MakeLower();
-
- int color;
- swscanf_s(code, L"{c:$%x", &color);
- code.Format(L"{\\c&H%x&}", color);
- ret += code;
- } else if (!_wcsnicmp(code, L"{f:", 3)) {
- fRestore[FONTNAME] = (iswupper(code[1]) == 0);
-
- code.Format(L"{\\fn%s}", code.Mid(3));
- ret += code;
- } else if (!_wcsnicmp(code, L"{s:", 3)) {
- fRestore[FONTSIZE] = (iswupper(code[1]) == 0);
- code.MakeLower();
-
- double size;
- swscanf_s(code, L"{s:%lf", &size);
- code.Format(L"{\\fs%f}", size);
- ret += code;
- } else if (!_wcsnicmp(code, L"{h:", 3)) {
- fRestore[COLOR] = (_istupper(code[1]) == 0);
- code.MakeLower();
-
- int CharSet;
- swscanf_s(code, L"{h:%d", &CharSet);
- code.Format(L"{\\fe%d}", CharSet);
- ret += code;
- } else if (!_wcsnicmp(code, L"{y:", 3)) {
- bool f = (_istupper(code[1]) == 0);
-
- code.MakeLower();
-
- ret += '{';
- if (code.Find('b') >= 0) {
- ret += L"\\b1";
- fRestore[BOLD] = f;
- }
- if (code.Find('i') >= 0) {
- ret += L"\\i1";
- fRestore[ITALIC] = f;
- }
- if (code.Find('u') >= 0) {
- ret += L"\\u1";
- fRestore[UNDERLINE] = f;
- }
- if (code.Find('s') >= 0) {
- ret += L"\\s1";
- fRestore[STRIKEOUT] = f;
- }
- ret += '}';
- } else if (!_wcsnicmp(code, L"{o:", 3)) {
- code.MakeLower();
-
- int x, y;
- TCHAR c;
- swscanf_s(code, L"{o:%d%c%d", &x, &c, sizeof(TCHAR), &y);
- code.Format(L"{\\move(%d,%d,0,0,0,0)}", x, y);
- ret += code;
- } else {
- ret += code;
- }
- }
-
- i = k;
- }
-
- if (pos >= str.GetLength()) {
- break;
- }
-
- for (ptrdiff_t i = 0; i < fRestoreLen; i++) {
- if (fRestore[i]) {
- switch (i) {
- case COLOR:
- ret += L"{\\c}";
- break;
- case FONTNAME:
- ret += L"{\\fn}";
- break;
- case FONTSIZE:
- ret += L"{\\fs}";
- break;
- case FONTCHARSET:
- ret += L"{\\fe}";
- break;
- case BOLD:
- ret += L"{\\b}";
- break;
- case ITALIC:
- ret += L"{\\i}";
- break;
- case UNDERLINE:
- ret += L"{\\u}";
- break;
- case STRIKEOUT:
- ret += L"{\\s}";
- break;
- default:
- break;
- }
- }
- }
-
- memset(fRestore, 0, sizeof(bool)*fRestoreLen);
-
- ret += L"\\N";
- }
-
- return ret;
+ CStringW ret;
+
+ enum {COLOR = 0, FONTNAME, FONTSIZE, FONTCHARSET, BOLD, ITALIC, UNDERLINE, STRIKEOUT};
+ bool fRestore[8];
+ int fRestoreLen = 8;
+ memset(fRestore, 0, sizeof(bool)*fRestoreLen);
+
+ for (int pos = 0, eol; pos < str.GetLength(); pos++) {
+ if ((eol = FindChar(str, '|', pos, fUnicode, CharSet)) < 0) {
+ eol = str.GetLength();
+ }
+
+ CStringW line = str.Mid(pos, eol - pos);
+
+ pos = eol;
+
+ for (int i = 0, j, k, len = line.GetLength(); i < len; i++) {
+ if ((j = FindChar(line, '{', i, fUnicode, CharSet)) < 0) {
+ j = str.GetLength();
+ }
+
+ ret += line.Mid(i, j - i);
+
+ if (j >= len) {
+ break;
+ }
+
+ if ((k = FindChar(line, '}', j, fUnicode, CharSet)) < 0) {
+ k = len;
+ }
+
+ {
+ CStringW code = line.Mid(j, k - j);
+
+ if (!_wcsnicmp(code, L"{c:$", 4)) {
+ fRestore[COLOR] = (iswupper(code[1]) == 0);
+ code.MakeLower();
+
+ int color;
+ swscanf_s(code, L"{c:$%x", &color);
+ code.Format(L"{\\c&H%x&}", color);
+ ret += code;
+ } else if (!_wcsnicmp(code, L"{f:", 3)) {
+ fRestore[FONTNAME] = (iswupper(code[1]) == 0);
+
+ code.Format(L"{\\fn%s}", code.Mid(3));
+ ret += code;
+ } else if (!_wcsnicmp(code, L"{s:", 3)) {
+ fRestore[FONTSIZE] = (iswupper(code[1]) == 0);
+ code.MakeLower();
+
+ double size;
+ swscanf_s(code, L"{s:%lf", &size);
+ code.Format(L"{\\fs%f}", size);
+ ret += code;
+ } else if (!_wcsnicmp(code, L"{h:", 3)) {
+ fRestore[COLOR] = (_istupper(code[1]) == 0);
+ code.MakeLower();
+
+ int CharSet;
+ swscanf_s(code, L"{h:%d", &CharSet);
+ code.Format(L"{\\fe%d}", CharSet);
+ ret += code;
+ } else if (!_wcsnicmp(code, L"{y:", 3)) {
+ bool f = (_istupper(code[1]) == 0);
+
+ code.MakeLower();
+
+ ret += '{';
+ if (code.Find('b') >= 0) {
+ ret += L"\\b1";
+ fRestore[BOLD] = f;
+ }
+ if (code.Find('i') >= 0) {
+ ret += L"\\i1";
+ fRestore[ITALIC] = f;
+ }
+ if (code.Find('u') >= 0) {
+ ret += L"\\u1";
+ fRestore[UNDERLINE] = f;
+ }
+ if (code.Find('s') >= 0) {
+ ret += L"\\s1";
+ fRestore[STRIKEOUT] = f;
+ }
+ ret += '}';
+ } else if (!_wcsnicmp(code, L"{o:", 3)) {
+ code.MakeLower();
+
+ int x, y;
+ TCHAR c;
+ swscanf_s(code, L"{o:%d%c%d", &x, &c, sizeof(TCHAR), &y);
+ code.Format(L"{\\move(%d,%d,0,0,0,0)}", x, y);
+ ret += code;
+ } else {
+ ret += code;
+ }
+ }
+
+ i = k;
+ }
+
+ if (pos >= str.GetLength()) {
+ break;
+ }
+
+ for (ptrdiff_t i = 0; i < fRestoreLen; i++) {
+ if (fRestore[i]) {
+ switch (i) {
+ case COLOR:
+ ret += L"{\\c}";
+ break;
+ case FONTNAME:
+ ret += L"{\\fn}";
+ break;
+ case FONTSIZE:
+ ret += L"{\\fs}";
+ break;
+ case FONTCHARSET:
+ ret += L"{\\fe}";
+ break;
+ case BOLD:
+ ret += L"{\\b}";
+ break;
+ case ITALIC:
+ ret += L"{\\i}";
+ break;
+ case UNDERLINE:
+ ret += L"{\\u}";
+ break;
+ case STRIKEOUT:
+ ret += L"{\\s}";
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ memset(fRestore, 0, sizeof(bool)*fRestoreLen);
+
+ ret += L"\\N";
+ }
+
+ return ret;
}
static bool OpenMicroDVD(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
{
- bool fCheck = false, fCheck2 = false;
-
- CString style(_T("Default"));
-
- CStringW buff;
- while (file->ReadString(buff)) {
- buff.Trim();
- if (buff.IsEmpty()) {
- continue;
- }
-
- int start, end;
- int c = swscanf_s(buff, L"{%d}{%d}", &start, &end);
-
- if (c != 2) {
- c = swscanf_s(buff, L"{%d}{}", &start) + 1;
- end = start + 60;
- fCheck = true;
- }
-
- if (c != 2) {
- int i;
- if (buff.Find('{') == 0 && (i = buff.Find('}')) > 1 && i < buff.GetLength()) {
- if (STSStyle* s = GetMicroDVDStyle(WToT(buff.Mid(i+1)), CharSet)) {
- style = buff.Mid(1, i-1);
- style.MakeUpper();
- if (style.GetLength()) {
- CString str = style.Mid(1);
- str.MakeLower();
- style = style.Left(1) + str;
- }
- ret.AddStyle(style, s);
- CharSet = s->charSet;
- continue;
- }
- }
- }
-
- if (c == 2) {
- if (fCheck2 && ret.GetCount()) {
- STSEntry& stse = ret[ret.GetCount()-1];
- stse.end = min(stse.end, start);
- fCheck2 = false;
- }
-
- ret.Add(
- MicroDVD2SSA(buff.Mid(buff.Find('}', buff.Find('}')+1)+1), file->IsUnicode(), CharSet),
- file->IsUnicode(),
- start, end,
- style);
-
- if (fCheck) {
- fCheck = false;
- fCheck2 = true;
- }
- } else if (c != EOF) { // might be another format
- return false;
- }
- }
-
- return (ret.GetCount() > 0);
+ bool fCheck = false, fCheck2 = false;
+
+ CString style(_T("Default"));
+
+ CStringW buff;
+ while (file->ReadString(buff)) {
+ buff.Trim();
+ if (buff.IsEmpty()) {
+ continue;
+ }
+
+ int start, end;
+ int c = swscanf_s(buff, L"{%d}{%d}", &start, &end);
+
+ if (c != 2) {
+ c = swscanf_s(buff, L"{%d}{}", &start) + 1;
+ end = start + 60;
+ fCheck = true;
+ }
+
+ if (c != 2) {
+ int i;
+ if (buff.Find('{') == 0 && (i = buff.Find('}')) > 1 && i < buff.GetLength()) {
+ if (STSStyle* s = GetMicroDVDStyle(WToT(buff.Mid(i + 1)), CharSet)) {
+ style = buff.Mid(1, i - 1);
+ style.MakeUpper();
+ if (style.GetLength()) {
+ CString str = style.Mid(1);
+ str.MakeLower();
+ style = style.Left(1) + str;
+ }
+ ret.AddStyle(style, s);
+ CharSet = s->charSet;
+ continue;
+ }
+ }
+ }
+
+ if (c == 2) {
+ if (fCheck2 && ret.GetCount()) {
+ STSEntry& stse = ret[ret.GetCount() - 1];
+ stse.end = min(stse.end, start);
+ fCheck2 = false;
+ }
+
+ ret.Add(
+ MicroDVD2SSA(buff.Mid(buff.Find('}', buff.Find('}') + 1) + 1), file->IsUnicode(), CharSet),
+ file->IsUnicode(),
+ start, end,
+ style);
+
+ if (fCheck) {
+ fCheck = false;
+ fCheck2 = true;
+ }
+ } else if (c != EOF) { // might be another format
+ return false;
+ }
+ }
+
+ return (ret.GetCount() > 0);
}
static void ReplaceNoCase(CStringW& str, CStringW from, CStringW to)
{
- CStringW lstr = str;
- lstr.MakeLower();
+ CStringW lstr = str;
+ lstr.MakeLower();
- int i, j, k;
+ int i, j, k;
- for (i = 0, j = str.GetLength(); i < j; ) {
- if ((k = lstr.Find(from, i)) >= 0) {
- str.Delete(k, from.GetLength());
- lstr.Delete(k, from.GetLength());
- str.Insert(k, to);
- lstr.Insert(k, to);
- i = k + to.GetLength();
- j = str.GetLength();
- } else {
- break;
- }
- }
+ for (i = 0, j = str.GetLength(); i < j;) {
+ if ((k = lstr.Find(from, i)) >= 0) {
+ str.Delete(k, from.GetLength());
+ lstr.Delete(k, from.GetLength());
+ str.Insert(k, to);
+ lstr.Insert(k, to);
+ i = k + to.GetLength();
+ j = str.GetLength();
+ } else {
+ break;
+ }
+ }
}
static CStringW SMI2SSA(CStringW str, int CharSet)
{
- ReplaceNoCase(str, L"&nbsp;", L" ");
- ReplaceNoCase(str, L"&quot;", L"\"");
- ReplaceNoCase(str, L"<br>", L"\\N");
- ReplaceNoCase(str, L"<i>", L"{\\i1}");
- ReplaceNoCase(str, L"</i>", L"{\\i}");
- ReplaceNoCase(str, L"<b>", L"{\\b1}");
- ReplaceNoCase(str, L"</b>", L"{\\b}");
-
- CStringW lstr = str;
- lstr.MakeLower();
-
- // maven@maven.de
- // now parse line
- for (int i = 0, j = str.GetLength(); i < j; ) {
- int k;
- if ((k = lstr.Find('<', i)) < 0) {
- break;
- }
-
- int chars_inserted = 0;
-
- int l = 1;
- for (; k+l < j && lstr[k+l] != '>'; l++) {
- ;
- }
- l++;
-
- // Modified by Cookie Monster
- if (lstr.Find(L"<font ", k) == k) {
- CStringW args = lstr.Mid(k+6, l-6); // delete "<font "
- CStringW arg ;
-
- args.Remove('\"');
- args.Remove('#'); // may include 2 * " + #
- arg.TrimLeft();
- arg.TrimRight(L" >");
-
- for (;;) {
- args.TrimLeft();
- arg = args.SpanExcluding(L" \t>");
- args = args.Mid(arg.GetLength());
-
- if (arg.IsEmpty()) {
- break;
- }
- if (arg.Find(L"color=") == 0 ) {
- DWORD color;
-
- arg = arg.Mid(6); // delete "color="
- if ( arg.IsEmpty()) {
- continue;
- }
-
- DWORD val;
- if (g_colors.Lookup(CString(arg), val)) {
- color = (DWORD)val;
- } else if ((color = wcstol(arg, NULL, 16) ) == 0) {
- color = 0x00ffffff; // default is white
- }
-
- arg.Format(L"%02x%02x%02x", color&0xff, (color>>8)&0xff, (color>>16)&0xff);
- lstr.Insert(k + l + chars_inserted, CStringW(L"{\\c&H") + arg + L"&}");
- str.Insert(k + l + chars_inserted, CStringW(L"{\\c&H") + arg + L"&}");
- chars_inserted += 5 + arg.GetLength() + 2;
- }
- /*
- else if (arg.Find(_T("size=" )) == 0 )
- {
- uint fsize;
-
- arg = arg.Mid(5); // delete "size="
- if ( arg.GetLength() == 0)
- continue;
-
- if ( fsize = _tcstol(arg, &tmp, 10) == 0 )
- continue;
-
- lstr.Insert(k + l + chars_inserted, CString(_T("{\\fs")) + arg + _T("&}"));
- str.Insert(k + l + chars_inserted, CString(_T("{\\fs")) + arg + _T("&}"));
- chars_inserted += 4 + arg.GetLength() + 2;
- }
- */
- }
- }
-
- // Original Code
- /*
- if (lstr.Find(L"<font color=", k) == k)
- {
- CStringW arg = lstr.Mid(k+12, l-12); // may include 2 * " + #
-
- arg.Remove('\"');
- arg.Remove('#');
- arg.TrimLeft(); arg.TrimRight(L" >");
-
- if (arg.GetLength() > 0)
- {
- DWORD color;
-
- CString key = WToT(arg);
- void* val;
- if (g_colors.Lookup(key, val)) color = (DWORD)val;
- else color = wcstol(arg, NULL, 16);
-
- arg.Format(L"%02x%02x%02x", color&0xff, (color>>8)&0xff, (color>>16)&0xff);
- }
-
- lstr.Insert(k + l + chars_inserted, L"{\\c&H" + arg + L"&}");
- str.Insert(k + l + chars_inserted, L"{\\c&H" + arg + L"&}");
- chars_inserted += 5 + arg.GetLength() + 2;
- }
- */
- else if (lstr.Find(L"</font>", k) == k) {
- lstr.Insert(k + l + chars_inserted, L"{\\c}");
- str.Insert(k + l + chars_inserted, L"{\\c}");
- chars_inserted += 4;
- }
-
- str.Delete(k, l);
- lstr.Delete(k, l);
- i = k + chars_inserted;
- j = str.GetLength();
- }
-
- return str;
+ ReplaceNoCase(str, L"&nbsp;", L" ");
+ ReplaceNoCase(str, L"&quot;", L"\"");
+ ReplaceNoCase(str, L"<br>", L"\\N");
+ ReplaceNoCase(str, L"<i>", L"{\\i1}");
+ ReplaceNoCase(str, L"</i>", L"{\\i}");
+ ReplaceNoCase(str, L"<b>", L"{\\b1}");
+ ReplaceNoCase(str, L"</b>", L"{\\b}");
+
+ CStringW lstr = str;
+ lstr.MakeLower();
+
+ // maven@maven.de
+ // now parse line
+ for (int i = 0, j = str.GetLength(); i < j;) {
+ int k;
+ if ((k = lstr.Find('<', i)) < 0) {
+ break;
+ }
+
+ int chars_inserted = 0;
+
+ int l = 1;
+ for (; k + l < j && lstr[k + l] != '>'; l++) {
+ ;
+ }
+ l++;
+
+ // Modified by Cookie Monster
+ if (lstr.Find(L"<font ", k) == k) {
+ CStringW args = lstr.Mid(k + 6, l - 6); // delete "<font "
+ CStringW arg ;
+
+ args.Remove('\"');
+ args.Remove('#'); // may include 2 * " + #
+ arg.TrimLeft();
+ arg.TrimRight(L" >");
+
+ for (;;) {
+ args.TrimLeft();
+ arg = args.SpanExcluding(L" \t>");
+ args = args.Mid(arg.GetLength());
+
+ if (arg.IsEmpty()) {
+ break;
+ }
+ if (arg.Find(L"color=") == 0) {
+ DWORD color;
+
+ arg = arg.Mid(6); // delete "color="
+ if (arg.IsEmpty()) {
+ continue;
+ }
+
+ DWORD val;
+ if (g_colors.Lookup(CString(arg), val)) {
+ color = (DWORD)val;
+ } else if ((color = wcstol(arg, NULL, 16)) == 0) {
+ color = 0x00ffffff; // default is white
+ }
+
+ arg.Format(L"%02x%02x%02x", color & 0xff, (color >> 8) & 0xff, (color >> 16) & 0xff);
+ lstr.Insert(k + l + chars_inserted, CStringW(L"{\\c&H") + arg + L"&}");
+ str.Insert(k + l + chars_inserted, CStringW(L"{\\c&H") + arg + L"&}");
+ chars_inserted += 5 + arg.GetLength() + 2;
+ }
+ /*
+ else if (arg.Find(_T("size=" )) == 0 )
+ {
+ uint fsize;
+
+ arg = arg.Mid(5); // delete "size="
+ if ( arg.GetLength() == 0)
+ continue;
+
+ if ( fsize = _tcstol(arg, &tmp, 10) == 0 )
+ continue;
+
+ lstr.Insert(k + l + chars_inserted, CString(_T("{\\fs")) + arg + _T("&}"));
+ str.Insert(k + l + chars_inserted, CString(_T("{\\fs")) + arg + _T("&}"));
+ chars_inserted += 4 + arg.GetLength() + 2;
+ }
+ */
+ }
+ }
+
+ // Original Code
+ /*
+ if (lstr.Find(L"<font color=", k) == k)
+ {
+ CStringW arg = lstr.Mid(k+12, l-12); // may include 2 * " + #
+
+ arg.Remove('\"');
+ arg.Remove('#');
+ arg.TrimLeft(); arg.TrimRight(L" >");
+
+ if (arg.GetLength() > 0)
+ {
+ DWORD color;
+
+ CString key = WToT(arg);
+ void* val;
+ if (g_colors.Lookup(key, val)) color = (DWORD)val;
+ else color = wcstol(arg, NULL, 16);
+
+ arg.Format(L"%02x%02x%02x", color&0xff, (color>>8)&0xff, (color>>16)&0xff);
+ }
+
+ lstr.Insert(k + l + chars_inserted, L"{\\c&H" + arg + L"&}");
+ str.Insert(k + l + chars_inserted, L"{\\c&H" + arg + L"&}");
+ chars_inserted += 5 + arg.GetLength() + 2;
+ }
+ */
+ else if (lstr.Find(L"</font>", k) == k) {
+ lstr.Insert(k + l + chars_inserted, L"{\\c}");
+ str.Insert(k + l + chars_inserted, L"{\\c}");
+ chars_inserted += 4;
+ }
+
+ str.Delete(k, l);
+ lstr.Delete(k, l);
+ i = k + chars_inserted;
+ j = str.GetLength();
+ }
+
+ return str;
}
static bool OpenSami(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
{
- CStringW buff, caption;
+ CStringW buff, caption;
- ULONGLONG pos = file->GetPosition();
+ ULONGLONG pos = file->GetPosition();
- bool fSAMI = false;
+ bool fSAMI = false;
- while (file->ReadString(buff) && !fSAMI) {
- if (buff.MakeUpper().Find(L"<SAMI>") >= 0) {
- fSAMI = true;
- }
- }
+ while (file->ReadString(buff) && !fSAMI) {
+ if (buff.MakeUpper().Find(L"<SAMI>") >= 0) {
+ fSAMI = true;
+ }
+ }
- if (!fSAMI) {
- return false;
- }
+ if (!fSAMI) {
+ return false;
+ }
- file->Seek(pos, 0);
+ file->Seek(pos, 0);
- bool fComment = false;
+ bool fComment = false;
- int start_time = 0;
+ int start_time = 0;
- while (file->ReadString(buff)) {
- buff.Trim();
- if (buff.IsEmpty()) {
- continue;
- }
+ while (file->ReadString(buff)) {
+ buff.Trim();
+ if (buff.IsEmpty()) {
+ continue;
+ }
- CStringW ubuff = buff;
- ubuff.MakeUpper();
+ CStringW ubuff = buff;
+ ubuff.MakeUpper();
- if (ubuff.Find(L"<!--") >= 0 || ubuff.Find(L"<TITLE>") >= 0) {
- fComment = true;
- }
+ if (ubuff.Find(L"<!--") >= 0 || ubuff.Find(L"<TITLE>") >= 0) {
+ fComment = true;
+ }
- if (!fComment) {
- int i;
+ if (!fComment) {
+ int i;
- if ((i = ubuff.Find(L"<SYNC START=")) >= 0) {
- int time = 0;
+ if ((i = ubuff.Find(L"<SYNC START=")) >= 0) {
+ int time = 0;
- for (i = 12; i < ubuff.GetLength(); i++) {
- if (ubuff[i] != '>' && ubuff[i] != 'M') {
- if (iswdigit(ubuff[i])) {
- time *= 10;
- time += ubuff[i] - 0x30;
- }
- } else {
- break;
- }
- }
+ for (i = 12; i < ubuff.GetLength(); i++) {
+ if (ubuff[i] != '>' && ubuff[i] != 'M') {
+ if (iswdigit(ubuff[i])) {
+ time *= 10;
+ time += ubuff[i] - 0x30;
+ }
+ } else {
+ break;
+ }
+ }
- ret.Add(
- SMI2SSA(caption, CharSet),
- file->IsUnicode(),
- start_time, time);
+ ret.Add(
+ SMI2SSA(caption, CharSet),
+ file->IsUnicode(),
+ start_time, time);
- start_time = time;
- caption.Empty();
- }
+ start_time = time;
+ caption.Empty();
+ }
- caption += buff;
- }
+ caption += buff;
+ }
- if (ubuff.Find(L"-->") >= 0 || ubuff.Find(L"</TITLE>") >= 0) {
- fComment = false;
- }
- }
+ if (ubuff.Find(L"-->") >= 0 || ubuff.Find(L"</TITLE>") >= 0) {
+ fComment = false;
+ }
+ }
- ret.Add(
- SMI2SSA(caption, CharSet),
- file->IsUnicode(),
- start_time, MAXLONG);
+ ret.Add(
+ SMI2SSA(caption, CharSet),
+ file->IsUnicode(),
+ start_time, MAXLONG);
- return true;
+ return true;
}
static bool OpenVPlayer(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
{
- CStringW buff;
- while (file->ReadString(buff)) {
- buff.Trim();
- if (buff.IsEmpty()) {
- continue;
- }
-
- for (int i = 0; i < buff.GetLength(); i++) {
- if ((i = FindChar(buff, '|', i, file->IsUnicode(), CharSet)) < 0) {
- break;
- }
- buff.SetAt(i, '\n');
- }
-
- int hh, mm, ss;
- int c = swscanf_s(buff, L"%d:%d:%d:", &hh, &mm, &ss);
-
- if (c == 3) {
- CStringW str = buff.Mid(buff.Find(':', buff.Find(':', buff.Find(':')+1)+1)+1);
- ret.Add(str,
- file->IsUnicode(),
- (((hh*60 + mm)*60) + ss)*1000,
- (((hh*60 + mm)*60) + ss)*1000 + 1000 + 50*str.GetLength());
- } else if (c != EOF) { // might be another format
- return false;
- }
- }
-
- return (ret.GetCount() > 0);
+ CStringW buff;
+ while (file->ReadString(buff)) {
+ buff.Trim();
+ if (buff.IsEmpty()) {
+ continue;
+ }
+
+ for (int i = 0; i < buff.GetLength(); i++) {
+ if ((i = FindChar(buff, '|', i, file->IsUnicode(), CharSet)) < 0) {
+ break;
+ }
+ buff.SetAt(i, '\n');
+ }
+
+ int hh, mm, ss;
+ int c = swscanf_s(buff, L"%d:%d:%d:", &hh, &mm, &ss);
+
+ if (c == 3) {
+ CStringW str = buff.Mid(buff.Find(':', buff.Find(':', buff.Find(':') + 1) + 1) + 1);
+ ret.Add(str,
+ file->IsUnicode(),
+ (((hh * 60 + mm) * 60) + ss) * 1000,
+ (((hh * 60 + mm) * 60) + ss) * 1000 + 1000 + 50 * str.GetLength());
+ } else if (c != EOF) { // might be another format
+ return false;
+ }
+ }
+
+ return (ret.GetCount() > 0);
}
CStringW GetStr(CStringW& buff, char sep = ',') //throw(...)
{
- buff.TrimLeft();
+ buff.TrimLeft();
- int pos = buff.Find(sep);
- if (pos < 0) {
- pos = buff.GetLength();
- if (pos < 1) {
- throw 1;
- }
- }
+ int pos = buff.Find(sep);
+ if (pos < 0) {
+ pos = buff.GetLength();
+ if (pos < 1) {
+ throw 1;
+ }
+ }
- CStringW ret = buff.Left(pos);
- if (pos < buff.GetLength()) {
- buff = buff.Mid(pos+1);
- }
+ CStringW ret = buff.Left(pos);
+ if (pos < buff.GetLength()) {
+ buff = buff.Mid(pos + 1);
+ }
- return ret;
+ return ret;
}
int GetInt(CStringW& buff, char sep = ',') //throw(...)
{
- CStringW str;
+ CStringW str;
- str = GetStr(buff, sep);
- str.MakeLower();
+ str = GetStr(buff, sep);
+ str.MakeLower();
- CStringW fmtstr = str.GetLength() > 2 && (str.Left(2) == L"&h" || str.Left(2) == L"0x")
- ? str = str.Mid(2), L"%x"
- : L"%d";
+ CStringW fmtstr = str.GetLength() > 2 && (str.Left(2) == L"&h" || str.Left(2) == L"0x")
+ ? str = str.Mid(2), L"%x"
+ : L"%d";
- int ret;
- if (swscanf_s(str, fmtstr, &ret) != 1) {
- throw 1;
- }
+ int ret;
+ if (swscanf_s(str, fmtstr, &ret) != 1) {
+ throw 1;
+ }
- return ret;
+ return ret;
}
double GetFloat(CStringW& buff, char sep = ',') //throw(...)
{
- CStringW str;
+ CStringW str;
- str = GetStr(buff, sep);
- str.MakeLower();
+ str = GetStr(buff, sep);
+ str.MakeLower();
- double ret;
- if (swscanf_s(str, L"%lf", &ret) != 1) {
- throw 1;
- }
+ double ret;
+ if (swscanf_s(str, L"%lf", &ret) != 1) {
+ throw 1;
+ }
- return ret;
+ return ret;
}
static bool LoadFont(CString& font)
{
- int len = font.GetLength();
+ int len = font.GetLength();
- CAutoVectorPtr<BYTE> pData;
- if (len == 0 || (len&3) == 1 || !pData.Allocate(len)) {
- return false;
- }
+ CAutoVectorPtr<BYTE> pData;
+ if (len == 0 || (len & 3) == 1 || !pData.Allocate(len)) {
+ return false;
+ }
- const TCHAR* s = font;
- const TCHAR* e = s + len;
- for (BYTE* p = pData; s < e; s++, p++) {
- *p = *s - 33;
- }
+ const TCHAR* s = font;
+ const TCHAR* e = s + len;
+ for (BYTE* p = pData; s < e; s++, p++) {
+ *p = *s - 33;
+ }
- for (ptrdiff_t i = 0, j = 0, k = len&~3; i < k; i+=4, j+=3) {
- pData[j+0] = ((pData[i+0]&63)<<2)|((pData[i+1]>>4)& 3);
- pData[j+1] = ((pData[i+1]&15)<<4)|((pData[i+2]>>2)&15);
- pData[j+2] = ((pData[i+2]& 3)<<6)|((pData[i+3]>>0)&63);
- }
+ for (ptrdiff_t i = 0, j = 0, k = len&~3; i < k; i += 4, j += 3) {
+ pData[j + 0] = ((pData[i + 0] & 63) << 2) | ((pData[i + 1] >> 4) & 3);
+ pData[j + 1] = ((pData[i + 1] & 15) << 4) | ((pData[i + 2] >> 2) & 15);
+ pData[j + 2] = ((pData[i + 2] & 3) << 6) | ((pData[i + 3] >> 0) & 63);
+ }
- int datalen = (len&~3)*3/4;
+ int datalen = (len&~3) * 3 / 4;
- if ((len&3) == 2) {
- pData[datalen++] = ((pData[(len&~3)+0]&63)<<2)|((pData[(len&~3)+1]>>4)&3);
- } else if ((len&3) == 3) {
- pData[datalen++] = ((pData[(len&~3)+0]&63)<<2)|((pData[(len&~3)+1]>>4)& 3);
- pData[datalen++] = ((pData[(len&~3)+1]&15)<<4)|((pData[(len&~3)+2]>>2)&15);
- }
+ if ((len & 3) == 2) {
+ pData[datalen++] = ((pData[(len&~3) + 0] & 63) << 2) | ((pData[(len&~3) + 1] >> 4) & 3);
+ } else if ((len & 3) == 3) {
+ pData[datalen++] = ((pData[(len&~3) + 0] & 63) << 2) | ((pData[(len&~3) + 1] >> 4) & 3);
+ pData[datalen++] = ((pData[(len&~3) + 1] & 15) << 4) | ((pData[(len&~3) + 2] >> 2) & 15);
+ }
- HANDLE hFont = INVALID_HANDLE_VALUE;
+ HANDLE hFont = INVALID_HANDLE_VALUE;
- if (HMODULE hModule = LoadLibrary(_T("gdi32.dll"))) {
- typedef HANDLE (WINAPI *PAddFontMemResourceEx)( IN PVOID, IN DWORD, IN PVOID , IN DWORD*);
- if (PAddFontMemResourceEx f = (PAddFontMemResourceEx)GetProcAddress(hModule, "AddFontMemResourceEx")) {
- DWORD cFonts;
- hFont = f(pData, datalen, NULL, &cFonts);
- }
+ if (HMODULE hModule = LoadLibrary(_T("gdi32.dll"))) {
+ typedef HANDLE(WINAPI * PAddFontMemResourceEx)(IN PVOID, IN DWORD, IN PVOID , IN DWORD*);
+ if (PAddFontMemResourceEx f = (PAddFontMemResourceEx)GetProcAddress(hModule, "AddFontMemResourceEx")) {
+ DWORD cFonts;
+ hFont = f(pData, datalen, NULL, &cFonts);
+ }
- FreeLibrary(hModule);
- }
+ FreeLibrary(hModule);
+ }
- if (hFont == INVALID_HANDLE_VALUE) {
- TCHAR path[_MAX_PATH];
- GetTempPath(_MAX_PATH, path);
+ if (hFont == INVALID_HANDLE_VALUE) {
+ TCHAR path[_MAX_PATH];
+ GetTempPath(_MAX_PATH, path);
- DWORD chksum = 0;
- for (ptrdiff_t i = 0, j = datalen>>2; i < j; i++) {
- chksum += ((DWORD*)(BYTE*)pData)[i];
- }
+ DWORD chksum = 0;
+ for (ptrdiff_t i = 0, j = datalen >> 2; i < j; i++) {
+ chksum += ((DWORD*)(BYTE*)pData)[i];
+ }
- CString fn;
- fn.Format(_T("%sfont%08x.ttf"), path, chksum);
+ CString fn;
+ fn.Format(_T("%sfont%08x.ttf"), path, chksum);
- CFileStatus fs;
- if (!CFileGetStatus(fn, fs)) {
- CFile f;
- if (f.Open(fn, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary|CFile::shareDenyNone)) {
- f.Write(pData, datalen);
- f.Close();
- }
- }
+ CFileStatus fs;
+ if (!CFileGetStatus(fn, fs)) {
+ CFile f;
+ if (f.Open(fn, CFile::modeCreate | CFile::modeWrite | CFile::typeBinary | CFile::shareDenyNone)) {
+ f.Write(pData, datalen);
+ f.Close();
+ }
+ }
- AddFontResource(fn);
- }
+ AddFontResource(fn);
+ }
- return true;
+ return true;
}
static bool LoadUUEFont(CTextFile* file)
{
- CString s, font;
- while (file->ReadString(s)) {
- s.Trim();
- if (s.IsEmpty()) {
- break;
- }
- if (s[0] == '[') { // check for some standatr blocks
- if (s.Find(_T("[Script Info]")) == 0) {
- break;
- }
- if (s.Find(_T("[V4+ Styles]")) == 0) {
- break;
- }
- if (s.Find(_T("[V4 Styles]")) == 0) {
- break;
- }
- if (s.Find(_T("[Events]")) == 0) {
- break;
- }
- if (s.Find(_T("[Fonts]")) == 0) {
- break;
- }
- if (s.Find(_T("[Graphics]")) == 0) {
- break;
- }
- }
- if (s.Find(_T("fontname:")) == 0) {
- LoadFont(font);
- font.Empty();
- continue;
- }
-
- font += s;
- }
-
- if (!font.IsEmpty()) {
- LoadFont(font);
- }
-
- return true;
+ CString s, font;
+ while (file->ReadString(s)) {
+ s.Trim();
+ if (s.IsEmpty()) {
+ break;
+ }
+ if (s[0] == '[') { // check for some standatr blocks
+ if (s.Find(_T("[Script Info]")) == 0) {
+ break;
+ }
+ if (s.Find(_T("[V4+ Styles]")) == 0) {
+ break;
+ }
+ if (s.Find(_T("[V4 Styles]")) == 0) {
+ break;
+ }
+ if (s.Find(_T("[Events]")) == 0) {
+ break;
+ }
+ if (s.Find(_T("[Fonts]")) == 0) {
+ break;
+ }
+ if (s.Find(_T("[Graphics]")) == 0) {
+ break;
+ }
+ }
+ if (s.Find(_T("fontname:")) == 0) {
+ LoadFont(font);
+ font.Empty();
+ continue;
+ }
+
+ font += s;
+ }
+
+ if (!font.IsEmpty()) {
+ LoadFont(font);
+ }
+
+ return true;
}
static bool OpenSubStationAlpha(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
{
- bool fRet = false;
-
- int version = 3, sver = 3;
-
- CStringW buff;
- while (file->ReadString(buff)) {
- buff.Trim();
- if (buff.IsEmpty() || buff.GetAt(0) == ';') {
- continue;
- }
-
- CStringW entry;
-
- // try {
- entry = GetStr(buff, ':');
- // }
- // catch(...) {continue;}
-
- entry.MakeLower();
-
- if (entry == L"[script info]") {
- fRet = true;
- } else if (entry == L"playresx") {
- try {
- ret.m_dstScreenSize.cx = GetInt(buff);
- } catch (...) {
- ret.m_dstScreenSize = CSize(0, 0);
- return false;
- }
-
- if (ret.m_dstScreenSize.cy <= 0) {
- ret.m_dstScreenSize.cy = (ret.m_dstScreenSize.cx == 1280)
- ? 1024
- : ret.m_dstScreenSize.cx * 3 / 4;
- }
- } else if (entry == L"playresy") {
- try {
- ret.m_dstScreenSize.cy = GetInt(buff);
- } catch (...) {
- ret.m_dstScreenSize = CSize(0, 0);
- return false;
- }
-
- if (ret.m_dstScreenSize.cx <= 0) {
- ret.m_dstScreenSize.cx = (ret.m_dstScreenSize.cy == 1024)
- ? 1280
- : ret.m_dstScreenSize.cy * 4 / 3;
- }
- } else if (entry == L"wrapstyle") {
- try {
- ret.m_defaultWrapStyle = GetInt(buff);
- } catch (...) {
- ret.m_defaultWrapStyle = 1;
- return false;
- }
- } else if (entry == L"scripttype") {
- if (buff.GetLength() >= 4 && !buff.Right(4).CompareNoCase(L"4.00")) {
- version = sver = 4;
- } else if (buff.GetLength() >= 5 && !buff.Right(5).CompareNoCase(L"4.00+")) {
- version = sver = 5;
- } else if (buff.GetLength() >= 6 && !buff.Right(6).CompareNoCase(L"4.00++")) {
- version = sver = 6;
- }
- } else if (entry == L"collisions") {
- buff = GetStr(buff);
- buff.MakeLower();
- ret.m_collisions = buff.Find(L"reverse") >= 0 ? 1 : 0;
- } else if (entry == L"scaledborderandshadow") {
- buff = GetStr(buff);
- buff.MakeLower();
- ret.m_fScaledBAS = buff.Find(L"yes") >= 0;
- } else if (entry == L"[v4 styles]") {
- fRet = true;
- sver = 4;
- } else if (entry == L"[v4+ styles]") {
- fRet = true;
- sver = 5;
- } else if (entry == L"[v4++ styles]") {
- fRet = true;
- sver = 6;
- } else if (entry == L"style") {
- STSStyle* style = DNew STSStyle;
- if (!style) {
- return false;
- }
-
- try {
- CString StyleName;
- int alpha = 0;
-
- StyleName = WToT(GetStr(buff));
- style->fontName = WToT(GetStr(buff));
- style->fontSize = GetFloat(buff);
- for (size_t i = 0; i < 4; i++) {
- style->colors[i] = (COLORREF)GetInt(buff);
- }
- style->fontWeight = GetInt(buff) ? FW_BOLD : FW_NORMAL;
- style->fItalic = GetInt(buff);
- if (sver >= 5) {
- style->fUnderline = GetInt(buff);
- }
- if (sver >= 5) {
- style->fStrikeOut = GetInt(buff);
- }
- if (sver >= 5) {
- style->fontScaleX = GetFloat(buff);
- }
- if (sver >= 5) {
- style->fontScaleY = GetFloat(buff);
- }
- if (sver >= 5) {
- style->fontSpacing = GetFloat(buff);
- }
- if (sver >= 5) {
- style->fontAngleZ = GetFloat(buff);
- }
- if (sver >= 4) {
- style->borderStyle = GetInt(buff);
- }
- style->outlineWidthX = style->outlineWidthY = GetFloat(buff);
- style->shadowDepthX = style->shadowDepthY = GetFloat(buff);
- style->scrAlignment = GetInt(buff);
- style->marginRect.left = GetInt(buff);
- style->marginRect.right = GetInt(buff);
- style->marginRect.top = style->marginRect.bottom = GetInt(buff);
- if (sver >= 6) {
- style->marginRect.bottom = GetInt(buff);
- }
- if (sver <= 4) {
- alpha = GetInt(buff);
- }
- style->charSet = GetInt(buff);
- if (sver >= 6) {
- style->relativeTo = GetInt(buff);
- }
-
- if (sver <= 4) {
- style->colors[2] = style->colors[3]; // style->colors[2] is used for drawing the outline
- }
- if (sver <= 4) {
- alpha = max(min(alpha, 0xff), 0);
- }
- if (sver <= 4) {
- for (size_t i = 0; i < 3; i++) {
- style->alpha[i] = alpha;
- }
- style->alpha[3] = 0x80;
- }
- if (sver >= 5) for (size_t i = 0; i < 4; i++) {
- style->alpha[i] = (BYTE)(style->colors[i] >> 24);
- style->colors[i] &= 0xffffff;
- }
- if (sver >= 5) {
- style->fontScaleX = max(style->fontScaleX, 0);
- }
- if (sver >= 5) {
- style->fontScaleY = max(style->fontScaleY, 0);
- }
- style->fontAngleX = style->fontAngleY = 0;
- style->borderStyle = style->borderStyle == 1 ? 0 : style->borderStyle == 3 ? 1 : 0;
- style->outlineWidthX = max(style->outlineWidthX, 0);
- style->outlineWidthY = max(style->outlineWidthY, 0);
- style->shadowDepthX = max(style->shadowDepthX, 0);
- style->shadowDepthY = max(style->shadowDepthY, 0);
- if (sver <= 4) style->scrAlignment = (style->scrAlignment & 4) ? ((style->scrAlignment & 3) + 6) // top
- : (style->scrAlignment & 8) ? ((style->scrAlignment & 3) + 3) // mid
- : (style->scrAlignment & 3); // bottom
-
- StyleName.TrimLeft('*');
-
- ret.AddStyle(StyleName, style);
- } catch (...) {
- delete style;
- return false;
- }
- } else if (entry == L"[events]") {
- fRet = true;
- } else if (entry == _T("dialogue")) {
- try {
- int hh1, mm1, ss1, ms1_div10, hh2, mm2, ss2, ms2_div10, layer = 0;
- CString Style, Actor, Effect;
- CRect marginRect;
-
- if (version <= 4) {
- GetStr(buff, '='); /* Marked = */
- GetInt(buff);
- }
- if (version >= 5) {
- layer = GetInt(buff);
- }
- hh1 = GetInt(buff, ':');
- mm1 = GetInt(buff, ':');
- ss1 = GetInt(buff, '.');
- ms1_div10 = GetInt(buff);
- hh2 = GetInt(buff, ':');
- mm2 = GetInt(buff, ':');
- ss2 = GetInt(buff, '.');
- ms2_div10 = GetInt(buff);
- Style = WToT(GetStr(buff));
- Actor = WToT(GetStr(buff));
- marginRect.left = GetInt(buff);
- marginRect.right = GetInt(buff);
- marginRect.top = marginRect.bottom = GetInt(buff);
- if (version >= 6) {
- marginRect.bottom = GetInt(buff);
- }
- Effect = WToT(GetStr(buff));
-
- int len = min(Effect.GetLength(), buff.GetLength());
- if (Effect.Left(len) == WToT(buff.Left(len))) {
- Effect.Empty();
- }
-
- Style.TrimLeft('*');
- if (!Style.CompareNoCase(_T("Default"))) {
- Style = _T("Default");
- }
-
- ret.Add(buff,
- file->IsUnicode(),
- (((hh1*60 + mm1)*60) + ss1)*1000 + ms1_div10*10,
- (((hh2*60 + mm2)*60) + ss2)*1000 + ms2_div10*10,
- Style, Actor, Effect,
- marginRect,
- layer);
- } catch (...) {
- return false;
- }
- } else if (entry == L"fontname") {
- LoadUUEFont(file);
- }
- }
-
- return fRet;
+ bool fRet = false;
+
+ int version = 3, sver = 3;
+
+ CStringW buff;
+ while (file->ReadString(buff)) {
+ buff.Trim();
+ if (buff.IsEmpty() || buff.GetAt(0) == ';') {
+ continue;
+ }
+
+ CStringW entry;
+
+ // try {
+ entry = GetStr(buff, ':');
+ // }
+ // catch(...) {continue;}
+
+ entry.MakeLower();
+
+ if (entry == L"[script info]") {
+ fRet = true;
+ } else if (entry == L"playresx") {
+ try {
+ ret.m_dstScreenSize.cx = GetInt(buff);
+ } catch (...) {
+ ret.m_dstScreenSize = CSize(0, 0);
+ return false;
+ }
+
+ if (ret.m_dstScreenSize.cy <= 0) {
+ ret.m_dstScreenSize.cy = (ret.m_dstScreenSize.cx == 1280)
+ ? 1024
+ : ret.m_dstScreenSize.cx * 3 / 4;
+ }
+ } else if (entry == L"playresy") {
+ try {
+ ret.m_dstScreenSize.cy = GetInt(buff);
+ } catch (...) {
+ ret.m_dstScreenSize = CSize(0, 0);
+ return false;
+ }
+
+ if (ret.m_dstScreenSize.cx <= 0) {
+ ret.m_dstScreenSize.cx = (ret.m_dstScreenSize.cy == 1024)
+ ? 1280
+ : ret.m_dstScreenSize.cy * 4 / 3;
+ }
+ } else if (entry == L"wrapstyle") {
+ try {
+ ret.m_defaultWrapStyle = GetInt(buff);
+ } catch (...) {
+ ret.m_defaultWrapStyle = 1;
+ return false;
+ }
+ } else if (entry == L"scripttype") {
+ if (buff.GetLength() >= 4 && !buff.Right(4).CompareNoCase(L"4.00")) {
+ version = sver = 4;
+ } else if (buff.GetLength() >= 5 && !buff.Right(5).CompareNoCase(L"4.00+")) {
+ version = sver = 5;
+ } else if (buff.GetLength() >= 6 && !buff.Right(6).CompareNoCase(L"4.00++")) {
+ version = sver = 6;
+ }
+ } else if (entry == L"collisions") {
+ buff = GetStr(buff);
+ buff.MakeLower();
+ ret.m_collisions = buff.Find(L"reverse") >= 0 ? 1 : 0;
+ } else if (entry == L"scaledborderandshadow") {
+ buff = GetStr(buff);
+ buff.MakeLower();
+ ret.m_fScaledBAS = buff.Find(L"yes") >= 0;
+ } else if (entry == L"[v4 styles]") {
+ fRet = true;
+ sver = 4;
+ } else if (entry == L"[v4+ styles]") {
+ fRet = true;
+ sver = 5;
+ } else if (entry == L"[v4++ styles]") {
+ fRet = true;
+ sver = 6;
+ } else if (entry == L"style") {
+ STSStyle* style = DNew STSStyle;
+ if (!style) {
+ return false;
+ }
+
+ try {
+ CString StyleName;
+ int alpha = 0;
+
+ StyleName = WToT(GetStr(buff));
+ style->fontName = WToT(GetStr(buff));
+ style->fontSize = GetFloat(buff);
+ for (size_t i = 0; i < 4; i++) {
+ style->colors[i] = (COLORREF)GetInt(buff);
+ }
+ style->fontWeight = GetInt(buff) ? FW_BOLD : FW_NORMAL;
+ style->fItalic = GetInt(buff);
+ if (sver >= 5) {
+ style->fUnderline = GetInt(buff);
+ }
+ if (sver >= 5) {
+ style->fStrikeOut = GetInt(buff);
+ }
+ if (sver >= 5) {
+ style->fontScaleX = GetFloat(buff);
+ }
+ if (sver >= 5) {
+ style->fontScaleY = GetFloat(buff);
+ }
+ if (sver >= 5) {
+ style->fontSpacing = GetFloat(buff);
+ }
+ if (sver >= 5) {
+ style->fontAngleZ = GetFloat(buff);
+ }
+ if (sver >= 4) {
+ style->borderStyle = GetInt(buff);
+ }
+ style->outlineWidthX = style->outlineWidthY = GetFloat(buff);
+ style->shadowDepthX = style->shadowDepthY = GetFloat(buff);
+ style->scrAlignment = GetInt(buff);
+ style->marginRect.left = GetInt(buff);
+ style->marginRect.right = GetInt(buff);
+ style->marginRect.top = style->marginRect.bottom = GetInt(buff);
+ if (sver >= 6) {
+ style->marginRect.bottom = GetInt(buff);
+ }
+ if (sver <= 4) {
+ alpha = GetInt(buff);
+ }
+ style->charSet = GetInt(buff);
+ if (sver >= 6) {
+ style->relativeTo = GetInt(buff);
+ }
+
+ if (sver <= 4) {
+ style->colors[2] = style->colors[3]; // style->colors[2] is used for drawing the outline
+ }
+ if (sver <= 4) {
+ alpha = max(min(alpha, 0xff), 0);
+ }
+ if (sver <= 4) {
+ for (size_t i = 0; i < 3; i++) {
+ style->alpha[i] = alpha;
+ }
+ style->alpha[3] = 0x80;
+ }
+ if (sver >= 5) for (size_t i = 0; i < 4; i++) {
+ style->alpha[i] = (BYTE)(style->colors[i] >> 24);
+ style->colors[i] &= 0xffffff;
+ }
+ if (sver >= 5) {
+ style->fontScaleX = max(style->fontScaleX, 0);
+ }
+ if (sver >= 5) {
+ style->fontScaleY = max(style->fontScaleY, 0);
+ }
+ style->fontAngleX = style->fontAngleY = 0;
+ style->borderStyle = style->borderStyle == 1 ? 0 : style->borderStyle == 3 ? 1 : 0;
+ style->outlineWidthX = max(style->outlineWidthX, 0);
+ style->outlineWidthY = max(style->outlineWidthY, 0);
+ style->shadowDepthX = max(style->shadowDepthX, 0);
+ style->shadowDepthY = max(style->shadowDepthY, 0);
+ if (sver <= 4) style->scrAlignment = (style->scrAlignment & 4) ? ((style->scrAlignment & 3) + 6) // top
+ : (style->scrAlignment & 8) ? ((style->scrAlignment & 3) + 3) // mid
+ : (style->scrAlignment & 3); // bottom
+
+ StyleName.TrimLeft('*');
+
+ ret.AddStyle(StyleName, style);
+ } catch (...) {
+ delete style;
+ return false;
+ }
+ } else if (entry == L"[events]") {
+ fRet = true;
+ } else if (entry == _T("dialogue")) {
+ try {
+ int hh1, mm1, ss1, ms1_div10, hh2, mm2, ss2, ms2_div10, layer = 0;
+ CString Style, Actor, Effect;
+ CRect marginRect;
+
+ if (version <= 4) {
+ GetStr(buff, '='); /* Marked = */
+ GetInt(buff);
+ }
+ if (version >= 5) {
+ layer = GetInt(buff);
+ }
+ hh1 = GetInt(buff, ':');
+ mm1 = GetInt(buff, ':');
+ ss1 = GetInt(buff, '.');
+ ms1_div10 = GetInt(buff);
+ hh2 = GetInt(buff, ':');
+ mm2 = GetInt(buff, ':');
+ ss2 = GetInt(buff, '.');
+ ms2_div10 = GetInt(buff);
+ Style = WToT(GetStr(buff));
+ Actor = WToT(GetStr(buff));
+ marginRect.left = GetInt(buff);
+ marginRect.right = GetInt(buff);
+ marginRect.top = marginRect.bottom = GetInt(buff);
+ if (version >= 6) {
+ marginRect.bottom = GetInt(buff);
+ }
+ Effect = WToT(GetStr(buff));
+
+ int len = min(Effect.GetLength(), buff.GetLength());
+ if (Effect.Left(len) == WToT(buff.Left(len))) {
+ Effect.Empty();
+ }
+
+ Style.TrimLeft('*');
+ if (!Style.CompareNoCase(_T("Default"))) {
+ Style = _T("Default");
+ }
+
+ ret.Add(buff,
+ file->IsUnicode(),
+ (((hh1 * 60 + mm1) * 60) + ss1) * 1000 + ms1_div10 * 10,
+ (((hh2 * 60 + mm2) * 60) + ss2) * 1000 + ms2_div10 * 10,
+ Style, Actor, Effect,
+ marginRect,
+ layer);
+ } catch (...) {
+ return false;
+ }
+ } else if (entry == L"fontname") {
+ LoadUUEFont(file);
+ }
+ }
+
+ return fRet;
}
static bool OpenXombieSub(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
{
- // CMapStringToPtr stylemap;
-
- CStringW buff;
- while (file->ReadString(buff)) {
-
- buff.Trim();
- if (buff.IsEmpty() || buff.GetAt(0) == ';') {
- continue;
- }
-
- CStringW entry;
-
- //try {
- entry = GetStr(buff, '=');
- //}
- //catch(...) {continue;}
-
- entry.MakeLower();
-
- /*if (entry == L"version") {
- double version = GetFloat(buff);
- } else*/ if (entry == L"screenhorizontal") {
- try {
- ret.m_dstScreenSize.cx = GetInt(buff);
- } catch (...) {
- ret.m_dstScreenSize = CSize(0, 0);
- return false;
- }
-
- if (ret.m_dstScreenSize.cy <= 0) {
- ret.m_dstScreenSize.cy = (ret.m_dstScreenSize.cx == 1280)
- ? 1024
- : ret.m_dstScreenSize.cx * 3 / 4;
- }
- } else if (entry == L"screenvertical") {
- try {
- ret.m_dstScreenSize.cy = GetInt(buff);
- } catch (...) {
- ret.m_dstScreenSize = CSize(0, 0);
- return false;
- }
-
- if (ret.m_dstScreenSize.cx <= 0) {
- ret.m_dstScreenSize.cx = (ret.m_dstScreenSize.cy == 1024)
- ? 1280
- : ret.m_dstScreenSize.cy * 4 / 3;
- }
- } else if (entry == L"style") {
- STSStyle* style = DNew STSStyle;
- if (!style) {
- return false;
- }
-
- try {
- CString StyleName;
-
- StyleName = WToT(GetStr(buff)) + _T("_") + WToT(GetStr(buff));
- style->fontName = WToT(GetStr(buff));
- style->fontSize = GetFloat(buff);
- for (size_t i = 0; i < 4; i++) {
- style->colors[i] = (COLORREF)GetInt(buff);
- }
- for (size_t i = 0; i < 4; i++) {
- style->alpha[i] = GetInt(buff);
- }
- style->fontWeight = GetInt(buff) ? FW_BOLD : FW_NORMAL;
- style->fItalic = GetInt(buff);
- style->fUnderline = GetInt(buff);
- style->fStrikeOut = GetInt(buff);
- style->fBlur = GetInt(buff);
- style->fontScaleX = GetFloat(buff);
- style->fontScaleY = GetFloat(buff);
- style->fontSpacing = GetFloat(buff);
- style->fontAngleX = GetFloat(buff);
- style->fontAngleY = GetFloat(buff);
- style->fontAngleZ = GetFloat(buff);
- style->borderStyle = GetInt(buff);
- style->outlineWidthX = style->outlineWidthY = GetFloat(buff);
- style->shadowDepthX = style->shadowDepthY = GetFloat(buff);
- style->scrAlignment = GetInt(buff);
- style->marginRect.left = GetInt(buff);
- style->marginRect.right = GetInt(buff);
- style->marginRect.top = style->marginRect.bottom = GetInt(buff);
- style->charSet = GetInt(buff);
-
- style->fontScaleX = max(style->fontScaleX, 0);
- style->fontScaleY = max(style->fontScaleY, 0);
- style->fontSpacing = max(style->fontSpacing, 0);
- style->borderStyle = style->borderStyle == 1 ? 0 : style->borderStyle == 3 ? 1 : 0;
- style->outlineWidthX = max(style->outlineWidthX, 0);
- style->outlineWidthY = max(style->outlineWidthY, 0);
- style->shadowDepthX = max(style->shadowDepthX, 0);
- style->shadowDepthY = max(style->shadowDepthY, 0);
-
- ret.AddStyle(StyleName, style);
- } catch (...) {
- delete style;
- return false;
- }
- } else if (entry == L"line") {
- try {
- CString id;
- int hh1, mm1, ss1, ms1, hh2, mm2, ss2, ms2, layer = 0;
- CString Style, Actor;
- CRect marginRect;
-
- if (GetStr(buff) != L"D") {
- continue;
- }
- id = GetStr(buff);
- layer = GetInt(buff);
- hh1 = GetInt(buff, ':');
- mm1 = GetInt(buff, ':');
- ss1 = GetInt(buff, '.');
- ms1 = GetInt(buff);
- hh2 = GetInt(buff, ':');
- mm2 = GetInt(buff, ':');
- ss2 = GetInt(buff, '.');
- ms2 = GetInt(buff);
- Style = WToT(GetStr(buff)) + _T("_") + WToT(GetStr(buff));
- Actor = WToT(GetStr(buff));
- marginRect.left = GetInt(buff);
- marginRect.right = GetInt(buff);
- marginRect.top = marginRect.bottom = GetInt(buff);
-
- Style.TrimLeft('*');
- if (!Style.CompareNoCase(_T("Default"))) {
- Style = _T("Default");
- }
-
- ret.Add(buff,
- file->IsUnicode(),
- (((hh1*60 + mm1)*60) + ss1)*1000 + ms1,
- (((hh2*60 + mm2)*60) + ss2)*1000 + ms2,
- Style, Actor, _T(""),
- marginRect,
- layer);
- } catch (...) {
- return false;
- }
- } else if (entry == L"fontname") {
- LoadUUEFont(file);
- }
- }
-
- return (ret.GetCount() > 0);
+ // CMapStringToPtr stylemap;
+
+ CStringW buff;
+ while (file->ReadString(buff)) {
+
+ buff.Trim();
+ if (buff.IsEmpty() || buff.GetAt(0) == ';') {
+ continue;
+ }
+
+ CStringW entry;
+
+ //try {
+ entry = GetStr(buff, '=');
+ //}
+ //catch(...) {continue;}
+
+ entry.MakeLower();
+
+ /*if (entry == L"version") {
+ double version = GetFloat(buff);
+ } else*/ if (entry == L"screenhorizontal") {
+ try {
+ ret.m_dstScreenSize.cx = GetInt(buff);
+ } catch (...) {
+ ret.m_dstScreenSize = CSize(0, 0);
+ return false;
+ }
+
+ if (ret.m_dstScreenSize.cy <= 0) {
+ ret.m_dstScreenSize.cy = (ret.m_dstScreenSize.cx == 1280)
+ ? 1024
+ : ret.m_dstScreenSize.cx * 3 / 4;
+ }
+ } else if (entry == L"screenvertical") {
+ try {
+ ret.m_dstScreenSize.cy = GetInt(buff);
+ } catch (...) {
+ ret.m_dstScreenSize = CSize(0, 0);
+ return false;
+ }
+
+ if (ret.m_dstScreenSize.cx <= 0) {
+ ret.m_dstScreenSize.cx = (ret.m_dstScreenSize.cy == 1024)
+ ? 1280
+ : ret.m_dstScreenSize.cy * 4 / 3;
+ }
+ } else if (entry == L"style") {
+ STSStyle* style = DNew STSStyle;
+ if (!style) {
+ return false;
+ }
+
+ try {
+ CString StyleName;
+
+ StyleName = WToT(GetStr(buff)) + _T("_") + WToT(GetStr(buff));
+ style->fontName = WToT(GetStr(buff));
+ style->fontSize = GetFloat(buff);
+ for (size_t i = 0; i < 4; i++) {
+ style->colors[i] = (COLORREF)GetInt(buff);
+ }
+ for (size_t i = 0; i < 4; i++) {
+ style->alpha[i] = GetInt(buff);
+ }
+ style->fontWeight = GetInt(buff) ? FW_BOLD : FW_NORMAL;
+ style->fItalic = GetInt(buff);
+ style->fUnderline = GetInt(buff);
+ style->fStrikeOut = GetInt(buff);
+ style->fBlur = GetInt(buff);
+ style->fontScaleX = GetFloat(buff);
+ style->fontScaleY = GetFloat(buff);
+ style->fontSpacing = GetFloat(buff);
+ style->fontAngleX = GetFloat(buff);
+ style->fontAngleY = GetFloat(buff);
+ style->fontAngleZ = GetFloat(buff);
+ style->borderStyle = GetInt(buff);
+ style->outlineWidthX = style->outlineWidthY = GetFloat(buff);
+ style->shadowDepthX = style->shadowDepthY = GetFloat(buff);
+ style->scrAlignment = GetInt(buff);
+ style->marginRect.left = GetInt(buff);
+ style->marginRect.right = GetInt(buff);
+ style->marginRect.top = style->marginRect.bottom = GetInt(buff);
+ style->charSet = GetInt(buff);
+
+ style->fontScaleX = max(style->fontScaleX, 0);
+ style->fontScaleY = max(style->fontScaleY, 0);
+ style->fontSpacing = max(style->fontSpacing, 0);
+ style->borderStyle = style->borderStyle == 1 ? 0 : style->borderStyle == 3 ? 1 : 0;
+ style->outlineWidthX = max(style->outlineWidthX, 0);
+ style->outlineWidthY = max(style->outlineWidthY, 0);
+ style->shadowDepthX = max(style->shadowDepthX, 0);
+ style->shadowDepthY = max(style->shadowDepthY, 0);
+
+ ret.AddStyle(StyleName, style);
+ } catch (...) {
+ delete style;
+ return false;
+ }
+ } else if (entry == L"line") {
+ try {
+ CString id;
+ int hh1, mm1, ss1, ms1, hh2, mm2, ss2, ms2, layer = 0;
+ CString Style, Actor;
+ CRect marginRect;
+
+ if (GetStr(buff) != L"D") {
+ continue;
+ }
+ id = GetStr(buff);
+ layer = GetInt(buff);
+ hh1 = GetInt(buff, ':');
+ mm1 = GetInt(buff, ':');
+ ss1 = GetInt(buff, '.');
+ ms1 = GetInt(buff);
+ hh2 = GetInt(buff, ':');
+ mm2 = GetInt(buff, ':');
+ ss2 = GetInt(buff, '.');
+ ms2 = GetInt(buff);
+ Style = WToT(GetStr(buff)) + _T("_") + WToT(GetStr(buff));
+ Actor = WToT(GetStr(buff));
+ marginRect.left = GetInt(buff);
+ marginRect.right = GetInt(buff);
+ marginRect.top = marginRect.bottom = GetInt(buff);
+
+ Style.TrimLeft('*');
+ if (!Style.CompareNoCase(_T("Default"))) {
+ Style = _T("Default");
+ }
+
+ ret.Add(buff,
+ file->IsUnicode(),
+ (((hh1 * 60 + mm1) * 60) + ss1) * 1000 + ms1,
+ (((hh2 * 60 + mm2) * 60) + ss2) * 1000 + ms2,
+ Style, Actor, _T(""),
+ marginRect,
+ layer);
+ } catch (...) {
+ return false;
+ }
+ } else if (entry == L"fontname") {
+ LoadUUEFont(file);
+ }
+ }
+
+ return (ret.GetCount() > 0);
}
static bool OpenUSF(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
{
- CString str;
- while (file->ReadString(str)) {
- if (str.Find(_T("USFSubtitles")) >= 0) {
- CUSFSubtitles usf;
- if (usf.Read(file->GetFilePath()) && usf.ConvertToSTS(ret)) {
- return true;
- }
+ CString str;
+ while (file->ReadString(str)) {
+ if (str.Find(_T("USFSubtitles")) >= 0) {
+ CUSFSubtitles usf;
+ if (usf.Read(file->GetFilePath()) && usf.ConvertToSTS(ret)) {
+ return true;
+ }
- break;
- }
- }
+ break;
+ }
+ }
- return false;
+ return false;
}
static CStringW MPL22SSA(CStringW str)
{
- CAtlList<CStringW> sl;
- Explode(str, sl, '|');
- POSITION pos = sl.GetHeadPosition();
- while (pos) {
- CStringW& s = sl.GetNext(pos);
- if (s[0] == '/') {
- s = L"{\\i1}" + s.Mid(1) + L"{\\i0}";
- }
- }
- str = Implode(sl, '\n');
- str.Replace(L"\n", L"\\N");
- return str;
+ CAtlList<CStringW> sl;
+ Explode(str, sl, '|');
+ POSITION pos = sl.GetHeadPosition();
+ while (pos) {
+ CStringW& s = sl.GetNext(pos);
+ if (s[0] == '/') {
+ s = L"{\\i1}" + s.Mid(1) + L"{\\i0}";
+ }
+ }
+ str = Implode(sl, '\n');
+ str.Replace(L"\n", L"\\N");
+ return str;
}
static bool OpenMPL2(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
{
- CStringW buff;
- while (file->ReadString(buff)) {
- buff.Trim();
- if (buff.IsEmpty()) {
- continue;
- }
+ CStringW buff;
+ while (file->ReadString(buff)) {
+ buff.Trim();
+ if (buff.IsEmpty()) {
+ continue;
+ }
- int start, end;
- int c = swscanf_s(buff, L"[%d][%d]", &start, &end);
+ int start, end;
+ int c = swscanf_s(buff, L"[%d][%d]", &start, &end);
- if (c == 2) {
- ret.Add(
- MPL22SSA(buff.Mid(buff.Find(']', buff.Find(']')+1)+1)),
- file->IsUnicode(),
- start*100, end*100);
- } else if (c != EOF) { // might be another format
- return false;
- }
- }
+ if (c == 2) {
+ ret.Add(
+ MPL22SSA(buff.Mid(buff.Find(']', buff.Find(']') + 1) + 1)),
+ file->IsUnicode(),
+ start * 100, end * 100);
+ } else if (c != EOF) { // might be another format
+ return false;
+ }
+ }
- return (ret.GetCount() > 0);
+ return (ret.GetCount() > 0);
}
typedef bool (*STSOpenFunct)(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet);
@@ -1833,23 +1833,23 @@ typedef bool (*STSOpenFunct)(CTextFile* file, CSimpleTextSubtitle& ret, int Char
static bool OpenRealText(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet);
typedef struct {
- STSOpenFunct open;
- tmode mode;
- exttype type;
+ STSOpenFunct open;
+ tmode mode;
+ exttype type;
} OpenFunctStruct;
static OpenFunctStruct OpenFuncts[] = {
- OpenSubRipper, TIME, EXTSRT,
- OpenOldSubRipper, TIME, EXTSRT,
- OpenSubViewer, TIME, EXTSUB,
- OpenMicroDVD, FRAME, EXTSSA,
- OpenSami, TIME, EXTSMI,
- OpenVPlayer, TIME, EXTSRT,
- OpenSubStationAlpha, TIME, EXTSSA,
- OpenXombieSub, TIME, EXTXSS,
- OpenUSF, TIME, EXTUSF,
- OpenMPL2, TIME, EXTSRT,
- OpenRealText, TIME, EXTRT,
+ OpenSubRipper, TIME, EXTSRT,
+ OpenOldSubRipper, TIME, EXTSRT,
+ OpenSubViewer, TIME, EXTSUB,
+ OpenMicroDVD, FRAME, EXTSSA,
+ OpenSami, TIME, EXTSMI,
+ OpenVPlayer, TIME, EXTSRT,
+ OpenSubStationAlpha, TIME, EXTSSA,
+ OpenXombieSub, TIME, EXTXSS,
+ OpenUSF, TIME, EXTUSF,
+ OpenMPL2, TIME, EXTSRT,
+ OpenRealText, TIME, EXTRT,
};
static int nOpenFuncts = _countof(OpenFuncts);
@@ -1858,1314 +1858,1314 @@ static int nOpenFuncts = _countof(OpenFuncts);
CSimpleTextSubtitle::CSimpleTextSubtitle()
{
- m_mode = TIME;
- m_dstScreenSize = CSize(0, 0);
- m_defaultWrapStyle = 0;
- m_collisions = 0;
- m_fScaledBAS = false;
- m_encoding = CTextFile::ASCII;
- m_lcid = 0;
- m_ePARCompensationType = EPCTDisabled;
- m_dPARCompensation = 1.0;
+ m_mode = TIME;
+ m_dstScreenSize = CSize(0, 0);
+ m_defaultWrapStyle = 0;
+ m_collisions = 0;
+ m_fScaledBAS = false;
+ m_encoding = CTextFile::ASCII;
+ m_lcid = 0;
+ m_ePARCompensationType = EPCTDisabled;
+ m_dPARCompensation = 1.0;
}
CSimpleTextSubtitle::~CSimpleTextSubtitle()
{
- Empty();
+ Empty();
}
/*
CSimpleTextSubtitle::CSimpleTextSubtitle(CSimpleTextSubtitle& sts)
{
- *this = sts;
+ *this = sts;
}
CSimpleTextSubtitle& CSimpleTextSubtitle::operator = (CSimpleTextSubtitle& sts)
{
- Copy(sts);
+ Copy(sts);
- return *this;
+ return *this;
}
*/
void CSimpleTextSubtitle::Copy(CSimpleTextSubtitle& sts)
{
- if (this != &sts) {
- Empty();
-
- m_name = sts.m_name;
- m_mode = sts.m_mode;
- m_path = sts.m_path;
- m_exttype = sts.m_exttype;
- m_dstScreenSize = sts.m_dstScreenSize;
- m_defaultWrapStyle = sts.m_defaultWrapStyle;
- m_collisions = sts.m_collisions;
- m_fScaledBAS = sts.m_fScaledBAS;
- m_encoding = sts.m_encoding;
- m_fUsingAutoGeneratedDefaultStyle = sts.m_fUsingAutoGeneratedDefaultStyle;
- CopyStyles(sts.m_styles);
- m_segments.Copy(sts.m_segments);
- __super::Copy(sts);
- }
+ if (this != &sts) {
+ Empty();
+
+ m_name = sts.m_name;
+ m_mode = sts.m_mode;
+ m_path = sts.m_path;
+ m_exttype = sts.m_exttype;
+ m_dstScreenSize = sts.m_dstScreenSize;
+ m_defaultWrapStyle = sts.m_defaultWrapStyle;
+ m_collisions = sts.m_collisions;
+ m_fScaledBAS = sts.m_fScaledBAS;
+ m_encoding = sts.m_encoding;
+ m_fUsingAutoGeneratedDefaultStyle = sts.m_fUsingAutoGeneratedDefaultStyle;
+ CopyStyles(sts.m_styles);
+ m_segments.Copy(sts.m_segments);
+ __super::Copy(sts);
+ }
}
void CSimpleTextSubtitle::Append(CSimpleTextSubtitle& sts, int timeoff)
{
- if (timeoff < 0) {
- timeoff = GetCount() > 0 ? GetAt(GetCount()-1).end : 0;
- }
+ if (timeoff < 0) {
+ timeoff = GetCount() > 0 ? GetAt(GetCount() - 1).end : 0;
+ }
- for (size_t i = 0, j = GetCount(); i < j; i++) {
- if (GetAt(i).start > timeoff) {
- RemoveAt(i, j - i);
- break;
- }
- }
+ for (size_t i = 0, j = GetCount(); i < j; i++) {
+ if (GetAt(i).start > timeoff) {
+ RemoveAt(i, j - i);
+ break;
+ }
+ }
- CopyStyles(sts.m_styles, true);
+ CopyStyles(sts.m_styles, true);
- for (size_t i = 0, j = sts.GetCount(); i < j; i++) {
- STSEntry stse = sts.GetAt(i);
- stse.start += timeoff;
- stse.end += timeoff;
- stse.readorder += (int)GetCount();
- __super::Add(stse);
- }
+ for (size_t i = 0, j = sts.GetCount(); i < j; i++) {
+ STSEntry stse = sts.GetAt(i);
+ stse.start += timeoff;
+ stse.end += timeoff;
+ stse.readorder += (int)GetCount();
+ __super::Add(stse);
+ }
- CreateSegments();
+ CreateSegments();
}
void CSTSStyleMap::Free()
{
- POSITION pos = GetStartPosition();
- while (pos) {
- CString key;
- STSStyle* val;
- GetNextAssoc(pos, key, val);
- delete val;
- }
+ POSITION pos = GetStartPosition();
+ while (pos) {
+ CString key;
+ STSStyle* val;
+ GetNextAssoc(pos, key, val);
+ delete val;
+ }
- RemoveAll();
+ RemoveAll();
}
bool CSimpleTextSubtitle::CopyStyles(const CSTSStyleMap& styles, bool fAppend)
{
- if (!fAppend) {
- m_styles.Free();
- }
+ if (!fAppend) {
+ m_styles.Free();
+ }
- POSITION pos = styles.GetStartPosition();
- while (pos) {
- CString key;
- STSStyle* val;
- styles.GetNextAssoc(pos, key, val);
+ POSITION pos = styles.GetStartPosition();
+ while (pos) {
+ CString key;
+ STSStyle* val;
+ styles.GetNextAssoc(pos, key, val);
- STSStyle* s = DNew STSStyle;
- if (!s) {
- return false;
- }
+ STSStyle* s = DNew STSStyle;
+ if (!s) {
+ return false;
+ }
- *s = *val;
+ *s = *val;
- AddStyle(key, s);
- }
+ AddStyle(key, s);
+ }
- return true;
+ return true;
}
void CSimpleTextSubtitle::Empty()
{
- m_dstScreenSize = CSize(0, 0);
- m_styles.Free();
- m_segments.RemoveAll();
- RemoveAll();
+ m_dstScreenSize = CSize(0, 0);
+ m_styles.Free();
+ m_segments.RemoveAll();
+ RemoveAll();
}
void CSimpleTextSubtitle::Add(CStringW str, bool fUnicode, int start, int end, CString style, CString actor, CString effect, CRect marginRect, int layer, int readorder)
{
- if (str.Trim().IsEmpty() || start > end) {
- return;
- }
-
- str.Remove('\r');
- str.Replace(L"\n", L"\\N");
- if (style.IsEmpty()) {
- style = _T("Default");
- }
- style.TrimLeft('*');
-
- STSEntry sub;
- sub.str = str;
- sub.fUnicode = fUnicode;
- sub.style = style;
- sub.actor = actor;
- sub.effect = effect;
- sub.marginRect = marginRect;
- sub.layer = layer;
- sub.start = start;
- sub.end = end;
- sub.readorder = readorder < 0 ? (int)GetCount() : readorder;
-
- int n = (int)__super::Add(sub);
-
- int len = (int)m_segments.GetCount();
-
- if (len == 0) {
- STSSegment stss(start, end);
- stss.subs.Add(n);
- m_segments.Add(stss);
- } else if (end <= m_segments[0].start) {
- STSSegment stss(start, end);
- stss.subs.Add(n);
- m_segments.InsertAt(0, stss);
- } else if (start >= m_segments[len-1].end) {
- STSSegment stss(start, end);
- stss.subs.Add(n);
- m_segments.Add(stss);
- } else {
- if (start < m_segments[0].start) {
- STSSegment stss(start, m_segments[0].start);
- stss.subs.Add(n);
- start = m_segments[0].start;
- m_segments.InsertAt(0, stss);
- }
-
- for (size_t i = 0; i < m_segments.GetCount(); i++) {
- STSSegment& s = m_segments[i];
-
- if (start >= s.end) {
- continue;
- }
-
- if (end <= s.start) {
- break;
- }
-
- if (s.start < start && start < s.end) {
- STSSegment stss(s.start, start);
- stss.subs.Copy(s.subs);
- s.start = start;
- m_segments.InsertAt(i, stss);
- continue;
- }
-
- if (start <= s.start && s.end <= end) {
- for (size_t j = 0, k = s.subs.GetCount(); j <= k; j++) {
- if (j == k || sub.readorder < GetAt(s.subs[j]).readorder) {
- s.subs.InsertAt(j, n);
- }
- }
- // s.subs.Add(n);
- }
-
- if (s.start < end && end < s.end) {
- STSSegment stss(s.start, end);
- stss.subs.Copy(s.subs);
- for (size_t j = 0, k = s.subs.GetCount(); j <= k; j++) {
- if (j == k || sub.readorder < GetAt(stss.subs[j]).readorder) {
- stss.subs.InsertAt(j, n);
- }
- }
- // stss.subs.Add(n);
- s.start = end;
- m_segments.InsertAt(i, stss);
- }
- }
-
- if (end > m_segments[m_segments.GetCount()-1].end) {
- STSSegment stss(m_segments[m_segments.GetCount()-1].end, end);
- stss.subs.Add(n);
- m_segments.Add(stss);
- }
- }
+ if (str.Trim().IsEmpty() || start > end) {
+ return;
+ }
+
+ str.Remove('\r');
+ str.Replace(L"\n", L"\\N");
+ if (style.IsEmpty()) {
+ style = _T("Default");
+ }
+ style.TrimLeft('*');
+
+ STSEntry sub;
+ sub.str = str;
+ sub.fUnicode = fUnicode;
+ sub.style = style;
+ sub.actor = actor;
+ sub.effect = effect;
+ sub.marginRect = marginRect;
+ sub.layer = layer;
+ sub.start = start;
+ sub.end = end;
+ sub.readorder = readorder < 0 ? (int)GetCount() : readorder;
+
+ int n = (int)__super::Add(sub);
+
+ int len = (int)m_segments.GetCount();
+
+ if (len == 0) {
+ STSSegment stss(start, end);
+ stss.subs.Add(n);
+ m_segments.Add(stss);
+ } else if (end <= m_segments[0].start) {
+ STSSegment stss(start, end);
+ stss.subs.Add(n);
+ m_segments.InsertAt(0, stss);
+ } else if (start >= m_segments[len - 1].end) {
+ STSSegment stss(start, end);
+ stss.subs.Add(n);
+ m_segments.Add(stss);
+ } else {
+ if (start < m_segments[0].start) {
+ STSSegment stss(start, m_segments[0].start);
+ stss.subs.Add(n);
+ start = m_segments[0].start;
+ m_segments.InsertAt(0, stss);
+ }
+
+ for (size_t i = 0; i < m_segments.GetCount(); i++) {
+ STSSegment& s = m_segments[i];
+
+ if (start >= s.end) {
+ continue;
+ }
+
+ if (end <= s.start) {
+ break;
+ }
+
+ if (s.start < start && start < s.end) {
+ STSSegment stss(s.start, start);
+ stss.subs.Copy(s.subs);
+ s.start = start;
+ m_segments.InsertAt(i, stss);
+ continue;
+ }
+
+ if (start <= s.start && s.end <= end) {
+ for (size_t j = 0, k = s.subs.GetCount(); j <= k; j++) {
+ if (j == k || sub.readorder < GetAt(s.subs[j]).readorder) {
+ s.subs.InsertAt(j, n);
+ }
+ }
+ // s.subs.Add(n);
+ }
+
+ if (s.start < end && end < s.end) {
+ STSSegment stss(s.start, end);
+ stss.subs.Copy(s.subs);
+ for (size_t j = 0, k = s.subs.GetCount(); j <= k; j++) {
+ if (j == k || sub.readorder < GetAt(stss.subs[j]).readorder) {
+ stss.subs.InsertAt(j, n);
+ }
+ }
+ // stss.subs.Add(n);
+ s.start = end;
+ m_segments.InsertAt(i, stss);
+ }
+ }
+
+ if (end > m_segments[m_segments.GetCount() - 1].end) {
+ STSSegment stss(m_segments[m_segments.GetCount() - 1].end, end);
+ stss.subs.Add(n);
+ m_segments.Add(stss);
+ }
+ }
}
STSStyle* CSimpleTextSubtitle::CreateDefaultStyle(int CharSet)
{
- CString def(_T("Default"));
+ CString def(_T("Default"));
- STSStyle* ret = NULL;
+ STSStyle* ret = NULL;
- if (!m_styles.Lookup(def, ret)) {
- STSStyle* style = DNew STSStyle();
- style->charSet = CharSet;
- AddStyle(def, style);
- m_styles.Lookup(def, ret);
+ if (!m_styles.Lookup(def, ret)) {
+ STSStyle* style = DNew STSStyle();
+ style->charSet = CharSet;
+ AddStyle(def, style);
+ m_styles.Lookup(def, ret);
- m_fUsingAutoGeneratedDefaultStyle = true;
- } else {
- m_fUsingAutoGeneratedDefaultStyle = false;
- }
+ m_fUsingAutoGeneratedDefaultStyle = true;
+ } else {
+ m_fUsingAutoGeneratedDefaultStyle = false;
+ }
- return ret;
+ return ret;
}
void CSimpleTextSubtitle::ChangeUnknownStylesToDefault()
{
- CAtlMap<CString, STSStyle*, CStringElementTraits<CString> > unknown;
- bool fReport = true;
+ CAtlMap<CString, STSStyle*, CStringElementTraits<CString> > unknown;
+ bool fReport = true;
- for (size_t i = 0; i < GetCount(); i++) {
- STSEntry& stse = GetAt(i);
+ for (size_t i = 0; i < GetCount(); i++) {
+ STSEntry& stse = GetAt(i);
- STSStyle* val;
- if (!m_styles.Lookup(stse.style, val)) {
- if (!unknown.Lookup(stse.style, val)) {
- if (fReport) {
- CString msg;
- msg.Format(_T("Unknown style found: \"%s\", changed to \"Default\"!\n\nPress Cancel to ignore further warnings."), stse.style);
- if (MessageBox(NULL, msg, _T("Warning"), MB_OKCANCEL|MB_ICONWARNING) != IDOK) {
- fReport = false;
- }
- }
+ STSStyle* val;
+ if (!m_styles.Lookup(stse.style, val)) {
+ if (!unknown.Lookup(stse.style, val)) {
+ if (fReport) {
+ CString msg;
+ msg.Format(_T("Unknown style found: \"%s\", changed to \"Default\"!\n\nPress Cancel to ignore further warnings."), stse.style);
+ if (MessageBox(NULL, msg, _T("Warning"), MB_OKCANCEL | MB_ICONWARNING) != IDOK) {
+ fReport = false;
+ }
+ }
- unknown[stse.style] = NULL;
- }
+ unknown[stse.style] = NULL;
+ }
- stse.style = _T("Default");
- }
- }
+ stse.style = _T("Default");
+ }
+ }
}
void CSimpleTextSubtitle::AddStyle(CString name, STSStyle* style)
{
- if (name.IsEmpty()) {
- name = _T("Default");
- }
+ if (name.IsEmpty()) {
+ name = _T("Default");
+ }
- STSStyle* val;
- if (m_styles.Lookup(name, val)) {
- if (*val == *style) {
- delete style;
- return;
- }
+ STSStyle* val;
+ if (m_styles.Lookup(name, val)) {
+ if (*val == *style) {
+ delete style;
+ return;
+ }
- int i;
- int len = name.GetLength();
+ int i;
+ int len = name.GetLength();
- for (i = len; i > 0 && _istdigit(name[i-1]); i--) {
- ;
- }
+ for (i = len; i > 0 && _istdigit(name[i - 1]); i--) {
+ ;
+ }
- int idx = 1;
+ int idx = 1;
- CString name2 = name;
+ CString name2 = name;
- if (i < len && _stscanf_s(name.Right(len-i), _T("%d"), &idx) == 1) {
- name2 = name.Left(i);
- }
+ if (i < len && _stscanf_s(name.Right(len - i), _T("%d"), &idx) == 1) {
+ name2 = name.Left(i);
+ }
- idx++;
+ idx++;
- CString name3;
- do {
- name3.Format(_T("%s%d"), name2, idx);
- idx++;
- } while (m_styles.Lookup(name3));
+ CString name3;
+ do {
+ name3.Format(_T("%s%d"), name2, idx);
+ idx++;
+ } while (m_styles.Lookup(name3));
- m_styles.RemoveKey(name);
- m_styles[name3] = val;
+ m_styles.RemoveKey(name);
+ m_styles[name3] = val;
- for (size_t i = 0, j = GetCount(); i < j; i++) {
- STSEntry& stse = GetAt(i);
- if (stse.style == name) {
- stse.style = name3;
- }
- }
- }
+ for (size_t i = 0, j = GetCount(); i < j; i++) {
+ STSEntry& stse = GetAt(i);
+ if (stse.style == name) {
+ stse.style = name3;
+ }
+ }
+ }
- m_styles[name] = style;
+ m_styles[name] = style;
}
bool CSimpleTextSubtitle::SetDefaultStyle(STSStyle& s)
{
- STSStyle* val;
- if (!m_styles.Lookup(_T("Default"), val)) {
- return false;
- }
- *val = s;
- m_fUsingAutoGeneratedDefaultStyle = false;
- return true;
+ STSStyle* val;
+ if (!m_styles.Lookup(_T("Default"), val)) {
+ return false;
+ }
+ *val = s;
+ m_fUsingAutoGeneratedDefaultStyle = false;
+ return true;
}
bool CSimpleTextSubtitle::GetDefaultStyle(STSStyle& s)
{
- STSStyle* val;
- if (!m_styles.Lookup(_T("Default"), val)) {
- return false;
- }
- s = *val;
- return true;
+ STSStyle* val;
+ if (!m_styles.Lookup(_T("Default"), val)) {
+ return false;
+ }
+ s = *val;
+ return true;
}
void CSimpleTextSubtitle::ConvertToTimeBased(double fps)
{
- if (m_mode == TIME) {
- return;
- }
+ if (m_mode == TIME) {
+ return;
+ }
- for (size_t i = 0, j = GetCount(); i < j; i++) {
- STSEntry& stse = (*this)[i];
- stse.start = (int)(stse.start * 1000.0 / fps + 0.5);
- stse.end = (int)(stse.end * 1000.0 / fps + 0.5);
- }
+ for (size_t i = 0, j = GetCount(); i < j; i++) {
+ STSEntry& stse = (*this)[i];
+ stse.start = (int)(stse.start * 1000.0 / fps + 0.5);
+ stse.end = (int)(stse.end * 1000.0 / fps + 0.5);
+ }
- m_mode = TIME;
+ m_mode = TIME;
- CreateSegments();
+ CreateSegments();
}
void CSimpleTextSubtitle::ConvertToFrameBased(double fps)
{
- if (m_mode == FRAME) {
- return;
- }
+ if (m_mode == FRAME) {
+ return;
+ }
- for (size_t i = 0, j = GetCount(); i < j; i++) {
- STSEntry& stse = (*this)[i];
- stse.start = (int)(stse.start * fps / 1000 + 0.5);
- stse.end = (int)(stse.end * fps / 1000 + 0.5);
- }
+ for (size_t i = 0, j = GetCount(); i < j; i++) {
+ STSEntry& stse = (*this)[i];
+ stse.start = (int)(stse.start * fps / 1000 + 0.5);
+ stse.end = (int)(stse.end * fps / 1000 + 0.5);
+ }
- m_mode = FRAME;
+ m_mode = FRAME;
- CreateSegments();
+ CreateSegments();
}
int CSimpleTextSubtitle::SearchSub(int t, double fps)
{
- int i = 0, j = (int)GetCount() - 1, ret = -1;
-
- if (j >= 0 && t >= TranslateStart(j, fps)) {
- return j;
- }
-
- while (i < j) {
- int mid = (i + j) >> 1;
-
- int midt = TranslateStart(mid, fps);
-
- if (t == midt) {
- while (mid > 0 && t == TranslateStart(mid-1, fps)) {
- --mid;
- }
- ret = mid;
- break;
- } else if (t < midt) {
- ret = -1;
- if (j == mid) {
- mid--;
- }
- j = mid;
- } else if (t > midt) {
- ret = mid;
- if (i == mid) {
- ++mid;
- }
- i = mid;
- }
- }
-
- return ret;
+ int i = 0, j = (int)GetCount() - 1, ret = -1;
+
+ if (j >= 0 && t >= TranslateStart(j, fps)) {
+ return j;
+ }
+
+ while (i < j) {
+ int mid = (i + j) >> 1;
+
+ int midt = TranslateStart(mid, fps);
+
+ if (t == midt) {
+ while (mid > 0 && t == TranslateStart(mid - 1, fps)) {
+ --mid;
+ }
+ ret = mid;
+ break;
+ } else if (t < midt) {
+ ret = -1;
+ if (j == mid) {
+ mid--;
+ }
+ j = mid;
+ } else if (t > midt) {
+ ret = mid;
+ if (i == mid) {
+ ++mid;
+ }
+ i = mid;
+ }
+ }
+
+ return ret;
}
const STSSegment* CSimpleTextSubtitle::SearchSubs(int t, double fps, /*[out]*/ int* iSegment, int* nSegments)
{
- int i = 0, j = (int)m_segments.GetCount() - 1, ret = -1;
-
- if (nSegments) {
- *nSegments = j+1;
- }
-
- // last segment
- if (j >= 0 && t >= TranslateSegmentStart(j, fps) && t < TranslateSegmentEnd(j, fps)) {
- if (iSegment) {
- *iSegment = j;
- }
- return &m_segments[j];
- }
-
- // after last segment
- if (j >= 0 && t >= TranslateSegmentEnd(j, fps)) {
- if (iSegment) {
- *iSegment = j+1;
- }
- return NULL;
- }
-
- // before first segment
- if (j > 0 && t < TranslateSegmentStart(i, fps)) {
- if (iSegment) {
- *iSegment = -1;
- }
- return NULL;
- }
-
- while (i < j) {
- int mid = (i + j) >> 1;
-
- int midt = TranslateSegmentStart(mid, fps);
-
- if (t == midt) {
- ret = mid;
- break;
- } else if (t < midt) {
- ret = -1;
- if (j == mid) {
- mid--;
- }
- j = mid;
- } else if (t > midt) {
- ret = mid;
- if (i == mid) {
- mid++;
- }
- i = mid;
- }
- }
-
- if (0 <= ret && (size_t)ret < m_segments.GetCount()) {
- if (iSegment) {
- *iSegment = ret;
- }
- }
-
- if (0 <= ret && (size_t)ret < m_segments.GetCount()
- && m_segments[ret].subs.GetCount() > 0
- && TranslateSegmentStart(ret, fps) <= t && t < TranslateSegmentEnd(ret, fps)) {
- return &m_segments[ret];
- }
-
- return NULL;
+ int i = 0, j = (int)m_segments.GetCount() - 1, ret = -1;
+
+ if (nSegments) {
+ *nSegments = j + 1;
+ }
+
+ // last segment
+ if (j >= 0 && t >= TranslateSegmentStart(j, fps) && t < TranslateSegmentEnd(j, fps)) {
+ if (iSegment) {
+ *iSegment = j;
+ }
+ return &m_segments[j];
+ }
+
+ // after last segment
+ if (j >= 0 && t >= TranslateSegmentEnd(j, fps)) {
+ if (iSegment) {
+ *iSegment = j + 1;
+ }
+ return NULL;
+ }
+
+ // before first segment
+ if (j > 0 && t < TranslateSegmentStart(i, fps)) {
+ if (iSegment) {
+ *iSegment = -1;
+ }
+ return NULL;
+ }
+
+ while (i < j) {
+ int mid = (i + j) >> 1;
+
+ int midt = TranslateSegmentStart(mid, fps);
+
+ if (t == midt) {
+ ret = mid;
+ break;
+ } else if (t < midt) {
+ ret = -1;
+ if (j == mid) {
+ mid--;
+ }
+ j = mid;
+ } else if (t > midt) {
+ ret = mid;
+ if (i == mid) {
+ mid++;
+ }
+ i = mid;
+ }
+ }
+
+ if (0 <= ret && (size_t)ret < m_segments.GetCount()) {
+ if (iSegment) {
+ *iSegment = ret;
+ }
+ }
+
+ if (0 <= ret && (size_t)ret < m_segments.GetCount()
+ && m_segments[ret].subs.GetCount() > 0
+ && TranslateSegmentStart(ret, fps) <= t && t < TranslateSegmentEnd(ret, fps)) {
+ return &m_segments[ret];
+ }
+
+ return NULL;
}
int CSimpleTextSubtitle::TranslateStart(int i, double fps)
{
- return (i < 0 || GetCount() <= (size_t)i ? -1 :
- m_mode == TIME ? GetAt(i).start :
- m_mode == FRAME ? (int)(GetAt(i).start*1000/fps) :
- 0);
+ return (i < 0 || GetCount() <= (size_t)i ? -1 :
+ m_mode == TIME ? GetAt(i).start :
+ m_mode == FRAME ? (int)(GetAt(i).start * 1000 / fps) :
+ 0);
}
int CSimpleTextSubtitle::TranslateEnd(int i, double fps)
{
- return (i < 0 || GetCount() <= (size_t)i ? -1 :
- m_mode == TIME ? GetAt(i).end :
- m_mode == FRAME ? (int)(GetAt(i).end*1000/fps) :
- 0);
+ return (i < 0 || GetCount() <= (size_t)i ? -1 :
+ m_mode == TIME ? GetAt(i).end :
+ m_mode == FRAME ? (int)(GetAt(i).end * 1000 / fps) :
+ 0);
}
int CSimpleTextSubtitle::TranslateSegmentStart(int i, double fps)
{
- return (i < 0 || m_segments.GetCount() <= (size_t)i ? -1 :
- m_mode == TIME ? m_segments[i].start :
- m_mode == FRAME ? (int)(m_segments[i].start*1000/fps) :
- 0);
+ return (i < 0 || m_segments.GetCount() <= (size_t)i ? -1 :
+ m_mode == TIME ? m_segments[i].start :
+ m_mode == FRAME ? (int)(m_segments[i].start * 1000 / fps) :
+ 0);
}
int CSimpleTextSubtitle::TranslateSegmentEnd(int i, double fps)
{
- return (i < 0 || m_segments.GetCount() <= (size_t)i ? -1 :
- m_mode == TIME ? m_segments[i].end :
- m_mode == FRAME ? (int)(m_segments[i].end*1000/fps) :
- 0);
+ return (i < 0 || m_segments.GetCount() <= (size_t)i ? -1 :
+ m_mode == TIME ? m_segments[i].end :
+ m_mode == FRAME ? (int)(m_segments[i].end * 1000 / fps) :
+ 0);
}
STSStyle* CSimpleTextSubtitle::GetStyle(int i)
{
- CString def = _T("Default");
+ CString def = _T("Default");
- STSStyle* style = NULL;
- m_styles.Lookup(GetAt(i).style, style);
+ STSStyle* style = NULL;
+ m_styles.Lookup(GetAt(i).style, style);
- STSStyle* defstyle = NULL;
- m_styles.Lookup(def, defstyle);
+ STSStyle* defstyle = NULL;
+ m_styles.Lookup(def, defstyle);
- if (!style) {
- style = defstyle;
- }
+ if (!style) {
+ style = defstyle;
+ }
- ASSERT(style);
+ ASSERT(style);
- return style;
+ return style;
}
bool CSimpleTextSubtitle::GetStyle(int i, STSStyle& stss)
{
- CString def = _T("Default");
+ CString def = _T("Default");
- STSStyle* style = NULL;
- m_styles.Lookup(GetAt(i).style, style);
+ STSStyle* style = NULL;
+ m_styles.Lookup(GetAt(i).style, style);
- STSStyle* defstyle = NULL;
- m_styles.Lookup(def, defstyle);
+ STSStyle* defstyle = NULL;
+ m_styles.Lookup(def, defstyle);
- if (!style) {
- if (!defstyle) {
- defstyle = CreateDefaultStyle(DEFAULT_CHARSET);
- }
+ if (!style) {
+ if (!defstyle) {
+ defstyle = CreateDefaultStyle(DEFAULT_CHARSET);
+ }
- style = defstyle;
- }
+ style = defstyle;
+ }
- if (!style) {
- ASSERT(0);
- return false;
- }
+ if (!style) {
+ ASSERT(0);
+ return false;
+ }
- stss = *style;
- if (stss.relativeTo == 2 && defstyle) {
- stss.relativeTo = defstyle->relativeTo;
- }
+ stss = *style;
+ if (stss.relativeTo == 2 && defstyle) {
+ stss.relativeTo = defstyle->relativeTo;
+ }
- return true;
+ return true;
}
int CSimpleTextSubtitle::GetCharSet(int i)
{
- STSStyle stss;
- GetStyle(i, stss);
- return stss.charSet;
+ STSStyle stss;
+ GetStyle(i, stss);
+ return stss.charSet;
}
bool CSimpleTextSubtitle::IsEntryUnicode(int i)
{
- return GetAt(i).fUnicode;
+ return GetAt(i).fUnicode;
}
void CSimpleTextSubtitle::ConvertUnicode(int i, bool fUnicode)
{
- STSEntry& stse = GetAt(i);
+ STSEntry& stse = GetAt(i);
- if (stse.fUnicode ^ fUnicode) {
- int CharSet = GetCharSet(i);
+ if (stse.fUnicode ^ fUnicode) {
+ int CharSet = GetCharSet(i);
- stse.str = fUnicode
- ? MBCSSSAToUnicode(stse.str, CharSet)
- : UnicodeSSAToMBCS(stse.str, CharSet);
+ stse.str = fUnicode
+ ? MBCSSSAToUnicode(stse.str, CharSet)
+ : UnicodeSSAToMBCS(stse.str, CharSet);
- stse.fUnicode = fUnicode;
- }
+ stse.fUnicode = fUnicode;
+ }
}
CStringA CSimpleTextSubtitle::GetStrA(int i, bool fSSA)
{
- return WToA(GetStrWA(i, fSSA));
+ return WToA(GetStrWA(i, fSSA));
}
CStringW CSimpleTextSubtitle::GetStrW(int i, bool fSSA)
{
- bool fUnicode = IsEntryUnicode(i);
- int CharSet = GetCharSet(i);
+ bool fUnicode = IsEntryUnicode(i);
+ int CharSet = GetCharSet(i);
- CStringW str = GetAt(i).str;
+ CStringW str = GetAt(i).str;
- if (!fUnicode) {
- str = MBCSSSAToUnicode(str, CharSet);
- }
+ if (!fUnicode) {
+ str = MBCSSSAToUnicode(str, CharSet);
+ }
- if (!fSSA) {
- str = RemoveSSATags(str, fUnicode, CharSet);
- }
+ if (!fSSA) {
+ str = RemoveSSATags(str, fUnicode, CharSet);
+ }
- return str;
+ return str;
}
CStringW CSimpleTextSubtitle::GetStrWA(int i, bool fSSA)
{
- bool fUnicode = IsEntryUnicode(i);
- int CharSet = GetCharSet(i);
+ bool fUnicode = IsEntryUnicode(i);
+ int CharSet = GetCharSet(i);
- CStringW str = GetAt(i).str;
+ CStringW str = GetAt(i).str;
- if (fUnicode) {
- str = UnicodeSSAToMBCS(str, CharSet);
- }
+ if (fUnicode) {
+ str = UnicodeSSAToMBCS(str, CharSet);
+ }
- if (!fSSA) {
- str = RemoveSSATags(str, fUnicode, CharSet);
- }
+ if (!fSSA) {
+ str = RemoveSSATags(str, fUnicode, CharSet);
+ }
- return str;
+ return str;
}
void CSimpleTextSubtitle::SetStr(int i, CStringA str, bool fUnicode)
{
- SetStr(i, AToW(str), false);
+ SetStr(i, AToW(str), false);
}
void CSimpleTextSubtitle::SetStr(int i, CStringW str, bool fUnicode)
{
- STSEntry& stse = GetAt(i);
+ STSEntry& stse = GetAt(i);
- str.Replace(L"\n", L"\\N");
+ str.Replace(L"\n", L"\\N");
- if (stse.fUnicode && !fUnicode) {
- stse.str = MBCSSSAToUnicode(str, GetCharSet(i));
- } else if (!stse.fUnicode && fUnicode) {
- stse.str = UnicodeSSAToMBCS(str, GetCharSet(i));
- } else {
- stse.str = str;
- }
+ if (stse.fUnicode && !fUnicode) {
+ stse.str = MBCSSSAToUnicode(str, GetCharSet(i));
+ } else if (!stse.fUnicode && fUnicode) {
+ stse.str = UnicodeSSAToMBCS(str, GetCharSet(i));
+ } else {
+ stse.str = str;
+ }
}
static int comp1(const void* a, const void* b)
{
- int ret = ((STSEntry*)a)->start - ((STSEntry*)b)->start;
- if (ret == 0) {
- ret = ((STSEntry*)a)->layer - ((STSEntry*)b)->layer;
- }
- if (ret == 0) {
- ret = ((STSEntry*)a)->readorder - ((STSEntry*)b)->readorder;
- }
- return ret;
+ int ret = ((STSEntry*)a)->start - ((STSEntry*)b)->start;
+ if (ret == 0) {
+ ret = ((STSEntry*)a)->layer - ((STSEntry*)b)->layer;
+ }
+ if (ret == 0) {
+ ret = ((STSEntry*)a)->readorder - ((STSEntry*)b)->readorder;
+ }
+ return ret;
}
static int comp2(const void* a, const void* b)
{
- return (((STSEntry*)a)->readorder - ((STSEntry*)b)->readorder);
+ return (((STSEntry*)a)->readorder - ((STSEntry*)b)->readorder);
}
void CSimpleTextSubtitle::Sort(bool fRestoreReadorder)
{
- qsort(GetData(), GetCount(), sizeof(STSEntry), !fRestoreReadorder ? comp1 : comp2);
- CreateSegments();
+ qsort(GetData(), GetCount(), sizeof(STSEntry), !fRestoreReadorder ? comp1 : comp2);
+ CreateSegments();
}
static int intcomp(const void* i1, const void* i2)
{
- return (*((int*)i1) - *((int*)i2));
+ return (*((int*)i1) - * ((int*)i2));
}
void CSimpleTextSubtitle::CreateSegments()
{
- m_segments.RemoveAll();
+ m_segments.RemoveAll();
- size_t i, j;
+ size_t i, j;
- CAtlArray<int> breakpoints;
+ CAtlArray<int> breakpoints;
- for (i = 0; i < GetCount(); i++) {
- STSEntry& stse = GetAt(i);
- breakpoints.Add(stse.start);
- breakpoints.Add(stse.end);
- }
+ for (i = 0; i < GetCount(); i++) {
+ STSEntry& stse = GetAt(i);
+ breakpoints.Add(stse.start);
+ breakpoints.Add(stse.end);
+ }
- qsort(breakpoints.GetData(), breakpoints.GetCount(), sizeof(int), intcomp);
+ qsort(breakpoints.GetData(), breakpoints.GetCount(), sizeof(int), intcomp);
- int* ptr = breakpoints.GetData(), prev = ptr ? *ptr : NULL;
+ int* ptr = breakpoints.GetData(), prev = ptr ? *ptr : NULL;
- for (i = breakpoints.GetCount(); i > 0; i--, ptr++) {
- if (*ptr != prev) {
- m_segments.Add(STSSegment(prev, *ptr));
- prev = *ptr;
- }
- }
+ for (i = breakpoints.GetCount(); i > 0; i--, ptr++) {
+ if (*ptr != prev) {
+ m_segments.Add(STSSegment(prev, *ptr));
+ prev = *ptr;
+ }
+ }
- for (i = 0; i < GetCount(); i++) {
- STSEntry& stse = GetAt(i);
- for (j = 0; j < m_segments.GetCount() && m_segments[j].start < stse.start; j++) {
- ;
- }
- for (; j < m_segments.GetCount() && m_segments[j].end <= stse.end; j++) {
- m_segments[j].subs.Add(int(i));
- }
- }
+ for (i = 0; i < GetCount(); i++) {
+ STSEntry& stse = GetAt(i);
+ for (j = 0; j < m_segments.GetCount() && m_segments[j].start < stse.start; j++) {
+ ;
+ }
+ for (; j < m_segments.GetCount() && m_segments[j].end <= stse.end; j++) {
+ m_segments[j].subs.Add(int(i));
+ }
+ }
- OnChanged();
- /*
- for (i = 0, j = m_segments.GetCount(); i < j; i++)
- {
- STSSegment& stss = m_segments[i];
+ OnChanged();
+ /*
+ for (i = 0, j = m_segments.GetCount(); i < j; i++)
+ {
+ STSSegment& stss = m_segments[i];
- TRACE(_T("%d - %d"), stss.start, stss.end);
+ TRACE(_T("%d - %d"), stss.start, stss.end);
- for (size_t k = 0, l = stss.subs.GetCount(); k < l; k++)
- {
- TRACE(_T(", %d"), stss.subs[k]);
- }
+ for (size_t k = 0, l = stss.subs.GetCount(); k < l; k++)
+ {
+ TRACE(_T(", %d"), stss.subs[k]);
+ }
- TRACE(_T("\n"));
- }
- */
+ TRACE(_T("\n"));
+ }
+ */
}
bool CSimpleTextSubtitle::Open(CString fn, int CharSet, CString name)
{
- Empty();
+ Empty();
- CWebTextFile f;
- if (!f.Open(fn)) {
- return false;
- }
+ CWebTextFile f;
+ if (!f.Open(fn)) {
+ return false;
+ }
- fn.Replace('\\', '/');
- if (name.IsEmpty()) {
- name = fn.Left(fn.ReverseFind('.'));
- name = name.Mid(name.ReverseFind('/')+1);
- int len = name.GetLength();
- int pos = name.ReverseFind('.') + 1;
- if ((len - pos) > 1) {
- name = name.Mid(pos);
- }
- }
+ fn.Replace('\\', '/');
+ if (name.IsEmpty()) {
+ name = fn.Left(fn.ReverseFind('.'));
+ name = name.Mid(name.ReverseFind('/') + 1);
+ int len = name.GetLength();
+ int pos = name.ReverseFind('.') + 1;
+ if ((len - pos) > 1) {
+ name = name.Mid(pos);
+ }
+ }
- return Open(&f, CharSet, name);
+ return Open(&f, CharSet, name);
}
static int CountLines(CTextFile* f, ULONGLONG from, ULONGLONG to)
{
- int n = 0;
- CString s;
- f->Seek(from, 0);
- while (f->ReadString(s) && f->GetPosition() < to) {
- n++;
- }
- return n;
+ int n = 0;
+ CString s;
+ f->Seek(from, 0);
+ while (f->ReadString(s) && f->GetPosition() < to) {
+ n++;
+ }
+ return n;
}
bool CSimpleTextSubtitle::Open(CTextFile* f, int CharSet, CString name)
{
- Empty();
+ Empty();
- ULONGLONG pos = f->GetPosition();
+ ULONGLONG pos = f->GetPosition();
- for (ptrdiff_t i = 0; i < nOpenFuncts; i++) {
- if (!OpenFuncts[i].open(f, *this, CharSet) /*|| !GetCount()*/) {
- if (GetCount() > 0) {
- int n = CountLines(f, pos, f->GetPosition());
- CString s;
- s.Format(_T("Syntax error at line %d!\t"), n+1);
- AfxMessageBox(s, MB_OK|MB_ICONERROR);
- Empty();
- break;
- }
+ for (ptrdiff_t i = 0; i < nOpenFuncts; i++) {
+ if (!OpenFuncts[i].open(f, *this, CharSet) /*|| !GetCount()*/) {
+ if (GetCount() > 0) {
+ int n = CountLines(f, pos, f->GetPosition());
+ CString s;
+ s.Format(_T("Syntax error at line %d!\t"), n + 1);
+ AfxMessageBox(s, MB_OK | MB_ICONERROR);
+ Empty();
+ break;
+ }
- f->Seek(pos, 0);
- Empty();
- continue;
- }
+ f->Seek(pos, 0);
+ Empty();
+ continue;
+ }
- m_name = name;
- m_exttype = OpenFuncts[i].type;
- m_mode = OpenFuncts[i].mode;
- m_encoding = f->GetEncoding();
- m_path = f->GetFilePath();
+ m_name = name;
+ m_exttype = OpenFuncts[i].type;
+ m_mode = OpenFuncts[i].mode;
+ m_encoding = f->GetEncoding();
+ m_path = f->GetFilePath();
- // Sort();
- CreateSegments();
- CWebTextFile f2;
- if (f2.Open(f->GetFilePath() + _T(".style"))) {
- OpenSubStationAlpha(&f2, *this, CharSet);
- }
+ // Sort();
+ CreateSegments();
+ CWebTextFile f2;
+ if (f2.Open(f->GetFilePath() + _T(".style"))) {
+ OpenSubStationAlpha(&f2, *this, CharSet);
+ }
- CreateDefaultStyle(CharSet);
+ CreateDefaultStyle(CharSet);
- ChangeUnknownStylesToDefault();
+ ChangeUnknownStylesToDefault();
- if (m_dstScreenSize == CSize(0, 0)) {
- m_dstScreenSize = CSize(384, 288);
- }
+ if (m_dstScreenSize == CSize(0, 0)) {
+ m_dstScreenSize = CSize(384, 288);
+ }
- return true;
- }
+ return true;
+ }
- return false;
+ return false;
}
bool CSimpleTextSubtitle::Open(BYTE* data, int len, int CharSet, CString name)
{
- TCHAR path[_MAX_PATH];
- if (!GetTempPath(_MAX_PATH, path)) {
- return false;
- }
+ TCHAR path[_MAX_PATH];
+ if (!GetTempPath(_MAX_PATH, path)) {
+ return false;
+ }
- TCHAR fn[_MAX_PATH];
- if (!GetTempFileName(path, _T("vs"), 0, fn)) {
- return false;
- }
+ TCHAR fn[_MAX_PATH];
+ if (!GetTempFileName(path, _T("vs"), 0, fn)) {
+ return false;
+ }
- FILE* tmp = NULL;
- if (_tfopen_s(&tmp, fn, _T("wb"))) {
- return false;
- }
+ FILE* tmp = NULL;
+ if (_tfopen_s(&tmp, fn, _T("wb"))) {
+ return false;
+ }
- int i = 0;
- for (; i <= (len-1024); i += 1024) {
- fwrite(&data[i], 1024, 1, tmp);
- }
- if (len > i) {
- fwrite(&data[i], len - i, 1, tmp);
- }
+ int i = 0;
+ for (; i <= (len - 1024); i += 1024) {
+ fwrite(&data[i], 1024, 1, tmp);
+ }
+ if (len > i) {
+ fwrite(&data[i], len - i, 1, tmp);
+ }
- fclose(tmp);
+ fclose(tmp);
- bool fRet = Open(fn, CharSet, name);
+ bool fRet = Open(fn, CharSet, name);
- _tremove(fn);
+ _tremove(fn);
- return fRet;
+ return fRet;
}
bool CSimpleTextSubtitle::SaveAs(CString fn, exttype et, double fps, CTextFile::enc e)
{
- if (fn.Mid(fn.ReverseFind('.')+1).CompareNoCase(exttypestr[et])) {
- if (fn[fn.GetLength()-1] != '.') {
- fn += _T(".");
- }
- fn += exttypestr[et];
- }
-
- CTextFile f;
- if (!f.Save(fn, e)) {
- return false;
- }
-
- if (et == EXTSMI) {
- CString str;
-
- str += _T("<SAMI>\n<HEAD>\n");
- str += _T("<STYLE TYPE=\"text/css\">\n");
- str += _T("<!--\n");
- str += _T("P {margin-left: 16pt; margin-right: 16pt; margin-bottom: 16pt; margin-top: 16pt;\n");
- str += _T(" text-align: center; font-size: 18pt; font-family: arial; font-weight: bold; color: #f0f0f0;}\n");
- str += _T(".UNKNOWNCC {Name:Unknown; lang:en-US; SAMIType:CC;}\n");
- str += _T("-->\n");
- str += _T("</STYLE>\n");
- str += _T("</HEAD>\n");
- str += _T("\n");
- str += _T("<BODY>\n");
-
- f.WriteString(str);
- } else if (et == EXTSSA || et == EXTASS) {
- CString str;
-
- str = _T("[Script Info]\n");
- str += (et == EXTSSA) ? _T("; This is a Sub Station Alpha v4 script.\n") : _T("; This is an Advanced Sub Station Alpha v4+ script.\n");
- str += _T("; For Sub Station Alpha info and downloads,\n");
- str += _T("; go to http://www.eswat.demon.co.uk/\n");
- str += _T("; or email kotus@eswat.demon.co.uk\n");
- str += _T("; \n");
- if (et == EXTASS) {
- str += _T("; Advanced Sub Station Alpha script format developed by #Anime-Fansubs@EfNET\n");
- str += _T("; http://www.anime-fansubs.org\n");
- str += _T("; \n");
- str += _T("; For additional info and downloads go to http://gabest.org/\n");
- str += _T("; or email gabest@freemail.hu\n");
- str += _T("; \n");
- }
- str += _T("; Note: This file was saved by Subresync.\n");
- str += _T("; \n");
- str += (et == EXTSSA) ? _T("ScriptType: v4.00\n") : _T("ScriptType: v4.00+\n");
- str += (m_collisions == 0) ? _T("Collisions: Normal\n") : _T("Collisions: Reverse\n");
- if (et == EXTASS && m_fScaledBAS) {
- str += _T("ScaledBorderAndShadow: Yes\n");
- }
- str += _T("PlayResX: %d\n");
- str += _T("PlayResY: %d\n");
- str += _T("Timer: 100.0000\n");
- str += _T("\n");
- str += (et == EXTSSA)
- ? _T("[V4 Styles]\nFormat: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding\n")
- : _T("[V4+ Styles]\nFormat: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding\n");
-
- CString str2;
- str2.Format(str, m_dstScreenSize.cx, m_dstScreenSize.cy);
- f.WriteString(str2);
-
- str = (et == EXTSSA)
- ? _T("Style: %s,%s,%d,&H%06x,&H%06x,&H%06x,&H%06x,%d,%d,%d,%.2f,%.2f,%d,%d,%d,%d,%d,%d\n")
- : _T("Style: %s,%s,%d,&H%08x,&H%08x,&H%08x,&H%08x,%d,%d,%d,%d,%.2f,%.2f,%.2f,%.2f,%d,%.2f,%.2f,%d,%d,%d,%d,%d\n");
-
- POSITION pos = m_styles.GetStartPosition();
- while (pos) {
- CString key;
- STSStyle* s;
- m_styles.GetNextAssoc(pos, key, s);
-
- if (et == EXTSSA) {
- CString str2;
- str2.Format(str, key,
- s->fontName, (int)s->fontSize,
- s->colors[0]&0xffffff,
- s->colors[1]&0xffffff,
- s->colors[2]&0xffffff,
- s->colors[3]&0xffffff,
- s->fontWeight > FW_NORMAL ? -1 : 0, s->fItalic ? -1 : 0,
- s->borderStyle == 0 ? 1 : s->borderStyle == 1 ? 3 : 0,
- s->outlineWidthY, s->shadowDepthY,
- s->scrAlignment <= 3 ? s->scrAlignment : s->scrAlignment <= 6 ? ((s->scrAlignment-3)|8) : s->scrAlignment <= 9 ? ((s->scrAlignment-6)|4) : 2,
- s->marginRect.left, s->marginRect.right, (s->marginRect.top + s->marginRect.bottom) / 2,
- s->alpha[0],
- s->charSet);
- f.WriteString(str2);
- } else {
- CString str2;
- str2.Format(str, key,
- s->fontName, (int)s->fontSize,
- (s->colors[0]&0xffffff) | (s->alpha[0]<<24),
- (s->colors[1]&0xffffff) | (s->alpha[1]<<24),
- (s->colors[2]&0xffffff) | (s->alpha[2]<<24),
- (s->colors[3]&0xffffff) | (s->alpha[3]<<24),
- s->fontWeight > FW_NORMAL ? -1 : 0,
- s->fItalic ? -1 : 0, s->fUnderline ? -1 : 0, s->fStrikeOut ? -1 : 0,
- s->fontScaleX, s->fontScaleY,
- s->fontSpacing, s->fontAngleZ,
- s->borderStyle == 0 ? 1 : s->borderStyle == 1 ? 3 : 0,
- s->outlineWidthY, s->shadowDepthY,
- s->scrAlignment,
- s->marginRect.left, s->marginRect.right, (int)((s->marginRect.top + s->marginRect.bottom) / 2),
- s->charSet);
- f.WriteString(str2);
- }
- }
-
- if (GetCount() > 0) {
- str = _T("\n");
- str += _T("[Events]\n");
- str += (et == EXTSSA)
- ? _T("Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text\n")
- : _T("Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text\n");
- f.WriteString(str);
- }
- }
-
- CStringW fmt =
- et == EXTSRT ? L"%d\n%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\n%s\n\n" :
- et == EXTSUB ? L"{%d}{%d}%s\n" :
- et == EXTSMI ? L"<SYNC Start=%d><P Class=UNKNOWNCC>\n%s\n<SYNC Start=%d><P Class=UNKNOWNCC>&nbsp;\n" :
- et == EXTPSB ? L"{%d:%02d:%02d}{%d:%02d:%02d}%s\n" :
- et == EXTSSA ? L"Dialogue: Marked=0,%d:%02d:%02d.%02d,%d:%02d:%02d.%02d,%s,%s,%04d,%04d,%04d,%s,%s\n" :
- et == EXTASS ? L"Dialogue: %d,%d:%02d:%02d.%02d,%d:%02d:%02d.%02d,%s,%s,%04d,%04d,%04d,%s,%s\n" :
- L"";
- // Sort(true);
-
- for (int i = 0, j = (int)GetCount(), k = 0; i < j; i++) {
- STSEntry& stse = GetAt(i);
-
- int t1 = TranslateStart(i, fps);
- if (t1 < 0) {
- k++;
- continue;
- }
-
- int t2 = TranslateEnd(i, fps);
-
- int hh1 = (t1/60/60/1000);
- int mm1 = (t1/60/1000)%60;
- int ss1 = (t1/1000)%60;
- int ms1 = (t1)%1000;
- int hh2 = (t2/60/60/1000);
- int mm2 = (t2/60/1000)%60;
- int ss2 = (t2/1000)%60;
- int ms2 = (t2)%1000;
-
- CStringW str = f.IsUnicode()
- ? GetStrW(i, et == EXTSSA || et == EXTASS)
- : GetStrWA(i, et == EXTSSA || et == EXTASS);
-
- CStringW str2;
-
- if (et == EXTSRT) {
- str2.Format(fmt, i-k+1, hh1, mm1, ss1, ms1, hh2, mm2, ss2, ms2, str);
- } else if (et == EXTSUB) {
- str.Replace('\n', '|');
- str2.Format(fmt, t1*fps/1000, t2*fps/1000, str);
- } else if (et == EXTSMI) {
- str.Replace(L"\n", L"<br>");
- str2.Format(fmt, t1, str, t2);
- } else if (et == EXTPSB) {
- str.Replace('\n', '|');
- str2.Format(fmt, hh1, mm1, ss1, hh2, mm2, ss2, str);
- } else if (et == EXTSSA) {
- str.Replace(L"\n", L"\\N");
- str2.Format(fmt,
- hh1, mm1, ss1, ms1/10,
- hh2, mm2, ss2, ms2/10,
- TToW(stse.style), TToW(stse.actor),
- stse.marginRect.left, stse.marginRect.right, (stse.marginRect.top + stse.marginRect.bottom) / 2,
- TToW(stse.effect), str);
- } else if (et == EXTASS) {
- str.Replace(L"\n", L"\\N");
- str2.Format(fmt,
- stse.layer,
- hh1, mm1, ss1, ms1/10,
- hh2, mm2, ss2, ms2/10,
- TToW(stse.style), TToW(stse.actor),
- stse.marginRect.left, stse.marginRect.right, (stse.marginRect.top + stse.marginRect.bottom) / 2,
- TToW(stse.effect), str);
- }
-
- f.WriteString(str2);
- }
-
- // Sort();
-
- if (et == EXTSMI) {
- f.WriteString(_T("</BODY>\n</SAMI>\n"));
- }
-
- STSStyle* s;
- if (!m_fUsingAutoGeneratedDefaultStyle && m_styles.Lookup(_T("Default"), s) && et != EXTSSA && et != EXTASS) {
- CTextFile f;
- if (!f.Save(fn + _T(".style"), e)) {
- return false;
- }
-
- CString str, str2;
-
- str += _T("ScriptType: v4.00+\n");
- str += _T("PlayResX: %d\n");
- str += _T("PlayResY: %d\n");
- str += _T("\n");
- str += _T("[V4+ Styles]\nFormat: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding\n");
- str2.Format(str, m_dstScreenSize.cx, m_dstScreenSize.cy);
- f.WriteString(str2);
-
- str = _T("Style: Default,%s,%d,&H%08x,&H%08x,&H%08x,&H%08x,%d,%d,%d,%d,%.2f,%.2f,%.2f,%.2f,%d,%.2f,%.2f,%d,%d,%d,%d,%d\n");
- str2.Format(str,
- s->fontName, (int)s->fontSize,
- (s->colors[0]&0xffffff) | (s->alpha[0]<<24),
- (s->colors[1]&0xffffff) | (s->alpha[1]<<24),
- (s->colors[2]&0xffffff) | (s->alpha[2]<<24),
- (s->colors[3]&0xffffff) | (s->alpha[3]<<24),
- s->fontWeight > FW_NORMAL ? -1 : 0,
- s->fItalic ? -1 : 0, s->fUnderline ? -1 : 0, s->fStrikeOut ? -1 : 0,
- s->fontScaleX, s->fontScaleY,
- s->fontSpacing, s->fontAngleZ,
- s->borderStyle == 0 ? 1 : s->borderStyle == 1 ? 3 : 0,
- s->outlineWidthY, s->shadowDepthY,
- s->scrAlignment,
- s->marginRect.left, s->marginRect.right, (int)((s->marginRect.top + s->marginRect.bottom) / 2),
- s->charSet);
- f.WriteString(str2);
- }
-
- return true;
+ if (fn.Mid(fn.ReverseFind('.') + 1).CompareNoCase(exttypestr[et])) {
+ if (fn[fn.GetLength() - 1] != '.') {
+ fn += _T(".");
+ }
+ fn += exttypestr[et];
+ }
+
+ CTextFile f;
+ if (!f.Save(fn, e)) {
+ return false;
+ }
+
+ if (et == EXTSMI) {
+ CString str;
+
+ str += _T("<SAMI>\n<HEAD>\n");
+ str += _T("<STYLE TYPE=\"text/css\">\n");
+ str += _T("<!--\n");
+ str += _T("P {margin-left: 16pt; margin-right: 16pt; margin-bottom: 16pt; margin-top: 16pt;\n");
+ str += _T(" text-align: center; font-size: 18pt; font-family: arial; font-weight: bold; color: #f0f0f0;}\n");
+ str += _T(".UNKNOWNCC {Name:Unknown; lang:en-US; SAMIType:CC;}\n");
+ str += _T("-->\n");
+ str += _T("</STYLE>\n");
+ str += _T("</HEAD>\n");
+ str += _T("\n");
+ str += _T("<BODY>\n");
+
+ f.WriteString(str);
+ } else if (et == EXTSSA || et == EXTASS) {
+ CString str;
+
+ str = _T("[Script Info]\n");
+ str += (et == EXTSSA) ? _T("; This is a Sub Station Alpha v4 script.\n") : _T("; This is an Advanced Sub Station Alpha v4+ script.\n");
+ str += _T("; For Sub Station Alpha info and downloads,\n");
+ str += _T("; go to http://www.eswat.demon.co.uk/\n");
+ str += _T("; or email kotus@eswat.demon.co.uk\n");
+ str += _T("; \n");
+ if (et == EXTASS) {
+ str += _T("; Advanced Sub Station Alpha script format developed by #Anime-Fansubs@EfNET\n");
+ str += _T("; http://www.anime-fansubs.org\n");
+ str += _T("; \n");
+ str += _T("; For additional info and downloads go to http://gabest.org/\n");
+ str += _T("; or email gabest@freemail.hu\n");
+ str += _T("; \n");
+ }
+ str += _T("; Note: This file was saved by Subresync.\n");
+ str += _T("; \n");
+ str += (et == EXTSSA) ? _T("ScriptType: v4.00\n") : _T("ScriptType: v4.00+\n");
+ str += (m_collisions == 0) ? _T("Collisions: Normal\n") : _T("Collisions: Reverse\n");
+ if (et == EXTASS && m_fScaledBAS) {
+ str += _T("ScaledBorderAndShadow: Yes\n");
+ }
+ str += _T("PlayResX: %d\n");
+ str += _T("PlayResY: %d\n");
+ str += _T("Timer: 100.0000\n");
+ str += _T("\n");
+ str += (et == EXTSSA)
+ ? _T("[V4 Styles]\nFormat: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding\n")
+ : _T("[V4+ Styles]\nFormat: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding\n");
+
+ CString str2;
+ str2.Format(str, m_dstScreenSize.cx, m_dstScreenSize.cy);
+ f.WriteString(str2);
+
+ str = (et == EXTSSA)
+ ? _T("Style: %s,%s,%d,&H%06x,&H%06x,&H%06x,&H%06x,%d,%d,%d,%.2f,%.2f,%d,%d,%d,%d,%d,%d\n")
+ : _T("Style: %s,%s,%d,&H%08x,&H%08x,&H%08x,&H%08x,%d,%d,%d,%d,%.2f,%.2f,%.2f,%.2f,%d,%.2f,%.2f,%d,%d,%d,%d,%d\n");
+
+ POSITION pos = m_styles.GetStartPosition();
+ while (pos) {
+ CString key;
+ STSStyle* s;
+ m_styles.GetNextAssoc(pos, key, s);
+
+ if (et == EXTSSA) {
+ CString str2;
+ str2.Format(str, key,
+ s->fontName, (int)s->fontSize,
+ s->colors[0] & 0xffffff,
+ s->colors[1] & 0xffffff,
+ s->colors[2] & 0xffffff,
+ s->colors[3] & 0xffffff,
+ s->fontWeight > FW_NORMAL ? -1 : 0, s->fItalic ? -1 : 0,
+ s->borderStyle == 0 ? 1 : s->borderStyle == 1 ? 3 : 0,
+ s->outlineWidthY, s->shadowDepthY,
+ s->scrAlignment <= 3 ? s->scrAlignment : s->scrAlignment <= 6 ? ((s->scrAlignment - 3) | 8) : s->scrAlignment <= 9 ? ((s->scrAlignment - 6) | 4) : 2,
+ s->marginRect.left, s->marginRect.right, (s->marginRect.top + s->marginRect.bottom) / 2,
+ s->alpha[0],
+ s->charSet);
+ f.WriteString(str2);
+ } else {
+ CString str2;
+ str2.Format(str, key,
+ s->fontName, (int)s->fontSize,
+ (s->colors[0] & 0xffffff) | (s->alpha[0] << 24),
+ (s->colors[1] & 0xffffff) | (s->alpha[1] << 24),
+ (s->colors[2] & 0xffffff) | (s->alpha[2] << 24),
+ (s->colors[3] & 0xffffff) | (s->alpha[3] << 24),
+ s->fontWeight > FW_NORMAL ? -1 : 0,
+ s->fItalic ? -1 : 0, s->fUnderline ? -1 : 0, s->fStrikeOut ? -1 : 0,
+ s->fontScaleX, s->fontScaleY,
+ s->fontSpacing, s->fontAngleZ,
+ s->borderStyle == 0 ? 1 : s->borderStyle == 1 ? 3 : 0,
+ s->outlineWidthY, s->shadowDepthY,
+ s->scrAlignment,
+ s->marginRect.left, s->marginRect.right, (int)((s->marginRect.top + s->marginRect.bottom) / 2),
+ s->charSet);
+ f.WriteString(str2);
+ }
+ }
+
+ if (GetCount() > 0) {
+ str = _T("\n");
+ str += _T("[Events]\n");
+ str += (et == EXTSSA)
+ ? _T("Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text\n")
+ : _T("Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text\n");
+ f.WriteString(str);
+ }
+ }
+
+ CStringW fmt =
+ et == EXTSRT ? L"%d\n%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\n%s\n\n" :
+ et == EXTSUB ? L"{%d}{%d}%s\n" :
+ et == EXTSMI ? L"<SYNC Start=%d><P Class=UNKNOWNCC>\n%s\n<SYNC Start=%d><P Class=UNKNOWNCC>&nbsp;\n" :
+ et == EXTPSB ? L"{%d:%02d:%02d}{%d:%02d:%02d}%s\n" :
+ et == EXTSSA ? L"Dialogue: Marked=0,%d:%02d:%02d.%02d,%d:%02d:%02d.%02d,%s,%s,%04d,%04d,%04d,%s,%s\n" :
+ et == EXTASS ? L"Dialogue: %d,%d:%02d:%02d.%02d,%d:%02d:%02d.%02d,%s,%s,%04d,%04d,%04d,%s,%s\n" :
+ L"";
+ // Sort(true);
+
+ for (int i = 0, j = (int)GetCount(), k = 0; i < j; i++) {
+ STSEntry& stse = GetAt(i);
+
+ int t1 = TranslateStart(i, fps);
+ if (t1 < 0) {
+ k++;
+ continue;
+ }
+
+ int t2 = TranslateEnd(i, fps);
+
+ int hh1 = (t1 / 60 / 60 / 1000);
+ int mm1 = (t1 / 60 / 1000) % 60;
+ int ss1 = (t1 / 1000) % 60;
+ int ms1 = (t1) % 1000;
+ int hh2 = (t2 / 60 / 60 / 1000);
+ int mm2 = (t2 / 60 / 1000) % 60;
+ int ss2 = (t2 / 1000) % 60;
+ int ms2 = (t2) % 1000;
+
+ CStringW str = f.IsUnicode()
+ ? GetStrW(i, et == EXTSSA || et == EXTASS)
+ : GetStrWA(i, et == EXTSSA || et == EXTASS);
+
+ CStringW str2;
+
+ if (et == EXTSRT) {
+ str2.Format(fmt, i - k + 1, hh1, mm1, ss1, ms1, hh2, mm2, ss2, ms2, str);
+ } else if (et == EXTSUB) {
+ str.Replace('\n', '|');
+ str2.Format(fmt, t1 * fps / 1000, t2 * fps / 1000, str);
+ } else if (et == EXTSMI) {
+ str.Replace(L"\n", L"<br>");
+ str2.Format(fmt, t1, str, t2);
+ } else if (et == EXTPSB) {
+ str.Replace('\n', '|');
+ str2.Format(fmt, hh1, mm1, ss1, hh2, mm2, ss2, str);
+ } else if (et == EXTSSA) {
+ str.Replace(L"\n", L"\\N");
+ str2.Format(fmt,
+ hh1, mm1, ss1, ms1 / 10,
+ hh2, mm2, ss2, ms2 / 10,
+ TToW(stse.style), TToW(stse.actor),
+ stse.marginRect.left, stse.marginRect.right, (stse.marginRect.top + stse.marginRect.bottom) / 2,
+ TToW(stse.effect), str);
+ } else if (et == EXTASS) {
+ str.Replace(L"\n", L"\\N");
+ str2.Format(fmt,
+ stse.layer,
+ hh1, mm1, ss1, ms1 / 10,
+ hh2, mm2, ss2, ms2 / 10,
+ TToW(stse.style), TToW(stse.actor),
+ stse.marginRect.left, stse.marginRect.right, (stse.marginRect.top + stse.marginRect.bottom) / 2,
+ TToW(stse.effect), str);
+ }
+
+ f.WriteString(str2);
+ }
+
+ // Sort();
+
+ if (et == EXTSMI) {
+ f.WriteString(_T("</BODY>\n</SAMI>\n"));
+ }
+
+ STSStyle* s;
+ if (!m_fUsingAutoGeneratedDefaultStyle && m_styles.Lookup(_T("Default"), s) && et != EXTSSA && et != EXTASS) {
+ CTextFile f;
+ if (!f.Save(fn + _T(".style"), e)) {
+ return false;
+ }
+
+ CString str, str2;
+
+ str += _T("ScriptType: v4.00+\n");
+ str += _T("PlayResX: %d\n");
+ str += _T("PlayResY: %d\n");
+ str += _T("\n");
+ str += _T("[V4+ Styles]\nFormat: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding\n");
+ str2.Format(str, m_dstScreenSize.cx, m_dstScreenSize.cy);
+ f.WriteString(str2);
+
+ str = _T("Style: Default,%s,%d,&H%08x,&H%08x,&H%08x,&H%08x,%d,%d,%d,%d,%.2f,%.2f,%.2f,%.2f,%d,%.2f,%.2f,%d,%d,%d,%d,%d\n");
+ str2.Format(str,
+ s->fontName, (int)s->fontSize,
+ (s->colors[0] & 0xffffff) | (s->alpha[0] << 24),
+ (s->colors[1] & 0xffffff) | (s->alpha[1] << 24),
+ (s->colors[2] & 0xffffff) | (s->alpha[2] << 24),
+ (s->colors[3] & 0xffffff) | (s->alpha[3] << 24),
+ s->fontWeight > FW_NORMAL ? -1 : 0,
+ s->fItalic ? -1 : 0, s->fUnderline ? -1 : 0, s->fStrikeOut ? -1 : 0,
+ s->fontScaleX, s->fontScaleY,
+ s->fontSpacing, s->fontAngleZ,
+ s->borderStyle == 0 ? 1 : s->borderStyle == 1 ? 3 : 0,
+ s->outlineWidthY, s->shadowDepthY,
+ s->scrAlignment,
+ s->marginRect.left, s->marginRect.right, (int)((s->marginRect.top + s->marginRect.bottom) / 2),
+ s->charSet);
+ f.WriteString(str2);
+ }
+
+ return true;
}
////////////////////////////////////////////////////////////////////
STSStyle::STSStyle()
{
- SetDefault();
+ SetDefault();
}
void STSStyle::SetDefault()
{
- marginRect = CRect(20, 20, 20, 20);
- scrAlignment = 2;
- borderStyle = 0;
- outlineWidthX = outlineWidthY = 2;
- shadowDepthX = shadowDepthY = 3;
- colors[0] = 0x00ffffff;
- colors[1] = 0x0000ffff;
- colors[2] = 0x00000000;
- colors[3] = 0x00000000;
- alpha[0] = 0x00;
- alpha[1] = 0x00;
- alpha[2] = 0x00;
- alpha[3] = 0x80;
- charSet = DEFAULT_CHARSET;
- fontName = _T("Arial");
- fontSize = 18;
- fontScaleX = fontScaleY = 100;
- fontSpacing = 0;
- fontWeight = FW_BOLD;
- fItalic = false;
- fUnderline = false;
- fStrikeOut = false;
- fBlur = 0;
- fGaussianBlur = 0;
- fontShiftX = fontShiftY = fontAngleZ = fontAngleX = fontAngleY = 0;
- relativeTo = 2;
+ marginRect = CRect(20, 20, 20, 20);
+ scrAlignment = 2;
+ borderStyle = 0;
+ outlineWidthX = outlineWidthY = 2;
+ shadowDepthX = shadowDepthY = 3;
+ colors[0] = 0x00ffffff;
+ colors[1] = 0x0000ffff;
+ colors[2] = 0x00000000;
+ colors[3] = 0x00000000;
+ alpha[0] = 0x00;
+ alpha[1] = 0x00;
+ alpha[2] = 0x00;
+ alpha[3] = 0x80;
+ charSet = DEFAULT_CHARSET;
+ fontName = _T("Arial");
+ fontSize = 18;
+ fontScaleX = fontScaleY = 100;
+ fontSpacing = 0;
+ fontWeight = FW_BOLD;
+ fItalic = false;
+ fUnderline = false;
+ fStrikeOut = false;
+ fBlur = 0;
+ fGaussianBlur = 0;
+ fontShiftX = fontShiftY = fontAngleZ = fontAngleX = fontAngleY = 0;
+ relativeTo = 2;
}
bool STSStyle::operator == (STSStyle& s)
{
- return (marginRect == s.marginRect
- && scrAlignment == s.scrAlignment
- && borderStyle == s.borderStyle
- && outlineWidthX == s.outlineWidthX
- && outlineWidthY == s.outlineWidthY
- && shadowDepthX == s.shadowDepthX
- && shadowDepthY == s.shadowDepthY
- && *((int*)&colors[0]) == *((int*)&s.colors[0])
- && *((int*)&colors[1]) == *((int*)&s.colors[1])
- && *((int*)&colors[2]) == *((int*)&s.colors[2])
- && *((int*)&colors[3]) == *((int*)&s.colors[3])
- && alpha[0] == s.alpha[0]
- && alpha[1] == s.alpha[1]
- && alpha[2] == s.alpha[2]
- && alpha[3] == s.alpha[3]
- && fBlur == s.fBlur
- && fGaussianBlur == s.fGaussianBlur
- && relativeTo == s.relativeTo
- && IsFontStyleEqual(s));
+ return (marginRect == s.marginRect
+ && scrAlignment == s.scrAlignment
+ && borderStyle == s.borderStyle
+ && outlineWidthX == s.outlineWidthX
+ && outlineWidthY == s.outlineWidthY
+ && shadowDepthX == s.shadowDepthX
+ && shadowDepthY == s.shadowDepthY
+ && *((int*)&colors[0]) == *((int*)&s.colors[0])
+ && *((int*)&colors[1]) == *((int*)&s.colors[1])
+ && *((int*)&colors[2]) == *((int*)&s.colors[2])
+ && *((int*)&colors[3]) == *((int*)&s.colors[3])
+ && alpha[0] == s.alpha[0]
+ && alpha[1] == s.alpha[1]
+ && alpha[2] == s.alpha[2]
+ && alpha[3] == s.alpha[3]
+ && fBlur == s.fBlur
+ && fGaussianBlur == s.fGaussianBlur
+ && relativeTo == s.relativeTo
+ && IsFontStyleEqual(s));
}
bool STSStyle::IsFontStyleEqual(STSStyle& s)
{
- return (
- charSet == s.charSet
- && fontName == s.fontName
- && fontSize == s.fontSize
- && fontScaleX == s.fontScaleX
- && fontScaleY == s.fontScaleY
- && fontSpacing == s.fontSpacing
- && fontWeight == s.fontWeight
- && fItalic == s.fItalic
- && fUnderline == s.fUnderline
- && fStrikeOut == s.fStrikeOut
- && fontAngleZ == s.fontAngleZ
- && fontAngleX == s.fontAngleX
- && fontAngleY == s.fontAngleY
- // patch f001. fax fay patch (many instances at line)
- && fontShiftX == s.fontShiftX
- && fontShiftY == s.fontShiftY);
+ return (
+ charSet == s.charSet
+ && fontName == s.fontName
+ && fontSize == s.fontSize
+ && fontScaleX == s.fontScaleX
+ && fontScaleY == s.fontScaleY
+ && fontSpacing == s.fontSpacing
+ && fontWeight == s.fontWeight
+ && fItalic == s.fItalic
+ && fUnderline == s.fUnderline
+ && fStrikeOut == s.fStrikeOut
+ && fontAngleZ == s.fontAngleZ
+ && fontAngleX == s.fontAngleX
+ && fontAngleY == s.fontAngleY
+ // patch f001. fax fay patch (many instances at line)
+ && fontShiftX == s.fontShiftX
+ && fontShiftY == s.fontShiftY);
}
STSStyle& STSStyle::operator = (LOGFONT& lf)
{
- charSet = lf.lfCharSet;
- fontName = lf.lfFaceName;
- HDC hDC = GetDC(0);
- fontSize = -MulDiv(lf.lfHeight, 72, GetDeviceCaps(hDC, LOGPIXELSY));
- ReleaseDC(0, hDC);
- // fontAngleZ = lf.lfEscapement/10.0;
- fontWeight = lf.lfWeight;
- fItalic = lf.lfItalic;
- fUnderline = lf.lfUnderline;
- fStrikeOut = lf.lfStrikeOut;
- return *this;
+ charSet = lf.lfCharSet;
+ fontName = lf.lfFaceName;
+ HDC hDC = GetDC(0);
+ fontSize = -MulDiv(lf.lfHeight, 72, GetDeviceCaps(hDC, LOGPIXELSY));
+ ReleaseDC(0, hDC);
+ // fontAngleZ = lf.lfEscapement/10.0;
+ fontWeight = lf.lfWeight;
+ fItalic = lf.lfItalic;
+ fUnderline = lf.lfUnderline;
+ fStrikeOut = lf.lfStrikeOut;
+ return *this;
}
LOGFONTA& operator <<= (LOGFONTA& lfa, STSStyle& s)
{
- lfa.lfCharSet = s.charSet;
- strncpy_s(lfa.lfFaceName, LF_FACESIZE, CStringA(s.fontName), _TRUNCATE);
- HDC hDC = GetDC(0);
- lfa.lfHeight = -MulDiv((int)(s.fontSize+0.5), GetDeviceCaps(hDC, LOGPIXELSY), 72);
- ReleaseDC(0, hDC);
- lfa.lfWeight = s.fontWeight;
- lfa.lfItalic = s.fItalic?-1:0;
- lfa.lfUnderline = s.fUnderline?-1:0;
- lfa.lfStrikeOut = s.fStrikeOut?-1:0;
- return lfa;
+ lfa.lfCharSet = s.charSet;
+ strncpy_s(lfa.lfFaceName, LF_FACESIZE, CStringA(s.fontName), _TRUNCATE);
+ HDC hDC = GetDC(0);
+ lfa.lfHeight = -MulDiv((int)(s.fontSize + 0.5), GetDeviceCaps(hDC, LOGPIXELSY), 72);
+ ReleaseDC(0, hDC);
+ lfa.lfWeight = s.fontWeight;
+ lfa.lfItalic = s.fItalic ? -1 : 0;
+ lfa.lfUnderline = s.fUnderline ? -1 : 0;
+ lfa.lfStrikeOut = s.fStrikeOut ? -1 : 0;
+ return lfa;
}
LOGFONTW& operator <<= (LOGFONTW& lfw, STSStyle& s)
{
- lfw.lfCharSet = s.charSet;
- wcsncpy_s(lfw.lfFaceName, LF_FACESIZE, CStringW(s.fontName), _TRUNCATE);
- HDC hDC = GetDC(0);
- lfw.lfHeight = -MulDiv((int)(s.fontSize+0.5), GetDeviceCaps(hDC, LOGPIXELSY), 72);
- ReleaseDC(0, hDC);
- lfw.lfWeight = s.fontWeight;
- lfw.lfItalic = s.fItalic?-1:0;
- lfw.lfUnderline = s.fUnderline?-1:0;
- lfw.lfStrikeOut = s.fStrikeOut?-1:0;
- return lfw;
+ lfw.lfCharSet = s.charSet;
+ wcsncpy_s(lfw.lfFaceName, LF_FACESIZE, CStringW(s.fontName), _TRUNCATE);
+ HDC hDC = GetDC(0);
+ lfw.lfHeight = -MulDiv((int)(s.fontSize + 0.5), GetDeviceCaps(hDC, LOGPIXELSY), 72);
+ ReleaseDC(0, hDC);
+ lfw.lfWeight = s.fontWeight;
+ lfw.lfItalic = s.fItalic ? -1 : 0;
+ lfw.lfUnderline = s.fUnderline ? -1 : 0;
+ lfw.lfStrikeOut = s.fStrikeOut ? -1 : 0;
+ return lfw;
}
CString& operator <<= (CString& style, STSStyle& s)
{
- style.Format(_T("%d;%d;%d;%d;%d;%d;%f;%f;%f;%f;0x%06x;0x%06x;0x%06x;0x%06x;0x%02x;0x%02x;0x%02x;0x%02x;%d;%s;%f;%f;%f;%f;%d;%d;%d;%d;%d;%f;%f;%f;%f;%d"),
- s.marginRect.left, s.marginRect.right, s.marginRect.top, s.marginRect.bottom,
- s.scrAlignment, s.borderStyle,
- s.outlineWidthX, s.outlineWidthY, s.shadowDepthX, s.shadowDepthY,
- s.colors[0], s.colors[1], s.colors[2], s.colors[3],
- s.alpha[0], s.alpha[1], s.alpha[2], s.alpha[3],
- s.charSet,
- s.fontName,s.fontSize,
- s.fontScaleX, s.fontScaleY,
- s.fontSpacing,s.fontWeight,
- s.fItalic, s.fUnderline, s.fStrikeOut, s.fBlur, s.fGaussianBlur,
- s.fontAngleZ, s.fontAngleX, s.fontAngleY,
- s.relativeTo);
+ style.Format(_T("%d;%d;%d;%d;%d;%d;%f;%f;%f;%f;0x%06x;0x%06x;0x%06x;0x%06x;0x%02x;0x%02x;0x%02x;0x%02x;%d;%s;%f;%f;%f;%f;%d;%d;%d;%d;%d;%f;%f;%f;%f;%d"),
+ s.marginRect.left, s.marginRect.right, s.marginRect.top, s.marginRect.bottom,
+ s.scrAlignment, s.borderStyle,
+ s.outlineWidthX, s.outlineWidthY, s.shadowDepthX, s.shadowDepthY,
+ s.colors[0], s.colors[1], s.colors[2], s.colors[3],
+ s.alpha[0], s.alpha[1], s.alpha[2], s.alpha[3],
+ s.charSet,
+ s.fontName, s.fontSize,
+ s.fontScaleX, s.fontScaleY,
+ s.fontSpacing, s.fontWeight,
+ s.fItalic, s.fUnderline, s.fStrikeOut, s.fBlur, s.fGaussianBlur,
+ s.fontAngleZ, s.fontAngleX, s.fontAngleY,
+ s.relativeTo);
- return style;
+ return style;
}
STSStyle& operator <<= (STSStyle& s, CString& style)
{
- s.SetDefault();
-
- try {
- CStringW str = TToW(style);
- if (str.Find(';')>=0) {
- s.marginRect.left = GetInt(str, ';');
- s.marginRect.right = GetInt(str, ';');
- s.marginRect.top = GetInt(str, ';');
- s.marginRect.bottom = GetInt(str, ';');
- s.scrAlignment = GetInt(str, ';');
- s.borderStyle = GetInt(str, ';');
- s.outlineWidthX = GetFloat(str, ';');
- s.outlineWidthY = GetFloat(str, ';');
- s.shadowDepthX = GetFloat(str, ';');
- s.shadowDepthY = GetFloat(str, ';');
- for (size_t i = 0; i < 4; i++) {
- s.colors[i] = (COLORREF)GetInt(str, ';');
- }
- for (size_t i = 0; i < 4; i++) {
- s.alpha[i] = GetInt(str, ';');
- }
- s.charSet = GetInt(str, ';');
- s.fontName = WToT(GetStr(str, ';'));
- s.fontSize = GetFloat(str, ';');
- s.fontScaleX = GetFloat(str, ';');
- s.fontScaleY = GetFloat(str, ';');
- s.fontSpacing = GetFloat(str, ';');
- s.fontWeight = GetInt(str, ';');
- s.fItalic = GetInt(str, ';');
- s.fUnderline = GetInt(str, ';');
- s.fStrikeOut = GetInt(str, ';');
- s.fBlur = GetInt(str, ';');
- s.fGaussianBlur = GetFloat(str, ';');
- s.fontAngleZ = GetFloat(str, ';');
- s.fontAngleX = GetFloat(str, ';');
- s.fontAngleY = GetFloat(str, ';');
- s.relativeTo = GetInt(str, ';');
- }
- } catch (...) {
- s.SetDefault();
- }
-
- return s;
+ s.SetDefault();
+
+ try {
+ CStringW str = TToW(style);
+ if (str.Find(';') >= 0) {
+ s.marginRect.left = GetInt(str, ';');
+ s.marginRect.right = GetInt(str, ';');
+ s.marginRect.top = GetInt(str, ';');
+ s.marginRect.bottom = GetInt(str, ';');
+ s.scrAlignment = GetInt(str, ';');
+ s.borderStyle = GetInt(str, ';');
+ s.outlineWidthX = GetFloat(str, ';');
+ s.outlineWidthY = GetFloat(str, ';');
+ s.shadowDepthX = GetFloat(str, ';');
+ s.shadowDepthY = GetFloat(str, ';');
+ for (size_t i = 0; i < 4; i++) {
+ s.colors[i] = (COLORREF)GetInt(str, ';');
+ }
+ for (size_t i = 0; i < 4; i++) {
+ s.alpha[i] = GetInt(str, ';');
+ }
+ s.charSet = GetInt(str, ';');
+ s.fontName = WToT(GetStr(str, ';'));
+ s.fontSize = GetFloat(str, ';');
+ s.fontScaleX = GetFloat(str, ';');
+ s.fontScaleY = GetFloat(str, ';');
+ s.fontSpacing = GetFloat(str, ';');
+ s.fontWeight = GetInt(str, ';');
+ s.fItalic = GetInt(str, ';');
+ s.fUnderline = GetInt(str, ';');
+ s.fStrikeOut = GetInt(str, ';');
+ s.fBlur = GetInt(str, ';');
+ s.fGaussianBlur = GetFloat(str, ';');
+ s.fontAngleZ = GetFloat(str, ';');
+ s.fontAngleX = GetFloat(str, ';');
+ s.fontAngleY = GetFloat(str, ';');
+ s.relativeTo = GetInt(str, ';');
+ }
+ } catch (...) {
+ s.SetDefault();
+ }
+
+ return s;
}
static bool OpenRealText(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
{
- wstring szFile;
+ wstring szFile;
- CStringW buff;
- while (file->ReadString(buff)) {
- buff.Trim();
- if (buff.IsEmpty()) {
- continue;
- }
+ CStringW buff;
+ while (file->ReadString(buff)) {
+ buff.Trim();
+ if (buff.IsEmpty()) {
+ continue;
+ }
- szFile += CStringW(_T("\n")) + buff.GetBuffer();
- }
+ szFile += CStringW(_T("\n")) + buff.GetBuffer();
+ }
- CRealTextParser RealTextParser;
- if (!RealTextParser.ParseRealText(szFile)) {
- return false;
- }
+ CRealTextParser RealTextParser;
+ if (!RealTextParser.ParseRealText(szFile)) {
+ return false;
+ }
- CRealTextParser::Subtitles crRealText = RealTextParser.GetParsedSubtitles();
+ CRealTextParser::Subtitles crRealText = RealTextParser.GetParsedSubtitles();
- for (map<pair<int, int>, wstring>::const_iterator i = crRealText.m_mapLines.begin();
- i != crRealText.m_mapLines.end();
- ++i) {
- ret.Add(
- SubRipper2SSA(i->second.c_str(), CharSet),
- file->IsUnicode(),
- i->first.first,
- i->first.second);
- }
+ for (map<pair<int, int>, wstring>::const_iterator i = crRealText.m_mapLines.begin();
+ i != crRealText.m_mapLines.end();
+ ++i) {
+ ret.Add(
+ SubRipper2SSA(i->second.c_str(), CharSet),
+ file->IsUnicode(),
+ i->first.first,
+ i->first.second);
+ }
- // std::wofstream wofsOut(L"c:/zzz.srt");
- // RealTextParser.OutputSRT(wofsOut);
+ // std::wofstream wofsOut(L"c:/zzz.srt");
+ // RealTextParser.OutputSRT(wofsOut);
- return (ret.GetCount() > 0);
+ return (ret.GetCount() > 0);
}
diff --git a/src/Subtitles/STS.h b/src/Subtitles/STS.h
index bb905eb89..e65534188 100644
--- a/src/Subtitles/STS.h
+++ b/src/Subtitles/STS.h
@@ -33,177 +33,177 @@ typedef enum {TIME, FRAME} tmode; // the meaning of STSEntry::start/end
class STSStyle
{
public:
- CRect marginRect; // measured from the sides
- int scrAlignment; // 1 - 9: as on the numpad, 0: default
- int borderStyle; // 0: outline, 1: opaque box
- double outlineWidthX, outlineWidthY;
- double shadowDepthX, shadowDepthY;
- COLORREF colors[4]; // usually: {primary, secondary, outline/background, shadow}
- BYTE alpha[4];
- int charSet;
- CString fontName;
- double fontSize; // height
- double fontScaleX, fontScaleY; // percent
- double fontSpacing; // +/- pixels
- LONG fontWeight;
- BYTE fItalic;
- BYTE fUnderline;
- BYTE fStrikeOut;
- int fBlur;
- double fGaussianBlur;
- double fontAngleZ, fontAngleX, fontAngleY;
- double fontShiftX, fontShiftY;
- int relativeTo; // 0: window, 1: video, 2: undefined (~window)
-
- STSStyle();
-
- void SetDefault();
-
- bool operator == (STSStyle& s);
- bool IsFontStyleEqual(STSStyle& s);
-
- STSStyle& operator = (LOGFONT& lf);
-
- friend LOGFONTA& operator <<= (LOGFONTA& lfa, STSStyle& s);
- friend LOGFONTW& operator <<= (LOGFONTW& lfw, STSStyle& s);
-
- friend CString& operator <<= (CString& style, STSStyle& s);
- friend STSStyle& operator <<= (STSStyle& s, CString& style);
+ CRect marginRect; // measured from the sides
+ int scrAlignment; // 1 - 9: as on the numpad, 0: default
+ int borderStyle; // 0: outline, 1: opaque box
+ double outlineWidthX, outlineWidthY;
+ double shadowDepthX, shadowDepthY;
+ COLORREF colors[4]; // usually: {primary, secondary, outline/background, shadow}
+ BYTE alpha[4];
+ int charSet;
+ CString fontName;
+ double fontSize; // height
+ double fontScaleX, fontScaleY; // percent
+ double fontSpacing; // +/- pixels
+ LONG fontWeight;
+ BYTE fItalic;
+ BYTE fUnderline;
+ BYTE fStrikeOut;
+ int fBlur;
+ double fGaussianBlur;
+ double fontAngleZ, fontAngleX, fontAngleY;
+ double fontShiftX, fontShiftY;
+ int relativeTo; // 0: window, 1: video, 2: undefined (~window)
+
+ STSStyle();
+
+ void SetDefault();
+
+ bool operator == (STSStyle& s);
+ bool IsFontStyleEqual(STSStyle& s);
+
+ STSStyle& operator = (LOGFONT& lf);
+
+ friend LOGFONTA& operator <<= (LOGFONTA& lfa, STSStyle& s);
+ friend LOGFONTW& operator <<= (LOGFONTW& lfw, STSStyle& s);
+
+ friend CString& operator <<= (CString& style, STSStyle& s);
+ friend STSStyle& operator <<= (STSStyle& s, CString& style);
};
class CSTSStyleMap : public CAtlMap<CString, STSStyle*, CStringElementTraits<CString> >
{
public:
- CSTSStyleMap() {}
- virtual ~CSTSStyleMap() {
- Free();
- }
- void Free();
+ CSTSStyleMap() {}
+ virtual ~CSTSStyleMap() {
+ Free();
+ }
+ void Free();
};
typedef struct {
- CStringW str;
- bool fUnicode;
- CString style, actor, effect;
- CRect marginRect;
- int layer;
- int start, end;
- int readorder;
+ CStringW str;
+ bool fUnicode;
+ CString style, actor, effect;
+ CRect marginRect;
+ int layer;
+ int start, end;
+ int readorder;
} STSEntry;
class STSSegment
{
public:
- int start, end;
- CAtlArray<int> subs;
-
- STSSegment() {};
- STSSegment(int s, int e) {
- start = s;
- end = e;
- }
- STSSegment(const STSSegment& stss) {
- *this = stss;
- }
- STSSegment& operator = (const STSSegment& stss) {
- if (this != &stss) {
- start = stss.start;
- end = stss.end;
- subs.Copy(stss.subs);
- }
- return *this;
- }
+ int start, end;
+ CAtlArray<int> subs;
+
+ STSSegment() {};
+ STSSegment(int s, int e) {
+ start = s;
+ end = e;
+ }
+ STSSegment(const STSSegment& stss) {
+ *this = stss;
+ }
+ STSSegment& operator = (const STSSegment& stss) {
+ if (this != &stss) {
+ start = stss.start;
+ end = stss.end;
+ subs.Copy(stss.subs);
+ }
+ return *this;
+ }
};
class CSimpleTextSubtitle : public CAtlArray<STSEntry>
{
- friend class CSubtitleEditorDlg;
+ friend class CSubtitleEditorDlg;
protected:
- CAtlArray<STSSegment> m_segments;
- virtual void OnChanged() {}
+ CAtlArray<STSSegment> m_segments;
+ virtual void OnChanged() {}
public:
- CString m_name;
- LCID m_lcid;
- exttype m_exttype;
- tmode m_mode;
- CTextFile::enc m_encoding;
- CString m_path;
+ CString m_name;
+ LCID m_lcid;
+ exttype m_exttype;
+ tmode m_mode;
+ CTextFile::enc m_encoding;
+ CString m_path;
- CSize m_dstScreenSize;
- int m_defaultWrapStyle;
- int m_collisions;
- bool m_fScaledBAS;
+ CSize m_dstScreenSize;
+ int m_defaultWrapStyle;
+ int m_collisions;
+ bool m_fScaledBAS;
- bool m_fUsingAutoGeneratedDefaultStyle;
+ bool m_fUsingAutoGeneratedDefaultStyle;
- CSTSStyleMap m_styles;
+ CSTSStyleMap m_styles;
- enum EPARCompensationType {
- EPCTDisabled = 0,
- EPCTDownscale = 1,
- EPCTUpscale = 2,
- EPCTAccurateSize = 3
- };
+ enum EPARCompensationType {
+ EPCTDisabled = 0,
+ EPCTDownscale = 1,
+ EPCTUpscale = 2,
+ EPCTAccurateSize = 3
+ };
- EPARCompensationType m_ePARCompensationType;
- double m_dPARCompensation;
+ EPARCompensationType m_ePARCompensationType;
+ double m_dPARCompensation;
public:
- CSimpleTextSubtitle();
- virtual ~CSimpleTextSubtitle();
+ CSimpleTextSubtitle();
+ virtual ~CSimpleTextSubtitle();
- virtual void Copy(CSimpleTextSubtitle& sts);
- virtual void Empty();
+ virtual void Copy(CSimpleTextSubtitle& sts);
+ virtual void Empty();
- void Sort(bool fRestoreReadorder = false);
- void CreateSegments();
+ void Sort(bool fRestoreReadorder = false);
+ void CreateSegments();
- void Append(CSimpleTextSubtitle& sts, int timeoff = -1);
+ void Append(CSimpleTextSubtitle& sts, int timeoff = -1);
- bool Open(CString fn, int CharSet, CString name = _T(""));
- bool Open(CTextFile* f, int CharSet, CString name);
- bool Open(BYTE* data, int len, int CharSet, CString name);
- bool SaveAs(CString fn, exttype et, double fps = -1, CTextFile::enc = CTextFile::ASCII);
+ bool Open(CString fn, int CharSet, CString name = _T(""));
+ bool Open(CTextFile* f, int CharSet, CString name);
+ bool Open(BYTE* data, int len, int CharSet, CString name);
+ bool SaveAs(CString fn, exttype et, double fps = -1, CTextFile::enc = CTextFile::ASCII);
- void Add(CStringW str, bool fUnicode, int start, int end, CString style = _T("Default"), CString actor = _T(""), CString effect = _T(""), CRect marginRect = CRect(0,0,0,0), int layer = 0, int readorder = -1);
- STSStyle* CreateDefaultStyle(int CharSet);
- void ChangeUnknownStylesToDefault();
- void AddStyle(CString name, STSStyle* style); // style will be stored and freed in Empty() later
- bool CopyStyles(const CSTSStyleMap& styles, bool fAppend = false);
+ void Add(CStringW str, bool fUnicode, int start, int end, CString style = _T("Default"), CString actor = _T(""), CString effect = _T(""), CRect marginRect = CRect(0, 0, 0, 0), int layer = 0, int readorder = -1);
+ STSStyle* CreateDefaultStyle(int CharSet);
+ void ChangeUnknownStylesToDefault();
+ void AddStyle(CString name, STSStyle* style); // style will be stored and freed in Empty() later
+ bool CopyStyles(const CSTSStyleMap& styles, bool fAppend = false);
- bool SetDefaultStyle(STSStyle& s);
- bool GetDefaultStyle(STSStyle& s);
+ bool SetDefaultStyle(STSStyle& s);
+ bool GetDefaultStyle(STSStyle& s);
- void ConvertToTimeBased(double fps);
- void ConvertToFrameBased(double fps);
+ void ConvertToTimeBased(double fps);
+ void ConvertToFrameBased(double fps);
- int TranslateStart(int i, double fps);
- int TranslateEnd(int i, double fps);
- int SearchSub(int t, double fps);
+ int TranslateStart(int i, double fps);
+ int TranslateEnd(int i, double fps);
+ int SearchSub(int t, double fps);
- int TranslateSegmentStart(int i, double fps);
- int TranslateSegmentEnd(int i, double fps);
- const STSSegment* SearchSubs(int t, double fps, /*[out]*/ int* iSegment = NULL, int* nSegments = NULL);
- const STSSegment* GetSegment(int iSegment) {
- return iSegment >= 0 && iSegment < (int)m_segments.GetCount() ? &m_segments[iSegment] : NULL;
- }
+ int TranslateSegmentStart(int i, double fps);
+ int TranslateSegmentEnd(int i, double fps);
+ const STSSegment* SearchSubs(int t, double fps, /*[out]*/ int* iSegment = NULL, int* nSegments = NULL);
+ const STSSegment* GetSegment(int iSegment) {
+ return iSegment >= 0 && iSegment < (int)m_segments.GetCount() ? &m_segments[iSegment] : NULL;
+ }
- STSStyle* GetStyle(int i);
- bool GetStyle(int i, STSStyle& stss);
- int GetCharSet(int i);
- bool IsEntryUnicode(int i);
- void ConvertUnicode(int i, bool fUnicode);
+ STSStyle* GetStyle(int i);
+ bool GetStyle(int i, STSStyle& stss);
+ int GetCharSet(int i);
+ bool IsEntryUnicode(int i);
+ void ConvertUnicode(int i, bool fUnicode);
- CStringA GetStrA(int i, bool fSSA = false);
- CStringW GetStrW(int i, bool fSSA = false);
- CStringW GetStrWA(int i, bool fSSA = false);
+ CStringA GetStrA(int i, bool fSSA = false);
+ CStringW GetStrW(int i, bool fSSA = false);
+ CStringW GetStrWA(int i, bool fSSA = false);
#define GetStr GetStrW
- void SetStr(int i, CStringA str, bool fUnicode /* ignored */);
- void SetStr(int i, CStringW str, bool fUnicode);
+ void SetStr(int i, CStringA str, bool fUnicode /* ignored */);
+ void SetStr(int i, CStringW str, bool fUnicode);
};
extern BYTE CharSetList[];
@@ -213,7 +213,7 @@ extern int CharSetLen;
class CHtmlColorMap : public CAtlMap<CString, DWORD, CStringElementTraits<CString> >
{
public:
- CHtmlColorMap();
+ CHtmlColorMap();
};
extern CHtmlColorMap g_colors;
diff --git a/src/Subtitles/SeparableFilter.h b/src/Subtitles/SeparableFilter.h
index 748fe20b6..e9537dea3 100644
--- a/src/Subtitles/SeparableFilter.h
+++ b/src/Subtitles/SeparableFilter.h
@@ -32,38 +32,38 @@
// Filter an image in horizontal direction with a one-dimensional filter
// PixelWidth is the distance in bytes between pixels
template<ptrdiff_t PixelDist>
-void SeparableFilterX(unsigned char *src, unsigned char *dst, int width, int height, ptrdiff_t stride, int *kernel, int kernel_size, int divisor)
+void SeparableFilterX(unsigned char* src, unsigned char* dst, int width, int height, ptrdiff_t stride, int* kernel, int kernel_size, int divisor)
{
#ifdef _OPENMP
- #pragma omp parallel for
+ #pragma omp parallel for
#endif
- for (int y = 0; y < height; y++) {
- unsigned char *in = src + y*stride;
- unsigned char *out = dst + y*stride;
- for (int x = 0; x < width; x++) {
- int accum = 0;
- for (int k = 0; k < kernel_size; k++) {
- int xofs = k - kernel_size/2;
- if (x+xofs < 0) {
- xofs += width;
- }
- if (x+xofs >= width) {
- xofs -= width;
- }
- accum += (int)(in[xofs*PixelDist] * kernel[k]);
- }
- accum /= divisor;
- if (accum > 255) {
- accum = 255;
- }
- if (accum < 0) {
- accum = 0;
- }
- *out = (unsigned char)accum;
- in+=PixelDist;
- out+=PixelDist;
- }
- }
+ for (int y = 0; y < height; y++) {
+ unsigned char* in = src + y * stride;
+ unsigned char* out = dst + y * stride;
+ for (int x = 0; x < width; x++) {
+ int accum = 0;
+ for (int k = 0; k < kernel_size; k++) {
+ int xofs = k - kernel_size / 2;
+ if (x + xofs < 0) {
+ xofs += width;
+ }
+ if (x + xofs >= width) {
+ xofs -= width;
+ }
+ accum += (int)(in[xofs * PixelDist] * kernel[k]);
+ }
+ accum /= divisor;
+ if (accum > 255) {
+ accum = 255;
+ }
+ if (accum < 0) {
+ accum = 0;
+ }
+ *out = (unsigned char)accum;
+ in += PixelDist;
+ out += PixelDist;
+ }
+ }
}
@@ -72,74 +72,74 @@ void SeparableFilterX(unsigned char *src, unsigned char *dst, int width, int hei
// filtering once vertically will automatically catch all channels.
// (Width must be multiplied by pixel width for that to happen though.)
template<ptrdiff_t PixelDist>
-void SeparableFilterY(unsigned char *src, unsigned char *dst, int width, int height, ptrdiff_t stride, int *kernel, int kernel_size, int divisor)
+void SeparableFilterY(unsigned char* src, unsigned char* dst, int width, int height, ptrdiff_t stride, int* kernel, int kernel_size, int divisor)
{
- width *= PixelDist;
+ width *= PixelDist;
#ifdef _OPENMP
- #pragma omp parallel for
+ #pragma omp parallel for
#endif
- for (int x = 0; x < width; x+=PixelDist) {
- unsigned char *in = src + x;
- unsigned char *out = dst + x;
- for (int y = 0; y < height; y++) {
- int accum = 0;
- for (int k = 0; k < kernel_size; k++) {
- int yofs = k - kernel_size/2;
- if (y+yofs < 0) {
- yofs += height;
- }
- if (y+yofs >= height) {
- yofs -= height;
- }
- accum += (int)(in[yofs*stride] * kernel[k]);
- }
- accum /= divisor;
- if (accum > 255) {
- accum = 255;
- }
- if (accum < 0) {
- accum = 0;
- }
- *out = (unsigned char)accum;
- in += stride;
- out += stride;
- }
- }
+ for (int x = 0; x < width; x += PixelDist) {
+ unsigned char* in = src + x;
+ unsigned char* out = dst + x;
+ for (int y = 0; y < height; y++) {
+ int accum = 0;
+ for (int k = 0; k < kernel_size; k++) {
+ int yofs = k - kernel_size / 2;
+ if (y + yofs < 0) {
+ yofs += height;
+ }
+ if (y + yofs >= height) {
+ yofs -= height;
+ }
+ accum += (int)(in[yofs * stride] * kernel[k]);
+ }
+ accum /= divisor;
+ if (accum > 255) {
+ accum = 255;
+ }
+ if (accum < 0) {
+ accum = 0;
+ }
+ *out = (unsigned char)accum;
+ in += stride;
+ out += stride;
+ }
+ }
}
static inline double NormalDist(double sigma, double x)
{
- if (sigma <= 0 && x == 0) {
- return 1;
- } else if (sigma <= 0) {
- return 0;
- } else {
- return exp(-(x*x)/(2*sigma*sigma)) / (sigma * sqrt(2*3.1415926535));
- }
+ if (sigma <= 0 && x == 0) {
+ return 1;
+ } else if (sigma <= 0) {
+ return 0;
+ } else {
+ return exp(-(x * x) / (2 * sigma * sigma)) / (sigma * sqrt(2 * 3.1415926535));
+ }
}
struct GaussianKernel {
- int *kernel;
- int width;
- int divisor;
- inline GaussianKernel(double sigma) {
- width = (int)(sigma*3 + 0.5) | 1; // binary-or with 1 to make sure the number is odd
- if (width < 3) {
- width = 3;
- }
- kernel = DNew int[width];
- kernel[width/2] = (int)(NormalDist(sigma, 0) * 255);
- divisor = kernel[width/2];
- for (int x = width/2-1; x >= 0; x--) {
- int val = (int)(NormalDist(sigma, width/2-x) * 255 + 0.5);
- divisor += val*2;
- kernel[x] = val;
- kernel[width - x - 1] = val;
- }
- }
- inline ~GaussianKernel() {
- delete[] kernel;
- }
+ int* kernel;
+ int width;
+ int divisor;
+ inline GaussianKernel(double sigma) {
+ width = (int)(sigma * 3 + 0.5) | 1; // binary-or with 1 to make sure the number is odd
+ if (width < 3) {
+ width = 3;
+ }
+ kernel = DNew int[width];
+ kernel[width / 2] = (int)(NormalDist(sigma, 0) * 255);
+ divisor = kernel[width / 2];
+ for (int x = width / 2 - 1; x >= 0; x--) {
+ int val = (int)(NormalDist(sigma, width / 2 - x) * 255 + 0.5);
+ divisor += val * 2;
+ kernel[x] = val;
+ kernel[width - x - 1] = val;
+ }
+ }
+ inline ~GaussianKernel() {
+ delete[] kernel;
+ }
};
diff --git a/src/Subtitles/SubtitleInputPin.cpp b/src/Subtitles/SubtitleInputPin.cpp
index ca2d7b3f1..2f9e16a7b 100644
--- a/src/Subtitles/SubtitleInputPin.cpp
+++ b/src/Subtitles/SubtitleInputPin.cpp
@@ -52,312 +52,312 @@
#define __GAB1_RAWTEXTSUBTITLE__ 4
CSubtitleInputPin::CSubtitleInputPin(CBaseFilter* pFilter, CCritSec* pLock, CCritSec* pSubLock, HRESULT* phr)
- : CBaseInputPin(NAME("CSubtitleInputPin"), pFilter, pLock, phr, L"Input")
- , m_pSubLock(pSubLock)
+ : CBaseInputPin(NAME("CSubtitleInputPin"), pFilter, pLock, phr, L"Input")
+ , m_pSubLock(pSubLock)
{
- m_bCanReconnectWhenActive = TRUE;
+ m_bCanReconnectWhenActive = TRUE;
}
HRESULT CSubtitleInputPin::CheckMediaType(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Text && (pmt->subtype == MEDIASUBTYPE_NULL || pmt->subtype == FOURCCMap((DWORD)0))
- || pmt->majortype == MEDIATYPE_Subtitle && pmt->subtype == MEDIASUBTYPE_UTF8
- || pmt->majortype == MEDIATYPE_Subtitle && (pmt->subtype == MEDIASUBTYPE_SSA || pmt->subtype == MEDIASUBTYPE_ASS || pmt->subtype == MEDIASUBTYPE_ASS2)
- || pmt->majortype == MEDIATYPE_Subtitle && (pmt->subtype == MEDIASUBTYPE_VOBSUB)
- || IsHdmvSub(pmt)
- ? S_OK
- : E_FAIL;
+ return pmt->majortype == MEDIATYPE_Text && (pmt->subtype == MEDIASUBTYPE_NULL || pmt->subtype == FOURCCMap((DWORD)0))
+ || pmt->majortype == MEDIATYPE_Subtitle && pmt->subtype == MEDIASUBTYPE_UTF8
+ || pmt->majortype == MEDIATYPE_Subtitle && (pmt->subtype == MEDIASUBTYPE_SSA || pmt->subtype == MEDIASUBTYPE_ASS || pmt->subtype == MEDIASUBTYPE_ASS2)
+ || pmt->majortype == MEDIATYPE_Subtitle && (pmt->subtype == MEDIASUBTYPE_VOBSUB)
+ || IsHdmvSub(pmt)
+ ? S_OK
+ : E_FAIL;
}
HRESULT CSubtitleInputPin::CompleteConnect(IPin* pReceivePin)
{
- if (m_mt.majortype == MEDIATYPE_Text) {
- if (!(m_pSubStream = DNew CRenderedTextSubtitle(m_pSubLock))) {
- return E_FAIL;
- }
- CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
- pRTS->m_name = CString(GetPinName(pReceivePin)) + _T(" (embeded)");
- pRTS->m_dstScreenSize = CSize(384, 288);
- pRTS->CreateDefaultStyle(DEFAULT_CHARSET);
- } else if (m_mt.majortype == MEDIATYPE_Subtitle) {
- SUBTITLEINFO* psi = (SUBTITLEINFO*)m_mt.pbFormat;
- DWORD dwOffset = 0;
- CString name;
- LCID lcid = 0;
-
- if (psi != NULL) {
- dwOffset = psi->dwOffset;
-
- name = ISO6392ToLanguage(psi->IsoLang);
- lcid = ISO6392ToLcid(psi->IsoLang);
-
- if (wcslen(psi->TrackName) > 0) {
- name += (!name.IsEmpty() ? _T(", ") : _T("")) + CString(psi->TrackName);
- }
- if (name.IsEmpty()) {
- name = _T("Unknown");
- }
- }
-
- name.Replace(_T(""), _T(""));
- name.Replace(_T(""), _T(""));
-
- if (m_mt.subtype == MEDIASUBTYPE_UTF8
- /*|| m_mt.subtype == MEDIASUBTYPE_USF*/
- || m_mt.subtype == MEDIASUBTYPE_SSA
- || m_mt.subtype == MEDIASUBTYPE_ASS
- || m_mt.subtype == MEDIASUBTYPE_ASS2) {
- if (!(m_pSubStream = DNew CRenderedTextSubtitle(m_pSubLock))) {
- return E_FAIL;
- }
- CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
- pRTS->m_name = name;
- pRTS->m_lcid = lcid;
- pRTS->m_dstScreenSize = CSize(384, 288);
- pRTS->CreateDefaultStyle(DEFAULT_CHARSET);
-
- if (dwOffset > 0 && m_mt.cbFormat - dwOffset > 0) {
- CMediaType mt = m_mt;
- if (mt.pbFormat[dwOffset+0] != 0xef
- && mt.pbFormat[dwOffset+1] != 0xbb
- && mt.pbFormat[dwOffset+2] != 0xfb) {
- dwOffset -= 3;
- mt.pbFormat[dwOffset+0] = 0xef;
- mt.pbFormat[dwOffset+1] = 0xbb;
- mt.pbFormat[dwOffset+2] = 0xbf;
- }
-
- pRTS->Open(mt.pbFormat + dwOffset, mt.cbFormat - dwOffset, DEFAULT_CHARSET, pRTS->m_name);
- }
- } else if (m_mt.subtype == MEDIASUBTYPE_VOBSUB) {
- if (!(m_pSubStream = DNew CVobSubStream(m_pSubLock))) {
- return E_FAIL;
- }
- CVobSubStream* pVSS = (CVobSubStream*)(ISubStream*)m_pSubStream;
- pVSS->Open(name, m_mt.pbFormat + dwOffset, m_mt.cbFormat - dwOffset);
- } else if (IsHdmvSub(&m_mt)) {
- if (!(m_pSubStream = DNew CRenderedHdmvSubtitle(m_pSubLock, (m_mt.subtype == MEDIASUBTYPE_DVB_SUBTITLES) ? ST_DVB : ST_HDMV, name, lcid))) {
- return E_FAIL;
- }
- }
- }
-
- AddSubStream(m_pSubStream);
-
- return __super::CompleteConnect(pReceivePin);
+ if (m_mt.majortype == MEDIATYPE_Text) {
+ if (!(m_pSubStream = DNew CRenderedTextSubtitle(m_pSubLock))) {
+ return E_FAIL;
+ }
+ CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
+ pRTS->m_name = CString(GetPinName(pReceivePin)) + _T(" (embeded)");
+ pRTS->m_dstScreenSize = CSize(384, 288);
+ pRTS->CreateDefaultStyle(DEFAULT_CHARSET);
+ } else if (m_mt.majortype == MEDIATYPE_Subtitle) {
+ SUBTITLEINFO* psi = (SUBTITLEINFO*)m_mt.pbFormat;
+ DWORD dwOffset = 0;
+ CString name;
+ LCID lcid = 0;
+
+ if (psi != NULL) {
+ dwOffset = psi->dwOffset;
+
+ name = ISO6392ToLanguage(psi->IsoLang);
+ lcid = ISO6392ToLcid(psi->IsoLang);
+
+ if (wcslen(psi->TrackName) > 0) {
+ name += (!name.IsEmpty() ? _T(", ") : _T("")) + CString(psi->TrackName);
+ }
+ if (name.IsEmpty()) {
+ name = _T("Unknown");
+ }
+ }
+
+ name.Replace(_T(""), _T(""));
+ name.Replace(_T(""), _T(""));
+
+ if (m_mt.subtype == MEDIASUBTYPE_UTF8
+ /*|| m_mt.subtype == MEDIASUBTYPE_USF*/
+ || m_mt.subtype == MEDIASUBTYPE_SSA
+ || m_mt.subtype == MEDIASUBTYPE_ASS
+ || m_mt.subtype == MEDIASUBTYPE_ASS2) {
+ if (!(m_pSubStream = DNew CRenderedTextSubtitle(m_pSubLock))) {
+ return E_FAIL;
+ }
+ CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
+ pRTS->m_name = name;
+ pRTS->m_lcid = lcid;
+ pRTS->m_dstScreenSize = CSize(384, 288);
+ pRTS->CreateDefaultStyle(DEFAULT_CHARSET);
+
+ if (dwOffset > 0 && m_mt.cbFormat - dwOffset > 0) {
+ CMediaType mt = m_mt;
+ if (mt.pbFormat[dwOffset + 0] != 0xef
+ && mt.pbFormat[dwOffset + 1] != 0xbb
+ && mt.pbFormat[dwOffset + 2] != 0xfb) {
+ dwOffset -= 3;
+ mt.pbFormat[dwOffset + 0] = 0xef;
+ mt.pbFormat[dwOffset + 1] = 0xbb;
+ mt.pbFormat[dwOffset + 2] = 0xbf;
+ }
+
+ pRTS->Open(mt.pbFormat + dwOffset, mt.cbFormat - dwOffset, DEFAULT_CHARSET, pRTS->m_name);
+ }
+ } else if (m_mt.subtype == MEDIASUBTYPE_VOBSUB) {
+ if (!(m_pSubStream = DNew CVobSubStream(m_pSubLock))) {
+ return E_FAIL;
+ }
+ CVobSubStream* pVSS = (CVobSubStream*)(ISubStream*)m_pSubStream;
+ pVSS->Open(name, m_mt.pbFormat + dwOffset, m_mt.cbFormat - dwOffset);
+ } else if (IsHdmvSub(&m_mt)) {
+ if (!(m_pSubStream = DNew CRenderedHdmvSubtitle(m_pSubLock, (m_mt.subtype == MEDIASUBTYPE_DVB_SUBTITLES) ? ST_DVB : ST_HDMV, name, lcid))) {
+ return E_FAIL;
+ }
+ }
+ }
+
+ AddSubStream(m_pSubStream);
+
+ return __super::CompleteConnect(pReceivePin);
}
HRESULT CSubtitleInputPin::BreakConnect()
{
- RemoveSubStream(m_pSubStream);
- m_pSubStream = NULL;
+ RemoveSubStream(m_pSubStream);
+ m_pSubStream = NULL;
- ASSERT(IsStopped());
+ ASSERT(IsStopped());
- return __super::BreakConnect();
+ return __super::BreakConnect();
}
STDMETHODIMP CSubtitleInputPin::ReceiveConnection(IPin* pConnector, const AM_MEDIA_TYPE* pmt)
{
- if (m_Connected) {
- RemoveSubStream(m_pSubStream);
- m_pSubStream = NULL;
+ if (m_Connected) {
+ RemoveSubStream(m_pSubStream);
+ m_pSubStream = NULL;
- m_Connected->Release();
- m_Connected = NULL;
- }
+ m_Connected->Release();
+ m_Connected = NULL;
+ }
- return __super::ReceiveConnection(pConnector, pmt);
+ return __super::ReceiveConnection(pConnector, pmt);
}
STDMETHODIMP CSubtitleInputPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- CAutoLock cAutoLock(&m_csReceive);
-
- if (m_mt.majortype == MEDIATYPE_Text
- || m_mt.majortype == MEDIATYPE_Subtitle
- && (m_mt.subtype == MEDIASUBTYPE_UTF8
- /*|| m_mt.subtype == MEDIASUBTYPE_USF*/
- || m_mt.subtype == MEDIASUBTYPE_SSA
- || m_mt.subtype == MEDIASUBTYPE_ASS
- || m_mt.subtype == MEDIASUBTYPE_ASS2)) {
- CAutoLock cAutoLock(m_pSubLock);
- CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
- pRTS->RemoveAll();
- pRTS->CreateSegments();
- } else if (m_mt.majortype == MEDIATYPE_Subtitle && (m_mt.subtype == MEDIASUBTYPE_VOBSUB)) {
- CAutoLock cAutoLock(m_pSubLock);
- CVobSubStream* pVSS = (CVobSubStream*)(ISubStream*)m_pSubStream;
- pVSS->RemoveAll();
- } else if (IsHdmvSub(&m_mt)) {
- CAutoLock cAutoLock(m_pSubLock);
- CRenderedHdmvSubtitle* pHdmvSubtitle = (CRenderedHdmvSubtitle*)(ISubStream*)m_pSubStream;
- pHdmvSubtitle->NewSegment (tStart, tStop, dRate);
- }
-
- return __super::NewSegment(tStart, tStop, dRate);
+ CAutoLock cAutoLock(&m_csReceive);
+
+ if (m_mt.majortype == MEDIATYPE_Text
+ || m_mt.majortype == MEDIATYPE_Subtitle
+ && (m_mt.subtype == MEDIASUBTYPE_UTF8
+ /*|| m_mt.subtype == MEDIASUBTYPE_USF*/
+ || m_mt.subtype == MEDIASUBTYPE_SSA
+ || m_mt.subtype == MEDIASUBTYPE_ASS
+ || m_mt.subtype == MEDIASUBTYPE_ASS2)) {
+ CAutoLock cAutoLock(m_pSubLock);
+ CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
+ pRTS->RemoveAll();
+ pRTS->CreateSegments();
+ } else if (m_mt.majortype == MEDIATYPE_Subtitle && (m_mt.subtype == MEDIASUBTYPE_VOBSUB)) {
+ CAutoLock cAutoLock(m_pSubLock);
+ CVobSubStream* pVSS = (CVobSubStream*)(ISubStream*)m_pSubStream;
+ pVSS->RemoveAll();
+ } else if (IsHdmvSub(&m_mt)) {
+ CAutoLock cAutoLock(m_pSubLock);
+ CRenderedHdmvSubtitle* pHdmvSubtitle = (CRenderedHdmvSubtitle*)(ISubStream*)m_pSubStream;
+ pHdmvSubtitle->NewSegment(tStart, tStop, dRate);
+ }
+
+ return __super::NewSegment(tStart, tStop, dRate);
}
interface __declspec(uuid("D3D92BC3-713B-451B-9122-320095D51EA5"))
IMpeg2DemultiplexerTesting :
public IUnknown {
- STDMETHOD(GetMpeg2StreamType)(ULONG* plType) = NULL;
- STDMETHOD(toto)() = NULL;
+ STDMETHOD(GetMpeg2StreamType)(ULONG * plType) = NULL;
+ STDMETHOD(toto)() = NULL;
};
STDMETHODIMP CSubtitleInputPin::Receive(IMediaSample* pSample)
{
- HRESULT hr;
-
- hr = __super::Receive(pSample);
- if (FAILED(hr)) {
- return hr;
- }
-
- CAutoLock cAutoLock(&m_csReceive);
-
- REFERENCE_TIME tStart, tStop;
- pSample->GetTime(&tStart, &tStop);
- tStart += m_tStart;
- tStop += m_tStart;
-
- BYTE* pData = NULL;
- hr = pSample->GetPointer(&pData);
- if (FAILED(hr) || pData == NULL) {
- return hr;
- }
-
- int len = pSample->GetActualDataLength();
-
- bool fInvalidate = false;
-
- if (m_mt.majortype == MEDIATYPE_Text) {
- CAutoLock cAutoLock(m_pSubLock);
- CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
-
- if (!strncmp((char*)pData, __GAB1__, strlen(__GAB1__))) {
- char* ptr = (char*)&pData[strlen(__GAB1__)+1];
- char* end = (char*)&pData[len];
-
- while (ptr < end) {
- WORD tag = *((WORD*)(ptr));
- ptr += 2;
- WORD size = *((WORD*)(ptr));
- ptr += 2;
-
- if (tag == __GAB1_LANGUAGE__) {
- pRTS->m_name = CString(ptr);
- } else if (tag == __GAB1_ENTRY__) {
- pRTS->Add(AToW(&ptr[8]), false, *(int*)ptr, *(int*)(ptr+4));
- fInvalidate = true;
- } else if (tag == __GAB1_LANGUAGE_UNICODE__) {
- pRTS->m_name = (WCHAR*)ptr;
- } else if (tag == __GAB1_ENTRY_UNICODE__) {
- pRTS->Add((WCHAR*)(ptr+8), true, *(int*)ptr, *(int*)(ptr+4));
- fInvalidate = true;
- }
-
- ptr += size;
- }
- } else if (!strncmp((char*)pData, __GAB2__, strlen(__GAB2__))) {
- char* ptr = (char*)&pData[strlen(__GAB2__)+1];
- char* end = (char*)&pData[len];
-
- while (ptr < end) {
- WORD tag = *((WORD*)(ptr));
- ptr += 2;
- DWORD size = *((DWORD*)(ptr));
- ptr += 4;
-
- if (tag == __GAB1_LANGUAGE_UNICODE__) {
- pRTS->m_name = (WCHAR*)ptr;
- } else if (tag == __GAB1_RAWTEXTSUBTITLE__) {
- pRTS->Open((BYTE*)ptr, size, DEFAULT_CHARSET, pRTS->m_name);
- fInvalidate = true;
- }
-
- ptr += size;
- }
- } else if (pData != 0 && len > 1 && *pData != 0) {
- CStringA str((char*)pData, len);
-
- str.Replace("\r\n", "\n");
- str.Trim();
-
- if (!str.IsEmpty()) {
- pRTS->Add(AToW(str), false, (int)(tStart / 10000), (int)(tStop / 10000));
- fInvalidate = true;
- }
- }
- } else if (m_mt.majortype == MEDIATYPE_Subtitle) {
- CAutoLock cAutoLock(m_pSubLock);
-
- if (m_mt.subtype == MEDIASUBTYPE_UTF8) {
- CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
-
- CStringW str = UTF8To16(CStringA((LPCSTR)pData, len)).Trim();
- if (!str.IsEmpty()) {
- pRTS->Add(str, true, (int)(tStart / 10000), (int)(tStop / 10000));
- fInvalidate = true;
- }
- } else if (m_mt.subtype == MEDIASUBTYPE_SSA || m_mt.subtype == MEDIASUBTYPE_ASS || m_mt.subtype == MEDIASUBTYPE_ASS2) {
- CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
-
- CStringW str = UTF8To16(CStringA((LPCSTR)pData, len)).Trim();
- if (!str.IsEmpty()) {
- STSEntry stse;
-
- int fields = m_mt.subtype == MEDIASUBTYPE_ASS2 ? 10 : 9;
-
- CAtlList<CStringW> sl;
- Explode(str, sl, ',', fields);
- if (sl.GetCount() == (size_t)fields) {
- stse.readorder = wcstol(sl.RemoveHead(), NULL, 10);
- stse.layer = wcstol(sl.RemoveHead(), NULL, 10);
- stse.style = sl.RemoveHead();
- stse.actor = sl.RemoveHead();
- stse.marginRect.left = wcstol(sl.RemoveHead(), NULL, 10);
- stse.marginRect.right = wcstol(sl.RemoveHead(), NULL, 10);
- stse.marginRect.top = stse.marginRect.bottom = wcstol(sl.RemoveHead(), NULL, 10);
- if (fields == 10) {
- stse.marginRect.bottom = wcstol(sl.RemoveHead(), NULL, 10);
- }
- stse.effect = sl.RemoveHead();
- stse.str = sl.RemoveHead();
- }
-
- if (!stse.str.IsEmpty()) {
- pRTS->Add(stse.str, true, (int)(tStart / 10000), (int)(tStop / 10000),
- stse.style, stse.actor, stse.effect, stse.marginRect, stse.layer, stse.readorder);
- fInvalidate = true;
- }
- }
- } else if (m_mt.subtype == MEDIASUBTYPE_VOBSUB) {
- CVobSubStream* pVSS = (CVobSubStream*)(ISubStream*)m_pSubStream;
- pVSS->Add(tStart, tStop, pData, len);
- } else if (IsHdmvSub(&m_mt)) {
- CAutoLock cAutoLock(m_pSubLock);
- CRenderedHdmvSubtitle* pHdmvSubtitle = (CRenderedHdmvSubtitle*)(ISubStream*)m_pSubStream;
- pHdmvSubtitle->ParseSample (pSample);
- }
- }
-
- if (fInvalidate) {
- TRACE(_T("InvalidateSubtitle(%I64d, ..)\n"), tStart);
- // IMPORTANT: m_pSubLock must not be locked when calling this
- InvalidateSubtitle(tStart, m_pSubStream);
- }
-
- hr = S_OK;
-
- return hr;
+ HRESULT hr;
+
+ hr = __super::Receive(pSample);
+ if (FAILED(hr)) {
+ return hr;
+ }
+
+ CAutoLock cAutoLock(&m_csReceive);
+
+ REFERENCE_TIME tStart, tStop;
+ pSample->GetTime(&tStart, &tStop);
+ tStart += m_tStart;
+ tStop += m_tStart;
+
+ BYTE* pData = NULL;
+ hr = pSample->GetPointer(&pData);
+ if (FAILED(hr) || pData == NULL) {
+ return hr;
+ }
+
+ int len = pSample->GetActualDataLength();
+
+ bool fInvalidate = false;
+
+ if (m_mt.majortype == MEDIATYPE_Text) {
+ CAutoLock cAutoLock(m_pSubLock);
+ CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
+
+ if (!strncmp((char*)pData, __GAB1__, strlen(__GAB1__))) {
+ char* ptr = (char*)&pData[strlen(__GAB1__) + 1];
+ char* end = (char*)&pData[len];
+
+ while (ptr < end) {
+ WORD tag = *((WORD*)(ptr));
+ ptr += 2;
+ WORD size = *((WORD*)(ptr));
+ ptr += 2;
+
+ if (tag == __GAB1_LANGUAGE__) {
+ pRTS->m_name = CString(ptr);
+ } else if (tag == __GAB1_ENTRY__) {
+ pRTS->Add(AToW(&ptr[8]), false, *(int*)ptr, *(int*)(ptr + 4));
+ fInvalidate = true;
+ } else if (tag == __GAB1_LANGUAGE_UNICODE__) {
+ pRTS->m_name = (WCHAR*)ptr;
+ } else if (tag == __GAB1_ENTRY_UNICODE__) {
+ pRTS->Add((WCHAR*)(ptr + 8), true, *(int*)ptr, *(int*)(ptr + 4));
+ fInvalidate = true;
+ }
+
+ ptr += size;
+ }
+ } else if (!strncmp((char*)pData, __GAB2__, strlen(__GAB2__))) {
+ char* ptr = (char*)&pData[strlen(__GAB2__) + 1];
+ char* end = (char*)&pData[len];
+
+ while (ptr < end) {
+ WORD tag = *((WORD*)(ptr));
+ ptr += 2;
+ DWORD size = *((DWORD*)(ptr));
+ ptr += 4;
+
+ if (tag == __GAB1_LANGUAGE_UNICODE__) {
+ pRTS->m_name = (WCHAR*)ptr;
+ } else if (tag == __GAB1_RAWTEXTSUBTITLE__) {
+ pRTS->Open((BYTE*)ptr, size, DEFAULT_CHARSET, pRTS->m_name);
+ fInvalidate = true;
+ }
+
+ ptr += size;
+ }
+ } else if (pData != 0 && len > 1 && *pData != 0) {
+ CStringA str((char*)pData, len);
+
+ str.Replace("\r\n", "\n");
+ str.Trim();
+
+ if (!str.IsEmpty()) {
+ pRTS->Add(AToW(str), false, (int)(tStart / 10000), (int)(tStop / 10000));
+ fInvalidate = true;
+ }
+ }
+ } else if (m_mt.majortype == MEDIATYPE_Subtitle) {
+ CAutoLock cAutoLock(m_pSubLock);
+
+ if (m_mt.subtype == MEDIASUBTYPE_UTF8) {
+ CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
+
+ CStringW str = UTF8To16(CStringA((LPCSTR)pData, len)).Trim();
+ if (!str.IsEmpty()) {
+ pRTS->Add(str, true, (int)(tStart / 10000), (int)(tStop / 10000));
+ fInvalidate = true;
+ }
+ } else if (m_mt.subtype == MEDIASUBTYPE_SSA || m_mt.subtype == MEDIASUBTYPE_ASS || m_mt.subtype == MEDIASUBTYPE_ASS2) {
+ CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
+
+ CStringW str = UTF8To16(CStringA((LPCSTR)pData, len)).Trim();
+ if (!str.IsEmpty()) {
+ STSEntry stse;
+
+ int fields = m_mt.subtype == MEDIASUBTYPE_ASS2 ? 10 : 9;
+
+ CAtlList<CStringW> sl;
+ Explode(str, sl, ',', fields);
+ if (sl.GetCount() == (size_t)fields) {
+ stse.readorder = wcstol(sl.RemoveHead(), NULL, 10);
+ stse.layer = wcstol(sl.RemoveHead(), NULL, 10);
+ stse.style = sl.RemoveHead();
+ stse.actor = sl.RemoveHead();
+ stse.marginRect.left = wcstol(sl.RemoveHead(), NULL, 10);
+ stse.marginRect.right = wcstol(sl.RemoveHead(), NULL, 10);
+ stse.marginRect.top = stse.marginRect.bottom = wcstol(sl.RemoveHead(), NULL, 10);
+ if (fields == 10) {
+ stse.marginRect.bottom = wcstol(sl.RemoveHead(), NULL, 10);
+ }
+ stse.effect = sl.RemoveHead();
+ stse.str = sl.RemoveHead();
+ }
+
+ if (!stse.str.IsEmpty()) {
+ pRTS->Add(stse.str, true, (int)(tStart / 10000), (int)(tStop / 10000),
+ stse.style, stse.actor, stse.effect, stse.marginRect, stse.layer, stse.readorder);
+ fInvalidate = true;
+ }
+ }
+ } else if (m_mt.subtype == MEDIASUBTYPE_VOBSUB) {
+ CVobSubStream* pVSS = (CVobSubStream*)(ISubStream*)m_pSubStream;
+ pVSS->Add(tStart, tStop, pData, len);
+ } else if (IsHdmvSub(&m_mt)) {
+ CAutoLock cAutoLock(m_pSubLock);
+ CRenderedHdmvSubtitle* pHdmvSubtitle = (CRenderedHdmvSubtitle*)(ISubStream*)m_pSubStream;
+ pHdmvSubtitle->ParseSample(pSample);
+ }
+ }
+
+ if (fInvalidate) {
+ TRACE(_T("InvalidateSubtitle(%I64d, ..)\n"), tStart);
+ // IMPORTANT: m_pSubLock must not be locked when calling this
+ InvalidateSubtitle(tStart, m_pSubStream);
+ }
+
+ hr = S_OK;
+
+ return hr;
}
bool CSubtitleInputPin::IsHdmvSub(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Subtitle && (pmt->subtype == MEDIASUBTYPE_HDMVSUB || // Blu ray presentation graphics
- pmt->subtype == MEDIASUBTYPE_DVB_SUBTITLES || // DVB subtitles
- (pmt->subtype == MEDIASUBTYPE_NULL && pmt->formattype == FORMAT_SubtitleInfo)) // Workaround : support for Haali PGS
- ? true
- : false;
+ return pmt->majortype == MEDIATYPE_Subtitle && (pmt->subtype == MEDIASUBTYPE_HDMVSUB || // Blu ray presentation graphics
+ pmt->subtype == MEDIASUBTYPE_DVB_SUBTITLES || // DVB subtitles
+ (pmt->subtype == MEDIASUBTYPE_NULL && pmt->formattype == FORMAT_SubtitleInfo)) // Workaround : support for Haali PGS
+ ? true
+ : false;
} \ No newline at end of file
diff --git a/src/Subtitles/SubtitleInputPin.h b/src/Subtitles/SubtitleInputPin.h
index e56c28115..184df4b8e 100644
--- a/src/Subtitles/SubtitleInputPin.h
+++ b/src/Subtitles/SubtitleInputPin.h
@@ -31,28 +31,26 @@
class CSubtitleInputPin : public CBaseInputPin
{
- CCritSec m_csReceive;
+ CCritSec m_csReceive;
- CCritSec* m_pSubLock;
- CComPtr<ISubStream> m_pSubStream;
+ CCritSec* m_pSubLock;
+ CComPtr<ISubStream> m_pSubStream;
protected:
- virtual void AddSubStream(ISubStream* pSubStream) = 0;
- virtual void RemoveSubStream(ISubStream* pSubStream) = 0;
- virtual void InvalidateSubtitle(REFERENCE_TIME rtStart, ISubStream* pSubStream) = 0;
- bool IsHdmvSub(const CMediaType* pmt);
+ virtual void AddSubStream(ISubStream* pSubStream) = 0;
+ virtual void RemoveSubStream(ISubStream* pSubStream) = 0;
+ virtual void InvalidateSubtitle(REFERENCE_TIME rtStart, ISubStream* pSubStream) = 0;
+ bool IsHdmvSub(const CMediaType* pmt);
public:
- CSubtitleInputPin(CBaseFilter* pFilter, CCritSec* pLock, CCritSec* pSubLock, HRESULT* phr);
-
- HRESULT CheckMediaType(const CMediaType* pmt);
- HRESULT CompleteConnect(IPin* pReceivePin);
- HRESULT BreakConnect();
- STDMETHODIMP ReceiveConnection(IPin* pConnector, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
- STDMETHODIMP Receive(IMediaSample* pSample);
-
- ISubStream* GetSubStream() {
- return m_pSubStream;
- }
+ CSubtitleInputPin(CBaseFilter* pFilter, CCritSec* pLock, CCritSec* pSubLock, HRESULT* phr);
+
+ HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT CompleteConnect(IPin* pReceivePin);
+ HRESULT BreakConnect();
+ STDMETHODIMP ReceiveConnection(IPin* pConnector, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ STDMETHODIMP Receive(IMediaSample* pSample);
+
+ ISubStream* GetSubStream() { return m_pSubStream; }
};
diff --git a/src/Subtitles/TextFile.cpp b/src/Subtitles/TextFile.cpp
index 26c56a274..b2857c797 100644
--- a/src/Subtitles/TextFile.cpp
+++ b/src/Subtitles/TextFile.cpp
@@ -28,366 +28,366 @@
CTextFile::CTextFile(enc e)
{
- m_encoding = m_defaultencoding = e;
- m_offset = 0;
+ m_encoding = m_defaultencoding = e;
+ m_offset = 0;
}
bool CTextFile::Open(LPCTSTR lpszFileName)
{
- if (!__super::Open(lpszFileName, modeRead|typeBinary|shareDenyNone)) {
- return false;
- }
-
- m_encoding = m_defaultencoding;
- m_offset = 0;
-
- if (__super::GetLength() >= 2) {
- WORD w;
- if (sizeof(w) != Read(&w, sizeof(w))) {
- return Close(), false;
- }
-
- if (w == 0xfeff) {
- m_encoding = LE16;
- m_offset = 2;
- } else if (w == 0xfffe) {
- m_encoding = BE16;
- m_offset = 2;
- } else if (w == 0xbbef && __super::GetLength() >= 3) {
- BYTE b;
- if (sizeof(b) != Read(&b, sizeof(b))) {
- return Close(), false;
- }
-
- if (b == 0xbf) {
- m_encoding = UTF8;
- m_offset = 3;
- }
- }
- }
-
- if (m_encoding == m_defaultencoding) {
- __super::Close(); // CWebTextFile::Close() would delete the temp file if we called it...
- if (!__super::Open(lpszFileName, modeRead|typeText|shareDenyNone)) {
- return false;
- }
- }
-
- return true;
+ if (!__super::Open(lpszFileName, modeRead | typeBinary | shareDenyNone)) {
+ return false;
+ }
+
+ m_encoding = m_defaultencoding;
+ m_offset = 0;
+
+ if (__super::GetLength() >= 2) {
+ WORD w;
+ if (sizeof(w) != Read(&w, sizeof(w))) {
+ return Close(), false;
+ }
+
+ if (w == 0xfeff) {
+ m_encoding = LE16;
+ m_offset = 2;
+ } else if (w == 0xfffe) {
+ m_encoding = BE16;
+ m_offset = 2;
+ } else if (w == 0xbbef && __super::GetLength() >= 3) {
+ BYTE b;
+ if (sizeof(b) != Read(&b, sizeof(b))) {
+ return Close(), false;
+ }
+
+ if (b == 0xbf) {
+ m_encoding = UTF8;
+ m_offset = 3;
+ }
+ }
+ }
+
+ if (m_encoding == m_defaultencoding) {
+ __super::Close(); // CWebTextFile::Close() would delete the temp file if we called it...
+ if (!__super::Open(lpszFileName, modeRead | typeText | shareDenyNone)) {
+ return false;
+ }
+ }
+
+ return true;
}
bool CTextFile::Save(LPCTSTR lpszFileName, enc e)
{
- if (!__super::Open(lpszFileName, modeCreate|modeWrite|shareDenyWrite|(e==ASCII?typeText:typeBinary))) {
- return false;
- }
-
- if (e == UTF8) {
- BYTE b[3] = {0xef,0xbb,0xbf};
- Write(b, sizeof(b));
- } else if (e == LE16) {
- BYTE b[2] = {0xff,0xfe};
- Write(b, sizeof(b));
- } else if (e == BE16) {
- BYTE b[2] = {0xfe,0xff};
- Write(b, sizeof(b));
- }
-
- m_encoding = e;
-
- return true;
+ if (!__super::Open(lpszFileName, modeCreate | modeWrite | shareDenyWrite | (e == ASCII ? typeText : typeBinary))) {
+ return false;
+ }
+
+ if (e == UTF8) {
+ BYTE b[3] = {0xef, 0xbb, 0xbf};
+ Write(b, sizeof(b));
+ } else if (e == LE16) {
+ BYTE b[2] = {0xff, 0xfe};
+ Write(b, sizeof(b));
+ } else if (e == BE16) {
+ BYTE b[2] = {0xfe, 0xff};
+ Write(b, sizeof(b));
+ }
+
+ m_encoding = e;
+
+ return true;
}
void CTextFile::SetEncoding(enc e)
{
- m_encoding = e;
+ m_encoding = e;
}
CTextFile::enc CTextFile::GetEncoding()
{
- return m_encoding;
+ return m_encoding;
}
bool CTextFile::IsUnicode()
{
- return m_encoding == UTF8 || m_encoding == LE16 || m_encoding == BE16;
+ return m_encoding == UTF8 || m_encoding == LE16 || m_encoding == BE16;
}
// CFile
CString CTextFile::GetFilePath() const
{
- // to avoid a CException coming from CTime
- return m_strFileName; // __super::GetFilePath();
+ // to avoid a CException coming from CTime
+ return m_strFileName; // __super::GetFilePath();
}
// CStdioFile
ULONGLONG CTextFile::GetPosition() const
{
- return (CStdioFile::GetPosition() - m_offset);
+ return (CStdioFile::GetPosition() - m_offset);
}
ULONGLONG CTextFile::GetLength() const
{
- return (CStdioFile::GetLength() - m_offset);
+ return (CStdioFile::GetLength() - m_offset);
}
ULONGLONG CTextFile::Seek(LONGLONG lOff, UINT nFrom)
{
- ULONGLONG pos = GetPosition();
- ULONGLONG len = GetLength();
-
- switch (nFrom) {
- default:
- case begin:
- break;
- case current:
- lOff = pos + lOff;
- break;
- case end:
- lOff = len - lOff;
- break;
- }
-
- lOff = max(min((ULONGLONG)lOff, len), 0) + m_offset;
-
- pos = CStdioFile::Seek(lOff, begin) - m_offset;
-
- return pos;
+ ULONGLONG pos = GetPosition();
+ ULONGLONG len = GetLength();
+
+ switch (nFrom) {
+ default:
+ case begin:
+ break;
+ case current:
+ lOff = pos + lOff;
+ break;
+ case end:
+ lOff = len - lOff;
+ break;
+ }
+
+ lOff = max(min((ULONGLONG)lOff, len), 0) + m_offset;
+
+ pos = CStdioFile::Seek(lOff, begin) - m_offset;
+
+ return pos;
}
void CTextFile::WriteString(LPCSTR lpsz/*CStringA str*/)
{
- CStringA str(lpsz);
-
- if (m_encoding == ASCII) {
- __super::WriteString(AToT(str));
- } else if (m_encoding == ANSI) {
- str.Replace("\n", "\r\n");
- Write((LPCSTR)str, str.GetLength());
- } else if (m_encoding == UTF8) {
- WriteString(AToW(str));
- } else if (m_encoding == LE16) {
- WriteString(AToW(str));
- } else if (m_encoding == BE16) {
- WriteString(AToW(str));
- }
+ CStringA str(lpsz);
+
+ if (m_encoding == ASCII) {
+ __super::WriteString(AToT(str));
+ } else if (m_encoding == ANSI) {
+ str.Replace("\n", "\r\n");
+ Write((LPCSTR)str, str.GetLength());
+ } else if (m_encoding == UTF8) {
+ WriteString(AToW(str));
+ } else if (m_encoding == LE16) {
+ WriteString(AToW(str));
+ } else if (m_encoding == BE16) {
+ WriteString(AToW(str));
+ }
}
void CTextFile::WriteString(LPCWSTR lpsz/*CStringW str*/)
{
- CStringW str(lpsz);
-
- if (m_encoding == ASCII) {
- __super::WriteString(WToT(str));
- } else if (m_encoding == ANSI) {
- str.Replace(L"\n", L"\r\n");
- CStringA stra = CStringA(CString(str)); // TODO: codepage
- Write((LPCSTR)stra, stra.GetLength());
- } else if (m_encoding == UTF8) {
- str.Replace(L"\n", L"\r\n");
- for (unsigned int i = 0, l = str.GetLength(); i < l; i++) {
- DWORD c = (WORD)str[i];
-
- if (0 <= c && c < 0x80) { // 0xxxxxxx
- Write(&c, 1);
- } else if (0x80 <= c && c < 0x800) { // 110xxxxx 10xxxxxx
- c = 0xc080|((c<<2)&0x1f00)|(c&0x003f);
- Write((BYTE*)&c+1, 1);
- Write(&c, 1);
- } else if (0x800 <= c && c < 0xFFFF) { // 1110xxxx 10xxxxxx 10xxxxxx
- c = 0xe08080|((c<<4)&0x0f0000)|((c<<2)&0x3f00)|(c&0x003f);
- Write((BYTE*)&c+2, 1);
- Write((BYTE*)&c+1, 1);
- Write(&c, 1);
- } else {
- c = '?';
- Write(&c, 1);
- }
- }
- } else if (m_encoding == LE16) {
- str.Replace(L"\n", L"\r\n");
- Write((LPCWSTR)str, str.GetLength()*2);
- } else if (m_encoding == BE16) {
- str.Replace(L"\n", L"\r\n");
- for (unsigned int i = 0, l = str.GetLength(); i < l; i++) {
- str.SetAt(i, ((str[i]>>8)&0x00ff)|((str[i]<<8)&0xff00));
- }
- Write((LPCWSTR)str, str.GetLength()*2);
- }
+ CStringW str(lpsz);
+
+ if (m_encoding == ASCII) {
+ __super::WriteString(WToT(str));
+ } else if (m_encoding == ANSI) {
+ str.Replace(L"\n", L"\r\n");
+ CStringA stra = CStringA(CString(str)); // TODO: codepage
+ Write((LPCSTR)stra, stra.GetLength());
+ } else if (m_encoding == UTF8) {
+ str.Replace(L"\n", L"\r\n");
+ for (unsigned int i = 0, l = str.GetLength(); i < l; i++) {
+ DWORD c = (WORD)str[i];
+
+ if (0 <= c && c < 0x80) { // 0xxxxxxx
+ Write(&c, 1);
+ } else if (0x80 <= c && c < 0x800) { // 110xxxxx 10xxxxxx
+ c = 0xc080 | ((c << 2) & 0x1f00) | (c & 0x003f);
+ Write((BYTE*)&c + 1, 1);
+ Write(&c, 1);
+ } else if (0x800 <= c && c < 0xFFFF) { // 1110xxxx 10xxxxxx 10xxxxxx
+ c = 0xe08080 | ((c << 4) & 0x0f0000) | ((c << 2) & 0x3f00) | (c & 0x003f);
+ Write((BYTE*)&c + 2, 1);
+ Write((BYTE*)&c + 1, 1);
+ Write(&c, 1);
+ } else {
+ c = '?';
+ Write(&c, 1);
+ }
+ }
+ } else if (m_encoding == LE16) {
+ str.Replace(L"\n", L"\r\n");
+ Write((LPCWSTR)str, str.GetLength() * 2);
+ } else if (m_encoding == BE16) {
+ str.Replace(L"\n", L"\r\n");
+ for (unsigned int i = 0, l = str.GetLength(); i < l; i++) {
+ str.SetAt(i, ((str[i] >> 8) & 0x00ff) | ((str[i] << 8) & 0xff00));
+ }
+ Write((LPCWSTR)str, str.GetLength() * 2);
+ }
}
BOOL CTextFile::ReadString(CStringA& str)
{
- bool fEOF = true;
-
- str.Empty();
-
- if (m_encoding == ASCII) {
- CString s;
- fEOF = !__super::ReadString(s);
- str = TToA(s);
- } else if (m_encoding == ANSI) {
- char c;
- while (Read(&c, sizeof(c)) == sizeof(c)) {
- fEOF = false;
- if (c == '\r') {
- continue;
- }
- if (c == '\n') {
- break;
- }
- str += c;
- }
- } else if (m_encoding == UTF8) {
- BYTE b;
- while (Read(&b, sizeof(b)) == sizeof(b)) {
- fEOF = false;
- char c = '?';
- if (!(b&0x80)) { // 0xxxxxxx
- c = b&0x7f;
- } else if ((b&0xe0) == 0xc0) { // 110xxxxx 10xxxxxx
- if (Read(&b, sizeof(b)) != sizeof(b)) {
- break;
- }
- } else if ((b&0xf0) == 0xe0) { // 1110xxxx 10xxxxxx 10xxxxxx
- if (Read(&b, sizeof(b)) != sizeof(b)) {
- break;
- }
- if (Read(&b, sizeof(b)) != sizeof(b)) {
- break;
- }
- }
- if (c == '\r') {
- continue;
- }
- if (c == '\n') {
- break;
- }
- str += c;
- }
- } else if (m_encoding == LE16) {
- WORD w;
- while (Read(&w, sizeof(w)) == sizeof(w)) {
- fEOF = false;
- char c = '?';
- if (!(w&0xff00)) {
- c = w&0xff;
- }
- if (c == '\r') {
- continue;
- }
- if (c == '\n') {
- break;
- }
- str += c;
- }
- } else if (m_encoding == BE16) {
- WORD w;
- while (Read(&w, sizeof(w)) == sizeof(w)) {
- fEOF = false;
- char c = '?';
- if (!(w&0xff)) {
- c = w>>8;
- }
- if (c == '\r') {
- continue;
- }
- if (c == '\n') {
- break;
- }
- str += c;
- }
- }
-
- return !fEOF;
+ bool fEOF = true;
+
+ str.Empty();
+
+ if (m_encoding == ASCII) {
+ CString s;
+ fEOF = !__super::ReadString(s);
+ str = TToA(s);
+ } else if (m_encoding == ANSI) {
+ char c;
+ while (Read(&c, sizeof(c)) == sizeof(c)) {
+ fEOF = false;
+ if (c == '\r') {
+ continue;
+ }
+ if (c == '\n') {
+ break;
+ }
+ str += c;
+ }
+ } else if (m_encoding == UTF8) {
+ BYTE b;
+ while (Read(&b, sizeof(b)) == sizeof(b)) {
+ fEOF = false;
+ char c = '?';
+ if (!(b & 0x80)) { // 0xxxxxxx
+ c = b & 0x7f;
+ } else if ((b & 0xe0) == 0xc0) { // 110xxxxx 10xxxxxx
+ if (Read(&b, sizeof(b)) != sizeof(b)) {
+ break;
+ }
+ } else if ((b & 0xf0) == 0xe0) { // 1110xxxx 10xxxxxx 10xxxxxx
+ if (Read(&b, sizeof(b)) != sizeof(b)) {
+ break;
+ }
+ if (Read(&b, sizeof(b)) != sizeof(b)) {
+ break;
+ }
+ }
+ if (c == '\r') {
+ continue;
+ }
+ if (c == '\n') {
+ break;
+ }
+ str += c;
+ }
+ } else if (m_encoding == LE16) {
+ WORD w;
+ while (Read(&w, sizeof(w)) == sizeof(w)) {
+ fEOF = false;
+ char c = '?';
+ if (!(w & 0xff00)) {
+ c = w & 0xff;
+ }
+ if (c == '\r') {
+ continue;
+ }
+ if (c == '\n') {
+ break;
+ }
+ str += c;
+ }
+ } else if (m_encoding == BE16) {
+ WORD w;
+ while (Read(&w, sizeof(w)) == sizeof(w)) {
+ fEOF = false;
+ char c = '?';
+ if (!(w & 0xff)) {
+ c = w >> 8;
+ }
+ if (c == '\r') {
+ continue;
+ }
+ if (c == '\n') {
+ break;
+ }
+ str += c;
+ }
+ }
+
+ return !fEOF;
}
BOOL CTextFile::ReadString(CStringW& str)
{
- bool fEOF = true;
-
- str.Empty();
-
- if (m_encoding == ASCII) {
- CString s;
- fEOF = !__super::ReadString(s);
- str = TToW(s);
- } else if (m_encoding == ANSI) {
- CStringA stra;
- char c;
- while (Read(&c, sizeof(c)) == sizeof(c)) {
- fEOF = false;
- if (c == '\r') {
- continue;
- }
- if (c == '\n') {
- break;
- }
- stra += c;
- }
- str = CStringW(CString(stra)); // TODO: codepage
- } else if (m_encoding == UTF8) {
- BYTE b;
- while (Read(&b, sizeof(b)) == sizeof(b)) {
- fEOF = false;
- WCHAR c = '?';
- if (!(b&0x80)) { // 0xxxxxxx
- c = b&0x7f;
- } else if ((b&0xe0) == 0xc0) { // 110xxxxx 10xxxxxx
- c = (b&0x1f)<<6;
- if (Read(&b, sizeof(b)) != sizeof(b)) {
- break;
- }
- c |= (b&0x3f);
- } else if ((b&0xf0) == 0xe0) { // 1110xxxx 10xxxxxx 10xxxxxx
- c = (b&0x0f)<<12;
- if (Read(&b, sizeof(b)) != sizeof(b)) {
- break;
- }
- c |= (b&0x3f)<<6;
- if (Read(&b, sizeof(b)) != sizeof(b)) {
- break;
- }
- c |= (b&0x3f);
- }
- if (c == '\r') {
- continue;
- }
- if (c == '\n') {
- break;
- }
- str += c;
- }
- } else if (m_encoding == LE16) {
- WCHAR wc;
- while (Read(&wc, sizeof(wc)) == sizeof(wc)) {
- fEOF = false;
- if (wc == '\r') {
- continue;
- }
- if (wc == '\n') {
- break;
- }
- str += wc;
- }
- } else if (m_encoding == BE16) {
- WCHAR wc;
- while (Read(&wc, sizeof(wc)) == sizeof(wc)) {
- fEOF = false;
- wc = ((wc>>8)&0x00ff)|((wc<<8)&0xff00);
- if (wc == '\r') {
- continue;
- }
- if (wc == '\n') {
- break;
- }
- str += wc;
- }
- }
-
- return !fEOF;
+ bool fEOF = true;
+
+ str.Empty();
+
+ if (m_encoding == ASCII) {
+ CString s;
+ fEOF = !__super::ReadString(s);
+ str = TToW(s);
+ } else if (m_encoding == ANSI) {
+ CStringA stra;
+ char c;
+ while (Read(&c, sizeof(c)) == sizeof(c)) {
+ fEOF = false;
+ if (c == '\r') {
+ continue;
+ }
+ if (c == '\n') {
+ break;
+ }
+ stra += c;
+ }
+ str = CStringW(CString(stra)); // TODO: codepage
+ } else if (m_encoding == UTF8) {
+ BYTE b;
+ while (Read(&b, sizeof(b)) == sizeof(b)) {
+ fEOF = false;
+ WCHAR c = '?';
+ if (!(b & 0x80)) { // 0xxxxxxx
+ c = b & 0x7f;
+ } else if ((b & 0xe0) == 0xc0) { // 110xxxxx 10xxxxxx
+ c = (b & 0x1f) << 6;
+ if (Read(&b, sizeof(b)) != sizeof(b)) {
+ break;
+ }
+ c |= (b & 0x3f);
+ } else if ((b & 0xf0) == 0xe0) { // 1110xxxx 10xxxxxx 10xxxxxx
+ c = (b & 0x0f) << 12;
+ if (Read(&b, sizeof(b)) != sizeof(b)) {
+ break;
+ }
+ c |= (b & 0x3f) << 6;
+ if (Read(&b, sizeof(b)) != sizeof(b)) {
+ break;
+ }
+ c |= (b & 0x3f);
+ }
+ if (c == '\r') {
+ continue;
+ }
+ if (c == '\n') {
+ break;
+ }
+ str += c;
+ }
+ } else if (m_encoding == LE16) {
+ WCHAR wc;
+ while (Read(&wc, sizeof(wc)) == sizeof(wc)) {
+ fEOF = false;
+ if (wc == '\r') {
+ continue;
+ }
+ if (wc == '\n') {
+ break;
+ }
+ str += wc;
+ }
+ } else if (m_encoding == BE16) {
+ WCHAR wc;
+ while (Read(&wc, sizeof(wc)) == sizeof(wc)) {
+ fEOF = false;
+ wc = ((wc >> 8) & 0x00ff) | ((wc << 8) & 0xff00);
+ if (wc == '\r') {
+ continue;
+ }
+ if (wc == '\n') {
+ break;
+ }
+ str += wc;
+ }
+ }
+
+ return !fEOF;
}
//
@@ -395,137 +395,137 @@ BOOL CTextFile::ReadString(CStringW& str)
//
CWebTextFile::CWebTextFile(LONGLONG llMaxSize)
- : m_llMaxSize(llMaxSize)
+ : m_llMaxSize(llMaxSize)
{
}
bool CWebTextFile::Open(LPCTSTR lpszFileName)
{
- CString fn(lpszFileName);
-
- if (fn.Find(_T("http://")) != 0) {
- return __super::Open(lpszFileName);
- }
-
- try {
- CInternetSession is;
-
- CAutoPtr<CStdioFile> f(is.OpenURL(fn, 1, INTERNET_FLAG_TRANSFER_BINARY|INTERNET_FLAG_EXISTING_CONNECT));
- if (!f) {
- return false;
- }
-
- TCHAR path[_MAX_PATH];
- GetTempPath(_MAX_PATH, path);
-
- fn = path + fn.Mid(fn.ReverseFind('/')+1);
- int i = fn.Find(_T("?"));
- if (i > 0) {
- fn = fn.Left(i);
- }
- CFile temp;
- if (!temp.Open(fn, modeCreate|modeWrite|typeBinary|shareDenyWrite)) {
- f->Close();
- return false;
- }
-
- BYTE buff[1024];
- int len, total = 0;
- while ((len = f->Read(buff, 1024)) == 1024 && (m_llMaxSize < 0 || (total+=1024) < m_llMaxSize)) {
- temp.Write(buff, len);
- }
- if (len > 0) {
- temp.Write(buff, len);
- }
-
- m_tempfn = fn;
-
- f->Close(); // must close it because the desctructor doesn't seem to do it and we will get an exception when "is" is destroying
- } catch (CInternetException* ie) {
- ie->Delete();
- return false;
- }
-
- return __super::Open(m_tempfn);
+ CString fn(lpszFileName);
+
+ if (fn.Find(_T("http://")) != 0) {
+ return __super::Open(lpszFileName);
+ }
+
+ try {
+ CInternetSession is;
+
+ CAutoPtr<CStdioFile> f(is.OpenURL(fn, 1, INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_EXISTING_CONNECT));
+ if (!f) {
+ return false;
+ }
+
+ TCHAR path[_MAX_PATH];
+ GetTempPath(_MAX_PATH, path);
+
+ fn = path + fn.Mid(fn.ReverseFind('/') + 1);
+ int i = fn.Find(_T("?"));
+ if (i > 0) {
+ fn = fn.Left(i);
+ }
+ CFile temp;
+ if (!temp.Open(fn, modeCreate | modeWrite | typeBinary | shareDenyWrite)) {
+ f->Close();
+ return false;
+ }
+
+ BYTE buff[1024];
+ int len, total = 0;
+ while ((len = f->Read(buff, 1024)) == 1024 && (m_llMaxSize < 0 || (total += 1024) < m_llMaxSize)) {
+ temp.Write(buff, len);
+ }
+ if (len > 0) {
+ temp.Write(buff, len);
+ }
+
+ m_tempfn = fn;
+
+ f->Close(); // must close it because the desctructor doesn't seem to do it and we will get an exception when "is" is destroying
+ } catch (CInternetException* ie) {
+ ie->Delete();
+ return false;
+ }
+
+ return __super::Open(m_tempfn);
}
bool CWebTextFile::Save(LPCTSTR lpszFileName, enc e)
{
- // CWebTextFile is read-only...
- ASSERT(0);
- return false;
+ // CWebTextFile is read-only...
+ ASSERT(0);
+ return false;
}
void CWebTextFile::Close()
{
- __super::Close();
+ __super::Close();
- if (!m_tempfn.IsEmpty()) {
- _tremove(m_tempfn);
- m_tempfn.Empty();
- }
+ if (!m_tempfn.IsEmpty()) {
+ _tremove(m_tempfn);
+ m_tempfn.Empty();
+ }
}
///////////////////////////////////////////////////////////////
CStringW AToW(CStringA str)
{
- CStringW ret;
- for (int i = 0, j = str.GetLength(); i < j; i++) {
- ret += (WCHAR)(BYTE)str[i];
- }
- return ret;
+ CStringW ret;
+ for (int i = 0, j = str.GetLength(); i < j; i++) {
+ ret += (WCHAR)(BYTE)str[i];
+ }
+ return ret;
}
CStringA WToA(CStringW str)
{
- CStringA ret;
- for (int i = 0, j = str.GetLength(); i < j; i++) {
- ret += (CHAR)(WORD)str[i];
- }
- return ret;
+ CStringA ret;
+ for (int i = 0, j = str.GetLength(); i < j; i++) {
+ ret += (CHAR)(WORD)str[i];
+ }
+ return ret;
}
CString AToT(CStringA str)
{
- CString ret;
- for (int i = 0, j = str.GetLength(); i < j; i++) {
- ret += (TCHAR)(BYTE)str[i];
- }
- return ret;
+ CString ret;
+ for (int i = 0, j = str.GetLength(); i < j; i++) {
+ ret += (TCHAR)(BYTE)str[i];
+ }
+ return ret;
}
CString WToT(CStringW str)
{
- CString ret;
- for (int i = 0, j = str.GetLength(); i < j; i++) {
- ret += (TCHAR)(WORD)str[i];
- }
- return ret;
+ CString ret;
+ for (int i = 0, j = str.GetLength(); i < j; i++) {
+ ret += (TCHAR)(WORD)str[i];
+ }
+ return ret;
}
CStringA TToA(CString str)
{
- CStringA ret;
+ CStringA ret;
#ifdef UNICODE
- for (int i = 0, j = str.GetLength(); i < j; i++) {
- ret += (CHAR)(BYTE)str[i];
- }
+ for (int i = 0, j = str.GetLength(); i < j; i++) {
+ ret += (CHAR)(BYTE)str[i];
+ }
#else
- ret = str;
+ ret = str;
#endif
- return ret;
+ return ret;
}
CStringW TToW(CString str)
{
- CStringW ret;
+ CStringW ret;
#ifdef UNICODE
- ret = str;
+ ret = str;
#else
- for (size_t i = 0, j = str.GetLength(); i < j; i++) {
- ret += (WCHAR)(BYTE)str[i];
- }
+ for (size_t i = 0, j = str.GetLength(); i < j; i++) {
+ ret += (WCHAR)(BYTE)str[i];
+ }
#endif
- return ret;
+ return ret;
}
diff --git a/src/Subtitles/TextFile.h b/src/Subtitles/TextFile.h
index 8d65caa08..88bcde1b4 100644
--- a/src/Subtitles/TextFile.h
+++ b/src/Subtitles/TextFile.h
@@ -28,54 +28,54 @@
class CTextFile : protected CStdioFile
{
public:
- typedef enum {ASCII, UTF8, LE16, BE16, ANSI} enc;
+ typedef enum {ASCII, UTF8, LE16, BE16, ANSI} enc;
private:
- enc m_encoding, m_defaultencoding;
- int m_offset;
+ enc m_encoding, m_defaultencoding;
+ int m_offset;
public:
- CTextFile(enc e = ASCII);
+ CTextFile(enc e = ASCII);
- virtual bool Open(LPCTSTR lpszFileName);
- virtual bool Save(LPCTSTR lpszFileName, enc e /*= ASCII*/);
+ virtual bool Open(LPCTSTR lpszFileName);
+ virtual bool Save(LPCTSTR lpszFileName, enc e /*= ASCII*/);
- void SetEncoding(enc e);
- enc GetEncoding();
- bool IsUnicode();
+ void SetEncoding(enc e);
+ enc GetEncoding();
+ bool IsUnicode();
- // CFile
+ // CFile
- CString GetFilePath() const;
+ CString GetFilePath() const;
- // CStdioFile
+ // CStdioFile
- ULONGLONG GetPosition() const;
- ULONGLONG GetLength() const;
- ULONGLONG Seek(LONGLONG lOff, UINT nFrom);
+ ULONGLONG GetPosition() const;
+ ULONGLONG GetLength() const;
+ ULONGLONG Seek(LONGLONG lOff, UINT nFrom);
- void WriteString(LPCSTR lpsz/*CStringA str*/);
- void WriteString(LPCWSTR lpsz/*CStringW str*/);
- BOOL ReadString(CStringA& str);
- BOOL ReadString(CStringW& str);
+ void WriteString(LPCSTR lpsz/*CStringA str*/);
+ void WriteString(LPCWSTR lpsz/*CStringW str*/);
+ BOOL ReadString(CStringA& str);
+ BOOL ReadString(CStringW& str);
};
class CWebTextFile : public CTextFile
{
- LONGLONG m_llMaxSize;
- CString m_tempfn;
+ LONGLONG m_llMaxSize;
+ CString m_tempfn;
public:
- CWebTextFile(LONGLONG llMaxSize = 1024*1024);
+ CWebTextFile(LONGLONG llMaxSize = 1024 * 1024);
- bool Open(LPCTSTR lpszFileName);
- bool Save(LPCTSTR lpszFileName, enc e /*= ASCII*/);
- void Close();
+ bool Open(LPCTSTR lpszFileName);
+ bool Save(LPCTSTR lpszFileName, enc e /*= ASCII*/);
+ void Close();
};
extern CStringW AToW(CStringA str);
extern CStringA WToA(CStringW str);
-extern CString AToT(CStringA str);
-extern CString WToT(CStringW str);
-extern CStringA TToA(CString str);
-extern CStringW TToW(CString str);
+extern CString AToT(CStringA str);
+extern CString WToT(CStringW str);
+extern CStringA TToA(CString str);
+extern CStringW TToW(CString str);
diff --git a/src/Subtitles/USFSubtitles.cpp b/src/Subtitles/USFSubtitles.cpp
index 287d11fe1..497bb6498 100644
--- a/src/Subtitles/USFSubtitles.cpp
+++ b/src/Subtitles/USFSubtitles.cpp
@@ -51,131 +51,131 @@
static CStringW GetText(CComPtr<IXMLDOMNode> pNode)
{
- CComBSTR bstr;
- pNode->get_text(&bstr);
+ CComBSTR bstr;
+ pNode->get_text(&bstr);
- return CStringW(bstr);
+ return CStringW(bstr);
}
static CStringW GetXML(CComPtr<IXMLDOMNode> pNode)
{
- CComBSTR bstr;
- pNode->get_xml(&bstr);
- CStringW str(bstr);
- str.Remove('\r');
- str.Replace('\n', ' ');
- for (int i = 0; (i = str.Find(L" ", i)) >= 0; ) {
- for (++i; i < str.GetLength() && (str[i] == ' ');) {
- str.Delete(i);
- }
- }
- return str;
+ CComBSTR bstr;
+ pNode->get_xml(&bstr);
+ CStringW str(bstr);
+ str.Remove('\r');
+ str.Replace('\n', ' ');
+ for (int i = 0; (i = str.Find(L" ", i)) >= 0;) {
+ for (++i; i < str.GetLength() && (str[i] == ' ');) {
+ str.Delete(i);
+ }
+ }
+ return str;
}
static CStringW GetAttrib(CStringW attrib, CComPtr<IXMLDOMNode> pNode)
{
- CStringW ret;
+ CStringW ret;
- BeginEnumAttribs(pNode, pChild) {
- DeclareNameAndValue(pChild, name, val);
+ BeginEnumAttribs(pNode, pChild) {
+ DeclareNameAndValue(pChild, name, val);
- if (CStringW(name) == attrib && val.vt == VT_BSTR) { // TODO: prepare for other types
- ret = val.bstrVal;
- break;
- }
- }
- EndEnumAttribs
+ if (CStringW(name) == attrib && val.vt == VT_BSTR) { // TODO: prepare for other types
+ ret = val.bstrVal;
+ break;
+ }
+ }
+ EndEnumAttribs
- return ret;
+ return ret;
}
static int TimeToInt(CStringW str)
{
- CAtlList<CStringW> sl;
- int i = 0;
- for (CStringW token = str.Tokenize(L":.,", i); !token.IsEmpty(); token = str.Tokenize(L":.,", i)) {
- sl.AddHead(token);
- }
-
- if (sl.GetCount() > 4) {
- return -1;
- }
-
- int time = 0;
-
- int mul[4] = {1,1000,60*1000,60*60*1000};
- POSITION pos = sl.GetHeadPosition();
- for (i = 0; pos; i++) {
- const WCHAR* s = sl.GetNext(pos);
- WCHAR* tmp = NULL;
- int t = wcstol(s, &tmp, 10);
- if (s >= tmp) {
- return -1;
- }
- time += t * mul[i];
- }
-
- return time;
+ CAtlList<CStringW> sl;
+ int i = 0;
+ for (CStringW token = str.Tokenize(L":.,", i); !token.IsEmpty(); token = str.Tokenize(L":.,", i)) {
+ sl.AddHead(token);
+ }
+
+ if (sl.GetCount() > 4) {
+ return -1;
+ }
+
+ int time = 0;
+
+ int mul[4] = {1, 1000, 60 * 1000, 60 * 60 * 1000};
+ POSITION pos = sl.GetHeadPosition();
+ for (i = 0; pos; i++) {
+ const WCHAR* s = sl.GetNext(pos);
+ WCHAR* tmp = NULL;
+ int t = wcstol(s, &tmp, 10);
+ if (s >= tmp) {
+ return -1;
+ }
+ time += t * mul[i];
+ }
+
+ return time;
}
static DWORD StringToDWORD(CStringW str)
{
- if (str.IsEmpty()) {
- return 0;
- }
- if (str[0] == '#') {
- return (DWORD)wcstol(str, NULL, 16);
- } else {
- return (DWORD)wcstol(str, NULL, 10);
- }
+ if (str.IsEmpty()) {
+ return 0;
+ }
+ if (str[0] == '#') {
+ return (DWORD)wcstol(str, NULL, 16);
+ } else {
+ return (DWORD)wcstol(str, NULL, 10);
+ }
}
static DWORD ColorToDWORD(CStringW str)
{
- if (str.IsEmpty()) {
- return 0;
- }
+ if (str.IsEmpty()) {
+ return 0;
+ }
- DWORD ret = 0;
+ DWORD ret = 0;
- if (str[0] == '#') {
- ret = (DWORD)wcstol(str.TrimLeft('#'), NULL, 16);
- } else {
- g_colors.Lookup(CString(str), ret);
- }
+ if (str[0] == '#') {
+ ret = (DWORD)wcstol(str.TrimLeft('#'), NULL, 16);
+ } else {
+ g_colors.Lookup(CString(str), ret);
+ }
- ret = ((ret&0xff)<<16)|(ret&0xff00ff00)|((ret>>16)&0xff);
+ ret = ((ret & 0xff) << 16) | (ret & 0xff00ff00) | ((ret >> 16) & 0xff);
- return ret;
+ return ret;
}
static int TranslateAlignment(CStringW alignment)
{
- return
- !alignment.CompareNoCase(L"BottomLeft") ? 1 :
- !alignment.CompareNoCase(L"BottomCenter") ? 2 :
- !alignment.CompareNoCase(L"BottomRight") ? 3 :
- !alignment.CompareNoCase(L"MiddleLeft") ? 4 :
- !alignment.CompareNoCase(L"MiddleCenter") ? 5 :
- !alignment.CompareNoCase(L"MiddleRight") ? 6 :
- !alignment.CompareNoCase(L"TopLeft") ? 7 :
- !alignment.CompareNoCase(L"TopCenter") ? 8 :
- !alignment.CompareNoCase(L"TopRight") ? 9 :
- 2;
+ return
+ !alignment.CompareNoCase(L"BottomLeft") ? 1 :
+ !alignment.CompareNoCase(L"BottomCenter") ? 2 :
+ !alignment.CompareNoCase(L"BottomRight") ? 3 :
+ !alignment.CompareNoCase(L"MiddleLeft") ? 4 :
+ !alignment.CompareNoCase(L"MiddleCenter") ? 5 :
+ !alignment.CompareNoCase(L"MiddleRight") ? 6 :
+ !alignment.CompareNoCase(L"TopLeft") ? 7 :
+ !alignment.CompareNoCase(L"TopCenter") ? 8 :
+ !alignment.CompareNoCase(L"TopRight") ? 9 :
+ 2;
}
static int TranslateMargin(CStringW margin, int wndsize)
{
- int ret = 0;
+ int ret = 0;
- if (!margin.IsEmpty()) {
- ret = wcstol(margin, NULL, 10);
- if (margin.Find('%') >= 0) {
- ret = wndsize * ret / 100;
- }
- }
+ if (!margin.IsEmpty()) {
+ ret = wcstol(margin, NULL, 10);
+ if (margin.Find('%') >= 0) {
+ ret = wndsize * ret / 100;
+ }
+ }
- return ret;
+ return ret;
}
////////////////
@@ -190,595 +190,595 @@ CUSFSubtitles::~CUSFSubtitles()
bool CUSFSubtitles::Read(LPCTSTR fn)
{
- VARIANT_BOOL vb;
- CComPtr<IXMLDOMDocument> pDoc;
- if (FAILED(pDoc.CoCreateInstance(CLSID_DOMDocument))
- || FAILED(pDoc->put_async(VARIANT_FALSE))
- || FAILED(pDoc->load(CComVariant(fn), &vb)) || vb != VARIANT_TRUE) {
- return false;
- }
-
- styles.RemoveAll();
- effects.RemoveAll();
- texts.RemoveAll();
-
- if (!ParseUSFSubtitles(CComQIPtr<IXMLDOMNode>(pDoc))) {
- return false;
- }
-
- POSITION pos = styles.GetHeadPosition();
- while (pos) {
- style_t* def = styles.GetNext(pos);
-
- if (def->name.CompareNoCase(L"Default")) {
- continue;
- }
-
- POSITION pos2 = styles.GetHeadPosition();
- while (pos2) {
- style_t* s = styles.GetNext(pos2);
-
- if (!s->name.CompareNoCase(L"Default")) {
- continue;
- }
-
- if (s->fontstyle.face.IsEmpty()) {
- s->fontstyle.face = def->fontstyle.face;
- }
- if (s->fontstyle.size.IsEmpty()) {
- s->fontstyle.size = def->fontstyle.size;
- }
- if (s->fontstyle.color[0].IsEmpty()) {
- s->fontstyle.color[0] = def->fontstyle.color[0];
- }
- if (s->fontstyle.color[1].IsEmpty()) {
- s->fontstyle.color[1] = def->fontstyle.color[1];
- }
- if (s->fontstyle.color[2].IsEmpty()) {
- s->fontstyle.color[2] = def->fontstyle.color[2];
- }
- if (s->fontstyle.color[3].IsEmpty()) {
- s->fontstyle.color[3] = def->fontstyle.color[3];
- }
- if (s->fontstyle.italic.IsEmpty()) {
- s->fontstyle.italic = def->fontstyle.italic;
- }
- if (s->fontstyle.weight.IsEmpty()) {
- s->fontstyle.weight = def->fontstyle.weight;
- }
- if (s->fontstyle.underline.IsEmpty()) {
- s->fontstyle.underline = def->fontstyle.underline;
- }
- if (s->fontstyle.alpha.IsEmpty()) {
- s->fontstyle.alpha = def->fontstyle.alpha;
- }
- if (s->fontstyle.outline.IsEmpty()) {
- s->fontstyle.outline = def->fontstyle.outline;
- }
- if (s->fontstyle.shadow.IsEmpty()) {
- s->fontstyle.shadow = def->fontstyle.shadow;
- }
- if (s->fontstyle.wrap.IsEmpty()) {
- s->fontstyle.wrap = def->fontstyle.wrap;
- }
- if (s->pal.alignment.IsEmpty()) {
- s->pal.alignment = def->pal.alignment;
- }
- if (s->pal.relativeto.IsEmpty()) {
- s->pal.relativeto = def->pal.relativeto;
- }
- if (s->pal.horizontal_margin.IsEmpty()) {
- s->pal.horizontal_margin = def->pal.horizontal_margin;
- }
- if (s->pal.vertical_margin.IsEmpty()) {
- s->pal.vertical_margin = def->pal.vertical_margin;
- }
- if (s->pal.rotate[0].IsEmpty()) {
- s->pal.rotate[0] = def->pal.rotate[0];
- }
- if (s->pal.rotate[1].IsEmpty()) {
- s->pal.rotate[1] = def->pal.rotate[1];
- }
- if (s->pal.rotate[2].IsEmpty()) {
- s->pal.rotate[2] = def->pal.rotate[2];
- }
- }
-
- break;
- }
-
- pos = texts.GetHeadPosition();
- while (pos) {
- text_t* t = texts.GetNext(pos);
- if (t->style.IsEmpty()) {
- t->style = L"Default";
- }
- }
-
- return true;
+ VARIANT_BOOL vb;
+ CComPtr<IXMLDOMDocument> pDoc;
+ if (FAILED(pDoc.CoCreateInstance(CLSID_DOMDocument))
+ || FAILED(pDoc->put_async(VARIANT_FALSE))
+ || FAILED(pDoc->load(CComVariant(fn), &vb)) || vb != VARIANT_TRUE) {
+ return false;
+ }
+
+ styles.RemoveAll();
+ effects.RemoveAll();
+ texts.RemoveAll();
+
+ if (!ParseUSFSubtitles(CComQIPtr<IXMLDOMNode>(pDoc))) {
+ return false;
+ }
+
+ POSITION pos = styles.GetHeadPosition();
+ while (pos) {
+ style_t* def = styles.GetNext(pos);
+
+ if (def->name.CompareNoCase(L"Default")) {
+ continue;
+ }
+
+ POSITION pos2 = styles.GetHeadPosition();
+ while (pos2) {
+ style_t* s = styles.GetNext(pos2);
+
+ if (!s->name.CompareNoCase(L"Default")) {
+ continue;
+ }
+
+ if (s->fontstyle.face.IsEmpty()) {
+ s->fontstyle.face = def->fontstyle.face;
+ }
+ if (s->fontstyle.size.IsEmpty()) {
+ s->fontstyle.size = def->fontstyle.size;
+ }
+ if (s->fontstyle.color[0].IsEmpty()) {
+ s->fontstyle.color[0] = def->fontstyle.color[0];
+ }
+ if (s->fontstyle.color[1].IsEmpty()) {
+ s->fontstyle.color[1] = def->fontstyle.color[1];
+ }
+ if (s->fontstyle.color[2].IsEmpty()) {
+ s->fontstyle.color[2] = def->fontstyle.color[2];
+ }
+ if (s->fontstyle.color[3].IsEmpty()) {
+ s->fontstyle.color[3] = def->fontstyle.color[3];
+ }
+ if (s->fontstyle.italic.IsEmpty()) {
+ s->fontstyle.italic = def->fontstyle.italic;
+ }
+ if (s->fontstyle.weight.IsEmpty()) {
+ s->fontstyle.weight = def->fontstyle.weight;
+ }
+ if (s->fontstyle.underline.IsEmpty()) {
+ s->fontstyle.underline = def->fontstyle.underline;
+ }
+ if (s->fontstyle.alpha.IsEmpty()) {
+ s->fontstyle.alpha = def->fontstyle.alpha;
+ }
+ if (s->fontstyle.outline.IsEmpty()) {
+ s->fontstyle.outline = def->fontstyle.outline;
+ }
+ if (s->fontstyle.shadow.IsEmpty()) {
+ s->fontstyle.shadow = def->fontstyle.shadow;
+ }
+ if (s->fontstyle.wrap.IsEmpty()) {
+ s->fontstyle.wrap = def->fontstyle.wrap;
+ }
+ if (s->pal.alignment.IsEmpty()) {
+ s->pal.alignment = def->pal.alignment;
+ }
+ if (s->pal.relativeto.IsEmpty()) {
+ s->pal.relativeto = def->pal.relativeto;
+ }
+ if (s->pal.horizontal_margin.IsEmpty()) {
+ s->pal.horizontal_margin = def->pal.horizontal_margin;
+ }
+ if (s->pal.vertical_margin.IsEmpty()) {
+ s->pal.vertical_margin = def->pal.vertical_margin;
+ }
+ if (s->pal.rotate[0].IsEmpty()) {
+ s->pal.rotate[0] = def->pal.rotate[0];
+ }
+ if (s->pal.rotate[1].IsEmpty()) {
+ s->pal.rotate[1] = def->pal.rotate[1];
+ }
+ if (s->pal.rotate[2].IsEmpty()) {
+ s->pal.rotate[2] = def->pal.rotate[2];
+ }
+ }
+
+ break;
+ }
+
+ pos = texts.GetHeadPosition();
+ while (pos) {
+ text_t* t = texts.GetNext(pos);
+ if (t->style.IsEmpty()) {
+ t->style = L"Default";
+ }
+ }
+
+ return true;
}
bool CUSFSubtitles::ConvertToSTS(CSimpleTextSubtitle& sts)
{
- sts.m_name = metadata.language.text;
- sts.m_encoding = CTextFile::UTF8;
- sts.m_dstScreenSize = CSize(640, 480);
- sts.m_fScaledBAS = true;
- sts.m_defaultWrapStyle = 1;
-
- // TODO: map metadata.language.code to charset num (windows doesn't have such a function...)
- int charSet = DEFAULT_CHARSET;
-
- POSITION pos = styles.GetHeadPosition();
- while (pos) {
- style_t* s = styles.GetNext(pos);
-
- if (!s->name.CompareNoCase(L"Default") && !s->fontstyle.wrap.IsEmpty()) {
- sts.m_defaultWrapStyle =
- !s->fontstyle.wrap.CompareNoCase(L"no") ? 2 :
- !s->fontstyle.wrap.CompareNoCase(L"auto") ? 1 :
- 1;
- }
-
- STSStyle* stss = DNew STSStyle;
- if (!stss) {
- continue;
- }
-
- if (!s->pal.horizontal_margin.IsEmpty()) {
- stss->marginRect.left = stss->marginRect.right = TranslateMargin(s->pal.horizontal_margin, sts.m_dstScreenSize.cx);
- }
- if (!s->pal.vertical_margin.IsEmpty()) {
- stss->marginRect.top = stss->marginRect.bottom = TranslateMargin(s->pal.vertical_margin, sts.m_dstScreenSize.cy);
- }
-
- stss->scrAlignment = TranslateAlignment(s->pal.alignment);
-
- if (!s->pal.relativeto.IsEmpty()) stss->relativeTo =
- !s->pal.relativeto.CompareNoCase(L"window") ? 0 :
- !s->pal.relativeto.CompareNoCase(L"video") ? 1 :
- 0;
-
- stss->borderStyle = 0;
- if (!s->fontstyle.outline.IsEmpty()) {
- stss->outlineWidthX = stss->outlineWidthY = wcstol(s->fontstyle.outline, NULL, 10);
- }
- if (!s->fontstyle.shadow.IsEmpty()) {
- stss->shadowDepthX = stss->shadowDepthY = wcstol(s->fontstyle.shadow, NULL, 10);
- }
-
- for (size_t i = 0; i < 4; i++) {
- DWORD color = ColorToDWORD(s->fontstyle.color[i]);
- int alpha = (BYTE)wcstol(s->fontstyle.alpha, NULL, 10);
-
- stss->colors[i] = color & 0xffffff;
- stss->alpha[i] = (BYTE)(color>>24);
-
- stss->alpha[i] = stss->alpha[i] + (255 - stss->alpha[i]) * min(max(alpha, 0), 100) / 100;
- }
-
- if (!s->fontstyle.face.IsEmpty()) {
- stss->fontName = s->fontstyle.face;
- }
- if (!s->fontstyle.size.IsEmpty()) {
- stss->fontSize = wcstol(s->fontstyle.size, NULL, 10);
- }
- if (!s->fontstyle.weight.IsEmpty()) stss->fontWeight =
- !s->fontstyle.weight.CompareNoCase(L"normal") ? FW_NORMAL :
- !s->fontstyle.weight.CompareNoCase(L"bold") ? FW_BOLD :
- !s->fontstyle.weight.CompareNoCase(L"lighter") ? FW_LIGHT :
- !s->fontstyle.weight.CompareNoCase(L"bolder") ? FW_SEMIBOLD :
- wcstol(s->fontstyle.weight, NULL, 10);
- if (stss->fontWeight == 0) {
- stss->fontWeight = FW_NORMAL;
- }
- if (!s->fontstyle.italic.IsEmpty()) {
- stss->fItalic = s->fontstyle.italic.CompareNoCase(L"yes") == 0;
- }
- if (!s->fontstyle.underline.IsEmpty()) {
- stss->fUnderline = s->fontstyle.underline.CompareNoCase(L"yes") == 0;
- }
- if (!s->pal.rotate[0].IsEmpty()) {
- stss->fontAngleZ = wcstol(s->pal.rotate[0], NULL, 10);
- }
- if (!s->pal.rotate[1].IsEmpty()) {
- stss->fontAngleX = wcstol(s->pal.rotate[1], NULL, 10);
- }
- if (!s->pal.rotate[2].IsEmpty()) {
- stss->fontAngleY = wcstol(s->pal.rotate[2], NULL, 10);
- }
-
- stss->charSet = charSet;
-
- sts.AddStyle(WToT(s->name), stss);
- }
-
- pos = texts.GetHeadPosition();
- while (pos) {
- text_t* t = texts.GetNext(pos);
-
- if (!t->pal.alignment.IsEmpty()) {
- CStringW s;
- s.Format(L"{\\an%d}", TranslateAlignment(t->pal.alignment));
- t->str = s + t->str;
- }
-
- CRect marginRect;
- marginRect.SetRectEmpty();
-
- if (!t->pal.horizontal_margin.IsEmpty()) {
- marginRect.left = marginRect.right = TranslateMargin(t->pal.horizontal_margin, sts.m_dstScreenSize.cx);
- }
- if (!t->pal.vertical_margin.IsEmpty()) {
- marginRect.top = marginRect.bottom = TranslateMargin(t->pal.vertical_margin, sts.m_dstScreenSize.cy);
- }
-
- WCHAR rtags[3][8] = {L"{\\rz%d}", L"{\\rx%d}", L"{\\ry%d}"};
- for (size_t i = 0; i < 3; i++) {
- if (int angle = wcstol(t->pal.rotate[i], NULL, 10)) {
- CStringW str;
- str.Format(rtags[i], angle);
- t->str = str + t->str;
- }
- }
-
- if (t->style.CompareNoCase(L"Default") != 0) {
- POSITION pos = styles.GetHeadPosition();
- while (pos) {
- style_t* s = styles.GetNext(pos);
- if (s->name == t->style && !s->fontstyle.wrap.IsEmpty()) {
- int WrapStyle =
- !s->fontstyle.wrap.CompareNoCase(L"no") ? 2 :
- !s->fontstyle.wrap.CompareNoCase(L"auto") ? 1 :
- 1;
-
- if (WrapStyle != sts.m_defaultWrapStyle) {
- CStringW str;
- str.Format(L"{\\q%d}", WrapStyle);
- t->str = str + t->str;
- }
-
- break;
- }
- }
- }
-
- // TODO: apply effects as {\t(..)} after usf's standard clearly defines them
-
- sts.Add(t->str, true, t->start, t->stop, WToT(t->style), _T(""), _T(""), marginRect);
- }
-
- return true;
+ sts.m_name = metadata.language.text;
+ sts.m_encoding = CTextFile::UTF8;
+ sts.m_dstScreenSize = CSize(640, 480);
+ sts.m_fScaledBAS = true;
+ sts.m_defaultWrapStyle = 1;
+
+ // TODO: map metadata.language.code to charset num (windows doesn't have such a function...)
+ int charSet = DEFAULT_CHARSET;
+
+ POSITION pos = styles.GetHeadPosition();
+ while (pos) {
+ style_t* s = styles.GetNext(pos);
+
+ if (!s->name.CompareNoCase(L"Default") && !s->fontstyle.wrap.IsEmpty()) {
+ sts.m_defaultWrapStyle =
+ !s->fontstyle.wrap.CompareNoCase(L"no") ? 2 :
+ !s->fontstyle.wrap.CompareNoCase(L"auto") ? 1 :
+ 1;
+ }
+
+ STSStyle* stss = DNew STSStyle;
+ if (!stss) {
+ continue;
+ }
+
+ if (!s->pal.horizontal_margin.IsEmpty()) {
+ stss->marginRect.left = stss->marginRect.right = TranslateMargin(s->pal.horizontal_margin, sts.m_dstScreenSize.cx);
+ }
+ if (!s->pal.vertical_margin.IsEmpty()) {
+ stss->marginRect.top = stss->marginRect.bottom = TranslateMargin(s->pal.vertical_margin, sts.m_dstScreenSize.cy);
+ }
+
+ stss->scrAlignment = TranslateAlignment(s->pal.alignment);
+
+ if (!s->pal.relativeto.IsEmpty()) stss->relativeTo =
+ !s->pal.relativeto.CompareNoCase(L"window") ? 0 :
+ !s->pal.relativeto.CompareNoCase(L"video") ? 1 :
+ 0;
+
+ stss->borderStyle = 0;
+ if (!s->fontstyle.outline.IsEmpty()) {
+ stss->outlineWidthX = stss->outlineWidthY = wcstol(s->fontstyle.outline, NULL, 10);
+ }
+ if (!s->fontstyle.shadow.IsEmpty()) {
+ stss->shadowDepthX = stss->shadowDepthY = wcstol(s->fontstyle.shadow, NULL, 10);
+ }
+
+ for (size_t i = 0; i < 4; i++) {
+ DWORD color = ColorToDWORD(s->fontstyle.color[i]);
+ int alpha = (BYTE)wcstol(s->fontstyle.alpha, NULL, 10);
+
+ stss->colors[i] = color & 0xffffff;
+ stss->alpha[i] = (BYTE)(color >> 24);
+
+ stss->alpha[i] = stss->alpha[i] + (255 - stss->alpha[i]) * min(max(alpha, 0), 100) / 100;
+ }
+
+ if (!s->fontstyle.face.IsEmpty()) {
+ stss->fontName = s->fontstyle.face;
+ }
+ if (!s->fontstyle.size.IsEmpty()) {
+ stss->fontSize = wcstol(s->fontstyle.size, NULL, 10);
+ }
+ if (!s->fontstyle.weight.IsEmpty()) stss->fontWeight =
+ !s->fontstyle.weight.CompareNoCase(L"normal") ? FW_NORMAL :
+ !s->fontstyle.weight.CompareNoCase(L"bold") ? FW_BOLD :
+ !s->fontstyle.weight.CompareNoCase(L"lighter") ? FW_LIGHT :
+ !s->fontstyle.weight.CompareNoCase(L"bolder") ? FW_SEMIBOLD :
+ wcstol(s->fontstyle.weight, NULL, 10);
+ if (stss->fontWeight == 0) {
+ stss->fontWeight = FW_NORMAL;
+ }
+ if (!s->fontstyle.italic.IsEmpty()) {
+ stss->fItalic = s->fontstyle.italic.CompareNoCase(L"yes") == 0;
+ }
+ if (!s->fontstyle.underline.IsEmpty()) {
+ stss->fUnderline = s->fontstyle.underline.CompareNoCase(L"yes") == 0;
+ }
+ if (!s->pal.rotate[0].IsEmpty()) {
+ stss->fontAngleZ = wcstol(s->pal.rotate[0], NULL, 10);
+ }
+ if (!s->pal.rotate[1].IsEmpty()) {
+ stss->fontAngleX = wcstol(s->pal.rotate[1], NULL, 10);
+ }
+ if (!s->pal.rotate[2].IsEmpty()) {
+ stss->fontAngleY = wcstol(s->pal.rotate[2], NULL, 10);
+ }
+
+ stss->charSet = charSet;
+
+ sts.AddStyle(WToT(s->name), stss);
+ }
+
+ pos = texts.GetHeadPosition();
+ while (pos) {
+ text_t* t = texts.GetNext(pos);
+
+ if (!t->pal.alignment.IsEmpty()) {
+ CStringW s;
+ s.Format(L"{\\an%d}", TranslateAlignment(t->pal.alignment));
+ t->str = s + t->str;
+ }
+
+ CRect marginRect;
+ marginRect.SetRectEmpty();
+
+ if (!t->pal.horizontal_margin.IsEmpty()) {
+ marginRect.left = marginRect.right = TranslateMargin(t->pal.horizontal_margin, sts.m_dstScreenSize.cx);
+ }
+ if (!t->pal.vertical_margin.IsEmpty()) {
+ marginRect.top = marginRect.bottom = TranslateMargin(t->pal.vertical_margin, sts.m_dstScreenSize.cy);
+ }
+
+ WCHAR rtags[3][8] = {L"{\\rz%d}", L"{\\rx%d}", L"{\\ry%d}"};
+ for (size_t i = 0; i < 3; i++) {
+ if (int angle = wcstol(t->pal.rotate[i], NULL, 10)) {
+ CStringW str;
+ str.Format(rtags[i], angle);
+ t->str = str + t->str;
+ }
+ }
+
+ if (t->style.CompareNoCase(L"Default") != 0) {
+ POSITION pos = styles.GetHeadPosition();
+ while (pos) {
+ style_t* s = styles.GetNext(pos);
+ if (s->name == t->style && !s->fontstyle.wrap.IsEmpty()) {
+ int WrapStyle =
+ !s->fontstyle.wrap.CompareNoCase(L"no") ? 2 :
+ !s->fontstyle.wrap.CompareNoCase(L"auto") ? 1 :
+ 1;
+
+ if (WrapStyle != sts.m_defaultWrapStyle) {
+ CStringW str;
+ str.Format(L"{\\q%d}", WrapStyle);
+ t->str = str + t->str;
+ }
+
+ break;
+ }
+ }
+ }
+
+ // TODO: apply effects as {\t(..)} after usf's standard clearly defines them
+
+ sts.Add(t->str, true, t->start, t->stop, WToT(t->style), _T(""), _T(""), marginRect);
+ }
+
+ return true;
}
bool CUSFSubtitles::ParseUSFSubtitles(CComPtr<IXMLDOMNode> pNode)
{
- DeclareNameAndValue(pNode, name, val);
-
- if (name == L"usfsubtitles") {
- // metadata
-
- BeginEnumChildren(pNode, pChild) {
- DeclareNameAndValue(pChild, name, val);
-
- if (name == L"metadata") {
- ParseMetadata(pChild, metadata);
- }
- }
- EndEnumChildren
-
- // styles
-
- BeginEnumChildren(pNode, pChild) {
- DeclareNameAndValue(pChild, name, val);
-
- if (name == L"styles") {
- BeginEnumChildren(pChild, pGrandChild) { // :)
- DeclareNameAndValue(pGrandChild, name, val);
-
- if (name == L"style") {
- CAutoPtr<style_t> s(DNew style_t);
- if (s) {
- ParseStyle(pGrandChild, s);
- styles.AddTail(s);
- }
- }
- }
- EndEnumChildren
- }
- }
- EndEnumChildren
-
- // effects
-
- BeginEnumChildren(pNode, pChild) {
- DeclareNameAndValue(pChild, name, val);
-
- if (name == L"effects") {
- BeginEnumChildren(pChild, pGrandChild) { // :)
- DeclareNameAndValue(pGrandChild, name, val);
-
- if (name == L"effect") {
- CAutoPtr<effect_t> e(DNew effect_t);
- if (e) {
- ParseEffect(pGrandChild, e);
- effects.AddTail(e);
- }
- }
- }
- EndEnumChildren
- }
- }
- EndEnumChildren
-
- // subtitles
-
- BeginEnumChildren(pNode, pChild) {
- DeclareNameAndValue(pChild, name, val);
-
- if (name == L"subtitles") {
- BeginEnumChildren(pChild, pGrandChild) { // :)
- DeclareNameAndValue(pGrandChild, name, val);
-
- if (name == L"subtitle") {
- CStringW sstart = GetAttrib(L"start", pGrandChild);
- CStringW sstop = GetAttrib(L"stop", pGrandChild);
- CStringW sduration = GetAttrib(L"duration", pGrandChild);
- if (sstart.IsEmpty() || (sstop.IsEmpty() && sduration.IsEmpty())) {
- continue;
- }
-
- int start = TimeToInt(sstart);
- int stop = !sstop.IsEmpty() ? TimeToInt(sstop) : (start + TimeToInt(sduration));
-
- ParseSubtitle(pGrandChild, start, stop);
- }
- }
- EndEnumChildren
- }
- }
- EndEnumChildren
-
- return true;
- }
-
- BeginEnumChildren(pNode, pChild) {
- if (ParseUSFSubtitles(pChild)) {
- return true;
- }
- }
- EndEnumChildren
-
- return false;
+ DeclareNameAndValue(pNode, name, val);
+
+ if (name == L"usfsubtitles") {
+ // metadata
+
+ BeginEnumChildren(pNode, pChild) {
+ DeclareNameAndValue(pChild, name, val);
+
+ if (name == L"metadata") {
+ ParseMetadata(pChild, metadata);
+ }
+ }
+ EndEnumChildren
+
+ // styles
+
+ BeginEnumChildren(pNode, pChild) {
+ DeclareNameAndValue(pChild, name, val);
+
+ if (name == L"styles") {
+ BeginEnumChildren(pChild, pGrandChild) { // :)
+ DeclareNameAndValue(pGrandChild, name, val);
+
+ if (name == L"style") {
+ CAutoPtr<style_t> s(DNew style_t);
+ if (s) {
+ ParseStyle(pGrandChild, s);
+ styles.AddTail(s);
+ }
+ }
+ }
+ EndEnumChildren
+ }
+ }
+ EndEnumChildren
+
+ // effects
+
+ BeginEnumChildren(pNode, pChild) {
+ DeclareNameAndValue(pChild, name, val);
+
+ if (name == L"effects") {
+ BeginEnumChildren(pChild, pGrandChild) { // :)
+ DeclareNameAndValue(pGrandChild, name, val);
+
+ if (name == L"effect") {
+ CAutoPtr<effect_t> e(DNew effect_t);
+ if (e) {
+ ParseEffect(pGrandChild, e);
+ effects.AddTail(e);
+ }
+ }
+ }
+ EndEnumChildren
+ }
+ }
+ EndEnumChildren
+
+ // subtitles
+
+ BeginEnumChildren(pNode, pChild) {
+ DeclareNameAndValue(pChild, name, val);
+
+ if (name == L"subtitles") {
+ BeginEnumChildren(pChild, pGrandChild) { // :)
+ DeclareNameAndValue(pGrandChild, name, val);
+
+ if (name == L"subtitle") {
+ CStringW sstart = GetAttrib(L"start", pGrandChild);
+ CStringW sstop = GetAttrib(L"stop", pGrandChild);
+ CStringW sduration = GetAttrib(L"duration", pGrandChild);
+ if (sstart.IsEmpty() || (sstop.IsEmpty() && sduration.IsEmpty())) {
+ continue;
+ }
+
+ int start = TimeToInt(sstart);
+ int stop = !sstop.IsEmpty() ? TimeToInt(sstop) : (start + TimeToInt(sduration));
+
+ ParseSubtitle(pGrandChild, start, stop);
+ }
+ }
+ EndEnumChildren
+ }
+ }
+ EndEnumChildren
+
+ return true;
+ }
+
+ BeginEnumChildren(pNode, pChild) {
+ if (ParseUSFSubtitles(pChild)) {
+ return true;
+ }
+ }
+ EndEnumChildren
+
+ return false;
}
void CUSFSubtitles::ParseMetadata(CComPtr<IXMLDOMNode> pNode, metadata_t& m)
{
- DeclareNameAndValue(pNode, name, val);
-
- if (name == L"title") {
- m.title = GetText(pNode);
- } else if (name == L"date") {
- m.date = GetText(pNode);
- } else if (name == L"comment") {
- m.comment = GetText(pNode);
- } else if (name == L"author") {
- BeginEnumChildren(pNode, pChild) {
- DeclareNameAndValue(pChild, name, val);
-
- if (name == L"name") {
- m.author.name = GetText(pChild);
- } else if (name == L"email") {
- m.author.email = GetText(pChild);
- } else if (name == L"url") {
- m.author.url = GetText(pChild);
- }
- }
- EndEnumChildren
-
- return;
- } else if (name == L"language") {
- m.language.text = GetText(pNode);
- m.language.code = GetAttrib(L"code", pNode);
- } else if (name == L"languageext") {
- m.languageext.text = GetText(pNode);
- m.languageext.code = GetAttrib(L"code", pNode);
- }
-
- BeginEnumChildren(pNode, pChild) {
- ParseMetadata(pChild, metadata);
- }
- EndEnumChildren
+ DeclareNameAndValue(pNode, name, val);
+
+ if (name == L"title") {
+ m.title = GetText(pNode);
+ } else if (name == L"date") {
+ m.date = GetText(pNode);
+ } else if (name == L"comment") {
+ m.comment = GetText(pNode);
+ } else if (name == L"author") {
+ BeginEnumChildren(pNode, pChild) {
+ DeclareNameAndValue(pChild, name, val);
+
+ if (name == L"name") {
+ m.author.name = GetText(pChild);
+ } else if (name == L"email") {
+ m.author.email = GetText(pChild);
+ } else if (name == L"url") {
+ m.author.url = GetText(pChild);
+ }
+ }
+ EndEnumChildren
+
+ return;
+ } else if (name == L"language") {
+ m.language.text = GetText(pNode);
+ m.language.code = GetAttrib(L"code", pNode);
+ } else if (name == L"languageext") {
+ m.languageext.text = GetText(pNode);
+ m.languageext.code = GetAttrib(L"code", pNode);
+ }
+
+ BeginEnumChildren(pNode, pChild) {
+ ParseMetadata(pChild, metadata);
+ }
+ EndEnumChildren
}
void CUSFSubtitles::ParseStyle(CComPtr<IXMLDOMNode> pNode, style_t* s)
{
- DeclareNameAndValue(pNode, name, val);
-
- if (name == L"style") {
- s->name = GetAttrib(L"name", pNode);
- } else if (name == L"fontstyle") {
- ParseFontstyle(pNode, s->fontstyle);
- return;
- } else if (name == L"position") {
- ParsePal(pNode, s->pal);
- return;
- }
-
- BeginEnumChildren(pNode, pChild) {
- ParseStyle(pChild, s);
- }
- EndEnumChildren
+ DeclareNameAndValue(pNode, name, val);
+
+ if (name == L"style") {
+ s->name = GetAttrib(L"name", pNode);
+ } else if (name == L"fontstyle") {
+ ParseFontstyle(pNode, s->fontstyle);
+ return;
+ } else if (name == L"position") {
+ ParsePal(pNode, s->pal);
+ return;
+ }
+
+ BeginEnumChildren(pNode, pChild) {
+ ParseStyle(pChild, s);
+ }
+ EndEnumChildren
}
void CUSFSubtitles::ParseFontstyle(CComPtr<IXMLDOMNode> pNode, fontstyle_t& fs)
{
- fs.face = GetAttrib(L"face", pNode);
- fs.size = GetAttrib(L"size", pNode);
- fs.color[0] = GetAttrib(L"color", pNode);
- fs.color[1] = GetAttrib(L"back-color", pNode);
- fs.color[2] = GetAttrib(L"outline-color", pNode);
- fs.color[3] = GetAttrib(L"shadow-color", pNode);
- fs.italic = GetAttrib(L"italic", pNode);
- fs.weight = GetAttrib(L"weight", pNode);
- fs.underline = GetAttrib(L"underline", pNode);
- fs.alpha = GetAttrib(L"alpha", pNode);
- fs.outline = GetAttrib(L"outline-level", pNode);
- fs.shadow = GetAttrib(L"shadow-level", pNode);
- fs.wrap = GetAttrib(L"wrap", pNode);
+ fs.face = GetAttrib(L"face", pNode);
+ fs.size = GetAttrib(L"size", pNode);
+ fs.color[0] = GetAttrib(L"color", pNode);
+ fs.color[1] = GetAttrib(L"back-color", pNode);
+ fs.color[2] = GetAttrib(L"outline-color", pNode);
+ fs.color[3] = GetAttrib(L"shadow-color", pNode);
+ fs.italic = GetAttrib(L"italic", pNode);
+ fs.weight = GetAttrib(L"weight", pNode);
+ fs.underline = GetAttrib(L"underline", pNode);
+ fs.alpha = GetAttrib(L"alpha", pNode);
+ fs.outline = GetAttrib(L"outline-level", pNode);
+ fs.shadow = GetAttrib(L"shadow-level", pNode);
+ fs.wrap = GetAttrib(L"wrap", pNode);
}
void CUSFSubtitles::ParsePal(CComPtr<IXMLDOMNode> pNode, posattriblist_t& pal)
{
- pal.alignment = GetAttrib(L"alignment", pNode);
- pal.relativeto = GetAttrib(L"relative-to", pNode);
- pal.horizontal_margin = GetAttrib(L"horizontal-margin", pNode);
- pal.vertical_margin = GetAttrib(L"vertical-margin", pNode);
- pal.rotate[0] = GetAttrib(L"rotate-z", pNode);
- pal.rotate[1] = GetAttrib(L"rotate-x", pNode);
- pal.rotate[2] = GetAttrib(L"rotate-y", pNode);
+ pal.alignment = GetAttrib(L"alignment", pNode);
+ pal.relativeto = GetAttrib(L"relative-to", pNode);
+ pal.horizontal_margin = GetAttrib(L"horizontal-margin", pNode);
+ pal.vertical_margin = GetAttrib(L"vertical-margin", pNode);
+ pal.rotate[0] = GetAttrib(L"rotate-z", pNode);
+ pal.rotate[1] = GetAttrib(L"rotate-x", pNode);
+ pal.rotate[2] = GetAttrib(L"rotate-y", pNode);
}
void CUSFSubtitles::ParseEffect(CComPtr<IXMLDOMNode> pNode, effect_t* e)
{
- DeclareNameAndValue(pNode, name, val);
-
- if (name == L"effect") {
- e->name = GetAttrib(L"name", pNode);
- } else if (name == L"keyframes") {
- BeginEnumChildren(pNode, pChild) {
- DeclareNameAndValue(pChild, name, val);
-
- if (name == L"keyframe") {
- CAutoPtr<keyframe_t> k(DNew keyframe_t);
- if (k) {
- ParseKeyframe(pChild, k);
- e->keyframes.AddTail(k);
- }
- }
- }
- EndEnumChildren
-
- return;
- }
-
- BeginEnumChildren(pNode, pChild) {
- ParseEffect(pChild, e);
- }
- EndEnumChildren
+ DeclareNameAndValue(pNode, name, val);
+
+ if (name == L"effect") {
+ e->name = GetAttrib(L"name", pNode);
+ } else if (name == L"keyframes") {
+ BeginEnumChildren(pNode, pChild) {
+ DeclareNameAndValue(pChild, name, val);
+
+ if (name == L"keyframe") {
+ CAutoPtr<keyframe_t> k(DNew keyframe_t);
+ if (k) {
+ ParseKeyframe(pChild, k);
+ e->keyframes.AddTail(k);
+ }
+ }
+ }
+ EndEnumChildren
+
+ return;
+ }
+
+ BeginEnumChildren(pNode, pChild) {
+ ParseEffect(pChild, e);
+ }
+ EndEnumChildren
}
void CUSFSubtitles::ParseKeyframe(CComPtr<IXMLDOMNode> pNode, keyframe_t* k)
{
- DeclareNameAndValue(pNode, name, val);
-
- if (name == L"keyframe") {
- k->position = GetAttrib(L"position", pNode);
- } else if (name == L"fontstyle") {
- ParseFontstyle(pNode, k->fontstyle);
- return;
- } else if (name == L"position") {
- ParsePal(pNode, k->pal);
- return;
- }
+ DeclareNameAndValue(pNode, name, val);
+
+ if (name == L"keyframe") {
+ k->position = GetAttrib(L"position", pNode);
+ } else if (name == L"fontstyle") {
+ ParseFontstyle(pNode, k->fontstyle);
+ return;
+ } else if (name == L"position") {
+ ParsePal(pNode, k->pal);
+ return;
+ }
}
void CUSFSubtitles::ParseSubtitle(CComPtr<IXMLDOMNode> pNode, int start, int stop)
{
- DeclareNameAndValue(pNode, name, val);
-
- if (name == L"text" || name == L"karaoke") {
- CAutoPtr<text_t> t(DNew text_t);
- if (t) {
- t->start = start;
- t->stop = stop;
- t->style = GetAttrib(L"style", pNode);
- t->effect = GetAttrib(L"effect", pNode);
- ParsePal(pNode, t->pal);
- ParseText(pNode, t->str);
- texts.AddTail(t);
- }
-
- return;
- }
- // else if
-
- BeginEnumChildren(pNode, pChild) {
- ParseSubtitle(pChild, start, stop);
- }
- EndEnumChildren
+ DeclareNameAndValue(pNode, name, val);
+
+ if (name == L"text" || name == L"karaoke") {
+ CAutoPtr<text_t> t(DNew text_t);
+ if (t) {
+ t->start = start;
+ t->stop = stop;
+ t->style = GetAttrib(L"style", pNode);
+ t->effect = GetAttrib(L"effect", pNode);
+ ParsePal(pNode, t->pal);
+ ParseText(pNode, t->str);
+ texts.AddTail(t);
+ }
+
+ return;
+ }
+ // else if
+
+ BeginEnumChildren(pNode, pChild) {
+ ParseSubtitle(pChild, start, stop);
+ }
+ EndEnumChildren
}
void CUSFSubtitles::ParseText(CComPtr<IXMLDOMNode> pNode, CStringW& str)
{
- DeclareNameAndValue(pNode, name, val);
-
- CStringW prefix, postfix;
-
- if (name == L"b") {
- prefix = L"{\\b1}";
- postfix = L"{\\b}";
- } else if (name == L"i") {
- prefix = L"{\\i1}";
- postfix = L"{\\i}";
- } else if (name == L"u") {
- prefix = L"{\\u1}";
- postfix = L"{\\u}";
- } else if (name == L"font") {
- fontstyle_t fs;
- ParseFontstyle(pNode, fs);
-
- if (!fs.face.IsEmpty()) {
- prefix += L"{\\fn" + fs.face + L"}";
- postfix += L"{\\fn}";
- }
- if (!fs.size.IsEmpty()) {
- prefix += L"{\\fs" + fs.size + L"}";
- postfix += L"{\\fs}";
- }
- if (!fs.outline.IsEmpty()) {
- prefix += L"{\\bord" + fs.outline + L"}";
- postfix += L"{\\bord}";
- }
- if (!fs.shadow.IsEmpty()) {
- prefix += L"{\\shad" + fs.shadow + L"}";
- postfix += L"{\\shad}";
- }
-
- for (size_t i = 0; i < 4; i++) {
- if (!fs.color[i].IsEmpty()) {
- CStringW s;
- s.Format(L"{\\%dc&H%06x&}", i+1, ColorToDWORD(fs.color[i]));
- prefix += s;
- s.Format(L"{\\%dc}", i+1);
- postfix += s;
- }
- }
- } else if (name == L"k") {
- int t = wcstol(GetAttrib(L"t", pNode), NULL, 10);
- CStringW s;
- s.Format(L"{\\kf%d}", t / 10);
- str += s;
- return;
- } else if (name == L"br") {
- str += L"\\N";
- return;
- } else if (name == L"#text") {
- str += GetXML(pNode);
- return;
- }
-
- BeginEnumChildren(pNode, pChild) {
- CStringW s;
- ParseText(pChild, s);
- str += s;
- }
- EndEnumChildren
-
- str = prefix + str + postfix;
+ DeclareNameAndValue(pNode, name, val);
+
+ CStringW prefix, postfix;
+
+ if (name == L"b") {
+ prefix = L"{\\b1}";
+ postfix = L"{\\b}";
+ } else if (name == L"i") {
+ prefix = L"{\\i1}";
+ postfix = L"{\\i}";
+ } else if (name == L"u") {
+ prefix = L"{\\u1}";
+ postfix = L"{\\u}";
+ } else if (name == L"font") {
+ fontstyle_t fs;
+ ParseFontstyle(pNode, fs);
+
+ if (!fs.face.IsEmpty()) {
+ prefix += L"{\\fn" + fs.face + L"}";
+ postfix += L"{\\fn}";
+ }
+ if (!fs.size.IsEmpty()) {
+ prefix += L"{\\fs" + fs.size + L"}";
+ postfix += L"{\\fs}";
+ }
+ if (!fs.outline.IsEmpty()) {
+ prefix += L"{\\bord" + fs.outline + L"}";
+ postfix += L"{\\bord}";
+ }
+ if (!fs.shadow.IsEmpty()) {
+ prefix += L"{\\shad" + fs.shadow + L"}";
+ postfix += L"{\\shad}";
+ }
+
+ for (size_t i = 0; i < 4; i++) {
+ if (!fs.color[i].IsEmpty()) {
+ CStringW s;
+ s.Format(L"{\\%dc&H%06x&}", i + 1, ColorToDWORD(fs.color[i]));
+ prefix += s;
+ s.Format(L"{\\%dc}", i + 1);
+ postfix += s;
+ }
+ }
+ } else if (name == L"k") {
+ int t = wcstol(GetAttrib(L"t", pNode), NULL, 10);
+ CStringW s;
+ s.Format(L"{\\kf%d}", t / 10);
+ str += s;
+ return;
+ } else if (name == L"br") {
+ str += L"\\N";
+ return;
+ } else if (name == L"#text") {
+ str += GetXML(pNode);
+ return;
+ }
+
+ BeginEnumChildren(pNode, pChild) {
+ CStringW s;
+ ParseText(pChild, s);
+ str += s;
+ }
+ EndEnumChildren
+
+ str = prefix + str + postfix;
}
void CUSFSubtitles::ParseShape(CComPtr<IXMLDOMNode> pNode)
{
- // no specs on this yet
+ // no specs on this yet
}
diff --git a/src/Subtitles/USFSubtitles.h b/src/Subtitles/USFSubtitles.h
index c39dbe31d..0614f24df 100644
--- a/src/Subtitles/USFSubtitles.h
+++ b/src/Subtitles/USFSubtitles.h
@@ -28,70 +28,70 @@
// metadata
typedef struct {
- CStringW name, email, url;
+ CStringW name, email, url;
} author_t;
typedef struct {
- CStringW code, text;
+ CStringW code, text;
} language_t;
typedef struct {
- CStringW title, date, comment;
- author_t author;
- language_t language, languageext;
+ CStringW title, date, comment;
+ author_t author;
+ language_t language, languageext;
} metadata_t;
// style
typedef struct {
- CStringW alignment, relativeto, horizontal_margin, vertical_margin, rotate[3];
+ CStringW alignment, relativeto, horizontal_margin, vertical_margin, rotate[3];
} posattriblist_t;
typedef struct {
- CStringW face, size, color[4], weight, italic, underline, alpha, outline, shadow, wrap;
+ CStringW face, size, color[4], weight, italic, underline, alpha, outline, shadow, wrap;
} fontstyle_t;
typedef struct {
- CStringW name;
- fontstyle_t fontstyle;
- posattriblist_t pal;
+ CStringW name;
+ fontstyle_t fontstyle;
+ posattriblist_t pal;
} style_t;
// effect
typedef struct {
- CStringW position;
- fontstyle_t fontstyle;
- posattriblist_t pal;
+ CStringW position;
+ fontstyle_t fontstyle;
+ posattriblist_t pal;
} keyframe_t;
typedef struct {
- CStringW name;
- CAutoPtrList<keyframe_t> keyframes;
+ CStringW name;
+ CAutoPtrList<keyframe_t> keyframes;
} effect_t;
// subtitle/text
typedef struct {
- int start, stop;
- CStringW effect, style, str;
- posattriblist_t pal;
+ int start, stop;
+ CStringW effect, style, str;
+ posattriblist_t pal;
} text_t;
class CUSFSubtitles
{
- bool ParseUSFSubtitles(CComPtr<IXMLDOMNode> pNode);
- void ParseMetadata(CComPtr<IXMLDOMNode> pNode, metadata_t& m);
- void ParseStyle(CComPtr<IXMLDOMNode> pNode, style_t* s);
- void ParseFontstyle(CComPtr<IXMLDOMNode> pNode, fontstyle_t& fs);
- void ParsePal(CComPtr<IXMLDOMNode> pNode, posattriblist_t& pal);
- void ParseEffect(CComPtr<IXMLDOMNode> pNode, effect_t* e);
- void ParseKeyframe(CComPtr<IXMLDOMNode> pNode, keyframe_t* k);
- void ParseSubtitle(CComPtr<IXMLDOMNode> pNode, int start, int stop);
- void ParseText(CComPtr<IXMLDOMNode> pNode, CStringW& assstr);
- void ParseShape(CComPtr<IXMLDOMNode> pNode);
+ bool ParseUSFSubtitles(CComPtr<IXMLDOMNode> pNode);
+ void ParseMetadata(CComPtr<IXMLDOMNode> pNode, metadata_t& m);
+ void ParseStyle(CComPtr<IXMLDOMNode> pNode, style_t* s);
+ void ParseFontstyle(CComPtr<IXMLDOMNode> pNode, fontstyle_t& fs);
+ void ParsePal(CComPtr<IXMLDOMNode> pNode, posattriblist_t& pal);
+ void ParseEffect(CComPtr<IXMLDOMNode> pNode, effect_t* e);
+ void ParseKeyframe(CComPtr<IXMLDOMNode> pNode, keyframe_t* k);
+ void ParseSubtitle(CComPtr<IXMLDOMNode> pNode, int start, int stop);
+ void ParseText(CComPtr<IXMLDOMNode> pNode, CStringW& assstr);
+ void ParseShape(CComPtr<IXMLDOMNode> pNode);
public:
- CUSFSubtitles();
- virtual ~CUSFSubtitles();
+ CUSFSubtitles();
+ virtual ~CUSFSubtitles();
- bool Read(LPCTSTR fn);
- //bool Write(LPCTSTR fn); // TODO
+ bool Read(LPCTSTR fn);
+ //bool Write(LPCTSTR fn); // TODO
- metadata_t metadata;
- CAutoPtrList<style_t> styles;
- CAutoPtrList<effect_t> effects;
- CAutoPtrList<text_t> texts;
+ metadata_t metadata;
+ CAutoPtrList<style_t> styles;
+ CAutoPtrList<effect_t> effects;
+ CAutoPtrList<text_t> texts;
- bool ConvertToSTS(CSimpleTextSubtitle& sts);
- //bool ConvertFromSTS(CSimpleTextSubtitle& sts); // TODO
+ bool ConvertToSTS(CSimpleTextSubtitle& sts);
+ //bool ConvertFromSTS(CSimpleTextSubtitle& sts); // TODO
};
diff --git a/src/Subtitles/VobSubFile.cpp b/src/Subtitles/VobSubFile.cpp
index 0a4576a46..ba0f5aee6 100644
--- a/src/Subtitles/VobSubFile.cpp
+++ b/src/Subtitles/VobSubFile.cpp
@@ -31,176 +31,176 @@
//
struct lang_type {
- unsigned short id;
- LPCSTR lang_long;
+ unsigned short id;
+ LPCSTR lang_long;
} lang_tbl[] = {
- {'--', "(Not detected)"},
- {'cc', "Closed Caption"},
- {'aa', "Afar"},
- {'ab', "Abkhazian"},
- {'af', "Afrikaans"},
- {'am', "Amharic"},
- {'ar', "Arabic"},
- {'as', "Assamese"},
- {'ay', "Aymara"},
- {'az', "Azerbaijani"},
- {'ba', "Bashkir"},
- {'be', "Byelorussian"},
- {'bg', "Bulgarian"},
- {'bh', "Bihari"},
- {'bi', "Bislama"},
- {'bn', "Bengali; Bangla"},
- {'bo', "Tibetan"},
- {'br', "Breton"},
- {'ca', "Catalan"},
- {'co', "Corsican"},
- {'cs', "Czech"},
- {'cy', "Welsh"},
- {'da', "Dansk"},
- {'de', "Deutsch"},
- {'dz', "Bhutani"},
- {'el', "Greek"},
- {'en', "English"},
- {'eo', "Esperanto"},
- {'es', "Espanol"},
- {'et', "Estonian"},
- {'eu', "Basque"},
- {'fa', "Persian"},
- {'fi', "Finnish"},
- {'fj', "Fiji"},
- {'fo', "Faroese"},
- {'fr', "Francais"},
- {'fy', "Frisian"},
- {'ga', "Irish"},
- {'gd', "Scots Gaelic"},
- {'gl', "Galician"},
- {'gn', "Guarani"},
- {'gu', "Gujarati"},
- {'ha', "Hausa"},
- {'he', "Hebrew"},
- {'hi', "Hindi"},
- {'hr', "Hrvatski"},
- {'hu', "Hungarian"},
- {'hy', "Armenian"},
- {'ia', "Interlingua"},
- {'id', "Indonesian"},
- {'ie', "Interlingue"},
- {'ik', "Inupiak"},
- {'in', "Indonesian"},
- {'is', "Islenska"},
- {'it', "Italiano"},
- {'iu', "Inuktitut"},
- {'iw', "Hebrew"},
- {'ja', "Japanese"},
- {'ji', "Yiddish"},
- {'jw', "Javanese"},
- {'ka', "Georgian"},
- {'kk', "Kazakh"},
- {'kl', "Greenlandic"},
- {'km', "Cambodian"},
- {'kn', "Kannada"},
- {'ko', "Korean"},
- {'ks', "Kashmiri"},
- {'ku', "Kurdish"},
- {'ky', "Kirghiz"},
- {'la', "Latin"},
- {'ln', "Lingala"},
- {'lo', "Laothian"},
- {'lt', "Lithuanian"},
- {'lv', "Latvian, Lettish"},
- {'mg', "Malagasy"},
- {'mi', "Maori"},
- {'mk', "Macedonian"},
- {'ml', "Malayalam"},
- {'mn', "Mongolian"},
- {'mo', "Moldavian"},
- {'mr', "Marathi"},
- {'ms', "Malay"},
- {'mt', "Maltese"},
- {'my', "Burmese"},
- {'na', "Nauru"},
- {'ne', "Nepali"},
- {'nl', "Nederlands"},
- {'no', "Norsk"},
- {'oc', "Occitan"},
- {'om', "(Afan) Oromo"},
- {'or', "Oriya"},
- {'pa', "Punjabi"},
- {'pl', "Polish"},
- {'ps', "Pashto, Pushto"},
- {'pt', "Portugues"},
- {'qu', "Quechua"},
- {'rm', "Rhaeto-Romance"},
- {'rn', "Kirundi"},
- {'ro', "Romanian"},
- {'ru', "Russian"},
- {'rw', "Kinyarwanda"},
- {'sa', "Sanskrit"},
- {'sd', "Sindhi"},
- {'sg', "Sangho"},
- {'sh', "Serbo-Croatian"},
- {'si', "Sinhalese"},
- {'sk', "Slovak"},
- {'sl', "Slovenian"},
- {'sm', "Samoan"},
- {'sn', "Shona"},
- {'so', "Somali"},
- {'sq', "Albanian"},
- {'sr', "Serbian"},
- {'ss', "Siswati"},
- {'st', "Sesotho"},
- {'su', "Sundanese"},
- {'sv', "Svenska"},
- {'sw', "Swahili"},
- {'ta', "Tamil"},
- {'te', "Telugu"},
- {'tg', "Tajik"},
- {'th', "Thai"},
- {'ti', "Tigrinya"},
- {'tk', "Turkmen"},
- {'tl', "Tagalog"},
- {'tn', "Setswana"},
- {'to', "Tonga"},
- {'tr', "Turkish"},
- {'ts', "Tsonga"},
- {'tt', "Tatar"},
- {'tw', "Twi"},
- {'ug', "Uighur"},
- {'uk', "Ukrainian"},
- {'ur', "Urdu"},
- {'uz', "Uzbek"},
- {'vi', "Vietnamese"},
- {'vo', "Volapuk"},
- {'wo', "Wolof"},
- {'xh', "Xhosa"},
- {'yi', "Yiddish"}, // formerly ji
- {'yo', "Yoruba"},
- {'za', "Zhuang"},
- {'zh', "Chinese"},
- {'zu', "Zulu"},
+ {'--', "(Not detected)"},
+ {'cc', "Closed Caption"},
+ {'aa', "Afar"},
+ {'ab', "Abkhazian"},
+ {'af', "Afrikaans"},
+ {'am', "Amharic"},
+ {'ar', "Arabic"},
+ {'as', "Assamese"},
+ {'ay', "Aymara"},
+ {'az', "Azerbaijani"},
+ {'ba', "Bashkir"},
+ {'be', "Byelorussian"},
+ {'bg', "Bulgarian"},
+ {'bh', "Bihari"},
+ {'bi', "Bislama"},
+ {'bn', "Bengali; Bangla"},
+ {'bo', "Tibetan"},
+ {'br', "Breton"},
+ {'ca', "Catalan"},
+ {'co', "Corsican"},
+ {'cs', "Czech"},
+ {'cy', "Welsh"},
+ {'da', "Dansk"},
+ {'de', "Deutsch"},
+ {'dz', "Bhutani"},
+ {'el', "Greek"},
+ {'en', "English"},
+ {'eo', "Esperanto"},
+ {'es', "Espanol"},
+ {'et', "Estonian"},
+ {'eu', "Basque"},
+ {'fa', "Persian"},
+ {'fi', "Finnish"},
+ {'fj', "Fiji"},
+ {'fo', "Faroese"},
+ {'fr', "Francais"},
+ {'fy', "Frisian"},
+ {'ga', "Irish"},
+ {'gd', "Scots Gaelic"},
+ {'gl', "Galician"},
+ {'gn', "Guarani"},
+ {'gu', "Gujarati"},
+ {'ha', "Hausa"},
+ {'he', "Hebrew"},
+ {'hi', "Hindi"},
+ {'hr', "Hrvatski"},
+ {'hu', "Hungarian"},
+ {'hy', "Armenian"},
+ {'ia', "Interlingua"},
+ {'id', "Indonesian"},
+ {'ie', "Interlingue"},
+ {'ik', "Inupiak"},
+ {'in', "Indonesian"},
+ {'is', "Islenska"},
+ {'it', "Italiano"},
+ {'iu', "Inuktitut"},
+ {'iw', "Hebrew"},
+ {'ja', "Japanese"},
+ {'ji', "Yiddish"},
+ {'jw', "Javanese"},
+ {'ka', "Georgian"},
+ {'kk', "Kazakh"},
+ {'kl', "Greenlandic"},
+ {'km', "Cambodian"},
+ {'kn', "Kannada"},
+ {'ko', "Korean"},
+ {'ks', "Kashmiri"},
+ {'ku', "Kurdish"},
+ {'ky', "Kirghiz"},
+ {'la', "Latin"},
+ {'ln', "Lingala"},
+ {'lo', "Laothian"},
+ {'lt', "Lithuanian"},
+ {'lv', "Latvian, Lettish"},
+ {'mg', "Malagasy"},
+ {'mi', "Maori"},
+ {'mk', "Macedonian"},
+ {'ml', "Malayalam"},
+ {'mn', "Mongolian"},
+ {'mo', "Moldavian"},
+ {'mr', "Marathi"},
+ {'ms', "Malay"},
+ {'mt', "Maltese"},
+ {'my', "Burmese"},
+ {'na', "Nauru"},
+ {'ne', "Nepali"},
+ {'nl', "Nederlands"},
+ {'no', "Norsk"},
+ {'oc', "Occitan"},
+ {'om', "(Afan) Oromo"},
+ {'or', "Oriya"},
+ {'pa', "Punjabi"},
+ {'pl', "Polish"},
+ {'ps', "Pashto, Pushto"},
+ {'pt', "Portugues"},
+ {'qu', "Quechua"},
+ {'rm', "Rhaeto-Romance"},
+ {'rn', "Kirundi"},
+ {'ro', "Romanian"},
+ {'ru', "Russian"},
+ {'rw', "Kinyarwanda"},
+ {'sa', "Sanskrit"},
+ {'sd', "Sindhi"},
+ {'sg', "Sangho"},
+ {'sh', "Serbo-Croatian"},
+ {'si', "Sinhalese"},
+ {'sk', "Slovak"},
+ {'sl', "Slovenian"},
+ {'sm', "Samoan"},
+ {'sn', "Shona"},
+ {'so', "Somali"},
+ {'sq', "Albanian"},
+ {'sr', "Serbian"},
+ {'ss', "Siswati"},
+ {'st', "Sesotho"},
+ {'su', "Sundanese"},
+ {'sv', "Svenska"},
+ {'sw', "Swahili"},
+ {'ta', "Tamil"},
+ {'te', "Telugu"},
+ {'tg', "Tajik"},
+ {'th', "Thai"},
+ {'ti', "Tigrinya"},
+ {'tk', "Turkmen"},
+ {'tl', "Tagalog"},
+ {'tn', "Setswana"},
+ {'to', "Tonga"},
+ {'tr', "Turkish"},
+ {'ts', "Tsonga"},
+ {'tt', "Tatar"},
+ {'tw', "Twi"},
+ {'ug', "Uighur"},
+ {'uk', "Ukrainian"},
+ {'ur', "Urdu"},
+ {'uz', "Uzbek"},
+ {'vi', "Vietnamese"},
+ {'vo', "Volapuk"},
+ {'wo', "Wolof"},
+ {'xh', "Xhosa"},
+ {'yi', "Yiddish"}, // formerly ji
+ {'yo', "Yoruba"},
+ {'za', "Zhuang"},
+ {'zh', "Chinese"},
+ {'zu', "Zulu"},
};
int find_lang(unsigned short id)
{
- int mid, lo = 0, hi = _countof(lang_tbl) - 1;
+ int mid, lo = 0, hi = _countof(lang_tbl) - 1;
- while (lo < hi) {
- mid = (lo + hi) >> 1;
- if (id < lang_tbl[mid].id) {
- hi = mid;
- } else if (id > lang_tbl[mid].id) {
- lo = mid + 1;
- } else {
- return mid;
- }
- }
+ while (lo < hi) {
+ mid = (lo + hi) >> 1;
+ if (id < lang_tbl[mid].id) {
+ hi = mid;
+ } else if (id > lang_tbl[mid].id) {
+ lo = mid + 1;
+ } else {
+ return mid;
+ }
+ }
- return (id == lang_tbl[lo].id ? lo : 0);
+ return (id == lang_tbl[lo].id ? lo : 0);
}
CString FindLangFromId(WORD id)
{
- return CString(lang_tbl[find_lang(id)].lang_long);
+ return CString(lang_tbl[find_lang(id)].lang_long);
}
//
@@ -208,8 +208,8 @@ CString FindLangFromId(WORD id)
//
CVobSubFile::CVobSubFile(CCritSec* pLock)
- : CSubPicProviderImpl(pLock)
- , m_sub(1024*1024)
+ : CSubPicProviderImpl(pLock)
+ , m_sub(1024 * 1024)
{
}
@@ -221,523 +221,523 @@ CVobSubFile::~CVobSubFile()
bool CVobSubFile::Copy(CVobSubFile& vsf)
{
- Close();
+ Close();
- *(CVobSubSettings*)this = *(CVobSubSettings*)&vsf;
- m_title = vsf.m_title;
- m_iLang = vsf.m_iLang;
+ *(CVobSubSettings*)this = *(CVobSubSettings*)&vsf;
+ m_title = vsf.m_title;
+ m_iLang = vsf.m_iLang;
- m_sub.SetLength(vsf.m_sub.GetLength());
- m_sub.SeekToBegin();
+ m_sub.SetLength(vsf.m_sub.GetLength());
+ m_sub.SeekToBegin();
- for (size_t i = 0; i < 32; i++) {
- SubLang& src = vsf.m_langs[i];
- SubLang& dst = m_langs[i];
+ for (size_t i = 0; i < 32; i++) {
+ SubLang& src = vsf.m_langs[i];
+ SubLang& dst = m_langs[i];
- dst.id = src.id;
- dst.name = src.name;
- dst.alt = src.alt;
+ dst.id = src.id;
+ dst.name = src.name;
+ dst.alt = src.alt;
- for (size_t j = 0; j < src.subpos.GetCount(); j++) {
- SubPos& sp = src.subpos[j];
- if (!sp.fValid) {
- continue;
- }
+ for (size_t j = 0; j < src.subpos.GetCount(); j++) {
+ SubPos& sp = src.subpos[j];
+ if (!sp.fValid) {
+ continue;
+ }
- if (sp.filepos != (__int64)vsf.m_sub.Seek(sp.filepos, CFile::begin)) {
- continue;
- }
+ if (sp.filepos != (__int64)vsf.m_sub.Seek(sp.filepos, CFile::begin)) {
+ continue;
+ }
- sp.filepos = m_sub.GetPosition();
+ sp.filepos = m_sub.GetPosition();
- BYTE buff[2048];
- vsf.m_sub.Read(buff, 2048);
- m_sub.Write(buff, 2048);
+ BYTE buff[2048];
+ vsf.m_sub.Read(buff, 2048);
+ m_sub.Write(buff, 2048);
- WORD packetsize = (buff[buff[0x16]+0x18]<<8) | buff[buff[0x16]+0x19];
+ WORD packetsize = (buff[buff[0x16] + 0x18] << 8) | buff[buff[0x16] + 0x19];
- for (int k = 0, size, sizeleft = packetsize - 4;
- k < packetsize - 4;
- k += size, sizeleft -= size) {
- int hsize = buff[0x16]+0x18 + ((buff[0x15]&0x80) ? 4 : 0);
- size = min(sizeleft, 2048 - hsize);
+ for (int k = 0, size, sizeleft = packetsize - 4;
+ k < packetsize - 4;
+ k += size, sizeleft -= size) {
+ int hsize = buff[0x16] + 0x18 + ((buff[0x15] & 0x80) ? 4 : 0);
+ size = min(sizeleft, 2048 - hsize);
- if (size != sizeleft) {
- while (vsf.m_sub.Read(buff, 2048)) {
- if (!(buff[0x15]&0x80) && buff[buff[0x16]+0x17] == (i|0x20)) {
- break;
- }
- }
+ if (size != sizeleft) {
+ while (vsf.m_sub.Read(buff, 2048)) {
+ if (!(buff[0x15] & 0x80) && buff[buff[0x16] + 0x17] == (i | 0x20)) {
+ break;
+ }
+ }
- m_sub.Write(buff, 2048);
- }
- }
+ m_sub.Write(buff, 2048);
+ }
+ }
- dst.subpos.Add(sp);
- }
- }
+ dst.subpos.Add(sp);
+ }
+ }
- m_sub.SetLength(m_sub.GetPosition());
+ m_sub.SetLength(m_sub.GetPosition());
- return true;
+ return true;
}
//
void CVobSubFile::TrimExtension(CString& fn)
{
- int i = fn.ReverseFind('.');
- if (i > 0) {
- CString ext = fn.Mid(i).MakeLower();
- if (ext == _T(".ifo") || ext == _T(".idx") || ext == _T(".sub")
- || ext == _T(".sst") || ext == _T(".son") || ext == _T(".rar")) {
- fn = fn.Left(i);
- }
- }
+ int i = fn.ReverseFind('.');
+ if (i > 0) {
+ CString ext = fn.Mid(i).MakeLower();
+ if (ext == _T(".ifo") || ext == _T(".idx") || ext == _T(".sub")
+ || ext == _T(".sst") || ext == _T(".son") || ext == _T(".rar")) {
+ fn = fn.Left(i);
+ }
+ }
}
bool CVobSubFile::Open(CString fn)
{
- TrimExtension(fn);
+ TrimExtension(fn);
- do {
- Close();
+ do {
+ Close();
- int ver;
- if (!ReadIdx(fn + _T(".idx"), ver)) {
- break;
- }
+ int ver;
+ if (!ReadIdx(fn + _T(".idx"), ver)) {
+ break;
+ }
- if (ver < 6 && !ReadIfo(fn + _T(".ifo"))) {
- break;
- }
+ if (ver < 6 && !ReadIfo(fn + _T(".ifo"))) {
+ break;
+ }
- if (!ReadSub(fn + _T(".sub")) && !ReadRar(fn + _T(".rar"))) {
- break;
- }
+ if (!ReadSub(fn + _T(".sub")) && !ReadRar(fn + _T(".rar"))) {
+ break;
+ }
- m_title = fn;
+ m_title = fn;
- for (int i = 0; i < 32; i++) {
- CAtlArray<SubPos>& sp = m_langs[i].subpos;
+ for (int i = 0; i < 32; i++) {
+ CAtlArray<SubPos>& sp = m_langs[i].subpos;
- for (size_t j = 0; j < sp.GetCount(); j++) {
- sp[j].stop = sp[j].start;
- sp[j].fForced = false;
+ for (size_t j = 0; j < sp.GetCount(); j++) {
+ sp[j].stop = sp[j].start;
+ sp[j].fForced = false;
- int packetsize = 0, datasize = 0;
- BYTE* buff = GetPacket((int)j, packetsize, datasize, i);
- if (!buff) {
- continue;
- }
+ int packetsize = 0, datasize = 0;
+ BYTE* buff = GetPacket((int)j, packetsize, datasize, i);
+ if (!buff) {
+ continue;
+ }
- m_img.delay = j+1 < sp.GetCount() ? sp[j+1].start - sp[j].start : 3000;
- m_img.GetPacketInfo(buff, packetsize, datasize);
- if (j+1 < sp.GetCount()) {
- m_img.delay = min(m_img.delay, sp[j+1].start - sp[j].start);
- }
+ m_img.delay = j + 1 < sp.GetCount() ? sp[j + 1].start - sp[j].start : 3000;
+ m_img.GetPacketInfo(buff, packetsize, datasize);
+ if (j + 1 < sp.GetCount()) {
+ m_img.delay = min(m_img.delay, sp[j + 1].start - sp[j].start);
+ }
- sp[j].stop = sp[j].start + m_img.delay;
- sp[j].fForced = m_img.fForced;
+ sp[j].stop = sp[j].start + m_img.delay;
+ sp[j].fForced = m_img.fForced;
- if (j > 0 && sp[j-1].stop > sp[j].start) {
- sp[j-1].stop = sp[j].start;
- }
+ if (j > 0 && sp[j - 1].stop > sp[j].start) {
+ sp[j - 1].stop = sp[j].start;
+ }
- delete [] buff;
- }
- }
+ delete [] buff;
+ }
+ }
- return true;
- } while (false);
+ return true;
+ } while (false);
- Close();
+ Close();
- return false;
+ return false;
}
bool CVobSubFile::Save(CString fn, SubFormat sf)
{
- TrimExtension(fn);
-
- CVobSubFile vsf(NULL);
- if (!vsf.Copy(*this)) {
- return false;
- }
-
- switch (sf) {
- case VobSub:
- return vsf.SaveVobSub(fn);
- break;
- case WinSubMux:
- return vsf.SaveWinSubMux(fn);
- break;
- case Scenarist:
- return vsf.SaveScenarist(fn);
- break;
- case Maestro:
- return vsf.SaveMaestro(fn);
- break;
- default:
- break;
- }
-
- return false;
+ TrimExtension(fn);
+
+ CVobSubFile vsf(NULL);
+ if (!vsf.Copy(*this)) {
+ return false;
+ }
+
+ switch (sf) {
+ case VobSub:
+ return vsf.SaveVobSub(fn);
+ break;
+ case WinSubMux:
+ return vsf.SaveWinSubMux(fn);
+ break;
+ case Scenarist:
+ return vsf.SaveScenarist(fn);
+ break;
+ case Maestro:
+ return vsf.SaveMaestro(fn);
+ break;
+ default:
+ break;
+ }
+
+ return false;
}
void CVobSubFile::Close()
{
- InitSettings();
- m_title.Empty();
- m_sub.SetLength(0);
- m_img.Invalidate();
- m_iLang = -1;
- for (size_t i = 0; i < 32; i++) {
- m_langs[i].id = 0;
- m_langs[i].name.Empty();
- m_langs[i].alt.Empty();
- m_langs[i].subpos.RemoveAll();
- }
+ InitSettings();
+ m_title.Empty();
+ m_sub.SetLength(0);
+ m_img.Invalidate();
+ m_iLang = -1;
+ for (size_t i = 0; i < 32; i++) {
+ m_langs[i].id = 0;
+ m_langs[i].name.Empty();
+ m_langs[i].alt.Empty();
+ m_langs[i].subpos.RemoveAll();
+ }
}
//
bool CVobSubFile::ReadIdx(CString fn, int& ver)
{
- CWebTextFile f;
- if (!f.Open(fn)) {
- return false;
- }
-
- bool fError = false;
-
- int id = -1, delay = 0, vobid = -1, cellid = -1;
- __int64 celltimestamp = 0;
-
- CString str;
- for (ptrdiff_t line = 0; !fError && f.ReadString(str); line++) {
- str.Trim();
-
- if (line == 0) {
- TCHAR buff[] = _T("VobSub index file, v");
-
- const TCHAR* s = str;
-
- int i = str.Find(buff);
- if (i < 0 || _stscanf_s(&s[i+_tcslen(buff)], _T("%d"), &ver) != 1
- || ver > VOBSUBIDXVER) {
- AfxMessageBox(_T("Wrong file version!"));
- fError = true;
- continue;
- }
- } else if (!str.GetLength()) {
- continue;
- } else if (str[0] == _T('#')) {
- TCHAR buff[] = _T("Vob/Cell ID:");
-
- const TCHAR* s = str;
-
- int i = str.Find(buff);
- if (i >= 0) {
- _stscanf_s(&s[i+_tcslen(buff)], _T("%d, %d (PTS: %d)"), &vobid, &cellid, &celltimestamp);
- }
-
- continue;
- }
-
- int i = str.Find(':');
- if (i <= 0) {
- continue;
- }
-
- CString entry = str.Left(i).MakeLower();
-
- str = str.Mid(i+1);
- str.Trim();
- if (str.IsEmpty()) {
- continue;
- }
-
- if (entry == _T("size")) {
- int x, y;
- if (_stscanf_s(str, _T("%dx%d"), &x, &y) != 2) {
- fError = true;
- }
- m_size.cx = x;
- m_size.cy = y;
- } else if (entry == _T("org")) {
- if (_stscanf_s(str, _T("%d,%d"), &m_x, &m_y) != 2) {
- fError = true;
- } else {
- m_org = CPoint(m_x, m_y);
- }
- } else if (entry == _T("scale")) {
- if (ver < 5) {
- int scale = 100;
- if (_stscanf_s(str, _T("%d%%"), &scale) != 1) {
- fError = true;
- }
- m_scale_x = m_scale_y = scale;
- } else {
- if (_stscanf_s(str, _T("%d%%,%d%%"), &m_scale_x, &m_scale_y) != 2) {
- fError = true;
- }
- }
- } else if (entry == _T("alpha")) {
- if (_stscanf_s(str, _T("%d"), &m_alpha) != 1) {
- fError = true;
- }
- } else if (entry == _T("smooth")) {
- str.MakeLower();
-
- if (str.Find(_T("old")) >= 0 || str.Find(_T("2")) >= 0) {
- m_fSmooth = 2;
- } else if (str.Find(_T("on")) >= 0 || str.Find(_T("1")) >= 0) {
- m_fSmooth = 1;
- } else if (str.Find(_T("off")) >= 0 || str.Find(_T("0")) >= 0) {
- m_fSmooth = 0;
- } else {
- fError = true;
- }
- } else if (entry == _T("fadein/out")) {
- if (_stscanf_s(str, _T("%d,%d"), &m_fadein, &m_fadeout) != 2) {
- fError = true;
- }
- } else if (entry == _T("align")) {
- str.MakeLower();
-
- int i = 0, j = 0;
- for (CString token = str.Tokenize(_T(" "), i);
- j < 3 && !fError && !token.IsEmpty();
- token = str.Tokenize(_T(" "), i), j++) {
- if (j == 0) {
- if (token == _T("on") || token == _T("1")) {
- m_fAlign = true;
- } else if (token == _T("off") || token == _T("0")) {
- m_fAlign = false;
- } else {
- fError = true;
- }
- } else if (j == 1) {
- if (token == _T("at")) {
- j--;
- continue;
- }
-
- if (token == _T("left")) {
- m_alignhor = 0;
- } else if (token == _T("center")) {
- m_alignhor = 1;
- } else if (token == _T("right")) {
- m_alignhor = 2;
- } else {
- fError = true;
- }
- } else if (j == 2) {
- if (token == _T("top")) {
- m_alignver = 0;
- } else if (token == _T("center")) {
- m_alignver = 1;
- } else if (token == _T("bottom")) {
- m_alignver = 2;
- } else {
- fError = true;
- }
- }
- }
- } else if (entry == _T("time offset")) {
- bool fNegative = false;
- if (str[0] == '-') {
- fNegative = true;
- }
- str.TrimLeft(_T("+-"));
-
- TCHAR c;
- int hh, mm, ss, ms;
- int n = _stscanf_s(str, _T("%d%c%d%c%d%c%d"), &hh, &c, sizeof(TCHAR),
- &mm, &c, sizeof(TCHAR), &ss, &c, sizeof(TCHAR), &ms);
-
- m_toff = n == 1
- ? hh * (fNegative ? -1 : 1)
- : n == 4+3
- ? (hh*60*60*1000 + mm*60*1000 + ss*1000 + ms) * (fNegative ? -1 : 1)
- : fError = true, 0;
- } else if (entry == _T("forced subs")) {
- str.MakeLower();
-
- if (str.Find(_T("on")) >= 0 || str.Find(_T("1")) >= 0) {
- m_fOnlyShowForcedSubs = true;
- } else if (str.Find(_T("off")) >= 0 || str.Find(_T("0")) >= 0) {
- m_fOnlyShowForcedSubs = false;
- } else {
- fError = true;
- }
- } else if (entry == _T("langidx")) {
- if (_stscanf_s(str, _T("%d"), &m_iLang) != 1) {
- fError = true;
- }
- } else if (entry == _T("palette")) {
- if (_stscanf_s(str, _T("%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x"),
- &m_orgpal[0], &m_orgpal[1], &m_orgpal[2], &m_orgpal[3],
- &m_orgpal[4], &m_orgpal[5], &m_orgpal[6], &m_orgpal[7],
- &m_orgpal[8], &m_orgpal[9], &m_orgpal[10], &m_orgpal[11],
- &m_orgpal[12], &m_orgpal[13], &m_orgpal[14], &m_orgpal[15]
- ) != 16) {
- fError = true;
- }
- } else if (entry == _T("custom colors")) {
- str.MakeLower();
-
- if (str.Find(_T("on")) == 0 || str.Find(_T("1")) == 0) {
- m_fCustomPal = true;
- } else if (str.Find(_T("off")) == 0 || str.Find(_T("0")) == 0) {
- m_fCustomPal = false;
- } else {
- fError = true;
- }
-
- i = str.Find(_T("tridx:"));
- if (i < 0) {
- fError = true;
- continue;
- }
- str = str.Mid(i + (int)_tcslen(_T("tridx:")));
-
- int tridx;
- if (_stscanf_s(str, _T("%x"), &tridx) != 1) {
- fError = true;
- continue;
- }
- tridx = ((tridx&0x1000)>>12) | ((tridx&0x100)>>7) | ((tridx&0x10)>>2) | ((tridx&1)<<3);
-
- i = str.Find(_T("colors:"));
- if (i < 0) {
- fError = true;
- continue;
- }
- str = str.Mid(i + (int)_tcslen(_T("colors:")));
-
- RGBQUAD pal[4];
- if (_stscanf_s(str, _T("%x,%x,%x,%x"), &pal[0], &pal[1], &pal[2], &pal[3]) != 4) {
- fError = true;
- continue;
- }
-
- SetCustomPal(pal, tridx);
- } else if (entry == _T("id")) {
- str.MakeLower();
-
- int langid = ((str[0]&0xff)<<8)|(str[1]&0xff);
-
- i = str.Find(_T("index:"));
- if (i < 0) {
- fError = true;
- continue;
- }
- str = str.Mid(i + (int)_tcslen(_T("index:")));
-
- if (_stscanf_s(str, _T("%d"), &id) != 1 || id < 0 || id >= 32) {
- fError = true;
- continue;
- }
- if (m_iLang < 0) {
- m_iLang = id;
- }
-
- m_langs[id].id = langid;
- m_langs[id].name = lang_tbl[find_lang(langid)].lang_long;
- m_langs[id].alt = lang_tbl[find_lang(langid)].lang_long;
-
- delay = 0;
- } else if (id >= 0 && entry == _T("alt")) {
- m_langs[id].alt = str;
- } else if (id >= 0 && entry == _T("delay")) {
- bool fNegative = false;
- if (str[0] == '-') {
- fNegative = true;
- }
- str.TrimLeft(_T("+-"));
-
- TCHAR c;
- int hh, mm, ss, ms;
- if (_stscanf_s(str, _T("%d%c%d%c%d%c%d"), &hh, &c, sizeof(TCHAR),
- &mm, &c, sizeof(TCHAR), &ss, &c, sizeof(TCHAR), &ms) != 4+3) {
- fError = true;
- continue;
- }
-
- delay += (hh*60*60*1000 + mm*60*1000 + ss*1000 + ms) * (fNegative ? -1 : 1);
- } else if (id >= 0 && entry == _T("timestamp")) {
- SubPos sb;
-
- sb.vobid = vobid;
- sb.cellid = cellid;
- sb.celltimestamp = celltimestamp;
- sb.fValid = true;
-
- bool fNegative = false;
- if (str[0] == '-') {
- fNegative = true;
- }
- str.TrimLeft(_T("+-"));
-
- TCHAR c;
- int hh, mm, ss, ms;
- if (_stscanf_s(str, _T("%d%c%d%c%d%c%d"), &hh, &c, sizeof(TCHAR),
- &mm, &c, sizeof(TCHAR), &ss, &c, sizeof(TCHAR), &ms) != 4+3) {
- fError = true;
- continue;
- }
-
- sb.start = (hh*60*60*1000 + mm*60*1000 + ss*1000 + ms) * (fNegative ? -1 : 1) + delay;
-
- i = str.Find(_T("filepos:"));
- if (i < 0) {
- fError = true;
- continue;
- }
- str = str.Mid(i + (int)_tcslen(_T("filepos:")));
-
- if (_stscanf_s(str, _T("%I64x"), &sb.filepos) != 1) {
- fError = true;
- continue;
- }
-
- if (delay < 0 && m_langs[id].subpos.GetCount() > 0) {
- __int64 ts = m_langs[id].subpos[m_langs[id].subpos.GetCount()-1].start;
-
- if (sb.start < ts) {
- delay += (int)(ts - sb.start);
- sb.start = ts;
- }
- }
-
- m_langs[id].subpos.Add(sb);
- } else {
- fError = true;
- }
- }
-
- return !fError;
+ CWebTextFile f;
+ if (!f.Open(fn)) {
+ return false;
+ }
+
+ bool fError = false;
+
+ int id = -1, delay = 0, vobid = -1, cellid = -1;
+ __int64 celltimestamp = 0;
+
+ CString str;
+ for (ptrdiff_t line = 0; !fError && f.ReadString(str); line++) {
+ str.Trim();
+
+ if (line == 0) {
+ TCHAR buff[] = _T("VobSub index file, v");
+
+ const TCHAR* s = str;
+
+ int i = str.Find(buff);
+ if (i < 0 || _stscanf_s(&s[i + _tcslen(buff)], _T("%d"), &ver) != 1
+ || ver > VOBSUBIDXVER) {
+ AfxMessageBox(_T("Wrong file version!"));
+ fError = true;
+ continue;
+ }
+ } else if (!str.GetLength()) {
+ continue;
+ } else if (str[0] == _T('#')) {
+ TCHAR buff[] = _T("Vob/Cell ID:");
+
+ const TCHAR* s = str;
+
+ int i = str.Find(buff);
+ if (i >= 0) {
+ _stscanf_s(&s[i + _tcslen(buff)], _T("%d, %d (PTS: %d)"), &vobid, &cellid, &celltimestamp);
+ }
+
+ continue;
+ }
+
+ int i = str.Find(':');
+ if (i <= 0) {
+ continue;
+ }
+
+ CString entry = str.Left(i).MakeLower();
+
+ str = str.Mid(i + 1);
+ str.Trim();
+ if (str.IsEmpty()) {
+ continue;
+ }
+
+ if (entry == _T("size")) {
+ int x, y;
+ if (_stscanf_s(str, _T("%dx%d"), &x, &y) != 2) {
+ fError = true;
+ }
+ m_size.cx = x;
+ m_size.cy = y;
+ } else if (entry == _T("org")) {
+ if (_stscanf_s(str, _T("%d,%d"), &m_x, &m_y) != 2) {
+ fError = true;
+ } else {
+ m_org = CPoint(m_x, m_y);
+ }
+ } else if (entry == _T("scale")) {
+ if (ver < 5) {
+ int scale = 100;
+ if (_stscanf_s(str, _T("%d%%"), &scale) != 1) {
+ fError = true;
+ }
+ m_scale_x = m_scale_y = scale;
+ } else {
+ if (_stscanf_s(str, _T("%d%%,%d%%"), &m_scale_x, &m_scale_y) != 2) {
+ fError = true;
+ }
+ }
+ } else if (entry == _T("alpha")) {
+ if (_stscanf_s(str, _T("%d"), &m_alpha) != 1) {
+ fError = true;
+ }
+ } else if (entry == _T("smooth")) {
+ str.MakeLower();
+
+ if (str.Find(_T("old")) >= 0 || str.Find(_T("2")) >= 0) {
+ m_fSmooth = 2;
+ } else if (str.Find(_T("on")) >= 0 || str.Find(_T("1")) >= 0) {
+ m_fSmooth = 1;
+ } else if (str.Find(_T("off")) >= 0 || str.Find(_T("0")) >= 0) {
+ m_fSmooth = 0;
+ } else {
+ fError = true;
+ }
+ } else if (entry == _T("fadein/out")) {
+ if (_stscanf_s(str, _T("%d,%d"), &m_fadein, &m_fadeout) != 2) {
+ fError = true;
+ }
+ } else if (entry == _T("align")) {
+ str.MakeLower();
+
+ int i = 0, j = 0;
+ for (CString token = str.Tokenize(_T(" "), i);
+ j < 3 && !fError && !token.IsEmpty();
+ token = str.Tokenize(_T(" "), i), j++) {
+ if (j == 0) {
+ if (token == _T("on") || token == _T("1")) {
+ m_fAlign = true;
+ } else if (token == _T("off") || token == _T("0")) {
+ m_fAlign = false;
+ } else {
+ fError = true;
+ }
+ } else if (j == 1) {
+ if (token == _T("at")) {
+ j--;
+ continue;
+ }
+
+ if (token == _T("left")) {
+ m_alignhor = 0;
+ } else if (token == _T("center")) {
+ m_alignhor = 1;
+ } else if (token == _T("right")) {
+ m_alignhor = 2;
+ } else {
+ fError = true;
+ }
+ } else if (j == 2) {
+ if (token == _T("top")) {
+ m_alignver = 0;
+ } else if (token == _T("center")) {
+ m_alignver = 1;
+ } else if (token == _T("bottom")) {
+ m_alignver = 2;
+ } else {
+ fError = true;
+ }
+ }
+ }
+ } else if (entry == _T("time offset")) {
+ bool fNegative = false;
+ if (str[0] == '-') {
+ fNegative = true;
+ }
+ str.TrimLeft(_T("+-"));
+
+ TCHAR c;
+ int hh, mm, ss, ms;
+ int n = _stscanf_s(str, _T("%d%c%d%c%d%c%d"), &hh, &c, sizeof(TCHAR),
+ &mm, &c, sizeof(TCHAR), &ss, &c, sizeof(TCHAR), &ms);
+
+ m_toff = n == 1
+ ? hh * (fNegative ? -1 : 1)
+ : n == 4 + 3
+ ? (hh * 60 * 60 * 1000 + mm * 60 * 1000 + ss * 1000 + ms) * (fNegative ? -1 : 1)
+ : fError = true, 0;
+ } else if (entry == _T("forced subs")) {
+ str.MakeLower();
+
+ if (str.Find(_T("on")) >= 0 || str.Find(_T("1")) >= 0) {
+ m_fOnlyShowForcedSubs = true;
+ } else if (str.Find(_T("off")) >= 0 || str.Find(_T("0")) >= 0) {
+ m_fOnlyShowForcedSubs = false;
+ } else {
+ fError = true;
+ }
+ } else if (entry == _T("langidx")) {
+ if (_stscanf_s(str, _T("%d"), &m_iLang) != 1) {
+ fError = true;
+ }
+ } else if (entry == _T("palette")) {
+ if (_stscanf_s(str, _T("%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x"),
+ &m_orgpal[0], &m_orgpal[1], &m_orgpal[2], &m_orgpal[3],
+ &m_orgpal[4], &m_orgpal[5], &m_orgpal[6], &m_orgpal[7],
+ &m_orgpal[8], &m_orgpal[9], &m_orgpal[10], &m_orgpal[11],
+ &m_orgpal[12], &m_orgpal[13], &m_orgpal[14], &m_orgpal[15]
+ ) != 16) {
+ fError = true;
+ }
+ } else if (entry == _T("custom colors")) {
+ str.MakeLower();
+
+ if (str.Find(_T("on")) == 0 || str.Find(_T("1")) == 0) {
+ m_fCustomPal = true;
+ } else if (str.Find(_T("off")) == 0 || str.Find(_T("0")) == 0) {
+ m_fCustomPal = false;
+ } else {
+ fError = true;
+ }
+
+ i = str.Find(_T("tridx:"));
+ if (i < 0) {
+ fError = true;
+ continue;
+ }
+ str = str.Mid(i + (int)_tcslen(_T("tridx:")));
+
+ int tridx;
+ if (_stscanf_s(str, _T("%x"), &tridx) != 1) {
+ fError = true;
+ continue;
+ }
+ tridx = ((tridx & 0x1000) >> 12) | ((tridx & 0x100) >> 7) | ((tridx & 0x10) >> 2) | ((tridx & 1) << 3);
+
+ i = str.Find(_T("colors:"));
+ if (i < 0) {
+ fError = true;
+ continue;
+ }
+ str = str.Mid(i + (int)_tcslen(_T("colors:")));
+
+ RGBQUAD pal[4];
+ if (_stscanf_s(str, _T("%x,%x,%x,%x"), &pal[0], &pal[1], &pal[2], &pal[3]) != 4) {
+ fError = true;
+ continue;
+ }
+
+ SetCustomPal(pal, tridx);
+ } else if (entry == _T("id")) {
+ str.MakeLower();
+
+ int langid = ((str[0] & 0xff) << 8) | (str[1] & 0xff);
+
+ i = str.Find(_T("index:"));
+ if (i < 0) {
+ fError = true;
+ continue;
+ }
+ str = str.Mid(i + (int)_tcslen(_T("index:")));
+
+ if (_stscanf_s(str, _T("%d"), &id) != 1 || id < 0 || id >= 32) {
+ fError = true;
+ continue;
+ }
+ if (m_iLang < 0) {
+ m_iLang = id;
+ }
+
+ m_langs[id].id = langid;
+ m_langs[id].name = lang_tbl[find_lang(langid)].lang_long;
+ m_langs[id].alt = lang_tbl[find_lang(langid)].lang_long;
+
+ delay = 0;
+ } else if (id >= 0 && entry == _T("alt")) {
+ m_langs[id].alt = str;
+ } else if (id >= 0 && entry == _T("delay")) {
+ bool fNegative = false;
+ if (str[0] == '-') {
+ fNegative = true;
+ }
+ str.TrimLeft(_T("+-"));
+
+ TCHAR c;
+ int hh, mm, ss, ms;
+ if (_stscanf_s(str, _T("%d%c%d%c%d%c%d"), &hh, &c, sizeof(TCHAR),
+ &mm, &c, sizeof(TCHAR), &ss, &c, sizeof(TCHAR), &ms) != 4 + 3) {
+ fError = true;
+ continue;
+ }
+
+ delay += (hh * 60 * 60 * 1000 + mm * 60 * 1000 + ss * 1000 + ms) * (fNegative ? -1 : 1);
+ } else if (id >= 0 && entry == _T("timestamp")) {
+ SubPos sb;
+
+ sb.vobid = vobid;
+ sb.cellid = cellid;
+ sb.celltimestamp = celltimestamp;
+ sb.fValid = true;
+
+ bool fNegative = false;
+ if (str[0] == '-') {
+ fNegative = true;
+ }
+ str.TrimLeft(_T("+-"));
+
+ TCHAR c;
+ int hh, mm, ss, ms;
+ if (_stscanf_s(str, _T("%d%c%d%c%d%c%d"), &hh, &c, sizeof(TCHAR),
+ &mm, &c, sizeof(TCHAR), &ss, &c, sizeof(TCHAR), &ms) != 4 + 3) {
+ fError = true;
+ continue;
+ }
+
+ sb.start = (hh * 60 * 60 * 1000 + mm * 60 * 1000 + ss * 1000 + ms) * (fNegative ? -1 : 1) + delay;
+
+ i = str.Find(_T("filepos:"));
+ if (i < 0) {
+ fError = true;
+ continue;
+ }
+ str = str.Mid(i + (int)_tcslen(_T("filepos:")));
+
+ if (_stscanf_s(str, _T("%I64x"), &sb.filepos) != 1) {
+ fError = true;
+ continue;
+ }
+
+ if (delay < 0 && m_langs[id].subpos.GetCount() > 0) {
+ __int64 ts = m_langs[id].subpos[m_langs[id].subpos.GetCount() - 1].start;
+
+ if (sb.start < ts) {
+ delay += (int)(ts - sb.start);
+ sb.start = ts;
+ }
+ }
+
+ m_langs[id].subpos.Add(sb);
+ } else {
+ fError = true;
+ }
+ }
+
+ return !fError;
}
bool CVobSubFile::ReadSub(CString fn)
{
- CFile f;
- if (!f.Open(fn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone)) {
- return false;
- }
+ CFile f;
+ if (!f.Open(fn, CFile::modeRead | CFile::typeBinary | CFile::shareDenyNone)) {
+ return false;
+ }
- m_sub.SetLength(f.GetLength());
- m_sub.SeekToBegin();
+ m_sub.SetLength(f.GetLength());
+ m_sub.SeekToBegin();
- int len;
- BYTE buff[2048];
- while ((len = f.Read(buff, sizeof(buff))) > 0 && *(DWORD*)buff == 0xba010000) {
- m_sub.Write(buff, len);
- }
+ int len;
+ BYTE buff[2048];
+ while ((len = f.Read(buff, sizeof(buff))) > 0 && *(DWORD*)buff == 0xba010000) {
+ m_sub.Write(buff, len);
+ }
- return true;
+ return true;
}
static unsigned char* RARbuff = NULL;
@@ -745,502 +745,502 @@ static unsigned int RARpos = 0;
static int PASCAL MyProcessDataProc(unsigned char* Addr, int Size)
{
- ASSERT(RARbuff);
+ ASSERT(RARbuff);
- memcpy(&RARbuff[RARpos], Addr, Size);
- RARpos += Size;
+ memcpy(&RARbuff[RARpos], Addr, Size);
+ RARpos += Size;
- return 1;
+ return 1;
}
bool CVobSubFile::ReadRar(CString fn)
{
#ifdef _WIN64
- HMODULE h = LoadLibrary(_T("unrar64.dll"));
+ HMODULE h = LoadLibrary(_T("unrar64.dll"));
#else
- HMODULE h = LoadLibrary(_T("unrar.dll"));
+ HMODULE h = LoadLibrary(_T("unrar.dll"));
#endif
- if (!h) {
- return false;
- }
-
- RAROpenArchiveEx OpenArchiveEx = (RAROpenArchiveEx)GetProcAddress(h, "RAROpenArchiveEx");
- RARCloseArchive CloseArchive = (RARCloseArchive)GetProcAddress(h, "RARCloseArchive");
- RARReadHeaderEx ReadHeaderEx = (RARReadHeaderEx)GetProcAddress(h, "RARReadHeaderEx");
- RARProcessFile ProcessFile = (RARProcessFile)GetProcAddress(h, "RARProcessFile");
- RARSetChangeVolProc SetChangeVolProc = (RARSetChangeVolProc)GetProcAddress(h, "RARSetChangeVolProc");
- RARSetProcessDataProc SetProcessDataProc = (RARSetProcessDataProc)GetProcAddress(h, "RARSetProcessDataProc");
- RARSetPassword SetPassword = (RARSetPassword)GetProcAddress(h, "RARSetPassword");
-
- if (!(OpenArchiveEx && CloseArchive && ReadHeaderEx && ProcessFile
- && SetChangeVolProc && SetProcessDataProc && SetPassword)) {
- FreeLibrary(h);
- return false;
- }
-
- struct RAROpenArchiveDataEx ArchiveDataEx;
- memset(&ArchiveDataEx, 0, sizeof(ArchiveDataEx));
- ArchiveDataEx.ArcNameW = (LPTSTR)(LPCTSTR)fn;
- char fnA[_MAX_PATH];
- size_t size;
- if (wcstombs_s(&size, fnA, fn, fn.GetLength())) {
- fnA[0] = 0;
- }
- ArchiveDataEx.ArcName = fnA;
- ArchiveDataEx.OpenMode = RAR_OM_EXTRACT;
- ArchiveDataEx.CmtBuf = 0;
- HANDLE hrar = OpenArchiveEx(&ArchiveDataEx);
- if (!hrar) {
- FreeLibrary(h);
- return false;
- }
-
- SetProcessDataProc(hrar, MyProcessDataProc);
-
- struct RARHeaderDataEx HeaderDataEx;
- HeaderDataEx.CmtBuf = NULL;
-
- while (ReadHeaderEx(hrar, &HeaderDataEx) == 0) {
- CString subfn(HeaderDataEx.FileNameW);
-
- if (!subfn.Right(4).CompareNoCase(_T(".sub"))) {
- CAutoVectorPtr<BYTE> buff;
- if (!buff.Allocate(HeaderDataEx.UnpSize)) {
- CloseArchive(hrar);
- FreeLibrary(h);
- return false;
- }
-
- RARbuff = buff;
- RARpos = 0;
-
- if (ProcessFile(hrar, RAR_TEST, NULL, NULL)) {
- CloseArchive(hrar);
- FreeLibrary(h);
-
- return false;
- }
-
- m_sub.SetLength(HeaderDataEx.UnpSize);
- m_sub.SeekToBegin();
- m_sub.Write(buff, HeaderDataEx.UnpSize);
- m_sub.SeekToBegin();
-
- RARbuff = NULL;
- RARpos = 0;
-
- break;
- }
-
- ProcessFile(hrar, RAR_SKIP, NULL, NULL);
- }
-
- CloseArchive(hrar);
- FreeLibrary(h);
-
- return true;
+ if (!h) {
+ return false;
+ }
+
+ RAROpenArchiveEx OpenArchiveEx = (RAROpenArchiveEx)GetProcAddress(h, "RAROpenArchiveEx");
+ RARCloseArchive CloseArchive = (RARCloseArchive)GetProcAddress(h, "RARCloseArchive");
+ RARReadHeaderEx ReadHeaderEx = (RARReadHeaderEx)GetProcAddress(h, "RARReadHeaderEx");
+ RARProcessFile ProcessFile = (RARProcessFile)GetProcAddress(h, "RARProcessFile");
+ RARSetChangeVolProc SetChangeVolProc = (RARSetChangeVolProc)GetProcAddress(h, "RARSetChangeVolProc");
+ RARSetProcessDataProc SetProcessDataProc = (RARSetProcessDataProc)GetProcAddress(h, "RARSetProcessDataProc");
+ RARSetPassword SetPassword = (RARSetPassword)GetProcAddress(h, "RARSetPassword");
+
+ if (!(OpenArchiveEx && CloseArchive && ReadHeaderEx && ProcessFile
+ && SetChangeVolProc && SetProcessDataProc && SetPassword)) {
+ FreeLibrary(h);
+ return false;
+ }
+
+ struct RAROpenArchiveDataEx ArchiveDataEx;
+ memset(&ArchiveDataEx, 0, sizeof(ArchiveDataEx));
+ ArchiveDataEx.ArcNameW = (LPTSTR)(LPCTSTR)fn;
+ char fnA[_MAX_PATH];
+ size_t size;
+ if (wcstombs_s(&size, fnA, fn, fn.GetLength())) {
+ fnA[0] = 0;
+ }
+ ArchiveDataEx.ArcName = fnA;
+ ArchiveDataEx.OpenMode = RAR_OM_EXTRACT;
+ ArchiveDataEx.CmtBuf = 0;
+ HANDLE hrar = OpenArchiveEx(&ArchiveDataEx);
+ if (!hrar) {
+ FreeLibrary(h);
+ return false;
+ }
+
+ SetProcessDataProc(hrar, MyProcessDataProc);
+
+ struct RARHeaderDataEx HeaderDataEx;
+ HeaderDataEx.CmtBuf = NULL;
+
+ while (ReadHeaderEx(hrar, &HeaderDataEx) == 0) {
+ CString subfn(HeaderDataEx.FileNameW);
+
+ if (!subfn.Right(4).CompareNoCase(_T(".sub"))) {
+ CAutoVectorPtr<BYTE> buff;
+ if (!buff.Allocate(HeaderDataEx.UnpSize)) {
+ CloseArchive(hrar);
+ FreeLibrary(h);
+ return false;
+ }
+
+ RARbuff = buff;
+ RARpos = 0;
+
+ if (ProcessFile(hrar, RAR_TEST, NULL, NULL)) {
+ CloseArchive(hrar);
+ FreeLibrary(h);
+
+ return false;
+ }
+
+ m_sub.SetLength(HeaderDataEx.UnpSize);
+ m_sub.SeekToBegin();
+ m_sub.Write(buff, HeaderDataEx.UnpSize);
+ m_sub.SeekToBegin();
+
+ RARbuff = NULL;
+ RARpos = 0;
+
+ break;
+ }
+
+ ProcessFile(hrar, RAR_SKIP, NULL, NULL);
+ }
+
+ CloseArchive(hrar);
+ FreeLibrary(h);
+
+ return true;
}
#define ReadBEdw(var) \
f.Read(&((BYTE*)&var)[3], 1); \
- f.Read(&((BYTE*)&var)[2], 1); \
- f.Read(&((BYTE*)&var)[1], 1); \
- f.Read(&((BYTE*)&var)[0], 1);
+ f.Read(&((BYTE*)&var)[2], 1); \
+ f.Read(&((BYTE*)&var)[1], 1); \
+ f.Read(&((BYTE*)&var)[0], 1);
bool CVobSubFile::ReadIfo(CString fn)
{
- CFile f;
- if (!f.Open(fn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone)) {
- return false;
- }
+ CFile f;
+ if (!f.Open(fn, CFile::modeRead | CFile::typeBinary | CFile::shareDenyNone)) {
+ return false;
+ }
- /* PGC1 */
+ /* PGC1 */
- f.Seek(0xc0+0x0c, SEEK_SET);
+ f.Seek(0xc0 + 0x0c, SEEK_SET);
- DWORD pos;
- ReadBEdw(pos);
+ DWORD pos;
+ ReadBEdw(pos);
- f.Seek(pos*0x800 + 0x0c, CFile::begin);
+ f.Seek(pos * 0x800 + 0x0c, CFile::begin);
- DWORD offset;
- ReadBEdw(offset);
+ DWORD offset;
+ ReadBEdw(offset);
- /* Subpic palette */
+ /* Subpic palette */
- f.Seek(pos*0x800 + offset + 0xa4, CFile::begin);
+ f.Seek(pos * 0x800 + offset + 0xa4, CFile::begin);
- for (size_t i = 0; i < 16; i++) {
- BYTE y, u, v, tmp;
+ for (size_t i = 0; i < 16; i++) {
+ BYTE y, u, v, tmp;
- f.Read(&tmp, 1);
- f.Read(&y, 1);
- f.Read(&u, 1);
- f.Read(&v, 1);
+ f.Read(&tmp, 1);
+ f.Read(&y, 1);
+ f.Read(&u, 1);
+ f.Read(&v, 1);
- y = (y-16)*255/219;
+ y = (y - 16) * 255 / 219;
- m_orgpal[i].rgbRed = (BYTE)min(max(1.0*y + 1.4022*(u-128), 0), 255);
- m_orgpal[i].rgbGreen = (BYTE)min(max(1.0*y - 0.3456*(u-128) - 0.7145*(v-128), 0), 255);
- m_orgpal[i].rgbBlue = (BYTE)min(max(1.0*y + 1.7710*(v-128), 0) , 255);
- }
+ m_orgpal[i].rgbRed = (BYTE)min(max(1.0 * y + 1.4022 * (u - 128), 0), 255);
+ m_orgpal[i].rgbGreen = (BYTE)min(max(1.0 * y - 0.3456 * (u - 128) - 0.7145 * (v - 128), 0), 255);
+ m_orgpal[i].rgbBlue = (BYTE)min(max(1.0 * y + 1.7710 * (v - 128), 0) , 255);
+ }
- return true;
+ return true;
}
bool CVobSubFile::WriteIdx(CString fn)
{
- CTextFile f;
- if (!f.Save(fn, CTextFile::ASCII)) {
- return false;
- }
-
- CString str;
- str.Format(_T("# VobSub index file, v%d (do not modify this line!)\n"), VOBSUBIDXVER);
-
- f.WriteString(str);
- f.WriteString(_T("# \n"));
- f.WriteString(_T("# To repair desyncronization, you can insert gaps this way:\n"));
- f.WriteString(_T("# (it usually happens after vob id changes)\n"));
- f.WriteString(_T("# \n"));
- f.WriteString(_T("#\t delay: [sign]hh:mm:ss:ms\n"));
- f.WriteString(_T("# \n"));
- f.WriteString(_T("# Where:\n"));
- f.WriteString(_T("#\t [sign]: +, - (optional)\n"));
- f.WriteString(_T("#\t hh: hours (0 <= hh)\n"));
- f.WriteString(_T("#\t mm/ss: minutes/seconds (0 <= mm/ss <= 59)\n"));
- f.WriteString(_T("#\t ms: milliseconds (0 <= ms <= 999)\n"));
- f.WriteString(_T("# \n"));
- f.WriteString(_T("#\t Note: You can't position a sub before the previous with a negative value.\n"));
- f.WriteString(_T("# \n"));
- f.WriteString(_T("# You can also modify timestamps or delete a few subs you don't like.\n"));
- f.WriteString(_T("# Just make sure they stay in increasing order.\n"));
- f.WriteString(_T("\n"));
- f.WriteString(_T("\n"));
-
- // Settings
-
- f.WriteString(_T("# Settings\n\n"));
-
- f.WriteString(_T("# Original frame size\n"));
- str.Format(_T("size: %dx%d\n\n"), m_size.cx, m_size.cy);
- f.WriteString(str);
-
- f.WriteString(_T("# Origin, relative to the upper-left corner, can be overloaded by aligment\n"));
- str.Format(_T("org: %d, %d\n\n"), m_x, m_y);
- f.WriteString(str);
-
- f.WriteString(_T("# Image scaling (hor,ver), origin is at the upper-left corner or at the alignment coord (x, y)\n"));
- str.Format(_T("scale: %d%%, %d%%\n\n"), m_scale_x, m_scale_y);
- f.WriteString(str);
-
- f.WriteString(_T("# Alpha blending\n"));
- str.Format(_T("alpha: %d%%\n\n"), m_alpha);
- f.WriteString(str);
-
- f.WriteString(_T("# Smoothing for very blocky images (use OLD for no filtering)\n"));
- str.Format(_T("smooth: %s\n\n"), m_fSmooth == 0 ? _T("OFF") : m_fSmooth == 1 ? _T("ON") : _T("OLD"));
- f.WriteString(str);
-
- f.WriteString(_T("# In millisecs\n"));
- str.Format(_T("fadein/out: %d, %d\n\n"), m_fadein, m_fadeout);
- f.WriteString(str);
-
- f.WriteString(_T("# Force subtitle placement relative to (org.x, org.y)\n"));
- str.Format(_T("align: %s %s %s\n\n"),
- m_fAlign ? _T("ON at") : _T("OFF at"),
- m_alignhor == 0 ? _T("LEFT") : m_alignhor == 1 ? _T("CENTER") : m_alignhor == 2 ? _T("RIGHT") : _T(""),
- m_alignver == 0 ? _T("TOP") : m_alignver == 1 ? _T("CENTER") : m_alignver == 2 ? _T("BOTTOM") : _T(""));
- f.WriteString(str);
-
- f.WriteString(_T("# For correcting non-progressive desync. (in millisecs or hh:mm:ss:ms)\n"));
- f.WriteString(_T("# Note: Not effective in DirectVobSub, use \"delay: ... \" instead.\n"));
- str.Format(_T("time offset: %d\n\n"), m_toff);
- f.WriteString(str);
-
- f.WriteString(_T("# ON: displays only forced subtitles, OFF: shows everything\n"));
- str.Format(_T("forced subs: %s\n\n"), m_fOnlyShowForcedSubs ? _T("ON") : _T("OFF"));
- f.WriteString(str);
-
- f.WriteString(_T("# The original palette of the DVD\n"));
- str.Format(_T("palette: %06x, %06x, %06x, %06x, %06x, %06x, %06x, %06x, %06x, %06x, %06x, %06x, %06x, %06x, %06x, %06x\n\n"),
- *((unsigned int*)&m_orgpal[0])&0xffffff,
- *((unsigned int*)&m_orgpal[1])&0xffffff,
- *((unsigned int*)&m_orgpal[2])&0xffffff,
- *((unsigned int*)&m_orgpal[3])&0xffffff,
- *((unsigned int*)&m_orgpal[4])&0xffffff,
- *((unsigned int*)&m_orgpal[5])&0xffffff,
- *((unsigned int*)&m_orgpal[6])&0xffffff,
- *((unsigned int*)&m_orgpal[7])&0xffffff,
- *((unsigned int*)&m_orgpal[8])&0xffffff,
- *((unsigned int*)&m_orgpal[9])&0xffffff,
- *((unsigned int*)&m_orgpal[10])&0xffffff,
- *((unsigned int*)&m_orgpal[11])&0xffffff,
- *((unsigned int*)&m_orgpal[12])&0xffffff,
- *((unsigned int*)&m_orgpal[13])&0xffffff,
- *((unsigned int*)&m_orgpal[14])&0xffffff,
- *((unsigned int*)&m_orgpal[15])&0xffffff);
- f.WriteString(str);
-
- int tridx = (!!(m_tridx&1))*0x1000 + (!!(m_tridx&2))*0x100 + (!!(m_tridx&4))*0x10 + (!!(m_tridx&8));
-
- f.WriteString(_T("# Custom colors (transp idxs and the four colors)\n"));
- str.Format(_T("custom colors: %s, tridx: %04x, colors: %06x, %06x, %06x, %06x\n\n"),
- m_fCustomPal ? _T("ON") : _T("OFF"),
- tridx,
- *((unsigned int*)&m_cuspal[0])&0xffffff,
- *((unsigned int*)&m_cuspal[1])&0xffffff,
- *((unsigned int*)&m_cuspal[2])&0xffffff,
- *((unsigned int*)&m_cuspal[3])&0xffffff);
- f.WriteString(str);
-
- f.WriteString(_T("# Language index in use\n"));
- str.Format(_T("langidx: %d\n\n"), m_iLang);
- f.WriteString(str);
-
- // Subs
-
- for (size_t i = 0; i < 32; i++) {
- SubLang& sl = m_langs[i];
-
- CAtlArray<SubPos>& sp = sl.subpos;
- if (sp.IsEmpty() && !sl.id) {
- continue;
- }
-
- str.Format(_T("# %s\n"), sl.name);
- f.WriteString(str);
-
- ASSERT(sl.id);
- if (!sl.id) {
- sl.id = '--';
- }
- str.Format(_T("id: %c%c, index: %d\n"), sl.id>>8, sl.id&0xff, i);
- f.WriteString(str);
-
- str = _T("# Uncomment next line to activate alternative name in DirectVobSub / Windows Media Player 6.x\n");
- f.WriteString(str);
- str.Format(_T("alt: %s\n"), sl.alt);
- if (sl.name == sl.alt) {
- str = _T("# ") + str;
- }
- f.WriteString(str);
-
- char vobid = -1, cellid = -1;
-
- for (size_t j = 0; j < sp.GetCount(); j++) {
- if (!sp[j].fValid) {
- continue;
- }
-
- if (sp[j].vobid != vobid || sp[j].cellid != cellid) {
- str.Format(_T("# Vob/Cell ID: %d, %d (PTS: %d)\n"), sp[j].vobid, sp[j].cellid, sp[j].celltimestamp);
- f.WriteString(str);
- vobid = sp[j].vobid;
- cellid = sp[j].cellid;
- }
-
- str.Format(_T("timestamp: %s%02d:%02d:%02d:%03d, filepos: %09I64x\n"),
- sp[j].start < 0 ? _T("-") : _T(""),
- abs(int((sp[j].start/1000/60/60)%60)),
- abs(int((sp[j].start/1000/60)%60)),
- abs(int((sp[j].start/1000)%60)),
- abs(int((sp[j].start)%1000)),
- sp[j].filepos);
- f.WriteString(str);
- }
-
- f.WriteString(_T("\n"));
- }
-
- return true;
+ CTextFile f;
+ if (!f.Save(fn, CTextFile::ASCII)) {
+ return false;
+ }
+
+ CString str;
+ str.Format(_T("# VobSub index file, v%d (do not modify this line!)\n"), VOBSUBIDXVER);
+
+ f.WriteString(str);
+ f.WriteString(_T("# \n"));
+ f.WriteString(_T("# To repair desyncronization, you can insert gaps this way:\n"));
+ f.WriteString(_T("# (it usually happens after vob id changes)\n"));
+ f.WriteString(_T("# \n"));
+ f.WriteString(_T("#\t delay: [sign]hh:mm:ss:ms\n"));
+ f.WriteString(_T("# \n"));
+ f.WriteString(_T("# Where:\n"));
+ f.WriteString(_T("#\t [sign]: +, - (optional)\n"));
+ f.WriteString(_T("#\t hh: hours (0 <= hh)\n"));
+ f.WriteString(_T("#\t mm/ss: minutes/seconds (0 <= mm/ss <= 59)\n"));
+ f.WriteString(_T("#\t ms: milliseconds (0 <= ms <= 999)\n"));
+ f.WriteString(_T("# \n"));
+ f.WriteString(_T("#\t Note: You can't position a sub before the previous with a negative value.\n"));
+ f.WriteString(_T("# \n"));
+ f.WriteString(_T("# You can also modify timestamps or delete a few subs you don't like.\n"));
+ f.WriteString(_T("# Just make sure they stay in increasing order.\n"));
+ f.WriteString(_T("\n"));
+ f.WriteString(_T("\n"));
+
+ // Settings
+
+ f.WriteString(_T("# Settings\n\n"));
+
+ f.WriteString(_T("# Original frame size\n"));
+ str.Format(_T("size: %dx%d\n\n"), m_size.cx, m_size.cy);
+ f.WriteString(str);
+
+ f.WriteString(_T("# Origin, relative to the upper-left corner, can be overloaded by aligment\n"));
+ str.Format(_T("org: %d, %d\n\n"), m_x, m_y);
+ f.WriteString(str);
+
+ f.WriteString(_T("# Image scaling (hor,ver), origin is at the upper-left corner or at the alignment coord (x, y)\n"));
+ str.Format(_T("scale: %d%%, %d%%\n\n"), m_scale_x, m_scale_y);
+ f.WriteString(str);
+
+ f.WriteString(_T("# Alpha blending\n"));
+ str.Format(_T("alpha: %d%%\n\n"), m_alpha);
+ f.WriteString(str);
+
+ f.WriteString(_T("# Smoothing for very blocky images (use OLD for no filtering)\n"));
+ str.Format(_T("smooth: %s\n\n"), m_fSmooth == 0 ? _T("OFF") : m_fSmooth == 1 ? _T("ON") : _T("OLD"));
+ f.WriteString(str);
+
+ f.WriteString(_T("# In millisecs\n"));
+ str.Format(_T("fadein/out: %d, %d\n\n"), m_fadein, m_fadeout);
+ f.WriteString(str);
+
+ f.WriteString(_T("# Force subtitle placement relative to (org.x, org.y)\n"));
+ str.Format(_T("align: %s %s %s\n\n"),
+ m_fAlign ? _T("ON at") : _T("OFF at"),
+ m_alignhor == 0 ? _T("LEFT") : m_alignhor == 1 ? _T("CENTER") : m_alignhor == 2 ? _T("RIGHT") : _T(""),
+ m_alignver == 0 ? _T("TOP") : m_alignver == 1 ? _T("CENTER") : m_alignver == 2 ? _T("BOTTOM") : _T(""));
+ f.WriteString(str);
+
+ f.WriteString(_T("# For correcting non-progressive desync. (in millisecs or hh:mm:ss:ms)\n"));
+ f.WriteString(_T("# Note: Not effective in DirectVobSub, use \"delay: ... \" instead.\n"));
+ str.Format(_T("time offset: %d\n\n"), m_toff);
+ f.WriteString(str);
+
+ f.WriteString(_T("# ON: displays only forced subtitles, OFF: shows everything\n"));
+ str.Format(_T("forced subs: %s\n\n"), m_fOnlyShowForcedSubs ? _T("ON") : _T("OFF"));
+ f.WriteString(str);
+
+ f.WriteString(_T("# The original palette of the DVD\n"));
+ str.Format(_T("palette: %06x, %06x, %06x, %06x, %06x, %06x, %06x, %06x, %06x, %06x, %06x, %06x, %06x, %06x, %06x, %06x\n\n"),
+ *((unsigned int*)&m_orgpal[0]) & 0xffffff,
+ *((unsigned int*)&m_orgpal[1]) & 0xffffff,
+ *((unsigned int*)&m_orgpal[2]) & 0xffffff,
+ *((unsigned int*)&m_orgpal[3]) & 0xffffff,
+ *((unsigned int*)&m_orgpal[4]) & 0xffffff,
+ *((unsigned int*)&m_orgpal[5]) & 0xffffff,
+ *((unsigned int*)&m_orgpal[6]) & 0xffffff,
+ *((unsigned int*)&m_orgpal[7]) & 0xffffff,
+ *((unsigned int*)&m_orgpal[8]) & 0xffffff,
+ *((unsigned int*)&m_orgpal[9]) & 0xffffff,
+ *((unsigned int*)&m_orgpal[10]) & 0xffffff,
+ *((unsigned int*)&m_orgpal[11]) & 0xffffff,
+ *((unsigned int*)&m_orgpal[12]) & 0xffffff,
+ *((unsigned int*)&m_orgpal[13]) & 0xffffff,
+ *((unsigned int*)&m_orgpal[14]) & 0xffffff,
+ *((unsigned int*)&m_orgpal[15]) & 0xffffff);
+ f.WriteString(str);
+
+ int tridx = (!!(m_tridx & 1)) * 0x1000 + (!!(m_tridx & 2)) * 0x100 + (!!(m_tridx & 4)) * 0x10 + (!!(m_tridx & 8));
+
+ f.WriteString(_T("# Custom colors (transp idxs and the four colors)\n"));
+ str.Format(_T("custom colors: %s, tridx: %04x, colors: %06x, %06x, %06x, %06x\n\n"),
+ m_fCustomPal ? _T("ON") : _T("OFF"),
+ tridx,
+ *((unsigned int*)&m_cuspal[0]) & 0xffffff,
+ *((unsigned int*)&m_cuspal[1]) & 0xffffff,
+ *((unsigned int*)&m_cuspal[2]) & 0xffffff,
+ *((unsigned int*)&m_cuspal[3]) & 0xffffff);
+ f.WriteString(str);
+
+ f.WriteString(_T("# Language index in use\n"));
+ str.Format(_T("langidx: %d\n\n"), m_iLang);
+ f.WriteString(str);
+
+ // Subs
+
+ for (size_t i = 0; i < 32; i++) {
+ SubLang& sl = m_langs[i];
+
+ CAtlArray<SubPos>& sp = sl.subpos;
+ if (sp.IsEmpty() && !sl.id) {
+ continue;
+ }
+
+ str.Format(_T("# %s\n"), sl.name);
+ f.WriteString(str);
+
+ ASSERT(sl.id);
+ if (!sl.id) {
+ sl.id = '--';
+ }
+ str.Format(_T("id: %c%c, index: %d\n"), sl.id >> 8, sl.id & 0xff, i);
+ f.WriteString(str);
+
+ str = _T("# Uncomment next line to activate alternative name in DirectVobSub / Windows Media Player 6.x\n");
+ f.WriteString(str);
+ str.Format(_T("alt: %s\n"), sl.alt);
+ if (sl.name == sl.alt) {
+ str = _T("# ") + str;
+ }
+ f.WriteString(str);
+
+ char vobid = -1, cellid = -1;
+
+ for (size_t j = 0; j < sp.GetCount(); j++) {
+ if (!sp[j].fValid) {
+ continue;
+ }
+
+ if (sp[j].vobid != vobid || sp[j].cellid != cellid) {
+ str.Format(_T("# Vob/Cell ID: %d, %d (PTS: %d)\n"), sp[j].vobid, sp[j].cellid, sp[j].celltimestamp);
+ f.WriteString(str);
+ vobid = sp[j].vobid;
+ cellid = sp[j].cellid;
+ }
+
+ str.Format(_T("timestamp: %s%02d:%02d:%02d:%03d, filepos: %09I64x\n"),
+ sp[j].start < 0 ? _T("-") : _T(""),
+ abs(int((sp[j].start / 1000 / 60 / 60) % 60)),
+ abs(int((sp[j].start / 1000 / 60) % 60)),
+ abs(int((sp[j].start / 1000) % 60)),
+ abs(int((sp[j].start) % 1000)),
+ sp[j].filepos);
+ f.WriteString(str);
+ }
+
+ f.WriteString(_T("\n"));
+ }
+
+ return true;
}
bool CVobSubFile::WriteSub(CString fn)
{
- CFile f;
- if (!f.Open(fn, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary|CFile::shareDenyWrite)) {
- return false;
- }
+ CFile f;
+ if (!f.Open(fn, CFile::modeCreate | CFile::modeWrite | CFile::typeBinary | CFile::shareDenyWrite)) {
+ return false;
+ }
- if (m_sub.GetLength() == 0) {
- return true; // nothing to do...
- }
+ if (m_sub.GetLength() == 0) {
+ return true; // nothing to do...
+ }
- m_sub.SeekToBegin();
+ m_sub.SeekToBegin();
- int len;
- BYTE buff[2048];
- while ((len = m_sub.Read(buff, sizeof(buff))) > 0 && *(DWORD*)buff == 0xba010000) {
- f.Write(buff, len);
- }
+ int len;
+ BYTE buff[2048];
+ while ((len = m_sub.Read(buff, sizeof(buff))) > 0 && *(DWORD*)buff == 0xba010000) {
+ f.Write(buff, len);
+ }
- return true;
+ return true;
}
//
BYTE* CVobSubFile::GetPacket(int idx, int& packetsize, int& datasize, int iLang)
{
- BYTE* ret = NULL;
-
- if (iLang < 0 || iLang >= 32) {
- iLang = m_iLang;
- }
- CAtlArray<SubPos>& sp = m_langs[iLang].subpos;
-
- do {
- if (idx < 0 || (size_t)idx >= sp.GetCount()) {
- break;
- }
-
- if ((__int64)m_sub.Seek(sp[idx].filepos, CFile::begin) != sp[idx].filepos) {
- break;
- }
-
- BYTE buff[0x800];
- if (sizeof(buff) != m_sub.Read(buff, sizeof(buff))) {
- break;
- }
-
- // let's check a few things to make sure...
- if (*(DWORD*)&buff[0x00] != 0xba010000
- || *(DWORD*)&buff[0x0e] != 0xbd010000
- || !(buff[0x15] & 0x80)
- || (buff[0x17] & 0xf0) != 0x20
- || (buff[buff[0x16] + 0x17] & 0xe0) != 0x20
- || (buff[buff[0x16] + 0x17] & 0x1f) != iLang) {
- break;
- }
-
- packetsize = (buff[buff[0x16] + 0x18] << 8) + buff[buff[0x16] + 0x19];
- datasize = (buff[buff[0x16] + 0x1a] << 8) + buff[buff[0x16] + 0x1b];
-
- ret = DNew BYTE[packetsize];
- if (!ret) {
- break;
- }
-
- int i = 0, sizeleft = packetsize;
- for (int size; i < packetsize; i += size, sizeleft -= size) {
- int hsize = 0x18 + buff[0x16];
- size = min(sizeleft, 0x800 - hsize);
- memcpy(&ret[i], &buff[hsize], size);
-
- if (size != sizeleft) {
- while (m_sub.Read(buff, sizeof(buff))) {
- if (/*!(buff[0x15] & 0x80) &&*/ buff[buff[0x16] + 0x17] == (iLang|0x20)) {
- break;
- }
- }
- }
- }
-
- if (i != packetsize || sizeleft > 0) {
- delete [] ret, ret = NULL;
- }
- } while (false);
-
- return ret;
+ BYTE* ret = NULL;
+
+ if (iLang < 0 || iLang >= 32) {
+ iLang = m_iLang;
+ }
+ CAtlArray<SubPos>& sp = m_langs[iLang].subpos;
+
+ do {
+ if (idx < 0 || (size_t)idx >= sp.GetCount()) {
+ break;
+ }
+
+ if ((__int64)m_sub.Seek(sp[idx].filepos, CFile::begin) != sp[idx].filepos) {
+ break;
+ }
+
+ BYTE buff[0x800];
+ if (sizeof(buff) != m_sub.Read(buff, sizeof(buff))) {
+ break;
+ }
+
+ // let's check a few things to make sure...
+ if (*(DWORD*)&buff[0x00] != 0xba010000
+ || *(DWORD*)&buff[0x0e] != 0xbd010000
+ || !(buff[0x15] & 0x80)
+ || (buff[0x17] & 0xf0) != 0x20
+ || (buff[buff[0x16] + 0x17] & 0xe0) != 0x20
+ || (buff[buff[0x16] + 0x17] & 0x1f) != iLang) {
+ break;
+ }
+
+ packetsize = (buff[buff[0x16] + 0x18] << 8) + buff[buff[0x16] + 0x19];
+ datasize = (buff[buff[0x16] + 0x1a] << 8) + buff[buff[0x16] + 0x1b];
+
+ ret = DNew BYTE[packetsize];
+ if (!ret) {
+ break;
+ }
+
+ int i = 0, sizeleft = packetsize;
+ for (int size; i < packetsize; i += size, sizeleft -= size) {
+ int hsize = 0x18 + buff[0x16];
+ size = min(sizeleft, 0x800 - hsize);
+ memcpy(&ret[i], &buff[hsize], size);
+
+ if (size != sizeleft) {
+ while (m_sub.Read(buff, sizeof(buff))) {
+ if (/*!(buff[0x15] & 0x80) &&*/ buff[buff[0x16] + 0x17] == (iLang | 0x20)) {
+ break;
+ }
+ }
+ }
+ }
+
+ if (i != packetsize || sizeleft > 0) {
+ delete [] ret, ret = NULL;
+ }
+ } while (false);
+
+ return ret;
}
bool CVobSubFile::GetFrame(int idx, int iLang)
{
- if (iLang < 0 || iLang >= 32) {
- iLang = m_iLang;
- }
- CAtlArray<SubPos>& sp = m_langs[iLang].subpos;
+ if (iLang < 0 || iLang >= 32) {
+ iLang = m_iLang;
+ }
+ CAtlArray<SubPos>& sp = m_langs[iLang].subpos;
- if (idx < 0 || (size_t)idx >= sp.GetCount()) {
- return false;
- }
+ if (idx < 0 || (size_t)idx >= sp.GetCount()) {
+ return false;
+ }
- if (m_img.iLang != iLang || m_img.iIdx != idx) {
- int packetsize = 0, datasize = 0;
- CAutoVectorPtr<BYTE> buff;
- buff.Attach(GetPacket(idx, packetsize, datasize, iLang));
- if (!buff || packetsize <= 0 || datasize <= 0) {
- return false;
- }
+ if (m_img.iLang != iLang || m_img.iIdx != idx) {
+ int packetsize = 0, datasize = 0;
+ CAutoVectorPtr<BYTE> buff;
+ buff.Attach(GetPacket(idx, packetsize, datasize, iLang));
+ if (!buff || packetsize <= 0 || datasize <= 0) {
+ return false;
+ }
- m_img.start = sp[idx].start;
- m_img.delay = (size_t)idx < (sp.GetCount()-1)
- ? sp[idx+1].start - sp[idx].start
- : 3000;
+ m_img.start = sp[idx].start;
+ m_img.delay = (size_t)idx < (sp.GetCount() - 1)
+ ? sp[idx + 1].start - sp[idx].start
+ : 3000;
- bool ret = m_img.Decode(buff, packetsize, datasize, m_fCustomPal, m_tridx, m_orgpal, m_cuspal, true);
+ bool ret = m_img.Decode(buff, packetsize, datasize, m_fCustomPal, m_tridx, m_orgpal, m_cuspal, true);
- if ((size_t)idx < (sp.GetCount()-1)) {
- m_img.delay = min(m_img.delay, sp[idx+1].start - m_img.start);
- }
+ if ((size_t)idx < (sp.GetCount() - 1)) {
+ m_img.delay = min(m_img.delay, sp[idx + 1].start - m_img.start);
+ }
- if (!ret) {
- return false;
- }
+ if (!ret) {
+ return false;
+ }
- m_img.iIdx = idx;
- m_img.iLang = iLang;
- }
+ m_img.iIdx = idx;
+ m_img.iLang = iLang;
+ }
- return (m_fOnlyShowForcedSubs ? m_img.fForced : true);
+ return (m_fOnlyShowForcedSubs ? m_img.fForced : true);
}
bool CVobSubFile::GetFrameByTimeStamp(__int64 time)
{
- return GetFrame(GetFrameIdxByTimeStamp(time));
+ return GetFrame(GetFrameIdxByTimeStamp(time));
}
int CVobSubFile::GetFrameIdxByTimeStamp(__int64 time)
{
- if (m_iLang < 0 || m_iLang >= 32) {
- return -1;
- }
+ if (m_iLang < 0 || m_iLang >= 32) {
+ return -1;
+ }
- CAtlArray<SubPos>& sp = m_langs[m_iLang].subpos;
+ CAtlArray<SubPos>& sp = m_langs[m_iLang].subpos;
- int i = 0, j = (int)sp.GetCount() - 1, ret = -1;
+ int i = 0, j = (int)sp.GetCount() - 1, ret = -1;
- if (j >= 0 && time >= sp[j].start) {
- return j;
- }
+ if (j >= 0 && time >= sp[j].start) {
+ return j;
+ }
- while (i < j) {
- int mid = (i + j) >> 1;
- int midstart = (int)sp[mid].start;
+ while (i < j) {
+ int mid = (i + j) >> 1;
+ int midstart = (int)sp[mid].start;
- if (time == midstart) {
- ret = mid;
- break;
- } else if (time < midstart) {
- ret = -1;
- if (j == mid) {
- mid--;
- }
- j = mid;
- } else if (time > midstart) {
- ret = mid;
- if (i == mid) {
- mid++;
- }
- i = mid;
- }
- }
+ if (time == midstart) {
+ ret = mid;
+ break;
+ } else if (time < midstart) {
+ ret = -1;
+ if (j == mid) {
+ mid--;
+ }
+ j = mid;
+ } else if (time > midstart) {
+ ret = mid;
+ if (i == mid) {
+ mid++;
+ }
+ i = mid;
+ }
+ }
- return ret;
+ return ret;
}
//
STDMETHODIMP CVobSubFile::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
- *ppv = NULL;
+ CheckPointer(ppv, E_POINTER);
+ *ppv = NULL;
- return
- QI(IPersist)
- QI(ISubStream)
- QI(ISubPicProvider)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IPersist)
+ QI(ISubStream)
+ QI(ISubPicProvider)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// ISubPicProvider
@@ -1249,255 +1249,255 @@ STDMETHODIMP CVobSubFile::NonDelegatingQueryInterface(REFIID riid, void** ppv)
STDMETHODIMP_(POSITION) CVobSubFile::GetStartPosition(REFERENCE_TIME rt, double fps)
{
- rt /= 10000;
+ rt /= 10000;
- int i = GetFrameIdxByTimeStamp(rt);
+ int i = GetFrameIdxByTimeStamp(rt);
- if (!GetFrame(i)) {
- return NULL;
- }
+ if (!GetFrame(i)) {
+ return NULL;
+ }
- if (rt >= (m_img.start + m_img.delay)) {
- if (!GetFrame(++i)) {
- return NULL;
- }
- }
+ if (rt >= (m_img.start + m_img.delay)) {
+ if (!GetFrame(++i)) {
+ return NULL;
+ }
+ }
- return (POSITION)(i+1);
+ return (POSITION)(i + 1);
}
STDMETHODIMP_(POSITION) CVobSubFile::GetNext(POSITION pos)
{
- int i = (int)pos;
- return (GetFrame(i) ? (POSITION)(i+1) : NULL);
+ int i = (int)pos;
+ return (GetFrame(i) ? (POSITION)(i + 1) : NULL);
}
STDMETHODIMP_(REFERENCE_TIME) CVobSubFile::GetStart(POSITION pos, double fps)
{
- int i = (int)pos-1;
- return (GetFrame(i) ? 10000i64*m_img.start : 0);
+ int i = (int)pos - 1;
+ return (GetFrame(i) ? 10000i64 * m_img.start : 0);
}
STDMETHODIMP_(REFERENCE_TIME) CVobSubFile::GetStop(POSITION pos, double fps)
{
- int i = (int)pos-1;
- return (GetFrame(i) ? 10000i64*(m_img.start + m_img.delay) : 0);
+ int i = (int)pos - 1;
+ return (GetFrame(i) ? 10000i64 * (m_img.start + m_img.delay) : 0);
}
STDMETHODIMP_(bool) CVobSubFile::IsAnimated(POSITION pos)
{
- return false;
+ return false;
}
STDMETHODIMP CVobSubFile::Render(SubPicDesc& spd, REFERENCE_TIME rt, double fps, RECT& bbox)
{
- if (spd.bpp != 32) {
- return E_INVALIDARG;
- }
+ if (spd.bpp != 32) {
+ return E_INVALIDARG;
+ }
- rt /= 10000;
+ rt /= 10000;
- if (!GetFrame(GetFrameIdxByTimeStamp(rt))) {
- return E_FAIL;
- }
+ if (!GetFrame(GetFrameIdxByTimeStamp(rt))) {
+ return E_FAIL;
+ }
- if (rt >= (m_img.start + m_img.delay)) {
- return E_FAIL;
- }
+ if (rt >= (m_img.start + m_img.delay)) {
+ return E_FAIL;
+ }
- return __super::Render(spd, bbox);
+ return __super::Render(spd, bbox);
}
// IPersist
STDMETHODIMP CVobSubFile::GetClassID(CLSID* pClassID)
{
- return pClassID ? *pClassID = __uuidof(this), S_OK : E_POINTER;
+ return pClassID ? *pClassID = __uuidof(this), S_OK : E_POINTER;
}
// ISubStream
STDMETHODIMP_(int) CVobSubFile::GetStreamCount()
{
- int iStreamCount = 0;
- for (size_t i = 0; i < 32; i++)
- if (m_langs[i].subpos.GetCount()) {
- iStreamCount++;
- }
- return iStreamCount;
+ int iStreamCount = 0;
+ for (size_t i = 0; i < 32; i++)
+ if (m_langs[i].subpos.GetCount()) {
+ iStreamCount++;
+ }
+ return iStreamCount;
}
STDMETHODIMP CVobSubFile::GetStreamInfo(int iStream, WCHAR** ppName, LCID* pLCID)
{
- for (size_t i = 0; i < 32; i++) {
- SubLang& sl = m_langs[i];
+ for (size_t i = 0; i < 32; i++) {
+ SubLang& sl = m_langs[i];
- if (sl.subpos.IsEmpty() || iStream-- > 0) {
- continue;
- }
+ if (sl.subpos.IsEmpty() || iStream-- > 0) {
+ continue;
+ }
- if (ppName) {
- *ppName = (WCHAR*)CoTaskMemAlloc((sl.alt.GetLength() + 1) * sizeof(WCHAR));
- if (!(*ppName)) {
- return E_OUTOFMEMORY;
- }
+ if (ppName) {
+ *ppName = (WCHAR*)CoTaskMemAlloc((sl.alt.GetLength() + 1) * sizeof(WCHAR));
+ if (!(*ppName)) {
+ return E_OUTOFMEMORY;
+ }
- wcscpy_s(*ppName, sl.alt.GetLength() + 1, CStringW(sl.alt));
- }
+ wcscpy_s(*ppName, sl.alt.GetLength() + 1, CStringW(sl.alt));
+ }
- if (pLCID) {
- *pLCID = 0; // TODO: make lcid out of "sl.id"
- }
+ if (pLCID) {
+ *pLCID = 0; // TODO: make lcid out of "sl.id"
+ }
- return S_OK;
- }
+ return S_OK;
+ }
- return E_FAIL;
+ return E_FAIL;
}
STDMETHODIMP_(int) CVobSubFile::GetStream()
{
- int iStream = 0;
+ int iStream = 0;
- for (ptrdiff_t i = 0; i < m_iLang; i++)
- if (!m_langs[i].subpos.IsEmpty()) {
- iStream++;
- }
+ for (ptrdiff_t i = 0; i < m_iLang; i++)
+ if (!m_langs[i].subpos.IsEmpty()) {
+ iStream++;
+ }
- return iStream;
+ return iStream;
}
STDMETHODIMP CVobSubFile::SetStream(int iStream)
{
- for (int i = 0; i < 32; i++) {
- CAtlArray<SubPos>& sp = m_langs[i].subpos;
+ for (int i = 0; i < 32; i++) {
+ CAtlArray<SubPos>& sp = m_langs[i].subpos;
- if (sp.IsEmpty() || iStream-- > 0) {
- continue;
- }
+ if (sp.IsEmpty() || iStream-- > 0) {
+ continue;
+ }
- m_iLang = i;
+ m_iLang = i;
- m_img.Invalidate();
+ m_img.Invalidate();
- break;
- }
+ break;
+ }
- return iStream < 0 ? S_OK : E_FAIL;
+ return iStream < 0 ? S_OK : E_FAIL;
}
STDMETHODIMP CVobSubFile::Reload()
{
- CFileStatus s;
- if (!CFile::GetStatus(m_title + _T(".idx"), s)) {
- return E_FAIL;
- }
- return !m_title.IsEmpty() && Open(m_title) ? S_OK : E_FAIL;
+ CFileStatus s;
+ if (!CFile::GetStatus(m_title + _T(".idx"), s)) {
+ return E_FAIL;
+ }
+ return !m_title.IsEmpty() && Open(m_title) ? S_OK : E_FAIL;
}
// StretchBlt
static void PixelAtBiLinear(RGBQUAD& c, int x, int y, CVobSubImage& src)
{
- int w = src.rect.Width(),
- h = src.rect.Height();
+ int w = src.rect.Width(),
+ h = src.rect.Height();
- int x1 = (x >> 16), y1 = (y >> 16) * w,
- x2 = min(x1 + 1, w-1), y2 = min(y1 + w, (h-1)*w);
+ int x1 = (x >> 16), y1 = (y >> 16) * w,
+ x2 = min(x1 + 1, w - 1), y2 = min(y1 + w, (h - 1) * w);
- RGBQUAD* ptr = src.lpPixels;
+ RGBQUAD* ptr = src.lpPixels;
- RGBQUAD c11 = ptr[y1 + x1], c12 = ptr[y1 + x2],
- c21 = ptr[y2 + x1], c22 = ptr[y2 + x2];
+ RGBQUAD c11 = ptr[y1 + x1], c12 = ptr[y1 + x2],
+ c21 = ptr[y2 + x1], c22 = ptr[y2 + x2];
- __int64 u2 = x & 0xffff,
- v2 = y & 0xffff,
- u1 = 0x10000 - u2,
- v1 = 0x10000 - v2;
+ __int64 u2 = x & 0xffff,
+ v2 = y & 0xffff,
+ u1 = 0x10000 - u2,
+ v1 = 0x10000 - v2;
- int v1u1 = int(v1*u1 >> 16) * c11.rgbReserved,
- v1u2 = int(v1*u2 >> 16) * c12.rgbReserved,
- v2u1 = int(v2*u1 >> 16) * c21.rgbReserved,
- v2u2 = int(v2*u2 >> 16) * c22.rgbReserved;
+ int v1u1 = int(v1 * u1 >> 16) * c11.rgbReserved,
+ v1u2 = int(v1 * u2 >> 16) * c12.rgbReserved,
+ v2u1 = int(v2 * u1 >> 16) * c21.rgbReserved,
+ v2u2 = int(v2 * u2 >> 16) * c22.rgbReserved;
- c.rgbRed = (c11.rgbRed * v1u1 + c12.rgbRed * v1u2
- + c21.rgbRed * v2u1 + c22.rgbRed * v2u2) >> 24;
- c.rgbGreen = (c11.rgbGreen * v1u1 + c12.rgbGreen * v1u2
- + c21.rgbGreen * v2u1 + c22.rgbGreen * v2u2) >> 24;
- c.rgbBlue = (c11.rgbBlue * v1u1 + c12.rgbBlue * v1u2
- + c21.rgbBlue * v2u1 + c22.rgbBlue * v2u2) >> 24;
- c.rgbReserved = (v1u1 + v1u2
- + v2u1 + v2u2) >> 16;
+ c.rgbRed = (c11.rgbRed * v1u1 + c12.rgbRed * v1u2
+ + c21.rgbRed * v2u1 + c22.rgbRed * v2u2) >> 24;
+ c.rgbGreen = (c11.rgbGreen * v1u1 + c12.rgbGreen * v1u2
+ + c21.rgbGreen * v2u1 + c22.rgbGreen * v2u2) >> 24;
+ c.rgbBlue = (c11.rgbBlue * v1u1 + c12.rgbBlue * v1u2
+ + c21.rgbBlue * v2u1 + c22.rgbBlue * v2u2) >> 24;
+ c.rgbReserved = (v1u1 + v1u2
+ + v2u1 + v2u2) >> 16;
}
static void StretchBlt(SubPicDesc& spd, CRect dstrect, CVobSubImage& src)
{
- if (dstrect.IsRectEmpty()) {
- return;
- }
-
- if ((dstrect & CRect(0, 0, spd.w, spd.h)).IsRectEmpty()) {
- return;
- }
-
- int sw = src.rect.Width(),
- sh = src.rect.Height(),
- dw = dstrect.Width(),
- dh = dstrect.Height();
-
- int srcx = 0,
- srcy = 0,
- srcdx = (sw << 16) / dw >> 1,
- srcdy = (sh << 16) / dh >> 1;
-
- if (dstrect.left < 0) {
- srcx = -dstrect.left * (srcdx << 1);
- dstrect.left = 0;
- }
- if (dstrect.top < 0) {
- srcy = -dstrect.top * (srcdy << 1);
- dstrect.top = 0;
- }
- if (dstrect.right > spd.w) {
- dstrect.right = spd.w;
- }
- if (dstrect.bottom > spd.h) {
- dstrect.bottom = spd.h;
- }
-
- if ((dstrect & CRect(0, 0, spd.w, spd.h)).IsRectEmpty()) {
- return;
- }
-
- dw = dstrect.Width();
- dh = dstrect.Height();
-
- for (int y = dstrect.top; y < dstrect.bottom; y++, srcy += (srcdy<<1)) {
- RGBQUAD* ptr = (RGBQUAD*)&((BYTE*)spd.bits)[y*spd.pitch] + dstrect.left;
- RGBQUAD* endptr = ptr + dw;
-
- for (int sx = srcx; ptr < endptr; sx += (srcdx<<1), ptr++) {
- // PixelAtBiLinear(*ptr, sx, srcy, src);
- ////
- RGBQUAD cc[4];
-
- PixelAtBiLinear(cc[0], sx, srcy, src);
- PixelAtBiLinear(cc[1], sx+srcdx, srcy, src);
- PixelAtBiLinear(cc[2], sx, srcy+srcdy, src);
- PixelAtBiLinear(cc[3], sx+srcdx, srcy+srcdy, src);
-
- ptr->rgbRed = (cc[0].rgbRed + cc[1].rgbRed + cc[2].rgbRed + cc[3].rgbRed) >> 2;
- ptr->rgbGreen = (cc[0].rgbGreen + cc[1].rgbGreen + cc[2].rgbGreen + cc[3].rgbGreen) >> 2;
- ptr->rgbBlue = (cc[0].rgbBlue + cc[1].rgbBlue + cc[2].rgbBlue + cc[3].rgbBlue) >> 2;
- ptr->rgbReserved = (cc[0].rgbReserved + cc[1].rgbReserved + cc[2].rgbReserved + cc[3].rgbReserved) >> 2;
- ////
- ptr->rgbRed = ptr->rgbRed * ptr->rgbReserved >> 8;
- ptr->rgbGreen = ptr->rgbGreen * ptr->rgbReserved >> 8;
- ptr->rgbBlue = ptr->rgbBlue * ptr->rgbReserved >> 8;
- ptr->rgbReserved = ~ptr->rgbReserved;
-
- }
- }
+ if (dstrect.IsRectEmpty()) {
+ return;
+ }
+
+ if ((dstrect & CRect(0, 0, spd.w, spd.h)).IsRectEmpty()) {
+ return;
+ }
+
+ int sw = src.rect.Width(),
+ sh = src.rect.Height(),
+ dw = dstrect.Width(),
+ dh = dstrect.Height();
+
+ int srcx = 0,
+ srcy = 0,
+ srcdx = (sw << 16) / dw >> 1,
+ srcdy = (sh << 16) / dh >> 1;
+
+ if (dstrect.left < 0) {
+ srcx = -dstrect.left * (srcdx << 1);
+ dstrect.left = 0;
+ }
+ if (dstrect.top < 0) {
+ srcy = -dstrect.top * (srcdy << 1);
+ dstrect.top = 0;
+ }
+ if (dstrect.right > spd.w) {
+ dstrect.right = spd.w;
+ }
+ if (dstrect.bottom > spd.h) {
+ dstrect.bottom = spd.h;
+ }
+
+ if ((dstrect & CRect(0, 0, spd.w, spd.h)).IsRectEmpty()) {
+ return;
+ }
+
+ dw = dstrect.Width();
+ dh = dstrect.Height();
+
+ for (int y = dstrect.top; y < dstrect.bottom; y++, srcy += (srcdy << 1)) {
+ RGBQUAD* ptr = (RGBQUAD*) & ((BYTE*)spd.bits)[y * spd.pitch] + dstrect.left;
+ RGBQUAD* endptr = ptr + dw;
+
+ for (int sx = srcx; ptr < endptr; sx += (srcdx << 1), ptr++) {
+ // PixelAtBiLinear(*ptr, sx, srcy, src);
+ ////
+ RGBQUAD cc[4];
+
+ PixelAtBiLinear(cc[0], sx, srcy, src);
+ PixelAtBiLinear(cc[1], sx + srcdx, srcy, src);
+ PixelAtBiLinear(cc[2], sx, srcy + srcdy, src);
+ PixelAtBiLinear(cc[3], sx + srcdx, srcy + srcdy, src);
+
+ ptr->rgbRed = (cc[0].rgbRed + cc[1].rgbRed + cc[2].rgbRed + cc[3].rgbRed) >> 2;
+ ptr->rgbGreen = (cc[0].rgbGreen + cc[1].rgbGreen + cc[2].rgbGreen + cc[3].rgbGreen) >> 2;
+ ptr->rgbBlue = (cc[0].rgbBlue + cc[1].rgbBlue + cc[2].rgbBlue + cc[3].rgbBlue) >> 2;
+ ptr->rgbReserved = (cc[0].rgbReserved + cc[1].rgbReserved + cc[2].rgbReserved + cc[3].rgbReserved) >> 2;
+ ////
+ ptr->rgbRed = ptr->rgbRed * ptr->rgbReserved >> 8;
+ ptr->rgbGreen = ptr->rgbGreen * ptr->rgbReserved >> 8;
+ ptr->rgbBlue = ptr->rgbBlue * ptr->rgbReserved >> 8;
+ ptr->rgbReserved = ~ptr->rgbReserved;
+
+ }
+ }
}
//
@@ -1506,777 +1506,777 @@ static void StretchBlt(SubPicDesc& spd, CRect dstrect, CVobSubImage& src)
void CVobSubSettings::InitSettings()
{
- m_size.SetSize(720, 480);
- m_toff = m_x = m_y = 0;
- m_org.SetPoint(0, 0);
- m_scale_x = m_scale_y = m_alpha = 100;
- m_fadein = m_fadeout = 50;
- m_fSmooth = 0;
- m_fAlign = false;
- m_alignhor = m_alignver = 0;
- m_fOnlyShowForcedSubs = false;
- m_fCustomPal = false;
- m_tridx = 0;
- memset(m_orgpal, 0, sizeof(m_orgpal));
- memset(m_cuspal, 0, sizeof(m_cuspal));
+ m_size.SetSize(720, 480);
+ m_toff = m_x = m_y = 0;
+ m_org.SetPoint(0, 0);
+ m_scale_x = m_scale_y = m_alpha = 100;
+ m_fadein = m_fadeout = 50;
+ m_fSmooth = 0;
+ m_fAlign = false;
+ m_alignhor = m_alignver = 0;
+ m_fOnlyShowForcedSubs = false;
+ m_fCustomPal = false;
+ m_tridx = 0;
+ memset(m_orgpal, 0, sizeof(m_orgpal));
+ memset(m_cuspal, 0, sizeof(m_cuspal));
}
bool CVobSubSettings::GetCustomPal(RGBQUAD* cuspal, int& tridx)
{
- memcpy(cuspal, m_cuspal, sizeof(RGBQUAD)*4);
- tridx = m_tridx;
- return m_fCustomPal;
+ memcpy(cuspal, m_cuspal, sizeof(RGBQUAD) * 4);
+ tridx = m_tridx;
+ return m_fCustomPal;
}
void CVobSubSettings::SetCustomPal(RGBQUAD* cuspal, int tridx)
{
- memcpy(m_cuspal, cuspal, sizeof(RGBQUAD)*4);
- m_tridx = tridx & 0xf;
- for (int i = 0; i < 4; i++) {
- m_cuspal[i].rgbReserved = (tridx&(1<<i)) ? 0 : 0xff;
- }
- m_img.Invalidate();
+ memcpy(m_cuspal, cuspal, sizeof(RGBQUAD) * 4);
+ m_tridx = tridx & 0xf;
+ for (int i = 0; i < 4; i++) {
+ m_cuspal[i].rgbReserved = (tridx & (1 << i)) ? 0 : 0xff;
+ }
+ m_img.Invalidate();
}
void CVobSubSettings::GetDestrect(CRect& r)
{
- int w = MulDiv(m_img.rect.Width(), m_scale_x, 100);
- int h = MulDiv(m_img.rect.Height(), m_scale_y, 100);
-
- if (!m_fAlign) {
- r.left = MulDiv(m_img.rect.left, m_scale_x, 100);
- r.right = MulDiv(m_img.rect.right, m_scale_x, 100);
- r.top = MulDiv(m_img.rect.top, m_scale_y, 100);
- r.bottom = MulDiv(m_img.rect.bottom, m_scale_y, 100);
- } else {
- switch (m_alignhor) {
- case 0:
- r.left = 0;
- r.right = w;
- break; // left
- case 1:
- r.left = -(w >> 1);
- r.right = -(w >> 1) + w;
- break; // center
- case 2:
- r.left = -w;
- r.right = 0;
- break; // right
- default:
- r.left = MulDiv(m_img.rect.left, m_scale_x, 100);
- r.right = MulDiv(m_img.rect.right, m_scale_x, 100);
- break;
- }
-
- switch (m_alignver) {
- case 0:
- r.top = 0;
- r.bottom = h;
- break; // top
- case 1:
- r.top = -(h >> 1);
- r.bottom = -(h >> 1) + h;
- break; // center
- case 2:
- r.top = -h;
- r.bottom = 0;
- break; // bottom
- default:
- r.top = MulDiv(m_img.rect.top, m_scale_y, 100);
- r.bottom = MulDiv(m_img.rect.bottom, m_scale_y, 100);
- break;
- }
- }
-
- r += m_org;
+ int w = MulDiv(m_img.rect.Width(), m_scale_x, 100);
+ int h = MulDiv(m_img.rect.Height(), m_scale_y, 100);
+
+ if (!m_fAlign) {
+ r.left = MulDiv(m_img.rect.left, m_scale_x, 100);
+ r.right = MulDiv(m_img.rect.right, m_scale_x, 100);
+ r.top = MulDiv(m_img.rect.top, m_scale_y, 100);
+ r.bottom = MulDiv(m_img.rect.bottom, m_scale_y, 100);
+ } else {
+ switch (m_alignhor) {
+ case 0:
+ r.left = 0;
+ r.right = w;
+ break; // left
+ case 1:
+ r.left = -(w >> 1);
+ r.right = -(w >> 1) + w;
+ break; // center
+ case 2:
+ r.left = -w;
+ r.right = 0;
+ break; // right
+ default:
+ r.left = MulDiv(m_img.rect.left, m_scale_x, 100);
+ r.right = MulDiv(m_img.rect.right, m_scale_x, 100);
+ break;
+ }
+
+ switch (m_alignver) {
+ case 0:
+ r.top = 0;
+ r.bottom = h;
+ break; // top
+ case 1:
+ r.top = -(h >> 1);
+ r.bottom = -(h >> 1) + h;
+ break; // center
+ case 2:
+ r.top = -h;
+ r.bottom = 0;
+ break; // bottom
+ default:
+ r.top = MulDiv(m_img.rect.top, m_scale_y, 100);
+ r.bottom = MulDiv(m_img.rect.bottom, m_scale_y, 100);
+ break;
+ }
+ }
+
+ r += m_org;
}
void CVobSubSettings::GetDestrect(CRect& r, int w, int h)
{
- GetDestrect(r);
+ GetDestrect(r);
- r.left = MulDiv(r.left, w, m_size.cx);
- r.right = MulDiv(r.right, w, m_size.cx);
- r.top = MulDiv(r.top, h, m_size.cy);
- r.bottom = MulDiv(r.bottom, h, m_size.cy);
+ r.left = MulDiv(r.left, w, m_size.cx);
+ r.right = MulDiv(r.right, w, m_size.cx);
+ r.top = MulDiv(r.top, h, m_size.cy);
+ r.bottom = MulDiv(r.bottom, h, m_size.cy);
}
void CVobSubSettings::SetAlignment(bool fAlign, int x, int y, int hor, int ver)
{
- m_fAlign = fAlign;
- if (fAlign) {
- m_org.x = MulDiv(m_size.cx, x, 100);
- m_org.y = MulDiv(m_size.cy, y, 100);
- m_alignhor = min(max(hor, 0), 2);
- m_alignver = min(max(ver, 0), 2);
- } else {
- m_org.x = m_x;
- m_org.y = m_y;
- }
+ m_fAlign = fAlign;
+ if (fAlign) {
+ m_org.x = MulDiv(m_size.cx, x, 100);
+ m_org.y = MulDiv(m_size.cy, y, 100);
+ m_alignhor = min(max(hor, 0), 2);
+ m_alignver = min(max(ver, 0), 2);
+ } else {
+ m_org.x = m_x;
+ m_org.y = m_y;
+ }
}
HRESULT CVobSubSettings::Render(SubPicDesc& spd, RECT& bbox)
{
- CRect r;
- GetDestrect(r, spd.w, spd.h);
- StretchBlt(spd, r, m_img);
- /*
- CRenderedTextSubtitle rts(NULL);
- rts.CreateDefaultStyle(DEFAULT_CHARSET);
- rts.m_dstScreenSize.SetSize(m_size.cx, m_size.cy);
- CStringW assstr;
- m_img.Polygonize(assstr, false);
- REFERENCE_TIME rtStart = 10000i64*m_img.start, rtStop = 10000i64*(m_img.start+m_img.delay);
- rts.Add(assstr, true, rtStart, rtStop);
- rts.Render(spd, (rtStart+rtStop)/2, 25, r);
- */
- r &= CRect(CPoint(0, 0), CSize(spd.w, spd.h));
- bbox = r;
- return !r.IsRectEmpty() ? S_OK : S_FALSE;
+ CRect r;
+ GetDestrect(r, spd.w, spd.h);
+ StretchBlt(spd, r, m_img);
+ /*
+ CRenderedTextSubtitle rts(NULL);
+ rts.CreateDefaultStyle(DEFAULT_CHARSET);
+ rts.m_dstScreenSize.SetSize(m_size.cx, m_size.cy);
+ CStringW assstr;
+ m_img.Polygonize(assstr, false);
+ REFERENCE_TIME rtStart = 10000i64*m_img.start, rtStop = 10000i64*(m_img.start+m_img.delay);
+ rts.Add(assstr, true, rtStart, rtStop);
+ rts.Render(spd, (rtStart+rtStop)/2, 25, r);
+ */
+ r &= CRect(CPoint(0, 0), CSize(spd.w, spd.h));
+ bbox = r;
+ return !r.IsRectEmpty() ? S_OK : S_FALSE;
}
/////////////////////////////////////////////////////////
static bool CompressFile(CString fn)
{
- if (GetVersion() < 0) {
- return false;
- }
+ if (GetVersion() < 0) {
+ return false;
+ }
- BOOL b = FALSE;
+ BOOL b = FALSE;
- HANDLE h = CreateFile(fn, GENERIC_WRITE|GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, 0);
- if (h != INVALID_HANDLE_VALUE) {
- USHORT us = COMPRESSION_FORMAT_DEFAULT;
- DWORD nBytesReturned;
- b = DeviceIoControl(h, FSCTL_SET_COMPRESSION, (LPVOID)&us, 2, NULL, 0, (LPDWORD)&nBytesReturned, NULL);
- CloseHandle(h);
- }
+ HANDLE h = CreateFile(fn, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, 0);
+ if (h != INVALID_HANDLE_VALUE) {
+ USHORT us = COMPRESSION_FORMAT_DEFAULT;
+ DWORD nBytesReturned;
+ b = DeviceIoControl(h, FSCTL_SET_COMPRESSION, (LPVOID)&us, 2, NULL, 0, (LPDWORD)&nBytesReturned, NULL);
+ CloseHandle(h);
+ }
- return !!b;
+ return !!b;
}
bool CVobSubFile::SaveVobSub(CString fn)
{
- return WriteIdx(fn + _T(".idx")) && WriteSub(fn + _T(".sub"));
+ return WriteIdx(fn + _T(".idx")) && WriteSub(fn + _T(".sub"));
}
bool CVobSubFile::SaveWinSubMux(CString fn)
{
- TrimExtension(fn);
-
- CStdioFile f;
- if (!f.Open(fn + _T(".sub"), CFile::modeCreate|CFile::modeWrite|CFile::typeText|CFile::shareDenyWrite)) {
- return false;
- }
-
- m_img.Invalidate();
-
- CAutoVectorPtr<BYTE> p4bpp;
- if (!p4bpp.Allocate(720*576/2)) {
- return false;
- }
-
- CAtlArray<SubPos>& sp = m_langs[m_iLang].subpos;
- for (size_t i = 0; i < sp.GetCount(); i++) {
- if (!GetFrame((int)i)) {
- continue;
- }
-
- int pal[4] = {0, 1, 2, 3};
-
- for (int j = 0; j < 5; j++) {
- if (j == 4 || !m_img.pal[j].tr) {
- j &= 3;
- memset(p4bpp, (j<<4)|j, 720*576/2);
- pal[j] ^= pal[0], pal[0] ^= pal[j], pal[j] ^= pal[0];
- break;
- }
- }
-
- int tr[4] = {m_img.pal[pal[0]].tr, m_img.pal[pal[1]].tr, m_img.pal[pal[2]].tr, m_img.pal[pal[3]].tr};
-
- DWORD uipal[4+12];
-
- if (!m_fCustomPal) {
- uipal[0] = *((DWORD*)&m_img.orgpal[m_img.pal[pal[0]].pal]);
- uipal[1] = *((DWORD*)&m_img.orgpal[m_img.pal[pal[1]].pal]);
- uipal[2] = *((DWORD*)&m_img.orgpal[m_img.pal[pal[2]].pal]);
- uipal[3] = *((DWORD*)&m_img.orgpal[m_img.pal[pal[3]].pal]);
- } else {
- uipal[0] = *((DWORD*)&m_img.cuspal[pal[0]]) & 0xffffff;
- uipal[1] = *((DWORD*)&m_img.cuspal[pal[1]]) & 0xffffff;
- uipal[2] = *((DWORD*)&m_img.cuspal[pal[2]]) & 0xffffff;
- uipal[3] = *((DWORD*)&m_img.cuspal[pal[3]]) & 0xffffff;
- }
-
- CAtlMap<DWORD,BYTE> palmap;
- palmap[uipal[0]] = 0;
- palmap[uipal[1]] = 1;
- palmap[uipal[2]] = 2;
- palmap[uipal[3]] = 3;
-
- uipal[0] = 0xff; // blue background
-
- int w = m_img.rect.Width()-2;
- int h = m_img.rect.Height()-2;
- int pitch = (((w+1)>>1) + 3) & ~3;
-
- for (ptrdiff_t y = 0; y < h; y++) {
- DWORD* p = (DWORD*)&m_img.lpPixels[(y+1)*(w+2)+1];
-
- for (ptrdiff_t x = 0; x < w; x++, p++) {
- BYTE c = 0;
-
- if (*p & 0xff000000) {
- DWORD uic = *p & 0xffffff;
- palmap.Lookup(uic, c);
- }
-
- BYTE& c4bpp = p4bpp[(h-y-1)*pitch+(x>>1)];
- c4bpp = (x&1) ? ((c4bpp&0xf0)|c) : ((c4bpp&0x0f)|(c<<4));
- }
- }
-
- int t1 = (int)m_img.start;
- int t2 = t1 + (int)m_img.delay /*+ (m_size.cy==480?(1000/29.97+1):(1000/25))*/;
-
- ASSERT(t2>t1);
-
- if (t2 <= 0) {
- continue;
- }
- if (t1 < 0) {
- t1 = 0;
- }
-
- CString bmpfn;
- bmpfn.Format(_T("%s_%06d.bmp"), fn, i+1);
-
- CString str;
- str.Format(_T("%s\t%02d:%02d:%02d:%02d %02d:%02d:%02d:%02d\t%03d %03d %03d %03d %d %d %d %d\n"),
- bmpfn,
- t1/1000/60/60, (t1/1000/60)%60, (t1/1000)%60, (t1%1000)/10,
- t2/1000/60/60, (t2/1000/60)%60, (t2/1000)%60, (t2%1000)/10,
- m_img.rect.Width(), m_img.rect.Height(), m_img.rect.left, m_img.rect.top,
- (tr[0]<<4)|tr[0], (tr[1]<<4)|tr[1], (tr[2]<<4)|tr[2], (tr[3]<<4)|tr[3]);
- f.WriteString(str);
-
- BITMAPFILEHEADER fhdr = {
- 0x4d42,
- sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + 16*sizeof(RGBQUAD) + pitch*h,
- 0, 0,
- sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + 16*sizeof(RGBQUAD)
- };
-
- BITMAPINFOHEADER ihdr = {
- sizeof(BITMAPINFOHEADER),
- w, h, 1, 4, 0,
- 0,
- pitch*h, 0,
- 16, 4
- };
-
- CFile bmp;
- if (bmp.Open(bmpfn, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary|CFile::shareDenyWrite)) {
- bmp.Write(&fhdr, sizeof(fhdr));
- bmp.Write(&ihdr, sizeof(ihdr));
- bmp.Write(uipal, sizeof(RGBQUAD)*16);
- bmp.Write(p4bpp, pitch*h);
- bmp.Close();
-
- CompressFile(bmpfn);
- }
- }
-
- return true;
+ TrimExtension(fn);
+
+ CStdioFile f;
+ if (!f.Open(fn + _T(".sub"), CFile::modeCreate | CFile::modeWrite | CFile::typeText | CFile::shareDenyWrite)) {
+ return false;
+ }
+
+ m_img.Invalidate();
+
+ CAutoVectorPtr<BYTE> p4bpp;
+ if (!p4bpp.Allocate(720 * 576 / 2)) {
+ return false;
+ }
+
+ CAtlArray<SubPos>& sp = m_langs[m_iLang].subpos;
+ for (size_t i = 0; i < sp.GetCount(); i++) {
+ if (!GetFrame((int)i)) {
+ continue;
+ }
+
+ int pal[4] = {0, 1, 2, 3};
+
+ for (int j = 0; j < 5; j++) {
+ if (j == 4 || !m_img.pal[j].tr) {
+ j &= 3;
+ memset(p4bpp, (j << 4) | j, 720 * 576 / 2);
+ pal[j] ^= pal[0], pal[0] ^= pal[j], pal[j] ^= pal[0];
+ break;
+ }
+ }
+
+ int tr[4] = {m_img.pal[pal[0]].tr, m_img.pal[pal[1]].tr, m_img.pal[pal[2]].tr, m_img.pal[pal[3]].tr};
+
+ DWORD uipal[4 + 12];
+
+ if (!m_fCustomPal) {
+ uipal[0] = *((DWORD*)&m_img.orgpal[m_img.pal[pal[0]].pal]);
+ uipal[1] = *((DWORD*)&m_img.orgpal[m_img.pal[pal[1]].pal]);
+ uipal[2] = *((DWORD*)&m_img.orgpal[m_img.pal[pal[2]].pal]);
+ uipal[3] = *((DWORD*)&m_img.orgpal[m_img.pal[pal[3]].pal]);
+ } else {
+ uipal[0] = *((DWORD*)&m_img.cuspal[pal[0]]) & 0xffffff;
+ uipal[1] = *((DWORD*)&m_img.cuspal[pal[1]]) & 0xffffff;
+ uipal[2] = *((DWORD*)&m_img.cuspal[pal[2]]) & 0xffffff;
+ uipal[3] = *((DWORD*)&m_img.cuspal[pal[3]]) & 0xffffff;
+ }
+
+ CAtlMap<DWORD, BYTE> palmap;
+ palmap[uipal[0]] = 0;
+ palmap[uipal[1]] = 1;
+ palmap[uipal[2]] = 2;
+ palmap[uipal[3]] = 3;
+
+ uipal[0] = 0xff; // blue background
+
+ int w = m_img.rect.Width() - 2;
+ int h = m_img.rect.Height() - 2;
+ int pitch = (((w + 1) >> 1) + 3) & ~3;
+
+ for (ptrdiff_t y = 0; y < h; y++) {
+ DWORD* p = (DWORD*)&m_img.lpPixels[(y + 1) * (w + 2) + 1];
+
+ for (ptrdiff_t x = 0; x < w; x++, p++) {
+ BYTE c = 0;
+
+ if (*p & 0xff000000) {
+ DWORD uic = *p & 0xffffff;
+ palmap.Lookup(uic, c);
+ }
+
+ BYTE& c4bpp = p4bpp[(h - y - 1) * pitch + (x >> 1)];
+ c4bpp = (x & 1) ? ((c4bpp & 0xf0) | c) : ((c4bpp & 0x0f) | (c << 4));
+ }
+ }
+
+ int t1 = (int)m_img.start;
+ int t2 = t1 + (int)m_img.delay /*+ (m_size.cy==480?(1000/29.97+1):(1000/25))*/;
+
+ ASSERT(t2 > t1);
+
+ if (t2 <= 0) {
+ continue;
+ }
+ if (t1 < 0) {
+ t1 = 0;
+ }
+
+ CString bmpfn;
+ bmpfn.Format(_T("%s_%06d.bmp"), fn, i + 1);
+
+ CString str;
+ str.Format(_T("%s\t%02d:%02d:%02d:%02d %02d:%02d:%02d:%02d\t%03d %03d %03d %03d %d %d %d %d\n"),
+ bmpfn,
+ t1 / 1000 / 60 / 60, (t1 / 1000 / 60) % 60, (t1 / 1000) % 60, (t1 % 1000) / 10,
+ t2 / 1000 / 60 / 60, (t2 / 1000 / 60) % 60, (t2 / 1000) % 60, (t2 % 1000) / 10,
+ m_img.rect.Width(), m_img.rect.Height(), m_img.rect.left, m_img.rect.top,
+ (tr[0] << 4) | tr[0], (tr[1] << 4) | tr[1], (tr[2] << 4) | tr[2], (tr[3] << 4) | tr[3]);
+ f.WriteString(str);
+
+ BITMAPFILEHEADER fhdr = {
+ 0x4d42,
+ sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + 16 * sizeof(RGBQUAD) + pitch * h,
+ 0, 0,
+ sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + 16 * sizeof(RGBQUAD)
+ };
+
+ BITMAPINFOHEADER ihdr = {
+ sizeof(BITMAPINFOHEADER),
+ w, h, 1, 4, 0,
+ 0,
+ pitch * h, 0,
+ 16, 4
+ };
+
+ CFile bmp;
+ if (bmp.Open(bmpfn, CFile::modeCreate | CFile::modeWrite | CFile::typeBinary | CFile::shareDenyWrite)) {
+ bmp.Write(&fhdr, sizeof(fhdr));
+ bmp.Write(&ihdr, sizeof(ihdr));
+ bmp.Write(uipal, sizeof(RGBQUAD) * 16);
+ bmp.Write(p4bpp, pitch * h);
+ bmp.Close();
+
+ CompressFile(bmpfn);
+ }
+ }
+
+ return true;
}
bool CVobSubFile::SaveScenarist(CString fn)
{
- TrimExtension(fn);
-
- CStdioFile f;
- if (!f.Open(fn + _T(".sst"), CFile::modeCreate|CFile::modeWrite|CFile::typeText|CFile::shareDenyWrite)) {
- return false;
- }
-
- m_img.Invalidate();
-
- fn.Replace('\\', '/');
- CString title = fn.Mid(fn.ReverseFind('/')+1);
-
- TCHAR buff[_MAX_PATH], * pFilePart = buff;
- if (GetFullPathName(fn, _MAX_PATH, buff, &pFilePart) == 0) {
- return false;
- }
-
- CString fullpath = CString(buff).Left(int(pFilePart - buff));
- fullpath.TrimRight(_T("\\/"));
- if (fullpath.IsEmpty()) {
- return false;
- }
-
- CString str, str2;
- str += _T("st_format\t2\n");
- str += _T("Display_Start\t%s\n");
- str += _T("TV_Type\t\t%s\n");
- str += _T("Tape_Type\tNON_DROP\n");
- str += _T("Pixel_Area\t(0 %d)\n");
- str += _T("Directory\t%s\n");
- str += _T("Subtitle\t%s\n");
- str += _T("Display_Area\t(0 2 719 %d)\n");
- str += _T("Contrast\t(15 15 15 0)\n");
- str += _T("\n");
- str += _T("PA\t(0 0 255 - - - )\n");
- str += _T("E1\t(255 0 0 - - - )\n");
- str += _T("E2\t(0 0 0 - - - )\n");
- str += _T("BG\t(255 255 255 - - - )\n");
- str += _T("\n");
- str += _T("SP_NUMBER\tSTART\tEND\tFILE_NAME\n");
- str2.Format(str,
- !m_fOnlyShowForcedSubs ? _T("non_forced") : _T("forced"),
- m_size.cy == 480 ? _T("NTSC") : _T("PAL"),
- m_size.cy-3,
- fullpath,
- title,
- m_size.cy == 480 ? 479 : 574);
-
- f.WriteString(str2);
-
- f.Flush();
-
- RGBQUAD pal[16] = {
- {255, 0, 0, 0},
- {0, 0, 255, 0},
- {0, 0, 0, 0},
- {255, 255, 255, 0},
- {0, 255, 0, 0},
- {255, 0, 255, 0},
- {0, 255, 255, 0},
- {125, 125, 0, 0},
- {125, 125, 125, 0},
- {225, 225, 225, 0},
- {0, 0, 125, 0},
- {0, 125, 0, 0},
- {125, 0, 0, 0},
- {255, 0, 222, 0},
- {0, 125, 222, 0},
- {125, 0, 125, 0},
- };
-
- BITMAPFILEHEADER fhdr = {
- 0x4d42,
- sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + 16*sizeof(RGBQUAD) + 360*(m_size.cy-2),
- 0, 0,
- sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + 16*sizeof(RGBQUAD)
- };
-
- BITMAPINFOHEADER ihdr = {
- sizeof(BITMAPINFOHEADER),
- 720, m_size.cy-2, 1, 4, 0,
- 360*(m_size.cy-2),
- 0, 0,
- 16, 4
- };
-
- bool fCustomPal = m_fCustomPal;
- m_fCustomPal = true;
- RGBQUAD tempCusPal[4], newCusPal[4+12] = {{255, 0, 0, 0}, {0, 0, 255, 0}, {0, 0, 0, 0}, {255, 255, 255, 0}};
- memcpy(tempCusPal, m_cuspal, sizeof(tempCusPal));
- memcpy(m_cuspal, newCusPal, sizeof(m_cuspal));
-
- CAutoVectorPtr<BYTE> p4bpp;
- if (!p4bpp.Allocate((m_size.cy-2)*360)) {
- return false;
- }
-
- BYTE colormap[16];
-
- for (size_t i = 0; i < 16; i++) {
- int idx = 0, maxdif = 255*255*3+1;
-
- for (size_t j = 0; j < 16 && maxdif; j++) {
- int rdif = pal[j].rgbRed - m_orgpal[i].rgbRed;
- int gdif = pal[j].rgbGreen - m_orgpal[i].rgbGreen;
- int bdif = pal[j].rgbBlue - m_orgpal[i].rgbBlue;
-
- int dif = rdif*rdif + gdif*gdif + bdif*bdif;
- if (dif < maxdif) {
- maxdif = dif;
- idx = (int)j;
- }
- }
-
- colormap[i] = idx+1;
- }
-
- int pc[4] = {1, 1, 1, 1}, pa[4] = {15, 15, 15, 0};
-
- CAtlArray<SubPos>& sp = m_langs[m_iLang].subpos;
- for (size_t i = 0, k = 0; i < sp.GetCount(); i++) {
- if (!GetFrame((int)i)) {
- continue;
- }
-
- for (int j = 0; j < 5; j++) {
- if (j == 4 || !m_img.pal[j].tr) {
- j &= 3;
- memset(p4bpp, (j<<4)|j, (m_size.cy-2)*360);
- break;
- }
- }
-
- for (ptrdiff_t y = max(m_img.rect.top+1, 2); y < m_img.rect.bottom-1; y++) {
- ASSERT(m_size.cy-y-1 >= 0);
- if (m_size.cy-y-1 < 0) {
- break;
- }
-
- DWORD* p = (DWORD*)&m_img.lpPixels[(y-m_img.rect.top)*m_img.rect.Width()+1];
-
- for (ptrdiff_t x = m_img.rect.left+1; x < m_img.rect.right-1; x++, p++) {
- DWORD rgb = *p&0xffffff;
- BYTE c = rgb == 0x0000ff ? 0 : rgb == 0xff0000 ? 1 : rgb == 0x000000 ? 2 : 3;
- BYTE& c4bpp = p4bpp[(m_size.cy-y-1)*360+(x>>1)];
- c4bpp = (x&1) ? ((c4bpp&0xf0)|c) : ((c4bpp&0x0f)|(c<<4));
- }
- }
-
- CString bmpfn;
- bmpfn.Format(_T("%s_%04d.bmp"), fn, i+1);
- title = bmpfn.Mid(bmpfn.ReverseFind('/')+1);
-
- // E1, E2, P, Bg
- int c[4] = {colormap[m_img.pal[1].pal], colormap[m_img.pal[2].pal], colormap[m_img.pal[0].pal], colormap[m_img.pal[3].pal]};
- c[0]^=c[1], c[1]^=c[0], c[0]^=c[1];
-
- if (memcmp(pc, c, sizeof(c))) {
- memcpy(pc, c, sizeof(c));
- str.Format(_T("Color\t (%d %d %d %d)\n"), c[0], c[1], c[2], c[3]);
- f.WriteString(str);
- }
-
- // E1, E2, P, Bg
- int a[4] = {m_img.pal[1].tr, m_img.pal[2].tr, m_img.pal[0].tr, m_img.pal[3].tr};
- a[0]^=a[1], a[1]^=a[0], a[0]^=a[1];
-
- if (memcmp(pa, a, sizeof(a))) {
- memcpy(pa, a, sizeof(a));
- str.Format(_T("Contrast (%d %d %d %d)\n"), a[0], a[1], a[2], a[3]);
- f.WriteString(str);
- }
-
- int t1 = (int)sp[i].start;
- int h1 = t1/1000/60/60, m1 = (t1/1000/60)%60, s1 = (t1/1000)%60;
- int f1 = (int)((m_size.cy==480?29.97:25)*(t1%1000)/1000);
-
- int t2 = (int)sp[i].stop;
- int h2 = t2/1000/60/60, m2 = (t2/1000/60)%60, s2 = (t2/1000)%60;
- int f2 = (int)((m_size.cy==480?29.97:25)*(t2%1000)/1000);
-
- if (t2 <= 0) {
- continue;
- }
- if (t1 < 0) {
- t1 = 0;
- }
-
- if (h1 == h2 && m1 == m2 && s1 == s2 && f1 == f2) {
- f2++;
- if (f2 == (m_size.cy == 480 ? 30 : 25)) {
- f2 = 0;
- s2++;
- if (s2 == 60) {
- s2 = 0;
- m2++;
- if (m2 == 60) {
- m2 = 0;
- h2++;
- }
- }
- }
- }
-
- if (i+1 < sp.GetCount()) {
- int t3 = (int)sp[i+1].start;
- int h3 = t3/1000/60/60, m3 = (t3/1000/60)%60, s3 = (t3/1000)%60;
- int f3 = (int)((m_size.cy==480?29.97:25)*(t3%1000)/1000);
-
- if (h3 == h2 && m3 == m2 && s3 == s2 && f3 == f2) {
- f2--;
- if (f2 == -1) {
- f2 = (m_size.cy == 480 ? 29 : 24);
- s2--;
- if (s2 == -1) {
- s2 = 59;
- m2--;
- if (m2 == -1) {
- m2 = 59;
- if (h2 > 0) {
- h2--;
- }
- }
- }
- }
- }
- }
-
- if (h1 == h2 && m1 == m2 && s1 == s2 && f1 == f2) {
- continue;
- }
-
- str.Format(_T("%04d\t%02d:%02d:%02d:%02d\t%02d:%02d:%02d:%02d\t%s\n"),
- ++k,
- h1, m1, s1, f1,
- h2, m2, s2, f2,
- title);
- f.WriteString(str);
-
- CFile bmp;
- if (bmp.Open(bmpfn, CFile::modeCreate|CFile::modeWrite|CFile::modeRead|CFile::typeBinary)) {
- bmp.Write(&fhdr, sizeof(fhdr));
- bmp.Write(&ihdr, sizeof(ihdr));
- bmp.Write(newCusPal, sizeof(RGBQUAD)*16);
- bmp.Write(p4bpp, 360*(m_size.cy-2));
- bmp.Close();
-
- CompressFile(bmpfn);
- }
- }
-
- m_fCustomPal = fCustomPal;
- memcpy(m_cuspal, tempCusPal, sizeof(m_cuspal));
-
- return true;
+ TrimExtension(fn);
+
+ CStdioFile f;
+ if (!f.Open(fn + _T(".sst"), CFile::modeCreate | CFile::modeWrite | CFile::typeText | CFile::shareDenyWrite)) {
+ return false;
+ }
+
+ m_img.Invalidate();
+
+ fn.Replace('\\', '/');
+ CString title = fn.Mid(fn.ReverseFind('/') + 1);
+
+ TCHAR buff[_MAX_PATH], * pFilePart = buff;
+ if (GetFullPathName(fn, _MAX_PATH, buff, &pFilePart) == 0) {
+ return false;
+ }
+
+ CString fullpath = CString(buff).Left(int(pFilePart - buff));
+ fullpath.TrimRight(_T("\\/"));
+ if (fullpath.IsEmpty()) {
+ return false;
+ }
+
+ CString str, str2;
+ str += _T("st_format\t2\n");
+ str += _T("Display_Start\t%s\n");
+ str += _T("TV_Type\t\t%s\n");
+ str += _T("Tape_Type\tNON_DROP\n");
+ str += _T("Pixel_Area\t(0 %d)\n");
+ str += _T("Directory\t%s\n");
+ str += _T("Subtitle\t%s\n");
+ str += _T("Display_Area\t(0 2 719 %d)\n");
+ str += _T("Contrast\t(15 15 15 0)\n");
+ str += _T("\n");
+ str += _T("PA\t(0 0 255 - - - )\n");
+ str += _T("E1\t(255 0 0 - - - )\n");
+ str += _T("E2\t(0 0 0 - - - )\n");
+ str += _T("BG\t(255 255 255 - - - )\n");
+ str += _T("\n");
+ str += _T("SP_NUMBER\tSTART\tEND\tFILE_NAME\n");
+ str2.Format(str,
+ !m_fOnlyShowForcedSubs ? _T("non_forced") : _T("forced"),
+ m_size.cy == 480 ? _T("NTSC") : _T("PAL"),
+ m_size.cy - 3,
+ fullpath,
+ title,
+ m_size.cy == 480 ? 479 : 574);
+
+ f.WriteString(str2);
+
+ f.Flush();
+
+ RGBQUAD pal[16] = {
+ {255, 0, 0, 0},
+ {0, 0, 255, 0},
+ {0, 0, 0, 0},
+ {255, 255, 255, 0},
+ {0, 255, 0, 0},
+ {255, 0, 255, 0},
+ {0, 255, 255, 0},
+ {125, 125, 0, 0},
+ {125, 125, 125, 0},
+ {225, 225, 225, 0},
+ {0, 0, 125, 0},
+ {0, 125, 0, 0},
+ {125, 0, 0, 0},
+ {255, 0, 222, 0},
+ {0, 125, 222, 0},
+ {125, 0, 125, 0},
+ };
+
+ BITMAPFILEHEADER fhdr = {
+ 0x4d42,
+ sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + 16 * sizeof(RGBQUAD) + 360 * (m_size.cy - 2),
+ 0, 0,
+ sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + 16 * sizeof(RGBQUAD)
+ };
+
+ BITMAPINFOHEADER ihdr = {
+ sizeof(BITMAPINFOHEADER),
+ 720, m_size.cy - 2, 1, 4, 0,
+ 360 * (m_size.cy - 2),
+ 0, 0,
+ 16, 4
+ };
+
+ bool fCustomPal = m_fCustomPal;
+ m_fCustomPal = true;
+ RGBQUAD tempCusPal[4], newCusPal[4 + 12] = {{255, 0, 0, 0}, {0, 0, 255, 0}, {0, 0, 0, 0}, {255, 255, 255, 0}};
+ memcpy(tempCusPal, m_cuspal, sizeof(tempCusPal));
+ memcpy(m_cuspal, newCusPal, sizeof(m_cuspal));
+
+ CAutoVectorPtr<BYTE> p4bpp;
+ if (!p4bpp.Allocate((m_size.cy - 2) * 360)) {
+ return false;
+ }
+
+ BYTE colormap[16];
+
+ for (size_t i = 0; i < 16; i++) {
+ int idx = 0, maxdif = 255 * 255 * 3 + 1;
+
+ for (size_t j = 0; j < 16 && maxdif; j++) {
+ int rdif = pal[j].rgbRed - m_orgpal[i].rgbRed;
+ int gdif = pal[j].rgbGreen - m_orgpal[i].rgbGreen;
+ int bdif = pal[j].rgbBlue - m_orgpal[i].rgbBlue;
+
+ int dif = rdif * rdif + gdif * gdif + bdif * bdif;
+ if (dif < maxdif) {
+ maxdif = dif;
+ idx = (int)j;
+ }
+ }
+
+ colormap[i] = idx + 1;
+ }
+
+ int pc[4] = {1, 1, 1, 1}, pa[4] = {15, 15, 15, 0};
+
+ CAtlArray<SubPos>& sp = m_langs[m_iLang].subpos;
+ for (size_t i = 0, k = 0; i < sp.GetCount(); i++) {
+ if (!GetFrame((int)i)) {
+ continue;
+ }
+
+ for (int j = 0; j < 5; j++) {
+ if (j == 4 || !m_img.pal[j].tr) {
+ j &= 3;
+ memset(p4bpp, (j << 4) | j, (m_size.cy - 2) * 360);
+ break;
+ }
+ }
+
+ for (ptrdiff_t y = max(m_img.rect.top + 1, 2); y < m_img.rect.bottom - 1; y++) {
+ ASSERT(m_size.cy - y - 1 >= 0);
+ if (m_size.cy - y - 1 < 0) {
+ break;
+ }
+
+ DWORD* p = (DWORD*)&m_img.lpPixels[(y - m_img.rect.top) * m_img.rect.Width() + 1];
+
+ for (ptrdiff_t x = m_img.rect.left + 1; x < m_img.rect.right - 1; x++, p++) {
+ DWORD rgb = *p & 0xffffff;
+ BYTE c = rgb == 0x0000ff ? 0 : rgb == 0xff0000 ? 1 : rgb == 0x000000 ? 2 : 3;
+ BYTE& c4bpp = p4bpp[(m_size.cy - y - 1) * 360 + (x >> 1)];
+ c4bpp = (x & 1) ? ((c4bpp & 0xf0) | c) : ((c4bpp & 0x0f) | (c << 4));
+ }
+ }
+
+ CString bmpfn;
+ bmpfn.Format(_T("%s_%04d.bmp"), fn, i + 1);
+ title = bmpfn.Mid(bmpfn.ReverseFind('/') + 1);
+
+ // E1, E2, P, Bg
+ int c[4] = {colormap[m_img.pal[1].pal], colormap[m_img.pal[2].pal], colormap[m_img.pal[0].pal], colormap[m_img.pal[3].pal]};
+ c[0] ^= c[1], c[1] ^= c[0], c[0] ^= c[1];
+
+ if (memcmp(pc, c, sizeof(c))) {
+ memcpy(pc, c, sizeof(c));
+ str.Format(_T("Color\t (%d %d %d %d)\n"), c[0], c[1], c[2], c[3]);
+ f.WriteString(str);
+ }
+
+ // E1, E2, P, Bg
+ int a[4] = {m_img.pal[1].tr, m_img.pal[2].tr, m_img.pal[0].tr, m_img.pal[3].tr};
+ a[0] ^= a[1], a[1] ^= a[0], a[0] ^= a[1];
+
+ if (memcmp(pa, a, sizeof(a))) {
+ memcpy(pa, a, sizeof(a));
+ str.Format(_T("Contrast (%d %d %d %d)\n"), a[0], a[1], a[2], a[3]);
+ f.WriteString(str);
+ }
+
+ int t1 = (int)sp[i].start;
+ int h1 = t1 / 1000 / 60 / 60, m1 = (t1 / 1000 / 60) % 60, s1 = (t1 / 1000) % 60;
+ int f1 = (int)((m_size.cy == 480 ? 29.97 : 25) * (t1 % 1000) / 1000);
+
+ int t2 = (int)sp[i].stop;
+ int h2 = t2 / 1000 / 60 / 60, m2 = (t2 / 1000 / 60) % 60, s2 = (t2 / 1000) % 60;
+ int f2 = (int)((m_size.cy == 480 ? 29.97 : 25) * (t2 % 1000) / 1000);
+
+ if (t2 <= 0) {
+ continue;
+ }
+ if (t1 < 0) {
+ t1 = 0;
+ }
+
+ if (h1 == h2 && m1 == m2 && s1 == s2 && f1 == f2) {
+ f2++;
+ if (f2 == (m_size.cy == 480 ? 30 : 25)) {
+ f2 = 0;
+ s2++;
+ if (s2 == 60) {
+ s2 = 0;
+ m2++;
+ if (m2 == 60) {
+ m2 = 0;
+ h2++;
+ }
+ }
+ }
+ }
+
+ if (i + 1 < sp.GetCount()) {
+ int t3 = (int)sp[i + 1].start;
+ int h3 = t3 / 1000 / 60 / 60, m3 = (t3 / 1000 / 60) % 60, s3 = (t3 / 1000) % 60;
+ int f3 = (int)((m_size.cy == 480 ? 29.97 : 25) * (t3 % 1000) / 1000);
+
+ if (h3 == h2 && m3 == m2 && s3 == s2 && f3 == f2) {
+ f2--;
+ if (f2 == -1) {
+ f2 = (m_size.cy == 480 ? 29 : 24);
+ s2--;
+ if (s2 == -1) {
+ s2 = 59;
+ m2--;
+ if (m2 == -1) {
+ m2 = 59;
+ if (h2 > 0) {
+ h2--;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (h1 == h2 && m1 == m2 && s1 == s2 && f1 == f2) {
+ continue;
+ }
+
+ str.Format(_T("%04d\t%02d:%02d:%02d:%02d\t%02d:%02d:%02d:%02d\t%s\n"),
+ ++k,
+ h1, m1, s1, f1,
+ h2, m2, s2, f2,
+ title);
+ f.WriteString(str);
+
+ CFile bmp;
+ if (bmp.Open(bmpfn, CFile::modeCreate | CFile::modeWrite | CFile::modeRead | CFile::typeBinary)) {
+ bmp.Write(&fhdr, sizeof(fhdr));
+ bmp.Write(&ihdr, sizeof(ihdr));
+ bmp.Write(newCusPal, sizeof(RGBQUAD) * 16);
+ bmp.Write(p4bpp, 360 * (m_size.cy - 2));
+ bmp.Close();
+
+ CompressFile(bmpfn);
+ }
+ }
+
+ m_fCustomPal = fCustomPal;
+ memcpy(m_cuspal, tempCusPal, sizeof(m_cuspal));
+
+ return true;
}
bool CVobSubFile::SaveMaestro(CString fn)
{
- TrimExtension(fn);
-
- CStdioFile f;
- if (!f.Open(fn + _T(".son"), CFile::modeCreate|CFile::modeWrite|CFile::typeText|CFile::shareDenyWrite)) {
- return false;
- }
-
- m_img.Invalidate();
-
- fn.Replace('\\', '/');
- CString title = fn.Mid(fn.ReverseFind('/')+1);
-
- TCHAR buff[_MAX_PATH], * pFilePart = buff;
- if (GetFullPathName(fn, _MAX_PATH, buff, &pFilePart) == 0) {
- return false;
- }
-
- CString fullpath = CString(buff).Left(int(pFilePart - buff));
- fullpath.TrimRight(_T("\\/"));
- if (fullpath.IsEmpty()) {
- return false;
- }
-
- CString str, str2;
- str += _T("st_format\t2\n");
- str += _T("Display_Start\t%s\n");
- str += _T("TV_Type\t\t%s\n");
- str += _T("Tape_Type\tNON_DROP\n");
- str += _T("Pixel_Area\t(0 %d)\n");
- str += _T("Directory\t%s\n");
- str += _T("Subtitle\t%s\n");
- str += _T("Display_Area\t(0 2 719 %d)\n");
- str += _T("Contrast\t(15 15 15 0)\n");
- str += _T("\n");
- str += _T("SP_NUMBER\tSTART\tEND\tFILE_NAME\n");
- str2.Format(str,
- !m_fOnlyShowForcedSubs ? _T("non_forced") : _T("forced"),
- m_size.cy == 480 ? _T("NTSC") : _T("PAL"),
- m_size.cy-3,
- fullpath,
- title,
- m_size.cy == 480 ? 479 : 574);
-
- f.WriteString(str2);
-
- f.Flush();
-
- BITMAPFILEHEADER fhdr = {
- 0x4d42,
- sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + 16*sizeof(RGBQUAD) + 360*(m_size.cy-2),
- 0, 0,
- sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + 16*sizeof(RGBQUAD)
- };
-
- BITMAPINFOHEADER ihdr = {
- sizeof(BITMAPINFOHEADER),
- 720, m_size.cy-2, 1, 4, 0,
- 360*(m_size.cy-2),
- 0, 0,
- 16, 4
- };
-
- bool fCustomPal = m_fCustomPal;
- m_fCustomPal = true;
- RGBQUAD tempCusPal[4], newCusPal[4+12] = {{255, 0, 0, 0}, {0, 0, 255, 0}, {0, 0, 0, 0}, {255, 255, 255, 0}};
- memcpy(tempCusPal, m_cuspal, sizeof(tempCusPal));
- memcpy(m_cuspal, newCusPal, sizeof(m_cuspal));
-
- CAutoVectorPtr<BYTE> p4bpp;
- if (!p4bpp.Allocate((m_size.cy-2)*360)) {
- return false;
- }
-
- BYTE colormap[16];
- for (BYTE i = 0; i < 16; i++) {
- colormap[i] = i;
- }
-
- CFile spf;
- if (spf.Open(fn + _T(".spf"), CFile::modeCreate|CFile::modeWrite|CFile::typeBinary)) {
- for (size_t i = 0; i < 16; i++) {
- COLORREF c = (m_orgpal[i].rgbBlue<<16) | (m_orgpal[i].rgbGreen<<8) | m_orgpal[i].rgbRed;
- spf.Write(&c, sizeof(COLORREF));
- }
-
- spf.Close();
- }
-
- int pc[4] = {1,1,1,1}, pa[4] = {15,15,15,0};
-
- CAtlArray<SubPos>& sp = m_langs[m_iLang].subpos;
- for (size_t i = 0, k = 0; i < sp.GetCount(); i++) {
- if (!GetFrame((int)i)) {
- continue;
- }
-
- for (int j = 0; j < 5; j++) {
- if (j == 4 || !m_img.pal[j].tr) {
- j &= 3;
- memset(p4bpp, (j<<4)|j, (m_size.cy-2)*360);
- break;
- }
- }
-
- for (ptrdiff_t y = max(m_img.rect.top+1, 2); y < m_img.rect.bottom-1; y++) {
- ASSERT(m_size.cy-y-1 >= 0);
- if (m_size.cy-y-1 < 0) {
- break;
- }
-
- DWORD* p = (DWORD*)&m_img.lpPixels[(y-m_img.rect.top)*m_img.rect.Width()+1];
-
- for (ptrdiff_t x = m_img.rect.left+1; x < m_img.rect.right-1; x++, p++) {
- DWORD rgb = *p&0xffffff;
- BYTE c = rgb == 0x0000ff ? 0 : rgb == 0xff0000 ? 1 : rgb == 0x000000 ? 2 : 3;
- BYTE& c4bpp = p4bpp[(m_size.cy-y-1)*360+(x>>1)];
- c4bpp = (x&1) ? ((c4bpp&0xf0)|c) : ((c4bpp&0x0f)|(c<<4));
- }
- }
-
- CString bmpfn;
- bmpfn.Format(_T("%s_%04d.bmp"), fn, i+1);
- title = bmpfn.Mid(bmpfn.ReverseFind('/')+1);
-
- // E1, E2, P, Bg
- int c[4] = {colormap[m_img.pal[1].pal], colormap[m_img.pal[2].pal], colormap[m_img.pal[0].pal], colormap[m_img.pal[3].pal]};
-
- if (memcmp(pc, c, sizeof(c))) {
- memcpy(pc, c, sizeof(c));
- str.Format(_T("Color\t (%d %d %d %d)\n"), c[0], c[1], c[2], c[3]);
- f.WriteString(str);
- }
-
- // E1, E2, P, Bg
- int a[4] = {m_img.pal[1].tr, m_img.pal[2].tr, m_img.pal[0].tr, m_img.pal[3].tr};
-
- if (memcmp(pa, a, sizeof(a))) {
- memcpy(pa, a, sizeof(a));
- str.Format(_T("Contrast (%d %d %d %d)\n"), a[0], a[1], a[2], a[3]);
- f.WriteString(str);
- }
-
- int t1 = (int)sp[i].start;
- int h1 = t1/1000/60/60, m1 = (t1/1000/60)%60, s1 = (t1/1000)%60;
- int f1 = (int)((m_size.cy==480?29.97:25)*(t1%1000)/1000);
-
- int t2 = (int)sp[i].stop;
- int h2 = t2/1000/60/60, m2 = (t2/1000/60)%60, s2 = (t2/1000)%60;
- int f2 = (int)((m_size.cy==480?29.97:25)*(t2%1000)/1000);
-
- if (t2 <= 0) {
- continue;
- }
- if (t1 < 0) {
- t1 = 0;
- }
-
- if (h1 == h2 && m1 == m2 && s1 == s2 && f1 == f2) {
- f2++;
- if (f2 == (m_size.cy == 480 ? 30 : 25)) {
- f2 = 0;
- s2++;
- if (s2 == 60) {
- s2 = 0;
- m2++;
- if (m2 == 60) {
- m2 = 0;
- h2++;
- }
- }
- }
- }
-
- if (i < sp.GetCount()-1) {
- int t3 = (int)sp[i+1].start;
- int h3 = t3/1000/60/60, m3 = (t3/1000/60)%60, s3 = (t3/1000)%60;
- int f3 = (int)((m_size.cy==480?29.97:25)*(t3%1000)/1000);
-
- if (h3 == h2 && m3 == m2 && s3 == s2 && f3 == f2) {
- f2--;
- if (f2 == -1) {
- f2 = (m_size.cy == 480 ? 29 : 24);
- s2--;
- if (s2 == -1) {
- s2 = 59;
- m2--;
- if (m2 == -1) {
- m2 = 59;
- if (h2 > 0) {
- h2--;
- }
- }
- }
- }
- }
- }
-
- if (h1 == h2 && m1 == m2 && s1 == s2 && f1 == f2) {
- continue;
- }
-
- str.Format(_T("%04d\t%02d:%02d:%02d:%02d\t%02d:%02d:%02d:%02d\t%s\n"),
- ++k,
- h1, m1, s1, f1,
- h2, m2, s2, f2,
- title);
- f.WriteString(str);
-
- CFile bmp;
- if (bmp.Open(bmpfn, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary)) {
- bmp.Write(&fhdr, sizeof(fhdr));
- bmp.Write(&ihdr, sizeof(ihdr));
- bmp.Write(newCusPal, sizeof(RGBQUAD)*16);
- bmp.Write(p4bpp, 360*(m_size.cy-2));
- bmp.Close();
-
- CompressFile(bmpfn);
- }
- }
-
- m_fCustomPal = fCustomPal;
- memcpy(m_cuspal, tempCusPal, sizeof(m_cuspal));
-
- return true;
+ TrimExtension(fn);
+
+ CStdioFile f;
+ if (!f.Open(fn + _T(".son"), CFile::modeCreate | CFile::modeWrite | CFile::typeText | CFile::shareDenyWrite)) {
+ return false;
+ }
+
+ m_img.Invalidate();
+
+ fn.Replace('\\', '/');
+ CString title = fn.Mid(fn.ReverseFind('/') + 1);
+
+ TCHAR buff[_MAX_PATH], * pFilePart = buff;
+ if (GetFullPathName(fn, _MAX_PATH, buff, &pFilePart) == 0) {
+ return false;
+ }
+
+ CString fullpath = CString(buff).Left(int(pFilePart - buff));
+ fullpath.TrimRight(_T("\\/"));
+ if (fullpath.IsEmpty()) {
+ return false;
+ }
+
+ CString str, str2;
+ str += _T("st_format\t2\n");
+ str += _T("Display_Start\t%s\n");
+ str += _T("TV_Type\t\t%s\n");
+ str += _T("Tape_Type\tNON_DROP\n");
+ str += _T("Pixel_Area\t(0 %d)\n");
+ str += _T("Directory\t%s\n");
+ str += _T("Subtitle\t%s\n");
+ str += _T("Display_Area\t(0 2 719 %d)\n");
+ str += _T("Contrast\t(15 15 15 0)\n");
+ str += _T("\n");
+ str += _T("SP_NUMBER\tSTART\tEND\tFILE_NAME\n");
+ str2.Format(str,
+ !m_fOnlyShowForcedSubs ? _T("non_forced") : _T("forced"),
+ m_size.cy == 480 ? _T("NTSC") : _T("PAL"),
+ m_size.cy - 3,
+ fullpath,
+ title,
+ m_size.cy == 480 ? 479 : 574);
+
+ f.WriteString(str2);
+
+ f.Flush();
+
+ BITMAPFILEHEADER fhdr = {
+ 0x4d42,
+ sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + 16 * sizeof(RGBQUAD) + 360 * (m_size.cy - 2),
+ 0, 0,
+ sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + 16 * sizeof(RGBQUAD)
+ };
+
+ BITMAPINFOHEADER ihdr = {
+ sizeof(BITMAPINFOHEADER),
+ 720, m_size.cy - 2, 1, 4, 0,
+ 360 * (m_size.cy - 2),
+ 0, 0,
+ 16, 4
+ };
+
+ bool fCustomPal = m_fCustomPal;
+ m_fCustomPal = true;
+ RGBQUAD tempCusPal[4], newCusPal[4 + 12] = {{255, 0, 0, 0}, {0, 0, 255, 0}, {0, 0, 0, 0}, {255, 255, 255, 0}};
+ memcpy(tempCusPal, m_cuspal, sizeof(tempCusPal));
+ memcpy(m_cuspal, newCusPal, sizeof(m_cuspal));
+
+ CAutoVectorPtr<BYTE> p4bpp;
+ if (!p4bpp.Allocate((m_size.cy - 2) * 360)) {
+ return false;
+ }
+
+ BYTE colormap[16];
+ for (BYTE i = 0; i < 16; i++) {
+ colormap[i] = i;
+ }
+
+ CFile spf;
+ if (spf.Open(fn + _T(".spf"), CFile::modeCreate | CFile::modeWrite | CFile::typeBinary)) {
+ for (size_t i = 0; i < 16; i++) {
+ COLORREF c = (m_orgpal[i].rgbBlue << 16) | (m_orgpal[i].rgbGreen << 8) | m_orgpal[i].rgbRed;
+ spf.Write(&c, sizeof(COLORREF));
+ }
+
+ spf.Close();
+ }
+
+ int pc[4] = {1, 1, 1, 1}, pa[4] = {15, 15, 15, 0};
+
+ CAtlArray<SubPos>& sp = m_langs[m_iLang].subpos;
+ for (size_t i = 0, k = 0; i < sp.GetCount(); i++) {
+ if (!GetFrame((int)i)) {
+ continue;
+ }
+
+ for (int j = 0; j < 5; j++) {
+ if (j == 4 || !m_img.pal[j].tr) {
+ j &= 3;
+ memset(p4bpp, (j << 4) | j, (m_size.cy - 2) * 360);
+ break;
+ }
+ }
+
+ for (ptrdiff_t y = max(m_img.rect.top + 1, 2); y < m_img.rect.bottom - 1; y++) {
+ ASSERT(m_size.cy - y - 1 >= 0);
+ if (m_size.cy - y - 1 < 0) {
+ break;
+ }
+
+ DWORD* p = (DWORD*)&m_img.lpPixels[(y - m_img.rect.top) * m_img.rect.Width() + 1];
+
+ for (ptrdiff_t x = m_img.rect.left + 1; x < m_img.rect.right - 1; x++, p++) {
+ DWORD rgb = *p & 0xffffff;
+ BYTE c = rgb == 0x0000ff ? 0 : rgb == 0xff0000 ? 1 : rgb == 0x000000 ? 2 : 3;
+ BYTE& c4bpp = p4bpp[(m_size.cy - y - 1) * 360 + (x >> 1)];
+ c4bpp = (x & 1) ? ((c4bpp & 0xf0) | c) : ((c4bpp & 0x0f) | (c << 4));
+ }
+ }
+
+ CString bmpfn;
+ bmpfn.Format(_T("%s_%04d.bmp"), fn, i + 1);
+ title = bmpfn.Mid(bmpfn.ReverseFind('/') + 1);
+
+ // E1, E2, P, Bg
+ int c[4] = {colormap[m_img.pal[1].pal], colormap[m_img.pal[2].pal], colormap[m_img.pal[0].pal], colormap[m_img.pal[3].pal]};
+
+ if (memcmp(pc, c, sizeof(c))) {
+ memcpy(pc, c, sizeof(c));
+ str.Format(_T("Color\t (%d %d %d %d)\n"), c[0], c[1], c[2], c[3]);
+ f.WriteString(str);
+ }
+
+ // E1, E2, P, Bg
+ int a[4] = {m_img.pal[1].tr, m_img.pal[2].tr, m_img.pal[0].tr, m_img.pal[3].tr};
+
+ if (memcmp(pa, a, sizeof(a))) {
+ memcpy(pa, a, sizeof(a));
+ str.Format(_T("Contrast (%d %d %d %d)\n"), a[0], a[1], a[2], a[3]);
+ f.WriteString(str);
+ }
+
+ int t1 = (int)sp[i].start;
+ int h1 = t1 / 1000 / 60 / 60, m1 = (t1 / 1000 / 60) % 60, s1 = (t1 / 1000) % 60;
+ int f1 = (int)((m_size.cy == 480 ? 29.97 : 25) * (t1 % 1000) / 1000);
+
+ int t2 = (int)sp[i].stop;
+ int h2 = t2 / 1000 / 60 / 60, m2 = (t2 / 1000 / 60) % 60, s2 = (t2 / 1000) % 60;
+ int f2 = (int)((m_size.cy == 480 ? 29.97 : 25) * (t2 % 1000) / 1000);
+
+ if (t2 <= 0) {
+ continue;
+ }
+ if (t1 < 0) {
+ t1 = 0;
+ }
+
+ if (h1 == h2 && m1 == m2 && s1 == s2 && f1 == f2) {
+ f2++;
+ if (f2 == (m_size.cy == 480 ? 30 : 25)) {
+ f2 = 0;
+ s2++;
+ if (s2 == 60) {
+ s2 = 0;
+ m2++;
+ if (m2 == 60) {
+ m2 = 0;
+ h2++;
+ }
+ }
+ }
+ }
+
+ if (i < sp.GetCount() - 1) {
+ int t3 = (int)sp[i + 1].start;
+ int h3 = t3 / 1000 / 60 / 60, m3 = (t3 / 1000 / 60) % 60, s3 = (t3 / 1000) % 60;
+ int f3 = (int)((m_size.cy == 480 ? 29.97 : 25) * (t3 % 1000) / 1000);
+
+ if (h3 == h2 && m3 == m2 && s3 == s2 && f3 == f2) {
+ f2--;
+ if (f2 == -1) {
+ f2 = (m_size.cy == 480 ? 29 : 24);
+ s2--;
+ if (s2 == -1) {
+ s2 = 59;
+ m2--;
+ if (m2 == -1) {
+ m2 = 59;
+ if (h2 > 0) {
+ h2--;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (h1 == h2 && m1 == m2 && s1 == s2 && f1 == f2) {
+ continue;
+ }
+
+ str.Format(_T("%04d\t%02d:%02d:%02d:%02d\t%02d:%02d:%02d:%02d\t%s\n"),
+ ++k,
+ h1, m1, s1, f1,
+ h2, m2, s2, f2,
+ title);
+ f.WriteString(str);
+
+ CFile bmp;
+ if (bmp.Open(bmpfn, CFile::modeCreate | CFile::modeWrite | CFile::typeBinary)) {
+ bmp.Write(&fhdr, sizeof(fhdr));
+ bmp.Write(&ihdr, sizeof(ihdr));
+ bmp.Write(newCusPal, sizeof(RGBQUAD) * 16);
+ bmp.Write(p4bpp, 360 * (m_size.cy - 2));
+ bmp.Close();
+
+ CompressFile(bmpfn);
+ }
+ }
+
+ m_fCustomPal = fCustomPal;
+ memcpy(m_cuspal, tempCusPal, sizeof(m_cuspal));
+
+ return true;
}
//
@@ -2284,7 +2284,7 @@ bool CVobSubFile::SaveMaestro(CString fn)
//
CVobSubStream::CVobSubStream(CCritSec* pLock)
- : CSubPicProviderImpl(pLock)
+ : CSubPicProviderImpl(pLock)
{
}
@@ -2294,230 +2294,230 @@ CVobSubStream::~CVobSubStream()
void CVobSubStream::Open(CString name, BYTE* pData, int len)
{
- CAutoLock cAutoLock(&m_csSubPics);
-
- m_name = name;
-
- CAtlList<CString> lines;
- Explode(CString(CStringA((CHAR*)pData, len)), lines, '\n');
- while (lines.GetCount()) {
- CAtlList<CString> sl;
- Explode(lines.RemoveHead(), sl, ':', 2);
- if (sl.GetCount() != 2) {
- continue;
- }
- CString key = sl.GetHead();
- CString value = sl.GetTail();
- if (key == _T("size")) {
- _stscanf_s(value, _T("%dx %d"), &m_size.cx, &m_size.cy);
- } else if (key == _T("org")) {
- _stscanf_s(value, _T("%d, %d"), &m_org.x, &m_org.y);
- } else if (key == _T("scale")) {
- _stscanf_s(value, _T("%d%%, %d%%"), &m_scale_x, &m_scale_y);
- } else if (key == _T("alpha")) {
- _stscanf_s(value, _T("%d%%"), &m_alpha);
- } else if (key == _T("smooth"))
- m_fSmooth =
- value == _T("0") || value == _T("OFF") ? 0 :
- value == _T("1") || value == _T("ON") ? 1 :
- value == _T("2") || value == _T("OLD") ? 2 :
- 0;
- else if (key == _T("align")) {
- Explode(value, sl, ' ');
- if (sl.GetCount() == 4) {
- sl.RemoveAt(sl.FindIndex(1));
- }
- if (sl.GetCount() == 3) {
- m_fAlign = sl.RemoveHead() == _T("ON");
- CString hor = sl.GetHead(), ver = sl.GetTail();
- m_alignhor = hor == _T("LEFT") ? 0 : hor == _T("CENTER") ? 1 : hor == _T("RIGHT") ? 2 : 1;
- m_alignver = ver == _T("TOP") ? 0 : ver == _T("CENTER") ? 1 : ver == _T("BOTTOM") ? 2 : 2;
- }
- } else if (key == _T("fade in/out")) {
- _stscanf_s(value, _T("%d%, %d%"), &m_fadein, &m_fadeout);
- } else if (key == _T("time offset")) {
- m_toff = _tcstol(value, NULL, 10);
- } else if (key == _T("forced subs")) {
- m_fOnlyShowForcedSubs = value == _T("1") || value == _T("ON");
- } else if (key == _T("palette")) {
- Explode(value, sl, ',', 16);
- for (size_t i = 0; i < 16 && sl.GetCount(); i++) {
- *(DWORD*)&m_orgpal[i] = _tcstol(sl.RemoveHead(), NULL, 16);
- }
- } else if (key == _T("custom colors")) {
- m_fCustomPal = Explode(value, sl, ',', 3) == _T("ON");
- if (sl.GetCount() == 3) {
- sl.RemoveHead();
- CAtlList<CString> tridx, colors;
- Explode(sl.RemoveHead(), tridx, ':', 2);
- if (tridx.RemoveHead() == _T("tridx")) {
- TCHAR tr[4];
- _stscanf_s(tridx.RemoveHead(), _T("%c%c%c%c"), &tr[0], sizeof(TCHAR),
- &tr[1], sizeof(TCHAR), &tr[2], sizeof(TCHAR), &tr[3], sizeof(TCHAR));
- for (size_t i = 0; i < 4; i++) {
- m_tridx |= ((tr[i]=='1')?1:0)<<i;
- }
- }
- Explode(sl.RemoveHead(), colors, ':', 2);
- if (colors.RemoveHead() == _T("colors")) {
- Explode(colors.RemoveHead(), colors, ',', 4);
- for (size_t i = 0; i < 4 && colors.GetCount(); i++) {
- *(DWORD*)&m_cuspal[i] = _tcstol(colors.RemoveHead(), NULL, 16);
- }
- }
- }
- }
- }
+ CAutoLock cAutoLock(&m_csSubPics);
+
+ m_name = name;
+
+ CAtlList<CString> lines;
+ Explode(CString(CStringA((CHAR*)pData, len)), lines, '\n');
+ while (lines.GetCount()) {
+ CAtlList<CString> sl;
+ Explode(lines.RemoveHead(), sl, ':', 2);
+ if (sl.GetCount() != 2) {
+ continue;
+ }
+ CString key = sl.GetHead();
+ CString value = sl.GetTail();
+ if (key == _T("size")) {
+ _stscanf_s(value, _T("%dx %d"), &m_size.cx, &m_size.cy);
+ } else if (key == _T("org")) {
+ _stscanf_s(value, _T("%d, %d"), &m_org.x, &m_org.y);
+ } else if (key == _T("scale")) {
+ _stscanf_s(value, _T("%d%%, %d%%"), &m_scale_x, &m_scale_y);
+ } else if (key == _T("alpha")) {
+ _stscanf_s(value, _T("%d%%"), &m_alpha);
+ } else if (key == _T("smooth"))
+ m_fSmooth =
+ value == _T("0") || value == _T("OFF") ? 0 :
+ value == _T("1") || value == _T("ON") ? 1 :
+ value == _T("2") || value == _T("OLD") ? 2 :
+ 0;
+ else if (key == _T("align")) {
+ Explode(value, sl, ' ');
+ if (sl.GetCount() == 4) {
+ sl.RemoveAt(sl.FindIndex(1));
+ }
+ if (sl.GetCount() == 3) {
+ m_fAlign = sl.RemoveHead() == _T("ON");
+ CString hor = sl.GetHead(), ver = sl.GetTail();
+ m_alignhor = hor == _T("LEFT") ? 0 : hor == _T("CENTER") ? 1 : hor == _T("RIGHT") ? 2 : 1;
+ m_alignver = ver == _T("TOP") ? 0 : ver == _T("CENTER") ? 1 : ver == _T("BOTTOM") ? 2 : 2;
+ }
+ } else if (key == _T("fade in/out")) {
+ _stscanf_s(value, _T("%d%, %d%"), &m_fadein, &m_fadeout);
+ } else if (key == _T("time offset")) {
+ m_toff = _tcstol(value, NULL, 10);
+ } else if (key == _T("forced subs")) {
+ m_fOnlyShowForcedSubs = value == _T("1") || value == _T("ON");
+ } else if (key == _T("palette")) {
+ Explode(value, sl, ',', 16);
+ for (size_t i = 0; i < 16 && sl.GetCount(); i++) {
+ *(DWORD*)&m_orgpal[i] = _tcstol(sl.RemoveHead(), NULL, 16);
+ }
+ } else if (key == _T("custom colors")) {
+ m_fCustomPal = Explode(value, sl, ',', 3) == _T("ON");
+ if (sl.GetCount() == 3) {
+ sl.RemoveHead();
+ CAtlList<CString> tridx, colors;
+ Explode(sl.RemoveHead(), tridx, ':', 2);
+ if (tridx.RemoveHead() == _T("tridx")) {
+ TCHAR tr[4];
+ _stscanf_s(tridx.RemoveHead(), _T("%c%c%c%c"), &tr[0], sizeof(TCHAR),
+ &tr[1], sizeof(TCHAR), &tr[2], sizeof(TCHAR), &tr[3], sizeof(TCHAR));
+ for (size_t i = 0; i < 4; i++) {
+ m_tridx |= ((tr[i] == '1') ? 1 : 0) << i;
+ }
+ }
+ Explode(sl.RemoveHead(), colors, ':', 2);
+ if (colors.RemoveHead() == _T("colors")) {
+ Explode(colors.RemoveHead(), colors, ',', 4);
+ for (size_t i = 0; i < 4 && colors.GetCount(); i++) {
+ *(DWORD*)&m_cuspal[i] = _tcstol(colors.RemoveHead(), NULL, 16);
+ }
+ }
+ }
+ }
+ }
}
void CVobSubStream::Add(REFERENCE_TIME tStart, REFERENCE_TIME tStop, BYTE* pData, int len)
{
- if (len <= 4 || ((pData[0]<<8)|pData[1]) != len) {
- return;
- }
+ if (len <= 4 || ((pData[0] << 8) | pData[1]) != len) {
+ return;
+ }
- CVobSubImage vsi;
- vsi.GetPacketInfo(pData, (pData[0]<<8)|pData[1], (pData[2]<<8)|pData[3]);
+ CVobSubImage vsi;
+ vsi.GetPacketInfo(pData, (pData[0] << 8) | pData[1], (pData[2] << 8) | pData[3]);
- CAutoPtr<SubPic> p(DNew SubPic());
- p->tStart = tStart;
- p->tStop = vsi.delay > 0 ? (tStart + 10000i64*vsi.delay) : tStop;
- p->pData.SetCount(len);
- memcpy(p->pData.GetData(), pData, p->pData.GetCount());
+ CAutoPtr<SubPic> p(DNew SubPic());
+ p->tStart = tStart;
+ p->tStop = vsi.delay > 0 ? (tStart + 10000i64 * vsi.delay) : tStop;
+ p->pData.SetCount(len);
+ memcpy(p->pData.GetData(), pData, p->pData.GetCount());
- CAutoLock cAutoLock(&m_csSubPics);
- while (m_subpics.GetCount() && m_subpics.GetTail()->tStart >= tStart) {
- m_subpics.RemoveTail();
- m_img.iIdx = -1;
- }
- m_subpics.AddTail(p);
+ CAutoLock cAutoLock(&m_csSubPics);
+ while (m_subpics.GetCount() && m_subpics.GetTail()->tStart >= tStart) {
+ m_subpics.RemoveTail();
+ m_img.iIdx = -1;
+ }
+ m_subpics.AddTail(p);
}
void CVobSubStream::RemoveAll()
{
- CAutoLock cAutoLock(&m_csSubPics);
- m_subpics.RemoveAll();
- m_img.iIdx = -1;
+ CAutoLock cAutoLock(&m_csSubPics);
+ m_subpics.RemoveAll();
+ m_img.iIdx = -1;
}
STDMETHODIMP CVobSubStream::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
- *ppv = NULL;
+ CheckPointer(ppv, E_POINTER);
+ *ppv = NULL;
- return
- QI(IPersist)
- QI(ISubStream)
- QI(ISubPicProvider)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IPersist)
+ QI(ISubStream)
+ QI(ISubPicProvider)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// ISubPicProvider
STDMETHODIMP_(POSITION) CVobSubStream::GetStartPosition(REFERENCE_TIME rt, double fps)
{
- CAutoLock cAutoLock(&m_csSubPics);
- POSITION pos = m_subpics.GetTailPosition();
- for (; pos; m_subpics.GetPrev(pos)) {
- SubPic* sp = m_subpics.GetAt(pos);
- if (sp->tStart <= rt) {
- if (sp->tStop <= rt) {
- m_subpics.GetNext(pos);
- }
- break;
- }
- }
- return pos;
+ CAutoLock cAutoLock(&m_csSubPics);
+ POSITION pos = m_subpics.GetTailPosition();
+ for (; pos; m_subpics.GetPrev(pos)) {
+ SubPic* sp = m_subpics.GetAt(pos);
+ if (sp->tStart <= rt) {
+ if (sp->tStop <= rt) {
+ m_subpics.GetNext(pos);
+ }
+ break;
+ }
+ }
+ return pos;
}
STDMETHODIMP_(POSITION) CVobSubStream::GetNext(POSITION pos)
{
- CAutoLock cAutoLock(&m_csSubPics);
- m_subpics.GetNext(pos);
- return pos;
+ CAutoLock cAutoLock(&m_csSubPics);
+ m_subpics.GetNext(pos);
+ return pos;
}
STDMETHODIMP_(REFERENCE_TIME) CVobSubStream::GetStart(POSITION pos, double fps)
{
- CAutoLock cAutoLock(&m_csSubPics);
- return m_subpics.GetAt(pos)->tStart;
+ CAutoLock cAutoLock(&m_csSubPics);
+ return m_subpics.GetAt(pos)->tStart;
}
STDMETHODIMP_(REFERENCE_TIME) CVobSubStream::GetStop(POSITION pos, double fps)
{
- CAutoLock cAutoLock(&m_csSubPics);
- return m_subpics.GetAt(pos)->tStop;
+ CAutoLock cAutoLock(&m_csSubPics);
+ return m_subpics.GetAt(pos)->tStop;
}
STDMETHODIMP_(bool) CVobSubStream::IsAnimated(POSITION pos)
{
- return false;
+ return false;
}
STDMETHODIMP CVobSubStream::Render(SubPicDesc& spd, REFERENCE_TIME rt, double fps, RECT& bbox)
{
- if (spd.bpp != 32) {
- return E_INVALIDARG;
- }
+ if (spd.bpp != 32) {
+ return E_INVALIDARG;
+ }
- POSITION pos = m_subpics.GetTailPosition();
- for (; pos; m_subpics.GetPrev(pos)) {
- SubPic* sp = m_subpics.GetAt(pos);
- if (sp->tStart <= rt && rt < sp->tStop) {
- if (m_img.iIdx != (int)pos) {
- BYTE* pData = sp->pData.GetData();
- m_img.Decode(
- pData, (pData[0]<<8)|pData[1], (pData[2]<<8)|pData[3],
- m_fCustomPal, m_tridx, m_orgpal, m_cuspal, true);
- m_img.iIdx = (int)pos;
- }
+ POSITION pos = m_subpics.GetTailPosition();
+ for (; pos; m_subpics.GetPrev(pos)) {
+ SubPic* sp = m_subpics.GetAt(pos);
+ if (sp->tStart <= rt && rt < sp->tStop) {
+ if (m_img.iIdx != (int)pos) {
+ BYTE* pData = sp->pData.GetData();
+ m_img.Decode(
+ pData, (pData[0] << 8) | pData[1], (pData[2] << 8) | pData[3],
+ m_fCustomPal, m_tridx, m_orgpal, m_cuspal, true);
+ m_img.iIdx = (int)pos;
+ }
- return __super::Render(spd, bbox);
- }
- }
+ return __super::Render(spd, bbox);
+ }
+ }
- return E_FAIL;
+ return E_FAIL;
}
// IPersist
STDMETHODIMP CVobSubStream::GetClassID(CLSID* pClassID)
{
- return pClassID ? *pClassID = __uuidof(this), S_OK : E_POINTER;
+ return pClassID ? *pClassID = __uuidof(this), S_OK : E_POINTER;
}
// ISubStream
STDMETHODIMP_(int) CVobSubStream::GetStreamCount()
{
- return 1;
+ return 1;
}
STDMETHODIMP CVobSubStream::GetStreamInfo(int i, WCHAR** ppName, LCID* pLCID)
{
- CAutoLock cAutoLock(&m_csSubPics);
+ CAutoLock cAutoLock(&m_csSubPics);
- if (ppName) {
- *ppName = (WCHAR*)CoTaskMemAlloc((m_name.GetLength() + 1) * sizeof(WCHAR));
- if (!(*ppName)) {
- return E_OUTOFMEMORY;
- }
- wcscpy_s(*ppName, m_name.GetLength() + 1, CStringW(m_name));
- }
+ if (ppName) {
+ *ppName = (WCHAR*)CoTaskMemAlloc((m_name.GetLength() + 1) * sizeof(WCHAR));
+ if (!(*ppName)) {
+ return E_OUTOFMEMORY;
+ }
+ wcscpy_s(*ppName, m_name.GetLength() + 1, CStringW(m_name));
+ }
- if (pLCID) {
- *pLCID = 0; // TODO
- }
+ if (pLCID) {
+ *pLCID = 0; // TODO
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP_(int) CVobSubStream::GetStream()
{
- return 0;
+ return 0;
}
STDMETHODIMP CVobSubStream::SetStream(int iStream)
{
- return iStream == 0 ? S_OK : E_FAIL;
+ return iStream == 0 ? S_OK : E_FAIL;
}
diff --git a/src/Subtitles/VobSubFile.h b/src/Subtitles/VobSubFile.h
index 1d8482e5f..cead77d21 100644
--- a/src/Subtitles/VobSubFile.h
+++ b/src/Subtitles/VobSubFile.h
@@ -34,154 +34,154 @@ extern CString FindLangFromId(WORD id);
class CVobSubSettings
{
protected:
- HRESULT Render(SubPicDesc& spd, RECT& bbox);
+ HRESULT Render(SubPicDesc& spd, RECT& bbox);
public:
- CSize m_size;
- int m_x, m_y;
- CPoint m_org;
- int m_scale_x, m_scale_y; // % (don't set it to unsigned because as a side effect it will mess up negative coordinates in GetDestrect())
- int m_alpha; // %
- int m_fSmooth; // 0: OFF, 1: ON, 2: OLD (means no filtering at all)
- int m_fadein, m_fadeout; // ms
- bool m_fAlign;
- int m_alignhor, m_alignver; // 0: left/top, 1: center, 2: right/bottom
- unsigned int m_toff; // ms
- bool m_fOnlyShowForcedSubs;
- bool m_fCustomPal;
- int m_tridx;
- RGBQUAD m_orgpal[16], m_cuspal[4];
-
- CVobSubImage m_img;
-
- CVobSubSettings() {InitSettings();}
- void InitSettings();
-
- bool GetCustomPal(RGBQUAD* cuspal, int& tridx);
- void SetCustomPal(RGBQUAD* cuspal, int tridx);
-
- void GetDestrect(CRect& r); // destrect of m_img, considering the current alignment mode
- void GetDestrect(CRect& r, int w, int h); // this will scale it to the frame size of (w, h)
-
- void SetAlignment(bool fAlign, int x, int y, int hor, int ver);
+ CSize m_size;
+ int m_x, m_y;
+ CPoint m_org;
+ int m_scale_x, m_scale_y; // % (don't set it to unsigned because as a side effect it will mess up negative coordinates in GetDestrect())
+ int m_alpha; // %
+ int m_fSmooth; // 0: OFF, 1: ON, 2: OLD (means no filtering at all)
+ int m_fadein, m_fadeout; // ms
+ bool m_fAlign;
+ int m_alignhor, m_alignver; // 0: left/top, 1: center, 2: right/bottom
+ unsigned int m_toff; // ms
+ bool m_fOnlyShowForcedSubs;
+ bool m_fCustomPal;
+ int m_tridx;
+ RGBQUAD m_orgpal[16], m_cuspal[4];
+
+ CVobSubImage m_img;
+
+ CVobSubSettings() {InitSettings();}
+ void InitSettings();
+
+ bool GetCustomPal(RGBQUAD* cuspal, int& tridx);
+ void SetCustomPal(RGBQUAD* cuspal, int tridx);
+
+ void GetDestrect(CRect& r); // destrect of m_img, considering the current alignment mode
+ void GetDestrect(CRect& r, int w, int h); // this will scale it to the frame size of (w, h)
+
+ void SetAlignment(bool fAlign, int x, int y, int hor, int ver);
};
class __declspec(uuid("998D4C9A-460F-4de6-BDCD-35AB24F94ADF"))
- CVobSubFile : public CVobSubSettings, public ISubStream, public CSubPicProviderImpl
+ CVobSubFile : public CVobSubSettings, public ISubStream, public CSubPicProviderImpl
{
protected:
- CString m_title;
+ CString m_title;
- void TrimExtension(CString& fn);
- bool ReadIdx(CString fn, int& ver), ReadSub(CString fn), ReadRar(CString fn), ReadIfo(CString fn);
- bool WriteIdx(CString fn), WriteSub(CString fn);
+ void TrimExtension(CString& fn);
+ bool ReadIdx(CString fn, int& ver), ReadSub(CString fn), ReadRar(CString fn), ReadIfo(CString fn);
+ bool WriteIdx(CString fn), WriteSub(CString fn);
- CMemFile m_sub;
+ CMemFile m_sub;
- BYTE* GetPacket(int idx, int& packetsize, int& datasize, int iLang = -1);
- bool GetFrame(int idx, int iLang = -1);
- bool GetFrameByTimeStamp(__int64 time);
- int GetFrameIdxByTimeStamp(__int64 time);
+ BYTE* GetPacket(int idx, int& packetsize, int& datasize, int iLang = -1);
+ bool GetFrame(int idx, int iLang = -1);
+ bool GetFrameByTimeStamp(__int64 time);
+ int GetFrameIdxByTimeStamp(__int64 time);
- bool SaveVobSub(CString fn);
- bool SaveWinSubMux(CString fn);
- bool SaveScenarist(CString fn);
- bool SaveMaestro(CString fn);
+ bool SaveVobSub(CString fn);
+ bool SaveWinSubMux(CString fn);
+ bool SaveScenarist(CString fn);
+ bool SaveMaestro(CString fn);
public:
- typedef struct {
- __int64 filepos;
- __int64 start, stop;
- bool fForced;
- char vobid, cellid;
- __int64 celltimestamp;
- bool fValid;
- } SubPos;
-
- typedef struct {
- int id;
- CString name, alt;
- CAtlArray<SubPos> subpos;
- } SubLang;
-
- int m_iLang;
- SubLang m_langs[32];
+ typedef struct {
+ __int64 filepos;
+ __int64 start, stop;
+ bool fForced;
+ char vobid, cellid;
+ __int64 celltimestamp;
+ bool fValid;
+ } SubPos;
+
+ typedef struct {
+ int id;
+ CString name, alt;
+ CAtlArray<SubPos> subpos;
+ } SubLang;
+
+ int m_iLang;
+ SubLang m_langs[32];
public:
- CVobSubFile(CCritSec* pLock);
- virtual ~CVobSubFile();
+ CVobSubFile(CCritSec* pLock);
+ virtual ~CVobSubFile();
- bool Copy(CVobSubFile& vsf);
+ bool Copy(CVobSubFile& vsf);
- typedef enum {None,VobSub,WinSubMux,Scenarist,Maestro} SubFormat;
+ typedef enum {None, VobSub, WinSubMux, Scenarist, Maestro} SubFormat;
- bool Open(CString fn);
- bool Save(CString fn, SubFormat sf = VobSub);
- void Close();
+ bool Open(CString fn);
+ bool Save(CString fn, SubFormat sf = VobSub);
+ void Close();
- CString GetTitle() {return m_title;}
+ CString GetTitle() {return m_title;}
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // ISubPicProvider
- STDMETHODIMP_(POSITION) GetStartPosition(REFERENCE_TIME rt, double fps);
- STDMETHODIMP_(POSITION) GetNext(POSITION pos);
- STDMETHODIMP_(REFERENCE_TIME) GetStart(POSITION pos, double fps);
- STDMETHODIMP_(REFERENCE_TIME) GetStop(POSITION pos, double fps);
- STDMETHODIMP_(bool) IsAnimated(POSITION pos);
- STDMETHODIMP Render(SubPicDesc& spd, REFERENCE_TIME rt, double fps, RECT& bbox);
+ // ISubPicProvider
+ STDMETHODIMP_(POSITION) GetStartPosition(REFERENCE_TIME rt, double fps);
+ STDMETHODIMP_(POSITION) GetNext(POSITION pos);
+ STDMETHODIMP_(REFERENCE_TIME) GetStart(POSITION pos, double fps);
+ STDMETHODIMP_(REFERENCE_TIME) GetStop(POSITION pos, double fps);
+ STDMETHODIMP_(bool) IsAnimated(POSITION pos);
+ STDMETHODIMP Render(SubPicDesc& spd, REFERENCE_TIME rt, double fps, RECT& bbox);
- // IPersist
- STDMETHODIMP GetClassID(CLSID* pClassID);
+ // IPersist
+ STDMETHODIMP GetClassID(CLSID* pClassID);
- // ISubStream
- STDMETHODIMP_(int) GetStreamCount();
- STDMETHODIMP GetStreamInfo(int i, WCHAR** ppName, LCID* pLCID);
- STDMETHODIMP_(int) GetStream();
- STDMETHODIMP SetStream(int iStream);
- STDMETHODIMP Reload();
+ // ISubStream
+ STDMETHODIMP_(int) GetStreamCount();
+ STDMETHODIMP GetStreamInfo(int i, WCHAR** ppName, LCID* pLCID);
+ STDMETHODIMP_(int) GetStream();
+ STDMETHODIMP SetStream(int iStream);
+ STDMETHODIMP Reload();
};
class __declspec(uuid("D7FBFB45-2D13-494F-9B3D-FFC9557D5C45"))
- CVobSubStream : public CVobSubSettings, public ISubStream, public CSubPicProviderImpl
+ CVobSubStream : public CVobSubSettings, public ISubStream, public CSubPicProviderImpl
{
- CString m_name;
+ CString m_name;
- CCritSec m_csSubPics;
- struct SubPic {
- REFERENCE_TIME tStart, tStop;
- CAtlArray<BYTE> pData;
- };
- CAutoPtrList<SubPic> m_subpics;
+ CCritSec m_csSubPics;
+ struct SubPic {
+ REFERENCE_TIME tStart, tStop;
+ CAtlArray<BYTE> pData;
+ };
+ CAutoPtrList<SubPic> m_subpics;
public:
- CVobSubStream(CCritSec* pLock);
- virtual ~CVobSubStream();
-
- void Open(CString name, BYTE* pData, int len);
-
- void Add(REFERENCE_TIME tStart, REFERENCE_TIME tStop, BYTE* pData, int len);
- void RemoveAll();
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // ISubPicProvider
- STDMETHODIMP_(POSITION) GetStartPosition(REFERENCE_TIME rt, double fps);
- STDMETHODIMP_(POSITION) GetNext(POSITION pos);
- STDMETHODIMP_(REFERENCE_TIME) GetStart(POSITION pos, double fps);
- STDMETHODIMP_(REFERENCE_TIME) GetStop(POSITION pos, double fps);
- STDMETHODIMP_(bool) IsAnimated(POSITION pos);
- STDMETHODIMP Render(SubPicDesc& spd, REFERENCE_TIME rt, double fps, RECT& bbox);
-
- // IPersist
- STDMETHODIMP GetClassID(CLSID* pClassID);
-
- // ISubStream
- STDMETHODIMP_(int) GetStreamCount();
- STDMETHODIMP GetStreamInfo(int i, WCHAR** ppName, LCID* pLCID);
- STDMETHODIMP_(int) GetStream();
- STDMETHODIMP SetStream(int iStream);
- STDMETHODIMP Reload() {return E_NOTIMPL;}
+ CVobSubStream(CCritSec* pLock);
+ virtual ~CVobSubStream();
+
+ void Open(CString name, BYTE* pData, int len);
+
+ void Add(REFERENCE_TIME tStart, REFERENCE_TIME tStop, BYTE* pData, int len);
+ void RemoveAll();
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ // ISubPicProvider
+ STDMETHODIMP_(POSITION) GetStartPosition(REFERENCE_TIME rt, double fps);
+ STDMETHODIMP_(POSITION) GetNext(POSITION pos);
+ STDMETHODIMP_(REFERENCE_TIME) GetStart(POSITION pos, double fps);
+ STDMETHODIMP_(REFERENCE_TIME) GetStop(POSITION pos, double fps);
+ STDMETHODIMP_(bool) IsAnimated(POSITION pos);
+ STDMETHODIMP Render(SubPicDesc& spd, REFERENCE_TIME rt, double fps, RECT& bbox);
+
+ // IPersist
+ STDMETHODIMP GetClassID(CLSID* pClassID);
+
+ // ISubStream
+ STDMETHODIMP_(int) GetStreamCount();
+ STDMETHODIMP GetStreamInfo(int i, WCHAR** ppName, LCID* pLCID);
+ STDMETHODIMP_(int) GetStream();
+ STDMETHODIMP SetStream(int iStream);
+ STDMETHODIMP Reload() {return E_NOTIMPL;}
};
diff --git a/src/Subtitles/VobSubFileRipper.cpp b/src/Subtitles/VobSubFileRipper.cpp
index 2a3f7c8dd..37da23e25 100644
--- a/src/Subtitles/VobSubFileRipper.cpp
+++ b/src/Subtitles/VobSubFileRipper.cpp
@@ -31,79 +31,79 @@
//
CVobSubFileRipper::CVobSubFileRipper()
- : CVobSubFile(NULL)
- , m_fThreadActive(false)
- , m_fBreakThread(false)
- , m_fIndexing(false)
+ : CVobSubFile(NULL)
+ , m_fThreadActive(false)
+ , m_fBreakThread(false)
+ , m_fIndexing(false)
{
- m_rd.Reset();
- CAMThread::Create();
+ m_rd.Reset();
+ CAMThread::Create();
}
CVobSubFileRipper::~CVobSubFileRipper()
{
- CAMThread::CallWorker(CMD_EXIT);
- CAMThread::Close();
+ CAMThread::CallWorker(CMD_EXIT);
+ CAMThread::Close();
}
STDMETHODIMP CVobSubFileRipper::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- return
- QI(IVSFRipper)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IVSFRipper)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
void CVobSubFileRipper::Log(log_t type, LPCTSTR lpszFormat, ...)
{
- CAutoLock cAutoLock(&m_csCallback);
- if (!m_pCallback) {
- return;
- }
-
- TCHAR buff[1024];
-
- va_list args;
- va_start(args, lpszFormat);
- _vstprintf_s(buff, _countof(buff), lpszFormat, args);
- va_end(args);
-
- CString msg;
- switch (type) {
- default:
- case LOG_INFO:
- msg = _T("");
- break;
- case LOG_WARNING:
- msg = _T("WARNING: ");
- break;
- case LOG_ERROR:
- msg = _T("ERROR: ");
- break;
- }
-
- msg += buff;
-
- m_pCallback->OnMessage(msg);
+ CAutoLock cAutoLock(&m_csCallback);
+ if (!m_pCallback) {
+ return;
+ }
+
+ TCHAR buff[1024];
+
+ va_list args;
+ va_start(args, lpszFormat);
+ _vstprintf_s(buff, _countof(buff), lpszFormat, args);
+ va_end(args);
+
+ CString msg;
+ switch (type) {
+ default:
+ case LOG_INFO:
+ msg = _T("");
+ break;
+ case LOG_WARNING:
+ msg = _T("WARNING: ");
+ break;
+ case LOG_ERROR:
+ msg = _T("ERROR: ");
+ break;
+ }
+
+ msg += buff;
+
+ m_pCallback->OnMessage(msg);
}
void CVobSubFileRipper::Progress(double progress)
{
- CAutoLock cAutoLock(&m_csCallback);
- if (!m_pCallback) {
- return;
- }
+ CAutoLock cAutoLock(&m_csCallback);
+ if (!m_pCallback) {
+ return;
+ }
- m_pCallback->OnProgress(progress);
+ m_pCallback->OnProgress(progress);
}
void CVobSubFileRipper::Finished(bool fSucceeded)
{
- CAutoLock cAutoLock(&m_csCallback);
- if (!m_pCallback) {
- return;
- }
+ CAutoLock cAutoLock(&m_csCallback);
+ if (!m_pCallback) {
+ return;
+ }
- m_pCallback->OnFinished(fSucceeded);
+ m_pCallback->OnFinished(fSucceeded);
}
#define ReadBEb(var) \
@@ -121,1125 +121,1125 @@ void CVobSubFileRipper::Finished(bool fSucceeded)
bool CVobSubFileRipper::LoadIfo(CString fn)
{
- CString str;
+ CString str;
- CFileStatus status;
- if (!CFileGetStatus(fn, status) || !status.m_size) {
- Log(LOG_ERROR, _T("Invalid ifo"));
- return false;
- }
+ CFileStatus status;
+ if (!CFileGetStatus(fn, status) || !status.m_size) {
+ Log(LOG_ERROR, _T("Invalid ifo"));
+ return false;
+ }
- CFile f;
- if (!f.Open(fn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone)) {
- Log(LOG_ERROR, _T("Cannot open ifo"));
- return false;
- }
+ CFile f;
+ if (!f.Open(fn, CFile::modeRead | CFile::typeBinary | CFile::shareDenyNone)) {
+ Log(LOG_ERROR, _T("Cannot open ifo"));
+ return false;
+ }
- Log(LOG_INFO, _T("Opening ifo OK"));
+ Log(LOG_INFO, _T("Opening ifo OK"));
- char hdr[13];
- f.Read(hdr, 12);
- hdr[12] = 0;
- if (strcmp(hdr, "DVDVIDEO-VTS")) {
- Log(LOG_ERROR, _T("Not a Video Title Set IFO file!"));
- return false;
- }
+ char hdr[13];
+ f.Read(hdr, 12);
+ hdr[12] = 0;
+ if (strcmp(hdr, "DVDVIDEO-VTS")) {
+ Log(LOG_ERROR, _T("Not a Video Title Set IFO file!"));
+ return false;
+ }
- // lang ids
+ // lang ids
- f.Seek(0x254, CFile::begin);
+ f.Seek(0x254, CFile::begin);
- WORD ids[32];
- memset(ids, 0, sizeof(ids));
+ WORD ids[32];
+ memset(ids, 0, sizeof(ids));
- int len = 0;
- ReadBEw(len);
+ int len = 0;
+ ReadBEw(len);
- for (ptrdiff_t i = 0; i < len; i++) {
- f.Seek(2, CFile::current); // 01 00 ?
- ReadBEw(ids[i]);
- if (ids[i] == 0) {
- ids[i] = '--';
- }
- f.Seek(2, CFile::current); // 00 00 ?
- }
+ for (ptrdiff_t i = 0; i < len; i++) {
+ f.Seek(2, CFile::current); // 01 00 ?
+ ReadBEw(ids[i]);
+ if (ids[i] == 0) {
+ ids[i] = '--';
+ }
+ f.Seek(2, CFile::current); // 00 00 ?
+ }
- /* Video info */
+ /* Video info */
- f.Seek(0x200, CFile::begin);
- f.Read(&m_rd.vidinfo, 2);
+ f.Seek(0x200, CFile::begin);
+ f.Read(&m_rd.vidinfo, 2);
- SIZE res[4][2] = {
- {{720,480},{720,576}},
- {{704,480},{704,576}},
- {{352,480},{352,576}},
- {{352,240},{352,288}}
- };
+ SIZE res[4][2] = {
+ {{720, 480}, {720, 576}},
+ {{704, 480}, {704, 576}},
+ {{352, 480}, {352, 576}},
+ {{352, 240}, {352, 288}}
+ };
- m_rd.vidsize = res[m_rd.vidinfo.source_res][m_rd.vidinfo.system&1];
+ m_rd.vidsize = res[m_rd.vidinfo.source_res][m_rd.vidinfo.system & 1];
- double rate = (m_rd.vidinfo.system == 0) ? 30.0/29.97 : 1.0;
+ double rate = (m_rd.vidinfo.system == 0) ? 30.0 / 29.97 : 1.0;
- /* PGCs */
+ /* PGCs */
- {
- DWORD offset;
+ {
+ DWORD offset;
- DWORD pgcpos;
- f.Seek(0xc0+0x0c, CFile::begin);
- ReadBEdw(pgcpos);
- pgcpos *= 0x800;
+ DWORD pgcpos;
+ f.Seek(0xc0 + 0x0c, CFile::begin);
+ ReadBEdw(pgcpos);
+ pgcpos *= 0x800;
- WORD nPGC;
- f.Seek(pgcpos, CFile::begin);
- ReadBEw(nPGC);
+ WORD nPGC;
+ f.Seek(pgcpos, CFile::begin);
+ ReadBEw(nPGC);
- m_rd.pgcs.RemoveAll();
- m_rd.pgcs.SetCount(nPGC);
+ m_rd.pgcs.RemoveAll();
+ m_rd.pgcs.SetCount(nPGC);
- for (size_t i = 0; i < nPGC; i++) {
- PGC& pgc = m_rd.pgcs[i];
+ for (size_t i = 0; i < nPGC; i++) {
+ PGC& pgc = m_rd.pgcs[i];
- f.Seek(pgcpos + 8 + i*8 + 4, CFile::begin);
- ReadBEdw(offset);
- offset += pgcpos;
+ f.Seek(pgcpos + 8 + i * 8 + 4, CFile::begin);
+ ReadBEdw(offset);
+ offset += pgcpos;
- BYTE nProgs, nCells;
- f.Seek(offset + 2, CFile::begin);
- ReadBEb(nProgs);
- ReadBEb(nCells);
+ BYTE nProgs, nCells;
+ f.Seek(offset + 2, CFile::begin);
+ ReadBEb(nProgs);
+ ReadBEb(nCells);
- //
+ //
- memcpy(pgc.ids, ids, sizeof(ids));
+ memcpy(pgc.ids, ids, sizeof(ids));
- struct splanginfo {
- BYTE res1, id1, id2, res2;
- };
- splanginfo splinfo[32];
+ struct splanginfo {
+ BYTE res1, id1, id2, res2;
+ };
+ splanginfo splinfo[32];
- f.Seek(offset + 0x1c, CFile::begin);
- f.Read(splinfo, 32*4);
+ f.Seek(offset + 0x1c, CFile::begin);
+ f.Read(splinfo, 32 * 4);
- for (size_t j = 0; j < 32; j++) {
- if (splinfo[j].id1 || splinfo[i].id2) {
- WORD tmpids[32];
- memset(tmpids, 0, sizeof(tmpids));
+ for (size_t j = 0; j < 32; j++) {
+ if (splinfo[j].id1 || splinfo[i].id2) {
+ WORD tmpids[32];
+ memset(tmpids, 0, sizeof(tmpids));
- for (j = 0; j < 32; j++) {
- if (!(splinfo[j].res1 & 0x80)) {
- break;
- }
-
- pgc.ids[splinfo[j].id1] = ids[j];
- pgc.ids[splinfo[j].id2] = ids[j];
- }
+ for (j = 0; j < 32; j++) {
+ if (!(splinfo[j].res1 & 0x80)) {
+ break;
+ }
+
+ pgc.ids[splinfo[j].id1] = ids[j];
+ pgc.ids[splinfo[j].id2] = ids[j];
+ }
- break;
- }
- }
-
- //
-
- f.Seek(offset + 0xa4, CFile::begin);
-
- for (size_t j = 0; j < 16; j++) {
- BYTE y, u, v, tmp;
-
- f.Read(&tmp, 1);
- f.Read(&y, 1);
- f.Read(&u, 1);
- f.Read(&v, 1);
-
- y = (y-16)*255/219;
-
- pgc.pal[j].rgbRed = (BYTE)min(max(1.0*y + 1.4022*(u-128), 0), 255);
- pgc.pal[j].rgbGreen = (BYTE)min(max(1.0*y - 0.3456*(u-128) - 0.7145*(v-128), 0), 255);
- pgc.pal[j].rgbBlue = (BYTE)min(max(1.0*y + 1.7710*(v-128), 0) , 255);
- }
-
- //
-
- WORD progoff, celladdroff, vobcelloff;
- f.Seek(offset + 0xe6, CFile::begin);
- ReadBEw(progoff);
- f.Seek(offset + 0xe8, CFile::begin);
- ReadBEw(celladdroff);
- f.Seek(offset + 0xea, CFile::begin);
- ReadBEw(vobcelloff);
-
- //
-
- CAtlArray<BYTE> progs;
- progs.SetCount(nProgs);
- f.Seek(offset + progoff, CFile::begin);
- f.Read(progs.GetData(), nProgs);
+ break;
+ }
+ }
+
+ //
+
+ f.Seek(offset + 0xa4, CFile::begin);
+
+ for (size_t j = 0; j < 16; j++) {
+ BYTE y, u, v, tmp;
+
+ f.Read(&tmp, 1);
+ f.Read(&y, 1);
+ f.Read(&u, 1);
+ f.Read(&v, 1);
+
+ y = (y - 16) * 255 / 219;
+
+ pgc.pal[j].rgbRed = (BYTE)min(max(1.0 * y + 1.4022 * (u - 128), 0), 255);
+ pgc.pal[j].rgbGreen = (BYTE)min(max(1.0 * y - 0.3456 * (u - 128) - 0.7145 * (v - 128), 0), 255);
+ pgc.pal[j].rgbBlue = (BYTE)min(max(1.0 * y + 1.7710 * (v - 128), 0) , 255);
+ }
+
+ //
+
+ WORD progoff, celladdroff, vobcelloff;
+ f.Seek(offset + 0xe6, CFile::begin);
+ ReadBEw(progoff);
+ f.Seek(offset + 0xe8, CFile::begin);
+ ReadBEw(celladdroff);
+ f.Seek(offset + 0xea, CFile::begin);
+ ReadBEw(vobcelloff);
+
+ //
+
+ CAtlArray<BYTE> progs;
+ progs.SetCount(nProgs);
+ f.Seek(offset + progoff, CFile::begin);
+ f.Read(progs.GetData(), nProgs);
- //
-
- pgc.angles[0].SetCount(nCells);
- pgc.iSelAngle = 0;
-
- //
-
- f.Seek(offset + vobcelloff, CFile::begin);
- for (size_t j = 0; j < nCells; j++) {
- ReadBEw(pgc.angles[0][j].vob);
- ReadBEw(pgc.angles[0][j].cell);
- }
-
- //
-
- DWORD tOffset = 0, tTotal = 0;
-
- int iAngle = 0;
-
- pgc.nAngles = 0;
-
- f.Seek(offset + celladdroff, CFile::begin);
- for (size_t j = 0; j < nCells; j++) {
- BYTE b;
- ReadBEb(b);
- switch (b>>6) {
- case 0:
- iAngle = 0;
- break; // normal
- case 1:
- iAngle = 1;
- break; // first angle block
- case 2:
- iAngle++;
- break; // middle angle block
- case 3:
- iAngle++;
- break; // last angle block (no more should follow)
- }
- pgc.angles[0][j].iAngle = iAngle;
- pgc.nAngles = max(pgc.nAngles, iAngle);
-
- f.Seek(3, CFile::current);
- ReadBEdw(pgc.angles[0][j].tTime);
- ReadBEdw(pgc.angles[0][j].start);
- f.Seek(8, CFile::current);
- ReadBEdw(pgc.angles[0][j].end);
-
- float fps;
- switch ((pgc.angles[0][j].tTime>>6)&0x3) {
- default:
- case 3:
- fps = 30;
- break;
- case 1:
- fps = 25;
- break;
- }
-
- int t = pgc.angles[0][j].tTime;
- int hh = ((t>>28)&0xf)*10+((t>>24)&0xf);
- int mm = ((t>>20)&0xf)*10+((t>>16)&0xf);
- int ss = ((t>>12)&0xf)*10+((t>>8)&0xf);
- int ms = (int)(1000.0 * (((t>>4)&0x3)*10+((t>>0)&0xf)) / fps);
- pgc.angles[0][j].tTime = (DWORD)((((hh*60+mm)*60+ss)*1000+ms)*rate);
-
- // time discontinuity
- if (b&0x02) {
- tOffset = tTotal;
- }
- pgc.angles[0][j].fDiscontinuity = !!(b&0x02);
-
- pgc.angles[0][j].tTotal = tTotal;
- pgc.angles[0][j].tOffset = tOffset;
-
- tTotal += pgc.angles[0][j].tTime;
- }
-
- for (iAngle = 1; iAngle <= 9; iAngle++) {
- tOffset = tTotal = 0;
-
- for (size_t j = 0, k = 0; j < nCells; j++) {
- if (pgc.angles[0][j].iAngle != 0
- && pgc.angles[0][j].iAngle != iAngle) {
- continue;
- }
-
- pgc.angles[iAngle].Add(pgc.angles[0][j]);
-
- if (pgc.angles[iAngle][k].fDiscontinuity) {
- tOffset = tTotal;
- }
-
- pgc.angles[iAngle][k].tTotal = tTotal;
- pgc.angles[iAngle][k].tOffset = tOffset;
-
- tTotal += pgc.angles[iAngle][k].tTime;
-
- k++;
- }
- }
- }
- }
-
- Log(LOG_INFO, _T("Parsing ifo OK"));
-
- return true;
+ //
+
+ pgc.angles[0].SetCount(nCells);
+ pgc.iSelAngle = 0;
+
+ //
+
+ f.Seek(offset + vobcelloff, CFile::begin);
+ for (size_t j = 0; j < nCells; j++) {
+ ReadBEw(pgc.angles[0][j].vob);
+ ReadBEw(pgc.angles[0][j].cell);
+ }
+
+ //
+
+ DWORD tOffset = 0, tTotal = 0;
+
+ int iAngle = 0;
+
+ pgc.nAngles = 0;
+
+ f.Seek(offset + celladdroff, CFile::begin);
+ for (size_t j = 0; j < nCells; j++) {
+ BYTE b;
+ ReadBEb(b);
+ switch (b >> 6) {
+ case 0:
+ iAngle = 0;
+ break; // normal
+ case 1:
+ iAngle = 1;
+ break; // first angle block
+ case 2:
+ iAngle++;
+ break; // middle angle block
+ case 3:
+ iAngle++;
+ break; // last angle block (no more should follow)
+ }
+ pgc.angles[0][j].iAngle = iAngle;
+ pgc.nAngles = max(pgc.nAngles, iAngle);
+
+ f.Seek(3, CFile::current);
+ ReadBEdw(pgc.angles[0][j].tTime);
+ ReadBEdw(pgc.angles[0][j].start);
+ f.Seek(8, CFile::current);
+ ReadBEdw(pgc.angles[0][j].end);
+
+ float fps;
+ switch ((pgc.angles[0][j].tTime >> 6) & 0x3) {
+ default:
+ case 3:
+ fps = 30;
+ break;
+ case 1:
+ fps = 25;
+ break;
+ }
+
+ int t = pgc.angles[0][j].tTime;
+ int hh = ((t >> 28) & 0xf) * 10 + ((t >> 24) & 0xf);
+ int mm = ((t >> 20) & 0xf) * 10 + ((t >> 16) & 0xf);
+ int ss = ((t >> 12) & 0xf) * 10 + ((t >> 8) & 0xf);
+ int ms = (int)(1000.0 * (((t >> 4) & 0x3) * 10 + ((t >> 0) & 0xf)) / fps);
+ pgc.angles[0][j].tTime = (DWORD)((((hh * 60 + mm) * 60 + ss) * 1000 + ms) * rate);
+
+ // time discontinuity
+ if (b & 0x02) {
+ tOffset = tTotal;
+ }
+ pgc.angles[0][j].fDiscontinuity = !!(b & 0x02);
+
+ pgc.angles[0][j].tTotal = tTotal;
+ pgc.angles[0][j].tOffset = tOffset;
+
+ tTotal += pgc.angles[0][j].tTime;
+ }
+
+ for (iAngle = 1; iAngle <= 9; iAngle++) {
+ tOffset = tTotal = 0;
+
+ for (size_t j = 0, k = 0; j < nCells; j++) {
+ if (pgc.angles[0][j].iAngle != 0
+ && pgc.angles[0][j].iAngle != iAngle) {
+ continue;
+ }
+
+ pgc.angles[iAngle].Add(pgc.angles[0][j]);
+
+ if (pgc.angles[iAngle][k].fDiscontinuity) {
+ tOffset = tTotal;
+ }
+
+ pgc.angles[iAngle][k].tTotal = tTotal;
+ pgc.angles[iAngle][k].tOffset = tOffset;
+
+ tTotal += pgc.angles[iAngle][k].tTime;
+
+ k++;
+ }
+ }
+ }
+ }
+
+ Log(LOG_INFO, _T("Parsing ifo OK"));
+
+ return true;
}
bool CVobSubFileRipper::LoadVob(CString fn)
{
- Log(LOG_INFO, _T("Searching vobs..."));
- /*
- CAtlList<CString> m_vobs;
-
- fn = fn.Left(fn.ReverseFind('.')+1);
- fn.TrimRight(_T(".0123456789"));
- for (int i = 0; i < 100; i++)
- {
- CString vob;
- vob.Format(_T("%s%d.vob"), fn, i);
-
- CFileStatus status;
- if (!(CFileGetStatus(vob, status) && status.m_size))
- {
- if (i > 0) break;
- else continue;
- }
-
- if (status.m_size&0x7ff)
- {
- Log(LOG_ERROR, _T("Length of %s is not n*2048!"), vob);
- m_vobs.RemoveAll();
- break;
- }
-
- CString str = _T("Found ") + vob;
-
- if (i == 0)
- {
- str += _T(" (skipping, if not a menu vob rename it)");
- }
- else
- {
- m_vobs.AddTail(vob);
- }
-
- Log(LOG_INFO, str);
- }
-
- if (m_vobs.GetCount() <= 0)
- {
- Log(LOG_ERROR, _T("Nothing found! (%s*.vob)"), fn);
- return false;
- }
- */
- CAtlList<CString> vobs;
- if (!m_vob.Open(fn, vobs/*m_vobs*/)) {
- Log(LOG_ERROR, _T("Cannot open vob sequence"));
- return false;
- }
-
- if (vobs.GetCount() <= 0) {
- Log(LOG_ERROR, _T("Nothing found! (%s*.vob)"), fn);
- return false;
- }
-
- POSITION pos = vobs.GetHeadPosition();
- while (pos) {
- Log(LOG_INFO, _T("Found ") + vobs.GetNext(pos));
- }
-
- if (m_vob.IsDVD()) {
- Log(LOG_INFO, _T("DVD detected..."));
-
- BYTE key[5];
-
- if (m_vob.HasDiscKey(key)) {
- Log(LOG_INFO, _T("Disc key: %02x%02x%02x%02x%02x"), key[0], key[1], key[2], key[3], key[4]);
- } else {
- Log(LOG_WARNING, _T("Couldn't get the disc key"));
- }
-
- if (m_vob.HasTitleKey(key)) {
- Log(LOG_INFO, _T("Title key: %02x%02x%02x%02x%02x"), key[0], key[1], key[2], key[3], key[4]);
- } else {
- Log(LOG_WARNING, _T("Couldn't get the title key"));
- }
-
- BYTE buff[2048];
-
- m_vob.Seek(0);
- if (!m_vob.Read(buff)) {
- Log(LOG_ERROR, _T("Can't read vob, please unlock it with a software player!"));
- return false;
- }
- m_vob.Seek(0);
- }
-
- return true;
+ Log(LOG_INFO, _T("Searching vobs..."));
+ /*
+ CAtlList<CString> m_vobs;
+
+ fn = fn.Left(fn.ReverseFind('.')+1);
+ fn.TrimRight(_T(".0123456789"));
+ for (int i = 0; i < 100; i++)
+ {
+ CString vob;
+ vob.Format(_T("%s%d.vob"), fn, i);
+
+ CFileStatus status;
+ if (!(CFileGetStatus(vob, status) && status.m_size))
+ {
+ if (i > 0) break;
+ else continue;
+ }
+
+ if (status.m_size&0x7ff)
+ {
+ Log(LOG_ERROR, _T("Length of %s is not n*2048!"), vob);
+ m_vobs.RemoveAll();
+ break;
+ }
+
+ CString str = _T("Found ") + vob;
+
+ if (i == 0)
+ {
+ str += _T(" (skipping, if not a menu vob rename it)");
+ }
+ else
+ {
+ m_vobs.AddTail(vob);
+ }
+
+ Log(LOG_INFO, str);
+ }
+
+ if (m_vobs.GetCount() <= 0)
+ {
+ Log(LOG_ERROR, _T("Nothing found! (%s*.vob)"), fn);
+ return false;
+ }
+ */
+ CAtlList<CString> vobs;
+ if (!m_vob.Open(fn, vobs/*m_vobs*/)) {
+ Log(LOG_ERROR, _T("Cannot open vob sequence"));
+ return false;
+ }
+
+ if (vobs.GetCount() <= 0) {
+ Log(LOG_ERROR, _T("Nothing found! (%s*.vob)"), fn);
+ return false;
+ }
+
+ POSITION pos = vobs.GetHeadPosition();
+ while (pos) {
+ Log(LOG_INFO, _T("Found ") + vobs.GetNext(pos));
+ }
+
+ if (m_vob.IsDVD()) {
+ Log(LOG_INFO, _T("DVD detected..."));
+
+ BYTE key[5];
+
+ if (m_vob.HasDiscKey(key)) {
+ Log(LOG_INFO, _T("Disc key: %02x%02x%02x%02x%02x"), key[0], key[1], key[2], key[3], key[4]);
+ } else {
+ Log(LOG_WARNING, _T("Couldn't get the disc key"));
+ }
+
+ if (m_vob.HasTitleKey(key)) {
+ Log(LOG_INFO, _T("Title key: %02x%02x%02x%02x%02x"), key[0], key[1], key[2], key[3], key[4]);
+ } else {
+ Log(LOG_WARNING, _T("Couldn't get the title key"));
+ }
+
+ BYTE buff[2048];
+
+ m_vob.Seek(0);
+ if (!m_vob.Read(buff)) {
+ Log(LOG_ERROR, _T("Can't read vob, please unlock it with a software player!"));
+ return false;
+ }
+ m_vob.Seek(0);
+ }
+
+ return true;
}
DWORD CVobSubFileRipper::ThreadProc()
{
- SetThreadPriority(m_hThread, THREAD_PRIORITY_BELOW_NORMAL);
-
- for (;;) {
- DWORD cmd = GetRequest();
-
- m_fThreadActive = true;
-
- switch (cmd) {
- case CMD_EXIT:
- Reply(S_OK);
- return 0;
-
- case CMD_INDEX:
- Reply(S_OK);
- {
- m_fIndexing = true;
- bool fSucceeded = Create();
- m_fIndexing = false;
- Finished(fSucceeded);
- }
- break;
-
- default:
- Reply((DWORD)E_FAIL);
- return (DWORD)-1;
- }
-
- m_fBreakThread = false;
- m_fThreadActive = false;
- }
-
- return 1;
+ SetThreadPriority(m_hThread, THREAD_PRIORITY_BELOW_NORMAL);
+
+ for (;;) {
+ DWORD cmd = GetRequest();
+
+ m_fThreadActive = true;
+
+ switch (cmd) {
+ case CMD_EXIT:
+ Reply(S_OK);
+ return 0;
+
+ case CMD_INDEX:
+ Reply(S_OK);
+ {
+ m_fIndexing = true;
+ bool fSucceeded = Create();
+ m_fIndexing = false;
+ Finished(fSucceeded);
+ }
+ break;
+
+ default:
+ Reply((DWORD)E_FAIL);
+ return (DWORD) - 1;
+ }
+
+ m_fBreakThread = false;
+ m_fThreadActive = false;
+ }
+
+ return 1;
}
static int SubPosSortProc(const void* e1, const void* e2)
{
- return ((int)(((CVobSubFile::SubPos*)e1)->start - ((CVobSubFile::SubPos*)e2)->start));
+ return ((int)(((CVobSubFile::SubPos*)e1)->start - ((CVobSubFile::SubPos*)e2)->start));
}
bool CVobSubFileRipper::Create()
{
- CAutoLock cAutoLock(&m_csAccessLock);
+ CAutoLock cAutoLock(&m_csAccessLock);
- if (m_rd.iSelPGC < 0 || (size_t)m_rd.iSelPGC >= m_rd.pgcs.GetCount()) {
- Log(LOG_ERROR, _T("Invalid program chain number (%d)!"), m_rd.iSelPGC);
- return false;
- }
+ if (m_rd.iSelPGC < 0 || (size_t)m_rd.iSelPGC >= m_rd.pgcs.GetCount()) {
+ Log(LOG_ERROR, _T("Invalid program chain number (%d)!"), m_rd.iSelPGC);
+ return false;
+ }
- PGC& pgc = m_rd.pgcs[m_rd.iSelPGC];
+ PGC& pgc = m_rd.pgcs[m_rd.iSelPGC];
- if (pgc.iSelAngle < 0 || pgc.iSelAngle > 9 || pgc.angles[pgc.iSelAngle].GetCount() == 0) {
- Log(LOG_ERROR, _T("Invalid angle number (%d)!"), pgc.iSelAngle);
- return false;
- }
+ if (pgc.iSelAngle < 0 || pgc.iSelAngle > 9 || pgc.angles[pgc.iSelAngle].GetCount() == 0) {
+ Log(LOG_ERROR, _T("Invalid angle number (%d)!"), pgc.iSelAngle);
+ return false;
+ }
- CAtlArray<vc_t>& angle = pgc.angles[pgc.iSelAngle];
+ CAtlArray<vc_t>& angle = pgc.angles[pgc.iSelAngle];
- if (m_rd.selids.GetCount() == 0 && !m_rd.fClosedCaption) {
- Log(LOG_ERROR, _T("No valid stream set to be extacted!"));
- return false;
- }
+ if (m_rd.selids.GetCount() == 0 && !m_rd.fClosedCaption) {
+ Log(LOG_ERROR, _T("No valid stream set to be extacted!"));
+ return false;
+ }
- if (m_rd.selvcs.GetCount() == 0) {
- Log(LOG_ERROR, _T("No valid vob/cell id set to be extacted!"));
- return false;
- }
+ if (m_rd.selvcs.GetCount() == 0) {
+ Log(LOG_ERROR, _T("No valid vob/cell id set to be extacted!"));
+ return false;
+ }
- Log(LOG_INFO, _T("Indexing..."));
+ Log(LOG_INFO, _T("Indexing..."));
- // initalize CVobSubFile
- CVobSubFile::Close();
- InitSettings();
- m_title = m_outfn;
- m_size = m_rd.vidsize;
- TrimExtension(m_title);
- memcpy(m_orgpal, pgc.pal, sizeof(m_orgpal));
- m_sub.SetLength(0);
+ // initalize CVobSubFile
+ CVobSubFile::Close();
+ InitSettings();
+ m_title = m_outfn;
+ m_size = m_rd.vidsize;
+ TrimExtension(m_title);
+ memcpy(m_orgpal, pgc.pal, sizeof(m_orgpal));
+ m_sub.SetLength(0);
- CCDecoder ccdec(m_title + _T(".cc.srt"), m_title + _T(".cc.raw"));
+ CCDecoder ccdec(m_title + _T(".cc.srt"), m_title + _T(".cc.raw"));
- CVobDec vd;
+ CVobDec vd;
- __int64 PTS = 0, tOffset = 0, tPrevOffset = 0, tTotal = 0, tStart = 0;
- int vob = 0, cell = 0;
- bool fDiscontinuity = false, fDiscontinuityFixApplied = false, fNavpackFound = false;
+ __int64 PTS = 0, tOffset = 0, tPrevOffset = 0, tTotal = 0, tStart = 0;
+ int vob = 0, cell = 0;
+ bool fDiscontinuity = false, fDiscontinuityFixApplied = false, fNavpackFound = false;
- int PTSframeoffset = 0, minPTSframeoffset = 0;
+ int PTSframeoffset = 0, minPTSframeoffset = 0;
- if (m_rd.fResetTime) {
- for (size_t i = 0; i < angle.GetCount() && (UINT)((angle[i].vob<<16)|angle[i].cell) != m_rd.selvcs[0]; i++) {
- tStart += angle[i].tTime;
- }
+ if (m_rd.fResetTime) {
+ for (size_t i = 0; i < angle.GetCount() && (UINT)((angle[i].vob << 16) | angle[i].cell) != m_rd.selvcs[0]; i++) {
+ tStart += angle[i].tTime;
+ }
- Log(LOG_INFO, _T("Counting timestamps from %I64dms (v%02dc%02d)"),
- tStart, m_rd.selvcs[0]>>16, m_rd.selvcs[0]&0xffff);
- }
+ Log(LOG_INFO, _T("Counting timestamps from %I64dms (v%02dc%02d)"),
+ tStart, m_rd.selvcs[0] >> 16, m_rd.selvcs[0] & 0xffff);
+ }
- CAtlMap<DWORD, int> selvcmap;
- selvcmap.RemoveAll();
- for (size_t i = 0; i < m_rd.selvcs.GetCount(); i++) {
- selvcmap[m_rd.selvcs[i]] = 90000;
- }
+ CAtlMap<DWORD, int> selvcmap;
+ selvcmap.RemoveAll();
+ for (size_t i = 0; i < m_rd.selvcs.GetCount(); i++) {
+ selvcmap[m_rd.selvcs[i]] = 90000;
+ }
- CAtlArray<vcchunk> chunks, foundchunks, loadedchunks;
+ CAtlArray<vcchunk> chunks, foundchunks, loadedchunks;
- if (m_vob.IsDVD()) {
- Log(LOG_INFO, _T("Indexing mode: DVD"));
+ if (m_vob.IsDVD()) {
+ Log(LOG_INFO, _T("Indexing mode: DVD"));
- for (size_t i = 0; i < angle.GetCount(); i++) {
- DWORD vc = (angle[i].vob<<16)|angle[i].cell;
- if (!selvcmap.Lookup(vc)) {
- continue;
- }
+ for (size_t i = 0; i < angle.GetCount(); i++) {
+ DWORD vc = (angle[i].vob << 16) | angle[i].cell;
+ if (!selvcmap.Lookup(vc)) {
+ continue;
+ }
- vcchunk c = {2048i64*angle[i].start, 2048i64*angle[i].end+2048, vc};
- chunks.Add(c);
-
- Log(LOG_INFO, _T("Adding: 0x%x - 0x%x (lba) for vob %d cell %d"),
- angle[i].start, angle[i].end, angle[i].vob, angle[i].cell);
- }
- } else if (LoadChunks(loadedchunks)) {
- Log(LOG_INFO, _T("Indexing mode: File"));
+ vcchunk c = {2048i64 * angle[i].start, 2048i64 * angle[i].end + 2048, vc};
+ chunks.Add(c);
+
+ Log(LOG_INFO, _T("Adding: 0x%x - 0x%x (lba) for vob %d cell %d"),
+ angle[i].start, angle[i].end, angle[i].vob, angle[i].cell);
+ }
+ } else if (LoadChunks(loadedchunks)) {
+ Log(LOG_INFO, _T("Indexing mode: File"));
- for (size_t i = 0; i < loadedchunks.GetCount(); i++) {
- DWORD vcid = loadedchunks[i].vc;
- if (!selvcmap.Lookup(vcid)) {
- continue;
- }
-
- chunks.Add(loadedchunks[i]);
- }
+ for (size_t i = 0; i < loadedchunks.GetCount(); i++) {
+ DWORD vcid = loadedchunks[i].vc;
+ if (!selvcmap.Lookup(vcid)) {
+ continue;
+ }
+
+ chunks.Add(loadedchunks[i]);
+ }
- Log(LOG_INFO, _T(".chunk file loaded"));
- } else {
- Log(LOG_INFO, _T("Indexing mode: File"));
+ Log(LOG_INFO, _T(".chunk file loaded"));
+ } else {
+ Log(LOG_INFO, _T("Indexing mode: File"));
- chunks.RemoveAll();
- vcchunk c = {0, 2048i64*m_vob.GetLength(), 0};
- chunks.Add(c);
- }
+ chunks.RemoveAll();
+ vcchunk c = {0, 2048i64 * m_vob.GetLength(), 0};
+ chunks.Add(c);
+ }
- __int64 sizedone = 0, sizetotal = 0;
- for (size_t i = 0; i < chunks.GetCount(); i++) {
- sizetotal += chunks[i].end - chunks[i].start;
- }
+ __int64 sizedone = 0, sizetotal = 0;
+ for (size_t i = 0; i < chunks.GetCount(); i++) {
+ sizetotal += chunks[i].end - chunks[i].start;
+ }
- for (size_t i = 0; !m_fBreakThread && i < chunks.GetCount(); i++) {
- __int64 curpos = chunks[i].start, endpos = chunks[i].end;
-
- vcchunk curchunk = {curpos, curpos, chunks[i].vc};
-
- for (m_vob.Seek((int)(curpos/2048)); !m_fBreakThread && curpos < endpos; curpos += 2048, sizedone += 2048) {
- if (!(curpos&0x7ffff)) {
- Progress(1.0 * sizedone / sizetotal);
- }
-
- static BYTE buff[2048];
-
- if (!m_vob.Read(buff)) {
- Log(LOG_ERROR, _T("Cannot read, either locked dvd or truncated/missing files!"));
- return false;
- }
-
- curchunk.end = curpos;
-
- if (buff[0x14] & 0x30) {
- if (!vd.m_fFoundKey) {
- Log(LOG_INFO, _T("Encrypted sector found, searching key..."));
-
- __int64 savepos = curpos;
-
- m_vob.Seek(0);
- for (__int64 pos = 0; !m_fBreakThread && pos < endpos; pos += 2048) {
- if (!m_vob.Read(buff)) {
- Log(LOG_ERROR, _T("Cannot read, either locked dvd or truncated/missing files!"));
- return false;
- }
-
- if (vd.FindKey(buff)) {
- break;
- }
- }
-
- if (m_fBreakThread) {
- break;
- }
-
- if (!vd.m_fFoundKey) {
- Log(LOG_ERROR, _T("Key not found, can't decrypt!"));
- return false;
- }
-
- Log(LOG_INFO, _T("Key found, continuing extraction..."));
-
- m_vob.Seek((int)((curpos = savepos)/2048));
- m_vob.Read(buff);
- }
-
- vd.Decrypt(buff);
- }
-
- if (*((DWORD*)&buff[0]) != 0xba010000) {
- Log(LOG_WARNING, _T("Bad sector header at block %08d!"), (int)(curpos/2048));
-
- if (AfxMessageBox(_T("Bad packet header found, do you want to continue?"), MB_YESNO) == IDNO) {
- Log(LOG_ERROR, _T("Terminated!"));
- return false;
- }
- }
-
- /*__int64 SCR = (__int64(buff[0x04] & 0x38) >> 3) << 30
- | __int64(buff[0x04] & 0x03) << 28
- | __int64(buff[0x05]) << 20
- | (__int64(buff[0x06] & 0xf8) >> 3) << 15
- | __int64(buff[0x06] & 0x03) << 13
- | __int64(buff[0x07]) << 5
- | (__int64(buff[0x08] & 0xf8) >> 3) << 0;*/
-
- bool hasPTS = false;
-
- if ((*(DWORD*)&buff[0x0e] == 0xe0010000 || *(DWORD*)&buff[0x0e] == 0xbd010000)
- && buff[0x15] & 0x80) {
- PTS = (__int64)(buff[0x17] & 0x0e) << 29 // 32-30 (+marker)
- | ((__int64)(buff[0x18]) << 22) // 29-22
- | ((__int64)(buff[0x19] & 0xfe) << 14) // 21-15 (+marker)
- | ((__int64)(buff[0x1a]) << 7) // 14-07
- | ((__int64)(buff[0x1b]) >> 1); // 06-00 (+marker)
-
- hasPTS = true;
- }
-
- if (*((DWORD*)&buff[0x0e]) == 0xbb010000) {
- fNavpackFound = true;
-
- if (vob == buff[0x420] && cell == buff[0x422]) {
- continue;
- }
-
- vob = buff[0x420];
- cell = buff[0x422];
-
- tOffset = tTotal = 0;
-
- for (size_t i = 0; i < angle.GetCount(); i++) {
- if (angle[i].vob == vob && angle[i].cell == cell) {
- tPrevOffset = tOffset;
- tOffset = (__int64)angle[i].tOffset;
- tTotal = (__int64)angle[i].tTotal;
- fDiscontinuity = angle[i].fDiscontinuity;
- fDiscontinuityFixApplied = false;
- break;
- }
- }
-
- if (curchunk.vc != (DWORD)((vob<<16)|cell)) {
- if (curchunk.vc != 0) {
- foundchunks.Add(curchunk);
- }
- curchunk.start = curchunk.end = curpos;
- curchunk.vc = (vob<<16)|cell;
- }
-
- CString str, str2;
- str.Format(_T("v%02d c%02d lba%08d"), vob, cell, (int)(curpos/2048));
- UINT vcid = (vob<<16)|cell;
- if (!selvcmap.Lookup(vcid, minPTSframeoffset)) {
- str2 = _T(", skipping");
- } else str2.Format(_T(", total=%I64dms, off=%I64dms, corr=%I64dms, discont.:%d"),
- tTotal, tOffset, -tStart, (int)fDiscontinuity);
- Log(LOG_INFO, str + str2);
- }
-
- DWORD vcid = (vob<<16)|cell;
- if (!selvcmap.Lookup(vcid, minPTSframeoffset)) {
- continue;
- }
-
- if (hasPTS && fDiscontinuity && !fDiscontinuityFixApplied) {
- __int64 tDiff = tOffset - tPrevOffset;
- if (tDiff > 0 && tDiff < (PTS/90+1000)) {
- CString str;
- str.Format(_T("False discontinuity detected, correcting time by %I64dms"), -tDiff);
- Log(LOG_INFO, str);
-
- tStart += tDiff;
- }
- fDiscontinuityFixApplied = true;
- }
-
- if (*(DWORD*)&buff[0x0e] == 0xe0010000) {
- if (fDiscontinuity) {
- if (PTS < minPTSframeoffset) {
- selvcmap[vcid] = PTSframeoffset = (int)PTS;
- }
-
- fDiscontinuity = false;
- }
-
- if (m_rd.fClosedCaption) {
- ccdec.ExtractCC(buff, 2048, tOffset + ((PTS - PTSframeoffset) / 90) - tStart);
- }
- } else if (*(DWORD*)&buff[0x0e] == 0xbd010000) {
- BYTE id = buff[0x17 + buff[0x16]], iLang = id&0x1f;
-
- if ((id & 0xe0) == 0x20 && m_rd.selids.Lookup(iLang)) {
- if (hasPTS) {
- SubPos sb;
- sb.filepos = m_sub.GetPosition();
- sb.start = tOffset + ((PTS - PTSframeoffset) / 90) - tStart;
- sb.vobid = (char)vob;
- sb.cellid = (char)cell;
- sb.celltimestamp = tTotal;
- sb.fValid = true;
- m_langs[iLang].subpos.Add(sb);
- }
-
- m_sub.Write(buff, 2048);
- }
- }
- }
-
- if (curchunk.vc != (DWORD)((vob<<16)|cell)) {
- if (curchunk.vc != 0) {
- foundchunks.Add(curchunk);
- }
- curchunk.start = curchunk.end = curpos;
- curchunk.vc = (vob<<16)|cell;
- }
- }
-
- if (sizedone < sizetotal) {
- Log(LOG_ERROR, _T("Indexing terminated before reaching the end!"));
- Progress(0);
- return false;
- }
-
- if (!fNavpackFound) {
- Log(LOG_ERROR, _T("Could not find any system header start code! (0x000001bb)"));
- if (!m_vob.IsDVD()) {
- Log(LOG_ERROR, _T("Make sure the ripper doesn't strip these packets."));
- }
- Progress(0);
- return false;
- }
-
- Log(LOG_INFO, _T("Indexing finished"));
- Progress(1);
-
- for (ptrdiff_t i = 0; i < 32; i++) {
- if (m_iLang == -1 && m_langs[i].subpos.GetCount() > 0) {
- m_iLang = (int)i;
- }
- m_langs[i].id = pgc.ids[i];
- m_langs[i].name = m_langs[i].alt = FindLangFromId(m_langs[i].id);
-
- CAtlArray<SubPos>& sp = m_langs[i].subpos;
- qsort(sp.GetData(), sp.GetCount(), sizeof(SubPos), SubPosSortProc);
-
- if (m_rd.fForcedOnly) {
- Log(LOG_INFO, _T("Searching for forced subs..."));
- Progress(0);
-
- for (ptrdiff_t j = 0, len = sp.GetCount(); j < len; j++) {
- Progress(1.0 * j / len);
-
- sp[j].fValid = false;
- int packetsize = 0, datasize = 0;
- if (BYTE* buff = GetPacket((int)j, packetsize, datasize, (int)i)) {
- m_img.GetPacketInfo(buff, packetsize, datasize);
- sp[j].fValid = m_img.fForced;
- delete [] buff;
- }
- }
-
- Progress(1);
- }
- }
-
- Log(LOG_INFO, _T("Saving files..."));
-
- if (m_iLang != -1) {
- if (!Save(m_title)) {
- Log(LOG_ERROR, _T("Could not save output files!"));
- return false;
- }
- }
-
- Log(LOG_INFO, _T("Subtitles saved"));
-
- if (!m_vob.IsDVD() && loadedchunks.GetCount() == 0) {
- if (SaveChunks(foundchunks)) {
- Log(LOG_INFO, _T(".chunk file saved"));
- }
- }
-
- Log(LOG_INFO, _T("Done!"));
-
- return true;
+ for (size_t i = 0; !m_fBreakThread && i < chunks.GetCount(); i++) {
+ __int64 curpos = chunks[i].start, endpos = chunks[i].end;
+
+ vcchunk curchunk = {curpos, curpos, chunks[i].vc};
+
+ for (m_vob.Seek((int)(curpos / 2048)); !m_fBreakThread && curpos < endpos; curpos += 2048, sizedone += 2048) {
+ if (!(curpos & 0x7ffff)) {
+ Progress(1.0 * sizedone / sizetotal);
+ }
+
+ static BYTE buff[2048];
+
+ if (!m_vob.Read(buff)) {
+ Log(LOG_ERROR, _T("Cannot read, either locked dvd or truncated/missing files!"));
+ return false;
+ }
+
+ curchunk.end = curpos;
+
+ if (buff[0x14] & 0x30) {
+ if (!vd.m_fFoundKey) {
+ Log(LOG_INFO, _T("Encrypted sector found, searching key..."));
+
+ __int64 savepos = curpos;
+
+ m_vob.Seek(0);
+ for (__int64 pos = 0; !m_fBreakThread && pos < endpos; pos += 2048) {
+ if (!m_vob.Read(buff)) {
+ Log(LOG_ERROR, _T("Cannot read, either locked dvd or truncated/missing files!"));
+ return false;
+ }
+
+ if (vd.FindKey(buff)) {
+ break;
+ }
+ }
+
+ if (m_fBreakThread) {
+ break;
+ }
+
+ if (!vd.m_fFoundKey) {
+ Log(LOG_ERROR, _T("Key not found, can't decrypt!"));
+ return false;
+ }
+
+ Log(LOG_INFO, _T("Key found, continuing extraction..."));
+
+ m_vob.Seek((int)((curpos = savepos) / 2048));
+ m_vob.Read(buff);
+ }
+
+ vd.Decrypt(buff);
+ }
+
+ if (*((DWORD*)&buff[0]) != 0xba010000) {
+ Log(LOG_WARNING, _T("Bad sector header at block %08d!"), (int)(curpos / 2048));
+
+ if (AfxMessageBox(_T("Bad packet header found, do you want to continue?"), MB_YESNO) == IDNO) {
+ Log(LOG_ERROR, _T("Terminated!"));
+ return false;
+ }
+ }
+
+ /*__int64 SCR = (__int64(buff[0x04] & 0x38) >> 3) << 30
+ | __int64(buff[0x04] & 0x03) << 28
+ | __int64(buff[0x05]) << 20
+ | (__int64(buff[0x06] & 0xf8) >> 3) << 15
+ | __int64(buff[0x06] & 0x03) << 13
+ | __int64(buff[0x07]) << 5
+ | (__int64(buff[0x08] & 0xf8) >> 3) << 0;*/
+
+ bool hasPTS = false;
+
+ if ((*(DWORD*)&buff[0x0e] == 0xe0010000 || *(DWORD*)&buff[0x0e] == 0xbd010000)
+ && buff[0x15] & 0x80) {
+ PTS = (__int64)(buff[0x17] & 0x0e) << 29 // 32-30 (+marker)
+ | ((__int64)(buff[0x18]) << 22) // 29-22
+ | ((__int64)(buff[0x19] & 0xfe) << 14) // 21-15 (+marker)
+ | ((__int64)(buff[0x1a]) << 7) // 14-07
+ | ((__int64)(buff[0x1b]) >> 1); // 06-00 (+marker)
+
+ hasPTS = true;
+ }
+
+ if (*((DWORD*)&buff[0x0e]) == 0xbb010000) {
+ fNavpackFound = true;
+
+ if (vob == buff[0x420] && cell == buff[0x422]) {
+ continue;
+ }
+
+ vob = buff[0x420];
+ cell = buff[0x422];
+
+ tOffset = tTotal = 0;
+
+ for (size_t i = 0; i < angle.GetCount(); i++) {
+ if (angle[i].vob == vob && angle[i].cell == cell) {
+ tPrevOffset = tOffset;
+ tOffset = (__int64)angle[i].tOffset;
+ tTotal = (__int64)angle[i].tTotal;
+ fDiscontinuity = angle[i].fDiscontinuity;
+ fDiscontinuityFixApplied = false;
+ break;
+ }
+ }
+
+ if (curchunk.vc != (DWORD)((vob << 16) | cell)) {
+ if (curchunk.vc != 0) {
+ foundchunks.Add(curchunk);
+ }
+ curchunk.start = curchunk.end = curpos;
+ curchunk.vc = (vob << 16) | cell;
+ }
+
+ CString str, str2;
+ str.Format(_T("v%02d c%02d lba%08d"), vob, cell, (int)(curpos / 2048));
+ UINT vcid = (vob << 16) | cell;
+ if (!selvcmap.Lookup(vcid, minPTSframeoffset)) {
+ str2 = _T(", skipping");
+ } else str2.Format(_T(", total=%I64dms, off=%I64dms, corr=%I64dms, discont.:%d"),
+ tTotal, tOffset, -tStart, (int)fDiscontinuity);
+ Log(LOG_INFO, str + str2);
+ }
+
+ DWORD vcid = (vob << 16) | cell;
+ if (!selvcmap.Lookup(vcid, minPTSframeoffset)) {
+ continue;
+ }
+
+ if (hasPTS && fDiscontinuity && !fDiscontinuityFixApplied) {
+ __int64 tDiff = tOffset - tPrevOffset;
+ if (tDiff > 0 && tDiff < (PTS / 90 + 1000)) {
+ CString str;
+ str.Format(_T("False discontinuity detected, correcting time by %I64dms"), -tDiff);
+ Log(LOG_INFO, str);
+
+ tStart += tDiff;
+ }
+ fDiscontinuityFixApplied = true;
+ }
+
+ if (*(DWORD*)&buff[0x0e] == 0xe0010000) {
+ if (fDiscontinuity) {
+ if (PTS < minPTSframeoffset) {
+ selvcmap[vcid] = PTSframeoffset = (int)PTS;
+ }
+
+ fDiscontinuity = false;
+ }
+
+ if (m_rd.fClosedCaption) {
+ ccdec.ExtractCC(buff, 2048, tOffset + ((PTS - PTSframeoffset) / 90) - tStart);
+ }
+ } else if (*(DWORD*)&buff[0x0e] == 0xbd010000) {
+ BYTE id = buff[0x17 + buff[0x16]], iLang = id & 0x1f;
+
+ if ((id & 0xe0) == 0x20 && m_rd.selids.Lookup(iLang)) {
+ if (hasPTS) {
+ SubPos sb;
+ sb.filepos = m_sub.GetPosition();
+ sb.start = tOffset + ((PTS - PTSframeoffset) / 90) - tStart;
+ sb.vobid = (char)vob;
+ sb.cellid = (char)cell;
+ sb.celltimestamp = tTotal;
+ sb.fValid = true;
+ m_langs[iLang].subpos.Add(sb);
+ }
+
+ m_sub.Write(buff, 2048);
+ }
+ }
+ }
+
+ if (curchunk.vc != (DWORD)((vob << 16) | cell)) {
+ if (curchunk.vc != 0) {
+ foundchunks.Add(curchunk);
+ }
+ curchunk.start = curchunk.end = curpos;
+ curchunk.vc = (vob << 16) | cell;
+ }
+ }
+
+ if (sizedone < sizetotal) {
+ Log(LOG_ERROR, _T("Indexing terminated before reaching the end!"));
+ Progress(0);
+ return false;
+ }
+
+ if (!fNavpackFound) {
+ Log(LOG_ERROR, _T("Could not find any system header start code! (0x000001bb)"));
+ if (!m_vob.IsDVD()) {
+ Log(LOG_ERROR, _T("Make sure the ripper doesn't strip these packets."));
+ }
+ Progress(0);
+ return false;
+ }
+
+ Log(LOG_INFO, _T("Indexing finished"));
+ Progress(1);
+
+ for (ptrdiff_t i = 0; i < 32; i++) {
+ if (m_iLang == -1 && m_langs[i].subpos.GetCount() > 0) {
+ m_iLang = (int)i;
+ }
+ m_langs[i].id = pgc.ids[i];
+ m_langs[i].name = m_langs[i].alt = FindLangFromId(m_langs[i].id);
+
+ CAtlArray<SubPos>& sp = m_langs[i].subpos;
+ qsort(sp.GetData(), sp.GetCount(), sizeof(SubPos), SubPosSortProc);
+
+ if (m_rd.fForcedOnly) {
+ Log(LOG_INFO, _T("Searching for forced subs..."));
+ Progress(0);
+
+ for (ptrdiff_t j = 0, len = sp.GetCount(); j < len; j++) {
+ Progress(1.0 * j / len);
+
+ sp[j].fValid = false;
+ int packetsize = 0, datasize = 0;
+ if (BYTE* buff = GetPacket((int)j, packetsize, datasize, (int)i)) {
+ m_img.GetPacketInfo(buff, packetsize, datasize);
+ sp[j].fValid = m_img.fForced;
+ delete [] buff;
+ }
+ }
+
+ Progress(1);
+ }
+ }
+
+ Log(LOG_INFO, _T("Saving files..."));
+
+ if (m_iLang != -1) {
+ if (!Save(m_title)) {
+ Log(LOG_ERROR, _T("Could not save output files!"));
+ return false;
+ }
+ }
+
+ Log(LOG_INFO, _T("Subtitles saved"));
+
+ if (!m_vob.IsDVD() && loadedchunks.GetCount() == 0) {
+ if (SaveChunks(foundchunks)) {
+ Log(LOG_INFO, _T(".chunk file saved"));
+ }
+ }
+
+ Log(LOG_INFO, _T("Done!"));
+
+ return true;
}
static const DWORD s_version = 1;
bool CVobSubFileRipper::LoadChunks(CAtlArray<vcchunk>& chunks)
{
- CFile f;
-
- CString fn = m_infn;
- TrimExtension(fn);
- fn += _T(".chunks");
-
- DWORD chksum = 0, chunklen, version;
- __int64 voblen = 0;
-
- if (!f.Open(fn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone)) {
- return false;
- }
- f.Read(&version, sizeof(version));
- if (version == 1) {
- f.Read(&chksum, sizeof(chksum));
- f.Read(&voblen, sizeof(voblen));
- f.Read(&chunklen, sizeof(chunklen));
- chunks.SetCount(chunklen);
- f.Read(chunks.GetData(), UINT(sizeof(vcchunk)*chunks.GetCount()));
- }
- f.Close();
-
- if (voblen != m_vob.GetLength()) {
- chunks.RemoveAll();
- return false;
- }
-
- if (!f.Open(m_infn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone)) {
- return false;
- }
- DWORD dw, chksum2 = 0;
- while (f.Read(&dw, sizeof(dw)) == sizeof(dw)) {
- chksum2 += dw;
- }
- f.Close();
-
- if (chksum != chksum2) {
- chunks.RemoveAll();
- return false;
- }
-
- return true;
+ CFile f;
+
+ CString fn = m_infn;
+ TrimExtension(fn);
+ fn += _T(".chunks");
+
+ DWORD chksum = 0, chunklen, version;
+ __int64 voblen = 0;
+
+ if (!f.Open(fn, CFile::modeRead | CFile::typeBinary | CFile::shareDenyNone)) {
+ return false;
+ }
+ f.Read(&version, sizeof(version));
+ if (version == 1) {
+ f.Read(&chksum, sizeof(chksum));
+ f.Read(&voblen, sizeof(voblen));
+ f.Read(&chunklen, sizeof(chunklen));
+ chunks.SetCount(chunklen);
+ f.Read(chunks.GetData(), UINT(sizeof(vcchunk)*chunks.GetCount()));
+ }
+ f.Close();
+
+ if (voblen != m_vob.GetLength()) {
+ chunks.RemoveAll();
+ return false;
+ }
+
+ if (!f.Open(m_infn, CFile::modeRead | CFile::typeBinary | CFile::shareDenyNone)) {
+ return false;
+ }
+ DWORD dw, chksum2 = 0;
+ while (f.Read(&dw, sizeof(dw)) == sizeof(dw)) {
+ chksum2 += dw;
+ }
+ f.Close();
+
+ if (chksum != chksum2) {
+ chunks.RemoveAll();
+ return false;
+ }
+
+ return true;
}
bool CVobSubFileRipper::SaveChunks(CAtlArray<vcchunk>& chunks)
{
- CFile f;
-
- CString fn = m_infn;
- TrimExtension(fn);
- fn += _T(".chunks");
-
- DWORD chksum = 0, chunklen = (DWORD)chunks.GetCount();
- __int64 voblen = m_vob.GetLength();
-
- if (!f.Open(m_infn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone)) {
- return false;
- }
- DWORD dw;
- while (f.Read(&dw, sizeof(dw)) == sizeof(dw)) {
- chksum += dw;
- }
- f.Close();
-
- if (!f.Open(fn, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary|CFile::shareDenyWrite)) {
- return false;
- }
- f.Write(&s_version, sizeof(s_version));
- f.Write(&chksum, sizeof(chksum));
- f.Write(&voblen, sizeof(voblen));
- f.Write(&chunklen, sizeof(chunklen));
- f.Write(chunks.GetData(), sizeof(vcchunk)*chunklen);
- f.Close();
-
- return true;
+ CFile f;
+
+ CString fn = m_infn;
+ TrimExtension(fn);
+ fn += _T(".chunks");
+
+ DWORD chksum = 0, chunklen = (DWORD)chunks.GetCount();
+ __int64 voblen = m_vob.GetLength();
+
+ if (!f.Open(m_infn, CFile::modeRead | CFile::typeBinary | CFile::shareDenyNone)) {
+ return false;
+ }
+ DWORD dw;
+ while (f.Read(&dw, sizeof(dw)) == sizeof(dw)) {
+ chksum += dw;
+ }
+ f.Close();
+
+ if (!f.Open(fn, CFile::modeCreate | CFile::modeWrite | CFile::typeBinary | CFile::shareDenyWrite)) {
+ return false;
+ }
+ f.Write(&s_version, sizeof(s_version));
+ f.Write(&chksum, sizeof(chksum));
+ f.Write(&voblen, sizeof(voblen));
+ f.Write(&chunklen, sizeof(chunklen));
+ f.Write(chunks.GetData(), sizeof(vcchunk)*chunklen);
+ f.Close();
+
+ return true;
}
// IVSFRipper
STDMETHODIMP CVobSubFileRipper::SetCallBack(IVSFRipperCallback* pCallback)
{
- CAutoLock cAutoLock(&m_csCallback);
- m_pCallback = pCallback;
- return S_OK;
+ CAutoLock cAutoLock(&m_csCallback);
+ m_pCallback = pCallback;
+ return S_OK;
}
STDMETHODIMP CVobSubFileRipper::LoadParamFile(CString fn)
{
- CAutoLock cAutoLock(&m_csAccessLock);
-
- m_rd.Reset();
-
- CStdioFile f;
- if (!f.Open(fn, CFile::modeRead|CFile::typeText)) {
- return E_FAIL;
- }
-
- TCHAR langid[256];
-
- enum {P_INPUT, P_OUTPUT, P_PGC, P_ANGLE, P_LANGS, P_OPTIONS};
- int phase = P_INPUT;
-
- CString line;
- while (f.ReadString(line)) {
- if (line.Trim().IsEmpty() || line[0] == '#') {
- continue;
- }
-
- if (phase == P_INPUT) {
- if (S_OK != SetInput(line)) {
- break;
- }
- phase = P_OUTPUT;
- } else if (phase == P_OUTPUT) {
- if (S_OK != SetOutput(line)) {
- break;
- }
- phase = P_PGC;
- } else if (phase == P_PGC) {
- m_rd.iSelPGC = _tcstol(line, NULL, 10)-1;
- if (m_rd.iSelPGC < 0 || (size_t)m_rd.iSelPGC >= m_rd.pgcs.GetCount()) {
- break;
- }
- phase = P_ANGLE;
- } else if (phase == 3) {
- PGC& pgc = m_rd.pgcs[m_rd.iSelPGC];
-
- pgc.iSelAngle = _tcstol(line, NULL, 10);
- if (pgc.iSelAngle < 0 || pgc.iSelAngle > max(1, pgc.nAngles) || pgc.iSelAngle > 9) {
- break;
- }
-
- CAtlArray<vc_t>& angle = pgc.angles[pgc.iSelAngle];
-
- if (line.Find('v') >= 0) {
- int vob = 0, cell = 0;
-
- line += ' ';
-
- TCHAR* s = (LPTSTR)(LPCTSTR)line;
- TCHAR* e = s + line.GetLength();
- while (s < e) {
- if (*s == 'v' || s == e-1) {
- s++;
- if (vob != 0 && cell == 0) {
- for (size_t i = 0; i < angle.GetCount(); i++) {
- if (angle[i].vob == vob) {
- m_rd.selvcs.Add((angle[i].vob<<16)|angle[i].cell);
- }
- }
- }
-
- vob = _tcstol(s, &s, 10);
- cell = 0;
- } else if (*s == 'c' && vob > 0) {
- s++;
- cell = _tcstol(s, &s, 10);
-
- for (size_t i = 0; i < angle.GetCount(); i++) {
- if (angle[i].vob == vob && angle[i].cell == cell) {
- m_rd.selvcs.Add((vob<<16)|cell);
- break;
- }
- }
- } else {
- s++;
- }
- }
- } else {
- for (size_t i = 0; i < angle.GetCount(); i++) {
- m_rd.selvcs.Add((angle[i].vob<<16)|angle[i].cell);
- }
- }
-
- phase = P_LANGS;
- } else if (phase == 4) {
- if (!line.CompareNoCase(_T("ALL"))) {
- for (BYTE i = 0; i < 32; i++) {
- m_rd.selids[i] = true;
- }
- m_rd.fClosedCaption = true;
- phase = P_OPTIONS;
- } else {
- line += ' ';
-
- while (line.GetLength() > 0) {
- int n = line.Find(_T(" "));
-
- CString lang = line.Left(n);
-
- line = line.Mid(n);
- line.TrimLeft();
-
- n = 0;
-
- int langnum;
-
- if (_istdigit(lang[0])) {
- n = _stscanf_s(lang, _T("%d"), &langnum);
- if (n != 1) {
- break;
- }
-
- m_rd.selids[langnum] = true;
- } else if (_istalpha(lang[0])) {
- n = _stscanf_s(lang, _T("%s"), langid, _countof(langid));
- if (n != 1) {
- break;
- }
-
- int id = (langid[0] << 8) + langid[1];
-
- if (id == 'cc') {
- m_rd.fClosedCaption = true;
- } else {
- m_rd.selids[id] = true;
- }
- } else {
- break;
- }
-
- if (n != 1) {
- break;
- }
- }
-
- if ((m_rd.selids.GetCount() > 0 || m_rd.fClosedCaption) && line.IsEmpty()) {
- phase = P_OPTIONS;
- }
- }
- } else if (phase == 5 && !line.CompareNoCase(_T("CLOSE"))) {
- m_rd.fClose = true;
- } else if (phase == 5 && !line.CompareNoCase(_T("BEEP"))) {
- m_rd.fBeep = true;
- } else if (phase == 5 && !line.CompareNoCase(_T("RESETTIME"))) {
- m_rd.fResetTime = true;
- } else if (phase == 5 && !line.CompareNoCase(_T("FORCEDONLY"))) {
- m_rd.fForcedOnly = true;
- } else if (phase == 5 && !line.CompareNoCase(_T("CLOSEIGNOREERRORS"))) {
- m_rd.fCloseIgnoreError = true;
- }
-
- }
-
- m_rd.fAuto = true;
-
- return phase == P_OPTIONS ? S_OK : E_FAIL;
+ CAutoLock cAutoLock(&m_csAccessLock);
+
+ m_rd.Reset();
+
+ CStdioFile f;
+ if (!f.Open(fn, CFile::modeRead | CFile::typeText)) {
+ return E_FAIL;
+ }
+
+ TCHAR langid[256];
+
+ enum {P_INPUT, P_OUTPUT, P_PGC, P_ANGLE, P_LANGS, P_OPTIONS};
+ int phase = P_INPUT;
+
+ CString line;
+ while (f.ReadString(line)) {
+ if (line.Trim().IsEmpty() || line[0] == '#') {
+ continue;
+ }
+
+ if (phase == P_INPUT) {
+ if (S_OK != SetInput(line)) {
+ break;
+ }
+ phase = P_OUTPUT;
+ } else if (phase == P_OUTPUT) {
+ if (S_OK != SetOutput(line)) {
+ break;
+ }
+ phase = P_PGC;
+ } else if (phase == P_PGC) {
+ m_rd.iSelPGC = _tcstol(line, NULL, 10) - 1;
+ if (m_rd.iSelPGC < 0 || (size_t)m_rd.iSelPGC >= m_rd.pgcs.GetCount()) {
+ break;
+ }
+ phase = P_ANGLE;
+ } else if (phase == 3) {
+ PGC& pgc = m_rd.pgcs[m_rd.iSelPGC];
+
+ pgc.iSelAngle = _tcstol(line, NULL, 10);
+ if (pgc.iSelAngle < 0 || pgc.iSelAngle > max(1, pgc.nAngles) || pgc.iSelAngle > 9) {
+ break;
+ }
+
+ CAtlArray<vc_t>& angle = pgc.angles[pgc.iSelAngle];
+
+ if (line.Find('v') >= 0) {
+ int vob = 0, cell = 0;
+
+ line += ' ';
+
+ TCHAR* s = (LPTSTR)(LPCTSTR)line;
+ TCHAR* e = s + line.GetLength();
+ while (s < e) {
+ if (*s == 'v' || s == e - 1) {
+ s++;
+ if (vob != 0 && cell == 0) {
+ for (size_t i = 0; i < angle.GetCount(); i++) {
+ if (angle[i].vob == vob) {
+ m_rd.selvcs.Add((angle[i].vob << 16) | angle[i].cell);
+ }
+ }
+ }
+
+ vob = _tcstol(s, &s, 10);
+ cell = 0;
+ } else if (*s == 'c' && vob > 0) {
+ s++;
+ cell = _tcstol(s, &s, 10);
+
+ for (size_t i = 0; i < angle.GetCount(); i++) {
+ if (angle[i].vob == vob && angle[i].cell == cell) {
+ m_rd.selvcs.Add((vob << 16) | cell);
+ break;
+ }
+ }
+ } else {
+ s++;
+ }
+ }
+ } else {
+ for (size_t i = 0; i < angle.GetCount(); i++) {
+ m_rd.selvcs.Add((angle[i].vob << 16) | angle[i].cell);
+ }
+ }
+
+ phase = P_LANGS;
+ } else if (phase == 4) {
+ if (!line.CompareNoCase(_T("ALL"))) {
+ for (BYTE i = 0; i < 32; i++) {
+ m_rd.selids[i] = true;
+ }
+ m_rd.fClosedCaption = true;
+ phase = P_OPTIONS;
+ } else {
+ line += ' ';
+
+ while (line.GetLength() > 0) {
+ int n = line.Find(_T(" "));
+
+ CString lang = line.Left(n);
+
+ line = line.Mid(n);
+ line.TrimLeft();
+
+ n = 0;
+
+ int langnum;
+
+ if (_istdigit(lang[0])) {
+ n = _stscanf_s(lang, _T("%d"), &langnum);
+ if (n != 1) {
+ break;
+ }
+
+ m_rd.selids[langnum] = true;
+ } else if (_istalpha(lang[0])) {
+ n = _stscanf_s(lang, _T("%s"), langid, _countof(langid));
+ if (n != 1) {
+ break;
+ }
+
+ int id = (langid[0] << 8) + langid[1];
+
+ if (id == 'cc') {
+ m_rd.fClosedCaption = true;
+ } else {
+ m_rd.selids[id] = true;
+ }
+ } else {
+ break;
+ }
+
+ if (n != 1) {
+ break;
+ }
+ }
+
+ if ((m_rd.selids.GetCount() > 0 || m_rd.fClosedCaption) && line.IsEmpty()) {
+ phase = P_OPTIONS;
+ }
+ }
+ } else if (phase == 5 && !line.CompareNoCase(_T("CLOSE"))) {
+ m_rd.fClose = true;
+ } else if (phase == 5 && !line.CompareNoCase(_T("BEEP"))) {
+ m_rd.fBeep = true;
+ } else if (phase == 5 && !line.CompareNoCase(_T("RESETTIME"))) {
+ m_rd.fResetTime = true;
+ } else if (phase == 5 && !line.CompareNoCase(_T("FORCEDONLY"))) {
+ m_rd.fForcedOnly = true;
+ } else if (phase == 5 && !line.CompareNoCase(_T("CLOSEIGNOREERRORS"))) {
+ m_rd.fCloseIgnoreError = true;
+ }
+
+ }
+
+ m_rd.fAuto = true;
+
+ return phase == P_OPTIONS ? S_OK : E_FAIL;
}
STDMETHODIMP CVobSubFileRipper::SetInput(CString infn)
{
- CAutoLock cAutoLock(&m_csAccessLock);
+ CAutoLock cAutoLock(&m_csAccessLock);
- m_rd.Reset();
+ m_rd.Reset();
- if (!LoadIfo(infn) || !LoadVob(infn)) {
- return E_INVALIDARG;
- }
+ if (!LoadIfo(infn) || !LoadVob(infn)) {
+ return E_INVALIDARG;
+ }
- m_infn = infn;
+ m_infn = infn;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CVobSubFileRipper::SetOutput(CString outfn)
{
- CAutoLock cAutoLock(&m_csAccessLock);
- m_outfn = outfn;
- return S_OK;
+ CAutoLock cAutoLock(&m_csAccessLock);
+ m_outfn = outfn;
+ return S_OK;
}
STDMETHODIMP CVobSubFileRipper::GetRipperData(VSFRipperData& rd)
{
- CAutoLock cAutoLock(&m_csAccessLock);
- rd.Copy(m_rd);
- return S_OK;
+ CAutoLock cAutoLock(&m_csAccessLock);
+ rd.Copy(m_rd);
+ return S_OK;
}
STDMETHODIMP CVobSubFileRipper::UpdateRipperData(VSFRipperData& rd)
{
- CAutoLock cAutoLock(&m_csAccessLock);
- m_rd.Copy(rd);
- return S_OK;
+ CAutoLock cAutoLock(&m_csAccessLock);
+ m_rd.Copy(rd);
+ return S_OK;
}
STDMETHODIMP CVobSubFileRipper::Index()
{
- if (m_fIndexing) {
- return E_FAIL;
- }
- CAMThread::CallWorker(CMD_INDEX);
- return S_OK;
+ if (m_fIndexing) {
+ return E_FAIL;
+ }
+ CAMThread::CallWorker(CMD_INDEX);
+ return S_OK;
}
STDMETHODIMP CVobSubFileRipper::IsIndexing()
{
- return m_fIndexing ? S_OK : S_FALSE;
+ return m_fIndexing ? S_OK : S_FALSE;
}
STDMETHODIMP CVobSubFileRipper::Abort(bool fSavePartial)
{
- m_fBreakThread = true;
- return S_OK;
+ m_fBreakThread = true;
+ return S_OK;
}
//
void VSFRipperData::Reset()
{
- vidsize.SetSize(0,0);
- memset(&vidinfo, 0, sizeof(vidinfo));
- pgcs.RemoveAll();
- iSelPGC = -1;
- fResetTime = fClosedCaption = true;
- fForcedOnly = false;
- fClose = fBeep = fAuto = false;
- fCloseIgnoreError = false;
-
- selvcs.RemoveAll();
- selids.RemoveAll();
+ vidsize.SetSize(0, 0);
+ memset(&vidinfo, 0, sizeof(vidinfo));
+ pgcs.RemoveAll();
+ iSelPGC = -1;
+ fResetTime = fClosedCaption = true;
+ fForcedOnly = false;
+ fClose = fBeep = fAuto = false;
+ fCloseIgnoreError = false;
+
+ selvcs.RemoveAll();
+ selids.RemoveAll();
}
void VSFRipperData::Copy(VSFRipperData& rd)
{
- Reset();
-
- vidsize = rd.vidsize;
- vidinfo = rd.vidinfo;
- if (size_t len = rd.pgcs.GetCount()) {
- pgcs.SetCount(len);
- for (size_t i = 0; i < len; i++) {
- PGC& src = rd.pgcs[i];
- PGC& dst = pgcs[i];
- dst.nAngles = src.nAngles;
- for (size_t j = 0; j < _countof(dst.angles); j++) {
- dst.angles[j].Copy(src.angles[j]);
- }
- dst.iSelAngle = src.iSelAngle;
- memcpy(dst.pal, src.pal, sizeof(src.pal));
- memcpy(dst.ids, src.ids, sizeof(src.ids));
- }
- }
- iSelPGC = rd.iSelPGC;
- fResetTime = rd.fResetTime;
- fClosedCaption = rd.fClosedCaption;
- fForcedOnly = rd.fForcedOnly;
- fClose = rd.fClose;
- fBeep = rd.fBeep;
- fAuto = rd.fAuto;
- fCloseIgnoreError = rd.fCloseIgnoreError;
- selvcs.Copy(rd.selvcs);
- POSITION pos = rd.selids.GetStartPosition();
- while (pos) {
- BYTE key;
- bool val;
- rd.selids.GetNextAssoc(pos, key, val);
- selids[key] = val;
- }
+ Reset();
+
+ vidsize = rd.vidsize;
+ vidinfo = rd.vidinfo;
+ if (size_t len = rd.pgcs.GetCount()) {
+ pgcs.SetCount(len);
+ for (size_t i = 0; i < len; i++) {
+ PGC& src = rd.pgcs[i];
+ PGC& dst = pgcs[i];
+ dst.nAngles = src.nAngles;
+ for (size_t j = 0; j < _countof(dst.angles); j++) {
+ dst.angles[j].Copy(src.angles[j]);
+ }
+ dst.iSelAngle = src.iSelAngle;
+ memcpy(dst.pal, src.pal, sizeof(src.pal));
+ memcpy(dst.ids, src.ids, sizeof(src.ids));
+ }
+ }
+ iSelPGC = rd.iSelPGC;
+ fResetTime = rd.fResetTime;
+ fClosedCaption = rd.fClosedCaption;
+ fForcedOnly = rd.fForcedOnly;
+ fClose = rd.fClose;
+ fBeep = rd.fBeep;
+ fAuto = rd.fAuto;
+ fCloseIgnoreError = rd.fCloseIgnoreError;
+ selvcs.Copy(rd.selvcs);
+ POSITION pos = rd.selids.GetStartPosition();
+ while (pos) {
+ BYTE key;
+ bool val;
+ rd.selids.GetNextAssoc(pos, key, val);
+ selids[key] = val;
+ }
}
diff --git a/src/Subtitles/VobSubFileRipper.h b/src/Subtitles/VobSubFileRipper.h
index 7a09ab810..6bc1723e7 100644
--- a/src/Subtitles/VobSubFileRipper.h
+++ b/src/Subtitles/VobSubFileRipper.h
@@ -31,55 +31,55 @@
#pragma pack(1)
typedef struct {
- WORD perm_displ : 2;
- WORD ratio : 2;
- WORD system : 2;
- WORD compression : 2;
- WORD mode : 1;
- WORD letterboxed : 1;
- WORD source_res : 2;
- WORD cbrvbr : 2;
- WORD line21_2 : 1;
- WORD line21_1 : 1;
+ WORD perm_displ : 2;
+ WORD ratio : 2;
+ WORD system : 2;
+ WORD compression : 2;
+ WORD mode : 1;
+ WORD letterboxed : 1;
+ WORD source_res : 2;
+ WORD cbrvbr : 2;
+ WORD line21_2 : 1;
+ WORD line21_1 : 1;
} vidinfo;
typedef struct {
- BYTE vob, cell;
- DWORD tTime, tOffset, tTotal;
- DWORD start, end;
- int iAngle;
- bool fDiscontinuity;
+ BYTE vob, cell;
+ DWORD tTime, tOffset, tTotal;
+ DWORD start, end;
+ int iAngle;
+ bool fDiscontinuity;
} vc_t;
typedef struct {
- int nAngles;
- CAtlArray<vc_t> angles[10];
- int iSelAngle;
- RGBQUAD pal[16];
- WORD ids[32];
+ int nAngles;
+ CAtlArray<vc_t> angles[10];
+ int iSelAngle;
+ RGBQUAD pal[16];
+ WORD ids[32];
} PGC;
typedef struct VSFRipperData_t {
- CSize vidsize;
- vidinfo vidinfo;
- CAtlArray<PGC> pgcs;
- int iSelPGC;
- bool fResetTime, fClosedCaption, fForcedOnly;
+ CSize vidsize;
+ vidinfo vidinfo;
+ CAtlArray<PGC> pgcs;
+ int iSelPGC;
+ bool fResetTime, fClosedCaption, fForcedOnly;
- bool fClose, fBeep, fAuto; // only used by the UI externally, but may be set through the parameter file
- bool fCloseIgnoreError;
+ bool fClose, fBeep, fAuto; // only used by the UI externally, but may be set through the parameter file
+ bool fCloseIgnoreError;
- CAtlArray<UINT> selvcs;
- CAtlMap<BYTE, bool> selids;
+ CAtlArray<UINT> selvcs;
+ CAtlMap<BYTE, bool> selids;
- void Reset();
- void Copy(struct VSFRipperData_t& rd);
+ void Reset();
+ void Copy(struct VSFRipperData_t& rd);
} VSFRipperData;
typedef struct {
- __int64 start, end;
- DWORD vc;
+ __int64 start, end;
+ DWORD vc;
} vcchunk;
#pragma pack(pop)
@@ -93,9 +93,9 @@ typedef struct {
interface __declspec(uuid("9E2EBB5C-AD7C-452f-A48B-38685716AC46"))
IVSFRipperCallback :
public IUnknown {
- STDMETHOD (OnMessage) (LPCTSTR msg) PURE;
- STDMETHOD (OnProgress) (double progress /*0->1*/) PURE;
- STDMETHOD (OnFinished) (bool fSucceeded) PURE;
+ STDMETHOD(OnMessage)(LPCTSTR msg) PURE;
+ STDMETHOD(OnProgress)(double progress /*0->1*/) PURE;
+ STDMETHOD(OnFinished)(bool fSucceeded) PURE;
};
// IVSFRipperCallbackImpl
@@ -107,26 +107,20 @@ public IUnknown {
class IVSFRipperCallbackImpl : public CUnknown, public IVSFRipperCallback
{
protected:
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
- return
- QI(IVSFRipperCallback)
- __super::NonDelegatingQueryInterface(riid, ppv);
- }
-
- // IVSFRipperCallback
- STDMETHODIMP OnMessage(LPCTSTR msg) {
- return S_FALSE;
- }
- STDMETHODIMP OnProgress(double progress /*0->1*/) {
- return S_FALSE;
- }
- STDMETHODIMP OnFinished(bool fSucceeded) {
- return S_FALSE;
- }
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
+ return
+ QI(IVSFRipperCallback)
+ __super::NonDelegatingQueryInterface(riid, ppv);
+ }
+
+ // IVSFRipperCallback
+ STDMETHODIMP OnMessage(LPCTSTR msg) { return S_FALSE; }
+ STDMETHODIMP OnProgress(double progress /*0->1*/) { return S_FALSE; }
+ STDMETHODIMP OnFinished(bool fSucceeded) { return S_FALSE; }
public:
- IVSFRipperCallbackImpl() : CUnknown(NAME("IVSFRipperCallbackImpl"), NULL) {}
+ IVSFRipperCallbackImpl() : CUnknown(NAME("IVSFRipperCallbackImpl"), NULL) {}
};
//
@@ -136,64 +130,64 @@ public:
interface __declspec(uuid("69F935BB-B8D0-43f5-AA2E-BBD0851CC9A6"))
IVSFRipper :
public IUnknown {
- STDMETHOD (SetCallBack) (IVSFRipperCallback* pCallback) PURE;
- STDMETHOD (LoadParamFile) (CString fn) PURE;
- STDMETHOD (SetInput) (CString infn) PURE;
- STDMETHOD (SetOutput) (CString outfn) PURE;
- STDMETHOD (GetRipperData) (VSFRipperData& rd) PURE;
- STDMETHOD (UpdateRipperData) (VSFRipperData& rd) PURE;
- STDMETHOD (Index) () PURE;
- STDMETHOD (IsIndexing) () PURE;
- STDMETHOD (Abort) (bool fSavePartial) PURE;
+ STDMETHOD(SetCallBack)(IVSFRipperCallback * pCallback) PURE;
+ STDMETHOD(LoadParamFile)(CString fn) PURE;
+ STDMETHOD(SetInput)(CString infn) PURE;
+ STDMETHOD(SetOutput)(CString outfn) PURE;
+ STDMETHOD(GetRipperData)(VSFRipperData & rd) PURE;
+ STDMETHOD(UpdateRipperData)(VSFRipperData & rd) PURE;
+ STDMETHOD(Index)() PURE;
+ STDMETHOD(IsIndexing)() PURE;
+ STDMETHOD(Abort)(bool fSavePartial) PURE;
};
class CVobSubFileRipper : public CVobSubFile, protected CAMThread, public IVSFRipper
{
private:
- bool m_fThreadActive, m_fBreakThread, m_fIndexing;
- enum {CMD_EXIT, CMD_INDEX};
- DWORD ThreadProc();
- bool Create();
+ bool m_fThreadActive, m_fBreakThread, m_fIndexing;
+ enum {CMD_EXIT, CMD_INDEX};
+ DWORD ThreadProc();
+ bool Create();
- //
+ //
- typedef enum {LOG_INFO, LOG_WARNING, LOG_ERROR} log_t;
- void Log(log_t type, LPCTSTR lpszFormat, ...);
- void Progress(double progress);
- void Finished(bool fSucceeded);
+ typedef enum {LOG_INFO, LOG_WARNING, LOG_ERROR} log_t;
+ void Log(log_t type, LPCTSTR lpszFormat, ...);
+ void Progress(double progress);
+ void Finished(bool fSucceeded);
- //
+ //
- CCritSec m_csAccessLock;
- CString m_infn, m_outfn;
- CVobFile m_vob;
- VSFRipperData m_rd;
+ CCritSec m_csAccessLock;
+ CString m_infn, m_outfn;
+ CVobFile m_vob;
+ VSFRipperData m_rd;
- bool LoadIfo(CString fn);
- bool LoadVob(CString fn);
- bool LoadChunks(CAtlArray<vcchunk>& chunks);
- bool SaveChunks(CAtlArray<vcchunk>& chunks);
+ bool LoadIfo(CString fn);
+ bool LoadVob(CString fn);
+ bool LoadChunks(CAtlArray<vcchunk>& chunks);
+ bool SaveChunks(CAtlArray<vcchunk>& chunks);
- //
+ //
- CCritSec m_csCallback;
- CComPtr<IVSFRipperCallback> m_pCallback;
+ CCritSec m_csCallback;
+ CComPtr<IVSFRipperCallback> m_pCallback;
public:
- CVobSubFileRipper();
- virtual ~CVobSubFileRipper();
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // IVSFRipper
- STDMETHODIMP SetCallBack(IVSFRipperCallback* pCallback);
- STDMETHODIMP LoadParamFile(CString fn);
- STDMETHODIMP SetInput(CString infn);
- STDMETHODIMP SetOutput(CString outfn);
- STDMETHODIMP GetRipperData(VSFRipperData& rd);
- STDMETHODIMP UpdateRipperData(VSFRipperData& rd);
- STDMETHODIMP Index();
- STDMETHODIMP IsIndexing();
- STDMETHODIMP Abort(bool fSavePartial);
+ CVobSubFileRipper();
+ virtual ~CVobSubFileRipper();
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ // IVSFRipper
+ STDMETHODIMP SetCallBack(IVSFRipperCallback* pCallback);
+ STDMETHODIMP LoadParamFile(CString fn);
+ STDMETHODIMP SetInput(CString infn);
+ STDMETHODIMP SetOutput(CString outfn);
+ STDMETHODIMP GetRipperData(VSFRipperData& rd);
+ STDMETHODIMP UpdateRipperData(VSFRipperData& rd);
+ STDMETHODIMP Index();
+ STDMETHODIMP IsIndexing();
+ STDMETHODIMP Abort(bool fSavePartial);
};
diff --git a/src/Subtitles/VobSubImage.cpp b/src/Subtitles/VobSubImage.cpp
index 068cb07c7..d664e943a 100644
--- a/src/Subtitles/VobSubImage.cpp
+++ b/src/Subtitles/VobSubImage.cpp
@@ -28,331 +28,331 @@
CVobSubImage::CVobSubImage()
{
- iLang = iIdx = -1;
- fForced = false;
- start = delay = 0;
- rect = CRect(0,0,0,0);
- lpPixels = lpTemp1 = lpTemp2 = NULL;
- org = CSize(0,0);
+ iLang = iIdx = -1;
+ fForced = false;
+ start = delay = 0;
+ rect = CRect(0, 0, 0, 0);
+ lpPixels = lpTemp1 = lpTemp2 = NULL;
+ org = CSize(0, 0);
}
CVobSubImage::~CVobSubImage()
{
- Free();
+ Free();
}
bool CVobSubImage::Alloc(int w, int h)
{
- // if there is nothing to crop TrimSubImage might even add a 1 pixel
- // wide border around the text, that's why we need a bit more memory
- // to be allocated.
+ // if there is nothing to crop TrimSubImage might even add a 1 pixel
+ // wide border around the text, that's why we need a bit more memory
+ // to be allocated.
- if (lpTemp1 == NULL || w*h > org.cx*org.cy || (w+2)*(h+2) > (org.cx+2)*(org.cy+2)) {
- Free();
+ if (lpTemp1 == NULL || w * h > org.cx * org.cy || (w + 2) * (h + 2) > (org.cx + 2) * (org.cy + 2)) {
+ Free();
- lpTemp1 = DNew RGBQUAD[w*h];
- if (!lpTemp1) {
- return false;
- }
+ lpTemp1 = DNew RGBQUAD[w * h];
+ if (!lpTemp1) {
+ return false;
+ }
- lpTemp2 = DNew RGBQUAD[(w+2)*(h+2)];
- if (!lpTemp2) {
- delete [] lpTemp1;
- lpTemp1 = NULL;
- return false;
- }
+ lpTemp2 = DNew RGBQUAD[(w + 2) * (h + 2)];
+ if (!lpTemp2) {
+ delete [] lpTemp1;
+ lpTemp1 = NULL;
+ return false;
+ }
- org.cx = w;
- org.cy = h;
- }
+ org.cx = w;
+ org.cy = h;
+ }
- lpPixels = lpTemp1;
+ lpPixels = lpTemp1;
- return true;
+ return true;
}
void CVobSubImage::Free()
{
- if (lpTemp1) {
- delete [] lpTemp1;
- }
- lpTemp1 = NULL;
+ if (lpTemp1) {
+ delete [] lpTemp1;
+ }
+ lpTemp1 = NULL;
- if (lpTemp2) {
- delete [] lpTemp2;
- }
- lpTemp2 = NULL;
+ if (lpTemp2) {
+ delete [] lpTemp2;
+ }
+ lpTemp2 = NULL;
- lpPixels = NULL;
+ lpPixels = NULL;
}
bool CVobSubImage::Decode(BYTE* lpData, int packetsize, int datasize,
- bool fCustomPal,
- int tridx,
- RGBQUAD* orgpal /*[16]*/, RGBQUAD* cuspal /*[4]*/,
- bool fTrim)
+ bool fCustomPal,
+ int tridx,
+ RGBQUAD* orgpal /*[16]*/, RGBQUAD* cuspal /*[4]*/,
+ bool fTrim)
{
- GetPacketInfo(lpData, packetsize, datasize);
+ GetPacketInfo(lpData, packetsize, datasize);
- if (!Alloc(rect.Width(), rect.Height())) {
- return false;
- }
+ if (!Alloc(rect.Width(), rect.Height())) {
+ return false;
+ }
- lpPixels = lpTemp1;
+ lpPixels = lpTemp1;
- nPlane = 0;
- fAligned = 1;
+ nPlane = 0;
+ fAligned = 1;
- this->fCustomPal = fCustomPal;
- this->orgpal = orgpal;
- this->tridx = tridx;
- this->cuspal = cuspal;
+ this->fCustomPal = fCustomPal;
+ this->orgpal = orgpal;
+ this->tridx = tridx;
+ this->cuspal = cuspal;
- CPoint p(rect.left, rect.top);
+ CPoint p(rect.left, rect.top);
- int end0 = nOffset[1];
- int end1 = datasize;
+ int end0 = nOffset[1];
+ int end1 = datasize;
- while ((nPlane == 0 && nOffset[0] < end0) || (nPlane == 1 && nOffset[1] < end1)) {
- DWORD code;
+ while ((nPlane == 0 && nOffset[0] < end0) || (nPlane == 1 && nOffset[1] < end1)) {
+ DWORD code;
- if ((code = GetNibble(lpData)) >= 0x4
- || (code = (code << 4) | GetNibble(lpData)) >= 0x10
- || (code = (code << 4) | GetNibble(lpData)) >= 0x40
- || (code = (code << 4) | GetNibble(lpData)) >= 0x100) {
- DrawPixels(p, code >> 2, code & 3);
- if ((p.x += code >> 2) < rect.right) {
- continue;
- }
- }
+ if ((code = GetNibble(lpData)) >= 0x4
+ || (code = (code << 4) | GetNibble(lpData)) >= 0x10
+ || (code = (code << 4) | GetNibble(lpData)) >= 0x40
+ || (code = (code << 4) | GetNibble(lpData)) >= 0x100) {
+ DrawPixels(p, code >> 2, code & 3);
+ if ((p.x += code >> 2) < rect.right) {
+ continue;
+ }
+ }
- DrawPixels(p, rect.right - p.x, code & 3);
+ DrawPixels(p, rect.right - p.x, code & 3);
- if (!fAligned) {
- GetNibble(lpData); // align to byte
- }
+ if (!fAligned) {
+ GetNibble(lpData); // align to byte
+ }
- p.x = rect.left;
- p.y++;
- nPlane = 1 - nPlane;
- }
+ p.x = rect.left;
+ p.y++;
+ nPlane = 1 - nPlane;
+ }
- rect.bottom = min(p.y, rect.bottom);
+ rect.bottom = min(p.y, rect.bottom);
- if (fTrim) {
- TrimSubImage();
- }
+ if (fTrim) {
+ TrimSubImage();
+ }
- return true;
+ return true;
}
void CVobSubImage::GetPacketInfo(BYTE* lpData, int packetsize, int datasize)
{
- // delay = 0;
-
- int i, nextctrlblk = datasize;
- WORD pal = 0, tr = 0;
-
- do {
- i = nextctrlblk;
-
- int t = (lpData[i] << 8) | lpData[i+1];
- i += 2;
- nextctrlblk = (lpData[i] << 8) | lpData[i+1];
- i += 2;
-
- if (nextctrlblk > packetsize || nextctrlblk < datasize) {
- ASSERT(0);
- return;
- }
-
- bool fBreak = false;
-
- while (!fBreak) {
- int len = 0;
-
- switch (lpData[i]) {
- case 0x00:
- len = 0;
- break;
- case 0x01:
- len = 0;
- break;
- case 0x02:
- len = 0;
- break;
- case 0x03:
- len = 2;
- break;
- case 0x04:
- len = 2;
- break;
- case 0x05:
- len = 6;
- break;
- case 0x06:
- len = 4;
- break;
- default:
- len = 0;
- break;
- }
-
- if (i+len >= packetsize) {
- TRACE(_T("Warning: Wrong subpicture parameter block ending\n"));
- break;
- }
-
- switch (lpData[i++]) {
- case 0x00: // forced start displaying
- fForced = true;
- break;
- case 0x01: // start displaying
- fForced = false;
- break;
- case 0x02: // stop displaying
- delay = 1024 * t / 90;
- break;
- case 0x03:
- pal = (lpData[i] << 8) | lpData[i+1];
- i += 2;
- break;
- case 0x04:
- tr = (lpData[i] << 8) | lpData[i+1];
- i += 2;
- //tr &= 0x00f0;
- break;
- case 0x05:
- rect = CRect((lpData[i] << 4) + (lpData[i+1] >> 4),
- (lpData[i+3] << 4) + (lpData[i+4] >> 4),
- ((lpData[i+1] & 0x0f) << 8) + lpData[i+2] + 1,
- ((lpData[i+4] & 0x0f) << 8) + lpData[i+5] + 1);
- i += 6;
- break;
- case 0x06:
- nOffset[0] = (lpData[i] << 8) + lpData[i+1];
- i += 2;
- nOffset[1] = (lpData[i] << 8) + lpData[i+1];
- i += 2;
- break;
- case 0xff: // end of ctrlblk
- fBreak = true;
- continue;
- default: // skip this ctrlblk
- fBreak = true;
- break;
- }
- }
- } while (i <= nextctrlblk && i < packetsize);
-
- for (i = 0; i < 4; i++) {
- this->pal[i].pal = (pal >> (i << 2)) & 0xf;
- this->pal[i].tr = (tr >> (i << 2)) & 0xf;
- }
+ // delay = 0;
+
+ int i, nextctrlblk = datasize;
+ WORD pal = 0, tr = 0;
+
+ do {
+ i = nextctrlblk;
+
+ int t = (lpData[i] << 8) | lpData[i + 1];
+ i += 2;
+ nextctrlblk = (lpData[i] << 8) | lpData[i + 1];
+ i += 2;
+
+ if (nextctrlblk > packetsize || nextctrlblk < datasize) {
+ ASSERT(0);
+ return;
+ }
+
+ bool fBreak = false;
+
+ while (!fBreak) {
+ int len = 0;
+
+ switch (lpData[i]) {
+ case 0x00:
+ len = 0;
+ break;
+ case 0x01:
+ len = 0;
+ break;
+ case 0x02:
+ len = 0;
+ break;
+ case 0x03:
+ len = 2;
+ break;
+ case 0x04:
+ len = 2;
+ break;
+ case 0x05:
+ len = 6;
+ break;
+ case 0x06:
+ len = 4;
+ break;
+ default:
+ len = 0;
+ break;
+ }
+
+ if (i + len >= packetsize) {
+ TRACE(_T("Warning: Wrong subpicture parameter block ending\n"));
+ break;
+ }
+
+ switch (lpData[i++]) {
+ case 0x00: // forced start displaying
+ fForced = true;
+ break;
+ case 0x01: // start displaying
+ fForced = false;
+ break;
+ case 0x02: // stop displaying
+ delay = 1024 * t / 90;
+ break;
+ case 0x03:
+ pal = (lpData[i] << 8) | lpData[i + 1];
+ i += 2;
+ break;
+ case 0x04:
+ tr = (lpData[i] << 8) | lpData[i + 1];
+ i += 2;
+ //tr &= 0x00f0;
+ break;
+ case 0x05:
+ rect = CRect((lpData[i] << 4) + (lpData[i + 1] >> 4),
+ (lpData[i + 3] << 4) + (lpData[i + 4] >> 4),
+ ((lpData[i + 1] & 0x0f) << 8) + lpData[i + 2] + 1,
+ ((lpData[i + 4] & 0x0f) << 8) + lpData[i + 5] + 1);
+ i += 6;
+ break;
+ case 0x06:
+ nOffset[0] = (lpData[i] << 8) + lpData[i + 1];
+ i += 2;
+ nOffset[1] = (lpData[i] << 8) + lpData[i + 1];
+ i += 2;
+ break;
+ case 0xff: // end of ctrlblk
+ fBreak = true;
+ continue;
+ default: // skip this ctrlblk
+ fBreak = true;
+ break;
+ }
+ }
+ } while (i <= nextctrlblk && i < packetsize);
+
+ for (i = 0; i < 4; i++) {
+ this->pal[i].pal = (pal >> (i << 2)) & 0xf;
+ this->pal[i].tr = (tr >> (i << 2)) & 0xf;
+ }
}
BYTE CVobSubImage::GetNibble(BYTE* lpData)
{
- WORD& off = nOffset[nPlane];
- BYTE ret = (lpData[off] >> (fAligned << 2)) & 0x0f;
- fAligned = !fAligned;
- off += fAligned;
- return ret;
+ WORD& off = nOffset[nPlane];
+ BYTE ret = (lpData[off] >> (fAligned << 2)) & 0x0f;
+ fAligned = !fAligned;
+ off += fAligned;
+ return ret;
}
void CVobSubImage::DrawPixels(CPoint p, int length, int colorid)
{
- if (length <= 0
- || p.x + length < rect.left
- || p.x >= rect.right
- || p.y < rect.top
- || p.y >= rect.bottom) {
- return;
- }
-
- if (p.x < rect.left) {
- p.x = rect.left;
- }
- if (p.x + length >= rect.right) {
- length = rect.right - p.x;
- }
-
- RGBQUAD* ptr = &lpPixels[rect.Width() * (p.y - rect.top) + (p.x - rect.left)];
-
- RGBQUAD c;
-
- if (!fCustomPal) {
- c = orgpal[pal[colorid].pal];
- c.rgbReserved = (pal[colorid].tr<<4)|pal[colorid].tr;
- } else {
- c = cuspal[colorid];
- }
-
- while (length-- > 0) {
- *ptr++ = c;
- }
+ if (length <= 0
+ || p.x + length < rect.left
+ || p.x >= rect.right
+ || p.y < rect.top
+ || p.y >= rect.bottom) {
+ return;
+ }
+
+ if (p.x < rect.left) {
+ p.x = rect.left;
+ }
+ if (p.x + length >= rect.right) {
+ length = rect.right - p.x;
+ }
+
+ RGBQUAD* ptr = &lpPixels[rect.Width() * (p.y - rect.top) + (p.x - rect.left)];
+
+ RGBQUAD c;
+
+ if (!fCustomPal) {
+ c = orgpal[pal[colorid].pal];
+ c.rgbReserved = (pal[colorid].tr << 4) | pal[colorid].tr;
+ } else {
+ c = cuspal[colorid];
+ }
+
+ while (length-- > 0) {
+ *ptr++ = c;
+ }
}
void CVobSubImage::TrimSubImage()
{
- CRect r;
- r.left = rect.Width();
- r.top = rect.Height();
- r.right = 0;
- r.bottom = 0;
+ CRect r;
+ r.left = rect.Width();
+ r.top = rect.Height();
+ r.right = 0;
+ r.bottom = 0;
- RGBQUAD* ptr = lpTemp1;
+ RGBQUAD* ptr = lpTemp1;
- for (int j = 0, y = rect.Height(); j < y; j++) {
- for (int i = 0, x = rect.Width(); i < x; i++, ptr++) {
- if (ptr->rgbReserved) {
- if (r.top > j) {
- r.top = j;
- }
- if (r.bottom < j) {
- r.bottom = j;
- }
- if (r.left > i) {
- r.left = i;
- }
- if (r.right < i) {
- r.right = i;
- }
- }
- }
- }
+ for (int j = 0, y = rect.Height(); j < y; j++) {
+ for (int i = 0, x = rect.Width(); i < x; i++, ptr++) {
+ if (ptr->rgbReserved) {
+ if (r.top > j) {
+ r.top = j;
+ }
+ if (r.bottom < j) {
+ r.bottom = j;
+ }
+ if (r.left > i) {
+ r.left = i;
+ }
+ if (r.right < i) {
+ r.right = i;
+ }
+ }
+ }
+ }
- if (r.left > r.right || r.top > r.bottom) {
- return;
- }
+ if (r.left > r.right || r.top > r.bottom) {
+ return;
+ }
- r += CRect(0, 0, 1, 1);
+ r += CRect(0, 0, 1, 1);
- r &= CRect(CPoint(0,0), rect.Size());
+ r &= CRect(CPoint(0, 0), rect.Size());
- int w = r.Width(), h = r.Height();
+ int w = r.Width(), h = r.Height();
- DWORD offset = r.top*rect.Width() + r.left;
+ DWORD offset = r.top * rect.Width() + r.left;
- r += CRect(1, 1, 1, 1);
+ r += CRect(1, 1, 1, 1);
- DWORD* src = (DWORD*)&lpTemp1[offset];
- DWORD* dst = (DWORD*)&lpTemp2[1 + w + 1];
+ DWORD* src = (DWORD*)&lpTemp1[offset];
+ DWORD* dst = (DWORD*)&lpTemp2[1 + w + 1];
- memset(lpTemp2, 0, (1 + w + 1)*sizeof(RGBQUAD));
+ memset(lpTemp2, 0, (1 + w + 1)*sizeof(RGBQUAD));
- for (int height = h; height; height--, src += rect.Width()) {
- *dst++ = 0;
- memcpy(dst, src, w*sizeof(RGBQUAD));
- dst += w;
- *dst++ = 0;
- }
+ for (int height = h; height; height--, src += rect.Width()) {
+ *dst++ = 0;
+ memcpy(dst, src, w * sizeof(RGBQUAD));
+ dst += w;
+ *dst++ = 0;
+ }
- memset(dst, 0, (1 + w + 1)*sizeof(RGBQUAD));
+ memset(dst, 0, (1 + w + 1)*sizeof(RGBQUAD));
- lpPixels = lpTemp2;
+ lpPixels = lpTemp2;
- rect = r + rect.TopLeft();
+ rect = r + rect.TopLeft();
}
////////////////////////////////
@@ -361,964 +361,964 @@ void CVobSubImage::TrimSubImage()
CAutoPtrList<COutline>* CVobSubImage::GetOutlineList(CPoint& topleft)
{
- int w = rect.Width(), h = rect.Height(), len = w*h;
- if (len <= 0) {
- return NULL;
- }
-
- CAutoVectorPtr<BYTE> p;
- if (!p.Allocate(len)) {
- return NULL;
- }
-
- CAutoPtrList<COutline>* ol = DNew CAutoPtrList<COutline>();
- if (!ol) {
- return NULL;
- }
-
- BYTE* cp = p;
- RGBQUAD* rgbp = (RGBQUAD*)lpPixels;
-
- for (int i = 0; i < len; i++, cp++, rgbp++) {
- *cp = !!rgbp->rgbReserved;
- }
-
- enum {UP, RIGHT, DOWN, LEFT};
-
- topleft.x = topleft.y = INT_MAX;
-
- for (;;) {
- cp = p;
-
- int x = 0;
- int y = 0;
-
- for (y = 0; y < h; y++) {
- for (x = 0; x < w-1; x++, cp++) {
- if (cp[0] == 0 && cp[1] == 1) {
- break;
- }
- }
-
- if (x < w-1) {
- break;
- }
-
- cp++;
- }
-
- if (y == h) {
- break;
- }
-
- int prevdir, dir = UP;
-
- int ox = x, oy = y, odir = dir;
-
- CAutoPtr<COutline> o(DNew COutline);
- if (!o) {
- break;
- }
-
- do {
- CPoint pp;
- BYTE fl = 0;
- BYTE fr = 0;
- BYTE br = 0;
-
- prevdir = dir;
-
- switch (prevdir) {
- case UP:
- pp = CPoint(x+1, y);
- fl = GP(x, y-1);
- fr = GP(x+1, y-1);
- br = GP(x+1, y);
- break;
- case RIGHT:
- pp = CPoint(x+1, y+1);
- fl = GP(x+1, y);
- fr = GP(x+1, y+1);
- br = GP(x, y+1);
- break;
- case DOWN:
- pp = CPoint(x, y+1);
- fl = GP(x, y+1);
- fr = GP(x-1, y+1);
- br = GP(x-1, y);
- break;
- case LEFT:
- pp = CPoint(x, y);
- fl = GP(x-1, y);
- fr = GP(x-1, y-1);
- br = GP(x, y-1);
- break;
- }
-
- // turning left if:
- // o . | o .
- // ^ o | < o
- // turning right if:
- // x x | x >
- // ^ o | x o
- //
- // o set, x empty, . can be anything
-
- if (fl==1) {
- dir = (dir-1+4)&3;
- } else if (fl!=1 && fr!=1 && br==1) {
- dir = (dir+1)&3;
- } else if (p[y*w+x]&16) {
- ASSERT(0); // we are going around in one place (this must not happen if the starting conditions were correct)
- break;
- }
-
- p[y*w+x] = (p[y*w+x]<<1) | 2; // increase turn count (== log2(highordbit(*p)))
-
- switch (dir) {
- case UP:
- if (prevdir == LEFT) {
- x--;
- y--;
- }
- if (prevdir == UP) {
- y--;
- }
- break;
- case RIGHT:
- if (prevdir == UP) {
- x++;
- y--;
- }
- if (prevdir == RIGHT) {
- x++;
- }
- break;
- case DOWN:
- if (prevdir == RIGHT) {
- x++;
- y++;
- }
- if (prevdir == DOWN) {
- y++;
- }
- break;
- case LEFT:
- if (prevdir == DOWN) {
- x--;
- y++;
- }
- if (prevdir == LEFT) {
- x--;
- }
- break;
- }
-
- int d = dir - prevdir;
- o->Add(pp, d == 3 ? -1 : d == -3 ? 1 : d);
-
- if (topleft.x > pp.x) {
- topleft.x = pp.x;
- }
- if (topleft.y > pp.y) {
- topleft.y = pp.y;
- }
- } while (!(x == ox && y == oy && dir == odir));
-
- if (o->pa.GetCount() > 0 && (x == ox && y == oy && dir == odir)) {
- ol->AddTail(o);
- } else {
- ASSERT(0);
- }
- }
-
- return ol;
+ int w = rect.Width(), h = rect.Height(), len = w * h;
+ if (len <= 0) {
+ return NULL;
+ }
+
+ CAutoVectorPtr<BYTE> p;
+ if (!p.Allocate(len)) {
+ return NULL;
+ }
+
+ CAutoPtrList<COutline>* ol = DNew CAutoPtrList<COutline>();
+ if (!ol) {
+ return NULL;
+ }
+
+ BYTE* cp = p;
+ RGBQUAD* rgbp = (RGBQUAD*)lpPixels;
+
+ for (int i = 0; i < len; i++, cp++, rgbp++) {
+ *cp = !!rgbp->rgbReserved;
+ }
+
+ enum {UP, RIGHT, DOWN, LEFT};
+
+ topleft.x = topleft.y = INT_MAX;
+
+ for (;;) {
+ cp = p;
+
+ int x = 0;
+ int y = 0;
+
+ for (y = 0; y < h; y++) {
+ for (x = 0; x < w - 1; x++, cp++) {
+ if (cp[0] == 0 && cp[1] == 1) {
+ break;
+ }
+ }
+
+ if (x < w - 1) {
+ break;
+ }
+
+ cp++;
+ }
+
+ if (y == h) {
+ break;
+ }
+
+ int prevdir, dir = UP;
+
+ int ox = x, oy = y, odir = dir;
+
+ CAutoPtr<COutline> o(DNew COutline);
+ if (!o) {
+ break;
+ }
+
+ do {
+ CPoint pp;
+ BYTE fl = 0;
+ BYTE fr = 0;
+ BYTE br = 0;
+
+ prevdir = dir;
+
+ switch (prevdir) {
+ case UP:
+ pp = CPoint(x + 1, y);
+ fl = GP(x, y - 1);
+ fr = GP(x + 1, y - 1);
+ br = GP(x + 1, y);
+ break;
+ case RIGHT:
+ pp = CPoint(x + 1, y + 1);
+ fl = GP(x + 1, y);
+ fr = GP(x + 1, y + 1);
+ br = GP(x, y + 1);
+ break;
+ case DOWN:
+ pp = CPoint(x, y + 1);
+ fl = GP(x, y + 1);
+ fr = GP(x - 1, y + 1);
+ br = GP(x - 1, y);
+ break;
+ case LEFT:
+ pp = CPoint(x, y);
+ fl = GP(x - 1, y);
+ fr = GP(x - 1, y - 1);
+ br = GP(x, y - 1);
+ break;
+ }
+
+ // turning left if:
+ // o . | o .
+ // ^ o | < o
+ // turning right if:
+ // x x | x >
+ // ^ o | x o
+ //
+ // o set, x empty, . can be anything
+
+ if (fl == 1) {
+ dir = (dir - 1 + 4) & 3;
+ } else if (fl != 1 && fr != 1 && br == 1) {
+ dir = (dir + 1) & 3;
+ } else if (p[y * w + x] & 16) {
+ ASSERT(0); // we are going around in one place (this must not happen if the starting conditions were correct)
+ break;
+ }
+
+ p[y * w + x] = (p[y * w + x] << 1) | 2; // increase turn count (== log2(highordbit(*p)))
+
+ switch (dir) {
+ case UP:
+ if (prevdir == LEFT) {
+ x--;
+ y--;
+ }
+ if (prevdir == UP) {
+ y--;
+ }
+ break;
+ case RIGHT:
+ if (prevdir == UP) {
+ x++;
+ y--;
+ }
+ if (prevdir == RIGHT) {
+ x++;
+ }
+ break;
+ case DOWN:
+ if (prevdir == RIGHT) {
+ x++;
+ y++;
+ }
+ if (prevdir == DOWN) {
+ y++;
+ }
+ break;
+ case LEFT:
+ if (prevdir == DOWN) {
+ x--;
+ y++;
+ }
+ if (prevdir == LEFT) {
+ x--;
+ }
+ break;
+ }
+
+ int d = dir - prevdir;
+ o->Add(pp, d == 3 ? -1 : d == -3 ? 1 : d);
+
+ if (topleft.x > pp.x) {
+ topleft.x = pp.x;
+ }
+ if (topleft.y > pp.y) {
+ topleft.y = pp.y;
+ }
+ } while (!(x == ox && y == oy && dir == odir));
+
+ if (o->pa.GetCount() > 0 && (x == ox && y == oy && dir == odir)) {
+ ol->AddTail(o);
+ } else {
+ ASSERT(0);
+ }
+ }
+
+ return ol;
}
static bool FitLine(COutline& o, int& start, int& end)
{
- int len = (int)o.pa.GetCount();
- if (len < 7) {
- return false; // small segments should be handled with beziers...
- }
-
- for (start = 0; start < len && !o.da[start]; start++) {
- ;
- }
- for (end = len-1; end > start && !o.da[end]; end--) {
- ;
- }
-
- if (end-start < 8 || end-start < (len-end)+(start-0)) {
- return false;
- }
-
- CUIntArray la, ra;
-
- UINT i, j, k;
-
- for (i = start+1, j = end, k = start; i <= j; i++) {
- if (!o.da[i]) {
- continue;
- }
- if (o.da[i] == o.da[k]) {
- return false;
- }
- if (o.da[i] == -1) {
- la.Add(i-k);
- } else {
- ra.Add(i-k);
- }
- k = i;
- }
-
- bool fl = true, fr = true;
-
- // these tests are completly heuristic and might be redundant a bit...
-
- for (i = 0, j = (UINT)la.GetSize(); i < j && fl; i++) {
- if (la[i] != 1) {
- fl = false;
- }
- }
- for (i = 0, j = (UINT)ra.GetSize(); i < j && fr; i++) {
- if (ra[i] != 1) {
- fr = false;
- }
- }
-
- if (!fl && !fr) {
- return false; // can't be a line if there are bigger steps than one in both directions (lines are usually drawn by stepping one either horizontally or vertically)
- }
- if (fl && fr && 1.0*(end-start)/((len-end)*2+(start-0)*2) > 0.4) {
- return false; // if this section is relatively too small it may only be a rounded corner
- }
- if (!fl && la.GetSize() > 0 && la.GetSize() <= 4 && (la[0] == 1 && la[la.GetSize()-1] == 1)) {
- return false; // one step at both ends, doesn't sound good for a line (may be it was skewed, so only eliminate smaller sections where beziers going to look just as good)
- }
- if (!fr && ra.GetSize() > 0 && ra.GetSize() <= 4 && (ra[0] == 1 && ra[ra.GetSize()-1] == 1)) {
- return false; // -''-
- }
-
- CUIntArray& a = !fl ? la : ra;
-
- len = (int)a.GetSize();
-
- int sum = 0;
-
- for (i = 0, j = INT_MAX, k = 0; i < (UINT)len; i++) {
- if (j > a[i]) {
- j = a[i];
- }
- if (k < a[i]) {
- k = a[i];
- }
- sum += a[i];
- }
-
- if (k - j > 2 && 1.0*sum/len < 2) {
- return false;
- }
- if (k - j > 2 && 1.0*sum/len >= 2 && len < 4) {
- return false;
- }
-
- if ((la.GetSize()/2+ra.GetSize()/2)/2 <= 2) {
- if ((k+j)/2 < 2 && k*j!=1) {
- return false;
- }
- }
-
- double err = 0;
-
- CPoint sp = o.pa[start], ep = o.pa[end];
-
- double minerr = 0, maxerr = 0;
-
- double vx = ep.x - sp.x, vy = ep.y - sp.y, l = sqrt(vx*vx+vy*vy);
- vx /= l;
- vy /= l;
-
- for (i = start+1, j = end-1; i <= j; i++) {
- CPoint p = o.pa[i], dp = p - sp;
- double t = vx*dp.x+vy*dp.y, dx = vx*t + sp.x - p.x, dy = vy*t + sp.y - p.y;
- t = dx*dx+dy*dy;
- err += t;
- t = sqrt(t);
- if (vy*dx-dy*vx < 0) {
- if (minerr > -t) {
- minerr = -t;
- }
- } else {
- if (maxerr < t) {
- maxerr = t;
- }
- }
- }
-
- return ((maxerr-minerr)/l < 0.1 || err/l < 1.5 || (fabs(maxerr) < 8 && fabs(minerr) < 8));
+ int len = (int)o.pa.GetCount();
+ if (len < 7) {
+ return false; // small segments should be handled with beziers...
+ }
+
+ for (start = 0; start < len && !o.da[start]; start++) {
+ ;
+ }
+ for (end = len - 1; end > start && !o.da[end]; end--) {
+ ;
+ }
+
+ if (end - start < 8 || end - start < (len - end) + (start - 0)) {
+ return false;
+ }
+
+ CUIntArray la, ra;
+
+ UINT i, j, k;
+
+ for (i = start + 1, j = end, k = start; i <= j; i++) {
+ if (!o.da[i]) {
+ continue;
+ }
+ if (o.da[i] == o.da[k]) {
+ return false;
+ }
+ if (o.da[i] == -1) {
+ la.Add(i - k);
+ } else {
+ ra.Add(i - k);
+ }
+ k = i;
+ }
+
+ bool fl = true, fr = true;
+
+ // these tests are completly heuristic and might be redundant a bit...
+
+ for (i = 0, j = (UINT)la.GetSize(); i < j && fl; i++) {
+ if (la[i] != 1) {
+ fl = false;
+ }
+ }
+ for (i = 0, j = (UINT)ra.GetSize(); i < j && fr; i++) {
+ if (ra[i] != 1) {
+ fr = false;
+ }
+ }
+
+ if (!fl && !fr) {
+ return false; // can't be a line if there are bigger steps than one in both directions (lines are usually drawn by stepping one either horizontally or vertically)
+ }
+ if (fl && fr && 1.0 * (end - start) / ((len - end) * 2 + (start - 0) * 2) > 0.4) {
+ return false; // if this section is relatively too small it may only be a rounded corner
+ }
+ if (!fl && la.GetSize() > 0 && la.GetSize() <= 4 && (la[0] == 1 && la[la.GetSize() - 1] == 1)) {
+ return false; // one step at both ends, doesn't sound good for a line (may be it was skewed, so only eliminate smaller sections where beziers going to look just as good)
+ }
+ if (!fr && ra.GetSize() > 0 && ra.GetSize() <= 4 && (ra[0] == 1 && ra[ra.GetSize() - 1] == 1)) {
+ return false; // -''-
+ }
+
+ CUIntArray& a = !fl ? la : ra;
+
+ len = (int)a.GetSize();
+
+ int sum = 0;
+
+ for (i = 0, j = INT_MAX, k = 0; i < (UINT)len; i++) {
+ if (j > a[i]) {
+ j = a[i];
+ }
+ if (k < a[i]) {
+ k = a[i];
+ }
+ sum += a[i];
+ }
+
+ if (k - j > 2 && 1.0 * sum / len < 2) {
+ return false;
+ }
+ if (k - j > 2 && 1.0 * sum / len >= 2 && len < 4) {
+ return false;
+ }
+
+ if ((la.GetSize() / 2 + ra.GetSize() / 2) / 2 <= 2) {
+ if ((k + j) / 2 < 2 && k * j != 1) {
+ return false;
+ }
+ }
+
+ double err = 0;
+
+ CPoint sp = o.pa[start], ep = o.pa[end];
+
+ double minerr = 0, maxerr = 0;
+
+ double vx = ep.x - sp.x, vy = ep.y - sp.y, l = sqrt(vx * vx + vy * vy);
+ vx /= l;
+ vy /= l;
+
+ for (i = start + 1, j = end - 1; i <= j; i++) {
+ CPoint p = o.pa[i], dp = p - sp;
+ double t = vx * dp.x + vy * dp.y, dx = vx * t + sp.x - p.x, dy = vy * t + sp.y - p.y;
+ t = dx * dx + dy * dy;
+ err += t;
+ t = sqrt(t);
+ if (vy * dx - dy * vx < 0) {
+ if (minerr > -t) {
+ minerr = -t;
+ }
+ } else {
+ if (maxerr < t) {
+ maxerr = t;
+ }
+ }
+ }
+
+ return ((maxerr - minerr) / l < 0.1 || err / l < 1.5 || (fabs(maxerr) < 8 && fabs(minerr) < 8));
}
static int CalcPossibleCurveDegree(COutline& o)
{
- size_t len2 = o.da.GetCount();
+ size_t len2 = o.da.GetCount();
- CUIntArray la;
+ CUIntArray la;
- for (size_t i = 0, j = 0; j < len2; j++) {
- if (j+1 == len2 || o.da[j]) {
- la.Add(UINT(j-i));
- i = j;
- }
- }
+ for (size_t i = 0, j = 0; j < len2; j++) {
+ if (j + 1 == len2 || o.da[j]) {
+ la.Add(UINT(j - i));
+ i = j;
+ }
+ }
- ptrdiff_t len = la.GetCount();
+ ptrdiff_t len = la.GetCount();
- int ret = 0;
+ int ret = 0;
- // check if we can find a reason to add a penalty degree, or two :P
- // it is mainly about looking for distant corners
- {
- int penalty = 0;
+ // check if we can find a reason to add a penalty degree, or two :P
+ // it is mainly about looking for distant corners
+ {
+ int penalty = 0;
- int ma[2] = {0, 0};
- for (ptrdiff_t i = 0; i < len; i++) {
- ma[i&1] += la[i];
- }
+ int ma[2] = {0, 0};
+ for (ptrdiff_t i = 0; i < len; i++) {
+ ma[i & 1] += la[i];
+ }
- int ca[2] = {ma[0], ma[1]};
- for (ptrdiff_t i = 0; i < len; i++) {
- ca[i&1] -= la[i];
+ int ca[2] = {ma[0], ma[1]};
+ for (ptrdiff_t i = 0; i < len; i++) {
+ ca[i & 1] -= la[i];
- double c1 = 1.0*ca[0]/ma[0], c2 = 1.0*ca[1]/ma[1], c3 = 1.0*la[i]/ma[i&1];
+ double c1 = 1.0 * ca[0] / ma[0], c2 = 1.0 * ca[1] / ma[1], c3 = 1.0 * la[i] / ma[i & 1];
- if (len2 > 16 && (fabs(c1-c2) > 0.7 || (c3 > 0.6 && la[i] > 5))) {
- penalty = 2;
- break;
- }
+ if (len2 > 16 && (fabs(c1 - c2) > 0.7 || (c3 > 0.6 && la[i] > 5))) {
+ penalty = 2;
+ break;
+ }
- if (fabs(c1-c2) > 0.6 || (c3 > 0.4 && la[i] > 5)) {
- penalty = 1;
- }
- }
+ if (fabs(c1 - c2) > 0.6 || (c3 > 0.4 && la[i] > 5)) {
+ penalty = 1;
+ }
+ }
- ret += penalty;
- }
+ ret += penalty;
+ }
- la[0] <<= 1;
- la[len-1] <<= 1;
+ la[0] <<= 1;
+ la[len - 1] <<= 1;
- for (ptrdiff_t i = 0; i < len; i+=2) {
- if (la[i] > 1) {
- ret++; // prependicular to the last chosen section and bigger then 1 -> add a degree and continue with the other dir
- i--;
- }
- }
+ for (ptrdiff_t i = 0; i < len; i += 2) {
+ if (la[i] > 1) {
+ ret++; // prependicular to the last chosen section and bigger then 1 -> add a degree and continue with the other dir
+ i--;
+ }
+ }
- return ret;
+ return ret;
}
inline double vectlen(CPoint p)
{
- return sqrt((double)(p.x*p.x+p.y*p.y));
+ return sqrt((double)(p.x * p.x + p.y * p.y));
}
inline double vectlen(CPoint p1, CPoint p2)
{
- return vectlen(p2 - p1);
+ return vectlen(p2 - p1);
}
static bool MinMaxCosfi(COutline& o, double& mincf, double& maxcf) // not really cosfi, it is weighted by the distance from the segment endpoints, and since it would be always between -1 and 0, the applied sign marks side
{
- CAtlArray<CPoint>& pa = o.pa;
+ CAtlArray<CPoint>& pa = o.pa;
- int len = (int)pa.GetCount();
- if (len < 6) {
- return false;
- }
+ int len = (int)pa.GetCount();
+ if (len < 6) {
+ return false;
+ }
- mincf = 1;
- maxcf = -1;
+ mincf = 1;
+ maxcf = -1;
- CPoint p = pa[len-1] - pa[0];
- double l = vectlen(p);
- UNREFERENCED_PARAMETER(l);
+ CPoint p = pa[len - 1] - pa[0];
+ double l = vectlen(p);
+ UNREFERENCED_PARAMETER(l);
- for (ptrdiff_t i = 2; i < len-2; i++) { // skip the endpoints, they aren't accurate
- CPoint p1 = pa[0] - pa[i], p2 = pa[len-1] - pa[i];
- double l1 = vectlen(p1), l2 = vectlen(p2);
- int sign = p1.x*p.y-p1.y*p.x >= 0 ? 1 : -1;
+ for (ptrdiff_t i = 2; i < len - 2; i++) { // skip the endpoints, they aren't accurate
+ CPoint p1 = pa[0] - pa[i], p2 = pa[len - 1] - pa[i];
+ double l1 = vectlen(p1), l2 = vectlen(p2);
+ int sign = p1.x * p.y - p1.y * p.x >= 0 ? 1 : -1;
- double c = (1.0*len/2 - fabs(i - 1.0*len/2)) / len * 2; // c: 0 -> 1 -> 0
+ double c = (1.0 * len / 2 - fabs(i - 1.0 * len / 2)) / len * 2; // c: 0 -> 1 -> 0
- double cosfi = (1+(p1.x*p2.x+p1.y*p2.y)/(l1*l2)) * sign * c;
- if (mincf > cosfi) {
- mincf = cosfi;
- }
- if (maxcf < cosfi) {
- maxcf = cosfi;
- }
- }
+ double cosfi = (1 + (p1.x * p2.x + p1.y * p2.y) / (l1 * l2)) * sign * c;
+ if (mincf > cosfi) {
+ mincf = cosfi;
+ }
+ if (maxcf < cosfi) {
+ maxcf = cosfi;
+ }
+ }
- return true;
+ return true;
}
static bool FitBezierVH(COutline& o, CPoint& p1, CPoint& p2)
{
- int i;
-
- CAtlArray<CPoint>& pa = o.pa;
-
- int len = (int)pa.GetCount();
-
- if (len <= 1) {
- return false;
- } else if (len == 2) {
- CPoint mid = pa[0]+pa[1];
- mid.x >>= 1;
- mid.y >>= 1;
- p1 = p2 = mid;
- return true;
- }
-
- CPoint dir1 = pa[1] - pa[0], dir2 = pa[len-2] - pa[len-1];
- if ((dir1.x&&dir1.y)||(dir2.x&&dir2.y)) {
- return false; // we are only fitting beziers with hor./ver. endings
- }
-
- if (CalcPossibleCurveDegree(o) > 3) {
- return false;
- }
-
- double mincf, maxcf;
- if (MinMaxCosfi(o, mincf, maxcf)) {
- if (maxcf-mincf > 0.8
- || maxcf-mincf > 0.6 && (maxcf >= 0.4 || mincf <= -0.4)) {
- return false;
- }
- }
-
- CPoint p0 = p1 = pa[0];
- CPoint p3 = p2 = pa[len-1];
-
- CAtlArray<double> pl;
- pl.SetCount(len);
-
- double c10 = 0, c11 = 0, c12 = 0, c13 = 0, c1x = 0, c1y = 0;
- double c20 = 0, c21 = 0, c22 = 0, c23 = 0, c2x = 0, c2y = 0;
- double length = 0;
-
- for (pl[0] = 0, i = 1; i < len; i++) {
- CPoint diff = (pa[i] - pa[i-1]);
- pl[i] = (length += sqrt((double)(diff.x*diff.x+diff.y*diff.y)));
- }
-
- for (i = 0; i < len; i++) {
- double t1 = pl[i] / length;
- double t2 = t1*t1;
- double t3 = t2*t1;
- double it1 = 1 - t1;
- double it2 = it1*it1;
- double it3 = it2*it1;
-
- double dc1 = 3.0*it2*t1;
- double dc2 = 3.0*it1*t2;
-
- c10 += it3*dc1;
- c11 += dc1*dc1;
- c12 += dc2*dc1;
- c13 += t3*dc1;
- c1x += pa[i].x*dc1;
- c1y += pa[i].y*dc1;
-
- c20 += it3*dc2;
- c21 += dc1*dc2;
- c22 += dc2*dc2;
- c23 += t3*dc2;
- c2x += pa[i].x*dc2;
- c2y += pa[i].y*dc2;
- }
-
- if (dir1.y == 0 && dir2.x == 0) {
- p1.x = (int)((c1x - c10*p0.x - c12*p3.x - c13*p3.x) / c11 + 0.5);
- p2.y = (int)((c2y - c20*p0.y - c21*p0.y - c23*p3.y) / c22 + 0.5);
- } else if (dir1.x == 0 && dir2.y == 0) {
- p2.x = (int)((c2x - c20*p0.x - c21*p0.x - c23*p3.x) / c22 + 0.5);
- p1.y = (int)((c1y - c10*p0.y - c12*p3.y - c13*p3.y) / c11 + 0.5);
- } else if (dir1.y == 0 && dir2.y == 0) {
- // cramer's rule
- double D = c11*c22 - c12*c21;
- p1.x = (int)(((c1x-c10*p0.x-c13*p3.x)*c22 - c12*(c2x-c20*p0.x-c23*p3.x)) / D + 0.5);
- p2.x = (int)((c11*(c2x-c20*p0.x-c23*p3.x) - (c1x-c10*p0.x-c13*p3.x)*c21) / D + 0.5);
- } else if (dir1.x == 0 && dir2.x == 0) {
- // cramer's rule
- double D = c11*c22 - c12*c21;
- p1.y = (int)(((c1y-c10*p0.y-c13*p3.y)*c22 - c12*(c2y-c20*p0.y-c23*p3.y)) / D + 0.5);
- p2.y = (int)((c11*(c2y-c20*p0.y-c23*p3.y) - (c1y-c10*p0.y-c13*p3.y)*c21) / D + 0.5);
- } else { // must not happen
- ASSERT(0);
- return false;
- }
-
- // check for "inside-out" beziers
- CPoint dir3 = p1 - p0, dir4 = p2 - p3;
- if ((dir1.x*dir3.x+dir1.y*dir3.y) <= 0 || (dir2.x*dir4.x+dir2.y*dir4.y) <= 0) {
- return false;
- }
-
- return true;
+ int i;
+
+ CAtlArray<CPoint>& pa = o.pa;
+
+ int len = (int)pa.GetCount();
+
+ if (len <= 1) {
+ return false;
+ } else if (len == 2) {
+ CPoint mid = pa[0] + pa[1];
+ mid.x >>= 1;
+ mid.y >>= 1;
+ p1 = p2 = mid;
+ return true;
+ }
+
+ CPoint dir1 = pa[1] - pa[0], dir2 = pa[len - 2] - pa[len - 1];
+ if ((dir1.x && dir1.y) || (dir2.x && dir2.y)) {
+ return false; // we are only fitting beziers with hor./ver. endings
+ }
+
+ if (CalcPossibleCurveDegree(o) > 3) {
+ return false;
+ }
+
+ double mincf, maxcf;
+ if (MinMaxCosfi(o, mincf, maxcf)) {
+ if (maxcf - mincf > 0.8
+ || maxcf - mincf > 0.6 && (maxcf >= 0.4 || mincf <= -0.4)) {
+ return false;
+ }
+ }
+
+ CPoint p0 = p1 = pa[0];
+ CPoint p3 = p2 = pa[len - 1];
+
+ CAtlArray<double> pl;
+ pl.SetCount(len);
+
+ double c10 = 0, c11 = 0, c12 = 0, c13 = 0, c1x = 0, c1y = 0;
+ double c20 = 0, c21 = 0, c22 = 0, c23 = 0, c2x = 0, c2y = 0;
+ double length = 0;
+
+ for (pl[0] = 0, i = 1; i < len; i++) {
+ CPoint diff = (pa[i] - pa[i - 1]);
+ pl[i] = (length += sqrt((double)(diff.x * diff.x + diff.y * diff.y)));
+ }
+
+ for (i = 0; i < len; i++) {
+ double t1 = pl[i] / length;
+ double t2 = t1 * t1;
+ double t3 = t2 * t1;
+ double it1 = 1 - t1;
+ double it2 = it1 * it1;
+ double it3 = it2 * it1;
+
+ double dc1 = 3.0 * it2 * t1;
+ double dc2 = 3.0 * it1 * t2;
+
+ c10 += it3 * dc1;
+ c11 += dc1 * dc1;
+ c12 += dc2 * dc1;
+ c13 += t3 * dc1;
+ c1x += pa[i].x * dc1;
+ c1y += pa[i].y * dc1;
+
+ c20 += it3 * dc2;
+ c21 += dc1 * dc2;
+ c22 += dc2 * dc2;
+ c23 += t3 * dc2;
+ c2x += pa[i].x * dc2;
+ c2y += pa[i].y * dc2;
+ }
+
+ if (dir1.y == 0 && dir2.x == 0) {
+ p1.x = (int)((c1x - c10 * p0.x - c12 * p3.x - c13 * p3.x) / c11 + 0.5);
+ p2.y = (int)((c2y - c20 * p0.y - c21 * p0.y - c23 * p3.y) / c22 + 0.5);
+ } else if (dir1.x == 0 && dir2.y == 0) {
+ p2.x = (int)((c2x - c20 * p0.x - c21 * p0.x - c23 * p3.x) / c22 + 0.5);
+ p1.y = (int)((c1y - c10 * p0.y - c12 * p3.y - c13 * p3.y) / c11 + 0.5);
+ } else if (dir1.y == 0 && dir2.y == 0) {
+ // cramer's rule
+ double D = c11 * c22 - c12 * c21;
+ p1.x = (int)(((c1x - c10 * p0.x - c13 * p3.x) * c22 - c12 * (c2x - c20 * p0.x - c23 * p3.x)) / D + 0.5);
+ p2.x = (int)((c11 * (c2x - c20 * p0.x - c23 * p3.x) - (c1x - c10 * p0.x - c13 * p3.x) * c21) / D + 0.5);
+ } else if (dir1.x == 0 && dir2.x == 0) {
+ // cramer's rule
+ double D = c11 * c22 - c12 * c21;
+ p1.y = (int)(((c1y - c10 * p0.y - c13 * p3.y) * c22 - c12 * (c2y - c20 * p0.y - c23 * p3.y)) / D + 0.5);
+ p2.y = (int)((c11 * (c2y - c20 * p0.y - c23 * p3.y) - (c1y - c10 * p0.y - c13 * p3.y) * c21) / D + 0.5);
+ } else { // must not happen
+ ASSERT(0);
+ return false;
+ }
+
+ // check for "inside-out" beziers
+ CPoint dir3 = p1 - p0, dir4 = p2 - p3;
+ if ((dir1.x * dir3.x + dir1.y * dir3.y) <= 0 || (dir2.x * dir4.x + dir2.y * dir4.y) <= 0) {
+ return false;
+ }
+
+ return true;
}
int CVobSubImage::GrabSegment(int start, COutline& o, COutline& ret)
{
- ret.RemoveAll();
-
- int len = int(o.pa.GetCount());
-
- int cur = (start)%len, first = -1, last = -1;
- int lastDir = 0;
-
- for (ptrdiff_t i = 0; i < len; i++) {
- cur = (cur+1)%len;
-
- if (o.da[cur] == 0) {
- continue;
- }
-
- if (first == -1) {
- first = cur;
- }
-
- if (lastDir == o.da[cur]) {
- CPoint startp = o.pa[first]+o.pa[start];
- startp.x >>= 1;
- startp.y >>= 1;
- CPoint endp = o.pa[last]+o.pa[cur];
- endp.x >>= 1;
- endp.y >>= 1;
-
- if (first < start) {
- first += len;
- }
- start = ((start+first)>>1)+1;
- if (start >= len) {
- start -= len;
- }
- if (cur < last) {
- cur += len;
- }
- cur = ((last+cur+1)>>1);
- if (cur >= len) {
- cur -= len;
- }
-
- ret.Add(startp, 0);
-
- while (start != cur) {
- ret.Add(o.pa[start], o.da[start]);
-
- start++;
- if (start >= len) {
- start -= len;
- }
- }
-
- ret.Add(endp, 0);
-
- return last;
- }
-
- lastDir = o.da[cur];
- last = cur;
- }
-
- ASSERT(0);
-
- return start;
+ ret.RemoveAll();
+
+ int len = int(o.pa.GetCount());
+
+ int cur = (start) % len, first = -1, last = -1;
+ int lastDir = 0;
+
+ for (ptrdiff_t i = 0; i < len; i++) {
+ cur = (cur + 1) % len;
+
+ if (o.da[cur] == 0) {
+ continue;
+ }
+
+ if (first == -1) {
+ first = cur;
+ }
+
+ if (lastDir == o.da[cur]) {
+ CPoint startp = o.pa[first] + o.pa[start];
+ startp.x >>= 1;
+ startp.y >>= 1;
+ CPoint endp = o.pa[last] + o.pa[cur];
+ endp.x >>= 1;
+ endp.y >>= 1;
+
+ if (first < start) {
+ first += len;
+ }
+ start = ((start + first) >> 1) + 1;
+ if (start >= len) {
+ start -= len;
+ }
+ if (cur < last) {
+ cur += len;
+ }
+ cur = ((last + cur + 1) >> 1);
+ if (cur >= len) {
+ cur -= len;
+ }
+
+ ret.Add(startp, 0);
+
+ while (start != cur) {
+ ret.Add(o.pa[start], o.da[start]);
+
+ start++;
+ if (start >= len) {
+ start -= len;
+ }
+ }
+
+ ret.Add(endp, 0);
+
+ return last;
+ }
+
+ lastDir = o.da[cur];
+ last = cur;
+ }
+
+ ASSERT(0);
+
+ return start;
}
void CVobSubImage::SplitOutline(COutline& o, COutline& o1, COutline& o2)
{
- size_t len = o.pa.GetCount();
- if (len < 4) {
- return;
- }
-
- CAtlArray<UINT> la, sa, ea;
-
- size_t i, j, k;
-
- for (i = 0, j = 0; j < len; j++) {
- if (j+1 == len || o.da[j]) {
- la.Add(unsigned int(j-i));
- sa.Add(unsigned int(i));
- ea.Add(unsigned int(j));
- i = j;
- }
- }
-
- size_t maxlen = 0, maxidx = -1;
- size_t maxlen2 = 0, maxidx2 = -1;
-
- for (i = 0; i < la.GetCount(); i++) {
- if (maxlen < la[i]) {
- maxlen = la[i];
- maxidx = i;
- }
-
- if (maxlen2 < la[i] && i > 0 && i < la.GetCount()-1) {
- maxlen2 = la[i];
- maxidx2 = i;
- }
- }
-
- if (maxlen == maxlen2) {
- maxidx = maxidx2; // if equal choose the inner section
- }
-
- j = (sa[maxidx] + ea[maxidx]) >> 1, k = (sa[maxidx] + ea[maxidx] + 1) >> 1;
-
- o1.RemoveAll();
- o2.RemoveAll();
-
- for (i = 0; i <= j; i++) {
- o1.Add(o.pa[i], o.da[i]);
- }
-
- if (j != k) {
- CPoint mid = o.pa[j]+o.pa[k];
- mid.x >>= 1;
- mid.y >>= 1;
- o1.Add(mid, 0);
- o2.Add(mid, 0);
- }
-
- for (i = k; i < len; i++) {
- o2.Add(o.pa[i], o.da[i]);
- }
+ size_t len = o.pa.GetCount();
+ if (len < 4) {
+ return;
+ }
+
+ CAtlArray<UINT> la, sa, ea;
+
+ size_t i, j, k;
+
+ for (i = 0, j = 0; j < len; j++) {
+ if (j + 1 == len || o.da[j]) {
+ la.Add(unsigned int(j - i));
+ sa.Add(unsigned int(i));
+ ea.Add(unsigned int(j));
+ i = j;
+ }
+ }
+
+ size_t maxlen = 0, maxidx = -1;
+ size_t maxlen2 = 0, maxidx2 = -1;
+
+ for (i = 0; i < la.GetCount(); i++) {
+ if (maxlen < la[i]) {
+ maxlen = la[i];
+ maxidx = i;
+ }
+
+ if (maxlen2 < la[i] && i > 0 && i < la.GetCount() - 1) {
+ maxlen2 = la[i];
+ maxidx2 = i;
+ }
+ }
+
+ if (maxlen == maxlen2) {
+ maxidx = maxidx2; // if equal choose the inner section
+ }
+
+ j = (sa[maxidx] + ea[maxidx]) >> 1, k = (sa[maxidx] + ea[maxidx] + 1) >> 1;
+
+ o1.RemoveAll();
+ o2.RemoveAll();
+
+ for (i = 0; i <= j; i++) {
+ o1.Add(o.pa[i], o.da[i]);
+ }
+
+ if (j != k) {
+ CPoint mid = o.pa[j] + o.pa[k];
+ mid.x >>= 1;
+ mid.y >>= 1;
+ o1.Add(mid, 0);
+ o2.Add(mid, 0);
+ }
+
+ for (i = k; i < len; i++) {
+ o2.Add(o.pa[i], o.da[i]);
+ }
}
void CVobSubImage::AddSegment(COutline& o, CAtlArray<BYTE>& pathTypes, CAtlArray<CPoint>& pathPoints)
{
- int i, len = int(o.pa.GetCount());
- if (len < 3) {
- return;
- }
-
- int nLeftTurns = 0, nRightTurns = 0;
+ int i, len = int(o.pa.GetCount());
+ if (len < 3) {
+ return;
+ }
+
+ int nLeftTurns = 0, nRightTurns = 0;
- for (i = 0; i < len; i++) {
- if (o.da[i] == -1) {
- nLeftTurns++;
- } else if (o.da[i] == 1) {
- nRightTurns++;
- }
- }
+ for (i = 0; i < len; i++) {
+ if (o.da[i] == -1) {
+ nLeftTurns++;
+ } else if (o.da[i] == 1) {
+ nRightTurns++;
+ }
+ }
- if (nLeftTurns == 0 && nRightTurns == 0) { // line
- pathTypes.Add(PT_LINETO);
- pathPoints.Add(o.pa[len-1]);
-
- return;
- }
-
- if (nLeftTurns == 0 || nRightTurns == 0) { // b-spline
- pathTypes.Add(PT_MOVETONC);
- pathPoints.Add(o.pa[0]+(o.pa[0]-o.pa[1]));
-
- for (i = 0; i < 3; i++) {
- pathTypes.Add(PT_BSPLINETO);
- pathPoints.Add(o.pa[i]);
- }
-
- for (; i < len; i++) {
- pathTypes.Add(PT_BSPLINEPATCHTO);
- pathPoints.Add(o.pa[i]);
- }
-
- pathTypes.Add(PT_BSPLINEPATCHTO);
- pathPoints.Add(o.pa[len-1]+(o.pa[len-1]-o.pa[len-2]));
-
- pathTypes.Add(PT_MOVETONC);
- pathPoints.Add(o.pa[len-1]);
-
- return;
- }
-
- int start, end;
- if (FitLine(o, start, end)) { // b-spline, line, b-spline
- pathTypes.Add(PT_MOVETONC);
- pathPoints.Add(o.pa[0]+(o.pa[0]-o.pa[1]));
-
- pathTypes.Add(PT_BSPLINETO);
- pathPoints.Add(o.pa[0]);
-
- pathTypes.Add(PT_BSPLINETO);
- pathPoints.Add(o.pa[1]);
-
- CPoint p[4], pp, d = o.pa[end] - o.pa[start];
- double l = sqrt((double)(d.x*d.x+d.y*d.y)), dx = 1.0 * d.x / l, dy = 1.0 * d.y / l;
-
- pp = o.pa[start]-o.pa[start-1];
- double l1 = abs(pp.x)+abs(pp.y);
- pp = o.pa[end]-o.pa[end+1];
- double l2 = abs(pp.x)+abs(pp.y);
- p[0] = CPoint((int)(1.0 * o.pa[start].x + dx*l1 + 0.5), (int)(1.0 * o.pa[start].y + dy*l1 + 0.5));
- p[1] = CPoint((int)(1.0 * o.pa[start].x + dx*l1*2 + 0.5), (int)(1.0 * o.pa[start].y + dy*l1*2 + 0.5));
- p[2] = CPoint((int)(1.0 * o.pa[end].x - dx*l2*2 + 0.5), (int)(1.0 * o.pa[end].y - dy*l2*2 + 0.5));
- p[3] = CPoint((int)(1.0 * o.pa[end].x - dx*l2 + 0.5), (int)(1.0 * o.pa[end].y - dy*l2 + 0.5));
-
- if (start == 1) {
- pathTypes.Add(PT_BSPLINETO);
- pathPoints.Add(p[0]);
- } else {
- pathTypes.Add(PT_BSPLINETO);
- pathPoints.Add(o.pa[2]);
-
- for (ptrdiff_t i = 3; i <= start; i++) {
- pathTypes.Add(PT_BSPLINEPATCHTO);
- pathPoints.Add(o.pa[i]);
- }
-
- pathTypes.Add(PT_BSPLINEPATCHTO);
- pathPoints.Add(p[0]);
- }
-
- pathTypes.Add(PT_BSPLINEPATCHTO);
- pathPoints.Add(p[1]);
-
- pathTypes.Add(PT_MOVETONC);
- pathPoints.Add(p[0]);
-
- pathTypes.Add(PT_LINETO);
- pathPoints.Add(p[3]);
-
- pathTypes.Add(PT_MOVETONC);
- pathPoints.Add(p[2]);
-
- pathTypes.Add(PT_BSPLINEPATCHTO);
- pathPoints.Add(p[3]);
-
- for (i = end; i < len; i++) {
- pathTypes.Add(PT_BSPLINEPATCHTO);
- pathPoints.Add(o.pa[i]);
- }
-
- pathTypes.Add(PT_BSPLINEPATCHTO);
- pathPoints.Add(o.pa[len-1]+(o.pa[len-1]-o.pa[len-2]));
-
- pathTypes.Add(PT_MOVETONC);
- pathPoints.Add(o.pa[len-1]);
-
- return;
- }
-
- CPoint p1, p2;
- if (FitBezierVH(o, p1, p2)) { // bezier
- pathTypes.Add(PT_BEZIERTO);
- pathPoints.Add(p1);
- pathTypes.Add(PT_BEZIERTO);
- pathPoints.Add(p2);
- pathTypes.Add(PT_BEZIERTO);
- pathPoints.Add(o.pa[o.pa.GetCount()-1]);
-
- return;
- }
-
- COutline o1, o2;
- SplitOutline(o, o1, o2);
- AddSegment(o1, pathTypes, pathPoints);
- AddSegment(o2, pathTypes, pathPoints);
+ if (nLeftTurns == 0 && nRightTurns == 0) { // line
+ pathTypes.Add(PT_LINETO);
+ pathPoints.Add(o.pa[len - 1]);
+
+ return;
+ }
+
+ if (nLeftTurns == 0 || nRightTurns == 0) { // b-spline
+ pathTypes.Add(PT_MOVETONC);
+ pathPoints.Add(o.pa[0] + (o.pa[0] - o.pa[1]));
+
+ for (i = 0; i < 3; i++) {
+ pathTypes.Add(PT_BSPLINETO);
+ pathPoints.Add(o.pa[i]);
+ }
+
+ for (; i < len; i++) {
+ pathTypes.Add(PT_BSPLINEPATCHTO);
+ pathPoints.Add(o.pa[i]);
+ }
+
+ pathTypes.Add(PT_BSPLINEPATCHTO);
+ pathPoints.Add(o.pa[len - 1] + (o.pa[len - 1] - o.pa[len - 2]));
+
+ pathTypes.Add(PT_MOVETONC);
+ pathPoints.Add(o.pa[len - 1]);
+
+ return;
+ }
+
+ int start, end;
+ if (FitLine(o, start, end)) { // b-spline, line, b-spline
+ pathTypes.Add(PT_MOVETONC);
+ pathPoints.Add(o.pa[0] + (o.pa[0] - o.pa[1]));
+
+ pathTypes.Add(PT_BSPLINETO);
+ pathPoints.Add(o.pa[0]);
+
+ pathTypes.Add(PT_BSPLINETO);
+ pathPoints.Add(o.pa[1]);
+
+ CPoint p[4], pp, d = o.pa[end] - o.pa[start];
+ double l = sqrt((double)(d.x * d.x + d.y * d.y)), dx = 1.0 * d.x / l, dy = 1.0 * d.y / l;
+
+ pp = o.pa[start] - o.pa[start - 1];
+ double l1 = abs(pp.x) + abs(pp.y);
+ pp = o.pa[end] - o.pa[end + 1];
+ double l2 = abs(pp.x) + abs(pp.y);
+ p[0] = CPoint((int)(1.0 * o.pa[start].x + dx * l1 + 0.5), (int)(1.0 * o.pa[start].y + dy * l1 + 0.5));
+ p[1] = CPoint((int)(1.0 * o.pa[start].x + dx * l1 * 2 + 0.5), (int)(1.0 * o.pa[start].y + dy * l1 * 2 + 0.5));
+ p[2] = CPoint((int)(1.0 * o.pa[end].x - dx * l2 * 2 + 0.5), (int)(1.0 * o.pa[end].y - dy * l2 * 2 + 0.5));
+ p[3] = CPoint((int)(1.0 * o.pa[end].x - dx * l2 + 0.5), (int)(1.0 * o.pa[end].y - dy * l2 + 0.5));
+
+ if (start == 1) {
+ pathTypes.Add(PT_BSPLINETO);
+ pathPoints.Add(p[0]);
+ } else {
+ pathTypes.Add(PT_BSPLINETO);
+ pathPoints.Add(o.pa[2]);
+
+ for (ptrdiff_t i = 3; i <= start; i++) {
+ pathTypes.Add(PT_BSPLINEPATCHTO);
+ pathPoints.Add(o.pa[i]);
+ }
+
+ pathTypes.Add(PT_BSPLINEPATCHTO);
+ pathPoints.Add(p[0]);
+ }
+
+ pathTypes.Add(PT_BSPLINEPATCHTO);
+ pathPoints.Add(p[1]);
+
+ pathTypes.Add(PT_MOVETONC);
+ pathPoints.Add(p[0]);
+
+ pathTypes.Add(PT_LINETO);
+ pathPoints.Add(p[3]);
+
+ pathTypes.Add(PT_MOVETONC);
+ pathPoints.Add(p[2]);
+
+ pathTypes.Add(PT_BSPLINEPATCHTO);
+ pathPoints.Add(p[3]);
+
+ for (i = end; i < len; i++) {
+ pathTypes.Add(PT_BSPLINEPATCHTO);
+ pathPoints.Add(o.pa[i]);
+ }
+
+ pathTypes.Add(PT_BSPLINEPATCHTO);
+ pathPoints.Add(o.pa[len - 1] + (o.pa[len - 1] - o.pa[len - 2]));
+
+ pathTypes.Add(PT_MOVETONC);
+ pathPoints.Add(o.pa[len - 1]);
+
+ return;
+ }
+
+ CPoint p1, p2;
+ if (FitBezierVH(o, p1, p2)) { // bezier
+ pathTypes.Add(PT_BEZIERTO);
+ pathPoints.Add(p1);
+ pathTypes.Add(PT_BEZIERTO);
+ pathPoints.Add(p2);
+ pathTypes.Add(PT_BEZIERTO);
+ pathPoints.Add(o.pa[o.pa.GetCount() - 1]);
+
+ return;
+ }
+
+ COutline o1, o2;
+ SplitOutline(o, o1, o2);
+ AddSegment(o1, pathTypes, pathPoints);
+ AddSegment(o2, pathTypes, pathPoints);
}
bool CVobSubImage::Polygonize(CAtlArray<BYTE>& pathTypes, CAtlArray<CPoint>& pathPoints, bool fSmooth, int scale)
{
- CPoint topleft;
- CAutoPtr<CAutoPtrList<COutline> > ol(GetOutlineList(topleft));
- if (!ol) {
- return false;
- }
-
- POSITION pos;
-
- pos = ol->GetHeadPosition();
- while (pos) {
- CAtlArray<CPoint>& pa = ol->GetNext(pos)->pa;
- for (size_t i = 0; i < pa.GetCount(); i++) {
- pa[i].x = (pa[i].x-topleft.x)<<scale;
- pa[i].y = (pa[i].y-topleft.y)<<scale;
- }
- }
-
- pos = ol->GetHeadPosition();
- while (pos) {
- COutline& o = *ol->GetNext(pos), o2;
-
- if (fSmooth) {
- int i = 0, iFirst = -1;
-
- for (;;) {
- i = GrabSegment(i, o, o2);
-
- if (i == iFirst) {
- break;
- }
-
- if (iFirst < 0) {
- iFirst = i;
- pathTypes.Add(PT_MOVETO);
- pathPoints.Add(o2.pa[0]);
- }
-
- AddSegment(o2, pathTypes, pathPoints);
- }
- } else {
- /*
- for (ptrdiff_t i = 1, len = o.pa.GetSize(); i < len; i++)
- {
- if (int dir = o.da[i-1])
- {
- CPoint dir2 = o.pa[i] - o.pa[i-1];
- dir2.x /= 2; dir2.y /= 2;
- CPoint dir1 = dir > 0 ? CPoint(dir2.y, -dir2.x) : CPoint(-dir2.y, dir2.x);
- i = i;
- o.pa[i-1] -= dir1;
- o.pa.InsertAt(i, o.pa[i-1] + dir2);
- o.da.InsertAt(i, -dir);
- o.pa.InsertAt(i+1, o.pa[i] + dir1);
- o.da.InsertAt(i+1, dir);
- i += 2;
- len += 2;
- }
- }
- */
- pathTypes.Add(PT_MOVETO);
- pathPoints.Add(o.pa[0]);
-
- for (size_t i = 1, len = o.pa.GetCount(); i < len; i++) {
- pathTypes.Add(PT_LINETO);
- pathPoints.Add(o.pa[i]);
- }
- }
- }
-
- return !pathTypes.IsEmpty();
+ CPoint topleft;
+ CAutoPtr<CAutoPtrList<COutline> > ol(GetOutlineList(topleft));
+ if (!ol) {
+ return false;
+ }
+
+ POSITION pos;
+
+ pos = ol->GetHeadPosition();
+ while (pos) {
+ CAtlArray<CPoint>& pa = ol->GetNext(pos)->pa;
+ for (size_t i = 0; i < pa.GetCount(); i++) {
+ pa[i].x = (pa[i].x - topleft.x) << scale;
+ pa[i].y = (pa[i].y - topleft.y) << scale;
+ }
+ }
+
+ pos = ol->GetHeadPosition();
+ while (pos) {
+ COutline& o = *ol->GetNext(pos), o2;
+
+ if (fSmooth) {
+ int i = 0, iFirst = -1;
+
+ for (;;) {
+ i = GrabSegment(i, o, o2);
+
+ if (i == iFirst) {
+ break;
+ }
+
+ if (iFirst < 0) {
+ iFirst = i;
+ pathTypes.Add(PT_MOVETO);
+ pathPoints.Add(o2.pa[0]);
+ }
+
+ AddSegment(o2, pathTypes, pathPoints);
+ }
+ } else {
+ /*
+ for (ptrdiff_t i = 1, len = o.pa.GetSize(); i < len; i++)
+ {
+ if (int dir = o.da[i-1])
+ {
+ CPoint dir2 = o.pa[i] - o.pa[i-1];
+ dir2.x /= 2; dir2.y /= 2;
+ CPoint dir1 = dir > 0 ? CPoint(dir2.y, -dir2.x) : CPoint(-dir2.y, dir2.x);
+ i = i;
+ o.pa[i-1] -= dir1;
+ o.pa.InsertAt(i, o.pa[i-1] + dir2);
+ o.da.InsertAt(i, -dir);
+ o.pa.InsertAt(i+1, o.pa[i] + dir1);
+ o.da.InsertAt(i+1, dir);
+ i += 2;
+ len += 2;
+ }
+ }
+ */
+ pathTypes.Add(PT_MOVETO);
+ pathPoints.Add(o.pa[0]);
+
+ for (size_t i = 1, len = o.pa.GetCount(); i < len; i++) {
+ pathTypes.Add(PT_LINETO);
+ pathPoints.Add(o.pa[i]);
+ }
+ }
+ }
+
+ return !pathTypes.IsEmpty();
}
bool CVobSubImage::Polygonize(CStringW& assstr, bool fSmooth, int scale)
{
- CAtlArray<BYTE> pathTypes;
- CAtlArray<CPoint> pathPoints;
-
- if (!Polygonize(pathTypes, pathPoints, fSmooth, scale)) {
- return false;
- }
-
- assstr.Format(L"{\\an7\\pos(%d,%d)\\p%d}", rect.left, rect.top, 1+scale);
- // assstr.Format(L"{\\p%d}", 1+scale);
-
- BYTE lastType = 0;
-
- size_t nPoints = pathTypes.GetCount();
-
- for (size_t i = 0; i < nPoints; i++) {
- CStringW s;
-
- switch (pathTypes[i]) {
- case PT_MOVETO:
- if (lastType != PT_MOVETO) {
- assstr += L"m ";
- }
- s.Format(L"%d %d ", pathPoints[i].x, pathPoints[i].y);
- break;
- case PT_MOVETONC:
- if (lastType != PT_MOVETONC) {
- assstr += L"n ";
- }
- s.Format(L"%d %d ", pathPoints[i].x, pathPoints[i].y);
- break;
- case PT_LINETO:
- if (lastType != PT_LINETO) {
- assstr += L"l ";
- }
- s.Format(L"%d %d ", pathPoints[i].x, pathPoints[i].y);
- break;
- case PT_BEZIERTO:
- if (i+2 < nPoints) {
- if (lastType != PT_BEZIERTO) {
- assstr += L"b ";
- }
- s.Format(L"%d %d %d %d %d %d ", pathPoints[i].x, pathPoints[i].y, pathPoints[i+1].x, pathPoints[i+1].y, pathPoints[i+2].x, pathPoints[i+2].y);
- i+=2;
- }
- break;
- case PT_BSPLINETO:
- if (i+2 < nPoints) {
- if (lastType != PT_BSPLINETO) {
- assstr += L"s ";
- }
- s.Format(L"%d %d %d %d %d %d ", pathPoints[i].x, pathPoints[i].y, pathPoints[i+1].x, pathPoints[i+1].y, pathPoints[i+2].x, pathPoints[i+2].y);
- i+=2;
- }
- break;
- case PT_BSPLINEPATCHTO:
- if (lastType != PT_BSPLINEPATCHTO) {
- assstr += L"p ";
- }
- s.Format(L"%d %d ", pathPoints[i].x, pathPoints[i].y);
- break;
- }
-
- lastType = pathTypes[i];
-
- assstr += s;
- }
-
- assstr += L"{\\p0}";
-
- return nPoints > 0;
+ CAtlArray<BYTE> pathTypes;
+ CAtlArray<CPoint> pathPoints;
+
+ if (!Polygonize(pathTypes, pathPoints, fSmooth, scale)) {
+ return false;
+ }
+
+ assstr.Format(L"{\\an7\\pos(%d,%d)\\p%d}", rect.left, rect.top, 1 + scale);
+ // assstr.Format(L"{\\p%d}", 1+scale);
+
+ BYTE lastType = 0;
+
+ size_t nPoints = pathTypes.GetCount();
+
+ for (size_t i = 0; i < nPoints; i++) {
+ CStringW s;
+
+ switch (pathTypes[i]) {
+ case PT_MOVETO:
+ if (lastType != PT_MOVETO) {
+ assstr += L"m ";
+ }
+ s.Format(L"%d %d ", pathPoints[i].x, pathPoints[i].y);
+ break;
+ case PT_MOVETONC:
+ if (lastType != PT_MOVETONC) {
+ assstr += L"n ";
+ }
+ s.Format(L"%d %d ", pathPoints[i].x, pathPoints[i].y);
+ break;
+ case PT_LINETO:
+ if (lastType != PT_LINETO) {
+ assstr += L"l ";
+ }
+ s.Format(L"%d %d ", pathPoints[i].x, pathPoints[i].y);
+ break;
+ case PT_BEZIERTO:
+ if (i + 2 < nPoints) {
+ if (lastType != PT_BEZIERTO) {
+ assstr += L"b ";
+ }
+ s.Format(L"%d %d %d %d %d %d ", pathPoints[i].x, pathPoints[i].y, pathPoints[i + 1].x, pathPoints[i + 1].y, pathPoints[i + 2].x, pathPoints[i + 2].y);
+ i += 2;
+ }
+ break;
+ case PT_BSPLINETO:
+ if (i + 2 < nPoints) {
+ if (lastType != PT_BSPLINETO) {
+ assstr += L"s ";
+ }
+ s.Format(L"%d %d %d %d %d %d ", pathPoints[i].x, pathPoints[i].y, pathPoints[i + 1].x, pathPoints[i + 1].y, pathPoints[i + 2].x, pathPoints[i + 2].y);
+ i += 2;
+ }
+ break;
+ case PT_BSPLINEPATCHTO:
+ if (lastType != PT_BSPLINEPATCHTO) {
+ assstr += L"p ";
+ }
+ s.Format(L"%d %d ", pathPoints[i].x, pathPoints[i].y);
+ break;
+ }
+
+ lastType = pathTypes[i];
+
+ assstr += s;
+ }
+
+ assstr += L"{\\p0}";
+
+ return nPoints > 0;
}
void CVobSubImage::Scale2x()
{
- int w = rect.Width(), h = rect.Height();
+ int w = rect.Width(), h = rect.Height();
- DWORD* src = (DWORD*)lpPixels;
- DWORD* dst = DNew DWORD[w*h];
+ DWORD* src = (DWORD*)lpPixels;
+ DWORD* dst = DNew DWORD[w * h];
- for (int y = 0; y < h; y++) {
- for (int x = 0; x < w; x++, src++, dst++) {
- DWORD E = *src;
+ for (int y = 0; y < h; y++) {
+ for (int x = 0; x < w; x++, src++, dst++) {
+ DWORD E = *src;
- DWORD A = x > 0 && y > 0 ? src[-w-1] : E;
- DWORD B = y > 0 ? src[-w] : E;
- DWORD C = x < w-1 && y > 0 ? src[-w+1] : E;
- UNREFERENCED_PARAMETER(A);
- UNREFERENCED_PARAMETER(C);
+ DWORD A = x > 0 && y > 0 ? src[-w - 1] : E;
+ DWORD B = y > 0 ? src[-w] : E;
+ DWORD C = x < w - 1 && y > 0 ? src[-w + 1] : E;
+ UNREFERENCED_PARAMETER(A);
+ UNREFERENCED_PARAMETER(C);
- DWORD D = x > 0 ? src[-1] : E;
- DWORD F = x < w-1 ? src[+1] : E;
+ DWORD D = x > 0 ? src[-1] : E;
+ DWORD F = x < w - 1 ? src[+1] : E;
- DWORD G = x > 0 && y < h-1 ? src[+w-1] : E;
- DWORD H = y < h-1 ? src[+w] : E;
- DWORD I = x < w-1 && y < h-1 ? src[+w+1] : E;
- UNREFERENCED_PARAMETER(G);
- UNREFERENCED_PARAMETER(I);
+ DWORD G = x > 0 && y < h - 1 ? src[+w - 1] : E;
+ DWORD H = y < h - 1 ? src[+w] : E;
+ DWORD I = x < w - 1 && y < h - 1 ? src[+w + 1] : E;
+ UNREFERENCED_PARAMETER(G);
+ UNREFERENCED_PARAMETER(I);
- DWORD E0 = D == B && B != F && D != H ? D : E;
- DWORD E1 = B == F && B != D && F != H ? F : E;
- DWORD E2 = D == H && D != B && H != F ? D : E;
- DWORD E3 = H == F && D != H && B != F ? F : E;
+ DWORD E0 = D == B && B != F && D != H ? D : E;
+ DWORD E1 = B == F && B != D && F != H ? F : E;
+ DWORD E2 = D == H && D != B && H != F ? D : E;
+ DWORD E3 = H == F && D != H && B != F ? F : E;
- *dst = ((((E0&0x00ff00ff)+(E1&0x00ff00ff)+(E2&0x00ff00ff)+(E3&0x00ff00ff)+2)>>2)&0x00ff00ff)
- | (((((E0>>8)&0x00ff00ff)+((E1>>8)&0x00ff00ff)+((E2>>8)&0x00ff00ff)+((E3>>8)&0x00ff00ff)+2)<<6)&0xff00ff00);
- }
- }
+ *dst = ((((E0 & 0x00ff00ff) + (E1 & 0x00ff00ff) + (E2 & 0x00ff00ff) + (E3 & 0x00ff00ff) + 2) >> 2) & 0x00ff00ff)
+ | (((((E0 >> 8) & 0x00ff00ff) + ((E1 >> 8) & 0x00ff00ff) + ((E2 >> 8) & 0x00ff00ff) + ((E3 >> 8) & 0x00ff00ff) + 2) << 6) & 0xff00ff00);
+ }
+ }
- src -= w*h;
- dst -= w*h;
+ src -= w * h;
+ dst -= w * h;
- memcpy(src, dst, w*h*4);
+ memcpy(src, dst, w * h * 4);
- delete [] dst;
+ delete [] dst;
}
diff --git a/src/Subtitles/VobSubImage.h b/src/Subtitles/VobSubImage.h
index cee1dddf5..bee6a80b0 100644
--- a/src/Subtitles/VobSubImage.h
+++ b/src/Subtitles/VobSubImage.h
@@ -26,76 +26,74 @@
#include <atlcoll.h>
typedef struct {
- CAtlArray<CPoint> pa;
- CAtlArray<int> da;
- void RemoveAll() {
- pa.RemoveAll();
- da.RemoveAll();
- }
- void Add(CPoint p, int d) {
- pa.Add(p);
- da.Add(d);
- }
+ CAtlArray<CPoint> pa;
+ CAtlArray<int> da;
+ void RemoveAll() {
+ pa.RemoveAll();
+ da.RemoveAll();
+ }
+ void Add(CPoint p, int d) {
+ pa.Add(p);
+ da.Add(d);
+ }
} COutline;
class CVobSubImage
{
- friend class CVobSubFile;
+ friend class CVobSubFile;
private:
- CSize org;
- RGBQUAD* lpTemp1;
- RGBQUAD* lpTemp2;
+ CSize org;
+ RGBQUAD* lpTemp1;
+ RGBQUAD* lpTemp2;
- WORD nOffset[2], nPlane;
- bool fCustomPal;
- char fAligned; // we are also using this for calculations, that's why it is char instead of bool...
- int tridx;
- RGBQUAD* orgpal /*[16]*/,* cuspal /*[4]*/;
+ WORD nOffset[2], nPlane;
+ bool fCustomPal;
+ char fAligned; // we are also using this for calculations, that's why it is char instead of bool...
+ int tridx;
+ RGBQUAD* orgpal /*[16]*/, * cuspal /*[4]*/;
- bool Alloc(int w, int h);
- void Free();
+ bool Alloc(int w, int h);
+ void Free();
- BYTE GetNibble(BYTE* lpData);
- void DrawPixels(CPoint p, int length, int colorid);
- void TrimSubImage();
+ BYTE GetNibble(BYTE* lpData);
+ void DrawPixels(CPoint p, int length, int colorid);
+ void TrimSubImage();
public:
- int iLang, iIdx;
- bool fForced;
- __int64 start, delay;
- CRect rect;
- typedef struct {
- BYTE pal: 4, tr: 4;
- } SubPal;
- SubPal pal[4];
- RGBQUAD* lpPixels;
-
- CVobSubImage();
- virtual ~CVobSubImage();
-
- void Invalidate() {
- iLang = iIdx = -1;
- }
-
- void GetPacketInfo(BYTE* lpData, int packetsize, int datasize);
- bool Decode(BYTE* lpData, int packetsize, int datasize,
- bool fCustomPal,
- int tridx,
- RGBQUAD* orgpal /*[16]*/, RGBQUAD* cuspal /*[4]*/,
- bool fTrim);
-
- /////////
+ int iLang, iIdx;
+ bool fForced;
+ __int64 start, delay;
+ CRect rect;
+ typedef struct {
+ BYTE pal: 4, tr: 4;
+ } SubPal;
+ SubPal pal[4];
+ RGBQUAD* lpPixels;
+
+ CVobSubImage();
+ virtual ~CVobSubImage();
+
+ void Invalidate() { iLang = iIdx = -1; }
+
+ void GetPacketInfo(BYTE* lpData, int packetsize, int datasize);
+ bool Decode(BYTE* lpData, int packetsize, int datasize,
+ bool fCustomPal,
+ int tridx,
+ RGBQUAD* orgpal /*[16]*/, RGBQUAD* cuspal /*[4]*/,
+ bool fTrim);
+
+ /////////
private:
- CAutoPtrList<COutline>* GetOutlineList(CPoint& topleft);
- int GrabSegment(int start, COutline& o, COutline& ret);
- void SplitOutline(COutline& o, COutline& o1, COutline& o2);
- void AddSegment(COutline& o, CAtlArray<BYTE>& pathTypes, CAtlArray<CPoint>& pathPoints);
+ CAutoPtrList<COutline>* GetOutlineList(CPoint& topleft);
+ int GrabSegment(int start, COutline& o, COutline& ret);
+ void SplitOutline(COutline& o, COutline& o1, COutline& o2);
+ void AddSegment(COutline& o, CAtlArray<BYTE>& pathTypes, CAtlArray<CPoint>& pathPoints);
public:
- bool Polygonize(CAtlArray<BYTE>& pathTypes, CAtlArray<CPoint>& pathPoints, bool fSmooth, int scale);
- bool Polygonize(CStringW& assstr, bool fSmooth = true, int scale = 3);
+ bool Polygonize(CAtlArray<BYTE>& pathTypes, CAtlArray<CPoint>& pathPoints, bool fSmooth, int scale);
+ bool Polygonize(CStringW& assstr, bool fSmooth = true, int scale = 3);
- void Scale2x();
+ void Scale2x();
};
diff --git a/src/Subtitles/stdafx.h b/src/Subtitles/stdafx.h
index b00d7a09c..370b3298d 100644
--- a/src/Subtitles/stdafx.h
+++ b/src/Subtitles/stdafx.h
@@ -26,16 +26,16 @@
#include "../DSUtil/SharedInclude.h"
#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#endif
-#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
#ifndef VC_EXTRALEAN
-#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
+#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
#include <afx.h>
-#include <afxwin.h> // MFC core and standard components
+#include <afxwin.h> // MFC core and standard components
#include <crtdefs.h>
#include <BaseClasses/streams.h>
diff --git a/src/filters/FilterApp.cpp b/src/filters/FilterApp.cpp
index 5d0228b46..d57f71d02 100644
--- a/src/filters/FilterApp.cpp
+++ b/src/filters/FilterApp.cpp
@@ -32,22 +32,22 @@ CFilterApp::CFilterApp()
BOOL CFilterApp::InitInstance()
{
- if (!__super::InitInstance()) {
- return FALSE;
- }
+ if (!__super::InitInstance()) {
+ return FALSE;
+ }
- SetRegistryKey(_T("Gabest"));
+ SetRegistryKey(_T("Gabest"));
- DllEntryPoint(AfxGetInstanceHandle(), DLL_PROCESS_ATTACH, 0);
+ DllEntryPoint(AfxGetInstanceHandle(), DLL_PROCESS_ATTACH, 0);
- return TRUE;
+ return TRUE;
}
BOOL CFilterApp::ExitInstance()
{
- DllEntryPoint(AfxGetInstanceHandle(), DLL_PROCESS_DETACH, 0);
+ DllEntryPoint(AfxGetInstanceHandle(), DLL_PROCESS_DETACH, 0);
- return __super::ExitInstance();
+ return __super::ExitInstance();
}
BEGIN_MESSAGE_MAP(CFilterApp, CWinApp)
diff --git a/src/filters/FilterApp.h b/src/filters/FilterApp.h
index 4999d7053..b21360e22 100644
--- a/src/filters/FilterApp.h
+++ b/src/filters/FilterApp.h
@@ -26,10 +26,10 @@
class CFilterApp : public CWinApp
{
public:
- CFilterApp();
+ CFilterApp();
- BOOL InitInstance();
- BOOL ExitInstance();
+ BOOL InitInstance();
+ BOOL ExitInstance();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
};
diff --git a/src/filters/InternalPropertyPage.cpp b/src/filters/InternalPropertyPage.cpp
index 51f91cf70..a7ef8c39a 100644
--- a/src/filters/InternalPropertyPage.cpp
+++ b/src/filters/InternalPropertyPage.cpp
@@ -30,75 +30,75 @@
//
CInternalPropertyPageWnd::CInternalPropertyPageWnd()
- : m_fDirty(false)
- , m_fontheight(13)
+ : m_fDirty(false)
+ , m_fontheight(13)
{
}
BOOL CInternalPropertyPageWnd::Create(IPropertyPageSite* pPageSite, LPCRECT pRect, CWnd* pParentWnd)
{
- if (!pPageSite || !pRect) {
- return FALSE;
- }
-
- m_pPageSite = pPageSite;
-
- if (!m_font.m_hObject) {
- CString face;
- WORD height;
- extern BOOL AFXAPI AfxGetPropSheetFont(CString& strFace, WORD& wSize, BOOL bWizard); // yay
- if (!AfxGetPropSheetFont(face, height, FALSE)) {
- return FALSE;
- }
-
- LOGFONT lf;
- memset(&lf, 0, sizeof(lf));
- _tcscpy_s(lf.lfFaceName, face);
- HDC hDC = ::GetDC(0);
- lf.lfHeight = -MulDiv(height, GetDeviceCaps(hDC, LOGPIXELSY), 72);
- ::ReleaseDC(0, hDC);
- lf.lfWeight = FW_NORMAL;
- lf.lfCharSet = DEFAULT_CHARSET;
- if (!m_font.CreateFontIndirect(&lf)) {
- return FALSE;
- }
-
- lf.lfHeight -= -1;
- _tcscpy_s(lf.lfFaceName, _T("Lucida Console"));
- if (!m_monospacefont.CreateFontIndirect(&lf)) {
- _tcscpy_s(lf.lfFaceName, _T("Courier New"));
- if (!m_monospacefont.CreateFontIndirect(&lf)) {
- return FALSE;
- }
- }
-
- hDC = ::GetDC(0);
- HFONT hFontOld = (HFONT)::SelectObject(hDC, m_font.m_hObject);
- CSize size;
- ::GetTextExtentPoint32(hDC, _T("x"), 1, &size);
- ::SelectObject(hDC, hFontOld);
- ::ReleaseDC(0, hDC);
-
- m_fontheight = size.cy;
- }
-
- LPCTSTR wc = AfxRegisterWndClass(CS_VREDRAW|CS_HREDRAW|CS_DBLCLKS, 0, (HBRUSH)(COLOR_BTNFACE + 1));
- if (!CreateEx(0, wc, _T("CInternalPropertyPageWnd"), WS_CHILDWINDOW, *pRect, pParentWnd, 0)) {
- return FALSE;
- }
-
- SetFont(&m_font);
-
- return TRUE;
+ if (!pPageSite || !pRect) {
+ return FALSE;
+ }
+
+ m_pPageSite = pPageSite;
+
+ if (!m_font.m_hObject) {
+ CString face;
+ WORD height;
+ extern BOOL AFXAPI AfxGetPropSheetFont(CString & strFace, WORD & wSize, BOOL bWizard); // yay
+ if (!AfxGetPropSheetFont(face, height, FALSE)) {
+ return FALSE;
+ }
+
+ LOGFONT lf;
+ memset(&lf, 0, sizeof(lf));
+ _tcscpy_s(lf.lfFaceName, face);
+ HDC hDC = ::GetDC(0);
+ lf.lfHeight = -MulDiv(height, GetDeviceCaps(hDC, LOGPIXELSY), 72);
+ ::ReleaseDC(0, hDC);
+ lf.lfWeight = FW_NORMAL;
+ lf.lfCharSet = DEFAULT_CHARSET;
+ if (!m_font.CreateFontIndirect(&lf)) {
+ return FALSE;
+ }
+
+ lf.lfHeight -= -1;
+ _tcscpy_s(lf.lfFaceName, _T("Lucida Console"));
+ if (!m_monospacefont.CreateFontIndirect(&lf)) {
+ _tcscpy_s(lf.lfFaceName, _T("Courier New"));
+ if (!m_monospacefont.CreateFontIndirect(&lf)) {
+ return FALSE;
+ }
+ }
+
+ hDC = ::GetDC(0);
+ HFONT hFontOld = (HFONT)::SelectObject(hDC, m_font.m_hObject);
+ CSize size;
+ ::GetTextExtentPoint32(hDC, _T("x"), 1, &size);
+ ::SelectObject(hDC, hFontOld);
+ ::ReleaseDC(0, hDC);
+
+ m_fontheight = size.cy;
+ }
+
+ LPCTSTR wc = AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS, 0, (HBRUSH)(COLOR_BTNFACE + 1));
+ if (!CreateEx(0, wc, _T("CInternalPropertyPageWnd"), WS_CHILDWINDOW, *pRect, pParentWnd, 0)) {
+ return FALSE;
+ }
+
+ SetFont(&m_font);
+
+ return TRUE;
}
BOOL CInternalPropertyPageWnd::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
- if (message == WM_COMMAND || message == WM_HSCROLL || message == WM_VSCROLL) {
- SetDirty(true);
- }
+ if (message == WM_COMMAND || message == WM_HSCROLL || message == WM_VSCROLL) {
+ SetDirty(true);
+ }
- return __super::OnWndMsg(message, wParam, lParam, pResult);
+ return __super::OnWndMsg(message, wParam, lParam, pResult);
}
BEGIN_MESSAGE_MAP(CInternalPropertyPageWnd, CWnd)
@@ -109,225 +109,225 @@ END_MESSAGE_MAP()
//
CInternalPropertyPage::CInternalPropertyPage(LPUNKNOWN lpunk, HRESULT* phr)
- : CUnknown(_T("CInternalPropertyPage"), lpunk)
- , m_pWnd(NULL)
+ : CUnknown(_T("CInternalPropertyPage"), lpunk)
+ , m_pWnd(NULL)
{
- if (phr) {
- *phr = S_OK;
- }
+ if (phr) {
+ *phr = S_OK;
+ }
}
CInternalPropertyPage::~CInternalPropertyPage()
{
- if (m_pWnd) {
- if (m_pWnd->m_hWnd) {
- ASSERT(0);
- m_pWnd->DestroyWindow();
- }
- delete m_pWnd;
- m_pWnd = NULL;
- }
+ if (m_pWnd) {
+ if (m_pWnd->m_hWnd) {
+ ASSERT(0);
+ m_pWnd->DestroyWindow();
+ }
+ delete m_pWnd;
+ m_pWnd = NULL;
+ }
}
STDMETHODIMP CInternalPropertyPage::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- return
- QI2(IPropertyPage)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI2(IPropertyPage)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// IPropertyPage
STDMETHODIMP CInternalPropertyPage::SetPageSite(IPropertyPageSite* pPageSite)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- if (pPageSite && m_pPageSite || !pPageSite && !m_pPageSite) {
- return E_UNEXPECTED;
- }
+ if (pPageSite && m_pPageSite || !pPageSite && !m_pPageSite) {
+ return E_UNEXPECTED;
+ }
- m_pPageSite = pPageSite;
+ m_pPageSite = pPageSite;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CInternalPropertyPage::Activate(HWND hwndParent, LPCRECT pRect, BOOL fModal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- CheckPointer(pRect, E_POINTER);
+ CheckPointer(pRect, E_POINTER);
- if (!m_pWnd || m_pWnd->m_hWnd || m_pUnks.IsEmpty()) {
- return E_UNEXPECTED;
- }
+ if (!m_pWnd || m_pWnd->m_hWnd || m_pUnks.IsEmpty()) {
+ return E_UNEXPECTED;
+ }
- if (!m_pWnd->Create(m_pPageSite, pRect, CWnd::FromHandle(hwndParent))) {
- return E_OUTOFMEMORY;
- }
+ if (!m_pWnd->Create(m_pPageSite, pRect, CWnd::FromHandle(hwndParent))) {
+ return E_OUTOFMEMORY;
+ }
- if (!m_pWnd->OnActivate()) {
- m_pWnd->DestroyWindow();
- return E_FAIL;
- }
+ if (!m_pWnd->OnActivate()) {
+ m_pWnd->DestroyWindow();
+ return E_FAIL;
+ }
- m_pWnd->ModifyStyleEx(WS_EX_DLGMODALFRAME, WS_EX_CONTROLPARENT);
- m_pWnd->ShowWindow(SW_SHOWNORMAL);
+ m_pWnd->ModifyStyleEx(WS_EX_DLGMODALFRAME, WS_EX_CONTROLPARENT);
+ m_pWnd->ShowWindow(SW_SHOWNORMAL);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CInternalPropertyPage::Deactivate()
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- if (!m_pWnd || !m_pWnd->m_hWnd) {
- return E_UNEXPECTED;
- }
+ if (!m_pWnd || !m_pWnd->m_hWnd) {
+ return E_UNEXPECTED;
+ }
- m_pWnd->OnDeactivate();
+ m_pWnd->OnDeactivate();
- m_pWnd->ModifyStyleEx(WS_EX_CONTROLPARENT, 0);
- m_pWnd->DestroyWindow();
+ m_pWnd->ModifyStyleEx(WS_EX_CONTROLPARENT, 0);
+ m_pWnd->DestroyWindow();
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CInternalPropertyPage::GetPageInfo(PROPPAGEINFO* pPageInfo)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- CheckPointer(pPageInfo, E_POINTER);
+ CheckPointer(pPageInfo, E_POINTER);
- LPOLESTR pszTitle;
- HRESULT hr = AMGetWideString(CStringW(GetWindowTitle()), &pszTitle);
- if (FAILED(hr)) {
- return hr;
- }
+ LPOLESTR pszTitle;
+ HRESULT hr = AMGetWideString(CStringW(GetWindowTitle()), &pszTitle);
+ if (FAILED(hr)) {
+ return hr;
+ }
- pPageInfo->cb = sizeof(PROPPAGEINFO);
- pPageInfo->pszTitle = pszTitle;
- pPageInfo->pszDocString = NULL;
- pPageInfo->pszHelpFile = NULL;
- pPageInfo->dwHelpContext = 0;
- pPageInfo->size = GetWindowSize();
+ pPageInfo->cb = sizeof(PROPPAGEINFO);
+ pPageInfo->pszTitle = pszTitle;
+ pPageInfo->pszDocString = NULL;
+ pPageInfo->pszHelpFile = NULL;
+ pPageInfo->dwHelpContext = 0;
+ pPageInfo->size = GetWindowSize();
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CInternalPropertyPage::SetObjects(ULONG cObjects, LPUNKNOWN* ppUnk)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- if (cObjects && m_pWnd || !cObjects && !m_pWnd) {
- return E_UNEXPECTED;
- }
+ if (cObjects && m_pWnd || !cObjects && !m_pWnd) {
+ return E_UNEXPECTED;
+ }
- m_pUnks.RemoveAll();
+ m_pUnks.RemoveAll();
- if (cObjects > 0) {
- CheckPointer(ppUnk, E_POINTER);
+ if (cObjects > 0) {
+ CheckPointer(ppUnk, E_POINTER);
- for (ULONG i = 0; i < cObjects; i++) {
- m_pUnks.AddTail(ppUnk[i]);
- }
+ for (ULONG i = 0; i < cObjects; i++) {
+ m_pUnks.AddTail(ppUnk[i]);
+ }
- m_pWnd = GetWindow();
- if (!m_pWnd) {
- return E_OUTOFMEMORY;
- }
+ m_pWnd = GetWindow();
+ if (!m_pWnd) {
+ return E_OUTOFMEMORY;
+ }
- if (!m_pWnd->OnConnect(m_pUnks)) {
- delete m_pWnd;
- m_pWnd = NULL;
+ if (!m_pWnd->OnConnect(m_pUnks)) {
+ delete m_pWnd;
+ m_pWnd = NULL;
- return E_FAIL;
- }
- } else {
- m_pWnd->OnDisconnect();
+ return E_FAIL;
+ }
+ } else {
+ m_pWnd->OnDisconnect();
- m_pWnd->DestroyWindow();
- delete m_pWnd;
- m_pWnd = NULL;
- }
+ m_pWnd->DestroyWindow();
+ delete m_pWnd;
+ m_pWnd = NULL;
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CInternalPropertyPage::Show(UINT nCmdShow)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- if (!m_pWnd) {
- return E_UNEXPECTED;
- }
+ if (!m_pWnd) {
+ return E_UNEXPECTED;
+ }
- if ((nCmdShow != SW_SHOW) && (nCmdShow != SW_SHOWNORMAL) && (nCmdShow != SW_HIDE)) {
- return E_INVALIDARG;
- }
+ if ((nCmdShow != SW_SHOW) && (nCmdShow != SW_SHOWNORMAL) && (nCmdShow != SW_HIDE)) {
+ return E_INVALIDARG;
+ }
- m_pWnd->ShowWindow(nCmdShow);
- m_pWnd->Invalidate();
+ m_pWnd->ShowWindow(nCmdShow);
+ m_pWnd->Invalidate();
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CInternalPropertyPage::Move(LPCRECT pRect)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- CheckPointer(pRect, E_POINTER);
+ CheckPointer(pRect, E_POINTER);
- if (!m_pWnd) {
- return E_UNEXPECTED;
- }
+ if (!m_pWnd) {
+ return E_UNEXPECTED;
+ }
- m_pWnd->MoveWindow(pRect, TRUE);
+ m_pWnd->MoveWindow(pRect, TRUE);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CInternalPropertyPage::IsPageDirty()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return m_pWnd && m_pWnd->GetDirty() ? S_OK : S_FALSE;
+ return m_pWnd && m_pWnd->GetDirty() ? S_OK : S_FALSE;
}
STDMETHODIMP CInternalPropertyPage::Apply()
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- if (!m_pWnd || m_pUnks.IsEmpty() || !m_pPageSite) {
- return E_UNEXPECTED;
- }
+ if (!m_pWnd || m_pUnks.IsEmpty() || !m_pPageSite) {
+ return E_UNEXPECTED;
+ }
- if (m_pWnd->GetDirty() && m_pWnd->OnApply()) {
- m_pWnd->SetDirty(false);
- }
+ if (m_pWnd->GetDirty() && m_pWnd->OnApply()) {
+ m_pWnd->SetDirty(false);
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CInternalPropertyPage::Help(LPCWSTR lpszHelpDir)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CInternalPropertyPage::TranslateAccelerator(LPMSG lpMsg)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
diff --git a/src/filters/InternalPropertyPage.h b/src/filters/InternalPropertyPage.h
index b4a57ac3a..7f6798295 100644
--- a/src/filters/InternalPropertyPage.h
+++ b/src/filters/InternalPropertyPage.h
@@ -28,107 +28,107 @@
interface __declspec(uuid("03481710-D73E-4674-839F-03EDE2D60ED8"))
ISpecifyPropertyPages2 :
public ISpecifyPropertyPages {
- STDMETHOD (CreatePage) (const GUID& guid, IPropertyPage** ppPage) = 0;
+ STDMETHOD(CreatePage)(const GUID & guid, IPropertyPage** ppPage) = 0;
};
class CInternalPropertyPageWnd : public CWnd
{
- bool m_fDirty;
- CComPtr<IPropertyPageSite> m_pPageSite;
+ bool m_fDirty;
+ CComPtr<IPropertyPageSite> m_pPageSite;
protected:
- CFont m_font, m_monospacefont;
- int m_fontheight;
+ CFont m_font, m_monospacefont;
+ int m_fontheight;
- virtual BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult);
+ virtual BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult);
public:
- CInternalPropertyPageWnd();
-
- void SetDirty(bool fDirty = true) {
- m_fDirty = fDirty;
- if (m_pPageSite) {
- if (fDirty) {
- m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);
- } else {
- m_pPageSite->OnStatusChange(PROPPAGESTATUS_CLEAN);
- }
- }
- }
- bool GetDirty() {
- return m_fDirty;
- }
-
- virtual BOOL Create(IPropertyPageSite* pPageSite, LPCRECT pRect, CWnd* pParentWnd);
-
- virtual bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks) {
- return true;
- }
- virtual void OnDisconnect() {}
- virtual bool OnActivate() {
- return true;
- }
- virtual void OnDeactivate() {}
- virtual bool OnApply() {
- return true;
- }
-
- DECLARE_MESSAGE_MAP()
+ CInternalPropertyPageWnd();
+
+ void SetDirty(bool fDirty = true) {
+ m_fDirty = fDirty;
+ if (m_pPageSite) {
+ if (fDirty) {
+ m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);
+ } else {
+ m_pPageSite->OnStatusChange(PROPPAGESTATUS_CLEAN);
+ }
+ }
+ }
+ bool GetDirty() {
+ return m_fDirty;
+ }
+
+ virtual BOOL Create(IPropertyPageSite* pPageSite, LPCRECT pRect, CWnd* pParentWnd);
+
+ virtual bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks) {
+ return true;
+ }
+ virtual void OnDisconnect() {}
+ virtual bool OnActivate() {
+ return true;
+ }
+ virtual void OnDeactivate() {}
+ virtual bool OnApply() {
+ return true;
+ }
+
+ DECLARE_MESSAGE_MAP()
};
class CInternalPropertyPage
- : public CUnknown
- , public IPropertyPage
- , public CCritSec
+ : public CUnknown
+ , public IPropertyPage
+ , public CCritSec
{
- CComPtr<IPropertyPageSite> m_pPageSite;
- CInterfaceList<IUnknown, &IID_IUnknown> m_pUnks;
- CInternalPropertyPageWnd* m_pWnd;
+ CComPtr<IPropertyPageSite> m_pPageSite;
+ CInterfaceList<IUnknown, &IID_IUnknown> m_pUnks;
+ CInternalPropertyPageWnd* m_pWnd;
protected:
- virtual CInternalPropertyPageWnd* GetWindow() = 0;
- virtual LPCTSTR GetWindowTitle() = 0;
- virtual CSize GetWindowSize() = 0;
+ virtual CInternalPropertyPageWnd* GetWindow() = 0;
+ virtual LPCTSTR GetWindowTitle() = 0;
+ virtual CSize GetWindowSize() = 0;
public:
- CInternalPropertyPage(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CInternalPropertyPage();
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // IPropertyPage
-
- STDMETHODIMP SetPageSite(IPropertyPageSite* pPageSite);
- STDMETHODIMP Activate(HWND hwndParent, LPCRECT pRect, BOOL fModal);
- STDMETHODIMP Deactivate();
- STDMETHODIMP GetPageInfo(PROPPAGEINFO* pPageInfo);
- STDMETHODIMP SetObjects(ULONG cObjects, LPUNKNOWN* ppUnk);
- STDMETHODIMP Show(UINT nCmdShow);
- STDMETHODIMP Move(LPCRECT prect);
- STDMETHODIMP IsPageDirty();
- STDMETHODIMP Apply();
- STDMETHODIMP Help(LPCWSTR lpszHelpDir);
- STDMETHODIMP TranslateAccelerator(LPMSG lpMsg);
+ CInternalPropertyPage(LPUNKNOWN lpunk, HRESULT* phr);
+ virtual ~CInternalPropertyPage();
+
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ // IPropertyPage
+
+ STDMETHODIMP SetPageSite(IPropertyPageSite* pPageSite);
+ STDMETHODIMP Activate(HWND hwndParent, LPCRECT pRect, BOOL fModal);
+ STDMETHODIMP Deactivate();
+ STDMETHODIMP GetPageInfo(PROPPAGEINFO* pPageInfo);
+ STDMETHODIMP SetObjects(ULONG cObjects, LPUNKNOWN* ppUnk);
+ STDMETHODIMP Show(UINT nCmdShow);
+ STDMETHODIMP Move(LPCRECT prect);
+ STDMETHODIMP IsPageDirty();
+ STDMETHODIMP Apply();
+ STDMETHODIMP Help(LPCWSTR lpszHelpDir);
+ STDMETHODIMP TranslateAccelerator(LPMSG lpMsg);
};
template<class WndClass>
class CInternalPropertyPageTempl : public CInternalPropertyPage
{
- virtual CInternalPropertyPageWnd* GetWindow() {
- return DNew WndClass();
- }
+ virtual CInternalPropertyPageWnd* GetWindow() {
+ return DNew WndClass();
+ }
- virtual LPCTSTR GetWindowTitle() {
- return WndClass::GetWindowTitle();
- }
+ virtual LPCTSTR GetWindowTitle() {
+ return WndClass::GetWindowTitle();
+ }
- virtual CSize GetWindowSize() {
- return WndClass::GetWindowSize();
- }
+ virtual CSize GetWindowSize() {
+ return WndClass::GetWindowSize();
+ }
public:
- CInternalPropertyPageTempl(LPUNKNOWN lpunk, HRESULT* phr)
- : CInternalPropertyPage(lpunk, phr) {
- }
+ CInternalPropertyPageTempl(LPUNKNOWN lpunk, HRESULT* phr)
+ : CInternalPropertyPage(lpunk, phr) {
+ }
};
diff --git a/src/filters/PinInfoWnd.cpp b/src/filters/PinInfoWnd.cpp
index 3d174defc..06b17dbae 100644
--- a/src/filters/PinInfoWnd.cpp
+++ b/src/filters/PinInfoWnd.cpp
@@ -35,90 +35,90 @@ CPinInfoWnd::CPinInfoWnd()
bool CPinInfoWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
{
- ASSERT(!m_pBF);
+ ASSERT(!m_pBF);
- m_pBF.Release();
+ m_pBF.Release();
- POSITION pos = pUnks.GetHeadPosition();
- while (pos && !(m_pBF = pUnks.GetNext(pos))) {
- ;
- }
+ POSITION pos = pUnks.GetHeadPosition();
+ while (pos && !(m_pBF = pUnks.GetNext(pos))) {
+ ;
+ }
- if (!m_pBF) {
- return false;
- }
+ if (!m_pBF) {
+ return false;
+ }
- return true;
+ return true;
}
void CPinInfoWnd::OnDisconnect()
{
- m_pBF.Release();
+ m_pBF.Release();
}
static WNDPROC OldControlProc;
static LRESULT CALLBACK ControlProc(HWND control, UINT message, WPARAM wParam, LPARAM lParam)
{
- if (message == WM_KEYDOWN) {
- if (LOWORD(wParam)==VK_ESCAPE) {
- return 0; // just ignore ESCAPE in edit control
- }
- if ((LOWORD(wParam)== 'A' || LOWORD(wParam) == 'a')
- &&(GetKeyState(VK_CONTROL) < 0)) {
- CEdit *pEdit = (CEdit*)CWnd::FromHandle(control);
- pEdit->SetSel(0, pEdit->GetWindowTextLength(),TRUE);
- return 0;
- }
- }
-
- return CallWindowProc(OldControlProc, control, message, wParam, lParam); // call edit control's own windowproc
+ if (message == WM_KEYDOWN) {
+ if (LOWORD(wParam) == VK_ESCAPE) {
+ return 0; // just ignore ESCAPE in edit control
+ }
+ if ((LOWORD(wParam) == 'A' || LOWORD(wParam) == 'a')
+ && (GetKeyState(VK_CONTROL) < 0)) {
+ CEdit* pEdit = (CEdit*)CWnd::FromHandle(control);
+ pEdit->SetSel(0, pEdit->GetWindowTextLength(), TRUE);
+ return 0;
+ }
+ }
+
+ return CallWindowProc(OldControlProc, control, message, wParam, lParam); // call edit control's own windowproc
}
bool CPinInfoWnd::OnActivate()
{
- DWORD dwStyle = WS_VISIBLE|WS_CHILD|WS_TABSTOP;
-
- CPoint p(10, 10);
-
- m_pin_static.Create(_T("Pin:"), dwStyle, CRect(p + CPoint(0, 3), CSize(30, m_fontheight)), this);
- m_pin_combo.Create(dwStyle|CBS_DROPDOWNLIST, CRect(p + CPoint(30, 0), CSize(450, 200)), this, IDC_PP_COMBO1);
- BeginEnumPins(m_pBF, pEP, pPin) {
- CPinInfo pi;
- if (FAILED(pPin->QueryPinInfo(&pi))) {
- continue;
- }
- CString str = CString(pi.achName);
- if (!str.Find(_T("Apple"))) {
- str.Delete(0,1);
- }
- CString dir = _T("[?] ");
- if (pi.dir == PINDIR_INPUT) {
- dir = _T("[IN] ");
- } else if (pi.dir == PINDIR_OUTPUT) {
- dir = _T("[OUT] ");
- }
- m_pin_combo.SetItemDataPtr(m_pin_combo.AddString(dir + str), pPin);
- }
- EndEnumPins
- m_pin_combo.SetCurSel(0);
-
- p.y += m_fontheight + 20;
-
- m_info_edit.CreateEx(WS_EX_CLIENTEDGE, _T("EDIT"), _T(""), dwStyle|WS_BORDER|WS_VSCROLL|WS_HSCROLL|ES_MULTILINE|ES_AUTOHSCROLL|ES_READONLY, CRect(p, CSize(480, m_fontheight*20)), this, IDC_PP_EDIT1);
- m_info_edit.SetLimitText(60000);
-
- OnCbnSelchangeCombo1();
-
- for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
- pWnd->SetFont(&m_font, FALSE);
- }
-
- m_info_edit.SetFont(&m_monospacefont);
-
- // subclass the edit control
- OldControlProc = (WNDPROC) SetWindowLongPtr(m_info_edit.m_hWnd, GWLP_WNDPROC, (LONG_PTR) ControlProc);
-
- return true;
+ DWORD dwStyle = WS_VISIBLE | WS_CHILD | WS_TABSTOP;
+
+ CPoint p(10, 10);
+
+ m_pin_static.Create(_T("Pin:"), dwStyle, CRect(p + CPoint(0, 3), CSize(30, m_fontheight)), this);
+ m_pin_combo.Create(dwStyle | CBS_DROPDOWNLIST, CRect(p + CPoint(30, 0), CSize(450, 200)), this, IDC_PP_COMBO1);
+ BeginEnumPins(m_pBF, pEP, pPin) {
+ CPinInfo pi;
+ if (FAILED(pPin->QueryPinInfo(&pi))) {
+ continue;
+ }
+ CString str = CString(pi.achName);
+ if (!str.Find(_T("Apple"))) {
+ str.Delete(0, 1);
+ }
+ CString dir = _T("[?] ");
+ if (pi.dir == PINDIR_INPUT) {
+ dir = _T("[IN] ");
+ } else if (pi.dir == PINDIR_OUTPUT) {
+ dir = _T("[OUT] ");
+ }
+ m_pin_combo.SetItemDataPtr(m_pin_combo.AddString(dir + str), pPin);
+ }
+ EndEnumPins
+ m_pin_combo.SetCurSel(0);
+
+ p.y += m_fontheight + 20;
+
+ m_info_edit.CreateEx(WS_EX_CLIENTEDGE, _T("EDIT"), _T(""), dwStyle | WS_BORDER | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY, CRect(p, CSize(480, m_fontheight * 20)), this, IDC_PP_EDIT1);
+ m_info_edit.SetLimitText(60000);
+
+ OnCbnSelchangeCombo1();
+
+ for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
+ pWnd->SetFont(&m_font, FALSE);
+ }
+
+ m_info_edit.SetFont(&m_monospacefont);
+
+ // subclass the edit control
+ OldControlProc = (WNDPROC) SetWindowLongPtr(m_info_edit.m_hWnd, GWLP_WNDPROC, (LONG_PTR) ControlProc);
+
+ return true;
}
void CPinInfoWnd::OnDeactivate()
@@ -127,118 +127,118 @@ void CPinInfoWnd::OnDeactivate()
bool CPinInfoWnd::OnApply()
{
- OnDeactivate();
+ OnDeactivate();
- if (m_pBF) {
- }
+ if (m_pBF) {
+ }
- return true;
+ return true;
}
BOOL CPinInfoWnd::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
- SetDirty(false);
- return __super::OnWndMsg(message, wParam, lParam, pResult);
+ SetDirty(false);
+ return __super::OnWndMsg(message, wParam, lParam, pResult);
}
BEGIN_MESSAGE_MAP(CPinInfoWnd, CInternalPropertyPageWnd)
- ON_CBN_SELCHANGE(IDC_PP_COMBO1, OnCbnSelchangeCombo1)
+ ON_CBN_SELCHANGE(IDC_PP_COMBO1, OnCbnSelchangeCombo1)
END_MESSAGE_MAP()
void CPinInfoWnd::AddLine(CString str)
{
- str.Replace(_T("\n"), _T("\r\n"));
- int len = m_info_edit.GetWindowTextLength();
- m_info_edit.SetSel(len, len, TRUE);
- m_info_edit.ReplaceSel(str);
+ str.Replace(_T("\n"), _T("\r\n"));
+ int len = m_info_edit.GetWindowTextLength();
+ m_info_edit.SetSel(len, len, TRUE);
+ m_info_edit.ReplaceSel(str);
}
void CPinInfoWnd::OnCbnSelchangeCombo1()
{
- m_info_edit.SetWindowText(_T(""));
-
- int i = m_pin_combo.GetCurSel();
- if (i < 0) {
- return;
- }
-
- CComPtr<IPin> pPin = (IPin*)m_pin_combo.GetItemDataPtr(i);
- if (!pPin) {
- return;
- }
-
- CString str;
-
- PIN_INFO PinInfo;
- if (SUCCEEDED (pPin->QueryPinInfo(&PinInfo))) {
- CString strName;
- CLSID FilterClsid;
- FILTER_INFO FilterInfo;
-
- if (SUCCEEDED (PinInfo.pFilter->QueryFilterInfo (&FilterInfo))) {
- CRegKey key;
- PinInfo.pFilter->GetClassID(&FilterClsid);
- if (ERROR_SUCCESS == key.Open (HKEY_CLASSES_ROOT, _T("CLSID\\{083863F1-70DE-11D0-BD40-00A0C911CE86}\\Instance\\") + CStringFromGUID(FilterClsid), KEY_READ)) {
- ULONG len;
- TCHAR buff[128];
- len = _countof(buff);
- key.QueryStringValue(_T("FriendlyName"), buff, &len);
- strName = CString (buff);
- } else {
- strName = FilterInfo.achName;
- }
- str.Format (_T("Filter : %s - CLSID : %s\n\n"), strName, CStringFromGUID(FilterClsid));
- AddLine(str);
- FilterInfo.pGraph->Release();
- }
- PinInfo.pFilter->Release();
- }
-
- CMediaTypeEx cmt;
-
- CComPtr<IPin> pPinTo;
- if (SUCCEEDED(pPin->ConnectedTo(&pPinTo)) && pPinTo) {
- str.Format(_T("- Connected to:\n\nCLSID: %s\nFilter: %s\nPin: %s\n\n"),
- CString(CStringFromGUID(GetCLSID(pPinTo))),
- CString(GetFilterName(GetFilterFromPin(pPinTo))),
- CString(GetPinName(pPinTo)));
-
- AddLine(str);
-
- AddLine(_T("- Connection media type:\n\n"));
-
- if (SUCCEEDED(pPin->ConnectionMediaType(&cmt))) {
- CAtlList<CString> sl;
- cmt.Dump(sl);
- POSITION pos = sl.GetHeadPosition();
- while (pos) {
- AddLine(sl.GetNext(pos) + '\n');
- }
- }
- } else {
- str = _T("- Not connected\n\n");
- }
-
- int iMT = 0;
-
- BeginEnumMediaTypes(pPin, pEMT, pmt) {
- CMediaTypeEx mt(*pmt);
-
- str.Format(_T("- Enumerated media type %d:\n\n"), iMT++);
- AddLine(str);
-
- if (cmt.majortype != GUID_NULL && mt == cmt) {
- AddLine(_T("Set as the current media type\n\n"));
- } else {
- CAtlList<CString> sl;
- mt.Dump(sl);
- POSITION pos = sl.GetHeadPosition();
- while (pos) {
- AddLine(sl.GetNext(pos) + '\n');
- }
- }
- }
- EndEnumMediaTypes(pmt)
-
- m_info_edit.SetSel(0, 0);
+ m_info_edit.SetWindowText(_T(""));
+
+ int i = m_pin_combo.GetCurSel();
+ if (i < 0) {
+ return;
+ }
+
+ CComPtr<IPin> pPin = (IPin*)m_pin_combo.GetItemDataPtr(i);
+ if (!pPin) {
+ return;
+ }
+
+ CString str;
+
+ PIN_INFO PinInfo;
+ if (SUCCEEDED(pPin->QueryPinInfo(&PinInfo))) {
+ CString strName;
+ CLSID FilterClsid;
+ FILTER_INFO FilterInfo;
+
+ if (SUCCEEDED(PinInfo.pFilter->QueryFilterInfo(&FilterInfo))) {
+ CRegKey key;
+ PinInfo.pFilter->GetClassID(&FilterClsid);
+ if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("CLSID\\{083863F1-70DE-11D0-BD40-00A0C911CE86}\\Instance\\") + CStringFromGUID(FilterClsid), KEY_READ)) {
+ ULONG len;
+ TCHAR buff[128];
+ len = _countof(buff);
+ key.QueryStringValue(_T("FriendlyName"), buff, &len);
+ strName = CString(buff);
+ } else {
+ strName = FilterInfo.achName;
+ }
+ str.Format(_T("Filter : %s - CLSID : %s\n\n"), strName, CStringFromGUID(FilterClsid));
+ AddLine(str);
+ FilterInfo.pGraph->Release();
+ }
+ PinInfo.pFilter->Release();
+ }
+
+ CMediaTypeEx cmt;
+
+ CComPtr<IPin> pPinTo;
+ if (SUCCEEDED(pPin->ConnectedTo(&pPinTo)) && pPinTo) {
+ str.Format(_T("- Connected to:\n\nCLSID: %s\nFilter: %s\nPin: %s\n\n"),
+ CString(CStringFromGUID(GetCLSID(pPinTo))),
+ CString(GetFilterName(GetFilterFromPin(pPinTo))),
+ CString(GetPinName(pPinTo)));
+
+ AddLine(str);
+
+ AddLine(_T("- Connection media type:\n\n"));
+
+ if (SUCCEEDED(pPin->ConnectionMediaType(&cmt))) {
+ CAtlList<CString> sl;
+ cmt.Dump(sl);
+ POSITION pos = sl.GetHeadPosition();
+ while (pos) {
+ AddLine(sl.GetNext(pos) + '\n');
+ }
+ }
+ } else {
+ str = _T("- Not connected\n\n");
+ }
+
+ int iMT = 0;
+
+ BeginEnumMediaTypes(pPin, pEMT, pmt) {
+ CMediaTypeEx mt(*pmt);
+
+ str.Format(_T("- Enumerated media type %d:\n\n"), iMT++);
+ AddLine(str);
+
+ if (cmt.majortype != GUID_NULL && mt == cmt) {
+ AddLine(_T("Set as the current media type\n\n"));
+ } else {
+ CAtlList<CString> sl;
+ mt.Dump(sl);
+ POSITION pos = sl.GetHeadPosition();
+ while (pos) {
+ AddLine(sl.GetNext(pos) + '\n');
+ }
+ }
+ }
+ EndEnumMediaTypes(pmt)
+
+ m_info_edit.SetSel(0, 0);
} \ No newline at end of file
diff --git a/src/filters/PinInfoWnd.h b/src/filters/PinInfoWnd.h
index 29bef9f15..76595a8ae 100644
--- a/src/filters/PinInfoWnd.h
+++ b/src/filters/PinInfoWnd.h
@@ -27,41 +27,41 @@
#include <afxcmn.h>
class __declspec(uuid("A1EB391C-6089-4A87-9988-BE50872317D4"))
- CPinInfoWnd : public CInternalPropertyPageWnd
+ CPinInfoWnd : public CInternalPropertyPageWnd
{
- CComQIPtr<IBaseFilter> m_pBF;
+ CComQIPtr<IBaseFilter> m_pBF;
- enum {
- IDC_PP_COMBO1 = 10000,
- IDC_PP_EDIT1,
- };
+ enum {
+ IDC_PP_COMBO1 = 10000,
+ IDC_PP_EDIT1,
+ };
- CStatic m_pin_static;
- CComboBox m_pin_combo;
- CEdit m_info_edit;
+ CStatic m_pin_static;
+ CComboBox m_pin_combo;
+ CEdit m_info_edit;
- void AddLine(CString str);
+ void AddLine(CString str);
public:
- CPinInfoWnd();
+ CPinInfoWnd();
- bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
- void OnDisconnect();
- bool OnActivate();
- void OnDeactivate();
- bool OnApply();
+ bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
+ void OnDisconnect();
+ bool OnActivate();
+ void OnDeactivate();
+ bool OnApply();
- static LPCTSTR GetWindowTitle() {
- return _T("Pin Info");
- }
- static CSize GetWindowSize() {
- return CSize(500, 300);
- }
+ static LPCTSTR GetWindowTitle() {
+ return _T("Pin Info");
+ }
+ static CSize GetWindowSize() {
+ return CSize(500, 300);
+ }
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
- void OnCbnSelchangeCombo1();
+ void OnCbnSelchangeCombo1();
protected:
- virtual BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult);
+ virtual BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult);
};
diff --git a/src/filters/muxer/BaseMuxer/BaseMuxer.cpp b/src/filters/muxer/BaseMuxer/BaseMuxer.cpp
index 49f702e1a..53236560a 100644
--- a/src/filters/muxer/BaseMuxer/BaseMuxer.cpp
+++ b/src/filters/muxer/BaseMuxer/BaseMuxer.cpp
@@ -29,14 +29,14 @@
//
CBaseMuxerFilter::CBaseMuxerFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLSID& clsid)
- : CBaseFilter(NAME("CBaseMuxerFilter"), pUnk, this, clsid)
- , m_rtCurrent(0)
+ : CBaseFilter(NAME("CBaseMuxerFilter"), pUnk, this, clsid)
+ , m_rtCurrent(0)
{
- if (phr) {
- *phr = S_OK;
- }
- m_pOutput.Attach(DNew CBaseMuxerOutputPin(L"Output", this, this, phr));
- AddInput();
+ if (phr) {
+ *phr = S_OK;
+ }
+ m_pOutput.Attach(DNew CBaseMuxerOutputPin(L"Output", this, this, phr));
+ AddInput();
}
CBaseMuxerFilter::~CBaseMuxerFilter()
@@ -45,472 +45,472 @@ CBaseMuxerFilter::~CBaseMuxerFilter()
STDMETHODIMP CBaseMuxerFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- *ppv = NULL;
+ *ppv = NULL;
- return
- QI(IMediaSeeking)
- QI(IPropertyBag)
- QI(IPropertyBag2)
- QI(IDSMPropertyBag)
- QI(IDSMResourceBag)
- QI(IDSMChapterBag)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IMediaSeeking)
+ QI(IPropertyBag)
+ QI(IPropertyBag2)
+ QI(IDSMPropertyBag)
+ QI(IDSMResourceBag)
+ QI(IDSMChapterBag)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
//
void CBaseMuxerFilter::AddInput()
{
- POSITION pos = m_pInputs.GetHeadPosition();
- while (pos) {
- CBasePin* pPin = m_pInputs.GetNext(pos);
- if (!pPin->IsConnected()) {
- return;
- }
- }
+ POSITION pos = m_pInputs.GetHeadPosition();
+ while (pos) {
+ CBasePin* pPin = m_pInputs.GetNext(pos);
+ if (!pPin->IsConnected()) {
+ return;
+ }
+ }
- CStringW name;
+ CStringW name;
- name.Format(L"Input %d", m_pInputs.GetCount()+1);
+ name.Format(L"Input %d", m_pInputs.GetCount() + 1);
- CBaseMuxerInputPin* pInputPin = NULL;
- if (FAILED(CreateInput(name, &pInputPin)) || !pInputPin) {
- ASSERT(0);
- return;
- }
- CAutoPtr<CBaseMuxerInputPin> pAutoPtrInputPin(pInputPin);
+ CBaseMuxerInputPin* pInputPin = NULL;
+ if (FAILED(CreateInput(name, &pInputPin)) || !pInputPin) {
+ ASSERT(0);
+ return;
+ }
+ CAutoPtr<CBaseMuxerInputPin> pAutoPtrInputPin(pInputPin);
- name.Format(L"~Output %d", m_pRawOutputs.GetCount()+1);
+ name.Format(L"~Output %d", m_pRawOutputs.GetCount() + 1);
- CBaseMuxerRawOutputPin* pRawOutputPin = NULL;
- if (FAILED(CreateRawOutput(name, &pRawOutputPin)) || !pRawOutputPin) {
- ASSERT(0);
- return;
- }
- CAutoPtr<CBaseMuxerRawOutputPin> pAutoPtrRawOutputPin(pRawOutputPin);
+ CBaseMuxerRawOutputPin* pRawOutputPin = NULL;
+ if (FAILED(CreateRawOutput(name, &pRawOutputPin)) || !pRawOutputPin) {
+ ASSERT(0);
+ return;
+ }
+ CAutoPtr<CBaseMuxerRawOutputPin> pAutoPtrRawOutputPin(pRawOutputPin);
- pInputPin->SetRelatedPin(pRawOutputPin);
- pRawOutputPin->SetRelatedPin(pInputPin);
+ pInputPin->SetRelatedPin(pRawOutputPin);
+ pRawOutputPin->SetRelatedPin(pInputPin);
- m_pInputs.AddTail(pAutoPtrInputPin);
- m_pRawOutputs.AddTail(pAutoPtrRawOutputPin);
+ m_pInputs.AddTail(pAutoPtrInputPin);
+ m_pRawOutputs.AddTail(pAutoPtrRawOutputPin);
}
HRESULT CBaseMuxerFilter::CreateInput(CStringW name, CBaseMuxerInputPin** ppPin)
{
- CheckPointer(ppPin, E_POINTER);
- HRESULT hr = S_OK;
- *ppPin = DNew CBaseMuxerInputPin(name, this, this, &hr);
- return hr;
+ CheckPointer(ppPin, E_POINTER);
+ HRESULT hr = S_OK;
+ *ppPin = DNew CBaseMuxerInputPin(name, this, this, &hr);
+ return hr;
}
HRESULT CBaseMuxerFilter::CreateRawOutput(CStringW name, CBaseMuxerRawOutputPin** ppPin)
{
- CheckPointer(ppPin, E_POINTER);
- HRESULT hr = S_OK;
- *ppPin = DNew CBaseMuxerRawOutputPin(name, this, this, &hr);
- return hr;
+ CheckPointer(ppPin, E_POINTER);
+ HRESULT hr = S_OK;
+ *ppPin = DNew CBaseMuxerRawOutputPin(name, this, this, &hr);
+ return hr;
}
//
DWORD CBaseMuxerFilter::ThreadProc()
{
- SetThreadPriority(m_hThread, THREAD_PRIORITY_ABOVE_NORMAL);
+ SetThreadPriority(m_hThread, THREAD_PRIORITY_ABOVE_NORMAL);
- POSITION pos;
+ POSITION pos;
- for (;;) {
- DWORD cmd = GetRequest();
+ for (;;) {
+ DWORD cmd = GetRequest();
- switch (cmd) {
- default:
- case CMD_EXIT:
- CAMThread::m_hThread = NULL;
- Reply(S_OK);
- return 0;
+ switch (cmd) {
+ default:
+ case CMD_EXIT:
+ CAMThread::m_hThread = NULL;
+ Reply(S_OK);
+ return 0;
- case CMD_RUN:
- m_pActivePins.RemoveAll();
- m_pPins.RemoveAll();
+ case CMD_RUN:
+ m_pActivePins.RemoveAll();
+ m_pPins.RemoveAll();
- pos = m_pInputs.GetHeadPosition();
- while (pos) {
- CBaseMuxerInputPin* pPin = m_pInputs.GetNext(pos);
- if (pPin->IsConnected()) {
- m_pActivePins.AddTail(pPin);
- m_pPins.AddTail(pPin);
- }
- }
+ pos = m_pInputs.GetHeadPosition();
+ while (pos) {
+ CBaseMuxerInputPin* pPin = m_pInputs.GetNext(pos);
+ if (pPin->IsConnected()) {
+ m_pActivePins.AddTail(pPin);
+ m_pPins.AddTail(pPin);
+ }
+ }
- m_rtCurrent = 0;
+ m_rtCurrent = 0;
- Reply(S_OK);
+ Reply(S_OK);
- MuxInit();
+ MuxInit();
- try {
- MuxHeaderInternal();
+ try {
+ MuxHeaderInternal();
- while (!CheckRequest(NULL) && m_pActivePins.GetCount()) {
- if (m_State == State_Paused) {
- Sleep(10);
- continue;
- }
+ while (!CheckRequest(NULL) && m_pActivePins.GetCount()) {
+ if (m_State == State_Paused) {
+ Sleep(10);
+ continue;
+ }
- CAutoPtr<MuxerPacket> pPacket = GetPacket();
- if (!pPacket) {
- Sleep(1);
- continue;
- }
+ CAutoPtr<MuxerPacket> pPacket = GetPacket();
+ if (!pPacket) {
+ Sleep(1);
+ continue;
+ }
- if (pPacket->IsTimeValid()) {
- m_rtCurrent = pPacket->rtStart;
- }
+ if (pPacket->IsTimeValid()) {
+ m_rtCurrent = pPacket->rtStart;
+ }
- if (pPacket->IsEOS()) {
- m_pActivePins.RemoveAt(m_pActivePins.Find(pPacket->pPin));
- }
+ if (pPacket->IsEOS()) {
+ m_pActivePins.RemoveAt(m_pActivePins.Find(pPacket->pPin));
+ }
- MuxPacketInternal(pPacket);
- }
+ MuxPacketInternal(pPacket);
+ }
- MuxFooterInternal();
- } catch (HRESULT hr) {
- CComQIPtr<IMediaEventSink>(m_pGraph)->Notify(EC_ERRORABORT, hr, 0);
- }
+ MuxFooterInternal();
+ } catch (HRESULT hr) {
+ CComQIPtr<IMediaEventSink>(m_pGraph)->Notify(EC_ERRORABORT, hr, 0);
+ }
- m_pOutput->DeliverEndOfStream();
+ m_pOutput->DeliverEndOfStream();
- pos = m_pRawOutputs.GetHeadPosition();
- while (pos) {
- m_pRawOutputs.GetNext(pos)->DeliverEndOfStream();
- }
+ pos = m_pRawOutputs.GetHeadPosition();
+ while (pos) {
+ m_pRawOutputs.GetNext(pos)->DeliverEndOfStream();
+ }
- m_pActivePins.RemoveAll();
- m_pPins.RemoveAll();
+ m_pActivePins.RemoveAll();
+ m_pPins.RemoveAll();
- break;
- }
- }
+ break;
+ }
+ }
- ASSERT(0); // this function should only return via CMD_EXIT
+ ASSERT(0); // this function should only return via CMD_EXIT
- CAMThread::m_hThread = NULL;
- return 0;
+ CAMThread::m_hThread = NULL;
+ return 0;
}
void CBaseMuxerFilter::MuxHeaderInternal()
{
- TRACE(_T("MuxHeader\n"));
+ TRACE(_T("MuxHeader\n"));
- if (CComQIPtr<IBitStream> pBitStream = m_pOutput->GetBitStream()) {
- MuxHeader(pBitStream);
- }
+ if (CComQIPtr<IBitStream> pBitStream = m_pOutput->GetBitStream()) {
+ MuxHeader(pBitStream);
+ }
- MuxHeader();
+ MuxHeader();
- //
+ //
- POSITION pos = m_pPins.GetHeadPosition();
- while (pos) {
- if (CBaseMuxerInputPin* pInput = m_pPins.GetNext(pos))
- if (CBaseMuxerRawOutputPin* pOutput = dynamic_cast<CBaseMuxerRawOutputPin*>(pInput->GetRelatedPin())) {
- pOutput->MuxHeader(pInput->CurrentMediaType());
- }
- }
+ POSITION pos = m_pPins.GetHeadPosition();
+ while (pos) {
+ if (CBaseMuxerInputPin* pInput = m_pPins.GetNext(pos))
+ if (CBaseMuxerRawOutputPin* pOutput = dynamic_cast<CBaseMuxerRawOutputPin*>(pInput->GetRelatedPin())) {
+ pOutput->MuxHeader(pInput->CurrentMediaType());
+ }
+ }
}
void CBaseMuxerFilter::MuxPacketInternal(const MuxerPacket* pPacket)
{
- TRACE(_T("MuxPacket pPin=%x, size=%d, s%d e%d b%d, rt=(%I64d-%I64d)\n"),
- pPacket->pPin->GetID(),
- pPacket->pData.GetCount(),
- !!(pPacket->flags & MuxerPacket::syncpoint),
- !!(pPacket->flags & MuxerPacket::eos),
- !!(pPacket->flags & MuxerPacket::bogus),
- pPacket->rtStart/10000, pPacket->rtStop/10000);
+ TRACE(_T("MuxPacket pPin=%x, size=%d, s%d e%d b%d, rt=(%I64d-%I64d)\n"),
+ pPacket->pPin->GetID(),
+ pPacket->pData.GetCount(),
+ !!(pPacket->flags & MuxerPacket::syncpoint),
+ !!(pPacket->flags & MuxerPacket::eos),
+ !!(pPacket->flags & MuxerPacket::bogus),
+ pPacket->rtStart / 10000, pPacket->rtStop / 10000);
- if (CComQIPtr<IBitStream> pBitStream = m_pOutput->GetBitStream()) {
- MuxPacket(pBitStream, pPacket);
- }
+ if (CComQIPtr<IBitStream> pBitStream = m_pOutput->GetBitStream()) {
+ MuxPacket(pBitStream, pPacket);
+ }
- MuxPacket(pPacket);
+ MuxPacket(pPacket);
- if (CBaseMuxerInputPin* pInput = pPacket->pPin)
- if (CBaseMuxerRawOutputPin* pOutput = dynamic_cast<CBaseMuxerRawOutputPin*>(pInput->GetRelatedPin())) {
- pOutput->MuxPacket(pInput->CurrentMediaType(), pPacket);
- }
+ if (CBaseMuxerInputPin* pInput = pPacket->pPin)
+ if (CBaseMuxerRawOutputPin* pOutput = dynamic_cast<CBaseMuxerRawOutputPin*>(pInput->GetRelatedPin())) {
+ pOutput->MuxPacket(pInput->CurrentMediaType(), pPacket);
+ }
}
void CBaseMuxerFilter::MuxFooterInternal()
{
- TRACE(_T("MuxFooter\n"));
+ TRACE(_T("MuxFooter\n"));
- if (CComQIPtr<IBitStream> pBitStream = m_pOutput->GetBitStream()) {
- MuxFooter(pBitStream);
- }
+ if (CComQIPtr<IBitStream> pBitStream = m_pOutput->GetBitStream()) {
+ MuxFooter(pBitStream);
+ }
- MuxFooter();
+ MuxFooter();
- //
+ //
- POSITION pos = m_pPins.GetHeadPosition();
- while (pos) {
- if (CBaseMuxerInputPin* pInput = m_pPins.GetNext(pos))
- if (CBaseMuxerRawOutputPin* pOutput = dynamic_cast<CBaseMuxerRawOutputPin*>(pInput->GetRelatedPin())) {
- pOutput->MuxFooter(pInput->CurrentMediaType());
- }
- }
+ POSITION pos = m_pPins.GetHeadPosition();
+ while (pos) {
+ if (CBaseMuxerInputPin* pInput = m_pPins.GetNext(pos))
+ if (CBaseMuxerRawOutputPin* pOutput = dynamic_cast<CBaseMuxerRawOutputPin*>(pInput->GetRelatedPin())) {
+ pOutput->MuxFooter(pInput->CurrentMediaType());
+ }
+ }
}
CAutoPtr<MuxerPacket> CBaseMuxerFilter::GetPacket()
{
- REFERENCE_TIME rtMin = _I64_MAX;
- CBaseMuxerInputPin* pPinMin = NULL;
- int i = int(m_pActivePins.GetCount());
+ REFERENCE_TIME rtMin = _I64_MAX;
+ CBaseMuxerInputPin* pPinMin = NULL;
+ int i = int(m_pActivePins.GetCount());
- POSITION pos = m_pActivePins.GetHeadPosition();
- while (pos) {
- CBaseMuxerInputPin* pPin = m_pActivePins.GetNext(pos);
+ POSITION pos = m_pActivePins.GetHeadPosition();
+ while (pos) {
+ CBaseMuxerInputPin* pPin = m_pActivePins.GetNext(pos);
- CAutoLock cAutoLock(&pPin->m_csQueue);
- if (!pPin->m_queue.GetCount()) {
- continue;
- }
+ CAutoLock cAutoLock(&pPin->m_csQueue);
+ if (!pPin->m_queue.GetCount()) {
+ continue;
+ }
- MuxerPacket* p = pPin->m_queue.GetHead();
+ MuxerPacket* p = pPin->m_queue.GetHead();
- if (p->IsBogus() || !p->IsTimeValid() || p->IsEOS()) {
- pPinMin = pPin;
- i = 0;
- break;
- }
+ if (p->IsBogus() || !p->IsTimeValid() || p->IsEOS()) {
+ pPinMin = pPin;
+ i = 0;
+ break;
+ }
- if (p->rtStart < rtMin) {
- rtMin = p->rtStart;
- pPinMin = pPin;
- }
+ if (p->rtStart < rtMin) {
+ rtMin = p->rtStart;
+ pPinMin = pPin;
+ }
- i--;
- }
+ i--;
+ }
- CAutoPtr<MuxerPacket> pPacket;
+ CAutoPtr<MuxerPacket> pPacket;
- if (pPinMin && i == 0) {
- pPacket = pPinMin->PopPacket();
- } else {
- pos = m_pActivePins.GetHeadPosition();
- while (pos) {
- m_pActivePins.GetNext(pos)->m_evAcceptPacket.Set();
- }
- }
+ if (pPinMin && i == 0) {
+ pPacket = pPinMin->PopPacket();
+ } else {
+ pos = m_pActivePins.GetHeadPosition();
+ while (pos) {
+ m_pActivePins.GetNext(pos)->m_evAcceptPacket.Set();
+ }
+ }
- return pPacket;
+ return pPacket;
}
//
int CBaseMuxerFilter::GetPinCount()
{
- return int(m_pInputs.GetCount()) + (m_pOutput ? 1 : 0) + int(m_pRawOutputs.GetCount());
+ return int(m_pInputs.GetCount()) + (m_pOutput ? 1 : 0) + int(m_pRawOutputs.GetCount());
}
CBasePin* CBaseMuxerFilter::GetPin(int n)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- if (n >= 0 && n < (int)m_pInputs.GetCount()) {
- if (POSITION pos = m_pInputs.FindIndex(n)) {
- return m_pInputs.GetAt(pos);
- }
- }
+ if (n >= 0 && n < (int)m_pInputs.GetCount()) {
+ if (POSITION pos = m_pInputs.FindIndex(n)) {
+ return m_pInputs.GetAt(pos);
+ }
+ }
- n -= int(m_pInputs.GetCount());
+ n -= int(m_pInputs.GetCount());
- if (n == 0 && m_pOutput) {
- return m_pOutput;
- }
+ if (n == 0 && m_pOutput) {
+ return m_pOutput;
+ }
- n--;
+ n--;
- if (n >= 0 && n < (int)m_pRawOutputs.GetCount()) {
- if (POSITION pos = m_pRawOutputs.FindIndex(n)) {
- return m_pRawOutputs.GetAt(pos);
- }
- }
+ if (n >= 0 && n < (int)m_pRawOutputs.GetCount()) {
+ if (POSITION pos = m_pRawOutputs.FindIndex(n)) {
+ return m_pRawOutputs.GetAt(pos);
+ }
+ }
- n -= int(m_pRawOutputs.GetCount());
+ n -= int(m_pRawOutputs.GetCount());
- return NULL;
+ return NULL;
}
STDMETHODIMP CBaseMuxerFilter::Stop()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- HRESULT hr = __super::Stop();
- if (FAILED(hr)) {
- return hr;
- }
+ HRESULT hr = __super::Stop();
+ if (FAILED(hr)) {
+ return hr;
+ }
- CallWorker(CMD_EXIT);
+ CallWorker(CMD_EXIT);
- return hr;
+ return hr;
}
STDMETHODIMP CBaseMuxerFilter::Pause()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- FILTER_STATE fs = m_State;
+ FILTER_STATE fs = m_State;
- HRESULT hr = __super::Pause();
- if (FAILED(hr)) {
- return hr;
- }
+ HRESULT hr = __super::Pause();
+ if (FAILED(hr)) {
+ return hr;
+ }
- if (fs == State_Stopped && m_pOutput) {
- CAMThread::Create();
- CallWorker(CMD_RUN);
- }
+ if (fs == State_Stopped && m_pOutput) {
+ CAMThread::Create();
+ CallWorker(CMD_RUN);
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CBaseMuxerFilter::Run(REFERENCE_TIME tStart)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- HRESULT hr = __super::Run(tStart);
- if (FAILED(hr)) {
- return hr;
- }
+ HRESULT hr = __super::Run(tStart);
+ if (FAILED(hr)) {
+ return hr;
+ }
- return hr;
+ return hr;
}
// IMediaSeeking
STDMETHODIMP CBaseMuxerFilter::GetCapabilities(DWORD* pCapabilities)
{
- return pCapabilities ? *pCapabilities = AM_SEEKING_CanGetDuration|AM_SEEKING_CanGetCurrentPos, S_OK : E_POINTER;
+ return pCapabilities ? *pCapabilities = AM_SEEKING_CanGetDuration | AM_SEEKING_CanGetCurrentPos, S_OK : E_POINTER;
}
STDMETHODIMP CBaseMuxerFilter::CheckCapabilities(DWORD* pCapabilities)
{
- CheckPointer(pCapabilities, E_POINTER);
- if (*pCapabilities == 0) {
- return S_OK;
- }
- DWORD caps;
- GetCapabilities(&caps);
- caps &= *pCapabilities;
- return caps == 0 ? E_FAIL : caps == *pCapabilities ? S_OK : S_FALSE;
+ CheckPointer(pCapabilities, E_POINTER);
+ if (*pCapabilities == 0) {
+ return S_OK;
+ }
+ DWORD caps;
+ GetCapabilities(&caps);
+ caps &= *pCapabilities;
+ return caps == 0 ? E_FAIL : caps == *pCapabilities ? S_OK : S_FALSE;
}
STDMETHODIMP CBaseMuxerFilter::IsFormatSupported(const GUID* pFormat)
{
- return !pFormat ? E_POINTER : *pFormat == TIME_FORMAT_MEDIA_TIME ? S_OK : S_FALSE;
+ return !pFormat ? E_POINTER : *pFormat == TIME_FORMAT_MEDIA_TIME ? S_OK : S_FALSE;
}
STDMETHODIMP CBaseMuxerFilter::QueryPreferredFormat(GUID* pFormat)
{
- return GetTimeFormat(pFormat);
+ return GetTimeFormat(pFormat);
}
STDMETHODIMP CBaseMuxerFilter::GetTimeFormat(GUID* pFormat)
{
- return pFormat ? *pFormat = TIME_FORMAT_MEDIA_TIME, S_OK : E_POINTER;
+ return pFormat ? *pFormat = TIME_FORMAT_MEDIA_TIME, S_OK : E_POINTER;
}
STDMETHODIMP CBaseMuxerFilter::IsUsingTimeFormat(const GUID* pFormat)
{
- return IsFormatSupported(pFormat);
+ return IsFormatSupported(pFormat);
}
STDMETHODIMP CBaseMuxerFilter::SetTimeFormat(const GUID* pFormat)
{
- return S_OK == IsFormatSupported(pFormat) ? S_OK : E_INVALIDARG;
+ return S_OK == IsFormatSupported(pFormat) ? S_OK : E_INVALIDARG;
}
STDMETHODIMP CBaseMuxerFilter::GetDuration(LONGLONG* pDuration)
{
- CheckPointer(pDuration, E_POINTER);
- *pDuration = 0;
- POSITION pos = m_pInputs.GetHeadPosition();
- while (pos) {
- REFERENCE_TIME rt = m_pInputs.GetNext(pos)->GetDuration();
- if (rt > *pDuration) {
- *pDuration = rt;
- }
- }
- return S_OK;
+ CheckPointer(pDuration, E_POINTER);
+ *pDuration = 0;
+ POSITION pos = m_pInputs.GetHeadPosition();
+ while (pos) {
+ REFERENCE_TIME rt = m_pInputs.GetNext(pos)->GetDuration();
+ if (rt > *pDuration) {
+ *pDuration = rt;
+ }
+ }
+ return S_OK;
}
STDMETHODIMP CBaseMuxerFilter::GetStopPosition(LONGLONG* pStop)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseMuxerFilter::GetCurrentPosition(LONGLONG* pCurrent)
{
- CheckPointer(pCurrent, E_POINTER);
- *pCurrent = m_rtCurrent;
- return S_OK;
+ CheckPointer(pCurrent, E_POINTER);
+ *pCurrent = m_rtCurrent;
+ return S_OK;
}
STDMETHODIMP CBaseMuxerFilter::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseMuxerFilter::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags)
{
- FILTER_STATE fs;
+ FILTER_STATE fs;
- if (SUCCEEDED(GetState(0, &fs)) && fs == State_Stopped) {
- POSITION pos = m_pInputs.GetHeadPosition();
- while (pos) {
- CBasePin* pPin = m_pInputs.GetNext(pos);
- CComQIPtr<IMediaSeeking> pMS = pPin->GetConnected();
- if (!pMS) {
- pMS = GetFilterFromPin(pPin->GetConnected());
- }
- if (pMS) {
- pMS->SetPositions(pCurrent, dwCurrentFlags, pStop, dwStopFlags);
- }
- }
+ if (SUCCEEDED(GetState(0, &fs)) && fs == State_Stopped) {
+ POSITION pos = m_pInputs.GetHeadPosition();
+ while (pos) {
+ CBasePin* pPin = m_pInputs.GetNext(pos);
+ CComQIPtr<IMediaSeeking> pMS = pPin->GetConnected();
+ if (!pMS) {
+ pMS = GetFilterFromPin(pPin->GetConnected());
+ }
+ if (pMS) {
+ pMS->SetPositions(pCurrent, dwCurrentFlags, pStop, dwStopFlags);
+ }
+ }
- return S_OK;
- }
+ return S_OK;
+ }
- return VFW_E_WRONG_STATE;
+ return VFW_E_WRONG_STATE;
}
STDMETHODIMP CBaseMuxerFilter::GetPositions(LONGLONG* pCurrent, LONGLONG* pStop)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseMuxerFilter::GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseMuxerFilter::SetRate(double dRate)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseMuxerFilter::GetRate(double* pdRate)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseMuxerFilter::GetPreroll(LONGLONG* pllPreroll)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
diff --git a/src/filters/muxer/BaseMuxer/BaseMuxer.h b/src/filters/muxer/BaseMuxer/BaseMuxer.h
index 2fd0b927d..6f204ed0a 100644
--- a/src/filters/muxer/BaseMuxer/BaseMuxer.h
+++ b/src/filters/muxer/BaseMuxer/BaseMuxer.h
@@ -27,86 +27,86 @@
#include "BaseMuxerOutputPin.h"
class CBaseMuxerFilter
- : public CBaseFilter
- , public CCritSec
- , public CAMThread
- , public IMediaSeeking
- , public IDSMPropertyBagImpl
- , public IDSMResourceBagImpl
- , public IDSMChapterBagImpl
+ : public CBaseFilter
+ , public CCritSec
+ , public CAMThread
+ , public IMediaSeeking
+ , public IDSMPropertyBagImpl
+ , public IDSMResourceBagImpl
+ , public IDSMChapterBagImpl
{
private:
- CAutoPtrList<CBaseMuxerInputPin> m_pInputs;
- CAutoPtr<CBaseMuxerOutputPin> m_pOutput;
- CAutoPtrList<CBaseMuxerRawOutputPin> m_pRawOutputs;
+ CAutoPtrList<CBaseMuxerInputPin> m_pInputs;
+ CAutoPtr<CBaseMuxerOutputPin> m_pOutput;
+ CAutoPtrList<CBaseMuxerRawOutputPin> m_pRawOutputs;
- enum {CMD_EXIT, CMD_RUN};
- DWORD ThreadProc();
+ enum {CMD_EXIT, CMD_RUN};
+ DWORD ThreadProc();
- REFERENCE_TIME m_rtCurrent;
- CAtlList<CBaseMuxerInputPin*> m_pActivePins;
+ REFERENCE_TIME m_rtCurrent;
+ CAtlList<CBaseMuxerInputPin*> m_pActivePins;
- CAutoPtr<MuxerPacket> GetPacket();
+ CAutoPtr<MuxerPacket> GetPacket();
- void MuxHeaderInternal();
- void MuxPacketInternal(const MuxerPacket* pPacket);
- void MuxFooterInternal();
+ void MuxHeaderInternal();
+ void MuxPacketInternal(const MuxerPacket* pPacket);
+ void MuxFooterInternal();
protected:
- CAtlList<CBaseMuxerInputPin*> m_pPins;
- CBaseMuxerOutputPin* GetOutputPin() {
- return m_pOutput;
- }
+ CAtlList<CBaseMuxerInputPin*> m_pPins;
+ CBaseMuxerOutputPin* GetOutputPin() {
+ return m_pOutput;
+ }
- virtual void MuxInit() = 0;
+ virtual void MuxInit() = 0;
- // only called when the output pin is connected
- virtual void MuxHeader(IBitStream* pBS) {}
- virtual void MuxPacket(IBitStream* pBS, const MuxerPacket* pPacket) {}
- virtual void MuxFooter(IBitStream* pBS) {}
+ // only called when the output pin is connected
+ virtual void MuxHeader(IBitStream* pBS) {}
+ virtual void MuxPacket(IBitStream* pBS, const MuxerPacket* pPacket) {}
+ virtual void MuxFooter(IBitStream* pBS) {}
- // always called (useful if the derived class wants to write somewhere else than downstream)
- virtual void MuxHeader() {}
- virtual void MuxPacket(const MuxerPacket* pPacket) {}
- virtual void MuxFooter() {}
+ // always called (useful if the derived class wants to write somewhere else than downstream)
+ virtual void MuxHeader() {}
+ virtual void MuxPacket(const MuxerPacket* pPacket) {}
+ virtual void MuxFooter() {}
- // allows customized pins in derived classes
- virtual HRESULT CreateInput(CStringW name, CBaseMuxerInputPin** ppPin);
- virtual HRESULT CreateRawOutput(CStringW name, CBaseMuxerRawOutputPin** ppPin);
+ // allows customized pins in derived classes
+ virtual HRESULT CreateInput(CStringW name, CBaseMuxerInputPin** ppPin);
+ virtual HRESULT CreateRawOutput(CStringW name, CBaseMuxerRawOutputPin** ppPin);
public:
- CBaseMuxerFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLSID& clsid);
- virtual ~CBaseMuxerFilter();
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- void AddInput();
-
- int GetPinCount();
- CBasePin* GetPin(int n);
-
- STDMETHODIMP Stop();
- STDMETHODIMP Pause();
- STDMETHODIMP Run(REFERENCE_TIME tStart);
-
- // IMediaSeeking
-
- STDMETHODIMP GetCapabilities(DWORD* pCapabilities);
- STDMETHODIMP CheckCapabilities(DWORD* pCapabilities);
- STDMETHODIMP IsFormatSupported(const GUID* pFormat);
- STDMETHODIMP QueryPreferredFormat(GUID* pFormat);
- STDMETHODIMP GetTimeFormat(GUID* pFormat);
- STDMETHODIMP IsUsingTimeFormat(const GUID* pFormat);
- STDMETHODIMP SetTimeFormat(const GUID* pFormat);
- STDMETHODIMP GetDuration(LONGLONG* pDuration);
- STDMETHODIMP GetStopPosition(LONGLONG* pStop);
- STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
- STDMETHODIMP ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat);
- STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
- STDMETHODIMP GetPositions(LONGLONG* pCurrent, LONGLONG* pStop);
- STDMETHODIMP GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest);
- STDMETHODIMP SetRate(double dRate);
- STDMETHODIMP GetRate(double* pdRate);
- STDMETHODIMP GetPreroll(LONGLONG* pllPreroll);
+ CBaseMuxerFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLSID& clsid);
+ virtual ~CBaseMuxerFilter();
+
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ void AddInput();
+
+ int GetPinCount();
+ CBasePin* GetPin(int n);
+
+ STDMETHODIMP Stop();
+ STDMETHODIMP Pause();
+ STDMETHODIMP Run(REFERENCE_TIME tStart);
+
+ // IMediaSeeking
+
+ STDMETHODIMP GetCapabilities(DWORD* pCapabilities);
+ STDMETHODIMP CheckCapabilities(DWORD* pCapabilities);
+ STDMETHODIMP IsFormatSupported(const GUID* pFormat);
+ STDMETHODIMP QueryPreferredFormat(GUID* pFormat);
+ STDMETHODIMP GetTimeFormat(GUID* pFormat);
+ STDMETHODIMP IsUsingTimeFormat(const GUID* pFormat);
+ STDMETHODIMP SetTimeFormat(const GUID* pFormat);
+ STDMETHODIMP GetDuration(LONGLONG* pDuration);
+ STDMETHODIMP GetStopPosition(LONGLONG* pStop);
+ STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
+ STDMETHODIMP ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat);
+ STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
+ STDMETHODIMP GetPositions(LONGLONG* pCurrent, LONGLONG* pStop);
+ STDMETHODIMP GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest);
+ STDMETHODIMP SetRate(double dRate);
+ STDMETHODIMP GetRate(double* pdRate);
+ STDMETHODIMP GetPreroll(LONGLONG* pllPreroll);
};
diff --git a/src/filters/muxer/BaseMuxer/BaseMuxerInputPin.cpp b/src/filters/muxer/BaseMuxer/BaseMuxerInputPin.cpp
index 82e5d6936..ad2ad9767 100644
--- a/src/filters/muxer/BaseMuxer/BaseMuxerInputPin.cpp
+++ b/src/filters/muxer/BaseMuxer/BaseMuxerInputPin.cpp
@@ -35,13 +35,13 @@
//
CBaseMuxerInputPin::CBaseMuxerInputPin(LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseInputPin(NAME("CBaseMuxerInputPin"), pFilter, pLock, phr, pName)
- , m_rtDuration(0)
- , m_evAcceptPacket(TRUE)
- , m_iPacketIndex(0)
+ : CBaseInputPin(NAME("CBaseMuxerInputPin"), pFilter, pLock, phr, pName)
+ , m_rtDuration(0)
+ , m_evAcceptPacket(TRUE)
+ , m_iPacketIndex(0)
{
- static int s_iID = 0;
- m_iID = s_iID++;
+ static int s_iID = 0;
+ m_iID = s_iID++;
}
CBaseMuxerInputPin::~CBaseMuxerInputPin()
@@ -50,237 +50,237 @@ CBaseMuxerInputPin::~CBaseMuxerInputPin()
STDMETHODIMP CBaseMuxerInputPin::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
-
- return
- QI(IBaseMuxerRelatedPin)
- QI(IPropertyBag)
- QI(IPropertyBag2)
- QI(IDSMPropertyBag)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ CheckPointer(ppv, E_POINTER);
+
+ return
+ QI(IBaseMuxerRelatedPin)
+ QI(IPropertyBag)
+ QI(IPropertyBag2)
+ QI(IDSMPropertyBag)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
bool CBaseMuxerInputPin::IsSubtitleStream()
{
- return m_mt.majortype == MEDIATYPE_Subtitle || m_mt.majortype == MEDIATYPE_Text;
+ return m_mt.majortype == MEDIATYPE_Subtitle || m_mt.majortype == MEDIATYPE_Text;
}
void CBaseMuxerInputPin::PushPacket(CAutoPtr<MuxerPacket> pPacket)
{
- for (int i = 0; m_pFilter->IsActive() && !m_bFlushing
- && !m_evAcceptPacket.Wait(1)
- && i < 1000;
- i++) {
- ;
- }
+ for (int i = 0; m_pFilter->IsActive() && !m_bFlushing
+ && !m_evAcceptPacket.Wait(1)
+ && i < 1000;
+ i++) {
+ ;
+ }
- if (!m_pFilter->IsActive() || m_bFlushing) {
- return;
- }
+ if (!m_pFilter->IsActive() || m_bFlushing) {
+ return;
+ }
- CAutoLock cAutoLock(&m_csQueue);
+ CAutoLock cAutoLock(&m_csQueue);
- m_queue.AddTail(pPacket);
+ m_queue.AddTail(pPacket);
- if (m_queue.GetCount() >= MAXQUEUESIZE) {
- m_evAcceptPacket.Reset();
- }
+ if (m_queue.GetCount() >= MAXQUEUESIZE) {
+ m_evAcceptPacket.Reset();
+ }
}
CAutoPtr<MuxerPacket> CBaseMuxerInputPin::PopPacket()
{
- CAutoPtr<MuxerPacket> pPacket;
+ CAutoPtr<MuxerPacket> pPacket;
- CAutoLock cAutoLock(&m_csQueue);
+ CAutoLock cAutoLock(&m_csQueue);
- if (m_queue.GetCount()) {
- pPacket = m_queue.RemoveHead();
- }
+ if (m_queue.GetCount()) {
+ pPacket = m_queue.RemoveHead();
+ }
- if (m_queue.GetCount() < MAXQUEUESIZE) {
- m_evAcceptPacket.Set();
- }
+ if (m_queue.GetCount() < MAXQUEUESIZE) {
+ m_evAcceptPacket.Set();
+ }
- return pPacket;
+ return pPacket;
}
HRESULT CBaseMuxerInputPin::CheckMediaType(const CMediaType* pmt)
{
- if (pmt->formattype == FORMAT_WaveFormatEx) {
- WORD wFormatTag = ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag;
- if ((wFormatTag == WAVE_FORMAT_PCM
- || wFormatTag == WAVE_FORMAT_EXTENSIBLE
- || wFormatTag == WAVE_FORMAT_IEEE_FLOAT)
- && pmt->subtype != FOURCCMap(wFormatTag)
- && !(pmt->subtype == MEDIASUBTYPE_PCM && wFormatTag == WAVE_FORMAT_EXTENSIBLE)
- && !(pmt->subtype == MEDIASUBTYPE_PCM && wFormatTag == WAVE_FORMAT_IEEE_FLOAT)
- && pmt->subtype != MEDIASUBTYPE_DVD_LPCM_AUDIO
- && pmt->subtype != MEDIASUBTYPE_DOLBY_AC3
- && pmt->subtype != MEDIASUBTYPE_DTS) {
- return E_INVALIDARG;
- }
- }
-
- return pmt->majortype == MEDIATYPE_Video
- || pmt->majortype == MEDIATYPE_Audio && pmt->formattype != FORMAT_VorbisFormat
- || pmt->majortype == MEDIATYPE_Text && pmt->subtype == MEDIASUBTYPE_NULL && pmt->formattype == FORMAT_None
- || pmt->majortype == MEDIATYPE_Subtitle
- ? S_OK
- : E_INVALIDARG;
+ if (pmt->formattype == FORMAT_WaveFormatEx) {
+ WORD wFormatTag = ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag;
+ if ((wFormatTag == WAVE_FORMAT_PCM
+ || wFormatTag == WAVE_FORMAT_EXTENSIBLE
+ || wFormatTag == WAVE_FORMAT_IEEE_FLOAT)
+ && pmt->subtype != FOURCCMap(wFormatTag)
+ && !(pmt->subtype == MEDIASUBTYPE_PCM && wFormatTag == WAVE_FORMAT_EXTENSIBLE)
+ && !(pmt->subtype == MEDIASUBTYPE_PCM && wFormatTag == WAVE_FORMAT_IEEE_FLOAT)
+ && pmt->subtype != MEDIASUBTYPE_DVD_LPCM_AUDIO
+ && pmt->subtype != MEDIASUBTYPE_DOLBY_AC3
+ && pmt->subtype != MEDIASUBTYPE_DTS) {
+ return E_INVALIDARG;
+ }
+ }
+
+ return pmt->majortype == MEDIATYPE_Video
+ || pmt->majortype == MEDIATYPE_Audio && pmt->formattype != FORMAT_VorbisFormat
+ || pmt->majortype == MEDIATYPE_Text && pmt->subtype == MEDIASUBTYPE_NULL && pmt->formattype == FORMAT_None
+ || pmt->majortype == MEDIATYPE_Subtitle
+ ? S_OK
+ : E_INVALIDARG;
}
HRESULT CBaseMuxerInputPin::BreakConnect()
{
- HRESULT hr = __super::BreakConnect();
- if (FAILED(hr)) {
- return hr;
- }
+ HRESULT hr = __super::BreakConnect();
+ if (FAILED(hr)) {
+ return hr;
+ }
- RemoveAll();
+ RemoveAll();
- // TODO: remove extra disconnected pins, leave one
+ // TODO: remove extra disconnected pins, leave one
- return hr;
+ return hr;
}
HRESULT CBaseMuxerInputPin::CompleteConnect(IPin* pReceivePin)
{
- HRESULT hr = __super::CompleteConnect(pReceivePin);
- if (FAILED(hr)) {
- return hr;
- }
-
- // duration
-
- m_rtDuration = 0;
- CComQIPtr<IMediaSeeking> pMS;
- if ((pMS = GetFilterFromPin(pReceivePin)) || (pMS = pReceivePin)) {
- pMS->GetDuration(&m_rtDuration);
- }
-
- // properties
-
- for (CComPtr<IPin> pPin = pReceivePin; pPin; pPin = GetUpStreamPin(GetFilterFromPin(pPin))) {
- if (CComQIPtr<IDSMPropertyBag> pPB = pPin) {
- ULONG cProperties = 0;
- if (SUCCEEDED(pPB->CountProperties(&cProperties)) && cProperties > 0) {
- for (ULONG iProperty = 0; iProperty < cProperties; iProperty++) {
- PROPBAG2 PropBag;
- memset(&PropBag, 0, sizeof(PropBag));
- ULONG cPropertiesReturned = 0;
- if (FAILED(pPB->GetPropertyInfo(iProperty, 1, &PropBag, &cPropertiesReturned))) {
- continue;
- }
-
- HRESULT hr;
- CComVariant var;
- if (SUCCEEDED(pPB->Read(1, &PropBag, NULL, &var, &hr)) && SUCCEEDED(hr)) {
- SetProperty(PropBag.pstrName, &var);
- }
-
- CoTaskMemFree(PropBag.pstrName);
- }
- }
- }
- }
-
- (static_cast<CBaseMuxerFilter*>(m_pFilter))->AddInput();
-
- return S_OK;
+ HRESULT hr = __super::CompleteConnect(pReceivePin);
+ if (FAILED(hr)) {
+ return hr;
+ }
+
+ // duration
+
+ m_rtDuration = 0;
+ CComQIPtr<IMediaSeeking> pMS;
+ if ((pMS = GetFilterFromPin(pReceivePin)) || (pMS = pReceivePin)) {
+ pMS->GetDuration(&m_rtDuration);
+ }
+
+ // properties
+
+ for (CComPtr<IPin> pPin = pReceivePin; pPin; pPin = GetUpStreamPin(GetFilterFromPin(pPin))) {
+ if (CComQIPtr<IDSMPropertyBag> pPB = pPin) {
+ ULONG cProperties = 0;
+ if (SUCCEEDED(pPB->CountProperties(&cProperties)) && cProperties > 0) {
+ for (ULONG iProperty = 0; iProperty < cProperties; iProperty++) {
+ PROPBAG2 PropBag;
+ memset(&PropBag, 0, sizeof(PropBag));
+ ULONG cPropertiesReturned = 0;
+ if (FAILED(pPB->GetPropertyInfo(iProperty, 1, &PropBag, &cPropertiesReturned))) {
+ continue;
+ }
+
+ HRESULT hr;
+ CComVariant var;
+ if (SUCCEEDED(pPB->Read(1, &PropBag, NULL, &var, &hr)) && SUCCEEDED(hr)) {
+ SetProperty(PropBag.pstrName, &var);
+ }
+
+ CoTaskMemFree(PropBag.pstrName);
+ }
+ }
+ }
+ }
+
+ (static_cast<CBaseMuxerFilter*>(m_pFilter))->AddInput();
+
+ return S_OK;
}
HRESULT CBaseMuxerInputPin::Active()
{
- m_rtMaxStart = _I64_MIN;
- m_fEOS = false;
- m_iPacketIndex = 0;
- m_evAcceptPacket.Set();
- return __super::Active();
+ m_rtMaxStart = _I64_MIN;
+ m_fEOS = false;
+ m_iPacketIndex = 0;
+ m_evAcceptPacket.Set();
+ return __super::Active();
}
HRESULT CBaseMuxerInputPin::Inactive()
{
- CAutoLock cAutoLock(&m_csQueue);
- m_queue.RemoveAll();
- return __super::Inactive();
+ CAutoLock cAutoLock(&m_csQueue);
+ m_queue.RemoveAll();
+ return __super::Inactive();
}
STDMETHODIMP CBaseMuxerInputPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- CAutoLock cAutoLock(&m_csReceive);
+ CAutoLock cAutoLock(&m_csReceive);
- return __super::NewSegment(tStart, tStop, dRate);
+ return __super::NewSegment(tStart, tStop, dRate);
}
STDMETHODIMP CBaseMuxerInputPin::Receive(IMediaSample* pSample)
{
- CAutoLock cAutoLock(&m_csReceive);
+ CAutoLock cAutoLock(&m_csReceive);
- HRESULT hr = __super::Receive(pSample);
- if (FAILED(hr)) {
- return hr;
- }
+ HRESULT hr = __super::Receive(pSample);
+ if (FAILED(hr)) {
+ return hr;
+ }
- CAutoPtr<MuxerPacket> pPacket(DNew MuxerPacket(this));
+ CAutoPtr<MuxerPacket> pPacket(DNew MuxerPacket(this));
- long len = pSample->GetActualDataLength();
+ long len = pSample->GetActualDataLength();
- BYTE* pData = NULL;
- if (FAILED(pSample->GetPointer(&pData)) || !pData) {
- return S_OK;
- }
+ BYTE* pData = NULL;
+ if (FAILED(pSample->GetPointer(&pData)) || !pData) {
+ return S_OK;
+ }
- pPacket->pData.SetCount(len);
- memcpy(pPacket->pData.GetData(), pData, len);
+ pPacket->pData.SetCount(len);
+ memcpy(pPacket->pData.GetData(), pData, len);
- if (S_OK == pSample->IsSyncPoint() || m_mt.majortype == MEDIATYPE_Audio && !m_mt.bTemporalCompression) {
- pPacket->flags |= MuxerPacket::syncpoint;
- }
+ if (S_OK == pSample->IsSyncPoint() || m_mt.majortype == MEDIATYPE_Audio && !m_mt.bTemporalCompression) {
+ pPacket->flags |= MuxerPacket::syncpoint;
+ }
- if (S_OK == pSample->GetTime(&pPacket->rtStart, &pPacket->rtStop)) {
- pPacket->flags |= MuxerPacket::timevalid;
+ if (S_OK == pSample->GetTime(&pPacket->rtStart, &pPacket->rtStop)) {
+ pPacket->flags |= MuxerPacket::timevalid;
- pPacket->rtStart += m_tStart;
- pPacket->rtStop += m_tStart;
+ pPacket->rtStart += m_tStart;
+ pPacket->rtStop += m_tStart;
- if ((pPacket->flags & MuxerPacket::syncpoint) && pPacket->rtStart < m_rtMaxStart) {
- pPacket->flags &= ~MuxerPacket::syncpoint;
- pPacket->flags |= MuxerPacket::bogus;
- }
+ if ((pPacket->flags & MuxerPacket::syncpoint) && pPacket->rtStart < m_rtMaxStart) {
+ pPacket->flags &= ~MuxerPacket::syncpoint;
+ pPacket->flags |= MuxerPacket::bogus;
+ }
- m_rtMaxStart = max(m_rtMaxStart, pPacket->rtStart);
- } else if (pPacket->flags & MuxerPacket::syncpoint) {
- pPacket->flags &= ~MuxerPacket::syncpoint;
- pPacket->flags |= MuxerPacket::bogus;
- }
+ m_rtMaxStart = max(m_rtMaxStart, pPacket->rtStart);
+ } else if (pPacket->flags & MuxerPacket::syncpoint) {
+ pPacket->flags &= ~MuxerPacket::syncpoint;
+ pPacket->flags |= MuxerPacket::bogus;
+ }
- if (S_OK == pSample->IsDiscontinuity()) {
- pPacket->flags |= MuxerPacket::discontinuity;
- }
+ if (S_OK == pSample->IsDiscontinuity()) {
+ pPacket->flags |= MuxerPacket::discontinuity;
+ }
- pPacket->index = m_iPacketIndex++;
+ pPacket->index = m_iPacketIndex++;
- PushPacket(pPacket);
+ PushPacket(pPacket);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CBaseMuxerInputPin::EndOfStream()
{
- CAutoLock cAutoLock(&m_csReceive);
+ CAutoLock cAutoLock(&m_csReceive);
- HRESULT hr = __super::EndOfStream();
- if (FAILED(hr)) {
- return hr;
- }
+ HRESULT hr = __super::EndOfStream();
+ if (FAILED(hr)) {
+ return hr;
+ }
- ASSERT(!m_fEOS);
+ ASSERT(!m_fEOS);
- CAutoPtr<MuxerPacket> pPacket(DNew MuxerPacket(this));
- pPacket->flags |= MuxerPacket::eos;
- PushPacket(pPacket);
+ CAutoPtr<MuxerPacket> pPacket(DNew MuxerPacket(this));
+ pPacket->flags |= MuxerPacket::eos;
+ PushPacket(pPacket);
- m_fEOS = true;
+ m_fEOS = true;
- return hr;
+ return hr;
}
diff --git a/src/filters/muxer/BaseMuxer/BaseMuxerInputPin.h b/src/filters/muxer/BaseMuxer/BaseMuxerInputPin.h
index 6c2670fdf..fefd58439 100644
--- a/src/filters/muxer/BaseMuxer/BaseMuxerInputPin.h
+++ b/src/filters/muxer/BaseMuxer/BaseMuxerInputPin.h
@@ -29,79 +29,79 @@
class CBaseMuxerInputPin;
struct MuxerPacket {
- CBaseMuxerInputPin* pPin;
- REFERENCE_TIME rtStart, rtStop;
- CAtlArray<BYTE> pData;
- enum flag_t {empty = 0, timevalid = 1, syncpoint = 2, discontinuity = 4, eos = 8, bogus = 16};
- DWORD flags;
- int index;
- struct MuxerPacket(CBaseMuxerInputPin* pPin) {
- this->pPin = pPin;
- rtStart = rtStop = _I64_MIN;
- flags = empty;
- index = -1;
- }
- bool IsTimeValid() const {
- return !!(flags & timevalid);
- }
- bool IsSyncPoint() const {
- return !!(flags & syncpoint);
- }
- bool IsDiscontinuity() const {
- return !!(flags & discontinuity);
- }
- bool IsEOS() const {
- return !!(flags & eos);
- }
- bool IsBogus() const {
- return !!(flags & bogus);
- }
+ CBaseMuxerInputPin* pPin;
+ REFERENCE_TIME rtStart, rtStop;
+ CAtlArray<BYTE> pData;
+ enum flag_t {empty = 0, timevalid = 1, syncpoint = 2, discontinuity = 4, eos = 8, bogus = 16};
+ DWORD flags;
+ int index;
+ struct MuxerPacket(CBaseMuxerInputPin* pPin) {
+ this->pPin = pPin;
+ rtStart = rtStop = _I64_MIN;
+ flags = empty;
+ index = -1;
+ }
+ bool IsTimeValid() const {
+ return !!(flags & timevalid);
+ }
+ bool IsSyncPoint() const {
+ return !!(flags & syncpoint);
+ }
+ bool IsDiscontinuity() const {
+ return !!(flags & discontinuity);
+ }
+ bool IsEOS() const {
+ return !!(flags & eos);
+ }
+ bool IsBogus() const {
+ return !!(flags & bogus);
+ }
};
class CBaseMuxerInputPin : public CBaseInputPin, public CBaseMuxerRelatedPin, public IDSMPropertyBagImpl
{
private:
- int m_iID;
+ int m_iID;
- CCritSec m_csReceive;
- REFERENCE_TIME m_rtMaxStart, m_rtDuration;
- bool m_fEOS;
- int m_iPacketIndex;
+ CCritSec m_csReceive;
+ REFERENCE_TIME m_rtMaxStart, m_rtDuration;
+ bool m_fEOS;
+ int m_iPacketIndex;
- CCritSec m_csQueue;
- CAutoPtrList<MuxerPacket> m_queue;
- void PushPacket(CAutoPtr<MuxerPacket> pPacket);
- CAutoPtr<MuxerPacket> PopPacket();
- CAMEvent m_evAcceptPacket;
+ CCritSec m_csQueue;
+ CAutoPtrList<MuxerPacket> m_queue;
+ void PushPacket(CAutoPtr<MuxerPacket> pPacket);
+ CAutoPtr<MuxerPacket> PopPacket();
+ CAMEvent m_evAcceptPacket;
- friend class CBaseMuxerFilter;
+ friend class CBaseMuxerFilter;
public:
- CBaseMuxerInputPin(LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
- virtual ~CBaseMuxerInputPin();
+ CBaseMuxerInputPin(LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
+ virtual ~CBaseMuxerInputPin();
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- REFERENCE_TIME GetDuration() {
- return m_rtDuration;
- }
- int GetID() {
- return m_iID;
- }
- CMediaType& CurrentMediaType() {
- return m_mt;
- }
- bool IsSubtitleStream();
+ REFERENCE_TIME GetDuration() {
+ return m_rtDuration;
+ }
+ int GetID() {
+ return m_iID;
+ }
+ CMediaType& CurrentMediaType() {
+ return m_mt;
+ }
+ bool IsSubtitleStream();
- HRESULT CheckMediaType(const CMediaType* pmt);
- HRESULT BreakConnect();
- HRESULT CompleteConnect(IPin* pReceivePin);
+ HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT BreakConnect();
+ HRESULT CompleteConnect(IPin* pReceivePin);
- HRESULT Active();
- HRESULT Inactive();
+ HRESULT Active();
+ HRESULT Inactive();
- STDMETHODIMP NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
- STDMETHODIMP Receive(IMediaSample* pSample);
- STDMETHODIMP EndOfStream();
+ STDMETHODIMP NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ STDMETHODIMP Receive(IMediaSample* pSample);
+ STDMETHODIMP EndOfStream();
};
diff --git a/src/filters/muxer/BaseMuxer/BaseMuxerOutputPin.cpp b/src/filters/muxer/BaseMuxer/BaseMuxerOutputPin.cpp
index ec5abf339..baae85b9c 100644
--- a/src/filters/muxer/BaseMuxer/BaseMuxerOutputPin.cpp
+++ b/src/filters/muxer/BaseMuxer/BaseMuxerOutputPin.cpp
@@ -36,88 +36,88 @@
//
CBaseMuxerOutputPin::CBaseMuxerOutputPin(LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseOutputPin(_T("CBaseMuxerOutputPin"), pFilter, pLock, phr, pName)
+ : CBaseOutputPin(_T("CBaseMuxerOutputPin"), pFilter, pLock, phr, pName)
{
}
IBitStream* CBaseMuxerOutputPin::GetBitStream()
{
- if (!m_pBitStream) {
- if (CComQIPtr<IStream> pStream = GetConnected()) {
- m_pBitStream = DNew CBitStream(pStream, true);
- }
- }
+ if (!m_pBitStream) {
+ if (CComQIPtr<IStream> pStream = GetConnected()) {
+ m_pBitStream = DNew CBitStream(pStream, true);
+ }
+ }
- return m_pBitStream;
+ return m_pBitStream;
}
HRESULT CBaseMuxerOutputPin::BreakConnect()
{
- m_pBitStream = NULL;
+ m_pBitStream = NULL;
- return __super::BreakConnect();
+ return __super::BreakConnect();
}
HRESULT CBaseMuxerOutputPin::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties)
{
- ASSERT(pAlloc);
- ASSERT(pProperties);
+ ASSERT(pAlloc);
+ ASSERT(pProperties);
- HRESULT hr = NOERROR;
+ HRESULT hr = NOERROR;
- pProperties->cBuffers = 1;
- pProperties->cbBuffer = 1;
+ pProperties->cBuffers = 1;
+ pProperties->cbBuffer = 1;
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
- return hr;
- }
+ ALLOCATOR_PROPERTIES Actual;
+ if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
- if (Actual.cbBuffer < pProperties->cbBuffer) {
- return E_FAIL;
- }
- ASSERT(Actual.cBuffers == pProperties->cBuffers);
+ if (Actual.cbBuffer < pProperties->cbBuffer) {
+ return E_FAIL;
+ }
+ ASSERT(Actual.cBuffers == pProperties->cBuffers);
- return NOERROR;
+ return NOERROR;
}
HRESULT CBaseMuxerOutputPin::CheckMediaType(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Stream && pmt->subtype == MEDIASUBTYPE_NULL
- ? S_OK
- : E_INVALIDARG;
+ return pmt->majortype == MEDIATYPE_Stream && pmt->subtype == MEDIASUBTYPE_NULL
+ ? S_OK
+ : E_INVALIDARG;
}
HRESULT CBaseMuxerOutputPin::GetMediaType(int iPosition, CMediaType* pmt)
{
- CAutoLock cAutoLock(m_pLock);
-
- if (iPosition < 0) {
- return E_INVALIDARG;
- }
- if (iPosition > 0) {
- return VFW_S_NO_MORE_ITEMS;
- }
-
- pmt->ResetFormatBuffer();
- pmt->InitMediaType();
- pmt->majortype = MEDIATYPE_Stream;
- pmt->subtype = MEDIASUBTYPE_NULL;
- pmt->formattype = FORMAT_None;
-
- return S_OK;
+ CAutoLock cAutoLock(m_pLock);
+
+ if (iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if (iPosition > 0) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
+
+ pmt->ResetFormatBuffer();
+ pmt->InitMediaType();
+ pmt->majortype = MEDIATYPE_Stream;
+ pmt->subtype = MEDIASUBTYPE_NULL;
+ pmt->formattype = FORMAT_None;
+
+ return S_OK;
}
HRESULT CBaseMuxerOutputPin::DeliverEndOfStream()
{
- m_pBitStream = NULL;
+ m_pBitStream = NULL;
- return __super::DeliverEndOfStream();
+ return __super::DeliverEndOfStream();
}
STDMETHODIMP CBaseMuxerOutputPin::Notify(IBaseFilter* pSender, Quality q)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
//
@@ -125,364 +125,364 @@ STDMETHODIMP CBaseMuxerOutputPin::Notify(IBaseFilter* pSender, Quality q)
//
CBaseMuxerRawOutputPin::CBaseMuxerRawOutputPin(LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseMuxerOutputPin(pName, pFilter, pLock, phr)
+ : CBaseMuxerOutputPin(pName, pFilter, pLock, phr)
{
}
STDMETHODIMP CBaseMuxerRawOutputPin::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- QI(IBaseMuxerRelatedPin)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IBaseMuxerRelatedPin)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
void CBaseMuxerRawOutputPin::MuxHeader(const CMediaType& mt)
{
- CComQIPtr<IBitStream> pBitStream = GetBitStream();
- if (!pBitStream) {
- return;
- }
-
- const BYTE utf8bom[3] = {0xef, 0xbb, 0xbf};
-
- if ((mt.subtype == FOURCCMap('1CVA') || mt.subtype == FOURCCMap('1cva')) && mt.formattype == FORMAT_MPEG2_VIDEO) {
- MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.Format();
-
- for (DWORD i = 0; i < vih->cbSequenceHeader-2; i += 2) {
- pBitStream->BitWrite(0x00000001, 32);
- WORD size = (((BYTE*)vih->dwSequenceHeader)[i+0]<<8) | ((BYTE*)vih->dwSequenceHeader)[i+1];
- pBitStream->ByteWrite(&((BYTE*)vih->dwSequenceHeader)[i+2], size);
- i += size;
- }
- } else if (mt.subtype == MEDIASUBTYPE_UTF8) {
- pBitStream->ByteWrite(utf8bom, sizeof(utf8bom));
- } else if (mt.subtype == MEDIASUBTYPE_SSA || mt.subtype == MEDIASUBTYPE_ASS || mt.subtype == MEDIASUBTYPE_ASS2) {
- SUBTITLEINFO* si = (SUBTITLEINFO*)mt.Format();
- BYTE* p = (BYTE*)si + si->dwOffset;
-
- if (memcmp(utf8bom, p, 3) != 0) {
- pBitStream->ByteWrite(utf8bom, sizeof(utf8bom));
- }
-
- CStringA str((char*)p, mt.FormatLength() - (p - mt.Format()));
- pBitStream->StrWrite(str + '\n', true);
-
- if (str.Find("[Events]") < 0) {
- pBitStream->StrWrite("\n\n[Events]\n", true);
- }
- } else if (mt.subtype == MEDIASUBTYPE_VOBSUB) {
- m_idx.RemoveAll();
- } else if (mt.majortype == MEDIATYPE_Audio
- && (mt.subtype == MEDIASUBTYPE_PCM
- || mt.subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO
- || mt.subtype == FOURCCMap(WAVE_FORMAT_EXTENSIBLE)
- || mt.subtype == FOURCCMap(WAVE_FORMAT_IEEE_FLOAT))
- && mt.formattype == FORMAT_WaveFormatEx) {
- pBitStream->BitWrite('RIFF', 32);
- pBitStream->BitWrite(0, 32); // file length - 8, set later
- pBitStream->BitWrite('WAVE', 32);
-
- pBitStream->BitWrite('fmt ', 32);
- pBitStream->ByteWrite(&mt.cbFormat, 4);
- pBitStream->ByteWrite(mt.pbFormat, mt.cbFormat);
-
- pBitStream->BitWrite('data', 32);
- pBitStream->BitWrite(0, 32); // data length, set later
- }
+ CComQIPtr<IBitStream> pBitStream = GetBitStream();
+ if (!pBitStream) {
+ return;
+ }
+
+ const BYTE utf8bom[3] = {0xef, 0xbb, 0xbf};
+
+ if ((mt.subtype == FOURCCMap('1CVA') || mt.subtype == FOURCCMap('1cva')) && mt.formattype == FORMAT_MPEG2_VIDEO) {
+ MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.Format();
+
+ for (DWORD i = 0; i < vih->cbSequenceHeader - 2; i += 2) {
+ pBitStream->BitWrite(0x00000001, 32);
+ WORD size = (((BYTE*)vih->dwSequenceHeader)[i + 0] << 8) | ((BYTE*)vih->dwSequenceHeader)[i + 1];
+ pBitStream->ByteWrite(&((BYTE*)vih->dwSequenceHeader)[i + 2], size);
+ i += size;
+ }
+ } else if (mt.subtype == MEDIASUBTYPE_UTF8) {
+ pBitStream->ByteWrite(utf8bom, sizeof(utf8bom));
+ } else if (mt.subtype == MEDIASUBTYPE_SSA || mt.subtype == MEDIASUBTYPE_ASS || mt.subtype == MEDIASUBTYPE_ASS2) {
+ SUBTITLEINFO* si = (SUBTITLEINFO*)mt.Format();
+ BYTE* p = (BYTE*)si + si->dwOffset;
+
+ if (memcmp(utf8bom, p, 3) != 0) {
+ pBitStream->ByteWrite(utf8bom, sizeof(utf8bom));
+ }
+
+ CStringA str((char*)p, mt.FormatLength() - (p - mt.Format()));
+ pBitStream->StrWrite(str + '\n', true);
+
+ if (str.Find("[Events]") < 0) {
+ pBitStream->StrWrite("\n\n[Events]\n", true);
+ }
+ } else if (mt.subtype == MEDIASUBTYPE_VOBSUB) {
+ m_idx.RemoveAll();
+ } else if (mt.majortype == MEDIATYPE_Audio
+ && (mt.subtype == MEDIASUBTYPE_PCM
+ || mt.subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO
+ || mt.subtype == FOURCCMap(WAVE_FORMAT_EXTENSIBLE)
+ || mt.subtype == FOURCCMap(WAVE_FORMAT_IEEE_FLOAT))
+ && mt.formattype == FORMAT_WaveFormatEx) {
+ pBitStream->BitWrite('RIFF', 32);
+ pBitStream->BitWrite(0, 32); // file length - 8, set later
+ pBitStream->BitWrite('WAVE', 32);
+
+ pBitStream->BitWrite('fmt ', 32);
+ pBitStream->ByteWrite(&mt.cbFormat, 4);
+ pBitStream->ByteWrite(mt.pbFormat, mt.cbFormat);
+
+ pBitStream->BitWrite('data', 32);
+ pBitStream->BitWrite(0, 32); // data length, set later
+ }
}
void CBaseMuxerRawOutputPin::MuxPacket(const CMediaType& mt, const MuxerPacket* pPacket)
{
- CComQIPtr<IBitStream> pBitStream = GetBitStream();
- if (!pBitStream) {
- return;
- }
-
- const BYTE* pData = pPacket->pData.GetData();
- const int DataSize = int(pPacket->pData.GetCount());
-
- if (mt.subtype == MEDIASUBTYPE_AAC && mt.formattype == FORMAT_WaveFormatEx) {
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
-
- int profile = 0;
-
- int srate_idx = 11;
- if (92017 <= wfe->nSamplesPerSec) {
- srate_idx = 0;
- } else if (75132 <= wfe->nSamplesPerSec) {
- srate_idx = 1;
- } else if (55426 <= wfe->nSamplesPerSec) {
- srate_idx = 2;
- } else if (46009 <= wfe->nSamplesPerSec) {
- srate_idx = 3;
- } else if (37566 <= wfe->nSamplesPerSec) {
- srate_idx = 4;
- } else if (27713 <= wfe->nSamplesPerSec) {
- srate_idx = 5;
- } else if (23004 <= wfe->nSamplesPerSec) {
- srate_idx = 6;
- } else if (18783 <= wfe->nSamplesPerSec) {
- srate_idx = 7;
- } else if (13856 <= wfe->nSamplesPerSec) {
- srate_idx = 8;
- } else if (11502 <= wfe->nSamplesPerSec) {
- srate_idx = 9;
- } else if (9391 <= wfe->nSamplesPerSec) {
- srate_idx = 10;
- }
-
- int channels = wfe->nChannels;
-
- if (wfe->cbSize >= 2) {
- BYTE* p = (BYTE*)(wfe+1);
- profile = (p[0]>>3)-1;
- srate_idx = ((p[0]&7)<<1)|((p[1]&0x80)>>7);
- channels = (p[1]>>3)&15;
- }
-
- int len = (DataSize + 7) & 0x1fff;
-
- BYTE hdr[7] = {0xff, 0xf9};
- hdr[2] = (profile<<6) | (srate_idx<<2) | ((channels&4)>>2);
- hdr[3] = ((channels&3)<<6) | (len>>11);
- hdr[4] = (len>>3)&0xff;
- hdr[5] = ((len&7)<<5) | 0x1f;
- hdr[6] = 0xfc;
-
- pBitStream->ByteWrite(hdr, sizeof(hdr));
- } else if ((mt.subtype == FOURCCMap('1CVA') || mt.subtype == FOURCCMap('1cva')) && mt.formattype == FORMAT_MPEG2_VIDEO) {
- const BYTE* p = pData;
- int i = DataSize;
-
- while (i >= 4) {
- DWORD len = (p[0]<<24)|(p[1]<<16)|(p[2]<<8)|p[3];
-
- i -= len + 4;
- p += len + 4;
- }
-
- if (i == 0) {
- p = pData;
- i = DataSize;
-
- while (i >= 4) {
- DWORD len = (p[0]<<24)|(p[1]<<16)|(p[2]<<8)|p[3];
-
- pBitStream->BitWrite(0x00000001, 32);
-
- p += 4;
- i -= 4;
-
- if (len > (DWORD)i || len == 1) {
- len = i;
- ASSERT(0);
- }
-
- pBitStream->ByteWrite(p, len);
-
- p += len;
- i -= len;
- }
-
- return;
- }
- } else if (mt.subtype == MEDIASUBTYPE_UTF8 || mt.majortype == MEDIATYPE_Text) {
- CStringA str((char*)pData, DataSize);
- str.Trim();
- if (str.IsEmpty()) {
- return;
- }
-
- DVD_HMSF_TIMECODE start = RT2HMSF(pPacket->rtStart, 25);
- DVD_HMSF_TIMECODE stop = RT2HMSF(pPacket->rtStop, 25);
-
- str.Format("%d\n%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\n%s\n\n",
- pPacket->index+1,
- start.bHours, start.bMinutes, start.bSeconds, (int)((pPacket->rtStart/10000)%1000),
- stop.bHours, stop.bMinutes, stop.bSeconds, (int)((pPacket->rtStop/10000)%1000),
- CStringA(str));
-
- pBitStream->StrWrite(str, true);
-
- return;
- } else if (mt.subtype == MEDIASUBTYPE_SSA || mt.subtype == MEDIASUBTYPE_ASS || mt.subtype == MEDIASUBTYPE_ASS2) {
- CStringA str((char*)pData, DataSize);
- str.Trim();
- if (str.IsEmpty()) {
- return;
- }
-
- DVD_HMSF_TIMECODE start = RT2HMSF(pPacket->rtStart, 25);
- DVD_HMSF_TIMECODE stop = RT2HMSF(pPacket->rtStop, 25);
-
- size_t fields = mt.subtype == MEDIASUBTYPE_ASS2 ? 10 : 9;
-
- CAtlList<CStringA> sl;
- Explode(str, sl, ',', fields);
- if (sl.GetCount() < fields) {
- return;
- }
-
- CStringA readorder = sl.RemoveHead(); // TODO
- CStringA layer = sl.RemoveHead();
- CStringA style = sl.RemoveHead();
- CStringA actor = sl.RemoveHead();
- CStringA left = sl.RemoveHead();
- CStringA right = sl.RemoveHead();
- CStringA top = sl.RemoveHead();
- if (fields == 10) {
- top += ',' + sl.RemoveHead(); // bottom
- }
- CStringA effect = sl.RemoveHead();
- str = sl.RemoveHead();
-
- if (mt.subtype == MEDIASUBTYPE_SSA) {
- layer = "Marked=0";
- }
-
- str.Format("Dialogue: %s,%d:%02d:%02d.%02d,%d:%02d:%02d.%02d,%s,%s,%s,%s,%s,%s,%s\n",
- layer,
- start.bHours, start.bMinutes, start.bSeconds, (int)((pPacket->rtStart/100000)%100),
- stop.bHours, stop.bMinutes, stop.bSeconds, (int)((pPacket->rtStop/100000)%100),
- style, actor, left, right, top, effect,
- CStringA(str));
-
- pBitStream->StrWrite(str, true);
-
- return;
- } else if (mt.subtype == MEDIASUBTYPE_VOBSUB) {
- bool fTimeValid = pPacket->IsTimeValid();
-
- if (fTimeValid) {
- idx_t i;
- i.rt = pPacket->rtStart;
- i.fp = pBitStream->GetPos();
- m_idx.AddTail(i);
- }
-
- int DataSizeLeft = DataSize;
-
- while (DataSizeLeft > 0) {
- int BytesAvail = 0x7ec - (fTimeValid ? 9 : 4);
- int Size = min(BytesAvail, DataSizeLeft);
- int Padding = 0x800 - Size - 20 - (fTimeValid ? 9 : 4);
-
- pBitStream->BitWrite(0x000001ba, 32);
- pBitStream->BitWrite(0x440004000401ui64, 48);
- pBitStream->BitWrite(0x000003f8, 32);
- pBitStream->BitWrite(0x000001bd, 32);
-
- if (fTimeValid) {
- pBitStream->BitWrite(Size+9, 16);
- pBitStream->BitWrite(0x8180052100010001ui64, 64);
- } else {
- pBitStream->BitWrite(Size+4, 16);
- pBitStream->BitWrite(0x810000, 24);
- }
-
- pBitStream->BitWrite(0x20, 8);
-
- pBitStream->ByteWrite(pData, Size);
-
- pData += Size;
- DataSizeLeft -= Size;
-
- if (Padding > 0) {
- Padding -= 6;
- ASSERT(Padding >= 0);
- pBitStream->BitWrite(0x000001be, 32);
- pBitStream->BitWrite(Padding, 16);
- while (Padding-- > 0) {
- pBitStream->BitWrite(0xff, 8);
- }
- }
-
- fTimeValid = false;
- }
-
- return;
- } else if (mt.subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
-
- // This code is probably totally broken for anything but 16 bits
- for (int i = 0, bps = wfe->wBitsPerSample/8; i < DataSize; i += bps)
- for (int j = bps-1; j >= 0; j--) {
- pBitStream->BitWrite(pData[i+j], 8);
- }
-
- return;
- }
- // else // TODO: restore more streams (vorbis to ogg)
-
- pBitStream->ByteWrite(pData, DataSize);
+ CComQIPtr<IBitStream> pBitStream = GetBitStream();
+ if (!pBitStream) {
+ return;
+ }
+
+ const BYTE* pData = pPacket->pData.GetData();
+ const int DataSize = int(pPacket->pData.GetCount());
+
+ if (mt.subtype == MEDIASUBTYPE_AAC && mt.formattype == FORMAT_WaveFormatEx) {
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
+
+ int profile = 0;
+
+ int srate_idx = 11;
+ if (92017 <= wfe->nSamplesPerSec) {
+ srate_idx = 0;
+ } else if (75132 <= wfe->nSamplesPerSec) {
+ srate_idx = 1;
+ } else if (55426 <= wfe->nSamplesPerSec) {
+ srate_idx = 2;
+ } else if (46009 <= wfe->nSamplesPerSec) {
+ srate_idx = 3;
+ } else if (37566 <= wfe->nSamplesPerSec) {
+ srate_idx = 4;
+ } else if (27713 <= wfe->nSamplesPerSec) {
+ srate_idx = 5;
+ } else if (23004 <= wfe->nSamplesPerSec) {
+ srate_idx = 6;
+ } else if (18783 <= wfe->nSamplesPerSec) {
+ srate_idx = 7;
+ } else if (13856 <= wfe->nSamplesPerSec) {
+ srate_idx = 8;
+ } else if (11502 <= wfe->nSamplesPerSec) {
+ srate_idx = 9;
+ } else if (9391 <= wfe->nSamplesPerSec) {
+ srate_idx = 10;
+ }
+
+ int channels = wfe->nChannels;
+
+ if (wfe->cbSize >= 2) {
+ BYTE* p = (BYTE*)(wfe + 1);
+ profile = (p[0] >> 3) - 1;
+ srate_idx = ((p[0] & 7) << 1) | ((p[1] & 0x80) >> 7);
+ channels = (p[1] >> 3) & 15;
+ }
+
+ int len = (DataSize + 7) & 0x1fff;
+
+ BYTE hdr[7] = {0xff, 0xf9};
+ hdr[2] = (profile << 6) | (srate_idx << 2) | ((channels & 4) >> 2);
+ hdr[3] = ((channels & 3) << 6) | (len >> 11);
+ hdr[4] = (len >> 3) & 0xff;
+ hdr[5] = ((len & 7) << 5) | 0x1f;
+ hdr[6] = 0xfc;
+
+ pBitStream->ByteWrite(hdr, sizeof(hdr));
+ } else if ((mt.subtype == FOURCCMap('1CVA') || mt.subtype == FOURCCMap('1cva')) && mt.formattype == FORMAT_MPEG2_VIDEO) {
+ const BYTE* p = pData;
+ int i = DataSize;
+
+ while (i >= 4) {
+ DWORD len = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
+
+ i -= len + 4;
+ p += len + 4;
+ }
+
+ if (i == 0) {
+ p = pData;
+ i = DataSize;
+
+ while (i >= 4) {
+ DWORD len = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
+
+ pBitStream->BitWrite(0x00000001, 32);
+
+ p += 4;
+ i -= 4;
+
+ if (len > (DWORD)i || len == 1) {
+ len = i;
+ ASSERT(0);
+ }
+
+ pBitStream->ByteWrite(p, len);
+
+ p += len;
+ i -= len;
+ }
+
+ return;
+ }
+ } else if (mt.subtype == MEDIASUBTYPE_UTF8 || mt.majortype == MEDIATYPE_Text) {
+ CStringA str((char*)pData, DataSize);
+ str.Trim();
+ if (str.IsEmpty()) {
+ return;
+ }
+
+ DVD_HMSF_TIMECODE start = RT2HMSF(pPacket->rtStart, 25);
+ DVD_HMSF_TIMECODE stop = RT2HMSF(pPacket->rtStop, 25);
+
+ str.Format("%d\n%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\n%s\n\n",
+ pPacket->index + 1,
+ start.bHours, start.bMinutes, start.bSeconds, (int)((pPacket->rtStart / 10000) % 1000),
+ stop.bHours, stop.bMinutes, stop.bSeconds, (int)((pPacket->rtStop / 10000) % 1000),
+ CStringA(str));
+
+ pBitStream->StrWrite(str, true);
+
+ return;
+ } else if (mt.subtype == MEDIASUBTYPE_SSA || mt.subtype == MEDIASUBTYPE_ASS || mt.subtype == MEDIASUBTYPE_ASS2) {
+ CStringA str((char*)pData, DataSize);
+ str.Trim();
+ if (str.IsEmpty()) {
+ return;
+ }
+
+ DVD_HMSF_TIMECODE start = RT2HMSF(pPacket->rtStart, 25);
+ DVD_HMSF_TIMECODE stop = RT2HMSF(pPacket->rtStop, 25);
+
+ size_t fields = mt.subtype == MEDIASUBTYPE_ASS2 ? 10 : 9;
+
+ CAtlList<CStringA> sl;
+ Explode(str, sl, ',', fields);
+ if (sl.GetCount() < fields) {
+ return;
+ }
+
+ CStringA readorder = sl.RemoveHead(); // TODO
+ CStringA layer = sl.RemoveHead();
+ CStringA style = sl.RemoveHead();
+ CStringA actor = sl.RemoveHead();
+ CStringA left = sl.RemoveHead();
+ CStringA right = sl.RemoveHead();
+ CStringA top = sl.RemoveHead();
+ if (fields == 10) {
+ top += ',' + sl.RemoveHead(); // bottom
+ }
+ CStringA effect = sl.RemoveHead();
+ str = sl.RemoveHead();
+
+ if (mt.subtype == MEDIASUBTYPE_SSA) {
+ layer = "Marked=0";
+ }
+
+ str.Format("Dialogue: %s,%d:%02d:%02d.%02d,%d:%02d:%02d.%02d,%s,%s,%s,%s,%s,%s,%s\n",
+ layer,
+ start.bHours, start.bMinutes, start.bSeconds, (int)((pPacket->rtStart / 100000) % 100),
+ stop.bHours, stop.bMinutes, stop.bSeconds, (int)((pPacket->rtStop / 100000) % 100),
+ style, actor, left, right, top, effect,
+ CStringA(str));
+
+ pBitStream->StrWrite(str, true);
+
+ return;
+ } else if (mt.subtype == MEDIASUBTYPE_VOBSUB) {
+ bool fTimeValid = pPacket->IsTimeValid();
+
+ if (fTimeValid) {
+ idx_t i;
+ i.rt = pPacket->rtStart;
+ i.fp = pBitStream->GetPos();
+ m_idx.AddTail(i);
+ }
+
+ int DataSizeLeft = DataSize;
+
+ while (DataSizeLeft > 0) {
+ int BytesAvail = 0x7ec - (fTimeValid ? 9 : 4);
+ int Size = min(BytesAvail, DataSizeLeft);
+ int Padding = 0x800 - Size - 20 - (fTimeValid ? 9 : 4);
+
+ pBitStream->BitWrite(0x000001ba, 32);
+ pBitStream->BitWrite(0x440004000401ui64, 48);
+ pBitStream->BitWrite(0x000003f8, 32);
+ pBitStream->BitWrite(0x000001bd, 32);
+
+ if (fTimeValid) {
+ pBitStream->BitWrite(Size + 9, 16);
+ pBitStream->BitWrite(0x8180052100010001ui64, 64);
+ } else {
+ pBitStream->BitWrite(Size + 4, 16);
+ pBitStream->BitWrite(0x810000, 24);
+ }
+
+ pBitStream->BitWrite(0x20, 8);
+
+ pBitStream->ByteWrite(pData, Size);
+
+ pData += Size;
+ DataSizeLeft -= Size;
+
+ if (Padding > 0) {
+ Padding -= 6;
+ ASSERT(Padding >= 0);
+ pBitStream->BitWrite(0x000001be, 32);
+ pBitStream->BitWrite(Padding, 16);
+ while (Padding-- > 0) {
+ pBitStream->BitWrite(0xff, 8);
+ }
+ }
+
+ fTimeValid = false;
+ }
+
+ return;
+ } else if (mt.subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
+
+ // This code is probably totally broken for anything but 16 bits
+ for (int i = 0, bps = wfe->wBitsPerSample / 8; i < DataSize; i += bps)
+ for (int j = bps - 1; j >= 0; j--) {
+ pBitStream->BitWrite(pData[i + j], 8);
+ }
+
+ return;
+ }
+ // else // TODO: restore more streams (vorbis to ogg)
+
+ pBitStream->ByteWrite(pData, DataSize);
}
void CBaseMuxerRawOutputPin::MuxFooter(const CMediaType& mt)
{
- CComQIPtr<IBitStream> pBitStream = GetBitStream();
- if (!pBitStream) {
- return;
- }
-
- if (mt.majortype == MEDIATYPE_Audio
- && (mt.subtype == MEDIASUBTYPE_PCM
- || mt.subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO
- || mt.subtype == FOURCCMap(WAVE_FORMAT_EXTENSIBLE)
- || mt.subtype == FOURCCMap(WAVE_FORMAT_IEEE_FLOAT))
- && mt.formattype == FORMAT_WaveFormatEx) {
- pBitStream->BitFlush();
-
- ASSERT(pBitStream->GetPos() <= 0xffffffff);
- UINT32 size = (UINT32)pBitStream->GetPos();
-
- size -= 8;
- pBitStream->Seek(4);
- pBitStream->ByteWrite(&size, 4);
-
- size -= sizeof(RIFFLIST) + sizeof(RIFFCHUNK) + mt.FormatLength();
- pBitStream->Seek(sizeof(RIFFLIST) + sizeof(RIFFCHUNK) + mt.FormatLength() + 4);
- pBitStream->ByteWrite(&size, 4);
- } else if (mt.subtype == MEDIASUBTYPE_VOBSUB) {
- if (CComQIPtr<IFileSinkFilter> pFSF = GetFilterFromPin(GetConnected())) {
- WCHAR* fn = NULL;
- if (SUCCEEDED(pFSF->GetCurFile(&fn, NULL))) {
- CPathW p(fn);
- p.RenameExtension(L".idx");
- CoTaskMemFree(fn);
-
- FILE* f;
- if (!_tfopen_s(&f, CString((LPCWSTR)p), _T("w"))) {
- SUBTITLEINFO* si = (SUBTITLEINFO*)mt.Format();
-
- _ftprintf_s(f, _T("%s\n"), _T("# VobSub index file, v7 (do not modify this line!)"));
-
- fwrite(mt.Format() + si->dwOffset, mt.FormatLength() - si->dwOffset, 1, f);
-
- CString iso6391 = ISO6392To6391(si->IsoLang);
- if (iso6391.IsEmpty()) {
- iso6391 = _T("--");
- }
- _ftprintf_s(f, _T("\nlangidx: 0\n\nid: %s, index: 0\n"), iso6391);
-
- CString alt = CString(CStringW(si->TrackName));
- if (!alt.IsEmpty()) {
- _ftprintf_s(f, _T("alt: %s\n"), alt);
- }
-
- POSITION pos = m_idx.GetHeadPosition();
- while (pos) {
- const idx_t& i = m_idx.GetNext(pos);
- DVD_HMSF_TIMECODE start = RT2HMSF(i.rt, 25);
- _ftprintf_s(f, _T("timestamp: %02d:%02d:%02d:%03d, filepos: %09I64x\n"),
- start.bHours, start.bMinutes, start.bSeconds, (int)((i.rt/10000)%1000),
- i.fp);
- }
-
- fclose(f);
- }
- }
- }
- }
+ CComQIPtr<IBitStream> pBitStream = GetBitStream();
+ if (!pBitStream) {
+ return;
+ }
+
+ if (mt.majortype == MEDIATYPE_Audio
+ && (mt.subtype == MEDIASUBTYPE_PCM
+ || mt.subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO
+ || mt.subtype == FOURCCMap(WAVE_FORMAT_EXTENSIBLE)
+ || mt.subtype == FOURCCMap(WAVE_FORMAT_IEEE_FLOAT))
+ && mt.formattype == FORMAT_WaveFormatEx) {
+ pBitStream->BitFlush();
+
+ ASSERT(pBitStream->GetPos() <= 0xffffffff);
+ UINT32 size = (UINT32)pBitStream->GetPos();
+
+ size -= 8;
+ pBitStream->Seek(4);
+ pBitStream->ByteWrite(&size, 4);
+
+ size -= sizeof(RIFFLIST) + sizeof(RIFFCHUNK) + mt.FormatLength();
+ pBitStream->Seek(sizeof(RIFFLIST) + sizeof(RIFFCHUNK) + mt.FormatLength() + 4);
+ pBitStream->ByteWrite(&size, 4);
+ } else if (mt.subtype == MEDIASUBTYPE_VOBSUB) {
+ if (CComQIPtr<IFileSinkFilter> pFSF = GetFilterFromPin(GetConnected())) {
+ WCHAR* fn = NULL;
+ if (SUCCEEDED(pFSF->GetCurFile(&fn, NULL))) {
+ CPathW p(fn);
+ p.RenameExtension(L".idx");
+ CoTaskMemFree(fn);
+
+ FILE* f;
+ if (!_tfopen_s(&f, CString((LPCWSTR)p), _T("w"))) {
+ SUBTITLEINFO* si = (SUBTITLEINFO*)mt.Format();
+
+ _ftprintf_s(f, _T("%s\n"), _T("# VobSub index file, v7 (do not modify this line!)"));
+
+ fwrite(mt.Format() + si->dwOffset, mt.FormatLength() - si->dwOffset, 1, f);
+
+ CString iso6391 = ISO6392To6391(si->IsoLang);
+ if (iso6391.IsEmpty()) {
+ iso6391 = _T("--");
+ }
+ _ftprintf_s(f, _T("\nlangidx: 0\n\nid: %s, index: 0\n"), iso6391);
+
+ CString alt = CString(CStringW(si->TrackName));
+ if (!alt.IsEmpty()) {
+ _ftprintf_s(f, _T("alt: %s\n"), alt);
+ }
+
+ POSITION pos = m_idx.GetHeadPosition();
+ while (pos) {
+ const idx_t& i = m_idx.GetNext(pos);
+ DVD_HMSF_TIMECODE start = RT2HMSF(i.rt, 25);
+ _ftprintf_s(f, _T("timestamp: %02d:%02d:%02d:%03d, filepos: %09I64x\n"),
+ start.bHours, start.bMinutes, start.bSeconds, (int)((i.rt / 10000) % 1000),
+ i.fp);
+ }
+
+ fclose(f);
+ }
+ }
+ }
+ }
}
diff --git a/src/filters/muxer/BaseMuxer/BaseMuxerOutputPin.h b/src/filters/muxer/BaseMuxer/BaseMuxerOutputPin.h
index 995ea6bc0..3a0d1c25f 100644
--- a/src/filters/muxer/BaseMuxer/BaseMuxerOutputPin.h
+++ b/src/filters/muxer/BaseMuxer/BaseMuxerOutputPin.h
@@ -29,42 +29,42 @@
class CBaseMuxerOutputPin : public CBaseOutputPin
{
- CComPtr<IBitStream> m_pBitStream;
+ CComPtr<IBitStream> m_pBitStream;
public:
- CBaseMuxerOutputPin(LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
- virtual ~CBaseMuxerOutputPin() {}
+ CBaseMuxerOutputPin(LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
+ virtual ~CBaseMuxerOutputPin() {}
- IBitStream* GetBitStream();
+ IBitStream* GetBitStream();
- HRESULT BreakConnect();
+ HRESULT BreakConnect();
- HRESULT DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT CheckMediaType(const CMediaType* pmt);
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
+ HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT GetMediaType(int iPosition, CMediaType* pmt);
- HRESULT DeliverEndOfStream();
+ HRESULT DeliverEndOfStream();
- STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
+ STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
};
class CBaseMuxerRawOutputPin : public CBaseMuxerOutputPin, public CBaseMuxerRelatedPin
{
- struct idx_t {
- REFERENCE_TIME rt;
- __int64 fp;
- };
- CAtlList<idx_t> m_idx;
+ struct idx_t {
+ REFERENCE_TIME rt;
+ __int64 fp;
+ };
+ CAtlList<idx_t> m_idx;
public:
- CBaseMuxerRawOutputPin(LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
- virtual ~CBaseMuxerRawOutputPin() {}
+ CBaseMuxerRawOutputPin(LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
+ virtual ~CBaseMuxerRawOutputPin() {}
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- virtual void MuxHeader(const CMediaType& mt);
- virtual void MuxPacket(const CMediaType& mt, const MuxerPacket* pPacket);
- virtual void MuxFooter(const CMediaType& mt);
+ virtual void MuxHeader(const CMediaType& mt);
+ virtual void MuxPacket(const CMediaType& mt, const MuxerPacket* pPacket);
+ virtual void MuxFooter(const CMediaType& mt);
};
diff --git a/src/filters/muxer/BaseMuxer/BaseMuxerRelatedPin.cpp b/src/filters/muxer/BaseMuxer/BaseMuxerRelatedPin.cpp
index 3b216c1ca..8e82fd9ad 100644
--- a/src/filters/muxer/BaseMuxer/BaseMuxerRelatedPin.cpp
+++ b/src/filters/muxer/BaseMuxer/BaseMuxerRelatedPin.cpp
@@ -40,11 +40,11 @@ CBaseMuxerRelatedPin::~CBaseMuxerRelatedPin()
STDMETHODIMP CBaseMuxerRelatedPin::SetRelatedPin(CBasePin* pPin)
{
- m_pRelatedPin = pPin;
- return S_OK;
+ m_pRelatedPin = pPin;
+ return S_OK;
}
STDMETHODIMP_(CBasePin*) CBaseMuxerRelatedPin::GetRelatedPin()
{
- return m_pRelatedPin;
+ return m_pRelatedPin;
}
diff --git a/src/filters/muxer/BaseMuxer/BaseMuxerRelatedPin.h b/src/filters/muxer/BaseMuxer/BaseMuxerRelatedPin.h
index e9384a698..bd486f7ed 100644
--- a/src/filters/muxer/BaseMuxer/BaseMuxerRelatedPin.h
+++ b/src/filters/muxer/BaseMuxer/BaseMuxerRelatedPin.h
@@ -26,20 +26,20 @@
interface __declspec(uuid("EE6F2741-7DB4-4AAD-A3CB-545208EE4C0A"))
IBaseMuxerRelatedPin :
public IUnknown {
- STDMETHOD(SetRelatedPin) (CBasePin* pPin) = 0;
- STDMETHOD_(CBasePin*, GetRelatedPin) () = 0;
+ STDMETHOD(SetRelatedPin)(CBasePin * pPin) = 0;
+ STDMETHOD_(CBasePin*, GetRelatedPin)() = 0;
};
class CBaseMuxerRelatedPin : public IBaseMuxerRelatedPin
{
- CBasePin* m_pRelatedPin; // should not hold a reference because it would be circular
+ CBasePin* m_pRelatedPin; // should not hold a reference because it would be circular
public:
- CBaseMuxerRelatedPin();
- virtual ~CBaseMuxerRelatedPin();
+ CBaseMuxerRelatedPin();
+ virtual ~CBaseMuxerRelatedPin();
- // IBaseMuxerRelatedPin
+ // IBaseMuxerRelatedPin
- STDMETHODIMP SetRelatedPin(CBasePin* pPin);
- STDMETHODIMP_(CBasePin*) GetRelatedPin();
+ STDMETHODIMP SetRelatedPin(CBasePin* pPin);
+ STDMETHODIMP_(CBasePin*) GetRelatedPin();
};
diff --git a/src/filters/muxer/BaseMuxer/BitStream.cpp b/src/filters/muxer/BaseMuxer/BitStream.cpp
index bc0683ad0..a036f9c45 100644
--- a/src/filters/muxer/BaseMuxer/BitStream.cpp
+++ b/src/filters/muxer/BaseMuxer/BitStream.cpp
@@ -29,135 +29,135 @@
//
CBitStream::CBitStream(IStream* pStream, bool fThrowError)
- : CUnknown(_T("CBitStream"), NULL)
- , m_pStream(pStream)
- , m_fThrowError(fThrowError)
- , m_bitlen(0)
+ : CUnknown(_T("CBitStream"), NULL)
+ , m_pStream(pStream)
+ , m_fThrowError(fThrowError)
+ , m_bitlen(0)
{
- ASSERT(m_pStream);
+ ASSERT(m_pStream);
- LARGE_INTEGER li = {0};
- m_pStream->Seek(li, STREAM_SEEK_SET, NULL);
+ LARGE_INTEGER li = {0};
+ m_pStream->Seek(li, STREAM_SEEK_SET, NULL);
- ULARGE_INTEGER uli = {0};
- m_pStream->SetSize(uli); // not that it worked...
+ ULARGE_INTEGER uli = {0};
+ m_pStream->SetSize(uli); // not that it worked...
- m_pStream->Commit(S_OK); // also seems to have no effect, but maybe in the future...
+ m_pStream->Commit(S_OK); // also seems to have no effect, but maybe in the future...
}
CBitStream::~CBitStream()
{
- BitFlush();
+ BitFlush();
}
STDMETHODIMP CBitStream::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- *ppv = NULL;
+ *ppv = NULL;
- return
- QI(IBitStream)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IBitStream)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// IBitStream
STDMETHODIMP_(UINT64) CBitStream::GetPos()
{
- ULARGE_INTEGER pos = {0, 0};
- m_pStream->Seek(*(LARGE_INTEGER*)&pos, STREAM_SEEK_CUR, &pos);
- return pos.QuadPart;
+ ULARGE_INTEGER pos = {0, 0};
+ m_pStream->Seek(*(LARGE_INTEGER*)&pos, STREAM_SEEK_CUR, &pos);
+ return pos.QuadPart;
}
STDMETHODIMP_(UINT64) CBitStream::Seek(UINT64 pos)
{
- BitFlush();
-
- LARGE_INTEGER li;
- li.QuadPart = pos;
- ULARGE_INTEGER linew;
- linew.QuadPart = (ULONGLONG)-1;
- m_pStream->Seek(li, STREAM_SEEK_SET, &linew);
- ASSERT(li.QuadPart == (LONGLONG)linew.QuadPart);
- return linew.QuadPart;
+ BitFlush();
+
+ LARGE_INTEGER li;
+ li.QuadPart = pos;
+ ULARGE_INTEGER linew;
+ linew.QuadPart = (ULONGLONG) - 1;
+ m_pStream->Seek(li, STREAM_SEEK_SET, &linew);
+ ASSERT(li.QuadPart == (LONGLONG)linew.QuadPart);
+ return linew.QuadPart;
}
STDMETHODIMP CBitStream::ByteWrite(const void* pData, int len)
{
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- BitFlush();
+ BitFlush();
- if (len > 0) {
- ULONG cbWritten = 0;
- hr = m_pStream->Write(pData, len, &cbWritten);
+ if (len > 0) {
+ ULONG cbWritten = 0;
+ hr = m_pStream->Write(pData, len, &cbWritten);
- ASSERT(SUCCEEDED(hr));
- if (m_fThrowError && FAILED(hr)) {
- throw hr;
- }
- }
+ ASSERT(SUCCEEDED(hr));
+ if (m_fThrowError && FAILED(hr)) {
+ throw hr;
+ }
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CBitStream::BitWrite(UINT64 data, int len)
{
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- ASSERT(len >= 0 && len <= 64);
+ ASSERT(len >= 0 && len <= 64);
- if (len > 56) {
- BitWrite(data >> 56, len - 56);
- len = 56;
- }
+ if (len > 56) {
+ BitWrite(data >> 56, len - 56);
+ len = 56;
+ }
- m_bitbuff <<= len;
- m_bitbuff |= data & ((1ui64 << len) - 1);
- m_bitlen += len;
+ m_bitbuff <<= len;
+ m_bitbuff |= data & ((1ui64 << len) - 1);
+ m_bitlen += len;
- while (m_bitlen >= 8) {
- BYTE b = (BYTE)(m_bitbuff >> (m_bitlen - 8));
- hr = m_pStream->Write(&b, 1, NULL);
- m_bitlen -= 8;
+ while (m_bitlen >= 8) {
+ BYTE b = (BYTE)(m_bitbuff >> (m_bitlen - 8));
+ hr = m_pStream->Write(&b, 1, NULL);
+ m_bitlen -= 8;
- ASSERT(SUCCEEDED(hr));
- if (m_fThrowError && FAILED(hr)) {
- throw E_FAIL;
- }
- }
+ ASSERT(SUCCEEDED(hr));
+ if (m_fThrowError && FAILED(hr)) {
+ throw E_FAIL;
+ }
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CBitStream::BitFlush()
{
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- if (m_bitlen > 0) {
- ASSERT(m_bitlen < 8);
- BYTE b = (BYTE)(m_bitbuff << (8 - m_bitlen));
- hr = m_pStream->Write(&b, 1, NULL);
- m_bitlen = 0;
+ if (m_bitlen > 0) {
+ ASSERT(m_bitlen < 8);
+ BYTE b = (BYTE)(m_bitbuff << (8 - m_bitlen));
+ hr = m_pStream->Write(&b, 1, NULL);
+ m_bitlen = 0;
- ASSERT(SUCCEEDED(hr));
- if (m_fThrowError && FAILED(hr)) {
- throw E_FAIL;
- }
- }
+ ASSERT(SUCCEEDED(hr));
+ if (m_fThrowError && FAILED(hr)) {
+ throw E_FAIL;
+ }
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CBitStream::StrWrite(LPCSTR pData, BOOL bFixNewLine)
{
- CStringA str = pData;
+ CStringA str = pData;
- if (bFixNewLine) {
- str.Replace("\r", "");
- str.Replace("\n", "\r\n");
- }
+ if (bFixNewLine) {
+ str.Replace("\r", "");
+ str.Replace("\n", "\r\n");
+ }
- return ByteWrite((LPCSTR)str, str.GetLength());
+ return ByteWrite((LPCSTR)str, str.GetLength());
}
diff --git a/src/filters/muxer/BaseMuxer/BitStream.h b/src/filters/muxer/BaseMuxer/BitStream.h
index 7e758aff2..26b542cfb 100644
--- a/src/filters/muxer/BaseMuxer/BitStream.h
+++ b/src/filters/muxer/BaseMuxer/BitStream.h
@@ -26,34 +26,34 @@
interface __declspec(uuid("30AB78C7-5259-4594-AEFE-9C0FC2F08A5E"))
IBitStream :
public IUnknown {
- STDMETHOD_(UINT64, GetPos) () = 0;
- STDMETHOD_(UINT64, Seek) (UINT64 pos) = 0; // it's a _stream_, please don't seek if you don't have to
- STDMETHOD(ByteWrite) (const void* pData, int len) = 0;
- STDMETHOD(BitWrite) (UINT64 data, int len) = 0;
- STDMETHOD(BitFlush) () = 0;
- STDMETHOD(StrWrite) (LPCSTR pData, BOOL bFixNewLine) = 0;
+ STDMETHOD_(UINT64, GetPos)() = 0;
+ STDMETHOD_(UINT64, Seek)(UINT64 pos) = 0; // it's a _stream_, please don't seek if you don't have to
+ STDMETHOD(ByteWrite)(const void * pData, int len) = 0;
+ STDMETHOD(BitWrite)(UINT64 data, int len) = 0;
+ STDMETHOD(BitFlush)() = 0;
+ STDMETHOD(StrWrite)(LPCSTR pData, BOOL bFixNewLine) = 0;
};
class CBitStream : public CUnknown, public IBitStream
{
- CComPtr<IStream> m_pStream;
- bool m_fThrowError;
- UINT64 m_bitbuff;
- int m_bitlen;
+ CComPtr<IStream> m_pStream;
+ bool m_fThrowError;
+ UINT64 m_bitbuff;
+ int m_bitlen;
public:
- CBitStream(IStream* pStream, bool m_fThrowError = false);
- virtual ~CBitStream();
+ CBitStream(IStream* pStream, bool m_fThrowError = false);
+ virtual ~CBitStream();
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // IBitStream
+ // IBitStream
- STDMETHODIMP_(UINT64) GetPos();
- STDMETHODIMP_(UINT64) Seek(UINT64 pos);
- STDMETHODIMP ByteWrite(const void* pData, int len);
- STDMETHODIMP BitWrite(UINT64 data, int len);
- STDMETHODIMP BitFlush();
- STDMETHODIMP StrWrite(LPCSTR pData, BOOL bFixNewLine);
+ STDMETHODIMP_(UINT64) GetPos();
+ STDMETHODIMP_(UINT64) Seek(UINT64 pos);
+ STDMETHODIMP ByteWrite(const void* pData, int len);
+ STDMETHODIMP BitWrite(UINT64 data, int len);
+ STDMETHODIMP BitFlush();
+ STDMETHODIMP StrWrite(LPCSTR pData, BOOL bFixNewLine);
};
diff --git a/src/filters/muxer/BaseMuxer/stdafx.h b/src/filters/muxer/BaseMuxer/stdafx.h
index da1b20add..789cc67f2 100644
--- a/src/filters/muxer/BaseMuxer/stdafx.h
+++ b/src/filters/muxer/BaseMuxer/stdafx.h
@@ -26,16 +26,16 @@
#include "../../../DSUtil/SharedInclude.h"
#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#endif
-#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
#ifndef VC_EXTRALEAN
-#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
+#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
#include <afx.h>
-#include <afxwin.h> // MFC core and standard components
+#include <afxwin.h> // MFC core and standard components
#include <atlbase.h>
#include <atlcoll.h>
diff --git a/src/filters/muxer/DSMMuxer/DSMMuxer.cpp b/src/filters/muxer/DSMMuxer/DSMMuxer.cpp
index a8da28347..c542e1d70 100644
--- a/src/filters/muxer/DSMMuxer/DSMMuxer.cpp
+++ b/src/filters/muxer/DSMMuxer/DSMMuxer.cpp
@@ -35,32 +35,32 @@
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_DirectShowMedia}
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_DirectShowMedia}
};
const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, TRUE, &CLSID_NULL, NULL, 0, NULL},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
+ {L"Input", FALSE, FALSE, FALSE, TRUE, &CLSID_NULL, NULL, 0, NULL},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CDSMMuxerFilter), DSMMuxerName, MERIT_DO_NOT_USE, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory}
+ {&__uuidof(CDSMMuxerFilter), DSMMuxerName, MERIT_DO_NOT_USE, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory}
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDSMMuxerFilter>, NULL, &sudFilter[0]}
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDSMMuxerFilter>, NULL, &sudFilter[0]}
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -71,16 +71,16 @@ CFilterApp theApp;
template<typename T> static T myabs(T n)
{
- return n >= 0 ? n : -n;
+ return n >= 0 ? n : -n;
}
static int GetByteLength(UINT64 data, int min = 0)
{
- int i = 7;
- while (i >= min && ((BYTE*)&data)[i] == 0) {
- i--;
- }
- return ++i;
+ int i = 7;
+ while (i >= min && ((BYTE*)&data)[i] == 0) {
+ i--;
+ }
+ return ++i;
}
//
@@ -88,13 +88,13 @@ static int GetByteLength(UINT64 data, int min = 0)
//
CDSMMuxerFilter::CDSMMuxerFilter(LPUNKNOWN pUnk, HRESULT* phr, bool fAutoChap, bool fAutoRes)
- : CBaseMuxerFilter(pUnk, phr, __uuidof(this))
- , m_fAutoChap(fAutoChap)
- , m_fAutoRes(fAutoRes)
+ : CBaseMuxerFilter(pUnk, phr, __uuidof(this))
+ , m_fAutoChap(fAutoChap)
+ , m_fAutoRes(fAutoRes)
{
- if (phr) {
- *phr = S_OK;
- }
+ if (phr) {
+ *phr = S_OK;
+ }
}
CDSMMuxerFilter::~CDSMMuxerFilter()
@@ -103,348 +103,348 @@ CDSMMuxerFilter::~CDSMMuxerFilter()
STDMETHODIMP CDSMMuxerFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- *ppv = NULL;
+ *ppv = NULL;
- return
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
void CDSMMuxerFilter::MuxPacketHeader(IBitStream* pBS, dsmp_t type, UINT64 len)
{
- ASSERT(type < 32);
+ ASSERT(type < 32);
- int i = GetByteLength(len, 1);
+ int i = GetByteLength(len, 1);
- pBS->BitWrite(DSMSW, DSMSW_SIZE<<3);
- pBS->BitWrite(type, 5);
- pBS->BitWrite(i-1, 3);
- pBS->BitWrite(len, i<<3);
+ pBS->BitWrite(DSMSW, DSMSW_SIZE << 3);
+ pBS->BitWrite(type, 5);
+ pBS->BitWrite(i - 1, 3);
+ pBS->BitWrite(len, i << 3);
}
void CDSMMuxerFilter::MuxFileInfo(IBitStream* pBS)
{
- int len = 1;
- CSimpleMap<CStringA, CStringA> si;
-
- for (int i = 0; i < GetSize(); i++) {
- CStringA key = CStringA(CString(GetKeyAt(i))), value = UTF16To8(GetValueAt(i));
- if (key.GetLength() != 4) {
- continue;
- }
- si.Add(key, value);
- len += 4 + value.GetLength() + 1;
- }
-
- MuxPacketHeader(pBS, DSMP_FILEINFO, len);
- pBS->BitWrite(DSMF_VERSION, 8);
- for (int i = 0; i < si.GetSize(); i++) {
- CStringA key = si.GetKeyAt(i), value = si.GetValueAt(i);
- pBS->ByteWrite((LPCSTR)key, 4);
- pBS->ByteWrite((LPCSTR)value, value.GetLength()+1);
- }
+ int len = 1;
+ CSimpleMap<CStringA, CStringA> si;
+
+ for (int i = 0; i < GetSize(); i++) {
+ CStringA key = CStringA(CString(GetKeyAt(i))), value = UTF16To8(GetValueAt(i));
+ if (key.GetLength() != 4) {
+ continue;
+ }
+ si.Add(key, value);
+ len += 4 + value.GetLength() + 1;
+ }
+
+ MuxPacketHeader(pBS, DSMP_FILEINFO, len);
+ pBS->BitWrite(DSMF_VERSION, 8);
+ for (int i = 0; i < si.GetSize(); i++) {
+ CStringA key = si.GetKeyAt(i), value = si.GetValueAt(i);
+ pBS->ByteWrite((LPCSTR)key, 4);
+ pBS->ByteWrite((LPCSTR)value, value.GetLength() + 1);
+ }
}
void CDSMMuxerFilter::MuxStreamInfo(IBitStream* pBS, CBaseMuxerInputPin* pPin)
{
- int len = 1;
- CSimpleMap<CStringA, CStringA> si;
-
- for (int i = 0; i < pPin->GetSize(); i++) {
- CStringA key = CStringA(CString(pPin->GetKeyAt(i))), value = UTF16To8(pPin->GetValueAt(i));
- if (key.GetLength() != 4) {
- continue;
- }
- si.Add(key, value);
- len += 4 + value.GetLength() + 1;
- }
-
- if (len > 1) {
- MuxPacketHeader(pBS, DSMP_STREAMINFO, len);
- pBS->BitWrite(pPin->GetID(), 8);
- for (int i = 0; i < si.GetSize(); i++) {
- CStringA key = si.GetKeyAt(i), value = si.GetValueAt(i);
- pBS->ByteWrite((LPCSTR)key, 4);
- pBS->ByteWrite((LPCSTR)value, value.GetLength()+1);
- }
- }
+ int len = 1;
+ CSimpleMap<CStringA, CStringA> si;
+
+ for (int i = 0; i < pPin->GetSize(); i++) {
+ CStringA key = CStringA(CString(pPin->GetKeyAt(i))), value = UTF16To8(pPin->GetValueAt(i));
+ if (key.GetLength() != 4) {
+ continue;
+ }
+ si.Add(key, value);
+ len += 4 + value.GetLength() + 1;
+ }
+
+ if (len > 1) {
+ MuxPacketHeader(pBS, DSMP_STREAMINFO, len);
+ pBS->BitWrite(pPin->GetID(), 8);
+ for (int i = 0; i < si.GetSize(); i++) {
+ CStringA key = si.GetKeyAt(i), value = si.GetValueAt(i);
+ pBS->ByteWrite((LPCSTR)key, 4);
+ pBS->ByteWrite((LPCSTR)value, value.GetLength() + 1);
+ }
+ }
}
void CDSMMuxerFilter::MuxInit()
{
- m_sps.RemoveAll();
- m_isps.RemoveAll();
- m_rtPrevSyncPoint = _I64_MIN;
+ m_sps.RemoveAll();
+ m_isps.RemoveAll();
+ m_rtPrevSyncPoint = _I64_MIN;
}
void CDSMMuxerFilter::MuxHeader(IBitStream* pBS)
{
- CString muxer;
- muxer.Format(_T("DSM Muxer (%s)"), CString(__TIMESTAMP__));
-
- SetProperty(L"MUXR", CStringW(muxer));
- SetProperty(L"DATE", CStringW(CTime::GetCurrentTime().FormatGmt(_T("%Y-%m-%d %H:%M:%S"))));
-
- MuxFileInfo(pBS);
-
- POSITION pos = m_pPins.GetHeadPosition();
- while (pos) {
- CBaseMuxerInputPin* pPin = m_pPins.GetNext(pos);
- const CMediaType& mt = pPin->CurrentMediaType();
-
- ASSERT((mt.lSampleSize >> 30) == 0); // you don't need >1GB samples, do you?
-
- MuxPacketHeader(pBS, DSMP_MEDIATYPE, 5 + sizeof(GUID)*3 + mt.FormatLength());
- pBS->BitWrite(pPin->GetID(), 8);
- pBS->ByteWrite(&mt.majortype, sizeof(mt.majortype));
- pBS->ByteWrite(&mt.subtype, sizeof(mt.subtype));
- pBS->BitWrite(mt.bFixedSizeSamples, 1);
- pBS->BitWrite(mt.bTemporalCompression, 1);
- pBS->BitWrite(mt.lSampleSize, 30);
- pBS->ByteWrite(&mt.formattype, sizeof(mt.formattype));
- pBS->ByteWrite(mt.Format(), mt.FormatLength());
-
- MuxStreamInfo(pBS, pPin);
- }
-
- // resources & chapters
-
- CInterfaceList<IDSMResourceBag> pRBs;
- pRBs.AddTail(this);
-
- CComQIPtr<IDSMChapterBag> pCB = (IUnknown*)(INonDelegatingUnknown*)this;
-
- pos = m_pPins.GetHeadPosition();
- while (pos) {
- for (CComPtr<IPin> pPin = m_pPins.GetNext(pos)->GetConnected(); pPin; pPin = GetUpStreamPin(GetFilterFromPin(pPin))) {
- if (m_fAutoRes) {
- CComQIPtr<IDSMResourceBag> pPB = GetFilterFromPin(pPin);
- if (pPB && !pRBs.Find(pPB)) {
- pRBs.AddTail(pPB);
- }
- }
-
- if (m_fAutoChap) {
- if (!pCB || pCB->ChapGetCount() == 0) {
- pCB = GetFilterFromPin(pPin);
- }
- }
- }
- }
-
- // resources
-
- pos = pRBs.GetHeadPosition();
- while (pos) {
- IDSMResourceBag* pRB = pRBs.GetNext(pos);
-
- for (DWORD i = 0, j = pRB->ResGetCount(); i < j; i++) {
- CComBSTR name, desc, mime;
- BYTE* pData = NULL;
- DWORD len = 0;
- if (SUCCEEDED(pRB->ResGet(i, &name, &desc, &mime, &pData, &len, NULL))) {
- CStringA utf8_name = UTF16To8(name);
- CStringA utf8_desc = UTF16To8(desc);
- CStringA utf8_mime = UTF16To8(mime);
-
- MuxPacketHeader(pBS, DSMP_RESOURCE,
- 1 +
- utf8_name.GetLength()+1 +
- utf8_desc.GetLength()+1 +
- utf8_mime.GetLength()+1 +
- len);
-
- pBS->BitWrite(0, 2);
- pBS->BitWrite(0, 6); // reserved
- pBS->ByteWrite(utf8_name, utf8_name.GetLength()+1);
- pBS->ByteWrite(utf8_desc, utf8_desc.GetLength()+1);
- pBS->ByteWrite(utf8_mime, utf8_mime.GetLength()+1);
- pBS->ByteWrite(pData, len);
-
- CoTaskMemFree(pData);
- }
- }
- }
-
- // chapters
-
- if (pCB) {
- CAtlList<CDSMChapter> chapters;
- REFERENCE_TIME rtPrev = 0;
- int len = 0;
-
- pCB->ChapSort();
-
- for (DWORD i = 0; i < pCB->ChapGetCount(); i++) {
- CDSMChapter c;
- CComBSTR name;
- if (SUCCEEDED(pCB->ChapGet(i, &c.rt, &name))) {
- REFERENCE_TIME rtDiff = c.rt - rtPrev;
- rtPrev = c.rt;
- c.rt = rtDiff;
- c.name = name;
- len += 1 + GetByteLength(myabs(c.rt)) + UTF16To8(c.name).GetLength()+1;
- chapters.AddTail(c);
- }
- }
-
- if (chapters.GetCount()) {
- MuxPacketHeader(pBS, DSMP_CHAPTERS, len);
-
- pos = chapters.GetHeadPosition();
- while (pos) {
- CDSMChapter& c = chapters.GetNext(pos);
- CStringA name = UTF16To8(c.name);
- int irt = GetByteLength(myabs(c.rt));
- pBS->BitWrite(c.rt < 0, 1);
- pBS->BitWrite(irt, 3);
- pBS->BitWrite(0, 4);
- pBS->BitWrite(myabs(c.rt), irt<<3);
- pBS->ByteWrite((LPCSTR)name, name.GetLength()+1);
- }
- }
- }
+ CString muxer;
+ muxer.Format(_T("DSM Muxer (%s)"), CString(__TIMESTAMP__));
+
+ SetProperty(L"MUXR", CStringW(muxer));
+ SetProperty(L"DATE", CStringW(CTime::GetCurrentTime().FormatGmt(_T("%Y-%m-%d %H:%M:%S"))));
+
+ MuxFileInfo(pBS);
+
+ POSITION pos = m_pPins.GetHeadPosition();
+ while (pos) {
+ CBaseMuxerInputPin* pPin = m_pPins.GetNext(pos);
+ const CMediaType& mt = pPin->CurrentMediaType();
+
+ ASSERT((mt.lSampleSize >> 30) == 0); // you don't need >1GB samples, do you?
+
+ MuxPacketHeader(pBS, DSMP_MEDIATYPE, 5 + sizeof(GUID) * 3 + mt.FormatLength());
+ pBS->BitWrite(pPin->GetID(), 8);
+ pBS->ByteWrite(&mt.majortype, sizeof(mt.majortype));
+ pBS->ByteWrite(&mt.subtype, sizeof(mt.subtype));
+ pBS->BitWrite(mt.bFixedSizeSamples, 1);
+ pBS->BitWrite(mt.bTemporalCompression, 1);
+ pBS->BitWrite(mt.lSampleSize, 30);
+ pBS->ByteWrite(&mt.formattype, sizeof(mt.formattype));
+ pBS->ByteWrite(mt.Format(), mt.FormatLength());
+
+ MuxStreamInfo(pBS, pPin);
+ }
+
+ // resources & chapters
+
+ CInterfaceList<IDSMResourceBag> pRBs;
+ pRBs.AddTail(this);
+
+ CComQIPtr<IDSMChapterBag> pCB = (IUnknown*)(INonDelegatingUnknown*)this;
+
+ pos = m_pPins.GetHeadPosition();
+ while (pos) {
+ for (CComPtr<IPin> pPin = m_pPins.GetNext(pos)->GetConnected(); pPin; pPin = GetUpStreamPin(GetFilterFromPin(pPin))) {
+ if (m_fAutoRes) {
+ CComQIPtr<IDSMResourceBag> pPB = GetFilterFromPin(pPin);
+ if (pPB && !pRBs.Find(pPB)) {
+ pRBs.AddTail(pPB);
+ }
+ }
+
+ if (m_fAutoChap) {
+ if (!pCB || pCB->ChapGetCount() == 0) {
+ pCB = GetFilterFromPin(pPin);
+ }
+ }
+ }
+ }
+
+ // resources
+
+ pos = pRBs.GetHeadPosition();
+ while (pos) {
+ IDSMResourceBag* pRB = pRBs.GetNext(pos);
+
+ for (DWORD i = 0, j = pRB->ResGetCount(); i < j; i++) {
+ CComBSTR name, desc, mime;
+ BYTE* pData = NULL;
+ DWORD len = 0;
+ if (SUCCEEDED(pRB->ResGet(i, &name, &desc, &mime, &pData, &len, NULL))) {
+ CStringA utf8_name = UTF16To8(name);
+ CStringA utf8_desc = UTF16To8(desc);
+ CStringA utf8_mime = UTF16To8(mime);
+
+ MuxPacketHeader(pBS, DSMP_RESOURCE,
+ 1 +
+ utf8_name.GetLength() + 1 +
+ utf8_desc.GetLength() + 1 +
+ utf8_mime.GetLength() + 1 +
+ len);
+
+ pBS->BitWrite(0, 2);
+ pBS->BitWrite(0, 6); // reserved
+ pBS->ByteWrite(utf8_name, utf8_name.GetLength() + 1);
+ pBS->ByteWrite(utf8_desc, utf8_desc.GetLength() + 1);
+ pBS->ByteWrite(utf8_mime, utf8_mime.GetLength() + 1);
+ pBS->ByteWrite(pData, len);
+
+ CoTaskMemFree(pData);
+ }
+ }
+ }
+
+ // chapters
+
+ if (pCB) {
+ CAtlList<CDSMChapter> chapters;
+ REFERENCE_TIME rtPrev = 0;
+ int len = 0;
+
+ pCB->ChapSort();
+
+ for (DWORD i = 0; i < pCB->ChapGetCount(); i++) {
+ CDSMChapter c;
+ CComBSTR name;
+ if (SUCCEEDED(pCB->ChapGet(i, &c.rt, &name))) {
+ REFERENCE_TIME rtDiff = c.rt - rtPrev;
+ rtPrev = c.rt;
+ c.rt = rtDiff;
+ c.name = name;
+ len += 1 + GetByteLength(myabs(c.rt)) + UTF16To8(c.name).GetLength() + 1;
+ chapters.AddTail(c);
+ }
+ }
+
+ if (chapters.GetCount()) {
+ MuxPacketHeader(pBS, DSMP_CHAPTERS, len);
+
+ pos = chapters.GetHeadPosition();
+ while (pos) {
+ CDSMChapter& c = chapters.GetNext(pos);
+ CStringA name = UTF16To8(c.name);
+ int irt = GetByteLength(myabs(c.rt));
+ pBS->BitWrite(c.rt < 0, 1);
+ pBS->BitWrite(irt, 3);
+ pBS->BitWrite(0, 4);
+ pBS->BitWrite(myabs(c.rt), irt << 3);
+ pBS->ByteWrite((LPCSTR)name, name.GetLength() + 1);
+ }
+ }
+ }
}
void CDSMMuxerFilter::MuxPacket(IBitStream* pBS, const MuxerPacket* pPacket)
{
- if (pPacket->IsEOS()) {
- return;
- }
-
- if (pPacket->pPin->CurrentMediaType().majortype == MEDIATYPE_Text) {
- CStringA str((char*)pPacket->pData.GetData(), pPacket->pData.GetCount());
- str.Replace("\xff", " ");
- str.Replace("&nbsp;", " ");
- str.Replace("&nbsp", " ");
- str.Trim();
- if (str.IsEmpty()) {
- return;
- }
- }
-
- ASSERT(!pPacket->IsSyncPoint() || pPacket->IsTimeValid());
-
- REFERENCE_TIME rtTimeStamp = _I64_MIN, rtDuration = 0;
- int iTimeStamp = 0, iDuration = 0;
-
- if (pPacket->IsTimeValid()) {
- rtTimeStamp = pPacket->rtStart;
- rtDuration = max(pPacket->rtStop - pPacket->rtStart, 0);
-
- iTimeStamp = GetByteLength(myabs(rtTimeStamp));
- ASSERT(iTimeStamp <= 7);
-
- iDuration = GetByteLength(rtDuration);
- ASSERT(iDuration <= 7);
-
- IndexSyncPoint(pPacket, pBS->GetPos());
- }
-
- int len = 2 + iTimeStamp + iDuration + pPacket->pData.GetCount(); // id + flags + data
-
- MuxPacketHeader(pBS, DSMP_SAMPLE, len);
- pBS->BitWrite(pPacket->pPin->GetID(), 8);
- pBS->BitWrite(pPacket->IsSyncPoint(), 1);
- pBS->BitWrite(rtTimeStamp < 0, 1);
- pBS->BitWrite(iTimeStamp, 3);
- pBS->BitWrite(iDuration, 3);
- pBS->BitWrite(myabs(rtTimeStamp), iTimeStamp<<3);
- pBS->BitWrite(rtDuration, iDuration<<3);
- pBS->ByteWrite(pPacket->pData.GetData(), pPacket->pData.GetCount());
+ if (pPacket->IsEOS()) {
+ return;
+ }
+
+ if (pPacket->pPin->CurrentMediaType().majortype == MEDIATYPE_Text) {
+ CStringA str((char*)pPacket->pData.GetData(), pPacket->pData.GetCount());
+ str.Replace("\xff", " ");
+ str.Replace("&nbsp;", " ");
+ str.Replace("&nbsp", " ");
+ str.Trim();
+ if (str.IsEmpty()) {
+ return;
+ }
+ }
+
+ ASSERT(!pPacket->IsSyncPoint() || pPacket->IsTimeValid());
+
+ REFERENCE_TIME rtTimeStamp = _I64_MIN, rtDuration = 0;
+ int iTimeStamp = 0, iDuration = 0;
+
+ if (pPacket->IsTimeValid()) {
+ rtTimeStamp = pPacket->rtStart;
+ rtDuration = max(pPacket->rtStop - pPacket->rtStart, 0);
+
+ iTimeStamp = GetByteLength(myabs(rtTimeStamp));
+ ASSERT(iTimeStamp <= 7);
+
+ iDuration = GetByteLength(rtDuration);
+ ASSERT(iDuration <= 7);
+
+ IndexSyncPoint(pPacket, pBS->GetPos());
+ }
+
+ int len = 2 + iTimeStamp + iDuration + pPacket->pData.GetCount(); // id + flags + data
+
+ MuxPacketHeader(pBS, DSMP_SAMPLE, len);
+ pBS->BitWrite(pPacket->pPin->GetID(), 8);
+ pBS->BitWrite(pPacket->IsSyncPoint(), 1);
+ pBS->BitWrite(rtTimeStamp < 0, 1);
+ pBS->BitWrite(iTimeStamp, 3);
+ pBS->BitWrite(iDuration, 3);
+ pBS->BitWrite(myabs(rtTimeStamp), iTimeStamp << 3);
+ pBS->BitWrite(rtDuration, iDuration << 3);
+ pBS->ByteWrite(pPacket->pData.GetData(), pPacket->pData.GetCount());
}
void CDSMMuxerFilter::MuxFooter(IBitStream* pBS)
{
- // syncpoints
-
- int len = 0;
- CAtlList<IndexedSyncPoint> isps;
- REFERENCE_TIME rtPrev = 0, rt;
- UINT64 fpPrev = 0, fp;
-
- POSITION pos = m_isps.GetHeadPosition();
- while (pos) {
- IndexedSyncPoint& isp = m_isps.GetNext(pos);
- TRACE(_T("sp[%d]: %I64d %I64x\n"), isp.id, isp.rt, isp.fp);
-
- rt = isp.rt - rtPrev;
- rtPrev = isp.rt;
- fp = isp.fp - fpPrev;
- fpPrev = isp.fp;
-
- IndexedSyncPoint isp2;
- isp2.fp = fp;
- isp2.rt = rt;
- isps.AddTail(isp2);
-
- len += 1 + GetByteLength(myabs(rt)) + GetByteLength(fp); // flags + rt + fp
- }
-
- MuxPacketHeader(pBS, DSMP_SYNCPOINTS, len);
-
- pos = isps.GetHeadPosition();
- while (pos) {
- IndexedSyncPoint& isp = isps.GetNext(pos);
-
- int irt = GetByteLength(myabs(isp.rt));
- int ifp = GetByteLength(isp.fp);
-
- pBS->BitWrite(isp.rt < 0, 1);
- pBS->BitWrite(irt, 3);
- pBS->BitWrite(ifp, 3);
- pBS->BitWrite(0, 1); // reserved
- pBS->BitWrite(myabs(isp.rt), irt<<3);
- pBS->BitWrite(isp.fp, ifp<<3);
- }
+ // syncpoints
+
+ int len = 0;
+ CAtlList<IndexedSyncPoint> isps;
+ REFERENCE_TIME rtPrev = 0, rt;
+ UINT64 fpPrev = 0, fp;
+
+ POSITION pos = m_isps.GetHeadPosition();
+ while (pos) {
+ IndexedSyncPoint& isp = m_isps.GetNext(pos);
+ TRACE(_T("sp[%d]: %I64d %I64x\n"), isp.id, isp.rt, isp.fp);
+
+ rt = isp.rt - rtPrev;
+ rtPrev = isp.rt;
+ fp = isp.fp - fpPrev;
+ fpPrev = isp.fp;
+
+ IndexedSyncPoint isp2;
+ isp2.fp = fp;
+ isp2.rt = rt;
+ isps.AddTail(isp2);
+
+ len += 1 + GetByteLength(myabs(rt)) + GetByteLength(fp); // flags + rt + fp
+ }
+
+ MuxPacketHeader(pBS, DSMP_SYNCPOINTS, len);
+
+ pos = isps.GetHeadPosition();
+ while (pos) {
+ IndexedSyncPoint& isp = isps.GetNext(pos);
+
+ int irt = GetByteLength(myabs(isp.rt));
+ int ifp = GetByteLength(isp.fp);
+
+ pBS->BitWrite(isp.rt < 0, 1);
+ pBS->BitWrite(irt, 3);
+ pBS->BitWrite(ifp, 3);
+ pBS->BitWrite(0, 1); // reserved
+ pBS->BitWrite(myabs(isp.rt), irt << 3);
+ pBS->BitWrite(isp.fp, ifp << 3);
+ }
}
void CDSMMuxerFilter::IndexSyncPoint(const MuxerPacket* p, __int64 fp)
{
- // Yes, this is as complicated as it looks.
- // Rule #1: don't write this packet if you can't do it reliably.
- // (think about overlapped subtitles, line1: 0->10, line2: 1->9)
-
- // FIXME: the very last syncpoints won't get moved to m_isps because there are no more syncpoints to trigger it!
-
- if (fp < 0 || !p || !p->IsTimeValid() || !p->IsSyncPoint()) {
- return;
- }
-
- ASSERT(p->rtStart >= m_rtPrevSyncPoint);
- m_rtPrevSyncPoint = p->rtStart;
-
- SyncPoint sp;
- sp.id = p->pPin->GetID();
- sp.rtStart = p->rtStart;
- sp.rtStop = p->pPin->IsSubtitleStream() ? p->rtStop : _I64_MAX;
- sp.fp = fp;
-
- {
- SyncPoint& head = !m_sps.IsEmpty() ? m_sps.GetHead() : sp;
- SyncPoint& tail = !m_sps.IsEmpty() ? m_sps.GetTail() : sp;
- REFERENCE_TIME rtfp = !m_isps.IsEmpty() ? m_isps.GetTail().rtfp : _I64_MIN;
-
- if (head.rtStart > rtfp + 1000000) { // 100ms limit, just in case every stream had only keyframes, then sycnpoints would be too frequent
- IndexedSyncPoint isp;
- isp.id = head.id;
- isp.rt = tail.rtStart;
- isp.rtfp = head.rtStart;
- isp.fp = head.fp;
- m_isps.AddTail(isp);
- }
- }
-
- POSITION pos = m_sps.GetHeadPosition();
- while (pos) {
- POSITION cur = pos;
- SyncPoint& sp2 = m_sps.GetNext(pos);
- if (sp2.id == sp.id && sp2.rtStop <= sp.rtStop || sp2.rtStop <= sp.rtStart) {
- m_sps.RemoveAt(cur);
- }
- }
-
- m_sps.AddTail(sp);
+ // Yes, this is as complicated as it looks.
+ // Rule #1: don't write this packet if you can't do it reliably.
+ // (think about overlapped subtitles, line1: 0->10, line2: 1->9)
+
+ // FIXME: the very last syncpoints won't get moved to m_isps because there are no more syncpoints to trigger it!
+
+ if (fp < 0 || !p || !p->IsTimeValid() || !p->IsSyncPoint()) {
+ return;
+ }
+
+ ASSERT(p->rtStart >= m_rtPrevSyncPoint);
+ m_rtPrevSyncPoint = p->rtStart;
+
+ SyncPoint sp;
+ sp.id = p->pPin->GetID();
+ sp.rtStart = p->rtStart;
+ sp.rtStop = p->pPin->IsSubtitleStream() ? p->rtStop : _I64_MAX;
+ sp.fp = fp;
+
+ {
+ SyncPoint& head = !m_sps.IsEmpty() ? m_sps.GetHead() : sp;
+ SyncPoint& tail = !m_sps.IsEmpty() ? m_sps.GetTail() : sp;
+ REFERENCE_TIME rtfp = !m_isps.IsEmpty() ? m_isps.GetTail().rtfp : _I64_MIN;
+
+ if (head.rtStart > rtfp + 1000000) { // 100ms limit, just in case every stream had only keyframes, then sycnpoints would be too frequent
+ IndexedSyncPoint isp;
+ isp.id = head.id;
+ isp.rt = tail.rtStart;
+ isp.rtfp = head.rtStart;
+ isp.fp = head.fp;
+ m_isps.AddTail(isp);
+ }
+ }
+
+ POSITION pos = m_sps.GetHeadPosition();
+ while (pos) {
+ POSITION cur = pos;
+ SyncPoint& sp2 = m_sps.GetNext(pos);
+ if (sp2.id == sp.id && sp2.rtStop <= sp.rtStop || sp2.rtStop <= sp.rtStart) {
+ m_sps.RemoveAt(cur);
+ }
+ }
+
+ m_sps.AddTail(sp);
} \ No newline at end of file
diff --git a/src/filters/muxer/DSMMuxer/DSMMuxer.h b/src/filters/muxer/DSMMuxer/DSMMuxer.h
index a1dec87f1..8b5f00af6 100644
--- a/src/filters/muxer/DSMMuxer/DSMMuxer.h
+++ b/src/filters/muxer/DSMMuxer/DSMMuxer.h
@@ -29,40 +29,40 @@
#define DSMMuxerName L"MPC DSM Muxer"
class __declspec(uuid("C6590B76-587E-4082-9125-680D0693A97B"))
- CDSMMuxerFilter : public CBaseMuxerFilter
+ CDSMMuxerFilter : public CBaseMuxerFilter
{
- bool m_fAutoChap, m_fAutoRes;
+ bool m_fAutoChap, m_fAutoRes;
- struct SyncPoint {
- BYTE id;
- REFERENCE_TIME rtStart, rtStop;
- __int64 fp;
- };
- struct IndexedSyncPoint {
- BYTE id;
- REFERENCE_TIME rt, rtfp;
- __int64 fp;
- };
- CAtlList<SyncPoint> m_sps;
- CAtlList<IndexedSyncPoint> m_isps;
- REFERENCE_TIME m_rtPrevSyncPoint;
- void IndexSyncPoint(const MuxerPacket* p, __int64 fp);
+ struct SyncPoint {
+ BYTE id;
+ REFERENCE_TIME rtStart, rtStop;
+ __int64 fp;
+ };
+ struct IndexedSyncPoint {
+ BYTE id;
+ REFERENCE_TIME rt, rtfp;
+ __int64 fp;
+ };
+ CAtlList<SyncPoint> m_sps;
+ CAtlList<IndexedSyncPoint> m_isps;
+ REFERENCE_TIME m_rtPrevSyncPoint;
+ void IndexSyncPoint(const MuxerPacket* p, __int64 fp);
- void MuxPacketHeader(IBitStream* pBS, dsmp_t type, UINT64 len);
- void MuxFileInfo(IBitStream* pBS);
- void MuxStreamInfo(IBitStream* pBS, CBaseMuxerInputPin* pPin);
+ void MuxPacketHeader(IBitStream* pBS, dsmp_t type, UINT64 len);
+ void MuxFileInfo(IBitStream* pBS);
+ void MuxStreamInfo(IBitStream* pBS, CBaseMuxerInputPin* pPin);
protected:
- void MuxInit();
+ void MuxInit();
- void MuxHeader(IBitStream* pBS);
- void MuxPacket(IBitStream* pBS, const MuxerPacket* pPacket);
- void MuxFooter(IBitStream* pBS);
+ void MuxHeader(IBitStream* pBS);
+ void MuxPacket(IBitStream* pBS, const MuxerPacket* pPacket);
+ void MuxFooter(IBitStream* pBS);
public:
- CDSMMuxerFilter(LPUNKNOWN pUnk, HRESULT* phr, bool fAutoChap = true, bool fAutoRes = true);
- virtual ~CDSMMuxerFilter();
+ CDSMMuxerFilter(LPUNKNOWN pUnk, HRESULT* phr, bool fAutoChap = true, bool fAutoRes = true);
+ virtual ~CDSMMuxerFilter();
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
};
diff --git a/src/filters/muxer/MatroskaMuxer/MatroskaFile.cpp b/src/filters/muxer/MatroskaMuxer/MatroskaFile.cpp
index 3863bd825..5d6421eca 100644
--- a/src/filters/muxer/MatroskaMuxer/MatroskaFile.cpp
+++ b/src/filters/muxer/MatroskaMuxer/MatroskaFile.cpp
@@ -29,9 +29,9 @@ using namespace MatroskaWriter;
static void bswap(BYTE* s, int len)
{
- for (BYTE* d = s + len-1; s < d; s++, d--) {
- *s ^= *d, *d ^= *s, *s ^= *d;
- }
+ for (BYTE* d = s + len - 1; s < d; s++, d--) {
+ *s ^= *d, *d ^= *s, *s ^= *d;
+ }
}
//
@@ -42,889 +42,889 @@ CID::CID(DWORD id) : m_id(id)
MatroskaWriter::QWORD CID::Size(bool fWithHeader)
{
- return CUInt(0, m_id).Size(false);
+ return CUInt(0, m_id).Size(false);
}
HRESULT CID::Write(IStream* pStream)
{
- MatroskaWriter::QWORD len = CID::Size();
- DWORD id = m_id;
- bswap((BYTE*)&id, (int)len);
- *(BYTE*)&id = ((*(BYTE*)&id)&(1<<(8-len))-1)|(1<<(8-len));
- return pStream->Write(&id, (ULONG)len, NULL);
+ MatroskaWriter::QWORD len = CID::Size();
+ DWORD id = m_id;
+ bswap((BYTE*)&id, (int)len);
+ *(BYTE*)&id = ((*(BYTE*)&id) & (1 << (8 - len)) - 1) | (1 << (8 - len));
+ return pStream->Write(&id, (ULONG)len, NULL);
}
MatroskaWriter::QWORD CID::HeaderSize(MatroskaWriter::QWORD len)
{
- return CID::Size() + CLength(len).Size();
+ return CID::Size() + CLength(len).Size();
}
HRESULT CID::HeaderWrite(IStream* pStream)
{
- CID::Write(pStream);
- CLength(Size(false)).Write(pStream);
- return S_OK;
+ CID::Write(pStream);
+ CLength(Size(false)).Write(pStream);
+ return S_OK;
}
MatroskaWriter::QWORD CBinary::Size(bool fWithHeader)
{
- if (GetCount() == 0) {
- return 0;
- }
+ if (GetCount() == 0) {
+ return 0;
+ }
- MatroskaWriter::QWORD len = 0;
- len += GetCount();
- if (fWithHeader) {
- len += HeaderSize(len);
- }
- return len;
+ MatroskaWriter::QWORD len = 0;
+ len += GetCount();
+ if (fWithHeader) {
+ len += HeaderSize(len);
+ }
+ return len;
}
HRESULT CBinary::Write(IStream* pStream)
{
- if (GetCount() == 0) {
- return S_OK;
- }
+ if (GetCount() == 0) {
+ return S_OK;
+ }
- HeaderWrite(pStream);
- return pStream->Write(GetData(), GetCount(), NULL);
+ HeaderWrite(pStream);
+ return pStream->Write(GetData(), GetCount(), NULL);
}
MatroskaWriter::QWORD CANSI::Size(bool fWithHeader)
{
- if (GetLength() == 0) {
- return 0;
- }
+ if (GetLength() == 0) {
+ return 0;
+ }
- MatroskaWriter::QWORD len = 0;
- len += GetLength();
- if (fWithHeader) {
- len += HeaderSize(len);
- }
- return len;
+ MatroskaWriter::QWORD len = 0;
+ len += GetLength();
+ if (fWithHeader) {
+ len += HeaderSize(len);
+ }
+ return len;
}
HRESULT CANSI::Write(IStream* pStream)
{
- if (GetLength() == 0) {
- return S_OK;
- }
+ if (GetLength() == 0) {
+ return S_OK;
+ }
- HeaderWrite(pStream);
- return pStream->Write((LPCSTR)*this, GetLength(), NULL);
+ HeaderWrite(pStream);
+ return pStream->Write((LPCSTR) * this, GetLength(), NULL);
}
MatroskaWriter::QWORD CUTF8::Size(bool fWithHeader)
{
- if (GetLength() == 0) {
- return 0;
- }
+ if (GetLength() == 0) {
+ return 0;
+ }
- MatroskaWriter::QWORD len = 0;
- len += UTF16To8(*this).GetLength();
- if (fWithHeader) {
- len += HeaderSize(len);
- }
- return len;
+ MatroskaWriter::QWORD len = 0;
+ len += UTF16To8(*this).GetLength();
+ if (fWithHeader) {
+ len += HeaderSize(len);
+ }
+ return len;
}
HRESULT CUTF8::Write(IStream* pStream)
{
- if (GetLength() == 0) {
- return S_OK;
- }
+ if (GetLength() == 0) {
+ return S_OK;
+ }
- HeaderWrite(pStream);
- CStringA str = UTF16To8(*this);
- return pStream->Write((BYTE*)(LPCSTR)str, str.GetLength(), NULL);
+ HeaderWrite(pStream);
+ CStringA str = UTF16To8(*this);
+ return pStream->Write((BYTE*)(LPCSTR)str, str.GetLength(), NULL);
}
template<class T, class BASE>
MatroskaWriter::QWORD CSimpleVar<T, BASE>::Size(bool fWithHeader)
{
- if (!m_fSet) {
- return 0;
- }
+ if (!m_fSet) {
+ return 0;
+ }
- MatroskaWriter::QWORD len = 0;
- len += sizeof(T);
- if (fWithHeader) {
- len += HeaderSize(len);
- }
- return len;
+ MatroskaWriter::QWORD len = 0;
+ len += sizeof(T);
+ if (fWithHeader) {
+ len += HeaderSize(len);
+ }
+ return len;
}
template<class T, class BASE>
HRESULT CSimpleVar<T, BASE>::Write(IStream* pStream)
{
- if (!m_fSet) {
- return S_OK;
- }
+ if (!m_fSet) {
+ return S_OK;
+ }
- HeaderWrite(pStream);
- T val = m_val;
- bswap((BYTE*)&val, sizeof(T));
- return pStream->Write(&val, sizeof(T), NULL);
+ HeaderWrite(pStream);
+ T val = m_val;
+ bswap((BYTE*)&val, sizeof(T));
+ return pStream->Write(&val, sizeof(T), NULL);
}
MatroskaWriter::QWORD CUInt::Size(bool fWithHeader)
{
- if (!m_fSet) {
- return 0;
- }
+ if (!m_fSet) {
+ return 0;
+ }
- MatroskaWriter::QWORD len = 0;
+ MatroskaWriter::QWORD len = 0;
- if (m_val == 0) {
- len++;
- } else {
- for (int i = 8; i > 0; i--) {
- if (((0xffi64<<((i-1)*8))&m_val)) {
- len += i;
- break;
- }
- }
- }
- if (fWithHeader) {
- len += HeaderSize(len);
- }
- return len;
+ if (m_val == 0) {
+ len++;
+ } else {
+ for (int i = 8; i > 0; i--) {
+ if (((0xffi64 << ((i - 1) * 8))&m_val)) {
+ len += i;
+ break;
+ }
+ }
+ }
+ if (fWithHeader) {
+ len += HeaderSize(len);
+ }
+ return len;
}
HRESULT CUInt::Write(IStream* pStream)
{
- if (!m_fSet) {
- return S_OK;
- }
+ if (!m_fSet) {
+ return S_OK;
+ }
- CID::Write(pStream);
- CLength l(Size(false));
- l.Write(pStream);
- UINT64 val = m_val;
- bswap((BYTE*)&val, (int)l);
- return pStream->Write(&val, (ULONG)l, NULL);
+ CID::Write(pStream);
+ CLength l(Size(false));
+ l.Write(pStream);
+ UINT64 val = m_val;
+ bswap((BYTE*)&val, (int)l);
+ return pStream->Write(&val, (ULONG)l, NULL);
}
MatroskaWriter::QWORD CInt::Size(bool fWithHeader)
{
- if (!m_fSet) {
- return 0;
- }
-
- MatroskaWriter::QWORD len = 0;
-
- if (m_val == 0) {
- len++;
- } else {
- UINT64 val = m_val >= 0 ? m_val : -m_val;
- for (int i = 8; i > 0; i--) {
- if (((0xffi64<<((i-1)*8))&val)) {
- len += i;
- if (m_val < 0 && !(m_val&(0x80<<(i-1)))) {
- len++;
- }
- break;
- }
- }
- }
- if (fWithHeader) {
- len += HeaderSize(len);
- }
- return len;
+ if (!m_fSet) {
+ return 0;
+ }
+
+ MatroskaWriter::QWORD len = 0;
+
+ if (m_val == 0) {
+ len++;
+ } else {
+ UINT64 val = m_val >= 0 ? m_val : -m_val;
+ for (int i = 8; i > 0; i--) {
+ if (((0xffi64 << ((i - 1) * 8))&val)) {
+ len += i;
+ if (m_val < 0 && !(m_val & (0x80 << (i - 1)))) {
+ len++;
+ }
+ break;
+ }
+ }
+ }
+ if (fWithHeader) {
+ len += HeaderSize(len);
+ }
+ return len;
}
HRESULT CInt::Write(IStream* pStream)
{
- if (!m_fSet) {
- return S_OK;
- }
+ if (!m_fSet) {
+ return S_OK;
+ }
- CID::Write(pStream);
- CLength l(Size(false));
- l.Write(pStream);
- UINT64 val = m_val;
- bswap((BYTE*)&val, (int)l);
- return pStream->Write(&val, (ULONG)l, NULL);
+ CID::Write(pStream);
+ CLength l(Size(false));
+ l.Write(pStream);
+ UINT64 val = m_val;
+ bswap((BYTE*)&val, (int)l);
+ return pStream->Write(&val, (ULONG)l, NULL);
}
MatroskaWriter::QWORD CLength::Size(bool fWithHeader)
{
- if (m_len == 0x00FFFFFFFFFFFFFFi64) {
- return 8;
- }
+ if (m_len == 0x00FFFFFFFFFFFFFFi64) {
+ return 8;
+ }
- MatroskaWriter::QWORD len = 0;
- for (int i = 1; i <= 8; i++) {
- if (!(m_len&(~((1i64<<(7*i))-1))) && (m_len&((1i64<<(7*i))-1)) != ((1i64<<(7*i))-1)) {
- len += i;
- break;
- }
- }
- return len;
+ MatroskaWriter::QWORD len = 0;
+ for (int i = 1; i <= 8; i++) {
+ if (!(m_len & (~((1i64 << (7 * i)) - 1))) && (m_len & ((1i64 << (7 * i)) - 1)) != ((1i64 << (7 * i)) - 1)) {
+ len += i;
+ break;
+ }
+ }
+ return len;
}
HRESULT CLength::Write(IStream* pStream)
{
- MatroskaWriter::QWORD len = Size(false);
- UINT64 val = m_len;
- bswap((BYTE*)&val, (int)len);
- *(BYTE*)&val = ((*(BYTE*)&val)&(1<<(8-len))-1)|(1<<(8-len));
- return pStream->Write(&val, (ULONG)len, NULL);
+ MatroskaWriter::QWORD len = Size(false);
+ UINT64 val = m_len;
+ bswap((BYTE*)&val, (int)len);
+ *(BYTE*)&val = ((*(BYTE*)&val) & (1 << (8 - len)) - 1) | (1 << (8 - len));
+ return pStream->Write(&val, (ULONG)len, NULL);
}
//
EBML::EBML(DWORD id)
- : CID(id)
- , EBMLVersion(0x4286)
- , EBMLReadVersion(0x42F7)
- , EBMLMaxIDLength(0x42F2)
- , EBMLMaxSizeLength(0x42F3)
- , DocType(0x4282)
- , DocTypeVersion(0x4287)
- , DocTypeReadVersion(0x4285)
+ : CID(id)
+ , EBMLVersion(0x4286)
+ , EBMLReadVersion(0x42F7)
+ , EBMLMaxIDLength(0x42F2)
+ , EBMLMaxSizeLength(0x42F3)
+ , DocType(0x4282)
+ , DocTypeVersion(0x4287)
+ , DocTypeReadVersion(0x4285)
{
}
MatroskaWriter::QWORD EBML::Size(bool fWithHeader)
{
- MatroskaWriter::QWORD len = 0;
- len += EBMLVersion.Size();
- len += EBMLReadVersion.Size();
- len += EBMLMaxIDLength.Size();
- len += EBMLMaxSizeLength.Size();
- len += DocType.Size();
- len += DocTypeVersion.Size();
- len += DocTypeReadVersion.Size();
- if (fWithHeader) {
- len += HeaderSize(len);
- }
- return len;
+ MatroskaWriter::QWORD len = 0;
+ len += EBMLVersion.Size();
+ len += EBMLReadVersion.Size();
+ len += EBMLMaxIDLength.Size();
+ len += EBMLMaxSizeLength.Size();
+ len += DocType.Size();
+ len += DocTypeVersion.Size();
+ len += DocTypeReadVersion.Size();
+ if (fWithHeader) {
+ len += HeaderSize(len);
+ }
+ return len;
}
HRESULT EBML::Write(IStream* pStream)
{
- HeaderWrite(pStream);
- EBMLVersion.Write(pStream);
- EBMLReadVersion.Write(pStream);
- EBMLMaxIDLength.Write(pStream);
- EBMLMaxSizeLength.Write(pStream);
- DocType.Write(pStream);
- DocTypeVersion.Write(pStream);
- DocTypeReadVersion.Write(pStream);
- return S_OK;
+ HeaderWrite(pStream);
+ EBMLVersion.Write(pStream);
+ EBMLReadVersion.Write(pStream);
+ EBMLMaxIDLength.Write(pStream);
+ EBMLMaxSizeLength.Write(pStream);
+ DocType.Write(pStream);
+ DocTypeVersion.Write(pStream);
+ DocTypeReadVersion.Write(pStream);
+ return S_OK;
}
Info::Info(DWORD id)
- : CID(id)
- , SegmentUID(0x73A4)
- , SegmentFilename(0x7384)
- , PrevUID(0x3CB923)
- , PrevFilename(0x3C83AB)
- , NextUID(0x3EB923)
- , NextFilename(0x3E83BB)
- , TimeCodeScale(0x2AD7B1, 1000000ui64)
- , Duration(0x4489)
- , DateUTC(0x4461)
- , Title(0x7BA9)
- , MuxingApp(0x4D80)
- , WritingApp(0x5741)
+ : CID(id)
+ , SegmentUID(0x73A4)
+ , SegmentFilename(0x7384)
+ , PrevUID(0x3CB923)
+ , PrevFilename(0x3C83AB)
+ , NextUID(0x3EB923)
+ , NextFilename(0x3E83BB)
+ , TimeCodeScale(0x2AD7B1, 1000000ui64)
+ , Duration(0x4489)
+ , DateUTC(0x4461)
+ , Title(0x7BA9)
+ , MuxingApp(0x4D80)
+ , WritingApp(0x5741)
{
}
MatroskaWriter::QWORD Info::Size(bool fWithHeader)
{
- MatroskaWriter::QWORD len = 0;
- len += SegmentUID.Size();
- len += PrevUID.Size();
- len += NextUID.Size();
- len += SegmentFilename.Size();
- len += PrevFilename.Size();
- len += NextFilename.Size();
- len += TimeCodeScale.Size();
- len += Duration.Size();
- len += DateUTC.Size();
- len += Title.Size();
- len += MuxingApp.Size();
- len += WritingApp.Size();
- if (fWithHeader) {
- len += HeaderSize(len);
- }
- return len;
+ MatroskaWriter::QWORD len = 0;
+ len += SegmentUID.Size();
+ len += PrevUID.Size();
+ len += NextUID.Size();
+ len += SegmentFilename.Size();
+ len += PrevFilename.Size();
+ len += NextFilename.Size();
+ len += TimeCodeScale.Size();
+ len += Duration.Size();
+ len += DateUTC.Size();
+ len += Title.Size();
+ len += MuxingApp.Size();
+ len += WritingApp.Size();
+ if (fWithHeader) {
+ len += HeaderSize(len);
+ }
+ return len;
}
HRESULT Info::Write(IStream* pStream)
{
- HeaderWrite(pStream);
- SegmentUID.Write(pStream);
- PrevUID.Write(pStream);
- NextUID.Write(pStream);
- SegmentFilename.Write(pStream);
- PrevFilename.Write(pStream);
- NextFilename.Write(pStream);
- TimeCodeScale.Write(pStream);
- Duration.Write(pStream);
- DateUTC.Write(pStream);
- Title.Write(pStream);
- MuxingApp.Write(pStream);
- WritingApp.Write(pStream);
- return S_OK;
+ HeaderWrite(pStream);
+ SegmentUID.Write(pStream);
+ PrevUID.Write(pStream);
+ NextUID.Write(pStream);
+ SegmentFilename.Write(pStream);
+ PrevFilename.Write(pStream);
+ NextFilename.Write(pStream);
+ TimeCodeScale.Write(pStream);
+ Duration.Write(pStream);
+ DateUTC.Write(pStream);
+ Title.Write(pStream);
+ MuxingApp.Write(pStream);
+ WritingApp.Write(pStream);
+ return S_OK;
}
Segment::Segment(DWORD id)
- : CID(id)
+ : CID(id)
{
}
MatroskaWriter::QWORD Segment::Size(bool fWithHeader)
{
- return 0x00FFFFFFFFFFFFFFi64;
- /*
- MatroskaWriter::QWORD len = 0;
- if (fWithHeader) len += HeaderSize(len);
- return len;
- */
+ return 0x00FFFFFFFFFFFFFFi64;
+ /*
+ MatroskaWriter::QWORD len = 0;
+ if (fWithHeader) len += HeaderSize(len);
+ return len;
+ */
}
HRESULT Segment::Write(IStream* pStream)
{
- HeaderWrite(pStream);
- return S_OK;
+ HeaderWrite(pStream);
+ return S_OK;
}
Track::Track(DWORD id)
- : CID(id)
+ : CID(id)
{
}
MatroskaWriter::QWORD Track::Size(bool fWithHeader)
{
- MatroskaWriter::QWORD len = 0;
- len += TrackEntries.Size();
- if (fWithHeader) {
- len += HeaderSize(len);
- }
- return len;
+ MatroskaWriter::QWORD len = 0;
+ len += TrackEntries.Size();
+ if (fWithHeader) {
+ len += HeaderSize(len);
+ }
+ return len;
}
HRESULT Track::Write(IStream* pStream)
{
- HeaderWrite(pStream);
- TrackEntries.Write(pStream);
- return S_OK;
+ HeaderWrite(pStream);
+ TrackEntries.Write(pStream);
+ return S_OK;
}
TrackEntry::TrackEntry(DWORD id)
- : CID(id)
- , TrackNumber(0xD7)
- , TrackUID(0x73C5)
- , TrackType(0x83)
- , FlagEnabled(0xB9)
- , FlagDefault(0x88)
- , FlagLacing(0x9C)
- , MinCache(0x6DE7)
- , MaxCache(0x6DF8)
- , Name(0x536E)
- , Language(0x22B59C)
- , CodecID(0x86)
- , CodecPrivate(0x63A2)
- , CodecName(0x258688)
- , CodecSettings(0x3A9697)
- , CodecInfoURL(0x3B4040)
- , CodecDownloadURL(0x26B240)
- , CodecDecodeAll(0xAA)
- , TrackOverlay(0x6FAB)
- , DefaultDuration(0x23E383)
- , v(0xE0)
- , a(0xE1)
-{
- DescType = NoDesc;
+ : CID(id)
+ , TrackNumber(0xD7)
+ , TrackUID(0x73C5)
+ , TrackType(0x83)
+ , FlagEnabled(0xB9)
+ , FlagDefault(0x88)
+ , FlagLacing(0x9C)
+ , MinCache(0x6DE7)
+ , MaxCache(0x6DF8)
+ , Name(0x536E)
+ , Language(0x22B59C)
+ , CodecID(0x86)
+ , CodecPrivate(0x63A2)
+ , CodecName(0x258688)
+ , CodecSettings(0x3A9697)
+ , CodecInfoURL(0x3B4040)
+ , CodecDownloadURL(0x26B240)
+ , CodecDecodeAll(0xAA)
+ , TrackOverlay(0x6FAB)
+ , DefaultDuration(0x23E383)
+ , v(0xE0)
+ , a(0xE1)
+{
+ DescType = NoDesc;
}
MatroskaWriter::QWORD TrackEntry::Size(bool fWithHeader)
{
- MatroskaWriter::QWORD len = 0;
- len += TrackNumber.Size();
- len += TrackUID.Size();
- len += TrackType.Size();
- len += FlagEnabled.Size();
- len += FlagDefault.Size();
- len += FlagLacing.Size();
- len += MinCache.Size();
- len += MaxCache.Size();
- len += Name.Size();
- len += Language.Size();
- len += CodecID.Size();
- len += CodecPrivate.Size();
- len += CodecName.Size();
- len += CodecSettings.Size();
- len += CodecInfoURL.Size();
- len += CodecDownloadURL.Size();
- len += CodecDecodeAll.Size();
- len += TrackOverlay.Size();
- len += DefaultDuration.Size();
- if (DescType == TypeVideo) {
- len += v.Size();
- }
- if (DescType == TypeAudio) {
- len += a.Size();
- }
- if (fWithHeader) {
- len += HeaderSize(len);
- }
- return len;
+ MatroskaWriter::QWORD len = 0;
+ len += TrackNumber.Size();
+ len += TrackUID.Size();
+ len += TrackType.Size();
+ len += FlagEnabled.Size();
+ len += FlagDefault.Size();
+ len += FlagLacing.Size();
+ len += MinCache.Size();
+ len += MaxCache.Size();
+ len += Name.Size();
+ len += Language.Size();
+ len += CodecID.Size();
+ len += CodecPrivate.Size();
+ len += CodecName.Size();
+ len += CodecSettings.Size();
+ len += CodecInfoURL.Size();
+ len += CodecDownloadURL.Size();
+ len += CodecDecodeAll.Size();
+ len += TrackOverlay.Size();
+ len += DefaultDuration.Size();
+ if (DescType == TypeVideo) {
+ len += v.Size();
+ }
+ if (DescType == TypeAudio) {
+ len += a.Size();
+ }
+ if (fWithHeader) {
+ len += HeaderSize(len);
+ }
+ return len;
}
HRESULT TrackEntry::Write(IStream* pStream)
{
- HeaderWrite(pStream);
- TrackNumber.Write(pStream);
- TrackUID.Write(pStream);
- TrackType.Write(pStream);
- FlagEnabled.Write(pStream);
- FlagDefault.Write(pStream);
- FlagLacing.Write(pStream);
- MinCache.Write(pStream);
- MaxCache.Write(pStream);
- Name.Write(pStream);
- Language.Write(pStream);
- CodecID.Write(pStream);
- CodecPrivate.Write(pStream);
- CodecName.Write(pStream);
- CodecSettings.Write(pStream);
- CodecInfoURL.Write(pStream);
- CodecDownloadURL.Write(pStream);
- CodecDecodeAll.Write(pStream);
- TrackOverlay.Write(pStream);
- DefaultDuration.Write(pStream);
- if (DescType == TypeVideo) {
- v.Write(pStream);
- }
- if (DescType == TypeAudio) {
- a.Write(pStream);
- }
- return S_OK;
+ HeaderWrite(pStream);
+ TrackNumber.Write(pStream);
+ TrackUID.Write(pStream);
+ TrackType.Write(pStream);
+ FlagEnabled.Write(pStream);
+ FlagDefault.Write(pStream);
+ FlagLacing.Write(pStream);
+ MinCache.Write(pStream);
+ MaxCache.Write(pStream);
+ Name.Write(pStream);
+ Language.Write(pStream);
+ CodecID.Write(pStream);
+ CodecPrivate.Write(pStream);
+ CodecName.Write(pStream);
+ CodecSettings.Write(pStream);
+ CodecInfoURL.Write(pStream);
+ CodecDownloadURL.Write(pStream);
+ CodecDecodeAll.Write(pStream);
+ TrackOverlay.Write(pStream);
+ DefaultDuration.Write(pStream);
+ if (DescType == TypeVideo) {
+ v.Write(pStream);
+ }
+ if (DescType == TypeAudio) {
+ a.Write(pStream);
+ }
+ return S_OK;
}
Video::Video(DWORD id)
- : CID(id)
- , FlagInterlaced(0x9A)
- , StereoMode(0x53B8)
- , PixelWidth(0xB0)
- , PixelHeight(0xBA)
- , DisplayWidth(0x54B0)
- , DisplayHeight(0x54BA)
- , DisplayUnit(0x54B2)
- , AspectRatioType(0x54B3)
- , ColourSpace(0x2EB524)
- , GammaValue(0x2FB523)
- , FramePerSec(0x2383E3)
+ : CID(id)
+ , FlagInterlaced(0x9A)
+ , StereoMode(0x53B8)
+ , PixelWidth(0xB0)
+ , PixelHeight(0xBA)
+ , DisplayWidth(0x54B0)
+ , DisplayHeight(0x54BA)
+ , DisplayUnit(0x54B2)
+ , AspectRatioType(0x54B3)
+ , ColourSpace(0x2EB524)
+ , GammaValue(0x2FB523)
+ , FramePerSec(0x2383E3)
{
}
MatroskaWriter::QWORD Video::Size(bool fWithHeader)
{
- MatroskaWriter::QWORD len = 0;
- len += FlagInterlaced.Size();
- len += StereoMode.Size();
- len += PixelWidth.Size();
- len += PixelHeight.Size();
- len += DisplayWidth.Size();
- len += DisplayHeight.Size();
- len += DisplayUnit.Size();
- len += AspectRatioType.Size();
- len += ColourSpace.Size();
- len += GammaValue.Size();
- len += FramePerSec.Size();
- if (fWithHeader) {
- len += HeaderSize(len);
- }
- return len;
+ MatroskaWriter::QWORD len = 0;
+ len += FlagInterlaced.Size();
+ len += StereoMode.Size();
+ len += PixelWidth.Size();
+ len += PixelHeight.Size();
+ len += DisplayWidth.Size();
+ len += DisplayHeight.Size();
+ len += DisplayUnit.Size();
+ len += AspectRatioType.Size();
+ len += ColourSpace.Size();
+ len += GammaValue.Size();
+ len += FramePerSec.Size();
+ if (fWithHeader) {
+ len += HeaderSize(len);
+ }
+ return len;
}
HRESULT Video::Write(IStream* pStream)
{
- HeaderWrite(pStream);
- FlagInterlaced.Write(pStream);
- StereoMode.Write(pStream);
- PixelWidth.Write(pStream);
- PixelHeight.Write(pStream);
- DisplayWidth.Write(pStream);
- DisplayHeight.Write(pStream);
- DisplayUnit.Write(pStream);
- AspectRatioType.Write(pStream);
- ColourSpace.Write(pStream);
- GammaValue.Write(pStream);
- FramePerSec.Write(pStream);
- return S_OK;
+ HeaderWrite(pStream);
+ FlagInterlaced.Write(pStream);
+ StereoMode.Write(pStream);
+ PixelWidth.Write(pStream);
+ PixelHeight.Write(pStream);
+ DisplayWidth.Write(pStream);
+ DisplayHeight.Write(pStream);
+ DisplayUnit.Write(pStream);
+ AspectRatioType.Write(pStream);
+ ColourSpace.Write(pStream);
+ GammaValue.Write(pStream);
+ FramePerSec.Write(pStream);
+ return S_OK;
}
Audio::Audio(DWORD id)
- : CID(id)
- , SamplingFrequency(0xB5)
- , OutputSamplingFrequency(0x78B5)
- , Channels(0x9F)
- , ChannelPositions(0x7D7B)
- , BitDepth(0x6264)
+ : CID(id)
+ , SamplingFrequency(0xB5)
+ , OutputSamplingFrequency(0x78B5)
+ , Channels(0x9F)
+ , ChannelPositions(0x7D7B)
+ , BitDepth(0x6264)
{
}
MatroskaWriter::QWORD Audio::Size(bool fWithHeader)
{
- MatroskaWriter::QWORD len = 0;
- len += SamplingFrequency.Size();
- len += OutputSamplingFrequency.Size();
- len += Channels.Size();
- len += ChannelPositions.Size();
- len += BitDepth.Size();
- if (fWithHeader) {
- len += HeaderSize(len);
- }
- return len;
+ MatroskaWriter::QWORD len = 0;
+ len += SamplingFrequency.Size();
+ len += OutputSamplingFrequency.Size();
+ len += Channels.Size();
+ len += ChannelPositions.Size();
+ len += BitDepth.Size();
+ if (fWithHeader) {
+ len += HeaderSize(len);
+ }
+ return len;
}
HRESULT Audio::Write(IStream* pStream)
{
- HeaderWrite(pStream);
- SamplingFrequency.Write(pStream);
- OutputSamplingFrequency.Write(pStream);
- Channels.Write(pStream);
- ChannelPositions.Write(pStream);
- BitDepth.Write(pStream);
- return S_OK;
+ HeaderWrite(pStream);
+ SamplingFrequency.Write(pStream);
+ OutputSamplingFrequency.Write(pStream);
+ Channels.Write(pStream);
+ ChannelPositions.Write(pStream);
+ BitDepth.Write(pStream);
+ return S_OK;
}
Cluster::Cluster(DWORD id)
- : CID(id)
- , TimeCode(0xE7)
- , Position(0xA7)
- , PrevSize(0xAB)
+ : CID(id)
+ , TimeCode(0xE7)
+ , Position(0xA7)
+ , PrevSize(0xAB)
{
}
MatroskaWriter::QWORD Cluster::Size(bool fWithHeader)
{
- MatroskaWriter::QWORD len = 0;
- len += TimeCode.Size();
- len += Position.Size();
- len += PrevSize.Size();
- len += BlockGroups.Size();
- if (fWithHeader) {
- len += HeaderSize(len);
- }
- return len;
+ MatroskaWriter::QWORD len = 0;
+ len += TimeCode.Size();
+ len += Position.Size();
+ len += PrevSize.Size();
+ len += BlockGroups.Size();
+ if (fWithHeader) {
+ len += HeaderSize(len);
+ }
+ return len;
}
HRESULT Cluster::Write(IStream* pStream)
{
- HeaderWrite(pStream);
- TimeCode.Write(pStream);
- Position.Write(pStream);
- PrevSize.Write(pStream);
- BlockGroups.Write(pStream);
- return S_OK;
+ HeaderWrite(pStream);
+ TimeCode.Write(pStream);
+ Position.Write(pStream);
+ PrevSize.Write(pStream);
+ BlockGroups.Write(pStream);
+ return S_OK;
}
BlockGroup::BlockGroup(DWORD id)
- : CID(id)
- , BlockDuration(0x9B)
- , ReferencePriority(0xFA)
- , ReferenceBlock(0xFB)
- , ReferenceVirtual(0xFD)
- , CodecState(0xA4)
+ : CID(id)
+ , BlockDuration(0x9B)
+ , ReferencePriority(0xFA)
+ , ReferenceBlock(0xFB)
+ , ReferenceVirtual(0xFD)
+ , CodecState(0xA4)
{
}
MatroskaWriter::QWORD BlockGroup::Size(bool fWithHeader)
{
- MatroskaWriter::QWORD len = 0;
- len += BlockDuration.Size();
- len += ReferencePriority.Size();
- len += ReferenceBlock.Size();
- len += ReferenceVirtual.Size();
- len += CodecState.Size();
- len += Block.Size();
- if (fWithHeader) {
- len += HeaderSize(len);
- }
- return len;
+ MatroskaWriter::QWORD len = 0;
+ len += BlockDuration.Size();
+ len += ReferencePriority.Size();
+ len += ReferenceBlock.Size();
+ len += ReferenceVirtual.Size();
+ len += CodecState.Size();
+ len += Block.Size();
+ if (fWithHeader) {
+ len += HeaderSize(len);
+ }
+ return len;
}
HRESULT BlockGroup::Write(IStream* pStream)
{
- HeaderWrite(pStream);
- BlockDuration.Write(pStream);
- ReferencePriority.Write(pStream);
- ReferenceBlock.Write(pStream);
- ReferenceVirtual.Write(pStream);
- CodecState.Write(pStream);
- Block.Write(pStream);
- return S_OK;
+ HeaderWrite(pStream);
+ BlockDuration.Write(pStream);
+ ReferencePriority.Write(pStream);
+ ReferenceBlock.Write(pStream);
+ ReferenceVirtual.Write(pStream);
+ CodecState.Write(pStream);
+ Block.Write(pStream);
+ return S_OK;
}
CBlock::CBlock(DWORD id)
- : CID(id)
- , TimeCode(0)
+ : CID(id)
+ , TimeCode(0)
{
}
MatroskaWriter::QWORD CBlock::Size(bool fWithHeader)
{
- MatroskaWriter::QWORD len = 0;
- len += TrackNumber.Size() + 2 + 1; // TrackNumber + TimeCode + Lacing
- if (BlockData.GetCount() > 1) {
- len += 1; // nBlockData
- POSITION pos = BlockData.GetHeadPosition();
- while (pos) {
- CBinary* b = BlockData.GetNext(pos);
- if (pos) {
- len += b->GetCount()/255 + 1;
- }
- }
- }
- POSITION pos = BlockData.GetHeadPosition();
- while (pos) {
- CBinary* b = BlockData.GetNext(pos);
- len += b->GetCount();
- }
- if (fWithHeader) {
- len += HeaderSize(len);
- }
- return len;
+ MatroskaWriter::QWORD len = 0;
+ len += TrackNumber.Size() + 2 + 1; // TrackNumber + TimeCode + Lacing
+ if (BlockData.GetCount() > 1) {
+ len += 1; // nBlockData
+ POSITION pos = BlockData.GetHeadPosition();
+ while (pos) {
+ CBinary* b = BlockData.GetNext(pos);
+ if (pos) {
+ len += b->GetCount() / 255 + 1;
+ }
+ }
+ }
+ POSITION pos = BlockData.GetHeadPosition();
+ while (pos) {
+ CBinary* b = BlockData.GetNext(pos);
+ len += b->GetCount();
+ }
+ if (fWithHeader) {
+ len += HeaderSize(len);
+ }
+ return len;
}
HRESULT CBlock::Write(IStream* pStream)
{
- HeaderWrite(pStream);
- TrackNumber.Write(pStream);
- short t = (short)TimeCode;
- bswap((BYTE*)&t, 2);
- pStream->Write(&t, 2, NULL);
- BYTE Lacing = 0;
- BYTE n = BlockData.GetCount();
- if (n > 1) {
- Lacing |= 2;
- }
- pStream->Write(&Lacing, 1, NULL);
- if (n > 1) {
- pStream->Write(&n, 1, NULL);
- POSITION pos = BlockData.GetHeadPosition();
- while (pos) {
- CBinary* b = BlockData.GetNext(pos);
- if (pos) {
- INT_PTR len = b->GetCount();
- while (len >= 0) {
- n = (BYTE)min(len, 255);
- pStream->Write(&n, 1, NULL);
- len -= 255;
- }
- }
- }
- }
- POSITION pos = BlockData.GetHeadPosition();
- while (pos) {
- CBinary* b = BlockData.GetNext(pos);
- pStream->Write(b->GetData(), b->GetCount(), NULL);
- }
- return S_OK;
+ HeaderWrite(pStream);
+ TrackNumber.Write(pStream);
+ short t = (short)TimeCode;
+ bswap((BYTE*)&t, 2);
+ pStream->Write(&t, 2, NULL);
+ BYTE Lacing = 0;
+ BYTE n = BlockData.GetCount();
+ if (n > 1) {
+ Lacing |= 2;
+ }
+ pStream->Write(&Lacing, 1, NULL);
+ if (n > 1) {
+ pStream->Write(&n, 1, NULL);
+ POSITION pos = BlockData.GetHeadPosition();
+ while (pos) {
+ CBinary* b = BlockData.GetNext(pos);
+ if (pos) {
+ INT_PTR len = b->GetCount();
+ while (len >= 0) {
+ n = (BYTE)min(len, 255);
+ pStream->Write(&n, 1, NULL);
+ len -= 255;
+ }
+ }
+ }
+ }
+ POSITION pos = BlockData.GetHeadPosition();
+ while (pos) {
+ CBinary* b = BlockData.GetNext(pos);
+ pStream->Write(b->GetData(), b->GetCount(), NULL);
+ }
+ return S_OK;
}
Cue::Cue(DWORD id)
- : CID(id)
+ : CID(id)
{
}
MatroskaWriter::QWORD Cue::Size(bool fWithHeader)
{
- MatroskaWriter::QWORD len = 0;
- len += CuePoints.Size();
- if (fWithHeader) {
- len += HeaderSize(len);
- }
- return len;
+ MatroskaWriter::QWORD len = 0;
+ len += CuePoints.Size();
+ if (fWithHeader) {
+ len += HeaderSize(len);
+ }
+ return len;
}
HRESULT Cue::Write(IStream* pStream)
{
- HeaderWrite(pStream);
- CuePoints.Write(pStream);
- return S_OK;
+ HeaderWrite(pStream);
+ CuePoints.Write(pStream);
+ return S_OK;
}
CuePoint::CuePoint(DWORD id)
- : CID(id)
- , CueTime(0xB3)
+ : CID(id)
+ , CueTime(0xB3)
{
}
MatroskaWriter::QWORD CuePoint::Size(bool fWithHeader)
{
- MatroskaWriter::QWORD len = 0;
- len += CueTime.Size();
- len += CueTrackPositions.Size();
- if (fWithHeader) {
- len += HeaderSize(len);
- }
- return len;
+ MatroskaWriter::QWORD len = 0;
+ len += CueTime.Size();
+ len += CueTrackPositions.Size();
+ if (fWithHeader) {
+ len += HeaderSize(len);
+ }
+ return len;
}
HRESULT CuePoint::Write(IStream* pStream)
{
- HeaderWrite(pStream);
- CueTime.Write(pStream);
- CueTrackPositions.Write(pStream);
- return S_OK;
+ HeaderWrite(pStream);
+ CueTime.Write(pStream);
+ CueTrackPositions.Write(pStream);
+ return S_OK;
}
CueTrackPosition::CueTrackPosition(DWORD id)
- : CID(id)
- , CueTrack(0xF7)
- , CueClusterPosition(0xF1)
- , CueBlockNumber(0x5387)
- , CueCodecState(0xEA)
+ : CID(id)
+ , CueTrack(0xF7)
+ , CueClusterPosition(0xF1)
+ , CueBlockNumber(0x5387)
+ , CueCodecState(0xEA)
{
}
MatroskaWriter::QWORD CueTrackPosition::Size(bool fWithHeader)
{
- MatroskaWriter::QWORD len = 0;
- len += CueTrack.Size();
- len += CueClusterPosition.Size();
- len += CueBlockNumber.Size();
- len += CueCodecState.Size();
- // len += CueReferences.Size();
- if (fWithHeader) {
- len += HeaderSize(len);
- }
- return len;
+ MatroskaWriter::QWORD len = 0;
+ len += CueTrack.Size();
+ len += CueClusterPosition.Size();
+ len += CueBlockNumber.Size();
+ len += CueCodecState.Size();
+ // len += CueReferences.Size();
+ if (fWithHeader) {
+ len += HeaderSize(len);
+ }
+ return len;
}
HRESULT CueTrackPosition::Write(IStream* pStream)
{
- HeaderWrite(pStream);
- CueTrack.Write(pStream);
- CueClusterPosition.Write(pStream);
- CueBlockNumber.Write(pStream);
- CueCodecState.Write(pStream);
- // CueReferences.Write(pStream);
- return S_OK;
+ HeaderWrite(pStream);
+ CueTrack.Write(pStream);
+ CueClusterPosition.Write(pStream);
+ CueBlockNumber.Write(pStream);
+ CueCodecState.Write(pStream);
+ // CueReferences.Write(pStream);
+ return S_OK;
}
Seek::Seek(DWORD id)
- : CID(id)
+ : CID(id)
{
}
MatroskaWriter::QWORD Seek::Size(bool fWithHeader)
{
- MatroskaWriter::QWORD len = 0;
- len += SeekHeads.Size();
- if (fWithHeader) {
- len += HeaderSize(len);
- }
- return len;
+ MatroskaWriter::QWORD len = 0;
+ len += SeekHeads.Size();
+ if (fWithHeader) {
+ len += HeaderSize(len);
+ }
+ return len;
}
HRESULT Seek::Write(IStream* pStream)
{
- HeaderWrite(pStream);
- SeekHeads.Write(pStream);
- return S_OK;
+ HeaderWrite(pStream);
+ SeekHeads.Write(pStream);
+ return S_OK;
}
SeekID::SeekID(DWORD id)
- : CID(id)
- , m_id(0)
+ : CID(id)
+ , m_id(0)
{
}
MatroskaWriter::QWORD SeekID::Size(bool fWithHeader)
{
- MatroskaWriter::QWORD len = 0;
- len += m_id.Size();
- if (fWithHeader) {
- len += HeaderSize(len);
- }
- return len;
+ MatroskaWriter::QWORD len = 0;
+ len += m_id.Size();
+ if (fWithHeader) {
+ len += HeaderSize(len);
+ }
+ return len;
}
HRESULT SeekID::Write(IStream* pStream)
{
- HeaderWrite(pStream);
- m_id.Write(pStream);
- return S_OK;
+ HeaderWrite(pStream);
+ m_id.Write(pStream);
+ return S_OK;
}
SeekHead::SeekHead(DWORD id)
- : CID(id)
- , Position(0x53AC)
+ : CID(id)
+ , Position(0x53AC)
{
}
MatroskaWriter::QWORD SeekHead::Size(bool fWithHeader)
{
- MatroskaWriter::QWORD len = 0;
- len += ID.Size();
- len += Position.Size();
- if (fWithHeader) {
- len += HeaderSize(len);
- }
- return len;
+ MatroskaWriter::QWORD len = 0;
+ len += ID.Size();
+ len += Position.Size();
+ if (fWithHeader) {
+ len += HeaderSize(len);
+ }
+ return len;
}
HRESULT SeekHead::Write(IStream* pStream)
{
- HeaderWrite(pStream);
- ID.Write(pStream);
- Position.Write(pStream);
- return S_OK;
+ HeaderWrite(pStream);
+ ID.Write(pStream);
+ Position.Write(pStream);
+ return S_OK;
}
Tags::Tags(DWORD id)
- : CID(id)
+ : CID(id)
{
}
MatroskaWriter::QWORD Tags::Size(bool fWithHeader)
{
- MatroskaWriter::QWORD len = 0;
- // len += .Size();
- if (fWithHeader) {
- len += HeaderSize(len);
- }
- return len;
+ MatroskaWriter::QWORD len = 0;
+ // len += .Size();
+ if (fWithHeader) {
+ len += HeaderSize(len);
+ }
+ return len;
}
HRESULT Tags::Write(IStream* pStream)
{
- HeaderWrite(pStream);
- // .Write(pStream);
- return S_OK;
+ HeaderWrite(pStream);
+ // .Write(pStream);
+ return S_OK;
}
Void::Void(MatroskaWriter::QWORD len, DWORD id)
- : CID(id)
- , m_len(len)
+ : CID(id)
+ , m_len(len)
{
}
MatroskaWriter::QWORD Void::Size(bool fWithHeader)
{
- MatroskaWriter::QWORD len = 0;
- len += m_len;
- if (fWithHeader) {
- len += HeaderSize(len);
- }
- return len;
+ MatroskaWriter::QWORD len = 0;
+ len += m_len;
+ if (fWithHeader) {
+ len += HeaderSize(len);
+ }
+ return len;
}
HRESULT Void::Write(IStream* pStream)
{
- HeaderWrite(pStream);
- BYTE buff[64];
- memset(buff, 0x80, sizeof(buff));
- for (int len = (int)m_len; len > 0; len -= sizeof(buff)) {
- pStream->Write(buff, (ULONG)min(sizeof(buff), len), NULL);
- }
- return S_OK;
+ HeaderWrite(pStream);
+ BYTE buff[64];
+ memset(buff, 0x80, sizeof(buff));
+ for (int len = (int)m_len; len > 0; len -= sizeof(buff)) {
+ pStream->Write(buff, (ULONG)min(sizeof(buff), len), NULL);
+ }
+ return S_OK;
}
diff --git a/src/filters/muxer/MatroskaMuxer/MatroskaFile.h b/src/filters/muxer/MatroskaMuxer/MatroskaFile.h
index 1da6ad4b4..5950861fd 100644
--- a/src/filters/muxer/MatroskaMuxer/MatroskaFile.h
+++ b/src/filters/muxer/MatroskaMuxer/MatroskaFile.h
@@ -28,395 +28,395 @@
namespace MatroskaWriter
{
- typedef unsigned __int64 QWORD;
-
- class CID
- {
- protected:
- DWORD m_id;
- QWORD HeaderSize(QWORD len);
- HRESULT HeaderWrite(IStream* pStream);
-
- public:
- CID(DWORD id);
- DWORD GetID() const {
- return m_id;
- }
- virtual QWORD Size(bool fWithHeader = true);
- virtual HRESULT Write(IStream* pStream);
- };
-
- class CLength : public CID
- {
- UINT64 m_len;
- public:
- CLength(UINT64 len = 0) : CID(0), m_len(len) {}
- operator UINT64() {
- return m_len;
- }
- QWORD Size(bool fWithHeader = false);
- HRESULT Write(IStream* pStream);
- };
-
- class CBinary : public CAtlArray<BYTE>, public CID
- {
- public:
- CBinary(DWORD id) : CID(id) {}
- CBinary& operator = (const CBinary& b) {
- Copy(b);
- return *this;
- }
- operator BYTE*() {
- return (BYTE*)GetData();
- }
- CBinary& Set(CStringA str) {
- SetCount(str.GetLength()+1);
- strcpy_s((char*)GetData(), str.GetLength() + 1, str);
- return *this;
- }
- // CBinary& Set(CStringA str) {SetCount(str.GetLength()); memcpy((char*)GetData(), str, str.GetLength()); return *this;}
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class CANSI : public CStringA, public CID
- {
- public:
- CANSI(DWORD id) : CID(id) {}
- CANSI& Set(CStringA str) {
- CStringA::operator = (str);
- return *this;
- }
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class CUTF8 : public CStringW, public CID
- {
- public:
- CUTF8(DWORD id) : CID(id) {}
- CUTF8& Set(CStringW str) {
- CStringW::operator = (str);
- return *this;
- }
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- template<class T, class BASE>
- class CSimpleVar : public CID
- {
- protected:
- T m_val;
- bool m_fSet;
- public:
- explicit CSimpleVar(DWORD id, T val = 0) : CID(id), m_val(val) {
- m_fSet = !!val;
- }
- operator T() {
- return m_val;
- }
- BASE& Set(T val) {
- m_val = val;
- m_fSet = true;
- return (*(BASE*)this);
- }
- void UnSet() {
- m_fSet = false;
- }
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class CUInt : public CSimpleVar<UINT64, CUInt>
- {
- public:
- explicit CUInt(DWORD id, UINT64 val = 0) : CSimpleVar<UINT64, CUInt>(id, val) {}
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class CInt : public CSimpleVar<INT64, CInt>
- {
- public:
- explicit CInt(DWORD id, INT64 val = 0) : CSimpleVar<INT64, CInt>(id, val) {}
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class CByte : public CSimpleVar<BYTE, CByte>
- {
- public:
- explicit CByte(DWORD id, BYTE val = 0) : CSimpleVar<BYTE, CByte>(id, val) {}
- };
-
- class CShort : public CSimpleVar<short, CShort>
- {
- public:
- explicit CShort(DWORD id, short val = 0) : CSimpleVar<short, CShort>(id, val) {}
- };
-
- class CFloat : public CSimpleVar<float, CFloat>
- {
- public:
- explicit CFloat(DWORD id, float val = 0) : CSimpleVar<float, CFloat>(id, val) {}
- };
-
- template<class T>
- class CNode : public CAutoPtrList<T>
- {
- public:
- QWORD Size(bool fWithHeader = true) {
- QWORD len = 0;
- POSITION pos = GetHeadPosition();
- while (pos) {
- len += GetNext(pos)->Size(fWithHeader);
- }
- return len;
- }
- HRESULT Write(IStream* pStream) {
- HRESULT hr;
- POSITION pos = GetHeadPosition();
- while (pos) if (FAILED(hr = GetNext(pos)->Write(pStream))) {
- return hr;
- }
- return S_OK;
- }
- };
-
- class EBML : public CID
- {
- public:
- CUInt EBMLVersion, EBMLReadVersion;
- CUInt EBMLMaxIDLength, EBMLMaxSizeLength;
- CANSI DocType;
- CUInt DocTypeVersion, DocTypeReadVersion;
-
- EBML(DWORD id = 0x1A45DFA3);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class Info : public CID
- {
- public:
- CBinary SegmentUID, PrevUID, NextUID;
- CUTF8 SegmentFilename, PrevFilename, NextFilename;
- CUInt TimeCodeScale; // [ns], default: 1.000.000
- CFloat Duration;
- CInt DateUTC;
- CUTF8 Title, MuxingApp, WritingApp;
-
- Info(DWORD id = 0x1549A966);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class Video : public CID
- {
- public:
- CUInt FlagInterlaced, StereoMode;
- CUInt PixelWidth, PixelHeight, DisplayWidth, DisplayHeight, DisplayUnit;
- CUInt AspectRatioType;
- CUInt ColourSpace;
- CFloat GammaValue;
- CFloat FramePerSec;
-
- Video(DWORD id = 0xE0);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class Audio : public CID
- {
- public:
- CFloat SamplingFrequency;
- CFloat OutputSamplingFrequency;
- CUInt Channels;
- CBinary ChannelPositions;
- CUInt BitDepth;
-
- Audio(DWORD id = 0xE1);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class TrackEntry : public CID
- {
- public:
- enum {TypeVideo = 1, TypeAudio = 2, TypeComplex = 3, TypeLogo = 0x10, TypeSubtitle = 0x11, TypeControl = 0x20};
- CUInt TrackNumber, TrackUID, TrackType;
- CUInt FlagEnabled, FlagDefault, FlagLacing;
- CUInt MinCache, MaxCache;
- CUTF8 Name;
- CANSI Language;
- CBinary CodecID;
- CBinary CodecPrivate;
- CUTF8 CodecName;
- CUTF8 CodecSettings;
- CANSI CodecInfoURL;
- CANSI CodecDownloadURL;
- CUInt CodecDecodeAll;
- CUInt TrackOverlay;
- CUInt DefaultDuration;
- enum {NoDesc = 0, DescVideo = 1, DescAudio = 2};
- int DescType;
- Video v;
- Audio a;
-
- TrackEntry(DWORD id = 0xAE);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class Track : public CID
- {
- public:
- CNode<TrackEntry> TrackEntries;
-
- Track(DWORD id = 0x1654AE6B);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class CBlock : public CID
- {
- public:
- CLength TrackNumber;
- REFERENCE_TIME TimeCode, TimeCodeStop;
- CNode<CBinary> BlockData;
-
- CBlock(DWORD id = 0xA1);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class BlockGroup : public CID
- {
- public:
- CUInt BlockDuration;
- CUInt ReferencePriority;
- CInt ReferenceBlock;
- CInt ReferenceVirtual;
- CBinary CodecState;
- CBlock Block;
- // CNode<TimeSlice> TimeSlices;
-
- BlockGroup(DWORD id = 0xA0);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class Cluster : public CID
- {
- public:
- CUInt TimeCode, Position, PrevSize;
- CNode<BlockGroup> BlockGroups;
-
- Cluster(DWORD id = 0x1F43B675);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- /* class CueReference : public CID
- {
- public:
- CUInt CueRefTime, CueRefCluster, CueRefNumber, CueRefCodecState;
-
- CueReference(DWORD id = 0xDB);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
- */
- class CueTrackPosition : public CID
- {
- public:
- CUInt CueTrack, CueClusterPosition, CueBlockNumber, CueCodecState;
- // CNode<CueReference> CueReferences;
-
- CueTrackPosition(DWORD id = 0xB7);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class CuePoint : public CID
- {
- public:
- CUInt CueTime;
- CNode<CueTrackPosition> CueTrackPositions;
-
- CuePoint(DWORD id = 0xBB);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class Cue : public CID
- {
- public:
- CNode<CuePoint> CuePoints;
-
- Cue(DWORD id = 0x1C53BB6B);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class SeekID : public CID
- {
- CID m_id;
- public:
- SeekID(DWORD id = 0x53AB);
- void Set(DWORD id) {
- m_id = id;
- }
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class SeekHead : public CID
- {
- public:
- SeekID ID;
- CUInt Position;
-
- SeekHead(DWORD id = 0x4DBB);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class Seek : public CID
- {
- public:
- CNode<SeekHead> SeekHeads;
-
- Seek(DWORD id = 0x114D9B74);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class Segment : public CID
- {
- public:
- Segment(DWORD id = 0x18538067);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class Tags : public CID
- {
- public:
- // TODO
-
- Tags(DWORD id = 0x1254C367);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class Void : public CID
- {
- QWORD m_len;
- public:
- Void(QWORD len, DWORD id = 0xEC);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
+ typedef unsigned __int64 QWORD;
+
+ class CID
+ {
+ protected:
+ DWORD m_id;
+ QWORD HeaderSize(QWORD len);
+ HRESULT HeaderWrite(IStream* pStream);
+
+ public:
+ CID(DWORD id);
+ DWORD GetID() const {
+ return m_id;
+ }
+ virtual QWORD Size(bool fWithHeader = true);
+ virtual HRESULT Write(IStream* pStream);
+ };
+
+ class CLength : public CID
+ {
+ UINT64 m_len;
+ public:
+ CLength(UINT64 len = 0) : CID(0), m_len(len) {}
+ operator UINT64() {
+ return m_len;
+ }
+ QWORD Size(bool fWithHeader = false);
+ HRESULT Write(IStream* pStream);
+ };
+
+ class CBinary : public CAtlArray<BYTE>, public CID
+ {
+ public:
+ CBinary(DWORD id) : CID(id) {}
+ CBinary& operator = (const CBinary& b) {
+ Copy(b);
+ return *this;
+ }
+ operator BYTE* () {
+ return (BYTE*)GetData();
+ }
+ CBinary& Set(CStringA str) {
+ SetCount(str.GetLength() + 1);
+ strcpy_s((char*)GetData(), str.GetLength() + 1, str);
+ return *this;
+ }
+ // CBinary& Set(CStringA str) {SetCount(str.GetLength()); memcpy((char*)GetData(), str, str.GetLength()); return *this;}
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
+
+ class CANSI : public CStringA, public CID
+ {
+ public:
+ CANSI(DWORD id) : CID(id) {}
+ CANSI& Set(CStringA str) {
+ CStringA::operator = (str);
+ return *this;
+ }
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
+
+ class CUTF8 : public CStringW, public CID
+ {
+ public:
+ CUTF8(DWORD id) : CID(id) {}
+ CUTF8& Set(CStringW str) {
+ CStringW::operator = (str);
+ return *this;
+ }
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
+
+ template<class T, class BASE>
+ class CSimpleVar : public CID
+ {
+ protected:
+ T m_val;
+ bool m_fSet;
+ public:
+ explicit CSimpleVar(DWORD id, T val = 0) : CID(id), m_val(val) {
+ m_fSet = !!val;
+ }
+ operator T() {
+ return m_val;
+ }
+ BASE& Set(T val) {
+ m_val = val;
+ m_fSet = true;
+ return (*(BASE*)this);
+ }
+ void UnSet() {
+ m_fSet = false;
+ }
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
+
+ class CUInt : public CSimpleVar<UINT64, CUInt>
+ {
+ public:
+ explicit CUInt(DWORD id, UINT64 val = 0) : CSimpleVar<UINT64, CUInt>(id, val) {}
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
+
+ class CInt : public CSimpleVar<INT64, CInt>
+ {
+ public:
+ explicit CInt(DWORD id, INT64 val = 0) : CSimpleVar<INT64, CInt>(id, val) {}
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
+
+ class CByte : public CSimpleVar<BYTE, CByte>
+ {
+ public:
+ explicit CByte(DWORD id, BYTE val = 0) : CSimpleVar<BYTE, CByte>(id, val) {}
+ };
+
+ class CShort : public CSimpleVar<short, CShort>
+ {
+ public:
+ explicit CShort(DWORD id, short val = 0) : CSimpleVar<short, CShort>(id, val) {}
+ };
+
+ class CFloat : public CSimpleVar<float, CFloat>
+ {
+ public:
+ explicit CFloat(DWORD id, float val = 0) : CSimpleVar<float, CFloat>(id, val) {}
+ };
+
+ template<class T>
+ class CNode : public CAutoPtrList<T>
+ {
+ public:
+ QWORD Size(bool fWithHeader = true) {
+ QWORD len = 0;
+ POSITION pos = GetHeadPosition();
+ while (pos) {
+ len += GetNext(pos)->Size(fWithHeader);
+ }
+ return len;
+ }
+ HRESULT Write(IStream* pStream) {
+ HRESULT hr;
+ POSITION pos = GetHeadPosition();
+ while (pos) if (FAILED(hr = GetNext(pos)->Write(pStream))) {
+ return hr;
+ }
+ return S_OK;
+ }
+ };
+
+ class EBML : public CID
+ {
+ public:
+ CUInt EBMLVersion, EBMLReadVersion;
+ CUInt EBMLMaxIDLength, EBMLMaxSizeLength;
+ CANSI DocType;
+ CUInt DocTypeVersion, DocTypeReadVersion;
+
+ EBML(DWORD id = 0x1A45DFA3);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
+
+ class Info : public CID
+ {
+ public:
+ CBinary SegmentUID, PrevUID, NextUID;
+ CUTF8 SegmentFilename, PrevFilename, NextFilename;
+ CUInt TimeCodeScale; // [ns], default: 1.000.000
+ CFloat Duration;
+ CInt DateUTC;
+ CUTF8 Title, MuxingApp, WritingApp;
+
+ Info(DWORD id = 0x1549A966);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
+
+ class Video : public CID
+ {
+ public:
+ CUInt FlagInterlaced, StereoMode;
+ CUInt PixelWidth, PixelHeight, DisplayWidth, DisplayHeight, DisplayUnit;
+ CUInt AspectRatioType;
+ CUInt ColourSpace;
+ CFloat GammaValue;
+ CFloat FramePerSec;
+
+ Video(DWORD id = 0xE0);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
+
+ class Audio : public CID
+ {
+ public:
+ CFloat SamplingFrequency;
+ CFloat OutputSamplingFrequency;
+ CUInt Channels;
+ CBinary ChannelPositions;
+ CUInt BitDepth;
+
+ Audio(DWORD id = 0xE1);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
+
+ class TrackEntry : public CID
+ {
+ public:
+ enum {TypeVideo = 1, TypeAudio = 2, TypeComplex = 3, TypeLogo = 0x10, TypeSubtitle = 0x11, TypeControl = 0x20};
+ CUInt TrackNumber, TrackUID, TrackType;
+ CUInt FlagEnabled, FlagDefault, FlagLacing;
+ CUInt MinCache, MaxCache;
+ CUTF8 Name;
+ CANSI Language;
+ CBinary CodecID;
+ CBinary CodecPrivate;
+ CUTF8 CodecName;
+ CUTF8 CodecSettings;
+ CANSI CodecInfoURL;
+ CANSI CodecDownloadURL;
+ CUInt CodecDecodeAll;
+ CUInt TrackOverlay;
+ CUInt DefaultDuration;
+ enum {NoDesc = 0, DescVideo = 1, DescAudio = 2};
+ int DescType;
+ Video v;
+ Audio a;
+
+ TrackEntry(DWORD id = 0xAE);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
+
+ class Track : public CID
+ {
+ public:
+ CNode<TrackEntry> TrackEntries;
+
+ Track(DWORD id = 0x1654AE6B);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
+
+ class CBlock : public CID
+ {
+ public:
+ CLength TrackNumber;
+ REFERENCE_TIME TimeCode, TimeCodeStop;
+ CNode<CBinary> BlockData;
+
+ CBlock(DWORD id = 0xA1);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
+
+ class BlockGroup : public CID
+ {
+ public:
+ CUInt BlockDuration;
+ CUInt ReferencePriority;
+ CInt ReferenceBlock;
+ CInt ReferenceVirtual;
+ CBinary CodecState;
+ CBlock Block;
+ // CNode<TimeSlice> TimeSlices;
+
+ BlockGroup(DWORD id = 0xA0);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
+
+ class Cluster : public CID
+ {
+ public:
+ CUInt TimeCode, Position, PrevSize;
+ CNode<BlockGroup> BlockGroups;
+
+ Cluster(DWORD id = 0x1F43B675);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
+
+ /* class CueReference : public CID
+ {
+ public:
+ CUInt CueRefTime, CueRefCluster, CueRefNumber, CueRefCodecState;
+
+ CueReference(DWORD id = 0xDB);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
+ */
+ class CueTrackPosition : public CID
+ {
+ public:
+ CUInt CueTrack, CueClusterPosition, CueBlockNumber, CueCodecState;
+ // CNode<CueReference> CueReferences;
+
+ CueTrackPosition(DWORD id = 0xB7);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
+
+ class CuePoint : public CID
+ {
+ public:
+ CUInt CueTime;
+ CNode<CueTrackPosition> CueTrackPositions;
+
+ CuePoint(DWORD id = 0xBB);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
+
+ class Cue : public CID
+ {
+ public:
+ CNode<CuePoint> CuePoints;
+
+ Cue(DWORD id = 0x1C53BB6B);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
+
+ class SeekID : public CID
+ {
+ CID m_id;
+ public:
+ SeekID(DWORD id = 0x53AB);
+ void Set(DWORD id) {
+ m_id = id;
+ }
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
+
+ class SeekHead : public CID
+ {
+ public:
+ SeekID ID;
+ CUInt Position;
+
+ SeekHead(DWORD id = 0x4DBB);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
+
+ class Seek : public CID
+ {
+ public:
+ CNode<SeekHead> SeekHeads;
+
+ Seek(DWORD id = 0x114D9B74);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
+
+ class Segment : public CID
+ {
+ public:
+ Segment(DWORD id = 0x18538067);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
+
+ class Tags : public CID
+ {
+ public:
+ // TODO
+
+ Tags(DWORD id = 0x1254C367);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
+
+ class Void : public CID
+ {
+ QWORD m_len;
+ public:
+ Void(QWORD len, DWORD id = 0xEC);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
}
diff --git a/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.cpp b/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.cpp
index 63018f926..a936b7455 100644
--- a/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.cpp
+++ b/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.cpp
@@ -36,32 +36,32 @@ using namespace MatroskaWriter;
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_Matroska}
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_Matroska}
};
const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, TRUE, &CLSID_NULL, NULL, 0, NULL},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
+ {L"Input", FALSE, FALSE, FALSE, TRUE, &CLSID_NULL, NULL, 0, NULL},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CMatroskaMuxerFilter), MatroskaMuxerName, MERIT_DO_NOT_USE, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory}
+ {&__uuidof(CMatroskaMuxerFilter), MatroskaMuxerName, MERIT_DO_NOT_USE, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory}
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMatroskaMuxerFilter>, NULL, &sudFilter[0]}
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMatroskaMuxerFilter>, NULL, &sudFilter[0]}
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -75,634 +75,634 @@ CFilterApp theApp;
//
CMatroskaMuxerFilter::CMatroskaMuxerFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseFilter(NAME("CMatroskaMuxerFilter"), pUnk, this, __uuidof(this))
- , m_rtCurrent(0)
- , m_fNegative(true), m_fPositive(false)
+ : CBaseFilter(NAME("CMatroskaMuxerFilter"), pUnk, this, __uuidof(this))
+ , m_rtCurrent(0)
+ , m_fNegative(true), m_fPositive(false)
{
- if (phr) {
- *phr = S_OK;
- }
+ if (phr) {
+ *phr = S_OK;
+ }
- m_pOutput.Attach(DNew CMatroskaMuxerOutputPin(NAME("CMatroskaMuxerOutputPin"), this, this, phr));
+ m_pOutput.Attach(DNew CMatroskaMuxerOutputPin(NAME("CMatroskaMuxerOutputPin"), this, this, phr));
- AddInput();
+ AddInput();
- srand(clock());
+ srand(clock());
}
CMatroskaMuxerFilter::~CMatroskaMuxerFilter()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
}
STDMETHODIMP CMatroskaMuxerFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- *ppv = NULL;
+ *ppv = NULL;
- return
- // QI(IAMFilterMiscFlags)
- QI(IMediaSeeking)
- QI(IMatroskaMuxer)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ // QI(IAMFilterMiscFlags)
+ QI(IMediaSeeking)
+ QI(IMatroskaMuxer)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
UINT CMatroskaMuxerFilter::GetTrackNumber(CBasePin* pPin)
{
- UINT nTrackNumber = 0;
+ UINT nTrackNumber = 0;
- POSITION pos = m_pInputs.GetHeadPosition();
- while (pos) {
- nTrackNumber++;
- if (m_pInputs.GetNext(pos) == pPin) {
- return nTrackNumber;
- }
- }
+ POSITION pos = m_pInputs.GetHeadPosition();
+ while (pos) {
+ nTrackNumber++;
+ if (m_pInputs.GetNext(pos) == pPin) {
+ return nTrackNumber;
+ }
+ }
- return 0;
+ return 0;
}
void CMatroskaMuxerFilter::AddInput()
{
- POSITION pos = m_pInputs.GetHeadPosition();
- while (pos) {
- CBasePin* pPin = m_pInputs.GetNext(pos);
- if (!pPin->IsConnected()) {
- return;
- }
- }
-
- CStringW name;
- name.Format(L"Track %d", m_pInputs.GetCount()+1);
-
- HRESULT hr;
- CAutoPtr<CMatroskaMuxerInputPin> pPin(DNew CMatroskaMuxerInputPin(name, this, this, &hr));
- m_pInputs.AddTail(pPin);
+ POSITION pos = m_pInputs.GetHeadPosition();
+ while (pos) {
+ CBasePin* pPin = m_pInputs.GetNext(pos);
+ if (!pPin->IsConnected()) {
+ return;
+ }
+ }
+
+ CStringW name;
+ name.Format(L"Track %d", m_pInputs.GetCount() + 1);
+
+ HRESULT hr;
+ CAutoPtr<CMatroskaMuxerInputPin> pPin(DNew CMatroskaMuxerInputPin(name, this, this, &hr));
+ m_pInputs.AddTail(pPin);
}
int CMatroskaMuxerFilter::GetPinCount()
{
- return m_pInputs.GetCount() + (m_pOutput ? 1 : 0);
+ return m_pInputs.GetCount() + (m_pOutput ? 1 : 0);
}
CBasePin* CMatroskaMuxerFilter::GetPin(int n)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- if (n >= 0 && n < (int)m_pInputs.GetCount()) {
- if (POSITION pos = m_pInputs.FindIndex(n)) {
- return m_pInputs.GetAt(pos);
- }
- }
+ if (n >= 0 && n < (int)m_pInputs.GetCount()) {
+ if (POSITION pos = m_pInputs.FindIndex(n)) {
+ return m_pInputs.GetAt(pos);
+ }
+ }
- if (n == m_pInputs.GetCount() && m_pOutput) {
- return m_pOutput;
- }
+ if (n == m_pInputs.GetCount() && m_pOutput) {
+ return m_pOutput;
+ }
- return NULL;
+ return NULL;
}
STDMETHODIMP CMatroskaMuxerFilter::Stop()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- HRESULT hr;
+ HRESULT hr;
- if (FAILED(hr = __super::Stop())) {
- return hr;
- }
+ if (FAILED(hr = __super::Stop())) {
+ return hr;
+ }
- CallWorker(CMD_EXIT);
+ CallWorker(CMD_EXIT);
- return hr;
+ return hr;
}
STDMETHODIMP CMatroskaMuxerFilter::Pause()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- FILTER_STATE fs = m_State;
+ FILTER_STATE fs = m_State;
- HRESULT hr;
+ HRESULT hr;
- if (FAILED(hr = __super::Pause())) {
- return hr;
- }
+ if (FAILED(hr = __super::Pause())) {
+ return hr;
+ }
- if (fs == State_Stopped && m_pOutput) {
- CAMThread::Create();
- CallWorker(CMD_RUN);
- }
+ if (fs == State_Stopped && m_pOutput) {
+ CAMThread::Create();
+ CallWorker(CMD_RUN);
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CMatroskaMuxerFilter::Run(REFERENCE_TIME tStart)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- HRESULT hr;
+ HRESULT hr;
- if (FAILED(hr = __super::Run(tStart))) {
- return hr;
- }
+ if (FAILED(hr = __super::Run(tStart))) {
+ return hr;
+ }
- return hr;
+ return hr;
}
// IAMFilterMiscFlags
STDMETHODIMP_(ULONG) CMatroskaMuxerFilter::GetMiscFlags()
{
- return AM_FILTER_MISC_FLAGS_IS_RENDERER;
+ return AM_FILTER_MISC_FLAGS_IS_RENDERER;
}
// IMediaSeeking
STDMETHODIMP CMatroskaMuxerFilter::GetCapabilities(DWORD* pCapabilities)
{
- return pCapabilities ? *pCapabilities =
- AM_SEEKING_CanGetDuration|
- AM_SEEKING_CanGetCurrentPos, S_OK : E_POINTER;
+ return pCapabilities ? *pCapabilities =
+ AM_SEEKING_CanGetDuration |
+ AM_SEEKING_CanGetCurrentPos, S_OK : E_POINTER;
}
STDMETHODIMP CMatroskaMuxerFilter::CheckCapabilities(DWORD* pCapabilities)
{
- CheckPointer(pCapabilities, E_POINTER);
- if (*pCapabilities == 0) {
- return S_OK;
- }
- DWORD caps;
- GetCapabilities(&caps);
- caps &= *pCapabilities;
- return caps == 0 ? E_FAIL : caps == *pCapabilities ? S_OK : S_FALSE;
+ CheckPointer(pCapabilities, E_POINTER);
+ if (*pCapabilities == 0) {
+ return S_OK;
+ }
+ DWORD caps;
+ GetCapabilities(&caps);
+ caps &= *pCapabilities;
+ return caps == 0 ? E_FAIL : caps == *pCapabilities ? S_OK : S_FALSE;
}
STDMETHODIMP CMatroskaMuxerFilter::IsFormatSupported(const GUID* pFormat)
{
- return !pFormat ? E_POINTER : *pFormat == TIME_FORMAT_MEDIA_TIME ? S_OK : S_FALSE;
+ return !pFormat ? E_POINTER : *pFormat == TIME_FORMAT_MEDIA_TIME ? S_OK : S_FALSE;
}
STDMETHODIMP CMatroskaMuxerFilter::QueryPreferredFormat(GUID* pFormat)
{
- return GetTimeFormat(pFormat);
+ return GetTimeFormat(pFormat);
}
STDMETHODIMP CMatroskaMuxerFilter::GetTimeFormat(GUID* pFormat)
{
- return pFormat ? *pFormat = TIME_FORMAT_MEDIA_TIME, S_OK : E_POINTER;
+ return pFormat ? *pFormat = TIME_FORMAT_MEDIA_TIME, S_OK : E_POINTER;
}
STDMETHODIMP CMatroskaMuxerFilter::IsUsingTimeFormat(const GUID* pFormat)
{
- return IsFormatSupported(pFormat);
+ return IsFormatSupported(pFormat);
}
STDMETHODIMP CMatroskaMuxerFilter::SetTimeFormat(const GUID* pFormat)
{
- return S_OK == IsFormatSupported(pFormat) ? S_OK : E_INVALIDARG;
+ return S_OK == IsFormatSupported(pFormat) ? S_OK : E_INVALIDARG;
}
STDMETHODIMP CMatroskaMuxerFilter::GetDuration(LONGLONG* pDuration)
{
- CheckPointer(pDuration, E_POINTER);
- *pDuration = 0;
- POSITION pos = m_pInputs.GetHeadPosition();
- while (pos) {
- REFERENCE_TIME rt = m_pInputs.GetNext(pos)->m_rtDur;
- if (rt > *pDuration) {
- *pDuration = rt;
- }
- }
- return S_OK;
+ CheckPointer(pDuration, E_POINTER);
+ *pDuration = 0;
+ POSITION pos = m_pInputs.GetHeadPosition();
+ while (pos) {
+ REFERENCE_TIME rt = m_pInputs.GetNext(pos)->m_rtDur;
+ if (rt > *pDuration) {
+ *pDuration = rt;
+ }
+ }
+ return S_OK;
}
STDMETHODIMP CMatroskaMuxerFilter::GetStopPosition(LONGLONG* pStop)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CMatroskaMuxerFilter::GetCurrentPosition(LONGLONG* pCurrent)
{
- CheckPointer(pCurrent, E_POINTER);
- *pCurrent = m_rtCurrent;
- return S_OK;
+ CheckPointer(pCurrent, E_POINTER);
+ *pCurrent = m_rtCurrent;
+ return S_OK;
}
STDMETHODIMP CMatroskaMuxerFilter::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CMatroskaMuxerFilter::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CMatroskaMuxerFilter::GetPositions(LONGLONG* pCurrent, LONGLONG* pStop)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CMatroskaMuxerFilter::GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CMatroskaMuxerFilter::SetRate(double dRate)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CMatroskaMuxerFilter::GetRate(double* pdRate)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CMatroskaMuxerFilter::GetPreroll(LONGLONG* pllPreroll)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IMatroskaMuxer
STDMETHODIMP CMatroskaMuxerFilter::CorrectTimeOffset(bool fNegative, bool fPositive)
{
- m_fNegative = fNegative;
- m_fPositive = fPositive;
- return S_OK;
+ m_fNegative = fNegative;
+ m_fPositive = fPositive;
+ return S_OK;
}
//
ULONGLONG GetStreamPosition(IStream* pStream)
{
- ULARGE_INTEGER pos = {0, 0};
- pStream->Seek(*(LARGE_INTEGER*)&pos, STREAM_SEEK_CUR, &pos);
- return pos.QuadPart;
+ ULARGE_INTEGER pos = {0, 0};
+ pStream->Seek(*(LARGE_INTEGER*)&pos, STREAM_SEEK_CUR, &pos);
+ return pos.QuadPart;
}
ULONGLONG SetStreamPosition(IStream* pStream, ULONGLONG seekpos)
{
- LARGE_INTEGER pos;
- pos.QuadPart = seekpos;
- ULARGE_INTEGER posnew;
- posnew.QuadPart = GetStreamPosition(pStream);
- pStream->Seek(pos, STREAM_SEEK_SET, &posnew);
- return posnew.QuadPart;
+ LARGE_INTEGER pos;
+ pos.QuadPart = seekpos;
+ ULARGE_INTEGER posnew;
+ posnew.QuadPart = GetStreamPosition(pStream);
+ pStream->Seek(pos, STREAM_SEEK_SET, &posnew);
+ return posnew.QuadPart;
}
DWORD CMatroskaMuxerFilter::ThreadProc()
{
- CComQIPtr<IStream> pStream;
-
- if (!m_pOutput || !(pStream = m_pOutput->GetConnected())) {
- for (;;) {
- DWORD cmd = GetRequest();
- if (cmd == CMD_EXIT) {
- CAMThread::m_hThread = NULL;
- }
- Reply(S_OK);
- if (cmd == CMD_EXIT) {
- return 0;
- }
- }
- }
-
- REFERENCE_TIME rtDur = 0;
- GetDuration(&rtDur);
-
- SetStreamPosition(pStream, 0);
-
- ULARGE_INTEGER uli = {0};
- pStream->SetSize(uli);
-
- EBML hdr;
- hdr.DocType.Set("matroska");
- hdr.DocTypeVersion.Set(1);
- hdr.DocTypeReadVersion.Set(1);
- hdr.Write(pStream);
-
- Segment().Write(pStream);
- ULONGLONG segpos = GetStreamPosition(pStream);
-
- // TODO
- MatroskaWriter::QWORD voidlen = 100;
- if (rtDur > 0) {
- voidlen += int(1.0 * rtDur / MAXCLUSTERTIME / 10000 + 0.5) * 20;
- } else {
- voidlen += int(1.0 * 1000*60*60*24 / MAXCLUSTERTIME + 0.5) * 20; // when no duration is known, allocate for 24 hours (~340k)
- }
- ULONGLONG voidpos = GetStreamPosition(pStream);
- {
- Void v(voidlen);
- voidlen = v.Size();
- v.Write(pStream);
- }
-
- // Meta Seek
-
- Seek seek;
- CAutoPtr<SeekHead> sh;
-
- // Segment Info
-
- sh.Attach(DNew SeekHead());
- sh->ID.Set(0x1549A966);
- sh->Position.Set(GetStreamPosition(pStream) - segpos);
- seek.SeekHeads.AddTail(sh);
-
- ULONGLONG infopos = GetStreamPosition(pStream);
- Info info;
- info.MuxingApp.Set(L"DirectShow Matroska Muxer");
- info.TimeCodeScale.Set(1000000);
- info.Duration.Set((float)rtDur / 10000);
- struct tm _2001 = {0, 0, 0, 1, 0, 101, 0, 0, 1};
- info.DateUTC.Set((_time64(NULL) - _mktime64(&_2001)) * 1000000000);
- info.Write(pStream);
-
- // Tracks
-
- sh.Attach(DNew SeekHead());
- sh->ID.Set(0x1654AE6B);
- sh->Position.Set(GetStreamPosition(pStream) - segpos);
- seek.SeekHeads.AddTail(sh);
-
- UINT64 TrackNumber = 0;
- /*
- CNode<Track> Tracks;
- CAutoPtr<Track> pT(DNew Track());
- POSITION pos = m_pInputs.GetHeadPosition();
- for (int i = 1; pos; i++)
- {
- CMatroskaMuxerInputPin* pPin = m_pInputs.GetNext(pos);
- if (!pPin->IsConnected()) continue;
-
- CAutoPtr<TrackEntry> pTE(DNew TrackEntry());
- *pTE = *pPin->GetTrackEntry();
- if (TrackNumber == 0 && pTE->TrackType == TrackEntry::TypeVideo)
- TrackNumber = pTE->TrackNumber;
- pT->TrackEntries.AddTail(pTE);
- }
- Tracks.AddTail(pT);
- Tracks.Write(pStream);
-
- if (TrackNumber == 0) TrackNumber = 1;
- */
- bool fTracksWritten = false;
-
- //
-
- Cluster c;
- c.TimeCode.Set(0);
-
- bool fFirstBlock = true;
- INT64 firstTimeCode = 0;
-
- CAtlList<CMatroskaMuxerInputPin*> pActivePins;
-
- POSITION pos = m_pInputs.GetHeadPosition();
- while (pos) {
- CMatroskaMuxerInputPin* pPin = m_pInputs.GetNext(pos);
- if (pPin->IsConnected()) {
- pActivePins.AddTail(pPin);
- }
- }
-
- for (;;) {
- DWORD cmd = GetRequest();
-
- switch (cmd) {
- default:
- case CMD_EXIT:
- CAMThread::m_hThread = NULL;
- Reply(S_OK);
- return 0;
-
- case CMD_RUN:
- Reply(S_OK);
-
- Cue cue;
- ULONGLONG lastcueclusterpos = (ULONGLONG)-1;
- INT64 lastcuetimecode = (INT64)-1;
- UINT64 nBlocksInCueTrack = 0;
-
- while (!CheckRequest(NULL)) {
- if (m_State == State_Paused) {
- Sleep(10);
- continue;
- }
-
- int nPinsGotSomething = 0, nPinsNeeded = 0;
- CMatroskaMuxerInputPin* pPin = NULL;
- REFERENCE_TIME rtMin = _I64_MAX;
-
- pos = pActivePins.GetHeadPosition();
- while (pos) {
- CMatroskaMuxerInputPin* pTmp = pActivePins.GetNext(pos);
-
- CAutoLock cAutoLock(&pTmp->m_csQueue);
-
- if (pTmp->m_blocks.GetCount() == 0 && pTmp->m_fEndOfStreamReceived) {
- pActivePins.RemoveAt(pActivePins.Find(pTmp));
- continue;
- }
-
- if (pTmp->GetTrackEntry()->TrackType != TrackEntry::TypeSubtitle) {
- nPinsNeeded++;
- }
-
- if (pTmp->m_blocks.GetCount() > 0) {
- if (pTmp->GetTrackEntry()->TrackType != TrackEntry::TypeSubtitle) {
- nPinsGotSomething++;
- }
-
- if (pTmp->m_blocks.GetCount() > 0) {
- REFERENCE_TIME rt = pTmp->m_blocks.GetHead()->Block.TimeCode;
- if (rt < rtMin) {
- rtMin = rt;
- pPin = pTmp;
- }
- }
- }
- }
-
- if (pActivePins.GetCount() == 0) {
- break;
- }
-
- if (!pPin || nPinsNeeded > nPinsGotSomething || !pPin && nPinsGotSomething == 0) {
- Sleep(1);
- continue;
- }
-
- if (!fTracksWritten) {
- CNode<Track> Tracks;
- CAutoPtr<Track> pT(DNew Track());
- POSITION pos = pActivePins.GetHeadPosition();
- for (int i = 1; pos; i++) {
- CMatroskaMuxerInputPin* pPin = pActivePins.GetNext(pos);
-
- CAutoPtr<TrackEntry> pTE(DNew TrackEntry());
- *pTE = *pPin->GetTrackEntry();
- if (TrackNumber == 0 && pTE->TrackType == TrackEntry::TypeVideo) {
- TrackNumber = pTE->TrackNumber;
- }
- pT->TrackEntries.AddTail(pTE);
- }
- Tracks.AddTail(pT);
- Tracks.Write(pStream);
-
- if (TrackNumber == 0) {
- TrackNumber = 1;
- }
-
- fTracksWritten = true;
- }
-
- ASSERT(pPin);
-
- CAutoPtr<BlockGroup> b;
-
- {
- CAutoLock cAutoLock(&pPin->m_csQueue);
- b = pPin->m_blocks.RemoveHead();
- }
-
- if (b) {
- if (fFirstBlock) {
- if (b->Block.TimeCode < 0 && m_fNegative || b->Block.TimeCode > 0 && m_fPositive) {
- firstTimeCode = b->Block.TimeCode;
- }
- fFirstBlock = false;
- }
-
- b->Block.TimeCode -= firstTimeCode;
- b->Block.TimeCodeStop -= firstTimeCode;
-
- /*
- TRACE(_T("Muxing (%d): %I64d-%I64d dur=%I64d (c=%d, co=%dms), cnt=%d, ref=%d\n"),
- GetTrackNumber(pPin),
- (INT64)b->Block.TimeCode, (INT64)b->Block.TimeCodeStop, (UINT64)b->BlockDuration,
- (int)((b->Block.TimeCode)/MAXCLUSTERTIME), (int)(b->Block.TimeCode%MAXCLUSTERTIME),
- b->Block.BlockData.GetCount(), (int)b->ReferenceBlock);
- */
- if (b->Block.TimeCode < SHRT_MIN /*0*/) {
- ASSERT(0);
- continue;
- }
-
- while ((INT64)(c.TimeCode + MAXCLUSTERTIME) < b->Block.TimeCode) {
- if (!c.BlockGroups.IsEmpty()) {
- sh.Attach(DNew SeekHead());
- sh->ID.Set(c.GetID()/*0x1F43B675*/);
- sh->Position.Set(GetStreamPosition(pStream) - segpos);
- seek.SeekHeads.AddTail(sh);
-
- c.Write(pStream); // TODO: write blocks
- }
-
- c.TimeCode.Set(c.TimeCode + MAXCLUSTERTIME);
- c.BlockGroups.RemoveAll();
- nBlocksInCueTrack = 0;
- }
-
- if (b->Block.TrackNumber == TrackNumber) {
- nBlocksInCueTrack++;
- }
-
- if (b->ReferenceBlock == 0 && b->Block.TrackNumber == TrackNumber) {
- ULONGLONG clusterpos = GetStreamPosition(pStream) - segpos;
- if (lastcueclusterpos != clusterpos || lastcuetimecode + 1000 < b->Block.TimeCode) {
- CAutoPtr<CueTrackPosition> ctp(DNew CueTrackPosition());
- ctp->CueTrack.Set(b->Block.TrackNumber);
- ctp->CueClusterPosition.Set(clusterpos);
- if (c.BlockGroups.GetCount() > 0) {
- ctp->CueBlockNumber.Set(nBlocksInCueTrack);
- }
- CAutoPtr<CuePoint> cp(DNew CuePoint());
- cp->CueTime.Set(b->Block.TimeCode);
- cp->CueTrackPositions.AddTail(ctp);
- cue.CuePoints.AddTail(cp);
- lastcueclusterpos = clusterpos;
- lastcuetimecode = b->Block.TimeCode;
- }
- }
-
- info.Duration.Set(max(info.Duration, (float)b->Block.TimeCodeStop));
-
- m_rtCurrent = b->Block.TimeCode*10000;
-
- b->Block.TimeCode -= c.TimeCode;
- c.BlockGroups.AddTail(b);
- }
- }
-
- if (!c.BlockGroups.IsEmpty()) {
- sh.Attach(DNew SeekHead());
- sh->ID.Set(c.GetID()/*0x1F43B675*/);
- sh->Position.Set(GetStreamPosition(pStream) - segpos);
- seek.SeekHeads.AddTail(sh);
-
- c.Write(pStream);
- }
-
- if (!cue.CuePoints.IsEmpty()) {
- sh.Attach(DNew SeekHead());
- sh->ID.Set(cue.GetID()/*0x1C53BB6B*/);
- sh->Position.Set(GetStreamPosition(pStream) - segpos);
- seek.SeekHeads.AddTail(sh);
-
- cue.Write(pStream);
- }
-
- {
- Tags tags;
-
- sh.Attach(DNew SeekHead());
- sh->ID.Set(tags.GetID());
- sh->Position.Set(GetStreamPosition(pStream) - segpos);
- seek.SeekHeads.AddTail(sh);
-
- tags.Write(pStream);
- }
-
- SetStreamPosition(pStream, voidpos);
- int len = (int)(voidlen - seek.Size());
- ASSERT(len >= 0 && len != 1);
- seek.Write(pStream);
-
- if (len == 0) {
- // nothing to do
- } else if (len >= 2) {
- for (int i = 0; i < 8; i++) {
- if (len >= (1<<i*7)-2 && len <= (1<<(i+1)*7)-2) {
- Void(len-2-i).Write(pStream);
- break;
- }
- }
- }
-
- if (abs(m_rtCurrent - (REFERENCE_TIME)info.Duration*10000) > 10000000i64) {
- info.Duration.Set(m_rtCurrent / 10000 + 1);
- }
-
- SetStreamPosition(pStream, infopos);
- info.Write(pStream);
-
- // TODO: write some tags
-
- m_pOutput->DeliverEndOfStream();
-
- break;
- }
- }
-
- ASSERT(0); // we should only exit via CMD_EXIT
-
- CAMThread::m_hThread = NULL;
- return 0;
+ CComQIPtr<IStream> pStream;
+
+ if (!m_pOutput || !(pStream = m_pOutput->GetConnected())) {
+ for (;;) {
+ DWORD cmd = GetRequest();
+ if (cmd == CMD_EXIT) {
+ CAMThread::m_hThread = NULL;
+ }
+ Reply(S_OK);
+ if (cmd == CMD_EXIT) {
+ return 0;
+ }
+ }
+ }
+
+ REFERENCE_TIME rtDur = 0;
+ GetDuration(&rtDur);
+
+ SetStreamPosition(pStream, 0);
+
+ ULARGE_INTEGER uli = {0};
+ pStream->SetSize(uli);
+
+ EBML hdr;
+ hdr.DocType.Set("matroska");
+ hdr.DocTypeVersion.Set(1);
+ hdr.DocTypeReadVersion.Set(1);
+ hdr.Write(pStream);
+
+ Segment().Write(pStream);
+ ULONGLONG segpos = GetStreamPosition(pStream);
+
+ // TODO
+ MatroskaWriter::QWORD voidlen = 100;
+ if (rtDur > 0) {
+ voidlen += int(1.0 * rtDur / MAXCLUSTERTIME / 10000 + 0.5) * 20;
+ } else {
+ voidlen += int(1.0 * 1000 * 60 * 60 * 24 / MAXCLUSTERTIME + 0.5) * 20; // when no duration is known, allocate for 24 hours (~340k)
+ }
+ ULONGLONG voidpos = GetStreamPosition(pStream);
+ {
+ Void v(voidlen);
+ voidlen = v.Size();
+ v.Write(pStream);
+ }
+
+ // Meta Seek
+
+ Seek seek;
+ CAutoPtr<SeekHead> sh;
+
+ // Segment Info
+
+ sh.Attach(DNew SeekHead());
+ sh->ID.Set(0x1549A966);
+ sh->Position.Set(GetStreamPosition(pStream) - segpos);
+ seek.SeekHeads.AddTail(sh);
+
+ ULONGLONG infopos = GetStreamPosition(pStream);
+ Info info;
+ info.MuxingApp.Set(L"DirectShow Matroska Muxer");
+ info.TimeCodeScale.Set(1000000);
+ info.Duration.Set((float)rtDur / 10000);
+ struct tm _2001 = {0, 0, 0, 1, 0, 101, 0, 0, 1};
+ info.DateUTC.Set((_time64(NULL) - _mktime64(&_2001)) * 1000000000);
+ info.Write(pStream);
+
+ // Tracks
+
+ sh.Attach(DNew SeekHead());
+ sh->ID.Set(0x1654AE6B);
+ sh->Position.Set(GetStreamPosition(pStream) - segpos);
+ seek.SeekHeads.AddTail(sh);
+
+ UINT64 TrackNumber = 0;
+ /*
+ CNode<Track> Tracks;
+ CAutoPtr<Track> pT(DNew Track());
+ POSITION pos = m_pInputs.GetHeadPosition();
+ for (int i = 1; pos; i++)
+ {
+ CMatroskaMuxerInputPin* pPin = m_pInputs.GetNext(pos);
+ if (!pPin->IsConnected()) continue;
+
+ CAutoPtr<TrackEntry> pTE(DNew TrackEntry());
+ *pTE = *pPin->GetTrackEntry();
+ if (TrackNumber == 0 && pTE->TrackType == TrackEntry::TypeVideo)
+ TrackNumber = pTE->TrackNumber;
+ pT->TrackEntries.AddTail(pTE);
+ }
+ Tracks.AddTail(pT);
+ Tracks.Write(pStream);
+
+ if (TrackNumber == 0) TrackNumber = 1;
+ */
+ bool fTracksWritten = false;
+
+ //
+
+ Cluster c;
+ c.TimeCode.Set(0);
+
+ bool fFirstBlock = true;
+ INT64 firstTimeCode = 0;
+
+ CAtlList<CMatroskaMuxerInputPin*> pActivePins;
+
+ POSITION pos = m_pInputs.GetHeadPosition();
+ while (pos) {
+ CMatroskaMuxerInputPin* pPin = m_pInputs.GetNext(pos);
+ if (pPin->IsConnected()) {
+ pActivePins.AddTail(pPin);
+ }
+ }
+
+ for (;;) {
+ DWORD cmd = GetRequest();
+
+ switch (cmd) {
+ default:
+ case CMD_EXIT:
+ CAMThread::m_hThread = NULL;
+ Reply(S_OK);
+ return 0;
+
+ case CMD_RUN:
+ Reply(S_OK);
+
+ Cue cue;
+ ULONGLONG lastcueclusterpos = (ULONGLONG) - 1;
+ INT64 lastcuetimecode = (INT64) - 1;
+ UINT64 nBlocksInCueTrack = 0;
+
+ while (!CheckRequest(NULL)) {
+ if (m_State == State_Paused) {
+ Sleep(10);
+ continue;
+ }
+
+ int nPinsGotSomething = 0, nPinsNeeded = 0;
+ CMatroskaMuxerInputPin* pPin = NULL;
+ REFERENCE_TIME rtMin = _I64_MAX;
+
+ pos = pActivePins.GetHeadPosition();
+ while (pos) {
+ CMatroskaMuxerInputPin* pTmp = pActivePins.GetNext(pos);
+
+ CAutoLock cAutoLock(&pTmp->m_csQueue);
+
+ if (pTmp->m_blocks.GetCount() == 0 && pTmp->m_fEndOfStreamReceived) {
+ pActivePins.RemoveAt(pActivePins.Find(pTmp));
+ continue;
+ }
+
+ if (pTmp->GetTrackEntry()->TrackType != TrackEntry::TypeSubtitle) {
+ nPinsNeeded++;
+ }
+
+ if (pTmp->m_blocks.GetCount() > 0) {
+ if (pTmp->GetTrackEntry()->TrackType != TrackEntry::TypeSubtitle) {
+ nPinsGotSomething++;
+ }
+
+ if (pTmp->m_blocks.GetCount() > 0) {
+ REFERENCE_TIME rt = pTmp->m_blocks.GetHead()->Block.TimeCode;
+ if (rt < rtMin) {
+ rtMin = rt;
+ pPin = pTmp;
+ }
+ }
+ }
+ }
+
+ if (pActivePins.GetCount() == 0) {
+ break;
+ }
+
+ if (!pPin || nPinsNeeded > nPinsGotSomething || !pPin && nPinsGotSomething == 0) {
+ Sleep(1);
+ continue;
+ }
+
+ if (!fTracksWritten) {
+ CNode<Track> Tracks;
+ CAutoPtr<Track> pT(DNew Track());
+ POSITION pos = pActivePins.GetHeadPosition();
+ for (int i = 1; pos; i++) {
+ CMatroskaMuxerInputPin* pPin = pActivePins.GetNext(pos);
+
+ CAutoPtr<TrackEntry> pTE(DNew TrackEntry());
+ *pTE = *pPin->GetTrackEntry();
+ if (TrackNumber == 0 && pTE->TrackType == TrackEntry::TypeVideo) {
+ TrackNumber = pTE->TrackNumber;
+ }
+ pT->TrackEntries.AddTail(pTE);
+ }
+ Tracks.AddTail(pT);
+ Tracks.Write(pStream);
+
+ if (TrackNumber == 0) {
+ TrackNumber = 1;
+ }
+
+ fTracksWritten = true;
+ }
+
+ ASSERT(pPin);
+
+ CAutoPtr<BlockGroup> b;
+
+ {
+ CAutoLock cAutoLock(&pPin->m_csQueue);
+ b = pPin->m_blocks.RemoveHead();
+ }
+
+ if (b) {
+ if (fFirstBlock) {
+ if (b->Block.TimeCode < 0 && m_fNegative || b->Block.TimeCode > 0 && m_fPositive) {
+ firstTimeCode = b->Block.TimeCode;
+ }
+ fFirstBlock = false;
+ }
+
+ b->Block.TimeCode -= firstTimeCode;
+ b->Block.TimeCodeStop -= firstTimeCode;
+
+ /*
+ TRACE(_T("Muxing (%d): %I64d-%I64d dur=%I64d (c=%d, co=%dms), cnt=%d, ref=%d\n"),
+ GetTrackNumber(pPin),
+ (INT64)b->Block.TimeCode, (INT64)b->Block.TimeCodeStop, (UINT64)b->BlockDuration,
+ (int)((b->Block.TimeCode)/MAXCLUSTERTIME), (int)(b->Block.TimeCode%MAXCLUSTERTIME),
+ b->Block.BlockData.GetCount(), (int)b->ReferenceBlock);
+ */
+ if (b->Block.TimeCode < SHRT_MIN /*0*/) {
+ ASSERT(0);
+ continue;
+ }
+
+ while ((INT64)(c.TimeCode + MAXCLUSTERTIME) < b->Block.TimeCode) {
+ if (!c.BlockGroups.IsEmpty()) {
+ sh.Attach(DNew SeekHead());
+ sh->ID.Set(c.GetID()/*0x1F43B675*/);
+ sh->Position.Set(GetStreamPosition(pStream) - segpos);
+ seek.SeekHeads.AddTail(sh);
+
+ c.Write(pStream); // TODO: write blocks
+ }
+
+ c.TimeCode.Set(c.TimeCode + MAXCLUSTERTIME);
+ c.BlockGroups.RemoveAll();
+ nBlocksInCueTrack = 0;
+ }
+
+ if (b->Block.TrackNumber == TrackNumber) {
+ nBlocksInCueTrack++;
+ }
+
+ if (b->ReferenceBlock == 0 && b->Block.TrackNumber == TrackNumber) {
+ ULONGLONG clusterpos = GetStreamPosition(pStream) - segpos;
+ if (lastcueclusterpos != clusterpos || lastcuetimecode + 1000 < b->Block.TimeCode) {
+ CAutoPtr<CueTrackPosition> ctp(DNew CueTrackPosition());
+ ctp->CueTrack.Set(b->Block.TrackNumber);
+ ctp->CueClusterPosition.Set(clusterpos);
+ if (c.BlockGroups.GetCount() > 0) {
+ ctp->CueBlockNumber.Set(nBlocksInCueTrack);
+ }
+ CAutoPtr<CuePoint> cp(DNew CuePoint());
+ cp->CueTime.Set(b->Block.TimeCode);
+ cp->CueTrackPositions.AddTail(ctp);
+ cue.CuePoints.AddTail(cp);
+ lastcueclusterpos = clusterpos;
+ lastcuetimecode = b->Block.TimeCode;
+ }
+ }
+
+ info.Duration.Set(max(info.Duration, (float)b->Block.TimeCodeStop));
+
+ m_rtCurrent = b->Block.TimeCode * 10000;
+
+ b->Block.TimeCode -= c.TimeCode;
+ c.BlockGroups.AddTail(b);
+ }
+ }
+
+ if (!c.BlockGroups.IsEmpty()) {
+ sh.Attach(DNew SeekHead());
+ sh->ID.Set(c.GetID()/*0x1F43B675*/);
+ sh->Position.Set(GetStreamPosition(pStream) - segpos);
+ seek.SeekHeads.AddTail(sh);
+
+ c.Write(pStream);
+ }
+
+ if (!cue.CuePoints.IsEmpty()) {
+ sh.Attach(DNew SeekHead());
+ sh->ID.Set(cue.GetID()/*0x1C53BB6B*/);
+ sh->Position.Set(GetStreamPosition(pStream) - segpos);
+ seek.SeekHeads.AddTail(sh);
+
+ cue.Write(pStream);
+ }
+
+ {
+ Tags tags;
+
+ sh.Attach(DNew SeekHead());
+ sh->ID.Set(tags.GetID());
+ sh->Position.Set(GetStreamPosition(pStream) - segpos);
+ seek.SeekHeads.AddTail(sh);
+
+ tags.Write(pStream);
+ }
+
+ SetStreamPosition(pStream, voidpos);
+ int len = (int)(voidlen - seek.Size());
+ ASSERT(len >= 0 && len != 1);
+ seek.Write(pStream);
+
+ if (len == 0) {
+ // nothing to do
+ } else if (len >= 2) {
+ for (int i = 0; i < 8; i++) {
+ if (len >= (1 << i * 7) - 2 && len <= (1 << (i + 1) * 7) - 2) {
+ Void(len - 2 - i).Write(pStream);
+ break;
+ }
+ }
+ }
+
+ if (abs(m_rtCurrent - (REFERENCE_TIME)info.Duration * 10000) > 10000000i64) {
+ info.Duration.Set(m_rtCurrent / 10000 + 1);
+ }
+
+ SetStreamPosition(pStream, infopos);
+ info.Write(pStream);
+
+ // TODO: write some tags
+
+ m_pOutput->DeliverEndOfStream();
+
+ break;
+ }
+ }
+
+ ASSERT(0); // we should only exit via CMD_EXIT
+
+ CAMThread::m_hThread = NULL;
+ return 0;
}
//
@@ -710,10 +710,10 @@ DWORD CMatroskaMuxerFilter::ThreadProc()
//
CMatroskaMuxerInputPin::CMatroskaMuxerInputPin(LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseInputPin(NAME("CMatroskaMuxerInputPin"), pFilter, pLock, phr, pName)
- , m_fActive(false)
- , m_fEndOfStreamReceived(false)
- , m_rtDur(0)
+ : CBaseInputPin(NAME("CMatroskaMuxerInputPin"), pFilter, pLock, phr, pName)
+ , m_fActive(false)
+ , m_fEndOfStreamReceived(false)
+ , m_rtDur(0)
{
}
@@ -723,614 +723,614 @@ CMatroskaMuxerInputPin::~CMatroskaMuxerInputPin()
STDMETHODIMP CMatroskaMuxerInputPin::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CMatroskaMuxerInputPin::CheckMediaType(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Video && (pmt->formattype == FORMAT_VideoInfo
- || pmt->formattype == FORMAT_VideoInfo2)
- // || pmt->majortype == MEDIATYPE_Video && pmt->subtype == MEDIASUBTYPE_MPEG1Payload && pmt->formattype == FORMAT_MPEGVideo
- // || pmt->majortype == MEDIATYPE_Video && pmt->subtype == MEDIASUBTYPE_MPEG2_VIDEO && pmt->formattype == FORMAT_MPEG2_VIDEO
- || pmt->majortype == MEDIATYPE_Video && pmt->subtype == MEDIASUBTYPE_DiracVideo && pmt->formattype == FORMAT_DiracVideoInfo
- || pmt->majortype == MEDIATYPE_Audio && pmt->formattype == FORMAT_WaveFormatEx && pmt->subtype == FOURCCMap(((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag)
- || pmt->majortype == MEDIATYPE_Audio && pmt->subtype == MEDIASUBTYPE_Vorbis && pmt->formattype == FORMAT_VorbisFormat
- || pmt->majortype == MEDIATYPE_Audio && pmt->subtype == MEDIASUBTYPE_Vorbis2 && pmt->formattype == FORMAT_VorbisFormat2
- || pmt->majortype == MEDIATYPE_Audio && (pmt->subtype == MEDIASUBTYPE_14_4
- || pmt->subtype == MEDIASUBTYPE_28_8
- || pmt->subtype == MEDIASUBTYPE_ATRC
- || pmt->subtype == MEDIASUBTYPE_COOK
- || pmt->subtype == MEDIASUBTYPE_DNET
- || pmt->subtype == MEDIASUBTYPE_SIPR) && pmt->formattype == FORMAT_WaveFormatEx
- || pmt->majortype == MEDIATYPE_Text && pmt->subtype == MEDIASUBTYPE_NULL && pmt->formattype == FORMAT_None
- || pmt->majortype == MEDIATYPE_Subtitle && pmt->formattype == FORMAT_SubtitleInfo
- ? S_OK
- : E_INVALIDARG;
+ return pmt->majortype == MEDIATYPE_Video && (pmt->formattype == FORMAT_VideoInfo
+ || pmt->formattype == FORMAT_VideoInfo2)
+ // || pmt->majortype == MEDIATYPE_Video && pmt->subtype == MEDIASUBTYPE_MPEG1Payload && pmt->formattype == FORMAT_MPEGVideo
+ // || pmt->majortype == MEDIATYPE_Video && pmt->subtype == MEDIASUBTYPE_MPEG2_VIDEO && pmt->formattype == FORMAT_MPEG2_VIDEO
+ || pmt->majortype == MEDIATYPE_Video && pmt->subtype == MEDIASUBTYPE_DiracVideo && pmt->formattype == FORMAT_DiracVideoInfo
+ || pmt->majortype == MEDIATYPE_Audio && pmt->formattype == FORMAT_WaveFormatEx && pmt->subtype == FOURCCMap(((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag)
+ || pmt->majortype == MEDIATYPE_Audio && pmt->subtype == MEDIASUBTYPE_Vorbis && pmt->formattype == FORMAT_VorbisFormat
+ || pmt->majortype == MEDIATYPE_Audio && pmt->subtype == MEDIASUBTYPE_Vorbis2 && pmt->formattype == FORMAT_VorbisFormat2
+ || pmt->majortype == MEDIATYPE_Audio && (pmt->subtype == MEDIASUBTYPE_14_4
+ || pmt->subtype == MEDIASUBTYPE_28_8
+ || pmt->subtype == MEDIASUBTYPE_ATRC
+ || pmt->subtype == MEDIASUBTYPE_COOK
+ || pmt->subtype == MEDIASUBTYPE_DNET
+ || pmt->subtype == MEDIASUBTYPE_SIPR) && pmt->formattype == FORMAT_WaveFormatEx
+ || pmt->majortype == MEDIATYPE_Text && pmt->subtype == MEDIASUBTYPE_NULL && pmt->formattype == FORMAT_None
+ || pmt->majortype == MEDIATYPE_Subtitle && pmt->formattype == FORMAT_SubtitleInfo
+ ? S_OK
+ : E_INVALIDARG;
}
HRESULT CMatroskaMuxerInputPin::BreakConnect()
{
- HRESULT hr;
+ HRESULT hr;
- if (FAILED(hr = __super::BreakConnect())) {
- return hr;
- }
+ if (FAILED(hr = __super::BreakConnect())) {
+ return hr;
+ }
- m_pTE.Free();
+ m_pTE.Free();
- return hr;
+ return hr;
}
HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin)
{
- HRESULT hr;
-
- if (FAILED(hr = __super::CompleteConnect(pPin))) {
- return hr;
- }
-
- m_rtDur = 0;
- CComQIPtr<IMediaSeeking> pMS;
- if ((pMS = GetFilterFromPin(pPin)) || (pMS = pPin)) {
- pMS->GetDuration(&m_rtDur);
- }
-
- m_pTE.Free();
- m_pTE.Attach(DNew TrackEntry());
-
- m_pTE->TrackUID.Set(rand());
- m_pTE->MinCache.Set(1);
- m_pTE->MaxCache.Set(1);
- m_pTE->TrackNumber.Set((static_cast<CMatroskaMuxerFilter*>(m_pFilter))->GetTrackNumber(this));
-
- hr = E_FAIL;
-
- if (m_mt.majortype == MEDIATYPE_Video) {
- m_pTE->TrackType.Set(TrackEntry::TypeVideo);
-
- if (m_mt.formattype == FORMAT_VideoInfo
- && m_mt.subtype == MEDIASUBTYPE_RV10 || m_mt.subtype == MEDIASUBTYPE_RV20
- || m_mt.subtype == MEDIASUBTYPE_RV30 || m_mt.subtype == MEDIASUBTYPE_RV40) {
- m_pTE->CodecID.Set("V_REAL/RV00");
- m_pTE->CodecID.SetAt(9, (BYTE)(m_mt.subtype.Data1>>16));
-
- if (m_mt.formattype == FORMAT_VideoInfo) {
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)m_mt.pbFormat;
- if (m_mt.cbFormat > sizeof(VIDEOINFOHEADER)) {
- m_pTE->CodecPrivate.SetCount(m_mt.cbFormat - sizeof(VIDEOINFOHEADER));
- memcpy(m_pTE->CodecPrivate, m_mt.pbFormat + sizeof(VIDEOINFOHEADER), m_pTE->CodecPrivate.GetCount());
- }
- m_pTE->DefaultDuration.Set(vih->AvgTimePerFrame*100);
- m_pTE->DescType = TrackEntry::DescVideo;
- m_pTE->v.PixelWidth.Set(vih->bmiHeader.biWidth);
- m_pTE->v.PixelHeight.Set(abs(vih->bmiHeader.biHeight));
- if (vih->AvgTimePerFrame > 0) {
- m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->AvgTimePerFrame));
- }
- } else if (m_mt.formattype == FORMAT_VideoInfo2) {
- VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)m_mt.pbFormat;
- if (m_mt.cbFormat > sizeof(VIDEOINFOHEADER2)) {
- m_pTE->CodecPrivate.SetCount(m_mt.cbFormat - sizeof(VIDEOINFOHEADER2));
- memcpy(m_pTE->CodecPrivate, m_mt.pbFormat + sizeof(VIDEOINFOHEADER2), m_pTE->CodecPrivate.GetCount());
- }
- m_pTE->DefaultDuration.Set(vih->AvgTimePerFrame*100);
- m_pTE->DescType = TrackEntry::DescVideo;
- m_pTE->v.PixelWidth.Set(vih->bmiHeader.biWidth);
- m_pTE->v.PixelHeight.Set(abs(vih->bmiHeader.biHeight));
- if (vih->AvgTimePerFrame > 0) {
- m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->AvgTimePerFrame));
- }
- m_pTE->v.DisplayWidth.Set(vih->dwPictAspectRatioX);
- m_pTE->v.DisplayHeight.Set(vih->dwPictAspectRatioY);
- } else {
- ASSERT(0);
- return hr;
- }
-
- hr = S_OK;
- } else if (m_mt.formattype == FORMAT_VideoInfo) {
- m_pTE->CodecID.Set("V_MS/VFW/FOURCC");
-
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)m_mt.pbFormat;
- m_pTE->CodecPrivate.SetCount(m_mt.cbFormat - FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader));
- memcpy(m_pTE->CodecPrivate, &vih->bmiHeader, m_pTE->CodecPrivate.GetCount());
- m_pTE->DefaultDuration.Set(vih->AvgTimePerFrame*100);
- m_pTE->DescType = TrackEntry::DescVideo;
- m_pTE->v.PixelWidth.Set(vih->bmiHeader.biWidth);
- m_pTE->v.PixelHeight.Set(abs(vih->bmiHeader.biHeight));
- if (vih->AvgTimePerFrame > 0) {
- m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->AvgTimePerFrame));
- }
-
- hr = S_OK;
- } else if (m_mt.formattype == FORMAT_VideoInfo2) {
- m_pTE->CodecID.Set("V_MS/VFW/FOURCC");
-
- VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)m_mt.pbFormat;
- m_pTE->CodecPrivate.SetCount(m_mt.cbFormat - FIELD_OFFSET(VIDEOINFOHEADER2, bmiHeader));
- memcpy(m_pTE->CodecPrivate, &vih->bmiHeader, m_pTE->CodecPrivate.GetCount());
- m_pTE->DefaultDuration.Set(vih->AvgTimePerFrame*100);
- m_pTE->DescType = TrackEntry::DescVideo;
- m_pTE->v.PixelWidth.Set(vih->bmiHeader.biWidth);
- m_pTE->v.PixelHeight.Set(abs(vih->bmiHeader.biHeight));
- m_pTE->v.DisplayWidth.Set(vih->dwPictAspectRatioX);
- m_pTE->v.DisplayHeight.Set(vih->dwPictAspectRatioY);
- if (vih->AvgTimePerFrame > 0) {
- m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->AvgTimePerFrame));
- }
-
- hr = S_OK;
- } else if (m_mt.formattype == FORMAT_DiracVideoInfo) {
- m_pTE->CodecID.Set("V_DIRAC");
-
- DIRACINFOHEADER* vih = (DIRACINFOHEADER*)m_mt.pbFormat;
- m_pTE->CodecPrivate.SetCount(vih->cbSequenceHeader);
- memcpy(m_pTE->CodecPrivate, (BYTE*)&vih->dwSequenceHeader[0], m_pTE->CodecPrivate.GetCount());
- m_pTE->DefaultDuration.Set(vih->hdr.AvgTimePerFrame*100);
- m_pTE->DescType = TrackEntry::DescVideo;
- m_pTE->v.PixelWidth.Set(vih->hdr.bmiHeader.biWidth);
- m_pTE->v.PixelHeight.Set(abs(vih->hdr.bmiHeader.biHeight));
- // m_pTE->v.DisplayWidth.Set(vih->dwPictAspectRatioX);
- // m_pTE->v.DisplayHeight.Set(vih->dwPictAspectRatioY);
- if (vih->hdr.AvgTimePerFrame > 0) {
- m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->hdr.AvgTimePerFrame));
- }
-
- hr = S_OK;
- }
- /*
- else if (m_mt.formattype == FORMAT_MPEGVideo)
- {
- m_pTE->CodecID.Set("V_DSHOW/MPEG1VIDEO"); // V_MPEG1
-
- MPEG1VIDEOINFO* pm1vi = (MPEG1VIDEOINFO*)m_mt.pbFormat;
- m_pTE->CodecPrivate.SetCount(m_mt.FormatLength());
- memcpy(m_pTE->CodecPrivate, m_mt.pbFormat, m_pTE->CodecPrivate.GetCount());
- m_pTE->DefaultDuration.Set(pm1vi->hdr.AvgTimePerFrame*100);
- m_pTE->DescType = TrackEntry::DescVideo;
- m_pTE->v.PixelWidth.Set(pm1vi->hdr.bmiHeader.biWidth);
- m_pTE->v.PixelHeight.Set(abs(pm1vi->hdr.bmiHeader.biHeight));
- if (pm1vi->hdr.AvgTimePerFrame > 0)
- m_pTE->v.FramePerSec.Set((float)(10000000.0 / pm1vi->hdr.AvgTimePerFrame));
-
- hr = S_OK;
- }
- else if (m_mt.formattype == FORMAT_MPEG2_VIDEO)
- {
- m_pTE->CodecID.Set("V_DSHOW/MPEG2VIDEO"); // V_MPEG2
-
- MPEG2VIDEOINFO* pm2vi = (MPEG2VIDEOINFO*)m_mt.pbFormat;
- m_pTE->CodecPrivate.SetCount(m_mt.FormatLength());
- memcpy(m_pTE->CodecPrivate, m_mt.pbFormat, m_pTE->CodecPrivate.GetCount());
- m_pTE->DefaultDuration.Set(pm2vi->hdr.AvgTimePerFrame*100);
- m_pTE->DescType = TrackEntry::DescVideo;
- m_pTE->v.PixelWidth.Set(pm2vi->hdr.bmiHeader.biWidth);
- m_pTE->v.PixelHeight.Set(abs(pm2vi->hdr.bmiHeader.biHeight));
- if (pm2vi->hdr.AvgTimePerFrame > 0)
- m_pTE->v.FramePerSec.Set((float)(10000000.0 / pm2vi->hdr.AvgTimePerFrame));
-
- hr = S_OK;
- }
- */
- } else if (m_mt.majortype == MEDIATYPE_Audio) {
- m_pTE->TrackType.Set(TrackEntry::TypeAudio);
-
- if (m_mt.formattype == FORMAT_WaveFormatEx
- && ((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_AAC
- && m_mt.cbFormat >= sizeof(WAVEFORMATEX)+2) {
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.pbFormat;
- BYTE* p = (BYTE*)(wfe+1);
-
- DWORD nSamplesPerSec = wfe->nSamplesPerSec;
-
- int profile = (p[0]>>3)-1;
- int rate1 = ((p[0]&7)<<1)|(p[1]>>7);
- int channels = ((p[1]>>3)&15);
- int exttype = 0;
- int rate2 = rate1;
-
- if (wfe->cbSize >= 5) {
- profile = 4;
-
- exttype = (p[2]<<3)|(p[3]>>5);
- ASSERT(exttype == 0x2B7);
- ASSERT((p[3]&31) == 5);
- ASSERT((p[4]>>7) == 1);
- rate2 = ((p[4]>>3)&15);
-
- if (rate2 < rate1) {
- m_pTE->a.OutputSamplingFrequency.Set((float)nSamplesPerSec);
- nSamplesPerSec /= 2;
- }
- }
-
- switch (profile) {
- default:
- case 0:
- m_pTE->CodecID.Set("A_AAC/MPEG2/MAIN");
- break;
- case 1:
- m_pTE->CodecID.Set("A_AAC/MPEG2/LC");
- break;
- case 2:
- m_pTE->CodecID.Set("A_AAC/MPEG2/SSR");
- break;
- case 3:
- m_pTE->CodecID.Set("A_AAC/MPEG4/LTP");
- break;
- case 4:
- m_pTE->CodecID.Set("A_AAC/MPEG4/LC/SBR");
- break;
- }
-
- ASSERT(channels == wfe->nChannels);
-
- m_pTE->DescType = TrackEntry::DescAudio;
- m_pTE->a.SamplingFrequency.Set((float)nSamplesPerSec);
- m_pTE->a.Channels.Set(channels);
- m_pTE->a.BitDepth.Set(wfe->wBitsPerSample);
-
- hr = S_OK;
- } else if (m_mt.formattype == FORMAT_WaveFormatEx
- && ((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_DOLBY_AC3) {
- m_pTE->CodecID.Set("A_AC3");
-
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.pbFormat;
- m_pTE->DescType = TrackEntry::DescAudio;
- m_pTE->a.SamplingFrequency.Set((float)wfe->nSamplesPerSec);
- m_pTE->a.Channels.Set(wfe->nChannels);
- m_pTE->a.BitDepth.Set(wfe->wBitsPerSample);
-
- hr = S_OK;
- } else if (m_mt.formattype == FORMAT_WaveFormatEx
- && ((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_DVD_DTS) {
- m_pTE->CodecID.Set("A_DTS");
-
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.pbFormat;
- m_pTE->DescType = TrackEntry::DescAudio;
- m_pTE->a.SamplingFrequency.Set((float)wfe->nSamplesPerSec);
- m_pTE->a.Channels.Set(wfe->nChannels);
- m_pTE->a.BitDepth.Set(wfe->wBitsPerSample);
-
- hr = S_OK;
- } else if (m_mt.formattype == FORMAT_WaveFormatEx
- && ((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_FLAC) {
- m_pTE->CodecID.Set("A_FLAC");
-
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.pbFormat;
- m_pTE->DescType = TrackEntry::DescAudio;
- m_pTE->a.SamplingFrequency.Set((float)wfe->nSamplesPerSec);
- m_pTE->a.Channels.Set(wfe->nChannels);
- m_pTE->a.BitDepth.Set(wfe->wBitsPerSample);
-
- if (wfe->cbSize) {
- m_pTE->CodecPrivate.SetCount(wfe->cbSize);
- memcpy(m_pTE->CodecPrivate, m_mt.pbFormat + sizeof(WAVEFORMATEX), wfe->cbSize);
- }
-
- hr = S_OK;
- } else if (m_mt.formattype == FORMAT_WaveFormatEx
- && (m_mt.subtype == MEDIASUBTYPE_14_4
- || m_mt.subtype == MEDIASUBTYPE_28_8
- || m_mt.subtype == MEDIASUBTYPE_ATRC
- || m_mt.subtype == MEDIASUBTYPE_COOK
- || m_mt.subtype == MEDIASUBTYPE_DNET
- || m_mt.subtype == MEDIASUBTYPE_SIPR)) {
- CStringA id;
- id.Format("A_REAL/%c%c%c%c",
- (char)((m_mt.subtype.Data1>>0)&0xff),
- (char)((m_mt.subtype.Data1>>8)&0xff),
- (char)((m_mt.subtype.Data1>>16)&0xff),
- (char)((m_mt.subtype.Data1>>24)&0xff));
-
- m_pTE->CodecID.Set(id);
-
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.pbFormat;
- DWORD cbSize = sizeof(WAVEFORMATEX) + wfe->cbSize;
- if (m_mt.cbFormat > cbSize) {
- m_pTE->CodecPrivate.SetCount(m_mt.cbFormat - cbSize);
- memcpy(m_pTE->CodecPrivate, m_mt.pbFormat + cbSize, m_pTE->CodecPrivate.GetCount());
- }
- m_pTE->DescType = TrackEntry::DescAudio;
- m_pTE->a.SamplingFrequency.Set((float)wfe->nSamplesPerSec);
- m_pTE->a.Channels.Set(wfe->nChannels);
- m_pTE->a.BitDepth.Set(wfe->wBitsPerSample);
-
- hr = S_OK;
- } else if (m_mt.formattype == FORMAT_WaveFormatEx
- && ((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_PCM) {
- m_pTE->CodecID.Set("A_PCM/INT/LIT");
-
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.pbFormat;
- m_pTE->DescType = TrackEntry::DescAudio;
- m_pTE->a.SamplingFrequency.Set((float)wfe->nSamplesPerSec);
- m_pTE->a.Channels.Set(wfe->nChannels);
- m_pTE->a.BitDepth.Set(wfe->wBitsPerSample);
-
- hr = S_OK;
- } else if (m_mt.formattype == FORMAT_WaveFormatEx) {
- m_pTE->CodecID.Set("A_MS/ACM");
-
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.pbFormat;
- m_pTE->CodecPrivate.SetCount(m_mt.cbFormat);
- memcpy(m_pTE->CodecPrivate, wfe, m_pTE->CodecPrivate.GetCount());
- m_pTE->DescType = TrackEntry::DescAudio;
- m_pTE->a.SamplingFrequency.Set((float)wfe->nSamplesPerSec);
- m_pTE->a.Channels.Set(wfe->nChannels);
- m_pTE->a.BitDepth.Set(wfe->wBitsPerSample);
-
- hr = S_OK;
- } else if (m_mt.formattype == FORMAT_VorbisFormat) {
- m_pTE->CodecID.Set("A_VORBIS");
-
- VORBISFORMAT* pvf = (VORBISFORMAT*)m_mt.pbFormat;
- m_pTE->DescType = TrackEntry::DescAudio;
- m_pTE->a.SamplingFrequency.Set((float)pvf->nSamplesPerSec);
- m_pTE->a.Channels.Set(pvf->nChannels);
-
- // m_pTE->CodecPrivate will be filled later
-
- hr = S_OK;
- } else if (m_mt.formattype == FORMAT_VorbisFormat2) {
- m_pTE->CodecID.Set("A_VORBIS");
-
- VORBISFORMAT2* pvf2 = (VORBISFORMAT2*)m_mt.pbFormat;
- m_pTE->DescType = TrackEntry::DescAudio;
- m_pTE->a.SamplingFrequency.Set((float)pvf2->SamplesPerSec);
- m_pTE->a.Channels.Set(pvf2->Channels);
- m_pTE->a.BitDepth.Set(pvf2->BitsPerSample);
-
- int len = 1;
- for (int i = 0; i < 2; i++) {
- len += pvf2->HeaderSize[i]/255 + 1;
- }
- for (int i = 0; i < 3; i++) {
- len += pvf2->HeaderSize[i];
- }
- m_pTE->CodecPrivate.SetCount(len);
-
- BYTE* src = (BYTE*)m_mt.pbFormat + sizeof(VORBISFORMAT2);
- BYTE* dst = m_pTE->CodecPrivate.GetData();
-
- *dst++ = 2;
- for (int i = 0; i < 2; i++)
- for (int len = pvf2->HeaderSize[i]; len >= 0; len -= 255) {
- *dst++ = min(len, 255);
- }
-
- memcpy(dst, src, pvf2->HeaderSize[0]);
- dst += pvf2->HeaderSize[0];
- src += pvf2->HeaderSize[0];
- memcpy(dst, src, pvf2->HeaderSize[1]);
- dst += pvf2->HeaderSize[1];
- src += pvf2->HeaderSize[1];
- memcpy(dst, src, pvf2->HeaderSize[2]);
- dst += pvf2->HeaderSize[2];
- src += pvf2->HeaderSize[2];
-
- ASSERT(src <= m_mt.pbFormat + m_mt.cbFormat);
- ASSERT(dst <= m_pTE->CodecPrivate.GetData() + m_pTE->CodecPrivate.GetCount());
-
- hr = S_OK;
- }
- } else if (m_mt.majortype == MEDIATYPE_Text) {
- m_pTE->TrackType.Set(TrackEntry::TypeSubtitle);
-
- if (m_mt.formattype == FORMAT_None) {
- m_pTE->CodecID.Set("S_TEXT/ASCII");
- hr = S_OK;
- }
- } else if (m_mt.majortype == MEDIATYPE_Subtitle) {
- m_pTE->TrackType.Set(TrackEntry::TypeSubtitle);
-
- m_pTE->CodecID.Set(
- m_mt.subtype == MEDIASUBTYPE_UTF8 ? "S_TEXT/UTF8" :
- m_mt.subtype == MEDIASUBTYPE_SSA ? "S_TEXT/SSA" :
- m_mt.subtype == MEDIASUBTYPE_ASS ? "S_TEXT/ASS" :
- m_mt.subtype == MEDIASUBTYPE_USF ? "S_TEXT/USF" :
- m_mt.subtype == MEDIASUBTYPE_VOBSUB ? "S_VOBSUB" :
- "");
-
- if (!m_pTE->CodecID.IsEmpty()) {
- hr = S_OK;
-
- SUBTITLEINFO* psi = (SUBTITLEINFO*)m_mt.pbFormat;
- if (psi->dwOffset) {
- m_pTE->CodecPrivate.SetCount(m_mt.cbFormat - psi->dwOffset);
- memcpy(m_pTE->CodecPrivate, m_mt.pbFormat + psi->dwOffset, m_pTE->CodecPrivate.GetCount());
- }
- }
- }
-
- if (S_OK == hr) {
- (static_cast<CMatroskaMuxerFilter*>(m_pFilter))->AddInput();
- }
-
- return hr;
+ HRESULT hr;
+
+ if (FAILED(hr = __super::CompleteConnect(pPin))) {
+ return hr;
+ }
+
+ m_rtDur = 0;
+ CComQIPtr<IMediaSeeking> pMS;
+ if ((pMS = GetFilterFromPin(pPin)) || (pMS = pPin)) {
+ pMS->GetDuration(&m_rtDur);
+ }
+
+ m_pTE.Free();
+ m_pTE.Attach(DNew TrackEntry());
+
+ m_pTE->TrackUID.Set(rand());
+ m_pTE->MinCache.Set(1);
+ m_pTE->MaxCache.Set(1);
+ m_pTE->TrackNumber.Set((static_cast<CMatroskaMuxerFilter*>(m_pFilter))->GetTrackNumber(this));
+
+ hr = E_FAIL;
+
+ if (m_mt.majortype == MEDIATYPE_Video) {
+ m_pTE->TrackType.Set(TrackEntry::TypeVideo);
+
+ if (m_mt.formattype == FORMAT_VideoInfo
+ && m_mt.subtype == MEDIASUBTYPE_RV10 || m_mt.subtype == MEDIASUBTYPE_RV20
+ || m_mt.subtype == MEDIASUBTYPE_RV30 || m_mt.subtype == MEDIASUBTYPE_RV40) {
+ m_pTE->CodecID.Set("V_REAL/RV00");
+ m_pTE->CodecID.SetAt(9, (BYTE)(m_mt.subtype.Data1 >> 16));
+
+ if (m_mt.formattype == FORMAT_VideoInfo) {
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)m_mt.pbFormat;
+ if (m_mt.cbFormat > sizeof(VIDEOINFOHEADER)) {
+ m_pTE->CodecPrivate.SetCount(m_mt.cbFormat - sizeof(VIDEOINFOHEADER));
+ memcpy(m_pTE->CodecPrivate, m_mt.pbFormat + sizeof(VIDEOINFOHEADER), m_pTE->CodecPrivate.GetCount());
+ }
+ m_pTE->DefaultDuration.Set(vih->AvgTimePerFrame * 100);
+ m_pTE->DescType = TrackEntry::DescVideo;
+ m_pTE->v.PixelWidth.Set(vih->bmiHeader.biWidth);
+ m_pTE->v.PixelHeight.Set(abs(vih->bmiHeader.biHeight));
+ if (vih->AvgTimePerFrame > 0) {
+ m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->AvgTimePerFrame));
+ }
+ } else if (m_mt.formattype == FORMAT_VideoInfo2) {
+ VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)m_mt.pbFormat;
+ if (m_mt.cbFormat > sizeof(VIDEOINFOHEADER2)) {
+ m_pTE->CodecPrivate.SetCount(m_mt.cbFormat - sizeof(VIDEOINFOHEADER2));
+ memcpy(m_pTE->CodecPrivate, m_mt.pbFormat + sizeof(VIDEOINFOHEADER2), m_pTE->CodecPrivate.GetCount());
+ }
+ m_pTE->DefaultDuration.Set(vih->AvgTimePerFrame * 100);
+ m_pTE->DescType = TrackEntry::DescVideo;
+ m_pTE->v.PixelWidth.Set(vih->bmiHeader.biWidth);
+ m_pTE->v.PixelHeight.Set(abs(vih->bmiHeader.biHeight));
+ if (vih->AvgTimePerFrame > 0) {
+ m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->AvgTimePerFrame));
+ }
+ m_pTE->v.DisplayWidth.Set(vih->dwPictAspectRatioX);
+ m_pTE->v.DisplayHeight.Set(vih->dwPictAspectRatioY);
+ } else {
+ ASSERT(0);
+ return hr;
+ }
+
+ hr = S_OK;
+ } else if (m_mt.formattype == FORMAT_VideoInfo) {
+ m_pTE->CodecID.Set("V_MS/VFW/FOURCC");
+
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)m_mt.pbFormat;
+ m_pTE->CodecPrivate.SetCount(m_mt.cbFormat - FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader));
+ memcpy(m_pTE->CodecPrivate, &vih->bmiHeader, m_pTE->CodecPrivate.GetCount());
+ m_pTE->DefaultDuration.Set(vih->AvgTimePerFrame * 100);
+ m_pTE->DescType = TrackEntry::DescVideo;
+ m_pTE->v.PixelWidth.Set(vih->bmiHeader.biWidth);
+ m_pTE->v.PixelHeight.Set(abs(vih->bmiHeader.biHeight));
+ if (vih->AvgTimePerFrame > 0) {
+ m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->AvgTimePerFrame));
+ }
+
+ hr = S_OK;
+ } else if (m_mt.formattype == FORMAT_VideoInfo2) {
+ m_pTE->CodecID.Set("V_MS/VFW/FOURCC");
+
+ VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)m_mt.pbFormat;
+ m_pTE->CodecPrivate.SetCount(m_mt.cbFormat - FIELD_OFFSET(VIDEOINFOHEADER2, bmiHeader));
+ memcpy(m_pTE->CodecPrivate, &vih->bmiHeader, m_pTE->CodecPrivate.GetCount());
+ m_pTE->DefaultDuration.Set(vih->AvgTimePerFrame * 100);
+ m_pTE->DescType = TrackEntry::DescVideo;
+ m_pTE->v.PixelWidth.Set(vih->bmiHeader.biWidth);
+ m_pTE->v.PixelHeight.Set(abs(vih->bmiHeader.biHeight));
+ m_pTE->v.DisplayWidth.Set(vih->dwPictAspectRatioX);
+ m_pTE->v.DisplayHeight.Set(vih->dwPictAspectRatioY);
+ if (vih->AvgTimePerFrame > 0) {
+ m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->AvgTimePerFrame));
+ }
+
+ hr = S_OK;
+ } else if (m_mt.formattype == FORMAT_DiracVideoInfo) {
+ m_pTE->CodecID.Set("V_DIRAC");
+
+ DIRACINFOHEADER* vih = (DIRACINFOHEADER*)m_mt.pbFormat;
+ m_pTE->CodecPrivate.SetCount(vih->cbSequenceHeader);
+ memcpy(m_pTE->CodecPrivate, (BYTE*)&vih->dwSequenceHeader[0], m_pTE->CodecPrivate.GetCount());
+ m_pTE->DefaultDuration.Set(vih->hdr.AvgTimePerFrame * 100);
+ m_pTE->DescType = TrackEntry::DescVideo;
+ m_pTE->v.PixelWidth.Set(vih->hdr.bmiHeader.biWidth);
+ m_pTE->v.PixelHeight.Set(abs(vih->hdr.bmiHeader.biHeight));
+ // m_pTE->v.DisplayWidth.Set(vih->dwPictAspectRatioX);
+ // m_pTE->v.DisplayHeight.Set(vih->dwPictAspectRatioY);
+ if (vih->hdr.AvgTimePerFrame > 0) {
+ m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->hdr.AvgTimePerFrame));
+ }
+
+ hr = S_OK;
+ }
+ /*
+ else if (m_mt.formattype == FORMAT_MPEGVideo)
+ {
+ m_pTE->CodecID.Set("V_DSHOW/MPEG1VIDEO"); // V_MPEG1
+
+ MPEG1VIDEOINFO* pm1vi = (MPEG1VIDEOINFO*)m_mt.pbFormat;
+ m_pTE->CodecPrivate.SetCount(m_mt.FormatLength());
+ memcpy(m_pTE->CodecPrivate, m_mt.pbFormat, m_pTE->CodecPrivate.GetCount());
+ m_pTE->DefaultDuration.Set(pm1vi->hdr.AvgTimePerFrame*100);
+ m_pTE->DescType = TrackEntry::DescVideo;
+ m_pTE->v.PixelWidth.Set(pm1vi->hdr.bmiHeader.biWidth);
+ m_pTE->v.PixelHeight.Set(abs(pm1vi->hdr.bmiHeader.biHeight));
+ if (pm1vi->hdr.AvgTimePerFrame > 0)
+ m_pTE->v.FramePerSec.Set((float)(10000000.0 / pm1vi->hdr.AvgTimePerFrame));
+
+ hr = S_OK;
+ }
+ else if (m_mt.formattype == FORMAT_MPEG2_VIDEO)
+ {
+ m_pTE->CodecID.Set("V_DSHOW/MPEG2VIDEO"); // V_MPEG2
+
+ MPEG2VIDEOINFO* pm2vi = (MPEG2VIDEOINFO*)m_mt.pbFormat;
+ m_pTE->CodecPrivate.SetCount(m_mt.FormatLength());
+ memcpy(m_pTE->CodecPrivate, m_mt.pbFormat, m_pTE->CodecPrivate.GetCount());
+ m_pTE->DefaultDuration.Set(pm2vi->hdr.AvgTimePerFrame*100);
+ m_pTE->DescType = TrackEntry::DescVideo;
+ m_pTE->v.PixelWidth.Set(pm2vi->hdr.bmiHeader.biWidth);
+ m_pTE->v.PixelHeight.Set(abs(pm2vi->hdr.bmiHeader.biHeight));
+ if (pm2vi->hdr.AvgTimePerFrame > 0)
+ m_pTE->v.FramePerSec.Set((float)(10000000.0 / pm2vi->hdr.AvgTimePerFrame));
+
+ hr = S_OK;
+ }
+ */
+ } else if (m_mt.majortype == MEDIATYPE_Audio) {
+ m_pTE->TrackType.Set(TrackEntry::TypeAudio);
+
+ if (m_mt.formattype == FORMAT_WaveFormatEx
+ && ((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_AAC
+ && m_mt.cbFormat >= sizeof(WAVEFORMATEX) + 2) {
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.pbFormat;
+ BYTE* p = (BYTE*)(wfe + 1);
+
+ DWORD nSamplesPerSec = wfe->nSamplesPerSec;
+
+ int profile = (p[0] >> 3) - 1;
+ int rate1 = ((p[0] & 7) << 1) | (p[1] >> 7);
+ int channels = ((p[1] >> 3) & 15);
+ int exttype = 0;
+ int rate2 = rate1;
+
+ if (wfe->cbSize >= 5) {
+ profile = 4;
+
+ exttype = (p[2] << 3) | (p[3] >> 5);
+ ASSERT(exttype == 0x2B7);
+ ASSERT((p[3] & 31) == 5);
+ ASSERT((p[4] >> 7) == 1);
+ rate2 = ((p[4] >> 3) & 15);
+
+ if (rate2 < rate1) {
+ m_pTE->a.OutputSamplingFrequency.Set((float)nSamplesPerSec);
+ nSamplesPerSec /= 2;
+ }
+ }
+
+ switch (profile) {
+ default:
+ case 0:
+ m_pTE->CodecID.Set("A_AAC/MPEG2/MAIN");
+ break;
+ case 1:
+ m_pTE->CodecID.Set("A_AAC/MPEG2/LC");
+ break;
+ case 2:
+ m_pTE->CodecID.Set("A_AAC/MPEG2/SSR");
+ break;
+ case 3:
+ m_pTE->CodecID.Set("A_AAC/MPEG4/LTP");
+ break;
+ case 4:
+ m_pTE->CodecID.Set("A_AAC/MPEG4/LC/SBR");
+ break;
+ }
+
+ ASSERT(channels == wfe->nChannels);
+
+ m_pTE->DescType = TrackEntry::DescAudio;
+ m_pTE->a.SamplingFrequency.Set((float)nSamplesPerSec);
+ m_pTE->a.Channels.Set(channels);
+ m_pTE->a.BitDepth.Set(wfe->wBitsPerSample);
+
+ hr = S_OK;
+ } else if (m_mt.formattype == FORMAT_WaveFormatEx
+ && ((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_DOLBY_AC3) {
+ m_pTE->CodecID.Set("A_AC3");
+
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.pbFormat;
+ m_pTE->DescType = TrackEntry::DescAudio;
+ m_pTE->a.SamplingFrequency.Set((float)wfe->nSamplesPerSec);
+ m_pTE->a.Channels.Set(wfe->nChannels);
+ m_pTE->a.BitDepth.Set(wfe->wBitsPerSample);
+
+ hr = S_OK;
+ } else if (m_mt.formattype == FORMAT_WaveFormatEx
+ && ((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_DVD_DTS) {
+ m_pTE->CodecID.Set("A_DTS");
+
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.pbFormat;
+ m_pTE->DescType = TrackEntry::DescAudio;
+ m_pTE->a.SamplingFrequency.Set((float)wfe->nSamplesPerSec);
+ m_pTE->a.Channels.Set(wfe->nChannels);
+ m_pTE->a.BitDepth.Set(wfe->wBitsPerSample);
+
+ hr = S_OK;
+ } else if (m_mt.formattype == FORMAT_WaveFormatEx
+ && ((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_FLAC) {
+ m_pTE->CodecID.Set("A_FLAC");
+
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.pbFormat;
+ m_pTE->DescType = TrackEntry::DescAudio;
+ m_pTE->a.SamplingFrequency.Set((float)wfe->nSamplesPerSec);
+ m_pTE->a.Channels.Set(wfe->nChannels);
+ m_pTE->a.BitDepth.Set(wfe->wBitsPerSample);
+
+ if (wfe->cbSize) {
+ m_pTE->CodecPrivate.SetCount(wfe->cbSize);
+ memcpy(m_pTE->CodecPrivate, m_mt.pbFormat + sizeof(WAVEFORMATEX), wfe->cbSize);
+ }
+
+ hr = S_OK;
+ } else if (m_mt.formattype == FORMAT_WaveFormatEx
+ && (m_mt.subtype == MEDIASUBTYPE_14_4
+ || m_mt.subtype == MEDIASUBTYPE_28_8
+ || m_mt.subtype == MEDIASUBTYPE_ATRC
+ || m_mt.subtype == MEDIASUBTYPE_COOK
+ || m_mt.subtype == MEDIASUBTYPE_DNET
+ || m_mt.subtype == MEDIASUBTYPE_SIPR)) {
+ CStringA id;
+ id.Format("A_REAL/%c%c%c%c",
+ (char)((m_mt.subtype.Data1 >> 0) & 0xff),
+ (char)((m_mt.subtype.Data1 >> 8) & 0xff),
+ (char)((m_mt.subtype.Data1 >> 16) & 0xff),
+ (char)((m_mt.subtype.Data1 >> 24) & 0xff));
+
+ m_pTE->CodecID.Set(id);
+
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.pbFormat;
+ DWORD cbSize = sizeof(WAVEFORMATEX) + wfe->cbSize;
+ if (m_mt.cbFormat > cbSize) {
+ m_pTE->CodecPrivate.SetCount(m_mt.cbFormat - cbSize);
+ memcpy(m_pTE->CodecPrivate, m_mt.pbFormat + cbSize, m_pTE->CodecPrivate.GetCount());
+ }
+ m_pTE->DescType = TrackEntry::DescAudio;
+ m_pTE->a.SamplingFrequency.Set((float)wfe->nSamplesPerSec);
+ m_pTE->a.Channels.Set(wfe->nChannels);
+ m_pTE->a.BitDepth.Set(wfe->wBitsPerSample);
+
+ hr = S_OK;
+ } else if (m_mt.formattype == FORMAT_WaveFormatEx
+ && ((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_PCM) {
+ m_pTE->CodecID.Set("A_PCM/INT/LIT");
+
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.pbFormat;
+ m_pTE->DescType = TrackEntry::DescAudio;
+ m_pTE->a.SamplingFrequency.Set((float)wfe->nSamplesPerSec);
+ m_pTE->a.Channels.Set(wfe->nChannels);
+ m_pTE->a.BitDepth.Set(wfe->wBitsPerSample);
+
+ hr = S_OK;
+ } else if (m_mt.formattype == FORMAT_WaveFormatEx) {
+ m_pTE->CodecID.Set("A_MS/ACM");
+
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.pbFormat;
+ m_pTE->CodecPrivate.SetCount(m_mt.cbFormat);
+ memcpy(m_pTE->CodecPrivate, wfe, m_pTE->CodecPrivate.GetCount());
+ m_pTE->DescType = TrackEntry::DescAudio;
+ m_pTE->a.SamplingFrequency.Set((float)wfe->nSamplesPerSec);
+ m_pTE->a.Channels.Set(wfe->nChannels);
+ m_pTE->a.BitDepth.Set(wfe->wBitsPerSample);
+
+ hr = S_OK;
+ } else if (m_mt.formattype == FORMAT_VorbisFormat) {
+ m_pTE->CodecID.Set("A_VORBIS");
+
+ VORBISFORMAT* pvf = (VORBISFORMAT*)m_mt.pbFormat;
+ m_pTE->DescType = TrackEntry::DescAudio;
+ m_pTE->a.SamplingFrequency.Set((float)pvf->nSamplesPerSec);
+ m_pTE->a.Channels.Set(pvf->nChannels);
+
+ // m_pTE->CodecPrivate will be filled later
+
+ hr = S_OK;
+ } else if (m_mt.formattype == FORMAT_VorbisFormat2) {
+ m_pTE->CodecID.Set("A_VORBIS");
+
+ VORBISFORMAT2* pvf2 = (VORBISFORMAT2*)m_mt.pbFormat;
+ m_pTE->DescType = TrackEntry::DescAudio;
+ m_pTE->a.SamplingFrequency.Set((float)pvf2->SamplesPerSec);
+ m_pTE->a.Channels.Set(pvf2->Channels);
+ m_pTE->a.BitDepth.Set(pvf2->BitsPerSample);
+
+ int len = 1;
+ for (int i = 0; i < 2; i++) {
+ len += pvf2->HeaderSize[i] / 255 + 1;
+ }
+ for (int i = 0; i < 3; i++) {
+ len += pvf2->HeaderSize[i];
+ }
+ m_pTE->CodecPrivate.SetCount(len);
+
+ BYTE* src = (BYTE*)m_mt.pbFormat + sizeof(VORBISFORMAT2);
+ BYTE* dst = m_pTE->CodecPrivate.GetData();
+
+ *dst++ = 2;
+ for (int i = 0; i < 2; i++)
+ for (int len = pvf2->HeaderSize[i]; len >= 0; len -= 255) {
+ *dst++ = min(len, 255);
+ }
+
+ memcpy(dst, src, pvf2->HeaderSize[0]);
+ dst += pvf2->HeaderSize[0];
+ src += pvf2->HeaderSize[0];
+ memcpy(dst, src, pvf2->HeaderSize[1]);
+ dst += pvf2->HeaderSize[1];
+ src += pvf2->HeaderSize[1];
+ memcpy(dst, src, pvf2->HeaderSize[2]);
+ dst += pvf2->HeaderSize[2];
+ src += pvf2->HeaderSize[2];
+
+ ASSERT(src <= m_mt.pbFormat + m_mt.cbFormat);
+ ASSERT(dst <= m_pTE->CodecPrivate.GetData() + m_pTE->CodecPrivate.GetCount());
+
+ hr = S_OK;
+ }
+ } else if (m_mt.majortype == MEDIATYPE_Text) {
+ m_pTE->TrackType.Set(TrackEntry::TypeSubtitle);
+
+ if (m_mt.formattype == FORMAT_None) {
+ m_pTE->CodecID.Set("S_TEXT/ASCII");
+ hr = S_OK;
+ }
+ } else if (m_mt.majortype == MEDIATYPE_Subtitle) {
+ m_pTE->TrackType.Set(TrackEntry::TypeSubtitle);
+
+ m_pTE->CodecID.Set(
+ m_mt.subtype == MEDIASUBTYPE_UTF8 ? "S_TEXT/UTF8" :
+ m_mt.subtype == MEDIASUBTYPE_SSA ? "S_TEXT/SSA" :
+ m_mt.subtype == MEDIASUBTYPE_ASS ? "S_TEXT/ASS" :
+ m_mt.subtype == MEDIASUBTYPE_USF ? "S_TEXT/USF" :
+ m_mt.subtype == MEDIASUBTYPE_VOBSUB ? "S_VOBSUB" :
+ "");
+
+ if (!m_pTE->CodecID.IsEmpty()) {
+ hr = S_OK;
+
+ SUBTITLEINFO* psi = (SUBTITLEINFO*)m_mt.pbFormat;
+ if (psi->dwOffset) {
+ m_pTE->CodecPrivate.SetCount(m_mt.cbFormat - psi->dwOffset);
+ memcpy(m_pTE->CodecPrivate, m_mt.pbFormat + psi->dwOffset, m_pTE->CodecPrivate.GetCount());
+ }
+ }
+ }
+
+ if (S_OK == hr) {
+ (static_cast<CMatroskaMuxerFilter*>(m_pFilter))->AddInput();
+ }
+
+ return hr;
}
HRESULT CMatroskaMuxerInputPin::Active()
{
- m_fActive = true;
- m_rtLastStart = m_rtLastStop = -1;
- m_fEndOfStreamReceived = false;
- return __super::Active();
+ m_fActive = true;
+ m_rtLastStart = m_rtLastStop = -1;
+ m_fEndOfStreamReceived = false;
+ return __super::Active();
}
HRESULT CMatroskaMuxerInputPin::Inactive()
{
- m_fActive = false;
- CAutoLock cAutoLock(&m_csQueue);
- m_blocks.RemoveAll();
- m_pVorbisHdrs.RemoveAll();
- return __super::Inactive();
+ m_fActive = false;
+ CAutoLock cAutoLock(&m_csQueue);
+ m_blocks.RemoveAll();
+ m_pVorbisHdrs.RemoveAll();
+ return __super::Inactive();
}
STDMETHODIMP CMatroskaMuxerInputPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- CAutoLock cAutoLock(&m_csReceive);
- return __super::NewSegment(tStart, tStop, dRate);
+ CAutoLock cAutoLock(&m_csReceive);
+ return __super::NewSegment(tStart, tStop, dRate);
}
STDMETHODIMP CMatroskaMuxerInputPin::BeginFlush()
{
- return __super::BeginFlush();
+ return __super::BeginFlush();
}
STDMETHODIMP CMatroskaMuxerInputPin::EndFlush()
{
- return __super::EndFlush();
+ return __super::EndFlush();
}
STDMETHODIMP CMatroskaMuxerInputPin::Receive(IMediaSample* pSample)
{
- if (m_fEndOfStreamReceived) {
- /*ASSERT(0);*/
- return S_FALSE;
- }
-
- CAutoLock cAutoLock(&m_csReceive);
-
- while (m_fActive) {
- {
- CAutoLock cAutoLock2(&m_csQueue);
- if (m_blocks.GetCount() < MAXBLOCKS) {
- break;
- }
- }
-
- Sleep(1);
- }
-
- if (!m_fActive) {
- return S_FALSE;
- }
-
- HRESULT hr;
-
- if (FAILED(hr = __super::Receive(pSample))) {
- return hr;
- }
-
- BYTE* pData = NULL;
- pSample->GetPointer(&pData);
-
- long len = pSample->GetActualDataLength();
-
- REFERENCE_TIME rtStart = -1, rtStop = -1;
- hr = pSample->GetTime(&rtStart, &rtStop);
-
- if (FAILED(hr) || rtStart == -1 || rtStop == -1) {
- TRACE(_T("No timestamp was set on the sample!!!"));
- m_pFilter->NotifyEvent(EC_ERRORABORT, VFW_E_SAMPLE_TIME_NOT_SET, 0);
- return VFW_E_SAMPLE_TIME_NOT_SET;
- }
-
- // rtStart += m_tStart;
- // rtStop += m_tStart;
-
- /**/
- TRACE(_T("Received (%d): %I64d-%I64d (c=%d, co=%dms), len=%d, d%d p%d s%d\n"),
- (static_cast<CMatroskaMuxerFilter*>(m_pFilter))->GetTrackNumber(this),
- rtStart, rtStop, (int)((rtStart/10000)/MAXCLUSTERTIME), (int)((rtStart/10000)%MAXCLUSTERTIME),
- len,
- pSample->IsDiscontinuity() == S_OK ? 1 : 0,
- pSample->IsPreroll() == S_OK ? 1 : 0,
- pSample->IsSyncPoint() == S_OK ? 1 : 0);
-
- if (m_mt.subtype == MEDIASUBTYPE_Vorbis && m_pVorbisHdrs.GetCount() < 3) {
- CAutoPtr<CBinary> data(DNew CBinary(0));
- data->SetCount(len);
- memcpy(data->GetData(), pData, len);
- m_pVorbisHdrs.Add(data);
-
- if (m_pVorbisHdrs.GetCount() == 3) {
- int len = 1;
- for (size_t i = 0; i < 2; i++) {
- len += m_pVorbisHdrs[i]->GetCount()/255 + 1;
- }
- for (size_t i = 0; i < 3; i++) {
- len += m_pVorbisHdrs[i]->GetCount();
- }
- m_pTE->CodecPrivate.SetCount(len);
-
- BYTE* dst = m_pTE->CodecPrivate.GetData();
-
- *dst++ = 2;
- for (size_t i = 0; i < 2; i++)
- for (INT_PTR len = m_pVorbisHdrs[i]->GetCount(); len >= 0; len -= 255) {
- *dst++ = (BYTE)min(len, 255);
- }
-
- for (size_t i = 0; i < 3; i++) {
- memcpy(dst, m_pVorbisHdrs[i]->GetData(), m_pVorbisHdrs[i]->GetCount());
- dst += m_pVorbisHdrs[i]->GetCount();
- }
- }
-
- return S_OK;
- }
-
- if (m_mt.formattype == FORMAT_WaveFormatEx
- && (((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_PCM
- || ((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_MPEGLAYER3)) {
- pSample->SetSyncPoint(TRUE); // HACK: some capture filters don't set this
- }
-
- CAutoPtr<BlockGroup> b(DNew BlockGroup());
- /*
- // TODO: test this with a longer capture (pcm, mp3)
- if (S_OK == pSample->IsSyncPoint() && rtStart < m_rtLastStart)
- {
- TRACE(_T("!!! timestamp went backwards, dropping this frame !!! rtStart (%I64) < m_rtLastStart (%I64)"), rtStart, m_rtLastStart);
- return S_OK;
- }
- */
- if ((S_OK != pSample->IsSyncPoint() || m_rtLastStart == rtStart) && m_rtLastStart >= 0 /*&& m_rtLastStart < rtStart*/) {
- ASSERT(m_rtLastStart - rtStart <= 0);
- REFERENCE_TIME rtDiff = m_rtLastStart - rtStart;
- b->ReferenceBlock.Set((rtDiff + (rtDiff >= 0 ? 5000 : -5000)) / 10000);
- }
-
- b->Block.TrackNumber = (static_cast<CMatroskaMuxerFilter*>(m_pFilter))->GetTrackNumber(this);
-
- b->Block.TimeCode = (rtStart + 5000) / 10000;
- b->Block.TimeCodeStop = (rtStop + 5000) / 10000;
-
- if (m_pTE->TrackType == TrackEntry::TypeSubtitle) {
- b->BlockDuration.Set((rtStop - rtStart + 5000) / 10000);
- }
-
- CAutoPtr<CBinary> data(DNew CBinary(0));
- data->SetCount(len);
- memcpy(data->GetData(), pData, len);
- b->Block.BlockData.AddTail(data);
-
- CAutoLock cAutoLock2(&m_csQueue);
- m_blocks.AddTail(b); // TODO: lacing for audio
-
- m_rtLastStart = rtStart;
- m_rtLastStop = rtStop;
-
- return S_OK;
+ if (m_fEndOfStreamReceived) {
+ /*ASSERT(0);*/
+ return S_FALSE;
+ }
+
+ CAutoLock cAutoLock(&m_csReceive);
+
+ while (m_fActive) {
+ {
+ CAutoLock cAutoLock2(&m_csQueue);
+ if (m_blocks.GetCount() < MAXBLOCKS) {
+ break;
+ }
+ }
+
+ Sleep(1);
+ }
+
+ if (!m_fActive) {
+ return S_FALSE;
+ }
+
+ HRESULT hr;
+
+ if (FAILED(hr = __super::Receive(pSample))) {
+ return hr;
+ }
+
+ BYTE* pData = NULL;
+ pSample->GetPointer(&pData);
+
+ long len = pSample->GetActualDataLength();
+
+ REFERENCE_TIME rtStart = -1, rtStop = -1;
+ hr = pSample->GetTime(&rtStart, &rtStop);
+
+ if (FAILED(hr) || rtStart == -1 || rtStop == -1) {
+ TRACE(_T("No timestamp was set on the sample!!!"));
+ m_pFilter->NotifyEvent(EC_ERRORABORT, VFW_E_SAMPLE_TIME_NOT_SET, 0);
+ return VFW_E_SAMPLE_TIME_NOT_SET;
+ }
+
+ // rtStart += m_tStart;
+ // rtStop += m_tStart;
+
+ /**/
+ TRACE(_T("Received (%d): %I64d-%I64d (c=%d, co=%dms), len=%d, d%d p%d s%d\n"),
+ (static_cast<CMatroskaMuxerFilter*>(m_pFilter))->GetTrackNumber(this),
+ rtStart, rtStop, (int)((rtStart / 10000) / MAXCLUSTERTIME), (int)((rtStart / 10000) % MAXCLUSTERTIME),
+ len,
+ pSample->IsDiscontinuity() == S_OK ? 1 : 0,
+ pSample->IsPreroll() == S_OK ? 1 : 0,
+ pSample->IsSyncPoint() == S_OK ? 1 : 0);
+
+ if (m_mt.subtype == MEDIASUBTYPE_Vorbis && m_pVorbisHdrs.GetCount() < 3) {
+ CAutoPtr<CBinary> data(DNew CBinary(0));
+ data->SetCount(len);
+ memcpy(data->GetData(), pData, len);
+ m_pVorbisHdrs.Add(data);
+
+ if (m_pVorbisHdrs.GetCount() == 3) {
+ int len = 1;
+ for (size_t i = 0; i < 2; i++) {
+ len += m_pVorbisHdrs[i]->GetCount() / 255 + 1;
+ }
+ for (size_t i = 0; i < 3; i++) {
+ len += m_pVorbisHdrs[i]->GetCount();
+ }
+ m_pTE->CodecPrivate.SetCount(len);
+
+ BYTE* dst = m_pTE->CodecPrivate.GetData();
+
+ *dst++ = 2;
+ for (size_t i = 0; i < 2; i++)
+ for (INT_PTR len = m_pVorbisHdrs[i]->GetCount(); len >= 0; len -= 255) {
+ *dst++ = (BYTE)min(len, 255);
+ }
+
+ for (size_t i = 0; i < 3; i++) {
+ memcpy(dst, m_pVorbisHdrs[i]->GetData(), m_pVorbisHdrs[i]->GetCount());
+ dst += m_pVorbisHdrs[i]->GetCount();
+ }
+ }
+
+ return S_OK;
+ }
+
+ if (m_mt.formattype == FORMAT_WaveFormatEx
+ && (((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_PCM
+ || ((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_MPEGLAYER3)) {
+ pSample->SetSyncPoint(TRUE); // HACK: some capture filters don't set this
+ }
+
+ CAutoPtr<BlockGroup> b(DNew BlockGroup());
+ /*
+ // TODO: test this with a longer capture (pcm, mp3)
+ if (S_OK == pSample->IsSyncPoint() && rtStart < m_rtLastStart)
+ {
+ TRACE(_T("!!! timestamp went backwards, dropping this frame !!! rtStart (%I64) < m_rtLastStart (%I64)"), rtStart, m_rtLastStart);
+ return S_OK;
+ }
+ */
+ if ((S_OK != pSample->IsSyncPoint() || m_rtLastStart == rtStart) && m_rtLastStart >= 0 /*&& m_rtLastStart < rtStart*/) {
+ ASSERT(m_rtLastStart - rtStart <= 0);
+ REFERENCE_TIME rtDiff = m_rtLastStart - rtStart;
+ b->ReferenceBlock.Set((rtDiff + (rtDiff >= 0 ? 5000 : -5000)) / 10000);
+ }
+
+ b->Block.TrackNumber = (static_cast<CMatroskaMuxerFilter*>(m_pFilter))->GetTrackNumber(this);
+
+ b->Block.TimeCode = (rtStart + 5000) / 10000;
+ b->Block.TimeCodeStop = (rtStop + 5000) / 10000;
+
+ if (m_pTE->TrackType == TrackEntry::TypeSubtitle) {
+ b->BlockDuration.Set((rtStop - rtStart + 5000) / 10000);
+ }
+
+ CAutoPtr<CBinary> data(DNew CBinary(0));
+ data->SetCount(len);
+ memcpy(data->GetData(), pData, len);
+ b->Block.BlockData.AddTail(data);
+
+ CAutoLock cAutoLock2(&m_csQueue);
+ m_blocks.AddTail(b); // TODO: lacing for audio
+
+ m_rtLastStart = rtStart;
+ m_rtLastStop = rtStop;
+
+ return S_OK;
}
STDMETHODIMP CMatroskaMuxerInputPin::EndOfStream()
{
- HRESULT hr;
+ HRESULT hr;
- if (FAILED(hr = __super::EndOfStream())) {
- return hr;
- }
+ if (FAILED(hr = __super::EndOfStream())) {
+ return hr;
+ }
- CAutoLock cAutoLock(&m_csQueue);
+ CAutoLock cAutoLock(&m_csQueue);
- m_fEndOfStreamReceived = true;
+ m_fEndOfStreamReceived = true;
- return hr;
+ return hr;
}
//
@@ -1338,7 +1338,7 @@ STDMETHODIMP CMatroskaMuxerInputPin::EndOfStream()
//
CMatroskaMuxerOutputPin::CMatroskaMuxerOutputPin(TCHAR* pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseOutputPin(pName, pFilter, pLock, phr, L"Output")
+ : CBaseOutputPin(pName, pFilter, pLock, phr, L"Output")
{
}
@@ -1348,63 +1348,63 @@ CMatroskaMuxerOutputPin::~CMatroskaMuxerOutputPin()
STDMETHODIMP CMatroskaMuxerOutputPin::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CMatroskaMuxerOutputPin::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties)
{
- ASSERT(pAlloc);
- ASSERT(pProperties);
+ ASSERT(pAlloc);
+ ASSERT(pProperties);
- HRESULT hr = NOERROR;
+ HRESULT hr = NOERROR;
- pProperties->cBuffers = 1;
- pProperties->cbBuffer = 1;
+ pProperties->cBuffers = 1;
+ pProperties->cbBuffer = 1;
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
- return hr;
- }
+ ALLOCATOR_PROPERTIES Actual;
+ if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
- if (Actual.cbBuffer < pProperties->cbBuffer) {
- return E_FAIL;
- }
- ASSERT(Actual.cBuffers == pProperties->cBuffers);
+ if (Actual.cbBuffer < pProperties->cbBuffer) {
+ return E_FAIL;
+ }
+ ASSERT(Actual.cBuffers == pProperties->cBuffers);
- return NOERROR;
+ return NOERROR;
}
HRESULT CMatroskaMuxerOutputPin::CheckMediaType(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Stream && pmt->subtype == MEDIASUBTYPE_Matroska
- ? S_OK
- : E_INVALIDARG;
+ return pmt->majortype == MEDIATYPE_Stream && pmt->subtype == MEDIASUBTYPE_Matroska
+ ? S_OK
+ : E_INVALIDARG;
}
HRESULT CMatroskaMuxerOutputPin::GetMediaType(int iPosition, CMediaType* pmt)
{
- CAutoLock cAutoLock(m_pLock);
-
- if (iPosition < 0) {
- return E_INVALIDARG;
- }
- if (iPosition > 0) {
- return VFW_S_NO_MORE_ITEMS;
- }
-
- pmt->ResetFormatBuffer();
- pmt->InitMediaType();
- pmt->majortype = MEDIATYPE_Stream;
- pmt->subtype = MEDIASUBTYPE_Matroska;
- pmt->formattype = FORMAT_None;
-
- return S_OK;
+ CAutoLock cAutoLock(m_pLock);
+
+ if (iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if (iPosition > 0) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
+
+ pmt->ResetFormatBuffer();
+ pmt->InitMediaType();
+ pmt->majortype = MEDIATYPE_Stream;
+ pmt->subtype = MEDIASUBTYPE_Matroska;
+ pmt->formattype = FORMAT_None;
+
+ return S_OK;
}
STDMETHODIMP CMatroskaMuxerOutputPin::Notify(IBaseFilter* pSender, Quality q)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
diff --git a/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.h b/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.h
index 532157827..5dcf9d4d2 100644
--- a/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.h
+++ b/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.h
@@ -34,130 +34,130 @@
class CMatroskaMuxerInputPin : public CBaseInputPin
{
- CAutoPtr<MatroskaWriter::TrackEntry> m_pTE;
- CAutoPtrArray<MatroskaWriter::CBinary> m_pVorbisHdrs;
+ CAutoPtr<MatroskaWriter::TrackEntry> m_pTE;
+ CAutoPtrArray<MatroskaWriter::CBinary> m_pVorbisHdrs;
- bool m_fActive;
- CCritSec m_csReceive;
+ bool m_fActive;
+ CCritSec m_csReceive;
- REFERENCE_TIME m_rtLastStart, m_rtLastStop;
+ REFERENCE_TIME m_rtLastStart, m_rtLastStop;
public:
- CMatroskaMuxerInputPin(LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
- virtual ~CMatroskaMuxerInputPin();
+ CMatroskaMuxerInputPin(LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
+ virtual ~CMatroskaMuxerInputPin();
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- MatroskaWriter::TrackEntry* GetTrackEntry() {
- return m_pTE;
- }
+ MatroskaWriter::TrackEntry* GetTrackEntry() {
+ return m_pTE;
+ }
- REFERENCE_TIME m_rtDur;
+ REFERENCE_TIME m_rtDur;
- CCritSec m_csQueue;
- CAutoPtrList<MatroskaWriter::BlockGroup> m_blocks;
- bool m_fEndOfStreamReceived;
+ CCritSec m_csQueue;
+ CAutoPtrList<MatroskaWriter::BlockGroup> m_blocks;
+ bool m_fEndOfStreamReceived;
- HRESULT CheckMediaType(const CMediaType* pmt);
- HRESULT BreakConnect();
- HRESULT CompleteConnect(IPin* pPin);
- HRESULT Active(), Inactive();
+ HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT BreakConnect();
+ HRESULT CompleteConnect(IPin* pPin);
+ HRESULT Active(), Inactive();
- STDMETHODIMP NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
- STDMETHODIMP BeginFlush();
- STDMETHODIMP EndFlush();
+ STDMETHODIMP NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ STDMETHODIMP BeginFlush();
+ STDMETHODIMP EndFlush();
- STDMETHODIMP Receive(IMediaSample* pSample);
- STDMETHODIMP EndOfStream();
+ STDMETHODIMP Receive(IMediaSample* pSample);
+ STDMETHODIMP EndOfStream();
};
class CMatroskaMuxerOutputPin : public CBaseOutputPin
{
public:
- CMatroskaMuxerOutputPin(TCHAR* pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
- virtual ~CMatroskaMuxerOutputPin();
+ CMatroskaMuxerOutputPin(TCHAR* pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
+ virtual ~CMatroskaMuxerOutputPin();
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- HRESULT DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT CheckMediaType(const CMediaType* pmt);
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
+ HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT GetMediaType(int iPosition, CMediaType* pmt);
- STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
+ STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
};
interface __declspec(uuid("38E2D43D-915D-493C-B373-888DB16EE3DC"))
IMatroskaMuxer :
public IUnknown {
- STDMETHOD (CorrectTimeOffset) (bool fNegative, bool fPositive) = 0;
- // TODO: chapters
+ STDMETHOD(CorrectTimeOffset)(bool fNegative, bool fPositive) = 0;
+ // TODO: chapters
};
class __declspec(uuid("1E1299A2-9D42-4F12-8791-D79E376F4143"))
- CMatroskaMuxerFilter
- : public CBaseFilter
- , public CCritSec
- , public CAMThread
- , public IAMFilterMiscFlags
- , public IMediaSeeking
- , public IMatroskaMuxer
+ CMatroskaMuxerFilter
+ : public CBaseFilter
+ , public CCritSec
+ , public CAMThread
+ , public IAMFilterMiscFlags
+ , public IMediaSeeking
+ , public IMatroskaMuxer
{
protected:
- CAutoPtrList<CMatroskaMuxerInputPin> m_pInputs;
- CAutoPtr<CMatroskaMuxerOutputPin> m_pOutput;
+ CAutoPtrList<CMatroskaMuxerInputPin> m_pInputs;
+ CAutoPtr<CMatroskaMuxerOutputPin> m_pOutput;
- REFERENCE_TIME m_rtCurrent;
+ REFERENCE_TIME m_rtCurrent;
- bool m_fNegative, m_fPositive;
+ bool m_fNegative, m_fPositive;
- enum {CMD_EXIT, CMD_RUN};
- DWORD ThreadProc();
+ enum {CMD_EXIT, CMD_RUN};
+ DWORD ThreadProc();
public:
- CMatroskaMuxerFilter(LPUNKNOWN pUnk, HRESULT* phr);
- virtual ~CMatroskaMuxerFilter();
+ CMatroskaMuxerFilter(LPUNKNOWN pUnk, HRESULT* phr);
+ virtual ~CMatroskaMuxerFilter();
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- void AddInput();
- UINT GetTrackNumber(CBasePin* pPin);
+ void AddInput();
+ UINT GetTrackNumber(CBasePin* pPin);
- int GetPinCount();
- CBasePin* GetPin(int n);
+ int GetPinCount();
+ CBasePin* GetPin(int n);
- STDMETHODIMP Stop();
- STDMETHODIMP Pause();
- STDMETHODIMP Run(REFERENCE_TIME tStart);
+ STDMETHODIMP Stop();
+ STDMETHODIMP Pause();
+ STDMETHODIMP Run(REFERENCE_TIME tStart);
- // IAMFilterMiscFlags
+ // IAMFilterMiscFlags
- STDMETHODIMP_(ULONG) GetMiscFlags();
+ STDMETHODIMP_(ULONG) GetMiscFlags();
- // IMediaSeeking
+ // IMediaSeeking
- STDMETHODIMP GetCapabilities(DWORD* pCapabilities);
- STDMETHODIMP CheckCapabilities(DWORD* pCapabilities);
- STDMETHODIMP IsFormatSupported(const GUID* pFormat);
- STDMETHODIMP QueryPreferredFormat(GUID* pFormat);
- STDMETHODIMP GetTimeFormat(GUID* pFormat);
- STDMETHODIMP IsUsingTimeFormat(const GUID* pFormat);
- STDMETHODIMP SetTimeFormat(const GUID* pFormat);
- STDMETHODIMP GetDuration(LONGLONG* pDuration);
- STDMETHODIMP GetStopPosition(LONGLONG* pStop);
- STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
- STDMETHODIMP ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat);
- STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
- STDMETHODIMP GetPositions(LONGLONG* pCurrent, LONGLONG* pStop);
- STDMETHODIMP GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest);
- STDMETHODIMP SetRate(double dRate);
- STDMETHODIMP GetRate(double* pdRate);
- STDMETHODIMP GetPreroll(LONGLONG* pllPreroll);
+ STDMETHODIMP GetCapabilities(DWORD* pCapabilities);
+ STDMETHODIMP CheckCapabilities(DWORD* pCapabilities);
+ STDMETHODIMP IsFormatSupported(const GUID* pFormat);
+ STDMETHODIMP QueryPreferredFormat(GUID* pFormat);
+ STDMETHODIMP GetTimeFormat(GUID* pFormat);
+ STDMETHODIMP IsUsingTimeFormat(const GUID* pFormat);
+ STDMETHODIMP SetTimeFormat(const GUID* pFormat);
+ STDMETHODIMP GetDuration(LONGLONG* pDuration);
+ STDMETHODIMP GetStopPosition(LONGLONG* pStop);
+ STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
+ STDMETHODIMP ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat);
+ STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
+ STDMETHODIMP GetPositions(LONGLONG* pCurrent, LONGLONG* pStop);
+ STDMETHODIMP GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest);
+ STDMETHODIMP SetRate(double dRate);
+ STDMETHODIMP GetRate(double* pdRate);
+ STDMETHODIMP GetPreroll(LONGLONG* pllPreroll);
- // IMatroskaMuxer
+ // IMatroskaMuxer
- STDMETHODIMP CorrectTimeOffset(bool fNegative, bool fPositive);
+ STDMETHODIMP CorrectTimeOffset(bool fNegative, bool fPositive);
};
diff --git a/src/filters/muxer/WavDest/WavDest.cpp b/src/filters/muxer/WavDest/WavDest.cpp
index 20aa32672..348b2bb43 100644
--- a/src/filters/muxer/WavDest/WavDest.cpp
+++ b/src/filters/muxer/WavDest/WavDest.cpp
@@ -30,36 +30,36 @@
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_WAVE},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_WAVE},
};
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_WAVE},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_WAVE},
};
const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CWavDestFilter), WavDestName, MERIT_DO_NOT_USE, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory}
+ {&__uuidof(CWavDestFilter), WavDestName, MERIT_DO_NOT_USE, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory}
};
CFactoryTemplate g_Templates[] = {
- {L"WavDest", &__uuidof(CWavDestFilter), CreateInstance<CWavDestFilter>, NULL, &sudFilter[0]}
+ {L"WavDest", &__uuidof(CWavDestFilter), CreateInstance<CWavDestFilter>, NULL, &sudFilter[0]}
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -73,31 +73,31 @@ CFilterApp theApp;
//
CWavDestFilter::CWavDestFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CTransformFilter(NAME("WavDest filter"), pUnk, __uuidof(this))
+ : CTransformFilter(NAME("WavDest filter"), pUnk, __uuidof(this))
{
- if (SUCCEEDED(*phr)) {
- if (CWavDestOutputPin* pOut = DNew CWavDestOutputPin(this, phr)) {
- if (SUCCEEDED(*phr)) {
- m_pOutput = pOut;
- } else {
- delete pOut;
- }
- } else {
- *phr = E_OUTOFMEMORY;
- return;
- }
-
- if (CTransformInputPin* pIn = DNew CTransformInputPin(NAME("Transform input pin"), this, phr, L"In")) {
- if (SUCCEEDED(*phr)) {
- m_pInput = pIn;
- } else {
- delete pIn;
- }
- } else {
- *phr = E_OUTOFMEMORY;
- return;
- }
- }
+ if (SUCCEEDED(*phr)) {
+ if (CWavDestOutputPin* pOut = DNew CWavDestOutputPin(this, phr)) {
+ if (SUCCEEDED(*phr)) {
+ m_pOutput = pOut;
+ } else {
+ delete pOut;
+ }
+ } else {
+ *phr = E_OUTOFMEMORY;
+ return;
+ }
+
+ if (CTransformInputPin* pIn = DNew CTransformInputPin(NAME("Transform input pin"), this, phr, L"In")) {
+ if (SUCCEEDED(*phr)) {
+ m_pInput = pIn;
+ } else {
+ delete pIn;
+ }
+ } else {
+ *phr = E_OUTOFMEMORY;
+ return;
+ }
+ }
}
CWavDestFilter::~CWavDestFilter()
@@ -106,143 +106,143 @@ CWavDestFilter::~CWavDestFilter()
HRESULT CWavDestFilter::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
{
- return CheckInputType(mtIn);
+ return CheckInputType(mtIn);
}
HRESULT CWavDestFilter::Receive(IMediaSample* pSample)
{
- ULONG cbOld = m_cbWavData;
- HRESULT hr = CTransformFilter::Receive(pSample);
+ ULONG cbOld = m_cbWavData;
+ HRESULT hr = CTransformFilter::Receive(pSample);
- // don't update the count if Deliver() downstream fails.
- if (hr != S_OK) {
- m_cbWavData = cbOld;
- }
+ // don't update the count if Deliver() downstream fails.
+ if (hr != S_OK) {
+ m_cbWavData = cbOld;
+ }
- return hr;
+ return hr;
}
HRESULT CWavDestFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
{
- REFERENCE_TIME rtStart, rtEnd;
+ REFERENCE_TIME rtStart, rtEnd;
- HRESULT hr = Copy(pIn, pOut);
- if (FAILED(hr)) {
- return hr;
- }
+ HRESULT hr = Copy(pIn, pOut);
+ if (FAILED(hr)) {
+ return hr;
+ }
- // Prepare it for writing
- LONG lActual = pOut->GetActualDataLength();
+ // Prepare it for writing
+ LONG lActual = pOut->GetActualDataLength();
- if (m_cbWavData + m_cbHeader + lActual < m_cbWavData + m_cbHeader ) { // overflow
- return E_FAIL;
- }
+ if (m_cbWavData + m_cbHeader + lActual < m_cbWavData + m_cbHeader) { // overflow
+ return E_FAIL;
+ }
- rtStart = m_cbWavData + m_cbHeader;
- rtEnd = rtStart + lActual;
- m_cbWavData += lActual;
+ rtStart = m_cbWavData + m_cbHeader;
+ rtEnd = rtStart + lActual;
+ m_cbWavData += lActual;
- EXECUTE_ASSERT(pOut->SetTime(&rtStart, &rtEnd) == S_OK);
+ EXECUTE_ASSERT(pOut->SetTime(&rtStart, &rtEnd) == S_OK);
- return S_OK;
+ return S_OK;
}
HRESULT CWavDestFilter::Copy(IMediaSample* pSource, IMediaSample* pDest) const
{
- BYTE* pSourceBuffer, * pDestBuffer;
- long lSourceSize = pSource->GetActualDataLength();
+ BYTE* pSourceBuffer, * pDestBuffer;
+ long lSourceSize = pSource->GetActualDataLength();
#ifdef _DEBUG
- long lDestSize = pDest->GetSize();
- ASSERT(lDestSize >= lSourceSize);
+ long lDestSize = pDest->GetSize();
+ ASSERT(lDestSize >= lSourceSize);
#endif
- pSource->GetPointer(&pSourceBuffer);
- pDest->GetPointer(&pDestBuffer);
+ pSource->GetPointer(&pSourceBuffer);
+ pDest->GetPointer(&pDestBuffer);
- CopyMemory((PVOID)pDestBuffer, (PVOID)pSourceBuffer, lSourceSize);
+ CopyMemory((PVOID)pDestBuffer, (PVOID)pSourceBuffer, lSourceSize);
- // Copy the sample times
+ // Copy the sample times
- REFERENCE_TIME TimeStart, TimeEnd;
- if (NOERROR == pSource->GetTime(&TimeStart, &TimeEnd)) {
- pDest->SetTime(&TimeStart, &TimeEnd);
- }
+ REFERENCE_TIME TimeStart, TimeEnd;
+ if (NOERROR == pSource->GetTime(&TimeStart, &TimeEnd)) {
+ pDest->SetTime(&TimeStart, &TimeEnd);
+ }
- LONGLONG MediaStart, MediaEnd;
- if (pSource->GetMediaTime(&MediaStart, &MediaEnd) == NOERROR) {
- pDest->SetMediaTime(&MediaStart, &MediaEnd);
- }
+ LONGLONG MediaStart, MediaEnd;
+ if (pSource->GetMediaTime(&MediaStart, &MediaEnd) == NOERROR) {
+ pDest->SetMediaTime(&MediaStart, &MediaEnd);
+ }
- // Copy the media type
- AM_MEDIA_TYPE* pMediaType;
- pSource->GetMediaType(&pMediaType);
- pDest->SetMediaType(pMediaType);
- DeleteMediaType(pMediaType);
+ // Copy the media type
+ AM_MEDIA_TYPE* pMediaType;
+ pSource->GetMediaType(&pMediaType);
+ pDest->SetMediaType(pMediaType);
+ DeleteMediaType(pMediaType);
- // Copy the actual data length
- long lDataLength = pSource->GetActualDataLength();
- pDest->SetActualDataLength(lDataLength);
+ // Copy the actual data length
+ long lDataLength = pSource->GetActualDataLength();
+ pDest->SetActualDataLength(lDataLength);
- return NOERROR;
+ return NOERROR;
}
HRESULT CWavDestFilter::CheckInputType(const CMediaType* mtIn)
{
- return mtIn->formattype == FORMAT_WaveFormatEx ? S_OK : S_FALSE;
+ return mtIn->formattype == FORMAT_WaveFormatEx ? S_OK : S_FALSE;
}
HRESULT CWavDestFilter::GetMediaType(int iPosition, CMediaType* pMediaType)
{
- ASSERT(iPosition == 0 || iPosition == 1);
+ ASSERT(iPosition == 0 || iPosition == 1);
- if (iPosition == 0) {
- pMediaType->SetType(&MEDIATYPE_Stream);
- pMediaType->SetSubtype(&MEDIASUBTYPE_WAVE);
- return S_OK;
- }
+ if (iPosition == 0) {
+ pMediaType->SetType(&MEDIATYPE_Stream);
+ pMediaType->SetSubtype(&MEDIASUBTYPE_WAVE);
+ return S_OK;
+ }
- return VFW_S_NO_MORE_ITEMS;
+ return VFW_S_NO_MORE_ITEMS;
}
HRESULT CWavDestFilter::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties)
{
- if (m_pInput->IsConnected() == FALSE) {
- return E_UNEXPECTED;
- }
+ if (m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
- ASSERT(pAlloc);
- ASSERT(pProperties);
+ ASSERT(pAlloc);
+ ASSERT(pProperties);
- HRESULT hr = NOERROR;
+ HRESULT hr = NOERROR;
- pProperties->cBuffers = 1;
- pProperties->cbAlign = 1;
+ pProperties->cBuffers = 1;
+ pProperties->cbAlign = 1;
- CComPtr<IMemAllocator> pInAlloc;
- ALLOCATOR_PROPERTIES InProps;
- if (SUCCEEDED(hr = m_pInput->GetAllocator(&pInAlloc))
- && SUCCEEDED(hr = pInAlloc->GetProperties(&InProps))) {
- pProperties->cbBuffer = InProps.cbBuffer;
- } else {
- return hr;
- }
+ CComPtr<IMemAllocator> pInAlloc;
+ ALLOCATOR_PROPERTIES InProps;
+ if (SUCCEEDED(hr = m_pInput->GetAllocator(&pInAlloc))
+ && SUCCEEDED(hr = pInAlloc->GetProperties(&InProps))) {
+ pProperties->cbBuffer = InProps.cbBuffer;
+ } else {
+ return hr;
+ }
- ASSERT(pProperties->cbBuffer);
+ ASSERT(pProperties->cbBuffer);
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAlloc->SetProperties(pProperties,&Actual))) {
- return hr;
- }
+ ALLOCATOR_PROPERTIES Actual;
+ if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
- ASSERT(Actual.cBuffers == 1);
+ ASSERT(Actual.cBuffers == 1);
- if (pProperties->cBuffers > Actual.cBuffers
- || pProperties->cbBuffer > Actual.cbBuffer) {
- return E_FAIL;
- }
+ if (pProperties->cBuffers > Actual.cBuffers
+ || pProperties->cbBuffer > Actual.cbBuffer) {
+ return E_FAIL;
+ }
- return NOERROR;
+ return NOERROR;
}
// Compute the header size to allow space for us to write it at the end.
@@ -255,77 +255,77 @@ HRESULT CWavDestFilter::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPER
HRESULT CWavDestFilter::StartStreaming()
{
- // leave space for the header
- m_cbHeader = sizeof(RIFFLIST) +
- sizeof(RIFFCHUNK) +
- m_pInput->CurrentMediaType().FormatLength() +
- sizeof(RIFFCHUNK);
+ // leave space for the header
+ m_cbHeader = sizeof(RIFFLIST) +
+ sizeof(RIFFCHUNK) +
+ m_pInput->CurrentMediaType().FormatLength() +
+ sizeof(RIFFCHUNK);
- m_cbWavData = 0;
+ m_cbWavData = 0;
- return S_OK;
+ return S_OK;
}
HRESULT CWavDestFilter::StopStreaming()
{
- IStream* pStream;
- if (m_pOutput->IsConnected() == FALSE) {
- return E_FAIL;
- }
+ IStream* pStream;
+ if (m_pOutput->IsConnected() == FALSE) {
+ return E_FAIL;
+ }
- IPin* pDwnstrmInputPin = m_pOutput->GetConnected();
+ IPin* pDwnstrmInputPin = m_pOutput->GetConnected();
- if (!pDwnstrmInputPin) {
- return E_FAIL;
- }
+ if (!pDwnstrmInputPin) {
+ return E_FAIL;
+ }
- HRESULT hr = ((IMemInputPin *) pDwnstrmInputPin)->QueryInterface(IID_IStream, (void **)&pStream);
- if (SUCCEEDED(hr)) {
- BYTE *pb = (BYTE *)_alloca(m_cbHeader);
+ HRESULT hr = ((IMemInputPin*) pDwnstrmInputPin)->QueryInterface(IID_IStream, (void**)&pStream);
+ if (SUCCEEDED(hr)) {
+ BYTE* pb = (BYTE*)_alloca(m_cbHeader);
- RIFFLIST *pRiffWave = (RIFFLIST *)pb;
- RIFFCHUNK *pRiffFmt = (RIFFCHUNK *)(pRiffWave + 1);
- RIFFCHUNK *pRiffData = (RIFFCHUNK *)(((BYTE *)(pRiffFmt + 1)) + m_pInput->CurrentMediaType().FormatLength());
+ RIFFLIST* pRiffWave = (RIFFLIST*)pb;
+ RIFFCHUNK* pRiffFmt = (RIFFCHUNK*)(pRiffWave + 1);
+ RIFFCHUNK* pRiffData = (RIFFCHUNK*)(((BYTE*)(pRiffFmt + 1)) + m_pInput->CurrentMediaType().FormatLength());
- pRiffData->fcc = FCC('data');
- pRiffData->cb = m_cbWavData;
+ pRiffData->fcc = FCC('data');
+ pRiffData->cb = m_cbWavData;
- pRiffFmt->fcc = FCC('fmt ');
- pRiffFmt->cb = m_pInput->CurrentMediaType().FormatLength();
- CopyMemory(pRiffFmt + 1, m_pInput->CurrentMediaType().Format(), pRiffFmt->cb);
+ pRiffFmt->fcc = FCC('fmt ');
+ pRiffFmt->cb = m_pInput->CurrentMediaType().FormatLength();
+ CopyMemory(pRiffFmt + 1, m_pInput->CurrentMediaType().Format(), pRiffFmt->cb);
- pRiffWave->fcc = FCC('RIFF');
- pRiffWave->cb = m_cbWavData + m_cbHeader - sizeof(RIFFCHUNK);
- pRiffWave->fccListType = FCC('WAVE');
+ pRiffWave->fcc = FCC('RIFF');
+ pRiffWave->cb = m_cbWavData + m_cbHeader - sizeof(RIFFCHUNK);
+ pRiffWave->fccListType = FCC('WAVE');
- LARGE_INTEGER li;
- ZeroMemory(&li, sizeof(li));
+ LARGE_INTEGER li;
+ ZeroMemory(&li, sizeof(li));
- hr = pStream->Seek(li, STREAM_SEEK_SET, 0);
- if (SUCCEEDED(hr)) {
- hr = pStream->Write(pb, m_cbHeader, 0);
- }
- pStream->Release();
- }
+ hr = pStream->Seek(li, STREAM_SEEK_SET, 0);
+ if (SUCCEEDED(hr)) {
+ hr = pStream->Write(pb, m_cbHeader, 0);
+ }
+ pStream->Release();
+ }
- return hr;
+ return hr;
}
CWavDestOutputPin::CWavDestOutputPin(CTransformFilter* pFilter, HRESULT* phr)
- : CTransformOutputPin(NAME("WavDest output pin"), pFilter, phr, L"Out")
+ : CTransformOutputPin(NAME("WavDest output pin"), pFilter, phr, L"Out")
{
}
STDMETHODIMP CWavDestOutputPin::EnumMediaTypes(IEnumMediaTypes** ppEnum)
{
- return CBaseOutputPin::EnumMediaTypes(ppEnum);
+ return CBaseOutputPin::EnumMediaTypes(ppEnum);
}
HRESULT CWavDestOutputPin::CheckMediaType(const CMediaType* pmt)
{
- if (pmt->majortype == MEDIATYPE_Stream && pmt->subtype == MEDIASUBTYPE_WAVE) {
- return S_OK;
- } else {
- return S_FALSE;
- }
+ if (pmt->majortype == MEDIATYPE_Stream && pmt->subtype == MEDIASUBTYPE_WAVE) {
+ return S_OK;
+ } else {
+ return S_FALSE;
+ }
}
diff --git a/src/filters/muxer/WavDest/WavDest.h b/src/filters/muxer/WavDest/WavDest.h
index b5e58b413..e380c435a 100644
--- a/src/filters/muxer/WavDest/WavDest.h
+++ b/src/filters/muxer/WavDest/WavDest.h
@@ -30,39 +30,39 @@
class CWavDestOutputPin : public CTransformOutputPin
{
public:
- CWavDestOutputPin(CTransformFilter* pFilter, HRESULT* phr);
+ CWavDestOutputPin(CTransformFilter* pFilter, HRESULT* phr);
- STDMETHODIMP EnumMediaTypes(IEnumMediaTypes** ppEnum);
- HRESULT CheckMediaType(const CMediaType* pmt);
+ STDMETHODIMP EnumMediaTypes(IEnumMediaTypes** ppEnum);
+ HRESULT CheckMediaType(const CMediaType* pmt);
};
class __declspec(uuid("8685214E-4D32-4058-BE04-D01104F00B0C"))
- CWavDestFilter : public CTransformFilter
+ CWavDestFilter : public CTransformFilter
{
public:
- CWavDestFilter(LPUNKNOWN pUnk, HRESULT* pHr);
- ~CWavDestFilter();
+ CWavDestFilter(LPUNKNOWN pUnk, HRESULT* pHr);
+ ~CWavDestFilter();
- DECLARE_IUNKNOWN;
+ DECLARE_IUNKNOWN;
- HRESULT Transform(IMediaSample* pIn, IMediaSample* pOut);
- HRESULT Receive(IMediaSample* pSample);
+ HRESULT Transform(IMediaSample* pIn, IMediaSample* pOut);
+ HRESULT Receive(IMediaSample* pSample);
- HRESULT CheckInputType(const CMediaType* mtIn);
- HRESULT CheckTransform(const CMediaType*mtIn, const CMediaType* mtOut);
- HRESULT GetMediaType(int iPosition, CMediaType* pMediaType);
+ HRESULT CheckInputType(const CMediaType* mtIn);
+ HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
+ HRESULT GetMediaType(int iPosition, CMediaType* pMediaType);
- HRESULT DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT StartStreaming();
- HRESULT StopStreaming();
+ HRESULT StartStreaming();
+ HRESULT StopStreaming();
private:
- HRESULT Copy(IMediaSample* pSource, IMediaSample* pDest) const;
- HRESULT Transform(IMediaSample* pMediaSample);
- HRESULT Transform(AM_MEDIA_TYPE* pType, const signed char ContrastLevel) const;
+ HRESULT Copy(IMediaSample* pSource, IMediaSample* pDest) const;
+ HRESULT Transform(IMediaSample* pMediaSample);
+ HRESULT Transform(AM_MEDIA_TYPE* pType, const signed char ContrastLevel) const;
- ULONG m_cbWavData;
- ULONG m_cbHeader;
+ ULONG m_cbWavData;
+ ULONG m_cbHeader;
};
diff --git a/src/filters/parser/AviSplitter/AviFile.cpp b/src/filters/parser/AviSplitter/AviFile.cpp
index 2143705eb..92ceaa6bc 100644
--- a/src/filters/parser/AviSplitter/AviFile.cpp
+++ b/src/filters/parser/AviSplitter/AviFile.cpp
@@ -30,620 +30,620 @@
//
CAviFile::CAviFile(IAsyncReader* pAsyncReader, HRESULT& hr)
- : CBaseSplitterFile(pAsyncReader, hr)
+ : CBaseSplitterFile(pAsyncReader, hr)
{
- if (FAILED(hr)) {
- return;
- }
- m_isamv = false;
- hr = Init();
+ if (FAILED(hr)) {
+ return;
+ }
+ m_isamv = false;
+ hr = Init();
}
HRESULT CAviFile::Init()
{
- Seek(0);
- DWORD dw[3];
- if (S_OK != Read(dw) || dw[0] != FCC('RIFF') || (dw[2] != FCC('AVI ') && dw[2] != FCC('AVIX') && dw[2] != FCC('AMV '))) {
- return E_FAIL;
- }
-
- m_isamv = (dw[2] == FCC('AMV '));
- Seek(0);
- HRESULT hr = Parse(0, GetLength());
- UNREFERENCED_PARAMETER(hr);
- if (m_movis.GetCount() == 0) { // FAILED(hr) is allowed as long as there was a movi chunk found
- return E_FAIL;
- }
-
- if (m_avih.dwStreams == 0 && m_strms.GetCount() > 0) {
- m_avih.dwStreams = (DWORD)m_strms.GetCount();
- }
-
- if (m_avih.dwStreams != m_strms.GetCount()) {
- return E_FAIL;
- }
-
- for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
- strm_t* s = m_strms[i];
- if (s->strh.fccType != FCC('auds')) {
- continue;
- }
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)s->strf.GetData();
- if (wfe->wFormatTag == 0x55 && wfe->nBlockAlign == 1152
- && s->strh.dwScale == 1 && s->strh.dwRate != wfe->nSamplesPerSec) {
- // correcting encoder bugs...
- s->strh.dwScale = 1152;
- s->strh.dwRate = wfe->nSamplesPerSec;
- }
- }
-
- if (!m_isamv && (FAILED(BuildIndex()))) {
- EmptyIndex();
- }
-
- return S_OK;
+ Seek(0);
+ DWORD dw[3];
+ if (S_OK != Read(dw) || dw[0] != FCC('RIFF') || (dw[2] != FCC('AVI ') && dw[2] != FCC('AVIX') && dw[2] != FCC('AMV '))) {
+ return E_FAIL;
+ }
+
+ m_isamv = (dw[2] == FCC('AMV '));
+ Seek(0);
+ HRESULT hr = Parse(0, GetLength());
+ UNREFERENCED_PARAMETER(hr);
+ if (m_movis.GetCount() == 0) { // FAILED(hr) is allowed as long as there was a movi chunk found
+ return E_FAIL;
+ }
+
+ if (m_avih.dwStreams == 0 && m_strms.GetCount() > 0) {
+ m_avih.dwStreams = (DWORD)m_strms.GetCount();
+ }
+
+ if (m_avih.dwStreams != m_strms.GetCount()) {
+ return E_FAIL;
+ }
+
+ for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
+ strm_t* s = m_strms[i];
+ if (s->strh.fccType != FCC('auds')) {
+ continue;
+ }
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)s->strf.GetData();
+ if (wfe->wFormatTag == 0x55 && wfe->nBlockAlign == 1152
+ && s->strh.dwScale == 1 && s->strh.dwRate != wfe->nSamplesPerSec) {
+ // correcting encoder bugs...
+ s->strh.dwScale = 1152;
+ s->strh.dwRate = wfe->nSamplesPerSec;
+ }
+ }
+
+ if (!m_isamv && (FAILED(BuildIndex()))) {
+ EmptyIndex();
+ }
+
+ return S_OK;
}
HRESULT CAviFile::BuildAMVIndex()
{
- strm_t::chunk NewChunk;
- DWORD ulType;
- DWORD ulSize;
-
- memset (&NewChunk, 0, sizeof(strm_t::chunk));
- while ((Read(ulType) == S_OK) && (Read(ulSize) == S_OK)) {
- switch (ulType) {
- case FCC('00dc'): // 01bw : JPeg
- NewChunk.size = ulSize;
- NewChunk.filepos = GetPos();
- NewChunk.orgsize = ulSize;
- NewChunk.fKeyFrame = true;
- m_strms[0]->cs.Add (NewChunk);
- break;
- case FCC('01wb'): // 00dc : Audio
- NewChunk.size = ulSize;
- NewChunk.orgsize = ulSize;
- NewChunk.fKeyFrame = true;
- NewChunk.filepos = GetPos();
- m_strms[1]->cs.Add (NewChunk);
- break;
- }
- Seek(GetPos() + ulSize);
- }
-
- TRACE ("Video packet : %d Audio packet :%d\n", m_strms[0]->cs.GetCount(), m_strms[1]->cs.GetCount());
- return S_OK;
+ strm_t::chunk NewChunk;
+ DWORD ulType;
+ DWORD ulSize;
+
+ memset(&NewChunk, 0, sizeof(strm_t::chunk));
+ while ((Read(ulType) == S_OK) && (Read(ulSize) == S_OK)) {
+ switch (ulType) {
+ case FCC('00dc'): // 01bw : JPeg
+ NewChunk.size = ulSize;
+ NewChunk.filepos = GetPos();
+ NewChunk.orgsize = ulSize;
+ NewChunk.fKeyFrame = true;
+ m_strms[0]->cs.Add(NewChunk);
+ break;
+ case FCC('01wb'): // 00dc : Audio
+ NewChunk.size = ulSize;
+ NewChunk.orgsize = ulSize;
+ NewChunk.fKeyFrame = true;
+ NewChunk.filepos = GetPos();
+ m_strms[1]->cs.Add(NewChunk);
+ break;
+ }
+ Seek(GetPos() + ulSize);
+ }
+
+ TRACE("Video packet : %d Audio packet :%d\n", m_strms[0]->cs.GetCount(), m_strms[1]->cs.GetCount());
+ return S_OK;
}
HRESULT CAviFile::Parse(DWORD parentid, __int64 end)
{
- HRESULT hr = S_OK;
-
- CAutoPtr<strm_t> strm;
-
- while (S_OK == hr && GetPos() < end) {
- UINT64 pos = GetPos();
-
- DWORD id = 0, size;
- if (S_OK != Read(id) || id == 0) {
- return E_FAIL;
- }
-
- if (id == FCC('RIFF') || id == FCC('LIST')) {
- if (S_OK != Read(size) || S_OK != Read(id)) {
- return E_FAIL;
- }
-
- if (m_isamv) {
- size = (DWORD)(min(end, DWORD_MAX) - GetPos() - 8); // No size set in AVM : guess end of file...
- }
- size += (size&1) + 8;
-
- TRACE(_T("CAviFile::Parse(..): LIST '%c%c%c%c'\n"),
- TCHAR((id>>0)&0xff),
- TCHAR((id>>8)&0xff),
- TCHAR((id>>16)&0xff),
- TCHAR((id>>24)&0xff));
-
- if (id == FCC('movi')) {
- m_movis.AddTail(pos);
- if (m_isamv) {
- BuildAMVIndex();
- }
- } else {
- hr = Parse(id, pos + size);
- }
- } else {
- if (S_OK != Read(size)) {
- return E_FAIL;
- }
-
- TRACE(_T("CAviFile::Parse(..): '%c%c%c%c'\n"),
- TCHAR((id>>0)&0xff),
- TCHAR((id>>8)&0xff),
- TCHAR((id>>16)&0xff),
- TCHAR((id>>24)&0xff));
-
- if (parentid == FCC('INFO') && size > 0) {
- switch (id) {
- case FCC('IARL'): // Archival Location. Indicates where the subject of the file is archived.
- case FCC('IART'): // Artist. Lists the artist of the original subject of the file; for example, "Michaelangelo."
- case FCC('ICMS'): // Commissioned. Lists the name of the person or organization that commissioned the subject of the file; for example, "Pope Julian II."
- case FCC('ICMT'): // Comments. Provides general comments about the file or the subject of the file. If the comment is several sentences long, end each sentence with a period. Do not include new-line characters.
- case FCC('ICOP'): // Copyright. Records the copyright information for the file; for example, "Copyright Encyclopedia International 1991." If there are multiple copyrights, separate them by a semicolon followed by a space.
- case FCC('ICRD'): // Creation date. Specifies the date the subject of the file was created. List dates in year-month-day format, padding one-digit months and days with a zero on the left; for example, "1553-05-03" for May 3, 1553.
- case FCC('ICRP'): // Cropped. Describes whether an image has been cropped and, if so, how it was cropped; for example, "lower-right corner."
- case FCC('IDIM'): // Dimensions. Specifies the size of the original subject of the file; for example, "8.5 in h, 11 in w."
- case FCC('IDPI'): // Dots Per Inch. Stores dots per inch setting of the digitizer used to produce the file, such as "300."
- case FCC('IENG'): // Engineer. Stores the name of the engineer who worked on the file. If there are multiple engineers, separate the names by a semicolon and a blank; for example, "Smith, John; Adams, Joe."
- case FCC('IGNR'): // Genre. Describes the original work, such as "landscape," "portrait," "still life," etc.
- case FCC('IKEY'): // Keywords. Provides a list of keywords that refer to the file or subject of the file. Separate multiple keywords with a semicolon and a blank; for example, "Seattle; aerial view; scenery."
- case FCC('ILGT'): // Lightness. Describes the changes in lightness settings on the digitizer required to produce the file. Note that the format of this information depends on hardware used.
- case FCC('IMED'): // Medium. Describes the original subject of the file, such as "computer image," "drawing," "lithograph," and so on.
- case FCC('INAM'): // Name. Stores the title of the subject of the file, such as "Seattle From Above."
- case FCC('IPLT'): // Palette Setting. Specifies the number of colors requested when digitizing an image, such as "256."
- case FCC('IPRD'): // Product. Specifies the name of the title the file was originally intended for, such as "Encyclopedia of Pacific Northwest Geography."
- case FCC('ISBJ'): // Subject. Describes the contents of the file, such as "Aerial view of Seattle."
- case FCC('ISFT'): // Software. Identifies the name of the software package used to create the file, such as "Microsoft WaveEdit."
- case FCC('ISHP'): // Sharpness. Identifies the changes in sharpness for the digitizer required to produce the file (the format depends on the hardware used).
- case FCC('ISRC'): // Source. Identifies the name of the person or organization who supplied the original subject of the file; for example, "Trey Research."
- case FCC('ISRF'): // Source Form. Identifies the original form of the material that was digitized, such as "slide," "paper," "map," and so on. This is not necessarily the same as IMED.
- case FCC('ITCH'): { // Technician. Identifies the technician who digitized the subject file; for example, "Smith, John."
- CStringA str;
- if (S_OK != ByteRead((BYTE*)str.GetBufferSetLength(size), size)) {
- return E_FAIL;
- }
- m_info[id] = str;
- break;
- }
- }
- }
-
- switch (id) {
- case FCC('amvh'):
- case FCC('avih'):
- m_avih.fcc = id;
- m_avih.cb = size;
- if (S_OK != Read(m_avih, 8)) {
- return E_FAIL;
- }
- break;
- case FCC('strh'):
- if (!strm) {
- strm.Attach(DNew strm_t());
- }
- strm->strh.fcc = FCC('strh');
- strm->strh.cb = size;
- if (S_OK != Read(strm->strh, 8)) {
- return E_FAIL;
- }
- if (m_isamv) {
- // First alway video, second always audio
- strm->strh.fccType = m_strms.GetCount() == 0 ? FCC('vids') : FCC('amva');
- strm->strh.dwRate = m_avih.dwReserved[0]*1000; // dwReserved[0] = fps!
- strm->strh.dwScale = 1000;
- }
- break;
- case FCC('strn'):
- if (S_OK != ByteRead((BYTE*)strm->strn.GetBufferSetLength(size), size)) {
- return E_FAIL;
- }
- break;
- case FCC('strf'):
- if (!strm) {
- strm.Attach(DNew strm_t());
- }
- strm->strf.SetCount(size);
- if (S_OK != ByteRead(strm->strf.GetData(), size)) {
- return E_FAIL;
- }
- if (m_isamv) {
- if (strm->strh.fccType == FCC('vids')) {
- strm->strf.SetCount(sizeof(BITMAPINFOHEADER));
- BITMAPINFOHEADER* pbmi = &((BITMAPINFO*)strm->strf.GetData())->bmiHeader;
- pbmi->biSize = sizeof(BITMAPINFOHEADER);
- pbmi->biHeight = m_avih.dwHeight;
- pbmi->biWidth = m_avih.dwWidth;
- pbmi->biCompression = FCC('AMVV');
- pbmi->biPlanes = 1;
- pbmi->biBitCount = 24;
- pbmi->biSizeImage = pbmi->biHeight * pbmi->biWidth * (pbmi->biBitCount/8);
- }
- m_strms.Add(strm);
- }
-
- break;
- case FCC('indx'):
- if (!strm) {
- strm.Attach(DNew strm_t());
- }
- ASSERT(strm->indx == NULL);
- AVISUPERINDEX* pSuperIndex;
- if (size < MAXDWORD-8) {
- // Fix buffer overrun vulnerability : http://www.vulnhunt.com/advisories/CAL-20070912-1_Multiple_vendor_produce_handling_AVI_file_vulnerabilities.txt
- TRY {
- pSuperIndex = (AVISUPERINDEX*)DNew unsigned char [(size_t)(size + 8)];
- }
- CATCH (CMemoryException, e) {
- pSuperIndex = NULL;
- }
- END_CATCH
- if (pSuperIndex) {
- strm->indx.Attach(pSuperIndex);
- strm->indx->fcc = FCC('indx');
- strm->indx->cb = size;
- if (S_OK != ByteRead((BYTE*)(AVISUPERINDEX*)strm->indx + 8, size)) {
- return E_FAIL;
- }
- ASSERT(strm->indx->wLongsPerEntry == 4 && strm->indx->bIndexType == AVI_INDEX_OF_INDEXES);
- }
- }
- break;
- case FCC('dmlh'):
- if (S_OK != Read(m_dmlh)) {
- return E_FAIL;
- }
- break;
- case FCC('vprp'):
- //if (S_OK != Read(m_vprp)) return E_FAIL;
- break;
- case FCC('idx1'):
- ASSERT(m_idx1 == NULL);
- m_idx1.Attach((AVIOLDINDEX*)DNew BYTE[size + 8]);
- m_idx1->fcc = FCC('idx1');
- m_idx1->cb = size;
- if (S_OK != ByteRead((BYTE*)(AVIOLDINDEX*)m_idx1 + 8, size)) {
- return E_FAIL;
- }
- break;
- default :
- TRACE(_T("CAviFile::Parse(..): unknown tag '%c%c%c%c'\n"),
- TCHAR((id>>0)&0xff),
- TCHAR((id>>8)&0xff),
- TCHAR((id>>16)&0xff),
- TCHAR((id>>24)&0xff));
- break;
- }
-
- size += (size&1) + 8;
- }
-
- Seek(pos + size);
- }
-
- if (strm) {
- m_strms.Add(strm);
- }
-
- return hr;
+ HRESULT hr = S_OK;
+
+ CAutoPtr<strm_t> strm;
+
+ while (S_OK == hr && GetPos() < end) {
+ UINT64 pos = GetPos();
+
+ DWORD id = 0, size;
+ if (S_OK != Read(id) || id == 0) {
+ return E_FAIL;
+ }
+
+ if (id == FCC('RIFF') || id == FCC('LIST')) {
+ if (S_OK != Read(size) || S_OK != Read(id)) {
+ return E_FAIL;
+ }
+
+ if (m_isamv) {
+ size = (DWORD)(min(end, DWORD_MAX) - GetPos() - 8); // No size set in AVM : guess end of file...
+ }
+ size += (size & 1) + 8;
+
+ TRACE(_T("CAviFile::Parse(..): LIST '%c%c%c%c'\n"),
+ TCHAR((id >> 0) & 0xff),
+ TCHAR((id >> 8) & 0xff),
+ TCHAR((id >> 16) & 0xff),
+ TCHAR((id >> 24) & 0xff));
+
+ if (id == FCC('movi')) {
+ m_movis.AddTail(pos);
+ if (m_isamv) {
+ BuildAMVIndex();
+ }
+ } else {
+ hr = Parse(id, pos + size);
+ }
+ } else {
+ if (S_OK != Read(size)) {
+ return E_FAIL;
+ }
+
+ TRACE(_T("CAviFile::Parse(..): '%c%c%c%c'\n"),
+ TCHAR((id >> 0) & 0xff),
+ TCHAR((id >> 8) & 0xff),
+ TCHAR((id >> 16) & 0xff),
+ TCHAR((id >> 24) & 0xff));
+
+ if (parentid == FCC('INFO') && size > 0) {
+ switch (id) {
+ case FCC('IARL'): // Archival Location. Indicates where the subject of the file is archived.
+ case FCC('IART'): // Artist. Lists the artist of the original subject of the file; for example, "Michaelangelo."
+ case FCC('ICMS'): // Commissioned. Lists the name of the person or organization that commissioned the subject of the file; for example, "Pope Julian II."
+ case FCC('ICMT'): // Comments. Provides general comments about the file or the subject of the file. If the comment is several sentences long, end each sentence with a period. Do not include new-line characters.
+ case FCC('ICOP'): // Copyright. Records the copyright information for the file; for example, "Copyright Encyclopedia International 1991." If there are multiple copyrights, separate them by a semicolon followed by a space.
+ case FCC('ICRD'): // Creation date. Specifies the date the subject of the file was created. List dates in year-month-day format, padding one-digit months and days with a zero on the left; for example, "1553-05-03" for May 3, 1553.
+ case FCC('ICRP'): // Cropped. Describes whether an image has been cropped and, if so, how it was cropped; for example, "lower-right corner."
+ case FCC('IDIM'): // Dimensions. Specifies the size of the original subject of the file; for example, "8.5 in h, 11 in w."
+ case FCC('IDPI'): // Dots Per Inch. Stores dots per inch setting of the digitizer used to produce the file, such as "300."
+ case FCC('IENG'): // Engineer. Stores the name of the engineer who worked on the file. If there are multiple engineers, separate the names by a semicolon and a blank; for example, "Smith, John; Adams, Joe."
+ case FCC('IGNR'): // Genre. Describes the original work, such as "landscape," "portrait," "still life," etc.
+ case FCC('IKEY'): // Keywords. Provides a list of keywords that refer to the file or subject of the file. Separate multiple keywords with a semicolon and a blank; for example, "Seattle; aerial view; scenery."
+ case FCC('ILGT'): // Lightness. Describes the changes in lightness settings on the digitizer required to produce the file. Note that the format of this information depends on hardware used.
+ case FCC('IMED'): // Medium. Describes the original subject of the file, such as "computer image," "drawing," "lithograph," and so on.
+ case FCC('INAM'): // Name. Stores the title of the subject of the file, such as "Seattle From Above."
+ case FCC('IPLT'): // Palette Setting. Specifies the number of colors requested when digitizing an image, such as "256."
+ case FCC('IPRD'): // Product. Specifies the name of the title the file was originally intended for, such as "Encyclopedia of Pacific Northwest Geography."
+ case FCC('ISBJ'): // Subject. Describes the contents of the file, such as "Aerial view of Seattle."
+ case FCC('ISFT'): // Software. Identifies the name of the software package used to create the file, such as "Microsoft WaveEdit."
+ case FCC('ISHP'): // Sharpness. Identifies the changes in sharpness for the digitizer required to produce the file (the format depends on the hardware used).
+ case FCC('ISRC'): // Source. Identifies the name of the person or organization who supplied the original subject of the file; for example, "Trey Research."
+ case FCC('ISRF'): // Source Form. Identifies the original form of the material that was digitized, such as "slide," "paper," "map," and so on. This is not necessarily the same as IMED.
+ case FCC('ITCH'): { // Technician. Identifies the technician who digitized the subject file; for example, "Smith, John."
+ CStringA str;
+ if (S_OK != ByteRead((BYTE*)str.GetBufferSetLength(size), size)) {
+ return E_FAIL;
+ }
+ m_info[id] = str;
+ break;
+ }
+ }
+ }
+
+ switch (id) {
+ case FCC('amvh'):
+ case FCC('avih'):
+ m_avih.fcc = id;
+ m_avih.cb = size;
+ if (S_OK != Read(m_avih, 8)) {
+ return E_FAIL;
+ }
+ break;
+ case FCC('strh'):
+ if (!strm) {
+ strm.Attach(DNew strm_t());
+ }
+ strm->strh.fcc = FCC('strh');
+ strm->strh.cb = size;
+ if (S_OK != Read(strm->strh, 8)) {
+ return E_FAIL;
+ }
+ if (m_isamv) {
+ // First alway video, second always audio
+ strm->strh.fccType = m_strms.GetCount() == 0 ? FCC('vids') : FCC('amva');
+ strm->strh.dwRate = m_avih.dwReserved[0] * 1000; // dwReserved[0] = fps!
+ strm->strh.dwScale = 1000;
+ }
+ break;
+ case FCC('strn'):
+ if (S_OK != ByteRead((BYTE*)strm->strn.GetBufferSetLength(size), size)) {
+ return E_FAIL;
+ }
+ break;
+ case FCC('strf'):
+ if (!strm) {
+ strm.Attach(DNew strm_t());
+ }
+ strm->strf.SetCount(size);
+ if (S_OK != ByteRead(strm->strf.GetData(), size)) {
+ return E_FAIL;
+ }
+ if (m_isamv) {
+ if (strm->strh.fccType == FCC('vids')) {
+ strm->strf.SetCount(sizeof(BITMAPINFOHEADER));
+ BITMAPINFOHEADER* pbmi = &((BITMAPINFO*)strm->strf.GetData())->bmiHeader;
+ pbmi->biSize = sizeof(BITMAPINFOHEADER);
+ pbmi->biHeight = m_avih.dwHeight;
+ pbmi->biWidth = m_avih.dwWidth;
+ pbmi->biCompression = FCC('AMVV');
+ pbmi->biPlanes = 1;
+ pbmi->biBitCount = 24;
+ pbmi->biSizeImage = pbmi->biHeight * pbmi->biWidth * (pbmi->biBitCount / 8);
+ }
+ m_strms.Add(strm);
+ }
+
+ break;
+ case FCC('indx'):
+ if (!strm) {
+ strm.Attach(DNew strm_t());
+ }
+ ASSERT(strm->indx == NULL);
+ AVISUPERINDEX* pSuperIndex;
+ if (size < MAXDWORD - 8) {
+ // Fix buffer overrun vulnerability : http://www.vulnhunt.com/advisories/CAL-20070912-1_Multiple_vendor_produce_handling_AVI_file_vulnerabilities.txt
+ TRY {
+ pSuperIndex = (AVISUPERINDEX*)DNew unsigned char [(size_t)(size + 8)];
+ }
+ CATCH(CMemoryException, e) {
+ pSuperIndex = NULL;
+ }
+ END_CATCH
+ if (pSuperIndex) {
+ strm->indx.Attach(pSuperIndex);
+ strm->indx->fcc = FCC('indx');
+ strm->indx->cb = size;
+ if (S_OK != ByteRead((BYTE*)(AVISUPERINDEX*)strm->indx + 8, size)) {
+ return E_FAIL;
+ }
+ ASSERT(strm->indx->wLongsPerEntry == 4 && strm->indx->bIndexType == AVI_INDEX_OF_INDEXES);
+ }
+ }
+ break;
+ case FCC('dmlh'):
+ if (S_OK != Read(m_dmlh)) {
+ return E_FAIL;
+ }
+ break;
+ case FCC('vprp'):
+ //if (S_OK != Read(m_vprp)) return E_FAIL;
+ break;
+ case FCC('idx1'):
+ ASSERT(m_idx1 == NULL);
+ m_idx1.Attach((AVIOLDINDEX*)DNew BYTE[size + 8]);
+ m_idx1->fcc = FCC('idx1');
+ m_idx1->cb = size;
+ if (S_OK != ByteRead((BYTE*)(AVIOLDINDEX*)m_idx1 + 8, size)) {
+ return E_FAIL;
+ }
+ break;
+ default :
+ TRACE(_T("CAviFile::Parse(..): unknown tag '%c%c%c%c'\n"),
+ TCHAR((id >> 0) & 0xff),
+ TCHAR((id >> 8) & 0xff),
+ TCHAR((id >> 16) & 0xff),
+ TCHAR((id >> 24) & 0xff));
+ break;
+ }
+
+ size += (size & 1) + 8;
+ }
+
+ Seek(pos + size);
+ }
+
+ if (strm) {
+ m_strms.Add(strm);
+ }
+
+ return hr;
}
REFERENCE_TIME CAviFile::GetTotalTime()
{
- REFERENCE_TIME t = 0/*10i64*m_avih.dwMicroSecPerFrame*m_avih.dwTotalFrames*/;
+ REFERENCE_TIME t = 0/*10i64*m_avih.dwMicroSecPerFrame*m_avih.dwTotalFrames*/;
- for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
- strm_t* s = m_strms[i];
- REFERENCE_TIME t2 = s->GetRefTime((DWORD)s->cs.GetCount(), s->totalsize);
- t = max(t, t2);
- }
+ for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
+ strm_t* s = m_strms[i];
+ REFERENCE_TIME t2 = s->GetRefTime((DWORD)s->cs.GetCount(), s->totalsize);
+ t = max(t, t2);
+ }
- if (t == 0) {
- t = 10i64*m_avih.dwMicroSecPerFrame*m_avih.dwTotalFrames;
- }
+ if (t == 0) {
+ t = 10i64 * m_avih.dwMicroSecPerFrame * m_avih.dwTotalFrames;
+ }
- return t;
+ return t;
}
HRESULT CAviFile::BuildIndex()
{
- EmptyIndex();
-
- DWORD nSuperIndexes = 0;
-
- for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
- strm_t* s = m_strms[i];
- if (s->indx && s->indx->nEntriesInUse > 0) {
- ++nSuperIndexes;
- }
- }
-
- if (nSuperIndexes == m_avih.dwStreams) {
- for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
- strm_t* s = m_strms[i];
-
- AVISUPERINDEX* idx = (AVISUPERINDEX*)s->indx;
-
- DWORD nEntriesInUse = 0;
-
- for (DWORD j = 0; j < idx->nEntriesInUse; ++j) {
- Seek(idx->aIndex[j].qwOffset);
-
- AVISTDINDEX stdidx;
- if (S_OK != ByteRead((BYTE*)&stdidx, FIELD_OFFSET(AVISTDINDEX, aIndex))) {
- EmptyIndex();
- return E_FAIL;
- }
-
- nEntriesInUse += stdidx.nEntriesInUse;
- }
-
- s->cs.SetCount(nEntriesInUse);
-
- DWORD frame = 0;
- UINT64 size = 0;
-
- for (DWORD j = 0; j < idx->nEntriesInUse; ++j) {
- Seek(idx->aIndex[j].qwOffset);
-
- CAutoPtr<AVISTDINDEX> p((AVISTDINDEX*)DNew BYTE[idx->aIndex[j].dwSize]);
- if (!p || S_OK != ByteRead((BYTE*)(AVISTDINDEX*)p, idx->aIndex[j].dwSize) || p->qwBaseOffset >= (DWORDLONG)GetLength()) {
- EmptyIndex();
- return E_FAIL;
- }
-
- for (DWORD k = 0; k < p->nEntriesInUse; ++k) {
- s->cs[frame].size = size;
- s->cs[frame].filepos = p->qwBaseOffset + p->aIndex[k].dwOffset;
- s->cs[frame].fKeyFrame = !(p->aIndex[k].dwSize&AVISTDINDEX_DELTAFRAME)
- || s->strh.fccType == FCC('auds');
- s->cs[frame].fChunkHdr = false;
- s->cs[frame].orgsize = p->aIndex[k].dwSize&AVISTDINDEX_SIZEMASK;
-
- if (m_idx1) {
- s->cs[frame].filepos -= 8;
- s->cs[frame].fChunkHdr = true;
- }
-
- ++frame;
- size += s->GetChunkSize(p->aIndex[k].dwSize&AVISTDINDEX_SIZEMASK);
- }
- }
-
- s->totalsize = size;
- }
- } else if (AVIOLDINDEX* idx = m_idx1) {
- DWORD len = idx->cb / sizeof(idx->aIndex[0]);
-
- UINT64 offset = m_movis.GetHead() + 8;
-
- //detect absolute chunk addressing (TODO: read AVI specification and make it better)
- if (idx->aIndex[0].dwOffset > offset) {
- DWORD id;
- Seek(offset + idx->aIndex[0].dwOffset);
- Read(id);
- if (id != idx->aIndex[0].dwChunkId) {
- TRACE(_T("WARNING: CAviFile::Init() detected absolute chunk addressing in \'idx1\'"));
- offset = 0;
- }
- }
-
- for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
- strm_t* s = m_strms[i];
-
- // calculate the number of frames and set index size before using it
- DWORD nFrames = 0;
- for (DWORD j = 0; j < len; ++j) {
- if (TRACKNUM(idx->aIndex[j].dwChunkId) == i) {
- ++nFrames;
- }
- }
- s->cs.SetCount(nFrames);
-
- //read index
- DWORD frame = 0;
- UINT64 size = 0;
- for (DWORD j = 0; j < len; ++j) {
- DWORD TrackNumber = TRACKNUM(idx->aIndex[j].dwChunkId);
-
- if (TrackNumber == i) {
- s->cs[frame].size = size;
- s->cs[frame].filepos = offset + idx->aIndex[j].dwOffset;
- s->cs[frame].fKeyFrame = !!(idx->aIndex[j].dwFlags&AVIIF_KEYFRAME)
- || s->strh.fccType == FCC('auds') // FIXME: some audio index is without any kf flag
- || frame == 0; // grrr
- s->cs[frame].fChunkHdr = j == len-1 || idx->aIndex[j].dwOffset != idx->aIndex[j+1].dwOffset;
- s->cs[frame].orgsize = idx->aIndex[j].dwSize;
-
- ++frame;
- size += s->GetChunkSize(idx->aIndex[j].dwSize);
- }
- }
-
- s->totalsize = size;
- }
- }
-
- m_idx1.Free();
- for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
- m_strms[i]->indx.Free();
- }
-
- return S_OK;
+ EmptyIndex();
+
+ DWORD nSuperIndexes = 0;
+
+ for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
+ strm_t* s = m_strms[i];
+ if (s->indx && s->indx->nEntriesInUse > 0) {
+ ++nSuperIndexes;
+ }
+ }
+
+ if (nSuperIndexes == m_avih.dwStreams) {
+ for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
+ strm_t* s = m_strms[i];
+
+ AVISUPERINDEX* idx = (AVISUPERINDEX*)s->indx;
+
+ DWORD nEntriesInUse = 0;
+
+ for (DWORD j = 0; j < idx->nEntriesInUse; ++j) {
+ Seek(idx->aIndex[j].qwOffset);
+
+ AVISTDINDEX stdidx;
+ if (S_OK != ByteRead((BYTE*)&stdidx, FIELD_OFFSET(AVISTDINDEX, aIndex))) {
+ EmptyIndex();
+ return E_FAIL;
+ }
+
+ nEntriesInUse += stdidx.nEntriesInUse;
+ }
+
+ s->cs.SetCount(nEntriesInUse);
+
+ DWORD frame = 0;
+ UINT64 size = 0;
+
+ for (DWORD j = 0; j < idx->nEntriesInUse; ++j) {
+ Seek(idx->aIndex[j].qwOffset);
+
+ CAutoPtr<AVISTDINDEX> p((AVISTDINDEX*)DNew BYTE[idx->aIndex[j].dwSize]);
+ if (!p || S_OK != ByteRead((BYTE*)(AVISTDINDEX*)p, idx->aIndex[j].dwSize) || p->qwBaseOffset >= (DWORDLONG)GetLength()) {
+ EmptyIndex();
+ return E_FAIL;
+ }
+
+ for (DWORD k = 0; k < p->nEntriesInUse; ++k) {
+ s->cs[frame].size = size;
+ s->cs[frame].filepos = p->qwBaseOffset + p->aIndex[k].dwOffset;
+ s->cs[frame].fKeyFrame = !(p->aIndex[k].dwSize & AVISTDINDEX_DELTAFRAME)
+ || s->strh.fccType == FCC('auds');
+ s->cs[frame].fChunkHdr = false;
+ s->cs[frame].orgsize = p->aIndex[k].dwSize & AVISTDINDEX_SIZEMASK;
+
+ if (m_idx1) {
+ s->cs[frame].filepos -= 8;
+ s->cs[frame].fChunkHdr = true;
+ }
+
+ ++frame;
+ size += s->GetChunkSize(p->aIndex[k].dwSize & AVISTDINDEX_SIZEMASK);
+ }
+ }
+
+ s->totalsize = size;
+ }
+ } else if (AVIOLDINDEX* idx = m_idx1) {
+ DWORD len = idx->cb / sizeof(idx->aIndex[0]);
+
+ UINT64 offset = m_movis.GetHead() + 8;
+
+ //detect absolute chunk addressing (TODO: read AVI specification and make it better)
+ if (idx->aIndex[0].dwOffset > offset) {
+ DWORD id;
+ Seek(offset + idx->aIndex[0].dwOffset);
+ Read(id);
+ if (id != idx->aIndex[0].dwChunkId) {
+ TRACE(_T("WARNING: CAviFile::Init() detected absolute chunk addressing in \'idx1\'"));
+ offset = 0;
+ }
+ }
+
+ for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
+ strm_t* s = m_strms[i];
+
+ // calculate the number of frames and set index size before using it
+ DWORD nFrames = 0;
+ for (DWORD j = 0; j < len; ++j) {
+ if (TRACKNUM(idx->aIndex[j].dwChunkId) == i) {
+ ++nFrames;
+ }
+ }
+ s->cs.SetCount(nFrames);
+
+ //read index
+ DWORD frame = 0;
+ UINT64 size = 0;
+ for (DWORD j = 0; j < len; ++j) {
+ DWORD TrackNumber = TRACKNUM(idx->aIndex[j].dwChunkId);
+
+ if (TrackNumber == i) {
+ s->cs[frame].size = size;
+ s->cs[frame].filepos = offset + idx->aIndex[j].dwOffset;
+ s->cs[frame].fKeyFrame = !!(idx->aIndex[j].dwFlags & AVIIF_KEYFRAME)
+ || s->strh.fccType == FCC('auds') // FIXME: some audio index is without any kf flag
+ || frame == 0; // grrr
+ s->cs[frame].fChunkHdr = j == len - 1 || idx->aIndex[j].dwOffset != idx->aIndex[j + 1].dwOffset;
+ s->cs[frame].orgsize = idx->aIndex[j].dwSize;
+
+ ++frame;
+ size += s->GetChunkSize(idx->aIndex[j].dwSize);
+ }
+ }
+
+ s->totalsize = size;
+ }
+ }
+
+ m_idx1.Free();
+ for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
+ m_strms[i]->indx.Free();
+ }
+
+ return S_OK;
}
void CAviFile::EmptyIndex()
{
- for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
- strm_t* s = m_strms[i];
- s->cs.RemoveAll();
- s->totalsize = 0;
- }
+ for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
+ strm_t* s = m_strms[i];
+ s->cs.RemoveAll();
+ s->totalsize = 0;
+ }
}
bool CAviFile::IsInterleaved(bool fKeepInfo)
{
- if (m_strms.GetCount() < 2) {
- return true;
- }
- /*
- if (m_avih.dwFlags&AVIF_ISINTERLEAVED) // not reliable, nandub can write f*cked up files and still sets it
- return true;
- */
- for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
- m_strms[i]->cs2.SetCount(m_strms[i]->cs.GetCount());
- }
-
- DWORD* curchunks = DNew DWORD[m_avih.dwStreams];
- UINT64* cursizes = DNew UINT64[m_avih.dwStreams];
-
- memset(curchunks, 0, sizeof(DWORD)*m_avih.dwStreams);
- memset(cursizes, 0, sizeof(UINT64)*m_avih.dwStreams);
-
- int end = 0;
-
- for (;;) {
- UINT64 fpmin = _I64_MAX;
-
- DWORD n = (DWORD)-1;
- for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
- DWORD curchunk = curchunks[i];
- CAtlArray<strm_t::chunk>& cs = m_strms[i]->cs;
- if (curchunk >= cs.GetCount()) {
- continue;
- }
- UINT64 fp = cs[curchunk].filepos;
- if (fp < fpmin) {
- fpmin = fp;
- n = i;
- }
- }
- if (n == -1) {
- break;
- }
-
- strm_t* s = m_strms[n];
- DWORD& curchunk = curchunks[n];
- UINT64& cursize = cursizes[n];
-
- if (!s->IsRawSubtitleStream()) {
- strm_t::chunk2& cs2 = s->cs2[curchunk];
- cs2.t = (DWORD)(s->GetRefTime(curchunk, cursize)>>13); // for comparing later it is just as good as /10000 to get a near [ms] accuracy
- //cs2.t = (DWORD)(s->GetRefTime(curchunk, cursize)/10000);
- cs2.n = end++;
- }
-
- cursize = s->cs[curchunk].size;
- ++curchunk;
- }
-
- memset(curchunks, 0, sizeof(DWORD)*m_avih.dwStreams);
-
- strm_t::chunk2 cs2last = {(DWORD)-1, 0};
-
- bool fInterleaved = true;
-
- while (fInterleaved) {
- strm_t::chunk2 cs2min = {LONG_MAX, LONG_MAX};
-
- DWORD n = (DWORD)-1;
- for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
- DWORD curchunk = curchunks[i];
- if (curchunk >= m_strms[i]->cs2.GetCount()) {
- continue;
- }
- strm_t::chunk2& cs2 = m_strms[i]->cs2[curchunk];
- if (cs2.t < cs2min.t) {
- cs2min = cs2;
- n = i;
- }
- }
- if (n == -1) {
- break;
- }
-
- ++curchunks[n];
-
- if (cs2last.t != (DWORD)-1 && abs((int)cs2min.n - (int)cs2last.n) >= 1000) {
- fInterleaved = false;
- }
-
- cs2last = cs2min;
- }
-
- delete [] curchunks;
- delete [] cursizes;
-
- if (fInterleaved && !fKeepInfo) {
- // this is not needed anymore, let's save a little memory then
- for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
- m_strms[i]->cs2.RemoveAll();
- }
- }
-
- return fInterleaved;
+ if (m_strms.GetCount() < 2) {
+ return true;
+ }
+ /*
+ if (m_avih.dwFlags&AVIF_ISINTERLEAVED) // not reliable, nandub can write f*cked up files and still sets it
+ return true;
+ */
+ for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
+ m_strms[i]->cs2.SetCount(m_strms[i]->cs.GetCount());
+ }
+
+ DWORD* curchunks = DNew DWORD[m_avih.dwStreams];
+ UINT64* cursizes = DNew UINT64[m_avih.dwStreams];
+
+ memset(curchunks, 0, sizeof(DWORD)*m_avih.dwStreams);
+ memset(cursizes, 0, sizeof(UINT64)*m_avih.dwStreams);
+
+ int end = 0;
+
+ for (;;) {
+ UINT64 fpmin = _I64_MAX;
+
+ DWORD n = (DWORD) - 1;
+ for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
+ DWORD curchunk = curchunks[i];
+ CAtlArray<strm_t::chunk>& cs = m_strms[i]->cs;
+ if (curchunk >= cs.GetCount()) {
+ continue;
+ }
+ UINT64 fp = cs[curchunk].filepos;
+ if (fp < fpmin) {
+ fpmin = fp;
+ n = i;
+ }
+ }
+ if (n == -1) {
+ break;
+ }
+
+ strm_t* s = m_strms[n];
+ DWORD& curchunk = curchunks[n];
+ UINT64& cursize = cursizes[n];
+
+ if (!s->IsRawSubtitleStream()) {
+ strm_t::chunk2& cs2 = s->cs2[curchunk];
+ cs2.t = (DWORD)(s->GetRefTime(curchunk, cursize) >> 13); // for comparing later it is just as good as /10000 to get a near [ms] accuracy
+ //cs2.t = (DWORD)(s->GetRefTime(curchunk, cursize)/10000);
+ cs2.n = end++;
+ }
+
+ cursize = s->cs[curchunk].size;
+ ++curchunk;
+ }
+
+ memset(curchunks, 0, sizeof(DWORD)*m_avih.dwStreams);
+
+ strm_t::chunk2 cs2last = {(DWORD) - 1, 0};
+
+ bool fInterleaved = true;
+
+ while (fInterleaved) {
+ strm_t::chunk2 cs2min = {LONG_MAX, LONG_MAX};
+
+ DWORD n = (DWORD) - 1;
+ for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
+ DWORD curchunk = curchunks[i];
+ if (curchunk >= m_strms[i]->cs2.GetCount()) {
+ continue;
+ }
+ strm_t::chunk2& cs2 = m_strms[i]->cs2[curchunk];
+ if (cs2.t < cs2min.t) {
+ cs2min = cs2;
+ n = i;
+ }
+ }
+ if (n == -1) {
+ break;
+ }
+
+ ++curchunks[n];
+
+ if (cs2last.t != (DWORD) - 1 && abs((int)cs2min.n - (int)cs2last.n) >= 1000) {
+ fInterleaved = false;
+ }
+
+ cs2last = cs2min;
+ }
+
+ delete [] curchunks;
+ delete [] cursizes;
+
+ if (fInterleaved && !fKeepInfo) {
+ // this is not needed anymore, let's save a little memory then
+ for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
+ m_strms[i]->cs2.RemoveAll();
+ }
+ }
+
+ return fInterleaved;
}
REFERENCE_TIME CAviFile::strm_t::GetRefTime(DWORD frame, UINT64 size)
{
- if (frame == 0 || strh.dwRate == 0) {
- return 0;
- }
- if (strh.fccType == FCC('auds')) {
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)strf.GetData();
- if (wfe->nBlockAlign == 0) {
- return 0;
- }
- return (REFERENCE_TIME)ceil(10000000.0 * size * strh.dwScale / (unsigned __int64(strh.dwRate) * wfe->nBlockAlign));
- // need calculate in double, because the (10000000ui64 * size * strh.dwScale) can give overflow
- // "ceil" is necessary to compensate for framenumber->reftime->framenumber conversion
- }
- return (REFERENCE_TIME)ceil(10000000.0 * frame * strh.dwScale / strh.dwRate);
- // need calculate in double, because the (10000000ui64 * frame * strh.dwScale) can give overflow (verified in practice)
- // "ceil" is necessary to compensate for framenumber->reftime->framenumber conversion
+ if (frame == 0 || strh.dwRate == 0) {
+ return 0;
+ }
+ if (strh.fccType == FCC('auds')) {
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)strf.GetData();
+ if (wfe->nBlockAlign == 0) {
+ return 0;
+ }
+ return (REFERENCE_TIME)ceil(10000000.0 * size * strh.dwScale / (unsigned __int64(strh.dwRate) * wfe->nBlockAlign));
+ // need calculate in double, because the (10000000ui64 * size * strh.dwScale) can give overflow
+ // "ceil" is necessary to compensate for framenumber->reftime->framenumber conversion
+ }
+ return (REFERENCE_TIME)ceil(10000000.0 * frame * strh.dwScale / strh.dwRate);
+ // need calculate in double, because the (10000000ui64 * frame * strh.dwScale) can give overflow (verified in practice)
+ // "ceil" is necessary to compensate for framenumber->reftime->framenumber conversion
}
DWORD CAviFile::strm_t::GetFrame(REFERENCE_TIME rt)
{
- DWORD frame;
-
- if (strh.dwScale == 0 || rt <= 0 || cs.GetCount() == 0) {
- frame = 0;
- } else if (strh.fccType == FCC('auds')) {
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)strf.GetData();
-
- UINT64 size = (UINT64)(double(rt) * wfe->nBlockAlign * strh.dwRate / (strh.dwScale * 10000000.0));
- // need calculate in double, because the (rt * wfe->nBlockAlign * strh.dwRate) can give overflow
- frame = 1;
- for (; frame < cs.GetCount(); ++frame) {
- if (cs[frame].size > size) {
- break;
- }
- }
- --frame;
- } else {
- frame = (DWORD)(double(rt) * strh.dwRate / (strh.dwScale * 10000000.0));
- // need calculate in double, because the (rt * strh.dwRate) can give overflow (verified in practice)
- if (frame >= cs.GetCount()) {
- frame = (DWORD)cs.GetCount() - 1;
- }
- }
-
- return frame;
+ DWORD frame;
+
+ if (strh.dwScale == 0 || rt <= 0 || cs.GetCount() == 0) {
+ frame = 0;
+ } else if (strh.fccType == FCC('auds')) {
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)strf.GetData();
+
+ UINT64 size = (UINT64)(double(rt) * wfe->nBlockAlign * strh.dwRate / (strh.dwScale * 10000000.0));
+ // need calculate in double, because the (rt * wfe->nBlockAlign * strh.dwRate) can give overflow
+ frame = 1;
+ for (; frame < cs.GetCount(); ++frame) {
+ if (cs[frame].size > size) {
+ break;
+ }
+ }
+ --frame;
+ } else {
+ frame = (DWORD)(double(rt) * strh.dwRate / (strh.dwScale * 10000000.0));
+ // need calculate in double, because the (rt * strh.dwRate) can give overflow (verified in practice)
+ if (frame >= cs.GetCount()) {
+ frame = (DWORD)cs.GetCount() - 1;
+ }
+ }
+
+ return frame;
}
DWORD CAviFile::strm_t::GetKeyFrame(REFERENCE_TIME rt)
{
- DWORD i = GetFrame(rt);
- for (; i > 0; i--) {
- if (cs[i].fKeyFrame) {
- break;
- }
- }
- return i;
+ DWORD i = GetFrame(rt);
+ for (; i > 0; i--) {
+ if (cs[i].fKeyFrame) {
+ break;
+ }
+ }
+ return i;
}
DWORD CAviFile::strm_t::GetChunkSize(DWORD size)
{
- if (strh.fccType == FCC('auds')) {
- WORD nBlockAlign = ((WAVEFORMATEX*)strf.GetData())->nBlockAlign;
- size = nBlockAlign ? (size + (nBlockAlign-1)) / nBlockAlign * nBlockAlign : 0; // round up for nando's vbr hack
- }
+ if (strh.fccType == FCC('auds')) {
+ WORD nBlockAlign = ((WAVEFORMATEX*)strf.GetData())->nBlockAlign;
+ size = nBlockAlign ? (size + (nBlockAlign - 1)) / nBlockAlign * nBlockAlign : 0; // round up for nando's vbr hack
+ }
- return size;
+ return size;
}
bool CAviFile::strm_t::IsRawSubtitleStream()
{
- return strn.Find("Subtitle") == 0 || strh.fccType == FCC('txts') && cs.GetCount() == 1;
+ return strn.Find("Subtitle") == 0 || strh.fccType == FCC('txts') && cs.GetCount() == 1;
}
diff --git a/src/filters/parser/AviSplitter/AviFile.h b/src/filters/parser/AviSplitter/AviFile.h
index df036811a..4f81dc793 100644
--- a/src/filters/parser/AviSplitter/AviFile.h
+++ b/src/filters/parser/AviSplitter/AviFile.h
@@ -28,63 +28,63 @@
class CAviFile : public CBaseSplitterFile
{
- HRESULT Init();
- HRESULT Parse(DWORD parentid, __int64 end);
- HRESULT BuildAMVIndex();
+ HRESULT Init();
+ HRESULT Parse(DWORD parentid, __int64 end);
+ HRESULT BuildAMVIndex();
public:
- CAviFile(IAsyncReader* pAsyncReader, HRESULT& hr);
+ CAviFile(IAsyncReader* pAsyncReader, HRESULT& hr);
- //using CBaseSplitterFile::Read;
- template<typename T>
- HRESULT Read(T& var, int offset = 0) {
- memset(&var, 0, sizeof(var));
- HRESULT hr = ByteRead((BYTE*)&var + offset, sizeof(var) - offset);
- return hr;
- }
+ //using CBaseSplitterFile::Read;
+ template<typename T>
+ HRESULT Read(T& var, int offset = 0) {
+ memset(&var, 0, sizeof(var));
+ HRESULT hr = ByteRead((BYTE*)&var + offset, sizeof(var) - offset);
+ return hr;
+ }
- AVIMAINHEADER m_avih;
- struct ODMLExtendedAVIHeader {
- DWORD dwTotalFrames;
- } m_dmlh;
- //VideoPropHeader m_vprp;
- struct strm_t {
- AVISTREAMHEADER strh;
- CAtlArray<BYTE> strf;
- CStringA strn;
- CAutoPtr<AVISUPERINDEX> indx;
- struct chunk {
- UINT64 fKeyFrame:1, fChunkHdr:1, size:62;
- UINT64 filepos;
- DWORD orgsize;
- };
- CAtlArray<chunk> cs;
- UINT64 totalsize;
- REFERENCE_TIME GetRefTime(DWORD frame, UINT64 size);
- int GetTime(DWORD frame, UINT64 size);
- DWORD GetFrame(REFERENCE_TIME rt);
- DWORD GetKeyFrame(REFERENCE_TIME rt);
- DWORD GetChunkSize(DWORD size);
- bool IsRawSubtitleStream();
+ AVIMAINHEADER m_avih;
+ struct ODMLExtendedAVIHeader {
+ DWORD dwTotalFrames;
+ } m_dmlh;
+ //VideoPropHeader m_vprp;
+ struct strm_t {
+ AVISTREAMHEADER strh;
+ CAtlArray<BYTE> strf;
+ CStringA strn;
+ CAutoPtr<AVISUPERINDEX> indx;
+ struct chunk {
+ UINT64 fKeyFrame: 1, fChunkHdr: 1, size: 62;
+ UINT64 filepos;
+ DWORD orgsize;
+ };
+ CAtlArray<chunk> cs;
+ UINT64 totalsize;
+ REFERENCE_TIME GetRefTime(DWORD frame, UINT64 size);
+ int GetTime(DWORD frame, UINT64 size);
+ DWORD GetFrame(REFERENCE_TIME rt);
+ DWORD GetKeyFrame(REFERENCE_TIME rt);
+ DWORD GetChunkSize(DWORD size);
+ bool IsRawSubtitleStream();
- // tmp
- struct chunk2 {
- DWORD t;
- DWORD n;
- };
- CAtlArray<chunk2> cs2;
- };
- CAutoPtrArray<strm_t> m_strms;
- CAtlMap<DWORD, CStringA> m_info;
- CAutoPtr<AVIOLDINDEX> m_idx1;
+ // tmp
+ struct chunk2 {
+ DWORD t;
+ DWORD n;
+ };
+ CAtlArray<chunk2> cs2;
+ };
+ CAutoPtrArray<strm_t> m_strms;
+ CAtlMap<DWORD, CStringA> m_info;
+ CAutoPtr<AVIOLDINDEX> m_idx1;
- CAtlList<UINT64> m_movis;
- bool m_isamv;
+ CAtlList<UINT64> m_movis;
+ bool m_isamv;
- REFERENCE_TIME GetTotalTime();
- HRESULT BuildIndex();
- void EmptyIndex();
- bool IsInterleaved(bool fKeepInfo = false);
+ REFERENCE_TIME GetTotalTime();
+ HRESULT BuildIndex();
+ void EmptyIndex();
+ bool IsInterleaved(bool fKeepInfo = false);
};
#define TRACKNUM(fcc) (10*((fcc&0xff)-0x30) + (((fcc>>8)&0xff)-0x30))
diff --git a/src/filters/parser/AviSplitter/AviReportWnd.cpp b/src/filters/parser/AviSplitter/AviReportWnd.cpp
index d23f397c3..e35f6701e 100644
--- a/src/filters/parser/AviSplitter/AviReportWnd.cpp
+++ b/src/filters/parser/AviSplitter/AviReportWnd.cpp
@@ -7,160 +7,160 @@
CAviReportWnd::CAviReportWnd()
{
- m_font.CreateFont(12, 0, 0, 0, 400, 0, 0, 0, 1, 0, 0, 0, 0, _T("MS Shell Dlg"));
+ m_font.CreateFont(12, 0, 0, 0, 400, 0, 0, 0, 1, 0, 0, 0, 0, _T("MS Shell Dlg"));
}
bool CAviReportWnd::DoModal(CAviFile* pAF, bool fHideChecked, bool fShowWarningText)
{
- m_nChunks = 0;
- m_rtDur = 0;
+ m_nChunks = 0;
+ m_rtDur = 0;
- for (DWORD i = 0; i < pAF->m_avih.dwStreams; ++i) {
- size_t cnt = pAF->m_strms[i]->cs2.GetCount();
- if (cnt == 0) {
- continue;
- }
- CAviFile::strm_t::chunk2& c2 = pAF->m_strms[i]->cs2[cnt-1];
- m_nChunks = max(m_nChunks, c2.n);
- m_rtDur = max(m_rtDur, (REFERENCE_TIME)c2.t<<13);
- }
+ for (DWORD i = 0; i < pAF->m_avih.dwStreams; ++i) {
+ size_t cnt = pAF->m_strms[i]->cs2.GetCount();
+ if (cnt == 0) {
+ continue;
+ }
+ CAviFile::strm_t::chunk2& c2 = pAF->m_strms[i]->cs2[cnt - 1];
+ m_nChunks = max(m_nChunks, c2.n);
+ m_rtDur = max(m_rtDur, (REFERENCE_TIME)c2.t << 13);
+ }
- CRect r, r2;
- GetDesktopWindow()->GetWindowRect(r);
- r.DeflateRect(r.Width()/4, r.Height()/4);
+ CRect r, r2;
+ GetDesktopWindow()->GetWindowRect(r);
+ r.DeflateRect(r.Width() / 4, r.Height() / 4);
- LPCTSTR wndclass = AfxRegisterWndClass(
- CS_VREDRAW|CS_HREDRAW|CS_DBLCLKS,
- AfxGetApp()->LoadStandardCursor(IDC_ARROW),
- (HBRUSH)(COLOR_BTNFACE + 1), 0);
+ LPCTSTR wndclass = AfxRegisterWndClass(
+ CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS,
+ AfxGetApp()->LoadStandardCursor(IDC_ARROW),
+ (HBRUSH)(COLOR_BTNFACE + 1), 0);
- CreateEx(0, wndclass, TITLE, WS_POPUPWINDOW|WS_CAPTION|WS_CLIPCHILDREN, r, NULL, 0);
+ CreateEx(0, wndclass, TITLE, WS_POPUPWINDOW | WS_CAPTION | WS_CLIPCHILDREN, r, NULL, 0);
- CRect cr;
- GetClientRect(cr);
- cr.DeflateRect(10, 10);
+ CRect cr;
+ GetClientRect(cr);
+ cr.DeflateRect(10, 10);
- SetFont(&m_font, FALSE);
+ SetFont(&m_font, FALSE);
- CDC* pDC = GetDC();
- CFont* pOldFont = pDC->SelectObject(&m_font);
+ CDC* pDC = GetDC();
+ CFont* pOldFont = pDC->SelectObject(&m_font);
- //
+ //
- CString str(
- _T("This AVI file was not prepared for sequential reading, the alternative ")
- _T("'Avi Splitter' will now let the default one handle it. ")
- _T("The complete reinterleaving of this file is strongly recommended before ")
- _T("burning it onto a slow media like cd-rom."));
+ CString str(
+ _T("This AVI file was not prepared for sequential reading, the alternative ")
+ _T("'Avi Splitter' will now let the default one handle it. ")
+ _T("The complete reinterleaving of this file is strongly recommended before ")
+ _T("burning it onto a slow media like cd-rom."));
- r = cr;
+ r = cr;
- pDC->DrawText(str, r, DT_WORDBREAK|DT_CALCRECT);
- r.right = cr.right;
+ pDC->DrawText(str, r, DT_WORDBREAK | DT_CALCRECT);
+ r.right = cr.right;
- m_message.Create(str, WS_CHILD|WS_VISIBLE, r, this);
- m_message.SetFont(&m_font, FALSE);
+ m_message.Create(str, WS_CHILD | WS_VISIBLE, r, this);
+ m_message.SetFont(&m_font, FALSE);
- //
+ //
- r.SetRect(cr.left, r.bottom + 10, cr.right, cr.bottom);
+ r.SetRect(cr.left, r.bottom + 10, cr.right, cr.bottom);
- str = _T("Do not show this dialog again (hold Shift to re-enable it)");
+ str = _T("Do not show this dialog again (hold Shift to re-enable it)");
- pDC->DrawText(str, r, DT_WORDBREAK|DT_CALCRECT);
- r.right = cr.right;
+ pDC->DrawText(str, r, DT_WORDBREAK | DT_CALCRECT);
+ r.right = cr.right;
- m_checkbox.Create(str, WS_CHILD|WS_VISIBLE|BS_CHECKBOX|BS_AUTOCHECKBOX, r, this, IDC_DONOTSHOWAGAINCHECK);
- m_checkbox.SetFont(&m_font, FALSE);
+ m_checkbox.Create(str, WS_CHILD | WS_VISIBLE | BS_CHECKBOX | BS_AUTOCHECKBOX, r, this, IDC_DONOTSHOWAGAINCHECK);
+ m_checkbox.SetFont(&m_font, FALSE);
- CheckDlgButton(IDC_DONOTSHOWAGAINCHECK, fHideChecked?BST_CHECKED:BST_UNCHECKED);
+ CheckDlgButton(IDC_DONOTSHOWAGAINCHECK, fHideChecked ? BST_CHECKED : BST_UNCHECKED);
- //
+ //
- if (!fShowWarningText) {
- m_message.ShowWindow(SW_HIDE);
- m_checkbox.ShowWindow(SW_HIDE);
- r = cr;
- } else {
- r.SetRect(cr.left, r.bottom + 10, cr.right, cr.bottom);
- }
+ if (!fShowWarningText) {
+ m_message.ShowWindow(SW_HIDE);
+ m_checkbox.ShowWindow(SW_HIDE);
+ r = cr;
+ } else {
+ r.SetRect(cr.left, r.bottom + 10, cr.right, cr.bottom);
+ }
- m_graph.Create(pAF, r, this);
+ m_graph.Create(pAF, r, this);
- //
+ //
- pDC->SelectObject(pOldFont);
- ReleaseDC(pDC);
+ pDC->SelectObject(pOldFont);
+ ReleaseDC(pDC);
- SetWindowPos(&wndTop, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
- SetForegroundWindow();
- ShowWindow(SW_SHOWNORMAL);
+ SetWindowPos(&wndTop, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
+ SetForegroundWindow();
+ ShowWindow(SW_SHOWNORMAL);
- return !!RunModalLoop();
+ return !!RunModalLoop();
}
IMPLEMENT_DYNCREATE(CAviReportWnd, CWnd)
BEGIN_MESSAGE_MAP(CAviReportWnd, CWnd)
- ON_WM_CLOSE()
- ON_WM_MOUSEMOVE()
+ ON_WM_CLOSE()
+ ON_WM_MOUSEMOVE()
END_MESSAGE_MAP()
void CAviReportWnd::OnClose()
{
- EndModalLoop(IsDlgButtonChecked(IDC_DONOTSHOWAGAINCHECK));
- __super::OnClose();
+ EndModalLoop(IsDlgButtonChecked(IDC_DONOTSHOWAGAINCHECK));
+ __super::OnClose();
}
void CAviReportWnd::OnMouseMove(UINT nFlags, CPoint p)
{
- MapWindowPoints(&m_graph, &p, 1);
-
- CRect r, r2;
- m_graph.GetClientRect(r);
- r2 = r;
- r.bottom -= GRAPHFOOTER;
- r2.top = r.bottom;
-
- if (r.PtInRect(p)) {
- SetCapture();
-
- int x = p.x - r.left;
- int y = r.bottom - p.y;
-
- REFERENCE_TIME rt = m_rtDur * x / r.Width();
- int chunk = (int)(__int64(m_nChunks) * y / r.Height());
-
- rt /= 10000;
- int ms = (int)(rt%1000);
- rt /= 1000;
- int s = (int)(rt%60);
- rt /= 60;
- int m = (int)(rt%60);
- rt /= 60;
- int h = (int)(rt);
-
- CString str;
- str.Format(_T("%s (%d - %d:%02d:%02d.%03d)"), TITLE, chunk, h, m, s, ms);
- SetWindowText(str);
- } else if (r2.PtInRect(p)) {
- SetCapture();
-
- int dist = m_graph.GetChunkDist(p.x - r2.left);
- CString str;
- str.Format(_T("%s (chunk distance: %d"), TITLE, dist);
- if (dist >= 1000) {
- str += _T(" - over the limit!");
- }
- str += ")";
- SetWindowText(str);
- } else if (GetCapture() == this) {
- SetWindowText(TITLE);
-
- ReleaseCapture();
- }
-
- __super::OnMouseMove(nFlags, p);
+ MapWindowPoints(&m_graph, &p, 1);
+
+ CRect r, r2;
+ m_graph.GetClientRect(r);
+ r2 = r;
+ r.bottom -= GRAPHFOOTER;
+ r2.top = r.bottom;
+
+ if (r.PtInRect(p)) {
+ SetCapture();
+
+ int x = p.x - r.left;
+ int y = r.bottom - p.y;
+
+ REFERENCE_TIME rt = m_rtDur * x / r.Width();
+ int chunk = (int)(__int64(m_nChunks) * y / r.Height());
+
+ rt /= 10000;
+ int ms = (int)(rt % 1000);
+ rt /= 1000;
+ int s = (int)(rt % 60);
+ rt /= 60;
+ int m = (int)(rt % 60);
+ rt /= 60;
+ int h = (int)(rt);
+
+ CString str;
+ str.Format(_T("%s (%d - %d:%02d:%02d.%03d)"), TITLE, chunk, h, m, s, ms);
+ SetWindowText(str);
+ } else if (r2.PtInRect(p)) {
+ SetCapture();
+
+ int dist = m_graph.GetChunkDist(p.x - r2.left);
+ CString str;
+ str.Format(_T("%s (chunk distance: %d"), TITLE, dist);
+ if (dist >= 1000) {
+ str += _T(" - over the limit!");
+ }
+ str += ")";
+ SetWindowText(str);
+ } else if (GetCapture() == this) {
+ SetWindowText(TITLE);
+
+ ReleaseCapture();
+ }
+
+ __super::OnMouseMove(nFlags, p);
}
//////////////
@@ -171,187 +171,187 @@ CAviPlotterWnd::CAviPlotterWnd()
bool CAviPlotterWnd::Create(CAviFile* pAF, CRect r, CWnd* pParentWnd)
{
- if (!CreateEx(WS_EX_CLIENTEDGE, _T("STATIC"), _T(""), WS_CHILD|WS_VISIBLE, r, pParentWnd, 0)) {
- return false;
- }
-
- GetClientRect(r);
- int w = r.Width();
- int h = r.Height() - GRAPHFOOTER;
-
- CDC* pDC = GetDC();
- m_dc.CreateCompatibleDC(pDC);
- m_bm.CreateCompatibleBitmap(pDC, r.Width(), r.Height());
- ReleaseDC(pDC);
-
- CBitmap* pOldBitmap = m_dc.SelectObject(&m_bm);
-
- m_dc.FillSolidRect(r, 0);
-
- {
- CPen pen(PS_DOT, 1, 0x008000);
- CPen* pOldPen = m_dc.SelectObject(&pen);
- for (int y = 0, dy = max(h/10,1); y < h; y += dy) {
- if (y == 0) {
- continue;
- }
- m_dc.MoveTo(0, y);
- m_dc.LineTo(w, y);
- }
- for (int x = 0, dx = max(w/10,1); x < w; x += dx) {
- if (x == 0) {
- continue;
- }
- m_dc.MoveTo(x, 0);
- m_dc.LineTo(x, w);
- }
- m_dc.SelectObject(pOldPen);
- }
-
- {
- CPen pen(PS_SOLID, 1, 0x00ff00);
- CPen* pOldPen = m_dc.SelectObject(&pen);
- m_dc.MoveTo(15, 30);
- m_dc.LineTo(15, 2);
- m_dc.LineTo(19, 10);
- m_dc.LineTo(11, 10);
- m_dc.LineTo(15, 2);
- m_dc.MoveTo(w-30-10, h-15);
- m_dc.LineTo(w-2-10, h-15);
- m_dc.LineTo(w-10-10, h-19);
- m_dc.LineTo(w-10-10, h-11);
- m_dc.LineTo(w-2-10, h-15);
- m_dc.SelectObject(pOldPen);
-
- m_dc.SetTextColor(0x008000);
- m_dc.TextOut(20, 10, _T("Chunk"));
-
- CSize size = m_dc.GetTextExtent(_T("Time"));
- m_dc.TextOut(w - size.cx - 10, h - size.cy - 20, _T("Time"));
- }
-
- COLORREF clr[] = {0x0000ff,0xff0000,0x40ffff,0xff40ff,0xffff40,0xffffff};
-
- for (DWORD i = 0, y = 40, dy = m_dc.GetTextExtent(_T("Stream N")).cy + 1; i < pAF->m_avih.dwStreams; ++i, y += dy) {
- m_dc.SetTextColor(clr[i % pAF->m_avih.dwStreams]);
- m_dc.SetBkMode(TRANSPARENT);
- CString str;
- str.Format(_T("Stream %u"), i);
- m_dc.TextOut(10, y, str);
- }
-
- DWORD nmax = 0, tmax = 0;
-
- for (DWORD i = 0; i < pAF->m_avih.dwStreams; ++i) {
- size_t cnt = pAF->m_strms[i]->cs2.GetCount();
- if (cnt == 0) {
- continue;
- }
- CAviFile::strm_t::chunk2& c2 = pAF->m_strms[i]->cs2[cnt-1];
- nmax = max(nmax, c2.n);
- tmax = max(tmax, c2.t);
- }
-
- if (nmax > 0 && tmax > 0) {
- CAtlArray<CPen> pen;
- pen.SetCount(pAF->m_avih.dwStreams);
- for (size_t i = 0; i < pen.GetCount(); ++i) {
- pen[i].CreatePen(PS_SOLID, 2, clr[i]);
- }
-
- CAtlArray<CPoint> pp;
- pp.SetCount(pAF->m_avih.dwStreams);
- for (size_t i = 0; i < pen.GetCount(); ++i) {
- pp[i].SetPoint(-1, -1);
- }
-
- m_chunkdist.SetCount(w);
- memset(m_chunkdist.GetData(), 0, sizeof(int)*w);
-
- DWORD* curchunks = DNew DWORD[pAF->m_avih.dwStreams];
- memset(curchunks, 0, sizeof(DWORD)*pAF->m_avih.dwStreams);
-
- CAviFile::strm_t::chunk2 cs2last = {(DWORD)-1, 0};
-
- for (;;) {
- CAviFile::strm_t::chunk2 cs2min = {LONG_MAX, LONG_MAX};
-
- DWORD n = (DWORD)-1;
- for (DWORD i = 0; i < pAF->m_avih.dwStreams; ++i) {
- DWORD curchunk = curchunks[i];
- if (curchunk >= pAF->m_strms[i]->cs2.GetCount()) {
- continue;
- }
- CAviFile::strm_t::chunk2& cs2 = pAF->m_strms[i]->cs2[curchunk];
- if (cs2.t < cs2min.t) {
- cs2min = cs2;
- n = i;
- }
- }
- if (n == -1) {
- break;
- }
-
-
- CPoint p;
- p.x = (int)(1.0 * w * cs2min.t / tmax);
- p.y = (int)(h - 1.0 * h * cs2min.n / nmax);
- if (pp[n] != p) {
- CPen* pOldPen = m_dc.SelectObject(&pen[n]);
- if (pp[n] == CPoint(-1, -1)) {
- m_dc.MoveTo(p);
- } else {
- m_dc.MoveTo(pp[n]);
- m_dc.LineTo(p);
- }
- m_dc.SelectObject(pOldPen);
- pp[n] = p;
- }
-
- int dist = abs((int)cs2min.n - (int)cs2last.n);
-
- if (cs2last.t != (DWORD)-1 /*&& dist >= 1000*/) {
- if (p.x >= 0 && p.x < w) {
- m_chunkdist[p.x] = max(m_chunkdist[p.x], dist);
- }
- }
-
- ++curchunks[n];
- cs2last = cs2min;
- }
-
- CPen red(PS_SOLID, 1, 0x0000ff);
- CPen green(PS_SOLID, 1, 0x00ff00);
-
- for (int x = 0; x < w; ++x) {
- CPen* pOldPen = m_dc.SelectObject(m_chunkdist[x] >= 1000 ? &red : &green);
- m_dc.MoveTo(x, h);
- m_dc.LineTo(x, h + GRAPHFOOTER);
- m_dc.SelectObject(pOldPen);
- }
-
- delete [] curchunks;
- }
-
- m_dc.SelectObject(pOldBitmap);
-
- return true;
+ if (!CreateEx(WS_EX_CLIENTEDGE, _T("STATIC"), _T(""), WS_CHILD | WS_VISIBLE, r, pParentWnd, 0)) {
+ return false;
+ }
+
+ GetClientRect(r);
+ int w = r.Width();
+ int h = r.Height() - GRAPHFOOTER;
+
+ CDC* pDC = GetDC();
+ m_dc.CreateCompatibleDC(pDC);
+ m_bm.CreateCompatibleBitmap(pDC, r.Width(), r.Height());
+ ReleaseDC(pDC);
+
+ CBitmap* pOldBitmap = m_dc.SelectObject(&m_bm);
+
+ m_dc.FillSolidRect(r, 0);
+
+ {
+ CPen pen(PS_DOT, 1, 0x008000);
+ CPen* pOldPen = m_dc.SelectObject(&pen);
+ for (int y = 0, dy = max(h / 10, 1); y < h; y += dy) {
+ if (y == 0) {
+ continue;
+ }
+ m_dc.MoveTo(0, y);
+ m_dc.LineTo(w, y);
+ }
+ for (int x = 0, dx = max(w / 10, 1); x < w; x += dx) {
+ if (x == 0) {
+ continue;
+ }
+ m_dc.MoveTo(x, 0);
+ m_dc.LineTo(x, w);
+ }
+ m_dc.SelectObject(pOldPen);
+ }
+
+ {
+ CPen pen(PS_SOLID, 1, 0x00ff00);
+ CPen* pOldPen = m_dc.SelectObject(&pen);
+ m_dc.MoveTo(15, 30);
+ m_dc.LineTo(15, 2);
+ m_dc.LineTo(19, 10);
+ m_dc.LineTo(11, 10);
+ m_dc.LineTo(15, 2);
+ m_dc.MoveTo(w - 30 - 10, h - 15);
+ m_dc.LineTo(w - 2 - 10, h - 15);
+ m_dc.LineTo(w - 10 - 10, h - 19);
+ m_dc.LineTo(w - 10 - 10, h - 11);
+ m_dc.LineTo(w - 2 - 10, h - 15);
+ m_dc.SelectObject(pOldPen);
+
+ m_dc.SetTextColor(0x008000);
+ m_dc.TextOut(20, 10, _T("Chunk"));
+
+ CSize size = m_dc.GetTextExtent(_T("Time"));
+ m_dc.TextOut(w - size.cx - 10, h - size.cy - 20, _T("Time"));
+ }
+
+ COLORREF clr[] = {0x0000ff, 0xff0000, 0x40ffff, 0xff40ff, 0xffff40, 0xffffff};
+
+ for (DWORD i = 0, y = 40, dy = m_dc.GetTextExtent(_T("Stream N")).cy + 1; i < pAF->m_avih.dwStreams; ++i, y += dy) {
+ m_dc.SetTextColor(clr[i % pAF->m_avih.dwStreams]);
+ m_dc.SetBkMode(TRANSPARENT);
+ CString str;
+ str.Format(_T("Stream %u"), i);
+ m_dc.TextOut(10, y, str);
+ }
+
+ DWORD nmax = 0, tmax = 0;
+
+ for (DWORD i = 0; i < pAF->m_avih.dwStreams; ++i) {
+ size_t cnt = pAF->m_strms[i]->cs2.GetCount();
+ if (cnt == 0) {
+ continue;
+ }
+ CAviFile::strm_t::chunk2& c2 = pAF->m_strms[i]->cs2[cnt - 1];
+ nmax = max(nmax, c2.n);
+ tmax = max(tmax, c2.t);
+ }
+
+ if (nmax > 0 && tmax > 0) {
+ CAtlArray<CPen> pen;
+ pen.SetCount(pAF->m_avih.dwStreams);
+ for (size_t i = 0; i < pen.GetCount(); ++i) {
+ pen[i].CreatePen(PS_SOLID, 2, clr[i]);
+ }
+
+ CAtlArray<CPoint> pp;
+ pp.SetCount(pAF->m_avih.dwStreams);
+ for (size_t i = 0; i < pen.GetCount(); ++i) {
+ pp[i].SetPoint(-1, -1);
+ }
+
+ m_chunkdist.SetCount(w);
+ memset(m_chunkdist.GetData(), 0, sizeof(int)*w);
+
+ DWORD* curchunks = DNew DWORD[pAF->m_avih.dwStreams];
+ memset(curchunks, 0, sizeof(DWORD)*pAF->m_avih.dwStreams);
+
+ CAviFile::strm_t::chunk2 cs2last = {(DWORD) - 1, 0};
+
+ for (;;) {
+ CAviFile::strm_t::chunk2 cs2min = {LONG_MAX, LONG_MAX};
+
+ DWORD n = (DWORD) - 1;
+ for (DWORD i = 0; i < pAF->m_avih.dwStreams; ++i) {
+ DWORD curchunk = curchunks[i];
+ if (curchunk >= pAF->m_strms[i]->cs2.GetCount()) {
+ continue;
+ }
+ CAviFile::strm_t::chunk2& cs2 = pAF->m_strms[i]->cs2[curchunk];
+ if (cs2.t < cs2min.t) {
+ cs2min = cs2;
+ n = i;
+ }
+ }
+ if (n == -1) {
+ break;
+ }
+
+
+ CPoint p;
+ p.x = (int)(1.0 * w * cs2min.t / tmax);
+ p.y = (int)(h - 1.0 * h * cs2min.n / nmax);
+ if (pp[n] != p) {
+ CPen* pOldPen = m_dc.SelectObject(&pen[n]);
+ if (pp[n] == CPoint(-1, -1)) {
+ m_dc.MoveTo(p);
+ } else {
+ m_dc.MoveTo(pp[n]);
+ m_dc.LineTo(p);
+ }
+ m_dc.SelectObject(pOldPen);
+ pp[n] = p;
+ }
+
+ int dist = abs((int)cs2min.n - (int)cs2last.n);
+
+ if (cs2last.t != (DWORD) - 1 /*&& dist >= 1000*/) {
+ if (p.x >= 0 && p.x < w) {
+ m_chunkdist[p.x] = max(m_chunkdist[p.x], dist);
+ }
+ }
+
+ ++curchunks[n];
+ cs2last = cs2min;
+ }
+
+ CPen red(PS_SOLID, 1, 0x0000ff);
+ CPen green(PS_SOLID, 1, 0x00ff00);
+
+ for (int x = 0; x < w; ++x) {
+ CPen* pOldPen = m_dc.SelectObject(m_chunkdist[x] >= 1000 ? &red : &green);
+ m_dc.MoveTo(x, h);
+ m_dc.LineTo(x, h + GRAPHFOOTER);
+ m_dc.SelectObject(pOldPen);
+ }
+
+ delete [] curchunks;
+ }
+
+ m_dc.SelectObject(pOldBitmap);
+
+ return true;
}
IMPLEMENT_DYNCREATE(CAviPlotterWnd, CWnd)
BEGIN_MESSAGE_MAP(CAviPlotterWnd, CWnd)
- ON_WM_PAINT()
+ ON_WM_PAINT()
END_MESSAGE_MAP()
void CAviPlotterWnd::OnPaint()
{
- CPaintDC dc(this); // device context for painting
+ CPaintDC dc(this); // device context for painting
- CRect r;
- GetClientRect(r);
+ CRect r;
+ GetClientRect(r);
- CBitmap* pOld = m_dc.SelectObject(&m_bm);
- dc.BitBlt(0, 0, r.Width(), r.Height(), &m_dc, 0, 0, SRCCOPY);
- m_dc.SelectObject(pOld);
+ CBitmap* pOld = m_dc.SelectObject(&m_bm);
+ dc.BitBlt(0, 0, r.Width(), r.Height(), &m_dc, 0, 0, SRCCOPY);
+ m_dc.SelectObject(pOld);
}
diff --git a/src/filters/parser/AviSplitter/AviReportWnd.h b/src/filters/parser/AviSplitter/AviReportWnd.h
index 3813a1852..4db738f6e 100644
--- a/src/filters/parser/AviSplitter/AviReportWnd.h
+++ b/src/filters/parser/AviSplitter/AviReportWnd.h
@@ -4,44 +4,44 @@
class CAviPlotterWnd : public CStatic
{
- DECLARE_DYNCREATE(CAviPlotterWnd)
+ DECLARE_DYNCREATE(CAviPlotterWnd)
private:
- CDC m_dc;
- CBitmap m_bm;
+ CDC m_dc;
+ CBitmap m_bm;
- CAtlArray<int> m_chunkdist;
+ CAtlArray<int> m_chunkdist;
public:
- CAviPlotterWnd();
- bool Create(CAviFile* pAF, CRect r, CWnd* pParentWnd);
+ CAviPlotterWnd();
+ bool Create(CAviFile* pAF, CRect r, CWnd* pParentWnd);
- int GetChunkDist(int x) {
- return (x >= 0 && (size_t)x < m_chunkdist.GetCount()) ? m_chunkdist[x] : 0;
- }
+ int GetChunkDist(int x) {
+ return (x >= 0 && (size_t)x < m_chunkdist.GetCount()) ? m_chunkdist[x] : 0;
+ }
- DECLARE_MESSAGE_MAP()
- afx_msg void OnPaint();
+ DECLARE_MESSAGE_MAP()
+ afx_msg void OnPaint();
};
class CAviReportWnd : public CWnd
{
- DECLARE_DYNCREATE(CAviReportWnd)
+ DECLARE_DYNCREATE(CAviReportWnd)
protected:
- CFont m_font;
- CStatic m_message;
- CButton m_checkbox;
- CAviPlotterWnd m_graph;
+ CFont m_font;
+ CStatic m_message;
+ CButton m_checkbox;
+ CAviPlotterWnd m_graph;
- unsigned int m_nChunks;
- REFERENCE_TIME m_rtDur;
+ unsigned int m_nChunks;
+ REFERENCE_TIME m_rtDur;
public:
- CAviReportWnd();
- bool DoModal(CAviFile* pAF, bool fHideChecked, bool fShowWarningText);
+ CAviReportWnd();
+ bool DoModal(CAviFile* pAF, bool fHideChecked, bool fShowWarningText);
- DECLARE_MESSAGE_MAP()
- afx_msg void OnClose();
- afx_msg void OnMouseMove(UINT nFlags, CPoint point);
+ DECLARE_MESSAGE_MAP()
+ afx_msg void OnClose();
+ afx_msg void OnMouseMove(UINT nFlags, CPoint point);
};
diff --git a/src/filters/parser/AviSplitter/AviSplitter.cpp b/src/filters/parser/AviSplitter/AviSplitter.cpp
index f43a246b5..13fa02aa7 100644
--- a/src/filters/parser/AviSplitter/AviSplitter.cpp
+++ b/src/filters/parser/AviSplitter/AviSplitter.cpp
@@ -27,53 +27,53 @@
#include "AviReportWnd.h"
#include "AviSplitter.h"
-#define MAXPACKETS_AVI MAXPACKETS*10
+#define MAXPACKETS_AVI MAXPACKETS*10
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_Avi},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_Avi},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CAviSplitterFilter), AviSplitterName, MERIT_NORMAL+1, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CAviSourceFilter), AviSourceName, MERIT_NORMAL+1, 0, NULL, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CAviSplitterFilter), AviSplitterName, MERIT_NORMAL + 1, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CAviSourceFilter), AviSourceName, MERIT_NORMAL + 1, 0, NULL, CLSID_LegacyAmFilterCategory},
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CAviSplitterFilter>, NULL, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CAviSourceFilter>, NULL, &sudFilter[1]},
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CAviSplitterFilter>, NULL, &sudFilter[0]},
+ {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CAviSourceFilter>, NULL, &sudFilter[1]},
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- CAtlList<CString> chkbytes;
- chkbytes.AddTail(_T("0,4,,52494646,8,4,,41564920")); // 'RIFF' ... 'AVI '
- chkbytes.AddTail(_T("0,4,,52494646,8,4,,41564958")); // 'RIFF' ... 'AVIX'
- chkbytes.AddTail(_T("0,4,,52494646,8,4,,414D5620")); // 'RIFF' ... 'AMV '
-
- RegisterSourceFilter(
- CLSID_AsyncReader,
- MEDIASUBTYPE_Avi,
- chkbytes,
- _T(".avi"), _T(".divx"), _T(".vp6"), _T(".amv"), NULL);
-
- return AMovieDllRegisterServer2(TRUE);
+ CAtlList<CString> chkbytes;
+ chkbytes.AddTail(_T("0,4,,52494646,8,4,,41564920")); // 'RIFF' ... 'AVI '
+ chkbytes.AddTail(_T("0,4,,52494646,8,4,,41564958")); // 'RIFF' ... 'AVIX'
+ chkbytes.AddTail(_T("0,4,,52494646,8,4,,414D5620")); // 'RIFF' ... 'AMV '
+
+ RegisterSourceFilter(
+ CLSID_AsyncReader,
+ MEDIASUBTYPE_Avi,
+ chkbytes,
+ _T(".avi"), _T(".divx"), _T(".vp6"), _T(".amv"), NULL);
+
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- //UnRegisterSourceFilter(MEDIASUBTYPE_Avi);
+ //UnRegisterSourceFilter(MEDIASUBTYPE_Avi);
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);
@@ -81,26 +81,26 @@ extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);
class CAviSplitterApp : public CWinApp
{
public:
- CAviSplitterApp() {}
-
- BOOL InitInstance() {
- if (!__super::InitInstance()) {
- return FALSE;
- }
- DllEntryPoint(m_hInstance, DLL_PROCESS_ATTACH, 0);
- return TRUE;
- }
-
- BOOL ExitInstance() {
- DllEntryPoint(m_hInstance, DLL_PROCESS_DETACH, 0);
- return __super::ExitInstance();
- }
-
- void SetDefaultRegistryKey() {
- SetRegistryKey(_T("Gabest"));
- }
-
- DECLARE_MESSAGE_MAP()
+ CAviSplitterApp() {}
+
+ BOOL InitInstance() {
+ if (!__super::InitInstance()) {
+ return FALSE;
+ }
+ DllEntryPoint(m_hInstance, DLL_PROCESS_ATTACH, 0);
+ return TRUE;
+ }
+
+ BOOL ExitInstance() {
+ DllEntryPoint(m_hInstance, DLL_PROCESS_DETACH, 0);
+ return __super::ExitInstance();
+ }
+
+ void SetDefaultRegistryKey() {
+ SetRegistryKey(_T("Gabest"));
+ }
+
+ DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP(CAviSplitterApp, CWinApp)
@@ -115,786 +115,786 @@ CAviSplitterApp theApp;
//
CAviSplitterFilter::CAviSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("CAviSplitterFilter"), pUnk, phr, __uuidof(this), MAXPACKETS_AVI)
- , m_timeformat(TIME_FORMAT_MEDIA_TIME)
- , m_maxTimeStamp(Packet::INVALID_TIME)
+ : CBaseSplitterFilter(NAME("CAviSplitterFilter"), pUnk, phr, __uuidof(this), MAXPACKETS_AVI)
+ , m_timeformat(TIME_FORMAT_MEDIA_TIME)
+ , m_maxTimeStamp(Packet::INVALID_TIME)
{
}
STDMETHODIMP CAviSplitterFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- *ppv = NULL;
+ *ppv = NULL;
- return
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
STDMETHODIMP CAviSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo)
{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
-
- if (m_pName && m_pName[0]==L'M' && m_pName[1]==L'P' && m_pName[2]==L'C') {
- (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
- } else {
- wcscpy_s(pInfo->achName, AviSourceName);
- }
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
+ CheckPointer(pInfo, E_POINTER);
+ ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
+
+ if (m_pName && m_pName[0] == L'M' && m_pName[1] == L'P' && m_pName[2] == L'C') {
+ (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
+ } else {
+ wcscpy_s(pInfo->achName, AviSourceName);
+ }
+ pInfo->pGraph = m_pGraph;
+ if (m_pGraph) {
+ m_pGraph->AddRef();
+ }
+
+ return S_OK;
}
HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
{
- CheckPointer(pAsyncReader, E_POINTER);
+ CheckPointer(pAsyncReader, E_POINTER);
- HRESULT hr = E_FAIL;
+ HRESULT hr = E_FAIL;
- m_pFile.Free();
- m_tFrame.Free();
+ m_pFile.Free();
+ m_tFrame.Free();
- m_pFile.Attach(DNew CAviFile(pAsyncReader, hr));
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
+ m_pFile.Attach(DNew CAviFile(pAsyncReader, hr));
+ if (!m_pFile) {
+ return E_OUTOFMEMORY;
+ }
- bool fShiftDown = !!(::GetKeyState(VK_SHIFT)&0x8000);
- bool fShowWarningText = !m_pFile->IsInterleaved(fShiftDown);
+ bool fShiftDown = !!(::GetKeyState(VK_SHIFT) & 0x8000);
+ bool fShowWarningText = !m_pFile->IsInterleaved(fShiftDown);
- if (SUCCEEDED(hr) && (fShowWarningText || fShiftDown)) {
+ if (SUCCEEDED(hr) && (fShowWarningText || fShiftDown)) {
#ifdef REGISTER_FILTER
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
#endif
- bool fHideWarning = !!AfxGetApp()->GetProfileInt(_T("Settings"), _T("HideAviSplitterWarning"), 0);
-
- if (!fHideWarning && !dynamic_cast<CAviSourceFilter*>(this) || fShiftDown) {
- CAviReportWnd wnd;
- fHideWarning = wnd.DoModal(m_pFile, fHideWarning, fShowWarningText);
- AfxGetApp()->WriteProfileInt(_T("Settings"), _T("HideAviSplitterWarning"), fHideWarning);
- }
-
- if (fShowWarningText) {
- hr = E_FAIL;
- }
- }
-
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration = m_pFile->GetTotalTime();
-
- bool fHasIndex = false;
-
- for (unsigned int i = 0; !fHasIndex && i < m_pFile->m_strms.GetCount(); ++i)
- if (m_pFile->m_strms[i]->cs.GetCount() > 0) {
- fHasIndex = true;
- }
-
- for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
- CAviFile::strm_t* s = m_pFile->m_strms[i];
-
- if (fHasIndex && s->cs.GetCount() == 0) {
- continue;
- }
-
- CMediaType mt;
- CAtlArray<CMediaType> mts;
-
- CStringW name, label;
-
- if (s->strh.fccType == FCC('vids')) {
- label = L"Video";
-
- ASSERT(s->strf.GetCount() >= sizeof(BITMAPINFOHEADER));
-
- BITMAPINFOHEADER* pbmi = &((BITMAPINFO*)s->strf.GetData())->bmiHeader;
-
- mt.majortype = MEDIATYPE_Video;
- switch (pbmi->biCompression) {
- case BI_RGB:
- case BI_BITFIELDS:
- mt.subtype =
- pbmi->biBitCount == 1 ? MEDIASUBTYPE_RGB1 :
- pbmi->biBitCount == 4 ? MEDIASUBTYPE_RGB4 :
- pbmi->biBitCount == 8 ? MEDIASUBTYPE_RGB8 :
- pbmi->biBitCount == 16 ? MEDIASUBTYPE_RGB565 :
- pbmi->biBitCount == 24 ? MEDIASUBTYPE_RGB24 :
- pbmi->biBitCount == 32 ? MEDIASUBTYPE_ARGB32 :
- MEDIASUBTYPE_NULL;
- break;
- //case BI_RLE8: mt.subtype = MEDIASUBTYPE_RGB8; break;
- //case BI_RLE4: mt.subtype = MEDIASUBTYPE_RGB4; break;
- case FCC('AVRn')://uncommon fourcc
- case FCC('JPGL')://uncommon fourcc
- mt.subtype = MEDIASUBTYPE_MJPG;
- break;
- case FCC('MPG2'):
- mt.subtype = MEDIASUBTYPE_MPEG2_VIDEO;
- break;
- default:
- mt.subtype = FOURCCMap(pbmi->biCompression);
- }
- mt.formattype = FORMAT_VideoInfo;
- VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + (ULONG)s->strf.GetCount() - sizeof(BITMAPINFOHEADER));
- memset(mt.Format(), 0, mt.FormatLength());
- memcpy(&pvih->bmiHeader, s->strf.GetData(), s->strf.GetCount());
- if (s->strh.dwRate > 0) {
- pvih->AvgTimePerFrame = 10000000ui64 * s->strh.dwScale / s->strh.dwRate;
- }
-
- if (s->cs.GetCount() && pvih->AvgTimePerFrame > 0) {
- UINT64 size = 0;
- for (unsigned int i = 0; i < s->cs.GetCount(); ++i) {
- size += s->cs[i].orgsize;
- }
- pvih->dwBitRate = (DWORD)(10000000.0 * size * 8 / (s->cs.GetCount() * pvih->AvgTimePerFrame) + 0.5);
- // need calculate in double, because the (10000000ui64 * size * 8) can give overflow
- }
-
- mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
- ? s->strh.dwSuggestedBufferSize*3/2
- : (pvih->bmiHeader.biWidth*pvih->bmiHeader.biHeight*4));
- mts.Add(mt);
- } else if (s->strh.fccType == FCC('auds') || s->strh.fccType == FCC('amva')) {
- label = L"Audio";
-
- ASSERT(s->strf.GetCount() >= sizeof(WAVEFORMATEX)
- || s->strf.GetCount() == sizeof(PCMWAVEFORMAT));
-
- WAVEFORMATEX* pwfe = (WAVEFORMATEX*)s->strf.GetData();
-
- if (pwfe->nBlockAlign == 0) {
- continue;
- }
-
- mt.majortype = MEDIATYPE_Audio;
- if (m_pFile->m_isamv) {
- mt.subtype = FOURCCMap(MAKEFOURCC('A','M','V','A'));
- } else {
- mt.subtype = FOURCCMap(pwfe->wFormatTag);
- }
- mt.formattype = FORMAT_WaveFormatEx;
- mt.SetFormat(s->strf.GetData(), max((ULONG)s->strf.GetCount(), sizeof(WAVEFORMATEX)));
- pwfe = (WAVEFORMATEX*)mt.Format();
- if (s->strf.GetCount() == sizeof(PCMWAVEFORMAT)) {
- pwfe->cbSize = 0;
- }
- if (pwfe->wFormatTag == WAVE_FORMAT_PCM) {
- pwfe->nBlockAlign = pwfe->nChannels*pwfe->wBitsPerSample>>3;
- }
- if (pwfe->wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
- mt.subtype = FOURCCMap(WAVE_FORMAT_PCM); // audio renderer doesn't accept fffe in the subtype
- }
- mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
- ? s->strh.dwSuggestedBufferSize*3/2
- : (pwfe->nChannels*pwfe->nSamplesPerSec*32>>3));
- mts.Add(mt);
- } else if (s->strh.fccType == FCC('mids')) {
- label = L"Midi";
-
- mt.majortype = MEDIATYPE_Midi;
- mt.subtype = MEDIASUBTYPE_NULL;
- mt.formattype = FORMAT_None;
- mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
- ? s->strh.dwSuggestedBufferSize*3/2
- : (1024*1024));
- mts.Add(mt);
- } else if (s->strh.fccType == FCC('txts')) {
- label = L"Text";
-
- mt.majortype = MEDIATYPE_Text;
- mt.subtype = MEDIASUBTYPE_NULL;
- mt.formattype = FORMAT_None;
- mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
- ? s->strh.dwSuggestedBufferSize*3/2
- : (1024*1024));
- mts.Add(mt);
- } else if (s->strh.fccType == FCC('iavs')) {
- label = L"Interleaved";
-
- ASSERT(s->strh.fccHandler == FCC('dvsd'));
-
- mt.majortype = MEDIATYPE_Interleaved;
- mt.subtype = FOURCCMap(s->strh.fccHandler);
- mt.formattype = FORMAT_DvInfo;
- mt.SetFormat(s->strf.GetData(), max((ULONG)s->strf.GetCount(), sizeof(DVINFO)));
- mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
- ? s->strh.dwSuggestedBufferSize*3/2
- : (1024*1024));
- mts.Add(mt);
- }
-
- if (mts.IsEmpty()) {
- TRACE(_T("CAviSourceFilter: Unsupported stream (%d)\n"), i);
- continue;
- }
-
- //Put filename at front sometime(eg. ~temp.avi) will cause filter graph
- //stop check this pin. Not sure the reason exactly. but it happens.
- //If you know why, please emailto: tomasen@gmail.com
- if (s->strn.IsEmpty()) {
- name.Format(L"%s %u", label, i);
- } else {
- name.Format(L"%s (%s %u)", CStringW(s->strn), label, i);
- }
-
- HRESULT hr;
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CAviSplitterOutputPin(mts, name, this, this, &hr));
- AddOutputPin(i, pPinOut);
- }
-
- POSITION pos = m_pFile->m_info.GetStartPosition();
- while (pos) {
- DWORD fcc;
- CStringA value;
- m_pFile->m_info.GetNextAssoc(pos, fcc, value);
-
- switch (fcc) {
- case FCC('INAM'):
- SetProperty(L"TITL", CStringW(value));
- break;
- case FCC('IART'):
- SetProperty(L"AUTH", CStringW(value));
- break;
- case FCC('ICOP'):
- SetProperty(L"CPYR", CStringW(value));
- break;
- case FCC('ISBJ'):
- SetProperty(L"DESC", CStringW(value));
- break;
- }
- }
-
- m_tFrame.Attach(DNew DWORD[m_pFile->m_avih.dwStreams]);
-
- return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
+ bool fHideWarning = !!AfxGetApp()->GetProfileInt(_T("Settings"), _T("HideAviSplitterWarning"), 0);
+
+ if (!fHideWarning && !dynamic_cast<CAviSourceFilter*>(this) || fShiftDown) {
+ CAviReportWnd wnd;
+ fHideWarning = wnd.DoModal(m_pFile, fHideWarning, fShowWarningText);
+ AfxGetApp()->WriteProfileInt(_T("Settings"), _T("HideAviSplitterWarning"), fHideWarning);
+ }
+
+ if (fShowWarningText) {
+ hr = E_FAIL;
+ }
+ }
+
+ if (FAILED(hr)) {
+ m_pFile.Free();
+ return hr;
+ }
+
+ m_rtNewStart = m_rtCurrent = 0;
+ m_rtNewStop = m_rtStop = m_rtDuration = m_pFile->GetTotalTime();
+
+ bool fHasIndex = false;
+
+ for (unsigned int i = 0; !fHasIndex && i < m_pFile->m_strms.GetCount(); ++i)
+ if (m_pFile->m_strms[i]->cs.GetCount() > 0) {
+ fHasIndex = true;
+ }
+
+ for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
+ CAviFile::strm_t* s = m_pFile->m_strms[i];
+
+ if (fHasIndex && s->cs.GetCount() == 0) {
+ continue;
+ }
+
+ CMediaType mt;
+ CAtlArray<CMediaType> mts;
+
+ CStringW name, label;
+
+ if (s->strh.fccType == FCC('vids')) {
+ label = L"Video";
+
+ ASSERT(s->strf.GetCount() >= sizeof(BITMAPINFOHEADER));
+
+ BITMAPINFOHEADER* pbmi = &((BITMAPINFO*)s->strf.GetData())->bmiHeader;
+
+ mt.majortype = MEDIATYPE_Video;
+ switch (pbmi->biCompression) {
+ case BI_RGB:
+ case BI_BITFIELDS:
+ mt.subtype =
+ pbmi->biBitCount == 1 ? MEDIASUBTYPE_RGB1 :
+ pbmi->biBitCount == 4 ? MEDIASUBTYPE_RGB4 :
+ pbmi->biBitCount == 8 ? MEDIASUBTYPE_RGB8 :
+ pbmi->biBitCount == 16 ? MEDIASUBTYPE_RGB565 :
+ pbmi->biBitCount == 24 ? MEDIASUBTYPE_RGB24 :
+ pbmi->biBitCount == 32 ? MEDIASUBTYPE_ARGB32 :
+ MEDIASUBTYPE_NULL;
+ break;
+ //case BI_RLE8: mt.subtype = MEDIASUBTYPE_RGB8; break;
+ //case BI_RLE4: mt.subtype = MEDIASUBTYPE_RGB4; break;
+ case FCC('AVRn')://uncommon fourcc
+ case FCC('JPGL')://uncommon fourcc
+ mt.subtype = MEDIASUBTYPE_MJPG;
+ break;
+ case FCC('MPG2'):
+ mt.subtype = MEDIASUBTYPE_MPEG2_VIDEO;
+ break;
+ default:
+ mt.subtype = FOURCCMap(pbmi->biCompression);
+ }
+ mt.formattype = FORMAT_VideoInfo;
+ VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + (ULONG)s->strf.GetCount() - sizeof(BITMAPINFOHEADER));
+ memset(mt.Format(), 0, mt.FormatLength());
+ memcpy(&pvih->bmiHeader, s->strf.GetData(), s->strf.GetCount());
+ if (s->strh.dwRate > 0) {
+ pvih->AvgTimePerFrame = 10000000ui64 * s->strh.dwScale / s->strh.dwRate;
+ }
+
+ if (s->cs.GetCount() && pvih->AvgTimePerFrame > 0) {
+ UINT64 size = 0;
+ for (unsigned int i = 0; i < s->cs.GetCount(); ++i) {
+ size += s->cs[i].orgsize;
+ }
+ pvih->dwBitRate = (DWORD)(10000000.0 * size * 8 / (s->cs.GetCount() * pvih->AvgTimePerFrame) + 0.5);
+ // need calculate in double, because the (10000000ui64 * size * 8) can give overflow
+ }
+
+ mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
+ ? s->strh.dwSuggestedBufferSize * 3 / 2
+ : (pvih->bmiHeader.biWidth * pvih->bmiHeader.biHeight * 4));
+ mts.Add(mt);
+ } else if (s->strh.fccType == FCC('auds') || s->strh.fccType == FCC('amva')) {
+ label = L"Audio";
+
+ ASSERT(s->strf.GetCount() >= sizeof(WAVEFORMATEX)
+ || s->strf.GetCount() == sizeof(PCMWAVEFORMAT));
+
+ WAVEFORMATEX* pwfe = (WAVEFORMATEX*)s->strf.GetData();
+
+ if (pwfe->nBlockAlign == 0) {
+ continue;
+ }
+
+ mt.majortype = MEDIATYPE_Audio;
+ if (m_pFile->m_isamv) {
+ mt.subtype = FOURCCMap(MAKEFOURCC('A', 'M', 'V', 'A'));
+ } else {
+ mt.subtype = FOURCCMap(pwfe->wFormatTag);
+ }
+ mt.formattype = FORMAT_WaveFormatEx;
+ mt.SetFormat(s->strf.GetData(), max((ULONG)s->strf.GetCount(), sizeof(WAVEFORMATEX)));
+ pwfe = (WAVEFORMATEX*)mt.Format();
+ if (s->strf.GetCount() == sizeof(PCMWAVEFORMAT)) {
+ pwfe->cbSize = 0;
+ }
+ if (pwfe->wFormatTag == WAVE_FORMAT_PCM) {
+ pwfe->nBlockAlign = pwfe->nChannels * pwfe->wBitsPerSample >> 3;
+ }
+ if (pwfe->wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
+ mt.subtype = FOURCCMap(WAVE_FORMAT_PCM); // audio renderer doesn't accept fffe in the subtype
+ }
+ mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
+ ? s->strh.dwSuggestedBufferSize * 3 / 2
+ : (pwfe->nChannels * pwfe->nSamplesPerSec * 32 >> 3));
+ mts.Add(mt);
+ } else if (s->strh.fccType == FCC('mids')) {
+ label = L"Midi";
+
+ mt.majortype = MEDIATYPE_Midi;
+ mt.subtype = MEDIASUBTYPE_NULL;
+ mt.formattype = FORMAT_None;
+ mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
+ ? s->strh.dwSuggestedBufferSize * 3 / 2
+ : (1024 * 1024));
+ mts.Add(mt);
+ } else if (s->strh.fccType == FCC('txts')) {
+ label = L"Text";
+
+ mt.majortype = MEDIATYPE_Text;
+ mt.subtype = MEDIASUBTYPE_NULL;
+ mt.formattype = FORMAT_None;
+ mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
+ ? s->strh.dwSuggestedBufferSize * 3 / 2
+ : (1024 * 1024));
+ mts.Add(mt);
+ } else if (s->strh.fccType == FCC('iavs')) {
+ label = L"Interleaved";
+
+ ASSERT(s->strh.fccHandler == FCC('dvsd'));
+
+ mt.majortype = MEDIATYPE_Interleaved;
+ mt.subtype = FOURCCMap(s->strh.fccHandler);
+ mt.formattype = FORMAT_DvInfo;
+ mt.SetFormat(s->strf.GetData(), max((ULONG)s->strf.GetCount(), sizeof(DVINFO)));
+ mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
+ ? s->strh.dwSuggestedBufferSize * 3 / 2
+ : (1024 * 1024));
+ mts.Add(mt);
+ }
+
+ if (mts.IsEmpty()) {
+ TRACE(_T("CAviSourceFilter: Unsupported stream (%d)\n"), i);
+ continue;
+ }
+
+ //Put filename at front sometime(eg. ~temp.avi) will cause filter graph
+ //stop check this pin. Not sure the reason exactly. but it happens.
+ //If you know why, please emailto: tomasen@gmail.com
+ if (s->strn.IsEmpty()) {
+ name.Format(L"%s %u", label, i);
+ } else {
+ name.Format(L"%s (%s %u)", CStringW(s->strn), label, i);
+ }
+
+ HRESULT hr;
+
+ CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CAviSplitterOutputPin(mts, name, this, this, &hr));
+ AddOutputPin(i, pPinOut);
+ }
+
+ POSITION pos = m_pFile->m_info.GetStartPosition();
+ while (pos) {
+ DWORD fcc;
+ CStringA value;
+ m_pFile->m_info.GetNextAssoc(pos, fcc, value);
+
+ switch (fcc) {
+ case FCC('INAM'):
+ SetProperty(L"TITL", CStringW(value));
+ break;
+ case FCC('IART'):
+ SetProperty(L"AUTH", CStringW(value));
+ break;
+ case FCC('ICOP'):
+ SetProperty(L"CPYR", CStringW(value));
+ break;
+ case FCC('ISBJ'):
+ SetProperty(L"DESC", CStringW(value));
+ break;
+ }
+ }
+
+ m_tFrame.Attach(DNew DWORD[m_pFile->m_avih.dwStreams]);
+
+ return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
}
bool CAviSplitterFilter::DemuxInit()
{
- SetThreadName((DWORD)-1, "CAviSplitterFilter");
+ SetThreadName((DWORD) - 1, "CAviSplitterFilter");
- if (!m_pFile) {
- return false;
- }
+ if (!m_pFile) {
+ return false;
+ }
- // reindex if needed
+ // reindex if needed
- bool fReIndex = false;
+ bool fReIndex = false;
- for (DWORD i = 0; i < m_pFile->m_avih.dwStreams && !fReIndex; ++i) {
- if (m_pFile->m_strms[i]->cs.GetCount() == 0 && GetOutputPin(i)) {
- fReIndex = true;
- }
- }
+ for (DWORD i = 0; i < m_pFile->m_avih.dwStreams && !fReIndex; ++i) {
+ if (m_pFile->m_strms[i]->cs.GetCount() == 0 && GetOutputPin(i)) {
+ fReIndex = true;
+ }
+ }
- if (fReIndex) {
- m_pFile->EmptyIndex();
+ if (fReIndex) {
+ m_pFile->EmptyIndex();
- m_fAbort = false;
- m_nOpenProgress = 0;
+ m_fAbort = false;
+ m_nOpenProgress = 0;
- m_rtDuration = 0;
+ m_rtDuration = 0;
- CAutoVectorPtr<UINT64> pSize;
- pSize.Allocate(m_pFile->m_avih.dwStreams);
- memset((UINT64*)pSize, 0, sizeof(UINT64)*m_pFile->m_avih.dwStreams);
- m_pFile->Seek(0);
- ReIndex(m_pFile->GetLength(), pSize);
+ CAutoVectorPtr<UINT64> pSize;
+ pSize.Allocate(m_pFile->m_avih.dwStreams);
+ memset((UINT64*)pSize, 0, sizeof(UINT64)*m_pFile->m_avih.dwStreams);
+ m_pFile->Seek(0);
+ ReIndex(m_pFile->GetLength(), pSize);
- if (m_fAbort) {
- m_pFile->EmptyIndex();
- }
+ if (m_fAbort) {
+ m_pFile->EmptyIndex();
+ }
- m_fAbort = false;
- m_nOpenProgress = 100;
- }
+ m_fAbort = false;
+ m_nOpenProgress = 100;
+ }
- return true;
+ return true;
}
HRESULT CAviSplitterFilter::ReIndex(__int64 end, UINT64* pSize)
{
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- while (S_OK == hr && m_pFile->GetPos() < end && SUCCEEDED(hr) && !m_fAbort) {
- __int64 pos = m_pFile->GetPos();
+ while (S_OK == hr && m_pFile->GetPos() < end && SUCCEEDED(hr) && !m_fAbort) {
+ __int64 pos = m_pFile->GetPos();
- DWORD id = 0, size;
- if (S_OK != m_pFile->Read(id) || id == 0) {
- return E_FAIL;
- }
+ DWORD id = 0, size;
+ if (S_OK != m_pFile->Read(id) || id == 0) {
+ return E_FAIL;
+ }
- if (id == FCC('RIFF') || id == FCC('LIST')) {
- if (S_OK != m_pFile->Read(size) || S_OK != m_pFile->Read(id)) {
- return E_FAIL;
- }
+ if (id == FCC('RIFF') || id == FCC('LIST')) {
+ if (S_OK != m_pFile->Read(size) || S_OK != m_pFile->Read(id)) {
+ return E_FAIL;
+ }
- size += (size&1) + 8;
+ size += (size & 1) + 8;
- if (id == FCC('AVI ') || id == FCC('AVIX') || id == FCC('movi') || id == FCC('rec ')) {
- hr = ReIndex(pos + size, pSize);
- }
- } else {
- if (S_OK != m_pFile->Read(size)) {
- return E_FAIL;
- }
+ if (id == FCC('AVI ') || id == FCC('AVIX') || id == FCC('movi') || id == FCC('rec ')) {
+ hr = ReIndex(pos + size, pSize);
+ }
+ } else {
+ if (S_OK != m_pFile->Read(size)) {
+ return E_FAIL;
+ }
- DWORD TrackNumber = TRACKNUM(id);
+ DWORD TrackNumber = TRACKNUM(id);
- if (TrackNumber < m_pFile->m_strms.GetCount()) {
- CAviFile::strm_t* s = m_pFile->m_strms[TrackNumber];
+ if (TrackNumber < m_pFile->m_strms.GetCount()) {
+ CAviFile::strm_t* s = m_pFile->m_strms[TrackNumber];
- WORD type = TRACKTYPE(id);
+ WORD type = TRACKTYPE(id);
- if (type == 'db' || type == 'dc' || /*type == 'pc' ||*/ type == 'wb'
- || type == 'iv' || type == '__' || type == 'xx') {
- CAviFile::strm_t::chunk c;
- c.filepos = pos;
- c.size = pSize[TrackNumber];
- c.orgsize = size;
- c.fKeyFrame = size > 0; // TODO: find a better way...
- c.fChunkHdr = true;
- s->cs.Add(c);
+ if (type == 'db' || type == 'dc' || /*type == 'pc' ||*/ type == 'wb'
+ || type == 'iv' || type == '__' || type == 'xx') {
+ CAviFile::strm_t::chunk c;
+ c.filepos = pos;
+ c.size = pSize[TrackNumber];
+ c.orgsize = size;
+ c.fKeyFrame = size > 0; // TODO: find a better way...
+ c.fChunkHdr = true;
+ s->cs.Add(c);
- pSize[TrackNumber] += s->GetChunkSize(size);
+ pSize[TrackNumber] += s->GetChunkSize(size);
- REFERENCE_TIME rt = s->GetRefTime((DWORD)s->cs.GetCount()-1, pSize[TrackNumber]);
- m_rtDuration = max(rt, m_rtDuration);
- }
- }
+ REFERENCE_TIME rt = s->GetRefTime((DWORD)s->cs.GetCount() - 1, pSize[TrackNumber]);
+ m_rtDuration = max(rt, m_rtDuration);
+ }
+ }
- size += (size&1) + 8;
- }
+ size += (size & 1) + 8;
+ }
- m_pFile->Seek(pos + size);
+ m_pFile->Seek(pos + size);
- m_nOpenProgress = m_pFile->GetPos()*100/m_pFile->GetLength();
+ m_nOpenProgress = m_pFile->GetPos() * 100 / m_pFile->GetLength();
- DWORD cmd;
- if (CheckRequest(&cmd)) {
- if (cmd == CMD_EXIT) {
- m_fAbort = true;
- } else {
- Reply(S_OK);
- }
- }
- }
+ DWORD cmd;
+ if (CheckRequest(&cmd)) {
+ if (cmd == CMD_EXIT) {
+ m_fAbort = true;
+ } else {
+ Reply(S_OK);
+ }
+ }
+ }
- return hr;
+ return hr;
}
void CAviSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
- memset((DWORD*)m_tFrame, 0, sizeof(DWORD)*m_pFile->m_avih.dwStreams);
- m_pFile->Seek(0);
+ memset((DWORD*)m_tFrame, 0, sizeof(DWORD)*m_pFile->m_avih.dwStreams);
+ m_pFile->Seek(0);
- DbgLog((LOG_TRACE, 0, _T("Seek: %I64d"), rt/10000));
+ DbgLog((LOG_TRACE, 0, _T("Seek: %I64d"), rt / 10000));
- if (rt > 0) {
- UINT64 minfp = _I64_MAX;
+ if (rt > 0) {
+ UINT64 minfp = _I64_MAX;
- for (unsigned int j = 0; j < m_pFile->m_strms.GetCount(); ++j) {
- CAviFile::strm_t* s = m_pFile->m_strms[j];
+ for (unsigned int j = 0; j < m_pFile->m_strms.GetCount(); ++j) {
+ CAviFile::strm_t* s = m_pFile->m_strms[j];
- if (s->IsRawSubtitleStream()) continue;
+ if (s->IsRawSubtitleStream()) { continue; }
- //ASSERT(s->GetFrame(rt) == s->GetKeyFrame(rt)); // fast seek test
- UINT64 fp = s->cs[s->GetKeyFrame(rt)].filepos;
- minfp = min(minfp, fp);
- }
+ //ASSERT(s->GetFrame(rt) == s->GetKeyFrame(rt)); // fast seek test
+ UINT64 fp = s->cs[s->GetKeyFrame(rt)].filepos;
+ minfp = min(minfp, fp);
+ }
- for (unsigned int j = 0; j < m_pFile->m_strms.GetCount(); ++j) {
- CAviFile::strm_t* s = m_pFile->m_strms[j];
+ for (unsigned int j = 0; j < m_pFile->m_strms.GetCount(); ++j) {
+ CAviFile::strm_t* s = m_pFile->m_strms[j];
- for (unsigned int i = 0; i < s->cs.GetCount(); ++i) {
- CAviFile::strm_t::chunk& c = s->cs[i];
- if (c.filepos >= minfp) {
- m_tFrame[j] = i;
- break;
- }
- }
- }
- DbgLog((LOG_TRACE, 0, _T("minfp: %I64d"), minfp));
- }
+ for (unsigned int i = 0; i < s->cs.GetCount(); ++i) {
+ CAviFile::strm_t::chunk& c = s->cs[i];
+ if (c.filepos >= minfp) {
+ m_tFrame[j] = i;
+ break;
+ }
+ }
+ }
+ DbgLog((LOG_TRACE, 0, _T("minfp: %I64d"), minfp));
+ }
}
bool CAviSplitterFilter::DemuxLoop()
{
- HRESULT hr = S_OK;
-
- size_t nTracks = m_pFile->m_strms.GetCount();
-
- CAtlArray<BOOL> fDiscontinuity;
- fDiscontinuity.SetCount(nTracks);
- memset(fDiscontinuity.GetData(), 0, nTracks*sizeof(bool));
-
- while (SUCCEEDED(hr) && !CheckRequest(NULL)) {
- size_t minTrack = nTracks;
- UINT64 minFilePos = _I64_MAX;
-
- for (unsigned int i = 0; i < nTracks; ++i) {
- CAviFile::strm_t* s = m_pFile->m_strms[i];
-
- DWORD f = m_tFrame[i];
- if (f >= (DWORD)s->cs.GetCount()) {
- continue;
- }
-
- bool fUrgent = s->IsRawSubtitleStream();
-
- if (fUrgent || s->cs[f].filepos < minFilePos) {
- minTrack = i;
- minFilePos = s->cs[f].filepos;
- }
-
- if (fUrgent) {
- break;
- }
- }
-
- if (minTrack == nTracks) {
- break;
- }
-
- DWORD& f = m_tFrame[minTrack];
-
- do {
- CAviFile::strm_t* s = m_pFile->m_strms[minTrack];
-
- m_pFile->Seek(s->cs[f].filepos);
-
- DWORD size = 0;
-
- if (s->cs[f].fChunkHdr) {
- DWORD id = 0;
- if (S_OK != m_pFile->Read(id) || id == 0 || minTrack != TRACKNUM(id)
- || S_OK != m_pFile->Read(size)) {
- fDiscontinuity[minTrack] = true;
- break;
- }
-
- UINT64 expectedsize = (UINT64)-1;
- expectedsize = f < (DWORD)s->cs.GetCount()-1
- ? s->cs[f+1].size - s->cs[f].size
- : s->totalsize - s->cs[f].size;
-
- if (expectedsize != s->GetChunkSize(size)) {
- fDiscontinuity[minTrack] = true;
- //ASSERT(0);
- break;
- }
- } else {
- size = s->cs[f].orgsize;
- }
-
- CAutoPtr<Packet> p(DNew Packet());
-
- p->TrackNumber = (DWORD)minTrack;
- p->bSyncPoint = (BOOL)s->cs[f].fKeyFrame;
- p->bDiscontinuity = fDiscontinuity[minTrack];
- p->rtStart = s->GetRefTime(f, s->cs[f].size);
- p->rtStop = s->GetRefTime(f+1, f+1 < (DWORD)s->cs.GetCount() ? s->cs[f+1].size : s->totalsize);
- p->SetCount(size);
- if (S_OK != (hr = m_pFile->ByteRead(p->GetData(), p->GetCount()))) {
- return true; // break;
- }
+ HRESULT hr = S_OK;
+
+ size_t nTracks = m_pFile->m_strms.GetCount();
+
+ CAtlArray<BOOL> fDiscontinuity;
+ fDiscontinuity.SetCount(nTracks);
+ memset(fDiscontinuity.GetData(), 0, nTracks * sizeof(bool));
+
+ while (SUCCEEDED(hr) && !CheckRequest(NULL)) {
+ size_t minTrack = nTracks;
+ UINT64 minFilePos = _I64_MAX;
+
+ for (unsigned int i = 0; i < nTracks; ++i) {
+ CAviFile::strm_t* s = m_pFile->m_strms[i];
+
+ DWORD f = m_tFrame[i];
+ if (f >= (DWORD)s->cs.GetCount()) {
+ continue;
+ }
+
+ bool fUrgent = s->IsRawSubtitleStream();
+
+ if (fUrgent || s->cs[f].filepos < minFilePos) {
+ minTrack = i;
+ minFilePos = s->cs[f].filepos;
+ }
+
+ if (fUrgent) {
+ break;
+ }
+ }
+
+ if (minTrack == nTracks) {
+ break;
+ }
+
+ DWORD& f = m_tFrame[minTrack];
+
+ do {
+ CAviFile::strm_t* s = m_pFile->m_strms[minTrack];
+
+ m_pFile->Seek(s->cs[f].filepos);
+
+ DWORD size = 0;
+
+ if (s->cs[f].fChunkHdr) {
+ DWORD id = 0;
+ if (S_OK != m_pFile->Read(id) || id == 0 || minTrack != TRACKNUM(id)
+ || S_OK != m_pFile->Read(size)) {
+ fDiscontinuity[minTrack] = true;
+ break;
+ }
+
+ UINT64 expectedsize = (UINT64) - 1;
+ expectedsize = f < (DWORD)s->cs.GetCount() - 1
+ ? s->cs[f + 1].size - s->cs[f].size
+ : s->totalsize - s->cs[f].size;
+
+ if (expectedsize != s->GetChunkSize(size)) {
+ fDiscontinuity[minTrack] = true;
+ //ASSERT(0);
+ break;
+ }
+ } else {
+ size = s->cs[f].orgsize;
+ }
+
+ CAutoPtr<Packet> p(DNew Packet());
+
+ p->TrackNumber = (DWORD)minTrack;
+ p->bSyncPoint = (BOOL)s->cs[f].fKeyFrame;
+ p->bDiscontinuity = fDiscontinuity[minTrack];
+ p->rtStart = s->GetRefTime(f, s->cs[f].size);
+ p->rtStop = s->GetRefTime(f + 1, f + 1 < (DWORD)s->cs.GetCount() ? s->cs[f + 1].size : s->totalsize);
+ p->SetCount(size);
+ if (S_OK != (hr = m_pFile->ByteRead(p->GetData(), p->GetCount()))) {
+ return true; // break;
+ }
#if defined(_DEBUG) && 0
- DbgLog((LOG_TRACE, 0,
- _T("%d (%d): %I64d - %I64d, %I64d - %I64d (size = %d)"),
- minTrack, (int)p->bSyncPoint,
- (p->rtStart)/10000, (p->rtStop)/10000,
- (p->rtStart-m_rtStart)/10000, (p->rtStop-m_rtStart)/10000,
- size));
+ DbgLog((LOG_TRACE, 0,
+ _T("%d (%d): %I64d - %I64d, %I64d - %I64d (size = %d)"),
+ minTrack, (int)p->bSyncPoint,
+ (p->rtStart) / 10000, (p->rtStop) / 10000,
+ (p->rtStart - m_rtStart) / 10000, (p->rtStop - m_rtStart) / 10000,
+ size));
#endif
- m_maxTimeStamp = max(m_maxTimeStamp, p->rtStart);
+ m_maxTimeStamp = max(m_maxTimeStamp, p->rtStart);
- hr = DeliverPacket(p);
+ hr = DeliverPacket(p);
- fDiscontinuity[minTrack] = false;
- } while (0);
+ fDiscontinuity[minTrack] = false;
+ } while (0);
- ++f;
- }
+ ++f;
+ }
- if (m_maxTimeStamp != Packet::INVALID_TIME) {
- m_rtCurrent = m_maxTimeStamp;
- }
- return true;
+ if (m_maxTimeStamp != Packet::INVALID_TIME) {
+ m_rtCurrent = m_maxTimeStamp;
+ }
+ return true;
}
// IMediaSeeking
STDMETHODIMP CAviSplitterFilter::GetDuration(LONGLONG* pDuration)
{
- CheckPointer(pDuration, E_POINTER);
- CheckPointer(m_pFile, VFW_E_NOT_CONNECTED);
-
- if (m_timeformat == TIME_FORMAT_FRAME) {
- for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
- CAviFile::strm_t* s = m_pFile->m_strms[i];
- if (s->strh.fccType == FCC('vids')) {
- *pDuration = s->cs.GetCount();
- return S_OK;
- }
- }
-
- return E_UNEXPECTED;
- }
-
- return __super::GetDuration(pDuration);
+ CheckPointer(pDuration, E_POINTER);
+ CheckPointer(m_pFile, VFW_E_NOT_CONNECTED);
+
+ if (m_timeformat == TIME_FORMAT_FRAME) {
+ for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
+ CAviFile::strm_t* s = m_pFile->m_strms[i];
+ if (s->strh.fccType == FCC('vids')) {
+ *pDuration = s->cs.GetCount();
+ return S_OK;
+ }
+ }
+
+ return E_UNEXPECTED;
+ }
+
+ return __super::GetDuration(pDuration);
}
//
STDMETHODIMP CAviSplitterFilter::IsFormatSupported(const GUID* pFormat)
{
- CheckPointer(pFormat, E_POINTER);
- HRESULT hr = __super::IsFormatSupported(pFormat);
- if (S_OK == hr) {
- return hr;
- }
- return *pFormat == TIME_FORMAT_FRAME ? S_OK : S_FALSE;
+ CheckPointer(pFormat, E_POINTER);
+ HRESULT hr = __super::IsFormatSupported(pFormat);
+ if (S_OK == hr) {
+ return hr;
+ }
+ return *pFormat == TIME_FORMAT_FRAME ? S_OK : S_FALSE;
}
STDMETHODIMP CAviSplitterFilter::GetTimeFormat(GUID* pFormat)
{
- CheckPointer(pFormat, E_POINTER);
- *pFormat = m_timeformat;
- return S_OK;
+ CheckPointer(pFormat, E_POINTER);
+ *pFormat = m_timeformat;
+ return S_OK;
}
STDMETHODIMP CAviSplitterFilter::IsUsingTimeFormat(const GUID* pFormat)
{
- CheckPointer(pFormat, E_POINTER);
- return *pFormat == m_timeformat ? S_OK : S_FALSE;
+ CheckPointer(pFormat, E_POINTER);
+ return *pFormat == m_timeformat ? S_OK : S_FALSE;
}
STDMETHODIMP CAviSplitterFilter::SetTimeFormat(const GUID* pFormat)
{
- CheckPointer(pFormat, E_POINTER);
- if (S_OK != IsFormatSupported(pFormat)) {
- return E_FAIL;
- }
- m_timeformat = *pFormat;
- return S_OK;
+ CheckPointer(pFormat, E_POINTER);
+ if (S_OK != IsFormatSupported(pFormat)) {
+ return E_FAIL;
+ }
+ m_timeformat = *pFormat;
+ return S_OK;
}
STDMETHODIMP CAviSplitterFilter::GetStopPosition(LONGLONG* pStop)
{
- CheckPointer(pStop, E_POINTER);
- if (FAILED(__super::GetStopPosition(pStop))) {
- return E_FAIL;
- }
- if (m_timeformat == TIME_FORMAT_MEDIA_TIME) {
- return S_OK;
- }
- LONGLONG rt = *pStop;
- if (FAILED(ConvertTimeFormat(pStop, &TIME_FORMAT_FRAME, rt, &TIME_FORMAT_MEDIA_TIME))) {
- return E_FAIL;
- }
- return S_OK;
+ CheckPointer(pStop, E_POINTER);
+ if (FAILED(__super::GetStopPosition(pStop))) {
+ return E_FAIL;
+ }
+ if (m_timeformat == TIME_FORMAT_MEDIA_TIME) {
+ return S_OK;
+ }
+ LONGLONG rt = *pStop;
+ if (FAILED(ConvertTimeFormat(pStop, &TIME_FORMAT_FRAME, rt, &TIME_FORMAT_MEDIA_TIME))) {
+ return E_FAIL;
+ }
+ return S_OK;
}
STDMETHODIMP CAviSplitterFilter::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat)
{
- CheckPointer(pTarget, E_POINTER);
-
- const GUID& SourceFormat = pSourceFormat ? *pSourceFormat : m_timeformat;
- const GUID& TargetFormat = pTargetFormat ? *pTargetFormat : m_timeformat;
-
- if (TargetFormat == SourceFormat) {
- *pTarget = Source;
- return S_OK;
- } else if (TargetFormat == TIME_FORMAT_FRAME && SourceFormat == TIME_FORMAT_MEDIA_TIME) {
- for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
- CAviFile::strm_t* s = m_pFile->m_strms[i];
- if (s->strh.fccType == FCC('vids')) {
- *pTarget = s->GetFrame(Source);
- return S_OK;
- }
- }
- } else if (TargetFormat == TIME_FORMAT_MEDIA_TIME && SourceFormat == TIME_FORMAT_FRAME) {
- for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
- CAviFile::strm_t* s = m_pFile->m_strms[i];
- if (s->strh.fccType == FCC('vids')) {
- if (Source < 0 || Source >= (LONGLONG)s->cs.GetCount()) {
- return E_FAIL;
- }
- CAviFile::strm_t::chunk& c = s->cs[(size_t)Source];
- *pTarget = s->GetRefTime((DWORD)Source, c.size);
- return S_OK;
- }
- }
- }
-
- return E_FAIL;
+ CheckPointer(pTarget, E_POINTER);
+
+ const GUID& SourceFormat = pSourceFormat ? *pSourceFormat : m_timeformat;
+ const GUID& TargetFormat = pTargetFormat ? *pTargetFormat : m_timeformat;
+
+ if (TargetFormat == SourceFormat) {
+ *pTarget = Source;
+ return S_OK;
+ } else if (TargetFormat == TIME_FORMAT_FRAME && SourceFormat == TIME_FORMAT_MEDIA_TIME) {
+ for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
+ CAviFile::strm_t* s = m_pFile->m_strms[i];
+ if (s->strh.fccType == FCC('vids')) {
+ *pTarget = s->GetFrame(Source);
+ return S_OK;
+ }
+ }
+ } else if (TargetFormat == TIME_FORMAT_MEDIA_TIME && SourceFormat == TIME_FORMAT_FRAME) {
+ for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
+ CAviFile::strm_t* s = m_pFile->m_strms[i];
+ if (s->strh.fccType == FCC('vids')) {
+ if (Source < 0 || Source >= (LONGLONG)s->cs.GetCount()) {
+ return E_FAIL;
+ }
+ CAviFile::strm_t::chunk& c = s->cs[(size_t)Source];
+ *pTarget = s->GetRefTime((DWORD)Source, c.size);
+ return S_OK;
+ }
+ }
+ }
+
+ return E_FAIL;
}
STDMETHODIMP CAviSplitterFilter::GetPositions(LONGLONG* pCurrent, LONGLONG* pStop)
{
- HRESULT hr;
- if (FAILED(hr = __super::GetPositions(pCurrent, pStop)) || m_timeformat != TIME_FORMAT_FRAME) {
- return hr;
- }
-
- if (pCurrent)
- if (FAILED(ConvertTimeFormat(pCurrent, &TIME_FORMAT_FRAME, *pCurrent, &TIME_FORMAT_MEDIA_TIME))) {
- return E_FAIL;
- }
- if (pStop)
- if (FAILED(ConvertTimeFormat(pStop, &TIME_FORMAT_FRAME, *pStop, &TIME_FORMAT_MEDIA_TIME))) {
- return E_FAIL;
- }
-
- return S_OK;
+ HRESULT hr;
+ if (FAILED(hr = __super::GetPositions(pCurrent, pStop)) || m_timeformat != TIME_FORMAT_FRAME) {
+ return hr;
+ }
+
+ if (pCurrent)
+ if (FAILED(ConvertTimeFormat(pCurrent, &TIME_FORMAT_FRAME, *pCurrent, &TIME_FORMAT_MEDIA_TIME))) {
+ return E_FAIL;
+ }
+ if (pStop)
+ if (FAILED(ConvertTimeFormat(pStop, &TIME_FORMAT_FRAME, *pStop, &TIME_FORMAT_MEDIA_TIME))) {
+ return E_FAIL;
+ }
+
+ return S_OK;
}
HRESULT CAviSplitterFilter::SetPositionsInternal(void* id, LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags)
{
- if (m_timeformat != TIME_FORMAT_FRAME) {
- return __super::SetPositionsInternal(id, pCurrent, dwCurrentFlags, pStop, dwStopFlags);
- }
-
- if (!pCurrent && !pStop
- || (dwCurrentFlags&AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning
- && (dwStopFlags&AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning) {
- return S_OK;
- }
-
- REFERENCE_TIME
- rtCurrent = m_rtCurrent,
- rtStop = m_rtStop;
-
- if ((dwCurrentFlags&AM_SEEKING_PositioningBitsMask)
- && FAILED(ConvertTimeFormat(&rtCurrent, &TIME_FORMAT_FRAME, rtCurrent, &TIME_FORMAT_MEDIA_TIME))) {
- return E_FAIL;
- }
- if ((dwStopFlags&AM_SEEKING_PositioningBitsMask)
- && FAILED(ConvertTimeFormat(&rtStop, &TIME_FORMAT_FRAME, rtStop, &TIME_FORMAT_MEDIA_TIME))) {
- return E_FAIL;
- }
-
- if (pCurrent)
- switch (dwCurrentFlags&AM_SEEKING_PositioningBitsMask) {
- case AM_SEEKING_NoPositioning:
- break;
- case AM_SEEKING_AbsolutePositioning:
- rtCurrent = *pCurrent;
- break;
- case AM_SEEKING_RelativePositioning:
- rtCurrent = rtCurrent + *pCurrent;
- break;
- case AM_SEEKING_IncrementalPositioning:
- rtCurrent = rtCurrent + *pCurrent;
- break;
- }
-
- if (pStop)
- switch (dwStopFlags&AM_SEEKING_PositioningBitsMask) {
- case AM_SEEKING_NoPositioning:
- break;
- case AM_SEEKING_AbsolutePositioning:
- rtStop = *pStop;
- break;
- case AM_SEEKING_RelativePositioning:
- rtStop += *pStop;
- break;
- case AM_SEEKING_IncrementalPositioning:
- rtStop = rtCurrent + *pStop;
- break;
- }
-
- if ((dwCurrentFlags&AM_SEEKING_PositioningBitsMask)
- && pCurrent)
- if (FAILED(ConvertTimeFormat(pCurrent, &TIME_FORMAT_MEDIA_TIME, rtCurrent, &TIME_FORMAT_FRAME))) {
- return E_FAIL;
- }
- if ((dwStopFlags&AM_SEEKING_PositioningBitsMask)
- && pStop)
- if (FAILED(ConvertTimeFormat(pStop, &TIME_FORMAT_MEDIA_TIME, rtStop, &TIME_FORMAT_FRAME))) {
- return E_FAIL;
- }
-
- return __super::SetPositionsInternal(id, pCurrent, dwCurrentFlags, pStop, dwStopFlags);
+ if (m_timeformat != TIME_FORMAT_FRAME) {
+ return __super::SetPositionsInternal(id, pCurrent, dwCurrentFlags, pStop, dwStopFlags);
+ }
+
+ if (!pCurrent && !pStop
+ || (dwCurrentFlags & AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning
+ && (dwStopFlags & AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning) {
+ return S_OK;
+ }
+
+ REFERENCE_TIME
+ rtCurrent = m_rtCurrent,
+ rtStop = m_rtStop;
+
+ if ((dwCurrentFlags & AM_SEEKING_PositioningBitsMask)
+ && FAILED(ConvertTimeFormat(&rtCurrent, &TIME_FORMAT_FRAME, rtCurrent, &TIME_FORMAT_MEDIA_TIME))) {
+ return E_FAIL;
+ }
+ if ((dwStopFlags & AM_SEEKING_PositioningBitsMask)
+ && FAILED(ConvertTimeFormat(&rtStop, &TIME_FORMAT_FRAME, rtStop, &TIME_FORMAT_MEDIA_TIME))) {
+ return E_FAIL;
+ }
+
+ if (pCurrent)
+ switch (dwCurrentFlags & AM_SEEKING_PositioningBitsMask) {
+ case AM_SEEKING_NoPositioning:
+ break;
+ case AM_SEEKING_AbsolutePositioning:
+ rtCurrent = *pCurrent;
+ break;
+ case AM_SEEKING_RelativePositioning:
+ rtCurrent = rtCurrent + *pCurrent;
+ break;
+ case AM_SEEKING_IncrementalPositioning:
+ rtCurrent = rtCurrent + *pCurrent;
+ break;
+ }
+
+ if (pStop)
+ switch (dwStopFlags & AM_SEEKING_PositioningBitsMask) {
+ case AM_SEEKING_NoPositioning:
+ break;
+ case AM_SEEKING_AbsolutePositioning:
+ rtStop = *pStop;
+ break;
+ case AM_SEEKING_RelativePositioning:
+ rtStop += *pStop;
+ break;
+ case AM_SEEKING_IncrementalPositioning:
+ rtStop = rtCurrent + *pStop;
+ break;
+ }
+
+ if ((dwCurrentFlags & AM_SEEKING_PositioningBitsMask)
+ && pCurrent)
+ if (FAILED(ConvertTimeFormat(pCurrent, &TIME_FORMAT_MEDIA_TIME, rtCurrent, &TIME_FORMAT_FRAME))) {
+ return E_FAIL;
+ }
+ if ((dwStopFlags & AM_SEEKING_PositioningBitsMask)
+ && pStop)
+ if (FAILED(ConvertTimeFormat(pStop, &TIME_FORMAT_MEDIA_TIME, rtStop, &TIME_FORMAT_FRAME))) {
+ return E_FAIL;
+ }
+
+ return __super::SetPositionsInternal(id, pCurrent, dwCurrentFlags, pStop, dwStopFlags);
}
// IKeyFrameInfo
STDMETHODIMP CAviSplitterFilter::GetKeyFrameCount(UINT& nKFs)
{
- if (!m_pFile) {
- return E_UNEXPECTED;
- }
+ if (!m_pFile) {
+ return E_UNEXPECTED;
+ }
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- nKFs = 0;
+ nKFs = 0;
- for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
- CAviFile::strm_t* s = m_pFile->m_strms[i];
- if (s->strh.fccType != FCC('vids')) {
- continue;
- }
+ for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
+ CAviFile::strm_t* s = m_pFile->m_strms[i];
+ if (s->strh.fccType != FCC('vids')) {
+ continue;
+ }
- for (unsigned int j = 0; j < s->cs.GetCount(); ++j) {
- CAviFile::strm_t::chunk& c = s->cs[j];
- if (c.fKeyFrame) {
- ++nKFs;
- }
- }
+ for (unsigned int j = 0; j < s->cs.GetCount(); ++j) {
+ CAviFile::strm_t::chunk& c = s->cs[j];
+ if (c.fKeyFrame) {
+ ++nKFs;
+ }
+ }
- if (nKFs == s->cs.GetCount()) {
- hr = S_FALSE;
- }
+ if (nKFs == s->cs.GetCount()) {
+ hr = S_FALSE;
+ }
- break;
- }
+ break;
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CAviSplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs)
{
- CheckPointer(pFormat, E_POINTER);
- CheckPointer(pKFs, E_POINTER);
-
- if (!m_pFile) {
- return E_UNEXPECTED;
- }
- if (*pFormat != TIME_FORMAT_MEDIA_TIME && *pFormat != TIME_FORMAT_FRAME) {
- return E_INVALIDARG;
- }
-
- for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
- CAviFile::strm_t* s = m_pFile->m_strms[i];
- if (s->strh.fccType != FCC('vids')) {
- continue;
- }
- bool fConvertToRefTime = !!(*pFormat == TIME_FORMAT_MEDIA_TIME);
-
- UINT nKFsTmp = 0;
-
- for (unsigned int j = 0; j < s->cs.GetCount() && nKFsTmp < nKFs; ++j) {
- if (s->cs[j].fKeyFrame) {
- pKFs[nKFsTmp++] = fConvertToRefTime ? s->GetRefTime(j, s->cs[j].size) : j;
- }
- }
- nKFs = nKFsTmp;
-
- return S_OK;
- }
-
- return E_FAIL;
+ CheckPointer(pFormat, E_POINTER);
+ CheckPointer(pKFs, E_POINTER);
+
+ if (!m_pFile) {
+ return E_UNEXPECTED;
+ }
+ if (*pFormat != TIME_FORMAT_MEDIA_TIME && *pFormat != TIME_FORMAT_FRAME) {
+ return E_INVALIDARG;
+ }
+
+ for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
+ CAviFile::strm_t* s = m_pFile->m_strms[i];
+ if (s->strh.fccType != FCC('vids')) {
+ continue;
+ }
+ bool fConvertToRefTime = !!(*pFormat == TIME_FORMAT_MEDIA_TIME);
+
+ UINT nKFsTmp = 0;
+
+ for (unsigned int j = 0; j < s->cs.GetCount() && nKFsTmp < nKFs; ++j) {
+ if (s->cs[j].fKeyFrame) {
+ pKFs[nKFsTmp++] = fConvertToRefTime ? s->GetRefTime(j, s->cs[j].size) : j;
+ }
+ }
+ nKFs = nKFsTmp;
+
+ return S_OK;
+ }
+
+ return E_FAIL;
}
//
@@ -902,10 +902,10 @@ STDMETHODIMP CAviSplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENCE_TIM
//
CAviSourceFilter::CAviSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CAviSplitterFilter(pUnk, phr)
+ : CAviSplitterFilter(pUnk, phr)
{
- m_clsid = __uuidof(this);
- m_pInput.Free();
+ m_clsid = __uuidof(this);
+ m_pInput.Free();
}
//
@@ -913,27 +913,27 @@ CAviSourceFilter::CAviSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
//
CAviSplitterOutputPin::CAviSplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseSplitterOutputPin(mts, pName, pFilter, pLock, phr, 0, MAXPACKETS_AVI)
+ : CBaseSplitterOutputPin(mts, pName, pFilter, pLock, phr, 0, MAXPACKETS_AVI)
{
}
HRESULT CAviSplitterOutputPin::CheckConnect(IPin* pPin)
{
- int iPosition = 0;
- CMediaType mt;
- while (S_OK == GetMediaType(iPosition++, &mt)) {
- if (mt.majortype == MEDIATYPE_Video
- && (mt.subtype == FOURCCMap(FCC('IV32'))
- || mt.subtype == FOURCCMap(FCC('IV31'))
- || mt.subtype == FOURCCMap(FCC('IF09')))) {
- CLSID clsid = GetCLSID(GetFilterFromPin(pPin));
- if (clsid == CLSID_VideoMixingRenderer || clsid == CLSID_OverlayMixer) {
- return E_FAIL;
- }
- }
-
- mt.InitMediaType();
- }
-
- return __super::CheckConnect(pPin);
+ int iPosition = 0;
+ CMediaType mt;
+ while (S_OK == GetMediaType(iPosition++, &mt)) {
+ if (mt.majortype == MEDIATYPE_Video
+ && (mt.subtype == FOURCCMap(FCC('IV32'))
+ || mt.subtype == FOURCCMap(FCC('IV31'))
+ || mt.subtype == FOURCCMap(FCC('IF09')))) {
+ CLSID clsid = GetCLSID(GetFilterFromPin(pPin));
+ if (clsid == CLSID_VideoMixingRenderer || clsid == CLSID_OverlayMixer) {
+ return E_FAIL;
+ }
+ }
+
+ mt.InitMediaType();
+ }
+
+ return __super::CheckConnect(pPin);
}
diff --git a/src/filters/parser/AviSplitter/AviSplitter.h b/src/filters/parser/AviSplitter/AviSplitter.h
index 9366c6daf..b899c1ad1 100644
--- a/src/filters/parser/AviSplitter/AviSplitter.h
+++ b/src/filters/parser/AviSplitter/AviSplitter.h
@@ -35,62 +35,62 @@ class CAviFile;
class CAviSplitterOutputPin : public CBaseSplitterOutputPin
{
public:
- CAviSplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
+ CAviSplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
- HRESULT CheckConnect(IPin* pPin);
+ HRESULT CheckConnect(IPin* pPin);
};
class __declspec(uuid("9736D831-9D6C-4E72-B6E7-560EF9181001"))
- CAviSplitterFilter : public CBaseSplitterFilter
+ CAviSplitterFilter : public CBaseSplitterFilter
{
- CAutoVectorPtr<DWORD> m_tFrame;
+ CAutoVectorPtr<DWORD> m_tFrame;
protected:
- CAutoPtr<CAviFile> m_pFile;
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
+ CAutoPtr<CAviFile> m_pFile;
+ HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
+ bool DemuxInit();
+ void DemuxSeek(REFERENCE_TIME rt);
+ bool DemuxLoop();
- HRESULT ReIndex(__int64 end, UINT64* pSize);
+ HRESULT ReIndex(__int64 end, UINT64* pSize);
- REFERENCE_TIME m_maxTimeStamp;
+ REFERENCE_TIME m_maxTimeStamp;
public:
- CAviSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
+ CAviSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // CBaseFilter
+ // CBaseFilter
- STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
+ STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
- // IMediaSeeking
+ // IMediaSeeking
- STDMETHODIMP GetDuration(LONGLONG* pDuration);
+ STDMETHODIMP GetDuration(LONGLONG* pDuration);
- // TODO: this is too ugly, integrate this with the baseclass somehow
- GUID m_timeformat;
- STDMETHODIMP IsFormatSupported(const GUID* pFormat);
- STDMETHODIMP GetTimeFormat(GUID* pFormat);
- STDMETHODIMP IsUsingTimeFormat(const GUID* pFormat);
- STDMETHODIMP SetTimeFormat(const GUID* pFormat);
- STDMETHODIMP GetStopPosition(LONGLONG* pStop);
- STDMETHODIMP ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat);
- STDMETHODIMP GetPositions(LONGLONG* pCurrent, LONGLONG* pStop);
+ // TODO: this is too ugly, integrate this with the baseclass somehow
+ GUID m_timeformat;
+ STDMETHODIMP IsFormatSupported(const GUID* pFormat);
+ STDMETHODIMP GetTimeFormat(GUID* pFormat);
+ STDMETHODIMP IsUsingTimeFormat(const GUID* pFormat);
+ STDMETHODIMP SetTimeFormat(const GUID* pFormat);
+ STDMETHODIMP GetStopPosition(LONGLONG* pStop);
+ STDMETHODIMP ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat);
+ STDMETHODIMP GetPositions(LONGLONG* pCurrent, LONGLONG* pStop);
- HRESULT SetPositionsInternal(void* id, LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
+ HRESULT SetPositionsInternal(void* id, LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
- // IKeyFrameInfo
+ // IKeyFrameInfo
- STDMETHODIMP GetKeyFrameCount(UINT& nKFs);
- STDMETHODIMP GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs);
+ STDMETHODIMP GetKeyFrameCount(UINT& nKFs);
+ STDMETHODIMP GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs);
};
class __declspec(uuid("CEA8DEFF-0AF7-4DB9-9A38-FB3C3AEFC0DE"))
- CAviSourceFilter : public CAviSplitterFilter
+ CAviSourceFilter : public CAviSplitterFilter
{
public:
- CAviSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
+ CAviSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
};
diff --git a/src/filters/parser/BaseSplitter/AsyncReader.cpp b/src/filters/parser/BaseSplitter/AsyncReader.cpp
index 1a14a52b2..7ae1455af 100644
--- a/src/filters/parser/BaseSplitter/AsyncReader.cpp
+++ b/src/filters/parser/BaseSplitter/AsyncReader.cpp
@@ -33,110 +33,110 @@
//
CAsyncFileReader::CAsyncFileReader(CString fn, HRESULT& hr)
- : CUnknown(NAME("CAsyncFileReader"), NULL, &hr)
- , m_len((ULONGLONG)-1)
- , m_hBreakEvent(NULL)
- , m_lOsError(0)
+ : CUnknown(NAME("CAsyncFileReader"), NULL, &hr)
+ , m_len((ULONGLONG) - 1)
+ , m_hBreakEvent(NULL)
+ , m_lOsError(0)
{
- hr = Open(fn, modeRead|shareDenyNone|typeBinary|osSequentialScan) ? S_OK : E_FAIL;
- if (SUCCEEDED(hr)) {
- m_len = GetLength();
- }
+ hr = Open(fn, modeRead | shareDenyNone | typeBinary | osSequentialScan) ? S_OK : E_FAIL;
+ if (SUCCEEDED(hr)) {
+ m_len = GetLength();
+ }
}
CAsyncFileReader::CAsyncFileReader(CAtlList<CHdmvClipInfo::PlaylistItem>& Items, HRESULT& hr)
- : CUnknown(NAME("CAsyncFileReader"), NULL, &hr)
- , m_len((ULONGLONG)-1)
- , m_hBreakEvent(NULL)
- , m_lOsError(0)
+ : CUnknown(NAME("CAsyncFileReader"), NULL, &hr)
+ , m_len((ULONGLONG) - 1)
+ , m_hBreakEvent(NULL)
+ , m_lOsError(0)
{
- hr = OpenFiles(Items, modeRead|shareDenyNone|typeBinary|osSequentialScan) ? S_OK : E_FAIL;
- if (SUCCEEDED(hr)) {
- m_len = GetLength();
- }
+ hr = OpenFiles(Items, modeRead | shareDenyNone | typeBinary | osSequentialScan) ? S_OK : E_FAIL;
+ if (SUCCEEDED(hr)) {
+ m_len = GetLength();
+ }
}
STDMETHODIMP CAsyncFileReader::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- QI(IAsyncReader)
- QI(ISyncReader)
- QI(IFileHandle)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IAsyncReader)
+ QI(ISyncReader)
+ QI(IFileHandle)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// IAsyncReader
STDMETHODIMP CAsyncFileReader::SyncRead(LONGLONG llPosition, LONG lLength, BYTE* pBuffer)
{
- do {
- try {
- if ((ULONGLONG)llPosition+lLength > GetLength()) {
- return E_FAIL; // strange, but the Seek below can return llPosition even if the file is not that big (?)
- }
- if ((ULONGLONG)llPosition != Seek(llPosition, begin)) {
- return E_FAIL;
- }
- if ((UINT)lLength < Read(pBuffer, lLength)) {
- return E_FAIL;
- }
+ do {
+ try {
+ if ((ULONGLONG)llPosition + lLength > GetLength()) {
+ return E_FAIL; // strange, but the Seek below can return llPosition even if the file is not that big (?)
+ }
+ if ((ULONGLONG)llPosition != Seek(llPosition, begin)) {
+ return E_FAIL;
+ }
+ if ((UINT)lLength < Read(pBuffer, lLength)) {
+ return E_FAIL;
+ }
#if 0 // def DEBUG
- static __int64 s_total = 0, s_laststoppos = 0;
- s_total += lLength;
- if (s_laststoppos > llPosition) {
- TRACE(_T("[%I64d - %I64d] %d (%I64d)\n"), llPosition, llPosition + lLength, lLength, s_total);
- }
- s_laststoppos = llPosition + lLength;
+ static __int64 s_total = 0, s_laststoppos = 0;
+ s_total += lLength;
+ if (s_laststoppos > llPosition) {
+ TRACE(_T("[%I64d - %I64d] %d (%I64d)\n"), llPosition, llPosition + lLength, lLength, s_total);
+ }
+ s_laststoppos = llPosition + lLength;
#endif
- return S_OK;
- } catch (CFileException* e) {
- m_lOsError = e->m_lOsError;
- e->Delete();
- Sleep(1);
- CString fn = m_strFileName;
- try {
- Close();
- } catch (CFileException* e) {
- e->Delete();
- }
- try {
- Open(fn, modeRead|shareDenyNone|typeBinary|osSequentialScan);
- } catch (CFileException* e) {
- e->Delete();
- }
- m_strFileName = fn;
- }
- } while (m_hBreakEvent && WaitForSingleObject(m_hBreakEvent, 0) == WAIT_TIMEOUT);
-
- return E_FAIL;
+ return S_OK;
+ } catch (CFileException* e) {
+ m_lOsError = e->m_lOsError;
+ e->Delete();
+ Sleep(1);
+ CString fn = m_strFileName;
+ try {
+ Close();
+ } catch (CFileException* e) {
+ e->Delete();
+ }
+ try {
+ Open(fn, modeRead | shareDenyNone | typeBinary | osSequentialScan);
+ } catch (CFileException* e) {
+ e->Delete();
+ }
+ m_strFileName = fn;
+ }
+ } while (m_hBreakEvent && WaitForSingleObject(m_hBreakEvent, 0) == WAIT_TIMEOUT);
+
+ return E_FAIL;
}
STDMETHODIMP CAsyncFileReader::Length(LONGLONG* pTotal, LONGLONG* pAvailable)
{
- LONGLONG len = m_len >= 0 ? m_len : GetLength();
- if (pTotal) {
- *pTotal = len;
- }
- if (pAvailable) {
- *pAvailable = len;
- }
- return S_OK;
+ LONGLONG len = m_len >= 0 ? m_len : GetLength();
+ if (pTotal) {
+ *pTotal = len;
+ }
+ if (pAvailable) {
+ *pAvailable = len;
+ }
+ return S_OK;
}
// IFileHandle
STDMETHODIMP_(HANDLE) CAsyncFileReader::GetFileHandle()
{
- return m_hFile;
+ return m_hFile;
}
STDMETHODIMP_(LPCTSTR) CAsyncFileReader::GetFileName()
{
- return m_nCurPart != -1 ? m_strFiles[m_nCurPart] : m_strFiles[0];
+ return m_nCurPart != -1 ? m_strFiles[m_nCurPart] : m_strFiles[0];
}
//
@@ -144,99 +144,99 @@ STDMETHODIMP_(LPCTSTR) CAsyncFileReader::GetFileName()
//
CAsyncUrlReader::CAsyncUrlReader(CString url, HRESULT& hr)
- : CAsyncFileReader(url, hr)
+ : CAsyncFileReader(url, hr)
{
- if (SUCCEEDED(hr)) {
- return;
- }
+ if (SUCCEEDED(hr)) {
+ return;
+ }
- m_url = url;
+ m_url = url;
- if (CAMThread::Create()) {
- CallWorker(CMD_INIT);
- }
+ if (CAMThread::Create()) {
+ CallWorker(CMD_INIT);
+ }
- hr = Open(m_fn, modeRead|shareDenyRead|typeBinary|osSequentialScan) ? S_OK : E_FAIL;
- m_len = (ULONGLONG)-1; // force GetLength() return actual length always
+ hr = Open(m_fn, modeRead | shareDenyRead | typeBinary | osSequentialScan) ? S_OK : E_FAIL;
+ m_len = (ULONGLONG) - 1; // force GetLength() return actual length always
}
CAsyncUrlReader::~CAsyncUrlReader()
{
- if (ThreadExists()) {
- CallWorker(CMD_EXIT);
- }
-
- if (!m_fn.IsEmpty()) {
- CMultiFiles::Close();
- DeleteFile(m_fn);
- }
+ if (ThreadExists()) {
+ CallWorker(CMD_EXIT);
+ }
+
+ if (!m_fn.IsEmpty()) {
+ CMultiFiles::Close();
+ DeleteFile(m_fn);
+ }
}
// IAsyncReader
STDMETHODIMP CAsyncUrlReader::Length(LONGLONG* pTotal, LONGLONG* pAvailable)
{
- if (pTotal) {
- *pTotal = 0;
- }
- return __super::Length(NULL, pAvailable);
+ if (pTotal) {
+ *pTotal = 0;
+ }
+ return __super::Length(NULL, pAvailable);
}
// CAMThread
DWORD CAsyncUrlReader::ThreadProc()
{
- AfxSocketInit(NULL);
-
- DWORD cmd = GetRequest();
- if (cmd != CMD_INIT) {
- Reply((DWORD)E_FAIL);
- return (DWORD)-1;
- }
-
- try {
- CInternetSession is;
- CAutoPtr<CStdioFile> fin(is.OpenURL(m_url, 1, INTERNET_FLAG_TRANSFER_BINARY|INTERNET_FLAG_EXISTING_CONNECT|INTERNET_FLAG_NO_CACHE_WRITE));
-
- TCHAR path[_MAX_PATH], fn[_MAX_PATH];
- CFile fout;
- if (GetTempPath(_MAX_PATH, path) && GetTempFileName(path, _T("mpc_http"), 0, fn)
- && fout.Open(fn, modeCreate|modeWrite|shareDenyWrite|typeBinary)) {
- m_fn = fn;
-
- char buff[1024];
- int len = fin->Read(buff, sizeof(buff));
- if (len > 0) {
- fout.Write(buff, len);
- }
-
- Reply(S_OK);
-
- while (!CheckRequest(&cmd)) {
- int len = fin->Read(buff, sizeof(buff));
- if (len > 0) {
- fout.Write(buff, len);
- }
- }
- } else {
- Reply((DWORD)E_FAIL);
- }
-
- fin->Close(); // must close it because the destructor doesn't seem to do it and we will get an exception when "is" is destroying
- } catch (CInternetException* ie) {
- ie->Delete();
- Reply((DWORD)E_FAIL);
- }
-
- //
-
- cmd = GetRequest();
- ASSERT(cmd == CMD_EXIT);
- Reply(S_OK);
-
- //
-
- m_hThread = NULL;
-
- return S_OK;
+ AfxSocketInit(NULL);
+
+ DWORD cmd = GetRequest();
+ if (cmd != CMD_INIT) {
+ Reply((DWORD)E_FAIL);
+ return (DWORD) - 1;
+ }
+
+ try {
+ CInternetSession is;
+ CAutoPtr<CStdioFile> fin(is.OpenURL(m_url, 1, INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_NO_CACHE_WRITE));
+
+ TCHAR path[_MAX_PATH], fn[_MAX_PATH];
+ CFile fout;
+ if (GetTempPath(_MAX_PATH, path) && GetTempFileName(path, _T("mpc_http"), 0, fn)
+ && fout.Open(fn, modeCreate | modeWrite | shareDenyWrite | typeBinary)) {
+ m_fn = fn;
+
+ char buff[1024];
+ int len = fin->Read(buff, sizeof(buff));
+ if (len > 0) {
+ fout.Write(buff, len);
+ }
+
+ Reply(S_OK);
+
+ while (!CheckRequest(&cmd)) {
+ int len = fin->Read(buff, sizeof(buff));
+ if (len > 0) {
+ fout.Write(buff, len);
+ }
+ }
+ } else {
+ Reply((DWORD)E_FAIL);
+ }
+
+ fin->Close(); // must close it because the destructor doesn't seem to do it and we will get an exception when "is" is destroying
+ } catch (CInternetException* ie) {
+ ie->Delete();
+ Reply((DWORD)E_FAIL);
+ }
+
+ //
+
+ cmd = GetRequest();
+ ASSERT(cmd == CMD_EXIT);
+ Reply(S_OK);
+
+ //
+
+ m_hThread = NULL;
+
+ return S_OK;
}
diff --git a/src/filters/parser/BaseSplitter/AsyncReader.h b/src/filters/parser/BaseSplitter/AsyncReader.h
index c41223421..3bac9b034 100644
--- a/src/filters/parser/BaseSplitter/AsyncReader.h
+++ b/src/filters/parser/BaseSplitter/AsyncReader.h
@@ -28,91 +28,91 @@
interface __declspec(uuid("6DDB4EE7-45A0-4459-A508-BD77B32C91B2"))
ISyncReader :
public IUnknown {
- STDMETHOD_(void, SetBreakEvent) (HANDLE hBreakEvent) = 0;
- STDMETHOD_(bool, HasErrors) () = 0;
- STDMETHOD_(void, ClearErrors) () = 0;
- STDMETHOD_(void, SetPTSOffset) (REFERENCE_TIME* rtPTSOffset) = 0;
+ STDMETHOD_(void, SetBreakEvent)(HANDLE hBreakEvent) = 0;
+ STDMETHOD_(bool, HasErrors)() = 0;
+ STDMETHOD_(void, ClearErrors)() = 0;
+ STDMETHOD_(void, SetPTSOffset)(REFERENCE_TIME * rtPTSOffset) = 0;
};
interface __declspec(uuid("7D55F67A-826E-40B9-8A7D-3DF0CBBD272D"))
IFileHandle :
public IUnknown {
- STDMETHOD_(HANDLE, GetFileHandle)() = 0;
- STDMETHOD_(LPCTSTR, GetFileName)() = 0;
+ STDMETHOD_(HANDLE, GetFileHandle)() = 0;
+ STDMETHOD_(LPCTSTR, GetFileName)() = 0;
};
class CAsyncFileReader : public CUnknown, public CMultiFiles, public IAsyncReader, public ISyncReader, public IFileHandle
{
protected:
- ULONGLONG m_len;
- HANDLE m_hBreakEvent;
- LONG m_lOsError; // CFileException::m_lOsError
+ ULONGLONG m_len;
+ HANDLE m_hBreakEvent;
+ LONG m_lOsError; // CFileException::m_lOsError
public:
- CAsyncFileReader(CString fn, HRESULT& hr);
- CAsyncFileReader(CAtlList<CHdmvClipInfo::PlaylistItem>& Items, HRESULT& hr);
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // IAsyncReader
-
- STDMETHODIMP RequestAllocator(IMemAllocator* pPreferred, ALLOCATOR_PROPERTIES* pProps, IMemAllocator** ppActual) {
- return E_NOTIMPL;
- }
- STDMETHODIMP Request(IMediaSample* pSample, DWORD_PTR dwUser) {
- return E_NOTIMPL;
- }
- STDMETHODIMP WaitForNext(DWORD dwTimeout, IMediaSample** ppSample, DWORD_PTR* pdwUser) {
- return E_NOTIMPL;
- }
- STDMETHODIMP SyncReadAligned(IMediaSample* pSample) {
- return E_NOTIMPL;
- }
- STDMETHODIMP SyncRead(LONGLONG llPosition, LONG lLength, BYTE* pBuffer);
- STDMETHODIMP Length(LONGLONG* pTotal, LONGLONG* pAvailable);
- STDMETHODIMP BeginFlush() {
- return E_NOTIMPL;
- }
- STDMETHODIMP EndFlush() {
- return E_NOTIMPL;
- }
-
- // ISyncReader
-
- STDMETHODIMP_(void) SetBreakEvent(HANDLE hBreakEvent) {
- m_hBreakEvent = hBreakEvent;
- }
- STDMETHODIMP_(bool) HasErrors() {
- return m_lOsError != 0;
- }
- STDMETHODIMP_(void) ClearErrors() {
- m_lOsError = 0;
- }
- STDMETHODIMP_(void) SetPTSOffset (REFERENCE_TIME* rtPTSOffset) {
- m_pCurrentPTSOffset = rtPTSOffset;
- };
-
- // IFileHandle
-
- STDMETHODIMP_(HANDLE) GetFileHandle();
- STDMETHODIMP_(LPCTSTR) GetFileName();
+ CAsyncFileReader(CString fn, HRESULT& hr);
+ CAsyncFileReader(CAtlList<CHdmvClipInfo::PlaylistItem>& Items, HRESULT& hr);
+
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ // IAsyncReader
+
+ STDMETHODIMP RequestAllocator(IMemAllocator* pPreferred, ALLOCATOR_PROPERTIES* pProps, IMemAllocator** ppActual) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP Request(IMediaSample* pSample, DWORD_PTR dwUser) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP WaitForNext(DWORD dwTimeout, IMediaSample** ppSample, DWORD_PTR* pdwUser) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP SyncReadAligned(IMediaSample* pSample) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP SyncRead(LONGLONG llPosition, LONG lLength, BYTE* pBuffer);
+ STDMETHODIMP Length(LONGLONG* pTotal, LONGLONG* pAvailable);
+ STDMETHODIMP BeginFlush() {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP EndFlush() {
+ return E_NOTIMPL;
+ }
+
+ // ISyncReader
+
+ STDMETHODIMP_(void) SetBreakEvent(HANDLE hBreakEvent) {
+ m_hBreakEvent = hBreakEvent;
+ }
+ STDMETHODIMP_(bool) HasErrors() {
+ return m_lOsError != 0;
+ }
+ STDMETHODIMP_(void) ClearErrors() {
+ m_lOsError = 0;
+ }
+ STDMETHODIMP_(void) SetPTSOffset(REFERENCE_TIME* rtPTSOffset) {
+ m_pCurrentPTSOffset = rtPTSOffset;
+ };
+
+ // IFileHandle
+
+ STDMETHODIMP_(HANDLE) GetFileHandle();
+ STDMETHODIMP_(LPCTSTR) GetFileName();
};
class CAsyncUrlReader : public CAsyncFileReader, protected CAMThread
{
- CString m_url, m_fn;
+ CString m_url, m_fn;
protected:
- enum {CMD_EXIT, CMD_INIT};
- DWORD ThreadProc();
+ enum {CMD_EXIT, CMD_INIT};
+ DWORD ThreadProc();
public:
- CAsyncUrlReader(CString url, HRESULT& hr);
- virtual ~CAsyncUrlReader();
+ CAsyncUrlReader(CString url, HRESULT& hr);
+ virtual ~CAsyncUrlReader();
- // IAsyncReader
+ // IAsyncReader
- STDMETHODIMP Length(LONGLONG* pTotal, LONGLONG* pAvailable);
+ STDMETHODIMP Length(LONGLONG* pTotal, LONGLONG* pAvailable);
};
diff --git a/src/filters/parser/BaseSplitter/BaseSplitter.cpp b/src/filters/parser/BaseSplitter/BaseSplitter.cpp
index 4787c6222..4e71285e0 100644
--- a/src/filters/parser/BaseSplitter/BaseSplitter.cpp
+++ b/src/filters/parser/BaseSplitter/BaseSplitter.cpp
@@ -39,57 +39,57 @@ CPacketQueue::CPacketQueue() : m_size(0)
void CPacketQueue::Add(CAutoPtr<Packet> p)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- if (p) {
- m_size += p->GetDataSize();
+ if (p) {
+ m_size += p->GetDataSize();
- if (p->bAppendable && !p->bDiscontinuity && !p->pmt
- && p->rtStart == Packet::INVALID_TIME
- && !IsEmpty() && GetTail()->rtStart != Packet::INVALID_TIME) {
- Packet* tail = GetTail();
- size_t oldsize = tail->GetCount();
- size_t newsize = tail->GetCount() + p->GetCount();
- tail->SetCount(newsize, max(1024, (int)newsize)); // doubles the reserved buffer size
- memcpy(tail->GetData() + oldsize, p->GetData(), p->GetCount());
- /*
- GetTail()->Append(*p); // too slow
- */
- return;
- }
- }
+ if (p->bAppendable && !p->bDiscontinuity && !p->pmt
+ && p->rtStart == Packet::INVALID_TIME
+ && !IsEmpty() && GetTail()->rtStart != Packet::INVALID_TIME) {
+ Packet* tail = GetTail();
+ size_t oldsize = tail->GetCount();
+ size_t newsize = tail->GetCount() + p->GetCount();
+ tail->SetCount(newsize, max(1024, (int)newsize)); // doubles the reserved buffer size
+ memcpy(tail->GetData() + oldsize, p->GetData(), p->GetCount());
+ /*
+ GetTail()->Append(*p); // too slow
+ */
+ return;
+ }
+ }
- AddTail(p);
+ AddTail(p);
}
CAutoPtr<Packet> CPacketQueue::Remove()
{
- CAutoLock cAutoLock(this);
- ASSERT(__super::GetCount() > 0);
- CAutoPtr<Packet> p = RemoveHead();
- if (p) {
- m_size -= p->GetDataSize();
- }
- return p;
+ CAutoLock cAutoLock(this);
+ ASSERT(__super::GetCount() > 0);
+ CAutoPtr<Packet> p = RemoveHead();
+ if (p) {
+ m_size -= p->GetDataSize();
+ }
+ return p;
}
void CPacketQueue::RemoveAll()
{
- CAutoLock cAutoLock(this);
- m_size = 0;
- __super::RemoveAll();
+ CAutoLock cAutoLock(this);
+ m_size = 0;
+ __super::RemoveAll();
}
int CPacketQueue::GetCount()
{
- CAutoLock cAutoLock(this);
- return (int)__super::GetCount();
+ CAutoLock cAutoLock(this);
+ return (int)__super::GetCount();
}
int CPacketQueue::GetSize()
{
- CAutoLock cAutoLock(this);
- return m_size;
+ CAutoLock cAutoLock(this);
+ return m_size;
}
//
@@ -97,7 +97,7 @@ int CPacketQueue::GetSize()
//
CBaseSplitterInputPin::CBaseSplitterInputPin(TCHAR* pName, CBaseSplitterFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBasePin(pName, pFilter, pLock, phr, L"Input", PINDIR_INPUT)
+ : CBasePin(pName, pFilter, pLock, phr, L"Input", PINDIR_INPUT)
{
}
@@ -107,85 +107,85 @@ CBaseSplitterInputPin::~CBaseSplitterInputPin()
HRESULT CBaseSplitterInputPin::GetAsyncReader(IAsyncReader** ppAsyncReader)
{
- CheckPointer(ppAsyncReader, E_POINTER);
- *ppAsyncReader = NULL;
- CheckPointer(m_pAsyncReader, VFW_E_NOT_CONNECTED);
- (*ppAsyncReader = m_pAsyncReader)->AddRef();
- return S_OK;
+ CheckPointer(ppAsyncReader, E_POINTER);
+ *ppAsyncReader = NULL;
+ CheckPointer(m_pAsyncReader, VFW_E_NOT_CONNECTED);
+ (*ppAsyncReader = m_pAsyncReader)->AddRef();
+ return S_OK;
}
STDMETHODIMP CBaseSplitterInputPin::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CBaseSplitterInputPin::CheckMediaType(const CMediaType* pmt)
{
- return S_OK;
- /*
- return pmt->majortype == MEDIATYPE_Stream
- ? S_OK
- : E_INVALIDARG;
- */
+ return S_OK;
+ /*
+ return pmt->majortype == MEDIATYPE_Stream
+ ? S_OK
+ : E_INVALIDARG;
+ */
}
HRESULT CBaseSplitterInputPin::CheckConnect(IPin* pPin)
{
- HRESULT hr;
- if (FAILED(hr = __super::CheckConnect(pPin))) {
- return hr;
- }
+ HRESULT hr;
+ if (FAILED(hr = __super::CheckConnect(pPin))) {
+ return hr;
+ }
- return CComQIPtr<IAsyncReader>(pPin) ? S_OK : E_NOINTERFACE;
+ return CComQIPtr<IAsyncReader>(pPin) ? S_OK : E_NOINTERFACE;
}
HRESULT CBaseSplitterInputPin::BreakConnect()
{
- HRESULT hr;
+ HRESULT hr;
- if (FAILED(hr = __super::BreakConnect())) {
- return hr;
- }
+ if (FAILED(hr = __super::BreakConnect())) {
+ return hr;
+ }
- if (FAILED(hr = (static_cast<CBaseSplitterFilter*>(m_pFilter))->BreakConnect(PINDIR_INPUT, this))) {
- return hr;
- }
+ if (FAILED(hr = (static_cast<CBaseSplitterFilter*>(m_pFilter))->BreakConnect(PINDIR_INPUT, this))) {
+ return hr;
+ }
- m_pAsyncReader.Release();
+ m_pAsyncReader.Release();
- return S_OK;
+ return S_OK;
}
HRESULT CBaseSplitterInputPin::CompleteConnect(IPin* pPin)
{
- HRESULT hr;
+ HRESULT hr;
- if (FAILED(hr = __super::CompleteConnect(pPin))) {
- return hr;
- }
+ if (FAILED(hr = __super::CompleteConnect(pPin))) {
+ return hr;
+ }
- CheckPointer(pPin, E_POINTER);
- m_pAsyncReader = pPin;
- CheckPointer(m_pAsyncReader, E_NOINTERFACE);
+ CheckPointer(pPin, E_POINTER);
+ m_pAsyncReader = pPin;
+ CheckPointer(m_pAsyncReader, E_NOINTERFACE);
- if (FAILED(hr = (static_cast<CBaseSplitterFilter*>(m_pFilter))->CompleteConnect(PINDIR_INPUT, this))) {
- return hr;
- }
+ if (FAILED(hr = (static_cast<CBaseSplitterFilter*>(m_pFilter))->CompleteConnect(PINDIR_INPUT, this))) {
+ return hr;
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CBaseSplitterInputPin::BeginFlush()
{
- return E_UNEXPECTED;
+ return E_UNEXPECTED;
}
STDMETHODIMP CBaseSplitterInputPin::EndFlush()
{
- return E_UNEXPECTED;
+ return E_UNEXPECTED;
}
//
@@ -193,28 +193,28 @@ STDMETHODIMP CBaseSplitterInputPin::EndFlush()
//
CBaseSplitterOutputPin::CBaseSplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr, int nBuffers, int QueueMaxPackets)
- : CBaseOutputPin(NAME("CBaseSplitterOutputPin"), pFilter, pLock, phr, pName)
- , m_hrDeliver(S_OK) // just in case it were asked before the worker thread could be created and reset it
- , m_fFlushing(false)
- , m_eEndFlush(TRUE)
- , m_QueueMaxPackets(QueueMaxPackets)
+ : CBaseOutputPin(NAME("CBaseSplitterOutputPin"), pFilter, pLock, phr, pName)
+ , m_hrDeliver(S_OK) // just in case it were asked before the worker thread could be created and reset it
+ , m_fFlushing(false)
+ , m_eEndFlush(TRUE)
+ , m_QueueMaxPackets(QueueMaxPackets)
{
- m_mts.Copy(mts);
- m_nBuffers = max(nBuffers, 1);
- memset(&m_brs, 0, sizeof(m_brs));
- m_brs.rtLastDeliverTime = Packet::INVALID_TIME;
+ m_mts.Copy(mts);
+ m_nBuffers = max(nBuffers, 1);
+ memset(&m_brs, 0, sizeof(m_brs));
+ m_brs.rtLastDeliverTime = Packet::INVALID_TIME;
}
CBaseSplitterOutputPin::CBaseSplitterOutputPin(LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr, int nBuffers, int QueueMaxPackets)
- : CBaseOutputPin(NAME("CBaseSplitterOutputPin"), pFilter, pLock, phr, pName)
- , m_hrDeliver(S_OK) // just in case it were asked before the worker thread could be created and reset it
- , m_fFlushing(false)
- , m_eEndFlush(TRUE)
- , m_QueueMaxPackets(QueueMaxPackets)
+ : CBaseOutputPin(NAME("CBaseSplitterOutputPin"), pFilter, pLock, phr, pName)
+ , m_hrDeliver(S_OK) // just in case it were asked before the worker thread could be created and reset it
+ , m_fFlushing(false)
+ , m_eEndFlush(TRUE)
+ , m_QueueMaxPackets(QueueMaxPackets)
{
- m_nBuffers = max(nBuffers, 1);
- memset(&m_brs, 0, sizeof(m_brs));
- m_brs.rtLastDeliverTime = Packet::INVALID_TIME;
+ m_nBuffers = max(nBuffers, 1);
+ memset(&m_brs, 0, sizeof(m_brs));
+ m_brs.rtLastDeliverTime = Packet::INVALID_TIME;
}
CBaseSplitterOutputPin::~CBaseSplitterOutputPin()
@@ -223,549 +223,549 @@ CBaseSplitterOutputPin::~CBaseSplitterOutputPin()
STDMETHODIMP CBaseSplitterOutputPin::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- // riid == __uuidof(IMediaSeeking) ? m_pFilter->QueryInterface(riid, ppv) :
- QI(IMediaSeeking)
- QI(IPropertyBag)
- QI(IPropertyBag2)
- QI(IDSMPropertyBag)
- QI(IBitRateInfo)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ // riid == __uuidof(IMediaSeeking) ? m_pFilter->QueryInterface(riid, ppv) :
+ QI(IMediaSeeking)
+ QI(IPropertyBag)
+ QI(IPropertyBag2)
+ QI(IDSMPropertyBag)
+ QI(IBitRateInfo)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CBaseSplitterOutputPin::SetName(LPCWSTR pName)
{
- CheckPointer(pName, E_POINTER);
- if (m_pName) {
- delete [] m_pName;
- }
- m_pName = DNew WCHAR[wcslen(pName)+1];
- CheckPointer(m_pName, E_OUTOFMEMORY);
- wcscpy_s(m_pName, wcslen(pName) + 1, pName);
- return S_OK;
+ CheckPointer(pName, E_POINTER);
+ if (m_pName) {
+ delete [] m_pName;
+ }
+ m_pName = DNew WCHAR[wcslen(pName) + 1];
+ CheckPointer(m_pName, E_OUTOFMEMORY);
+ wcscpy_s(m_pName, wcslen(pName) + 1, pName);
+ return S_OK;
}
HRESULT CBaseSplitterOutputPin::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties)
{
- ASSERT(pAlloc);
- ASSERT(pProperties);
+ ASSERT(pAlloc);
+ ASSERT(pProperties);
- HRESULT hr = NOERROR;
+ HRESULT hr = NOERROR;
- pProperties->cBuffers = max(pProperties->cBuffers, m_nBuffers);
- pProperties->cbBuffer = max(m_mt.lSampleSize, 1);
+ pProperties->cBuffers = max(pProperties->cBuffers, m_nBuffers);
+ pProperties->cbBuffer = max(m_mt.lSampleSize, 1);
- // TODO: is this still needed ?
- if (m_mt.subtype == MEDIASUBTYPE_Vorbis && m_mt.formattype == FORMAT_VorbisFormat) {
- // oh great, the oggds vorbis decoder assumes there will be two at least, stupid thing...
- pProperties->cBuffers = max(pProperties->cBuffers, 2);
- }
+ // TODO: is this still needed ?
+ if (m_mt.subtype == MEDIASUBTYPE_Vorbis && m_mt.formattype == FORMAT_VorbisFormat) {
+ // oh great, the oggds vorbis decoder assumes there will be two at least, stupid thing...
+ pProperties->cBuffers = max(pProperties->cBuffers, 2);
+ }
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
- return hr;
- }
+ ALLOCATOR_PROPERTIES Actual;
+ if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
- if (Actual.cbBuffer < pProperties->cbBuffer) {
- return E_FAIL;
- }
- ASSERT(Actual.cBuffers == pProperties->cBuffers);
+ if (Actual.cbBuffer < pProperties->cbBuffer) {
+ return E_FAIL;
+ }
+ ASSERT(Actual.cBuffers == pProperties->cBuffers);
- return NOERROR;
+ return NOERROR;
}
HRESULT CBaseSplitterOutputPin::CheckMediaType(const CMediaType* pmt)
{
- for (size_t i = 0; i < m_mts.GetCount(); i++) {
- if (*pmt == m_mts[i]) {
- return S_OK;
- }
- }
+ for (size_t i = 0; i < m_mts.GetCount(); i++) {
+ if (*pmt == m_mts[i]) {
+ return S_OK;
+ }
+ }
- return E_INVALIDARG;
+ return E_INVALIDARG;
}
HRESULT CBaseSplitterOutputPin::GetMediaType(int iPosition, CMediaType* pmt)
{
- CAutoLock cAutoLock(m_pLock);
+ CAutoLock cAutoLock(m_pLock);
- if (iPosition < 0) {
- return E_INVALIDARG;
- }
- if ((size_t)iPosition >= m_mts.GetCount()) {
- return VFW_S_NO_MORE_ITEMS;
- }
+ if (iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if ((size_t)iPosition >= m_mts.GetCount()) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
- *pmt = m_mts[iPosition];
+ *pmt = m_mts[iPosition];
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CBaseSplitterOutputPin::Notify(IBaseFilter* pSender, Quality q)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
//
HRESULT CBaseSplitterOutputPin::Active()
{
- CAutoLock cAutoLock(m_pLock);
+ CAutoLock cAutoLock(m_pLock);
- if (m_Connected) {
- Create();
- }
+ if (m_Connected) {
+ Create();
+ }
- return __super::Active();
+ return __super::Active();
}
HRESULT CBaseSplitterOutputPin::Inactive()
{
- CAutoLock cAutoLock(m_pLock);
+ CAutoLock cAutoLock(m_pLock);
- if (ThreadExists()) {
- CallWorker(CMD_EXIT);
- }
+ if (ThreadExists()) {
+ CallWorker(CMD_EXIT);
+ }
- return __super::Inactive();
+ return __super::Inactive();
}
HRESULT CBaseSplitterOutputPin::DeliverBeginFlush()
{
- m_eEndFlush.Reset();
- m_fFlushed = false;
- m_fFlushing = true;
- m_hrDeliver = S_FALSE;
- m_queue.RemoveAll();
- HRESULT hr = IsConnected() ? GetConnected()->BeginFlush() : S_OK;
- if (S_OK != hr) {
- m_eEndFlush.Set();
- }
- return hr;
+ m_eEndFlush.Reset();
+ m_fFlushed = false;
+ m_fFlushing = true;
+ m_hrDeliver = S_FALSE;
+ m_queue.RemoveAll();
+ HRESULT hr = IsConnected() ? GetConnected()->BeginFlush() : S_OK;
+ if (S_OK != hr) {
+ m_eEndFlush.Set();
+ }
+ return hr;
}
HRESULT CBaseSplitterOutputPin::DeliverEndFlush()
{
- if (!ThreadExists()) {
- return S_FALSE;
- }
- HRESULT hr = IsConnected() ? GetConnected()->EndFlush() : S_OK;
- m_hrDeliver = S_OK;
- m_fFlushing = false;
- m_fFlushed = true;
- m_eEndFlush.Set();
- return hr;
+ if (!ThreadExists()) {
+ return S_FALSE;
+ }
+ HRESULT hr = IsConnected() ? GetConnected()->EndFlush() : S_OK;
+ m_hrDeliver = S_OK;
+ m_fFlushing = false;
+ m_fFlushed = true;
+ m_eEndFlush.Set();
+ return hr;
}
HRESULT CBaseSplitterOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- m_brs.rtLastDeliverTime = Packet::INVALID_TIME;
- if (m_fFlushing) {
- return S_FALSE;
- }
- m_rtStart = tStart;
- if (!ThreadExists()) {
- return S_FALSE;
- }
- HRESULT hr = __super::DeliverNewSegment(tStart, tStop, dRate);
- if (S_OK != hr) {
- return hr;
- }
- MakeISCRHappy();
- return hr;
+ m_brs.rtLastDeliverTime = Packet::INVALID_TIME;
+ if (m_fFlushing) {
+ return S_FALSE;
+ }
+ m_rtStart = tStart;
+ if (!ThreadExists()) {
+ return S_FALSE;
+ }
+ HRESULT hr = __super::DeliverNewSegment(tStart, tStop, dRate);
+ if (S_OK != hr) {
+ return hr;
+ }
+ MakeISCRHappy();
+ return hr;
}
int CBaseSplitterOutputPin::QueueCount()
{
- return m_queue.GetCount();
+ return m_queue.GetCount();
}
int CBaseSplitterOutputPin::QueueSize()
{
- return m_queue.GetSize();
+ return m_queue.GetSize();
}
HRESULT CBaseSplitterOutputPin::QueueEndOfStream()
{
- return QueuePacket(CAutoPtr<Packet>()); // NULL means EndOfStream
+ return QueuePacket(CAutoPtr<Packet>()); // NULL means EndOfStream
}
HRESULT CBaseSplitterOutputPin::QueuePacket(CAutoPtr<Packet> p)
{
- if (!ThreadExists()) {
- return S_FALSE;
- }
+ if (!ThreadExists()) {
+ return S_FALSE;
+ }
- while (S_OK == m_hrDeliver
- && ((m_queue.GetCount() > (m_QueueMaxPackets*3/2) || m_queue.GetSize() > (MAXPACKETSIZE*3/2))
- || ((m_queue.GetCount() > m_QueueMaxPackets || m_queue.GetSize() > MAXPACKETSIZE) && !(static_cast<CBaseSplitterFilter*>(m_pFilter))->IsAnyPinDrying()))) {
- Sleep(10);
- }
+ while (S_OK == m_hrDeliver
+ && ((m_queue.GetCount() > (m_QueueMaxPackets * 3 / 2) || m_queue.GetSize() > (MAXPACKETSIZE * 3 / 2))
+ || ((m_queue.GetCount() > m_QueueMaxPackets || m_queue.GetSize() > MAXPACKETSIZE) && !(static_cast<CBaseSplitterFilter*>(m_pFilter))->IsAnyPinDrying()))) {
+ Sleep(10);
+ }
- if (S_OK != m_hrDeliver) {
- return m_hrDeliver;
- }
+ if (S_OK != m_hrDeliver) {
+ return m_hrDeliver;
+ }
- m_queue.Add(p);
+ m_queue.Add(p);
- return m_hrDeliver;
+ return m_hrDeliver;
}
bool CBaseSplitterOutputPin::IsDiscontinuous()
{
- return m_mt.majortype == MEDIATYPE_Text
- || m_mt.majortype == MEDIATYPE_ScriptCommand
- || m_mt.majortype == MEDIATYPE_Subtitle
- || m_mt.subtype == MEDIASUBTYPE_DVD_SUBPICTURE
- || m_mt.subtype == MEDIASUBTYPE_CVD_SUBPICTURE
- || m_mt.subtype == MEDIASUBTYPE_SVCD_SUBPICTURE;
+ return m_mt.majortype == MEDIATYPE_Text
+ || m_mt.majortype == MEDIATYPE_ScriptCommand
+ || m_mt.majortype == MEDIATYPE_Subtitle
+ || m_mt.subtype == MEDIASUBTYPE_DVD_SUBPICTURE
+ || m_mt.subtype == MEDIASUBTYPE_CVD_SUBPICTURE
+ || m_mt.subtype == MEDIASUBTYPE_SVCD_SUBPICTURE;
}
bool CBaseSplitterOutputPin::IsActive()
{
- CComPtr<IPin> pPin = this;
- do {
- CComPtr<IPin> pPinTo;
- CComQIPtr<IStreamSwitcherInputPin> pSSIP;
- if (S_OK == pPin->ConnectedTo(&pPinTo) && (pSSIP = pPinTo) && !pSSIP->IsActive()) {
- return false;
- }
- pPin = GetFirstPin(GetFilterFromPin(pPinTo), PINDIR_OUTPUT);
- } while (pPin);
+ CComPtr<IPin> pPin = this;
+ do {
+ CComPtr<IPin> pPinTo;
+ CComQIPtr<IStreamSwitcherInputPin> pSSIP;
+ if (S_OK == pPin->ConnectedTo(&pPinTo) && (pSSIP = pPinTo) && !pSSIP->IsActive()) {
+ return false;
+ }
+ pPin = GetFirstPin(GetFilterFromPin(pPinTo), PINDIR_OUTPUT);
+ } while (pPin);
- return true;
+ return true;
}
DWORD CBaseSplitterOutputPin::ThreadProc()
{
- SetThreadName((DWORD)-1, "CBaseSplitterOutputPin");
- m_hrDeliver = S_OK;
- m_fFlushing = m_fFlushed = false;
- m_eEndFlush.Set();
-
- // fix for Microsoft DTV-DVD Video Decoder - video freeze after STOP/PLAY
- bool iHaaliRenderConnect = false;
- CComPtr<IPin> pPinTo = this, pTmp;
- while (pPinTo && SUCCEEDED(pPinTo->ConnectedTo(&pTmp)) && (pPinTo = pTmp)) {
- pTmp = NULL;
- CComPtr<IBaseFilter> pBF = GetFilterFromPin(pPinTo);
- if (GetCLSID(pBF) == CLSID_DXR) { // Haali Renderer
- iHaaliRenderConnect = true;
- break;
- }
- pPinTo = GetFirstPin(pBF, PINDIR_OUTPUT);
- }
- if (IsConnected() && !iHaaliRenderConnect) {
- GetConnected()->BeginFlush();
- GetConnected()->EndFlush();
- }
-
- for (;;) {
- Sleep(1);
-
- DWORD cmd;
- if (CheckRequest(&cmd)) {
- m_hThread = NULL;
- cmd = GetRequest();
- Reply(S_OK);
- ASSERT(cmd == CMD_EXIT);
- return 0;
- }
-
- int cnt = 0;
- do {
- CAutoPtr<Packet> p;
-
- {
- CAutoLock cAutoLock(&m_queue);
- if ((cnt = m_queue.GetCount()) > 0) {
- p = m_queue.Remove();
- }
- }
-
- if (S_OK == m_hrDeliver && cnt > 0) {
- ASSERT(!m_fFlushing);
-
- m_fFlushed = false;
-
- // flushing can still start here, to release a blocked deliver call
-
- HRESULT hr = p
- ? DeliverPacket(p)
- : DeliverEndOfStream();
-
- m_eEndFlush.Wait(); // .. so we have to wait until it is done
-
- if (hr != S_OK && !m_fFlushed) { // and only report the error in m_hrDeliver if we didn't flush the stream
- // CAutoLock cAutoLock(&m_csQueueLock);
- m_hrDeliver = hr;
- break;
- }
- }
- } while (--cnt > 0);
- }
+ SetThreadName((DWORD) - 1, "CBaseSplitterOutputPin");
+ m_hrDeliver = S_OK;
+ m_fFlushing = m_fFlushed = false;
+ m_eEndFlush.Set();
+
+ // fix for Microsoft DTV-DVD Video Decoder - video freeze after STOP/PLAY
+ bool iHaaliRenderConnect = false;
+ CComPtr<IPin> pPinTo = this, pTmp;
+ while (pPinTo && SUCCEEDED(pPinTo->ConnectedTo(&pTmp)) && (pPinTo = pTmp)) {
+ pTmp = NULL;
+ CComPtr<IBaseFilter> pBF = GetFilterFromPin(pPinTo);
+ if (GetCLSID(pBF) == CLSID_DXR) { // Haali Renderer
+ iHaaliRenderConnect = true;
+ break;
+ }
+ pPinTo = GetFirstPin(pBF, PINDIR_OUTPUT);
+ }
+ if (IsConnected() && !iHaaliRenderConnect) {
+ GetConnected()->BeginFlush();
+ GetConnected()->EndFlush();
+ }
+
+ for (;;) {
+ Sleep(1);
+
+ DWORD cmd;
+ if (CheckRequest(&cmd)) {
+ m_hThread = NULL;
+ cmd = GetRequest();
+ Reply(S_OK);
+ ASSERT(cmd == CMD_EXIT);
+ return 0;
+ }
+
+ int cnt = 0;
+ do {
+ CAutoPtr<Packet> p;
+
+ {
+ CAutoLock cAutoLock(&m_queue);
+ if ((cnt = m_queue.GetCount()) > 0) {
+ p = m_queue.Remove();
+ }
+ }
+
+ if (S_OK == m_hrDeliver && cnt > 0) {
+ ASSERT(!m_fFlushing);
+
+ m_fFlushed = false;
+
+ // flushing can still start here, to release a blocked deliver call
+
+ HRESULT hr = p
+ ? DeliverPacket(p)
+ : DeliverEndOfStream();
+
+ m_eEndFlush.Wait(); // .. so we have to wait until it is done
+
+ if (hr != S_OK && !m_fFlushed) { // and only report the error in m_hrDeliver if we didn't flush the stream
+ // CAutoLock cAutoLock(&m_csQueueLock);
+ m_hrDeliver = hr;
+ break;
+ }
+ }
+ } while (--cnt > 0);
+ }
}
HRESULT CBaseSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
{
- HRESULT hr;
-
- long nBytes = (long)p->GetCount();
-
- if (nBytes == 0) {
- return S_OK;
- }
-
- m_brs.nBytesSinceLastDeliverTime += nBytes;
-
- if (p->rtStart != Packet::INVALID_TIME) {
- if (m_brs.rtLastDeliverTime == Packet::INVALID_TIME) {
- m_brs.rtLastDeliverTime = p->rtStart;
- m_brs.nBytesSinceLastDeliverTime = 0;
- }
-
- if (m_brs.rtLastDeliverTime + 10000000 < p->rtStart) {
- REFERENCE_TIME rtDiff = p->rtStart - m_brs.rtLastDeliverTime;
-
- double secs, bits;
-
- secs = (double)rtDiff / 10000000;
- bits = 8.0 * m_brs.nBytesSinceLastDeliverTime;
- m_brs.nCurrentBitRate = (DWORD)(bits / secs);
-
- m_brs.rtTotalTimeDelivered += rtDiff;
- m_brs.nTotalBytesDelivered += m_brs.nBytesSinceLastDeliverTime;
-
- secs = (double)m_brs.rtTotalTimeDelivered / 10000000;
- bits = 8.0 * m_brs.nTotalBytesDelivered;
- m_brs.nAverageBitRate = (DWORD)(bits / secs);
-
- m_brs.rtLastDeliverTime = p->rtStart;
- m_brs.nBytesSinceLastDeliverTime = 0;
- /*
- TRACE(_T("[%d] c: %d kbps, a: %d kbps\n"),
- p->TrackNumber,
- (m_brs.nCurrentBitRate+500)/1000,
- (m_brs.nAverageBitRate+500)/1000);
- */
- }
-
- double dRate = 1.0;
- if (SUCCEEDED((static_cast<CBaseSplitterFilter*>(m_pFilter))->GetRate(&dRate))) {
- p->rtStart = (REFERENCE_TIME)((double)p->rtStart / dRate);
- p->rtStop = (REFERENCE_TIME)((double)p->rtStop / dRate);
- }
- }
-
- do {
- CComPtr<IMediaSample> pSample;
- if (S_OK != (hr = GetDeliveryBuffer(&pSample, NULL, NULL, 0))) {
- break;
- }
-
- if (nBytes > pSample->GetSize()) {
- pSample.Release();
-
- ALLOCATOR_PROPERTIES props, actual;
- if (S_OK != (hr = m_pAllocator->GetProperties(&props))) {
- break;
- }
- props.cbBuffer = nBytes*3/2;
-
- if (props.cBuffers > 1) {
- if (S_OK != (hr = __super::DeliverBeginFlush())) {
- break;
- }
- if (S_OK != (hr = __super::DeliverEndFlush())) {
- break;
- }
- }
-
- if (S_OK != (hr = m_pAllocator->Decommit())) {
- break;
- }
- if (S_OK != (hr = m_pAllocator->SetProperties(&props, &actual))) {
- break;
- }
- if (S_OK != (hr = m_pAllocator->Commit())) {
- break;
- }
- if (S_OK != (hr = GetDeliveryBuffer(&pSample, NULL, NULL, 0))) {
- break;
- }
- }
-
- if (p->pmt) {
- pSample->SetMediaType(p->pmt);
- p->bDiscontinuity = true;
-
- CAutoLock cAutoLock(m_pLock);
- m_mts.RemoveAll();
- m_mts.Add(*p->pmt);
- }
-
- bool fTimeValid = p->rtStart != Packet::INVALID_TIME;
+ HRESULT hr;
+
+ long nBytes = (long)p->GetCount();
+
+ if (nBytes == 0) {
+ return S_OK;
+ }
+
+ m_brs.nBytesSinceLastDeliverTime += nBytes;
+
+ if (p->rtStart != Packet::INVALID_TIME) {
+ if (m_brs.rtLastDeliverTime == Packet::INVALID_TIME) {
+ m_brs.rtLastDeliverTime = p->rtStart;
+ m_brs.nBytesSinceLastDeliverTime = 0;
+ }
+
+ if (m_brs.rtLastDeliverTime + 10000000 < p->rtStart) {
+ REFERENCE_TIME rtDiff = p->rtStart - m_brs.rtLastDeliverTime;
+
+ double secs, bits;
+
+ secs = (double)rtDiff / 10000000;
+ bits = 8.0 * m_brs.nBytesSinceLastDeliverTime;
+ m_brs.nCurrentBitRate = (DWORD)(bits / secs);
+
+ m_brs.rtTotalTimeDelivered += rtDiff;
+ m_brs.nTotalBytesDelivered += m_brs.nBytesSinceLastDeliverTime;
+
+ secs = (double)m_brs.rtTotalTimeDelivered / 10000000;
+ bits = 8.0 * m_brs.nTotalBytesDelivered;
+ m_brs.nAverageBitRate = (DWORD)(bits / secs);
+
+ m_brs.rtLastDeliverTime = p->rtStart;
+ m_brs.nBytesSinceLastDeliverTime = 0;
+ /*
+ TRACE(_T("[%d] c: %d kbps, a: %d kbps\n"),
+ p->TrackNumber,
+ (m_brs.nCurrentBitRate+500)/1000,
+ (m_brs.nAverageBitRate+500)/1000);
+ */
+ }
+
+ double dRate = 1.0;
+ if (SUCCEEDED((static_cast<CBaseSplitterFilter*>(m_pFilter))->GetRate(&dRate))) {
+ p->rtStart = (REFERENCE_TIME)((double)p->rtStart / dRate);
+ p->rtStop = (REFERENCE_TIME)((double)p->rtStop / dRate);
+ }
+ }
+
+ do {
+ CComPtr<IMediaSample> pSample;
+ if (S_OK != (hr = GetDeliveryBuffer(&pSample, NULL, NULL, 0))) {
+ break;
+ }
+
+ if (nBytes > pSample->GetSize()) {
+ pSample.Release();
+
+ ALLOCATOR_PROPERTIES props, actual;
+ if (S_OK != (hr = m_pAllocator->GetProperties(&props))) {
+ break;
+ }
+ props.cbBuffer = nBytes * 3 / 2;
+
+ if (props.cBuffers > 1) {
+ if (S_OK != (hr = __super::DeliverBeginFlush())) {
+ break;
+ }
+ if (S_OK != (hr = __super::DeliverEndFlush())) {
+ break;
+ }
+ }
+
+ if (S_OK != (hr = m_pAllocator->Decommit())) {
+ break;
+ }
+ if (S_OK != (hr = m_pAllocator->SetProperties(&props, &actual))) {
+ break;
+ }
+ if (S_OK != (hr = m_pAllocator->Commit())) {
+ break;
+ }
+ if (S_OK != (hr = GetDeliveryBuffer(&pSample, NULL, NULL, 0))) {
+ break;
+ }
+ }
+
+ if (p->pmt) {
+ pSample->SetMediaType(p->pmt);
+ p->bDiscontinuity = true;
+
+ CAutoLock cAutoLock(m_pLock);
+ m_mts.RemoveAll();
+ m_mts.Add(*p->pmt);
+ }
+
+ bool fTimeValid = p->rtStart != Packet::INVALID_TIME;
#if defined(_DEBUG) && 0
- TRACE(_T("[%d]: d%d s%d p%d, b=%d, [%20I64d - %20I64d]\n"),
- p->TrackNumber,
- p->bDiscontinuity, p->bSyncPoint, fTimeValid && p->rtStart < 0,
- nBytes, p->rtStart, p->rtStop);
+ TRACE(_T("[%d]: d%d s%d p%d, b=%d, [%20I64d - %20I64d]\n"),
+ p->TrackNumber,
+ p->bDiscontinuity, p->bSyncPoint, fTimeValid && p->rtStart < 0,
+ nBytes, p->rtStart, p->rtStop);
#endif
- ASSERT(!p->bSyncPoint || fTimeValid);
-
- BYTE* pData = NULL;
- if (S_OK != (hr = pSample->GetPointer(&pData)) || !pData) {
- break;
- }
- memcpy(pData, p->GetData(), nBytes);
- if (S_OK != (hr = pSample->SetActualDataLength(nBytes))) {
- break;
- }
- if (S_OK != (hr = pSample->SetTime(fTimeValid ? &p->rtStart : NULL, fTimeValid ? &p->rtStop : NULL))) {
- break;
- }
- if (S_OK != (hr = pSample->SetMediaTime(NULL, NULL))) {
- break;
- }
- if (S_OK != (hr = pSample->SetDiscontinuity(p->bDiscontinuity))) {
- break;
- }
- if (S_OK != (hr = pSample->SetSyncPoint(p->bSyncPoint))) {
- break;
- }
- if (S_OK != (hr = pSample->SetPreroll(fTimeValid && p->rtStart < 0))) {
- break;
- }
- if (S_OK != (hr = Deliver(pSample))) {
- break;
- }
- } while (false);
-
- return hr;
+ ASSERT(!p->bSyncPoint || fTimeValid);
+
+ BYTE* pData = NULL;
+ if (S_OK != (hr = pSample->GetPointer(&pData)) || !pData) {
+ break;
+ }
+ memcpy(pData, p->GetData(), nBytes);
+ if (S_OK != (hr = pSample->SetActualDataLength(nBytes))) {
+ break;
+ }
+ if (S_OK != (hr = pSample->SetTime(fTimeValid ? &p->rtStart : NULL, fTimeValid ? &p->rtStop : NULL))) {
+ break;
+ }
+ if (S_OK != (hr = pSample->SetMediaTime(NULL, NULL))) {
+ break;
+ }
+ if (S_OK != (hr = pSample->SetDiscontinuity(p->bDiscontinuity))) {
+ break;
+ }
+ if (S_OK != (hr = pSample->SetSyncPoint(p->bSyncPoint))) {
+ break;
+ }
+ if (S_OK != (hr = pSample->SetPreroll(fTimeValid && p->rtStart < 0))) {
+ break;
+ }
+ if (S_OK != (hr = Deliver(pSample))) {
+ break;
+ }
+ } while (false);
+
+ return hr;
}
void CBaseSplitterOutputPin::MakeISCRHappy()
{
- CComPtr<IPin> pPinTo = this, pTmp;
- while (pPinTo && SUCCEEDED(pPinTo->ConnectedTo(&pTmp)) && (pPinTo = pTmp)) {
- pTmp = NULL;
+ CComPtr<IPin> pPinTo = this, pTmp;
+ while (pPinTo && SUCCEEDED(pPinTo->ConnectedTo(&pTmp)) && (pPinTo = pTmp)) {
+ pTmp = NULL;
- CComPtr<IBaseFilter> pBF = GetFilterFromPin(pPinTo);
+ CComPtr<IBaseFilter> pBF = GetFilterFromPin(pPinTo);
- if (GetCLSID(pBF) == GUIDFromCString(_T("{48025243-2D39-11CE-875D-00608CB78066}"))) { // ISCR
- CAutoPtr<Packet> p(DNew Packet());
- p->TrackNumber = (DWORD)-1;
- p->rtStart = -1;
- p->rtStop = 0;
- p->bSyncPoint = FALSE;
- p->SetData(" ", 2);
- QueuePacket(p);
- break;
- }
+ if (GetCLSID(pBF) == GUIDFromCString(_T("{48025243-2D39-11CE-875D-00608CB78066}"))) { // ISCR
+ CAutoPtr<Packet> p(DNew Packet());
+ p->TrackNumber = (DWORD) - 1;
+ p->rtStart = -1;
+ p->rtStop = 0;
+ p->bSyncPoint = FALSE;
+ p->SetData(" ", 2);
+ QueuePacket(p);
+ break;
+ }
- pPinTo = GetFirstPin(pBF, PINDIR_OUTPUT);
- }
+ pPinTo = GetFirstPin(pBF, PINDIR_OUTPUT);
+ }
}
HRESULT CBaseSplitterOutputPin::GetDeliveryBuffer(IMediaSample** ppSample, REFERENCE_TIME* pStartTime, REFERENCE_TIME* pEndTime, DWORD dwFlags)
{
- return __super::GetDeliveryBuffer(ppSample, pStartTime, pEndTime, dwFlags);
+ return __super::GetDeliveryBuffer(ppSample, pStartTime, pEndTime, dwFlags);
}
HRESULT CBaseSplitterOutputPin::Deliver(IMediaSample* pSample)
{
- return __super::Deliver(pSample);
+ return __super::Deliver(pSample);
}
// IMediaSeeking
STDMETHODIMP CBaseSplitterOutputPin::GetCapabilities(DWORD* pCapabilities)
{
- return (static_cast<CBaseSplitterFilter*>(m_pFilter))->GetCapabilities(pCapabilities);
+ return (static_cast<CBaseSplitterFilter*>(m_pFilter))->GetCapabilities(pCapabilities);
}
STDMETHODIMP CBaseSplitterOutputPin::CheckCapabilities(DWORD* pCapabilities)
{
- return (static_cast<CBaseSplitterFilter*>(m_pFilter))->CheckCapabilities(pCapabilities);
+ return (static_cast<CBaseSplitterFilter*>(m_pFilter))->CheckCapabilities(pCapabilities);
}
STDMETHODIMP CBaseSplitterOutputPin::IsFormatSupported(const GUID* pFormat)
{
- return (static_cast<CBaseSplitterFilter*>(m_pFilter))->IsFormatSupported(pFormat);
+ return (static_cast<CBaseSplitterFilter*>(m_pFilter))->IsFormatSupported(pFormat);
}
STDMETHODIMP CBaseSplitterOutputPin::QueryPreferredFormat(GUID* pFormat)
{
- return (static_cast<CBaseSplitterFilter*>(m_pFilter))->QueryPreferredFormat(pFormat);
+ return (static_cast<CBaseSplitterFilter*>(m_pFilter))->QueryPreferredFormat(pFormat);
}
STDMETHODIMP CBaseSplitterOutputPin::GetTimeFormat(GUID* pFormat)
{
- return (static_cast<CBaseSplitterFilter*>(m_pFilter))->GetTimeFormat(pFormat);
+ return (static_cast<CBaseSplitterFilter*>(m_pFilter))->GetTimeFormat(pFormat);
}
STDMETHODIMP CBaseSplitterOutputPin::IsUsingTimeFormat(const GUID* pFormat)
{
- return (static_cast<CBaseSplitterFilter*>(m_pFilter))->IsUsingTimeFormat(pFormat);
+ return (static_cast<CBaseSplitterFilter*>(m_pFilter))->IsUsingTimeFormat(pFormat);
}
STDMETHODIMP CBaseSplitterOutputPin::SetTimeFormat(const GUID* pFormat)
{
- return (static_cast<CBaseSplitterFilter*>(m_pFilter))->SetTimeFormat(pFormat);
+ return (static_cast<CBaseSplitterFilter*>(m_pFilter))->SetTimeFormat(pFormat);
}
STDMETHODIMP CBaseSplitterOutputPin::GetDuration(LONGLONG* pDuration)
{
- return (static_cast<CBaseSplitterFilter*>(m_pFilter))->GetDuration(pDuration);
+ return (static_cast<CBaseSplitterFilter*>(m_pFilter))->GetDuration(pDuration);
}
STDMETHODIMP CBaseSplitterOutputPin::GetStopPosition(LONGLONG* pStop)
{
- return (static_cast<CBaseSplitterFilter*>(m_pFilter))->GetStopPosition(pStop);
+ return (static_cast<CBaseSplitterFilter*>(m_pFilter))->GetStopPosition(pStop);
}
STDMETHODIMP CBaseSplitterOutputPin::GetCurrentPosition(LONGLONG* pCurrent)
{
- return (static_cast<CBaseSplitterFilter*>(m_pFilter))->GetCurrentPosition(pCurrent);
+ return (static_cast<CBaseSplitterFilter*>(m_pFilter))->GetCurrentPosition(pCurrent);
}
STDMETHODIMP CBaseSplitterOutputPin::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat)
{
- return (static_cast<CBaseSplitterFilter*>(m_pFilter))->ConvertTimeFormat(pTarget, pTargetFormat, Source, pSourceFormat);
+ return (static_cast<CBaseSplitterFilter*>(m_pFilter))->ConvertTimeFormat(pTarget, pTargetFormat, Source, pSourceFormat);
}
STDMETHODIMP CBaseSplitterOutputPin::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags)
{
- return (static_cast<CBaseSplitterFilter*>(m_pFilter))->SetPositionsInternal(this, pCurrent, dwCurrentFlags, pStop, dwStopFlags);
+ return (static_cast<CBaseSplitterFilter*>(m_pFilter))->SetPositionsInternal(this, pCurrent, dwCurrentFlags, pStop, dwStopFlags);
}
STDMETHODIMP CBaseSplitterOutputPin::GetPositions(LONGLONG* pCurrent, LONGLONG* pStop)
{
- return (static_cast<CBaseSplitterFilter*>(m_pFilter))->GetPositions(pCurrent, pStop);
+ return (static_cast<CBaseSplitterFilter*>(m_pFilter))->GetPositions(pCurrent, pStop);
}
STDMETHODIMP CBaseSplitterOutputPin::GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest)
{
- return (static_cast<CBaseSplitterFilter*>(m_pFilter))->GetAvailable(pEarliest, pLatest);
+ return (static_cast<CBaseSplitterFilter*>(m_pFilter))->GetAvailable(pEarliest, pLatest);
}
STDMETHODIMP CBaseSplitterOutputPin::SetRate(double dRate)
{
- return (static_cast<CBaseSplitterFilter*>(m_pFilter))->SetRate(dRate);
+ return (static_cast<CBaseSplitterFilter*>(m_pFilter))->SetRate(dRate);
}
STDMETHODIMP CBaseSplitterOutputPin::GetRate(double* pdRate)
{
- return (static_cast<CBaseSplitterFilter*>(m_pFilter))->GetRate(pdRate);
+ return (static_cast<CBaseSplitterFilter*>(m_pFilter))->GetRate(pdRate);
}
STDMETHODIMP CBaseSplitterOutputPin::GetPreroll(LONGLONG* pllPreroll)
{
- return (static_cast<CBaseSplitterFilter*>(m_pFilter))->GetPreroll(pllPreroll);
+ return (static_cast<CBaseSplitterFilter*>(m_pFilter))->GetPreroll(pllPreroll);
}
//
@@ -773,845 +773,842 @@ STDMETHODIMP CBaseSplitterOutputPin::GetPreroll(LONGLONG* pllPreroll)
//
CBaseSplitterFilter::CBaseSplitterFilter(LPCTSTR pName, LPUNKNOWN pUnk, HRESULT* phr, const CLSID& clsid, int QueueMaxPackets)
- : CBaseFilter(pName, pUnk, this, clsid)
- , m_rtDuration(0), m_rtStart(0), m_rtStop(0), m_rtCurrent(0)
- , m_dRate(1.0)
- , m_nOpenProgress(100)
- , m_fAbort(false)
- , m_rtLastStart(_I64_MIN)
- , m_rtLastStop(_I64_MIN)
- , m_priority(THREAD_PRIORITY_NORMAL)
- , m_QueueMaxPackets(QueueMaxPackets)
+ : CBaseFilter(pName, pUnk, this, clsid)
+ , m_rtDuration(0), m_rtStart(0), m_rtStop(0), m_rtCurrent(0)
+ , m_dRate(1.0)
+ , m_nOpenProgress(100)
+ , m_fAbort(false)
+ , m_rtLastStart(_I64_MIN)
+ , m_rtLastStop(_I64_MIN)
+ , m_priority(THREAD_PRIORITY_NORMAL)
+ , m_QueueMaxPackets(QueueMaxPackets)
{
- if (phr) {
- *phr = S_OK;
- }
+ if (phr) {
+ *phr = S_OK;
+ }
- m_pInput.Attach(DNew CBaseSplitterInputPin(NAME("CBaseSplitterInputPin"), this, this, phr));
+ m_pInput.Attach(DNew CBaseSplitterInputPin(NAME("CBaseSplitterInputPin"), this, this, phr));
}
CBaseSplitterFilter::~CBaseSplitterFilter()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- CAMThread::CallWorker(CMD_EXIT);
- CAMThread::Close();
+ CAMThread::CallWorker(CMD_EXIT);
+ CAMThread::Close();
}
STDMETHODIMP CBaseSplitterFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- *ppv = NULL;
+ *ppv = NULL;
- if (m_pInput && riid == __uuidof(IFileSourceFilter)) {
- return E_NOINTERFACE;
- }
+ if (m_pInput && riid == __uuidof(IFileSourceFilter)) {
+ return E_NOINTERFACE;
+ }
- return
- QI(IFileSourceFilter)
- QI(IMediaSeeking)
- QI(IAMOpenProgress)
- QI2(IAMMediaContent)
- QI2(IAMExtendedSeeking)
- QI(IKeyFrameInfo)
- QI(IBufferInfo)
- QI(IPropertyBag)
- QI(IPropertyBag2)
- QI(IDSMPropertyBag)
- QI(IDSMResourceBag)
- QI(IDSMChapterBag)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IFileSourceFilter)
+ QI(IMediaSeeking)
+ QI(IAMOpenProgress)
+ QI2(IAMMediaContent)
+ QI2(IAMExtendedSeeking)
+ QI(IKeyFrameInfo)
+ QI(IBufferInfo)
+ QI(IPropertyBag)
+ QI(IPropertyBag2)
+ QI(IDSMPropertyBag)
+ QI(IDSMResourceBag)
+ QI(IDSMChapterBag)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
CBaseSplitterOutputPin* CBaseSplitterFilter::GetOutputPin(DWORD TrackNum)
{
- CAutoLock cAutoLock(&m_csPinMap);
+ CAutoLock cAutoLock(&m_csPinMap);
- CBaseSplitterOutputPin* pPin = NULL;
- m_pPinMap.Lookup(TrackNum, pPin);
- return pPin;
+ CBaseSplitterOutputPin* pPin = NULL;
+ m_pPinMap.Lookup(TrackNum, pPin);
+ return pPin;
}
DWORD CBaseSplitterFilter::GetOutputTrackNum(CBaseSplitterOutputPin* pPin)
{
- CAutoLock cAutoLock(&m_csPinMap);
+ CAutoLock cAutoLock(&m_csPinMap);
- POSITION pos = m_pPinMap.GetStartPosition();
- while (pos) {
- DWORD TrackNum;
- CBaseSplitterOutputPin* pPinTmp;
- m_pPinMap.GetNextAssoc(pos, TrackNum, pPinTmp);
- if (pPinTmp == pPin) {
- return TrackNum;
- }
- }
+ POSITION pos = m_pPinMap.GetStartPosition();
+ while (pos) {
+ DWORD TrackNum;
+ CBaseSplitterOutputPin* pPinTmp;
+ m_pPinMap.GetNextAssoc(pos, TrackNum, pPinTmp);
+ if (pPinTmp == pPin) {
+ return TrackNum;
+ }
+ }
- return (DWORD)-1;
+ return (DWORD) - 1;
}
HRESULT CBaseSplitterFilter::RenameOutputPin(DWORD TrackNumSrc, DWORD TrackNumDst, const AM_MEDIA_TYPE* pmt)
{
- CAutoLock cAutoLock(&m_csPinMap);
+ CAutoLock cAutoLock(&m_csPinMap);
- CBaseSplitterOutputPin* pPin;
- if (m_pPinMap.Lookup(TrackNumSrc, pPin)) {
- if (CComQIPtr<IPin> pPinTo = pPin->GetConnected()) {
- if (pmt && S_OK != pPinTo->QueryAccept(pmt)) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- }
+ CBaseSplitterOutputPin* pPin;
+ if (m_pPinMap.Lookup(TrackNumSrc, pPin)) {
+ if (CComQIPtr<IPin> pPinTo = pPin->GetConnected()) {
+ if (pmt && S_OK != pPinTo->QueryAccept(pmt)) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+ }
- m_pPinMap.RemoveKey(TrackNumSrc);
- m_pPinMap[TrackNumDst] = pPin;
+ m_pPinMap.RemoveKey(TrackNumSrc);
+ m_pPinMap[TrackNumDst] = pPin;
- if (pmt) {
- CAutoLock cAutoLock(&m_csmtnew);
- m_mtnew[TrackNumDst] = *pmt;
- }
+ if (pmt) {
+ CAutoLock cAutoLock(&m_csmtnew);
+ m_mtnew[TrackNumDst] = *pmt;
+ }
- return S_OK;
- }
+ return S_OK;
+ }
- return E_FAIL;
+ return E_FAIL;
}
HRESULT CBaseSplitterFilter::AddOutputPin(DWORD TrackNum, CAutoPtr<CBaseSplitterOutputPin> pPin)
{
- CAutoLock cAutoLock(&m_csPinMap);
+ CAutoLock cAutoLock(&m_csPinMap);
- if (!pPin) {
- return E_INVALIDARG;
- }
- m_pPinMap[TrackNum] = pPin;
- m_pOutputs.AddTail(pPin);
- return S_OK;
+ if (!pPin) {
+ return E_INVALIDARG;
+ }
+ m_pPinMap[TrackNum] = pPin;
+ m_pOutputs.AddTail(pPin);
+ return S_OK;
}
HRESULT CBaseSplitterFilter::DeleteOutputs()
{
- m_rtDuration = 0;
+ m_rtDuration = 0;
- m_pRetiredOutputs.RemoveAll();
+ m_pRetiredOutputs.RemoveAll();
- CAutoLock cAutoLockF(this);
- if (m_State != State_Stopped) {
- return VFW_E_NOT_STOPPED;
- }
+ CAutoLock cAutoLockF(this);
+ if (m_State != State_Stopped) {
+ return VFW_E_NOT_STOPPED;
+ }
- while (m_pOutputs.GetCount()) {
- CAutoPtr<CBaseSplitterOutputPin> pPin = m_pOutputs.RemoveHead();
- if (IPin* pPinTo = pPin->GetConnected()) {
- pPinTo->Disconnect();
- }
- pPin->Disconnect();
- // we can't just let it be deleted now, something might have AddRefed on it (graphedit...)
- m_pRetiredOutputs.AddTail(pPin);
- }
+ while (m_pOutputs.GetCount()) {
+ CAutoPtr<CBaseSplitterOutputPin> pPin = m_pOutputs.RemoveHead();
+ if (IPin* pPinTo = pPin->GetConnected()) {
+ pPinTo->Disconnect();
+ }
+ pPin->Disconnect();
+ // we can't just let it be deleted now, something might have AddRefed on it (graphedit...)
+ m_pRetiredOutputs.AddTail(pPin);
+ }
- CAutoLock cAutoLockPM(&m_csPinMap);
- m_pPinMap.RemoveAll();
+ CAutoLock cAutoLockPM(&m_csPinMap);
+ m_pPinMap.RemoveAll();
- CAutoLock cAutoLockMT(&m_csmtnew);
- m_mtnew.RemoveAll();
+ CAutoLock cAutoLockMT(&m_csmtnew);
+ m_mtnew.RemoveAll();
- RemoveAll();
- ResRemoveAll();
- ChapRemoveAll();
+ RemoveAll();
+ ResRemoveAll();
+ ChapRemoveAll();
- m_fontinst.UninstallFonts();
+ m_fontinst.UninstallFonts();
- m_pSyncReader.Release();
+ m_pSyncReader.Release();
- return S_OK;
+ return S_OK;
}
void CBaseSplitterFilter::DeliverBeginFlush()
{
- m_fFlushing = true;
- POSITION pos = m_pOutputs.GetHeadPosition();
- while (pos) {
- m_pOutputs.GetNext(pos)->DeliverBeginFlush();
- }
+ m_fFlushing = true;
+ POSITION pos = m_pOutputs.GetHeadPosition();
+ while (pos) {
+ m_pOutputs.GetNext(pos)->DeliverBeginFlush();
+ }
}
void CBaseSplitterFilter::DeliverEndFlush()
{
- POSITION pos = m_pOutputs.GetHeadPosition();
- while (pos) {
- m_pOutputs.GetNext(pos)->DeliverEndFlush();
- }
- m_fFlushing = false;
- m_eEndFlush.Set();
+ POSITION pos = m_pOutputs.GetHeadPosition();
+ while (pos) {
+ m_pOutputs.GetNext(pos)->DeliverEndFlush();
+ }
+ m_fFlushing = false;
+ m_eEndFlush.Set();
}
DWORD CBaseSplitterFilter::ThreadProc()
{
- if (m_pSyncReader) {
- m_pSyncReader->SetBreakEvent(GetRequestHandle());
- }
+ if (m_pSyncReader) {
+ m_pSyncReader->SetBreakEvent(GetRequestHandle());
+ }
- if (!DemuxInit()) {
- for (;;) {
- DWORD cmd = GetRequest();
- if (cmd == CMD_EXIT) {
- CAMThread::m_hThread = NULL;
- }
- Reply(S_OK);
- if (cmd == CMD_EXIT) {
- return 0;
- }
- }
- }
+ if (!DemuxInit()) {
+ for (;;) {
+ DWORD cmd = GetRequest();
+ if (cmd == CMD_EXIT) {
+ CAMThread::m_hThread = NULL;
+ }
+ Reply(S_OK);
+ if (cmd == CMD_EXIT) {
+ return 0;
+ }
+ }
+ }
- m_eEndFlush.Set();
- m_fFlushing = false;
+ m_eEndFlush.Set();
+ m_fFlushing = false;
- for (DWORD cmd = (DWORD)-1; ; cmd = GetRequest()) {
- if (cmd == CMD_EXIT) {
- m_hThread = NULL;
- Reply(S_OK);
- return 0;
- }
+ for (DWORD cmd = (DWORD) - 1; ; cmd = GetRequest()) {
+ if (cmd == CMD_EXIT) {
+ m_hThread = NULL;
+ Reply(S_OK);
+ return 0;
+ }
- SetThreadPriority(m_hThread, m_priority = THREAD_PRIORITY_NORMAL);
+ SetThreadPriority(m_hThread, m_priority = THREAD_PRIORITY_NORMAL);
- m_rtStart = m_rtNewStart;
- m_rtStop = m_rtNewStop;
+ m_rtStart = m_rtNewStart;
+ m_rtStop = m_rtNewStop;
- DemuxSeek(m_rtStart);
+ DemuxSeek(m_rtStart);
- if (cmd != (DWORD)-1) {
- Reply(S_OK);
- }
+ if (cmd != (DWORD) - 1) {
+ Reply(S_OK);
+ }
- m_eEndFlush.Wait();
+ m_eEndFlush.Wait();
- m_pActivePins.RemoveAll();
+ m_pActivePins.RemoveAll();
- POSITION pos = m_pOutputs.GetHeadPosition();
- while (pos && !m_fFlushing) {
- CBaseSplitterOutputPin* pPin = m_pOutputs.GetNext(pos);
- if (pPin->IsConnected() && pPin->IsActive()) {
- m_pActivePins.AddTail(pPin);
- pPin->DeliverNewSegment(m_rtStart, m_rtStop, m_dRate);
- }
- }
+ POSITION pos = m_pOutputs.GetHeadPosition();
+ while (pos && !m_fFlushing) {
+ CBaseSplitterOutputPin* pPin = m_pOutputs.GetNext(pos);
+ if (pPin->IsConnected() && pPin->IsActive()) {
+ m_pActivePins.AddTail(pPin);
+ pPin->DeliverNewSegment(m_rtStart, m_rtStop, m_dRate);
+ }
+ }
- do {
- m_bDiscontinuitySent.RemoveAll();
- } while (!DemuxLoop());
+ do {
+ m_bDiscontinuitySent.RemoveAll();
+ } while (!DemuxLoop());
- pos = m_pActivePins.GetHeadPosition();
- while (pos && !CheckRequest(&cmd)) {
- m_pActivePins.GetNext(pos)->QueueEndOfStream();
- }
- }
+ pos = m_pActivePins.GetHeadPosition();
+ while (pos && !CheckRequest(&cmd)) {
+ m_pActivePins.GetNext(pos)->QueueEndOfStream();
+ }
+ }
- ASSERT(0); // we should only exit via CMD_EXIT
+ ASSERT(0); // we should only exit via CMD_EXIT
- m_hThread = NULL;
- return 0;
+ m_hThread = NULL;
+ return 0;
}
HRESULT CBaseSplitterFilter::DeliverPacket(CAutoPtr<Packet> p)
{
- HRESULT hr = S_FALSE;
+ HRESULT hr = S_FALSE;
- CBaseSplitterOutputPin* pPin = GetOutputPin(p->TrackNumber);
- if (!pPin || !pPin->IsConnected() || !m_pActivePins.Find(pPin)) {
- return S_FALSE;
- }
+ CBaseSplitterOutputPin* pPin = GetOutputPin(p->TrackNumber);
+ if (!pPin || !pPin->IsConnected() || !m_pActivePins.Find(pPin)) {
+ return S_FALSE;
+ }
- if (p->rtStart != Packet::INVALID_TIME) {
- m_rtCurrent = p->rtStart;
+ if (p->rtStart != Packet::INVALID_TIME) {
+ m_rtCurrent = p->rtStart;
- p->rtStart -= m_rtStart;
- p->rtStop -= m_rtStart;
+ p->rtStart -= m_rtStart;
+ p->rtStop -= m_rtStart;
- ASSERT(p->rtStart <= p->rtStop);
- }
+ ASSERT(p->rtStart <= p->rtStop);
+ }
- {
- CAutoLock cAutoLock(&m_csmtnew);
+ {
+ CAutoLock cAutoLock(&m_csmtnew);
- CMediaType mt;
- if (m_mtnew.Lookup(p->TrackNumber, mt)) {
- p->pmt = CreateMediaType(&mt);
- m_mtnew.RemoveKey(p->TrackNumber);
- }
- }
+ CMediaType mt;
+ if (m_mtnew.Lookup(p->TrackNumber, mt)) {
+ p->pmt = CreateMediaType(&mt);
+ m_mtnew.RemoveKey(p->TrackNumber);
+ }
+ }
- if (!m_bDiscontinuitySent.Find(p->TrackNumber)) {
- p->bDiscontinuity = TRUE;
- }
+ if (!m_bDiscontinuitySent.Find(p->TrackNumber)) {
+ p->bDiscontinuity = TRUE;
+ }
- DWORD TrackNumber = p->TrackNumber;
- BOOL bDiscontinuity = p->bDiscontinuity;
+ DWORD TrackNumber = p->TrackNumber;
+ BOOL bDiscontinuity = p->bDiscontinuity;
#if defined(_DEBUG) && 0
- TRACE(_T("[%d]: d%d s%d p%d, b=%d, [%20I64d - %20I64d]\n"),
- p->TrackNumber,
- p->bDiscontinuity, p->bSyncPoint, p->rtStart != Packet::INVALID_TIME && p->rtStart < 0,
- p->GetCount(), p->rtStart, p->rtStop);
+ TRACE(_T("[%d]: d%d s%d p%d, b=%d, [%20I64d - %20I64d]\n"),
+ p->TrackNumber,
+ p->bDiscontinuity, p->bSyncPoint, p->rtStart != Packet::INVALID_TIME && p->rtStart < 0,
+ p->GetCount(), p->rtStart, p->rtStop);
#endif
- hr = pPin->QueuePacket(p);
+ hr = pPin->QueuePacket(p);
- if (S_OK != hr) {
- if (POSITION pos = m_pActivePins.Find(pPin)) {
- m_pActivePins.RemoveAt(pos);
- }
+ if (S_OK != hr) {
+ if (POSITION pos = m_pActivePins.Find(pPin)) {
+ m_pActivePins.RemoveAt(pos);
+ }
- if (!m_pActivePins.IsEmpty()) { // only die when all pins are down
- hr = S_OK;
- }
+ if (!m_pActivePins.IsEmpty()) { // only die when all pins are down
+ hr = S_OK;
+ }
- return hr;
- }
+ return hr;
+ }
- if (bDiscontinuity) {
- m_bDiscontinuitySent.AddTail(TrackNumber);
- }
+ if (bDiscontinuity) {
+ m_bDiscontinuitySent.AddTail(TrackNumber);
+ }
- return hr;
+ return hr;
}
bool CBaseSplitterFilter::IsAnyPinDrying()
{
- int totalcount = 0, totalsize = 0;
-
- POSITION pos = m_pActivePins.GetHeadPosition();
- while (pos) {
- CBaseSplitterOutputPin* pPin = m_pActivePins.GetNext(pos);
- int count = pPin->QueueCount();
- int size = pPin->QueueSize();
- if (!pPin->IsDiscontinuous() && (count < MINPACKETS || size < MINPACKETSIZE)) {
- // if (m_priority != THREAD_PRIORITY_ABOVE_NORMAL && (count < MINPACKETS/3 || size < MINPACKETSIZE/3))
- if (m_priority != THREAD_PRIORITY_BELOW_NORMAL && (count < MINPACKETS/3 || size < MINPACKETSIZE/3)) {
- // SetThreadPriority(m_hThread, m_priority = THREAD_PRIORITY_ABOVE_NORMAL);
- POSITION pos = m_pOutputs.GetHeadPosition();
- while (pos) {
- m_pOutputs.GetNext(pos)->SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL);
- }
- m_priority = THREAD_PRIORITY_BELOW_NORMAL;
- }
- return true;
- }
- totalcount += count;
- totalsize += size;
- }
-
- if (m_priority != THREAD_PRIORITY_NORMAL && (totalcount > m_QueueMaxPackets*2/3 || totalsize > MAXPACKETSIZE*2/3)) {
- // SetThreadPriority(m_hThread, m_priority = THREAD_PRIORITY_NORMAL);
- POSITION pos = m_pOutputs.GetHeadPosition();
- while (pos) {
- m_pOutputs.GetNext(pos)->SetThreadPriority(THREAD_PRIORITY_NORMAL);
- }
- m_priority = THREAD_PRIORITY_NORMAL;
- }
-
- if (totalcount < MAXPACKETS && totalsize < MAXPACKETSIZE) {
- return true;
- }
-
- return false;
+ int totalcount = 0, totalsize = 0;
+
+ POSITION pos = m_pActivePins.GetHeadPosition();
+ while (pos) {
+ CBaseSplitterOutputPin* pPin = m_pActivePins.GetNext(pos);
+ int count = pPin->QueueCount();
+ int size = pPin->QueueSize();
+ if (!pPin->IsDiscontinuous() && (count < MINPACKETS || size < MINPACKETSIZE)) {
+ // if (m_priority != THREAD_PRIORITY_ABOVE_NORMAL && (count < MINPACKETS/3 || size < MINPACKETSIZE/3))
+ if (m_priority != THREAD_PRIORITY_BELOW_NORMAL && (count < MINPACKETS / 3 || size < MINPACKETSIZE / 3)) {
+ // SetThreadPriority(m_hThread, m_priority = THREAD_PRIORITY_ABOVE_NORMAL);
+ POSITION pos = m_pOutputs.GetHeadPosition();
+ while (pos) {
+ m_pOutputs.GetNext(pos)->SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL);
+ }
+ m_priority = THREAD_PRIORITY_BELOW_NORMAL;
+ }
+ return true;
+ }
+ totalcount += count;
+ totalsize += size;
+ }
+
+ if (m_priority != THREAD_PRIORITY_NORMAL && (totalcount > m_QueueMaxPackets * 2 / 3 || totalsize > MAXPACKETSIZE * 2 / 3)) {
+ // SetThreadPriority(m_hThread, m_priority = THREAD_PRIORITY_NORMAL);
+ POSITION pos = m_pOutputs.GetHeadPosition();
+ while (pos) {
+ m_pOutputs.GetNext(pos)->SetThreadPriority(THREAD_PRIORITY_NORMAL);
+ }
+ m_priority = THREAD_PRIORITY_NORMAL;
+ }
+
+ if (totalcount < MAXPACKETS && totalsize < MAXPACKETSIZE) {
+ return true;
+ }
+
+ return false;
}
HRESULT CBaseSplitterFilter::BreakConnect(PIN_DIRECTION dir, CBasePin* pPin)
{
- CheckPointer(pPin, E_POINTER);
+ CheckPointer(pPin, E_POINTER);
- if (dir == PINDIR_INPUT) {
- DeleteOutputs();
- } else if (dir == PINDIR_OUTPUT) {
- } else {
- return E_UNEXPECTED;
- }
+ if (dir == PINDIR_INPUT) {
+ DeleteOutputs();
+ } else if (dir == PINDIR_OUTPUT) {
+ } else {
+ return E_UNEXPECTED;
+ }
- return S_OK;
+ return S_OK;
}
HRESULT CBaseSplitterFilter::CompleteConnect(PIN_DIRECTION dir, CBasePin* pPin)
{
- CheckPointer(pPin, E_POINTER);
+ CheckPointer(pPin, E_POINTER);
- if (dir == PINDIR_INPUT) {
- CBaseSplitterInputPin* pIn = static_cast<CBaseSplitterInputPin*>(pPin);
+ if (dir == PINDIR_INPUT) {
+ CBaseSplitterInputPin* pIn = static_cast<CBaseSplitterInputPin*>(pPin);
- HRESULT hr;
+ HRESULT hr;
- CComPtr<IAsyncReader> pAsyncReader;
- if (FAILED(hr = pIn->GetAsyncReader(&pAsyncReader))
- || FAILED(hr = DeleteOutputs())
- || FAILED(hr = CreateOutputs(pAsyncReader))) {
- return hr;
- }
+ CComPtr<IAsyncReader> pAsyncReader;
+ if (FAILED(hr = pIn->GetAsyncReader(&pAsyncReader))
+ || FAILED(hr = DeleteOutputs())
+ || FAILED(hr = CreateOutputs(pAsyncReader))) {
+ return hr;
+ }
- ChapSort();
+ ChapSort();
- m_pSyncReader = pAsyncReader;
- } else if (dir == PINDIR_OUTPUT) {
- m_pRetiredOutputs.RemoveAll();
- } else {
- return E_UNEXPECTED;
- }
+ m_pSyncReader = pAsyncReader;
+ } else if (dir == PINDIR_OUTPUT) {
+ m_pRetiredOutputs.RemoveAll();
+ } else {
+ return E_UNEXPECTED;
+ }
- return S_OK;
+ return S_OK;
}
int CBaseSplitterFilter::GetPinCount()
{
- return (m_pInput ? 1 : 0) + (int)m_pOutputs.GetCount();
+ return (m_pInput ? 1 : 0) + (int)m_pOutputs.GetCount();
}
CBasePin* CBaseSplitterFilter::GetPin(int n)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- if (n >= 0 && n < (int)m_pOutputs.GetCount()) {
- if (POSITION pos = m_pOutputs.FindIndex(n)) {
- return m_pOutputs.GetAt(pos);
- }
- }
+ if (n >= 0 && n < (int)m_pOutputs.GetCount()) {
+ if (POSITION pos = m_pOutputs.FindIndex(n)) {
+ return m_pOutputs.GetAt(pos);
+ }
+ }
- if (n == (int)m_pOutputs.GetCount() && m_pInput) {
- return m_pInput;
- }
+ if (n == (int)m_pOutputs.GetCount() && m_pInput) {
+ return m_pInput;
+ }
- return NULL;
+ return NULL;
}
STDMETHODIMP CBaseSplitterFilter::Stop()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- DeliverBeginFlush();
- CallWorker(CMD_EXIT);
- DeliverEndFlush();
+ DeliverBeginFlush();
+ CallWorker(CMD_EXIT);
+ DeliverEndFlush();
- HRESULT hr;
- if (FAILED(hr = __super::Stop())) {
- return hr;
- }
+ HRESULT hr;
+ if (FAILED(hr = __super::Stop())) {
+ return hr;
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CBaseSplitterFilter::Pause()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- FILTER_STATE fs = m_State;
+ FILTER_STATE fs = m_State;
- HRESULT hr;
- if (FAILED(hr = __super::Pause())) {
- return hr;
- }
+ HRESULT hr;
+ if (FAILED(hr = __super::Pause())) {
+ return hr;
+ }
- if (fs == State_Stopped) {
- Create();
- }
+ if (fs == State_Stopped) {
+ Create();
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CBaseSplitterFilter::Run(REFERENCE_TIME tStart)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- HRESULT hr;
- if (FAILED(hr = __super::Run(tStart))) {
- return hr;
- }
+ HRESULT hr;
+ if (FAILED(hr = __super::Run(tStart))) {
+ return hr;
+ }
- return S_OK;
+ return S_OK;
}
// IFileSourceFilter
STDMETHODIMP CBaseSplitterFilter::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
- CheckPointer(pszFileName, E_POINTER);
-
- m_fn = pszFileName;
- HRESULT hr = E_FAIL;
- CComPtr<IAsyncReader> pAsyncReader;
- CAtlList<CHdmvClipInfo::PlaylistItem> Items;
- CAtlList<CHdmvClipInfo::PlaylistChapter> Chapters;
-
- if (BuildPlaylist (pszFileName, Items))
- pAsyncReader = (IAsyncReader*)DNew CAsyncFileReader(Items, hr);
- else
- pAsyncReader = (IAsyncReader*)DNew CAsyncFileReader(CString(pszFileName), hr);
-
- if (FAILED(hr)
- || FAILED(hr = DeleteOutputs())
- || FAILED(hr = CreateOutputs(pAsyncReader)))
- {
- m_fn = "";
- return hr;
- }
-
- if (BuildChapters (pszFileName, Items, Chapters))
- {
- POSITION pos = Chapters.GetHeadPosition();
- int i = 1;
- while (pos)
- {
- CString str;
- CHdmvClipInfo::PlaylistChapter& chap = Chapters.GetNext(pos);
- if (chap.m_nMarkType == CHdmvClipInfo::EntryMark)
- {
- str.Format (_T("Chapter %d"), i);
- ChapAppend (chap.m_rtTimestamp, str);
- i++;
- }
- }
- }
-
- ChapSort();
-
- m_pSyncReader = pAsyncReader;
-
- return S_OK;
+ CheckPointer(pszFileName, E_POINTER);
+
+ m_fn = pszFileName;
+ HRESULT hr = E_FAIL;
+ CComPtr<IAsyncReader> pAsyncReader;
+ CAtlList<CHdmvClipInfo::PlaylistItem> Items;
+ CAtlList<CHdmvClipInfo::PlaylistChapter> Chapters;
+
+ if (BuildPlaylist(pszFileName, Items)) {
+ pAsyncReader = (IAsyncReader*)DNew CAsyncFileReader(Items, hr);
+ } else {
+ pAsyncReader = (IAsyncReader*)DNew CAsyncFileReader(CString(pszFileName), hr);
+ }
+
+ if (FAILED(hr)
+ || FAILED(hr = DeleteOutputs())
+ || FAILED(hr = CreateOutputs(pAsyncReader))) {
+ m_fn = "";
+ return hr;
+ }
+
+ if (BuildChapters(pszFileName, Items, Chapters)) {
+ POSITION pos = Chapters.GetHeadPosition();
+ int i = 1;
+ while (pos) {
+ CString str;
+ CHdmvClipInfo::PlaylistChapter& chap = Chapters.GetNext(pos);
+ if (chap.m_nMarkType == CHdmvClipInfo::EntryMark) {
+ str.Format(_T("Chapter %d"), i);
+ ChapAppend(chap.m_rtTimestamp, str);
+ i++;
+ }
+ }
+ }
+
+ ChapSort();
+
+ m_pSyncReader = pAsyncReader;
+
+ return S_OK;
}
STDMETHODIMP CBaseSplitterFilter::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
{
- CheckPointer(ppszFileName, E_POINTER);
- *ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR));
- if (!(*ppszFileName)) {
- return E_OUTOFMEMORY;
- }
- wcscpy_s(*ppszFileName, m_fn.GetLength() + 1, m_fn);
- return S_OK;
+ CheckPointer(ppszFileName, E_POINTER);
+ *ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength() + 1) * sizeof(WCHAR));
+ if (!(*ppszFileName)) {
+ return E_OUTOFMEMORY;
+ }
+ wcscpy_s(*ppszFileName, m_fn.GetLength() + 1, m_fn);
+ return S_OK;
}
LPCTSTR CBaseSplitterFilter::GetPartFilename(IAsyncReader* pAsyncReader)
{
- CComQIPtr<IFileHandle> pFH = pAsyncReader;
- return pFH ? pFH->GetFileName() : m_fn;
+ CComQIPtr<IFileHandle> pFH = pAsyncReader;
+ return pFH ? pFH->GetFileName() : m_fn;
}
// IMediaSeeking
STDMETHODIMP CBaseSplitterFilter::GetCapabilities(DWORD* pCapabilities)
{
- return pCapabilities ? *pCapabilities =
- AM_SEEKING_CanGetStopPos|
- AM_SEEKING_CanGetDuration|
- AM_SEEKING_CanSeekAbsolute|
- AM_SEEKING_CanSeekForwards|
- AM_SEEKING_CanSeekBackwards, S_OK : E_POINTER;
+ return pCapabilities ? *pCapabilities =
+ AM_SEEKING_CanGetStopPos |
+ AM_SEEKING_CanGetDuration |
+ AM_SEEKING_CanSeekAbsolute |
+ AM_SEEKING_CanSeekForwards |
+ AM_SEEKING_CanSeekBackwards, S_OK : E_POINTER;
}
STDMETHODIMP CBaseSplitterFilter::CheckCapabilities(DWORD* pCapabilities)
{
- CheckPointer(pCapabilities, E_POINTER);
- if (*pCapabilities == 0) {
- return S_OK;
- }
- DWORD caps;
- GetCapabilities(&caps);
- if ((caps&*pCapabilities) == 0) {
- return E_FAIL;
- }
- if (caps == *pCapabilities) {
- return S_OK;
- }
- return S_FALSE;
+ CheckPointer(pCapabilities, E_POINTER);
+ if (*pCapabilities == 0) {
+ return S_OK;
+ }
+ DWORD caps;
+ GetCapabilities(&caps);
+ if ((caps&*pCapabilities) == 0) {
+ return E_FAIL;
+ }
+ if (caps == *pCapabilities) {
+ return S_OK;
+ }
+ return S_FALSE;
}
STDMETHODIMP CBaseSplitterFilter::IsFormatSupported(const GUID* pFormat)
{
- return !pFormat ? E_POINTER : *pFormat == TIME_FORMAT_MEDIA_TIME ? S_OK : S_FALSE;
+ return !pFormat ? E_POINTER : *pFormat == TIME_FORMAT_MEDIA_TIME ? S_OK : S_FALSE;
}
STDMETHODIMP CBaseSplitterFilter::QueryPreferredFormat(GUID* pFormat)
{
- return GetTimeFormat(pFormat);
+ return GetTimeFormat(pFormat);
}
STDMETHODIMP CBaseSplitterFilter::GetTimeFormat(GUID* pFormat)
{
- return pFormat ? *pFormat = TIME_FORMAT_MEDIA_TIME, S_OK : E_POINTER;
+ return pFormat ? *pFormat = TIME_FORMAT_MEDIA_TIME, S_OK : E_POINTER;
}
STDMETHODIMP CBaseSplitterFilter::IsUsingTimeFormat(const GUID* pFormat)
{
- return IsFormatSupported(pFormat);
+ return IsFormatSupported(pFormat);
}
STDMETHODIMP CBaseSplitterFilter::SetTimeFormat(const GUID* pFormat)
{
- return S_OK == IsFormatSupported(pFormat) ? S_OK : E_INVALIDARG;
+ return S_OK == IsFormatSupported(pFormat) ? S_OK : E_INVALIDARG;
}
STDMETHODIMP CBaseSplitterFilter::GetDuration(LONGLONG* pDuration)
{
- CheckPointer(pDuration, E_POINTER);
- *pDuration = m_rtDuration;
- return S_OK;
+ CheckPointer(pDuration, E_POINTER);
+ *pDuration = m_rtDuration;
+ return S_OK;
}
STDMETHODIMP CBaseSplitterFilter::GetStopPosition(LONGLONG* pStop)
{
- return GetDuration(pStop);
+ return GetDuration(pStop);
}
STDMETHODIMP CBaseSplitterFilter::GetCurrentPosition(LONGLONG* pCurrent)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseSplitterFilter::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseSplitterFilter::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags)
{
- return SetPositionsInternal(this, pCurrent, dwCurrentFlags, pStop, dwStopFlags);
+ return SetPositionsInternal(this, pCurrent, dwCurrentFlags, pStop, dwStopFlags);
}
STDMETHODIMP CBaseSplitterFilter::GetPositions(LONGLONG* pCurrent, LONGLONG* pStop)
{
- if (pCurrent) {
- *pCurrent = m_rtCurrent;
- }
- if (pStop) {
- *pStop = m_rtStop;
- }
- return S_OK;
+ if (pCurrent) {
+ *pCurrent = m_rtCurrent;
+ }
+ if (pStop) {
+ *pStop = m_rtStop;
+ }
+ return S_OK;
}
STDMETHODIMP CBaseSplitterFilter::GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest)
{
- if (pEarliest) {
- *pEarliest = 0;
- }
- return GetDuration(pLatest);
+ if (pEarliest) {
+ *pEarliest = 0;
+ }
+ return GetDuration(pLatest);
}
STDMETHODIMP CBaseSplitterFilter::SetRate(double dRate)
{
- return dRate > 0 ? m_dRate = dRate, S_OK : E_INVALIDARG;
+ return dRate > 0 ? m_dRate = dRate, S_OK : E_INVALIDARG;
}
STDMETHODIMP CBaseSplitterFilter::GetRate(double* pdRate)
{
- return pdRate ? *pdRate = m_dRate, S_OK : E_POINTER;
+ return pdRate ? *pdRate = m_dRate, S_OK : E_POINTER;
}
STDMETHODIMP CBaseSplitterFilter::GetPreroll(LONGLONG* pllPreroll)
{
- return pllPreroll ? *pllPreroll = 0, S_OK : E_POINTER;
+ return pllPreroll ? *pllPreroll = 0, S_OK : E_POINTER;
}
HRESULT CBaseSplitterFilter::SetPositionsInternal(void* id, LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags)
{
- CAutoLock cAutoLock(this);
-
- if (!pCurrent && !pStop
- || (dwCurrentFlags&AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning
- && (dwStopFlags&AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning) {
- return S_OK;
- }
-
- REFERENCE_TIME
- rtCurrent = m_rtCurrent,
- rtStop = m_rtStop;
-
- if (pCurrent)
- switch (dwCurrentFlags&AM_SEEKING_PositioningBitsMask) {
- case AM_SEEKING_NoPositioning:
- break;
- case AM_SEEKING_AbsolutePositioning:
- rtCurrent = *pCurrent;
- break;
- case AM_SEEKING_RelativePositioning:
- rtCurrent = rtCurrent + *pCurrent;
- break;
- case AM_SEEKING_IncrementalPositioning:
- rtCurrent = rtCurrent + *pCurrent;
- break;
- }
-
- if (pStop)
- switch (dwStopFlags&AM_SEEKING_PositioningBitsMask) {
- case AM_SEEKING_NoPositioning:
- break;
- case AM_SEEKING_AbsolutePositioning:
- rtStop = *pStop;
- break;
- case AM_SEEKING_RelativePositioning:
- rtStop += *pStop;
- break;
- case AM_SEEKING_IncrementalPositioning:
- rtStop = rtCurrent + *pStop;
- break;
- }
-
- if (m_rtCurrent == rtCurrent && m_rtStop == rtStop) {
- return S_OK;
- }
-
- if (m_rtLastStart == rtCurrent && m_rtLastStop == rtStop && !m_LastSeekers.Find(id)) {
- m_LastSeekers.AddTail(id);
- return S_OK;
- }
-
- m_rtLastStart = rtCurrent;
- m_rtLastStop = rtStop;
- m_LastSeekers.RemoveAll();
- m_LastSeekers.AddTail(id);
-
- DbgLog((LOG_TRACE, 0, _T("Seek Started %I64d"), rtCurrent));
-
- m_rtNewStart = m_rtCurrent = rtCurrent;
- m_rtNewStop = rtStop;
-
- if (ThreadExists()) {
- DeliverBeginFlush();
- CallWorker(CMD_SEEK);
- DeliverEndFlush();
- }
-
- DbgLog((LOG_TRACE, 0, _T("Seek Ended")));
-
- return S_OK;
+ CAutoLock cAutoLock(this);
+
+ if (!pCurrent && !pStop
+ || (dwCurrentFlags & AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning
+ && (dwStopFlags & AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning) {
+ return S_OK;
+ }
+
+ REFERENCE_TIME
+ rtCurrent = m_rtCurrent,
+ rtStop = m_rtStop;
+
+ if (pCurrent)
+ switch (dwCurrentFlags & AM_SEEKING_PositioningBitsMask) {
+ case AM_SEEKING_NoPositioning:
+ break;
+ case AM_SEEKING_AbsolutePositioning:
+ rtCurrent = *pCurrent;
+ break;
+ case AM_SEEKING_RelativePositioning:
+ rtCurrent = rtCurrent + *pCurrent;
+ break;
+ case AM_SEEKING_IncrementalPositioning:
+ rtCurrent = rtCurrent + *pCurrent;
+ break;
+ }
+
+ if (pStop)
+ switch (dwStopFlags & AM_SEEKING_PositioningBitsMask) {
+ case AM_SEEKING_NoPositioning:
+ break;
+ case AM_SEEKING_AbsolutePositioning:
+ rtStop = *pStop;
+ break;
+ case AM_SEEKING_RelativePositioning:
+ rtStop += *pStop;
+ break;
+ case AM_SEEKING_IncrementalPositioning:
+ rtStop = rtCurrent + *pStop;
+ break;
+ }
+
+ if (m_rtCurrent == rtCurrent && m_rtStop == rtStop) {
+ return S_OK;
+ }
+
+ if (m_rtLastStart == rtCurrent && m_rtLastStop == rtStop && !m_LastSeekers.Find(id)) {
+ m_LastSeekers.AddTail(id);
+ return S_OK;
+ }
+
+ m_rtLastStart = rtCurrent;
+ m_rtLastStop = rtStop;
+ m_LastSeekers.RemoveAll();
+ m_LastSeekers.AddTail(id);
+
+ DbgLog((LOG_TRACE, 0, _T("Seek Started %I64d"), rtCurrent));
+
+ m_rtNewStart = m_rtCurrent = rtCurrent;
+ m_rtNewStop = rtStop;
+
+ if (ThreadExists()) {
+ DeliverBeginFlush();
+ CallWorker(CMD_SEEK);
+ DeliverEndFlush();
+ }
+
+ DbgLog((LOG_TRACE, 0, _T("Seek Ended")));
+
+ return S_OK;
}
// IAMOpenProgress
STDMETHODIMP CBaseSplitterFilter::QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent)
{
- CheckPointer(pllTotal, E_POINTER);
- CheckPointer(pllCurrent, E_POINTER);
+ CheckPointer(pllTotal, E_POINTER);
+ CheckPointer(pllCurrent, E_POINTER);
- *pllTotal = 100;
- *pllCurrent = m_nOpenProgress;
+ *pllTotal = 100;
+ *pllCurrent = m_nOpenProgress;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CBaseSplitterFilter::AbortOperation()
{
- m_fAbort = true;
- return S_OK;
+ m_fAbort = true;
+ return S_OK;
}
// IAMMediaContent
STDMETHODIMP CBaseSplitterFilter::get_AuthorName(BSTR* pbstrAuthorName)
{
- return GetProperty(L"AUTH", pbstrAuthorName);
+ return GetProperty(L"AUTH", pbstrAuthorName);
}
STDMETHODIMP CBaseSplitterFilter::get_Title(BSTR* pbstrTitle)
{
- return GetProperty(L"TITL", pbstrTitle);
+ return GetProperty(L"TITL", pbstrTitle);
}
STDMETHODIMP CBaseSplitterFilter::get_Rating(BSTR* pbstrRating)
{
- return GetProperty(L"RTNG", pbstrRating);
+ return GetProperty(L"RTNG", pbstrRating);
}
STDMETHODIMP CBaseSplitterFilter::get_Description(BSTR* pbstrDescription)
{
- return GetProperty(L"DESC", pbstrDescription);
+ return GetProperty(L"DESC", pbstrDescription);
}
STDMETHODIMP CBaseSplitterFilter::get_Copyright(BSTR* pbstrCopyright)
{
- return GetProperty(L"CPYR", pbstrCopyright);
+ return GetProperty(L"CPYR", pbstrCopyright);
}
// IAMExtendedSeeking
STDMETHODIMP CBaseSplitterFilter::get_ExSeekCapabilities(long* pExCapabilities)
{
- CheckPointer(pExCapabilities, E_POINTER);
- *pExCapabilities = AM_EXSEEK_CANSEEK;
- if (ChapGetCount()) {
- *pExCapabilities |= AM_EXSEEK_MARKERSEEK;
- }
- return S_OK;
+ CheckPointer(pExCapabilities, E_POINTER);
+ *pExCapabilities = AM_EXSEEK_CANSEEK;
+ if (ChapGetCount()) {
+ *pExCapabilities |= AM_EXSEEK_MARKERSEEK;
+ }
+ return S_OK;
}
STDMETHODIMP CBaseSplitterFilter::get_MarkerCount(long* pMarkerCount)
{
- CheckPointer(pMarkerCount, E_POINTER);
- *pMarkerCount = (long)ChapGetCount();
- return S_OK;
+ CheckPointer(pMarkerCount, E_POINTER);
+ *pMarkerCount = (long)ChapGetCount();
+ return S_OK;
}
STDMETHODIMP CBaseSplitterFilter::get_CurrentMarker(long* pCurrentMarker)
{
- CheckPointer(pCurrentMarker, E_POINTER);
- REFERENCE_TIME rt = m_rtCurrent;
- long i = ChapLookup(&rt);
- if (i < 0) {
- return E_FAIL;
- }
- *pCurrentMarker = i+1;
- return S_OK;
+ CheckPointer(pCurrentMarker, E_POINTER);
+ REFERENCE_TIME rt = m_rtCurrent;
+ long i = ChapLookup(&rt);
+ if (i < 0) {
+ return E_FAIL;
+ }
+ *pCurrentMarker = i + 1;
+ return S_OK;
}
STDMETHODIMP CBaseSplitterFilter::GetMarkerTime(long MarkerNum, double* pMarkerTime)
{
- CheckPointer(pMarkerTime, E_POINTER);
- REFERENCE_TIME rt;
- if (FAILED(ChapGet((int)MarkerNum-1, &rt))) {
- return E_FAIL;
- }
- *pMarkerTime = (double)rt / 10000000;
- return S_OK;
+ CheckPointer(pMarkerTime, E_POINTER);
+ REFERENCE_TIME rt;
+ if (FAILED(ChapGet((int)MarkerNum - 1, &rt))) {
+ return E_FAIL;
+ }
+ *pMarkerTime = (double)rt / 10000000;
+ return S_OK;
}
STDMETHODIMP CBaseSplitterFilter::GetMarkerName(long MarkerNum, BSTR* pbstrMarkerName)
{
- return ChapGet((int)MarkerNum-1, NULL, pbstrMarkerName);
+ return ChapGet((int)MarkerNum - 1, NULL, pbstrMarkerName);
}
// IKeyFrameInfo
STDMETHODIMP CBaseSplitterFilter::GetKeyFrameCount(UINT& nKFs)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseSplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IBufferInfo
STDMETHODIMP_(int) CBaseSplitterFilter::GetCount()
{
- CAutoLock cAutoLock(m_pLock);
+ CAutoLock cAutoLock(m_pLock);
- return (int)m_pOutputs.GetCount();
+ return (int)m_pOutputs.GetCount();
}
STDMETHODIMP CBaseSplitterFilter::GetStatus(int i, int& samples, int& size)
{
- CAutoLock cAutoLock(m_pLock);
+ CAutoLock cAutoLock(m_pLock);
- if (POSITION pos = m_pOutputs.FindIndex(i)) {
- CBaseSplitterOutputPin* pPin = m_pOutputs.GetAt(pos);
- samples = pPin->QueueCount();
- size = pPin->QueueSize();
- return pPin->IsConnected() ? S_OK : S_FALSE;
- }
+ if (POSITION pos = m_pOutputs.FindIndex(i)) {
+ CBaseSplitterOutputPin* pPin = m_pOutputs.GetAt(pos);
+ samples = pPin->QueueCount();
+ size = pPin->QueueSize();
+ return pPin->IsConnected() ? S_OK : S_FALSE;
+ }
- return E_INVALIDARG;
+ return E_INVALIDARG;
}
STDMETHODIMP_(DWORD) CBaseSplitterFilter::GetPriority()
{
- return m_priority;
+ return m_priority;
}
diff --git a/src/filters/parser/BaseSplitter/BaseSplitter.h b/src/filters/parser/BaseSplitter/BaseSplitter.h
index 0cd998dd4..b4dfce18f 100644
--- a/src/filters/parser/BaseSplitter/BaseSplitter.h
+++ b/src/filters/parser/BaseSplitter/BaseSplitter.h
@@ -34,432 +34,432 @@
#include "../../../DSUtil/DSMPropertyBag.h"
#include "../../../DSUtil/FontInstaller.h"
-#define MINPACKETS 100 // Beliyaal: Changed the min number of packets to allow Bluray playback over network
-#define MINPACKETSIZE 256*1024 // Beliyaal: Changed the min packet size to allow Bluray playback over network
+#define MINPACKETS 100 // Beliyaal: Changed the min number of packets to allow Bluray playback over network
+#define MINPACKETSIZE 256*1024 // Beliyaal: Changed the min packet size to allow Bluray playback over network
#define MAXPACKETS 1000
#define MAXPACKETSIZE 1024*1024*128
enum {
- /* various PCM "codecs" */
- FF_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
- FF_CODEC_ID_PCM_S16LE= 0x10000,
- FF_CODEC_ID_PCM_S16BE,
- FF_CODEC_ID_PCM_U16LE,
- FF_CODEC_ID_PCM_U16BE,
- FF_CODEC_ID_PCM_S8,
- FF_CODEC_ID_PCM_U8,
- FF_CODEC_ID_PCM_MULAW,
- FF_CODEC_ID_PCM_ALAW,
- FF_CODEC_ID_PCM_S32LE,
- FF_CODEC_ID_PCM_S32BE,
- FF_CODEC_ID_PCM_U32LE,
- FF_CODEC_ID_PCM_U32BE,
- FF_CODEC_ID_PCM_S24LE,
- FF_CODEC_ID_PCM_S24BE,
- FF_CODEC_ID_PCM_U24LE,
- FF_CODEC_ID_PCM_U24BE,
- FF_CODEC_ID_PCM_S24DAUD,
- FF_CODEC_ID_PCM_ZORK,
- FF_CODEC_ID_PCM_S16LE_PLANAR,
- FF_CODEC_ID_PCM_DVD,
- FF_CODEC_ID_PCM_F32BE,
- FF_CODEC_ID_PCM_F32LE,
- FF_CODEC_ID_PCM_F64BE,
- FF_CODEC_ID_PCM_F64LE,
- FF_CODEC_ID_PCM_BLURAY,
- FF_CODEC_ID_PCM_LXF,
- FF_CODEC_ID_S302M,
-
- /* various ADPCM codecs */
- FF_CODEC_ID_ADPCM_IMA_QT= 0x11000,
- FF_CODEC_ID_ADPCM_IMA_WAV,
- FF_CODEC_ID_ADPCM_IMA_DK3,
- FF_CODEC_ID_ADPCM_IMA_DK4,
- FF_CODEC_ID_ADPCM_IMA_WS,
- FF_CODEC_ID_ADPCM_IMA_SMJPEG,
- FF_CODEC_ID_ADPCM_MS,
- FF_CODEC_ID_ADPCM_4XM,
- FF_CODEC_ID_ADPCM_XA,
- FF_CODEC_ID_ADPCM_ADX,
- FF_CODEC_ID_ADPCM_EA,
- FF_CODEC_ID_ADPCM_G726,
- FF_CODEC_ID_ADPCM_CT,
- FF_CODEC_ID_ADPCM_SWF,
- FF_CODEC_ID_ADPCM_YAMAHA,
- FF_CODEC_ID_ADPCM_SBPRO_4,
- FF_CODEC_ID_ADPCM_SBPRO_3,
- FF_CODEC_ID_ADPCM_SBPRO_2,
- FF_CODEC_ID_ADPCM_THP,
- FF_CODEC_ID_ADPCM_IMA_AMV,
- FF_CODEC_ID_ADPCM_EA_R1,
- FF_CODEC_ID_ADPCM_EA_R3,
- FF_CODEC_ID_ADPCM_EA_R2,
- FF_CODEC_ID_ADPCM_IMA_EA_SEAD,
- FF_CODEC_ID_ADPCM_IMA_EA_EACS,
- FF_CODEC_ID_ADPCM_EA_XAS,
- FF_CODEC_ID_ADPCM_EA_MAXIS_XA,
- FF_CODEC_ID_ADPCM_IMA_ISS,
- FF_CODEC_ID_ADPCM_G722,
+ /* various PCM "codecs" */
+ FF_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
+ FF_CODEC_ID_PCM_S16LE = 0x10000,
+ FF_CODEC_ID_PCM_S16BE,
+ FF_CODEC_ID_PCM_U16LE,
+ FF_CODEC_ID_PCM_U16BE,
+ FF_CODEC_ID_PCM_S8,
+ FF_CODEC_ID_PCM_U8,
+ FF_CODEC_ID_PCM_MULAW,
+ FF_CODEC_ID_PCM_ALAW,
+ FF_CODEC_ID_PCM_S32LE,
+ FF_CODEC_ID_PCM_S32BE,
+ FF_CODEC_ID_PCM_U32LE,
+ FF_CODEC_ID_PCM_U32BE,
+ FF_CODEC_ID_PCM_S24LE,
+ FF_CODEC_ID_PCM_S24BE,
+ FF_CODEC_ID_PCM_U24LE,
+ FF_CODEC_ID_PCM_U24BE,
+ FF_CODEC_ID_PCM_S24DAUD,
+ FF_CODEC_ID_PCM_ZORK,
+ FF_CODEC_ID_PCM_S16LE_PLANAR,
+ FF_CODEC_ID_PCM_DVD,
+ FF_CODEC_ID_PCM_F32BE,
+ FF_CODEC_ID_PCM_F32LE,
+ FF_CODEC_ID_PCM_F64BE,
+ FF_CODEC_ID_PCM_F64LE,
+ FF_CODEC_ID_PCM_BLURAY,
+ FF_CODEC_ID_PCM_LXF,
+ FF_CODEC_ID_S302M,
+
+ /* various ADPCM codecs */
+ FF_CODEC_ID_ADPCM_IMA_QT = 0x11000,
+ FF_CODEC_ID_ADPCM_IMA_WAV,
+ FF_CODEC_ID_ADPCM_IMA_DK3,
+ FF_CODEC_ID_ADPCM_IMA_DK4,
+ FF_CODEC_ID_ADPCM_IMA_WS,
+ FF_CODEC_ID_ADPCM_IMA_SMJPEG,
+ FF_CODEC_ID_ADPCM_MS,
+ FF_CODEC_ID_ADPCM_4XM,
+ FF_CODEC_ID_ADPCM_XA,
+ FF_CODEC_ID_ADPCM_ADX,
+ FF_CODEC_ID_ADPCM_EA,
+ FF_CODEC_ID_ADPCM_G726,
+ FF_CODEC_ID_ADPCM_CT,
+ FF_CODEC_ID_ADPCM_SWF,
+ FF_CODEC_ID_ADPCM_YAMAHA,
+ FF_CODEC_ID_ADPCM_SBPRO_4,
+ FF_CODEC_ID_ADPCM_SBPRO_3,
+ FF_CODEC_ID_ADPCM_SBPRO_2,
+ FF_CODEC_ID_ADPCM_THP,
+ FF_CODEC_ID_ADPCM_IMA_AMV,
+ FF_CODEC_ID_ADPCM_EA_R1,
+ FF_CODEC_ID_ADPCM_EA_R3,
+ FF_CODEC_ID_ADPCM_EA_R2,
+ FF_CODEC_ID_ADPCM_IMA_EA_SEAD,
+ FF_CODEC_ID_ADPCM_IMA_EA_EACS,
+ FF_CODEC_ID_ADPCM_EA_XAS,
+ FF_CODEC_ID_ADPCM_EA_MAXIS_XA,
+ FF_CODEC_ID_ADPCM_IMA_ISS,
+ FF_CODEC_ID_ADPCM_G722,
};
class Packet : public CAtlArray<BYTE>
{
public:
- DWORD TrackNumber;
- BOOL bDiscontinuity, bSyncPoint, bAppendable;
- static const REFERENCE_TIME INVALID_TIME = _I64_MIN;
- REFERENCE_TIME rtStart, rtStop;
- AM_MEDIA_TYPE* pmt;
- Packet() {
- pmt = NULL;
- bDiscontinuity = bAppendable = FALSE;
- }
- virtual ~Packet() {
- if (pmt) {
- DeleteMediaType(pmt);
- }
- }
- virtual int GetDataSize() {return (int)GetCount();}
- void SetData(const void* ptr, DWORD len) {
- SetCount(len);
- memcpy(GetData(), ptr, len);
- }
+ DWORD TrackNumber;
+ BOOL bDiscontinuity, bSyncPoint, bAppendable;
+ static const REFERENCE_TIME INVALID_TIME = _I64_MIN;
+ REFERENCE_TIME rtStart, rtStop;
+ AM_MEDIA_TYPE* pmt;
+ Packet() {
+ pmt = NULL;
+ bDiscontinuity = bAppendable = FALSE;
+ }
+ virtual ~Packet() {
+ if (pmt) {
+ DeleteMediaType(pmt);
+ }
+ }
+ virtual int GetDataSize() {return (int)GetCount();}
+ void SetData(const void* ptr, DWORD len) {
+ SetCount(len);
+ memcpy(GetData(), ptr, len);
+ }
};
class CPacketQueue
- : public CCritSec
- , protected CAutoPtrList<Packet>
+ : public CCritSec
+ , protected CAutoPtrList<Packet>
{
- int m_size;
+ int m_size;
public:
- CPacketQueue();
- void Add(CAutoPtr<Packet> p);
- CAutoPtr<Packet> Remove();
- void RemoveAll();
- int GetCount(), GetSize();
+ CPacketQueue();
+ void Add(CAutoPtr<Packet> p);
+ CAutoPtr<Packet> Remove();
+ void RemoveAll();
+ int GetCount(), GetSize();
};
class CBaseSplitterFilter;
class CBaseSplitterInputPin
- : public CBasePin
+ : public CBasePin
{
protected:
- CComQIPtr<IAsyncReader> m_pAsyncReader;
+ CComQIPtr<IAsyncReader> m_pAsyncReader;
public:
- CBaseSplitterInputPin(TCHAR* pName, CBaseSplitterFilter* pFilter, CCritSec* pLock, HRESULT* phr);
- virtual ~CBaseSplitterInputPin();
+ CBaseSplitterInputPin(TCHAR* pName, CBaseSplitterFilter* pFilter, CCritSec* pLock, HRESULT* phr);
+ virtual ~CBaseSplitterInputPin();
- HRESULT GetAsyncReader(IAsyncReader** ppAsyncReader);
+ HRESULT GetAsyncReader(IAsyncReader** ppAsyncReader);
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT CheckMediaType(const CMediaType* pmt);
- HRESULT CheckConnect(IPin* pPin);
- HRESULT BreakConnect();
- HRESULT CompleteConnect(IPin* pPin);
+ HRESULT CheckConnect(IPin* pPin);
+ HRESULT BreakConnect();
+ HRESULT CompleteConnect(IPin* pPin);
- STDMETHODIMP BeginFlush();
- STDMETHODIMP EndFlush();
+ STDMETHODIMP BeginFlush();
+ STDMETHODIMP EndFlush();
};
class CBaseSplitterOutputPin
- : public CBaseOutputPin
- , public IDSMPropertyBagImpl
- , protected CAMThread
- , public IMediaSeeking
- , public IBitRateInfo
+ : public CBaseOutputPin
+ , public IDSMPropertyBagImpl
+ , protected CAMThread
+ , public IMediaSeeking
+ , public IBitRateInfo
{
protected:
- CAtlArray<CMediaType> m_mts;
- int m_nBuffers;
+ CAtlArray<CMediaType> m_mts;
+ int m_nBuffers;
private:
- CPacketQueue m_queue;
+ CPacketQueue m_queue;
- HRESULT m_hrDeliver;
+ HRESULT m_hrDeliver;
- bool m_fFlushing, m_fFlushed;
- CAMEvent m_eEndFlush;
+ bool m_fFlushing, m_fFlushed;
+ CAMEvent m_eEndFlush;
- enum {CMD_EXIT};
- DWORD ThreadProc();
+ enum {CMD_EXIT};
+ DWORD ThreadProc();
- void MakeISCRHappy();
+ void MakeISCRHappy();
- // please only use DeliverPacket from the derived class
- HRESULT GetDeliveryBuffer(IMediaSample** ppSample, REFERENCE_TIME* pStartTime, REFERENCE_TIME* pEndTime, DWORD dwFlags);
- HRESULT Deliver(IMediaSample* pSample);
+ // please only use DeliverPacket from the derived class
+ HRESULT GetDeliveryBuffer(IMediaSample** ppSample, REFERENCE_TIME* pStartTime, REFERENCE_TIME* pEndTime, DWORD dwFlags);
+ HRESULT Deliver(IMediaSample* pSample);
- // bitrate stats
+ // bitrate stats
- struct {
- UINT64 nTotalBytesDelivered;
- REFERENCE_TIME rtTotalTimeDelivered;
- UINT64 nBytesSinceLastDeliverTime;
- REFERENCE_TIME rtLastDeliverTime;
- DWORD nCurrentBitRate;
- DWORD nAverageBitRate;
- } m_brs;
+ struct {
+ UINT64 nTotalBytesDelivered;
+ REFERENCE_TIME rtTotalTimeDelivered;
+ UINT64 nBytesSinceLastDeliverTime;
+ REFERENCE_TIME rtLastDeliverTime;
+ DWORD nCurrentBitRate;
+ DWORD nAverageBitRate;
+ } m_brs;
- int m_QueueMaxPackets;
+ int m_QueueMaxPackets;
protected:
- REFERENCE_TIME m_rtStart;
-
- // override this if you need some second level stream specific demuxing (optional)
- // the default implementation will send the sample as is
- virtual HRESULT DeliverPacket(CAutoPtr<Packet> p);
-
- // IMediaSeeking
-
- STDMETHODIMP GetCapabilities(DWORD* pCapabilities);
- STDMETHODIMP CheckCapabilities(DWORD* pCapabilities);
- STDMETHODIMP IsFormatSupported(const GUID* pFormat);
- STDMETHODIMP QueryPreferredFormat(GUID* pFormat);
- STDMETHODIMP GetTimeFormat(GUID* pFormat);
- STDMETHODIMP IsUsingTimeFormat(const GUID* pFormat);
- STDMETHODIMP SetTimeFormat(const GUID* pFormat);
- STDMETHODIMP GetDuration(LONGLONG* pDuration);
- STDMETHODIMP GetStopPosition(LONGLONG* pStop);
- STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
- STDMETHODIMP ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat);
- STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
- STDMETHODIMP GetPositions(LONGLONG* pCurrent, LONGLONG* pStop);
- STDMETHODIMP GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest);
- STDMETHODIMP SetRate(double dRate);
- STDMETHODIMP GetRate(double* pdRate);
- STDMETHODIMP GetPreroll(LONGLONG* pllPreroll);
+ REFERENCE_TIME m_rtStart;
+
+ // override this if you need some second level stream specific demuxing (optional)
+ // the default implementation will send the sample as is
+ virtual HRESULT DeliverPacket(CAutoPtr<Packet> p);
+
+ // IMediaSeeking
+
+ STDMETHODIMP GetCapabilities(DWORD* pCapabilities);
+ STDMETHODIMP CheckCapabilities(DWORD* pCapabilities);
+ STDMETHODIMP IsFormatSupported(const GUID* pFormat);
+ STDMETHODIMP QueryPreferredFormat(GUID* pFormat);
+ STDMETHODIMP GetTimeFormat(GUID* pFormat);
+ STDMETHODIMP IsUsingTimeFormat(const GUID* pFormat);
+ STDMETHODIMP SetTimeFormat(const GUID* pFormat);
+ STDMETHODIMP GetDuration(LONGLONG* pDuration);
+ STDMETHODIMP GetStopPosition(LONGLONG* pStop);
+ STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
+ STDMETHODIMP ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat);
+ STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
+ STDMETHODIMP GetPositions(LONGLONG* pCurrent, LONGLONG* pStop);
+ STDMETHODIMP GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest);
+ STDMETHODIMP SetRate(double dRate);
+ STDMETHODIMP GetRate(double* pdRate);
+ STDMETHODIMP GetPreroll(LONGLONG* pllPreroll);
public:
- CBaseSplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr, int nBuffers = 0, int QueueMaxPackets = MAXPACKETS);
- CBaseSplitterOutputPin(LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr, int nBuffers = 0, int QueueMaxPackets = MAXPACKETS);
- virtual ~CBaseSplitterOutputPin();
+ CBaseSplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr, int nBuffers = 0, int QueueMaxPackets = MAXPACKETS);
+ CBaseSplitterOutputPin(LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr, int nBuffers = 0, int QueueMaxPackets = MAXPACKETS);
+ virtual ~CBaseSplitterOutputPin();
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- HRESULT SetName(LPCWSTR pName);
+ HRESULT SetName(LPCWSTR pName);
- HRESULT DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT CheckMediaType(const CMediaType* pmt);
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
- CMediaType& CurrentMediaType() {return m_mt;}
+ HRESULT DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT GetMediaType(int iPosition, CMediaType* pmt);
+ CMediaType& CurrentMediaType() {return m_mt;}
- STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
+ STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
- // Queueing
+ // Queueing
- HANDLE GetThreadHandle() {
- ASSERT(m_hThread != NULL);
- return m_hThread;
- }
- void SetThreadPriority(int nPriority) {
- if (m_hThread) {
- ::SetThreadPriority(m_hThread, nPriority);
- }
- }
+ HANDLE GetThreadHandle() {
+ ASSERT(m_hThread != NULL);
+ return m_hThread;
+ }
+ void SetThreadPriority(int nPriority) {
+ if (m_hThread) {
+ ::SetThreadPriority(m_hThread, nPriority);
+ }
+ }
- HRESULT Active();
- HRESULT Inactive();
+ HRESULT Active();
+ HRESULT Inactive();
- HRESULT DeliverBeginFlush();
- HRESULT DeliverEndFlush();
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ HRESULT DeliverBeginFlush();
+ HRESULT DeliverEndFlush();
+ HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
- int QueueCount();
- int QueueSize();
- HRESULT QueueEndOfStream();
- HRESULT QueuePacket(CAutoPtr<Packet> p);
+ int QueueCount();
+ int QueueSize();
+ HRESULT QueueEndOfStream();
+ HRESULT QueuePacket(CAutoPtr<Packet> p);
- // returns true for everything which (the lack of) would not block other streams (subtitle streams, basically)
- virtual bool IsDiscontinuous();
+ // returns true for everything which (the lack of) would not block other streams (subtitle streams, basically)
+ virtual bool IsDiscontinuous();
- // returns IStreamsSwitcherInputPin::IsActive(), when it can find one downstream
- bool IsActive();
+ // returns IStreamsSwitcherInputPin::IsActive(), when it can find one downstream
+ bool IsActive();
- // IBitRateInfo
+ // IBitRateInfo
- STDMETHODIMP_(DWORD) GetCurrentBitRate() {return m_brs.nCurrentBitRate;}
- STDMETHODIMP_(DWORD) GetAverageBitRate() {return m_brs.nAverageBitRate;}
+ STDMETHODIMP_(DWORD) GetCurrentBitRate() {return m_brs.nCurrentBitRate;}
+ STDMETHODIMP_(DWORD) GetAverageBitRate() {return m_brs.nAverageBitRate;}
};
class CBaseSplitterFilter
- : public CBaseFilter
- , public CCritSec
- , public IDSMPropertyBagImpl
- , public IDSMResourceBagImpl
- , public IDSMChapterBagImpl
- , protected CAMThread
- , public IFileSourceFilter
- , public IMediaSeeking
- , public IAMOpenProgress
- , public IAMMediaContent
- , public IAMExtendedSeeking
- , public IKeyFrameInfo
- , public IBufferInfo
+ : public CBaseFilter
+ , public CCritSec
+ , public IDSMPropertyBagImpl
+ , public IDSMResourceBagImpl
+ , public IDSMChapterBagImpl
+ , protected CAMThread
+ , public IFileSourceFilter
+ , public IMediaSeeking
+ , public IAMOpenProgress
+ , public IAMMediaContent
+ , public IAMExtendedSeeking
+ , public IKeyFrameInfo
+ , public IBufferInfo
{
- CCritSec m_csPinMap;
- CAtlMap<DWORD, CBaseSplitterOutputPin*> m_pPinMap;
+ CCritSec m_csPinMap;
+ CAtlMap<DWORD, CBaseSplitterOutputPin*> m_pPinMap;
- CCritSec m_csmtnew;
- CAtlMap<DWORD, CMediaType> m_mtnew;
+ CCritSec m_csmtnew;
+ CAtlMap<DWORD, CMediaType> m_mtnew;
- CAutoPtrList<CBaseSplitterOutputPin> m_pRetiredOutputs;
+ CAutoPtrList<CBaseSplitterOutputPin> m_pRetiredOutputs;
- CComQIPtr<ISyncReader> m_pSyncReader;
+ CComQIPtr<ISyncReader> m_pSyncReader;
protected:
- CStringW m_fn;
+ CStringW m_fn;
- CAutoPtr<CBaseSplitterInputPin> m_pInput;
- CAutoPtrList<CBaseSplitterOutputPin> m_pOutputs;
+ CAutoPtr<CBaseSplitterInputPin> m_pInput;
+ CAutoPtrList<CBaseSplitterOutputPin> m_pOutputs;
- CBaseSplitterOutputPin* GetOutputPin(DWORD TrackNum);
- DWORD GetOutputTrackNum(CBaseSplitterOutputPin* pPin);
- HRESULT AddOutputPin(DWORD TrackNum, CAutoPtr<CBaseSplitterOutputPin> pPin);
- HRESULT RenameOutputPin(DWORD TrackNumSrc, DWORD TrackNumDst, const AM_MEDIA_TYPE* pmt);
- virtual HRESULT DeleteOutputs();
- virtual HRESULT CreateOutputs(IAsyncReader* pAsyncReader) = 0; // override this ...
- virtual LPCTSTR GetPartFilename(IAsyncReader* pAsyncReader);
+ CBaseSplitterOutputPin* GetOutputPin(DWORD TrackNum);
+ DWORD GetOutputTrackNum(CBaseSplitterOutputPin* pPin);
+ HRESULT AddOutputPin(DWORD TrackNum, CAutoPtr<CBaseSplitterOutputPin> pPin);
+ HRESULT RenameOutputPin(DWORD TrackNumSrc, DWORD TrackNumDst, const AM_MEDIA_TYPE* pmt);
+ virtual HRESULT DeleteOutputs();
+ virtual HRESULT CreateOutputs(IAsyncReader* pAsyncReader) = 0; // override this ...
+ virtual LPCTSTR GetPartFilename(IAsyncReader* pAsyncReader);
- LONGLONG m_nOpenProgress;
- bool m_fAbort;
+ LONGLONG m_nOpenProgress;
+ bool m_fAbort;
- REFERENCE_TIME m_rtDuration; // derived filter should set this at the end of CreateOutputs
- REFERENCE_TIME m_rtStart, m_rtStop, m_rtCurrent, m_rtNewStart, m_rtNewStop;
- double m_dRate;
+ REFERENCE_TIME m_rtDuration; // derived filter should set this at the end of CreateOutputs
+ REFERENCE_TIME m_rtStart, m_rtStop, m_rtCurrent, m_rtNewStart, m_rtNewStop;
+ double m_dRate;
- CAtlList<UINT64> m_bDiscontinuitySent;
- CAtlList<CBaseSplitterOutputPin*> m_pActivePins;
+ CAtlList<UINT64> m_bDiscontinuitySent;
+ CAtlList<CBaseSplitterOutputPin*> m_pActivePins;
- CAMEvent m_eEndFlush;
- bool m_fFlushing;
+ CAMEvent m_eEndFlush;
+ bool m_fFlushing;
- void DeliverBeginFlush();
- void DeliverEndFlush();
- HRESULT DeliverPacket(CAutoPtr<Packet> p);
+ void DeliverBeginFlush();
+ void DeliverEndFlush();
+ HRESULT DeliverPacket(CAutoPtr<Packet> p);
- int m_priority;
+ int m_priority;
- CFontInstaller m_fontinst;
+ CFontInstaller m_fontinst;
- int m_QueueMaxPackets;
+ int m_QueueMaxPackets;
protected:
- enum {CMD_EXIT, CMD_SEEK};
- DWORD ThreadProc();
+ enum {CMD_EXIT, CMD_SEEK};
+ DWORD ThreadProc();
- // ... and also override all these too
- virtual bool DemuxInit() = 0;
- virtual void DemuxSeek(REFERENCE_TIME rt) = 0;
- virtual bool DemuxLoop() = 0;
- virtual bool BuildPlaylist(LPCTSTR pszFileName, CAtlList<CHdmvClipInfo::PlaylistItem>& Items) { return false; };
- virtual bool BuildChapters(LPCTSTR pszFileName, CAtlList<CHdmvClipInfo::PlaylistItem>& PlaylistItems, CAtlList<CHdmvClipInfo::PlaylistChapter>& Items) { return false; };
+ // ... and also override all these too
+ virtual bool DemuxInit() = 0;
+ virtual void DemuxSeek(REFERENCE_TIME rt) = 0;
+ virtual bool DemuxLoop() = 0;
+ virtual bool BuildPlaylist(LPCTSTR pszFileName, CAtlList<CHdmvClipInfo::PlaylistItem>& Items) { return false; };
+ virtual bool BuildChapters(LPCTSTR pszFileName, CAtlList<CHdmvClipInfo::PlaylistItem>& PlaylistItems, CAtlList<CHdmvClipInfo::PlaylistChapter>& Items) { return false; };
public:
- CBaseSplitterFilter(LPCTSTR pName, LPUNKNOWN pUnk, HRESULT* phr, const CLSID& clsid, int QueueMaxPackets = MAXPACKETS);
- virtual ~CBaseSplitterFilter();
+ CBaseSplitterFilter(LPCTSTR pName, LPUNKNOWN pUnk, HRESULT* phr, const CLSID& clsid, int QueueMaxPackets = MAXPACKETS);
+ virtual ~CBaseSplitterFilter();
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- bool IsAnyPinDrying();
+ bool IsAnyPinDrying();
- HRESULT BreakConnect(PIN_DIRECTION dir, CBasePin* pPin);
- HRESULT CompleteConnect(PIN_DIRECTION dir, CBasePin* pPin);
+ HRESULT BreakConnect(PIN_DIRECTION dir, CBasePin* pPin);
+ HRESULT CompleteConnect(PIN_DIRECTION dir, CBasePin* pPin);
- int GetPinCount();
- CBasePin* GetPin(int n);
+ int GetPinCount();
+ CBasePin* GetPin(int n);
- STDMETHODIMP Stop();
- STDMETHODIMP Pause();
- STDMETHODIMP Run(REFERENCE_TIME tStart);
+ STDMETHODIMP Stop();
+ STDMETHODIMP Pause();
+ STDMETHODIMP Run(REFERENCE_TIME tStart);
- // IFileSourceFilter
+ // IFileSourceFilter
- STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
- // IMediaSeeking
+ // IMediaSeeking
- STDMETHODIMP GetCapabilities(DWORD* pCapabilities);
- STDMETHODIMP CheckCapabilities(DWORD* pCapabilities);
- STDMETHODIMP IsFormatSupported(const GUID* pFormat);
- STDMETHODIMP QueryPreferredFormat(GUID* pFormat);
- STDMETHODIMP GetTimeFormat(GUID* pFormat);
- STDMETHODIMP IsUsingTimeFormat(const GUID* pFormat);
- STDMETHODIMP SetTimeFormat(const GUID* pFormat);
- STDMETHODIMP GetDuration(LONGLONG* pDuration);
- STDMETHODIMP GetStopPosition(LONGLONG* pStop);
- STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
- STDMETHODIMP ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat);
- STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
- STDMETHODIMP GetPositions(LONGLONG* pCurrent, LONGLONG* pStop);
- STDMETHODIMP GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest);
- STDMETHODIMP SetRate(double dRate);
- STDMETHODIMP GetRate(double* pdRate);
- STDMETHODIMP GetPreroll(LONGLONG* pllPreroll);
+ STDMETHODIMP GetCapabilities(DWORD* pCapabilities);
+ STDMETHODIMP CheckCapabilities(DWORD* pCapabilities);
+ STDMETHODIMP IsFormatSupported(const GUID* pFormat);
+ STDMETHODIMP QueryPreferredFormat(GUID* pFormat);
+ STDMETHODIMP GetTimeFormat(GUID* pFormat);
+ STDMETHODIMP IsUsingTimeFormat(const GUID* pFormat);
+ STDMETHODIMP SetTimeFormat(const GUID* pFormat);
+ STDMETHODIMP GetDuration(LONGLONG* pDuration);
+ STDMETHODIMP GetStopPosition(LONGLONG* pStop);
+ STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
+ STDMETHODIMP ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat);
+ STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
+ STDMETHODIMP GetPositions(LONGLONG* pCurrent, LONGLONG* pStop);
+ STDMETHODIMP GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest);
+ STDMETHODIMP SetRate(double dRate);
+ STDMETHODIMP GetRate(double* pdRate);
+ STDMETHODIMP GetPreroll(LONGLONG* pllPreroll);
protected:
- friend class CBaseSplitterOutputPin;
- virtual HRESULT SetPositionsInternal(void* id, LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
+ friend class CBaseSplitterOutputPin;
+ virtual HRESULT SetPositionsInternal(void* id, LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
private:
- REFERENCE_TIME m_rtLastStart, m_rtLastStop;
- CAtlList<void*> m_LastSeekers;
+ REFERENCE_TIME m_rtLastStart, m_rtLastStop;
+ CAtlList<void*> m_LastSeekers;
public:
- // IAMOpenProgress
-
- STDMETHODIMP QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent);
- STDMETHODIMP AbortOperation();
-
- // IDispatch
-
- STDMETHODIMP GetTypeInfoCount(UINT* pctinfo) {return E_NOTIMPL;}
- STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo) {return E_NOTIMPL;}
- STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** rgszNames, UINT cNames, LCID lcid, DISPID* rgdispid) {return E_NOTIMPL;}
- STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult, EXCEPINFO* pexcepinfo, UINT* puArgErr) {return E_NOTIMPL;}
-
- // IAMMediaContent
-
- STDMETHODIMP get_AuthorName(BSTR* pbstrAuthorName);
- STDMETHODIMP get_Title(BSTR* pbstrTitle);
- STDMETHODIMP get_Rating(BSTR* pbstrRating);
- STDMETHODIMP get_Description(BSTR* pbstrDescription);
- STDMETHODIMP get_Copyright(BSTR* pbstrCopyright);
- STDMETHODIMP get_BaseURL(BSTR* pbstrBaseURL) {return E_NOTIMPL;}
- STDMETHODIMP get_LogoURL(BSTR* pbstrLogoURL) {return E_NOTIMPL;}
- STDMETHODIMP get_LogoIconURL(BSTR* pbstrLogoURL) {return E_NOTIMPL;}
- STDMETHODIMP get_WatermarkURL(BSTR* pbstrWatermarkURL) {return E_NOTIMPL;}
- STDMETHODIMP get_MoreInfoURL(BSTR* pbstrMoreInfoURL) {return E_NOTIMPL;}
- STDMETHODIMP get_MoreInfoBannerImage(BSTR* pbstrMoreInfoBannerImage) {return E_NOTIMPL;}
- STDMETHODIMP get_MoreInfoBannerURL(BSTR* pbstrMoreInfoBannerURL) {return E_NOTIMPL;}
- STDMETHODIMP get_MoreInfoText(BSTR* pbstrMoreInfoText) {return E_NOTIMPL;}
-
- // IAMExtendedSeeking
-
- STDMETHODIMP get_ExSeekCapabilities(long* pExCapabilities);
- STDMETHODIMP get_MarkerCount(long* pMarkerCount);
- STDMETHODIMP get_CurrentMarker(long* pCurrentMarker);
- STDMETHODIMP GetMarkerTime(long MarkerNum, double* pMarkerTime);
- STDMETHODIMP GetMarkerName(long MarkerNum, BSTR* pbstrMarkerName);
- STDMETHODIMP put_PlaybackSpeed(double Speed) {return E_NOTIMPL;}
- STDMETHODIMP get_PlaybackSpeed(double* pSpeed) {return E_NOTIMPL;}
-
- // IKeyFrameInfo
-
- STDMETHODIMP_(HRESULT) GetKeyFrameCount(UINT& nKFs);
- STDMETHODIMP_(HRESULT) GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs);
-
- // IBufferInfo
-
- STDMETHODIMP_(int) GetCount();
- STDMETHODIMP GetStatus(int i, int& samples, int& size);
- STDMETHODIMP_(DWORD) GetPriority();
+ // IAMOpenProgress
+
+ STDMETHODIMP QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent);
+ STDMETHODIMP AbortOperation();
+
+ // IDispatch
+
+ STDMETHODIMP GetTypeInfoCount(UINT* pctinfo) {return E_NOTIMPL;}
+ STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo) {return E_NOTIMPL;}
+ STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** rgszNames, UINT cNames, LCID lcid, DISPID* rgdispid) {return E_NOTIMPL;}
+ STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult, EXCEPINFO* pexcepinfo, UINT* puArgErr) {return E_NOTIMPL;}
+
+ // IAMMediaContent
+
+ STDMETHODIMP get_AuthorName(BSTR* pbstrAuthorName);
+ STDMETHODIMP get_Title(BSTR* pbstrTitle);
+ STDMETHODIMP get_Rating(BSTR* pbstrRating);
+ STDMETHODIMP get_Description(BSTR* pbstrDescription);
+ STDMETHODIMP get_Copyright(BSTR* pbstrCopyright);
+ STDMETHODIMP get_BaseURL(BSTR* pbstrBaseURL) {return E_NOTIMPL;}
+ STDMETHODIMP get_LogoURL(BSTR* pbstrLogoURL) {return E_NOTIMPL;}
+ STDMETHODIMP get_LogoIconURL(BSTR* pbstrLogoURL) {return E_NOTIMPL;}
+ STDMETHODIMP get_WatermarkURL(BSTR* pbstrWatermarkURL) {return E_NOTIMPL;}
+ STDMETHODIMP get_MoreInfoURL(BSTR* pbstrMoreInfoURL) {return E_NOTIMPL;}
+ STDMETHODIMP get_MoreInfoBannerImage(BSTR* pbstrMoreInfoBannerImage) {return E_NOTIMPL;}
+ STDMETHODIMP get_MoreInfoBannerURL(BSTR* pbstrMoreInfoBannerURL) {return E_NOTIMPL;}
+ STDMETHODIMP get_MoreInfoText(BSTR* pbstrMoreInfoText) {return E_NOTIMPL;}
+
+ // IAMExtendedSeeking
+
+ STDMETHODIMP get_ExSeekCapabilities(long* pExCapabilities);
+ STDMETHODIMP get_MarkerCount(long* pMarkerCount);
+ STDMETHODIMP get_CurrentMarker(long* pCurrentMarker);
+ STDMETHODIMP GetMarkerTime(long MarkerNum, double* pMarkerTime);
+ STDMETHODIMP GetMarkerName(long MarkerNum, BSTR* pbstrMarkerName);
+ STDMETHODIMP put_PlaybackSpeed(double Speed) {return E_NOTIMPL;}
+ STDMETHODIMP get_PlaybackSpeed(double* pSpeed) {return E_NOTIMPL;}
+
+ // IKeyFrameInfo
+
+ STDMETHODIMP_(HRESULT) GetKeyFrameCount(UINT& nKFs);
+ STDMETHODIMP_(HRESULT) GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs);
+
+ // IBufferInfo
+
+ STDMETHODIMP_(int) GetCount();
+ STDMETHODIMP GetStatus(int i, int& samples, int& size);
+ STDMETHODIMP_(DWORD) GetPriority();
};
diff --git a/src/filters/parser/BaseSplitter/BaseSplitterFile.cpp b/src/filters/parser/BaseSplitter/BaseSplitterFile.cpp
index 3db0849e2..08a117b8c 100644
--- a/src/filters/parser/BaseSplitter/BaseSplitterFile.cpp
+++ b/src/filters/parser/BaseSplitter/BaseSplitterFile.cpp
@@ -30,222 +30,222 @@
//
CBaseSplitterFile::CBaseSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr, int cachelen, bool fRandomAccess, bool fStreaming)
- : m_pAsyncReader(pAsyncReader)
- , m_fStreaming(false)
- , m_fRandomAccess(false)
- , m_pos(0), m_len(0)
- , m_bitbuff(0), m_bitlen(0)
- , m_cachepos(0), m_cachelen(0)
+ : m_pAsyncReader(pAsyncReader)
+ , m_fStreaming(false)
+ , m_fRandomAccess(false)
+ , m_pos(0), m_len(0)
+ , m_bitbuff(0), m_bitlen(0)
+ , m_cachepos(0), m_cachelen(0)
{
- if (!m_pAsyncReader) {
- hr = E_UNEXPECTED;
- return;
- }
+ if (!m_pAsyncReader) {
+ hr = E_UNEXPECTED;
+ return;
+ }
- LONGLONG total = 0, available;
- hr = m_pAsyncReader->Length(&total, &available);
+ LONGLONG total = 0, available;
+ hr = m_pAsyncReader->Length(&total, &available);
- m_fStreaming = total == 0 && available > 0;
- m_fRandomAccess = total > 0 && total == available;
- m_len = total;
+ m_fStreaming = total == 0 && available > 0;
+ m_fRandomAccess = total > 0 && total == available;
+ m_len = total;
- if (FAILED(hr) || fRandomAccess && !m_fRandomAccess || !fStreaming && m_fStreaming || m_len < 0) {
- hr = E_FAIL;
- return;
- }
+ if (FAILED(hr) || fRandomAccess && !m_fRandomAccess || !fStreaming && m_fStreaming || m_len < 0) {
+ hr = E_FAIL;
+ return;
+ }
- if (!SetCacheSize(cachelen)) {
- hr = E_OUTOFMEMORY;
- return;
- }
+ if (!SetCacheSize(cachelen)) {
+ hr = E_OUTOFMEMORY;
+ return;
+ }
- hr = S_OK;
+ hr = S_OK;
}
bool CBaseSplitterFile::SetCacheSize(int cachelen)
{
- m_pCache.Free();
- m_cachetotal = 0;
- m_pCache.Allocate((size_t)cachelen);
- if (!m_pCache) {
- return false;
- }
- m_cachetotal = cachelen;
- m_cachelen = 0;
- return true;
+ m_pCache.Free();
+ m_cachetotal = 0;
+ m_pCache.Allocate((size_t)cachelen);
+ if (!m_pCache) {
+ return false;
+ }
+ m_cachetotal = cachelen;
+ m_cachelen = 0;
+ return true;
}
__int64 CBaseSplitterFile::GetPos()
{
- return m_pos - (m_bitlen>>3);
+ return m_pos - (m_bitlen >> 3);
}
__int64 CBaseSplitterFile::GetAvailable()
{
- LONGLONG total, available = 0;
- m_pAsyncReader->Length(&total, &available);
- return available;
+ LONGLONG total, available = 0;
+ m_pAsyncReader->Length(&total, &available);
+ return available;
}
__int64 CBaseSplitterFile::GetLength(bool fUpdate)
{
- if (m_fStreaming) {
- m_len = GetAvailable();
- } else if (fUpdate) {
- LONGLONG total = 0, available;
- m_pAsyncReader->Length(&total, &available);
- m_len = total;
- }
-
- return m_len;
+ if (m_fStreaming) {
+ m_len = GetAvailable();
+ } else if (fUpdate) {
+ LONGLONG total = 0, available;
+ m_pAsyncReader->Length(&total, &available);
+ m_len = total;
+ }
+
+ return m_len;
}
void CBaseSplitterFile::Seek(__int64 pos)
{
- __int64 len = GetLength();
- m_pos = min(max(pos, 0), len);
- BitFlush();
+ __int64 len = GetLength();
+ m_pos = min(max(pos, 0), len);
+ BitFlush();
}
HRESULT CBaseSplitterFile::Read(BYTE* pData, __int64 len)
{
- CheckPointer(m_pAsyncReader, E_NOINTERFACE);
-
- HRESULT hr = S_OK;
-
- if (!m_fRandomAccess) {
- LONGLONG total = 0, available = -1;
- m_pAsyncReader->Length(&total, &available);
- if (total == available) {
- m_fRandomAccess = true;
- OnComplete();
- }
- }
-
- if (m_cachetotal == 0 || !m_pCache) {
- hr = m_pAsyncReader->SyncRead(m_pos, (long)len, pData);
- m_pos += len;
- return hr;
- }
-
- BYTE* pCache = m_pCache;
-
- if (m_cachepos <= m_pos && m_pos < m_cachepos + m_cachelen) {
- __int64 minlen = min(len, m_cachelen - (m_pos - m_cachepos));
-
- memcpy(pData, &pCache[m_pos - m_cachepos], (size_t)minlen);
-
- len -= minlen;
- m_pos += minlen;
- pData += minlen;
- }
-
- while (len > m_cachetotal) {
- hr = m_pAsyncReader->SyncRead(m_pos, (long)m_cachetotal, pData);
- if (S_OK != hr) {
- return hr;
- }
-
- len -= m_cachetotal;
- m_pos += m_cachetotal;
- pData += m_cachetotal;
- }
-
- while (len > 0) {
- __int64 tmplen = GetLength();
- __int64 maxlen = min(tmplen - m_pos, m_cachetotal);
- __int64 minlen = min(len, maxlen);
- if (minlen <= 0) {
- return S_FALSE;
- }
-
- hr = m_pAsyncReader->SyncRead(m_pos, (long)maxlen, pCache);
- if (S_OK != hr) {
- return hr;
- }
-
- m_cachepos = m_pos;
- m_cachelen = maxlen;
-
- memcpy(pData, pCache, (size_t)minlen);
-
- len -= minlen;
- m_pos += minlen;
- pData += minlen;
- }
-
- return hr;
+ CheckPointer(m_pAsyncReader, E_NOINTERFACE);
+
+ HRESULT hr = S_OK;
+
+ if (!m_fRandomAccess) {
+ LONGLONG total = 0, available = -1;
+ m_pAsyncReader->Length(&total, &available);
+ if (total == available) {
+ m_fRandomAccess = true;
+ OnComplete();
+ }
+ }
+
+ if (m_cachetotal == 0 || !m_pCache) {
+ hr = m_pAsyncReader->SyncRead(m_pos, (long)len, pData);
+ m_pos += len;
+ return hr;
+ }
+
+ BYTE* pCache = m_pCache;
+
+ if (m_cachepos <= m_pos && m_pos < m_cachepos + m_cachelen) {
+ __int64 minlen = min(len, m_cachelen - (m_pos - m_cachepos));
+
+ memcpy(pData, &pCache[m_pos - m_cachepos], (size_t)minlen);
+
+ len -= minlen;
+ m_pos += minlen;
+ pData += minlen;
+ }
+
+ while (len > m_cachetotal) {
+ hr = m_pAsyncReader->SyncRead(m_pos, (long)m_cachetotal, pData);
+ if (S_OK != hr) {
+ return hr;
+ }
+
+ len -= m_cachetotal;
+ m_pos += m_cachetotal;
+ pData += m_cachetotal;
+ }
+
+ while (len > 0) {
+ __int64 tmplen = GetLength();
+ __int64 maxlen = min(tmplen - m_pos, m_cachetotal);
+ __int64 minlen = min(len, maxlen);
+ if (minlen <= 0) {
+ return S_FALSE;
+ }
+
+ hr = m_pAsyncReader->SyncRead(m_pos, (long)maxlen, pCache);
+ if (S_OK != hr) {
+ return hr;
+ }
+
+ m_cachepos = m_pos;
+ m_cachelen = maxlen;
+
+ memcpy(pData, pCache, (size_t)minlen);
+
+ len -= minlen;
+ m_pos += minlen;
+ pData += minlen;
+ }
+
+ return hr;
}
UINT64 CBaseSplitterFile::BitRead(int nBits, bool fPeek)
{
- ASSERT(nBits >= 0 && nBits <= 64);
+ ASSERT(nBits >= 0 && nBits <= 64);
- while (m_bitlen < nBits) {
- m_bitbuff <<= 8;
- if (S_OK != Read((BYTE*)&m_bitbuff, 1)) {
- return 0; // EOF? // ASSERT(0);
- }
- m_bitlen += 8;
- }
+ while (m_bitlen < nBits) {
+ m_bitbuff <<= 8;
+ if (S_OK != Read((BYTE*)&m_bitbuff, 1)) {
+ return 0; // EOF? // ASSERT(0);
+ }
+ m_bitlen += 8;
+ }
- int bitlen = m_bitlen - nBits;
+ int bitlen = m_bitlen - nBits;
- UINT64 ret = (m_bitbuff >> bitlen) & ((1ui64 << nBits) - 1);
+ UINT64 ret = (m_bitbuff >> bitlen) & ((1ui64 << nBits) - 1);
- if (!fPeek) {
- m_bitbuff &= ((1ui64 << bitlen) - 1);
- m_bitlen = bitlen;
- }
+ if (!fPeek) {
+ m_bitbuff &= ((1ui64 << bitlen) - 1);
+ m_bitlen = bitlen;
+ }
- return ret;
+ return ret;
}
void CBaseSplitterFile::BitByteAlign()
{
- m_bitlen &= ~7;
+ m_bitlen &= ~7;
}
void CBaseSplitterFile::BitFlush()
{
- m_bitlen = 0;
+ m_bitlen = 0;
}
HRESULT CBaseSplitterFile::ByteRead(BYTE* pData, __int64 len)
{
- Seek(GetPos());
- return Read(pData, len);
+ Seek(GetPos());
+ return Read(pData, len);
}
UINT64 CBaseSplitterFile::UExpGolombRead()
{
- int n = -1;
- for (BYTE b = 0; !b; n++) {
- b = (BYTE)BitRead(1);
- }
- return (1ui64 << n) - 1 + BitRead(n);
+ int n = -1;
+ for (BYTE b = 0; !b; n++) {
+ b = (BYTE)BitRead(1);
+ }
+ return (1ui64 << n) - 1 + BitRead(n);
}
INT64 CBaseSplitterFile::SExpGolombRead()
{
- UINT64 k = UExpGolombRead();
- return ((k&1) ? 1 : -1) * ((k + 1) >> 1);
+ UINT64 k = UExpGolombRead();
+ return ((k & 1) ? 1 : -1) * ((k + 1) >> 1);
}
HRESULT CBaseSplitterFile::HasMoreData(__int64 len, DWORD ms)
{
- __int64 available = GetLength() - GetPos();
+ __int64 available = GetLength() - GetPos();
- if (!m_fStreaming) {
- return available < 1 ? E_FAIL : S_OK;
- }
+ if (!m_fStreaming) {
+ return available < 1 ? E_FAIL : S_OK;
+ }
- if (available < len) {
- if (ms > 0) {
- Sleep(ms);
- }
- return S_FALSE;
- }
+ if (available < len) {
+ if (ms > 0) {
+ Sleep(ms);
+ }
+ return S_FALSE;
+ }
- return S_OK;
+ return S_OK;
}
diff --git a/src/filters/parser/BaseSplitter/BaseSplitterFile.h b/src/filters/parser/BaseSplitter/BaseSplitterFile.h
index 54533140a..59cae090f 100644
--- a/src/filters/parser/BaseSplitter/BaseSplitterFile.h
+++ b/src/filters/parser/BaseSplitter/BaseSplitterFile.h
@@ -25,46 +25,46 @@
#include <atlcoll.h>
-#define DEFAULT_CACHE_LENGTH 64*1024 // Beliyaal: Changed the default cache length to allow Bluray playback over network
+#define DEFAULT_CACHE_LENGTH 64*1024 // Beliyaal: Changed the default cache length to allow Bluray playback over network
class CBaseSplitterFile
{
- CComPtr<IAsyncReader> m_pAsyncReader;
- CAutoVectorPtr<BYTE> m_pCache;
- __int64 m_cachepos, m_cachelen, m_cachetotal;
+ CComPtr<IAsyncReader> m_pAsyncReader;
+ CAutoVectorPtr<BYTE> m_pCache;
+ __int64 m_cachepos, m_cachelen, m_cachetotal;
- bool m_fStreaming, m_fRandomAccess;
- __int64 m_pos, m_len;
+ bool m_fStreaming, m_fRandomAccess;
+ __int64 m_pos, m_len;
- virtual HRESULT Read(BYTE* pData, __int64 len); // use ByteRead
+ virtual HRESULT Read(BYTE* pData, __int64 len); // use ByteRead
protected:
- UINT64 m_bitbuff;
- int m_bitlen;
+ UINT64 m_bitbuff;
+ int m_bitlen;
- virtual void OnComplete() {}
+ virtual void OnComplete() {}
public:
- CBaseSplitterFile(IAsyncReader* pReader, HRESULT& hr, int cachelen = DEFAULT_CACHE_LENGTH, bool fRandomAccess = true, bool fStreaming = false);
- virtual ~CBaseSplitterFile() {}
+ CBaseSplitterFile(IAsyncReader* pReader, HRESULT& hr, int cachelen = DEFAULT_CACHE_LENGTH, bool fRandomAccess = true, bool fStreaming = false);
+ virtual ~CBaseSplitterFile() {}
- bool SetCacheSize(int cachelen = DEFAULT_CACHE_LENGTH);
+ bool SetCacheSize(int cachelen = DEFAULT_CACHE_LENGTH);
- __int64 GetPos();
- __int64 GetAvailable();
- __int64 GetLength(bool fUpdate = false);
- __int64 GetRemaining() {return max(0, GetLength() - GetPos());}
- virtual void Seek(__int64 pos);
+ __int64 GetPos();
+ __int64 GetAvailable();
+ __int64 GetLength(bool fUpdate = false);
+ __int64 GetRemaining() {return max(0, GetLength() - GetPos());}
+ virtual void Seek(__int64 pos);
- UINT64 UExpGolombRead();
- INT64 SExpGolombRead();
+ UINT64 UExpGolombRead();
+ INT64 SExpGolombRead();
- UINT64 BitRead(int nBits, bool fPeek = false);
- void BitByteAlign(), BitFlush();
- HRESULT ByteRead(BYTE* pData, __int64 len);
+ UINT64 BitRead(int nBits, bool fPeek = false);
+ void BitByteAlign(), BitFlush();
+ HRESULT ByteRead(BYTE* pData, __int64 len);
- bool IsStreaming() const {return m_fStreaming;}
- bool IsRandomAccess() const {return m_fRandomAccess;}
+ bool IsStreaming() const {return m_fStreaming;}
+ bool IsRandomAccess() const {return m_fRandomAccess;}
- HRESULT HasMoreData(__int64 len = 1, DWORD ms = 1);
+ HRESULT HasMoreData(__int64 len = 1, DWORD ms = 1);
};
diff --git a/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp b/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp
index e4129fd58..490d2aab5 100644
--- a/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp
+++ b/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp
@@ -35,9 +35,9 @@
//
CBaseSplitterFileEx::CBaseSplitterFileEx(IAsyncReader* pReader, HRESULT& hr, int cachelen, bool fRandomAccess, bool fStreaming)
- : CBaseSplitterFile(pReader, hr, cachelen, fRandomAccess, fStreaming)
- , m_tslen(0)
- ,m_rtPTSOffset(0)
+ : CBaseSplitterFile(pReader, hr, cachelen, fRandomAccess, fStreaming)
+ , m_tslen(0)
+ , m_rtPTSOffset(0)
{
}
@@ -49,16 +49,16 @@ CBaseSplitterFileEx::~CBaseSplitterFileEx()
bool CBaseSplitterFileEx::NextMpegStartCode(BYTE& code, __int64 len)
{
- BitByteAlign();
- DWORD dw = (DWORD)-1;
- do {
- if (len-- == 0 || !GetRemaining()) {
- return false;
- }
- dw = (dw << 8) | (BYTE)BitRead(8);
- } while ((dw&0xffffff00) != 0x00000100);
- code = (BYTE)(dw&0xff);
- return true;
+ BitByteAlign();
+ DWORD dw = (DWORD) - 1;
+ do {
+ if (len-- == 0 || !GetRemaining()) {
+ return false;
+ }
+ dw = (dw << 8) | (BYTE)BitRead(8);
+ } while ((dw & 0xffffff00) != 0x00000100);
+ code = (BYTE)(dw & 0xff);
+ return true;
}
//
@@ -67,2098 +67,2111 @@ bool CBaseSplitterFileEx::NextMpegStartCode(BYTE& code, __int64 len)
bool CBaseSplitterFileEx::Read(pshdr& h)
{
- memset(&h, 0, sizeof(h));
-
- BYTE b = (BYTE)BitRead(8, true);
-
- if ((b&0xf1) == 0x21) {
- h.type = mpeg1;
-
- EXECUTE_ASSERT(BitRead(4) == 2);
-
- h.scr = 0;
- h.scr |= BitRead(3) << 30;
- MARKER; // 32..30
- h.scr |= BitRead(15) << 15;
- MARKER; // 29..15
- h.scr |= BitRead(15);
- MARKER;
- MARKER; // 14..0
- h.bitrate = BitRead(22);
- MARKER;
- } else if ((b&0xc4) == 0x44) {
- h.type = mpeg2;
-
- EXECUTE_ASSERT(BitRead(2) == 1);
-
- h.scr = 0;
- h.scr |= BitRead(3) << 30;
- MARKER; // 32..30
- h.scr |= BitRead(15) << 15;
- MARKER; // 29..15
- h.scr |= BitRead(15);
- MARKER; // 14..0
- h.scr = (h.scr*300 + BitRead(9)) * 10 / 27;
- MARKER;
- h.bitrate = BitRead(22);
- MARKER;
- MARKER;
- BitRead(5); // reserved
- UINT64 stuffing = BitRead(3);
- while (stuffing-- > 0) {
- EXECUTE_ASSERT(BitRead(8) == 0xff);
- }
- } else {
- return false;
- }
-
- h.bitrate *= 400;
-
- return true;
+ memset(&h, 0, sizeof(h));
+
+ BYTE b = (BYTE)BitRead(8, true);
+
+ if ((b & 0xf1) == 0x21) {
+ h.type = mpeg1;
+
+ EXECUTE_ASSERT(BitRead(4) == 2);
+
+ h.scr = 0;
+ h.scr |= BitRead(3) << 30;
+ MARKER; // 32..30
+ h.scr |= BitRead(15) << 15;
+ MARKER; // 29..15
+ h.scr |= BitRead(15);
+ MARKER;
+ MARKER; // 14..0
+ h.bitrate = BitRead(22);
+ MARKER;
+ } else if ((b & 0xc4) == 0x44) {
+ h.type = mpeg2;
+
+ EXECUTE_ASSERT(BitRead(2) == 1);
+
+ h.scr = 0;
+ h.scr |= BitRead(3) << 30;
+ MARKER; // 32..30
+ h.scr |= BitRead(15) << 15;
+ MARKER; // 29..15
+ h.scr |= BitRead(15);
+ MARKER; // 14..0
+ h.scr = (h.scr * 300 + BitRead(9)) * 10 / 27;
+ MARKER;
+ h.bitrate = BitRead(22);
+ MARKER;
+ MARKER;
+ BitRead(5); // reserved
+ UINT64 stuffing = BitRead(3);
+ while (stuffing-- > 0) {
+ EXECUTE_ASSERT(BitRead(8) == 0xff);
+ }
+ } else {
+ return false;
+ }
+
+ h.bitrate *= 400;
+
+ return true;
}
bool CBaseSplitterFileEx::Read(pssyshdr& h)
{
- memset(&h, 0, sizeof(h));
-
- WORD len = (WORD)BitRead(16);
- MARKER;
- h.rate_bound = (DWORD)BitRead(22);
- MARKER;
- h.audio_bound = (BYTE)BitRead(6);
- h.fixed_rate = !!BitRead(1);
- h.csps = !!BitRead(1);
- h.sys_audio_loc_flag = !!BitRead(1);
- h.sys_video_loc_flag = !!BitRead(1);
- MARKER;
- h.video_bound = (BYTE)BitRead(5);
-
- EXECUTE_ASSERT((BitRead(8)&0x7f) == 0x7f); // reserved (should be 0xff, but not in reality)
-
- for (len -= 6; len > 3; len -= 3) { // TODO: also store these, somewhere, if needed
- UINT64 stream_id = BitRead(8);
- UNREFERENCED_PARAMETER(stream_id);
- EXECUTE_ASSERT(BitRead(2) == 3);
- UINT64 p_std_buff_size_bound = (BitRead(1)?1024:128)*BitRead(13);
- UNREFERENCED_PARAMETER(p_std_buff_size_bound);
- }
-
- return true;
+ memset(&h, 0, sizeof(h));
+
+ WORD len = (WORD)BitRead(16);
+ MARKER;
+ h.rate_bound = (DWORD)BitRead(22);
+ MARKER;
+ h.audio_bound = (BYTE)BitRead(6);
+ h.fixed_rate = !!BitRead(1);
+ h.csps = !!BitRead(1);
+ h.sys_audio_loc_flag = !!BitRead(1);
+ h.sys_video_loc_flag = !!BitRead(1);
+ MARKER;
+ h.video_bound = (BYTE)BitRead(5);
+
+ EXECUTE_ASSERT((BitRead(8) & 0x7f) == 0x7f); // reserved (should be 0xff, but not in reality)
+
+ for (len -= 6; len > 3; len -= 3) { // TODO: also store these, somewhere, if needed
+ UINT64 stream_id = BitRead(8);
+ UNREFERENCED_PARAMETER(stream_id);
+ EXECUTE_ASSERT(BitRead(2) == 3);
+ UINT64 p_std_buff_size_bound = (BitRead(1) ? 1024 : 128) * BitRead(13);
+ UNREFERENCED_PARAMETER(p_std_buff_size_bound);
+ }
+
+ return true;
}
bool CBaseSplitterFileEx::Read(peshdr& h, BYTE code)
{
- memset(&h, 0, sizeof(h));
-
- if (!(code >= 0xbd && code < 0xf0 || code == 0xfd)) { // 0xfd => blu-ray (.m2ts)
- return false;
- }
-
- h.len = (WORD)BitRead(16);
-
- if (code == 0xbe || code == 0xbf) {
- return true;
- }
-
- // mpeg1 stuffing (ff ff .. , max 16x)
- for (int i = 0; i < 16 && BitRead(8, true) == 0xff; i++) {
- BitRead(8);
- if (h.len) {
- h.len--;
- }
- }
-
- h.type = (BYTE)BitRead(2, true) == mpeg2 ? mpeg2 : mpeg1;
-
- if (h.type == mpeg1) {
- BYTE b = (BYTE)BitRead(2);
-
- if (b == 1) {
- h.std_buff_size = (BitRead(1)?1024:128)*BitRead(13);
- if (h.len) {
- h.len -= 2;
- }
- b = (BYTE)BitRead(2);
- }
-
- if (b == 0) {
- h.fpts = (BYTE)BitRead(1);
- h.fdts = (BYTE)BitRead(1);
- }
- } else if (h.type == mpeg2) {
- EXECUTE_ASSERT(BitRead(2) == mpeg2);
- h.scrambling = (BYTE)BitRead(2);
- h.priority = (BYTE)BitRead(1);
- h.alignment = (BYTE)BitRead(1);
- h.copyright = (BYTE)BitRead(1);
- h.original = (BYTE)BitRead(1);
- h.fpts = (BYTE)BitRead(1);
- h.fdts = (BYTE)BitRead(1);
- h.escr = (BYTE)BitRead(1);
- h.esrate = (BYTE)BitRead(1);
- h.dsmtrickmode = (BYTE)BitRead(1);
- h.morecopyright = (BYTE)BitRead(1);
- h.crc = (BYTE)BitRead(1);
- h.extension = (BYTE)BitRead(1);
- h.hdrlen = (BYTE)BitRead(8);
- } else {
- if (h.len) while (h.len-- > 0) {
- BitRead(8);
- }
- return false;
- }
-
- if (h.fpts) {
- if (h.type == mpeg2) {
- BYTE b = (BYTE)BitRead(4);
- if (!(h.fdts && b == 3 || !h.fdts && b == 2)) {/*ASSERT(0); */return false;}
- }
-
- h.pts = 0;
- h.pts |= BitRead(3) << 30;
- MARKER; // 32..30
- h.pts |= BitRead(15) << 15;
- MARKER; // 29..15
- h.pts |= BitRead(15);
- MARKER; // 14..0
- h.pts = 10000*h.pts/90 + m_rtPTSOffset;
- }
-
- if (h.fdts) {
- if ((BYTE)BitRead(4) != 1) {/*ASSERT(0); */return false;}
-
- h.dts = 0;
- h.dts |= BitRead(3) << 30;
- MARKER; // 32..30
- h.dts |= BitRead(15) << 15;
- MARKER; // 29..15
- h.dts |= BitRead(15);
- MARKER; // 14..0
- h.dts = 10000*h.dts/90 + m_rtPTSOffset;
- }
-
- // skip to the end of header
-
- if (h.type == mpeg1) {
- if (!h.fpts && !h.fdts && BitRead(4) != 0xf) {
- /*ASSERT(0);*/ return false;
- }
-
- if (h.len) {
- h.len--;
- if (h.pts) {
- h.len -= 4;
- }
- if (h.dts) {
- h.len -= 5;
- }
- }
- }
-
- if (h.type == mpeg2) {
- if (h.len) {
- h.len -= 3+h.hdrlen;
- }
-
- int left = h.hdrlen;
- if (h.fpts) {
- left -= 5;
- }
- if (h.fdts) {
- left -= 5;
- }
-
- if (h.extension) { /* PES extension */
- BYTE pes_ext = (BYTE)BitRead(8);
- left--;
- BYTE skip = (pes_ext >> 4) & 0xb;
- skip += skip & 0x9;
- if (pes_ext & 0x40 || skip > left) {
- TRACE(_T("pes_ext %X is invalid\n"), pes_ext);
- pes_ext = skip = 0;
- }
- for (int i=0; i<skip; i++) {
- BitRead(8);
- }
- left -= skip;
- if (pes_ext & 0x01) { /* PES extension 2 */
- BYTE ext2_len = (BYTE)BitRead(8);
- left--;
- if ((ext2_len & 0x7f) > 0) {
- BYTE id_ext = (BYTE)BitRead(8);
- if ((id_ext & 0x80) == 0) {
- h.id_ext = id_ext;
- }
- left--;
- }
- }
- }
- while (left-- > 0) {
- BitRead(8);
- }
- }
-
- return true;
+ memset(&h, 0, sizeof(h));
+
+ if (!(code >= 0xbd && code < 0xf0 || code == 0xfd)) { // 0xfd => blu-ray (.m2ts)
+ return false;
+ }
+
+ h.len = (WORD)BitRead(16);
+
+ if (code == 0xbe || code == 0xbf) {
+ return true;
+ }
+
+ // mpeg1 stuffing (ff ff .. , max 16x)
+ for (int i = 0; i < 16 && BitRead(8, true) == 0xff; i++) {
+ BitRead(8);
+ if (h.len) {
+ h.len--;
+ }
+ }
+
+ h.type = (BYTE)BitRead(2, true) == mpeg2 ? mpeg2 : mpeg1;
+
+ if (h.type == mpeg1) {
+ BYTE b = (BYTE)BitRead(2);
+
+ if (b == 1) {
+ h.std_buff_size = (BitRead(1) ? 1024 : 128) * BitRead(13);
+ if (h.len) {
+ h.len -= 2;
+ }
+ b = (BYTE)BitRead(2);
+ }
+
+ if (b == 0) {
+ h.fpts = (BYTE)BitRead(1);
+ h.fdts = (BYTE)BitRead(1);
+ }
+ } else if (h.type == mpeg2) {
+ EXECUTE_ASSERT(BitRead(2) == mpeg2);
+ h.scrambling = (BYTE)BitRead(2);
+ h.priority = (BYTE)BitRead(1);
+ h.alignment = (BYTE)BitRead(1);
+ h.copyright = (BYTE)BitRead(1);
+ h.original = (BYTE)BitRead(1);
+ h.fpts = (BYTE)BitRead(1);
+ h.fdts = (BYTE)BitRead(1);
+ h.escr = (BYTE)BitRead(1);
+ h.esrate = (BYTE)BitRead(1);
+ h.dsmtrickmode = (BYTE)BitRead(1);
+ h.morecopyright = (BYTE)BitRead(1);
+ h.crc = (BYTE)BitRead(1);
+ h.extension = (BYTE)BitRead(1);
+ h.hdrlen = (BYTE)BitRead(8);
+ } else {
+ if (h.len) while (h.len-- > 0) {
+ BitRead(8);
+ }
+ return false;
+ }
+
+ if (h.fpts) {
+ if (h.type == mpeg2) {
+ BYTE b = (BYTE)BitRead(4);
+ if (!(h.fdts && b == 3 || !h.fdts && b == 2)) {/*ASSERT(0); */return false;}
+ }
+
+ h.pts = 0;
+ h.pts |= BitRead(3) << 30;
+ MARKER; // 32..30
+ h.pts |= BitRead(15) << 15;
+ MARKER; // 29..15
+ h.pts |= BitRead(15);
+ MARKER; // 14..0
+ h.pts = 10000 * h.pts / 90 + m_rtPTSOffset;
+ }
+
+ if (h.fdts) {
+ if ((BYTE)BitRead(4) != 1) {/*ASSERT(0); */return false;}
+
+ h.dts = 0;
+ h.dts |= BitRead(3) << 30;
+ MARKER; // 32..30
+ h.dts |= BitRead(15) << 15;
+ MARKER; // 29..15
+ h.dts |= BitRead(15);
+ MARKER; // 14..0
+ h.dts = 10000 * h.dts / 90 + m_rtPTSOffset;
+ }
+
+ // skip to the end of header
+
+ if (h.type == mpeg1) {
+ if (!h.fpts && !h.fdts && BitRead(4) != 0xf) {
+ /*ASSERT(0);*/ return false;
+ }
+
+ if (h.len) {
+ h.len--;
+ if (h.pts) {
+ h.len -= 4;
+ }
+ if (h.dts) {
+ h.len -= 5;
+ }
+ }
+ }
+
+ if (h.type == mpeg2) {
+ if (h.len) {
+ h.len -= 3 + h.hdrlen;
+ }
+
+ int left = h.hdrlen;
+ if (h.fpts) {
+ left -= 5;
+ }
+ if (h.fdts) {
+ left -= 5;
+ }
+
+ if (h.extension) { /* PES extension */
+ BYTE pes_ext = (BYTE)BitRead(8);
+ left--;
+ BYTE skip = (pes_ext >> 4) & 0xb;
+ skip += skip & 0x9;
+ if (pes_ext & 0x40 || skip > left) {
+ TRACE(_T("pes_ext %X is invalid\n"), pes_ext);
+ pes_ext = skip = 0;
+ }
+ for (int i = 0; i < skip; i++) {
+ BitRead(8);
+ }
+ left -= skip;
+ if (pes_ext & 0x01) { /* PES extension 2 */
+ BYTE ext2_len = (BYTE)BitRead(8);
+ left--;
+ if ((ext2_len & 0x7f) > 0) {
+ BYTE id_ext = (BYTE)BitRead(8);
+ if ((id_ext & 0x80) == 0) {
+ h.id_ext = id_ext;
+ }
+ left--;
+ }
+ }
+ }
+ while (left-- > 0) {
+ BitRead(8);
+ }
+ }
+
+ return true;
}
bool CBaseSplitterFileEx::Read(seqhdr& h, int len, CMediaType* pmt)
{
- __int64 endpos = GetPos() + len; // - sequence header length
-
- BYTE id = 0;
-
- while (GetPos() < endpos && id != 0xb3) {
- if (!NextMpegStartCode(id, len)) {
- return false;
- }
- }
-
- if (id != 0xb3) {
- return false;
- }
-
- __int64 shpos = GetPos() - 4;
-
- h.width = (WORD)BitRead(12);
- h.height = (WORD)BitRead(12);
- h.ar = BitRead(4);
- static int ifps[16] = {0, 1126125, 1125000, 1080000, 900900, 900000, 540000, 450450, 450000, 0, 0, 0, 0, 0, 0, 0};
- h.ifps = ifps[BitRead(4)];
- h.bitrate = (DWORD)BitRead(18);
- MARKER;
- h.vbv = (DWORD)BitRead(10);
- h.constrained = BitRead(1);
-
- h.fiqm = BitRead(1);
- if (h.fiqm)
- for (int i = 0; i < _countof(h.iqm); i++) {
- h.iqm[i] = (BYTE)BitRead(8);
- }
-
- h.fniqm = BitRead(1);
- if (h.fniqm)
- for (int i = 0; i < _countof(h.niqm); i++) {
- h.niqm[i] = (BYTE)BitRead(8);
- }
-
- __int64 shlen = GetPos() - shpos;
-
- static float ar[] = {
- 1.0000f,1.0000f,0.6735f,0.7031f,0.7615f,0.8055f,0.8437f,0.8935f,
- 0.9157f,0.9815f,1.0255f,1.0695f,1.0950f,1.1575f,1.2015f,1.0000f
- };
-
- h.arx = (int)((float)h.width / ar[h.ar] + 0.5);
- h.ary = h.height;
-
- mpeg_t type = mpeg1;
-
- __int64 shextpos = 0, shextlen = 0;
-
- if (NextMpegStartCode(id, 8) && id == 0xb5) { // sequence header ext
- shextpos = GetPos() - 4;
-
- h.startcodeid = BitRead(4);
- h.profile_levelescape = BitRead(1); // reserved, should be 0
- h.profile = BitRead(3);
- h.level = BitRead(4);
- h.progressive = BitRead(1);
- h.chroma = BitRead(2);
- h.width |= (BitRead(2)<<12);
- h.height |= (BitRead(2)<<12);
- h.bitrate |= (BitRead(12)<<18);
- MARKER;
- h.vbv |= (BitRead(8)<<10);
- h.lowdelay = BitRead(1);
- h.ifps = (DWORD)(h.ifps * (BitRead(2)+1) / (BitRead(5)+1));
-
- shextlen = GetPos() - shextpos;
-
- struct {
- DWORD x, y;
- } ar[] = {{h.width,h.height},{4,3},{16,9},{221,100},{h.width,h.height}};
- int i = min(max(h.ar, 1), 5)-1;
- h.arx = ar[i].x;
- h.ary = ar[i].y;
-
- type = mpeg2;
- }
-
- h.ifps = 10 * h.ifps / 27;
- h.bitrate = h.bitrate == (1<<30)-1 ? 0 : h.bitrate * 400;
-
- DWORD a = h.arx, b = h.ary;
- while (a) {
- DWORD tmp = a;
- a = b % tmp;
- b = tmp;
- }
- if (b) {
- h.arx /= b, h.ary /= b;
- }
-
- if (!pmt) {
- return true;
- }
-
- pmt->majortype = MEDIATYPE_Video;
-
- if (type == mpeg1) {
- pmt->subtype = MEDIASUBTYPE_MPEG1Payload;
- pmt->formattype = FORMAT_MPEGVideo;
- int len = FIELD_OFFSET(MPEG1VIDEOINFO, bSequenceHeader) + int(shlen + shextlen);
- MPEG1VIDEOINFO* vi = (MPEG1VIDEOINFO*)DNew BYTE[len];
- memset(vi, 0, len);
- vi->hdr.dwBitRate = h.bitrate;
- vi->hdr.AvgTimePerFrame = h.ifps;
- vi->hdr.bmiHeader.biSize = sizeof(vi->hdr.bmiHeader);
- vi->hdr.bmiHeader.biWidth = h.width;
- vi->hdr.bmiHeader.biHeight = h.height;
- vi->hdr.bmiHeader.biXPelsPerMeter = h.width * h.ary;
- vi->hdr.bmiHeader.biYPelsPerMeter = h.height * h.arx;
- vi->cbSequenceHeader = DWORD(shlen + shextlen);
- Seek(shpos);
- ByteRead((BYTE*)&vi->bSequenceHeader[0], shlen);
- if (shextpos && shextlen) {
- Seek(shextpos);
- }
- ByteRead((BYTE*)&vi->bSequenceHeader[0] + shlen, shextlen);
- pmt->SetFormat((BYTE*)vi, len);
- delete [] vi;
- } else if (type == mpeg2) {
- pmt->subtype = MEDIASUBTYPE_MPEG2_VIDEO;
- pmt->formattype = FORMAT_MPEG2_VIDEO;
- int len = FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + int(shlen + shextlen);
- MPEG2VIDEOINFO* vi = (MPEG2VIDEOINFO*)DNew BYTE[len];
- memset(vi, 0, len);
- vi->hdr.dwBitRate = h.bitrate;
- vi->hdr.AvgTimePerFrame = h.ifps;
- vi->hdr.dwPictAspectRatioX = h.arx;
- vi->hdr.dwPictAspectRatioY = h.ary;
- vi->hdr.bmiHeader.biSize = sizeof(vi->hdr.bmiHeader);
- vi->hdr.bmiHeader.biWidth = h.width;
- vi->hdr.bmiHeader.biHeight = h.height;
- vi->dwProfile = h.profile;
- vi->dwLevel = h.level;
- vi->cbSequenceHeader = DWORD(shlen + shextlen);
- Seek(shpos);
- ByteRead((BYTE*)&vi->dwSequenceHeader[0], shlen);
- if (shextpos && shextlen) {
- Seek(shextpos);
- }
- ByteRead((BYTE*)&vi->dwSequenceHeader[0] + shlen, shextlen);
- pmt->SetFormat((BYTE*)vi, len);
- delete [] vi;
- } else {
- return false;
- }
-
- return true;
+ __int64 endpos = GetPos() + len; // - sequence header length
+
+ BYTE id = 0;
+
+ while (GetPos() < endpos && id != 0xb3) {
+ if (!NextMpegStartCode(id, len)) {
+ return false;
+ }
+ }
+
+ if (id != 0xb3) {
+ return false;
+ }
+
+ __int64 shpos = GetPos() - 4;
+
+ h.width = (WORD)BitRead(12);
+ h.height = (WORD)BitRead(12);
+ h.ar = BitRead(4);
+ static int ifps[16] = {0, 1126125, 1125000, 1080000, 900900, 900000, 540000, 450450, 450000, 0, 0, 0, 0, 0, 0, 0};
+ h.ifps = ifps[BitRead(4)];
+ h.bitrate = (DWORD)BitRead(18);
+ MARKER;
+ h.vbv = (DWORD)BitRead(10);
+ h.constrained = BitRead(1);
+
+ h.fiqm = BitRead(1);
+ if (h.fiqm)
+ for (int i = 0; i < _countof(h.iqm); i++) {
+ h.iqm[i] = (BYTE)BitRead(8);
+ }
+
+ h.fniqm = BitRead(1);
+ if (h.fniqm)
+ for (int i = 0; i < _countof(h.niqm); i++) {
+ h.niqm[i] = (BYTE)BitRead(8);
+ }
+
+ __int64 shlen = GetPos() - shpos;
+
+ static float ar[] = {
+ 1.0000f, 1.0000f, 0.6735f, 0.7031f, 0.7615f, 0.8055f, 0.8437f, 0.8935f,
+ 0.9157f, 0.9815f, 1.0255f, 1.0695f, 1.0950f, 1.1575f, 1.2015f, 1.0000f
+ };
+
+ h.arx = (int)((float)h.width / ar[h.ar] + 0.5);
+ h.ary = h.height;
+
+ mpeg_t type = mpeg1;
+
+ __int64 shextpos = 0, shextlen = 0;
+
+ if (NextMpegStartCode(id, 8) && id == 0xb5) { // sequence header ext
+ shextpos = GetPos() - 4;
+
+ h.startcodeid = BitRead(4);
+ h.profile_levelescape = BitRead(1); // reserved, should be 0
+ h.profile = BitRead(3);
+ h.level = BitRead(4);
+ h.progressive = BitRead(1);
+ h.chroma = BitRead(2);
+ h.width |= (BitRead(2) << 12);
+ h.height |= (BitRead(2) << 12);
+ h.bitrate |= (BitRead(12) << 18);
+ MARKER;
+ h.vbv |= (BitRead(8) << 10);
+ h.lowdelay = BitRead(1);
+ h.ifps = (DWORD)(h.ifps * (BitRead(2) + 1) / (BitRead(5) + 1));
+
+ shextlen = GetPos() - shextpos;
+
+ struct {
+ DWORD x, y;
+ } ar[] = {{h.width, h.height}, {4, 3}, {16, 9}, {221, 100}, {h.width, h.height}};
+ int i = min(max(h.ar, 1), 5) - 1;
+ h.arx = ar[i].x;
+ h.ary = ar[i].y;
+
+ type = mpeg2;
+ }
+
+ h.ifps = 10 * h.ifps / 27;
+ h.bitrate = h.bitrate == (1 << 30) - 1 ? 0 : h.bitrate * 400;
+
+ DWORD a = h.arx, b = h.ary;
+ while (a) {
+ DWORD tmp = a;
+ a = b % tmp;
+ b = tmp;
+ }
+ if (b) {
+ h.arx /= b, h.ary /= b;
+ }
+
+ if (!pmt) {
+ return true;
+ }
+
+ pmt->majortype = MEDIATYPE_Video;
+
+ if (type == mpeg1) {
+ pmt->subtype = MEDIASUBTYPE_MPEG1Payload;
+ pmt->formattype = FORMAT_MPEGVideo;
+ int len = FIELD_OFFSET(MPEG1VIDEOINFO, bSequenceHeader) + int(shlen + shextlen);
+ MPEG1VIDEOINFO* vi = (MPEG1VIDEOINFO*)DNew BYTE[len];
+ memset(vi, 0, len);
+ vi->hdr.dwBitRate = h.bitrate;
+ vi->hdr.AvgTimePerFrame = h.ifps;
+ vi->hdr.bmiHeader.biSize = sizeof(vi->hdr.bmiHeader);
+ vi->hdr.bmiHeader.biWidth = h.width;
+ vi->hdr.bmiHeader.biHeight = h.height;
+ vi->hdr.bmiHeader.biXPelsPerMeter = h.width * h.ary;
+ vi->hdr.bmiHeader.biYPelsPerMeter = h.height * h.arx;
+ vi->cbSequenceHeader = DWORD(shlen + shextlen);
+ Seek(shpos);
+ ByteRead((BYTE*)&vi->bSequenceHeader[0], shlen);
+ if (shextpos && shextlen) {
+ Seek(shextpos);
+ }
+ ByteRead((BYTE*)&vi->bSequenceHeader[0] + shlen, shextlen);
+ pmt->SetFormat((BYTE*)vi, len);
+ delete [] vi;
+ } else if (type == mpeg2) {
+ pmt->subtype = MEDIASUBTYPE_MPEG2_VIDEO;
+ pmt->formattype = FORMAT_MPEG2_VIDEO;
+ int len = FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + int(shlen + shextlen);
+ MPEG2VIDEOINFO* vi = (MPEG2VIDEOINFO*)DNew BYTE[len];
+ memset(vi, 0, len);
+ vi->hdr.dwBitRate = h.bitrate;
+ vi->hdr.AvgTimePerFrame = h.ifps;
+ vi->hdr.dwPictAspectRatioX = h.arx;
+ vi->hdr.dwPictAspectRatioY = h.ary;
+ vi->hdr.bmiHeader.biSize = sizeof(vi->hdr.bmiHeader);
+ vi->hdr.bmiHeader.biWidth = h.width;
+ vi->hdr.bmiHeader.biHeight = h.height;
+ vi->dwProfile = h.profile;
+ vi->dwLevel = h.level;
+ vi->cbSequenceHeader = DWORD(shlen + shextlen);
+ Seek(shpos);
+ ByteRead((BYTE*)&vi->dwSequenceHeader[0], shlen);
+ if (shextpos && shextlen) {
+ Seek(shextpos);
+ }
+ ByteRead((BYTE*)&vi->dwSequenceHeader[0] + shlen, shextlen);
+ pmt->SetFormat((BYTE*)vi, len);
+ delete [] vi;
+ } else {
+ return false;
+ }
+
+ return true;
}
bool CBaseSplitterFileEx::Read(mpahdr& h, int len, bool fAllowV25, CMediaType* pmt)
{
- memset(&h, 0, sizeof(h));
-
- int syncbits = fAllowV25 ? 11 : 12;
-
- for (; len >= 4 && BitRead(syncbits, true) != (1<<syncbits) - 1; len--) {
- BitRead(8);
- }
-
- if (len < 4) {
- return false;
- }
-
- h.sync = BitRead(11);
- h.version = BitRead(2);
- h.layer = BitRead(2);
- h.crc = BitRead(1);
- h.bitrate = BitRead(4);
- h.freq = BitRead(2);
- h.padding = BitRead(1);
- h.privatebit = BitRead(1);
- h.channels = BitRead(2);
- h.modeext = BitRead(2);
- h.copyright = BitRead(1);
- h.original = BitRead(1);
- h.emphasis = BitRead(2);
-
- if (h.version == 1 || h.layer == 0 || h.freq == 3 || h.bitrate == 15 || h.emphasis == 2) {
- return false;
- }
-
- if (h.version == 3 && h.layer == 2) {
- if ((h.bitrate == 1 || h.bitrate == 2 || h.bitrate == 3 || h.bitrate == 5) && h.channels != 3
- && (h.bitrate >= 11 && h.bitrate <= 14) && h.channels == 3) {
- return false;
- }
- }
-
- h.layer = 4 - h.layer;
-
- //
-
- static int brtbl[][5] = {
- {0,0,0,0,0},
- {32,32,32,32,8},
- {64,48,40,48,16},
- {96,56,48,56,24},
- {128,64,56,64,32},
- {160,80,64,80,40},
- {192,96,80,96,48},
- {224,112,96,112,56},
- {256,128,112,128,64},
- {288,160,128,144,80},
- {320,192,160,160,96},
- {352,224,192,176,112},
- {384,256,224,192,128},
- {416,320,256,224,144},
- {448,384,320,256,160},
- {0,0,0,0,0},
- };
-
- static int brtblcol[][4] = {{0,3,4,4},{0,0,1,2}};
- int bitrate = 1000*brtbl[h.bitrate][brtblcol[h.version&1][h.layer]];
- if (bitrate == 0) {
- return false;
- }
-
- static int freq[][4] = {{11025,0,22050,44100},{12000,0,24000,48000},{8000,0,16000,32000}};
-
- bool l3ext = h.layer == 3 && !(h.version&1);
-
- h.nSamplesPerSec = freq[h.freq][h.version];
- h.FrameSize = h.layer == 1
- ? (12 * bitrate / h.nSamplesPerSec + h.padding) * 4
- : (l3ext ? 72 : 144) * bitrate / h.nSamplesPerSec + h.padding;
- h.rtDuration = 10000000i64 * (h.layer == 1 ? 384 : l3ext ? 576 : 1152) / h.nSamplesPerSec;// / (h.channels == 3 ? 1 : 2);
- h.nBytesPerSec = bitrate / 8;
-
- if (!pmt) {
- return true;
- }
-
- size_t size = h.layer == 3
- ? sizeof(WAVEFORMATEX/*MPEGLAYER3WAVEFORMAT*/) // no need to overcomplicate this...
- : sizeof(MPEG1WAVEFORMAT);
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)DNew BYTE[size];
- memset(wfe, 0, size);
- wfe->cbSize = WORD(size - sizeof(WAVEFORMATEX));
-
- if (h.layer == 3) {
- wfe->wFormatTag = WAVE_FORMAT_MP3;
-
- /* MPEGLAYER3WAVEFORMAT* f = (MPEGLAYER3WAVEFORMAT*)wfe;
- f->wfx.wFormatTag = WAVE_FORMAT_MP3;
- f->wID = MPEGLAYER3_ID_UNKNOWN;
- f->fdwFlags = h.padding ? MPEGLAYER3_FLAG_PADDING_ON : MPEGLAYER3_FLAG_PADDING_OFF; // _OFF or _ISO ?
- */
- } else {
- MPEG1WAVEFORMAT* f = (MPEG1WAVEFORMAT*)wfe;
- f->wfx.wFormatTag = WAVE_FORMAT_MPEG;
- f->fwHeadMode = 1 << h.channels;
- f->fwHeadModeExt = 1 << h.modeext;
- f->wHeadEmphasis = h.emphasis+1;
- if (h.privatebit) {
- f->fwHeadFlags |= ACM_MPEG_PRIVATEBIT;
- }
- if (h.copyright) {
- f->fwHeadFlags |= ACM_MPEG_COPYRIGHT;
- }
- if (h.original) {
- f->fwHeadFlags |= ACM_MPEG_ORIGINALHOME;
- }
- if (h.crc == 0) {
- f->fwHeadFlags |= ACM_MPEG_PROTECTIONBIT;
- }
- if (h.version == 3) {
- f->fwHeadFlags |= ACM_MPEG_ID_MPEG1;
- }
- f->fwHeadLayer = 1 << (h.layer-1);
- f->dwHeadBitrate = bitrate;
- }
-
- wfe->nChannels = h.channels == 3 ? 1 : 2;
- wfe->nSamplesPerSec = h.nSamplesPerSec;
- wfe->nBlockAlign = h.FrameSize;
- wfe->nAvgBytesPerSec = h.nBytesPerSec;
-
- pmt->majortype = MEDIATYPE_Audio;
- pmt->subtype = FOURCCMap(wfe->wFormatTag);
- pmt->formattype = FORMAT_WaveFormatEx;
- pmt->SetFormat((BYTE*)wfe, sizeof(WAVEFORMATEX) + wfe->cbSize);
-
- delete [] wfe;
-
- return true;
+ memset(&h, 0, sizeof(h));
+
+ int syncbits = fAllowV25 ? 11 : 12;
+
+ for (; len >= 4 && BitRead(syncbits, true) != (1 << syncbits) - 1; len--) {
+ BitRead(8);
+ }
+
+ if (len < 4) {
+ return false;
+ }
+
+ h.sync = BitRead(11);
+ h.version = BitRead(2);
+ h.layer = BitRead(2);
+ h.crc = BitRead(1);
+ h.bitrate = BitRead(4);
+ h.freq = BitRead(2);
+ h.padding = BitRead(1);
+ h.privatebit = BitRead(1);
+ h.channels = BitRead(2);
+ h.modeext = BitRead(2);
+ h.copyright = BitRead(1);
+ h.original = BitRead(1);
+ h.emphasis = BitRead(2);
+
+ if (h.version == 1 || h.layer == 0 || h.freq == 3 || h.bitrate == 15 || h.emphasis == 2) {
+ return false;
+ }
+
+ if (h.version == 3 && h.layer == 2) {
+ if ((h.bitrate == 1 || h.bitrate == 2 || h.bitrate == 3 || h.bitrate == 5) && h.channels != 3
+ && (h.bitrate >= 11 && h.bitrate <= 14) && h.channels == 3) {
+ return false;
+ }
+ }
+
+ h.layer = 4 - h.layer;
+
+ //
+
+ static int brtbl[][5] = {
+ {0, 0, 0, 0, 0},
+ {32, 32, 32, 32, 8},
+ {64, 48, 40, 48, 16},
+ {96, 56, 48, 56, 24},
+ {128, 64, 56, 64, 32},
+ {160, 80, 64, 80, 40},
+ {192, 96, 80, 96, 48},
+ {224, 112, 96, 112, 56},
+ {256, 128, 112, 128, 64},
+ {288, 160, 128, 144, 80},
+ {320, 192, 160, 160, 96},
+ {352, 224, 192, 176, 112},
+ {384, 256, 224, 192, 128},
+ {416, 320, 256, 224, 144},
+ {448, 384, 320, 256, 160},
+ {0, 0, 0, 0, 0},
+ };
+
+ static int brtblcol[][4] = {{0, 3, 4, 4}, {0, 0, 1, 2}};
+ int bitrate = 1000 * brtbl[h.bitrate][brtblcol[h.version & 1][h.layer]];
+ if (bitrate == 0) {
+ return false;
+ }
+
+ static int freq[][4] = {{11025, 0, 22050, 44100}, {12000, 0, 24000, 48000}, {8000, 0, 16000, 32000}};
+
+ bool l3ext = h.layer == 3 && !(h.version & 1);
+
+ h.nSamplesPerSec = freq[h.freq][h.version];
+ h.FrameSize = h.layer == 1
+ ? (12 * bitrate / h.nSamplesPerSec + h.padding) * 4
+ : (l3ext ? 72 : 144) * bitrate / h.nSamplesPerSec + h.padding;
+ h.rtDuration = 10000000i64 * (h.layer == 1 ? 384 : l3ext ? 576 : 1152) / h.nSamplesPerSec;// / (h.channels == 3 ? 1 : 2);
+ h.nBytesPerSec = bitrate / 8;
+
+ if (!pmt) {
+ return true;
+ }
+
+ size_t size = h.layer == 3
+ ? sizeof(WAVEFORMATEX/*MPEGLAYER3WAVEFORMAT*/) // no need to overcomplicate this...
+ : sizeof(MPEG1WAVEFORMAT);
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)DNew BYTE[size];
+ memset(wfe, 0, size);
+ wfe->cbSize = WORD(size - sizeof(WAVEFORMATEX));
+
+ if (h.layer == 3) {
+ wfe->wFormatTag = WAVE_FORMAT_MP3;
+
+ /* MPEGLAYER3WAVEFORMAT* f = (MPEGLAYER3WAVEFORMAT*)wfe;
+ f->wfx.wFormatTag = WAVE_FORMAT_MP3;
+ f->wID = MPEGLAYER3_ID_UNKNOWN;
+ f->fdwFlags = h.padding ? MPEGLAYER3_FLAG_PADDING_ON : MPEGLAYER3_FLAG_PADDING_OFF; // _OFF or _ISO ?
+ */
+ } else {
+ MPEG1WAVEFORMAT* f = (MPEG1WAVEFORMAT*)wfe;
+ f->wfx.wFormatTag = WAVE_FORMAT_MPEG;
+ f->fwHeadMode = 1 << h.channels;
+ f->fwHeadModeExt = 1 << h.modeext;
+ f->wHeadEmphasis = h.emphasis + 1;
+ if (h.privatebit) {
+ f->fwHeadFlags |= ACM_MPEG_PRIVATEBIT;
+ }
+ if (h.copyright) {
+ f->fwHeadFlags |= ACM_MPEG_COPYRIGHT;
+ }
+ if (h.original) {
+ f->fwHeadFlags |= ACM_MPEG_ORIGINALHOME;
+ }
+ if (h.crc == 0) {
+ f->fwHeadFlags |= ACM_MPEG_PROTECTIONBIT;
+ }
+ if (h.version == 3) {
+ f->fwHeadFlags |= ACM_MPEG_ID_MPEG1;
+ }
+ f->fwHeadLayer = 1 << (h.layer - 1);
+ f->dwHeadBitrate = bitrate;
+ }
+
+ wfe->nChannels = h.channels == 3 ? 1 : 2;
+ wfe->nSamplesPerSec = h.nSamplesPerSec;
+ wfe->nBlockAlign = h.FrameSize;
+ wfe->nAvgBytesPerSec = h.nBytesPerSec;
+
+ pmt->majortype = MEDIATYPE_Audio;
+ pmt->subtype = FOURCCMap(wfe->wFormatTag);
+ pmt->formattype = FORMAT_WaveFormatEx;
+ pmt->SetFormat((BYTE*)wfe, sizeof(WAVEFORMATEX) + wfe->cbSize);
+
+ delete [] wfe;
+
+ return true;
}
bool CBaseSplitterFileEx::Read(latm_aachdr& h, int len, CMediaType* pmt)
{
- memset(&h, 0, sizeof(h));
+ memset(&h, 0, sizeof(h));
- for (; len >= 3 && BitRead(11, true) != 0x2b7; len--) {
- BitRead(8);
- }
+ for (; len >= 3 && BitRead(11, true) != 0x2b7; len--) {
+ BitRead(8);
+ }
- if (len < 3) {
- return false;
- }
+ if (len < 3) {
+ return false;
+ }
- // Disable AAC latm stream support until make correct header parsing ...
- return true;
+ // Disable AAC latm stream support until make correct header parsing ...
+ return true;
}
bool CBaseSplitterFileEx::Read(aachdr& h, int len, CMediaType* pmt, MPEG_TYPES m_type)
{
- memset(&h, 0, sizeof(h));
-
- __int64 pos = 0;
- int found_fake_sync = m_type == mpeg_ts ? 0 : 1;
-
- for (;;) {
- for (; len >= 7 && BitRead(12, true) != 0xfff; len--) {
- BitRead(8);
- }
-
- if (len < 7) {
- return false;
- }
-
- pos = GetPos();
-
- h.sync = BitRead(12);
- h.version = BitRead(1);
- h.layer = BitRead(2);
- h.fcrc = BitRead(1);
- h.profile = BitRead(2);
- h.freq = BitRead(4);
- h.privatebit = BitRead(1);
- h.channels = BitRead(3);
- h.original = BitRead(1);
- h.home = BitRead(1);
-
- h.copyright_id_bit = BitRead(1);
- h.copyright_id_start = BitRead(1);
- h.aac_frame_length = BitRead(13);
- h.adts_buffer_fullness = BitRead(11);
- h.no_raw_data_blocks_in_frame = BitRead(2);
-
- if (h.fcrc == 0) {
- h.crc = (WORD)BitRead(16);
- }
-
- if (h.layer != 0 || h.freq >= 12 || h.aac_frame_length <= (h.fcrc == 0 ? 9 : 7)) {
- if (found_fake_sync) // skip only one "fake" sync. TODO - find better way to detect and skip "fake" sync
- return false;
- found_fake_sync++;
- Seek(pos + 1);
- len--;
- continue;
- }
-
- h.FrameSize = h.aac_frame_length - (h.fcrc == 0 ? 9 : 7);
- static int freq[] = {96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000};
- h.nBytesPerSec = h.aac_frame_length * freq[h.freq] / 1024; // ok?
- h.rtDuration = 10000000i64 * 1024 / freq[h.freq]; // ok?
-
- if (!pmt) {
- return true;
- }
-
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)DNew BYTE[sizeof(WAVEFORMATEX)+5];
- memset(wfe, 0, sizeof(WAVEFORMATEX)+5);
- wfe->wFormatTag = WAVE_FORMAT_AAC;
- wfe->nChannels = h.channels <= 6 ? h.channels : 2;
- wfe->nSamplesPerSec = freq[h.freq];
- wfe->nBlockAlign = h.aac_frame_length;
- wfe->nAvgBytesPerSec = h.nBytesPerSec;
- wfe->cbSize = MakeAACInitData((BYTE*)(wfe+1), h.profile, wfe->nSamplesPerSec, wfe->nChannels);
-
- pmt->majortype = MEDIATYPE_Audio;
- pmt->subtype = MEDIASUBTYPE_AAC;
- pmt->formattype = FORMAT_WaveFormatEx;
- pmt->SetFormat((BYTE*)wfe, sizeof(WAVEFORMATEX)+wfe->cbSize);
-
- delete [] wfe;
-
- return true;
- }
+ memset(&h, 0, sizeof(h));
+
+ __int64 pos = 0;
+ int found_fake_sync = m_type == mpeg_ts ? 0 : 1;
+
+ for (;;) {
+ for (; len >= 7 && BitRead(12, true) != 0xfff; len--) {
+ BitRead(8);
+ }
+
+ if (len < 7) {
+ return false;
+ }
+
+ pos = GetPos();
+
+ h.sync = BitRead(12);
+ h.version = BitRead(1);
+ h.layer = BitRead(2);
+ h.fcrc = BitRead(1);
+ h.profile = BitRead(2);
+ h.freq = BitRead(4);
+ h.privatebit = BitRead(1);
+ h.channels = BitRead(3);
+ h.original = BitRead(1);
+ h.home = BitRead(1);
+
+ h.copyright_id_bit = BitRead(1);
+ h.copyright_id_start = BitRead(1);
+ h.aac_frame_length = BitRead(13);
+ h.adts_buffer_fullness = BitRead(11);
+ h.no_raw_data_blocks_in_frame = BitRead(2);
+
+ if (h.fcrc == 0) {
+ h.crc = (WORD)BitRead(16);
+ }
+
+ if (h.layer != 0 || h.freq >= 12 || h.aac_frame_length <= (h.fcrc == 0 ? 9 : 7)) {
+ if (found_fake_sync) { // skip only one "fake" sync. TODO - find better way to detect and skip "fake" sync
+ return false;
+ }
+ found_fake_sync++;
+ Seek(pos + 1);
+ len--;
+ continue;
+ }
+
+ h.FrameSize = h.aac_frame_length - (h.fcrc == 0 ? 9 : 7);
+ static int freq[] = {96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000};
+ h.nBytesPerSec = h.aac_frame_length * freq[h.freq] / 1024; // ok?
+ h.rtDuration = 10000000i64 * 1024 / freq[h.freq]; // ok?
+
+ if (!pmt) {
+ return true;
+ }
+
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)DNew BYTE[sizeof(WAVEFORMATEX) + 5];
+ memset(wfe, 0, sizeof(WAVEFORMATEX) + 5);
+ wfe->wFormatTag = WAVE_FORMAT_AAC;
+ wfe->nChannels = h.channels <= 6 ? h.channels : 2;
+ wfe->nSamplesPerSec = freq[h.freq];
+ wfe->nBlockAlign = h.aac_frame_length;
+ wfe->nAvgBytesPerSec = h.nBytesPerSec;
+ wfe->cbSize = MakeAACInitData((BYTE*)(wfe + 1), h.profile, wfe->nSamplesPerSec, wfe->nChannels);
+
+ pmt->majortype = MEDIATYPE_Audio;
+ pmt->subtype = MEDIASUBTYPE_AAC;
+ pmt->formattype = FORMAT_WaveFormatEx;
+ pmt->SetFormat((BYTE*)wfe, sizeof(WAVEFORMATEX) + wfe->cbSize);
+
+ delete [] wfe;
+
+ return true;
+ }
}
bool CBaseSplitterFileEx::Read(ac3hdr& h, int len, CMediaType* pmt, bool find_sync, bool AC3CoreOnly)
{
- static int freq[] = {48000, 44100, 32000, 0};
-
- bool e_ac3 = false;
-
- __int64 startpos = GetPos();
-
- memset(&h, 0, sizeof(h));
-
- // Parse TrueHD and MLP header
- if (!AC3CoreOnly) {
- BYTE buf[20];
- int channels;
- int samplerate;
- int framelength;
- WORD bitdepth;
- bool isTrueHD;
-
- int fsize = 0;
- ByteRead(buf, 20);
-
- fsize = ParseMLPHeader(buf, &samplerate, &channels, &framelength, &bitdepth, &isTrueHD);
- if (fsize) {
-
- if (!pmt) {
- return true;
- }
-
- int bitrate = (int)(fsize * 8i64 * samplerate / framelength); // inaccurate, because fsize is not constant
-
- pmt->majortype = MEDIATYPE_Audio;
- pmt->subtype = isTrueHD ? MEDIASUBTYPE_DOLBY_TRUEHD : MEDIASUBTYPE_MLP;
- pmt->formattype = FORMAT_WaveFormatEx;
-
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
- wfe->wFormatTag = WAVE_FORMAT_UNKNOWN;
- wfe->nChannels = channels;
- wfe->nSamplesPerSec = samplerate;
- wfe->nAvgBytesPerSec = (bitrate + 4) /8;
- wfe->nBlockAlign = fsize < WORD_MAX ? fsize : WORD_MAX;
- wfe->wBitsPerSample = bitdepth;
- wfe->cbSize = 0;
-
- pmt->SetSampleSize(0);
-
- return true;
- }
- }
-
- Seek(startpos);
-
- if (find_sync) {
- for (; len >= 7 && BitRead(16, true) != 0x0b77; len--) {
- BitRead(8);
- }
- }
-
- if (len < 7) {
- return false;
- }
-
- h.sync = (WORD)BitRead(16);
- if (h.sync != 0x0B77) {
- return false;
- }
-
- _int64 pos = GetPos();
- h.crc1 = (WORD)BitRead(16);
- h.fscod = BitRead(2);
- h.frmsizecod = BitRead(6);
- h.bsid = BitRead(5);
- if (h.bsid > 16) {
- return false;
- }
- if (h.bsid <= 10) {
- /* Normal AC-3 */
- if (h.fscod == 3) {
- return false;
- }
- if (h.frmsizecod > 37) {
- return false;
- }
- h.bsmod = BitRead(3);
- h.acmod = BitRead(3);
- if (h.acmod == 2) {
- h.dsurmod = BitRead(2);
- }
- if ((h.acmod & 1) && h.acmod != 1) {
- h.cmixlev = BitRead(2);
- }
- if (h.acmod & 4) {
- h.surmixlev = BitRead(2);
- }
- h.lfeon = BitRead(1);
- h.sr_shift = max(h.bsid, 8) - 8;
- } else {
- /* Enhanced AC-3 */
- e_ac3 = true;
- Seek(pos);
- h.frame_type = (BYTE)BitRead(2);
- h.substreamid = (BYTE)BitRead(3);
- if (h.frame_type || h.substreamid) {
- return false;
- }
- h.frame_size = ((WORD)BitRead(11) + 1) << 1;
- if (h.frame_size < 7) {
- return false;
- }
- h.sr_code = (BYTE)BitRead(2);
- if (h.sr_code == 3) {
- BYTE sr_code2 = (BYTE)BitRead(2);
- if (sr_code2 == 3) {
- return false;
- }
- h.sample_rate = freq[sr_code2] / 2;
- h.sr_shift = 1;
- } else {
- static int eac3_blocks[4] = {1, 2, 3, 6};
- h.num_blocks = eac3_blocks[BitRead(2)];
- h.sample_rate = freq[h.sr_code];
- h.sr_shift = 0;
- }
- h.acmod = BitRead(3);
- h.lfeon = BitRead(1);
- }
-
- if (!pmt) {
- return true;
- }
-
- WAVEFORMATEX wfe;
- memset(&wfe, 0, sizeof(wfe));
- wfe.wFormatTag = WAVE_FORMAT_DOLBY_AC3;
-
- static int channels[] = {2, 1, 2, 3, 3, 4, 4, 5};
- wfe.nChannels = channels[h.acmod] + h.lfeon;
-
- if (!e_ac3) {
- wfe.nSamplesPerSec = freq[h.fscod] >> h.sr_shift;
- static int rate[] = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 512, 576, 640, 768, 896, 1024, 1152, 1280};
- wfe.nAvgBytesPerSec = ((rate[h.frmsizecod>>1] * 1000) >> h.sr_shift) / 8;
- } else {
- wfe.nSamplesPerSec = h.sample_rate;
- wfe.nAvgBytesPerSec = h.frame_size * h.sample_rate / (h.num_blocks * 256);
- }
-
- wfe.nBlockAlign = (WORD)(1536 * wfe.nAvgBytesPerSec / wfe.nSamplesPerSec);
-
- pmt->majortype = MEDIATYPE_Audio;
- if (e_ac3) {
- pmt->subtype = MEDIASUBTYPE_DOLBY_DDPLUS;
- } else {
- pmt->subtype = MEDIASUBTYPE_DOLBY_AC3;
- }
- pmt->formattype = FORMAT_WaveFormatEx;
- pmt->SetFormat((BYTE*)&wfe, sizeof(wfe));
-
- return true;
+ static int freq[] = {48000, 44100, 32000, 0};
+
+ bool e_ac3 = false;
+
+ __int64 startpos = GetPos();
+
+ memset(&h, 0, sizeof(h));
+
+ // Parse TrueHD and MLP header
+ if (!AC3CoreOnly) {
+ BYTE buf[20];
+ int channels;
+ int samplerate;
+ int framelength;
+ WORD bitdepth;
+ bool isTrueHD;
+
+ int fsize = 0;
+ ByteRead(buf, 20);
+
+ fsize = ParseMLPHeader(buf, &samplerate, &channels, &framelength, &bitdepth, &isTrueHD);
+ if (fsize) {
+
+ if (!pmt) {
+ return true;
+ }
+
+ int bitrate = (int)(fsize * 8i64 * samplerate / framelength); // inaccurate, because fsize is not constant
+
+ pmt->majortype = MEDIATYPE_Audio;
+ pmt->subtype = isTrueHD ? MEDIASUBTYPE_DOLBY_TRUEHD : MEDIASUBTYPE_MLP;
+ pmt->formattype = FORMAT_WaveFormatEx;
+
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
+ wfe->wFormatTag = WAVE_FORMAT_UNKNOWN;
+ wfe->nChannels = channels;
+ wfe->nSamplesPerSec = samplerate;
+ wfe->nAvgBytesPerSec = (bitrate + 4) / 8;
+ wfe->nBlockAlign = fsize < WORD_MAX ? fsize : WORD_MAX;
+ wfe->wBitsPerSample = bitdepth;
+ wfe->cbSize = 0;
+
+ pmt->SetSampleSize(0);
+
+ return true;
+ }
+ }
+
+ Seek(startpos);
+
+ if (find_sync) {
+ for (; len >= 7 && BitRead(16, true) != 0x0b77; len--) {
+ BitRead(8);
+ }
+ }
+
+ if (len < 7) {
+ return false;
+ }
+
+ h.sync = (WORD)BitRead(16);
+ if (h.sync != 0x0B77) {
+ return false;
+ }
+
+ _int64 pos = GetPos();
+ h.crc1 = (WORD)BitRead(16);
+ h.fscod = BitRead(2);
+ h.frmsizecod = BitRead(6);
+ h.bsid = BitRead(5);
+ if (h.bsid > 16) {
+ return false;
+ }
+ if (h.bsid <= 10) {
+ /* Normal AC-3 */
+ if (h.fscod == 3) {
+ return false;
+ }
+ if (h.frmsizecod > 37) {
+ return false;
+ }
+ h.bsmod = BitRead(3);
+ h.acmod = BitRead(3);
+ if (h.acmod == 2) {
+ h.dsurmod = BitRead(2);
+ }
+ if ((h.acmod & 1) && h.acmod != 1) {
+ h.cmixlev = BitRead(2);
+ }
+ if (h.acmod & 4) {
+ h.surmixlev = BitRead(2);
+ }
+ h.lfeon = BitRead(1);
+ h.sr_shift = max(h.bsid, 8) - 8;
+ } else {
+ /* Enhanced AC-3 */
+ e_ac3 = true;
+ Seek(pos);
+ h.frame_type = (BYTE)BitRead(2);
+ h.substreamid = (BYTE)BitRead(3);
+ if (h.frame_type || h.substreamid) {
+ return false;
+ }
+ h.frame_size = ((WORD)BitRead(11) + 1) << 1;
+ if (h.frame_size < 7) {
+ return false;
+ }
+ h.sr_code = (BYTE)BitRead(2);
+ if (h.sr_code == 3) {
+ BYTE sr_code2 = (BYTE)BitRead(2);
+ if (sr_code2 == 3) {
+ return false;
+ }
+ h.sample_rate = freq[sr_code2] / 2;
+ h.sr_shift = 1;
+ } else {
+ static int eac3_blocks[4] = {1, 2, 3, 6};
+ h.num_blocks = eac3_blocks[BitRead(2)];
+ h.sample_rate = freq[h.sr_code];
+ h.sr_shift = 0;
+ }
+ h.acmod = BitRead(3);
+ h.lfeon = BitRead(1);
+ }
+
+ if (!pmt) {
+ return true;
+ }
+
+ WAVEFORMATEX wfe;
+ memset(&wfe, 0, sizeof(wfe));
+ wfe.wFormatTag = WAVE_FORMAT_DOLBY_AC3;
+
+ static int channels[] = {2, 1, 2, 3, 3, 4, 4, 5};
+ wfe.nChannels = channels[h.acmod] + h.lfeon;
+
+ if (!e_ac3) {
+ wfe.nSamplesPerSec = freq[h.fscod] >> h.sr_shift;
+ static int rate[] = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 512, 576, 640, 768, 896, 1024, 1152, 1280};
+ wfe.nAvgBytesPerSec = ((rate[h.frmsizecod >> 1] * 1000) >> h.sr_shift) / 8;
+ } else {
+ wfe.nSamplesPerSec = h.sample_rate;
+ wfe.nAvgBytesPerSec = h.frame_size * h.sample_rate / (h.num_blocks * 256);
+ }
+
+ wfe.nBlockAlign = (WORD)(1536 * wfe.nAvgBytesPerSec / wfe.nSamplesPerSec);
+
+ pmt->majortype = MEDIATYPE_Audio;
+ if (e_ac3) {
+ pmt->subtype = MEDIASUBTYPE_DOLBY_DDPLUS;
+ } else {
+ pmt->subtype = MEDIASUBTYPE_DOLBY_AC3;
+ }
+ pmt->formattype = FORMAT_WaveFormatEx;
+ pmt->SetFormat((BYTE*)&wfe, sizeof(wfe));
+
+ return true;
}
bool CBaseSplitterFileEx::Read(dtshdr& h, int len, CMediaType* pmt, bool find_sync)
{
- memset(&h, 0, sizeof(h));
-
- if (find_sync) {
- for (; len >= 10 && BitRead(32, true) != 0x7ffe8001; len--) {
- BitRead(8);
- }
- }
-
- if (len < 10) {
- return false;
- }
-
- h.sync = (DWORD)BitRead(32);
- if (h.sync != 0x7ffe8001) {
- return false;
- }
-
- h.frametype = BitRead(1);
- h.deficitsamplecount = BitRead(5);
- h.fcrc = BitRead(1);
- h.nblocks = BitRead(7)+1;
- h.framebytes = (WORD)BitRead(14)+1;
- h.amode = BitRead(6);
- h.sfreq = BitRead(4);
- h.rate = BitRead(5);
-
- h.downmix = BitRead(1);
- h.dynrange = BitRead(1);
- h.timestamp = BitRead(1);
- h.aux_data = BitRead(1);
- h.hdcd = BitRead(1);
- h.ext_descr = BitRead(3);
- h.ext_coding = BitRead(1);
- h.aspf = BitRead(1);
- h.lfe = BitRead(2);
- h.predictor_history = BitRead(1);
-
-
- if (!pmt) {
- return true;
- }
-
- WAVEFORMATEX wfe;
- memset(&wfe, 0, sizeof(wfe));
- wfe.wFormatTag = WAVE_FORMAT_DVD_DTS;
-
- static int channels[] = {1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8};
-
- if (h.amode < _countof(channels)) {
- wfe.nChannels = channels[h.amode];
- if (h.lfe > 0) {
- ++wfe.nChannels;
- }
- }
-
- static int freq[] = {0,8000,16000,32000,0,0,11025,22050,44100,0,0,12000,24000,48000,0,0};
- wfe.nSamplesPerSec = freq[h.sfreq];
-
- /*static int rate[] = {
- 32000, 56000, 64000, 96000,
- 112000, 128000, 192000, 224000,
- 256000, 320000, 384000, 448000,
- 512000, 576000, 640000, 768000,
- 960000, 1024000, 1152000, 1280000,
- 1344000, 1408000, 1411200, 1472000,
- 1536000, 1920000, 2048000, 3072000,
- 3840000, 0, 0, 0 //open, variable, lossless
- };
- int nom_bitrate = rate[h.rate];*/
-
- unsigned int bitrate = (unsigned int)(8ui64 * h.framebytes * wfe.nSamplesPerSec / (h.nblocks*32));
-
- wfe.nAvgBytesPerSec = (bitrate + 4) / 8;
- wfe.nBlockAlign = h.framebytes;
-
- pmt->majortype = MEDIATYPE_Audio;
- pmt->subtype = MEDIASUBTYPE_DTS;
- pmt->formattype = FORMAT_WaveFormatEx;
- pmt->SetFormat((BYTE*)&wfe, sizeof(wfe));
-
- return true;
+ memset(&h, 0, sizeof(h));
+
+ if (find_sync) {
+ for (; len >= 10 && BitRead(32, true) != 0x7ffe8001; len--) {
+ BitRead(8);
+ }
+ }
+
+ if (len < 10) {
+ return false;
+ }
+
+ h.sync = (DWORD)BitRead(32);
+ if (h.sync != 0x7ffe8001) {
+ return false;
+ }
+
+ h.frametype = BitRead(1);
+ h.deficitsamplecount = BitRead(5);
+ h.fcrc = BitRead(1);
+ h.nblocks = BitRead(7) + 1;
+ h.framebytes = (WORD)BitRead(14) + 1;
+ h.amode = BitRead(6);
+ h.sfreq = BitRead(4);
+ h.rate = BitRead(5);
+
+ h.downmix = BitRead(1);
+ h.dynrange = BitRead(1);
+ h.timestamp = BitRead(1);
+ h.aux_data = BitRead(1);
+ h.hdcd = BitRead(1);
+ h.ext_descr = BitRead(3);
+ h.ext_coding = BitRead(1);
+ h.aspf = BitRead(1);
+ h.lfe = BitRead(2);
+ h.predictor_history = BitRead(1);
+
+
+ if (!pmt) {
+ return true;
+ }
+
+ WAVEFORMATEX wfe;
+ memset(&wfe, 0, sizeof(wfe));
+ wfe.wFormatTag = WAVE_FORMAT_DVD_DTS;
+
+ static int channels[] = {1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8};
+
+ if (h.amode < _countof(channels)) {
+ wfe.nChannels = channels[h.amode];
+ if (h.lfe > 0) {
+ ++wfe.nChannels;
+ }
+ }
+
+ static int freq[] = {0, 8000, 16000, 32000, 0, 0, 11025, 22050, 44100, 0, 0, 12000, 24000, 48000, 0, 0};
+ wfe.nSamplesPerSec = freq[h.sfreq];
+
+ /*static int rate[] = {
+ 32000, 56000, 64000, 96000,
+ 112000, 128000, 192000, 224000,
+ 256000, 320000, 384000, 448000,
+ 512000, 576000, 640000, 768000,
+ 960000, 1024000, 1152000, 1280000,
+ 1344000, 1408000, 1411200, 1472000,
+ 1536000, 1920000, 2048000, 3072000,
+ 3840000, 0, 0, 0 //open, variable, lossless
+ };
+ int nom_bitrate = rate[h.rate];*/
+
+ unsigned int bitrate = (unsigned int)(8ui64 * h.framebytes * wfe.nSamplesPerSec / (h.nblocks * 32));
+
+ wfe.nAvgBytesPerSec = (bitrate + 4) / 8;
+ wfe.nBlockAlign = h.framebytes;
+
+ pmt->majortype = MEDIATYPE_Audio;
+ pmt->subtype = MEDIASUBTYPE_DTS;
+ pmt->formattype = FORMAT_WaveFormatEx;
+ pmt->SetFormat((BYTE*)&wfe, sizeof(wfe));
+
+ return true;
}
bool CBaseSplitterFileEx::Read(lpcmhdr& h, CMediaType* pmt)
{
- memset(&h, 0, sizeof(h));
-
- h.emphasis = BitRead(1);
- h.mute = BitRead(1);
- h.reserved1 = BitRead(1);
- h.framenum = BitRead(5);
- h.quantwordlen = BitRead(2);
- h.freq = BitRead(2);
- h.reserved2 = BitRead(1);
- h.channels = BitRead(3);
- h.drc = (BYTE)BitRead(8);
-
- if (h.quantwordlen == 3 || h.reserved1 || h.reserved2) {
- return false;
- }
-
- if (!pmt) {
- return true;
- }
-
- WAVEFORMATEX wfe;
- memset(&wfe, 0, sizeof(wfe));
- wfe.wFormatTag = WAVE_FORMAT_PCM;
- wfe.nChannels = h.channels+1;
- static int freq[] = {48000, 96000, 44100, 32000};
- wfe.nSamplesPerSec = freq[h.freq];
- switch (h.quantwordlen) {
- case 0:
- wfe.wBitsPerSample = 16;
- break;
- case 1:
- wfe.wBitsPerSample = 20;
- break;
- case 2:
- wfe.wBitsPerSample = 24;
- break;
- }
- wfe.nBlockAlign = (wfe.nChannels*2*wfe.wBitsPerSample) / 8;
- wfe.nAvgBytesPerSec = (wfe.nBlockAlign*wfe.nSamplesPerSec) / 2;
-
- pmt->majortype = MEDIATYPE_Audio;
- pmt->subtype = MEDIASUBTYPE_DVD_LPCM_AUDIO;
- pmt->formattype = FORMAT_WaveFormatEx;
- pmt->SetFormat((BYTE*)&wfe, sizeof(wfe));
-
- return true;
+ memset(&h, 0, sizeof(h));
+
+ h.emphasis = BitRead(1);
+ h.mute = BitRead(1);
+ h.reserved1 = BitRead(1);
+ h.framenum = BitRead(5);
+ h.quantwordlen = BitRead(2);
+ h.freq = BitRead(2);
+ h.reserved2 = BitRead(1);
+ h.channels = BitRead(3);
+ h.drc = (BYTE)BitRead(8);
+
+ if (h.quantwordlen == 3 || h.reserved1 || h.reserved2) {
+ return false;
+ }
+
+ if (!pmt) {
+ return true;
+ }
+
+ WAVEFORMATEX wfe;
+ memset(&wfe, 0, sizeof(wfe));
+ wfe.wFormatTag = WAVE_FORMAT_PCM;
+ wfe.nChannels = h.channels + 1;
+ static int freq[] = {48000, 96000, 44100, 32000};
+ wfe.nSamplesPerSec = freq[h.freq];
+ switch (h.quantwordlen) {
+ case 0:
+ wfe.wBitsPerSample = 16;
+ break;
+ case 1:
+ wfe.wBitsPerSample = 20;
+ break;
+ case 2:
+ wfe.wBitsPerSample = 24;
+ break;
+ }
+ wfe.nBlockAlign = (wfe.nChannels * 2 * wfe.wBitsPerSample) / 8;
+ wfe.nAvgBytesPerSec = (wfe.nBlockAlign * wfe.nSamplesPerSec) / 2;
+
+ pmt->majortype = MEDIATYPE_Audio;
+ pmt->subtype = MEDIASUBTYPE_DVD_LPCM_AUDIO;
+ pmt->formattype = FORMAT_WaveFormatEx;
+ pmt->SetFormat((BYTE*)&wfe, sizeof(wfe));
+
+ return true;
}
bool CBaseSplitterFileEx::Read(dvdalpcmhdr& h, int len, CMediaType* pmt)
{
- memset(&h, 0, sizeof(h));
- if (len < 8) return false;
-
- h.firstaudioframe = (WORD)BitRead(16);// Byte pointer to start of first audio frame.
- h.unknown1 = (BYTE)BitRead(8); // Unknown - e.g. 0x10 for stereo, 0x00 for surround
- if (h.unknown1!= 0x10 && h.unknown1!= 0x00)
- return false; // this is not the aob. maybe this is a vob.
-
- h.bitpersample1 = (BYTE)BitRead(4);
- h.bitpersample2 = (BYTE)BitRead(4);
- h.samplerate1 = (BYTE)BitRead(4);
- h.samplerate2 = (BYTE)BitRead(4);
- h.unknown2 = (BYTE)BitRead(8); // Unknown - e.g. 0x00
- h.groupassignment = (BYTE)BitRead(8); // Channel Group Assignment
- h.unknown3 = (BYTE)BitRead(8); // Unknown - e.g. 0x80
-
- if (h.bitpersample1 > 2 || (h.samplerate1&7) > 2 || h.groupassignment > 20 ||
- h.unknown2 != 0x00 || h.unknown3 != 0x80) {
- return false; // poor parameters or this is a vob.
- }
- // decoder limitations
- if (h.groupassignment > 1 && (h.bitpersample2 != h.bitpersample1 || h.samplerate2 != h.samplerate1)) {
- return false; // decoder does not support different bit depth and frequency.
- }
-
- if (!pmt) {
- return true;
- }
-
- WAVEFORMATEX wfe;
- memset(&wfe, 0, sizeof(wfe));
- wfe.wFormatTag = WAVE_FORMAT_UNKNOWN;
- static const WORD depth[] = {16, 20, 24};
- static const DWORD freq[] = {48000, 96000, 192000, 0, 0, 0, 0, 0, 44100, 88200, 1764000};
- // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
- static const WORD channels1[] = {1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4};
- static const WORD channels2[] = {0, 0, 1, 2, 1, 2, 3, 1, 2, 3, 2, 3, 4, 1, 2, 1, 2, 3, 1, 1, 2};
- wfe.wBitsPerSample = depth[h.bitpersample1];
- wfe.nSamplesPerSec = freq[h.samplerate1];
- wfe.nChannels = channels1[h.groupassignment]+channels2[h.groupassignment];
-
- if (wfe.nChannels > 2) {
- wfe.nBlockAlign = (depth[h.bitpersample1] * channels1[h.groupassignment] * (WORD)(freq[h.samplerate1] / freq[h.samplerate2]) +
- depth[h.bitpersample2] * channels2[h.groupassignment]) * 2 / 8;
- } else {
- wfe.nBlockAlign = depth[h.bitpersample1] * channels1[h.groupassignment] * 2 / 8;
- }
- wfe.nAvgBytesPerSec = wfe.nBlockAlign * wfe.nSamplesPerSec / 2;
-
- pmt->majortype = MEDIATYPE_Audio;
- pmt->subtype = MEDIASUBTYPE_DVD_LPCM_AUDIO;
- pmt->formattype = FORMAT_WaveFormatEx;
- pmt->SetFormat((BYTE*)&wfe, sizeof(wfe));
-
- return true;
+ memset(&h, 0, sizeof(h));
+ if (len < 8) { return false; }
+
+ h.firstaudioframe = (WORD)BitRead(16);// Byte pointer to start of first audio frame.
+ h.unknown1 = (BYTE)BitRead(8); // Unknown - e.g. 0x10 for stereo, 0x00 for surround
+ if (h.unknown1 != 0x10 && h.unknown1 != 0x00) {
+ return false; // this is not the aob. maybe this is a vob.
+ }
+
+ h.bitpersample1 = (BYTE)BitRead(4);
+ h.bitpersample2 = (BYTE)BitRead(4);
+ h.samplerate1 = (BYTE)BitRead(4);
+ h.samplerate2 = (BYTE)BitRead(4);
+ h.unknown2 = (BYTE)BitRead(8); // Unknown - e.g. 0x00
+ h.groupassignment = (BYTE)BitRead(8); // Channel Group Assignment
+ h.unknown3 = (BYTE)BitRead(8); // Unknown - e.g. 0x80
+
+ if (h.bitpersample1 > 2 || (h.samplerate1 & 7) > 2 || h.groupassignment > 20 ||
+ h.unknown2 != 0x00 || h.unknown3 != 0x80) {
+ return false; // poor parameters or this is a vob.
+ }
+ // decoder limitations
+ if (h.groupassignment > 1 && (h.bitpersample2 != h.bitpersample1 || h.samplerate2 != h.samplerate1)) {
+ return false; // decoder does not support different bit depth and frequency.
+ }
+
+ if (!pmt) {
+ return true;
+ }
+
+ WAVEFORMATEX wfe;
+ memset(&wfe, 0, sizeof(wfe));
+ wfe.wFormatTag = WAVE_FORMAT_UNKNOWN;
+ static const WORD depth[] = {16, 20, 24};
+ static const DWORD freq[] = {48000, 96000, 192000, 0, 0, 0, 0, 0, 44100, 88200, 1764000};
+ // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+ static const WORD channels1[] = {1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4};
+ static const WORD channels2[] = {0, 0, 1, 2, 1, 2, 3, 1, 2, 3, 2, 3, 4, 1, 2, 1, 2, 3, 1, 1, 2};
+ wfe.wBitsPerSample = depth[h.bitpersample1];
+ wfe.nSamplesPerSec = freq[h.samplerate1];
+ wfe.nChannels = channels1[h.groupassignment] + channels2[h.groupassignment];
+
+ if (wfe.nChannels > 2) {
+ wfe.nBlockAlign = (depth[h.bitpersample1] * channels1[h.groupassignment] * (WORD)(freq[h.samplerate1] / freq[h.samplerate2]) +
+ depth[h.bitpersample2] * channels2[h.groupassignment]) * 2 / 8;
+ } else {
+ wfe.nBlockAlign = depth[h.bitpersample1] * channels1[h.groupassignment] * 2 / 8;
+ }
+ wfe.nAvgBytesPerSec = wfe.nBlockAlign * wfe.nSamplesPerSec / 2;
+
+ pmt->majortype = MEDIATYPE_Audio;
+ pmt->subtype = MEDIASUBTYPE_DVD_LPCM_AUDIO;
+ pmt->formattype = FORMAT_WaveFormatEx;
+ pmt->SetFormat((BYTE*)&wfe, sizeof(wfe));
+
+ return true;
}
bool CBaseSplitterFileEx::Read(hdmvlpcmhdr& h, CMediaType* pmt)
{
- memset(&h, 0, sizeof(h));
+ memset(&h, 0, sizeof(h));
- h.size = (WORD)BitRead(16);
- h.channels = (BYTE)BitRead(4);
- h.samplerate = (BYTE)BitRead(4);
- h.bitpersample = (BYTE)BitRead(2);
+ h.size = (WORD)BitRead(16);
+ h.channels = (BYTE)BitRead(4);
+ h.samplerate = (BYTE)BitRead(4);
+ h.bitpersample = (BYTE)BitRead(2);
- if (h.channels==0 || h.channels==2 ||
- (h.samplerate != 1 && h.samplerate!= 4 && h.samplerate!= 5) ||
- h.bitpersample<0 || h.bitpersample>3) {
- return false;
- }
+ if (h.channels == 0 || h.channels == 2 ||
+ (h.samplerate != 1 && h.samplerate != 4 && h.samplerate != 5) ||
+ h.bitpersample < 0 || h.bitpersample > 3) {
+ return false;
+ }
- if (!pmt) {
- return true;
- }
+ if (!pmt) {
+ return true;
+ }
- WAVEFORMATEX_HDMV_LPCM wfe;
- wfe.wFormatTag = WAVE_FORMAT_PCM;
+ WAVEFORMATEX_HDMV_LPCM wfe;
+ wfe.wFormatTag = WAVE_FORMAT_PCM;
- static int channels[] = {0, 1, 0, 2, 3, 3, 4, 4, 5, 6, 7, 8};
- wfe.nChannels = channels[h.channels];
- wfe.channel_conf = h.channels;
+ static int channels[] = {0, 1, 0, 2, 3, 3, 4, 4, 5, 6, 7, 8};
+ wfe.nChannels = channels[h.channels];
+ wfe.channel_conf = h.channels;
- static int freq[] = {0, 48000, 0, 0, 96000, 192000};
- wfe.nSamplesPerSec = freq[h.samplerate];
+ static int freq[] = {0, 48000, 0, 0, 96000, 192000};
+ wfe.nSamplesPerSec = freq[h.samplerate];
- static int bitspersample[] = {0, 16, 20, 24};
- wfe.wBitsPerSample = bitspersample[h.bitpersample];
+ static int bitspersample[] = {0, 16, 20, 24};
+ wfe.wBitsPerSample = bitspersample[h.bitpersample];
- wfe.nBlockAlign = wfe.nChannels*wfe.wBitsPerSample>>3;
- wfe.nAvgBytesPerSec = wfe.nBlockAlign*wfe.nSamplesPerSec;
+ wfe.nBlockAlign = wfe.nChannels * wfe.wBitsPerSample >> 3;
+ wfe.nAvgBytesPerSec = wfe.nBlockAlign * wfe.nSamplesPerSec;
- pmt->majortype = MEDIATYPE_Audio;
- pmt->subtype = MEDIASUBTYPE_HDMV_LPCM_AUDIO;
- pmt->formattype = FORMAT_WaveFormatEx;
- pmt->SetFormat((BYTE*)&wfe, sizeof(wfe));
+ pmt->majortype = MEDIATYPE_Audio;
+ pmt->subtype = MEDIASUBTYPE_HDMV_LPCM_AUDIO;
+ pmt->formattype = FORMAT_WaveFormatEx;
+ pmt->SetFormat((BYTE*)&wfe, sizeof(wfe));
- return true;
+ return true;
}
bool CBaseSplitterFileEx::Read(mlphdr& h, int len, CMediaType* pmt, bool find_sync)
{
- memset(&h, 0, sizeof(h));
- if (len < 20) return false;
-
- __int64 startpos = GetPos();
-
- int samplerate, channels, framelength;
- WORD bitdepth;
- bool isTrueHD;
- int fsize = 0;
-
- BYTE buf[20];
- int k = find_sync ? len - 20 : 1;
- int i = 0;
- while (i < k) {
- Seek(startpos+i);
- ByteRead(buf, 20);
- if (GetMLPFrameSize(buf)) {
- fsize = ParseMLPHeader(buf, &samplerate, &channels, &framelength, &bitdepth, &isTrueHD);
- break;
- }
- ++i;
- }
-
- if (fsize && !isTrueHD) {
- h.size = fsize;
-
- if (!pmt) {
- return true;
- }
-
- int bitrate = (int)(fsize * 8i64 * samplerate / framelength); // inaccurate, because fsize is not constant
- pmt->majortype = MEDIATYPE_Audio;
- pmt->subtype = MEDIASUBTYPE_MLP;
- pmt->formattype = FORMAT_WaveFormatEx;
-
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
- wfe->wFormatTag = WAVE_FORMAT_UNKNOWN;
- wfe->nChannels = channels;
- wfe->nSamplesPerSec = samplerate;
- wfe->nAvgBytesPerSec = (bitrate + 4) /8;
- wfe->nBlockAlign = fsize < WORD_MAX ? fsize : WORD_MAX;
- wfe->wBitsPerSample = bitdepth;
- wfe->cbSize = 0;
-
- pmt->SetSampleSize(0);
-
- Seek(startpos+i);
- return true;
- }
-
- return false;
+ memset(&h, 0, sizeof(h));
+ if (len < 20) { return false; }
+
+ __int64 startpos = GetPos();
+
+ int samplerate, channels, framelength;
+ WORD bitdepth;
+ bool isTrueHD;
+ int fsize = 0;
+
+ BYTE buf[20];
+ int k = find_sync ? len - 20 : 1;
+ int i = 0;
+ while (i < k) {
+ Seek(startpos + i);
+ ByteRead(buf, 20);
+ if (GetMLPFrameSize(buf)) {
+ fsize = ParseMLPHeader(buf, &samplerate, &channels, &framelength, &bitdepth, &isTrueHD);
+ break;
+ }
+ ++i;
+ }
+
+ if (fsize && !isTrueHD) {
+ h.size = fsize;
+
+ if (!pmt) {
+ return true;
+ }
+
+ int bitrate = (int)(fsize * 8i64 * samplerate / framelength); // inaccurate, because fsize is not constant
+ pmt->majortype = MEDIATYPE_Audio;
+ pmt->subtype = MEDIASUBTYPE_MLP;
+ pmt->formattype = FORMAT_WaveFormatEx;
+
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
+ wfe->wFormatTag = WAVE_FORMAT_UNKNOWN;
+ wfe->nChannels = channels;
+ wfe->nSamplesPerSec = samplerate;
+ wfe->nAvgBytesPerSec = (bitrate + 4) / 8;
+ wfe->nBlockAlign = fsize < WORD_MAX ? fsize : WORD_MAX;
+ wfe->wBitsPerSample = bitdepth;
+ wfe->cbSize = 0;
+
+ pmt->SetSampleSize(0);
+
+ Seek(startpos + i);
+ return true;
+ }
+
+ return false;
}
bool CBaseSplitterFileEx::Read(dvdspuhdr& h, CMediaType* pmt)
{
- memset(&h, 0, sizeof(h));
+ memset(&h, 0, sizeof(h));
- if (!pmt) {
- return true;
- }
+ if (!pmt) {
+ return true;
+ }
- pmt->majortype = MEDIATYPE_Video;
- pmt->subtype = MEDIASUBTYPE_DVD_SUBPICTURE;
- pmt->formattype = FORMAT_None;
+ pmt->majortype = MEDIATYPE_Video;
+ pmt->subtype = MEDIASUBTYPE_DVD_SUBPICTURE;
+ pmt->formattype = FORMAT_None;
- return true;
+ return true;
}
bool CBaseSplitterFileEx::Read(hdmvsubhdr& h, CMediaType* pmt, const char* language_code)
{
- memset(&h, 0, sizeof(h));
+ memset(&h, 0, sizeof(h));
- if (!pmt) {
- return true;
- }
+ if (!pmt) {
+ return true;
+ }
- pmt->majortype = MEDIATYPE_Subtitle;
- pmt->subtype = MEDIASUBTYPE_HDMVSUB;
- pmt->formattype = FORMAT_None;
+ pmt->majortype = MEDIATYPE_Subtitle;
+ pmt->subtype = MEDIASUBTYPE_HDMVSUB;
+ pmt->formattype = FORMAT_None;
- SUBTITLEINFO* psi = (SUBTITLEINFO*)pmt->AllocFormatBuffer(sizeof(SUBTITLEINFO));
- if (psi) {
- memset(psi, 0, pmt->FormatLength());
- strcpy_s(psi->IsoLang, language_code ? language_code : "eng");
- }
+ SUBTITLEINFO* psi = (SUBTITLEINFO*)pmt->AllocFormatBuffer(sizeof(SUBTITLEINFO));
+ if (psi) {
+ memset(psi, 0, pmt->FormatLength());
+ strcpy_s(psi->IsoLang, language_code ? language_code : "eng");
+ }
- return true;
+ return true;
}
bool CBaseSplitterFileEx::Read(svcdspuhdr& h, CMediaType* pmt)
{
- memset(&h, 0, sizeof(h));
+ memset(&h, 0, sizeof(h));
- if (!pmt) {
- return true;
- }
+ if (!pmt) {
+ return true;
+ }
- pmt->majortype = MEDIATYPE_Video;
- pmt->subtype = MEDIASUBTYPE_SVCD_SUBPICTURE;
- pmt->formattype = FORMAT_None;
+ pmt->majortype = MEDIATYPE_Video;
+ pmt->subtype = MEDIASUBTYPE_SVCD_SUBPICTURE;
+ pmt->formattype = FORMAT_None;
- return true;
+ return true;
}
bool CBaseSplitterFileEx::Read(cvdspuhdr& h, CMediaType* pmt)
{
- memset(&h, 0, sizeof(h));
+ memset(&h, 0, sizeof(h));
- if (!pmt) {
- return true;
- }
+ if (!pmt) {
+ return true;
+ }
- pmt->majortype = MEDIATYPE_Video;
- pmt->subtype = MEDIASUBTYPE_CVD_SUBPICTURE;
- pmt->formattype = FORMAT_None;
+ pmt->majortype = MEDIATYPE_Video;
+ pmt->subtype = MEDIASUBTYPE_CVD_SUBPICTURE;
+ pmt->formattype = FORMAT_None;
- return true;
+ return true;
}
bool CBaseSplitterFileEx::Read(ps2audhdr& h, CMediaType* pmt)
{
- memset(&h, 0, sizeof(h));
-
- if (BitRead(16, true) != 'SS') {
- return false;
- }
-
- __int64 pos = GetPos();
-
- while (BitRead(16, true) == 'SS') {
- DWORD tag = (DWORD)BitRead(32, true);
- DWORD size = 0;
-
- if (tag == 'SShd') {
- BitRead(32);
- ByteRead((BYTE*)&size, sizeof(size));
- ASSERT(size == 0x18);
- Seek(GetPos());
- ByteRead((BYTE*)&h, sizeof(h));
- } else if (tag == 'SSbd') {
- BitRead(32);
- ByteRead((BYTE*)&size, sizeof(size));
- break;
- }
- }
-
- Seek(pos);
-
- if (!pmt) {
- return true;
- }
-
- WAVEFORMATEXPS2 wfe;
- wfe.wFormatTag =
- h.unk1 == 0x01 ? WAVE_FORMAT_PS2_PCM :
- h.unk1 == 0x10 ? WAVE_FORMAT_PS2_ADPCM :
- WAVE_FORMAT_UNKNOWN;
- wfe.nChannels = (WORD)h.channels;
- wfe.nSamplesPerSec = h.freq;
- wfe.wBitsPerSample = 16; // always?
- wfe.nBlockAlign = wfe.nChannels*wfe.wBitsPerSample>>3;
- wfe.nAvgBytesPerSec = wfe.nBlockAlign*wfe.nSamplesPerSec;
- wfe.dwInterleave = h.interleave;
-
- pmt->majortype = MEDIATYPE_Audio;
- pmt->subtype = FOURCCMap(wfe.wFormatTag);
- pmt->formattype = FORMAT_WaveFormatEx;
- pmt->SetFormat((BYTE*)&wfe, sizeof(wfe));
-
- return true;
+ memset(&h, 0, sizeof(h));
+
+ if (BitRead(16, true) != 'SS') {
+ return false;
+ }
+
+ __int64 pos = GetPos();
+
+ while (BitRead(16, true) == 'SS') {
+ DWORD tag = (DWORD)BitRead(32, true);
+ DWORD size = 0;
+
+ if (tag == 'SShd') {
+ BitRead(32);
+ ByteRead((BYTE*)&size, sizeof(size));
+ ASSERT(size == 0x18);
+ Seek(GetPos());
+ ByteRead((BYTE*)&h, sizeof(h));
+ } else if (tag == 'SSbd') {
+ BitRead(32);
+ ByteRead((BYTE*)&size, sizeof(size));
+ break;
+ }
+ }
+
+ Seek(pos);
+
+ if (!pmt) {
+ return true;
+ }
+
+ WAVEFORMATEXPS2 wfe;
+ wfe.wFormatTag =
+ h.unk1 == 0x01 ? WAVE_FORMAT_PS2_PCM :
+ h.unk1 == 0x10 ? WAVE_FORMAT_PS2_ADPCM :
+ WAVE_FORMAT_UNKNOWN;
+ wfe.nChannels = (WORD)h.channels;
+ wfe.nSamplesPerSec = h.freq;
+ wfe.wBitsPerSample = 16; // always?
+ wfe.nBlockAlign = wfe.nChannels * wfe.wBitsPerSample >> 3;
+ wfe.nAvgBytesPerSec = wfe.nBlockAlign * wfe.nSamplesPerSec;
+ wfe.dwInterleave = h.interleave;
+
+ pmt->majortype = MEDIATYPE_Audio;
+ pmt->subtype = FOURCCMap(wfe.wFormatTag);
+ pmt->formattype = FORMAT_WaveFormatEx;
+ pmt->SetFormat((BYTE*)&wfe, sizeof(wfe));
+
+ return true;
}
bool CBaseSplitterFileEx::Read(ps2subhdr& h, CMediaType* pmt)
{
- memset(&h, 0, sizeof(h));
+ memset(&h, 0, sizeof(h));
- if (!pmt) {
- return true;
- }
+ if (!pmt) {
+ return true;
+ }
- pmt->majortype = MEDIATYPE_Subtitle;
- pmt->subtype = MEDIASUBTYPE_PS2_SUB;
- pmt->formattype = FORMAT_None;
+ pmt->majortype = MEDIATYPE_Subtitle;
+ pmt->subtype = MEDIASUBTYPE_PS2_SUB;
+ pmt->formattype = FORMAT_None;
- return true;
+ return true;
}
bool CBaseSplitterFileEx::Read(trhdr& h, bool fSync)
{
- memset(&h, 0, sizeof(h));
-
- BitByteAlign();
-
- if (m_tslen == 0) {
- __int64 pos = GetPos();
- int count = 0;
-
- for (int i = 0; i < 192; i++) {
- if (BitRead(8, true) == 0x47) {
- __int64 pos = GetPos();
- Seek(pos + 188);
- if (BitRead(8, true) == 0x47) {
- if (m_tslen != 188) {
- count = 0;
- }
- m_tslen = 188; // TS stream
- if (count > 1) {
- break;
- }
- count++;
- } else {
- Seek(pos + 192);
- if (BitRead(8, true) == 0x47) {
- if (m_tslen != 192) {
- count = 0;
- }
- m_tslen = 192; // M2TS stream
- if (count > 1) {
- break;
- }
- count++;
- }
- }
- } else {
- BitRead(8);
- }
- }
-
- Seek(pos);
-
- if (m_tslen == 0) {
- return false;
- }
- }
-
- if (fSync) {
- for (int i = 0; i < m_tslen; i++) {
- if (BitRead(8, true) == 0x47) {
- if (i == 0) {
- break;
- }
- Seek(GetPos()+m_tslen);
- if (BitRead(8, true) == 0x47) {
- Seek(GetPos()-m_tslen);
- break;
- }
- }
-
- BitRead(8);
-
- if (i == m_tslen-1) {
- return false;
- }
- }
- }
-
- if (BitRead(8, true) != 0x47) {
- return false;
- }
-
- h.next = GetPos() + m_tslen;
-
- h.sync = (BYTE)BitRead(8);
- h.error = BitRead(1);
- h.payloadstart = BitRead(1);
- h.transportpriority = BitRead(1);
- h.pid = BitRead(13);
- h.scrambling = BitRead(2);
- h.adapfield = BitRead(1);
- h.payload = BitRead(1);
- h.counter = BitRead(4);
-
- h.bytes = 188 - 4;
-
- if (h.adapfield) {
- h.length = (BYTE)BitRead(8);
-
- if (h.length > 0) {
- h.discontinuity = BitRead(1);
- h.randomaccess = BitRead(1);
- h.priority = BitRead(1);
- h.fPCR = BitRead(1);
- h.OPCR = BitRead(1);
- h.splicingpoint = BitRead(1);
- h.privatedata = BitRead(1);
- h.extension = BitRead(1);
-
- int i = 1;
-
- if (h.fPCR && h.length>6) {
- h.PCR = BitRead(33);
- BitRead(6);
- UINT64 PCRExt = BitRead(9);
- h.PCR = (h.PCR*300 + PCRExt) * 10 / 27;
- i += 6;
- }
-
- h.length = min(h.length, h.bytes-1);
- for (; i < h.length; i++) {
- BitRead(8);
- }
- }
-
- h.bytes -= h.length+1;
-
- if (h.bytes < 0) {
- ASSERT(0);
- return false;
- }
- }
- return true;
+ memset(&h, 0, sizeof(h));
+
+ BitByteAlign();
+
+ if (m_tslen == 0) {
+ __int64 pos = GetPos();
+ int count = 0;
+
+ for (int i = 0; i < 192; i++) {
+ if (BitRead(8, true) == 0x47) {
+ __int64 pos = GetPos();
+ Seek(pos + 188);
+ if (BitRead(8, true) == 0x47) {
+ if (m_tslen != 188) {
+ count = 0;
+ }
+ m_tslen = 188; // TS stream
+ if (count > 1) {
+ break;
+ }
+ count++;
+ } else {
+ Seek(pos + 192);
+ if (BitRead(8, true) == 0x47) {
+ if (m_tslen != 192) {
+ count = 0;
+ }
+ m_tslen = 192; // M2TS stream
+ if (count > 1) {
+ break;
+ }
+ count++;
+ }
+ }
+ } else {
+ BitRead(8);
+ }
+ }
+
+ Seek(pos);
+
+ if (m_tslen == 0) {
+ return false;
+ }
+ }
+
+ if (fSync) {
+ for (int i = 0; i < m_tslen; i++) {
+ if (BitRead(8, true) == 0x47) {
+ if (i == 0) {
+ break;
+ }
+ Seek(GetPos() + m_tslen);
+ if (BitRead(8, true) == 0x47) {
+ Seek(GetPos() - m_tslen);
+ break;
+ }
+ }
+
+ BitRead(8);
+
+ if (i == m_tslen - 1) {
+ return false;
+ }
+ }
+ }
+
+ if (BitRead(8, true) != 0x47) {
+ return false;
+ }
+
+ h.next = GetPos() + m_tslen;
+
+ h.sync = (BYTE)BitRead(8);
+ h.error = BitRead(1);
+ h.payloadstart = BitRead(1);
+ h.transportpriority = BitRead(1);
+ h.pid = BitRead(13);
+ h.scrambling = BitRead(2);
+ h.adapfield = BitRead(1);
+ h.payload = BitRead(1);
+ h.counter = BitRead(4);
+
+ h.bytes = 188 - 4;
+
+ if (h.adapfield) {
+ h.length = (BYTE)BitRead(8);
+
+ if (h.length > 0) {
+ h.discontinuity = BitRead(1);
+ h.randomaccess = BitRead(1);
+ h.priority = BitRead(1);
+ h.fPCR = BitRead(1);
+ h.OPCR = BitRead(1);
+ h.splicingpoint = BitRead(1);
+ h.privatedata = BitRead(1);
+ h.extension = BitRead(1);
+
+ int i = 1;
+
+ if (h.fPCR && h.length > 6) {
+ h.PCR = BitRead(33);
+ BitRead(6);
+ UINT64 PCRExt = BitRead(9);
+ h.PCR = (h.PCR * 300 + PCRExt) * 10 / 27;
+ i += 6;
+ }
+
+ h.length = min(h.length, h.bytes - 1);
+ for (; i < h.length; i++) {
+ BitRead(8);
+ }
+ }
+
+ h.bytes -= h.length + 1;
+
+ if (h.bytes < 0) {
+ ASSERT(0);
+ return false;
+ }
+ }
+ return true;
}
bool CBaseSplitterFileEx::Read(trsechdr& h)
{
- memset(&h, 0, sizeof(h));
-
- BYTE pointer_field = (BYTE)BitRead(8);
- while (pointer_field-- > 0) {
- BitRead(8);
- }
- h.table_id = (BYTE)BitRead(8);
- h.section_syntax_indicator = (WORD)BitRead(1);
- h.zero = (WORD)BitRead(1);
- h.reserved1 = (WORD)BitRead(2);
- h.section_length = (WORD)BitRead(12);
- h.transport_stream_id = (WORD)BitRead(16);
- h.reserved2 = (BYTE)BitRead(2);
- h.version_number = (BYTE)BitRead(5);
- h.current_next_indicator = (BYTE)BitRead(1);
- h.section_number = (BYTE)BitRead(8);
- h.last_section_number = (BYTE)BitRead(8);
-
- return h.section_syntax_indicator == 1 && h.zero == 0;
+ memset(&h, 0, sizeof(h));
+
+ BYTE pointer_field = (BYTE)BitRead(8);
+ while (pointer_field-- > 0) {
+ BitRead(8);
+ }
+ h.table_id = (BYTE)BitRead(8);
+ h.section_syntax_indicator = (WORD)BitRead(1);
+ h.zero = (WORD)BitRead(1);
+ h.reserved1 = (WORD)BitRead(2);
+ h.section_length = (WORD)BitRead(12);
+ h.transport_stream_id = (WORD)BitRead(16);
+ h.reserved2 = (BYTE)BitRead(2);
+ h.version_number = (BYTE)BitRead(5);
+ h.current_next_indicator = (BYTE)BitRead(1);
+ h.section_number = (BYTE)BitRead(8);
+ h.last_section_number = (BYTE)BitRead(8);
+
+ return h.section_syntax_indicator == 1 && h.zero == 0;
}
bool CBaseSplitterFileEx::Read(pvahdr& h, bool fSync)
{
- memset(&h, 0, sizeof(h));
-
- BitByteAlign();
-
- if (fSync) {
- for (int i = 0; i < 65536; i++) {
- if ((BitRead(64, true)&0xfffffc00ffe00000i64) == 0x4156000055000000i64) {
- break;
- }
- BitRead(8);
- }
- }
-
- if ((BitRead(64, true)&0xfffffc00ffe00000i64) != 0x4156000055000000i64) {
- return false;
- }
-
- h.sync = (WORD)BitRead(16);
- h.streamid = (BYTE)BitRead(8);
- h.counter = (BYTE)BitRead(8);
- h.res1 = (BYTE)BitRead(8);
- h.res2 = BitRead(3);
- h.fpts = BitRead(1);
- h.postbytes = BitRead(2);
- h.prebytes = BitRead(2);
- h.length = (WORD)BitRead(16);
-
- if (h.length > 6136) {
- return false;
- }
-
- __int64 pos = GetPos();
-
- if (h.streamid == 1 && h.fpts) {
- h.pts = 10000*BitRead(32)/90 + m_rtPTSOffset;
- } else if (h.streamid == 2 && (h.fpts || (BitRead(32, true)&0xffffffe0) == 0x000001c0)) {
- BYTE b;
- if (!NextMpegStartCode(b, 4)) {
- return false;
- }
- peshdr h2;
- if (!Read(h2, b)) {
- return false;
- }
- // Maybe bug, code before: if (h.fpts = h2.fpts) h.pts = h2.pts;
- h.fpts = h2.fpts;
- if (h.fpts) {
- h.pts = h2.pts;
- }
- }
-
- BitRead(8*h.prebytes);
-
- h.length -= (WORD)(GetPos() - pos);
-
- return true;
+ memset(&h, 0, sizeof(h));
+
+ BitByteAlign();
+
+ if (fSync) {
+ for (int i = 0; i < 65536; i++) {
+ if ((BitRead(64, true) & 0xfffffc00ffe00000i64) == 0x4156000055000000i64) {
+ break;
+ }
+ BitRead(8);
+ }
+ }
+
+ if ((BitRead(64, true) & 0xfffffc00ffe00000i64) != 0x4156000055000000i64) {
+ return false;
+ }
+
+ h.sync = (WORD)BitRead(16);
+ h.streamid = (BYTE)BitRead(8);
+ h.counter = (BYTE)BitRead(8);
+ h.res1 = (BYTE)BitRead(8);
+ h.res2 = BitRead(3);
+ h.fpts = BitRead(1);
+ h.postbytes = BitRead(2);
+ h.prebytes = BitRead(2);
+ h.length = (WORD)BitRead(16);
+
+ if (h.length > 6136) {
+ return false;
+ }
+
+ __int64 pos = GetPos();
+
+ if (h.streamid == 1 && h.fpts) {
+ h.pts = 10000 * BitRead(32) / 90 + m_rtPTSOffset;
+ } else if (h.streamid == 2 && (h.fpts || (BitRead(32, true) & 0xffffffe0) == 0x000001c0)) {
+ BYTE b;
+ if (!NextMpegStartCode(b, 4)) {
+ return false;
+ }
+ peshdr h2;
+ if (!Read(h2, b)) {
+ return false;
+ }
+ // Maybe bug, code before: if (h.fpts = h2.fpts) h.pts = h2.pts;
+ h.fpts = h2.fpts;
+ if (h.fpts) {
+ h.pts = h2.pts;
+ }
+ }
+
+ BitRead(8 * h.prebytes);
+
+ h.length -= (WORD)(GetPos() - pos);
+
+ return true;
}
int CBaseSplitterFileEx::HrdParameters(CGolombBuffer& gb)
{
- UINT64 cnt = gb.UExpGolombRead(); // cpb_cnt_minus1
- if (cnt > 32U)
- return -1;
- gb.BitRead(4); // bit_rate_scale
- gb.BitRead(4); // cpb_size_scale
-
- for (unsigned int i = 0; i <= cnt; i++ ) {
- gb.UExpGolombRead(); // bit_rate_value_minus1
- gb.UExpGolombRead(); // cpb_size_value_minus1
- gb.BitRead(1); // cbr_flag
- }
-
- gb.BitRead(5); // initial_cpb_removal_delay_length_minus1
- gb.BitRead(5); // cpb_removal_delay_length_minus1
- gb.BitRead(5); // dpb_output_delay_length_minus1
- gb.BitRead(5); // time_offset_length
-
- return 0;
+ UINT64 cnt = gb.UExpGolombRead(); // cpb_cnt_minus1
+ if (cnt > 32U) {
+ return -1;
+ }
+ gb.BitRead(4); // bit_rate_scale
+ gb.BitRead(4); // cpb_size_scale
+
+ for (unsigned int i = 0; i <= cnt; i++) {
+ gb.UExpGolombRead(); // bit_rate_value_minus1
+ gb.UExpGolombRead(); // cpb_size_value_minus1
+ gb.BitRead(1); // cbr_flag
+ }
+
+ gb.BitRead(5); // initial_cpb_removal_delay_length_minus1
+ gb.BitRead(5); // cpb_removal_delay_length_minus1
+ gb.BitRead(5); // dpb_output_delay_length_minus1
+ gb.BitRead(5); // time_offset_length
+
+ return 0;
}
void CBaseSplitterFileEx::RemoveMpegEscapeCode(BYTE* dst, BYTE* src, int length)
{
- int si=0;
- int di=0;
- while (si+2<length) {
- //remove escapes (very rare 1:2^22)
- if (src[si+2]>3) {
- dst[di++]= src[si++];
- dst[di++]= src[si++];
- } else if (src[si]==0 && src[si+1]==0) {
- if (src[si+2]==3) { //escape
- dst[di++]= 0;
- dst[di++]= 0;
- si+=3;
- continue;
- } else { //next start code
- return;
- }
- }
-
- dst[di++]= src[si++];
- }
+ int si = 0;
+ int di = 0;
+ while (si + 2 < length) {
+ //remove escapes (very rare 1:2^22)
+ if (src[si + 2] > 3) {
+ dst[di++] = src[si++];
+ dst[di++] = src[si++];
+ } else if (src[si] == 0 && src[si + 1] == 0) {
+ if (src[si + 2] == 3) { //escape
+ dst[di++] = 0;
+ dst[di++] = 0;
+ si += 3;
+ continue;
+ } else { //next start code
+ return;
+ }
+ }
+
+ dst[di++] = src[si++];
+ }
}
bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt)
{
- __int64 endpos = GetPos() + len;
- __int64 nalstartpos = GetPos();
- //__int64 nalendpos;
- bool repeat = false;
-
- // First try search for the start code
- DWORD _dwStartCode = (DWORD)BitRead(32, true);
- while (GetPos() < endpos+4 &&
- (_dwStartCode & 0xFFFFFF1F) != 0x101 && // Coded slide of a non-IDR
- (_dwStartCode & 0xFFFFFF1F) != 0x105 && // Coded slide of an IDR
- (_dwStartCode & 0xFFFFFF1F) != 0x107 && // Sequence Parameter Set
- (_dwStartCode & 0xFFFFFF1F) != 0x108 && // Picture Parameter Set
- (_dwStartCode & 0xFFFFFF1F) != 0x109 && // Access Unit Delimiter
- (_dwStartCode & 0xFFFFFF1F) != 0x10f // Subset Sequence Parameter Set (MVC)
- ) {
- BitRead(8);
- _dwStartCode = (DWORD)BitRead(32, true);
- }
- if (GetPos() >= endpos+4) {
- return false;
- }
-
- // At least a SPS (normal or subset) and a PPS is required
- while (GetPos() < endpos+4 && (!(h.spspps[index_sps].complete || h.spspps[index_subsetsps].complete) || !h.spspps[index_pps1].complete || repeat))
- {
- BYTE id = h.lastid;
- repeat = false;
-
- // Get array index from NAL unit type
- spsppsindex index = index_unknown;
-
- if ((id&0x60) != 0) {
- if ((id&0x9f) == 0x07) {
- index = index_sps;
- } else if ((id&0x9f) == 0x0F) {
- index = index_subsetsps;
- } else if ((id&0x9f) == 0x08) {
- index = h.spspps[index_pps1].complete ? index_pps2 : index_pps1;
- }
- }
-
- // Search for next start code
- DWORD dwStartCode = (DWORD)BitRead(32, true);
- while (GetPos() < endpos+4 && (dwStartCode != 0x00000001) && (dwStartCode & 0xFFFFFF00) != 0x00000100) {
- BitRead(8);
- dwStartCode = (DWORD)BitRead(32, true);
- }
-
- //nalendpos = GetPos();
-
- // Skip start code
- __int64 pos;
- if (GetPos() < endpos+4) {
- if (dwStartCode == 0x00000001)
- BitRead(32);
- else
- BitRead(24);
-
- pos = GetPos();
- h.lastid = (BYTE)BitRead(8);
- } else {
- pos = GetPos()-4;
- }
-
- // The SPS or PPS might be fragmented, copy data into buffer until NAL is complete
- if (index >= 0) {
- if (h.spspps[index].complete) {
- // Don't handle SPS/PPS twice
- continue;
- } else if (pos > nalstartpos) {
- // Copy into buffer
- Seek(nalstartpos);
- unsigned int bufsize = _countof(h.spspps[index].buffer);
- int len = min(int(bufsize - h.spspps[index].size), int(pos - nalstartpos));
- ByteRead(h.spspps[index].buffer+h.spspps[index].size, len);
- Seek(pos);
- h.spspps[index].size += len;
-
- //ASSERT(h.spspps[index].size < bufsize); // disable for better debug ...
-
- if (h.spspps[index].size >= bufsize || dwStartCode == 0x00000001 || (dwStartCode & 0xFFFFFF00) == 0x00000100) {
- if (Read(h, index)) {
- h.spspps[index].complete = true;
- h.spspps[index].size -= 4;
- } else {
- h.spspps[index].size = 0;
- }
- }
-
- repeat = true;
- }
- }
-
- nalstartpos = pos;
- }
-
- // Exit and wait for next packet if there is no SPS and PPS yet
- if ((!h.spspps[index_sps].complete && !h.spspps[index_subsetsps].complete) || !h.spspps[index_pps1].complete || repeat) {
-
- return false;
- }
-
- if (!pmt) {
- return true;
- }
-
- {
- // Calculate size of extra data
- int extra = 0;
- for (int i = 0; i < 4; i++) {
- if (h.spspps[i].complete)
- extra += 2+(h.spspps[i].size);
- }
-
- pmt->majortype = MEDIATYPE_Video;
- if (h.spspps[index_subsetsps].complete && !h.spspps[index_sps].complete) {
- pmt->subtype = FOURCCMap('CVME'); // MVC stream without base view
- } else if (h.spspps[index_subsetsps].complete && h.spspps[index_sps].complete) {
- pmt->subtype = FOURCCMap('CVMA'); // MVC stream with base view
- } else {
- pmt->subtype = FOURCCMap('1CVA'); // AVC stream
- }
- //pmt->subtype = MEDIASUBTYPE_H264; // TODO : put MEDIASUBTYPE_H264 to support Windows 7 decoder !
- pmt->formattype = FORMAT_MPEG2_VIDEO;
- int len = FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + extra;
- MPEG2VIDEOINFO* vi = (MPEG2VIDEOINFO*)DNew BYTE[len];
- memset(vi, 0, len);
- // vi->hdr.dwBitRate = ;
- vi->hdr.AvgTimePerFrame = h.AvgTimePerFrame;
- if (!h.sar.num) h.sar.num = 1;
- if (!h.sar.den) h.sar.den = 1;
- CSize aspect(h.width * h.sar.num, h.height * h.sar.den);
- int lnko = LNKO(aspect.cx, aspect.cy);
- if (lnko > 1) {
- aspect.cx /= lnko, aspect.cy /= lnko;
- }
-
- if (aspect.cx * 2 < aspect.cy) {
- delete[] vi;
- return false;
- }
-
- vi->hdr.dwPictAspectRatioX = aspect.cx;
- vi->hdr.dwPictAspectRatioY = aspect.cy;
- vi->hdr.bmiHeader.biSize = sizeof(vi->hdr.bmiHeader);
- vi->hdr.bmiHeader.biWidth = h.width;
- vi->hdr.bmiHeader.biHeight = h.height;
- if (h.spspps[index_subsetsps].complete && !h.spspps[index_sps].complete) {
- vi->hdr.bmiHeader.biCompression = 'CVME';
- } else if (h.spspps[index_subsetsps].complete && h.spspps[index_sps].complete) {
- vi->hdr.bmiHeader.biCompression = 'CVMA';
- } else {
- vi->hdr.bmiHeader.biCompression = '1CVA';
- }
- vi->dwProfile = h.profile;
- vi->dwFlags = 4; // ?
- vi->dwLevel = h.level;
- vi->cbSequenceHeader = extra;
-
- // Copy extra data
- BYTE* p = (BYTE*)&vi->dwSequenceHeader[0];
- for (int i = 0; i < 4; i++) {
- if (h.spspps[i].complete) {
- *p++ = (h.spspps[i].size) >> 8;
- *p++ = (h.spspps[i].size) & 0xff;
- memcpy(p, h.spspps[i].buffer, h.spspps[i].size);
- p += h.spspps[i].size;
- }
- }
-
- pmt->SetFormat((BYTE*)vi, len);
- delete [] vi;
- }
-
- return true;
+ __int64 endpos = GetPos() + len;
+ __int64 nalstartpos = GetPos();
+ //__int64 nalendpos;
+ bool repeat = false;
+
+ // First try search for the start code
+ DWORD _dwStartCode = (DWORD)BitRead(32, true);
+ while (GetPos() < endpos + 4 &&
+ (_dwStartCode & 0xFFFFFF1F) != 0x101 && // Coded slide of a non-IDR
+ (_dwStartCode & 0xFFFFFF1F) != 0x105 && // Coded slide of an IDR
+ (_dwStartCode & 0xFFFFFF1F) != 0x107 && // Sequence Parameter Set
+ (_dwStartCode & 0xFFFFFF1F) != 0x108 && // Picture Parameter Set
+ (_dwStartCode & 0xFFFFFF1F) != 0x109 && // Access Unit Delimiter
+ (_dwStartCode & 0xFFFFFF1F) != 0x10f // Subset Sequence Parameter Set (MVC)
+ ) {
+ BitRead(8);
+ _dwStartCode = (DWORD)BitRead(32, true);
+ }
+ if (GetPos() >= endpos + 4) {
+ return false;
+ }
+
+ // At least a SPS (normal or subset) and a PPS is required
+ while (GetPos() < endpos + 4 && (!(h.spspps[index_sps].complete || h.spspps[index_subsetsps].complete) || !h.spspps[index_pps1].complete || repeat)) {
+ BYTE id = h.lastid;
+ repeat = false;
+
+ // Get array index from NAL unit type
+ spsppsindex index = index_unknown;
+
+ if ((id & 0x60) != 0) {
+ if ((id & 0x9f) == 0x07) {
+ index = index_sps;
+ } else if ((id & 0x9f) == 0x0F) {
+ index = index_subsetsps;
+ } else if ((id & 0x9f) == 0x08) {
+ index = h.spspps[index_pps1].complete ? index_pps2 : index_pps1;
+ }
+ }
+
+ // Search for next start code
+ DWORD dwStartCode = (DWORD)BitRead(32, true);
+ while (GetPos() < endpos + 4 && (dwStartCode != 0x00000001) && (dwStartCode & 0xFFFFFF00) != 0x00000100) {
+ BitRead(8);
+ dwStartCode = (DWORD)BitRead(32, true);
+ }
+
+ //nalendpos = GetPos();
+
+ // Skip start code
+ __int64 pos;
+ if (GetPos() < endpos + 4) {
+ if (dwStartCode == 0x00000001) {
+ BitRead(32);
+ } else {
+ BitRead(24);
+ }
+
+ pos = GetPos();
+ h.lastid = (BYTE)BitRead(8);
+ } else {
+ pos = GetPos() - 4;
+ }
+
+ // The SPS or PPS might be fragmented, copy data into buffer until NAL is complete
+ if (index >= 0) {
+ if (h.spspps[index].complete) {
+ // Don't handle SPS/PPS twice
+ continue;
+ } else if (pos > nalstartpos) {
+ // Copy into buffer
+ Seek(nalstartpos);
+ unsigned int bufsize = _countof(h.spspps[index].buffer);
+ int len = min(int(bufsize - h.spspps[index].size), int(pos - nalstartpos));
+ ByteRead(h.spspps[index].buffer + h.spspps[index].size, len);
+ Seek(pos);
+ h.spspps[index].size += len;
+
+ //ASSERT(h.spspps[index].size < bufsize); // disable for better debug ...
+
+ if (h.spspps[index].size >= bufsize || dwStartCode == 0x00000001 || (dwStartCode & 0xFFFFFF00) == 0x00000100) {
+ if (Read(h, index)) {
+ h.spspps[index].complete = true;
+ h.spspps[index].size -= 4;
+ } else {
+ h.spspps[index].size = 0;
+ }
+ }
+
+ repeat = true;
+ }
+ }
+
+ nalstartpos = pos;
+ }
+
+ // Exit and wait for next packet if there is no SPS and PPS yet
+ if ((!h.spspps[index_sps].complete && !h.spspps[index_subsetsps].complete) || !h.spspps[index_pps1].complete || repeat) {
+
+ return false;
+ }
+
+ if (!pmt) {
+ return true;
+ }
+
+ {
+ // Calculate size of extra data
+ int extra = 0;
+ for (int i = 0; i < 4; i++) {
+ if (h.spspps[i].complete) {
+ extra += 2 + (h.spspps[i].size);
+ }
+ }
+
+ pmt->majortype = MEDIATYPE_Video;
+ if (h.spspps[index_subsetsps].complete && !h.spspps[index_sps].complete) {
+ pmt->subtype = FOURCCMap('CVME'); // MVC stream without base view
+ } else if (h.spspps[index_subsetsps].complete && h.spspps[index_sps].complete) {
+ pmt->subtype = FOURCCMap('CVMA'); // MVC stream with base view
+ } else {
+ pmt->subtype = FOURCCMap('1CVA'); // AVC stream
+ }
+ //pmt->subtype = MEDIASUBTYPE_H264; // TODO : put MEDIASUBTYPE_H264 to support Windows 7 decoder !
+ pmt->formattype = FORMAT_MPEG2_VIDEO;
+ int len = FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + extra;
+ MPEG2VIDEOINFO* vi = (MPEG2VIDEOINFO*)DNew BYTE[len];
+ memset(vi, 0, len);
+ // vi->hdr.dwBitRate = ;
+ vi->hdr.AvgTimePerFrame = h.AvgTimePerFrame;
+ if (!h.sar.num) { h.sar.num = 1; }
+ if (!h.sar.den) { h.sar.den = 1; }
+ CSize aspect(h.width * h.sar.num, h.height * h.sar.den);
+ int lnko = LNKO(aspect.cx, aspect.cy);
+ if (lnko > 1) {
+ aspect.cx /= lnko, aspect.cy /= lnko;
+ }
+
+ if (aspect.cx * 2 < aspect.cy) {
+ delete[] vi;
+ return false;
+ }
+
+ vi->hdr.dwPictAspectRatioX = aspect.cx;
+ vi->hdr.dwPictAspectRatioY = aspect.cy;
+ vi->hdr.bmiHeader.biSize = sizeof(vi->hdr.bmiHeader);
+ vi->hdr.bmiHeader.biWidth = h.width;
+ vi->hdr.bmiHeader.biHeight = h.height;
+ if (h.spspps[index_subsetsps].complete && !h.spspps[index_sps].complete) {
+ vi->hdr.bmiHeader.biCompression = 'CVME';
+ } else if (h.spspps[index_subsetsps].complete && h.spspps[index_sps].complete) {
+ vi->hdr.bmiHeader.biCompression = 'CVMA';
+ } else {
+ vi->hdr.bmiHeader.biCompression = '1CVA';
+ }
+ vi->dwProfile = h.profile;
+ vi->dwFlags = 4; // ?
+ vi->dwLevel = h.level;
+ vi->cbSequenceHeader = extra;
+
+ // Copy extra data
+ BYTE* p = (BYTE*)&vi->dwSequenceHeader[0];
+ for (int i = 0; i < 4; i++) {
+ if (h.spspps[i].complete) {
+ *p++ = (h.spspps[i].size) >> 8;
+ *p++ = (h.spspps[i].size) & 0xff;
+ memcpy(p, h.spspps[i].buffer, h.spspps[i].size);
+ p += h.spspps[i].size;
+ }
+ }
+
+ pmt->SetFormat((BYTE*)vi, len);
+ delete [] vi;
+ }
+
+ return true;
}
bool CBaseSplitterFileEx::Read(avchdr& h, spsppsindex index)
{
- static BYTE profiles[] = {44, 66, 77, 88, 100, 110, 118, 122, 128, 144, 244};
- static BYTE levels[] = {10, 11, 12, 13, 20, 21, 22, 30, 31, 32, 40, 41, 42, 50, 51};
-
- // Only care about SPS and subset SPS
- if (index != index_sps && index != index_subsetsps)
- return true;
-
- // Manage escape codes
- BYTE buffer[MAX_SPSPPS];
- RemoveMpegEscapeCode(buffer, h.spspps[index].buffer, MAX_SPSPPS);
- CGolombBuffer gb(buffer, MAX_SPSPPS);
-
- gb.BitRead(8); // nal_unit_type
- h.profile = (BYTE)gb.BitRead(8);
- bool b_ident = false;
- for (int i = 0; i<sizeof(profiles); i++) {
- if (h.profile == profiles[i]) {
- b_ident = true;
- break;
- }
- }
- if (!b_ident)
- return false;
-
- gb.BitRead(8);
- h.level = (BYTE)gb.BitRead(8);
- b_ident = false;
- for (int i = 0; i<sizeof(levels); i++) {
- if (h.level == levels[i]) {
- b_ident = true;
- break;
- }
- }
- if (!b_ident)
- return false;
-
- UINT64 sps_id = gb.UExpGolombRead(); // seq_parameter_set_id
- if (sps_id >= 32)
- return false;
-
- UINT64 chroma_format_idc = 0;
- if (h.profile >= 100) { // high profile
- chroma_format_idc = gb.UExpGolombRead();
- if (chroma_format_idc == 3) { // chroma_format_idc
- gb.BitRead(1); // residue_transform_flag
- }
-
- gb.UExpGolombRead(); // bit_depth_luma_minus8
- gb.UExpGolombRead(); // bit_depth_chroma_minus8
-
- gb.BitRead(1); // qpprime_y_zero_transform_bypass_flag
-
- if (gb.BitRead(1)) { // seq_scaling_matrix_present_flag
- for (int i = 0; i < 8; i++) {
- if (gb.BitRead(1)) { // seq_scaling_list_present_flag
- for (int j = 0, size = i < 6 ? 16 : 64, next = 8; j < size && next != 0; ++j) {
- next = (next + gb.SExpGolombRead() + 256) & 255;
- }
- }
- }
- }
- }
-
- gb.UExpGolombRead(); // log2_max_frame_num_minus4
-
- UINT64 pic_order_cnt_type = gb.UExpGolombRead();
-
- if (pic_order_cnt_type == 0) {
- gb.UExpGolombRead(); // log2_max_pic_order_cnt_lsb_minus4
- } else if (pic_order_cnt_type == 1) {
- gb.BitRead(1); // delta_pic_order_always_zero_flag
- gb.SExpGolombRead(); // offset_for_non_ref_pic
- gb.SExpGolombRead(); // offset_for_top_to_bottom_field
- UINT64 num_ref_frames_in_pic_order_cnt_cycle = gb.UExpGolombRead();
- if (num_ref_frames_in_pic_order_cnt_cycle >= 256)
- return false;
- for (int i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++) {
- gb.SExpGolombRead(); // offset_for_ref_frame[i]
- }
- } else if (pic_order_cnt_type != 2) {
- return false;
- }
-
- UINT64 ref_frame_count = gb.UExpGolombRead(); // num_ref_frames
- if (ref_frame_count > 30)
- return false;
- gb.BitRead(1); // gaps_in_frame_num_value_allowed_flag
-
- UINT64 pic_width_in_mbs_minus1 = gb.UExpGolombRead();
- UINT64 pic_height_in_map_units_minus1 = gb.UExpGolombRead();
- BYTE frame_mbs_only_flag = (BYTE)gb.BitRead(1);
-
- if (!frame_mbs_only_flag) {
- gb.BitRead(1); // mb_adaptive_frame_field_flag
- }
-
- BYTE direct_8x8_inference_flag = (BYTE)gb.BitRead(1); // direct_8x8_inference_flag
- if (!frame_mbs_only_flag && !direct_8x8_inference_flag) {
- return false;
- }
-
- if (gb.BitRead(1)) { // frame_cropping_flag
- h.crop_left = (unsigned int)gb.UExpGolombRead(); // frame_cropping_rect_left_offset
- h.crop_right = (unsigned int)gb.UExpGolombRead(); // frame_cropping_rect_right_offset
- h.crop_top = (unsigned int)gb.UExpGolombRead(); // frame_cropping_rect_top_offset
- h.crop_bottom = (unsigned int)gb.UExpGolombRead(); // frame_cropping_rect_bottom_offset
- }
-
- if (gb.BitRead(1)) { // vui_parameters_present_flag
- if (gb.BitRead(1)) { // aspect_ratio_info_present_flag
- BYTE aspect_ratio_idc = (BYTE)gb.BitRead(8); // aspect_ratio_idc
- if (255 == aspect_ratio_idc) {
- h.sar.num = (WORD)gb.BitRead(16); // sar_width
- h.sar.den = (WORD)gb.BitRead(16); // sar_height
- } else if (aspect_ratio_idc < 17) {
- h.sar.num = pixel_aspect[aspect_ratio_idc][0];
- h.sar.den = pixel_aspect[aspect_ratio_idc][1];
- } else {
- return false;
- }
- } else {
- h.sar.num = 1;
- h.sar.den = 1;
- }
-
- if (gb.BitRead(1)) { // overscan_info_present_flag
- gb.BitRead(1); // overscan_appropriate_flag
- }
-
- if (gb.BitRead(1)) { // video_signal_type_present_flag
- gb.BitRead(3); // video_format
- gb.BitRead(1); // video_full_range_flag
- if (gb.BitRead(1)) { // colour_description_present_flag
- gb.BitRead(8); // colour_primaries
- gb.BitRead(8); // transfer_characteristics
- gb.BitRead(8); // matrix_coefficients
- }
- }
- if (gb.BitRead(1)) { // chroma_location_info_present_flag
- gb.UExpGolombRead(); // chroma_sample_loc_type_top_field
- gb.UExpGolombRead(); // chroma_sample_loc_type_bottom_field
- }
- if (gb.BitRead(1)) { // timing_info_present_flag
- __int64 num_units_in_tick = gb.BitRead(32);
- __int64 time_scale = gb.BitRead(32);
- /*long fixed_frame_rate_flag = */gb.BitRead(1);
-
- // Trick for weird parameters
- if ((num_units_in_tick < 1000) || (num_units_in_tick > 1001)) {
- if ((time_scale % num_units_in_tick != 0) && ((time_scale*1001) % num_units_in_tick == 0)) {
- time_scale = (time_scale * 1001) / num_units_in_tick;
- num_units_in_tick = 1001;
- } else {
- time_scale = (time_scale * 1000) / num_units_in_tick;
- num_units_in_tick = 1000;
- }
- }
- time_scale = time_scale / 2; // VUI consider fields even for progressive stream : divide by 2!
-
- if (time_scale) {
- h.AvgTimePerFrame = (10000000I64*num_units_in_tick)/time_scale;
- }
- }
-
- bool nalflag = !!gb.BitRead(1); // nal_hrd_parameters_present_flag
- if (nalflag) {
- if (HrdParameters(gb)<0)
- return false;
- }
- bool vlcflag = !!gb.BitRead(1); // vlc_hrd_parameters_present_flag
- if (vlcflag) {
- if (HrdParameters(gb)<0)
- return false;
- }
- if (nalflag || vlcflag) {
- gb.BitRead(1); // low_delay_hrd_flag
- }
-
- gb.BitRead(1); // pic_struct_present_flag
- if (gb.BitRead(1)) { // bitstream_restriction_flag
- gb.BitRead(1); // motion_vectors_over_pic_boundaries_flag
- gb.UExpGolombRead(); // max_bytes_per_pic_denom
- gb.UExpGolombRead(); // max_bits_per_mb_denom
- gb.UExpGolombRead(); // log2_max_mv_length_horizontal
- gb.UExpGolombRead(); // log2_max_mv_length_vertical
- UINT64 num_reorder_frames = gb.UExpGolombRead(); // num_reorder_frames
- gb.UExpGolombRead(); // max_dec_frame_buffering
-
- if (gb.GetSize() < gb.GetPos()) {
- num_reorder_frames = 0;
- }
- if (num_reorder_frames > 16U)
- return false;
- }
- }
-
- if (index == index_subsetsps) {
- if (h.profile == 83 || h.profile == 86) {
- // TODO: SVC extensions
- return false;
- } else if (h.profile == 118 || h.profile == 128) {
- gb.BitRead(1); // bit_equal_to_one
-
- // seq_parameter_set_mvc_extension
- h.views = (unsigned int) gb.UExpGolombRead()+1;
-
- /*
- for (unsigned int i = 0; i < h.views; i++) {
- gb.UExpGolombRead(); // view_id
- }
-
- for (unsigned int i = 1; i < h.views; i++) {
- for (int j = 0; j < gb.UExpGolombRead(); j++) { // num_anchor_refs_l0
- gb.UExpGolombRead(); // anchor_refs_l0
- }
- for (int j = 0; j < gb.UExpGolombRead(); j++) { // num_anchor_refs_l1
- gb.UExpGolombRead(); // anchor_refs_l1
- }
- }
-
- for (unsigned int i = 1; i < h.views; i++) {
- for (int j = 0; j < gb.UExpGolombRead(); j++) { // num_non_anchor_refs_l0
- gb.UExpGolombRead(); // non_anchor_refs_l0
- }
- for (int j = 0; j < gb.UExpGolombRead(); j++) { // num_non_anchor_refs_l1
- gb.UExpGolombRead(); // non_anchor_refs_l1
- }
- }
-
- for (unsigned int i = 0; i <= gb.UExpGolombRead(); i++) { // num_level_values_signalled_minus1
- gb.BitRead(8); // level_idc
- for (int j = 0; j <= gb.UExpGolombRead(); j++) { // num_applicable_ops_minus1
- gb.BitRead(3); // applicable_op_temporal_id
- for (int k = 0; k <= gb.UExpGolombRead(); k++) { // applicable_op_num_target_views_minus1
- gb.UExpGolombRead(); // applicable_op_traget_view_id
- }
- gb.UExpGolombRead(); // applicable_op_num_views_minus1
- }
- }
-
- if (gb.BitRead(1)) { // mvc_vui_parameters_present_flag
- // mvc_vui_parameters_extension
- for (unsigned int i = 0; i <= gb.UExpGolombRead(); i++) { // vui_mvc_num_ops_minus1
- gb.BitRead(3);
- for (unsigned int j = 0; j <= gb.UExpGolombRead(); j++) { // vui_mvc_num_target_output_views_minus1
- gb.UExpGolombRead(); // vui_mvc_view_id
- }
- if (gb.BitRead(1)) { // vui_mvc_timing_info_present_flag
- gb.BitRead(32); // vui_mvc_num_units_in_tick
- gb.BitRead(32); // vui_mvc_time_scale
- gb.BitRead(1); // vui_mvc_fixed_frame_rate_flag
- }
- bool nalflag = gb.BitRead(1); // vui_mvc_nal_hrd_parameters_present_flag
- if (nalflag) {
- HrdParameters(gb);
- }
- bool vclflag = gb.BitRead(1); // vui_mvc_vcl_hrd_parameters_present_flag
- if (vclflag) {
- HrdParameters(gb);
- }
- if (nalflag || vclflag) {
- gb.BitRead(1); // vui_mvc_low_delay_hrd_flag
- }
- gb.BitRead(1); // vui_mvc_pic_struct_present_flag
- }
- }
- */
- }
- }
-
- unsigned int mb_Width = (unsigned int)pic_width_in_mbs_minus1 + 1;
- unsigned int mb_Height = ((unsigned int)pic_height_in_map_units_minus1 + 1) * (2 - frame_mbs_only_flag);
- BYTE CHROMA444 = (chroma_format_idc == 3);
-
- h.width = 16 * mb_Width - (2u>>CHROMA444) * min(h.crop_right, (8u<<CHROMA444)-1);
- if (frame_mbs_only_flag) {
- h.height = 16 * mb_Height - (2u>>CHROMA444) * min(h.crop_bottom, (8u<<CHROMA444)-1);
- } else {
- h.height = 16 * mb_Height - (4u>>CHROMA444) * min(h.crop_bottom, (8u<<CHROMA444)-1);
- }
-
- if (h.height<100 || h.width<100) {
- return false;
- }
-
- if (h.height == 1088) {
- h.height = 1080; // Prevent blur lines
- }
-
- return true;
+ static BYTE profiles[] = {44, 66, 77, 88, 100, 110, 118, 122, 128, 144, 244};
+ static BYTE levels[] = {10, 11, 12, 13, 20, 21, 22, 30, 31, 32, 40, 41, 42, 50, 51};
+
+ // Only care about SPS and subset SPS
+ if (index != index_sps && index != index_subsetsps) {
+ return true;
+ }
+
+ // Manage escape codes
+ BYTE buffer[MAX_SPSPPS];
+ RemoveMpegEscapeCode(buffer, h.spspps[index].buffer, MAX_SPSPPS);
+ CGolombBuffer gb(buffer, MAX_SPSPPS);
+
+ gb.BitRead(8); // nal_unit_type
+ h.profile = (BYTE)gb.BitRead(8);
+ bool b_ident = false;
+ for (int i = 0; i < sizeof(profiles); i++) {
+ if (h.profile == profiles[i]) {
+ b_ident = true;
+ break;
+ }
+ }
+ if (!b_ident) {
+ return false;
+ }
+
+ gb.BitRead(8);
+ h.level = (BYTE)gb.BitRead(8);
+ b_ident = false;
+ for (int i = 0; i < sizeof(levels); i++) {
+ if (h.level == levels[i]) {
+ b_ident = true;
+ break;
+ }
+ }
+ if (!b_ident) {
+ return false;
+ }
+
+ UINT64 sps_id = gb.UExpGolombRead(); // seq_parameter_set_id
+ if (sps_id >= 32) {
+ return false;
+ }
+
+ UINT64 chroma_format_idc = 0;
+ if (h.profile >= 100) { // high profile
+ chroma_format_idc = gb.UExpGolombRead();
+ if (chroma_format_idc == 3) { // chroma_format_idc
+ gb.BitRead(1); // residue_transform_flag
+ }
+
+ gb.UExpGolombRead(); // bit_depth_luma_minus8
+ gb.UExpGolombRead(); // bit_depth_chroma_minus8
+
+ gb.BitRead(1); // qpprime_y_zero_transform_bypass_flag
+
+ if (gb.BitRead(1)) { // seq_scaling_matrix_present_flag
+ for (int i = 0; i < 8; i++) {
+ if (gb.BitRead(1)) { // seq_scaling_list_present_flag
+ for (int j = 0, size = i < 6 ? 16 : 64, next = 8; j < size && next != 0; ++j) {
+ next = (next + gb.SExpGolombRead() + 256) & 255;
+ }
+ }
+ }
+ }
+ }
+
+ gb.UExpGolombRead(); // log2_max_frame_num_minus4
+
+ UINT64 pic_order_cnt_type = gb.UExpGolombRead();
+
+ if (pic_order_cnt_type == 0) {
+ gb.UExpGolombRead(); // log2_max_pic_order_cnt_lsb_minus4
+ } else if (pic_order_cnt_type == 1) {
+ gb.BitRead(1); // delta_pic_order_always_zero_flag
+ gb.SExpGolombRead(); // offset_for_non_ref_pic
+ gb.SExpGolombRead(); // offset_for_top_to_bottom_field
+ UINT64 num_ref_frames_in_pic_order_cnt_cycle = gb.UExpGolombRead();
+ if (num_ref_frames_in_pic_order_cnt_cycle >= 256) {
+ return false;
+ }
+ for (int i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++) {
+ gb.SExpGolombRead(); // offset_for_ref_frame[i]
+ }
+ } else if (pic_order_cnt_type != 2) {
+ return false;
+ }
+
+ UINT64 ref_frame_count = gb.UExpGolombRead(); // num_ref_frames
+ if (ref_frame_count > 30) {
+ return false;
+ }
+ gb.BitRead(1); // gaps_in_frame_num_value_allowed_flag
+
+ UINT64 pic_width_in_mbs_minus1 = gb.UExpGolombRead();
+ UINT64 pic_height_in_map_units_minus1 = gb.UExpGolombRead();
+ BYTE frame_mbs_only_flag = (BYTE)gb.BitRead(1);
+
+ if (!frame_mbs_only_flag) {
+ gb.BitRead(1); // mb_adaptive_frame_field_flag
+ }
+
+ BYTE direct_8x8_inference_flag = (BYTE)gb.BitRead(1); // direct_8x8_inference_flag
+ if (!frame_mbs_only_flag && !direct_8x8_inference_flag) {
+ return false;
+ }
+
+ if (gb.BitRead(1)) { // frame_cropping_flag
+ h.crop_left = (unsigned int)gb.UExpGolombRead(); // frame_cropping_rect_left_offset
+ h.crop_right = (unsigned int)gb.UExpGolombRead(); // frame_cropping_rect_right_offset
+ h.crop_top = (unsigned int)gb.UExpGolombRead(); // frame_cropping_rect_top_offset
+ h.crop_bottom = (unsigned int)gb.UExpGolombRead(); // frame_cropping_rect_bottom_offset
+ }
+
+ if (gb.BitRead(1)) { // vui_parameters_present_flag
+ if (gb.BitRead(1)) { // aspect_ratio_info_present_flag
+ BYTE aspect_ratio_idc = (BYTE)gb.BitRead(8); // aspect_ratio_idc
+ if (255 == aspect_ratio_idc) {
+ h.sar.num = (WORD)gb.BitRead(16); // sar_width
+ h.sar.den = (WORD)gb.BitRead(16); // sar_height
+ } else if (aspect_ratio_idc < 17) {
+ h.sar.num = pixel_aspect[aspect_ratio_idc][0];
+ h.sar.den = pixel_aspect[aspect_ratio_idc][1];
+ } else {
+ return false;
+ }
+ } else {
+ h.sar.num = 1;
+ h.sar.den = 1;
+ }
+
+ if (gb.BitRead(1)) { // overscan_info_present_flag
+ gb.BitRead(1); // overscan_appropriate_flag
+ }
+
+ if (gb.BitRead(1)) { // video_signal_type_present_flag
+ gb.BitRead(3); // video_format
+ gb.BitRead(1); // video_full_range_flag
+ if (gb.BitRead(1)) { // colour_description_present_flag
+ gb.BitRead(8); // colour_primaries
+ gb.BitRead(8); // transfer_characteristics
+ gb.BitRead(8); // matrix_coefficients
+ }
+ }
+ if (gb.BitRead(1)) { // chroma_location_info_present_flag
+ gb.UExpGolombRead(); // chroma_sample_loc_type_top_field
+ gb.UExpGolombRead(); // chroma_sample_loc_type_bottom_field
+ }
+ if (gb.BitRead(1)) { // timing_info_present_flag
+ __int64 num_units_in_tick = gb.BitRead(32);
+ __int64 time_scale = gb.BitRead(32);
+ /*long fixed_frame_rate_flag = */gb.BitRead(1);
+
+ // Trick for weird parameters
+ if ((num_units_in_tick < 1000) || (num_units_in_tick > 1001)) {
+ if ((time_scale % num_units_in_tick != 0) && ((time_scale * 1001) % num_units_in_tick == 0)) {
+ time_scale = (time_scale * 1001) / num_units_in_tick;
+ num_units_in_tick = 1001;
+ } else {
+ time_scale = (time_scale * 1000) / num_units_in_tick;
+ num_units_in_tick = 1000;
+ }
+ }
+ time_scale = time_scale / 2; // VUI consider fields even for progressive stream : divide by 2!
+
+ if (time_scale) {
+ h.AvgTimePerFrame = (10000000I64 * num_units_in_tick) / time_scale;
+ }
+ }
+
+ bool nalflag = !!gb.BitRead(1); // nal_hrd_parameters_present_flag
+ if (nalflag) {
+ if (HrdParameters(gb) < 0) {
+ return false;
+ }
+ }
+ bool vlcflag = !!gb.BitRead(1); // vlc_hrd_parameters_present_flag
+ if (vlcflag) {
+ if (HrdParameters(gb) < 0) {
+ return false;
+ }
+ }
+ if (nalflag || vlcflag) {
+ gb.BitRead(1); // low_delay_hrd_flag
+ }
+
+ gb.BitRead(1); // pic_struct_present_flag
+ if (gb.BitRead(1)) { // bitstream_restriction_flag
+ gb.BitRead(1); // motion_vectors_over_pic_boundaries_flag
+ gb.UExpGolombRead(); // max_bytes_per_pic_denom
+ gb.UExpGolombRead(); // max_bits_per_mb_denom
+ gb.UExpGolombRead(); // log2_max_mv_length_horizontal
+ gb.UExpGolombRead(); // log2_max_mv_length_vertical
+ UINT64 num_reorder_frames = gb.UExpGolombRead(); // num_reorder_frames
+ gb.UExpGolombRead(); // max_dec_frame_buffering
+
+ if (gb.GetSize() < gb.GetPos()) {
+ num_reorder_frames = 0;
+ }
+ if (num_reorder_frames > 16U) {
+ return false;
+ }
+ }
+ }
+
+ if (index == index_subsetsps) {
+ if (h.profile == 83 || h.profile == 86) {
+ // TODO: SVC extensions
+ return false;
+ } else if (h.profile == 118 || h.profile == 128) {
+ gb.BitRead(1); // bit_equal_to_one
+
+ // seq_parameter_set_mvc_extension
+ h.views = (unsigned int) gb.UExpGolombRead() + 1;
+
+ /*
+ for (unsigned int i = 0; i < h.views; i++) {
+ gb.UExpGolombRead(); // view_id
+ }
+
+ for (unsigned int i = 1; i < h.views; i++) {
+ for (int j = 0; j < gb.UExpGolombRead(); j++) { // num_anchor_refs_l0
+ gb.UExpGolombRead(); // anchor_refs_l0
+ }
+ for (int j = 0; j < gb.UExpGolombRead(); j++) { // num_anchor_refs_l1
+ gb.UExpGolombRead(); // anchor_refs_l1
+ }
+ }
+
+ for (unsigned int i = 1; i < h.views; i++) {
+ for (int j = 0; j < gb.UExpGolombRead(); j++) { // num_non_anchor_refs_l0
+ gb.UExpGolombRead(); // non_anchor_refs_l0
+ }
+ for (int j = 0; j < gb.UExpGolombRead(); j++) { // num_non_anchor_refs_l1
+ gb.UExpGolombRead(); // non_anchor_refs_l1
+ }
+ }
+
+ for (unsigned int i = 0; i <= gb.UExpGolombRead(); i++) { // num_level_values_signalled_minus1
+ gb.BitRead(8); // level_idc
+ for (int j = 0; j <= gb.UExpGolombRead(); j++) { // num_applicable_ops_minus1
+ gb.BitRead(3); // applicable_op_temporal_id
+ for (int k = 0; k <= gb.UExpGolombRead(); k++) { // applicable_op_num_target_views_minus1
+ gb.UExpGolombRead(); // applicable_op_traget_view_id
+ }
+ gb.UExpGolombRead(); // applicable_op_num_views_minus1
+ }
+ }
+
+ if (gb.BitRead(1)) { // mvc_vui_parameters_present_flag
+ // mvc_vui_parameters_extension
+ for (unsigned int i = 0; i <= gb.UExpGolombRead(); i++) { // vui_mvc_num_ops_minus1
+ gb.BitRead(3);
+ for (unsigned int j = 0; j <= gb.UExpGolombRead(); j++) { // vui_mvc_num_target_output_views_minus1
+ gb.UExpGolombRead(); // vui_mvc_view_id
+ }
+ if (gb.BitRead(1)) { // vui_mvc_timing_info_present_flag
+ gb.BitRead(32); // vui_mvc_num_units_in_tick
+ gb.BitRead(32); // vui_mvc_time_scale
+ gb.BitRead(1); // vui_mvc_fixed_frame_rate_flag
+ }
+ bool nalflag = gb.BitRead(1); // vui_mvc_nal_hrd_parameters_present_flag
+ if (nalflag) {
+ HrdParameters(gb);
+ }
+ bool vclflag = gb.BitRead(1); // vui_mvc_vcl_hrd_parameters_present_flag
+ if (vclflag) {
+ HrdParameters(gb);
+ }
+ if (nalflag || vclflag) {
+ gb.BitRead(1); // vui_mvc_low_delay_hrd_flag
+ }
+ gb.BitRead(1); // vui_mvc_pic_struct_present_flag
+ }
+ }
+ */
+ }
+ }
+
+ unsigned int mb_Width = (unsigned int)pic_width_in_mbs_minus1 + 1;
+ unsigned int mb_Height = ((unsigned int)pic_height_in_map_units_minus1 + 1) * (2 - frame_mbs_only_flag);
+ BYTE CHROMA444 = (chroma_format_idc == 3);
+
+ h.width = 16 * mb_Width - (2u >> CHROMA444) * min(h.crop_right, (8u << CHROMA444) - 1);
+ if (frame_mbs_only_flag) {
+ h.height = 16 * mb_Height - (2u >> CHROMA444) * min(h.crop_bottom, (8u << CHROMA444) - 1);
+ } else {
+ h.height = 16 * mb_Height - (4u >> CHROMA444) * min(h.crop_bottom, (8u << CHROMA444) - 1);
+ }
+
+ if (h.height < 100 || h.width < 100) {
+ return false;
+ }
+
+ if (h.height == 1088) {
+ h.height = 1080; // Prevent blur lines
+ }
+
+ return true;
}
bool CBaseSplitterFileEx::Read(vc1hdr& h, int len, CMediaType* pmt, int guid_flag)
{
- memset(&h, 0, sizeof(h));
-
- __int64 endpos = GetPos() + len; // - sequence header length
- __int64 extrapos = 0, extralen = 0;
- int nFrameRateNum = 0, nFrameRateDen = 1;
-
- if (GetPos() < endpos+4 && BitRead(32, true) == 0x0000010F) {
- extrapos = GetPos();
-
- BitRead(32);
-
- h.profile = (BYTE)BitRead(2);
-
- // Check if advanced profile
- if (h.profile != 3) {
- return false;
- }
-
- h.level = (BYTE)BitRead(3);
- h.chromaformat = (BYTE)BitRead(2);
-
- // (fps-2)/4 (->30)
- h.frmrtq_postproc = (BYTE)BitRead(3); //common
- // (bitrate-32kbps)/64kbps
- h.bitrtq_postproc = (BYTE)BitRead(5); //common
- h.postprocflag = (BYTE)BitRead(1); //common
-
- h.width = ((unsigned int)BitRead(12) + 1) << 1;
- h.height = ((unsigned int)BitRead(12) + 1) << 1;
-
- h.broadcast = (BYTE)BitRead(1);
- h.interlace = (BYTE)BitRead(1);
- h.tfcntrflag = (BYTE)BitRead(1);
- h.finterpflag = (BYTE)BitRead(1);
- BitRead(1); // reserved
- h.psf = (BYTE)BitRead(1);
- if (BitRead(1)) {
- int ar = 0;
- BitRead(14);
- BitRead(14);
- if (BitRead(1)) {
- ar = (int)BitRead(4);
- }
- if (ar && ar < 14) {
- h.sar.num = pixel_aspect[ar][0];
- h.sar.den = pixel_aspect[ar][1];
- } else if (ar == 15) {
- h.sar.num = (BYTE)BitRead(8);
- h.sar.den = (BYTE)BitRead(8);
- }
-
- // Read framerate
- const int ff_vc1_fps_nr[5] = { 24, 25, 30, 50, 60 };
- const int ff_vc1_fps_dr[2] = { 1000, 1001 };
-
- if (BitRead(1)) {
- if (BitRead(1)) {
- nFrameRateNum = 32;
- nFrameRateDen = (int)BitRead(16) + 1;
- } else {
- int nr, dr;
- nr = (int)BitRead(8);
- dr = (int)BitRead(4);
- if (nr && nr < 8 && dr && dr < 3) {
- nFrameRateNum = ff_vc1_fps_dr[dr - 1];
- nFrameRateDen = ff_vc1_fps_nr[nr - 1] * 1000;
- }
- }
- }
-
- }
-
- Seek(extrapos+4);
- extralen = 0;
- int parse = 0; // really need a signed type? may be unsigned will be better
-
- while (GetPos() < endpos+4 && ((parse == 0x0000010E) || (parse & 0xFFFFFF00) != 0x00000100)) {
- parse = (parse<<8) | (int)BitRead(8);
- extralen++;
- }
- }
-
- if (!extrapos || !extralen) {
- return false;
- }
-
- if (!pmt) {
- return true;
- }
-
- {
- pmt->majortype = MEDIATYPE_Video;
- switch (guid_flag) {
- case 1: pmt->subtype = FOURCCMap('1CVW');
- break;
- case 2: pmt->subtype = MEDIASUBTYPE_WVC1_CYBERLINK;
- break;
- case 3: pmt->subtype = MEDIASUBTYPE_WVC1_ARCSOFT;
- break;
- }
- pmt->formattype = FORMAT_VIDEOINFO2;
- int vi_len = sizeof(VIDEOINFOHEADER2) + (int)extralen + 1;
- VIDEOINFOHEADER2* vi = (VIDEOINFOHEADER2*)DNew BYTE[vi_len];
- memset(vi, 0, vi_len);
- vi->AvgTimePerFrame = (10000000I64*nFrameRateNum)/nFrameRateDen;
-
- if (!h.sar.num) h.sar.num = 1;
- if (!h.sar.den) h.sar.den = 1;
- CSize aspect = CSize(h.width * h.sar.num, h.height * h.sar.den);
- if (h.width == h.sar.num && h.height == h.sar.den) {
- aspect = CSize(h.width, h.height);
- }
- int lnko = LNKO(aspect.cx, aspect.cy);
- if (lnko > 1) {
- aspect.cx /= lnko, aspect.cy /= lnko;
- }
-
- vi->dwPictAspectRatioX = aspect.cx;
- vi->dwPictAspectRatioY = aspect.cy;
- vi->bmiHeader.biSize = sizeof(vi->bmiHeader);
- vi->bmiHeader.biWidth = h.width;
- vi->bmiHeader.biHeight = h.height;
- vi->bmiHeader.biCompression = '1CVW';
- BYTE* p = (BYTE*)vi + sizeof(VIDEOINFOHEADER2);
- *p++ = 0;
- Seek(extrapos);
- ByteRead(p, extralen);
- pmt->SetFormat((BYTE*)vi, vi_len);
- delete [] vi;
- }
- return true;
+ memset(&h, 0, sizeof(h));
+
+ __int64 endpos = GetPos() + len; // - sequence header length
+ __int64 extrapos = 0, extralen = 0;
+ int nFrameRateNum = 0, nFrameRateDen = 1;
+
+ if (GetPos() < endpos + 4 && BitRead(32, true) == 0x0000010F) {
+ extrapos = GetPos();
+
+ BitRead(32);
+
+ h.profile = (BYTE)BitRead(2);
+
+ // Check if advanced profile
+ if (h.profile != 3) {
+ return false;
+ }
+
+ h.level = (BYTE)BitRead(3);
+ h.chromaformat = (BYTE)BitRead(2);
+
+ // (fps-2)/4 (->30)
+ h.frmrtq_postproc = (BYTE)BitRead(3); //common
+ // (bitrate-32kbps)/64kbps
+ h.bitrtq_postproc = (BYTE)BitRead(5); //common
+ h.postprocflag = (BYTE)BitRead(1); //common
+
+ h.width = ((unsigned int)BitRead(12) + 1) << 1;
+ h.height = ((unsigned int)BitRead(12) + 1) << 1;
+
+ h.broadcast = (BYTE)BitRead(1);
+ h.interlace = (BYTE)BitRead(1);
+ h.tfcntrflag = (BYTE)BitRead(1);
+ h.finterpflag = (BYTE)BitRead(1);
+ BitRead(1); // reserved
+ h.psf = (BYTE)BitRead(1);
+ if (BitRead(1)) {
+ int ar = 0;
+ BitRead(14);
+ BitRead(14);
+ if (BitRead(1)) {
+ ar = (int)BitRead(4);
+ }
+ if (ar && ar < 14) {
+ h.sar.num = pixel_aspect[ar][0];
+ h.sar.den = pixel_aspect[ar][1];
+ } else if (ar == 15) {
+ h.sar.num = (BYTE)BitRead(8);
+ h.sar.den = (BYTE)BitRead(8);
+ }
+
+ // Read framerate
+ const int ff_vc1_fps_nr[5] = { 24, 25, 30, 50, 60 };
+ const int ff_vc1_fps_dr[2] = { 1000, 1001 };
+
+ if (BitRead(1)) {
+ if (BitRead(1)) {
+ nFrameRateNum = 32;
+ nFrameRateDen = (int)BitRead(16) + 1;
+ } else {
+ int nr, dr;
+ nr = (int)BitRead(8);
+ dr = (int)BitRead(4);
+ if (nr && nr < 8 && dr && dr < 3) {
+ nFrameRateNum = ff_vc1_fps_dr[dr - 1];
+ nFrameRateDen = ff_vc1_fps_nr[nr - 1] * 1000;
+ }
+ }
+ }
+
+ }
+
+ Seek(extrapos + 4);
+ extralen = 0;
+ int parse = 0; // really need a signed type? may be unsigned will be better
+
+ while (GetPos() < endpos + 4 && ((parse == 0x0000010E) || (parse & 0xFFFFFF00) != 0x00000100)) {
+ parse = (parse << 8) | (int)BitRead(8);
+ extralen++;
+ }
+ }
+
+ if (!extrapos || !extralen) {
+ return false;
+ }
+
+ if (!pmt) {
+ return true;
+ }
+
+ {
+ pmt->majortype = MEDIATYPE_Video;
+ switch (guid_flag) {
+ case 1: pmt->subtype = FOURCCMap('1CVW');
+ break;
+ case 2: pmt->subtype = MEDIASUBTYPE_WVC1_CYBERLINK;
+ break;
+ case 3: pmt->subtype = MEDIASUBTYPE_WVC1_ARCSOFT;
+ break;
+ }
+ pmt->formattype = FORMAT_VIDEOINFO2;
+ int vi_len = sizeof(VIDEOINFOHEADER2) + (int)extralen + 1;
+ VIDEOINFOHEADER2* vi = (VIDEOINFOHEADER2*)DNew BYTE[vi_len];
+ memset(vi, 0, vi_len);
+ vi->AvgTimePerFrame = (10000000I64 * nFrameRateNum) / nFrameRateDen;
+
+ if (!h.sar.num) { h.sar.num = 1; }
+ if (!h.sar.den) { h.sar.den = 1; }
+ CSize aspect = CSize(h.width * h.sar.num, h.height * h.sar.den);
+ if (h.width == h.sar.num && h.height == h.sar.den) {
+ aspect = CSize(h.width, h.height);
+ }
+ int lnko = LNKO(aspect.cx, aspect.cy);
+ if (lnko > 1) {
+ aspect.cx /= lnko, aspect.cy /= lnko;
+ }
+
+ vi->dwPictAspectRatioX = aspect.cx;
+ vi->dwPictAspectRatioY = aspect.cy;
+ vi->bmiHeader.biSize = sizeof(vi->bmiHeader);
+ vi->bmiHeader.biWidth = h.width;
+ vi->bmiHeader.biHeight = h.height;
+ vi->bmiHeader.biCompression = '1CVW';
+ BYTE* p = (BYTE*)vi + sizeof(VIDEOINFOHEADER2);
+ *p++ = 0;
+ Seek(extrapos);
+ ByteRead(p, extralen);
+ pmt->SetFormat((BYTE*)vi, vi_len);
+ delete [] vi;
+ }
+ return true;
}
bool CBaseSplitterFileEx::Read(dvbsub& h, int len, CMediaType* pmt)
{
- memset(&h, 0, sizeof(h));
+ memset(&h, 0, sizeof(h));
- if ((BitRead(32, true) & 0xFFFFFF00) == 0x20000f00) {
- static const SUBTITLEINFO SubFormat = { 0, "", L"" };
+ if ((BitRead(32, true) & 0xFFFFFF00) == 0x20000f00) {
+ static const SUBTITLEINFO SubFormat = { 0, "", L"" };
- pmt->majortype = MEDIATYPE_Subtitle;
- pmt->subtype = MEDIASUBTYPE_DVB_SUBTITLES;
- pmt->formattype = FORMAT_None;
- pmt->SetFormat ((BYTE*)&SubFormat, sizeof(SUBTITLEINFO));
+ pmt->majortype = MEDIATYPE_Subtitle;
+ pmt->subtype = MEDIASUBTYPE_DVB_SUBTITLES;
+ pmt->formattype = FORMAT_None;
+ pmt->SetFormat((BYTE*)&SubFormat, sizeof(SUBTITLEINFO));
- return true;
- }
+ return true;
+ }
- return false;
+ return false;
}
/*
To see working buffer in debugger, look :
- - m_pCache.m_p for the cached buffer
- - m_pos for current read position
+ - m_pCache.m_p for the cached buffer
+ - m_pos for current read position
*/
diff --git a/src/filters/parser/BaseSplitter/BaseSplitterFileEx.h b/src/filters/parser/BaseSplitter/BaseSplitterFileEx.h
index a42d54b8c..285a9a008 100644
--- a/src/filters/parser/BaseSplitter/BaseSplitterFileEx.h
+++ b/src/filters/parser/BaseSplitter/BaseSplitterFileEx.h
@@ -26,434 +26,412 @@
#include "BaseSplitterFile.h"
#include "../../../DSUtil/Mpeg2Def.h"
-#define MAX_SPSPPS 256 // Max size for a SPS/PPS packet
+#define MAX_SPSPPS 256 // Max size for a SPS/PPS packet
class CGolombBuffer;
-static const byte pixel_aspect[17][2]= {
- {0, 1},
- {1, 1},
- {12, 11},
- {10, 11},
- {16, 11},
- {40, 33},
- {24, 11},
- {20, 11},
- {32, 11},
- {80, 33},
- {18, 11},
- {15, 11},
- {64, 33},
- {160,99},
- {4, 3},
- {3, 2},
- {2, 1},
+static const byte pixel_aspect[17][2] = {
+ {0, 1},
+ {1, 1},
+ {12, 11},
+ {10, 11},
+ {16, 11},
+ {40, 33},
+ {24, 11},
+ {20, 11},
+ {32, 11},
+ {80, 33},
+ {18, 11},
+ {15, 11},
+ {64, 33},
+ {160, 99},
+ {4, 3},
+ {3, 2},
+ {2, 1},
};
class CBaseSplitterFileEx : public CBaseSplitterFile
{
- int m_tslen; // transport stream packet length (188 or 192 bytes, auto-detected)
+ int m_tslen; // transport stream packet length (188 or 192 bytes, auto-detected)
protected :
- REFERENCE_TIME m_rtPTSOffset;
+ REFERENCE_TIME m_rtPTSOffset;
public:
- CBaseSplitterFileEx(IAsyncReader* pReader, HRESULT& hr, int cachelen = DEFAULT_CACHE_LENGTH, bool fRandomAccess = true, bool fStreaming = false);
- virtual ~CBaseSplitterFileEx();
+ CBaseSplitterFileEx(IAsyncReader* pReader, HRESULT& hr, int cachelen = DEFAULT_CACHE_LENGTH, bool fRandomAccess = true, bool fStreaming = false);
+ virtual ~CBaseSplitterFileEx();
- // using CBaseSplitterFile::Read;
+ // using CBaseSplitterFile::Read;
- bool NextMpegStartCode(BYTE& b, __int64 len = 65536);
+ bool NextMpegStartCode(BYTE& b, __int64 len = 65536);
#pragma pack(push, 1)
- enum mpeg_t {mpegunk, mpeg1, mpeg2};
-
- struct pshdr {
- mpeg_t type;
- UINT64 scr, bitrate;
- };
-
- struct pssyshdr {
- DWORD rate_bound;
- BYTE video_bound, audio_bound;
- bool fixed_rate, csps;
- bool sys_video_loc_flag, sys_audio_loc_flag;
- };
-
- struct peshdr {
- WORD len;
-
- BYTE type:2, fpts:1, fdts:1;
- REFERENCE_TIME pts, dts;
-
- // mpeg1 stuff
- UINT64 std_buff_size;
-
- // mpeg2 stuff
- BYTE scrambling:2, priority:1, alignment:1, copyright:1, original:1;
- BYTE escr:1, esrate:1, dsmtrickmode:1, morecopyright:1, crc:1, extension:1;
- BYTE hdrlen;
-
- BYTE id_ext;
-
- struct peshdr() {
- memset(this, 0, sizeof(*this));
- }
- };
-
- struct seqhdr {
- WORD width;
- WORD height;
- BYTE ar:4;
- DWORD ifps;
- DWORD bitrate;
- DWORD vbv;
- BYTE constrained:1;
- BYTE fiqm:1;
- BYTE iqm[64];
- BYTE fniqm:1;
- BYTE niqm[64];
- // ext
- BYTE startcodeid:4;
- BYTE profile_levelescape:1;
- BYTE profile:3;
- BYTE level:4;
- BYTE progressive:1;
- BYTE chroma:2;
- BYTE lowdelay:1;
- // misc
- int arx, ary;
- };
-
- struct mpahdr
- {
- WORD sync:11;
- WORD version:2;
- WORD layer:2;
- WORD crc:1;
- WORD bitrate:4;
- WORD freq:2;
- WORD padding:1;
- WORD privatebit:1;
- WORD channels:2;
- WORD modeext:2;
- WORD copyright:1;
- WORD original:1;
- WORD emphasis:2;
-
- int nSamplesPerSec, FrameSize, nBytesPerSec;
- REFERENCE_TIME rtDuration;
- };
-
- struct aachdr
- {
- WORD sync:12;
- WORD version:1;
- WORD layer:2;
- WORD fcrc:1;
- WORD profile:2;
- WORD freq:4;
- WORD privatebit:1;
- WORD channels:3;
- WORD original:1;
- WORD home:1; // ?
-
- WORD copyright_id_bit:1;
- WORD copyright_id_start:1;
- WORD aac_frame_length:13;
- WORD adts_buffer_fullness:11;
- WORD no_raw_data_blocks_in_frame:2;
-
- WORD crc;
-
- int FrameSize, nBytesPerSec;
- REFERENCE_TIME rtDuration;
- };
-
- struct latm_aachdr
- {
- // nothing ;)
- };
-
- struct ac3hdr
- {
- WORD sync;
- WORD crc1;
- BYTE fscod:2;
- BYTE frmsizecod:6;
- BYTE bsid:5;
- BYTE bsmod:3;
- BYTE acmod:3;
- BYTE cmixlev:2;
- BYTE surmixlev:2;
- BYTE dsurmod:2;
- BYTE lfeon:1;
- BYTE sr_shift;
- // E-AC3 header
- BYTE frame_type;
- BYTE substreamid;
- WORD frame_size;
- BYTE sr_code;
- WORD sample_rate;
- BYTE num_blocks;
- // the rest is unimportant for us
- };
-
- struct dtshdr
- {
- DWORD sync;
- BYTE frametype:1;
- BYTE deficitsamplecount:5;
- BYTE fcrc:1;
- BYTE nblocks:7;
- WORD framebytes;
- BYTE amode:6;
- BYTE sfreq:4;
- BYTE rate:5;
-
- BYTE downmix:1;
- BYTE dynrange:1;
- BYTE timestamp:1;
- BYTE aux_data:1;
- BYTE hdcd:1;
- BYTE ext_descr:3;
- BYTE ext_coding:1;
- BYTE aspf:1;
- BYTE lfe:2;
- BYTE predictor_history:1;
- };
-
- struct lpcmhdr
- {
- BYTE emphasis:1;
- BYTE mute:1;
- BYTE reserved1:1;
- BYTE framenum:5;
- BYTE quantwordlen:2;
- BYTE freq:2; // 48, 96, 44.1, 32
- BYTE reserved2:1;
- BYTE channels:3; // +1
- BYTE drc; // 0x80: off
- };
-
- struct dvdalpcmhdr
- {
- // http://dvd-audio.sourceforge.net/spec/aob.shtml
- WORD firstaudioframe;
- BYTE unknown1;
- BYTE bitpersample1:4;
- BYTE bitpersample2:4;
- BYTE samplerate1:4;
- BYTE samplerate2:4;
- BYTE unknown2;
- BYTE groupassignment;
- BYTE unknown3;
- };
-
- struct hdmvlpcmhdr
- {
- WORD size;
- BYTE channels:4;
- BYTE samplerate:4;
- BYTE bitpersample:2;
- };
-
- struct mlphdr
- {
- DWORD size;
- //DWORD samplerate;
- //WORD bitdepth;
- //WORD channels;
- };
-
- struct dvdspuhdr
- {
- // nothing ;)
- };
-
- struct hdmvsubhdr
- {
- // nothing ;)
- };
-
- struct svcdspuhdr
- {
- // nothing ;)
- };
-
- struct cvdspuhdr
- {
- // nothing ;)
- };
-
- struct ps2audhdr
- {
- // 'SShd' + len (0x18)
- DWORD unk1;
- DWORD freq;
- DWORD channels;
- DWORD interleave; // bytes per channel
- // padding: FF .. FF
- // 'SSbd' + len
- // pcm or adpcm data
- };
-
- struct ps2subhdr
- {
- // nothing ;)
- };
-
- struct trhdr
- {
- BYTE sync; // 0x47
- BYTE error:1;
- BYTE payloadstart:1;
- BYTE transportpriority:1;
- WORD pid:13;
- BYTE scrambling:2;
- BYTE adapfield:1;
- BYTE payload:1;
- BYTE counter:4;
- // if adapfield set
- BYTE length;
- BYTE discontinuity:1;
- BYTE randomaccess:1;
- BYTE priority:1;
- BYTE fPCR:1;
- BYTE OPCR:1;
- BYTE splicingpoint:1;
- BYTE privatedata:1;
- BYTE extension:1;
- // TODO: add more fields here when the flags above are set (they aren't very interesting...)
- __int64 PCR;
-
- int bytes;
- __int64 next;
- };
-
- struct trsechdr
- {
- BYTE table_id;
- WORD section_syntax_indicator:1;
- WORD zero:1;
- WORD reserved1:2;
- WORD section_length:12;
- WORD transport_stream_id;
- BYTE reserved2:2;
- BYTE version_number:5;
- BYTE current_next_indicator:1;
- BYTE section_number;
- BYTE last_section_number;
- };
-
- // http://multimedia.cx/mirror/av_format_v1.pdf
- struct pvahdr
- {
- WORD sync; // 'VA'
- BYTE streamid; // 1 - video, 2 - audio
- BYTE counter;
- BYTE res1; // 0x55
- BYTE res2:3;
- BYTE fpts:1;
- BYTE postbytes:2;
- BYTE prebytes:2;
- WORD length;
- REFERENCE_TIME pts;
- };
-
- enum spsppsindex {
- index_unknown = -1,
- index_subsetsps = 0,
- index_sps = 1,
- index_pps1 = 2,
- index_pps2 = 3,
- };
-
- struct spsppsdata
- {
- BYTE buffer[MAX_SPSPPS];
- unsigned int size;
- bool complete;
- };
-
- struct avchdr
- {
- BYTE profile, level;
- unsigned int width, height;
- unsigned int views;
- unsigned int crop_left, crop_right, crop_top, crop_bottom;
- __int64 AvgTimePerFrame;
-
- struct sar {
- WORD num;
- WORD den;
- } sar;
-
- spsppsdata spspps[4];
- BYTE lastid;
-
- avchdr() {
- memset(spspps, 0, sizeof(spspps));
- lastid = 0;
- views = 1;
- AvgTimePerFrame = 0;
- }
- };
-
- struct vc1hdr
- {
- BYTE profile;
- BYTE level;
- BYTE chromaformat;
- BYTE frmrtq_postproc;
- BYTE bitrtq_postproc;
- BYTE postprocflag;
- BYTE broadcast;
- BYTE interlace;
- BYTE tfcntrflag;
- BYTE finterpflag;
- BYTE psf;
- unsigned int width, height;
- struct sar {
- BYTE num;
- BYTE den;
- } sar;
- };
-
- struct dvbsub
- {
- // nothing ;)
- };
+ enum mpeg_t {mpegunk, mpeg1, mpeg2};
+
+ struct pshdr {
+ mpeg_t type;
+ UINT64 scr, bitrate;
+ };
+
+ struct pssyshdr {
+ DWORD rate_bound;
+ BYTE video_bound, audio_bound;
+ bool fixed_rate, csps;
+ bool sys_video_loc_flag, sys_audio_loc_flag;
+ };
+
+ struct peshdr {
+ WORD len;
+
+ BYTE type: 2, fpts: 1, fdts: 1;
+ REFERENCE_TIME pts, dts;
+
+ // mpeg1 stuff
+ UINT64 std_buff_size;
+
+ // mpeg2 stuff
+ BYTE scrambling: 2, priority: 1, alignment: 1, copyright: 1, original: 1;
+ BYTE escr: 1, esrate: 1, dsmtrickmode: 1, morecopyright: 1, crc: 1, extension: 1;
+ BYTE hdrlen;
+
+ BYTE id_ext;
+
+ struct peshdr() {
+ memset(this, 0, sizeof(*this));
+ }
+ };
+
+ struct seqhdr {
+ WORD width;
+ WORD height;
+ BYTE ar: 4;
+ DWORD ifps;
+ DWORD bitrate;
+ DWORD vbv;
+ BYTE constrained: 1;
+ BYTE fiqm: 1;
+ BYTE iqm[64];
+ BYTE fniqm: 1;
+ BYTE niqm[64];
+ // ext
+ BYTE startcodeid: 4;
+ BYTE profile_levelescape: 1;
+ BYTE profile: 3;
+ BYTE level: 4;
+ BYTE progressive: 1;
+ BYTE chroma: 2;
+ BYTE lowdelay: 1;
+ // misc
+ int arx, ary;
+ };
+
+ struct mpahdr {
+ WORD sync: 11;
+ WORD version: 2;
+ WORD layer: 2;
+ WORD crc: 1;
+ WORD bitrate: 4;
+ WORD freq: 2;
+ WORD padding: 1;
+ WORD privatebit: 1;
+ WORD channels: 2;
+ WORD modeext: 2;
+ WORD copyright: 1;
+ WORD original: 1;
+ WORD emphasis: 2;
+
+ int nSamplesPerSec, FrameSize, nBytesPerSec;
+ REFERENCE_TIME rtDuration;
+ };
+
+ struct aachdr {
+ WORD sync: 12;
+ WORD version: 1;
+ WORD layer: 2;
+ WORD fcrc: 1;
+ WORD profile: 2;
+ WORD freq: 4;
+ WORD privatebit: 1;
+ WORD channels: 3;
+ WORD original: 1;
+ WORD home: 1; // ?
+
+ WORD copyright_id_bit: 1;
+ WORD copyright_id_start: 1;
+ WORD aac_frame_length: 13;
+ WORD adts_buffer_fullness: 11;
+ WORD no_raw_data_blocks_in_frame: 2;
+
+ WORD crc;
+
+ int FrameSize, nBytesPerSec;
+ REFERENCE_TIME rtDuration;
+ };
+
+ struct latm_aachdr {
+ // nothing ;)
+ };
+
+ struct ac3hdr {
+ WORD sync;
+ WORD crc1;
+ BYTE fscod: 2;
+ BYTE frmsizecod: 6;
+ BYTE bsid: 5;
+ BYTE bsmod: 3;
+ BYTE acmod: 3;
+ BYTE cmixlev: 2;
+ BYTE surmixlev: 2;
+ BYTE dsurmod: 2;
+ BYTE lfeon: 1;
+ BYTE sr_shift;
+ // E-AC3 header
+ BYTE frame_type;
+ BYTE substreamid;
+ WORD frame_size;
+ BYTE sr_code;
+ WORD sample_rate;
+ BYTE num_blocks;
+ // the rest is unimportant for us
+ };
+
+ struct dtshdr {
+ DWORD sync;
+ BYTE frametype: 1;
+ BYTE deficitsamplecount: 5;
+ BYTE fcrc: 1;
+ BYTE nblocks: 7;
+ WORD framebytes;
+ BYTE amode: 6;
+ BYTE sfreq: 4;
+ BYTE rate: 5;
+
+ BYTE downmix: 1;
+ BYTE dynrange: 1;
+ BYTE timestamp: 1;
+ BYTE aux_data: 1;
+ BYTE hdcd: 1;
+ BYTE ext_descr: 3;
+ BYTE ext_coding: 1;
+ BYTE aspf: 1;
+ BYTE lfe: 2;
+ BYTE predictor_history: 1;
+ };
+
+ struct lpcmhdr {
+ BYTE emphasis: 1;
+ BYTE mute: 1;
+ BYTE reserved1: 1;
+ BYTE framenum: 5;
+ BYTE quantwordlen: 2;
+ BYTE freq: 2; // 48, 96, 44.1, 32
+ BYTE reserved2: 1;
+ BYTE channels: 3; // +1
+ BYTE drc; // 0x80: off
+ };
+
+ struct dvdalpcmhdr {
+ // http://dvd-audio.sourceforge.net/spec/aob.shtml
+ WORD firstaudioframe;
+ BYTE unknown1;
+ BYTE bitpersample1: 4;
+ BYTE bitpersample2: 4;
+ BYTE samplerate1: 4;
+ BYTE samplerate2: 4;
+ BYTE unknown2;
+ BYTE groupassignment;
+ BYTE unknown3;
+ };
+
+ struct hdmvlpcmhdr {
+ WORD size;
+ BYTE channels: 4;
+ BYTE samplerate: 4;
+ BYTE bitpersample: 2;
+ };
+
+ struct mlphdr {
+ DWORD size;
+ //DWORD samplerate;
+ //WORD bitdepth;
+ //WORD channels;
+ };
+
+ struct dvdspuhdr {
+ // nothing ;)
+ };
+
+ struct hdmvsubhdr {
+ // nothing ;)
+ };
+
+ struct svcdspuhdr {
+ // nothing ;)
+ };
+
+ struct cvdspuhdr {
+ // nothing ;)
+ };
+
+ struct ps2audhdr {
+ // 'SShd' + len (0x18)
+ DWORD unk1;
+ DWORD freq;
+ DWORD channels;
+ DWORD interleave; // bytes per channel
+ // padding: FF .. FF
+ // 'SSbd' + len
+ // pcm or adpcm data
+ };
+
+ struct ps2subhdr {
+ // nothing ;)
+ };
+
+ struct trhdr {
+ BYTE sync; // 0x47
+ BYTE error: 1;
+ BYTE payloadstart: 1;
+ BYTE transportpriority: 1;
+ WORD pid: 13;
+ BYTE scrambling: 2;
+ BYTE adapfield: 1;
+ BYTE payload: 1;
+ BYTE counter: 4;
+ // if adapfield set
+ BYTE length;
+ BYTE discontinuity: 1;
+ BYTE randomaccess: 1;
+ BYTE priority: 1;
+ BYTE fPCR: 1;
+ BYTE OPCR: 1;
+ BYTE splicingpoint: 1;
+ BYTE privatedata: 1;
+ BYTE extension: 1;
+ // TODO: add more fields here when the flags above are set (they aren't very interesting...)
+ __int64 PCR;
+
+ int bytes;
+ __int64 next;
+ };
+
+ struct trsechdr {
+ BYTE table_id;
+ WORD section_syntax_indicator: 1;
+ WORD zero: 1;
+ WORD reserved1: 2;
+ WORD section_length: 12;
+ WORD transport_stream_id;
+ BYTE reserved2: 2;
+ BYTE version_number: 5;
+ BYTE current_next_indicator: 1;
+ BYTE section_number;
+ BYTE last_section_number;
+ };
+
+ // http://multimedia.cx/mirror/av_format_v1.pdf
+ struct pvahdr {
+ WORD sync; // 'VA'
+ BYTE streamid; // 1 - video, 2 - audio
+ BYTE counter;
+ BYTE res1; // 0x55
+ BYTE res2: 3;
+ BYTE fpts: 1;
+ BYTE postbytes: 2;
+ BYTE prebytes: 2;
+ WORD length;
+ REFERENCE_TIME pts;
+ };
+
+ enum spsppsindex {
+ index_unknown = -1,
+ index_subsetsps = 0,
+ index_sps = 1,
+ index_pps1 = 2,
+ index_pps2 = 3,
+ };
+
+ struct spsppsdata {
+ BYTE buffer[MAX_SPSPPS];
+ unsigned int size;
+ bool complete;
+ };
+
+ struct avchdr {
+ BYTE profile, level;
+ unsigned int width, height;
+ unsigned int views;
+ unsigned int crop_left, crop_right, crop_top, crop_bottom;
+ __int64 AvgTimePerFrame;
+
+ struct sar {
+ WORD num;
+ WORD den;
+ } sar;
+
+ spsppsdata spspps[4];
+ BYTE lastid;
+
+ avchdr() {
+ memset(spspps, 0, sizeof(spspps));
+ lastid = 0;
+ views = 1;
+ AvgTimePerFrame = 0;
+ }
+ };
+
+ struct vc1hdr {
+ BYTE profile;
+ BYTE level;
+ BYTE chromaformat;
+ BYTE frmrtq_postproc;
+ BYTE bitrtq_postproc;
+ BYTE postprocflag;
+ BYTE broadcast;
+ BYTE interlace;
+ BYTE tfcntrflag;
+ BYTE finterpflag;
+ BYTE psf;
+ unsigned int width, height;
+ struct sar {
+ BYTE num;
+ BYTE den;
+ } sar;
+ };
+
+ struct dvbsub {
+ // nothing ;)
+ };
#pragma pack(pop)
- bool Read(pshdr& h);
- bool Read(pssyshdr& h);
- bool Read(peshdr& h, BYTE code);
- bool Read(seqhdr& h, int len, CMediaType* pmt = NULL);
- bool Read(mpahdr& h, int len, bool fAllowV25, CMediaType* pmt = NULL);
- bool Read(aachdr& h, int len, CMediaType* pmt = NULL, MPEG_TYPES m_type = mpeg_es);
- bool Read(latm_aachdr& h, int len, CMediaType* pmt = NULL);
- bool Read(ac3hdr& h, int len, CMediaType* pmt = NULL, bool find_sync = true, bool AC3CoreOnly = true);
- bool Read(dtshdr& h, int len, CMediaType* pmt = NULL, bool find_sync = true);
- bool Read(lpcmhdr& h, CMediaType* pmt = NULL);
- bool Read(dvdalpcmhdr& h, int len, CMediaType* pmt = NULL);
- bool Read(hdmvlpcmhdr& h, CMediaType* pmt = NULL);
- bool Read(mlphdr& h, int len, CMediaType* pmt = NULL, bool find_sync = false);
- bool Read(dvdspuhdr& h, CMediaType* pmt = NULL);
- bool Read(hdmvsubhdr& h, CMediaType* pmt = NULL, const char* language_code = NULL);
- bool Read(svcdspuhdr& h, CMediaType* pmt = NULL);
- bool Read(cvdspuhdr& h, CMediaType* pmt = NULL);
- bool Read(ps2audhdr& h, CMediaType* pmt = NULL);
- bool Read(ps2subhdr& h, CMediaType* pmt = NULL);
- bool Read(trhdr& h, bool fSync = true);
- bool Read(trsechdr& h);
- bool Read(pvahdr& h, bool fSync = true);
- bool Read(avchdr& h, int len, CMediaType* pmt = NULL);
- bool Read(vc1hdr& h, int len, CMediaType* pmt = NULL, int guid_flag = 1);
- bool Read(dvbsub& h, int len, CMediaType* pmt = NULL);
- bool Read(avchdr& h, spsppsindex index);
-
- int HrdParameters(CGolombBuffer& gb);
- void RemoveMpegEscapeCode(BYTE* dst, BYTE* src, int length);
+ bool Read(pshdr& h);
+ bool Read(pssyshdr& h);
+ bool Read(peshdr& h, BYTE code);
+ bool Read(seqhdr& h, int len, CMediaType* pmt = NULL);
+ bool Read(mpahdr& h, int len, bool fAllowV25, CMediaType* pmt = NULL);
+ bool Read(aachdr& h, int len, CMediaType* pmt = NULL, MPEG_TYPES m_type = mpeg_es);
+ bool Read(latm_aachdr& h, int len, CMediaType* pmt = NULL);
+ bool Read(ac3hdr& h, int len, CMediaType* pmt = NULL, bool find_sync = true, bool AC3CoreOnly = true);
+ bool Read(dtshdr& h, int len, CMediaType* pmt = NULL, bool find_sync = true);
+ bool Read(lpcmhdr& h, CMediaType* pmt = NULL);
+ bool Read(dvdalpcmhdr& h, int len, CMediaType* pmt = NULL);
+ bool Read(hdmvlpcmhdr& h, CMediaType* pmt = NULL);
+ bool Read(mlphdr& h, int len, CMediaType* pmt = NULL, bool find_sync = false);
+ bool Read(dvdspuhdr& h, CMediaType* pmt = NULL);
+ bool Read(hdmvsubhdr& h, CMediaType* pmt = NULL, const char* language_code = NULL);
+ bool Read(svcdspuhdr& h, CMediaType* pmt = NULL);
+ bool Read(cvdspuhdr& h, CMediaType* pmt = NULL);
+ bool Read(ps2audhdr& h, CMediaType* pmt = NULL);
+ bool Read(ps2subhdr& h, CMediaType* pmt = NULL);
+ bool Read(trhdr& h, bool fSync = true);
+ bool Read(trsechdr& h);
+ bool Read(pvahdr& h, bool fSync = true);
+ bool Read(avchdr& h, int len, CMediaType* pmt = NULL);
+ bool Read(vc1hdr& h, int len, CMediaType* pmt = NULL, int guid_flag = 1);
+ bool Read(dvbsub& h, int len, CMediaType* pmt = NULL);
+ bool Read(avchdr& h, spsppsindex index);
+
+ int HrdParameters(CGolombBuffer& gb);
+ void RemoveMpegEscapeCode(BYTE* dst, BYTE* src, int length);
};
diff --git a/src/filters/parser/BaseSplitter/MultiFiles.cpp b/src/filters/parser/BaseSplitter/MultiFiles.cpp
index 65a5b946c..d8d308131 100644
--- a/src/filters/parser/BaseSplitter/MultiFiles.cpp
+++ b/src/filters/parser/BaseSplitter/MultiFiles.cpp
@@ -28,173 +28,173 @@
IMPLEMENT_DYNAMIC(CMultiFiles, CObject)
CMultiFiles::CMultiFiles()
- : m_hFile(INVALID_HANDLE_VALUE)
- , m_llTotalLength(0)
- , m_nCurPart(-1)
- , m_pCurrentPTSOffset(NULL)
+ : m_hFile(INVALID_HANDLE_VALUE)
+ , m_llTotalLength(0)
+ , m_nCurPart(-1)
+ , m_pCurrentPTSOffset(NULL)
{
}
void CMultiFiles::Reset()
{
- m_strFiles.RemoveAll();
- m_FilesSize.RemoveAll();
- m_rtPtsOffsets.RemoveAll();
- m_llTotalLength = 0;
+ m_strFiles.RemoveAll();
+ m_FilesSize.RemoveAll();
+ m_rtPtsOffsets.RemoveAll();
+ m_llTotalLength = 0;
}
BOOL CMultiFiles::Open(LPCTSTR lpszFileName, UINT nOpenFlags)
{
- Reset();
- m_strFiles.Add (lpszFileName);
+ Reset();
+ m_strFiles.Add(lpszFileName);
- return OpenPart(0);
+ return OpenPart(0);
}
BOOL CMultiFiles::OpenFiles(CAtlList<CHdmvClipInfo::PlaylistItem>& files, UINT nOpenFlags)
{
- POSITION pos = files.GetHeadPosition();
- LARGE_INTEGER llSize;
- int nPos = 0;
- REFERENCE_TIME rtDur = 0;
-
- Reset();
- while (pos) {
- CHdmvClipInfo::PlaylistItem& s = files.GetNext(pos);
- m_strFiles.Add(s.m_strFileName);
- if (!OpenPart(nPos)) {
- return false;
- }
-
- llSize.QuadPart = 0;
- GetFileSizeEx (m_hFile, &llSize);
- m_llTotalLength += llSize.QuadPart;
- m_FilesSize.Add (llSize.QuadPart);
- m_rtPtsOffsets.Add (rtDur);
- rtDur += s.Duration();
- nPos++;
- }
-
- if (files.GetCount() > 1) {
- ClosePart();
- }
-
- return TRUE;
+ POSITION pos = files.GetHeadPosition();
+ LARGE_INTEGER llSize;
+ int nPos = 0;
+ REFERENCE_TIME rtDur = 0;
+
+ Reset();
+ while (pos) {
+ CHdmvClipInfo::PlaylistItem& s = files.GetNext(pos);
+ m_strFiles.Add(s.m_strFileName);
+ if (!OpenPart(nPos)) {
+ return false;
+ }
+
+ llSize.QuadPart = 0;
+ GetFileSizeEx(m_hFile, &llSize);
+ m_llTotalLength += llSize.QuadPart;
+ m_FilesSize.Add(llSize.QuadPart);
+ m_rtPtsOffsets.Add(rtDur);
+ rtDur += s.Duration();
+ nPos++;
+ }
+
+ if (files.GetCount() > 1) {
+ ClosePart();
+ }
+
+ return TRUE;
}
ULONGLONG CMultiFiles::Seek(LONGLONG lOff, UINT nFrom)
{
- LARGE_INTEGER llNewPos;
- LARGE_INTEGER llOff;
-
- if (m_strFiles.GetCount() == 1) {
- llOff.QuadPart = lOff;
- SetFilePointerEx (m_hFile, llOff, &llNewPos, nFrom);
-
- return llNewPos.QuadPart;
- } else {
- ULONGLONG lAbsolutePos = GetAbsolutePosition(lOff, nFrom);
- int nNewPart = 0;
- ULONGLONG llSum = 0;
-
- while (m_FilesSize[nNewPart]+llSum <= lAbsolutePos) {
- llSum += m_FilesSize[nNewPart];
- nNewPart++;
- }
-
- OpenPart (nNewPart);
- llOff.QuadPart = lAbsolutePos - llSum;
- SetFilePointerEx (m_hFile, llOff, &llNewPos, FILE_BEGIN);
-
- return llSum + llNewPos.QuadPart;
- }
+ LARGE_INTEGER llNewPos;
+ LARGE_INTEGER llOff;
+
+ if (m_strFiles.GetCount() == 1) {
+ llOff.QuadPart = lOff;
+ SetFilePointerEx(m_hFile, llOff, &llNewPos, nFrom);
+
+ return llNewPos.QuadPart;
+ } else {
+ ULONGLONG lAbsolutePos = GetAbsolutePosition(lOff, nFrom);
+ int nNewPart = 0;
+ ULONGLONG llSum = 0;
+
+ while (m_FilesSize[nNewPart] + llSum <= lAbsolutePos) {
+ llSum += m_FilesSize[nNewPart];
+ nNewPart++;
+ }
+
+ OpenPart(nNewPart);
+ llOff.QuadPart = lAbsolutePos - llSum;
+ SetFilePointerEx(m_hFile, llOff, &llNewPos, FILE_BEGIN);
+
+ return llSum + llNewPos.QuadPart;
+ }
}
ULONGLONG CMultiFiles::GetAbsolutePosition(LONGLONG lOff, UINT nFrom)
{
- LARGE_INTEGER llNoMove = {0, 0};
- LARGE_INTEGER llCurPos;
-
- switch (nFrom) {
- case begin :
- return lOff;
- case current :
- SetFilePointerEx (m_hFile, llNoMove, &llCurPos, FILE_CURRENT);
- return llCurPos.QuadPart + lOff;
- case end :
- return m_llTotalLength - lOff;
- default:
- return 0; // just used to quash "not all control paths return a value" warning
- }
+ LARGE_INTEGER llNoMove = {0, 0};
+ LARGE_INTEGER llCurPos;
+
+ switch (nFrom) {
+ case begin :
+ return lOff;
+ case current :
+ SetFilePointerEx(m_hFile, llNoMove, &llCurPos, FILE_CURRENT);
+ return llCurPos.QuadPart + lOff;
+ case end :
+ return m_llTotalLength - lOff;
+ default:
+ return 0; // just used to quash "not all control paths return a value" warning
+ }
}
ULONGLONG CMultiFiles::GetLength() const
{
- if (m_strFiles.GetCount() == 1) {
- LARGE_INTEGER llSize;
- GetFileSizeEx (m_hFile, &llSize);
- return llSize.QuadPart;
- } else {
- return m_llTotalLength;
- }
+ if (m_strFiles.GetCount() == 1) {
+ LARGE_INTEGER llSize;
+ GetFileSizeEx(m_hFile, &llSize);
+ return llSize.QuadPart;
+ } else {
+ return m_llTotalLength;
+ }
}
UINT CMultiFiles::Read(void* lpBuf, UINT nCount)
{
- DWORD dwRead;
- do {
- if (!ReadFile(m_hFile, lpBuf, nCount, &dwRead, NULL)) {
- break;
- }
-
- if (dwRead != nCount && (m_nCurPart < 0 || (size_t)m_nCurPart < m_strFiles.GetCount()-1)) {
- OpenPart (m_nCurPart+1);
- lpBuf = (void*)((BYTE*)lpBuf + dwRead);
- nCount -= dwRead;
- }
- } while (nCount != dwRead && (m_nCurPart < 0 || (size_t)m_nCurPart < m_strFiles.GetCount()-1));
- return dwRead;
+ DWORD dwRead;
+ do {
+ if (!ReadFile(m_hFile, lpBuf, nCount, &dwRead, NULL)) {
+ break;
+ }
+
+ if (dwRead != nCount && (m_nCurPart < 0 || (size_t)m_nCurPart < m_strFiles.GetCount() - 1)) {
+ OpenPart(m_nCurPart + 1);
+ lpBuf = (void*)((BYTE*)lpBuf + dwRead);
+ nCount -= dwRead;
+ }
+ } while (nCount != dwRead && (m_nCurPart < 0 || (size_t)m_nCurPart < m_strFiles.GetCount() - 1));
+ return dwRead;
}
void CMultiFiles::Close()
{
- ClosePart();
- Reset();
+ ClosePart();
+ Reset();
}
CMultiFiles::~CMultiFiles()
{
- Close();
+ Close();
}
BOOL CMultiFiles::OpenPart(int nPart)
{
- if (m_nCurPart == nPart) {
- return TRUE;
- } else {
- CString fn;
+ if (m_nCurPart == nPart) {
+ return TRUE;
+ } else {
+ CString fn;
- ClosePart();
+ ClosePart();
- fn = m_strFiles.GetAt(nPart);
- m_hFile = CreateFile (fn, GENERIC_READ, FILE_SHARE_DELETE|FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
+ fn = m_strFiles.GetAt(nPart);
+ m_hFile = CreateFile(fn, GENERIC_READ, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
- if (m_hFile != INVALID_HANDLE_VALUE) {
- m_nCurPart = nPart;
- if (m_pCurrentPTSOffset != NULL) {
- *m_pCurrentPTSOffset = m_rtPtsOffsets[nPart];
- }
- }
+ if (m_hFile != INVALID_HANDLE_VALUE) {
+ m_nCurPart = nPart;
+ if (m_pCurrentPTSOffset != NULL) {
+ *m_pCurrentPTSOffset = m_rtPtsOffsets[nPart];
+ }
+ }
- return (m_hFile != INVALID_HANDLE_VALUE);
- }
+ return (m_hFile != INVALID_HANDLE_VALUE);
+ }
}
void CMultiFiles::ClosePart()
{
- if (m_hFile != INVALID_HANDLE_VALUE) {
- CloseHandle (m_hFile);
- m_hFile = INVALID_HANDLE_VALUE;
- m_nCurPart = -1;
- }
+ if (m_hFile != INVALID_HANDLE_VALUE) {
+ CloseHandle(m_hFile);
+ m_hFile = INVALID_HANDLE_VALUE;
+ m_nCurPart = -1;
+ }
}
diff --git a/src/filters/parser/BaseSplitter/MultiFiles.h b/src/filters/parser/BaseSplitter/MultiFiles.h
index 7df49c0fd..7f1ac0c42 100644
--- a/src/filters/parser/BaseSplitter/MultiFiles.h
+++ b/src/filters/parser/BaseSplitter/MultiFiles.h
@@ -27,73 +27,73 @@
class CMultiFiles : public CObject
{
- DECLARE_DYNAMIC(CMultiFiles)
+ DECLARE_DYNAMIC(CMultiFiles)
public:
- // Flag values
- enum OpenFlags {
- modeRead = (int) 0x00000,
- modeWrite = (int) 0x00001,
- modeReadWrite = (int) 0x00002,
- shareCompat = (int) 0x00000,
- shareExclusive = (int) 0x00010,
- shareDenyWrite = (int) 0x00020,
- shareDenyRead = (int) 0x00030,
- shareDenyNone = (int) 0x00040,
- modeNoInherit = (int) 0x00080,
- modeCreate = (int) 0x01000,
- modeNoTruncate = (int) 0x02000,
- typeText = (int) 0x04000, // typeText and typeBinary are
- typeBinary = (int) 0x08000, // used in derived classes only
- osNoBuffer = (int) 0x10000,
- osWriteThrough = (int) 0x20000,
- osRandomAccess = (int) 0x40000,
- osSequentialScan = (int) 0x80000,
- };
+ // Flag values
+ enum OpenFlags {
+ modeRead = (int) 0x00000,
+ modeWrite = (int) 0x00001,
+ modeReadWrite = (int) 0x00002,
+ shareCompat = (int) 0x00000,
+ shareExclusive = (int) 0x00010,
+ shareDenyWrite = (int) 0x00020,
+ shareDenyRead = (int) 0x00030,
+ shareDenyNone = (int) 0x00040,
+ modeNoInherit = (int) 0x00080,
+ modeCreate = (int) 0x01000,
+ modeNoTruncate = (int) 0x02000,
+ typeText = (int) 0x04000, // typeText and typeBinary are
+ typeBinary = (int) 0x08000, // used in derived classes only
+ osNoBuffer = (int) 0x10000,
+ osWriteThrough = (int) 0x20000,
+ osRandomAccess = (int) 0x40000,
+ osSequentialScan = (int) 0x80000,
+ };
- enum Attribute {
- normal = 0x00,
- readOnly = 0x01,
- hidden = 0x02,
- system = 0x04,
- volume = 0x08,
- directory = 0x10,
- archive = 0x20
- };
+ enum Attribute {
+ normal = 0x00,
+ readOnly = 0x01,
+ hidden = 0x02,
+ system = 0x04,
+ volume = 0x08,
+ directory = 0x10,
+ archive = 0x20
+ };
- enum SeekPosition { begin = 0x0, current = 0x1, end = 0x2 };
+ enum SeekPosition { begin = 0x0, current = 0x1, end = 0x2 };
- // Constructors
- CMultiFiles();
+ // Constructors
+ CMultiFiles();
- CString m_strFileName;
+ CString m_strFileName;
- // Operations
- virtual BOOL Open(LPCTSTR lpszFileName, UINT nOpenFlags);
- virtual BOOL OpenFiles(CAtlList<CHdmvClipInfo::PlaylistItem>& files, UINT nOpenFlags);
+ // Operations
+ virtual BOOL Open(LPCTSTR lpszFileName, UINT nOpenFlags);
+ virtual BOOL OpenFiles(CAtlList<CHdmvClipInfo::PlaylistItem>& files, UINT nOpenFlags);
- virtual ULONGLONG Seek(LONGLONG lOff, UINT nFrom);
- virtual ULONGLONG GetLength() const;
+ virtual ULONGLONG Seek(LONGLONG lOff, UINT nFrom);
+ virtual ULONGLONG GetLength() const;
- virtual UINT Read(void* lpBuf, UINT nCount);
- virtual void Close();
+ virtual UINT Read(void* lpBuf, UINT nCount);
+ virtual void Close();
- // Implementation
+ // Implementation
public:
- virtual ~CMultiFiles();
+ virtual ~CMultiFiles();
protected:
- REFERENCE_TIME* m_pCurrentPTSOffset;
- CAtlArray<CString> m_strFiles;
- CAtlArray<ULONGLONG> m_FilesSize;
- CAtlArray<REFERENCE_TIME> m_rtPtsOffsets;
- HANDLE m_hFile;
- int m_nCurPart;
- ULONGLONG m_llTotalLength;
+ REFERENCE_TIME* m_pCurrentPTSOffset;
+ CAtlArray<CString> m_strFiles;
+ CAtlArray<ULONGLONG> m_FilesSize;
+ CAtlArray<REFERENCE_TIME> m_rtPtsOffsets;
+ HANDLE m_hFile;
+ int m_nCurPart;
+ ULONGLONG m_llTotalLength;
- BOOL OpenPart(int nPart);
- void ClosePart();
- ULONGLONG GetAbsolutePosition(LONGLONG lOff, UINT nFrom);
- void Reset();
+ BOOL OpenPart(int nPart);
+ void ClosePart();
+ ULONGLONG GetAbsolutePosition(LONGLONG lOff, UINT nFrom);
+ void Reset();
};
diff --git a/src/filters/parser/DSMSplitter/DSMSplitter.cpp b/src/filters/parser/DSMSplitter/DSMSplitter.cpp
index e0bf825ca..81f17ae6b 100644
--- a/src/filters/parser/DSMSplitter/DSMSplitter.cpp
+++ b/src/filters/parser/DSMSplitter/DSMSplitter.cpp
@@ -33,46 +33,46 @@
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_DirectShowMedia},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_DirectShowMedia},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CDSMSplitterFilter), DSMSplitterName, MERIT_NORMAL, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CDSMSourceFilter), DSMSourceName, MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CDSMSplitterFilter), DSMSplitterName, MERIT_NORMAL, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CDSMSourceFilter), DSMSourceName, MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDSMSplitterFilter>, NULL, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CDSMSourceFilter>, NULL, &sudFilter[1]},
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDSMSplitterFilter>, NULL, &sudFilter[0]},
+ {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CDSMSourceFilter>, NULL, &sudFilter[1]},
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- CString str;
- str.Format(_T("0,%d,,%%0%dI64x"), DSMSW_SIZE, DSMSW_SIZE*2);
- str.Format(CString(str), DSMSW);
+ CString str;
+ str.Format(_T("0,%d,,%%0%dI64x"), DSMSW_SIZE, DSMSW_SIZE * 2);
+ str.Format(CString(str), DSMSW);
- RegisterSourceFilter(
- CLSID_AsyncReader,
- MEDIASUBTYPE_DirectShowMedia,
- str, NULL);
+ RegisterSourceFilter(
+ CLSID_AsyncReader,
+ MEDIASUBTYPE_DirectShowMedia,
+ str, NULL);
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- UnRegisterSourceFilter(MEDIASUBTYPE_DirectShowMedia);
+ UnRegisterSourceFilter(MEDIASUBTYPE_DirectShowMedia);
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -86,7 +86,7 @@ CFilterApp theApp;
//
CDSMSplitterFilter::CDSMSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("CDSMSplitterFilter"), pUnk, phr, __uuidof(this))
+ : CBaseSplitterFilter(NAME("CDSMSplitterFilter"), pUnk, phr, __uuidof(this))
{
}
@@ -96,190 +96,190 @@ CDSMSplitterFilter::~CDSMSplitterFilter()
STDMETHODIMP CDSMSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo)
{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
-
- if (m_pName && m_pName[0]==L'M' && m_pName[1]==L'P' && m_pName[2]==L'C') {
- (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
- } else {
- wcscpy_s(pInfo->achName, DSMSourceName);
- }
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
+ CheckPointer(pInfo, E_POINTER);
+ ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
+
+ if (m_pName && m_pName[0] == L'M' && m_pName[1] == L'P' && m_pName[2] == L'C') {
+ (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
+ } else {
+ wcscpy_s(pInfo->achName, DSMSourceName);
+ }
+ pInfo->pGraph = m_pGraph;
+ if (m_pGraph) {
+ m_pGraph->AddRef();
+ }
+
+ return S_OK;
}
static int compare_id(const void* id1, const void* id2)
{
- return (int)*(BYTE*)id1 - (int)*(BYTE*)id2;
+ return (int) * (BYTE*)id1 - (int) * (BYTE*)id2;
}
HRESULT CDSMSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
{
- CheckPointer(pAsyncReader, E_POINTER);
-
- HRESULT hr = E_FAIL;
-
- m_pFile.Free();
- m_pFile.Attach(DNew CDSMSplitterFile(pAsyncReader, hr, *this, *this));
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration = m_pFile->m_rtDuration;
-
- CAtlArray<BYTE> ids;
-
- POSITION pos = m_pFile->m_mts.GetStartPosition();
- while (pos) {
- BYTE id;
- CMediaType mt;
- m_pFile->m_mts.GetNextAssoc(pos, id, mt);
- ids.Add(id);
- }
-
- qsort(ids.GetData(), ids.GetCount(), sizeof(BYTE), compare_id);
-
- for (size_t i = 0; i < ids.GetCount(); i++) {
- BYTE id = ids[i];
- CMediaType& mt = m_pFile->m_mts[id];
-
- CStringW name, lang;
- name.Format(L"Output %02d", id);
-
- CAtlArray<CMediaType> mts;
- mts.Add(mt);
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, name, this, this, &hr));
-
- name.Empty();
-
- pos = m_pFile->m_sim[id].GetStartPosition();
- while (pos) {
- CStringA key;
- CStringW value;
- m_pFile->m_sim[id].GetNextAssoc(pos, key, value);
- pPinOut->SetProperty(CStringW(key), value);
-
- if (key == "NAME") {
- name = value;
- }
- if (key == "LANG") if ((lang = ISO6392ToLanguage(CStringA(CString(value)))).IsEmpty()) {
- lang = value;
- }
- }
-
- if (!name.IsEmpty() || !lang.IsEmpty()) {
- if (!name.IsEmpty()) {
- if (!lang.IsEmpty()) {
- name += L" (" + lang + L")";
- }
- } else if (!lang.IsEmpty()) {
- name = lang;
- }
- pPinOut->SetName(name);
- }
-
- EXECUTE_ASSERT(SUCCEEDED(AddOutputPin(id, pPinOut)));
- }
-
- pos = m_pFile->m_fim.GetStartPosition();
- while (pos) {
- CStringA key;
- CStringW value;
- m_pFile->m_fim.GetNextAssoc(pos, key, value);
- SetProperty(CStringW(key), value);
- }
-
- for (size_t i = 0; i < m_resources.GetCount(); i++) {
- const CDSMResource& r = m_resources[i];
- if (r.mime == "application/x-truetype-font" ||
- r.mime == "application/x-font-ttf" ||
- r.mime == "application/vnd.ms-opentype") {
- //m_fontinst.InstallFont(r.data);
- m_fontinst.InstallFontMemory(r.data.GetData(), r.data.GetCount());
- }
- }
-
- return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
+ CheckPointer(pAsyncReader, E_POINTER);
+
+ HRESULT hr = E_FAIL;
+
+ m_pFile.Free();
+ m_pFile.Attach(DNew CDSMSplitterFile(pAsyncReader, hr, *this, *this));
+ if (!m_pFile) {
+ return E_OUTOFMEMORY;
+ }
+ if (FAILED(hr)) {
+ m_pFile.Free();
+ return hr;
+ }
+
+ m_rtNewStart = m_rtCurrent = 0;
+ m_rtNewStop = m_rtStop = m_rtDuration = m_pFile->m_rtDuration;
+
+ CAtlArray<BYTE> ids;
+
+ POSITION pos = m_pFile->m_mts.GetStartPosition();
+ while (pos) {
+ BYTE id;
+ CMediaType mt;
+ m_pFile->m_mts.GetNextAssoc(pos, id, mt);
+ ids.Add(id);
+ }
+
+ qsort(ids.GetData(), ids.GetCount(), sizeof(BYTE), compare_id);
+
+ for (size_t i = 0; i < ids.GetCount(); i++) {
+ BYTE id = ids[i];
+ CMediaType& mt = m_pFile->m_mts[id];
+
+ CStringW name, lang;
+ name.Format(L"Output %02d", id);
+
+ CAtlArray<CMediaType> mts;
+ mts.Add(mt);
+
+ CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, name, this, this, &hr));
+
+ name.Empty();
+
+ pos = m_pFile->m_sim[id].GetStartPosition();
+ while (pos) {
+ CStringA key;
+ CStringW value;
+ m_pFile->m_sim[id].GetNextAssoc(pos, key, value);
+ pPinOut->SetProperty(CStringW(key), value);
+
+ if (key == "NAME") {
+ name = value;
+ }
+ if (key == "LANG") if ((lang = ISO6392ToLanguage(CStringA(CString(value)))).IsEmpty()) {
+ lang = value;
+ }
+ }
+
+ if (!name.IsEmpty() || !lang.IsEmpty()) {
+ if (!name.IsEmpty()) {
+ if (!lang.IsEmpty()) {
+ name += L" (" + lang + L")";
+ }
+ } else if (!lang.IsEmpty()) {
+ name = lang;
+ }
+ pPinOut->SetName(name);
+ }
+
+ EXECUTE_ASSERT(SUCCEEDED(AddOutputPin(id, pPinOut)));
+ }
+
+ pos = m_pFile->m_fim.GetStartPosition();
+ while (pos) {
+ CStringA key;
+ CStringW value;
+ m_pFile->m_fim.GetNextAssoc(pos, key, value);
+ SetProperty(CStringW(key), value);
+ }
+
+ for (size_t i = 0; i < m_resources.GetCount(); i++) {
+ const CDSMResource& r = m_resources[i];
+ if (r.mime == "application/x-truetype-font" ||
+ r.mime == "application/x-font-ttf" ||
+ r.mime == "application/vnd.ms-opentype") {
+ //m_fontinst.InstallFont(r.data);
+ m_fontinst.InstallFontMemory(r.data.GetData(), r.data.GetCount());
+ }
+ }
+
+ return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
}
bool CDSMSplitterFilter::DemuxInit()
{
- SetThreadName((DWORD)-1, "CDSMSplitterFilter");
- return true;
+ SetThreadName((DWORD) - 1, "CDSMSplitterFilter");
+ return true;
}
void CDSMSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
- m_pFile->Seek(m_pFile->FindSyncPoint(rt));
+ m_pFile->Seek(m_pFile->FindSyncPoint(rt));
}
bool CDSMSplitterFilter::DemuxLoop()
{
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- while (SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetRemaining()) {
- dsmp_t type;
- UINT64 len;
+ while (SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetRemaining()) {
+ dsmp_t type;
+ UINT64 len;
- if (!m_pFile->Sync(type, len)) {
- continue;
- }
+ if (!m_pFile->Sync(type, len)) {
+ continue;
+ }
- __int64 pos = m_pFile->GetPos();
+ __int64 pos = m_pFile->GetPos();
- if (type == DSMP_SAMPLE) {
- CAutoPtr<Packet> p(DNew Packet());
- if (m_pFile->Read(len, p)) {
- if (p->rtStart != Packet::INVALID_TIME) {
- p->rtStart -= m_pFile->m_rtFirst;
- p->rtStop -= m_pFile->m_rtFirst;
- }
+ if (type == DSMP_SAMPLE) {
+ CAutoPtr<Packet> p(DNew Packet());
+ if (m_pFile->Read(len, p)) {
+ if (p->rtStart != Packet::INVALID_TIME) {
+ p->rtStart -= m_pFile->m_rtFirst;
+ p->rtStop -= m_pFile->m_rtFirst;
+ }
- hr = DeliverPacket(p);
- }
- }
+ hr = DeliverPacket(p);
+ }
+ }
- m_pFile->Seek(pos + len);
- }
+ m_pFile->Seek(pos + len);
+ }
- return true;
+ return true;
}
// IKeyFrameInfo
STDMETHODIMP CDSMSplitterFilter::GetKeyFrameCount(UINT& nKFs)
{
- CheckPointer(m_pFile, E_UNEXPECTED);
- nKFs = m_pFile->m_sps.GetCount();
- return S_OK;
+ CheckPointer(m_pFile, E_UNEXPECTED);
+ nKFs = m_pFile->m_sps.GetCount();
+ return S_OK;
}
STDMETHODIMP CDSMSplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs)
{
- CheckPointer(pFormat, E_POINTER);
- CheckPointer(pKFs, E_POINTER);
- CheckPointer(m_pFile, E_UNEXPECTED);
+ CheckPointer(pFormat, E_POINTER);
+ CheckPointer(pKFs, E_POINTER);
+ CheckPointer(m_pFile, E_UNEXPECTED);
- if (*pFormat != TIME_FORMAT_MEDIA_TIME) {
- return E_INVALIDARG;
- }
+ if (*pFormat != TIME_FORMAT_MEDIA_TIME) {
+ return E_INVALIDARG;
+ }
- // these aren't really the keyframes, but quicky accessable points in the stream
- for (nKFs = 0; nKFs < m_pFile->m_sps.GetCount(); nKFs++) {
- pKFs[nKFs] = m_pFile->m_sps[nKFs].rt;
- }
+ // these aren't really the keyframes, but quicky accessable points in the stream
+ for (nKFs = 0; nKFs < m_pFile->m_sps.GetCount(); nKFs++) {
+ pKFs[nKFs] = m_pFile->m_sps[nKFs].rt;
+ }
- return S_OK;
+ return S_OK;
}
//
@@ -287,8 +287,8 @@ STDMETHODIMP CDSMSplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENCE_TIM
//
CDSMSourceFilter::CDSMSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CDSMSplitterFilter(pUnk, phr)
+ : CDSMSplitterFilter(pUnk, phr)
{
- m_clsid = __uuidof(this);
- m_pInput.Free();
+ m_clsid = __uuidof(this);
+ m_pInput.Free();
}
diff --git a/src/filters/parser/DSMSplitter/DSMSplitter.h b/src/filters/parser/DSMSplitter/DSMSplitter.h
index 7cdbb1ea2..0022b7795 100644
--- a/src/filters/parser/DSMSplitter/DSMSplitter.h
+++ b/src/filters/parser/DSMSplitter/DSMSplitter.h
@@ -32,32 +32,32 @@
#define DSMSourceName L"MPC DSM Source"
class __declspec(uuid("0912B4DD-A30A-4568-B590-7179EBB420EC"))
- CDSMSplitterFilter : public CBaseSplitterFilter
+ CDSMSplitterFilter : public CBaseSplitterFilter
{
protected:
- CAutoPtr<CDSMSplitterFile> m_pFile;
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
+ CAutoPtr<CDSMSplitterFile> m_pFile;
+ HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
+ bool DemuxInit();
+ void DemuxSeek(REFERENCE_TIME rt);
+ bool DemuxLoop();
public:
- CDSMSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
- virtual ~CDSMSplitterFilter();
+ CDSMSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
+ virtual ~CDSMSplitterFilter();
- // CBaseFilter
- STDMETHODIMP_(HRESULT) QueryFilterInfo(FILTER_INFO* pInfo);
+ // CBaseFilter
+ STDMETHODIMP_(HRESULT) QueryFilterInfo(FILTER_INFO* pInfo);
- // IKeyFrameInfo
+ // IKeyFrameInfo
- STDMETHODIMP_(HRESULT) GetKeyFrameCount(UINT& nKFs);
- STDMETHODIMP_(HRESULT) GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs);
+ STDMETHODIMP_(HRESULT) GetKeyFrameCount(UINT& nKFs);
+ STDMETHODIMP_(HRESULT) GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs);
};
class __declspec(uuid("803E8280-F3CE-4201-982C-8CD8FB512004"))
- CDSMSourceFilter : public CDSMSplitterFilter
+ CDSMSourceFilter : public CDSMSplitterFilter
{
public:
- CDSMSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
+ CDSMSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
};
diff --git a/src/filters/parser/DSMSplitter/DSMSplitterFile.cpp b/src/filters/parser/DSMSplitter/DSMSplitterFile.cpp
index f9375f52f..0bdd9257e 100644
--- a/src/filters/parser/DSMSplitter/DSMSplitterFile.cpp
+++ b/src/filters/parser/DSMSplitter/DSMSplitterFile.cpp
@@ -4,399 +4,399 @@
#include <moreuuids.h>
CDSMSplitterFile::CDSMSplitterFile(IAsyncReader* pReader, HRESULT& hr, IDSMResourceBagImpl& res, IDSMChapterBagImpl& chap)
- : CBaseSplitterFile(pReader, hr, DEFAULT_CACHE_LENGTH, false)
- , m_rtFirst(0)
- , m_rtDuration(0)
+ : CBaseSplitterFile(pReader, hr, DEFAULT_CACHE_LENGTH, false)
+ , m_rtFirst(0)
+ , m_rtDuration(0)
{
- if (FAILED(hr)) {
- return;
- }
+ if (FAILED(hr)) {
+ return;
+ }
- hr = Init(res, chap);
+ hr = Init(res, chap);
}
HRESULT CDSMSplitterFile::Init(IDSMResourceBagImpl& res, IDSMChapterBagImpl& chap)
{
- Seek(0);
-
- if (BitRead(DSMSW_SIZE<<3) != DSMSW || BitRead(5) != DSMP_FILEINFO) {
- return E_FAIL;
- }
-
- Seek(0);
-
- m_mts.RemoveAll();
- m_rtFirst = m_rtDuration = 0;
- m_fim.RemoveAll();
- m_sim.RemoveAll();
- res.ResRemoveAll();
- chap.ChapRemoveAll();
-
- dsmp_t type;
- UINT64 len;
- int limit = 65536;
-
- // examine the beginning of the file ...
-
- while (Sync(type, len, 0)) {
- __int64 pos = GetPos();
-
- if (type == DSMP_MEDIATYPE) {
- BYTE id;
- CMediaType mt;
- if (Read(len, id, mt)) {
- m_mts[id] = mt;
- }
- } else if (type == DSMP_SAMPLE) {
- Packet p;
- if (Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME) {
- m_rtFirst = p.rtStart;
- break;
- }
- } else if (type == DSMP_FILEINFO) {
- if ((BYTE)BitRead(8) > DSMF_VERSION) {
- return E_FAIL;
- }
- Read(len-1, m_fim);
- } else if (type == DSMP_STREAMINFO) {
- Read(len-1, m_sim[(BYTE)BitRead(8)]);
- } else if (type == DSMP_SYNCPOINTS) {
- Read(len, m_sps);
- } else if (type == DSMP_RESOURCE) {
- Read(len, res);
- } else if (type == DSMP_CHAPTERS) {
- Read(len, chap);
- }
-
- Seek(pos + len);
- }
-
- if (type != DSMP_SAMPLE) {
- return E_FAIL;
- }
-
- // ... and the end
-
- if (IsRandomAccess())
- for (int i = 1, j = (int)((GetLength()+limit/2)/limit); i <= j; i++) {
- __int64 seekpos = max(0, (__int64)GetLength()-i*limit);
- Seek(seekpos);
-
- while (Sync(type, len, limit) && GetPos() < seekpos+limit) {
- __int64 pos = GetPos();
-
- if (type == DSMP_SAMPLE) {
- Packet p;
- if (Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME) {
- m_rtDuration = max(m_rtDuration, p.rtStop - m_rtFirst); // max isn't really needed, only for safety
- i = j;
- }
- } else if (type == DSMP_SYNCPOINTS) {
- Read(len, m_sps);
- } else if (type == DSMP_RESOURCE) {
- Read(len, res);
- } else if (type == DSMP_CHAPTERS) {
- Read(len, chap);
- }
-
- Seek(pos + len);
- }
- }
-
- if (m_rtFirst < 0) {
- m_rtDuration += m_rtFirst;
- m_rtFirst = 0;
- }
-
- return m_mts.GetCount() > 0 ? S_OK : E_FAIL;
+ Seek(0);
+
+ if (BitRead(DSMSW_SIZE << 3) != DSMSW || BitRead(5) != DSMP_FILEINFO) {
+ return E_FAIL;
+ }
+
+ Seek(0);
+
+ m_mts.RemoveAll();
+ m_rtFirst = m_rtDuration = 0;
+ m_fim.RemoveAll();
+ m_sim.RemoveAll();
+ res.ResRemoveAll();
+ chap.ChapRemoveAll();
+
+ dsmp_t type;
+ UINT64 len;
+ int limit = 65536;
+
+ // examine the beginning of the file ...
+
+ while (Sync(type, len, 0)) {
+ __int64 pos = GetPos();
+
+ if (type == DSMP_MEDIATYPE) {
+ BYTE id;
+ CMediaType mt;
+ if (Read(len, id, mt)) {
+ m_mts[id] = mt;
+ }
+ } else if (type == DSMP_SAMPLE) {
+ Packet p;
+ if (Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME) {
+ m_rtFirst = p.rtStart;
+ break;
+ }
+ } else if (type == DSMP_FILEINFO) {
+ if ((BYTE)BitRead(8) > DSMF_VERSION) {
+ return E_FAIL;
+ }
+ Read(len - 1, m_fim);
+ } else if (type == DSMP_STREAMINFO) {
+ Read(len - 1, m_sim[(BYTE)BitRead(8)]);
+ } else if (type == DSMP_SYNCPOINTS) {
+ Read(len, m_sps);
+ } else if (type == DSMP_RESOURCE) {
+ Read(len, res);
+ } else if (type == DSMP_CHAPTERS) {
+ Read(len, chap);
+ }
+
+ Seek(pos + len);
+ }
+
+ if (type != DSMP_SAMPLE) {
+ return E_FAIL;
+ }
+
+ // ... and the end
+
+ if (IsRandomAccess())
+ for (int i = 1, j = (int)((GetLength() + limit / 2) / limit); i <= j; i++) {
+ __int64 seekpos = max(0, (__int64)GetLength() - i * limit);
+ Seek(seekpos);
+
+ while (Sync(type, len, limit) && GetPos() < seekpos + limit) {
+ __int64 pos = GetPos();
+
+ if (type == DSMP_SAMPLE) {
+ Packet p;
+ if (Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME) {
+ m_rtDuration = max(m_rtDuration, p.rtStop - m_rtFirst); // max isn't really needed, only for safety
+ i = j;
+ }
+ } else if (type == DSMP_SYNCPOINTS) {
+ Read(len, m_sps);
+ } else if (type == DSMP_RESOURCE) {
+ Read(len, res);
+ } else if (type == DSMP_CHAPTERS) {
+ Read(len, chap);
+ }
+
+ Seek(pos + len);
+ }
+ }
+
+ if (m_rtFirst < 0) {
+ m_rtDuration += m_rtFirst;
+ m_rtFirst = 0;
+ }
+
+ return m_mts.GetCount() > 0 ? S_OK : E_FAIL;
}
bool CDSMSplitterFile::Sync(dsmp_t& type, UINT64& len, __int64 limit)
{
- UINT64 pos;
- return Sync(pos, type, len, limit);
+ UINT64 pos;
+ return Sync(pos, type, len, limit);
}
bool CDSMSplitterFile::Sync(UINT64& syncpos, dsmp_t& type, UINT64& len, __int64 limit)
{
- BitByteAlign();
+ BitByteAlign();
- limit += DSMSW_SIZE;
+ limit += DSMSW_SIZE;
- for (UINT64 id = 0; (id&((1ui64<<(DSMSW_SIZE<<3))-1)) != DSMSW; id = (id << 8) | (BYTE)BitRead(8)) {
- if (limit-- <= 0 || GetRemaining() <= 2) {
- return false;
- }
- }
+ for (UINT64 id = 0; (id & ((1ui64 << (DSMSW_SIZE << 3)) - 1)) != DSMSW; id = (id << 8) | (BYTE)BitRead(8)) {
+ if (limit-- <= 0 || GetRemaining() <= 2) {
+ return false;
+ }
+ }
- syncpos = GetPos() - (DSMSW_SIZE<<3);
- type = (dsmp_t)BitRead(5);
- len = BitRead(((int)BitRead(3)+1)<<3);
+ syncpos = GetPos() - (DSMSW_SIZE << 3);
+ type = (dsmp_t)BitRead(5);
+ len = BitRead(((int)BitRead(3) + 1) << 3);
- return true;
+ return true;
}
bool CDSMSplitterFile::Read(__int64 len, BYTE& id, CMediaType& mt)
{
- id = (BYTE)BitRead(8);
- ByteRead((BYTE*)&mt.majortype, sizeof(mt.majortype));
- ByteRead((BYTE*)&mt.subtype, sizeof(mt.subtype));
- mt.bFixedSizeSamples = (BOOL)BitRead(1);
- mt.bTemporalCompression = (BOOL)BitRead(1);
- mt.lSampleSize = (ULONG)BitRead(30);
- ByteRead((BYTE*)&mt.formattype, sizeof(mt.formattype));
- len -= 5 + sizeof(GUID)*3;
- ASSERT(len >= 0);
- if (len > 0) {
- mt.AllocFormatBuffer((LONG)len);
- ByteRead(mt.Format(), mt.FormatLength());
- } else {
- mt.ResetFormatBuffer();
- }
- return true;
+ id = (BYTE)BitRead(8);
+ ByteRead((BYTE*)&mt.majortype, sizeof(mt.majortype));
+ ByteRead((BYTE*)&mt.subtype, sizeof(mt.subtype));
+ mt.bFixedSizeSamples = (BOOL)BitRead(1);
+ mt.bTemporalCompression = (BOOL)BitRead(1);
+ mt.lSampleSize = (ULONG)BitRead(30);
+ ByteRead((BYTE*)&mt.formattype, sizeof(mt.formattype));
+ len -= 5 + sizeof(GUID) * 3;
+ ASSERT(len >= 0);
+ if (len > 0) {
+ mt.AllocFormatBuffer((LONG)len);
+ ByteRead(mt.Format(), mt.FormatLength());
+ } else {
+ mt.ResetFormatBuffer();
+ }
+ return true;
}
bool CDSMSplitterFile::Read(__int64 len, Packet* p, bool fData)
{
- if (!p) {
- return false;
- }
-
- p->TrackNumber = (DWORD)BitRead(8);
- p->bSyncPoint = (BOOL)BitRead(1);
- bool fSign = !!BitRead(1);
- int iTimeStamp = (int)BitRead(3);
- int iDuration = (int)BitRead(3);
-
- if (fSign && !iTimeStamp) {
- ASSERT(!iDuration);
- p->rtStart = Packet::INVALID_TIME;
- p->rtStop = Packet::INVALID_TIME + 1;
- } else {
- p->rtStart = (REFERENCE_TIME)BitRead(iTimeStamp<<3) * (fSign ? -1 : 1);
- p->rtStop = p->rtStart + BitRead(iDuration<<3);
- }
-
- if (fData) {
- p->SetCount((INT_PTR)len - (2 + iTimeStamp + iDuration));
- ByteRead(p->GetData(), p->GetCount());
- }
-
- return true;
+ if (!p) {
+ return false;
+ }
+
+ p->TrackNumber = (DWORD)BitRead(8);
+ p->bSyncPoint = (BOOL)BitRead(1);
+ bool fSign = !!BitRead(1);
+ int iTimeStamp = (int)BitRead(3);
+ int iDuration = (int)BitRead(3);
+
+ if (fSign && !iTimeStamp) {
+ ASSERT(!iDuration);
+ p->rtStart = Packet::INVALID_TIME;
+ p->rtStop = Packet::INVALID_TIME + 1;
+ } else {
+ p->rtStart = (REFERENCE_TIME)BitRead(iTimeStamp << 3) * (fSign ? -1 : 1);
+ p->rtStop = p->rtStart + BitRead(iDuration << 3);
+ }
+
+ if (fData) {
+ p->SetCount((INT_PTR)len - (2 + iTimeStamp + iDuration));
+ ByteRead(p->GetData(), p->GetCount());
+ }
+
+ return true;
}
bool CDSMSplitterFile::Read(__int64 len, CAtlArray<SyncPoint>& sps)
{
- SyncPoint sp = {0, 0};
- sps.RemoveAll();
+ SyncPoint sp = {0, 0};
+ sps.RemoveAll();
- while (len > 0) {
- bool fSign = !!BitRead(1);
- int iTimeStamp = (int)BitRead(3);
- int iFilePos = (int)BitRead(3);
- BitRead(1); // reserved
+ while (len > 0) {
+ bool fSign = !!BitRead(1);
+ int iTimeStamp = (int)BitRead(3);
+ int iFilePos = (int)BitRead(3);
+ BitRead(1); // reserved
- sp.rt += (REFERENCE_TIME)BitRead(iTimeStamp<<3) * (fSign ? -1 : 1);
- sp.fp += BitRead(iFilePos<<3);
- sps.Add(sp);
+ sp.rt += (REFERENCE_TIME)BitRead(iTimeStamp << 3) * (fSign ? -1 : 1);
+ sp.fp += BitRead(iFilePos << 3);
+ sps.Add(sp);
- len -= 1 + iTimeStamp + iFilePos;
- }
+ len -= 1 + iTimeStamp + iFilePos;
+ }
- if (len != 0) {
- sps.RemoveAll();
- return false;
- }
+ if (len != 0) {
+ sps.RemoveAll();
+ return false;
+ }
- // TODO: sort sps
+ // TODO: sort sps
- return true;
+ return true;
}
bool CDSMSplitterFile::Read(__int64 len, CStreamInfoMap& im)
{
- while (len >= 5) {
- CStringA key;
- ByteRead((BYTE*)key.GetBufferSetLength(4), 4);
- len -= 4;
- len -= Read(len, im[key]);
- }
-
- return len == 0;
+ while (len >= 5) {
+ CStringA key;
+ ByteRead((BYTE*)key.GetBufferSetLength(4), 4);
+ len -= 4;
+ len -= Read(len, im[key]);
+ }
+
+ return len == 0;
}
bool CDSMSplitterFile::Read(__int64 len, IDSMResourceBagImpl& res)
{
- BYTE compression = (BYTE)BitRead(2);
- BYTE reserved = (BYTE)BitRead(6);
- UNREFERENCED_PARAMETER(reserved);
- len--;
+ BYTE compression = (BYTE)BitRead(2);
+ BYTE reserved = (BYTE)BitRead(6);
+ UNREFERENCED_PARAMETER(reserved);
+ len--;
- CDSMResource r;
- len -= Read(len, r.name);
- len -= Read(len, r.desc);
- len -= Read(len, r.mime);
+ CDSMResource r;
+ len -= Read(len, r.name);
+ len -= Read(len, r.desc);
+ len -= Read(len, r.mime);
- if (compression != 0) {
- return false; // TODO
- }
+ if (compression != 0) {
+ return false; // TODO
+ }
- r.data.SetCount((size_t)len);
- ByteRead(r.data.GetData(), r.data.GetCount());
+ r.data.SetCount((size_t)len);
+ ByteRead(r.data.GetData(), r.data.GetCount());
- res += r;
+ res += r;
- return true;
+ return true;
}
bool CDSMSplitterFile::Read(__int64 len, IDSMChapterBagImpl& chap)
{
- CDSMChapter c(0, L"");
+ CDSMChapter c(0, L"");
- while (len > 0) {
- bool fSign = !!BitRead(1);
- int iTimeStamp = (int)BitRead(3);
- BitRead(4); // reserved
- len--;
+ while (len > 0) {
+ bool fSign = !!BitRead(1);
+ int iTimeStamp = (int)BitRead(3);
+ BitRead(4); // reserved
+ len--;
- c.rt += (REFERENCE_TIME)BitRead(iTimeStamp<<3) * (fSign ? -1 : 1);
- len -= iTimeStamp;
- len -= Read(len, c.name);
+ c.rt += (REFERENCE_TIME)BitRead(iTimeStamp << 3) * (fSign ? -1 : 1);
+ len -= iTimeStamp;
+ len -= Read(len, c.name);
- chap += c;
- }
+ chap += c;
+ }
- chap.ChapSort();
+ chap.ChapSort();
- return len == 0;
+ return len == 0;
}
__int64 CDSMSplitterFile::Read(__int64 len, CStringW& str)
{
- char c;
- CStringA s;
- __int64 i = 0;
- while (i++ < len && (c = (char)BitRead(8)) != 0) {
- s += c;
- }
- str = UTF8To16(s);
- return i;
+ char c;
+ CStringA s;
+ __int64 i = 0;
+ while (i++ < len && (c = (char)BitRead(8)) != 0) {
+ s += c;
+ }
+ str = UTF8To16(s);
+ return i;
}
__int64 CDSMSplitterFile::FindSyncPoint(REFERENCE_TIME rt)
{
- if (/*!m_sps.IsEmpty()*/ m_sps.GetCount() > 1) {
- ptrdiff_t i = range_bsearch(m_sps, m_rtFirst + rt);
- return i >= 0 ? m_sps[i].fp : 0;
- }
-
- if (m_rtDuration <= 0 || rt <= m_rtFirst) {
- return 0;
- }
-
- // ok, do the hard way then
-
- dsmp_t type;
- UINT64 syncpos, len;
-
- // 1. find some boundaries close to rt's position (minpos, maxpos)
-
- __int64 minpos = 0, maxpos = GetLength();
-
- for (int i = 0; i < 10 && (maxpos - minpos) >= 1024*1024; i++) {
- Seek((minpos + maxpos) / 2);
-
- while (GetPos() < maxpos) {
- if (!Sync(syncpos, type, len)) {
- continue;
- }
-
- __int64 pos = GetPos();
-
- if (type == DSMP_SAMPLE) {
- Packet p;
- if (Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME) {
- REFERENCE_TIME dt = (p.rtStart -= m_rtFirst) - rt;
- if (dt >= 0) {
- maxpos = max((__int64)syncpos - 65536, minpos);
- } else {
- minpos = syncpos;
- }
- break;
- }
- }
-
- Seek(pos + len);
- }
- }
-
- // 2. find the first packet just after rt (maxpos)
-
- Seek(minpos);
-
- while (GetRemaining()) {
- if (!Sync(syncpos, type, len)) {
- continue;
- }
-
- __int64 pos = GetPos();
-
- if (type == DSMP_SAMPLE) {
- Packet p;
- if (Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME) {
- REFERENCE_TIME dt = (p.rtStart -= m_rtFirst) - rt;
- if (dt >= 0) {
- maxpos = (__int64)syncpos;
- break;
- }
- }
- }
-
- Seek(pos + len);
- }
-
- // 3. iterate backwards from maxpos and find at least one syncpoint for every stream, except for subtitle streams
-
- CAtlMap<BYTE,BYTE> ids;
-
- {
- POSITION pos = m_mts.GetStartPosition();
- while (pos) {
- BYTE id;
- CMediaType mt;
- m_mts.GetNextAssoc(pos, id, mt);
- if (mt.majortype != MEDIATYPE_Text && mt.majortype != MEDIATYPE_Subtitle) {
- ids[id] = 0;
- }
- }
- }
-
- __int64 ret = maxpos;
-
- while (maxpos > 0 && !ids.IsEmpty()) {
- minpos = max(0, maxpos - 65536);
-
- Seek(minpos);
-
- while (Sync(syncpos, type, len) && GetPos() < maxpos) {
- UINT64 pos = GetPos();
-
- if (type == DSMP_SAMPLE) {
- Packet p;
- if (Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME && p.bSyncPoint) {
- BYTE id = (BYTE)p.TrackNumber, tmp;
- if (ids.Lookup(id, tmp)) {
- ids.RemoveKey((BYTE)p.TrackNumber);
- ret = min(ret, (__int64)syncpos);
- }
- }
- }
-
- Seek(pos + len);
- }
-
- maxpos = minpos;
- }
-
- return ret;
+ if (/*!m_sps.IsEmpty()*/ m_sps.GetCount() > 1) {
+ ptrdiff_t i = range_bsearch(m_sps, m_rtFirst + rt);
+ return i >= 0 ? m_sps[i].fp : 0;
+ }
+
+ if (m_rtDuration <= 0 || rt <= m_rtFirst) {
+ return 0;
+ }
+
+ // ok, do the hard way then
+
+ dsmp_t type;
+ UINT64 syncpos, len;
+
+ // 1. find some boundaries close to rt's position (minpos, maxpos)
+
+ __int64 minpos = 0, maxpos = GetLength();
+
+ for (int i = 0; i < 10 && (maxpos - minpos) >= 1024 * 1024; i++) {
+ Seek((minpos + maxpos) / 2);
+
+ while (GetPos() < maxpos) {
+ if (!Sync(syncpos, type, len)) {
+ continue;
+ }
+
+ __int64 pos = GetPos();
+
+ if (type == DSMP_SAMPLE) {
+ Packet p;
+ if (Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME) {
+ REFERENCE_TIME dt = (p.rtStart -= m_rtFirst) - rt;
+ if (dt >= 0) {
+ maxpos = max((__int64)syncpos - 65536, minpos);
+ } else {
+ minpos = syncpos;
+ }
+ break;
+ }
+ }
+
+ Seek(pos + len);
+ }
+ }
+
+ // 2. find the first packet just after rt (maxpos)
+
+ Seek(minpos);
+
+ while (GetRemaining()) {
+ if (!Sync(syncpos, type, len)) {
+ continue;
+ }
+
+ __int64 pos = GetPos();
+
+ if (type == DSMP_SAMPLE) {
+ Packet p;
+ if (Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME) {
+ REFERENCE_TIME dt = (p.rtStart -= m_rtFirst) - rt;
+ if (dt >= 0) {
+ maxpos = (__int64)syncpos;
+ break;
+ }
+ }
+ }
+
+ Seek(pos + len);
+ }
+
+ // 3. iterate backwards from maxpos and find at least one syncpoint for every stream, except for subtitle streams
+
+ CAtlMap<BYTE, BYTE> ids;
+
+ {
+ POSITION pos = m_mts.GetStartPosition();
+ while (pos) {
+ BYTE id;
+ CMediaType mt;
+ m_mts.GetNextAssoc(pos, id, mt);
+ if (mt.majortype != MEDIATYPE_Text && mt.majortype != MEDIATYPE_Subtitle) {
+ ids[id] = 0;
+ }
+ }
+ }
+
+ __int64 ret = maxpos;
+
+ while (maxpos > 0 && !ids.IsEmpty()) {
+ minpos = max(0, maxpos - 65536);
+
+ Seek(minpos);
+
+ while (Sync(syncpos, type, len) && GetPos() < maxpos) {
+ UINT64 pos = GetPos();
+
+ if (type == DSMP_SAMPLE) {
+ Packet p;
+ if (Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME && p.bSyncPoint) {
+ BYTE id = (BYTE)p.TrackNumber, tmp;
+ if (ids.Lookup(id, tmp)) {
+ ids.RemoveKey((BYTE)p.TrackNumber);
+ ret = min(ret, (__int64)syncpos);
+ }
+ }
+ }
+
+ Seek(pos + len);
+ }
+
+ maxpos = minpos;
+ }
+
+ return ret;
}
diff --git a/src/filters/parser/DSMSplitter/DSMSplitterFile.h b/src/filters/parser/DSMSplitter/DSMSplitterFile.h
index b61e5e1b7..420ccd8f0 100644
--- a/src/filters/parser/DSMSplitter/DSMSplitterFile.h
+++ b/src/filters/parser/DSMSplitter/DSMSplitterFile.h
@@ -6,33 +6,33 @@
class CDSMSplitterFile : public CBaseSplitterFile
{
- HRESULT Init(IDSMResourceBagImpl& res, IDSMChapterBagImpl& chap);
+ HRESULT Init(IDSMResourceBagImpl& res, IDSMChapterBagImpl& chap);
public:
- CDSMSplitterFile(IAsyncReader* pReader, HRESULT& hr, IDSMResourceBagImpl& res, IDSMChapterBagImpl& chap);
-
- CAtlMap<BYTE, CMediaType> m_mts;
- REFERENCE_TIME m_rtFirst, m_rtDuration;
-
- struct SyncPoint {
- REFERENCE_TIME rt;
- __int64 fp;
- };
- CAtlArray<SyncPoint> m_sps;
-
- typedef CAtlMap<CStringA, CStringW, CStringElementTraits<CStringA>, CStringElementTraits<CStringW> > CStreamInfoMap;
- CStreamInfoMap m_fim;
- CAtlMap<BYTE, CStreamInfoMap> m_sim;
-
- bool Sync(dsmp_t& type, UINT64& len, __int64 limit = 65536);
- bool Sync(UINT64& syncpos, dsmp_t& type, UINT64& len, __int64 limit = 65536);
- bool Read(__int64 len, BYTE& id, CMediaType& mt);
- bool Read(__int64 len, Packet* p, bool fData = true);
- bool Read(__int64 len, CAtlArray<SyncPoint>& sps);
- bool Read(__int64 len, CStreamInfoMap& im);
- bool Read(__int64 len, IDSMResourceBagImpl& res);
- bool Read(__int64 len, IDSMChapterBagImpl& chap);
- __int64 Read(__int64 len, CStringW& str);
-
- __int64 FindSyncPoint(REFERENCE_TIME rt);
+ CDSMSplitterFile(IAsyncReader* pReader, HRESULT& hr, IDSMResourceBagImpl& res, IDSMChapterBagImpl& chap);
+
+ CAtlMap<BYTE, CMediaType> m_mts;
+ REFERENCE_TIME m_rtFirst, m_rtDuration;
+
+ struct SyncPoint {
+ REFERENCE_TIME rt;
+ __int64 fp;
+ };
+ CAtlArray<SyncPoint> m_sps;
+
+ typedef CAtlMap<CStringA, CStringW, CStringElementTraits<CStringA>, CStringElementTraits<CStringW> > CStreamInfoMap;
+ CStreamInfoMap m_fim;
+ CAtlMap<BYTE, CStreamInfoMap> m_sim;
+
+ bool Sync(dsmp_t& type, UINT64& len, __int64 limit = 65536);
+ bool Sync(UINT64& syncpos, dsmp_t& type, UINT64& len, __int64 limit = 65536);
+ bool Read(__int64 len, BYTE& id, CMediaType& mt);
+ bool Read(__int64 len, Packet* p, bool fData = true);
+ bool Read(__int64 len, CAtlArray<SyncPoint>& sps);
+ bool Read(__int64 len, CStreamInfoMap& im);
+ bool Read(__int64 len, IDSMResourceBagImpl& res);
+ bool Read(__int64 len, IDSMChapterBagImpl& chap);
+ __int64 Read(__int64 len, CStringW& str);
+
+ __int64 FindSyncPoint(REFERENCE_TIME rt);
};
diff --git a/src/filters/parser/FLVSplitter/FLVSplitter.cpp b/src/filters/parser/FLVSplitter/FLVSplitter.cpp
index f2d40b023..024757fd4 100644
--- a/src/filters/parser/FLVSplitter/FLVSplitter.cpp
+++ b/src/filters/parser/FLVSplitter/FLVSplitter.cpp
@@ -60,45 +60,45 @@
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_FLV},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_FLV},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
};
const AMOVIESETUP_MEDIATYPE sudPinTypesOut2[] = {
- {&MEDIATYPE_Video, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_NULL},
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CFLVSplitterFilter), FlvSplitterName, MERIT_NORMAL, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CFLVSourceFilter), FlvSourceName, MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CFLVSplitterFilter), FlvSplitterName, MERIT_NORMAL, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CFLVSourceFilter), FlvSourceName, MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CFLVSplitterFilter>, NULL, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CFLVSourceFilter>, NULL, &sudFilter[1]},
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CFLVSplitterFilter>, NULL, &sudFilter[0]},
+ {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CFLVSourceFilter>, NULL, &sudFilter[1]},
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- DeleteRegKey(_T("Media Type\\Extensions\\"), _T(".flv"));
+ DeleteRegKey(_T("Media Type\\Extensions\\"), _T(".flv"));
- RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_FLV, _T("0,4,,464C5601"), NULL);
+ RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_FLV, _T("0,4,,464C5601"), NULL);
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- UnRegisterSourceFilter(MEDIASUBTYPE_FLV);
+ UnRegisterSourceFilter(MEDIASUBTYPE_FLV);
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -112,792 +112,792 @@ CFilterApp theApp;
//
CFLVSplitterFilter::CFLVSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("CFLVSplitterFilter"), pUnk, phr, __uuidof(this))
+ : CBaseSplitterFilter(NAME("CFLVSplitterFilter"), pUnk, phr, __uuidof(this))
{
}
STDMETHODIMP CFLVSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo)
{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
-
- if (m_pName && m_pName[0]==L'M' && m_pName[1]==L'P' && m_pName[2]==L'C') {
- (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
- } else {
- wcscpy_s(pInfo->achName, FlvSourceName);
- }
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
+ CheckPointer(pInfo, E_POINTER);
+ ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
+
+ if (m_pName && m_pName[0] == L'M' && m_pName[1] == L'P' && m_pName[2] == L'C') {
+ (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
+ } else {
+ wcscpy_s(pInfo->achName, FlvSourceName);
+ }
+ pInfo->pGraph = m_pGraph;
+ if (m_pGraph) {
+ m_pGraph->AddRef();
+ }
+
+ return S_OK;
}
bool CFLVSplitterFilter::ReadTag(Tag& t)
{
- if (m_pFile->GetRemaining() < 15) {
- return false;
- }
-
- t.PreviousTagSize = (UINT32)m_pFile->BitRead(32);
- t.TagType = (BYTE)m_pFile->BitRead(8);
- t.DataSize = (UINT32)m_pFile->BitRead(24);
- t.TimeStamp = (UINT32)m_pFile->BitRead(24);
- t.TimeStamp |= (UINT32)m_pFile->BitRead(8) << 24;
- t.StreamID = (UINT32)m_pFile->BitRead(24);
-
- return m_pFile->GetRemaining() >= t.DataSize;
+ if (m_pFile->GetRemaining() < 15) {
+ return false;
+ }
+
+ t.PreviousTagSize = (UINT32)m_pFile->BitRead(32);
+ t.TagType = (BYTE)m_pFile->BitRead(8);
+ t.DataSize = (UINT32)m_pFile->BitRead(24);
+ t.TimeStamp = (UINT32)m_pFile->BitRead(24);
+ t.TimeStamp |= (UINT32)m_pFile->BitRead(8) << 24;
+ t.StreamID = (UINT32)m_pFile->BitRead(24);
+
+ return m_pFile->GetRemaining() >= t.DataSize;
}
bool CFLVSplitterFilter::ReadTag(AudioTag& at)
{
- if (!m_pFile->GetRemaining()) {
- return false;
- }
+ if (!m_pFile->GetRemaining()) {
+ return false;
+ }
- at.SoundFormat = (BYTE)m_pFile->BitRead(4);
- at.SoundRate = (BYTE)m_pFile->BitRead(2);
- at.SoundSize = (BYTE)m_pFile->BitRead(1);
- at.SoundType = (BYTE)m_pFile->BitRead(1);
+ at.SoundFormat = (BYTE)m_pFile->BitRead(4);
+ at.SoundRate = (BYTE)m_pFile->BitRead(2);
+ at.SoundSize = (BYTE)m_pFile->BitRead(1);
+ at.SoundType = (BYTE)m_pFile->BitRead(1);
- return true;
+ return true;
}
bool CFLVSplitterFilter::ReadTag(VideoTag& vt)
{
- if (!m_pFile->GetRemaining()) {
- return false;
- }
+ if (!m_pFile->GetRemaining()) {
+ return false;
+ }
- vt.FrameType = (BYTE)m_pFile->BitRead(4);
- vt.CodecID = (BYTE)m_pFile->BitRead(4);
+ vt.FrameType = (BYTE)m_pFile->BitRead(4);
+ vt.CodecID = (BYTE)m_pFile->BitRead(4);
- return true;
+ return true;
}
#ifndef NOVIDEOTWEAK
bool CFLVSplitterFilter::ReadTag(VideoTweak& vt)
{
- if (!m_pFile->GetRemaining()) {
- return false;
- }
+ if (!m_pFile->GetRemaining()) {
+ return false;
+ }
- vt.x = (BYTE)m_pFile->BitRead(4);
- vt.y = (BYTE)m_pFile->BitRead(4);
+ vt.x = (BYTE)m_pFile->BitRead(4);
+ vt.y = (BYTE)m_pFile->BitRead(4);
- return true;
+ return true;
}
#endif
bool CFLVSplitterFilter::Sync(__int64& pos)
{
- m_pFile->Seek(pos);
-
- while (m_pFile->GetRemaining() >= 15) {
- __int64 limit = m_pFile->GetRemaining();
- while (true) {
- BYTE b = (BYTE)m_pFile->BitRead(8);
- if (b == FLV_AUDIODATA || b == FLV_VIDEODATA) {
- break;
- }
- if (--limit < 15) {
- return false;
- }
- }
-
- pos = m_pFile->GetPos() - 5;
- m_pFile->Seek(pos);
-
- Tag ct;
- if (ReadTag(ct)) {
- __int64 next = m_pFile->GetPos() + ct.DataSize;
- if (next == m_pFile->GetLength() - 4) {
- m_pFile->Seek(pos);
- return true;
- } else if (next <= m_pFile->GetLength() - 19) {
- m_pFile->Seek(next);
- Tag nt;
- if (ReadTag(nt) && (nt.TagType == FLV_AUDIODATA || nt.TagType == FLV_VIDEODATA || nt.TagType == FLV_SCRIPTDATA)) {
- if ((nt.PreviousTagSize == ct.DataSize + 11) ||
- (m_IgnorePrevSizes &&
- nt.TimeStamp >= ct.TimeStamp &&
- nt.TimeStamp - ct.TimeStamp <= 1000)) {
- m_pFile->Seek(pos);
- return true;
- }
- }
- }
- }
-
- m_pFile->Seek(pos + 5);
- }
-
- return false;
+ m_pFile->Seek(pos);
+
+ while (m_pFile->GetRemaining() >= 15) {
+ __int64 limit = m_pFile->GetRemaining();
+ while (true) {
+ BYTE b = (BYTE)m_pFile->BitRead(8);
+ if (b == FLV_AUDIODATA || b == FLV_VIDEODATA) {
+ break;
+ }
+ if (--limit < 15) {
+ return false;
+ }
+ }
+
+ pos = m_pFile->GetPos() - 5;
+ m_pFile->Seek(pos);
+
+ Tag ct;
+ if (ReadTag(ct)) {
+ __int64 next = m_pFile->GetPos() + ct.DataSize;
+ if (next == m_pFile->GetLength() - 4) {
+ m_pFile->Seek(pos);
+ return true;
+ } else if (next <= m_pFile->GetLength() - 19) {
+ m_pFile->Seek(next);
+ Tag nt;
+ if (ReadTag(nt) && (nt.TagType == FLV_AUDIODATA || nt.TagType == FLV_VIDEODATA || nt.TagType == FLV_SCRIPTDATA)) {
+ if ((nt.PreviousTagSize == ct.DataSize + 11) ||
+ (m_IgnorePrevSizes &&
+ nt.TimeStamp >= ct.TimeStamp &&
+ nt.TimeStamp - ct.TimeStamp <= 1000)) {
+ m_pFile->Seek(pos);
+ return true;
+ }
+ }
+ }
+ }
+
+ m_pFile->Seek(pos + 5);
+ }
+
+ return false;
}
HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
{
- CheckPointer(pAsyncReader, E_POINTER);
-
- HRESULT hr = E_FAIL;
-
- m_pFile.Free();
- m_pFile.Attach(DNew CBaseSplitterFileEx(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false));
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration = 0;
-
- if (m_pFile->BitRead(24) != 'FLV' || m_pFile->BitRead(8) != 1) {
- return E_FAIL;
- }
-
- EXECUTE_ASSERT(m_pFile->BitRead(5) == 0); // TypeFlagsReserved
- bool fTypeFlagsAudio = !!m_pFile->BitRead(1);
- EXECUTE_ASSERT(m_pFile->BitRead(1) == 0); // TypeFlagsReserved
- bool fTypeFlagsVideo = !!m_pFile->BitRead(1);
- m_DataOffset = (UINT32)m_pFile->BitRead(32);
-
- // doh, these flags aren't always telling the truth
- fTypeFlagsAudio = fTypeFlagsVideo = true;
-
- Tag t;
- AudioTag at;
- VideoTag vt;
-
- UINT32 prevTagSize = 0;
- m_IgnorePrevSizes = false;
-
- m_pFile->Seek(m_DataOffset);
-
- for (int i = 0; ReadTag(t) && (fTypeFlagsVideo || fTypeFlagsAudio); i++) {
- if (!t.DataSize) continue; // skip empty Tag
-
- UINT64 next = m_pFile->GetPos() + t.DataSize;
-
- CStringW name;
-
- CMediaType mt;
- CMediaType ff_mtype;
- mt.SetSampleSize(1);
- mt.subtype = GUID_NULL;
-
- if (i != 0 && t.PreviousTagSize != prevTagSize) {
- m_IgnorePrevSizes = true;
- }
- prevTagSize = t.DataSize + 11;
-
- if (t.TagType == FLV_AUDIODATA && t.DataSize != 0 && fTypeFlagsAudio) {
- UNREFERENCED_PARAMETER(at);
- AudioTag at;
- name = L"Audio";
-
- if (ReadTag(at)) {
- int dataSize = t.DataSize - 1;
-
- fTypeFlagsAudio = false;
-
- mt.majortype = MEDIATYPE_Audio;
- mt.formattype = FORMAT_WaveFormatEx;
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX));
- memset(wfe, 0, sizeof(WAVEFORMATEX));
- wfe->nSamplesPerSec = 44100*(1<<at.SoundRate)/8;
- wfe->wBitsPerSample = 8*(at.SoundSize+1);
- wfe->nChannels = at.SoundType+1;
-
- switch (at.SoundFormat) {
- case FLV_AUDIO_PCM:
- case FLV_AUDIO_PCMLE:
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_PCM);
- name += L" PCM";
- break;
- case FLV_AUDIO_ADPCM:
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_ADPCM_SWF);
- name += L" ADPCM";
- break;
- case FLV_AUDIO_MP3:
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_MP3);
- name += L" MP3";
-
- {
- CBaseSplitterFileEx::mpahdr h;
- CMediaType mt2;
- if (m_pFile->Read(h, 4, false, &mt2)) {
- mt = mt2;
- }
- }
- break;
- case FLV_AUDIO_NELLY16:
- mt.subtype = FOURCCMap(MAKEFOURCC('N','E','L','L'));
- wfe->nSamplesPerSec = 16000;
- name += L" Nellimoser";
- break;
- case FLV_AUDIO_NELLY8:
- mt.subtype = FOURCCMap(MAKEFOURCC('N','E','L','L'));
- wfe->nSamplesPerSec = 8000;
- name += L" Nellimoser";
- break;
- case FLV_AUDIO_NELLY:
- mt.subtype = FOURCCMap(MAKEFOURCC('N','E','L','L'));
- name += L" Nellimoser";
- break;
- case FLV_AUDIO_AAC: {
- if (dataSize < 1 || m_pFile->BitRead(8) != 0) { // packet type 0 == aac header
- fTypeFlagsAudio = true;
- break;
- }
- name += L" AAC";
-
- const int sampleRates[] = {
- 96000, 88200, 64000, 48000, 44100, 32000, 24000,
- 22050, 16000, 12000, 11025, 8000, 7350
- };
- const int channels[] = {
- 0, 1, 2, 3, 4, 5, 6, 8
- };
-
- __int64 configOffset = m_pFile->GetPos();
- UINT32 configSize = dataSize - 1;
- if (configSize < 2) {
- break;
- }
-
- // Might break depending on the AAC profile, see ff_mpeg4audio_get_config in ffmpeg's mpeg4audio.c
- m_pFile->BitRead(5);
- int iSampleRate = (int)m_pFile->BitRead(4);
- int iChannels = (int)m_pFile->BitRead(4);
- if (iSampleRate > 12 || iChannels > 7) {
- break;
- }
-
- wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX) + configSize);
- memset(wfe, 0, mt.FormatLength());
- wfe->nSamplesPerSec = sampleRates[iSampleRate];
- wfe->wBitsPerSample = 16;
- wfe->nChannels = channels[iChannels];
- wfe->cbSize = configSize;
-
- m_pFile->Seek(configOffset);
- m_pFile->ByteRead((BYTE*)(wfe+1), configSize);
-
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_AAC);
- }
-
- }
- }
- } else if (t.TagType == FLV_VIDEODATA && t.DataSize != 0 && fTypeFlagsVideo) {
- UNREFERENCED_PARAMETER(vt);
- VideoTag vt;
- if (ReadTag(vt) && vt.FrameType == 1) {
- int dataSize = t.DataSize - 1;
-
- fTypeFlagsVideo = false;
- name = L"Video";
-
- mt.majortype = MEDIATYPE_Video;
- mt.formattype = FORMAT_VideoInfo;
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
- memset(vih, 0, sizeof(VIDEOINFOHEADER));
-
- BITMAPINFOHEADER* bih = &vih->bmiHeader;
-
- int w, h, arx, ary;
-
- switch (vt.CodecID) {
- case FLV_VIDEO_H263: // H.263
- if (m_pFile->BitRead(17) != 1) {
- break;
- }
-
- m_pFile->BitRead(13); // Version (5), TemporalReference (8)
-
- switch (BYTE PictureSize = (BYTE)m_pFile->BitRead(3)) { // w00t
- case 0:
- case 1:
- vih->bmiHeader.biWidth = (WORD)m_pFile->BitRead(8*(PictureSize+1));
- vih->bmiHeader.biHeight = (WORD)m_pFile->BitRead(8*(PictureSize+1));
- break;
- case 2:
- case 3:
- case 4:
- vih->bmiHeader.biWidth = 704 / PictureSize;
- vih->bmiHeader.biHeight = 576 / PictureSize;
- break;
- case 5:
- case 6:
- PictureSize -= 3;
- vih->bmiHeader.biWidth = 640 / PictureSize;
- vih->bmiHeader.biHeight = 480 / PictureSize;
- break;
- }
-
- if (!vih->bmiHeader.biWidth || !vih->bmiHeader.biHeight) {
- break;
- }
-
- mt.subtype = FOURCCMap(vih->bmiHeader.biCompression = '1VLF');
- name += L" H.263";
-
- break;
- case FLV_VIDEO_SCREEN: {
- m_pFile->BitRead(4);
- vih->bmiHeader.biWidth = (LONG)m_pFile->BitRead(12);
- m_pFile->BitRead(4);
- vih->bmiHeader.biHeight = (LONG)m_pFile->BitRead(12);
-
- if (!vih->bmiHeader.biWidth || !vih->bmiHeader.biHeight) {
- break;
- }
-
- vih->bmiHeader.biSize = sizeof(vih->bmiHeader);
- vih->bmiHeader.biPlanes = 1;
- vih->bmiHeader.biBitCount = 24;
- vih->bmiHeader.biSizeImage = vih->bmiHeader.biWidth * vih->bmiHeader.biHeight * 3;
-
- mt.subtype = FOURCCMap(vih->bmiHeader.biCompression = '1VSF');
- name += L" Screen";
-
- break;
- }
- case FLV_VIDEO_VP6A: // VP6 with alpha
- m_pFile->BitRead(24);
- case FLV_VIDEO_VP6: { // VP6
+ CheckPointer(pAsyncReader, E_POINTER);
+
+ HRESULT hr = E_FAIL;
+
+ m_pFile.Free();
+ m_pFile.Attach(DNew CBaseSplitterFileEx(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false));
+ if (!m_pFile) {
+ return E_OUTOFMEMORY;
+ }
+ if (FAILED(hr)) {
+ m_pFile.Free();
+ return hr;
+ }
+
+ m_rtNewStart = m_rtCurrent = 0;
+ m_rtNewStop = m_rtStop = m_rtDuration = 0;
+
+ if (m_pFile->BitRead(24) != 'FLV' || m_pFile->BitRead(8) != 1) {
+ return E_FAIL;
+ }
+
+ EXECUTE_ASSERT(m_pFile->BitRead(5) == 0); // TypeFlagsReserved
+ bool fTypeFlagsAudio = !!m_pFile->BitRead(1);
+ EXECUTE_ASSERT(m_pFile->BitRead(1) == 0); // TypeFlagsReserved
+ bool fTypeFlagsVideo = !!m_pFile->BitRead(1);
+ m_DataOffset = (UINT32)m_pFile->BitRead(32);
+
+ // doh, these flags aren't always telling the truth
+ fTypeFlagsAudio = fTypeFlagsVideo = true;
+
+ Tag t;
+ AudioTag at;
+ VideoTag vt;
+
+ UINT32 prevTagSize = 0;
+ m_IgnorePrevSizes = false;
+
+ m_pFile->Seek(m_DataOffset);
+
+ for (int i = 0; ReadTag(t) && (fTypeFlagsVideo || fTypeFlagsAudio); i++) {
+ if (!t.DataSize) { continue; } // skip empty Tag
+
+ UINT64 next = m_pFile->GetPos() + t.DataSize;
+
+ CStringW name;
+
+ CMediaType mt;
+ CMediaType ff_mtype;
+ mt.SetSampleSize(1);
+ mt.subtype = GUID_NULL;
+
+ if (i != 0 && t.PreviousTagSize != prevTagSize) {
+ m_IgnorePrevSizes = true;
+ }
+ prevTagSize = t.DataSize + 11;
+
+ if (t.TagType == FLV_AUDIODATA && t.DataSize != 0 && fTypeFlagsAudio) {
+ UNREFERENCED_PARAMETER(at);
+ AudioTag at;
+ name = L"Audio";
+
+ if (ReadTag(at)) {
+ int dataSize = t.DataSize - 1;
+
+ fTypeFlagsAudio = false;
+
+ mt.majortype = MEDIATYPE_Audio;
+ mt.formattype = FORMAT_WaveFormatEx;
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX));
+ memset(wfe, 0, sizeof(WAVEFORMATEX));
+ wfe->nSamplesPerSec = 44100 * (1 << at.SoundRate) / 8;
+ wfe->wBitsPerSample = 8 * (at.SoundSize + 1);
+ wfe->nChannels = at.SoundType + 1;
+
+ switch (at.SoundFormat) {
+ case FLV_AUDIO_PCM:
+ case FLV_AUDIO_PCMLE:
+ mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_PCM);
+ name += L" PCM";
+ break;
+ case FLV_AUDIO_ADPCM:
+ mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_ADPCM_SWF);
+ name += L" ADPCM";
+ break;
+ case FLV_AUDIO_MP3:
+ mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_MP3);
+ name += L" MP3";
+
+ {
+ CBaseSplitterFileEx::mpahdr h;
+ CMediaType mt2;
+ if (m_pFile->Read(h, 4, false, &mt2)) {
+ mt = mt2;
+ }
+ }
+ break;
+ case FLV_AUDIO_NELLY16:
+ mt.subtype = FOURCCMap(MAKEFOURCC('N', 'E', 'L', 'L'));
+ wfe->nSamplesPerSec = 16000;
+ name += L" Nellimoser";
+ break;
+ case FLV_AUDIO_NELLY8:
+ mt.subtype = FOURCCMap(MAKEFOURCC('N', 'E', 'L', 'L'));
+ wfe->nSamplesPerSec = 8000;
+ name += L" Nellimoser";
+ break;
+ case FLV_AUDIO_NELLY:
+ mt.subtype = FOURCCMap(MAKEFOURCC('N', 'E', 'L', 'L'));
+ name += L" Nellimoser";
+ break;
+ case FLV_AUDIO_AAC: {
+ if (dataSize < 1 || m_pFile->BitRead(8) != 0) { // packet type 0 == aac header
+ fTypeFlagsAudio = true;
+ break;
+ }
+ name += L" AAC";
+
+ const int sampleRates[] = {
+ 96000, 88200, 64000, 48000, 44100, 32000, 24000,
+ 22050, 16000, 12000, 11025, 8000, 7350
+ };
+ const int channels[] = {
+ 0, 1, 2, 3, 4, 5, 6, 8
+ };
+
+ __int64 configOffset = m_pFile->GetPos();
+ UINT32 configSize = dataSize - 1;
+ if (configSize < 2) {
+ break;
+ }
+
+ // Might break depending on the AAC profile, see ff_mpeg4audio_get_config in ffmpeg's mpeg4audio.c
+ m_pFile->BitRead(5);
+ int iSampleRate = (int)m_pFile->BitRead(4);
+ int iChannels = (int)m_pFile->BitRead(4);
+ if (iSampleRate > 12 || iChannels > 7) {
+ break;
+ }
+
+ wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX) + configSize);
+ memset(wfe, 0, mt.FormatLength());
+ wfe->nSamplesPerSec = sampleRates[iSampleRate];
+ wfe->wBitsPerSample = 16;
+ wfe->nChannels = channels[iChannels];
+ wfe->cbSize = configSize;
+
+ m_pFile->Seek(configOffset);
+ m_pFile->ByteRead((BYTE*)(wfe + 1), configSize);
+
+ mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_AAC);
+ }
+
+ }
+ }
+ } else if (t.TagType == FLV_VIDEODATA && t.DataSize != 0 && fTypeFlagsVideo) {
+ UNREFERENCED_PARAMETER(vt);
+ VideoTag vt;
+ if (ReadTag(vt) && vt.FrameType == 1) {
+ int dataSize = t.DataSize - 1;
+
+ fTypeFlagsVideo = false;
+ name = L"Video";
+
+ mt.majortype = MEDIATYPE_Video;
+ mt.formattype = FORMAT_VideoInfo;
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
+ memset(vih, 0, sizeof(VIDEOINFOHEADER));
+
+ BITMAPINFOHEADER* bih = &vih->bmiHeader;
+
+ int w, h, arx, ary;
+
+ switch (vt.CodecID) {
+ case FLV_VIDEO_H263: // H.263
+ if (m_pFile->BitRead(17) != 1) {
+ break;
+ }
+
+ m_pFile->BitRead(13); // Version (5), TemporalReference (8)
+
+ switch (BYTE PictureSize = (BYTE)m_pFile->BitRead(3)) { // w00t
+ case 0:
+ case 1:
+ vih->bmiHeader.biWidth = (WORD)m_pFile->BitRead(8 * (PictureSize + 1));
+ vih->bmiHeader.biHeight = (WORD)m_pFile->BitRead(8 * (PictureSize + 1));
+ break;
+ case 2:
+ case 3:
+ case 4:
+ vih->bmiHeader.biWidth = 704 / PictureSize;
+ vih->bmiHeader.biHeight = 576 / PictureSize;
+ break;
+ case 5:
+ case 6:
+ PictureSize -= 3;
+ vih->bmiHeader.biWidth = 640 / PictureSize;
+ vih->bmiHeader.biHeight = 480 / PictureSize;
+ break;
+ }
+
+ if (!vih->bmiHeader.biWidth || !vih->bmiHeader.biHeight) {
+ break;
+ }
+
+ mt.subtype = FOURCCMap(vih->bmiHeader.biCompression = '1VLF');
+ name += L" H.263";
+
+ break;
+ case FLV_VIDEO_SCREEN: {
+ m_pFile->BitRead(4);
+ vih->bmiHeader.biWidth = (LONG)m_pFile->BitRead(12);
+ m_pFile->BitRead(4);
+ vih->bmiHeader.biHeight = (LONG)m_pFile->BitRead(12);
+
+ if (!vih->bmiHeader.biWidth || !vih->bmiHeader.biHeight) {
+ break;
+ }
+
+ vih->bmiHeader.biSize = sizeof(vih->bmiHeader);
+ vih->bmiHeader.biPlanes = 1;
+ vih->bmiHeader.biBitCount = 24;
+ vih->bmiHeader.biSizeImage = vih->bmiHeader.biWidth * vih->bmiHeader.biHeight * 3;
+
+ mt.subtype = FOURCCMap(vih->bmiHeader.biCompression = '1VSF');
+ name += L" Screen";
+
+ break;
+ }
+ case FLV_VIDEO_VP6A: // VP6 with alpha
+ m_pFile->BitRead(24);
+ case FLV_VIDEO_VP6: { // VP6
#ifdef NOVIDEOTWEAK
- m_pFile->BitRead(8);
+ m_pFile->BitRead(8);
#else
- VideoTweak fudge;
- ReadTag(fudge);
+ VideoTweak fudge;
+ ReadTag(fudge);
#endif
- if (m_pFile->BitRead(1)) {
- // Delta (inter) frame
- fTypeFlagsVideo = true;
- break;
- }
- m_pFile->BitRead(6);
- bool fSeparatedCoeff = !!m_pFile->BitRead(1);
- m_pFile->BitRead(5);
- int filterHeader = (int)m_pFile->BitRead(2);
- m_pFile->BitRead(1);
- if (fSeparatedCoeff || !filterHeader) {
- m_pFile->BitRead(16);
- }
-
- h = (int)m_pFile->BitRead(8) * 16;
- w = (int)m_pFile->BitRead(8) * 16;
-
- ary = (int)m_pFile->BitRead(8) * 16;
- arx = (int)m_pFile->BitRead(8) * 16;
-
- if (arx && arx != w || ary && ary != h) {
- VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER2));
- memset(vih2, 0, sizeof(VIDEOINFOHEADER2));
- vih2->dwPictAspectRatioX = arx;
- vih2->dwPictAspectRatioY = ary;
- bih = &vih2->bmiHeader;
- mt.formattype = FORMAT_VideoInfo2;
- vih = (VIDEOINFOHEADER *)vih2;
- }
-
- bih->biWidth = w;
- bih->biHeight = h;
+ if (m_pFile->BitRead(1)) {
+ // Delta (inter) frame
+ fTypeFlagsVideo = true;
+ break;
+ }
+ m_pFile->BitRead(6);
+ bool fSeparatedCoeff = !!m_pFile->BitRead(1);
+ m_pFile->BitRead(5);
+ int filterHeader = (int)m_pFile->BitRead(2);
+ m_pFile->BitRead(1);
+ if (fSeparatedCoeff || !filterHeader) {
+ m_pFile->BitRead(16);
+ }
+
+ h = (int)m_pFile->BitRead(8) * 16;
+ w = (int)m_pFile->BitRead(8) * 16;
+
+ ary = (int)m_pFile->BitRead(8) * 16;
+ arx = (int)m_pFile->BitRead(8) * 16;
+
+ if (arx && arx != w || ary && ary != h) {
+ VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER2));
+ memset(vih2, 0, sizeof(VIDEOINFOHEADER2));
+ vih2->dwPictAspectRatioX = arx;
+ vih2->dwPictAspectRatioY = ary;
+ bih = &vih2->bmiHeader;
+ mt.formattype = FORMAT_VideoInfo2;
+ vih = (VIDEOINFOHEADER*)vih2;
+ }
+
+ bih->biWidth = w;
+ bih->biHeight = h;
#ifndef NOVIDEOTWEAK
- SetRect(&vih->rcSource, 0, 0, w - fudge.x, h - fudge.y);
- SetRect(&vih->rcTarget, 0, 0, w - fudge.x, h - fudge.y);
+ SetRect(&vih->rcSource, 0, 0, w - fudge.x, h - fudge.y);
+ SetRect(&vih->rcTarget, 0, 0, w - fudge.x, h - fudge.y);
#endif
- mt.subtype = FOURCCMap(bih->biCompression = '4VLF');
- name += L" VP6";
-
- break;
- }
- case FLV_VIDEO_AVC: { // H.264
- if (dataSize < 4 || m_pFile->BitRead(8) != 0) { // packet type 0 == avc header
- fTypeFlagsVideo = true;
- break;
- }
- m_pFile->BitRead(24); // composition time
-
- __int64 headerOffset = m_pFile->GetPos();
- UINT32 headerSize = dataSize - 4;
- BYTE *headerData = DNew BYTE[headerSize];
-
- m_pFile->ByteRead(headerData, headerSize);
-
- m_pFile->Seek(headerOffset + 9);
-
- mt.formattype = FORMAT_MPEG2Video;
- MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + headerSize);
- memset(vih, 0, mt.FormatLength());
- vih->hdr.bmiHeader.biSize = sizeof(vih->hdr.bmiHeader);
- vih->hdr.bmiHeader.biPlanes = 1;
- vih->hdr.bmiHeader.biBitCount = 24;
- vih->dwFlags = (headerData[4] & 0x03) + 1; // nal length size
-
- vih->dwProfile = (BYTE)m_pFile->BitRead(8);
- m_pFile->BitRead(8);
- vih->dwLevel = (BYTE)m_pFile->BitRead(8);
- m_pFile->UExpGolombRead(); // seq_parameter_set_id
- UINT64 chroma_format_idc = 0;
- if (vih->dwProfile >= 100) { // high profile
- chroma_format_idc = m_pFile->UExpGolombRead();
- if (chroma_format_idc == 3) { // chroma_format_idc
- m_pFile->BitRead(1); // residue_transform_flag
- }
- m_pFile->UExpGolombRead(); // bit_depth_luma_minus8
- m_pFile->UExpGolombRead(); // bit_depth_chroma_minus8
- m_pFile->BitRead(1); // qpprime_y_zero_transform_bypass_flag
- if (m_pFile->BitRead(1)) // seq_scaling_matrix_present_flag
- for (int i = 0; i < 8; i++)
- if (m_pFile->BitRead(1)) // seq_scaling_list_present_flag
- for (int j = 0, size = i < 6 ? 16 : 64, next = 8; j < size && next != 0; ++j) {
- next = (next + m_pFile->SExpGolombRead() + 256) & 255;
- }
- }
- m_pFile->UExpGolombRead(); // log2_max_frame_num_minus4
- UINT64 pic_order_cnt_type = m_pFile->UExpGolombRead();
- if (pic_order_cnt_type == 0) {
- m_pFile->UExpGolombRead(); // log2_max_pic_order_cnt_lsb_minus4
- } else if (pic_order_cnt_type == 1) {
- m_pFile->BitRead(1); // delta_pic_order_always_zero_flag
- m_pFile->SExpGolombRead(); // offset_for_non_ref_pic
- m_pFile->SExpGolombRead(); // offset_for_top_to_bottom_field
- UINT64 num_ref_frames_in_pic_order_cnt_cycle = m_pFile->UExpGolombRead();
- for (int i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++) {
- m_pFile->SExpGolombRead(); // offset_for_ref_frame[i]
- }
- }
- m_pFile->UExpGolombRead(); // num_ref_frames
- m_pFile->BitRead(1); // gaps_in_frame_num_value_allowed_flag
- UINT64 pic_width_in_mbs_minus1 = m_pFile->UExpGolombRead();
- UINT64 pic_height_in_map_units_minus1 = m_pFile->UExpGolombRead();
- BYTE frame_mbs_only_flag = (BYTE)m_pFile->BitRead(1);
- if (!frame_mbs_only_flag) {
- m_pFile->BitRead(1); // mb_adaptive_frame_field_flag
- }
- m_pFile->BitRead(1); // direct_8x8_inference_flag
- BYTE crop = (BYTE)m_pFile->BitRead(1); // frame_cropping_flag
- unsigned int crop_left = 0;
- unsigned int crop_right = 0;
- unsigned int crop_top = 0;
- unsigned int crop_bottom = 0;
-
- if (crop) {
- crop_left = (unsigned int)m_pFile->UExpGolombRead(); // frame_cropping_rect_left_offset
- crop_right = (unsigned int)m_pFile->UExpGolombRead(); // frame_cropping_rect_right_offset
- crop_top = (unsigned int)m_pFile->UExpGolombRead(); // frame_cropping_rect_top_offset
- crop_bottom = (unsigned int)m_pFile->UExpGolombRead(); // frame_cropping_rect_bottom_offset
- }
- struct sar {
- WORD num;
- WORD den;
- } sar;
-
- if (m_pFile->BitRead(1)) { // vui_parameters_present_flag
- if (m_pFile->BitRead(1)) { // aspect_ratio_info_present_flag
- BYTE aspect_ratio_idc = (BYTE)m_pFile->BitRead(8); // aspect_ratio_idc
- if (255 == aspect_ratio_idc) {
- sar.num = (WORD)m_pFile->BitRead(16); // sar_width
- sar.den = (WORD)m_pFile->BitRead(16); // sar_height
- } else if (aspect_ratio_idc < 17) {
- sar.num = pixel_aspect[aspect_ratio_idc][0];
- sar.den = pixel_aspect[aspect_ratio_idc][1];
- } else {
- return false;
- }
- } else {
- sar.num = 1;
- sar.den = 1;
- }
- }
- unsigned int mb_Width = (unsigned int)pic_width_in_mbs_minus1 + 1;
- unsigned int mb_Height = ((unsigned int)pic_height_in_map_units_minus1 + 1) * (2 - frame_mbs_only_flag);
- BYTE CHROMA444 = (chroma_format_idc == 3);
-
- unsigned int Width, Height;
- Width = 16 * mb_Width - (2u>>CHROMA444) * min(crop_right, (8u<<CHROMA444)-1);
- if (frame_mbs_only_flag) {
- Height = 16 * mb_Height - (2u>>CHROMA444) * min(crop_bottom, (8u<<CHROMA444)-1);
- } else {
- Height = 16 * mb_Height - (4u>>CHROMA444) * min(crop_bottom, (8u<<CHROMA444)-1);
- }
- if (!sar.num) sar.num = 1;
- if (!sar.den) sar.den = 1;
- CSize aspect(Width * sar.num, Height * sar.den);
- int lnko = LNKO(aspect.cx, aspect.cy);
- if (lnko > 1) {
- aspect.cx /= lnko, aspect.cy /= lnko;
- }
-
- vih->hdr.dwPictAspectRatioX = aspect.cx;
- vih->hdr.dwPictAspectRatioY = aspect.cy;
- vih->hdr.bmiHeader.biWidth = Width;
- vih->hdr.bmiHeader.biHeight = Height;
-
- BYTE* src = (BYTE*)headerData + 5;
- BYTE* dst = (BYTE*)vih->dwSequenceHeader;
- BYTE* src_end = (BYTE*)headerData + headerSize;
- BYTE* dst_end = (BYTE*)vih->dwSequenceHeader + headerSize;
- int spsCount = *(src++) & 0x1F;
- int ppsCount = -1;
-
- vih->cbSequenceHeader = 0;
-
- while (src < src_end - 1) {
- if (spsCount == 0 && ppsCount == -1) {
- ppsCount = *(src++);
- continue;
- }
-
- if (spsCount > 0) {
- spsCount--;
- } else if (ppsCount > 0) {
- ppsCount--;
- } else {
- break;
- }
-
- int len = ((src[0] << 8) | src[1]) + 2;
- if (src + len > src_end || dst + len > dst_end) {
- ASSERT(0);
- break;
- }
- memcpy(dst, src, len);
- src += len;
- dst += len;
- vih->cbSequenceHeader += len;
- }
-
- delete[] headerData;
-
- mt.subtype = FOURCCMap(vih->hdr.bmiHeader.biCompression = '1CVA');
- name += L" H.264";
-
- break;
- }
- default:
- fTypeFlagsVideo = true;
- }
- }
- }
-
- if (mt.subtype != GUID_NULL) {
- CAtlArray<CMediaType> mts;
- if (mt.subtype == FOURCCMap(MAKEFOURCC('A','S','W','F'))) {
- mts.InsertAt(0, ff_mtype);
- }
- mts.Add(mt);
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, name, this, this, &hr));
- EXECUTE_ASSERT(SUCCEEDED(AddOutputPin(t.TagType, pPinOut)));
- }
-
- m_pFile->Seek(next);
- }
-
- if (m_pFile->IsRandomAccess()) {
- __int64 pos = max(m_DataOffset, m_pFile->GetLength() - 256 * 1024);
-
- if (Sync(pos)) {
- Tag t;
- AudioTag at;
- VideoTag vt;
-
- while (ReadTag(t)) {
- UINT64 next = m_pFile->GetPos() + t.DataSize;
-
- if (t.TagType == FLV_AUDIODATA && ReadTag(at) || t.TagType == FLV_VIDEODATA && ReadTag(vt)) {
- m_rtDuration = max(m_rtDuration, 10000i64 * t.TimeStamp);
- }
-
- m_pFile->Seek(next);
- }
- }
- }
-
- m_rtNewStop = m_rtStop = m_rtDuration;
-
- return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
+ mt.subtype = FOURCCMap(bih->biCompression = '4VLF');
+ name += L" VP6";
+
+ break;
+ }
+ case FLV_VIDEO_AVC: { // H.264
+ if (dataSize < 4 || m_pFile->BitRead(8) != 0) { // packet type 0 == avc header
+ fTypeFlagsVideo = true;
+ break;
+ }
+ m_pFile->BitRead(24); // composition time
+
+ __int64 headerOffset = m_pFile->GetPos();
+ UINT32 headerSize = dataSize - 4;
+ BYTE* headerData = DNew BYTE[headerSize];
+
+ m_pFile->ByteRead(headerData, headerSize);
+
+ m_pFile->Seek(headerOffset + 9);
+
+ mt.formattype = FORMAT_MPEG2Video;
+ MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + headerSize);
+ memset(vih, 0, mt.FormatLength());
+ vih->hdr.bmiHeader.biSize = sizeof(vih->hdr.bmiHeader);
+ vih->hdr.bmiHeader.biPlanes = 1;
+ vih->hdr.bmiHeader.biBitCount = 24;
+ vih->dwFlags = (headerData[4] & 0x03) + 1; // nal length size
+
+ vih->dwProfile = (BYTE)m_pFile->BitRead(8);
+ m_pFile->BitRead(8);
+ vih->dwLevel = (BYTE)m_pFile->BitRead(8);
+ m_pFile->UExpGolombRead(); // seq_parameter_set_id
+ UINT64 chroma_format_idc = 0;
+ if (vih->dwProfile >= 100) { // high profile
+ chroma_format_idc = m_pFile->UExpGolombRead();
+ if (chroma_format_idc == 3) { // chroma_format_idc
+ m_pFile->BitRead(1); // residue_transform_flag
+ }
+ m_pFile->UExpGolombRead(); // bit_depth_luma_minus8
+ m_pFile->UExpGolombRead(); // bit_depth_chroma_minus8
+ m_pFile->BitRead(1); // qpprime_y_zero_transform_bypass_flag
+ if (m_pFile->BitRead(1)) // seq_scaling_matrix_present_flag
+ for (int i = 0; i < 8; i++)
+ if (m_pFile->BitRead(1)) // seq_scaling_list_present_flag
+ for (int j = 0, size = i < 6 ? 16 : 64, next = 8; j < size && next != 0; ++j) {
+ next = (next + m_pFile->SExpGolombRead() + 256) & 255;
+ }
+ }
+ m_pFile->UExpGolombRead(); // log2_max_frame_num_minus4
+ UINT64 pic_order_cnt_type = m_pFile->UExpGolombRead();
+ if (pic_order_cnt_type == 0) {
+ m_pFile->UExpGolombRead(); // log2_max_pic_order_cnt_lsb_minus4
+ } else if (pic_order_cnt_type == 1) {
+ m_pFile->BitRead(1); // delta_pic_order_always_zero_flag
+ m_pFile->SExpGolombRead(); // offset_for_non_ref_pic
+ m_pFile->SExpGolombRead(); // offset_for_top_to_bottom_field
+ UINT64 num_ref_frames_in_pic_order_cnt_cycle = m_pFile->UExpGolombRead();
+ for (int i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++) {
+ m_pFile->SExpGolombRead(); // offset_for_ref_frame[i]
+ }
+ }
+ m_pFile->UExpGolombRead(); // num_ref_frames
+ m_pFile->BitRead(1); // gaps_in_frame_num_value_allowed_flag
+ UINT64 pic_width_in_mbs_minus1 = m_pFile->UExpGolombRead();
+ UINT64 pic_height_in_map_units_minus1 = m_pFile->UExpGolombRead();
+ BYTE frame_mbs_only_flag = (BYTE)m_pFile->BitRead(1);
+ if (!frame_mbs_only_flag) {
+ m_pFile->BitRead(1); // mb_adaptive_frame_field_flag
+ }
+ m_pFile->BitRead(1); // direct_8x8_inference_flag
+ BYTE crop = (BYTE)m_pFile->BitRead(1); // frame_cropping_flag
+ unsigned int crop_left = 0;
+ unsigned int crop_right = 0;
+ unsigned int crop_top = 0;
+ unsigned int crop_bottom = 0;
+
+ if (crop) {
+ crop_left = (unsigned int)m_pFile->UExpGolombRead(); // frame_cropping_rect_left_offset
+ crop_right = (unsigned int)m_pFile->UExpGolombRead(); // frame_cropping_rect_right_offset
+ crop_top = (unsigned int)m_pFile->UExpGolombRead(); // frame_cropping_rect_top_offset
+ crop_bottom = (unsigned int)m_pFile->UExpGolombRead(); // frame_cropping_rect_bottom_offset
+ }
+ struct sar {
+ WORD num;
+ WORD den;
+ } sar;
+
+ if (m_pFile->BitRead(1)) { // vui_parameters_present_flag
+ if (m_pFile->BitRead(1)) { // aspect_ratio_info_present_flag
+ BYTE aspect_ratio_idc = (BYTE)m_pFile->BitRead(8); // aspect_ratio_idc
+ if (255 == aspect_ratio_idc) {
+ sar.num = (WORD)m_pFile->BitRead(16); // sar_width
+ sar.den = (WORD)m_pFile->BitRead(16); // sar_height
+ } else if (aspect_ratio_idc < 17) {
+ sar.num = pixel_aspect[aspect_ratio_idc][0];
+ sar.den = pixel_aspect[aspect_ratio_idc][1];
+ } else {
+ return false;
+ }
+ } else {
+ sar.num = 1;
+ sar.den = 1;
+ }
+ }
+ unsigned int mb_Width = (unsigned int)pic_width_in_mbs_minus1 + 1;
+ unsigned int mb_Height = ((unsigned int)pic_height_in_map_units_minus1 + 1) * (2 - frame_mbs_only_flag);
+ BYTE CHROMA444 = (chroma_format_idc == 3);
+
+ unsigned int Width, Height;
+ Width = 16 * mb_Width - (2u >> CHROMA444) * min(crop_right, (8u << CHROMA444) - 1);
+ if (frame_mbs_only_flag) {
+ Height = 16 * mb_Height - (2u >> CHROMA444) * min(crop_bottom, (8u << CHROMA444) - 1);
+ } else {
+ Height = 16 * mb_Height - (4u >> CHROMA444) * min(crop_bottom, (8u << CHROMA444) - 1);
+ }
+ if (!sar.num) { sar.num = 1; }
+ if (!sar.den) { sar.den = 1; }
+ CSize aspect(Width * sar.num, Height * sar.den);
+ int lnko = LNKO(aspect.cx, aspect.cy);
+ if (lnko > 1) {
+ aspect.cx /= lnko, aspect.cy /= lnko;
+ }
+
+ vih->hdr.dwPictAspectRatioX = aspect.cx;
+ vih->hdr.dwPictAspectRatioY = aspect.cy;
+ vih->hdr.bmiHeader.biWidth = Width;
+ vih->hdr.bmiHeader.biHeight = Height;
+
+ BYTE* src = (BYTE*)headerData + 5;
+ BYTE* dst = (BYTE*)vih->dwSequenceHeader;
+ BYTE* src_end = (BYTE*)headerData + headerSize;
+ BYTE* dst_end = (BYTE*)vih->dwSequenceHeader + headerSize;
+ int spsCount = *(src++) & 0x1F;
+ int ppsCount = -1;
+
+ vih->cbSequenceHeader = 0;
+
+ while (src < src_end - 1) {
+ if (spsCount == 0 && ppsCount == -1) {
+ ppsCount = *(src++);
+ continue;
+ }
+
+ if (spsCount > 0) {
+ spsCount--;
+ } else if (ppsCount > 0) {
+ ppsCount--;
+ } else {
+ break;
+ }
+
+ int len = ((src[0] << 8) | src[1]) + 2;
+ if (src + len > src_end || dst + len > dst_end) {
+ ASSERT(0);
+ break;
+ }
+ memcpy(dst, src, len);
+ src += len;
+ dst += len;
+ vih->cbSequenceHeader += len;
+ }
+
+ delete[] headerData;
+
+ mt.subtype = FOURCCMap(vih->hdr.bmiHeader.biCompression = '1CVA');
+ name += L" H.264";
+
+ break;
+ }
+ default:
+ fTypeFlagsVideo = true;
+ }
+ }
+ }
+
+ if (mt.subtype != GUID_NULL) {
+ CAtlArray<CMediaType> mts;
+ if (mt.subtype == FOURCCMap(MAKEFOURCC('A', 'S', 'W', 'F'))) {
+ mts.InsertAt(0, ff_mtype);
+ }
+ mts.Add(mt);
+ CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, name, this, this, &hr));
+ EXECUTE_ASSERT(SUCCEEDED(AddOutputPin(t.TagType, pPinOut)));
+ }
+
+ m_pFile->Seek(next);
+ }
+
+ if (m_pFile->IsRandomAccess()) {
+ __int64 pos = max(m_DataOffset, m_pFile->GetLength() - 256 * 1024);
+
+ if (Sync(pos)) {
+ Tag t;
+ AudioTag at;
+ VideoTag vt;
+
+ while (ReadTag(t)) {
+ UINT64 next = m_pFile->GetPos() + t.DataSize;
+
+ if (t.TagType == FLV_AUDIODATA && ReadTag(at) || t.TagType == FLV_VIDEODATA && ReadTag(vt)) {
+ m_rtDuration = max(m_rtDuration, 10000i64 * t.TimeStamp);
+ }
+
+ m_pFile->Seek(next);
+ }
+ }
+ }
+
+ m_rtNewStop = m_rtStop = m_rtDuration;
+
+ return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
}
bool CFLVSplitterFilter::DemuxInit()
{
- SetThreadName((DWORD)-1, "CFLVSplitterFilter");
- return true;
+ SetThreadName((DWORD) - 1, "CFLVSplitterFilter");
+ return true;
}
void CFLVSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
- if (!m_rtDuration || rt <= 0) {
- m_pFile->Seek(m_DataOffset);
- } else if (!m_IgnorePrevSizes) {
- NormalSeek(rt);
- } else {
- AlternateSeek(rt);
- }
+ if (!m_rtDuration || rt <= 0) {
+ m_pFile->Seek(m_DataOffset);
+ } else if (!m_IgnorePrevSizes) {
+ NormalSeek(rt);
+ } else {
+ AlternateSeek(rt);
+ }
}
void CFLVSplitterFilter::NormalSeek(REFERENCE_TIME rt)
{
- bool fAudio = !!GetOutputPin(FLV_AUDIODATA);
- bool fVideo = !!GetOutputPin(FLV_VIDEODATA);
-
- __int64 pos = m_DataOffset + (__int64)(double(m_pFile->GetLength() - m_DataOffset) * rt / m_rtDuration);
-
- if (!Sync(pos)) {
- ASSERT(0);
- m_pFile->Seek(m_DataOffset);
- return;
- }
-
- Tag t;
- AudioTag at;
- VideoTag vt;
-
- while (ReadTag(t)) {
- if (10000i64 * t.TimeStamp >= rt) {
- m_pFile->Seek(m_pFile->GetPos() - 15);
- break;
- }
-
- m_pFile->Seek(m_pFile->GetPos() + t.DataSize);
- }
-
- while (m_pFile->GetPos() >= m_DataOffset && (fAudio || fVideo) && ReadTag(t)) {
- UINT64 prev = m_pFile->GetPos() - 15 - t.PreviousTagSize - 4;
-
- if (10000i64 * t.TimeStamp <= rt) {
- if (t.TagType == FLV_AUDIODATA && ReadTag(at)) {
- fAudio = false;
- } else if (t.TagType == FLV_VIDEODATA && ReadTag(vt) && vt.FrameType == 1) {
- fVideo = false;
- }
- }
-
- m_pFile->Seek(prev);
- }
-
- if (fAudio || fVideo) {
- ASSERT(0);
- m_pFile->Seek(m_DataOffset);
- }
+ bool fAudio = !!GetOutputPin(FLV_AUDIODATA);
+ bool fVideo = !!GetOutputPin(FLV_VIDEODATA);
+
+ __int64 pos = m_DataOffset + (__int64)(double(m_pFile->GetLength() - m_DataOffset) * rt / m_rtDuration);
+
+ if (!Sync(pos)) {
+ ASSERT(0);
+ m_pFile->Seek(m_DataOffset);
+ return;
+ }
+
+ Tag t;
+ AudioTag at;
+ VideoTag vt;
+
+ while (ReadTag(t)) {
+ if (10000i64 * t.TimeStamp >= rt) {
+ m_pFile->Seek(m_pFile->GetPos() - 15);
+ break;
+ }
+
+ m_pFile->Seek(m_pFile->GetPos() + t.DataSize);
+ }
+
+ while (m_pFile->GetPos() >= m_DataOffset && (fAudio || fVideo) && ReadTag(t)) {
+ UINT64 prev = m_pFile->GetPos() - 15 - t.PreviousTagSize - 4;
+
+ if (10000i64 * t.TimeStamp <= rt) {
+ if (t.TagType == FLV_AUDIODATA && ReadTag(at)) {
+ fAudio = false;
+ } else if (t.TagType == FLV_VIDEODATA && ReadTag(vt) && vt.FrameType == 1) {
+ fVideo = false;
+ }
+ }
+
+ m_pFile->Seek(prev);
+ }
+
+ if (fAudio || fVideo) {
+ ASSERT(0);
+ m_pFile->Seek(m_DataOffset);
+ }
}
void CFLVSplitterFilter::AlternateSeek(REFERENCE_TIME rt)
{
- bool hasAudio = !!GetOutputPin(FLV_AUDIODATA);
- bool hasVideo = !!GetOutputPin(FLV_VIDEODATA);
-
- __int64 estimPos = m_DataOffset + (__int64)(double(m_pFile->GetLength() - m_DataOffset) * rt / m_rtDuration);
-
- while (true) {
- estimPos -= 256 * 1024;
- if (estimPos < m_DataOffset) estimPos = m_DataOffset;
-
- bool foundAudio = !hasAudio;
- bool foundVideo = !hasVideo;
- __int64 bestPos = estimPos;
-
- if (Sync(bestPos)) {
- Tag t;
- AudioTag at;
- VideoTag vt;
-
- while (ReadTag(t) && t.TimeStamp * 10000i64 < rt) {
- __int64 cur = m_pFile->GetPos() - 15;
- __int64 next = cur + 15 + t.DataSize;
-
- if (hasAudio && t.TagType == FLV_AUDIODATA && ReadTag(at)) {
- foundAudio = true;
- if (!hasVideo) {
- bestPos = cur;
- }
- } else if (hasVideo && t.TagType == FLV_VIDEODATA && ReadTag(vt) && vt.FrameType == 1) {
- foundVideo = true;
- bestPos = cur;
- }
-
- m_pFile->Seek(next);
- }
- }
-
- if (foundAudio && foundVideo) {
- m_pFile->Seek(bestPos);
- return;
- } else if (estimPos == m_DataOffset) {
- m_pFile->Seek(m_DataOffset);
- return;
- }
-
- }
+ bool hasAudio = !!GetOutputPin(FLV_AUDIODATA);
+ bool hasVideo = !!GetOutputPin(FLV_VIDEODATA);
+
+ __int64 estimPos = m_DataOffset + (__int64)(double(m_pFile->GetLength() - m_DataOffset) * rt / m_rtDuration);
+
+ while (true) {
+ estimPos -= 256 * 1024;
+ if (estimPos < m_DataOffset) { estimPos = m_DataOffset; }
+
+ bool foundAudio = !hasAudio;
+ bool foundVideo = !hasVideo;
+ __int64 bestPos = estimPos;
+
+ if (Sync(bestPos)) {
+ Tag t;
+ AudioTag at;
+ VideoTag vt;
+
+ while (ReadTag(t) && t.TimeStamp * 10000i64 < rt) {
+ __int64 cur = m_pFile->GetPos() - 15;
+ __int64 next = cur + 15 + t.DataSize;
+
+ if (hasAudio && t.TagType == FLV_AUDIODATA && ReadTag(at)) {
+ foundAudio = true;
+ if (!hasVideo) {
+ bestPos = cur;
+ }
+ } else if (hasVideo && t.TagType == FLV_VIDEODATA && ReadTag(vt) && vt.FrameType == 1) {
+ foundVideo = true;
+ bestPos = cur;
+ }
+
+ m_pFile->Seek(next);
+ }
+ }
+
+ if (foundAudio && foundVideo) {
+ m_pFile->Seek(bestPos);
+ return;
+ } else if (estimPos == m_DataOffset) {
+ m_pFile->Seek(m_DataOffset);
+ return;
+ }
+
+ }
}
bool CFLVSplitterFilter::DemuxLoop()
{
- HRESULT hr = S_OK;
-
- CAutoPtr<Packet> p;
-
- Tag t;
- AudioTag at = {};
- VideoTag vt = {};
-
- while (SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetRemaining()) {
- if (!ReadTag(t)) {
- break;
- }
-
- __int64 next = m_pFile->GetPos() + t.DataSize;
-
- if ((t.DataSize > 0) && (t.TagType == FLV_AUDIODATA && ReadTag(at) || t.TagType == FLV_VIDEODATA && ReadTag(vt))) {
- UINT32 tsOffset = 0;
- if (t.TagType == FLV_VIDEODATA) {
- if (vt.FrameType == 5) {
- goto NextTag; // video info/command frame
- }
- if (vt.CodecID == FLV_VIDEO_VP6) {
- m_pFile->BitRead(8);
- } else if (vt.CodecID == FLV_VIDEO_VP6A) {
- m_pFile->BitRead(32);
- } else if (vt.CodecID == FLV_VIDEO_AVC) {
- if (m_pFile->BitRead(8) != 1) {
- goto NextTag;
- }
- // Tag timestamps specify decode time, this is the display time offset
- tsOffset = (UINT32)m_pFile->BitRead(24);
- tsOffset = (tsOffset + 0xff800000) ^ 0xff800000; // sign extension
- }
- }
- if (t.TagType == FLV_AUDIODATA && at.SoundFormat == FLV_AUDIO_AAC) {
- if (m_pFile->BitRead(8) != 1) {
- goto NextTag;
- }
- }
- __int64 dataSize = next - m_pFile->GetPos();
- if (dataSize <= 0) {
- goto NextTag;
- }
- p.Attach(DNew Packet());
- p->TrackNumber = t.TagType;
- p->rtStart = 10000i64 * (t.TimeStamp + tsOffset);
- p->rtStop = p->rtStart + 1;
- p->bSyncPoint = t.TagType == FLV_VIDEODATA ? vt.FrameType == 1 : true;
- p->SetCount((size_t)dataSize);
- m_pFile->ByteRead(p->GetData(), p->GetCount());
- hr = DeliverPacket(p);
- }
+ HRESULT hr = S_OK;
+
+ CAutoPtr<Packet> p;
+
+ Tag t;
+ AudioTag at = {};
+ VideoTag vt = {};
+
+ while (SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetRemaining()) {
+ if (!ReadTag(t)) {
+ break;
+ }
+
+ __int64 next = m_pFile->GetPos() + t.DataSize;
+
+ if ((t.DataSize > 0) && (t.TagType == FLV_AUDIODATA && ReadTag(at) || t.TagType == FLV_VIDEODATA && ReadTag(vt))) {
+ UINT32 tsOffset = 0;
+ if (t.TagType == FLV_VIDEODATA) {
+ if (vt.FrameType == 5) {
+ goto NextTag; // video info/command frame
+ }
+ if (vt.CodecID == FLV_VIDEO_VP6) {
+ m_pFile->BitRead(8);
+ } else if (vt.CodecID == FLV_VIDEO_VP6A) {
+ m_pFile->BitRead(32);
+ } else if (vt.CodecID == FLV_VIDEO_AVC) {
+ if (m_pFile->BitRead(8) != 1) {
+ goto NextTag;
+ }
+ // Tag timestamps specify decode time, this is the display time offset
+ tsOffset = (UINT32)m_pFile->BitRead(24);
+ tsOffset = (tsOffset + 0xff800000) ^ 0xff800000; // sign extension
+ }
+ }
+ if (t.TagType == FLV_AUDIODATA && at.SoundFormat == FLV_AUDIO_AAC) {
+ if (m_pFile->BitRead(8) != 1) {
+ goto NextTag;
+ }
+ }
+ __int64 dataSize = next - m_pFile->GetPos();
+ if (dataSize <= 0) {
+ goto NextTag;
+ }
+ p.Attach(DNew Packet());
+ p->TrackNumber = t.TagType;
+ p->rtStart = 10000i64 * (t.TimeStamp + tsOffset);
+ p->rtStop = p->rtStart + 1;
+ p->bSyncPoint = t.TagType == FLV_VIDEODATA ? vt.FrameType == 1 : true;
+ p->SetCount((size_t)dataSize);
+ m_pFile->ByteRead(p->GetData(), p->GetCount());
+ hr = DeliverPacket(p);
+ }
NextTag:
- m_pFile->Seek(next);
- }
+ m_pFile->Seek(next);
+ }
- return true;
+ return true;
}
//
@@ -905,8 +905,8 @@ NextTag:
//
CFLVSourceFilter::CFLVSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CFLVSplitterFilter(pUnk, phr)
+ : CFLVSplitterFilter(pUnk, phr)
{
- m_clsid = __uuidof(this);
- m_pInput.Free();
+ m_clsid = __uuidof(this);
+ m_pInput.Free();
}
diff --git a/src/filters/parser/FLVSplitter/FLVSplitter.h b/src/filters/parser/FLVSplitter/FLVSplitter.h
index e2f0a4250..e44fc7d1d 100644
--- a/src/filters/parser/FLVSplitter/FLVSplitter.h
+++ b/src/filters/parser/FLVSplitter/FLVSplitter.h
@@ -31,68 +31,68 @@
#define FlvSourceName L"MPC FLV Source"
class __declspec(uuid("47E792CF-0BBE-4F7A-859C-194B0768650A"))
- CFLVSplitterFilter : public CBaseSplitterFilter
+ CFLVSplitterFilter : public CBaseSplitterFilter
{
- UINT32 m_DataOffset;
- bool m_IgnorePrevSizes;
+ UINT32 m_DataOffset;
+ bool m_IgnorePrevSizes;
- bool Sync(__int64& pos);
+ bool Sync(__int64& pos);
- struct VideoTweak {
- BYTE x;
- BYTE y;
- };
+ struct VideoTweak {
+ BYTE x;
+ BYTE y;
+ };
- bool ReadTag(VideoTweak& t);
+ bool ReadTag(VideoTweak& t);
- struct Tag {
- UINT32 PreviousTagSize;
- BYTE TagType;
- UINT32 DataSize;
- UINT32 TimeStamp;
- UINT32 StreamID;
- };
+ struct Tag {
+ UINT32 PreviousTagSize;
+ BYTE TagType;
+ UINT32 DataSize;
+ UINT32 TimeStamp;
+ UINT32 StreamID;
+ };
- bool ReadTag(Tag& t);
+ bool ReadTag(Tag& t);
- struct AudioTag {
- BYTE SoundFormat;
- BYTE SoundRate;
- BYTE SoundSize;
- BYTE SoundType;
- };
+ struct AudioTag {
+ BYTE SoundFormat;
+ BYTE SoundRate;
+ BYTE SoundSize;
+ BYTE SoundType;
+ };
- bool ReadTag(AudioTag& at);
+ bool ReadTag(AudioTag& at);
- struct VideoTag {
- BYTE FrameType;
- BYTE CodecID;
- };
+ struct VideoTag {
+ BYTE FrameType;
+ BYTE CodecID;
+ };
- bool ReadTag(VideoTag& vt);
+ bool ReadTag(VideoTag& vt);
- void NormalSeek(REFERENCE_TIME rt);
- void AlternateSeek(REFERENCE_TIME rt);
+ void NormalSeek(REFERENCE_TIME rt);
+ void AlternateSeek(REFERENCE_TIME rt);
protected:
- CAutoPtr<CBaseSplitterFileEx> m_pFile;
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
+ CAutoPtr<CBaseSplitterFileEx> m_pFile;
+ HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
+ bool DemuxInit();
+ void DemuxSeek(REFERENCE_TIME rt);
+ bool DemuxLoop();
public:
- CFLVSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
+ CFLVSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
- // CBaseFilter
- STDMETHODIMP_(HRESULT) QueryFilterInfo(FILTER_INFO* pInfo);
+ // CBaseFilter
+ STDMETHODIMP_(HRESULT) QueryFilterInfo(FILTER_INFO* pInfo);
};
class __declspec(uuid("C9ECE7B3-1D8E-41F5-9F24-B255DF16C087"))
- CFLVSourceFilter : public CFLVSplitterFilter
+ CFLVSourceFilter : public CFLVSplitterFilter
{
public:
- CFLVSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
+ CFLVSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
};
diff --git a/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.cpp b/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.cpp
index 2824094a2..dc07cce13 100644
--- a/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.cpp
+++ b/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.cpp
@@ -2,79 +2,79 @@
#include "Ap4AsyncReaderStream.h"
AP4_AsyncReaderStream::AP4_AsyncReaderStream(CBaseSplitterFile* pFile)
- : m_refs(1)
- , m_pFile(pFile)
+ : m_refs(1)
+ , m_pFile(pFile)
{
- ASSERT(pFile);
+ ASSERT(pFile);
}
AP4_AsyncReaderStream::~AP4_AsyncReaderStream()
{
- ASSERT(m_refs == 0);
+ ASSERT(m_refs == 0);
}
void AP4_AsyncReaderStream::AddReference()
{
- ASSERT(m_refs > 0);
- ++m_refs;
+ ASSERT(m_refs > 0);
+ ++m_refs;
}
void AP4_AsyncReaderStream::Release()
{
- ASSERT(m_refs > 0);
- if (--m_refs == 0) {
- delete this;
- }
+ ASSERT(m_refs > 0);
+ if (--m_refs == 0) {
+ delete this;
+ }
}
AP4_Result AP4_AsyncReaderStream::Read(void* buffer, AP4_Size bytesToRead, AP4_Size* bytesRead)
{
- __int64 bytesAvail = m_pFile->GetRemaining();
+ __int64 bytesAvail = m_pFile->GetRemaining();
- if (bytesAvail < (long long)bytesToRead) {
- if (bytesRead) {
- *bytesRead = bytesAvail;
- }
- bytesToRead = bytesAvail;
- }
+ if (bytesAvail < (long long)bytesToRead) {
+ if (bytesRead) {
+ *bytesRead = bytesAvail;
+ }
+ bytesToRead = bytesAvail;
+ }
- if (bytesAvail == 0) {
- return AP4_ERROR_EOS;
- }
+ if (bytesAvail == 0) {
+ return AP4_ERROR_EOS;
+ }
- if (FAILED(m_pFile->ByteRead((BYTE*)buffer, bytesToRead))) {
- if (bytesRead) {
- *bytesRead = 0;
- }
- return AP4_ERROR_READ_FAILED;
- }
+ if (FAILED(m_pFile->ByteRead((BYTE*)buffer, bytesToRead))) {
+ if (bytesRead) {
+ *bytesRead = 0;
+ }
+ return AP4_ERROR_READ_FAILED;
+ }
- if (bytesRead) {
- *bytesRead = bytesToRead;
- }
+ if (bytesRead) {
+ *bytesRead = bytesToRead;
+ }
- return AP4_SUCCESS;
+ return AP4_SUCCESS;
}
AP4_Result AP4_AsyncReaderStream::Write(const void* buffer, AP4_Size bytesToWrite, AP4_Size* bytesWritten)
{
- return AP4_ERROR_WRITE_FAILED;
+ return AP4_ERROR_WRITE_FAILED;
}
AP4_Result AP4_AsyncReaderStream::Seek(AP4_Offset offset)
{
- m_pFile->Seek(offset);
- return m_pFile->GetPos() == offset ? AP4_SUCCESS : AP4_FAILURE;
+ m_pFile->Seek(offset);
+ return m_pFile->GetPos() == offset ? AP4_SUCCESS : AP4_FAILURE;
}
AP4_Result AP4_AsyncReaderStream::Tell(AP4_Offset& offset)
{
- offset = (AP4_Offset)m_pFile->GetPos();
- return AP4_SUCCESS;
+ offset = (AP4_Offset)m_pFile->GetPos();
+ return AP4_SUCCESS;
}
AP4_Result AP4_AsyncReaderStream::GetSize(AP4_Size& size)
{
- size = (AP4_Size)m_pFile->GetLength();
- return AP4_SUCCESS;
+ size = (AP4_Size)m_pFile->GetLength();
+ return AP4_SUCCESS;
} \ No newline at end of file
diff --git a/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.h b/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.h
index f1e1a14a2..aec075a1f 100644
--- a/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.h
+++ b/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.h
@@ -4,31 +4,23 @@
#include "Ap4.h"
#include "Ap4File.h"
-//#include "Ap4Utils.h"
-//#include "Ap4Sample.h"
#include "Ap4ByteStream.h"
-//#include "Ap4SampleEntry.h"
-//#include "Ap4IsmaCryp.h"
-//#include "Ap4AvcCAtom.h"
-//#include "Ap4FtabAtom.h"
-//#include "Ap4MdhdAtom.h"
-//#include "Ap4HdlrAtom.h"
class AP4_AsyncReaderStream : public AP4_ByteStream
{
- int m_refs;
- CBaseSplitterFile* m_pFile;
+ int m_refs;
+ CBaseSplitterFile* m_pFile;
public:
- AP4_AsyncReaderStream(CBaseSplitterFile* pFile);
- virtual ~AP4_AsyncReaderStream();
+ AP4_AsyncReaderStream(CBaseSplitterFile* pFile);
+ virtual ~AP4_AsyncReaderStream();
- void AddReference();
- void Release();
+ void AddReference();
+ void Release();
- AP4_Result Read(void* buffer, AP4_Size bytesToRead, AP4_Size* bytesRead);
- AP4_Result Write(const void* buffer, AP4_Size bytesToWrite, AP4_Size* bytesWritten);
- AP4_Result Seek(AP4_Offset offset);
- AP4_Result Tell(AP4_Offset& offset);
- AP4_Result GetSize(AP4_Size& size);
+ AP4_Result Read(void* buffer, AP4_Size bytesToRead, AP4_Size* bytesRead);
+ AP4_Result Write(const void* buffer, AP4_Size bytesToWrite, AP4_Size* bytesWritten);
+ AP4_Result Seek(AP4_Offset offset);
+ AP4_Result Tell(AP4_Offset& offset);
+ AP4_Result GetSize(AP4_Size& size);
}; \ No newline at end of file
diff --git a/src/filters/parser/MP4Splitter/MP4Splitter.cpp b/src/filters/parser/MP4Splitter/MP4Splitter.cpp
index 74254469d..a5ab36613 100644
--- a/src/filters/parser/MP4Splitter/MP4Splitter.cpp
+++ b/src/filters/parser/MP4Splitter/MP4Splitter.cpp
@@ -46,58 +46,58 @@
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_MP4},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_MP4},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CMP4SplitterFilter), MP4SplitterName, MERIT_NORMAL, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CMP4SourceFilter), MP4SourceName, MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CMPEG4VideoSplitterFilter), L"MPC MPEG4 Video Splitter", MERIT_NORMAL, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CMPEG4VideoSourceFilter), L"MPC MPEG4 Video Source", MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CMP4SplitterFilter), MP4SplitterName, MERIT_NORMAL, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CMP4SourceFilter), MP4SourceName, MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CMPEG4VideoSplitterFilter), L"MPC MPEG4 Video Splitter", MERIT_NORMAL, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CMPEG4VideoSourceFilter), L"MPC MPEG4 Video Source", MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMP4SplitterFilter>, NULL, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CMP4SourceFilter>, NULL, &sudFilter[1]},
- {sudFilter[2].strName, sudFilter[2].clsID, CreateInstance<CMPEG4VideoSplitterFilter>, NULL, &sudFilter[2]},
- {sudFilter[3].strName, sudFilter[3].clsID, CreateInstance<CMPEG4VideoSourceFilter>, NULL, &sudFilter[3]},
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMP4SplitterFilter>, NULL, &sudFilter[0]},
+ {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CMP4SourceFilter>, NULL, &sudFilter[1]},
+ {sudFilter[2].strName, sudFilter[2].clsID, CreateInstance<CMPEG4VideoSplitterFilter>, NULL, &sudFilter[2]},
+ {sudFilter[3].strName, sudFilter[3].clsID, CreateInstance<CMPEG4VideoSourceFilter>, NULL, &sudFilter[3]},
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- DeleteRegKey(_T("Media Type\\Extensions\\"), _T(".mp4"));
- DeleteRegKey(_T("Media Type\\Extensions\\"), _T(".mov"));
+ DeleteRegKey(_T("Media Type\\Extensions\\"), _T(".mp4"));
+ DeleteRegKey(_T("Media Type\\Extensions\\"), _T(".mov"));
- CAtlList<CString> chkbytes;
+ CAtlList<CString> chkbytes;
- // mp4
- chkbytes.AddTail(_T("4,4,,66747970")); // ftyp
- chkbytes.AddTail(_T("4,4,,6d6f6f76")); // moov
- chkbytes.AddTail(_T("4,4,,6d646174")); // mdat
- chkbytes.AddTail(_T("4,4,,736b6970")); // skip
- chkbytes.AddTail(_T("4,12,ffffffff00000000ffffffff,77696465027fe3706d646174")); // wide ? mdat
+ // mp4
+ chkbytes.AddTail(_T("4,4,,66747970")); // ftyp
+ chkbytes.AddTail(_T("4,4,,6d6f6f76")); // moov
+ chkbytes.AddTail(_T("4,4,,6d646174")); // mdat
+ chkbytes.AddTail(_T("4,4,,736b6970")); // skip
+ chkbytes.AddTail(_T("4,12,ffffffff00000000ffffffff,77696465027fe3706d646174")); // wide ? mdat
- // mpeg4 video
- chkbytes.AddTail(_T("3,3,,000001"));
+ // mpeg4 video
+ chkbytes.AddTail(_T("3,3,,000001"));
- RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_MP4, chkbytes, NULL);
+ RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_MP4, chkbytes, NULL);
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- UnRegisterSourceFilter(MEDIASUBTYPE_MP4);
+ UnRegisterSourceFilter(MEDIASUBTYPE_MP4);
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -107,294 +107,294 @@ CFilterApp theApp;
#endif
struct SSACharacter {
- CString pre, post;
- WCHAR c;
+ CString pre, post;
+ WCHAR c;
};
static CStringW ConvertTX3GToSSA(
- CStringW str,
- const AP4_Tx3gSampleEntry::AP4_Tx3gDescription& desc,
- CStringW font,
- const AP4_Byte* mods,
- int size,
- CSize framesize,
- CPoint translation,
- int durationms,
- CRect& rbox)
+ CStringW str,
+ const AP4_Tx3gSampleEntry::AP4_Tx3gDescription& desc,
+ CStringW font,
+ const AP4_Byte* mods,
+ int size,
+ CSize framesize,
+ CPoint translation,
+ int durationms,
+ CRect& rbox)
{
- int str_len = str.GetLength();
-
- SSACharacter* chars = DNew SSACharacter[str_len];
- for (int i = 0; i < str_len; ++i) {
- chars[i].c = str[i];
- }
- str.Empty();
-
- //
-
- rbox.SetRect(desc.TextBox.Left, desc.TextBox.Top, desc.TextBox.Right, desc.TextBox.Bottom);
-
- int align = 2;
- signed char h = (signed char)desc.HorizontalJustification;
- signed char v = (signed char)desc.VerticalJustification;
- if (h == 0 && v < 0) {
- align = 1;
- } else if (h > 0 && v < 0) {
- align = 2;
- } else if (h < 0 && v < 0) {
- align = 3;
- } else if (h == 0 && v > 0) {
- align = 4;
- } else if (h > 0 && v > 0) {
- align = 5;
- } else if (h < 0 && v > 0) {
- align = 6;
- } else if (h == 0 && v == 0) {
- align = 7;
- } else if (h > 0 && v == 0) {
- align = 8;
- } else if (h < 0 && v == 0) {
- align = 9;
- }
- str.Format(L"{\\an%d}%s", align, CStringW(str));
-
- if (!font.CompareNoCase(L"serif")) {
- font = L"Times New Roman";
- } else if (!font.CompareNoCase(L"sans-serif")) {
- font = L"Arial";
- } else if (!font.CompareNoCase(L"monospace")) {
- font = L"Courier New";
- }
- str.Format(L"{\\fn%s}%s", font, CStringW(str));
-
- const AP4_Byte* fclr = (const AP4_Byte*)&desc.Style.Font.Color;
-
- CStringW font_color;
- font_color.Format(L"{\\1c%02x%02x%02x\\1a%02x}", fclr[2], fclr[1], fclr[0], 255 - fclr[3]);
- str = font_color + str;
-
- str.Format(L"%s{\\2c%02x%02x%02x\\2a%02x}", CString(str), fclr[2], fclr[1], fclr[0], 255 - fclr[3]);
-
- CStringW font_size;
- font_size.Format(L"{\\fs%d}", desc.Style.Font.Size);
- str = font_size + str;
-
- CStringW font_flags;
- font_flags.Format(L"{\\b%d\\i%d\\u%d}",
- (desc.Style.Font.Face&1) ? 1 : 0,
- (desc.Style.Font.Face&2) ? 1 : 0,
- (desc.Style.Font.Face&4) ? 1 : 0);
- str = font_flags + str;
-
- //
-
- const AP4_Byte* hclr = (const AP4_Byte*)&desc.BackgroundColor;
-
- while (size > 8) {
- DWORD tag_size = (mods[0]<<24)|(mods[1]<<16)|(mods[2]<<8)|(mods[3]);
- mods += 4;
- DWORD tag = (mods[0]<<24)|(mods[1]<<16)|(mods[2]<<8)|(mods[3]);
- mods += 4;
-
- size -= tag_size;
- tag_size -= 8;
- const AP4_Byte* next = mods + tag_size;
-
- if (tag == 'styl') {
- WORD styl_count = (mods[0]<<8)|(mods[1]);
- mods += 2;
-
- while (styl_count-- > 0) {
- WORD start = (mods[0]<<8)|(mods[1]);
- mods += 2;
- WORD end = (mods[0]<<8)|(mods[1]);
- mods += 2;
- WORD font_id = (mods[0]<<8)|(mods[1]);
- mods += 2;
- WORD flags = mods[0];
- mods += 1;
- WORD size = mods[0];
- mods += 1;
- const AP4_Byte* color = mods;
- mods += 4;
-
- if (end > str_len) {
- end = str_len;
- }
-
- if (start < end) {
- CStringW s;
-
- s.Format(L"{\\1c%02x%02x%02x\\1a%02x}", color[2], color[1], color[0], 255 - color[3]);
- chars[start].pre += s;
- chars[end-1].post += font_color;
-
- s.Format(L"{\\fs%d}", size);
- chars[start].pre += s;
- chars[end-1].post += font_size;
-
- s.Format(L"{\\b%d\\i%d\\u%d}", (flags&1) ? 1 : 0, (flags&2) ? 1 : 0, (flags&4) ? 1 : 0);
- chars[start].pre += s;
- chars[end-1].post += font_flags;
- }
- }
- } else if (tag == 'hclr') {
- hclr = mods;
- } else if (tag == 'hlit') {
- WORD start = (mods[0]<<8)|(mods[1]);
- mods += 2;
- WORD end = (mods[0]<<8)|(mods[1]);
- mods += 2;
-
- if (end > str_len) {
- end = str_len;
- }
-
- if (start < end) {
- CStringW s;
-
- s.Format(L"{\\3c%02x%02x%02x\\3a%02x}", hclr[2], hclr[1], hclr[0], 255 - hclr[3]);
- chars[start].pre += s;
- chars[end-1].post += font_color;
-
- chars[start].pre += L"{\\bord0.1}";
- chars[end-1].post += L"{\\bord}";
- }
- } else if (tag == 'blnk') {
- WORD start = (mods[0]<<8)|(mods[1]);
- mods += 2;
- WORD end = (mods[0]<<8)|(mods[1]);
- mods += 2;
-
- if (end > str_len) {
- end = str_len;
- }
-
- if (start < end) {
- // cheap...
-
- for (int i = 0, alpha = 255; i < durationms; i += 750, alpha = 255 - alpha) {
- CStringW s;
- s.Format(L"{\\t(%d, %d, \\alpha&H%02x&)}", i, i + 750, alpha);
- chars[start].pre += s;
- }
-
- chars[end-1].post += L"{\\alpha}";
- }
- } else if (tag == 'tbox') {
- rbox.top = (mods[0]<<8)|(mods[1]);
- mods += 2;
- rbox.left = (mods[0]<<8)|(mods[1]);
- mods += 2;
- rbox.bottom = (mods[0]<<8)|(mods[1]);
- mods += 2;
- rbox.right = (mods[0]<<8)|(mods[1]);
- mods += 2;
- } else if (tag == 'krok' && !(desc.DisplayFlags & 0x800)) {
- DWORD start_time = (mods[0]<<24)|(mods[1]<<16)|(mods[2]<<8)|(mods[3]);
- mods += 4;
- WORD krok_count = (mods[0]<<8)|(mods[1]);
- mods += 2;
-
- while (krok_count-- > 0) {
- DWORD end_time = (mods[0]<<24)|(mods[1]<<16)|(mods[2]<<8)|(mods[3]);
- mods += 4;
- WORD start = (mods[0]<<8)|(mods[1]);
- mods += 2;
- WORD end = (mods[0]<<8)|(mods[1]);
- mods += 2;
-
- if (end > str_len) {
- end = str_len;
- }
-
- if (start < end) {
- CStringW s;
-
- s.Format(L"{\\kt%d\\kf%d}", start_time/10, (end_time - start_time)/10);
- chars[start].pre += s;
- s.Format(L"{\\1c%02x%02x%02x\\1a%02x}", hclr[2], hclr[1], hclr[0], 255 - hclr[3]);
- chars[start].pre += s;
- chars[end-1].post += L"{\\kt}" + font_color;
- }
-
- start_time = end_time;
- }
- }
-
- mods = next;
- }
-
- // continous karaoke
-
- if (desc.DisplayFlags & 0x800) {
- CStringW s;
-
- s.Format(L"{\\1c%02x%02x%02x\\1a%02x}", hclr[2], hclr[1], hclr[0], 255 - hclr[3]);
- str += s;
-
- int breaks = 0;
-
- for (int i = 0, j = 0; i <= str_len; ++i) {
- if (chars[i].c == '\n' /*|| chars[i].c == ' '*/) {
- ++breaks;
- }
- }
-
- if (str_len > breaks) {
- float dur = (float)max(durationms - 500, 0) / 10;
-
- for (int i = 0, j = 0; i <= str_len; ++i) {
- if (i == str_len || chars[i].c == '\n' /*|| chars[i].c == ' '*/) {
- s.Format(L"{\\kf%d}", (int)(dur * (i - j) / (str_len - breaks)));
- chars[j].pre += s;
- j = i+1;
- }
- }
- }
- }
-
- //
-
- for (int i = 0; i < str_len; ++i) {
- str += chars[i].pre;
- str += chars[i].c;
- if (desc.DisplayFlags & 0x20000) {
- str += L"\\N";
- }
- str += chars[i].post;
- }
-
- delete [] chars;
-
- //
-
- if (rbox.IsRectEmpty()) {
- rbox.SetRect(0, 0, framesize.cx, framesize.cy);
- }
- rbox.OffsetRect(translation);
-
- CRect rbox2 = rbox;
- rbox2.DeflateRect(2, 2);
-
- CRect r(0,0,0,0);
- if (rbox2.Height() > 0) {
- r.top = rbox2.top;
- r.bottom = framesize.cy - rbox2.bottom;
- }
- if (rbox2.Width() > 0) {
- r.left = rbox2.left;
- r.right = framesize.cx - rbox2.right;
- }
-
- CStringW hdr;
- hdr.Format(L"0,0,Text,,%d,%d,%d,%d,,{\\clip(%d,%d,%d,%d)}",
- r.left, r.right, r.top, r.bottom,
- rbox.left, rbox.top, rbox.right, rbox.bottom);
-
- //
-
- return hdr + str;
+ int str_len = str.GetLength();
+
+ SSACharacter* chars = DNew SSACharacter[str_len];
+ for (int i = 0; i < str_len; ++i) {
+ chars[i].c = str[i];
+ }
+ str.Empty();
+
+ //
+
+ rbox.SetRect(desc.TextBox.Left, desc.TextBox.Top, desc.TextBox.Right, desc.TextBox.Bottom);
+
+ int align = 2;
+ signed char h = (signed char)desc.HorizontalJustification;
+ signed char v = (signed char)desc.VerticalJustification;
+ if (h == 0 && v < 0) {
+ align = 1;
+ } else if (h > 0 && v < 0) {
+ align = 2;
+ } else if (h < 0 && v < 0) {
+ align = 3;
+ } else if (h == 0 && v > 0) {
+ align = 4;
+ } else if (h > 0 && v > 0) {
+ align = 5;
+ } else if (h < 0 && v > 0) {
+ align = 6;
+ } else if (h == 0 && v == 0) {
+ align = 7;
+ } else if (h > 0 && v == 0) {
+ align = 8;
+ } else if (h < 0 && v == 0) {
+ align = 9;
+ }
+ str.Format(L"{\\an%d}%s", align, CStringW(str));
+
+ if (!font.CompareNoCase(L"serif")) {
+ font = L"Times New Roman";
+ } else if (!font.CompareNoCase(L"sans-serif")) {
+ font = L"Arial";
+ } else if (!font.CompareNoCase(L"monospace")) {
+ font = L"Courier New";
+ }
+ str.Format(L"{\\fn%s}%s", font, CStringW(str));
+
+ const AP4_Byte* fclr = (const AP4_Byte*)&desc.Style.Font.Color;
+
+ CStringW font_color;
+ font_color.Format(L"{\\1c%02x%02x%02x\\1a%02x}", fclr[2], fclr[1], fclr[0], 255 - fclr[3]);
+ str = font_color + str;
+
+ str.Format(L"%s{\\2c%02x%02x%02x\\2a%02x}", CString(str), fclr[2], fclr[1], fclr[0], 255 - fclr[3]);
+
+ CStringW font_size;
+ font_size.Format(L"{\\fs%d}", desc.Style.Font.Size);
+ str = font_size + str;
+
+ CStringW font_flags;
+ font_flags.Format(L"{\\b%d\\i%d\\u%d}",
+ (desc.Style.Font.Face & 1) ? 1 : 0,
+ (desc.Style.Font.Face & 2) ? 1 : 0,
+ (desc.Style.Font.Face & 4) ? 1 : 0);
+ str = font_flags + str;
+
+ //
+
+ const AP4_Byte* hclr = (const AP4_Byte*)&desc.BackgroundColor;
+
+ while (size > 8) {
+ DWORD tag_size = (mods[0] << 24) | (mods[1] << 16) | (mods[2] << 8) | (mods[3]);
+ mods += 4;
+ DWORD tag = (mods[0] << 24) | (mods[1] << 16) | (mods[2] << 8) | (mods[3]);
+ mods += 4;
+
+ size -= tag_size;
+ tag_size -= 8;
+ const AP4_Byte* next = mods + tag_size;
+
+ if (tag == 'styl') {
+ WORD styl_count = (mods[0] << 8) | (mods[1]);
+ mods += 2;
+
+ while (styl_count-- > 0) {
+ WORD start = (mods[0] << 8) | (mods[1]);
+ mods += 2;
+ WORD end = (mods[0] << 8) | (mods[1]);
+ mods += 2;
+ WORD font_id = (mods[0] << 8) | (mods[1]);
+ mods += 2;
+ WORD flags = mods[0];
+ mods += 1;
+ WORD size = mods[0];
+ mods += 1;
+ const AP4_Byte* color = mods;
+ mods += 4;
+
+ if (end > str_len) {
+ end = str_len;
+ }
+
+ if (start < end) {
+ CStringW s;
+
+ s.Format(L"{\\1c%02x%02x%02x\\1a%02x}", color[2], color[1], color[0], 255 - color[3]);
+ chars[start].pre += s;
+ chars[end - 1].post += font_color;
+
+ s.Format(L"{\\fs%d}", size);
+ chars[start].pre += s;
+ chars[end - 1].post += font_size;
+
+ s.Format(L"{\\b%d\\i%d\\u%d}", (flags & 1) ? 1 : 0, (flags & 2) ? 1 : 0, (flags & 4) ? 1 : 0);
+ chars[start].pre += s;
+ chars[end - 1].post += font_flags;
+ }
+ }
+ } else if (tag == 'hclr') {
+ hclr = mods;
+ } else if (tag == 'hlit') {
+ WORD start = (mods[0] << 8) | (mods[1]);
+ mods += 2;
+ WORD end = (mods[0] << 8) | (mods[1]);
+ mods += 2;
+
+ if (end > str_len) {
+ end = str_len;
+ }
+
+ if (start < end) {
+ CStringW s;
+
+ s.Format(L"{\\3c%02x%02x%02x\\3a%02x}", hclr[2], hclr[1], hclr[0], 255 - hclr[3]);
+ chars[start].pre += s;
+ chars[end - 1].post += font_color;
+
+ chars[start].pre += L"{\\bord0.1}";
+ chars[end - 1].post += L"{\\bord}";
+ }
+ } else if (tag == 'blnk') {
+ WORD start = (mods[0] << 8) | (mods[1]);
+ mods += 2;
+ WORD end = (mods[0] << 8) | (mods[1]);
+ mods += 2;
+
+ if (end > str_len) {
+ end = str_len;
+ }
+
+ if (start < end) {
+ // cheap...
+
+ for (int i = 0, alpha = 255; i < durationms; i += 750, alpha = 255 - alpha) {
+ CStringW s;
+ s.Format(L"{\\t(%d, %d, \\alpha&H%02x&)}", i, i + 750, alpha);
+ chars[start].pre += s;
+ }
+
+ chars[end - 1].post += L"{\\alpha}";
+ }
+ } else if (tag == 'tbox') {
+ rbox.top = (mods[0] << 8) | (mods[1]);
+ mods += 2;
+ rbox.left = (mods[0] << 8) | (mods[1]);
+ mods += 2;
+ rbox.bottom = (mods[0] << 8) | (mods[1]);
+ mods += 2;
+ rbox.right = (mods[0] << 8) | (mods[1]);
+ mods += 2;
+ } else if (tag == 'krok' && !(desc.DisplayFlags & 0x800)) {
+ DWORD start_time = (mods[0] << 24) | (mods[1] << 16) | (mods[2] << 8) | (mods[3]);
+ mods += 4;
+ WORD krok_count = (mods[0] << 8) | (mods[1]);
+ mods += 2;
+
+ while (krok_count-- > 0) {
+ DWORD end_time = (mods[0] << 24) | (mods[1] << 16) | (mods[2] << 8) | (mods[3]);
+ mods += 4;
+ WORD start = (mods[0] << 8) | (mods[1]);
+ mods += 2;
+ WORD end = (mods[0] << 8) | (mods[1]);
+ mods += 2;
+
+ if (end > str_len) {
+ end = str_len;
+ }
+
+ if (start < end) {
+ CStringW s;
+
+ s.Format(L"{\\kt%d\\kf%d}", start_time / 10, (end_time - start_time) / 10);
+ chars[start].pre += s;
+ s.Format(L"{\\1c%02x%02x%02x\\1a%02x}", hclr[2], hclr[1], hclr[0], 255 - hclr[3]);
+ chars[start].pre += s;
+ chars[end - 1].post += L"{\\kt}" + font_color;
+ }
+
+ start_time = end_time;
+ }
+ }
+
+ mods = next;
+ }
+
+ // continous karaoke
+
+ if (desc.DisplayFlags & 0x800) {
+ CStringW s;
+
+ s.Format(L"{\\1c%02x%02x%02x\\1a%02x}", hclr[2], hclr[1], hclr[0], 255 - hclr[3]);
+ str += s;
+
+ int breaks = 0;
+
+ for (int i = 0, j = 0; i <= str_len; ++i) {
+ if (chars[i].c == '\n' /*|| chars[i].c == ' '*/) {
+ ++breaks;
+ }
+ }
+
+ if (str_len > breaks) {
+ float dur = (float)max(durationms - 500, 0) / 10;
+
+ for (int i = 0, j = 0; i <= str_len; ++i) {
+ if (i == str_len || chars[i].c == '\n' /*|| chars[i].c == ' '*/) {
+ s.Format(L"{\\kf%d}", (int)(dur * (i - j) / (str_len - breaks)));
+ chars[j].pre += s;
+ j = i + 1;
+ }
+ }
+ }
+ }
+
+ //
+
+ for (int i = 0; i < str_len; ++i) {
+ str += chars[i].pre;
+ str += chars[i].c;
+ if (desc.DisplayFlags & 0x20000) {
+ str += L"\\N";
+ }
+ str += chars[i].post;
+ }
+
+ delete [] chars;
+
+ //
+
+ if (rbox.IsRectEmpty()) {
+ rbox.SetRect(0, 0, framesize.cx, framesize.cy);
+ }
+ rbox.OffsetRect(translation);
+
+ CRect rbox2 = rbox;
+ rbox2.DeflateRect(2, 2);
+
+ CRect r(0, 0, 0, 0);
+ if (rbox2.Height() > 0) {
+ r.top = rbox2.top;
+ r.bottom = framesize.cy - rbox2.bottom;
+ }
+ if (rbox2.Width() > 0) {
+ r.left = rbox2.left;
+ r.right = framesize.cx - rbox2.right;
+ }
+
+ CStringW hdr;
+ hdr.Format(L"0,0,Text,,%d,%d,%d,%d,,{\\clip(%d,%d,%d,%d)}",
+ r.left, r.right, r.top, r.bottom,
+ rbox.left, rbox.top, rbox.right, rbox.bottom);
+
+ //
+
+ return hdr + str;
}
//
@@ -402,7 +402,7 @@ static CStringW ConvertTX3GToSSA(
//
CMP4SplitterFilter::CMP4SplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("CMP4SplitterFilter"), pUnk, phr, __uuidof(this))
+ : CBaseSplitterFilter(NAME("CMP4SplitterFilter"), pUnk, phr, __uuidof(this))
{
}
@@ -412,1286 +412,1288 @@ CMP4SplitterFilter::~CMP4SplitterFilter()
STDMETHODIMP CMP4SplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo)
{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
-
- if (m_pName && m_pName[0]==L'M' && m_pName[1]==L'P' && m_pName[2]==L'C') {
- (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
- } else {
- wcscpy_s(pInfo->achName, MP4SourceName);
- }
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
+ CheckPointer(pInfo, E_POINTER);
+ ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
+
+ if (m_pName && m_pName[0] == L'M' && m_pName[1] == L'P' && m_pName[2] == L'C') {
+ (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
+ } else {
+ wcscpy_s(pInfo->achName, MP4SourceName);
+ }
+ pInfo->pGraph = m_pGraph;
+ if (m_pGraph) {
+ m_pGraph->AddRef();
+ }
+
+ return S_OK;
}
-void SetTrackName(CString *TrackName, CString Suffix)
+void SetTrackName(CString* TrackName, CString Suffix)
{
- if (TrackName->IsEmpty()) {
- *TrackName = Suffix;
- } else {
- *TrackName += _T(" - ");
- *TrackName += Suffix;
- }
+ if (TrackName->IsEmpty()) {
+ *TrackName = Suffix;
+ } else {
+ *TrackName += _T(" - ");
+ *TrackName += Suffix;
+ }
}
HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
{
- CheckPointer(pAsyncReader, E_POINTER);
-
- HRESULT hr = E_FAIL;
-
- //bool b_HasVideo = false;
-
- m_trackpos.RemoveAll();
-
- m_pFile.Free();
- m_pFile.Attach(DNew CMP4SplitterFile(pAsyncReader, hr));
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration = 0;
- REFERENCE_TIME rtVideoDuration = 0;
-
- m_framesize.SetSize(640, 480);
-
- if (AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie()) {
- // looking for main video track (skip tracks with motionless frames)
- AP4_UI32 mainvideoID = 0;
- for (AP4_List<AP4_Track>::Item* item = movie->GetTracks().FirstItem();
- item;
- item = item->GetNext()) {
- AP4_Track* track = item->GetData();
-
- if (track->GetType() != AP4_Track::TYPE_VIDEO) {
- continue;
- }
- if (!mainvideoID) {
- mainvideoID = track->GetId();
- }
- if (AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
- if (stss->m_Entries.ItemCount() > 0) {
- mainvideoID = track->GetId();
- break;
- }
- }
- }
- // process the tracks
- for (AP4_List<AP4_Track>::Item* item = movie->GetTracks().FirstItem();
- item;
- item = item->GetNext()) {
- AP4_Track* track = item->GetData();
-
- if (track->GetType() != AP4_Track::TYPE_VIDEO
- && track->GetType() != AP4_Track::TYPE_AUDIO
- && track->GetType() != AP4_Track::TYPE_TEXT
- && track->GetType() != AP4_Track::TYPE_SUBP) {
- continue;
- }
-
- //if (b_HasVideo && track->GetType() == AP4_Track::TYPE_VIDEO) {
- if (track->GetType() == AP4_Track::TYPE_VIDEO && track->GetId() != mainvideoID) {
- continue;
- }
-
- AP4_Sample sample;
-
- if (!AP4_SUCCEEDED(track->GetSample(0, sample)) || sample.GetDescriptionIndex() == 0xFFFFFFFF) {
- continue;
- }
-
- CStringW TrackName = UTF8ToStringW(track->GetTrackName().c_str());
- if (TrackName.IsEmpty()) {
- TrackName = LocalToStringW(track->GetTrackName().c_str()); //Trying Local...
- }
- TrackName.TrimLeft(_T("\x0010\x0013\x0015\x0017\x0018\x0019\x001A\x001B"));
- TrackName.Trim();
-
- CStringA TrackLanguage = track->GetTrackLanguage().c_str();
-
- CAtlArray<CMediaType> mts;
-
- CMediaType mt;
- mt.SetSampleSize(1);
-
- VIDEOINFOHEADER* vih = NULL;
- WAVEFORMATEX* wfe = NULL;
-
- AP4_DataBuffer empty;
-
- if (AP4_SampleDescription* desc = track->GetSampleDescription(sample.GetDescriptionIndex())) {
- AP4_MpegSampleDescription* mpeg_desc = NULL;
-
- if (desc->GetType() == AP4_SampleDescription::TYPE_MPEG) {
- mpeg_desc = dynamic_cast<AP4_MpegSampleDescription*>(desc);
- } else if (desc->GetType() == AP4_SampleDescription::TYPE_ISMACRYP) {
- AP4_IsmaCrypSampleDescription* isma_desc = dynamic_cast<AP4_IsmaCrypSampleDescription*>(desc);
- mpeg_desc = isma_desc->GetOriginalSampleDescription();
- }
-
- if (mpeg_desc) {
- CStringW TypeString = CStringW(mpeg_desc->GetObjectTypeString(mpeg_desc->GetObjectTypeId()));
- if ((TypeString.Find(_T("UNKNOWN")) == -1) && (TypeString.Find(_T("INVALID")) == -1)) {
- SetTrackName(&TrackName, TypeString);
- }
- }
-
- if (AP4_MpegVideoSampleDescription* video_desc =
- dynamic_cast<AP4_MpegVideoSampleDescription*>(mpeg_desc)) {
- const AP4_DataBuffer* di = video_desc->GetDecoderInfo();
- if (!di) {
- di = &empty;
- }
-
- LONG biWidth = (LONG)video_desc->GetWidth();
- LONG biHeight = (LONG)video_desc->GetHeight();
-
- if (!biWidth || !biHeight) {
- if (AP4_TkhdAtom* tkhd = dynamic_cast<AP4_TkhdAtom*>(track->GetTrakAtom()->GetChild(AP4_ATOM_TYPE_TKHD))) {
- biWidth = tkhd->GetWidth()>>16;
- biHeight = tkhd->GetHeight()>>16;
- }
- }
-
- if (!biWidth || !biHeight) {
- continue;
- }
-
- mt.majortype = MEDIATYPE_Video;
- mt.formattype = FORMAT_VideoInfo;
- vih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + di->GetDataSize());
- memset(vih, 0, mt.FormatLength());
- vih->dwBitRate = video_desc->GetAvgBitrate()/8;
- vih->bmiHeader.biSize = sizeof(vih->bmiHeader);
- vih->bmiHeader.biWidth = biWidth;
- vih->bmiHeader.biHeight = biHeight;
- memcpy(vih + 1, di->GetData(), di->GetDataSize());
-
- switch (video_desc->GetObjectTypeId()) {
- case AP4_MPEG4_VISUAL_OTI:
- mt.subtype = FOURCCMap('v4pm');
- mt.formattype = FORMAT_MPEG2Video;
- {
- MPEG2VIDEOINFO* mvih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + di->GetDataSize());
- memset(mvih, 0, mt.FormatLength());
- mvih->hdr.bmiHeader.biSize = sizeof(mvih->hdr.bmiHeader);
- mvih->hdr.bmiHeader.biWidth = biWidth;
- mvih->hdr.bmiHeader.biHeight = biHeight;
- mvih->hdr.bmiHeader.biCompression = 'v4pm';
- mvih->hdr.bmiHeader.biPlanes = 1;
- mvih->hdr.bmiHeader.biBitCount = 24;
- mvih->hdr.dwPictAspectRatioX = mvih->hdr.bmiHeader.biWidth;
- mvih->hdr.dwPictAspectRatioY = mvih->hdr.bmiHeader.biHeight;
- mvih->cbSequenceHeader = di->GetDataSize();
- memcpy(mvih->dwSequenceHeader, di->GetData(), di->GetDataSize());
- mts.Add(mt);
- mt.subtype = FOURCCMap(mvih->hdr.bmiHeader.biCompression = 'V4PM');
- mts.Add(mt);
- //b_HasVideo = true;
- }
- break;
- case AP4_JPEG_OTI:
- mt.subtype = FOURCCMap('gepj');
- mt.formattype = FORMAT_MPEG2Video;
- {
- MPEG2VIDEOINFO* mvih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + di->GetDataSize());
- memset(mvih, 0, mt.FormatLength());
- mvih->hdr.bmiHeader.biSize = sizeof(mvih->hdr.bmiHeader);
- mvih->hdr.bmiHeader.biWidth = biWidth;
- mvih->hdr.bmiHeader.biHeight = biHeight;
- mvih->hdr.bmiHeader.biCompression = 'gepj';
- mvih->hdr.bmiHeader.biPlanes = 1;
- mvih->hdr.bmiHeader.biBitCount = 24;
- mvih->hdr.dwPictAspectRatioX = mvih->hdr.bmiHeader.biWidth;
- mvih->hdr.dwPictAspectRatioY = mvih->hdr.bmiHeader.biHeight;
- mvih->cbSequenceHeader = di->GetDataSize();
- memcpy(mvih->dwSequenceHeader, di->GetData(), di->GetDataSize());
- mts.Add(mt);
- //b_HasVideo = true;
- }
- break;
- case AP4_MPEG2_VISUAL_SIMPLE_OTI:
- case AP4_MPEG2_VISUAL_MAIN_OTI:
- case AP4_MPEG2_VISUAL_SNR_OTI:
- case AP4_MPEG2_VISUAL_SPATIAL_OTI:
- case AP4_MPEG2_VISUAL_HIGH_OTI:
- case AP4_MPEG2_VISUAL_422_OTI:
- mt.subtype = MEDIASUBTYPE_MPEG2_VIDEO;
- {
- m_pFile->Seek(sample.GetOffset());
- CBaseSplitterFileEx::seqhdr h;
- CMediaType mt2;
- if (m_pFile->Read(h, sample.GetSize(), &mt2)) {
- mt = mt2;
- }
- }
- mts.Add(mt);
- break;
- case AP4_MPEG1_VISUAL_OTI: // ???
- mt.subtype = MEDIASUBTYPE_MPEG1Payload;
- {
- m_pFile->Seek(sample.GetOffset());
- CBaseSplitterFileEx::seqhdr h;
- CMediaType mt2;
- if (m_pFile->Read(h, sample.GetSize(), &mt2)) {
- mt = mt2;
- }
- }
- mts.Add(mt);
- break;
- }
-
- if (mt.subtype == GUID_NULL) {
- TRACE(_T("Unknown video OBI: %02x\n"), video_desc->GetObjectTypeId());
- }
- } else if (AP4_MpegAudioSampleDescription* audio_desc =
- dynamic_cast<AP4_MpegAudioSampleDescription*>(mpeg_desc)) {
- const AP4_DataBuffer* di = audio_desc->GetDecoderInfo();
- if (!di) {
- di = &empty;
- }
-
- mt.majortype = MEDIATYPE_Audio;
- mt.formattype = FORMAT_WaveFormatEx;
-
- wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX) + di->GetDataSize());
- memset(wfe, 0, mt.FormatLength());
- wfe->nSamplesPerSec = audio_desc->GetSampleRate();
- wfe->nAvgBytesPerSec = audio_desc->GetAvgBitrate()/8;
- wfe->nChannels = audio_desc->GetChannelCount();
- wfe->wBitsPerSample = audio_desc->GetSampleSize();
- wfe->cbSize = (WORD)di->GetDataSize();
- wfe->nBlockAlign = (WORD)((wfe->nChannels * wfe->wBitsPerSample) / 8);
-
- memcpy(wfe + 1, di->GetData(), di->GetDataSize());
-
- switch (audio_desc->GetObjectTypeId()) {
- case AP4_MPEG4_AUDIO_OTI:
- case AP4_MPEG2_AAC_AUDIO_MAIN_OTI: // ???
- case AP4_MPEG2_AAC_AUDIO_LC_OTI: // ???
- case AP4_MPEG2_AAC_AUDIO_SSRP_OTI: // ???
- if (di->GetDataSize() > 10) {
- if (*(DWORD*)(di->GetData()+6) == 0x00534c41) { // 'ALS\0' sync word
- wfe->wFormatTag = WAVE_FORMAT_UNKNOWN;
- mt.subtype = FOURCCMap(MAKEFOURCC('A','L','S',' ')); // create our own GUID - {20534C41-0000-0010-8000-00AA00389B71}
- mts.Add(mt);
- break;
- }
- }
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_AAC);
- if (wfe->cbSize >= 2 && wfe->nChannels < 8) {
- wfe->nChannels = (((BYTE*)(wfe+1))[1]>>3) & 0xf;
- wfe->nBlockAlign = (WORD)((wfe->nChannels * wfe->wBitsPerSample) / 8);
- }
- mts.Add(mt);
- break;
- case AP4_MPEG2_PART3_AUDIO_OTI: // ???
- case AP4_MPEG1_AUDIO_OTI:
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_MP3);
- {
- m_pFile->Seek(sample.GetOffset());
- CBaseSplitterFileEx::mpahdr h;
- CMediaType mt2;
- if (m_pFile->Read(h, sample.GetSize(), false, &mt2)) {
- mt = mt2;
- }
- }
- mts.Add(mt);
- break;
- case AP4_DTSC_AUDIO_OTI:
- case AP4_DTSH_AUDIO_OTI:
- case AP4_DTSL_AUDIO_OTI:
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_DVD_DTS);
- {
- m_pFile->Seek(sample.GetOffset());
- CBaseSplitterFileEx::dtshdr h;
- CMediaType mt2;
- if (m_pFile->Read(h, sample.GetSize(), &mt2)) {
- mt = mt2;
- }
- }
- mts.Add(mt);
- break;
- }
-
- if (mt.subtype == GUID_NULL) {
- TRACE(_T("Unknown audio OBI: %02x\n"), audio_desc->GetObjectTypeId());
- }
- } else if (AP4_MpegSystemSampleDescription* system_desc =
- dynamic_cast<AP4_MpegSystemSampleDescription*>(desc)) {
- const AP4_DataBuffer* di = system_desc->GetDecoderInfo();
- if (!di) {
- di = &empty;
- }
-
- switch (system_desc->GetObjectTypeId()) {
- case AP4_NERO_VOBSUB:
- if (di->GetDataSize() >= 16*4) {
- CSize size(720, 576);
- if (AP4_TkhdAtom* tkhd = dynamic_cast<AP4_TkhdAtom*>(track->GetTrakAtom()->GetChild(AP4_ATOM_TYPE_TKHD))) {
- size.cx = tkhd->GetWidth()>>16;
- size.cy = tkhd->GetHeight()>>16;
- }
-
- const AP4_Byte* pal = di->GetData();
- CAtlList<CStringA> sl;
- for (int i = 0; i < 16*4; i += 4) {
- BYTE y = (pal[i+1]-16)*255/219;
- BYTE u = pal[i+2];
- BYTE v = pal[i+3];
- BYTE r = (BYTE)min(max(1.0*y + 1.4022*(v-128), 0), 255);
- BYTE g = (BYTE)min(max(1.0*y - 0.3456*(u-128) - 0.7145*(v-128), 0), 255);
- BYTE b = (BYTE)min(max(1.0*y + 1.7710*(u-128), 0) , 255);
- CStringA str;
- str.Format("%02x%02x%02x", r, g, b);
- sl.AddTail(str);
- }
-
- CStringA hdr;
- hdr.Format(
- "# VobSub index file, v7 (do not modify this line!)\n"
- "size: %dx%d\n"
- "palette: %s\n",
- size.cx, size.cy,
- Implode(sl, ','));
-
- mt.majortype = MEDIATYPE_Subtitle;
- mt.subtype = MEDIASUBTYPE_VOBSUB;
- mt.formattype = FORMAT_SubtitleInfo;
- SUBTITLEINFO* si = (SUBTITLEINFO*)mt.AllocFormatBuffer(sizeof(SUBTITLEINFO) + hdr.GetLength());
- memset(si, 0, mt.FormatLength());
- si->dwOffset = sizeof(SUBTITLEINFO);
- strcpy_s(si->IsoLang, _countof(si->IsoLang), CStringA(TrackLanguage));
- wcscpy_s(si->TrackName, _countof(si->TrackName), TrackName);
- memcpy(si + 1, (LPCSTR)hdr, hdr.GetLength());
- mts.Add(mt);
- }
- break;
- }
-
- if (mt.subtype == GUID_NULL) {
- TRACE(_T("Unknown audio OBI: %02x\n"), system_desc->GetObjectTypeId());
- }
- } else if (AP4_UnknownSampleDescription* unknown_desc =
- dynamic_cast<AP4_UnknownSampleDescription*>(desc)) { // TEMP
- AP4_SampleEntry* sample_entry = unknown_desc->GetSampleEntry();
-
- if (dynamic_cast<AP4_TextSampleEntry*>(sample_entry)
- || dynamic_cast<AP4_Tx3gSampleEntry*>(sample_entry)) {
- mt.majortype = MEDIATYPE_Subtitle;
- mt.subtype = MEDIASUBTYPE_ASS2;
- mt.formattype = FORMAT_SubtitleInfo;
- CStringA hdr;
- hdr.Format(
- "[Script Info]\n"
- "ScriptType: v4.00++\n"
- "ScaledBorderAndShadow: yes\n"
- "PlayResX: %d\n"
- "PlayResY: %d\n"
- "[V4++ Styles]\n"
- "Style: Text,Arial,12,&H00ffffff,&H0000ffff,&H00000000,&H80000000,0,0,0,0,100,100,0,0.00,3,0,0,2,0,0,0,0,1,1\n",
- // "Style: Text,Arial,12,&H00ffffff,&H0000ffff,&H00000000,&H80000000,0,0,0,0,100,100,0,0.00,1,0,0,2,0,0,0,0,1,1\n",
- m_framesize.cx,
- m_framesize.cy);
- SUBTITLEINFO* si = (SUBTITLEINFO*)mt.AllocFormatBuffer(sizeof(SUBTITLEINFO) + hdr.GetLength());
- memset(si, 0, mt.FormatLength());
- si->dwOffset = sizeof(SUBTITLEINFO);
- strcpy_s(si->IsoLang, _countof(si->IsoLang), CStringA(TrackLanguage));
- wcscpy_s(si->TrackName, _countof(si->TrackName), TrackName);
- memcpy(si + 1, (LPCSTR)hdr, hdr.GetLength());
- mts.Add(mt);
- }
- }
- } else if (AP4_Avc1SampleEntry* avc1 = dynamic_cast<AP4_Avc1SampleEntry*>(
- track->GetTrakAtom()->FindChild("mdia/minf/stbl/stsd/avc1"))) {
- if (AP4_AvcCAtom* avcC = dynamic_cast<AP4_AvcCAtom*>(avc1->GetChild(AP4_ATOM_TYPE_AVCC))) {
- SetTrackName(&TrackName, _T("MPEG4 Video (H264)"));
-
- const AP4_DataBuffer* di = avcC->GetDecoderInfo();
- if (!di) {
- di = &empty;
- }
- int num = 1;
- int den = 1;
- if (AP4_PaspAtom* pasp = dynamic_cast<AP4_PaspAtom*>(avc1->GetChild(AP4_ATOM_TYPE_PASP))) {
- num = pasp->GetNum();
- den = pasp->GetDen();
- }
- if (num <= 0 || den <= 0) { // if bad AR
- num = den = 1; // then reset AR
- }
-
- const AP4_Byte* data = di->GetData();
- AP4_Size size = di->GetDataSize();
-
- mt.majortype = MEDIATYPE_Video;
- mt.subtype = FOURCCMap('1cva');
- mt.formattype = FORMAT_MPEG2Video;
-
- MPEG2VIDEOINFO* mvih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + size - 7);
- memset(mvih, 0, mt.FormatLength());
- mvih->hdr.bmiHeader.biSize = sizeof(mvih->hdr.bmiHeader);
- mvih->hdr.bmiHeader.biWidth = (LONG)avc1->GetWidth();
- mvih->hdr.bmiHeader.biHeight = (LONG)avc1->GetHeight();
- mvih->hdr.bmiHeader.biCompression = '1cva';
- mvih->hdr.bmiHeader.biPlanes = 1;
- mvih->hdr.bmiHeader.biBitCount = 24;
-
- CSize aspect(mvih->hdr.bmiHeader.biWidth * num, mvih->hdr.bmiHeader.biHeight * den);
- int lnko = LNKO(aspect.cx, aspect.cy);
- if (lnko > 1) {
- aspect.cx /= lnko, aspect.cy /= lnko;
- }
- mvih->hdr.dwPictAspectRatioX = aspect.cx;
- mvih->hdr.dwPictAspectRatioY = aspect.cy;
- if (item->GetData()->GetSampleCount()) {
- mvih->hdr.AvgTimePerFrame = item->GetData()->GetDurationMs()*10000 / (item->GetData()->GetSampleCount());
- }
- mvih->dwProfile = data[1];
- mvih->dwLevel = data[3];
- mvih->dwFlags = (data[4] & 3) + 1;
-
- mvih->cbSequenceHeader = 0;
-
- BYTE* src = (BYTE*)data + 5;
- BYTE* dst = (BYTE*)mvih->dwSequenceHeader;
-
- BYTE* src_end = (BYTE*)data + size;
- BYTE* dst_end = (BYTE*)mvih->dwSequenceHeader + size;
-
- for (int i = 0; i < 2; ++i) {
- for (int n = *src++ & 0x1f; n > 0; --n) {
- int len = ((src[0] << 8) | src[1]) + 2;
- if (src + len > src_end || dst + len > dst_end) {
- ASSERT(0);
- break;
- }
- memcpy(dst, src, len);
- src += len;
- dst += len;
- mvih->cbSequenceHeader += len;
- }
- }
-
- mts.Add(mt);
-
- mt.subtype = FOURCCMap(mvih->hdr.bmiHeader.biCompression = '1CVA');
- mts.Add(mt);
- //b_HasVideo = true;
- }
- } else if (AP4_StsdAtom* stsd = dynamic_cast<AP4_StsdAtom*>(
- track->GetTrakAtom()->FindChild("mdia/minf/stbl/stsd"))) {
- const AP4_DataBuffer& db = stsd->GetDataBuffer();
-
- for (AP4_List<AP4_Atom>::Item* item = stsd->GetChildren().FirstItem();
- item;
- item = item->GetNext()) {
- AP4_Atom* atom = item->GetData();
-
- AP4_Atom::Type type = atom->GetType();
- DWORD fourcc =
- ((type >> 24) & 0x000000ff) |
- ((type >> 8) & 0x0000ff00) |
- ((type << 8) & 0x00ff0000) |
- ((type << 24) & 0xff000000);
-
- if (AP4_VisualSampleEntry* vse = dynamic_cast<AP4_VisualSampleEntry*>(atom)) {
-
- if (type == AP4_ATOM_TYPE_MJPA || type == AP4_ATOM_TYPE_MJPB || type == AP4_ATOM_TYPE_MJPG) {
- SetTrackName(&TrackName, _T("M-Jpeg"));
- }
-
- mt.majortype = MEDIATYPE_Video;
- mt.subtype = FOURCCMap(fourcc);
- mt.formattype = FORMAT_VideoInfo;
- vih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER)+db.GetDataSize());
- memset(vih, 0, mt.FormatLength());
- vih->bmiHeader.biSize = sizeof(vih->bmiHeader);
- vih->bmiHeader.biWidth = (LONG)vse->GetWidth();
- vih->bmiHeader.biHeight = (LONG)vse->GetHeight();
- vih->bmiHeader.biCompression = fourcc;
- vih->bmiHeader.biBitCount = (LONG)vse->GetDepth();
- memcpy(vih+1, db.GetData(), db.GetDataSize());
- mts.Add(mt);
-
- char buff[5];
- memcpy(buff, &fourcc, 4);
- buff[4] = 0;
-
- _strlwr_s(buff);
- AP4_Atom::Type typelwr = *(AP4_Atom::Type*)buff;
-
- if (typelwr != fourcc) {
- mt.subtype = FOURCCMap(vih->bmiHeader.biCompression = typelwr);
- mts.Add(mt);
- //b_HasVideo = true;
- }
-
- _strupr_s(buff);
- AP4_Atom::Type typeupr = *(AP4_Atom::Type*)buff;
-
- if (typeupr != fourcc) {
- mt.subtype = FOURCCMap(vih->bmiHeader.biCompression = typeupr);
- mts.Add(mt);
- //b_HasVideo = true;
- }
-
- break;
- } else if (AP4_AudioSampleEntry* ase = dynamic_cast<AP4_AudioSampleEntry*>(atom)) {
- DWORD samplerate = ase->GetSampleRate();
- WORD channels = ase->GetChannelCount();
- WORD bitspersample = ase->GetSampleSize();
-
- // overwrite audio fourc
- if ((type & 0xffff0000) == AP4_ATOM_TYPE('m', 's', 0, 0)) {
- fourcc = type & 0xffff;
- } else if (type == AP4_ATOM_TYPE_ALAW) {
- fourcc = WAVE_FORMAT_ALAW;
- SetTrackName(&TrackName, _T("PCM A-law"));
- } else if (type == AP4_ATOM_TYPE_ULAW) {
- fourcc = WAVE_FORMAT_MULAW;
- SetTrackName(&TrackName, _T("PCM mu-law"));
- } else if (type == AP4_ATOM_TYPE__MP3) {
- SetTrackName(&TrackName, _T("MPEG Audio (MP3)"));
- fourcc = WAVE_FORMAT_MPEGLAYER3;
- } else if ((type == AP4_ATOM_TYPE__AC3) || (type == AP4_ATOM_TYPE_SAC3) || (type == AP4_ATOM_TYPE_EAC3)) {
- fourcc = 0x2000;
- if (type == AP4_ATOM_TYPE_EAC3) {
- SetTrackName(&TrackName, _T("AC-3 Audio"));
- } else {
- SetTrackName(&TrackName, _T("Enhanced AC-3 audio"));
- }
- } else if (type == AP4_ATOM_TYPE_MP4A) {
- fourcc = WAVE_FORMAT_AAC;
- SetTrackName(&TrackName, _T("MPEG-2 Audio AAC"));
- } else if (type == AP4_ATOM_TYPE_NMOS) {
- fourcc = MAKEFOURCC('N','E','L','L');
- SetTrackName(&TrackName, _T("NellyMoser Audio"));
- } else if (type == AP4_ATOM_TYPE_ALAC) {
- fourcc = MAKEFOURCC('a','l','a','c');
- SetTrackName(&TrackName, _T("Alac Audio"));
- } else if ((type == AP4_ATOM_TYPE_NONE || type == AP4_ATOM_TYPE_RAW) && bitspersample == 8 ||
- type == AP4_ATOM_TYPE_SOWT && bitspersample == 16 ||
- (type == AP4_ATOM_TYPE_IN24 || type == AP4_ATOM_TYPE_IN32) && ase->GetEndian()==ENDIAN_LITTLE) {
- fourcc = type = WAVE_FORMAT_PCM;
- } else if ((type == AP4_ATOM_TYPE_FL32 || type == AP4_ATOM_TYPE_FL64) && ase->GetEndian()==ENDIAN_LITTLE) {
- fourcc = type = WAVE_FORMAT_IEEE_FLOAT;
- } else if (type == AP4_ATOM_TYPE_LPCM) {
- DWORD flags = ase->GetFormatSpecificFlags();
- if (flags & 2) { // big endian
- if (flags & 1) { // floating point
- if (bitspersample == 32) type = AP4_ATOM_TYPE_FL32;
- else if (bitspersample == 64) type = AP4_ATOM_TYPE_FL64;
- } else {
- if (bitspersample == 16) type = AP4_ATOM_TYPE_TWOS;
- else if (bitspersample == 24) type = AP4_ATOM_TYPE_IN24;
- else if (bitspersample == 32) type = AP4_ATOM_TYPE_IN32;
- }
- fourcc = ((type >> 24) & 0x000000ff) |
- ((type >> 8) & 0x0000ff00) |
- ((type << 8) & 0x00ff0000) |
- ((type << 24) & 0xff000000);
- } else { // little endian
- if (flags & 1) { // floating point
- fourcc = type = WAVE_FORMAT_IEEE_FLOAT;
- } else {
- fourcc = type = WAVE_FORMAT_PCM;
- }
- }
- }
-
- DWORD nAvgBytesPerSec = 0;
- if (type == AP4_ATOM_TYPE_EAC3) {
-
- AP4_Sample sample;
- AP4_DataBuffer sample_data;
-
- AP4_Cardinal SampleCount = track->GetSampleCount();
- if (SampleCount) {
- track->ReadSample(1, sample, sample_data);
- const AP4_Byte* data = sample_data.GetData();
- AP4_Size size = sample_data.GetDataSize();
-
- CGolombBuffer gb((BYTE *)data, size);
- for (; size >= 7 && gb.BitRead(16, true) != 0x0b77; --size) {
- gb.BitRead(8);
- }
- WORD sync = (WORD)gb.BitRead(16);
- if ((size >= 7) && (sync == 0x0b77)) {
- static DWORD freq[] = {48000, 44100, 32000, 0};
- gb.BitRead(2);
- gb.BitRead(3);
- WORD frame_size = ((WORD)gb.BitRead(11) + 1) << 1;
- BYTE sr_code = (BYTE)gb.BitRead(2);
- if (sr_code == 3) {
- BYTE sr_code2 = (BYTE)gb.BitRead(2);
- samplerate = freq[sr_code2] / 2;
- } else {
- static BYTE eac3_blocks[4] = {1, 2, 3, 6};
- BYTE num_blocks = eac3_blocks[gb.BitRead(2)];
- samplerate = freq[sr_code];
- nAvgBytesPerSec = frame_size * samplerate / (num_blocks * 256);
- }
- BYTE acmod = (BYTE)gb.BitRead(3);
- BYTE lfeon = (BYTE)gb.BitRead(1);
- static WORD channels_tbl[] = {2, 1, 2, 3, 3, 4, 4, 5};
- channels = channels_tbl[acmod] + lfeon;
- }
- }
- }
-
- mt.majortype = MEDIATYPE_Audio;
- mt.formattype = FORMAT_WaveFormatEx;
- wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX));
- memset(wfe, 0, mt.FormatLength());
- if (!(fourcc & 0xffff0000)) {
- wfe->wFormatTag = (WORD)fourcc;
- }
- wfe->nSamplesPerSec = samplerate;
- wfe->nChannels = channels;
- wfe->wBitsPerSample = bitspersample;
- wfe->nBlockAlign = ase->GetBytesPerFrame();
- if (nAvgBytesPerSec == 0 && ase->GetSamplesPerPacket() > 0) {
- wfe->nAvgBytesPerSec = wfe->nSamplesPerSec * wfe->nBlockAlign / ase->GetSamplesPerPacket();
- }
-
- mt.subtype = FOURCCMap(fourcc);
-
-
- if (type == AP4_ATOM_TYPE('m', 's', 0x00, 0x02)) {
- const WORD numcoef = 7;
- static ADPCMCOEFSET coef[] = { {256, 0}, {512, -256}, {0,0}, {192,64}, {240,0}, {460, -208}, {392,-232} };
- const ULONG size = sizeof(ADPCMWAVEFORMAT) + (numcoef * sizeof(ADPCMCOEFSET));
- ADPCMWAVEFORMAT* format = (ADPCMWAVEFORMAT*)mt.ReallocFormatBuffer(size);
- if (format != NULL) {
- format->wfx.wFormatTag = WAVE_FORMAT_ADPCM;
- format->wfx.wBitsPerSample = 4;
- format->wfx.cbSize = (WORD)(size - sizeof(WAVEFORMATEX));
- format->wSamplesPerBlock = format->wfx.nBlockAlign * 2 / format->wfx.nChannels - 12;
- format->wNumCoef = numcoef;
- memcpy( format->aCoef, coef, sizeof(coef) );
- }
- } else if (type == AP4_ATOM_TYPE('m', 's', 0x00, 0x11)) {
- IMAADPCMWAVEFORMAT* format = (IMAADPCMWAVEFORMAT*)mt.ReallocFormatBuffer(sizeof(IMAADPCMWAVEFORMAT));
- if (format != NULL) {
- format->wfx.wFormatTag = WAVE_FORMAT_IMA_ADPCM;
- format->wfx.wBitsPerSample = 4;
- format->wfx.cbSize = (WORD)(sizeof(IMAADPCMWAVEFORMAT) - sizeof(WAVEFORMATEX));
- int X = (format->wfx.nBlockAlign - (4 * format->wfx.nChannels)) * 8;
- int Y = format->wfx.wBitsPerSample * format->wfx.nChannels;
- format->wSamplesPerBlock = (X / Y) + 1;
- }
- } else if (type == AP4_ATOM_TYPE_ALAC) {
- const AP4_Byte* data = db.GetData();
- AP4_Size size = db.GetDataSize();
-
- while (size >= 36) {
- if ((*(DWORD*)(data) == 0x24000000) && (*(DWORD*)(data+4) == 0x63616c61)) {
- break;
- }
- size--;
- data++;
- }
-
- if (size >= 36) {
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + 36);
- wfe->cbSize = 36;
- memcpy(wfe+1, data, 36);
- }
- } else if (type == WAVE_FORMAT_PCM) {
- mt.SetSampleSize(wfe->nBlockAlign);
- if (channels > 2 || bitspersample > 16) {
- WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEXTENSIBLE));
- if (wfex != NULL) {
- wfex->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
- wfex->Format.cbSize = 22;
- wfex->Samples.wValidBitsPerSample = bitspersample;
- wfex->dwChannelMask = GetDefChannelMask(channels); // TODO: get correct channel mask from mov file
- wfex->SubFormat = MEDIASUBTYPE_PCM;
- }
- }
- } else if (type == WAVE_FORMAT_IEEE_FLOAT) {
- mt.SetSampleSize(wfe->nBlockAlign);
- if (channels > 2) {
- WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEXTENSIBLE));
- if (wfex != NULL) {
- wfex->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
- wfex->Format.cbSize = 22;
- wfex->Samples.wValidBitsPerSample = bitspersample;
- wfex->dwChannelMask = GetDefChannelMask(channels); // TODO: get correct channel mask from mov file
- wfex->SubFormat = MEDIASUBTYPE_IEEE_FLOAT;
- }
- }
- } else if (type == AP4_ATOM_TYPE_MP4A ||
- type == AP4_ATOM_TYPE_ALAW ||
- type == AP4_ATOM_TYPE_ULAW) {
- // not need any extra data for ALAW, ULAW
- // also extra data is not required for IMA4, MAC3, MAC6
- } else if (db.GetDataSize() > 0) {
- //always needed extra data for QDM2
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + db.GetDataSize());
- wfe->cbSize = db.GetDataSize();
- memcpy(wfe+1, db.GetData(), db.GetDataSize());
- }
-
- mts.Add(mt);
- break;
- } else {
- TRACE(_T("Unknow MP4 Stream %x") , fourcc);
- }
- }
- }
-
- if (mts.IsEmpty()) {
- continue;
- }
-
- REFERENCE_TIME rtDuration = 10000i64 * track->GetDurationMs();
- if (m_rtDuration < rtDuration) {
- m_rtDuration = rtDuration;
- }
- if (rtVideoDuration < rtDuration && AP4_Track::TYPE_VIDEO == track->GetType())
- rtVideoDuration = rtDuration; // get the max video duration
-
- DWORD id = track->GetId();
-
- CStringW name, lang;
- name.Format(L"Output %d", id);
-
- if (!TrackName.IsEmpty()) {
- name = TrackName;
- }
-
- if (!TrackLanguage.IsEmpty()) {
- if (TrackLanguage != L"und") {
- name += " (" + TrackLanguage + ")";
- }
- }
-
- for (int i = 0, j = mts.GetCount(); i < j; ++i) {
- BITMAPINFOHEADER bih;
- if (ExtractBIH(&mts[i], &bih)) {
- m_framesize.cx = bih.biWidth;
- m_framesize.cy = abs(bih.biHeight);
- }
- }
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CMP4SplitterOutputPin(mts, name, this, this, &hr));
-
- if (!TrackName.IsEmpty()) {
- pPinOut->SetProperty(L"NAME", TrackName);
- }
- if (!TrackLanguage.IsEmpty()) {
- pPinOut->SetProperty(L"LANG", CStringW(TrackLanguage));
- }
-
- EXECUTE_ASSERT(SUCCEEDED(AddOutputPin(id, pPinOut)));
-
- m_trackpos[id] = trackpos();
-
- if (mts.GetCount() == 1 && mts[0].subtype == MEDIASUBTYPE_ASS2) {
- LPCWSTR postfix = L" (plain text)";
-
- mts[0].subtype = MEDIASUBTYPE_UTF8;
-
- SUBTITLEINFO* si = (SUBTITLEINFO*)mts[0].ReallocFormatBuffer(sizeof(SUBTITLEINFO));
- wcscat_s(si->TrackName, postfix);
-
- id ^= 0x80402010; // FIXME: until fixing, let's hope there won't be another track like this...
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CMP4SplitterOutputPin(mts, name + postfix, this, this, &hr));
-
- if (!TrackName.IsEmpty()) {
- pPinOut->SetProperty(L"NAME", TrackName + postfix);
- }
- if (!TrackLanguage.IsEmpty()) {
- pPinOut->SetProperty(L"LANG", CStringW(TrackLanguage));
- }
-
- EXECUTE_ASSERT(SUCCEEDED(AddOutputPin(id, pPinOut)));
- }
- }
-
- if (AP4_ChplAtom* chpl = dynamic_cast<AP4_ChplAtom*>(movie->GetMoovAtom()->FindChild("udta/chpl"))) {
- AP4_Array<AP4_ChplAtom::AP4_Chapter>& chapters = chpl->GetChapters();
-
- for (AP4_Cardinal i = 0; i < chapters.ItemCount(); ++i) {
- AP4_ChplAtom::AP4_Chapter& chapter = chapters[i];
- ChapAppend(chapter.Time, UTF8To16(ConvertMBCS(chapter.Name.c_str(), ANSI_CHARSET, CP_UTF8))); // this is b0rked, thx to nero :P
- }
-
- ChapSort();
- }
-
- if (AP4_ContainerAtom* ilst = dynamic_cast<AP4_ContainerAtom*>(movie->GetMoovAtom()->FindChild("udta/meta/ilst"))) {
- CStringW title, artist, writer, album, year, appl, desc, gen, track;
-
- for (AP4_List<AP4_Atom>::Item* item = ilst->GetChildren().FirstItem();
- item;
- item = item->GetNext()) {
- if (AP4_ContainerAtom* atom = dynamic_cast<AP4_ContainerAtom*>(item->GetData())) {
- if (AP4_DataAtom* data = dynamic_cast<AP4_DataAtom*>(atom->GetChild(AP4_ATOM_TYPE_DATA))) {
- const AP4_DataBuffer* db = data->GetData();
-
- if (atom->GetType() == AP4_ATOM_TYPE_TRKN) {
- if (db->GetDataSize() >= 4) {
- unsigned short n = (db->GetData()[2] << 8) | db->GetData()[3];
- if (n > 0 && n < 100) {
- track.Format(L"%02d", n);
- } else if (n >= 100) {
- track.Format(L"%d", n);
- }
- }
- } else {
- CStringW str = UTF8To16(CStringA((LPCSTR)db->GetData(), db->GetDataSize()));
-
- switch (atom->GetType()) {
- case AP4_ATOM_TYPE_NAM:
- title = str;
- break;
- case AP4_ATOM_TYPE_ART:
- artist = str;
- break;
- case AP4_ATOM_TYPE_WRT:
- writer = str;
- break;
- case AP4_ATOM_TYPE_ALB:
- album = str;
- break;
- case AP4_ATOM_TYPE_DAY:
- year = str;
- break;
- case AP4_ATOM_TYPE_TOO:
- appl = str;
- break;
- case AP4_ATOM_TYPE_CMT:
- desc = str;
- break;
- case AP4_ATOM_TYPE_GEN:
- gen = str;
- break;
- }
- }
- }
- }
- }
-
- if (!title.IsEmpty()) {
- if (!track.IsEmpty()) {
- title = track + L" - " + title;
- }
- if (!album.IsEmpty()) {
- title = album + L" - " + title;
- }
- if (!year.IsEmpty()) {
- title += L" - " + year;
- }
- if (!gen.IsEmpty()) {
- title += L" - " + gen;
- }
- SetProperty(L"TITL", title);
- }
-
- if (!artist.IsEmpty()) {
- SetProperty(L"AUTH", artist);
- } else if (!writer.IsEmpty()) {
- SetProperty(L"AUTH", writer);
- }
-
- if (!appl.IsEmpty()) {
- SetProperty(L"APPL", appl);
- }
-
- if (!desc.IsEmpty()) {
- SetProperty(L"DESC", desc);
- }
- }
- }
-
- if (rtVideoDuration > 0 && rtVideoDuration < m_rtDuration/2)
- m_rtDuration = rtVideoDuration; // fix incorrect duration
-
- m_rtNewStop = m_rtStop = m_rtDuration;
-
- TRACE(_T("CMP4SplitterFilter m_pOutputs.GetCount() = %d") , m_pOutputs.GetCount());
-
- return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
+ CheckPointer(pAsyncReader, E_POINTER);
+
+ HRESULT hr = E_FAIL;
+
+ //bool b_HasVideo = false;
+
+ m_trackpos.RemoveAll();
+
+ m_pFile.Free();
+ m_pFile.Attach(DNew CMP4SplitterFile(pAsyncReader, hr));
+ if (!m_pFile) {
+ return E_OUTOFMEMORY;
+ }
+ if (FAILED(hr)) {
+ m_pFile.Free();
+ return hr;
+ }
+
+ m_rtNewStart = m_rtCurrent = 0;
+ m_rtNewStop = m_rtStop = m_rtDuration = 0;
+ REFERENCE_TIME rtVideoDuration = 0;
+
+ m_framesize.SetSize(640, 480);
+
+ if (AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie()) {
+ // looking for main video track (skip tracks with motionless frames)
+ AP4_UI32 mainvideoID = 0;
+ for (AP4_List<AP4_Track>::Item* item = movie->GetTracks().FirstItem();
+ item;
+ item = item->GetNext()) {
+ AP4_Track* track = item->GetData();
+
+ if (track->GetType() != AP4_Track::TYPE_VIDEO) {
+ continue;
+ }
+ if (!mainvideoID) {
+ mainvideoID = track->GetId();
+ }
+ if (AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
+ if (stss->m_Entries.ItemCount() > 0) {
+ mainvideoID = track->GetId();
+ break;
+ }
+ }
+ }
+ // process the tracks
+ for (AP4_List<AP4_Track>::Item* item = movie->GetTracks().FirstItem();
+ item;
+ item = item->GetNext()) {
+ AP4_Track* track = item->GetData();
+
+ if (track->GetType() != AP4_Track::TYPE_VIDEO
+ && track->GetType() != AP4_Track::TYPE_AUDIO
+ && track->GetType() != AP4_Track::TYPE_TEXT
+ && track->GetType() != AP4_Track::TYPE_SUBP) {
+ continue;
+ }
+
+ //if (b_HasVideo && track->GetType() == AP4_Track::TYPE_VIDEO) {
+ if (track->GetType() == AP4_Track::TYPE_VIDEO && track->GetId() != mainvideoID) {
+ continue;
+ }
+
+ AP4_Sample sample;
+
+ if (!AP4_SUCCEEDED(track->GetSample(0, sample)) || sample.GetDescriptionIndex() == 0xFFFFFFFF) {
+ continue;
+ }
+
+ CStringW TrackName = UTF8ToStringW(track->GetTrackName().c_str());
+ if (TrackName.IsEmpty()) {
+ TrackName = LocalToStringW(track->GetTrackName().c_str()); //Trying Local...
+ }
+ TrackName.TrimLeft(_T("\x0010\x0013\x0015\x0017\x0018\x0019\x001A\x001B"));
+ TrackName.Trim();
+
+ CStringA TrackLanguage = track->GetTrackLanguage().c_str();
+
+ CAtlArray<CMediaType> mts;
+
+ CMediaType mt;
+ mt.SetSampleSize(1);
+
+ VIDEOINFOHEADER* vih = NULL;
+ WAVEFORMATEX* wfe = NULL;
+
+ AP4_DataBuffer empty;
+
+ if (AP4_SampleDescription* desc = track->GetSampleDescription(sample.GetDescriptionIndex())) {
+ AP4_MpegSampleDescription* mpeg_desc = NULL;
+
+ if (desc->GetType() == AP4_SampleDescription::TYPE_MPEG) {
+ mpeg_desc = dynamic_cast<AP4_MpegSampleDescription*>(desc);
+ } else if (desc->GetType() == AP4_SampleDescription::TYPE_ISMACRYP) {
+ AP4_IsmaCrypSampleDescription* isma_desc = dynamic_cast<AP4_IsmaCrypSampleDescription*>(desc);
+ mpeg_desc = isma_desc->GetOriginalSampleDescription();
+ }
+
+ if (mpeg_desc) {
+ CStringW TypeString = CStringW(mpeg_desc->GetObjectTypeString(mpeg_desc->GetObjectTypeId()));
+ if ((TypeString.Find(_T("UNKNOWN")) == -1) && (TypeString.Find(_T("INVALID")) == -1)) {
+ SetTrackName(&TrackName, TypeString);
+ }
+ }
+
+ if (AP4_MpegVideoSampleDescription* video_desc =
+ dynamic_cast<AP4_MpegVideoSampleDescription*>(mpeg_desc)) {
+ const AP4_DataBuffer* di = video_desc->GetDecoderInfo();
+ if (!di) {
+ di = &empty;
+ }
+
+ LONG biWidth = (LONG)video_desc->GetWidth();
+ LONG biHeight = (LONG)video_desc->GetHeight();
+
+ if (!biWidth || !biHeight) {
+ if (AP4_TkhdAtom* tkhd = dynamic_cast<AP4_TkhdAtom*>(track->GetTrakAtom()->GetChild(AP4_ATOM_TYPE_TKHD))) {
+ biWidth = tkhd->GetWidth() >> 16;
+ biHeight = tkhd->GetHeight() >> 16;
+ }
+ }
+
+ if (!biWidth || !biHeight) {
+ continue;
+ }
+
+ mt.majortype = MEDIATYPE_Video;
+ mt.formattype = FORMAT_VideoInfo;
+ vih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + di->GetDataSize());
+ memset(vih, 0, mt.FormatLength());
+ vih->dwBitRate = video_desc->GetAvgBitrate() / 8;
+ vih->bmiHeader.biSize = sizeof(vih->bmiHeader);
+ vih->bmiHeader.biWidth = biWidth;
+ vih->bmiHeader.biHeight = biHeight;
+ memcpy(vih + 1, di->GetData(), di->GetDataSize());
+
+ switch (video_desc->GetObjectTypeId()) {
+ case AP4_MPEG4_VISUAL_OTI:
+ mt.subtype = FOURCCMap('v4pm');
+ mt.formattype = FORMAT_MPEG2Video;
+ {
+ MPEG2VIDEOINFO* mvih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + di->GetDataSize());
+ memset(mvih, 0, mt.FormatLength());
+ mvih->hdr.bmiHeader.biSize = sizeof(mvih->hdr.bmiHeader);
+ mvih->hdr.bmiHeader.biWidth = biWidth;
+ mvih->hdr.bmiHeader.biHeight = biHeight;
+ mvih->hdr.bmiHeader.biCompression = 'v4pm';
+ mvih->hdr.bmiHeader.biPlanes = 1;
+ mvih->hdr.bmiHeader.biBitCount = 24;
+ mvih->hdr.dwPictAspectRatioX = mvih->hdr.bmiHeader.biWidth;
+ mvih->hdr.dwPictAspectRatioY = mvih->hdr.bmiHeader.biHeight;
+ mvih->cbSequenceHeader = di->GetDataSize();
+ memcpy(mvih->dwSequenceHeader, di->GetData(), di->GetDataSize());
+ mts.Add(mt);
+ mt.subtype = FOURCCMap(mvih->hdr.bmiHeader.biCompression = 'V4PM');
+ mts.Add(mt);
+ //b_HasVideo = true;
+ }
+ break;
+ case AP4_JPEG_OTI:
+ mt.subtype = FOURCCMap('gepj');
+ mt.formattype = FORMAT_MPEG2Video;
+ {
+ MPEG2VIDEOINFO* mvih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + di->GetDataSize());
+ memset(mvih, 0, mt.FormatLength());
+ mvih->hdr.bmiHeader.biSize = sizeof(mvih->hdr.bmiHeader);
+ mvih->hdr.bmiHeader.biWidth = biWidth;
+ mvih->hdr.bmiHeader.biHeight = biHeight;
+ mvih->hdr.bmiHeader.biCompression = 'gepj';
+ mvih->hdr.bmiHeader.biPlanes = 1;
+ mvih->hdr.bmiHeader.biBitCount = 24;
+ mvih->hdr.dwPictAspectRatioX = mvih->hdr.bmiHeader.biWidth;
+ mvih->hdr.dwPictAspectRatioY = mvih->hdr.bmiHeader.biHeight;
+ mvih->cbSequenceHeader = di->GetDataSize();
+ memcpy(mvih->dwSequenceHeader, di->GetData(), di->GetDataSize());
+ mts.Add(mt);
+ //b_HasVideo = true;
+ }
+ break;
+ case AP4_MPEG2_VISUAL_SIMPLE_OTI:
+ case AP4_MPEG2_VISUAL_MAIN_OTI:
+ case AP4_MPEG2_VISUAL_SNR_OTI:
+ case AP4_MPEG2_VISUAL_SPATIAL_OTI:
+ case AP4_MPEG2_VISUAL_HIGH_OTI:
+ case AP4_MPEG2_VISUAL_422_OTI:
+ mt.subtype = MEDIASUBTYPE_MPEG2_VIDEO;
+ {
+ m_pFile->Seek(sample.GetOffset());
+ CBaseSplitterFileEx::seqhdr h;
+ CMediaType mt2;
+ if (m_pFile->Read(h, sample.GetSize(), &mt2)) {
+ mt = mt2;
+ }
+ }
+ mts.Add(mt);
+ break;
+ case AP4_MPEG1_VISUAL_OTI: // ???
+ mt.subtype = MEDIASUBTYPE_MPEG1Payload;
+ {
+ m_pFile->Seek(sample.GetOffset());
+ CBaseSplitterFileEx::seqhdr h;
+ CMediaType mt2;
+ if (m_pFile->Read(h, sample.GetSize(), &mt2)) {
+ mt = mt2;
+ }
+ }
+ mts.Add(mt);
+ break;
+ }
+
+ if (mt.subtype == GUID_NULL) {
+ TRACE(_T("Unknown video OBI: %02x\n"), video_desc->GetObjectTypeId());
+ }
+ } else if (AP4_MpegAudioSampleDescription* audio_desc =
+ dynamic_cast<AP4_MpegAudioSampleDescription*>(mpeg_desc)) {
+ const AP4_DataBuffer* di = audio_desc->GetDecoderInfo();
+ if (!di) {
+ di = &empty;
+ }
+
+ mt.majortype = MEDIATYPE_Audio;
+ mt.formattype = FORMAT_WaveFormatEx;
+
+ wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX) + di->GetDataSize());
+ memset(wfe, 0, mt.FormatLength());
+ wfe->nSamplesPerSec = audio_desc->GetSampleRate();
+ wfe->nAvgBytesPerSec = audio_desc->GetAvgBitrate() / 8;
+ wfe->nChannels = audio_desc->GetChannelCount();
+ wfe->wBitsPerSample = audio_desc->GetSampleSize();
+ wfe->cbSize = (WORD)di->GetDataSize();
+ wfe->nBlockAlign = (WORD)((wfe->nChannels * wfe->wBitsPerSample) / 8);
+
+ memcpy(wfe + 1, di->GetData(), di->GetDataSize());
+
+ switch (audio_desc->GetObjectTypeId()) {
+ case AP4_MPEG4_AUDIO_OTI:
+ case AP4_MPEG2_AAC_AUDIO_MAIN_OTI: // ???
+ case AP4_MPEG2_AAC_AUDIO_LC_OTI: // ???
+ case AP4_MPEG2_AAC_AUDIO_SSRP_OTI: // ???
+ if (di->GetDataSize() > 10) {
+ if (*(DWORD*)(di->GetData() + 6) == 0x00534c41) { // 'ALS\0' sync word
+ wfe->wFormatTag = WAVE_FORMAT_UNKNOWN;
+ mt.subtype = FOURCCMap(MAKEFOURCC('A', 'L', 'S', ' ')); // create our own GUID - {20534C41-0000-0010-8000-00AA00389B71}
+ mts.Add(mt);
+ break;
+ }
+ }
+ mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_AAC);
+ if (wfe->cbSize >= 2 && wfe->nChannels < 8) {
+ wfe->nChannels = (((BYTE*)(wfe + 1))[1] >> 3) & 0xf;
+ wfe->nBlockAlign = (WORD)((wfe->nChannels * wfe->wBitsPerSample) / 8);
+ }
+ mts.Add(mt);
+ break;
+ case AP4_MPEG2_PART3_AUDIO_OTI: // ???
+ case AP4_MPEG1_AUDIO_OTI:
+ mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_MP3);
+ {
+ m_pFile->Seek(sample.GetOffset());
+ CBaseSplitterFileEx::mpahdr h;
+ CMediaType mt2;
+ if (m_pFile->Read(h, sample.GetSize(), false, &mt2)) {
+ mt = mt2;
+ }
+ }
+ mts.Add(mt);
+ break;
+ case AP4_DTSC_AUDIO_OTI:
+ case AP4_DTSH_AUDIO_OTI:
+ case AP4_DTSL_AUDIO_OTI:
+ mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_DVD_DTS);
+ {
+ m_pFile->Seek(sample.GetOffset());
+ CBaseSplitterFileEx::dtshdr h;
+ CMediaType mt2;
+ if (m_pFile->Read(h, sample.GetSize(), &mt2)) {
+ mt = mt2;
+ }
+ }
+ mts.Add(mt);
+ break;
+ }
+
+ if (mt.subtype == GUID_NULL) {
+ TRACE(_T("Unknown audio OBI: %02x\n"), audio_desc->GetObjectTypeId());
+ }
+ } else if (AP4_MpegSystemSampleDescription* system_desc =
+ dynamic_cast<AP4_MpegSystemSampleDescription*>(desc)) {
+ const AP4_DataBuffer* di = system_desc->GetDecoderInfo();
+ if (!di) {
+ di = &empty;
+ }
+
+ switch (system_desc->GetObjectTypeId()) {
+ case AP4_NERO_VOBSUB:
+ if (di->GetDataSize() >= 16 * 4) {
+ CSize size(720, 576);
+ if (AP4_TkhdAtom* tkhd = dynamic_cast<AP4_TkhdAtom*>(track->GetTrakAtom()->GetChild(AP4_ATOM_TYPE_TKHD))) {
+ size.cx = tkhd->GetWidth() >> 16;
+ size.cy = tkhd->GetHeight() >> 16;
+ }
+
+ const AP4_Byte* pal = di->GetData();
+ CAtlList<CStringA> sl;
+ for (int i = 0; i < 16 * 4; i += 4) {
+ BYTE y = (pal[i + 1] - 16) * 255 / 219;
+ BYTE u = pal[i + 2];
+ BYTE v = pal[i + 3];
+ BYTE r = (BYTE)min(max(1.0 * y + 1.4022 * (v - 128), 0), 255);
+ BYTE g = (BYTE)min(max(1.0 * y - 0.3456 * (u - 128) - 0.7145 * (v - 128), 0), 255);
+ BYTE b = (BYTE)min(max(1.0 * y + 1.7710 * (u - 128), 0) , 255);
+ CStringA str;
+ str.Format("%02x%02x%02x", r, g, b);
+ sl.AddTail(str);
+ }
+
+ CStringA hdr;
+ hdr.Format(
+ "# VobSub index file, v7 (do not modify this line!)\n"
+ "size: %dx%d\n"
+ "palette: %s\n",
+ size.cx, size.cy,
+ Implode(sl, ','));
+
+ mt.majortype = MEDIATYPE_Subtitle;
+ mt.subtype = MEDIASUBTYPE_VOBSUB;
+ mt.formattype = FORMAT_SubtitleInfo;
+ SUBTITLEINFO* si = (SUBTITLEINFO*)mt.AllocFormatBuffer(sizeof(SUBTITLEINFO) + hdr.GetLength());
+ memset(si, 0, mt.FormatLength());
+ si->dwOffset = sizeof(SUBTITLEINFO);
+ strcpy_s(si->IsoLang, _countof(si->IsoLang), CStringA(TrackLanguage));
+ wcscpy_s(si->TrackName, _countof(si->TrackName), TrackName);
+ memcpy(si + 1, (LPCSTR)hdr, hdr.GetLength());
+ mts.Add(mt);
+ }
+ break;
+ }
+
+ if (mt.subtype == GUID_NULL) {
+ TRACE(_T("Unknown audio OBI: %02x\n"), system_desc->GetObjectTypeId());
+ }
+ } else if (AP4_UnknownSampleDescription* unknown_desc =
+ dynamic_cast<AP4_UnknownSampleDescription*>(desc)) { // TEMP
+ AP4_SampleEntry* sample_entry = unknown_desc->GetSampleEntry();
+
+ if (dynamic_cast<AP4_TextSampleEntry*>(sample_entry)
+ || dynamic_cast<AP4_Tx3gSampleEntry*>(sample_entry)) {
+ mt.majortype = MEDIATYPE_Subtitle;
+ mt.subtype = MEDIASUBTYPE_ASS2;
+ mt.formattype = FORMAT_SubtitleInfo;
+ CStringA hdr;
+ hdr.Format(
+ "[Script Info]\n"
+ "ScriptType: v4.00++\n"
+ "ScaledBorderAndShadow: yes\n"
+ "PlayResX: %d\n"
+ "PlayResY: %d\n"
+ "[V4++ Styles]\n"
+ "Style: Text,Arial,12,&H00ffffff,&H0000ffff,&H00000000,&H80000000,0,0,0,0,100,100,0,0.00,3,0,0,2,0,0,0,0,1,1\n",
+ // "Style: Text,Arial,12,&H00ffffff,&H0000ffff,&H00000000,&H80000000,0,0,0,0,100,100,0,0.00,1,0,0,2,0,0,0,0,1,1\n",
+ m_framesize.cx,
+ m_framesize.cy);
+ SUBTITLEINFO* si = (SUBTITLEINFO*)mt.AllocFormatBuffer(sizeof(SUBTITLEINFO) + hdr.GetLength());
+ memset(si, 0, mt.FormatLength());
+ si->dwOffset = sizeof(SUBTITLEINFO);
+ strcpy_s(si->IsoLang, _countof(si->IsoLang), CStringA(TrackLanguage));
+ wcscpy_s(si->TrackName, _countof(si->TrackName), TrackName);
+ memcpy(si + 1, (LPCSTR)hdr, hdr.GetLength());
+ mts.Add(mt);
+ }
+ }
+ } else if (AP4_Avc1SampleEntry* avc1 = dynamic_cast<AP4_Avc1SampleEntry*>(
+ track->GetTrakAtom()->FindChild("mdia/minf/stbl/stsd/avc1"))) {
+ if (AP4_AvcCAtom* avcC = dynamic_cast<AP4_AvcCAtom*>(avc1->GetChild(AP4_ATOM_TYPE_AVCC))) {
+ SetTrackName(&TrackName, _T("MPEG4 Video (H264)"));
+
+ const AP4_DataBuffer* di = avcC->GetDecoderInfo();
+ if (!di) {
+ di = &empty;
+ }
+ int num = 1;
+ int den = 1;
+ if (AP4_PaspAtom* pasp = dynamic_cast<AP4_PaspAtom*>(avc1->GetChild(AP4_ATOM_TYPE_PASP))) {
+ num = pasp->GetNum();
+ den = pasp->GetDen();
+ }
+ if (num <= 0 || den <= 0) { // if bad AR
+ num = den = 1; // then reset AR
+ }
+
+ const AP4_Byte* data = di->GetData();
+ AP4_Size size = di->GetDataSize();
+
+ mt.majortype = MEDIATYPE_Video;
+ mt.subtype = FOURCCMap('1cva');
+ mt.formattype = FORMAT_MPEG2Video;
+
+ MPEG2VIDEOINFO* mvih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + size - 7);
+ memset(mvih, 0, mt.FormatLength());
+ mvih->hdr.bmiHeader.biSize = sizeof(mvih->hdr.bmiHeader);
+ mvih->hdr.bmiHeader.biWidth = (LONG)avc1->GetWidth();
+ mvih->hdr.bmiHeader.biHeight = (LONG)avc1->GetHeight();
+ mvih->hdr.bmiHeader.biCompression = '1cva';
+ mvih->hdr.bmiHeader.biPlanes = 1;
+ mvih->hdr.bmiHeader.biBitCount = 24;
+
+ CSize aspect(mvih->hdr.bmiHeader.biWidth * num, mvih->hdr.bmiHeader.biHeight * den);
+ int lnko = LNKO(aspect.cx, aspect.cy);
+ if (lnko > 1) {
+ aspect.cx /= lnko, aspect.cy /= lnko;
+ }
+ mvih->hdr.dwPictAspectRatioX = aspect.cx;
+ mvih->hdr.dwPictAspectRatioY = aspect.cy;
+ if (item->GetData()->GetSampleCount()) {
+ mvih->hdr.AvgTimePerFrame = item->GetData()->GetDurationMs() * 10000 / (item->GetData()->GetSampleCount());
+ }
+ mvih->dwProfile = data[1];
+ mvih->dwLevel = data[3];
+ mvih->dwFlags = (data[4] & 3) + 1;
+
+ mvih->cbSequenceHeader = 0;
+
+ BYTE* src = (BYTE*)data + 5;
+ BYTE* dst = (BYTE*)mvih->dwSequenceHeader;
+
+ BYTE* src_end = (BYTE*)data + size;
+ BYTE* dst_end = (BYTE*)mvih->dwSequenceHeader + size;
+
+ for (int i = 0; i < 2; ++i) {
+ for (int n = *src++ & 0x1f; n > 0; --n) {
+ int len = ((src[0] << 8) | src[1]) + 2;
+ if (src + len > src_end || dst + len > dst_end) {
+ ASSERT(0);
+ break;
+ }
+ memcpy(dst, src, len);
+ src += len;
+ dst += len;
+ mvih->cbSequenceHeader += len;
+ }
+ }
+
+ mts.Add(mt);
+
+ mt.subtype = FOURCCMap(mvih->hdr.bmiHeader.biCompression = '1CVA');
+ mts.Add(mt);
+ //b_HasVideo = true;
+ }
+ } else if (AP4_StsdAtom* stsd = dynamic_cast<AP4_StsdAtom*>(
+ track->GetTrakAtom()->FindChild("mdia/minf/stbl/stsd"))) {
+ const AP4_DataBuffer& db = stsd->GetDataBuffer();
+
+ for (AP4_List<AP4_Atom>::Item* item = stsd->GetChildren().FirstItem();
+ item;
+ item = item->GetNext()) {
+ AP4_Atom* atom = item->GetData();
+
+ AP4_Atom::Type type = atom->GetType();
+ DWORD fourcc =
+ ((type >> 24) & 0x000000ff) |
+ ((type >> 8) & 0x0000ff00) |
+ ((type << 8) & 0x00ff0000) |
+ ((type << 24) & 0xff000000);
+
+ if (AP4_VisualSampleEntry* vse = dynamic_cast<AP4_VisualSampleEntry*>(atom)) {
+
+ if (type == AP4_ATOM_TYPE_MJPA || type == AP4_ATOM_TYPE_MJPB || type == AP4_ATOM_TYPE_MJPG) {
+ SetTrackName(&TrackName, _T("M-Jpeg"));
+ }
+
+ mt.majortype = MEDIATYPE_Video;
+ mt.subtype = FOURCCMap(fourcc);
+ mt.formattype = FORMAT_VideoInfo;
+ vih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + db.GetDataSize());
+ memset(vih, 0, mt.FormatLength());
+ vih->bmiHeader.biSize = sizeof(vih->bmiHeader);
+ vih->bmiHeader.biWidth = (LONG)vse->GetWidth();
+ vih->bmiHeader.biHeight = (LONG)vse->GetHeight();
+ vih->bmiHeader.biCompression = fourcc;
+ vih->bmiHeader.biBitCount = (LONG)vse->GetDepth();
+ memcpy(vih + 1, db.GetData(), db.GetDataSize());
+ mts.Add(mt);
+
+ char buff[5];
+ memcpy(buff, &fourcc, 4);
+ buff[4] = 0;
+
+ _strlwr_s(buff);
+ AP4_Atom::Type typelwr = *(AP4_Atom::Type*)buff;
+
+ if (typelwr != fourcc) {
+ mt.subtype = FOURCCMap(vih->bmiHeader.biCompression = typelwr);
+ mts.Add(mt);
+ //b_HasVideo = true;
+ }
+
+ _strupr_s(buff);
+ AP4_Atom::Type typeupr = *(AP4_Atom::Type*)buff;
+
+ if (typeupr != fourcc) {
+ mt.subtype = FOURCCMap(vih->bmiHeader.biCompression = typeupr);
+ mts.Add(mt);
+ //b_HasVideo = true;
+ }
+
+ break;
+ } else if (AP4_AudioSampleEntry* ase = dynamic_cast<AP4_AudioSampleEntry*>(atom)) {
+ DWORD samplerate = ase->GetSampleRate();
+ WORD channels = ase->GetChannelCount();
+ WORD bitspersample = ase->GetSampleSize();
+
+ // overwrite audio fourc
+ if ((type & 0xffff0000) == AP4_ATOM_TYPE('m', 's', 0, 0)) {
+ fourcc = type & 0xffff;
+ } else if (type == AP4_ATOM_TYPE_ALAW) {
+ fourcc = WAVE_FORMAT_ALAW;
+ SetTrackName(&TrackName, _T("PCM A-law"));
+ } else if (type == AP4_ATOM_TYPE_ULAW) {
+ fourcc = WAVE_FORMAT_MULAW;
+ SetTrackName(&TrackName, _T("PCM mu-law"));
+ } else if (type == AP4_ATOM_TYPE__MP3) {
+ SetTrackName(&TrackName, _T("MPEG Audio (MP3)"));
+ fourcc = WAVE_FORMAT_MPEGLAYER3;
+ } else if ((type == AP4_ATOM_TYPE__AC3) || (type == AP4_ATOM_TYPE_SAC3) || (type == AP4_ATOM_TYPE_EAC3)) {
+ fourcc = 0x2000;
+ if (type == AP4_ATOM_TYPE_EAC3) {
+ SetTrackName(&TrackName, _T("AC-3 Audio"));
+ } else {
+ SetTrackName(&TrackName, _T("Enhanced AC-3 audio"));
+ }
+ } else if (type == AP4_ATOM_TYPE_MP4A) {
+ fourcc = WAVE_FORMAT_AAC;
+ SetTrackName(&TrackName, _T("MPEG-2 Audio AAC"));
+ } else if (type == AP4_ATOM_TYPE_NMOS) {
+ fourcc = MAKEFOURCC('N', 'E', 'L', 'L');
+ SetTrackName(&TrackName, _T("NellyMoser Audio"));
+ } else if (type == AP4_ATOM_TYPE_ALAC) {
+ fourcc = MAKEFOURCC('a', 'l', 'a', 'c');
+ SetTrackName(&TrackName, _T("Alac Audio"));
+ } else if ((type == AP4_ATOM_TYPE_NONE || type == AP4_ATOM_TYPE_RAW) && bitspersample == 8 ||
+ type == AP4_ATOM_TYPE_SOWT && bitspersample == 16 ||
+ (type == AP4_ATOM_TYPE_IN24 || type == AP4_ATOM_TYPE_IN32) && ase->GetEndian() == ENDIAN_LITTLE) {
+ fourcc = type = WAVE_FORMAT_PCM;
+ } else if ((type == AP4_ATOM_TYPE_FL32 || type == AP4_ATOM_TYPE_FL64) && ase->GetEndian() == ENDIAN_LITTLE) {
+ fourcc = type = WAVE_FORMAT_IEEE_FLOAT;
+ } else if (type == AP4_ATOM_TYPE_LPCM) {
+ DWORD flags = ase->GetFormatSpecificFlags();
+ if (flags & 2) { // big endian
+ if (flags & 1) { // floating point
+ if (bitspersample == 32) { type = AP4_ATOM_TYPE_FL32; }
+ else if (bitspersample == 64) { type = AP4_ATOM_TYPE_FL64; }
+ } else {
+ if (bitspersample == 16) { type = AP4_ATOM_TYPE_TWOS; }
+ else if (bitspersample == 24) { type = AP4_ATOM_TYPE_IN24; }
+ else if (bitspersample == 32) { type = AP4_ATOM_TYPE_IN32; }
+ }
+ fourcc = ((type >> 24) & 0x000000ff) |
+ ((type >> 8) & 0x0000ff00) |
+ ((type << 8) & 0x00ff0000) |
+ ((type << 24) & 0xff000000);
+ } else { // little endian
+ if (flags & 1) { // floating point
+ fourcc = type = WAVE_FORMAT_IEEE_FLOAT;
+ } else {
+ fourcc = type = WAVE_FORMAT_PCM;
+ }
+ }
+ }
+
+ DWORD nAvgBytesPerSec = 0;
+ if (type == AP4_ATOM_TYPE_EAC3) {
+
+ AP4_Sample sample;
+ AP4_DataBuffer sample_data;
+
+ AP4_Cardinal SampleCount = track->GetSampleCount();
+ if (SampleCount) {
+ track->ReadSample(1, sample, sample_data);
+ const AP4_Byte* data = sample_data.GetData();
+ AP4_Size size = sample_data.GetDataSize();
+
+ CGolombBuffer gb((BYTE*)data, size);
+ for (; size >= 7 && gb.BitRead(16, true) != 0x0b77; --size) {
+ gb.BitRead(8);
+ }
+ WORD sync = (WORD)gb.BitRead(16);
+ if ((size >= 7) && (sync == 0x0b77)) {
+ static DWORD freq[] = {48000, 44100, 32000, 0};
+ gb.BitRead(2);
+ gb.BitRead(3);
+ WORD frame_size = ((WORD)gb.BitRead(11) + 1) << 1;
+ BYTE sr_code = (BYTE)gb.BitRead(2);
+ if (sr_code == 3) {
+ BYTE sr_code2 = (BYTE)gb.BitRead(2);
+ samplerate = freq[sr_code2] / 2;
+ } else {
+ static BYTE eac3_blocks[4] = {1, 2, 3, 6};
+ BYTE num_blocks = eac3_blocks[gb.BitRead(2)];
+ samplerate = freq[sr_code];
+ nAvgBytesPerSec = frame_size * samplerate / (num_blocks * 256);
+ }
+ BYTE acmod = (BYTE)gb.BitRead(3);
+ BYTE lfeon = (BYTE)gb.BitRead(1);
+ static WORD channels_tbl[] = {2, 1, 2, 3, 3, 4, 4, 5};
+ channels = channels_tbl[acmod] + lfeon;
+ }
+ }
+ }
+
+ mt.majortype = MEDIATYPE_Audio;
+ mt.formattype = FORMAT_WaveFormatEx;
+ wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX));
+ memset(wfe, 0, mt.FormatLength());
+ if (!(fourcc & 0xffff0000)) {
+ wfe->wFormatTag = (WORD)fourcc;
+ }
+ wfe->nSamplesPerSec = samplerate;
+ wfe->nChannels = channels;
+ wfe->wBitsPerSample = bitspersample;
+ wfe->nBlockAlign = ase->GetBytesPerFrame();
+ if (nAvgBytesPerSec == 0 && ase->GetSamplesPerPacket() > 0) {
+ wfe->nAvgBytesPerSec = wfe->nSamplesPerSec * wfe->nBlockAlign / ase->GetSamplesPerPacket();
+ }
+
+ mt.subtype = FOURCCMap(fourcc);
+
+
+ if (type == AP4_ATOM_TYPE('m', 's', 0x00, 0x02)) {
+ const WORD numcoef = 7;
+ static ADPCMCOEFSET coef[] = { {256, 0}, {512, -256}, {0, 0}, {192, 64}, {240, 0}, {460, -208}, {392, -232} };
+ const ULONG size = sizeof(ADPCMWAVEFORMAT) + (numcoef * sizeof(ADPCMCOEFSET));
+ ADPCMWAVEFORMAT* format = (ADPCMWAVEFORMAT*)mt.ReallocFormatBuffer(size);
+ if (format != NULL) {
+ format->wfx.wFormatTag = WAVE_FORMAT_ADPCM;
+ format->wfx.wBitsPerSample = 4;
+ format->wfx.cbSize = (WORD)(size - sizeof(WAVEFORMATEX));
+ format->wSamplesPerBlock = format->wfx.nBlockAlign * 2 / format->wfx.nChannels - 12;
+ format->wNumCoef = numcoef;
+ memcpy(format->aCoef, coef, sizeof(coef));
+ }
+ } else if (type == AP4_ATOM_TYPE('m', 's', 0x00, 0x11)) {
+ IMAADPCMWAVEFORMAT* format = (IMAADPCMWAVEFORMAT*)mt.ReallocFormatBuffer(sizeof(IMAADPCMWAVEFORMAT));
+ if (format != NULL) {
+ format->wfx.wFormatTag = WAVE_FORMAT_IMA_ADPCM;
+ format->wfx.wBitsPerSample = 4;
+ format->wfx.cbSize = (WORD)(sizeof(IMAADPCMWAVEFORMAT) - sizeof(WAVEFORMATEX));
+ int X = (format->wfx.nBlockAlign - (4 * format->wfx.nChannels)) * 8;
+ int Y = format->wfx.wBitsPerSample * format->wfx.nChannels;
+ format->wSamplesPerBlock = (X / Y) + 1;
+ }
+ } else if (type == AP4_ATOM_TYPE_ALAC) {
+ const AP4_Byte* data = db.GetData();
+ AP4_Size size = db.GetDataSize();
+
+ while (size >= 36) {
+ if ((*(DWORD*)(data) == 0x24000000) && (*(DWORD*)(data + 4) == 0x63616c61)) {
+ break;
+ }
+ size--;
+ data++;
+ }
+
+ if (size >= 36) {
+ wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + 36);
+ wfe->cbSize = 36;
+ memcpy(wfe + 1, data, 36);
+ }
+ } else if (type == WAVE_FORMAT_PCM) {
+ mt.SetSampleSize(wfe->nBlockAlign);
+ if (channels > 2 || bitspersample > 16) {
+ WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEXTENSIBLE));
+ if (wfex != NULL) {
+ wfex->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
+ wfex->Format.cbSize = 22;
+ wfex->Samples.wValidBitsPerSample = bitspersample;
+ wfex->dwChannelMask = GetDefChannelMask(channels); // TODO: get correct channel mask from mov file
+ wfex->SubFormat = MEDIASUBTYPE_PCM;
+ }
+ }
+ } else if (type == WAVE_FORMAT_IEEE_FLOAT) {
+ mt.SetSampleSize(wfe->nBlockAlign);
+ if (channels > 2) {
+ WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEXTENSIBLE));
+ if (wfex != NULL) {
+ wfex->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
+ wfex->Format.cbSize = 22;
+ wfex->Samples.wValidBitsPerSample = bitspersample;
+ wfex->dwChannelMask = GetDefChannelMask(channels); // TODO: get correct channel mask from mov file
+ wfex->SubFormat = MEDIASUBTYPE_IEEE_FLOAT;
+ }
+ }
+ } else if (type == AP4_ATOM_TYPE_MP4A ||
+ type == AP4_ATOM_TYPE_ALAW ||
+ type == AP4_ATOM_TYPE_ULAW) {
+ // not need any extra data for ALAW, ULAW
+ // also extra data is not required for IMA4, MAC3, MAC6
+ } else if (db.GetDataSize() > 0) {
+ //always needed extra data for QDM2
+ wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + db.GetDataSize());
+ wfe->cbSize = db.GetDataSize();
+ memcpy(wfe + 1, db.GetData(), db.GetDataSize());
+ }
+
+ mts.Add(mt);
+ break;
+ } else {
+ TRACE(_T("Unknow MP4 Stream %x") , fourcc);
+ }
+ }
+ }
+
+ if (mts.IsEmpty()) {
+ continue;
+ }
+
+ REFERENCE_TIME rtDuration = 10000i64 * track->GetDurationMs();
+ if (m_rtDuration < rtDuration) {
+ m_rtDuration = rtDuration;
+ }
+ if (rtVideoDuration < rtDuration && AP4_Track::TYPE_VIDEO == track->GetType()) {
+ rtVideoDuration = rtDuration; // get the max video duration
+ }
+
+ DWORD id = track->GetId();
+
+ CStringW name, lang;
+ name.Format(L"Output %d", id);
+
+ if (!TrackName.IsEmpty()) {
+ name = TrackName;
+ }
+
+ if (!TrackLanguage.IsEmpty()) {
+ if (TrackLanguage != L"und") {
+ name += " (" + TrackLanguage + ")";
+ }
+ }
+
+ for (int i = 0, j = mts.GetCount(); i < j; ++i) {
+ BITMAPINFOHEADER bih;
+ if (ExtractBIH(&mts[i], &bih)) {
+ m_framesize.cx = bih.biWidth;
+ m_framesize.cy = abs(bih.biHeight);
+ }
+ }
+
+ CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CMP4SplitterOutputPin(mts, name, this, this, &hr));
+
+ if (!TrackName.IsEmpty()) {
+ pPinOut->SetProperty(L"NAME", TrackName);
+ }
+ if (!TrackLanguage.IsEmpty()) {
+ pPinOut->SetProperty(L"LANG", CStringW(TrackLanguage));
+ }
+
+ EXECUTE_ASSERT(SUCCEEDED(AddOutputPin(id, pPinOut)));
+
+ m_trackpos[id] = trackpos();
+
+ if (mts.GetCount() == 1 && mts[0].subtype == MEDIASUBTYPE_ASS2) {
+ LPCWSTR postfix = L" (plain text)";
+
+ mts[0].subtype = MEDIASUBTYPE_UTF8;
+
+ SUBTITLEINFO* si = (SUBTITLEINFO*)mts[0].ReallocFormatBuffer(sizeof(SUBTITLEINFO));
+ wcscat_s(si->TrackName, postfix);
+
+ id ^= 0x80402010; // FIXME: until fixing, let's hope there won't be another track like this...
+
+ CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CMP4SplitterOutputPin(mts, name + postfix, this, this, &hr));
+
+ if (!TrackName.IsEmpty()) {
+ pPinOut->SetProperty(L"NAME", TrackName + postfix);
+ }
+ if (!TrackLanguage.IsEmpty()) {
+ pPinOut->SetProperty(L"LANG", CStringW(TrackLanguage));
+ }
+
+ EXECUTE_ASSERT(SUCCEEDED(AddOutputPin(id, pPinOut)));
+ }
+ }
+
+ if (AP4_ChplAtom* chpl = dynamic_cast<AP4_ChplAtom*>(movie->GetMoovAtom()->FindChild("udta/chpl"))) {
+ AP4_Array<AP4_ChplAtom::AP4_Chapter>& chapters = chpl->GetChapters();
+
+ for (AP4_Cardinal i = 0; i < chapters.ItemCount(); ++i) {
+ AP4_ChplAtom::AP4_Chapter& chapter = chapters[i];
+ ChapAppend(chapter.Time, UTF8To16(ConvertMBCS(chapter.Name.c_str(), ANSI_CHARSET, CP_UTF8))); // this is b0rked, thx to nero :P
+ }
+
+ ChapSort();
+ }
+
+ if (AP4_ContainerAtom* ilst = dynamic_cast<AP4_ContainerAtom*>(movie->GetMoovAtom()->FindChild("udta/meta/ilst"))) {
+ CStringW title, artist, writer, album, year, appl, desc, gen, track;
+
+ for (AP4_List<AP4_Atom>::Item* item = ilst->GetChildren().FirstItem();
+ item;
+ item = item->GetNext()) {
+ if (AP4_ContainerAtom* atom = dynamic_cast<AP4_ContainerAtom*>(item->GetData())) {
+ if (AP4_DataAtom* data = dynamic_cast<AP4_DataAtom*>(atom->GetChild(AP4_ATOM_TYPE_DATA))) {
+ const AP4_DataBuffer* db = data->GetData();
+
+ if (atom->GetType() == AP4_ATOM_TYPE_TRKN) {
+ if (db->GetDataSize() >= 4) {
+ unsigned short n = (db->GetData()[2] << 8) | db->GetData()[3];
+ if (n > 0 && n < 100) {
+ track.Format(L"%02d", n);
+ } else if (n >= 100) {
+ track.Format(L"%d", n);
+ }
+ }
+ } else {
+ CStringW str = UTF8To16(CStringA((LPCSTR)db->GetData(), db->GetDataSize()));
+
+ switch (atom->GetType()) {
+ case AP4_ATOM_TYPE_NAM:
+ title = str;
+ break;
+ case AP4_ATOM_TYPE_ART:
+ artist = str;
+ break;
+ case AP4_ATOM_TYPE_WRT:
+ writer = str;
+ break;
+ case AP4_ATOM_TYPE_ALB:
+ album = str;
+ break;
+ case AP4_ATOM_TYPE_DAY:
+ year = str;
+ break;
+ case AP4_ATOM_TYPE_TOO:
+ appl = str;
+ break;
+ case AP4_ATOM_TYPE_CMT:
+ desc = str;
+ break;
+ case AP4_ATOM_TYPE_GEN:
+ gen = str;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if (!title.IsEmpty()) {
+ if (!track.IsEmpty()) {
+ title = track + L" - " + title;
+ }
+ if (!album.IsEmpty()) {
+ title = album + L" - " + title;
+ }
+ if (!year.IsEmpty()) {
+ title += L" - " + year;
+ }
+ if (!gen.IsEmpty()) {
+ title += L" - " + gen;
+ }
+ SetProperty(L"TITL", title);
+ }
+
+ if (!artist.IsEmpty()) {
+ SetProperty(L"AUTH", artist);
+ } else if (!writer.IsEmpty()) {
+ SetProperty(L"AUTH", writer);
+ }
+
+ if (!appl.IsEmpty()) {
+ SetProperty(L"APPL", appl);
+ }
+
+ if (!desc.IsEmpty()) {
+ SetProperty(L"DESC", desc);
+ }
+ }
+ }
+
+ if (rtVideoDuration > 0 && rtVideoDuration < m_rtDuration / 2) {
+ m_rtDuration = rtVideoDuration; // fix incorrect duration
+ }
+
+ m_rtNewStop = m_rtStop = m_rtDuration;
+
+ TRACE(_T("CMP4SplitterFilter m_pOutputs.GetCount() = %d") , m_pOutputs.GetCount());
+
+ return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
}
bool CMP4SplitterFilter::DemuxInit()
{
- AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
+ AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
- POSITION pos = m_trackpos.GetStartPosition();
- while (pos) {
- CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
+ POSITION pos = m_trackpos.GetStartPosition();
+ while (pos) {
+ CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
- pPair->m_value.index = 0;
- pPair->m_value.ts = 0;
+ pPair->m_value.index = 0;
+ pPair->m_value.ts = 0;
- AP4_Track* track = movie->GetTrack(pPair->m_key);
+ AP4_Track* track = movie->GetTrack(pPair->m_key);
- AP4_Sample sample;
- if (AP4_SUCCEEDED(track->GetSample(0, sample))) {
- pPair->m_value.ts = sample.GetCts();
- }
- }
+ AP4_Sample sample;
+ if (AP4_SUCCEEDED(track->GetSample(0, sample))) {
+ pPair->m_value.ts = sample.GetCts();
+ }
+ }
- return true;
+ return true;
}
void CMP4SplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
- AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
-
- POSITION pos = m_trackpos.GetStartPosition();
- while (pos) {
- CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
-
- AP4_Track* track = movie->GetTrack(pPair->m_key);
-
- if (AP4_FAILED(track->GetSampleIndexForRefTime(rt, pPair->m_value.index))) {
- continue;
- }
-
- AP4_Sample sample;
- if (AP4_SUCCEEDED(track->GetSample(pPair->m_value.index, sample))) {
- pPair->m_value.ts = sample.GetCts();
- }
-
- // FIXME: slow search & stss->m_Entries is private
- if (AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
- if (stss->m_Entries.ItemCount() > 0) {
- AP4_Cardinal i = 1;
- while (i < stss->m_Entries.ItemCount()) {
- if (stss->m_Entries[i] - 1 > pPair->m_value.index) {
- break;
- }
- ++i;
- }
- //ASSERT(pPair->m_value.index == stss->m_Entries[i-1] - 1); // fast seek test
- pPair->m_value.index = stss->m_Entries[i-1] - 1;
- }
- }
- }
+ AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
+
+ POSITION pos = m_trackpos.GetStartPosition();
+ while (pos) {
+ CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
+
+ AP4_Track* track = movie->GetTrack(pPair->m_key);
+
+ if (AP4_FAILED(track->GetSampleIndexForRefTime(rt, pPair->m_value.index))) {
+ continue;
+ }
+
+ AP4_Sample sample;
+ if (AP4_SUCCEEDED(track->GetSample(pPair->m_value.index, sample))) {
+ pPair->m_value.ts = sample.GetCts();
+ }
+
+ // FIXME: slow search & stss->m_Entries is private
+ if (AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
+ if (stss->m_Entries.ItemCount() > 0) {
+ AP4_Cardinal i = 1;
+ while (i < stss->m_Entries.ItemCount()) {
+ if (stss->m_Entries[i] - 1 > pPair->m_value.index) {
+ break;
+ }
+ ++i;
+ }
+ //ASSERT(pPair->m_value.index == stss->m_Entries[i-1] - 1); // fast seek test
+ pPair->m_value.index = stss->m_Entries[i - 1] - 1;
+ }
+ }
+ }
}
bool CMP4SplitterFilter::DemuxLoop()
{
- HRESULT hr = S_OK;
-
- AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
-
- while (SUCCEEDED(hr) && !CheckRequest(NULL)) {
- CAtlMap<DWORD, trackpos>::CPair* pPairNext = NULL;
- REFERENCE_TIME rtNext = 0;
-
- POSITION pos = m_trackpos.GetStartPosition();
- while (pos) {
- CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
-
- AP4_Track* track = movie->GetTrack(pPair->m_key);
-
- CBaseSplitterOutputPin* pPin = GetOutputPin((DWORD)track->GetId());
- if (!pPin->IsConnected()) {
- continue;
- }
-
- REFERENCE_TIME rt = (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * pPair->m_value.ts);
-
- if (pPair->m_value.index < track->GetSampleCount() && (!pPairNext || rt < rtNext)) {
- pPairNext = pPair;
- rtNext = rt;
- }
- }
-
- if (!pPairNext) {
- break;
- }
-
- AP4_Track* track = movie->GetTrack(pPairNext->m_key);
-
- CBaseSplitterOutputPin* pPin = GetOutputPin((DWORD)track->GetId());
-
- AP4_Sample sample;
- AP4_DataBuffer data;
-
- if (pPin && pPin->IsConnected() && AP4_SUCCEEDED(track->ReadSample(pPairNext->m_value.index, sample, data))) {
- const CMediaType& mt = pPin->CurrentMediaType();
-
- CAutoPtr<Packet> p(DNew Packet());
- p->TrackNumber = (DWORD)track->GetId();
- p->rtStart = (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * sample.GetCts());
- p->rtStop = p->rtStart + (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * sample.GetDuration());
- p->bSyncPoint = TRUE;
-
- // FIXME: slow search & stss->m_Entries is private
- if (AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
- if (stss->m_Entries.ItemCount() > 0) {
- p->bSyncPoint = FALSE;
- for (AP4_Cardinal i = 0; i < stss->m_Entries.ItemCount(); ++i) {
- if (stss->m_Entries[i] - 1 < pPairNext->m_value.index) {
- continue;
- }
- if (stss->m_Entries[i] - 1 == pPairNext->m_value.index) {
- p->bSyncPoint = TRUE;
- }
- break;
- }
- }
- }
-
- //
- if (track->GetType() == AP4_Track::TYPE_AUDIO && data.GetDataSize() >= 1 && data.GetDataSize() <= 16) {
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
-
- int nBlockAlign;
- if (wfe->nBlockAlign == 0) {
- nBlockAlign = 1200;
- } else if (wfe->nBlockAlign <= 16) { // for PCM (from 8bit mono to 64bit stereo), A-Law, u-Law
- nBlockAlign = wfe->nBlockAlign * (wfe->nSamplesPerSec >> 4); // 1/16s=62.5ms
- } else {
- nBlockAlign = wfe->nBlockAlign;
- pPairNext->m_value.index -= pPairNext->m_value.index % wfe->nBlockAlign;
- }
-
- p->rtStop = p->rtStart;
- TRACE(_T("track->GetSampleCount() %d %d "), track->GetSampleCount(),pPairNext->m_value.index);
- int fFirst = true;
-
- while (AP4_SUCCEEDED(track->ReadSample(pPairNext->m_value.index, sample, data))) {
- AP4_Size size = data.GetDataSize();
- const AP4_Byte* ptr = data.GetData();
-
- if (fFirst) {
- p->SetData(ptr, size);
- p->rtStart = p->rtStop = (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * sample.GetCts());
- fFirst = false;
- } else {
- for (int i = 0; i < size; ++i) p->Add(ptr[i]);
- }
-
- p->rtStop += (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * sample.GetDuration());
-
- if (pPairNext->m_value.index+1 >= track->GetSampleCount() || (int)p->GetCount() >= nBlockAlign) {
- break;
- }
-
- pPairNext->m_value.index++;
- }
- } else if (track->GetType() == AP4_Track::TYPE_TEXT) {
- CStringA dlgln_bkg, dlgln_plaintext;
-
- const AP4_Byte* ptr = data.GetData();
- AP4_Size avail = data.GetDataSize();
-
- if (avail > 2) {
- AP4_UI16 size = (ptr[0] << 8) | ptr[1];
-
- if (size <= avail-2) {
- CStringA str;
-
- if (size >= 2 && ptr[2] == 0xfe && ptr[3] == 0xff) {
- CStringW wstr = CStringW((LPCWSTR)&ptr[2], size/2);
- for (int i = 0; i < wstr.GetLength(); ++i) {
- wstr.SetAt(i, ((WORD)wstr[i] >> 8) | ((WORD)wstr[i] << 8));
- }
- str = UTF16To8(wstr);
- } else {
- str = CStringA((LPCSTR)&ptr[2], size);
- }
-
- CStringA dlgln = str;
-
- if (mt.subtype == MEDIASUBTYPE_ASS2) {
- AP4_SampleDescription* desc = track->GetSampleDescription(sample.GetDescriptionIndex());
-
- dlgln = "0,0,Text,,0000,0000,0000,0000,," + str;
- dlgln_plaintext = str;
-
- CPoint translation(0, 0);
- if (AP4_TkhdAtom* tkhd = dynamic_cast<AP4_TkhdAtom*>(track->GetTrakAtom()->GetChild(AP4_ATOM_TYPE_TKHD))) {
- AP4_Float x, y;
- tkhd->GetTranslation(x, y);
- translation.SetPoint((int)x, (int)y);
- }
-
- if (AP4_UnknownSampleDescription* unknown_desc = dynamic_cast<AP4_UnknownSampleDescription*>(desc)) { // TEMP
- AP4_SampleEntry* sample_entry = unknown_desc->GetSampleEntry();
-
- if (AP4_TextSampleEntry* text = dynamic_cast<AP4_TextSampleEntry*>(sample_entry)) {
- const AP4_TextSampleEntry::AP4_TextDescription& d = text->GetDescription();
-
- // TODO
- } else if (AP4_Tx3gSampleEntry* tx3g = dynamic_cast<AP4_Tx3gSampleEntry*>(sample_entry)) {
- const AP4_Tx3gSampleEntry::AP4_Tx3gDescription& desc = tx3g->GetDescription();
-
- CStringW font = L"Arial";
-
- if (AP4_FtabAtom* ftab = dynamic_cast<AP4_FtabAtom*>(tx3g->GetChild(AP4_ATOM_TYPE_FTAB))) {
- AP4_String Name;
- if (AP4_SUCCEEDED(ftab->LookupFont(desc.Style.Font.Id, Name))) {
- font = Name.c_str();
- }
- }
-
- CRect rbox;
- CStringW ssa = ConvertTX3GToSSA(
- UTF8To16(str), desc, font,
- ptr + (2 + size), avail - (2 + size),
- m_framesize, translation,
- (p->rtStop - p->rtStart)/10000,
- rbox);
- dlgln = UTF16To8(ssa);
-
- const AP4_Byte* bclr = (const AP4_Byte*)&desc.BackgroundColor;
-
- if (bclr[3]) {
- CPoint tl = rbox.TopLeft();
- rbox.OffsetRect(-tl.x, -tl.y);
-
- dlgln_bkg.Format(
- "0,-1,Text,,0,0,0,0,,{\\an7\\pos(%d,%d)\\1c%02x%02x%02x\\1a%02x\\bord0\\shad0}{\\p1}m %d %d l %d %d l %d %d l %d %d {\\p0}",
- tl.x, tl.y,
- bclr[2], bclr[1], bclr[0],
- 255 - bclr[3],
- rbox.left, rbox.top,
- rbox.right, rbox.top,
- rbox.right, rbox.bottom,
- rbox.left, rbox.bottom);
- }
- }
- }
- }
-
- dlgln.Replace("\r", "");
- dlgln.Replace("\n", "\\N");
-
- p->SetData((LPCSTR)dlgln, dlgln.GetLength());
- }
- }
-
- if (!dlgln_bkg.IsEmpty()) {
- CAutoPtr<Packet> p2(DNew Packet());
- p2->TrackNumber = p->TrackNumber;
- p2->rtStart = p->rtStart;
- p2->rtStop = p->rtStop;
- p2->bSyncPoint = p->bSyncPoint;
- p2->SetData((LPCSTR)dlgln_bkg, dlgln_bkg.GetLength());
- hr = DeliverPacket(p2);
- }
-
- if (!dlgln_plaintext.IsEmpty()) {
- CAutoPtr<Packet> p2(DNew Packet());
- p2->TrackNumber = p->TrackNumber ^ 0x80402010;
- p2->rtStart = p->rtStart;
- p2->rtStop = p->rtStop;
- p2->bSyncPoint = p->bSyncPoint;
- p2->SetData((LPCSTR)dlgln_plaintext, dlgln_plaintext.GetLength());
- hr = DeliverPacket(p2);
- }
- } else {
- p->SetData(data.GetData(), data.GetDataSize());
- }
- hr = DeliverPacket(p);
- }
-
- {
- AP4_Sample sample;
- if (AP4_SUCCEEDED(track->GetSample(++pPairNext->m_value.index, sample))) {
- pPairNext->m_value.ts = sample.GetCts();
- }
- }
-
- }
-
- return true;
+ HRESULT hr = S_OK;
+
+ AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
+
+ while (SUCCEEDED(hr) && !CheckRequest(NULL)) {
+ CAtlMap<DWORD, trackpos>::CPair* pPairNext = NULL;
+ REFERENCE_TIME rtNext = 0;
+
+ POSITION pos = m_trackpos.GetStartPosition();
+ while (pos) {
+ CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
+
+ AP4_Track* track = movie->GetTrack(pPair->m_key);
+
+ CBaseSplitterOutputPin* pPin = GetOutputPin((DWORD)track->GetId());
+ if (!pPin->IsConnected()) {
+ continue;
+ }
+
+ REFERENCE_TIME rt = (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * pPair->m_value.ts);
+
+ if (pPair->m_value.index < track->GetSampleCount() && (!pPairNext || rt < rtNext)) {
+ pPairNext = pPair;
+ rtNext = rt;
+ }
+ }
+
+ if (!pPairNext) {
+ break;
+ }
+
+ AP4_Track* track = movie->GetTrack(pPairNext->m_key);
+
+ CBaseSplitterOutputPin* pPin = GetOutputPin((DWORD)track->GetId());
+
+ AP4_Sample sample;
+ AP4_DataBuffer data;
+
+ if (pPin && pPin->IsConnected() && AP4_SUCCEEDED(track->ReadSample(pPairNext->m_value.index, sample, data))) {
+ const CMediaType& mt = pPin->CurrentMediaType();
+
+ CAutoPtr<Packet> p(DNew Packet());
+ p->TrackNumber = (DWORD)track->GetId();
+ p->rtStart = (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * sample.GetCts());
+ p->rtStop = p->rtStart + (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * sample.GetDuration());
+ p->bSyncPoint = TRUE;
+
+ // FIXME: slow search & stss->m_Entries is private
+ if (AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
+ if (stss->m_Entries.ItemCount() > 0) {
+ p->bSyncPoint = FALSE;
+ for (AP4_Cardinal i = 0; i < stss->m_Entries.ItemCount(); ++i) {
+ if (stss->m_Entries[i] - 1 < pPairNext->m_value.index) {
+ continue;
+ }
+ if (stss->m_Entries[i] - 1 == pPairNext->m_value.index) {
+ p->bSyncPoint = TRUE;
+ }
+ break;
+ }
+ }
+ }
+
+ //
+ if (track->GetType() == AP4_Track::TYPE_AUDIO && data.GetDataSize() >= 1 && data.GetDataSize() <= 16) {
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
+
+ int nBlockAlign;
+ if (wfe->nBlockAlign == 0) {
+ nBlockAlign = 1200;
+ } else if (wfe->nBlockAlign <= 16) { // for PCM (from 8bit mono to 64bit stereo), A-Law, u-Law
+ nBlockAlign = wfe->nBlockAlign * (wfe->nSamplesPerSec >> 4); // 1/16s=62.5ms
+ } else {
+ nBlockAlign = wfe->nBlockAlign;
+ pPairNext->m_value.index -= pPairNext->m_value.index % wfe->nBlockAlign;
+ }
+
+ p->rtStop = p->rtStart;
+ TRACE(_T("track->GetSampleCount() %d %d "), track->GetSampleCount(), pPairNext->m_value.index);
+ int fFirst = true;
+
+ while (AP4_SUCCEEDED(track->ReadSample(pPairNext->m_value.index, sample, data))) {
+ AP4_Size size = data.GetDataSize();
+ const AP4_Byte* ptr = data.GetData();
+
+ if (fFirst) {
+ p->SetData(ptr, size);
+ p->rtStart = p->rtStop = (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * sample.GetCts());
+ fFirst = false;
+ } else {
+ for (int i = 0; i < size; ++i) { p->Add(ptr[i]); }
+ }
+
+ p->rtStop += (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * sample.GetDuration());
+
+ if (pPairNext->m_value.index + 1 >= track->GetSampleCount() || (int)p->GetCount() >= nBlockAlign) {
+ break;
+ }
+
+ pPairNext->m_value.index++;
+ }
+ } else if (track->GetType() == AP4_Track::TYPE_TEXT) {
+ CStringA dlgln_bkg, dlgln_plaintext;
+
+ const AP4_Byte* ptr = data.GetData();
+ AP4_Size avail = data.GetDataSize();
+
+ if (avail > 2) {
+ AP4_UI16 size = (ptr[0] << 8) | ptr[1];
+
+ if (size <= avail - 2) {
+ CStringA str;
+
+ if (size >= 2 && ptr[2] == 0xfe && ptr[3] == 0xff) {
+ CStringW wstr = CStringW((LPCWSTR)&ptr[2], size / 2);
+ for (int i = 0; i < wstr.GetLength(); ++i) {
+ wstr.SetAt(i, ((WORD)wstr[i] >> 8) | ((WORD)wstr[i] << 8));
+ }
+ str = UTF16To8(wstr);
+ } else {
+ str = CStringA((LPCSTR)&ptr[2], size);
+ }
+
+ CStringA dlgln = str;
+
+ if (mt.subtype == MEDIASUBTYPE_ASS2) {
+ AP4_SampleDescription* desc = track->GetSampleDescription(sample.GetDescriptionIndex());
+
+ dlgln = "0,0,Text,,0000,0000,0000,0000,," + str;
+ dlgln_plaintext = str;
+
+ CPoint translation(0, 0);
+ if (AP4_TkhdAtom* tkhd = dynamic_cast<AP4_TkhdAtom*>(track->GetTrakAtom()->GetChild(AP4_ATOM_TYPE_TKHD))) {
+ AP4_Float x, y;
+ tkhd->GetTranslation(x, y);
+ translation.SetPoint((int)x, (int)y);
+ }
+
+ if (AP4_UnknownSampleDescription* unknown_desc = dynamic_cast<AP4_UnknownSampleDescription*>(desc)) { // TEMP
+ AP4_SampleEntry* sample_entry = unknown_desc->GetSampleEntry();
+
+ if (AP4_TextSampleEntry* text = dynamic_cast<AP4_TextSampleEntry*>(sample_entry)) {
+ const AP4_TextSampleEntry::AP4_TextDescription& d = text->GetDescription();
+
+ // TODO
+ } else if (AP4_Tx3gSampleEntry* tx3g = dynamic_cast<AP4_Tx3gSampleEntry*>(sample_entry)) {
+ const AP4_Tx3gSampleEntry::AP4_Tx3gDescription& desc = tx3g->GetDescription();
+
+ CStringW font = L"Arial";
+
+ if (AP4_FtabAtom* ftab = dynamic_cast<AP4_FtabAtom*>(tx3g->GetChild(AP4_ATOM_TYPE_FTAB))) {
+ AP4_String Name;
+ if (AP4_SUCCEEDED(ftab->LookupFont(desc.Style.Font.Id, Name))) {
+ font = Name.c_str();
+ }
+ }
+
+ CRect rbox;
+ CStringW ssa = ConvertTX3GToSSA(
+ UTF8To16(str), desc, font,
+ ptr + (2 + size), avail - (2 + size),
+ m_framesize, translation,
+ (p->rtStop - p->rtStart) / 10000,
+ rbox);
+ dlgln = UTF16To8(ssa);
+
+ const AP4_Byte* bclr = (const AP4_Byte*)&desc.BackgroundColor;
+
+ if (bclr[3]) {
+ CPoint tl = rbox.TopLeft();
+ rbox.OffsetRect(-tl.x, -tl.y);
+
+ dlgln_bkg.Format(
+ "0,-1,Text,,0,0,0,0,,{\\an7\\pos(%d,%d)\\1c%02x%02x%02x\\1a%02x\\bord0\\shad0}{\\p1}m %d %d l %d %d l %d %d l %d %d {\\p0}",
+ tl.x, tl.y,
+ bclr[2], bclr[1], bclr[0],
+ 255 - bclr[3],
+ rbox.left, rbox.top,
+ rbox.right, rbox.top,
+ rbox.right, rbox.bottom,
+ rbox.left, rbox.bottom);
+ }
+ }
+ }
+ }
+
+ dlgln.Replace("\r", "");
+ dlgln.Replace("\n", "\\N");
+
+ p->SetData((LPCSTR)dlgln, dlgln.GetLength());
+ }
+ }
+
+ if (!dlgln_bkg.IsEmpty()) {
+ CAutoPtr<Packet> p2(DNew Packet());
+ p2->TrackNumber = p->TrackNumber;
+ p2->rtStart = p->rtStart;
+ p2->rtStop = p->rtStop;
+ p2->bSyncPoint = p->bSyncPoint;
+ p2->SetData((LPCSTR)dlgln_bkg, dlgln_bkg.GetLength());
+ hr = DeliverPacket(p2);
+ }
+
+ if (!dlgln_plaintext.IsEmpty()) {
+ CAutoPtr<Packet> p2(DNew Packet());
+ p2->TrackNumber = p->TrackNumber ^ 0x80402010;
+ p2->rtStart = p->rtStart;
+ p2->rtStop = p->rtStop;
+ p2->bSyncPoint = p->bSyncPoint;
+ p2->SetData((LPCSTR)dlgln_plaintext, dlgln_plaintext.GetLength());
+ hr = DeliverPacket(p2);
+ }
+ } else {
+ p->SetData(data.GetData(), data.GetDataSize());
+ }
+ hr = DeliverPacket(p);
+ }
+
+ {
+ AP4_Sample sample;
+ if (AP4_SUCCEEDED(track->GetSample(++pPairNext->m_value.index, sample))) {
+ pPairNext->m_value.ts = sample.GetCts();
+ }
+ }
+
+ }
+
+ return true;
}
// IKeyFrameInfo
STDMETHODIMP CMP4SplitterFilter::GetKeyFrameCount(UINT& nKFs)
{
- CheckPointer(m_pFile, E_UNEXPECTED);
+ CheckPointer(m_pFile, E_UNEXPECTED);
- if (!m_pFile) {
- return E_UNEXPECTED;
- }
+ if (!m_pFile) {
+ return E_UNEXPECTED;
+ }
- AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
+ AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
- POSITION pos = m_trackpos.GetStartPosition();
- while (pos) {
- CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
+ POSITION pos = m_trackpos.GetStartPosition();
+ while (pos) {
+ CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
- AP4_Track* track = movie->GetTrack(pPair->m_key);
+ AP4_Track* track = movie->GetTrack(pPair->m_key);
- if (track->GetType() != AP4_Track::TYPE_VIDEO) {
- continue;
- }
+ if (track->GetType() != AP4_Track::TYPE_VIDEO) {
+ continue;
+ }
- if (AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
- nKFs = stss->m_Entries.ItemCount();
- return S_OK;
- }
- }
+ if (AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
+ nKFs = stss->m_Entries.ItemCount();
+ return S_OK;
+ }
+ }
- return E_FAIL;
+ return E_FAIL;
}
STDMETHODIMP CMP4SplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs)
{
- CheckPointer(pFormat, E_POINTER);
- CheckPointer(pKFs, E_POINTER);
- CheckPointer(m_pFile, E_UNEXPECTED);
+ CheckPointer(pFormat, E_POINTER);
+ CheckPointer(pKFs, E_POINTER);
+ CheckPointer(m_pFile, E_UNEXPECTED);
- if (*pFormat != TIME_FORMAT_MEDIA_TIME) {
- return E_INVALIDARG;
- }
+ if (*pFormat != TIME_FORMAT_MEDIA_TIME) {
+ return E_INVALIDARG;
+ }
- if (!m_pFile) {
- return E_UNEXPECTED;
- }
+ if (!m_pFile) {
+ return E_UNEXPECTED;
+ }
- AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
+ AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
- POSITION pos = m_trackpos.GetStartPosition();
- while (pos) {
- CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
+ POSITION pos = m_trackpos.GetStartPosition();
+ while (pos) {
+ CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
- AP4_Track* track = movie->GetTrack(pPair->m_key);
+ AP4_Track* track = movie->GetTrack(pPair->m_key);
- if (track->GetType() != AP4_Track::TYPE_VIDEO) {
- continue;
- }
+ if (track->GetType() != AP4_Track::TYPE_VIDEO) {
+ continue;
+ }
- if (AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
- UINT nKFsTmp = 0;
- AP4_UI32 mts = track->GetMediaTimeScale();
+ if (AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
+ UINT nKFsTmp = 0;
+ AP4_UI32 mts = track->GetMediaTimeScale();
- for (AP4_Cardinal i = 0; i < stss->m_Entries.ItemCount() && nKFsTmp < nKFs; ++i) {
- AP4_Sample sample;
- if (AP4_SUCCEEDED(track->GetSample(stss->m_Entries[i]-1, sample))) {
- pKFs[nKFsTmp++] = REFERENCE_TIME((10000000ui64 * sample.GetCts() + mts/2) / mts);
- //pKFs[nKFsTmp++] = REFERENCE_TIME(10000000.0 * sample.GetCts() / track->GetMediaTimeScale() + 0.5);
- }
- }
- nKFs = nKFsTmp;
+ for (AP4_Cardinal i = 0; i < stss->m_Entries.ItemCount() && nKFsTmp < nKFs; ++i) {
+ AP4_Sample sample;
+ if (AP4_SUCCEEDED(track->GetSample(stss->m_Entries[i] - 1, sample))) {
+ pKFs[nKFsTmp++] = REFERENCE_TIME((10000000ui64 * sample.GetCts() + mts / 2) / mts);
+ //pKFs[nKFsTmp++] = REFERENCE_TIME(10000000.0 * sample.GetCts() / track->GetMediaTimeScale() + 0.5);
+ }
+ }
+ nKFs = nKFsTmp;
- return S_OK;
- }
- }
+ return S_OK;
+ }
+ }
- return E_FAIL;
+ return E_FAIL;
}
//
@@ -1699,10 +1701,10 @@ STDMETHODIMP CMP4SplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENCE_TIM
//
CMP4SourceFilter::CMP4SourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CMP4SplitterFilter(pUnk, phr)
+ : CMP4SplitterFilter(pUnk, phr)
{
- m_clsid = __uuidof(this);
- m_pInput.Free();
+ m_clsid = __uuidof(this);
+ m_pInput.Free();
}
//
@@ -1710,325 +1712,325 @@ CMP4SourceFilter::CMP4SourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
//
CMPEG4VideoSplitterFilter::CMPEG4VideoSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("CMPEG4VideoSplitterFilter"), pUnk, phr, __uuidof(this))
+ : CBaseSplitterFilter(NAME("CMPEG4VideoSplitterFilter"), pUnk, phr, __uuidof(this))
{
}
void CMPEG4VideoSplitterFilter::SkipUserData()
{
- m_pFile->BitByteAlign();
- while (m_pFile->BitRead(32, true) == 0x000001b2)
- while (m_pFile->BitRead(24, true) != 0x000001) {
- m_pFile->BitRead(8);
- }
+ m_pFile->BitByteAlign();
+ while (m_pFile->BitRead(32, true) == 0x000001b2)
+ while (m_pFile->BitRead(24, true) != 0x000001) {
+ m_pFile->BitRead(8);
+ }
}
HRESULT CMPEG4VideoSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
{
- CheckPointer(pAsyncReader, E_POINTER);
-
- HRESULT hr = E_FAIL;
-
- m_pFile.Free();
- m_pFile.Attach(DNew CBaseSplitterFileEx(pAsyncReader, hr));
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration = 0;
-
- // TODO
-
- DWORD width = 0;
- DWORD height = 0;
- BYTE parx = 1;
- BYTE pary = 1;
- REFERENCE_TIME atpf = 400000;
-
- if (m_pFile->BitRead(24, true) != 0x000001) {
- return E_FAIL;
- }
-
- BYTE id;
- while (m_pFile->NextMpegStartCode(id, 1024 - m_pFile->GetPos())) {
- if (id == 0xb5) {
- BYTE is_visual_object_identifier = (BYTE)m_pFile->BitRead(1);
-
- if (is_visual_object_identifier) {
- BYTE visual_object_verid = (BYTE)m_pFile->BitRead(4);
- BYTE visual_object_priority = (BYTE)m_pFile->BitRead(3);
- }
-
- BYTE visual_object_type = (BYTE)m_pFile->BitRead(4);
-
- if (visual_object_type == 1 || visual_object_type == 2) {
- BYTE video_signal_type = (BYTE)m_pFile->BitRead(1);
-
- if (video_signal_type) {
- BYTE video_format = (BYTE)m_pFile->BitRead(3);
- BYTE video_range = (BYTE)m_pFile->BitRead(1);
- BYTE colour_description = (BYTE)m_pFile->BitRead(1);
-
- if (colour_description) {
- BYTE colour_primaries = (BYTE)m_pFile->BitRead(8);
- BYTE transfer_characteristics = (BYTE)m_pFile->BitRead(8);
- BYTE matrix_coefficients = (BYTE)m_pFile->BitRead(8);
- }
- }
- }
-
- SkipUserData();
-
- if (visual_object_type == 1) {
- if (m_pFile->BitRead(24) != 0x000001) {
- break;
- }
-
- BYTE video_object_start_code = (BYTE)m_pFile->BitRead(8);
- if (video_object_start_code < 0x00 || video_object_start_code > 0x1f) {
- break;
- }
-
- if (m_pFile->BitRead(24) != 0x000001) {
- break;
- }
-
- BYTE video_object_layer_start_code = (DWORD)m_pFile->BitRead(8);
- if (video_object_layer_start_code < 0x20 || video_object_layer_start_code > 0x2f) {
- break;
- }
-
- BYTE random_accessible_vol = (BYTE)m_pFile->BitRead(1);
- BYTE video_object_type_indication = (BYTE)m_pFile->BitRead(8);
-
- if (video_object_type_indication == 0x12) { // Fine Granularity Scalable
- break; // huh
- }
-
- BYTE is_object_layer_identifier = (BYTE)m_pFile->BitRead(1);
-
- BYTE video_object_layer_verid = 0;
-
- if (is_object_layer_identifier) {
- video_object_layer_verid = (BYTE)m_pFile->BitRead(4);
- BYTE video_object_layer_priority = (BYTE)m_pFile->BitRead(3);
- }
-
- BYTE aspect_ratio_info = (BYTE)m_pFile->BitRead(4);
-
- switch (aspect_ratio_info) {
- default:
- ASSERT(0);
- break;
- case 1:
- parx = 1;
- pary = 1;
- break;
- case 2:
- parx = 12;
- pary = 11;
- break;
- case 3:
- parx = 10;
- pary = 11;
- break;
- case 4:
- parx = 16;
- pary = 11;
- break;
- case 5:
- parx = 40;
- pary = 33;
- break;
- case 15:
- parx = (BYTE)m_pFile->BitRead(8);
- pary = (BYTE)m_pFile->BitRead(8);
- break;
- }
-
- BYTE vol_control_parameters = (BYTE)m_pFile->BitRead(1);
-
- if (vol_control_parameters) {
- BYTE chroma_format = (BYTE)m_pFile->BitRead(2);
- BYTE low_delay = (BYTE)m_pFile->BitRead(1);
- BYTE vbv_parameters = (BYTE)m_pFile->BitRead(1);
-
- if (vbv_parameters) {
- WORD first_half_bit_rate = (WORD)m_pFile->BitRead(15);
- if (!m_pFile->BitRead(1)) {
- break;
- }
- WORD latter_half_bit_rate = (WORD)m_pFile->BitRead(15);
- if (!m_pFile->BitRead(1)) {
- break;
- }
- WORD first_half_vbv_buffer_size = (WORD)m_pFile->BitRead(15);
- if (!m_pFile->BitRead(1)) {
- break;
- }
-
- BYTE latter_half_vbv_buffer_size = (BYTE)m_pFile->BitRead(3);
- WORD first_half_vbv_occupancy = (WORD)m_pFile->BitRead(11);
- if (!m_pFile->BitRead(1)) {
- break;
- }
- WORD latter_half_vbv_occupancy = (WORD)m_pFile->BitRead(15);
- if (!m_pFile->BitRead(1)) {
- break;
- }
- }
- }
-
- BYTE video_object_layer_shape = (BYTE)m_pFile->BitRead(2);
-
- if (video_object_layer_shape == 3 && video_object_layer_verid != 1) {
- BYTE video_object_layer_shape_extension = (BYTE)m_pFile->BitRead(4);
- }
-
- if (!m_pFile->BitRead(1)) {
- break;
- }
- WORD vop_time_increment_resolution = (WORD)m_pFile->BitRead(16);
- if (!m_pFile->BitRead(1)) {
- break;
- }
- BYTE fixed_vop_rate = (BYTE)m_pFile->BitRead(1);
-
- if (fixed_vop_rate) {
- int bits = 0;
- for (WORD i = vop_time_increment_resolution; i; i /= 2) {
- ++bits;
- }
-
- WORD fixed_vop_time_increment = m_pFile->BitRead(bits);
-
- if (fixed_vop_time_increment) {
- atpf = 10000000i64 * fixed_vop_time_increment / vop_time_increment_resolution;
- }
- }
-
- if (video_object_layer_shape != 2) {
- if (video_object_layer_shape == 0) {
- if (!m_pFile->BitRead(1)) {
- break;
- }
- width = (WORD)m_pFile->BitRead(13);
- if (!m_pFile->BitRead(1)) {
- break;
- }
- height = (WORD)m_pFile->BitRead(13);
- if (!m_pFile->BitRead(1)) {
- break;
- }
- }
-
- BYTE interlaced = (BYTE)m_pFile->BitRead(1);
- BYTE obmc_disable = (BYTE)m_pFile->BitRead(1);
-
- // ...
- }
- }
- } else if (id == 0xb6) {
- m_seqhdrsize = m_pFile->GetPos() - 4;
- }
- }
-
- if (!width || !height) {
- return E_FAIL;
- }
-
- CAtlArray<CMediaType> mts;
-
- CMediaType mt;
- mt.SetSampleSize(1);
-
- mt.majortype = MEDIATYPE_Video;
- mt.subtype = FOURCCMap('v4pm');
- mt.formattype = FORMAT_MPEG2Video;
- MPEG2VIDEOINFO* mvih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + m_seqhdrsize);
- memset(mvih, 0, mt.FormatLength());
- mvih->hdr.bmiHeader.biSize = sizeof(mvih->hdr.bmiHeader);
- mvih->hdr.bmiHeader.biWidth = width;
- mvih->hdr.bmiHeader.biHeight = height;
- mvih->hdr.bmiHeader.biCompression = 'v4pm';
- mvih->hdr.bmiHeader.biPlanes = 1;
- mvih->hdr.bmiHeader.biBitCount = 24;
- mvih->hdr.AvgTimePerFrame = atpf;
- mvih->hdr.dwPictAspectRatioX = width*parx;
- mvih->hdr.dwPictAspectRatioY = height*pary;
- mvih->cbSequenceHeader = m_seqhdrsize;
- m_pFile->Seek(0);
- m_pFile->ByteRead((BYTE*)mvih->dwSequenceHeader, m_seqhdrsize);
- mts.Add(mt);
- mt.subtype = FOURCCMap(mvih->hdr.bmiHeader.biCompression = 'V4PM');
- mts.Add(mt);
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, L"Video", this, this, &hr));
- EXECUTE_ASSERT(SUCCEEDED(AddOutputPin(0, pPinOut)));
-
- m_rtNewStop = m_rtStop = m_rtDuration;
-
- return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
+ CheckPointer(pAsyncReader, E_POINTER);
+
+ HRESULT hr = E_FAIL;
+
+ m_pFile.Free();
+ m_pFile.Attach(DNew CBaseSplitterFileEx(pAsyncReader, hr));
+ if (!m_pFile) {
+ return E_OUTOFMEMORY;
+ }
+ if (FAILED(hr)) {
+ m_pFile.Free();
+ return hr;
+ }
+
+ m_rtNewStart = m_rtCurrent = 0;
+ m_rtNewStop = m_rtStop = m_rtDuration = 0;
+
+ // TODO
+
+ DWORD width = 0;
+ DWORD height = 0;
+ BYTE parx = 1;
+ BYTE pary = 1;
+ REFERENCE_TIME atpf = 400000;
+
+ if (m_pFile->BitRead(24, true) != 0x000001) {
+ return E_FAIL;
+ }
+
+ BYTE id;
+ while (m_pFile->NextMpegStartCode(id, 1024 - m_pFile->GetPos())) {
+ if (id == 0xb5) {
+ BYTE is_visual_object_identifier = (BYTE)m_pFile->BitRead(1);
+
+ if (is_visual_object_identifier) {
+ BYTE visual_object_verid = (BYTE)m_pFile->BitRead(4);
+ BYTE visual_object_priority = (BYTE)m_pFile->BitRead(3);
+ }
+
+ BYTE visual_object_type = (BYTE)m_pFile->BitRead(4);
+
+ if (visual_object_type == 1 || visual_object_type == 2) {
+ BYTE video_signal_type = (BYTE)m_pFile->BitRead(1);
+
+ if (video_signal_type) {
+ BYTE video_format = (BYTE)m_pFile->BitRead(3);
+ BYTE video_range = (BYTE)m_pFile->BitRead(1);
+ BYTE colour_description = (BYTE)m_pFile->BitRead(1);
+
+ if (colour_description) {
+ BYTE colour_primaries = (BYTE)m_pFile->BitRead(8);
+ BYTE transfer_characteristics = (BYTE)m_pFile->BitRead(8);
+ BYTE matrix_coefficients = (BYTE)m_pFile->BitRead(8);
+ }
+ }
+ }
+
+ SkipUserData();
+
+ if (visual_object_type == 1) {
+ if (m_pFile->BitRead(24) != 0x000001) {
+ break;
+ }
+
+ BYTE video_object_start_code = (BYTE)m_pFile->BitRead(8);
+ if (video_object_start_code < 0x00 || video_object_start_code > 0x1f) {
+ break;
+ }
+
+ if (m_pFile->BitRead(24) != 0x000001) {
+ break;
+ }
+
+ BYTE video_object_layer_start_code = (DWORD)m_pFile->BitRead(8);
+ if (video_object_layer_start_code < 0x20 || video_object_layer_start_code > 0x2f) {
+ break;
+ }
+
+ BYTE random_accessible_vol = (BYTE)m_pFile->BitRead(1);
+ BYTE video_object_type_indication = (BYTE)m_pFile->BitRead(8);
+
+ if (video_object_type_indication == 0x12) { // Fine Granularity Scalable
+ break; // huh
+ }
+
+ BYTE is_object_layer_identifier = (BYTE)m_pFile->BitRead(1);
+
+ BYTE video_object_layer_verid = 0;
+
+ if (is_object_layer_identifier) {
+ video_object_layer_verid = (BYTE)m_pFile->BitRead(4);
+ BYTE video_object_layer_priority = (BYTE)m_pFile->BitRead(3);
+ }
+
+ BYTE aspect_ratio_info = (BYTE)m_pFile->BitRead(4);
+
+ switch (aspect_ratio_info) {
+ default:
+ ASSERT(0);
+ break;
+ case 1:
+ parx = 1;
+ pary = 1;
+ break;
+ case 2:
+ parx = 12;
+ pary = 11;
+ break;
+ case 3:
+ parx = 10;
+ pary = 11;
+ break;
+ case 4:
+ parx = 16;
+ pary = 11;
+ break;
+ case 5:
+ parx = 40;
+ pary = 33;
+ break;
+ case 15:
+ parx = (BYTE)m_pFile->BitRead(8);
+ pary = (BYTE)m_pFile->BitRead(8);
+ break;
+ }
+
+ BYTE vol_control_parameters = (BYTE)m_pFile->BitRead(1);
+
+ if (vol_control_parameters) {
+ BYTE chroma_format = (BYTE)m_pFile->BitRead(2);
+ BYTE low_delay = (BYTE)m_pFile->BitRead(1);
+ BYTE vbv_parameters = (BYTE)m_pFile->BitRead(1);
+
+ if (vbv_parameters) {
+ WORD first_half_bit_rate = (WORD)m_pFile->BitRead(15);
+ if (!m_pFile->BitRead(1)) {
+ break;
+ }
+ WORD latter_half_bit_rate = (WORD)m_pFile->BitRead(15);
+ if (!m_pFile->BitRead(1)) {
+ break;
+ }
+ WORD first_half_vbv_buffer_size = (WORD)m_pFile->BitRead(15);
+ if (!m_pFile->BitRead(1)) {
+ break;
+ }
+
+ BYTE latter_half_vbv_buffer_size = (BYTE)m_pFile->BitRead(3);
+ WORD first_half_vbv_occupancy = (WORD)m_pFile->BitRead(11);
+ if (!m_pFile->BitRead(1)) {
+ break;
+ }
+ WORD latter_half_vbv_occupancy = (WORD)m_pFile->BitRead(15);
+ if (!m_pFile->BitRead(1)) {
+ break;
+ }
+ }
+ }
+
+ BYTE video_object_layer_shape = (BYTE)m_pFile->BitRead(2);
+
+ if (video_object_layer_shape == 3 && video_object_layer_verid != 1) {
+ BYTE video_object_layer_shape_extension = (BYTE)m_pFile->BitRead(4);
+ }
+
+ if (!m_pFile->BitRead(1)) {
+ break;
+ }
+ WORD vop_time_increment_resolution = (WORD)m_pFile->BitRead(16);
+ if (!m_pFile->BitRead(1)) {
+ break;
+ }
+ BYTE fixed_vop_rate = (BYTE)m_pFile->BitRead(1);
+
+ if (fixed_vop_rate) {
+ int bits = 0;
+ for (WORD i = vop_time_increment_resolution; i; i /= 2) {
+ ++bits;
+ }
+
+ WORD fixed_vop_time_increment = m_pFile->BitRead(bits);
+
+ if (fixed_vop_time_increment) {
+ atpf = 10000000i64 * fixed_vop_time_increment / vop_time_increment_resolution;
+ }
+ }
+
+ if (video_object_layer_shape != 2) {
+ if (video_object_layer_shape == 0) {
+ if (!m_pFile->BitRead(1)) {
+ break;
+ }
+ width = (WORD)m_pFile->BitRead(13);
+ if (!m_pFile->BitRead(1)) {
+ break;
+ }
+ height = (WORD)m_pFile->BitRead(13);
+ if (!m_pFile->BitRead(1)) {
+ break;
+ }
+ }
+
+ BYTE interlaced = (BYTE)m_pFile->BitRead(1);
+ BYTE obmc_disable = (BYTE)m_pFile->BitRead(1);
+
+ // ...
+ }
+ }
+ } else if (id == 0xb6) {
+ m_seqhdrsize = m_pFile->GetPos() - 4;
+ }
+ }
+
+ if (!width || !height) {
+ return E_FAIL;
+ }
+
+ CAtlArray<CMediaType> mts;
+
+ CMediaType mt;
+ mt.SetSampleSize(1);
+
+ mt.majortype = MEDIATYPE_Video;
+ mt.subtype = FOURCCMap('v4pm');
+ mt.formattype = FORMAT_MPEG2Video;
+ MPEG2VIDEOINFO* mvih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + m_seqhdrsize);
+ memset(mvih, 0, mt.FormatLength());
+ mvih->hdr.bmiHeader.biSize = sizeof(mvih->hdr.bmiHeader);
+ mvih->hdr.bmiHeader.biWidth = width;
+ mvih->hdr.bmiHeader.biHeight = height;
+ mvih->hdr.bmiHeader.biCompression = 'v4pm';
+ mvih->hdr.bmiHeader.biPlanes = 1;
+ mvih->hdr.bmiHeader.biBitCount = 24;
+ mvih->hdr.AvgTimePerFrame = atpf;
+ mvih->hdr.dwPictAspectRatioX = width * parx;
+ mvih->hdr.dwPictAspectRatioY = height * pary;
+ mvih->cbSequenceHeader = m_seqhdrsize;
+ m_pFile->Seek(0);
+ m_pFile->ByteRead((BYTE*)mvih->dwSequenceHeader, m_seqhdrsize);
+ mts.Add(mt);
+ mt.subtype = FOURCCMap(mvih->hdr.bmiHeader.biCompression = 'V4PM');
+ mts.Add(mt);
+
+ CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, L"Video", this, this, &hr));
+ EXECUTE_ASSERT(SUCCEEDED(AddOutputPin(0, pPinOut)));
+
+ m_rtNewStop = m_rtStop = m_rtDuration;
+
+ return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
}
bool CMPEG4VideoSplitterFilter::DemuxInit()
{
- return true;
+ return true;
}
void CMPEG4VideoSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
- ASSERT(rt == 0);
+ ASSERT(rt == 0);
- m_pFile->Seek(m_seqhdrsize);
+ m_pFile->Seek(m_seqhdrsize);
}
bool CMPEG4VideoSplitterFilter::DemuxLoop()
{
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- CAutoPtr<Packet> p;
+ CAutoPtr<Packet> p;
- REFERENCE_TIME rt = 0;
- REFERENCE_TIME atpf = ((MPEG2VIDEOINFO*)GetOutputPin(0)->CurrentMediaType().Format())->hdr.AvgTimePerFrame;
+ REFERENCE_TIME rt = 0;
+ REFERENCE_TIME atpf = ((MPEG2VIDEOINFO*)GetOutputPin(0)->CurrentMediaType().Format())->hdr.AvgTimePerFrame;
- DWORD sync = ~0;
+ DWORD sync = ~0;
- while (SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetRemaining()) {
- for (int i = 0; i < 65536; ++i) { // don't call CheckRequest so often
- bool eof = !m_pFile->GetRemaining();
+ while (SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetRemaining()) {
+ for (int i = 0; i < 65536; ++i) { // don't call CheckRequest so often
+ bool eof = !m_pFile->GetRemaining();
- if (p && !p->IsEmpty() && (m_pFile->BitRead(32, true) == 0x000001b6 || eof)) {
- hr = DeliverPacket(p);
- }
+ if (p && !p->IsEmpty() && (m_pFile->BitRead(32, true) == 0x000001b6 || eof)) {
+ hr = DeliverPacket(p);
+ }
- if (eof) {
- break;
- }
+ if (eof) {
+ break;
+ }
- if (!p) {
- p.Attach(DNew Packet());
- p->SetCount(0, 1024);
- p->TrackNumber = 0;
- p->rtStart = rt;
- p->rtStop = rt + atpf;
- p->bSyncPoint = FALSE;
- rt += atpf;
- // rt = Packet::INVALID_TIME;
- }
+ if (!p) {
+ p.Attach(DNew Packet());
+ p->SetCount(0, 1024);
+ p->TrackNumber = 0;
+ p->rtStart = rt;
+ p->rtStop = rt + atpf;
+ p->bSyncPoint = FALSE;
+ rt += atpf;
+ // rt = Packet::INVALID_TIME;
+ }
- BYTE b;
- m_pFile->ByteRead(&b, 1);
- p->Add(b);
- }
- }
+ BYTE b;
+ m_pFile->ByteRead(&b, 1);
+ p->Add(b);
+ }
+ }
- return true;
+ return true;
}
//
@@ -2036,10 +2038,10 @@ bool CMPEG4VideoSplitterFilter::DemuxLoop()
//
CMPEG4VideoSourceFilter::CMPEG4VideoSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CMPEG4VideoSplitterFilter(pUnk, phr)
+ : CMPEG4VideoSplitterFilter(pUnk, phr)
{
- m_clsid = __uuidof(this);
- m_pInput.Free();
+ m_clsid = __uuidof(this);
+ m_pInput.Free();
}
//
@@ -2047,7 +2049,7 @@ CMPEG4VideoSourceFilter::CMPEG4VideoSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
//
CMP4SplitterOutputPin::CMP4SplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseSplitterOutputPin(mts, pName, pFilter, pLock, phr)
+ : CBaseSplitterOutputPin(mts, pName, pFilter, pLock, phr)
{
}
@@ -2057,18 +2059,18 @@ CMP4SplitterOutputPin::~CMP4SplitterOutputPin()
HRESULT CMP4SplitterOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- CAutoLock cAutoLock(this);
- return __super::DeliverNewSegment(tStart, tStop, dRate);
+ CAutoLock cAutoLock(this);
+ return __super::DeliverNewSegment(tStart, tStop, dRate);
}
HRESULT CMP4SplitterOutputPin::DeliverEndFlush()
{
- CAutoLock cAutoLock(this);
- return __super::DeliverEndFlush();
+ CAutoLock cAutoLock(this);
+ return __super::DeliverEndFlush();
}
HRESULT CMP4SplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
{
- CAutoLock cAutoLock(this);
- return __super::DeliverPacket(p);
+ CAutoLock cAutoLock(this);
+ return __super::DeliverPacket(p);
}
diff --git a/src/filters/parser/MP4Splitter/MP4Splitter.h b/src/filters/parser/MP4Splitter/MP4Splitter.h
index 6faeb2d06..d90fd7f86 100644
--- a/src/filters/parser/MP4Splitter/MP4Splitter.h
+++ b/src/filters/parser/MP4Splitter/MP4Splitter.h
@@ -32,78 +32,78 @@
#define MP4SourceName L"MPC MP4/MOV Source"
class __declspec(uuid("61F47056-E400-43d3-AF1E-AB7DFFD4C4AD"))
- CMP4SplitterFilter : public CBaseSplitterFilter
+ CMP4SplitterFilter : public CBaseSplitterFilter
{
- struct trackpos {
- DWORD /*AP4_Ordinal*/ index;
- unsigned __int64 /*AP4_TimeStamp*/ ts;
- };
- CAtlMap<DWORD, trackpos> m_trackpos;
- CSize m_framesize;
+ struct trackpos {
+ DWORD /*AP4_Ordinal*/ index;
+ unsigned __int64 /*AP4_TimeStamp*/ ts;
+ };
+ CAtlMap<DWORD, trackpos> m_trackpos;
+ CSize m_framesize;
protected:
- CAutoPtr<CMP4SplitterFile> m_pFile;
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
+ CAutoPtr<CMP4SplitterFile> m_pFile;
+ HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
+ bool DemuxInit();
+ void DemuxSeek(REFERENCE_TIME rt);
+ bool DemuxLoop();
public:
- CMP4SplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
- virtual ~CMP4SplitterFilter();
+ CMP4SplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
+ virtual ~CMP4SplitterFilter();
- // CBaseFilter
- STDMETHODIMP_(HRESULT) QueryFilterInfo(FILTER_INFO* pInfo);
+ // CBaseFilter
+ STDMETHODIMP_(HRESULT) QueryFilterInfo(FILTER_INFO* pInfo);
- // IKeyFrameInfo
+ // IKeyFrameInfo
- STDMETHODIMP_(HRESULT) GetKeyFrameCount(UINT& nKFs);
- STDMETHODIMP_(HRESULT) GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs);
+ STDMETHODIMP_(HRESULT) GetKeyFrameCount(UINT& nKFs);
+ STDMETHODIMP_(HRESULT) GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs);
};
class __declspec(uuid("3CCC052E-BDEE-408a-BEA7-90914EF2964B"))
- CMP4SourceFilter : public CMP4SplitterFilter
+ CMP4SourceFilter : public CMP4SplitterFilter
{
public:
- CMP4SourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
+ CMP4SourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
};
// for raw mpeg4 elementary streams:
class __declspec(uuid("D3D9D58B-45B5-48AB-B199-B8C40560AEC7"))
- CMPEG4VideoSplitterFilter : public CBaseSplitterFilter
+ CMPEG4VideoSplitterFilter : public CBaseSplitterFilter
{
- __int64 m_seqhdrsize;
- int NextStartCode();
- void SkipUserData();
+ __int64 m_seqhdrsize;
+ int NextStartCode();
+ void SkipUserData();
protected:
- CAutoPtr<CBaseSplitterFileEx> m_pFile;
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
+ CAutoPtr<CBaseSplitterFileEx> m_pFile;
+ HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
+ bool DemuxInit();
+ void DemuxSeek(REFERENCE_TIME rt);
+ bool DemuxLoop();
public:
- CMPEG4VideoSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
+ CMPEG4VideoSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
};
class __declspec(uuid("E2B98EEA-EE55-4E9B-A8C1-6E5288DF785A"))
- CMPEG4VideoSourceFilter : public CMPEG4VideoSplitterFilter
+ CMPEG4VideoSourceFilter : public CMPEG4VideoSplitterFilter
{
public:
- CMPEG4VideoSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
+ CMPEG4VideoSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
};
class CMP4SplitterOutputPin : public CBaseSplitterOutputPin, protected CCritSec
{
public:
- CMP4SplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
- virtual ~CMP4SplitterOutputPin();
+ CMP4SplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
+ virtual ~CMP4SplitterOutputPin();
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
- HRESULT DeliverPacket(CAutoPtr<Packet> p);
- HRESULT DeliverEndFlush();
+ HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ HRESULT DeliverPacket(CAutoPtr<Packet> p);
+ HRESULT DeliverEndFlush();
};
diff --git a/src/filters/parser/MP4Splitter/MP4SplitterFile.cpp b/src/filters/parser/MP4Splitter/MP4SplitterFile.cpp
index b7331bba4..fe45ebe3c 100644
--- a/src/filters/parser/MP4Splitter/MP4SplitterFile.cpp
+++ b/src/filters/parser/MP4Splitter/MP4SplitterFile.cpp
@@ -3,40 +3,40 @@
#include "Ap4AsyncReaderStream.h"
CMP4SplitterFile::CMP4SplitterFile(IAsyncReader* pReader, HRESULT& hr)
- : CBaseSplitterFileEx(pReader, hr, DEFAULT_CACHE_LENGTH, false)
- , m_pAp4File(NULL)
+ : CBaseSplitterFileEx(pReader, hr, DEFAULT_CACHE_LENGTH, false)
+ , m_pAp4File(NULL)
{
- if (FAILED(hr)) {
- return;
- }
+ if (FAILED(hr)) {
+ return;
+ }
- hr = Init();
+ hr = Init();
}
CMP4SplitterFile::~CMP4SplitterFile()
{
- delete (AP4_File*)m_pAp4File;
+ delete(AP4_File*)m_pAp4File;
}
void* /* AP4_Movie* */ CMP4SplitterFile::GetMovie()
{
- ASSERT(m_pAp4File);
- return m_pAp4File ? ((AP4_File*)m_pAp4File)->GetMovie() : NULL;
+ ASSERT(m_pAp4File);
+ return m_pAp4File ? ((AP4_File*)m_pAp4File)->GetMovie() : NULL;
}
HRESULT CMP4SplitterFile::Init()
{
- Seek(0);
+ Seek(0);
- delete (AP4_File*)m_pAp4File;
+ delete(AP4_File*)m_pAp4File;
- AP4_ByteStream* stream = DNew AP4_AsyncReaderStream(this);
+ AP4_ByteStream* stream = DNew AP4_AsyncReaderStream(this);
- m_pAp4File = DNew AP4_File(*stream);
+ m_pAp4File = DNew AP4_File(*stream);
- AP4_Movie* movie = ((AP4_File*)m_pAp4File)->GetMovie();
+ AP4_Movie* movie = ((AP4_File*)m_pAp4File)->GetMovie();
- stream->Release();
+ stream->Release();
- return movie ? S_OK : E_FAIL;
+ return movie ? S_OK : E_FAIL;
}
diff --git a/src/filters/parser/MP4Splitter/MP4SplitterFile.h b/src/filters/parser/MP4Splitter/MP4SplitterFile.h
index ef1557b9f..ac8377c88 100644
--- a/src/filters/parser/MP4Splitter/MP4SplitterFile.h
+++ b/src/filters/parser/MP4Splitter/MP4SplitterFile.h
@@ -5,13 +5,13 @@
class CMP4SplitterFile : public CBaseSplitterFileEx
{
- void* /* AP4_File* */ m_pAp4File;
+ void* /* AP4_File* */ m_pAp4File;
- HRESULT Init();
+ HRESULT Init();
public:
- CMP4SplitterFile(IAsyncReader* pReader, HRESULT& hr);
- virtual ~CMP4SplitterFile();
+ CMP4SplitterFile(IAsyncReader* pReader, HRESULT& hr);
+ virtual ~CMP4SplitterFile();
- void* /* AP4_Movie* */ GetMovie();
+ void* /* AP4_Movie* */ GetMovie();
};
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaFile.cpp b/src/filters/parser/MatroskaSplitter/MatroskaFile.cpp
index 2e4e84776..714074ea3 100644
--- a/src/filters/parser/MatroskaSplitter/MatroskaFile.cpp
+++ b/src/filters/parser/MatroskaSplitter/MatroskaFile.cpp
@@ -55,9 +55,9 @@ using namespace MatroskaReader;
static void bswap(BYTE* s, int len)
{
- for (BYTE* d = s + len-1; s < d; s++, d--) {
- *s ^= *d, *d ^= *s, *s ^= *d;
- }
+ for (BYTE* d = s + len - 1; s < d; s++, d--) {
+ *s ^= *d, *d ^= *s, *s ^= *d;
+ }
}
//
@@ -65,1516 +65,1516 @@ static void bswap(BYTE* s, int len)
//
CMatroskaFile::CMatroskaFile(IAsyncReader* pAsyncReader, HRESULT& hr)
- : CBaseSplitterFile(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false)
- , m_rtOffset(0)
+ : CBaseSplitterFile(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false)
+ , m_rtOffset(0)
{
- if (FAILED(hr)) {
- return;
- }
- hr = Init();
+ if (FAILED(hr)) {
+ return;
+ }
+ hr = Init();
}
HRESULT CMatroskaFile::Init()
{
- DWORD dw;
- if (FAILED(Read(dw)) || dw != 0x1A45DFA3) {
- return E_FAIL;
- }
+ DWORD dw;
+ if (FAILED(Read(dw)) || dw != 0x1A45DFA3) {
+ return E_FAIL;
+ }
- CMatroskaNode Root(this);
- if (FAILED(Parse(&Root))) {
- return E_FAIL;
- }
+ CMatroskaNode Root(this);
+ if (FAILED(Parse(&Root))) {
+ return E_FAIL;
+ }
- CAutoPtr<CMatroskaNode> pSegment, pCluster;
- if ((pSegment = Root.Child(0x18538067))
- && (pCluster = pSegment->Child(0x1F43B675))) {
- Cluster c0;
- c0.ParseTimeCode(pCluster);
- m_rtOffset = m_segment.GetRefTime(c0.TimeCode);
- }
+ CAutoPtr<CMatroskaNode> pSegment, pCluster;
+ if ((pSegment = Root.Child(0x18538067))
+ && (pCluster = pSegment->Child(0x1F43B675))) {
+ Cluster c0;
+ c0.ParseTimeCode(pCluster);
+ m_rtOffset = m_segment.GetRefTime(c0.TimeCode);
+ }
- return S_OK;
+ return S_OK;
}
template <class T>
HRESULT CMatroskaFile::Read(T& var)
{
- HRESULT hr = ByteRead((BYTE*)&var, sizeof(var));
- if (S_OK == hr) {
- bswap((BYTE*)&var, sizeof(var));
- }
- return hr;
+ HRESULT hr = ByteRead((BYTE*)&var, sizeof(var));
+ if (S_OK == hr) {
+ bswap((BYTE*)&var, sizeof(var));
+ }
+ return hr;
}
HRESULT CMatroskaFile::Parse(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0x1A45DFA3:
- m_ebml.Parse(pMN);
- if ((m_ebml.DocType != DOCTYPE || m_ebml.DocTypeReadVersion > DOCTYPEVERSION) && m_ebml.DocType != DOCTYPE_WEBM) {
- return E_FAIL;
- }
- break;
+ m_ebml.Parse(pMN);
+ if ((m_ebml.DocType != DOCTYPE || m_ebml.DocTypeReadVersion > DOCTYPEVERSION) && m_ebml.DocType != DOCTYPE_WEBM) {
+ return E_FAIL;
+ }
+ break;
case 0x18538067:
- if (m_segment.SegmentInfo.SegmentUID.IsEmpty()) {
- m_segment.ParseMinimal(pMN);
- }
- break;
- EndChunk
+ if (m_segment.SegmentInfo.SegmentUID.IsEmpty()) {
+ m_segment.ParseMinimal(pMN);
+ }
+ break;
+ EndChunk
}
//
HRESULT EBML::Parse(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0x4286:
- EBMLVersion.Parse(pMN);
- break;
+ EBMLVersion.Parse(pMN);
+ break;
case 0x42F7:
- EBMLReadVersion.Parse(pMN);
- break;
+ EBMLReadVersion.Parse(pMN);
+ break;
case 0x42F2:
- EBMLMaxIDLength.Parse(pMN);
- break;
+ EBMLMaxIDLength.Parse(pMN);
+ break;
case 0x42F3:
- EBMLMaxSizeLength.Parse(pMN);
- break;
+ EBMLMaxSizeLength.Parse(pMN);
+ break;
case 0x4282:
- DocType.Parse(pMN);
- break;
+ DocType.Parse(pMN);
+ break;
case 0x4287:
- DocTypeVersion.Parse(pMN);
- break;
+ DocTypeVersion.Parse(pMN);
+ break;
case 0x4285:
- DocTypeReadVersion.Parse(pMN);
- break;
- EndChunk
+ DocTypeReadVersion.Parse(pMN);
+ break;
+ EndChunk
}
HRESULT Segment::Parse(CMatroskaNode* pMN0)
{
- pos = pMN0->GetPos();
+ pos = pMN0->GetPos();
- BeginChunk
+ BeginChunk
case 0x1549A966:
- SegmentInfo.Parse(pMN);
- break;
+ SegmentInfo.Parse(pMN);
+ break;
case 0x114D9B74:
- MetaSeekInfo.Parse(pMN);
- break;
+ MetaSeekInfo.Parse(pMN);
+ break;
case 0x1654AE6B:
- Tracks.Parse(pMN);
- break;
+ Tracks.Parse(pMN);
+ break;
case 0x1F43B675:
- Clusters.Parse(pMN);
- break;
+ Clusters.Parse(pMN);
+ break;
case 0x1C53BB6B:
- Cues.Parse(pMN);
- break;
+ Cues.Parse(pMN);
+ break;
case 0x1941A469:
- Attachments.Parse(pMN);
- break;
+ Attachments.Parse(pMN);
+ break;
case 0x1043A770:
- Chapters.Parse(pMN);
- break;
- // case 0x1254C367: Tags.Parse(pMN); break;
- EndChunk
+ Chapters.Parse(pMN);
+ break;
+ // case 0x1254C367: Tags.Parse(pMN); break;
+ EndChunk
}
HRESULT Segment::ParseMinimal(CMatroskaNode* pMN0)
{
- CheckPointer(pMN0, E_POINTER);
-
- pos = pMN0->GetPos();
- len = pMN0->m_len;
-
- CAutoPtr<CMatroskaNode> pMN = pMN0->Child();
- if (!pMN) {
- return S_FALSE;
- }
-
- unsigned int k = 0;
-
- do {
- switch (pMN->m_id) {
- case 0x1549A966:
- SegmentInfo.Parse(pMN);
- k |= (1 << 0);
- break;
- case 0x114D9B74:
- MetaSeekInfo.Parse(pMN);
- k |= (1 << 1);
- break;
- case 0x1654AE6B:
- Tracks.Parse(pMN);
- k |= (1 << 2);
- break;
- case 0x1C53BB6B:
- k |= (1 << 3);
- Cues.Parse(pMN);
- break;
- }
- } while (k != 15 && pMN->m_id != 0x1F43B675 && pMN->Next());
-
- if (!pMN->IsRandomAccess()) {
- return S_OK;
- }
-
- while (MatroskaReader::QWORD pos = pMN->FindPos(0x114D9B74, pMN->GetPos())) {
- pMN->SeekTo(pos);
- if (FAILED(pMN->Parse())) {
- break; // a broken file
- }
- MetaSeekInfo.Parse(pMN);
- }
-
- if (k != 15) {
- if (Cues.IsEmpty() && (pMN = pMN0->Child(0x1C53BB6B, false))) {
- do {
- Cues.Parse(pMN);
- } while (pMN->Next(true));
- }
-
- if (Chapters.IsEmpty() && (pMN = pMN0->Child(0x1043A770, false))) {
- do {
- Chapters.Parse(pMN); /*BIG UGLY HACK:*/
- break;
- } while (pMN->Next(true));
- }
-
- if (Attachments.IsEmpty() && (pMN = pMN0->Child(0x1941A469, false))) {
- do {
- Attachments.Parse(pMN); /*BIG UGLY HACK:*/
- break;
- } while (pMN->Next(true));
- }
- }
-
- return S_OK;
+ CheckPointer(pMN0, E_POINTER);
+
+ pos = pMN0->GetPos();
+ len = pMN0->m_len;
+
+ CAutoPtr<CMatroskaNode> pMN = pMN0->Child();
+ if (!pMN) {
+ return S_FALSE;
+ }
+
+ unsigned int k = 0;
+
+ do {
+ switch (pMN->m_id) {
+ case 0x1549A966:
+ SegmentInfo.Parse(pMN);
+ k |= (1 << 0);
+ break;
+ case 0x114D9B74:
+ MetaSeekInfo.Parse(pMN);
+ k |= (1 << 1);
+ break;
+ case 0x1654AE6B:
+ Tracks.Parse(pMN);
+ k |= (1 << 2);
+ break;
+ case 0x1C53BB6B:
+ k |= (1 << 3);
+ Cues.Parse(pMN);
+ break;
+ }
+ } while (k != 15 && pMN->m_id != 0x1F43B675 && pMN->Next());
+
+ if (!pMN->IsRandomAccess()) {
+ return S_OK;
+ }
+
+ while (MatroskaReader::QWORD pos = pMN->FindPos(0x114D9B74, pMN->GetPos())) {
+ pMN->SeekTo(pos);
+ if (FAILED(pMN->Parse())) {
+ break; // a broken file
+ }
+ MetaSeekInfo.Parse(pMN);
+ }
+
+ if (k != 15) {
+ if (Cues.IsEmpty() && (pMN = pMN0->Child(0x1C53BB6B, false))) {
+ do {
+ Cues.Parse(pMN);
+ } while (pMN->Next(true));
+ }
+
+ if (Chapters.IsEmpty() && (pMN = pMN0->Child(0x1043A770, false))) {
+ do {
+ Chapters.Parse(pMN); /*BIG UGLY HACK:*/
+ break;
+ } while (pMN->Next(true));
+ }
+
+ if (Attachments.IsEmpty() && (pMN = pMN0->Child(0x1941A469, false))) {
+ do {
+ Attachments.Parse(pMN); /*BIG UGLY HACK:*/
+ break;
+ } while (pMN->Next(true));
+ }
+ }
+
+ return S_OK;
}
UINT64 Segment::GetMasterTrack()
{
- UINT64 TrackNumber = 0, AltTrackNumber = 0;
+ UINT64 TrackNumber = 0, AltTrackNumber = 0;
- POSITION pos1 = Tracks.GetHeadPosition();
- while (pos1 && TrackNumber == 0) {
- Track* pT = Tracks.GetNext(pos1);
+ POSITION pos1 = Tracks.GetHeadPosition();
+ while (pos1 && TrackNumber == 0) {
+ Track* pT = Tracks.GetNext(pos1);
- POSITION pos2 = pT->TrackEntries.GetHeadPosition();
- while (pos2 && TrackNumber == 0) {
- TrackEntry* pTE = pT->TrackEntries.GetNext(pos2);
+ POSITION pos2 = pT->TrackEntries.GetHeadPosition();
+ while (pos2 && TrackNumber == 0) {
+ TrackEntry* pTE = pT->TrackEntries.GetNext(pos2);
- if (pTE->TrackType == TrackEntry::TypeVideo) {
- TrackNumber = pTE->TrackNumber;
- break;
- } else if (pTE->TrackType == TrackEntry::TypeAudio && AltTrackNumber == 0) {
- AltTrackNumber = pTE->TrackNumber;
- }
- }
- }
+ if (pTE->TrackType == TrackEntry::TypeVideo) {
+ TrackNumber = pTE->TrackNumber;
+ break;
+ } else if (pTE->TrackType == TrackEntry::TypeAudio && AltTrackNumber == 0) {
+ AltTrackNumber = pTE->TrackNumber;
+ }
+ }
+ }
- if (TrackNumber == 0) {
- TrackNumber = AltTrackNumber;
- }
- if (TrackNumber == 0) {
- TrackNumber = 1;
- }
+ if (TrackNumber == 0) {
+ TrackNumber = AltTrackNumber;
+ }
+ if (TrackNumber == 0) {
+ TrackNumber = 1;
+ }
- return TrackNumber;
+ return TrackNumber;
}
ChapterAtom* ChapterAtom::FindChapterAtom(UINT64 id)
{
- if (ChapterUID == id) {
- return this;
- }
+ if (ChapterUID == id) {
+ return this;
+ }
- POSITION pos = ChapterAtoms.GetHeadPosition();
- while (pos) {
- ChapterAtom* ca = ChapterAtoms.GetNext(pos)->FindChapterAtom(id);
- if (ca) {
- return ca;
- }
- }
+ POSITION pos = ChapterAtoms.GetHeadPosition();
+ while (pos) {
+ ChapterAtom* ca = ChapterAtoms.GetNext(pos)->FindChapterAtom(id);
+ if (ca) {
+ return ca;
+ }
+ }
- return NULL;
+ return NULL;
}
ChapterAtom* Segment::FindChapterAtom(UINT64 id, int nEditionEntry)
{
- POSITION pos1 = Chapters.GetHeadPosition();
- while (pos1) {
- Chapter* c = Chapters.GetNext(pos1);
+ POSITION pos1 = Chapters.GetHeadPosition();
+ while (pos1) {
+ Chapter* c = Chapters.GetNext(pos1);
- POSITION pos2 = c->EditionEntries.GetHeadPosition();
- while (pos2) {
- EditionEntry* ee = c->EditionEntries.GetNext(pos2);
+ POSITION pos2 = c->EditionEntries.GetHeadPosition();
+ while (pos2) {
+ EditionEntry* ee = c->EditionEntries.GetNext(pos2);
- if (nEditionEntry-- == 0) {
- return id == 0 ? ee : ee->FindChapterAtom(id);
- }
- }
- }
+ if (nEditionEntry-- == 0) {
+ return id == 0 ? ee : ee->FindChapterAtom(id);
+ }
+ }
+ }
- return NULL;
+ return NULL;
}
HRESULT Info::Parse(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0x73A4:
- SegmentUID.Parse(pMN);
- break;
+ SegmentUID.Parse(pMN);
+ break;
case 0x7384:
- SegmentFilename.Parse(pMN);
- break;
+ SegmentFilename.Parse(pMN);
+ break;
case 0x3CB923:
- PrevUID.Parse(pMN);
- break;
+ PrevUID.Parse(pMN);
+ break;
case 0x3C83AB:
- PrevFilename.Parse(pMN);
- break;
+ PrevFilename.Parse(pMN);
+ break;
case 0x3EB923:
- NextUID.Parse(pMN);
- break;
+ NextUID.Parse(pMN);
+ break;
case 0x3E83BB:
- NextFilename.Parse(pMN);
- break;
+ NextFilename.Parse(pMN);
+ break;
case 0x2AD7B1:
- TimeCodeScale.Parse(pMN);
- break;
+ TimeCodeScale.Parse(pMN);
+ break;
case 0x4489:
- Duration.Parse(pMN);
- break;
+ Duration.Parse(pMN);
+ break;
case 0x4461:
- DateUTC.Parse(pMN);
- break;
+ DateUTC.Parse(pMN);
+ break;
case 0x7BA9:
- Title.Parse(pMN);
- break;
+ Title.Parse(pMN);
+ break;
case 0x4D80:
- MuxingApp.Parse(pMN);
- break;
+ MuxingApp.Parse(pMN);
+ break;
case 0x5741:
- WritingApp.Parse(pMN);
- break;
- EndChunk
+ WritingApp.Parse(pMN);
+ break;
+ EndChunk
}
HRESULT Seek::Parse(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0x4DBB:
- SeekHeads.Parse(pMN);
- break;
- EndChunk
+ SeekHeads.Parse(pMN);
+ break;
+ EndChunk
}
HRESULT SeekHead::Parse(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0x53AB:
- SeekID.Parse(pMN);
- break;
+ SeekID.Parse(pMN);
+ break;
case 0x53AC:
- SeekPosition.Parse(pMN);
- break;
- EndChunk
+ SeekPosition.Parse(pMN);
+ break;
+ EndChunk
}
HRESULT Track::Parse(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0xAE:
- TrackEntries.Parse(pMN);
- break;
- EndChunk
+ TrackEntries.Parse(pMN);
+ break;
+ EndChunk
}
HRESULT TrackEntry::Parse(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0xD7:
- TrackNumber.Parse(pMN);
- break;
+ TrackNumber.Parse(pMN);
+ break;
case 0x73C5:
- TrackUID.Parse(pMN);
- break;
+ TrackUID.Parse(pMN);
+ break;
case 0x83:
- TrackType.Parse(pMN);
- break;
+ TrackType.Parse(pMN);
+ break;
case 0xB9:
- FlagEnabled.Parse(pMN);
- break;
+ FlagEnabled.Parse(pMN);
+ break;
case 0x88:
- FlagDefault.Parse(pMN);
- break;
+ FlagDefault.Parse(pMN);
+ break;
case 0x9C:
- FlagLacing.Parse(pMN);
- break;
+ FlagLacing.Parse(pMN);
+ break;
case 0x55AA:
- FlagForced.Parse(pMN);
- break;
+ FlagForced.Parse(pMN);
+ break;
case 0x6DE7:
- MinCache.Parse(pMN);
- break;
+ MinCache.Parse(pMN);
+ break;
case 0x6DF8:
- MaxCache.Parse(pMN);
- break;
+ MaxCache.Parse(pMN);
+ break;
case 0x536E:
- Name.Parse(pMN);
- break;
+ Name.Parse(pMN);
+ break;
case 0x22B59C:
- Language.Parse(pMN);
- break;
+ Language.Parse(pMN);
+ break;
case 0x86:
- CodecID.Parse(pMN);
- break;
+ CodecID.Parse(pMN);
+ break;
case 0x63A2:
- CodecPrivate.Parse(pMN);
- break;
+ CodecPrivate.Parse(pMN);
+ break;
case 0x258688:
- CodecName.Parse(pMN);
- break;
+ CodecName.Parse(pMN);
+ break;
case 0x3A9697:
- CodecSettings.Parse(pMN);
- break;
+ CodecSettings.Parse(pMN);
+ break;
case 0x3B4040:
- CodecInfoURL.Parse(pMN);
- break;
+ CodecInfoURL.Parse(pMN);
+ break;
case 0x26B240:
- CodecDownloadURL.Parse(pMN);
- break;
+ CodecDownloadURL.Parse(pMN);
+ break;
case 0xAA:
- CodecDecodeAll.Parse(pMN);
- break;
+ CodecDecodeAll.Parse(pMN);
+ break;
case 0x6FAB:
- TrackOverlay.Parse(pMN);
- break;
+ TrackOverlay.Parse(pMN);
+ break;
case 0x23E383:
case 0x2383E3:
- DefaultDuration.Parse(pMN);
- break;
+ DefaultDuration.Parse(pMN);
+ break;
case 0x23314F:
- TrackTimecodeScale.Parse(pMN);
- break;
+ TrackTimecodeScale.Parse(pMN);
+ break;
case 0xE0:
- if (S_OK == v.Parse(pMN)) {
- DescType |= DescVideo;
- }
- break;
+ if (S_OK == v.Parse(pMN)) {
+ DescType |= DescVideo;
+ }
+ break;
case 0xE1:
- if (S_OK == a.Parse(pMN)) {
- DescType |= DescAudio;
- }
- break;
+ if (S_OK == a.Parse(pMN)) {
+ DescType |= DescAudio;
+ }
+ break;
case 0x6D80:
- ces.Parse(pMN);
- break;
- EndChunk
+ ces.Parse(pMN);
+ break;
+ EndChunk
}
static int cesort(const void* a, const void* b)
{
- UINT64 ce1 = (static_cast<ContentEncoding*>(const_cast<void *>(a)))->ContentEncodingOrder;
- UINT64 ce2 = (static_cast<ContentEncoding*>(const_cast<void *>(b)))->ContentEncodingOrder;
+ UINT64 ce1 = (static_cast<ContentEncoding*>(const_cast<void*>(a)))->ContentEncodingOrder;
+ UINT64 ce2 = (static_cast<ContentEncoding*>(const_cast<void*>(b)))->ContentEncodingOrder;
- return (int)ce1 - (int)ce2;
+ return (int)ce1 - (int)ce2;
}
bool TrackEntry::Expand(CBinary& data, UINT64 Scope)
{
- if (ces.ce.GetCount() == 0) {
- return true;
- }
+ if (ces.ce.GetCount() == 0) {
+ return true;
+ }
- CAtlArray<ContentEncoding*> cearray;
- POSITION pos = ces.ce.GetHeadPosition();
- while (pos) {
- cearray.Add(ces.ce.GetNext(pos));
- }
- qsort(cearray.GetData(), cearray.GetCount(), sizeof(ContentEncoding*), cesort);
+ CAtlArray<ContentEncoding*> cearray;
+ POSITION pos = ces.ce.GetHeadPosition();
+ while (pos) {
+ cearray.Add(ces.ce.GetNext(pos));
+ }
+ qsort(cearray.GetData(), cearray.GetCount(), sizeof(ContentEncoding*), cesort);
- for (int i = (int)cearray.GetCount()-1; i >= 0; i--) {
- ContentEncoding* ce = cearray[i];
+ for (int i = (int)cearray.GetCount() - 1; i >= 0; i--) {
+ ContentEncoding* ce = cearray[i];
- if (!(ce->ContentEncodingScope & Scope)) {
- continue;
- }
+ if (!(ce->ContentEncodingScope & Scope)) {
+ continue;
+ }
- if (ce->ContentEncodingType == ContentEncoding::Compression) {
- if (!data.Decompress(ce->cc)) {
- return false;
- }
- } else if (ce->ContentEncodingType == ContentEncoding::Encryption) {
- // TODO
- return false;
- }
- }
+ if (ce->ContentEncodingType == ContentEncoding::Compression) {
+ if (!data.Decompress(ce->cc)) {
+ return false;
+ }
+ } else if (ce->ContentEncodingType == ContentEncoding::Encryption) {
+ // TODO
+ return false;
+ }
+ }
- return true;
+ return true;
}
HRESULT Video::Parse(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0x9A:
- FlagInterlaced.Parse(pMN);
- break;
+ FlagInterlaced.Parse(pMN);
+ break;
case 0x53B8:
- StereoMode.Parse(pMN);
- break;
+ StereoMode.Parse(pMN);
+ break;
case 0xB0:
- PixelWidth.Parse(pMN);
- if (!DisplayWidth) {
- DisplayWidth.Set(PixelWidth);
- }
- break;
+ PixelWidth.Parse(pMN);
+ if (!DisplayWidth) {
+ DisplayWidth.Set(PixelWidth);
+ }
+ break;
case 0xBA:
- PixelHeight.Parse(pMN);
- if (!DisplayHeight) {
- DisplayHeight.Set(PixelHeight);
- }
- break;
+ PixelHeight.Parse(pMN);
+ if (!DisplayHeight) {
+ DisplayHeight.Set(PixelHeight);
+ }
+ break;
case 0x54B0:
- DisplayWidth.Parse(pMN);
- break;
+ DisplayWidth.Parse(pMN);
+ break;
case 0x54BA:
- DisplayHeight.Parse(pMN);
- break;
+ DisplayHeight.Parse(pMN);
+ break;
case 0x54B2:
- DisplayUnit.Parse(pMN);
- break;
+ DisplayUnit.Parse(pMN);
+ break;
case 0x54B3:
- AspectRatioType.Parse(pMN);
- break;
+ AspectRatioType.Parse(pMN);
+ break;
case 0x54AA:
- VideoPixelCropBottom.Parse(pMN);
- break;
+ VideoPixelCropBottom.Parse(pMN);
+ break;
case 0x54BB:
- VideoPixelCropTop.Parse(pMN);
- break;
+ VideoPixelCropTop.Parse(pMN);
+ break;
case 0x54CC:
- VideoPixelCropLeft.Parse(pMN);
- break;
+ VideoPixelCropLeft.Parse(pMN);
+ break;
case 0x54DD:
- VideoPixelCropRight.Parse(pMN);
- break;
+ VideoPixelCropRight.Parse(pMN);
+ break;
case 0x2EB524:
- ColourSpace.Parse(pMN);
- break;
+ ColourSpace.Parse(pMN);
+ break;
case 0x2FB523:
- GammaValue.Parse(pMN);
- break;
+ GammaValue.Parse(pMN);
+ break;
case 0x2383E3:
- FramePerSec.Parse(pMN);
- break;
- EndChunk
+ FramePerSec.Parse(pMN);
+ break;
+ EndChunk
}
HRESULT Audio::Parse(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0xB5:
- SamplingFrequency.Parse(pMN);
- if (!OutputSamplingFrequency) {
- OutputSamplingFrequency.Set(SamplingFrequency);
- }
- break;
+ SamplingFrequency.Parse(pMN);
+ if (!OutputSamplingFrequency) {
+ OutputSamplingFrequency.Set(SamplingFrequency);
+ }
+ break;
case 0x78B5:
- OutputSamplingFrequency.Parse(pMN);
- break;
+ OutputSamplingFrequency.Parse(pMN);
+ break;
case 0x9F:
- Channels.Parse(pMN);
- break;
+ Channels.Parse(pMN);
+ break;
case 0x7D7B:
- ChannelPositions.Parse(pMN);
- break;
+ ChannelPositions.Parse(pMN);
+ break;
case 0x6264:
- BitDepth.Parse(pMN);
- break;
- EndChunk
+ BitDepth.Parse(pMN);
+ break;
+ EndChunk
}
HRESULT ContentEncodings::Parse(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0x6240:
- ce.Parse(pMN);
- break;
- EndChunk
+ ce.Parse(pMN);
+ break;
+ EndChunk
}
HRESULT ContentEncoding::Parse(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0x5031:
- ContentEncodingOrder.Parse(pMN);
- break;
+ ContentEncodingOrder.Parse(pMN);
+ break;
case 0x5032:
- ContentEncodingScope.Parse(pMN);
- break;
+ ContentEncodingScope.Parse(pMN);
+ break;
case 0x5033:
- ContentEncodingType.Parse(pMN);
- break;
+ ContentEncodingType.Parse(pMN);
+ break;
case 0x5034:
- cc.Parse(pMN);
- break;
+ cc.Parse(pMN);
+ break;
case 0x5035:
- ce.Parse(pMN);
- break;
- EndChunk
+ ce.Parse(pMN);
+ break;
+ EndChunk
}
HRESULT ContentCompression::Parse(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0x4254:
- ContentCompAlgo.Parse(pMN);
- break;
+ ContentCompAlgo.Parse(pMN);
+ break;
case 0x4255:
- ContentCompSettings.Parse(pMN);
- break;
- EndChunk
+ ContentCompSettings.Parse(pMN);
+ break;
+ EndChunk
}
HRESULT ContentEncryption::Parse(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0x47e1:
- ContentEncAlgo.Parse(pMN);
- break;
+ ContentEncAlgo.Parse(pMN);
+ break;
case 0x47e2:
- ContentEncKeyID.Parse(pMN);
- break;
+ ContentEncKeyID.Parse(pMN);
+ break;
case 0x47e3:
- ContentSignature.Parse(pMN);
- break;
+ ContentSignature.Parse(pMN);
+ break;
case 0x47e4:
- ContentSigKeyID.Parse(pMN);
- break;
+ ContentSigKeyID.Parse(pMN);
+ break;
case 0x47e5:
- ContentSigAlgo.Parse(pMN);
- break;
+ ContentSigAlgo.Parse(pMN);
+ break;
case 0x47e6:
- ContentSigHashAlgo.Parse(pMN);
- break;
- EndChunk
+ ContentSigHashAlgo.Parse(pMN);
+ break;
+ EndChunk
}
HRESULT Cluster::Parse(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0xE7:
- TimeCode.Parse(pMN);
- break;
+ TimeCode.Parse(pMN);
+ break;
case 0xA7:
- Position.Parse(pMN);
- break;
+ Position.Parse(pMN);
+ break;
case 0xAB:
- PrevSize.Parse(pMN);
- break;
+ PrevSize.Parse(pMN);
+ break;
case 0xA0:
- BlockGroups.Parse(pMN, true);
- break;
+ BlockGroups.Parse(pMN, true);
+ break;
case 0xA3:
- SimpleBlocks.Parse(pMN, true);
- break;
- EndChunk
+ SimpleBlocks.Parse(pMN, true);
+ break;
+ EndChunk
}
HRESULT Cluster::ParseTimeCode(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0xE7:
- TimeCode.Parse(pMN);
- return S_OK;
- EndChunk
+ TimeCode.Parse(pMN);
+ return S_OK;
+ EndChunk
}
HRESULT BlockGroup::Parse(CMatroskaNode* pMN0, bool fFull)
{
- BeginChunk
+ BeginChunk
case 0xA1:
- Block.Parse(pMN, fFull);
- break;
+ Block.Parse(pMN, fFull);
+ break;
case 0xA2: /* TODO: multiple virt blocks? */
- ;
- break;
+ ;
+ break;
case 0x9B:
- BlockDuration.Parse(pMN);
- break;
+ BlockDuration.Parse(pMN);
+ break;
case 0xFA:
- ReferencePriority.Parse(pMN);
- break;
+ ReferencePriority.Parse(pMN);
+ break;
case 0xFB:
- ReferenceBlock.Parse(pMN);
- break;
+ ReferenceBlock.Parse(pMN);
+ break;
case 0xFD:
- ReferenceVirtual.Parse(pMN);
- break;
+ ReferenceVirtual.Parse(pMN);
+ break;
case 0xA4:
- CodecState.Parse(pMN);
- break;
+ CodecState.Parse(pMN);
+ break;
case 0xE8:
- TimeSlices.Parse(pMN);
- break;
+ TimeSlices.Parse(pMN);
+ break;
case 0x75A1:
- if (fFull) {
- ba.Parse(pMN);
- }
- break;
- EndChunk
+ if (fFull) {
+ ba.Parse(pMN);
+ }
+ break;
+ EndChunk
}
HRESULT SimpleBlock::Parse(CMatroskaNode* pMN, bool fFull)
{
- pMN->SeekTo(pMN->m_start);
-
- TrackNumber.Parse(pMN);
- CShort s;
- s.Parse(pMN);
- TimeCode.Set(s);
- Lacing.Parse(pMN);
-
- if (!fFull) {
- return S_OK;
- }
-
- CAtlList<MatroskaReader::QWORD> lens;
- MatroskaReader::QWORD tlen = 0;
- MatroskaReader::QWORD FrameSize;
- BYTE FramesInLaceLessOne;
-
- switch ((Lacing & 0x06) >> 1) {
- case 0:
- // No lacing
- lens.AddTail((pMN->m_start+pMN->m_len) - (pMN->GetPos()+tlen));
- break;
- case 1:
- // Xiph lacing
- BYTE n;
- pMN->Read(n);
- while (n-- > 0) {
- BYTE b;
- MatroskaReader::QWORD len = 0;
- do {
- pMN->Read(b);
- len += b;
- } while (b == 0xff);
- lens.AddTail(len);
- tlen += len;
- }
- lens.AddTail((pMN->m_start+pMN->m_len) - (pMN->GetPos()+tlen));
- break;
- case 2:
- // Fixed-size lacing
- pMN->Read(FramesInLaceLessOne);
- FramesInLaceLessOne++;
- FrameSize = ((pMN->m_start+pMN->m_len) - (pMN->GetPos()+tlen)) / FramesInLaceLessOne;
- while (FramesInLaceLessOne-- > 0) {
- lens.AddTail(FrameSize);
- }
- break;
- case 3:
- // EBML lacing
- pMN->Read(FramesInLaceLessOne);
-
- CLength FirstFrameSize;
- FirstFrameSize.Parse(pMN);
- lens.AddTail(FirstFrameSize);
- FramesInLaceLessOne--;
- tlen = FirstFrameSize;
-
- CSignedLength DiffSize;
- FrameSize = FirstFrameSize;
- while (FramesInLaceLessOne--) {
- DiffSize.Parse(pMN);
- FrameSize += DiffSize;
- lens.AddTail(FrameSize);
- tlen += FrameSize;
- }
- lens.AddTail((pMN->m_start+pMN->m_len) - (pMN->GetPos()+tlen));
- break;
- }
-
- POSITION pos = lens.GetHeadPosition();
- while (pos) {
- MatroskaReader::QWORD len = lens.GetNext(pos);
- CAutoPtr<CBinary> p(DNew CBinary());
- p->SetCount((INT_PTR)len);
- pMN->Read(p->GetData(), len);
- BlockData.AddTail(p);
- }
-
- return S_OK;
+ pMN->SeekTo(pMN->m_start);
+
+ TrackNumber.Parse(pMN);
+ CShort s;
+ s.Parse(pMN);
+ TimeCode.Set(s);
+ Lacing.Parse(pMN);
+
+ if (!fFull) {
+ return S_OK;
+ }
+
+ CAtlList<MatroskaReader::QWORD> lens;
+ MatroskaReader::QWORD tlen = 0;
+ MatroskaReader::QWORD FrameSize;
+ BYTE FramesInLaceLessOne;
+
+ switch ((Lacing & 0x06) >> 1) {
+ case 0:
+ // No lacing
+ lens.AddTail((pMN->m_start + pMN->m_len) - (pMN->GetPos() + tlen));
+ break;
+ case 1:
+ // Xiph lacing
+ BYTE n;
+ pMN->Read(n);
+ while (n-- > 0) {
+ BYTE b;
+ MatroskaReader::QWORD len = 0;
+ do {
+ pMN->Read(b);
+ len += b;
+ } while (b == 0xff);
+ lens.AddTail(len);
+ tlen += len;
+ }
+ lens.AddTail((pMN->m_start + pMN->m_len) - (pMN->GetPos() + tlen));
+ break;
+ case 2:
+ // Fixed-size lacing
+ pMN->Read(FramesInLaceLessOne);
+ FramesInLaceLessOne++;
+ FrameSize = ((pMN->m_start + pMN->m_len) - (pMN->GetPos() + tlen)) / FramesInLaceLessOne;
+ while (FramesInLaceLessOne-- > 0) {
+ lens.AddTail(FrameSize);
+ }
+ break;
+ case 3:
+ // EBML lacing
+ pMN->Read(FramesInLaceLessOne);
+
+ CLength FirstFrameSize;
+ FirstFrameSize.Parse(pMN);
+ lens.AddTail(FirstFrameSize);
+ FramesInLaceLessOne--;
+ tlen = FirstFrameSize;
+
+ CSignedLength DiffSize;
+ FrameSize = FirstFrameSize;
+ while (FramesInLaceLessOne--) {
+ DiffSize.Parse(pMN);
+ FrameSize += DiffSize;
+ lens.AddTail(FrameSize);
+ tlen += FrameSize;
+ }
+ lens.AddTail((pMN->m_start + pMN->m_len) - (pMN->GetPos() + tlen));
+ break;
+ }
+
+ POSITION pos = lens.GetHeadPosition();
+ while (pos) {
+ MatroskaReader::QWORD len = lens.GetNext(pos);
+ CAutoPtr<CBinary> p(DNew CBinary());
+ p->SetCount((INT_PTR)len);
+ pMN->Read(p->GetData(), len);
+ BlockData.AddTail(p);
+ }
+
+ return S_OK;
}
HRESULT BlockAdditions::Parse(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0xA6:
- bm.Parse(pMN);
- break;
- EndChunk
+ bm.Parse(pMN);
+ break;
+ EndChunk
}
HRESULT BlockMore::Parse(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0xEE:
- BlockAddID.Parse(pMN);
- break;
+ BlockAddID.Parse(pMN);
+ break;
case 0xA5:
- BlockAdditional.Parse(pMN);
- break;
- EndChunk
+ BlockAdditional.Parse(pMN);
+ break;
+ EndChunk
}
HRESULT TimeSlice::Parse(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0xCC:
- LaceNumber.Parse(pMN);
- break;
+ LaceNumber.Parse(pMN);
+ break;
case 0xCD:
- FrameNumber.Parse(pMN);
- break;
+ FrameNumber.Parse(pMN);
+ break;
case 0xCE:
- Delay.Parse(pMN);
- break;
+ Delay.Parse(pMN);
+ break;
case 0xCF:
- Duration.Parse(pMN);
- break;
- EndChunk
+ Duration.Parse(pMN);
+ break;
+ EndChunk
}
HRESULT Cue::Parse(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0xBB:
- CuePoints.Parse(pMN);
- break;
- EndChunk
+ CuePoints.Parse(pMN);
+ break;
+ EndChunk
}
HRESULT CuePoint::Parse(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0xB3:
- CueTime.Parse(pMN);
- break;
+ CueTime.Parse(pMN);
+ break;
case 0xB7:
- CueTrackPositions.Parse(pMN);
- break;
- EndChunk
+ CueTrackPositions.Parse(pMN);
+ break;
+ EndChunk
}
HRESULT CueTrackPosition::Parse(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0xF7:
- CueTrack.Parse(pMN);
- break;
+ CueTrack.Parse(pMN);
+ break;
case 0xF1:
- CueClusterPosition.Parse(pMN);
- break;
+ CueClusterPosition.Parse(pMN);
+ break;
case 0x5387:
- CueBlockNumber.Parse(pMN);
- break;
+ CueBlockNumber.Parse(pMN);
+ break;
case 0xEA:
- CueCodecState.Parse(pMN);
- break;
+ CueCodecState.Parse(pMN);
+ break;
case 0xDB:
- CueReferences.Parse(pMN);
- break;
- EndChunk
+ CueReferences.Parse(pMN);
+ break;
+ EndChunk
}
HRESULT CueReference::Parse(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0x96:
- CueRefTime.Parse(pMN);
- break;
+ CueRefTime.Parse(pMN);
+ break;
case 0x97:
- CueRefCluster.Parse(pMN);
- break;
+ CueRefCluster.Parse(pMN);
+ break;
case 0x535F:
- CueRefNumber.Parse(pMN);
- break;
+ CueRefNumber.Parse(pMN);
+ break;
case 0xEB:
- CueRefCodecState.Parse(pMN);
- break;
- EndChunk
+ CueRefCodecState.Parse(pMN);
+ break;
+ EndChunk
}
HRESULT Attachment::Parse(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0x61A7:
- AttachedFiles.Parse(pMN);
- break;
- EndChunk
+ AttachedFiles.Parse(pMN);
+ break;
+ EndChunk
}
HRESULT AttachedFile::Parse(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0x467E:
- FileDescription.Parse(pMN);
- break;
+ FileDescription.Parse(pMN);
+ break;
case 0x466E:
- FileName.Parse(pMN);
- break;
+ FileName.Parse(pMN);
+ break;
case 0x4660:
- FileMimeType.Parse(pMN);
- break;
+ FileMimeType.Parse(pMN);
+ break;
case 0x465C: // binary
- FileDataLen = (INT_PTR)pMN->m_len;
- FileDataPos = pMN->m_start;
- break;
+ FileDataLen = (INT_PTR)pMN->m_len;
+ FileDataPos = pMN->m_start;
+ break;
case 0x46AE:
- FileUID.Parse(pMN);
- break;
- EndChunk
+ FileUID.Parse(pMN);
+ break;
+ EndChunk
}
HRESULT Chapter::Parse(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0x45B9:
- EditionEntries.Parse(pMN);
- break;
- EndChunk
+ EditionEntries.Parse(pMN);
+ break;
+ EndChunk
}
HRESULT EditionEntry::Parse(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0xB6:
- ChapterAtoms.Parse(pMN);
- break;
- EndChunk
+ ChapterAtoms.Parse(pMN);
+ break;
+ EndChunk
}
HRESULT ChapterAtom::Parse(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0x73C4:
- ChapterUID.Parse(pMN);
- break;
+ ChapterUID.Parse(pMN);
+ break;
case 0x91:
- ChapterTimeStart.Parse(pMN);
- break;
+ ChapterTimeStart.Parse(pMN);
+ break;
case 0x92:
- ChapterTimeEnd.Parse(pMN);
- break;
- // case 0x8F: // TODO
+ ChapterTimeEnd.Parse(pMN);
+ break;
+ // case 0x8F: // TODO
case 0x80:
- ChapterDisplays.Parse(pMN);
- break;
+ ChapterDisplays.Parse(pMN);
+ break;
case 0xB6:
- ChapterAtoms.Parse(pMN);
- break;
+ ChapterAtoms.Parse(pMN);
+ break;
case 0x98:
- ChapterFlagHidden.Parse(pMN);
- break;
+ ChapterFlagHidden.Parse(pMN);
+ break;
case 0x4598:
- ChapterFlagEnabled.Parse(pMN);
- break;
- EndChunk
+ ChapterFlagEnabled.Parse(pMN);
+ break;
+ EndChunk
}
HRESULT ChapterDisplay::Parse(CMatroskaNode* pMN0)
{
- BeginChunk
+ BeginChunk
case 0x85:
- ChapString.Parse(pMN);
- break;
+ ChapString.Parse(pMN);
+ break;
case 0x437C:
- ChapLanguage.Parse(pMN);
- break;
+ ChapLanguage.Parse(pMN);
+ break;
case 0x437E:
- ChapCountry.Parse(pMN);
- break;
- EndChunk
+ ChapCountry.Parse(pMN);
+ break;
+ EndChunk
}
//
HRESULT CBinary::Parse(CMatroskaNode* pMN)
{
- ASSERT(pMN->m_len <= INT_MAX);
- SetCount((INT_PTR)pMN->m_len);
- return pMN->Read(GetData(), pMN->m_len);
+ ASSERT(pMN->m_len <= INT_MAX);
+ SetCount((INT_PTR)pMN->m_len);
+ return pMN->Read(GetData(), pMN->m_len);
}
bool CBinary::Compress(ContentCompression& cc)
{
- if (cc.ContentCompAlgo == ContentCompression::ZLIB) {
- int res;
- z_stream c_stream;
+ if (cc.ContentCompAlgo == ContentCompression::ZLIB) {
+ int res;
+ z_stream c_stream;
- c_stream.zalloc = (alloc_func)0;
- c_stream.zfree = (free_func)0;
- c_stream.opaque = (voidpf)0;
+ c_stream.zalloc = (alloc_func)0;
+ c_stream.zfree = (free_func)0;
+ c_stream.opaque = (voidpf)0;
- if (Z_OK != (res = deflateInit(&c_stream, 9))) {
- return false;
- }
+ if (Z_OK != (res = deflateInit(&c_stream, 9))) {
+ return false;
+ }
- c_stream.next_in = GetData();
- c_stream.avail_in = (uInt)GetCount();
+ c_stream.next_in = GetData();
+ c_stream.avail_in = (uInt)GetCount();
- BYTE* dst = NULL;
- int n = 0;
- do {
- dst = (BYTE*)realloc(dst, ++n*10);
- c_stream.next_out = &dst[(n-1)*10];
- c_stream.avail_out = 10;
- if (Z_OK != (res = deflate(&c_stream, Z_FINISH)) && Z_STREAM_END != res) {
- free(dst);
- return false;
- }
- } while (0 == c_stream.avail_out && Z_STREAM_END != res);
+ BYTE* dst = NULL;
+ int n = 0;
+ do {
+ dst = (BYTE*)realloc(dst, ++n * 10);
+ c_stream.next_out = &dst[(n - 1) * 10];
+ c_stream.avail_out = 10;
+ if (Z_OK != (res = deflate(&c_stream, Z_FINISH)) && Z_STREAM_END != res) {
+ free(dst);
+ return false;
+ }
+ } while (0 == c_stream.avail_out && Z_STREAM_END != res);
- deflateEnd(&c_stream);
+ deflateEnd(&c_stream);
- SetCount(c_stream.total_out);
- memcpy(GetData(), dst, GetCount());
+ SetCount(c_stream.total_out);
+ memcpy(GetData(), dst, GetCount());
- free(dst);
+ free(dst);
- return true;
- }
+ return true;
+ }
- return false;
+ return false;
}
bool CBinary::Decompress(ContentCompression& cc)
{
- if (cc.ContentCompAlgo == ContentCompression::ZLIB) {
- int res;
- z_stream d_stream;
+ if (cc.ContentCompAlgo == ContentCompression::ZLIB) {
+ int res;
+ z_stream d_stream;
- d_stream.zalloc = (alloc_func)0;
- d_stream.zfree = (free_func)0;
- d_stream.opaque = (voidpf)0;
+ d_stream.zalloc = (alloc_func)0;
+ d_stream.zfree = (free_func)0;
+ d_stream.opaque = (voidpf)0;
- if (Z_OK != (res = inflateInit(&d_stream))) {
- return false;
- }
+ if (Z_OK != (res = inflateInit(&d_stream))) {
+ return false;
+ }
- d_stream.next_in = GetData();
- d_stream.avail_in = (uInt)GetCount();
+ d_stream.next_in = GetData();
+ d_stream.avail_in = (uInt)GetCount();
- BYTE* dst = NULL;
- int n = 0;
- do {
- dst = (unsigned char *)realloc(dst, ++n*1000);
- d_stream.next_out = &dst[(n-1)*1000];
- d_stream.avail_out = 1000;
- if (Z_OK != (res = inflate(&d_stream, Z_NO_FLUSH)) && Z_STREAM_END != res) {
- free(dst);
- return false;
- }
- } while (0 == d_stream.avail_out && 0 != d_stream.avail_in && Z_STREAM_END != res);
+ BYTE* dst = NULL;
+ int n = 0;
+ do {
+ dst = (unsigned char*)realloc(dst, ++n * 1000);
+ d_stream.next_out = &dst[(n - 1) * 1000];
+ d_stream.avail_out = 1000;
+ if (Z_OK != (res = inflate(&d_stream, Z_NO_FLUSH)) && Z_STREAM_END != res) {
+ free(dst);
+ return false;
+ }
+ } while (0 == d_stream.avail_out && 0 != d_stream.avail_in && Z_STREAM_END != res);
- inflateEnd(&d_stream);
+ inflateEnd(&d_stream);
- SetCount(d_stream.total_out);
- memcpy(GetData(), dst, GetCount());
+ SetCount(d_stream.total_out);
+ memcpy(GetData(), dst, GetCount());
- free(dst);
+ free(dst);
- return true;
- } else if (cc.ContentCompAlgo == ContentCompression::HDRSTRIP) {
- InsertArrayAt(0, &cc.ContentCompSettings);
- }
+ return true;
+ } else if (cc.ContentCompAlgo == ContentCompression::HDRSTRIP) {
+ InsertArrayAt(0, &cc.ContentCompSettings);
+ }
- return false;
+ return false;
}
HRESULT CANSI::Parse(CMatroskaNode* pMN)
{
- Empty();
+ Empty();
- MatroskaReader::QWORD len = pMN->m_len;
- CHAR c;
- while (len-- > 0 && SUCCEEDED(pMN->Read(c))) {
- *this += c;
- }
+ MatroskaReader::QWORD len = pMN->m_len;
+ CHAR c;
+ while (len-- > 0 && SUCCEEDED(pMN->Read(c))) {
+ *this += c;
+ }
- return (len == -1 ? S_OK : E_FAIL);
+ return (len == -1 ? S_OK : E_FAIL);
}
HRESULT CUTF8::Parse(CMatroskaNode* pMN)
{
- Empty();
- CAutoVectorPtr<BYTE> buff;
- if (!buff.Allocate((UINT)pMN->m_len + 1) || S_OK != pMN->Read(buff, pMN->m_len)) {
- return E_FAIL;
- }
- buff[pMN->m_len] = 0;
- CStringW::operator = (UTF8To16((LPCSTR)(BYTE*)buff));
- return S_OK;
+ Empty();
+ CAutoVectorPtr<BYTE> buff;
+ if (!buff.Allocate((UINT)pMN->m_len + 1) || S_OK != pMN->Read(buff, pMN->m_len)) {
+ return E_FAIL;
+ }
+ buff[pMN->m_len] = 0;
+ CStringW::operator = (UTF8To16((LPCSTR)(BYTE*)buff));
+ return S_OK;
}
HRESULT CUInt::Parse(CMatroskaNode* pMN)
{
- m_val = 0;
- for (int i = 0; i < (int)pMN->m_len; i++) {
- m_val <<= 8;
- HRESULT hr = pMN->Read(*(BYTE*)&m_val);
- if (FAILED(hr)) {
- return hr;
- }
- }
- m_fValid = true;
- return S_OK;
+ m_val = 0;
+ for (int i = 0; i < (int)pMN->m_len; i++) {
+ m_val <<= 8;
+ HRESULT hr = pMN->Read(*(BYTE*)&m_val);
+ if (FAILED(hr)) {
+ return hr;
+ }
+ }
+ m_fValid = true;
+ return S_OK;
}
HRESULT CInt::Parse(CMatroskaNode* pMN)
{
- m_val = 0;
- for (int i = 0; i < (int)pMN->m_len; i++) {
- HRESULT hr = pMN->Read(*((BYTE*)&m_val+7-i));
- if (FAILED(hr)) {
- return hr;
- }
- }
- m_val >>= (8-pMN->m_len)*8;
- m_fValid = true;
- return S_OK;
+ m_val = 0;
+ for (int i = 0; i < (int)pMN->m_len; i++) {
+ HRESULT hr = pMN->Read(*((BYTE*)&m_val + 7 - i));
+ if (FAILED(hr)) {
+ return hr;
+ }
+ }
+ m_val >>= (8 - pMN->m_len) * 8;
+ m_fValid = true;
+ return S_OK;
}
HRESULT CFloat::Parse(CMatroskaNode* pMN)
{
- HRESULT hr = E_FAIL;
- m_val = 0;
+ HRESULT hr = E_FAIL;
+ m_val = 0;
- if (pMN->m_len == 4) {
- float val = 0;
- hr = pMN->Read(val);
- m_val = val;
- } else if (pMN->m_len == 8) {
- hr = pMN->Read(m_val);
- }
- if (SUCCEEDED(hr)) {
- m_fValid = true;
- }
- return hr;
+ if (pMN->m_len == 4) {
+ float val = 0;
+ hr = pMN->Read(val);
+ m_val = val;
+ } else if (pMN->m_len == 8) {
+ hr = pMN->Read(m_val);
+ }
+ if (SUCCEEDED(hr)) {
+ m_fValid = true;
+ }
+ return hr;
}
template<class T, class BASE>
HRESULT CSimpleVar<T, BASE>::Parse(CMatroskaNode* pMN)
{
- m_val = 0;
- m_fValid = true;
- return pMN->Read(m_val);
+ m_val = 0;
+ m_fValid = true;
+ return pMN->Read(m_val);
}
HRESULT CID::Parse(CMatroskaNode* pMN)
{
- m_val = 0;
-
- BYTE b = 0;
- HRESULT hr = pMN->Read(b);
- if (FAILED(hr)) {
- return hr;
- }
-
- int nMoreBytes = 0;
-
- if ((b&0x80) == 0x80) {
- m_val = b&0xff;
- nMoreBytes = 0;
- } else if ((b&0xc0) == 0x40) {
- m_val = b&0x7f;
- nMoreBytes = 1;
- } else if ((b&0xe0) == 0x20) {
- m_val = b&0x3f;
- nMoreBytes = 2;
- } else if ((b&0xf0) == 0x10) {
- m_val = b&0x1f;
- nMoreBytes = 3;
- } else {
- return E_FAIL;
- }
-
- while (nMoreBytes-- > 0) {
- m_val <<= 8;
- hr = pMN->Read(*(BYTE*)&m_val);
- if (FAILED(hr)) {
- return hr;
- }
- }
-
- m_fValid = true;
-
- return S_OK;
+ m_val = 0;
+
+ BYTE b = 0;
+ HRESULT hr = pMN->Read(b);
+ if (FAILED(hr)) {
+ return hr;
+ }
+
+ int nMoreBytes = 0;
+
+ if ((b & 0x80) == 0x80) {
+ m_val = b & 0xff;
+ nMoreBytes = 0;
+ } else if ((b & 0xc0) == 0x40) {
+ m_val = b & 0x7f;
+ nMoreBytes = 1;
+ } else if ((b & 0xe0) == 0x20) {
+ m_val = b & 0x3f;
+ nMoreBytes = 2;
+ } else if ((b & 0xf0) == 0x10) {
+ m_val = b & 0x1f;
+ nMoreBytes = 3;
+ } else {
+ return E_FAIL;
+ }
+
+ while (nMoreBytes-- > 0) {
+ m_val <<= 8;
+ hr = pMN->Read(*(BYTE*)&m_val);
+ if (FAILED(hr)) {
+ return hr;
+ }
+ }
+
+ m_fValid = true;
+
+ return S_OK;
}
HRESULT CLength::Parse(CMatroskaNode* pMN)
{
- m_val = 0;
-
- BYTE b = 0;
- HRESULT hr = pMN->Read(b);
- if (FAILED(hr)) {
- return hr;
- }
-
- int nMoreBytes = 0;
-
- if ((b&0x80) == 0x80) {
- m_val = b&0x7f;
- nMoreBytes = 0;
- } else if ((b&0xc0) == 0x40) {
- m_val = b&0x3f;
- nMoreBytes = 1;
- } else if ((b&0xe0) == 0x20) {
- m_val = b&0x1f;
- nMoreBytes = 2;
- } else if ((b&0xf0) == 0x10) {
- m_val = b&0x0f;
- nMoreBytes = 3;
- } else if ((b&0xf8) == 0x08) {
- m_val = b&0x07;
- nMoreBytes = 4;
- } else if ((b&0xfc) == 0x04) {
- m_val = b&0x03;
- nMoreBytes = 5;
- } else if ((b&0xfe) == 0x02) {
- m_val = b&0x01;
- nMoreBytes = 6;
- } else if ((b&0xff) == 0x01) {
- m_val = b&0x00;
- nMoreBytes = 7;
- } else {
- return E_FAIL;
- }
-
- //int nMoreBytesTmp = nMoreBytes;
-
- MatroskaReader::QWORD UnknownSize = (1i64<<(7*(nMoreBytes+1)))-1;
-
- while (nMoreBytes-- > 0) {
- m_val <<= 8;
- hr = pMN->Read(*(BYTE*)&m_val);
- if (FAILED(hr)) {
- return hr;
- }
- }
-
- if (m_val == UnknownSize) {
- m_val = pMN->GetLength() - pMN->GetPos();
- TRACE(_T("CLength: Unspecified chunk size at %I64d (corrected to %I64d)\n"), pMN->GetPos(), m_val);
- }
-
- if (m_fSigned) {
- m_val -= (UnknownSize >> 1);
- }
-
- m_fValid = true;
-
- return S_OK;
+ m_val = 0;
+
+ BYTE b = 0;
+ HRESULT hr = pMN->Read(b);
+ if (FAILED(hr)) {
+ return hr;
+ }
+
+ int nMoreBytes = 0;
+
+ if ((b & 0x80) == 0x80) {
+ m_val = b & 0x7f;
+ nMoreBytes = 0;
+ } else if ((b & 0xc0) == 0x40) {
+ m_val = b & 0x3f;
+ nMoreBytes = 1;
+ } else if ((b & 0xe0) == 0x20) {
+ m_val = b & 0x1f;
+ nMoreBytes = 2;
+ } else if ((b & 0xf0) == 0x10) {
+ m_val = b & 0x0f;
+ nMoreBytes = 3;
+ } else if ((b & 0xf8) == 0x08) {
+ m_val = b & 0x07;
+ nMoreBytes = 4;
+ } else if ((b & 0xfc) == 0x04) {
+ m_val = b & 0x03;
+ nMoreBytes = 5;
+ } else if ((b & 0xfe) == 0x02) {
+ m_val = b & 0x01;
+ nMoreBytes = 6;
+ } else if ((b & 0xff) == 0x01) {
+ m_val = b & 0x00;
+ nMoreBytes = 7;
+ } else {
+ return E_FAIL;
+ }
+
+ //int nMoreBytesTmp = nMoreBytes;
+
+ MatroskaReader::QWORD UnknownSize = (1i64 << (7 * (nMoreBytes + 1))) - 1;
+
+ while (nMoreBytes-- > 0) {
+ m_val <<= 8;
+ hr = pMN->Read(*(BYTE*)&m_val);
+ if (FAILED(hr)) {
+ return hr;
+ }
+ }
+
+ if (m_val == UnknownSize) {
+ m_val = pMN->GetLength() - pMN->GetPos();
+ TRACE(_T("CLength: Unspecified chunk size at %I64d (corrected to %I64d)\n"), pMN->GetPos(), m_val);
+ }
+
+ if (m_fSigned) {
+ m_val -= (UnknownSize >> 1);
+ }
+
+ m_fValid = true;
+
+ return S_OK;
}
/*
HRESULT CSignedLength::Parse(CMatroskaNode* pMN)
{
-// HRESULT hr = __super::Parse(pMN);
-// if (FAILED(hr)) return hr;
+// HRESULT hr = __super::Parse(pMN);
+// if (FAILED(hr)) return hr;
- m_val = 0;
+ m_val = 0;
- BYTE b = 0;
- HRESULT hr = pMN->Read(b);
- if (FAILED(hr)) return hr;
+ BYTE b = 0;
+ HRESULT hr = pMN->Read(b);
+ if (FAILED(hr)) return hr;
- int nMoreBytes = 0;
+ int nMoreBytes = 0;
- if ((b&0x80) == 0x80) {m_val = b&0x7f; nMoreBytes = 0;}
- else if ((b&0xc0) == 0x40) {m_val = b&0x3f; nMoreBytes = 1;}
- else if ((b&0xe0) == 0x20) {m_val = b&0x1f; nMoreBytes = 2;}
- else if ((b&0xf0) == 0x10) {m_val = b&0x0f; nMoreBytes = 3;}
- else if ((b&0xf8) == 0x08) {m_val = b&0x07; nMoreBytes = 4;}
- else if ((b&0xfc) == 0x04) {m_val = b&0x03; nMoreBytes = 5;}
- else if ((b&0xfe) == 0x02) {m_val = b&0x01; nMoreBytes = 6;}
- else if ((b&0xff) == 0x01) {m_val = b&0x00; nMoreBytes = 7;}
- else return E_FAIL;
+ if ((b&0x80) == 0x80) {m_val = b&0x7f; nMoreBytes = 0;}
+ else if ((b&0xc0) == 0x40) {m_val = b&0x3f; nMoreBytes = 1;}
+ else if ((b&0xe0) == 0x20) {m_val = b&0x1f; nMoreBytes = 2;}
+ else if ((b&0xf0) == 0x10) {m_val = b&0x0f; nMoreBytes = 3;}
+ else if ((b&0xf8) == 0x08) {m_val = b&0x07; nMoreBytes = 4;}
+ else if ((b&0xfc) == 0x04) {m_val = b&0x03; nMoreBytes = 5;}
+ else if ((b&0xfe) == 0x02) {m_val = b&0x01; nMoreBytes = 6;}
+ else if ((b&0xff) == 0x01) {m_val = b&0x00; nMoreBytes = 7;}
+ else return E_FAIL;
- //int nMoreBytesTmp = nMoreBytes;
+ //int nMoreBytesTmp = nMoreBytes;
- MatroskaReader::QWORD UnknownSize = (1i64<<(7*(nMoreBytes+1)))-1;
+ MatroskaReader::QWORD UnknownSize = (1i64<<(7*(nMoreBytes+1)))-1;
- while (nMoreBytes-- > 0)
- {
- m_val <<= 8;
- hr = pMN->Read(*(BYTE*)&m_val);
- if (FAILED(hr)) return hr;
- }
+ while (nMoreBytes-- > 0)
+ {
+ m_val <<= 8;
+ hr = pMN->Read(*(BYTE*)&m_val);
+ if (FAILED(hr)) return hr;
+ }
- if (m_val == UnknownSize)
- {
- m_val = pMN->GetLength() - pMN->GetPos();
- TRACE(_T("CLength: Unspecified chunk size at %I64d (corrected to %I64d)\n"), pMN->GetPos(), m_val);
- }
+ if (m_val == UnknownSize)
+ {
+ m_val = pMN->GetLength() - pMN->GetPos();
+ TRACE(_T("CLength: Unspecified chunk size at %I64d (corrected to %I64d)\n"), pMN->GetPos(), m_val);
+ }
- m_val -= (UnknownSize >> 1);
+ m_val -= (UnknownSize >> 1);
- m_fValid = true;
+ m_fValid = true;
- return S_OK;
+ return S_OK;
}
*/
template<class T>
HRESULT CNode<T>::Parse(CMatroskaNode* pMN)
{
- CAutoPtr<T> p(DNew T());
- HRESULT hr = E_OUTOFMEMORY;
- if (!p || FAILED(hr = p->Parse(pMN))) {
- return hr;
- }
- AddTail(p);
- return S_OK;
+ CAutoPtr<T> p(DNew T());
+ HRESULT hr = E_OUTOFMEMORY;
+ if (!p || FAILED(hr = p->Parse(pMN))) {
+ return hr;
+ }
+ AddTail(p);
+ return S_OK;
}
HRESULT CBlockGroupNode::Parse(CMatroskaNode* pMN, bool fFull)
{
- CAutoPtr<BlockGroup> p(DNew BlockGroup());
- HRESULT hr = E_OUTOFMEMORY;
- if (!p || FAILED(hr = p->Parse(pMN, fFull))) {
- return hr;
- }
- AddTail(p);
- return S_OK;
+ CAutoPtr<BlockGroup> p(DNew BlockGroup());
+ HRESULT hr = E_OUTOFMEMORY;
+ if (!p || FAILED(hr = p->Parse(pMN, fFull))) {
+ return hr;
+ }
+ AddTail(p);
+ return S_OK;
}
HRESULT CSimpleBlockNode::Parse(CMatroskaNode* pMN, bool fFull)
{
- CAutoPtr<SimpleBlock> p(DNew SimpleBlock());
- HRESULT hr = E_OUTOFMEMORY;
- if (!p || FAILED(hr = p->Parse(pMN, fFull))) {
- return hr;
- }
- AddTail(p);
- return S_OK;
+ CAutoPtr<SimpleBlock> p(DNew SimpleBlock());
+ HRESULT hr = E_OUTOFMEMORY;
+ if (!p || FAILED(hr = p->Parse(pMN, fFull))) {
+ return hr;
+ }
+ AddTail(p);
+ return S_OK;
}
///////////////////////////////
CMatroskaNode::CMatroskaNode(CMatroskaFile* pMF)
- : m_pMF(pMF)
- , m_pParent(NULL)
+ : m_pMF(pMF)
+ , m_pParent(NULL)
{
- ASSERT(m_pMF);
- m_start = m_filepos = 0;
- m_len.Set(m_pMF ? m_pMF->GetLength() : 0);
+ ASSERT(m_pMF);
+ m_start = m_filepos = 0;
+ m_len.Set(m_pMF ? m_pMF->GetLength() : 0);
}
CMatroskaNode::CMatroskaNode(CMatroskaNode* pParent)
- : m_pMF(pParent->m_pMF)
- , m_pParent(pParent)
+ : m_pMF(pParent->m_pMF)
+ , m_pParent(pParent)
{
- Parse();
+ Parse();
}
HRESULT CMatroskaNode::Parse()
{
- m_filepos = GetPos();
- if (FAILED(m_id.Parse(this)) || FAILED(m_len.Parse(this))) {
- return E_FAIL;
- }
- m_start = GetPos();
- return S_OK;
+ m_filepos = GetPos();
+ if (FAILED(m_id.Parse(this)) || FAILED(m_len.Parse(this))) {
+ return E_FAIL;
+ }
+ m_start = GetPos();
+ return S_OK;
}
CAutoPtr<CMatroskaNode> CMatroskaNode::Child(DWORD id, bool fSearch)
{
- if (m_len == 0) {
- return CAutoPtr<CMatroskaNode>();
- }
- SeekTo(m_start);
- CAutoPtr<CMatroskaNode> pMN(DNew CMatroskaNode(this));
- if (id && !pMN->Find(id, fSearch)) {
- pMN.Free();
- }
- return pMN;
+ if (m_len == 0) {
+ return CAutoPtr<CMatroskaNode>();
+ }
+ SeekTo(m_start);
+ CAutoPtr<CMatroskaNode> pMN(DNew CMatroskaNode(this));
+ if (id && !pMN->Find(id, fSearch)) {
+ pMN.Free();
+ }
+ return pMN;
}
bool CMatroskaNode::Next(bool fSame)
{
- if (!m_pParent) {
- return false;
- }
+ if (!m_pParent) {
+ return false;
+ }
- CID id = m_id;
+ CID id = m_id;
- while (m_start+m_len < m_pParent->m_start+m_pParent->m_len) {
- SeekTo(m_start+m_len);
+ while (m_start + m_len < m_pParent->m_start + m_pParent->m_len) {
+ SeekTo(m_start + m_len);
- if (FAILED(Parse())) {
- if (!Resync()) {
- return false;
- }
- }
+ if (FAILED(Parse())) {
+ if (!Resync()) {
+ return false;
+ }
+ }
- if (!fSame || m_id == id) {
- return true;
- }
- }
+ if (!fSame || m_id == id) {
+ return true;
+ }
+ }
- return false;
+ return false;
}
bool CMatroskaNode::Find(DWORD id, bool fSearch)
{
- MatroskaReader::QWORD pos = m_pParent && m_pParent->m_id == 0x18538067 /*segment?*/
- ? FindPos(id)
- : 0;
+ MatroskaReader::QWORD pos = m_pParent && m_pParent->m_id == 0x18538067 /*segment?*/
+ ? FindPos(id)
+ : 0;
- if (pos) {
- SeekTo(pos);
- Parse();
- } else if (fSearch) {
- while (m_id != id && Next()) {
- ;
- }
- }
+ if (pos) {
+ SeekTo(pos);
+ Parse();
+ } else if (fSearch) {
+ while (m_id != id && Next()) {
+ ;
+ }
+ }
- return (m_id == id);
+ return (m_id == id);
}
void CMatroskaNode::SeekTo(MatroskaReader::QWORD pos)
{
- m_pMF->Seek(pos);
+ m_pMF->Seek(pos);
}
MatroskaReader::QWORD CMatroskaNode::GetPos()
{
- return m_pMF->GetPos();
+ return m_pMF->GetPos();
}
MatroskaReader::QWORD CMatroskaNode::GetLength()
{
- return m_pMF->GetLength();
+ return m_pMF->GetLength();
}
template <class T>
HRESULT CMatroskaNode::Read(T& var)
{
- return m_pMF->Read(var);
+ return m_pMF->Read(var);
}
HRESULT CMatroskaNode::Read(BYTE* pData, MatroskaReader::QWORD len)
{
- return m_pMF->ByteRead(pData, len);
+ return m_pMF->ByteRead(pData, len);
}
MatroskaReader::QWORD CMatroskaNode::FindPos(DWORD id, MatroskaReader::QWORD start)
{
- Segment& sm = m_pMF->m_segment;
+ Segment& sm = m_pMF->m_segment;
- POSITION pos = sm.MetaSeekInfo.GetHeadPosition();
- while (pos) {
- Seek* s = sm.MetaSeekInfo.GetNext(pos);
+ POSITION pos = sm.MetaSeekInfo.GetHeadPosition();
+ while (pos) {
+ Seek* s = sm.MetaSeekInfo.GetNext(pos);
- POSITION pos2 = s->SeekHeads.GetHeadPosition();
- while (pos2) {
- SeekHead* sh = s->SeekHeads.GetNext(pos2);
- if (sh->SeekID == id && sh->SeekPosition+sm.pos >= start) {
- return sh->SeekPosition+sm.pos;
- }
- }
- }
+ POSITION pos2 = s->SeekHeads.GetHeadPosition();
+ while (pos2) {
+ SeekHead* sh = s->SeekHeads.GetNext(pos2);
+ if (sh->SeekID == id && sh->SeekPosition + sm.pos >= start) {
+ return sh->SeekPosition + sm.pos;
+ }
+ }
+ }
- return 0;
+ return 0;
}
CAutoPtr<CMatroskaNode> CMatroskaNode::Copy()
{
- CAutoPtr<CMatroskaNode> pNewNode(DNew CMatroskaNode(m_pMF));
- pNewNode->m_pParent = m_pParent;
- pNewNode->m_id.Set(m_id);
- pNewNode->m_len.Set(m_len);
- pNewNode->m_filepos = m_filepos;
- pNewNode->m_start = m_start;
- return pNewNode;
+ CAutoPtr<CMatroskaNode> pNewNode(DNew CMatroskaNode(m_pMF));
+ pNewNode->m_pParent = m_pParent;
+ pNewNode->m_id.Set(m_id);
+ pNewNode->m_len.Set(m_len);
+ pNewNode->m_filepos = m_filepos;
+ pNewNode->m_start = m_start;
+ return pNewNode;
}
CAutoPtr<CMatroskaNode> CMatroskaNode::GetFirstBlock()
{
- CAutoPtr<CMatroskaNode> pNode = Child();
- do {
- if (pNode->m_id == 0xA0 || pNode->m_id == 0xA3) {
- return pNode;
- }
- } while (pNode->Next());
- return CAutoPtr<CMatroskaNode>();
+ CAutoPtr<CMatroskaNode> pNode = Child();
+ do {
+ if (pNode->m_id == 0xA0 || pNode->m_id == 0xA3) {
+ return pNode;
+ }
+ } while (pNode->Next());
+ return CAutoPtr<CMatroskaNode>();
}
bool CMatroskaNode::NextBlock()
{
- if (!m_pParent) {
- return false;
- }
+ if (!m_pParent) {
+ return false;
+ }
- CID id = m_id;
+ CID id = m_id;
- while (m_start+m_len < m_pParent->m_start+m_pParent->m_len) {
- SeekTo(m_start+m_len);
+ while (m_start + m_len < m_pParent->m_start + m_pParent->m_len) {
+ SeekTo(m_start + m_len);
- if (FAILED(Parse())) {
- if (!Resync()) {
- return false;
- }
- }
+ if (FAILED(Parse())) {
+ if (!Resync()) {
+ return false;
+ }
+ }
- if (m_id == 0xA0 || m_id == 0xA3) {
- return true;
- }
- }
+ if (m_id == 0xA0 || m_id == 0xA3) {
+ return true;
+ }
+ }
- return false;
+ return false;
}
bool CMatroskaNode::Resync()
{
- if (m_pParent->m_id == 0x18538067) { /*segment?*/
- SeekTo(m_filepos);
-
- for (BYTE b = 0; S_OK == Read(b); b = 0) {
- if ((b&0xf0) != 0x10) {
- continue;
- }
-
- DWORD dw = b;
- Read((BYTE*)&dw+1, 3);
- bswap((BYTE*)&dw, 4);
-
- switch (dw) {
- case 0x1549A966: // SegmentInfo
- case 0x114D9B74: // MetaSeekInfo
- case 0x1654AE6B: // Tracks
- case 0x1F43B675: // Clusters
- case 0x1C53BB6B: // Cues
- case 0x1941A469: // Attachments
- case 0x1043A770: // Chapters
- case 0x1254C367: // Tags
- SeekTo(GetPos()-4);
- return SUCCEEDED(Parse());
- default:
- SeekTo(GetPos()-3);
- break;
- }
- }
- }
-
- return false;
+ if (m_pParent->m_id == 0x18538067) { /*segment?*/
+ SeekTo(m_filepos);
+
+ for (BYTE b = 0; S_OK == Read(b); b = 0) {
+ if ((b & 0xf0) != 0x10) {
+ continue;
+ }
+
+ DWORD dw = b;
+ Read((BYTE*)&dw + 1, 3);
+ bswap((BYTE*)&dw, 4);
+
+ switch (dw) {
+ case 0x1549A966: // SegmentInfo
+ case 0x114D9B74: // MetaSeekInfo
+ case 0x1654AE6B: // Tracks
+ case 0x1F43B675: // Clusters
+ case 0x1C53BB6B: // Cues
+ case 0x1941A469: // Attachments
+ case 0x1043A770: // Chapters
+ case 0x1254C367: // Tags
+ SeekTo(GetPos() - 4);
+ return SUCCEEDED(Parse());
+ default:
+ SeekTo(GetPos() - 3);
+ break;
+ }
+ }
+ }
+
+ return false;
}
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaFile.h b/src/filters/parser/MatroskaSplitter/MatroskaFile.h
index 02cbbc475..989d4f2fc 100644
--- a/src/filters/parser/MatroskaSplitter/MatroskaFile.h
+++ b/src/filters/parser/MatroskaSplitter/MatroskaFile.h
@@ -29,577 +29,577 @@
namespace MatroskaReader
{
- class CMatroskaNode;
-
- typedef unsigned __int64 QWORD;
-
- class CANSI : public CStringA
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN);
- };
- class CUTF8 : public CStringW
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- template<class T, class BASE>
- class CSimpleVar
- {
- protected:
- T m_val;
- bool m_fValid;
- public:
- CSimpleVar(T val = 0) : m_val(val), m_fValid(false) {}
- BASE& operator = (const BASE& v) {
- m_val = v.m_val;
- m_fValid = true;
- return *this;
- }
- BASE& operator = (T val) {
- m_val = val;
- m_fValid = true;
- return *this;
- }
- operator T() const {
- return m_val;
- }
- BASE& Set(T val) {
- m_val = val;
- m_fValid = true;
- return (*(BASE*)this);
- }
- bool IsValid() const {
- return m_fValid;
- }
- virtual HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class CUInt : public CSimpleVar<UINT64, CUInt>
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN);
- };
- class CInt : public CSimpleVar<INT64, CInt>
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN);
- };
- class CByte : public CSimpleVar<BYTE, CByte> {};
- class CShort : public CSimpleVar<short, CShort> {};
- class CFloat : public CSimpleVar<double, CFloat>
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN);
- };
- class CID : public CSimpleVar<DWORD, CID>
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN);
- };
- class CLength : public CSimpleVar<UINT64, CLength>
- {
- bool m_fSigned;
- public:
- CLength(bool fSigned = false) : m_fSigned(fSigned) {} HRESULT Parse(CMatroskaNode* pMN);
- };
- class CSignedLength : public CLength
- {
- public:
- CSignedLength() : CLength(true) {}
- };
-
- class ContentCompression;
-
- class CBinary : public CAtlArray<BYTE>
- {
- public:
- CBinary& operator = (const CBinary& b) {
- Copy(b);
- return *this;
- }
- CStringA ToString() {
- return CStringA((LPCSTR)GetData(), (int)GetCount());
- }
- bool Compress(ContentCompression& cc), Decompress(ContentCompression& cc);
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- template<class T>
- class CNode : public CAutoPtrList<T>
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class EBML
- {
- public:
- CUInt EBMLVersion, EBMLReadVersion;
- CUInt EBMLMaxIDLength, EBMLMaxSizeLength;
- CANSI DocType;
- CUInt DocTypeVersion, DocTypeReadVersion;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class Info
- {
- public:
- CBinary SegmentUID, PrevUID, NextUID;
- CUTF8 SegmentFilename, PrevFilename, NextFilename;
- CUInt TimeCodeScale; // [ns], default: 1.000.000
- CFloat Duration;
- CInt DateUTC;
- CUTF8 Title, MuxingApp, WritingApp;
-
- Info() {
- TimeCodeScale.Set(1000000ui64);
- }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class SeekHead
- {
- public:
- CID SeekID;
- CUInt SeekPosition;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class Seek
- {
- public:
- CNode<SeekHead> SeekHeads;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class TimeSlice
- {
- public:
- CUInt LaceNumber, FrameNumber;
- CUInt Delay, Duration;
-
- TimeSlice() {
- LaceNumber.Set(0);
- FrameNumber.Set(0);
- Delay.Set(0);
- Duration.Set(0);
- }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class SimpleBlock
- {
- public:
- CLength TrackNumber;
- CInt TimeCode;
- CByte Lacing;
- CAutoPtrList<CBinary> BlockData;
-
- HRESULT Parse(CMatroskaNode* pMN, bool fFull);
- };
-
- class BlockMore
- {
- public:
- CInt BlockAddID;
- CBinary BlockAdditional;
-
- BlockMore() {
- BlockAddID.Set(1);
- }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class BlockAdditions
- {
- public:
- CNode<BlockMore> bm;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class BlockGroup
- {
- public:
- SimpleBlock Block;
- // BlockVirtual
- CUInt BlockDuration;
- CUInt ReferencePriority;
- CInt ReferenceBlock;
- CInt ReferenceVirtual;
- CBinary CodecState;
- CNode<TimeSlice> TimeSlices;
- BlockAdditions ba;
-
- HRESULT Parse(CMatroskaNode* pMN, bool fFull);
- };
-
- class CBlockGroupNode : public CNode<BlockGroup>
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN, bool fFull);
- };
-
- class CSimpleBlockNode : public CNode<SimpleBlock>
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN, bool fFull);
- };
-
- class Cluster
- {
- public:
- CUInt TimeCode, Position, PrevSize;
- CBlockGroupNode BlockGroups;
- CSimpleBlockNode SimpleBlocks;
-
- HRESULT Parse(CMatroskaNode* pMN);
- HRESULT ParseTimeCode(CMatroskaNode* pMN);
- };
-
- class Video
- {
- public:
- CUInt FlagInterlaced, StereoMode;
- CUInt PixelWidth, PixelHeight, DisplayWidth, DisplayHeight, DisplayUnit;
- CUInt VideoPixelCropBottom, VideoPixelCropTop, VideoPixelCropLeft, VideoPixelCropRight;
- CUInt AspectRatioType;
- CUInt ColourSpace;
- CFloat GammaValue;
- CFloat FramePerSec;
-
- Video() {
- FlagInterlaced.Set(0);
- StereoMode.Set(0);
- DisplayUnit.Set(0);
- AspectRatioType.Set(0);
- }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class Audio
- {
- public:
- CFloat SamplingFrequency;
- CFloat OutputSamplingFrequency;
- CUInt Channels;
- CBinary ChannelPositions;
- CUInt BitDepth;
-
- Audio() {
- SamplingFrequency.Set(8000.0);
- Channels.Set(1);
- }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class ContentCompression
- {
- public:
- CUInt ContentCompAlgo;
- enum {ZLIB, BZLIB, LZO1X, HDRSTRIP};
- CBinary ContentCompSettings;
-
- ContentCompression() {
- ContentCompAlgo.Set(ZLIB);
- }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class ContentEncryption
- {
- public:
- CUInt ContentEncAlgo;
- enum {UNKE, DES, THREEDES, TWOFISH, BLOWFISH, AES};
- CBinary ContentEncKeyID, ContentSignature, ContentSigKeyID;
- CUInt ContentSigAlgo;
- enum {UNKS, RSA};
- CUInt ContentSigHashAlgo;
- enum {UNKSH, SHA1_160, MD5};
-
- ContentEncryption() {
- ContentEncAlgo.Set(0);
- ContentSigAlgo.Set(0);
- ContentSigHashAlgo.Set(0);
- }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class ContentEncoding
- {
- public:
- CUInt ContentEncodingOrder;
- CUInt ContentEncodingScope;
- enum {AllFrameContents = 1, TracksPrivateData = 2};
- CUInt ContentEncodingType;
- enum {Compression, Encryption};
- ContentCompression cc;
- ContentEncryption ce;
-
- ContentEncoding() {
- ContentEncodingOrder.Set(0);
- ContentEncodingScope.Set(AllFrameContents);
- ContentEncodingType.Set(Compression);
- }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class ContentEncodings
- {
- public:
- CNode<ContentEncoding> ce;
-
- ContentEncodings() {}
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class TrackEntry
- {
- public:
- enum {TypeVideo = 1, TypeAudio = 2, TypeComplex = 3, TypeLogo = 0x10, TypeSubtitle = 0x11, TypeControl = 0x20};
- CUInt TrackNumber, TrackUID, TrackType;
- CUInt FlagEnabled, FlagDefault, FlagLacing, FlagForced;
- CUInt MinCache, MaxCache;
- CUTF8 Name;
- CANSI Language;
- CBinary CodecID;
- CBinary CodecPrivate;
- CUTF8 CodecName;
- CUTF8 CodecSettings;
- CANSI CodecInfoURL;
- CANSI CodecDownloadURL;
- CUInt CodecDecodeAll;
- CUInt TrackOverlay;
- CUInt DefaultDuration;
- CUInt MaxBlockAdditionID;
- CFloat TrackTimecodeScale;
- enum {NoDesc = 0, DescVideo = 1, DescAudio = 2};
- unsigned int DescType;
- Video v;
- Audio a;
- ContentEncodings ces;
- TrackEntry() {
- DescType = NoDesc;
- FlagEnabled.Set(1);
- FlagDefault.Set(1);
- FlagLacing.Set(1);
- FlagForced.Set(0);
- MinCache.Set(0);
- TrackTimecodeScale.Set(1.0f);
- Language.CStringA::operator = ("eng");
- MaxBlockAdditionID.Set(0);
- CodecDecodeAll.Set(1);
- }
- HRESULT Parse(CMatroskaNode* pMN);
-
- bool Expand(CBinary& data, UINT64 Scope);
- };
-
- class Track
- {
- public:
- CNode<TrackEntry> TrackEntries;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class CueReference
- {
- public:
- CUInt CueRefTime, CueRefCluster, CueRefNumber, CueRefCodecState;
-
- CueReference() {
- CueRefNumber.Set(1);
- CueRefCodecState.Set(0);
- }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class CueTrackPosition
- {
- public:
- CUInt CueTrack, CueClusterPosition, CueBlockNumber, CueCodecState;
- CNode<CueReference> CueReferences;
-
- CueTrackPosition() {
- CueBlockNumber.Set(1);
- CueCodecState.Set(0);
- }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class CuePoint
- {
- public:
- CUInt CueTime;
- CNode<CueTrackPosition> CueTrackPositions;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class Cue
- {
- public:
- CNode<CuePoint> CuePoints;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class AttachedFile
- {
- public:
- CUTF8 FileDescription;
- CUTF8 FileName;
- CANSI FileMimeType;
- QWORD FileDataPos, FileDataLen; // BYTE* FileData
- CUInt FileUID;
-
- AttachedFile() {
- FileDataPos = FileDataLen = 0;
- }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class Attachment
- {
- public:
- CNode<AttachedFile> AttachedFiles;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class ChapterDisplay
- {
- public:
- CUTF8 ChapString;
- CANSI ChapLanguage;
- CANSI ChapCountry;
-
- ChapterDisplay() {
- ChapLanguage.CStringA::operator = ("eng");
- }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class ChapterAtom
- {
- public:
- CUInt ChapterUID;
- CUInt ChapterTimeStart, ChapterTimeEnd, ChapterFlagHidden, ChapterFlagEnabled;
- //CNode<CUInt> ChapterTracks; // TODO
- CNode<ChapterDisplay> ChapterDisplays;
- CNode<ChapterAtom> ChapterAtoms;
-
- ChapterAtom() {
- ChapterUID.Set(0);// 0 = not set (ChapUID zero not allow by Matroska specs)
- ChapterFlagHidden.Set(0);
- ChapterFlagEnabled.Set(1);
- }
- HRESULT Parse(CMatroskaNode* pMN);
- ChapterAtom* FindChapterAtom(UINT64 id);
- };
-
- class EditionEntry : public ChapterAtom
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class Chapter
- {
- public:
- CNode<EditionEntry> EditionEntries;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class Segment
- {
- public:
- QWORD pos, len;
- Info SegmentInfo;
- CNode<Seek> MetaSeekInfo;
- CNode<Cluster> Clusters;
- CNode<Track> Tracks;
- CNode<Cue> Cues;
- CNode<Attachment> Attachments;
- CNode<Chapter> Chapters;
- // TODO: Chapters
- // TODO: Tags
-
- HRESULT Parse(CMatroskaNode* pMN);
- HRESULT ParseMinimal(CMatroskaNode* pMN);
-
- UINT64 GetMasterTrack();
-
- REFERENCE_TIME GetRefTime(INT64 t) const {
- return t*(REFERENCE_TIME)(SegmentInfo.TimeCodeScale)/100;
- }
- ChapterAtom* FindChapterAtom(UINT64 id, int nEditionEntry = 0);
- };
-
- class CMatroskaFile : public CBaseSplitterFile
- {
- public:
- CMatroskaFile(IAsyncReader* pAsyncReader, HRESULT& hr);
- virtual ~CMatroskaFile() {}
-
- HRESULT Init();
-
- //using CBaseSplitterFile::Read;
- template <class T> HRESULT Read(T& var);
-
- EBML m_ebml;
- Segment m_segment;
- REFERENCE_TIME m_rtOffset;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class CMatroskaNode
- {
- CMatroskaNode* m_pParent;
- CMatroskaFile* m_pMF;
-
- bool Resync();
-
- public:
- CID m_id;
- CLength m_len;
- QWORD m_filepos, m_start;
-
- HRESULT Parse();
-
- public:
- CMatroskaNode(CMatroskaFile* pMF); // creates the root
- CMatroskaNode(CMatroskaNode* pParent);
-
- CMatroskaNode* Parent() {
- return m_pParent;
- }
- CAutoPtr<CMatroskaNode> Child(DWORD id = 0, bool fSearch = true);
- bool Next(bool fSame = false);
- bool Find(DWORD id, bool fSearch = true);
-
- QWORD FindPos(DWORD id, QWORD start = 0);
-
- void SeekTo(QWORD pos);
- QWORD GetPos(), GetLength();
- template <class T> HRESULT Read(T& var);
- HRESULT Read(BYTE* pData, QWORD len);
-
- CAutoPtr<CMatroskaNode> Copy();
-
- CAutoPtr<CMatroskaNode> GetFirstBlock();
- bool NextBlock();
-
- bool IsRandomAccess() {
- return m_pMF->IsRandomAccess();
- }
- };
+ class CMatroskaNode;
+
+ typedef unsigned __int64 QWORD;
+
+ class CANSI : public CStringA
+ {
+ public:
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+ class CUTF8 : public CStringW
+ {
+ public:
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ template<class T, class BASE>
+ class CSimpleVar
+ {
+ protected:
+ T m_val;
+ bool m_fValid;
+ public:
+ CSimpleVar(T val = 0) : m_val(val), m_fValid(false) {}
+ BASE& operator = (const BASE& v) {
+ m_val = v.m_val;
+ m_fValid = true;
+ return *this;
+ }
+ BASE& operator = (T val) {
+ m_val = val;
+ m_fValid = true;
+ return *this;
+ }
+ operator T() const {
+ return m_val;
+ }
+ BASE& Set(T val) {
+ m_val = val;
+ m_fValid = true;
+ return (*(BASE*)this);
+ }
+ bool IsValid() const {
+ return m_fValid;
+ }
+ virtual HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ class CUInt : public CSimpleVar<UINT64, CUInt>
+ {
+ public:
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+ class CInt : public CSimpleVar<INT64, CInt>
+ {
+ public:
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+ class CByte : public CSimpleVar<BYTE, CByte> {};
+ class CShort : public CSimpleVar<short, CShort> {};
+ class CFloat : public CSimpleVar<double, CFloat>
+ {
+ public:
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+ class CID : public CSimpleVar<DWORD, CID>
+ {
+ public:
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+ class CLength : public CSimpleVar<UINT64, CLength>
+ {
+ bool m_fSigned;
+ public:
+ CLength(bool fSigned = false) : m_fSigned(fSigned) {} HRESULT Parse(CMatroskaNode* pMN);
+ };
+ class CSignedLength : public CLength
+ {
+ public:
+ CSignedLength() : CLength(true) {}
+ };
+
+ class ContentCompression;
+
+ class CBinary : public CAtlArray<BYTE>
+ {
+ public:
+ CBinary& operator = (const CBinary& b) {
+ Copy(b);
+ return *this;
+ }
+ CStringA ToString() {
+ return CStringA((LPCSTR)GetData(), (int)GetCount());
+ }
+ bool Compress(ContentCompression& cc), Decompress(ContentCompression& cc);
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ template<class T>
+ class CNode : public CAutoPtrList<T>
+ {
+ public:
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ class EBML
+ {
+ public:
+ CUInt EBMLVersion, EBMLReadVersion;
+ CUInt EBMLMaxIDLength, EBMLMaxSizeLength;
+ CANSI DocType;
+ CUInt DocTypeVersion, DocTypeReadVersion;
+
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ class Info
+ {
+ public:
+ CBinary SegmentUID, PrevUID, NextUID;
+ CUTF8 SegmentFilename, PrevFilename, NextFilename;
+ CUInt TimeCodeScale; // [ns], default: 1.000.000
+ CFloat Duration;
+ CInt DateUTC;
+ CUTF8 Title, MuxingApp, WritingApp;
+
+ Info() {
+ TimeCodeScale.Set(1000000ui64);
+ }
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ class SeekHead
+ {
+ public:
+ CID SeekID;
+ CUInt SeekPosition;
+
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ class Seek
+ {
+ public:
+ CNode<SeekHead> SeekHeads;
+
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ class TimeSlice
+ {
+ public:
+ CUInt LaceNumber, FrameNumber;
+ CUInt Delay, Duration;
+
+ TimeSlice() {
+ LaceNumber.Set(0);
+ FrameNumber.Set(0);
+ Delay.Set(0);
+ Duration.Set(0);
+ }
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ class SimpleBlock
+ {
+ public:
+ CLength TrackNumber;
+ CInt TimeCode;
+ CByte Lacing;
+ CAutoPtrList<CBinary> BlockData;
+
+ HRESULT Parse(CMatroskaNode* pMN, bool fFull);
+ };
+
+ class BlockMore
+ {
+ public:
+ CInt BlockAddID;
+ CBinary BlockAdditional;
+
+ BlockMore() {
+ BlockAddID.Set(1);
+ }
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ class BlockAdditions
+ {
+ public:
+ CNode<BlockMore> bm;
+
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ class BlockGroup
+ {
+ public:
+ SimpleBlock Block;
+ // BlockVirtual
+ CUInt BlockDuration;
+ CUInt ReferencePriority;
+ CInt ReferenceBlock;
+ CInt ReferenceVirtual;
+ CBinary CodecState;
+ CNode<TimeSlice> TimeSlices;
+ BlockAdditions ba;
+
+ HRESULT Parse(CMatroskaNode* pMN, bool fFull);
+ };
+
+ class CBlockGroupNode : public CNode<BlockGroup>
+ {
+ public:
+ HRESULT Parse(CMatroskaNode* pMN, bool fFull);
+ };
+
+ class CSimpleBlockNode : public CNode<SimpleBlock>
+ {
+ public:
+ HRESULT Parse(CMatroskaNode* pMN, bool fFull);
+ };
+
+ class Cluster
+ {
+ public:
+ CUInt TimeCode, Position, PrevSize;
+ CBlockGroupNode BlockGroups;
+ CSimpleBlockNode SimpleBlocks;
+
+ HRESULT Parse(CMatroskaNode* pMN);
+ HRESULT ParseTimeCode(CMatroskaNode* pMN);
+ };
+
+ class Video
+ {
+ public:
+ CUInt FlagInterlaced, StereoMode;
+ CUInt PixelWidth, PixelHeight, DisplayWidth, DisplayHeight, DisplayUnit;
+ CUInt VideoPixelCropBottom, VideoPixelCropTop, VideoPixelCropLeft, VideoPixelCropRight;
+ CUInt AspectRatioType;
+ CUInt ColourSpace;
+ CFloat GammaValue;
+ CFloat FramePerSec;
+
+ Video() {
+ FlagInterlaced.Set(0);
+ StereoMode.Set(0);
+ DisplayUnit.Set(0);
+ AspectRatioType.Set(0);
+ }
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ class Audio
+ {
+ public:
+ CFloat SamplingFrequency;
+ CFloat OutputSamplingFrequency;
+ CUInt Channels;
+ CBinary ChannelPositions;
+ CUInt BitDepth;
+
+ Audio() {
+ SamplingFrequency.Set(8000.0);
+ Channels.Set(1);
+ }
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ class ContentCompression
+ {
+ public:
+ CUInt ContentCompAlgo;
+ enum {ZLIB, BZLIB, LZO1X, HDRSTRIP};
+ CBinary ContentCompSettings;
+
+ ContentCompression() {
+ ContentCompAlgo.Set(ZLIB);
+ }
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ class ContentEncryption
+ {
+ public:
+ CUInt ContentEncAlgo;
+ enum {UNKE, DES, THREEDES, TWOFISH, BLOWFISH, AES};
+ CBinary ContentEncKeyID, ContentSignature, ContentSigKeyID;
+ CUInt ContentSigAlgo;
+ enum {UNKS, RSA};
+ CUInt ContentSigHashAlgo;
+ enum {UNKSH, SHA1_160, MD5};
+
+ ContentEncryption() {
+ ContentEncAlgo.Set(0);
+ ContentSigAlgo.Set(0);
+ ContentSigHashAlgo.Set(0);
+ }
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ class ContentEncoding
+ {
+ public:
+ CUInt ContentEncodingOrder;
+ CUInt ContentEncodingScope;
+ enum {AllFrameContents = 1, TracksPrivateData = 2};
+ CUInt ContentEncodingType;
+ enum {Compression, Encryption};
+ ContentCompression cc;
+ ContentEncryption ce;
+
+ ContentEncoding() {
+ ContentEncodingOrder.Set(0);
+ ContentEncodingScope.Set(AllFrameContents);
+ ContentEncodingType.Set(Compression);
+ }
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ class ContentEncodings
+ {
+ public:
+ CNode<ContentEncoding> ce;
+
+ ContentEncodings() {}
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ class TrackEntry
+ {
+ public:
+ enum {TypeVideo = 1, TypeAudio = 2, TypeComplex = 3, TypeLogo = 0x10, TypeSubtitle = 0x11, TypeControl = 0x20};
+ CUInt TrackNumber, TrackUID, TrackType;
+ CUInt FlagEnabled, FlagDefault, FlagLacing, FlagForced;
+ CUInt MinCache, MaxCache;
+ CUTF8 Name;
+ CANSI Language;
+ CBinary CodecID;
+ CBinary CodecPrivate;
+ CUTF8 CodecName;
+ CUTF8 CodecSettings;
+ CANSI CodecInfoURL;
+ CANSI CodecDownloadURL;
+ CUInt CodecDecodeAll;
+ CUInt TrackOverlay;
+ CUInt DefaultDuration;
+ CUInt MaxBlockAdditionID;
+ CFloat TrackTimecodeScale;
+ enum {NoDesc = 0, DescVideo = 1, DescAudio = 2};
+ unsigned int DescType;
+ Video v;
+ Audio a;
+ ContentEncodings ces;
+ TrackEntry() {
+ DescType = NoDesc;
+ FlagEnabled.Set(1);
+ FlagDefault.Set(1);
+ FlagLacing.Set(1);
+ FlagForced.Set(0);
+ MinCache.Set(0);
+ TrackTimecodeScale.Set(1.0f);
+ Language.CStringA::operator = ("eng");
+ MaxBlockAdditionID.Set(0);
+ CodecDecodeAll.Set(1);
+ }
+ HRESULT Parse(CMatroskaNode* pMN);
+
+ bool Expand(CBinary& data, UINT64 Scope);
+ };
+
+ class Track
+ {
+ public:
+ CNode<TrackEntry> TrackEntries;
+
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ class CueReference
+ {
+ public:
+ CUInt CueRefTime, CueRefCluster, CueRefNumber, CueRefCodecState;
+
+ CueReference() {
+ CueRefNumber.Set(1);
+ CueRefCodecState.Set(0);
+ }
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ class CueTrackPosition
+ {
+ public:
+ CUInt CueTrack, CueClusterPosition, CueBlockNumber, CueCodecState;
+ CNode<CueReference> CueReferences;
+
+ CueTrackPosition() {
+ CueBlockNumber.Set(1);
+ CueCodecState.Set(0);
+ }
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ class CuePoint
+ {
+ public:
+ CUInt CueTime;
+ CNode<CueTrackPosition> CueTrackPositions;
+
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ class Cue
+ {
+ public:
+ CNode<CuePoint> CuePoints;
+
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ class AttachedFile
+ {
+ public:
+ CUTF8 FileDescription;
+ CUTF8 FileName;
+ CANSI FileMimeType;
+ QWORD FileDataPos, FileDataLen; // BYTE* FileData
+ CUInt FileUID;
+
+ AttachedFile() {
+ FileDataPos = FileDataLen = 0;
+ }
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ class Attachment
+ {
+ public:
+ CNode<AttachedFile> AttachedFiles;
+
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ class ChapterDisplay
+ {
+ public:
+ CUTF8 ChapString;
+ CANSI ChapLanguage;
+ CANSI ChapCountry;
+
+ ChapterDisplay() {
+ ChapLanguage.CStringA::operator = ("eng");
+ }
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ class ChapterAtom
+ {
+ public:
+ CUInt ChapterUID;
+ CUInt ChapterTimeStart, ChapterTimeEnd, ChapterFlagHidden, ChapterFlagEnabled;
+ //CNode<CUInt> ChapterTracks; // TODO
+ CNode<ChapterDisplay> ChapterDisplays;
+ CNode<ChapterAtom> ChapterAtoms;
+
+ ChapterAtom() {
+ ChapterUID.Set(0);// 0 = not set (ChapUID zero not allow by Matroska specs)
+ ChapterFlagHidden.Set(0);
+ ChapterFlagEnabled.Set(1);
+ }
+ HRESULT Parse(CMatroskaNode* pMN);
+ ChapterAtom* FindChapterAtom(UINT64 id);
+ };
+
+ class EditionEntry : public ChapterAtom
+ {
+ public:
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ class Chapter
+ {
+ public:
+ CNode<EditionEntry> EditionEntries;
+
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ class Segment
+ {
+ public:
+ QWORD pos, len;
+ Info SegmentInfo;
+ CNode<Seek> MetaSeekInfo;
+ CNode<Cluster> Clusters;
+ CNode<Track> Tracks;
+ CNode<Cue> Cues;
+ CNode<Attachment> Attachments;
+ CNode<Chapter> Chapters;
+ // TODO: Chapters
+ // TODO: Tags
+
+ HRESULT Parse(CMatroskaNode* pMN);
+ HRESULT ParseMinimal(CMatroskaNode* pMN);
+
+ UINT64 GetMasterTrack();
+
+ REFERENCE_TIME GetRefTime(INT64 t) const {
+ return t * (REFERENCE_TIME)(SegmentInfo.TimeCodeScale) / 100;
+ }
+ ChapterAtom* FindChapterAtom(UINT64 id, int nEditionEntry = 0);
+ };
+
+ class CMatroskaFile : public CBaseSplitterFile
+ {
+ public:
+ CMatroskaFile(IAsyncReader* pAsyncReader, HRESULT& hr);
+ virtual ~CMatroskaFile() {}
+
+ HRESULT Init();
+
+ //using CBaseSplitterFile::Read;
+ template <class T> HRESULT Read(T& var);
+
+ EBML m_ebml;
+ Segment m_segment;
+ REFERENCE_TIME m_rtOffset;
+
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
+
+ class CMatroskaNode
+ {
+ CMatroskaNode* m_pParent;
+ CMatroskaFile* m_pMF;
+
+ bool Resync();
+
+ public:
+ CID m_id;
+ CLength m_len;
+ QWORD m_filepos, m_start;
+
+ HRESULT Parse();
+
+ public:
+ CMatroskaNode(CMatroskaFile* pMF); // creates the root
+ CMatroskaNode(CMatroskaNode* pParent);
+
+ CMatroskaNode* Parent() {
+ return m_pParent;
+ }
+ CAutoPtr<CMatroskaNode> Child(DWORD id = 0, bool fSearch = true);
+ bool Next(bool fSame = false);
+ bool Find(DWORD id, bool fSearch = true);
+
+ QWORD FindPos(DWORD id, QWORD start = 0);
+
+ void SeekTo(QWORD pos);
+ QWORD GetPos(), GetLength();
+ template <class T> HRESULT Read(T& var);
+ HRESULT Read(BYTE* pData, QWORD len);
+
+ CAutoPtr<CMatroskaNode> Copy();
+
+ CAutoPtr<CMatroskaNode> GetFirstBlock();
+ bool NextBlock();
+
+ bool IsRandomAccess() {
+ return m_pMF->IsRandomAccess();
+ }
+ };
}
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp
index 7a8b93f81..43d7a64b5 100644
--- a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp
+++ b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp
@@ -37,43 +37,43 @@ using namespace MatroskaReader;
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_Matroska},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL}
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_Matroska},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL}
};
const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CMatroskaSplitterFilter), MatroskaSplitterName, MERIT_NORMAL, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CMatroskaSourceFilter), MatroskaSourceName, MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CMatroskaSplitterFilter), MatroskaSplitterName, MERIT_NORMAL, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CMatroskaSourceFilter), MatroskaSourceName, MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMatroskaSplitterFilter>, NULL, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CMatroskaSourceFilter>, NULL, &sudFilter[1]},
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMatroskaSplitterFilter>, NULL, &sudFilter[0]},
+ {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CMatroskaSourceFilter>, NULL, &sudFilter[1]},
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- RegisterSourceFilter(
- __uuidof(CMatroskaSourceFilter),
- MEDIASUBTYPE_Matroska,
- _T("0,4,,1A45DFA3"),
- _T(".mkv"), _T(".mka"), _T(".mks"), NULL);
+ RegisterSourceFilter(
+ __uuidof(CMatroskaSourceFilter),
+ MEDIASUBTYPE_Matroska,
+ _T("0,4,,1A45DFA3"),
+ _T(".mkv"), _T(".mka"), _T(".mks"), NULL);
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- UnRegisterSourceFilter(MEDIASUBTYPE_Matroska);
+ UnRegisterSourceFilter(MEDIASUBTYPE_Matroska);
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -87,7 +87,7 @@ CFilterApp theApp;
//
CMatroskaSplitterFilter::CMatroskaSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("CMatroskaSplitterFilter"), pUnk, phr, __uuidof(this))
+ : CBaseSplitterFilter(NAME("CMatroskaSplitterFilter"), pUnk, phr, __uuidof(this))
{
}
@@ -97,1255 +97,1263 @@ CMatroskaSplitterFilter::~CMatroskaSplitterFilter()
STDMETHODIMP CMatroskaSplitterFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- QI(ITrackInfo)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(ITrackInfo)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
STDMETHODIMP CMatroskaSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo)
{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
-
- if (m_pName && m_pName[0]==L'M' && m_pName[1]==L'P' && m_pName[2]==L'C') {
- (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
- } else {
- wcscpy_s(pInfo->achName, MatroskaSourceName);
- }
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
+ CheckPointer(pInfo, E_POINTER);
+ ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
+
+ if (m_pName && m_pName[0] == L'M' && m_pName[1] == L'P' && m_pName[2] == L'C') {
+ (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
+ } else {
+ wcscpy_s(pInfo->achName, MatroskaSourceName);
+ }
+ pInfo->pGraph = m_pGraph;
+ if (m_pGraph) {
+ m_pGraph->AddRef();
+ }
+
+ return S_OK;
}
HRESULT CMatroskaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
{
- CheckPointer(pAsyncReader, E_POINTER);
-
- HRESULT hr = E_FAIL;
-
- m_pFile.Free();
- m_pTrackEntryMap.RemoveAll();
- m_pOrderedTrackArray.RemoveAll();
-
- CAtlArray<CMatroskaSplitterOutputPin*> pinOut;
- CAtlArray<TrackEntry*> pinOutTE;
-
- m_pFile.Attach(DNew CMatroskaFile(pAsyncReader, hr));
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration = 0;
-
- int iVideo = 1, iAudio = 1, iSubtitle = 1;
- bool bHasVideo = 0;
-
- POSITION pos = m_pFile->m_segment.Tracks.GetHeadPosition();
- while (pos) {
- Track* pT = m_pFile->m_segment.Tracks.GetNext(pos);
-
- POSITION pos2 = pT->TrackEntries.GetHeadPosition();
- while (pos2) {
- TrackEntry* pTE = pT->TrackEntries.GetNext(pos2);
-
- bool isSub = false;
-
- if (!pTE->Expand(pTE->CodecPrivate, ContentEncoding::TracksPrivateData)) {
- continue;
- }
-
- CStringA CodecID = pTE->CodecID.ToString();
-
- CStringW Name;
- Name.Format(L"Output %I64d", (UINT64)pTE->TrackNumber);
-
- CMediaType mt;
- CAtlArray<CMediaType> mts;
-
- mt.SetSampleSize(1);
-
- if (pTE->TrackType == TrackEntry::TypeVideo) {
- Name.Format(L"Video %d", iVideo++);
-
- mt.majortype = MEDIATYPE_Video;
-
- if (CodecID == "V_MS/VFW/FOURCC") {
- mt.formattype = FORMAT_VideoInfo;
- VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + pTE->CodecPrivate.GetCount() - sizeof(BITMAPINFOHEADER));
- memset(mt.Format(), 0, mt.FormatLength());
- memcpy(&pvih->bmiHeader, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- mt.subtype = FOURCCMap(pvih->bmiHeader.biCompression);
- switch (pvih->bmiHeader.biCompression) {
- case BI_RGB:
- case BI_BITFIELDS:
- mt.subtype =
- pvih->bmiHeader.biBitCount == 1 ? MEDIASUBTYPE_RGB1 :
- pvih->bmiHeader.biBitCount == 4 ? MEDIASUBTYPE_RGB4 :
- pvih->bmiHeader.biBitCount == 8 ? MEDIASUBTYPE_RGB8 :
- pvih->bmiHeader.biBitCount == 16 ? MEDIASUBTYPE_RGB565 :
- pvih->bmiHeader.biBitCount == 24 ? MEDIASUBTYPE_RGB24 :
- pvih->bmiHeader.biBitCount == 32 ? MEDIASUBTYPE_ARGB32 :
- MEDIASUBTYPE_NULL;
- break;
- // case BI_RLE8: mt.subtype = MEDIASUBTYPE_RGB8; break;
- // case BI_RLE4: mt.subtype = MEDIASUBTYPE_RGB4; break;
- }
- if (!bHasVideo) {
- mts.Add(mt);
- if (mt.subtype == MEDIASUBTYPE_WVC1) {
- mt.subtype = MEDIASUBTYPE_WVC1_CYBERLINK;
- mts.Add(mt);
- }
- }
- bHasVideo = true;
- } else if (CodecID == "V_UNCOMPRESSED") {
- } else if (CodecID.Find("V_MPEG4/ISO/AVC") == 0 && pTE->CodecPrivate.GetCount() >= 6) {
- BYTE sps = pTE->CodecPrivate[5] & 0x1f;
-
- std::vector<BYTE> avcC;
- for (size_t i = 0, j = pTE->CodecPrivate.GetCount(); i < j; i++) {
- avcC.push_back(pTE->CodecPrivate[i]);
- }
-
- std::vector<BYTE> sh;
-
- unsigned jj = 6;
-
- while (sps--) {
- if (jj + 2 > avcC.size()) {
- goto avcfail;
- }
- unsigned spslen = ((unsigned)avcC[jj] << 8) | avcC[jj+1];
- if (jj + 2 + spslen > avcC.size()) {
- goto avcfail;
- }
- unsigned cur = sh.size();
- sh.resize(cur + spslen + 2, 0);
- std::copy(avcC.begin() + jj, avcC.begin() + jj + 2 + spslen,sh.begin() + cur);
- jj += 2 + spslen;
- }
-
- if (jj + 1 > avcC.size()) {
- continue;
- }
-
- unsigned pps = avcC[jj++];
-
- while (pps--) {
- if (jj + 2 > avcC.size()) {
- goto avcfail;
- }
- unsigned ppslen = ((unsigned)avcC[jj] << 8) | avcC[jj+1];
- if (jj + 2 + ppslen > avcC.size()) {
- goto avcfail;
- }
- unsigned cur = sh.size();
- sh.resize(cur + ppslen + 2, 0);
- std::copy(avcC.begin() + jj, avcC.begin() + jj + 2 + ppslen, sh.begin() + cur);
- jj += 2 + ppslen;
- }
-
- goto avcsuccess;
+ CheckPointer(pAsyncReader, E_POINTER);
+
+ HRESULT hr = E_FAIL;
+
+ m_pFile.Free();
+ m_pTrackEntryMap.RemoveAll();
+ m_pOrderedTrackArray.RemoveAll();
+
+ CAtlArray<CMatroskaSplitterOutputPin*> pinOut;
+ CAtlArray<TrackEntry*> pinOutTE;
+
+ m_pFile.Attach(DNew CMatroskaFile(pAsyncReader, hr));
+ if (!m_pFile) {
+ return E_OUTOFMEMORY;
+ }
+ if (FAILED(hr)) {
+ m_pFile.Free();
+ return hr;
+ }
+
+ m_rtNewStart = m_rtCurrent = 0;
+ m_rtNewStop = m_rtStop = m_rtDuration = 0;
+
+ int iVideo = 1, iAudio = 1, iSubtitle = 1;
+ bool bHasVideo = 0;
+
+ POSITION pos = m_pFile->m_segment.Tracks.GetHeadPosition();
+ while (pos) {
+ Track* pT = m_pFile->m_segment.Tracks.GetNext(pos);
+
+ POSITION pos2 = pT->TrackEntries.GetHeadPosition();
+ while (pos2) {
+ TrackEntry* pTE = pT->TrackEntries.GetNext(pos2);
+
+ bool isSub = false;
+
+ if (!pTE->Expand(pTE->CodecPrivate, ContentEncoding::TracksPrivateData)) {
+ continue;
+ }
+
+ CStringA CodecID = pTE->CodecID.ToString();
+
+ CStringW Name;
+ Name.Format(L"Output %I64d", (UINT64)pTE->TrackNumber);
+
+ CMediaType mt;
+ CAtlArray<CMediaType> mts;
+
+ mt.SetSampleSize(1);
+
+ if (pTE->TrackType == TrackEntry::TypeVideo) {
+ Name.Format(L"Video %d", iVideo++);
+
+ mt.majortype = MEDIATYPE_Video;
+
+ if (CodecID == "V_MS/VFW/FOURCC") {
+ mt.formattype = FORMAT_VideoInfo;
+ VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + pTE->CodecPrivate.GetCount() - sizeof(BITMAPINFOHEADER));
+ memset(mt.Format(), 0, mt.FormatLength());
+ memcpy(&pvih->bmiHeader, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
+ mt.subtype = FOURCCMap(pvih->bmiHeader.biCompression);
+ switch (pvih->bmiHeader.biCompression) {
+ case BI_RGB:
+ case BI_BITFIELDS:
+ mt.subtype =
+ pvih->bmiHeader.biBitCount == 1 ? MEDIASUBTYPE_RGB1 :
+ pvih->bmiHeader.biBitCount == 4 ? MEDIASUBTYPE_RGB4 :
+ pvih->bmiHeader.biBitCount == 8 ? MEDIASUBTYPE_RGB8 :
+ pvih->bmiHeader.biBitCount == 16 ? MEDIASUBTYPE_RGB565 :
+ pvih->bmiHeader.biBitCount == 24 ? MEDIASUBTYPE_RGB24 :
+ pvih->bmiHeader.biBitCount == 32 ? MEDIASUBTYPE_ARGB32 :
+ MEDIASUBTYPE_NULL;
+ break;
+ // case BI_RLE8: mt.subtype = MEDIASUBTYPE_RGB8; break;
+ // case BI_RLE4: mt.subtype = MEDIASUBTYPE_RGB4; break;
+ }
+ if (!bHasVideo) {
+ mts.Add(mt);
+ if (mt.subtype == MEDIASUBTYPE_WVC1) {
+ mt.subtype = MEDIASUBTYPE_WVC1_CYBERLINK;
+ mts.Add(mt);
+ }
+ }
+ bHasVideo = true;
+ } else if (CodecID == "V_UNCOMPRESSED") {
+ } else if (CodecID.Find("V_MPEG4/ISO/AVC") == 0 && pTE->CodecPrivate.GetCount() >= 6) {
+ BYTE sps = pTE->CodecPrivate[5] & 0x1f;
+
+ std::vector<BYTE> avcC;
+ for (size_t i = 0, j = pTE->CodecPrivate.GetCount(); i < j; i++) {
+ avcC.push_back(pTE->CodecPrivate[i]);
+ }
+
+ std::vector<BYTE> sh;
+
+ unsigned jj = 6;
+
+ while (sps--) {
+ if (jj + 2 > avcC.size()) {
+ goto avcfail;
+ }
+ unsigned spslen = ((unsigned)avcC[jj] << 8) | avcC[jj + 1];
+ if (jj + 2 + spslen > avcC.size()) {
+ goto avcfail;
+ }
+ unsigned cur = sh.size();
+ sh.resize(cur + spslen + 2, 0);
+ std::copy(avcC.begin() + jj, avcC.begin() + jj + 2 + spslen, sh.begin() + cur);
+ jj += 2 + spslen;
+ }
+
+ if (jj + 1 > avcC.size()) {
+ continue;
+ }
+
+ unsigned pps = avcC[jj++];
+
+ while (pps--) {
+ if (jj + 2 > avcC.size()) {
+ goto avcfail;
+ }
+ unsigned ppslen = ((unsigned)avcC[jj] << 8) | avcC[jj + 1];
+ if (jj + 2 + ppslen > avcC.size()) {
+ goto avcfail;
+ }
+ unsigned cur = sh.size();
+ sh.resize(cur + ppslen + 2, 0);
+ std::copy(avcC.begin() + jj, avcC.begin() + jj + 2 + ppslen, sh.begin() + cur);
+ jj += 2 + ppslen;
+ }
+
+ goto avcsuccess;
avcfail:
- continue;
+ continue;
avcsuccess:
- CAtlArray<BYTE> data;
- data.SetCount(sh.size());
- std::copy(sh.begin(), sh.end(), data.GetData());
-
- mt.subtype = FOURCCMap('1CVA');
- mt.formattype = FORMAT_MPEG2Video;
- MPEG2VIDEOINFO* pm2vi = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + data.GetCount());
- memset(mt.Format(), 0, mt.FormatLength());
- pm2vi->hdr.bmiHeader.biSize = sizeof(pm2vi->hdr.bmiHeader);
- pm2vi->hdr.bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
- pm2vi->hdr.bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
- pm2vi->hdr.bmiHeader.biCompression = '1CVA';
- pm2vi->hdr.bmiHeader.biPlanes = 1;
- pm2vi->hdr.bmiHeader.biBitCount = 24;
- pm2vi->dwProfile = pTE->CodecPrivate[1];
- pm2vi->dwLevel = pTE->CodecPrivate[3];
- pm2vi->dwFlags = (pTE->CodecPrivate[4] & 3) + 1;
- BYTE* pSequenceHeader = (BYTE*)pm2vi->dwSequenceHeader;
- memcpy(pSequenceHeader, data.GetData(), data.GetCount());
- pm2vi->cbSequenceHeader = (DWORD)data.GetCount();
- if (!bHasVideo)
- mts.Add(mt);
- bHasVideo = true;
- } else if (CodecID.Find("V_MPEG4/") == 0) {
- mt.subtype = FOURCCMap('V4PM');
- mt.formattype = FORMAT_MPEG2Video;
- MPEG2VIDEOINFO* pm2vi = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + pTE->CodecPrivate.GetCount());
- memset(mt.Format(), 0, mt.FormatLength());
- pm2vi->hdr.bmiHeader.biSize = sizeof(pm2vi->hdr.bmiHeader);
- pm2vi->hdr.bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
- pm2vi->hdr.bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
- pm2vi->hdr.bmiHeader.biCompression = 'V4PM';
- pm2vi->hdr.bmiHeader.biPlanes = 1;
- pm2vi->hdr.bmiHeader.biBitCount = 24;
- BYTE* pSequenceHeader = (BYTE*)pm2vi->dwSequenceHeader;
- memcpy(pSequenceHeader, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- pm2vi->cbSequenceHeader = (DWORD)pTE->CodecPrivate.GetCount();
- if (!bHasVideo)
- mts.Add(mt);
- bHasVideo = true;
- } else if (CodecID.Find("V_REAL/RV") == 0) {
- mt.subtype = FOURCCMap('00VR' + ((CodecID[9]-0x30)<<16));
- mt.formattype = FORMAT_VideoInfo;
- VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + pTE->CodecPrivate.GetCount());
- memset(mt.Format(), 0, mt.FormatLength());
- memcpy(mt.Format() + sizeof(VIDEOINFOHEADER), pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- pvih->bmiHeader.biSize = sizeof(pvih->bmiHeader);
- pvih->bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
- pvih->bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
- pvih->bmiHeader.biCompression = mt.subtype.Data1;
- if (!bHasVideo)
- mts.Add(mt);
- bHasVideo = true;
- } else if (CodecID == "V_DIRAC") {
- mt.subtype = MEDIASUBTYPE_DiracVideo;
- mt.formattype = FORMAT_DiracVideoInfo;
- DIRACINFOHEADER* dvih = (DIRACINFOHEADER*)mt.AllocFormatBuffer(FIELD_OFFSET(DIRACINFOHEADER, dwSequenceHeader) + pTE->CodecPrivate.GetCount());
- memset(mt.Format(), 0, mt.FormatLength());
- dvih->hdr.bmiHeader.biSize = sizeof(dvih->hdr.bmiHeader);
- dvih->hdr.bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
- dvih->hdr.bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
- dvih->hdr.dwPictAspectRatioX = dvih->hdr.bmiHeader.biWidth;
- dvih->hdr.dwPictAspectRatioY = dvih->hdr.bmiHeader.biHeight;
-
- BYTE* pSequenceHeader = (BYTE*)dvih->dwSequenceHeader;
- memcpy(pSequenceHeader, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- dvih->cbSequenceHeader = (DWORD)pTE->CodecPrivate.GetCount();
-
- if (!bHasVideo)
- mts.Add(mt);
- bHasVideo = true;
- } else if (CodecID == "V_MPEG2") {
- BYTE* seqhdr = pTE->CodecPrivate.GetData();
- DWORD len = (DWORD)pTE->CodecPrivate.GetCount();
- int w = (int)pTE->v.PixelWidth;
- int h = (int)pTE->v.PixelHeight;
-
- if (MakeMPEG2MediaType(mt, seqhdr, len, w, h)) {
- if (!bHasVideo)
- mts.Add(mt);
- bHasVideo = true;
- }
- } else if (CodecID == "V_THEORA") {
- BYTE* thdr = pTE->CodecPrivate.GetData() + 3;
-
- mt.majortype = MEDIATYPE_Video;
- mt.subtype = FOURCCMap('OEHT');
- mt.formattype = FORMAT_MPEG2_VIDEO;
- MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(sizeof(MPEG2VIDEOINFO) + pTE->CodecPrivate.GetCount());
- memset(mt.Format(), 0, mt.FormatLength());
- vih->hdr.bmiHeader.biSize = sizeof(vih->hdr.bmiHeader);
- vih->hdr.bmiHeader.biWidth = *(WORD*)&thdr[10] >> 4;
- vih->hdr.bmiHeader.biHeight = *(WORD*)&thdr[12] >> 4;
- vih->hdr.bmiHeader.biCompression = 'OEHT';
- vih->hdr.bmiHeader.biPlanes = 1;
- vih->hdr.bmiHeader.biBitCount = 24;
- int nFpsNum = (thdr[22]<<24)|(thdr[23]<<16)|(thdr[24]<<8)|thdr[25];
- int nFpsDenum = (thdr[26]<<24)|(thdr[27]<<16)|(thdr[28]<<8)|thdr[29];
- if (nFpsNum) {
- vih->hdr.AvgTimePerFrame = (REFERENCE_TIME)(10000000.0 * nFpsDenum / nFpsNum);
- }
- vih->hdr.dwPictAspectRatioX = (thdr[14]<<16)|(thdr[15]<<8)|thdr[16];
- vih->hdr.dwPictAspectRatioY = (thdr[17]<<16)|(thdr[18]<<8)|thdr[19];
- mt.bFixedSizeSamples = 0;
-
- vih->cbSequenceHeader = (DWORD)pTE->CodecPrivate.GetCount();
- memcpy (&vih->dwSequenceHeader, pTE->CodecPrivate.GetData(), vih->cbSequenceHeader);
-
- if (!bHasVideo)
- mts.Add(mt);
- bHasVideo = true;
- } else if (CodecID.Find("V_VP8") == 0) {
- mt.subtype = FOURCCMap('08PV');
- mt.formattype = FORMAT_VideoInfo;
- VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + pTE->CodecPrivate.GetCount());
- memset(mt.Format(), 0, mt.FormatLength());
- memcpy(mt.Format() + sizeof(VIDEOINFOHEADER), pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- pvih->bmiHeader.biSize = sizeof(pvih->bmiHeader);
- pvih->bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
- pvih->bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
- pvih->bmiHeader.biCompression = mt.subtype.Data1;
- if (!bHasVideo)
- mts.Add(mt);
- bHasVideo = true;
- } else if (CodecID == "V_QUICKTIME" && pTE->CodecPrivate.GetCount() >= 8) {
- DWORD* type;
- if (m_pFile->m_ebml.DocTypeReadVersion == 1) {
- type = (DWORD*)(pTE->CodecPrivate.GetData());
- } else {
- type = (DWORD*)(pTE->CodecPrivate.GetData() + 4);
- }
- if (*type == MAKEFOURCC('S','V','Q','3') || *type == MAKEFOURCC('S','V','Q','1') || *type == MAKEFOURCC('c','v','i','d')) {
- mt.subtype = FOURCCMap(*type);
- mt.formattype = FORMAT_VideoInfo;
- VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + pTE->CodecPrivate.GetCount());
- memset(mt.Format(), 0, mt.FormatLength());
- memcpy(mt.Format() + sizeof(VIDEOINFOHEADER), pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- pvih->bmiHeader.biSize = sizeof(pvih->bmiHeader);
- pvih->bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
- pvih->bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
- pvih->bmiHeader.biCompression = mt.subtype.Data1;
- if (!bHasVideo)
- mts.Add(mt);
- bHasVideo = true;
- }
- } else if (CodecID == "V_DSHOW/MPEG1VIDEO" || CodecID == "V_MPEG1") {
- mt.majortype = MEDIATYPE_Video;
- mt.subtype = MEDIASUBTYPE_MPEG1Payload;
- mt.formattype = FORMAT_MPEGVideo;
-
- MPEG1VIDEOINFO* pm1vi = (MPEG1VIDEOINFO*)mt.AllocFormatBuffer(sizeof(MPEG1VIDEOINFO) + pTE->CodecPrivate.GetCount());
- memset(mt.Format(), 0, mt.FormatLength());
- memcpy(mt.Format() + sizeof(MPEG1VIDEOINFO), pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
-
- pm1vi->hdr.bmiHeader.biSize = sizeof(pm1vi->hdr.bmiHeader);
- pm1vi->hdr.bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
- pm1vi->hdr.bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
- pm1vi->hdr.bmiHeader.biBitCount = 12;
- pm1vi->hdr.bmiHeader.biSizeImage = DIBSIZE(pm1vi->hdr.bmiHeader);
-
- mt.SetSampleSize(pm1vi->hdr.bmiHeader.biWidth*pm1vi->hdr.bmiHeader.biHeight*4);
- if (!bHasVideo)
- mts.Add(mt);
- bHasVideo = true;
- }
- REFERENCE_TIME AvgTimePerFrame = 0;
-
- if (pTE->v.FramePerSec > 0) {
- AvgTimePerFrame = (REFERENCE_TIME)(10000000i64 / pTE->v.FramePerSec);
- } else if (pTE->DefaultDuration > 0 && pTE->DefaultDuration != 1000000) {
- AvgTimePerFrame = (REFERENCE_TIME)pTE->DefaultDuration / 100;
- } else { // pTE->DefaultDuration == 1000000 or < 0
- CMatroskaNode Root(m_pFile);
- m_pSegment = Root.Child(0x18538067);
- m_pCluster = m_pSegment->Child(0x1F43B675);
-
- MatroskaReader::QWORD lastCueClusterPosition = (MatroskaReader::QWORD)-1;
- UINT64 timecode1 = -1;
- UINT64 timecode2 = -1;
- unsigned int framecount = 0;
- bool readmore = true;
-
- POSITION pos1 = m_pFile->m_segment.Cues.GetHeadPosition();
- while (readmore && pos1) {
- Cue* pCue = m_pFile->m_segment.Cues.GetNext(pos1);
- POSITION pos2 = pCue->CuePoints.GetHeadPosition();
- while (readmore && pos2) {
- CuePoint* pCuePoint = pCue->CuePoints.GetNext(pos2);
- POSITION pos3 = pCuePoint->CueTrackPositions.GetHeadPosition();
- while (readmore && pos3) {
- CueTrackPosition* pCueTrackPositions = pCuePoint->CueTrackPositions.GetNext(pos3);
- if (pCueTrackPositions->CueTrack != pTE->TrackNumber) {
- continue;
- }
-
- if (lastCueClusterPosition == pCueTrackPositions->CueClusterPosition) {
- continue;
- }
- lastCueClusterPosition = pCueTrackPositions->CueClusterPosition;
-
- m_pCluster->SeekTo(m_pSegment->m_start + pCueTrackPositions->CueClusterPosition);
- m_pCluster->Parse();
-
- Cluster c;
- c.ParseTimeCode(m_pCluster);
-
- if (CAutoPtr<CMatroskaNode> pBlock = m_pCluster->GetFirstBlock()) {
- do {
- CBlockGroupNode bgn;
-
- if (pBlock->m_id == 0xA0) {
- bgn.Parse(pBlock, true);
- } else if (pBlock->m_id == 0xA3) {
- CAutoPtr<BlockGroup> bg(DNew BlockGroup());
- bg->Block.Parse(pBlock, true);
- if (!(bg->Block.Lacing & 0x80)) {
- bg->ReferenceBlock.Set(0); // not a kf
- }
- bgn.AddTail(bg);
- }
-
- POSITION pos4 = bgn.GetHeadPosition();
- while (pos4) {
- BlockGroup* bg = bgn.GetNext(pos4);
- if (bg->Block.TrackNumber != pTE->TrackNumber) {
- continue;
- }
- UINT64 tc = c.TimeCode + bg->Block.TimeCode;
- if (tc == timecode2) {
- continue;
- }
-
- if (timecode1 == -1) {
- timecode1 = tc;
- } else {
- timecode2 = tc;
- ++framecount;
- }
-
- if (framecount >= 24) {
- // good for 23.976, 24, 25, 30, 50, 60 fps.
- // for 29.97 and 59,94 can give a small inaccuracy
- readmore = false;
- break;
- }
- }
- } while (readmore && pBlock->NextBlock());
- }
- }
- }
- }
- if (framecount) {
- AvgTimePerFrame = m_pFile->m_segment.SegmentInfo.TimeCodeScale*(timecode2 - timecode1) / (100*framecount);
- }
-
- m_pCluster.Free();
- }
- //if (AvgTimePerFrame < 0) AvgTimePerFrame = 0;
-
- for (size_t i = 0; i < mts.GetCount(); i++) {
- if (mts[i].formattype == FORMAT_VideoInfo
- || mts[i].formattype == FORMAT_VideoInfo2
- || mts[i].formattype == FORMAT_MPEG2Video
- || mts[i].formattype == FORMAT_MPEGVideo) {
- if (pTE->v.PixelWidth && pTE->v.PixelHeight) {
- RECT rect = {(LONG)pTE->v.VideoPixelCropLeft,
- (LONG)pTE->v.VideoPixelCropTop,
- (LONG)(pTE->v.PixelWidth - pTE->v.VideoPixelCropRight),
- (LONG)(pTE->v.PixelHeight - pTE->v.VideoPixelCropBottom)
- };
- VIDEOINFOHEADER *vih = (VIDEOINFOHEADER*)mts[i].Format();
- vih->rcSource = vih->rcTarget = rect;
- }
-
- if (AvgTimePerFrame) {
- if (mts[i].subtype == MEDIASUBTYPE_MPEG1Payload) {
- AvgTimePerFrame *= 2; // Need more testing, but work on all sample that i have :)
- }
- ((VIDEOINFOHEADER*)mts[i].Format())->AvgTimePerFrame = AvgTimePerFrame;
- }
- }
- }
-
- if (pTE->v.DisplayWidth && pTE->v.DisplayHeight) {
- for (size_t i = 0; i < mts.GetCount(); i++) {
- if (mts[i].formattype == FORMAT_VideoInfo) {
- mt = mts[i];
- DWORD vih1 = FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader);
- DWORD vih2 = FIELD_OFFSET(VIDEOINFOHEADER2, bmiHeader);
- DWORD bmi = mts[i].FormatLength() - FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader);
- mt.formattype = FORMAT_VideoInfo2;
- mt.AllocFormatBuffer(vih2 + bmi);
- memcpy(mt.Format(), mts[i].Format(), vih1);
- memset(mt.Format() + vih1, 0, vih2 - vih1);
- memcpy(mt.Format() + vih2, mts[i].Format() + vih1, bmi);
-
- CSize aspect((int)pTE->v.DisplayWidth, (int)pTE->v.DisplayHeight);
- int lnko = LNKO(aspect.cx, aspect.cy);
- if (lnko > 1) {
- aspect.cx /= lnko, aspect.cy /= lnko;
- }
- ((VIDEOINFOHEADER2*)mt.Format())->dwPictAspectRatioX = aspect.cx;
- ((VIDEOINFOHEADER2*)mt.Format())->dwPictAspectRatioY = aspect.cy;
- mts.InsertAt(i++, mt);
- } else if (mts[i].formattype == FORMAT_MPEG2Video) {
- CSize aspect((int)pTE->v.DisplayWidth, (int)pTE->v.DisplayHeight);
- int lnko = LNKO(aspect.cx, aspect.cy);
- if (lnko > 1) {
- aspect.cx /= lnko, aspect.cy /= lnko;
- }
- ((MPEG2VIDEOINFO*)mts[i].Format())->hdr.dwPictAspectRatioX = aspect.cx;
- ((MPEG2VIDEOINFO*)mts[i].Format())->hdr.dwPictAspectRatioY = aspect.cy;
- }
- }
- }
- } else if (pTE->TrackType == TrackEntry::TypeAudio) {
- Name.Format(L"Audio %d", iAudio++);
-
- mt.majortype = MEDIATYPE_Audio;
- mt.formattype = FORMAT_WaveFormatEx;
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX));
- memset(wfe, 0, mt.FormatLength());
- wfe->nChannels = (WORD)pTE->a.Channels;
- wfe->nSamplesPerSec = (DWORD)pTE->a.SamplingFrequency;
- wfe->wBitsPerSample = (WORD)pTE->a.BitDepth;
- wfe->nBlockAlign = (WORD)((wfe->nChannels * wfe->wBitsPerSample) / 8);
- wfe->nAvgBytesPerSec = wfe->nSamplesPerSec * wfe->nBlockAlign;
- mt.SetSampleSize(256000);
-
- if (CodecID == "A_MPEG/L3") {
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_MPEGLAYER3);
- mts.Add(mt);
- } else if (CodecID == "A_MPEG/L2" ||
- CodecID == "A_MPEG/L1") {
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_MPEG);
- mts.Add(mt);
- } else if (CodecID == "A_AC3" ||
- CodecID == "A_EAC3") {
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_DOLBY_AC3);
- mts.Add(mt);
- } else if (CodecID == "A_TRUEHD" ||
- CodecID == "A_MLP") {
- wfe->wFormatTag = WAVE_FORMAT_DOLBY_AC3;
- mt.subtype = MEDIASUBTYPE_DOLBY_TRUEHD;
- mts.Add(mt);
- } else if (CodecID == "A_DTS") {
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_DVD_DTS);
- mts.Add(mt);
- } else if (CodecID == "A_TTA1") {
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_TTA1);
- wfe->cbSize = 30;
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + 30);
- BYTE *p = (BYTE *)(wfe + 1);
- memcpy(p, (const unsigned char *)"TTA1\x01\x00", 6);
- memcpy(p + 6, &wfe->nChannels, 2);
- memcpy(p + 8, &wfe->wBitsPerSample, 2);
- memcpy(p + 10, &wfe->nSamplesPerSec, 4);
- memset(p + 14, 0, 30 - 14);
- mts.Add(mt);
- } else if (CodecID == "A_AAC") {
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_AAC);
- wfe->cbSize = (WORD)pTE->CodecPrivate.GetCount();
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + pTE->CodecPrivate.GetCount());
- memcpy(wfe + 1, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- mts.Add(mt);
- } else if (CodecID == "A_WAVPACK4") {
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_WAVPACK4);
- wfe->cbSize = (WORD)pTE->CodecPrivate.GetCount();
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + pTE->CodecPrivate.GetCount());
- memcpy(wfe + 1, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- mts.Add(mt);
- } else if (CodecID == "A_FLAC") {
- wfe->wFormatTag = WAVE_FORMAT_FLAC;
- wfe->cbSize = (WORD)pTE->CodecPrivate.GetCount();
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + pTE->CodecPrivate.GetCount());
- memcpy(wfe + 1, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
-
- mt.subtype = MEDIASUBTYPE_FLAC_FRAMED;
- mts.Add(mt);
- mt.subtype = MEDIASUBTYPE_FLAC;
- mts.Add(mt);
- } else if (CodecID == "A_PCM/INT/LIT") {
- mt.subtype = MEDIASUBTYPE_PCM;
- mt.SetSampleSize(wfe->nBlockAlign);
- if (pTE->a.Channels <= 2 && pTE->a.BitDepth <= 16) {
- wfe->wFormatTag = WAVE_FORMAT_PCM;
- } else {
- WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEXTENSIBLE));
- if (pTE->a.BitDepth&7) {
- wfex->Format.wBitsPerSample = (WORD)(pTE->a.BitDepth + 7) & 0xFFF8;
- wfex->Format.nBlockAlign = wfex->Format.nChannels * wfex->Format.wBitsPerSample / 8;
- wfex->Format.nAvgBytesPerSec = wfex->Format.nSamplesPerSec * wfex->Format.nBlockAlign;
- mt.SetSampleSize(wfex->Format.nBlockAlign);
- }
- wfex->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
- wfex->Format.cbSize = 22;
- wfex->Samples.wValidBitsPerSample = (WORD)pTE->a.BitDepth;
- wfex->dwChannelMask = GetDefChannelMask(wfex->Format.nChannels);
- wfex->SubFormat = MEDIASUBTYPE_PCM;
- }
- mts.Add(mt);
- } else if (CodecID == "A_PCM/FLOAT/IEEE") {
- mt.subtype = MEDIASUBTYPE_IEEE_FLOAT;
- mt.SetSampleSize(wfe->nBlockAlign);
- if (pTE->a.Channels <= 2) {
- wfe->wFormatTag = WAVE_FORMAT_IEEE_FLOAT;
- } else {
- WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEXTENSIBLE));
- wfex->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
- wfex->Format.cbSize = 22;
- wfex->Samples.wValidBitsPerSample = (WORD)pTE->a.BitDepth;
- wfex->dwChannelMask = GetDefChannelMask(wfex->Format.nChannels);
- wfex->SubFormat = MEDIASUBTYPE_IEEE_FLOAT;
- }
- mts.Add(mt);
- } else if (CodecID == "A_MS/ACM") {
- wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(pTE->CodecPrivate.GetCount());
- memcpy(wfe, (WAVEFORMATEX*)pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- if (wfe->wFormatTag == WAVE_FORMAT_EXTENSIBLE && wfe->cbSize == 22) {
- mt.subtype = ((WAVEFORMATEXTENSIBLE*)wfe)->SubFormat;
- }
- else mt.subtype = FOURCCMap(wfe->wFormatTag);
- mts.Add(mt);
- } else if (CodecID == "A_VORBIS") {
- BYTE* p = pTE->CodecPrivate.GetData();
- CAtlArray<int> sizes;
- int totalsize = 0;
- for (BYTE n = *p++; n > 0; n--) {
- int size = 0;
- do {
- size += *p;
- } while (*p++ == 0xff);
- sizes.Add(size);
- totalsize += size;
- }
- sizes.Add(pTE->CodecPrivate.GetCount() - (p - pTE->CodecPrivate.GetData()) - totalsize);
- totalsize += sizes[sizes.GetCount()-1];
-
- if (sizes.GetCount() == 3) {
- mt.subtype = MEDIASUBTYPE_Vorbis2;
- mt.formattype = FORMAT_VorbisFormat2;
- VORBISFORMAT2* pvf2 = (VORBISFORMAT2*)mt.AllocFormatBuffer(sizeof(VORBISFORMAT2) + totalsize);
- memset(pvf2, 0, mt.FormatLength());
- pvf2->Channels = (WORD)pTE->a.Channels;
- pvf2->SamplesPerSec = (DWORD)pTE->a.SamplingFrequency;
- pvf2->BitsPerSample = (DWORD)pTE->a.BitDepth;
- BYTE* p2 = mt.Format() + sizeof(VORBISFORMAT2);
- for (size_t i = 0; i < sizes.GetCount(); p += sizes[i], p2 += sizes[i], i++) {
- memcpy(p2, p, pvf2->HeaderSize[i] = sizes[i]);
- }
-
- mts.Add(mt);
- }
-
- mt.subtype = MEDIASUBTYPE_Vorbis;
- mt.formattype = FORMAT_VorbisFormat;
- VORBISFORMAT* vf = (VORBISFORMAT*)mt.AllocFormatBuffer(sizeof(VORBISFORMAT));
- memset(vf, 0, mt.FormatLength());
- vf->nChannels = (WORD)pTE->a.Channels;
- vf->nSamplesPerSec = (DWORD)pTE->a.SamplingFrequency;
- vf->nMinBitsPerSec = vf->nMaxBitsPerSec = vf->nAvgBitsPerSec = (DWORD)-1;
- mts.Add(mt);
- } else if (CodecID.Find("A_AAC/") == 0) {
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_AAC);
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + 5);
- wfe->cbSize = 2;
-
- int profile;
-
- if (CodecID.Find("/MAIN") > 0) {
- profile = 0;
- } else if (CodecID.Find("/SBR") > 0) {
- profile = -1;
- } else if (CodecID.Find("/LC") > 0) {
- profile = 1;
- } else if (CodecID.Find("/SSR") > 0) {
- profile = 2;
- } else if (CodecID.Find("/LTP") > 0) {
- profile = 3;
- } else {
- continue;
- }
-
- WORD cbSize = MakeAACInitData((BYTE*)(wfe + 1), profile, wfe->nSamplesPerSec, (int)pTE->a.Channels);
-
- mts.Add(mt);
-
- if (profile < 0) {
- wfe->cbSize = cbSize;
- wfe->nSamplesPerSec *= 2;
- wfe->nAvgBytesPerSec *= 2;
-
- mts.InsertAt(0, mt);
- }
- } else if (CodecID.Find("A_REAL/") == 0 && CodecID.GetLength() >= 11) {
- mt.subtype = FOURCCMap((DWORD)CodecID[7]|((DWORD)CodecID[8]<<8)|((DWORD)CodecID[9]<<16)|((DWORD)CodecID[10]<<24));
- mt.bTemporalCompression = TRUE;
- wfe->cbSize = (WORD)pTE->CodecPrivate.GetCount();
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + pTE->CodecPrivate.GetCount());
- memcpy(wfe + 1, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- wfe->cbSize = 0; // IMPORTANT: this is screwed, but cbSize has to be 0 and the extra data from codec priv must be after WAVEFORMATEX
- mts.Add(mt);
- } else if (CodecID == "A_QUICKTIME" && pTE->CodecPrivate.GetCount() >= 8) {
- DWORD* type = (DWORD*)(pTE->CodecPrivate.GetData() + 4);
- if (*type == MAKEFOURCC('Q','D','M','2') || *type == MAKEFOURCC('Q','D','M','C')) {
- mt.subtype = FOURCCMap(*type);
- wfe->cbSize = (WORD)pTE->CodecPrivate.GetCount();
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + pTE->CodecPrivate.GetCount());
- memcpy(wfe + 1, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- mts.Add(mt);
- }
- }
- } else if (pTE->TrackType == TrackEntry::TypeSubtitle) {
- if (iSubtitle == 1) {
- InstallFonts();
- }
-
- Name.Format(L"Subtitle %d", iSubtitle++);
-
- mt.SetSampleSize(1);
-
- if (CodecID == "S_TEXT/ASCII") {
- mt.majortype = MEDIATYPE_Text;
- mt.subtype = MEDIASUBTYPE_NULL;
- mt.formattype = FORMAT_None;
- mts.Add(mt);
- isSub = true;
- } else {
- mt.majortype = MEDIATYPE_Subtitle;
- mt.formattype = FORMAT_SubtitleInfo;
- SUBTITLEINFO* psi = (SUBTITLEINFO*)mt.AllocFormatBuffer(sizeof(SUBTITLEINFO) + pTE->CodecPrivate.GetCount());
- memset(psi, 0, mt.FormatLength());
- strncpy_s(psi->IsoLang, pTE->Language, _countof(psi->IsoLang)-1);
- CString subtitle_Name = pTE->Name;
- if (pTE->FlagForced) { // "Forced" overrides "Default"
- subtitle_Name += L" [Forced]";
- } else if (pTE->FlagDefault) {
- subtitle_Name += L" [Default]";
- }
- subtitle_Name = subtitle_Name.Trim();
-
- wcsncpy_s(psi->TrackName, subtitle_Name, _countof(psi->TrackName)-1);
- memcpy(mt.pbFormat + (psi->dwOffset = sizeof(SUBTITLEINFO)), pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
-
- mt.subtype =
- CodecID == "S_TEXT/UTF8" ? MEDIASUBTYPE_UTF8 :
- CodecID == "S_TEXT/SSA" || CodecID == "S_SSA" ? MEDIASUBTYPE_SSA :
- CodecID == "S_TEXT/ASS" || CodecID == "S_ASS" ? MEDIASUBTYPE_ASS :
- CodecID == "S_TEXT/USF" || CodecID == "S_USF" ? MEDIASUBTYPE_USF :
- CodecID == "S_HDMV/PGS" ? MEDIASUBTYPE_HDMVSUB :
- //CodecID == "S_DVBSUB" ? MEDIASUBTYPE_DVB_SUBTITLES : // does not work
- CodecID == "S_VOBSUB" ? MEDIASUBTYPE_VOBSUB :
- MEDIASUBTYPE_NULL;
-
- if (mt.subtype != MEDIASUBTYPE_NULL) {
- mts.Add(mt);
- isSub = true;
- }
- }
- }
-
- if (mts.IsEmpty()) {
- TRACE(_T("CMatroskaSourceFilter: Unsupported TrackType %s (%I64d)\n"), CString(CodecID), (UINT64)pTE->TrackType);
- continue;
- }
-
- Name = CStringW(pTE->Language.IsEmpty() ? L"English" : CStringW(ISO6392ToLanguage(pTE->Language)))
- + (pTE->Name.IsEmpty() ? L"" : L", " + pTE->Name)
- + (L" (" + Name + L")");
-
- if (pTE->FlagForced) { // "Forced" overrides "Default"
- Name = Name + L" [Forced]";
- } else if (pTE->FlagDefault) {
- Name = Name + L" [Default]";
- }
-
- HRESULT hr;
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CMatroskaSplitterOutputPin(pTE->MinCache, pTE->DefaultDuration / 100, mts, Name, this, this, &hr));
- if (!pTE->Name.IsEmpty()) {
- pPinOut->SetProperty(L"NAME", pTE->Name);
- }
- if (pTE->Language.GetLength() == 3) {
- pPinOut->SetProperty(L"LANG", CStringW(CString(pTE->Language)));
- }
-
- if (!isSub) {
- pinOut.InsertAt((iVideo + iAudio - 3), DNew CMatroskaSplitterOutputPin(pTE->MinCache, pTE->DefaultDuration / 100, mts, Name, this, this, &hr), 1);
- pinOutTE.InsertAt((iVideo + iAudio - 3), pTE, 1);
- } else {
- pinOut.Add(DNew CMatroskaSplitterOutputPin(pTE->MinCache, pTE->DefaultDuration / 100, mts, Name, this, this, &hr));
- pinOutTE.Add(pTE);
- }
-
- }
- }
-
- for (size_t i = 0; i < pinOut.GetCount(); i++) {
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut;
- pPinOut.Attach(pinOut[i]);
- TrackEntry* pTE = pinOutTE[i];
-
- if (pTE != NULL) {
- AddOutputPin((DWORD)pTE->TrackNumber, pPinOut);
- m_pTrackEntryMap[(DWORD)pTE->TrackNumber] = pTE;
- m_pOrderedTrackArray.Add(pTE);
- }
- }
-
-
- Info& info = m_pFile->m_segment.SegmentInfo;
-
- if (m_pFile->IsRandomAccess()) {
- m_rtDuration = (REFERENCE_TIME)(info.Duration * info.TimeCodeScale / 100);
- }
-
- m_rtNewStop = m_rtStop = m_rtDuration;
-
-/*#ifdef _DEBUG
- for (int i = 1, j = GetChapterCount(CHAPTER_ROOT_ID); i <= j; i++)
- {
- UINT id = GetChapterId(CHAPTER_ROOT_ID, i);
- struct ChapterElement ce;
- BOOL b = GetChapterInfo(id, &ce);
- BSTR bstr = GetChapterStringInfo(id, "eng", "");
- if (bstr) ::SysFreeString(bstr);
- }
-#endif*/
-
- SetProperty(L"TITL", info.Title);
- // TODO
-
- // resources
-
- {
- POSITION pos = m_pFile->m_segment.Attachments.GetHeadPosition();
- while (pos) {
- Attachment* pA = m_pFile->m_segment.Attachments.GetNext(pos);
-
- POSITION pos = pA->AttachedFiles.GetHeadPosition();
- while (pos) {
- AttachedFile* pF = pA->AttachedFiles.GetNext(pos);
-
- CAtlArray<BYTE> pData;
- pData.SetCount((size_t)pF->FileDataLen);
- m_pFile->Seek(pF->FileDataPos);
- if (SUCCEEDED(m_pFile->ByteRead(pData.GetData(), pData.GetCount()))) {
- ResAppend(pF->FileName, pF->FileDescription, CStringW(pF->FileMimeType), pData.GetData(), (DWORD)pData.GetCount());
- }
- }
- }
- }
-
- // chapters
-
- if (ChapterAtom* caroot = m_pFile->m_segment.FindChapterAtom(0)) {
- CStringA str;
- str.ReleaseBufferSetLength(GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, str.GetBuffer(3), 3));
- CStringA ChapLanguage = CStringA(ISO6391To6392(str));
- if (ChapLanguage.GetLength() < 3) {
- ChapLanguage = "eng";
- }
-
- SetupChapters(ChapLanguage, caroot);
- }
-
- return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
+ CAtlArray<BYTE> data;
+ data.SetCount(sh.size());
+ std::copy(sh.begin(), sh.end(), data.GetData());
+
+ mt.subtype = FOURCCMap('1CVA');
+ mt.formattype = FORMAT_MPEG2Video;
+ MPEG2VIDEOINFO* pm2vi = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + data.GetCount());
+ memset(mt.Format(), 0, mt.FormatLength());
+ pm2vi->hdr.bmiHeader.biSize = sizeof(pm2vi->hdr.bmiHeader);
+ pm2vi->hdr.bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
+ pm2vi->hdr.bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
+ pm2vi->hdr.bmiHeader.biCompression = '1CVA';
+ pm2vi->hdr.bmiHeader.biPlanes = 1;
+ pm2vi->hdr.bmiHeader.biBitCount = 24;
+ pm2vi->dwProfile = pTE->CodecPrivate[1];
+ pm2vi->dwLevel = pTE->CodecPrivate[3];
+ pm2vi->dwFlags = (pTE->CodecPrivate[4] & 3) + 1;
+ BYTE* pSequenceHeader = (BYTE*)pm2vi->dwSequenceHeader;
+ memcpy(pSequenceHeader, data.GetData(), data.GetCount());
+ pm2vi->cbSequenceHeader = (DWORD)data.GetCount();
+ if (!bHasVideo) {
+ mts.Add(mt);
+ }
+ bHasVideo = true;
+ } else if (CodecID.Find("V_MPEG4/") == 0) {
+ mt.subtype = FOURCCMap('V4PM');
+ mt.formattype = FORMAT_MPEG2Video;
+ MPEG2VIDEOINFO* pm2vi = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + pTE->CodecPrivate.GetCount());
+ memset(mt.Format(), 0, mt.FormatLength());
+ pm2vi->hdr.bmiHeader.biSize = sizeof(pm2vi->hdr.bmiHeader);
+ pm2vi->hdr.bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
+ pm2vi->hdr.bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
+ pm2vi->hdr.bmiHeader.biCompression = 'V4PM';
+ pm2vi->hdr.bmiHeader.biPlanes = 1;
+ pm2vi->hdr.bmiHeader.biBitCount = 24;
+ BYTE* pSequenceHeader = (BYTE*)pm2vi->dwSequenceHeader;
+ memcpy(pSequenceHeader, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
+ pm2vi->cbSequenceHeader = (DWORD)pTE->CodecPrivate.GetCount();
+ if (!bHasVideo) {
+ mts.Add(mt);
+ }
+ bHasVideo = true;
+ } else if (CodecID.Find("V_REAL/RV") == 0) {
+ mt.subtype = FOURCCMap('00VR' + ((CodecID[9] - 0x30) << 16));
+ mt.formattype = FORMAT_VideoInfo;
+ VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + pTE->CodecPrivate.GetCount());
+ memset(mt.Format(), 0, mt.FormatLength());
+ memcpy(mt.Format() + sizeof(VIDEOINFOHEADER), pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
+ pvih->bmiHeader.biSize = sizeof(pvih->bmiHeader);
+ pvih->bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
+ pvih->bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
+ pvih->bmiHeader.biCompression = mt.subtype.Data1;
+ if (!bHasVideo) {
+ mts.Add(mt);
+ }
+ bHasVideo = true;
+ } else if (CodecID == "V_DIRAC") {
+ mt.subtype = MEDIASUBTYPE_DiracVideo;
+ mt.formattype = FORMAT_DiracVideoInfo;
+ DIRACINFOHEADER* dvih = (DIRACINFOHEADER*)mt.AllocFormatBuffer(FIELD_OFFSET(DIRACINFOHEADER, dwSequenceHeader) + pTE->CodecPrivate.GetCount());
+ memset(mt.Format(), 0, mt.FormatLength());
+ dvih->hdr.bmiHeader.biSize = sizeof(dvih->hdr.bmiHeader);
+ dvih->hdr.bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
+ dvih->hdr.bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
+ dvih->hdr.dwPictAspectRatioX = dvih->hdr.bmiHeader.biWidth;
+ dvih->hdr.dwPictAspectRatioY = dvih->hdr.bmiHeader.biHeight;
+
+ BYTE* pSequenceHeader = (BYTE*)dvih->dwSequenceHeader;
+ memcpy(pSequenceHeader, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
+ dvih->cbSequenceHeader = (DWORD)pTE->CodecPrivate.GetCount();
+
+ if (!bHasVideo) {
+ mts.Add(mt);
+ }
+ bHasVideo = true;
+ } else if (CodecID == "V_MPEG2") {
+ BYTE* seqhdr = pTE->CodecPrivate.GetData();
+ DWORD len = (DWORD)pTE->CodecPrivate.GetCount();
+ int w = (int)pTE->v.PixelWidth;
+ int h = (int)pTE->v.PixelHeight;
+
+ if (MakeMPEG2MediaType(mt, seqhdr, len, w, h)) {
+ if (!bHasVideo) {
+ mts.Add(mt);
+ }
+ bHasVideo = true;
+ }
+ } else if (CodecID == "V_THEORA") {
+ BYTE* thdr = pTE->CodecPrivate.GetData() + 3;
+
+ mt.majortype = MEDIATYPE_Video;
+ mt.subtype = FOURCCMap('OEHT');
+ mt.formattype = FORMAT_MPEG2_VIDEO;
+ MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(sizeof(MPEG2VIDEOINFO) + pTE->CodecPrivate.GetCount());
+ memset(mt.Format(), 0, mt.FormatLength());
+ vih->hdr.bmiHeader.biSize = sizeof(vih->hdr.bmiHeader);
+ vih->hdr.bmiHeader.biWidth = *(WORD*)&thdr[10] >> 4;
+ vih->hdr.bmiHeader.biHeight = *(WORD*)&thdr[12] >> 4;
+ vih->hdr.bmiHeader.biCompression = 'OEHT';
+ vih->hdr.bmiHeader.biPlanes = 1;
+ vih->hdr.bmiHeader.biBitCount = 24;
+ int nFpsNum = (thdr[22] << 24) | (thdr[23] << 16) | (thdr[24] << 8) | thdr[25];
+ int nFpsDenum = (thdr[26] << 24) | (thdr[27] << 16) | (thdr[28] << 8) | thdr[29];
+ if (nFpsNum) {
+ vih->hdr.AvgTimePerFrame = (REFERENCE_TIME)(10000000.0 * nFpsDenum / nFpsNum);
+ }
+ vih->hdr.dwPictAspectRatioX = (thdr[14] << 16) | (thdr[15] << 8) | thdr[16];
+ vih->hdr.dwPictAspectRatioY = (thdr[17] << 16) | (thdr[18] << 8) | thdr[19];
+ mt.bFixedSizeSamples = 0;
+
+ vih->cbSequenceHeader = (DWORD)pTE->CodecPrivate.GetCount();
+ memcpy(&vih->dwSequenceHeader, pTE->CodecPrivate.GetData(), vih->cbSequenceHeader);
+
+ if (!bHasVideo) {
+ mts.Add(mt);
+ }
+ bHasVideo = true;
+ } else if (CodecID.Find("V_VP8") == 0) {
+ mt.subtype = FOURCCMap('08PV');
+ mt.formattype = FORMAT_VideoInfo;
+ VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + pTE->CodecPrivate.GetCount());
+ memset(mt.Format(), 0, mt.FormatLength());
+ memcpy(mt.Format() + sizeof(VIDEOINFOHEADER), pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
+ pvih->bmiHeader.biSize = sizeof(pvih->bmiHeader);
+ pvih->bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
+ pvih->bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
+ pvih->bmiHeader.biCompression = mt.subtype.Data1;
+ if (!bHasVideo) {
+ mts.Add(mt);
+ }
+ bHasVideo = true;
+ } else if (CodecID == "V_QUICKTIME" && pTE->CodecPrivate.GetCount() >= 8) {
+ DWORD* type;
+ if (m_pFile->m_ebml.DocTypeReadVersion == 1) {
+ type = (DWORD*)(pTE->CodecPrivate.GetData());
+ } else {
+ type = (DWORD*)(pTE->CodecPrivate.GetData() + 4);
+ }
+ if (*type == MAKEFOURCC('S', 'V', 'Q', '3') || *type == MAKEFOURCC('S', 'V', 'Q', '1') || *type == MAKEFOURCC('c', 'v', 'i', 'd')) {
+ mt.subtype = FOURCCMap(*type);
+ mt.formattype = FORMAT_VideoInfo;
+ VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + pTE->CodecPrivate.GetCount());
+ memset(mt.Format(), 0, mt.FormatLength());
+ memcpy(mt.Format() + sizeof(VIDEOINFOHEADER), pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
+ pvih->bmiHeader.biSize = sizeof(pvih->bmiHeader);
+ pvih->bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
+ pvih->bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
+ pvih->bmiHeader.biCompression = mt.subtype.Data1;
+ if (!bHasVideo) {
+ mts.Add(mt);
+ }
+ bHasVideo = true;
+ }
+ } else if (CodecID == "V_DSHOW/MPEG1VIDEO" || CodecID == "V_MPEG1") {
+ mt.majortype = MEDIATYPE_Video;
+ mt.subtype = MEDIASUBTYPE_MPEG1Payload;
+ mt.formattype = FORMAT_MPEGVideo;
+
+ MPEG1VIDEOINFO* pm1vi = (MPEG1VIDEOINFO*)mt.AllocFormatBuffer(sizeof(MPEG1VIDEOINFO) + pTE->CodecPrivate.GetCount());
+ memset(mt.Format(), 0, mt.FormatLength());
+ memcpy(mt.Format() + sizeof(MPEG1VIDEOINFO), pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
+
+ pm1vi->hdr.bmiHeader.biSize = sizeof(pm1vi->hdr.bmiHeader);
+ pm1vi->hdr.bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
+ pm1vi->hdr.bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
+ pm1vi->hdr.bmiHeader.biBitCount = 12;
+ pm1vi->hdr.bmiHeader.biSizeImage = DIBSIZE(pm1vi->hdr.bmiHeader);
+
+ mt.SetSampleSize(pm1vi->hdr.bmiHeader.biWidth * pm1vi->hdr.bmiHeader.biHeight * 4);
+ if (!bHasVideo) {
+ mts.Add(mt);
+ }
+ bHasVideo = true;
+ }
+ REFERENCE_TIME AvgTimePerFrame = 0;
+
+ if (pTE->v.FramePerSec > 0) {
+ AvgTimePerFrame = (REFERENCE_TIME)(10000000i64 / pTE->v.FramePerSec);
+ } else if (pTE->DefaultDuration > 0 && pTE->DefaultDuration != 1000000) {
+ AvgTimePerFrame = (REFERENCE_TIME)pTE->DefaultDuration / 100;
+ } else { // pTE->DefaultDuration == 1000000 or < 0
+ CMatroskaNode Root(m_pFile);
+ m_pSegment = Root.Child(0x18538067);
+ m_pCluster = m_pSegment->Child(0x1F43B675);
+
+ MatroskaReader::QWORD lastCueClusterPosition = (MatroskaReader::QWORD) - 1;
+ UINT64 timecode1 = -1;
+ UINT64 timecode2 = -1;
+ unsigned int framecount = 0;
+ bool readmore = true;
+
+ POSITION pos1 = m_pFile->m_segment.Cues.GetHeadPosition();
+ while (readmore && pos1) {
+ Cue* pCue = m_pFile->m_segment.Cues.GetNext(pos1);
+ POSITION pos2 = pCue->CuePoints.GetHeadPosition();
+ while (readmore && pos2) {
+ CuePoint* pCuePoint = pCue->CuePoints.GetNext(pos2);
+ POSITION pos3 = pCuePoint->CueTrackPositions.GetHeadPosition();
+ while (readmore && pos3) {
+ CueTrackPosition* pCueTrackPositions = pCuePoint->CueTrackPositions.GetNext(pos3);
+ if (pCueTrackPositions->CueTrack != pTE->TrackNumber) {
+ continue;
+ }
+
+ if (lastCueClusterPosition == pCueTrackPositions->CueClusterPosition) {
+ continue;
+ }
+ lastCueClusterPosition = pCueTrackPositions->CueClusterPosition;
+
+ m_pCluster->SeekTo(m_pSegment->m_start + pCueTrackPositions->CueClusterPosition);
+ m_pCluster->Parse();
+
+ Cluster c;
+ c.ParseTimeCode(m_pCluster);
+
+ if (CAutoPtr<CMatroskaNode> pBlock = m_pCluster->GetFirstBlock()) {
+ do {
+ CBlockGroupNode bgn;
+
+ if (pBlock->m_id == 0xA0) {
+ bgn.Parse(pBlock, true);
+ } else if (pBlock->m_id == 0xA3) {
+ CAutoPtr<BlockGroup> bg(DNew BlockGroup());
+ bg->Block.Parse(pBlock, true);
+ if (!(bg->Block.Lacing & 0x80)) {
+ bg->ReferenceBlock.Set(0); // not a kf
+ }
+ bgn.AddTail(bg);
+ }
+
+ POSITION pos4 = bgn.GetHeadPosition();
+ while (pos4) {
+ BlockGroup* bg = bgn.GetNext(pos4);
+ if (bg->Block.TrackNumber != pTE->TrackNumber) {
+ continue;
+ }
+ UINT64 tc = c.TimeCode + bg->Block.TimeCode;
+ if (tc == timecode2) {
+ continue;
+ }
+
+ if (timecode1 == -1) {
+ timecode1 = tc;
+ } else {
+ timecode2 = tc;
+ ++framecount;
+ }
+
+ if (framecount >= 24) {
+ // good for 23.976, 24, 25, 30, 50, 60 fps.
+ // for 29.97 and 59,94 can give a small inaccuracy
+ readmore = false;
+ break;
+ }
+ }
+ } while (readmore && pBlock->NextBlock());
+ }
+ }
+ }
+ }
+ if (framecount) {
+ AvgTimePerFrame = m_pFile->m_segment.SegmentInfo.TimeCodeScale * (timecode2 - timecode1) / (100 * framecount);
+ }
+
+ m_pCluster.Free();
+ }
+ //if (AvgTimePerFrame < 0) AvgTimePerFrame = 0;
+
+ for (size_t i = 0; i < mts.GetCount(); i++) {
+ if (mts[i].formattype == FORMAT_VideoInfo
+ || mts[i].formattype == FORMAT_VideoInfo2
+ || mts[i].formattype == FORMAT_MPEG2Video
+ || mts[i].formattype == FORMAT_MPEGVideo) {
+ if (pTE->v.PixelWidth && pTE->v.PixelHeight) {
+ RECT rect = {(LONG)pTE->v.VideoPixelCropLeft,
+ (LONG)pTE->v.VideoPixelCropTop,
+ (LONG)(pTE->v.PixelWidth - pTE->v.VideoPixelCropRight),
+ (LONG)(pTE->v.PixelHeight - pTE->v.VideoPixelCropBottom)
+ };
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mts[i].Format();
+ vih->rcSource = vih->rcTarget = rect;
+ }
+
+ if (AvgTimePerFrame) {
+ if (mts[i].subtype == MEDIASUBTYPE_MPEG1Payload) {
+ AvgTimePerFrame *= 2; // Need more testing, but work on all sample that i have :)
+ }
+ ((VIDEOINFOHEADER*)mts[i].Format())->AvgTimePerFrame = AvgTimePerFrame;
+ }
+ }
+ }
+
+ if (pTE->v.DisplayWidth && pTE->v.DisplayHeight) {
+ for (size_t i = 0; i < mts.GetCount(); i++) {
+ if (mts[i].formattype == FORMAT_VideoInfo) {
+ mt = mts[i];
+ DWORD vih1 = FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader);
+ DWORD vih2 = FIELD_OFFSET(VIDEOINFOHEADER2, bmiHeader);
+ DWORD bmi = mts[i].FormatLength() - FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader);
+ mt.formattype = FORMAT_VideoInfo2;
+ mt.AllocFormatBuffer(vih2 + bmi);
+ memcpy(mt.Format(), mts[i].Format(), vih1);
+ memset(mt.Format() + vih1, 0, vih2 - vih1);
+ memcpy(mt.Format() + vih2, mts[i].Format() + vih1, bmi);
+
+ CSize aspect((int)pTE->v.DisplayWidth, (int)pTE->v.DisplayHeight);
+ int lnko = LNKO(aspect.cx, aspect.cy);
+ if (lnko > 1) {
+ aspect.cx /= lnko, aspect.cy /= lnko;
+ }
+ ((VIDEOINFOHEADER2*)mt.Format())->dwPictAspectRatioX = aspect.cx;
+ ((VIDEOINFOHEADER2*)mt.Format())->dwPictAspectRatioY = aspect.cy;
+ mts.InsertAt(i++, mt);
+ } else if (mts[i].formattype == FORMAT_MPEG2Video) {
+ CSize aspect((int)pTE->v.DisplayWidth, (int)pTE->v.DisplayHeight);
+ int lnko = LNKO(aspect.cx, aspect.cy);
+ if (lnko > 1) {
+ aspect.cx /= lnko, aspect.cy /= lnko;
+ }
+ ((MPEG2VIDEOINFO*)mts[i].Format())->hdr.dwPictAspectRatioX = aspect.cx;
+ ((MPEG2VIDEOINFO*)mts[i].Format())->hdr.dwPictAspectRatioY = aspect.cy;
+ }
+ }
+ }
+ } else if (pTE->TrackType == TrackEntry::TypeAudio) {
+ Name.Format(L"Audio %d", iAudio++);
+
+ mt.majortype = MEDIATYPE_Audio;
+ mt.formattype = FORMAT_WaveFormatEx;
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX));
+ memset(wfe, 0, mt.FormatLength());
+ wfe->nChannels = (WORD)pTE->a.Channels;
+ wfe->nSamplesPerSec = (DWORD)pTE->a.SamplingFrequency;
+ wfe->wBitsPerSample = (WORD)pTE->a.BitDepth;
+ wfe->nBlockAlign = (WORD)((wfe->nChannels * wfe->wBitsPerSample) / 8);
+ wfe->nAvgBytesPerSec = wfe->nSamplesPerSec * wfe->nBlockAlign;
+ mt.SetSampleSize(256000);
+
+ if (CodecID == "A_MPEG/L3") {
+ mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_MPEGLAYER3);
+ mts.Add(mt);
+ } else if (CodecID == "A_MPEG/L2" ||
+ CodecID == "A_MPEG/L1") {
+ mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_MPEG);
+ mts.Add(mt);
+ } else if (CodecID == "A_AC3" ||
+ CodecID == "A_EAC3") {
+ mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_DOLBY_AC3);
+ mts.Add(mt);
+ } else if (CodecID == "A_TRUEHD" ||
+ CodecID == "A_MLP") {
+ wfe->wFormatTag = WAVE_FORMAT_DOLBY_AC3;
+ mt.subtype = MEDIASUBTYPE_DOLBY_TRUEHD;
+ mts.Add(mt);
+ } else if (CodecID == "A_DTS") {
+ mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_DVD_DTS);
+ mts.Add(mt);
+ } else if (CodecID == "A_TTA1") {
+ mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_TTA1);
+ wfe->cbSize = 30;
+ wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + 30);
+ BYTE* p = (BYTE*)(wfe + 1);
+ memcpy(p, (const unsigned char*)"TTA1\x01\x00", 6);
+ memcpy(p + 6, &wfe->nChannels, 2);
+ memcpy(p + 8, &wfe->wBitsPerSample, 2);
+ memcpy(p + 10, &wfe->nSamplesPerSec, 4);
+ memset(p + 14, 0, 30 - 14);
+ mts.Add(mt);
+ } else if (CodecID == "A_AAC") {
+ mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_AAC);
+ wfe->cbSize = (WORD)pTE->CodecPrivate.GetCount();
+ wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + pTE->CodecPrivate.GetCount());
+ memcpy(wfe + 1, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
+ mts.Add(mt);
+ } else if (CodecID == "A_WAVPACK4") {
+ mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_WAVPACK4);
+ wfe->cbSize = (WORD)pTE->CodecPrivate.GetCount();
+ wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + pTE->CodecPrivate.GetCount());
+ memcpy(wfe + 1, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
+ mts.Add(mt);
+ } else if (CodecID == "A_FLAC") {
+ wfe->wFormatTag = WAVE_FORMAT_FLAC;
+ wfe->cbSize = (WORD)pTE->CodecPrivate.GetCount();
+ wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + pTE->CodecPrivate.GetCount());
+ memcpy(wfe + 1, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
+
+ mt.subtype = MEDIASUBTYPE_FLAC_FRAMED;
+ mts.Add(mt);
+ mt.subtype = MEDIASUBTYPE_FLAC;
+ mts.Add(mt);
+ } else if (CodecID == "A_PCM/INT/LIT") {
+ mt.subtype = MEDIASUBTYPE_PCM;
+ mt.SetSampleSize(wfe->nBlockAlign);
+ if (pTE->a.Channels <= 2 && pTE->a.BitDepth <= 16) {
+ wfe->wFormatTag = WAVE_FORMAT_PCM;
+ } else {
+ WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEXTENSIBLE));
+ if (pTE->a.BitDepth & 7) {
+ wfex->Format.wBitsPerSample = (WORD)(pTE->a.BitDepth + 7) & 0xFFF8;
+ wfex->Format.nBlockAlign = wfex->Format.nChannels * wfex->Format.wBitsPerSample / 8;
+ wfex->Format.nAvgBytesPerSec = wfex->Format.nSamplesPerSec * wfex->Format.nBlockAlign;
+ mt.SetSampleSize(wfex->Format.nBlockAlign);
+ }
+ wfex->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
+ wfex->Format.cbSize = 22;
+ wfex->Samples.wValidBitsPerSample = (WORD)pTE->a.BitDepth;
+ wfex->dwChannelMask = GetDefChannelMask(wfex->Format.nChannels);
+ wfex->SubFormat = MEDIASUBTYPE_PCM;
+ }
+ mts.Add(mt);
+ } else if (CodecID == "A_PCM/FLOAT/IEEE") {
+ mt.subtype = MEDIASUBTYPE_IEEE_FLOAT;
+ mt.SetSampleSize(wfe->nBlockAlign);
+ if (pTE->a.Channels <= 2) {
+ wfe->wFormatTag = WAVE_FORMAT_IEEE_FLOAT;
+ } else {
+ WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEXTENSIBLE));
+ wfex->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
+ wfex->Format.cbSize = 22;
+ wfex->Samples.wValidBitsPerSample = (WORD)pTE->a.BitDepth;
+ wfex->dwChannelMask = GetDefChannelMask(wfex->Format.nChannels);
+ wfex->SubFormat = MEDIASUBTYPE_IEEE_FLOAT;
+ }
+ mts.Add(mt);
+ } else if (CodecID == "A_MS/ACM") {
+ wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(pTE->CodecPrivate.GetCount());
+ memcpy(wfe, (WAVEFORMATEX*)pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
+ if (wfe->wFormatTag == WAVE_FORMAT_EXTENSIBLE && wfe->cbSize == 22) {
+ mt.subtype = ((WAVEFORMATEXTENSIBLE*)wfe)->SubFormat;
+ } else { mt.subtype = FOURCCMap(wfe->wFormatTag); }
+ mts.Add(mt);
+ } else if (CodecID == "A_VORBIS") {
+ BYTE* p = pTE->CodecPrivate.GetData();
+ CAtlArray<int> sizes;
+ int totalsize = 0;
+ for (BYTE n = *p++; n > 0; n--) {
+ int size = 0;
+ do {
+ size += *p;
+ } while (*p++ == 0xff);
+ sizes.Add(size);
+ totalsize += size;
+ }
+ sizes.Add(pTE->CodecPrivate.GetCount() - (p - pTE->CodecPrivate.GetData()) - totalsize);
+ totalsize += sizes[sizes.GetCount() - 1];
+
+ if (sizes.GetCount() == 3) {
+ mt.subtype = MEDIASUBTYPE_Vorbis2;
+ mt.formattype = FORMAT_VorbisFormat2;
+ VORBISFORMAT2* pvf2 = (VORBISFORMAT2*)mt.AllocFormatBuffer(sizeof(VORBISFORMAT2) + totalsize);
+ memset(pvf2, 0, mt.FormatLength());
+ pvf2->Channels = (WORD)pTE->a.Channels;
+ pvf2->SamplesPerSec = (DWORD)pTE->a.SamplingFrequency;
+ pvf2->BitsPerSample = (DWORD)pTE->a.BitDepth;
+ BYTE* p2 = mt.Format() + sizeof(VORBISFORMAT2);
+ for (size_t i = 0; i < sizes.GetCount(); p += sizes[i], p2 += sizes[i], i++) {
+ memcpy(p2, p, pvf2->HeaderSize[i] = sizes[i]);
+ }
+
+ mts.Add(mt);
+ }
+
+ mt.subtype = MEDIASUBTYPE_Vorbis;
+ mt.formattype = FORMAT_VorbisFormat;
+ VORBISFORMAT* vf = (VORBISFORMAT*)mt.AllocFormatBuffer(sizeof(VORBISFORMAT));
+ memset(vf, 0, mt.FormatLength());
+ vf->nChannels = (WORD)pTE->a.Channels;
+ vf->nSamplesPerSec = (DWORD)pTE->a.SamplingFrequency;
+ vf->nMinBitsPerSec = vf->nMaxBitsPerSec = vf->nAvgBitsPerSec = (DWORD) - 1;
+ mts.Add(mt);
+ } else if (CodecID.Find("A_AAC/") == 0) {
+ mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_AAC);
+ wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + 5);
+ wfe->cbSize = 2;
+
+ int profile;
+
+ if (CodecID.Find("/MAIN") > 0) {
+ profile = 0;
+ } else if (CodecID.Find("/SBR") > 0) {
+ profile = -1;
+ } else if (CodecID.Find("/LC") > 0) {
+ profile = 1;
+ } else if (CodecID.Find("/SSR") > 0) {
+ profile = 2;
+ } else if (CodecID.Find("/LTP") > 0) {
+ profile = 3;
+ } else {
+ continue;
+ }
+
+ WORD cbSize = MakeAACInitData((BYTE*)(wfe + 1), profile, wfe->nSamplesPerSec, (int)pTE->a.Channels);
+
+ mts.Add(mt);
+
+ if (profile < 0) {
+ wfe->cbSize = cbSize;
+ wfe->nSamplesPerSec *= 2;
+ wfe->nAvgBytesPerSec *= 2;
+
+ mts.InsertAt(0, mt);
+ }
+ } else if (CodecID.Find("A_REAL/") == 0 && CodecID.GetLength() >= 11) {
+ mt.subtype = FOURCCMap((DWORD)CodecID[7] | ((DWORD)CodecID[8] << 8) | ((DWORD)CodecID[9] << 16) | ((DWORD)CodecID[10] << 24));
+ mt.bTemporalCompression = TRUE;
+ wfe->cbSize = (WORD)pTE->CodecPrivate.GetCount();
+ wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + pTE->CodecPrivate.GetCount());
+ memcpy(wfe + 1, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
+ wfe->cbSize = 0; // IMPORTANT: this is screwed, but cbSize has to be 0 and the extra data from codec priv must be after WAVEFORMATEX
+ mts.Add(mt);
+ } else if (CodecID == "A_QUICKTIME" && pTE->CodecPrivate.GetCount() >= 8) {
+ DWORD* type = (DWORD*)(pTE->CodecPrivate.GetData() + 4);
+ if (*type == MAKEFOURCC('Q', 'D', 'M', '2') || *type == MAKEFOURCC('Q', 'D', 'M', 'C')) {
+ mt.subtype = FOURCCMap(*type);
+ wfe->cbSize = (WORD)pTE->CodecPrivate.GetCount();
+ wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + pTE->CodecPrivate.GetCount());
+ memcpy(wfe + 1, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
+ mts.Add(mt);
+ }
+ }
+ } else if (pTE->TrackType == TrackEntry::TypeSubtitle) {
+ if (iSubtitle == 1) {
+ InstallFonts();
+ }
+
+ Name.Format(L"Subtitle %d", iSubtitle++);
+
+ mt.SetSampleSize(1);
+
+ if (CodecID == "S_TEXT/ASCII") {
+ mt.majortype = MEDIATYPE_Text;
+ mt.subtype = MEDIASUBTYPE_NULL;
+ mt.formattype = FORMAT_None;
+ mts.Add(mt);
+ isSub = true;
+ } else {
+ mt.majortype = MEDIATYPE_Subtitle;
+ mt.formattype = FORMAT_SubtitleInfo;
+ SUBTITLEINFO* psi = (SUBTITLEINFO*)mt.AllocFormatBuffer(sizeof(SUBTITLEINFO) + pTE->CodecPrivate.GetCount());
+ memset(psi, 0, mt.FormatLength());
+ strncpy_s(psi->IsoLang, pTE->Language, _countof(psi->IsoLang) - 1);
+ CString subtitle_Name = pTE->Name;
+ if (pTE->FlagForced) { // "Forced" overrides "Default"
+ subtitle_Name += L" [Forced]";
+ } else if (pTE->FlagDefault) {
+ subtitle_Name += L" [Default]";
+ }
+ subtitle_Name = subtitle_Name.Trim();
+
+ wcsncpy_s(psi->TrackName, subtitle_Name, _countof(psi->TrackName) - 1);
+ memcpy(mt.pbFormat + (psi->dwOffset = sizeof(SUBTITLEINFO)), pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
+
+ mt.subtype =
+ CodecID == "S_TEXT/UTF8" ? MEDIASUBTYPE_UTF8 :
+ CodecID == "S_TEXT/SSA" || CodecID == "S_SSA" ? MEDIASUBTYPE_SSA :
+ CodecID == "S_TEXT/ASS" || CodecID == "S_ASS" ? MEDIASUBTYPE_ASS :
+ CodecID == "S_TEXT/USF" || CodecID == "S_USF" ? MEDIASUBTYPE_USF :
+ CodecID == "S_HDMV/PGS" ? MEDIASUBTYPE_HDMVSUB :
+ //CodecID == "S_DVBSUB" ? MEDIASUBTYPE_DVB_SUBTITLES : // does not work
+ CodecID == "S_VOBSUB" ? MEDIASUBTYPE_VOBSUB :
+ MEDIASUBTYPE_NULL;
+
+ if (mt.subtype != MEDIASUBTYPE_NULL) {
+ mts.Add(mt);
+ isSub = true;
+ }
+ }
+ }
+
+ if (mts.IsEmpty()) {
+ TRACE(_T("CMatroskaSourceFilter: Unsupported TrackType %s (%I64d)\n"), CString(CodecID), (UINT64)pTE->TrackType);
+ continue;
+ }
+
+ Name = CStringW(pTE->Language.IsEmpty() ? L"English" : CStringW(ISO6392ToLanguage(pTE->Language)))
+ + (pTE->Name.IsEmpty() ? L"" : L", " + pTE->Name)
+ + (L" (" + Name + L")");
+
+ if (pTE->FlagForced) { // "Forced" overrides "Default"
+ Name = Name + L" [Forced]";
+ } else if (pTE->FlagDefault) {
+ Name = Name + L" [Default]";
+ }
+
+ HRESULT hr;
+
+ CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CMatroskaSplitterOutputPin(pTE->MinCache, pTE->DefaultDuration / 100, mts, Name, this, this, &hr));
+ if (!pTE->Name.IsEmpty()) {
+ pPinOut->SetProperty(L"NAME", pTE->Name);
+ }
+ if (pTE->Language.GetLength() == 3) {
+ pPinOut->SetProperty(L"LANG", CStringW(CString(pTE->Language)));
+ }
+
+ if (!isSub) {
+ pinOut.InsertAt((iVideo + iAudio - 3), DNew CMatroskaSplitterOutputPin(pTE->MinCache, pTE->DefaultDuration / 100, mts, Name, this, this, &hr), 1);
+ pinOutTE.InsertAt((iVideo + iAudio - 3), pTE, 1);
+ } else {
+ pinOut.Add(DNew CMatroskaSplitterOutputPin(pTE->MinCache, pTE->DefaultDuration / 100, mts, Name, this, this, &hr));
+ pinOutTE.Add(pTE);
+ }
+
+ }
+ }
+
+ for (size_t i = 0; i < pinOut.GetCount(); i++) {
+
+ CAutoPtr<CBaseSplitterOutputPin> pPinOut;
+ pPinOut.Attach(pinOut[i]);
+ TrackEntry* pTE = pinOutTE[i];
+
+ if (pTE != NULL) {
+ AddOutputPin((DWORD)pTE->TrackNumber, pPinOut);
+ m_pTrackEntryMap[(DWORD)pTE->TrackNumber] = pTE;
+ m_pOrderedTrackArray.Add(pTE);
+ }
+ }
+
+
+ Info& info = m_pFile->m_segment.SegmentInfo;
+
+ if (m_pFile->IsRandomAccess()) {
+ m_rtDuration = (REFERENCE_TIME)(info.Duration * info.TimeCodeScale / 100);
+ }
+
+ m_rtNewStop = m_rtStop = m_rtDuration;
+
+ /*#ifdef _DEBUG
+ for (int i = 1, j = GetChapterCount(CHAPTER_ROOT_ID); i <= j; i++)
+ {
+ UINT id = GetChapterId(CHAPTER_ROOT_ID, i);
+ struct ChapterElement ce;
+ BOOL b = GetChapterInfo(id, &ce);
+ BSTR bstr = GetChapterStringInfo(id, "eng", "");
+ if (bstr) ::SysFreeString(bstr);
+ }
+ #endif*/
+
+ SetProperty(L"TITL", info.Title);
+ // TODO
+
+ // resources
+
+ {
+ POSITION pos = m_pFile->m_segment.Attachments.GetHeadPosition();
+ while (pos) {
+ Attachment* pA = m_pFile->m_segment.Attachments.GetNext(pos);
+
+ POSITION pos = pA->AttachedFiles.GetHeadPosition();
+ while (pos) {
+ AttachedFile* pF = pA->AttachedFiles.GetNext(pos);
+
+ CAtlArray<BYTE> pData;
+ pData.SetCount((size_t)pF->FileDataLen);
+ m_pFile->Seek(pF->FileDataPos);
+ if (SUCCEEDED(m_pFile->ByteRead(pData.GetData(), pData.GetCount()))) {
+ ResAppend(pF->FileName, pF->FileDescription, CStringW(pF->FileMimeType), pData.GetData(), (DWORD)pData.GetCount());
+ }
+ }
+ }
+ }
+
+ // chapters
+
+ if (ChapterAtom* caroot = m_pFile->m_segment.FindChapterAtom(0)) {
+ CStringA str;
+ str.ReleaseBufferSetLength(GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, str.GetBuffer(3), 3));
+ CStringA ChapLanguage = CStringA(ISO6391To6392(str));
+ if (ChapLanguage.GetLength() < 3) {
+ ChapLanguage = "eng";
+ }
+
+ SetupChapters(ChapLanguage, caroot);
+ }
+
+ return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
}
void CMatroskaSplitterFilter::SetupChapters(LPCSTR lng, ChapterAtom* parent, int level)
{
- CStringW tabs('+', level);
-
- if (!tabs.IsEmpty()) {
- tabs += ' ';
- }
-
- POSITION pos = parent->ChapterAtoms.GetHeadPosition();
- while (pos) {
- // ChapUID zero not allow by Matroska specs
- UINT64 ChapUID = parent->ChapterAtoms.GetNext(pos)->ChapterUID;
- ChapterAtom* ca = (ChapUID == 0) ? NULL : m_pFile->m_segment.FindChapterAtom(ChapUID);
-
- if (ca) {
- CStringW name, first;
-
- POSITION pos = ca->ChapterDisplays.GetHeadPosition();
- while (pos) {
- ChapterDisplay* cd = ca->ChapterDisplays.GetNext(pos);
- if (first.IsEmpty()) {
- first = cd->ChapString;
- }
- if (cd->ChapLanguage == lng) {
- name = cd->ChapString;
- }
- }
-
- name = tabs + (!name.IsEmpty() ? name : first);
-
- ChapAppend(ca->ChapterTimeStart / 100 - m_pFile->m_rtOffset, name);
-
- if (!ca->ChapterAtoms.IsEmpty() && level < 5) {
- // level < 5 - hard limit for the number of levels
- SetupChapters(lng, ca, level+1);
- }
- }
- }
+ CStringW tabs('+', level);
+
+ if (!tabs.IsEmpty()) {
+ tabs += ' ';
+ }
+
+ POSITION pos = parent->ChapterAtoms.GetHeadPosition();
+ while (pos) {
+ // ChapUID zero not allow by Matroska specs
+ UINT64 ChapUID = parent->ChapterAtoms.GetNext(pos)->ChapterUID;
+ ChapterAtom* ca = (ChapUID == 0) ? NULL : m_pFile->m_segment.FindChapterAtom(ChapUID);
+
+ if (ca) {
+ CStringW name, first;
+
+ POSITION pos = ca->ChapterDisplays.GetHeadPosition();
+ while (pos) {
+ ChapterDisplay* cd = ca->ChapterDisplays.GetNext(pos);
+ if (first.IsEmpty()) {
+ first = cd->ChapString;
+ }
+ if (cd->ChapLanguage == lng) {
+ name = cd->ChapString;
+ }
+ }
+
+ name = tabs + (!name.IsEmpty() ? name : first);
+
+ ChapAppend(ca->ChapterTimeStart / 100 - m_pFile->m_rtOffset, name);
+
+ if (!ca->ChapterAtoms.IsEmpty() && level < 5) {
+ // level < 5 - hard limit for the number of levels
+ SetupChapters(lng, ca, level + 1);
+ }
+ }
+ }
}
void CMatroskaSplitterFilter::InstallFonts()
{
- POSITION pos = m_pFile->m_segment.Attachments.GetHeadPosition();
- while (pos) {
- Attachment* pA = m_pFile->m_segment.Attachments.GetNext(pos);
-
- POSITION p2 = pA->AttachedFiles.GetHeadPosition();
- while (p2) {
- AttachedFile* pF = pA->AttachedFiles.GetNext(p2);
-
- if (pF->FileMimeType == "application/x-truetype-font" ||
- pF->FileMimeType == "application/x-font-ttf" ||
- pF->FileMimeType == "application/vnd.ms-opentype") {
- // assume this is a font resource
-
- if (BYTE* pData = DNew BYTE[(UINT)pF->FileDataLen]) {
- m_pFile->Seek(pF->FileDataPos);
-
- if (SUCCEEDED(m_pFile->ByteRead(pData, pF->FileDataLen))) {
- //m_fontinst.InstallFont(pData, (UINT)pF->FileDataLen);
- m_fontinst.InstallFontMemory(pData, (UINT)pF->FileDataLen);
- }
-
- delete [] pData;
- }
- }
- }
- }
+ POSITION pos = m_pFile->m_segment.Attachments.GetHeadPosition();
+ while (pos) {
+ Attachment* pA = m_pFile->m_segment.Attachments.GetNext(pos);
+
+ POSITION p2 = pA->AttachedFiles.GetHeadPosition();
+ while (p2) {
+ AttachedFile* pF = pA->AttachedFiles.GetNext(p2);
+
+ if (pF->FileMimeType == "application/x-truetype-font" ||
+ pF->FileMimeType == "application/x-font-ttf" ||
+ pF->FileMimeType == "application/vnd.ms-opentype") {
+ // assume this is a font resource
+
+ if (BYTE* pData = DNew BYTE[(UINT)pF->FileDataLen]) {
+ m_pFile->Seek(pF->FileDataPos);
+
+ if (SUCCEEDED(m_pFile->ByteRead(pData, pF->FileDataLen))) {
+ //m_fontinst.InstallFont(pData, (UINT)pF->FileDataLen);
+ m_fontinst.InstallFontMemory(pData, (UINT)pF->FileDataLen);
+ }
+
+ delete [] pData;
+ }
+ }
+ }
+ }
}
void CMatroskaSplitterFilter::SendVorbisHeaderSample()
{
- HRESULT hr;
-
- POSITION pos = m_pTrackEntryMap.GetStartPosition();
- while (pos) {
- DWORD TrackNumber = 0;
- TrackEntry* pTE = NULL;
- m_pTrackEntryMap.GetNextAssoc(pos, TrackNumber, pTE);
-
- CBaseSplitterOutputPin* pPin = GetOutputPin(TrackNumber);
-
- if (!(pTE && pPin && pPin->IsConnected())) {
- continue;
- }
-
- if (pTE->CodecID.ToString() == "A_VORBIS" && pPin->CurrentMediaType().subtype == MEDIASUBTYPE_Vorbis
- && pTE->CodecPrivate.GetCount() > 0) {
- BYTE* ptr = pTE->CodecPrivate.GetData();
-
- CAtlList<int> sizes;
- long last = 0;
- for (BYTE n = *ptr++; n > 0; n--) {
- int size = 0;
- do {
- size += *ptr;
- } while (*ptr++ == 0xff);
- sizes.AddTail(size);
- last += size;
- }
- sizes.AddTail(pTE->CodecPrivate.GetCount() - (ptr - pTE->CodecPrivate.GetData()) - last);
-
- hr = S_OK;
-
- POSITION pos = sizes.GetHeadPosition();
- while (pos && SUCCEEDED(hr)) {
- long len = sizes.GetNext(pos);
-
- CAutoPtr<Packet> p(DNew Packet());
- p->TrackNumber = (DWORD)pTE->TrackNumber;
- p->rtStart = 0;
- p->rtStop = 1;
- p->bSyncPoint = FALSE;
-
- p->SetData(ptr, len);
- ptr += len;
-
- hr = DeliverPacket(p);
- }
-
- if (FAILED(hr)) {
- TRACE(_T("ERROR: Vorbis initialization failed for stream %I64d\n"), TrackNumber);
- }
- }
- }
+ HRESULT hr;
+
+ POSITION pos = m_pTrackEntryMap.GetStartPosition();
+ while (pos) {
+ DWORD TrackNumber = 0;
+ TrackEntry* pTE = NULL;
+ m_pTrackEntryMap.GetNextAssoc(pos, TrackNumber, pTE);
+
+ CBaseSplitterOutputPin* pPin = GetOutputPin(TrackNumber);
+
+ if (!(pTE && pPin && pPin->IsConnected())) {
+ continue;
+ }
+
+ if (pTE->CodecID.ToString() == "A_VORBIS" && pPin->CurrentMediaType().subtype == MEDIASUBTYPE_Vorbis
+ && pTE->CodecPrivate.GetCount() > 0) {
+ BYTE* ptr = pTE->CodecPrivate.GetData();
+
+ CAtlList<int> sizes;
+ long last = 0;
+ for (BYTE n = *ptr++; n > 0; n--) {
+ int size = 0;
+ do {
+ size += *ptr;
+ } while (*ptr++ == 0xff);
+ sizes.AddTail(size);
+ last += size;
+ }
+ sizes.AddTail(pTE->CodecPrivate.GetCount() - (ptr - pTE->CodecPrivate.GetData()) - last);
+
+ hr = S_OK;
+
+ POSITION pos = sizes.GetHeadPosition();
+ while (pos && SUCCEEDED(hr)) {
+ long len = sizes.GetNext(pos);
+
+ CAutoPtr<Packet> p(DNew Packet());
+ p->TrackNumber = (DWORD)pTE->TrackNumber;
+ p->rtStart = 0;
+ p->rtStop = 1;
+ p->bSyncPoint = FALSE;
+
+ p->SetData(ptr, len);
+ ptr += len;
+
+ hr = DeliverPacket(p);
+ }
+
+ if (FAILED(hr)) {
+ TRACE(_T("ERROR: Vorbis initialization failed for stream %I64d\n"), TrackNumber);
+ }
+ }
+ }
}
bool CMatroskaSplitterFilter::DemuxInit()
{
- SetThreadName((DWORD)-1, "CMatroskaSplitterFilter");
+ SetThreadName((DWORD) - 1, "CMatroskaSplitterFilter");
- CMatroskaNode Root(m_pFile);
- if (!m_pFile
- || !(m_pSegment = Root.Child(0x18538067))
- || !(m_pCluster = m_pSegment->Child(0x1F43B675))) {
- return false;
- }
+ CMatroskaNode Root(m_pFile);
+ if (!m_pFile
+ || !(m_pSegment = Root.Child(0x18538067))
+ || !(m_pCluster = m_pSegment->Child(0x1F43B675))) {
+ return false;
+ }
- // reindex if needed
+ // reindex if needed
- if (m_pFile->IsRandomAccess() && m_pFile->m_segment.Cues.GetCount() == 0) {
- m_nOpenProgress = 0;
- m_pFile->m_segment.SegmentInfo.Duration.Set(0);
+ if (m_pFile->IsRandomAccess() && m_pFile->m_segment.Cues.GetCount() == 0) {
+ m_nOpenProgress = 0;
+ m_pFile->m_segment.SegmentInfo.Duration.Set(0);
- UINT64 TrackNumber = m_pFile->m_segment.GetMasterTrack();
+ UINT64 TrackNumber = m_pFile->m_segment.GetMasterTrack();
- CAutoPtr<Cue> pCue(DNew Cue());
+ CAutoPtr<Cue> pCue(DNew Cue());
- do {
- Cluster c;
- c.ParseTimeCode(m_pCluster);
+ do {
+ Cluster c;
+ c.ParseTimeCode(m_pCluster);
- m_pFile->m_segment.SegmentInfo.Duration.Set((float)c.TimeCode - m_pFile->m_rtOffset/10000);
+ m_pFile->m_segment.SegmentInfo.Duration.Set((float)c.TimeCode - m_pFile->m_rtOffset / 10000);
- CAutoPtr<CuePoint> pCuePoint(DNew CuePoint());
- CAutoPtr<CueTrackPosition> pCueTrackPosition(DNew CueTrackPosition());
- pCuePoint->CueTime.Set(c.TimeCode);
- pCueTrackPosition->CueTrack.Set(TrackNumber);
- pCueTrackPosition->CueClusterPosition.Set(m_pCluster->m_filepos - m_pSegment->m_start);
- pCuePoint->CueTrackPositions.AddTail(pCueTrackPosition);
- pCue->CuePoints.AddTail(pCuePoint);
+ CAutoPtr<CuePoint> pCuePoint(DNew CuePoint());
+ CAutoPtr<CueTrackPosition> pCueTrackPosition(DNew CueTrackPosition());
+ pCuePoint->CueTime.Set(c.TimeCode);
+ pCueTrackPosition->CueTrack.Set(TrackNumber);
+ pCueTrackPosition->CueClusterPosition.Set(m_pCluster->m_filepos - m_pSegment->m_start);
+ pCuePoint->CueTrackPositions.AddTail(pCueTrackPosition);
+ pCue->CuePoints.AddTail(pCuePoint);
- m_nOpenProgress = m_pFile->GetPos()*100/m_pFile->GetLength();
+ m_nOpenProgress = m_pFile->GetPos() * 100 / m_pFile->GetLength();
- DWORD cmd;
- if (CheckRequest(&cmd)) {
- if (cmd == CMD_EXIT) {
- m_fAbort = true;
- } else {
- Reply(S_OK);
- }
- }
- } while (!m_fAbort && m_pCluster->Next(true));
+ DWORD cmd;
+ if (CheckRequest(&cmd)) {
+ if (cmd == CMD_EXIT) {
+ m_fAbort = true;
+ } else {
+ Reply(S_OK);
+ }
+ }
+ } while (!m_fAbort && m_pCluster->Next(true));
- m_nOpenProgress = 100;
+ m_nOpenProgress = 100;
- if (!m_fAbort) {
- m_pFile->m_segment.Cues.AddTail(pCue);
- }
+ if (!m_fAbort) {
+ m_pFile->m_segment.Cues.AddTail(pCue);
+ }
- m_fAbort = false;
- }
+ m_fAbort = false;
+ }
- m_pCluster.Free();
- m_pBlock.Free();
+ m_pCluster.Free();
+ m_pBlock.Free();
- return true;
+ return true;
}
void CMatroskaSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
- m_pCluster = m_pSegment->Child(0x1F43B675);
- m_pBlock.Free();
-
- if (rt > 0) {
- rt += m_pFile->m_rtOffset;
-
- MatroskaReader::QWORD lastCueClusterPosition = (MatroskaReader::QWORD)-1;
-
- Segment& s = m_pFile->m_segment;
-
- UINT64 TrackNumber = s.GetMasterTrack();
-
- POSITION pos1 = s.Cues.GetHeadPosition();
- while (pos1) {
- Cue* pCue = s.Cues.GetNext(pos1);
-
- POSITION pos2 = pCue->CuePoints.GetTailPosition();
- while (pos2) {
- CuePoint* pCuePoint = pCue->CuePoints.GetPrev(pos2);
-
- if (rt < s.GetRefTime(pCuePoint->CueTime)) {
- continue;
- }
-
- POSITION pos3 = pCuePoint->CueTrackPositions.GetHeadPosition();
- while (pos3) {
- CueTrackPosition* pCueTrackPositions = pCuePoint->CueTrackPositions.GetNext(pos3);
-
- if (TrackNumber != pCueTrackPositions->CueTrack) {
- continue;
- }
-
- if (lastCueClusterPosition == pCueTrackPositions->CueClusterPosition) {
- continue;
- }
-
- lastCueClusterPosition = pCueTrackPositions->CueClusterPosition;
-
- m_pCluster->SeekTo(m_pSegment->m_start + pCueTrackPositions->CueClusterPosition);
- m_pCluster->Parse();
-
- bool fFoundKeyFrame = false;
- /*
- if (pCueTrackPositions->CueBlockNumber > 0)
- {
- // TODO: CueBlockNumber only tells the block num of the track and not for all mixed in the cluster
- m_nLastBlock = (int)pCueTrackPositions->CueBlockNumber;
- fFoundKeyFrame = true;
- }
- else
- */
- {
- Cluster c;
- c.ParseTimeCode(m_pCluster);
-
- if (CAutoPtr<CMatroskaNode> pBlock = m_pCluster->GetFirstBlock()) {
- bool fPassedCueTime = false;
-
- do {
- CBlockGroupNode bgn;
-
- if (pBlock->m_id == 0xA0) {
- bgn.Parse(pBlock, true);
- } else if (pBlock->m_id == 0xA3) {
- CAutoPtr<BlockGroup> bg(DNew BlockGroup());
- bg->Block.Parse(pBlock, true);
- if (!(bg->Block.Lacing & 0x80)) {
- bg->ReferenceBlock.Set(0); // not a kf
- }
- bgn.AddTail(bg);
- }
-
- POSITION pos4 = bgn.GetHeadPosition();
- while (!fPassedCueTime && pos4) {
- BlockGroup* bg = bgn.GetNext(pos4);
-
- if (bg->Block.TrackNumber == pCueTrackPositions->CueTrack && rt < s.GetRefTime(c.TimeCode + bg->Block.TimeCode)
- || rt + 5000000i64 < s.GetRefTime(c.TimeCode + bg->Block.TimeCode)) { // allow 500ms difference between tracks, just in case intreleaving wasn't that much precise
- fPassedCueTime = true;
- } else if (bg->Block.TrackNumber == pCueTrackPositions->CueTrack && !bg->ReferenceBlock.IsValid()) {
- fFoundKeyFrame = true;
- m_pBlock = pBlock->Copy();
- }
- }
- } while (!fPassedCueTime && pBlock->NextBlock());
- }
- }
-
- if (fFoundKeyFrame) {
- pos1 = pos2 = pos3 = NULL;
- }
- }
- }
- }
-
- if (!m_pBlock) {
- m_pCluster = m_pSegment->Child(0x1F43B675);
- }
- }
+ m_pCluster = m_pSegment->Child(0x1F43B675);
+ m_pBlock.Free();
+
+ if (rt > 0) {
+ rt += m_pFile->m_rtOffset;
+
+ MatroskaReader::QWORD lastCueClusterPosition = (MatroskaReader::QWORD) - 1;
+
+ Segment& s = m_pFile->m_segment;
+
+ UINT64 TrackNumber = s.GetMasterTrack();
+
+ POSITION pos1 = s.Cues.GetHeadPosition();
+ while (pos1) {
+ Cue* pCue = s.Cues.GetNext(pos1);
+
+ POSITION pos2 = pCue->CuePoints.GetTailPosition();
+ while (pos2) {
+ CuePoint* pCuePoint = pCue->CuePoints.GetPrev(pos2);
+
+ if (rt < s.GetRefTime(pCuePoint->CueTime)) {
+ continue;
+ }
+
+ POSITION pos3 = pCuePoint->CueTrackPositions.GetHeadPosition();
+ while (pos3) {
+ CueTrackPosition* pCueTrackPositions = pCuePoint->CueTrackPositions.GetNext(pos3);
+
+ if (TrackNumber != pCueTrackPositions->CueTrack) {
+ continue;
+ }
+
+ if (lastCueClusterPosition == pCueTrackPositions->CueClusterPosition) {
+ continue;
+ }
+
+ lastCueClusterPosition = pCueTrackPositions->CueClusterPosition;
+
+ m_pCluster->SeekTo(m_pSegment->m_start + pCueTrackPositions->CueClusterPosition);
+ m_pCluster->Parse();
+
+ bool fFoundKeyFrame = false;
+ /*
+ if (pCueTrackPositions->CueBlockNumber > 0)
+ {
+ // TODO: CueBlockNumber only tells the block num of the track and not for all mixed in the cluster
+ m_nLastBlock = (int)pCueTrackPositions->CueBlockNumber;
+ fFoundKeyFrame = true;
+ }
+ else
+ */
+ {
+ Cluster c;
+ c.ParseTimeCode(m_pCluster);
+
+ if (CAutoPtr<CMatroskaNode> pBlock = m_pCluster->GetFirstBlock()) {
+ bool fPassedCueTime = false;
+
+ do {
+ CBlockGroupNode bgn;
+
+ if (pBlock->m_id == 0xA0) {
+ bgn.Parse(pBlock, true);
+ } else if (pBlock->m_id == 0xA3) {
+ CAutoPtr<BlockGroup> bg(DNew BlockGroup());
+ bg->Block.Parse(pBlock, true);
+ if (!(bg->Block.Lacing & 0x80)) {
+ bg->ReferenceBlock.Set(0); // not a kf
+ }
+ bgn.AddTail(bg);
+ }
+
+ POSITION pos4 = bgn.GetHeadPosition();
+ while (!fPassedCueTime && pos4) {
+ BlockGroup* bg = bgn.GetNext(pos4);
+
+ if (bg->Block.TrackNumber == pCueTrackPositions->CueTrack && rt < s.GetRefTime(c.TimeCode + bg->Block.TimeCode)
+ || rt + 5000000i64 < s.GetRefTime(c.TimeCode + bg->Block.TimeCode)) { // allow 500ms difference between tracks, just in case intreleaving wasn't that much precise
+ fPassedCueTime = true;
+ } else if (bg->Block.TrackNumber == pCueTrackPositions->CueTrack && !bg->ReferenceBlock.IsValid()) {
+ fFoundKeyFrame = true;
+ m_pBlock = pBlock->Copy();
+ }
+ }
+ } while (!fPassedCueTime && pBlock->NextBlock());
+ }
+ }
+
+ if (fFoundKeyFrame) {
+ pos1 = pos2 = pos3 = NULL;
+ }
+ }
+ }
+ }
+
+ if (!m_pBlock) {
+ m_pCluster = m_pSegment->Child(0x1F43B675);
+ }
+ }
}
bool CMatroskaSplitterFilter::DemuxLoop()
{
- HRESULT hr = S_OK;
-
- SendVorbisHeaderSample(); // HACK: init vorbis decoder with the headers
-
- do {
- Cluster c;
- c.ParseTimeCode(m_pCluster);
-
- if (!m_pBlock) {
- m_pBlock = m_pCluster->GetFirstBlock();
- }
- if (!m_pBlock) {
- continue;
- }
-
- do {
- CBlockGroupNode bgn;
-
- if (m_pBlock->m_id == 0xA0) {
- bgn.Parse(m_pBlock, true);
- } else if (m_pBlock->m_id == 0xA3) {
- CAutoPtr<BlockGroup> bg(DNew BlockGroup());
- bg->Block.Parse(m_pBlock, true);
- if (!(bg->Block.Lacing & 0x80)) {
- bg->ReferenceBlock.Set(0); // not a kf
- }
- bgn.AddTail(bg);
- }
-
- while (bgn.GetCount() && SUCCEEDED(hr)) {
- CAutoPtr<MatroskaPacket> p(DNew MatroskaPacket());
- p->bg = bgn.RemoveHead();
-
- p->bSyncPoint = !p->bg->ReferenceBlock.IsValid();
- p->TrackNumber = (DWORD)p->bg->Block.TrackNumber;
-
- TrackEntry* pTE = NULL;
-
- if (!m_pTrackEntryMap.Lookup (p->TrackNumber, pTE) || !pTE) {
- continue;
- }
-
- p->rtStart = m_pFile->m_segment.GetRefTime((REFERENCE_TIME)c.TimeCode + p->bg->Block.TimeCode);
- p->rtStop = p->rtStart + (p->bg->BlockDuration.IsValid() ? m_pFile->m_segment.GetRefTime(p->bg->BlockDuration) : 1);
-
- // Fix subtitle with duration = 0
- if (pTE->TrackType == TrackEntry::TypeSubtitle && !p->bg->BlockDuration.IsValid()) {
- p->bg->BlockDuration.Set(1); // just setting it to be valid
- p->rtStop = p->rtStart;
- }
-
- POSITION pos = p->bg->Block.BlockData.GetHeadPosition();
- while (pos) {
- CBinary* pb = p->bg->Block.BlockData.GetNext(pos);
- pTE->Expand(*pb, ContentEncoding::AllFrameContents);
- }
-
- // HACK
- p->rtStart -= m_pFile->m_rtOffset;
- p->rtStop -= m_pFile->m_rtOffset;
-
- hr = DeliverPacket(p);
- }
- } while (m_pBlock->NextBlock() && SUCCEEDED(hr) && !CheckRequest(NULL));
-
- m_pBlock.Free();
- } while (m_pFile->GetPos() < (__int64)(m_pFile->m_segment.pos + m_pFile->m_segment.len)
- && m_pCluster->Next(true) && SUCCEEDED(hr) && !CheckRequest(NULL));
-
- m_pCluster.Free();
-
- return true;
+ HRESULT hr = S_OK;
+
+ SendVorbisHeaderSample(); // HACK: init vorbis decoder with the headers
+
+ do {
+ Cluster c;
+ c.ParseTimeCode(m_pCluster);
+
+ if (!m_pBlock) {
+ m_pBlock = m_pCluster->GetFirstBlock();
+ }
+ if (!m_pBlock) {
+ continue;
+ }
+
+ do {
+ CBlockGroupNode bgn;
+
+ if (m_pBlock->m_id == 0xA0) {
+ bgn.Parse(m_pBlock, true);
+ } else if (m_pBlock->m_id == 0xA3) {
+ CAutoPtr<BlockGroup> bg(DNew BlockGroup());
+ bg->Block.Parse(m_pBlock, true);
+ if (!(bg->Block.Lacing & 0x80)) {
+ bg->ReferenceBlock.Set(0); // not a kf
+ }
+ bgn.AddTail(bg);
+ }
+
+ while (bgn.GetCount() && SUCCEEDED(hr)) {
+ CAutoPtr<MatroskaPacket> p(DNew MatroskaPacket());
+ p->bg = bgn.RemoveHead();
+
+ p->bSyncPoint = !p->bg->ReferenceBlock.IsValid();
+ p->TrackNumber = (DWORD)p->bg->Block.TrackNumber;
+
+ TrackEntry* pTE = NULL;
+
+ if (!m_pTrackEntryMap.Lookup(p->TrackNumber, pTE) || !pTE) {
+ continue;
+ }
+
+ p->rtStart = m_pFile->m_segment.GetRefTime((REFERENCE_TIME)c.TimeCode + p->bg->Block.TimeCode);
+ p->rtStop = p->rtStart + (p->bg->BlockDuration.IsValid() ? m_pFile->m_segment.GetRefTime(p->bg->BlockDuration) : 1);
+
+ // Fix subtitle with duration = 0
+ if (pTE->TrackType == TrackEntry::TypeSubtitle && !p->bg->BlockDuration.IsValid()) {
+ p->bg->BlockDuration.Set(1); // just setting it to be valid
+ p->rtStop = p->rtStart;
+ }
+
+ POSITION pos = p->bg->Block.BlockData.GetHeadPosition();
+ while (pos) {
+ CBinary* pb = p->bg->Block.BlockData.GetNext(pos);
+ pTE->Expand(*pb, ContentEncoding::AllFrameContents);
+ }
+
+ // HACK
+ p->rtStart -= m_pFile->m_rtOffset;
+ p->rtStop -= m_pFile->m_rtOffset;
+
+ hr = DeliverPacket(p);
+ }
+ } while (m_pBlock->NextBlock() && SUCCEEDED(hr) && !CheckRequest(NULL));
+
+ m_pBlock.Free();
+ } while (m_pFile->GetPos() < (__int64)(m_pFile->m_segment.pos + m_pFile->m_segment.len)
+ && m_pCluster->Next(true) && SUCCEEDED(hr) && !CheckRequest(NULL));
+
+ m_pCluster.Free();
+
+ return true;
}
// IKeyFrameInfo
STDMETHODIMP CMatroskaSplitterFilter::GetKeyFrameCount(UINT& nKFs)
{
- if (!m_pFile) {
- return E_UNEXPECTED;
- }
+ if (!m_pFile) {
+ return E_UNEXPECTED;
+ }
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- nKFs = 0;
+ nKFs = 0;
- POSITION pos = m_pFile->m_segment.Cues.GetHeadPosition();
- while (pos) {
- nKFs += (UINT)m_pFile->m_segment.Cues.GetNext(pos)->CuePoints.GetCount();
- }
+ POSITION pos = m_pFile->m_segment.Cues.GetHeadPosition();
+ while (pos) {
+ nKFs += (UINT)m_pFile->m_segment.Cues.GetNext(pos)->CuePoints.GetCount();
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CMatroskaSplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs)
{
- CheckPointer(pFormat, E_POINTER);
- CheckPointer(pKFs, E_POINTER);
+ CheckPointer(pFormat, E_POINTER);
+ CheckPointer(pKFs, E_POINTER);
- if (!m_pFile) {
- return E_UNEXPECTED;
- }
- if (*pFormat != TIME_FORMAT_MEDIA_TIME) {
- return E_INVALIDARG;
- }
+ if (!m_pFile) {
+ return E_UNEXPECTED;
+ }
+ if (*pFormat != TIME_FORMAT_MEDIA_TIME) {
+ return E_INVALIDARG;
+ }
- UINT nKFsTmp = 0;
+ UINT nKFsTmp = 0;
- POSITION pos1 = m_pFile->m_segment.Cues.GetHeadPosition();
- while (pos1 && nKFsTmp < nKFs) {
- Cue* pCue = m_pFile->m_segment.Cues.GetNext(pos1);
+ POSITION pos1 = m_pFile->m_segment.Cues.GetHeadPosition();
+ while (pos1 && nKFsTmp < nKFs) {
+ Cue* pCue = m_pFile->m_segment.Cues.GetNext(pos1);
- POSITION pos2 = pCue->CuePoints.GetHeadPosition();
- while (pos2 && nKFsTmp < nKFs) {
- pKFs[nKFsTmp++] = m_pFile->m_segment.GetRefTime(pCue->CuePoints.GetNext(pos2)->CueTime);
- }
- }
+ POSITION pos2 = pCue->CuePoints.GetHeadPosition();
+ while (pos2 && nKFsTmp < nKFs) {
+ pKFs[nKFsTmp++] = m_pFile->m_segment.GetRefTime(pCue->CuePoints.GetNext(pos2)->CueTime);
+ }
+ }
- nKFs = nKFsTmp;
+ nKFs = nKFsTmp;
- return S_OK;
+ return S_OK;
}
//
@@ -1353,10 +1361,10 @@ STDMETHODIMP CMatroskaSplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENC
//
CMatroskaSourceFilter::CMatroskaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CMatroskaSplitterFilter(pUnk, phr)
+ : CMatroskaSplitterFilter(pUnk, phr)
{
- m_clsid = __uuidof(this);
- m_pInput.Free();
+ m_clsid = __uuidof(this);
+ m_pInput.Free();
}
//
@@ -1364,12 +1372,12 @@ CMatroskaSourceFilter::CMatroskaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
//
CMatroskaSplitterOutputPin::CMatroskaSplitterOutputPin(
- unsigned int nMinCache, REFERENCE_TIME rtDefaultDuration,
- CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseSplitterOutputPin(mts, pName, pFilter, pLock, phr)
- , m_nMinCache(nMinCache), m_rtDefaultDuration(rtDefaultDuration)
+ unsigned int nMinCache, REFERENCE_TIME rtDefaultDuration,
+ CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
+ : CBaseSplitterOutputPin(mts, pName, pFilter, pLock, phr)
+ , m_nMinCache(nMinCache), m_rtDefaultDuration(rtDefaultDuration)
{
- m_nMinCache = 1;//max(m_nMinCache, 1);
+ m_nMinCache = 1;//max(m_nMinCache, 1);
}
CMatroskaSplitterOutputPin::~CMatroskaSplitterOutputPin()
@@ -1378,281 +1386,281 @@ CMatroskaSplitterOutputPin::~CMatroskaSplitterOutputPin()
HRESULT CMatroskaSplitterOutputPin::DeliverEndFlush()
{
- {
- CAutoLock cAutoLock(&m_csQueue);
- m_packets.RemoveAll();
- m_rob.RemoveAll();
- m_tos.RemoveAll();
- }
-
- return __super::DeliverEndFlush();
+ {
+ CAutoLock cAutoLock(&m_csQueue);
+ m_packets.RemoveAll();
+ m_rob.RemoveAll();
+ m_tos.RemoveAll();
+ }
+
+ return __super::DeliverEndFlush();
}
HRESULT CMatroskaSplitterOutputPin::DeliverEndOfStream()
{
- CAutoLock cAutoLock(&m_csQueue);
-
- // send out the last remaining packets from the queue
-
- while (m_rob.GetCount()) {
- MatroskaPacket* mp = m_rob.RemoveHead();
- if (m_rob.GetCount() && !mp->bg->BlockDuration.IsValid()) {
- mp->rtStop = m_rob.GetHead()->rtStart;
- } else if (m_rob.GetCount() == 0 && m_rtDefaultDuration > 0) {
- mp->rtStop = mp->rtStart + m_rtDefaultDuration;
- }
-
- timeoverride to = {mp->rtStart, mp->rtStop};
- m_tos.AddTail(to);
- }
-
- while (m_packets.GetCount()) {
- HRESULT hr = DeliverBlock(m_packets.RemoveHead());
- if (hr != S_OK) {
- return hr;
- }
- }
-
- return __super::DeliverEndOfStream();
+ CAutoLock cAutoLock(&m_csQueue);
+
+ // send out the last remaining packets from the queue
+
+ while (m_rob.GetCount()) {
+ MatroskaPacket* mp = m_rob.RemoveHead();
+ if (m_rob.GetCount() && !mp->bg->BlockDuration.IsValid()) {
+ mp->rtStop = m_rob.GetHead()->rtStart;
+ } else if (m_rob.GetCount() == 0 && m_rtDefaultDuration > 0) {
+ mp->rtStop = mp->rtStart + m_rtDefaultDuration;
+ }
+
+ timeoverride to = {mp->rtStart, mp->rtStop};
+ m_tos.AddTail(to);
+ }
+
+ while (m_packets.GetCount()) {
+ HRESULT hr = DeliverBlock(m_packets.RemoveHead());
+ if (hr != S_OK) {
+ return hr;
+ }
+ }
+
+ return __super::DeliverEndOfStream();
}
HRESULT CMatroskaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
{
- MatroskaPacket* mp = dynamic_cast<MatroskaPacket*>(p.m_p);
- if (!mp) {
- return __super::DeliverPacket(p);
- }
-
- // don't try to understand what's happening here, it's magic
-
- CAutoLock cAutoLock(&m_csQueue);
-
- CAutoPtr<MatroskaPacket> p2;
- p.Detach();
- p2.Attach(mp);
- m_packets.AddTail(p2);
-
- POSITION pos = m_rob.GetTailPosition();
- _ASSERTE(m_nMinCache > 0);
- for (int i = m_nMinCache - 1; i > 0 && pos && mp->bg->ReferencePriority < m_rob.GetAt(pos)->bg->ReferencePriority; --i) {
- m_rob.GetPrev(pos);
- }
-
- if (!pos) {
- m_rob.AddHead(mp);
- } else {
- m_rob.InsertAfter(pos, mp);
- }
-
- mp = NULL;
-
- if (m_rob.GetCount() == m_nMinCache + 1) {
- ASSERT(m_nMinCache > 0);
- pos = m_rob.GetHeadPosition();
- MatroskaPacket* mp1 = m_rob.GetNext(pos);
- MatroskaPacket* mp2 = m_rob.GetNext(pos);
- if (!mp1->bg->BlockDuration.IsValid()) {
- mp1->bg->BlockDuration.Set(1); // just to set it valid
-
- if (mp1->rtStart >= mp2->rtStart) {
- /* CString str;
- str.Format(_T("mp1->rtStart (%I64d) >= mp2->rtStart (%I64d)!!!\n"), mp1->rtStart, mp2->rtStart);
- AfxMessageBox(str);
- */
- // TRACE(_T("mp1->rtStart (%I64d) >= mp2->rtStart (%I64d)!!!\n"), mp1->rtStart, mp2->rtStart);
- } else {
- mp1->rtStop = mp2->rtStart;
- }
- }
- }
-
- while (m_packets.GetCount()) {
- mp = m_packets.GetHead();
- if (!mp->bg->BlockDuration.IsValid()) {
- break;
- }
-
- mp = m_rob.RemoveHead();
- timeoverride to = {mp->rtStart, mp->rtStop};
- m_tos.AddTail(to);
-
- HRESULT hr = DeliverBlock(m_packets.RemoveHead());
- if (hr != S_OK) {
- return hr;
- }
- }
-
- return S_OK;
+ MatroskaPacket* mp = dynamic_cast<MatroskaPacket*>(p.m_p);
+ if (!mp) {
+ return __super::DeliverPacket(p);
+ }
+
+ // don't try to understand what's happening here, it's magic
+
+ CAutoLock cAutoLock(&m_csQueue);
+
+ CAutoPtr<MatroskaPacket> p2;
+ p.Detach();
+ p2.Attach(mp);
+ m_packets.AddTail(p2);
+
+ POSITION pos = m_rob.GetTailPosition();
+ _ASSERTE(m_nMinCache > 0);
+ for (int i = m_nMinCache - 1; i > 0 && pos && mp->bg->ReferencePriority < m_rob.GetAt(pos)->bg->ReferencePriority; --i) {
+ m_rob.GetPrev(pos);
+ }
+
+ if (!pos) {
+ m_rob.AddHead(mp);
+ } else {
+ m_rob.InsertAfter(pos, mp);
+ }
+
+ mp = NULL;
+
+ if (m_rob.GetCount() == m_nMinCache + 1) {
+ ASSERT(m_nMinCache > 0);
+ pos = m_rob.GetHeadPosition();
+ MatroskaPacket* mp1 = m_rob.GetNext(pos);
+ MatroskaPacket* mp2 = m_rob.GetNext(pos);
+ if (!mp1->bg->BlockDuration.IsValid()) {
+ mp1->bg->BlockDuration.Set(1); // just to set it valid
+
+ if (mp1->rtStart >= mp2->rtStart) {
+ /* CString str;
+ str.Format(_T("mp1->rtStart (%I64d) >= mp2->rtStart (%I64d)!!!\n"), mp1->rtStart, mp2->rtStart);
+ AfxMessageBox(str);
+ */
+ // TRACE(_T("mp1->rtStart (%I64d) >= mp2->rtStart (%I64d)!!!\n"), mp1->rtStart, mp2->rtStart);
+ } else {
+ mp1->rtStop = mp2->rtStart;
+ }
+ }
+ }
+
+ while (m_packets.GetCount()) {
+ mp = m_packets.GetHead();
+ if (!mp->bg->BlockDuration.IsValid()) {
+ break;
+ }
+
+ mp = m_rob.RemoveHead();
+ timeoverride to = {mp->rtStart, mp->rtStop};
+ m_tos.AddTail(to);
+
+ HRESULT hr = DeliverBlock(m_packets.RemoveHead());
+ if (hr != S_OK) {
+ return hr;
+ }
+ }
+
+ return S_OK;
}
HRESULT CMatroskaSplitterOutputPin::DeliverBlock(MatroskaPacket* p)
{
- HRESULT hr = S_FALSE;
+ HRESULT hr = S_FALSE;
- if (m_tos.GetCount()) {
- timeoverride to = m_tos.RemoveHead();
+ if (m_tos.GetCount()) {
+ timeoverride to = m_tos.RemoveHead();
#if defined(_DEBUG) && 0
- TRACE(_T("(track=%d) %I64d, %I64d -> %I64d, %I64d (buffcnt=%d)\n"),
- p->TrackNumber, p->rtStart, p->rtStop, to.rtStart, to.rtStop,
- QueueCount());
+ TRACE(_T("(track=%d) %I64d, %I64d -> %I64d, %I64d (buffcnt=%d)\n"),
+ p->TrackNumber, p->rtStart, p->rtStop, to.rtStart, to.rtStop,
+ QueueCount());
#endif
- p->rtStart = to.rtStart;
- p->rtStop = to.rtStop;
- }
-
- REFERENCE_TIME
- rtStart = p->rtStart,
- rtDelta = (p->rtStop - p->rtStart) / p->bg->Block.BlockData.GetCount(),
- rtStop = p->rtStart + rtDelta;
-
- POSITION pos = p->bg->Block.BlockData.GetHeadPosition();
- while (pos) {
- CAutoPtr<Packet> tmp(DNew Packet());
- tmp->TrackNumber = p->TrackNumber;
- tmp->bDiscontinuity = p->bDiscontinuity;
- tmp->bSyncPoint = p->bSyncPoint;
- tmp->rtStart = rtStart;
- tmp->rtStop = rtStop;
- tmp->Copy(*p->bg->Block.BlockData.GetNext(pos));
- if (S_OK != (hr = DeliverPacket(tmp))) {
- break;
- }
-
- rtStart += rtDelta;
- rtStop += rtDelta;
-
- p->bSyncPoint = false;
- p->bDiscontinuity = false;
- }
-
- if (m_mt.subtype == FOURCCMap(WAVE_FORMAT_WAVPACK4)) {
- POSITION pos = p->bg->ba.bm.GetHeadPosition();
- while (pos) {
- const BlockMore* bm = p->bg->ba.bm.GetNext(pos);
- CAutoPtr<Packet> tmp(DNew Packet());
- tmp->TrackNumber = p->TrackNumber;
- tmp->bDiscontinuity = false;
- tmp->bSyncPoint = false;
- tmp->rtStart = p->rtStart;
- tmp->rtStop = p->rtStop;
- tmp->Copy(bm->BlockAdditional);
- if (S_OK != (hr = DeliverPacket(tmp))) {
- break;
- }
- }
- }
-
- return hr;
+ p->rtStart = to.rtStart;
+ p->rtStop = to.rtStop;
+ }
+
+ REFERENCE_TIME
+ rtStart = p->rtStart,
+ rtDelta = (p->rtStop - p->rtStart) / p->bg->Block.BlockData.GetCount(),
+ rtStop = p->rtStart + rtDelta;
+
+ POSITION pos = p->bg->Block.BlockData.GetHeadPosition();
+ while (pos) {
+ CAutoPtr<Packet> tmp(DNew Packet());
+ tmp->TrackNumber = p->TrackNumber;
+ tmp->bDiscontinuity = p->bDiscontinuity;
+ tmp->bSyncPoint = p->bSyncPoint;
+ tmp->rtStart = rtStart;
+ tmp->rtStop = rtStop;
+ tmp->Copy(*p->bg->Block.BlockData.GetNext(pos));
+ if (S_OK != (hr = DeliverPacket(tmp))) {
+ break;
+ }
+
+ rtStart += rtDelta;
+ rtStop += rtDelta;
+
+ p->bSyncPoint = false;
+ p->bDiscontinuity = false;
+ }
+
+ if (m_mt.subtype == FOURCCMap(WAVE_FORMAT_WAVPACK4)) {
+ POSITION pos = p->bg->ba.bm.GetHeadPosition();
+ while (pos) {
+ const BlockMore* bm = p->bg->ba.bm.GetNext(pos);
+ CAutoPtr<Packet> tmp(DNew Packet());
+ tmp->TrackNumber = p->TrackNumber;
+ tmp->bDiscontinuity = false;
+ tmp->bSyncPoint = false;
+ tmp->rtStart = p->rtStart;
+ tmp->rtStop = p->rtStop;
+ tmp->Copy(bm->BlockAdditional);
+ if (S_OK != (hr = DeliverPacket(tmp))) {
+ break;
+ }
+ }
+ }
+
+ return hr;
}
// ITrackInfo
TrackEntry* CMatroskaSplitterFilter::GetTrackEntryAt(UINT aTrackIdx)
{
- if (aTrackIdx >= m_pOrderedTrackArray.GetCount()) {
- return NULL;
- }
- return m_pOrderedTrackArray[aTrackIdx];
+ if (aTrackIdx >= m_pOrderedTrackArray.GetCount()) {
+ return NULL;
+ }
+ return m_pOrderedTrackArray[aTrackIdx];
}
STDMETHODIMP_(UINT) CMatroskaSplitterFilter::GetTrackCount()
{
- return (UINT)m_pTrackEntryMap.GetCount();
+ return (UINT)m_pTrackEntryMap.GetCount();
}
STDMETHODIMP_(BOOL) CMatroskaSplitterFilter::GetTrackInfo(UINT aTrackIdx, struct TrackElement* pStructureToFill)
{
- TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if (pTE == NULL) {
- return FALSE;
- }
-
- pStructureToFill->FlagDefault = !!pTE->FlagDefault;
- pStructureToFill->FlagForced = !!pTE->FlagForced;
- pStructureToFill->FlagLacing = !!pTE->FlagLacing;
- strncpy_s(pStructureToFill->Language, pTE->Language, 3);
- if (pStructureToFill->Language[0] == '\0') {
- strncpy_s(pStructureToFill->Language, "eng", 3);
- }
- pStructureToFill->Language[3] = '\0';
- pStructureToFill->MaxCache = (UINT)pTE->MaxCache;
- pStructureToFill->MinCache = (UINT)pTE->MinCache;
- pStructureToFill->Type = (BYTE)pTE->TrackType;
- return TRUE;
+ TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
+ if (pTE == NULL) {
+ return FALSE;
+ }
+
+ pStructureToFill->FlagDefault = !!pTE->FlagDefault;
+ pStructureToFill->FlagForced = !!pTE->FlagForced;
+ pStructureToFill->FlagLacing = !!pTE->FlagLacing;
+ strncpy_s(pStructureToFill->Language, pTE->Language, 3);
+ if (pStructureToFill->Language[0] == '\0') {
+ strncpy_s(pStructureToFill->Language, "eng", 3);
+ }
+ pStructureToFill->Language[3] = '\0';
+ pStructureToFill->MaxCache = (UINT)pTE->MaxCache;
+ pStructureToFill->MinCache = (UINT)pTE->MinCache;
+ pStructureToFill->Type = (BYTE)pTE->TrackType;
+ return TRUE;
}
STDMETHODIMP_(BOOL) CMatroskaSplitterFilter::GetTrackExtendedInfo(UINT aTrackIdx, void* pStructureToFill)
{
- TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if (pTE == NULL) {
- return FALSE;
- }
-
- if (pTE->TrackType == TrackEntry::TypeVideo) {
- TrackExtendedInfoVideo* pTEIV = (TrackExtendedInfoVideo*)pStructureToFill;
- pTEIV->AspectRatioType = (BYTE)pTE->v.AspectRatioType;
- pTEIV->DisplayUnit = (BYTE)pTE->v.DisplayUnit;
- pTEIV->DisplayWidth = (UINT)pTE->v.DisplayWidth;
- pTEIV->DisplayHeight = (UINT)pTE->v.DisplayHeight;
- pTEIV->Interlaced = !!pTE->v.FlagInterlaced;
- pTEIV->PixelWidth = (UINT)pTE->v.PixelWidth;
- pTEIV->PixelHeight = (UINT)pTE->v.PixelHeight;
- } else if (pTE->TrackType == TrackEntry::TypeAudio) {
- TrackExtendedInfoAudio* pTEIA = (TrackExtendedInfoAudio*)pStructureToFill;
- pTEIA->BitDepth = (UINT)pTE->a.BitDepth;
- pTEIA->Channels = (UINT)pTE->a.Channels;
- pTEIA->OutputSamplingFrequency = (FLOAT)pTE->a.OutputSamplingFrequency;
- pTEIA->SamplingFreq = (FLOAT)pTE->a.SamplingFrequency;
- } else {
- return FALSE;
- }
-
- return TRUE;
+ TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
+ if (pTE == NULL) {
+ return FALSE;
+ }
+
+ if (pTE->TrackType == TrackEntry::TypeVideo) {
+ TrackExtendedInfoVideo* pTEIV = (TrackExtendedInfoVideo*)pStructureToFill;
+ pTEIV->AspectRatioType = (BYTE)pTE->v.AspectRatioType;
+ pTEIV->DisplayUnit = (BYTE)pTE->v.DisplayUnit;
+ pTEIV->DisplayWidth = (UINT)pTE->v.DisplayWidth;
+ pTEIV->DisplayHeight = (UINT)pTE->v.DisplayHeight;
+ pTEIV->Interlaced = !!pTE->v.FlagInterlaced;
+ pTEIV->PixelWidth = (UINT)pTE->v.PixelWidth;
+ pTEIV->PixelHeight = (UINT)pTE->v.PixelHeight;
+ } else if (pTE->TrackType == TrackEntry::TypeAudio) {
+ TrackExtendedInfoAudio* pTEIA = (TrackExtendedInfoAudio*)pStructureToFill;
+ pTEIA->BitDepth = (UINT)pTE->a.BitDepth;
+ pTEIA->Channels = (UINT)pTE->a.Channels;
+ pTEIA->OutputSamplingFrequency = (FLOAT)pTE->a.OutputSamplingFrequency;
+ pTEIA->SamplingFreq = (FLOAT)pTE->a.SamplingFrequency;
+ } else {
+ return FALSE;
+ }
+
+ return TRUE;
}
STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackName(UINT aTrackIdx)
{
- TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if (pTE == NULL) {
- return NULL;
- }
- return pTE->Name.AllocSysString();
+ TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
+ if (pTE == NULL) {
+ return NULL;
+ }
+ return pTE->Name.AllocSysString();
}
STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackCodecID(UINT aTrackIdx)
{
- TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if (pTE == NULL) {
- return NULL;
- }
- return pTE->CodecID.ToString().AllocSysString();
+ TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
+ if (pTE == NULL) {
+ return NULL;
+ }
+ return pTE->CodecID.ToString().AllocSysString();
}
STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackCodecName(UINT aTrackIdx)
{
- TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if (pTE == NULL) {
- return NULL;
- }
- return pTE->CodecName.AllocSysString();
+ TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
+ if (pTE == NULL) {
+ return NULL;
+ }
+ return pTE->CodecName.AllocSysString();
}
STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackCodecInfoURL(UINT aTrackIdx)
{
- TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if (pTE == NULL) {
- return NULL;
- }
- return pTE->CodecInfoURL.AllocSysString();
+ TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
+ if (pTE == NULL) {
+ return NULL;
+ }
+ return pTE->CodecInfoURL.AllocSysString();
}
STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackCodecDownloadURL(UINT aTrackIdx)
{
- TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if (pTE == NULL) {
- return NULL;
- }
- return pTE->CodecDownloadURL.AllocSysString();
+ TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
+ if (pTE == NULL) {
+ return NULL;
+ }
+ return pTE->CodecDownloadURL.AllocSysString();
}
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.h b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.h
index a6843bce8..959e33995 100644
--- a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.h
+++ b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.h
@@ -35,99 +35,99 @@
class MatroskaPacket : public Packet
{
protected:
- int GetDataSize() {
- size_t size = 0;
- POSITION pos = bg->Block.BlockData.GetHeadPosition();
- while (pos) {
- size += bg->Block.BlockData.GetNext(pos)->GetCount();
- }
- return (int)size;
- }
+ int GetDataSize() {
+ size_t size = 0;
+ POSITION pos = bg->Block.BlockData.GetHeadPosition();
+ while (pos) {
+ size += bg->Block.BlockData.GetNext(pos)->GetCount();
+ }
+ return (int)size;
+ }
public:
- CAutoPtr<MatroskaReader::BlockGroup> bg;
+ CAutoPtr<MatroskaReader::BlockGroup> bg;
};
class CMatroskaSplitterOutputPin : public CBaseSplitterOutputPin
{
- HRESULT DeliverBlock(MatroskaPacket* p);
+ HRESULT DeliverBlock(MatroskaPacket* p);
- unsigned int m_nMinCache;
- REFERENCE_TIME m_rtDefaultDuration;
+ unsigned int m_nMinCache;
+ REFERENCE_TIME m_rtDefaultDuration;
- CCritSec m_csQueue;
- CAutoPtrList<MatroskaPacket> m_packets;
- CAtlList<MatroskaPacket*> m_rob;
+ CCritSec m_csQueue;
+ CAutoPtrList<MatroskaPacket> m_packets;
+ CAtlList<MatroskaPacket*> m_rob;
- typedef struct {
- REFERENCE_TIME rtStart, rtStop;
- } timeoverride;
- CAtlList<timeoverride> m_tos;
+ typedef struct {
+ REFERENCE_TIME rtStart, rtStop;
+ } timeoverride;
+ CAtlList<timeoverride> m_tos;
protected:
- HRESULT DeliverPacket(CAutoPtr<Packet> p);
+ HRESULT DeliverPacket(CAutoPtr<Packet> p);
public:
- CMatroskaSplitterOutputPin(
- unsigned int nMinCache, REFERENCE_TIME rtDefaultDuration,
- CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
- virtual ~CMatroskaSplitterOutputPin();
+ CMatroskaSplitterOutputPin(
+ unsigned int nMinCache, REFERENCE_TIME rtDefaultDuration,
+ CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
+ virtual ~CMatroskaSplitterOutputPin();
- HRESULT DeliverEndFlush();
- HRESULT DeliverEndOfStream();
+ HRESULT DeliverEndFlush();
+ HRESULT DeliverEndOfStream();
};
class __declspec(uuid("149D2E01-C32E-4939-80F6-C07B81015A7A"))
- CMatroskaSplitterFilter : public CBaseSplitterFilter, public ITrackInfo
+ CMatroskaSplitterFilter : public CBaseSplitterFilter, public ITrackInfo
{
- void SetupChapters(LPCSTR lng, MatroskaReader::ChapterAtom* parent, int level = 0);
- void InstallFonts();
- void SendVorbisHeaderSample();
+ void SetupChapters(LPCSTR lng, MatroskaReader::ChapterAtom* parent, int level = 0);
+ void InstallFonts();
+ void SendVorbisHeaderSample();
- CAutoPtr<MatroskaReader::CMatroskaNode> m_pSegment, m_pCluster, m_pBlock;
+ CAutoPtr<MatroskaReader::CMatroskaNode> m_pSegment, m_pCluster, m_pBlock;
protected:
- CAutoPtr<MatroskaReader::CMatroskaFile> m_pFile;
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
+ CAutoPtr<MatroskaReader::CMatroskaFile> m_pFile;
+ HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
- CAtlMap<DWORD, MatroskaReader::TrackEntry*> m_pTrackEntryMap;
- CAtlArray<MatroskaReader::TrackEntry* > m_pOrderedTrackArray;
- MatroskaReader::TrackEntry* GetTrackEntryAt(UINT aTrackIdx);
+ CAtlMap<DWORD, MatroskaReader::TrackEntry*> m_pTrackEntryMap;
+ CAtlArray<MatroskaReader::TrackEntry* > m_pOrderedTrackArray;
+ MatroskaReader::TrackEntry* GetTrackEntryAt(UINT aTrackIdx);
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
+ bool DemuxInit();
+ void DemuxSeek(REFERENCE_TIME rt);
+ bool DemuxLoop();
public:
- CMatroskaSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
- virtual ~CMatroskaSplitterFilter();
+ CMatroskaSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
+ virtual ~CMatroskaSplitterFilter();
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // CBaseFilter
+ // CBaseFilter
- STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
+ STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
- // IKeyFrameInfo
+ // IKeyFrameInfo
- STDMETHODIMP GetKeyFrameCount(UINT& nKFs);
- STDMETHODIMP GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs);
+ STDMETHODIMP GetKeyFrameCount(UINT& nKFs);
+ STDMETHODIMP GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs);
- // ITrackInfo
+ // ITrackInfo
- STDMETHODIMP_(UINT) GetTrackCount();
- STDMETHODIMP_(BOOL) GetTrackInfo(UINT aTrackIdx, struct TrackElement* pStructureToFill);
- STDMETHODIMP_(BOOL) GetTrackExtendedInfo(UINT aTrackIdx, void* pStructureToFill);
- STDMETHODIMP_(BSTR) GetTrackName(UINT aTrackIdx);
- STDMETHODIMP_(BSTR) GetTrackCodecID(UINT aTrackIdx);
- STDMETHODIMP_(BSTR) GetTrackCodecName(UINT aTrackIdx);
- STDMETHODIMP_(BSTR) GetTrackCodecInfoURL(UINT aTrackIdx);
- STDMETHODIMP_(BSTR) GetTrackCodecDownloadURL(UINT aTrackIdx);
+ STDMETHODIMP_(UINT) GetTrackCount();
+ STDMETHODIMP_(BOOL) GetTrackInfo(UINT aTrackIdx, struct TrackElement* pStructureToFill);
+ STDMETHODIMP_(BOOL) GetTrackExtendedInfo(UINT aTrackIdx, void* pStructureToFill);
+ STDMETHODIMP_(BSTR) GetTrackName(UINT aTrackIdx);
+ STDMETHODIMP_(BSTR) GetTrackCodecID(UINT aTrackIdx);
+ STDMETHODIMP_(BSTR) GetTrackCodecName(UINT aTrackIdx);
+ STDMETHODIMP_(BSTR) GetTrackCodecInfoURL(UINT aTrackIdx);
+ STDMETHODIMP_(BSTR) GetTrackCodecDownloadURL(UINT aTrackIdx);
};
class __declspec(uuid("0A68C3B5-9164-4a54-AFAF-995B2FF0E0D4"))
- CMatroskaSourceFilter : public CMatroskaSplitterFilter
+ CMatroskaSourceFilter : public CMatroskaSplitterFilter
{
public:
- CMatroskaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
+ CMatroskaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
};
diff --git a/src/filters/parser/MpaSplitter/MpaSplitter.cpp b/src/filters/parser/MpaSplitter/MpaSplitter.cpp
index 4a76ee4ac..ae738753d 100644
--- a/src/filters/parser/MpaSplitter/MpaSplitter.cpp
+++ b/src/filters/parser/MpaSplitter/MpaSplitter.cpp
@@ -32,40 +32,40 @@
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG1Audio},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL}
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG1Audio},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL}
};
const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CMpaSplitterFilter), MpaSplitterName, MERIT_NORMAL+1, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CMpaSourceFilter), MpaSourceName, MERIT_NORMAL+1, 0, NULL, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CMpaSplitterFilter), MpaSplitterName, MERIT_NORMAL + 1, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CMpaSourceFilter), MpaSourceName, MERIT_NORMAL + 1, 0, NULL, CLSID_LegacyAmFilterCategory},
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMpaSplitterFilter>, NULL, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CMpaSourceFilter>, NULL, &sudFilter[1]},
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMpaSplitterFilter>, NULL, &sudFilter[0]},
+ {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CMpaSourceFilter>, NULL, &sudFilter[1]},
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- CAtlList<CString> chkbytes;
- chkbytes.AddTail(_T("0,2,FFE0,FFE0"));
- chkbytes.AddTail(_T("0,10,FFFFFF00000080808080,49443300000000000000"));
- RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_MPEG1Audio, chkbytes, NULL);
+ CAtlList<CString> chkbytes;
+ chkbytes.AddTail(_T("0,2,FFE0,FFE0"));
+ chkbytes.AddTail(_T("0,10,FFFFFF00000080808080,49443300000000000000"));
+ RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_MPEG1Audio, chkbytes, NULL);
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -79,150 +79,150 @@ CFilterApp theApp;
//
CMpaSplitterFilter::CMpaSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("CMpaSplitterFilter"), pUnk, phr, __uuidof(this))
+ : CBaseSplitterFilter(NAME("CMpaSplitterFilter"), pUnk, phr, __uuidof(this))
{
}
STDMETHODIMP CMpaSplitterFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
STDMETHODIMP CMpaSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo)
{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
-
- if (m_pName && m_pName[0]==L'M' && m_pName[1]==L'P' && m_pName[2]==L'C') {
- (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
- } else {
- wcscpy_s(pInfo->achName, MpaSourceName);
- }
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
+ CheckPointer(pInfo, E_POINTER);
+ ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
+
+ if (m_pName && m_pName[0] == L'M' && m_pName[1] == L'P' && m_pName[2] == L'C') {
+ (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
+ } else {
+ wcscpy_s(pInfo->achName, MpaSourceName);
+ }
+ pInfo->pGraph = m_pGraph;
+ if (m_pGraph) {
+ m_pGraph->AddRef();
+ }
+
+ return S_OK;
}
HRESULT CMpaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
{
- CheckPointer(pAsyncReader, E_POINTER);
-
- HRESULT hr = E_FAIL;
-
- m_pFile.Free();
-
- m_pFile.Attach(DNew CMpaSplitterFile(pAsyncReader, hr));
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- CAtlArray<CMediaType> mts;
- mts.Add(m_pFile->GetMediaType());
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, L"Audio", this, this, &hr));
- AddOutputPin(0, pPinOut);
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration = m_pFile->GetDuration();
-
- CStringW str, title;
- if (m_pFile->m_tags.Lookup('TIT2', str)) {
- title = str;
- }
- if (m_pFile->m_tags.Lookup('TYER', str) && !title.IsEmpty() && !str.IsEmpty()) {
- title += L" (" + str + L")";
- }
- if (!title.IsEmpty()) {
- SetProperty(L"TITL", title);
- }
- if (m_pFile->m_tags.Lookup('TPE1', str)) {
- SetProperty(L"AUTH", str);
- }
- if (m_pFile->m_tags.Lookup('TCOP', str)) {
- SetProperty(L"CPYR", str);
- }
- if (m_pFile->m_tags.Lookup('COMM', str)) {
- SetProperty(L"DESC", str);
- }
-
- return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
+ CheckPointer(pAsyncReader, E_POINTER);
+
+ HRESULT hr = E_FAIL;
+
+ m_pFile.Free();
+
+ m_pFile.Attach(DNew CMpaSplitterFile(pAsyncReader, hr));
+ if (!m_pFile) {
+ return E_OUTOFMEMORY;
+ }
+ if (FAILED(hr)) {
+ m_pFile.Free();
+ return hr;
+ }
+
+ CAtlArray<CMediaType> mts;
+ mts.Add(m_pFile->GetMediaType());
+
+ CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, L"Audio", this, this, &hr));
+ AddOutputPin(0, pPinOut);
+
+ m_rtNewStart = m_rtCurrent = 0;
+ m_rtNewStop = m_rtStop = m_rtDuration = m_pFile->GetDuration();
+
+ CStringW str, title;
+ if (m_pFile->m_tags.Lookup('TIT2', str)) {
+ title = str;
+ }
+ if (m_pFile->m_tags.Lookup('TYER', str) && !title.IsEmpty() && !str.IsEmpty()) {
+ title += L" (" + str + L")";
+ }
+ if (!title.IsEmpty()) {
+ SetProperty(L"TITL", title);
+ }
+ if (m_pFile->m_tags.Lookup('TPE1', str)) {
+ SetProperty(L"AUTH", str);
+ }
+ if (m_pFile->m_tags.Lookup('TCOP', str)) {
+ SetProperty(L"CPYR", str);
+ }
+ if (m_pFile->m_tags.Lookup('COMM', str)) {
+ SetProperty(L"DESC", str);
+ }
+
+ return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
}
STDMETHODIMP CMpaSplitterFilter::GetDuration(LONGLONG* pDuration)
{
- CheckPointer(pDuration, E_POINTER);
- CheckPointer(m_pFile, VFW_E_NOT_CONNECTED);
+ CheckPointer(pDuration, E_POINTER);
+ CheckPointer(m_pFile, VFW_E_NOT_CONNECTED);
- *pDuration = m_pFile->GetDuration();
+ *pDuration = m_pFile->GetDuration();
- return S_OK;
+ return S_OK;
}
bool CMpaSplitterFilter::DemuxInit()
{
- SetThreadName((DWORD)-1, "CMpaSplitterFilter");
- if (!m_pFile) {
- return false;
- }
+ SetThreadName((DWORD) - 1, "CMpaSplitterFilter");
+ if (!m_pFile) {
+ return false;
+ }
- // TODO
+ // TODO
- return true;
+ return true;
}
void CMpaSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
- __int64 startpos = m_pFile->GetStartPos();
- __int64 endpos = m_pFile->GetEndPos();
+ __int64 startpos = m_pFile->GetStartPos();
+ __int64 endpos = m_pFile->GetEndPos();
- if (rt <= 0 || m_pFile->GetDuration() <= 0) {
- m_pFile->Seek(startpos);
- m_rtStart = 0;
- } else {
- m_pFile->Seek(startpos + (__int64)((1.0 * rt / m_pFile->GetDuration()) * (endpos - startpos)));
- m_rtStart = rt;
- }
+ if (rt <= 0 || m_pFile->GetDuration() <= 0) {
+ m_pFile->Seek(startpos);
+ m_rtStart = 0;
+ } else {
+ m_pFile->Seek(startpos + (__int64)((1.0 * rt / m_pFile->GetDuration()) * (endpos - startpos)));
+ m_rtStart = rt;
+ }
}
bool CMpaSplitterFilter::DemuxLoop()
{
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- int FrameSize;
- REFERENCE_TIME rtDuration;
+ int FrameSize;
+ REFERENCE_TIME rtDuration;
- while (SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetPos() < m_pFile->GetEndPos() - 9) {
- if (!m_pFile->Sync(FrameSize, rtDuration)) {
- Sleep(1);
- continue;
- }
+ while (SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetPos() < m_pFile->GetEndPos() - 9) {
+ if (!m_pFile->Sync(FrameSize, rtDuration)) {
+ Sleep(1);
+ continue;
+ }
- CAutoPtr<Packet> p(DNew Packet());
- p->SetCount(FrameSize);
- m_pFile->ByteRead(p->GetData(), FrameSize);
+ CAutoPtr<Packet> p(DNew Packet());
+ p->SetCount(FrameSize);
+ m_pFile->ByteRead(p->GetData(), FrameSize);
- p->TrackNumber = 0;
- p->rtStart = m_rtStart;
- p->rtStop = m_rtStart + rtDuration;
- p->bSyncPoint = TRUE;
+ p->TrackNumber = 0;
+ p->rtStart = m_rtStart;
+ p->rtStop = m_rtStart + rtDuration;
+ p->bSyncPoint = TRUE;
- hr = DeliverPacket(p);
+ hr = DeliverPacket(p);
- m_rtStart += rtDuration;
- }
+ m_rtStart += rtDuration;
+ }
- return true;
+ return true;
}
//
@@ -230,8 +230,8 @@ bool CMpaSplitterFilter::DemuxLoop()
//
CMpaSourceFilter::CMpaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CMpaSplitterFilter(pUnk, phr)
+ : CMpaSplitterFilter(pUnk, phr)
{
- m_clsid = __uuidof(this);
- m_pInput.Free();
+ m_clsid = __uuidof(this);
+ m_pInput.Free();
}
diff --git a/src/filters/parser/MpaSplitter/MpaSplitter.h b/src/filters/parser/MpaSplitter/MpaSplitter.h
index 62e22103e..3f6e6ddbc 100644
--- a/src/filters/parser/MpaSplitter/MpaSplitter.h
+++ b/src/filters/parser/MpaSplitter/MpaSplitter.h
@@ -30,35 +30,35 @@
#define MpaSourceName L"MPC Mpa Source"
class __declspec(uuid("0E9D4BF7-CBCB-46C7-BD80-4EF223A3DC2B"))
- CMpaSplitterFilter : public CBaseSplitterFilter
+ CMpaSplitterFilter : public CBaseSplitterFilter
{
- REFERENCE_TIME m_rtStart;
+ REFERENCE_TIME m_rtStart;
protected:
- CAutoPtr<CMpaSplitterFile> m_pFile;
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
+ CAutoPtr<CMpaSplitterFile> m_pFile;
+ HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
- STDMETHODIMP GetDuration(LONGLONG* pDuration);
+ STDMETHODIMP GetDuration(LONGLONG* pDuration);
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
+ bool DemuxInit();
+ void DemuxSeek(REFERENCE_TIME rt);
+ bool DemuxLoop();
public:
- CMpaSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
+ CMpaSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // CBaseFilter
+ // CBaseFilter
- STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
+ STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
};
class __declspec(uuid("59A0DB73-0287-4C9A-9D3C-8CFF39F8E5DB"))
- CMpaSourceFilter : public CMpaSplitterFilter
+ CMpaSourceFilter : public CMpaSplitterFilter
{
public:
- CMpaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
+ CMpaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
}; \ No newline at end of file
diff --git a/src/filters/parser/MpaSplitter/MpaSplitterFile.cpp b/src/filters/parser/MpaSplitter/MpaSplitterFile.cpp
index 912050406..a05a880b3 100644
--- a/src/filters/parser/MpaSplitter/MpaSplitterFile.cpp
+++ b/src/filters/parser/MpaSplitter/MpaSplitterFile.cpp
@@ -31,402 +31,403 @@
#include <moreuuids.h>
#define FRAMES_FLAG 0x0001
-#define MPA_HEADER_SIZE 4 // MPEG-Audio Header Size
+#define MPA_HEADER_SIZE 4 // MPEG-Audio Header Size
//
static const LPCTSTR s_genre[] = {
- _T("Blues"), _T("Classic Rock"), _T("Country"), _T("Dance"),
- _T("Disco"), _T("Funk"), _T("Grunge"), _T("Hip-Hop"),
- _T("Jazz"), _T("Metal"), _T("New Age"), _T("Oldies"),
- _T("Other"), _T("Pop"), _T("R&B"), _T("Rap"),
- _T("Reggae"), _T("Rock"), _T("Techno"), _T("Industrial"),
- _T("Alternative"), _T("Ska"), _T("Death Metal"), _T("Pranks"),
- _T("Soundtrack"), _T("Euro-Techno"), _T("Ambient"), _T("Trip-Hop"),
- _T("Vocal"), _T("Jazz+Funk"), _T("Fusion"), _T("Trance"),
- _T("Classical"), _T("Instrumental"), _T("Acid"), _T("House"),
- _T("Game"), _T("Sound Clip"), _T("Gospel"), _T("Noise"),
- _T("Alternative Rock"), _T("Bass"), _T("Soul"), _T("Punk"),
- _T("Space"), _T("Meditative"), _T("Instrumental Pop"), _T("Instrumental Rock"),
- _T("Ethnic"), _T("Gothic"), _T("Darkwave"), _T("Techno-Industrial"),
- _T("Electronic"), _T("Pop-Folk"), _T("Eurodance"), _T("Dream"),
- _T("Southern Rock"), _T("Comedy"), _T("Cult"), _T("Gangsta"),
- _T("Top 40"), _T("Christian Rap"), _T("Pop/Funk"), _T("Jungle"),
- _T("Native US"), _T("Cabaret"), _T("New Wave"), _T("Psychadelic"),
- _T("Rave"), _T("Showtunes"), _T("Trailer"), _T("Lo-Fi"),
- _T("Tribal"), _T("Acid Punk"), _T("Acid Jazz"), _T("Polka"),
- _T("Retro"), _T("Musical"), _T("Rock & Roll"), _T("Hard Rock"),
- _T("Folk"), _T("Folk-Rock"), _T("National Folk"), _T("Swing"),
- _T("Fast Fusion"), _T("Bebob"), _T("Latin"), _T("Revival"),
- _T("Celtic"), _T("Bluegrass"), _T("Avantgarde"), _T("Gothic Rock"),
- _T("Progressive Rock"), _T("Psychedelic Rock"), _T("Symphonic Rock"), _T("Slow Rock"),
- _T("Big Band"), _T("Chorus"), _T("Easy Listening"), _T("Acoustic"),
- _T("Humour"), _T("Speech"), _T("Chanson"), _T("Opera"),
- _T("Chamber Music"), _T("Sonata"), _T("Symphony"), _T("Booty Bass"),
- _T("Primus"), _T("Porn Groove"), _T("Satire"), _T("Slow Jam"),
- _T("Club"), _T("Tango"), _T("Samba"), _T("Folklore"),
- _T("Ballad"), _T("Power Ballad"), _T("Rhytmic Soul"), _T("Freestyle"),
- _T("Duet"), _T("Punk Rock"), _T("Drum Solo"), _T("Acapella"),
- _T("Euro-House"), _T("Dance Hall"), _T("Goa"), _T("Drum & Bass"),
- _T("Club-House"), _T("Hardcore"), _T("Terror"), _T("Indie"),
- _T("BritPop"), _T("Negerpunk"), _T("Polsk Punk"), _T("Beat"),
- _T("Christian Gangsta"), _T("Heavy Metal"), _T("Black Metal"),
- _T("Crossover"), _T("Contemporary C"), _T("Christian Rock"), _T("Merengue"), _T("Salsa"),
- _T("Thrash Metal"), _T("Anime"), _T("JPop"), _T("SynthPop"),
+ _T("Blues"), _T("Classic Rock"), _T("Country"), _T("Dance"),
+ _T("Disco"), _T("Funk"), _T("Grunge"), _T("Hip-Hop"),
+ _T("Jazz"), _T("Metal"), _T("New Age"), _T("Oldies"),
+ _T("Other"), _T("Pop"), _T("R&B"), _T("Rap"),
+ _T("Reggae"), _T("Rock"), _T("Techno"), _T("Industrial"),
+ _T("Alternative"), _T("Ska"), _T("Death Metal"), _T("Pranks"),
+ _T("Soundtrack"), _T("Euro-Techno"), _T("Ambient"), _T("Trip-Hop"),
+ _T("Vocal"), _T("Jazz+Funk"), _T("Fusion"), _T("Trance"),
+ _T("Classical"), _T("Instrumental"), _T("Acid"), _T("House"),
+ _T("Game"), _T("Sound Clip"), _T("Gospel"), _T("Noise"),
+ _T("Alternative Rock"), _T("Bass"), _T("Soul"), _T("Punk"),
+ _T("Space"), _T("Meditative"), _T("Instrumental Pop"), _T("Instrumental Rock"),
+ _T("Ethnic"), _T("Gothic"), _T("Darkwave"), _T("Techno-Industrial"),
+ _T("Electronic"), _T("Pop-Folk"), _T("Eurodance"), _T("Dream"),
+ _T("Southern Rock"), _T("Comedy"), _T("Cult"), _T("Gangsta"),
+ _T("Top 40"), _T("Christian Rap"), _T("Pop/Funk"), _T("Jungle"),
+ _T("Native US"), _T("Cabaret"), _T("New Wave"), _T("Psychadelic"),
+ _T("Rave"), _T("Showtunes"), _T("Trailer"), _T("Lo-Fi"),
+ _T("Tribal"), _T("Acid Punk"), _T("Acid Jazz"), _T("Polka"),
+ _T("Retro"), _T("Musical"), _T("Rock & Roll"), _T("Hard Rock"),
+ _T("Folk"), _T("Folk-Rock"), _T("National Folk"), _T("Swing"),
+ _T("Fast Fusion"), _T("Bebob"), _T("Latin"), _T("Revival"),
+ _T("Celtic"), _T("Bluegrass"), _T("Avantgarde"), _T("Gothic Rock"),
+ _T("Progressive Rock"), _T("Psychedelic Rock"), _T("Symphonic Rock"), _T("Slow Rock"),
+ _T("Big Band"), _T("Chorus"), _T("Easy Listening"), _T("Acoustic"),
+ _T("Humour"), _T("Speech"), _T("Chanson"), _T("Opera"),
+ _T("Chamber Music"), _T("Sonata"), _T("Symphony"), _T("Booty Bass"),
+ _T("Primus"), _T("Porn Groove"), _T("Satire"), _T("Slow Jam"),
+ _T("Club"), _T("Tango"), _T("Samba"), _T("Folklore"),
+ _T("Ballad"), _T("Power Ballad"), _T("Rhytmic Soul"), _T("Freestyle"),
+ _T("Duet"), _T("Punk Rock"), _T("Drum Solo"), _T("Acapella"),
+ _T("Euro-House"), _T("Dance Hall"), _T("Goa"), _T("Drum & Bass"),
+ _T("Club-House"), _T("Hardcore"), _T("Terror"), _T("Indie"),
+ _T("BritPop"), _T("Negerpunk"), _T("Polsk Punk"), _T("Beat"),
+ _T("Christian Gangsta"), _T("Heavy Metal"), _T("Black Metal"),
+ _T("Crossover"), _T("Contemporary C"), _T("Christian Rock"), _T("Merengue"), _T("Salsa"),
+ _T("Thrash Metal"), _T("Anime"), _T("JPop"), _T("SynthPop"),
};
//
CMpaSplitterFile::CMpaSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr)
- : CBaseSplitterFileEx(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false)
- , m_mode(none)
- , m_rtDuration(0)
- , m_startpos(0)
- , m_endpos(0)
- , m_totalbps(0)
- , m_bIsVBR(false)
+ : CBaseSplitterFileEx(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false)
+ , m_mode(none)
+ , m_rtDuration(0)
+ , m_startpos(0)
+ , m_endpos(0)
+ , m_totalbps(0)
+ , m_bIsVBR(false)
{
- if (SUCCEEDED(hr)) {
- hr = Init();
- }
+ if (SUCCEEDED(hr)) {
+ hr = Init();
+ }
}
HRESULT CMpaSplitterFile::Init()
{
- m_startpos = 0;
- m_endpos = GetLength();
-
- Seek(0);
-
- // some files can be determined as Mpeg Audio
- if ((BitRead(24, true) == 0x000001) || // ?
- (BitRead(32, true) == 'RIFF') || // skip AVI and WAV files
- (BitRead(24, true) == 'AMV')) { // skip MTV files (.amv .mtv)
- return E_FAIL;
- }
-
- if (m_endpos > 128 && IsRandomAccess()) {
- Seek(m_endpos - 128);
-
- if (BitRead(24) == 'TAG') {
- m_endpos -= 128;
-
- CStringA str;
-
- // title
- ByteRead((BYTE*)str.GetBufferSetLength(30), 30);
- m_tags['TIT2'] = CStringW(str).Trim();
-
- // artist
- ByteRead((BYTE*)str.GetBufferSetLength(30), 30);
- m_tags['TPE1'] = CStringW(str).Trim();
-
- // album
- ByteRead((BYTE*)str.GetBufferSetLength(30), 30);
- m_tags['TALB'] = CStringW(str).Trim();
-
- // year
- ByteRead((BYTE*)str.GetBufferSetLength(4), 4);
- m_tags['TYER'] = CStringW(str).Trim();
-
- // comment
- ByteRead((BYTE*)str.GetBufferSetLength(30), 30);
- m_tags['COMM'] = CStringW(str).Trim();
-
- // track
- LPCSTR s = str;
- if (s[28] == 0 && s[29] != 0) {
- m_tags['TRCK'].Format(L"%d", s[29]);
- }
-
- // genre
- BYTE genre = (BYTE)BitRead(8);
- if (genre < _countof(s_genre)) {
- m_tags['TCON'] = CStringW(s_genre[genre]);
- }
- }
- }
-
- Seek(0);
-
- bool MP3_find = false;
-
- while (BitRead(24, true) == 'ID3') {
- MP3_find = true;
-
- BitRead(24);
-
- BYTE major = (BYTE)BitRead(8);
- BYTE revision = (BYTE)BitRead(8);
- UNREFERENCED_PARAMETER(revision);
-
- BYTE flags = (BYTE)BitRead(8);
- UNREFERENCED_PARAMETER(flags);
- DWORD size = 0;
- if (BitRead(1) != 0) {
- return E_FAIL;
- }
- size |= BitRead(7) << 21;
- if (BitRead(1) != 0) {
- return E_FAIL;
- }
- size |= BitRead(7) << 14;
- if (BitRead(1) != 0) {
- return E_FAIL;
- }
- size |= BitRead(7) << 7;
- if (BitRead(1) != 0) {
- return E_FAIL;
- }
- size |= BitRead(7);
-
- m_startpos = GetPos() + size;
-
- // TODO: read extended header
-
- if (major <= 4) {
- __int64 pos = GetPos();
-
- while (pos < m_startpos) {
- Seek(pos);
-
- DWORD tag = (DWORD)BitRead(32);
- DWORD size = 0;
- size |= BitRead(8) << 24;
- size |= BitRead(8) << 16;
- size |= BitRead(8) << 8;
- size |= BitRead(8);
- WORD flags = (WORD)BitRead(16);
- UNREFERENCED_PARAMETER(flags);
-
- pos += 4+4+2+size;
-
- if (!size || pos >= m_startpos) {
- break;
- }
-
- if (tag == 'TIT2'
- || tag == 'TPE1'
- || tag == 'TALB'
- || tag == 'TYER'
- || tag == 'COMM'
- || tag == 'TRCK') {
- BYTE encoding = (BYTE)BitRead(8);
- size--;
-
- WORD bom = (WORD)BitRead(16, true);
-
- CStringA str;
- CStringW wstr;
-
- if (encoding > 0 && size >= 2 && bom == 0xfffe) {
- BitRead(16);
- size = (size - 2) / 2;
- ByteRead((BYTE*)wstr.GetBufferSetLength(size), size*2);
- m_tags[tag] = wstr.Trim();
- } else if (encoding > 0 && size >= 2 && bom == 0xfeff) {
- BitRead(16);
- size = (size - 2) / 2;
- ByteRead((BYTE*)wstr.GetBufferSetLength(size), size*2);
- for (int i = 0, j = wstr.GetLength(); i < j; i++) {
- wstr.SetAt(i, (wstr[i]<<8)|(wstr[i]>>8));
- }
- m_tags[tag] = wstr.Trim();
- } else {
- ByteRead((BYTE*)str.GetBufferSetLength(size), size);
- m_tags[tag] = (encoding > 0 ? UTF8To16(str) : CStringW(str)).Trim();
- }
- }
- }
- }
-
- Seek(m_startpos);
-
- for (int i = 0; i < (1<<20) && m_startpos < m_endpos && BitRead(8, true) == 0; i++) {
- BitRead(8), m_startpos++;
- }
- }
-
- int searchlen = 0;
- __int64 startpos = 0;
- __int64 syncpos = 0;
-
- __int64 startpos_mp3 = m_startpos;
- while (m_mode == none) {
- if (!MP3_find && GetPos() >= 2048) {
- break;
- }
- searchlen = (int)min(m_endpos - startpos_mp3, 512);
- Seek(startpos_mp3);
-
- // If we fail to see sync bytes, we reposition here and search again
- syncpos = startpos_mp3 + searchlen;
-
- // Check for a valid MPA header
- if (Read(m_mpahdr, searchlen, true, &m_mt)) {
- m_mode = mpa;
-
- syncpos = GetPos();
- startpos = syncpos - 4;
-
- // make sure the first frame is followed by another of the same kind (validates m_mpahdr basically)
- Seek(startpos + m_mpahdr.FrameSize);
- if (!Sync(4)) {
- m_mode = none;
- } else {
- break;
- }
- }
-
- // If we have enough room to search for a valid header, then skip ahead and try again
- if (m_endpos - syncpos >= 8) {
- startpos_mp3 = syncpos;
- } else {
- break;
- }
- }
-
- searchlen = (int)min(m_endpos - m_startpos, m_startpos > 0 ? 512 : 7);
- Seek(m_startpos);
-
- if (m_mode == none && Read(m_aachdr, searchlen, &m_mt)) {
- m_mode = mp4a;
-
- startpos = GetPos() - (m_aachdr.fcrc?7:9);
-
- // make sure the first frame is followed by another of the same kind (validates m_aachdr basically)
- Seek(startpos + m_aachdr.aac_frame_length);
- if (!Sync(9)) {
- m_mode = none;
- }
- }
-
- if (m_mode == none) {
- return E_FAIL;
- }
-
- m_startpos = startpos;
-
- if (m_mode == mpa) {
- DWORD m_dwFrames = 0; // total number of frames
- Seek(m_startpos + MPA_HEADER_SIZE + 32);
- if (BitRead(32, true) == 'Xing' || BitRead(32, true) == 'Info') {
- BitRead(32); // Skip ID tag
- DWORD dwFlags = (DWORD)BitRead(32);
- // extract total number of frames in file
- if (dwFlags & FRAMES_FLAG)
- m_dwFrames = (DWORD)BitRead(32);
-
- } else if (BitRead(32, true) == 'VBRI') {
- BitRead(32); // Skip ID tag
- // extract all fields from header (all mandatory)
- BitRead(16); // version
- BitRead(16); // delay
- BitRead(16); // quality
- BitRead(32); // bytes
- m_dwFrames = (DWORD)BitRead(32); // extract total number of frames in file
- }
-
- if (m_dwFrames) {
-
- bool l3ext = m_mpahdr.layer == 3 && !(m_mpahdr.version&1);
- DWORD m_dwSamplesPerFrame = m_mpahdr.layer == 1 ? 384 : l3ext ? 576 : 1152;
-
- m_bIsVBR = true;
- m_rtDuration = 10000000i64 * (m_dwFrames * m_dwSamplesPerFrame / m_mpahdr.nSamplesPerSec);
- }
- }
-
- Seek(m_startpos);
-
- int FrameSize;
- REFERENCE_TIME rtFrameDur, rtPrevDur = -1;
- clock_t start = clock();
- int i = 0;
- while (Sync(FrameSize, rtFrameDur) && (clock() - start) < CLOCKS_PER_SEC) {
- TRACE(_T("%I64d\n"), m_rtDuration);
- Seek(GetPos() + FrameSize);
- i = rtPrevDur == m_rtDuration ? i+1 : 0;
- if (i == 10) {
- break;
- }
- rtPrevDur = m_rtDuration;
- }
-
- return S_OK;
+ m_startpos = 0;
+ m_endpos = GetLength();
+
+ Seek(0);
+
+ // some files can be determined as Mpeg Audio
+ if ((BitRead(24, true) == 0x000001) || // ?
+ (BitRead(32, true) == 'RIFF') || // skip AVI and WAV files
+ (BitRead(24, true) == 'AMV')) { // skip MTV files (.amv .mtv)
+ return E_FAIL;
+ }
+
+ if (m_endpos > 128 && IsRandomAccess()) {
+ Seek(m_endpos - 128);
+
+ if (BitRead(24) == 'TAG') {
+ m_endpos -= 128;
+
+ CStringA str;
+
+ // title
+ ByteRead((BYTE*)str.GetBufferSetLength(30), 30);
+ m_tags['TIT2'] = CStringW(str).Trim();
+
+ // artist
+ ByteRead((BYTE*)str.GetBufferSetLength(30), 30);
+ m_tags['TPE1'] = CStringW(str).Trim();
+
+ // album
+ ByteRead((BYTE*)str.GetBufferSetLength(30), 30);
+ m_tags['TALB'] = CStringW(str).Trim();
+
+ // year
+ ByteRead((BYTE*)str.GetBufferSetLength(4), 4);
+ m_tags['TYER'] = CStringW(str).Trim();
+
+ // comment
+ ByteRead((BYTE*)str.GetBufferSetLength(30), 30);
+ m_tags['COMM'] = CStringW(str).Trim();
+
+ // track
+ LPCSTR s = str;
+ if (s[28] == 0 && s[29] != 0) {
+ m_tags['TRCK'].Format(L"%d", s[29]);
+ }
+
+ // genre
+ BYTE genre = (BYTE)BitRead(8);
+ if (genre < _countof(s_genre)) {
+ m_tags['TCON'] = CStringW(s_genre[genre]);
+ }
+ }
+ }
+
+ Seek(0);
+
+ bool MP3_find = false;
+
+ while (BitRead(24, true) == 'ID3') {
+ MP3_find = true;
+
+ BitRead(24);
+
+ BYTE major = (BYTE)BitRead(8);
+ BYTE revision = (BYTE)BitRead(8);
+ UNREFERENCED_PARAMETER(revision);
+
+ BYTE flags = (BYTE)BitRead(8);
+ UNREFERENCED_PARAMETER(flags);
+ DWORD size = 0;
+ if (BitRead(1) != 0) {
+ return E_FAIL;
+ }
+ size |= BitRead(7) << 21;
+ if (BitRead(1) != 0) {
+ return E_FAIL;
+ }
+ size |= BitRead(7) << 14;
+ if (BitRead(1) != 0) {
+ return E_FAIL;
+ }
+ size |= BitRead(7) << 7;
+ if (BitRead(1) != 0) {
+ return E_FAIL;
+ }
+ size |= BitRead(7);
+
+ m_startpos = GetPos() + size;
+
+ // TODO: read extended header
+
+ if (major <= 4) {
+ __int64 pos = GetPos();
+
+ while (pos < m_startpos) {
+ Seek(pos);
+
+ DWORD tag = (DWORD)BitRead(32);
+ DWORD size = 0;
+ size |= BitRead(8) << 24;
+ size |= BitRead(8) << 16;
+ size |= BitRead(8) << 8;
+ size |= BitRead(8);
+ WORD flags = (WORD)BitRead(16);
+ UNREFERENCED_PARAMETER(flags);
+
+ pos += 4 + 4 + 2 + size;
+
+ if (!size || pos >= m_startpos) {
+ break;
+ }
+
+ if (tag == 'TIT2'
+ || tag == 'TPE1'
+ || tag == 'TALB'
+ || tag == 'TYER'
+ || tag == 'COMM'
+ || tag == 'TRCK') {
+ BYTE encoding = (BYTE)BitRead(8);
+ size--;
+
+ WORD bom = (WORD)BitRead(16, true);
+
+ CStringA str;
+ CStringW wstr;
+
+ if (encoding > 0 && size >= 2 && bom == 0xfffe) {
+ BitRead(16);
+ size = (size - 2) / 2;
+ ByteRead((BYTE*)wstr.GetBufferSetLength(size), size * 2);
+ m_tags[tag] = wstr.Trim();
+ } else if (encoding > 0 && size >= 2 && bom == 0xfeff) {
+ BitRead(16);
+ size = (size - 2) / 2;
+ ByteRead((BYTE*)wstr.GetBufferSetLength(size), size * 2);
+ for (int i = 0, j = wstr.GetLength(); i < j; i++) {
+ wstr.SetAt(i, (wstr[i] << 8) | (wstr[i] >> 8));
+ }
+ m_tags[tag] = wstr.Trim();
+ } else {
+ ByteRead((BYTE*)str.GetBufferSetLength(size), size);
+ m_tags[tag] = (encoding > 0 ? UTF8To16(str) : CStringW(str)).Trim();
+ }
+ }
+ }
+ }
+
+ Seek(m_startpos);
+
+ for (int i = 0; i < (1 << 20) && m_startpos < m_endpos && BitRead(8, true) == 0; i++) {
+ BitRead(8), m_startpos++;
+ }
+ }
+
+ int searchlen = 0;
+ __int64 startpos = 0;
+ __int64 syncpos = 0;
+
+ __int64 startpos_mp3 = m_startpos;
+ while (m_mode == none) {
+ if (!MP3_find && GetPos() >= 2048) {
+ break;
+ }
+ searchlen = (int)min(m_endpos - startpos_mp3, 512);
+ Seek(startpos_mp3);
+
+ // If we fail to see sync bytes, we reposition here and search again
+ syncpos = startpos_mp3 + searchlen;
+
+ // Check for a valid MPA header
+ if (Read(m_mpahdr, searchlen, true, &m_mt)) {
+ m_mode = mpa;
+
+ syncpos = GetPos();
+ startpos = syncpos - 4;
+
+ // make sure the first frame is followed by another of the same kind (validates m_mpahdr basically)
+ Seek(startpos + m_mpahdr.FrameSize);
+ if (!Sync(4)) {
+ m_mode = none;
+ } else {
+ break;
+ }
+ }
+
+ // If we have enough room to search for a valid header, then skip ahead and try again
+ if (m_endpos - syncpos >= 8) {
+ startpos_mp3 = syncpos;
+ } else {
+ break;
+ }
+ }
+
+ searchlen = (int)min(m_endpos - m_startpos, m_startpos > 0 ? 512 : 7);
+ Seek(m_startpos);
+
+ if (m_mode == none && Read(m_aachdr, searchlen, &m_mt)) {
+ m_mode = mp4a;
+
+ startpos = GetPos() - (m_aachdr.fcrc ? 7 : 9);
+
+ // make sure the first frame is followed by another of the same kind (validates m_aachdr basically)
+ Seek(startpos + m_aachdr.aac_frame_length);
+ if (!Sync(9)) {
+ m_mode = none;
+ }
+ }
+
+ if (m_mode == none) {
+ return E_FAIL;
+ }
+
+ m_startpos = startpos;
+
+ if (m_mode == mpa) {
+ DWORD m_dwFrames = 0; // total number of frames
+ Seek(m_startpos + MPA_HEADER_SIZE + 32);
+ if (BitRead(32, true) == 'Xing' || BitRead(32, true) == 'Info') {
+ BitRead(32); // Skip ID tag
+ DWORD dwFlags = (DWORD)BitRead(32);
+ // extract total number of frames in file
+ if (dwFlags & FRAMES_FLAG) {
+ m_dwFrames = (DWORD)BitRead(32);
+ }
+
+ } else if (BitRead(32, true) == 'VBRI') {
+ BitRead(32); // Skip ID tag
+ // extract all fields from header (all mandatory)
+ BitRead(16); // version
+ BitRead(16); // delay
+ BitRead(16); // quality
+ BitRead(32); // bytes
+ m_dwFrames = (DWORD)BitRead(32); // extract total number of frames in file
+ }
+
+ if (m_dwFrames) {
+
+ bool l3ext = m_mpahdr.layer == 3 && !(m_mpahdr.version & 1);
+ DWORD m_dwSamplesPerFrame = m_mpahdr.layer == 1 ? 384 : l3ext ? 576 : 1152;
+
+ m_bIsVBR = true;
+ m_rtDuration = 10000000i64 * (m_dwFrames * m_dwSamplesPerFrame / m_mpahdr.nSamplesPerSec);
+ }
+ }
+
+ Seek(m_startpos);
+
+ int FrameSize;
+ REFERENCE_TIME rtFrameDur, rtPrevDur = -1;
+ clock_t start = clock();
+ int i = 0;
+ while (Sync(FrameSize, rtFrameDur) && (clock() - start) < CLOCKS_PER_SEC) {
+ TRACE(_T("%I64d\n"), m_rtDuration);
+ Seek(GetPos() + FrameSize);
+ i = rtPrevDur == m_rtDuration ? i + 1 : 0;
+ if (i == 10) {
+ break;
+ }
+ rtPrevDur = m_rtDuration;
+ }
+
+ return S_OK;
}
bool CMpaSplitterFile::Sync(int limit)
{
- int FrameSize;
- REFERENCE_TIME rtDuration;
- return Sync(FrameSize, rtDuration, limit);
+ int FrameSize;
+ REFERENCE_TIME rtDuration;
+ return Sync(FrameSize, rtDuration, limit);
}
bool CMpaSplitterFile::Sync(int& FrameSize, REFERENCE_TIME& rtDuration, int limit)
{
- __int64 endpos = min(m_endpos, GetPos() + limit);
-
- if (m_mode == mpa) {
- while (GetPos() <= endpos - 4) {
- mpahdr h;
-
- if (Read(h, (int)(endpos - GetPos()), true)) {
- if (m_mpahdr.version == h.version
- && m_mpahdr.layer == h.layer
- && m_mpahdr.channels == h.channels) {
- Seek(GetPos() - 4);
- AdjustDuration(h.nBytesPerSec);
-
- FrameSize = h.FrameSize;
- rtDuration = h.rtDuration;
-
- return true;
- }
- } else {
- break;
- }
- }
- } else if (m_mode == mp4a) {
- while (GetPos() <= endpos - 9) {
- aachdr h;
-
- if (Read(h, (int)(endpos - GetPos()))) {
- if (m_aachdr.version == h.version
- && m_aachdr.layer == h.layer
- && m_aachdr.channels == h.channels) {
- Seek(GetPos() - (h.fcrc?7:9));
- AdjustDuration(h.nBytesPerSec);
- Seek(GetPos() + (h.fcrc?7:9));
-
- FrameSize = h.FrameSize;
- rtDuration = h.rtDuration;
-
- return true;
- }
- } else {
- break;
- }
- }
- }
-
- return false;
+ __int64 endpos = min(m_endpos, GetPos() + limit);
+
+ if (m_mode == mpa) {
+ while (GetPos() <= endpos - 4) {
+ mpahdr h;
+
+ if (Read(h, (int)(endpos - GetPos()), true)) {
+ if (m_mpahdr.version == h.version
+ && m_mpahdr.layer == h.layer
+ && m_mpahdr.channels == h.channels) {
+ Seek(GetPos() - 4);
+ AdjustDuration(h.nBytesPerSec);
+
+ FrameSize = h.FrameSize;
+ rtDuration = h.rtDuration;
+
+ return true;
+ }
+ } else {
+ break;
+ }
+ }
+ } else if (m_mode == mp4a) {
+ while (GetPos() <= endpos - 9) {
+ aachdr h;
+
+ if (Read(h, (int)(endpos - GetPos()))) {
+ if (m_aachdr.version == h.version
+ && m_aachdr.layer == h.layer
+ && m_aachdr.channels == h.channels) {
+ Seek(GetPos() - (h.fcrc ? 7 : 9));
+ AdjustDuration(h.nBytesPerSec);
+ Seek(GetPos() + (h.fcrc ? 7 : 9));
+
+ FrameSize = h.FrameSize;
+ rtDuration = h.rtDuration;
+
+ return true;
+ }
+ } else {
+ break;
+ }
+ }
+ }
+
+ return false;
}
void CMpaSplitterFile::AdjustDuration(int nBytesPerSec)
{
- ASSERT(nBytesPerSec);
-
- if (!m_bIsVBR) {
- int rValue;
- if (!m_pos2bps.Lookup(GetPos(), rValue)) {
- m_totalbps += nBytesPerSec;
- if (!m_totalbps) {
- return;
- }
- m_pos2bps.SetAt(GetPos(), nBytesPerSec);
- __int64 avgbps = m_totalbps / m_pos2bps.GetCount();
- m_rtDuration = 10000000i64 * (m_endpos - m_startpos) / avgbps;
- }
- }
+ ASSERT(nBytesPerSec);
+
+ if (!m_bIsVBR) {
+ int rValue;
+ if (!m_pos2bps.Lookup(GetPos(), rValue)) {
+ m_totalbps += nBytesPerSec;
+ if (!m_totalbps) {
+ return;
+ }
+ m_pos2bps.SetAt(GetPos(), nBytesPerSec);
+ __int64 avgbps = m_totalbps / m_pos2bps.GetCount();
+ m_rtDuration = 10000000i64 * (m_endpos - m_startpos) / avgbps;
+ }
+ }
}
diff --git a/src/filters/parser/MpaSplitter/MpaSplitterFile.h b/src/filters/parser/MpaSplitter/MpaSplitterFile.h
index 3870090e7..31cc43844 100644
--- a/src/filters/parser/MpaSplitter/MpaSplitterFile.h
+++ b/src/filters/parser/MpaSplitter/MpaSplitterFile.h
@@ -27,42 +27,42 @@
class CMpaSplitterFile : public CBaseSplitterFileEx
{
- CMediaType m_mt;
- REFERENCE_TIME m_rtDuration;
+ CMediaType m_mt;
+ REFERENCE_TIME m_rtDuration;
- enum {none, mpa, mp4a} m_mode;
+ enum {none, mpa, mp4a} m_mode;
- mpahdr m_mpahdr;
- aachdr m_aachdr;
- __int64 m_startpos, m_endpos;
+ mpahdr m_mpahdr;
+ aachdr m_aachdr;
+ __int64 m_startpos, m_endpos;
- __int64 m_totalbps;
- CRBMap<__int64, int> m_pos2bps;
+ __int64 m_totalbps;
+ CRBMap<__int64, int> m_pos2bps;
- HRESULT Init();
- void AdjustDuration(int nBytesPerSec);
+ HRESULT Init();
+ void AdjustDuration(int nBytesPerSec);
- bool m_bIsVBR;
+ bool m_bIsVBR;
public:
- CMpaSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr);
+ CMpaSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr);
- CAtlMap<DWORD, CStringW> m_tags;
+ CAtlMap<DWORD, CStringW> m_tags;
- const CMediaType& GetMediaType() {
- return m_mt;
- }
- REFERENCE_TIME GetDuration() {
- return IsRandomAccess() ? m_rtDuration : 0;
- }
+ const CMediaType& GetMediaType() {
+ return m_mt;
+ }
+ REFERENCE_TIME GetDuration() {
+ return IsRandomAccess() ? m_rtDuration : 0;
+ }
- __int64 GetStartPos() {
- return m_startpos;
- }
- __int64 GetEndPos() {
- return m_endpos;
- }
+ __int64 GetStartPos() {
+ return m_startpos;
+ }
+ __int64 GetEndPos() {
+ return m_endpos;
+ }
- bool Sync(int limit = 0x2000);
- bool Sync(int& FrameSize, REFERENCE_TIME& rtDuration, int limit = 0x2000);
+ bool Sync(int limit = 0x2000);
+ bool Sync(int& FrameSize, REFERENCE_TIME& rtDuration, int limit = 0x2000);
};
diff --git a/src/filters/parser/MpegSplitter/IMpegSplitterFilter.h b/src/filters/parser/MpegSplitter/IMpegSplitterFilter.h
index 1329a5207..5c2544706 100644
--- a/src/filters/parser/MpegSplitter/IMpegSplitterFilter.h
+++ b/src/filters/parser/MpegSplitter/IMpegSplitterFilter.h
@@ -25,31 +25,31 @@
interface __declspec(uuid("1DC9C085-04AC-4BB8-B2BD-C49A4D30B104"))
IMpegSplitterFilter :
public IUnknown {
- STDMETHOD(Apply()) = 0;
+ STDMETHOD(Apply()) = 0;
- STDMETHOD(SetFastStreamChange(BOOL nValue)) = 0;
- STDMETHOD_(BOOL, GetFastStreamChange()) = 0;
+ STDMETHOD(SetFastStreamChange(BOOL nValue)) = 0;
+ STDMETHOD_(BOOL, GetFastStreamChange()) = 0;
- STDMETHOD(SetForcedSub(BOOL nValue)) = 0;
- STDMETHOD_(BOOL, GetForcedSub()) = 0;
+ STDMETHOD(SetForcedSub(BOOL nValue)) = 0;
+ STDMETHOD_(BOOL, GetForcedSub()) = 0;
- STDMETHOD(SetTrackPriority(BOOL nValue)) = 0;
- STDMETHOD_(BOOL, GetTrackPriority()) = 0;
+ STDMETHOD(SetTrackPriority(BOOL nValue)) = 0;
+ STDMETHOD_(BOOL, GetTrackPriority()) = 0;
- STDMETHOD(SetAudioLanguageOrder(WCHAR *nValue)) = 0;
- STDMETHOD_(WCHAR *, GetAudioLanguageOrder()) = 0;
+ STDMETHOD(SetAudioLanguageOrder(WCHAR * nValue)) = 0;
+ STDMETHOD_(WCHAR*, GetAudioLanguageOrder()) = 0;
- STDMETHOD(SetSubtitlesLanguageOrder(WCHAR *nValue)) = 0;
- STDMETHOD_(WCHAR *, GetSubtitlesLanguageOrder()) = 0;
+ STDMETHOD(SetSubtitlesLanguageOrder(WCHAR * nValue)) = 0;
+ STDMETHOD_(WCHAR*, GetSubtitlesLanguageOrder()) = 0;
- STDMETHOD(SetVC1_GuidFlag(int nValue)) = 0;
- STDMETHOD_(int, GetVC1_GuidFlag()) = 0;
+ STDMETHOD(SetVC1_GuidFlag(int nValue)) = 0;
+ STDMETHOD_(int, GetVC1_GuidFlag()) = 0;
- STDMETHOD(SetTrueHD(int nValue)) = 0;
- STDMETHOD_(int, GetTrueHD()) = 0;
+ STDMETHOD(SetTrueHD(int nValue)) = 0;
+ STDMETHOD_(int, GetTrueHD()) = 0;
- STDMETHOD(SetAlternativeDuration(BOOL nValue)) = 0;
- STDMETHOD_(BOOL, GetAlternativeDuration()) = 0;
+ STDMETHOD(SetAlternativeDuration(BOOL nValue)) = 0;
+ STDMETHOD_(BOOL, GetAlternativeDuration()) = 0;
- STDMETHOD_(int, GetMPEGType()) = 0;
+ STDMETHOD_(int, GetMPEGType()) = 0;
};
diff --git a/src/filters/parser/MpegSplitter/MpegSplitter.cpp b/src/filters/parser/MpegSplitter/MpegSplitter.cpp
index c450fc225..58532cd4a 100644
--- a/src/filters/parser/MpegSplitter/MpegSplitter.cpp
+++ b/src/filters/parser/MpegSplitter/MpegSplitter.cpp
@@ -33,86 +33,84 @@
#include "../../../mpc-hc/SettingsDefines.h"
-TCHAR* MPEG2_Profile[]=
-{
- L"0",
- L"High Profile",
- L"Spatially Scalable Profile",
- L"SNR Scalable Profile",
- L"Main Profile",
- L"Simple Profile",
- L"6",
- L"7",
+TCHAR* MPEG2_Profile[] = {
+ L"0",
+ L"High Profile",
+ L"Spatially Scalable Profile",
+ L"SNR Scalable Profile",
+ L"Main Profile",
+ L"Simple Profile",
+ L"6",
+ L"7",
};
-TCHAR* MPEG2_Level[]=
-{
- L"0",
- L"1",
- L"2",
- L"3",
- L"High Level",
- L"4",
- L"High1440 Level",
- L"5",
- L"Main Level",
- L"6",
- L"Low Level",
- L"7",
- L"8",
- L"9",
- L"10",
- L"11",
+TCHAR* MPEG2_Level[] = {
+ L"0",
+ L"1",
+ L"2",
+ L"3",
+ L"High Level",
+ L"4",
+ L"High1440 Level",
+ L"5",
+ L"Main Level",
+ L"6",
+ L"Low Level",
+ L"7",
+ L"8",
+ L"9",
+ L"10",
+ L"11",
};
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG1System},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG2_PROGRAM},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG2_TRANSPORT},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG2_PVA},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG1System},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG2_PROGRAM},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG2_TRANSPORT},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG2_PVA},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL},
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL},
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CMpegSplitterFilter), MpegSplitterName, MERIT_NORMAL+1, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CMpegSourceFilter), MpegSourceName, MERIT_UNLIKELY, 0, NULL, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CMpegSplitterFilter), MpegSplitterName, MERIT_NORMAL + 1, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CMpegSourceFilter), MpegSourceName, MERIT_UNLIKELY, 0, NULL, CLSID_LegacyAmFilterCategory},
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMpegSplitterFilter>, NULL, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CMpegSourceFilter>, NULL, &sudFilter[1]},
- {L"CMpegSplitterPropertyPage", &__uuidof(CMpegSplitterSettingsWnd), CreateInstance<CInternalPropertyPageTempl<CMpegSplitterSettingsWnd> >},
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMpegSplitterFilter>, NULL, &sudFilter[0]},
+ {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CMpegSourceFilter>, NULL, &sudFilter[1]},
+ {L"CMpegSplitterPropertyPage", &__uuidof(CMpegSplitterSettingsWnd), CreateInstance<CInternalPropertyPageTempl<CMpegSplitterSettingsWnd> >},
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- DeleteRegKey(_T("Media Type\\Extensions\\"), _T(".ts"));
+ DeleteRegKey(_T("Media Type\\Extensions\\"), _T(".ts"));
- RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_MPEG1System, _T("0,16,FFFFFFFFF100010001800001FFFFFFFF,000001BA2100010001800001000001BB"), NULL);
- RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_MPEG2_PROGRAM, _T("0,5,FFFFFFFFC0,000001BA40"), NULL);
- RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_MPEG2_PVA, _T("0,8,fffffc00ffe00000,4156000055000000"), NULL);
+ RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_MPEG1System, _T("0,16,FFFFFFFFF100010001800001FFFFFFFF,000001BA2100010001800001000001BB"), NULL);
+ RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_MPEG2_PROGRAM, _T("0,5,FFFFFFFFC0,000001BA40"), NULL);
+ RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_MPEG2_PVA, _T("0,8,fffffc00ffe00000,4156000055000000"), NULL);
- CAtlList<CString> chkbytes;
- chkbytes.AddTail(_T("0,1,,47,188,1,,47,376,1,,47"));
- chkbytes.AddTail(_T("4,1,,47,196,1,,47,388,1,,47"));
- chkbytes.AddTail(_T("0,4,,54467263,1660,1,,47")); // TFrc
- RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_MPEG2_TRANSPORT, chkbytes, NULL);
+ CAtlList<CString> chkbytes;
+ chkbytes.AddTail(_T("0,1,,47,188,1,,47,376,1,,47"));
+ chkbytes.AddTail(_T("4,1,,47,196,1,,47,388,1,,47"));
+ chkbytes.AddTail(_T("0,4,,54467263,1660,1,,47")); // TFrc
+ RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_MPEG2_TRANSPORT, chkbytes, NULL);
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -122,366 +120,366 @@ CFilterApp theApp;
#endif
template <typename t_CType>
-t_CType GetFormatHelper(t_CType &_pInfo, const CMediaType *_pFormat)
+t_CType GetFormatHelper(t_CType& _pInfo, const CMediaType* _pFormat)
{
- ASSERT(_pFormat->cbFormat >= sizeof(*_pInfo));
- _pInfo = (t_CType)_pFormat->pbFormat;
- return _pInfo;
+ ASSERT(_pFormat->cbFormat >= sizeof(*_pInfo));
+ _pInfo = (t_CType)_pFormat->pbFormat;
+ return _pInfo;
}
static int GetHighestBitSet32(unsigned long _Value)
{
- unsigned long Ret;
- unsigned char bNonZero = _BitScanReverse(&Ret, _Value);
- if (bNonZero) {
- return Ret;
- } else {
- return -1;
- }
+ unsigned long Ret;
+ unsigned char bNonZero = _BitScanReverse(&Ret, _Value);
+ if (bNonZero) {
+ return Ret;
+ } else {
+ return -1;
+ }
}
CString FormatBitrate(double _Bitrate)
{
- CString Temp;
- if (_Bitrate > 20000000) { // More than 2 mbit
- Temp.Format(L"%.2f mbit/s", double(_Bitrate)/1000000.0);
- } else {
- Temp.Format(L"%.1f kbit/s", double(_Bitrate)/1000.0);
- }
-
- return Temp;
+ CString Temp;
+ if (_Bitrate > 20000000) { // More than 2 mbit
+ Temp.Format(L"%.2f mbit/s", double(_Bitrate) / 1000000.0);
+ } else {
+ Temp.Format(L"%.1f kbit/s", double(_Bitrate) / 1000.0);
+ }
+
+ return Temp;
}
-CString FormatString(const wchar_t *pszFormat, ... )
+CString FormatString(const wchar_t* pszFormat, ...)
{
- CString Temp;
- ATLASSERT( AtlIsValidString( pszFormat ) );
+ CString Temp;
+ ATLASSERT(AtlIsValidString(pszFormat));
- va_list argList;
- va_start( argList, pszFormat );
- Temp.FormatV( pszFormat, argList );
- va_end( argList );
+ va_list argList;
+ va_start(argList, pszFormat);
+ Temp.FormatV(pszFormat, argList);
+ va_end(argList);
- return Temp;
+ return Temp;
}
-CString GetMediaTypeDesc(const CMediaType *_pMediaType, const CHdmvClipInfo::Stream *pClipInfo, int _PresentationType, CString lang)
+CString GetMediaTypeDesc(const CMediaType* _pMediaType, const CHdmvClipInfo::Stream* pClipInfo, int _PresentationType, CString lang)
{
- const WCHAR *pPresentationDesc = NULL;
-
- if (pClipInfo) {
- pPresentationDesc = StreamTypeToName(pClipInfo->m_Type);
- } else {
- pPresentationDesc = StreamTypeToName((PES_STREAM_TYPE)_PresentationType);
- }
-
- CString MajorType;
- CAtlList<CString> Infos;
-
- if (_pMediaType->majortype == MEDIATYPE_Video) {
- MajorType = "Video";
-
- if (pClipInfo) {
- CString name = ISO6392ToLanguage(pClipInfo->m_LanguageCode);
-
- if (!name.IsEmpty()) {
- Infos.AddTail(name);
- }
- } else {
- if (!lang.IsEmpty()) {
- Infos.AddTail(lang);
- }
- }
-
- const VIDEOINFOHEADER *pVideoInfo = NULL;
- const VIDEOINFOHEADER2 *pVideoInfo2 = NULL;
-
- if (_pMediaType->formattype == FORMAT_MPEGVideo) {
- Infos.AddTail(L"MPEG");
-
- const MPEG1VIDEOINFO *pInfo = GetFormatHelper(pInfo, _pMediaType);
-
- pVideoInfo = &pInfo->hdr;
-
- } else if (_pMediaType->formattype == FORMAT_MPEG2_VIDEO) {
- const MPEG2VIDEOINFO *pInfo = GetFormatHelper(pInfo, _pMediaType);
-
- pVideoInfo2 = &pInfo->hdr;
-
- bool bIsAVC = false;
- bool bIsMPEG2 = false;
-
- if (pInfo->hdr.bmiHeader.biCompression == '1CVA') {
- bIsAVC = true;
- Infos.AddTail(L"AVC (H.264)");
- } else if (pInfo->hdr.bmiHeader.biCompression == 'CVMA') {
- bIsAVC = true;
- Infos.AddTail(L"MVC (Full)");
- } else if (pInfo->hdr.bmiHeader.biCompression == 'CVME') {
- bIsAVC = true;
- Infos.AddTail(L"MVC (Subset)");
- } else if (pInfo->hdr.bmiHeader.biCompression == 0) {
- Infos.AddTail(L"MPEG2");
- bIsMPEG2 = true;
- } else {
- WCHAR Temp[5];
- memset(Temp, 0, sizeof(Temp));
- Temp[0] = (pInfo->hdr.bmiHeader.biCompression >> 0) & 0xFF;
- Temp[1] = (pInfo->hdr.bmiHeader.biCompression >> 8) & 0xFF;
- Temp[2] = (pInfo->hdr.bmiHeader.biCompression >> 16) & 0xFF;
- Temp[3] = (pInfo->hdr.bmiHeader.biCompression >> 24) & 0xFF;
- Infos.AddTail(Temp);
- }
-
- if (bIsMPEG2) {
- Infos.AddTail(MPEG2_Profile[pInfo->dwProfile]);
- } else if (pInfo->dwProfile) {
- if (bIsAVC) {
- switch (pInfo->dwProfile) {
- case 44:
- Infos.AddTail(L"CAVLC Profile");
- break;
- case 66:
- Infos.AddTail(L"Baseline Profile");
- break;
- case 77:
- Infos.AddTail(L"Main Profile");
- break;
- case 88:
- Infos.AddTail(L"Extended Profile");
- break;
- case 100:
- Infos.AddTail(L"High Profile");
- break;
- case 110:
- Infos.AddTail(L"High 10 Profile");
- break;
- case 118:
- Infos.AddTail(L"Multiview High Profile");
- break;
- case 122:
- Infos.AddTail(L"High 4:2:2 Profile");
- break;
- case 244:
- Infos.AddTail(L"High 4:4:4 Profile");
- break;
- case 128:
- Infos.AddTail(L"Stereo High Profile");
- break;
- default:
- Infos.AddTail(FormatString(L"Profile %d", pInfo->dwProfile));
- break;
- }
- } else {
- Infos.AddTail(FormatString(L"Profile %d", pInfo->dwProfile));
- }
- }
-
- if (bIsMPEG2) {
- Infos.AddTail(MPEG2_Level[pInfo->dwLevel]);
- } else if (pInfo->dwLevel) {
- if (bIsAVC) {
- Infos.AddTail(FormatString(L"Level %1.1f", double(pInfo->dwLevel)/10.0));
- } else {
- Infos.AddTail(FormatString(L"Level %d", pInfo->dwLevel));
- }
- }
- } else if (_pMediaType->formattype == FORMAT_VIDEOINFO2) {
- const VIDEOINFOHEADER2 *pInfo = GetFormatHelper(pInfo, _pMediaType);
-
- pVideoInfo2 = pInfo;
- bool bIsVC1 = false;
-
- DWORD CodecType = pInfo->bmiHeader.biCompression;
- if (CodecType == '1CVW') {
- bIsVC1 = true;
- Infos.AddTail(L"VC-1");
- } else if (CodecType) {
- WCHAR Temp[5];
- memset(Temp, 0, sizeof(Temp));
- Temp[0] = (CodecType >> 0) & 0xFF;
- Temp[1] = (CodecType >> 8) & 0xFF;
- Temp[2] = (CodecType >> 16) & 0xFF;
- Temp[3] = (CodecType >> 24) & 0xFF;
- Infos.AddTail(Temp);
- }
- } else if (_pMediaType->subtype == MEDIASUBTYPE_DVD_SUBPICTURE) {
- Infos.AddTail(L"DVD Sub Picture");
- } else if (_pMediaType->subtype == MEDIASUBTYPE_SVCD_SUBPICTURE) {
- Infos.AddTail(L"SVCD Sub Picture");
- } else if (_pMediaType->subtype == MEDIASUBTYPE_CVD_SUBPICTURE) {
- Infos.AddTail(L"CVD Sub Picture");
- }
-
- if (pVideoInfo2) {
- if (pVideoInfo2->bmiHeader.biWidth && pVideoInfo2->bmiHeader.biHeight) {
- Infos.AddTail(FormatString(L"%dx%d", pVideoInfo2->bmiHeader.biWidth, pVideoInfo2->bmiHeader.biHeight));
- }
- if (pVideoInfo2->AvgTimePerFrame) {
- Infos.AddTail(FormatString(L"%.3f fps", 10000000.0/double(pVideoInfo2->AvgTimePerFrame)));
- }
- if (pVideoInfo2->dwBitRate) {
- Infos.AddTail(FormatBitrate(pVideoInfo2->dwBitRate));
- }
- } else if (pVideoInfo) {
- if (pVideoInfo->bmiHeader.biWidth && pVideoInfo->bmiHeader.biHeight) {
- Infos.AddTail(FormatString(L"%dx%d", pVideoInfo->bmiHeader.biWidth, pVideoInfo->bmiHeader.biHeight));
- }
- if (pVideoInfo->AvgTimePerFrame) {
- Infos.AddTail(FormatString(L"%.3f fps", 10000000.0/double(pVideoInfo->AvgTimePerFrame)));
- }
- if (pVideoInfo->dwBitRate) {
- Infos.AddTail(FormatBitrate(pVideoInfo->dwBitRate));
- }
- }
-
- } else if (_pMediaType->majortype == MEDIATYPE_Audio) {
- MajorType = "Audio";
- if (pClipInfo) {
- CString name = ISO6392ToLanguage(pClipInfo->m_LanguageCode);
- if (!name.IsEmpty()) {
- Infos.AddTail(name);
- }
- } else {
- if (!lang.IsEmpty()) {
- Infos.AddTail(lang);
- }
- }
- if (_pMediaType->formattype == FORMAT_WaveFormatEx) {
- const WAVEFORMATEX *pInfo = GetFormatHelper(pInfo, _pMediaType);
-
- if (_pMediaType->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
- Infos.AddTail(L"DVD LPCM");
- } else if (_pMediaType->subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
- const WAVEFORMATEX_HDMV_LPCM *pInfoHDMV = GetFormatHelper(pInfoHDMV, _pMediaType);
- UNREFERENCED_PARAMETER(pInfoHDMV);
- Infos.AddTail(L"HDMV LPCM");
- }
- if (_pMediaType->subtype == MEDIASUBTYPE_DOLBY_DDPLUS) {
- Infos.AddTail(L"Dolby Digital Plus");
- } else if (_pMediaType->subtype == MEDIASUBTYPE_DOLBY_TRUEHD) {
- Infos.AddTail(L"TrueHD");
- } else {
- switch (pInfo->wFormatTag) {
- case WAVE_FORMAT_PS2_PCM: {
- Infos.AddTail(L"PS2 PCM");
- }
- break;
- case WAVE_FORMAT_PS2_ADPCM: {
- Infos.AddTail(L"PS2 ADPCM");
- }
- break;
- case WAVE_FORMAT_DVD_DTS: {
- if (pPresentationDesc) {
- Infos.AddTail(pPresentationDesc);
- } else {
- Infos.AddTail(L"DTS");
- }
- }
- break;
- case WAVE_FORMAT_DOLBY_AC3: {
- if (pPresentationDesc) {
- Infos.AddTail(pPresentationDesc);
- } else {
- Infos.AddTail(L"Dolby Digital");
- }
- }
- break;
- case WAVE_FORMAT_AAC: {
- Infos.AddTail(L"AAC");
- }
- break;
- case WAVE_FORMAT_MP3: {
- Infos.AddTail(L"MP3");
- }
- break;
- case WAVE_FORMAT_MPEG: {
- const MPEG1WAVEFORMAT* pInfoMPEG1 = GetFormatHelper(pInfoMPEG1, _pMediaType);
-
- int layer = GetHighestBitSet32(pInfoMPEG1->fwHeadLayer) + 1;
- Infos.AddTail(FormatString(L"MPEG1 - Layer %d", layer));
- }
- break;
- }
- }
-
- if (pClipInfo && (pClipInfo->m_SampleRate == BDVM_SampleRate_48_192 || pClipInfo->m_SampleRate == BDVM_SampleRate_48_96)) {
- switch (pClipInfo->m_SampleRate) {
- case BDVM_SampleRate_48_192:
- Infos.AddTail(FormatString(L"192(48) kHz"));
- break;
- case BDVM_SampleRate_48_96:
- Infos.AddTail(FormatString(L"96(48) kHz"));
- break;
- }
- } else if (pInfo->nSamplesPerSec) {
- Infos.AddTail(FormatString(L"%.1f kHz", double(pInfo->nSamplesPerSec)/1000.0));
- }
- if (pInfo->nChannels) {
- Infos.AddTail(FormatString(L"%d chn", pInfo->nChannels));
- }
- if (pInfo->wBitsPerSample) {
- Infos.AddTail(FormatString(L"%d bit", pInfo->wBitsPerSample));
- }
- if (pInfo->nAvgBytesPerSec) {
- Infos.AddTail(FormatBitrate(pInfo->nAvgBytesPerSec * 8));
- }
-
- }
- } else if (_pMediaType->majortype == MEDIATYPE_Subtitle) {
- MajorType = "Subtitle";
-
- if (pPresentationDesc) {
- Infos.AddTail(pPresentationDesc);
- }
-
- if (pClipInfo) {
- CString name = ISO6392ToLanguage(pClipInfo->m_LanguageCode);
- if (!name.IsEmpty()) {
- Infos.AddHead(name);
- } else if (!lang.IsEmpty()) {
- Infos.AddHead(lang);
- }
- } else if (_pMediaType->cbFormat == sizeof(SUBTITLEINFO)) {
- const SUBTITLEINFO *pInfo = GetFormatHelper(pInfo, _pMediaType);
- CString name = ISO6392ToLanguage(pInfo->IsoLang);
-
- if (!lang.IsEmpty()) {
- Infos.AddHead(lang);
- } else if (!name.IsEmpty()) {
- Infos.AddHead(name);
- }
- if (pInfo->TrackName[0]) {
- Infos.AddTail(pInfo->TrackName);
- }
- } else if (!lang.IsEmpty()) {
- Infos.AddHead(lang);
- }
- }
-
- if (!Infos.IsEmpty()) {
- CString Ret;
-
- Ret += MajorType;
- Ret += " - ";
-
- bool bFirst = true;
-
- for (POSITION pos = Infos.GetHeadPosition(); pos; Infos.GetNext(pos)) {
- CString& String = Infos.GetAt(pos);
-
- if (bFirst) {
- Ret += String;
- } else {
- Ret += L", " + String;
- }
-
- bFirst = false;
- }
-
- return Ret;
- }
- return CString();
+ const WCHAR* pPresentationDesc = NULL;
+
+ if (pClipInfo) {
+ pPresentationDesc = StreamTypeToName(pClipInfo->m_Type);
+ } else {
+ pPresentationDesc = StreamTypeToName((PES_STREAM_TYPE)_PresentationType);
+ }
+
+ CString MajorType;
+ CAtlList<CString> Infos;
+
+ if (_pMediaType->majortype == MEDIATYPE_Video) {
+ MajorType = "Video";
+
+ if (pClipInfo) {
+ CString name = ISO6392ToLanguage(pClipInfo->m_LanguageCode);
+
+ if (!name.IsEmpty()) {
+ Infos.AddTail(name);
+ }
+ } else {
+ if (!lang.IsEmpty()) {
+ Infos.AddTail(lang);
+ }
+ }
+
+ const VIDEOINFOHEADER* pVideoInfo = NULL;
+ const VIDEOINFOHEADER2* pVideoInfo2 = NULL;
+
+ if (_pMediaType->formattype == FORMAT_MPEGVideo) {
+ Infos.AddTail(L"MPEG");
+
+ const MPEG1VIDEOINFO* pInfo = GetFormatHelper(pInfo, _pMediaType);
+
+ pVideoInfo = &pInfo->hdr;
+
+ } else if (_pMediaType->formattype == FORMAT_MPEG2_VIDEO) {
+ const MPEG2VIDEOINFO* pInfo = GetFormatHelper(pInfo, _pMediaType);
+
+ pVideoInfo2 = &pInfo->hdr;
+
+ bool bIsAVC = false;
+ bool bIsMPEG2 = false;
+
+ if (pInfo->hdr.bmiHeader.biCompression == '1CVA') {
+ bIsAVC = true;
+ Infos.AddTail(L"AVC (H.264)");
+ } else if (pInfo->hdr.bmiHeader.biCompression == 'CVMA') {
+ bIsAVC = true;
+ Infos.AddTail(L"MVC (Full)");
+ } else if (pInfo->hdr.bmiHeader.biCompression == 'CVME') {
+ bIsAVC = true;
+ Infos.AddTail(L"MVC (Subset)");
+ } else if (pInfo->hdr.bmiHeader.biCompression == 0) {
+ Infos.AddTail(L"MPEG2");
+ bIsMPEG2 = true;
+ } else {
+ WCHAR Temp[5];
+ memset(Temp, 0, sizeof(Temp));
+ Temp[0] = (pInfo->hdr.bmiHeader.biCompression >> 0) & 0xFF;
+ Temp[1] = (pInfo->hdr.bmiHeader.biCompression >> 8) & 0xFF;
+ Temp[2] = (pInfo->hdr.bmiHeader.biCompression >> 16) & 0xFF;
+ Temp[3] = (pInfo->hdr.bmiHeader.biCompression >> 24) & 0xFF;
+ Infos.AddTail(Temp);
+ }
+
+ if (bIsMPEG2) {
+ Infos.AddTail(MPEG2_Profile[pInfo->dwProfile]);
+ } else if (pInfo->dwProfile) {
+ if (bIsAVC) {
+ switch (pInfo->dwProfile) {
+ case 44:
+ Infos.AddTail(L"CAVLC Profile");
+ break;
+ case 66:
+ Infos.AddTail(L"Baseline Profile");
+ break;
+ case 77:
+ Infos.AddTail(L"Main Profile");
+ break;
+ case 88:
+ Infos.AddTail(L"Extended Profile");
+ break;
+ case 100:
+ Infos.AddTail(L"High Profile");
+ break;
+ case 110:
+ Infos.AddTail(L"High 10 Profile");
+ break;
+ case 118:
+ Infos.AddTail(L"Multiview High Profile");
+ break;
+ case 122:
+ Infos.AddTail(L"High 4:2:2 Profile");
+ break;
+ case 244:
+ Infos.AddTail(L"High 4:4:4 Profile");
+ break;
+ case 128:
+ Infos.AddTail(L"Stereo High Profile");
+ break;
+ default:
+ Infos.AddTail(FormatString(L"Profile %d", pInfo->dwProfile));
+ break;
+ }
+ } else {
+ Infos.AddTail(FormatString(L"Profile %d", pInfo->dwProfile));
+ }
+ }
+
+ if (bIsMPEG2) {
+ Infos.AddTail(MPEG2_Level[pInfo->dwLevel]);
+ } else if (pInfo->dwLevel) {
+ if (bIsAVC) {
+ Infos.AddTail(FormatString(L"Level %1.1f", double(pInfo->dwLevel) / 10.0));
+ } else {
+ Infos.AddTail(FormatString(L"Level %d", pInfo->dwLevel));
+ }
+ }
+ } else if (_pMediaType->formattype == FORMAT_VIDEOINFO2) {
+ const VIDEOINFOHEADER2* pInfo = GetFormatHelper(pInfo, _pMediaType);
+
+ pVideoInfo2 = pInfo;
+ bool bIsVC1 = false;
+
+ DWORD CodecType = pInfo->bmiHeader.biCompression;
+ if (CodecType == '1CVW') {
+ bIsVC1 = true;
+ Infos.AddTail(L"VC-1");
+ } else if (CodecType) {
+ WCHAR Temp[5];
+ memset(Temp, 0, sizeof(Temp));
+ Temp[0] = (CodecType >> 0) & 0xFF;
+ Temp[1] = (CodecType >> 8) & 0xFF;
+ Temp[2] = (CodecType >> 16) & 0xFF;
+ Temp[3] = (CodecType >> 24) & 0xFF;
+ Infos.AddTail(Temp);
+ }
+ } else if (_pMediaType->subtype == MEDIASUBTYPE_DVD_SUBPICTURE) {
+ Infos.AddTail(L"DVD Sub Picture");
+ } else if (_pMediaType->subtype == MEDIASUBTYPE_SVCD_SUBPICTURE) {
+ Infos.AddTail(L"SVCD Sub Picture");
+ } else if (_pMediaType->subtype == MEDIASUBTYPE_CVD_SUBPICTURE) {
+ Infos.AddTail(L"CVD Sub Picture");
+ }
+
+ if (pVideoInfo2) {
+ if (pVideoInfo2->bmiHeader.biWidth && pVideoInfo2->bmiHeader.biHeight) {
+ Infos.AddTail(FormatString(L"%dx%d", pVideoInfo2->bmiHeader.biWidth, pVideoInfo2->bmiHeader.biHeight));
+ }
+ if (pVideoInfo2->AvgTimePerFrame) {
+ Infos.AddTail(FormatString(L"%.3f fps", 10000000.0 / double(pVideoInfo2->AvgTimePerFrame)));
+ }
+ if (pVideoInfo2->dwBitRate) {
+ Infos.AddTail(FormatBitrate(pVideoInfo2->dwBitRate));
+ }
+ } else if (pVideoInfo) {
+ if (pVideoInfo->bmiHeader.biWidth && pVideoInfo->bmiHeader.biHeight) {
+ Infos.AddTail(FormatString(L"%dx%d", pVideoInfo->bmiHeader.biWidth, pVideoInfo->bmiHeader.biHeight));
+ }
+ if (pVideoInfo->AvgTimePerFrame) {
+ Infos.AddTail(FormatString(L"%.3f fps", 10000000.0 / double(pVideoInfo->AvgTimePerFrame)));
+ }
+ if (pVideoInfo->dwBitRate) {
+ Infos.AddTail(FormatBitrate(pVideoInfo->dwBitRate));
+ }
+ }
+
+ } else if (_pMediaType->majortype == MEDIATYPE_Audio) {
+ MajorType = "Audio";
+ if (pClipInfo) {
+ CString name = ISO6392ToLanguage(pClipInfo->m_LanguageCode);
+ if (!name.IsEmpty()) {
+ Infos.AddTail(name);
+ }
+ } else {
+ if (!lang.IsEmpty()) {
+ Infos.AddTail(lang);
+ }
+ }
+ if (_pMediaType->formattype == FORMAT_WaveFormatEx) {
+ const WAVEFORMATEX* pInfo = GetFormatHelper(pInfo, _pMediaType);
+
+ if (_pMediaType->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
+ Infos.AddTail(L"DVD LPCM");
+ } else if (_pMediaType->subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
+ const WAVEFORMATEX_HDMV_LPCM* pInfoHDMV = GetFormatHelper(pInfoHDMV, _pMediaType);
+ UNREFERENCED_PARAMETER(pInfoHDMV);
+ Infos.AddTail(L"HDMV LPCM");
+ }
+ if (_pMediaType->subtype == MEDIASUBTYPE_DOLBY_DDPLUS) {
+ Infos.AddTail(L"Dolby Digital Plus");
+ } else if (_pMediaType->subtype == MEDIASUBTYPE_DOLBY_TRUEHD) {
+ Infos.AddTail(L"TrueHD");
+ } else {
+ switch (pInfo->wFormatTag) {
+ case WAVE_FORMAT_PS2_PCM: {
+ Infos.AddTail(L"PS2 PCM");
+ }
+ break;
+ case WAVE_FORMAT_PS2_ADPCM: {
+ Infos.AddTail(L"PS2 ADPCM");
+ }
+ break;
+ case WAVE_FORMAT_DVD_DTS: {
+ if (pPresentationDesc) {
+ Infos.AddTail(pPresentationDesc);
+ } else {
+ Infos.AddTail(L"DTS");
+ }
+ }
+ break;
+ case WAVE_FORMAT_DOLBY_AC3: {
+ if (pPresentationDesc) {
+ Infos.AddTail(pPresentationDesc);
+ } else {
+ Infos.AddTail(L"Dolby Digital");
+ }
+ }
+ break;
+ case WAVE_FORMAT_AAC: {
+ Infos.AddTail(L"AAC");
+ }
+ break;
+ case WAVE_FORMAT_MP3: {
+ Infos.AddTail(L"MP3");
+ }
+ break;
+ case WAVE_FORMAT_MPEG: {
+ const MPEG1WAVEFORMAT* pInfoMPEG1 = GetFormatHelper(pInfoMPEG1, _pMediaType);
+
+ int layer = GetHighestBitSet32(pInfoMPEG1->fwHeadLayer) + 1;
+ Infos.AddTail(FormatString(L"MPEG1 - Layer %d", layer));
+ }
+ break;
+ }
+ }
+
+ if (pClipInfo && (pClipInfo->m_SampleRate == BDVM_SampleRate_48_192 || pClipInfo->m_SampleRate == BDVM_SampleRate_48_96)) {
+ switch (pClipInfo->m_SampleRate) {
+ case BDVM_SampleRate_48_192:
+ Infos.AddTail(FormatString(L"192(48) kHz"));
+ break;
+ case BDVM_SampleRate_48_96:
+ Infos.AddTail(FormatString(L"96(48) kHz"));
+ break;
+ }
+ } else if (pInfo->nSamplesPerSec) {
+ Infos.AddTail(FormatString(L"%.1f kHz", double(pInfo->nSamplesPerSec) / 1000.0));
+ }
+ if (pInfo->nChannels) {
+ Infos.AddTail(FormatString(L"%d chn", pInfo->nChannels));
+ }
+ if (pInfo->wBitsPerSample) {
+ Infos.AddTail(FormatString(L"%d bit", pInfo->wBitsPerSample));
+ }
+ if (pInfo->nAvgBytesPerSec) {
+ Infos.AddTail(FormatBitrate(pInfo->nAvgBytesPerSec * 8));
+ }
+
+ }
+ } else if (_pMediaType->majortype == MEDIATYPE_Subtitle) {
+ MajorType = "Subtitle";
+
+ if (pPresentationDesc) {
+ Infos.AddTail(pPresentationDesc);
+ }
+
+ if (pClipInfo) {
+ CString name = ISO6392ToLanguage(pClipInfo->m_LanguageCode);
+ if (!name.IsEmpty()) {
+ Infos.AddHead(name);
+ } else if (!lang.IsEmpty()) {
+ Infos.AddHead(lang);
+ }
+ } else if (_pMediaType->cbFormat == sizeof(SUBTITLEINFO)) {
+ const SUBTITLEINFO* pInfo = GetFormatHelper(pInfo, _pMediaType);
+ CString name = ISO6392ToLanguage(pInfo->IsoLang);
+
+ if (!lang.IsEmpty()) {
+ Infos.AddHead(lang);
+ } else if (!name.IsEmpty()) {
+ Infos.AddHead(name);
+ }
+ if (pInfo->TrackName[0]) {
+ Infos.AddTail(pInfo->TrackName);
+ }
+ } else if (!lang.IsEmpty()) {
+ Infos.AddHead(lang);
+ }
+ }
+
+ if (!Infos.IsEmpty()) {
+ CString Ret;
+
+ Ret += MajorType;
+ Ret += " - ";
+
+ bool bFirst = true;
+
+ for (POSITION pos = Infos.GetHeadPosition(); pos; Infos.GetNext(pos)) {
+ CString& String = Infos.GetAt(pos);
+
+ if (bFirst) {
+ Ret += String;
+ } else {
+ Ret += L", " + String;
+ }
+
+ bFirst = false;
+ }
+
+ return Ret;
+ }
+ return CString();
}
//
@@ -489,1097 +487,1095 @@ CString GetMediaTypeDesc(const CMediaType *_pMediaType, const CHdmvClipInfo::Str
//
CMpegSplitterFilter::CMpegSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLSID& clsid)
- : CBaseSplitterFilter(NAME("CMpegSplitterFilter"), pUnk, phr, clsid)
- , m_pPipoBimbo(false)
- , m_rtPlaylistDuration(0)
- , m_csAudioLanguageOrder(_T(""))
- , m_csSubtitlesLanguageOrder(_T(""))
- , m_useFastStreamChange(true)
- , m_ForcedSub(false)
- , m_TrackPriority(false)
- , m_AC3CoreOnly(0)
- , m_nVC1_GuidFlag(1)
- , m_AlternativeDuration(false)
+ : CBaseSplitterFilter(NAME("CMpegSplitterFilter"), pUnk, phr, clsid)
+ , m_pPipoBimbo(false)
+ , m_rtPlaylistDuration(0)
+ , m_csAudioLanguageOrder(_T(""))
+ , m_csSubtitlesLanguageOrder(_T(""))
+ , m_useFastStreamChange(true)
+ , m_ForcedSub(false)
+ , m_TrackPriority(false)
+ , m_AC3CoreOnly(0)
+ , m_nVC1_GuidFlag(1)
+ , m_AlternativeDuration(false)
{
#ifdef REGISTER_FILTER
- CRegKey key;
- TCHAR buff[256];
- ULONG len;
-
- if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Splitter"), KEY_READ)) {
- DWORD dw;
-
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("UseFastStreamChange"), dw)) {
- m_useFastStreamChange = !!dw;
- }
-
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("ForcedSub"), dw)) {
- m_ForcedSub = !!dw;
- }
-
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("TrackPriority"), dw)) {
- m_TrackPriority = !!dw;
- }
-
- len = _countof(buff);
- memset(buff, 0, sizeof(buff));
- if (ERROR_SUCCESS == key.QueryStringValue(_T("AudioLanguageOrder"), buff, &len)) {
- m_csAudioLanguageOrder = CString(buff);
- }
-
- len = _countof(buff);
- memset(buff, 0, sizeof(buff));
- if (ERROR_SUCCESS == key.QueryStringValue(_T("SubtitlesLanguageOrder"), buff, &len)) {
- m_csSubtitlesLanguageOrder = CString(buff);
- }
-
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("VC1_Decoder_Output"), dw)) {
- m_nVC1_GuidFlag = dw;
- }
-
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("AC3CoreOnly"), dw)) {
- m_AC3CoreOnly = dw;
- }
-
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("AlternativeDuration"), dw)) {
- m_AlternativeDuration = !!dw;
- }
- }
+ CRegKey key;
+ TCHAR buff[256];
+ ULONG len;
+
+ if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Splitter"), KEY_READ)) {
+ DWORD dw;
+
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("UseFastStreamChange"), dw)) {
+ m_useFastStreamChange = !!dw;
+ }
+
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("ForcedSub"), dw)) {
+ m_ForcedSub = !!dw;
+ }
+
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("TrackPriority"), dw)) {
+ m_TrackPriority = !!dw;
+ }
+
+ len = _countof(buff);
+ memset(buff, 0, sizeof(buff));
+ if (ERROR_SUCCESS == key.QueryStringValue(_T("AudioLanguageOrder"), buff, &len)) {
+ m_csAudioLanguageOrder = CString(buff);
+ }
+
+ len = _countof(buff);
+ memset(buff, 0, sizeof(buff));
+ if (ERROR_SUCCESS == key.QueryStringValue(_T("SubtitlesLanguageOrder"), buff, &len)) {
+ m_csSubtitlesLanguageOrder = CString(buff);
+ }
+
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("VC1_Decoder_Output"), dw)) {
+ m_nVC1_GuidFlag = dw;
+ }
+
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("AC3CoreOnly"), dw)) {
+ m_AC3CoreOnly = dw;
+ }
+
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("AlternativeDuration"), dw)) {
+ m_AlternativeDuration = !!dw;
+ }
+ }
#else
- m_useFastStreamChange = !!AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Splitter"), _T("UseFastStreamChange"), m_useFastStreamChange);
- m_ForcedSub = !!AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Splitter"), _T("ForcedSub"), m_ForcedSub);
- m_TrackPriority = !!AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Splitter"), _T("TrackPriority"), m_TrackPriority);
- m_csSubtitlesLanguageOrder = AfxGetApp()->GetProfileString(IDS_R_SETTINGS, IDS_RS_SUBTITLESLANGORDER, _T(""));
- m_csAudioLanguageOrder = AfxGetApp()->GetProfileString(IDS_R_SETTINGS, IDS_RS_AUDIOSLANGORDER, _T(""));
- m_nVC1_GuidFlag = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Splitter"), _T("VC1_Decoder_Output"), m_nVC1_GuidFlag);
- if (m_nVC1_GuidFlag<1 || m_nVC1_GuidFlag>3) m_nVC1_GuidFlag = 1;
- m_AC3CoreOnly = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Splitter"), _T("AC3CoreOnly"), m_AC3CoreOnly);
- m_AlternativeDuration = !!AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Splitter"), _T("AlternativeDuration"), m_AlternativeDuration);
+ m_useFastStreamChange = !!AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Splitter"), _T("UseFastStreamChange"), m_useFastStreamChange);
+ m_ForcedSub = !!AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Splitter"), _T("ForcedSub"), m_ForcedSub);
+ m_TrackPriority = !!AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Splitter"), _T("TrackPriority"), m_TrackPriority);
+ m_csSubtitlesLanguageOrder = AfxGetApp()->GetProfileString(IDS_R_SETTINGS, IDS_RS_SUBTITLESLANGORDER, _T(""));
+ m_csAudioLanguageOrder = AfxGetApp()->GetProfileString(IDS_R_SETTINGS, IDS_RS_AUDIOSLANGORDER, _T(""));
+ m_nVC1_GuidFlag = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Splitter"), _T("VC1_Decoder_Output"), m_nVC1_GuidFlag);
+ if (m_nVC1_GuidFlag < 1 || m_nVC1_GuidFlag > 3) { m_nVC1_GuidFlag = 1; }
+ m_AC3CoreOnly = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Splitter"), _T("AC3CoreOnly"), m_AC3CoreOnly);
+ m_AlternativeDuration = !!AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Splitter"), _T("AlternativeDuration"), m_AlternativeDuration);
#endif
}
bool CMpegSplitterFilter::StreamIsTrueHD(const WORD pid)
{
- int iProgram = -1;
- const CHdmvClipInfo::Stream *pClipInfo;
- const CMpegSplitterFile::program * pProgram = m_pFile->FindProgram(pid, iProgram, pClipInfo);
- int StreamType = pClipInfo ? pClipInfo->m_Type : pProgram ? pProgram->streams[iProgram].type : 0;
- return (StreamType == AUDIO_STREAM_AC3_TRUE_HD);
+ int iProgram = -1;
+ const CHdmvClipInfo::Stream* pClipInfo;
+ const CMpegSplitterFile::program* pProgram = m_pFile->FindProgram(pid, iProgram, pClipInfo);
+ int StreamType = pClipInfo ? pClipInfo->m_Type : pProgram ? pProgram->streams[iProgram].type : 0;
+ return (StreamType == AUDIO_STREAM_AC3_TRUE_HD);
}
STDMETHODIMP CMpegSplitterFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
-
- return
- QI(IMpegSplitterFilter)
- QI(ISpecifyPropertyPages)
- QI(ISpecifyPropertyPages2)
- QI(IAMStreamSelect)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ CheckPointer(ppv, E_POINTER);
+
+ return
+ QI(IMpegSplitterFilter)
+ QI(ISpecifyPropertyPages)
+ QI(ISpecifyPropertyPages2)
+ QI(IAMStreamSelect)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
STDMETHODIMP CMpegSplitterFilter::GetClassID(CLSID* pClsID)
{
- CheckPointer (pClsID, E_POINTER);
-
- if (m_pPipoBimbo) {
- memcpy (pClsID, &CLSID_WMAsfReader, sizeof (GUID));
- return S_OK;
- } else {
- return __super::GetClassID(pClsID);
- }
+ CheckPointer(pClsID, E_POINTER);
+
+ if (m_pPipoBimbo) {
+ memcpy(pClsID, &CLSID_WMAsfReader, sizeof(GUID));
+ return S_OK;
+ } else {
+ return __super::GetClassID(pClsID);
+ }
}
STDMETHODIMP CMpegSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo)
{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
-
- if (m_pName && m_pName[0]==L'M' && m_pName[1]==L'P' && m_pName[2]==L'C') {
- (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
- } else {
- wcscpy_s(pInfo->achName, MpegSourceName);
- }
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
+ CheckPointer(pInfo, E_POINTER);
+ ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
+
+ if (m_pName && m_pName[0] == L'M' && m_pName[1] == L'P' && m_pName[2] == L'C') {
+ (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
+ } else {
+ wcscpy_s(pInfo->achName, MpegSourceName);
+ }
+ pInfo->pGraph = m_pGraph;
+ if (m_pGraph) {
+ m_pGraph->AddRef();
+ }
+
+ return S_OK;
}
void CMpegSplitterFilter::ReadClipInfo(LPCOLESTR pszFileName)
{
- if (wcslen (pszFileName) > 0) {
- WCHAR Drive[_MAX_DRIVE];
- WCHAR Dir[_MAX_PATH];
- WCHAR Filename[_MAX_PATH];
- WCHAR Ext[_MAX_EXT];
-
- if (_wsplitpath_s (pszFileName, Drive, _countof(Drive), Dir, _countof(Dir), Filename, _countof(Filename), Ext, _countof(Ext)) == 0) {
- CString strClipInfo;
-
- _wcslwr_s(Ext, _countof(Ext));
-
- if (wcscmp(Ext, L".ssif") == 0) {
- if (Drive[0]) {
- strClipInfo.Format (_T("%s\\%s\\..\\..\\CLIPINF\\%s.clpi"), Drive, Dir, Filename);
- } else {
- strClipInfo.Format (_T("%s\\..\\..\\CLIPINF\\%s.clpi"), Dir, Filename);
- }
- } else {
- if (Drive[0]) {
- strClipInfo.Format (_T("%s\\%s\\..\\CLIPINF\\%s.clpi"), Drive, Dir, Filename);
- } else {
- strClipInfo.Format (_T("%s\\..\\CLIPINF\\%s.clpi"), Dir, Filename);
- }
- }
-
- m_ClipInfo.ReadInfo (strClipInfo);
- }
- }
+ if (wcslen(pszFileName) > 0) {
+ WCHAR Drive[_MAX_DRIVE];
+ WCHAR Dir[_MAX_PATH];
+ WCHAR Filename[_MAX_PATH];
+ WCHAR Ext[_MAX_EXT];
+
+ if (_wsplitpath_s(pszFileName, Drive, _countof(Drive), Dir, _countof(Dir), Filename, _countof(Filename), Ext, _countof(Ext)) == 0) {
+ CString strClipInfo;
+
+ _wcslwr_s(Ext, _countof(Ext));
+
+ if (wcscmp(Ext, L".ssif") == 0) {
+ if (Drive[0]) {
+ strClipInfo.Format(_T("%s\\%s\\..\\..\\CLIPINF\\%s.clpi"), Drive, Dir, Filename);
+ } else {
+ strClipInfo.Format(_T("%s\\..\\..\\CLIPINF\\%s.clpi"), Dir, Filename);
+ }
+ } else {
+ if (Drive[0]) {
+ strClipInfo.Format(_T("%s\\%s\\..\\CLIPINF\\%s.clpi"), Drive, Dir, Filename);
+ } else {
+ strClipInfo.Format(_T("%s\\..\\CLIPINF\\%s.clpi"), Dir, Filename);
+ }
+ }
+
+ m_ClipInfo.ReadInfo(strClipInfo);
+ }
+ }
}
STDMETHODIMP CMpegSplitterFilter::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
- return __super::Load (pszFileName, pmt);
+ return __super::Load(pszFileName, pmt);
}
HRESULT CMpegSplitterFilter::DemuxNextPacket(REFERENCE_TIME rtStartOffset)
{
- HRESULT hr;
- BYTE b;
-
- if (m_pFile->m_type == mpeg_ps || m_pFile->m_type == mpeg_es) {
- if (!m_pFile->NextMpegStartCode(b)) {
- return S_FALSE;
- }
-
- if (b == 0xba) { // program stream header
- CMpegSplitterFile::pshdr h;
- if (!m_pFile->Read(h)) {
- return S_FALSE;
- }
- } else if (b == 0xbb) { // program stream system header
- CMpegSplitterFile::pssyshdr h;
- if (!m_pFile->Read(h)) {
- return S_FALSE;
- }
- }
- else if ((b >= 0xbd && b < 0xf0) || (b == 0xfd)) { // pes packet
- CMpegSplitterFile::peshdr h;
-
- if (!m_pFile->Read(h, b) || !h.len) {
- return S_FALSE;
- }
-
- if (h.type == CMpegSplitterFile::mpeg2 && h.scrambling) {
- ASSERT(0);
- return E_FAIL;
- }
-
- __int64 pos = m_pFile->GetPos();
-
- DWORD TrackNumber = m_pFile->AddStream(0, b, h.id_ext, h.len);
-
- if (GetOutputPin(TrackNumber)) {
- CAutoPtr<Packet> p(DNew Packet());
-
- p->TrackNumber = TrackNumber;
- p->bSyncPoint = !!h.fpts;
- p->bAppendable = !h.fpts;
- p->rtStart = h.fpts ? (h.pts - rtStartOffset) : Packet::INVALID_TIME;
- p->rtStop = p->rtStart+1;
- p->SetCount(h.len - (size_t)(m_pFile->GetPos() - pos));
-
- m_pFile->ByteRead(p->GetData(), h.len - (m_pFile->GetPos() - pos));
-
- hr = DeliverPacket(p);
- }
- m_pFile->Seek(pos + h.len);
- }
- } else if (m_pFile->m_type == mpeg_ts) {
- CMpegSplitterFile::trhdr h;
-
- if (!m_pFile->Read(h)) {
- return S_FALSE;
- }
-
-
- __int64 pos = m_pFile->GetPos();
-
- m_pFile->UpdatePrograms(h, false);
-
- if (h.payload && ISVALIDPID(h.pid)) {
- DWORD TrackNumber = h.pid;
-
- CMpegSplitterFile::peshdr h2;
-
- if (h.payloadstart && m_pFile->NextMpegStartCode(b, 4) && m_pFile->Read(h2, b)) { // pes packet
- if (h2.type == CMpegSplitterFile::mpeg2 && h2.scrambling) {
- ASSERT(0);
- return E_FAIL;
- }
- TrackNumber = m_pFile->AddStream(h.pid, b, 0, h.bytes - (DWORD)(m_pFile->GetPos() - pos));
- }
-
- if (GetOutputPin(TrackNumber)) {
- CAutoPtr<Packet> p(DNew Packet());
-
- p->TrackNumber = TrackNumber;
- p->bSyncPoint = !!h2.fpts;
- p->bAppendable = !h2.fpts;
-
- if (h.fPCR) {
- CRefTime rtNow;
- StreamTime(rtNow);
- //TRACE ("Now=%S PCR=%S\n", ReftimeToString(rtNow.m_time), ReftimeToString(h.PCR));
- }
-
- p->rtStart = h2.fpts ? (h2.pts - rtStartOffset) : Packet::INVALID_TIME;
- p->rtStop = p->rtStart+1;
- p->SetCount(h.bytes - (size_t)(m_pFile->GetPos() - pos));
-
- int nBytes = int(h.bytes - (m_pFile->GetPos() - pos));
- m_pFile->ByteRead(p->GetData(), nBytes);
-
- hr = DeliverPacket(p);
- }
- }
-
- m_pFile->Seek(h.next);
- } else if (m_pFile->m_type == mpeg_pva) {
- CMpegSplitterFile::pvahdr h;
- if (!m_pFile->Read(h)) {
- return S_FALSE;
- }
+ HRESULT hr;
+ BYTE b;
+
+ if (m_pFile->m_type == mpeg_ps || m_pFile->m_type == mpeg_es) {
+ if (!m_pFile->NextMpegStartCode(b)) {
+ return S_FALSE;
+ }
+
+ if (b == 0xba) { // program stream header
+ CMpegSplitterFile::pshdr h;
+ if (!m_pFile->Read(h)) {
+ return S_FALSE;
+ }
+ } else if (b == 0xbb) { // program stream system header
+ CMpegSplitterFile::pssyshdr h;
+ if (!m_pFile->Read(h)) {
+ return S_FALSE;
+ }
+ } else if ((b >= 0xbd && b < 0xf0) || (b == 0xfd)) { // pes packet
+ CMpegSplitterFile::peshdr h;
+
+ if (!m_pFile->Read(h, b) || !h.len) {
+ return S_FALSE;
+ }
+
+ if (h.type == CMpegSplitterFile::mpeg2 && h.scrambling) {
+ ASSERT(0);
+ return E_FAIL;
+ }
+
+ __int64 pos = m_pFile->GetPos();
+
+ DWORD TrackNumber = m_pFile->AddStream(0, b, h.id_ext, h.len);
+
+ if (GetOutputPin(TrackNumber)) {
+ CAutoPtr<Packet> p(DNew Packet());
+
+ p->TrackNumber = TrackNumber;
+ p->bSyncPoint = !!h.fpts;
+ p->bAppendable = !h.fpts;
+ p->rtStart = h.fpts ? (h.pts - rtStartOffset) : Packet::INVALID_TIME;
+ p->rtStop = p->rtStart + 1;
+ p->SetCount(h.len - (size_t)(m_pFile->GetPos() - pos));
+
+ m_pFile->ByteRead(p->GetData(), h.len - (m_pFile->GetPos() - pos));
+
+ hr = DeliverPacket(p);
+ }
+ m_pFile->Seek(pos + h.len);
+ }
+ } else if (m_pFile->m_type == mpeg_ts) {
+ CMpegSplitterFile::trhdr h;
+
+ if (!m_pFile->Read(h)) {
+ return S_FALSE;
+ }
+
+
+ __int64 pos = m_pFile->GetPos();
+
+ m_pFile->UpdatePrograms(h, false);
+
+ if (h.payload && ISVALIDPID(h.pid)) {
+ DWORD TrackNumber = h.pid;
+
+ CMpegSplitterFile::peshdr h2;
+
+ if (h.payloadstart && m_pFile->NextMpegStartCode(b, 4) && m_pFile->Read(h2, b)) { // pes packet
+ if (h2.type == CMpegSplitterFile::mpeg2 && h2.scrambling) {
+ ASSERT(0);
+ return E_FAIL;
+ }
+ TrackNumber = m_pFile->AddStream(h.pid, b, 0, h.bytes - (DWORD)(m_pFile->GetPos() - pos));
+ }
+
+ if (GetOutputPin(TrackNumber)) {
+ CAutoPtr<Packet> p(DNew Packet());
+
+ p->TrackNumber = TrackNumber;
+ p->bSyncPoint = !!h2.fpts;
+ p->bAppendable = !h2.fpts;
+
+ if (h.fPCR) {
+ CRefTime rtNow;
+ StreamTime(rtNow);
+ //TRACE ("Now=%S PCR=%S\n", ReftimeToString(rtNow.m_time), ReftimeToString(h.PCR));
+ }
+
+ p->rtStart = h2.fpts ? (h2.pts - rtStartOffset) : Packet::INVALID_TIME;
+ p->rtStop = p->rtStart + 1;
+ p->SetCount(h.bytes - (size_t)(m_pFile->GetPos() - pos));
+
+ int nBytes = int(h.bytes - (m_pFile->GetPos() - pos));
+ m_pFile->ByteRead(p->GetData(), nBytes);
+
+ hr = DeliverPacket(p);
+ }
+ }
+
+ m_pFile->Seek(h.next);
+ } else if (m_pFile->m_type == mpeg_pva) {
+ CMpegSplitterFile::pvahdr h;
+ if (!m_pFile->Read(h)) {
+ return S_FALSE;
+ }
+
+ DWORD TrackNumber = h.streamid;
- DWORD TrackNumber = h.streamid;
-
- __int64 pos = m_pFile->GetPos();
+ __int64 pos = m_pFile->GetPos();
- if (GetOutputPin(TrackNumber)) {
- CAutoPtr<Packet> p(DNew Packet());
+ if (GetOutputPin(TrackNumber)) {
+ CAutoPtr<Packet> p(DNew Packet());
- p->TrackNumber = TrackNumber;
- p->bSyncPoint = !!h.fpts;
- p->bAppendable = !h.fpts;
- p->rtStart = h.fpts ? (h.pts - rtStartOffset) : Packet::INVALID_TIME;
- p->rtStop = p->rtStart+1;
- p->SetCount(h.length);
+ p->TrackNumber = TrackNumber;
+ p->bSyncPoint = !!h.fpts;
+ p->bAppendable = !h.fpts;
+ p->rtStart = h.fpts ? (h.pts - rtStartOffset) : Packet::INVALID_TIME;
+ p->rtStop = p->rtStart + 1;
+ p->SetCount(h.length);
- m_pFile->ByteRead(p->GetData(), h.length);
- hr = DeliverPacket(p);
- }
+ m_pFile->ByteRead(p->GetData(), h.length);
+ hr = DeliverPacket(p);
+ }
- m_pFile->Seek(pos + h.length);
- }
+ m_pFile->Seek(pos + h.length);
+ }
- return S_OK;
+ return S_OK;
}
//
HRESULT CMpegSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
{
- CheckPointer(pAsyncReader, E_POINTER);
-
- HRESULT hr = E_FAIL;
-
- m_pFile.Free();
-
- ReadClipInfo (GetPartFilename(pAsyncReader));
- m_pFile.Attach(DNew CMpegSplitterFile(pAsyncReader, hr, m_ClipInfo.IsHdmv(), m_ClipInfo, m_nVC1_GuidFlag, m_ForcedSub, m_TrackPriority, m_AC3CoreOnly, m_AlternativeDuration));
-
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
-
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- if (m_pFile->m_type == mpeg_ps) {
- if (m_pInput && m_pInput->IsConnected() && (GetCLSID(m_pInput->GetConnected()) == GUIDFromCString(_T("{773EAEDE-D5EE-4fce-9C8F-C4F53D0A2F73}")))) { // MPC VTS Reader
- pTI = GetFilterFromPin(m_pInput->GetConnected());
- }
- }
-
- CString cs_audioProgram = _T("");
- CString cs_subpicProgram = _T("");
-
- // Create
- if (m_ClipInfo.IsHdmv()) {
- for (size_t i=0; i < m_ClipInfo.GetStreamNumber(); i++) {
- CHdmvClipInfo::Stream* stream = m_ClipInfo.GetStreamByIndex (i);
- if (stream->m_Type == PRESENTATION_GRAPHICS_STREAM) {
- m_pFile->AddHdmvPGStream (stream->m_PID, stream->m_LanguageCode);
- }
- }
- }
-
- CString lang = _T("");
- CAtlList<CString> lang_list_audio;
- CAtlList<CString> lang_list_subpic;
- int Idx_audio = 99;
- int Idx_subpic = 99;
-
- if (!m_csAudioLanguageOrder.IsEmpty()) {
- int tPos = 0;
- lang = m_csAudioLanguageOrder.Tokenize(_T(",; "), tPos);
- while (tPos != -1) {
- if (!lang.IsEmpty()) lang_list_audio.AddTail(lang);
- lang = m_csAudioLanguageOrder.Tokenize(_T(",; "), tPos);
- }
- if (!lang.IsEmpty()) lang_list_audio.AddTail(lang);
- }
-
- if (!m_csSubtitlesLanguageOrder.IsEmpty()) {
- int tPos = 0;
- lang = m_csSubtitlesLanguageOrder.Tokenize(_T(",; "), tPos);
- while (tPos != -1) {
- if (!lang.IsEmpty()) lang_list_subpic.AddTail(lang);
- lang = m_csSubtitlesLanguageOrder.Tokenize(_T(",; "), tPos);
- }
- if (!lang.IsEmpty()) lang_list_subpic.AddTail(lang);
- }
-
- for (int i = 0; i < _countof(m_pFile->m_streams); i++) {
- POSITION pos = m_pFile->m_streams[i].GetHeadPosition();
- while (pos) {
- CMpegSplitterFile::stream& s = m_pFile->m_streams[i].GetNext(pos);
- CAtlArray<CMediaType> mts;
- mts.Add(s.mt);
-
- CStringW name = CMpegSplitterFile::CStreamList::ToString(i);
- CStringW str;
-
- if (i == CMpegSplitterFile::subpic && s.pid == NO_SUBTITLE_PID) {
- str = NO_SUBTITLE_NAME;
- continue;
- } else {
- int iProgram = -1;
- const CHdmvClipInfo::Stream *pClipInfo;
- const CMpegSplitterFile::program * pProgram = m_pFile->FindProgram(s.pid, iProgram, pClipInfo);
- const wchar_t *pStreamName = NULL;
- int StreamType = pClipInfo ? pClipInfo->m_Type : pProgram ? pProgram->streams[iProgram].type : 0;
- pStreamName = StreamTypeToName((PES_STREAM_TYPE)StreamType);
-
- CString lang_name = _T("");
- m_pFile->m_pPMT_Lang.Lookup(s.pid, lang_name);
-
- lang_name = pTI ? pTI->GetTrackName(s.ps1id) : lang_name;
-
- CString FormatDesc = GetMediaTypeDesc(&s.mt, pClipInfo, StreamType, lang_name);
-
- if (!FormatDesc.IsEmpty()) {
- str.Format(L"%s (%04x,%02x,%02x)", FormatDesc.GetString(), s.pid, s.pesid, s.ps1id); // TODO: make this nicer
- } else if (pStreamName) {
- str.Format(L"%s - %s (%04x,%02x,%02x)", name, pStreamName, s.pid, s.pesid, s.ps1id); // TODO: make this nicer
- } else {
- str.Format(L"%s (%04x,%02x,%02x)", name, s.pid, s.pesid, s.ps1id); // TODO: make this nicer
- }
- }
- CString str_tmp = str;
- str_tmp.MakeLower();
- if (i == CMpegSplitterFile::audio) {
- if (lang_list_audio.GetCount()>0) {
- int idx = 0;
- POSITION pos = lang_list_audio.GetHeadPosition();
- while (pos) {
- lang = lang_list_audio.GetNext(pos).MakeLower();
- if (-1 != str_tmp.Find(lang)) {
- if (idx<Idx_audio) {
- cs_audioProgram = str;
- Idx_audio = idx;
- break;
- }
- }
- idx++;
- }
- }
- if (!Idx_audio && !cs_audioProgram.IsEmpty()) break;
- }
- if (i == CMpegSplitterFile::subpic) {
- if (lang_list_subpic.GetCount()>0) {
- int idx = 0;
- POSITION pos = lang_list_subpic.GetHeadPosition();
- while (pos) {
- lang = lang_list_subpic.GetNext(pos).MakeLower();
- if (-1 != str_tmp.Find(lang)) {
- if (idx<Idx_subpic) {
- cs_subpicProgram = str;
- Idx_subpic = idx;
- break;
- }
- }
- idx++;
- }
- }
- if (!Idx_subpic && !cs_subpicProgram.IsEmpty()) break;
- }
- }
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration = 0;
-
- for (int i = 0; i < _countof(m_pFile->m_streams); i++) {
- POSITION pos = m_pFile->m_streams[i].GetHeadPosition();
- while (pos) {
- CMpegSplitterFile::stream& s = m_pFile->m_streams[i].GetNext(pos);
- CAtlArray<CMediaType> mts;
- mts.Add(s.mt);
-
- CStringW name = CMpegSplitterFile::CStreamList::ToString(i);
- CStringW str;
-
- if (i == CMpegSplitterFile::subpic && s.pid == NO_SUBTITLE_PID) {
- str = NO_SUBTITLE_NAME;
- } else {
- int iProgram = -1;
- const CHdmvClipInfo::Stream *pClipInfo;
- const CMpegSplitterFile::program * pProgram = m_pFile->FindProgram(s.pid, iProgram, pClipInfo);
- const wchar_t *pStreamName = NULL;
- int StreamType = pClipInfo ? pClipInfo->m_Type : pProgram ? pProgram->streams[iProgram].type : 0;
- pStreamName = StreamTypeToName((PES_STREAM_TYPE)StreamType);
-
- CString lang_name = _T("");
- m_pFile->m_pPMT_Lang.Lookup(s.pid, lang_name);
-
- lang_name = pTI ? pTI->GetTrackName(s.ps1id) : lang_name;
-
- CString FormatDesc = GetMediaTypeDesc(&s.mt, pClipInfo, StreamType, lang_name);
-
- if (!FormatDesc.IsEmpty()) {
- str.Format(L"%s (%04x,%02x,%02x)", FormatDesc.GetString(), s.pid, s.pesid, s.ps1id); // TODO: make this nicer
- } else if (pStreamName) {
- str.Format(L"%s - %s (%04x,%02x,%02x)", name, pStreamName, s.pid, s.pesid, s.ps1id); // TODO: make this nicer
- } else {
- str.Format(L"%s (%04x,%02x,%02x)", name, s.pid, s.pesid, s.ps1id); // TODO: make this nicer
- }
- }
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CMpegSplitterOutputPin(mts, str, this, this, &hr, m_pFile->m_type));
- if (i == CMpegSplitterFile::subpic) {
- (static_cast<CMpegSplitterOutputPin*>(pPinOut.m_p))->SetMaxShift (_I64_MAX);
- }
-
- if (i == CMpegSplitterFile::audio) {
- if (!cs_audioProgram.IsEmpty()) {
- if ((!cs_audioProgram.Compare(str)) && (S_OK == AddOutputPin(s, pPinOut))) {
- break;
- }
- } else {
- if (S_OK == AddOutputPin(s, pPinOut)) {
- break;
- }
- }
- }
- else if (i == CMpegSplitterFile::subpic) {
- if (!cs_subpicProgram.IsEmpty()) {
- if ((!cs_subpicProgram.Compare(str)) && (S_OK == AddOutputPin(s, pPinOut))) {
- break;
- }
- } else {
- if ((m_pFile->m_streams[CMpegSplitterFile::subpic].GetCount() == 1) && (S_OK == AddOutputPin(s, pPinOut))) {
- break;
- } else if ((s.pid != NO_SUBTITLE_PID) && (S_OK == AddOutputPin(s, pPinOut))) {
- break;
- }
- }
- } else {
- if (S_OK == AddOutputPin(s, pPinOut)) {
- break;
- }
- }
- }
- }
-
- if (m_rtPlaylistDuration) {
- m_rtNewStop = m_rtStop = m_rtDuration = m_rtPlaylistDuration;
- } else if (m_pFile->IsRandomAccess() && m_pFile->m_rate) {
- m_rtNewStop = m_rtStop = m_rtDuration = 10000000i64 * m_pFile->GetLength() / m_pFile->m_rate;
- }
-
- return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
+ CheckPointer(pAsyncReader, E_POINTER);
+
+ HRESULT hr = E_FAIL;
+
+ m_pFile.Free();
+
+ ReadClipInfo(GetPartFilename(pAsyncReader));
+ m_pFile.Attach(DNew CMpegSplitterFile(pAsyncReader, hr, m_ClipInfo.IsHdmv(), m_ClipInfo, m_nVC1_GuidFlag, m_ForcedSub, m_TrackPriority, m_AC3CoreOnly, m_AlternativeDuration));
+
+ if (!m_pFile) {
+ return E_OUTOFMEMORY;
+ }
+
+ if (FAILED(hr)) {
+ m_pFile.Free();
+ return hr;
+ }
+
+ if (m_pFile->m_type == mpeg_ps) {
+ if (m_pInput && m_pInput->IsConnected() && (GetCLSID(m_pInput->GetConnected()) == GUIDFromCString(_T("{773EAEDE-D5EE-4fce-9C8F-C4F53D0A2F73}")))) { // MPC VTS Reader
+ pTI = GetFilterFromPin(m_pInput->GetConnected());
+ }
+ }
+
+ CString cs_audioProgram = _T("");
+ CString cs_subpicProgram = _T("");
+
+ // Create
+ if (m_ClipInfo.IsHdmv()) {
+ for (size_t i = 0; i < m_ClipInfo.GetStreamNumber(); i++) {
+ CHdmvClipInfo::Stream* stream = m_ClipInfo.GetStreamByIndex(i);
+ if (stream->m_Type == PRESENTATION_GRAPHICS_STREAM) {
+ m_pFile->AddHdmvPGStream(stream->m_PID, stream->m_LanguageCode);
+ }
+ }
+ }
+
+ CString lang = _T("");
+ CAtlList<CString> lang_list_audio;
+ CAtlList<CString> lang_list_subpic;
+ int Idx_audio = 99;
+ int Idx_subpic = 99;
+
+ if (!m_csAudioLanguageOrder.IsEmpty()) {
+ int tPos = 0;
+ lang = m_csAudioLanguageOrder.Tokenize(_T(",; "), tPos);
+ while (tPos != -1) {
+ if (!lang.IsEmpty()) { lang_list_audio.AddTail(lang); }
+ lang = m_csAudioLanguageOrder.Tokenize(_T(",; "), tPos);
+ }
+ if (!lang.IsEmpty()) { lang_list_audio.AddTail(lang); }
+ }
+
+ if (!m_csSubtitlesLanguageOrder.IsEmpty()) {
+ int tPos = 0;
+ lang = m_csSubtitlesLanguageOrder.Tokenize(_T(",; "), tPos);
+ while (tPos != -1) {
+ if (!lang.IsEmpty()) { lang_list_subpic.AddTail(lang); }
+ lang = m_csSubtitlesLanguageOrder.Tokenize(_T(",; "), tPos);
+ }
+ if (!lang.IsEmpty()) { lang_list_subpic.AddTail(lang); }
+ }
+
+ for (int i = 0; i < _countof(m_pFile->m_streams); i++) {
+ POSITION pos = m_pFile->m_streams[i].GetHeadPosition();
+ while (pos) {
+ CMpegSplitterFile::stream& s = m_pFile->m_streams[i].GetNext(pos);
+ CAtlArray<CMediaType> mts;
+ mts.Add(s.mt);
+
+ CStringW name = CMpegSplitterFile::CStreamList::ToString(i);
+ CStringW str;
+
+ if (i == CMpegSplitterFile::subpic && s.pid == NO_SUBTITLE_PID) {
+ str = NO_SUBTITLE_NAME;
+ continue;
+ } else {
+ int iProgram = -1;
+ const CHdmvClipInfo::Stream* pClipInfo;
+ const CMpegSplitterFile::program* pProgram = m_pFile->FindProgram(s.pid, iProgram, pClipInfo);
+ const wchar_t* pStreamName = NULL;
+ int StreamType = pClipInfo ? pClipInfo->m_Type : pProgram ? pProgram->streams[iProgram].type : 0;
+ pStreamName = StreamTypeToName((PES_STREAM_TYPE)StreamType);
+
+ CString lang_name = _T("");
+ m_pFile->m_pPMT_Lang.Lookup(s.pid, lang_name);
+
+ lang_name = pTI ? pTI->GetTrackName(s.ps1id) : lang_name;
+
+ CString FormatDesc = GetMediaTypeDesc(&s.mt, pClipInfo, StreamType, lang_name);
+
+ if (!FormatDesc.IsEmpty()) {
+ str.Format(L"%s (%04x,%02x,%02x)", FormatDesc.GetString(), s.pid, s.pesid, s.ps1id); // TODO: make this nicer
+ } else if (pStreamName) {
+ str.Format(L"%s - %s (%04x,%02x,%02x)", name, pStreamName, s.pid, s.pesid, s.ps1id); // TODO: make this nicer
+ } else {
+ str.Format(L"%s (%04x,%02x,%02x)", name, s.pid, s.pesid, s.ps1id); // TODO: make this nicer
+ }
+ }
+ CString str_tmp = str;
+ str_tmp.MakeLower();
+ if (i == CMpegSplitterFile::audio) {
+ if (lang_list_audio.GetCount() > 0) {
+ int idx = 0;
+ POSITION pos = lang_list_audio.GetHeadPosition();
+ while (pos) {
+ lang = lang_list_audio.GetNext(pos).MakeLower();
+ if (-1 != str_tmp.Find(lang)) {
+ if (idx < Idx_audio) {
+ cs_audioProgram = str;
+ Idx_audio = idx;
+ break;
+ }
+ }
+ idx++;
+ }
+ }
+ if (!Idx_audio && !cs_audioProgram.IsEmpty()) { break; }
+ }
+ if (i == CMpegSplitterFile::subpic) {
+ if (lang_list_subpic.GetCount() > 0) {
+ int idx = 0;
+ POSITION pos = lang_list_subpic.GetHeadPosition();
+ while (pos) {
+ lang = lang_list_subpic.GetNext(pos).MakeLower();
+ if (-1 != str_tmp.Find(lang)) {
+ if (idx < Idx_subpic) {
+ cs_subpicProgram = str;
+ Idx_subpic = idx;
+ break;
+ }
+ }
+ idx++;
+ }
+ }
+ if (!Idx_subpic && !cs_subpicProgram.IsEmpty()) { break; }
+ }
+ }
+ }
+
+ m_rtNewStart = m_rtCurrent = 0;
+ m_rtNewStop = m_rtStop = m_rtDuration = 0;
+
+ for (int i = 0; i < _countof(m_pFile->m_streams); i++) {
+ POSITION pos = m_pFile->m_streams[i].GetHeadPosition();
+ while (pos) {
+ CMpegSplitterFile::stream& s = m_pFile->m_streams[i].GetNext(pos);
+ CAtlArray<CMediaType> mts;
+ mts.Add(s.mt);
+
+ CStringW name = CMpegSplitterFile::CStreamList::ToString(i);
+ CStringW str;
+
+ if (i == CMpegSplitterFile::subpic && s.pid == NO_SUBTITLE_PID) {
+ str = NO_SUBTITLE_NAME;
+ } else {
+ int iProgram = -1;
+ const CHdmvClipInfo::Stream* pClipInfo;
+ const CMpegSplitterFile::program* pProgram = m_pFile->FindProgram(s.pid, iProgram, pClipInfo);
+ const wchar_t* pStreamName = NULL;
+ int StreamType = pClipInfo ? pClipInfo->m_Type : pProgram ? pProgram->streams[iProgram].type : 0;
+ pStreamName = StreamTypeToName((PES_STREAM_TYPE)StreamType);
+
+ CString lang_name = _T("");
+ m_pFile->m_pPMT_Lang.Lookup(s.pid, lang_name);
+
+ lang_name = pTI ? pTI->GetTrackName(s.ps1id) : lang_name;
+
+ CString FormatDesc = GetMediaTypeDesc(&s.mt, pClipInfo, StreamType, lang_name);
+
+ if (!FormatDesc.IsEmpty()) {
+ str.Format(L"%s (%04x,%02x,%02x)", FormatDesc.GetString(), s.pid, s.pesid, s.ps1id); // TODO: make this nicer
+ } else if (pStreamName) {
+ str.Format(L"%s - %s (%04x,%02x,%02x)", name, pStreamName, s.pid, s.pesid, s.ps1id); // TODO: make this nicer
+ } else {
+ str.Format(L"%s (%04x,%02x,%02x)", name, s.pid, s.pesid, s.ps1id); // TODO: make this nicer
+ }
+ }
+
+ CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CMpegSplitterOutputPin(mts, str, this, this, &hr, m_pFile->m_type));
+ if (i == CMpegSplitterFile::subpic) {
+ (static_cast<CMpegSplitterOutputPin*>(pPinOut.m_p))->SetMaxShift(_I64_MAX);
+ }
+
+ if (i == CMpegSplitterFile::audio) {
+ if (!cs_audioProgram.IsEmpty()) {
+ if ((!cs_audioProgram.Compare(str)) && (S_OK == AddOutputPin(s, pPinOut))) {
+ break;
+ }
+ } else {
+ if (S_OK == AddOutputPin(s, pPinOut)) {
+ break;
+ }
+ }
+ } else if (i == CMpegSplitterFile::subpic) {
+ if (!cs_subpicProgram.IsEmpty()) {
+ if ((!cs_subpicProgram.Compare(str)) && (S_OK == AddOutputPin(s, pPinOut))) {
+ break;
+ }
+ } else {
+ if ((m_pFile->m_streams[CMpegSplitterFile::subpic].GetCount() == 1) && (S_OK == AddOutputPin(s, pPinOut))) {
+ break;
+ } else if ((s.pid != NO_SUBTITLE_PID) && (S_OK == AddOutputPin(s, pPinOut))) {
+ break;
+ }
+ }
+ } else {
+ if (S_OK == AddOutputPin(s, pPinOut)) {
+ break;
+ }
+ }
+ }
+ }
+
+ if (m_rtPlaylistDuration) {
+ m_rtNewStop = m_rtStop = m_rtDuration = m_rtPlaylistDuration;
+ } else if (m_pFile->IsRandomAccess() && m_pFile->m_rate) {
+ m_rtNewStop = m_rtStop = m_rtDuration = 10000000i64 * m_pFile->GetLength() / m_pFile->m_rate;
+ }
+
+ return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
}
bool CMpegSplitterFilter::DemuxInit()
{
- SetThreadName((DWORD)-1, "CMpegSplitterFilter");
- if (!m_pFile) {
- return false;
- }
+ SetThreadName((DWORD) - 1, "CMpegSplitterFilter");
+ if (!m_pFile) {
+ return false;
+ }
- m_rtStartOffset = 0;
+ m_rtStartOffset = 0;
- return true;
+ return true;
}
void CMpegSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
- CAtlList<CMpegSplitterFile::stream>* pMasterStream = m_pFile->GetMasterStream();
-
- if (!pMasterStream) {
- ASSERT(0);
- return;
- }
-
- if (m_pFile->IsStreaming()) {
- m_pFile->Seek(max(0, m_pFile->GetLength() - 100*1024));
- m_rtStartOffset = m_pFile->m_rtMin + m_pFile->NextPTS(pMasterStream->GetHead());
- return;
- }
-
- REFERENCE_TIME rtPreroll = 10000000;
-
- if (rt <= rtPreroll || m_rtDuration <= 0) {
- m_pFile->Seek(0);
- } else {
- __int64 len = m_pFile->GetLength();
- __int64 seekpos = (__int64)(1.0*rt/m_rtDuration*len);
- __int64 minseekpos = _I64_MAX;
-
- REFERENCE_TIME rtmax = rt - rtPreroll;
- REFERENCE_TIME rtmin = rtmax - 5000000;
-
- if (m_rtStartOffset == 0)
- for (int i = 0; i < _countof(m_pFile->m_streams)-1; i++) {
- POSITION pos = m_pFile->m_streams[i].GetHeadPosition();
- while (pos) {
- DWORD TrackNum = m_pFile->m_streams[i].GetNext(pos);
-
- CBaseSplitterOutputPin* pPin = GetOutputPin(TrackNum);
- if (pPin && pPin->IsConnected()) {
- m_pFile->Seek(seekpos);
-
- __int64 curpos = seekpos;
- REFERENCE_TIME pdt = _I64_MIN;
-
- for (int j = 0; j < 10; j++) {
- REFERENCE_TIME rt = m_pFile->NextPTS(TrackNum);
-
- if (rt < 0) {
- break;
- }
-
- REFERENCE_TIME dt = rt - rtmax;
- if (dt > 0 && dt == pdt) {
- dt = 10000000i64;
- }
-
-
- if (rtmin <= rt && rt <= rtmax || pdt > 0 && dt < 0) {
- minseekpos = min(minseekpos, curpos);
- break;
- }
-
- curpos -= (__int64)(1.0*dt/m_rtDuration*len);
- m_pFile->Seek(curpos);
-
- //pdt = dt;
- }
- }
- }
- }
-
- if (minseekpos != _I64_MAX) {
- seekpos = minseekpos;
- } else {
- // this file is probably screwed up, try plan B, seek simply by bitrate
-
- rt -= rtPreroll;
- seekpos = (__int64)(1.0*rt/m_rtDuration*len);
- m_pFile->Seek(seekpos);
- m_rtStartOffset = m_pFile->m_rtMin + m_pFile->NextPTS(pMasterStream->GetHead()) - rt;
- }
-
- m_pFile->Seek(seekpos);
- }
+ CAtlList<CMpegSplitterFile::stream>* pMasterStream = m_pFile->GetMasterStream();
+
+ if (!pMasterStream) {
+ ASSERT(0);
+ return;
+ }
+
+ if (m_pFile->IsStreaming()) {
+ m_pFile->Seek(max(0, m_pFile->GetLength() - 100 * 1024));
+ m_rtStartOffset = m_pFile->m_rtMin + m_pFile->NextPTS(pMasterStream->GetHead());
+ return;
+ }
+
+ REFERENCE_TIME rtPreroll = 10000000;
+
+ if (rt <= rtPreroll || m_rtDuration <= 0) {
+ m_pFile->Seek(0);
+ } else {
+ __int64 len = m_pFile->GetLength();
+ __int64 seekpos = (__int64)(1.0 * rt / m_rtDuration * len);
+ __int64 minseekpos = _I64_MAX;
+
+ REFERENCE_TIME rtmax = rt - rtPreroll;
+ REFERENCE_TIME rtmin = rtmax - 5000000;
+
+ if (m_rtStartOffset == 0)
+ for (int i = 0; i < _countof(m_pFile->m_streams) - 1; i++) {
+ POSITION pos = m_pFile->m_streams[i].GetHeadPosition();
+ while (pos) {
+ DWORD TrackNum = m_pFile->m_streams[i].GetNext(pos);
+
+ CBaseSplitterOutputPin* pPin = GetOutputPin(TrackNum);
+ if (pPin && pPin->IsConnected()) {
+ m_pFile->Seek(seekpos);
+
+ __int64 curpos = seekpos;
+ REFERENCE_TIME pdt = _I64_MIN;
+
+ for (int j = 0; j < 10; j++) {
+ REFERENCE_TIME rt = m_pFile->NextPTS(TrackNum);
+
+ if (rt < 0) {
+ break;
+ }
+
+ REFERENCE_TIME dt = rt - rtmax;
+ if (dt > 0 && dt == pdt) {
+ dt = 10000000i64;
+ }
+
+
+ if (rtmin <= rt && rt <= rtmax || pdt > 0 && dt < 0) {
+ minseekpos = min(minseekpos, curpos);
+ break;
+ }
+
+ curpos -= (__int64)(1.0 * dt / m_rtDuration * len);
+ m_pFile->Seek(curpos);
+
+ //pdt = dt;
+ }
+ }
+ }
+ }
+
+ if (minseekpos != _I64_MAX) {
+ seekpos = minseekpos;
+ } else {
+ // this file is probably screwed up, try plan B, seek simply by bitrate
+
+ rt -= rtPreroll;
+ seekpos = (__int64)(1.0 * rt / m_rtDuration * len);
+ m_pFile->Seek(seekpos);
+ m_rtStartOffset = m_pFile->m_rtMin + m_pFile->NextPTS(pMasterStream->GetHead()) - rt;
+ }
+
+ m_pFile->Seek(seekpos);
+ }
}
bool CMpegSplitterFilter::DemuxLoop()
{
- REFERENCE_TIME rtStartOffset = m_rtStartOffset ? m_rtStartOffset : m_pFile->m_rtMin;
+ REFERENCE_TIME rtStartOffset = m_rtStartOffset ? m_rtStartOffset : m_pFile->m_rtMin;
- HRESULT hr = S_OK;
- while (SUCCEEDED(hr) && !CheckRequest(NULL)) {
- if ((hr = m_pFile->HasMoreData(1024*500)) == S_OK)
- if ((hr = DemuxNextPacket(rtStartOffset)) == S_FALSE) {
- Sleep(1);
- }
- }
+ HRESULT hr = S_OK;
+ while (SUCCEEDED(hr) && !CheckRequest(NULL)) {
+ if ((hr = m_pFile->HasMoreData(1024 * 500)) == S_OK)
+ if ((hr = DemuxNextPacket(rtStartOffset)) == S_FALSE) {
+ Sleep(1);
+ }
+ }
- return true;
+ return true;
}
bool CMpegSplitterFilter::BuildPlaylist(LPCTSTR pszFileName, CAtlList<CHdmvClipInfo::PlaylistItem>& Items)
{
- m_rtPlaylistDuration = 0;
- return SUCCEEDED (m_ClipInfo.ReadPlaylist (pszFileName, m_rtPlaylistDuration, Items)) ? true : false;
+ m_rtPlaylistDuration = 0;
+ return SUCCEEDED(m_ClipInfo.ReadPlaylist(pszFileName, m_rtPlaylistDuration, Items)) ? true : false;
}
bool CMpegSplitterFilter::BuildChapters(LPCTSTR pszFileName, CAtlList<CHdmvClipInfo::PlaylistItem>& PlaylistItems, CAtlList<CHdmvClipInfo::PlaylistChapter>& Items)
{
- return SUCCEEDED (m_ClipInfo.ReadChapters (pszFileName, PlaylistItems, Items)) ? true : false;
+ return SUCCEEDED(m_ClipInfo.ReadChapters(pszFileName, PlaylistItems, Items)) ? true : false;
}
// IAMStreamSelect
STDMETHODIMP CMpegSplitterFilter::Count(DWORD* pcStreams)
{
- CheckPointer(pcStreams, E_POINTER);
+ CheckPointer(pcStreams, E_POINTER);
- *pcStreams = 0;
+ *pcStreams = 0;
- for (int i = 0; i < _countof(m_pFile->m_streams); i++) {
- (*pcStreams) += m_pFile->m_streams[i].GetCount();
- }
+ for (int i = 0; i < _countof(m_pFile->m_streams); i++) {
+ (*pcStreams) += m_pFile->m_streams[i].GetCount();
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CMpegSplitterFilter::Enable(long lIndex, DWORD dwFlags)
{
- if (!(dwFlags & AMSTREAMSELECTENABLE_ENABLE)) {
- return E_NOTIMPL;
- }
+ if (!(dwFlags & AMSTREAMSELECTENABLE_ENABLE)) {
+ return E_NOTIMPL;
+ }
- for (int i = 0, j = 0; i < _countof(m_pFile->m_streams); i++) {
- int cnt = m_pFile->m_streams[i].GetCount();
+ for (int i = 0, j = 0; i < _countof(m_pFile->m_streams); i++) {
+ int cnt = m_pFile->m_streams[i].GetCount();
- if (lIndex >= j && lIndex < j+cnt) {
- lIndex -= j;
+ if (lIndex >= j && lIndex < j + cnt) {
+ lIndex -= j;
- POSITION pos = m_pFile->m_streams[i].FindIndex(lIndex);
- if (!pos) {
- return E_UNEXPECTED;
- }
+ POSITION pos = m_pFile->m_streams[i].FindIndex(lIndex);
+ if (!pos) {
+ return E_UNEXPECTED;
+ }
- CMpegSplitterFile::stream& to = m_pFile->m_streams[i].GetAt(pos);
+ CMpegSplitterFile::stream& to = m_pFile->m_streams[i].GetAt(pos);
- pos = m_pFile->m_streams[i].GetHeadPosition();
- while (pos) {
- CMpegSplitterFile::stream& from = m_pFile->m_streams[i].GetNext(pos);
- if (!GetOutputPin(from)) {
- continue;
- }
+ pos = m_pFile->m_streams[i].GetHeadPosition();
+ while (pos) {
+ CMpegSplitterFile::stream& from = m_pFile->m_streams[i].GetNext(pos);
+ if (!GetOutputPin(from)) {
+ continue;
+ }
- if (m_useFastStreamChange) {
- PauseGraph;
- ResumeGraph;
- }
+ if (m_useFastStreamChange) {
+ PauseGraph;
+ ResumeGraph;
+ }
- HRESULT hr;
- if (FAILED(hr = RenameOutputPin(from, to, &to.mt))) {
- return hr;
- }
+ HRESULT hr;
+ if (FAILED(hr = RenameOutputPin(from, to, &to.mt))) {
+ return hr;
+ }
#if 0
- // Don't rename other pin for Hdmv!
- int iProgram;
- const CHdmvClipInfo::Stream *pClipInfo;
- const CMpegSplitterFile::program* p = m_pFile->FindProgram(to.pid, iProgram, pClipInfo);
-
- if (p!=NULL && !m_ClipInfo.IsHdmv() && !m_pFile->IsHdmv()) {
- for (int k = 0; k < _countof(m_pFile->m_streams); k++) {
- if (k == i) {
- continue;
- }
-
- pos = m_pFile->m_streams[k].GetHeadPosition();
- while (pos) {
- CMpegSplitterFile::stream& from = m_pFile->m_streams[k].GetNext(pos);
- if (!GetOutputPin(from)) {
- continue;
- }
-
- for (int l = 0; l < _countof(p->streams); l++) {
- if (const CMpegSplitterFile::stream* s = m_pFile->m_streams[k].FindStream(p->streams[l].pid)) {
- if (from != *s) {
- hr = RenameOutputPin(from, *s, &s->mt);
- }
- break;
- }
- }
- }
- }
- }
+ // Don't rename other pin for Hdmv!
+ int iProgram;
+ const CHdmvClipInfo::Stream* pClipInfo;
+ const CMpegSplitterFile::program* p = m_pFile->FindProgram(to.pid, iProgram, pClipInfo);
+
+ if (p != NULL && !m_ClipInfo.IsHdmv() && !m_pFile->IsHdmv()) {
+ for (int k = 0; k < _countof(m_pFile->m_streams); k++) {
+ if (k == i) {
+ continue;
+ }
+
+ pos = m_pFile->m_streams[k].GetHeadPosition();
+ while (pos) {
+ CMpegSplitterFile::stream& from = m_pFile->m_streams[k].GetNext(pos);
+ if (!GetOutputPin(from)) {
+ continue;
+ }
+
+ for (int l = 0; l < _countof(p->streams); l++) {
+ if (const CMpegSplitterFile::stream* s = m_pFile->m_streams[k].FindStream(p->streams[l].pid)) {
+ if (from != *s) {
+ hr = RenameOutputPin(from, *s, &s->mt);
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
#endif
- return S_OK;
- }
- }
+ return S_OK;
+ }
+ }
- j += cnt;
- }
+ j += cnt;
+ }
- return S_FALSE;
+ return S_FALSE;
}
-LONGLONG GetMediaTypeQuality(const CMediaType *_pMediaType, int _PresentationFormat)
+LONGLONG GetMediaTypeQuality(const CMediaType* _pMediaType, int _PresentationFormat)
{
- if (_pMediaType->formattype == FORMAT_WaveFormatEx) {
- __int64 Ret = 0;
-
- const WAVEFORMATEX *pInfo = GetFormatHelper(pInfo, _pMediaType);
- int TypePriority = 0;
-
- if (_pMediaType->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
- TypePriority = 12;
- } else if (_pMediaType->subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
- TypePriority = 12;
- } else {
- if (_PresentationFormat == AUDIO_STREAM_DTS_HD_MASTER_AUDIO) {
- TypePriority = 12;
- } else if (_PresentationFormat == AUDIO_STREAM_DTS_HD) {
- TypePriority = 11;
- } else if (_PresentationFormat == AUDIO_STREAM_AC3_TRUE_HD) {
- TypePriority = 12;
- } else if (_PresentationFormat == AUDIO_STREAM_AC3_PLUS) {
- TypePriority = 10;
- } else {
- switch (pInfo->wFormatTag) {
- case WAVE_FORMAT_PS2_PCM: {
- TypePriority = 12;
- }
- break;
- case WAVE_FORMAT_PS2_ADPCM: {
- TypePriority = 4;
- }
- break;
- case WAVE_FORMAT_DVD_DTS: {
- TypePriority = 9;
- }
- break;
- case WAVE_FORMAT_DOLBY_AC3: {
- TypePriority = 8;
- }
- break;
- case WAVE_FORMAT_AAC: {
- TypePriority = 7;
- }
- break;
- case WAVE_FORMAT_MP3: {
- TypePriority = 6;
- }
- break;
- case WAVE_FORMAT_MPEG: {
- TypePriority = 5;
- }
- break;
- }
- }
- }
-
- Ret += __int64(TypePriority) * 100000000i64 * 1000000000i64;
-
- Ret += __int64(pInfo->nChannels) * 1000000i64 * 1000000000i64;
- Ret += __int64(pInfo->nSamplesPerSec) * 10i64 * 1000000000i64;
- Ret += __int64(pInfo->wBitsPerSample) * 10000000i64;
- Ret += __int64(pInfo->nAvgBytesPerSec);
-
- return Ret;
- }
-
- return 0;
+ if (_pMediaType->formattype == FORMAT_WaveFormatEx) {
+ __int64 Ret = 0;
+
+ const WAVEFORMATEX* pInfo = GetFormatHelper(pInfo, _pMediaType);
+ int TypePriority = 0;
+
+ if (_pMediaType->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
+ TypePriority = 12;
+ } else if (_pMediaType->subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
+ TypePriority = 12;
+ } else {
+ if (_PresentationFormat == AUDIO_STREAM_DTS_HD_MASTER_AUDIO) {
+ TypePriority = 12;
+ } else if (_PresentationFormat == AUDIO_STREAM_DTS_HD) {
+ TypePriority = 11;
+ } else if (_PresentationFormat == AUDIO_STREAM_AC3_TRUE_HD) {
+ TypePriority = 12;
+ } else if (_PresentationFormat == AUDIO_STREAM_AC3_PLUS) {
+ TypePriority = 10;
+ } else {
+ switch (pInfo->wFormatTag) {
+ case WAVE_FORMAT_PS2_PCM: {
+ TypePriority = 12;
+ }
+ break;
+ case WAVE_FORMAT_PS2_ADPCM: {
+ TypePriority = 4;
+ }
+ break;
+ case WAVE_FORMAT_DVD_DTS: {
+ TypePriority = 9;
+ }
+ break;
+ case WAVE_FORMAT_DOLBY_AC3: {
+ TypePriority = 8;
+ }
+ break;
+ case WAVE_FORMAT_AAC: {
+ TypePriority = 7;
+ }
+ break;
+ case WAVE_FORMAT_MP3: {
+ TypePriority = 6;
+ }
+ break;
+ case WAVE_FORMAT_MPEG: {
+ TypePriority = 5;
+ }
+ break;
+ }
+ }
+ }
+
+ Ret += __int64(TypePriority) * 100000000i64 * 1000000000i64;
+
+ Ret += __int64(pInfo->nChannels) * 1000000i64 * 1000000000i64;
+ Ret += __int64(pInfo->nSamplesPerSec) * 10i64 * 1000000000i64;
+ Ret += __int64(pInfo->wBitsPerSample) * 10000000i64;
+ Ret += __int64(pInfo->nAvgBytesPerSec);
+
+ return Ret;
+ }
+
+ return 0;
}
-bool CMpegSplitterFile::stream::operator < (const stream &_Other) const
+bool CMpegSplitterFile::stream::operator < (const stream& _Other) const
{
- if (mt.majortype == MEDIATYPE_Audio && _Other.mt.majortype == MEDIATYPE_Audio) {
- int iProgram0;
- const CHdmvClipInfo::Stream *pClipInfo0;
- const CMpegSplitterFile::program * pProgram0 = m_pFile->FindProgram(pid, iProgram0, pClipInfo0);
- int StreamType0 = pClipInfo0 ? pClipInfo0->m_Type : pProgram0 ? pProgram0->streams[iProgram0].type : 0;
- int iProgram1;
- const CHdmvClipInfo::Stream *pClipInfo1;
- const CMpegSplitterFile::program * pProgram1 = m_pFile->FindProgram(_Other.pid, iProgram1, pClipInfo1);
- int StreamType1 = pClipInfo1 ? pClipInfo1->m_Type : pProgram1 ? pProgram1->streams[iProgram1].type : 0;
-
- if (mt.formattype == FORMAT_WaveFormatEx && _Other.mt.formattype != FORMAT_WaveFormatEx) {
- return true;
- }
- if (mt.formattype != FORMAT_WaveFormatEx && _Other.mt.formattype == FORMAT_WaveFormatEx) {
- return false;
- }
-
- LONGLONG Quality0 = GetMediaTypeQuality(&mt, StreamType0);
- LONGLONG Quality1 = GetMediaTypeQuality(&_Other.mt, StreamType1);
- if (Quality0 > Quality1) {
- return true;
- }
- if (Quality0 < Quality1) {
- return false;
- }
- }
- DWORD DefaultFirst = *this;
- DWORD DefaultSecond = _Other;
- return DefaultFirst < DefaultSecond;
+ if (mt.majortype == MEDIATYPE_Audio && _Other.mt.majortype == MEDIATYPE_Audio) {
+ int iProgram0;
+ const CHdmvClipInfo::Stream* pClipInfo0;
+ const CMpegSplitterFile::program* pProgram0 = m_pFile->FindProgram(pid, iProgram0, pClipInfo0);
+ int StreamType0 = pClipInfo0 ? pClipInfo0->m_Type : pProgram0 ? pProgram0->streams[iProgram0].type : 0;
+ int iProgram1;
+ const CHdmvClipInfo::Stream* pClipInfo1;
+ const CMpegSplitterFile::program* pProgram1 = m_pFile->FindProgram(_Other.pid, iProgram1, pClipInfo1);
+ int StreamType1 = pClipInfo1 ? pClipInfo1->m_Type : pProgram1 ? pProgram1->streams[iProgram1].type : 0;
+
+ if (mt.formattype == FORMAT_WaveFormatEx && _Other.mt.formattype != FORMAT_WaveFormatEx) {
+ return true;
+ }
+ if (mt.formattype != FORMAT_WaveFormatEx && _Other.mt.formattype == FORMAT_WaveFormatEx) {
+ return false;
+ }
+
+ LONGLONG Quality0 = GetMediaTypeQuality(&mt, StreamType0);
+ LONGLONG Quality1 = GetMediaTypeQuality(&_Other.mt, StreamType1);
+ if (Quality0 > Quality1) {
+ return true;
+ }
+ if (Quality0 < Quality1) {
+ return false;
+ }
+ }
+ DWORD DefaultFirst = *this;
+ DWORD DefaultSecond = _Other;
+ return DefaultFirst < DefaultSecond;
}
STDMETHODIMP CMpegSplitterFilter::Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* pdwFlags, LCID* plcid, DWORD* pdwGroup, WCHAR** ppszName, IUnknown** ppObject, IUnknown** ppUnk)
{
- for (int i = 0, j = 0; i < _countof(m_pFile->m_streams); i++) {
- int cnt = m_pFile->m_streams[i].GetCount();
-
- if (lIndex >= j && lIndex < j+cnt) {
- lIndex -= j;
-
- POSITION pos = m_pFile->m_streams[i].FindIndex(lIndex);
- if (!pos) {
- return E_UNEXPECTED;
- }
-
- CMpegSplitterFile::stream& s = m_pFile->m_streams[i].GetAt(pos);
- CHdmvClipInfo::Stream* pStream = m_ClipInfo.FindStream (s.pid);
-
- if (ppmt) {
- *ppmt = CreateMediaType(&s.mt);
- }
- if (pdwFlags) {
- *pdwFlags = GetOutputPin(s) ? (AMSTREAMSELECTINFO_ENABLED|AMSTREAMSELECTINFO_EXCLUSIVE) : 0;
- }
- if (plcid) {
- *plcid = pStream ? pStream->m_LCID : 0;
- }
- if (pdwGroup) {
- *pdwGroup = i;
- }
- if (ppObject) {
- *ppObject = NULL;
- }
- if (ppUnk) {
- *ppUnk = NULL;
- }
-
- if (ppszName) {
- CStringW name = CMpegSplitterFile::CStreamList::ToString(i);
-
- CStringW str;
-
- if (i == CMpegSplitterFile::subpic && s.pid == NO_SUBTITLE_PID) {
- str = NO_SUBTITLE_NAME;
- if (plcid) {
- *plcid = (LCID)LCID_NOSUBTITLES;
- }
- } else {
- int iProgram;
- const CHdmvClipInfo::Stream *pClipInfo;
- const CMpegSplitterFile::program * pProgram = m_pFile->FindProgram(s.pid, iProgram, pClipInfo);
- const wchar_t *pStreamName = NULL;
- int StreamType = pClipInfo ? pClipInfo->m_Type : pProgram ? pProgram->streams[iProgram].type : 0;
- pStreamName = StreamTypeToName((PES_STREAM_TYPE)StreamType);
-
- CString lang_name = _T("");
- m_pFile->m_pPMT_Lang.Lookup(s.pid, lang_name);
-
- lang_name = pTI ? pTI->GetTrackName(s.ps1id) : lang_name;
-
- CString FormatDesc = GetMediaTypeDesc(&s.mt, pClipInfo, StreamType, lang_name);
-
- if (!FormatDesc.IsEmpty()) {
- str.Format(L"%s (%04x,%02x,%02x)", FormatDesc.GetString(), s.pid, s.pesid, s.ps1id); // TODO: make this nicer
- } else if (pStreamName) {
- str.Format(L"%s - %s (%04x,%02x,%02x)", name, pStreamName, s.pid, s.pesid, s.ps1id); // TODO: make this nicer
- } else {
- str.Format(L"%s (%04x,%02x,%02x)", name, s.pid, s.pesid, s.ps1id); // TODO: make this nicer
- }
- }
-
- *ppszName = (WCHAR*)CoTaskMemAlloc((str.GetLength()+1)*sizeof(WCHAR));
- if (*ppszName == NULL) {
- return E_OUTOFMEMORY;
- }
-
- wcscpy_s(*ppszName, str.GetLength()+1, str);
- }
- }
-
- j += cnt;
- }
-
- return S_OK;
+ for (int i = 0, j = 0; i < _countof(m_pFile->m_streams); i++) {
+ int cnt = m_pFile->m_streams[i].GetCount();
+
+ if (lIndex >= j && lIndex < j + cnt) {
+ lIndex -= j;
+
+ POSITION pos = m_pFile->m_streams[i].FindIndex(lIndex);
+ if (!pos) {
+ return E_UNEXPECTED;
+ }
+
+ CMpegSplitterFile::stream& s = m_pFile->m_streams[i].GetAt(pos);
+ CHdmvClipInfo::Stream* pStream = m_ClipInfo.FindStream(s.pid);
+
+ if (ppmt) {
+ *ppmt = CreateMediaType(&s.mt);
+ }
+ if (pdwFlags) {
+ *pdwFlags = GetOutputPin(s) ? (AMSTREAMSELECTINFO_ENABLED | AMSTREAMSELECTINFO_EXCLUSIVE) : 0;
+ }
+ if (plcid) {
+ *plcid = pStream ? pStream->m_LCID : 0;
+ }
+ if (pdwGroup) {
+ *pdwGroup = i;
+ }
+ if (ppObject) {
+ *ppObject = NULL;
+ }
+ if (ppUnk) {
+ *ppUnk = NULL;
+ }
+
+ if (ppszName) {
+ CStringW name = CMpegSplitterFile::CStreamList::ToString(i);
+
+ CStringW str;
+
+ if (i == CMpegSplitterFile::subpic && s.pid == NO_SUBTITLE_PID) {
+ str = NO_SUBTITLE_NAME;
+ if (plcid) {
+ *plcid = (LCID)LCID_NOSUBTITLES;
+ }
+ } else {
+ int iProgram;
+ const CHdmvClipInfo::Stream* pClipInfo;
+ const CMpegSplitterFile::program* pProgram = m_pFile->FindProgram(s.pid, iProgram, pClipInfo);
+ const wchar_t* pStreamName = NULL;
+ int StreamType = pClipInfo ? pClipInfo->m_Type : pProgram ? pProgram->streams[iProgram].type : 0;
+ pStreamName = StreamTypeToName((PES_STREAM_TYPE)StreamType);
+
+ CString lang_name = _T("");
+ m_pFile->m_pPMT_Lang.Lookup(s.pid, lang_name);
+
+ lang_name = pTI ? pTI->GetTrackName(s.ps1id) : lang_name;
+
+ CString FormatDesc = GetMediaTypeDesc(&s.mt, pClipInfo, StreamType, lang_name);
+
+ if (!FormatDesc.IsEmpty()) {
+ str.Format(L"%s (%04x,%02x,%02x)", FormatDesc.GetString(), s.pid, s.pesid, s.ps1id); // TODO: make this nicer
+ } else if (pStreamName) {
+ str.Format(L"%s - %s (%04x,%02x,%02x)", name, pStreamName, s.pid, s.pesid, s.ps1id); // TODO: make this nicer
+ } else {
+ str.Format(L"%s (%04x,%02x,%02x)", name, s.pid, s.pesid, s.ps1id); // TODO: make this nicer
+ }
+ }
+
+ *ppszName = (WCHAR*)CoTaskMemAlloc((str.GetLength() + 1) * sizeof(WCHAR));
+ if (*ppszName == NULL) {
+ return E_OUTOFMEMORY;
+ }
+
+ wcscpy_s(*ppszName, str.GetLength() + 1, str);
+ }
+ }
+
+ j += cnt;
+ }
+
+ return S_OK;
}
// ISpecifyPropertyPages2
STDMETHODIMP CMpegSplitterFilter::GetPages(CAUUID* pPages)
{
- CheckPointer(pPages, E_POINTER);
+ CheckPointer(pPages, E_POINTER);
- pPages->cElems = 1;
- pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID) * pPages->cElems);
- pPages->pElems[0] = __uuidof(CMpegSplitterSettingsWnd);
+ pPages->cElems = 1;
+ pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID) * pPages->cElems);
+ pPages->pElems[0] = __uuidof(CMpegSplitterSettingsWnd);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CMpegSplitterFilter::CreatePage(const GUID& guid, IPropertyPage** ppPage)
{
- CheckPointer(ppPage, E_POINTER);
+ CheckPointer(ppPage, E_POINTER);
- if (*ppPage != NULL) {
- return E_INVALIDARG;
- }
+ if (*ppPage != NULL) {
+ return E_INVALIDARG;
+ }
- HRESULT hr;
+ HRESULT hr;
- if (guid == __uuidof(CMpegSplitterSettingsWnd)) {
- (*ppPage = DNew CInternalPropertyPageTempl<CMpegSplitterSettingsWnd>(NULL, &hr))->AddRef();
- }
+ if (guid == __uuidof(CMpegSplitterSettingsWnd)) {
+ (*ppPage = DNew CInternalPropertyPageTempl<CMpegSplitterSettingsWnd>(NULL, &hr))->AddRef();
+ }
- return *ppPage ? S_OK : E_FAIL;
+ return *ppPage ? S_OK : E_FAIL;
}
// IMpegSplitterFilter
STDMETHODIMP CMpegSplitterFilter::Apply()
{
#ifdef REGISTER_FILTER
- CRegKey key;
- if (ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Splitter"))) {
- key.SetDWORDValue(_T("UseFastStreamChange"), m_useFastStreamChange);
- key.SetDWORDValue(_T("ForcedSub"), m_ForcedSub);
- key.SetDWORDValue(_T("TrackPriority"), m_TrackPriority);
- key.SetStringValue(_T("AudioLanguageOrder"), m_csAudioLanguageOrder);
- key.SetStringValue(_T("SubtitlesLanguageOrder"), m_csSubtitlesLanguageOrder);
- key.SetDWORDValue(_T("VC1_Decoder_Output"), m_nVC1_GuidFlag);
- key.SetDWORDValue(_T("AC3CoreOnly"), m_AC3CoreOnly);
- key.SetDWORDValue(_T("AlternativeDuration"), m_AlternativeDuration);
- }
+ CRegKey key;
+ if (ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Splitter"))) {
+ key.SetDWORDValue(_T("UseFastStreamChange"), m_useFastStreamChange);
+ key.SetDWORDValue(_T("ForcedSub"), m_ForcedSub);
+ key.SetDWORDValue(_T("TrackPriority"), m_TrackPriority);
+ key.SetStringValue(_T("AudioLanguageOrder"), m_csAudioLanguageOrder);
+ key.SetStringValue(_T("SubtitlesLanguageOrder"), m_csSubtitlesLanguageOrder);
+ key.SetDWORDValue(_T("VC1_Decoder_Output"), m_nVC1_GuidFlag);
+ key.SetDWORDValue(_T("AC3CoreOnly"), m_AC3CoreOnly);
+ key.SetDWORDValue(_T("AlternativeDuration"), m_AlternativeDuration);
+ }
#else
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Splitter"), _T("UseFastStreamChange"), m_useFastStreamChange);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Splitter"), _T("ForcedSub"), m_ForcedSub);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Splitter"), _T("TrackPriority"), m_TrackPriority);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Splitter"), _T("VC1_Decoder_Output"), m_nVC1_GuidFlag);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Splitter"), _T("AC3CoreOnly"), m_AC3CoreOnly);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Splitter"), _T("AlternativeDuration"), m_AlternativeDuration);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Splitter"), _T("UseFastStreamChange"), m_useFastStreamChange);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Splitter"), _T("ForcedSub"), m_ForcedSub);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Splitter"), _T("TrackPriority"), m_TrackPriority);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Splitter"), _T("VC1_Decoder_Output"), m_nVC1_GuidFlag);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Splitter"), _T("AC3CoreOnly"), m_AC3CoreOnly);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Splitter"), _T("AlternativeDuration"), m_AlternativeDuration);
#endif
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CMpegSplitterFilter::SetFastStreamChange(BOOL nValue)
{
- CAutoLock cAutoLock(&m_csProps);
- m_useFastStreamChange = !!nValue;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_useFastStreamChange = !!nValue;
+ return S_OK;
}
STDMETHODIMP_(BOOL) CMpegSplitterFilter::GetFastStreamChange()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_useFastStreamChange;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_useFastStreamChange;
}
STDMETHODIMP CMpegSplitterFilter::SetForcedSub(BOOL nValue)
{
- CAutoLock cAutoLock(&m_csProps);
- m_ForcedSub = !!nValue;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_ForcedSub = !!nValue;
+ return S_OK;
}
STDMETHODIMP_(BOOL) CMpegSplitterFilter::GetForcedSub()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_ForcedSub;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_ForcedSub;
}
STDMETHODIMP CMpegSplitterFilter::SetTrackPriority(BOOL nValue)
{
- CAutoLock cAutoLock(&m_csProps);
- m_TrackPriority = !!nValue;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_TrackPriority = !!nValue;
+ return S_OK;
}
STDMETHODIMP_(BOOL) CMpegSplitterFilter::GetTrackPriority()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_TrackPriority;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_TrackPriority;
}
-STDMETHODIMP CMpegSplitterFilter::SetAudioLanguageOrder(WCHAR *nValue)
+STDMETHODIMP CMpegSplitterFilter::SetAudioLanguageOrder(WCHAR* nValue)
{
- CAutoLock cAutoLock(&m_csProps);
- m_csAudioLanguageOrder = nValue;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_csAudioLanguageOrder = nValue;
+ return S_OK;
}
-STDMETHODIMP_(WCHAR *) CMpegSplitterFilter::GetAudioLanguageOrder()
+STDMETHODIMP_(WCHAR*) CMpegSplitterFilter::GetAudioLanguageOrder()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_csAudioLanguageOrder.GetBuffer();
+ CAutoLock cAutoLock(&m_csProps);
+ return m_csAudioLanguageOrder.GetBuffer();
}
-STDMETHODIMP CMpegSplitterFilter::SetSubtitlesLanguageOrder(WCHAR *nValue)
+STDMETHODIMP CMpegSplitterFilter::SetSubtitlesLanguageOrder(WCHAR* nValue)
{
- CAutoLock cAutoLock(&m_csProps);
- m_csSubtitlesLanguageOrder = nValue;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_csSubtitlesLanguageOrder = nValue;
+ return S_OK;
}
-STDMETHODIMP_(WCHAR *) CMpegSplitterFilter::GetSubtitlesLanguageOrder()
+STDMETHODIMP_(WCHAR*) CMpegSplitterFilter::GetSubtitlesLanguageOrder()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_csSubtitlesLanguageOrder.GetBuffer();
+ CAutoLock cAutoLock(&m_csProps);
+ return m_csSubtitlesLanguageOrder.GetBuffer();
}
STDMETHODIMP CMpegSplitterFilter::SetVC1_GuidFlag(int nValue)
{
- CAutoLock cAutoLock(&m_csProps);
- m_nVC1_GuidFlag = nValue;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_nVC1_GuidFlag = nValue;
+ return S_OK;
}
STDMETHODIMP_(int) CMpegSplitterFilter::GetVC1_GuidFlag()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_nVC1_GuidFlag;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_nVC1_GuidFlag;
}
STDMETHODIMP CMpegSplitterFilter::SetTrueHD(int nValue)
{
- CAutoLock cAutoLock(&m_csProps);
- m_AC3CoreOnly = nValue;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_AC3CoreOnly = nValue;
+ return S_OK;
}
STDMETHODIMP_(int) CMpegSplitterFilter::GetTrueHD()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_AC3CoreOnly;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_AC3CoreOnly;
}
STDMETHODIMP CMpegSplitterFilter::SetAlternativeDuration(BOOL nValue)
{
- CAutoLock cAutoLock(&m_csProps);
- m_AlternativeDuration = !!nValue;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_AlternativeDuration = !!nValue;
+ return S_OK;
}
STDMETHODIMP_(BOOL) CMpegSplitterFilter::GetAlternativeDuration()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_AlternativeDuration;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_AlternativeDuration;
}
STDMETHODIMP_(int) CMpegSplitterFilter::GetMPEGType()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_pFile->m_type;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_pFile->m_type;
}
//
// CMpegSourceFilter
//
CMpegSourceFilter::CMpegSourceFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLSID& clsid)
- : CMpegSplitterFilter(pUnk, phr, clsid)
+ : CMpegSplitterFilter(pUnk, phr, clsid)
{
- m_pInput.Free();
+ m_pInput.Free();
}
//
@@ -1587,13 +1583,13 @@ CMpegSourceFilter::CMpegSourceFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLSID&
//
CMpegSplitterOutputPin::CMpegSplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr, int type)
- : CBaseSplitterOutputPin(mts, pName, pFilter, pLock, phr)
- , m_fHasAccessUnitDelimiters(false)
- , m_rtMaxShift(50000000)
- , m_bFilterDTSMA(false)
- , m_type(type)
- , DD_reset(false)
- , m_bFlushed(false)
+ : CBaseSplitterOutputPin(mts, pName, pFilter, pLock, phr)
+ , m_fHasAccessUnitDelimiters(false)
+ , m_rtMaxShift(50000000)
+ , m_bFilterDTSMA(false)
+ , m_type(type)
+ , DD_reset(false)
+ , m_bFlushed(false)
{
}
@@ -1603,522 +1599,522 @@ CMpegSplitterOutputPin::~CMpegSplitterOutputPin()
HRESULT CMpegSplitterOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- {
- CAutoLock cAutoLock(this);
+ {
+ CAutoLock cAutoLock(this);
- m_rtPrev = Packet::INVALID_TIME;
- m_rtOffset = 0;
- }
+ m_rtPrev = Packet::INVALID_TIME;
+ m_rtOffset = 0;
+ }
- return __super::DeliverNewSegment(tStart, tStop, dRate);
+ return __super::DeliverNewSegment(tStart, tStop, dRate);
}
HRESULT CMpegSplitterOutputPin::DeliverEndFlush()
{
- {
- CAutoLock cAutoLock(this);
+ {
+ CAutoLock cAutoLock(this);
- m_p.Free();
- m_pl.RemoveAll();
- DD_reset = true;
- m_bFlushed = true;
- }
+ m_p.Free();
+ m_pl.RemoveAll();
+ DD_reset = true;
+ m_bFlushed = true;
+ }
- return __super::DeliverEndFlush();
+ return __super::DeliverEndFlush();
}
#define MOVE_TO_H264_START_CODE(b, e) while (b <= e-4 && !((*(DWORD *)b == 0x01000000) || ((*(DWORD *)b & 0x00FFFFFF) == 0x00010000))) b++; if ((b <= e-4) && *(DWORD *)b == 0x01000000) b++;
HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
{
- CAutoLock cAutoLock(this);
-
- if (p->rtStart != Packet::INVALID_TIME) {
- REFERENCE_TIME rt = p->rtStart + m_rtOffset;
-
- // Filter invalid PTS (if too different from previous packet)
- if (m_rtPrev != Packet::INVALID_TIME)
- if (_abs64(rt - m_rtPrev) > m_rtMaxShift) {
- m_rtOffset += m_rtPrev - rt;
- }
-
- p->rtStart += m_rtOffset;
- p->rtStop += m_rtOffset;
-
- m_rtPrev = p->rtStart;
- }
-
- if (p->pmt) {
- if (*((CMediaType *)p->pmt) != m_mt) {
- SetMediaType ((CMediaType*)p->pmt);
- }
- }
-
- if (m_mt.subtype == MEDIASUBTYPE_AAC) { // special code for aac, the currently available decoders only like whole frame samples
- if (m_p && m_p->GetCount() == 1 && m_p->GetAt(0) == 0xff && !(!p->IsEmpty() && (p->GetAt(0) & 0xf6) == 0xf0)) {
- m_p.Free();
- }
-
- if (!m_p) {
- BYTE* base = p->GetData();
- BYTE* s = base;
- BYTE* e = s + p->GetCount();
-
- for (; s < e; s++) {
- if (*s != 0xff) {
- continue;
- }
-
- if (s == e-1 || (s[1]&0xf6) == 0xf0) {
- memmove(base, s, e - s);
- p->SetCount(e - s);
- m_p = p;
- break;
- }
- }
- } else {
- m_p->Append(*p);
- }
-
- while (m_p && m_p->GetCount() > 9) {
- BYTE* base = m_p->GetData();
- BYTE* s = base;
- BYTE* e = s + m_p->GetCount();
- int len = ((s[3]&3)<<11)|(s[4]<<3)|(s[5]>>5);
- bool crc = !(s[1]&1);
- s += 7;
- len -= 7;
- if (crc) {
- s += 2, len -= 2;
- }
-
- if (e - s < len) {
- break;
- }
-
- if (len <= 0 || e - s >= len + 2 && (s[len] != 0xff || (s[len+1]&0xf6) != 0xf0)) {
- m_p.Free();
- break;
- }
-
- CAutoPtr<Packet> p2(DNew Packet());
-
- p2->TrackNumber = m_p->TrackNumber;
- p2->bDiscontinuity |= m_p->bDiscontinuity;
- m_p->bDiscontinuity = false;
-
- p2->bSyncPoint = m_p->rtStart != Packet::INVALID_TIME;
- p2->rtStart = m_p->rtStart;
- m_p->rtStart = Packet::INVALID_TIME;
-
- p2->rtStop = m_p->rtStop;
- m_p->rtStop = Packet::INVALID_TIME;
- p2->pmt = m_p->pmt;
- m_p->pmt = NULL;
- p2->SetData(s, len);
-
- s += len;
- memmove(base, s, e - s);
- m_p->SetCount(e - s);
-
- HRESULT hr = __super::DeliverPacket(p2);
- if (hr != S_OK) {
- return hr;
- }
- }
-
- if (m_p && p) {
- if (!m_p->bDiscontinuity) {
- m_p->bDiscontinuity = p->bDiscontinuity;
- }
- if (!m_p->bSyncPoint) {
- m_p->bSyncPoint = p->bSyncPoint;
- }
- if (m_p->rtStart == Packet::INVALID_TIME) {
- m_p->rtStart = p->rtStart, m_p->rtStop = p->rtStop;
- }
- if (m_p->pmt) {
- DeleteMediaType(m_p->pmt);
- }
-
- m_p->pmt = p->pmt;
- p->pmt = NULL;
- }
-
- return S_OK;
- } else if (m_mt.subtype == FOURCCMap('1CVA') || m_mt.subtype == FOURCCMap('1cva') || m_mt.subtype == FOURCCMap('CVMA') || m_mt.subtype == FOURCCMap('CVME')) {
- if (!m_p) {
- m_p.Attach(DNew Packet());
- m_p->TrackNumber = p->TrackNumber;
- m_p->bDiscontinuity = p->bDiscontinuity;
- p->bDiscontinuity = FALSE;
-
- m_p->bSyncPoint = p->bSyncPoint;
- p->bSyncPoint = FALSE;
-
- m_p->rtStart = p->rtStart;
- p->rtStart = Packet::INVALID_TIME;
-
- m_p->rtStop = p->rtStop;
- p->rtStop = Packet::INVALID_TIME;
- }
-
- m_p->Append(*p);
-
- BYTE* start = m_p->GetData();
- BYTE* end = start + m_p->GetCount();
-
- MOVE_TO_H264_START_CODE(start, end);
-
- while (start <= end-4) {
- BYTE* next = start+1;
-
- MOVE_TO_H264_START_CODE(next, end);
-
- if (next >= end-4) {
- break;
- }
-
- int size = next - start;
-
- CH264Nalu Nalu;
- Nalu.SetBuffer (start, size, 0);
-
- CAutoPtr<Packet> p2;
-
- while (Nalu.ReadNext()) {
- DWORD dwNalLength =
- ((Nalu.GetDataLength() >> 24) & 0x000000ff) |
- ((Nalu.GetDataLength() >> 8) & 0x0000ff00) |
- ((Nalu.GetDataLength() << 8) & 0x00ff0000) |
- ((Nalu.GetDataLength() << 24) & 0xff000000);
-
- CAutoPtr<Packet> p3(DNew Packet());
-
- p3->SetCount (Nalu.GetDataLength()+sizeof(dwNalLength));
- memcpy (p3->GetData(), &dwNalLength, sizeof(dwNalLength));
- memcpy (p3->GetData()+sizeof(dwNalLength), Nalu.GetDataBuffer(), Nalu.GetDataLength());
-
- if (p2 == NULL) {
- p2 = p3;
- } else {
- p2->Append(*p3);
- }
- }
- start = next;
-
- if (!p2) {
- continue;
- }
-
- p2->TrackNumber = m_p->TrackNumber;
- p2->bDiscontinuity = m_p->bDiscontinuity;
- m_p->bDiscontinuity = FALSE;
-
- p2->bSyncPoint = m_p->bSyncPoint;
- m_p->bSyncPoint = FALSE;
-
- p2->rtStart = m_p->rtStart;
- m_p->rtStart = Packet::INVALID_TIME;
- p2->rtStop = m_p->rtStop;
- m_p->rtStop = Packet::INVALID_TIME;
-
- p2->pmt = m_p->pmt;
- m_p->pmt = NULL;
-
- m_pl.AddTail(p2);
-
- if (p->rtStart != Packet::INVALID_TIME) {
- m_p->rtStart = p->rtStart;
- m_p->rtStop = p->rtStop;
- p->rtStart = Packet::INVALID_TIME;
- }
- if (p->bDiscontinuity) {
- m_p->bDiscontinuity = p->bDiscontinuity;
- p->bDiscontinuity = FALSE;
- }
- if (p->bSyncPoint) {
- m_p->bSyncPoint = p->bSyncPoint;
- p->bSyncPoint = FALSE;
- }
- if (m_p->pmt) {
- DeleteMediaType(m_p->pmt);
- }
-
- m_p->pmt = p->pmt;
- p->pmt = NULL;
- }
- if (start > m_p->GetData()) {
- m_p->RemoveAt(0, start - m_p->GetData());
- }
-
- REFERENCE_TIME rtStart = Packet::INVALID_TIME, rtStop = Packet::INVALID_TIME;
-
- for (POSITION pos = m_pl.GetHeadPosition(); pos; m_pl.GetNext(pos)) {
- if (pos == m_pl.GetHeadPosition()) {
- continue;
- }
-
- Packet* pPacket = m_pl.GetAt(pos);
- BYTE* pData = pPacket->GetData();
-
- if ((pData[4]&0x1f) == 0x09) {
- m_fHasAccessUnitDelimiters = true;
- }
-
- if ((pData[4]&0x1f) == 0x09 || (!m_fHasAccessUnitDelimiters && pPacket->rtStart != Packet::INVALID_TIME)) {
- if (pPacket->rtStart == Packet::INVALID_TIME && rtStart != Packet::INVALID_TIME) {
- pPacket->rtStart = rtStart;
- pPacket->rtStop = rtStop;
- }
-
- p = m_pl.RemoveHead();
-
- while (pos != m_pl.GetHeadPosition()) {
- CAutoPtr<Packet> p2 = m_pl.RemoveHead();
- p->Append(*p2);
- }
-
- HRESULT hr = __super::DeliverPacket(p);
- if (hr != S_OK) {
- return hr;
- }
- } else if (rtStart == Packet::INVALID_TIME) {
- rtStart = pPacket->rtStart;
- rtStop = pPacket->rtStop;
- }
- }
-
- return S_OK;
- } else if (m_mt.subtype == FOURCCMap('1CVW') || m_mt.subtype == FOURCCMap('1cvw') ||
- m_mt.subtype == MEDIASUBTYPE_WVC1_CYBERLINK || m_mt.subtype == MEDIASUBTYPE_WVC1_ARCSOFT) { // just like aac, this has to be starting nalus, more can be packed together
- if (!m_p) {
- m_p.Attach(DNew Packet());
- m_p->TrackNumber = p->TrackNumber;
- m_p->bDiscontinuity = p->bDiscontinuity;
- p->bDiscontinuity = FALSE;
-
- m_p->bSyncPoint = p->bSyncPoint;
- p->bSyncPoint = FALSE;
-
- m_p->rtStart = p->rtStart;
- p->rtStart = Packet::INVALID_TIME;
-
- m_p->rtStop = p->rtStop;
- p->rtStop = Packet::INVALID_TIME;
- }
-
- m_p->Append(*p);
-
- BYTE* start = m_p->GetData();
- BYTE* end = start + m_p->GetCount();
-
- bool bSeqFound = false;
- while (start <= end-4) {
- if (*(DWORD*)start == 0x0D010000) {
- bSeqFound = true;
- break;
- } else if (*(DWORD*)start == 0x0F010000) {
- break;
- }
- start++;
- }
-
- while (start <= end-4) {
- BYTE* next = start+1;
-
- while (next <= end-4) {
- if (*(DWORD*)next == 0x0D010000) {
- if (bSeqFound) {
- break;
- }
- bSeqFound = true;
- } else if (*(DWORD*)next == 0x0F010000) {
- break;
- }
- next++;
- }
-
- if (next >= end-4) {
- break;
- }
-
- int size = next - start - 4;
- UNREFERENCED_PARAMETER(size);
-
- CAutoPtr<Packet> p2(DNew Packet());
- p2->TrackNumber = m_p->TrackNumber;
- p2->bDiscontinuity = m_p->bDiscontinuity;
- m_p->bDiscontinuity = FALSE;
-
- p2->bSyncPoint = m_p->bSyncPoint;
- m_p->bSyncPoint = FALSE;
-
- p2->rtStart = m_p->rtStart;
- m_p->rtStart = Packet::INVALID_TIME;
-
- p2->rtStop = m_p->rtStop;
- m_p->rtStop = Packet::INVALID_TIME;
-
- p2->pmt = m_p->pmt;
- m_p->pmt = NULL;
-
- p2->SetData(start, next - start);
-
- HRESULT hr = __super::DeliverPacket(p2);
- if (hr != S_OK) {
- return hr;
- }
-
- if (p->rtStart != Packet::INVALID_TIME) {
- m_p->rtStart = p->rtStop; //p->rtStart; //Sebastiii for enable VC1 decoding in FFDshow (no more shutter)
- m_p->rtStop = p->rtStop;
- p->rtStart = Packet::INVALID_TIME;
- }
- if (p->bDiscontinuity) {
- m_p->bDiscontinuity = p->bDiscontinuity;
- p->bDiscontinuity = FALSE;
- }
- if (p->bSyncPoint) {
- m_p->bSyncPoint = p->bSyncPoint;
- p->bSyncPoint = FALSE;
- }
- if (m_p->pmt) {
- DeleteMediaType(m_p->pmt);
- }
-
- m_p->pmt = p->pmt;
- p->pmt = NULL;
-
- start = next;
- bSeqFound = (*(DWORD*)start == 0x0D010000);
- }
-
- if (start > m_p->GetData()) {
- m_p->RemoveAt(0, start - m_p->GetData());
- }
-
- return S_OK;
- }
- // DTS HD MA data is causing trouble with some filters, lets just remove it
- else if (m_bFilterDTSMA && ((m_mt.subtype == MEDIASUBTYPE_DTS || m_mt.subtype == MEDIASUBTYPE_WAVE_DTS))) {
- if (p->GetCount() < 4 && !p->pmt) {
- return S_OK; // Should be invalid packet
- }
- BYTE* hdr = p->GetData();
-
- int Type;
- // 16 bits big endian bitstream
- if (hdr[0] == 0x7f && hdr[1] == 0xfe &&
- hdr[2] == 0x80 && hdr[3] == 0x01) {
- Type = 16 + 32;
- }
-
- // 16 bits low endian bitstream
- else if (hdr[0] == 0xfe && hdr[1] == 0x7f &&
- hdr[2] == 0x01 && hdr[3] == 0x80) {
- Type = 16;
- }
-
- // 14 bits big endian bitstream
- else if (hdr[0] == 0x1f && hdr[1] == 0xff &&
- hdr[2] == 0xe8 && hdr[3] == 0x00 &&
- hdr[4] == 0x07 && (hdr[5] & 0xf0) == 0xf0) {
- Type = 14 + 32;
- }
-
- // 14 bits low endian bitstream
- else if (hdr[0] == 0xff && hdr[1] == 0x1f &&
- hdr[2] == 0x00 && hdr[3] == 0xe8 &&
- (hdr[4] & 0xf0) == 0xf0 && hdr[5] == 0x07) {
- Type = 14;
- }
-
- // no sync
- else if (!p->pmt) {
- return S_OK;
- }
- // HDMV LPCM
- } else if (m_mt.subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
- if (!m_p) {
- m_p.Attach(DNew Packet());
- }
- m_p->Append(*p);
-
- if (m_p->GetCount() < 4) {
- m_p.Free();
- return S_OK; // Should be invalid packet
- }
-
- BYTE* start = m_p->GetData();
- int samplerate, channels;
- size_t header_size = ParseHdmvLPCMHeader(start, &samplerate, &channels);
- if (!header_size || header_size > m_p->GetCount()) {
- if (!header_size) {
- m_p.Free();
- }
- return S_OK;
- }
-
- if (!p->pmt && m_bFlushed) {
- p->pmt = CreateMediaType(&m_mt);
- m_bFlushed = false;
- }
- p->SetData(start + 4, m_p->GetCount() - 4);
- m_p.Free();
- // Dolby_AC3
- } else if ((m_type == mpeg_ts) &&
- (m_mt.subtype == MEDIASUBTYPE_DOLBY_AC3) &&
- (static_cast<CMpegSplitterFilter*>(m_pFilter))->StreamIsTrueHD(p->TrackNumber) &&
- (static_cast<CMpegSplitterFilter*>(m_pFilter))->GetTrueHD() != 2) {
- if (p->GetCount() < 8) {
- return S_OK; // Should be invalid packet
- }
- BYTE* start = p->GetData();
- if (*(WORD*)start != 0x770b) { // skip none AC3
- return S_OK;
- }
- // TrueHD
- } else if (m_mt.subtype == MEDIASUBTYPE_DOLBY_TRUEHD && (static_cast<CMpegSplitterFilter*>(m_pFilter))->GetTrueHD() != 2) {
- if (p->GetCount() < 8) {
- return S_OK; // Should be invalid packet
- }
- BYTE* start = p->GetData();
- if (*(WORD*)start == 0x770b) { // skip AC3
- return S_OK;
- }
- if (DD_reset || p->rtStart == 0) {
- p->bDiscontinuity = true;
- DD_reset = false;
- }
- } else {
- m_p.Free();
- m_pl.RemoveAll();
- }
-
- return __super::DeliverPacket(p);
+ CAutoLock cAutoLock(this);
+
+ if (p->rtStart != Packet::INVALID_TIME) {
+ REFERENCE_TIME rt = p->rtStart + m_rtOffset;
+
+ // Filter invalid PTS (if too different from previous packet)
+ if (m_rtPrev != Packet::INVALID_TIME)
+ if (_abs64(rt - m_rtPrev) > m_rtMaxShift) {
+ m_rtOffset += m_rtPrev - rt;
+ }
+
+ p->rtStart += m_rtOffset;
+ p->rtStop += m_rtOffset;
+
+ m_rtPrev = p->rtStart;
+ }
+
+ if (p->pmt) {
+ if (*((CMediaType*)p->pmt) != m_mt) {
+ SetMediaType((CMediaType*)p->pmt);
+ }
+ }
+
+ if (m_mt.subtype == MEDIASUBTYPE_AAC) { // special code for aac, the currently available decoders only like whole frame samples
+ if (m_p && m_p->GetCount() == 1 && m_p->GetAt(0) == 0xff && !(!p->IsEmpty() && (p->GetAt(0) & 0xf6) == 0xf0)) {
+ m_p.Free();
+ }
+
+ if (!m_p) {
+ BYTE* base = p->GetData();
+ BYTE* s = base;
+ BYTE* e = s + p->GetCount();
+
+ for (; s < e; s++) {
+ if (*s != 0xff) {
+ continue;
+ }
+
+ if (s == e - 1 || (s[1] & 0xf6) == 0xf0) {
+ memmove(base, s, e - s);
+ p->SetCount(e - s);
+ m_p = p;
+ break;
+ }
+ }
+ } else {
+ m_p->Append(*p);
+ }
+
+ while (m_p && m_p->GetCount() > 9) {
+ BYTE* base = m_p->GetData();
+ BYTE* s = base;
+ BYTE* e = s + m_p->GetCount();
+ int len = ((s[3] & 3) << 11) | (s[4] << 3) | (s[5] >> 5);
+ bool crc = !(s[1] & 1);
+ s += 7;
+ len -= 7;
+ if (crc) {
+ s += 2, len -= 2;
+ }
+
+ if (e - s < len) {
+ break;
+ }
+
+ if (len <= 0 || e - s >= len + 2 && (s[len] != 0xff || (s[len + 1] & 0xf6) != 0xf0)) {
+ m_p.Free();
+ break;
+ }
+
+ CAutoPtr<Packet> p2(DNew Packet());
+
+ p2->TrackNumber = m_p->TrackNumber;
+ p2->bDiscontinuity |= m_p->bDiscontinuity;
+ m_p->bDiscontinuity = false;
+
+ p2->bSyncPoint = m_p->rtStart != Packet::INVALID_TIME;
+ p2->rtStart = m_p->rtStart;
+ m_p->rtStart = Packet::INVALID_TIME;
+
+ p2->rtStop = m_p->rtStop;
+ m_p->rtStop = Packet::INVALID_TIME;
+ p2->pmt = m_p->pmt;
+ m_p->pmt = NULL;
+ p2->SetData(s, len);
+
+ s += len;
+ memmove(base, s, e - s);
+ m_p->SetCount(e - s);
+
+ HRESULT hr = __super::DeliverPacket(p2);
+ if (hr != S_OK) {
+ return hr;
+ }
+ }
+
+ if (m_p && p) {
+ if (!m_p->bDiscontinuity) {
+ m_p->bDiscontinuity = p->bDiscontinuity;
+ }
+ if (!m_p->bSyncPoint) {
+ m_p->bSyncPoint = p->bSyncPoint;
+ }
+ if (m_p->rtStart == Packet::INVALID_TIME) {
+ m_p->rtStart = p->rtStart, m_p->rtStop = p->rtStop;
+ }
+ if (m_p->pmt) {
+ DeleteMediaType(m_p->pmt);
+ }
+
+ m_p->pmt = p->pmt;
+ p->pmt = NULL;
+ }
+
+ return S_OK;
+ } else if (m_mt.subtype == FOURCCMap('1CVA') || m_mt.subtype == FOURCCMap('1cva') || m_mt.subtype == FOURCCMap('CVMA') || m_mt.subtype == FOURCCMap('CVME')) {
+ if (!m_p) {
+ m_p.Attach(DNew Packet());
+ m_p->TrackNumber = p->TrackNumber;
+ m_p->bDiscontinuity = p->bDiscontinuity;
+ p->bDiscontinuity = FALSE;
+
+ m_p->bSyncPoint = p->bSyncPoint;
+ p->bSyncPoint = FALSE;
+
+ m_p->rtStart = p->rtStart;
+ p->rtStart = Packet::INVALID_TIME;
+
+ m_p->rtStop = p->rtStop;
+ p->rtStop = Packet::INVALID_TIME;
+ }
+
+ m_p->Append(*p);
+
+ BYTE* start = m_p->GetData();
+ BYTE* end = start + m_p->GetCount();
+
+ MOVE_TO_H264_START_CODE(start, end);
+
+ while (start <= end - 4) {
+ BYTE* next = start + 1;
+
+ MOVE_TO_H264_START_CODE(next, end);
+
+ if (next >= end - 4) {
+ break;
+ }
+
+ int size = next - start;
+
+ CH264Nalu Nalu;
+ Nalu.SetBuffer(start, size, 0);
+
+ CAutoPtr<Packet> p2;
+
+ while (Nalu.ReadNext()) {
+ DWORD dwNalLength =
+ ((Nalu.GetDataLength() >> 24) & 0x000000ff) |
+ ((Nalu.GetDataLength() >> 8) & 0x0000ff00) |
+ ((Nalu.GetDataLength() << 8) & 0x00ff0000) |
+ ((Nalu.GetDataLength() << 24) & 0xff000000);
+
+ CAutoPtr<Packet> p3(DNew Packet());
+
+ p3->SetCount(Nalu.GetDataLength() + sizeof(dwNalLength));
+ memcpy(p3->GetData(), &dwNalLength, sizeof(dwNalLength));
+ memcpy(p3->GetData() + sizeof(dwNalLength), Nalu.GetDataBuffer(), Nalu.GetDataLength());
+
+ if (p2 == NULL) {
+ p2 = p3;
+ } else {
+ p2->Append(*p3);
+ }
+ }
+ start = next;
+
+ if (!p2) {
+ continue;
+ }
+
+ p2->TrackNumber = m_p->TrackNumber;
+ p2->bDiscontinuity = m_p->bDiscontinuity;
+ m_p->bDiscontinuity = FALSE;
+
+ p2->bSyncPoint = m_p->bSyncPoint;
+ m_p->bSyncPoint = FALSE;
+
+ p2->rtStart = m_p->rtStart;
+ m_p->rtStart = Packet::INVALID_TIME;
+ p2->rtStop = m_p->rtStop;
+ m_p->rtStop = Packet::INVALID_TIME;
+
+ p2->pmt = m_p->pmt;
+ m_p->pmt = NULL;
+
+ m_pl.AddTail(p2);
+
+ if (p->rtStart != Packet::INVALID_TIME) {
+ m_p->rtStart = p->rtStart;
+ m_p->rtStop = p->rtStop;
+ p->rtStart = Packet::INVALID_TIME;
+ }
+ if (p->bDiscontinuity) {
+ m_p->bDiscontinuity = p->bDiscontinuity;
+ p->bDiscontinuity = FALSE;
+ }
+ if (p->bSyncPoint) {
+ m_p->bSyncPoint = p->bSyncPoint;
+ p->bSyncPoint = FALSE;
+ }
+ if (m_p->pmt) {
+ DeleteMediaType(m_p->pmt);
+ }
+
+ m_p->pmt = p->pmt;
+ p->pmt = NULL;
+ }
+ if (start > m_p->GetData()) {
+ m_p->RemoveAt(0, start - m_p->GetData());
+ }
+
+ REFERENCE_TIME rtStart = Packet::INVALID_TIME, rtStop = Packet::INVALID_TIME;
+
+ for (POSITION pos = m_pl.GetHeadPosition(); pos; m_pl.GetNext(pos)) {
+ if (pos == m_pl.GetHeadPosition()) {
+ continue;
+ }
+
+ Packet* pPacket = m_pl.GetAt(pos);
+ BYTE* pData = pPacket->GetData();
+
+ if ((pData[4] & 0x1f) == 0x09) {
+ m_fHasAccessUnitDelimiters = true;
+ }
+
+ if ((pData[4] & 0x1f) == 0x09 || (!m_fHasAccessUnitDelimiters && pPacket->rtStart != Packet::INVALID_TIME)) {
+ if (pPacket->rtStart == Packet::INVALID_TIME && rtStart != Packet::INVALID_TIME) {
+ pPacket->rtStart = rtStart;
+ pPacket->rtStop = rtStop;
+ }
+
+ p = m_pl.RemoveHead();
+
+ while (pos != m_pl.GetHeadPosition()) {
+ CAutoPtr<Packet> p2 = m_pl.RemoveHead();
+ p->Append(*p2);
+ }
+
+ HRESULT hr = __super::DeliverPacket(p);
+ if (hr != S_OK) {
+ return hr;
+ }
+ } else if (rtStart == Packet::INVALID_TIME) {
+ rtStart = pPacket->rtStart;
+ rtStop = pPacket->rtStop;
+ }
+ }
+
+ return S_OK;
+ } else if (m_mt.subtype == FOURCCMap('1CVW') || m_mt.subtype == FOURCCMap('1cvw') ||
+ m_mt.subtype == MEDIASUBTYPE_WVC1_CYBERLINK || m_mt.subtype == MEDIASUBTYPE_WVC1_ARCSOFT) { // just like aac, this has to be starting nalus, more can be packed together
+ if (!m_p) {
+ m_p.Attach(DNew Packet());
+ m_p->TrackNumber = p->TrackNumber;
+ m_p->bDiscontinuity = p->bDiscontinuity;
+ p->bDiscontinuity = FALSE;
+
+ m_p->bSyncPoint = p->bSyncPoint;
+ p->bSyncPoint = FALSE;
+
+ m_p->rtStart = p->rtStart;
+ p->rtStart = Packet::INVALID_TIME;
+
+ m_p->rtStop = p->rtStop;
+ p->rtStop = Packet::INVALID_TIME;
+ }
+
+ m_p->Append(*p);
+
+ BYTE* start = m_p->GetData();
+ BYTE* end = start + m_p->GetCount();
+
+ bool bSeqFound = false;
+ while (start <= end - 4) {
+ if (*(DWORD*)start == 0x0D010000) {
+ bSeqFound = true;
+ break;
+ } else if (*(DWORD*)start == 0x0F010000) {
+ break;
+ }
+ start++;
+ }
+
+ while (start <= end - 4) {
+ BYTE* next = start + 1;
+
+ while (next <= end - 4) {
+ if (*(DWORD*)next == 0x0D010000) {
+ if (bSeqFound) {
+ break;
+ }
+ bSeqFound = true;
+ } else if (*(DWORD*)next == 0x0F010000) {
+ break;
+ }
+ next++;
+ }
+
+ if (next >= end - 4) {
+ break;
+ }
+
+ int size = next - start - 4;
+ UNREFERENCED_PARAMETER(size);
+
+ CAutoPtr<Packet> p2(DNew Packet());
+ p2->TrackNumber = m_p->TrackNumber;
+ p2->bDiscontinuity = m_p->bDiscontinuity;
+ m_p->bDiscontinuity = FALSE;
+
+ p2->bSyncPoint = m_p->bSyncPoint;
+ m_p->bSyncPoint = FALSE;
+
+ p2->rtStart = m_p->rtStart;
+ m_p->rtStart = Packet::INVALID_TIME;
+
+ p2->rtStop = m_p->rtStop;
+ m_p->rtStop = Packet::INVALID_TIME;
+
+ p2->pmt = m_p->pmt;
+ m_p->pmt = NULL;
+
+ p2->SetData(start, next - start);
+
+ HRESULT hr = __super::DeliverPacket(p2);
+ if (hr != S_OK) {
+ return hr;
+ }
+
+ if (p->rtStart != Packet::INVALID_TIME) {
+ m_p->rtStart = p->rtStop; //p->rtStart; //Sebastiii for enable VC1 decoding in FFDshow (no more shutter)
+ m_p->rtStop = p->rtStop;
+ p->rtStart = Packet::INVALID_TIME;
+ }
+ if (p->bDiscontinuity) {
+ m_p->bDiscontinuity = p->bDiscontinuity;
+ p->bDiscontinuity = FALSE;
+ }
+ if (p->bSyncPoint) {
+ m_p->bSyncPoint = p->bSyncPoint;
+ p->bSyncPoint = FALSE;
+ }
+ if (m_p->pmt) {
+ DeleteMediaType(m_p->pmt);
+ }
+
+ m_p->pmt = p->pmt;
+ p->pmt = NULL;
+
+ start = next;
+ bSeqFound = (*(DWORD*)start == 0x0D010000);
+ }
+
+ if (start > m_p->GetData()) {
+ m_p->RemoveAt(0, start - m_p->GetData());
+ }
+
+ return S_OK;
+ }
+ // DTS HD MA data is causing trouble with some filters, lets just remove it
+ else if (m_bFilterDTSMA && ((m_mt.subtype == MEDIASUBTYPE_DTS || m_mt.subtype == MEDIASUBTYPE_WAVE_DTS))) {
+ if (p->GetCount() < 4 && !p->pmt) {
+ return S_OK; // Should be invalid packet
+ }
+ BYTE* hdr = p->GetData();
+
+ int Type;
+ // 16 bits big endian bitstream
+ if (hdr[0] == 0x7f && hdr[1] == 0xfe &&
+ hdr[2] == 0x80 && hdr[3] == 0x01) {
+ Type = 16 + 32;
+ }
+
+ // 16 bits low endian bitstream
+ else if (hdr[0] == 0xfe && hdr[1] == 0x7f &&
+ hdr[2] == 0x01 && hdr[3] == 0x80) {
+ Type = 16;
+ }
+
+ // 14 bits big endian bitstream
+ else if (hdr[0] == 0x1f && hdr[1] == 0xff &&
+ hdr[2] == 0xe8 && hdr[3] == 0x00 &&
+ hdr[4] == 0x07 && (hdr[5] & 0xf0) == 0xf0) {
+ Type = 14 + 32;
+ }
+
+ // 14 bits low endian bitstream
+ else if (hdr[0] == 0xff && hdr[1] == 0x1f &&
+ hdr[2] == 0x00 && hdr[3] == 0xe8 &&
+ (hdr[4] & 0xf0) == 0xf0 && hdr[5] == 0x07) {
+ Type = 14;
+ }
+
+ // no sync
+ else if (!p->pmt) {
+ return S_OK;
+ }
+ // HDMV LPCM
+ } else if (m_mt.subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
+ if (!m_p) {
+ m_p.Attach(DNew Packet());
+ }
+ m_p->Append(*p);
+
+ if (m_p->GetCount() < 4) {
+ m_p.Free();
+ return S_OK; // Should be invalid packet
+ }
+
+ BYTE* start = m_p->GetData();
+ int samplerate, channels;
+ size_t header_size = ParseHdmvLPCMHeader(start, &samplerate, &channels);
+ if (!header_size || header_size > m_p->GetCount()) {
+ if (!header_size) {
+ m_p.Free();
+ }
+ return S_OK;
+ }
+
+ if (!p->pmt && m_bFlushed) {
+ p->pmt = CreateMediaType(&m_mt);
+ m_bFlushed = false;
+ }
+ p->SetData(start + 4, m_p->GetCount() - 4);
+ m_p.Free();
+ // Dolby_AC3
+ } else if ((m_type == mpeg_ts) &&
+ (m_mt.subtype == MEDIASUBTYPE_DOLBY_AC3) &&
+ (static_cast<CMpegSplitterFilter*>(m_pFilter))->StreamIsTrueHD(p->TrackNumber) &&
+ (static_cast<CMpegSplitterFilter*>(m_pFilter))->GetTrueHD() != 2) {
+ if (p->GetCount() < 8) {
+ return S_OK; // Should be invalid packet
+ }
+ BYTE* start = p->GetData();
+ if (*(WORD*)start != 0x770b) { // skip none AC3
+ return S_OK;
+ }
+ // TrueHD
+ } else if (m_mt.subtype == MEDIASUBTYPE_DOLBY_TRUEHD && (static_cast<CMpegSplitterFilter*>(m_pFilter))->GetTrueHD() != 2) {
+ if (p->GetCount() < 8) {
+ return S_OK; // Should be invalid packet
+ }
+ BYTE* start = p->GetData();
+ if (*(WORD*)start == 0x770b) { // skip AC3
+ return S_OK;
+ }
+ if (DD_reset || p->rtStart == 0) {
+ p->bDiscontinuity = true;
+ DD_reset = false;
+ }
+ } else {
+ m_p.Free();
+ m_pl.RemoveAll();
+ }
+
+ return __super::DeliverPacket(p);
}
STDMETHODIMP CMpegSplitterOutputPin::Connect(IPin* pReceivePin, const AM_MEDIA_TYPE* pmt)
{
- HRESULT hr;
- PIN_INFO PinInfo;
- GUID FilterClsid;
-
- if (SUCCEEDED (pReceivePin->QueryPinInfo (&PinInfo))) {
- if (SUCCEEDED (PinInfo.pFilter->GetClassID(&FilterClsid))) {
- if (FilterClsid == CLSID_DMOWrapperFilter) {
- (static_cast<CMpegSplitterFilter*>(m_pFilter))->SetPipo(true);
- }
- // AC3 Filter did not support DTS-MA
- else if (FilterClsid == CLSID_AC3Filter) {
- m_bFilterDTSMA = true;
- }
- }
- PinInfo.pFilter->Release();
- }
-
- hr = __super::Connect (pReceivePin, pmt);
- (static_cast<CMpegSplitterFilter*>(m_pFilter))->SetPipo(false);
- return hr;
+ HRESULT hr;
+ PIN_INFO PinInfo;
+ GUID FilterClsid;
+
+ if (SUCCEEDED(pReceivePin->QueryPinInfo(&PinInfo))) {
+ if (SUCCEEDED(PinInfo.pFilter->GetClassID(&FilterClsid))) {
+ if (FilterClsid == CLSID_DMOWrapperFilter) {
+ (static_cast<CMpegSplitterFilter*>(m_pFilter))->SetPipo(true);
+ }
+ // AC3 Filter did not support DTS-MA
+ else if (FilterClsid == CLSID_AC3Filter) {
+ m_bFilterDTSMA = true;
+ }
+ }
+ PinInfo.pFilter->Release();
+ }
+
+ hr = __super::Connect(pReceivePin, pmt);
+ (static_cast<CMpegSplitterFilter*>(m_pFilter))->SetPipo(false);
+ return hr;
}
diff --git a/src/filters/parser/MpegSplitter/MpegSplitter.h b/src/filters/parser/MpegSplitter/MpegSplitter.h
index a7f9d5082..ef12de2d4 100644
--- a/src/filters/parser/MpegSplitter/MpegSplitter.h
+++ b/src/filters/parser/MpegSplitter/MpegSplitter.h
@@ -53,121 +53,121 @@
class __declspec(uuid("DC257063-045F-4BE2-BD5B-E12279C464F0"))
- CMpegSplitterFilter
- : public CBaseSplitterFilter
- , public IAMStreamSelect
- , public ISpecifyPropertyPages2
- , public IMpegSplitterFilter
+ CMpegSplitterFilter
+ : public CBaseSplitterFilter
+ , public IAMStreamSelect
+ , public ISpecifyPropertyPages2
+ , public IMpegSplitterFilter
{
- REFERENCE_TIME m_rtStartOffset;
- bool m_pPipoBimbo;
- CHdmvClipInfo m_ClipInfo;
+ REFERENCE_TIME m_rtStartOffset;
+ bool m_pPipoBimbo;
+ CHdmvClipInfo m_ClipInfo;
protected:
- CAutoPtr<CMpegSplitterFile> m_pFile;
- CComQIPtr<ITrackInfo> pTI;
+ CAutoPtr<CMpegSplitterFile> m_pFile;
+ CComQIPtr<ITrackInfo> pTI;
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
- void ReadClipInfo(LPCOLESTR pszFileName);
+ HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
+ void ReadClipInfo(LPCOLESTR pszFileName);
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
- bool BuildPlaylist(LPCTSTR pszFileName, CAtlList<CHdmvClipInfo::PlaylistItem>& files);
- bool BuildChapters(LPCTSTR pszFileName, CAtlList<CHdmvClipInfo::PlaylistItem>& PlaylistItems, CAtlList<CHdmvClipInfo::PlaylistChapter>& Items);
+ bool DemuxInit();
+ void DemuxSeek(REFERENCE_TIME rt);
+ bool DemuxLoop();
+ bool BuildPlaylist(LPCTSTR pszFileName, CAtlList<CHdmvClipInfo::PlaylistItem>& files);
+ bool BuildChapters(LPCTSTR pszFileName, CAtlList<CHdmvClipInfo::PlaylistItem>& PlaylistItems, CAtlList<CHdmvClipInfo::PlaylistChapter>& Items);
- HRESULT DemuxNextPacket(REFERENCE_TIME rtStartOffset);
+ HRESULT DemuxNextPacket(REFERENCE_TIME rtStartOffset);
- REFERENCE_TIME m_rtPlaylistDuration;
+ REFERENCE_TIME m_rtPlaylistDuration;
private:
- CString m_csAudioLanguageOrder, m_csSubtitlesLanguageOrder;
- bool m_useFastStreamChange, m_ForcedSub, m_TrackPriority, m_AlternativeDuration;
- int m_nVC1_GuidFlag, m_AC3CoreOnly;
- CCritSec m_csProps;
+ CString m_csAudioLanguageOrder, m_csSubtitlesLanguageOrder;
+ bool m_useFastStreamChange, m_ForcedSub, m_TrackPriority, m_AlternativeDuration;
+ int m_nVC1_GuidFlag, m_AC3CoreOnly;
+ CCritSec m_csProps;
public:
- CMpegSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLSID& clsid = __uuidof(CMpegSplitterFilter));
- void SetPipo(bool bPipo) { m_pPipoBimbo = bPipo; };
+ CMpegSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLSID& clsid = __uuidof(CMpegSplitterFilter));
+ void SetPipo(bool bPipo) { m_pPipoBimbo = bPipo; };
- bool StreamIsTrueHD(const WORD pid);
+ bool StreamIsTrueHD(const WORD pid);
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- STDMETHODIMP GetClassID(CLSID* pClsID);
- STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP GetClassID(CLSID* pClsID);
+ STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
- // CBaseFilter
+ // CBaseFilter
- STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
+ STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
- // IAMStreamSelect
+ // IAMStreamSelect
- STDMETHODIMP Count(DWORD* pcStreams);
- STDMETHODIMP Enable(long lIndex, DWORD dwFlags);
- STDMETHODIMP Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* pdwFlags, LCID* plcid, DWORD* pdwGroup, WCHAR** ppszName, IUnknown** ppObject, IUnknown** ppUnk);
+ STDMETHODIMP Count(DWORD* pcStreams);
+ STDMETHODIMP Enable(long lIndex, DWORD dwFlags);
+ STDMETHODIMP Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* pdwFlags, LCID* plcid, DWORD* pdwGroup, WCHAR** ppszName, IUnknown** ppObject, IUnknown** ppUnk);
- // ISpecifyPropertyPages2
+ // ISpecifyPropertyPages2
- STDMETHODIMP GetPages(CAUUID* pPages);
- STDMETHODIMP CreatePage(const GUID& guid, IPropertyPage** ppPage);
+ STDMETHODIMP GetPages(CAUUID* pPages);
+ STDMETHODIMP CreatePage(const GUID& guid, IPropertyPage** ppPage);
- // IMpegSplitterFilter
- STDMETHODIMP Apply();
+ // IMpegSplitterFilter
+ STDMETHODIMP Apply();
- STDMETHODIMP SetFastStreamChange(BOOL nValue);
- STDMETHODIMP_(BOOL) GetFastStreamChange();
+ STDMETHODIMP SetFastStreamChange(BOOL nValue);
+ STDMETHODIMP_(BOOL) GetFastStreamChange();
- STDMETHODIMP SetForcedSub(BOOL nValue);
- STDMETHODIMP_(BOOL) GetForcedSub();
+ STDMETHODIMP SetForcedSub(BOOL nValue);
+ STDMETHODIMP_(BOOL) GetForcedSub();
- STDMETHODIMP SetTrackPriority(BOOL nValue);
- STDMETHODIMP_(BOOL) GetTrackPriority();
+ STDMETHODIMP SetTrackPriority(BOOL nValue);
+ STDMETHODIMP_(BOOL) GetTrackPriority();
- STDMETHODIMP SetAudioLanguageOrder(WCHAR *nValue);
- STDMETHODIMP_(WCHAR *) GetAudioLanguageOrder();
+ STDMETHODIMP SetAudioLanguageOrder(WCHAR* nValue);
+ STDMETHODIMP_(WCHAR*) GetAudioLanguageOrder();
- STDMETHODIMP SetSubtitlesLanguageOrder(WCHAR *nValue);
- STDMETHODIMP_(WCHAR *) GetSubtitlesLanguageOrder();
+ STDMETHODIMP SetSubtitlesLanguageOrder(WCHAR* nValue);
+ STDMETHODIMP_(WCHAR*) GetSubtitlesLanguageOrder();
- STDMETHODIMP SetVC1_GuidFlag(int nValue);
- STDMETHODIMP_(int) GetVC1_GuidFlag();
+ STDMETHODIMP SetVC1_GuidFlag(int nValue);
+ STDMETHODIMP_(int) GetVC1_GuidFlag();
- STDMETHODIMP SetTrueHD(int nValue);
- STDMETHODIMP_(int) GetTrueHD();
+ STDMETHODIMP SetTrueHD(int nValue);
+ STDMETHODIMP_(int) GetTrueHD();
- STDMETHODIMP SetAlternativeDuration(BOOL nValue);
- STDMETHODIMP_(BOOL) GetAlternativeDuration();
+ STDMETHODIMP SetAlternativeDuration(BOOL nValue);
+ STDMETHODIMP_(BOOL) GetAlternativeDuration();
- STDMETHODIMP_(int) GetMPEGType();
+ STDMETHODIMP_(int) GetMPEGType();
};
class __declspec(uuid("1365BE7A-C86A-473C-9A41-C0A6E82C9FA3"))
- CMpegSourceFilter : public CMpegSplitterFilter
+ CMpegSourceFilter : public CMpegSplitterFilter
{
public:
- CMpegSourceFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLSID& clsid = __uuidof(CMpegSourceFilter));
+ CMpegSourceFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLSID& clsid = __uuidof(CMpegSourceFilter));
};
class CMpegSplitterOutputPin : public CBaseSplitterOutputPin, protected CCritSec
{
- CAutoPtr<Packet> m_p;
- CAutoPtrList<Packet> m_pl;
- REFERENCE_TIME m_rtPrev, m_rtOffset, m_rtMaxShift;
- bool m_fHasAccessUnitDelimiters;
- bool m_bFilterDTSMA;
- bool DD_reset;
- bool m_bFlushed;
- int m_type;
+ CAutoPtr<Packet> m_p;
+ CAutoPtrList<Packet> m_pl;
+ REFERENCE_TIME m_rtPrev, m_rtOffset, m_rtMaxShift;
+ bool m_fHasAccessUnitDelimiters;
+ bool m_bFilterDTSMA;
+ bool DD_reset;
+ bool m_bFlushed;
+ int m_type;
protected:
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
- HRESULT DeliverPacket(CAutoPtr<Packet> p);
- HRESULT DeliverEndFlush();
+ HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ HRESULT DeliverPacket(CAutoPtr<Packet> p);
+ HRESULT DeliverEndFlush();
public:
- CMpegSplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr, int type);
- virtual ~CMpegSplitterOutputPin();
- STDMETHODIMP Connect(IPin* pReceivePin, const AM_MEDIA_TYPE* pmt);
- void SetMaxShift(REFERENCE_TIME rtMaxShift) { m_rtMaxShift = rtMaxShift; };
+ CMpegSplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr, int type);
+ virtual ~CMpegSplitterOutputPin();
+ STDMETHODIMP Connect(IPin* pReceivePin, const AM_MEDIA_TYPE* pmt);
+ void SetMaxShift(REFERENCE_TIME rtMaxShift) { m_rtMaxShift = rtMaxShift; };
};
diff --git a/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp b/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp
index ecacdf03b..599f00f6a 100644
--- a/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp
+++ b/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp
@@ -33,486 +33,485 @@
#define MEGABYTE 1024*1024
-CMpegSplitterFile::CMpegSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr, bool bIsHdmv, CHdmvClipInfo &ClipInfo, int guid_flag, bool ForcedSub, bool TrackPriority, int AC3CoreOnly, bool AlternativeDuration)
- : CBaseSplitterFileEx(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false, true)
- , m_type(mpeg_us)
- , m_rate(0)
- , m_rtMin(0), m_rtMax(0)
- , m_posMin(0), m_posMax(0)
- , m_bIsHdmv(bIsHdmv)
- , m_ClipInfo(ClipInfo)
- , m_nVC1_GuidFlag(guid_flag)
- , m_ForcedSub(ForcedSub)
- , m_TrackPriority(TrackPriority)
- , m_AC3CoreOnly(AC3CoreOnly)
- , m_AlternativeDuration(AlternativeDuration)
- , m_init(false)
+CMpegSplitterFile::CMpegSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr, bool bIsHdmv, CHdmvClipInfo& ClipInfo, int guid_flag, bool ForcedSub, bool TrackPriority, int AC3CoreOnly, bool AlternativeDuration)
+ : CBaseSplitterFileEx(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false, true)
+ , m_type(mpeg_us)
+ , m_rate(0)
+ , m_rtMin(0), m_rtMax(0)
+ , m_posMin(0), m_posMax(0)
+ , m_bIsHdmv(bIsHdmv)
+ , m_ClipInfo(ClipInfo)
+ , m_nVC1_GuidFlag(guid_flag)
+ , m_ForcedSub(ForcedSub)
+ , m_TrackPriority(TrackPriority)
+ , m_AC3CoreOnly(AC3CoreOnly)
+ , m_AlternativeDuration(AlternativeDuration)
+ , m_init(false)
{
- if (SUCCEEDED(hr)) {
- hr = Init(pAsyncReader);
- }
+ if (SUCCEEDED(hr)) {
+ hr = Init(pAsyncReader);
+ }
}
HRESULT CMpegSplitterFile::Init(IAsyncReader* pAsyncReader)
{
- HRESULT hr;
-
- // get the type first
-
- m_type = mpeg_us;
-
- Seek(0);
-
- if (m_type == mpeg_us) {
- if (BitRead(32, true) == 'TFrc') {
- Seek(0x67c);
- }
- int cnt = 0, limit = 4;
- for (trhdr h; cnt < limit && Read(h); cnt++) {
- Seek(h.next);
- }
- if (cnt >= limit) {
- m_type = mpeg_ts;
- }
- }
-
- Seek(0);
-
- if (m_type == mpeg_us) {
- if (BitRead(32, true) == 'TFrc') {
- Seek(0xE80);
- }
- int cnt = 0, limit = 4;
- for (trhdr h; cnt < limit && Read(h); cnt++) {
- Seek(h.next);
- }
- if (cnt >= limit) {
- m_type = mpeg_ts;
- }
- }
-
- Seek(0);
-
- if (m_type == mpeg_us) {
- int cnt = 0, limit = 4;
- for (pvahdr h; cnt < limit && Read(h); cnt++) {
- Seek(GetPos() + h.length);
- }
- if (cnt >= limit) {
- m_type = mpeg_pva;
- }
- }
-
- Seek(0);
-
- if (m_type == mpeg_us) {
- BYTE b;
- for (int i = 0; (i < 4 || GetPos() < 65536) && m_type == mpeg_us && NextMpegStartCode(b); i++) {
- if (b == 0xba) {
- pshdr h;
- if (Read(h)) {
- m_type = mpeg_ps;
- m_rate = int(h.bitrate/8);
- break;
- }
- } else if ((b&0xe0) == 0xc0 // audio, 110xxxxx, mpeg1/2/3
- || (b&0xf0) == 0xe0 // video, 1110xxxx, mpeg1/2
- // || (b&0xbd) == 0xbd) // private stream 1, 0xbd, ac3/dts/lpcm/subpic
- || b == 0xbd) { // private stream 1, 0xbd, ac3/dts/lpcm/subpic
- peshdr h;
- if (Read(h, b) && BitRead(24, true) == 0x000001) {
- m_type = mpeg_es;
- }
- }
- }
- }
-
- Seek(0);
-
- if (m_type == mpeg_us) {
- return E_FAIL;
- }
-
- // min/max pts & bitrate
- m_rtMin = m_posMin = _I64_MAX;
- m_rtMax = m_posMax = 0;
-
- m_init = true;
-
- if (IsRandomAccess() || IsStreaming()) {
- if (IsStreaming()) {
- for (int i = 0; i < 20 || i < 50 && S_OK != HasMoreData(1024*100, 100); i++) {
- ;
- }
- }
-
- SearchPrograms(0, min(GetLength(), MEGABYTE*5)); // max 5Mb for search a valid Program Map Table
-
- CAtlList<__int64> fps;
- for (int i = 0, j = 5; i <= j; i++) {
- fps.AddTail(i*GetLength()/j);
- }
-
- for (__int64 pfp = 0; fps.GetCount(); ) {
- __int64 fp = fps.RemoveHead();
- fp = min(GetLength() - MEGABYTE/8, fp);
- fp = max(pfp, fp);
- __int64 nfp = fp + (pfp == 0 ? 10*MEGABYTE : MEGABYTE/8);
- if (FAILED(hr = SearchStreams(fp, nfp, pAsyncReader))) {
- return hr;
- }
- pfp = nfp;
- }
- } else {
- if (FAILED(hr = SearchStreams(0, MEGABYTE/8, pAsyncReader))) {
- return hr;
- }
- }
-
- if (m_type == mpeg_ts) {
- if (IsRandomAccess() || IsStreaming()) {
- if (IsStreaming()) {
- for (int i = 0; i < 20 || i < 50 && S_OK != HasMoreData(1024*100, 100); i++) {
- ;
- }
- }
-
- CAtlList<__int64> fps;
- for (int i = 0, j = 5; i <= j; i++) {
- fps.AddTail(i*GetLength()/j);
- }
-
- for (__int64 pfp = 0; fps.GetCount(); ) {
- __int64 fp = fps.RemoveHead();
- fp = min(GetLength() - MEGABYTE/8, fp);
- fp = max(pfp, fp);
- __int64 nfp = fp + (pfp == 0 ? 10*MEGABYTE : MEGABYTE/8);
- if (FAILED(hr = SearchStreams(fp, nfp, pAsyncReader, TRUE))) {
- return hr;
- }
- pfp = nfp;
- }
- } else {
- if (FAILED(hr = SearchStreams(0, MEGABYTE/8, pAsyncReader, TRUE))) {
- return hr;
- }
- }
- }
-
- if (m_posMax - m_posMin <= 0 || m_rtMax - m_rtMin <= 0) {
- return E_FAIL;
- }
-
- m_init = false;
-
- int indicated_rate = m_rate;
- int detected_rate = int(m_rtMax > m_rtMin ? 10000000i64 * (m_posMax - m_posMin) / (m_rtMax - m_rtMin) : 0);
-
- m_rate = detected_rate ? detected_rate : m_rate;
+ HRESULT hr;
+
+ // get the type first
+
+ m_type = mpeg_us;
+
+ Seek(0);
+
+ if (m_type == mpeg_us) {
+ if (BitRead(32, true) == 'TFrc') {
+ Seek(0x67c);
+ }
+ int cnt = 0, limit = 4;
+ for (trhdr h; cnt < limit && Read(h); cnt++) {
+ Seek(h.next);
+ }
+ if (cnt >= limit) {
+ m_type = mpeg_ts;
+ }
+ }
+
+ Seek(0);
+
+ if (m_type == mpeg_us) {
+ if (BitRead(32, true) == 'TFrc') {
+ Seek(0xE80);
+ }
+ int cnt = 0, limit = 4;
+ for (trhdr h; cnt < limit && Read(h); cnt++) {
+ Seek(h.next);
+ }
+ if (cnt >= limit) {
+ m_type = mpeg_ts;
+ }
+ }
+
+ Seek(0);
+
+ if (m_type == mpeg_us) {
+ int cnt = 0, limit = 4;
+ for (pvahdr h; cnt < limit && Read(h); cnt++) {
+ Seek(GetPos() + h.length);
+ }
+ if (cnt >= limit) {
+ m_type = mpeg_pva;
+ }
+ }
+
+ Seek(0);
+
+ if (m_type == mpeg_us) {
+ BYTE b;
+ for (int i = 0; (i < 4 || GetPos() < 65536) && m_type == mpeg_us && NextMpegStartCode(b); i++) {
+ if (b == 0xba) {
+ pshdr h;
+ if (Read(h)) {
+ m_type = mpeg_ps;
+ m_rate = int(h.bitrate / 8);
+ break;
+ }
+ } else if ((b & 0xe0) == 0xc0 // audio, 110xxxxx, mpeg1/2/3
+ || (b & 0xf0) == 0xe0 // video, 1110xxxx, mpeg1/2
+ // || (b&0xbd) == 0xbd) // private stream 1, 0xbd, ac3/dts/lpcm/subpic
+ || b == 0xbd) { // private stream 1, 0xbd, ac3/dts/lpcm/subpic
+ peshdr h;
+ if (Read(h, b) && BitRead(24, true) == 0x000001) {
+ m_type = mpeg_es;
+ }
+ }
+ }
+ }
+
+ Seek(0);
+
+ if (m_type == mpeg_us) {
+ return E_FAIL;
+ }
+
+ // min/max pts & bitrate
+ m_rtMin = m_posMin = _I64_MAX;
+ m_rtMax = m_posMax = 0;
+
+ m_init = true;
+
+ if (IsRandomAccess() || IsStreaming()) {
+ if (IsStreaming()) {
+ for (int i = 0; i < 20 || i < 50 && S_OK != HasMoreData(1024 * 100, 100); i++) {
+ ;
+ }
+ }
+
+ SearchPrograms(0, min(GetLength(), MEGABYTE * 5)); // max 5Mb for search a valid Program Map Table
+
+ CAtlList<__int64> fps;
+ for (int i = 0, j = 5; i <= j; i++) {
+ fps.AddTail(i * GetLength() / j);
+ }
+
+ for (__int64 pfp = 0; fps.GetCount();) {
+ __int64 fp = fps.RemoveHead();
+ fp = min(GetLength() - MEGABYTE / 8, fp);
+ fp = max(pfp, fp);
+ __int64 nfp = fp + (pfp == 0 ? 10 * MEGABYTE : MEGABYTE / 8);
+ if (FAILED(hr = SearchStreams(fp, nfp, pAsyncReader))) {
+ return hr;
+ }
+ pfp = nfp;
+ }
+ } else {
+ if (FAILED(hr = SearchStreams(0, MEGABYTE / 8, pAsyncReader))) {
+ return hr;
+ }
+ }
+
+ if (m_type == mpeg_ts) {
+ if (IsRandomAccess() || IsStreaming()) {
+ if (IsStreaming()) {
+ for (int i = 0; i < 20 || i < 50 && S_OK != HasMoreData(1024 * 100, 100); i++) {
+ ;
+ }
+ }
+
+ CAtlList<__int64> fps;
+ for (int i = 0, j = 5; i <= j; i++) {
+ fps.AddTail(i * GetLength() / j);
+ }
+
+ for (__int64 pfp = 0; fps.GetCount();) {
+ __int64 fp = fps.RemoveHead();
+ fp = min(GetLength() - MEGABYTE / 8, fp);
+ fp = max(pfp, fp);
+ __int64 nfp = fp + (pfp == 0 ? 10 * MEGABYTE : MEGABYTE / 8);
+ if (FAILED(hr = SearchStreams(fp, nfp, pAsyncReader, TRUE))) {
+ return hr;
+ }
+ pfp = nfp;
+ }
+ } else {
+ if (FAILED(hr = SearchStreams(0, MEGABYTE / 8, pAsyncReader, TRUE))) {
+ return hr;
+ }
+ }
+ }
+
+ if (m_posMax - m_posMin <= 0 || m_rtMax - m_rtMin <= 0) {
+ return E_FAIL;
+ }
+
+ m_init = false;
+
+ int indicated_rate = m_rate;
+ int detected_rate = int(m_rtMax > m_rtMin ? 10000000i64 * (m_posMax - m_posMin) / (m_rtMax - m_rtMin) : 0);
+
+ m_rate = detected_rate ? detected_rate : m_rate;
#if (0)
- // normally "detected" should always be less than "indicated", but sometimes it can be a few percent higher (+10% is allowed here)
- // (update: also allowing +/-50k/s)
- if (indicated_rate == 0 || ((float)detected_rate / indicated_rate) < 1.1 || abs(detected_rate - indicated_rate) < 50*1024) {
- m_rate = detected_rate;
- } else {
- ; // TODO: in this case disable seeking, or try doing something less drastical...
- }
+ // normally "detected" should always be less than "indicated", but sometimes it can be a few percent higher (+10% is allowed here)
+ // (update: also allowing +/-50k/s)
+ if (indicated_rate == 0 || ((float)detected_rate / indicated_rate) < 1.1 || abs(detected_rate - indicated_rate) < 50 * 1024) {
+ m_rate = detected_rate;
+ } else {
+ ; // TODO: in this case disable seeking, or try doing something less drastical...
+ }
#endif
- // Add fake Subtitle stream ...
- if (m_type == mpeg_ts) {
- if (m_streams[video].GetCount()) {
- if (!m_bIsHdmv && m_streams[subpic].GetCount()) {
- stream s;
- s.pid = NO_SUBTITLE_PID;
- s.mt.majortype = m_streams[subpic].GetHead().mt.majortype;
- s.mt.subtype = m_streams[subpic].GetHead().mt.subtype;
- s.mt.formattype = m_streams[subpic].GetHead().mt.formattype;
- m_streams[subpic].Insert(s, this);
- } else {
- AddHdmvPGStream(NO_SUBTITLE_PID, "---");
- }
- }
- } else {
- if (m_streams[video].GetCount() && m_streams[subpic].GetCount()) {
- stream s;
- s.pid = NO_SUBTITLE_PID;
- s.mt.majortype = m_streams[subpic].GetHead().mt.majortype;
- s.mt.subtype = m_streams[subpic].GetHead().mt.subtype;
- s.mt.formattype = m_streams[subpic].GetHead().mt.formattype;
- m_streams[subpic].Insert(s, this);
- }
- }
-
- Seek(0);
-
- return S_OK;
+ // Add fake Subtitle stream ...
+ if (m_type == mpeg_ts) {
+ if (m_streams[video].GetCount()) {
+ if (!m_bIsHdmv && m_streams[subpic].GetCount()) {
+ stream s;
+ s.pid = NO_SUBTITLE_PID;
+ s.mt.majortype = m_streams[subpic].GetHead().mt.majortype;
+ s.mt.subtype = m_streams[subpic].GetHead().mt.subtype;
+ s.mt.formattype = m_streams[subpic].GetHead().mt.formattype;
+ m_streams[subpic].Insert(s, this);
+ } else {
+ AddHdmvPGStream(NO_SUBTITLE_PID, "---");
+ }
+ }
+ } else {
+ if (m_streams[video].GetCount() && m_streams[subpic].GetCount()) {
+ stream s;
+ s.pid = NO_SUBTITLE_PID;
+ s.mt.majortype = m_streams[subpic].GetHead().mt.majortype;
+ s.mt.subtype = m_streams[subpic].GetHead().mt.subtype;
+ s.mt.formattype = m_streams[subpic].GetHead().mt.formattype;
+ m_streams[subpic].Insert(s, this);
+ }
+ }
+
+ Seek(0);
+
+ return S_OK;
}
void CMpegSplitterFile::OnComplete(IAsyncReader* pAsyncReader)
{
- __int64 pos = GetPos();
+ __int64 pos = GetPos();
- if (SUCCEEDED(SearchStreams(GetLength() - 500*1024, GetLength(), pAsyncReader, TRUE))) {
- int indicated_rate = m_rate;
- int detected_rate = int(m_rtMax > m_rtMin ? 10000000i64 * (m_posMax - m_posMin) / (m_rtMax - m_rtMin) : 0);
+ if (SUCCEEDED(SearchStreams(GetLength() - 500 * 1024, GetLength(), pAsyncReader, TRUE))) {
+ int indicated_rate = m_rate;
+ int detected_rate = int(m_rtMax > m_rtMin ? 10000000i64 * (m_posMax - m_posMin) / (m_rtMax - m_rtMin) : 0);
- m_rate = detected_rate ? detected_rate : m_rate;
+ m_rate = detected_rate ? detected_rate : m_rate;
#if (0)
- // normally "detected" should always be less than "indicated", but sometimes it can be a few percent higher (+10% is allowed here)
- // (update: also allowing +/-50k/s)
- if (indicated_rate == 0 || ((float)detected_rate / indicated_rate) < 1.1 || abs(detected_rate - indicated_rate) < 50*1024) {
- m_rate = detected_rate;
- } else {
- ; // TODO: in this case disable seeking, or try doing something less drastical...
- }
+ // normally "detected" should always be less than "indicated", but sometimes it can be a few percent higher (+10% is allowed here)
+ // (update: also allowing +/-50k/s)
+ if (indicated_rate == 0 || ((float)detected_rate / indicated_rate) < 1.1 || abs(detected_rate - indicated_rate) < 50 * 1024) {
+ m_rate = detected_rate;
+ } else {
+ ; // TODO: in this case disable seeking, or try doing something less drastical...
+ }
#endif
- }
+ }
- Seek(pos);
+ Seek(pos);
}
REFERENCE_TIME CMpegSplitterFile::NextPTS(DWORD TrackNum)
{
- REFERENCE_TIME rt = -1;
- __int64 rtpos = -1;
-
- BYTE b;
-
- while (GetRemaining()) {
- if (m_type == mpeg_ps || m_type == mpeg_es) {
- if (!NextMpegStartCode(b)) { // continue;
- ASSERT(0);
- break;
- }
-
- rtpos = GetPos()-4;
-
- if ((b >= 0xbd && b < 0xf0) || (b == 0xfd)) {
- peshdr h;
- if (!Read(h, b) || !h.len) {
- continue;
- }
-
- __int64 pos = GetPos();
-
- if (h.fpts && AddStream(0, b, h.id_ext, h.len) == TrackNum) {
- //ASSERT(h.pts >= m_rtMin && h.pts <= m_rtMax);
- rt = h.pts;
- break;
- }
-
- Seek(pos + h.len);
- }
- } else if (m_type == mpeg_ts) {
- trhdr h;
- if (!Read(h)) {
- continue;
- }
-
- rtpos = GetPos()-4;
-
- if (h.payload && h.payloadstart && ISVALIDPID(h.pid)) {
- peshdr h2;
- if (NextMpegStartCode(b, 4) && Read(h2, b)) { // pes packet
- if (h2.fpts && AddStream(h.pid, b, 0, DWORD(h.bytes - (GetPos() - rtpos)) == TrackNum)) {
- //ASSERT(h2.pts >= m_rtMin && h2.pts <= m_rtMax);
- rt = h2.pts;
- break;
- }
- }
- }
-
- Seek(h.next);
- } else if (m_type == mpeg_pva) {
- pvahdr h;
- if (!Read(h)) {
- continue;
- }
-
- if (h.fpts) {
- rt = h.pts;
- break;
- }
- }
- }
-
- if (rtpos >= 0) {
- Seek(rtpos);
- }
- if (rt >= 0) {
- rt -= m_rtMin;
- }
-
- return rt;
+ REFERENCE_TIME rt = -1;
+ __int64 rtpos = -1;
+
+ BYTE b;
+
+ while (GetRemaining()) {
+ if (m_type == mpeg_ps || m_type == mpeg_es) {
+ if (!NextMpegStartCode(b)) { // continue;
+ ASSERT(0);
+ break;
+ }
+
+ rtpos = GetPos() - 4;
+
+ if ((b >= 0xbd && b < 0xf0) || (b == 0xfd)) {
+ peshdr h;
+ if (!Read(h, b) || !h.len) {
+ continue;
+ }
+
+ __int64 pos = GetPos();
+
+ if (h.fpts && AddStream(0, b, h.id_ext, h.len) == TrackNum) {
+ //ASSERT(h.pts >= m_rtMin && h.pts <= m_rtMax);
+ rt = h.pts;
+ break;
+ }
+
+ Seek(pos + h.len);
+ }
+ } else if (m_type == mpeg_ts) {
+ trhdr h;
+ if (!Read(h)) {
+ continue;
+ }
+
+ rtpos = GetPos() - 4;
+
+ if (h.payload && h.payloadstart && ISVALIDPID(h.pid)) {
+ peshdr h2;
+ if (NextMpegStartCode(b, 4) && Read(h2, b)) { // pes packet
+ if (h2.fpts && AddStream(h.pid, b, 0, DWORD(h.bytes - (GetPos() - rtpos)) == TrackNum)) {
+ //ASSERT(h2.pts >= m_rtMin && h2.pts <= m_rtMax);
+ rt = h2.pts;
+ break;
+ }
+ }
+ }
+
+ Seek(h.next);
+ } else if (m_type == mpeg_pva) {
+ pvahdr h;
+ if (!Read(h)) {
+ continue;
+ }
+
+ if (h.fpts) {
+ rt = h.pts;
+ break;
+ }
+ }
+ }
+
+ if (rtpos >= 0) {
+ Seek(rtpos);
+ }
+ if (rt >= 0) {
+ rt -= m_rtMin;
+ }
+
+ return rt;
}
void CMpegSplitterFile::SearchPrograms(__int64 start, __int64 stop)
{
- if (m_type != mpeg_ts) {
- return;
- }
-
- Seek(start);
- stop = min(stop, GetLength());
-
- while (GetPos() < stop) {
- trhdr h;
- if (!Read(h)) {
- continue;
- }
-
- UpdatePrograms(h);
- Seek(h.next);
- }
+ if (m_type != mpeg_ts) {
+ return;
+ }
+
+ Seek(start);
+ stop = min(stop, GetLength());
+
+ while (GetPos() < stop) {
+ trhdr h;
+ if (!Read(h)) {
+ continue;
+ }
+
+ UpdatePrograms(h);
+ Seek(h.next);
+ }
}
HRESULT CMpegSplitterFile::SearchStreams(__int64 start, __int64 stop, IAsyncReader* pAsyncReader, BOOL CalcDuration)
{
- Seek(start);
- stop = min(stop, GetLength());
-
- while (GetPos() < stop) {
- BYTE b;
-
- if (m_type == mpeg_ps || m_type == mpeg_es) {
- if (!NextMpegStartCode(b)) {
- continue;
- }
-
- if (b == 0xba) { // program stream header
- pshdr h;
- if (!Read(h)) {
- continue;
- }
- m_rate = int(h.bitrate/8);
- } else if (b == 0xbb) { // program stream system header
- pssyshdr h;
- if (!Read(h)) {
- continue;
- }
- }
- else if ((b >= 0xbd && b < 0xf0) || (b == 0xfd)) { // pes packet
- peshdr h;
- if (!Read(h, b)) {
- continue;
- }
-
- if (h.type == mpeg2 && h.scrambling) {
- ASSERT(0);
- return E_FAIL;
- }
-
- if (h.fpts) {
- if (m_rtMin == _I64_MAX) {
- m_rtMin = h.pts;
- m_posMin = GetPos();
- TRACE ("m_rtMin(SearchStreams)=%S\n", ReftimeToString(m_rtMin));
- }
- if (m_rtMin < h.pts && m_rtMax < h.pts) {
- m_rtMax = h.pts;
- m_posMax = GetPos();
- TRACE ("m_rtMax(SearchStreams)=%S\n", ReftimeToString(m_rtMax));
- }
- }
-
- __int64 pos = GetPos();
- AddStream(0, b, h.id_ext, h.len);
- if (h.len) {
- Seek(pos + h.len);
- }
- }
- } else if (m_type == mpeg_ts) {
- trhdr h;
- if (!Read(h)) {
- continue;
- }
-
- __int64 pos = GetPos();
-
- //UpdatePrograms(h);
-
- if (h.payload && ISVALIDPID(h.pid)) {
- peshdr h2;
- if (h.payloadstart && NextMpegStartCode(b, 4) && Read(h2, b)) { // pes packet
- if (h2.type == mpeg2 && h2.scrambling) {
- ASSERT(0);
- return E_FAIL;
- }
-
- if (h2.fpts && CalcDuration && (m_AlternativeDuration || (GetMasterStream() && GetMasterStream()->GetHead() == h.pid))) {
- if ((m_rtMin == _I64_MAX) || (m_rtMin > h2.pts)) {
- m_rtMin = h2.pts;
- m_posMin = GetPos();
- TRACE ("m_rtMin(SearchStreams)=%S, PID=%d\n", ReftimeToString(m_rtMin), h.pid);
- }
-
- if (m_rtMin < h2.pts && m_rtMax < h2.pts) {
- m_rtMax = h2.pts;
- m_posMax = GetPos();
- TRACE ("m_rtMax(SearchStreams)=%S, PID=%d\n", ReftimeToString(m_rtMax), h.pid);
- // Ugly code : to support BRD H264 seamless playback, CMultiFiles need to update m_rtPTSOffset variable
- // each time a new part is open...
- // use this code only if Blu-ray is detected
- if (m_ClipInfo.IsHdmv()) {
- for (size_t i=0; i<m_ClipInfo.GetStreamNumber(); i++) {
- CHdmvClipInfo::Stream* stream = m_ClipInfo.GetStreamByIndex(i);
- if (stream->m_Type == VIDEO_STREAM_H264 && m_rtMin == 116506666) {
- CComQIPtr<ISyncReader> pReader = pAsyncReader;
- if (pReader) pReader->SetPTSOffset (&m_rtPTSOffset);
- //TRACE ("UPDATE m_rtPTSOffset(SearchStreams)=%S\n", ReftimeToString(m_rtPTSOffset));
- //TRACE ("m_rtMin(Boucle)=%S\n", ReftimeToString(m_rtMin));
- //TRACE ("stream=%d\n", stream->m_Type);
- //TRACE ("m_rtMax(Boucle)=%S\n", ReftimeToString(m_rtMax));
- //TRACE ("m_rtMax - m_rtMin(Boucle)=%S\n", ReftimeToString(m_rtMax - m_rtMin));
- }
- }
- }
- }
- }
- } else {
- b = 0;
- }
-
- if (!CalcDuration) {
- AddStream(h.pid, b, 0, DWORD(h.bytes - (GetPos() - pos)));
- }
- }
-
- Seek(h.next);
- } else if (m_type == mpeg_pva) {
- pvahdr h;
- if (!Read(h)) {
- continue;
- }
-
- if (h.fpts) {
- if (m_rtMin == _I64_MAX) {
- m_rtMin = h.pts;
- m_posMin = GetPos();
- }
-
- if (m_rtMin < h.pts && m_rtMax < h.pts) {
- m_rtMax = h.pts;
- m_posMax = GetPos();
- }
- }
-
- __int64 pos = GetPos();
-
- if (h.streamid == 1) {
- AddStream(h.streamid, 0xe0, 0, h.length);
- } else if (h.streamid == 2) {
- AddStream(h.streamid, 0xc0, 0, h.length);
- }
-
- if (h.length) {
- Seek(pos + h.length);
- }
- }
- }
-
- return S_OK;
+ Seek(start);
+ stop = min(stop, GetLength());
+
+ while (GetPos() < stop) {
+ BYTE b;
+
+ if (m_type == mpeg_ps || m_type == mpeg_es) {
+ if (!NextMpegStartCode(b)) {
+ continue;
+ }
+
+ if (b == 0xba) { // program stream header
+ pshdr h;
+ if (!Read(h)) {
+ continue;
+ }
+ m_rate = int(h.bitrate / 8);
+ } else if (b == 0xbb) { // program stream system header
+ pssyshdr h;
+ if (!Read(h)) {
+ continue;
+ }
+ } else if ((b >= 0xbd && b < 0xf0) || (b == 0xfd)) { // pes packet
+ peshdr h;
+ if (!Read(h, b)) {
+ continue;
+ }
+
+ if (h.type == mpeg2 && h.scrambling) {
+ ASSERT(0);
+ return E_FAIL;
+ }
+
+ if (h.fpts) {
+ if (m_rtMin == _I64_MAX) {
+ m_rtMin = h.pts;
+ m_posMin = GetPos();
+ TRACE("m_rtMin(SearchStreams)=%S\n", ReftimeToString(m_rtMin));
+ }
+ if (m_rtMin < h.pts && m_rtMax < h.pts) {
+ m_rtMax = h.pts;
+ m_posMax = GetPos();
+ TRACE("m_rtMax(SearchStreams)=%S\n", ReftimeToString(m_rtMax));
+ }
+ }
+
+ __int64 pos = GetPos();
+ AddStream(0, b, h.id_ext, h.len);
+ if (h.len) {
+ Seek(pos + h.len);
+ }
+ }
+ } else if (m_type == mpeg_ts) {
+ trhdr h;
+ if (!Read(h)) {
+ continue;
+ }
+
+ __int64 pos = GetPos();
+
+ //UpdatePrograms(h);
+
+ if (h.payload && ISVALIDPID(h.pid)) {
+ peshdr h2;
+ if (h.payloadstart && NextMpegStartCode(b, 4) && Read(h2, b)) { // pes packet
+ if (h2.type == mpeg2 && h2.scrambling) {
+ ASSERT(0);
+ return E_FAIL;
+ }
+
+ if (h2.fpts && CalcDuration && (m_AlternativeDuration || (GetMasterStream() && GetMasterStream()->GetHead() == h.pid))) {
+ if ((m_rtMin == _I64_MAX) || (m_rtMin > h2.pts)) {
+ m_rtMin = h2.pts;
+ m_posMin = GetPos();
+ TRACE("m_rtMin(SearchStreams)=%S, PID=%d\n", ReftimeToString(m_rtMin), h.pid);
+ }
+
+ if (m_rtMin < h2.pts && m_rtMax < h2.pts) {
+ m_rtMax = h2.pts;
+ m_posMax = GetPos();
+ TRACE("m_rtMax(SearchStreams)=%S, PID=%d\n", ReftimeToString(m_rtMax), h.pid);
+ // Ugly code : to support BRD H264 seamless playback, CMultiFiles need to update m_rtPTSOffset variable
+ // each time a new part is open...
+ // use this code only if Blu-ray is detected
+ if (m_ClipInfo.IsHdmv()) {
+ for (size_t i = 0; i < m_ClipInfo.GetStreamNumber(); i++) {
+ CHdmvClipInfo::Stream* stream = m_ClipInfo.GetStreamByIndex(i);
+ if (stream->m_Type == VIDEO_STREAM_H264 && m_rtMin == 116506666) {
+ CComQIPtr<ISyncReader> pReader = pAsyncReader;
+ if (pReader) { pReader->SetPTSOffset(&m_rtPTSOffset); }
+ //TRACE ("UPDATE m_rtPTSOffset(SearchStreams)=%S\n", ReftimeToString(m_rtPTSOffset));
+ //TRACE ("m_rtMin(Boucle)=%S\n", ReftimeToString(m_rtMin));
+ //TRACE ("stream=%d\n", stream->m_Type);
+ //TRACE ("m_rtMax(Boucle)=%S\n", ReftimeToString(m_rtMax));
+ //TRACE ("m_rtMax - m_rtMin(Boucle)=%S\n", ReftimeToString(m_rtMax - m_rtMin));
+ }
+ }
+ }
+ }
+ }
+ } else {
+ b = 0;
+ }
+
+ if (!CalcDuration) {
+ AddStream(h.pid, b, 0, DWORD(h.bytes - (GetPos() - pos)));
+ }
+ }
+
+ Seek(h.next);
+ } else if (m_type == mpeg_pva) {
+ pvahdr h;
+ if (!Read(h)) {
+ continue;
+ }
+
+ if (h.fpts) {
+ if (m_rtMin == _I64_MAX) {
+ m_rtMin = h.pts;
+ m_posMin = GetPos();
+ }
+
+ if (m_rtMin < h.pts && m_rtMax < h.pts) {
+ m_rtMax = h.pts;
+ m_posMax = GetPos();
+ }
+ }
+
+ __int64 pos = GetPos();
+
+ if (h.streamid == 1) {
+ AddStream(h.streamid, 0xe0, 0, h.length);
+ } else if (h.streamid == 2) {
+ AddStream(h.streamid, 0xc0, 0, h.length);
+ }
+
+ if (h.length) {
+ Seek(pos + h.length);
+ }
+ }
+ }
+
+ return S_OK;
}
#define IsMpegAudio(stream_type) (stream_type == AUDIO_STREAM_MPEG1 || stream_type == AUDIO_STREAM_MPEG2)
@@ -527,590 +526,594 @@ HRESULT CMpegSplitterFile::SearchStreams(__int64 start, __int64 stop, IAsyncRead
DWORD CMpegSplitterFile::AddStream(WORD pid, BYTE pesid, BYTE ps1id, DWORD len)
{
- if (pid) {
- if (pesid) {
- m_pid2pes[pid] = pesid;
- } else {
- m_pid2pes.Lookup(pid, pesid);
- }
- }
-
- stream s;
- s.pid = pid;
- s.pesid = pesid;
- s.ps1id = ps1id;
-
- const __int64 start = GetPos();
- int type = unknown;
-
- if (pesid >= 0xe0 && pesid < 0xf0) { // mpeg video
-
- // MPEG2
- if (type == unknown) {
- CMpegSplitterFile::seqhdr h;
- if (!m_streams[video].Find(s) && Read(h, len, &s.mt)) {
- PES_STREAM_TYPE stream_type = INVALID;
- if (GetStreamType(s.pid, stream_type)) {
- if (IsMPEG2Video(stream_type)) {
- type = video;
- }
- } else {
- type = video;
- }
- }
- }
-
- // H.264
- if (type == unknown) {
- Seek(start);
- // PPS and SPS can be present on differents packets
- // and can also be split into multiple packets
- if (!avch.Lookup(pid))
- memset(&avch[pid], 0, sizeof(CMpegSplitterFile::avchdr));
+ if (pid) {
+ if (pesid) {
+ m_pid2pes[pid] = pesid;
+ } else {
+ m_pid2pes.Lookup(pid, pesid);
+ }
+ }
+
+ stream s;
+ s.pid = pid;
+ s.pesid = pesid;
+ s.ps1id = ps1id;
+
+ const __int64 start = GetPos();
+ int type = unknown;
+
+ if (pesid >= 0xe0 && pesid < 0xf0) { // mpeg video
+
+ // MPEG2
+ if (type == unknown) {
+ CMpegSplitterFile::seqhdr h;
+ if (!m_streams[video].Find(s) && Read(h, len, &s.mt)) {
+ PES_STREAM_TYPE stream_type = INVALID;
+ if (GetStreamType(s.pid, stream_type)) {
+ if (IsMPEG2Video(stream_type)) {
+ type = video;
+ }
+ } else {
+ type = video;
+ }
+ }
+ }
+
+ // H.264
+ if (type == unknown) {
+ Seek(start);
+ // PPS and SPS can be present on differents packets
+ // and can also be split into multiple packets
+ if (!avch.Lookup(pid)) {
+ memset(&avch[pid], 0, sizeof(CMpegSplitterFile::avchdr));
+ }
#if defined(MVC_SUPPORT)
- if (!m_streams[video].Find(s) && !m_streams[stereo].Find(s) && Read(avch[pid], len, &s.mt))
- {
- if (avch[pid].spspps[index_subsetsps].complete)
- type = stereo;
- else
- type = video;
- }
+ if (!m_streams[video].Find(s) && !m_streams[stereo].Find(s) && Read(avch[pid], len, &s.mt)) {
+ if (avch[pid].spspps[index_subsetsps].complete) {
+ type = stereo;
+ } else {
+ type = video;
+ }
+ }
#else
- if (!m_streams[video].Find(s) && Read(avch[pid], len, &s.mt)) {
- PES_STREAM_TYPE stream_type = INVALID;
- if (GetStreamType(s.pid, stream_type)) {
- if (IsH264Video(stream_type)) {
- type = video;
- }
- } else {
- type = video;
- }
- }
+ if (!m_streams[video].Find(s) && Read(avch[pid], len, &s.mt)) {
+ PES_STREAM_TYPE stream_type = INVALID;
+ if (GetStreamType(s.pid, stream_type)) {
+ if (IsH264Video(stream_type)) {
+ type = video;
+ }
+ } else {
+ type = video;
+ }
+ }
#endif
- }
- } else if (pesid >= 0xc0 && pesid < 0xe0) { // mpeg audio
-
- // MPEG Audio
- if (type == unknown) {
- CMpegSplitterFile::aachdr h;
- if (!m_streams[audio].Find(s) && Read(h, len, &s.mt, m_type)) {
- PES_STREAM_TYPE stream_type = INVALID;
- if (GetStreamType(s.pid, stream_type)) {
- if (IsAACAudio(stream_type)) {
- type = audio;
- }
- } else {
- type = audio;
- }
- }
- }
-
- // AAC
- if (type == unknown) {
- Seek(start);
- CMpegSplitterFile::mpahdr h;
- if (!m_streams[audio].Find(s) && Read(h, len, false, &s.mt)) {
- PES_STREAM_TYPE stream_type = INVALID;
- if (GetStreamType(s.pid, stream_type)) {
- if (IsMpegAudio(stream_type)) {
- type = audio;
- }
- } else {
- type = audio;
- }
- }
- }
- } else if (pesid == 0xbd || pesid == 0xfd) { // private stream 1
- if (s.pid) {
- if (!m_streams[audio].Find(s) && !m_streams[video].Find(s)) {
-
- // AC3, E-AC3, TrueHD
- if (type == unknown) {
- CMpegSplitterFile::ac3hdr h;
- if (Read(h, len, &s.mt, true, (m_AC3CoreOnly == 1))) {
- PES_STREAM_TYPE stream_type = INVALID;
- if (GetStreamType(s.pid, stream_type)) {
- if (IsAC3Audio(stream_type)) {
- type = audio;
- }
- } else {
- type = audio;
- }
- }
- }
-
- // DTS, DTS HD, DTS HD MA
- if (type == unknown) {
- Seek(start);
- CMpegSplitterFile::dtshdr h;
- if (Read(h, len, &s.mt, false)) {
- type = audio;
- }
- }
-
- // VC1
- if (type == unknown) {
- Seek(start);
- CMpegSplitterFile::vc1hdr h;
- if (!m_streams[video].Find(s) && Read(h, len, &s.mt, m_nVC1_GuidFlag)) {
- PES_STREAM_TYPE stream_type = INVALID;
- if (GetStreamType(s.pid, stream_type)) {
- if (IsVC1Video(stream_type)) {
- type = video;
- }
- } else {
- type = video;
- }
- }
- }
-
- // DVB subtitles
- if (type == unknown) {
- Seek(start);
- CMpegSplitterFile::dvbsub h;
- if (!m_streams[video].Find(s) && Read(h, len, &s.mt)) {
- type = subpic;
- }
- }
-
- int iProgram;
- const CHdmvClipInfo::Stream *pClipInfo;
- const program* pProgram = FindProgram (s.pid, iProgram, pClipInfo);
- if ((type == unknown) && (pProgram != NULL)) {
- PES_STREAM_TYPE StreamType = INVALID;
-
- Seek(start);
- StreamType = pProgram->streams[iProgram].type;
-
- switch (StreamType) {
- case AUDIO_STREAM_LPCM : {
- CMpegSplitterFile::hdmvlpcmhdr h;
- if (!m_streams[audio].Find(s) && Read(h, &s.mt)) {
- type = audio;
- }
- }
- break;
- case PRESENTATION_GRAPHICS_STREAM : {
- CMpegSplitterFile::hdmvsubhdr h;
- if (!m_streams[subpic].Find(s) && Read(h, &s.mt, pClipInfo ? pClipInfo->m_LanguageCode : NULL)) {
- m_bIsHdmv = true;
- type = subpic;
- }
- }
- break;
- }
- }
- } else if ((m_AC3CoreOnly != 1) && m_init) {
- int iProgram;
- const CHdmvClipInfo::Stream *pClipInfo;
- const program* pProgram = FindProgram (s.pid, iProgram, pClipInfo);
- if ((type == unknown) && (pProgram != NULL) && AUDIO_STREAM_AC3_TRUE_HD == pProgram->streams[iProgram].type) {
- const stream* source = m_streams[audio].FindStream(s.pid);
- if (source && source->mt.subtype == MEDIASUBTYPE_DOLBY_AC3) {
- CMpegSplitterFile::ac3hdr h;
- if (Read(h, len, &s.mt, false, (m_AC3CoreOnly == 1)) && s.mt.subtype == MEDIASUBTYPE_DOLBY_TRUEHD) {
- m_streams[audio].Replace((stream&)*source, s, this);
- }
- }
- }
- }
- } else if (pesid == 0xfd) {
- CMpegSplitterFile::vc1hdr h;
- if (!m_streams[video].Find(s) && Read(h, len, &s.mt, m_nVC1_GuidFlag)) {
- type = video;
- }
- } else {
- BYTE b = (BYTE)BitRead(8, true);
- WORD w = (WORD)BitRead(16, true);
- DWORD dw = (DWORD)BitRead(32, true);
-
- if (b >= 0x80 && b < 0x88 || w == 0x0b77) { // ac3
- s.ps1id = (b >= 0x80 && b < 0x88) ? (BYTE)(BitRead(32) >> 24) : 0x80;
-
- CMpegSplitterFile::ac3hdr h;
- if (!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
- type = audio;
- }
- } else if (b >= 0x88 && b < 0x90 || dw == 0x7ffe8001) { // dts
- s.ps1id = (b >= 0x88 && b < 0x90) ? (BYTE)(BitRead(32) >> 24) : 0x88;
-
- CMpegSplitterFile::dtshdr h;
- if (!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
- type = audio;
- }
- } else if (b >= 0xa0 && b < 0xa8) { // lpcm
- s.ps1id = (BYTE)BitRead(8);
-
- do {
- // DVD-Audio LPCM
- if (b == 0xa0) {
- BitRead(8); // Continuity Counter - counts from 0x00 to 0x1f and then wraps to 0x00.
- DWORD headersize = (DWORD)BitRead(16); // LPCM_header_length
- if (headersize >= 8 && headersize+4 < len) {
- CMpegSplitterFile::dvdalpcmhdr h;
- if (Read(h, len-4, &s.mt)) {
- Seek(start + 4 + headersize);
- type = audio;
- break;
- }
- }
- }
- // DVD-Audio MLP
- else if (b == 0xa1 && len > 10) {
- BYTE counter = (BYTE)BitRead(8); // Continuity Counter: 0x00..0x1f or 0x20..0x3f or 0x40..0x5f
- BitRead(8); // some unknown data
- DWORD headersize = (DWORD)BitRead(8); // MLP_header_length (always equal 6?)
- BitRead(32); // some unknown data
- WORD unknown1 = (WORD)BitRead(16); // 0x0000 or 0x0400
- if (counter <= 0x5f && headersize == 6 && (unknown1 == 0x0000 || unknown1 == 0x0400)) { // Maybe it's MLP?
- // MLP header may be missing in the first package
- CMpegSplitterFile::mlphdr h;
- if (!m_streams[audio].Find(s) && Read(h, len-10, &s.mt, true)) {
- // This is exactly the MLP.
- Seek(start + 10);
- type = audio;
- }
- Seek(start + 10);
- break;
- }
- }
-
- // DVD LPCM
- if (m_streams[audio].Find(s)) {
- Seek(start + 7);
- } else {
- Seek(start + 4);
- CMpegSplitterFile::lpcmhdr h;
- if (Read(h, &s.mt)) {
- type = audio;
- }
- }
- } while (false);
- } else if (b >= 0x20 && b < 0x40) { // DVD subpic
- s.ps1id = (BYTE)BitRead(8);
-
- CMpegSplitterFile::dvdspuhdr h;
- if (!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
- type = subpic;
- }
- } else if (b >= 0x70 && b < 0x80) { // SVCD subpic
- s.ps1id = (BYTE)BitRead(8);
-
- CMpegSplitterFile::svcdspuhdr h;
- if (!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
- type = subpic;
- }
- } else if (b >= 0x00 && b < 0x10) { // CVD subpic
- s.ps1id = (BYTE)BitRead(8);
-
- CMpegSplitterFile::cvdspuhdr h;
- if (!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
- type = subpic;
- }
- } else if (w == 0xffa0 || w == 0xffa1) { // ps2-mpg audio
- s.ps1id = (BYTE)BitRead(8);
- s.pid = (WORD)((BitRead(8) << 8) | BitRead(16)); // pid = 0xa000 | track id
-
- CMpegSplitterFile::ps2audhdr h;
- if (!m_streams[audio].Find(s) && Read(h, &s.mt)) {
- type = audio;
- }
- } else if (w == 0xff90) { // ps2-mpg ac3 or subtitles
- s.ps1id = (BYTE)BitRead(8);
- s.pid = (WORD)((BitRead(8) << 8) | BitRead(16)); // pid = 0x9000 | track id
-
- w = (WORD)BitRead(16, true);
-
- if (w == 0x0b77) {
- CMpegSplitterFile::ac3hdr h;
- if (!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
- type = audio;
- }
- } else if (w == 0x0000) { // usually zero...
- CMpegSplitterFile::ps2subhdr h;
- if (!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
- type = subpic;
- }
- }
- } else if (b >= 0xc0 && b < 0xcf) { // dolby digital/dolby digital +
- s.ps1id = (BYTE)BitRead(8);
- // skip audio header - 3-byte
- BitRead(8);
- BitRead(8);
- BitRead(8);
- CMpegSplitterFile::ac3hdr h;
- if (!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
- type = audio;
- }
- } else if (b >= 0xb0 && b < 0xbf) { // truehd
- s.ps1id = (BYTE)BitRead(8);
- // skip audio header - 3-byte
- BitRead(8);
- BitRead(8);
- BitRead(8);
- // TrueHD audio has a 4-byte header
- BitRead(8);
- CMpegSplitterFile::ac3hdr h;
- if (!m_streams[audio].Find(s) && Read(h, len, &s.mt, false, false)) {
- type = audio;
- }
- }
- }
- } else if (pesid == 0xbe) { // padding
- } else if (pesid == 0xbf) { // private stream 2
- }
-
- if (type != unknown && !m_streams[type].Find(s)) {
- if (s.pid) {
- for (int i = 0; i < unknown; i++) {
- if (m_streams[i].Find(s)) {
- return s;
- }
- }
- }
-
- m_streams[type].Insert(s, this);
- }
-
- return s;
+ }
+ } else if (pesid >= 0xc0 && pesid < 0xe0) { // mpeg audio
+
+ // MPEG Audio
+ if (type == unknown) {
+ CMpegSplitterFile::aachdr h;
+ if (!m_streams[audio].Find(s) && Read(h, len, &s.mt, m_type)) {
+ PES_STREAM_TYPE stream_type = INVALID;
+ if (GetStreamType(s.pid, stream_type)) {
+ if (IsAACAudio(stream_type)) {
+ type = audio;
+ }
+ } else {
+ type = audio;
+ }
+ }
+ }
+
+ // AAC
+ if (type == unknown) {
+ Seek(start);
+ CMpegSplitterFile::mpahdr h;
+ if (!m_streams[audio].Find(s) && Read(h, len, false, &s.mt)) {
+ PES_STREAM_TYPE stream_type = INVALID;
+ if (GetStreamType(s.pid, stream_type)) {
+ if (IsMpegAudio(stream_type)) {
+ type = audio;
+ }
+ } else {
+ type = audio;
+ }
+ }
+ }
+ } else if (pesid == 0xbd || pesid == 0xfd) { // private stream 1
+ if (s.pid) {
+ if (!m_streams[audio].Find(s) && !m_streams[video].Find(s)) {
+
+ // AC3, E-AC3, TrueHD
+ if (type == unknown) {
+ CMpegSplitterFile::ac3hdr h;
+ if (Read(h, len, &s.mt, true, (m_AC3CoreOnly == 1))) {
+ PES_STREAM_TYPE stream_type = INVALID;
+ if (GetStreamType(s.pid, stream_type)) {
+ if (IsAC3Audio(stream_type)) {
+ type = audio;
+ }
+ } else {
+ type = audio;
+ }
+ }
+ }
+
+ // DTS, DTS HD, DTS HD MA
+ if (type == unknown) {
+ Seek(start);
+ CMpegSplitterFile::dtshdr h;
+ if (Read(h, len, &s.mt, false)) {
+ type = audio;
+ }
+ }
+
+ // VC1
+ if (type == unknown) {
+ Seek(start);
+ CMpegSplitterFile::vc1hdr h;
+ if (!m_streams[video].Find(s) && Read(h, len, &s.mt, m_nVC1_GuidFlag)) {
+ PES_STREAM_TYPE stream_type = INVALID;
+ if (GetStreamType(s.pid, stream_type)) {
+ if (IsVC1Video(stream_type)) {
+ type = video;
+ }
+ } else {
+ type = video;
+ }
+ }
+ }
+
+ // DVB subtitles
+ if (type == unknown) {
+ Seek(start);
+ CMpegSplitterFile::dvbsub h;
+ if (!m_streams[video].Find(s) && Read(h, len, &s.mt)) {
+ type = subpic;
+ }
+ }
+
+ int iProgram;
+ const CHdmvClipInfo::Stream* pClipInfo;
+ const program* pProgram = FindProgram(s.pid, iProgram, pClipInfo);
+ if ((type == unknown) && (pProgram != NULL)) {
+ PES_STREAM_TYPE StreamType = INVALID;
+
+ Seek(start);
+ StreamType = pProgram->streams[iProgram].type;
+
+ switch (StreamType) {
+ case AUDIO_STREAM_LPCM : {
+ CMpegSplitterFile::hdmvlpcmhdr h;
+ if (!m_streams[audio].Find(s) && Read(h, &s.mt)) {
+ type = audio;
+ }
+ }
+ break;
+ case PRESENTATION_GRAPHICS_STREAM : {
+ CMpegSplitterFile::hdmvsubhdr h;
+ if (!m_streams[subpic].Find(s) && Read(h, &s.mt, pClipInfo ? pClipInfo->m_LanguageCode : NULL)) {
+ m_bIsHdmv = true;
+ type = subpic;
+ }
+ }
+ break;
+ }
+ }
+ } else if ((m_AC3CoreOnly != 1) && m_init) {
+ int iProgram;
+ const CHdmvClipInfo::Stream* pClipInfo;
+ const program* pProgram = FindProgram(s.pid, iProgram, pClipInfo);
+ if ((type == unknown) && (pProgram != NULL) && AUDIO_STREAM_AC3_TRUE_HD == pProgram->streams[iProgram].type) {
+ const stream* source = m_streams[audio].FindStream(s.pid);
+ if (source && source->mt.subtype == MEDIASUBTYPE_DOLBY_AC3) {
+ CMpegSplitterFile::ac3hdr h;
+ if (Read(h, len, &s.mt, false, (m_AC3CoreOnly == 1)) && s.mt.subtype == MEDIASUBTYPE_DOLBY_TRUEHD) {
+ m_streams[audio].Replace((stream&)*source, s, this);
+ }
+ }
+ }
+ }
+ } else if (pesid == 0xfd) {
+ CMpegSplitterFile::vc1hdr h;
+ if (!m_streams[video].Find(s) && Read(h, len, &s.mt, m_nVC1_GuidFlag)) {
+ type = video;
+ }
+ } else {
+ BYTE b = (BYTE)BitRead(8, true);
+ WORD w = (WORD)BitRead(16, true);
+ DWORD dw = (DWORD)BitRead(32, true);
+
+ if (b >= 0x80 && b < 0x88 || w == 0x0b77) { // ac3
+ s.ps1id = (b >= 0x80 && b < 0x88) ? (BYTE)(BitRead(32) >> 24) : 0x80;
+
+ CMpegSplitterFile::ac3hdr h;
+ if (!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
+ type = audio;
+ }
+ } else if (b >= 0x88 && b < 0x90 || dw == 0x7ffe8001) { // dts
+ s.ps1id = (b >= 0x88 && b < 0x90) ? (BYTE)(BitRead(32) >> 24) : 0x88;
+
+ CMpegSplitterFile::dtshdr h;
+ if (!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
+ type = audio;
+ }
+ } else if (b >= 0xa0 && b < 0xa8) { // lpcm
+ s.ps1id = (BYTE)BitRead(8);
+
+ do {
+ // DVD-Audio LPCM
+ if (b == 0xa0) {
+ BitRead(8); // Continuity Counter - counts from 0x00 to 0x1f and then wraps to 0x00.
+ DWORD headersize = (DWORD)BitRead(16); // LPCM_header_length
+ if (headersize >= 8 && headersize + 4 < len) {
+ CMpegSplitterFile::dvdalpcmhdr h;
+ if (Read(h, len - 4, &s.mt)) {
+ Seek(start + 4 + headersize);
+ type = audio;
+ break;
+ }
+ }
+ }
+ // DVD-Audio MLP
+ else if (b == 0xa1 && len > 10) {
+ BYTE counter = (BYTE)BitRead(8); // Continuity Counter: 0x00..0x1f or 0x20..0x3f or 0x40..0x5f
+ BitRead(8); // some unknown data
+ DWORD headersize = (DWORD)BitRead(8); // MLP_header_length (always equal 6?)
+ BitRead(32); // some unknown data
+ WORD unknown1 = (WORD)BitRead(16); // 0x0000 or 0x0400
+ if (counter <= 0x5f && headersize == 6 && (unknown1 == 0x0000 || unknown1 == 0x0400)) { // Maybe it's MLP?
+ // MLP header may be missing in the first package
+ CMpegSplitterFile::mlphdr h;
+ if (!m_streams[audio].Find(s) && Read(h, len - 10, &s.mt, true)) {
+ // This is exactly the MLP.
+ Seek(start + 10);
+ type = audio;
+ }
+ Seek(start + 10);
+ break;
+ }
+ }
+
+ // DVD LPCM
+ if (m_streams[audio].Find(s)) {
+ Seek(start + 7);
+ } else {
+ Seek(start + 4);
+ CMpegSplitterFile::lpcmhdr h;
+ if (Read(h, &s.mt)) {
+ type = audio;
+ }
+ }
+ } while (false);
+ } else if (b >= 0x20 && b < 0x40) { // DVD subpic
+ s.ps1id = (BYTE)BitRead(8);
+
+ CMpegSplitterFile::dvdspuhdr h;
+ if (!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
+ type = subpic;
+ }
+ } else if (b >= 0x70 && b < 0x80) { // SVCD subpic
+ s.ps1id = (BYTE)BitRead(8);
+
+ CMpegSplitterFile::svcdspuhdr h;
+ if (!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
+ type = subpic;
+ }
+ } else if (b >= 0x00 && b < 0x10) { // CVD subpic
+ s.ps1id = (BYTE)BitRead(8);
+
+ CMpegSplitterFile::cvdspuhdr h;
+ if (!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
+ type = subpic;
+ }
+ } else if (w == 0xffa0 || w == 0xffa1) { // ps2-mpg audio
+ s.ps1id = (BYTE)BitRead(8);
+ s.pid = (WORD)((BitRead(8) << 8) | BitRead(16)); // pid = 0xa000 | track id
+
+ CMpegSplitterFile::ps2audhdr h;
+ if (!m_streams[audio].Find(s) && Read(h, &s.mt)) {
+ type = audio;
+ }
+ } else if (w == 0xff90) { // ps2-mpg ac3 or subtitles
+ s.ps1id = (BYTE)BitRead(8);
+ s.pid = (WORD)((BitRead(8) << 8) | BitRead(16)); // pid = 0x9000 | track id
+
+ w = (WORD)BitRead(16, true);
+
+ if (w == 0x0b77) {
+ CMpegSplitterFile::ac3hdr h;
+ if (!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
+ type = audio;
+ }
+ } else if (w == 0x0000) { // usually zero...
+ CMpegSplitterFile::ps2subhdr h;
+ if (!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
+ type = subpic;
+ }
+ }
+ } else if (b >= 0xc0 && b < 0xcf) { // dolby digital/dolby digital +
+ s.ps1id = (BYTE)BitRead(8);
+ // skip audio header - 3-byte
+ BitRead(8);
+ BitRead(8);
+ BitRead(8);
+ CMpegSplitterFile::ac3hdr h;
+ if (!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
+ type = audio;
+ }
+ } else if (b >= 0xb0 && b < 0xbf) { // truehd
+ s.ps1id = (BYTE)BitRead(8);
+ // skip audio header - 3-byte
+ BitRead(8);
+ BitRead(8);
+ BitRead(8);
+ // TrueHD audio has a 4-byte header
+ BitRead(8);
+ CMpegSplitterFile::ac3hdr h;
+ if (!m_streams[audio].Find(s) && Read(h, len, &s.mt, false, false)) {
+ type = audio;
+ }
+ }
+ }
+ } else if (pesid == 0xbe) { // padding
+ } else if (pesid == 0xbf) { // private stream 2
+ }
+
+ if (type != unknown && !m_streams[type].Find(s)) {
+ if (s.pid) {
+ for (int i = 0; i < unknown; i++) {
+ if (m_streams[i].Find(s)) {
+ return s;
+ }
+ }
+ }
+
+ m_streams[type].Insert(s, this);
+ }
+
+ return s;
}
void CMpegSplitterFile::AddHdmvPGStream(WORD pid, const char* language_code)
{
- stream s;
+ stream s;
- s.pid = pid;
- s.pesid = 0xbd;
+ s.pid = pid;
+ s.pesid = 0xbd;
- CMpegSplitterFile::hdmvsubhdr h;
- if (!m_streams[subpic].Find(s) && Read(h, &s.mt, language_code)) {
- m_streams[subpic].Insert(s, this);
- }
+ CMpegSplitterFile::hdmvsubhdr h;
+ if (!m_streams[subpic].Find(s) && Read(h, &s.mt, language_code)) {
+ m_streams[subpic].Insert(s, this);
+ }
}
CAtlList<CMpegSplitterFile::stream>* CMpegSplitterFile::GetMasterStream()
{
- return
- !m_streams[video].IsEmpty() ? &m_streams[video] :
- !m_streams[audio].IsEmpty() ? &m_streams[audio] :
- !m_streams[subpic].IsEmpty() ? &m_streams[subpic] :
+ return
+ !m_streams[video].IsEmpty() ? &m_streams[video] :
+ !m_streams[audio].IsEmpty() ? &m_streams[audio] :
+ !m_streams[subpic].IsEmpty() ? &m_streams[subpic] :
#if defined(MVC_SUPPORT)
- !m_streams[stereo].IsEmpty() ? &m_streams[stereo] :
+ !m_streams[stereo].IsEmpty() ? &m_streams[stereo] :
#endif
- NULL;
+ NULL;
}
void CMpegSplitterFile::UpdatePrograms(const trhdr& h, bool UpdateLang)
{
- CAutoLock cAutoLock(&m_csProps);
-
- if (h.payload && h.payloadstart && h.pid == 0) {
- trsechdr h2;
- if (Read(h2) && h2.table_id == 0) {
- CAtlMap<WORD, bool> newprograms;
-
- int len = h2.section_length;
- len -= 5+4;
-
- for (int i = len/4; i > 0; i--) {
- WORD program_number = (WORD)BitRead(16);
- BYTE reserved = (BYTE)BitRead(3);
- WORD pid = (WORD)BitRead(13);
- UNREFERENCED_PARAMETER(reserved);
- if (program_number != 0) {
- m_programs[pid].program_number = program_number;
- newprograms[program_number] = true;
- }
- }
-
- POSITION pos = m_programs.GetStartPosition();
- while (pos) {
- const CAtlMap<WORD, program>::CPair* pPair = m_programs.GetNext(pos);
-
- if (!newprograms.Lookup(pPair->m_value.program_number)) {
- m_programs.RemoveKey(pPair->m_key);
- }
- }
- }
- } else if (CAtlMap<WORD, program>::CPair* pPair = m_programs.Lookup(h.pid)) {
- if (h.payload && h.payloadstart) {
- trsechdr h2;
- if (Read(h2) && h2.table_id == 2) {
- int len = h2.section_length;
- len -= 5+4;
-
- BYTE buffer[1024];
- ByteRead(buffer, len);
- CGolombBuffer gb(buffer, len);
-
- int max_len = h.bytes - 9;
-
- if (len > max_len) {
- memset(pPair->m_value.ts_buffer, 0, sizeof(pPair->m_value.ts_buffer));
- pPair->m_value.ts_len_cur = max_len;
- pPair->m_value.ts_len_packet = len;
- memcpy(pPair->m_value.ts_buffer, buffer, max_len);
- } else {
- CGolombBuffer gb(buffer, len);
- UpdatePrograms(gb, h.pid, UpdateLang);
- }
- }
- } else {
- if (pPair->m_value.ts_len_cur > 0) {
- int len = pPair->m_value.ts_len_packet - pPair->m_value.ts_len_cur;
- if (len > h.bytes) {
- ByteRead(pPair->m_value.ts_buffer + pPair->m_value.ts_len_cur, h.bytes);
- pPair->m_value.ts_len_cur += h.bytes;
- } else {
- ByteRead(pPair->m_value.ts_buffer + pPair->m_value.ts_len_cur, pPair->m_value.ts_len_packet - pPair->m_value.ts_len_cur);
- CGolombBuffer gb(pPair->m_value.ts_buffer, pPair->m_value.ts_len_packet);
- UpdatePrograms(gb, h.pid, UpdateLang);
- }
- }
- }
- }
+ CAutoLock cAutoLock(&m_csProps);
+
+ if (h.payload && h.payloadstart && h.pid == 0) {
+ trsechdr h2;
+ if (Read(h2) && h2.table_id == 0) {
+ CAtlMap<WORD, bool> newprograms;
+
+ int len = h2.section_length;
+ len -= 5 + 4;
+
+ for (int i = len / 4; i > 0; i--) {
+ WORD program_number = (WORD)BitRead(16);
+ BYTE reserved = (BYTE)BitRead(3);
+ WORD pid = (WORD)BitRead(13);
+ UNREFERENCED_PARAMETER(reserved);
+ if (program_number != 0) {
+ m_programs[pid].program_number = program_number;
+ newprograms[program_number] = true;
+ }
+ }
+
+ POSITION pos = m_programs.GetStartPosition();
+ while (pos) {
+ const CAtlMap<WORD, program>::CPair* pPair = m_programs.GetNext(pos);
+
+ if (!newprograms.Lookup(pPair->m_value.program_number)) {
+ m_programs.RemoveKey(pPair->m_key);
+ }
+ }
+ }
+ } else if (CAtlMap<WORD, program>::CPair* pPair = m_programs.Lookup(h.pid)) {
+ if (h.payload && h.payloadstart) {
+ trsechdr h2;
+ if (Read(h2) && h2.table_id == 2) {
+ int len = h2.section_length;
+ len -= 5 + 4;
+
+ BYTE buffer[1024];
+ ByteRead(buffer, len);
+ CGolombBuffer gb(buffer, len);
+
+ int max_len = h.bytes - 9;
+
+ if (len > max_len) {
+ memset(pPair->m_value.ts_buffer, 0, sizeof(pPair->m_value.ts_buffer));
+ pPair->m_value.ts_len_cur = max_len;
+ pPair->m_value.ts_len_packet = len;
+ memcpy(pPair->m_value.ts_buffer, buffer, max_len);
+ } else {
+ CGolombBuffer gb(buffer, len);
+ UpdatePrograms(gb, h.pid, UpdateLang);
+ }
+ }
+ } else {
+ if (pPair->m_value.ts_len_cur > 0) {
+ int len = pPair->m_value.ts_len_packet - pPair->m_value.ts_len_cur;
+ if (len > h.bytes) {
+ ByteRead(pPair->m_value.ts_buffer + pPair->m_value.ts_len_cur, h.bytes);
+ pPair->m_value.ts_len_cur += h.bytes;
+ } else {
+ ByteRead(pPair->m_value.ts_buffer + pPair->m_value.ts_len_cur, pPair->m_value.ts_len_packet - pPair->m_value.ts_len_cur);
+ CGolombBuffer gb(pPair->m_value.ts_buffer, pPair->m_value.ts_len_packet);
+ UpdatePrograms(gb, h.pid, UpdateLang);
+ }
+ }
+ }
+ }
}
void CMpegSplitterFile::UpdatePrograms(CGolombBuffer gb, WORD pid, bool UpdateLang)
{
- if (CAtlMap<WORD, program>::CPair* pPair = m_programs.Lookup(pid))
- {
- memset(pPair->m_value.streams, 0, sizeof(pPair->m_value.streams));
-
- int len = gb.GetSize();
-
- BYTE reserved1 = (BYTE)gb.BitRead(3);
- WORD PCR_PID = (WORD)gb.BitRead(13);
- BYTE reserved2 = (BYTE)gb.BitRead(4);
- WORD program_info_length = (WORD)gb.BitRead(12);
- UNREFERENCED_PARAMETER(reserved1);
- UNREFERENCED_PARAMETER(PCR_PID);
- UNREFERENCED_PARAMETER(reserved2);
-
- len -= (4 + program_info_length);
- if (len <= 0)
- return;
-
- while (program_info_length-- > 0) {
- gb.BitRead(8);
- }
-
- for (int i = 0; i < _countof(pPair->m_value.streams) && len >= 5; i++) {
- BYTE stream_type = (BYTE)gb.BitRead(8);
- BYTE nreserved1 = (BYTE)gb.BitRead(3);
- WORD pid = (WORD)gb.BitRead(13);
- BYTE nreserved2 = (BYTE)gb.BitRead(4);
- WORD ES_info_length = (WORD)gb.BitRead(12);
- UNREFERENCED_PARAMETER(nreserved1);
- UNREFERENCED_PARAMETER(nreserved2);
-
- pPair->m_value.streams[i].pid = pid;
- pPair->m_value.streams[i].type = (PES_STREAM_TYPE)stream_type;
-
- if (m_ForcedSub) {
- if (stream_type == PRESENTATION_GRAPHICS_STREAM) {
- stream s;
- s.pid = pid;
- CMpegSplitterFile::hdmvsubhdr hdr;
- if (Read(hdr, &s.mt, NULL)) {
- if (!m_streams[subpic].Find(s)) {
- m_streams[subpic].Insert(s, this);
- }
- }
- }
- }
-
- len -= (5 + ES_info_length);
- if (len < 0)
- break;
- if (ES_info_length<=2)
- continue;
-
- if (UpdateLang) {
- int info_length = ES_info_length;
- for (;;) {
- BYTE descriptor_tag = (BYTE)gb.BitRead(8);
- BYTE descriptor_length = (BYTE)gb.BitRead(8);
- info_length -= (2 + descriptor_length);
- if (info_length < 0)
- break;
- char ch[4];
- switch (descriptor_tag) {
- case 0x0a: // ISO 639 language descriptor
- case 0x56: // Teletext descriptor
- case 0x59: // Subtitling descriptor
- gb.ReadBuffer((BYTE *)ch, 3);
- ch[3] = 0;
- for (int i = 3; i < descriptor_length; i++) {
- gb.BitRead(8);
- }
- if (!(ch[0] == 'u' && ch[1] == 'n' && ch[2] == 'd')) {
- m_pPMT_Lang[pid] = ISO6392ToLanguage(ch);
- }
- break;
- default:
- for (int i = 0; i < descriptor_length; i++) {
- gb.BitRead(8);
- }
- break;
- }
- if (info_length<=2) break;
- }
- } else {
- while (ES_info_length-- > 0) {
- gb.BitRead(8);
- }
- }
- }
- pPair->m_value.ts_len_cur = 0;
- pPair->m_value.ts_len_packet = 0;
- }
+ if (CAtlMap<WORD, program>::CPair* pPair = m_programs.Lookup(pid)) {
+ memset(pPair->m_value.streams, 0, sizeof(pPair->m_value.streams));
+
+ int len = gb.GetSize();
+
+ BYTE reserved1 = (BYTE)gb.BitRead(3);
+ WORD PCR_PID = (WORD)gb.BitRead(13);
+ BYTE reserved2 = (BYTE)gb.BitRead(4);
+ WORD program_info_length = (WORD)gb.BitRead(12);
+ UNREFERENCED_PARAMETER(reserved1);
+ UNREFERENCED_PARAMETER(PCR_PID);
+ UNREFERENCED_PARAMETER(reserved2);
+
+ len -= (4 + program_info_length);
+ if (len <= 0) {
+ return;
+ }
+
+ while (program_info_length-- > 0) {
+ gb.BitRead(8);
+ }
+
+ for (int i = 0; i < _countof(pPair->m_value.streams) && len >= 5; i++) {
+ BYTE stream_type = (BYTE)gb.BitRead(8);
+ BYTE nreserved1 = (BYTE)gb.BitRead(3);
+ WORD pid = (WORD)gb.BitRead(13);
+ BYTE nreserved2 = (BYTE)gb.BitRead(4);
+ WORD ES_info_length = (WORD)gb.BitRead(12);
+ UNREFERENCED_PARAMETER(nreserved1);
+ UNREFERENCED_PARAMETER(nreserved2);
+
+ pPair->m_value.streams[i].pid = pid;
+ pPair->m_value.streams[i].type = (PES_STREAM_TYPE)stream_type;
+
+ if (m_ForcedSub) {
+ if (stream_type == PRESENTATION_GRAPHICS_STREAM) {
+ stream s;
+ s.pid = pid;
+ CMpegSplitterFile::hdmvsubhdr hdr;
+ if (Read(hdr, &s.mt, NULL)) {
+ if (!m_streams[subpic].Find(s)) {
+ m_streams[subpic].Insert(s, this);
+ }
+ }
+ }
+ }
+
+ len -= (5 + ES_info_length);
+ if (len < 0) {
+ break;
+ }
+ if (ES_info_length <= 2) {
+ continue;
+ }
+
+ if (UpdateLang) {
+ int info_length = ES_info_length;
+ for (;;) {
+ BYTE descriptor_tag = (BYTE)gb.BitRead(8);
+ BYTE descriptor_length = (BYTE)gb.BitRead(8);
+ info_length -= (2 + descriptor_length);
+ if (info_length < 0) {
+ break;
+ }
+ char ch[4];
+ switch (descriptor_tag) {
+ case 0x0a: // ISO 639 language descriptor
+ case 0x56: // Teletext descriptor
+ case 0x59: // Subtitling descriptor
+ gb.ReadBuffer((BYTE*)ch, 3);
+ ch[3] = 0;
+ for (int i = 3; i < descriptor_length; i++) {
+ gb.BitRead(8);
+ }
+ if (!(ch[0] == 'u' && ch[1] == 'n' && ch[2] == 'd')) {
+ m_pPMT_Lang[pid] = ISO6392ToLanguage(ch);
+ }
+ break;
+ default:
+ for (int i = 0; i < descriptor_length; i++) {
+ gb.BitRead(8);
+ }
+ break;
+ }
+ if (info_length <= 2) { break; }
+ }
+ } else {
+ while (ES_info_length-- > 0) {
+ gb.BitRead(8);
+ }
+ }
+ }
+ pPair->m_value.ts_len_cur = 0;
+ pPair->m_value.ts_len_packet = 0;
+ }
}
-uint32 SwapLE(const uint32 &_Value)
+uint32 SwapLE(const uint32& _Value)
{
- return (_Value & 0xFF) << 24 | ((_Value>>8) & 0xFF) << 16 | ((_Value>>16) & 0xFF) << 8 | ((_Value>>24) & 0xFF) << 0;
+ return (_Value & 0xFF) << 24 | ((_Value >> 8) & 0xFF) << 16 | ((_Value >> 16) & 0xFF) << 8 | ((_Value >> 24) & 0xFF) << 0;
}
-uint16 SwapLE(const uint16 &_Value)
+uint16 SwapLE(const uint16& _Value)
{
- return (_Value & 0xFF) << 8 | ((_Value>>8) & 0xFF) << 0;
+ return (_Value & 0xFF) << 8 | ((_Value >> 8) & 0xFF) << 0;
}
-const CMpegSplitterFile::program* CMpegSplitterFile::FindProgram(WORD pid, int &iStream, const CHdmvClipInfo::Stream * &_pClipInfo)
+const CMpegSplitterFile::program* CMpegSplitterFile::FindProgram(WORD pid, int& iStream, const CHdmvClipInfo::Stream*& _pClipInfo)
{
- _pClipInfo = m_ClipInfo.FindStream(pid);
+ _pClipInfo = m_ClipInfo.FindStream(pid);
- iStream = -1;
+ iStream = -1;
- POSITION pos = m_programs.GetStartPosition();
+ POSITION pos = m_programs.GetStartPosition();
- while (pos) {
- program* p = &m_programs.GetNextValue(pos);
+ while (pos) {
+ program* p = &m_programs.GetNextValue(pos);
- for (int i = 0; i < _countof(p->streams); i++) {
- if (p->streams[i].pid == pid) {
- iStream = i;
- return p;
- }
- }
- }
+ for (int i = 0; i < _countof(p->streams); i++) {
+ if (p->streams[i].pid == pid) {
+ iStream = i;
+ return p;
+ }
+ }
+ }
- return NULL;
+ return NULL;
}
-bool CMpegSplitterFile::GetStreamType(WORD pid, PES_STREAM_TYPE &stream_type)
+bool CMpegSplitterFile::GetStreamType(WORD pid, PES_STREAM_TYPE& stream_type)
{
- int iProgram;
- const CHdmvClipInfo::Stream *pClipInfo;
- const program* pProgram = FindProgram (pid, iProgram, pClipInfo);
- if (pProgram) {
- stream_type = pProgram->streams[iProgram].type;
-
- if (stream_type != INVALID) {
- return true;
- }
- }
-
- return false;
+ int iProgram;
+ const CHdmvClipInfo::Stream* pClipInfo;
+ const program* pProgram = FindProgram(pid, iProgram, pClipInfo);
+ if (pProgram) {
+ stream_type = pProgram->streams[iProgram].type;
+
+ if (stream_type != INVALID) {
+ return true;
+ }
+ }
+
+ return false;
} \ No newline at end of file
diff --git a/src/filters/parser/MpegSplitter/MpegSplitterFile.h b/src/filters/parser/MpegSplitter/MpegSplitterFile.h
index c5f00887c..ce5ede555 100644
--- a/src/filters/parser/MpegSplitter/MpegSplitterFile.h
+++ b/src/filters/parser/MpegSplitter/MpegSplitterFile.h
@@ -37,150 +37,150 @@
class CMpegSplitterFile : public CBaseSplitterFileEx
{
- CAtlMap<WORD, BYTE> m_pid2pes;
- CAtlMap<WORD, CMpegSplitterFile::avchdr> avch;
- bool m_bIsHdmv;
- bool m_init;
+ CAtlMap<WORD, BYTE> m_pid2pes;
+ CAtlMap<WORD, CMpegSplitterFile::avchdr> avch;
+ bool m_bIsHdmv;
+ bool m_init;
- HRESULT Init(IAsyncReader* pAsyncReader);
+ HRESULT Init(IAsyncReader* pAsyncReader);
- void OnComplete(IAsyncReader* pAsyncReader);
+ void OnComplete(IAsyncReader* pAsyncReader);
public:
- CHdmvClipInfo &m_ClipInfo;
- CMpegSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr, bool bIsHdmv, CHdmvClipInfo &ClipInfo, int guid_flag, bool ForcedSub, bool TrackPriority, int AC3CoreOnly, bool m_AlternativeDuration);
-
- REFERENCE_TIME NextPTS(DWORD TrackNum);
-
- CCritSec m_csProps;
-
- MPEG_TYPES m_type;
-
- REFERENCE_TIME m_rtMin, m_rtMax;
- __int64 m_posMin, m_posMax;
- int m_rate; // byte/sec
-
- int m_nVC1_GuidFlag, m_AC3CoreOnly;
- bool m_ForcedSub, m_TrackPriority, m_AlternativeDuration;
-
- struct stream {
- CMpegSplitterFile *m_pFile;
- CMediaType mt;
- WORD pid;
- BYTE pesid, ps1id;
- bool operator < (const stream &_Other) const;
- struct stream() {
- pid = pesid = ps1id = 0;
- }
- operator DWORD() const {
- return pid ? pid : ((pesid<<8)|ps1id);
- }
- bool operator == (const struct stream& s) const {
- return (DWORD)*this == (DWORD)s;
- }
- };
-
- enum {video, audio, subpic,
+ CHdmvClipInfo& m_ClipInfo;
+ CMpegSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr, bool bIsHdmv, CHdmvClipInfo& ClipInfo, int guid_flag, bool ForcedSub, bool TrackPriority, int AC3CoreOnly, bool m_AlternativeDuration);
+
+ REFERENCE_TIME NextPTS(DWORD TrackNum);
+
+ CCritSec m_csProps;
+
+ MPEG_TYPES m_type;
+
+ REFERENCE_TIME m_rtMin, m_rtMax;
+ __int64 m_posMin, m_posMax;
+ int m_rate; // byte/sec
+
+ int m_nVC1_GuidFlag, m_AC3CoreOnly;
+ bool m_ForcedSub, m_TrackPriority, m_AlternativeDuration;
+
+ struct stream {
+ CMpegSplitterFile* m_pFile;
+ CMediaType mt;
+ WORD pid;
+ BYTE pesid, ps1id;
+ bool operator < (const stream& _Other) const;
+ struct stream() {
+ pid = pesid = ps1id = 0;
+ }
+ operator DWORD() const {
+ return pid ? pid : ((pesid << 8) | ps1id);
+ }
+ bool operator == (const struct stream& s) const {
+ return (DWORD) * this == (DWORD)s;
+ }
+ };
+
+ enum {video, audio, subpic,
#if defined(MVC_SUPPORT)
- stereo,
+ stereo,
#endif
- unknown
- };
-
- class CStreamList : public CAtlList<stream>
- {
- public:
- void Insert(stream& s, CMpegSplitterFile *_pFile) {
- s.m_pFile = _pFile;
- if (_pFile->m_TrackPriority) {
- for (POSITION pos = GetHeadPosition(); pos; GetNext(pos)) {
- stream& s2 = GetAt(pos);
- if (s < s2) {
- InsertBefore(pos, s);
- return;
- }
- }
- AddTail(s);
- } else {
- AddTail(s);
- if (GetCount() > 1) {
- for (size_t j=0; j<GetCount(); j++) {
- for (size_t i=0; i<GetCount()-1; i++) {
- if (GetAt(FindIndex(i)) > GetAt(FindIndex(i+1))) {
- SwapElements(FindIndex(i), FindIndex(i+1));
- }
- }
- }
- }
- }
- }
-
- void Replace(stream& source, stream& dest, CMpegSplitterFile *_pFile) {
- source.m_pFile = _pFile;
- dest.m_pFile = _pFile;
- for (POSITION pos = GetHeadPosition(); pos; GetNext(pos)) {
- stream& s = GetAt(pos);
- if (source == s) {
- SetAt(pos, dest);
- return;
- }
- }
- }
-
- static CStringW ToString(int type) {
- return
- type == video ? L"Video" :
- type == audio ? L"Audio" :
- type == subpic ? L"Subtitle" :
+ unknown
+ };
+
+ class CStreamList : public CAtlList<stream>
+ {
+ public:
+ void Insert(stream& s, CMpegSplitterFile* _pFile) {
+ s.m_pFile = _pFile;
+ if (_pFile->m_TrackPriority) {
+ for (POSITION pos = GetHeadPosition(); pos; GetNext(pos)) {
+ stream& s2 = GetAt(pos);
+ if (s < s2) {
+ InsertBefore(pos, s);
+ return;
+ }
+ }
+ AddTail(s);
+ } else {
+ AddTail(s);
+ if (GetCount() > 1) {
+ for (size_t j = 0; j < GetCount(); j++) {
+ for (size_t i = 0; i < GetCount() - 1; i++) {
+ if (GetAt(FindIndex(i)) > GetAt(FindIndex(i + 1))) {
+ SwapElements(FindIndex(i), FindIndex(i + 1));
+ }
+ }
+ }
+ }
+ }
+ }
+
+ void Replace(stream& source, stream& dest, CMpegSplitterFile* _pFile) {
+ source.m_pFile = _pFile;
+ dest.m_pFile = _pFile;
+ for (POSITION pos = GetHeadPosition(); pos; GetNext(pos)) {
+ stream& s = GetAt(pos);
+ if (source == s) {
+ SetAt(pos, dest);
+ return;
+ }
+ }
+ }
+
+ static CStringW ToString(int type) {
+ return
+ type == video ? L"Video" :
+ type == audio ? L"Audio" :
+ type == subpic ? L"Subtitle" :
#if defined(MVC_SUPPORT)
- type == stereo ? L"Stereo" :
+ type == stereo ? L"Stereo" :
#endif
- L"Unknown";
- }
-
- const stream* FindStream(int pid) {
- for (POSITION pos = GetHeadPosition(); pos; GetNext(pos)) {
- const stream& s = GetAt(pos);
- if (s.pid == pid) {
- return &s;
- }
- }
-
- return NULL;
- }
-
- } m_streams[unknown];
-
- HRESULT SearchStreams(__int64 start, __int64 stop, IAsyncReader* pAsyncReader, BOOL CalcDuration = FALSE);
- DWORD AddStream(WORD pid, BYTE pesid, BYTE ps1id, DWORD len);
- void AddHdmvPGStream(WORD pid, const char* language_code);
- CAtlList<stream>* GetMasterStream();
- bool IsHdmv() { return m_bIsHdmv; };
-
- struct program {
- WORD program_number;
- struct stream {
- WORD pid;
- PES_STREAM_TYPE type;
-
- };
- stream streams[64];
- struct program() {
- memset(this, 0, sizeof(*this));
- }
-
- BYTE ts_buffer[1024];
- WORD ts_len_cur, ts_len_packet;
- };
-
- CAtlMap<WORD, program> m_programs;
-
- void SearchPrograms(__int64 start, __int64 stop);
- void UpdatePrograms(const trhdr& h, bool UpdateLang = true);
- void UpdatePrograms(CGolombBuffer gb, WORD pid, bool UpdateLang = true);
- const program* FindProgram(WORD pid, int &iStream, const CHdmvClipInfo::Stream * &_pClipInfo);
-
- CAtlMap<DWORD, CString> m_pPMT_Lang;
-
- bool GetStreamType(WORD pid, PES_STREAM_TYPE &stream_type);
+ L"Unknown";
+ }
+
+ const stream* FindStream(int pid) {
+ for (POSITION pos = GetHeadPosition(); pos; GetNext(pos)) {
+ const stream& s = GetAt(pos);
+ if (s.pid == pid) {
+ return &s;
+ }
+ }
+
+ return NULL;
+ }
+
+ } m_streams[unknown];
+
+ HRESULT SearchStreams(__int64 start, __int64 stop, IAsyncReader* pAsyncReader, BOOL CalcDuration = FALSE);
+ DWORD AddStream(WORD pid, BYTE pesid, BYTE ps1id, DWORD len);
+ void AddHdmvPGStream(WORD pid, const char* language_code);
+ CAtlList<stream>* GetMasterStream();
+ bool IsHdmv() { return m_bIsHdmv; };
+
+ struct program {
+ WORD program_number;
+ struct stream {
+ WORD pid;
+ PES_STREAM_TYPE type;
+
+ };
+ stream streams[64];
+ struct program() {
+ memset(this, 0, sizeof(*this));
+ }
+
+ BYTE ts_buffer[1024];
+ WORD ts_len_cur, ts_len_packet;
+ };
+
+ CAtlMap<WORD, program> m_programs;
+
+ void SearchPrograms(__int64 start, __int64 stop);
+ void UpdatePrograms(const trhdr& h, bool UpdateLang = true);
+ void UpdatePrograms(CGolombBuffer gb, WORD pid, bool UpdateLang = true);
+ const program* FindProgram(WORD pid, int& iStream, const CHdmvClipInfo::Stream*& _pClipInfo);
+
+ CAtlMap<DWORD, CString> m_pPMT_Lang;
+
+ bool GetStreamType(WORD pid, PES_STREAM_TYPE& stream_type);
};
diff --git a/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.cpp b/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.cpp
index ec08f301c..c38e54499 100644
--- a/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.cpp
+++ b/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.cpp
@@ -28,8 +28,8 @@
#define ResStr(id) CString(MAKEINTRESOURCE(id))
-#define LEFT_SPACING 25
-#define VERTICAL_SPACING 25
+#define LEFT_SPACING 25
+#define VERTICAL_SPACING 25
CMpegSplitterSettingsWnd::CMpegSplitterSettingsWnd(void)
{
@@ -37,97 +37,97 @@ CMpegSplitterSettingsWnd::CMpegSplitterSettingsWnd(void)
bool CMpegSplitterSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
{
- ASSERT(!m_pMSF);
+ ASSERT(!m_pMSF);
- m_pMSF.Release();
+ m_pMSF.Release();
- POSITION pos = pUnks.GetHeadPosition();
- while (pos && !(m_pMSF = pUnks.GetNext(pos))) {
- ;
- }
+ POSITION pos = pUnks.GetHeadPosition();
+ while (pos && !(m_pMSF = pUnks.GetNext(pos))) {
+ ;
+ }
- if (!m_pMSF) {
- return false;
- }
+ if (!m_pMSF) {
+ return false;
+ }
- return true;
+ return true;
}
void CMpegSplitterSettingsWnd::OnDisconnect()
{
- m_pMSF.Release();
+ m_pMSF.Release();
}
bool CMpegSplitterSettingsWnd::OnActivate()
{
- int nPosY = 10;
-
- m_grpDefault.Create (ResStr(IDS_OPTIONS_CAPTION), WS_VISIBLE|WS_CHILD | BS_GROUPBOX, CRect (10, nPosY, 320, nPosY+310), this, (UINT)IDC_STATIC);
-
- nPosY += VERTICAL_SPACING;
- m_cbFastStreamChange.Create (ResStr(IDS_MPEGSPLITTER_FSTREAM_CHANGE), WS_VISIBLE|WS_CHILD|WS_TABSTOP|BS_AUTOCHECKBOX|BS_LEFTTEXT, CRect (LEFT_SPACING, nPosY, 305, nPosY+15), this, IDC_PP_FAST_STREAM_SELECT);
-
- nPosY += VERTICAL_SPACING;
- m_cbForcedSub.Create (ResStr(IDS_MPEGSPLITTER_SUB_FORCING), WS_VISIBLE|WS_CHILD|WS_TABSTOP|BS_AUTOCHECKBOX|BS_LEFTTEXT, CRect (LEFT_SPACING, nPosY, 305, nPosY+15), this, IDC_PP_SUBTITLE_FORCED);
-
- nPosY += VERTICAL_SPACING;
- m_cbTrackPriority.Create (ResStr(IDS_MPEGSPLITTER_TRACKS_ORDER), WS_VISIBLE|WS_CHILD|WS_TABSTOP|BS_AUTOCHECKBOX|BS_LEFTTEXT, CRect (LEFT_SPACING, nPosY, 305, nPosY+15), this, IDC_PP_TRACK_PRIORITY);
-
- nPosY += VERTICAL_SPACING;
- m_cbAlternativeDuration.Create (ResStr(IDS_MPEGSPLITTER_ALT_DUR_CALC), WS_VISIBLE|WS_CHILD|WS_TABSTOP|BS_AUTOCHECKBOX|BS_LEFTTEXT, CRect (LEFT_SPACING, nPosY, 305, nPosY+15), this, IDC_PP_ALTERNATIVE_DURATION);
-
- nPosY += VERTICAL_SPACING;
- m_txtAudioLanguageOrder.Create (ResStr(IDS_MPEGSPLITTER_LANG_ORDER), WS_VISIBLE|WS_CHILD, CRect (LEFT_SPACING, nPosY, 200, nPosY+15), this, (UINT)IDC_STATIC);
- nPosY += 15;
- m_edtAudioLanguageOrder.CreateEx(WS_EX_CLIENTEDGE, _T("EDIT"), _T(""), WS_CHILD|WS_VISIBLE|WS_TABSTOP, CRect (LEFT_SPACING, nPosY, 305, nPosY+20), this, IDC_PP_AUDIO_LANGUAGE_ORDER);
-
- nPosY += VERTICAL_SPACING;
- m_txtSubtitlesLanguageOrder.Create (ResStr(IDS_MPEGSPLITTER_SUB_ORDER), WS_VISIBLE|WS_CHILD, CRect (LEFT_SPACING, nPosY, 200, nPosY+15), this, (UINT)IDC_STATIC);
- nPosY += 15;
- m_edtSubtitlesLanguageOrder.CreateEx(WS_EX_CLIENTEDGE, _T("EDIT"), _T(""), WS_CHILD|WS_VISIBLE|WS_TABSTOP, CRect (LEFT_SPACING, nPosY, 305, nPosY+20), this, IDC_PP_SUBTITLES_LANGUAGE_ORDER);
-
- nPosY += VERTICAL_SPACING;
- m_txtVC1_GuidFlag.Create (ResStr(IDS_MPEGSPLITTER_VC1_GUIDFLAG), WS_VISIBLE|WS_CHILD, CRect (LEFT_SPACING, nPosY, 200, nPosY+15), this, (UINT)IDC_STATIC);
- nPosY += 15;
- m_cbVC1_GuidFlag.Create (WS_VISIBLE|WS_CHILD|CBS_DROPDOWNLIST|WS_VSCROLL, CRect (LEFT_SPACING, nPosY, 305, nPosY+20), this, IDC_PP_VC1_GUIDFLAG);
- m_cbVC1_GuidFlag.AddString (_T("Default"));
- m_cbVC1_GuidFlag.AddString (_T("Cyberlink VC-1 Decoder"));
- m_cbVC1_GuidFlag.AddString (_T("ArcSoft VC-1 Decoder"));
-
- SetClassLongPtr(GetDlgItem(IDC_PP_VC1_GUIDFLAG)->m_hWnd, GCLP_HCURSOR, (LONG_PTR)AfxGetApp()->LoadStandardCursor(IDC_HAND));
-
- nPosY += VERTICAL_SPACING + 5;
- m_grpTrueHD.Create (ResStr(IDS_MPEGSPLITTER_TRUEHD_OUTPUT), WS_VISIBLE|WS_CHILD | BS_GROUPBOX, CRect (LEFT_SPACING, nPosY, 305, nPosY+50), this, (UINT)IDC_STATIC);
-
- nPosY += VERTICAL_SPACING - 5;
- m_cbTrueHD.Create (_T("TrueHD"), WS_VISIBLE|WS_CHILD|WS_TABSTOP|BS_AUTORADIOBUTTON|BS_TOP|BS_MULTILINE|WS_GROUP, CRect (LEFT_SPACING + 15, nPosY, LEFT_SPACING + 15 + 80, nPosY+20), this, IDC_PP_TRUEHD);
- m_cbAC3Core.Create (_T("AC-3 core"), WS_VISIBLE|WS_CHILD|WS_TABSTOP|BS_AUTORADIOBUTTON|BS_TOP|BS_MULTILINE, CRect (LEFT_SPACING + 15 + 85, nPosY, LEFT_SPACING + 15 + 165, nPosY+20), this, IDC_PP_AC3CORE);
- m_cbAsIs.Create (ResStr(IDS_MPEGSPLITTER_THD_NOSPLIT), WS_VISIBLE|WS_CHILD|WS_TABSTOP|BS_AUTORADIOBUTTON|BS_TOP|BS_MULTILINE, CRect (LEFT_SPACING + 15 + 170, nPosY, LEFT_SPACING + 15 + 260, nPosY+20), this, IDC_PP_ASIS);
-
- if (m_pMSF) {
- m_cbFastStreamChange.SetCheck(m_pMSF->GetFastStreamChange());
- m_cbForcedSub.SetCheck(m_pMSF->GetForcedSub());
- m_cbTrackPriority.SetCheck(m_pMSF->GetTrackPriority());
- m_edtAudioLanguageOrder.SetWindowText(m_pMSF->GetAudioLanguageOrder());
- m_edtSubtitlesLanguageOrder.SetWindowText(m_pMSF->GetSubtitlesLanguageOrder());
- m_cbVC1_GuidFlag.SetCurSel(m_pMSF->GetVC1_GuidFlag() - 1);
- m_cbTrueHD.SetCheck (m_pMSF->GetTrueHD() == 0);
- m_cbAC3Core.SetCheck(m_pMSF->GetTrueHD() == 1);
- m_cbAsIs.SetCheck (!m_cbTrueHD.GetCheck() && !m_cbAC3Core.GetCheck());
- m_cbAlternativeDuration.SetCheck(m_pMSF->GetAlternativeDuration());
- }
+ int nPosY = 10;
+
+ m_grpDefault.Create(ResStr(IDS_OPTIONS_CAPTION), WS_VISIBLE | WS_CHILD | BS_GROUPBOX, CRect(10, nPosY, 320, nPosY + 310), this, (UINT)IDC_STATIC);
+
+ nPosY += VERTICAL_SPACING;
+ m_cbFastStreamChange.Create(ResStr(IDS_MPEGSPLITTER_FSTREAM_CHANGE), WS_VISIBLE | WS_CHILD | WS_TABSTOP | BS_AUTOCHECKBOX | BS_LEFTTEXT, CRect(LEFT_SPACING, nPosY, 305, nPosY + 15), this, IDC_PP_FAST_STREAM_SELECT);
+
+ nPosY += VERTICAL_SPACING;
+ m_cbForcedSub.Create(ResStr(IDS_MPEGSPLITTER_SUB_FORCING), WS_VISIBLE | WS_CHILD | WS_TABSTOP | BS_AUTOCHECKBOX | BS_LEFTTEXT, CRect(LEFT_SPACING, nPosY, 305, nPosY + 15), this, IDC_PP_SUBTITLE_FORCED);
+
+ nPosY += VERTICAL_SPACING;
+ m_cbTrackPriority.Create(ResStr(IDS_MPEGSPLITTER_TRACKS_ORDER), WS_VISIBLE | WS_CHILD | WS_TABSTOP | BS_AUTOCHECKBOX | BS_LEFTTEXT, CRect(LEFT_SPACING, nPosY, 305, nPosY + 15), this, IDC_PP_TRACK_PRIORITY);
+
+ nPosY += VERTICAL_SPACING;
+ m_cbAlternativeDuration.Create(ResStr(IDS_MPEGSPLITTER_ALT_DUR_CALC), WS_VISIBLE | WS_CHILD | WS_TABSTOP | BS_AUTOCHECKBOX | BS_LEFTTEXT, CRect(LEFT_SPACING, nPosY, 305, nPosY + 15), this, IDC_PP_ALTERNATIVE_DURATION);
+
+ nPosY += VERTICAL_SPACING;
+ m_txtAudioLanguageOrder.Create(ResStr(IDS_MPEGSPLITTER_LANG_ORDER), WS_VISIBLE | WS_CHILD, CRect(LEFT_SPACING, nPosY, 200, nPosY + 15), this, (UINT)IDC_STATIC);
+ nPosY += 15;
+ m_edtAudioLanguageOrder.CreateEx(WS_EX_CLIENTEDGE, _T("EDIT"), _T(""), WS_CHILD | WS_VISIBLE | WS_TABSTOP, CRect(LEFT_SPACING, nPosY, 305, nPosY + 20), this, IDC_PP_AUDIO_LANGUAGE_ORDER);
+
+ nPosY += VERTICAL_SPACING;
+ m_txtSubtitlesLanguageOrder.Create(ResStr(IDS_MPEGSPLITTER_SUB_ORDER), WS_VISIBLE | WS_CHILD, CRect(LEFT_SPACING, nPosY, 200, nPosY + 15), this, (UINT)IDC_STATIC);
+ nPosY += 15;
+ m_edtSubtitlesLanguageOrder.CreateEx(WS_EX_CLIENTEDGE, _T("EDIT"), _T(""), WS_CHILD | WS_VISIBLE | WS_TABSTOP, CRect(LEFT_SPACING, nPosY, 305, nPosY + 20), this, IDC_PP_SUBTITLES_LANGUAGE_ORDER);
+
+ nPosY += VERTICAL_SPACING;
+ m_txtVC1_GuidFlag.Create(ResStr(IDS_MPEGSPLITTER_VC1_GUIDFLAG), WS_VISIBLE | WS_CHILD, CRect(LEFT_SPACING, nPosY, 200, nPosY + 15), this, (UINT)IDC_STATIC);
+ nPosY += 15;
+ m_cbVC1_GuidFlag.Create(WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST | WS_VSCROLL, CRect(LEFT_SPACING, nPosY, 305, nPosY + 20), this, IDC_PP_VC1_GUIDFLAG);
+ m_cbVC1_GuidFlag.AddString(_T("Default"));
+ m_cbVC1_GuidFlag.AddString(_T("Cyberlink VC-1 Decoder"));
+ m_cbVC1_GuidFlag.AddString(_T("ArcSoft VC-1 Decoder"));
+
+ SetClassLongPtr(GetDlgItem(IDC_PP_VC1_GUIDFLAG)->m_hWnd, GCLP_HCURSOR, (LONG_PTR)AfxGetApp()->LoadStandardCursor(IDC_HAND));
+
+ nPosY += VERTICAL_SPACING + 5;
+ m_grpTrueHD.Create(ResStr(IDS_MPEGSPLITTER_TRUEHD_OUTPUT), WS_VISIBLE | WS_CHILD | BS_GROUPBOX, CRect(LEFT_SPACING, nPosY, 305, nPosY + 50), this, (UINT)IDC_STATIC);
+
+ nPosY += VERTICAL_SPACING - 5;
+ m_cbTrueHD.Create(_T("TrueHD"), WS_VISIBLE | WS_CHILD | WS_TABSTOP | BS_AUTORADIOBUTTON | BS_TOP | BS_MULTILINE | WS_GROUP, CRect(LEFT_SPACING + 15, nPosY, LEFT_SPACING + 15 + 80, nPosY + 20), this, IDC_PP_TRUEHD);
+ m_cbAC3Core.Create(_T("AC-3 core"), WS_VISIBLE | WS_CHILD | WS_TABSTOP | BS_AUTORADIOBUTTON | BS_TOP | BS_MULTILINE, CRect(LEFT_SPACING + 15 + 85, nPosY, LEFT_SPACING + 15 + 165, nPosY + 20), this, IDC_PP_AC3CORE);
+ m_cbAsIs.Create(ResStr(IDS_MPEGSPLITTER_THD_NOSPLIT), WS_VISIBLE | WS_CHILD | WS_TABSTOP | BS_AUTORADIOBUTTON | BS_TOP | BS_MULTILINE, CRect(LEFT_SPACING + 15 + 170, nPosY, LEFT_SPACING + 15 + 260, nPosY + 20), this, IDC_PP_ASIS);
+
+ if (m_pMSF) {
+ m_cbFastStreamChange.SetCheck(m_pMSF->GetFastStreamChange());
+ m_cbForcedSub.SetCheck(m_pMSF->GetForcedSub());
+ m_cbTrackPriority.SetCheck(m_pMSF->GetTrackPriority());
+ m_edtAudioLanguageOrder.SetWindowText(m_pMSF->GetAudioLanguageOrder());
+ m_edtSubtitlesLanguageOrder.SetWindowText(m_pMSF->GetSubtitlesLanguageOrder());
+ m_cbVC1_GuidFlag.SetCurSel(m_pMSF->GetVC1_GuidFlag() - 1);
+ m_cbTrueHD.SetCheck(m_pMSF->GetTrueHD() == 0);
+ m_cbAC3Core.SetCheck(m_pMSF->GetTrueHD() == 1);
+ m_cbAsIs.SetCheck(!m_cbTrueHD.GetCheck() && !m_cbAC3Core.GetCheck());
+ m_cbAlternativeDuration.SetCheck(m_pMSF->GetAlternativeDuration());
+ }
#ifndef REGISTER_FILTER
- m_edtAudioLanguageOrder.EnableWindow(FALSE);
- m_edtSubtitlesLanguageOrder.EnableWindow(FALSE);
+ m_edtAudioLanguageOrder.EnableWindow(FALSE);
+ m_edtSubtitlesLanguageOrder.EnableWindow(FALSE);
#endif
- for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
- pWnd->SetFont(&m_font, FALSE);
- }
+ for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
+ pWnd->SetFont(&m_font, FALSE);
+ }
- return true;
+ return true;
}
void CMpegSplitterSettingsWnd::OnDeactivate()
@@ -136,27 +136,27 @@ void CMpegSplitterSettingsWnd::OnDeactivate()
bool CMpegSplitterSettingsWnd::OnApply()
{
- OnDeactivate();
+ OnDeactivate();
- if (m_pMSF) {
- m_pMSF->SetFastStreamChange(m_cbFastStreamChange.GetCheck());
- m_pMSF->SetForcedSub(m_cbForcedSub.GetCheck());
- m_pMSF->SetTrackPriority(m_cbTrackPriority.GetCheck());
- m_pMSF->SetVC1_GuidFlag(m_cbVC1_GuidFlag.GetCurSel() + 1);
- m_pMSF->SetTrueHD(m_cbTrueHD.GetCheck() ? 0 : m_cbAC3Core.GetCheck() ? 1 : 2);
- m_pMSF->SetAlternativeDuration(m_cbAlternativeDuration.GetCheck());
+ if (m_pMSF) {
+ m_pMSF->SetFastStreamChange(m_cbFastStreamChange.GetCheck());
+ m_pMSF->SetForcedSub(m_cbForcedSub.GetCheck());
+ m_pMSF->SetTrackPriority(m_cbTrackPriority.GetCheck());
+ m_pMSF->SetVC1_GuidFlag(m_cbVC1_GuidFlag.GetCurSel() + 1);
+ m_pMSF->SetTrueHD(m_cbTrueHD.GetCheck() ? 0 : m_cbAC3Core.GetCheck() ? 1 : 2);
+ m_pMSF->SetAlternativeDuration(m_cbAlternativeDuration.GetCheck());
#ifdef REGISTER_FILTER
- CString str = _T("");
- m_edtAudioLanguageOrder.GetWindowText(str);
- m_pMSF->SetAudioLanguageOrder(str.GetBuffer());
- m_edtSubtitlesLanguageOrder.GetWindowText(str);
- m_pMSF->SetSubtitlesLanguageOrder(str.GetBuffer());
+ CString str = _T("");
+ m_edtAudioLanguageOrder.GetWindowText(str);
+ m_pMSF->SetAudioLanguageOrder(str.GetBuffer());
+ m_edtSubtitlesLanguageOrder.GetWindowText(str);
+ m_pMSF->SetSubtitlesLanguageOrder(str.GetBuffer());
#endif
- m_pMSF->Apply();
- }
+ m_pMSF->Apply();
+ }
- return true;
+ return true;
}
BEGIN_MESSAGE_MAP(CMpegSplitterSettingsWnd, CInternalPropertyPageWnd)
diff --git a/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.h b/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.h
index 81689c897..c70d892d2 100644
--- a/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.h
+++ b/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.h
@@ -27,56 +27,56 @@
#include <afxcmn.h>
class __declspec(uuid("44FCB62D-3AEB-401C-A7E1-8A984C017923"))
- CMpegSplitterSettingsWnd : public CInternalPropertyPageWnd
+ CMpegSplitterSettingsWnd : public CInternalPropertyPageWnd
{
private :
- CComQIPtr<IMpegSplitterFilter> m_pMSF;
+ CComQIPtr<IMpegSplitterFilter> m_pMSF;
- CButton m_grpDefault;
- CButton m_cbFastStreamChange;
- CButton m_cbForcedSub;
- CButton m_cbTrackPriority;
- CButton m_cbAlternativeDuration;
- CStatic m_txtAudioLanguageOrder;
- CEdit m_edtAudioLanguageOrder;
- CStatic m_txtSubtitlesLanguageOrder;
- CEdit m_edtSubtitlesLanguageOrder;
- CStatic m_txtVC1_GuidFlag;
- CComboBox m_cbVC1_GuidFlag;
+ CButton m_grpDefault;
+ CButton m_cbFastStreamChange;
+ CButton m_cbForcedSub;
+ CButton m_cbTrackPriority;
+ CButton m_cbAlternativeDuration;
+ CStatic m_txtAudioLanguageOrder;
+ CEdit m_edtAudioLanguageOrder;
+ CStatic m_txtSubtitlesLanguageOrder;
+ CEdit m_edtSubtitlesLanguageOrder;
+ CStatic m_txtVC1_GuidFlag;
+ CComboBox m_cbVC1_GuidFlag;
- CButton m_grpTrueHD;
- CButton m_cbTrueHD;
- CButton m_cbAC3Core;
- CButton m_cbAsIs;
+ CButton m_grpTrueHD;
+ CButton m_cbTrueHD;
+ CButton m_cbAC3Core;
+ CButton m_cbAsIs;
- enum {
- IDC_PP_FAST_STREAM_SELECT = 10000,
- IDC_PP_SUBTITLE_FORCED,
- IDC_PP_TRACK_PRIORITY,
- IDC_PP_AUDIO_LANGUAGE_ORDER,
- IDC_PP_SUBTITLES_LANGUAGE_ORDER,
- IDC_PP_VC1_GUIDFLAG,
- IDC_PP_TRUEHD,
- IDC_PP_AC3CORE,
- IDC_PP_ASIS,
- IDC_PP_ALTERNATIVE_DURATION
- };
+ enum {
+ IDC_PP_FAST_STREAM_SELECT = 10000,
+ IDC_PP_SUBTITLE_FORCED,
+ IDC_PP_TRACK_PRIORITY,
+ IDC_PP_AUDIO_LANGUAGE_ORDER,
+ IDC_PP_SUBTITLES_LANGUAGE_ORDER,
+ IDC_PP_VC1_GUIDFLAG,
+ IDC_PP_TRUEHD,
+ IDC_PP_AC3CORE,
+ IDC_PP_ASIS,
+ IDC_PP_ALTERNATIVE_DURATION
+ };
public:
- CMpegSplitterSettingsWnd(void);
+ CMpegSplitterSettingsWnd(void);
- bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
- void OnDisconnect();
- bool OnActivate();
- void OnDeactivate();
- bool OnApply();
+ bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
+ void OnDisconnect();
+ bool OnActivate();
+ void OnDeactivate();
+ bool OnApply();
- static LPCTSTR GetWindowTitle() {
- return _T("Settings");
- }
- static CSize GetWindowSize() {
- return CSize(320, 310);
- }
+ static LPCTSTR GetWindowTitle() {
+ return _T("Settings");
+ }
+ static CSize GetWindowSize() {
+ return CSize(320, 310);
+ }
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
};
diff --git a/src/filters/parser/OggSplitter/OggFile.cpp b/src/filters/parser/OggSplitter/OggFile.cpp
index ad28f38e5..028233db7 100644
--- a/src/filters/parser/OggSplitter/OggFile.cpp
+++ b/src/filters/parser/OggSplitter/OggFile.cpp
@@ -25,82 +25,82 @@
#include "OggFile.h"
COggFile::COggFile(IAsyncReader* pAsyncReader, HRESULT& hr)
- : CBaseSplitterFile(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false)
+ : CBaseSplitterFile(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false)
{
- if (FAILED(hr)) {
- return;
- }
- hr = Init();
+ if (FAILED(hr)) {
+ return;
+ }
+ hr = Init();
}
HRESULT COggFile::Init()
{
- Seek(0);
- if (!Sync()) {
- return E_FAIL;
- }
+ Seek(0);
+ if (!Sync()) {
+ return E_FAIL;
+ }
- return S_OK;
+ return S_OK;
}
bool COggFile::Sync(HANDLE hBreak)
{
- __int64 start = GetPos();
+ __int64 start = GetPos();
- DWORD dw;
- for (__int64 i = 0, j = hBreak ? GetLength() - start : 65536;
- i < j && S_OK == ByteRead((BYTE*)&dw, sizeof(dw))
- && ((i&0xffff) || !hBreak || WaitForSingleObject(hBreak, 0) != WAIT_OBJECT_0);
- i++, Seek(start + i)) {
- if (dw == 'SggO') {
- Seek(start + i);
- return true;
- }
- }
+ DWORD dw;
+ for (__int64 i = 0, j = hBreak ? GetLength() - start : 65536;
+ i < j && S_OK == ByteRead((BYTE*)&dw, sizeof(dw))
+ && ((i & 0xffff) || !hBreak || WaitForSingleObject(hBreak, 0) != WAIT_OBJECT_0);
+ i++, Seek(start + i)) {
+ if (dw == 'SggO') {
+ Seek(start + i);
+ return true;
+ }
+ }
- Seek(start);
+ Seek(start);
- return false;
+ return false;
}
bool COggFile::Read(OggPageHeader& hdr, HANDLE hBreak)
{
- return Sync(hBreak) && S_OK == ByteRead((BYTE*)&hdr, sizeof(hdr)) && hdr.capture_pattern == 'SggO';
+ return Sync(hBreak) && S_OK == ByteRead((BYTE*)&hdr, sizeof(hdr)) && hdr.capture_pattern == 'SggO';
}
bool COggFile::Read(OggPage& page, bool fFull, HANDLE hBreak)
{
- memset(&page.m_hdr, 0, sizeof(page.m_hdr));
- page.m_lens.RemoveAll();
- page.SetCount(0);
+ memset(&page.m_hdr, 0, sizeof(page.m_hdr));
+ page.m_lens.RemoveAll();
+ page.SetCount(0);
- if (!Read(page.m_hdr, hBreak)) {
- return false;
- }
+ if (!Read(page.m_hdr, hBreak)) {
+ return false;
+ }
- int pagelen = 0, packetlen = 0;
- for (BYTE i = 0; i < page.m_hdr.number_page_segments; i++) {
- BYTE b;
- if (S_OK != ByteRead(&b, 1)) {
- return false;
- }
- packetlen += b;
- if (1/*b < 0xff*/) {
- page.m_lens.AddTail(packetlen);
- pagelen += packetlen;
- packetlen = 0;
- }
- }
+ int pagelen = 0, packetlen = 0;
+ for (BYTE i = 0; i < page.m_hdr.number_page_segments; i++) {
+ BYTE b;
+ if (S_OK != ByteRead(&b, 1)) {
+ return false;
+ }
+ packetlen += b;
+ if (1/*b < 0xff*/) {
+ page.m_lens.AddTail(packetlen);
+ pagelen += packetlen;
+ packetlen = 0;
+ }
+ }
- if (fFull) {
- page.SetCount(pagelen);
- if (S_OK != ByteRead(page.GetData(), page.GetCount())) {
- return false;
- }
- } else {
- Seek(GetPos() + pagelen);
- page.m_lens.RemoveAll();
- }
+ if (fFull) {
+ page.SetCount(pagelen);
+ if (S_OK != ByteRead(page.GetData(), page.GetCount())) {
+ return false;
+ }
+ } else {
+ Seek(GetPos() + pagelen);
+ page.m_lens.RemoveAll();
+ }
- return true;
+ return true;
}
diff --git a/src/filters/parser/OggSplitter/OggFile.h b/src/filters/parser/OggSplitter/OggFile.h
index 971b3daf9..82752ad35 100644
--- a/src/filters/parser/OggSplitter/OggFile.h
+++ b/src/filters/parser/OggSplitter/OggFile.h
@@ -28,72 +28,72 @@
#pragma pack(push, 1)
struct OggPageHeader {
- DWORD capture_pattern;
- BYTE stream_structure_version;
- BYTE header_type_flag;
- enum {continued=1, first=2, last=4};
- __int64 granule_position;
- DWORD bitstream_serial_number;
- DWORD page_sequence_number;
- DWORD CRC_checksum;
- BYTE number_page_segments;
+ DWORD capture_pattern;
+ BYTE stream_structure_version;
+ BYTE header_type_flag;
+ enum {continued = 1, first = 2, last = 4};
+ __int64 granule_position;
+ DWORD bitstream_serial_number;
+ DWORD page_sequence_number;
+ DWORD CRC_checksum;
+ BYTE number_page_segments;
};
struct OggVorbisIdHeader {
- DWORD vorbis_version;
- BYTE audio_channels;
- DWORD audio_sample_rate;
- DWORD bitrate_maximum;
- DWORD bitrate_nominal;
- DWORD bitrate_minimum;
- BYTE blocksize_0:4;
- BYTE blocksize_1:4;
- BYTE framing_flag;
+ DWORD vorbis_version;
+ BYTE audio_channels;
+ DWORD audio_sample_rate;
+ DWORD bitrate_maximum;
+ DWORD bitrate_nominal;
+ DWORD bitrate_minimum;
+ BYTE blocksize_0: 4;
+ BYTE blocksize_1: 4;
+ BYTE framing_flag;
};
struct OggVideoHeader {
- DWORD w, h;
+ DWORD w, h;
};
struct OggAudioHeader {
- WORD nChannels, nBlockAlign;
- DWORD nAvgBytesPerSec;
+ WORD nChannels, nBlockAlign;
+ DWORD nAvgBytesPerSec;
};
struct OggStreamHeader {
- char streamtype[8], subtype[4];
- DWORD size;
- __int64 time_unit, samples_per_unit;
- DWORD default_len;
- DWORD buffersize;
- WORD bps;
- WORD alignmentfix1;
- union {
- OggVideoHeader v;
- OggAudioHeader a;
- };
- DWORD alignmentfix2;
+ char streamtype[8], subtype[4];
+ DWORD size;
+ __int64 time_unit, samples_per_unit;
+ DWORD default_len;
+ DWORD buffersize;
+ WORD bps;
+ WORD alignmentfix1;
+ union {
+ OggVideoHeader v;
+ OggAudioHeader a;
+ };
+ DWORD alignmentfix2;
};
#pragma pack(pop)
class OggPage : public CAtlArray<BYTE>
{
public:
- OggPageHeader m_hdr;
- CAtlList<int> m_lens;
- OggPage() {
- memset(&m_hdr, 0, sizeof(m_hdr));
- }
+ OggPageHeader m_hdr;
+ CAtlList<int> m_lens;
+ OggPage() {
+ memset(&m_hdr, 0, sizeof(m_hdr));
+ }
};
class COggFile : public CBaseSplitterFile
{
- HRESULT Init();
+ HRESULT Init();
public:
- COggFile(IAsyncReader* pAsyncReader, HRESULT& hr);
+ COggFile(IAsyncReader* pAsyncReader, HRESULT& hr);
- bool Sync(HANDLE hBreak = NULL);
- bool Read(OggPageHeader& hdr, HANDLE hBreak = NULL);
- bool Read(OggPage& page, bool fFull = true, HANDLE hBreak = NULL);
+ bool Sync(HANDLE hBreak = NULL);
+ bool Read(OggPageHeader& hdr, HANDLE hBreak = NULL);
+ bool Read(OggPage& page, bool fFull = true, HANDLE hBreak = NULL);
};
diff --git a/src/filters/parser/OggSplitter/OggSplitter.cpp b/src/filters/parser/OggSplitter/OggSplitter.cpp
index fc161b4fb..f304b5fd7 100644
--- a/src/filters/parser/OggSplitter/OggSplitter.cpp
+++ b/src/filters/parser/OggSplitter/OggSplitter.cpp
@@ -39,42 +39,42 @@
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(COggSplitterFilter), OggSplitterName, MERIT_NORMAL+1, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(COggSourceFilter), OggSourceName, MERIT_NORMAL+1, 0, NULL, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(COggSplitterFilter), OggSplitterName, MERIT_NORMAL + 1, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(COggSourceFilter), OggSourceName, MERIT_NORMAL + 1, 0, NULL, CLSID_LegacyAmFilterCategory},
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<COggSplitterFilter>, NULL, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<COggSourceFilter>, NULL, &sudFilter[1]},
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<COggSplitterFilter>, NULL, &sudFilter[0]},
+ {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<COggSourceFilter>, NULL, &sudFilter[1]},
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- RegisterSourceFilter(
- CLSID_AsyncReader,
- MEDIASUBTYPE_Ogg,
- _T("0,4,,4F676753"), // OggS
- _T(".ogg"), _T(".ogm"), NULL);
+ RegisterSourceFilter(
+ CLSID_AsyncReader,
+ MEDIASUBTYPE_Ogg,
+ _T("0,4,,4F676753"), // OggS
+ _T(".ogg"), _T(".ogm"), NULL);
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- UnRegisterSourceFilter(MEDIASUBTYPE_Ogg);
+ UnRegisterSourceFilter(MEDIASUBTYPE_Ogg);
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -89,49 +89,49 @@ CFilterApp theApp;
class bitstream
{
- BYTE* m_p;
- int m_len, m_pos;
+ BYTE* m_p;
+ int m_len, m_pos;
public:
- bitstream(BYTE* p, int len, bool rev = false) : m_p(p), m_len(len*8) {
- m_pos = !rev ? 0 : len*8;
- }
- bool hasbits(int cnt) {
- int pos = m_pos+cnt;
- return (pos >= 0 && pos < m_len);
- }
- unsigned int showbits(int cnt) { // a bit unclean, but works and can read backwards too! :P
- if (!hasbits(cnt)) {
- ASSERT(0);
- return 0;
- }
- unsigned int ret = 0, off = 0;
- BYTE* p = m_p;
- if (cnt < 0) {
- p += (m_pos+cnt)>>3;
- off = (m_pos+cnt)&7;
- cnt = abs(cnt);
- ret = (*p++&(~0<<off))>>off;
- off = 8 - off;
- cnt -= off;
- } else {
- p += m_pos>>3;
- off = m_pos&7;
- ret = (*p++>>off)&((1<<min(cnt,8))-1);
- off = 0;
- cnt -= 8 - off;
- }
- while (cnt > 0) {
- ret |= (*p++&((1<<min(cnt,8))-1)) << off;
- off += 8;
- cnt -= 8;
- }
- return ret;
- }
- unsigned int getbits(int cnt) {
- unsigned int ret = showbits(cnt);
- m_pos += cnt;
- return ret;
- }
+ bitstream(BYTE* p, int len, bool rev = false) : m_p(p), m_len(len * 8) {
+ m_pos = !rev ? 0 : len * 8;
+ }
+ bool hasbits(int cnt) {
+ int pos = m_pos + cnt;
+ return (pos >= 0 && pos < m_len);
+ }
+ unsigned int showbits(int cnt) { // a bit unclean, but works and can read backwards too! :P
+ if (!hasbits(cnt)) {
+ ASSERT(0);
+ return 0;
+ }
+ unsigned int ret = 0, off = 0;
+ BYTE* p = m_p;
+ if (cnt < 0) {
+ p += (m_pos + cnt) >> 3;
+ off = (m_pos + cnt) & 7;
+ cnt = abs(cnt);
+ ret = (*p++ & (~0 << off)) >> off;
+ off = 8 - off;
+ cnt -= off;
+ } else {
+ p += m_pos >> 3;
+ off = m_pos & 7;
+ ret = (*p++ >> off) & ((1 << min(cnt, 8)) - 1);
+ off = 0;
+ cnt -= 8 - off;
+ }
+ while (cnt > 0) {
+ ret |= (*p++ & ((1 << min(cnt, 8)) - 1)) << off;
+ off += 8;
+ cnt -= 8;
+ }
+ return ret;
+ }
+ unsigned int getbits(int cnt) {
+ unsigned int ret = showbits(cnt);
+ m_pos += cnt;
+ return ret;
+ }
};
//
@@ -139,7 +139,7 @@ public:
//
COggSplitterFilter::COggSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("COggSplitterFilter"), pUnk, phr, __uuidof(this))
+ : CBaseSplitterFilter(NAME("COggSplitterFilter"), pUnk, phr, __uuidof(this))
{
}
@@ -149,436 +149,436 @@ COggSplitterFilter::~COggSplitterFilter()
STDMETHODIMP COggSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo)
{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
-
- if (m_pName && m_pName[0]==L'M' && m_pName[1]==L'P' && m_pName[2]==L'C') {
- (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
- } else {
- wcscpy_s(pInfo->achName, OggSourceName);
- }
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
+ CheckPointer(pInfo, E_POINTER);
+ ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
+
+ if (m_pName && m_pName[0] == L'M' && m_pName[1] == L'P' && m_pName[2] == L'C') {
+ (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
+ } else {
+ wcscpy_s(pInfo->achName, OggSourceName);
+ }
+ pInfo->pGraph = m_pGraph;
+ if (m_pGraph) {
+ m_pGraph->AddRef();
+ }
+
+ return S_OK;
}
HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
{
- CheckPointer(pAsyncReader, E_POINTER);
-
- HRESULT hr = E_FAIL;
-
- m_pFile.Free();
-
- m_pFile.Attach(DNew COggFile(pAsyncReader, hr));
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = 0;
-
- m_rtDuration = 0;
-
- m_pFile->Seek(0);
- OggPage page;
- for (int i = 0, nWaitForMore = 0; m_pFile->Read(page), i<100; i++) {
- BYTE* p = page.GetData();
- if (!p) {
- break;
- }
-
- if (!(page.m_hdr.header_type_flag & OggPageHeader::continued)) {
- if (!memcmp(p, "fishead", 7) || !memcmp(p, "fisbone", 7)) {
- continue;
- }
-
- BYTE type = *p++;
-
- CStringW name;
- name.Format(L"Stream %d", i);
-
- HRESULT hr;
-
- if (type >= 0x80 && type <= 0x82 && !memcmp(p, "theora", 6)) {
- if (type == 0x80) {
- name.Format(L"Theora %d", i);
- CAutoPtr<CBaseSplitterOutputPin> pPinOut;
- pPinOut.Attach(DNew COggTheoraOutputPin(page.GetData(), name, this, this, &hr));
- AddOutputPin(page.m_hdr.bitstream_serial_number, pPinOut);
- nWaitForMore++;
- }
- } else if (type == 1 && (page.m_hdr.header_type_flag & OggPageHeader::first)) {
- CAutoPtr<CBaseSplitterOutputPin> pPinOut;
-
- if (!memcmp(p, "vorbis", 6)) {
- name.Format(L"Vorbis %d", i);
- pPinOut.Attach(DNew COggVorbisOutputPin((OggVorbisIdHeader*)(p+6), name, this, this, &hr));
- nWaitForMore++;
- } else if (!memcmp(p, "video", 5)) {
- name.Format(L"Video %d", i);
- pPinOut.Attach(DNew COggVideoOutputPin((OggStreamHeader*)p, name, this, this, &hr));
- } else if (!memcmp(p, "audio", 5)) {
- name.Format(L"Audio %d", i);
- pPinOut.Attach(DNew COggAudioOutputPin((OggStreamHeader*)p, name, this, this, &hr));
- } else if (!memcmp(p, "text", 4)) {
- name.Format(L"Text %d", i);
- pPinOut.Attach(DNew COggTextOutputPin((OggStreamHeader*)p, name, this, this, &hr));
- } else if (!memcmp(p, "Direct Show Samples embedded in Ogg", 35)) {
- name.Format(L"DirectShow %d", i);
- pPinOut.Attach(DNew COggDirectShowOutputPin((AM_MEDIA_TYPE*)(p+35+sizeof(GUID)), name, this, this, &hr));
- }
-
- AddOutputPin(page.m_hdr.bitstream_serial_number, pPinOut);
- } else if (type == 3 && !memcmp(p, "vorbis", 6)) {
- if (COggSplitterOutputPin* pOggPin =
- dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
- pOggPin->AddComment(p+6, page.GetCount()-6-1);
- }
- } else if (type == 0x7F && page.GetCount()>12 && *(long*)(p+8) == 0x43614C66) { // Flac
- // Ogg Flac : method 1
- CAutoPtr<CBaseSplitterOutputPin> pPinOut;
- name.Format(L"FLAC %d", i);
- pPinOut.Attach(DNew COggFlacOutputPin(p+12, page.GetCount()-14, name, this, this, &hr));
- AddOutputPin(page.m_hdr.bitstream_serial_number, pPinOut);
- } else if (*(long*)(p-1) == 0x43614C66) {
- //bFlac = true;
- //nWaitForMore++;
- if (m_pFile->Read(page)) {
- CAutoPtr<CBaseSplitterOutputPin> pPinOut;
- name.Format(L"FLAC %d", i);
- p = page.GetData();
- pPinOut.Attach(DNew COggFlacOutputPin(p, page.GetCount(), name, this, this, &hr));
- AddOutputPin(page.m_hdr.bitstream_serial_number, pPinOut);
- }
- } else if (!(type&1) && nWaitForMore == 0) {
- break;
- }
- }
-
- if (COggTheoraOutputPin* p = dynamic_cast<COggTheoraOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
- p->UnpackInitPage(page);
- if (p->IsInitialized()) {
- nWaitForMore--;
- }
- }
-
- if (COggVorbisOutputPin* p = dynamic_cast<COggVorbisOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
- p->UnpackInitPage(page);
- if (p->IsInitialized()) {
- nWaitForMore--;
- }
- }
- }
-
- if (m_pOutputs.IsEmpty()) {
- return E_FAIL;
- }
-
- if (m_pFile->IsRandomAccess()) {
- m_pFile->Seek(max(m_pFile->GetLength()-65536, 0));
-
- OggPage page;
- while (m_pFile->Read(page)) {
- COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number));
- if (!pOggPin || page.m_hdr.granule_position == -1) {
- continue;
- }
- REFERENCE_TIME rt = pOggPin->GetRefTime(page.m_hdr.granule_position);
- m_rtDuration = max(rt, m_rtDuration);
- }
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration;
-
- // comments
-
- {
- CAtlMap<CStringW, CStringW, CStringElementTraits<CStringW> > tagmap;
- tagmap[L"TITLE"] = L"TITL";
- tagmap[L"ARTIST"] = L"AUTH"; // not quite
- tagmap[L"COPYRIGHT"] = L"CPYR";
- tagmap[L"DESCRIPTION"] = L"DESC";
-
- POSITION pos2 = tagmap.GetStartPosition();
- while (pos2) {
- CStringW oggtag, dsmtag;
- tagmap.GetNextAssoc(pos2, oggtag, dsmtag);
-
- POSITION pos = m_pOutputs.GetHeadPosition();
- while (pos) {
- COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>((CBaseOutputPin*)m_pOutputs.GetNext(pos));
- if (!pOggPin) {
- continue;
- }
-
- CStringW value = pOggPin->GetComment(oggtag);
- if (!value.IsEmpty()) {
- SetProperty(dsmtag, value);
- break;
- }
- }
- }
-
- POSITION pos = m_pOutputs.GetHeadPosition();
- while (pos && !ChapGetCount()) {
- COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>((CBaseOutputPin*)m_pOutputs.GetNext(pos));
- if (!pOggPin) {
- continue;
- }
-
- for (int i = 1; pOggPin; i++) {
- CStringW key;
- key.Format(L"CHAPTER%02d", i);
- CStringW time = pOggPin->GetComment(key);
- if (time.IsEmpty()) {
- break;
- }
- key.Format(L"CHAPTER%02dNAME", i);
- CStringW name = pOggPin->GetComment(key);
- if (name.IsEmpty()) {
- name.Format(L"Chapter %d", i);
- }
- int h, m, s, ms;
- WCHAR c;
- if (7 != swscanf_s(time, L"%d%c%d%c%d%c%d", &h, &c, sizeof(WCHAR),
- &m, &c, sizeof(WCHAR), &s, &c, sizeof(WCHAR), &ms)) {
- break;
- }
- REFERENCE_TIME rt = ((((REFERENCE_TIME)h*60+m)*60+s)*1000+ms)*10000;
- ChapAppend(rt, name);
- }
- }
- }
-
- return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
+ CheckPointer(pAsyncReader, E_POINTER);
+
+ HRESULT hr = E_FAIL;
+
+ m_pFile.Free();
+
+ m_pFile.Attach(DNew COggFile(pAsyncReader, hr));
+ if (!m_pFile) {
+ return E_OUTOFMEMORY;
+ }
+ if (FAILED(hr)) {
+ m_pFile.Free();
+ return hr;
+ }
+
+ m_rtNewStart = m_rtCurrent = 0;
+ m_rtNewStop = m_rtStop = 0;
+
+ m_rtDuration = 0;
+
+ m_pFile->Seek(0);
+ OggPage page;
+ for (int i = 0, nWaitForMore = 0; m_pFile->Read(page), i < 100; i++) {
+ BYTE* p = page.GetData();
+ if (!p) {
+ break;
+ }
+
+ if (!(page.m_hdr.header_type_flag & OggPageHeader::continued)) {
+ if (!memcmp(p, "fishead", 7) || !memcmp(p, "fisbone", 7)) {
+ continue;
+ }
+
+ BYTE type = *p++;
+
+ CStringW name;
+ name.Format(L"Stream %d", i);
+
+ HRESULT hr;
+
+ if (type >= 0x80 && type <= 0x82 && !memcmp(p, "theora", 6)) {
+ if (type == 0x80) {
+ name.Format(L"Theora %d", i);
+ CAutoPtr<CBaseSplitterOutputPin> pPinOut;
+ pPinOut.Attach(DNew COggTheoraOutputPin(page.GetData(), name, this, this, &hr));
+ AddOutputPin(page.m_hdr.bitstream_serial_number, pPinOut);
+ nWaitForMore++;
+ }
+ } else if (type == 1 && (page.m_hdr.header_type_flag & OggPageHeader::first)) {
+ CAutoPtr<CBaseSplitterOutputPin> pPinOut;
+
+ if (!memcmp(p, "vorbis", 6)) {
+ name.Format(L"Vorbis %d", i);
+ pPinOut.Attach(DNew COggVorbisOutputPin((OggVorbisIdHeader*)(p + 6), name, this, this, &hr));
+ nWaitForMore++;
+ } else if (!memcmp(p, "video", 5)) {
+ name.Format(L"Video %d", i);
+ pPinOut.Attach(DNew COggVideoOutputPin((OggStreamHeader*)p, name, this, this, &hr));
+ } else if (!memcmp(p, "audio", 5)) {
+ name.Format(L"Audio %d", i);
+ pPinOut.Attach(DNew COggAudioOutputPin((OggStreamHeader*)p, name, this, this, &hr));
+ } else if (!memcmp(p, "text", 4)) {
+ name.Format(L"Text %d", i);
+ pPinOut.Attach(DNew COggTextOutputPin((OggStreamHeader*)p, name, this, this, &hr));
+ } else if (!memcmp(p, "Direct Show Samples embedded in Ogg", 35)) {
+ name.Format(L"DirectShow %d", i);
+ pPinOut.Attach(DNew COggDirectShowOutputPin((AM_MEDIA_TYPE*)(p + 35 + sizeof(GUID)), name, this, this, &hr));
+ }
+
+ AddOutputPin(page.m_hdr.bitstream_serial_number, pPinOut);
+ } else if (type == 3 && !memcmp(p, "vorbis", 6)) {
+ if (COggSplitterOutputPin* pOggPin =
+ dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
+ pOggPin->AddComment(p + 6, page.GetCount() - 6 - 1);
+ }
+ } else if (type == 0x7F && page.GetCount() > 12 && *(long*)(p + 8) == 0x43614C66) { // Flac
+ // Ogg Flac : method 1
+ CAutoPtr<CBaseSplitterOutputPin> pPinOut;
+ name.Format(L"FLAC %d", i);
+ pPinOut.Attach(DNew COggFlacOutputPin(p + 12, page.GetCount() - 14, name, this, this, &hr));
+ AddOutputPin(page.m_hdr.bitstream_serial_number, pPinOut);
+ } else if (*(long*)(p - 1) == 0x43614C66) {
+ //bFlac = true;
+ //nWaitForMore++;
+ if (m_pFile->Read(page)) {
+ CAutoPtr<CBaseSplitterOutputPin> pPinOut;
+ name.Format(L"FLAC %d", i);
+ p = page.GetData();
+ pPinOut.Attach(DNew COggFlacOutputPin(p, page.GetCount(), name, this, this, &hr));
+ AddOutputPin(page.m_hdr.bitstream_serial_number, pPinOut);
+ }
+ } else if (!(type & 1) && nWaitForMore == 0) {
+ break;
+ }
+ }
+
+ if (COggTheoraOutputPin* p = dynamic_cast<COggTheoraOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
+ p->UnpackInitPage(page);
+ if (p->IsInitialized()) {
+ nWaitForMore--;
+ }
+ }
+
+ if (COggVorbisOutputPin* p = dynamic_cast<COggVorbisOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
+ p->UnpackInitPage(page);
+ if (p->IsInitialized()) {
+ nWaitForMore--;
+ }
+ }
+ }
+
+ if (m_pOutputs.IsEmpty()) {
+ return E_FAIL;
+ }
+
+ if (m_pFile->IsRandomAccess()) {
+ m_pFile->Seek(max(m_pFile->GetLength() - 65536, 0));
+
+ OggPage page;
+ while (m_pFile->Read(page)) {
+ COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number));
+ if (!pOggPin || page.m_hdr.granule_position == -1) {
+ continue;
+ }
+ REFERENCE_TIME rt = pOggPin->GetRefTime(page.m_hdr.granule_position);
+ m_rtDuration = max(rt, m_rtDuration);
+ }
+ }
+
+ m_rtNewStart = m_rtCurrent = 0;
+ m_rtNewStop = m_rtStop = m_rtDuration;
+
+ // comments
+
+ {
+ CAtlMap<CStringW, CStringW, CStringElementTraits<CStringW> > tagmap;
+ tagmap[L"TITLE"] = L"TITL";
+ tagmap[L"ARTIST"] = L"AUTH"; // not quite
+ tagmap[L"COPYRIGHT"] = L"CPYR";
+ tagmap[L"DESCRIPTION"] = L"DESC";
+
+ POSITION pos2 = tagmap.GetStartPosition();
+ while (pos2) {
+ CStringW oggtag, dsmtag;
+ tagmap.GetNextAssoc(pos2, oggtag, dsmtag);
+
+ POSITION pos = m_pOutputs.GetHeadPosition();
+ while (pos) {
+ COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>((CBaseOutputPin*)m_pOutputs.GetNext(pos));
+ if (!pOggPin) {
+ continue;
+ }
+
+ CStringW value = pOggPin->GetComment(oggtag);
+ if (!value.IsEmpty()) {
+ SetProperty(dsmtag, value);
+ break;
+ }
+ }
+ }
+
+ POSITION pos = m_pOutputs.GetHeadPosition();
+ while (pos && !ChapGetCount()) {
+ COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>((CBaseOutputPin*)m_pOutputs.GetNext(pos));
+ if (!pOggPin) {
+ continue;
+ }
+
+ for (int i = 1; pOggPin; i++) {
+ CStringW key;
+ key.Format(L"CHAPTER%02d", i);
+ CStringW time = pOggPin->GetComment(key);
+ if (time.IsEmpty()) {
+ break;
+ }
+ key.Format(L"CHAPTER%02dNAME", i);
+ CStringW name = pOggPin->GetComment(key);
+ if (name.IsEmpty()) {
+ name.Format(L"Chapter %d", i);
+ }
+ int h, m, s, ms;
+ WCHAR c;
+ if (7 != swscanf_s(time, L"%d%c%d%c%d%c%d", &h, &c, sizeof(WCHAR),
+ &m, &c, sizeof(WCHAR), &s, &c, sizeof(WCHAR), &ms)) {
+ break;
+ }
+ REFERENCE_TIME rt = ((((REFERENCE_TIME)h * 60 + m) * 60 + s) * 1000 + ms) * 10000;
+ ChapAppend(rt, name);
+ }
+ }
+ }
+
+ return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
}
bool COggSplitterFilter::DemuxInit()
{
- SetThreadName((DWORD)-1, "COggSplitterFilter");
- if (!m_pFile) {
- return false;
- }
+ SetThreadName((DWORD) - 1, "COggSplitterFilter");
+ if (!m_pFile) {
+ return false;
+ }
- return true;
+ return true;
}
void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
- if (rt <= 0 ) {
- m_pFile->Seek(0);
- } else if (m_rtDuration > 0) {
- // oh, the horror...
-
- __int64 len = m_pFile->GetLength();
- __int64 startpos = len * rt/m_rtDuration;
- //__int64 diff = 0;
-
- REFERENCE_TIME rtMinDiff = _I64_MAX;
-
- for (;;) {
- __int64 endpos = startpos;
- REFERENCE_TIME rtPos = -1;
-
- OggPage page;
- m_pFile->Seek(startpos);
- while (m_pFile->Read(page, false)) {
- if (page.m_hdr.granule_position == -1) {
- continue;
- }
-
- COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number));
- if (!pOggPin) {
- ASSERT(0);
- continue;
- }
-
- rtPos = pOggPin->GetRefTime(page.m_hdr.granule_position);
- endpos = m_pFile->GetPos();
-
- break;
- }
-
- __int64 rtDiff = rtPos - rt;
-
- if (rtDiff < 0) {
- rtDiff = -rtDiff;
-
- if (rtDiff < 1000000 || rtDiff >= rtMinDiff) {
- m_pFile->Seek(startpos);
- break;
- }
-
- rtMinDiff = rtDiff;
- }
-
- __int64 newpos = startpos;
-
- if (rtPos < rt && rtPos < m_rtDuration) {
- newpos = startpos + (__int64)((1.0*(rt - rtPos)/(m_rtDuration - rtPos)) * (len - startpos)) + 1024;
- if (newpos < endpos) {
- newpos = endpos + 1024;
- }
- } else if (rtPos > rt && rtPos > 0) {
- newpos = startpos - (__int64)((1.0*(rtPos - rt)/(rtPos - 0)) * (startpos - 0)) - 1024;
- if (newpos >= startpos) {
- newpos = startpos - 1024;
- }
- } else if (rtPos == rt) {
- m_pFile->Seek(startpos);
- break;
- } else {
- ASSERT(0);
- m_pFile->Seek(0);
- break;
- }
-
- //diff = newpos - startpos;
-
- startpos = max(min(newpos, len), 0);
- }
-
- m_pFile->Seek(startpos);
-
- POSITION pos = m_pOutputs.GetHeadPosition();
- while (pos) {
- COggSplitterOutputPin* pPin = dynamic_cast<COggSplitterOutputPin*>(static_cast<CBaseSplitterOutputPin*>(m_pOutputs.GetNext(pos)));
-
- if (!dynamic_cast<COggVideoOutputPin*>(pPin) && !dynamic_cast<COggTheoraOutputPin*>(pPin)) {
- continue;
- }
-
- bool fKeyFrameFound = false, fSkipKeyFrame = true;
- __int64 endpos = _I64_MAX;
-
- while (!(fKeyFrameFound && !fSkipKeyFrame) && startpos > 0) {
- OggPage page;
- while (!(fKeyFrameFound && !fSkipKeyFrame) && m_pFile->GetPos() < endpos && m_pFile->Read(page)) {
- if (page.m_hdr.granule_position == -1) {
- continue;
- }
-
- if (pPin != dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
- continue;
- }
-
- if (pPin->GetRefTime(page.m_hdr.granule_position) > rt) {
- break;
- }
-
- if (!fKeyFrameFound) {
- pPin->UnpackPage(page);
-
- CAutoPtr<OggPacket> p;
- while (p = pPin->GetPacket()) {
- if (p->bSyncPoint) {
- fKeyFrameFound = true;
- fSkipKeyFrame = p->fSkip;
- }
- }
-
- if (fKeyFrameFound) {
- break;
- }
- } else {
- pPin->UnpackPage(page);
-
- CAutoPtr<OggPacket> p;
- while (p = pPin->GetPacket()) {
- if (!p->fSkip) {
- fSkipKeyFrame = false;
- break;
- }
- }
- }
- }
-
- if (!(fKeyFrameFound && !fSkipKeyFrame)) {
- endpos = startpos;
- startpos = max(startpos - 10*65536, 0);
- }
-
- m_pFile->Seek(startpos);
- }
+ if (rt <= 0) {
+ m_pFile->Seek(0);
+ } else if (m_rtDuration > 0) {
+ // oh, the horror...
+
+ __int64 len = m_pFile->GetLength();
+ __int64 startpos = len * rt / m_rtDuration;
+ //__int64 diff = 0;
+
+ REFERENCE_TIME rtMinDiff = _I64_MAX;
+
+ for (;;) {
+ __int64 endpos = startpos;
+ REFERENCE_TIME rtPos = -1;
+
+ OggPage page;
+ m_pFile->Seek(startpos);
+ while (m_pFile->Read(page, false)) {
+ if (page.m_hdr.granule_position == -1) {
+ continue;
+ }
+
+ COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number));
+ if (!pOggPin) {
+ ASSERT(0);
+ continue;
+ }
+
+ rtPos = pOggPin->GetRefTime(page.m_hdr.granule_position);
+ endpos = m_pFile->GetPos();
+
+ break;
+ }
+
+ __int64 rtDiff = rtPos - rt;
+
+ if (rtDiff < 0) {
+ rtDiff = -rtDiff;
+
+ if (rtDiff < 1000000 || rtDiff >= rtMinDiff) {
+ m_pFile->Seek(startpos);
+ break;
+ }
+
+ rtMinDiff = rtDiff;
+ }
+
+ __int64 newpos = startpos;
+
+ if (rtPos < rt && rtPos < m_rtDuration) {
+ newpos = startpos + (__int64)((1.0 * (rt - rtPos) / (m_rtDuration - rtPos)) * (len - startpos)) + 1024;
+ if (newpos < endpos) {
+ newpos = endpos + 1024;
+ }
+ } else if (rtPos > rt && rtPos > 0) {
+ newpos = startpos - (__int64)((1.0 * (rtPos - rt) / (rtPos - 0)) * (startpos - 0)) - 1024;
+ if (newpos >= startpos) {
+ newpos = startpos - 1024;
+ }
+ } else if (rtPos == rt) {
+ m_pFile->Seek(startpos);
+ break;
+ } else {
+ ASSERT(0);
+ m_pFile->Seek(0);
+ break;
+ }
+
+ //diff = newpos - startpos;
+
+ startpos = max(min(newpos, len), 0);
+ }
+
+ m_pFile->Seek(startpos);
+
+ POSITION pos = m_pOutputs.GetHeadPosition();
+ while (pos) {
+ COggSplitterOutputPin* pPin = dynamic_cast<COggSplitterOutputPin*>(static_cast<CBaseSplitterOutputPin*>(m_pOutputs.GetNext(pos)));
+
+ if (!dynamic_cast<COggVideoOutputPin*>(pPin) && !dynamic_cast<COggTheoraOutputPin*>(pPin)) {
+ continue;
+ }
+
+ bool fKeyFrameFound = false, fSkipKeyFrame = true;
+ __int64 endpos = _I64_MAX;
+
+ while (!(fKeyFrameFound && !fSkipKeyFrame) && startpos > 0) {
+ OggPage page;
+ while (!(fKeyFrameFound && !fSkipKeyFrame) && m_pFile->GetPos() < endpos && m_pFile->Read(page)) {
+ if (page.m_hdr.granule_position == -1) {
+ continue;
+ }
+
+ if (pPin != dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
+ continue;
+ }
+
+ if (pPin->GetRefTime(page.m_hdr.granule_position) > rt) {
+ break;
+ }
+
+ if (!fKeyFrameFound) {
+ pPin->UnpackPage(page);
+
+ CAutoPtr<OggPacket> p;
+ while (p = pPin->GetPacket()) {
+ if (p->bSyncPoint) {
+ fKeyFrameFound = true;
+ fSkipKeyFrame = p->fSkip;
+ }
+ }
+
+ if (fKeyFrameFound) {
+ break;
+ }
+ } else {
+ pPin->UnpackPage(page);
+
+ CAutoPtr<OggPacket> p;
+ while (p = pPin->GetPacket()) {
+ if (!p->fSkip) {
+ fSkipKeyFrame = false;
+ break;
+ }
+ }
+ }
+ }
+
+ if (!(fKeyFrameFound && !fSkipKeyFrame)) {
+ endpos = startpos;
+ startpos = max(startpos - 10 * 65536, 0);
+ }
+
+ m_pFile->Seek(startpos);
+ }
#ifdef _DEBUG
- // verify kf
+ // verify kf
- {
- fKeyFrameFound = false;
+ {
+ fKeyFrameFound = false;
- OggPage page;
- while (!fKeyFrameFound && m_pFile->Read(page)) {
- if (page.m_hdr.granule_position == -1) {
- continue;
- }
+ OggPage page;
+ while (!fKeyFrameFound && m_pFile->Read(page)) {
+ if (page.m_hdr.granule_position == -1) {
+ continue;
+ }
- if (pPin != dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
- continue;
- }
+ if (pPin != dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
+ continue;
+ }
- REFERENCE_TIME rtPos = pPin->GetRefTime(page.m_hdr.granule_position);
- if (rtPos > rt) {
- break;
- }
+ REFERENCE_TIME rtPos = pPin->GetRefTime(page.m_hdr.granule_position);
+ if (rtPos > rt) {
+ break;
+ }
- pPin->UnpackPage(page);
+ pPin->UnpackPage(page);
- CAutoPtr<OggPacket> p;
- while (p = pPin->GetPacket()) {
- if (p->bSyncPoint) {
- fKeyFrameFound = true;
- break;
- }
- }
- }
+ CAutoPtr<OggPacket> p;
+ while (p = pPin->GetPacket()) {
+ if (p->bSyncPoint) {
+ fKeyFrameFound = true;
+ break;
+ }
+ }
+ }
- ASSERT(fKeyFrameFound);
+ ASSERT(fKeyFrameFound);
- m_pFile->Seek(startpos);
- }
+ m_pFile->Seek(startpos);
+ }
#endif
- break;
- }
- }
+ break;
+ }
+ }
}
bool COggSplitterFilter::DemuxLoop()
{
- HRESULT hr = S_OK;
-
- OggPage page;
- while (SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->Read(page, true, GetRequestHandle())) {
- COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number));
- if (!pOggPin) {
- ASSERT(0);
- continue;
- }
- if (!pOggPin->IsConnected()) {
- continue;
- }
- if (FAILED(hr = pOggPin->UnpackPage(page))) {
- ASSERT(0);
- break;
- }
- CAutoPtr<OggPacket> p;
- while (!CheckRequest(NULL) && SUCCEEDED(hr) && (p = pOggPin->GetPacket())) {
- if (!p->fSkip) {
- hr = DeliverPacket(p);
- }
- }
- }
-
- return true;
+ HRESULT hr = S_OK;
+
+ OggPage page;
+ while (SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->Read(page, true, GetRequestHandle())) {
+ COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number));
+ if (!pOggPin) {
+ ASSERT(0);
+ continue;
+ }
+ if (!pOggPin->IsConnected()) {
+ continue;
+ }
+ if (FAILED(hr = pOggPin->UnpackPage(page))) {
+ ASSERT(0);
+ break;
+ }
+ CAutoPtr<OggPacket> p;
+ while (!CheckRequest(NULL) && SUCCEEDED(hr) && (p = pOggPin->GetPacket())) {
+ if (!p->fSkip) {
+ hr = DeliverPacket(p);
+ }
+ }
+ }
+
+ return true;
}
//
@@ -586,10 +586,10 @@ bool COggSplitterFilter::DemuxLoop()
//
COggSourceFilter::COggSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : COggSplitterFilter(pUnk, phr)
+ : COggSplitterFilter(pUnk, phr)
{
- m_clsid = __uuidof(this);
- m_pInput.Free();
+ m_clsid = __uuidof(this);
+ m_pInput.Free();
}
//
@@ -597,187 +597,187 @@ COggSourceFilter::COggSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
//
COggSplitterOutputPin::COggSplitterOutputPin(LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseSplitterOutputPin(pName, pFilter, pLock, phr)
+ : CBaseSplitterOutputPin(pName, pFilter, pLock, phr)
{
- ResetState((DWORD)-1);
+ ResetState((DWORD) - 1);
}
void COggSplitterOutputPin::AddComment(BYTE* p, int len)
{
- bitstream bs(p, len);
- bs.getbits(bs.getbits(32)*8);
- for (int n = bs.getbits(32); n-- > 0; ) {
- CStringA str;
- for (int len = bs.getbits(32); len-- > 0; ) {
- str += (CHAR)bs.getbits(8);
- }
-
- CAtlList<CStringA> sl;
- Explode(str, sl, '=', 2);
- if (sl.GetCount() == 2) {
- CAutoPtr<CComment> p(DNew CComment(UTF8To16(sl.GetHead()), UTF8To16(sl.GetTail())));
-
- if (p->m_key == L"LANGUAGE") {
- CString lang = ISO6392ToLanguage(sl.GetTail()), iso6392 = LanguageToISO6392(CString(p->m_value));
-
- if (p->m_value.GetLength() == 3 && !lang.IsEmpty()) {
- SetName(CStringW(lang));
- SetProperty(L"LANG", p->m_value);
- } else if (!iso6392.IsEmpty()) {
- SetName(p->m_value);
- SetProperty(L"LANG", CStringW(iso6392));
- } else {
- SetName(p->m_value);
- SetProperty(L"NAME", p->m_value);
- }
- }
-
- m_pComments.AddTail(p);
- }
- }
- ASSERT(bs.getbits(1) == 1);
+ bitstream bs(p, len);
+ bs.getbits(bs.getbits(32) * 8);
+ for (int n = bs.getbits(32); n-- > 0;) {
+ CStringA str;
+ for (int len = bs.getbits(32); len-- > 0;) {
+ str += (CHAR)bs.getbits(8);
+ }
+
+ CAtlList<CStringA> sl;
+ Explode(str, sl, '=', 2);
+ if (sl.GetCount() == 2) {
+ CAutoPtr<CComment> p(DNew CComment(UTF8To16(sl.GetHead()), UTF8To16(sl.GetTail())));
+
+ if (p->m_key == L"LANGUAGE") {
+ CString lang = ISO6392ToLanguage(sl.GetTail()), iso6392 = LanguageToISO6392(CString(p->m_value));
+
+ if (p->m_value.GetLength() == 3 && !lang.IsEmpty()) {
+ SetName(CStringW(lang));
+ SetProperty(L"LANG", p->m_value);
+ } else if (!iso6392.IsEmpty()) {
+ SetName(p->m_value);
+ SetProperty(L"LANG", CStringW(iso6392));
+ } else {
+ SetName(p->m_value);
+ SetProperty(L"NAME", p->m_value);
+ }
+ }
+
+ m_pComments.AddTail(p);
+ }
+ }
+ ASSERT(bs.getbits(1) == 1);
}
CStringW COggSplitterOutputPin::GetComment(CStringW key)
{
- key.MakeUpper();
- CAtlList<CStringW> sl;
- POSITION pos = m_pComments.GetHeadPosition();
- while (pos) {
- CComment* p = m_pComments.GetNext(pos);
- if (key == p->m_key) {
- sl.AddTail(p->m_value);
- }
- }
- return Implode(sl, ';');
+ key.MakeUpper();
+ CAtlList<CStringW> sl;
+ POSITION pos = m_pComments.GetHeadPosition();
+ while (pos) {
+ CComment* p = m_pComments.GetNext(pos);
+ if (key == p->m_key) {
+ sl.AddTail(p->m_value);
+ }
+ }
+ return Implode(sl, ';');
}
void COggSplitterOutputPin::ResetState(DWORD seqnum)
{
- CAutoLock csAutoLock(&m_csPackets);
- m_packets.RemoveAll();
- m_lastpacket.Free();
- m_lastseqnum = seqnum;
- m_rtLast = 0;
- m_fSkip = true;
+ CAutoLock csAutoLock(&m_csPackets);
+ m_packets.RemoveAll();
+ m_lastpacket.Free();
+ m_lastseqnum = seqnum;
+ m_rtLast = 0;
+ m_fSkip = true;
}
HRESULT COggSplitterOutputPin::UnpackPage(OggPage& page)
{
- if (m_lastseqnum != page.m_hdr.page_sequence_number - 1) {
- ResetState(page.m_hdr.page_sequence_number);
- return S_FALSE; // FIXME
- } else {
- m_lastseqnum = page.m_hdr.page_sequence_number;
- }
-
- POSITION first = page.m_lens.GetHeadPosition();
- while (first && page.m_lens.GetAt(first) == 255) {
- page.m_lens.GetNext(first);
- }
- if (!first) {
- first = page.m_lens.GetTailPosition();
- }
-
- POSITION last = page.m_lens.GetTailPosition();
- while (last && page.m_lens.GetAt(last) == 255) {
- page.m_lens.GetPrev(last);
- }
- if (!last) {
- last = page.m_lens.GetTailPosition();
- }
-
- BYTE* pData = page.GetData();
-
- int i = 0, j = 0, len = 0;
-
- for (POSITION pos = page.m_lens.GetHeadPosition(); pos; page.m_lens.GetNext(pos)) {
- len = page.m_lens.GetAt(pos);
- j += len;
-
- if (len < 255 || pos == page.m_lens.GetTailPosition()) {
- if (first == pos && (page.m_hdr.header_type_flag & OggPageHeader::continued)) {
- // ASSERT(m_lastpacket);
-
- if (m_lastpacket) {
- int size = m_lastpacket->GetCount();
- m_lastpacket->SetCount(size + j-i);
- memcpy(m_lastpacket->GetData() + size, pData + i, j-i);
-
- CAutoLock csAutoLock(&m_csPackets);
-
- if (len < 255) {
- m_packets.AddTail(m_lastpacket);
- }
- }
- } else {
- CAutoPtr<OggPacket> p(DNew OggPacket());
-
- if (last == pos && page.m_hdr.granule_position != -1) {
- p->bDiscontinuity = m_fSkip;
- REFERENCE_TIME rtLast = m_rtLast;
- m_rtLast = GetRefTime(page.m_hdr.granule_position);
- // some bad encodings have a +/-1 frame difference from the normal timeline,
- // but these seem to cancel eachother out nicely so we can just ignore them
- // to make it play a bit more smooth.
- if (abs(rtLast - m_rtLast) == GetRefTime(1)) {
- m_rtLast = rtLast; // FIXME
- }
- m_fSkip = false;
- }
-
- p->TrackNumber = page.m_hdr.bitstream_serial_number;
-
- if (S_OK == UnpackPacket(p, pData + i, j-i)) {
- //if (p->TrackNumber == 1)
- //TRACE(_T("[%d]: %d, %I64d -> %I64d (skip=%d, disc=%d, sync=%d)\n"),
- // (int)p->TrackNumber, p->GetCount(), p->rtStart, p->rtStop,
- // (int)m_fSkip, (int)p->bDiscontinuity, (int)p->bSyncPoint);
-
- if (p->rtStart <= p->rtStop && p->rtStop <= p->rtStart + 10000000i64*60) {
- CAutoLock csAutoLock(&m_csPackets);
-
- m_rtLast = p->rtStop;
- p->fSkip = m_fSkip;
-
- if (len < 255) {
- m_packets.AddTail(p);
- } else {
- m_lastpacket = p;
- }
- } else {
- ASSERT(0);
- }
- }
- }
-
- i = j;
- }
- }
-
- return S_OK;
+ if (m_lastseqnum != page.m_hdr.page_sequence_number - 1) {
+ ResetState(page.m_hdr.page_sequence_number);
+ return S_FALSE; // FIXME
+ } else {
+ m_lastseqnum = page.m_hdr.page_sequence_number;
+ }
+
+ POSITION first = page.m_lens.GetHeadPosition();
+ while (first && page.m_lens.GetAt(first) == 255) {
+ page.m_lens.GetNext(first);
+ }
+ if (!first) {
+ first = page.m_lens.GetTailPosition();
+ }
+
+ POSITION last = page.m_lens.GetTailPosition();
+ while (last && page.m_lens.GetAt(last) == 255) {
+ page.m_lens.GetPrev(last);
+ }
+ if (!last) {
+ last = page.m_lens.GetTailPosition();
+ }
+
+ BYTE* pData = page.GetData();
+
+ int i = 0, j = 0, len = 0;
+
+ for (POSITION pos = page.m_lens.GetHeadPosition(); pos; page.m_lens.GetNext(pos)) {
+ len = page.m_lens.GetAt(pos);
+ j += len;
+
+ if (len < 255 || pos == page.m_lens.GetTailPosition()) {
+ if (first == pos && (page.m_hdr.header_type_flag & OggPageHeader::continued)) {
+ // ASSERT(m_lastpacket);
+
+ if (m_lastpacket) {
+ int size = m_lastpacket->GetCount();
+ m_lastpacket->SetCount(size + j - i);
+ memcpy(m_lastpacket->GetData() + size, pData + i, j - i);
+
+ CAutoLock csAutoLock(&m_csPackets);
+
+ if (len < 255) {
+ m_packets.AddTail(m_lastpacket);
+ }
+ }
+ } else {
+ CAutoPtr<OggPacket> p(DNew OggPacket());
+
+ if (last == pos && page.m_hdr.granule_position != -1) {
+ p->bDiscontinuity = m_fSkip;
+ REFERENCE_TIME rtLast = m_rtLast;
+ m_rtLast = GetRefTime(page.m_hdr.granule_position);
+ // some bad encodings have a +/-1 frame difference from the normal timeline,
+ // but these seem to cancel eachother out nicely so we can just ignore them
+ // to make it play a bit more smooth.
+ if (abs(rtLast - m_rtLast) == GetRefTime(1)) {
+ m_rtLast = rtLast; // FIXME
+ }
+ m_fSkip = false;
+ }
+
+ p->TrackNumber = page.m_hdr.bitstream_serial_number;
+
+ if (S_OK == UnpackPacket(p, pData + i, j - i)) {
+ //if (p->TrackNumber == 1)
+ //TRACE(_T("[%d]: %d, %I64d -> %I64d (skip=%d, disc=%d, sync=%d)\n"),
+ // (int)p->TrackNumber, p->GetCount(), p->rtStart, p->rtStop,
+ // (int)m_fSkip, (int)p->bDiscontinuity, (int)p->bSyncPoint);
+
+ if (p->rtStart <= p->rtStop && p->rtStop <= p->rtStart + 10000000i64 * 60) {
+ CAutoLock csAutoLock(&m_csPackets);
+
+ m_rtLast = p->rtStop;
+ p->fSkip = m_fSkip;
+
+ if (len < 255) {
+ m_packets.AddTail(p);
+ } else {
+ m_lastpacket = p;
+ }
+ } else {
+ ASSERT(0);
+ }
+ }
+ }
+
+ i = j;
+ }
+ }
+
+ return S_OK;
}
CAutoPtr<OggPacket> COggSplitterOutputPin::GetPacket()
{
- CAutoPtr<OggPacket> p;
- CAutoLock csAutoLock(&m_csPackets);
- if (m_packets.GetCount()) {
- p = m_packets.RemoveHead();
- }
- return p;
+ CAutoPtr<OggPacket> p;
+ CAutoLock csAutoLock(&m_csPackets);
+ if (m_packets.GetCount()) {
+ p = m_packets.RemoveHead();
+ }
+ return p;
}
HRESULT COggSplitterOutputPin::DeliverEndFlush()
{
- ResetState();
- return __super::DeliverEndFlush();
+ ResetState();
+ return __super::DeliverEndFlush();
}
HRESULT COggSplitterOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- ResetState();
- return __super::DeliverNewSegment(tStart, tStop, dRate);
+ ResetState();
+ return __super::DeliverNewSegment(tStart, tStop, dRate);
}
//
@@ -785,149 +785,149 @@ HRESULT COggSplitterOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENC
//
COggVorbisOutputPin::COggVorbisOutputPin(OggVorbisIdHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : COggSplitterOutputPin(pName, pFilter, pLock, phr)
+ : COggSplitterOutputPin(pName, pFilter, pLock, phr)
{
- m_audio_sample_rate = h->audio_sample_rate;
- m_blocksize[0] = 1<<h->blocksize_0;
- m_blocksize[1] = 1<<h->blocksize_1;
- m_lastblocksize = 0;
-
- CMediaType mt;
-
- mt.InitMediaType();
- mt.majortype = MEDIATYPE_Audio;
- mt.subtype = MEDIASUBTYPE_Vorbis;
- mt.formattype = FORMAT_VorbisFormat;
- VORBISFORMAT* vf = (VORBISFORMAT*)mt.AllocFormatBuffer(sizeof(VORBISFORMAT));
- memset(mt.Format(), 0, mt.FormatLength());
- vf->nChannels = h->audio_channels;
- vf->nSamplesPerSec = h->audio_sample_rate;
- vf->nAvgBitsPerSec = h->bitrate_nominal;
- vf->nMinBitsPerSec = h->bitrate_minimum;
- vf->nMaxBitsPerSec = h->bitrate_maximum;
- vf->fQuality = -1;
- mt.SetSampleSize(8192);
- m_mts.Add(mt);
-
- mt.InitMediaType();
- mt.majortype = MEDIATYPE_Audio;
- mt.subtype = MEDIASUBTYPE_Vorbis2;
- mt.formattype = FORMAT_VorbisFormat2;
- VORBISFORMAT2* vf2 = (VORBISFORMAT2*)mt.AllocFormatBuffer(sizeof(VORBISFORMAT2));
- memset(mt.Format(), 0, mt.FormatLength());
- vf2->Channels = h->audio_channels;
- vf2->SamplesPerSec = h->audio_sample_rate;
- mt.SetSampleSize(8192);
- m_mts.InsertAt(0, mt);
+ m_audio_sample_rate = h->audio_sample_rate;
+ m_blocksize[0] = 1 << h->blocksize_0;
+ m_blocksize[1] = 1 << h->blocksize_1;
+ m_lastblocksize = 0;
+
+ CMediaType mt;
+
+ mt.InitMediaType();
+ mt.majortype = MEDIATYPE_Audio;
+ mt.subtype = MEDIASUBTYPE_Vorbis;
+ mt.formattype = FORMAT_VorbisFormat;
+ VORBISFORMAT* vf = (VORBISFORMAT*)mt.AllocFormatBuffer(sizeof(VORBISFORMAT));
+ memset(mt.Format(), 0, mt.FormatLength());
+ vf->nChannels = h->audio_channels;
+ vf->nSamplesPerSec = h->audio_sample_rate;
+ vf->nAvgBitsPerSec = h->bitrate_nominal;
+ vf->nMinBitsPerSec = h->bitrate_minimum;
+ vf->nMaxBitsPerSec = h->bitrate_maximum;
+ vf->fQuality = -1;
+ mt.SetSampleSize(8192);
+ m_mts.Add(mt);
+
+ mt.InitMediaType();
+ mt.majortype = MEDIATYPE_Audio;
+ mt.subtype = MEDIASUBTYPE_Vorbis2;
+ mt.formattype = FORMAT_VorbisFormat2;
+ VORBISFORMAT2* vf2 = (VORBISFORMAT2*)mt.AllocFormatBuffer(sizeof(VORBISFORMAT2));
+ memset(mt.Format(), 0, mt.FormatLength());
+ vf2->Channels = h->audio_channels;
+ vf2->SamplesPerSec = h->audio_sample_rate;
+ mt.SetSampleSize(8192);
+ m_mts.InsertAt(0, mt);
}
HRESULT COggVorbisOutputPin::UnpackInitPage(OggPage& page)
{
- HRESULT hr = __super::UnpackPage(page);
-
- while (m_packets.GetCount()) {
- Packet* p = m_packets.GetHead();
-
- if (p->GetCount() >= 6 && p->GetAt(0) == 0x05) {
- // yeah, right, we are going to be parsing this backwards! :P
- bitstream bs(p->GetData(), p->GetCount(), true);
- while (bs.hasbits(-1) && bs.getbits(-1) != 1) {
- ;
- }
- for (int cnt = 0; bs.hasbits(-8-16-16-1-6); cnt++) {
- unsigned int modes = bs.showbits(-6) + 1;
-
- unsigned int mapping = bs.getbits(-8);
- unsigned int transformtype = bs.getbits(-16);
- unsigned int windowtype = bs.getbits(-16);
- unsigned int blockflag = bs.getbits(-1);
- UNREFERENCED_PARAMETER(mapping);
-
- if (transformtype != 0 || windowtype != 0) {
- ASSERT(modes == cnt);
- UNREFERENCED_PARAMETER(modes);
- break;
- }
-
- m_blockflags.InsertAt(0, !!blockflag);
- }
- }
-
- int cnt = m_initpackets.GetCount();
- if (cnt <= 3 && (p->GetCount() >= 6 && p->GetAt(0) == 1+cnt*2)) {
- VORBISFORMAT2* vf2 = (VORBISFORMAT2*)m_mts[0].Format();
- vf2->HeaderSize[cnt] = p->GetCount();
- int len = m_mts[0].FormatLength();
- memcpy(m_mts[0].ReallocFormatBuffer(len + p->GetCount()) + len, p->GetData(), p->GetCount());
- }
-
- m_initpackets.AddTail(m_packets.RemoveHead());
- }
-
- return hr;
+ HRESULT hr = __super::UnpackPage(page);
+
+ while (m_packets.GetCount()) {
+ Packet* p = m_packets.GetHead();
+
+ if (p->GetCount() >= 6 && p->GetAt(0) == 0x05) {
+ // yeah, right, we are going to be parsing this backwards! :P
+ bitstream bs(p->GetData(), p->GetCount(), true);
+ while (bs.hasbits(-1) && bs.getbits(-1) != 1) {
+ ;
+ }
+ for (int cnt = 0; bs.hasbits(-8 - 16 - 16 - 1 - 6); cnt++) {
+ unsigned int modes = bs.showbits(-6) + 1;
+
+ unsigned int mapping = bs.getbits(-8);
+ unsigned int transformtype = bs.getbits(-16);
+ unsigned int windowtype = bs.getbits(-16);
+ unsigned int blockflag = bs.getbits(-1);
+ UNREFERENCED_PARAMETER(mapping);
+
+ if (transformtype != 0 || windowtype != 0) {
+ ASSERT(modes == cnt);
+ UNREFERENCED_PARAMETER(modes);
+ break;
+ }
+
+ m_blockflags.InsertAt(0, !!blockflag);
+ }
+ }
+
+ int cnt = m_initpackets.GetCount();
+ if (cnt <= 3 && (p->GetCount() >= 6 && p->GetAt(0) == 1 + cnt * 2)) {
+ VORBISFORMAT2* vf2 = (VORBISFORMAT2*)m_mts[0].Format();
+ vf2->HeaderSize[cnt] = p->GetCount();
+ int len = m_mts[0].FormatLength();
+ memcpy(m_mts[0].ReallocFormatBuffer(len + p->GetCount()) + len, p->GetData(), p->GetCount());
+ }
+
+ m_initpackets.AddTail(m_packets.RemoveHead());
+ }
+
+ return hr;
}
REFERENCE_TIME COggVorbisOutputPin::GetRefTime(__int64 granule_position)
{
- REFERENCE_TIME rt = granule_position * 10000000 / m_audio_sample_rate;
- return rt;
+ REFERENCE_TIME rt = granule_position * 10000000 / m_audio_sample_rate;
+ return rt;
}
HRESULT COggVorbisOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len)
{
- if (len > 0 && m_blockflags.GetCount()) {
- bitstream bs(pData, len);
- if (bs.getbits(1) == 0) {
- int x = m_blockflags.GetCount()-1, n = 0;
- while (x) {
- n++;
- x >>= 1;
- }
- DWORD blocksize = m_blocksize[m_blockflags[bs.getbits(n)]?1:0];
- if (m_lastblocksize) {
- m_rtLast += GetRefTime((m_lastblocksize + blocksize) >> 2);
- }
- m_lastblocksize = blocksize;
- }
- }
-
- p->bSyncPoint = TRUE;
- p->rtStart = m_rtLast;
- p->rtStop = m_rtLast+1;
- p->SetData(pData, len);
-
- return S_OK;
+ if (len > 0 && m_blockflags.GetCount()) {
+ bitstream bs(pData, len);
+ if (bs.getbits(1) == 0) {
+ int x = m_blockflags.GetCount() - 1, n = 0;
+ while (x) {
+ n++;
+ x >>= 1;
+ }
+ DWORD blocksize = m_blocksize[m_blockflags[bs.getbits(n)] ? 1 : 0];
+ if (m_lastblocksize) {
+ m_rtLast += GetRefTime((m_lastblocksize + blocksize) >> 2);
+ }
+ m_lastblocksize = blocksize;
+ }
+ }
+
+ p->bSyncPoint = TRUE;
+ p->rtStart = m_rtLast;
+ p->rtStop = m_rtLast + 1;
+ p->SetData(pData, len);
+
+ return S_OK;
}
HRESULT COggVorbisOutputPin::DeliverPacket(CAutoPtr<OggPacket> p)
{
- if (p->GetCount() > 0 && (p->GetAt(0)&1)) {
- return S_OK;
- }
+ if (p->GetCount() > 0 && (p->GetAt(0) & 1)) {
+ return S_OK;
+ }
- return __super::DeliverPacket(p);
+ return __super::DeliverPacket(p);
}
HRESULT COggVorbisOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- HRESULT hr = __super::DeliverNewSegment(tStart, tStop, dRate);
-
- m_lastblocksize = 0;
-
- if (m_mt.subtype == MEDIASUBTYPE_Vorbis) {
- POSITION pos = m_initpackets.GetHeadPosition();
- while (pos) {
- Packet* pi = m_initpackets.GetNext(pos);
- CAutoPtr<OggPacket> p(DNew OggPacket());
- p->TrackNumber = pi->TrackNumber;
- p->bDiscontinuity = p->bSyncPoint = FALSE;//TRUE;
- p->rtStart = p->rtStop = 0;
- p->Copy(*pi);
- __super::DeliverPacket(p);
- }
- }
-
- return hr;
+ HRESULT hr = __super::DeliverNewSegment(tStart, tStop, dRate);
+
+ m_lastblocksize = 0;
+
+ if (m_mt.subtype == MEDIASUBTYPE_Vorbis) {
+ POSITION pos = m_initpackets.GetHeadPosition();
+ while (pos) {
+ Packet* pi = m_initpackets.GetNext(pos);
+ CAutoPtr<OggPacket> p(DNew OggPacket());
+ p->TrackNumber = pi->TrackNumber;
+ p->bDiscontinuity = p->bSyncPoint = FALSE;//TRUE;
+ p->rtStart = p->rtStop = 0;
+ p->Copy(*pi);
+ __super::DeliverPacket(p);
+ }
+ }
+
+ return hr;
}
//
@@ -935,156 +935,156 @@ HRESULT COggVorbisOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_
//
COggFlacOutputPin::COggFlacOutputPin(BYTE* h, int nCount, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : COggSplitterOutputPin(pName, pFilter, pLock, phr)
+ : COggSplitterOutputPin(pName, pFilter, pLock, phr)
{
- CGolombBuffer Buffer(h, nCount);
-
- Buffer.BitRead(1); // Last-metadata-block flag
-
- if (Buffer.BitRead(7) != 0) { // Should be a STREAMINFO block
- if (phr) {
- *phr = VFW_E_INVALID_FILE_FORMAT;
- }
- return;
- }
-
- Buffer.BitRead(24); // Length (in bytes) of metadata to follow
- Buffer.ReadShort(); // m_nMinBlocksize
- Buffer.ReadShort(); // m_nMaxBlocksize
- Buffer.BitRead(24); // m_nMinFrameSize
- Buffer.BitRead(24); // m_nMaxFrameSize
- m_nSamplesPerSec = (int)Buffer.BitRead(20);
- m_nChannels = (int)Buffer.BitRead(3) + 1;
- m_wBitsPerSample = (WORD)Buffer.BitRead(5) + 1;
- Buffer.BitRead(36); // m_i64TotalNumSamples
- m_nAvgBytesPerSec = (m_nChannels * (m_wBitsPerSample >> 3)) * m_nSamplesPerSec;
-
- CMediaType mt;
-
- mt.majortype = MEDIATYPE_Audio;
- mt.subtype = MEDIASUBTYPE_FLAC_FRAMED;
- mt.formattype = FORMAT_WaveFormatEx;
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX));
- memset(wfe, 0, sizeof(WAVEFORMATEX));
- wfe->cbSize = sizeof(WAVEFORMATEX);
- wfe->wFormatTag = WAVE_FORMAT_FLAC;
- wfe->nSamplesPerSec = m_nSamplesPerSec;
- wfe->nAvgBytesPerSec = m_nAvgBytesPerSec;
- wfe->nChannels = m_nChannels;
- wfe->nBlockAlign = 1;
- wfe->wBitsPerSample = m_wBitsPerSample;
-
- m_mts.InsertAt(0, mt);
- *phr = S_OK;
+ CGolombBuffer Buffer(h, nCount);
+
+ Buffer.BitRead(1); // Last-metadata-block flag
+
+ if (Buffer.BitRead(7) != 0) { // Should be a STREAMINFO block
+ if (phr) {
+ *phr = VFW_E_INVALID_FILE_FORMAT;
+ }
+ return;
+ }
+
+ Buffer.BitRead(24); // Length (in bytes) of metadata to follow
+ Buffer.ReadShort(); // m_nMinBlocksize
+ Buffer.ReadShort(); // m_nMaxBlocksize
+ Buffer.BitRead(24); // m_nMinFrameSize
+ Buffer.BitRead(24); // m_nMaxFrameSize
+ m_nSamplesPerSec = (int)Buffer.BitRead(20);
+ m_nChannels = (int)Buffer.BitRead(3) + 1;
+ m_wBitsPerSample = (WORD)Buffer.BitRead(5) + 1;
+ Buffer.BitRead(36); // m_i64TotalNumSamples
+ m_nAvgBytesPerSec = (m_nChannels * (m_wBitsPerSample >> 3)) * m_nSamplesPerSec;
+
+ CMediaType mt;
+
+ mt.majortype = MEDIATYPE_Audio;
+ mt.subtype = MEDIASUBTYPE_FLAC_FRAMED;
+ mt.formattype = FORMAT_WaveFormatEx;
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX));
+ memset(wfe, 0, sizeof(WAVEFORMATEX));
+ wfe->cbSize = sizeof(WAVEFORMATEX);
+ wfe->wFormatTag = WAVE_FORMAT_FLAC;
+ wfe->nSamplesPerSec = m_nSamplesPerSec;
+ wfe->nAvgBytesPerSec = m_nAvgBytesPerSec;
+ wfe->nChannels = m_nChannels;
+ wfe->nBlockAlign = 1;
+ wfe->wBitsPerSample = m_wBitsPerSample;
+
+ m_mts.InsertAt(0, mt);
+ *phr = S_OK;
}
REFERENCE_TIME COggFlacOutputPin::GetRefTime(__int64 granule_position)
{
- REFERENCE_TIME rt = (granule_position * UNITS) / m_nSamplesPerSec;
- return rt;
+ REFERENCE_TIME rt = (granule_position * UNITS) / m_nSamplesPerSec;
+ return rt;
}
HRESULT COggFlacOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len)
{
- if (pData[0] != 0xFF || (pData[1] & 0xFE) != 0xF8) {
- return S_FALSE;
- }
+ if (pData[0] != 0xFF || (pData[1] & 0xFE) != 0xF8) {
+ return S_FALSE;
+ }
- p->bSyncPoint = TRUE;
- p->rtStart = m_rtLast;
- p->rtStop = m_rtLast+1; // TODO : find packet duration !
- p->SetData(pData, len);
+ p->bSyncPoint = TRUE;
+ p->rtStart = m_rtLast;
+ p->rtStop = m_rtLast + 1; // TODO : find packet duration !
+ p->SetData(pData, len);
- return S_OK;
+ return S_OK;
}
HRESULT COggFlacOutputPin::DeliverPacket(CAutoPtr<OggPacket> p)
{
- if (p->GetCount() > 0 && (p->GetAt(0)&1)) {
- return S_OK;
- }
+ if (p->GetCount() > 0 && (p->GetAt(0) & 1)) {
+ return S_OK;
+ }
- return __super::DeliverPacket(p);
+ return __super::DeliverPacket(p);
}
HRESULT COggFlacOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- HRESULT hr = __super::DeliverNewSegment(tStart, tStop, dRate);
-
- m_lastblocksize = 0;
-
- if (m_mt.subtype == MEDIASUBTYPE_FLAC_FRAMED) {
- POSITION pos = m_initpackets.GetHeadPosition();
- while (pos) {
- Packet* pi = m_initpackets.GetNext(pos);
- CAutoPtr<OggPacket> p(DNew OggPacket());
- p->TrackNumber = pi->TrackNumber;
- p->bDiscontinuity = p->bSyncPoint = FALSE;//TRUE;
- p->rtStart = p->rtStop = 0;
- p->Copy(*pi);
- __super::DeliverPacket(p);
- }
- }
-
- return hr;
+ HRESULT hr = __super::DeliverNewSegment(tStart, tStop, dRate);
+
+ m_lastblocksize = 0;
+
+ if (m_mt.subtype == MEDIASUBTYPE_FLAC_FRAMED) {
+ POSITION pos = m_initpackets.GetHeadPosition();
+ while (pos) {
+ Packet* pi = m_initpackets.GetNext(pos);
+ CAutoPtr<OggPacket> p(DNew OggPacket());
+ p->TrackNumber = pi->TrackNumber;
+ p->bDiscontinuity = p->bSyncPoint = FALSE;//TRUE;
+ p->rtStart = p->rtStop = 0;
+ p->Copy(*pi);
+ __super::DeliverPacket(p);
+ }
+ }
+
+ return hr;
}
//
// COggDirectShowOutputPin
//
COggDirectShowOutputPin::COggDirectShowOutputPin(AM_MEDIA_TYPE* pmt, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : COggSplitterOutputPin(pName, pFilter, pLock, phr)
+ : COggSplitterOutputPin(pName, pFilter, pLock, phr)
{
- CMediaType mt;
- memcpy((AM_MEDIA_TYPE*)&mt, pmt, FIELD_OFFSET(AM_MEDIA_TYPE, pUnk));
- mt.SetFormat((BYTE*)(pmt+1), pmt->cbFormat);
- mt.SetSampleSize(1);
- if (mt.majortype == MEDIATYPE_Video) { // TODO: find samples for audio and find out what to return in GetRefTime...
- m_mts.Add(mt);
- }
+ CMediaType mt;
+ memcpy((AM_MEDIA_TYPE*)&mt, pmt, FIELD_OFFSET(AM_MEDIA_TYPE, pUnk));
+ mt.SetFormat((BYTE*)(pmt + 1), pmt->cbFormat);
+ mt.SetSampleSize(1);
+ if (mt.majortype == MEDIATYPE_Video) { // TODO: find samples for audio and find out what to return in GetRefTime...
+ m_mts.Add(mt);
+ }
}
REFERENCE_TIME COggDirectShowOutputPin::GetRefTime(__int64 granule_position)
{
- REFERENCE_TIME rt = 0;
+ REFERENCE_TIME rt = 0;
- if (m_mt.majortype == MEDIATYPE_Video) {
- rt = granule_position * ((VIDEOINFOHEADER*)m_mt.Format())->AvgTimePerFrame;
- } else if (m_mt.majortype == MEDIATYPE_Audio) {
- rt = granule_position; // ((WAVEFORMATEX*)m_mt.Format())-> // TODO
- }
+ if (m_mt.majortype == MEDIATYPE_Video) {
+ rt = granule_position * ((VIDEOINFOHEADER*)m_mt.Format())->AvgTimePerFrame;
+ } else if (m_mt.majortype == MEDIATYPE_Audio) {
+ rt = granule_position; // ((WAVEFORMATEX*)m_mt.Format())-> // TODO
+ }
- return rt;
+ return rt;
}
HRESULT COggDirectShowOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len)
{
- int i = 0;
+ int i = 0;
- BYTE hdr = pData[i++];
+ BYTE hdr = pData[i++];
- if (!(hdr&1)) {
- // TODO: verify if this was still present in the old format (haven't found one sample yet)
- BYTE nLenBytes = (hdr>>6)|((hdr&2)<<1);
- __int64 Length = 0;
- for (int j = 0; j < nLenBytes; j++) {
- Length |= (__int64)pData[i++] << (j << 3);
- }
+ if (!(hdr & 1)) {
+ // TODO: verify if this was still present in the old format (haven't found one sample yet)
+ BYTE nLenBytes = (hdr >> 6) | ((hdr & 2) << 1);
+ __int64 Length = 0;
+ for (int j = 0; j < nLenBytes; j++) {
+ Length |= (__int64)pData[i++] << (j << 3);
+ }
- if (len < i) {
- ASSERT(0);
- return E_FAIL;
- }
+ if (len < i) {
+ ASSERT(0);
+ return E_FAIL;
+ }
- p->bSyncPoint = !!(hdr&8);
- p->rtStart = m_rtLast;
- p->rtStop = m_rtLast + (nLenBytes ? GetRefTime(Length) : GetRefTime(1));
- p->SetData(&pData[i], len - i);
+ p->bSyncPoint = !!(hdr & 8);
+ p->rtStart = m_rtLast;
+ p->rtStop = m_rtLast + (nLenBytes ? GetRefTime(Length) : GetRefTime(1));
+ p->SetData(&pData[i], len - i);
- return S_OK;
- }
+ return S_OK;
+ }
- return S_FALSE;
+ return S_FALSE;
}
//
@@ -1092,45 +1092,45 @@ HRESULT COggDirectShowOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pDat
//
COggStreamOutputPin::COggStreamOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : COggSplitterOutputPin(pName, pFilter, pLock, phr)
+ : COggSplitterOutputPin(pName, pFilter, pLock, phr)
{
- m_time_unit = h->time_unit;
- m_samples_per_unit = h->samples_per_unit;
- m_default_len = h->default_len;
+ m_time_unit = h->time_unit;
+ m_samples_per_unit = h->samples_per_unit;
+ m_default_len = h->default_len;
}
REFERENCE_TIME COggStreamOutputPin::GetRefTime(__int64 granule_position)
{
- return granule_position * m_time_unit / m_samples_per_unit;
+ return granule_position * m_time_unit / m_samples_per_unit;
}
HRESULT COggStreamOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len)
{
- int i = 0;
+ int i = 0;
- BYTE hdr = pData[i++];
+ BYTE hdr = pData[i++];
- if (!(hdr&1)) {
- BYTE nLenBytes = (hdr>>6)|((hdr&2)<<1);
- __int64 Length = 0;
- for (int j = 0; j < nLenBytes; j++) {
- Length |= (__int64)pData[i++] << (j << 3);
- }
+ if (!(hdr & 1)) {
+ BYTE nLenBytes = (hdr >> 6) | ((hdr & 2) << 1);
+ __int64 Length = 0;
+ for (int j = 0; j < nLenBytes; j++) {
+ Length |= (__int64)pData[i++] << (j << 3);
+ }
- if (len < i) {
- ASSERT(0);
- return E_FAIL;
- }
+ if (len < i) {
+ ASSERT(0);
+ return E_FAIL;
+ }
- p->bSyncPoint = !!(hdr&8);
- p->rtStart = m_rtLast;
- p->rtStop = m_rtLast + (nLenBytes ? GetRefTime(Length) : GetRefTime(m_default_len));
- p->SetData(&pData[i], len - i);
+ p->bSyncPoint = !!(hdr & 8);
+ p->rtStart = m_rtLast;
+ p->rtStop = m_rtLast + (nLenBytes ? GetRefTime(Length) : GetRefTime(m_default_len));
+ p->SetData(&pData[i], len - i);
- return S_OK;
- }
+ return S_OK;
+ }
- return S_FALSE;
+ return S_FALSE;
}
//
@@ -1138,44 +1138,44 @@ HRESULT COggStreamOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, i
//
COggVideoOutputPin::COggVideoOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : COggStreamOutputPin(h, pName, pFilter, pLock, phr)
+ : COggStreamOutputPin(h, pName, pFilter, pLock, phr)
{
- int extra = (int)h->size - sizeof(OggStreamHeader);
- extra = max(extra, 0);
-
- CMediaType mt;
- mt.majortype = MEDIATYPE_Video;
- mt.subtype = FOURCCMap(MAKEFOURCC(h->subtype[0],h->subtype[1],h->subtype[2],h->subtype[3]));
- mt.formattype = FORMAT_VideoInfo;
- VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + extra);
- memset(mt.Format(), 0, mt.FormatLength());
- memcpy(mt.Format() + sizeof(VIDEOINFOHEADER), h+1, extra);
- pvih->AvgTimePerFrame = h->time_unit / h->samples_per_unit;
- pvih->bmiHeader.biWidth = h->v.w;
- pvih->bmiHeader.biHeight = h->v.h;
- pvih->bmiHeader.biBitCount = (WORD)h->bps;
- pvih->bmiHeader.biCompression = mt.subtype.Data1;
- switch (pvih->bmiHeader.biCompression) {
- case BI_RGB:
- case BI_BITFIELDS:
- mt.subtype =
- pvih->bmiHeader.biBitCount == 1 ? MEDIASUBTYPE_RGB1 :
- pvih->bmiHeader.biBitCount == 4 ? MEDIASUBTYPE_RGB4 :
- pvih->bmiHeader.biBitCount == 8 ? MEDIASUBTYPE_RGB8 :
- pvih->bmiHeader.biBitCount == 16 ? MEDIASUBTYPE_RGB565 :
- pvih->bmiHeader.biBitCount == 24 ? MEDIASUBTYPE_RGB24 :
- pvih->bmiHeader.biBitCount == 32 ? MEDIASUBTYPE_RGB32 :
- MEDIASUBTYPE_NULL;
- break;
- case BI_RLE8:
- mt.subtype = MEDIASUBTYPE_RGB8;
- break;
- case BI_RLE4:
- mt.subtype = MEDIASUBTYPE_RGB4;
- break;
- }
- mt.SetSampleSize(max(h->buffersize, 1));
- m_mts.Add(mt);
+ int extra = (int)h->size - sizeof(OggStreamHeader);
+ extra = max(extra, 0);
+
+ CMediaType mt;
+ mt.majortype = MEDIATYPE_Video;
+ mt.subtype = FOURCCMap(MAKEFOURCC(h->subtype[0], h->subtype[1], h->subtype[2], h->subtype[3]));
+ mt.formattype = FORMAT_VideoInfo;
+ VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + extra);
+ memset(mt.Format(), 0, mt.FormatLength());
+ memcpy(mt.Format() + sizeof(VIDEOINFOHEADER), h + 1, extra);
+ pvih->AvgTimePerFrame = h->time_unit / h->samples_per_unit;
+ pvih->bmiHeader.biWidth = h->v.w;
+ pvih->bmiHeader.biHeight = h->v.h;
+ pvih->bmiHeader.biBitCount = (WORD)h->bps;
+ pvih->bmiHeader.biCompression = mt.subtype.Data1;
+ switch (pvih->bmiHeader.biCompression) {
+ case BI_RGB:
+ case BI_BITFIELDS:
+ mt.subtype =
+ pvih->bmiHeader.biBitCount == 1 ? MEDIASUBTYPE_RGB1 :
+ pvih->bmiHeader.biBitCount == 4 ? MEDIASUBTYPE_RGB4 :
+ pvih->bmiHeader.biBitCount == 8 ? MEDIASUBTYPE_RGB8 :
+ pvih->bmiHeader.biBitCount == 16 ? MEDIASUBTYPE_RGB565 :
+ pvih->bmiHeader.biBitCount == 24 ? MEDIASUBTYPE_RGB24 :
+ pvih->bmiHeader.biBitCount == 32 ? MEDIASUBTYPE_RGB32 :
+ MEDIASUBTYPE_NULL;
+ break;
+ case BI_RLE8:
+ mt.subtype = MEDIASUBTYPE_RGB8;
+ break;
+ case BI_RLE4:
+ mt.subtype = MEDIASUBTYPE_RGB4;
+ break;
+ }
+ mt.SetSampleSize(max(h->buffersize, 1));
+ m_mts.Add(mt);
}
//
@@ -1183,27 +1183,27 @@ COggVideoOutputPin::COggVideoOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseF
//
COggAudioOutputPin::COggAudioOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : COggStreamOutputPin(h, pName, pFilter, pLock, phr)
+ : COggStreamOutputPin(h, pName, pFilter, pLock, phr)
{
- int extra = (int)h->size - sizeof(OggStreamHeader);
- extra = max(extra, 0);
-
- CMediaType mt;
- mt.majortype = MEDIATYPE_Audio;
- mt.subtype = FOURCCMap(strtol(CStringA(h->subtype, 4), NULL, 16));
- mt.formattype = FORMAT_WaveFormatEx;
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX) + extra);
- memset(mt.Format(), 0, mt.FormatLength());
- memcpy(mt.Format() + sizeof(WAVEFORMATEX), h+1, extra);
- wfe->cbSize = extra;
- wfe->wFormatTag = (WORD)mt.subtype.Data1;
- wfe->nChannels = h->a.nChannels;
- wfe->nSamplesPerSec = (DWORD)(10000000i64 * h->samples_per_unit / h->time_unit);
- wfe->wBitsPerSample = (WORD)h->bps;
- wfe->nAvgBytesPerSec = h->a.nAvgBytesPerSec; // TODO: verify for PCM
- wfe->nBlockAlign = h->a.nBlockAlign; // TODO: verify for PCM
- mt.SetSampleSize(max(h->buffersize, 1));
- m_mts.Add(mt);
+ int extra = (int)h->size - sizeof(OggStreamHeader);
+ extra = max(extra, 0);
+
+ CMediaType mt;
+ mt.majortype = MEDIATYPE_Audio;
+ mt.subtype = FOURCCMap(strtol(CStringA(h->subtype, 4), NULL, 16));
+ mt.formattype = FORMAT_WaveFormatEx;
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX) + extra);
+ memset(mt.Format(), 0, mt.FormatLength());
+ memcpy(mt.Format() + sizeof(WAVEFORMATEX), h + 1, extra);
+ wfe->cbSize = extra;
+ wfe->wFormatTag = (WORD)mt.subtype.Data1;
+ wfe->nChannels = h->a.nChannels;
+ wfe->nSamplesPerSec = (DWORD)(10000000i64 * h->samples_per_unit / h->time_unit);
+ wfe->wBitsPerSample = (WORD)h->bps;
+ wfe->nAvgBytesPerSec = h->a.nAvgBytesPerSec; // TODO: verify for PCM
+ wfe->nBlockAlign = h->a.nBlockAlign; // TODO: verify for PCM
+ mt.SetSampleSize(max(h->buffersize, 1));
+ m_mts.Add(mt);
}
//
@@ -1211,108 +1211,108 @@ COggAudioOutputPin::COggAudioOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseF
//
COggTextOutputPin::COggTextOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : COggStreamOutputPin(h, pName, pFilter, pLock, phr)
+ : COggStreamOutputPin(h, pName, pFilter, pLock, phr)
{
- CMediaType mt;
- mt.majortype = MEDIATYPE_Text;
- mt.subtype = MEDIASUBTYPE_NULL;
- mt.formattype = FORMAT_None;
- mt.SetSampleSize(1);
- m_mts.Add(mt);
+ CMediaType mt;
+ mt.majortype = MEDIATYPE_Text;
+ mt.subtype = MEDIASUBTYPE_NULL;
+ mt.formattype = FORMAT_None;
+ mt.SetSampleSize(1);
+ m_mts.Add(mt);
}
// COggTheoraOutputPin
COggTheoraOutputPin::COggTheoraOutputPin(BYTE* p, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : COggSplitterOutputPin(pName, pFilter, pLock, phr)
+ : COggSplitterOutputPin(pName, pFilter, pLock, phr)
{
- CMediaType mt;
- mt.majortype = MEDIATYPE_Video;
- mt.subtype = FOURCCMap('OEHT');
- mt.formattype = FORMAT_MPEG2_VIDEO;
- MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(sizeof(MPEG2VIDEOINFO));
- memset(mt.Format(), 0, mt.FormatLength());
- vih->hdr.bmiHeader.biSize = sizeof(vih->hdr.bmiHeader);
- vih->hdr.bmiHeader.biWidth = *(WORD*)&p[10] >> 4;
- vih->hdr.bmiHeader.biHeight = *(WORD*)&p[12] >> 4;
- vih->hdr.bmiHeader.biCompression = 'OEHT';
- vih->hdr.bmiHeader.biPlanes = 1;
- vih->hdr.bmiHeader.biBitCount = 24;
- m_nFpsNum = (p[22]<<24)|(p[23]<<16)|(p[24]<<8)|p[25];
- m_nFpsDenum = (p[26]<<24)|(p[27]<<16)|(p[28]<<8)|p[29];
- if (m_nFpsNum) {
- m_rtAvgTimePerFrame = (REFERENCE_TIME)(10000000.0 * m_nFpsDenum / m_nFpsNum);
- vih->hdr.AvgTimePerFrame = m_rtAvgTimePerFrame;
- }
- vih->hdr.dwPictAspectRatioX = (p[14]<<16)|(p[15]<<8)|p[16];
- vih->hdr.dwPictAspectRatioY = (p[17]<<16)|(p[18]<<8)|p[19];
-
- m_KfgShift = (((p[40]<<8)+p[41]) &0x3E0) >> 5;
- m_nIndexOffset = TH_VERSION_CHECK(p[7],p[8],p[9],3,2,1);
-
- if (m_KfgShift == 0) {
- m_KfgShift = 6; // Is it really default value ?
- }
-
- mt.bFixedSizeSamples = 0;
- m_mts.Add(mt);
+ CMediaType mt;
+ mt.majortype = MEDIATYPE_Video;
+ mt.subtype = FOURCCMap('OEHT');
+ mt.formattype = FORMAT_MPEG2_VIDEO;
+ MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(sizeof(MPEG2VIDEOINFO));
+ memset(mt.Format(), 0, mt.FormatLength());
+ vih->hdr.bmiHeader.biSize = sizeof(vih->hdr.bmiHeader);
+ vih->hdr.bmiHeader.biWidth = *(WORD*)&p[10] >> 4;
+ vih->hdr.bmiHeader.biHeight = *(WORD*)&p[12] >> 4;
+ vih->hdr.bmiHeader.biCompression = 'OEHT';
+ vih->hdr.bmiHeader.biPlanes = 1;
+ vih->hdr.bmiHeader.biBitCount = 24;
+ m_nFpsNum = (p[22] << 24) | (p[23] << 16) | (p[24] << 8) | p[25];
+ m_nFpsDenum = (p[26] << 24) | (p[27] << 16) | (p[28] << 8) | p[29];
+ if (m_nFpsNum) {
+ m_rtAvgTimePerFrame = (REFERENCE_TIME)(10000000.0 * m_nFpsDenum / m_nFpsNum);
+ vih->hdr.AvgTimePerFrame = m_rtAvgTimePerFrame;
+ }
+ vih->hdr.dwPictAspectRatioX = (p[14] << 16) | (p[15] << 8) | p[16];
+ vih->hdr.dwPictAspectRatioY = (p[17] << 16) | (p[18] << 8) | p[19];
+
+ m_KfgShift = (((p[40] << 8) + p[41]) & 0x3E0) >> 5;
+ m_nIndexOffset = TH_VERSION_CHECK(p[7], p[8], p[9], 3, 2, 1);
+
+ if (m_KfgShift == 0) {
+ m_KfgShift = 6; // Is it really default value ?
+ }
+
+ mt.bFixedSizeSamples = 0;
+ m_mts.Add(mt);
}
HRESULT COggTheoraOutputPin::UnpackInitPage(OggPage& page)
{
- HRESULT hr = __super::UnpackPage(page);
-
- while (m_packets.GetCount()) {
- Packet* p = m_packets.GetHead();
-
- CMediaType& mt = m_mts[0];
- int size = p->GetCount();
- ASSERT(size <= 0xffff);
- MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.ReallocFormatBuffer(
- FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) +
- ((MPEG2VIDEOINFO*)mt.Format())->cbSequenceHeader +
- 2 + size);
- *(WORD*)((BYTE*)vih->dwSequenceHeader + vih->cbSequenceHeader) = (size>>8)|(size<<8);
- memcpy((BYTE*)vih->dwSequenceHeader + vih->cbSequenceHeader + 2, p->GetData(), size);
- vih->cbSequenceHeader += 2 + size;
-
- m_initpackets.AddTail(m_packets.RemoveHead());
- }
-
- return hr;
+ HRESULT hr = __super::UnpackPage(page);
+
+ while (m_packets.GetCount()) {
+ Packet* p = m_packets.GetHead();
+
+ CMediaType& mt = m_mts[0];
+ int size = p->GetCount();
+ ASSERT(size <= 0xffff);
+ MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.ReallocFormatBuffer(
+ FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) +
+ ((MPEG2VIDEOINFO*)mt.Format())->cbSequenceHeader +
+ 2 + size);
+ *(WORD*)((BYTE*)vih->dwSequenceHeader + vih->cbSequenceHeader) = (size >> 8) | (size << 8);
+ memcpy((BYTE*)vih->dwSequenceHeader + vih->cbSequenceHeader + 2, p->GetData(), size);
+ vih->cbSequenceHeader += 2 + size;
+
+ m_initpackets.AddTail(m_packets.RemoveHead());
+ }
+
+ return hr;
}
REFERENCE_TIME COggTheoraOutputPin::GetRefTime(__int64 granule_position)
{
- LONGLONG iframe;
- LONGLONG pframe;
-
- iframe=granule_position>>m_KfgShift;
- pframe=granule_position-(iframe<<m_KfgShift);
- /*3.2.0 streams store the frame index in the granule position.
- 3.2.1 and later store the frame count.
- We return the index, so adjust the value if we have a 3.2.1 or later
- stream.*/
-
- REFERENCE_TIME rt = 0;
- rt = (iframe+pframe-m_nIndexOffset) * m_rtAvgTimePerFrame;
- return rt;
+ LONGLONG iframe;
+ LONGLONG pframe;
+
+ iframe = granule_position >> m_KfgShift;
+ pframe = granule_position - (iframe << m_KfgShift);
+ /*3.2.0 streams store the frame index in the granule position.
+ 3.2.1 and later store the frame count.
+ We return the index, so adjust the value if we have a 3.2.1 or later
+ stream.*/
+
+ REFERENCE_TIME rt = 0;
+ rt = (iframe + pframe - m_nIndexOffset) * m_rtAvgTimePerFrame;
+ return rt;
}
HRESULT COggTheoraOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len)
{
- if (!pData) {
- return E_FAIL;
- }
+ if (!pData) {
+ return E_FAIL;
+ }
- p->bSyncPoint = len > 0 ? !(*pData & 0x40) : TRUE;
- p->rtStart = m_rtLast;
- p->rtStop = m_rtLast+1;
- p->SetData(pData, len);
+ p->bSyncPoint = len > 0 ? !(*pData & 0x40) : TRUE;
+ p->rtStart = m_rtLast;
+ p->rtStop = m_rtLast + 1;
+ p->SetData(pData, len);
- if (!(*pData & 0x80) && m_mt.majortype == MEDIATYPE_Video) {
- p->rtStop = p->rtStart + ((MPEG2VIDEOINFO*)m_mt.Format())->hdr.AvgTimePerFrame;
- }
+ if (!(*pData & 0x80) && m_mt.majortype == MEDIATYPE_Video) {
+ p->rtStop = p->rtStart + ((MPEG2VIDEOINFO*)m_mt.Format())->hdr.AvgTimePerFrame;
+ }
- return S_OK;
+ return S_OK;
}
diff --git a/src/filters/parser/OggSplitter/OggSplitter.h b/src/filters/parser/OggSplitter/OggSplitter.h
index b9f9b78c1..cd24cce82 100644
--- a/src/filters/parser/OggSplitter/OggSplitter.h
+++ b/src/filters/parser/OggSplitter/OggSplitter.h
@@ -34,183 +34,183 @@
class OggPacket : public Packet
{
public:
- OggPacket() {
- fSkip = false;
- }
- bool fSkip;
+ OggPacket() {
+ fSkip = false;
+ }
+ bool fSkip;
};
class COggSplitterOutputPin : public CBaseSplitterOutputPin
{
- class CComment
- {
- public:
- CStringW m_key, m_value;
- CComment(CStringW key, CStringW value) : m_key(key), m_value(value) {
- m_key.MakeUpper();
- }
- };
+ class CComment
+ {
+ public:
+ CStringW m_key, m_value;
+ CComment(CStringW key, CStringW value) : m_key(key), m_value(value) {
+ m_key.MakeUpper();
+ }
+ };
- CAutoPtrList<CComment> m_pComments;
+ CAutoPtrList<CComment> m_pComments;
protected:
- CCritSec m_csPackets;
- CAutoPtrList<OggPacket> m_packets;
- CAutoPtr<OggPacket> m_lastpacket;
- DWORD m_lastseqnum;
- REFERENCE_TIME m_rtLast;
- bool m_fSkip;
+ CCritSec m_csPackets;
+ CAutoPtrList<OggPacket> m_packets;
+ CAutoPtr<OggPacket> m_lastpacket;
+ DWORD m_lastseqnum;
+ REFERENCE_TIME m_rtLast;
+ bool m_fSkip;
- void ResetState(DWORD seqnum = -1);
+ void ResetState(DWORD seqnum = -1);
public:
- COggSplitterOutputPin(LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
+ COggSplitterOutputPin(LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
- void AddComment(BYTE* p, int len);
- CStringW GetComment(CStringW key);
+ void AddComment(BYTE* p, int len);
+ CStringW GetComment(CStringW key);
- HRESULT UnpackPage(OggPage& page);
- virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len) = 0;
- virtual REFERENCE_TIME GetRefTime(__int64 granule_position) = 0;
- CAutoPtr<OggPacket> GetPacket();
+ HRESULT UnpackPage(OggPage& page);
+ virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len) = 0;
+ virtual REFERENCE_TIME GetRefTime(__int64 granule_position) = 0;
+ CAutoPtr<OggPacket> GetPacket();
- HRESULT DeliverEndFlush();
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ HRESULT DeliverEndFlush();
+ HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
};
class COggVorbisOutputPin : public COggSplitterOutputPin
{
- CAutoPtrList<OggPacket> m_initpackets;
+ CAutoPtrList<OggPacket> m_initpackets;
- DWORD m_audio_sample_rate;
- DWORD m_blocksize[2], m_lastblocksize;
- CAtlArray<bool> m_blockflags;
+ DWORD m_audio_sample_rate;
+ DWORD m_blocksize[2], m_lastblocksize;
+ CAtlArray<bool> m_blockflags;
- virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len);
- virtual REFERENCE_TIME GetRefTime(__int64 granule_position);
+ virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len);
+ virtual REFERENCE_TIME GetRefTime(__int64 granule_position);
- HRESULT DeliverPacket(CAutoPtr<OggPacket> p);
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ HRESULT DeliverPacket(CAutoPtr<OggPacket> p);
+ HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
public:
- COggVorbisOutputPin(OggVorbisIdHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
+ COggVorbisOutputPin(OggVorbisIdHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
- HRESULT UnpackInitPage(OggPage& page);
- bool IsInitialized() {
- return m_initpackets.GetCount() >= 3;
- }
+ HRESULT UnpackInitPage(OggPage& page);
+ bool IsInitialized() {
+ return m_initpackets.GetCount() >= 3;
+ }
};
class COggFlacOutputPin : public COggSplitterOutputPin
{
- CAutoPtrList<OggPacket> m_initpackets;
+ CAutoPtrList<OggPacket> m_initpackets;
- int m_nSamplesPerSec;
- int m_nChannels;
- WORD m_wBitsPerSample;
- int m_nAvgBytesPerSec;
+ int m_nSamplesPerSec;
+ int m_nChannels;
+ WORD m_wBitsPerSample;
+ int m_nAvgBytesPerSec;
- DWORD m_blocksize[2], m_lastblocksize;
- CAtlArray<bool> m_blockflags;
+ DWORD m_blocksize[2], m_lastblocksize;
+ CAtlArray<bool> m_blockflags;
- virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len);
- virtual REFERENCE_TIME GetRefTime(__int64 granule_position);
+ virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len);
+ virtual REFERENCE_TIME GetRefTime(__int64 granule_position);
- HRESULT DeliverPacket(CAutoPtr<OggPacket> p);
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ HRESULT DeliverPacket(CAutoPtr<OggPacket> p);
+ HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
public:
- COggFlacOutputPin(BYTE* h, int nCount, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
+ COggFlacOutputPin(BYTE* h, int nCount, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
- bool IsInitialized() {
- return m_initpackets.GetCount() >= 3;
- }
+ bool IsInitialized() {
+ return m_initpackets.GetCount() >= 3;
+ }
};
class COggDirectShowOutputPin : public COggSplitterOutputPin
{
- virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len);
- virtual REFERENCE_TIME GetRefTime(__int64 granule_position);
+ virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len);
+ virtual REFERENCE_TIME GetRefTime(__int64 granule_position);
public:
- COggDirectShowOutputPin(AM_MEDIA_TYPE* pmt, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
+ COggDirectShowOutputPin(AM_MEDIA_TYPE* pmt, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
};
class COggStreamOutputPin : public COggSplitterOutputPin
{
- __int64 m_time_unit, m_samples_per_unit;
- DWORD m_default_len;
+ __int64 m_time_unit, m_samples_per_unit;
+ DWORD m_default_len;
- virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len);
- virtual REFERENCE_TIME GetRefTime(__int64 granule_position);
+ virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len);
+ virtual REFERENCE_TIME GetRefTime(__int64 granule_position);
public:
- COggStreamOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
+ COggStreamOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
};
class COggVideoOutputPin : public COggStreamOutputPin
{
public:
- COggVideoOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
+ COggVideoOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
};
class COggAudioOutputPin : public COggStreamOutputPin
{
public:
- COggAudioOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
+ COggAudioOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
};
class COggTextOutputPin : public COggStreamOutputPin
{
public:
- COggTextOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
+ COggTextOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
};
class COggTheoraOutputPin : public COggSplitterOutputPin
{
- CAutoPtrList<OggPacket> m_initpackets;
- LONGLONG m_KfgShift;
- int m_nIndexOffset;
- int m_nFpsNum;
- int m_nFpsDenum;
- REFERENCE_TIME m_rtAvgTimePerFrame;
+ CAutoPtrList<OggPacket> m_initpackets;
+ LONGLONG m_KfgShift;
+ int m_nIndexOffset;
+ int m_nFpsNum;
+ int m_nFpsDenum;
+ REFERENCE_TIME m_rtAvgTimePerFrame;
- virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len);
- virtual REFERENCE_TIME GetRefTime(__int64 granule_position);
+ virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len);
+ virtual REFERENCE_TIME GetRefTime(__int64 granule_position);
public:
- COggTheoraOutputPin(BYTE* p, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
+ COggTheoraOutputPin(BYTE* p, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
- HRESULT UnpackInitPage(OggPage& page);
- bool IsInitialized() {
- return m_initpackets.GetCount() >= 3;
- }
+ HRESULT UnpackInitPage(OggPage& page);
+ bool IsInitialized() {
+ return m_initpackets.GetCount() >= 3;
+ }
};
class __declspec(uuid("9FF48807-E133-40AA-826F-9B2959E5232D"))
- COggSplitterFilter : public CBaseSplitterFilter
+ COggSplitterFilter : public CBaseSplitterFilter
{
protected:
- CAutoPtr<COggFile> m_pFile;
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
+ CAutoPtr<COggFile> m_pFile;
+ HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
+ bool DemuxInit();
+ void DemuxSeek(REFERENCE_TIME rt);
+ bool DemuxLoop();
public:
- COggSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
- virtual ~COggSplitterFilter();
+ COggSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
+ virtual ~COggSplitterFilter();
- // CBaseFilter
+ // CBaseFilter
- STDMETHODIMP_(HRESULT) QueryFilterInfo(FILTER_INFO* pInfo);
+ STDMETHODIMP_(HRESULT) QueryFilterInfo(FILTER_INFO* pInfo);
};
class __declspec(uuid("6D3688CE-3E9D-42F4-92CA-8A11119D25CD"))
- COggSourceFilter : public COggSplitterFilter
+ COggSourceFilter : public COggSplitterFilter
{
public:
- COggSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
+ COggSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
};
diff --git a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp
index 24eab18c3..5e858baac 100644
--- a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp
+++ b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp
@@ -37,55 +37,55 @@
#endif
#include <moreuuids.h>
-#define MAXPACKETS_RV MAXPACKETS*10
+#define MAXPACKETS_RV MAXPACKETS*10
template<typename T>
static void bswap(T& var)
{
- BYTE* s = (BYTE*)&var;
- for (BYTE* d = s + sizeof(var)-1; s < d; s++, d--) {
- *s ^= *d, *d ^= *s, *s ^= *d;
- }
+ BYTE* s = (BYTE*)&var;
+ for (BYTE* d = s + sizeof(var) - 1; s < d; s++, d--) {
+ *s ^= *d, *d ^= *s, *s ^= *d;
+ }
}
void rvinfo::bswap()
{
- ::bswap(dwSize);
- ::bswap(w);
- ::bswap(h);
- ::bswap(bpp);
- ::bswap(unk1);
- ::bswap(fps);
- ::bswap(type1);
- ::bswap(type2);
+ ::bswap(dwSize);
+ ::bswap(w);
+ ::bswap(h);
+ ::bswap(bpp);
+ ::bswap(unk1);
+ ::bswap(fps);
+ ::bswap(type1);
+ ::bswap(type2);
}
void rainfo::bswap()
{
- ::bswap(version1);
- ::bswap(version2);
- ::bswap(header_size);
- ::bswap(flavor);
- ::bswap(coded_frame_size);
- ::bswap(sub_packet_h);
- ::bswap(frame_size);
- ::bswap(sub_packet_size);
+ ::bswap(version1);
+ ::bswap(version2);
+ ::bswap(header_size);
+ ::bswap(flavor);
+ ::bswap(coded_frame_size);
+ ::bswap(sub_packet_h);
+ ::bswap(frame_size);
+ ::bswap(sub_packet_size);
}
void rainfo4::bswap()
{
- __super::bswap();
- ::bswap(sample_rate);
- ::bswap(sample_size);
- ::bswap(channels);
+ __super::bswap();
+ ::bswap(sample_rate);
+ ::bswap(sample_size);
+ ::bswap(channels);
}
void rainfo5::bswap()
{
- __super::bswap();
- ::bswap(sample_rate);
- ::bswap(sample_size);
- ::bswap(channels);
+ __super::bswap();
+ ::bswap(sample_rate);
+ ::bswap(sample_size);
+ ::bswap(channels);
}
using namespace RMFF;
@@ -93,79 +93,79 @@ using namespace RMFF;
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, 0, NULL}
};
const AMOVIESETUP_MEDIATYPE sudPinTypesIn2[] = {
- {&MEDIATYPE_Video, &MEDIASUBTYPE_RV20},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_RV30},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_RV40},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_RV41},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_RV20},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_RV30},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_RV40},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_RV41},
};
const AMOVIESETUP_MEDIATYPE sudPinTypesOut2[] = {
- {&MEDIATYPE_Video, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_NULL},
};
const AMOVIESETUP_PIN sudpPins2[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn2), sudPinTypesIn2},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut2), sudPinTypesOut2}
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn2), sudPinTypesIn2},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut2), sudPinTypesOut2}
};
const AMOVIESETUP_MEDIATYPE sudPinTypesIn3[] = {
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_14_4},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_28_8},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_ATRC},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_COOK},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_DNET},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_SIPR},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_AAC},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_RAAC},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_RACP},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_14_4},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_28_8},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_ATRC},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_COOK},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_DNET},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_SIPR},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_AAC},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_RAAC},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_RACP},
};
const AMOVIESETUP_MEDIATYPE sudPinTypesOut3[] = {
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM},
};
const AMOVIESETUP_PIN sudpPins3[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn3), sudPinTypesIn3},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut3), sudPinTypesOut3}
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn3), sudPinTypesIn3},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut3), sudPinTypesOut3}
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CRealMediaSplitterFilter), RMSplitterName, MERIT_NORMAL, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CRealMediaSourceFilter), RMSourceName, MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CRealVideoDecoder), L"MPC RealVideo Decoder", MERIT_NORMAL, _countof(sudpPins2), sudpPins2, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CRealAudioDecoder), L"MPC RealAudio Decoder", MERIT_NORMAL, _countof(sudpPins3), sudpPins3, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CRealMediaSplitterFilter), RMSplitterName, MERIT_NORMAL, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CRealMediaSourceFilter), RMSourceName, MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CRealVideoDecoder), L"MPC RealVideo Decoder", MERIT_NORMAL, _countof(sudpPins2), sudpPins2, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CRealAudioDecoder), L"MPC RealAudio Decoder", MERIT_NORMAL, _countof(sudpPins3), sudpPins3, CLSID_LegacyAmFilterCategory},
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CRealMediaSplitterFilter>, NULL, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CRealMediaSourceFilter>, NULL, &sudFilter[1]},
- {sudFilter[2].strName, sudFilter[2].clsID, CreateInstance<CRealVideoDecoder>, NULL, &sudFilter[2]},
- {sudFilter[3].strName, sudFilter[3].clsID, CreateInstance<CRealAudioDecoder>, NULL, &sudFilter[3]},
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CRealMediaSplitterFilter>, NULL, &sudFilter[0]},
+ {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CRealMediaSourceFilter>, NULL, &sudFilter[1]},
+ {sudFilter[2].strName, sudFilter[2].clsID, CreateInstance<CRealVideoDecoder>, NULL, &sudFilter[2]},
+ {sudFilter[3].strName, sudFilter[3].clsID, CreateInstance<CRealAudioDecoder>, NULL, &sudFilter[3]},
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_RealMedia, _T("0,4,,2E524D46"), _T(".rm"), _T(".rmvb"), _T(".ram"), NULL);
+ RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_RealMedia, _T("0,4,,2E524D46"), _T(".rm"), _T(".rmvb"), _T(".ram"), NULL);
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- UnRegisterSourceFilter(MEDIASUBTYPE_RealMedia);
+ UnRegisterSourceFilter(MEDIASUBTYPE_RealMedia);
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -179,7 +179,7 @@ CFilterApp theApp;
//
CRealMediaSplitterFilter::CRealMediaSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("CRealMediaSplitterFilter"), pUnk, phr, __uuidof(this), MAXPACKETS_RV)
+ : CBaseSplitterFilter(NAME("CRealMediaSplitterFilter"), pUnk, phr, __uuidof(this), MAXPACKETS_RV)
{
}
@@ -189,612 +189,612 @@ CRealMediaSplitterFilter::~CRealMediaSplitterFilter()
STDMETHODIMP CRealMediaSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo)
{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
-
- if (m_pName && m_pName[0]==L'M' && m_pName[1]==L'P' && m_pName[2]==L'C') {
- (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
- } else {
- wcscpy_s(pInfo->achName, RMSourceName);
- }
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
+ CheckPointer(pInfo, E_POINTER);
+ ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
+
+ if (m_pName && m_pName[0] == L'M' && m_pName[1] == L'P' && m_pName[2] == L'C') {
+ (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
+ } else {
+ wcscpy_s(pInfo->achName, RMSourceName);
+ }
+ pInfo->pGraph = m_pGraph;
+ if (m_pGraph) {
+ m_pGraph->AddRef();
+ }
+
+ return S_OK;
}
HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
{
- CheckPointer(pAsyncReader, E_POINTER);
-
- {
- DWORD dw;
- if (FAILED(pAsyncReader->SyncRead(0, 4, (BYTE*)&dw)) || dw != 'FMR.') {
- return E_FAIL;
- }
- }
-
- HRESULT hr = E_FAIL;
-
- m_pFile.Free();
-
- m_pFile.Attach(DNew CRMFile(pAsyncReader, hr));
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = 0;
-
- m_rtStop = 10000i64*m_pFile->m_p.tDuration;
-
- POSITION pos = m_pFile->m_mps.GetHeadPosition();
- while (pos) {
- MediaProperies* pmp = m_pFile->m_mps.GetNext(pos);
-
- CStringW name;
- name.Format(L"Output %02d", pmp->stream);
- if (!pmp->name.IsEmpty()) {
- name += L" (" + CStringW(pmp->name) + L")";
- }
-
- CAtlArray<CMediaType> mts;
-
- CMediaType mt;
- mt.SetSampleSize(max(pmp->maxPacketSize*16/**/, 1));
-
- if (pmp->mime == "video/x-pn-realvideo") {
- mt.majortype = MEDIATYPE_Video;
- mt.formattype = FORMAT_VideoInfo;
-
- VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + pmp->typeSpecData.GetCount());
- memset(mt.Format(), 0, mt.FormatLength());
- memcpy(pvih + 1, pmp->typeSpecData.GetData(), pmp->typeSpecData.GetCount());
-
- rvinfo rvi = *(rvinfo*)pmp->typeSpecData.GetData();
- rvi.bswap();
-
- ASSERT(rvi.dwSize >= FIELD_OFFSET(rvinfo, morewh));
- ASSERT(rvi.fcc1 == 'ODIV');
-
- mt.subtype = FOURCCMap(rvi.fcc2);
- if (rvi.fps > 0x10000) {
- pvih->AvgTimePerFrame = REFERENCE_TIME(10000000i64 / ((float)rvi.fps/0x10000));
- }
- pvih->dwBitRate = pmp->avgBitRate;
- pvih->bmiHeader.biSize = sizeof(pvih->bmiHeader);
- pvih->bmiHeader.biWidth = rvi.w;
- pvih->bmiHeader.biHeight = rvi.h;
- pvih->bmiHeader.biPlanes = 3;
- pvih->bmiHeader.biBitCount = rvi.bpp;
- pvih->bmiHeader.biCompression = rvi.fcc2;
- pvih->bmiHeader.biSizeImage = rvi.w*rvi.h*3/2;
- mts.Add(mt);
-
- BYTE* extra = pmp->typeSpecData.GetData();
- int extralen = pmp->typeSpecData.GetCount();
-
- if (extralen > 26) {
- extra += 26;
- extralen -= 26;
- VIDEOINFOHEADER* pvih2 = (VIDEOINFOHEADER*)mt.ReallocFormatBuffer(sizeof(VIDEOINFOHEADER) + extralen);
- memcpy(pvih2 + 1, extra, extralen);
- mts.InsertAt(0, mt);
- }
-
- if (pmp->width > 0 && pmp->height > 0) {
- BITMAPINFOHEADER bmi = pvih->bmiHeader;
- mt.formattype = FORMAT_VideoInfo2;
- VIDEOINFOHEADER2* pvih2 = (VIDEOINFOHEADER2*)mt.ReallocFormatBuffer(sizeof(VIDEOINFOHEADER2) + pmp->typeSpecData.GetCount());
- memset(mt.Format() + FIELD_OFFSET(VIDEOINFOHEADER2, dwInterlaceFlags), 0, mt.FormatLength() - FIELD_OFFSET(VIDEOINFOHEADER2, dwInterlaceFlags));
- memcpy(pvih2 + 1, pmp->typeSpecData.GetData(), pmp->typeSpecData.GetCount());
- pvih2->bmiHeader = bmi;
- pvih2->bmiHeader.biWidth = (DWORD)pmp->width;
- pvih2->bmiHeader.biHeight = (DWORD)pmp->height;
- pvih2->dwPictAspectRatioX = rvi.w;
- pvih2->dwPictAspectRatioY = rvi.h;
-
- mts.InsertAt(0, mt);
- }
- } else if (pmp->mime == "audio/x-pn-realaudio") {
- mt.majortype = MEDIATYPE_Audio;
- mt.formattype = FORMAT_WaveFormatEx;
- mt.bTemporalCompression = 1;
-
- WAVEFORMATEX* pwfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX) + pmp->typeSpecData.GetCount());
- memset(mt.Format(), 0, mt.FormatLength());
- memcpy(pwfe + 1, pmp->typeSpecData.GetData(), pmp->typeSpecData.GetCount());
-
- union {
- DWORD fcc;
- char fccstr[5];
- };
-
- fcc = 0;
- fccstr[4] = 0;
-
- BYTE* fmt = pmp->typeSpecData.GetData();
- for (size_t i = 0; i < pmp->typeSpecData.GetCount()-4; i++, fmt++) {
- if (fmt[0] == '.' || fmt[1] == 'r' || fmt[2] == 'a') {
- break;
- }
- }
-
- rainfo rai = *(rainfo*)fmt;
- rai.bswap();
-
- BYTE* extra = NULL;
-
- if (rai.version2 == 4) {
- rainfo4 rai4 = *(rainfo4*)fmt;
- rai4.bswap();
- pwfe->nChannels = rai4.channels;
- pwfe->wBitsPerSample = rai4.sample_size;
- pwfe->nSamplesPerSec = rai4.sample_rate;
- pwfe->nBlockAlign = rai4.frame_size;
- BYTE* p = (BYTE*)((rainfo4*)fmt+1);
- int len = *p++;
- p += len;
- len = *p++;
- ASSERT(len == 4);
- if (len == 4) {
- fcc = MAKEFOURCC(p[0],p[1],p[2],p[3]);
- }
- extra = p + len + 3;
- } else if (rai.version2 == 5) {
- rainfo5 rai5 = *(rainfo5*)fmt;
- rai5.bswap();
- pwfe->nChannels = rai5.channels;
- pwfe->wBitsPerSample = rai5.sample_size;
- pwfe->nSamplesPerSec = rai5.sample_rate;
- pwfe->nBlockAlign = rai5.frame_size;
- fcc = rai5.fourcc3;
- extra = fmt + sizeof(rainfo5) + 4;
- } else {
- continue;
- }
-
- _strupr_s(fccstr);
-
- mt.subtype = FOURCCMap(fcc);
-
- bswap(fcc);
-
- switch (fcc) {
- case '14_4':
- pwfe->wFormatTag = WAVE_FORMAT_14_4;
- break;
- case '28_8':
- pwfe->wFormatTag = WAVE_FORMAT_28_8;
- break;
- case 'ATRC':
- pwfe->wFormatTag = WAVE_FORMAT_ATRC;
- break;
- case 'COOK':
- pwfe->wFormatTag = WAVE_FORMAT_COOK;
- break;
- case 'DNET':
- pwfe->wFormatTag = WAVE_FORMAT_DNET;
- break;
- case 'SIPR':
- pwfe->wFormatTag = WAVE_FORMAT_SIPR;
- break;
- case 'RAAC':
- pwfe->wFormatTag = WAVE_FORMAT_RAAC;
- break;
- case 'RACP':
- pwfe->wFormatTag = WAVE_FORMAT_RACP;
- break;
- }
-
- if (pwfe->wFormatTag) {
- mts.Add(mt);
-
- if (fcc == 'DNET') {
- mt.subtype = FOURCCMap(pwfe->wFormatTag = WAVE_FORMAT_DOLBY_AC3);
- mts.InsertAt(0, mt);
- } else if (fcc == 'RAAC' || fcc == 'RACP') {
- mt.subtype = FOURCCMap(pwfe->wFormatTag = WAVE_FORMAT_AAC);
- int extralen = *(DWORD*)extra;
- extra += 4;
- ::bswap(extralen);
- ASSERT(*extra == 2); // always 2? why? what does it mean?
- if (*extra == 2) {
- extra++;
- extralen--;
- WAVEFORMATEX* pwfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + extralen);
- pwfe->cbSize = extralen;
- memcpy(pwfe + 1, extra, extralen);
- } else {
- WAVEFORMATEX* pwfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + 5);
- pwfe->cbSize = MakeAACInitData((BYTE*)(pwfe+1), 0, pwfe->nSamplesPerSec, pwfe->nChannels);
- }
- mts.InsertAt(0, mt);
- }
- }
- } else if (pmp->mime == "logical-fileinfo") {
- CAtlMap<CStringA, CStringA, CStringElementTraits<CStringA> > lfi;
- CStringA key, value;
-
- BYTE* p = pmp->typeSpecData.GetData();
- BYTE* end = p + pmp->typeSpecData.GetCount();
- p += 8;
-
- DWORD cnt = p <= end-4 ? *(DWORD*)p : 0;
- bswap(cnt);
- p += 4;
-
- if (cnt > 0xffff) { // different format?
- p += 2;
- cnt = p <= end-4 ? *(DWORD*)p : 0;
- bswap(cnt);
- p += 4;
- }
-
- while (p < end-4 && cnt-- > 0) {
- BYTE* base = p;
- DWORD len = *(DWORD*)p;
- bswap(len);
- p += 4;
- if (base + len > end) {
- break;
- }
-
- p++;
- WORD keylen = *(WORD*)p;
- bswap(keylen);
- p += 2;
- memcpy(key.GetBufferSetLength(keylen), p, keylen);
- p += keylen;
-
- p+=4;
- WORD valuelen = *(WORD*)p;
- bswap(valuelen);
- p += 2;
- memcpy(value.GetBufferSetLength(valuelen), p, valuelen);
- p += valuelen;
-
- ASSERT(p == base + len);
- p = base + len;
-
- lfi[key] = value;
- }
-
- POSITION pos = lfi.GetStartPosition();
- while (pos) {
- lfi.GetNextAssoc(pos, key, value);
-
- int n = 0;
- if (key.Find("CHAPTER") == 0 && key.Find("TIME") == key.GetLength()-4
- && (n = strtol(key.Mid(7), NULL, 10)) > 0) {
- int h, m, s, ms;
- char c;
- if (7 != sscanf_s(value, "%d%c%d%c%d%c%d", &h, &c, sizeof(CHAR),
- &m, &c, sizeof(CHAR), &s, &c, sizeof(CHAR), &ms)) {
- continue;
- }
-
- key.Format("CHAPTER%02dNAME", n);
- if (!lfi.Lookup(key, value) || value.IsEmpty()) {
- value.Format("Chapter %d", n);
- }
-
- ChapAppend(
- ((((REFERENCE_TIME)h*60+m)*60+s)*1000+ms)*10000,
- CStringW(CString(value)));
- }
- }
- }
-
- if (mts.IsEmpty()) {
- TRACE(_T("Unsupported RealMedia stream (%d): %s\n"), pmp->stream, CString(pmp->mime));
- continue;
- }
-
- HRESULT hr;
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CRealMediaSplitterOutputPin(mts, name, this, this, &hr));
- if (SUCCEEDED(AddOutputPin((DWORD)pmp->stream, pPinOut))) {
- if (!m_rtStop) {
- m_pFile->m_p.tDuration = max(m_pFile->m_p.tDuration, pmp->tDuration);
- }
- }
- }
-
- pos = m_pFile->m_subs.GetHeadPosition();
- for (DWORD stream = 0; pos; stream++) {
- CRMFile::subtitle& s = m_pFile->m_subs.GetNext(pos);
-
- CStringW name;
- name.Format(L"Subtitle %02d", stream);
- if (!s.name.IsEmpty()) {
- name += L" (" + CStringW(CString(s.name)) + L")";
- }
-
- CMediaType mt;
- mt.SetSampleSize(1);
- mt.majortype = MEDIATYPE_Text;
-
- CAtlArray<CMediaType> mts;
- mts.Add(mt);
-
- HRESULT hr;
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CRealMediaSplitterOutputPin(mts, name, this, this, &hr));
- AddOutputPin((DWORD)~stream, pPinOut);
- }
-
- m_rtDuration = m_rtNewStop = m_rtStop = 10000i64*m_pFile->m_p.tDuration;
-
- SetProperty(L"TITL", CStringW(m_pFile->m_cd.title));
- SetProperty(L"AUTH", CStringW(m_pFile->m_cd.author));
- SetProperty(L"CPYR", CStringW(m_pFile->m_cd.copyright));
- SetProperty(L"DESC", CStringW(m_pFile->m_cd.comment));
-
- return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
+ CheckPointer(pAsyncReader, E_POINTER);
+
+ {
+ DWORD dw;
+ if (FAILED(pAsyncReader->SyncRead(0, 4, (BYTE*)&dw)) || dw != 'FMR.') {
+ return E_FAIL;
+ }
+ }
+
+ HRESULT hr = E_FAIL;
+
+ m_pFile.Free();
+
+ m_pFile.Attach(DNew CRMFile(pAsyncReader, hr));
+ if (!m_pFile) {
+ return E_OUTOFMEMORY;
+ }
+ if (FAILED(hr)) {
+ m_pFile.Free();
+ return hr;
+ }
+
+ m_rtNewStart = m_rtCurrent = 0;
+ m_rtNewStop = m_rtStop = 0;
+
+ m_rtStop = 10000i64 * m_pFile->m_p.tDuration;
+
+ POSITION pos = m_pFile->m_mps.GetHeadPosition();
+ while (pos) {
+ MediaProperies* pmp = m_pFile->m_mps.GetNext(pos);
+
+ CStringW name;
+ name.Format(L"Output %02d", pmp->stream);
+ if (!pmp->name.IsEmpty()) {
+ name += L" (" + CStringW(pmp->name) + L")";
+ }
+
+ CAtlArray<CMediaType> mts;
+
+ CMediaType mt;
+ mt.SetSampleSize(max(pmp->maxPacketSize * 16/**/, 1));
+
+ if (pmp->mime == "video/x-pn-realvideo") {
+ mt.majortype = MEDIATYPE_Video;
+ mt.formattype = FORMAT_VideoInfo;
+
+ VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + pmp->typeSpecData.GetCount());
+ memset(mt.Format(), 0, mt.FormatLength());
+ memcpy(pvih + 1, pmp->typeSpecData.GetData(), pmp->typeSpecData.GetCount());
+
+ rvinfo rvi = *(rvinfo*)pmp->typeSpecData.GetData();
+ rvi.bswap();
+
+ ASSERT(rvi.dwSize >= FIELD_OFFSET(rvinfo, morewh));
+ ASSERT(rvi.fcc1 == 'ODIV');
+
+ mt.subtype = FOURCCMap(rvi.fcc2);
+ if (rvi.fps > 0x10000) {
+ pvih->AvgTimePerFrame = REFERENCE_TIME(10000000i64 / ((float)rvi.fps / 0x10000));
+ }
+ pvih->dwBitRate = pmp->avgBitRate;
+ pvih->bmiHeader.biSize = sizeof(pvih->bmiHeader);
+ pvih->bmiHeader.biWidth = rvi.w;
+ pvih->bmiHeader.biHeight = rvi.h;
+ pvih->bmiHeader.biPlanes = 3;
+ pvih->bmiHeader.biBitCount = rvi.bpp;
+ pvih->bmiHeader.biCompression = rvi.fcc2;
+ pvih->bmiHeader.biSizeImage = rvi.w * rvi.h * 3 / 2;
+ mts.Add(mt);
+
+ BYTE* extra = pmp->typeSpecData.GetData();
+ int extralen = pmp->typeSpecData.GetCount();
+
+ if (extralen > 26) {
+ extra += 26;
+ extralen -= 26;
+ VIDEOINFOHEADER* pvih2 = (VIDEOINFOHEADER*)mt.ReallocFormatBuffer(sizeof(VIDEOINFOHEADER) + extralen);
+ memcpy(pvih2 + 1, extra, extralen);
+ mts.InsertAt(0, mt);
+ }
+
+ if (pmp->width > 0 && pmp->height > 0) {
+ BITMAPINFOHEADER bmi = pvih->bmiHeader;
+ mt.formattype = FORMAT_VideoInfo2;
+ VIDEOINFOHEADER2* pvih2 = (VIDEOINFOHEADER2*)mt.ReallocFormatBuffer(sizeof(VIDEOINFOHEADER2) + pmp->typeSpecData.GetCount());
+ memset(mt.Format() + FIELD_OFFSET(VIDEOINFOHEADER2, dwInterlaceFlags), 0, mt.FormatLength() - FIELD_OFFSET(VIDEOINFOHEADER2, dwInterlaceFlags));
+ memcpy(pvih2 + 1, pmp->typeSpecData.GetData(), pmp->typeSpecData.GetCount());
+ pvih2->bmiHeader = bmi;
+ pvih2->bmiHeader.biWidth = (DWORD)pmp->width;
+ pvih2->bmiHeader.biHeight = (DWORD)pmp->height;
+ pvih2->dwPictAspectRatioX = rvi.w;
+ pvih2->dwPictAspectRatioY = rvi.h;
+
+ mts.InsertAt(0, mt);
+ }
+ } else if (pmp->mime == "audio/x-pn-realaudio") {
+ mt.majortype = MEDIATYPE_Audio;
+ mt.formattype = FORMAT_WaveFormatEx;
+ mt.bTemporalCompression = 1;
+
+ WAVEFORMATEX* pwfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX) + pmp->typeSpecData.GetCount());
+ memset(mt.Format(), 0, mt.FormatLength());
+ memcpy(pwfe + 1, pmp->typeSpecData.GetData(), pmp->typeSpecData.GetCount());
+
+ union {
+ DWORD fcc;
+ char fccstr[5];
+ };
+
+ fcc = 0;
+ fccstr[4] = 0;
+
+ BYTE* fmt = pmp->typeSpecData.GetData();
+ for (size_t i = 0; i < pmp->typeSpecData.GetCount() - 4; i++, fmt++) {
+ if (fmt[0] == '.' || fmt[1] == 'r' || fmt[2] == 'a') {
+ break;
+ }
+ }
+
+ rainfo rai = *(rainfo*)fmt;
+ rai.bswap();
+
+ BYTE* extra = NULL;
+
+ if (rai.version2 == 4) {
+ rainfo4 rai4 = *(rainfo4*)fmt;
+ rai4.bswap();
+ pwfe->nChannels = rai4.channels;
+ pwfe->wBitsPerSample = rai4.sample_size;
+ pwfe->nSamplesPerSec = rai4.sample_rate;
+ pwfe->nBlockAlign = rai4.frame_size;
+ BYTE* p = (BYTE*)((rainfo4*)fmt + 1);
+ int len = *p++;
+ p += len;
+ len = *p++;
+ ASSERT(len == 4);
+ if (len == 4) {
+ fcc = MAKEFOURCC(p[0], p[1], p[2], p[3]);
+ }
+ extra = p + len + 3;
+ } else if (rai.version2 == 5) {
+ rainfo5 rai5 = *(rainfo5*)fmt;
+ rai5.bswap();
+ pwfe->nChannels = rai5.channels;
+ pwfe->wBitsPerSample = rai5.sample_size;
+ pwfe->nSamplesPerSec = rai5.sample_rate;
+ pwfe->nBlockAlign = rai5.frame_size;
+ fcc = rai5.fourcc3;
+ extra = fmt + sizeof(rainfo5) + 4;
+ } else {
+ continue;
+ }
+
+ _strupr_s(fccstr);
+
+ mt.subtype = FOURCCMap(fcc);
+
+ bswap(fcc);
+
+ switch (fcc) {
+ case '14_4':
+ pwfe->wFormatTag = WAVE_FORMAT_14_4;
+ break;
+ case '28_8':
+ pwfe->wFormatTag = WAVE_FORMAT_28_8;
+ break;
+ case 'ATRC':
+ pwfe->wFormatTag = WAVE_FORMAT_ATRC;
+ break;
+ case 'COOK':
+ pwfe->wFormatTag = WAVE_FORMAT_COOK;
+ break;
+ case 'DNET':
+ pwfe->wFormatTag = WAVE_FORMAT_DNET;
+ break;
+ case 'SIPR':
+ pwfe->wFormatTag = WAVE_FORMAT_SIPR;
+ break;
+ case 'RAAC':
+ pwfe->wFormatTag = WAVE_FORMAT_RAAC;
+ break;
+ case 'RACP':
+ pwfe->wFormatTag = WAVE_FORMAT_RACP;
+ break;
+ }
+
+ if (pwfe->wFormatTag) {
+ mts.Add(mt);
+
+ if (fcc == 'DNET') {
+ mt.subtype = FOURCCMap(pwfe->wFormatTag = WAVE_FORMAT_DOLBY_AC3);
+ mts.InsertAt(0, mt);
+ } else if (fcc == 'RAAC' || fcc == 'RACP') {
+ mt.subtype = FOURCCMap(pwfe->wFormatTag = WAVE_FORMAT_AAC);
+ int extralen = *(DWORD*)extra;
+ extra += 4;
+ ::bswap(extralen);
+ ASSERT(*extra == 2); // always 2? why? what does it mean?
+ if (*extra == 2) {
+ extra++;
+ extralen--;
+ WAVEFORMATEX* pwfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + extralen);
+ pwfe->cbSize = extralen;
+ memcpy(pwfe + 1, extra, extralen);
+ } else {
+ WAVEFORMATEX* pwfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + 5);
+ pwfe->cbSize = MakeAACInitData((BYTE*)(pwfe + 1), 0, pwfe->nSamplesPerSec, pwfe->nChannels);
+ }
+ mts.InsertAt(0, mt);
+ }
+ }
+ } else if (pmp->mime == "logical-fileinfo") {
+ CAtlMap<CStringA, CStringA, CStringElementTraits<CStringA> > lfi;
+ CStringA key, value;
+
+ BYTE* p = pmp->typeSpecData.GetData();
+ BYTE* end = p + pmp->typeSpecData.GetCount();
+ p += 8;
+
+ DWORD cnt = p <= end - 4 ? *(DWORD*)p : 0;
+ bswap(cnt);
+ p += 4;
+
+ if (cnt > 0xffff) { // different format?
+ p += 2;
+ cnt = p <= end - 4 ? *(DWORD*)p : 0;
+ bswap(cnt);
+ p += 4;
+ }
+
+ while (p < end - 4 && cnt-- > 0) {
+ BYTE* base = p;
+ DWORD len = *(DWORD*)p;
+ bswap(len);
+ p += 4;
+ if (base + len > end) {
+ break;
+ }
+
+ p++;
+ WORD keylen = *(WORD*)p;
+ bswap(keylen);
+ p += 2;
+ memcpy(key.GetBufferSetLength(keylen), p, keylen);
+ p += keylen;
+
+ p += 4;
+ WORD valuelen = *(WORD*)p;
+ bswap(valuelen);
+ p += 2;
+ memcpy(value.GetBufferSetLength(valuelen), p, valuelen);
+ p += valuelen;
+
+ ASSERT(p == base + len);
+ p = base + len;
+
+ lfi[key] = value;
+ }
+
+ POSITION pos = lfi.GetStartPosition();
+ while (pos) {
+ lfi.GetNextAssoc(pos, key, value);
+
+ int n = 0;
+ if (key.Find("CHAPTER") == 0 && key.Find("TIME") == key.GetLength() - 4
+ && (n = strtol(key.Mid(7), NULL, 10)) > 0) {
+ int h, m, s, ms;
+ char c;
+ if (7 != sscanf_s(value, "%d%c%d%c%d%c%d", &h, &c, sizeof(CHAR),
+ &m, &c, sizeof(CHAR), &s, &c, sizeof(CHAR), &ms)) {
+ continue;
+ }
+
+ key.Format("CHAPTER%02dNAME", n);
+ if (!lfi.Lookup(key, value) || value.IsEmpty()) {
+ value.Format("Chapter %d", n);
+ }
+
+ ChapAppend(
+ ((((REFERENCE_TIME)h * 60 + m) * 60 + s) * 1000 + ms) * 10000,
+ CStringW(CString(value)));
+ }
+ }
+ }
+
+ if (mts.IsEmpty()) {
+ TRACE(_T("Unsupported RealMedia stream (%d): %s\n"), pmp->stream, CString(pmp->mime));
+ continue;
+ }
+
+ HRESULT hr;
+
+ CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CRealMediaSplitterOutputPin(mts, name, this, this, &hr));
+ if (SUCCEEDED(AddOutputPin((DWORD)pmp->stream, pPinOut))) {
+ if (!m_rtStop) {
+ m_pFile->m_p.tDuration = max(m_pFile->m_p.tDuration, pmp->tDuration);
+ }
+ }
+ }
+
+ pos = m_pFile->m_subs.GetHeadPosition();
+ for (DWORD stream = 0; pos; stream++) {
+ CRMFile::subtitle& s = m_pFile->m_subs.GetNext(pos);
+
+ CStringW name;
+ name.Format(L"Subtitle %02d", stream);
+ if (!s.name.IsEmpty()) {
+ name += L" (" + CStringW(CString(s.name)) + L")";
+ }
+
+ CMediaType mt;
+ mt.SetSampleSize(1);
+ mt.majortype = MEDIATYPE_Text;
+
+ CAtlArray<CMediaType> mts;
+ mts.Add(mt);
+
+ HRESULT hr;
+
+ CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CRealMediaSplitterOutputPin(mts, name, this, this, &hr));
+ AddOutputPin((DWORD)~stream, pPinOut);
+ }
+
+ m_rtDuration = m_rtNewStop = m_rtStop = 10000i64 * m_pFile->m_p.tDuration;
+
+ SetProperty(L"TITL", CStringW(m_pFile->m_cd.title));
+ SetProperty(L"AUTH", CStringW(m_pFile->m_cd.author));
+ SetProperty(L"CPYR", CStringW(m_pFile->m_cd.copyright));
+ SetProperty(L"DESC", CStringW(m_pFile->m_cd.comment));
+
+ return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
}
bool CRealMediaSplitterFilter::DemuxInit()
{
- SetThreadName((DWORD)-1, "CRealMediaSplitterFilter");
+ SetThreadName((DWORD) - 1, "CRealMediaSplitterFilter");
- if (!m_pFile) {
- return false;
- }
+ if (!m_pFile) {
+ return false;
+ }
- // reindex if needed
+ // reindex if needed
- if (m_pFile->m_irs.GetCount() == 0) {
- m_nOpenProgress = 0;
- m_rtDuration = 0;
+ if (m_pFile->m_irs.GetCount() == 0) {
+ m_nOpenProgress = 0;
+ m_rtDuration = 0;
- int stream = m_pFile->GetMasterStream();
+ int stream = m_pFile->GetMasterStream();
- UINT32 tLastStart = (UINT32)-1;
- UINT32 nPacket = 0;
+ UINT32 tLastStart = (UINT32) - 1;
+ UINT32 nPacket = 0;
- POSITION pos = m_pFile->m_dcs.GetHeadPosition();
- while (pos && !m_fAbort) {
- DataChunk* pdc = m_pFile->m_dcs.GetNext(pos);
+ POSITION pos = m_pFile->m_dcs.GetHeadPosition();
+ while (pos && !m_fAbort) {
+ DataChunk* pdc = m_pFile->m_dcs.GetNext(pos);
- m_pFile->Seek(pdc->pos);
+ m_pFile->Seek(pdc->pos);
- for (UINT32 i = 0; i < pdc->nPackets && !m_fAbort; i++, nPacket++) {
- UINT64 filepos = m_pFile->GetPos();
+ for (UINT32 i = 0; i < pdc->nPackets && !m_fAbort; i++, nPacket++) {
+ UINT64 filepos = m_pFile->GetPos();
- HRESULT hr;
+ HRESULT hr;
- MediaPacketHeader mph;
- if (S_OK != (hr = m_pFile->Read(mph, false))) {
- break;
- }
+ MediaPacketHeader mph;
+ if (S_OK != (hr = m_pFile->Read(mph, false))) {
+ break;
+ }
- m_rtDuration = max((__int64)(10000i64*mph.tStart), m_rtDuration);
+ m_rtDuration = max((__int64)(10000i64 * mph.tStart), m_rtDuration);
- if (mph.stream == stream && (mph.flags&MediaPacketHeader::PN_KEYFRAME_FLAG) && tLastStart != mph.tStart) {
- CAutoPtr<IndexRecord> pir(DNew IndexRecord);
- pir->tStart = mph.tStart;
- pir->ptrFilePos = (UINT32)filepos;
- pir->packet = nPacket;
- m_pFile->m_irs.AddTail(pir);
+ if (mph.stream == stream && (mph.flags & MediaPacketHeader::PN_KEYFRAME_FLAG) && tLastStart != mph.tStart) {
+ CAutoPtr<IndexRecord> pir(DNew IndexRecord);
+ pir->tStart = mph.tStart;
+ pir->ptrFilePos = (UINT32)filepos;
+ pir->packet = nPacket;
+ m_pFile->m_irs.AddTail(pir);
- tLastStart = mph.tStart;
- }
+ tLastStart = mph.tStart;
+ }
- m_nOpenProgress = m_pFile->GetPos()*100/m_pFile->GetLength();
+ m_nOpenProgress = m_pFile->GetPos() * 100 / m_pFile->GetLength();
- DWORD cmd;
- if (CheckRequest(&cmd)) {
- if (cmd == CMD_EXIT) {
- m_fAbort = true;
- } else {
- Reply(S_OK);
- }
- }
- }
- }
+ DWORD cmd;
+ if (CheckRequest(&cmd)) {
+ if (cmd == CMD_EXIT) {
+ m_fAbort = true;
+ } else {
+ Reply(S_OK);
+ }
+ }
+ }
+ }
- m_nOpenProgress = 100;
+ m_nOpenProgress = 100;
- if (m_fAbort) {
- m_pFile->m_irs.RemoveAll();
- }
+ if (m_fAbort) {
+ m_pFile->m_irs.RemoveAll();
+ }
- m_fAbort = false;
- }
+ m_fAbort = false;
+ }
- m_seekpos = NULL;
- m_seekpacket = 0;
- m_seekfilepos = 0;
+ m_seekpos = NULL;
+ m_seekpacket = 0;
+ m_seekfilepos = 0;
- return true;
+ return true;
}
void CRealMediaSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
- if (rt <= 0) {
- m_seekpos = m_pFile->m_dcs.GetHeadPosition();
- m_seekpacket = 0;
- m_seekfilepos = m_pFile->m_dcs.GetHead()->pos;
- } else {
- m_seekpos = NULL;
-
- POSITION pos = m_pFile->m_irs.GetTailPosition();
- while (pos && !m_seekpos) {
- IndexRecord* pir = m_pFile->m_irs.GetPrev(pos);
- if (pir->tStart <= rt/10000) {
- m_seekpacket = pir->packet;
-
- pos = m_pFile->m_dcs.GetTailPosition();
- while (pos && !m_seekpos) {
- POSITION tmp = pos;
-
- DataChunk* pdc = m_pFile->m_dcs.GetPrev(pos);
-
- if (pdc->pos <= pir->ptrFilePos) {
- m_seekpos = tmp;
- m_seekfilepos = pir->ptrFilePos;
-
- POSITION pos = m_pFile->m_dcs.GetHeadPosition();
- while (pos != m_seekpos) {
- m_seekpacket -= m_pFile->m_dcs.GetNext(pos)->nPackets;
- }
- }
- }
-
- // search the closest keyframe to the seek time (commented out 'cause rm seems to index all of its keyframes...)
- /*
- if (m_seekpos)
- {
- DataChunk* pdc = m_pFile->m_dcs.GetAt(m_seekpos);
-
- m_pFile->Seek(m_seekfilepos);
-
- REFERENCE_TIME seektime = -1;
- UINT32 seekstream = -1;
-
- for (UINT32 i = m_seekpacket; i < pdc->nPackets; i++)
- {
- UINT64 filepos = m_pFile->GetPos();
-
- MediaPacketHeader mph;
- if (S_OK != m_pFile->Read(mph, false))
- break;
-
- if (seekstream == -1) seekstream = mph.stream;
- if (seekstream != mph.stream) continue;
-
- if (seektime == 10000i64*mph.tStart) continue;
- if (rt < 10000i64*mph.tStart) break;
-
- if ((mph.flags&MediaPacketHeader::PN_KEYFRAME_FLAG))
- {
- m_seekpacket = i;
- m_seekfilepos = filepos;
- seektime = 10000i64*mph.tStart;
- }
- }
- }
- */
- }
- }
-
- if (!m_seekpos) {
- m_seekpos = m_pFile->m_dcs.GetHeadPosition();
- m_seekpacket = 0;
- m_seekfilepos = m_pFile->m_dcs.GetAt(m_seekpos)->pos;
- }
- }
+ if (rt <= 0) {
+ m_seekpos = m_pFile->m_dcs.GetHeadPosition();
+ m_seekpacket = 0;
+ m_seekfilepos = m_pFile->m_dcs.GetHead()->pos;
+ } else {
+ m_seekpos = NULL;
+
+ POSITION pos = m_pFile->m_irs.GetTailPosition();
+ while (pos && !m_seekpos) {
+ IndexRecord* pir = m_pFile->m_irs.GetPrev(pos);
+ if (pir->tStart <= rt / 10000) {
+ m_seekpacket = pir->packet;
+
+ pos = m_pFile->m_dcs.GetTailPosition();
+ while (pos && !m_seekpos) {
+ POSITION tmp = pos;
+
+ DataChunk* pdc = m_pFile->m_dcs.GetPrev(pos);
+
+ if (pdc->pos <= pir->ptrFilePos) {
+ m_seekpos = tmp;
+ m_seekfilepos = pir->ptrFilePos;
+
+ POSITION pos = m_pFile->m_dcs.GetHeadPosition();
+ while (pos != m_seekpos) {
+ m_seekpacket -= m_pFile->m_dcs.GetNext(pos)->nPackets;
+ }
+ }
+ }
+
+ // search the closest keyframe to the seek time (commented out 'cause rm seems to index all of its keyframes...)
+ /*
+ if (m_seekpos)
+ {
+ DataChunk* pdc = m_pFile->m_dcs.GetAt(m_seekpos);
+
+ m_pFile->Seek(m_seekfilepos);
+
+ REFERENCE_TIME seektime = -1;
+ UINT32 seekstream = -1;
+
+ for (UINT32 i = m_seekpacket; i < pdc->nPackets; i++)
+ {
+ UINT64 filepos = m_pFile->GetPos();
+
+ MediaPacketHeader mph;
+ if (S_OK != m_pFile->Read(mph, false))
+ break;
+
+ if (seekstream == -1) seekstream = mph.stream;
+ if (seekstream != mph.stream) continue;
+
+ if (seektime == 10000i64*mph.tStart) continue;
+ if (rt < 10000i64*mph.tStart) break;
+
+ if ((mph.flags&MediaPacketHeader::PN_KEYFRAME_FLAG))
+ {
+ m_seekpacket = i;
+ m_seekfilepos = filepos;
+ seektime = 10000i64*mph.tStart;
+ }
+ }
+ }
+ */
+ }
+ }
+
+ if (!m_seekpos) {
+ m_seekpos = m_pFile->m_dcs.GetHeadPosition();
+ m_seekpacket = 0;
+ m_seekfilepos = m_pFile->m_dcs.GetAt(m_seekpos)->pos;
+ }
+ }
}
bool CRealMediaSplitterFilter::DemuxLoop()
{
- HRESULT hr = S_OK;
- POSITION pos;
-
- pos = m_pFile->m_subs.GetHeadPosition();
- for (DWORD stream = 0; pos && SUCCEEDED(hr) && !CheckRequest(NULL); stream++) {
- CRMFile::subtitle& s = m_pFile->m_subs.GetNext(pos);
-
- CAutoPtr<Packet> p(DNew Packet);
-
- p->TrackNumber = ~stream;
- p->bSyncPoint = TRUE;
- p->rtStart = 0;
- p->rtStop = 1;
-
- size_t count = (4+1) + (2+4+(s.name.GetLength()+1)*2) + (2+4+s.data.GetLength());
- p->SetCount(count);
- BYTE* ptr = p->GetData();
-
- strcpy_s((char*)ptr, count, "GAB2");
- ptr += 4+1;
- count -= 4+1;
-
- *(WORD*)ptr = 2;
- ptr += 2;
- count -= 2;
- *(DWORD*)ptr = (s.name.GetLength()+1)*2;
- ptr += 4;
- count -= 4;
- wcscpy_s((WCHAR*)ptr, count / 2, CStringW(s.name));
- ptr += (s.name.GetLength()+1)*2;
-
- *(WORD*)ptr = 4;
- ptr += 2;
- *(DWORD*)ptr = s.data.GetLength();
- ptr += 4;
- memcpy((char*)ptr, s.data, s.data.GetLength());
- ptr += s.name.GetLength();
-
- hr = DeliverPacket(p);
- }
-
- pos = m_seekpos;
- while (pos && SUCCEEDED(hr) && !CheckRequest(NULL)) {
- DataChunk* pdc = m_pFile->m_dcs.GetNext(pos);
-
- m_pFile->Seek(m_seekfilepos > 0 ? m_seekfilepos : pdc->pos);
-
- for (UINT32 i = m_seekpacket; i < pdc->nPackets && SUCCEEDED(hr) && !CheckRequest(NULL); i++) {
- MediaPacketHeader mph;
- if (S_OK != (hr = m_pFile->Read(mph))) {
- break;
- }
-
- CAutoPtr<Packet> p(DNew Packet);
- p->TrackNumber = mph.stream;
- p->bSyncPoint = !!(mph.flags&MediaPacketHeader::PN_KEYFRAME_FLAG);
- p->rtStart = 10000i64*(mph.tStart);
- p->rtStop = p->rtStart+1;
- p->Copy(mph.pData);
- hr = DeliverPacket(p);
- }
-
- m_seekpacket = 0;
- m_seekfilepos = 0;
- }
-
- return true;
+ HRESULT hr = S_OK;
+ POSITION pos;
+
+ pos = m_pFile->m_subs.GetHeadPosition();
+ for (DWORD stream = 0; pos && SUCCEEDED(hr) && !CheckRequest(NULL); stream++) {
+ CRMFile::subtitle& s = m_pFile->m_subs.GetNext(pos);
+
+ CAutoPtr<Packet> p(DNew Packet);
+
+ p->TrackNumber = ~stream;
+ p->bSyncPoint = TRUE;
+ p->rtStart = 0;
+ p->rtStop = 1;
+
+ size_t count = (4 + 1) + (2 + 4 + (s.name.GetLength() + 1) * 2) + (2 + 4 + s.data.GetLength());
+ p->SetCount(count);
+ BYTE* ptr = p->GetData();
+
+ strcpy_s((char*)ptr, count, "GAB2");
+ ptr += 4 + 1;
+ count -= 4 + 1;
+
+ *(WORD*)ptr = 2;
+ ptr += 2;
+ count -= 2;
+ *(DWORD*)ptr = (s.name.GetLength() + 1) * 2;
+ ptr += 4;
+ count -= 4;
+ wcscpy_s((WCHAR*)ptr, count / 2, CStringW(s.name));
+ ptr += (s.name.GetLength() + 1) * 2;
+
+ *(WORD*)ptr = 4;
+ ptr += 2;
+ *(DWORD*)ptr = s.data.GetLength();
+ ptr += 4;
+ memcpy((char*)ptr, s.data, s.data.GetLength());
+ ptr += s.name.GetLength();
+
+ hr = DeliverPacket(p);
+ }
+
+ pos = m_seekpos;
+ while (pos && SUCCEEDED(hr) && !CheckRequest(NULL)) {
+ DataChunk* pdc = m_pFile->m_dcs.GetNext(pos);
+
+ m_pFile->Seek(m_seekfilepos > 0 ? m_seekfilepos : pdc->pos);
+
+ for (UINT32 i = m_seekpacket; i < pdc->nPackets && SUCCEEDED(hr) && !CheckRequest(NULL); i++) {
+ MediaPacketHeader mph;
+ if (S_OK != (hr = m_pFile->Read(mph))) {
+ break;
+ }
+
+ CAutoPtr<Packet> p(DNew Packet);
+ p->TrackNumber = mph.stream;
+ p->bSyncPoint = !!(mph.flags & MediaPacketHeader::PN_KEYFRAME_FLAG);
+ p->rtStart = 10000i64 * (mph.tStart);
+ p->rtStop = p->rtStart + 1;
+ p->Copy(mph.pData);
+ hr = DeliverPacket(p);
+ }
+
+ m_seekpacket = 0;
+ m_seekfilepos = 0;
+ }
+
+ return true;
}
// IKeyFrameInfo
STDMETHODIMP CRealMediaSplitterFilter::GetKeyFrameCount(UINT& nKFs)
{
- if (!m_pFile) {
- return E_UNEXPECTED;
- }
- nKFs = m_pFile->m_irs.GetCount();
- return S_OK;
+ if (!m_pFile) {
+ return E_UNEXPECTED;
+ }
+ nKFs = m_pFile->m_irs.GetCount();
+ return S_OK;
}
STDMETHODIMP CRealMediaSplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs)
{
- CheckPointer(pFormat, E_POINTER);
- CheckPointer(pKFs, E_POINTER);
-
- if (!m_pFile) {
- return E_UNEXPECTED;
- }
- if (*pFormat != TIME_FORMAT_MEDIA_TIME) {
- return E_INVALIDARG;
- }
-
- UINT nKFsTmp = 0;
- POSITION pos = m_pFile->m_irs.GetHeadPosition();
- for (int i = 0; pos && nKFsTmp < nKFs; i++) {
- pKFs[nKFsTmp++] = 10000i64*m_pFile->m_irs.GetNext(pos)->tStart;
- }
- nKFs = nKFsTmp;
-
- return S_OK;
+ CheckPointer(pFormat, E_POINTER);
+ CheckPointer(pKFs, E_POINTER);
+
+ if (!m_pFile) {
+ return E_UNEXPECTED;
+ }
+ if (*pFormat != TIME_FORMAT_MEDIA_TIME) {
+ return E_INVALIDARG;
+ }
+
+ UINT nKFsTmp = 0;
+ POSITION pos = m_pFile->m_irs.GetHeadPosition();
+ for (int i = 0; pos && nKFsTmp < nKFs; i++) {
+ pKFs[nKFsTmp++] = 10000i64 * m_pFile->m_irs.GetNext(pos)->tStart;
+ }
+ nKFs = nKFsTmp;
+
+ return S_OK;
}
//
@@ -802,7 +802,7 @@ STDMETHODIMP CRealMediaSplitterFilter::GetKeyFrames(const GUID* pFormat, REFEREN
//
CRealMediaSplitterOutputPin::CRealMediaSplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseSplitterOutputPin(mts, pName, pFilter, pLock, phr, 0, MAXPACKETS_RV)
+ : CBaseSplitterOutputPin(mts, pName, pFilter, pLock, phr, 0, MAXPACKETS_RV)
{
}
@@ -812,219 +812,219 @@ CRealMediaSplitterOutputPin::~CRealMediaSplitterOutputPin()
HRESULT CRealMediaSplitterOutputPin::DeliverEndFlush()
{
- {
- CAutoLock cAutoLock(&m_csQueue);
- m_segments.Clear();
- }
+ {
+ CAutoLock cAutoLock(&m_csQueue);
+ m_segments.Clear();
+ }
- return __super::DeliverEndFlush();
+ return __super::DeliverEndFlush();
}
HRESULT CRealMediaSplitterOutputPin::DeliverSegments()
{
- HRESULT hr;
-
- if (m_segments.GetCount() == 0) {
- m_segments.Clear();
- return S_OK;
- }
-
- CAutoPtr<Packet> p(DNew Packet());
-
- p->TrackNumber = (DWORD)-1;
- p->bDiscontinuity = m_segments.fDiscontinuity;
- p->bSyncPoint = m_segments.fSyncPoint;
- p->rtStart = m_segments.rtStart;
- p->rtStop = m_segments.rtStart+1;
-
- DWORD len = 0, total = 0;
- POSITION pos = m_segments.GetHeadPosition();
- while (pos) {
- segment* s = m_segments.GetNext(pos);
- len = max(len, s->offset + s->data.GetCount());
- total += s->data.GetCount();
- }
- ASSERT(len == total);
- len += 1 + 2*4*(!m_segments.fMerged ? m_segments.GetCount() : 1);
-
- p->SetCount(len);
-
- BYTE* pData = p->GetData();
-
- *pData++ = m_segments.fMerged ? 0 : m_segments.GetCount()-1;
-
- if (m_segments.fMerged) {
- *((DWORD*)pData) = 1;
- pData += 4;
- *((DWORD*)pData) = 0;
- pData += 4;
- } else {
- pos = m_segments.GetHeadPosition();
- while (pos) {
- *((DWORD*)pData) = 1;
- pData += 4;
- *((DWORD*)pData) = m_segments.GetNext(pos)->offset;
- pData += 4;
- }
- }
-
- pos = m_segments.GetHeadPosition();
- while (pos) {
- segment* s = m_segments.GetNext(pos);
- memcpy(pData + s->offset, s->data.GetData(), s->data.GetCount());
- }
-
- hr = __super::DeliverPacket(p);
-
- m_segments.Clear();
-
- return hr;
+ HRESULT hr;
+
+ if (m_segments.GetCount() == 0) {
+ m_segments.Clear();
+ return S_OK;
+ }
+
+ CAutoPtr<Packet> p(DNew Packet());
+
+ p->TrackNumber = (DWORD) - 1;
+ p->bDiscontinuity = m_segments.fDiscontinuity;
+ p->bSyncPoint = m_segments.fSyncPoint;
+ p->rtStart = m_segments.rtStart;
+ p->rtStop = m_segments.rtStart + 1;
+
+ DWORD len = 0, total = 0;
+ POSITION pos = m_segments.GetHeadPosition();
+ while (pos) {
+ segment* s = m_segments.GetNext(pos);
+ len = max(len, s->offset + s->data.GetCount());
+ total += s->data.GetCount();
+ }
+ ASSERT(len == total);
+ len += 1 + 2 * 4 * (!m_segments.fMerged ? m_segments.GetCount() : 1);
+
+ p->SetCount(len);
+
+ BYTE* pData = p->GetData();
+
+ *pData++ = m_segments.fMerged ? 0 : m_segments.GetCount() - 1;
+
+ if (m_segments.fMerged) {
+ *((DWORD*)pData) = 1;
+ pData += 4;
+ *((DWORD*)pData) = 0;
+ pData += 4;
+ } else {
+ pos = m_segments.GetHeadPosition();
+ while (pos) {
+ *((DWORD*)pData) = 1;
+ pData += 4;
+ *((DWORD*)pData) = m_segments.GetNext(pos)->offset;
+ pData += 4;
+ }
+ }
+
+ pos = m_segments.GetHeadPosition();
+ while (pos) {
+ segment* s = m_segments.GetNext(pos);
+ memcpy(pData + s->offset, s->data.GetData(), s->data.GetCount());
+ }
+
+ hr = __super::DeliverPacket(p);
+
+ m_segments.Clear();
+
+ return hr;
}
HRESULT CRealMediaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
{
- HRESULT hr = S_OK;
-
- ASSERT(p->rtStart < p->rtStop);
-
- if (m_mt.subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3) {
- WORD* s = (WORD*)p->GetData();
- WORD* e = s + p->GetCount()/2;
- while (s < e) {
- bswap(*s++);
- }
- }
-
- if (m_mt.subtype == MEDIASUBTYPE_RV10 || m_mt.subtype == MEDIASUBTYPE_RV20
- || m_mt.subtype == MEDIASUBTYPE_RV30 || m_mt.subtype == MEDIASUBTYPE_RV40
- || m_mt.subtype == MEDIASUBTYPE_RV41) {
- CAutoLock cAutoLock(&m_csQueue);
-
- int len = p->GetCount();
- BYTE* pIn = p->GetData();
- BYTE* pInOrg = pIn;
-
- if (m_segments.rtStart != p->rtStart) {
- if (S_OK != (hr = DeliverSegments())) {
- return hr;
- }
- }
-
- if (!m_segments.fDiscontinuity && p->bDiscontinuity) {
- m_segments.fDiscontinuity = true;
- }
- m_segments.fSyncPoint = !!p->bSyncPoint;
- m_segments.rtStart = p->rtStart;
-
- while (pIn - pInOrg < len) {
- BYTE hdr = *pIn++;
- DWORD packetlen = 0, packetoffset = 0;
-
- if ((hdr&0xc0) == 0x40) {
- pIn++;
- packetlen = len - (pIn - pInOrg);
- } else {
- if ((hdr&0x40) == 0) {
- pIn++; //BYTE subseq = (*pIn++)&0x7f;
- }
+ HRESULT hr = S_OK;
+
+ ASSERT(p->rtStart < p->rtStop);
+
+ if (m_mt.subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3) {
+ WORD* s = (WORD*)p->GetData();
+ WORD* e = s + p->GetCount() / 2;
+ while (s < e) {
+ bswap(*s++);
+ }
+ }
+
+ if (m_mt.subtype == MEDIASUBTYPE_RV10 || m_mt.subtype == MEDIASUBTYPE_RV20
+ || m_mt.subtype == MEDIASUBTYPE_RV30 || m_mt.subtype == MEDIASUBTYPE_RV40
+ || m_mt.subtype == MEDIASUBTYPE_RV41) {
+ CAutoLock cAutoLock(&m_csQueue);
+
+ int len = p->GetCount();
+ BYTE* pIn = p->GetData();
+ BYTE* pInOrg = pIn;
+
+ if (m_segments.rtStart != p->rtStart) {
+ if (S_OK != (hr = DeliverSegments())) {
+ return hr;
+ }
+ }
+
+ if (!m_segments.fDiscontinuity && p->bDiscontinuity) {
+ m_segments.fDiscontinuity = true;
+ }
+ m_segments.fSyncPoint = !!p->bSyncPoint;
+ m_segments.rtStart = p->rtStart;
+
+ while (pIn - pInOrg < len) {
+ BYTE hdr = *pIn++;
+ DWORD packetlen = 0, packetoffset = 0;
+
+ if ((hdr & 0xc0) == 0x40) {
+ pIn++;
+ packetlen = len - (pIn - pInOrg);
+ } else {
+ if ((hdr & 0x40) == 0) {
+ pIn++; //BYTE subseq = (*pIn++)&0x7f;
+ }
#define GetWORD(var) \
var = (var << 8) | (*pIn++); \
var = (var << 8) | (*pIn++);
- GetWORD(packetlen);
- if (packetlen&0x8000) {
- m_segments.fMerged = true;
- }
- if ((packetlen&0x4000) == 0) {
- GetWORD(packetlen);
- packetlen &= 0x3fffffff;
- } else {
- packetlen &= 0x3fff;
- }
-
- GetWORD(packetoffset);
- if ((packetoffset&0x4000) == 0) {
- GetWORD(packetoffset);
- packetoffset &= 0x3fffffff;
- } else {
- packetoffset &= 0x3fff;
- }
+ GetWORD(packetlen);
+ if (packetlen & 0x8000) {
+ m_segments.fMerged = true;
+ }
+ if ((packetlen & 0x4000) == 0) {
+ GetWORD(packetlen);
+ packetlen &= 0x3fffffff;
+ } else {
+ packetlen &= 0x3fff;
+ }
+
+ GetWORD(packetoffset);
+ if ((packetoffset & 0x4000) == 0) {
+ GetWORD(packetoffset);
+ packetoffset &= 0x3fffffff;
+ } else {
+ packetoffset &= 0x3fff;
+ }
#undef GetWORD
- if ((hdr&0xc0) == 0xc0) {
- m_segments.rtStart = 10000i64*packetoffset - m_rtStart, packetoffset = 0;
- } else if ((hdr&0xc0) == 0x80) {
- packetoffset = packetlen - packetoffset;
- }
-
- pIn++; //BYTE seqnum = *pIn++;
- }
-
- int len2 = min(len - (pIn - pInOrg), int(packetlen - packetoffset));
-
- CAutoPtr<segment> s(DNew segment);
- s->offset = packetoffset;
- s->data.SetCount(len2);
- memcpy(s->data.GetData(), pIn, len2);
- m_segments.AddTail(s);
-
- pIn += len2;
-
- if ((hdr&0x80) || packetoffset+len2 >= packetlen) {
- if (S_OK != (hr = DeliverSegments())) {
- return hr;
- }
- }
- }
- } else if (m_mt.subtype == MEDIASUBTYPE_RAAC || m_mt.subtype == MEDIASUBTYPE_RACP
- || m_mt.subtype == MEDIASUBTYPE_AAC) {
- BYTE* ptr = p->GetData()+2;
-
- CAtlList<WORD> sizes;
- int total = 0;
- int remaining = p->GetCount()-2;
- int expected = *(ptr-1)>>4;
-
- while (total < remaining) {
- int size = (ptr[0]<<8)|(ptr[1]);
- sizes.AddTail(size);
- total += size;
- ptr += 2;
- remaining -= 2;
- expected--;
- }
-
- ASSERT(total == remaining);
- ASSERT(expected == 0);
-
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.pbFormat;
- REFERENCE_TIME rtDur = 10240000000i64/wfe->nSamplesPerSec * (wfe->cbSize>2?2:1);
- REFERENCE_TIME rtStart = p->rtStart;
- BOOL bDiscontinuity = p->bDiscontinuity;
-
- POSITION pos = sizes.GetHeadPosition();
- while (pos) {
- WORD size = sizes.GetNext(pos);
-
- CAutoPtr<Packet> p(DNew Packet);
- p->bDiscontinuity = bDiscontinuity;
- p->bSyncPoint = true;
- p->rtStart = rtStart;
- p->rtStop = rtStart += rtDur;
- p->SetData(ptr, size);
- ptr += size;
- bDiscontinuity = false;
- if (S_OK != (hr = __super::DeliverPacket(p))) {
- break;
- }
- }
- } else {
- hr = __super::DeliverPacket(p);
- }
-
- return hr;
+ if ((hdr & 0xc0) == 0xc0) {
+ m_segments.rtStart = 10000i64 * packetoffset - m_rtStart, packetoffset = 0;
+ } else if ((hdr & 0xc0) == 0x80) {
+ packetoffset = packetlen - packetoffset;
+ }
+
+ pIn++; //BYTE seqnum = *pIn++;
+ }
+
+ int len2 = min(len - (pIn - pInOrg), int(packetlen - packetoffset));
+
+ CAutoPtr<segment> s(DNew segment);
+ s->offset = packetoffset;
+ s->data.SetCount(len2);
+ memcpy(s->data.GetData(), pIn, len2);
+ m_segments.AddTail(s);
+
+ pIn += len2;
+
+ if ((hdr & 0x80) || packetoffset + len2 >= packetlen) {
+ if (S_OK != (hr = DeliverSegments())) {
+ return hr;
+ }
+ }
+ }
+ } else if (m_mt.subtype == MEDIASUBTYPE_RAAC || m_mt.subtype == MEDIASUBTYPE_RACP
+ || m_mt.subtype == MEDIASUBTYPE_AAC) {
+ BYTE* ptr = p->GetData() + 2;
+
+ CAtlList<WORD> sizes;
+ int total = 0;
+ int remaining = p->GetCount() - 2;
+ int expected = *(ptr - 1) >> 4;
+
+ while (total < remaining) {
+ int size = (ptr[0] << 8) | (ptr[1]);
+ sizes.AddTail(size);
+ total += size;
+ ptr += 2;
+ remaining -= 2;
+ expected--;
+ }
+
+ ASSERT(total == remaining);
+ ASSERT(expected == 0);
+
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.pbFormat;
+ REFERENCE_TIME rtDur = 10240000000i64 / wfe->nSamplesPerSec * (wfe->cbSize > 2 ? 2 : 1);
+ REFERENCE_TIME rtStart = p->rtStart;
+ BOOL bDiscontinuity = p->bDiscontinuity;
+
+ POSITION pos = sizes.GetHeadPosition();
+ while (pos) {
+ WORD size = sizes.GetNext(pos);
+
+ CAutoPtr<Packet> p(DNew Packet);
+ p->bDiscontinuity = bDiscontinuity;
+ p->bSyncPoint = true;
+ p->rtStart = rtStart;
+ p->rtStop = rtStart += rtDur;
+ p->SetData(ptr, size);
+ ptr += size;
+ bDiscontinuity = false;
+ if (S_OK != (hr = __super::DeliverPacket(p))) {
+ break;
+ }
+ }
+ } else {
+ hr = __super::DeliverPacket(p);
+ }
+
+ return hr;
}
//
@@ -1032,10 +1032,10 @@ HRESULT CRealMediaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
//
CRealMediaSourceFilter::CRealMediaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CRealMediaSplitterFilter(pUnk, phr)
+ : CRealMediaSplitterFilter(pUnk, phr)
{
- m_clsid = __uuidof(this);
- m_pInput.Free();
+ m_clsid = __uuidof(this);
+ m_pInput.Free();
}
//
@@ -1043,572 +1043,572 @@ CRealMediaSourceFilter::CRealMediaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
//
CRMFile::CRMFile(IAsyncReader* pAsyncReader, HRESULT& hr)
- : CBaseSplitterFile(pAsyncReader, hr)
+ : CBaseSplitterFile(pAsyncReader, hr)
{
- if (FAILED(hr)) {
- return;
- }
- hr = Init();
+ if (FAILED(hr)) {
+ return;
+ }
+ hr = Init();
}
template<typename T>
HRESULT CRMFile::Read(T& var)
{
- HRESULT hr = ByteRead((BYTE*)&var, sizeof(var));
- bswap(var);
- return hr;
+ HRESULT hr = ByteRead((BYTE*)&var, sizeof(var));
+ bswap(var);
+ return hr;
}
HRESULT CRMFile::Read(ChunkHdr& hdr)
{
- memset(&hdr, 0, sizeof(hdr));
- HRESULT hr;
- if (S_OK != (hr = Read(hdr.object_id))
- || S_OK != (hr = Read(hdr.size))
- || S_OK != (hr = Read(hdr.object_version))) {
- return hr;
- }
- return S_OK;
+ memset(&hdr, 0, sizeof(hdr));
+ HRESULT hr;
+ if (S_OK != (hr = Read(hdr.object_id))
+ || S_OK != (hr = Read(hdr.size))
+ || S_OK != (hr = Read(hdr.object_version))) {
+ return hr;
+ }
+ return S_OK;
}
HRESULT CRMFile::Read(MediaPacketHeader& mph, bool fFull)
{
- memset(&mph, 0, FIELD_OFFSET(MediaPacketHeader, pData));
- mph.stream = (UINT16)-1;
-
- HRESULT hr;
-
- UINT16 object_version;
- if (S_OK != (hr = Read(object_version))) {
- return hr;
- }
- if (object_version != 0 && object_version != 1) {
- return S_OK;
- }
-
- UINT8 flags;
- if (S_OK != (hr = Read(mph.len))
- || S_OK != (hr = Read(mph.stream))
- || S_OK != (hr = Read(mph.tStart))
- || S_OK != (hr = Read(mph.reserved))
- || S_OK != (hr = Read(flags))) {
- return hr;
- }
- mph.flags = (MediaPacketHeader::flag_t)flags;
-
- LONG len = mph.len;
- len -= sizeof(object_version);
- len -= FIELD_OFFSET(MediaPacketHeader, flags);
- len -= sizeof(flags);
- ASSERT(len >= 0);
- len = max(len, 0);
-
- if (fFull) {
- mph.pData.SetCount(len);
- if (mph.len > 0 && S_OK != (hr = ByteRead(mph.pData.GetData(), len))) {
- return hr;
- }
- } else {
- Seek(GetPos() + len);
- }
-
- return S_OK;
+ memset(&mph, 0, FIELD_OFFSET(MediaPacketHeader, pData));
+ mph.stream = (UINT16) - 1;
+
+ HRESULT hr;
+
+ UINT16 object_version;
+ if (S_OK != (hr = Read(object_version))) {
+ return hr;
+ }
+ if (object_version != 0 && object_version != 1) {
+ return S_OK;
+ }
+
+ UINT8 flags;
+ if (S_OK != (hr = Read(mph.len))
+ || S_OK != (hr = Read(mph.stream))
+ || S_OK != (hr = Read(mph.tStart))
+ || S_OK != (hr = Read(mph.reserved))
+ || S_OK != (hr = Read(flags))) {
+ return hr;
+ }
+ mph.flags = (MediaPacketHeader::flag_t)flags;
+
+ LONG len = mph.len;
+ len -= sizeof(object_version);
+ len -= FIELD_OFFSET(MediaPacketHeader, flags);
+ len -= sizeof(flags);
+ ASSERT(len >= 0);
+ len = max(len, 0);
+
+ if (fFull) {
+ mph.pData.SetCount(len);
+ if (mph.len > 0 && S_OK != (hr = ByteRead(mph.pData.GetData(), len))) {
+ return hr;
+ }
+ } else {
+ Seek(GetPos() + len);
+ }
+
+ return S_OK;
}
HRESULT CRMFile::Init()
{
- Seek(0);
-
- bool fFirstChunk = true;
-
- HRESULT hr;
-
- ChunkHdr hdr;
- while (GetRemaining() && S_OK == (hr = Read(hdr))) {
- __int64 pos = GetPos() - sizeof(hdr);
-
- if (fFirstChunk && hdr.object_id != '.RMF') {
- return E_FAIL;
- }
-
- fFirstChunk = false;
-
- if (pos + hdr.size > GetLength() && hdr.object_id != 'DATA') { // truncated?
- break;
- }
-
- if (hdr.object_id == 0x2E7261FD) { // '.ra+0xFD'
- return E_FAIL;
- }
-
- if (hdr.object_version == 0) {
- switch (hdr.object_id) {
- case '.RMF':
- if (S_OK != (hr = Read(m_fh.version))) {
- return hr;
- }
- if (hdr.size == 0x10) {
- WORD w = 0;
- if (S_OK != (hr = Read(w))) {
- return hr;
- }
- m_fh.nHeaders = w;
- } else if (S_OK != (hr = Read(m_fh.nHeaders))) {
- return hr;
- }
- break;
- case 'CONT':
- UINT16 slen;
- if (S_OK != (hr = Read(slen))) {
- return hr;
- }
- if (slen > 0 && S_OK != (hr = ByteRead((BYTE*)m_cd.title.GetBufferSetLength(slen), slen))) {
- return hr;
- }
- if (S_OK != (hr = Read(slen))) {
- return hr;
- }
- if (slen > 0 && S_OK != (hr = ByteRead((BYTE*)m_cd.author.GetBufferSetLength(slen), slen))) {
- return hr;
- }
- if (S_OK != (hr = Read(slen))) {
- return hr;
- }
- if (slen > 0 && S_OK != (hr = ByteRead((BYTE*)m_cd.copyright.GetBufferSetLength(slen), slen))) {
- return hr;
- }
- if (S_OK != (hr = Read(slen))) {
- return hr;
- }
- if (slen > 0 && S_OK != (hr = ByteRead((BYTE*)m_cd.comment.GetBufferSetLength(slen), slen))) {
- return hr;
- }
- break;
- case 'PROP':
- if (S_OK != (hr = Read(m_p.maxBitRate))) {
- return hr;
- }
- if (S_OK != (hr = Read(m_p.avgBitRate))) {
- return hr;
- }
- if (S_OK != (hr = Read(m_p.maxPacketSize))) {
- return hr;
- }
- if (S_OK != (hr = Read(m_p.avgPacketSize))) {
- return hr;
- }
- if (S_OK != (hr = Read(m_p.nPackets))) {
- return hr;
- }
- if (S_OK != (hr = Read(m_p.tDuration))) {
- return hr;
- }
- if (S_OK != (hr = Read(m_p.tPreroll))) {
- return hr;
- }
- if (S_OK != (hr = Read(m_p.ptrIndex))) {
- return hr;
- }
- if (S_OK != (hr = Read(m_p.ptrData))) {
- return hr;
- }
- if (S_OK != (hr = Read(m_p.nStreams))) {
- return hr;
- }
- UINT16 flags;
- if (S_OK != (hr = Read(flags))) {
- return hr;
- }
- m_p.flags = (Properies::flags_t)flags;
- break;
- case 'MDPR': {
- CAutoPtr<MediaProperies> mp(DNew MediaProperies);
- if (S_OK != (hr = Read(mp->stream))) {
- return hr;
- }
- if (S_OK != (hr = Read(mp->maxBitRate))) {
- return hr;
- }
- if (S_OK != (hr = Read(mp->avgBitRate))) {
- return hr;
- }
- if (S_OK != (hr = Read(mp->maxPacketSize))) {
- return hr;
- }
- if (S_OK != (hr = Read(mp->avgPacketSize))) {
- return hr;
- }
- if (S_OK != (hr = Read(mp->tStart))) {
- return hr;
- }
- if (S_OK != (hr = Read(mp->tPreroll))) {
- return hr;
- }
- if (S_OK != (hr = Read(mp->tDuration))) {
- return hr;
- }
- UINT8 slen;
- if (S_OK != (hr = Read(slen))) {
- return hr;
- }
- if (slen > 0 && S_OK != (hr = ByteRead((BYTE*)mp->name.GetBufferSetLength(slen), slen))) {
- return hr;
- }
- if (S_OK != (hr = Read(slen))) {
- return hr;
- }
- if (slen > 0 && S_OK != (hr = ByteRead((BYTE*)mp->mime.GetBufferSetLength(slen), slen))) {
- return hr;
- }
- UINT32 tsdlen;
- if (S_OK != (hr = Read(tsdlen))) {
- return hr;
- }
- mp->typeSpecData.SetCount(tsdlen);
- if (tsdlen > 0 && S_OK != (hr = ByteRead(mp->typeSpecData.GetData(), tsdlen))) {
- return hr;
- }
- mp->width = mp->height = 0;
- mp->interlaced = mp->top_field_first = false;
- m_mps.AddTail(mp);
- break;
- }
- case 'DATA': {
- CAutoPtr<DataChunk> dc(DNew DataChunk);
- if (S_OK != (hr = Read(dc->nPackets))) {
- return hr;
- }
- if (S_OK != (hr = Read(dc->ptrNext))) {
- return hr;
- }
- dc->pos = GetPos();
- m_dcs.AddTail(dc);
- GetDimensions();
- break;
- }
- case 'INDX': {
- IndexChunkHeader ich;
- if (S_OK != (hr = Read(ich.nIndices))) {
- return hr;
- }
- if (S_OK != (hr = Read(ich.stream))) {
- return hr;
- }
- if (S_OK != (hr = Read(ich.ptrNext))) {
- return hr;
- }
- int stream = GetMasterStream();
- while (ich.nIndices-- > 0) {
- UINT16 object_version;
- if (S_OK != (hr = Read(object_version))) {
- return hr;
- }
- if (object_version == 0) {
- CAutoPtr<IndexRecord> ir(DNew IndexRecord);
- if (S_OK != (hr = Read(ir->tStart))) {
- return hr;
- }
- if (S_OK != (hr = Read(ir->ptrFilePos))) {
- return hr;
- }
- if (S_OK != (hr = Read(ir->packet))) {
- return hr;
- }
- if (ich.stream == stream) {
- m_irs.AddTail(ir);
- }
- }
- }
- break;
- }
- case '.SUB':
- if (hdr.size > sizeof(hdr)) {
- int size = hdr.size - sizeof(hdr);
- CAutoVectorPtr<char> buff;
- if (!buff.Allocate(size)) {
- return E_OUTOFMEMORY;
- }
- char* p = buff;
- if (S_OK != (hr = ByteRead((BYTE*)p, size))) {
- return hr;
- }
- for (char* end = p + size; p < end; ) {
- subtitle s;
- s.name = p;
- p += s.name.GetLength()+1;
- CStringA len(p);
- p += len.GetLength()+1;
- s.data = CStringA(p, strtol(len, NULL, 10));
- p += s.data.GetLength();
- m_subs.AddTail(s);
- }
- }
- break;
- }
- }
-
- if (hdr.object_id == 'CONT' && BitRead(32, true) == 'DATA') {
- hdr.size = GetPos() - pos;
- }
-
- ASSERT(hdr.object_id == 'DATA'
- || GetPos() == pos + hdr.size
- || GetPos() == pos + sizeof(hdr));
-
- pos += hdr.size;
- if (pos > GetPos()) {
- Seek(pos);
- }
- }
-
- return S_OK;
+ Seek(0);
+
+ bool fFirstChunk = true;
+
+ HRESULT hr;
+
+ ChunkHdr hdr;
+ while (GetRemaining() && S_OK == (hr = Read(hdr))) {
+ __int64 pos = GetPos() - sizeof(hdr);
+
+ if (fFirstChunk && hdr.object_id != '.RMF') {
+ return E_FAIL;
+ }
+
+ fFirstChunk = false;
+
+ if (pos + hdr.size > GetLength() && hdr.object_id != 'DATA') { // truncated?
+ break;
+ }
+
+ if (hdr.object_id == 0x2E7261FD) { // '.ra+0xFD'
+ return E_FAIL;
+ }
+
+ if (hdr.object_version == 0) {
+ switch (hdr.object_id) {
+ case '.RMF':
+ if (S_OK != (hr = Read(m_fh.version))) {
+ return hr;
+ }
+ if (hdr.size == 0x10) {
+ WORD w = 0;
+ if (S_OK != (hr = Read(w))) {
+ return hr;
+ }
+ m_fh.nHeaders = w;
+ } else if (S_OK != (hr = Read(m_fh.nHeaders))) {
+ return hr;
+ }
+ break;
+ case 'CONT':
+ UINT16 slen;
+ if (S_OK != (hr = Read(slen))) {
+ return hr;
+ }
+ if (slen > 0 && S_OK != (hr = ByteRead((BYTE*)m_cd.title.GetBufferSetLength(slen), slen))) {
+ return hr;
+ }
+ if (S_OK != (hr = Read(slen))) {
+ return hr;
+ }
+ if (slen > 0 && S_OK != (hr = ByteRead((BYTE*)m_cd.author.GetBufferSetLength(slen), slen))) {
+ return hr;
+ }
+ if (S_OK != (hr = Read(slen))) {
+ return hr;
+ }
+ if (slen > 0 && S_OK != (hr = ByteRead((BYTE*)m_cd.copyright.GetBufferSetLength(slen), slen))) {
+ return hr;
+ }
+ if (S_OK != (hr = Read(slen))) {
+ return hr;
+ }
+ if (slen > 0 && S_OK != (hr = ByteRead((BYTE*)m_cd.comment.GetBufferSetLength(slen), slen))) {
+ return hr;
+ }
+ break;
+ case 'PROP':
+ if (S_OK != (hr = Read(m_p.maxBitRate))) {
+ return hr;
+ }
+ if (S_OK != (hr = Read(m_p.avgBitRate))) {
+ return hr;
+ }
+ if (S_OK != (hr = Read(m_p.maxPacketSize))) {
+ return hr;
+ }
+ if (S_OK != (hr = Read(m_p.avgPacketSize))) {
+ return hr;
+ }
+ if (S_OK != (hr = Read(m_p.nPackets))) {
+ return hr;
+ }
+ if (S_OK != (hr = Read(m_p.tDuration))) {
+ return hr;
+ }
+ if (S_OK != (hr = Read(m_p.tPreroll))) {
+ return hr;
+ }
+ if (S_OK != (hr = Read(m_p.ptrIndex))) {
+ return hr;
+ }
+ if (S_OK != (hr = Read(m_p.ptrData))) {
+ return hr;
+ }
+ if (S_OK != (hr = Read(m_p.nStreams))) {
+ return hr;
+ }
+ UINT16 flags;
+ if (S_OK != (hr = Read(flags))) {
+ return hr;
+ }
+ m_p.flags = (Properies::flags_t)flags;
+ break;
+ case 'MDPR': {
+ CAutoPtr<MediaProperies> mp(DNew MediaProperies);
+ if (S_OK != (hr = Read(mp->stream))) {
+ return hr;
+ }
+ if (S_OK != (hr = Read(mp->maxBitRate))) {
+ return hr;
+ }
+ if (S_OK != (hr = Read(mp->avgBitRate))) {
+ return hr;
+ }
+ if (S_OK != (hr = Read(mp->maxPacketSize))) {
+ return hr;
+ }
+ if (S_OK != (hr = Read(mp->avgPacketSize))) {
+ return hr;
+ }
+ if (S_OK != (hr = Read(mp->tStart))) {
+ return hr;
+ }
+ if (S_OK != (hr = Read(mp->tPreroll))) {
+ return hr;
+ }
+ if (S_OK != (hr = Read(mp->tDuration))) {
+ return hr;
+ }
+ UINT8 slen;
+ if (S_OK != (hr = Read(slen))) {
+ return hr;
+ }
+ if (slen > 0 && S_OK != (hr = ByteRead((BYTE*)mp->name.GetBufferSetLength(slen), slen))) {
+ return hr;
+ }
+ if (S_OK != (hr = Read(slen))) {
+ return hr;
+ }
+ if (slen > 0 && S_OK != (hr = ByteRead((BYTE*)mp->mime.GetBufferSetLength(slen), slen))) {
+ return hr;
+ }
+ UINT32 tsdlen;
+ if (S_OK != (hr = Read(tsdlen))) {
+ return hr;
+ }
+ mp->typeSpecData.SetCount(tsdlen);
+ if (tsdlen > 0 && S_OK != (hr = ByteRead(mp->typeSpecData.GetData(), tsdlen))) {
+ return hr;
+ }
+ mp->width = mp->height = 0;
+ mp->interlaced = mp->top_field_first = false;
+ m_mps.AddTail(mp);
+ break;
+ }
+ case 'DATA': {
+ CAutoPtr<DataChunk> dc(DNew DataChunk);
+ if (S_OK != (hr = Read(dc->nPackets))) {
+ return hr;
+ }
+ if (S_OK != (hr = Read(dc->ptrNext))) {
+ return hr;
+ }
+ dc->pos = GetPos();
+ m_dcs.AddTail(dc);
+ GetDimensions();
+ break;
+ }
+ case 'INDX': {
+ IndexChunkHeader ich;
+ if (S_OK != (hr = Read(ich.nIndices))) {
+ return hr;
+ }
+ if (S_OK != (hr = Read(ich.stream))) {
+ return hr;
+ }
+ if (S_OK != (hr = Read(ich.ptrNext))) {
+ return hr;
+ }
+ int stream = GetMasterStream();
+ while (ich.nIndices-- > 0) {
+ UINT16 object_version;
+ if (S_OK != (hr = Read(object_version))) {
+ return hr;
+ }
+ if (object_version == 0) {
+ CAutoPtr<IndexRecord> ir(DNew IndexRecord);
+ if (S_OK != (hr = Read(ir->tStart))) {
+ return hr;
+ }
+ if (S_OK != (hr = Read(ir->ptrFilePos))) {
+ return hr;
+ }
+ if (S_OK != (hr = Read(ir->packet))) {
+ return hr;
+ }
+ if (ich.stream == stream) {
+ m_irs.AddTail(ir);
+ }
+ }
+ }
+ break;
+ }
+ case '.SUB':
+ if (hdr.size > sizeof(hdr)) {
+ int size = hdr.size - sizeof(hdr);
+ CAutoVectorPtr<char> buff;
+ if (!buff.Allocate(size)) {
+ return E_OUTOFMEMORY;
+ }
+ char* p = buff;
+ if (S_OK != (hr = ByteRead((BYTE*)p, size))) {
+ return hr;
+ }
+ for (char* end = p + size; p < end;) {
+ subtitle s;
+ s.name = p;
+ p += s.name.GetLength() + 1;
+ CStringA len(p);
+ p += len.GetLength() + 1;
+ s.data = CStringA(p, strtol(len, NULL, 10));
+ p += s.data.GetLength();
+ m_subs.AddTail(s);
+ }
+ }
+ break;
+ }
+ }
+
+ if (hdr.object_id == 'CONT' && BitRead(32, true) == 'DATA') {
+ hdr.size = GetPos() - pos;
+ }
+
+ ASSERT(hdr.object_id == 'DATA'
+ || GetPos() == pos + hdr.size
+ || GetPos() == pos + sizeof(hdr));
+
+ pos += hdr.size;
+ if (pos > GetPos()) {
+ Seek(pos);
+ }
+ }
+
+ return S_OK;
}
#define GetBits(n) GetBits2(n, p, bit_offset, bit_buffer)
unsigned int GetBits2(int n, unsigned char*& p, unsigned int& bit_offset, unsigned int& bit_buffer)
{
- unsigned int ret = ((unsigned int)bit_buffer >> (32-(n)));
-
- bit_offset += n;
- bit_buffer <<= n;
- if (bit_offset > (32-16)) {
- p += bit_offset >> 3;
- bit_offset &= 7;
- bit_buffer = (unsigned int)p[0] << 24;
- bit_buffer |= (unsigned int)p[1] << 16;
- bit_buffer |= (unsigned int)p[2] << 8;
- bit_buffer |= (unsigned int)p[3];
- bit_buffer <<= bit_offset;
- }
-
- return ret;
+ unsigned int ret = ((unsigned int)bit_buffer >> (32 - (n)));
+
+ bit_offset += n;
+ bit_buffer <<= n;
+ if (bit_offset > (32 - 16)) {
+ p += bit_offset >> 3;
+ bit_offset &= 7;
+ bit_buffer = (unsigned int)p[0] << 24;
+ bit_buffer |= (unsigned int)p[1] << 16;
+ bit_buffer |= (unsigned int)p[2] << 8;
+ bit_buffer |= (unsigned int)p[3];
+ bit_buffer <<= bit_offset;
+ }
+
+ return ret;
}
void GetDimensions(unsigned char* p, unsigned int* wi, unsigned int* hi)
{
- unsigned int w, h, c;
+ unsigned int w, h, c;
- const unsigned int cw[8] = {160, 176, 240, 320, 352, 640, 704, 0};
- const unsigned int ch1[8] = {120, 132, 144, 240, 288, 480, 0, 0};
- const unsigned int ch2[4] = {180, 360, 576, 0};
+ const unsigned int cw[8] = {160, 176, 240, 320, 352, 640, 704, 0};
+ const unsigned int ch1[8] = {120, 132, 144, 240, 288, 480, 0, 0};
+ const unsigned int ch2[4] = {180, 360, 576, 0};
- unsigned int bit_offset = 0;
- unsigned int bit_buffer = *(unsigned int*)p;
- bswap(bit_buffer);
+ unsigned int bit_offset = 0;
+ unsigned int bit_buffer = *(unsigned int*)p;
+ bswap(bit_buffer);
- GetBits(13);
+ GetBits(13);
- GetBits(13);
+ GetBits(13);
- w = cw[GetBits(3)];
- if (w == 0) {
- do {
- c = GetBits(8);
- w += (c << 2);
- } while (c == 255);
- }
+ w = cw[GetBits(3)];
+ if (w == 0) {
+ do {
+ c = GetBits(8);
+ w += (c << 2);
+ } while (c == 255);
+ }
- c = GetBits(3);
+ c = GetBits(3);
- h = ch1[c];
- if (h == 0) {
- c = ((c << 1) | GetBits(1)) & 3;
+ h = ch1[c];
+ if (h == 0) {
+ c = ((c << 1) | GetBits(1)) & 3;
- h = ch2[c];
- if (h == 0) {
- do {
- c = GetBits(8);
- h += (c << 2);
- } while (c == 255);
- }
- }
+ h = ch2[c];
+ if (h == 0) {
+ do {
+ c = GetBits(8);
+ h += (c << 2);
+ } while (c == 255);
+ }
+ }
- *wi = w;
- *hi = h;
+ *wi = w;
+ *hi = h;
}
void GetDimensions_X10(unsigned char* p, unsigned int* wi, unsigned int* hi,
- bool *interlaced, bool *top_field_first, bool *repeat_field)
+ bool* interlaced, bool* top_field_first, bool* repeat_field)
{
- unsigned int w, h, c;
-
- const unsigned int cw[8] = {160, 176, 240, 320, 352, 640, 704, 0};
- const unsigned int ch1[8] = {120, 132, 144, 240, 288, 480, 0, 0};
- const unsigned int ch2[4] = {180, 360, 576, 0};
-
- unsigned int bit_offset = 0;
- unsigned int bit_buffer = *(unsigned int*)p;
- bswap(bit_buffer);
-
- GetBits(9);
-
- *interlaced = false;
- *top_field_first = false;
- *repeat_field = false;
- c = GetBits(1);
- if (c) {
- c = GetBits(1);
- if (c) {
- *interlaced = true;
- }
- c = GetBits(1);
- if (c) {
- *top_field_first = true;
- }
- c = GetBits(1);
- if (c) {
- *repeat_field = true;
- }
-
- c = GetBits(1);
- c = GetBits(1);
- if (c) {
- GetBits(2);
- }
- }
-
- GetBits(16);
-
- w = cw[GetBits(3)];
- if (w == 0) {
- do {
- c = GetBits(8);
- w += (c << 2);
- } while (c == 255);
- }
-
- c = GetBits(3);
-
- h = ch1[c];
- if (h == 0) {
- c = ((c << 1) | GetBits(1)) & 3;
-
- h = ch2[c];
- if (h == 0) {
- do {
- c = GetBits(8);
- h += (c << 2);
- } while (c == 255);
- }
- }
-
- *wi = w;
- *hi = h;
+ unsigned int w, h, c;
+
+ const unsigned int cw[8] = {160, 176, 240, 320, 352, 640, 704, 0};
+ const unsigned int ch1[8] = {120, 132, 144, 240, 288, 480, 0, 0};
+ const unsigned int ch2[4] = {180, 360, 576, 0};
+
+ unsigned int bit_offset = 0;
+ unsigned int bit_buffer = *(unsigned int*)p;
+ bswap(bit_buffer);
+
+ GetBits(9);
+
+ *interlaced = false;
+ *top_field_first = false;
+ *repeat_field = false;
+ c = GetBits(1);
+ if (c) {
+ c = GetBits(1);
+ if (c) {
+ *interlaced = true;
+ }
+ c = GetBits(1);
+ if (c) {
+ *top_field_first = true;
+ }
+ c = GetBits(1);
+ if (c) {
+ *repeat_field = true;
+ }
+
+ c = GetBits(1);
+ c = GetBits(1);
+ if (c) {
+ GetBits(2);
+ }
+ }
+
+ GetBits(16);
+
+ w = cw[GetBits(3)];
+ if (w == 0) {
+ do {
+ c = GetBits(8);
+ w += (c << 2);
+ } while (c == 255);
+ }
+
+ c = GetBits(3);
+
+ h = ch1[c];
+ if (h == 0) {
+ c = ((c << 1) | GetBits(1)) & 3;
+
+ h = ch2[c];
+ if (h == 0) {
+ do {
+ c = GetBits(8);
+ h += (c << 2);
+ } while (c == 255);
+ }
+ }
+
+ *wi = w;
+ *hi = h;
}
void CRMFile::GetDimensions()
{
- POSITION pos = m_mps.GetHeadPosition();
- while (pos) {
- UINT64 filepos = GetPos();
-
- MediaProperies* pmp = m_mps.GetNext(pos);
- if (pmp->mime == "video/x-pn-realvideo") {
- pmp->width = pmp->height = 0;
-
- rvinfo rvi = *(rvinfo*)pmp->typeSpecData.GetData();
- rvi.bswap();
-
- if (rvi.fcc2 != '04VR' && rvi.fcc2 != '14VR') {
- continue;
- }
-
- MediaPacketHeader mph;
- while (S_OK == Read(mph)) {
- if (mph.stream != pmp->stream || mph.len == 0
- || !(mph.flags&MediaPacketHeader::PN_KEYFRAME_FLAG)) {
- continue;
- }
-
- BYTE* p = mph.pData.GetData();
- BYTE* p0 = p;
- int len = mph.pData.GetCount();
-
- BYTE hdr = *p++;
- DWORD packetlen = 0, packetoffset = 0;
-
- if ((hdr&0xc0) == 0x40) {
- packetlen = len - (++p - p0);
- } else {
- if ((hdr&0x40) == 0) {
- p++;
- }
+ POSITION pos = m_mps.GetHeadPosition();
+ while (pos) {
+ UINT64 filepos = GetPos();
+
+ MediaProperies* pmp = m_mps.GetNext(pos);
+ if (pmp->mime == "video/x-pn-realvideo") {
+ pmp->width = pmp->height = 0;
+
+ rvinfo rvi = *(rvinfo*)pmp->typeSpecData.GetData();
+ rvi.bswap();
+
+ if (rvi.fcc2 != '04VR' && rvi.fcc2 != '14VR') {
+ continue;
+ }
+
+ MediaPacketHeader mph;
+ while (S_OK == Read(mph)) {
+ if (mph.stream != pmp->stream || mph.len == 0
+ || !(mph.flags & MediaPacketHeader::PN_KEYFRAME_FLAG)) {
+ continue;
+ }
+
+ BYTE* p = mph.pData.GetData();
+ BYTE* p0 = p;
+ int len = mph.pData.GetCount();
+
+ BYTE hdr = *p++;
+ DWORD packetlen = 0, packetoffset = 0;
+
+ if ((hdr & 0xc0) == 0x40) {
+ packetlen = len - (++p - p0);
+ } else {
+ if ((hdr & 0x40) == 0) {
+ p++;
+ }
#define GetWORD(var) \
var = (var << 8) | (*p++); \
var = (var << 8) | (*p++);
- GetWORD(packetlen);
- if ((packetlen&0x4000) == 0) {
- GetWORD(packetlen);
- packetlen &= 0x3fffffff;
- } else {
- packetlen &= 0x3fff;
- }
-
- GetWORD(packetoffset);
- if ((packetoffset&0x4000) == 0) {
- GetWORD(packetoffset);
- packetoffset &= 0x3fffffff;
- } else {
- packetoffset &= 0x3fff;
- }
+ GetWORD(packetlen);
+ if ((packetlen & 0x4000) == 0) {
+ GetWORD(packetlen);
+ packetlen &= 0x3fffffff;
+ } else {
+ packetlen &= 0x3fff;
+ }
+
+ GetWORD(packetoffset);
+ if ((packetoffset & 0x4000) == 0) {
+ GetWORD(packetoffset);
+ packetoffset &= 0x3fffffff;
+ } else {
+ packetoffset &= 0x3fff;
+ }
#undef GetWORD
- if ((hdr&0xc0) == 0xc0) {
- packetoffset = 0;
- } else if ((hdr&0xc0) == 0x80) {
- packetoffset = packetlen - packetoffset;
- }
+ if ((hdr & 0xc0) == 0xc0) {
+ packetoffset = 0;
+ } else if ((hdr & 0xc0) == 0x80) {
+ packetoffset = packetlen - packetoffset;
+ }
- p++;
- }
+ p++;
+ }
- len = min(len - (p - p0), int(packetlen - packetoffset));
+ len = min(len - (p - p0), int(packetlen - packetoffset));
- if (len > 0) {
- bool repeat_field;
- if (rvi.fcc2 == '14VR') {
- ::GetDimensions_X10(p, &pmp->width, &pmp->height, &pmp->interlaced, &pmp->top_field_first, &repeat_field);
- } else {
- ::GetDimensions(p, &pmp->width, &pmp->height);
- }
+ if (len > 0) {
+ bool repeat_field;
+ if (rvi.fcc2 == '14VR') {
+ ::GetDimensions_X10(p, &pmp->width, &pmp->height, &pmp->interlaced, &pmp->top_field_first, &repeat_field);
+ } else {
+ ::GetDimensions(p, &pmp->width, &pmp->height);
+ }
- if (rvi.w == pmp->width && rvi.h == pmp->height) {
- pmp->width = pmp->height = 0;
- }
+ if (rvi.w == pmp->width && rvi.h == pmp->height) {
+ pmp->width = pmp->height = 0;
+ }
- break;
- }
- }
- }
+ break;
+ }
+ }
+ }
- Seek(filepos);
- }
+ Seek(filepos);
+ }
}
int CRMFile::GetMasterStream()
{
- int s1 = -1, s2 = -1;
-
- POSITION pos = m_mps.GetHeadPosition();
- while (pos) {
- MediaProperies* pmp = m_mps.GetNext(pos);
- if (pmp->mime == "video/x-pn-realvideo") {
- s1 = pmp->stream;
- break;
- } else if (pmp->mime == "audio/x-pn-realaudio" && s2 == -1) {
- s2 = pmp->stream;
- }
- }
-
- if (s1 == -1) {
- s1 = s2;
- }
-
- return s1;
+ int s1 = -1, s2 = -1;
+
+ POSITION pos = m_mps.GetHeadPosition();
+ while (pos) {
+ MediaProperies* pmp = m_mps.GetNext(pos);
+ if (pmp->mime == "video/x-pn-realvideo") {
+ s1 = pmp->stream;
+ break;
+ } else if (pmp->mime == "audio/x-pn-realaudio" && s2 == -1) {
+ s2 = pmp->stream;
+ }
+ }
+
+ if (s1 == -1) {
+ s1 = s2;
+ }
+
+ return s1;
}
@@ -1619,465 +1619,465 @@ int CRMFile::GetMasterStream()
//
CRealVideoDecoder::CRealVideoDecoder(LPUNKNOWN lpunk, HRESULT* phr)
- : CBaseVideoFilter(NAME("CRealVideoDecoder"), lpunk, phr, __uuidof(this))
- , m_hDrvDll(NULL)
- , m_dwCookie(0)
- , m_lastBuffSizeDim(0)
+ : CBaseVideoFilter(NAME("CRealVideoDecoder"), lpunk, phr, __uuidof(this))
+ , m_hDrvDll(NULL)
+ , m_dwCookie(0)
+ , m_lastBuffSizeDim(0)
{
}
CRealVideoDecoder::~CRealVideoDecoder()
{
- if (m_hDrvDll) {
- FreeLibrary(m_hDrvDll);
- }
+ if (m_hDrvDll) {
+ FreeLibrary(m_hDrvDll);
+ }
}
HRESULT CRealVideoDecoder::InitRV(const CMediaType* pmt)
{
- FreeRV();
+ FreeRV();
- HRESULT hr = VFW_E_TYPE_NOT_ACCEPTED;
+ HRESULT hr = VFW_E_TYPE_NOT_ACCEPTED;
- rvinfo rvi = *(rvinfo*)(pmt->Format() + (pmt->formattype == FORMAT_VideoInfo ? sizeof(VIDEOINFOHEADER) : sizeof(VIDEOINFOHEADER2)));
- rvi.bswap();
+ rvinfo rvi = *(rvinfo*)(pmt->Format() + (pmt->formattype == FORMAT_VideoInfo ? sizeof(VIDEOINFOHEADER) : sizeof(VIDEOINFOHEADER2)));
+ rvi.bswap();
#pragma pack(push, 1)
- struct {
- WORD unk1, w, h, unk3;
- DWORD unk2, subformat, unk5, format;
- } i =
- {11, rvi.w, rvi.h, 0, 0, rvi.type1, 1, rvi.type2};
+ struct {
+ WORD unk1, w, h, unk3;
+ DWORD unk2, subformat, unk5, format;
+ } i =
+ {11, rvi.w, rvi.h, 0, 0, rvi.type1, 1, rvi.type2};
#pragma pack(pop)
- if (FAILED(hr = RVInit(&i, &m_dwCookie))) {
- return hr;
- }
-
- if (rvi.fcc2 <= '03VR' && rvi.type2 >= 0x20200002) {
- int nWidthHeight = (1+((rvi.type1>>16)&7));
- UINT32* pWH = DNew UINT32[nWidthHeight*2];
- pWH[0] = rvi.w;
- pWH[1] = rvi.h;
- for (int i = 2; i < nWidthHeight*2; i++) {
- pWH[i] = rvi.morewh[i-2]*4;
- }
+ if (FAILED(hr = RVInit(&i, &m_dwCookie))) {
+ return hr;
+ }
+
+ if (rvi.fcc2 <= '03VR' && rvi.type2 >= 0x20200002) {
+ int nWidthHeight = (1 + ((rvi.type1 >> 16) & 7));
+ UINT32* pWH = DNew UINT32[nWidthHeight * 2];
+ pWH[0] = rvi.w;
+ pWH[1] = rvi.h;
+ for (int i = 2; i < nWidthHeight * 2; i++) {
+ pWH[i] = rvi.morewh[i - 2] * 4;
+ }
#pragma pack(push, 1)
- struct {
- UINT32 data1;
- UINT32 data2;
- UINT32* dimensions;
- } cmsg_data =
- {0x24, nWidthHeight, pWH};
+ struct {
+ UINT32 data1;
+ UINT32 data2;
+ UINT32* dimensions;
+ } cmsg_data =
+ {0x24, nWidthHeight, pWH};
#pragma pack(pop)
- hr = RVCustomMessage(&cmsg_data, m_dwCookie);
- delete [] pWH;
- }
+ hr = RVCustomMessage(&cmsg_data, m_dwCookie);
+ delete [] pWH;
+ }
- return hr;
+ return hr;
}
void CRealVideoDecoder::FreeRV()
{
- if (m_dwCookie) {
- RVFree(m_dwCookie);
- m_dwCookie = 0;
- }
+ if (m_dwCookie) {
+ RVFree(m_dwCookie);
+ m_dwCookie = 0;
+ }
}
HRESULT CRealVideoDecoder::Transform(IMediaSample* pIn)
{
- CAutoLock cAutoLock(&m_csReceive);
+ CAutoLock cAutoLock(&m_csReceive);
- HRESULT hr;
+ HRESULT hr;
- BYTE* pDataIn = NULL;
- if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
- return hr;
- }
+ BYTE* pDataIn = NULL;
+ if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
+ return hr;
+ }
- long len = pIn->GetActualDataLength();
- if (len <= 0) {
- return S_OK; // nothing to do
- }
+ long len = pIn->GetActualDataLength();
+ if (len <= 0) {
+ return S_OK; // nothing to do
+ }
- REFERENCE_TIME rtStart, rtStop;
- pIn->GetTime(&rtStart, &rtStop);
+ REFERENCE_TIME rtStart, rtStop;
+ pIn->GetTime(&rtStart, &rtStop);
- rtStart += m_tStart;
+ rtStart += m_tStart;
- int offset = 1+((*pDataIn)+1)*8;
+ int offset = 1 + ((*pDataIn) + 1) * 8;
#pragma pack(push, 1)
- struct {
- DWORD len, unk1, chunks;
- DWORD* extra;
- DWORD unk2, timestamp;
- } transform_in =
- {len - offset, 0, *pDataIn, (DWORD*)(pDataIn+1), 0, (DWORD)(rtStart/10000)};
- struct {
- DWORD unk1, unk2, timestamp, w, h;
- } transform_out =
- {0,0,0,0,0};
+ struct {
+ DWORD len, unk1, chunks;
+ DWORD* extra;
+ DWORD unk2, timestamp;
+ } transform_in =
+ {len - offset, 0, *pDataIn, (DWORD*)(pDataIn + 1), 0, (DWORD)(rtStart / 10000)};
+ struct {
+ DWORD unk1, unk2, timestamp, w, h;
+ } transform_out =
+ {0, 0, 0, 0, 0};
#pragma pack(pop)
- pDataIn += offset;
-
- if (m_fDropFrames && m_timestamp+1 == transform_in.timestamp) {
- m_timestamp = transform_in.timestamp;
- return S_OK;
- }
-
-
- unsigned int tmp1, tmp2;
- bool interlaced = false, tmp3, tmp4;
- ::GetDimensions_X10(pDataIn, &tmp1, &tmp2, &interlaced, &tmp3, &tmp4);
-
- int size = tmp1*tmp2;
- if ( m_lastBuffSizeDim < size ) {
- _aligned_free(m_pI420);
- _aligned_free(m_pI420Tmp);
-
- m_lastBuffSizeDim = size;
- ATLTRACE("resize out put buff %d" ,size);
- m_pI420 = static_cast<BYTE*>(_aligned_malloc(size*3/2, 16));
- if ( m_pI420 ) {
- ATLTRACE(" m_pI420.Allocated 1" );
- memset(m_pI420, 0, size);
- ATLTRACE(" m_pI420.Allocated 2" );
- memset(m_pI420 + size, 0x80, size/2);
- ATLTRACE(" m_pI420.Allocated 3" );
- } else {
- ATLTRACE(" m_pI420.Allocate fail %d" ,size*3/2);
- return S_OK;
- }
- m_pI420Tmp = static_cast<BYTE*>(_aligned_malloc(size*3/2, 16));
- if ( m_pI420Tmp ) {
- ATLTRACE(" m_pI420Tmp.Allocated 1" );
- memset(m_pI420Tmp, 0, size);
- ATLTRACE(" m_pI420Tmp.Allocated 2" );
- memset(m_pI420Tmp + size, 0x80, size/2);
- ATLTRACE(" m_pI420Tmp.Allocated 3" );
- } else {
- ATLTRACE(" m_pI420Tmp.Allocate fail %d" ,size*3/2);
- return S_OK;
- }
- }
-
- hr = RVTransform(pDataIn, (BYTE*)m_pI420, &transform_in, &transform_out, m_dwCookie);
-
- m_timestamp = transform_in.timestamp;
-
- if (FAILED(hr)) {
- TRACE(_T("RV returned an error code!!!\n"));
- ASSERT(!(transform_out.unk1&1)); // error allowed when the "render" flag is not set
- // return hr;
- }
-
- if (pIn->IsPreroll() == S_OK || rtStart < 0 || !(transform_out.unk1&1)) {
- return S_OK;
- }
-
- CComPtr<IMediaSample> pOut;
- BYTE* pDataOut = NULL;
- if (/*FAILED(hr = GetDeliveryBuffer(transform_out.w, transform_out.h, &pOut)) // TODO
- && */ FAILED(hr = GetDeliveryBuffer(m_w, m_h, &pOut))
- || FAILED(hr = pOut->GetPointer(&pDataOut))) {
- return hr;
- }
-
- BYTE* pI420[3] = {m_pI420, m_pI420Tmp, NULL};
-
- if (interlaced) {
- int size = m_w*m_h;
- DeinterlaceBlend(pI420[1], pI420[0], m_w, m_h, m_w, m_w);
- DeinterlaceBlend(pI420[1]+size, pI420[0]+size, m_w/2, m_h/2, m_w/2, m_w/2);
- DeinterlaceBlend(pI420[1]+size*5/4, pI420[0]+size*5/4, m_w/2, m_h/2, m_w/2, m_w/2);
- pI420[2] = pI420[1], pI420[1] = pI420[0], pI420[0] = pI420[2];
- }
-
- if (transform_out.w != m_w || transform_out.h != m_h) {
- Resize(pI420[0], transform_out.w, transform_out.h, pI420[1], m_w, m_h);
- // only one of these can be true, and when it happens the result image must be in the tmp buffer
- if (transform_out.w == m_w || transform_out.h == m_h) {
- pI420[2] = pI420[1], pI420[1] = pI420[0], pI420[0] = pI420[2];
- }
- }
-
- rtStart = 10000i64*transform_out.timestamp - m_tStart;
- rtStop = rtStart + 1;
- pOut->SetTime(&rtStart, /*NULL*/&rtStop);
-
- pOut->SetDiscontinuity(pIn->IsDiscontinuity() == S_OK);
-
- CopyBuffer(pDataOut, pI420[0], m_w, m_h, m_w, MEDIASUBTYPE_I420);
-
- DbgLog((LOG_TRACE, 0, _T("V: rtStart=%I64d, rtStop=%I64d, disc=%d, sync=%d"),
- rtStart, rtStop, pOut->IsDiscontinuity() == S_OK, pOut->IsSyncPoint() == S_OK));
-
- return m_pOutput->Deliver(pOut);
+ pDataIn += offset;
+
+ if (m_fDropFrames && m_timestamp + 1 == transform_in.timestamp) {
+ m_timestamp = transform_in.timestamp;
+ return S_OK;
+ }
+
+
+ unsigned int tmp1, tmp2;
+ bool interlaced = false, tmp3, tmp4;
+ ::GetDimensions_X10(pDataIn, &tmp1, &tmp2, &interlaced, &tmp3, &tmp4);
+
+ int size = tmp1 * tmp2;
+ if (m_lastBuffSizeDim < size) {
+ _aligned_free(m_pI420);
+ _aligned_free(m_pI420Tmp);
+
+ m_lastBuffSizeDim = size;
+ ATLTRACE("resize out put buff %d" , size);
+ m_pI420 = static_cast<BYTE*>(_aligned_malloc(size * 3 / 2, 16));
+ if (m_pI420) {
+ ATLTRACE(" m_pI420.Allocated 1");
+ memset(m_pI420, 0, size);
+ ATLTRACE(" m_pI420.Allocated 2");
+ memset(m_pI420 + size, 0x80, size / 2);
+ ATLTRACE(" m_pI420.Allocated 3");
+ } else {
+ ATLTRACE(" m_pI420.Allocate fail %d" , size * 3 / 2);
+ return S_OK;
+ }
+ m_pI420Tmp = static_cast<BYTE*>(_aligned_malloc(size * 3 / 2, 16));
+ if (m_pI420Tmp) {
+ ATLTRACE(" m_pI420Tmp.Allocated 1");
+ memset(m_pI420Tmp, 0, size);
+ ATLTRACE(" m_pI420Tmp.Allocated 2");
+ memset(m_pI420Tmp + size, 0x80, size / 2);
+ ATLTRACE(" m_pI420Tmp.Allocated 3");
+ } else {
+ ATLTRACE(" m_pI420Tmp.Allocate fail %d" , size * 3 / 2);
+ return S_OK;
+ }
+ }
+
+ hr = RVTransform(pDataIn, (BYTE*)m_pI420, &transform_in, &transform_out, m_dwCookie);
+
+ m_timestamp = transform_in.timestamp;
+
+ if (FAILED(hr)) {
+ TRACE(_T("RV returned an error code!!!\n"));
+ ASSERT(!(transform_out.unk1 & 1)); // error allowed when the "render" flag is not set
+ // return hr;
+ }
+
+ if (pIn->IsPreroll() == S_OK || rtStart < 0 || !(transform_out.unk1 & 1)) {
+ return S_OK;
+ }
+
+ CComPtr<IMediaSample> pOut;
+ BYTE* pDataOut = NULL;
+ if (/*FAILED(hr = GetDeliveryBuffer(transform_out.w, transform_out.h, &pOut)) // TODO
+ && */ FAILED(hr = GetDeliveryBuffer(m_w, m_h, &pOut))
+ || FAILED(hr = pOut->GetPointer(&pDataOut))) {
+ return hr;
+ }
+
+ BYTE* pI420[3] = {m_pI420, m_pI420Tmp, NULL};
+
+ if (interlaced) {
+ int size = m_w * m_h;
+ DeinterlaceBlend(pI420[1], pI420[0], m_w, m_h, m_w, m_w);
+ DeinterlaceBlend(pI420[1] + size, pI420[0] + size, m_w / 2, m_h / 2, m_w / 2, m_w / 2);
+ DeinterlaceBlend(pI420[1] + size * 5 / 4, pI420[0] + size * 5 / 4, m_w / 2, m_h / 2, m_w / 2, m_w / 2);
+ pI420[2] = pI420[1], pI420[1] = pI420[0], pI420[0] = pI420[2];
+ }
+
+ if (transform_out.w != m_w || transform_out.h != m_h) {
+ Resize(pI420[0], transform_out.w, transform_out.h, pI420[1], m_w, m_h);
+ // only one of these can be true, and when it happens the result image must be in the tmp buffer
+ if (transform_out.w == m_w || transform_out.h == m_h) {
+ pI420[2] = pI420[1], pI420[1] = pI420[0], pI420[0] = pI420[2];
+ }
+ }
+
+ rtStart = 10000i64 * transform_out.timestamp - m_tStart;
+ rtStop = rtStart + 1;
+ pOut->SetTime(&rtStart, /*NULL*/&rtStop);
+
+ pOut->SetDiscontinuity(pIn->IsDiscontinuity() == S_OK);
+
+ CopyBuffer(pDataOut, pI420[0], m_w, m_h, m_w, MEDIASUBTYPE_I420);
+
+ DbgLog((LOG_TRACE, 0, _T("V: rtStart=%I64d, rtStop=%I64d, disc=%d, sync=%d"),
+ rtStart, rtStop, pOut->IsDiscontinuity() == S_OK, pOut->IsSyncPoint() == S_OK));
+
+ return m_pOutput->Deliver(pOut);
}
void CRealVideoDecoder::Resize(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD wo, DWORD ho)
{
- int si = wi*hi, so = wo*ho;
- ASSERT(((si*so)&3) == 0);
-
- if (wi < wo) {
- ResizeWidth(pIn, wi, hi, pOut, wo, ho);
- ResizeWidth(pIn + si, wi/2, hi/2, pOut + so, wo/2, ho/2);
- ResizeWidth(pIn + si + si/4, wi/2, hi/2, pOut + so + so/4, wo/2, ho/2);
- if (hi == ho) {
- return;
- }
- ResizeHeight(pOut, wo, hi, pIn, wo, ho);
- ResizeHeight(pOut + so, wo/2, hi/2, pIn + so, wo/2, ho/2);
- ResizeHeight(pOut + so + so/4, wo/2, hi/2, pIn + so + so/4, wo/2, ho/2);
- } else if (hi < ho) {
- ResizeHeight(pIn, wi, hi, pOut, wo, ho);
- ResizeHeight(pIn + si, wi/2, hi/2, pOut + so, wo/2, ho/2);
- ResizeHeight(pIn + si + si/4, wi/2, hi/2, pOut + so + so/4, wo/2, ho/2);
- if (wi == wo) {
- return;
- }
- ASSERT(0); // this is uncreachable code, but anyway... looks nice being so symmetric
- ResizeWidth(pOut, wi, ho, pIn, wo, ho);
- ResizeWidth(pOut + so, wi/2, ho/2, pIn + so, wo/2, ho/2);
- ResizeWidth(pOut + so + so/4, wi/2, ho/2, pIn + so + so/4, wo/2, ho/2);
- }
+ int si = wi * hi, so = wo * ho;
+ ASSERT(((si * so) & 3) == 0);
+
+ if (wi < wo) {
+ ResizeWidth(pIn, wi, hi, pOut, wo, ho);
+ ResizeWidth(pIn + si, wi / 2, hi / 2, pOut + so, wo / 2, ho / 2);
+ ResizeWidth(pIn + si + si / 4, wi / 2, hi / 2, pOut + so + so / 4, wo / 2, ho / 2);
+ if (hi == ho) {
+ return;
+ }
+ ResizeHeight(pOut, wo, hi, pIn, wo, ho);
+ ResizeHeight(pOut + so, wo / 2, hi / 2, pIn + so, wo / 2, ho / 2);
+ ResizeHeight(pOut + so + so / 4, wo / 2, hi / 2, pIn + so + so / 4, wo / 2, ho / 2);
+ } else if (hi < ho) {
+ ResizeHeight(pIn, wi, hi, pOut, wo, ho);
+ ResizeHeight(pIn + si, wi / 2, hi / 2, pOut + so, wo / 2, ho / 2);
+ ResizeHeight(pIn + si + si / 4, wi / 2, hi / 2, pOut + so + so / 4, wo / 2, ho / 2);
+ if (wi == wo) {
+ return;
+ }
+ ASSERT(0); // this is uncreachable code, but anyway... looks nice being so symmetric
+ ResizeWidth(pOut, wi, ho, pIn, wo, ho);
+ ResizeWidth(pOut + so, wi / 2, ho / 2, pIn + so, wo / 2, ho / 2);
+ ResizeWidth(pOut + so + so / 4, wi / 2, ho / 2, pIn + so + so / 4, wo / 2, ho / 2);
+ }
}
void CRealVideoDecoder::ResizeWidth(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD wo, DWORD ho)
{
- for (DWORD y = 0; y < hi; y++, pIn += wi, pOut += wo) {
- if (wi == wo) {
- memcpy(pOut, pIn, wo);
- } else {
- ResizeRow(pIn, wi, 1, pOut, wo, 1);
- }
- }
+ for (DWORD y = 0; y < hi; y++, pIn += wi, pOut += wo) {
+ if (wi == wo) {
+ memcpy(pOut, pIn, wo);
+ } else {
+ ResizeRow(pIn, wi, 1, pOut, wo, 1);
+ }
+ }
}
void CRealVideoDecoder::ResizeHeight(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD wo, DWORD ho)
{
- if (hi == ho) {
- memcpy(pOut, pIn, wo*ho);
- } else {
- for (DWORD x = 0; x < wo; x++, pIn++, pOut++) {
- ResizeRow(pIn, hi, wo, pOut, ho, wo);
- }
- }
+ if (hi == ho) {
+ memcpy(pOut, pIn, wo * ho);
+ } else {
+ for (DWORD x = 0; x < wo; x++, pIn++, pOut++) {
+ ResizeRow(pIn, hi, wo, pOut, ho, wo);
+ }
+ }
}
void CRealVideoDecoder::ResizeRow(BYTE* pIn, DWORD wi, DWORD dpi, BYTE* pOut, DWORD wo, DWORD dpo)
{
- ASSERT(wi < wo);
-
- if (dpo == 1) {
- for (DWORD i = 0, j = 0, dj = (wi<<16)/wo; i < wo-1; i++, pOut++, j += dj)
- // pOut[i] = pIn[j>>16];
- {
- BYTE* p = &pIn[j>>16];
- DWORD jf = j&0xffff;
- *pOut = ((p[0]*(0xffff-jf) + p[1]*jf) + 0x7fff) >> 16;
- }
-
- *pOut = pIn[wi-1];
- } else {
- for (DWORD i = 0, j = 0, dj = (wi<<16)/wo; i < wo-1; i++, pOut += dpo, j += dj)
- // *pOut = pIn[dpi*(j>>16)];
- {
- BYTE* p = &pIn[dpi*(j>>16)];
- DWORD jf = j&0xffff;
- *pOut = ((p[0]*(0xffff-jf) + p[dpi]*jf) + 0x7fff) >> 16;
- }
-
- *pOut = pIn[dpi*(wi-1)];
- }
+ ASSERT(wi < wo);
+
+ if (dpo == 1) {
+ for (DWORD i = 0, j = 0, dj = (wi << 16) / wo; i < wo - 1; i++, pOut++, j += dj)
+ // pOut[i] = pIn[j>>16];
+ {
+ BYTE* p = &pIn[j >> 16];
+ DWORD jf = j & 0xffff;
+ *pOut = ((p[0] * (0xffff - jf) + p[1] * jf) + 0x7fff) >> 16;
+ }
+
+ *pOut = pIn[wi - 1];
+ } else {
+ for (DWORD i = 0, j = 0, dj = (wi << 16) / wo; i < wo - 1; i++, pOut += dpo, j += dj)
+ // *pOut = pIn[dpi*(j>>16)];
+ {
+ BYTE* p = &pIn[dpi * (j >> 16)];
+ DWORD jf = j & 0xffff;
+ *pOut = ((p[0] * (0xffff - jf) + p[dpi] * jf) + 0x7fff) >> 16;
+ }
+
+ *pOut = pIn[dpi * (wi - 1)];
+ }
}
HRESULT CRealVideoDecoder::CheckInputType(const CMediaType* mtIn)
{
- if (mtIn->majortype != MEDIATYPE_Video
- || mtIn->subtype != MEDIASUBTYPE_RV20
- && mtIn->subtype != MEDIASUBTYPE_RV30
- && mtIn->subtype != MEDIASUBTYPE_RV40
- && mtIn->subtype != MEDIASUBTYPE_RV41) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- if (mtIn->formattype == FORMAT_VideoInfo2) {
- VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mtIn->Format();
- if (vih2->dwPictAspectRatioX < (DWORD)vih2->bmiHeader.biWidth
- || vih2->dwPictAspectRatioY < (DWORD)vih2->bmiHeader.biHeight) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- }
-
- if (!m_pInput->IsConnected()) {
- if (m_hDrvDll) {
- FreeLibrary(m_hDrvDll);
- m_hDrvDll = NULL;
- }
-
- CAtlList<CString> paths;
- CString olddll, newdll, oldpath, newpath;
-
- olddll.Format(_T("drv%c3260.dll"), (TCHAR)((mtIn->subtype.Data1>>16)&0xff));
- newdll =
- mtIn->subtype == FOURCCMap('14VR') ? _T("drvi.dll") :
- mtIn->subtype == FOURCCMap('02VR') ? _T("drv2.dll") :
- _T("drvc.dll");
-
- CRegKey key;
- TCHAR buff[_MAX_PATH];
- ULONG len = sizeof(buff);
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Software\\RealNetworks\\Preferences\\DT_Codecs"), KEY_READ)
- && ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && _tcslen(buff) > 0) {
- oldpath = buff;
- TCHAR c = oldpath[oldpath.GetLength()-1];
- if (c != '\\' && c != '/') {
- oldpath += '\\';
- }
- key.Close();
- }
- len = sizeof(buff);
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Helix\\HelixSDK\\10.0\\Preferences\\DT_Codecs"), KEY_READ)
- && ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && _tcslen(buff) > 0) {
- newpath = buff;
- TCHAR c = newpath[newpath.GetLength()-1];
- if (c != '\\' && c != '/') {
- newpath += '\\';
- }
- key.Close();
- }
-
- if (!newpath.IsEmpty()) {
- paths.AddTail(newpath + newdll);
- }
- if (!oldpath.IsEmpty()) {
- paths.AddTail(oldpath + newdll);
- }
- paths.AddTail(newdll); // default dll paths
- if (!newpath.IsEmpty()) {
- paths.AddTail(newpath + olddll);
- }
- if (!oldpath.IsEmpty()) {
- paths.AddTail(oldpath + olddll);
- }
- paths.AddTail(olddll); // default dll paths
-
- POSITION pos = paths.GetHeadPosition();
- do {
- if (pos) {
- m_hDrvDll = LoadLibrary(paths.GetNext(pos));
- }
- } while (pos && !m_hDrvDll);
-
- if (m_hDrvDll) {
- RVCustomMessage = (PRVCustomMessage)GetProcAddress(m_hDrvDll, "RV20toYUV420CustomMessage");
- RVFree = (PRVFree)GetProcAddress(m_hDrvDll, "RV20toYUV420Free");
- RVHiveMessage = (PRVHiveMessage)GetProcAddress(m_hDrvDll, "RV20toYUV420HiveMessage");
- RVInit = (PRVInit)GetProcAddress(m_hDrvDll, "RV20toYUV420Init");
- RVTransform = (PRVTransform)GetProcAddress(m_hDrvDll, "RV20toYUV420Transform");
-
- if (!RVCustomMessage) {
- RVCustomMessage = (PRVCustomMessage)GetProcAddress(m_hDrvDll, "RV40toYUV420CustomMessage");
- }
- if (!RVFree) {
- RVFree = (PRVFree)GetProcAddress(m_hDrvDll, "RV40toYUV420Free");
- }
- if (!RVHiveMessage) {
- RVHiveMessage = (PRVHiveMessage)GetProcAddress(m_hDrvDll, "RV40toYUV420HiveMessage");
- }
- if (!RVInit) {
- RVInit = (PRVInit)GetProcAddress(m_hDrvDll, "RV40toYUV420Init");
- }
- if (!RVTransform) {
- RVTransform = (PRVTransform)GetProcAddress(m_hDrvDll, "RV40toYUV420Transform");
- }
- }
-
- if (!m_hDrvDll || !RVCustomMessage
- || !RVFree || !RVHiveMessage
- || !RVInit || !RVTransform) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- if (FAILED(InitRV(mtIn))) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- }
-
- return S_OK;
+ if (mtIn->majortype != MEDIATYPE_Video
+ || mtIn->subtype != MEDIASUBTYPE_RV20
+ && mtIn->subtype != MEDIASUBTYPE_RV30
+ && mtIn->subtype != MEDIASUBTYPE_RV40
+ && mtIn->subtype != MEDIASUBTYPE_RV41) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+
+ if (mtIn->formattype == FORMAT_VideoInfo2) {
+ VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mtIn->Format();
+ if (vih2->dwPictAspectRatioX < (DWORD)vih2->bmiHeader.biWidth
+ || vih2->dwPictAspectRatioY < (DWORD)vih2->bmiHeader.biHeight) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+ }
+
+ if (!m_pInput->IsConnected()) {
+ if (m_hDrvDll) {
+ FreeLibrary(m_hDrvDll);
+ m_hDrvDll = NULL;
+ }
+
+ CAtlList<CString> paths;
+ CString olddll, newdll, oldpath, newpath;
+
+ olddll.Format(_T("drv%c3260.dll"), (TCHAR)((mtIn->subtype.Data1 >> 16) & 0xff));
+ newdll =
+ mtIn->subtype == FOURCCMap('14VR') ? _T("drvi.dll") :
+ mtIn->subtype == FOURCCMap('02VR') ? _T("drv2.dll") :
+ _T("drvc.dll");
+
+ CRegKey key;
+ TCHAR buff[_MAX_PATH];
+ ULONG len = sizeof(buff);
+ if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Software\\RealNetworks\\Preferences\\DT_Codecs"), KEY_READ)
+ && ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && _tcslen(buff) > 0) {
+ oldpath = buff;
+ TCHAR c = oldpath[oldpath.GetLength() - 1];
+ if (c != '\\' && c != '/') {
+ oldpath += '\\';
+ }
+ key.Close();
+ }
+ len = sizeof(buff);
+ if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Helix\\HelixSDK\\10.0\\Preferences\\DT_Codecs"), KEY_READ)
+ && ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && _tcslen(buff) > 0) {
+ newpath = buff;
+ TCHAR c = newpath[newpath.GetLength() - 1];
+ if (c != '\\' && c != '/') {
+ newpath += '\\';
+ }
+ key.Close();
+ }
+
+ if (!newpath.IsEmpty()) {
+ paths.AddTail(newpath + newdll);
+ }
+ if (!oldpath.IsEmpty()) {
+ paths.AddTail(oldpath + newdll);
+ }
+ paths.AddTail(newdll); // default dll paths
+ if (!newpath.IsEmpty()) {
+ paths.AddTail(newpath + olddll);
+ }
+ if (!oldpath.IsEmpty()) {
+ paths.AddTail(oldpath + olddll);
+ }
+ paths.AddTail(olddll); // default dll paths
+
+ POSITION pos = paths.GetHeadPosition();
+ do {
+ if (pos) {
+ m_hDrvDll = LoadLibrary(paths.GetNext(pos));
+ }
+ } while (pos && !m_hDrvDll);
+
+ if (m_hDrvDll) {
+ RVCustomMessage = (PRVCustomMessage)GetProcAddress(m_hDrvDll, "RV20toYUV420CustomMessage");
+ RVFree = (PRVFree)GetProcAddress(m_hDrvDll, "RV20toYUV420Free");
+ RVHiveMessage = (PRVHiveMessage)GetProcAddress(m_hDrvDll, "RV20toYUV420HiveMessage");
+ RVInit = (PRVInit)GetProcAddress(m_hDrvDll, "RV20toYUV420Init");
+ RVTransform = (PRVTransform)GetProcAddress(m_hDrvDll, "RV20toYUV420Transform");
+
+ if (!RVCustomMessage) {
+ RVCustomMessage = (PRVCustomMessage)GetProcAddress(m_hDrvDll, "RV40toYUV420CustomMessage");
+ }
+ if (!RVFree) {
+ RVFree = (PRVFree)GetProcAddress(m_hDrvDll, "RV40toYUV420Free");
+ }
+ if (!RVHiveMessage) {
+ RVHiveMessage = (PRVHiveMessage)GetProcAddress(m_hDrvDll, "RV40toYUV420HiveMessage");
+ }
+ if (!RVInit) {
+ RVInit = (PRVInit)GetProcAddress(m_hDrvDll, "RV40toYUV420Init");
+ }
+ if (!RVTransform) {
+ RVTransform = (PRVTransform)GetProcAddress(m_hDrvDll, "RV40toYUV420Transform");
+ }
+ }
+
+ if (!m_hDrvDll || !RVCustomMessage
+ || !RVFree || !RVHiveMessage
+ || !RVInit || !RVTransform) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+
+ if (FAILED(InitRV(mtIn))) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+ }
+
+ return S_OK;
}
HRESULT CRealVideoDecoder::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
{
- if (m_pOutput && m_pOutput->IsConnected()) {
- BITMAPINFOHEADER bih1, bih2;
- if (ExtractBIH(mtOut, &bih1) && ExtractBIH(&m_pOutput->CurrentMediaType(), &bih2)
- && abs(bih1.biHeight) != abs(bih2.biHeight)) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- }
-
- return __super::CheckTransform(mtIn, mtOut);
+ if (m_pOutput && m_pOutput->IsConnected()) {
+ BITMAPINFOHEADER bih1, bih2;
+ if (ExtractBIH(mtOut, &bih1) && ExtractBIH(&m_pOutput->CurrentMediaType(), &bih2)
+ && abs(bih1.biHeight) != abs(bih2.biHeight)) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+ }
+
+ return __super::CheckTransform(mtIn, mtOut);
}
HRESULT CRealVideoDecoder::StartStreaming()
{
- const CMediaType& mt = m_pInput->CurrentMediaType();
- if (FAILED(InitRV(&mt))) {
- return E_FAIL;
- }
-
- int size = m_w*m_h;
- m_lastBuffSizeDim = size;
- m_pI420 = static_cast<BYTE*>(_aligned_malloc(size*3/2, 16));
- memset(m_pI420, 0, size);
- memset(m_pI420 + size, 0x80, size/2);
- m_pI420Tmp = static_cast<BYTE*>(_aligned_malloc(size*3/2, 16));
- memset(m_pI420Tmp, 0, size);
- memset(m_pI420Tmp + size, 0x80, size/2);
-
- return __super::StartStreaming();
+ const CMediaType& mt = m_pInput->CurrentMediaType();
+ if (FAILED(InitRV(&mt))) {
+ return E_FAIL;
+ }
+
+ int size = m_w * m_h;
+ m_lastBuffSizeDim = size;
+ m_pI420 = static_cast<BYTE*>(_aligned_malloc(size * 3 / 2, 16));
+ memset(m_pI420, 0, size);
+ memset(m_pI420 + size, 0x80, size / 2);
+ m_pI420Tmp = static_cast<BYTE*>(_aligned_malloc(size * 3 / 2, 16));
+ memset(m_pI420Tmp, 0, size);
+ memset(m_pI420Tmp + size, 0x80, size / 2);
+
+ return __super::StartStreaming();
}
HRESULT CRealVideoDecoder::StopStreaming()
{
- _aligned_free(m_pI420);
- _aligned_free(m_pI420Tmp);
+ _aligned_free(m_pI420);
+ _aligned_free(m_pI420Tmp);
- FreeRV();
+ FreeRV();
- return __super::StopStreaming();
+ return __super::StopStreaming();
}
HRESULT CRealVideoDecoder::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- CAutoLock cAutoLock(&m_csReceive);
+ CAutoLock cAutoLock(&m_csReceive);
- m_timestamp = (DWORD)~0;
- m_fDropFrames = false;
+ m_timestamp = (DWORD)~0;
+ m_fDropFrames = false;
- DWORD tmp[2] = {20, 0};
- RVHiveMessage(tmp, m_dwCookie);
+ DWORD tmp[2] = {20, 0};
+ RVHiveMessage(tmp, m_dwCookie);
- m_tStart = tStart;
- return __super::NewSegment(tStart, tStop, dRate);
+ m_tStart = tStart;
+ return __super::NewSegment(tStart, tStop, dRate);
}
HRESULT CRealVideoDecoder::AlterQuality(Quality q)
{
- if (q.Late > 500*10000i64) {
- m_fDropFrames = true;
- }
- if (q.Late <= 0) {
- m_fDropFrames = false;
- }
- // TRACE(_T("CRealVideoDecoder::AlterQuality: Type=%d, Proportion=%d, Late=%I64d, TimeStamp=%I64d\n"), q.Type, q.Proportion, q.Late, q.TimeStamp);
- return E_NOTIMPL;
+ if (q.Late > 500 * 10000i64) {
+ m_fDropFrames = true;
+ }
+ if (q.Late <= 0) {
+ m_fDropFrames = false;
+ }
+ // TRACE(_T("CRealVideoDecoder::AlterQuality: Type=%d, Proportion=%d, Late=%I64d, TimeStamp=%I64d\n"), q.Type, q.Proportion, q.Late, q.TimeStamp);
+ return E_NOTIMPL;
}
/////////////////////////
@@ -2087,569 +2087,569 @@ HRESULT CRealVideoDecoder::AlterQuality(Quality q)
//
CRealAudioDecoder::CRealAudioDecoder(LPUNKNOWN lpunk, HRESULT* phr)
- : CTransformFilter(NAME("CRealAudioDecoder"), lpunk, __uuidof(this))
- , m_hDrvDll(NULL)
- , m_dwCookie(0)
+ : CTransformFilter(NAME("CRealAudioDecoder"), lpunk, __uuidof(this))
+ , m_hDrvDll(NULL)
+ , m_dwCookie(0)
{
- if (phr) {
- *phr = S_OK;
- }
+ if (phr) {
+ *phr = S_OK;
+ }
}
CRealAudioDecoder::~CRealAudioDecoder()
{
- // FreeRA();
- if (m_hDrvDll) {
- FreeLibrary(m_hDrvDll);
- }
+ // FreeRA();
+ if (m_hDrvDll) {
+ FreeLibrary(m_hDrvDll);
+ }
}
HRESULT CRealAudioDecoder::InitRA(const CMediaType* pmt)
{
- FreeRA();
+ FreeRA();
- HRESULT hr;
+ HRESULT hr;
- if (RAOpenCodec2 && FAILED(hr = RAOpenCodec2(&m_dwCookie, m_dllpath))
- || RAOpenCodec && FAILED(hr = RAOpenCodec(&m_dwCookie))) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
+ if (RAOpenCodec2 && FAILED(hr = RAOpenCodec2(&m_dwCookie, m_dllpath))
+ || RAOpenCodec && FAILED(hr = RAOpenCodec(&m_dwCookie))) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
- WAVEFORMATEX* pwfe = (WAVEFORMATEX*)pmt->Format();
+ WAVEFORMATEX* pwfe = (WAVEFORMATEX*)pmt->Format();
- // someone might be doing cbSize = sizeof(WAVEFORMATEX), chances of
- // cbSize being really sizeof(WAVEFORMATEX) is less than this,
- // especially with our rm splitter ;)
- DWORD cbSize = pwfe->cbSize;
- if (cbSize == sizeof(WAVEFORMATEX)) {
- ASSERT(0);
- cbSize = 0;
- }
+ // someone might be doing cbSize = sizeof(WAVEFORMATEX), chances of
+ // cbSize being really sizeof(WAVEFORMATEX) is less than this,
+ // especially with our rm splitter ;)
+ DWORD cbSize = pwfe->cbSize;
+ if (cbSize == sizeof(WAVEFORMATEX)) {
+ ASSERT(0);
+ cbSize = 0;
+ }
- WORD wBitsPerSample = pwfe->wBitsPerSample;
- if (!wBitsPerSample) {
- wBitsPerSample = 16;
- }
+ WORD wBitsPerSample = pwfe->wBitsPerSample;
+ if (!wBitsPerSample) {
+ wBitsPerSample = 16;
+ }
#pragma pack(push, 1)
- struct {
- DWORD freq;
- WORD bpsample, channels, quality;
- DWORD bpframe, packetsize, extralen;
- void* extra;
- } initdata = {
- pwfe->nSamplesPerSec, wBitsPerSample, pwfe->nChannels, 100,
- 0, 0, 0, NULL
- };
+ struct {
+ DWORD freq;
+ WORD bpsample, channels, quality;
+ DWORD bpframe, packetsize, extralen;
+ void* extra;
+ } initdata = {
+ pwfe->nSamplesPerSec, wBitsPerSample, pwfe->nChannels, 100,
+ 0, 0, 0, NULL
+ };
#pragma pack(pop)
- CAutoVectorPtr<BYTE> pBuff;
-
- if (pmt->subtype == MEDIASUBTYPE_AAC) {
- pBuff.Allocate(cbSize+1);
- pBuff[0] = 0x02;
- memcpy(pBuff+1, pwfe+1, cbSize);
- initdata.extralen = cbSize+1;
- initdata.extra = pBuff;
- } else {
- if (pmt->FormatLength() <= sizeof(WAVEFORMATEX) + cbSize) { // must have type_specific_data appended
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- BYTE* fmt = pmt->Format() + sizeof(WAVEFORMATEX) + cbSize;
-
- for (int i = 0, len = pmt->FormatLength() - (sizeof(WAVEFORMATEX) + cbSize); i < len-4; i++, fmt++) {
- if (fmt[0] == '.' || fmt[1] == 'r' || fmt[2] == 'a') {
- break;
- }
- }
-
- m_rai = *(rainfo*)fmt;
- m_rai.bswap();
-
- BYTE* p;
-
- if (m_rai.version2 == 4) {
- p = (BYTE*)((rainfo4*)fmt+1);
- int len = *p++;
- p += len;
- len = *p++;
- p += len;
- ASSERT(len == 4);
- } else if (m_rai.version2 == 5) {
- p = (BYTE*)((rainfo5*)fmt+1);
- } else {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- p += 3;
- if (m_rai.version2 == 5) {
- p++;
- }
-
- initdata.bpframe = m_rai.sub_packet_size;
- initdata.packetsize = m_rai.coded_frame_size;
- initdata.extralen = min((pmt->Format() + pmt->FormatLength()) - (p + 4), (LONG)*(DWORD*)p);
- initdata.extra = p + 4;
- }
-
- if (FAILED(hr = RAInitDecoder(m_dwCookie, &initdata))) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- if (RASetPwd) {
- RASetPwd(m_dwCookie, "Ardubancel Quazanga");
- }
-
- if (RASetFlavor && FAILED(hr = RASetFlavor(m_dwCookie, m_rai.flavor))) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- return S_OK;
+ CAutoVectorPtr<BYTE> pBuff;
+
+ if (pmt->subtype == MEDIASUBTYPE_AAC) {
+ pBuff.Allocate(cbSize + 1);
+ pBuff[0] = 0x02;
+ memcpy(pBuff + 1, pwfe + 1, cbSize);
+ initdata.extralen = cbSize + 1;
+ initdata.extra = pBuff;
+ } else {
+ if (pmt->FormatLength() <= sizeof(WAVEFORMATEX) + cbSize) { // must have type_specific_data appended
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+
+ BYTE* fmt = pmt->Format() + sizeof(WAVEFORMATEX) + cbSize;
+
+ for (int i = 0, len = pmt->FormatLength() - (sizeof(WAVEFORMATEX) + cbSize); i < len - 4; i++, fmt++) {
+ if (fmt[0] == '.' || fmt[1] == 'r' || fmt[2] == 'a') {
+ break;
+ }
+ }
+
+ m_rai = *(rainfo*)fmt;
+ m_rai.bswap();
+
+ BYTE* p;
+
+ if (m_rai.version2 == 4) {
+ p = (BYTE*)((rainfo4*)fmt + 1);
+ int len = *p++;
+ p += len;
+ len = *p++;
+ p += len;
+ ASSERT(len == 4);
+ } else if (m_rai.version2 == 5) {
+ p = (BYTE*)((rainfo5*)fmt + 1);
+ } else {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+
+ p += 3;
+ if (m_rai.version2 == 5) {
+ p++;
+ }
+
+ initdata.bpframe = m_rai.sub_packet_size;
+ initdata.packetsize = m_rai.coded_frame_size;
+ initdata.extralen = min((pmt->Format() + pmt->FormatLength()) - (p + 4), (LONG) * (DWORD*)p);
+ initdata.extra = p + 4;
+ }
+
+ if (FAILED(hr = RAInitDecoder(m_dwCookie, &initdata))) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+
+ if (RASetPwd) {
+ RASetPwd(m_dwCookie, "Ardubancel Quazanga");
+ }
+
+ if (RASetFlavor && FAILED(hr = RASetFlavor(m_dwCookie, m_rai.flavor))) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+
+ return S_OK;
}
void CRealAudioDecoder::FreeRA()
{
- if (m_dwCookie) {
- RAFreeDecoder(m_dwCookie);
- RACloseCodec(m_dwCookie);
- m_dwCookie = 0;
- }
+ if (m_dwCookie) {
+ RAFreeDecoder(m_dwCookie);
+ RACloseCodec(m_dwCookie);
+ m_dwCookie = 0;
+ }
}
HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn)
{
- CAutoLock cAutoLock(&m_csReceive);
-
- HRESULT hr;
-
- AM_SAMPLE2_PROPERTIES* const pProps = m_pInput->SampleProps();
- if (pProps->dwStreamId != AM_STREAM_MEDIA) {
- return m_pOutput->Deliver(pIn);
- }
-
- BYTE* pDataIn = NULL;
- if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
- return hr;
- }
- BYTE* pDataInOrg = pDataIn;
- UNREFERENCED_PARAMETER(pDataInOrg);
-
- long len = pIn->GetActualDataLength();
- if (len <= 0) {
- return S_OK;
- }
-
- REFERENCE_TIME rtStart, rtStop;
- pIn->GetTime(&rtStart, &rtStop);
- /*
- if (pIn->IsPreroll() == S_OK || rtStart < 0)
- return S_OK;
- */
-
- if (S_OK == pIn->IsSyncPoint()) {
- m_bufflen = 0;
- m_rtBuffStart = rtStart;
- m_fBuffDiscontinuity = pIn->IsDiscontinuity() == S_OK;
- }
-
- BYTE* src = NULL;
- BYTE* dst = NULL;
-
- int w = m_rai.coded_frame_size;
- int h = m_rai.sub_packet_h;
- int sps = m_rai.sub_packet_size;
-
- if (m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_RAAC
- || m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_RACP
- || m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_AAC) {
- src = pDataIn;
- dst = pDataIn + len;
- w = len;
- } else {
- memcpy(&m_buff[m_bufflen], pDataIn, len);
- m_bufflen += len;
-
- len = w*h;
-
- if (m_bufflen >= len) {
- ASSERT(m_bufflen == len);
-
- src = m_buff;
- dst = m_buff + len;
-
- if (sps > 0
- && (m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_COOK
- || m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_ATRC)) {
- for (int y = 0; y < h; y++) {
- for (int x = 0, w2 = w / sps; x < w2; x++) {
- // TRACE(_T("--- %d, %d\n"), (h*x+((h+1)/2)*(y&1)+(y>>1)), sps*(h*x+((h+1)/2)*(y&1)+(y>>1)));
- memcpy(dst + sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), src, sps);
- src += sps;
- }
- }
-
- src = m_buff + len;
- dst = m_buff + len*2;
- } else if (m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_SIPR) {
- // http://mplayerhq.hu/pipermail/mplayer-dev-eng/2002-August/010569.html
-
- static BYTE sipr_swaps[38][2]= {
- {0,63},{1,22},{2,44},{3,90},{5,81},{7,31},{8,86},{9,58},{10,36},{12,68},
- {13,39},{14,73},{15,53},{16,69},{17,57},{19,88},{20,34},{21,71},{24,46},
- {25,94},{26,54},{28,75},{29,50},{32,70},{33,92},{35,74},{38,85},{40,56},
- {42,87},{43,65},{45,59},{48,79},{49,93},{51,89},{55,95},{61,76},{67,83},
- {77,80}
- };
-
- int bs=h*w*2/96; // nibbles per subpacket
- for (int n=0; n<38; n++) {
- int i=bs*sipr_swaps[n][0];
- int o=bs*sipr_swaps[n][1];
- // swap nibbles of block 'i' with 'o' TODO: optimize
- for (int j=0; j<bs; j++) {
- int x=(i&1) ? (src[(i>>1)]>>4) : (src[(i>>1)]&15);
- int y=(o&1) ? (src[(o>>1)]>>4) : (src[(o>>1)]&15);
- if (o&1) {
- src[(o>>1)]=(src[(o>>1)]&0x0F)|(x<<4);
- } else {
- src[(o>>1)]=(src[(o>>1)]&0xF0)|x;
- }
- if (i&1) {
- src[(i>>1)]=(src[(i>>1)]&0x0F)|(y<<4);
- } else {
- src[(i>>1)]=(src[(i>>1)]&0xF0)|y;
- }
- ++i;
- ++o;
- }
- }
- }
-
- m_bufflen = 0;
- }
- }
-
- rtStart = m_rtBuffStart;
-
- for (; src < dst; src += w) {
- CComPtr<IMediaSample> pOut;
- BYTE* pDataOut = NULL;
- if (FAILED(hr = m_pOutput->GetDeliveryBuffer(&pOut, NULL, NULL, 0))
- || FAILED(hr = pOut->GetPointer(&pDataOut))) {
- return hr;
- }
-
- AM_MEDIA_TYPE* pmt;
- if (SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt) {
- CMediaType mt(*pmt);
- m_pOutput->SetMediaType(&mt);
- DeleteMediaType(pmt);
- }
-
- hr = RADecode(m_dwCookie, src, w, pDataOut, &len, -1);
-
- if (FAILED(hr)) {
- TRACE(_T("RA returned an error code!!!\n"));
- continue;
- // return hr;
- }
-
- WAVEFORMATEX* pwfe = (WAVEFORMATEX*)m_pOutput->CurrentMediaType().Format();
-
- rtStop = rtStart + 1000i64*len/pwfe->nAvgBytesPerSec*10000;
- pOut->SetTime(&rtStart, &rtStop);
- pOut->SetMediaTime(NULL, NULL);
-
- pOut->SetDiscontinuity(m_fBuffDiscontinuity);
- m_fBuffDiscontinuity = false;
- pOut->SetSyncPoint(TRUE);
-
- pOut->SetActualDataLength(len);
-
- DbgLog((LOG_TRACE, 0, _T("A: rtStart=%I64d, rtStop=%I64d, disc=%d, sync=%d"),
- rtStart, rtStop, pOut->IsDiscontinuity() == S_OK, pOut->IsSyncPoint() == S_OK));
-
- if (rtStart >= 0 && S_OK != (hr = m_pOutput->Deliver(pOut))) {
- return hr;
- }
-
- rtStart = rtStop;
- }
-
- m_rtBuffStart = rtStart;
-
- return S_OK;
+ CAutoLock cAutoLock(&m_csReceive);
+
+ HRESULT hr;
+
+ AM_SAMPLE2_PROPERTIES* const pProps = m_pInput->SampleProps();
+ if (pProps->dwStreamId != AM_STREAM_MEDIA) {
+ return m_pOutput->Deliver(pIn);
+ }
+
+ BYTE* pDataIn = NULL;
+ if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
+ return hr;
+ }
+ BYTE* pDataInOrg = pDataIn;
+ UNREFERENCED_PARAMETER(pDataInOrg);
+
+ long len = pIn->GetActualDataLength();
+ if (len <= 0) {
+ return S_OK;
+ }
+
+ REFERENCE_TIME rtStart, rtStop;
+ pIn->GetTime(&rtStart, &rtStop);
+ /*
+ if (pIn->IsPreroll() == S_OK || rtStart < 0)
+ return S_OK;
+ */
+
+ if (S_OK == pIn->IsSyncPoint()) {
+ m_bufflen = 0;
+ m_rtBuffStart = rtStart;
+ m_fBuffDiscontinuity = pIn->IsDiscontinuity() == S_OK;
+ }
+
+ BYTE* src = NULL;
+ BYTE* dst = NULL;
+
+ int w = m_rai.coded_frame_size;
+ int h = m_rai.sub_packet_h;
+ int sps = m_rai.sub_packet_size;
+
+ if (m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_RAAC
+ || m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_RACP
+ || m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_AAC) {
+ src = pDataIn;
+ dst = pDataIn + len;
+ w = len;
+ } else {
+ memcpy(&m_buff[m_bufflen], pDataIn, len);
+ m_bufflen += len;
+
+ len = w * h;
+
+ if (m_bufflen >= len) {
+ ASSERT(m_bufflen == len);
+
+ src = m_buff;
+ dst = m_buff + len;
+
+ if (sps > 0
+ && (m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_COOK
+ || m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_ATRC)) {
+ for (int y = 0; y < h; y++) {
+ for (int x = 0, w2 = w / sps; x < w2; x++) {
+ // TRACE(_T("--- %d, %d\n"), (h*x+((h+1)/2)*(y&1)+(y>>1)), sps*(h*x+((h+1)/2)*(y&1)+(y>>1)));
+ memcpy(dst + sps * (h * x + ((h + 1) / 2) * (y & 1) + (y >> 1)), src, sps);
+ src += sps;
+ }
+ }
+
+ src = m_buff + len;
+ dst = m_buff + len * 2;
+ } else if (m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_SIPR) {
+ // http://mplayerhq.hu/pipermail/mplayer-dev-eng/2002-August/010569.html
+
+ static BYTE sipr_swaps[38][2] = {
+ {0, 63}, {1, 22}, {2, 44}, {3, 90}, {5, 81}, {7, 31}, {8, 86}, {9, 58}, {10, 36}, {12, 68},
+ {13, 39}, {14, 73}, {15, 53}, {16, 69}, {17, 57}, {19, 88}, {20, 34}, {21, 71}, {24, 46},
+ {25, 94}, {26, 54}, {28, 75}, {29, 50}, {32, 70}, {33, 92}, {35, 74}, {38, 85}, {40, 56},
+ {42, 87}, {43, 65}, {45, 59}, {48, 79}, {49, 93}, {51, 89}, {55, 95}, {61, 76}, {67, 83},
+ {77, 80}
+ };
+
+ int bs = h * w * 2 / 96; // nibbles per subpacket
+ for (int n = 0; n < 38; n++) {
+ int i = bs * sipr_swaps[n][0];
+ int o = bs * sipr_swaps[n][1];
+ // swap nibbles of block 'i' with 'o' TODO: optimize
+ for (int j = 0; j < bs; j++) {
+ int x = (i & 1) ? (src[(i >> 1)] >> 4) : (src[(i >> 1)] & 15);
+ int y = (o & 1) ? (src[(o >> 1)] >> 4) : (src[(o >> 1)] & 15);
+ if (o & 1) {
+ src[(o >> 1)] = (src[(o >> 1)] & 0x0F) | (x << 4);
+ } else {
+ src[(o >> 1)] = (src[(o >> 1)] & 0xF0) | x;
+ }
+ if (i & 1) {
+ src[(i >> 1)] = (src[(i >> 1)] & 0x0F) | (y << 4);
+ } else {
+ src[(i >> 1)] = (src[(i >> 1)] & 0xF0) | y;
+ }
+ ++i;
+ ++o;
+ }
+ }
+ }
+
+ m_bufflen = 0;
+ }
+ }
+
+ rtStart = m_rtBuffStart;
+
+ for (; src < dst; src += w) {
+ CComPtr<IMediaSample> pOut;
+ BYTE* pDataOut = NULL;
+ if (FAILED(hr = m_pOutput->GetDeliveryBuffer(&pOut, NULL, NULL, 0))
+ || FAILED(hr = pOut->GetPointer(&pDataOut))) {
+ return hr;
+ }
+
+ AM_MEDIA_TYPE* pmt;
+ if (SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt) {
+ CMediaType mt(*pmt);
+ m_pOutput->SetMediaType(&mt);
+ DeleteMediaType(pmt);
+ }
+
+ hr = RADecode(m_dwCookie, src, w, pDataOut, &len, -1);
+
+ if (FAILED(hr)) {
+ TRACE(_T("RA returned an error code!!!\n"));
+ continue;
+ // return hr;
+ }
+
+ WAVEFORMATEX* pwfe = (WAVEFORMATEX*)m_pOutput->CurrentMediaType().Format();
+
+ rtStop = rtStart + 1000i64 * len / pwfe->nAvgBytesPerSec * 10000;
+ pOut->SetTime(&rtStart, &rtStop);
+ pOut->SetMediaTime(NULL, NULL);
+
+ pOut->SetDiscontinuity(m_fBuffDiscontinuity);
+ m_fBuffDiscontinuity = false;
+ pOut->SetSyncPoint(TRUE);
+
+ pOut->SetActualDataLength(len);
+
+ DbgLog((LOG_TRACE, 0, _T("A: rtStart=%I64d, rtStop=%I64d, disc=%d, sync=%d"),
+ rtStart, rtStop, pOut->IsDiscontinuity() == S_OK, pOut->IsSyncPoint() == S_OK));
+
+ if (rtStart >= 0 && S_OK != (hr = m_pOutput->Deliver(pOut))) {
+ return hr;
+ }
+
+ rtStart = rtStop;
+ }
+
+ m_rtBuffStart = rtStart;
+
+ return S_OK;
}
HRESULT CRealAudioDecoder::CheckInputType(const CMediaType* mtIn)
{
- if (mtIn->majortype != MEDIATYPE_Audio
- || mtIn->subtype != MEDIASUBTYPE_14_4
- && mtIn->subtype != MEDIASUBTYPE_28_8
- && mtIn->subtype != MEDIASUBTYPE_ATRC
- && mtIn->subtype != MEDIASUBTYPE_COOK
- && mtIn->subtype != MEDIASUBTYPE_DNET
- && mtIn->subtype != MEDIASUBTYPE_SIPR
- && mtIn->subtype != MEDIASUBTYPE_RAAC
- && mtIn->subtype != MEDIASUBTYPE_RACP
- && mtIn->subtype != MEDIASUBTYPE_AAC) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- if (!m_pInput->IsConnected()) {
- if (m_hDrvDll) {
- FreeLibrary(m_hDrvDll);
- m_hDrvDll = NULL;
- }
-
- CAtlList<CString> paths;
- CString olddll, newdll, oldpath, newpath;
-
- TCHAR fourcc[5] = {
- (TCHAR)((mtIn->subtype.Data1>>0)&0xff),
- (TCHAR)((mtIn->subtype.Data1>>8)&0xff),
- (TCHAR)((mtIn->subtype.Data1>>16)&0xff),
- (TCHAR)((mtIn->subtype.Data1>>24)&0xff),
- 0
- };
-
- if (!_tcscmp(_T("RACP"), fourcc) || !_tcscmp(_T("\xff"), fourcc)) {
- _tcscpy_s(fourcc, _T("RAAC"));
- }
-
- olddll.Format(_T("%s3260.dll"), fourcc);
- newdll.Format(_T("%s.dll"), fourcc);
-
- CRegKey key;
- TCHAR buff[_MAX_PATH];
- ULONG len = _countof(buff);
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Software\\RealNetworks\\Preferences\\DT_Codecs"), KEY_READ)
- && ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && _tcslen(buff) > 0) {
- oldpath = buff;
- TCHAR c = oldpath[oldpath.GetLength()-1];
- if (c != '\\' && c != '/') {
- oldpath += '\\';
- }
- key.Close();
- }
- len = _countof(buff);
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Helix\\HelixSDK\\10.0\\Preferences\\DT_Codecs"), KEY_READ)
- && ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && _tcslen(buff) > 0) {
- newpath = buff;
- TCHAR c = newpath[newpath.GetLength()-1];
- if (c != '\\' && c != '/') {
- newpath += '\\';
- }
- key.Close();
- }
-
- if (!newpath.IsEmpty()) {
- paths.AddTail(newpath + newdll);
- }
- if (!oldpath.IsEmpty()) {
- paths.AddTail(oldpath + newdll);
- }
- paths.AddTail(newdll); // default dll paths
- if (!newpath.IsEmpty()) {
- paths.AddTail(newpath + olddll);
- }
- if (!oldpath.IsEmpty()) {
- paths.AddTail(oldpath + olddll);
- }
- paths.AddTail(olddll); // default dll paths
-
- POSITION pos = paths.GetHeadPosition();
- do {
- if (pos) {
- m_hDrvDll = LoadLibrary(paths.GetNext(pos));
- }
- } while (pos && !m_hDrvDll);
-
- if (m_hDrvDll) {
- RACloseCodec = (PCloseCodec)GetProcAddress(m_hDrvDll, "RACloseCodec");
- RADecode = (PDecode)GetProcAddress(m_hDrvDll, "RADecode");
- RAFlush = (PFlush)GetProcAddress(m_hDrvDll, "RAFlush");
- RAFreeDecoder = (PFreeDecoder)GetProcAddress(m_hDrvDll, "RAFreeDecoder");
- RAGetFlavorProperty = (PGetFlavorProperty)GetProcAddress(m_hDrvDll, "RAGetFlavorProperty");
- RAInitDecoder = (PInitDecoder)GetProcAddress(m_hDrvDll, "RAInitDecoder");
- RAOpenCodec = (POpenCodec)GetProcAddress(m_hDrvDll, "RAOpenCodec");
- RAOpenCodec2 = (POpenCodec2)GetProcAddress(m_hDrvDll, "RAOpenCodec2");
- RASetFlavor = (PSetFlavor)GetProcAddress(m_hDrvDll, "RASetFlavor");
- RASetDLLAccessPath = (PSetDLLAccessPath)GetProcAddress(m_hDrvDll, "RASetDLLAccessPath");
- RASetPwd = (PSetPwd)GetProcAddress(m_hDrvDll, "RASetPwd");
- }
-
- if (!m_hDrvDll || !RACloseCodec || !RADecode /*|| !RAFlush*/
- || !RAFreeDecoder || !RAGetFlavorProperty || !RAInitDecoder
- || !(RAOpenCodec || RAOpenCodec2) /*|| !RASetFlavor*/) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- if (m_hDrvDll) {
- char buff[_MAX_PATH];
- GetModuleFileNameA(m_hDrvDll, buff, _MAX_PATH);
- CPathA p(buff);
- p.RemoveFileSpec();
- p.AddBackslash();
- m_dllpath = p.m_strPath;
- if (RASetDLLAccessPath) {
- RASetDLLAccessPath("DT_Codecs=" + m_dllpath);
- }
- }
-
- if (FAILED(InitRA(mtIn))) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- }
-
- return S_OK;
+ if (mtIn->majortype != MEDIATYPE_Audio
+ || mtIn->subtype != MEDIASUBTYPE_14_4
+ && mtIn->subtype != MEDIASUBTYPE_28_8
+ && mtIn->subtype != MEDIASUBTYPE_ATRC
+ && mtIn->subtype != MEDIASUBTYPE_COOK
+ && mtIn->subtype != MEDIASUBTYPE_DNET
+ && mtIn->subtype != MEDIASUBTYPE_SIPR
+ && mtIn->subtype != MEDIASUBTYPE_RAAC
+ && mtIn->subtype != MEDIASUBTYPE_RACP
+ && mtIn->subtype != MEDIASUBTYPE_AAC) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+
+ if (!m_pInput->IsConnected()) {
+ if (m_hDrvDll) {
+ FreeLibrary(m_hDrvDll);
+ m_hDrvDll = NULL;
+ }
+
+ CAtlList<CString> paths;
+ CString olddll, newdll, oldpath, newpath;
+
+ TCHAR fourcc[5] = {
+ (TCHAR)((mtIn->subtype.Data1 >> 0) & 0xff),
+ (TCHAR)((mtIn->subtype.Data1 >> 8) & 0xff),
+ (TCHAR)((mtIn->subtype.Data1 >> 16) & 0xff),
+ (TCHAR)((mtIn->subtype.Data1 >> 24) & 0xff),
+ 0
+ };
+
+ if (!_tcscmp(_T("RACP"), fourcc) || !_tcscmp(_T("\xff"), fourcc)) {
+ _tcscpy_s(fourcc, _T("RAAC"));
+ }
+
+ olddll.Format(_T("%s3260.dll"), fourcc);
+ newdll.Format(_T("%s.dll"), fourcc);
+
+ CRegKey key;
+ TCHAR buff[_MAX_PATH];
+ ULONG len = _countof(buff);
+ if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Software\\RealNetworks\\Preferences\\DT_Codecs"), KEY_READ)
+ && ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && _tcslen(buff) > 0) {
+ oldpath = buff;
+ TCHAR c = oldpath[oldpath.GetLength() - 1];
+ if (c != '\\' && c != '/') {
+ oldpath += '\\';
+ }
+ key.Close();
+ }
+ len = _countof(buff);
+ if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Helix\\HelixSDK\\10.0\\Preferences\\DT_Codecs"), KEY_READ)
+ && ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && _tcslen(buff) > 0) {
+ newpath = buff;
+ TCHAR c = newpath[newpath.GetLength() - 1];
+ if (c != '\\' && c != '/') {
+ newpath += '\\';
+ }
+ key.Close();
+ }
+
+ if (!newpath.IsEmpty()) {
+ paths.AddTail(newpath + newdll);
+ }
+ if (!oldpath.IsEmpty()) {
+ paths.AddTail(oldpath + newdll);
+ }
+ paths.AddTail(newdll); // default dll paths
+ if (!newpath.IsEmpty()) {
+ paths.AddTail(newpath + olddll);
+ }
+ if (!oldpath.IsEmpty()) {
+ paths.AddTail(oldpath + olddll);
+ }
+ paths.AddTail(olddll); // default dll paths
+
+ POSITION pos = paths.GetHeadPosition();
+ do {
+ if (pos) {
+ m_hDrvDll = LoadLibrary(paths.GetNext(pos));
+ }
+ } while (pos && !m_hDrvDll);
+
+ if (m_hDrvDll) {
+ RACloseCodec = (PCloseCodec)GetProcAddress(m_hDrvDll, "RACloseCodec");
+ RADecode = (PDecode)GetProcAddress(m_hDrvDll, "RADecode");
+ RAFlush = (PFlush)GetProcAddress(m_hDrvDll, "RAFlush");
+ RAFreeDecoder = (PFreeDecoder)GetProcAddress(m_hDrvDll, "RAFreeDecoder");
+ RAGetFlavorProperty = (PGetFlavorProperty)GetProcAddress(m_hDrvDll, "RAGetFlavorProperty");
+ RAInitDecoder = (PInitDecoder)GetProcAddress(m_hDrvDll, "RAInitDecoder");
+ RAOpenCodec = (POpenCodec)GetProcAddress(m_hDrvDll, "RAOpenCodec");
+ RAOpenCodec2 = (POpenCodec2)GetProcAddress(m_hDrvDll, "RAOpenCodec2");
+ RASetFlavor = (PSetFlavor)GetProcAddress(m_hDrvDll, "RASetFlavor");
+ RASetDLLAccessPath = (PSetDLLAccessPath)GetProcAddress(m_hDrvDll, "RASetDLLAccessPath");
+ RASetPwd = (PSetPwd)GetProcAddress(m_hDrvDll, "RASetPwd");
+ }
+
+ if (!m_hDrvDll || !RACloseCodec || !RADecode /*|| !RAFlush*/
+ || !RAFreeDecoder || !RAGetFlavorProperty || !RAInitDecoder
+ || !(RAOpenCodec || RAOpenCodec2) /*|| !RASetFlavor*/) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+
+ if (m_hDrvDll) {
+ char buff[_MAX_PATH];
+ GetModuleFileNameA(m_hDrvDll, buff, _MAX_PATH);
+ CPathA p(buff);
+ p.RemoveFileSpec();
+ p.AddBackslash();
+ m_dllpath = p.m_strPath;
+ if (RASetDLLAccessPath) {
+ RASetDLLAccessPath("DT_Codecs=" + m_dllpath);
+ }
+ }
+
+ if (FAILED(InitRA(mtIn))) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+ }
+
+ return S_OK;
}
HRESULT CRealAudioDecoder::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
{
- return mtIn->majortype == MEDIATYPE_Audio && (mtIn->subtype == MEDIASUBTYPE_14_4
- || mtIn->subtype == MEDIASUBTYPE_28_8
- || mtIn->subtype == MEDIASUBTYPE_ATRC
- || mtIn->subtype == MEDIASUBTYPE_COOK
- || mtIn->subtype == MEDIASUBTYPE_DNET
- || mtIn->subtype == MEDIASUBTYPE_SIPR
- || mtIn->subtype == MEDIASUBTYPE_RAAC
- || mtIn->subtype == MEDIASUBTYPE_RACP
- || mtIn->subtype == MEDIASUBTYPE_AAC)
- && mtOut->majortype == MEDIATYPE_Audio && mtOut->subtype == MEDIASUBTYPE_PCM
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ return mtIn->majortype == MEDIATYPE_Audio && (mtIn->subtype == MEDIASUBTYPE_14_4
+ || mtIn->subtype == MEDIASUBTYPE_28_8
+ || mtIn->subtype == MEDIASUBTYPE_ATRC
+ || mtIn->subtype == MEDIASUBTYPE_COOK
+ || mtIn->subtype == MEDIASUBTYPE_DNET
+ || mtIn->subtype == MEDIASUBTYPE_SIPR
+ || mtIn->subtype == MEDIASUBTYPE_RAAC
+ || mtIn->subtype == MEDIASUBTYPE_RACP
+ || mtIn->subtype == MEDIASUBTYPE_AAC)
+ && mtOut->majortype == MEDIATYPE_Audio && mtOut->subtype == MEDIASUBTYPE_PCM
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CRealAudioDecoder::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if (m_pInput->IsConnected() == FALSE) {
- return E_UNEXPECTED;
- }
-
- CComPtr<IMemAllocator> pAllocatorIn;
- m_pInput->GetAllocator(&pAllocatorIn);
- if (!pAllocatorIn) {
- return E_UNEXPECTED;
- }
-
- WAVEFORMATEX* pwfe = (WAVEFORMATEX*)m_pOutput->CurrentMediaType().Format();
-
- WORD wBitsPerSample = pwfe->wBitsPerSample;
- if (!wBitsPerSample) {
- wBitsPerSample = 16;
- }
-
- // ok, maybe this is too much...
- pProperties->cBuffers = 8;
- pProperties->cbBuffer = pwfe->nChannels*pwfe->nSamplesPerSec*wBitsPerSample>>3; // nAvgBytesPerSec;
- pProperties->cbAlign = 1;
- pProperties->cbPrefix = 0;
-
- HRESULT hr;
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
- return hr;
- }
-
- return (pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
- ? E_FAIL
- : NOERROR);
+ if (m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
+
+ CComPtr<IMemAllocator> pAllocatorIn;
+ m_pInput->GetAllocator(&pAllocatorIn);
+ if (!pAllocatorIn) {
+ return E_UNEXPECTED;
+ }
+
+ WAVEFORMATEX* pwfe = (WAVEFORMATEX*)m_pOutput->CurrentMediaType().Format();
+
+ WORD wBitsPerSample = pwfe->wBitsPerSample;
+ if (!wBitsPerSample) {
+ wBitsPerSample = 16;
+ }
+
+ // ok, maybe this is too much...
+ pProperties->cBuffers = 8;
+ pProperties->cbBuffer = pwfe->nChannels * pwfe->nSamplesPerSec * wBitsPerSample >> 3; // nAvgBytesPerSec;
+ pProperties->cbAlign = 1;
+ pProperties->cbPrefix = 0;
+
+ HRESULT hr;
+ ALLOCATOR_PROPERTIES Actual;
+ if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
+
+ return (pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
+ ? E_FAIL
+ : NOERROR);
}
HRESULT CRealAudioDecoder::GetMediaType(int iPosition, CMediaType* pmt)
{
- if (m_pInput->IsConnected() == FALSE) {
- return E_UNEXPECTED;
- }
-
- *pmt = m_pInput->CurrentMediaType();
- pmt->subtype = MEDIASUBTYPE_PCM;
- WAVEFORMATEX* pwfe = (WAVEFORMATEX*)pmt->ReallocFormatBuffer(sizeof(WAVEFORMATEX));
-
- if (iPosition < 0) {
- return E_INVALIDARG;
- }
- if (iPosition > (pwfe->nChannels > 2 && pwfe->nChannels <= 6 ? 1 : 0)) {
- return VFW_S_NO_MORE_ITEMS;
- }
-
- if (!pwfe->wBitsPerSample) {
- pwfe->wBitsPerSample = 16;
- }
-
- pwfe->cbSize = 0;
- pwfe->wFormatTag = WAVE_FORMAT_PCM;
- pwfe->nBlockAlign = pwfe->nChannels*pwfe->wBitsPerSample>>3;
- pwfe->nAvgBytesPerSec = pwfe->nSamplesPerSec*pwfe->nBlockAlign;
-
- if (iPosition == 0 && pwfe->nChannels > 2 && pwfe->nChannels <= 6) {
- static DWORD chmask[] = {
- KSAUDIO_SPEAKER_DIRECTOUT,
- KSAUDIO_SPEAKER_MONO,
- KSAUDIO_SPEAKER_STEREO,
- KSAUDIO_SPEAKER_STEREO|SPEAKER_FRONT_CENTER,
- KSAUDIO_SPEAKER_QUAD,
- KSAUDIO_SPEAKER_QUAD|SPEAKER_FRONT_CENTER,
- KSAUDIO_SPEAKER_5POINT1
- };
-
- WAVEFORMATEXTENSIBLE* pwfex = (WAVEFORMATEXTENSIBLE*)pmt->ReallocFormatBuffer(sizeof(WAVEFORMATEXTENSIBLE));
- pwfex->Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX);
- pwfex->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
- pwfex->dwChannelMask = chmask[pwfex->Format.nChannels];
- pwfex->Samples.wValidBitsPerSample = pwfex->Format.wBitsPerSample;
- pwfex->SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
- }
-
- return S_OK;
+ if (m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
+
+ *pmt = m_pInput->CurrentMediaType();
+ pmt->subtype = MEDIASUBTYPE_PCM;
+ WAVEFORMATEX* pwfe = (WAVEFORMATEX*)pmt->ReallocFormatBuffer(sizeof(WAVEFORMATEX));
+
+ if (iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if (iPosition > (pwfe->nChannels > 2 && pwfe->nChannels <= 6 ? 1 : 0)) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
+
+ if (!pwfe->wBitsPerSample) {
+ pwfe->wBitsPerSample = 16;
+ }
+
+ pwfe->cbSize = 0;
+ pwfe->wFormatTag = WAVE_FORMAT_PCM;
+ pwfe->nBlockAlign = pwfe->nChannels * pwfe->wBitsPerSample >> 3;
+ pwfe->nAvgBytesPerSec = pwfe->nSamplesPerSec * pwfe->nBlockAlign;
+
+ if (iPosition == 0 && pwfe->nChannels > 2 && pwfe->nChannels <= 6) {
+ static DWORD chmask[] = {
+ KSAUDIO_SPEAKER_DIRECTOUT,
+ KSAUDIO_SPEAKER_MONO,
+ KSAUDIO_SPEAKER_STEREO,
+ KSAUDIO_SPEAKER_STEREO | SPEAKER_FRONT_CENTER,
+ KSAUDIO_SPEAKER_QUAD,
+ KSAUDIO_SPEAKER_QUAD | SPEAKER_FRONT_CENTER,
+ KSAUDIO_SPEAKER_5POINT1
+ };
+
+ WAVEFORMATEXTENSIBLE* pwfex = (WAVEFORMATEXTENSIBLE*)pmt->ReallocFormatBuffer(sizeof(WAVEFORMATEXTENSIBLE));
+ pwfex->Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX);
+ pwfex->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
+ pwfex->dwChannelMask = chmask[pwfex->Format.nChannels];
+ pwfex->Samples.wValidBitsPerSample = pwfex->Format.wBitsPerSample;
+ pwfex->SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
+ }
+
+ return S_OK;
}
HRESULT CRealAudioDecoder::StartStreaming()
{
- int w = m_rai.coded_frame_size;
- int h = m_rai.sub_packet_h;
- int sps = m_rai.sub_packet_size;
- UNREFERENCED_PARAMETER(sps);
+ int w = m_rai.coded_frame_size;
+ int h = m_rai.sub_packet_h;
+ int sps = m_rai.sub_packet_size;
+ UNREFERENCED_PARAMETER(sps);
- int len = w*h;
+ int len = w * h;
- m_buff.Allocate(len*2);
- m_bufflen = 0;
- m_rtBuffStart = 0;
+ m_buff.Allocate(len * 2);
+ m_bufflen = 0;
+ m_rtBuffStart = 0;
- return __super::StartStreaming();
+ return __super::StartStreaming();
}
HRESULT CRealAudioDecoder::StopStreaming()
{
- m_buff.Free();
- m_bufflen = 0;
+ m_buff.Free();
+ m_bufflen = 0;
- return __super::StopStreaming();
+ return __super::StopStreaming();
}
HRESULT CRealAudioDecoder::EndOfStream()
{
- return __super::EndOfStream();
+ return __super::EndOfStream();
}
HRESULT CRealAudioDecoder::BeginFlush()
{
- return __super::BeginFlush();
+ return __super::BeginFlush();
}
HRESULT CRealAudioDecoder::EndFlush()
{
- return __super::EndFlush();
+ return __super::EndFlush();
}
HRESULT CRealAudioDecoder::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- CAutoLock cAutoLock(&m_csReceive);
- m_tStart = tStart;
- m_bufflen = 0;
- m_rtBuffStart = 0;
- return __super::NewSegment(tStart, tStop, dRate);
+ CAutoLock cAutoLock(&m_csReceive);
+ m_tStart = tStart;
+ m_bufflen = 0;
+ m_rtBuffStart = 0;
+ return __super::NewSegment(tStart, tStop, dRate);
}
diff --git a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.h b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.h
index 51bdbdbb6..5e16fd241 100644
--- a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.h
+++ b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.h
@@ -37,316 +37,316 @@
namespace RMFF
{
- typedef struct {
- union {
- char id[4];
- UINT32 object_id;
- };
- UINT32 size;
- UINT16 object_version;
- } ChunkHdr;
- typedef struct {
- UINT32 version, nHeaders;
- } FileHdr;
- typedef struct {
- UINT32 maxBitRate, avgBitRate;
- UINT32 maxPacketSize, avgPacketSize, nPackets;
- UINT32 tDuration, tPreroll;
- UINT32 ptrIndex, ptrData;
- UINT16 nStreams;
- enum flags_t {PN_SAVE_ENABLED=1, PN_PERFECT_PLAY_ENABLED=2, PN_LIVE_BROADCAST=4} flags;
- } Properies;
- typedef struct {
- UINT16 stream;
- UINT32 maxBitRate, avgBitRate;
- UINT32 maxPacketSize, avgPacketSize;
- UINT32 tStart, tPreroll, tDuration;
- CStringA name, mime;
- CAtlArray<BYTE> typeSpecData;
- UINT32 width, height;
- bool interlaced, top_field_first;
- } MediaProperies;
- typedef struct {
- CStringA title, author, copyright, comment;
- } ContentDesc;
- typedef struct {
- UINT64 pos;
- UINT32 nPackets, ptrNext;
- } DataChunk;
- typedef struct {
- UINT16 len, stream;
- UINT32 tStart;
- UINT8 reserved;
- enum flag_t {PN_RELIABLE_FLAG=1, PN_KEYFRAME_FLAG=2} flags; // UINT8
- CAtlArray<BYTE> pData;
- } MediaPacketHeader;
- typedef struct {
- UINT32 nIndices;
- UINT16 stream;
- UINT32 ptrNext;
- } IndexChunkHeader;
- typedef struct {
- UINT32 tStart, ptrFilePos, packet;
- } IndexRecord;
+ typedef struct {
+ union {
+ char id[4];
+ UINT32 object_id;
+ };
+ UINT32 size;
+ UINT16 object_version;
+ } ChunkHdr;
+ typedef struct {
+ UINT32 version, nHeaders;
+ } FileHdr;
+ typedef struct {
+ UINT32 maxBitRate, avgBitRate;
+ UINT32 maxPacketSize, avgPacketSize, nPackets;
+ UINT32 tDuration, tPreroll;
+ UINT32 ptrIndex, ptrData;
+ UINT16 nStreams;
+ enum flags_t {PN_SAVE_ENABLED = 1, PN_PERFECT_PLAY_ENABLED = 2, PN_LIVE_BROADCAST = 4} flags;
+ } Properies;
+ typedef struct {
+ UINT16 stream;
+ UINT32 maxBitRate, avgBitRate;
+ UINT32 maxPacketSize, avgPacketSize;
+ UINT32 tStart, tPreroll, tDuration;
+ CStringA name, mime;
+ CAtlArray<BYTE> typeSpecData;
+ UINT32 width, height;
+ bool interlaced, top_field_first;
+ } MediaProperies;
+ typedef struct {
+ CStringA title, author, copyright, comment;
+ } ContentDesc;
+ typedef struct {
+ UINT64 pos;
+ UINT32 nPackets, ptrNext;
+ } DataChunk;
+ typedef struct {
+ UINT16 len, stream;
+ UINT32 tStart;
+ UINT8 reserved;
+ enum flag_t {PN_RELIABLE_FLAG = 1, PN_KEYFRAME_FLAG = 2} flags; // UINT8
+ CAtlArray<BYTE> pData;
+ } MediaPacketHeader;
+ typedef struct {
+ UINT32 nIndices;
+ UINT16 stream;
+ UINT32 ptrNext;
+ } IndexChunkHeader;
+ typedef struct {
+ UINT32 tStart, ptrFilePos, packet;
+ } IndexRecord;
}
struct rvinfo {
- DWORD dwSize, fcc1, fcc2;
- WORD w, h, bpp;
- DWORD unk1, fps, type1, type2;
- BYTE morewh[14];
- void bswap();
+ DWORD dwSize, fcc1, fcc2;
+ WORD w, h, bpp;
+ DWORD unk1, fps, type1, type2;
+ BYTE morewh[14];
+ void bswap();
};
struct rainfo {
- DWORD fourcc1; // '.', 'r', 'a', 0xfd
- WORD version1; // 4 or 5
- WORD unknown1; // 00 000
- DWORD fourcc2; // .ra4 or .ra5
- DWORD unknown2; // ???
- WORD version2; // 4 or 5
- DWORD header_size; // == 0x4e
- WORD flavor; // codec flavor id
- DWORD coded_frame_size; // coded frame size
- DWORD unknown3; // big number
- DWORD unknown4; // bigger number
- DWORD unknown5; // yet another number
- WORD sub_packet_h;
- WORD frame_size;
- WORD sub_packet_size;
- WORD unknown6; // 00 00
- void bswap();
+ DWORD fourcc1; // '.', 'r', 'a', 0xfd
+ WORD version1; // 4 or 5
+ WORD unknown1; // 00 000
+ DWORD fourcc2; // .ra4 or .ra5
+ DWORD unknown2; // ???
+ WORD version2; // 4 or 5
+ DWORD header_size; // == 0x4e
+ WORD flavor; // codec flavor id
+ DWORD coded_frame_size; // coded frame size
+ DWORD unknown3; // big number
+ DWORD unknown4; // bigger number
+ DWORD unknown5; // yet another number
+ WORD sub_packet_h;
+ WORD frame_size;
+ WORD sub_packet_size;
+ WORD unknown6; // 00 00
+ void bswap();
};
struct rainfo4 : rainfo {
- WORD sample_rate;
- WORD unknown8; // 0
- WORD sample_size;
- WORD channels;
- void bswap();
+ WORD sample_rate;
+ WORD unknown8; // 0
+ WORD sample_size;
+ WORD channels;
+ void bswap();
};
struct rainfo5 : rainfo {
- BYTE unknown7[6]; // 0, srate, 0
- WORD sample_rate;
- WORD unknown8; // 0
- WORD sample_size;
- WORD channels;
- DWORD genr; // "genr"
- DWORD fourcc3; // fourcc
- void bswap();
+ BYTE unknown7[6]; // 0, srate, 0
+ WORD sample_rate;
+ WORD unknown8; // 0
+ WORD sample_size;
+ WORD channels;
+ DWORD genr; // "genr"
+ DWORD fourcc3; // fourcc
+ void bswap();
};
#pragma pack(pop)
class CRMFile : public CBaseSplitterFile
{
- // using CBaseSplitterFile::Read;
+ // using CBaseSplitterFile::Read;
- HRESULT Init();
- void GetDimensions();
+ HRESULT Init();
+ void GetDimensions();
public:
- CRMFile(IAsyncReader* pAsyncReader, HRESULT& hr);
+ CRMFile(IAsyncReader* pAsyncReader, HRESULT& hr);
- template<typename T> HRESULT Read(T& var);
- HRESULT Read(RMFF::ChunkHdr& hdr);
- HRESULT Read(RMFF::MediaPacketHeader& mph, bool fFull = true);
+ template<typename T> HRESULT Read(T& var);
+ HRESULT Read(RMFF::ChunkHdr& hdr);
+ HRESULT Read(RMFF::MediaPacketHeader& mph, bool fFull = true);
- RMFF::FileHdr m_fh;
- RMFF::ContentDesc m_cd;
- RMFF::Properies m_p;
- CAutoPtrList<RMFF::MediaProperies> m_mps;
- CAutoPtrList<RMFF::DataChunk> m_dcs;
- CAutoPtrList<RMFF::IndexRecord> m_irs;
+ RMFF::FileHdr m_fh;
+ RMFF::ContentDesc m_cd;
+ RMFF::Properies m_p;
+ CAutoPtrList<RMFF::MediaProperies> m_mps;
+ CAutoPtrList<RMFF::DataChunk> m_dcs;
+ CAutoPtrList<RMFF::IndexRecord> m_irs;
- typedef struct {
- CStringA name, data;
- } subtitle;
- CAtlList<subtitle> m_subs;
+ typedef struct {
+ CStringA name, data;
+ } subtitle;
+ CAtlList<subtitle> m_subs;
- int GetMasterStream();
+ int GetMasterStream();
};
class CRealMediaSplitterOutputPin : public CBaseSplitterOutputPin
{
private:
- typedef struct {
- CAtlArray<BYTE> data;
- DWORD offset;
- } segment;
-
- class CSegments : public CAutoPtrList<segment>, public CCritSec
- {
- public:
- REFERENCE_TIME rtStart;
- bool fDiscontinuity, fSyncPoint, fMerged;
- void Clear() {
- CAutoLock cAutoLock(this);
- rtStart = 0;
- fDiscontinuity = fSyncPoint = fMerged = false;
- RemoveAll();
- }
- } m_segments;
-
- CCritSec m_csQueue;
-
- HRESULT DeliverSegments();
+ typedef struct {
+ CAtlArray<BYTE> data;
+ DWORD offset;
+ } segment;
+
+ class CSegments : public CAutoPtrList<segment>, public CCritSec
+ {
+ public:
+ REFERENCE_TIME rtStart;
+ bool fDiscontinuity, fSyncPoint, fMerged;
+ void Clear() {
+ CAutoLock cAutoLock(this);
+ rtStart = 0;
+ fDiscontinuity = fSyncPoint = fMerged = false;
+ RemoveAll();
+ }
+ } m_segments;
+
+ CCritSec m_csQueue;
+
+ HRESULT DeliverSegments();
protected:
- HRESULT DeliverPacket(CAutoPtr<Packet> p);
+ HRESULT DeliverPacket(CAutoPtr<Packet> p);
public:
- CRealMediaSplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
- virtual ~CRealMediaSplitterOutputPin();
+ CRealMediaSplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
+ virtual ~CRealMediaSplitterOutputPin();
- HRESULT DeliverEndFlush();
+ HRESULT DeliverEndFlush();
};
class __declspec(uuid("E21BE468-5C18-43EB-B0CC-DB93A847D769"))
- CRealMediaSplitterFilter : public CBaseSplitterFilter
+ CRealMediaSplitterFilter : public CBaseSplitterFilter
{
protected:
- CAutoPtr<CRMFile> m_pFile;
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
+ CAutoPtr<CRMFile> m_pFile;
+ HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
+ bool DemuxInit();
+ void DemuxSeek(REFERENCE_TIME rt);
+ bool DemuxLoop();
- POSITION m_seekpos;
- UINT32 m_seekpacket;
- UINT64 m_seekfilepos;
+ POSITION m_seekpos;
+ UINT32 m_seekpacket;
+ UINT64 m_seekfilepos;
public:
- CRealMediaSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
- virtual ~CRealMediaSplitterFilter();
+ CRealMediaSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
+ virtual ~CRealMediaSplitterFilter();
- // CBaseFilter
+ // CBaseFilter
- STDMETHODIMP_(HRESULT) QueryFilterInfo(FILTER_INFO* pInfo);
+ STDMETHODIMP_(HRESULT) QueryFilterInfo(FILTER_INFO* pInfo);
- // IKeyFrameInfo
+ // IKeyFrameInfo
- STDMETHODIMP_(HRESULT) GetKeyFrameCount(UINT& nKFs);
- STDMETHODIMP_(HRESULT) GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs);
+ STDMETHODIMP_(HRESULT) GetKeyFrameCount(UINT& nKFs);
+ STDMETHODIMP_(HRESULT) GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs);
};
class __declspec(uuid("765035B3-5944-4A94-806B-20EE3415F26F"))
- CRealMediaSourceFilter : public CRealMediaSplitterFilter
+ CRealMediaSourceFilter : public CRealMediaSplitterFilter
{
public:
- CRealMediaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
+ CRealMediaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
};
////////////
class __declspec(uuid("238D0F23-5DC9-45A6-9BE2-666160C324DD"))
- CRealVideoDecoder : public CBaseVideoFilter
+ CRealVideoDecoder : public CBaseVideoFilter
{
- typedef HRESULT (WINAPI *PRVCustomMessage)(void*, DWORD);
- typedef HRESULT (WINAPI *PRVFree)(DWORD);
- typedef HRESULT (WINAPI *PRVHiveMessage)(void*, DWORD);
- typedef HRESULT (WINAPI *PRVInit)(void*, DWORD* dwCookie);
- typedef HRESULT (WINAPI *PRVTransform)(BYTE*, BYTE*, void*, void*, DWORD);
+ typedef HRESULT(WINAPI* PRVCustomMessage)(void*, DWORD);
+ typedef HRESULT(WINAPI* PRVFree)(DWORD);
+ typedef HRESULT(WINAPI* PRVHiveMessage)(void*, DWORD);
+ typedef HRESULT(WINAPI* PRVInit)(void*, DWORD* dwCookie);
+ typedef HRESULT(WINAPI* PRVTransform)(BYTE*, BYTE*, void*, void*, DWORD);
- PRVCustomMessage RVCustomMessage;
- PRVFree RVFree;
- PRVHiveMessage RVHiveMessage;
- PRVInit RVInit;
- PRVTransform RVTransform;
+ PRVCustomMessage RVCustomMessage;
+ PRVFree RVFree;
+ PRVHiveMessage RVHiveMessage;
+ PRVInit RVInit;
+ PRVTransform RVTransform;
- HMODULE m_hDrvDll;
- DWORD m_dwCookie;
- int m_lastBuffSizeDim;
+ HMODULE m_hDrvDll;
+ DWORD m_dwCookie;
+ int m_lastBuffSizeDim;
- HRESULT InitRV(const CMediaType* pmt);
- void FreeRV();
+ HRESULT InitRV(const CMediaType* pmt);
+ void FreeRV();
- REFERENCE_TIME m_tStart;
+ REFERENCE_TIME m_tStart;
- void Resize(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD wo, DWORD ho);
- void ResizeWidth(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD wo, DWORD ho);
- void ResizeHeight(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD wo, DWORD ho);
- void ResizeRow(BYTE* pIn, DWORD wi, DWORD dpi, BYTE* pOut, DWORD wo, DWORD dpo);
+ void Resize(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD wo, DWORD ho);
+ void ResizeWidth(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD wo, DWORD ho);
+ void ResizeHeight(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD wo, DWORD ho);
+ void ResizeRow(BYTE* pIn, DWORD wi, DWORD dpi, BYTE* pOut, DWORD wo, DWORD dpo);
- BYTE* m_pI420, *m_pI420Tmp;
+ BYTE* m_pI420, *m_pI420Tmp;
public:
- CRealVideoDecoder(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CRealVideoDecoder();
+ CRealVideoDecoder(LPUNKNOWN lpunk, HRESULT* phr);
+ virtual ~CRealVideoDecoder();
- HRESULT Transform(IMediaSample* pIn);
- HRESULT CheckInputType(const CMediaType* mtIn);
- HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
+ HRESULT Transform(IMediaSample* pIn);
+ HRESULT CheckInputType(const CMediaType* mtIn);
+ HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
- HRESULT StartStreaming();
- HRESULT StopStreaming();
+ HRESULT StartStreaming();
+ HRESULT StopStreaming();
- HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
- DWORD m_timestamp;
- bool m_fDropFrames;
- HRESULT AlterQuality(Quality q);
+ DWORD m_timestamp;
+ bool m_fDropFrames;
+ HRESULT AlterQuality(Quality q);
};
class __declspec(uuid("941A4793-A705-4312-8DFC-C11CA05F397E"))
- CRealAudioDecoder : public CTransformFilter
+ CRealAudioDecoder : public CTransformFilter
{
- typedef HRESULT (WINAPI *PCloseCodec)(DWORD);
- typedef HRESULT (WINAPI *PDecode)(DWORD,BYTE*,long,BYTE*,long*,long);
- typedef HRESULT (WINAPI *PFlush)(DWORD,DWORD,DWORD);
- typedef HRESULT (WINAPI *PFreeDecoder)(DWORD);
- typedef void* (WINAPI *PGetFlavorProperty)(void*,DWORD,DWORD,int*);
- typedef HRESULT (WINAPI *PInitDecoder)(DWORD, void*);
- typedef HRESULT (WINAPI *POpenCodec)(void*);
- typedef HRESULT (WINAPI *POpenCodec2)(void*, const char*);
- typedef HRESULT (WINAPI *PSetFlavor)(DWORD, WORD);
- typedef void (WINAPI *PSetDLLAccessPath)(const char*);
- typedef void (WINAPI *PSetPwd)(DWORD, const char*);
-
- PCloseCodec RACloseCodec;
- PDecode RADecode;
- PFlush RAFlush;
- PFreeDecoder RAFreeDecoder;
- PGetFlavorProperty RAGetFlavorProperty;
- PInitDecoder RAInitDecoder;
- POpenCodec RAOpenCodec;
- POpenCodec2 RAOpenCodec2;
- PSetFlavor RASetFlavor;
- PSetDLLAccessPath RASetDLLAccessPath;
- PSetPwd RASetPwd;
-
- CStringA m_dllpath;
- HMODULE m_hDrvDll;
- DWORD m_dwCookie;
-
- HRESULT InitRA(const CMediaType* pmt);
- void FreeRA();
-
- REFERENCE_TIME m_tStart;
-
- rainfo m_rai;
- CAutoVectorPtr<BYTE> m_buff;
- int m_bufflen;
- REFERENCE_TIME m_rtBuffStart;
- bool m_fBuffDiscontinuity;
+ typedef HRESULT(WINAPI* PCloseCodec)(DWORD);
+ typedef HRESULT(WINAPI* PDecode)(DWORD, BYTE*, long, BYTE*, long*, long);
+ typedef HRESULT(WINAPI* PFlush)(DWORD, DWORD, DWORD);
+ typedef HRESULT(WINAPI* PFreeDecoder)(DWORD);
+ typedef void* (WINAPI* PGetFlavorProperty)(void*, DWORD, DWORD, int*);
+ typedef HRESULT(WINAPI* PInitDecoder)(DWORD, void*);
+ typedef HRESULT(WINAPI* POpenCodec)(void*);
+ typedef HRESULT(WINAPI* POpenCodec2)(void*, const char*);
+ typedef HRESULT(WINAPI* PSetFlavor)(DWORD, WORD);
+ typedef void (WINAPI* PSetDLLAccessPath)(const char*);
+ typedef void (WINAPI* PSetPwd)(DWORD, const char*);
+
+ PCloseCodec RACloseCodec;
+ PDecode RADecode;
+ PFlush RAFlush;
+ PFreeDecoder RAFreeDecoder;
+ PGetFlavorProperty RAGetFlavorProperty;
+ PInitDecoder RAInitDecoder;
+ POpenCodec RAOpenCodec;
+ POpenCodec2 RAOpenCodec2;
+ PSetFlavor RASetFlavor;
+ PSetDLLAccessPath RASetDLLAccessPath;
+ PSetPwd RASetPwd;
+
+ CStringA m_dllpath;
+ HMODULE m_hDrvDll;
+ DWORD m_dwCookie;
+
+ HRESULT InitRA(const CMediaType* pmt);
+ void FreeRA();
+
+ REFERENCE_TIME m_tStart;
+
+ rainfo m_rai;
+ CAutoVectorPtr<BYTE> m_buff;
+ int m_bufflen;
+ REFERENCE_TIME m_rtBuffStart;
+ bool m_fBuffDiscontinuity;
public:
- CRealAudioDecoder(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CRealAudioDecoder();
-
- HRESULT Receive(IMediaSample* pIn);
- HRESULT CheckInputType(const CMediaType* mtIn);
- HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
- HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT GetMediaType(int iPosition, CMediaType* pMediaType);
-
- HRESULT StartStreaming();
- HRESULT StopStreaming();
-
- HRESULT EndOfStream();
- HRESULT BeginFlush();
- HRESULT EndFlush();
- HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ CRealAudioDecoder(LPUNKNOWN lpunk, HRESULT* phr);
+ virtual ~CRealAudioDecoder();
+
+ HRESULT Receive(IMediaSample* pIn);
+ HRESULT CheckInputType(const CMediaType* mtIn);
+ HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
+ HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT GetMediaType(int iPosition, CMediaType* pMediaType);
+
+ HRESULT StartStreaming();
+ HRESULT StopStreaming();
+
+ HRESULT EndOfStream();
+ HRESULT BeginFlush();
+ HRESULT EndFlush();
+ HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
};
diff --git a/src/filters/parser/StreamDriveThru/StreamDriveThru.cpp b/src/filters/parser/StreamDriveThru/StreamDriveThru.cpp
index 9a956754e..d14d5bb3d 100644
--- a/src/filters/parser/StreamDriveThru/StreamDriveThru.cpp
+++ b/src/filters/parser/StreamDriveThru/StreamDriveThru.cpp
@@ -28,36 +28,36 @@
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CStreamDriveThruFilter), StreamDriveThruName, MERIT_DO_NOT_USE, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory}
+ {&__uuidof(CStreamDriveThruFilter), StreamDriveThruName, MERIT_DO_NOT_USE, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory}
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CStreamDriveThruFilter>, NULL, &sudFilter[0]}
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CStreamDriveThruFilter>, NULL, &sudFilter[0]}
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -71,305 +71,305 @@ CFilterApp theApp;
//
CStreamDriveThruFilter::CStreamDriveThruFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseFilter(NAME("CStreamDriveThruFilter"), pUnk, &m_csLock, __uuidof(this))
- , m_position(0)
+ : CBaseFilter(NAME("CStreamDriveThruFilter"), pUnk, &m_csLock, __uuidof(this))
+ , m_position(0)
{
- if (phr) {
- *phr = S_OK;
- }
+ if (phr) {
+ *phr = S_OK;
+ }
- m_pInput = DNew CStreamDriveThruInputPin(NAME("CStreamDriveThruInputPin"), this, &m_csLock, phr);
- m_pOutput = DNew CStreamDriveThruOutputPin(NAME("CStreamDriveThruOutputPin"), this, &m_csLock, phr);
+ m_pInput = DNew CStreamDriveThruInputPin(NAME("CStreamDriveThruInputPin"), this, &m_csLock, phr);
+ m_pOutput = DNew CStreamDriveThruOutputPin(NAME("CStreamDriveThruOutputPin"), this, &m_csLock, phr);
- CAMThread::Create();
+ CAMThread::Create();
}
CStreamDriveThruFilter::~CStreamDriveThruFilter()
{
- CAutoLock csAutoLock(&m_csLock);
+ CAutoLock csAutoLock(&m_csLock);
- CAMThread::CallWorker(CMD_EXIT);
- CAMThread::Close();
+ CAMThread::CallWorker(CMD_EXIT);
+ CAMThread::Close();
- delete m_pInput;
- delete m_pOutput;
+ delete m_pInput;
+ delete m_pOutput;
}
STDMETHODIMP CStreamDriveThruFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- QI(IMediaSeeking)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IMediaSeeking)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
#define PACKETSIZE 65536
DWORD CStreamDriveThruFilter::ThreadProc()
{
- for (;;) {
- DWORD cmd = GetRequest();
-
- switch (cmd) {
- default:
- case CMD_EXIT:
- Reply(S_OK);
- return 0;
- case CMD_STOP:
- Reply(S_OK);
- break;
- case CMD_PAUSE:
- Reply(S_OK);
- break;
- case CMD_RUN:
- Reply(S_OK);
-
- do {
- CComPtr<IAsyncReader> pAsyncReader;
- CComPtr<IStream> pStream;
-
- if (!m_pInput || !m_pInput->IsConnected() || FAILED(m_pInput->GetAsyncReader(&pAsyncReader))
- || !m_pOutput || !m_pOutput->IsConnected() || FAILED(m_pOutput->GetStream(&pStream))) {
- break;
- }
-
- LARGE_INTEGER li = {0};
- ULARGE_INTEGER uli = {0};
-
- if (FAILED(pStream->Seek(li, STREAM_SEEK_SET, NULL))
- || FAILED(pStream->SetSize(uli))) {
- break;
- }
-
- if (CComQIPtr<IFileSinkFilter2> pFSF = GetFilterFromPin(m_pOutput->GetConnected())) {
- pFSF->SetMode(AM_FILE_OVERWRITE);
-
- LPOLESTR pfn;
- if (SUCCEEDED(pFSF->GetCurFile(&pfn, NULL))) {
- pFSF->SetFileName(pfn, NULL);
- CoTaskMemFree(pfn);
- }
- }
-
- m_position = 0;
- BYTE buff[PACKETSIZE];
-
- do {
- while (!CheckRequest(&cmd)) {
- CAutoLock csAutoLock(&m_csLock);
-
- LONGLONG total = 0, available = 0;
- if (FAILED(pAsyncReader->Length(&total, &available)) || m_position >= total) {
- cmd = CMD_STOP;
- break;
- }
-
- LONG size = (LONG)min(PACKETSIZE, total - m_position);
- if (FAILED(pAsyncReader->SyncRead(m_position, size, buff))) {
- cmd = CMD_STOP;
- break;
- }
-
- ULONG written = 0;
- if (FAILED(pStream->Write(buff, (ULONG)size, &written)) || (ULONG)size != written) {
- cmd = CMD_STOP;
- break;
- }
-
- m_position += size;
- }
-
- if (cmd == CMD_PAUSE) {
- Reply(S_OK); // reply to CMD_PAUSE
-
- while (!CheckRequest(&cmd)) {
- Sleep(50);
- }
-
- Reply(S_OK); // reply to something
- }
- } while (cmd == CMD_RUN);
-
- uli.QuadPart = m_position;
- pStream->SetSize(uli);
-
- if (CComPtr<IPin> pPin = m_pOutput->GetConnected()) {
- pPin->EndOfStream();
- }
- } while (false);
-
- break;
- }
- }
-
- return 0;
+ for (;;) {
+ DWORD cmd = GetRequest();
+
+ switch (cmd) {
+ default:
+ case CMD_EXIT:
+ Reply(S_OK);
+ return 0;
+ case CMD_STOP:
+ Reply(S_OK);
+ break;
+ case CMD_PAUSE:
+ Reply(S_OK);
+ break;
+ case CMD_RUN:
+ Reply(S_OK);
+
+ do {
+ CComPtr<IAsyncReader> pAsyncReader;
+ CComPtr<IStream> pStream;
+
+ if (!m_pInput || !m_pInput->IsConnected() || FAILED(m_pInput->GetAsyncReader(&pAsyncReader))
+ || !m_pOutput || !m_pOutput->IsConnected() || FAILED(m_pOutput->GetStream(&pStream))) {
+ break;
+ }
+
+ LARGE_INTEGER li = {0};
+ ULARGE_INTEGER uli = {0};
+
+ if (FAILED(pStream->Seek(li, STREAM_SEEK_SET, NULL))
+ || FAILED(pStream->SetSize(uli))) {
+ break;
+ }
+
+ if (CComQIPtr<IFileSinkFilter2> pFSF = GetFilterFromPin(m_pOutput->GetConnected())) {
+ pFSF->SetMode(AM_FILE_OVERWRITE);
+
+ LPOLESTR pfn;
+ if (SUCCEEDED(pFSF->GetCurFile(&pfn, NULL))) {
+ pFSF->SetFileName(pfn, NULL);
+ CoTaskMemFree(pfn);
+ }
+ }
+
+ m_position = 0;
+ BYTE buff[PACKETSIZE];
+
+ do {
+ while (!CheckRequest(&cmd)) {
+ CAutoLock csAutoLock(&m_csLock);
+
+ LONGLONG total = 0, available = 0;
+ if (FAILED(pAsyncReader->Length(&total, &available)) || m_position >= total) {
+ cmd = CMD_STOP;
+ break;
+ }
+
+ LONG size = (LONG)min(PACKETSIZE, total - m_position);
+ if (FAILED(pAsyncReader->SyncRead(m_position, size, buff))) {
+ cmd = CMD_STOP;
+ break;
+ }
+
+ ULONG written = 0;
+ if (FAILED(pStream->Write(buff, (ULONG)size, &written)) || (ULONG)size != written) {
+ cmd = CMD_STOP;
+ break;
+ }
+
+ m_position += size;
+ }
+
+ if (cmd == CMD_PAUSE) {
+ Reply(S_OK); // reply to CMD_PAUSE
+
+ while (!CheckRequest(&cmd)) {
+ Sleep(50);
+ }
+
+ Reply(S_OK); // reply to something
+ }
+ } while (cmd == CMD_RUN);
+
+ uli.QuadPart = m_position;
+ pStream->SetSize(uli);
+
+ if (CComPtr<IPin> pPin = m_pOutput->GetConnected()) {
+ pPin->EndOfStream();
+ }
+ } while (false);
+
+ break;
+ }
+ }
+
+ return 0;
}
int CStreamDriveThruFilter::GetPinCount()
{
- return 2;
+ return 2;
}
CBasePin* CStreamDriveThruFilter::GetPin(int n)
{
- CAutoLock csAutoLock(&m_csLock);
+ CAutoLock csAutoLock(&m_csLock);
- if (n == 0) {
- return m_pInput;
- } else if (n == 1) {
- return m_pOutput;
- }
+ if (n == 0) {
+ return m_pInput;
+ } else if (n == 1) {
+ return m_pOutput;
+ }
- return NULL;
+ return NULL;
}
STDMETHODIMP CStreamDriveThruFilter::Stop()
{
- HRESULT hr;
+ HRESULT hr;
- if (FAILED(hr = __super::Stop())) {
- return hr;
- }
+ if (FAILED(hr = __super::Stop())) {
+ return hr;
+ }
- CallWorker(CMD_STOP);
+ CallWorker(CMD_STOP);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CStreamDriveThruFilter::Pause()
{
- HRESULT hr;
+ HRESULT hr;
- if (FAILED(hr = __super::Pause())) {
- return hr;
- }
+ if (FAILED(hr = __super::Pause())) {
+ return hr;
+ }
- CallWorker(CMD_PAUSE);
+ CallWorker(CMD_PAUSE);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CStreamDriveThruFilter::Run(REFERENCE_TIME tStart)
{
- HRESULT hr;
+ HRESULT hr;
- if (FAILED(hr = __super::Run(tStart))) {
- return hr;
- }
+ if (FAILED(hr = __super::Run(tStart))) {
+ return hr;
+ }
- CallWorker(CMD_RUN);
+ CallWorker(CMD_RUN);
- return S_OK;
+ return S_OK;
}
// IMediaSeeking
STDMETHODIMP CStreamDriveThruFilter::GetCapabilities(DWORD* pCapabilities)
{
- return pCapabilities ? *pCapabilities = AM_SEEKING_CanGetCurrentPos|AM_SEEKING_CanGetStopPos|AM_SEEKING_CanGetDuration, S_OK : E_POINTER;
+ return pCapabilities ? *pCapabilities = AM_SEEKING_CanGetCurrentPos | AM_SEEKING_CanGetStopPos | AM_SEEKING_CanGetDuration, S_OK : E_POINTER;
}
STDMETHODIMP CStreamDriveThruFilter::CheckCapabilities(DWORD* pCapabilities)
{
- CheckPointer(pCapabilities, E_POINTER);
+ CheckPointer(pCapabilities, E_POINTER);
- if (*pCapabilities == 0) {
- return S_OK;
- }
+ if (*pCapabilities == 0) {
+ return S_OK;
+ }
- DWORD caps;
- GetCapabilities(&caps);
+ DWORD caps;
+ GetCapabilities(&caps);
- DWORD caps2 = caps & *pCapabilities;
+ DWORD caps2 = caps & *pCapabilities;
- return caps2 == 0 ? E_FAIL : caps2 == *pCapabilities ? S_OK : S_FALSE;
+ return caps2 == 0 ? E_FAIL : caps2 == *pCapabilities ? S_OK : S_FALSE;
}
STDMETHODIMP CStreamDriveThruFilter::IsFormatSupported(const GUID* pFormat)
{
- return !pFormat ? E_POINTER : *pFormat == TIME_FORMAT_MEDIA_TIME ? S_OK : S_FALSE;
+ return !pFormat ? E_POINTER : *pFormat == TIME_FORMAT_MEDIA_TIME ? S_OK : S_FALSE;
}
STDMETHODIMP CStreamDriveThruFilter::QueryPreferredFormat(GUID* pFormat)
{
- return GetTimeFormat(pFormat);
+ return GetTimeFormat(pFormat);
}
STDMETHODIMP CStreamDriveThruFilter::GetTimeFormat(GUID* pFormat)
{
- return pFormat ? *pFormat = TIME_FORMAT_MEDIA_TIME, S_OK : E_POINTER;
+ return pFormat ? *pFormat = TIME_FORMAT_MEDIA_TIME, S_OK : E_POINTER;
}
STDMETHODIMP CStreamDriveThruFilter::IsUsingTimeFormat(const GUID* pFormat)
{
- return IsFormatSupported(pFormat);
+ return IsFormatSupported(pFormat);
}
STDMETHODIMP CStreamDriveThruFilter::SetTimeFormat(const GUID* pFormat)
{
- return S_OK == IsFormatSupported(pFormat) ? S_OK : E_INVALIDARG;
+ return S_OK == IsFormatSupported(pFormat) ? S_OK : E_INVALIDARG;
}
STDMETHODIMP CStreamDriveThruFilter::GetDuration(LONGLONG* pDuration)
{
- CheckPointer(pDuration, E_POINTER);
- CheckPointer(m_pInput, VFW_E_NOT_CONNECTED);
+ CheckPointer(pDuration, E_POINTER);
+ CheckPointer(m_pInput, VFW_E_NOT_CONNECTED);
- if (CComQIPtr<IAsyncReader> pAsyncReader = m_pInput->GetConnected()) {
- LONGLONG total, available;
- if (SUCCEEDED(pAsyncReader->Length(&total, &available))) {
- *pDuration = total;
- return S_OK;
- }
- }
+ if (CComQIPtr<IAsyncReader> pAsyncReader = m_pInput->GetConnected()) {
+ LONGLONG total, available;
+ if (SUCCEEDED(pAsyncReader->Length(&total, &available))) {
+ *pDuration = total;
+ return S_OK;
+ }
+ }
- return E_NOINTERFACE;
+ return E_NOINTERFACE;
}
STDMETHODIMP CStreamDriveThruFilter::GetStopPosition(LONGLONG* pStop)
{
- return GetDuration(pStop);
+ return GetDuration(pStop);
}
STDMETHODIMP CStreamDriveThruFilter::GetCurrentPosition(LONGLONG* pCurrent)
{
- return pCurrent ? *pCurrent = m_position, S_OK : E_POINTER;
+ return pCurrent ? *pCurrent = m_position, S_OK : E_POINTER;
}
STDMETHODIMP CStreamDriveThruFilter::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CStreamDriveThruFilter::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CStreamDriveThruFilter::GetPositions(LONGLONG* pCurrent, LONGLONG* pStop)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CStreamDriveThruFilter::GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CStreamDriveThruFilter::SetRate(double dRate)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CStreamDriveThruFilter::GetRate(double* pdRate)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CStreamDriveThruFilter::GetPreroll(LONGLONG* pllPreroll)
{
- return pllPreroll ? *pllPreroll = 0, S_OK : E_POINTER;
+ return pllPreroll ? *pllPreroll = 0, S_OK : E_POINTER;
}
//
@@ -377,7 +377,7 @@ STDMETHODIMP CStreamDriveThruFilter::GetPreroll(LONGLONG* pllPreroll)
//
CStreamDriveThruInputPin::CStreamDriveThruInputPin(TCHAR* pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBasePin(pName, pFilter, pLock, phr, L"Input", PINDIR_INPUT)
+ : CBasePin(pName, pFilter, pLock, phr, L"Input", PINDIR_INPUT)
{
}
@@ -387,83 +387,83 @@ CStreamDriveThruInputPin::~CStreamDriveThruInputPin()
HRESULT CStreamDriveThruInputPin::GetAsyncReader(IAsyncReader** ppAsyncReader)
{
- CheckPointer(ppAsyncReader, E_POINTER);
+ CheckPointer(ppAsyncReader, E_POINTER);
- *ppAsyncReader = NULL;
+ *ppAsyncReader = NULL;
- CheckPointer(m_pAsyncReader, VFW_E_NOT_CONNECTED);
+ CheckPointer(m_pAsyncReader, VFW_E_NOT_CONNECTED);
- (*ppAsyncReader = m_pAsyncReader)->AddRef();
+ (*ppAsyncReader = m_pAsyncReader)->AddRef();
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CStreamDriveThruInputPin::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CStreamDriveThruInputPin::CheckMediaType(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Stream
- ? S_OK
- : E_INVALIDARG;
+ return pmt->majortype == MEDIATYPE_Stream
+ ? S_OK
+ : E_INVALIDARG;
}
HRESULT CStreamDriveThruInputPin::CheckConnect(IPin* pPin)
{
- HRESULT hr;
+ HRESULT hr;
- if (FAILED(hr = __super::CheckConnect(pPin))) {
- return hr;
- }
+ if (FAILED(hr = __super::CheckConnect(pPin))) {
+ return hr;
+ }
- if (!CComQIPtr<IAsyncReader>(pPin)) {
- return E_NOINTERFACE;
- }
+ if (!CComQIPtr<IAsyncReader>(pPin)) {
+ return E_NOINTERFACE;
+ }
- return S_OK;
+ return S_OK;
}
HRESULT CStreamDriveThruInputPin::BreakConnect()
{
- HRESULT hr;
+ HRESULT hr;
- if (FAILED(hr = __super::BreakConnect())) {
- return hr;
- }
+ if (FAILED(hr = __super::BreakConnect())) {
+ return hr;
+ }
- m_pAsyncReader.Release();
+ m_pAsyncReader.Release();
- return S_OK;
+ return S_OK;
}
HRESULT CStreamDriveThruInputPin::CompleteConnect(IPin* pPin)
{
- HRESULT hr;
+ HRESULT hr;
- if (FAILED(hr = __super::CompleteConnect(pPin))) {
- return hr;
- }
+ if (FAILED(hr = __super::CompleteConnect(pPin))) {
+ return hr;
+ }
- CheckPointer(pPin, E_POINTER);
- m_pAsyncReader = pPin;
- CheckPointer(m_pAsyncReader, E_NOINTERFACE);
+ CheckPointer(pPin, E_POINTER);
+ m_pAsyncReader = pPin;
+ CheckPointer(m_pAsyncReader, E_NOINTERFACE);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CStreamDriveThruInputPin::BeginFlush()
{
- return E_UNEXPECTED;
+ return E_UNEXPECTED;
}
STDMETHODIMP CStreamDriveThruInputPin::EndFlush()
{
- return E_UNEXPECTED;
+ return E_UNEXPECTED;
}
//
@@ -471,7 +471,7 @@ STDMETHODIMP CStreamDriveThruInputPin::EndFlush()
//
CStreamDriveThruOutputPin::CStreamDriveThruOutputPin(TCHAR* pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseOutputPin(pName, pFilter, pLock, phr, L"Output")
+ : CBaseOutputPin(pName, pFilter, pLock, phr, L"Output")
{
}
@@ -481,128 +481,128 @@ CStreamDriveThruOutputPin::~CStreamDriveThruOutputPin()
HRESULT CStreamDriveThruOutputPin::GetStream(IStream** ppStream)
{
- CheckPointer(ppStream, E_POINTER);
+ CheckPointer(ppStream, E_POINTER);
- *ppStream = NULL;
+ *ppStream = NULL;
- CheckPointer(m_pStream, VFW_E_NOT_CONNECTED);
+ CheckPointer(m_pStream, VFW_E_NOT_CONNECTED);
- (*ppStream = m_pStream)->AddRef();
+ (*ppStream = m_pStream)->AddRef();
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CStreamDriveThruOutputPin::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CStreamDriveThruOutputPin::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties)
{
- ASSERT(pAlloc);
- ASSERT(pProperties);
+ ASSERT(pAlloc);
+ ASSERT(pProperties);
- HRESULT hr = NOERROR;
+ HRESULT hr = NOERROR;
- pProperties->cBuffers = 1;
- pProperties->cbBuffer = PACKETSIZE;
+ pProperties->cBuffers = 1;
+ pProperties->cbBuffer = PACKETSIZE;
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
- return hr;
- }
+ ALLOCATOR_PROPERTIES Actual;
+ if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
- if (Actual.cbBuffer < pProperties->cbBuffer) {
- return E_FAIL;
- }
- ASSERT(Actual.cBuffers == pProperties->cBuffers);
+ if (Actual.cbBuffer < pProperties->cbBuffer) {
+ return E_FAIL;
+ }
+ ASSERT(Actual.cBuffers == pProperties->cBuffers);
- return NOERROR;
+ return NOERROR;
}
HRESULT CStreamDriveThruOutputPin::CheckMediaType(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Stream
- ? S_OK
- : E_INVALIDARG;
+ return pmt->majortype == MEDIATYPE_Stream
+ ? S_OK
+ : E_INVALIDARG;
}
HRESULT CStreamDriveThruOutputPin::GetMediaType(int iPosition, CMediaType* pmt)
{
- CAutoLock cAutoLock(m_pLock);
+ CAutoLock cAutoLock(m_pLock);
- if (iPosition < 0) {
- return E_INVALIDARG;
- }
- if (iPosition > 0) {
- return VFW_S_NO_MORE_ITEMS;
- }
+ if (iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if (iPosition > 0) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
- pmt->majortype = MEDIATYPE_Stream;
- pmt->subtype = GUID_NULL;
- pmt->formattype = GUID_NULL;
- pmt->SetSampleSize(PACKETSIZE);
+ pmt->majortype = MEDIATYPE_Stream;
+ pmt->subtype = GUID_NULL;
+ pmt->formattype = GUID_NULL;
+ pmt->SetSampleSize(PACKETSIZE);
- return S_OK;
+ return S_OK;
}
HRESULT CStreamDriveThruOutputPin::CheckConnect(IPin* pPin)
{
- HRESULT hr;
+ HRESULT hr;
- if (FAILED(hr = __super::CheckConnect(pPin))) {
- return hr;
- }
+ if (FAILED(hr = __super::CheckConnect(pPin))) {
+ return hr;
+ }
- if (!CComQIPtr<IStream>(pPin)) {
- return E_NOINTERFACE;
- }
+ if (!CComQIPtr<IStream>(pPin)) {
+ return E_NOINTERFACE;
+ }
- return S_OK;
+ return S_OK;
}
HRESULT CStreamDriveThruOutputPin::BreakConnect()
{
- HRESULT hr;
+ HRESULT hr;
- if (FAILED(hr = __super::BreakConnect())) {
- return hr;
- }
+ if (FAILED(hr = __super::BreakConnect())) {
+ return hr;
+ }
- m_pStream.Release();
+ m_pStream.Release();
- return S_OK;
+ return S_OK;
}
HRESULT CStreamDriveThruOutputPin::CompleteConnect(IPin* pPin)
{
- HRESULT hr;
+ HRESULT hr;
- if (FAILED(hr = __super::CompleteConnect(pPin))) {
- return hr;
- }
+ if (FAILED(hr = __super::CompleteConnect(pPin))) {
+ return hr;
+ }
- CheckPointer(pPin, E_POINTER);
- m_pStream = pPin;
- CheckPointer(m_pStream, E_NOINTERFACE);
+ CheckPointer(pPin, E_POINTER);
+ m_pStream = pPin;
+ CheckPointer(m_pStream, E_NOINTERFACE);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CStreamDriveThruOutputPin::BeginFlush()
{
- return E_UNEXPECTED;
+ return E_UNEXPECTED;
}
STDMETHODIMP CStreamDriveThruOutputPin::EndFlush()
{
- return E_UNEXPECTED;
+ return E_UNEXPECTED;
}
STDMETHODIMP CStreamDriveThruOutputPin::Notify(IBaseFilter* pSender, Quality q)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
diff --git a/src/filters/parser/StreamDriveThru/StreamDriveThru.h b/src/filters/parser/StreamDriveThru/StreamDriveThru.h
index c4bb61f24..48eee3fcf 100644
--- a/src/filters/parser/StreamDriveThru/StreamDriveThru.h
+++ b/src/filters/parser/StreamDriveThru/StreamDriveThru.h
@@ -30,100 +30,100 @@
class CStreamDriveThruInputPin : public CBasePin
{
- CComQIPtr<IAsyncReader> m_pAsyncReader;
+ CComQIPtr<IAsyncReader> m_pAsyncReader;
public:
- CStreamDriveThruInputPin(TCHAR* pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
- virtual ~CStreamDriveThruInputPin();
+ CStreamDriveThruInputPin(TCHAR* pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
+ virtual ~CStreamDriveThruInputPin();
- HRESULT GetAsyncReader(IAsyncReader** ppAsyncReader);
+ HRESULT GetAsyncReader(IAsyncReader** ppAsyncReader);
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT CheckMediaType(const CMediaType* pmt);
- HRESULT CheckConnect(IPin* pPin);
- HRESULT BreakConnect();
- HRESULT CompleteConnect(IPin* pPin);
+ HRESULT CheckConnect(IPin* pPin);
+ HRESULT BreakConnect();
+ HRESULT CompleteConnect(IPin* pPin);
- STDMETHODIMP BeginFlush();
- STDMETHODIMP EndFlush();
+ STDMETHODIMP BeginFlush();
+ STDMETHODIMP EndFlush();
};
class CStreamDriveThruOutputPin : public CBaseOutputPin
{
- CComQIPtr<IStream> m_pStream;
+ CComQIPtr<IStream> m_pStream;
public:
- CStreamDriveThruOutputPin(TCHAR* pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
- virtual ~CStreamDriveThruOutputPin();
+ CStreamDriveThruOutputPin(TCHAR* pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
+ virtual ~CStreamDriveThruOutputPin();
- HRESULT GetStream(IStream** ppStream);
+ HRESULT GetStream(IStream** ppStream);
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- HRESULT DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT CheckMediaType(const CMediaType* pmt);
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
+ HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT GetMediaType(int iPosition, CMediaType* pmt);
- HRESULT CheckConnect(IPin* pPin);
- HRESULT BreakConnect();
- HRESULT CompleteConnect(IPin* pPin);
+ HRESULT CheckConnect(IPin* pPin);
+ HRESULT BreakConnect();
+ HRESULT CompleteConnect(IPin* pPin);
- STDMETHODIMP BeginFlush();
- STDMETHODIMP EndFlush();
+ STDMETHODIMP BeginFlush();
+ STDMETHODIMP EndFlush();
- STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
+ STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
};
class __declspec(uuid("534FE6FD-F1F0-4aec-9F45-FF397320CE33"))
- CStreamDriveThruFilter : public CBaseFilter, protected CAMThread, public IMediaSeeking
+ CStreamDriveThruFilter : public CBaseFilter, protected CAMThread, public IMediaSeeking
{
- CCritSec m_csLock;
+ CCritSec m_csLock;
- CStreamDriveThruInputPin* m_pInput;
- CStreamDriveThruOutputPin* m_pOutput;
+ CStreamDriveThruInputPin* m_pInput;
+ CStreamDriveThruOutputPin* m_pOutput;
protected:
- enum {CMD_EXIT, CMD_STOP, CMD_PAUSE, CMD_RUN};
- DWORD ThreadProc();
+ enum {CMD_EXIT, CMD_STOP, CMD_PAUSE, CMD_RUN};
+ DWORD ThreadProc();
- LONGLONG m_position;
+ LONGLONG m_position;
public:
- CStreamDriveThruFilter(LPUNKNOWN pUnk, HRESULT* phr);
- virtual ~CStreamDriveThruFilter();
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- int GetPinCount();
- CBasePin* GetPin(int n);
-
- STDMETHODIMP Stop();
- STDMETHODIMP Pause();
- STDMETHODIMP Run(REFERENCE_TIME tStart);
-
- // IMediaSeeking
-
- STDMETHODIMP GetCapabilities(DWORD* pCapabilities);
- STDMETHODIMP CheckCapabilities(DWORD* pCapabilities);
- STDMETHODIMP IsFormatSupported(const GUID* pFormat);
- STDMETHODIMP QueryPreferredFormat(GUID* pFormat);
- STDMETHODIMP GetTimeFormat(GUID* pFormat);
- STDMETHODIMP IsUsingTimeFormat(const GUID* pFormat);
- STDMETHODIMP SetTimeFormat(const GUID* pFormat);
- STDMETHODIMP GetDuration(LONGLONG* pDuration);
- STDMETHODIMP GetStopPosition(LONGLONG* pStop);
- STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
- STDMETHODIMP ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat);
- STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
- STDMETHODIMP GetPositions(LONGLONG* pCurrent, LONGLONG* pStop);
- STDMETHODIMP GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest);
- STDMETHODIMP SetRate(double dRate);
- STDMETHODIMP GetRate(double* pdRate);
- STDMETHODIMP GetPreroll(LONGLONG* pllPreroll);
+ CStreamDriveThruFilter(LPUNKNOWN pUnk, HRESULT* phr);
+ virtual ~CStreamDriveThruFilter();
+
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ int GetPinCount();
+ CBasePin* GetPin(int n);
+
+ STDMETHODIMP Stop();
+ STDMETHODIMP Pause();
+ STDMETHODIMP Run(REFERENCE_TIME tStart);
+
+ // IMediaSeeking
+
+ STDMETHODIMP GetCapabilities(DWORD* pCapabilities);
+ STDMETHODIMP CheckCapabilities(DWORD* pCapabilities);
+ STDMETHODIMP IsFormatSupported(const GUID* pFormat);
+ STDMETHODIMP QueryPreferredFormat(GUID* pFormat);
+ STDMETHODIMP GetTimeFormat(GUID* pFormat);
+ STDMETHODIMP IsUsingTimeFormat(const GUID* pFormat);
+ STDMETHODIMP SetTimeFormat(const GUID* pFormat);
+ STDMETHODIMP GetDuration(LONGLONG* pDuration);
+ STDMETHODIMP GetStopPosition(LONGLONG* pStop);
+ STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
+ STDMETHODIMP ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat);
+ STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
+ STDMETHODIMP GetPositions(LONGLONG* pCurrent, LONGLONG* pStop);
+ STDMETHODIMP GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest);
+ STDMETHODIMP SetRate(double dRate);
+ STDMETHODIMP GetRate(double* pdRate);
+ STDMETHODIMP GetPreroll(LONGLONG* pllPreroll);
};
diff --git a/src/filters/reader/CDDAReader/CDDAReader.cpp b/src/filters/reader/CDDAReader/CDDAReader.cpp
index d5558e47a..5b33b21e2 100644
--- a/src/filters/reader/CDDAReader/CDDAReader.cpp
+++ b/src/filters/reader/CDDAReader/CDDAReader.cpp
@@ -29,51 +29,51 @@
#include "../../../DSUtil/DSUtil.h"
#define RAW_SECTOR_SIZE 2352
-#define MSF2UINT(hgs) ((hgs[1]*4500)+(hgs[2]*75)+(hgs[3]))
+#define MSF2UINT(hgs) ((hgs[1] * 4500) + (hgs[2] * 75) + (hgs[3]))
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_WAVE},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_WAVE},
};
const AMOVIESETUP_PIN sudOpPin[] = {
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut},
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CCDDAReader), CCDDAReaderName, MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
+ {&__uuidof(CCDDAReader), CCDDAReaderName, MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CCDDAReader>, NULL, &sudFilter[0]}
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CCDDAReader>, NULL, &sudFilter[0]}
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{54A35221-2C8D-4a31-A5DF-6D809847E393}"),
- _T("0"), _T("0,4,,52494646,8,4,,43444441")); // "RIFFxxxxCDDA"
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{54A35221-2C8D-4a31-A5DF-6D809847E393}"),
+ _T("0"), _T("0,4,,52494646,8,4,,43444441")); // "RIFFxxxxCDDA"
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{54A35221-2C8D-4a31-A5DF-6D809847E393}"),
- _T("Source Filter"), _T("{54A35221-2C8D-4a31-A5DF-6D809847E393}"));
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{54A35221-2C8D-4a31-A5DF-6D809847E393}"),
+ _T("Source Filter"), _T("{54A35221-2C8D-4a31-A5DF-6D809847E393}"));
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".cda"),
- _T("Source Filter"), _T("{54A35221-2C8D-4a31-A5DF-6D809847E393}"));
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".cda"),
+ _T("Source Filter"), _T("{54A35221-2C8D-4a31-A5DF-6D809847E393}"));
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{54A35221-2C8D-4a31-A5DF-6D809847E393}"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".cda"));
+ DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{54A35221-2C8D-4a31-A5DF-6D809847E393}"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".cda"));
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -87,11 +87,11 @@ CFilterApp theApp;
//
CCDDAReader::CCDDAReader(IUnknown* pUnk, HRESULT* phr)
- : CAsyncReader(NAME("CCDDAReader"), pUnk, &m_stream, phr, __uuidof(this))
+ : CAsyncReader(NAME("CCDDAReader"), pUnk, &m_stream, phr, __uuidof(this))
{
- if (phr) {
- *phr = S_OK;
- }
+ if (phr) {
+ *phr = S_OK;
+ }
}
CCDDAReader::~CCDDAReader()
@@ -100,393 +100,393 @@ CCDDAReader::~CCDDAReader()
STDMETHODIMP CCDDAReader::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- QI(IFileSourceFilter)
- QI2(IAMMediaContent)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IFileSourceFilter)
+ QI2(IAMMediaContent)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// IFileSourceFilter
STDMETHODIMP CCDDAReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
- if (!m_stream.Load(pszFileName)) {
- return E_FAIL;
- }
+ if (!m_stream.Load(pszFileName)) {
+ return E_FAIL;
+ }
- m_fn = pszFileName;
+ m_fn = pszFileName;
- CMediaType mt;
- mt.majortype = MEDIATYPE_Stream;
- mt.subtype = MEDIASUBTYPE_WAVE;
- m_mt = mt;
+ CMediaType mt;
+ mt.majortype = MEDIATYPE_Stream;
+ mt.subtype = MEDIASUBTYPE_WAVE;
+ m_mt = mt;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CCDDAReader::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
{
- CheckPointer(ppszFileName, E_POINTER);
+ CheckPointer(ppszFileName, E_POINTER);
- *ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR));
- if (!(*ppszFileName)) {
- return E_OUTOFMEMORY;
- }
+ *ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength() + 1) * sizeof(WCHAR));
+ if (!(*ppszFileName)) {
+ return E_OUTOFMEMORY;
+ }
- wcscpy_s(*ppszFileName, m_fn.GetLength() + 1, m_fn);
+ wcscpy_s(*ppszFileName, m_fn.GetLength() + 1, m_fn);
- return S_OK;
+ return S_OK;
}
// IAMMediaContent
STDMETHODIMP CCDDAReader::GetTypeInfoCount(UINT* pctinfo)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CCDDAReader::GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CCDDAReader::GetIDsOfNames(REFIID riid, OLECHAR** rgszNames, UINT cNames, LCID lcid, DISPID* rgdispid)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CCDDAReader::Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult, EXCEPINFO* pexcepinfo, UINT* puArgErr)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CCDDAReader::get_AuthorName(BSTR* pbstrAuthorName)
{
- CheckPointer(pbstrAuthorName, E_POINTER);
- CString str = m_stream.m_trackArtist;
- if (str.IsEmpty()) {
- str = m_stream.m_discArtist;
- }
- *pbstrAuthorName = str.AllocSysString();
- return S_OK;
+ CheckPointer(pbstrAuthorName, E_POINTER);
+ CString str = m_stream.m_trackArtist;
+ if (str.IsEmpty()) {
+ str = m_stream.m_discArtist;
+ }
+ *pbstrAuthorName = str.AllocSysString();
+ return S_OK;
}
STDMETHODIMP CCDDAReader::get_Title(BSTR* pbstrTitle)
{
- CheckPointer(pbstrTitle, E_POINTER);
- CString str = m_stream.m_trackTitle;
- if (str.IsEmpty()) {
- str = m_stream.m_discTitle;
- }
- *pbstrTitle = str.AllocSysString();
- return S_OK;
+ CheckPointer(pbstrTitle, E_POINTER);
+ CString str = m_stream.m_trackTitle;
+ if (str.IsEmpty()) {
+ str = m_stream.m_discTitle;
+ }
+ *pbstrTitle = str.AllocSysString();
+ return S_OK;
}
STDMETHODIMP CCDDAReader::get_Rating(BSTR* pbstrRating)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CCDDAReader::get_Description(BSTR* pbstrDescription)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CCDDAReader::get_Copyright(BSTR* pbstrCopyright)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CCDDAReader::get_BaseURL(BSTR* pbstrBaseURL)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CCDDAReader::get_LogoURL(BSTR* pbstrLogoURL)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CCDDAReader::get_LogoIconURL(BSTR* pbstrLogoURL)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CCDDAReader::get_WatermarkURL(BSTR* pbstrWatermarkURL)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CCDDAReader::get_MoreInfoURL(BSTR* pbstrMoreInfoURL)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CCDDAReader::get_MoreInfoBannerImage(BSTR* pbstrMoreInfoBannerImage)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CCDDAReader::get_MoreInfoBannerURL(BSTR* pbstrMoreInfoBannerURL)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CCDDAReader::get_MoreInfoText(BSTR* pbstrMoreInfoText)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// CCDDAStream
CCDDAStream::CCDDAStream()
{
- m_hDrive = INVALID_HANDLE_VALUE;
+ m_hDrive = INVALID_HANDLE_VALUE;
- m_llPosition = m_llLength = 0;
+ m_llPosition = m_llLength = 0;
- memset(&m_TOC, 0, sizeof(m_TOC));
- m_nStartSector = m_nStopSector = 0;
+ memset(&m_TOC, 0, sizeof(m_TOC));
+ m_nStartSector = m_nStopSector = 0;
- memset(&m_header, 0, sizeof(m_header));
- m_header.riff.hdr.chunkID = RIFFID;
- m_header.riff.WAVE = WAVEID;
- m_header.frm.hdr.chunkID = FormatID;
- m_header.frm.hdr.chunkSize = sizeof(m_header.frm.pcm);
- m_header.frm.pcm.wf.wFormatTag = WAVE_FORMAT_PCM;
- m_header.frm.pcm.wf.nSamplesPerSec = 44100;
- m_header.frm.pcm.wf.nChannels = 2;
- m_header.frm.pcm.wBitsPerSample = 16;
- m_header.frm.pcm.wf.nBlockAlign = m_header.frm.pcm.wf.nChannels * m_header.frm.pcm.wBitsPerSample / 8;
- m_header.frm.pcm.wf.nAvgBytesPerSec = m_header.frm.pcm.wf.nSamplesPerSec * m_header.frm.pcm.wf.nBlockAlign;
- m_header.data.hdr.chunkID = DataID;
+ memset(&m_header, 0, sizeof(m_header));
+ m_header.riff.hdr.chunkID = RIFFID;
+ m_header.riff.WAVE = WAVEID;
+ m_header.frm.hdr.chunkID = FormatID;
+ m_header.frm.hdr.chunkSize = sizeof(m_header.frm.pcm);
+ m_header.frm.pcm.wf.wFormatTag = WAVE_FORMAT_PCM;
+ m_header.frm.pcm.wf.nSamplesPerSec = 44100;
+ m_header.frm.pcm.wf.nChannels = 2;
+ m_header.frm.pcm.wBitsPerSample = 16;
+ m_header.frm.pcm.wf.nBlockAlign = m_header.frm.pcm.wf.nChannels * m_header.frm.pcm.wBitsPerSample / 8;
+ m_header.frm.pcm.wf.nAvgBytesPerSec = m_header.frm.pcm.wf.nSamplesPerSec * m_header.frm.pcm.wf.nBlockAlign;
+ m_header.data.hdr.chunkID = DataID;
}
CCDDAStream::~CCDDAStream()
{
- if (m_hDrive != INVALID_HANDLE_VALUE) {
- CloseHandle(m_hDrive);
- m_hDrive = INVALID_HANDLE_VALUE;
- }
+ if (m_hDrive != INVALID_HANDLE_VALUE) {
+ CloseHandle(m_hDrive);
+ m_hDrive = INVALID_HANDLE_VALUE;
+ }
}
bool CCDDAStream::Load(const WCHAR* fnw)
{
- CString path(fnw);
-
- int iDriveLetter = path.Find(_T(":\\"))-1;
- int iTrackIndex = CString(path).MakeLower().Find(_T(".cda"))-1;
- if (iDriveLetter < 0 || iTrackIndex <= iDriveLetter) {
- return false;
- }
-
- CString drive = CString(_T("\\\\.\\")) + path[iDriveLetter] + _T(":");
- while (iTrackIndex > 0 && _istdigit(path[iTrackIndex-1])) {
- iTrackIndex--;
- }
- if (1 != _stscanf_s(path.Mid(iTrackIndex), _T("%d"), &iTrackIndex)) {
- return false;
- }
-
- if (m_hDrive != INVALID_HANDLE_VALUE) {
- CloseHandle(m_hDrive);
- m_hDrive = INVALID_HANDLE_VALUE;
- }
-
- m_hDrive = CreateFile(drive, GENERIC_READ, FILE_SHARE_READ, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_READONLY|FILE_FLAG_SEQUENTIAL_SCAN, (HANDLE)NULL);
- if (m_hDrive == INVALID_HANDLE_VALUE) {
- return false;
- }
-
- DWORD BytesReturned;
- if (!DeviceIoControl(m_hDrive, IOCTL_CDROM_READ_TOC, NULL, 0, &m_TOC, sizeof(m_TOC), &BytesReturned, 0)
- || !(m_TOC.FirstTrack <= iTrackIndex && iTrackIndex <= m_TOC.LastTrack)) {
- CloseHandle(m_hDrive);
- m_hDrive = INVALID_HANDLE_VALUE;
- return false;
- }
-
- // MMC-3 Draft Revision 10g: Table 222 - Q Sub-channel control field
- m_TOC.TrackData[iTrackIndex-1].Control &= 5;
- if (!(m_TOC.TrackData[iTrackIndex-1].Control == 0 || m_TOC.TrackData[iTrackIndex-1].Control == 1)) {
- CloseHandle(m_hDrive);
- m_hDrive = INVALID_HANDLE_VALUE;
- return false;
- }
-
- if (m_TOC.TrackData[iTrackIndex-1].Control&8) {
- m_header.frm.pcm.wf.nChannels = 4;
- }
-
- m_nStartSector = MSF2UINT(m_TOC.TrackData[iTrackIndex-1].Address) - 150;//MSF2UINT(m_TOC.TrackData[0].Address);
- m_nStopSector = MSF2UINT(m_TOC.TrackData[iTrackIndex].Address) - 150;//MSF2UINT(m_TOC.TrackData[0].Address);
-
- m_llLength = (m_nStopSector-m_nStartSector)*RAW_SECTOR_SIZE;
-
- m_header.riff.hdr.chunkSize = (long)(m_llLength + sizeof(m_header) - 8);
- m_header.data.hdr.chunkSize = (long)(m_llLength);
-
- do {
- CDROM_READ_TOC_EX TOCEx;
- memset(&TOCEx, 0, sizeof(TOCEx));
- TOCEx.Format = CDROM_READ_TOC_EX_FORMAT_CDTEXT;
- TOCEx.SessionTrack = iTrackIndex;
- WORD size = 0;
- ASSERT(MINIMUM_CDROM_READ_TOC_EX_SIZE == sizeof(size));
- if (!DeviceIoControl(m_hDrive, IOCTL_CDROM_READ_TOC_EX, &TOCEx, sizeof(TOCEx), &size, sizeof(size), &BytesReturned, 0)) {
- break;
- }
-
- size = ((size>>8)|(size<<8)) + sizeof(size);
-
- CAutoVectorPtr<BYTE> pCDTextData;
- pCDTextData.Allocate(size);
- memset(pCDTextData, 0, size);
-
- if (!DeviceIoControl(m_hDrive, IOCTL_CDROM_READ_TOC_EX, &TOCEx, sizeof(TOCEx), pCDTextData, size, &BytesReturned, 0)) {
- break;
- }
-
- size = (WORD)(BytesReturned - sizeof(CDROM_TOC_CD_TEXT_DATA));
- CDROM_TOC_CD_TEXT_DATA_BLOCK* pDesc = ((CDROM_TOC_CD_TEXT_DATA*)(BYTE*)pCDTextData)->Descriptors;
-
- CStringArray str[16];
- for (int i = 0; i < 16; i++) {
- str[i].SetSize(1+m_TOC.LastTrack);
- }
- CString last;
-
- for (int i = 0; size >= sizeof(CDROM_TOC_CD_TEXT_DATA_BLOCK); i++, size -= sizeof(CDROM_TOC_CD_TEXT_DATA_BLOCK), pDesc++) {
- if (pDesc->TrackNumber > m_TOC.LastTrack) {
- continue;
- }
-
- const int lenU = _countof(pDesc->Text);
- const int lenW = _countof(pDesc->WText);
-
- CString text = !pDesc->Unicode
- ? CString(CStringA((CHAR*)pDesc->Text, lenU))
- : CString(CStringW((WCHAR*)pDesc->WText, lenW));
-
- int tlen = text.GetLength();
- CString tmp = (tlen < 12-1)
- ? (!pDesc->Unicode
- ? CString(CStringA((CHAR*)pDesc->Text+tlen+1, lenU-(tlen+1)))
- : CString(CStringW((WCHAR*)pDesc->WText+tlen+1, lenW-(tlen+1))))
- : _T("");
-
- if ((pDesc->PackType -= 0x80) >= 0x10) {
- continue;
- }
-
- if (pDesc->CharacterPosition == 0) {
- str[pDesc->PackType][pDesc->TrackNumber] = text;
- } else if (pDesc->CharacterPosition <= 0xf) {
- if (pDesc->CharacterPosition < 0xf && last.GetLength() > 0) {
- str[pDesc->PackType][pDesc->TrackNumber] = last + text;
- } else {
- str[pDesc->PackType][pDesc->TrackNumber] += text;
- }
- }
-
- last = tmp;
- }
-
- m_discTitle = str[0][0];
- m_trackTitle = str[0][iTrackIndex];
- m_discArtist = str[1][0];
- m_trackArtist = str[1][iTrackIndex];
- } while (0);
-
-
- return true;
+ CString path(fnw);
+
+ int iDriveLetter = path.Find(_T(":\\")) - 1;
+ int iTrackIndex = CString(path).MakeLower().Find(_T(".cda")) - 1;
+ if (iDriveLetter < 0 || iTrackIndex <= iDriveLetter) {
+ return false;
+ }
+
+ CString drive = CString(_T("\\\\.\\")) + path[iDriveLetter] + _T(":");
+ while (iTrackIndex > 0 && _istdigit(path[iTrackIndex - 1])) {
+ iTrackIndex--;
+ }
+ if (1 != _stscanf_s(path.Mid(iTrackIndex), _T("%d"), &iTrackIndex)) {
+ return false;
+ }
+
+ if (m_hDrive != INVALID_HANDLE_VALUE) {
+ CloseHandle(m_hDrive);
+ m_hDrive = INVALID_HANDLE_VALUE;
+ }
+
+ m_hDrive = CreateFile(drive, GENERIC_READ, FILE_SHARE_READ, NULL,
+ OPEN_EXISTING, FILE_ATTRIBUTE_READONLY | FILE_FLAG_SEQUENTIAL_SCAN, (HANDLE)NULL);
+ if (m_hDrive == INVALID_HANDLE_VALUE) {
+ return false;
+ }
+
+ DWORD BytesReturned;
+ if (!DeviceIoControl(m_hDrive, IOCTL_CDROM_READ_TOC, NULL, 0, &m_TOC, sizeof(m_TOC), &BytesReturned, 0)
+ || !(m_TOC.FirstTrack <= iTrackIndex && iTrackIndex <= m_TOC.LastTrack)) {
+ CloseHandle(m_hDrive);
+ m_hDrive = INVALID_HANDLE_VALUE;
+ return false;
+ }
+
+ // MMC-3 Draft Revision 10g: Table 222 - Q Sub-channel control field
+ m_TOC.TrackData[iTrackIndex - 1].Control &= 5;
+ if (!(m_TOC.TrackData[iTrackIndex - 1].Control == 0 || m_TOC.TrackData[iTrackIndex - 1].Control == 1)) {
+ CloseHandle(m_hDrive);
+ m_hDrive = INVALID_HANDLE_VALUE;
+ return false;
+ }
+
+ if (m_TOC.TrackData[iTrackIndex - 1].Control & 8) {
+ m_header.frm.pcm.wf.nChannels = 4;
+ }
+
+ m_nStartSector = MSF2UINT(m_TOC.TrackData[iTrackIndex - 1].Address) - 150; //MSF2UINT(m_TOC.TrackData[0].Address);
+ m_nStopSector = MSF2UINT(m_TOC.TrackData[iTrackIndex].Address) - 150;//MSF2UINT(m_TOC.TrackData[0].Address);
+
+ m_llLength = (m_nStopSector - m_nStartSector) * RAW_SECTOR_SIZE;
+
+ m_header.riff.hdr.chunkSize = (long)(m_llLength + sizeof(m_header) - 8);
+ m_header.data.hdr.chunkSize = (long)(m_llLength);
+
+ do {
+ CDROM_READ_TOC_EX TOCEx;
+ memset(&TOCEx, 0, sizeof(TOCEx));
+ TOCEx.Format = CDROM_READ_TOC_EX_FORMAT_CDTEXT;
+ TOCEx.SessionTrack = iTrackIndex;
+ WORD size = 0;
+ ASSERT(MINIMUM_CDROM_READ_TOC_EX_SIZE == sizeof(size));
+ if (!DeviceIoControl(m_hDrive, IOCTL_CDROM_READ_TOC_EX, &TOCEx, sizeof(TOCEx), &size, sizeof(size), &BytesReturned, 0)) {
+ break;
+ }
+
+ size = ((size >> 8) | (size << 8)) + sizeof(size);
+
+ CAutoVectorPtr<BYTE> pCDTextData;
+ pCDTextData.Allocate(size);
+ memset(pCDTextData, 0, size);
+
+ if (!DeviceIoControl(m_hDrive, IOCTL_CDROM_READ_TOC_EX, &TOCEx, sizeof(TOCEx), pCDTextData, size, &BytesReturned, 0)) {
+ break;
+ }
+
+ size = (WORD)(BytesReturned - sizeof(CDROM_TOC_CD_TEXT_DATA));
+ CDROM_TOC_CD_TEXT_DATA_BLOCK* pDesc = ((CDROM_TOC_CD_TEXT_DATA*)(BYTE*)pCDTextData)->Descriptors;
+
+ CStringArray str[16];
+ for (int i = 0; i < 16; i++) {
+ str[i].SetSize(1 + m_TOC.LastTrack);
+ }
+ CString last;
+
+ for (int i = 0; size >= sizeof(CDROM_TOC_CD_TEXT_DATA_BLOCK); i++, size -= sizeof(CDROM_TOC_CD_TEXT_DATA_BLOCK), pDesc++) {
+ if (pDesc->TrackNumber > m_TOC.LastTrack) {
+ continue;
+ }
+
+ const int lenU = _countof(pDesc->Text);
+ const int lenW = _countof(pDesc->WText);
+
+ CString text = !pDesc->Unicode
+ ? CString(CStringA((CHAR*)pDesc->Text, lenU))
+ : CString(CStringW((WCHAR*)pDesc->WText, lenW));
+
+ int tlen = text.GetLength();
+ CString tmp = (tlen < 12 - 1)
+ ? (!pDesc->Unicode
+ ? CString(CStringA((CHAR*)pDesc->Text + tlen + 1, lenU - (tlen + 1)))
+ : CString(CStringW((WCHAR*)pDesc->WText + tlen + 1, lenW - (tlen + 1))))
+ : _T("");
+
+ if ((pDesc->PackType -= 0x80) >= 0x10) {
+ continue;
+ }
+
+ if (pDesc->CharacterPosition == 0) {
+ str[pDesc->PackType][pDesc->TrackNumber] = text;
+ } else if (pDesc->CharacterPosition <= 0xf) {
+ if (pDesc->CharacterPosition < 0xf && last.GetLength() > 0) {
+ str[pDesc->PackType][pDesc->TrackNumber] = last + text;
+ } else {
+ str[pDesc->PackType][pDesc->TrackNumber] += text;
+ }
+ }
+
+ last = tmp;
+ }
+
+ m_discTitle = str[0][0];
+ m_trackTitle = str[0][iTrackIndex];
+ m_discArtist = str[1][0];
+ m_trackArtist = str[1][iTrackIndex];
+ } while (0);
+
+
+ return true;
}
HRESULT CCDDAStream::SetPointer(LONGLONG llPos)
{
- if (llPos < 0 || llPos > m_llLength) {
- return S_FALSE;
- }
- m_llPosition = llPos;
- return S_OK;
+ if (llPos < 0 || llPos > m_llLength) {
+ return S_FALSE;
+ }
+ m_llPosition = llPos;
+ return S_OK;
}
HRESULT CCDDAStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWORD pdwBytesRead)
{
- CAutoLock lck(&m_csLock);
+ CAutoLock lck(&m_csLock);
- BYTE buff[RAW_SECTOR_SIZE];
+ BYTE buff[RAW_SECTOR_SIZE];
- PBYTE pbBufferOrg = pbBuffer;
- LONGLONG pos = m_llPosition;
- size_t len = (size_t)dwBytesToRead;
+ PBYTE pbBufferOrg = pbBuffer;
+ LONGLONG pos = m_llPosition;
+ size_t len = (size_t)dwBytesToRead;
- if (pos < sizeof(m_header) && len > 0) {
- size_t l = (size_t)min(len, sizeof(m_header) - pos);
- memcpy(pbBuffer, &((BYTE*)&m_header)[pos], l);
- pbBuffer += l;
- pos += l;
- len -= l;
- }
+ if (pos < sizeof(m_header) && len > 0) {
+ size_t l = (size_t)min(len, sizeof(m_header) - pos);
+ memcpy(pbBuffer, &((BYTE*)&m_header)[pos], l);
+ pbBuffer += l;
+ pos += l;
+ len -= l;
+ }
- pos -= sizeof(m_header);
+ pos -= sizeof(m_header);
- while (pos >= 0 && pos < m_llLength && len > 0) {
- RAW_READ_INFO rawreadinfo;
- rawreadinfo.SectorCount = 1;
- rawreadinfo.TrackMode = CDDA;
+ while (pos >= 0 && pos < m_llLength && len > 0) {
+ RAW_READ_INFO rawreadinfo;
+ rawreadinfo.SectorCount = 1;
+ rawreadinfo.TrackMode = CDDA;
- UINT sector = m_nStartSector + int(pos/RAW_SECTOR_SIZE);
- __int64 offset = pos%RAW_SECTOR_SIZE;
+ UINT sector = m_nStartSector + int(pos / RAW_SECTOR_SIZE);
+ __int64 offset = pos % RAW_SECTOR_SIZE;
- rawreadinfo.DiskOffset.QuadPart = sector*2048;
- DWORD BytesReturned = 0;
- BOOL b = DeviceIoControl(
- m_hDrive, IOCTL_CDROM_RAW_READ,
- &rawreadinfo, sizeof(rawreadinfo),
- buff, RAW_SECTOR_SIZE,
- &BytesReturned, 0);
- UNREFERENCED_PARAMETER(b);
+ rawreadinfo.DiskOffset.QuadPart = sector * 2048;
+ DWORD BytesReturned = 0;
+ BOOL b = DeviceIoControl(
+ m_hDrive, IOCTL_CDROM_RAW_READ,
+ &rawreadinfo, sizeof(rawreadinfo),
+ buff, RAW_SECTOR_SIZE,
+ &BytesReturned, 0);
+ UNREFERENCED_PARAMETER(b);
- size_t l = (size_t)min(min(len, size_t(RAW_SECTOR_SIZE - offset)), size_t(m_llLength - pos));
- memcpy(pbBuffer, &buff[offset], l);
+ size_t l = (size_t)min(min(len, size_t(RAW_SECTOR_SIZE - offset)), size_t(m_llLength - pos));
+ memcpy(pbBuffer, &buff[offset], l);
- pbBuffer += l;
- pos += l;
- len -= l;
- }
+ pbBuffer += l;
+ pos += l;
+ len -= l;
+ }
- if (pdwBytesRead) {
- *pdwBytesRead = pbBuffer - pbBufferOrg;
- }
- m_llPosition += pbBuffer - pbBufferOrg;
+ if (pdwBytesRead) {
+ *pdwBytesRead = pbBuffer - pbBufferOrg;
+ }
+ m_llPosition += pbBuffer - pbBufferOrg;
- return S_OK;
+ return S_OK;
}
LONGLONG CCDDAStream::Size(LONGLONG* pSizeAvailable)
{
- LONGLONG size = sizeof(m_header) + m_llLength;
- if (pSizeAvailable) {
- *pSizeAvailable = size;
- }
- return size;
+ LONGLONG size = sizeof(m_header) + m_llLength;
+ if (pSizeAvailable) {
+ *pSizeAvailable = size;
+ }
+ return size;
}
DWORD CCDDAStream::Alignment()
{
- return 1;
+ return 1;
}
void CCDDAStream::Lock()
{
- m_csLock.Lock();
+ m_csLock.Lock();
}
void CCDDAStream::Unlock()
{
- m_csLock.Unlock();
+ m_csLock.Unlock();
}
diff --git a/src/filters/reader/CDDAReader/CDDAReader.h b/src/filters/reader/CDDAReader/CDDAReader.h
index af33cae90..2ed9f2daf 100644
--- a/src/filters/reader/CDDAReader/CDDAReader.h
+++ b/src/filters/reader/CDDAReader/CDDAReader.h
@@ -33,104 +33,104 @@
#define CCDDAReaderName L"MPC CDDA Reader"
typedef struct {
- UINT chunkID;
- long chunkSize;
+ UINT chunkID;
+ long chunkSize;
} ChunkHeader;
#define RIFFID 'FFIR'
#define WAVEID 'EVAW'
typedef struct {
- ChunkHeader hdr;
- UINT WAVE;
+ ChunkHeader hdr;
+ UINT WAVE;
} RIFFChunk;
#define FormatID ' tmf'
typedef struct {
- ChunkHeader hdr;
- PCMWAVEFORMAT pcm;
+ ChunkHeader hdr;
+ PCMWAVEFORMAT pcm;
} FormatChunk;
#define DataID 'atad'
typedef struct {
- ChunkHeader hdr;
+ ChunkHeader hdr;
} DataChunk;
typedef struct {
- RIFFChunk riff;
- FormatChunk frm;
- DataChunk data;
+ RIFFChunk riff;
+ FormatChunk frm;
+ DataChunk data;
} WAVEChunck;
class CCDDAStream : public CAsyncStream
{
private:
- CCritSec m_csLock;
+ CCritSec m_csLock;
- LONGLONG m_llPosition, m_llLength;
+ LONGLONG m_llPosition, m_llLength;
- HANDLE m_hDrive;
- CDROM_TOC m_TOC;
- UINT m_nFirstSector, m_nStartSector, m_nStopSector;
+ HANDLE m_hDrive;
+ CDROM_TOC m_TOC;
+ UINT m_nFirstSector, m_nStartSector, m_nStopSector;
- WAVEChunck m_header;
+ WAVEChunck m_header;
public:
- CCDDAStream();
- virtual ~CCDDAStream();
+ CCDDAStream();
+ virtual ~CCDDAStream();
- CString m_discTitle, m_trackTitle;
- CString m_discArtist, m_trackArtist;
+ CString m_discTitle, m_trackTitle;
+ CString m_discArtist, m_trackArtist;
- bool Load(const WCHAR* fnw);
+ bool Load(const WCHAR* fnw);
- // overrides
- HRESULT SetPointer(LONGLONG llPos);
- HRESULT Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWORD pdwBytesRead);
- LONGLONG Size(LONGLONG* pSizeAvailable);
- DWORD Alignment();
- void Lock();
- void Unlock();
+ // overrides
+ HRESULT SetPointer(LONGLONG llPos);
+ HRESULT Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWORD pdwBytesRead);
+ LONGLONG Size(LONGLONG* pSizeAvailable);
+ DWORD Alignment();
+ void Lock();
+ void Unlock();
};
class __declspec(uuid("54A35221-2C8D-4a31-A5DF-6D809847E393"))
- CCDDAReader
- : public CAsyncReader
- , public IFileSourceFilter
- , public IAMMediaContent
+ CCDDAReader
+ : public CAsyncReader
+ , public IFileSourceFilter
+ , public IAMMediaContent
{
- CCDDAStream m_stream;
- CStringW m_fn;
+ CCDDAStream m_stream;
+ CStringW m_fn;
public:
- CCDDAReader(IUnknown* pUnk, HRESULT* phr);
- ~CCDDAReader();
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // IFileSourceFilter
-
- STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
-
- // IAMMediaContent
-
- STDMETHODIMP GetTypeInfoCount(UINT* pctinfo);
- STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo);
- STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** rgszNames, UINT cNames, LCID lcid, DISPID* rgdispid);
- STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult, EXCEPINFO* pexcepinfo, UINT* puArgErr);
-
- STDMETHODIMP get_AuthorName(BSTR* pbstrAuthorName);
- STDMETHODIMP get_Title(BSTR* pbstrTitle);
- STDMETHODIMP get_Rating(BSTR* pbstrRating);
- STDMETHODIMP get_Description(BSTR* pbstrDescription);
- STDMETHODIMP get_Copyright(BSTR* pbstrCopyright);
- STDMETHODIMP get_BaseURL(BSTR* pbstrBaseURL);
- STDMETHODIMP get_LogoURL(BSTR* pbstrLogoURL);
- STDMETHODIMP get_LogoIconURL(BSTR* pbstrLogoURL);
- STDMETHODIMP get_WatermarkURL(BSTR* pbstrWatermarkURL);
- STDMETHODIMP get_MoreInfoURL(BSTR* pbstrMoreInfoURL);
- STDMETHODIMP get_MoreInfoBannerImage(BSTR* pbstrMoreInfoBannerImage);
- STDMETHODIMP get_MoreInfoBannerURL(BSTR* pbstrMoreInfoBannerURL);
- STDMETHODIMP get_MoreInfoText(BSTR* pbstrMoreInfoText);
+ CCDDAReader(IUnknown* pUnk, HRESULT* phr);
+ ~CCDDAReader();
+
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ // IFileSourceFilter
+
+ STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
+
+ // IAMMediaContent
+
+ STDMETHODIMP GetTypeInfoCount(UINT* pctinfo);
+ STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo);
+ STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** rgszNames, UINT cNames, LCID lcid, DISPID* rgdispid);
+ STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult, EXCEPINFO* pexcepinfo, UINT* puArgErr);
+
+ STDMETHODIMP get_AuthorName(BSTR* pbstrAuthorName);
+ STDMETHODIMP get_Title(BSTR* pbstrTitle);
+ STDMETHODIMP get_Rating(BSTR* pbstrRating);
+ STDMETHODIMP get_Description(BSTR* pbstrDescription);
+ STDMETHODIMP get_Copyright(BSTR* pbstrCopyright);
+ STDMETHODIMP get_BaseURL(BSTR* pbstrBaseURL);
+ STDMETHODIMP get_LogoURL(BSTR* pbstrLogoURL);
+ STDMETHODIMP get_LogoIconURL(BSTR* pbstrLogoURL);
+ STDMETHODIMP get_WatermarkURL(BSTR* pbstrWatermarkURL);
+ STDMETHODIMP get_MoreInfoURL(BSTR* pbstrMoreInfoURL);
+ STDMETHODIMP get_MoreInfoBannerImage(BSTR* pbstrMoreInfoBannerImage);
+ STDMETHODIMP get_MoreInfoBannerURL(BSTR* pbstrMoreInfoBannerURL);
+ STDMETHODIMP get_MoreInfoText(BSTR* pbstrMoreInfoText);
};
diff --git a/src/filters/reader/CDXAReader/CDXAReader.cpp b/src/filters/reader/CDXAReader/CDXAReader.cpp
index 64beb50d7..6d9e32687 100644
--- a/src/filters/reader/CDXAReader/CDXAReader.cpp
+++ b/src/filters/reader/CDXAReader/CDXAReader.cpp
@@ -33,82 +33,82 @@
/////////
static DWORD EDC_crctable[256] = {
- 0x00000000l, 0x90910101l, 0x91210201l, 0x01b00300l,
- 0x92410401l, 0x02d00500l, 0x03600600l, 0x93f10701l,
- 0x94810801l, 0x04100900l, 0x05a00a00l, 0x95310b01l,
- 0x06c00c00l, 0x96510d01l, 0x97e10e01l, 0x07700f00l,
- 0x99011001l, 0x09901100l, 0x08201200l, 0x98b11301l,
- 0x0b401400l, 0x9bd11501l, 0x9a611601l, 0x0af01700l,
- 0x0d801800l, 0x9d111901l, 0x9ca11a01l, 0x0c301b00l,
- 0x9fc11c01l, 0x0f501d00l, 0x0ee01e00l, 0x9e711f01l,
- 0x82012001l, 0x12902100l, 0x13202200l, 0x83b12301l,
- 0x10402400l, 0x80d12501l, 0x81612601l, 0x11f02700l,
- 0x16802800l, 0x86112901l, 0x87a12a01l, 0x17302b00l,
- 0x84c12c01l, 0x14502d00l, 0x15e02e00l, 0x85712f01l,
- 0x1b003000l, 0x8b913101l, 0x8a213201l, 0x1ab03300l,
- 0x89413401l, 0x19d03500l, 0x18603600l, 0x88f13701l,
- 0x8f813801l, 0x1f103900l, 0x1ea03a00l, 0x8e313b01l,
- 0x1dc03c00l, 0x8d513d01l, 0x8ce13e01l, 0x1c703f00l,
- 0xb4014001l, 0x24904100l, 0x25204200l, 0xb5b14301l,
- 0x26404400l, 0xb6d14501l, 0xb7614601l, 0x27f04700l,
- 0x20804800l, 0xb0114901l, 0xb1a14a01l, 0x21304b00l,
- 0xb2c14c01l, 0x22504d00l, 0x23e04e00l, 0xb3714f01l,
- 0x2d005000l, 0xbd915101l, 0xbc215201l, 0x2cb05300l,
- 0xbf415401l, 0x2fd05500l, 0x2e605600l, 0xbef15701l,
- 0xb9815801l, 0x29105900l, 0x28a05a00l, 0xb8315b01l,
- 0x2bc05c00l, 0xbb515d01l, 0xbae15e01l, 0x2a705f00l,
- 0x36006000l, 0xa6916101l, 0xa7216201l, 0x37b06300l,
- 0xa4416401l, 0x34d06500l, 0x35606600l, 0xa5f16701l,
- 0xa2816801l, 0x32106900l, 0x33a06a00l, 0xa3316b01l,
- 0x30c06c00l, 0xa0516d01l, 0xa1e16e01l, 0x31706f00l,
- 0xaf017001l, 0x3f907100l, 0x3e207200l, 0xaeb17301l,
- 0x3d407400l, 0xadd17501l, 0xac617601l, 0x3cf07700l,
- 0x3b807800l, 0xab117901l, 0xaaa17a01l, 0x3a307b00l,
- 0xa9c17c01l, 0x39507d00l, 0x38e07e00l, 0xa8717f01l,
- 0xd8018001l, 0x48908100l, 0x49208200l, 0xd9b18301l,
- 0x4a408400l, 0xdad18501l, 0xdb618601l, 0x4bf08700l,
- 0x4c808800l, 0xdc118901l, 0xdda18a01l, 0x4d308b00l,
- 0xdec18c01l, 0x4e508d00l, 0x4fe08e00l, 0xdf718f01l,
- 0x41009000l, 0xd1919101l, 0xd0219201l, 0x40b09300l,
- 0xd3419401l, 0x43d09500l, 0x42609600l, 0xd2f19701l,
- 0xd5819801l, 0x45109900l, 0x44a09a00l, 0xd4319b01l,
- 0x47c09c00l, 0xd7519d01l, 0xd6e19e01l, 0x46709f00l,
- 0x5a00a000l, 0xca91a101l, 0xcb21a201l, 0x5bb0a300l,
- 0xc841a401l, 0x58d0a500l, 0x5960a600l, 0xc9f1a701l,
- 0xce81a801l, 0x5e10a900l, 0x5fa0aa00l, 0xcf31ab01l,
- 0x5cc0ac00l, 0xcc51ad01l, 0xcde1ae01l, 0x5d70af00l,
- 0xc301b001l, 0x5390b100l, 0x5220b200l, 0xc2b1b301l,
- 0x5140b400l, 0xc1d1b501l, 0xc061b601l, 0x50f0b700l,
- 0x5780b800l, 0xc711b901l, 0xc6a1ba01l, 0x5630bb00l,
- 0xc5c1bc01l, 0x5550bd00l, 0x54e0be00l, 0xc471bf01l,
- 0x6c00c000l, 0xfc91c101l, 0xfd21c201l, 0x6db0c300l,
- 0xfe41c401l, 0x6ed0c500l, 0x6f60c600l, 0xfff1c701l,
- 0xf881c801l, 0x6810c900l, 0x69a0ca00l, 0xf931cb01l,
- 0x6ac0cc00l, 0xfa51cd01l, 0xfbe1ce01l, 0x6b70cf00l,
- 0xf501d001l, 0x6590d100l, 0x6420d200l, 0xf4b1d301l,
- 0x6740d400l, 0xf7d1d501l, 0xf661d601l, 0x66f0d700l,
- 0x6180d800l, 0xf111d901l, 0xf0a1da01l, 0x6030db00l,
- 0xf3c1dc01l, 0x6350dd00l, 0x62e0de00l, 0xf271df01l,
- 0xee01e001l, 0x7e90e100l, 0x7f20e200l, 0xefb1e301l,
- 0x7c40e400l, 0xecd1e501l, 0xed61e601l, 0x7df0e700l,
- 0x7a80e800l, 0xea11e901l, 0xeba1ea01l, 0x7b30eb00l,
- 0xe8c1ec01l, 0x7850ed00l, 0x79e0ee00l, 0xe971ef01l,
- 0x7700f000l, 0xe791f101l, 0xe621f201l, 0x76b0f300l,
- 0xe541f401l, 0x75d0f500l, 0x7460f600l, 0xe4f1f701l,
- 0xe381f801l, 0x7310f900l, 0x72a0fa00l, 0xe231fb01l,
- 0x71c0fc00l, 0xe151fd01l, 0xe0e1fe01l, 0x7070ff00l
+ 0x00000000l, 0x90910101l, 0x91210201l, 0x01b00300l,
+ 0x92410401l, 0x02d00500l, 0x03600600l, 0x93f10701l,
+ 0x94810801l, 0x04100900l, 0x05a00a00l, 0x95310b01l,
+ 0x06c00c00l, 0x96510d01l, 0x97e10e01l, 0x07700f00l,
+ 0x99011001l, 0x09901100l, 0x08201200l, 0x98b11301l,
+ 0x0b401400l, 0x9bd11501l, 0x9a611601l, 0x0af01700l,
+ 0x0d801800l, 0x9d111901l, 0x9ca11a01l, 0x0c301b00l,
+ 0x9fc11c01l, 0x0f501d00l, 0x0ee01e00l, 0x9e711f01l,
+ 0x82012001l, 0x12902100l, 0x13202200l, 0x83b12301l,
+ 0x10402400l, 0x80d12501l, 0x81612601l, 0x11f02700l,
+ 0x16802800l, 0x86112901l, 0x87a12a01l, 0x17302b00l,
+ 0x84c12c01l, 0x14502d00l, 0x15e02e00l, 0x85712f01l,
+ 0x1b003000l, 0x8b913101l, 0x8a213201l, 0x1ab03300l,
+ 0x89413401l, 0x19d03500l, 0x18603600l, 0x88f13701l,
+ 0x8f813801l, 0x1f103900l, 0x1ea03a00l, 0x8e313b01l,
+ 0x1dc03c00l, 0x8d513d01l, 0x8ce13e01l, 0x1c703f00l,
+ 0xb4014001l, 0x24904100l, 0x25204200l, 0xb5b14301l,
+ 0x26404400l, 0xb6d14501l, 0xb7614601l, 0x27f04700l,
+ 0x20804800l, 0xb0114901l, 0xb1a14a01l, 0x21304b00l,
+ 0xb2c14c01l, 0x22504d00l, 0x23e04e00l, 0xb3714f01l,
+ 0x2d005000l, 0xbd915101l, 0xbc215201l, 0x2cb05300l,
+ 0xbf415401l, 0x2fd05500l, 0x2e605600l, 0xbef15701l,
+ 0xb9815801l, 0x29105900l, 0x28a05a00l, 0xb8315b01l,
+ 0x2bc05c00l, 0xbb515d01l, 0xbae15e01l, 0x2a705f00l,
+ 0x36006000l, 0xa6916101l, 0xa7216201l, 0x37b06300l,
+ 0xa4416401l, 0x34d06500l, 0x35606600l, 0xa5f16701l,
+ 0xa2816801l, 0x32106900l, 0x33a06a00l, 0xa3316b01l,
+ 0x30c06c00l, 0xa0516d01l, 0xa1e16e01l, 0x31706f00l,
+ 0xaf017001l, 0x3f907100l, 0x3e207200l, 0xaeb17301l,
+ 0x3d407400l, 0xadd17501l, 0xac617601l, 0x3cf07700l,
+ 0x3b807800l, 0xab117901l, 0xaaa17a01l, 0x3a307b00l,
+ 0xa9c17c01l, 0x39507d00l, 0x38e07e00l, 0xa8717f01l,
+ 0xd8018001l, 0x48908100l, 0x49208200l, 0xd9b18301l,
+ 0x4a408400l, 0xdad18501l, 0xdb618601l, 0x4bf08700l,
+ 0x4c808800l, 0xdc118901l, 0xdda18a01l, 0x4d308b00l,
+ 0xdec18c01l, 0x4e508d00l, 0x4fe08e00l, 0xdf718f01l,
+ 0x41009000l, 0xd1919101l, 0xd0219201l, 0x40b09300l,
+ 0xd3419401l, 0x43d09500l, 0x42609600l, 0xd2f19701l,
+ 0xd5819801l, 0x45109900l, 0x44a09a00l, 0xd4319b01l,
+ 0x47c09c00l, 0xd7519d01l, 0xd6e19e01l, 0x46709f00l,
+ 0x5a00a000l, 0xca91a101l, 0xcb21a201l, 0x5bb0a300l,
+ 0xc841a401l, 0x58d0a500l, 0x5960a600l, 0xc9f1a701l,
+ 0xce81a801l, 0x5e10a900l, 0x5fa0aa00l, 0xcf31ab01l,
+ 0x5cc0ac00l, 0xcc51ad01l, 0xcde1ae01l, 0x5d70af00l,
+ 0xc301b001l, 0x5390b100l, 0x5220b200l, 0xc2b1b301l,
+ 0x5140b400l, 0xc1d1b501l, 0xc061b601l, 0x50f0b700l,
+ 0x5780b800l, 0xc711b901l, 0xc6a1ba01l, 0x5630bb00l,
+ 0xc5c1bc01l, 0x5550bd00l, 0x54e0be00l, 0xc471bf01l,
+ 0x6c00c000l, 0xfc91c101l, 0xfd21c201l, 0x6db0c300l,
+ 0xfe41c401l, 0x6ed0c500l, 0x6f60c600l, 0xfff1c701l,
+ 0xf881c801l, 0x6810c900l, 0x69a0ca00l, 0xf931cb01l,
+ 0x6ac0cc00l, 0xfa51cd01l, 0xfbe1ce01l, 0x6b70cf00l,
+ 0xf501d001l, 0x6590d100l, 0x6420d200l, 0xf4b1d301l,
+ 0x6740d400l, 0xf7d1d501l, 0xf661d601l, 0x66f0d700l,
+ 0x6180d800l, 0xf111d901l, 0xf0a1da01l, 0x6030db00l,
+ 0xf3c1dc01l, 0x6350dd00l, 0x62e0de00l, 0xf271df01l,
+ 0xee01e001l, 0x7e90e100l, 0x7f20e200l, 0xefb1e301l,
+ 0x7c40e400l, 0xecd1e501l, 0xed61e601l, 0x7df0e700l,
+ 0x7a80e800l, 0xea11e901l, 0xeba1ea01l, 0x7b30eb00l,
+ 0xe8c1ec01l, 0x7850ed00l, 0x79e0ee00l, 0xe971ef01l,
+ 0x7700f000l, 0xe791f101l, 0xe621f201l, 0x76b0f300l,
+ 0xe541f401l, 0x75d0f500l, 0x7460f600l, 0xe4f1f701l,
+ 0xe381f801l, 0x7310f900l, 0x72a0fa00l, 0xe231fb01l,
+ 0x71c0fc00l, 0xe151fd01l, 0xe0e1fe01l, 0x7070ff00l
};
static DWORD build_edc(const void* in, unsigned from, unsigned upto)
{
- const BYTE* p = (BYTE*)in + from;
- DWORD result = 0;
+ const BYTE* p = (BYTE*)in + from;
+ DWORD result = 0;
- for (; from < upto; from++) {
- result = EDC_crctable[(result ^ *p++) & 0xffL] ^ (result >> 8);
- }
+ for (; from < upto; from++) {
+ result = EDC_crctable[(result ^ *p++) & 0xffL] ^ (result >> 8);
+ }
- return result;
+ return result;
}
/////////
@@ -116,41 +116,41 @@ static DWORD build_edc(const void* in, unsigned from, unsigned upto)
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL}
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL}
};
const AMOVIESETUP_PIN sudOpPin[] = {
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CCDXAReader), CCDXAReaderName, MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
+ {&__uuidof(CCDXAReader), CCDXAReaderName, MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CCDXAReader>, NULL, &sudFilter[0]}
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CCDXAReader>, NULL, &sudFilter[0]}
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{D367878E-F3B8-4235-A968-F378EF1B9A44}"),
- _T("0"), _T("0,4,,52494646,8,4,,43445841")); // "RIFFxxxxCDXA"
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{D367878E-F3B8-4235-A968-F378EF1B9A44}"),
+ _T("0"), _T("0,4,,52494646,8,4,,43445841")); // "RIFFxxxxCDXA"
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{D367878E-F3B8-4235-A968-F378EF1B9A44}"),
- _T("Source Filter"), _T("{D367878E-F3B8-4235-A968-F378EF1B9A44}"));
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{D367878E-F3B8-4235-A968-F378EF1B9A44}"),
+ _T("Source Filter"), _T("{D367878E-F3B8-4235-A968-F378EF1B9A44}"));
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{D367878E-F3B8-4235-A968-F378EF1B9A44}"));
+ DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{D367878E-F3B8-4235-A968-F378EF1B9A44}"));
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -164,11 +164,11 @@ CFilterApp theApp;
//
CCDXAReader::CCDXAReader(IUnknown* pUnk, HRESULT* phr)
- : CAsyncReader(NAME("CCDXAReader"), pUnk, &m_stream, phr, __uuidof(this))
+ : CAsyncReader(NAME("CCDXAReader"), pUnk, &m_stream, phr, __uuidof(this))
{
- if (phr) {
- *phr = S_OK;
- }
+ if (phr) {
+ *phr = S_OK;
+ }
}
CCDXAReader::~CCDXAReader()
@@ -177,365 +177,365 @@ CCDXAReader::~CCDXAReader()
STDMETHODIMP CCDXAReader::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- return
- QI(IFileSourceFilter)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IFileSourceFilter)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
-STDMETHODIMP CCDXAReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE *pmt)
+STDMETHODIMP CCDXAReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
- CMediaType mt;
- m_mt = mt;
+ CMediaType mt;
+ m_mt = mt;
- if (!m_stream.Load(pszFileName)) {
- return E_FAIL;
- }
+ if (!m_stream.Load(pszFileName)) {
+ return E_FAIL;
+ }
- m_fn = pszFileName;
+ m_fn = pszFileName;
- mt.majortype = MEDIATYPE_Stream;
- mt.subtype = m_stream.m_subtype;
- m_mt = mt;
+ mt.majortype = MEDIATYPE_Stream;
+ mt.subtype = m_stream.m_subtype;
+ m_mt = mt;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CCDXAReader::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
{
- if (!ppszFileName) {
- return E_POINTER;
- }
+ if (!ppszFileName) {
+ return E_POINTER;
+ }
- *ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR));
- if (!(*ppszFileName)) {
- return E_OUTOFMEMORY;
- }
+ *ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength() + 1) * sizeof(WCHAR));
+ if (!(*ppszFileName)) {
+ return E_OUTOFMEMORY;
+ }
- wcscpy_s(*ppszFileName, m_fn.GetLength() + 1, m_fn);
+ wcscpy_s(*ppszFileName, m_fn.GetLength() + 1, m_fn);
- return S_OK;
+ return S_OK;
}
// CCDXAStream
CCDXAStream::CCDXAStream()
{
- m_subtype = MEDIASUBTYPE_NULL;
+ m_subtype = MEDIASUBTYPE_NULL;
- m_hFile = INVALID_HANDLE_VALUE;
+ m_hFile = INVALID_HANDLE_VALUE;
- m_llPosition = m_llLength = 0;
- m_nFirstSector = 0;
- m_nBufferedSector = -1;
+ m_llPosition = m_llLength = 0;
+ m_nFirstSector = 0;
+ m_nBufferedSector = -1;
}
CCDXAStream::~CCDXAStream()
{
- if (m_hFile != INVALID_HANDLE_VALUE) {
- CloseHandle(m_hFile);
- m_hFile = INVALID_HANDLE_VALUE;
- }
+ if (m_hFile != INVALID_HANDLE_VALUE) {
+ CloseHandle(m_hFile);
+ m_hFile = INVALID_HANDLE_VALUE;
+ }
}
bool CCDXAStream::Load(const WCHAR* fnw)
{
- if (m_hFile != INVALID_HANDLE_VALUE) {
- CloseHandle(m_hFile);
- m_hFile = INVALID_HANDLE_VALUE;
- }
-
- m_hFile = CreateFile(CString(fnw), GENERIC_READ, FILE_SHARE_READ, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_READONLY|FILE_FLAG_SEQUENTIAL_SCAN, (HANDLE)NULL);
- if (m_hFile == INVALID_HANDLE_VALUE) {
- return false;
- }
-
- BYTE hdr[RIFFCDXA_HEADER_SIZE];
- DWORD NumberOfBytesRead;
- if (!ReadFile(m_hFile, (LPVOID)hdr, RIFFCDXA_HEADER_SIZE, &NumberOfBytesRead, NULL)
- || *((DWORD*)&hdr[0]) != 'FFIR' || *((DWORD*)&hdr[8]) != 'AXDC'
- || *((DWORD*)&hdr[4]) != (*((DWORD*)&hdr[0x28])+0x24)) {
- CloseHandle(m_hFile);
- m_hFile = INVALID_HANDLE_VALUE;
- return false;
- }
-
- LARGE_INTEGER size = {0, 0};
- GetFileSizeEx(m_hFile, &size);
-
- m_llLength = int((size.QuadPart - RIFFCDXA_HEADER_SIZE) / RAW_SECTOR_SIZE) * RAW_DATA_SIZE;
-
- if (!LookForMediaSubType()) {
- m_llPosition = m_llLength = 0;
- CloseHandle(m_hFile);
- m_hFile = INVALID_HANDLE_VALUE;
- return false;
- }
-
- m_llPosition = 0;
-
- m_nBufferedSector = -1;
-
- return true;
+ if (m_hFile != INVALID_HANDLE_VALUE) {
+ CloseHandle(m_hFile);
+ m_hFile = INVALID_HANDLE_VALUE;
+ }
+
+ m_hFile = CreateFile(CString(fnw), GENERIC_READ, FILE_SHARE_READ, NULL,
+ OPEN_EXISTING, FILE_ATTRIBUTE_READONLY | FILE_FLAG_SEQUENTIAL_SCAN, (HANDLE)NULL);
+ if (m_hFile == INVALID_HANDLE_VALUE) {
+ return false;
+ }
+
+ BYTE hdr[RIFFCDXA_HEADER_SIZE];
+ DWORD NumberOfBytesRead;
+ if (!ReadFile(m_hFile, (LPVOID)hdr, RIFFCDXA_HEADER_SIZE, &NumberOfBytesRead, NULL)
+ || *((DWORD*)&hdr[0]) != 'FFIR' || *((DWORD*)&hdr[8]) != 'AXDC'
+ || *((DWORD*)&hdr[4]) != (*((DWORD*)&hdr[0x28]) + 0x24)) {
+ CloseHandle(m_hFile);
+ m_hFile = INVALID_HANDLE_VALUE;
+ return false;
+ }
+
+ LARGE_INTEGER size = {0, 0};
+ GetFileSizeEx(m_hFile, &size);
+
+ m_llLength = int((size.QuadPart - RIFFCDXA_HEADER_SIZE) / RAW_SECTOR_SIZE) * RAW_DATA_SIZE;
+
+ if (!LookForMediaSubType()) {
+ m_llPosition = m_llLength = 0;
+ CloseHandle(m_hFile);
+ m_hFile = INVALID_HANDLE_VALUE;
+ return false;
+ }
+
+ m_llPosition = 0;
+
+ m_nBufferedSector = -1;
+
+ return true;
}
HRESULT CCDXAStream::SetPointer(LONGLONG llPos)
{
- return (llPos >= 0 && llPos < m_llLength) ? m_llPosition = llPos, S_OK : S_FALSE;
+ return (llPos >= 0 && llPos < m_llLength) ? m_llPosition = llPos, S_OK : S_FALSE;
}
HRESULT CCDXAStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWORD pdwBytesRead)
{
- CAutoLock lck(&m_csLock);
+ CAutoLock lck(&m_csLock);
- PBYTE pbBufferOrg = pbBuffer;
- LONGLONG pos = m_llPosition;
+ PBYTE pbBufferOrg = pbBuffer;
+ LONGLONG pos = m_llPosition;
- while (pos >= 0 && pos < m_llLength && dwBytesToRead > 0) {
- UINT sector = m_nFirstSector + int(pos/RAW_DATA_SIZE);
- __int64 offset = pos%RAW_DATA_SIZE;
+ while (pos >= 0 && pos < m_llLength && dwBytesToRead > 0) {
+ UINT sector = m_nFirstSector + int(pos / RAW_DATA_SIZE);
+ __int64 offset = pos % RAW_DATA_SIZE;
- if (m_nBufferedSector != (int)sector) {
- LARGE_INTEGER FilePointer;
- FilePointer.QuadPart = RIFFCDXA_HEADER_SIZE + sector*RAW_SECTOR_SIZE;
- SetFilePointerEx(m_hFile, FilePointer, &FilePointer, FILE_BEGIN);
+ if (m_nBufferedSector != (int)sector) {
+ LARGE_INTEGER FilePointer;
+ FilePointer.QuadPart = RIFFCDXA_HEADER_SIZE + sector * RAW_SECTOR_SIZE;
+ SetFilePointerEx(m_hFile, FilePointer, &FilePointer, FILE_BEGIN);
- memset(m_sector, 0, sizeof(m_sector));
+ memset(m_sector, 0, sizeof(m_sector));
- DWORD NumberOfBytesRead = 0;
+ DWORD NumberOfBytesRead = 0;
- int nRetries = 3;
- while (nRetries--) {
- NumberOfBytesRead = 0;
- if (!ReadFile(m_hFile, m_sector, RAW_SECTOR_SIZE, &NumberOfBytesRead, NULL)
- || NumberOfBytesRead != RAW_SECTOR_SIZE) {
- break;
- }
+ int nRetries = 3;
+ while (nRetries--) {
+ NumberOfBytesRead = 0;
+ if (!ReadFile(m_hFile, m_sector, RAW_SECTOR_SIZE, &NumberOfBytesRead, NULL)
+ || NumberOfBytesRead != RAW_SECTOR_SIZE) {
+ break;
+ }
- if (*(DWORD*)&m_sector[RAW_SECTOR_SIZE-4] == 0) { // no CRC? it happens...
- break;
- }
+ if (*(DWORD*)&m_sector[RAW_SECTOR_SIZE - 4] == 0) { // no CRC? it happens...
+ break;
+ }
- if (build_edc(m_sector, RAW_SYNC_SIZE + RAW_HEADER_SIZE, RAW_SECTOR_SIZE) == 0) {
- break;
- }
+ if (build_edc(m_sector, RAW_SYNC_SIZE + RAW_HEADER_SIZE, RAW_SECTOR_SIZE) == 0) {
+ break;
+ }
- TRACE(_T("CCDXAStream: CRC error at sector %d (fp=0x%I64x, retriesleft=%d)\n"), sector, FilePointer.QuadPart, nRetries);
- }
+ TRACE(_T("CCDXAStream: CRC error at sector %d (fp=0x%I64x, retriesleft=%d)\n"), sector, FilePointer.QuadPart, nRetries);
+ }
- m_nBufferedSector = sector;
- }
+ m_nBufferedSector = sector;
+ }
- DWORD l = (DWORD)min(dwBytesToRead, min(RAW_DATA_SIZE - offset, m_llLength - pos));
- memcpy(pbBuffer, &m_sector[RAW_SYNC_SIZE + RAW_HEADER_SIZE + RAW_SUBHEADER_SIZE + offset], l);
+ DWORD l = (DWORD)min(dwBytesToRead, min(RAW_DATA_SIZE - offset, m_llLength - pos));
+ memcpy(pbBuffer, &m_sector[RAW_SYNC_SIZE + RAW_HEADER_SIZE + RAW_SUBHEADER_SIZE + offset], l);
- pbBuffer += l;
- pos += l;
- dwBytesToRead -= l;
- }
+ pbBuffer += l;
+ pos += l;
+ dwBytesToRead -= l;
+ }
- if (pdwBytesRead) {
- *pdwBytesRead = pbBuffer - pbBufferOrg;
- }
- m_llPosition += pbBuffer - pbBufferOrg;
+ if (pdwBytesRead) {
+ *pdwBytesRead = pbBuffer - pbBufferOrg;
+ }
+ m_llPosition += pbBuffer - pbBufferOrg;
- if (dwBytesToRead != 0) {
- return S_FALSE;
- }
+ if (dwBytesToRead != 0) {
+ return S_FALSE;
+ }
- return S_OK;
+ return S_OK;
}
LONGLONG CCDXAStream::Size(LONGLONG* pSizeAvailable)
{
- if (pSizeAvailable) {
- *pSizeAvailable = m_llLength;
- }
- return m_llLength;
+ if (pSizeAvailable) {
+ *pSizeAvailable = m_llLength;
+ }
+ return m_llLength;
}
DWORD CCDXAStream::Alignment()
{
- return 1;
+ return 1;
}
void CCDXAStream::Lock()
{
- m_csLock.Lock();
+ m_csLock.Lock();
}
void CCDXAStream::Unlock()
{
- m_csLock.Unlock();
+ m_csLock.Unlock();
}
//
bool CCDXAStream::LookForMediaSubType()
{
- BYTE buff[RAW_DATA_SIZE];
-
- m_subtype = MEDIASUBTYPE_NULL;
-
- m_llPosition = 0;
-
- for (int iSectorsRead = 0;
- Read(buff, RAW_DATA_SIZE, 1, NULL) == S_OK && iSectorsRead < 1000;
- iSectorsRead++) {
- if (*((DWORD*)&buff[0]) == 0xba010000) {
- m_llPosition = 0;
- m_llLength -= iSectorsRead*RAW_DATA_SIZE;
- m_nFirstSector = iSectorsRead;
-
- if ((buff[4]&0xc4) == 0x44) {
- m_subtype = MEDIASUBTYPE_MPEG2_PROGRAM;
- } else if ((buff[4]&0xf1) == 0x21) {
- m_subtype = MEDIASUBTYPE_MPEG1System;
- }
-
- return !!(m_subtype != MEDIASUBTYPE_NULL);
- } else if (*((DWORD*)&buff[0]) == 'SggO') {
- m_llPosition = 0;
- m_llLength -= iSectorsRead*RAW_DATA_SIZE;
- m_nFirstSector = iSectorsRead;
-
- m_subtype = MEDIASUBTYPE_Ogg;
-
- return true;
- } else if (*((DWORD*)&buff[0]) == 0xA3DF451A) {
- m_llPosition = 0;
- m_llLength -= iSectorsRead*RAW_DATA_SIZE;
- m_nFirstSector = iSectorsRead;
-
- m_subtype = MEDIASUBTYPE_Matroska;
-
- return true;
- } else if (*((DWORD*)&buff[0]) == 'FMR.') {
- m_llPosition = 0;
- m_llLength -= iSectorsRead*RAW_DATA_SIZE;
- m_nFirstSector = iSectorsRead;
-
- m_subtype = MEDIASUBTYPE_RealMedia;
-
- return true;
- } else if (*((DWORD*)&buff[0]) == 'FFIR' && *((DWORD*)&buff[8]) == ' IVA') {
- m_llPosition = 0;
- m_llLength = min(m_llLength, *((DWORD*)&buff[4])+8);
- m_nFirstSector = iSectorsRead;
-
- m_subtype = MEDIASUBTYPE_Avi;
-
- return true;
- } else if (*((DWORD*)&buff[4]) == 'voom' || *((DWORD*)&buff[4]) == 'tadm'
- || *((DWORD*)&buff[4]) == 'pytf' && *((DWORD*)&buff[8]) == 'mosi' && *((DWORD*)&buff[16]) == '14pm') {
- m_llPosition = 0;
- m_llLength -= iSectorsRead*RAW_DATA_SIZE;
- m_nFirstSector = iSectorsRead;
-
- m_subtype = MEDIASUBTYPE_QTMovie;
-
- return true;
- }
- }
-
- m_llPosition = 0;
-
- CRegKey majorkey;
- CString majortype = _T("\\Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}");
- if (ERROR_SUCCESS == majorkey.Open(HKEY_CLASSES_ROOT, majortype, KEY_READ)) {
- TCHAR subtype[256+1];
- DWORD len = 256;
- for (int i = 0; ERROR_SUCCESS == majorkey.EnumKey(i, subtype, &len); i++, len = 256) {
- CRegKey subkey;
- if (ERROR_SUCCESS != subkey.Open(HKEY_CLASSES_ROOT, majortype + _T("\\") + subtype, KEY_READ)) {
- continue;
- }
-
- for (int j = 0; true; j++) {
- TCHAR number[10];
- _stprintf_s(number, _countof(number), _T("%d"), j);
-
- TCHAR pattern[256+1];
- ULONG len = 256;
- if (ERROR_SUCCESS != subkey.QueryStringValue(number, pattern, &len)) {
- break;
- }
-
- CString p = pattern;
- p += ',';
-
- __int64 offset = 0;
- DWORD cb = 0;
- CAtlArray<BYTE> mask, val;
-
- int nMatches = 0, nTries = 0;
-
- for (int k = 0, l; nTries >= 0 && (l = p.Find(',', k)) >= 0; k = l+1, nTries++) {
- CString s = p.Mid(k, l-k);
- TRACE(s + '\n');
-
- TCHAR* end = NULL;
-
- switch (nTries&3) {
- case 0:
- offset = _tcstol(s, &end, 10);
- break;
- case 1:
- cb = _tcstol(s, &end, 10);
- break;
- case 2:
- CStringToBin(s, mask);
- break;
- case 3:
- CStringToBin(s, val);
- break;
- default:
- nTries = -1;
- break;
- }
-
- if (nTries >= 0 && (nTries&3) == 3) {
- if (cb > 0 && val.GetCount() > 0 && cb == val.GetCount()) {
- if (offset >= 0 && S_OK == SetPointer(offset)
- || S_OK == SetPointer(m_llLength + offset)) {
- CAutoVectorPtr<BYTE> pData;
- if (pData.Allocate(cb)) {
- DWORD BytesRead = 0;
- if (S_OK == Read(pData, cb, 1, &BytesRead) && cb == BytesRead) {
- if (mask.GetCount() < cb) {
- size_t i = mask.GetCount();
- mask.SetCount(cb);
- for (; i < cb; i++) {
- mask[i] = 0xff;
- }
- }
-
- for (unsigned int i = 0; i < cb; i++) {
- pData[i] &= (BYTE)mask[i];
- }
-
- if (memcmp(pData, val.GetData(), cb) == 0) {
- nMatches++;
- }
- }
- }
- }
-
- offset = 0;
- cb = 0;
- mask.RemoveAll();
- val.RemoveAll();
- }
- }
- }
-
- if (nMatches > 0 && nMatches*4 == nTries) {
- m_subtype = GUIDFromCString(subtype);
- return S_OK;
- }
- }
- }
- }
-
- return false;
+ BYTE buff[RAW_DATA_SIZE];
+
+ m_subtype = MEDIASUBTYPE_NULL;
+
+ m_llPosition = 0;
+
+ for (int iSectorsRead = 0;
+ Read(buff, RAW_DATA_SIZE, 1, NULL) == S_OK && iSectorsRead < 1000;
+ iSectorsRead++) {
+ if (*((DWORD*)&buff[0]) == 0xba010000) {
+ m_llPosition = 0;
+ m_llLength -= iSectorsRead * RAW_DATA_SIZE;
+ m_nFirstSector = iSectorsRead;
+
+ if ((buff[4] & 0xc4) == 0x44) {
+ m_subtype = MEDIASUBTYPE_MPEG2_PROGRAM;
+ } else if ((buff[4] & 0xf1) == 0x21) {
+ m_subtype = MEDIASUBTYPE_MPEG1System;
+ }
+
+ return !!(m_subtype != MEDIASUBTYPE_NULL);
+ } else if (*((DWORD*)&buff[0]) == 'SggO') {
+ m_llPosition = 0;
+ m_llLength -= iSectorsRead * RAW_DATA_SIZE;
+ m_nFirstSector = iSectorsRead;
+
+ m_subtype = MEDIASUBTYPE_Ogg;
+
+ return true;
+ } else if (*((DWORD*)&buff[0]) == 0xA3DF451A) {
+ m_llPosition = 0;
+ m_llLength -= iSectorsRead * RAW_DATA_SIZE;
+ m_nFirstSector = iSectorsRead;
+
+ m_subtype = MEDIASUBTYPE_Matroska;
+
+ return true;
+ } else if (*((DWORD*)&buff[0]) == 'FMR.') {
+ m_llPosition = 0;
+ m_llLength -= iSectorsRead * RAW_DATA_SIZE;
+ m_nFirstSector = iSectorsRead;
+
+ m_subtype = MEDIASUBTYPE_RealMedia;
+
+ return true;
+ } else if (*((DWORD*)&buff[0]) == 'FFIR' && *((DWORD*)&buff[8]) == ' IVA') {
+ m_llPosition = 0;
+ m_llLength = min(m_llLength, *((DWORD*)&buff[4]) + 8);
+ m_nFirstSector = iSectorsRead;
+
+ m_subtype = MEDIASUBTYPE_Avi;
+
+ return true;
+ } else if (*((DWORD*)&buff[4]) == 'voom' || *((DWORD*)&buff[4]) == 'tadm'
+ || *((DWORD*)&buff[4]) == 'pytf' && *((DWORD*)&buff[8]) == 'mosi' && *((DWORD*)&buff[16]) == '14pm') {
+ m_llPosition = 0;
+ m_llLength -= iSectorsRead * RAW_DATA_SIZE;
+ m_nFirstSector = iSectorsRead;
+
+ m_subtype = MEDIASUBTYPE_QTMovie;
+
+ return true;
+ }
+ }
+
+ m_llPosition = 0;
+
+ CRegKey majorkey;
+ CString majortype = _T("\\Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}");
+ if (ERROR_SUCCESS == majorkey.Open(HKEY_CLASSES_ROOT, majortype, KEY_READ)) {
+ TCHAR subtype[256 + 1];
+ DWORD len = 256;
+ for (int i = 0; ERROR_SUCCESS == majorkey.EnumKey(i, subtype, &len); i++, len = 256) {
+ CRegKey subkey;
+ if (ERROR_SUCCESS != subkey.Open(HKEY_CLASSES_ROOT, majortype + _T("\\") + subtype, KEY_READ)) {
+ continue;
+ }
+
+ for (int j = 0; true; j++) {
+ TCHAR number[10];
+ _stprintf_s(number, _countof(number), _T("%d"), j);
+
+ TCHAR pattern[256 + 1];
+ ULONG len = 256;
+ if (ERROR_SUCCESS != subkey.QueryStringValue(number, pattern, &len)) {
+ break;
+ }
+
+ CString p = pattern;
+ p += ',';
+
+ __int64 offset = 0;
+ DWORD cb = 0;
+ CAtlArray<BYTE> mask, val;
+
+ int nMatches = 0, nTries = 0;
+
+ for (int k = 0, l; nTries >= 0 && (l = p.Find(',', k)) >= 0; k = l + 1, nTries++) {
+ CString s = p.Mid(k, l - k);
+ TRACE(s + '\n');
+
+ TCHAR* end = NULL;
+
+ switch (nTries & 3) {
+ case 0:
+ offset = _tcstol(s, &end, 10);
+ break;
+ case 1:
+ cb = _tcstol(s, &end, 10);
+ break;
+ case 2:
+ CStringToBin(s, mask);
+ break;
+ case 3:
+ CStringToBin(s, val);
+ break;
+ default:
+ nTries = -1;
+ break;
+ }
+
+ if (nTries >= 0 && (nTries & 3) == 3) {
+ if (cb > 0 && val.GetCount() > 0 && cb == val.GetCount()) {
+ if (offset >= 0 && S_OK == SetPointer(offset)
+ || S_OK == SetPointer(m_llLength + offset)) {
+ CAutoVectorPtr<BYTE> pData;
+ if (pData.Allocate(cb)) {
+ DWORD BytesRead = 0;
+ if (S_OK == Read(pData, cb, 1, &BytesRead) && cb == BytesRead) {
+ if (mask.GetCount() < cb) {
+ size_t i = mask.GetCount();
+ mask.SetCount(cb);
+ for (; i < cb; i++) {
+ mask[i] = 0xff;
+ }
+ }
+
+ for (unsigned int i = 0; i < cb; i++) {
+ pData[i] &= (BYTE)mask[i];
+ }
+
+ if (memcmp(pData, val.GetData(), cb) == 0) {
+ nMatches++;
+ }
+ }
+ }
+ }
+
+ offset = 0;
+ cb = 0;
+ mask.RemoveAll();
+ val.RemoveAll();
+ }
+ }
+ }
+
+ if (nMatches > 0 && nMatches * 4 == nTries) {
+ m_subtype = GUIDFromCString(subtype);
+ return S_OK;
+ }
+ }
+ }
+ }
+
+ return false;
}
diff --git a/src/filters/reader/CDXAReader/CDXAReader.h b/src/filters/reader/CDXAReader/CDXAReader.h
index bd8b22826..01a721c93 100644
--- a/src/filters/reader/CDXAReader/CDXAReader.h
+++ b/src/filters/reader/CDXAReader/CDXAReader.h
@@ -32,59 +32,59 @@
class CCDXAStream : public CAsyncStream
{
private:
- enum {
- RIFFCDXA_HEADER_SIZE = 44, // usually...
- RAW_SYNC_SIZE = 12, // 00 FF .. FF 00
- RAW_HEADER_SIZE = 4,
- RAW_SUBHEADER_SIZE = 8,
- RAW_DATA_SIZE = 2324,
- RAW_EDC_SIZE = 4,
- RAW_SECTOR_SIZE = 2352
- };
+ enum {
+ RIFFCDXA_HEADER_SIZE = 44, // usually...
+ RAW_SYNC_SIZE = 12, // 00 FF .. FF 00
+ RAW_HEADER_SIZE = 4,
+ RAW_SUBHEADER_SIZE = 8,
+ RAW_DATA_SIZE = 2324,
+ RAW_EDC_SIZE = 4,
+ RAW_SECTOR_SIZE = 2352
+ };
- CCritSec m_csLock;
+ CCritSec m_csLock;
- HANDLE m_hFile;
- LONGLONG m_llPosition, m_llLength;
- int m_nFirstSector;
+ HANDLE m_hFile;
+ LONGLONG m_llPosition, m_llLength;
+ int m_nFirstSector;
- int m_nBufferedSector;
- BYTE m_sector[RAW_SECTOR_SIZE];
+ int m_nBufferedSector;
+ BYTE m_sector[RAW_SECTOR_SIZE];
- bool LookForMediaSubType();
+ bool LookForMediaSubType();
public:
- CCDXAStream();
- virtual ~CCDXAStream();
+ CCDXAStream();
+ virtual ~CCDXAStream();
- bool Load(const WCHAR* fnw);
+ bool Load(const WCHAR* fnw);
- HRESULT SetPointer(LONGLONG llPos);
- HRESULT Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWORD pdwBytesRead);
- LONGLONG Size(LONGLONG* pSizeAvailable);
- DWORD Alignment();
- void Lock();
- void Unlock();
+ HRESULT SetPointer(LONGLONG llPos);
+ HRESULT Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWORD pdwBytesRead);
+ LONGLONG Size(LONGLONG* pSizeAvailable);
+ DWORD Alignment();
+ void Lock();
+ void Unlock();
- GUID m_subtype;
+ GUID m_subtype;
};
class __declspec(uuid("D367878E-F3B8-4235-A968-F378EF1B9A44"))
- CCDXAReader
- : public CAsyncReader
- , public IFileSourceFilter
+ CCDXAReader
+ : public CAsyncReader
+ , public IFileSourceFilter
{
- CCDXAStream m_stream;
- CStringW m_fn;
+ CCDXAStream m_stream;
+ CStringW m_fn;
public:
- CCDXAReader(IUnknown* pUnk, HRESULT* phr);
- ~CCDXAReader();
+ CCDXAReader(IUnknown* pUnk, HRESULT* phr);
+ ~CCDXAReader();
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // IFileSourceFilter
- STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
+ // IFileSourceFilter
+ STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
};
diff --git a/src/filters/reader/UDPReader/UDPReader.cpp b/src/filters/reader/UDPReader/UDPReader.cpp
index b8aceda1f..e04e78465 100644
--- a/src/filters/reader/UDPReader/UDPReader.cpp
+++ b/src/filters/reader/UDPReader/UDPReader.cpp
@@ -28,36 +28,36 @@
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
const AMOVIESETUP_PIN sudOpPin[] = {
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CUDPReader), UDPReaderName, MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
+ {&__uuidof(CUDPReader), UDPReaderName, MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CUDPReader>, NULL, &sudFilter[0]}
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CUDPReader>, NULL, &sudFilter[0]}
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- SetRegKeyValue(_T("udp"), 0, _T("Source Filter"), CStringFromGUID(__uuidof(CUDPReader)));
- SetRegKeyValue(_T("tévé"), 0, _T("Source Filter"), CStringFromGUID(__uuidof(CUDPReader)));
+ SetRegKeyValue(_T("udp"), 0, _T("Source Filter"), CStringFromGUID(__uuidof(CUDPReader)));
+ SetRegKeyValue(_T("tévé"), 0, _T("Source Filter"), CStringFromGUID(__uuidof(CUDPReader)));
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- // TODO
+ // TODO
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -74,11 +74,11 @@ CFilterApp theApp;
//
CUDPReader::CUDPReader(IUnknown* pUnk, HRESULT* phr)
- : CAsyncReader(NAME("CUDPReader"), pUnk, &m_stream, phr, __uuidof(this))
+ : CAsyncReader(NAME("CUDPReader"), pUnk, &m_stream, phr, __uuidof(this))
{
- if (phr) {
- *phr = S_OK;
- }
+ if (phr) {
+ *phr = S_OK;
+ }
}
CUDPReader::~CUDPReader()
@@ -87,374 +87,374 @@ CUDPReader::~CUDPReader()
STDMETHODIMP CUDPReader::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- QI(IFileSourceFilter)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IFileSourceFilter)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// IFileSourceFilter
STDMETHODIMP CUDPReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
- if (!m_stream.Load(pszFileName)) {
- return E_FAIL;
- }
+ if (!m_stream.Load(pszFileName)) {
+ return E_FAIL;
+ }
- m_fn = pszFileName;
+ m_fn = pszFileName;
- CMediaType mt;
- mt.majortype = MEDIATYPE_Stream;
- mt.subtype = m_stream.GetSubType();
- m_mt = mt;
+ CMediaType mt;
+ mt.majortype = MEDIATYPE_Stream;
+ mt.subtype = m_stream.GetSubType();
+ m_mt = mt;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CUDPReader::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
{
- if (!ppszFileName) {
- return E_POINTER;
- }
+ if (!ppszFileName) {
+ return E_POINTER;
+ }
- *ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR));
- if (!(*ppszFileName)) {
- return E_OUTOFMEMORY;
- }
+ *ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength() + 1) * sizeof(WCHAR));
+ if (!(*ppszFileName)) {
+ return E_OUTOFMEMORY;
+ }
- wcscpy_s(*ppszFileName, m_fn.GetLength() + 1, m_fn);
+ wcscpy_s(*ppszFileName, m_fn.GetLength() + 1, m_fn);
- return S_OK;
+ return S_OK;
}
// CUDPStream
CUDPStream::CUDPStream()
{
- m_port = 0;
- m_socket = INVALID_SOCKET;
- m_subtype = MEDIASUBTYPE_NULL;
+ m_port = 0;
+ m_socket = INVALID_SOCKET;
+ m_subtype = MEDIASUBTYPE_NULL;
}
CUDPStream::~CUDPStream()
{
- Clear();
+ Clear();
}
void CUDPStream::Clear()
{
- if (m_socket !=INVALID_SOCKET) {
- closesocket(m_socket);
- m_socket = INVALID_SOCKET;
- }
- if (CAMThread::ThreadExists()) {
- CAMThread::CallWorker(CMD_EXIT);
- CAMThread::Close();
- }
- while (!m_packets.IsEmpty()) {
- delete m_packets.RemoveHead();
- }
- m_pos = m_len = 0;
- m_drop = false;
+ if (m_socket != INVALID_SOCKET) {
+ closesocket(m_socket);
+ m_socket = INVALID_SOCKET;
+ }
+ if (CAMThread::ThreadExists()) {
+ CAMThread::CallWorker(CMD_EXIT);
+ CAMThread::Close();
+ }
+ while (!m_packets.IsEmpty()) {
+ delete m_packets.RemoveHead();
+ }
+ m_pos = m_len = 0;
+ m_drop = false;
}
void CUDPStream::Append(BYTE* buff, int len)
{
- CAutoLock cAutoLock(&m_csLock);
-
- if (m_packets.GetCount() > 1) {
- __int64 size = m_packets.GetTail()->m_end - m_packets.GetHead()->m_start;
-
- if (!m_drop && (m_pos >= BUFF_SIZE_FIRST && size >= BUFF_SIZE_FIRST || size >= 2*BUFF_SIZE_FIRST)) {
- m_drop = true;
- TRACE(_T("DROP ON\n"));
- } else if (m_drop && size <= BUFF_SIZE_FIRST) {
- m_drop = false;
- TRACE(_T("DROP OFF\n"));
- }
-
- if (m_drop) {
- return;
- }
- }
-
- m_packets.AddTail(DNew packet_t(buff, m_len, m_len + len));
- m_len += len;
+ CAutoLock cAutoLock(&m_csLock);
+
+ if (m_packets.GetCount() > 1) {
+ __int64 size = m_packets.GetTail()->m_end - m_packets.GetHead()->m_start;
+
+ if (!m_drop && (m_pos >= BUFF_SIZE_FIRST && size >= BUFF_SIZE_FIRST || size >= 2 * BUFF_SIZE_FIRST)) {
+ m_drop = true;
+ TRACE(_T("DROP ON\n"));
+ } else if (m_drop && size <= BUFF_SIZE_FIRST) {
+ m_drop = false;
+ TRACE(_T("DROP OFF\n"));
+ }
+
+ if (m_drop) {
+ return;
+ }
+ }
+
+ m_packets.AddTail(DNew packet_t(buff, m_len, m_len + len));
+ m_len += len;
}
bool CUDPStream::Load(const WCHAR* fnw)
{
- Clear();
+ Clear();
- CStringW url = CStringW(fnw);
+ CStringW url = CStringW(fnw);
- CAtlList<CStringW> sl;
- Explode(url, sl, ':');
- if (sl.GetCount() != 3) {
- return false;
- }
+ CAtlList<CStringW> sl;
+ Explode(url, sl, ':');
+ if (sl.GetCount() != 3) {
+ return false;
+ }
- CStringW protocol = sl.RemoveHead();
- // if (protocol != L"udp") return false;
+ CStringW protocol = sl.RemoveHead();
+ // if (protocol != L"udp") return false;
- m_ip = CString(sl.RemoveHead()).TrimLeft('/');
+ m_ip = CString(sl.RemoveHead()).TrimLeft('/');
- int port = _wtoi(Explode(sl.RemoveHead(), sl, '/', 2));
- if (port < 0 || port > 0xffff) {
- return false;
- }
- m_port = port;
+ int port = _wtoi(Explode(sl.RemoveHead(), sl, '/', 2));
+ if (port < 0 || port > 0xffff) {
+ return false;
+ }
+ m_port = port;
- if (sl.GetCount() != 2 || FAILED(GUIDFromCString(CString(sl.GetTail()), m_subtype))) {
- m_subtype = MEDIASUBTYPE_NULL; // TODO: detect subtype
- }
+ if (sl.GetCount() != 2 || FAILED(GUIDFromCString(CString(sl.GetTail()), m_subtype))) {
+ m_subtype = MEDIASUBTYPE_NULL; // TODO: detect subtype
+ }
- CAMThread::Create();
- if (FAILED(CAMThread::CallWorker(CMD_RUN))) {
- Clear();
- return false;
- }
+ CAMThread::Create();
+ if (FAILED(CAMThread::CallWorker(CMD_RUN))) {
+ Clear();
+ return false;
+ }
- clock_t start = clock();
- while (clock() - start < 3000 && m_len < 1000000) {
- Sleep(100);
- }
+ clock_t start = clock();
+ while (clock() - start < 3000 && m_len < 1000000) {
+ Sleep(100);
+ }
- return true;
+ return true;
}
HRESULT CUDPStream::SetPointer(LONGLONG llPos)
{
- CAutoLock cAutoLock(&m_csLock);
+ CAutoLock cAutoLock(&m_csLock);
- if (m_packets.IsEmpty() && llPos != 0
- || !m_packets.IsEmpty() && llPos < m_packets.GetHead()->m_start
- || !m_packets.IsEmpty() && llPos > m_packets.GetTail()->m_end) {
- TRACE(_T("CUDPStream: SetPointer error\n"));
- return E_FAIL;
- }
+ if (m_packets.IsEmpty() && llPos != 0
+ || !m_packets.IsEmpty() && llPos < m_packets.GetHead()->m_start
+ || !m_packets.IsEmpty() && llPos > m_packets.GetTail()->m_end) {
+ TRACE(_T("CUDPStream: SetPointer error\n"));
+ return E_FAIL;
+ }
- m_pos = llPos;
+ m_pos = llPos;
- return S_OK;
+ return S_OK;
}
HRESULT CUDPStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWORD pdwBytesRead)
{
- CAutoLock cAutoLock(&m_csLock);
+ CAutoLock cAutoLock(&m_csLock);
- DWORD len = dwBytesToRead;
- BYTE* ptr = pbBuffer;
+ DWORD len = dwBytesToRead;
+ BYTE* ptr = pbBuffer;
- while (len > 0 && !m_packets.IsEmpty()) {
- POSITION pos = m_packets.GetHeadPosition();
- while (pos && len > 0) {
- packet_t* p = m_packets.GetNext(pos);
+ while (len > 0 && !m_packets.IsEmpty()) {
+ POSITION pos = m_packets.GetHeadPosition();
+ while (pos && len > 0) {
+ packet_t* p = m_packets.GetNext(pos);
- if (p->m_start <= m_pos && m_pos < p->m_end) {
- DWORD size;
+ if (p->m_start <= m_pos && m_pos < p->m_end) {
+ DWORD size;
- if (m_pos < p->m_start) {
- ASSERT(0);
- size = (DWORD)min(len, p->m_start - m_pos);
- memset(ptr, 0, size);
- } else {
- size = (DWORD)min(len, p->m_end - m_pos);
- memcpy(ptr, &p->m_buff[m_pos - p->m_start], size);
- }
+ if (m_pos < p->m_start) {
+ ASSERT(0);
+ size = (DWORD)min(len, p->m_start - m_pos);
+ memset(ptr, 0, size);
+ } else {
+ size = (DWORD)min(len, p->m_end - m_pos);
+ memcpy(ptr, &p->m_buff[m_pos - p->m_start], size);
+ }
- m_pos += size;
+ m_pos += size;
- ptr += size;
- len -= size;
- }
+ ptr += size;
+ len -= size;
+ }
- if (p->m_end <= m_pos - 2048 && BUFF_SIZE_FIRST <= m_pos) {
- while (m_packets.GetHeadPosition() != pos) {
- delete m_packets.RemoveHead();
- }
- }
+ if (p->m_end <= m_pos - 2048 && BUFF_SIZE_FIRST <= m_pos) {
+ while (m_packets.GetHeadPosition() != pos) {
+ delete m_packets.RemoveHead();
+ }
+ }
- }
- }
+ }
+ }
- if (pdwBytesRead) {
- *pdwBytesRead = ptr - pbBuffer;
- }
+ if (pdwBytesRead) {
+ *pdwBytesRead = ptr - pbBuffer;
+ }
- return S_OK;
+ return S_OK;
}
LONGLONG CUDPStream::Size(LONGLONG* pSizeAvailable)
{
- CAutoLock cAutoLock(&m_csLock);
- if (pSizeAvailable) {
- *pSizeAvailable = m_len;
- }
- return 0;
+ CAutoLock cAutoLock(&m_csLock);
+ if (pSizeAvailable) {
+ *pSizeAvailable = m_len;
+ }
+ return 0;
}
DWORD CUDPStream::Alignment()
{
- return 1;
+ return 1;
}
void CUDPStream::Lock()
{
- m_csLock.Lock();
+ m_csLock.Lock();
}
void CUDPStream::Unlock()
{
- m_csLock.Unlock();
+ m_csLock.Unlock();
}
DWORD CUDPStream::ThreadProc()
{
- WSADATA wsaData;
- WSAStartup(MAKEWORD(2, 2), &wsaData);
-
- sockaddr_in addr;
- memset(&addr, 0, sizeof(addr));
- addr.sin_family = AF_INET;
- addr.sin_addr.s_addr = htonl(INADDR_ANY);
- addr.sin_port = htons((u_short)m_port);
-
- ip_mreq imr;
- imr.imr_multiaddr.s_addr = inet_addr(CStringA(m_ip));
- imr.imr_interface.s_addr = INADDR_ANY;
-
- if ((m_socket = socket(AF_INET, SOCK_DGRAM, 0))!=INVALID_SOCKET) {
- /* u_long argp = 1;
- ioctlsocket(m_socket, FIONBIO, &argp);
- */
- DWORD dw = TRUE;
- if (setsockopt(m_socket, SOL_SOCKET, SO_REUSEADDR, (const char*)&dw, sizeof(dw))==SOCKET_ERROR) {
- closesocket(m_socket);
- m_socket = INVALID_SOCKET;
- }
-
- if (bind(m_socket, (struct sockaddr*)&addr, sizeof(addr))==SOCKET_ERROR) {
- closesocket(m_socket);
- m_socket = INVALID_SOCKET;
- }
-
- if (IN_MULTICAST(htonl(imr.imr_multiaddr.s_addr))) {
- int ret = setsockopt(m_socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const char*)&imr, sizeof(imr));
- if (ret < 0) {
- ret = ::WSAGetLastError();
- }
- ret = ret;
- }
- }
-
- SetThreadPriority(m_hThread, THREAD_PRIORITY_TIME_CRITICAL);
+ WSADATA wsaData;
+ WSAStartup(MAKEWORD(2, 2), &wsaData);
+
+ sockaddr_in addr;
+ memset(&addr, 0, sizeof(addr));
+ addr.sin_family = AF_INET;
+ addr.sin_addr.s_addr = htonl(INADDR_ANY);
+ addr.sin_port = htons((u_short)m_port);
+
+ ip_mreq imr;
+ imr.imr_multiaddr.s_addr = inet_addr(CStringA(m_ip));
+ imr.imr_interface.s_addr = INADDR_ANY;
+
+ if ((m_socket = socket(AF_INET, SOCK_DGRAM, 0)) != INVALID_SOCKET) {
+ /* u_long argp = 1;
+ ioctlsocket(m_socket, FIONBIO, &argp);
+ */
+ DWORD dw = TRUE;
+ if (setsockopt(m_socket, SOL_SOCKET, SO_REUSEADDR, (const char*)&dw, sizeof(dw)) == SOCKET_ERROR) {
+ closesocket(m_socket);
+ m_socket = INVALID_SOCKET;
+ }
+
+ if (bind(m_socket, (struct sockaddr*)&addr, sizeof(addr)) == SOCKET_ERROR) {
+ closesocket(m_socket);
+ m_socket = INVALID_SOCKET;
+ }
+
+ if (IN_MULTICAST(htonl(imr.imr_multiaddr.s_addr))) {
+ int ret = setsockopt(m_socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const char*)&imr, sizeof(imr));
+ if (ret < 0) {
+ ret = ::WSAGetLastError();
+ }
+ ret = ret;
+ }
+ }
+
+ SetThreadPriority(m_hThread, THREAD_PRIORITY_TIME_CRITICAL);
#ifdef _DEBUG
- FILE* dump = NULL;
- // dump = _tfopen(_T("c:\\udp.ts"), _T("wb"));
- FILE* log = NULL;
- // log = _tfopen(_T("c:\\udp.txt"), _T("wt"));
+ FILE* dump = NULL;
+ // dump = _tfopen(_T("c:\\udp.ts"), _T("wb"));
+ FILE* log = NULL;
+ // log = _tfopen(_T("c:\\udp.txt"), _T("wt"));
#endif
- for (;;) {
- DWORD cmd = GetRequest();
-
- switch (cmd) {
- default:
- case CMD_EXIT:
- if (m_socket!=INVALID_SOCKET) {
- closesocket(m_socket);
- m_socket = INVALID_SOCKET;
- }
- WSACleanup();
+ for (;;) {
+ DWORD cmd = GetRequest();
+
+ switch (cmd) {
+ default:
+ case CMD_EXIT:
+ if (m_socket != INVALID_SOCKET) {
+ closesocket(m_socket);
+ m_socket = INVALID_SOCKET;
+ }
+ WSACleanup();
#ifdef _DEBUG
- if (dump) {
- fclose(dump);
- }
- if (log) {
- fclose(log);
- }
+ if (dump) {
+ fclose(dump);
+ }
+ if (log) {
+ fclose(log);
+ }
#endif
- Reply(S_OK);
- return 0;
- case CMD_RUN:
- Reply(m_socket!=INVALID_SOCKET ? S_OK : E_FAIL);
-
- {
- char buff[65536*2];
- int buffsize = 0;
-
- for (unsigned int i = 0; ; i++) {
- if (!(i&0xff)) {
- if (CheckRequest(NULL)) {
- break;
- }
- }
-
- int fromlen = sizeof(addr);
- int len = recvfrom(m_socket, &buff[buffsize], 65536, 0, (SOCKADDR*)&addr, &fromlen);
- if (len <= 0) {
- Sleep(1);
- continue;
- }
+ Reply(S_OK);
+ return 0;
+ case CMD_RUN:
+ Reply(m_socket != INVALID_SOCKET ? S_OK : E_FAIL);
+
+ {
+ char buff[65536 * 2];
+ int buffsize = 0;
+
+ for (unsigned int i = 0; ; i++) {
+ if (!(i & 0xff)) {
+ if (CheckRequest(NULL)) {
+ break;
+ }
+ }
+
+ int fromlen = sizeof(addr);
+ int len = recvfrom(m_socket, &buff[buffsize], 65536, 0, (SOCKADDR*)&addr, &fromlen);
+ if (len <= 0) {
+ Sleep(1);
+ continue;
+ }
#ifdef _DEBUG
- if (log) {
- if (buffsize >= len && !memcmp(&buff[buffsize-len], &buff[buffsize], len)) {
- DWORD pid = ((buff[buffsize+1]<<8)|buff[buffsize+2])&0x1fff;
- DWORD counter = buff[buffsize+3]&0xf;
- _ftprintf_s(log, _T("%04d %2d DUP\n"), pid, counter);
- }
- }
+ if (log) {
+ if (buffsize >= len && !memcmp(&buff[buffsize - len], &buff[buffsize], len)) {
+ DWORD pid = ((buff[buffsize + 1] << 8) | buff[buffsize + 2]) & 0x1fff;
+ DWORD counter = buff[buffsize + 3] & 0xf;
+ _ftprintf_s(log, _T("%04d %2d DUP\n"), pid, counter);
+ }
+ }
#endif
- buffsize += len;
+ buffsize += len;
- if (buffsize >= 65536 || m_len == 0) {
+ if (buffsize >= 65536 || m_len == 0) {
#ifdef _DEBUG
- if (dump) {
- fwrite(buff, buffsize, 1, dump);
- }
-
- if (log) {
- static BYTE pid2counter[0x2000];
- static bool init = false;
- if (!init) {
- memset(pid2counter, 0, sizeof(pid2counter));
- init = true;
- }
-
- for (int i = 0; i < buffsize; i += 188) {
- DWORD pid = ((buff[i+1]<<8)|buff[i+2])&0x1fff;
- BYTE counter = buff[i+3]&0xf;
- if (pid2counter[pid] != ((counter-1+16)&15)) {
- _ftprintf_s(log, _T("%04x %2d -> %2d\n"), pid, pid2counter[pid], counter);
- }
- pid2counter[pid] = counter;
- }
- }
+ if (dump) {
+ fwrite(buff, buffsize, 1, dump);
+ }
+
+ if (log) {
+ static BYTE pid2counter[0x2000];
+ static bool init = false;
+ if (!init) {
+ memset(pid2counter, 0, sizeof(pid2counter));
+ init = true;
+ }
+
+ for (int i = 0; i < buffsize; i += 188) {
+ DWORD pid = ((buff[i + 1] << 8) | buff[i + 2]) & 0x1fff;
+ BYTE counter = buff[i + 3] & 0xf;
+ if (pid2counter[pid] != ((counter - 1 + 16) & 15)) {
+ _ftprintf_s(log, _T("%04x %2d -> %2d\n"), pid, pid2counter[pid], counter);
+ }
+ pid2counter[pid] = counter;
+ }
+ }
#endif
- Append((BYTE*)buff, buffsize);
- buffsize = 0;
- }
- }
- }
- break;
- }
- }
-
- ASSERT(0);
- return (DWORD)-1;
+ Append((BYTE*)buff, buffsize);
+ buffsize = 0;
+ }
+ }
+ }
+ break;
+ }
+ }
+
+ ASSERT(0);
+ return (DWORD) - 1;
}
CUDPStream::packet_t::packet_t(BYTE* p, __int64 start, __int64 end)
- : m_start(start)
- , m_end(end)
+ : m_start(start)
+ , m_end(end)
{
- size_t size = (size_t)(end - start);
- m_buff = DNew BYTE[size];
- memcpy(m_buff, p, size);
+ size_t size = (size_t)(end - start);
+ m_buff = DNew BYTE[size];
+ memcpy(m_buff, p, size);
}
diff --git a/src/filters/reader/UDPReader/UDPReader.h b/src/filters/reader/UDPReader/UDPReader.h
index 1741fd77f..8cce7a74f 100644
--- a/src/filters/reader/UDPReader/UDPReader.h
+++ b/src/filters/reader/UDPReader/UDPReader.h
@@ -32,66 +32,66 @@
class CUDPStream : public CAsyncStream, public CAMThread
{
private:
- CCritSec m_csLock;
+ CCritSec m_csLock;
- class packet_t
- {
- public:
- BYTE* m_buff;
- __int64 m_start, m_end;
- packet_t(BYTE* p, __int64 start, __int64 end);
- virtual ~packet_t() {
- delete [] m_buff;
- }
- };
+ class packet_t
+ {
+ public:
+ BYTE* m_buff;
+ __int64 m_start, m_end;
+ packet_t(BYTE* p, __int64 start, __int64 end);
+ virtual ~packet_t() {
+ delete [] m_buff;
+ }
+ };
- int m_port;
- CString m_ip;
- SOCKET m_socket;
- GUID m_subtype;
- __int64 m_pos, m_len;
- bool m_drop;
- CAtlList<packet_t*> m_packets;
+ int m_port;
+ CString m_ip;
+ SOCKET m_socket;
+ GUID m_subtype;
+ __int64 m_pos, m_len;
+ bool m_drop;
+ CAtlList<packet_t*> m_packets;
- void Clear();
- void Append(BYTE* buff, int len);
+ void Clear();
+ void Append(BYTE* buff, int len);
- enum {CMD_EXIT, CMD_RUN};
- DWORD ThreadProc();
+ enum {CMD_EXIT, CMD_RUN};
+ DWORD ThreadProc();
public:
- CUDPStream();
- virtual ~CUDPStream();
+ CUDPStream();
+ virtual ~CUDPStream();
- bool Load(const WCHAR* fnw);
- const GUID& GetSubType() {
- return m_subtype;
- }
+ bool Load(const WCHAR* fnw);
+ const GUID& GetSubType() {
+ return m_subtype;
+ }
- HRESULT SetPointer(LONGLONG llPos);
- HRESULT Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWORD pdwBytesRead);
- LONGLONG Size(LONGLONG* pSizeAvailable);
- DWORD Alignment();
- void Lock();
- void Unlock();
+ HRESULT SetPointer(LONGLONG llPos);
+ HRESULT Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWORD pdwBytesRead);
+ LONGLONG Size(LONGLONG* pSizeAvailable);
+ DWORD Alignment();
+ void Lock();
+ void Unlock();
};
class __declspec(uuid("0E4221A9-9718-48D5-A5CF-4493DAD4A015"))
- CUDPReader
- : public CAsyncReader
- , public IFileSourceFilter
+ CUDPReader
+ : public CAsyncReader
+ , public IFileSourceFilter
{
- CUDPStream m_stream;
- CStringW m_fn;
+ CUDPStream m_stream;
+ CStringW m_fn;
public:
- CUDPReader(IUnknown* pUnk, HRESULT* phr);
- ~CUDPReader();
+ CUDPReader(IUnknown* pUnk, HRESULT* phr);
+ ~CUDPReader();
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // IFileSourceFilter
- STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
+ // IFileSourceFilter
+ STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
};
diff --git a/src/filters/reader/VTSReader/VTSReader.cpp b/src/filters/reader/VTSReader/VTSReader.cpp
index e6573878c..f88fadb15 100644
--- a/src/filters/reader/VTSReader/VTSReader.cpp
+++ b/src/filters/reader/VTSReader/VTSReader.cpp
@@ -29,41 +29,41 @@
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG2_PROGRAM},
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG2_PROGRAM},
};
const AMOVIESETUP_PIN sudOpPin[] = {
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CVTSReader), VTSReaderName, MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
+ {&__uuidof(CVTSReader), VTSReaderName, MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CVTSReader>, NULL, &sudFilter[0]}
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CVTSReader>, NULL, &sudFilter[0]}
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{773EAEDE-D5EE-4fce-9C8F-C4F53D0A2F73}"),
- _T("0"), _T("0,12,,445644564944454F2D565453")); // "DVDVIDEO-VTS"
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{773EAEDE-D5EE-4fce-9C8F-C4F53D0A2F73}"),
+ _T("0"), _T("0,12,,445644564944454F2D565453")); // "DVDVIDEO-VTS"
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{773EAEDE-D5EE-4fce-9C8F-C4F53D0A2F73}"),
- _T("Source Filter"), _T("{773EAEDE-D5EE-4fce-9C8F-C4F53D0A2F73}"));
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{773EAEDE-D5EE-4fce-9C8F-C4F53D0A2F73}"),
+ _T("Source Filter"), _T("{773EAEDE-D5EE-4fce-9C8F-C4F53D0A2F73}"));
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{773EAEDE-D5EE-4fce-9C8F-C4F53D0A2F73}"));
+ DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{773EAEDE-D5EE-4fce-9C8F-C4F53D0A2F73}"));
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -77,11 +77,11 @@ CFilterApp theApp;
//
CVTSReader::CVTSReader(IUnknown* pUnk, HRESULT* phr)
- : CAsyncReader(NAME("CVTSReader"), pUnk, &m_stream, phr, __uuidof(this))
+ : CAsyncReader(NAME("CVTSReader"), pUnk, &m_stream, phr, __uuidof(this))
{
- if (phr) {
- *phr = S_OK;
- }
+ if (phr) {
+ *phr = S_OK;
+ }
}
CVTSReader::~CVTSReader()
@@ -90,117 +90,117 @@ CVTSReader::~CVTSReader()
STDMETHODIMP CVTSReader::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- QI(IFileSourceFilter)
- QI(ITrackInfo)
- QI(IDSMChapterBag)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IFileSourceFilter)
+ QI(ITrackInfo)
+ QI(IDSMChapterBag)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
STDMETHODIMP CVTSReader::QueryFilterInfo(FILTER_INFO* pInfo)
{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
+ CheckPointer(pInfo, E_POINTER);
+ ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
- wcscpy_s(pInfo->achName, VTSReaderName);
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
+ wcscpy_s(pInfo->achName, VTSReaderName);
+ pInfo->pGraph = m_pGraph;
+ if (m_pGraph) {
+ m_pGraph->AddRef();
+ }
- return S_OK;
+ return S_OK;
}
// IFileSourceFilter
STDMETHODIMP CVTSReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
- if (!m_stream.Load(pszFileName)) {
- return E_FAIL;
- }
+ if (!m_stream.Load(pszFileName)) {
+ return E_FAIL;
+ }
- ChapRemoveAll();
- for (int i=0; i<m_stream.GetChaptersCount(); i++) {
- CString chap; chap.Format(_T("Chapter %d"), i+1);
- ChapAppend(m_stream.GetChapterOffset(i), chap);
- }
+ ChapRemoveAll();
+ for (int i = 0; i < m_stream.GetChaptersCount(); i++) {
+ CString chap; chap.Format(_T("Chapter %d"), i + 1);
+ ChapAppend(m_stream.GetChapterOffset(i), chap);
+ }
- m_fn = pszFileName;
+ m_fn = pszFileName;
- CMediaType mt;
- mt.majortype = MEDIATYPE_Stream;
- mt.subtype = MEDIASUBTYPE_MPEG2_PROGRAM;
- m_mt = mt;
+ CMediaType mt;
+ mt.majortype = MEDIATYPE_Stream;
+ mt.subtype = MEDIASUBTYPE_MPEG2_PROGRAM;
+ m_mt = mt;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CVTSReader::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
{
- if (!ppszFileName) {
- return E_POINTER;
- }
+ if (!ppszFileName) {
+ return E_POINTER;
+ }
- *ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR));
- if (!(*ppszFileName)) {
- return E_OUTOFMEMORY;
- }
+ *ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength() + 1) * sizeof(WCHAR));
+ if (!(*ppszFileName)) {
+ return E_OUTOFMEMORY;
+ }
- wcscpy_s(*ppszFileName, m_fn.GetLength() + 1, m_fn);
+ wcscpy_s(*ppszFileName, m_fn.GetLength() + 1, m_fn);
- return S_OK;
+ return S_OK;
}
// ITrackInfo
STDMETHODIMP_(UINT) CVTSReader::GetTrackCount()
{
- return 0; // Not implemented yet
+ return 0; // Not implemented yet
}
STDMETHODIMP_(BOOL) CVTSReader::GetTrackInfo(UINT aTrackIdx, struct TrackElement* pStructureToFill)
{
- return FALSE; // Not implemented yet
+ return FALSE; // Not implemented yet
}
STDMETHODIMP_(BOOL) CVTSReader::GetTrackExtendedInfo(UINT aTrackIdx, void* pStructureToFill)
{
- return FALSE; // Not implemented yet
+ return FALSE; // Not implemented yet
}
STDMETHODIMP_(BSTR) CVTSReader::GetTrackName(UINT aTrackIdx)
{
- return m_stream.GetTrackName(aTrackIdx); // return stream's language
+ return m_stream.GetTrackName(aTrackIdx); // return stream's language
}
STDMETHODIMP_(BSTR) CVTSReader::GetTrackCodecID(UINT aTrackIdx)
{
- return NULL; // Not implemented yet
+ return NULL; // Not implemented yet
}
STDMETHODIMP_(BSTR) CVTSReader::GetTrackCodecName(UINT aTrackIdx)
{
- return NULL; // Not implemented yet
+ return NULL; // Not implemented yet
}
STDMETHODIMP_(BSTR) CVTSReader::GetTrackCodecInfoURL(UINT aTrackIdx)
{
- return NULL; // Not implemented yet
+ return NULL; // Not implemented yet
}
STDMETHODIMP_(BSTR) CVTSReader::GetTrackCodecDownloadURL(UINT aTrackIdx)
{
- return NULL; // Not implemented yet
+ return NULL; // Not implemented yet
}
// CVTSStream
CVTSStream::CVTSStream() : m_off(0)
{
- m_vob.Attach(DNew CVobFile());
+ m_vob.Attach(DNew CVobFile());
}
CVTSStream::~CVTSStream()
@@ -209,87 +209,87 @@ CVTSStream::~CVTSStream()
bool CVTSStream::Load(const WCHAR* fnw)
{
- CAtlList<CString> sl;
- return (m_vob && m_vob->Open(CString(fnw), sl) /*&& m_vob->IsDVD()*/);
+ CAtlList<CString> sl;
+ return (m_vob && m_vob->Open(CString(fnw), sl) /*&& m_vob->IsDVD()*/);
}
HRESULT CVTSStream::SetPointer(LONGLONG llPos)
{
- m_off = (int)(llPos&2047);
- int lba = (int)(llPos/2048);
+ m_off = (int)(llPos & 2047);
+ int lba = (int)(llPos / 2048);
- return lba == m_vob->Seek(lba) ? S_OK : S_FALSE;
+ return lba == m_vob->Seek(lba) ? S_OK : S_FALSE;
}
HRESULT CVTSStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWORD pdwBytesRead)
{
- CAutoLock lck(&m_csLock);
+ CAutoLock lck(&m_csLock);
- DWORD len = dwBytesToRead;
- BYTE* ptr = pbBuffer;
+ DWORD len = dwBytesToRead;
+ BYTE* ptr = pbBuffer;
- while (len > 0) {
- BYTE buff[2048];
- if (!m_vob->Read(buff)) {
- break;
- }
+ while (len > 0) {
+ BYTE buff[2048];
+ if (!m_vob->Read(buff)) {
+ break;
+ }
- int size = min(2048 - m_off, (int)min(len, 2048));
+ int size = min(2048 - m_off, (int)min(len, 2048));
- memcpy(ptr, &buff[m_off], size);
+ memcpy(ptr, &buff[m_off], size);
- m_off = (m_off + size)&2047;
+ m_off = (m_off + size) & 2047;
- if (m_off > 0) {
- m_vob->Seek(m_vob->GetPosition()-1);
- }
+ if (m_off > 0) {
+ m_vob->Seek(m_vob->GetPosition() - 1);
+ }
- ptr += size;
- len -= size;
- }
+ ptr += size;
+ len -= size;
+ }
- if (pdwBytesRead) {
- *pdwBytesRead = ptr - pbBuffer;
- }
+ if (pdwBytesRead) {
+ *pdwBytesRead = ptr - pbBuffer;
+ }
- return S_OK;
+ return S_OK;
}
LONGLONG CVTSStream::Size(LONGLONG* pSizeAvailable)
{
- LONGLONG len = 2048i64*m_vob->GetLength();
- if (pSizeAvailable) {
- *pSizeAvailable = len;
- }
- return len;
+ LONGLONG len = 2048i64 * m_vob->GetLength();
+ if (pSizeAvailable) {
+ *pSizeAvailable = len;
+ }
+ return len;
}
DWORD CVTSStream::Alignment()
{
- return 1;
+ return 1;
}
void CVTSStream::Lock()
{
- m_csLock.Lock();
+ m_csLock.Lock();
}
void CVTSStream::Unlock()
{
- m_csLock.Unlock();
+ m_csLock.Unlock();
}
BSTR CVTSStream::GetTrackName(UINT aTrackIdx)
{
- return m_vob->GetTrackName(aTrackIdx);
+ return m_vob->GetTrackName(aTrackIdx);
}
int CVTSStream::GetChaptersCount()
{
- return m_vob->GetChaptersCount();
+ return m_vob->GetChaptersCount();
}
REFERENCE_TIME CVTSStream::GetChapterOffset(UINT ChapterNumber)
{
- return m_vob->GetChapterOffset(ChapterNumber);
+ return m_vob->GetChapterOffset(ChapterNumber);
} \ No newline at end of file
diff --git a/src/filters/reader/VTSReader/VTSReader.h b/src/filters/reader/VTSReader/VTSReader.h
index 7b26839a8..6eeab899e 100644
--- a/src/filters/reader/VTSReader/VTSReader.h
+++ b/src/filters/reader/VTSReader/VTSReader.h
@@ -37,62 +37,62 @@ class CVobFile;
class CVTSStream : public CAsyncStream
{
private:
- CCritSec m_csLock;
+ CCritSec m_csLock;
- CAutoPtr<CVobFile> m_vob;
- int m_off;
+ CAutoPtr<CVobFile> m_vob;
+ int m_off;
public:
- CVTSStream();
- virtual ~CVTSStream();
+ CVTSStream();
+ virtual ~CVTSStream();
- bool Load(const WCHAR* fnw);
+ bool Load(const WCHAR* fnw);
- HRESULT SetPointer(LONGLONG llPos);
- HRESULT Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWORD pdwBytesRead);
- LONGLONG Size(LONGLONG* pSizeAvailable);
- DWORD Alignment();
- void Lock();
- void Unlock();
+ HRESULT SetPointer(LONGLONG llPos);
+ HRESULT Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWORD pdwBytesRead);
+ LONGLONG Size(LONGLONG* pSizeAvailable);
+ DWORD Alignment();
+ void Lock();
+ void Unlock();
- BSTR GetTrackName(UINT aTrackIdx);
- int GetChaptersCount();
- REFERENCE_TIME GetChapterOffset(UINT ChapterNumber);
+ BSTR GetTrackName(UINT aTrackIdx);
+ int GetChaptersCount();
+ REFERENCE_TIME GetChapterOffset(UINT ChapterNumber);
};
class __declspec(uuid("773EAEDE-D5EE-4fce-9C8F-C4F53D0A2F73"))
- CVTSReader
- : public CAsyncReader
- , public IFileSourceFilter
- , public ITrackInfo
- , public IDSMChapterBagImpl
+ CVTSReader
+ : public CAsyncReader
+ , public IFileSourceFilter
+ , public ITrackInfo
+ , public IDSMChapterBagImpl
{
- CVTSStream m_stream;
- CStringW m_fn;
+ CVTSStream m_stream;
+ CStringW m_fn;
public:
- CVTSReader(IUnknown* pUnk, HRESULT* phr);
- ~CVTSReader();
+ CVTSReader(IUnknown* pUnk, HRESULT* phr);
+ ~CVTSReader();
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // CBaseFilter
+ // CBaseFilter
- STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
+ STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
- // IFileSourceFilter
- STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
+ // IFileSourceFilter
+ STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
- // ITrackInfo
+ // ITrackInfo
- STDMETHODIMP_(UINT) GetTrackCount();
- STDMETHODIMP_(BOOL) GetTrackInfo(UINT aTrackIdx, struct TrackElement* pStructureToFill);
- STDMETHODIMP_(BOOL) GetTrackExtendedInfo(UINT aTrackIdx, void* pStructureToFill);
- STDMETHODIMP_(BSTR) GetTrackName(UINT aTrackIdx);
- STDMETHODIMP_(BSTR) GetTrackCodecID(UINT aTrackIdx);
- STDMETHODIMP_(BSTR) GetTrackCodecName(UINT aTrackIdx);
- STDMETHODIMP_(BSTR) GetTrackCodecInfoURL(UINT aTrackIdx);
- STDMETHODIMP_(BSTR) GetTrackCodecDownloadURL(UINT aTrackIdx);
+ STDMETHODIMP_(UINT) GetTrackCount();
+ STDMETHODIMP_(BOOL) GetTrackInfo(UINT aTrackIdx, struct TrackElement* pStructureToFill);
+ STDMETHODIMP_(BOOL) GetTrackExtendedInfo(UINT aTrackIdx, void* pStructureToFill);
+ STDMETHODIMP_(BSTR) GetTrackName(UINT aTrackIdx);
+ STDMETHODIMP_(BSTR) GetTrackCodecID(UINT aTrackIdx);
+ STDMETHODIMP_(BSTR) GetTrackCodecName(UINT aTrackIdx);
+ STDMETHODIMP_(BSTR) GetTrackCodecInfoURL(UINT aTrackIdx);
+ STDMETHODIMP_(BSTR) GetTrackCodecDownloadURL(UINT aTrackIdx);
};
diff --git a/src/filters/renderer/MpcAudioRenderer/IMpcAudioRendererFilter.h b/src/filters/renderer/MpcAudioRenderer/IMpcAudioRendererFilter.h
index 04ecf022e..f1dadae38 100644
--- a/src/filters/renderer/MpcAudioRenderer/IMpcAudioRendererFilter.h
+++ b/src/filters/renderer/MpcAudioRenderer/IMpcAudioRendererFilter.h
@@ -27,12 +27,12 @@
interface __declspec(uuid("495D2C66-D430-439b-9DEE-40F9B7929BBA"))
IMpcAudioRendererFilter :
public IUnknown {
- STDMETHOD(Apply()) = 0;
+ STDMETHOD(Apply()) = 0;
- STDMETHOD(SetWasapiMode(BOOL nValue)) = 0;
- STDMETHOD_(BOOL, GetWasapiMode()) = 0;
- STDMETHOD(SetMuteFastForward(BOOL nValue)) = 0;
- STDMETHOD_(BOOL, GetMuteFastForward()) = 0;
- STDMETHOD(SetSoundDevice(CString nValue)) = 0;
- STDMETHOD_(CString, GetSoundDevice()) = 0;
+ STDMETHOD(SetWasapiMode(BOOL nValue)) = 0;
+ STDMETHOD_(BOOL, GetWasapiMode()) = 0;
+ STDMETHOD(SetMuteFastForward(BOOL nValue)) = 0;
+ STDMETHOD_(BOOL, GetMuteFastForward()) = 0;
+ STDMETHOD(SetSoundDevice(CString nValue)) = 0;
+ STDMETHOD_(CString, GetSoundDevice()) = 0;
};
diff --git a/src/filters/renderer/MpcAudioRenderer/MpcAudioRenderer.cpp b/src/filters/renderer/MpcAudioRenderer/MpcAudioRenderer.cpp
index b973327c0..26adf5cb0 100644
--- a/src/filters/renderer/MpcAudioRenderer/MpcAudioRenderer.cpp
+++ b/src/filters/renderer/MpcAudioRenderer/MpcAudioRenderer.cpp
@@ -36,32 +36,32 @@
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&GUID_NULL},
+ {&GUID_NULL},
};
const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CMpcAudioRenderer), MpcAudioRendererName, 0x40000001, _countof(sudpPins), sudpPins, CLSID_AudioRendererCategory},
+ {&__uuidof(CMpcAudioRenderer), MpcAudioRendererName, 0x40000001, _countof(sudpPins), sudpPins, CLSID_AudioRendererCategory},
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, &__uuidof(CMpcAudioRenderer), CreateInstance<CMpcAudioRenderer>, NULL, &sudFilter[0]},
- {L"CMpcAudioRendererPropertyPage", &__uuidof(CMpcAudioRendererSettingsWnd), CreateInstance<CInternalPropertyPageTempl<CMpcAudioRendererSettingsWnd> >},
+ {sudFilter[0].strName, &__uuidof(CMpcAudioRenderer), CreateInstance<CMpcAudioRenderer>, NULL, &sudFilter[0]},
+ {L"CMpcAudioRendererPropertyPage", &__uuidof(CMpcAudioRendererSettingsWnd), CreateInstance<CInternalPropertyPageTempl<CMpcAudioRendererSettingsWnd> >},
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -73,579 +73,578 @@ CFilterApp theApp;
static GUID lpSoundGUID = {0xdef00000, 0x9c6d, 0x47ed, {0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03}}; //DSDEVID_DefaultPlayback from dsound.h
bool CALLBACK DSEnumProc2(LPGUID lpGUID,
- LPCTSTR lpszDesc,
- LPCTSTR lpszDrvName,
- LPVOID lpContext )
+ LPCTSTR lpszDesc,
+ LPCTSTR lpszDrvName,
+ LPVOID lpContext)
{
- CString *pStr = (CString *)lpContext;
- ASSERT ( pStr );
- CString strGUID = *pStr;
-
- if (lpGUID != NULL) // NULL only for "Primary Sound Driver".
- {
- if (strGUID == lpszDesc) {
- memcpy((VOID *)&lpSoundGUID, lpGUID, sizeof(GUID));
- }
- }
-
- return TRUE;
+ CString* pStr = (CString*)lpContext;
+ ASSERT(pStr);
+ CString strGUID = *pStr;
+
+ if (lpGUID != NULL) { // NULL only for "Primary Sound Driver".
+ if (strGUID == lpszDesc) {
+ memcpy((VOID*)&lpSoundGUID, lpGUID, sizeof(GUID));
+ }
+ }
+
+ return TRUE;
}
-CMpcAudioRenderer::CMpcAudioRenderer(LPUNKNOWN punk, HRESULT *phr)
- : CBaseRenderer(__uuidof(this), MpcAudioRendererName, punk, phr)
- , m_pDSBuffer (NULL )
- , m_pSoundTouch (NULL )
- , m_pDS (NULL )
- , m_dwDSWriteOff (0 )
- , m_nDSBufSize (0 )
- , m_dRate (1.0 )
- , m_pReferenceClock (NULL )
- , m_pWaveFileFormat (NULL )
- , pMMDevice (NULL)
- , pAudioClient (NULL )
- , pRenderClient (NULL )
- , m_useWASAPI (true )
- , m_bMuteFastForward(false)
- , m_csSound_Device (_T(""))
- , nFramesInBuffer (0 )
- , hnsPeriod (0 )
- , hTask (NULL )
- , bufferSize (0)
- , isAudioClientStarted (false)
- , lastBufferTime (0)
- , hnsActualDuration (0)
- , m_lVolume(DSBVOLUME_MIN)
+CMpcAudioRenderer::CMpcAudioRenderer(LPUNKNOWN punk, HRESULT* phr)
+ : CBaseRenderer(__uuidof(this), MpcAudioRendererName, punk, phr)
+ , m_pDSBuffer(NULL)
+ , m_pSoundTouch(NULL)
+ , m_pDS(NULL)
+ , m_dwDSWriteOff(0)
+ , m_nDSBufSize(0)
+ , m_dRate(1.0)
+ , m_pReferenceClock(NULL)
+ , m_pWaveFileFormat(NULL)
+ , pMMDevice(NULL)
+ , pAudioClient(NULL)
+ , pRenderClient(NULL)
+ , m_useWASAPI(true)
+ , m_bMuteFastForward(false)
+ , m_csSound_Device(_T(""))
+ , nFramesInBuffer(0)
+ , hnsPeriod(0)
+ , hTask(NULL)
+ , bufferSize(0)
+ , isAudioClientStarted(false)
+ , lastBufferTime(0)
+ , hnsActualDuration(0)
+ , m_lVolume(DSBVOLUME_MIN)
{
- HMODULE hLib;
+ HMODULE hLib;
#ifdef REGISTER_FILTER
- CRegKey key;
- TCHAR buff[256];
- ULONG len;
-
- if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPC Audio Renderer"), KEY_READ)) {
- DWORD dw;
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("UseWasapi"), dw)) {
- m_useWASAPI = !!dw;
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("MuteFastForward"), dw)) {
- m_bMuteFastForward = !!dw;
- }
- len = _countof(buff);
- memset(buff, 0, sizeof(buff));
- if (ERROR_SUCCESS == key.QueryStringValue(_T("SoundDevice"), buff, &len)) {
- m_csSound_Device = CString(buff);
- }
- }
+ CRegKey key;
+ TCHAR buff[256];
+ ULONG len;
+
+ if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPC Audio Renderer"), KEY_READ)) {
+ DWORD dw;
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("UseWasapi"), dw)) {
+ m_useWASAPI = !!dw;
+ }
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("MuteFastForward"), dw)) {
+ m_bMuteFastForward = !!dw;
+ }
+ len = _countof(buff);
+ memset(buff, 0, sizeof(buff));
+ if (ERROR_SUCCESS == key.QueryStringValue(_T("SoundDevice"), buff, &len)) {
+ m_csSound_Device = CString(buff);
+ }
+ }
#else
- m_useWASAPI = !!AfxGetApp()->GetProfileInt(_T("Filters\\MPC Audio Renderer"), _T("UseWasapi"), m_useWASAPI);
- m_bMuteFastForward = !!AfxGetApp()->GetProfileInt(_T("Filters\\MPC Audio Renderer"), _T("MuteFastForward"), m_bMuteFastForward);
- m_csSound_Device = AfxGetApp()->GetProfileString(_T("Filters\\MPC Audio Renderer"), _T("SoundDevice"), _T(""));
+ m_useWASAPI = !!AfxGetApp()->GetProfileInt(_T("Filters\\MPC Audio Renderer"), _T("UseWasapi"), m_useWASAPI);
+ m_bMuteFastForward = !!AfxGetApp()->GetProfileInt(_T("Filters\\MPC Audio Renderer"), _T("MuteFastForward"), m_bMuteFastForward);
+ m_csSound_Device = AfxGetApp()->GetProfileString(_T("Filters\\MPC Audio Renderer"), _T("SoundDevice"), _T(""));
#endif
- m_useWASAPIAfterRestart = m_useWASAPI;
-
-
- // Load Vista specifics DLLs
- hLib = LoadLibrary (L"avrt.dll");
- if (hLib != NULL) {
- pfAvSetMmThreadCharacteristicsW = (PTR_AvSetMmThreadCharacteristicsW) GetProcAddress (hLib, "AvSetMmThreadCharacteristicsW");
- pfAvRevertMmThreadCharacteristics = (PTR_AvRevertMmThreadCharacteristics) GetProcAddress (hLib, "AvRevertMmThreadCharacteristics");
- } else {
- m_useWASAPI = false; // Wasapi not available below Vista
- }
-
- TRACE(_T("CMpcAudioRenderer constructor\n"));
- if (!m_useWASAPI) {
- DirectSoundEnumerate((LPDSENUMCALLBACK)DSEnumProc2, (VOID*)&m_csSound_Device);
- m_pSoundTouch = DNew soundtouch::SoundTouch();
- *phr = DirectSoundCreate8 (&lpSoundGUID, &m_pDS, NULL);
- }
+ m_useWASAPIAfterRestart = m_useWASAPI;
+
+
+ // Load Vista specifics DLLs
+ hLib = LoadLibrary(L"avrt.dll");
+ if (hLib != NULL) {
+ pfAvSetMmThreadCharacteristicsW = (PTR_AvSetMmThreadCharacteristicsW) GetProcAddress(hLib, "AvSetMmThreadCharacteristicsW");
+ pfAvRevertMmThreadCharacteristics = (PTR_AvRevertMmThreadCharacteristics) GetProcAddress(hLib, "AvRevertMmThreadCharacteristics");
+ } else {
+ m_useWASAPI = false; // Wasapi not available below Vista
+ }
+
+ TRACE(_T("CMpcAudioRenderer constructor\n"));
+ if (!m_useWASAPI) {
+ DirectSoundEnumerate((LPDSENUMCALLBACK)DSEnumProc2, (VOID*)&m_csSound_Device);
+ m_pSoundTouch = DNew soundtouch::SoundTouch();
+ *phr = DirectSoundCreate8(&lpSoundGUID, &m_pDS, NULL);
+ }
}
CMpcAudioRenderer::~CMpcAudioRenderer()
{
- Stop();
+ Stop();
- SAFE_DELETE (m_pSoundTouch);
- SAFE_RELEASE (m_pDSBuffer);
- SAFE_RELEASE (m_pDS);
+ SAFE_DELETE(m_pSoundTouch);
+ SAFE_RELEASE(m_pDSBuffer);
+ SAFE_RELEASE(m_pDS);
- SAFE_RELEASE (pRenderClient);
- SAFE_RELEASE (pAudioClient);
- SAFE_RELEASE (pMMDevice);
+ SAFE_RELEASE(pRenderClient);
+ SAFE_RELEASE(pAudioClient);
+ SAFE_RELEASE(pMMDevice);
- if (m_pReferenceClock) {
- SetSyncSource(NULL);
- SAFE_RELEASE (m_pReferenceClock);
- }
+ if (m_pReferenceClock) {
+ SetSyncSource(NULL);
+ SAFE_RELEASE(m_pReferenceClock);
+ }
- if (m_pWaveFileFormat) {
- BYTE *p = (BYTE *)m_pWaveFileFormat;
- SAFE_DELETE_ARRAY(p);
- }
+ if (m_pWaveFileFormat) {
+ BYTE* p = (BYTE*)m_pWaveFileFormat;
+ SAFE_DELETE_ARRAY(p);
+ }
- if (hTask != NULL && pfAvRevertMmThreadCharacteristics != NULL) {
- pfAvRevertMmThreadCharacteristics(hTask);
- }
+ if (hTask != NULL && pfAvRevertMmThreadCharacteristics != NULL) {
+ pfAvRevertMmThreadCharacteristics(hTask);
+ }
}
-HRESULT CMpcAudioRenderer::CheckInputType(const CMediaType *pmt)
+HRESULT CMpcAudioRenderer::CheckInputType(const CMediaType* pmt)
{
- return CheckMediaType(pmt);
+ return CheckMediaType(pmt);
}
-HRESULT CMpcAudioRenderer::CheckMediaType(const CMediaType *pmt)
+HRESULT CMpcAudioRenderer::CheckMediaType(const CMediaType* pmt)
{
- HRESULT hr = S_OK;
- if (pmt == NULL) {
- return E_INVALIDARG;
- }
- TRACE(_T("CMpcAudioRenderer::CheckMediaType\n"));
- WAVEFORMATEX *pwfx = (WAVEFORMATEX *) pmt->Format();
-
- if (pwfx == NULL) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- if ((pmt->majortype != MEDIATYPE_Audio ) ||
- (pmt->formattype != FORMAT_WaveFormatEx )) {
- TRACE(_T("CMpcAudioRenderer::CheckMediaType Not supported\n"));
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- if (m_useWASAPI) {
- hr=CheckAudioClient((WAVEFORMATEX *)NULL);
- if (FAILED(hr)) {
- TRACE(_T("CMpcAudioRenderer::CheckMediaType Error on check audio client\n"));
- return hr;
- }
- if (!pAudioClient) {
- TRACE(_T("CMpcAudioRenderer::CheckMediaType Error, audio client not loaded\n"));
- return VFW_E_CANNOT_CONNECT;
- }
-
- if (pAudioClient->IsFormatSupported(AUDCLNT_SHAREMODE_EXCLUSIVE, pwfx, NULL) != S_OK) {
- TRACE(_T("CMpcAudioRenderer::CheckMediaType WASAPI client refused the format\n"));
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- TRACE(_T("CMpcAudioRenderer::CheckMediaType WASAPI client accepted the format\n"));
- } else if (pwfx->wFormatTag != WAVE_FORMAT_PCM) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- return S_OK;
+ HRESULT hr = S_OK;
+ if (pmt == NULL) {
+ return E_INVALIDARG;
+ }
+ TRACE(_T("CMpcAudioRenderer::CheckMediaType\n"));
+ WAVEFORMATEX* pwfx = (WAVEFORMATEX*) pmt->Format();
+
+ if (pwfx == NULL) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+
+ if ((pmt->majortype != MEDIATYPE_Audio) ||
+ (pmt->formattype != FORMAT_WaveFormatEx)) {
+ TRACE(_T("CMpcAudioRenderer::CheckMediaType Not supported\n"));
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+
+ if (m_useWASAPI) {
+ hr = CheckAudioClient((WAVEFORMATEX*)NULL);
+ if (FAILED(hr)) {
+ TRACE(_T("CMpcAudioRenderer::CheckMediaType Error on check audio client\n"));
+ return hr;
+ }
+ if (!pAudioClient) {
+ TRACE(_T("CMpcAudioRenderer::CheckMediaType Error, audio client not loaded\n"));
+ return VFW_E_CANNOT_CONNECT;
+ }
+
+ if (pAudioClient->IsFormatSupported(AUDCLNT_SHAREMODE_EXCLUSIVE, pwfx, NULL) != S_OK) {
+ TRACE(_T("CMpcAudioRenderer::CheckMediaType WASAPI client refused the format\n"));
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+ TRACE(_T("CMpcAudioRenderer::CheckMediaType WASAPI client accepted the format\n"));
+ } else if (pwfx->wFormatTag != WAVE_FORMAT_PCM) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+ return S_OK;
}
-void CMpcAudioRenderer::OnReceiveFirstSample(IMediaSample *pMediaSample)
+void CMpcAudioRenderer::OnReceiveFirstSample(IMediaSample* pMediaSample)
{
- if (!m_useWASAPI) {
- ClearBuffer();
- }
+ if (!m_useWASAPI) {
+ ClearBuffer();
+ }
}
-BOOL CMpcAudioRenderer::ScheduleSample(IMediaSample *pMediaSample)
+BOOL CMpcAudioRenderer::ScheduleSample(IMediaSample* pMediaSample)
{
- REFERENCE_TIME StartSample;
- REFERENCE_TIME EndSample;
-
- // Is someone pulling our leg
- if (pMediaSample == NULL) {
- return FALSE;
- }
-
- // Get the next sample due up for rendering. If there aren't any ready
- // then GetNextSampleTimes returns an error. If there is one to be done
- // then it succeeds and yields the sample times. If it is due now then
- // it returns S_OK other if it's to be done when due it returns S_FALSE
- HRESULT hr = GetSampleTimes(pMediaSample, &StartSample, &EndSample);
- if (FAILED(hr)) {
- return FALSE;
- }
-
- // If we don't have a reference clock then we cannot set up the advise
- // time so we simply set the event indicating an image to render. This
- // will cause us to run flat out without any timing or synchronisation
- if (hr == S_OK) {
- EXECUTE_ASSERT(SetEvent((HANDLE) m_RenderEvent));
- return TRUE;
- }
-
- if (m_dRate <= 1.1) {
- ASSERT(m_dwAdvise == 0);
- ASSERT(m_pClock);
- WaitForSingleObject((HANDLE)m_RenderEvent,0);
-
- hr = m_pClock->AdviseTime( (REFERENCE_TIME) m_tStart, StartSample, (HEVENT)(HANDLE) m_RenderEvent, &m_dwAdvise);
- if (SUCCEEDED(hr)) {
- return TRUE;
- }
- } else {
- hr = DoRenderSample (pMediaSample);
- }
-
- // We could not schedule the next sample for rendering despite the fact
- // we have a valid sample here. This is a fair indication that either
- // the system clock is wrong or the time stamp for the sample is duff
- ASSERT(m_dwAdvise == 0);
-
- return FALSE;
+ REFERENCE_TIME StartSample;
+ REFERENCE_TIME EndSample;
+
+ // Is someone pulling our leg
+ if (pMediaSample == NULL) {
+ return FALSE;
+ }
+
+ // Get the next sample due up for rendering. If there aren't any ready
+ // then GetNextSampleTimes returns an error. If there is one to be done
+ // then it succeeds and yields the sample times. If it is due now then
+ // it returns S_OK other if it's to be done when due it returns S_FALSE
+ HRESULT hr = GetSampleTimes(pMediaSample, &StartSample, &EndSample);
+ if (FAILED(hr)) {
+ return FALSE;
+ }
+
+ // If we don't have a reference clock then we cannot set up the advise
+ // time so we simply set the event indicating an image to render. This
+ // will cause us to run flat out without any timing or synchronisation
+ if (hr == S_OK) {
+ EXECUTE_ASSERT(SetEvent((HANDLE) m_RenderEvent));
+ return TRUE;
+ }
+
+ if (m_dRate <= 1.1) {
+ ASSERT(m_dwAdvise == 0);
+ ASSERT(m_pClock);
+ WaitForSingleObject((HANDLE)m_RenderEvent, 0);
+
+ hr = m_pClock->AdviseTime((REFERENCE_TIME) m_tStart, StartSample, (HEVENT)(HANDLE) m_RenderEvent, &m_dwAdvise);
+ if (SUCCEEDED(hr)) {
+ return TRUE;
+ }
+ } else {
+ hr = DoRenderSample(pMediaSample);
+ }
+
+ // We could not schedule the next sample for rendering despite the fact
+ // we have a valid sample here. This is a fair indication that either
+ // the system clock is wrong or the time stamp for the sample is duff
+ ASSERT(m_dwAdvise == 0);
+
+ return FALSE;
}
-HRESULT CMpcAudioRenderer::DoRenderSample(IMediaSample *pMediaSample)
+HRESULT CMpcAudioRenderer::DoRenderSample(IMediaSample* pMediaSample)
{
- if (m_useWASAPI) {
- return DoRenderSampleWasapi(pMediaSample);
- } else {
- return DoRenderSampleDirectSound(pMediaSample);
- }
+ if (m_useWASAPI) {
+ return DoRenderSampleWasapi(pMediaSample);
+ } else {
+ return DoRenderSampleDirectSound(pMediaSample);
+ }
}
-STDMETHODIMP CMpcAudioRenderer::NonDelegatingQueryInterface(REFIID riid, void **ppv)
+STDMETHODIMP CMpcAudioRenderer::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- if (riid == IID_IReferenceClock) {
- return GetReferenceClockInterface(riid, ppv);
- } else if (riid == IID_IDispatch) {
- return GetInterface(static_cast<IDispatch*>(this), ppv);
- } else if (riid == IID_IBasicAudio) {
- return GetInterface(static_cast<IBasicAudio*>(this), ppv);
- } else if (riid == __uuidof(ISpecifyPropertyPages)) {
- return GetInterface(static_cast<ISpecifyPropertyPages*>(this), ppv);
- } else if (riid == __uuidof(ISpecifyPropertyPages2)) {
- return GetInterface(static_cast<ISpecifyPropertyPages2*>(this), ppv);
- } else if (riid == __uuidof(IMpcAudioRendererFilter)) {
- return GetInterface(static_cast<IMpcAudioRendererFilter*>(this), ppv);
- }
-
- return CBaseRenderer::NonDelegatingQueryInterface (riid, ppv);
+ if (riid == IID_IReferenceClock) {
+ return GetReferenceClockInterface(riid, ppv);
+ } else if (riid == IID_IDispatch) {
+ return GetInterface(static_cast<IDispatch*>(this), ppv);
+ } else if (riid == IID_IBasicAudio) {
+ return GetInterface(static_cast<IBasicAudio*>(this), ppv);
+ } else if (riid == __uuidof(ISpecifyPropertyPages)) {
+ return GetInterface(static_cast<ISpecifyPropertyPages*>(this), ppv);
+ } else if (riid == __uuidof(ISpecifyPropertyPages2)) {
+ return GetInterface(static_cast<ISpecifyPropertyPages2*>(this), ppv);
+ } else if (riid == __uuidof(IMpcAudioRendererFilter)) {
+ return GetInterface(static_cast<IMpcAudioRendererFilter*>(this), ppv);
+ }
+
+ return CBaseRenderer::NonDelegatingQueryInterface(riid, ppv);
}
-HRESULT CMpcAudioRenderer::SetMediaType(const CMediaType *pmt)
+HRESULT CMpcAudioRenderer::SetMediaType(const CMediaType* pmt)
{
- if (! pmt) {
- return E_POINTER;
- }
- TRACE(_T("CMpcAudioRenderer::SetMediaType\n"));
-
- if (m_useWASAPI) {
- // New media type set but render client already initialized => reset it
- if (pRenderClient!=NULL) {
- WAVEFORMATEX *pNewWf = (WAVEFORMATEX *) pmt->Format();
- TRACE(_T("CMpcAudioRenderer::SetMediaType Render client already initialized. Reinitialization...\n"));
- CheckAudioClient(pNewWf);
- }
- }
-
- if (m_pWaveFileFormat) {
- BYTE *p = (BYTE *)m_pWaveFileFormat;
- SAFE_DELETE_ARRAY(p);
- }
- m_pWaveFileFormat=NULL;
-
- WAVEFORMATEX *pwf = (WAVEFORMATEX *) pmt->Format();
- if (pwf!=NULL) {
- int size = sizeof(WAVEFORMATEX) + pwf->cbSize;
-
- m_pWaveFileFormat = (WAVEFORMATEX *)DNew BYTE[size];
- if (! m_pWaveFileFormat) {
- return E_OUTOFMEMORY;
- }
-
- memcpy(m_pWaveFileFormat, pwf, size);
-
-
- if (!m_useWASAPI && m_pSoundTouch && (pwf->nChannels <= 2)) {
- m_pSoundTouch->setSampleRate (pwf->nSamplesPerSec);
- m_pSoundTouch->setChannels (pwf->nChannels);
- m_pSoundTouch->setTempoChange (0);
- m_pSoundTouch->setPitchSemiTones(0);
- }
- }
-
- return CBaseRenderer::SetMediaType (pmt);
+ if (! pmt) {
+ return E_POINTER;
+ }
+ TRACE(_T("CMpcAudioRenderer::SetMediaType\n"));
+
+ if (m_useWASAPI) {
+ // New media type set but render client already initialized => reset it
+ if (pRenderClient != NULL) {
+ WAVEFORMATEX* pNewWf = (WAVEFORMATEX*) pmt->Format();
+ TRACE(_T("CMpcAudioRenderer::SetMediaType Render client already initialized. Reinitialization...\n"));
+ CheckAudioClient(pNewWf);
+ }
+ }
+
+ if (m_pWaveFileFormat) {
+ BYTE* p = (BYTE*)m_pWaveFileFormat;
+ SAFE_DELETE_ARRAY(p);
+ }
+ m_pWaveFileFormat = NULL;
+
+ WAVEFORMATEX* pwf = (WAVEFORMATEX*) pmt->Format();
+ if (pwf != NULL) {
+ int size = sizeof(WAVEFORMATEX) + pwf->cbSize;
+
+ m_pWaveFileFormat = (WAVEFORMATEX*)DNew BYTE[size];
+ if (! m_pWaveFileFormat) {
+ return E_OUTOFMEMORY;
+ }
+
+ memcpy(m_pWaveFileFormat, pwf, size);
+
+
+ if (!m_useWASAPI && m_pSoundTouch && (pwf->nChannels <= 2)) {
+ m_pSoundTouch->setSampleRate(pwf->nSamplesPerSec);
+ m_pSoundTouch->setChannels(pwf->nChannels);
+ m_pSoundTouch->setTempoChange(0);
+ m_pSoundTouch->setPitchSemiTones(0);
+ }
+ }
+
+ return CBaseRenderer::SetMediaType(pmt);
}
-HRESULT CMpcAudioRenderer::CompleteConnect(IPin *pReceivePin)
+HRESULT CMpcAudioRenderer::CompleteConnect(IPin* pReceivePin)
{
- HRESULT hr = S_OK;
- TRACE(_T("CMpcAudioRenderer::CompleteConnect\n"));
-
- if (!m_useWASAPI && ! m_pDS) {
- return E_FAIL;
- }
-
- if (SUCCEEDED(hr)) {
- hr = CBaseRenderer::CompleteConnect(pReceivePin);
- }
- if (SUCCEEDED(hr)) {
- hr = InitCoopLevel();
- }
-
- if (!m_useWASAPI) {
- if (SUCCEEDED(hr)) {
- hr = CreateDSBuffer();
- }
- }
- if (SUCCEEDED(hr)) {
- TRACE(_T("CMpcAudioRenderer::CompleteConnect Success\n"));
- }
- return hr;
+ HRESULT hr = S_OK;
+ TRACE(_T("CMpcAudioRenderer::CompleteConnect\n"));
+
+ if (!m_useWASAPI && ! m_pDS) {
+ return E_FAIL;
+ }
+
+ if (SUCCEEDED(hr)) {
+ hr = CBaseRenderer::CompleteConnect(pReceivePin);
+ }
+ if (SUCCEEDED(hr)) {
+ hr = InitCoopLevel();
+ }
+
+ if (!m_useWASAPI) {
+ if (SUCCEEDED(hr)) {
+ hr = CreateDSBuffer();
+ }
+ }
+ if (SUCCEEDED(hr)) {
+ TRACE(_T("CMpcAudioRenderer::CompleteConnect Success\n"));
+ }
+ return hr;
}
STDMETHODIMP CMpcAudioRenderer::Run(REFERENCE_TIME tStart)
{
- HRESULT hr;
-
- if (m_State == State_Running) {
- return NOERROR;
- }
-
- if (m_useWASAPI) {
- hr=CheckAudioClient(m_pWaveFileFormat);
- if (FAILED(hr)) {
- TRACE(_T("CMpcAudioRenderer::Run Error on check audio client\n"));
- return hr;
- }
- // Rather start the client at the last moment when the buffer is fed
- /*hr = pAudioClient->Start();
- if (FAILED (hr))
- {
- TRACE(_T("CMpcAudioRenderer::Run Start error"));
- return hr;
- }*/
- } else {
- if (m_pDSBuffer &&
- m_pPosition &&
- m_pWaveFileFormat &&
- SUCCEEDED(m_pPosition->GetRate(&m_dRate))) {
- if (m_dRate < 1.0) {
- hr = m_pDSBuffer->SetFrequency ((long)(m_pWaveFileFormat->nSamplesPerSec * m_dRate));
- if (FAILED (hr)) {
- return hr;
- }
- } else {
- hr = m_pDSBuffer->SetFrequency ((long)m_pWaveFileFormat->nSamplesPerSec);
- m_pSoundTouch->setRateChange((float)(m_dRate-1.0)*100);
-
- if (m_bMuteFastForward) {
- if (m_dRate == 1.0) {
- m_pDSBuffer->SetVolume(m_lVolume);
- } else {
- m_pDSBuffer->SetVolume(DSBVOLUME_MIN);
- }
- }
- }
- }
-
- ClearBuffer();
- }
- hr = CBaseRenderer::Run(tStart);
-
- return hr;
+ HRESULT hr;
+
+ if (m_State == State_Running) {
+ return NOERROR;
+ }
+
+ if (m_useWASAPI) {
+ hr = CheckAudioClient(m_pWaveFileFormat);
+ if (FAILED(hr)) {
+ TRACE(_T("CMpcAudioRenderer::Run Error on check audio client\n"));
+ return hr;
+ }
+ // Rather start the client at the last moment when the buffer is fed
+ /*hr = pAudioClient->Start();
+ if (FAILED (hr))
+ {
+ TRACE(_T("CMpcAudioRenderer::Run Start error"));
+ return hr;
+ }*/
+ } else {
+ if (m_pDSBuffer &&
+ m_pPosition &&
+ m_pWaveFileFormat &&
+ SUCCEEDED(m_pPosition->GetRate(&m_dRate))) {
+ if (m_dRate < 1.0) {
+ hr = m_pDSBuffer->SetFrequency((long)(m_pWaveFileFormat->nSamplesPerSec * m_dRate));
+ if (FAILED(hr)) {
+ return hr;
+ }
+ } else {
+ hr = m_pDSBuffer->SetFrequency((long)m_pWaveFileFormat->nSamplesPerSec);
+ m_pSoundTouch->setRateChange((float)(m_dRate - 1.0) * 100);
+
+ if (m_bMuteFastForward) {
+ if (m_dRate == 1.0) {
+ m_pDSBuffer->SetVolume(m_lVolume);
+ } else {
+ m_pDSBuffer->SetVolume(DSBVOLUME_MIN);
+ }
+ }
+ }
+ }
+
+ ClearBuffer();
+ }
+ hr = CBaseRenderer::Run(tStart);
+
+ return hr;
}
STDMETHODIMP CMpcAudioRenderer::Stop()
{
- if (m_pDSBuffer) {
- m_pDSBuffer->Stop();
- }
- isAudioClientStarted=false;
+ if (m_pDSBuffer) {
+ m_pDSBuffer->Stop();
+ }
+ isAudioClientStarted = false;
- return CBaseRenderer::Stop();
+ return CBaseRenderer::Stop();
};
STDMETHODIMP CMpcAudioRenderer::Pause()
{
- if (m_pDSBuffer) {
- m_pDSBuffer->Stop();
- }
- if (pAudioClient && isAudioClientStarted) {
- pAudioClient->Stop();
- }
- isAudioClientStarted=false;
-
- return CBaseRenderer::Pause();
+ if (m_pDSBuffer) {
+ m_pDSBuffer->Stop();
+ }
+ if (pAudioClient && isAudioClientStarted) {
+ pAudioClient->Stop();
+ }
+ isAudioClientStarted = false;
+
+ return CBaseRenderer::Pause();
};
// === IDispatch
-STDMETHODIMP CMpcAudioRenderer::GetTypeInfoCount(UINT * pctinfo)
+STDMETHODIMP CMpcAudioRenderer::GetTypeInfoCount(UINT* pctinfo)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CMpcAudioRenderer::GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CMpcAudioRenderer::GetIDsOfNames(REFIID riid, OLECHAR** rgszNames, UINT cNames, LCID lcid, DISPID* rgdispid)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CMpcAudioRenderer::Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult, EXCEPINFO* pexcepinfo, UINT* puArgErr)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// === IBasicAudio
STDMETHODIMP CMpcAudioRenderer::put_Volume(long lVolume)
{
- m_lVolume = lVolume;
- if (!m_useWASAPI && m_pDSBuffer) {
- return m_pDSBuffer->SetVolume(lVolume);
- }
+ m_lVolume = lVolume;
+ if (!m_useWASAPI && m_pDSBuffer) {
+ return m_pDSBuffer->SetVolume(lVolume);
+ }
- return S_OK;
+ return S_OK;
}
-STDMETHODIMP CMpcAudioRenderer::get_Volume(long *plVolume)
+STDMETHODIMP CMpcAudioRenderer::get_Volume(long* plVolume)
{
- if (!m_useWASAPI && m_pDSBuffer) {
- return m_pDSBuffer->GetVolume(plVolume);
- }
+ if (!m_useWASAPI && m_pDSBuffer) {
+ return m_pDSBuffer->GetVolume(plVolume);
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CMpcAudioRenderer::put_Balance(long lBalance)
{
- if (!m_useWASAPI && m_pDSBuffer) {
- return m_pDSBuffer->SetPan(lBalance);
- }
+ if (!m_useWASAPI && m_pDSBuffer) {
+ return m_pDSBuffer->SetPan(lBalance);
+ }
- return S_OK;
+ return S_OK;
}
-STDMETHODIMP CMpcAudioRenderer::get_Balance(long *plBalance)
+STDMETHODIMP CMpcAudioRenderer::get_Balance(long* plBalance)
{
- if (!m_useWASAPI && m_pDSBuffer) {
- return m_pDSBuffer->GetPan(plBalance);
- }
+ if (!m_useWASAPI && m_pDSBuffer) {
+ return m_pDSBuffer->GetPan(plBalance);
+ }
- return S_OK;
+ return S_OK;
}
// === ISpecifyPropertyPages2
STDMETHODIMP CMpcAudioRenderer::GetPages(CAUUID* pPages)
{
- CheckPointer(pPages, E_POINTER);
+ CheckPointer(pPages, E_POINTER);
- pPages->cElems = 1;
+ pPages->cElems = 1;
- pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID) * pPages->cElems);
- pPages->pElems[0] = __uuidof(CMpcAudioRendererSettingsWnd);
+ pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID) * pPages->cElems);
+ pPages->pElems[0] = __uuidof(CMpcAudioRendererSettingsWnd);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CMpcAudioRenderer::CreatePage(const GUID& guid, IPropertyPage** ppPage)
{
- CheckPointer(ppPage, E_POINTER);
+ CheckPointer(ppPage, E_POINTER);
- if (*ppPage != NULL) {
- return E_INVALIDARG;
- }
+ if (*ppPage != NULL) {
+ return E_INVALIDARG;
+ }
- HRESULT hr;
+ HRESULT hr;
- if (guid == __uuidof(CMpcAudioRendererSettingsWnd)) {
- (*ppPage = DNew CInternalPropertyPageTempl<CMpcAudioRendererSettingsWnd>(NULL, &hr))->AddRef();
- }
+ if (guid == __uuidof(CMpcAudioRendererSettingsWnd)) {
+ (*ppPage = DNew CInternalPropertyPageTempl<CMpcAudioRendererSettingsWnd>(NULL, &hr))->AddRef();
+ }
- return *ppPage ? S_OK : E_FAIL;
+ return *ppPage ? S_OK : E_FAIL;
}
// === IMpcAudioRendererFilter
STDMETHODIMP CMpcAudioRenderer::Apply()
{
#ifdef REGISTER_FILTER
- CRegKey key;
- if (ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPC Audio Renderer"))) {
- key.SetDWORDValue(_T("UseWasapi"), m_useWASAPIAfterRestart);
- key.SetDWORDValue(_T("MuteFastForward"), m_bMuteFastForward);
- key.SetStringValue(_T("SoundDevice"), m_csSound_Device);
- }
+ CRegKey key;
+ if (ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPC Audio Renderer"))) {
+ key.SetDWORDValue(_T("UseWasapi"), m_useWASAPIAfterRestart);
+ key.SetDWORDValue(_T("MuteFastForward"), m_bMuteFastForward);
+ key.SetStringValue(_T("SoundDevice"), m_csSound_Device);
+ }
#else
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPC Audio Renderer"), _T("UseWasapi"), m_useWASAPI);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPC Audio Renderer"), _T("MuteFastForward"), m_bMuteFastForward);
- AfxGetApp()->WriteProfileString(_T("Filters\\MPC Audio Renderer"), _T("SoundDevice"), m_csSound_Device);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPC Audio Renderer"), _T("UseWasapi"), m_useWASAPI);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPC Audio Renderer"), _T("MuteFastForward"), m_bMuteFastForward);
+ AfxGetApp()->WriteProfileString(_T("Filters\\MPC Audio Renderer"), _T("SoundDevice"), m_csSound_Device);
#endif
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CMpcAudioRenderer::SetWasapiMode(BOOL nValue)
{
- CAutoLock cAutoLock(&m_csProps);
- m_useWASAPIAfterRestart = !!nValue;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_useWASAPIAfterRestart = !!nValue;
+ return S_OK;
}
STDMETHODIMP_(BOOL) CMpcAudioRenderer::GetWasapiMode()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_useWASAPIAfterRestart;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_useWASAPIAfterRestart;
}
STDMETHODIMP CMpcAudioRenderer::SetMuteFastForward(BOOL nValue)
{
- CAutoLock cAutoLock(&m_csProps);
- m_bMuteFastForward = !!nValue;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_bMuteFastForward = !!nValue;
+ return S_OK;
}
STDMETHODIMP_(BOOL) CMpcAudioRenderer::GetMuteFastForward()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_bMuteFastForward;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_bMuteFastForward;
}
STDMETHODIMP CMpcAudioRenderer::SetSoundDevice(CString nValue)
{
- CAutoLock cAutoLock(&m_csProps);
- m_csSound_Device = nValue;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_csSound_Device = nValue;
+ return S_OK;
}
STDMETHODIMP_(CString) CMpcAudioRenderer::GetSoundDevice()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_csSound_Device;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_csSound_Device;
}
-HRESULT CMpcAudioRenderer::GetReferenceClockInterface(REFIID riid, void **ppv)
+HRESULT CMpcAudioRenderer::GetReferenceClockInterface(REFIID riid, void** ppv)
{
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- if (m_pReferenceClock) {
- return m_pReferenceClock->NonDelegatingQueryInterface(riid, ppv);
- }
+ if (m_pReferenceClock) {
+ return m_pReferenceClock->NonDelegatingQueryInterface(riid, ppv);
+ }
- m_pReferenceClock = DNew CBaseReferenceClock (NAME("Mpc Audio Clock"), NULL, &hr);
- if (! m_pReferenceClock) {
- return E_OUTOFMEMORY;
- }
+ m_pReferenceClock = DNew CBaseReferenceClock(NAME("Mpc Audio Clock"), NULL, &hr);
+ if (! m_pReferenceClock) {
+ return E_OUTOFMEMORY;
+ }
- m_pReferenceClock->AddRef();
+ m_pReferenceClock->AddRef();
- hr = SetSyncSource(m_pReferenceClock);
- if (FAILED(hr)) {
- SetSyncSource(NULL);
- return hr;
- }
+ hr = SetSyncSource(m_pReferenceClock);
+ if (FAILED(hr)) {
+ SetSyncSource(NULL);
+ return hr;
+ }
- return GetReferenceClockInterface(riid, ppv);
+ return GetReferenceClockInterface(riid, ppv);
}
HRESULT CMpcAudioRenderer::EndOfStream(void)
{
- if (m_pDSBuffer) {
- m_pDSBuffer->Stop();
- }
+ if (m_pDSBuffer) {
+ m_pDSBuffer->Stop();
+ }
#if !FILEWRITER
- if (pAudioClient && isAudioClientStarted) {
- pAudioClient->Stop();
- }
+ if (pAudioClient && isAudioClientStarted) {
+ pAudioClient->Stop();
+ }
#endif
- isAudioClientStarted=false;
+ isAudioClientStarted = false;
- return CBaseRenderer::EndOfStream();
+ return CBaseRenderer::EndOfStream();
}
@@ -653,674 +652,659 @@ HRESULT CMpcAudioRenderer::EndOfStream(void)
HRESULT CMpcAudioRenderer::CreateDSBuffer()
{
- if (! m_pWaveFileFormat) {
- return E_POINTER;
- }
-
- HRESULT hr = S_OK;
- LPDIRECTSOUNDBUFFER pDSBPrimary = NULL;
- DSBUFFERDESC dsbd;
- DSBUFFERDESC cDSBufferDesc;
- DSBCAPS bufferCaps;
- DWORD dwDSBufSize = m_pWaveFileFormat->nAvgBytesPerSec * 4;
-
- ZeroMemory(&bufferCaps, sizeof(bufferCaps));
- ZeroMemory(&dsbd, sizeof(DSBUFFERDESC));
-
- dsbd.dwSize = sizeof(DSBUFFERDESC);
- dsbd.dwFlags = DSBCAPS_PRIMARYBUFFER;
- dsbd.dwBufferBytes = 0;
- dsbd.lpwfxFormat = NULL;
- if (SUCCEEDED (hr = m_pDS->CreateSoundBuffer( &dsbd, &pDSBPrimary, NULL ))) {
- hr = pDSBPrimary->SetFormat(m_pWaveFileFormat);
- ATLASSERT(SUCCEEDED(hr));
- SAFE_RELEASE (pDSBPrimary);
- }
-
-
- SAFE_RELEASE (m_pDSBuffer);
- cDSBufferDesc.dwSize = sizeof (DSBUFFERDESC);
- cDSBufferDesc.dwFlags = DSBCAPS_GLOBALFOCUS |
- DSBCAPS_GETCURRENTPOSITION2 |
- DSBCAPS_CTRLVOLUME |
- DSBCAPS_CTRLPAN |
- DSBCAPS_CTRLFREQUENCY;
- cDSBufferDesc.dwBufferBytes = dwDSBufSize;
- cDSBufferDesc.dwReserved = 0;
- cDSBufferDesc.lpwfxFormat = m_pWaveFileFormat;
- cDSBufferDesc.guid3DAlgorithm = GUID_NULL;
-
- hr = m_pDS->CreateSoundBuffer (&cDSBufferDesc, &m_pDSBuffer, NULL);
-
- m_nDSBufSize = 0;
- if (SUCCEEDED(hr)) {
- bufferCaps.dwSize = sizeof(bufferCaps);
- hr = m_pDSBuffer->GetCaps(&bufferCaps);
- }
- if (SUCCEEDED (hr)) {
- m_nDSBufSize = bufferCaps.dwBufferBytes;
- hr = ClearBuffer();
- m_pDSBuffer->SetFrequency ((long)(m_pWaveFileFormat->nSamplesPerSec * m_dRate));
- }
-
- return hr;
+ if (! m_pWaveFileFormat) {
+ return E_POINTER;
+ }
+
+ HRESULT hr = S_OK;
+ LPDIRECTSOUNDBUFFER pDSBPrimary = NULL;
+ DSBUFFERDESC dsbd;
+ DSBUFFERDESC cDSBufferDesc;
+ DSBCAPS bufferCaps;
+ DWORD dwDSBufSize = m_pWaveFileFormat->nAvgBytesPerSec * 4;
+
+ ZeroMemory(&bufferCaps, sizeof(bufferCaps));
+ ZeroMemory(&dsbd, sizeof(DSBUFFERDESC));
+
+ dsbd.dwSize = sizeof(DSBUFFERDESC);
+ dsbd.dwFlags = DSBCAPS_PRIMARYBUFFER;
+ dsbd.dwBufferBytes = 0;
+ dsbd.lpwfxFormat = NULL;
+ if (SUCCEEDED(hr = m_pDS->CreateSoundBuffer(&dsbd, &pDSBPrimary, NULL))) {
+ hr = pDSBPrimary->SetFormat(m_pWaveFileFormat);
+ ATLASSERT(SUCCEEDED(hr));
+ SAFE_RELEASE(pDSBPrimary);
+ }
+
+
+ SAFE_RELEASE(m_pDSBuffer);
+ cDSBufferDesc.dwSize = sizeof(DSBUFFERDESC);
+ cDSBufferDesc.dwFlags = DSBCAPS_GLOBALFOCUS |
+ DSBCAPS_GETCURRENTPOSITION2 |
+ DSBCAPS_CTRLVOLUME |
+ DSBCAPS_CTRLPAN |
+ DSBCAPS_CTRLFREQUENCY;
+ cDSBufferDesc.dwBufferBytes = dwDSBufSize;
+ cDSBufferDesc.dwReserved = 0;
+ cDSBufferDesc.lpwfxFormat = m_pWaveFileFormat;
+ cDSBufferDesc.guid3DAlgorithm = GUID_NULL;
+
+ hr = m_pDS->CreateSoundBuffer(&cDSBufferDesc, &m_pDSBuffer, NULL);
+
+ m_nDSBufSize = 0;
+ if (SUCCEEDED(hr)) {
+ bufferCaps.dwSize = sizeof(bufferCaps);
+ hr = m_pDSBuffer->GetCaps(&bufferCaps);
+ }
+ if (SUCCEEDED(hr)) {
+ m_nDSBufSize = bufferCaps.dwBufferBytes;
+ hr = ClearBuffer();
+ m_pDSBuffer->SetFrequency((long)(m_pWaveFileFormat->nSamplesPerSec * m_dRate));
+ }
+
+ return hr;
}
HRESULT CMpcAudioRenderer::ClearBuffer()
{
- HRESULT hr = S_FALSE;
- VOID* pDSLockedBuffer = NULL;
- DWORD dwDSLockedSize = 0;
-
- if (m_pDSBuffer) {
- m_dwDSWriteOff = 0;
- m_pDSBuffer->SetCurrentPosition(0);
-
- hr = m_pDSBuffer->Lock (0, 0, &pDSLockedBuffer, &dwDSLockedSize, NULL, NULL, DSBLOCK_ENTIREBUFFER);
- if (SUCCEEDED (hr)) {
- memset (pDSLockedBuffer, 0, dwDSLockedSize);
- hr = m_pDSBuffer->Unlock (pDSLockedBuffer, dwDSLockedSize, NULL, NULL);
- }
- }
-
- return hr;
+ HRESULT hr = S_FALSE;
+ VOID* pDSLockedBuffer = NULL;
+ DWORD dwDSLockedSize = 0;
+
+ if (m_pDSBuffer) {
+ m_dwDSWriteOff = 0;
+ m_pDSBuffer->SetCurrentPosition(0);
+
+ hr = m_pDSBuffer->Lock(0, 0, &pDSLockedBuffer, &dwDSLockedSize, NULL, NULL, DSBLOCK_ENTIREBUFFER);
+ if (SUCCEEDED(hr)) {
+ memset(pDSLockedBuffer, 0, dwDSLockedSize);
+ hr = m_pDSBuffer->Unlock(pDSLockedBuffer, dwDSLockedSize, NULL, NULL);
+ }
+ }
+
+ return hr;
}
HRESULT CMpcAudioRenderer::InitCoopLevel()
{
- HRESULT hr = S_OK;
- IVideoWindow* pVideoWindow = NULL;
- HWND hWnd = NULL;
- CComBSTR bstrCaption;
-
- hr = m_pGraph->QueryInterface (__uuidof(IVideoWindow), (void**) &pVideoWindow);
- if (SUCCEEDED (hr)) {
- pVideoWindow->get_Owner((OAHWND*)&hWnd);
- SAFE_RELEASE (pVideoWindow);
- }
- if (!hWnd) {
- hWnd = GetTopWindow(NULL);
- }
-
- ATLASSERT(hWnd != NULL);
- if (!m_useWASAPI) {
- hr = m_pDS->SetCooperativeLevel(hWnd, DSSCL_PRIORITY);
- } else if (hTask == NULL) {
- // Ask MMCSS to temporarily boost the thread priority
- // to reduce glitches while the low-latency stream plays.
- DWORD taskIndex = 0;
-
- if (pfAvSetMmThreadCharacteristicsW) {
- hTask = pfAvSetMmThreadCharacteristicsW(_T("Pro Audio"), &taskIndex);
- TRACE(_T("CMpcAudioRenderer::InitCoopLevel Putting thread in higher priority for Wasapi mode (lowest latency)\n"));
- hr=GetLastError();
- if (hTask == NULL) {
- return hr;
- }
- }
- }
-
- return hr;
+ HRESULT hr = S_OK;
+ IVideoWindow* pVideoWindow = NULL;
+ HWND hWnd = NULL;
+ CComBSTR bstrCaption;
+
+ hr = m_pGraph->QueryInterface(__uuidof(IVideoWindow), (void**) &pVideoWindow);
+ if (SUCCEEDED(hr)) {
+ pVideoWindow->get_Owner((OAHWND*)&hWnd);
+ SAFE_RELEASE(pVideoWindow);
+ }
+ if (!hWnd) {
+ hWnd = GetTopWindow(NULL);
+ }
+
+ ATLASSERT(hWnd != NULL);
+ if (!m_useWASAPI) {
+ hr = m_pDS->SetCooperativeLevel(hWnd, DSSCL_PRIORITY);
+ } else if (hTask == NULL) {
+ // Ask MMCSS to temporarily boost the thread priority
+ // to reduce glitches while the low-latency stream plays.
+ DWORD taskIndex = 0;
+
+ if (pfAvSetMmThreadCharacteristicsW) {
+ hTask = pfAvSetMmThreadCharacteristicsW(_T("Pro Audio"), &taskIndex);
+ TRACE(_T("CMpcAudioRenderer::InitCoopLevel Putting thread in higher priority for Wasapi mode (lowest latency)\n"));
+ hr = GetLastError();
+ if (hTask == NULL) {
+ return hr;
+ }
+ }
+ }
+
+ return hr;
}
-HRESULT CMpcAudioRenderer::DoRenderSampleDirectSound(IMediaSample *pMediaSample)
+HRESULT CMpcAudioRenderer::DoRenderSampleDirectSound(IMediaSample* pMediaSample)
{
- HRESULT hr = S_OK;
- DWORD dwStatus = 0;
- const long lSize = pMediaSample->GetActualDataLength();
- DWORD dwPlayCursor = 0;
- DWORD dwWriteCursor = 0;
-
- hr = m_pDSBuffer->GetStatus(&dwStatus);
-
- if (SUCCEEDED(hr) && (dwStatus & DSBSTATUS_BUFFERLOST)) {
- hr = m_pDSBuffer->Restore();
- }
-
- if ((SUCCEEDED(hr)) && ((dwStatus & DSBSTATUS_PLAYING) != DSBSTATUS_PLAYING)) {
- hr = m_pDSBuffer->Play( 0, 0, DSBPLAY_LOOPING);
- ATLASSERT(SUCCEEDED(hr));
- }
-
- if (SUCCEEDED(hr)) {
- hr = m_pDSBuffer->GetCurrentPosition(&dwPlayCursor, &dwWriteCursor);
- }
-
- if (SUCCEEDED(hr)) {
- if ( ( (dwPlayCursor < dwWriteCursor) &&
- (
- ((m_dwDSWriteOff >= dwPlayCursor) && (m_dwDSWriteOff <= dwWriteCursor))
- ||
- ((m_dwDSWriteOff < dwPlayCursor) && (m_dwDSWriteOff + lSize >= dwPlayCursor))
- )
- )
- ||
- ( (dwWriteCursor < dwPlayCursor) &&
- (
- (m_dwDSWriteOff >= dwPlayCursor) || (m_dwDSWriteOff < dwWriteCursor)
- ) ) ) {
- m_dwDSWriteOff = dwWriteCursor;
- }
-
- if (m_dwDSWriteOff >= (DWORD)m_nDSBufSize) {
- m_dwDSWriteOff = 0;
- }
- }
-
- if (SUCCEEDED(hr)) {
- hr = WriteSampleToDSBuffer(pMediaSample, NULL);
- }
-
- return hr;
+ HRESULT hr = S_OK;
+ DWORD dwStatus = 0;
+ const long lSize = pMediaSample->GetActualDataLength();
+ DWORD dwPlayCursor = 0;
+ DWORD dwWriteCursor = 0;
+
+ hr = m_pDSBuffer->GetStatus(&dwStatus);
+
+ if (SUCCEEDED(hr) && (dwStatus & DSBSTATUS_BUFFERLOST)) {
+ hr = m_pDSBuffer->Restore();
+ }
+
+ if ((SUCCEEDED(hr)) && ((dwStatus & DSBSTATUS_PLAYING) != DSBSTATUS_PLAYING)) {
+ hr = m_pDSBuffer->Play(0, 0, DSBPLAY_LOOPING);
+ ATLASSERT(SUCCEEDED(hr));
+ }
+
+ if (SUCCEEDED(hr)) {
+ hr = m_pDSBuffer->GetCurrentPosition(&dwPlayCursor, &dwWriteCursor);
+ }
+
+ if (SUCCEEDED(hr)) {
+ if (((dwPlayCursor < dwWriteCursor) &&
+ (
+ ((m_dwDSWriteOff >= dwPlayCursor) && (m_dwDSWriteOff <= dwWriteCursor))
+ ||
+ ((m_dwDSWriteOff < dwPlayCursor) && (m_dwDSWriteOff + lSize >= dwPlayCursor))
+ )
+ )
+ ||
+ ((dwWriteCursor < dwPlayCursor) &&
+ (
+ (m_dwDSWriteOff >= dwPlayCursor) || (m_dwDSWriteOff < dwWriteCursor)
+ ))) {
+ m_dwDSWriteOff = dwWriteCursor;
+ }
+
+ if (m_dwDSWriteOff >= (DWORD)m_nDSBufSize) {
+ m_dwDSWriteOff = 0;
+ }
+ }
+
+ if (SUCCEEDED(hr)) {
+ hr = WriteSampleToDSBuffer(pMediaSample, NULL);
+ }
+
+ return hr;
}
-HRESULT CMpcAudioRenderer::WriteSampleToDSBuffer(IMediaSample *pMediaSample, bool *looped)
+HRESULT CMpcAudioRenderer::WriteSampleToDSBuffer(IMediaSample* pMediaSample, bool* looped)
{
- if (! m_pDSBuffer) {
- return E_POINTER;
- }
-
- REFERENCE_TIME rtStart = 0;
- REFERENCE_TIME rtStop = 0;
- HRESULT hr = S_OK;
- bool loop = false;
- VOID* pDSLockedBuffers[2] = { NULL, NULL };
- DWORD dwDSLockedSize[2] = { 0, 0 };
- BYTE* pMediaBuffer = NULL;
- long lSize = pMediaSample->GetActualDataLength();
-
- hr = pMediaSample->GetPointer(&pMediaBuffer);
-
- if (m_dRate > 1.0) {
- int nBytePerSample = m_pWaveFileFormat->nChannels * (m_pWaveFileFormat->wBitsPerSample/8);
- m_pSoundTouch->putSamples((const short*)pMediaBuffer, lSize / nBytePerSample);
- lSize = m_pSoundTouch->receiveSamples ((short*)pMediaBuffer, lSize / nBytePerSample) * nBytePerSample;
- }
-
- pMediaSample->GetTime (&rtStart, &rtStop);
-
- if (rtStart < 0) {
- DWORD dwPercent = (DWORD) ((-rtStart * 100) / (rtStop - rtStart));
- DWORD dwRemove = (lSize*dwPercent/100);
-
- dwRemove = (dwRemove / m_pWaveFileFormat->nBlockAlign) * m_pWaveFileFormat->nBlockAlign;
- pMediaBuffer += dwRemove;
- lSize -= dwRemove;
- }
-
- if (SUCCEEDED (hr)) {
- hr = m_pDSBuffer->Lock (m_dwDSWriteOff, lSize, &pDSLockedBuffers[0], &dwDSLockedSize[0], &pDSLockedBuffers[1], &dwDSLockedSize[1], 0 );
- }
- if (SUCCEEDED (hr)) {
- if (pDSLockedBuffers [0] != NULL) {
- memcpy(pDSLockedBuffers[0], pMediaBuffer, dwDSLockedSize[0]);
- m_dwDSWriteOff += dwDSLockedSize[0];
- }
-
- if (pDSLockedBuffers [1] != NULL) {
- memcpy(pDSLockedBuffers[1], &pMediaBuffer[dwDSLockedSize[0]], dwDSLockedSize[1]);
- m_dwDSWriteOff = dwDSLockedSize[1];
- loop = true;
- }
-
- hr = m_pDSBuffer->Unlock(pDSLockedBuffers[0], dwDSLockedSize[0], pDSLockedBuffers[1], dwDSLockedSize[1]);
- ATLASSERT (dwDSLockedSize [0] + dwDSLockedSize [1] == (DWORD)lSize);
- }
-
- if (SUCCEEDED(hr) && looped) {
- *looped = loop;
- }
-
- return hr;
+ if (! m_pDSBuffer) {
+ return E_POINTER;
+ }
+
+ REFERENCE_TIME rtStart = 0;
+ REFERENCE_TIME rtStop = 0;
+ HRESULT hr = S_OK;
+ bool loop = false;
+ VOID* pDSLockedBuffers[2] = { NULL, NULL };
+ DWORD dwDSLockedSize[2] = { 0, 0 };
+ BYTE* pMediaBuffer = NULL;
+ long lSize = pMediaSample->GetActualDataLength();
+
+ hr = pMediaSample->GetPointer(&pMediaBuffer);
+
+ if (m_dRate > 1.0) {
+ int nBytePerSample = m_pWaveFileFormat->nChannels * (m_pWaveFileFormat->wBitsPerSample / 8);
+ m_pSoundTouch->putSamples((const short*)pMediaBuffer, lSize / nBytePerSample);
+ lSize = m_pSoundTouch->receiveSamples((short*)pMediaBuffer, lSize / nBytePerSample) * nBytePerSample;
+ }
+
+ pMediaSample->GetTime(&rtStart, &rtStop);
+
+ if (rtStart < 0) {
+ DWORD dwPercent = (DWORD)((-rtStart * 100) / (rtStop - rtStart));
+ DWORD dwRemove = (lSize * dwPercent / 100);
+
+ dwRemove = (dwRemove / m_pWaveFileFormat->nBlockAlign) * m_pWaveFileFormat->nBlockAlign;
+ pMediaBuffer += dwRemove;
+ lSize -= dwRemove;
+ }
+
+ if (SUCCEEDED(hr)) {
+ hr = m_pDSBuffer->Lock(m_dwDSWriteOff, lSize, &pDSLockedBuffers[0], &dwDSLockedSize[0], &pDSLockedBuffers[1], &dwDSLockedSize[1], 0);
+ }
+ if (SUCCEEDED(hr)) {
+ if (pDSLockedBuffers [0] != NULL) {
+ memcpy(pDSLockedBuffers[0], pMediaBuffer, dwDSLockedSize[0]);
+ m_dwDSWriteOff += dwDSLockedSize[0];
+ }
+
+ if (pDSLockedBuffers [1] != NULL) {
+ memcpy(pDSLockedBuffers[1], &pMediaBuffer[dwDSLockedSize[0]], dwDSLockedSize[1]);
+ m_dwDSWriteOff = dwDSLockedSize[1];
+ loop = true;
+ }
+
+ hr = m_pDSBuffer->Unlock(pDSLockedBuffers[0], dwDSLockedSize[0], pDSLockedBuffers[1], dwDSLockedSize[1]);
+ ATLASSERT(dwDSLockedSize [0] + dwDSLockedSize [1] == (DWORD)lSize);
+ }
+
+ if (SUCCEEDED(hr) && looped) {
+ *looped = loop;
+ }
+
+ return hr;
}
#pragma endregion
#pragma region // ==== WASAPI
-HRESULT CMpcAudioRenderer::DoRenderSampleWasapi(IMediaSample *pMediaSample)
+HRESULT CMpcAudioRenderer::DoRenderSampleWasapi(IMediaSample* pMediaSample)
{
- HRESULT hr = S_OK;
- REFERENCE_TIME rtStart = 0;
- REFERENCE_TIME rtStop = 0;
- BYTE *pMediaBuffer = NULL;
- BYTE *pInputBufferPointer = NULL;
- BYTE *pInputBufferEnd = NULL;
- BYTE *pData;
- bufferSize = pMediaSample->GetActualDataLength();
- const long lSize = bufferSize;
- pMediaSample->GetTime (&rtStart, &rtStop);
-
- AM_MEDIA_TYPE *pmt;
- if (SUCCEEDED(pMediaSample->GetMediaType(&pmt)) && pmt!=NULL) {
- CMediaType mt(*pmt);
- if ((WAVEFORMATEXTENSIBLE*)mt.Format() != NULL) {
- hr=CheckAudioClient(&(((WAVEFORMATEXTENSIBLE*)mt.Format())->Format));
- } else {
- hr=CheckAudioClient((WAVEFORMATEX*)mt.Format());
- }
- if (FAILED(hr)) {
- TRACE(_T("CMpcAudioRenderer::DoRenderSampleWasapi Error while checking audio client with input media type\n"));
- return hr;
- }
- DeleteMediaType(pmt);
- pmt=NULL;
- }
-
- // Initialization
- hr = pMediaSample->GetPointer(&pMediaBuffer);
- if (FAILED (hr)) {
- return hr;
- }
-
- pInputBufferPointer=&pMediaBuffer[0];
- pInputBufferEnd=&pMediaBuffer[0]+lSize;
-
- WORD frameSize = m_pWaveFileFormat->nBlockAlign;
-
-
- // Sleep for half the buffer duration since last buffer feed
- DWORD currentTime=GetTickCount();
- if (lastBufferTime!=0 && hnsActualDuration!= 0 && lastBufferTime<currentTime && (currentTime-lastBufferTime)<hnsActualDuration) {
- hnsActualDuration=hnsActualDuration-(currentTime-lastBufferTime);
- Sleep(hnsActualDuration);
- }
-
- // Each loop fills one of the two buffers.
- while (pInputBufferPointer < pInputBufferEnd) {
- UINT32 numFramesPadding=0;
- pAudioClient->GetCurrentPadding(&numFramesPadding);
- UINT32 numFramesAvailable = nFramesInBuffer - numFramesPadding;
-
- UINT32 nAvailableBytes=numFramesAvailable*frameSize;
- UINT32 nBytesToWrite=nAvailableBytes;
- // More room than enough in the output buffer
- if (nAvailableBytes > (size_t)(pInputBufferEnd - pInputBufferPointer)) {
- nBytesToWrite=pInputBufferEnd - pInputBufferPointer;
- numFramesAvailable=(UINT32)((float)nBytesToWrite/frameSize);
- }
-
- // Grab the next empty buffer from the audio device.
- hr = pRenderClient->GetBuffer(numFramesAvailable, &pData);
- if (FAILED (hr)) {
- TRACE(_T("CMpcAudioRenderer::DoRenderSampleWasapi GetBuffer failed with size %ld : (error %lx)\n"),nFramesInBuffer,hr);
- return hr;
- }
-
- // Load the buffer with data from the audio source.
- if (pData != NULL) {
-
- memcpy(&pData[0], pInputBufferPointer, nBytesToWrite);
- pInputBufferPointer += nBytesToWrite;
- } else {
- TRACE(_T("CMpcAudioRenderer::DoRenderSampleWasapi Output buffer is NULL\n"));
- }
-
- hr = pRenderClient->ReleaseBuffer(numFramesAvailable, 0); // no flags
- if (FAILED (hr)) {
- TRACE(_T("CMpcAudioRenderer::DoRenderSampleWasapi ReleaseBuffer failed with size %ld (error %lx)\n"),nFramesInBuffer,hr);
- return hr;
- }
-
- if (!isAudioClientStarted) {
- TRACE(_T("CMpcAudioRenderer::DoRenderSampleWasapi Starting audio client\n"));
- pAudioClient->Start();
- isAudioClientStarted=true;
- }
-
- if (pInputBufferPointer >= pInputBufferEnd) {
- lastBufferTime=GetTickCount();
- // This is the duration of the filled buffer
- hnsActualDuration=(double)REFTIMES_PER_SEC * numFramesAvailable / m_pWaveFileFormat->nSamplesPerSec;
- // Sleep time is half this duration
- hnsActualDuration=(DWORD)(hnsActualDuration/REFTIMES_PER_MILLISEC/2);
- break;
- }
-
- // Buffer not completely filled, sleep for half buffer capacity duration
- hnsActualDuration=(double)REFTIMES_PER_SEC * nFramesInBuffer / m_pWaveFileFormat->nSamplesPerSec;
- // Sleep time is half this duration
- hnsActualDuration=(DWORD)(hnsActualDuration/REFTIMES_PER_MILLISEC/2);
- Sleep(hnsActualDuration);
- }
- return hr;
+ HRESULT hr = S_OK;
+ REFERENCE_TIME rtStart = 0;
+ REFERENCE_TIME rtStop = 0;
+ BYTE* pMediaBuffer = NULL;
+ BYTE* pInputBufferPointer = NULL;
+ BYTE* pInputBufferEnd = NULL;
+ BYTE* pData;
+ bufferSize = pMediaSample->GetActualDataLength();
+ const long lSize = bufferSize;
+ pMediaSample->GetTime(&rtStart, &rtStop);
+
+ AM_MEDIA_TYPE* pmt;
+ if (SUCCEEDED(pMediaSample->GetMediaType(&pmt)) && pmt != NULL) {
+ CMediaType mt(*pmt);
+ if ((WAVEFORMATEXTENSIBLE*)mt.Format() != NULL) {
+ hr = CheckAudioClient(&(((WAVEFORMATEXTENSIBLE*)mt.Format())->Format));
+ } else {
+ hr = CheckAudioClient((WAVEFORMATEX*)mt.Format());
+ }
+ if (FAILED(hr)) {
+ TRACE(_T("CMpcAudioRenderer::DoRenderSampleWasapi Error while checking audio client with input media type\n"));
+ return hr;
+ }
+ DeleteMediaType(pmt);
+ pmt = NULL;
+ }
+
+ // Initialization
+ hr = pMediaSample->GetPointer(&pMediaBuffer);
+ if (FAILED(hr)) {
+ return hr;
+ }
+
+ pInputBufferPointer = &pMediaBuffer[0];
+ pInputBufferEnd = &pMediaBuffer[0] + lSize;
+
+ WORD frameSize = m_pWaveFileFormat->nBlockAlign;
+
+
+ // Sleep for half the buffer duration since last buffer feed
+ DWORD currentTime = GetTickCount();
+ if (lastBufferTime != 0 && hnsActualDuration != 0 && lastBufferTime < currentTime && (currentTime - lastBufferTime) < hnsActualDuration) {
+ hnsActualDuration = hnsActualDuration - (currentTime - lastBufferTime);
+ Sleep(hnsActualDuration);
+ }
+
+ // Each loop fills one of the two buffers.
+ while (pInputBufferPointer < pInputBufferEnd) {
+ UINT32 numFramesPadding = 0;
+ pAudioClient->GetCurrentPadding(&numFramesPadding);
+ UINT32 numFramesAvailable = nFramesInBuffer - numFramesPadding;
+
+ UINT32 nAvailableBytes = numFramesAvailable * frameSize;
+ UINT32 nBytesToWrite = nAvailableBytes;
+ // More room than enough in the output buffer
+ if (nAvailableBytes > (size_t)(pInputBufferEnd - pInputBufferPointer)) {
+ nBytesToWrite = pInputBufferEnd - pInputBufferPointer;
+ numFramesAvailable = (UINT32)((float)nBytesToWrite / frameSize);
+ }
+
+ // Grab the next empty buffer from the audio device.
+ hr = pRenderClient->GetBuffer(numFramesAvailable, &pData);
+ if (FAILED(hr)) {
+ TRACE(_T("CMpcAudioRenderer::DoRenderSampleWasapi GetBuffer failed with size %ld : (error %lx)\n"), nFramesInBuffer, hr);
+ return hr;
+ }
+
+ // Load the buffer with data from the audio source.
+ if (pData != NULL) {
+
+ memcpy(&pData[0], pInputBufferPointer, nBytesToWrite);
+ pInputBufferPointer += nBytesToWrite;
+ } else {
+ TRACE(_T("CMpcAudioRenderer::DoRenderSampleWasapi Output buffer is NULL\n"));
+ }
+
+ hr = pRenderClient->ReleaseBuffer(numFramesAvailable, 0); // no flags
+ if (FAILED(hr)) {
+ TRACE(_T("CMpcAudioRenderer::DoRenderSampleWasapi ReleaseBuffer failed with size %ld (error %lx)\n"), nFramesInBuffer, hr);
+ return hr;
+ }
+
+ if (!isAudioClientStarted) {
+ TRACE(_T("CMpcAudioRenderer::DoRenderSampleWasapi Starting audio client\n"));
+ pAudioClient->Start();
+ isAudioClientStarted = true;
+ }
+
+ if (pInputBufferPointer >= pInputBufferEnd) {
+ lastBufferTime = GetTickCount();
+ // This is the duration of the filled buffer
+ hnsActualDuration = (double)REFTIMES_PER_SEC * numFramesAvailable / m_pWaveFileFormat->nSamplesPerSec;
+ // Sleep time is half this duration
+ hnsActualDuration = (DWORD)(hnsActualDuration / REFTIMES_PER_MILLISEC / 2);
+ break;
+ }
+
+ // Buffer not completely filled, sleep for half buffer capacity duration
+ hnsActualDuration = (double)REFTIMES_PER_SEC * nFramesInBuffer / m_pWaveFileFormat->nSamplesPerSec;
+ // Sleep time is half this duration
+ hnsActualDuration = (DWORD)(hnsActualDuration / REFTIMES_PER_MILLISEC / 2);
+ Sleep(hnsActualDuration);
+ }
+ return hr;
}
#pragma endregion
-HRESULT CMpcAudioRenderer::CheckAudioClient(WAVEFORMATEX *pWaveFormatEx)
+HRESULT CMpcAudioRenderer::CheckAudioClient(WAVEFORMATEX* pWaveFormatEx)
{
- HRESULT hr = S_OK;
- CAutoLock cAutoLock(&m_csCheck);
- TRACE(_T("CMpcAudioRenderer::CheckAudioClient\n"));
- if (pMMDevice == NULL) {
- hr = GetAudioDevice(&pMMDevice);
- }
-
- // If no WAVEFORMATEX structure provided and client already exists, return it
- if (pAudioClient != NULL && pWaveFormatEx == NULL) {
- return hr;
- }
-
- // Just create the audio client if no WAVEFORMATEX provided
- if (pAudioClient == NULL && pWaveFormatEx==NULL) {
- if (SUCCEEDED (hr)) {
- hr=CreateAudioClient(pMMDevice, &pAudioClient);
- }
- return hr;
- }
-
- // Compare the exisiting WAVEFORMATEX with the one provided
- WAVEFORMATEX *pNewWaveFormatEx = NULL;
- if (CheckFormatChanged(pWaveFormatEx, &pNewWaveFormatEx)) {
- // Format has changed, audio client has to be reinitialized
- TRACE(_T("CMpcAudioRenderer::CheckAudioClient Format changed, reinitialize the audio client\n"));
- if (m_pWaveFileFormat) {
- BYTE *p = (BYTE *)m_pWaveFileFormat;
- SAFE_DELETE_ARRAY(p);
- }
- m_pWaveFileFormat=pNewWaveFormatEx;
- hr = pAudioClient->IsFormatSupported(AUDCLNT_SHAREMODE_EXCLUSIVE, pWaveFormatEx, NULL);
- if (SUCCEEDED(hr)) {
- if (pAudioClient!=NULL && isAudioClientStarted) {
- pAudioClient->Stop();
- }
- isAudioClientStarted=false;
- SAFE_RELEASE(pRenderClient);
- SAFE_RELEASE(pAudioClient);
- if (SUCCEEDED (hr)) {
- hr=CreateAudioClient(pMMDevice, &pAudioClient);
- }
- } else {
- TRACE(_T("CMpcAudioRenderer::CheckAudioClient New format not supported, accept it anyway\n"));
- return S_OK;
- }
- } else if (pRenderClient == NULL) {
- TRACE(_T("CMpcAudioRenderer::CheckAudioClient First initialization of the audio renderer\n"));
- } else {
- return hr;
- }
-
-
- SAFE_RELEASE(pRenderClient);
- if (SUCCEEDED (hr)) {
- hr=InitAudioClient(pWaveFormatEx, pAudioClient, &pRenderClient);
- }
- return hr;
+ HRESULT hr = S_OK;
+ CAutoLock cAutoLock(&m_csCheck);
+ TRACE(_T("CMpcAudioRenderer::CheckAudioClient\n"));
+ if (pMMDevice == NULL) {
+ hr = GetAudioDevice(&pMMDevice);
+ }
+
+ // If no WAVEFORMATEX structure provided and client already exists, return it
+ if (pAudioClient != NULL && pWaveFormatEx == NULL) {
+ return hr;
+ }
+
+ // Just create the audio client if no WAVEFORMATEX provided
+ if (pAudioClient == NULL && pWaveFormatEx == NULL) {
+ if (SUCCEEDED(hr)) {
+ hr = CreateAudioClient(pMMDevice, &pAudioClient);
+ }
+ return hr;
+ }
+
+ // Compare the exisiting WAVEFORMATEX with the one provided
+ WAVEFORMATEX* pNewWaveFormatEx = NULL;
+ if (CheckFormatChanged(pWaveFormatEx, &pNewWaveFormatEx)) {
+ // Format has changed, audio client has to be reinitialized
+ TRACE(_T("CMpcAudioRenderer::CheckAudioClient Format changed, reinitialize the audio client\n"));
+ if (m_pWaveFileFormat) {
+ BYTE* p = (BYTE*)m_pWaveFileFormat;
+ SAFE_DELETE_ARRAY(p);
+ }
+ m_pWaveFileFormat = pNewWaveFormatEx;
+ hr = pAudioClient->IsFormatSupported(AUDCLNT_SHAREMODE_EXCLUSIVE, pWaveFormatEx, NULL);
+ if (SUCCEEDED(hr)) {
+ if (pAudioClient != NULL && isAudioClientStarted) {
+ pAudioClient->Stop();
+ }
+ isAudioClientStarted = false;
+ SAFE_RELEASE(pRenderClient);
+ SAFE_RELEASE(pAudioClient);
+ if (SUCCEEDED(hr)) {
+ hr = CreateAudioClient(pMMDevice, &pAudioClient);
+ }
+ } else {
+ TRACE(_T("CMpcAudioRenderer::CheckAudioClient New format not supported, accept it anyway\n"));
+ return S_OK;
+ }
+ } else if (pRenderClient == NULL) {
+ TRACE(_T("CMpcAudioRenderer::CheckAudioClient First initialization of the audio renderer\n"));
+ } else {
+ return hr;
+ }
+
+
+ SAFE_RELEASE(pRenderClient);
+ if (SUCCEEDED(hr)) {
+ hr = InitAudioClient(pWaveFormatEx, pAudioClient, &pRenderClient);
+ }
+ return hr;
}
-HRESULT CMpcAudioRenderer::GetAvailableAudioDevices(IMMDeviceCollection **ppMMDevices)
+HRESULT CMpcAudioRenderer::GetAvailableAudioDevices(IMMDeviceCollection** ppMMDevices)
{
- HRESULT hr;
-
- CComPtr<IMMDeviceEnumerator> enumerator;
- TRACE(_T("CMpcAudioRenderer::GetAvailableAudioDevices\n"));
- hr = enumerator.CoCreateInstance(__uuidof(MMDeviceEnumerator));
-
- if (FAILED(hr))
- {
- TRACE(_T("CMpcAudioRenderer::GetAvailableAudioDevices - failed to get MMDeviceEnumerator\n"));
- return S_FALSE;
- }
-
- //IMMDevice* pEndpoint = NULL;
- //IPropertyStore* pProps = NULL;
- //LPWSTR pwszID = NULL;
-
- enumerator->EnumAudioEndpoints(eRender, DEVICE_STATE_ACTIVE, ppMMDevices);
- UINT count(0);
- hr = (*ppMMDevices)->GetCount(&count);
- return hr;
+ HRESULT hr;
+
+ CComPtr<IMMDeviceEnumerator> enumerator;
+ TRACE(_T("CMpcAudioRenderer::GetAvailableAudioDevices\n"));
+ hr = enumerator.CoCreateInstance(__uuidof(MMDeviceEnumerator));
+
+ if (FAILED(hr)) {
+ TRACE(_T("CMpcAudioRenderer::GetAvailableAudioDevices - failed to get MMDeviceEnumerator\n"));
+ return S_FALSE;
+ }
+
+ //IMMDevice* pEndpoint = NULL;
+ //IPropertyStore* pProps = NULL;
+ //LPWSTR pwszID = NULL;
+
+ enumerator->EnumAudioEndpoints(eRender, DEVICE_STATE_ACTIVE, ppMMDevices);
+ UINT count(0);
+ hr = (*ppMMDevices)->GetCount(&count);
+ return hr;
}
-HRESULT CMpcAudioRenderer::GetAudioDevice(IMMDevice **ppMMDevice)
+HRESULT CMpcAudioRenderer::GetAudioDevice(IMMDevice** ppMMDevice)
{
- TRACE(_T("CMpcAudioRenderer::GetAudioDevice\n"));
-
- CComPtr<IMMDeviceEnumerator> enumerator;
- IMMDeviceCollection* devices;
- IPropertyStore* pProps = NULL;
- HRESULT hr = enumerator.CoCreateInstance(__uuidof(MMDeviceEnumerator));
-
- if (hr != S_OK)
- {
- TRACE(_T("CMpcAudioRenderer::GetAudioDevice - failed to create MMDeviceEnumerator!\n"));
- return hr;
- }
-
- TRACE(_T("CMpcAudioRenderer::GetAudioDevice - Target end point: %s\n"), m_csSound_Device);
-
- if (GetAvailableAudioDevices(&devices) == S_OK && devices)
- {
- UINT count(0);
- hr = devices->GetCount(&count);
- if (hr != S_OK)
- {
- TRACE(_T("CMpcAudioRenderer::GetAudioDevice - devices->GetCount failed: (0x%08x)\n"), hr);
- return hr;
- }
-
- for (ULONG i = 0 ; i < count ; i++)
- {
- LPWSTR pwszID = NULL;
- IMMDevice *endpoint = NULL;
- hr = devices->Item(i, &endpoint);
- if (hr == S_OK)
- {
- hr = endpoint->GetId(&pwszID);
- if (hr == S_OK)
- {
- if (endpoint->OpenPropertyStore(STGM_READ, &pProps) == S_OK)
- {
-
- PROPVARIANT varName;
- PropVariantInit(&varName);
-
- // Found the configured audio endpoint
- if ((pProps->GetValue(PKEY_Device_FriendlyName, &varName) == S_OK) && (m_csSound_Device == varName.pwszVal))
- {
- TRACE(_T("CMpcAudioRenderer::GetAudioDevice - devices->GetId OK, num: (%d), pwszVal: %s, pwszID: %s\n"), i, varName.pwszVal, pwszID);
- enumerator->GetDevice(pwszID, ppMMDevice);
- SAFE_RELEASE(devices);
- *(ppMMDevice) = endpoint;
- CoTaskMemFree(pwszID);
- pwszID = NULL;
- PropVariantClear(&varName);
- SAFE_RELEASE(pProps);
- return S_OK;
- }
- else
- {
- PropVariantClear(&varName);
- SAFE_RELEASE(pProps);
- SAFE_RELEASE(endpoint);
- CoTaskMemFree(pwszID);
- pwszID = NULL;
- }
- }
- }
- else
- {
- TRACE(_T("CMpcAudioRenderer::GetAudioDevice - devices->GetId failed: (0x%08x)\n"), hr);
- }
- }
- else
- {
- TRACE(_T("CMpcAudioRenderer::GetAudioDevice - devices->Item failed: (0x%08x)\n"), hr);
- }
-
- CoTaskMemFree(pwszID);
- pwszID = NULL;
- }
- }
-
- TRACE(_T("CMpcAudioRenderer::GetAudioDevice - Unable to find selected audio device, using the default end point!\n"));
- hr = enumerator->GetDefaultAudioEndpoint(eRender, eConsole, ppMMDevice);
-
- SAFE_RELEASE(devices);
-
- return hr;
+ TRACE(_T("CMpcAudioRenderer::GetAudioDevice\n"));
+
+ CComPtr<IMMDeviceEnumerator> enumerator;
+ IMMDeviceCollection* devices;
+ IPropertyStore* pProps = NULL;
+ HRESULT hr = enumerator.CoCreateInstance(__uuidof(MMDeviceEnumerator));
+
+ if (hr != S_OK) {
+ TRACE(_T("CMpcAudioRenderer::GetAudioDevice - failed to create MMDeviceEnumerator!\n"));
+ return hr;
+ }
+
+ TRACE(_T("CMpcAudioRenderer::GetAudioDevice - Target end point: %s\n"), m_csSound_Device);
+
+ if (GetAvailableAudioDevices(&devices) == S_OK && devices) {
+ UINT count(0);
+ hr = devices->GetCount(&count);
+ if (hr != S_OK) {
+ TRACE(_T("CMpcAudioRenderer::GetAudioDevice - devices->GetCount failed: (0x%08x)\n"), hr);
+ return hr;
+ }
+
+ for (ULONG i = 0 ; i < count ; i++) {
+ LPWSTR pwszID = NULL;
+ IMMDevice* endpoint = NULL;
+ hr = devices->Item(i, &endpoint);
+ if (hr == S_OK) {
+ hr = endpoint->GetId(&pwszID);
+ if (hr == S_OK) {
+ if (endpoint->OpenPropertyStore(STGM_READ, &pProps) == S_OK) {
+
+ PROPVARIANT varName;
+ PropVariantInit(&varName);
+
+ // Found the configured audio endpoint
+ if ((pProps->GetValue(PKEY_Device_FriendlyName, &varName) == S_OK) && (m_csSound_Device == varName.pwszVal)) {
+ TRACE(_T("CMpcAudioRenderer::GetAudioDevice - devices->GetId OK, num: (%d), pwszVal: %s, pwszID: %s\n"), i, varName.pwszVal, pwszID);
+ enumerator->GetDevice(pwszID, ppMMDevice);
+ SAFE_RELEASE(devices);
+ *(ppMMDevice) = endpoint;
+ CoTaskMemFree(pwszID);
+ pwszID = NULL;
+ PropVariantClear(&varName);
+ SAFE_RELEASE(pProps);
+ return S_OK;
+ } else {
+ PropVariantClear(&varName);
+ SAFE_RELEASE(pProps);
+ SAFE_RELEASE(endpoint);
+ CoTaskMemFree(pwszID);
+ pwszID = NULL;
+ }
+ }
+ } else {
+ TRACE(_T("CMpcAudioRenderer::GetAudioDevice - devices->GetId failed: (0x%08x)\n"), hr);
+ }
+ } else {
+ TRACE(_T("CMpcAudioRenderer::GetAudioDevice - devices->Item failed: (0x%08x)\n"), hr);
+ }
+
+ CoTaskMemFree(pwszID);
+ pwszID = NULL;
+ }
+ }
+
+ TRACE(_T("CMpcAudioRenderer::GetAudioDevice - Unable to find selected audio device, using the default end point!\n"));
+ hr = enumerator->GetDefaultAudioEndpoint(eRender, eConsole, ppMMDevice);
+
+ SAFE_RELEASE(devices);
+
+ return hr;
}
-bool CMpcAudioRenderer::CheckFormatChanged(WAVEFORMATEX *pWaveFormatEx, WAVEFORMATEX **ppNewWaveFormatEx)
+bool CMpcAudioRenderer::CheckFormatChanged(WAVEFORMATEX* pWaveFormatEx, WAVEFORMATEX** ppNewWaveFormatEx)
{
- bool formatChanged=false;
- if (m_pWaveFileFormat==NULL) {
- formatChanged=true;
- } else if (pWaveFormatEx->wFormatTag != m_pWaveFileFormat->wFormatTag
- || pWaveFormatEx->nChannels != m_pWaveFileFormat->nChannels
- || pWaveFormatEx->wBitsPerSample != m_pWaveFileFormat->wBitsPerSample) { // TODO : improve the checks
- formatChanged=true;
- }
-
-
- if (!formatChanged) {
- return false;
- }
-
- int size = sizeof(WAVEFORMATEX) + pWaveFormatEx->cbSize; // Always true, even for WAVEFORMATEXTENSIBLE and WAVEFORMATEXTENSIBLE_IEC61937
- *ppNewWaveFormatEx = (WAVEFORMATEX *)DNew BYTE[size];
- if (! *ppNewWaveFormatEx) {
- return false;
- }
- memcpy(*ppNewWaveFormatEx, pWaveFormatEx, size);
- return true;
+ bool formatChanged = false;
+ if (m_pWaveFileFormat == NULL) {
+ formatChanged = true;
+ } else if (pWaveFormatEx->wFormatTag != m_pWaveFileFormat->wFormatTag
+ || pWaveFormatEx->nChannels != m_pWaveFileFormat->nChannels
+ || pWaveFormatEx->wBitsPerSample != m_pWaveFileFormat->wBitsPerSample) { // TODO : improve the checks
+ formatChanged = true;
+ }
+
+
+ if (!formatChanged) {
+ return false;
+ }
+
+ int size = sizeof(WAVEFORMATEX) + pWaveFormatEx->cbSize; // Always true, even for WAVEFORMATEXTENSIBLE and WAVEFORMATEXTENSIBLE_IEC61937
+ *ppNewWaveFormatEx = (WAVEFORMATEX*)DNew BYTE[size];
+ if (! *ppNewWaveFormatEx) {
+ return false;
+ }
+ memcpy(*ppNewWaveFormatEx, pWaveFormatEx, size);
+ return true;
}
-HRESULT CMpcAudioRenderer::GetBufferSize(WAVEFORMATEX *pWaveFormatEx, REFERENCE_TIME *pHnsBufferPeriod)
+HRESULT CMpcAudioRenderer::GetBufferSize(WAVEFORMATEX* pWaveFormatEx, REFERENCE_TIME* pHnsBufferPeriod)
{
- if (pWaveFormatEx==NULL) {
- return S_OK;
- }
- if (pWaveFormatEx->cbSize <22) { //WAVEFORMATEX
- return S_OK;
- }
-
- WAVEFORMATEXTENSIBLE *wfext=(WAVEFORMATEXTENSIBLE*)pWaveFormatEx;
-
- if (bufferSize==0)
- if (wfext->SubFormat==KSDATAFORMAT_SUBTYPE_IEC61937_DOLBY_MLP) {
- bufferSize=61440;
- } else if (wfext->SubFormat==KSDATAFORMAT_SUBTYPE_IEC61937_DTS_HD) {
- bufferSize=32768;
- } else if (wfext->SubFormat==KSDATAFORMAT_SUBTYPE_IEC61937_DOLBY_DIGITAL_PLUS) {
- bufferSize=24576;
- } else if (wfext->Format.wFormatTag==WAVE_FORMAT_DOLBY_AC3_SPDIF) {
- bufferSize=6144;
- } else {
- return S_OK;
- }
-
- *pHnsBufferPeriod = (REFERENCE_TIME)( (REFERENCE_TIME)bufferSize * 10000 * 8 / ((REFERENCE_TIME)pWaveFormatEx->nChannels * pWaveFormatEx->wBitsPerSample *
- 1.0 * pWaveFormatEx->nSamplesPerSec) /*+ 0.5*/);
- *pHnsBufferPeriod *= 1000;
-
- TRACE(_T("CMpcAudioRenderer::GetBufferSize set a %lld period for a %ld buffer size\n"),*pHnsBufferPeriod,bufferSize);
-
- return S_OK;
+ if (pWaveFormatEx == NULL) {
+ return S_OK;
+ }
+ if (pWaveFormatEx->cbSize < 22) { //WAVEFORMATEX
+ return S_OK;
+ }
+
+ WAVEFORMATEXTENSIBLE* wfext = (WAVEFORMATEXTENSIBLE*)pWaveFormatEx;
+
+ if (bufferSize == 0)
+ if (wfext->SubFormat == KSDATAFORMAT_SUBTYPE_IEC61937_DOLBY_MLP) {
+ bufferSize = 61440;
+ } else if (wfext->SubFormat == KSDATAFORMAT_SUBTYPE_IEC61937_DTS_HD) {
+ bufferSize = 32768;
+ } else if (wfext->SubFormat == KSDATAFORMAT_SUBTYPE_IEC61937_DOLBY_DIGITAL_PLUS) {
+ bufferSize = 24576;
+ } else if (wfext->Format.wFormatTag == WAVE_FORMAT_DOLBY_AC3_SPDIF) {
+ bufferSize = 6144;
+ } else {
+ return S_OK;
+ }
+
+ *pHnsBufferPeriod = (REFERENCE_TIME)((REFERENCE_TIME)bufferSize * 10000 * 8 / ((REFERENCE_TIME)pWaveFormatEx->nChannels * pWaveFormatEx->wBitsPerSample *
+ 1.0 * pWaveFormatEx->nSamplesPerSec) /*+ 0.5*/);
+ *pHnsBufferPeriod *= 1000;
+
+ TRACE(_T("CMpcAudioRenderer::GetBufferSize set a %lld period for a %ld buffer size\n"), *pHnsBufferPeriod, bufferSize);
+
+ return S_OK;
}
-HRESULT CMpcAudioRenderer::InitAudioClient(WAVEFORMATEX *pWaveFormatEx, IAudioClient *pAudioClient, IAudioRenderClient **ppRenderClient)
+HRESULT CMpcAudioRenderer::InitAudioClient(WAVEFORMATEX* pWaveFormatEx, IAudioClient* pAudioClient, IAudioRenderClient** ppRenderClient)
{
- TRACE(_T("CMpcAudioRenderer::InitAudioClient\n"));
- HRESULT hr=S_OK;
- // Initialize the stream to play at the minimum latency.
- //if (SUCCEEDED (hr)) hr = pAudioClient->GetDevicePeriod(NULL, &hnsPeriod);
- hnsPeriod=500000; //50 ms is the best according to James @Slysoft
-
- hr = pAudioClient->IsFormatSupported(AUDCLNT_SHAREMODE_EXCLUSIVE, pWaveFormatEx, NULL);
- if (FAILED(hr)) {
- TRACE(_T("CMpcAudioRenderer::InitAudioClient not supported (0x%08x)\n"), hr);
- } else {
- TRACE(_T("CMpcAudioRenderer::InitAudioClient format supported\n"));
- }
-
- GetBufferSize(pWaveFormatEx, &hnsPeriod);
-
- if (SUCCEEDED (hr)) hr = pAudioClient->Initialize(AUDCLNT_SHAREMODE_EXCLUSIVE,0/*AUDCLNT_STREAMFLAGS_EVENTCALLBACK*/,
- hnsPeriod,hnsPeriod,pWaveFormatEx,NULL);
- if (FAILED (hr) && hr != AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED) {
- TRACE(_T("CMpcAudioRenderer::InitAudioClient failed (0x%08x)\n"), hr);
- return hr;
- }
-
- if (AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED == hr) {
- // if the buffer size was not aligned, need to do the alignment dance
- TRACE(_T("CMpcAudioRenderer::InitAudioClient Buffer size not aligned. Realigning\n"));
-
- // get the buffer size, which will be aligned
- hr = pAudioClient->GetBufferSize(&nFramesInBuffer);
-
- // throw away this IAudioClient
- pAudioClient->Release();
- pAudioClient=NULL;
-
- // calculate the new aligned periodicity
- hnsPeriod = // hns =
- (REFERENCE_TIME)(
- 10000.0 * // (hns / ms) *
- 1000 * // (ms / s) *
- nFramesInBuffer / // frames /
- pWaveFormatEx->nSamplesPerSec // (frames / s)
- + 0.5 // rounding
- );
-
- if (SUCCEEDED (hr)) {
- hr=CreateAudioClient(pMMDevice, &pAudioClient);
- }
- TRACE(_T("CMpcAudioRenderer::InitAudioClient Trying again with periodicity of %I64u hundred-nanoseconds, or %u frames.\n"), hnsPeriod, nFramesInBuffer);
- if (SUCCEEDED (hr))
- hr = pAudioClient->Initialize(AUDCLNT_SHAREMODE_EXCLUSIVE,0/*AUDCLNT_STREAMFLAGS_EVENTCALLBACK*/,
- hnsPeriod, hnsPeriod, pWaveFormatEx, NULL);
- if (FAILED(hr)) {
- TRACE(_T("CMpcAudioRenderer::InitAudioClient Failed to reinitialize the audio client\n"));
- return hr;
- }
- } // if (AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED == hr)
-
- // get the buffer size, which is aligned
- if (SUCCEEDED (hr)) {
- hr = pAudioClient->GetBufferSize(&nFramesInBuffer);
- }
-
- // calculate the new period
- if (SUCCEEDED (hr)) {
- hr = pAudioClient->GetService(__uuidof(IAudioRenderClient), (void**)(ppRenderClient));
- }
-
- if (FAILED (hr)) {
- TRACE(_T("CMpcAudioRenderer::InitAudioClient service initialization failed (0x%08x)\n"), hr);
- } else {
- TRACE(_T("CMpcAudioRenderer::InitAudioClient service initialization success\n"));
- }
-
- return hr;
+ TRACE(_T("CMpcAudioRenderer::InitAudioClient\n"));
+ HRESULT hr = S_OK;
+ // Initialize the stream to play at the minimum latency.
+ //if (SUCCEEDED (hr)) hr = pAudioClient->GetDevicePeriod(NULL, &hnsPeriod);
+ hnsPeriod = 500000; //50 ms is the best according to James @Slysoft
+
+ hr = pAudioClient->IsFormatSupported(AUDCLNT_SHAREMODE_EXCLUSIVE, pWaveFormatEx, NULL);
+ if (FAILED(hr)) {
+ TRACE(_T("CMpcAudioRenderer::InitAudioClient not supported (0x%08x)\n"), hr);
+ } else {
+ TRACE(_T("CMpcAudioRenderer::InitAudioClient format supported\n"));
+ }
+
+ GetBufferSize(pWaveFormatEx, &hnsPeriod);
+
+ if (SUCCEEDED(hr)) hr = pAudioClient->Initialize(AUDCLNT_SHAREMODE_EXCLUSIVE, 0/*AUDCLNT_STREAMFLAGS_EVENTCALLBACK*/,
+ hnsPeriod, hnsPeriod, pWaveFormatEx, NULL);
+ if (FAILED(hr) && hr != AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED) {
+ TRACE(_T("CMpcAudioRenderer::InitAudioClient failed (0x%08x)\n"), hr);
+ return hr;
+ }
+
+ if (AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED == hr) {
+ // if the buffer size was not aligned, need to do the alignment dance
+ TRACE(_T("CMpcAudioRenderer::InitAudioClient Buffer size not aligned. Realigning\n"));
+
+ // get the buffer size, which will be aligned
+ hr = pAudioClient->GetBufferSize(&nFramesInBuffer);
+
+ // throw away this IAudioClient
+ pAudioClient->Release();
+ pAudioClient = NULL;
+
+ // calculate the new aligned periodicity
+ hnsPeriod = // hns =
+ (REFERENCE_TIME)(
+ 10000.0 * // (hns / ms) *
+ 1000 * // (ms / s) *
+ nFramesInBuffer / // frames /
+ pWaveFormatEx->nSamplesPerSec // (frames / s)
+ + 0.5 // rounding
+ );
+
+ if (SUCCEEDED(hr)) {
+ hr = CreateAudioClient(pMMDevice, &pAudioClient);
+ }
+ TRACE(_T("CMpcAudioRenderer::InitAudioClient Trying again with periodicity of %I64u hundred-nanoseconds, or %u frames.\n"), hnsPeriod, nFramesInBuffer);
+ if (SUCCEEDED(hr))
+ hr = pAudioClient->Initialize(AUDCLNT_SHAREMODE_EXCLUSIVE, 0/*AUDCLNT_STREAMFLAGS_EVENTCALLBACK*/,
+ hnsPeriod, hnsPeriod, pWaveFormatEx, NULL);
+ if (FAILED(hr)) {
+ TRACE(_T("CMpcAudioRenderer::InitAudioClient Failed to reinitialize the audio client\n"));
+ return hr;
+ }
+ } // if (AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED == hr)
+
+ // get the buffer size, which is aligned
+ if (SUCCEEDED(hr)) {
+ hr = pAudioClient->GetBufferSize(&nFramesInBuffer);
+ }
+
+ // calculate the new period
+ if (SUCCEEDED(hr)) {
+ hr = pAudioClient->GetService(__uuidof(IAudioRenderClient), (void**)(ppRenderClient));
+ }
+
+ if (FAILED(hr)) {
+ TRACE(_T("CMpcAudioRenderer::InitAudioClient service initialization failed (0x%08x)\n"), hr);
+ } else {
+ TRACE(_T("CMpcAudioRenderer::InitAudioClient service initialization success\n"));
+ }
+
+ return hr;
}
-HRESULT CMpcAudioRenderer::CreateAudioClient(IMMDevice *pMMDevice, IAudioClient **ppAudioClient)
+HRESULT CMpcAudioRenderer::CreateAudioClient(IMMDevice* pMMDevice, IAudioClient** ppAudioClient)
{
- HRESULT hr = S_OK;
- hnsPeriod = 0;
-
- TRACE(_T("CMpcAudioRenderer::CreateAudioClient\n"));
-
- if (*ppAudioClient) {
- if (isAudioClientStarted) {
- (*ppAudioClient)->Stop();
- }
- SAFE_RELEASE(*ppAudioClient);
- isAudioClientStarted=false;
- }
-
- if (pMMDevice==NULL) {
- TRACE(_T("CMpcAudioRenderer::CreateAudioClient failed, device not loaded\n"));
- return E_FAIL;
- }
-
- hr = pMMDevice->Activate(__uuidof(IAudioClient), CLSCTX_ALL, NULL, reinterpret_cast<void**>(ppAudioClient));
- if (FAILED(hr)) {
- TRACE(_T("CMpcAudioRenderer::CreateAudioClient activation failed (0x%08x)\n"), hr);
- } else {
- TRACE(_T("CMpcAudioRenderer::CreateAudioClient success\n"));
- }
- return hr;
+ HRESULT hr = S_OK;
+ hnsPeriod = 0;
+
+ TRACE(_T("CMpcAudioRenderer::CreateAudioClient\n"));
+
+ if (*ppAudioClient) {
+ if (isAudioClientStarted) {
+ (*ppAudioClient)->Stop();
+ }
+ SAFE_RELEASE(*ppAudioClient);
+ isAudioClientStarted = false;
+ }
+
+ if (pMMDevice == NULL) {
+ TRACE(_T("CMpcAudioRenderer::CreateAudioClient failed, device not loaded\n"));
+ return E_FAIL;
+ }
+
+ hr = pMMDevice->Activate(__uuidof(IAudioClient), CLSCTX_ALL, NULL, reinterpret_cast<void**>(ppAudioClient));
+ if (FAILED(hr)) {
+ TRACE(_T("CMpcAudioRenderer::CreateAudioClient activation failed (0x%08x)\n"), hr);
+ } else {
+ TRACE(_T("CMpcAudioRenderer::CreateAudioClient success\n"));
+ }
+ return hr;
}
diff --git a/src/filters/renderer/MpcAudioRenderer/MpcAudioRenderer.h b/src/filters/renderer/MpcAudioRenderer/MpcAudioRenderer.h
index d012d9a78..9bd0ea496 100644
--- a/src/filters/renderer/MpcAudioRenderer/MpcAudioRenderer.h
+++ b/src/filters/renderer/MpcAudioRenderer/MpcAudioRenderer.h
@@ -25,7 +25,7 @@
#include <BaseClasses/streams.h>
#include <dsound.h>
-#include <MMReg.h> //must be before other Wasapi headers
+#include <MMReg.h> //must be before other Wasapi headers
#include <strsafe.h>
#include <mmdeviceapi.h>
#include <avrt.h>
@@ -39,124 +39,124 @@
#define MpcAudioRendererName L"MPC Audio Renderer"
// REFERENCE_TIME time units per second and per millisecond
-#define REFTIMES_PER_SEC 10000000
-#define REFTIMES_PER_MILLISEC 10000
+#define REFTIMES_PER_SEC 10000000
+#define REFTIMES_PER_MILLISEC 10000
// if you get a compilation error on AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED,
// uncomment the #define below
#define AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED AUDCLNT_ERR(0x019)
class __declspec(uuid("601D2A2B-9CDE-40bd-8650-0485E3522727"))
- CMpcAudioRenderer : public CBaseRenderer
- , public IBasicAudio
- , public ISpecifyPropertyPages2
- , public IMpcAudioRendererFilter
+ CMpcAudioRenderer : public CBaseRenderer
+ , public IBasicAudio
+ , public ISpecifyPropertyPages2
+ , public IMpcAudioRendererFilter
{
public:
- CMpcAudioRenderer(LPUNKNOWN punk, HRESULT *phr);
- virtual ~CMpcAudioRenderer();
+ CMpcAudioRenderer(LPUNKNOWN punk, HRESULT* phr);
+ virtual ~CMpcAudioRenderer();
- static const AMOVIESETUP_FILTER sudASFilter;
+ static const AMOVIESETUP_FILTER sudASFilter;
- HRESULT CheckInputType (const CMediaType* mtIn);
- virtual HRESULT CheckMediaType (const CMediaType *pmt);
- virtual HRESULT DoRenderSample (IMediaSample *pMediaSample);
- virtual void OnReceiveFirstSample (IMediaSample *pMediaSample);
- BOOL ScheduleSample (IMediaSample *pMediaSample);
- virtual HRESULT SetMediaType (const CMediaType *pmt);
- virtual HRESULT CompleteConnect (IPin *pReceivePin);
+ HRESULT CheckInputType(const CMediaType* mtIn);
+ virtual HRESULT CheckMediaType(const CMediaType* pmt);
+ virtual HRESULT DoRenderSample(IMediaSample* pMediaSample);
+ virtual void OnReceiveFirstSample(IMediaSample* pMediaSample);
+ BOOL ScheduleSample(IMediaSample* pMediaSample);
+ virtual HRESULT SetMediaType(const CMediaType* pmt);
+ virtual HRESULT CompleteConnect(IPin* pReceivePin);
- HRESULT EndOfStream(void);
+ HRESULT EndOfStream(void);
- DECLARE_IUNKNOWN
+ DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // === IMediaFilter
- STDMETHOD(Run) (REFERENCE_TIME tStart);
- STDMETHOD(Stop) ();
- STDMETHOD(Pause) ();
+ // === IMediaFilter
+ STDMETHOD(Run)(REFERENCE_TIME tStart);
+ STDMETHOD(Stop)();
+ STDMETHOD(Pause)();
- // === IDispatch (pour IBasicAudio)
- STDMETHOD(GetTypeInfoCount) (UINT * pctinfo);
- STDMETHOD(GetTypeInfo) (UINT itinfo, LCID lcid, ITypeInfo ** pptinfo);
- STDMETHOD(GetIDsOfNames) (REFIID riid, OLECHAR** rgszNames, UINT cNames, LCID lcid, DISPID* rgdispid);
- STDMETHOD(Invoke) (DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult, EXCEPINFO* pexcepinfo, UINT* puArgErr);
+ // === IDispatch (pour IBasicAudio)
+ STDMETHOD(GetTypeInfoCount)(UINT* pctinfo);
+ STDMETHOD(GetTypeInfo)(UINT itinfo, LCID lcid, ITypeInfo** pptinfo);
+ STDMETHOD(GetIDsOfNames)(REFIID riid, OLECHAR** rgszNames, UINT cNames, LCID lcid, DISPID* rgdispid);
+ STDMETHOD(Invoke)(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult, EXCEPINFO* pexcepinfo, UINT* puArgErr);
- // === IBasicAudio
- STDMETHOD(put_Volume) (long lVolume);
- STDMETHOD(get_Volume) (long *plVolume);
- STDMETHOD(put_Balance) (long lBalance);
- STDMETHOD(get_Balance) (long *plBalance);
+ // === IBasicAudio
+ STDMETHOD(put_Volume)(long lVolume);
+ STDMETHOD(get_Volume)(long* plVolume);
+ STDMETHOD(put_Balance)(long lBalance);
+ STDMETHOD(get_Balance)(long* plBalance);
- // === ISpecifyPropertyPages2
- STDMETHODIMP GetPages(CAUUID* pPages);
- STDMETHODIMP CreatePage(const GUID& guid, IPropertyPage** ppPage);
+ // === ISpecifyPropertyPages2
+ STDMETHODIMP GetPages(CAUUID* pPages);
+ STDMETHODIMP CreatePage(const GUID& guid, IPropertyPage** ppPage);
- // === IMpcAudioRendererFilter
- STDMETHODIMP Apply();
- STDMETHODIMP SetWasapiMode(BOOL nValue);
- STDMETHODIMP_(BOOL) GetWasapiMode();
- STDMETHODIMP SetMuteFastForward(BOOL nValue);
- STDMETHODIMP_(BOOL) GetMuteFastForward();
- STDMETHODIMP SetSoundDevice(CString nValue);
- STDMETHODIMP_(CString) GetSoundDevice();
+ // === IMpcAudioRendererFilter
+ STDMETHODIMP Apply();
+ STDMETHODIMP SetWasapiMode(BOOL nValue);
+ STDMETHODIMP_(BOOL) GetWasapiMode();
+ STDMETHODIMP SetMuteFastForward(BOOL nValue);
+ STDMETHODIMP_(BOOL) GetMuteFastForward();
+ STDMETHODIMP SetSoundDevice(CString nValue);
+ STDMETHODIMP_(CString) GetSoundDevice();
- // CMpcAudioRenderer
+ // CMpcAudioRenderer
private:
- HRESULT DoRenderSampleDirectSound(IMediaSample *pMediaSample);
-
- HRESULT InitCoopLevel();
- HRESULT ClearBuffer();
- HRESULT CreateDSBuffer();
- HRESULT GetReferenceClockInterface(REFIID riid, void **ppv);
- HRESULT WriteSampleToDSBuffer(IMediaSample *pMediaSample, bool *looped);
-
- LPDIRECTSOUND8 m_pDS;
- LPDIRECTSOUNDBUFFER m_pDSBuffer;
- DWORD m_dwDSWriteOff;
- WAVEFORMATEX *m_pWaveFileFormat;
- int m_nDSBufSize;
- CBaseReferenceClock* m_pReferenceClock;
- double m_dRate;
- long m_lVolume;
- soundtouch::SoundTouch* m_pSoundTouch;
- CCritSec m_csProps;
-
- // CMpcAudioRenderer WASAPI methods
- HRESULT GetAvailableAudioDevices(IMMDeviceCollection **ppMMDevices);
- HRESULT GetAudioDevice(IMMDevice **ppMMDevice);
- HRESULT CreateAudioClient(IMMDevice *pMMDevice, IAudioClient **ppAudioClient);
- HRESULT InitAudioClient(WAVEFORMATEX *pWaveFormatEx, IAudioClient *pAudioClient, IAudioRenderClient **ppRenderClient);
- HRESULT CheckAudioClient(WAVEFORMATEX *pWaveFormatEx);
- bool CheckFormatChanged(WAVEFORMATEX *pWaveFormatEx, WAVEFORMATEX **ppNewWaveFormatEx);
- HRESULT DoRenderSampleWasapi(IMediaSample *pMediaSample);
- HRESULT GetBufferSize(WAVEFORMATEX *pWaveFormatEx, REFERENCE_TIME *pHnsBufferPeriod);
-
-
- // WASAPI variables
- bool m_useWASAPI;
- bool m_useWASAPIAfterRestart;
- bool m_bMuteFastForward;
- CString m_csSound_Device;
- IMMDevice *pMMDevice;
- IAudioClient *pAudioClient;
- IAudioRenderClient *pRenderClient;
- UINT32 nFramesInBuffer;
- REFERENCE_TIME hnsPeriod, hnsActualDuration;
- HANDLE hTask;
- CCritSec m_csCheck;
- UINT32 bufferSize;
- bool isAudioClientStarted;
- DWORD lastBufferTime;
-
- // AVRT.dll (Vista or greater
- typedef HANDLE (__stdcall *PTR_AvSetMmThreadCharacteristicsW)(LPCWSTR TaskName, LPDWORD TaskIndex);
- typedef BOOL (__stdcall *PTR_AvRevertMmThreadCharacteristics)(HANDLE AvrtHandle);
-
- PTR_AvSetMmThreadCharacteristicsW pfAvSetMmThreadCharacteristicsW;
- PTR_AvRevertMmThreadCharacteristics pfAvRevertMmThreadCharacteristics;
+ HRESULT DoRenderSampleDirectSound(IMediaSample* pMediaSample);
+
+ HRESULT InitCoopLevel();
+ HRESULT ClearBuffer();
+ HRESULT CreateDSBuffer();
+ HRESULT GetReferenceClockInterface(REFIID riid, void** ppv);
+ HRESULT WriteSampleToDSBuffer(IMediaSample* pMediaSample, bool* looped);
+
+ LPDIRECTSOUND8 m_pDS;
+ LPDIRECTSOUNDBUFFER m_pDSBuffer;
+ DWORD m_dwDSWriteOff;
+ WAVEFORMATEX* m_pWaveFileFormat;
+ int m_nDSBufSize;
+ CBaseReferenceClock* m_pReferenceClock;
+ double m_dRate;
+ long m_lVolume;
+ soundtouch::SoundTouch* m_pSoundTouch;
+ CCritSec m_csProps;
+
+ // CMpcAudioRenderer WASAPI methods
+ HRESULT GetAvailableAudioDevices(IMMDeviceCollection** ppMMDevices);
+ HRESULT GetAudioDevice(IMMDevice** ppMMDevice);
+ HRESULT CreateAudioClient(IMMDevice* pMMDevice, IAudioClient** ppAudioClient);
+ HRESULT InitAudioClient(WAVEFORMATEX* pWaveFormatEx, IAudioClient* pAudioClient, IAudioRenderClient** ppRenderClient);
+ HRESULT CheckAudioClient(WAVEFORMATEX* pWaveFormatEx);
+ bool CheckFormatChanged(WAVEFORMATEX* pWaveFormatEx, WAVEFORMATEX** ppNewWaveFormatEx);
+ HRESULT DoRenderSampleWasapi(IMediaSample* pMediaSample);
+ HRESULT GetBufferSize(WAVEFORMATEX* pWaveFormatEx, REFERENCE_TIME* pHnsBufferPeriod);
+
+
+ // WASAPI variables
+ bool m_useWASAPI;
+ bool m_useWASAPIAfterRestart;
+ bool m_bMuteFastForward;
+ CString m_csSound_Device;
+ IMMDevice* pMMDevice;
+ IAudioClient* pAudioClient;
+ IAudioRenderClient* pRenderClient;
+ UINT32 nFramesInBuffer;
+ REFERENCE_TIME hnsPeriod, hnsActualDuration;
+ HANDLE hTask;
+ CCritSec m_csCheck;
+ UINT32 bufferSize;
+ bool isAudioClientStarted;
+ DWORD lastBufferTime;
+
+ // AVRT.dll (Vista or greater
+ typedef HANDLE(__stdcall* PTR_AvSetMmThreadCharacteristicsW)(LPCWSTR TaskName, LPDWORD TaskIndex);
+ typedef BOOL (__stdcall* PTR_AvRevertMmThreadCharacteristics)(HANDLE AvrtHandle);
+
+ PTR_AvSetMmThreadCharacteristicsW pfAvSetMmThreadCharacteristicsW;
+ PTR_AvRevertMmThreadCharacteristics pfAvRevertMmThreadCharacteristics;
};
diff --git a/src/filters/renderer/MpcAudioRenderer/MpcAudioRendererSettingsWnd.cpp b/src/filters/renderer/MpcAudioRenderer/MpcAudioRendererSettingsWnd.cpp
index 8b9465957..0100e05ff 100644
--- a/src/filters/renderer/MpcAudioRenderer/MpcAudioRendererSettingsWnd.cpp
+++ b/src/filters/renderer/MpcAudioRenderer/MpcAudioRendererSettingsWnd.cpp
@@ -30,8 +30,8 @@
// ==>>> Resource identifier from "resource.h" present in mplayerc project!
#define ResStr(id) CString(MAKEINTRESOURCE(id))
-#define LEFT_SPACING 25
-#define VERTICAL_SPACING 25
+#define LEFT_SPACING 25
+#define VERTICAL_SPACING 25
CMpcAudioRendererSettingsWnd::CMpcAudioRendererSettingsWnd(void)
{
@@ -39,84 +39,81 @@ CMpcAudioRendererSettingsWnd::CMpcAudioRendererSettingsWnd(void)
bool CMpcAudioRendererSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
{
- ASSERT(!m_pMAR);
+ ASSERT(!m_pMAR);
- m_pMAR.Release();
+ m_pMAR.Release();
- POSITION pos = pUnks.GetHeadPosition();
- while (pos && !(m_pMAR = pUnks.GetNext(pos))) {
- ;
- }
+ POSITION pos = pUnks.GetHeadPosition();
+ while (pos && !(m_pMAR = pUnks.GetNext(pos))) {
+ ;
+ }
- if (!m_pMAR) {
- return false;
- }
+ if (!m_pMAR) {
+ return false;
+ }
- return true;
+ return true;
}
void CMpcAudioRendererSettingsWnd::OnDisconnect()
{
- m_pMAR.Release();
+ m_pMAR.Release();
}
bool CALLBACK DSEnumProc(LPGUID lpGUID,
- LPCTSTR lpszDesc,
- LPCTSTR lpszDrvName,
- LPVOID lpContext )
+ LPCTSTR lpszDesc,
+ LPCTSTR lpszDrvName,
+ LPVOID lpContext)
{
- CComboBox *pCombo = (CComboBox*)lpContext;
- ASSERT ( pCombo );
- LPGUID lpTemp = NULL;
-
- if (lpGUID != NULL) // NULL only for "Primary Sound Driver".
- {
- if ((lpTemp = (LPGUID)malloc(sizeof(GUID))) == NULL)
- {
- return TRUE;
- }
- memcpy(lpTemp, lpGUID, sizeof(GUID));
- }
- pCombo->AddString ( lpszDesc );
- free(lpTemp);
- return TRUE;
+ CComboBox* pCombo = (CComboBox*)lpContext;
+ ASSERT(pCombo);
+ LPGUID lpTemp = NULL;
+
+ if (lpGUID != NULL) { // NULL only for "Primary Sound Driver".
+ if ((lpTemp = (LPGUID)malloc(sizeof(GUID))) == NULL) {
+ return TRUE;
+ }
+ memcpy(lpTemp, lpGUID, sizeof(GUID));
+ }
+ pCombo->AddString(lpszDesc);
+ free(lpTemp);
+ return TRUE;
}
bool CMpcAudioRendererSettingsWnd::OnActivate()
{
- int nPosY = 10;
-
- m_grpDefault.Create (_T(""), WS_VISIBLE|WS_CHILD | BS_GROUPBOX, CRect (10, nPosY, 350, nPosY+300), this, (UINT)IDC_STATIC);
- nPosY += VERTICAL_SPACING;
- m_cbWasapiMode.Create (ResStr (IDS_ARS_WASAPI_MODE), WS_VISIBLE|WS_CHILD|BS_AUTOCHECKBOX|BS_LEFTTEXT, CRect (LEFT_SPACING, nPosY, 325, nPosY+15), this, IDC_PP_WASAPI_MODE);
- nPosY += VERTICAL_SPACING;
- m_cbMuteFastForward.Create (ResStr (IDS_ARS_MUTE_FAST_FORWARD), WS_VISIBLE|WS_CHILD|BS_AUTOCHECKBOX|BS_LEFTTEXT, CRect (LEFT_SPACING, nPosY, 325, nPosY+15), this, IDC_PP_MUTE_FAST_FORWARD);
- nPosY += VERTICAL_SPACING + 5;
- m_txtSoundDevice.Create (ResStr (IDS_ARS_SOUND_DEVICE), WS_VISIBLE|WS_CHILD, CRect (LEFT_SPACING, nPosY, 100, nPosY+15), this, (UINT)IDC_STATIC);
- m_cbSoundDevice.Create (WS_VISIBLE|WS_CHILD|CBS_DROPDOWNLIST|WS_VSCROLL, CRect (110, nPosY-4, 325, nPosY+90), this, IDC_PP_SOUND_DEVICE);
-
- SetClassLongPtr(GetDlgItem(IDC_PP_SOUND_DEVICE)->m_hWnd, GCLP_HCURSOR, (LONG_PTR)AfxGetApp()->LoadStandardCursor(IDC_HAND));
-
- DirectSoundEnumerate((LPDSENUMCALLBACK)DSEnumProc, (VOID*)&m_cbSoundDevice);
-
- if ( m_cbSoundDevice.GetCount() > 0 ) {
- int idx = m_cbSoundDevice.FindString(0, m_pMAR->GetSoundDevice());
- if ( idx < 0) {
- m_cbSoundDevice.SetCurSel(0);
- }
- else {
- m_cbSoundDevice.SetCurSel(m_cbSoundDevice.FindString(0, m_pMAR->GetSoundDevice()));
- }
- }
-
- m_cbWasapiMode.SetCheck(m_pMAR->GetWasapiMode());
- m_cbMuteFastForward.SetCheck(m_pMAR->GetMuteFastForward());
-
- for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
- pWnd->SetFont(&m_font, FALSE);
- }
-
- return true;
+ int nPosY = 10;
+
+ m_grpDefault.Create(_T(""), WS_VISIBLE | WS_CHILD | BS_GROUPBOX, CRect(10, nPosY, 350, nPosY + 300), this, (UINT)IDC_STATIC);
+ nPosY += VERTICAL_SPACING;
+ m_cbWasapiMode.Create(ResStr(IDS_ARS_WASAPI_MODE), WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX | BS_LEFTTEXT, CRect(LEFT_SPACING, nPosY, 325, nPosY + 15), this, IDC_PP_WASAPI_MODE);
+ nPosY += VERTICAL_SPACING;
+ m_cbMuteFastForward.Create(ResStr(IDS_ARS_MUTE_FAST_FORWARD), WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX | BS_LEFTTEXT, CRect(LEFT_SPACING, nPosY, 325, nPosY + 15), this, IDC_PP_MUTE_FAST_FORWARD);
+ nPosY += VERTICAL_SPACING + 5;
+ m_txtSoundDevice.Create(ResStr(IDS_ARS_SOUND_DEVICE), WS_VISIBLE | WS_CHILD, CRect(LEFT_SPACING, nPosY, 100, nPosY + 15), this, (UINT)IDC_STATIC);
+ m_cbSoundDevice.Create(WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST | WS_VSCROLL, CRect(110, nPosY - 4, 325, nPosY + 90), this, IDC_PP_SOUND_DEVICE);
+
+ SetClassLongPtr(GetDlgItem(IDC_PP_SOUND_DEVICE)->m_hWnd, GCLP_HCURSOR, (LONG_PTR)AfxGetApp()->LoadStandardCursor(IDC_HAND));
+
+ DirectSoundEnumerate((LPDSENUMCALLBACK)DSEnumProc, (VOID*)&m_cbSoundDevice);
+
+ if (m_cbSoundDevice.GetCount() > 0) {
+ int idx = m_cbSoundDevice.FindString(0, m_pMAR->GetSoundDevice());
+ if (idx < 0) {
+ m_cbSoundDevice.SetCurSel(0);
+ } else {
+ m_cbSoundDevice.SetCurSel(m_cbSoundDevice.FindString(0, m_pMAR->GetSoundDevice()));
+ }
+ }
+
+ m_cbWasapiMode.SetCheck(m_pMAR->GetWasapiMode());
+ m_cbMuteFastForward.SetCheck(m_pMAR->GetMuteFastForward());
+
+ for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
+ pWnd->SetFont(&m_font, FALSE);
+ }
+
+ return true;
}
void CMpcAudioRendererSettingsWnd::OnDeactivate()
@@ -125,21 +122,21 @@ void CMpcAudioRendererSettingsWnd::OnDeactivate()
bool CMpcAudioRendererSettingsWnd::OnApply()
{
- OnDeactivate();
-
- if (m_pMAR) {
- m_pMAR->SetWasapiMode(m_cbWasapiMode.GetCheck());
- m_pMAR->SetMuteFastForward(m_cbMuteFastForward.GetCheck());
- CString str;
- int idx = m_cbSoundDevice.GetCurSel();
- if ( !(idx < 0) ) {
- m_cbSoundDevice.GetLBText( idx, str );
- m_pMAR->SetSoundDevice(str);
- }
- m_pMAR->Apply();
- }
-
- return true;
+ OnDeactivate();
+
+ if (m_pMAR) {
+ m_pMAR->SetWasapiMode(m_cbWasapiMode.GetCheck());
+ m_pMAR->SetMuteFastForward(m_cbMuteFastForward.GetCheck());
+ CString str;
+ int idx = m_cbSoundDevice.GetCurSel();
+ if (!(idx < 0)) {
+ m_cbSoundDevice.GetLBText(idx, str);
+ m_pMAR->SetSoundDevice(str);
+ }
+ m_pMAR->Apply();
+ }
+
+ return true;
}
diff --git a/src/filters/renderer/MpcAudioRenderer/MpcAudioRendererSettingsWnd.h b/src/filters/renderer/MpcAudioRenderer/MpcAudioRendererSettingsWnd.h
index 16b4d034b..c1884249e 100644
--- a/src/filters/renderer/MpcAudioRenderer/MpcAudioRendererSettingsWnd.h
+++ b/src/filters/renderer/MpcAudioRenderer/MpcAudioRendererSettingsWnd.h
@@ -27,44 +27,44 @@
#include <afxcmn.h>
class __declspec(uuid("1E53BA32-3BCC-4dff-9342-34E46BE3F5A5"))
- CMpcAudioRendererSettingsWnd : public CInternalPropertyPageWnd
+ CMpcAudioRendererSettingsWnd : public CInternalPropertyPageWnd
{
private :
- CComQIPtr<IMpcAudioRendererFilter> m_pMAR;
+ CComQIPtr<IMpcAudioRendererFilter> m_pMAR;
- CButton m_grpDefault;
+ CButton m_grpDefault;
- CStatic m_txtWasapiMode;
- CButton m_cbWasapiMode;
- CButton m_cbMuteFastForward;
+ CStatic m_txtWasapiMode;
+ CButton m_cbWasapiMode;
+ CButton m_cbMuteFastForward;
- CStatic m_txtSoundDevice;
- CComboBox m_cbSoundDevice;
+ CStatic m_txtSoundDevice;
+ CComboBox m_cbSoundDevice;
- enum {
- IDC_PP_WASAPI_MODE = 10000,
- IDC_PP_MUTE_FAST_FORWARD,
- IDC_PP_SOUND_DEVICE,
- };
+ enum {
+ IDC_PP_WASAPI_MODE = 10000,
+ IDC_PP_MUTE_FAST_FORWARD,
+ IDC_PP_SOUND_DEVICE,
+ };
public:
- CMpcAudioRendererSettingsWnd(void);
+ CMpcAudioRendererSettingsWnd(void);
- bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
- void OnDisconnect();
- bool OnActivate();
- void OnDeactivate();
- bool OnApply();
+ bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
+ void OnDisconnect();
+ bool OnActivate();
+ void OnDeactivate();
+ bool OnApply();
- HRESULT GetAvailableAudioDevices();
+ HRESULT GetAvailableAudioDevices();
- static LPCTSTR GetWindowTitle() {
- return _T("Settings");
- }
- static CSize GetWindowSize() {
- return CSize(350, 325);
- }
+ static LPCTSTR GetWindowTitle() {
+ return _T("Settings");
+ }
+ static CSize GetWindowSize() {
+ return CSize(350, 325);
+ }
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
};
diff --git a/src/filters/renderer/SyncClock/Interfaces.h b/src/filters/renderer/SyncClock/Interfaces.h
index 8194c1322..74b6340fb 100644
--- a/src/filters/renderer/SyncClock/Interfaces.h
+++ b/src/filters/renderer/SyncClock/Interfaces.h
@@ -28,8 +28,8 @@ MIDL_INTERFACE("A62888FB-8E37-44d2-8850-B3E3F2C1169F")
ISyncClock:
public IUnknown {
public:
- virtual HRESULT STDMETHODCALLTYPE AdjustClock(DOUBLE adjustment) = 0;
- virtual HRESULT STDMETHODCALLTYPE SetBias(DOUBLE bias) = 0;
- virtual HRESULT STDMETHODCALLTYPE GetBias(DOUBLE *bias) = 0;
- virtual HRESULT STDMETHODCALLTYPE GetStartTime(REFERENCE_TIME *startTime);
+ virtual HRESULT STDMETHODCALLTYPE AdjustClock(DOUBLE adjustment) = 0;
+ virtual HRESULT STDMETHODCALLTYPE SetBias(DOUBLE bias) = 0;
+ virtual HRESULT STDMETHODCALLTYPE GetBias(DOUBLE * bias) = 0;
+ virtual HRESULT STDMETHODCALLTYPE GetStartTime(REFERENCE_TIME * startTime);
};
diff --git a/src/filters/renderer/SyncClock/SyncClock.cpp b/src/filters/renderer/SyncClock/SyncClock.cpp
index 75b0adcc8..7688059f4 100644
--- a/src/filters/renderer/SyncClock/SyncClock.cpp
+++ b/src/filters/renderer/SyncClock/SyncClock.cpp
@@ -24,9 +24,9 @@
#include "SyncClock.h"
-CSyncClockFilter::CSyncClockFilter(LPUNKNOWN pUnk, HRESULT *phr)
- : CBaseFilter(NAME("SyncClock"), NULL, &m_Lock, CLSID_NULL)
- , m_Clock(static_cast<IBaseFilter*>(this), phr)
+CSyncClockFilter::CSyncClockFilter(LPUNKNOWN pUnk, HRESULT* phr)
+ : CBaseFilter(NAME("SyncClock"), NULL, &m_Lock, CLSID_NULL)
+ , m_Clock(static_cast<IBaseFilter*>(this), phr)
{
}
@@ -36,86 +36,86 @@ CSyncClockFilter::~CSyncClockFilter()
STDMETHODIMP CSyncClockFilter::AdjustClock(DOUBLE adjustment)
{
- m_Clock.adjustment = adjustment;
- return S_OK;
+ m_Clock.adjustment = adjustment;
+ return S_OK;
}
STDMETHODIMP CSyncClockFilter::SetBias(DOUBLE bias)
{
- m_Clock.bias = bias;
- return S_OK;
+ m_Clock.bias = bias;
+ return S_OK;
}
-STDMETHODIMP CSyncClockFilter::GetBias(DOUBLE *bias)
+STDMETHODIMP CSyncClockFilter::GetBias(DOUBLE* bias)
{
- *bias = m_Clock.bias;
- return S_OK;
+ *bias = m_Clock.bias;
+ return S_OK;
}
-STDMETHODIMP CSyncClockFilter::GetStartTime(REFERENCE_TIME *startTime)
+STDMETHODIMP CSyncClockFilter::GetStartTime(REFERENCE_TIME* startTime)
{
- *startTime = m_tStart;
- return S_OK;
+ *startTime = m_tStart;
+ return S_OK;
}
-STDMETHODIMP CSyncClockFilter::NonDelegatingQueryInterface( REFIID riid, void ** ppv )
+STDMETHODIMP CSyncClockFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
-
- if (riid == IID_IReferenceClock) {
- return GetInterface(static_cast<IReferenceClock*>(&m_Clock), ppv);
- } else if (riid == IID_ISyncClock) {
- return GetInterface(static_cast<ISyncClock*>(this), ppv);
- } else {
- return CBaseFilter::NonDelegatingQueryInterface(riid, ppv);
- }
+ CheckPointer(ppv, E_POINTER);
+
+ if (riid == IID_IReferenceClock) {
+ return GetInterface(static_cast<IReferenceClock*>(&m_Clock), ppv);
+ } else if (riid == IID_ISyncClock) {
+ return GetInterface(static_cast<ISyncClock*>(this), ppv);
+ } else {
+ return CBaseFilter::NonDelegatingQueryInterface(riid, ppv);
+ }
}
int CSyncClockFilter::GetPinCount()
{
- return 0;
+ return 0;
}
-CBasePin *CSyncClockFilter::GetPin(int i)
+CBasePin* CSyncClockFilter::GetPin(int i)
{
- UNREFERENCED_PARAMETER(i);
- return NULL;
+ UNREFERENCED_PARAMETER(i);
+ return NULL;
}
// CSyncClock methods
-CSyncClock::CSyncClock(LPUNKNOWN pUnk, HRESULT *phr)
- : CBaseReferenceClock(NAME("SyncClock"), pUnk, phr)
- , m_pCurrentRefClock(0), m_pPrevRefClock(0)
+CSyncClock::CSyncClock(LPUNKNOWN pUnk, HRESULT* phr)
+ : CBaseReferenceClock(NAME("SyncClock"), pUnk, phr)
+ , m_pCurrentRefClock(0), m_pPrevRefClock(0)
{
- QueryPerformanceFrequency((LARGE_INTEGER*)&m_llPerfFrequency);
- m_rtPrivateTime = GetTicks100ns();
- m_rtPrevTime = m_rtPrivateTime;
- adjustment = 1.0;
- bias = 1.0;
+ QueryPerformanceFrequency((LARGE_INTEGER*)&m_llPerfFrequency);
+ m_rtPrivateTime = GetTicks100ns();
+ m_rtPrevTime = m_rtPrivateTime;
+ adjustment = 1.0;
+ bias = 1.0;
}
REFERENCE_TIME CSyncClock::GetPrivateTime()
{
- CAutoLock cObjectLock(this);
+ CAutoLock cObjectLock(this);
- REFERENCE_TIME rtTime = GetTicks100ns();
+ REFERENCE_TIME rtTime = GetTicks100ns();
- REFERENCE_TIME delta = rtTime - m_rtPrevTime;
- // We ignore that rtTime may wrap around. Not gonna happen too often
- m_rtPrevTime = rtTime;
+ REFERENCE_TIME delta = rtTime - m_rtPrevTime;
+ // We ignore that rtTime may wrap around. Not gonna happen too often
+ m_rtPrevTime = rtTime;
- delta = (REFERENCE_TIME)((DOUBLE)delta * adjustment * bias);
- m_rtPrivateTime = m_rtPrivateTime + delta;
- return m_rtPrivateTime;
+ delta = (REFERENCE_TIME)((DOUBLE)delta * adjustment * bias);
+ m_rtPrivateTime = m_rtPrivateTime + delta;
+ return m_rtPrivateTime;
}
REFERENCE_TIME CSyncClock::GetTicks100ns()
{
- LONGLONG i64Ticks100ns;
- if (m_llPerfFrequency != 0) {
- QueryPerformanceCounter((LARGE_INTEGER*)&i64Ticks100ns);
- i64Ticks100ns = LONGLONG((double(i64Ticks100ns) * 10000000) / double(m_llPerfFrequency) + 0.5);
- return (REFERENCE_TIME)i64Ticks100ns;
- }
- return 0;
+ LONGLONG i64Ticks100ns;
+ if (m_llPerfFrequency != 0) {
+ QueryPerformanceCounter((LARGE_INTEGER*)&i64Ticks100ns);
+ i64Ticks100ns = LONGLONG((double(i64Ticks100ns) * 10000000) / double(m_llPerfFrequency) + 0.5);
+ return (REFERENCE_TIME)i64Ticks100ns;
+ }
+ return 0;
}
diff --git a/src/filters/renderer/SyncClock/SyncClock.h b/src/filters/renderer/SyncClock/SyncClock.h
index 1a0a24804..50de20a56 100644
--- a/src/filters/renderer/SyncClock/SyncClock.h
+++ b/src/filters/renderer/SyncClock/SyncClock.h
@@ -30,48 +30,48 @@ class CSyncClockFilter;
class CSyncClock: public CBaseReferenceClock
{
- friend class CSyncClockFilter;
+ friend class CSyncClockFilter;
public:
- CSyncClock(LPUNKNOWN pUnk, HRESULT *phr);
+ CSyncClock(LPUNKNOWN pUnk, HRESULT* phr);
- REFERENCE_TIME GetPrivateTime();
- IUnknown * pUnk() {
- return static_cast<IUnknown*>(static_cast<IReferenceClock*>(this));
- }
- DOUBLE adjustment; // For adjusting speed temporarily
- DOUBLE bias; // For changing speed permanently
+ REFERENCE_TIME GetPrivateTime();
+ IUnknown* pUnk() {
+ return static_cast<IUnknown*>(static_cast<IReferenceClock*>(this));
+ }
+ DOUBLE adjustment; // For adjusting speed temporarily
+ DOUBLE bias; // For changing speed permanently
private:
- REFERENCE_TIME m_rtPrivateTime;
- LONGLONG m_llPerfFrequency;
- REFERENCE_TIME m_rtPrevTime;
- CCritSec m_csClock;
- IReferenceClock * m_pCurrentRefClock;
- IReferenceClock * m_pPrevRefClock;
- REFERENCE_TIME GetTicks100ns();
+ REFERENCE_TIME m_rtPrivateTime;
+ LONGLONG m_llPerfFrequency;
+ REFERENCE_TIME m_rtPrevTime;
+ CCritSec m_csClock;
+ IReferenceClock* m_pCurrentRefClock;
+ IReferenceClock* m_pPrevRefClock;
+ REFERENCE_TIME GetTicks100ns();
};
class __declspec(uuid("57797fe5-ee9b-4408-98a9-20b134e7e8f0"))
- CSyncClockFilter: public ISyncClock, public CBaseFilter
+ CSyncClockFilter: public ISyncClock, public CBaseFilter
{
public:
- CSyncClockFilter(LPUNKNOWN pUnk, HRESULT *phr);
- virtual ~CSyncClockFilter();
+ CSyncClockFilter(LPUNKNOWN pUnk, HRESULT* phr);
+ virtual ~CSyncClockFilter();
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface( REFIID riid, void ** ppv);
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // ISyncClock
- STDMETHODIMP AdjustClock(DOUBLE adjustment);
- STDMETHODIMP SetBias(DOUBLE bias);
- STDMETHODIMP GetBias(DOUBLE *bias);
- STDMETHODIMP GetStartTime(REFERENCE_TIME *startTime);
+ // ISyncClock
+ STDMETHODIMP AdjustClock(DOUBLE adjustment);
+ STDMETHODIMP SetBias(DOUBLE bias);
+ STDMETHODIMP GetBias(DOUBLE* bias);
+ STDMETHODIMP GetStartTime(REFERENCE_TIME* startTime);
- // CBaseFilter methods
- int GetPinCount();
- CBasePin* GetPin(int iPin);
+ // CBaseFilter methods
+ int GetPinCount();
+ CBasePin* GetPin(int iPin);
private:
- CSyncClock m_Clock;
- CCritSec m_Lock;
+ CSyncClock m_Clock;
+ CCritSec m_Lock;
};
diff --git a/src/filters/renderer/SyncClock/stdafx.h b/src/filters/renderer/SyncClock/stdafx.h
index 57e5495e4..c8671082d 100644
--- a/src/filters/renderer/SyncClock/stdafx.h
+++ b/src/filters/renderer/SyncClock/stdafx.h
@@ -25,12 +25,12 @@
#include "../../../DSUtil/SharedInclude.h"
#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#endif
-#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
#ifndef VC_EXTRALEAN
-#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
+#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
#include <afx.h>
diff --git a/src/filters/renderer/VideoRenderers/AllocatorCommon.cpp b/src/filters/renderer/VideoRenderers/AllocatorCommon.cpp
index a422ca918..a21587ec5 100644
--- a/src/filters/renderer/VideoRenderers/AllocatorCommon.cpp
+++ b/src/filters/renderer/VideoRenderers/AllocatorCommon.cpp
@@ -34,296 +34,290 @@
bool IsVMR9InGraph(IFilterGraph* pFG)
{
- BeginEnumFilters(pFG, pEF, pBF)
- if (CComQIPtr<IVMRWindowlessControl9>(pBF)) {
- return true;
- }
- EndEnumFilters
- return false;
+ BeginEnumFilters(pFG, pEF, pBF)
+ if (CComQIPtr<IVMRWindowlessControl9>(pBF)) {
+ return true;
+ }
+ EndEnumFilters
+ return false;
}
//
HRESULT CreateAP9(const CLSID& clsid, HWND hWnd, bool bFullscreen, ISubPicAllocatorPresenter** ppAP)
{
- CheckPointer(ppAP, E_POINTER);
+ CheckPointer(ppAP, E_POINTER);
- *ppAP = NULL;
+ *ppAP = NULL;
- using namespace DSObjects;
+ using namespace DSObjects;
- HRESULT hr = E_FAIL;
- CString Error;
+ HRESULT hr = E_FAIL;
+ CString Error;
- if ( IsEqualCLSID(clsid, CLSID_VMR9AllocatorPresenter) ) {
- *ppAP = DNew CVMR9AllocatorPresenter(hWnd, bFullscreen, hr, Error);
- }
- else if ( IsEqualCLSID(clsid, CLSID_RM9AllocatorPresenter) ) {
- *ppAP = DNew CRM9AllocatorPresenter(hWnd, bFullscreen, hr, Error);
- }
- else if ( IsEqualCLSID(clsid, CLSID_QT9AllocatorPresenter) ) {
- *ppAP = DNew CQT9AllocatorPresenter(hWnd, bFullscreen, hr, Error);
- }
- else if ( IsEqualCLSID(clsid, CLSID_DXRAllocatorPresenter) ) {
- *ppAP = DNew CDXRAllocatorPresenter(hWnd, hr, Error);
- }
- else if ( IsEqualCLSID(clsid, CLSID_madVRAllocatorPresenter) ) {
- *ppAP = DNew CmadVRAllocatorPresenter(hWnd, hr, Error);
- }
- else {
- return E_FAIL;
- }
+ if (IsEqualCLSID(clsid, CLSID_VMR9AllocatorPresenter)) {
+ *ppAP = DNew CVMR9AllocatorPresenter(hWnd, bFullscreen, hr, Error);
+ } else if (IsEqualCLSID(clsid, CLSID_RM9AllocatorPresenter)) {
+ *ppAP = DNew CRM9AllocatorPresenter(hWnd, bFullscreen, hr, Error);
+ } else if (IsEqualCLSID(clsid, CLSID_QT9AllocatorPresenter)) {
+ *ppAP = DNew CQT9AllocatorPresenter(hWnd, bFullscreen, hr, Error);
+ } else if (IsEqualCLSID(clsid, CLSID_DXRAllocatorPresenter)) {
+ *ppAP = DNew CDXRAllocatorPresenter(hWnd, hr, Error);
+ } else if (IsEqualCLSID(clsid, CLSID_madVRAllocatorPresenter)) {
+ *ppAP = DNew CmadVRAllocatorPresenter(hWnd, hr, Error);
+ } else {
+ return E_FAIL;
+ }
- if ( *ppAP == NULL ) {
- return E_OUTOFMEMORY;
- }
+ if (*ppAP == NULL) {
+ return E_OUTOFMEMORY;
+ }
- (*ppAP)->AddRef();
+ (*ppAP)->AddRef();
- if ( FAILED(hr) ) {
- Error += L"\n";
- Error += GetWindowsErrorMessage(hr, NULL);
+ if (FAILED(hr)) {
+ Error += L"\n";
+ Error += GetWindowsErrorMessage(hr, NULL);
- MessageBox(hWnd, Error, L"Error creating DX9 allocation presenter", MB_OK | MB_ICONERROR);
- (*ppAP)->Release();
- *ppAP = NULL;
- }
- else if ( !Error.IsEmpty() ) {
- MessageBox(hWnd, Error, L"Warning creating DX9 allocation presenter", MB_OK | MB_ICONWARNING);
- }
+ MessageBox(hWnd, Error, L"Error creating DX9 allocation presenter", MB_OK | MB_ICONERROR);
+ (*ppAP)->Release();
+ *ppAP = NULL;
+ } else if (!Error.IsEmpty()) {
+ MessageBox(hWnd, Error, L"Warning creating DX9 allocation presenter", MB_OK | MB_ICONWARNING);
+ }
- return hr;
+ return hr;
}
HRESULT CreateEVR(const CLSID& clsid, HWND hWnd, bool bFullscreen, ISubPicAllocatorPresenter** ppAP)
{
- HRESULT hr = E_FAIL;
- if (clsid == CLSID_EVRAllocatorPresenter) {
- CString Error;
- *ppAP = DNew DSObjects::CEVRAllocatorPresenter(hWnd, bFullscreen, hr, Error);
- (*ppAP)->AddRef();
+ HRESULT hr = E_FAIL;
+ if (clsid == CLSID_EVRAllocatorPresenter) {
+ CString Error;
+ *ppAP = DNew DSObjects::CEVRAllocatorPresenter(hWnd, bFullscreen, hr, Error);
+ (*ppAP)->AddRef();
- if (FAILED(hr)) {
- Error += L"\n";
- Error += GetWindowsErrorMessage(hr, NULL);
- MessageBox(hWnd, Error, L"Error creating EVR Custom renderer", MB_OK | MB_ICONERROR);
- (*ppAP)->Release();
- *ppAP = NULL;
- } else if (!Error.IsEmpty()) {
- MessageBox(hWnd, Error, L"Warning creating EVR Custom renderer", MB_OK|MB_ICONWARNING);
- }
- }
+ if (FAILED(hr)) {
+ Error += L"\n";
+ Error += GetWindowsErrorMessage(hr, NULL);
+ MessageBox(hWnd, Error, L"Error creating EVR Custom renderer", MB_OK | MB_ICONERROR);
+ (*ppAP)->Release();
+ *ppAP = NULL;
+ } else if (!Error.IsEmpty()) {
+ MessageBox(hWnd, Error, L"Warning creating EVR Custom renderer", MB_OK | MB_ICONWARNING);
+ }
+ }
- return hr;
+ return hr;
}
CString GetWindowsErrorMessage(HRESULT _Error, HMODULE _Module)
{
- switch (_Error) {
- case D3DERR_WRONGTEXTUREFORMAT :
- return _T("D3DERR_WRONGTEXTUREFORMAT");
- case D3DERR_UNSUPPORTEDCOLOROPERATION :
- return _T("D3DERR_UNSUPPORTEDCOLOROPERATION");
- case D3DERR_UNSUPPORTEDCOLORARG :
- return _T("D3DERR_UNSUPPORTEDCOLORARG");
- case D3DERR_UNSUPPORTEDALPHAOPERATION :
- return _T("D3DERR_UNSUPPORTEDALPHAOPERATION");
- case D3DERR_UNSUPPORTEDALPHAARG :
- return _T("D3DERR_UNSUPPORTEDALPHAARG");
- case D3DERR_TOOMANYOPERATIONS :
- return _T("D3DERR_TOOMANYOPERATIONS");
- case D3DERR_CONFLICTINGTEXTUREFILTER :
- return _T("D3DERR_CONFLICTINGTEXTUREFILTER");
- case D3DERR_UNSUPPORTEDFACTORVALUE :
- return _T("D3DERR_UNSUPPORTEDFACTORVALUE");
- case D3DERR_CONFLICTINGRENDERSTATE :
- return _T("D3DERR_CONFLICTINGRENDERSTATE");
- case D3DERR_UNSUPPORTEDTEXTUREFILTER :
- return _T("D3DERR_UNSUPPORTEDTEXTUREFILTER");
- case D3DERR_CONFLICTINGTEXTUREPALETTE :
- return _T("D3DERR_CONFLICTINGTEXTUREPALETTE");
- case D3DERR_DRIVERINTERNALERROR :
- return _T("D3DERR_DRIVERINTERNALERROR");
- case D3DERR_NOTFOUND :
- return _T("D3DERR_NOTFOUND");
- case D3DERR_MOREDATA :
- return _T("D3DERR_MOREDATA");
- case D3DERR_DEVICELOST :
- return _T("D3DERR_DEVICELOST");
- case D3DERR_DEVICENOTRESET :
- return _T("D3DERR_DEVICENOTRESET");
- case D3DERR_NOTAVAILABLE :
- return _T("D3DERR_NOTAVAILABLE");
- case D3DERR_OUTOFVIDEOMEMORY :
- return _T("D3DERR_OUTOFVIDEOMEMORY");
- case D3DERR_INVALIDDEVICE :
- return _T("D3DERR_INVALIDDEVICE");
- case D3DERR_INVALIDCALL :
- return _T("D3DERR_INVALIDCALL");
- case D3DERR_DRIVERINVALIDCALL :
- return _T("D3DERR_DRIVERINVALIDCALL");
- case D3DERR_WASSTILLDRAWING :
- return _T("D3DERR_WASSTILLDRAWING");
- case D3DOK_NOAUTOGEN :
- return _T("D3DOK_NOAUTOGEN");
- case D3DERR_DEVICEREMOVED :
- return _T("D3DERR_DEVICEREMOVED");
- case S_NOT_RESIDENT :
- return _T("S_NOT_RESIDENT");
- case S_RESIDENT_IN_SHARED_MEMORY :
- return _T("S_RESIDENT_IN_SHARED_MEMORY");
- case S_PRESENT_MODE_CHANGED :
- return _T("S_PRESENT_MODE_CHANGED");
- case S_PRESENT_OCCLUDED :
- return _T("S_PRESENT_OCCLUDED");
- case D3DERR_DEVICEHUNG :
- return _T("D3DERR_DEVICEHUNG");
- case E_UNEXPECTED :
- return _T("E_UNEXPECTED");
- }
+ switch (_Error) {
+ case D3DERR_WRONGTEXTUREFORMAT :
+ return _T("D3DERR_WRONGTEXTUREFORMAT");
+ case D3DERR_UNSUPPORTEDCOLOROPERATION :
+ return _T("D3DERR_UNSUPPORTEDCOLOROPERATION");
+ case D3DERR_UNSUPPORTEDCOLORARG :
+ return _T("D3DERR_UNSUPPORTEDCOLORARG");
+ case D3DERR_UNSUPPORTEDALPHAOPERATION :
+ return _T("D3DERR_UNSUPPORTEDALPHAOPERATION");
+ case D3DERR_UNSUPPORTEDALPHAARG :
+ return _T("D3DERR_UNSUPPORTEDALPHAARG");
+ case D3DERR_TOOMANYOPERATIONS :
+ return _T("D3DERR_TOOMANYOPERATIONS");
+ case D3DERR_CONFLICTINGTEXTUREFILTER :
+ return _T("D3DERR_CONFLICTINGTEXTUREFILTER");
+ case D3DERR_UNSUPPORTEDFACTORVALUE :
+ return _T("D3DERR_UNSUPPORTEDFACTORVALUE");
+ case D3DERR_CONFLICTINGRENDERSTATE :
+ return _T("D3DERR_CONFLICTINGRENDERSTATE");
+ case D3DERR_UNSUPPORTEDTEXTUREFILTER :
+ return _T("D3DERR_UNSUPPORTEDTEXTUREFILTER");
+ case D3DERR_CONFLICTINGTEXTUREPALETTE :
+ return _T("D3DERR_CONFLICTINGTEXTUREPALETTE");
+ case D3DERR_DRIVERINTERNALERROR :
+ return _T("D3DERR_DRIVERINTERNALERROR");
+ case D3DERR_NOTFOUND :
+ return _T("D3DERR_NOTFOUND");
+ case D3DERR_MOREDATA :
+ return _T("D3DERR_MOREDATA");
+ case D3DERR_DEVICELOST :
+ return _T("D3DERR_DEVICELOST");
+ case D3DERR_DEVICENOTRESET :
+ return _T("D3DERR_DEVICENOTRESET");
+ case D3DERR_NOTAVAILABLE :
+ return _T("D3DERR_NOTAVAILABLE");
+ case D3DERR_OUTOFVIDEOMEMORY :
+ return _T("D3DERR_OUTOFVIDEOMEMORY");
+ case D3DERR_INVALIDDEVICE :
+ return _T("D3DERR_INVALIDDEVICE");
+ case D3DERR_INVALIDCALL :
+ return _T("D3DERR_INVALIDCALL");
+ case D3DERR_DRIVERINVALIDCALL :
+ return _T("D3DERR_DRIVERINVALIDCALL");
+ case D3DERR_WASSTILLDRAWING :
+ return _T("D3DERR_WASSTILLDRAWING");
+ case D3DOK_NOAUTOGEN :
+ return _T("D3DOK_NOAUTOGEN");
+ case D3DERR_DEVICEREMOVED :
+ return _T("D3DERR_DEVICEREMOVED");
+ case S_NOT_RESIDENT :
+ return _T("S_NOT_RESIDENT");
+ case S_RESIDENT_IN_SHARED_MEMORY :
+ return _T("S_RESIDENT_IN_SHARED_MEMORY");
+ case S_PRESENT_MODE_CHANGED :
+ return _T("S_PRESENT_MODE_CHANGED");
+ case S_PRESENT_OCCLUDED :
+ return _T("S_PRESENT_OCCLUDED");
+ case D3DERR_DEVICEHUNG :
+ return _T("D3DERR_DEVICEHUNG");
+ case E_UNEXPECTED :
+ return _T("E_UNEXPECTED");
+ }
- CString errmsg;
- LPVOID lpMsgBuf;
- if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_HMODULE,
- _Module, _Error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL)) {
- errmsg = (LPCTSTR)lpMsgBuf;
- LocalFree(lpMsgBuf);
- }
- CString Temp;
- Temp.Format(L"0x%08x ", _Error);
- return Temp + errmsg;
+ CString errmsg;
+ LPVOID lpMsgBuf;
+ if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_HMODULE,
+ _Module, _Error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL)) {
+ errmsg = (LPCTSTR)lpMsgBuf;
+ LocalFree(lpMsgBuf);
+ }
+ CString Temp;
+ Temp.Format(L"0x%08x ", _Error);
+ return Temp + errmsg;
}
-const wchar_t *GetD3DFormatStr(D3DFORMAT Format)
+const wchar_t* GetD3DFormatStr(D3DFORMAT Format)
{
- switch (Format) {
- case D3DFMT_R8G8B8 :
- return L"R8G8B8";
- case D3DFMT_A8R8G8B8 :
- return L"A8R8G8B8";
- case D3DFMT_X8R8G8B8 :
- return L"X8R8G8B8";
- case D3DFMT_R5G6B5 :
- return L"R5G6B5";
- case D3DFMT_X1R5G5B5 :
- return L"X1R5G5B5";
- case D3DFMT_A1R5G5B5 :
- return L"A1R5G5B5";
- case D3DFMT_A4R4G4B4 :
- return L"A4R4G4B4";
- case D3DFMT_R3G3B2 :
- return L"R3G3B2";
- case D3DFMT_A8 :
- return L"A8";
- case D3DFMT_A8R3G3B2 :
- return L"A8R3G3B2";
- case D3DFMT_X4R4G4B4 :
- return L"X4R4G4B4";
- case D3DFMT_A2B10G10R10:
- return L"A2B10G10R10";
- case D3DFMT_A8B8G8R8 :
- return L"A8B8G8R8";
- case D3DFMT_X8B8G8R8 :
- return L"X8B8G8R8";
- case D3DFMT_G16R16 :
- return L"G16R16";
- case D3DFMT_A2R10G10B10:
- return L"A2R10G10B10";
- case D3DFMT_A16B16G16R16 :
- return L"A16B16G16R16";
- case D3DFMT_A8P8 :
- return L"A8P8";
- case D3DFMT_P8 :
- return L"P8";
- case D3DFMT_L8 :
- return L"L8";
- case D3DFMT_A8L8 :
- return L"A8L8";
- case D3DFMT_A4L4 :
- return L"A4L4";
- case D3DFMT_V8U8 :
- return L"V8U8";
- case D3DFMT_L6V5U5 :
- return L"L6V5U5";
- case D3DFMT_X8L8V8U8 :
- return L"X8L8V8U8";
- case D3DFMT_Q8W8V8U8 :
- return L"Q8W8V8U8";
- case D3DFMT_V16U16 :
- return L"V16U16";
- case D3DFMT_A2W10V10U10:
- return L"A2W10V10U10";
- case D3DFMT_UYVY :
- return L"UYVY";
- case D3DFMT_R8G8_B8G8:
- return L"R8G8_B8G8";
- case D3DFMT_YUY2 :
- return L"YUY2";
- case D3DFMT_G8R8_G8B8:
- return L"G8R8_G8B8";
- case D3DFMT_DXT1 :
- return L"DXT1";
- case D3DFMT_DXT2 :
- return L"DXT2";
- case D3DFMT_DXT3 :
- return L"DXT3";
- case D3DFMT_DXT4 :
- return L"DXT4";
- case D3DFMT_DXT5 :
- return L"DXT5";
- case D3DFMT_D16_LOCKABLE :
- return L"D16_LOCKABLE";
- case D3DFMT_D32:
- return L"D32";
- case D3DFMT_D15S1:
- return L"D15S1";
- case D3DFMT_D24S8:
- return L"D24S8";
- case D3DFMT_D24X8:
- return L"D24X8";
- case D3DFMT_D24X4S4:
- return L"D24X4S4";
- case D3DFMT_D16:
- return L"D16";
- case D3DFMT_D32F_LOCKABLE:
- return L"D32F_LOCKABLE";
- case D3DFMT_D24FS8 :
- return L"D24FS8";
- case D3DFMT_D32_LOCKABLE :
- return L"D32_LOCKABLE";
- case D3DFMT_S8_LOCKABLE:
- return L"S8_LOCKABLE";
- case D3DFMT_L16:
- return L"L16";
- case D3DFMT_VERTEXDATA :
- return L"VERTEXDATA";
- case D3DFMT_INDEX16:
- return L"INDEX16";
- case D3DFMT_INDEX32:
- return L"INDEX32";
- case D3DFMT_Q16W16V16U16 :
- return L"Q16W16V16U16";
- case D3DFMT_MULTI2_ARGB8 :
- return L"MULTI2_ARGB8";
- case D3DFMT_R16F :
- return L"R16F";
- case D3DFMT_G16R16F:
- return L"G16R16F";
- case D3DFMT_A16B16G16R16F:
- return L"A16B16G16R16F";
- case D3DFMT_R32F :
- return L"R32F";
- case D3DFMT_G32R32F:
- return L"G32R32F";
- case D3DFMT_A32B32G32R32F:
- return L"A32B32G32R32F";
- case D3DFMT_CxV8U8 :
- return L"CxV8U8";
- case D3DFMT_A1 :
- return L"A1";
- case D3DFMT_BINARYBUFFER :
- return L"BINARYBUFFER";
- }
- return L"Unknown";
+ switch (Format) {
+ case D3DFMT_R8G8B8 :
+ return L"R8G8B8";
+ case D3DFMT_A8R8G8B8 :
+ return L"A8R8G8B8";
+ case D3DFMT_X8R8G8B8 :
+ return L"X8R8G8B8";
+ case D3DFMT_R5G6B5 :
+ return L"R5G6B5";
+ case D3DFMT_X1R5G5B5 :
+ return L"X1R5G5B5";
+ case D3DFMT_A1R5G5B5 :
+ return L"A1R5G5B5";
+ case D3DFMT_A4R4G4B4 :
+ return L"A4R4G4B4";
+ case D3DFMT_R3G3B2 :
+ return L"R3G3B2";
+ case D3DFMT_A8 :
+ return L"A8";
+ case D3DFMT_A8R3G3B2 :
+ return L"A8R3G3B2";
+ case D3DFMT_X4R4G4B4 :
+ return L"X4R4G4B4";
+ case D3DFMT_A2B10G10R10:
+ return L"A2B10G10R10";
+ case D3DFMT_A8B8G8R8 :
+ return L"A8B8G8R8";
+ case D3DFMT_X8B8G8R8 :
+ return L"X8B8G8R8";
+ case D3DFMT_G16R16 :
+ return L"G16R16";
+ case D3DFMT_A2R10G10B10:
+ return L"A2R10G10B10";
+ case D3DFMT_A16B16G16R16 :
+ return L"A16B16G16R16";
+ case D3DFMT_A8P8 :
+ return L"A8P8";
+ case D3DFMT_P8 :
+ return L"P8";
+ case D3DFMT_L8 :
+ return L"L8";
+ case D3DFMT_A8L8 :
+ return L"A8L8";
+ case D3DFMT_A4L4 :
+ return L"A4L4";
+ case D3DFMT_V8U8 :
+ return L"V8U8";
+ case D3DFMT_L6V5U5 :
+ return L"L6V5U5";
+ case D3DFMT_X8L8V8U8 :
+ return L"X8L8V8U8";
+ case D3DFMT_Q8W8V8U8 :
+ return L"Q8W8V8U8";
+ case D3DFMT_V16U16 :
+ return L"V16U16";
+ case D3DFMT_A2W10V10U10:
+ return L"A2W10V10U10";
+ case D3DFMT_UYVY :
+ return L"UYVY";
+ case D3DFMT_R8G8_B8G8:
+ return L"R8G8_B8G8";
+ case D3DFMT_YUY2 :
+ return L"YUY2";
+ case D3DFMT_G8R8_G8B8:
+ return L"G8R8_G8B8";
+ case D3DFMT_DXT1 :
+ return L"DXT1";
+ case D3DFMT_DXT2 :
+ return L"DXT2";
+ case D3DFMT_DXT3 :
+ return L"DXT3";
+ case D3DFMT_DXT4 :
+ return L"DXT4";
+ case D3DFMT_DXT5 :
+ return L"DXT5";
+ case D3DFMT_D16_LOCKABLE :
+ return L"D16_LOCKABLE";
+ case D3DFMT_D32:
+ return L"D32";
+ case D3DFMT_D15S1:
+ return L"D15S1";
+ case D3DFMT_D24S8:
+ return L"D24S8";
+ case D3DFMT_D24X8:
+ return L"D24X8";
+ case D3DFMT_D24X4S4:
+ return L"D24X4S4";
+ case D3DFMT_D16:
+ return L"D16";
+ case D3DFMT_D32F_LOCKABLE:
+ return L"D32F_LOCKABLE";
+ case D3DFMT_D24FS8 :
+ return L"D24FS8";
+ case D3DFMT_D32_LOCKABLE :
+ return L"D32_LOCKABLE";
+ case D3DFMT_S8_LOCKABLE:
+ return L"S8_LOCKABLE";
+ case D3DFMT_L16:
+ return L"L16";
+ case D3DFMT_VERTEXDATA :
+ return L"VERTEXDATA";
+ case D3DFMT_INDEX16:
+ return L"INDEX16";
+ case D3DFMT_INDEX32:
+ return L"INDEX32";
+ case D3DFMT_Q16W16V16U16 :
+ return L"Q16W16V16U16";
+ case D3DFMT_MULTI2_ARGB8 :
+ return L"MULTI2_ARGB8";
+ case D3DFMT_R16F :
+ return L"R16F";
+ case D3DFMT_G16R16F:
+ return L"G16R16F";
+ case D3DFMT_A16B16G16R16F:
+ return L"A16B16G16R16F";
+ case D3DFMT_R32F :
+ return L"R32F";
+ case D3DFMT_G32R32F:
+ return L"G32R32F";
+ case D3DFMT_A32B32G32R32F:
+ return L"A32B32G32R32F";
+ case D3DFMT_CxV8U8 :
+ return L"CxV8U8";
+ case D3DFMT_A1 :
+ return L"A1";
+ case D3DFMT_BINARYBUFFER :
+ return L"BINARYBUFFER";
+ }
+ return L"Unknown";
}
diff --git a/src/filters/renderer/VideoRenderers/AllocatorCommon.h b/src/filters/renderer/VideoRenderers/AllocatorCommon.h
index 0257f7072..a93d0e8df 100644
--- a/src/filters/renderer/VideoRenderers/AllocatorCommon.h
+++ b/src/filters/renderer/VideoRenderers/AllocatorCommon.h
@@ -31,33 +31,33 @@
// {4E4834FA-22C2-40e2-9446-F77DD05D245E}
DEFINE_GUID(CLSID_VMR9AllocatorPresenter,
- 0x4e4834fa, 0x22c2, 0x40e2, 0x94, 0x46, 0xf7, 0x7d, 0xd0, 0x5d, 0x24, 0x5e);
+ 0x4e4834fa, 0x22c2, 0x40e2, 0x94, 0x46, 0xf7, 0x7d, 0xd0, 0x5d, 0x24, 0x5e);
// {A1542F93-EB53-4e11-8D34-05C57ABA9207}
DEFINE_GUID(CLSID_RM9AllocatorPresenter,
- 0xa1542f93, 0xeb53, 0x4e11, 0x8d, 0x34, 0x5, 0xc5, 0x7a, 0xba, 0x92, 0x7);
+ 0xa1542f93, 0xeb53, 0x4e11, 0x8d, 0x34, 0x5, 0xc5, 0x7a, 0xba, 0x92, 0x7);
// {622A4032-70CE-4040-8231-0F24F2886618}
DEFINE_GUID(CLSID_QT9AllocatorPresenter,
- 0x622a4032, 0x70ce, 0x4040, 0x82, 0x31, 0xf, 0x24, 0xf2, 0x88, 0x66, 0x18);
+ 0x622a4032, 0x70ce, 0x4040, 0x82, 0x31, 0xf, 0x24, 0xf2, 0x88, 0x66, 0x18);
// {B72EBDD4-831D-440f-A656-B48F5486CD82}
DEFINE_GUID(CLSID_DXRAllocatorPresenter,
- 0xb72ebdd4, 0x831d, 0x440f, 0xa6, 0x56, 0xb4, 0x8f, 0x54, 0x86, 0xcd, 0x82);
+ 0xb72ebdd4, 0x831d, 0x440f, 0xa6, 0x56, 0xb4, 0x8f, 0x54, 0x86, 0xcd, 0x82);
// {C7ED3100-9002-4595-9DCA-B30B30413429}
DEFINE_GUID(CLSID_madVRAllocatorPresenter,
- 0xc7ed3100, 0x9002, 0x4595, 0x9d, 0xca, 0xb3, 0xb, 0x30, 0x41, 0x34, 0x29);
+ 0xc7ed3100, 0x9002, 0x4595, 0x9d, 0xca, 0xb3, 0xb, 0x30, 0x41, 0x34, 0x29);
DEFINE_GUID(CLSID_EVRAllocatorPresenter,
- 0x7612b889, 0xe070, 0x4bcc, 0xb8, 0x8, 0x91, 0xcb, 0x79, 0x41, 0x74, 0xab);
+ 0x7612b889, 0xe070, 0x4bcc, 0xb8, 0x8, 0x91, 0xcb, 0x79, 0x41, 0x74, 0xab);
extern CCritSec g_ffdshowReceive;
extern bool queue_ffdshow_support;
extern bool IsVMR9InGraph(IFilterGraph* pFG);
extern CString GetWindowsErrorMessage(HRESULT _Error, HMODULE _Module);
-extern const wchar_t *GetD3DFormatStr(D3DFORMAT Format);
+extern const wchar_t* GetD3DFormatStr(D3DFORMAT Format);
extern HRESULT CreateAP9(const CLSID& clsid, HWND hWnd, bool bFullscreen, ISubPicAllocatorPresenter** ppAP);
extern HRESULT CreateEVR(const CLSID& clsid, HWND hWnd, bool bFullscreen, ISubPicAllocatorPresenter** ppAP);
@@ -66,11 +66,11 @@ extern HRESULT CreateEVR(const CLSID& clsid, HWND hWnd, bool bFullscreen, ISubPi
// This interface is used to check version of Media Player Classic.
// {A273C7F6-25D4-46b0-B2C8-4F7FADC44E37}
DEFINE_GUID(IID_IVMRffdshow9,
- 0xa273c7f6, 0x25d4, 0x46b0, 0xb2, 0xc8, 0x4f, 0x7f, 0xad, 0xc4, 0x4e, 0x37);
+ 0xa273c7f6, 0x25d4, 0x46b0, 0xb2, 0xc8, 0x4f, 0x7f, 0xad, 0xc4, 0x4e, 0x37);
MIDL_INTERFACE("A273C7F6-25D4-46b0-B2C8-4F7FADC44E37")
IVMRffdshow9 :
public IUnknown {
public:
- virtual STDMETHODIMP support_ffdshow(void) = 0;
+ virtual STDMETHODIMP support_ffdshow(void) = 0;
};
diff --git a/src/filters/renderer/VideoRenderers/AllocatorCommon7.cpp b/src/filters/renderer/VideoRenderers/AllocatorCommon7.cpp
index 2b54dc10f..6cb275993 100644
--- a/src/filters/renderer/VideoRenderers/AllocatorCommon7.cpp
+++ b/src/filters/renderer/VideoRenderers/AllocatorCommon7.cpp
@@ -34,12 +34,12 @@
bool IsVMR7InGraph(IFilterGraph* pFG)
{
- BeginEnumFilters(pFG, pEF, pBF)
- if (CComQIPtr<IVMRWindowlessControl>(pBF)) {
- return true;
- }
- EndEnumFilters
- return false;
+ BeginEnumFilters(pFG, pEF, pBF)
+ if (CComQIPtr<IVMRWindowlessControl>(pBF)) {
+ return true;
+ }
+ EndEnumFilters
+ return false;
}
using namespace DSObjects;
@@ -48,35 +48,32 @@ using namespace DSObjects;
HRESULT CreateAP7(const CLSID& clsid, HWND hWnd, ISubPicAllocatorPresenter** ppAP)
{
- CheckPointer(ppAP, E_POINTER);
+ CheckPointer(ppAP, E_POINTER);
- *ppAP = NULL;
+ *ppAP = NULL;
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- if ( IsEqualCLSID(clsid, CLSID_VMR7AllocatorPresenter) ) {
- *ppAP = DNew CVMR7AllocatorPresenter(hWnd, hr);
- }
- else if ( IsEqualCLSID(clsid, CLSID_RM7AllocatorPresenter) ) {
- *ppAP = DNew CRM7AllocatorPresenter(hWnd, hr);
- }
- else if ( IsEqualCLSID(clsid, CLSID_QT7AllocatorPresenter) ) {
- *ppAP = DNew CQT7AllocatorPresenter(hWnd, hr);
- }
- else {
- return E_FAIL;
- }
+ if (IsEqualCLSID(clsid, CLSID_VMR7AllocatorPresenter)) {
+ *ppAP = DNew CVMR7AllocatorPresenter(hWnd, hr);
+ } else if (IsEqualCLSID(clsid, CLSID_RM7AllocatorPresenter)) {
+ *ppAP = DNew CRM7AllocatorPresenter(hWnd, hr);
+ } else if (IsEqualCLSID(clsid, CLSID_QT7AllocatorPresenter)) {
+ *ppAP = DNew CQT7AllocatorPresenter(hWnd, hr);
+ } else {
+ return E_FAIL;
+ }
- if ( *ppAP == NULL ) {
- return E_OUTOFMEMORY;
- }
+ if (*ppAP == NULL) {
+ return E_OUTOFMEMORY;
+ }
- (*ppAP)->AddRef();
+ (*ppAP)->AddRef();
- if (FAILED(hr)) {
- (*ppAP)->Release();
- *ppAP = NULL;
- }
+ if (FAILED(hr)) {
+ (*ppAP)->Release();
+ *ppAP = NULL;
+ }
- return hr;
+ return hr;
}
diff --git a/src/filters/renderer/VideoRenderers/AllocatorCommon7.h b/src/filters/renderer/VideoRenderers/AllocatorCommon7.h
index 40c9d4ee6..f8528f6a5 100644
--- a/src/filters/renderer/VideoRenderers/AllocatorCommon7.h
+++ b/src/filters/renderer/VideoRenderers/AllocatorCommon7.h
@@ -28,15 +28,15 @@
// {495CF191-810D-44c7-92C5-E7D46AE00F44}
DEFINE_GUID(CLSID_VMR7AllocatorPresenter,
- 0x495cf191, 0x810d, 0x44c7, 0x92, 0xc5, 0xe7, 0xd4, 0x6a, 0xe0, 0xf, 0x44);
+ 0x495cf191, 0x810d, 0x44c7, 0x92, 0xc5, 0xe7, 0xd4, 0x6a, 0xe0, 0xf, 0x44);
// {97B3462E-1752-4dfb-A038-271060BC7A94}
DEFINE_GUID(CLSID_RM7AllocatorPresenter,
- 0x97b3462e, 0x1752, 0x4dfb, 0xa0, 0x38, 0x27, 0x10, 0x60, 0xbc, 0x7a, 0x94);
+ 0x97b3462e, 0x1752, 0x4dfb, 0xa0, 0x38, 0x27, 0x10, 0x60, 0xbc, 0x7a, 0x94);
// {36CC5A71-441C-462a-9D10-48A19485938D}
DEFINE_GUID(CLSID_QT7AllocatorPresenter,
- 0x36cc5a71, 0x441c, 0x462a, 0x9d, 0x10, 0x48, 0xa1, 0x94, 0x85, 0x93, 0x8d);
+ 0x36cc5a71, 0x441c, 0x462a, 0x9d, 0x10, 0x48, 0xa1, 0x94, 0x85, 0x93, 0x8d);
extern HRESULT CreateAP7(const CLSID& clsid, HWND hWnd, ISubPicAllocatorPresenter** ppAP);
diff --git a/src/filters/renderer/VideoRenderers/D3DFont.cpp b/src/filters/renderer/VideoRenderers/D3DFont.cpp
index c4410557b..5e261d684 100644
--- a/src/filters/renderer/VideoRenderers/D3DFont.cpp
+++ b/src/filters/renderer/VideoRenderers/D3DFont.cpp
@@ -34,40 +34,40 @@
#define MAX_NUM_VERTICES 50*6
struct FONT2DVERTEX {
- D3DXVECTOR4 p;
- DWORD color;
- FLOAT tu, tv;
+ D3DXVECTOR4 p;
+ DWORD color;
+ FLOAT tu, tv;
};
struct FONT3DVERTEX {
- D3DXVECTOR3 p;
- D3DXVECTOR3 n;
- FLOAT tu, tv;
+ D3DXVECTOR3 p;
+ D3DXVECTOR3 n;
+ FLOAT tu, tv;
};
#define D3DFVF_FONT2DVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE|D3DFVF_TEX1)
#define D3DFVF_FONT3DVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1)
-inline FONT2DVERTEX InitFont2DVertex( const D3DXVECTOR4& p, D3DCOLOR color,
- FLOAT tu, FLOAT tv )
+inline FONT2DVERTEX InitFont2DVertex(const D3DXVECTOR4& p, D3DCOLOR color,
+ FLOAT tu, FLOAT tv)
{
- FONT2DVERTEX v;
- v.p = p;
- v.color = color;
- v.tu = tu;
- v.tv = tv;
- return v;
+ FONT2DVERTEX v;
+ v.p = p;
+ v.color = color;
+ v.tu = tu;
+ v.tv = tv;
+ return v;
}
-inline FONT3DVERTEX InitFont3DVertex( const D3DXVECTOR3& p, const D3DXVECTOR3& n,
- FLOAT tu, FLOAT tv )
+inline FONT3DVERTEX InitFont3DVertex(const D3DXVECTOR3& p, const D3DXVECTOR3& n,
+ FLOAT tu, FLOAT tv)
{
- FONT3DVERTEX v;
- v.p = p;
- v.n = n;
- v.tu = tu;
- v.tv = tv;
- return v;
+ FONT3DVERTEX v;
+ v.p = p;
+ v.n = n;
+ v.tu = tu;
+ v.tv = tv;
+ return v;
}
@@ -76,20 +76,20 @@ inline FONT3DVERTEX InitFont3DVertex( const D3DXVECTOR3& p, const D3DXVECTOR3& n
// Name: CD3DFont()
// Desc: Font class constructor
//-----------------------------------------------------------------------------
-CD3DFont::CD3DFont( const TCHAR* strFontName, DWORD dwHeight, DWORD dwFlags )
+CD3DFont::CD3DFont(const TCHAR* strFontName, DWORD dwHeight, DWORD dwFlags)
{
- _tcsncpy_s( m_strFontName, strFontName, _countof(m_strFontName) );
- m_strFontName[_countof(m_strFontName) - 1] = _T('\0');
- m_dwFontHeight = dwHeight;
- m_dwFontFlags = dwFlags;
- m_dwSpacing = 0;
-
- m_pd3dDevice = NULL;
- m_pTexture = NULL;
- m_pVB = NULL;
-
- m_pStateBlockSaved = NULL;
- m_pStateBlockDrawText = NULL;
+ _tcsncpy_s(m_strFontName, strFontName, _countof(m_strFontName));
+ m_strFontName[_countof(m_strFontName) - 1] = _T('\0');
+ m_dwFontHeight = dwHeight;
+ m_dwFontFlags = dwFlags;
+ m_dwSpacing = 0;
+
+ m_pd3dDevice = NULL;
+ m_pTexture = NULL;
+ m_pVB = NULL;
+
+ m_pStateBlockSaved = NULL;
+ m_pStateBlockDrawText = NULL;
}
@@ -100,8 +100,8 @@ CD3DFont::CD3DFont( const TCHAR* strFontName, DWORD dwHeight, DWORD dwFlags )
//-----------------------------------------------------------------------------
CD3DFont::~CD3DFont()
{
- InvalidateDeviceObjects();
- DeleteDeviceObjects();
+ InvalidateDeviceObjects();
+ DeleteDeviceObjects();
}
@@ -111,25 +111,25 @@ CD3DFont::~CD3DFont()
// Desc: Create a font based on the current state of related member variables
// and return the handle (or null on error)
//-----------------------------------------------------------------------------
-HRESULT CD3DFont::CreateGDIFont( HDC hDC, HFONT* pFont )
+HRESULT CD3DFont::CreateGDIFont(HDC hDC, HFONT* pFont)
{
- // Create a font. By specifying ANTIALIASED_QUALITY, we might get an
- // antialiased font, but this is not guaranteed.
- INT nHeight = -MulDiv( m_dwFontHeight,
- (INT)(GetDeviceCaps(hDC, LOGPIXELSY) * m_fTextScale),
- 72 );
- DWORD dwBold = (m_dwFontFlags & D3DFONT_BOLD) ? FW_BOLD : FW_NORMAL;
- DWORD dwItalic = (m_dwFontFlags & D3DFONT_ITALIC) ? TRUE : FALSE;
- *pFont = CreateFont( nHeight, 0, 0, 0, dwBold, dwItalic,
- FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
- CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
- VARIABLE_PITCH, m_strFontName );
-
- if ( *pFont == NULL ) {
- return E_FAIL;
- }
-
- return S_OK;
+ // Create a font. By specifying ANTIALIASED_QUALITY, we might get an
+ // antialiased font, but this is not guaranteed.
+ INT nHeight = -MulDiv(m_dwFontHeight,
+ (INT)(GetDeviceCaps(hDC, LOGPIXELSY) * m_fTextScale),
+ 72);
+ DWORD dwBold = (m_dwFontFlags & D3DFONT_BOLD) ? FW_BOLD : FW_NORMAL;
+ DWORD dwItalic = (m_dwFontFlags & D3DFONT_ITALIC) ? TRUE : FALSE;
+ *pFont = CreateFont(nHeight, 0, 0, 0, dwBold, dwItalic,
+ FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
+ CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
+ VARIABLE_PITCH, m_strFontName);
+
+ if (*pFont == NULL) {
+ return E_FAIL;
+ }
+
+ return S_OK;
}
@@ -140,54 +140,54 @@ HRESULT CD3DFont::CreateGDIFont( HDC hDC, HFONT* pFont )
// provided device context. If the bMeasureOnly flag is set, no drawing
// will occur.
//-----------------------------------------------------------------------------
-HRESULT CD3DFont::PaintAlphabet( HDC hDC, BOOL bMeasureOnly )
+HRESULT CD3DFont::PaintAlphabet(HDC hDC, BOOL bMeasureOnly)
{
- SIZE size;
- TCHAR str[2] = _T("x"); // One-character, null-terminated string
-
- // Calculate the spacing between characters based on line height
- if ( 0 == GetTextExtentPoint32( hDC, str, 1, &size ) ) {
- return E_FAIL;
- }
- m_dwSpacing = (DWORD) ceil(size.cy * 0.3f);
-
- // Set the starting point for the drawing
- DWORD x = m_dwSpacing;
- DWORD y = 0;
-
- // For each character, draw text on the DC and advance the current position
- for ( char c = 32; c < 127; c++ ) {
- str[0] = c;
- if ( 0 == GetTextExtentPoint32( hDC, str, 1, &size ) ) {
- return E_FAIL;
- }
-
- if ( (DWORD)(x + size.cx + m_dwSpacing) > m_dwTexWidth ) {
- x = m_dwSpacing;
- y += size.cy + 1;
- }
-
- // Check to see if there's room to write the character here
- if ( y + size.cy > m_dwTexHeight ) {
- return D3DERR_MOREDATA;
- }
-
- if ( !bMeasureOnly ) {
- // Perform the actual drawing
- if ( 0 == ExtTextOut( hDC, x+0, y+0, ETO_OPAQUE, NULL, str, 1, NULL ) ) {
- return E_FAIL;
- }
-
- m_fTexCoords[c-32][0] = ((FLOAT)(x + 0 - m_dwSpacing))/m_dwTexWidth;
- m_fTexCoords[c-32][1] = ((FLOAT)(y + 0 + 0 ))/m_dwTexHeight;
- m_fTexCoords[c-32][2] = ((FLOAT)(x + size.cx + m_dwSpacing))/m_dwTexWidth;
- m_fTexCoords[c-32][3] = ((FLOAT)(y + size.cy + 0 ))/m_dwTexHeight;
- }
-
- x += size.cx + (2 * m_dwSpacing);
- }
-
- return S_OK;
+ SIZE size;
+ TCHAR str[2] = _T("x"); // One-character, null-terminated string
+
+ // Calculate the spacing between characters based on line height
+ if (0 == GetTextExtentPoint32(hDC, str, 1, &size)) {
+ return E_FAIL;
+ }
+ m_dwSpacing = (DWORD) ceil(size.cy * 0.3f);
+
+ // Set the starting point for the drawing
+ DWORD x = m_dwSpacing;
+ DWORD y = 0;
+
+ // For each character, draw text on the DC and advance the current position
+ for (char c = 32; c < 127; c++) {
+ str[0] = c;
+ if (0 == GetTextExtentPoint32(hDC, str, 1, &size)) {
+ return E_FAIL;
+ }
+
+ if ((DWORD)(x + size.cx + m_dwSpacing) > m_dwTexWidth) {
+ x = m_dwSpacing;
+ y += size.cy + 1;
+ }
+
+ // Check to see if there's room to write the character here
+ if (y + size.cy > m_dwTexHeight) {
+ return D3DERR_MOREDATA;
+ }
+
+ if (!bMeasureOnly) {
+ // Perform the actual drawing
+ if (0 == ExtTextOut(hDC, x + 0, y + 0, ETO_OPAQUE, NULL, str, 1, NULL)) {
+ return E_FAIL;
+ }
+
+ m_fTexCoords[c - 32][0] = ((FLOAT)(x + 0 - m_dwSpacing)) / m_dwTexWidth;
+ m_fTexCoords[c - 32][1] = ((FLOAT)(y + 0 + 0)) / m_dwTexHeight;
+ m_fTexCoords[c - 32][2] = ((FLOAT)(x + size.cx + m_dwSpacing)) / m_dwTexWidth;
+ m_fTexCoords[c - 32][3] = ((FLOAT)(y + size.cy + 0)) / m_dwTexHeight;
+ }
+
+ x += size.cx + (2 * m_dwSpacing);
+ }
+
+ return S_OK;
}
@@ -197,151 +197,151 @@ HRESULT CD3DFont::PaintAlphabet( HDC hDC, BOOL bMeasureOnly )
// Desc: Initializes device-dependent objects, including the vertex buffer used
// for rendering text and the texture map which stores the font image.
//-----------------------------------------------------------------------------
-HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE9 pd3dDevice )
+HRESULT CD3DFont::InitDeviceObjects(LPDIRECT3DDEVICE9 pd3dDevice)
{
- HRESULT hr = S_OK;
- HFONT hFont = NULL;
- HFONT hFontOld = NULL;
- HDC hDC = NULL;
- HBITMAP hbmBitmap = NULL;
- HGDIOBJ hbmOld = NULL;
-
- // Keep a local copy of the device
- m_pd3dDevice = pd3dDevice;
-
- // Assume we will draw fonts into texture without scaling unless the
- // required texture size is found to be larger than the device max
- m_fTextScale = 1.0f;
-
- hDC = CreateCompatibleDC( NULL );
- SetMapMode( hDC, MM_TEXT );
-
- hr = CreateGDIFont( hDC, &hFont );
- if ( FAILED(hr) ) {
- goto LCleanReturn;
- }
-
- hFontOld = (HFONT) SelectObject( hDC, hFont );
-
- // Calculate the dimensions for the smallest power-of-two texture which
- // can hold all the printable characters
- m_dwTexWidth = m_dwTexHeight = 128;
- while ( D3DERR_MOREDATA == ( hr = PaintAlphabet( hDC, true ) ) ) {
- m_dwTexWidth *= 2;
- m_dwTexHeight *= 2;
- }
-
- if ( FAILED(hr) ) {
- goto LCleanReturn;
- }
-
- // If requested texture is too big, use a smaller texture and smaller font,
- // and scale up when rendering.
- D3DCAPS9 d3dCaps;
- m_pd3dDevice->GetDeviceCaps( &d3dCaps );
-
- if ( m_dwTexWidth > d3dCaps.MaxTextureWidth ) {
- m_fTextScale = (FLOAT)d3dCaps.MaxTextureWidth / (FLOAT)m_dwTexWidth;
- m_dwTexWidth = m_dwTexHeight = d3dCaps.MaxTextureWidth;
-
- bool bFirstRun = true; // Flag clear after first run
-
- do {
- // If we've already tried fitting the new text, the scale is still
- // too large. Reduce and try again.
- if ( !bFirstRun) {
- m_fTextScale *= 0.9f;
- }
-
- // The font has to be scaled to fit on the maximum texture size; our
- // current font is too big and needs to be recreated to scale.
- DeleteObject( SelectObject( hDC, hFontOld ) );
-
- hr = CreateGDIFont( hDC, &hFont );
- if ( FAILED(hr) ) {
- goto LCleanReturn;
- }
-
- hFontOld = (HFONT) SelectObject( hDC, hFont );
-
- bFirstRun = false;
- } while ( D3DERR_MOREDATA == ( hr = PaintAlphabet( hDC, true ) ) );
- }
-
-
- // Create a new texture for the font
- hr = m_pd3dDevice->CreateTexture( m_dwTexWidth, m_dwTexHeight, 1,
- 0, D3DFMT_A4R4G4B4,
- D3DPOOL_MANAGED, &m_pTexture, NULL );
- if ( FAILED(hr) ) {
- goto LCleanReturn;
- }
-
- // Prepare to create a bitmap
- DWORD* pBitmapBits;
- BITMAPINFO bmi;
- ZeroMemory( &bmi.bmiHeader, sizeof(BITMAPINFOHEADER) );
- bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bmi.bmiHeader.biWidth = (int)m_dwTexWidth;
- bmi.bmiHeader.biHeight = -(int)m_dwTexHeight;
- bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biCompression = BI_RGB;
- bmi.bmiHeader.biBitCount = 32;
-
- // Create a bitmap for the font
- hbmBitmap = CreateDIBSection( hDC, &bmi, DIB_RGB_COLORS,
- (void**)&pBitmapBits, NULL, 0 );
-
- hbmOld = SelectObject( hDC, hbmBitmap );
-
- // Set text properties
- SetTextColor( hDC, RGB(255,255,255) );
- SetBkColor( hDC, 0x00000000 );
- SetTextAlign( hDC, TA_TOP );
-
- // Paint the alphabet onto the selected bitmap
- hr = PaintAlphabet( hDC, false );
- if ( FAILED(hr) ) {
- goto LCleanReturn;
- }
-
- // Lock the surface and write the alpha values for the set pixels
- D3DLOCKED_RECT d3dlr;
- m_pTexture->LockRect( 0, &d3dlr, 0, 0 );
- BYTE* pDstRow;
- pDstRow = (BYTE*)d3dlr.pBits;
- WORD* pDst16;
- BYTE bAlpha; // 4-bit measure of pixel intensity
- DWORD x, y;
-
- for ( y=0; y < m_dwTexHeight; y++ ) {
- pDst16 = (WORD*)pDstRow;
- for ( x=0; x < m_dwTexWidth; x++ ) {
- bAlpha = (BYTE)((pBitmapBits[m_dwTexWidth*y + x] & 0xff) >> 4);
- if (bAlpha > 0) {
- *pDst16++ = (WORD) ((bAlpha << 12) | 0x0fff);
- } else {
- *pDst16++ = 0x0000;
- }
- }
- pDstRow += d3dlr.Pitch;
- }
-
- hr = S_OK;
-
- // Done updating texture, so clean up used objects
+ HRESULT hr = S_OK;
+ HFONT hFont = NULL;
+ HFONT hFontOld = NULL;
+ HDC hDC = NULL;
+ HBITMAP hbmBitmap = NULL;
+ HGDIOBJ hbmOld = NULL;
+
+ // Keep a local copy of the device
+ m_pd3dDevice = pd3dDevice;
+
+ // Assume we will draw fonts into texture without scaling unless the
+ // required texture size is found to be larger than the device max
+ m_fTextScale = 1.0f;
+
+ hDC = CreateCompatibleDC(NULL);
+ SetMapMode(hDC, MM_TEXT);
+
+ hr = CreateGDIFont(hDC, &hFont);
+ if (FAILED(hr)) {
+ goto LCleanReturn;
+ }
+
+ hFontOld = (HFONT) SelectObject(hDC, hFont);
+
+ // Calculate the dimensions for the smallest power-of-two texture which
+ // can hold all the printable characters
+ m_dwTexWidth = m_dwTexHeight = 128;
+ while (D3DERR_MOREDATA == (hr = PaintAlphabet(hDC, true))) {
+ m_dwTexWidth *= 2;
+ m_dwTexHeight *= 2;
+ }
+
+ if (FAILED(hr)) {
+ goto LCleanReturn;
+ }
+
+ // If requested texture is too big, use a smaller texture and smaller font,
+ // and scale up when rendering.
+ D3DCAPS9 d3dCaps;
+ m_pd3dDevice->GetDeviceCaps(&d3dCaps);
+
+ if (m_dwTexWidth > d3dCaps.MaxTextureWidth) {
+ m_fTextScale = (FLOAT)d3dCaps.MaxTextureWidth / (FLOAT)m_dwTexWidth;
+ m_dwTexWidth = m_dwTexHeight = d3dCaps.MaxTextureWidth;
+
+ bool bFirstRun = true; // Flag clear after first run
+
+ do {
+ // If we've already tried fitting the new text, the scale is still
+ // too large. Reduce and try again.
+ if (!bFirstRun) {
+ m_fTextScale *= 0.9f;
+ }
+
+ // The font has to be scaled to fit on the maximum texture size; our
+ // current font is too big and needs to be recreated to scale.
+ DeleteObject(SelectObject(hDC, hFontOld));
+
+ hr = CreateGDIFont(hDC, &hFont);
+ if (FAILED(hr)) {
+ goto LCleanReturn;
+ }
+
+ hFontOld = (HFONT) SelectObject(hDC, hFont);
+
+ bFirstRun = false;
+ } while (D3DERR_MOREDATA == (hr = PaintAlphabet(hDC, true)));
+ }
+
+
+ // Create a new texture for the font
+ hr = m_pd3dDevice->CreateTexture(m_dwTexWidth, m_dwTexHeight, 1,
+ 0, D3DFMT_A4R4G4B4,
+ D3DPOOL_MANAGED, &m_pTexture, NULL);
+ if (FAILED(hr)) {
+ goto LCleanReturn;
+ }
+
+ // Prepare to create a bitmap
+ DWORD* pBitmapBits;
+ BITMAPINFO bmi;
+ ZeroMemory(&bmi.bmiHeader, sizeof(BITMAPINFOHEADER));
+ bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ bmi.bmiHeader.biWidth = (int)m_dwTexWidth;
+ bmi.bmiHeader.biHeight = -(int)m_dwTexHeight;
+ bmi.bmiHeader.biPlanes = 1;
+ bmi.bmiHeader.biCompression = BI_RGB;
+ bmi.bmiHeader.biBitCount = 32;
+
+ // Create a bitmap for the font
+ hbmBitmap = CreateDIBSection(hDC, &bmi, DIB_RGB_COLORS,
+ (void**)&pBitmapBits, NULL, 0);
+
+ hbmOld = SelectObject(hDC, hbmBitmap);
+
+ // Set text properties
+ SetTextColor(hDC, RGB(255, 255, 255));
+ SetBkColor(hDC, 0x00000000);
+ SetTextAlign(hDC, TA_TOP);
+
+ // Paint the alphabet onto the selected bitmap
+ hr = PaintAlphabet(hDC, false);
+ if (FAILED(hr)) {
+ goto LCleanReturn;
+ }
+
+ // Lock the surface and write the alpha values for the set pixels
+ D3DLOCKED_RECT d3dlr;
+ m_pTexture->LockRect(0, &d3dlr, 0, 0);
+ BYTE* pDstRow;
+ pDstRow = (BYTE*)d3dlr.pBits;
+ WORD* pDst16;
+ BYTE bAlpha; // 4-bit measure of pixel intensity
+ DWORD x, y;
+
+ for (y = 0; y < m_dwTexHeight; y++) {
+ pDst16 = (WORD*)pDstRow;
+ for (x = 0; x < m_dwTexWidth; x++) {
+ bAlpha = (BYTE)((pBitmapBits[m_dwTexWidth * y + x] & 0xff) >> 4);
+ if (bAlpha > 0) {
+ *pDst16++ = (WORD)((bAlpha << 12) | 0x0fff);
+ } else {
+ *pDst16++ = 0x0000;
+ }
+ }
+ pDstRow += d3dlr.Pitch;
+ }
+
+ hr = S_OK;
+
+ // Done updating texture, so clean up used objects
LCleanReturn:
- if ( m_pTexture ) {
- m_pTexture->UnlockRect(0);
- }
+ if (m_pTexture) {
+ m_pTexture->UnlockRect(0);
+ }
- SelectObject( hDC, hbmOld );
- SelectObject( hDC, hFontOld );
- DeleteObject( hbmBitmap );
- DeleteObject( hFont );
- DeleteDC( hDC );
+ SelectObject(hDC, hbmOld);
+ SelectObject(hDC, hFontOld);
+ DeleteObject(hbmBitmap);
+ DeleteObject(hFont);
+ DeleteDC(hDC);
- return hr;
+ return hr;
}
@@ -352,91 +352,91 @@ LCleanReturn:
//-----------------------------------------------------------------------------
HRESULT CD3DFont::RestoreDeviceObjects()
{
- HRESULT hr;
-
- // Create vertex buffer for the letters
- int vertexSize = max( sizeof(FONT2DVERTEX), sizeof(FONT3DVERTEX ) );
- if ( FAILED( hr = m_pd3dDevice->CreateVertexBuffer( MAX_NUM_VERTICES * vertexSize,
- D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, 0,
- D3DPOOL_DEFAULT, &m_pVB, NULL ) ) ) {
- return hr;
- }
-
- bool bSupportsAlphaBlend = true;
- LPDIRECT3D9 pd3d9 = NULL;
- if ( SUCCEEDED( m_pd3dDevice->GetDirect3D( &pd3d9 ) ) ) {
- D3DCAPS9 Caps;
- D3DDISPLAYMODE Mode;
- LPDIRECT3DSURFACE9 pSurf = NULL;
- D3DSURFACE_DESC Desc;
- m_pd3dDevice->GetDeviceCaps( &Caps );
- m_pd3dDevice->GetDisplayMode( 0, &Mode );
- if ( SUCCEEDED( m_pd3dDevice->GetRenderTarget( 0, &pSurf ) ) ) {
- pSurf->GetDesc( &Desc );
- if ( FAILED( pd3d9->CheckDeviceFormat( Caps.AdapterOrdinal, Caps.DeviceType, Mode.Format,
- D3DUSAGE_RENDERTARGET | D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, D3DRTYPE_SURFACE,
- Desc.Format ) ) ) {
- bSupportsAlphaBlend = false;
- }
- SAFE_RELEASE( pSurf );
- }
- SAFE_RELEASE( pd3d9 );
- }
-
- // Create the state blocks for rendering text
- for ( UINT which=0; which<2; which++ ) {
- m_pd3dDevice->BeginStateBlock();
- m_pd3dDevice->SetTexture( 0, m_pTexture );
-
- if ( D3DFONT_ZENABLE & m_dwFontFlags ) {
- m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
- } else {
- m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
- }
-
- if ( bSupportsAlphaBlend ) {
- m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
- m_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
- m_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
- } else {
- m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
- }
- m_pd3dDevice->SetRenderState( D3DRS_ALPHATESTENABLE, TRUE );
- m_pd3dDevice->SetRenderState( D3DRS_ALPHAREF, 0x08 );
- m_pd3dDevice->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL );
- m_pd3dDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
- m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW );
- m_pd3dDevice->SetRenderState( D3DRS_STENCILENABLE, FALSE );
- m_pd3dDevice->SetRenderState( D3DRS_CLIPPING, TRUE );
- m_pd3dDevice->SetRenderState( D3DRS_CLIPPLANEENABLE, FALSE );
- m_pd3dDevice->SetRenderState( D3DRS_VERTEXBLEND, D3DVBF_DISABLE );
- m_pd3dDevice->SetRenderState( D3DRS_INDEXEDVERTEXBLENDENABLE, FALSE );
- m_pd3dDevice->SetRenderState( D3DRS_FOGENABLE, FALSE );
- m_pd3dDevice->SetRenderState( D3DRS_COLORWRITEENABLE,
- D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN |
- D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_ALPHA );
- m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
- m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
- m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
- m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
- m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
- m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
- m_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 );
- m_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
- m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );
- m_pd3dDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
- m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_POINT );
- m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT );
- m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MIPFILTER, D3DTEXF_NONE );
-
- if ( which==0 ) {
- m_pd3dDevice->EndStateBlock( &m_pStateBlockSaved );
- } else {
- m_pd3dDevice->EndStateBlock( &m_pStateBlockDrawText );
- }
- }
-
- return S_OK;
+ HRESULT hr;
+
+ // Create vertex buffer for the letters
+ int vertexSize = max(sizeof(FONT2DVERTEX), sizeof(FONT3DVERTEX));
+ if (FAILED(hr = m_pd3dDevice->CreateVertexBuffer(MAX_NUM_VERTICES * vertexSize,
+ D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, 0,
+ D3DPOOL_DEFAULT, &m_pVB, NULL))) {
+ return hr;
+ }
+
+ bool bSupportsAlphaBlend = true;
+ LPDIRECT3D9 pd3d9 = NULL;
+ if (SUCCEEDED(m_pd3dDevice->GetDirect3D(&pd3d9))) {
+ D3DCAPS9 Caps;
+ D3DDISPLAYMODE Mode;
+ LPDIRECT3DSURFACE9 pSurf = NULL;
+ D3DSURFACE_DESC Desc;
+ m_pd3dDevice->GetDeviceCaps(&Caps);
+ m_pd3dDevice->GetDisplayMode(0, &Mode);
+ if (SUCCEEDED(m_pd3dDevice->GetRenderTarget(0, &pSurf))) {
+ pSurf->GetDesc(&Desc);
+ if (FAILED(pd3d9->CheckDeviceFormat(Caps.AdapterOrdinal, Caps.DeviceType, Mode.Format,
+ D3DUSAGE_RENDERTARGET | D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, D3DRTYPE_SURFACE,
+ Desc.Format))) {
+ bSupportsAlphaBlend = false;
+ }
+ SAFE_RELEASE(pSurf);
+ }
+ SAFE_RELEASE(pd3d9);
+ }
+
+ // Create the state blocks for rendering text
+ for (UINT which = 0; which < 2; which++) {
+ m_pd3dDevice->BeginStateBlock();
+ m_pd3dDevice->SetTexture(0, m_pTexture);
+
+ if (D3DFONT_ZENABLE & m_dwFontFlags) {
+ m_pd3dDevice->SetRenderState(D3DRS_ZENABLE, TRUE);
+ } else {
+ m_pd3dDevice->SetRenderState(D3DRS_ZENABLE, FALSE);
+ }
+
+ if (bSupportsAlphaBlend) {
+ m_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ m_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
+ m_pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
+ } else {
+ m_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+ }
+ m_pd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
+ m_pd3dDevice->SetRenderState(D3DRS_ALPHAREF, 0x08);
+ m_pd3dDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
+ m_pd3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
+ m_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
+ m_pd3dDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE);
+ m_pd3dDevice->SetRenderState(D3DRS_CLIPPING, TRUE);
+ m_pd3dDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, FALSE);
+ m_pd3dDevice->SetRenderState(D3DRS_VERTEXBLEND, D3DVBF_DISABLE);
+ m_pd3dDevice->SetRenderState(D3DRS_INDEXEDVERTEXBLENDENABLE, FALSE);
+ m_pd3dDevice->SetRenderState(D3DRS_FOGENABLE, FALSE);
+ m_pd3dDevice->SetRenderState(D3DRS_COLORWRITEENABLE,
+ D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN |
+ D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_ALPHA);
+ m_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
+ m_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+ m_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
+ m_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
+ m_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
+ m_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
+ m_pd3dDevice->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);
+ m_pd3dDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
+ m_pd3dDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
+ m_pd3dDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
+ m_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
+ m_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
+ m_pd3dDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
+
+ if (which == 0) {
+ m_pd3dDevice->EndStateBlock(&m_pStateBlockSaved);
+ } else {
+ m_pd3dDevice->EndStateBlock(&m_pStateBlockDrawText);
+ }
+ }
+
+ return S_OK;
}
@@ -447,11 +447,11 @@ HRESULT CD3DFont::RestoreDeviceObjects()
//-----------------------------------------------------------------------------
HRESULT CD3DFont::InvalidateDeviceObjects()
{
- SAFE_RELEASE( m_pVB );
- SAFE_RELEASE( m_pStateBlockSaved );
- SAFE_RELEASE( m_pStateBlockDrawText );
+ SAFE_RELEASE(m_pVB);
+ SAFE_RELEASE(m_pStateBlockSaved);
+ SAFE_RELEASE(m_pStateBlockDrawText);
- return S_OK;
+ return S_OK;
}
@@ -462,10 +462,10 @@ HRESULT CD3DFont::InvalidateDeviceObjects()
//-----------------------------------------------------------------------------
HRESULT CD3DFont::DeleteDeviceObjects()
{
- SAFE_RELEASE( m_pTexture );
- m_pd3dDevice = NULL;
+ SAFE_RELEASE(m_pTexture);
+ m_pd3dDevice = NULL;
- return S_OK;
+ return S_OK;
}
@@ -474,43 +474,43 @@ HRESULT CD3DFont::DeleteDeviceObjects()
// Name: GetTextExtent()
// Desc: Get the dimensions of a text string
//-----------------------------------------------------------------------------
-HRESULT CD3DFont::GetTextExtent( const TCHAR* strText, SIZE* pSize )
+HRESULT CD3DFont::GetTextExtent(const TCHAR* strText, SIZE* pSize)
{
- if ( NULL==strText || NULL==pSize ) {
- return E_FAIL;
- }
+ if (NULL == strText || NULL == pSize) {
+ return E_FAIL;
+ }
- FLOAT fRowWidth = 0.0f;
- FLOAT fRowHeight = (m_fTexCoords[0][3]-m_fTexCoords[0][1])*m_dwTexHeight;
- FLOAT fWidth = 0.0f;
- FLOAT fHeight = fRowHeight;
+ FLOAT fRowWidth = 0.0f;
+ FLOAT fRowHeight = (m_fTexCoords[0][3] - m_fTexCoords[0][1]) * m_dwTexHeight;
+ FLOAT fWidth = 0.0f;
+ FLOAT fHeight = fRowHeight;
- while ( *strText ) {
- TCHAR c = *strText++;
+ while (*strText) {
+ TCHAR c = *strText++;
- if ( c == _T('\n') ) {
- fRowWidth = 0.0f;
- fHeight += fRowHeight;
- }
+ if (c == _T('\n')) {
+ fRowWidth = 0.0f;
+ fHeight += fRowHeight;
+ }
- if ( (c-32) < 0 || (c-32) >= 128-32 ) {
- continue;
- }
+ if ((c - 32) < 0 || (c - 32) >= 128 - 32) {
+ continue;
+ }
- FLOAT tx1 = m_fTexCoords[c-32][0];
- FLOAT tx2 = m_fTexCoords[c-32][2];
+ FLOAT tx1 = m_fTexCoords[c - 32][0];
+ FLOAT tx2 = m_fTexCoords[c - 32][2];
- fRowWidth += (tx2-tx1)*m_dwTexWidth - 2*m_dwSpacing;
+ fRowWidth += (tx2 - tx1) * m_dwTexWidth - 2 * m_dwSpacing;
- if ( fRowWidth > fWidth ) {
- fWidth = fRowWidth;
- }
- }
+ if (fRowWidth > fWidth) {
+ fWidth = fRowWidth;
+ }
+ }
- pSize->cx = (int)fWidth;
- pSize->cy = (int)fHeight;
+ pSize->cx = (int)fWidth;
+ pSize->cy = (int)fHeight;
- return S_OK;
+ return S_OK;
}
@@ -523,130 +523,130 @@ HRESULT CD3DFont::GetTextExtent( const TCHAR* strText, SIZE* pSize )
// 1/8th of the screen width. This allows you to output text at a fixed
// fraction of the viewport, even if the screen or window size changes.
//-----------------------------------------------------------------------------
-HRESULT CD3DFont::DrawTextScaled( FLOAT x, FLOAT y, FLOAT z,
- FLOAT fXScale, FLOAT fYScale, DWORD dwColor,
- const TCHAR* strText, DWORD dwFlags )
+HRESULT CD3DFont::DrawTextScaled(FLOAT x, FLOAT y, FLOAT z,
+ FLOAT fXScale, FLOAT fYScale, DWORD dwColor,
+ const TCHAR* strText, DWORD dwFlags)
{
- if ( m_pd3dDevice == NULL ) {
- return E_FAIL;
- }
-
- // Set up renderstate
- m_pStateBlockSaved->Capture();
- m_pStateBlockDrawText->Apply();
- m_pd3dDevice->SetFVF( D3DFVF_FONT2DVERTEX );
- m_pd3dDevice->SetPixelShader( NULL );
- m_pd3dDevice->SetStreamSource( 0, m_pVB, 0, sizeof(FONT2DVERTEX) );
-
- // Set filter states
- if ( dwFlags & D3DFONT_FILTERED ) {
- m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
- m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
- }
-
- D3DVIEWPORT9 vp;
- m_pd3dDevice->GetViewport( &vp );
- FLOAT fLineHeight = ( m_fTexCoords[0][3] - m_fTexCoords[0][1] ) * m_dwTexHeight;
-
- // Center the text block in the viewport
- if ( dwFlags & D3DFONT_CENTERED_X ) {
- const TCHAR* strTextTmp = strText;
- float xFinal = 0.0f;
-
- while ( *strTextTmp ) {
- TCHAR c = *strTextTmp++;
-
- if ( c == _T('\n') ) {
- break; // Isn't supported.
- }
- if ( (c-32) < 0 || (c-32) >= 128-32 ) {
- continue;
- }
-
- FLOAT tx1 = m_fTexCoords[c-32][0];
- FLOAT tx2 = m_fTexCoords[c-32][2];
-
- FLOAT w = (tx2-tx1)*m_dwTexWidth;
-
- w *= (fXScale*vp.Height)/fLineHeight;
-
- xFinal += w - (2 * m_dwSpacing) * (fXScale*vp.Height)/fLineHeight;
- }
-
- x = -xFinal/vp.Width;
- }
- if ( dwFlags & D3DFONT_CENTERED_Y ) {
- y = -fLineHeight/vp.Height;
- }
-
- FLOAT sx = (x+1.0f)*vp.Width/2;
- FLOAT sy = (y+1.0f)*vp.Height/2;
- FLOAT sz = z;
- FLOAT rhw = 1.0f;
-
- // Adjust for character spacing
- sx -= m_dwSpacing * (fXScale*vp.Height)/fLineHeight;
- FLOAT fStartX = sx;
-
- // Fill vertex buffer
- FONT2DVERTEX* pVertices;
- DWORD dwNumTriangles = 0L;
- m_pVB->Lock( 0, 0, (void**)&pVertices, D3DLOCK_DISCARD );
-
- while ( *strText ) {
- TCHAR c = *strText++;
-
- if ( c == _T('\n') ) {
- sx = fStartX;
- sy += fYScale*vp.Height;
- }
-
- if ( (c-32) < 0 || (c-32) >= 128-32 ) {
- continue;
- }
-
- FLOAT tx1 = m_fTexCoords[c-32][0];
- FLOAT ty1 = m_fTexCoords[c-32][1];
- FLOAT tx2 = m_fTexCoords[c-32][2];
- FLOAT ty2 = m_fTexCoords[c-32][3];
-
- FLOAT w = (tx2-tx1)*m_dwTexWidth;
- FLOAT h = (ty2-ty1)*m_dwTexHeight;
-
- w *= (fXScale*vp.Height)/fLineHeight;
- h *= (fYScale*vp.Height)/fLineHeight;
-
- if ( c != _T(' ') ) {
- *pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+0-0.5f,sy+h-0.5f,sz,rhw), dwColor, tx1, ty2 );
- *pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+0-0.5f,sy+0-0.5f,sz,rhw), dwColor, tx1, ty1 );
- *pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+w-0.5f,sy+h-0.5f,sz,rhw), dwColor, tx2, ty2 );
- *pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+w-0.5f,sy+0-0.5f,sz,rhw), dwColor, tx2, ty1 );
- *pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+w-0.5f,sy+h-0.5f,sz,rhw), dwColor, tx2, ty2 );
- *pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+0-0.5f,sy+0-0.5f,sz,rhw), dwColor, tx1, ty1 );
- dwNumTriangles += 2;
-
- if ( dwNumTriangles*3 > (MAX_NUM_VERTICES-6) ) {
- // Unlock, render, and relock the vertex buffer
- m_pVB->Unlock();
- m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
- m_pVB->Lock( 0, 0, (void**)&pVertices, D3DLOCK_DISCARD );
- dwNumTriangles = 0L;
- }
- }
-
- sx += w - (2 * m_dwSpacing) * (fXScale*vp.Height)/fLineHeight;
- }
-
- // Unlock and render the vertex buffer
- m_pVB->Unlock();
- if ( dwNumTriangles > 0 ) {
- m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
- }
-
- // Restore the modified renderstates
- m_pStateBlockSaved->Apply();
-
- return S_OK;
+ if (m_pd3dDevice == NULL) {
+ return E_FAIL;
+ }
+
+ // Set up renderstate
+ m_pStateBlockSaved->Capture();
+ m_pStateBlockDrawText->Apply();
+ m_pd3dDevice->SetFVF(D3DFVF_FONT2DVERTEX);
+ m_pd3dDevice->SetPixelShader(NULL);
+ m_pd3dDevice->SetStreamSource(0, m_pVB, 0, sizeof(FONT2DVERTEX));
+
+ // Set filter states
+ if (dwFlags & D3DFONT_FILTERED) {
+ m_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
+ m_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
+ }
+
+ D3DVIEWPORT9 vp;
+ m_pd3dDevice->GetViewport(&vp);
+ FLOAT fLineHeight = (m_fTexCoords[0][3] - m_fTexCoords[0][1]) * m_dwTexHeight;
+
+ // Center the text block in the viewport
+ if (dwFlags & D3DFONT_CENTERED_X) {
+ const TCHAR* strTextTmp = strText;
+ float xFinal = 0.0f;
+
+ while (*strTextTmp) {
+ TCHAR c = *strTextTmp++;
+
+ if (c == _T('\n')) {
+ break; // Isn't supported.
+ }
+ if ((c - 32) < 0 || (c - 32) >= 128 - 32) {
+ continue;
+ }
+
+ FLOAT tx1 = m_fTexCoords[c - 32][0];
+ FLOAT tx2 = m_fTexCoords[c - 32][2];
+
+ FLOAT w = (tx2 - tx1) * m_dwTexWidth;
+
+ w *= (fXScale * vp.Height) / fLineHeight;
+
+ xFinal += w - (2 * m_dwSpacing) * (fXScale * vp.Height) / fLineHeight;
+ }
+
+ x = -xFinal / vp.Width;
+ }
+ if (dwFlags & D3DFONT_CENTERED_Y) {
+ y = -fLineHeight / vp.Height;
+ }
+
+ FLOAT sx = (x + 1.0f) * vp.Width / 2;
+ FLOAT sy = (y + 1.0f) * vp.Height / 2;
+ FLOAT sz = z;
+ FLOAT rhw = 1.0f;
+
+ // Adjust for character spacing
+ sx -= m_dwSpacing * (fXScale * vp.Height) / fLineHeight;
+ FLOAT fStartX = sx;
+
+ // Fill vertex buffer
+ FONT2DVERTEX* pVertices;
+ DWORD dwNumTriangles = 0L;
+ m_pVB->Lock(0, 0, (void**)&pVertices, D3DLOCK_DISCARD);
+
+ while (*strText) {
+ TCHAR c = *strText++;
+
+ if (c == _T('\n')) {
+ sx = fStartX;
+ sy += fYScale * vp.Height;
+ }
+
+ if ((c - 32) < 0 || (c - 32) >= 128 - 32) {
+ continue;
+ }
+
+ FLOAT tx1 = m_fTexCoords[c - 32][0];
+ FLOAT ty1 = m_fTexCoords[c - 32][1];
+ FLOAT tx2 = m_fTexCoords[c - 32][2];
+ FLOAT ty2 = m_fTexCoords[c - 32][3];
+
+ FLOAT w = (tx2 - tx1) * m_dwTexWidth;
+ FLOAT h = (ty2 - ty1) * m_dwTexHeight;
+
+ w *= (fXScale * vp.Height) / fLineHeight;
+ h *= (fYScale * vp.Height) / fLineHeight;
+
+ if (c != _T(' ')) {
+ *pVertices++ = InitFont2DVertex(D3DXVECTOR4(sx + 0 - 0.5f, sy + h - 0.5f, sz, rhw), dwColor, tx1, ty2);
+ *pVertices++ = InitFont2DVertex(D3DXVECTOR4(sx + 0 - 0.5f, sy + 0 - 0.5f, sz, rhw), dwColor, tx1, ty1);
+ *pVertices++ = InitFont2DVertex(D3DXVECTOR4(sx + w - 0.5f, sy + h - 0.5f, sz, rhw), dwColor, tx2, ty2);
+ *pVertices++ = InitFont2DVertex(D3DXVECTOR4(sx + w - 0.5f, sy + 0 - 0.5f, sz, rhw), dwColor, tx2, ty1);
+ *pVertices++ = InitFont2DVertex(D3DXVECTOR4(sx + w - 0.5f, sy + h - 0.5f, sz, rhw), dwColor, tx2, ty2);
+ *pVertices++ = InitFont2DVertex(D3DXVECTOR4(sx + 0 - 0.5f, sy + 0 - 0.5f, sz, rhw), dwColor, tx1, ty1);
+ dwNumTriangles += 2;
+
+ if (dwNumTriangles * 3 > (MAX_NUM_VERTICES - 6)) {
+ // Unlock, render, and relock the vertex buffer
+ m_pVB->Unlock();
+ m_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, dwNumTriangles);
+ m_pVB->Lock(0, 0, (void**)&pVertices, D3DLOCK_DISCARD);
+ dwNumTriangles = 0L;
+ }
+ }
+
+ sx += w - (2 * m_dwSpacing) * (fXScale * vp.Height) / fLineHeight;
+ }
+
+ // Unlock and render the vertex buffer
+ m_pVB->Unlock();
+ if (dwNumTriangles > 0) {
+ m_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, dwNumTriangles);
+ }
+
+ // Restore the modified renderstates
+ m_pStateBlockSaved->Apply();
+
+ return S_OK;
}
@@ -655,121 +655,121 @@ HRESULT CD3DFont::DrawTextScaled( FLOAT x, FLOAT y, FLOAT z,
// Name: DrawText()
// Desc: Draws 2D text. Note that sx and sy are in pixels
//-----------------------------------------------------------------------------
-HRESULT CD3DFont::DrawText( FLOAT sx, FLOAT sy, DWORD dwColor,
- const TCHAR* strText, DWORD dwFlags )
+HRESULT CD3DFont::DrawText(FLOAT sx, FLOAT sy, DWORD dwColor,
+ const TCHAR* strText, DWORD dwFlags)
{
- if ( m_pd3dDevice == NULL ) {
- return E_FAIL;
- }
-
- // Setup renderstate
- m_pStateBlockSaved->Capture();
- m_pStateBlockDrawText->Apply();
- m_pd3dDevice->SetFVF( D3DFVF_FONT2DVERTEX );
- m_pd3dDevice->SetPixelShader( NULL );
- m_pd3dDevice->SetStreamSource( 0, m_pVB, 0, sizeof(FONT2DVERTEX) );
-
- // Set filter states
- if ( dwFlags & D3DFONT_FILTERED ) {
- m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
- m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
- }
-
- // Center the text block in the viewport
- if ( dwFlags & D3DFONT_CENTERED_X ) {
- D3DVIEWPORT9 vp;
- m_pd3dDevice->GetViewport( &vp );
- const TCHAR* strTextTmp = strText;
- float xFinal = 0.0f;
-
- while ( *strTextTmp ) {
- TCHAR c = *strTextTmp++;
-
- if ( c == _T('\n') ) {
- break; // Isn't supported.
- }
- if ( (c-32) < 0 || (c-32) >= 128-32 ) {
- continue;
- }
-
- FLOAT tx1 = m_fTexCoords[c-32][0];
- FLOAT tx2 = m_fTexCoords[c-32][2];
-
- FLOAT w = (tx2-tx1) * m_dwTexWidth / m_fTextScale;
-
- xFinal += w - (2 * m_dwSpacing);
- }
-
- sx = (vp.Width-xFinal)/2.0f;
- }
- if ( dwFlags & D3DFONT_CENTERED_Y ) {
- D3DVIEWPORT9 vp;
- m_pd3dDevice->GetViewport( &vp );
- float fLineHeight = ((m_fTexCoords[0][3]-m_fTexCoords[0][1])*m_dwTexHeight);
- sy = (vp.Height-fLineHeight)/2;
- }
-
- // Adjust for character spacing
- sx -= m_dwSpacing;
- FLOAT fStartX = sx;
-
- // Fill vertex buffer
- FONT2DVERTEX* pVertices = NULL;
- DWORD dwNumTriangles = 0;
- m_pVB->Lock( 0, 0, (void**)&pVertices, D3DLOCK_DISCARD );
-
- while ( *strText ) {
- TCHAR c = *strText++;
-
- if ( c == _T('\n') ) {
- sx = fStartX;
- sy += (m_fTexCoords[0][3]-m_fTexCoords[0][1])*m_dwTexHeight;
- }
-
- if ( (c-32) < 0 || (c-32) >= 128-32 ) {
- continue;
- }
-
- FLOAT tx1 = m_fTexCoords[c-32][0];
- FLOAT ty1 = m_fTexCoords[c-32][1];
- FLOAT tx2 = m_fTexCoords[c-32][2];
- FLOAT ty2 = m_fTexCoords[c-32][3];
-
- FLOAT w = (tx2-tx1) * m_dwTexWidth / m_fTextScale;
- FLOAT h = (ty2-ty1) * m_dwTexHeight / m_fTextScale;
-
- if ( c != _T(' ') ) {
- *pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+0-0.5f,sy+h-0.5f,0.9f,1.0f), dwColor, tx1, ty2 );
- *pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+0-0.5f,sy+0-0.5f,0.9f,1.0f), dwColor, tx1, ty1 );
- *pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+w-0.5f,sy+h-0.5f,0.9f,1.0f), dwColor, tx2, ty2 );
- *pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+w-0.5f,sy+0-0.5f,0.9f,1.0f), dwColor, tx2, ty1 );
- *pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+w-0.5f,sy+h-0.5f,0.9f,1.0f), dwColor, tx2, ty2 );
- *pVertices++ = InitFont2DVertex( D3DXVECTOR4(sx+0-0.5f,sy+0-0.5f,0.9f,1.0f), dwColor, tx1, ty1 );
- dwNumTriangles += 2;
-
- if ( dwNumTriangles*3 > (MAX_NUM_VERTICES-6) ) {
- // Unlock, render, and relock the vertex buffer
- m_pVB->Unlock();
- m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
- pVertices = NULL;
- m_pVB->Lock( 0, 0, (void**)&pVertices, D3DLOCK_DISCARD );
- dwNumTriangles = 0L;
- }
- }
-
- sx += w - (2 * m_dwSpacing);
- }
-
- // Unlock and render the vertex buffer
- m_pVB->Unlock();
- if ( dwNumTriangles > 0 ) {
- m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
- }
-
- // Restore the modified renderstates
- m_pStateBlockSaved->Apply();
-
- return S_OK;
+ if (m_pd3dDevice == NULL) {
+ return E_FAIL;
+ }
+
+ // Setup renderstate
+ m_pStateBlockSaved->Capture();
+ m_pStateBlockDrawText->Apply();
+ m_pd3dDevice->SetFVF(D3DFVF_FONT2DVERTEX);
+ m_pd3dDevice->SetPixelShader(NULL);
+ m_pd3dDevice->SetStreamSource(0, m_pVB, 0, sizeof(FONT2DVERTEX));
+
+ // Set filter states
+ if (dwFlags & D3DFONT_FILTERED) {
+ m_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
+ m_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
+ }
+
+ // Center the text block in the viewport
+ if (dwFlags & D3DFONT_CENTERED_X) {
+ D3DVIEWPORT9 vp;
+ m_pd3dDevice->GetViewport(&vp);
+ const TCHAR* strTextTmp = strText;
+ float xFinal = 0.0f;
+
+ while (*strTextTmp) {
+ TCHAR c = *strTextTmp++;
+
+ if (c == _T('\n')) {
+ break; // Isn't supported.
+ }
+ if ((c - 32) < 0 || (c - 32) >= 128 - 32) {
+ continue;
+ }
+
+ FLOAT tx1 = m_fTexCoords[c - 32][0];
+ FLOAT tx2 = m_fTexCoords[c - 32][2];
+
+ FLOAT w = (tx2 - tx1) * m_dwTexWidth / m_fTextScale;
+
+ xFinal += w - (2 * m_dwSpacing);
+ }
+
+ sx = (vp.Width - xFinal) / 2.0f;
+ }
+ if (dwFlags & D3DFONT_CENTERED_Y) {
+ D3DVIEWPORT9 vp;
+ m_pd3dDevice->GetViewport(&vp);
+ float fLineHeight = ((m_fTexCoords[0][3] - m_fTexCoords[0][1]) * m_dwTexHeight);
+ sy = (vp.Height - fLineHeight) / 2;
+ }
+
+ // Adjust for character spacing
+ sx -= m_dwSpacing;
+ FLOAT fStartX = sx;
+
+ // Fill vertex buffer
+ FONT2DVERTEX* pVertices = NULL;
+ DWORD dwNumTriangles = 0;
+ m_pVB->Lock(0, 0, (void**)&pVertices, D3DLOCK_DISCARD);
+
+ while (*strText) {
+ TCHAR c = *strText++;
+
+ if (c == _T('\n')) {
+ sx = fStartX;
+ sy += (m_fTexCoords[0][3] - m_fTexCoords[0][1]) * m_dwTexHeight;
+ }
+
+ if ((c - 32) < 0 || (c - 32) >= 128 - 32) {
+ continue;
+ }
+
+ FLOAT tx1 = m_fTexCoords[c - 32][0];
+ FLOAT ty1 = m_fTexCoords[c - 32][1];
+ FLOAT tx2 = m_fTexCoords[c - 32][2];
+ FLOAT ty2 = m_fTexCoords[c - 32][3];
+
+ FLOAT w = (tx2 - tx1) * m_dwTexWidth / m_fTextScale;
+ FLOAT h = (ty2 - ty1) * m_dwTexHeight / m_fTextScale;
+
+ if (c != _T(' ')) {
+ *pVertices++ = InitFont2DVertex(D3DXVECTOR4(sx + 0 - 0.5f, sy + h - 0.5f, 0.9f, 1.0f), dwColor, tx1, ty2);
+ *pVertices++ = InitFont2DVertex(D3DXVECTOR4(sx + 0 - 0.5f, sy + 0 - 0.5f, 0.9f, 1.0f), dwColor, tx1, ty1);
+ *pVertices++ = InitFont2DVertex(D3DXVECTOR4(sx + w - 0.5f, sy + h - 0.5f, 0.9f, 1.0f), dwColor, tx2, ty2);
+ *pVertices++ = InitFont2DVertex(D3DXVECTOR4(sx + w - 0.5f, sy + 0 - 0.5f, 0.9f, 1.0f), dwColor, tx2, ty1);
+ *pVertices++ = InitFont2DVertex(D3DXVECTOR4(sx + w - 0.5f, sy + h - 0.5f, 0.9f, 1.0f), dwColor, tx2, ty2);
+ *pVertices++ = InitFont2DVertex(D3DXVECTOR4(sx + 0 - 0.5f, sy + 0 - 0.5f, 0.9f, 1.0f), dwColor, tx1, ty1);
+ dwNumTriangles += 2;
+
+ if (dwNumTriangles * 3 > (MAX_NUM_VERTICES - 6)) {
+ // Unlock, render, and relock the vertex buffer
+ m_pVB->Unlock();
+ m_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, dwNumTriangles);
+ pVertices = NULL;
+ m_pVB->Lock(0, 0, (void**)&pVertices, D3DLOCK_DISCARD);
+ dwNumTriangles = 0L;
+ }
+ }
+
+ sx += w - (2 * m_dwSpacing);
+ }
+
+ // Unlock and render the vertex buffer
+ m_pVB->Unlock();
+ if (dwNumTriangles > 0) {
+ m_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, dwNumTriangles);
+ }
+
+ // Restore the modified renderstates
+ m_pStateBlockSaved->Apply();
+
+ return S_OK;
}
@@ -778,103 +778,103 @@ HRESULT CD3DFont::DrawText( FLOAT sx, FLOAT sy, DWORD dwColor,
// Name: Render3DText()
// Desc: Renders 3D text
//-----------------------------------------------------------------------------
-HRESULT CD3DFont::Render3DText( const TCHAR* strText, DWORD dwFlags )
+HRESULT CD3DFont::Render3DText(const TCHAR* strText, DWORD dwFlags)
{
- if ( m_pd3dDevice == NULL ) {
- return E_FAIL;
- }
-
- // Setup renderstate
- m_pStateBlockSaved->Capture();
- m_pStateBlockDrawText->Apply();
- m_pd3dDevice->SetFVF( D3DFVF_FONT3DVERTEX );
- m_pd3dDevice->SetPixelShader( NULL );
- m_pd3dDevice->SetStreamSource( 0, m_pVB, 0, sizeof(FONT3DVERTEX) );
-
- // Set filter states
- if ( dwFlags & D3DFONT_FILTERED ) {
- m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
- m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
- }
-
- // Position for each text element
- FLOAT x = 0.0f;
- FLOAT y = 0.0f;
-
- // Center the text block at the origin (not the viewport)
- if ( dwFlags & D3DFONT_CENTERED_X ) {
- SIZE sz;
- GetTextExtent( strText, &sz );
- x = -(((FLOAT)sz.cx)/10.0f)/2.0f;
- }
- if ( dwFlags & D3DFONT_CENTERED_Y ) {
- SIZE sz;
- GetTextExtent( strText, &sz );
- y = -(((FLOAT)sz.cy)/10.0f)/2.0f;
- }
-
- // Turn off culling for two-sided text
- if ( dwFlags & D3DFONT_TWOSIDED ) {
- m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
- }
-
- // Adjust for character spacing
- x -= m_dwSpacing / 10.0f;
- FLOAT fStartX = x;
- TCHAR c;
-
- // Fill vertex buffer
- FONT3DVERTEX* pVertices;
- DWORD dwNumTriangles = 0L;
- m_pVB->Lock( 0, 0, (void**)&pVertices, D3DLOCK_DISCARD );
-
- while ( (c = *strText++) != 0 ) {
- if ( c == '\n' ) {
- x = fStartX;
- y -= (m_fTexCoords[0][3]-m_fTexCoords[0][1])*m_dwTexHeight/10.0f;
- }
-
- if ( (c-32) < 0 || (c-32) >= 128-32 ) {
- continue;
- }
-
- FLOAT tx1 = m_fTexCoords[c-32][0];
- FLOAT ty1 = m_fTexCoords[c-32][1];
- FLOAT tx2 = m_fTexCoords[c-32][2];
- FLOAT ty2 = m_fTexCoords[c-32][3];
-
- FLOAT w = (tx2-tx1) * m_dwTexWidth / ( 10.0f * m_fTextScale );
- FLOAT h = (ty2-ty1) * m_dwTexHeight / ( 10.0f * m_fTextScale );
-
- if ( c != _T(' ') ) {
- *pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+0,y+0,0), D3DXVECTOR3(0,0,-1), tx1, ty2 );
- *pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+0,y+h,0), D3DXVECTOR3(0,0,-1), tx1, ty1 );
- *pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+w,y+0,0), D3DXVECTOR3(0,0,-1), tx2, ty2 );
- *pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+w,y+h,0), D3DXVECTOR3(0,0,-1), tx2, ty1 );
- *pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+w,y+0,0), D3DXVECTOR3(0,0,-1), tx2, ty2 );
- *pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+0,y+h,0), D3DXVECTOR3(0,0,-1), tx1, ty1 );
- dwNumTriangles += 2;
-
- if ( dwNumTriangles*3 > (MAX_NUM_VERTICES-6) ) {
- // Unlock, render, and relock the vertex buffer
- m_pVB->Unlock();
- m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
- m_pVB->Lock( 0, 0, (void**)&pVertices, D3DLOCK_DISCARD );
- dwNumTriangles = 0L;
- }
- }
-
- x += w - (2 * m_dwSpacing) / 10.0f;
- }
-
- // Unlock and render the vertex buffer
- m_pVB->Unlock();
- if ( dwNumTriangles > 0 ) {
- m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
- }
-
- // Restore the modified renderstates
- m_pStateBlockSaved->Apply();
-
- return S_OK;
+ if (m_pd3dDevice == NULL) {
+ return E_FAIL;
+ }
+
+ // Setup renderstate
+ m_pStateBlockSaved->Capture();
+ m_pStateBlockDrawText->Apply();
+ m_pd3dDevice->SetFVF(D3DFVF_FONT3DVERTEX);
+ m_pd3dDevice->SetPixelShader(NULL);
+ m_pd3dDevice->SetStreamSource(0, m_pVB, 0, sizeof(FONT3DVERTEX));
+
+ // Set filter states
+ if (dwFlags & D3DFONT_FILTERED) {
+ m_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
+ m_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
+ }
+
+ // Position for each text element
+ FLOAT x = 0.0f;
+ FLOAT y = 0.0f;
+
+ // Center the text block at the origin (not the viewport)
+ if (dwFlags & D3DFONT_CENTERED_X) {
+ SIZE sz;
+ GetTextExtent(strText, &sz);
+ x = -(((FLOAT)sz.cx) / 10.0f) / 2.0f;
+ }
+ if (dwFlags & D3DFONT_CENTERED_Y) {
+ SIZE sz;
+ GetTextExtent(strText, &sz);
+ y = -(((FLOAT)sz.cy) / 10.0f) / 2.0f;
+ }
+
+ // Turn off culling for two-sided text
+ if (dwFlags & D3DFONT_TWOSIDED) {
+ m_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
+ }
+
+ // Adjust for character spacing
+ x -= m_dwSpacing / 10.0f;
+ FLOAT fStartX = x;
+ TCHAR c;
+
+ // Fill vertex buffer
+ FONT3DVERTEX* pVertices;
+ DWORD dwNumTriangles = 0L;
+ m_pVB->Lock(0, 0, (void**)&pVertices, D3DLOCK_DISCARD);
+
+ while ((c = *strText++) != 0) {
+ if (c == '\n') {
+ x = fStartX;
+ y -= (m_fTexCoords[0][3] - m_fTexCoords[0][1]) * m_dwTexHeight / 10.0f;
+ }
+
+ if ((c - 32) < 0 || (c - 32) >= 128 - 32) {
+ continue;
+ }
+
+ FLOAT tx1 = m_fTexCoords[c - 32][0];
+ FLOAT ty1 = m_fTexCoords[c - 32][1];
+ FLOAT tx2 = m_fTexCoords[c - 32][2];
+ FLOAT ty2 = m_fTexCoords[c - 32][3];
+
+ FLOAT w = (tx2 - tx1) * m_dwTexWidth / (10.0f * m_fTextScale);
+ FLOAT h = (ty2 - ty1) * m_dwTexHeight / (10.0f * m_fTextScale);
+
+ if (c != _T(' ')) {
+ *pVertices++ = InitFont3DVertex(D3DXVECTOR3(x + 0, y + 0, 0), D3DXVECTOR3(0, 0, -1), tx1, ty2);
+ *pVertices++ = InitFont3DVertex(D3DXVECTOR3(x + 0, y + h, 0), D3DXVECTOR3(0, 0, -1), tx1, ty1);
+ *pVertices++ = InitFont3DVertex(D3DXVECTOR3(x + w, y + 0, 0), D3DXVECTOR3(0, 0, -1), tx2, ty2);
+ *pVertices++ = InitFont3DVertex(D3DXVECTOR3(x + w, y + h, 0), D3DXVECTOR3(0, 0, -1), tx2, ty1);
+ *pVertices++ = InitFont3DVertex(D3DXVECTOR3(x + w, y + 0, 0), D3DXVECTOR3(0, 0, -1), tx2, ty2);
+ *pVertices++ = InitFont3DVertex(D3DXVECTOR3(x + 0, y + h, 0), D3DXVECTOR3(0, 0, -1), tx1, ty1);
+ dwNumTriangles += 2;
+
+ if (dwNumTriangles * 3 > (MAX_NUM_VERTICES - 6)) {
+ // Unlock, render, and relock the vertex buffer
+ m_pVB->Unlock();
+ m_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, dwNumTriangles);
+ m_pVB->Lock(0, 0, (void**)&pVertices, D3DLOCK_DISCARD);
+ dwNumTriangles = 0L;
+ }
+ }
+
+ x += w - (2 * m_dwSpacing) / 10.0f;
+ }
+
+ // Unlock and render the vertex buffer
+ m_pVB->Unlock();
+ if (dwNumTriangles > 0) {
+ m_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, dwNumTriangles);
+ }
+
+ // Restore the modified renderstates
+ m_pStateBlockSaved->Apply();
+
+ return S_OK;
}
diff --git a/src/filters/renderer/VideoRenderers/D3DFont.h b/src/filters/renderer/VideoRenderers/D3DFont.h
index 6402985f0..62c991631 100644
--- a/src/filters/renderer/VideoRenderers/D3DFont.h
+++ b/src/filters/renderer/VideoRenderers/D3DFont.h
@@ -37,45 +37,45 @@
class CD3DFont
{
- TCHAR m_strFontName[80]; // Font properties
- DWORD m_dwFontHeight;
- DWORD m_dwFontFlags;
+ TCHAR m_strFontName[80]; // Font properties
+ DWORD m_dwFontHeight;
+ DWORD m_dwFontFlags;
- LPDIRECT3DDEVICE9 m_pd3dDevice; // A D3DDevice used for rendering
- LPDIRECT3DTEXTURE9 m_pTexture; // The d3d texture for this font
- LPDIRECT3DVERTEXBUFFER9 m_pVB; // VertexBuffer for rendering text
- DWORD m_dwTexWidth; // Texture dimensions
- DWORD m_dwTexHeight;
- FLOAT m_fTextScale;
- FLOAT m_fTexCoords[128-32][4];
- DWORD m_dwSpacing; // Character pixel spacing per side
+ LPDIRECT3DDEVICE9 m_pd3dDevice; // A D3DDevice used for rendering
+ LPDIRECT3DTEXTURE9 m_pTexture; // The d3d texture for this font
+ LPDIRECT3DVERTEXBUFFER9 m_pVB; // VertexBuffer for rendering text
+ DWORD m_dwTexWidth; // Texture dimensions
+ DWORD m_dwTexHeight;
+ FLOAT m_fTextScale;
+ FLOAT m_fTexCoords[128 - 32][4];
+ DWORD m_dwSpacing; // Character pixel spacing per side
- // Stateblocks for setting and restoring render states
- LPDIRECT3DSTATEBLOCK9 m_pStateBlockSaved;
- LPDIRECT3DSTATEBLOCK9 m_pStateBlockDrawText;
+ // Stateblocks for setting and restoring render states
+ LPDIRECT3DSTATEBLOCK9 m_pStateBlockSaved;
+ LPDIRECT3DSTATEBLOCK9 m_pStateBlockDrawText;
- HRESULT CreateGDIFont( HDC hDC, HFONT* pFont );
- HRESULT PaintAlphabet( HDC hDC, BOOL bMeasureOnly=FALSE );
+ HRESULT CreateGDIFont(HDC hDC, HFONT* pFont);
+ HRESULT PaintAlphabet(HDC hDC, BOOL bMeasureOnly = FALSE);
public:
- // 2D and 3D text drawing functions
- HRESULT DrawText( FLOAT x, FLOAT y, DWORD dwColor,
- const TCHAR* strText, DWORD dwFlags=0L );
- HRESULT DrawTextScaled( FLOAT x, FLOAT y, FLOAT z,
- FLOAT fXScale, FLOAT fYScale, DWORD dwColor,
- const TCHAR* strText, DWORD dwFlags=0L );
- HRESULT Render3DText( const TCHAR* strText, DWORD dwFlags=0L );
+ // 2D and 3D text drawing functions
+ HRESULT DrawText(FLOAT x, FLOAT y, DWORD dwColor,
+ const TCHAR* strText, DWORD dwFlags = 0L);
+ HRESULT DrawTextScaled(FLOAT x, FLOAT y, FLOAT z,
+ FLOAT fXScale, FLOAT fYScale, DWORD dwColor,
+ const TCHAR* strText, DWORD dwFlags = 0L);
+ HRESULT Render3DText(const TCHAR* strText, DWORD dwFlags = 0L);
- // Function to get extent of text
- HRESULT GetTextExtent( const TCHAR* strText, SIZE* pSize );
+ // Function to get extent of text
+ HRESULT GetTextExtent(const TCHAR* strText, SIZE* pSize);
- // Initializing and destroying device-dependent objects
- HRESULT InitDeviceObjects( IDirect3DDevice9* pd3dDevice );
- HRESULT RestoreDeviceObjects();
- HRESULT InvalidateDeviceObjects();
- HRESULT DeleteDeviceObjects();
+ // Initializing and destroying device-dependent objects
+ HRESULT InitDeviceObjects(IDirect3DDevice9* pd3dDevice);
+ HRESULT RestoreDeviceObjects();
+ HRESULT InvalidateDeviceObjects();
+ HRESULT DeleteDeviceObjects();
- // Constructor / destructor
- CD3DFont( const TCHAR* strFontName, DWORD dwHeight, DWORD dwFlags=0L );
- ~CD3DFont();
+ // Constructor / destructor
+ CD3DFont(const TCHAR* strFontName, DWORD dwHeight, DWORD dwFlags = 0L);
+ ~CD3DFont();
};
diff --git a/src/filters/renderer/VideoRenderers/DX7AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/DX7AllocatorPresenter.cpp
index 41d4c246c..9013f77c2 100644
--- a/src/filters/renderer/VideoRenderers/DX7AllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/DX7AllocatorPresenter.cpp
@@ -34,476 +34,476 @@ using namespace DSObjects;
static HRESULT TextureBlt(IDirect3DDevice7* pD3DDev, IDirectDrawSurface7* pTexture, Vector dst[4], CRect src)
{
- if (!pTexture) {
- return E_POINTER;
- }
+ if (!pTexture) {
+ return E_POINTER;
+ }
- ASSERT(pD3DDev);
- HRESULT hr;
+ ASSERT(pD3DDev);
+ HRESULT hr;
- do {
- DDSURFACEDESC2 ddsd;
- INITDDSTRUCT(ddsd);
- if (FAILED(hr = pTexture->GetSurfaceDesc(&ddsd))) {
- break;
- }
+ do {
+ DDSURFACEDESC2 ddsd;
+ INITDDSTRUCT(ddsd);
+ if (FAILED(hr = pTexture->GetSurfaceDesc(&ddsd))) {
+ break;
+ }
- float w = (float)ddsd.dwWidth;
- float h = (float)ddsd.dwHeight;
+ float w = (float)ddsd.dwWidth;
+ float h = (float)ddsd.dwHeight;
- struct {
- float x, y, z, rhw;
- float tu, tv;
- }
- pVertices[] = {
- {(float)dst[0].x, (float)dst[0].y, (float)dst[0].z, 1.0f/(float)dst[0].z, (float)src.left / w, (float)src.top / h},
- {(float)dst[1].x, (float)dst[1].y, (float)dst[1].z, 1.0f/(float)dst[1].z, (float)src.right / w, (float)src.top / h},
- {(float)dst[2].x, (float)dst[2].y, (float)dst[2].z, 1.0f/(float)dst[2].z, (float)src.left / w, (float)src.bottom / h},
- {(float)dst[3].x, (float)dst[3].y, (float)dst[3].z, 1.0f/(float)dst[3].z, (float)src.right / w, (float)src.bottom / h},
- };
+ struct {
+ float x, y, z, rhw;
+ float tu, tv;
+ }
+ pVertices[] = {
+ {(float)dst[0].x, (float)dst[0].y, (float)dst[0].z, 1.0f / (float)dst[0].z, (float)src.left / w, (float)src.top / h},
+ {(float)dst[1].x, (float)dst[1].y, (float)dst[1].z, 1.0f / (float)dst[1].z, (float)src.right / w, (float)src.top / h},
+ {(float)dst[2].x, (float)dst[2].y, (float)dst[2].z, 1.0f / (float)dst[2].z, (float)src.left / w, (float)src.bottom / h},
+ {(float)dst[3].x, (float)dst[3].y, (float)dst[3].z, 1.0f / (float)dst[3].z, (float)src.right / w, (float)src.bottom / h},
+ };
- for (int i = 0; i < _countof(pVertices); i++) {
- pVertices[i].x -= 0.5;
- pVertices[i].y -= 0.5;
- }
+ for (int i = 0; i < _countof(pVertices); i++) {
+ pVertices[i].x -= 0.5;
+ pVertices[i].y -= 0.5;
+ }
- hr = pD3DDev->SetTexture(0, pTexture);
+ hr = pD3DDev->SetTexture(0, pTexture);
- pD3DDev->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
- pD3DDev->SetRenderState(D3DRENDERSTATE_LIGHTING, FALSE);
- pD3DDev->SetRenderState(D3DRENDERSTATE_BLENDENABLE, FALSE);
- pD3DDev->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, FALSE);
+ pD3DDev->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
+ pD3DDev->SetRenderState(D3DRENDERSTATE_LIGHTING, FALSE);
+ pD3DDev->SetRenderState(D3DRENDERSTATE_BLENDENABLE, FALSE);
+ pD3DDev->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, FALSE);
- pD3DDev->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTFG_LINEAR);
- pD3DDev->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTFN_LINEAR);
- pD3DDev->SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTFP_LINEAR);
+ pD3DDev->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTFG_LINEAR);
+ pD3DDev->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTFN_LINEAR);
+ pD3DDev->SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTFP_LINEAR);
- pD3DDev->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP);
+ pD3DDev->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP);
- //
+ //
- if (FAILED(hr = pD3DDev->BeginScene())) {
- break;
- }
+ if (FAILED(hr = pD3DDev->BeginScene())) {
+ break;
+ }
- hr = pD3DDev->DrawPrimitive(D3DPT_TRIANGLESTRIP,
- D3DFVF_XYZRHW | D3DFVF_TEX1,
- pVertices, 4, D3DDP_WAIT);
- pD3DDev->EndScene();
+ hr = pD3DDev->DrawPrimitive(D3DPT_TRIANGLESTRIP,
+ D3DFVF_XYZRHW | D3DFVF_TEX1,
+ pVertices, 4, D3DDP_WAIT);
+ pD3DDev->EndScene();
- //
+ //
- pD3DDev->SetTexture(0, NULL);
+ pD3DDev->SetTexture(0, NULL);
- return S_OK;
- } while (0);
+ return S_OK;
+ } while (0);
- return E_FAIL;
+ return E_FAIL;
}
//
// CDX7AllocatorPresenter
//
-typedef HRESULT (WINAPI *DirectDrawCreateExPtr)( GUID FAR * lpGuid, LPVOID *lplpDD, REFIID iid,IUnknown FAR *pUnkOuter );
+typedef HRESULT(WINAPI* DirectDrawCreateExPtr)(GUID FAR* lpGuid, LPVOID* lplpDD, REFIID iid, IUnknown FAR* pUnkOuter);
CDX7AllocatorPresenter::CDX7AllocatorPresenter(HWND hWnd, HRESULT& hr)
- : CSubPicAllocatorPresenterImpl(hWnd, hr, NULL)
- , m_ScreenSize(0, 0)
+ : CSubPicAllocatorPresenterImpl(hWnd, hr, NULL)
+ , m_ScreenSize(0, 0)
{
- if (FAILED(hr)) {
- return;
- }
-
- DirectDrawCreateExPtr pDirectDrawCreateEx = NULL;
- HMODULE hDDrawLib = NULL;
-
- hDDrawLib = LoadLibrary (_T("ddraw.dll"));
- if (hDDrawLib) {
- pDirectDrawCreateEx = (DirectDrawCreateExPtr)GetProcAddress (hDDrawLib, "DirectDrawCreateEx");
- }
- if (pDirectDrawCreateEx == NULL) {
- hr = E_FAIL;
- return;
- }
-
- if (FAILED(hr = pDirectDrawCreateEx(NULL, (VOID**)&m_pDD, IID_IDirectDraw7, NULL))
- || FAILED(hr = m_pDD->SetCooperativeLevel(AfxGetMainWnd()->GetSafeHwnd(), DDSCL_NORMAL))) {
- return;
- }
-
- if (!(m_pD3D = m_pDD)) {
- hr = E_NOINTERFACE;
- return;
- }
-
- hr = CreateDevice();
- if (FAILED(hr)) {
- TRACE("CreateDevice failed: 0x%08x\n", (LONG)hr);
- }
+ if (FAILED(hr)) {
+ return;
+ }
+
+ DirectDrawCreateExPtr pDirectDrawCreateEx = NULL;
+ HMODULE hDDrawLib = NULL;
+
+ hDDrawLib = LoadLibrary(_T("ddraw.dll"));
+ if (hDDrawLib) {
+ pDirectDrawCreateEx = (DirectDrawCreateExPtr)GetProcAddress(hDDrawLib, "DirectDrawCreateEx");
+ }
+ if (pDirectDrawCreateEx == NULL) {
+ hr = E_FAIL;
+ return;
+ }
+
+ if (FAILED(hr = pDirectDrawCreateEx(NULL, (VOID**)&m_pDD, IID_IDirectDraw7, NULL))
+ || FAILED(hr = m_pDD->SetCooperativeLevel(AfxGetMainWnd()->GetSafeHwnd(), DDSCL_NORMAL))) {
+ return;
+ }
+
+ if (!(m_pD3D = m_pDD)) {
+ hr = E_NOINTERFACE;
+ return;
+ }
+
+ hr = CreateDevice();
+ if (FAILED(hr)) {
+ TRACE("CreateDevice failed: 0x%08x\n", (LONG)hr);
+ }
}
HRESULT CDX7AllocatorPresenter::CreateDevice()
{
- m_pD3DDev = NULL;
-
- m_pPrimary = NULL;
- m_pBackBuffer = NULL;
-
- DDSURFACEDESC2 ddsd;
- INITDDSTRUCT(ddsd);
- if (FAILED(m_pDD->GetDisplayMode(&ddsd)) ||
- ddsd.ddpfPixelFormat.dwRGBBitCount <= 8) {
- return DDERR_INVALIDMODE;
- }
-
- m_ScreenSize.SetSize(ddsd.dwWidth, ddsd.dwHeight);
-
- HRESULT hr;
-
- // m_pPrimary
-
- INITDDSTRUCT(ddsd);
- ddsd.dwFlags = DDSD_CAPS;
- ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
- if (FAILED(hr = m_pDD->CreateSurface(&ddsd, &m_pPrimary, NULL))) {
- return hr;
- }
-
- CComPtr<IDirectDrawClipper> pcClipper;
- if (FAILED(hr = m_pDD->CreateClipper(0, &pcClipper, NULL))) {
- return hr;
- }
- pcClipper->SetHWnd(0, m_hWnd);
- m_pPrimary->SetClipper(pcClipper);
-
- // m_pBackBuffer
-
- INITDDSTRUCT(ddsd);
- ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
- ddsd.ddsCaps.dwCaps = /*DDSCAPS_OFFSCREENPLAIN |*/ DDSCAPS_VIDEOMEMORY | DDSCAPS_3DDEVICE;
- ddsd.dwWidth = m_ScreenSize.cx;
- ddsd.dwHeight = m_ScreenSize.cy;
- if (FAILED(hr = m_pDD->CreateSurface(&ddsd, &m_pBackBuffer, NULL))) {
- return hr;
- }
-
- pcClipper = NULL;
- if (FAILED(hr = m_pDD->CreateClipper(0, &pcClipper, NULL))) {
- return hr;
- }
- BYTE rgnDataBuffer[1024];
- HRGN hrgn = CreateRectRgn(0, 0, ddsd.dwWidth, ddsd.dwHeight);
- GetRegionData(hrgn, sizeof(rgnDataBuffer), (RGNDATA*)rgnDataBuffer);
- DeleteObject(hrgn);
- pcClipper->SetClipList((RGNDATA*)rgnDataBuffer, 0);
- m_pBackBuffer->SetClipper(pcClipper);
-
- // m_pD3DDev
-
- if (FAILED(hr = m_pD3D->CreateDevice(IID_IDirect3DHALDevice, m_pBackBuffer, &m_pD3DDev))) { // this seems to fail if the desktop size is too large (width or height >2048)
- return hr;
- }
-
- //
-
- CComPtr<ISubPicProvider> pSubPicProvider;
- if (m_pSubPicQueue) {
- m_pSubPicQueue->GetSubPicProvider(&pSubPicProvider);
- }
-
- CSize size;
- switch (GetRenderersSettings().nSPCMaxRes) {
- case 0:
- default:
- size = m_ScreenSize;
- break;
- case 1:
- size.SetSize(1024, 768);
- break;
- case 2:
- size.SetSize(800, 600);
- break;
- case 3:
- size.SetSize(640, 480);
- break;
- case 4:
- size.SetSize(512, 384);
- break;
- case 5:
- size.SetSize(384, 288);
- break;
- case 6:
- size.SetSize(2560, 1600);
- break;
- case 7:
- size.SetSize(1920, 1080);
- break;
- case 8:
- size.SetSize(1320, 900);
- break;
- case 9:
- size.SetSize(1280, 720);
- break;
- }
-
- if (m_pAllocator) {
- m_pAllocator->ChangeDevice(m_pD3DDev);
- } else {
- m_pAllocator = DNew CDX7SubPicAllocator(m_pD3DDev, size, GetRenderersSettings().fSPCPow2Tex);
- if (!m_pAllocator || FAILED(hr)) {
- return E_FAIL;
- }
- }
-
- hr = S_OK;
- m_pSubPicQueue = GetRenderersSettings().nSPCSize > 0
- ? (ISubPicQueue*)DNew CSubPicQueue(GetRenderersSettings().nSPCSize, !GetRenderersSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
- : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
- if (!m_pSubPicQueue || FAILED(hr)) {
- return E_FAIL;
- }
-
- if (pSubPicProvider) {
- m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
- }
-
- return S_OK;
+ m_pD3DDev = NULL;
+
+ m_pPrimary = NULL;
+ m_pBackBuffer = NULL;
+
+ DDSURFACEDESC2 ddsd;
+ INITDDSTRUCT(ddsd);
+ if (FAILED(m_pDD->GetDisplayMode(&ddsd)) ||
+ ddsd.ddpfPixelFormat.dwRGBBitCount <= 8) {
+ return DDERR_INVALIDMODE;
+ }
+
+ m_ScreenSize.SetSize(ddsd.dwWidth, ddsd.dwHeight);
+
+ HRESULT hr;
+
+ // m_pPrimary
+
+ INITDDSTRUCT(ddsd);
+ ddsd.dwFlags = DDSD_CAPS;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
+ if (FAILED(hr = m_pDD->CreateSurface(&ddsd, &m_pPrimary, NULL))) {
+ return hr;
+ }
+
+ CComPtr<IDirectDrawClipper> pcClipper;
+ if (FAILED(hr = m_pDD->CreateClipper(0, &pcClipper, NULL))) {
+ return hr;
+ }
+ pcClipper->SetHWnd(0, m_hWnd);
+ m_pPrimary->SetClipper(pcClipper);
+
+ // m_pBackBuffer
+
+ INITDDSTRUCT(ddsd);
+ ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
+ ddsd.ddsCaps.dwCaps = /*DDSCAPS_OFFSCREENPLAIN |*/ DDSCAPS_VIDEOMEMORY | DDSCAPS_3DDEVICE;
+ ddsd.dwWidth = m_ScreenSize.cx;
+ ddsd.dwHeight = m_ScreenSize.cy;
+ if (FAILED(hr = m_pDD->CreateSurface(&ddsd, &m_pBackBuffer, NULL))) {
+ return hr;
+ }
+
+ pcClipper = NULL;
+ if (FAILED(hr = m_pDD->CreateClipper(0, &pcClipper, NULL))) {
+ return hr;
+ }
+ BYTE rgnDataBuffer[1024];
+ HRGN hrgn = CreateRectRgn(0, 0, ddsd.dwWidth, ddsd.dwHeight);
+ GetRegionData(hrgn, sizeof(rgnDataBuffer), (RGNDATA*)rgnDataBuffer);
+ DeleteObject(hrgn);
+ pcClipper->SetClipList((RGNDATA*)rgnDataBuffer, 0);
+ m_pBackBuffer->SetClipper(pcClipper);
+
+ // m_pD3DDev
+
+ if (FAILED(hr = m_pD3D->CreateDevice(IID_IDirect3DHALDevice, m_pBackBuffer, &m_pD3DDev))) { // this seems to fail if the desktop size is too large (width or height >2048)
+ return hr;
+ }
+
+ //
+
+ CComPtr<ISubPicProvider> pSubPicProvider;
+ if (m_pSubPicQueue) {
+ m_pSubPicQueue->GetSubPicProvider(&pSubPicProvider);
+ }
+
+ CSize size;
+ switch (GetRenderersSettings().nSPCMaxRes) {
+ case 0:
+ default:
+ size = m_ScreenSize;
+ break;
+ case 1:
+ size.SetSize(1024, 768);
+ break;
+ case 2:
+ size.SetSize(800, 600);
+ break;
+ case 3:
+ size.SetSize(640, 480);
+ break;
+ case 4:
+ size.SetSize(512, 384);
+ break;
+ case 5:
+ size.SetSize(384, 288);
+ break;
+ case 6:
+ size.SetSize(2560, 1600);
+ break;
+ case 7:
+ size.SetSize(1920, 1080);
+ break;
+ case 8:
+ size.SetSize(1320, 900);
+ break;
+ case 9:
+ size.SetSize(1280, 720);
+ break;
+ }
+
+ if (m_pAllocator) {
+ m_pAllocator->ChangeDevice(m_pD3DDev);
+ } else {
+ m_pAllocator = DNew CDX7SubPicAllocator(m_pD3DDev, size, GetRenderersSettings().fSPCPow2Tex);
+ if (!m_pAllocator || FAILED(hr)) {
+ return E_FAIL;
+ }
+ }
+
+ hr = S_OK;
+ m_pSubPicQueue = GetRenderersSettings().nSPCSize > 0
+ ? (ISubPicQueue*)DNew CSubPicQueue(GetRenderersSettings().nSPCSize, !GetRenderersSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
+ : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
+ if (!m_pSubPicQueue || FAILED(hr)) {
+ return E_FAIL;
+ }
+
+ if (pSubPicProvider) {
+ m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
+ }
+
+ return S_OK;
}
HRESULT CDX7AllocatorPresenter::AllocSurfaces()
{
- CAutoLock cAutoLock(this);
-
- CRenderersSettings& s = GetRenderersSettings();
-
- m_pVideoTexture = NULL;
- m_pVideoSurface = NULL;
-
- DDSURFACEDESC2 ddsd;
- INITDDSTRUCT(ddsd);
- ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT;
- ddsd.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY;
- ddsd.dwWidth = m_NativeVideoSize.cx;
- ddsd.dwHeight = m_NativeVideoSize.cy;
- ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
- ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
- ddsd.ddpfPixelFormat.dwRGBBitCount = 32;
- ddsd.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
- ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
- ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
-
- if (s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D || s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) {
- ddsd.ddsCaps.dwCaps |= DDSCAPS_TEXTURE;
- // ddsd.ddpfPixelFormat.dwFlags |= DDPF_ALPHAPIXELS;
- // ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = 0xFF000000;
- }
-
- HRESULT hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurface, NULL);
- if (FAILED(hr)) {
- // FIXME: eh, dx9 has no problem creating a 32bpp surface under a 16bpp desktop, but dx7 fails here (textures are ok)
- DDSURFACEDESC2 ddsd2;
- INITDDSTRUCT(ddsd2);
- if (!(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D || s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D)
- && SUCCEEDED(m_pDD->GetDisplayMode(&ddsd2))
- && ddsd2.ddpfPixelFormat.dwRGBBitCount == 16) {
- ddsd.ddpfPixelFormat.dwRGBBitCount = 16;
- ddsd.ddpfPixelFormat.dwRBitMask = 0x0000F800;
- ddsd.ddpfPixelFormat.dwGBitMask = 0x000007E0;
- ddsd.ddpfPixelFormat.dwBBitMask = 0x0000001F;
- hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurface, NULL);
- }
-
- if (FAILED(hr)) {
- return hr;
- }
- }
-
- if (s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) {
- m_pVideoTexture = m_pVideoSurface;
- }
-
- DDBLTFX fx;
- INITDDSTRUCT(fx);
- fx.dwFillColor = 0;
- hr = m_pVideoSurface->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
-
- return S_OK;
+ CAutoLock cAutoLock(this);
+
+ CRenderersSettings& s = GetRenderersSettings();
+
+ m_pVideoTexture = NULL;
+ m_pVideoSurface = NULL;
+
+ DDSURFACEDESC2 ddsd;
+ INITDDSTRUCT(ddsd);
+ ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY;
+ ddsd.dwWidth = m_NativeVideoSize.cx;
+ ddsd.dwHeight = m_NativeVideoSize.cy;
+ ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
+ ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
+ ddsd.ddpfPixelFormat.dwRGBBitCount = 32;
+ ddsd.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
+ ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
+ ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
+
+ if (s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D || s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) {
+ ddsd.ddsCaps.dwCaps |= DDSCAPS_TEXTURE;
+ // ddsd.ddpfPixelFormat.dwFlags |= DDPF_ALPHAPIXELS;
+ // ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = 0xFF000000;
+ }
+
+ HRESULT hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurface, NULL);
+ if (FAILED(hr)) {
+ // FIXME: eh, dx9 has no problem creating a 32bpp surface under a 16bpp desktop, but dx7 fails here (textures are ok)
+ DDSURFACEDESC2 ddsd2;
+ INITDDSTRUCT(ddsd2);
+ if (!(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D || s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D)
+ && SUCCEEDED(m_pDD->GetDisplayMode(&ddsd2))
+ && ddsd2.ddpfPixelFormat.dwRGBBitCount == 16) {
+ ddsd.ddpfPixelFormat.dwRGBBitCount = 16;
+ ddsd.ddpfPixelFormat.dwRBitMask = 0x0000F800;
+ ddsd.ddpfPixelFormat.dwGBitMask = 0x000007E0;
+ ddsd.ddpfPixelFormat.dwBBitMask = 0x0000001F;
+ hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurface, NULL);
+ }
+
+ if (FAILED(hr)) {
+ return hr;
+ }
+ }
+
+ if (s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) {
+ m_pVideoTexture = m_pVideoSurface;
+ }
+
+ DDBLTFX fx;
+ INITDDSTRUCT(fx);
+ fx.dwFillColor = 0;
+ hr = m_pVideoSurface->Blt(NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx);
+
+ return S_OK;
}
void CDX7AllocatorPresenter::DeleteSurfaces()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- m_pVideoTexture = NULL;
- m_pVideoSurface = NULL;
+ m_pVideoTexture = NULL;
+ m_pVideoSurface = NULL;
}
// ISubPicAllocatorPresenter
STDMETHODIMP CDX7AllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP_(bool) CDX7AllocatorPresenter::Paint(bool fAll)
{
- if (m_bPendingResetDevice) {
- SendResetRequest();
- return false;
- }
+ if (m_bPendingResetDevice) {
+ SendResetRequest();
+ return false;
+ }
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- if (m_WindowRect.right <= m_WindowRect.left || m_WindowRect.bottom <= m_WindowRect.top
- || m_NativeVideoSize.cx <= 0 || m_NativeVideoSize.cy <= 0
- || !m_pPrimary || !m_pBackBuffer || !m_pVideoSurface) {
- return false;
- }
+ if (m_WindowRect.right <= m_WindowRect.left || m_WindowRect.bottom <= m_WindowRect.top
+ || m_NativeVideoSize.cx <= 0 || m_NativeVideoSize.cy <= 0
+ || !m_pPrimary || !m_pBackBuffer || !m_pVideoSurface) {
+ return false;
+ }
- HRESULT hr;
+ HRESULT hr;
- CRect rSrcVid(CPoint(0, 0), m_NativeVideoSize);
- CRect rDstVid(m_VideoRect);
+ CRect rSrcVid(CPoint(0, 0), m_NativeVideoSize);
+ CRect rDstVid(m_VideoRect);
- CRect rSrcPri(CPoint(0, 0), m_WindowRect.Size());
- CRect rDstPri(m_WindowRect);
- MapWindowRect(m_hWnd, HWND_DESKTOP, &rDstPri);
+ CRect rSrcPri(CPoint(0, 0), m_WindowRect.Size());
+ CRect rDstPri(m_WindowRect);
+ MapWindowRect(m_hWnd, HWND_DESKTOP, &rDstPri);
- if (fAll) {
- // clear the backbuffer
+ if (fAll) {
+ // clear the backbuffer
- CRect rl(0, 0, rDstVid.left, rSrcPri.bottom);
- CRect rr(rDstVid.right, 0, rSrcPri.right, rSrcPri.bottom);
- CRect rt(0, 0, rSrcPri.right, rDstVid.top);
- CRect rb(0, rDstVid.bottom, rSrcPri.right, rSrcPri.bottom);
+ CRect rl(0, 0, rDstVid.left, rSrcPri.bottom);
+ CRect rr(rDstVid.right, 0, rSrcPri.right, rSrcPri.bottom);
+ CRect rt(0, 0, rSrcPri.right, rDstVid.top);
+ CRect rb(0, rDstVid.bottom, rSrcPri.right, rSrcPri.bottom);
- DDBLTFX fx;
- INITDDSTRUCT(fx);
- fx.dwFillColor = 0;
- hr = m_pBackBuffer->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
+ DDBLTFX fx;
+ INITDDSTRUCT(fx);
+ fx.dwFillColor = 0;
+ hr = m_pBackBuffer->Blt(NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx);
- // paint the video on the backbuffer
+ // paint the video on the backbuffer
- if (!rDstVid.IsRectEmpty()) {
- if (m_pVideoTexture) {
- Vector v[4];
- Transform(rDstVid, v);
- hr = TextureBlt(m_pD3DDev, m_pVideoTexture, v, rSrcVid);
- } else {
- hr = m_pBackBuffer->Blt(rDstVid, m_pVideoSurface, rSrcVid, DDBLT_WAIT, NULL);
- }
- }
+ if (!rDstVid.IsRectEmpty()) {
+ if (m_pVideoTexture) {
+ Vector v[4];
+ Transform(rDstVid, v);
+ hr = TextureBlt(m_pD3DDev, m_pVideoTexture, v, rSrcVid);
+ } else {
+ hr = m_pBackBuffer->Blt(rDstVid, m_pVideoSurface, rSrcVid, DDBLT_WAIT, NULL);
+ }
+ }
- // paint the text on the backbuffer
+ // paint the text on the backbuffer
- AlphaBltSubPic(rSrcPri.Size());
- }
+ AlphaBltSubPic(rSrcPri.Size());
+ }
- // wait vsync
+ // wait vsync
- m_pDD->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, NULL);
+ m_pDD->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, NULL);
- // blt to the primary surface
+ // blt to the primary surface
- hr = m_pPrimary->Blt(rDstPri, m_pBackBuffer, rSrcPri, DDBLT_WAIT, NULL);
+ hr = m_pPrimary->Blt(rDstPri, m_pBackBuffer, rSrcPri, DDBLT_WAIT, NULL);
- if (hr == DDERR_SURFACELOST) {
- m_bPendingResetDevice = true;
- SendResetRequest();
- return false;
- }
+ if (hr == DDERR_SURFACELOST) {
+ m_bPendingResetDevice = true;
+ SendResetRequest();
+ return false;
+ }
- return true;
+ return true;
}
void CDX7AllocatorPresenter::SendResetRequest()
{
- if (!m_bDeviceResetRequested) {
- m_bDeviceResetRequested = true;
- AfxGetApp()->m_pMainWnd->PostMessage(WM_RESET_DEVICE);
- }
+ if (!m_bDeviceResetRequested) {
+ m_bDeviceResetRequested = true;
+ AfxGetApp()->m_pMainWnd->PostMessage(WM_RESET_DEVICE);
+ }
}
STDMETHODIMP_(bool) CDX7AllocatorPresenter::ResetDevice()
{
- HRESULT hr;
- DeleteSurfaces();
- if (FAILED(hr = CreateDevice()) || FAILED(hr = AllocSurfaces())) {
- //DDERR_UNSUPPORTEDMODE - 0x8876024e
- TRACE("ResetDevice failed: 0x%08x\n", (LONG)hr);
- m_bDeviceResetRequested = false;
- return false;
- }
- TRACE("ResetDevice\n");
- m_bPendingResetDevice = false;
- m_bDeviceResetRequested = false;
- return true;
+ HRESULT hr;
+ DeleteSurfaces();
+ if (FAILED(hr = CreateDevice()) || FAILED(hr = AllocSurfaces())) {
+ //DDERR_UNSUPPORTEDMODE - 0x8876024e
+ TRACE("ResetDevice failed: 0x%08x\n", (LONG)hr);
+ m_bDeviceResetRequested = false;
+ return false;
+ }
+ TRACE("ResetDevice\n");
+ m_bPendingResetDevice = false;
+ m_bDeviceResetRequested = false;
+ return true;
}
STDMETHODIMP_(bool) CDX7AllocatorPresenter::DisplayChange()
{
- return true;
+ return true;
}
STDMETHODIMP CDX7AllocatorPresenter::GetDIB(BYTE* lpDib, DWORD* size)
{
- CheckPointer(size, E_POINTER);
-
- HRESULT hr;
-
- DDSURFACEDESC2 ddsd;
- INITDDSTRUCT(ddsd);
- if (FAILED(m_pVideoSurface->GetSurfaceDesc(&ddsd))) {
- return E_FAIL;
- }
-
- if (ddsd.ddpfPixelFormat.dwRGBBitCount != 16 && ddsd.ddpfPixelFormat.dwRGBBitCount != 32) {
- return E_FAIL;
- }
-
- DWORD required = sizeof(BITMAPINFOHEADER) + (ddsd.dwWidth*ddsd.dwHeight*32>>3);
- if (!lpDib) {
- *size = required;
- return S_OK;
- }
- if (*size < required) {
- return E_OUTOFMEMORY;
- }
- *size = required;
-
- INITDDSTRUCT(ddsd);
- if (FAILED(hr = m_pVideoSurface->Lock(NULL, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_READONLY|DDLOCK_NOSYSLOCK, NULL))) {
- // TODO
- return hr;
- }
-
- BITMAPINFOHEADER* bih = (BITMAPINFOHEADER*)lpDib;
- memset(bih, 0, sizeof(BITMAPINFOHEADER));
- bih->biSize = sizeof(BITMAPINFOHEADER);
- bih->biWidth = ddsd.dwWidth;
- bih->biHeight = ddsd.dwHeight;
- bih->biBitCount = 32;
- bih->biPlanes = 1;
- bih->biSizeImage = bih->biWidth*bih->biHeight*bih->biBitCount>>3;
-
- BitBltFromRGBToRGB(
- bih->biWidth, bih->biHeight,
- (BYTE*)(bih + 1), bih->biWidth*bih->biBitCount>>3, bih->biBitCount,
- (BYTE*)ddsd.lpSurface + ddsd.lPitch*(ddsd.dwHeight-1), -(int)ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount);
-
- m_pVideoSurface->Unlock(NULL);
-
- /*
- BitBltFromRGBToRGB(
- w, h,
- (BYTE*)ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount,
- (BYTE*)bm.bmBits, bm.bmWidthBytes, bm.bmBitsPixel);
- m_pVideoSurfaceOff->Unlock(NULL);
- fOk = true;
- }
- */
-
- return S_OK;
+ CheckPointer(size, E_POINTER);
+
+ HRESULT hr;
+
+ DDSURFACEDESC2 ddsd;
+ INITDDSTRUCT(ddsd);
+ if (FAILED(m_pVideoSurface->GetSurfaceDesc(&ddsd))) {
+ return E_FAIL;
+ }
+
+ if (ddsd.ddpfPixelFormat.dwRGBBitCount != 16 && ddsd.ddpfPixelFormat.dwRGBBitCount != 32) {
+ return E_FAIL;
+ }
+
+ DWORD required = sizeof(BITMAPINFOHEADER) + (ddsd.dwWidth * ddsd.dwHeight * 32 >> 3);
+ if (!lpDib) {
+ *size = required;
+ return S_OK;
+ }
+ if (*size < required) {
+ return E_OUTOFMEMORY;
+ }
+ *size = required;
+
+ INITDDSTRUCT(ddsd);
+ if (FAILED(hr = m_pVideoSurface->Lock(NULL, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR | DDLOCK_READONLY | DDLOCK_NOSYSLOCK, NULL))) {
+ // TODO
+ return hr;
+ }
+
+ BITMAPINFOHEADER* bih = (BITMAPINFOHEADER*)lpDib;
+ memset(bih, 0, sizeof(BITMAPINFOHEADER));
+ bih->biSize = sizeof(BITMAPINFOHEADER);
+ bih->biWidth = ddsd.dwWidth;
+ bih->biHeight = ddsd.dwHeight;
+ bih->biBitCount = 32;
+ bih->biPlanes = 1;
+ bih->biSizeImage = bih->biWidth * bih->biHeight * bih->biBitCount >> 3;
+
+ BitBltFromRGBToRGB(
+ bih->biWidth, bih->biHeight,
+ (BYTE*)(bih + 1), bih->biWidth * bih->biBitCount >> 3, bih->biBitCount,
+ (BYTE*)ddsd.lpSurface + ddsd.lPitch * (ddsd.dwHeight - 1), -(int)ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount);
+
+ m_pVideoSurface->Unlock(NULL);
+
+ /*
+ BitBltFromRGBToRGB(
+ w, h,
+ (BYTE*)ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount,
+ (BYTE*)bm.bmBits, bm.bmWidthBytes, bm.bmBitsPixel);
+ m_pVideoSurfaceOff->Unlock(NULL);
+ fOk = true;
+ }
+ */
+
+ return S_OK;
}
diff --git a/src/filters/renderer/VideoRenderers/DX7AllocatorPresenter.h b/src/filters/renderer/VideoRenderers/DX7AllocatorPresenter.h
index 5e1ec29d2..4f098ec27 100644
--- a/src/filters/renderer/VideoRenderers/DX7AllocatorPresenter.h
+++ b/src/filters/renderer/VideoRenderers/DX7AllocatorPresenter.h
@@ -31,36 +31,36 @@
namespace DSObjects
{
- class CDX7AllocatorPresenter
- : public CSubPicAllocatorPresenterImpl
- {
- protected:
- CSize m_ScreenSize;
+ class CDX7AllocatorPresenter
+ : public CSubPicAllocatorPresenterImpl
+ {
+ protected:
+ CSize m_ScreenSize;
- CComPtr<IDirectDraw7> m_pDD;
- CComQIPtr<IDirect3D7, &IID_IDirect3D7> m_pD3D;
- CComPtr<IDirect3DDevice7> m_pD3DDev;
+ CComPtr<IDirectDraw7> m_pDD;
+ CComQIPtr<IDirect3D7, &IID_IDirect3D7> m_pD3D;
+ CComPtr<IDirect3DDevice7> m_pD3DDev;
- CComPtr<IDirectDrawSurface7> m_pPrimary;
- CComPtr<IDirectDrawSurface7> m_pBackBuffer;
- CComPtr<IDirectDrawSurface7> m_pVideoTexture;
- CComPtr<IDirectDrawSurface7> m_pVideoSurface;
+ CComPtr<IDirectDrawSurface7> m_pPrimary;
+ CComPtr<IDirectDrawSurface7> m_pBackBuffer;
+ CComPtr<IDirectDrawSurface7> m_pVideoTexture;
+ CComPtr<IDirectDrawSurface7> m_pVideoSurface;
- virtual HRESULT CreateDevice();
- virtual HRESULT AllocSurfaces();
- virtual void DeleteSurfaces();
+ virtual HRESULT CreateDevice();
+ virtual HRESULT AllocSurfaces();
+ virtual void DeleteSurfaces();
- void SendResetRequest();
+ void SendResetRequest();
- public:
- CDX7AllocatorPresenter(HWND hWnd, HRESULT& hr);
+ public:
+ CDX7AllocatorPresenter(HWND hWnd, HRESULT& hr);
- // ISubPicAllocatorPresenter
- STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
- STDMETHODIMP_(bool) Paint(bool fAll);
- STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size);
- STDMETHODIMP_(bool) ResetDevice();
- STDMETHODIMP_(bool) DisplayChange();
- };
+ // ISubPicAllocatorPresenter
+ STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
+ STDMETHODIMP_(bool) Paint(bool fAll);
+ STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size);
+ STDMETHODIMP_(bool) ResetDevice();
+ STDMETHODIMP_(bool) DisplayChange();
+ };
}
diff --git a/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp
index 61f53b161..4a3585b46 100644
--- a/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp
@@ -37,163 +37,163 @@ bool queue_ffdshow_support = false;
// only for debugging
//#define DISABLE_USING_D3D9EX
-#define FRAMERATE_MAX_DELTA 3000
+#define FRAMERATE_MAX_DELTA 3000
using namespace DSObjects;
// CDX9AllocatorPresenter
-CDX9AllocatorPresenter::CDX9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRESULT& hr, bool bIsEVR, CString &_Error)
- : CDX9RenderingEngine(hWnd, hr, &_Error)
- , m_RefreshRate(0)
- , m_nTearingPos(0)
- , m_nVMR9Surfaces(0)
- , m_iVMR9Surface(0)
- , m_rtTimePerFrame(0)
- , m_bInterlaced(false)
- , m_nUsedBuffer(0)
- , m_OrderedPaint(0)
- , m_bCorrectedFrameTime(0)
- , m_FrameTimeCorrection(0)
- , m_LastSampleTime(0)
- , m_LastFrameDuration(0)
- , m_bAlternativeVSync(0)
- , m_bIsEVR(bIsEVR)
- , m_VSyncMode(0)
- , m_TextScale(1.0)
- , m_MainThreadId(0)
- , m_bNeedCheckSample(true)
- , m_pDirectDraw(NULL)
- , m_hVSyncThread(NULL)
- , m_hEvtQuit(NULL)
- , m_bIsFullscreen(bFullscreen)
- , m_Decoder(_T(""))
- , m_nFrameType(PICT_NONE)
+CDX9AllocatorPresenter::CDX9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRESULT& hr, bool bIsEVR, CString& _Error)
+ : CDX9RenderingEngine(hWnd, hr, &_Error)
+ , m_RefreshRate(0)
+ , m_nTearingPos(0)
+ , m_nVMR9Surfaces(0)
+ , m_iVMR9Surface(0)
+ , m_rtTimePerFrame(0)
+ , m_bInterlaced(false)
+ , m_nUsedBuffer(0)
+ , m_OrderedPaint(0)
+ , m_bCorrectedFrameTime(0)
+ , m_FrameTimeCorrection(0)
+ , m_LastSampleTime(0)
+ , m_LastFrameDuration(0)
+ , m_bAlternativeVSync(0)
+ , m_bIsEVR(bIsEVR)
+ , m_VSyncMode(0)
+ , m_TextScale(1.0)
+ , m_MainThreadId(0)
+ , m_bNeedCheckSample(true)
+ , m_pDirectDraw(NULL)
+ , m_hVSyncThread(NULL)
+ , m_hEvtQuit(NULL)
+ , m_bIsFullscreen(bFullscreen)
+ , m_Decoder(_T(""))
+ , m_nFrameType(PICT_NONE)
{
- HINSTANCE hDll;
-
- if (FAILED(hr)) {
- _Error += L"ISubPicAllocatorPresenterImpl failed\n";
- return;
- }
-
- m_pD3DXLoadSurfaceFromMemory = NULL;
- m_pD3DXLoadSurfaceFromSurface = NULL;
- m_pD3DXCreateLine = NULL;
- m_pD3DXCreateFont = NULL;
- m_pD3DXCreateSprite = NULL;
- hDll = GetRenderersData()->GetD3X9Dll();
- if (hDll) {
- (FARPROC&)m_pD3DXLoadSurfaceFromMemory = GetProcAddress(hDll, "D3DXLoadSurfaceFromMemory");
- (FARPROC&)m_pD3DXLoadSurfaceFromSurface = GetProcAddress(hDll, "D3DXLoadSurfaceFromSurface");
- (FARPROC&)m_pD3DXCreateLine = GetProcAddress(hDll, "D3DXCreateLine");
- (FARPROC&)m_pD3DXCreateFont = GetProcAddress(hDll, "D3DXCreateFontW");
- (FARPROC&)m_pD3DXCreateSprite = GetProcAddress(hDll, "D3DXCreateSprite");
- } else {
- _Error += L"The installed DirectX End-User Runtime is outdated. Please download and install the ";
- _Error += MPC_DX_SDK_MONTH " " MAKE_STR(MPC_DX_SDK_YEAR);
- _Error += L" release or newer in order for MPC-HC to function properly.\n";
- }
-
- m_pDwmIsCompositionEnabled = NULL;
- m_pDwmEnableComposition = NULL;
- m_hDWMAPI = LoadLibrary(L"dwmapi.dll");
- if (m_hDWMAPI) {
- (FARPROC &)m_pDwmIsCompositionEnabled = GetProcAddress(m_hDWMAPI, "DwmIsCompositionEnabled");
- (FARPROC &)m_pDwmEnableComposition = GetProcAddress(m_hDWMAPI, "DwmEnableComposition");
- }
-
- m_pDirect3DCreate9Ex = NULL;
- m_hD3D9 = LoadLibrary(L"d3d9.dll");
+ HINSTANCE hDll;
+
+ if (FAILED(hr)) {
+ _Error += L"ISubPicAllocatorPresenterImpl failed\n";
+ return;
+ }
+
+ m_pD3DXLoadSurfaceFromMemory = NULL;
+ m_pD3DXLoadSurfaceFromSurface = NULL;
+ m_pD3DXCreateLine = NULL;
+ m_pD3DXCreateFont = NULL;
+ m_pD3DXCreateSprite = NULL;
+ hDll = GetRenderersData()->GetD3X9Dll();
+ if (hDll) {
+ (FARPROC&)m_pD3DXLoadSurfaceFromMemory = GetProcAddress(hDll, "D3DXLoadSurfaceFromMemory");
+ (FARPROC&)m_pD3DXLoadSurfaceFromSurface = GetProcAddress(hDll, "D3DXLoadSurfaceFromSurface");
+ (FARPROC&)m_pD3DXCreateLine = GetProcAddress(hDll, "D3DXCreateLine");
+ (FARPROC&)m_pD3DXCreateFont = GetProcAddress(hDll, "D3DXCreateFontW");
+ (FARPROC&)m_pD3DXCreateSprite = GetProcAddress(hDll, "D3DXCreateSprite");
+ } else {
+ _Error += L"The installed DirectX End-User Runtime is outdated. Please download and install the ";
+ _Error += MPC_DX_SDK_MONTH " " MAKE_STR(MPC_DX_SDK_YEAR);
+ _Error += L" release or newer in order for MPC-HC to function properly.\n";
+ }
+
+ m_pDwmIsCompositionEnabled = NULL;
+ m_pDwmEnableComposition = NULL;
+ m_hDWMAPI = LoadLibrary(L"dwmapi.dll");
+ if (m_hDWMAPI) {
+ (FARPROC&)m_pDwmIsCompositionEnabled = GetProcAddress(m_hDWMAPI, "DwmIsCompositionEnabled");
+ (FARPROC&)m_pDwmEnableComposition = GetProcAddress(m_hDWMAPI, "DwmEnableComposition");
+ }
+
+ m_pDirect3DCreate9Ex = NULL;
+ m_hD3D9 = LoadLibrary(L"d3d9.dll");
#ifndef DISABLE_USING_D3D9EX
- if (m_hD3D9) {
- (FARPROC &)m_pDirect3DCreate9Ex = GetProcAddress(m_hD3D9, "Direct3DCreate9Ex");
- }
+ if (m_hD3D9) {
+ (FARPROC&)m_pDirect3DCreate9Ex = GetProcAddress(m_hD3D9, "Direct3DCreate9Ex");
+ }
#endif
- if (m_pDirect3DCreate9Ex) {
- m_pDirect3DCreate9Ex(D3D_SDK_VERSION, &m_pD3DEx);
- if (!m_pD3DEx) {
- m_pDirect3DCreate9Ex(D3D9b_SDK_VERSION, &m_pD3DEx);
- }
- }
- if (!m_pD3DEx) {
- m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
- if (!m_pD3D) {
- m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
- }
- } else {
- m_pD3D = m_pD3DEx;
- }
-
- m_DetectedFrameRate = 0.0;
- m_DetectedFrameTime = 0.0;
- m_DetectedFrameTimeStdDev = 0.0;
- m_DetectedLock = false;
- ZeroMemory(m_DetectedFrameTimeHistory, sizeof(m_DetectedFrameTimeHistory));
- ZeroMemory(m_DetectedFrameTimeHistoryHistory, sizeof(m_DetectedFrameTimeHistoryHistory));
- m_DetectedFrameTimePos = 0;
- ZeroMemory(&m_VMR9AlphaBitmap, sizeof(m_VMR9AlphaBitmap));
-
- ZeroMemory(m_ldDetectedRefreshRateList, sizeof(m_ldDetectedRefreshRateList));
- ZeroMemory(m_ldDetectedScanlineRateList, sizeof(m_ldDetectedScanlineRateList));
- m_DetectedRefreshRatePos = 0;
- m_DetectedRefreshTimePrim = 0;
- m_DetectedScanlineTime = 0;
- m_DetectedScanlineTimePrim = 0;
- m_DetectedRefreshRate = 0;
- CRenderersSettings& s = GetRenderersSettings();
-
- if (s.m_RenderSettings.iVMRDisableDesktopComposition) {
- m_bDesktopCompositionDisabled = true;
- if (m_pDwmEnableComposition) {
- m_pDwmEnableComposition(0);
- }
- } else {
- m_bDesktopCompositionDisabled = false;
- }
-
- hr = CreateDevice(_Error);
-
- memset (m_pllJitter, 0, sizeof(m_pllJitter));
- memset (m_pllSyncOffset, 0, sizeof(m_pllSyncOffset));
- m_nNextJitter = 0;
- m_nNextSyncOffset = 0;
- m_llLastPerf = 0;
- m_fAvrFps = 0.0;
- m_fJitterStdDev = 0.0;
- m_fSyncOffsetStdDev = 0.0;
- m_fSyncOffsetAvr = 0.0;
- m_bSyncStatsAvailable = false;
+ if (m_pDirect3DCreate9Ex) {
+ m_pDirect3DCreate9Ex(D3D_SDK_VERSION, &m_pD3DEx);
+ if (!m_pD3DEx) {
+ m_pDirect3DCreate9Ex(D3D9b_SDK_VERSION, &m_pD3DEx);
+ }
+ }
+ if (!m_pD3DEx) {
+ m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
+ if (!m_pD3D) {
+ m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
+ }
+ } else {
+ m_pD3D = m_pD3DEx;
+ }
+
+ m_DetectedFrameRate = 0.0;
+ m_DetectedFrameTime = 0.0;
+ m_DetectedFrameTimeStdDev = 0.0;
+ m_DetectedLock = false;
+ ZeroMemory(m_DetectedFrameTimeHistory, sizeof(m_DetectedFrameTimeHistory));
+ ZeroMemory(m_DetectedFrameTimeHistoryHistory, sizeof(m_DetectedFrameTimeHistoryHistory));
+ m_DetectedFrameTimePos = 0;
+ ZeroMemory(&m_VMR9AlphaBitmap, sizeof(m_VMR9AlphaBitmap));
+
+ ZeroMemory(m_ldDetectedRefreshRateList, sizeof(m_ldDetectedRefreshRateList));
+ ZeroMemory(m_ldDetectedScanlineRateList, sizeof(m_ldDetectedScanlineRateList));
+ m_DetectedRefreshRatePos = 0;
+ m_DetectedRefreshTimePrim = 0;
+ m_DetectedScanlineTime = 0;
+ m_DetectedScanlineTimePrim = 0;
+ m_DetectedRefreshRate = 0;
+ CRenderersSettings& s = GetRenderersSettings();
+
+ if (s.m_RenderSettings.iVMRDisableDesktopComposition) {
+ m_bDesktopCompositionDisabled = true;
+ if (m_pDwmEnableComposition) {
+ m_pDwmEnableComposition(0);
+ }
+ } else {
+ m_bDesktopCompositionDisabled = false;
+ }
+
+ hr = CreateDevice(_Error);
+
+ memset(m_pllJitter, 0, sizeof(m_pllJitter));
+ memset(m_pllSyncOffset, 0, sizeof(m_pllSyncOffset));
+ m_nNextJitter = 0;
+ m_nNextSyncOffset = 0;
+ m_llLastPerf = 0;
+ m_fAvrFps = 0.0;
+ m_fJitterStdDev = 0.0;
+ m_fSyncOffsetStdDev = 0.0;
+ m_fSyncOffsetAvr = 0.0;
+ m_bSyncStatsAvailable = false;
}
CDX9AllocatorPresenter::~CDX9AllocatorPresenter()
{
- if (m_bDesktopCompositionDisabled) {
- m_bDesktopCompositionDisabled = false;
- if (m_pDwmEnableComposition) {
- m_pDwmEnableComposition(1);
- }
- }
-
- StopWorkerThreads();
- m_pFont = NULL;
- m_pLine = NULL;
- m_pD3DDev = NULL;
- m_pD3DDevEx = NULL;
-
- CleanupRenderingEngine();
-
- m_pD3D = NULL;
- m_pD3DEx = NULL;
- if (m_hDWMAPI) {
- FreeLibrary(m_hDWMAPI);
- m_hDWMAPI = NULL;
- }
- if (m_hD3D9) {
- FreeLibrary(m_hD3D9);
- m_hD3D9 = NULL;
- }
+ if (m_bDesktopCompositionDisabled) {
+ m_bDesktopCompositionDisabled = false;
+ if (m_pDwmEnableComposition) {
+ m_pDwmEnableComposition(1);
+ }
+ }
+
+ StopWorkerThreads();
+ m_pFont = NULL;
+ m_pLine = NULL;
+ m_pD3DDev = NULL;
+ m_pD3DDevEx = NULL;
+
+ CleanupRenderingEngine();
+
+ m_pD3D = NULL;
+ m_pD3DEx = NULL;
+ if (m_hDWMAPI) {
+ FreeLibrary(m_hDWMAPI);
+ m_hDWMAPI = NULL;
+ }
+ if (m_hD3D9) {
+ FreeLibrary(m_hD3D9);
+ m_hD3D9 = NULL;
+ }
}
void ModerateFloat(double& Value, double Target, double& ValuePrim, double ChangeSpeed);
@@ -203,2192 +203,2192 @@ class CRandom31
{
public:
- CRandom31() {
- m_Seed = 12164;
- }
-
- void f_SetSeed(int32 _Seed) {
- m_Seed = _Seed;
- }
- int32 f_GetSeed() {
- return m_Seed;
- }
- /*
- Park and Miller's psuedo-random number generator.
- */
- int32 m_Seed;
- int32 f_Get() {
- static const int32 A = 16807;
- static const int32 M = 2147483647; // 2^31 - 1
- static const int32 q = M / A; // M / A
- static const int32 r = M % A; // M % A
- m_Seed = A * (m_Seed % q) - r * (m_Seed / q);
- if (m_Seed < 0) {
- m_Seed += M;
- }
- return m_Seed;
- }
-
- static int32 fs_Max() {
- return 2147483646;
- }
-
- double f_GetFloat() {
- return double(f_Get()) * (1.0 / double(fs_Max()));
- }
+ CRandom31() {
+ m_Seed = 12164;
+ }
+
+ void f_SetSeed(int32 _Seed) {
+ m_Seed = _Seed;
+ }
+ int32 f_GetSeed() {
+ return m_Seed;
+ }
+ /*
+ Park and Miller's psuedo-random number generator.
+ */
+ int32 m_Seed;
+ int32 f_Get() {
+ static const int32 A = 16807;
+ static const int32 M = 2147483647; // 2^31 - 1
+ static const int32 q = M / A; // M / A
+ static const int32 r = M % A; // M % A
+ m_Seed = A * (m_Seed % q) - r * (m_Seed / q);
+ if (m_Seed < 0) {
+ m_Seed += M;
+ }
+ return m_Seed;
+ }
+
+ static int32 fs_Max() {
+ return 2147483646;
+ }
+
+ double f_GetFloat() {
+ return double(f_Get()) * (1.0 / double(fs_Max()));
+ }
};
class CVSyncEstimation
{
private:
- class CHistoryEntry
- {
- public:
- CHistoryEntry() {
- m_Time = 0;
- m_ScanLine = -1;
- }
- LONGLONG m_Time;
- int m_ScanLine;
- };
-
- class CSolution
- {
- public:
- CSolution() {
- m_ScanLines = 1000;
- m_ScanLinesPerSecond = m_ScanLines * 100;
- }
- int m_ScanLines;
- double m_ScanLinesPerSecond;
- double m_SqrSum;
-
- void f_Mutate(double _Amount, CRandom31 &_Random, int _MinScans) {
- int ToDo = _Random.f_Get() % 10;
- if (ToDo == 0) {
- m_ScanLines = m_ScanLines / 2;
- } else if (ToDo == 1) {
- m_ScanLines = m_ScanLines * 2;
- }
-
- m_ScanLines = m_ScanLines * (1.0 + (_Random.f_GetFloat() * _Amount) - _Amount * 0.5);
- m_ScanLines = max(m_ScanLines, _MinScans);
-
- if (ToDo == 2) {
- m_ScanLinesPerSecond /= (_Random.f_Get() % 4) + 1;
- } else if (ToDo == 3) {
- m_ScanLinesPerSecond *= (_Random.f_Get() % 4) + 1;
- }
-
- m_ScanLinesPerSecond *= 1.0 + (_Random.f_GetFloat() * _Amount) - _Amount * 0.5;
- }
-
- void f_SpawnInto(CSolution &_Other, CRandom31 &_Random, int _MinScans) {
- _Other = *this;
- _Other.f_Mutate(_Random.f_GetFloat() * 0.1, _Random, _MinScans);
- }
-
- static int fs_Compare(const void *_pFirst, const void *_pSecond) {
- const CSolution *pFirst = (const CSolution *)_pFirst;
- const CSolution *pSecond = (const CSolution *)_pSecond;
- if (pFirst->m_SqrSum < pSecond->m_SqrSum) {
- return -1;
- } else if (pFirst->m_SqrSum > pSecond->m_SqrSum) {
- return 1;
- }
- return 0;
- }
-
-
- };
-
- enum {
- ENumHistory = 128
- };
-
- CHistoryEntry m_History[ENumHistory];
- int m_iHistory;
- CSolution m_OldSolutions[2];
-
- CRandom31 m_Random;
-
-
- double fp_GetSquareSum(double _ScansPerSecond, double _ScanLines) {
- double SquareSum = 0;
- int nHistory = min(m_nHistory, ENumHistory);
- int iHistory = m_iHistory - nHistory;
- if (iHistory < 0) {
- iHistory += ENumHistory;
- }
- for (int i = 1; i < nHistory; ++i) {
- int iHistory0 = iHistory + i - 1;
- int iHistory1 = iHistory + i;
- if (iHistory0 < 0) {
- iHistory0 += ENumHistory;
- }
- iHistory0 = iHistory0 % ENumHistory;
- iHistory1 = iHistory1 % ENumHistory;
- ASSERT(m_History[iHistory0].m_Time != 0);
- ASSERT(m_History[iHistory1].m_Time != 0);
-
- double DeltaTime = (m_History[iHistory1].m_Time - m_History[iHistory0].m_Time)/10000000.0;
- double PredictedScanLine = m_History[iHistory0].m_ScanLine + DeltaTime * _ScansPerSecond;
- PredictedScanLine = fmod(PredictedScanLine, _ScanLines);
- double Delta = (m_History[iHistory1].m_ScanLine - PredictedScanLine);
- double DeltaSqr = Delta * Delta;
- SquareSum += DeltaSqr;
- }
- return SquareSum;
- }
-
- int m_nHistory;
+ class CHistoryEntry
+ {
+ public:
+ CHistoryEntry() {
+ m_Time = 0;
+ m_ScanLine = -1;
+ }
+ LONGLONG m_Time;
+ int m_ScanLine;
+ };
+
+ class CSolution
+ {
+ public:
+ CSolution() {
+ m_ScanLines = 1000;
+ m_ScanLinesPerSecond = m_ScanLines * 100;
+ }
+ int m_ScanLines;
+ double m_ScanLinesPerSecond;
+ double m_SqrSum;
+
+ void f_Mutate(double _Amount, CRandom31& _Random, int _MinScans) {
+ int ToDo = _Random.f_Get() % 10;
+ if (ToDo == 0) {
+ m_ScanLines = m_ScanLines / 2;
+ } else if (ToDo == 1) {
+ m_ScanLines = m_ScanLines * 2;
+ }
+
+ m_ScanLines = m_ScanLines * (1.0 + (_Random.f_GetFloat() * _Amount) - _Amount * 0.5);
+ m_ScanLines = max(m_ScanLines, _MinScans);
+
+ if (ToDo == 2) {
+ m_ScanLinesPerSecond /= (_Random.f_Get() % 4) + 1;
+ } else if (ToDo == 3) {
+ m_ScanLinesPerSecond *= (_Random.f_Get() % 4) + 1;
+ }
+
+ m_ScanLinesPerSecond *= 1.0 + (_Random.f_GetFloat() * _Amount) - _Amount * 0.5;
+ }
+
+ void f_SpawnInto(CSolution& _Other, CRandom31& _Random, int _MinScans) {
+ _Other = *this;
+ _Other.f_Mutate(_Random.f_GetFloat() * 0.1, _Random, _MinScans);
+ }
+
+ static int fs_Compare(const void* _pFirst, const void* _pSecond) {
+ const CSolution* pFirst = (const CSolution*)_pFirst;
+ const CSolution* pSecond = (const CSolution*)_pSecond;
+ if (pFirst->m_SqrSum < pSecond->m_SqrSum) {
+ return -1;
+ } else if (pFirst->m_SqrSum > pSecond->m_SqrSum) {
+ return 1;
+ }
+ return 0;
+ }
+
+
+ };
+
+ enum {
+ ENumHistory = 128
+ };
+
+ CHistoryEntry m_History[ENumHistory];
+ int m_iHistory;
+ CSolution m_OldSolutions[2];
+
+ CRandom31 m_Random;
+
+
+ double fp_GetSquareSum(double _ScansPerSecond, double _ScanLines) {
+ double SquareSum = 0;
+ int nHistory = min(m_nHistory, ENumHistory);
+ int iHistory = m_iHistory - nHistory;
+ if (iHistory < 0) {
+ iHistory += ENumHistory;
+ }
+ for (int i = 1; i < nHistory; ++i) {
+ int iHistory0 = iHistory + i - 1;
+ int iHistory1 = iHistory + i;
+ if (iHistory0 < 0) {
+ iHistory0 += ENumHistory;
+ }
+ iHistory0 = iHistory0 % ENumHistory;
+ iHistory1 = iHistory1 % ENumHistory;
+ ASSERT(m_History[iHistory0].m_Time != 0);
+ ASSERT(m_History[iHistory1].m_Time != 0);
+
+ double DeltaTime = (m_History[iHistory1].m_Time - m_History[iHistory0].m_Time) / 10000000.0;
+ double PredictedScanLine = m_History[iHistory0].m_ScanLine + DeltaTime * _ScansPerSecond;
+ PredictedScanLine = fmod(PredictedScanLine, _ScanLines);
+ double Delta = (m_History[iHistory1].m_ScanLine - PredictedScanLine);
+ double DeltaSqr = Delta * Delta;
+ SquareSum += DeltaSqr;
+ }
+ return SquareSum;
+ }
+
+ int m_nHistory;
public:
- CVSyncEstimation() {
- m_iHistory = 0;
- m_nHistory = 0;
- }
-
- void f_AddSample(int _ScanLine, LONGLONG _Time) {
- m_History[m_iHistory].m_ScanLine = _ScanLine;
- m_History[m_iHistory].m_Time = _Time;
- ++m_nHistory;
- m_iHistory = (m_iHistory + 1) % ENumHistory;
- }
-
- void f_GetEstimation(double &_RefreshRate, int &_ScanLines, int _ScreenSizeY, int _WindowsRefreshRate) {
- _RefreshRate = 0;
- _ScanLines = 0;
-
- int iHistory = m_iHistory;
- // We have a full history
- if (m_nHistory > 10) {
- for (int l = 0; l < 5; ++l) {
- const int nSol = 3+5+5+3;
- CSolution Solutions[nSol];
-
- Solutions[0] = m_OldSolutions[0];
- Solutions[1] = m_OldSolutions[1];
- Solutions[2].m_ScanLines = _ScreenSizeY;
- Solutions[2].m_ScanLinesPerSecond = _ScreenSizeY * _WindowsRefreshRate;
-
- int iStart = 3;
- for (int i = iStart; i < iStart + 5; ++i) {
- Solutions[0].f_SpawnInto(Solutions[i], m_Random, _ScreenSizeY);
- }
- iStart += 5;
- for (int i = iStart; i < iStart + 5; ++i) {
- Solutions[1].f_SpawnInto(Solutions[i], m_Random, _ScreenSizeY);
- }
- iStart += 5;
- for (int i = iStart; i < iStart + 3; ++i) {
- Solutions[2].f_SpawnInto(Solutions[i], m_Random, _ScreenSizeY);
- }
-
- int Start = 2;
- if (l == 0) {
- Start = 0;
- }
- for (int i = Start; i < nSol; ++i) {
- Solutions[i].m_SqrSum = fp_GetSquareSum(Solutions[i].m_ScanLinesPerSecond, Solutions[i].m_ScanLines);
- }
-
- qsort(Solutions, nSol, sizeof(Solutions[0]), &CSolution::fs_Compare);
- for (int i = 0; i < 2; ++i) {
- m_OldSolutions[i] = Solutions[i];
- }
- }
-
- _ScanLines = m_OldSolutions[0].m_ScanLines + 0.5;
- _RefreshRate = 1.0 / (m_OldSolutions[0].m_ScanLines / m_OldSolutions[0].m_ScanLinesPerSecond);
- } else {
- m_OldSolutions[0].m_ScanLines = _ScreenSizeY;
- m_OldSolutions[1].m_ScanLines = _ScreenSizeY;
- }
- }
+ CVSyncEstimation() {
+ m_iHistory = 0;
+ m_nHistory = 0;
+ }
+
+ void f_AddSample(int _ScanLine, LONGLONG _Time) {
+ m_History[m_iHistory].m_ScanLine = _ScanLine;
+ m_History[m_iHistory].m_Time = _Time;
+ ++m_nHistory;
+ m_iHistory = (m_iHistory + 1) % ENumHistory;
+ }
+
+ void f_GetEstimation(double& _RefreshRate, int& _ScanLines, int _ScreenSizeY, int _WindowsRefreshRate) {
+ _RefreshRate = 0;
+ _ScanLines = 0;
+
+ int iHistory = m_iHistory;
+ // We have a full history
+ if (m_nHistory > 10) {
+ for (int l = 0; l < 5; ++l) {
+ const int nSol = 3 + 5 + 5 + 3;
+ CSolution Solutions[nSol];
+
+ Solutions[0] = m_OldSolutions[0];
+ Solutions[1] = m_OldSolutions[1];
+ Solutions[2].m_ScanLines = _ScreenSizeY;
+ Solutions[2].m_ScanLinesPerSecond = _ScreenSizeY * _WindowsRefreshRate;
+
+ int iStart = 3;
+ for (int i = iStart; i < iStart + 5; ++i) {
+ Solutions[0].f_SpawnInto(Solutions[i], m_Random, _ScreenSizeY);
+ }
+ iStart += 5;
+ for (int i = iStart; i < iStart + 5; ++i) {
+ Solutions[1].f_SpawnInto(Solutions[i], m_Random, _ScreenSizeY);
+ }
+ iStart += 5;
+ for (int i = iStart; i < iStart + 3; ++i) {
+ Solutions[2].f_SpawnInto(Solutions[i], m_Random, _ScreenSizeY);
+ }
+
+ int Start = 2;
+ if (l == 0) {
+ Start = 0;
+ }
+ for (int i = Start; i < nSol; ++i) {
+ Solutions[i].m_SqrSum = fp_GetSquareSum(Solutions[i].m_ScanLinesPerSecond, Solutions[i].m_ScanLines);
+ }
+
+ qsort(Solutions, nSol, sizeof(Solutions[0]), &CSolution::fs_Compare);
+ for (int i = 0; i < 2; ++i) {
+ m_OldSolutions[i] = Solutions[i];
+ }
+ }
+
+ _ScanLines = m_OldSolutions[0].m_ScanLines + 0.5;
+ _RefreshRate = 1.0 / (m_OldSolutions[0].m_ScanLines / m_OldSolutions[0].m_ScanLinesPerSecond);
+ } else {
+ m_OldSolutions[0].m_ScanLines = _ScreenSizeY;
+ m_OldSolutions[1].m_ScanLines = _ScreenSizeY;
+ }
+ }
};
#endif
void CDX9AllocatorPresenter::VSyncThread()
{
- HANDLE hEvts[] = { m_hEvtQuit};
- bool bQuit = false;
- TIMECAPS tc;
- DWORD dwResolution;
- DWORD dwUser = 0;
-
- //DWORD dwTaskIndex = 0;
- //// Tell Vista Multimedia Class Scheduler we are a playback thread (increase priority)
- //if (pfAvSetMmThreadCharacteristicsW)
- // hAvrt = pfAvSetMmThreadCharacteristicsW (L"Playback", &dwTaskIndex);
- //if (pfAvSetMmThreadPriority)
- // pfAvSetMmThreadPriority (hAvrt, AVRT_PRIORITY_HIGH /*AVRT_PRIORITY_CRITICAL*/);
-
- timeGetDevCaps(&tc, sizeof(TIMECAPS));
- dwResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
- dwUser = timeBeginPeriod(dwResolution);
- CRenderersData *pApp = GetRenderersData();
- CRenderersSettings& s = GetRenderersSettings();
-
- while (!bQuit) {
-
- DWORD dwObject = WaitForMultipleObjects (_countof(hEvts), hEvts, FALSE, 1);
- switch (dwObject) {
- case WAIT_OBJECT_0 :
- bQuit = true;
- break;
- case WAIT_TIMEOUT : {
- // Do our stuff
- if (m_pD3DDev && s.m_RenderSettings.iVMR9VSync) {
-
- int VSyncPos = GetVBlackPos();
- int WaitRange = max(m_ScreenSize.cy / 40, 5);
- int MinRange = max(min(int(0.003 * double(m_ScreenSize.cy) * double(m_RefreshRate) + 0.5), m_ScreenSize.cy/3), 5); // 1.8 ms or max 33 % of Time
-
- VSyncPos += MinRange + WaitRange;
-
- VSyncPos = VSyncPos % m_ScreenSize.cy;
- if (VSyncPos < 0) {
- VSyncPos += m_ScreenSize.cy;
- }
-
- int ScanLine = 0;
- int StartScanLine = ScanLine;
- UNREFERENCED_PARAMETER(StartScanLine);
- int LastPos = ScanLine;
- UNREFERENCED_PARAMETER(LastPos);
- ScanLine = (VSyncPos + 1) % m_ScreenSize.cy;
- if (ScanLine < 0) {
- ScanLine += m_ScreenSize.cy;
- }
- int ScanLineMiddle = ScanLine + m_ScreenSize.cy/2;
- ScanLineMiddle = ScanLineMiddle % m_ScreenSize.cy;
- if (ScanLineMiddle < 0) {
- ScanLineMiddle += m_ScreenSize.cy;
- }
-
- int ScanlineStart = ScanLine;
- bool bTakenLock;
- WaitForVBlankRange(ScanlineStart, 5, true, true, false, bTakenLock);
- LONGLONG TimeStart = pApp->GetPerfCounter();
-
- WaitForVBlankRange(ScanLineMiddle, 5, true, true, false, bTakenLock);
- LONGLONG TimeMiddle = pApp->GetPerfCounter();
-
- int ScanlineEnd = ScanLine;
- WaitForVBlankRange(ScanlineEnd, 5, true, true, false, bTakenLock);
- LONGLONG TimeEnd = pApp->GetPerfCounter();
-
- double nSeconds = double(TimeEnd - TimeStart) / 10000000.0;
- LONGLONG DiffMiddle = TimeMiddle - TimeStart;
- LONGLONG DiffEnd = TimeEnd - TimeMiddle;
- double DiffDiff;
- if (DiffEnd > DiffMiddle) {
- DiffDiff = double(DiffEnd) / double(DiffMiddle);
- } else {
- DiffDiff = double(DiffMiddle) / double(DiffEnd);
- }
- if (nSeconds > 0.003 && DiffDiff < 1.3) {
- double ScanLineSeconds;
- double nScanLines;
- if (ScanLineMiddle > ScanlineEnd) {
- ScanLineSeconds = double(TimeMiddle - TimeStart) / 10000000.0;
- nScanLines = ScanLineMiddle - ScanlineStart;
- } else {
- ScanLineSeconds = double(TimeEnd - TimeMiddle) / 10000000.0;
- nScanLines = ScanlineEnd - ScanLineMiddle;
- }
-
- double ScanLineTime = ScanLineSeconds / nScanLines;
-
- int iPos = m_DetectedRefreshRatePos % 100;
- m_ldDetectedScanlineRateList[iPos] = ScanLineTime;
- if (m_DetectedScanlineTime && ScanlineStart != ScanlineEnd) {
- int Diff = ScanlineEnd - ScanlineStart;
- nSeconds -= double(Diff) * m_DetectedScanlineTime;
- }
- m_ldDetectedRefreshRateList[iPos] = nSeconds;
- double Average = 0;
- double AverageScanline = 0;
- int nPos = min(iPos + 1, 100);
- for (int i = 0; i < nPos; ++i) {
- Average += m_ldDetectedRefreshRateList[i];
- AverageScanline += m_ldDetectedScanlineRateList[i];
- }
-
- if (nPos) {
- Average /= double(nPos);
- AverageScanline /= double(nPos);
- } else {
- Average = 0;
- AverageScanline = 0;
- }
-
- double ThisValue = Average;
-
- if (Average > 0.0 && AverageScanline > 0.0) {
- CAutoLock Lock(&m_RefreshRateLock);
- ++m_DetectedRefreshRatePos;
- if (m_DetectedRefreshTime == 0 || m_DetectedRefreshTime / ThisValue > 1.01 || m_DetectedRefreshTime / ThisValue < 0.99) {
- m_DetectedRefreshTime = ThisValue;
- m_DetectedRefreshTimePrim = 0;
- }
- if (_isnan(m_DetectedRefreshTime)) {m_DetectedRefreshTime = 0.0;}
- if (_isnan(m_DetectedRefreshTimePrim)) {m_DetectedRefreshTimePrim = 0.0;}
-
- ModerateFloat(m_DetectedRefreshTime, ThisValue, m_DetectedRefreshTimePrim, 1.5);
- if (m_DetectedRefreshTime > 0.0) {
- m_DetectedRefreshRate = 1.0/m_DetectedRefreshTime;
- } else {
- m_DetectedRefreshRate = 0.0;
- }
-
- if (m_DetectedScanlineTime == 0 || m_DetectedScanlineTime / AverageScanline > 1.01 || m_DetectedScanlineTime / AverageScanline < 0.99) {
- m_DetectedScanlineTime = AverageScanline;
- m_DetectedScanlineTimePrim = 0;
- }
- ModerateFloat(m_DetectedScanlineTime, AverageScanline, m_DetectedScanlineTimePrim, 1.5);
- if (m_DetectedScanlineTime > 0.0) {
- m_DetectedScanlinesPerFrame = m_DetectedRefreshTime / m_DetectedScanlineTime;
- } else {
- m_DetectedScanlinesPerFrame = 0;
- }
- }
- //TRACE("Refresh: %f\n", RefreshRate);
- }
- } else {
- m_DetectedRefreshRate = 0.0;
- m_DetectedScanlinesPerFrame = 0.0;
- }
- }
- break;
- }
- }
-
- timeEndPeriod (dwResolution);
- //if (pfAvRevertMmThreadCharacteristics) pfAvRevertMmThreadCharacteristics (hAvrt);
+ HANDLE hEvts[] = { m_hEvtQuit};
+ bool bQuit = false;
+ TIMECAPS tc;
+ DWORD dwResolution;
+ DWORD dwUser = 0;
+
+ //DWORD dwTaskIndex = 0;
+ //// Tell Vista Multimedia Class Scheduler we are a playback thread (increase priority)
+ //if (pfAvSetMmThreadCharacteristicsW)
+ // hAvrt = pfAvSetMmThreadCharacteristicsW (L"Playback", &dwTaskIndex);
+ //if (pfAvSetMmThreadPriority)
+ // pfAvSetMmThreadPriority (hAvrt, AVRT_PRIORITY_HIGH /*AVRT_PRIORITY_CRITICAL*/);
+
+ timeGetDevCaps(&tc, sizeof(TIMECAPS));
+ dwResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
+ dwUser = timeBeginPeriod(dwResolution);
+ CRenderersData* pApp = GetRenderersData();
+ CRenderersSettings& s = GetRenderersSettings();
+
+ while (!bQuit) {
+
+ DWORD dwObject = WaitForMultipleObjects(_countof(hEvts), hEvts, FALSE, 1);
+ switch (dwObject) {
+ case WAIT_OBJECT_0 :
+ bQuit = true;
+ break;
+ case WAIT_TIMEOUT : {
+ // Do our stuff
+ if (m_pD3DDev && s.m_RenderSettings.iVMR9VSync) {
+
+ int VSyncPos = GetVBlackPos();
+ int WaitRange = max(m_ScreenSize.cy / 40, 5);
+ int MinRange = max(min(int(0.003 * double(m_ScreenSize.cy) * double(m_RefreshRate) + 0.5), m_ScreenSize.cy / 3), 5); // 1.8 ms or max 33 % of Time
+
+ VSyncPos += MinRange + WaitRange;
+
+ VSyncPos = VSyncPos % m_ScreenSize.cy;
+ if (VSyncPos < 0) {
+ VSyncPos += m_ScreenSize.cy;
+ }
+
+ int ScanLine = 0;
+ int StartScanLine = ScanLine;
+ UNREFERENCED_PARAMETER(StartScanLine);
+ int LastPos = ScanLine;
+ UNREFERENCED_PARAMETER(LastPos);
+ ScanLine = (VSyncPos + 1) % m_ScreenSize.cy;
+ if (ScanLine < 0) {
+ ScanLine += m_ScreenSize.cy;
+ }
+ int ScanLineMiddle = ScanLine + m_ScreenSize.cy / 2;
+ ScanLineMiddle = ScanLineMiddle % m_ScreenSize.cy;
+ if (ScanLineMiddle < 0) {
+ ScanLineMiddle += m_ScreenSize.cy;
+ }
+
+ int ScanlineStart = ScanLine;
+ bool bTakenLock;
+ WaitForVBlankRange(ScanlineStart, 5, true, true, false, bTakenLock);
+ LONGLONG TimeStart = pApp->GetPerfCounter();
+
+ WaitForVBlankRange(ScanLineMiddle, 5, true, true, false, bTakenLock);
+ LONGLONG TimeMiddle = pApp->GetPerfCounter();
+
+ int ScanlineEnd = ScanLine;
+ WaitForVBlankRange(ScanlineEnd, 5, true, true, false, bTakenLock);
+ LONGLONG TimeEnd = pApp->GetPerfCounter();
+
+ double nSeconds = double(TimeEnd - TimeStart) / 10000000.0;
+ LONGLONG DiffMiddle = TimeMiddle - TimeStart;
+ LONGLONG DiffEnd = TimeEnd - TimeMiddle;
+ double DiffDiff;
+ if (DiffEnd > DiffMiddle) {
+ DiffDiff = double(DiffEnd) / double(DiffMiddle);
+ } else {
+ DiffDiff = double(DiffMiddle) / double(DiffEnd);
+ }
+ if (nSeconds > 0.003 && DiffDiff < 1.3) {
+ double ScanLineSeconds;
+ double nScanLines;
+ if (ScanLineMiddle > ScanlineEnd) {
+ ScanLineSeconds = double(TimeMiddle - TimeStart) / 10000000.0;
+ nScanLines = ScanLineMiddle - ScanlineStart;
+ } else {
+ ScanLineSeconds = double(TimeEnd - TimeMiddle) / 10000000.0;
+ nScanLines = ScanlineEnd - ScanLineMiddle;
+ }
+
+ double ScanLineTime = ScanLineSeconds / nScanLines;
+
+ int iPos = m_DetectedRefreshRatePos % 100;
+ m_ldDetectedScanlineRateList[iPos] = ScanLineTime;
+ if (m_DetectedScanlineTime && ScanlineStart != ScanlineEnd) {
+ int Diff = ScanlineEnd - ScanlineStart;
+ nSeconds -= double(Diff) * m_DetectedScanlineTime;
+ }
+ m_ldDetectedRefreshRateList[iPos] = nSeconds;
+ double Average = 0;
+ double AverageScanline = 0;
+ int nPos = min(iPos + 1, 100);
+ for (int i = 0; i < nPos; ++i) {
+ Average += m_ldDetectedRefreshRateList[i];
+ AverageScanline += m_ldDetectedScanlineRateList[i];
+ }
+
+ if (nPos) {
+ Average /= double(nPos);
+ AverageScanline /= double(nPos);
+ } else {
+ Average = 0;
+ AverageScanline = 0;
+ }
+
+ double ThisValue = Average;
+
+ if (Average > 0.0 && AverageScanline > 0.0) {
+ CAutoLock Lock(&m_RefreshRateLock);
+ ++m_DetectedRefreshRatePos;
+ if (m_DetectedRefreshTime == 0 || m_DetectedRefreshTime / ThisValue > 1.01 || m_DetectedRefreshTime / ThisValue < 0.99) {
+ m_DetectedRefreshTime = ThisValue;
+ m_DetectedRefreshTimePrim = 0;
+ }
+ if (_isnan(m_DetectedRefreshTime)) {m_DetectedRefreshTime = 0.0;}
+ if (_isnan(m_DetectedRefreshTimePrim)) {m_DetectedRefreshTimePrim = 0.0;}
+
+ ModerateFloat(m_DetectedRefreshTime, ThisValue, m_DetectedRefreshTimePrim, 1.5);
+ if (m_DetectedRefreshTime > 0.0) {
+ m_DetectedRefreshRate = 1.0 / m_DetectedRefreshTime;
+ } else {
+ m_DetectedRefreshRate = 0.0;
+ }
+
+ if (m_DetectedScanlineTime == 0 || m_DetectedScanlineTime / AverageScanline > 1.01 || m_DetectedScanlineTime / AverageScanline < 0.99) {
+ m_DetectedScanlineTime = AverageScanline;
+ m_DetectedScanlineTimePrim = 0;
+ }
+ ModerateFloat(m_DetectedScanlineTime, AverageScanline, m_DetectedScanlineTimePrim, 1.5);
+ if (m_DetectedScanlineTime > 0.0) {
+ m_DetectedScanlinesPerFrame = m_DetectedRefreshTime / m_DetectedScanlineTime;
+ } else {
+ m_DetectedScanlinesPerFrame = 0;
+ }
+ }
+ //TRACE("Refresh: %f\n", RefreshRate);
+ }
+ } else {
+ m_DetectedRefreshRate = 0.0;
+ m_DetectedScanlinesPerFrame = 0.0;
+ }
+ }
+ break;
+ }
+ }
+
+ timeEndPeriod(dwResolution);
+ //if (pfAvRevertMmThreadCharacteristics) pfAvRevertMmThreadCharacteristics (hAvrt);
}
DWORD WINAPI CDX9AllocatorPresenter::VSyncThreadStatic(LPVOID lpParam)
{
- SetThreadName((DWORD)-1, "CDX9Presenter::VSyncThread");
- CDX9AllocatorPresenter* pThis = (CDX9AllocatorPresenter*) lpParam;
- pThis->VSyncThread();
- return 0;
+ SetThreadName((DWORD) - 1, "CDX9Presenter::VSyncThread");
+ CDX9AllocatorPresenter* pThis = (CDX9AllocatorPresenter*) lpParam;
+ pThis->VSyncThread();
+ return 0;
}
void CDX9AllocatorPresenter::StartWorkerThreads()
{
- DWORD dwThreadId;
-
- if ( m_bIsEVR ) {
- m_hEvtQuit = CreateEvent( NULL, TRUE, FALSE, NULL );
- if ( m_hEvtQuit != NULL ) { // Don't create a thread with no stop switch
- m_hVSyncThread = ::CreateThread( NULL, 0, VSyncThreadStatic, (LPVOID)this, 0, &dwThreadId );
- if ( m_hVSyncThread != NULL ) {
- SetThreadPriority( m_hVSyncThread, THREAD_PRIORITY_HIGHEST );
- }
- }
- }
+ DWORD dwThreadId;
+
+ if (m_bIsEVR) {
+ m_hEvtQuit = CreateEvent(NULL, TRUE, FALSE, NULL);
+ if (m_hEvtQuit != NULL) { // Don't create a thread with no stop switch
+ m_hVSyncThread = ::CreateThread(NULL, 0, VSyncThreadStatic, (LPVOID)this, 0, &dwThreadId);
+ if (m_hVSyncThread != NULL) {
+ SetThreadPriority(m_hVSyncThread, THREAD_PRIORITY_HIGHEST);
+ }
+ }
+ }
}
void CDX9AllocatorPresenter::StopWorkerThreads()
{
- if ( m_bIsEVR ) {
- if ( m_hEvtQuit != NULL ) {
- SetEvent( m_hEvtQuit );
-
- if ( m_hVSyncThread != NULL ) {
- if ( WaitForSingleObject(m_hVSyncThread, 10000) == WAIT_TIMEOUT ) {
- ASSERT(FALSE);
- TerminateThread( m_hVSyncThread, 0xDEAD );
- }
-
- CloseHandle( m_hVSyncThread );
- m_hVSyncThread = NULL;
- }
-
- CloseHandle( m_hEvtQuit );
- m_hEvtQuit = NULL;
- }
- }
+ if (m_bIsEVR) {
+ if (m_hEvtQuit != NULL) {
+ SetEvent(m_hEvtQuit);
+
+ if (m_hVSyncThread != NULL) {
+ if (WaitForSingleObject(m_hVSyncThread, 10000) == WAIT_TIMEOUT) {
+ ASSERT(FALSE);
+ TerminateThread(m_hVSyncThread, 0xDEAD);
+ }
+
+ CloseHandle(m_hVSyncThread);
+ m_hVSyncThread = NULL;
+ }
+
+ CloseHandle(m_hEvtQuit);
+ m_hEvtQuit = NULL;
+ }
+ }
}
bool CDX9AllocatorPresenter::SettingsNeedResetDevice()
{
- CRenderersSettings& s = GetRenderersSettings();
- CRenderersSettings::CRendererSettingsEVR & New = GetRenderersSettings().m_RenderSettings;
- CRenderersSettings::CRendererSettingsEVR & Current = m_LastRendererSettings;
-
- bool bRet = false;
-
- bRet = bRet || New.fVMR9AlterativeVSync != Current.fVMR9AlterativeVSync;
- bRet = bRet || New.iVMR9VSyncAccurate != Current.iVMR9VSyncAccurate;
-
- if (m_bIsFullscreen) {
- bRet = bRet || New.iVMR9FullscreenGUISupport != Current.iVMR9FullscreenGUISupport;
- } else {
- if (Current.iVMRDisableDesktopComposition) {
- if (!m_bDesktopCompositionDisabled) {
- m_bDesktopCompositionDisabled = true;
- if (m_pDwmEnableComposition) {
- m_pDwmEnableComposition(0);
- }
- }
- } else {
- if (m_bDesktopCompositionDisabled) {
- m_bDesktopCompositionDisabled = false;
- if (m_pDwmEnableComposition) {
- m_pDwmEnableComposition(1);
- }
- }
- }
- }
-
- if (m_bIsEVR) {
- bRet = bRet || New.iEVRHighColorResolution != Current.iEVRHighColorResolution;
- bRet = bRet || New.iEVRForceInputHighColorResolution != Current.iEVRForceInputHighColorResolution;
- }
-
- m_LastRendererSettings = s.m_RenderSettings;
-
- return bRet;
+ CRenderersSettings& s = GetRenderersSettings();
+ CRenderersSettings::CRendererSettingsEVR& New = GetRenderersSettings().m_RenderSettings;
+ CRenderersSettings::CRendererSettingsEVR& Current = m_LastRendererSettings;
+
+ bool bRet = false;
+
+ bRet = bRet || New.fVMR9AlterativeVSync != Current.fVMR9AlterativeVSync;
+ bRet = bRet || New.iVMR9VSyncAccurate != Current.iVMR9VSyncAccurate;
+
+ if (m_bIsFullscreen) {
+ bRet = bRet || New.iVMR9FullscreenGUISupport != Current.iVMR9FullscreenGUISupport;
+ } else {
+ if (Current.iVMRDisableDesktopComposition) {
+ if (!m_bDesktopCompositionDisabled) {
+ m_bDesktopCompositionDisabled = true;
+ if (m_pDwmEnableComposition) {
+ m_pDwmEnableComposition(0);
+ }
+ }
+ } else {
+ if (m_bDesktopCompositionDisabled) {
+ m_bDesktopCompositionDisabled = false;
+ if (m_pDwmEnableComposition) {
+ m_pDwmEnableComposition(1);
+ }
+ }
+ }
+ }
+
+ if (m_bIsEVR) {
+ bRet = bRet || New.iEVRHighColorResolution != Current.iEVRHighColorResolution;
+ bRet = bRet || New.iEVRForceInputHighColorResolution != Current.iEVRForceInputHighColorResolution;
+ }
+
+ m_LastRendererSettings = s.m_RenderSettings;
+
+ return bRet;
}
-HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error)
+HRESULT CDX9AllocatorPresenter::CreateDevice(CString& _Error)
{
- StopWorkerThreads();
-
- CRenderersSettings& s = GetRenderersSettings();
- CRenderersData* renderersData = GetRenderersData();
-
- m_VBlankEndWait = 0;
- m_VBlankMin = 300000;
- m_VBlankMinCalc = 300000;
- m_VBlankMax = 0;
- m_VBlankStartWait = 0;
- m_VBlankWaitTime = 0;
- m_VBlankLockTime = 0;
- m_PresentWaitTime = 0;
- m_PresentWaitTimeMin = 3000000000;
- m_PresentWaitTimeMax = 0;
-
- m_LastRendererSettings = s.m_RenderSettings;
-
- m_VBlankEndPresent = -100000;
- m_VBlankStartMeasureTime = 0;
- m_VBlankStartMeasure = 0;
-
- m_PaintTime = 0;
- m_PaintTimeMin = 3000000000;
- m_PaintTimeMax = 0;
-
- m_RasterStatusWaitTime = 0;
- m_RasterStatusWaitTimeMin = 3000000000;
- m_RasterStatusWaitTimeMax = 0;
- m_RasterStatusWaitTimeMaxCalc = 0;
-
- m_ClockDiff = 0.0;
- m_ClockDiffPrim = 0.0;
- m_ClockDiffCalc = 0.0;
-
- m_ModeratedTimeSpeed = 1.0;
- m_ModeratedTimeSpeedDiff = 0.0;
- m_ModeratedTimeSpeedPrim = 0;
- ZeroMemory(m_TimeChangeHistory, sizeof(m_TimeChangeHistory));
- ZeroMemory(m_ClockChangeHistory, sizeof(m_ClockChangeHistory));
- m_ClockTimeChangeHistoryPos = 0;
-
- m_pD3DDev = NULL;
- m_pD3DDevEx = NULL;
- m_pDirectDraw = NULL;
-
- CleanupRenderingEngine();
-
- if (!m_pD3D) {
- _Error += L"Failed to create D3D9\n";
- return E_UNEXPECTED;
- }
-
- HRESULT hr = S_OK;
- m_CurrentAdapter = GetAdapter(m_pD3D);
-
- /* // TODO : add nVidia PerfHUD !!!
-
- // Set default settings
- UINT AdapterToUse=D3DADAPTER_DEFAULT;
- D3DDEVTYPE DeviceType=D3DDEVTYPE_HAL;
-
- #if SHIPPING_VERSION
- // When building a shipping version, disable PerfHUD (opt-out)
- #else
- // Look for 'NVIDIA PerfHUD' adapter
- // If it is present, override default settings
- for (UINT Adapter=0;Adapter<g_pD3D->GetAdapterCount();Adapter++)
- {
- D3DADAPTER_IDENTIFIER9 Identifier;
- HRESULT Res;
-
- Res = g_pD3D->GetAdapterIdentifier(Adapter,0,&Identifier);
- if (strstr(Identifier.Description,"PerfHUD") != 0)
- {
- AdapterToUse=Adapter;
- DeviceType=D3DDEVTYPE_REF;
- break;
- }
- }
- #endif
-
- if (FAILED(g_pD3D->CreateDevice( AdapterToUse, DeviceType, hWnd,
- D3DCREATE_HARDWARE_VERTEXPROCESSING,
- &d3dpp, &g_pd3dDevice) ) )
- {
- return E_FAIL;
- }
- */
-
-
-//#define ENABLE_DDRAWSYNC
+ StopWorkerThreads();
+
+ CRenderersSettings& s = GetRenderersSettings();
+ CRenderersData* renderersData = GetRenderersData();
+
+ m_VBlankEndWait = 0;
+ m_VBlankMin = 300000;
+ m_VBlankMinCalc = 300000;
+ m_VBlankMax = 0;
+ m_VBlankStartWait = 0;
+ m_VBlankWaitTime = 0;
+ m_VBlankLockTime = 0;
+ m_PresentWaitTime = 0;
+ m_PresentWaitTimeMin = 3000000000;
+ m_PresentWaitTimeMax = 0;
+
+ m_LastRendererSettings = s.m_RenderSettings;
+
+ m_VBlankEndPresent = -100000;
+ m_VBlankStartMeasureTime = 0;
+ m_VBlankStartMeasure = 0;
+
+ m_PaintTime = 0;
+ m_PaintTimeMin = 3000000000;
+ m_PaintTimeMax = 0;
+
+ m_RasterStatusWaitTime = 0;
+ m_RasterStatusWaitTimeMin = 3000000000;
+ m_RasterStatusWaitTimeMax = 0;
+ m_RasterStatusWaitTimeMaxCalc = 0;
+
+ m_ClockDiff = 0.0;
+ m_ClockDiffPrim = 0.0;
+ m_ClockDiffCalc = 0.0;
+
+ m_ModeratedTimeSpeed = 1.0;
+ m_ModeratedTimeSpeedDiff = 0.0;
+ m_ModeratedTimeSpeedPrim = 0;
+ ZeroMemory(m_TimeChangeHistory, sizeof(m_TimeChangeHistory));
+ ZeroMemory(m_ClockChangeHistory, sizeof(m_ClockChangeHistory));
+ m_ClockTimeChangeHistoryPos = 0;
+
+ m_pD3DDev = NULL;
+ m_pD3DDevEx = NULL;
+ m_pDirectDraw = NULL;
+
+ CleanupRenderingEngine();
+
+ if (!m_pD3D) {
+ _Error += L"Failed to create D3D9\n";
+ return E_UNEXPECTED;
+ }
+
+ HRESULT hr = S_OK;
+ m_CurrentAdapter = GetAdapter(m_pD3D);
+
+ /* // TODO : add nVidia PerfHUD !!!
+
+ // Set default settings
+ UINT AdapterToUse=D3DADAPTER_DEFAULT;
+ D3DDEVTYPE DeviceType=D3DDEVTYPE_HAL;
+
+ #if SHIPPING_VERSION
+ // When building a shipping version, disable PerfHUD (opt-out)
+ #else
+ // Look for 'NVIDIA PerfHUD' adapter
+ // If it is present, override default settings
+ for (UINT Adapter=0;Adapter<g_pD3D->GetAdapterCount();Adapter++)
+ {
+ D3DADAPTER_IDENTIFIER9 Identifier;
+ HRESULT Res;
+
+ Res = g_pD3D->GetAdapterIdentifier(Adapter,0,&Identifier);
+ if (strstr(Identifier.Description,"PerfHUD") != 0)
+ {
+ AdapterToUse=Adapter;
+ DeviceType=D3DDEVTYPE_REF;
+ break;
+ }
+ }
+ #endif
+
+ if (FAILED(g_pD3D->CreateDevice( AdapterToUse, DeviceType, hWnd,
+ D3DCREATE_HARDWARE_VERTEXPROCESSING,
+ &d3dpp, &g_pd3dDevice) ) )
+ {
+ return E_FAIL;
+ }
+ */
+
+
+ //#define ENABLE_DDRAWSYNC
#ifdef ENABLE_DDRAWSYNC
- hr = DirectDrawCreate(NULL, &m_pDirectDraw, NULL) ;
- if (hr == S_OK) {
- hr = m_pDirectDraw->SetCooperativeLevel(m_hWnd, DDSCL_NORMAL) ;
- }
+ hr = DirectDrawCreate(NULL, &m_pDirectDraw, NULL) ;
+ if (hr == S_OK) {
+ hr = m_pDirectDraw->SetCooperativeLevel(m_hWnd, DDSCL_NORMAL) ;
+ }
#endif
- D3DPRESENT_PARAMETERS pp;
- ZeroMemory(&pp, sizeof(pp));
-
- BOOL bCompositionEnabled = false;
- if (m_pDwmIsCompositionEnabled) {
- m_pDwmIsCompositionEnabled(&bCompositionEnabled);
- }
-
- m_bCompositionEnabled = !!bCompositionEnabled;
- m_bAlternativeVSync = s.m_RenderSettings.fVMR9AlterativeVSync;
-
- // detect FP textures support
- renderersData->m_bFP16Support = SUCCEEDED(m_pD3D->CheckDeviceFormat(m_CurrentAdapter, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_QUERY_FILTER, D3DRTYPE_VOLUMETEXTURE, D3DFMT_A32B32G32R32F));
-
- // detect 10-bit textures support
- renderersData->m_b10bitSupport = SUCCEEDED(m_pD3D->CheckDeviceFormat(m_CurrentAdapter, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_QUERY_FILTER, D3DRTYPE_TEXTURE, D3DFMT_A2R10G10B10));
-
- // set settings that depend on hardware feature support
- m_bForceInputHighColorResolution = s.m_RenderSettings.iEVRForceInputHighColorResolution && m_bIsEVR && renderersData->m_b10bitSupport;
- m_bHighColorResolution = s.m_RenderSettings.iEVRHighColorResolution && m_bIsEVR && renderersData->m_b10bitSupport;
- m_bFullFloatingPointProcessing = s.m_RenderSettings.iVMR9FullFloatingPointProcessing && renderersData->m_bFP16Support;
- m_bHalfFloatingPointProcessing = s.m_RenderSettings.iVMR9HalfFloatingPointProcessing && renderersData->m_bFP16Support && !m_bFullFloatingPointProcessing;
-
-
- // set color formats
- if (m_bFullFloatingPointProcessing) {
- m_SurfaceType = D3DFMT_A32B32G32R32F;
- } else if (m_bHalfFloatingPointProcessing) {
- m_SurfaceType = D3DFMT_A16B16G16R16F;
- } else if (m_bForceInputHighColorResolution || m_bHighColorResolution) {
- m_SurfaceType = D3DFMT_A2R10G10B10;
- } else {
- if (m_nPCIVendor == PCIV_ATI)
- m_SurfaceType = D3DFMT_X8R8G8B8;
- else
- m_SurfaceType = D3DFMT_A8R8G8B8;
- }
-
- D3DDISPLAYMODEEX DisplayMode;
- ZeroMemory(&DisplayMode, sizeof(DisplayMode));
- DisplayMode.Size = sizeof(DisplayMode);
- D3DDISPLAYMODE d3ddm;
- ZeroMemory(&d3ddm, sizeof(d3ddm));
-
- if (m_bIsFullscreen) {
- if (m_bHighColorResolution) {
- pp.BackBufferFormat = D3DFMT_A2R10G10B10;
- } else {
- pp.BackBufferFormat = D3DFMT_X8R8G8B8;
- }
- pp.Windowed = false;
- pp.BackBufferCount = 3;
- pp.SwapEffect = D3DSWAPEFFECT_FLIP;
- // there's no Desktop composition to take care of alternative vSync in exclusive mode, alternative vSync is therefore unused
- pp.hDeviceWindow = m_hWnd;
- pp.Flags = D3DPRESENTFLAG_VIDEO;
- if (s.m_RenderSettings.iVMR9FullscreenGUISupport && !m_bHighColorResolution) {
- pp.Flags |= D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
- }
- m_D3DDevExError = L"No m_pD3DEx";
- if (m_pD3DEx) {
- m_pD3DEx->GetAdapterDisplayModeEx(m_CurrentAdapter, &DisplayMode, NULL);
-
- DisplayMode.Format = pp.BackBufferFormat;
- m_ScreenSize.SetSize(DisplayMode.Width, DisplayMode.Height);
- pp.FullScreen_RefreshRateInHz = m_RefreshRate = DisplayMode.RefreshRate;
- pp.BackBufferWidth = m_ScreenSize.cx;
- pp.BackBufferHeight = m_ScreenSize.cy;
-
- hr = m_pD3DEx->CreateDeviceEx(
- m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd,
- GetVertexProcessing() | D3DCREATE_FPU_PRESERVE | D3DCREATE_MULTITHREADED | D3DCREATE_ENABLE_PRESENTSTATS, //D3DCREATE_MANAGED
- &pp, &DisplayMode, &m_pD3DDevEx);
-
- m_D3DDevExError = GetWindowsErrorMessage(hr, m_hD3D9);
- if (m_pD3DDevEx) {
- m_pD3DDev = m_pD3DDevEx;
- m_BackbufferType = pp.BackBufferFormat;
- m_DisplayType = DisplayMode.Format;
- }
- }
- if (!m_pD3DDev) {
- m_pD3D->GetAdapterDisplayMode(m_CurrentAdapter, &d3ddm);
- d3ddm.Format = pp.BackBufferFormat;
- m_ScreenSize.SetSize(d3ddm.Width, d3ddm.Height);
- pp.FullScreen_RefreshRateInHz = m_RefreshRate = d3ddm.RefreshRate;
- pp.BackBufferWidth = m_ScreenSize.cx;
- pp.BackBufferHeight = m_ScreenSize.cy;
-
- hr = m_pD3D->CreateDevice(
- m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd,
- GetVertexProcessing() | D3DCREATE_FPU_PRESERVE | D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
- &pp, &m_pD3DDev);
- m_DisplayType = d3ddm.Format;
- m_BackbufferType = pp.BackBufferFormat;
- }
- if (m_pD3DDev && s.m_RenderSettings.iVMR9FullscreenGUISupport && !m_bHighColorResolution) {
- m_pD3DDev->SetDialogBoxMode(true);
- //if (m_pD3DDev->SetDialogBoxMode(true) != S_OK)
- // ExitProcess(0);
- }
- } else {
- pp.Windowed = TRUE;
- pp.hDeviceWindow = m_hWnd;
- pp.SwapEffect = D3DSWAPEFFECT_COPY;
- pp.Flags = D3DPRESENTFLAG_VIDEO;
- pp.BackBufferCount = 1;
- if (bCompositionEnabled || m_bAlternativeVSync) {
- // Desktop composition takes care of the VSYNC
- pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
- }
-
- if (m_pD3DEx) {
- m_pD3DEx->GetAdapterDisplayModeEx(m_CurrentAdapter, &DisplayMode, NULL);
- m_ScreenSize.SetSize(DisplayMode.Width, DisplayMode.Height);
- m_RefreshRate = DisplayMode.RefreshRate;
- pp.BackBufferWidth = m_ScreenSize.cx;
- pp.BackBufferHeight = m_ScreenSize.cy;
-
- // We can get 0x8876086a here when switching from two displays to one display using Win + P (Windows 7)
- // Cause: We might not reinitialize dx correctly during the switch
- hr = m_pD3DEx->CreateDeviceEx(
- m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd,
- GetVertexProcessing() | D3DCREATE_FPU_PRESERVE | D3DCREATE_MULTITHREADED | D3DCREATE_ENABLE_PRESENTSTATS, //D3DCREATE_MANAGED
- &pp, NULL, &m_pD3DDevEx);
- if (m_pD3DDevEx) {
- m_pD3DDev = m_pD3DDevEx;
- m_DisplayType = DisplayMode.Format;
- }
- }
- if (!m_pD3DDev) {
- m_pD3D->GetAdapterDisplayMode(m_CurrentAdapter, &d3ddm);
- m_ScreenSize.SetSize(d3ddm.Width, d3ddm.Height);
- m_RefreshRate = d3ddm.RefreshRate;
- pp.BackBufferWidth = m_ScreenSize.cx;
- pp.BackBufferHeight = m_ScreenSize.cy;
-
- hr = m_pD3D->CreateDevice(
- m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd,
- GetVertexProcessing() | D3DCREATE_FPU_PRESERVE | D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
- &pp, &m_pD3DDev);
- m_DisplayType = d3ddm.Format;
- }
- m_BackbufferType = pp.BackBufferFormat;
- }
-
- while (hr == D3DERR_DEVICELOST) {
- TRACE("D3DERR_DEVICELOST. Trying to Reset.\n");
- hr = m_pD3DDev->TestCooperativeLevel();
- }
- if (hr == D3DERR_DEVICENOTRESET) {
- TRACE("D3DERR_DEVICENOTRESET\n");
- hr = m_pD3DDev->Reset(&pp);
- }
-
- TRACE("CreateDevice: %d\n", (LONG)hr);
- ASSERT (SUCCEEDED (hr));
-
- m_MainThreadId = GetCurrentThreadId();
-
- if (m_pD3DDevEx) {
- m_pD3DDevEx->SetGPUThreadPriority(7);
- }
-
- if (FAILED(hr)) {
- _Error += L"CreateDevice failed\n";
- CStringW str;
- str.Format(L"Error code: 0x%X\n", hr);
- _Error += str;
-
- return hr;
- }
-
- // Get the device caps
- ZeroMemory(&m_Caps, sizeof(m_Caps));
- m_pD3DDev->GetDeviceCaps(&m_Caps);
-
- // Initialize the rendering engine
- InitRenderingEngine();
-
- CComPtr<ISubPicProvider> pSubPicProvider;
- if (m_pSubPicQueue) {
- m_pSubPicQueue->GetSubPicProvider(&pSubPicProvider);
- }
-
- CSize size;
- switch (GetRenderersSettings().nSPCMaxRes) {
- case 0:
- default:
- size = m_ScreenSize;
- break;
- case 1:
- size.SetSize(1024, 768);
- break;
- case 2:
- size.SetSize(800, 600);
- break;
- case 3:
- size.SetSize(640, 480);
- break;
- case 4:
- size.SetSize(512, 384);
- break;
- case 5:
- size.SetSize(384, 288);
- break;
- case 6:
- size.SetSize(2560, 1600);
- break;
- case 7:
- size.SetSize(1920, 1080);
- break;
- case 8:
- size.SetSize(1320, 900);
- break;
- case 9:
- size.SetSize(1280, 720);
- break;
- }
-
- if (m_pAllocator) {
- m_pAllocator->ChangeDevice(m_pD3DDev);
- } else {
- m_pAllocator = DNew CDX9SubPicAllocator(m_pD3DDev, size, GetRenderersSettings().fSPCPow2Tex, false);
- if (!m_pAllocator) {
- _Error += L"CDX9SubPicAllocator failed\n";
-
- return E_FAIL;
- }
- }
-
- hr = S_OK;
- m_pSubPicQueue = GetRenderersSettings().nSPCSize > 0
- ? (ISubPicQueue*)DNew CSubPicQueue(GetRenderersSettings().nSPCSize, !GetRenderersSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
- : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
- if (!m_pSubPicQueue || FAILED(hr)) {
- _Error += L"m_pSubPicQueue failed\n";
-
- return E_FAIL;
- }
-
- if (pSubPicProvider) {
- m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
- }
-
- m_pFont = NULL;
- if (m_pD3DXCreateFont) {
- int MinSize = 1600;
- int CurrentSize = min(m_ScreenSize.cx, MinSize);
- double Scale = double(CurrentSize) / double(MinSize);
- m_TextScale = Scale;
- m_pD3DXCreateFont( m_pD3DDev, // D3D device
- (int)(-24.0*Scale), // Height
- (UINT)(-11.0*Scale), // Width
- CurrentSize < 800 ? FW_NORMAL : FW_BOLD, // Weight
- 0, // MipLevels, 0 = autogen mipmaps
- FALSE, // Italic
- DEFAULT_CHARSET, // CharSet
- OUT_DEFAULT_PRECIS, // OutputPrecision
- ANTIALIASED_QUALITY, // Quality
- FIXED_PITCH | FF_DONTCARE, // PitchAndFamily
- L"Lucida Console", // pFaceName
- &m_pFont); // ppFont
- }
-
-
- m_pSprite = NULL;
-
- if (m_pD3DXCreateSprite) {
- m_pD3DXCreateSprite( m_pD3DDev, // D3D device
- &m_pSprite);
- }
-
- m_pLine = NULL;
- if (m_pD3DXCreateLine) {
- m_pD3DXCreateLine (m_pD3DDev, &m_pLine);
- }
-
- m_LastAdapterCheck = GetRenderersData()->GetPerfCounter();
-
- StartWorkerThreads();
-
- return S_OK;
+ D3DPRESENT_PARAMETERS pp;
+ ZeroMemory(&pp, sizeof(pp));
+
+ BOOL bCompositionEnabled = false;
+ if (m_pDwmIsCompositionEnabled) {
+ m_pDwmIsCompositionEnabled(&bCompositionEnabled);
+ }
+
+ m_bCompositionEnabled = !!bCompositionEnabled;
+ m_bAlternativeVSync = s.m_RenderSettings.fVMR9AlterativeVSync;
+
+ // detect FP textures support
+ renderersData->m_bFP16Support = SUCCEEDED(m_pD3D->CheckDeviceFormat(m_CurrentAdapter, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_QUERY_FILTER, D3DRTYPE_VOLUMETEXTURE, D3DFMT_A32B32G32R32F));
+
+ // detect 10-bit textures support
+ renderersData->m_b10bitSupport = SUCCEEDED(m_pD3D->CheckDeviceFormat(m_CurrentAdapter, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_QUERY_FILTER, D3DRTYPE_TEXTURE, D3DFMT_A2R10G10B10));
+
+ // set settings that depend on hardware feature support
+ m_bForceInputHighColorResolution = s.m_RenderSettings.iEVRForceInputHighColorResolution && m_bIsEVR && renderersData->m_b10bitSupport;
+ m_bHighColorResolution = s.m_RenderSettings.iEVRHighColorResolution && m_bIsEVR && renderersData->m_b10bitSupport;
+ m_bFullFloatingPointProcessing = s.m_RenderSettings.iVMR9FullFloatingPointProcessing && renderersData->m_bFP16Support;
+ m_bHalfFloatingPointProcessing = s.m_RenderSettings.iVMR9HalfFloatingPointProcessing && renderersData->m_bFP16Support && !m_bFullFloatingPointProcessing;
+
+
+ // set color formats
+ if (m_bFullFloatingPointProcessing) {
+ m_SurfaceType = D3DFMT_A32B32G32R32F;
+ } else if (m_bHalfFloatingPointProcessing) {
+ m_SurfaceType = D3DFMT_A16B16G16R16F;
+ } else if (m_bForceInputHighColorResolution || m_bHighColorResolution) {
+ m_SurfaceType = D3DFMT_A2R10G10B10;
+ } else {
+ if (m_nPCIVendor == PCIV_ATI) {
+ m_SurfaceType = D3DFMT_X8R8G8B8;
+ } else {
+ m_SurfaceType = D3DFMT_A8R8G8B8;
+ }
+ }
+
+ D3DDISPLAYMODEEX DisplayMode;
+ ZeroMemory(&DisplayMode, sizeof(DisplayMode));
+ DisplayMode.Size = sizeof(DisplayMode);
+ D3DDISPLAYMODE d3ddm;
+ ZeroMemory(&d3ddm, sizeof(d3ddm));
+
+ if (m_bIsFullscreen) {
+ if (m_bHighColorResolution) {
+ pp.BackBufferFormat = D3DFMT_A2R10G10B10;
+ } else {
+ pp.BackBufferFormat = D3DFMT_X8R8G8B8;
+ }
+ pp.Windowed = false;
+ pp.BackBufferCount = 3;
+ pp.SwapEffect = D3DSWAPEFFECT_FLIP;
+ // there's no Desktop composition to take care of alternative vSync in exclusive mode, alternative vSync is therefore unused
+ pp.hDeviceWindow = m_hWnd;
+ pp.Flags = D3DPRESENTFLAG_VIDEO;
+ if (s.m_RenderSettings.iVMR9FullscreenGUISupport && !m_bHighColorResolution) {
+ pp.Flags |= D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
+ }
+ m_D3DDevExError = L"No m_pD3DEx";
+ if (m_pD3DEx) {
+ m_pD3DEx->GetAdapterDisplayModeEx(m_CurrentAdapter, &DisplayMode, NULL);
+
+ DisplayMode.Format = pp.BackBufferFormat;
+ m_ScreenSize.SetSize(DisplayMode.Width, DisplayMode.Height);
+ pp.FullScreen_RefreshRateInHz = m_RefreshRate = DisplayMode.RefreshRate;
+ pp.BackBufferWidth = m_ScreenSize.cx;
+ pp.BackBufferHeight = m_ScreenSize.cy;
+
+ hr = m_pD3DEx->CreateDeviceEx(
+ m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd,
+ GetVertexProcessing() | D3DCREATE_FPU_PRESERVE | D3DCREATE_MULTITHREADED | D3DCREATE_ENABLE_PRESENTSTATS, //D3DCREATE_MANAGED
+ &pp, &DisplayMode, &m_pD3DDevEx);
+
+ m_D3DDevExError = GetWindowsErrorMessage(hr, m_hD3D9);
+ if (m_pD3DDevEx) {
+ m_pD3DDev = m_pD3DDevEx;
+ m_BackbufferType = pp.BackBufferFormat;
+ m_DisplayType = DisplayMode.Format;
+ }
+ }
+ if (!m_pD3DDev) {
+ m_pD3D->GetAdapterDisplayMode(m_CurrentAdapter, &d3ddm);
+ d3ddm.Format = pp.BackBufferFormat;
+ m_ScreenSize.SetSize(d3ddm.Width, d3ddm.Height);
+ pp.FullScreen_RefreshRateInHz = m_RefreshRate = d3ddm.RefreshRate;
+ pp.BackBufferWidth = m_ScreenSize.cx;
+ pp.BackBufferHeight = m_ScreenSize.cy;
+
+ hr = m_pD3D->CreateDevice(
+ m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd,
+ GetVertexProcessing() | D3DCREATE_FPU_PRESERVE | D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
+ &pp, &m_pD3DDev);
+ m_DisplayType = d3ddm.Format;
+ m_BackbufferType = pp.BackBufferFormat;
+ }
+ if (m_pD3DDev && s.m_RenderSettings.iVMR9FullscreenGUISupport && !m_bHighColorResolution) {
+ m_pD3DDev->SetDialogBoxMode(true);
+ //if (m_pD3DDev->SetDialogBoxMode(true) != S_OK)
+ // ExitProcess(0);
+ }
+ } else {
+ pp.Windowed = TRUE;
+ pp.hDeviceWindow = m_hWnd;
+ pp.SwapEffect = D3DSWAPEFFECT_COPY;
+ pp.Flags = D3DPRESENTFLAG_VIDEO;
+ pp.BackBufferCount = 1;
+ if (bCompositionEnabled || m_bAlternativeVSync) {
+ // Desktop composition takes care of the VSYNC
+ pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
+ }
+
+ if (m_pD3DEx) {
+ m_pD3DEx->GetAdapterDisplayModeEx(m_CurrentAdapter, &DisplayMode, NULL);
+ m_ScreenSize.SetSize(DisplayMode.Width, DisplayMode.Height);
+ m_RefreshRate = DisplayMode.RefreshRate;
+ pp.BackBufferWidth = m_ScreenSize.cx;
+ pp.BackBufferHeight = m_ScreenSize.cy;
+
+ // We can get 0x8876086a here when switching from two displays to one display using Win + P (Windows 7)
+ // Cause: We might not reinitialize dx correctly during the switch
+ hr = m_pD3DEx->CreateDeviceEx(
+ m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd,
+ GetVertexProcessing() | D3DCREATE_FPU_PRESERVE | D3DCREATE_MULTITHREADED | D3DCREATE_ENABLE_PRESENTSTATS, //D3DCREATE_MANAGED
+ &pp, NULL, &m_pD3DDevEx);
+ if (m_pD3DDevEx) {
+ m_pD3DDev = m_pD3DDevEx;
+ m_DisplayType = DisplayMode.Format;
+ }
+ }
+ if (!m_pD3DDev) {
+ m_pD3D->GetAdapterDisplayMode(m_CurrentAdapter, &d3ddm);
+ m_ScreenSize.SetSize(d3ddm.Width, d3ddm.Height);
+ m_RefreshRate = d3ddm.RefreshRate;
+ pp.BackBufferWidth = m_ScreenSize.cx;
+ pp.BackBufferHeight = m_ScreenSize.cy;
+
+ hr = m_pD3D->CreateDevice(
+ m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd,
+ GetVertexProcessing() | D3DCREATE_FPU_PRESERVE | D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
+ &pp, &m_pD3DDev);
+ m_DisplayType = d3ddm.Format;
+ }
+ m_BackbufferType = pp.BackBufferFormat;
+ }
+
+ while (hr == D3DERR_DEVICELOST) {
+ TRACE("D3DERR_DEVICELOST. Trying to Reset.\n");
+ hr = m_pD3DDev->TestCooperativeLevel();
+ }
+ if (hr == D3DERR_DEVICENOTRESET) {
+ TRACE("D3DERR_DEVICENOTRESET\n");
+ hr = m_pD3DDev->Reset(&pp);
+ }
+
+ TRACE("CreateDevice: %d\n", (LONG)hr);
+ ASSERT(SUCCEEDED(hr));
+
+ m_MainThreadId = GetCurrentThreadId();
+
+ if (m_pD3DDevEx) {
+ m_pD3DDevEx->SetGPUThreadPriority(7);
+ }
+
+ if (FAILED(hr)) {
+ _Error += L"CreateDevice failed\n";
+ CStringW str;
+ str.Format(L"Error code: 0x%X\n", hr);
+ _Error += str;
+
+ return hr;
+ }
+
+ // Get the device caps
+ ZeroMemory(&m_Caps, sizeof(m_Caps));
+ m_pD3DDev->GetDeviceCaps(&m_Caps);
+
+ // Initialize the rendering engine
+ InitRenderingEngine();
+
+ CComPtr<ISubPicProvider> pSubPicProvider;
+ if (m_pSubPicQueue) {
+ m_pSubPicQueue->GetSubPicProvider(&pSubPicProvider);
+ }
+
+ CSize size;
+ switch (GetRenderersSettings().nSPCMaxRes) {
+ case 0:
+ default:
+ size = m_ScreenSize;
+ break;
+ case 1:
+ size.SetSize(1024, 768);
+ break;
+ case 2:
+ size.SetSize(800, 600);
+ break;
+ case 3:
+ size.SetSize(640, 480);
+ break;
+ case 4:
+ size.SetSize(512, 384);
+ break;
+ case 5:
+ size.SetSize(384, 288);
+ break;
+ case 6:
+ size.SetSize(2560, 1600);
+ break;
+ case 7:
+ size.SetSize(1920, 1080);
+ break;
+ case 8:
+ size.SetSize(1320, 900);
+ break;
+ case 9:
+ size.SetSize(1280, 720);
+ break;
+ }
+
+ if (m_pAllocator) {
+ m_pAllocator->ChangeDevice(m_pD3DDev);
+ } else {
+ m_pAllocator = DNew CDX9SubPicAllocator(m_pD3DDev, size, GetRenderersSettings().fSPCPow2Tex, false);
+ if (!m_pAllocator) {
+ _Error += L"CDX9SubPicAllocator failed\n";
+
+ return E_FAIL;
+ }
+ }
+
+ hr = S_OK;
+ m_pSubPicQueue = GetRenderersSettings().nSPCSize > 0
+ ? (ISubPicQueue*)DNew CSubPicQueue(GetRenderersSettings().nSPCSize, !GetRenderersSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
+ : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
+ if (!m_pSubPicQueue || FAILED(hr)) {
+ _Error += L"m_pSubPicQueue failed\n";
+
+ return E_FAIL;
+ }
+
+ if (pSubPicProvider) {
+ m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
+ }
+
+ m_pFont = NULL;
+ if (m_pD3DXCreateFont) {
+ int MinSize = 1600;
+ int CurrentSize = min(m_ScreenSize.cx, MinSize);
+ double Scale = double(CurrentSize) / double(MinSize);
+ m_TextScale = Scale;
+ m_pD3DXCreateFont(m_pD3DDev, // D3D device
+ (int)(-24.0 * Scale), // Height
+ (UINT)(-11.0 * Scale), // Width
+ CurrentSize < 800 ? FW_NORMAL : FW_BOLD, // Weight
+ 0, // MipLevels, 0 = autogen mipmaps
+ FALSE, // Italic
+ DEFAULT_CHARSET, // CharSet
+ OUT_DEFAULT_PRECIS, // OutputPrecision
+ ANTIALIASED_QUALITY, // Quality
+ FIXED_PITCH | FF_DONTCARE, // PitchAndFamily
+ L"Lucida Console", // pFaceName
+ &m_pFont); // ppFont
+ }
+
+
+ m_pSprite = NULL;
+
+ if (m_pD3DXCreateSprite) {
+ m_pD3DXCreateSprite(m_pD3DDev, // D3D device
+ &m_pSprite);
+ }
+
+ m_pLine = NULL;
+ if (m_pD3DXCreateLine) {
+ m_pD3DXCreateLine(m_pD3DDev, &m_pLine);
+ }
+
+ m_LastAdapterCheck = GetRenderersData()->GetPerfCounter();
+
+ StartWorkerThreads();
+
+ return S_OK;
}
HRESULT CDX9AllocatorPresenter::AllocSurfaces()
{
- CAutoLock cAutoLock(this);
- CAutoLock cRenderLock(&m_RenderLock);
+ CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
- return CreateVideoSurfaces();
+ return CreateVideoSurfaces();
}
void CDX9AllocatorPresenter::DeleteSurfaces()
{
- CAutoLock cAutoLock(this);
- CAutoLock cRenderLock(&m_RenderLock);
+ CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
- FreeVideoSurfaces();
+ FreeVideoSurfaces();
}
UINT CDX9AllocatorPresenter::GetAdapter(IDirect3D9* pD3D, bool bGetAdapter)
{
- if (m_hWnd == NULL || pD3D == NULL) {
- return D3DADAPTER_DEFAULT;
- }
-
- m_D3D9Device = _T("");
- m_nPCIVendor = 0;
-
- CRenderersSettings& s = GetRenderersSettings();
- if (bGetAdapter && (pD3D->GetAdapterCount()>1) && (s.D3D9RenderDevice != _T(""))) {
- TCHAR strGUID[50];
- D3DADAPTER_IDENTIFIER9 adapterIdentifier;
-
- for (UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp) {
- if (pD3D->GetAdapterIdentifier(adp, 0, &adapterIdentifier) == S_OK) {
- if ((::StringFromGUID2(adapterIdentifier.DeviceIdentifier, strGUID, 50) > 0) && (s.D3D9RenderDevice == strGUID)) {
- m_D3D9Device = adapterIdentifier.Description;
- m_nPCIVendor = adapterIdentifier.VendorId;
- return adp;
- }
- }
- }
- }
-
- HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- if (hMonitor == NULL) {
- return D3DADAPTER_DEFAULT;
- }
-
- for (UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp) {
- HMONITOR hAdpMon = pD3D->GetAdapterMonitor(adp);
- if (hAdpMon == hMonitor) {
- if (bGetAdapter) {
- D3DADAPTER_IDENTIFIER9 adapterIdentifier;
- if (pD3D->GetAdapterIdentifier(adp, 0, &adapterIdentifier) == S_OK) {
- m_D3D9Device = adapterIdentifier.Description;
- m_nPCIVendor = adapterIdentifier.VendorId;
- }
- }
- return adp;
- }
- }
-
- return D3DADAPTER_DEFAULT;
+ if (m_hWnd == NULL || pD3D == NULL) {
+ return D3DADAPTER_DEFAULT;
+ }
+
+ m_D3D9Device = _T("");
+ m_nPCIVendor = 0;
+
+ CRenderersSettings& s = GetRenderersSettings();
+ if (bGetAdapter && (pD3D->GetAdapterCount() > 1) && (s.D3D9RenderDevice != _T(""))) {
+ TCHAR strGUID[50];
+ D3DADAPTER_IDENTIFIER9 adapterIdentifier;
+
+ for (UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp) {
+ if (pD3D->GetAdapterIdentifier(adp, 0, &adapterIdentifier) == S_OK) {
+ if ((::StringFromGUID2(adapterIdentifier.DeviceIdentifier, strGUID, 50) > 0) && (s.D3D9RenderDevice == strGUID)) {
+ m_D3D9Device = adapterIdentifier.Description;
+ m_nPCIVendor = adapterIdentifier.VendorId;
+ return adp;
+ }
+ }
+ }
+ }
+
+ HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+ if (hMonitor == NULL) {
+ return D3DADAPTER_DEFAULT;
+ }
+
+ for (UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp) {
+ HMONITOR hAdpMon = pD3D->GetAdapterMonitor(adp);
+ if (hAdpMon == hMonitor) {
+ if (bGetAdapter) {
+ D3DADAPTER_IDENTIFIER9 adapterIdentifier;
+ if (pD3D->GetAdapterIdentifier(adp, 0, &adapterIdentifier) == S_OK) {
+ m_D3D9Device = adapterIdentifier.Description;
+ m_nPCIVendor = adapterIdentifier.VendorId;
+ }
+ }
+ return adp;
+ }
+ }
+
+ return D3DADAPTER_DEFAULT;
}
DWORD CDX9AllocatorPresenter::GetVertexProcessing()
{
- HRESULT hr;
- D3DCAPS9 caps;
+ HRESULT hr;
+ D3DCAPS9 caps;
- hr = m_pD3D->GetDeviceCaps(m_CurrentAdapter, D3DDEVTYPE_HAL, &caps);
- if (FAILED(hr)) {
- return D3DCREATE_SOFTWARE_VERTEXPROCESSING;
- }
+ hr = m_pD3D->GetDeviceCaps(m_CurrentAdapter, D3DDEVTYPE_HAL, &caps);
+ if (FAILED(hr)) {
+ return D3DCREATE_SOFTWARE_VERTEXPROCESSING;
+ }
- if ((caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0 ||
- caps.VertexShaderVersion < D3DVS_VERSION(2, 0)) {
- return D3DCREATE_SOFTWARE_VERTEXPROCESSING;
- }
+ if ((caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0 ||
+ caps.VertexShaderVersion < D3DVS_VERSION(2, 0)) {
+ return D3DCREATE_SOFTWARE_VERTEXPROCESSING;
+ }
- return D3DCREATE_HARDWARE_VERTEXPROCESSING;
+ return D3DCREATE_HARDWARE_VERTEXPROCESSING;
}
// ISubPicAllocatorPresenter
STDMETHODIMP CDX9AllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
void CDX9AllocatorPresenter::CalculateJitter(LONGLONG PerfCounter)
{
- // Calculate the jitter!
- LONGLONG llPerf = PerfCounter;
- if ((m_rtTimePerFrame != 0) && (labs ((long)(llPerf - m_llLastPerf)) < m_rtTimePerFrame*3) ) {
- m_nNextJitter = (m_nNextJitter+1) % NB_JITTER;
- m_pllJitter[m_nNextJitter] = llPerf - m_llLastPerf;
-
- m_MaxJitter = MINLONG64;
- m_MinJitter = MAXLONG64;
-
- // Calculate the real FPS
- LONGLONG llJitterSum = 0;
- LONGLONG llJitterSumAvg = 0;
- for (int i=0; i<NB_JITTER; i++) {
- LONGLONG Jitter = m_pllJitter[i];
- llJitterSum += Jitter;
- llJitterSumAvg += Jitter;
- }
- double FrameTimeMean = double(llJitterSumAvg)/NB_JITTER;
- m_fJitterMean = FrameTimeMean;
- double DeviationSum = 0;
- for (int i=0; i<NB_JITTER; i++) {
- LONGLONG DevInt = m_pllJitter[i] - (LONGLONG)FrameTimeMean;
- double Deviation = (double)DevInt;
- DeviationSum += Deviation*Deviation;
- m_MaxJitter = max(m_MaxJitter, DevInt);
- m_MinJitter = min(m_MinJitter, DevInt);
- }
- double StdDev = sqrt(DeviationSum/NB_JITTER);
-
- m_fJitterStdDev = StdDev;
-
- m_fAvrFps = 10000000.0/(double(llJitterSum)/NB_JITTER);
- }
-
- m_llLastPerf = llPerf;
+ // Calculate the jitter!
+ LONGLONG llPerf = PerfCounter;
+ if ((m_rtTimePerFrame != 0) && (labs((long)(llPerf - m_llLastPerf)) < m_rtTimePerFrame * 3)) {
+ m_nNextJitter = (m_nNextJitter + 1) % NB_JITTER;
+ m_pllJitter[m_nNextJitter] = llPerf - m_llLastPerf;
+
+ m_MaxJitter = MINLONG64;
+ m_MinJitter = MAXLONG64;
+
+ // Calculate the real FPS
+ LONGLONG llJitterSum = 0;
+ LONGLONG llJitterSumAvg = 0;
+ for (int i = 0; i < NB_JITTER; i++) {
+ LONGLONG Jitter = m_pllJitter[i];
+ llJitterSum += Jitter;
+ llJitterSumAvg += Jitter;
+ }
+ double FrameTimeMean = double(llJitterSumAvg) / NB_JITTER;
+ m_fJitterMean = FrameTimeMean;
+ double DeviationSum = 0;
+ for (int i = 0; i < NB_JITTER; i++) {
+ LONGLONG DevInt = m_pllJitter[i] - (LONGLONG)FrameTimeMean;
+ double Deviation = (double)DevInt;
+ DeviationSum += Deviation * Deviation;
+ m_MaxJitter = max(m_MaxJitter, DevInt);
+ m_MinJitter = min(m_MinJitter, DevInt);
+ }
+ double StdDev = sqrt(DeviationSum / NB_JITTER);
+
+ m_fJitterStdDev = StdDev;
+
+ m_fAvrFps = 10000000.0 / (double(llJitterSum) / NB_JITTER);
+ }
+
+ m_llLastPerf = llPerf;
}
-bool CDX9AllocatorPresenter::GetVBlank(int &_ScanLine, int &_bInVBlank, bool _bMeasureTime)
+bool CDX9AllocatorPresenter::GetVBlank(int& _ScanLine, int& _bInVBlank, bool _bMeasureTime)
{
- LONGLONG llPerf = 0;
- if (_bMeasureTime) {
- llPerf = GetRenderersData()->GetPerfCounter();
- }
-
- int ScanLine = 0;
- _ScanLine = 0;
- _bInVBlank = 0;
-
- if (m_pDirectDraw) {
- DWORD ScanLineGet = 0;
- m_pDirectDraw->GetScanLine(&ScanLineGet);
- BOOL InVBlank;
- if (m_pDirectDraw->GetVerticalBlankStatus (&InVBlank) != S_OK) {
- return false;
- }
- ScanLine = ScanLineGet;
- _bInVBlank = InVBlank;
- if (InVBlank) {
- ScanLine = 0;
- }
- } else {
- D3DRASTER_STATUS RasterStatus;
- if (m_pD3DDev->GetRasterStatus(0, &RasterStatus) != S_OK) {
- return false;
- }
- ScanLine = RasterStatus.ScanLine;
- _bInVBlank = RasterStatus.InVBlank;
- }
- if (_bMeasureTime) {
- m_VBlankMax = max(m_VBlankMax, ScanLine);
- if (ScanLine != 0 && !_bInVBlank) {
- m_VBlankMinCalc = min(m_VBlankMinCalc, ScanLine);
- }
- m_VBlankMin = m_VBlankMax - m_ScreenSize.cy;
- }
- if (_bInVBlank) {
- _ScanLine = 0;
- } else if (m_VBlankMin != 300000) {
- _ScanLine = ScanLine - m_VBlankMin;
- } else {
- _ScanLine = ScanLine;
- }
-
- if (_bMeasureTime) {
- LONGLONG Time = GetRenderersData()->GetPerfCounter() - llPerf;
- if (Time > 5000000) { // 0.5 sec
- TRACE("GetVBlank too long (%f sec)\n", Time / 10000000.0);
- }
- m_RasterStatusWaitTimeMaxCalc = max(m_RasterStatusWaitTimeMaxCalc, Time);
- }
-
- return true;
+ LONGLONG llPerf = 0;
+ if (_bMeasureTime) {
+ llPerf = GetRenderersData()->GetPerfCounter();
+ }
+
+ int ScanLine = 0;
+ _ScanLine = 0;
+ _bInVBlank = 0;
+
+ if (m_pDirectDraw) {
+ DWORD ScanLineGet = 0;
+ m_pDirectDraw->GetScanLine(&ScanLineGet);
+ BOOL InVBlank;
+ if (m_pDirectDraw->GetVerticalBlankStatus(&InVBlank) != S_OK) {
+ return false;
+ }
+ ScanLine = ScanLineGet;
+ _bInVBlank = InVBlank;
+ if (InVBlank) {
+ ScanLine = 0;
+ }
+ } else {
+ D3DRASTER_STATUS RasterStatus;
+ if (m_pD3DDev->GetRasterStatus(0, &RasterStatus) != S_OK) {
+ return false;
+ }
+ ScanLine = RasterStatus.ScanLine;
+ _bInVBlank = RasterStatus.InVBlank;
+ }
+ if (_bMeasureTime) {
+ m_VBlankMax = max(m_VBlankMax, ScanLine);
+ if (ScanLine != 0 && !_bInVBlank) {
+ m_VBlankMinCalc = min(m_VBlankMinCalc, ScanLine);
+ }
+ m_VBlankMin = m_VBlankMax - m_ScreenSize.cy;
+ }
+ if (_bInVBlank) {
+ _ScanLine = 0;
+ } else if (m_VBlankMin != 300000) {
+ _ScanLine = ScanLine - m_VBlankMin;
+ } else {
+ _ScanLine = ScanLine;
+ }
+
+ if (_bMeasureTime) {
+ LONGLONG Time = GetRenderersData()->GetPerfCounter() - llPerf;
+ if (Time > 5000000) { // 0.5 sec
+ TRACE("GetVBlank too long (%f sec)\n", Time / 10000000.0);
+ }
+ m_RasterStatusWaitTimeMaxCalc = max(m_RasterStatusWaitTimeMaxCalc, Time);
+ }
+
+ return true;
}
-bool CDX9AllocatorPresenter::WaitForVBlankRange(int &_RasterStart, int _RasterSize, bool _bWaitIfInside, bool _bNeedAccurate, bool _bMeasure, bool &_bTakenLock)
+bool CDX9AllocatorPresenter::WaitForVBlankRange(int& _RasterStart, int _RasterSize, bool _bWaitIfInside, bool _bNeedAccurate, bool _bMeasure, bool& _bTakenLock)
{
- if (_bMeasure) {
- m_RasterStatusWaitTimeMaxCalc = 0;
- }
- bool bWaited = false;
- int ScanLine = 0;
- int InVBlank = 0;
- LONGLONG llPerf = 0;
- if (_bMeasure) {
- llPerf = GetRenderersData()->GetPerfCounter();
- }
- GetVBlank(ScanLine, InVBlank, _bMeasure);
- if (_bMeasure) {
- m_VBlankStartWait = ScanLine;
- }
-
- static bool bOneWait = true;
- if (bOneWait && _bMeasure) {
- bOneWait = false;
- // If we are already in the wanted interval we need to wait until we aren't, this improves sync when for example you are playing 23.976 Hz material on a 24 Hz refresh rate
- int nInVBlank = 0;
- for (;;) {
- if (!GetVBlank(ScanLine, InVBlank, _bMeasure)) {
- break;
- }
-
- if (InVBlank && nInVBlank == 0) {
- nInVBlank = 1;
- } else if (!InVBlank && nInVBlank == 1) {
- nInVBlank = 2;
- } else if (InVBlank && nInVBlank == 2) {
- nInVBlank = 3;
- } else if (!InVBlank && nInVBlank == 3) {
- break;
- }
- }
- }
- if (_bWaitIfInside) {
- int ScanLineDiff = long(ScanLine) - _RasterStart;
- if (ScanLineDiff > m_ScreenSize.cy / 2) {
- ScanLineDiff -= m_ScreenSize.cy;
- } else if (ScanLineDiff < -m_ScreenSize.cy / 2) {
- ScanLineDiff += m_ScreenSize.cy;
- }
-
- if (ScanLineDiff >= 0 && ScanLineDiff <= _RasterSize) {
- bWaited = true;
- // If we are already in the wanted interval we need to wait until we aren't, this improves sync when for example you are playing 23.976 Hz material on a 24 Hz refresh rate
- int LastLineDiff = ScanLineDiff;
- for (;;) {
- if (!GetVBlank(ScanLine, InVBlank, _bMeasure)) {
- break;
- }
- int ScanLineDiff = long(ScanLine) - _RasterStart;
- if (ScanLineDiff > m_ScreenSize.cy / 2) {
- ScanLineDiff -= m_ScreenSize.cy;
- } else if (ScanLineDiff < -m_ScreenSize.cy / 2) {
- ScanLineDiff += m_ScreenSize.cy;
- }
- if (!(ScanLineDiff >= 0 && ScanLineDiff <= _RasterSize) || (LastLineDiff < 0 && ScanLineDiff > 0)) {
- break;
- }
- LastLineDiff = ScanLineDiff;
- Sleep(1); // Just sleep
- }
- }
- }
- double RefreshRate = GetRefreshRate();
- LONG ScanLines = GetScanLines();
- int MinRange = max(min(int(0.0015 * double(ScanLines) * RefreshRate + 0.5), ScanLines/3), 5); // 1.5 ms or max 33 % of Time
- int NoSleepStart = _RasterStart - MinRange;
- int NoSleepRange = MinRange;
- if (NoSleepStart < 0) {
- NoSleepStart += m_ScreenSize.cy;
- }
-
- int MinRange2 = max(min(int(0.0050 * double(ScanLines) * RefreshRate + 0.5), ScanLines/3), 5); // 5 ms or max 33 % of Time
- int D3DDevLockStart = _RasterStart - MinRange2;
- int D3DDevLockRange = MinRange2;
- if (D3DDevLockStart < 0) {
- D3DDevLockStart += m_ScreenSize.cy;
- }
-
- int ScanLineDiff = ScanLine - _RasterStart;
- if (ScanLineDiff > m_ScreenSize.cy / 2) {
- ScanLineDiff -= m_ScreenSize.cy;
- } else if (ScanLineDiff < -m_ScreenSize.cy / 2) {
- ScanLineDiff += m_ScreenSize.cy;
- }
- int LastLineDiff = ScanLineDiff;
-
-
- int ScanLineDiffSleep = long(ScanLine) - NoSleepStart;
- if (ScanLineDiffSleep > m_ScreenSize.cy / 2) {
- ScanLineDiffSleep -= m_ScreenSize.cy;
- } else if (ScanLineDiffSleep < -m_ScreenSize.cy / 2) {
- ScanLineDiffSleep += m_ScreenSize.cy;
- }
- int LastLineDiffSleep = ScanLineDiffSleep;
-
-
- int ScanLineDiffLock = long(ScanLine) - D3DDevLockStart;
- if (ScanLineDiffLock > m_ScreenSize.cy / 2) {
- ScanLineDiffLock -= m_ScreenSize.cy;
- } else if (ScanLineDiffLock < -m_ScreenSize.cy / 2) {
- ScanLineDiffLock += m_ScreenSize.cy;
- }
- int LastLineDiffLock = ScanLineDiffLock;
-
- LONGLONG llPerfLock = 0;
-
- for (;;) {
- if (!GetVBlank(ScanLine, InVBlank, _bMeasure)) {
- break;
- }
- int ScanLineDiff = long(ScanLine) - _RasterStart;
- if (ScanLineDiff > m_ScreenSize.cy / 2) {
- ScanLineDiff -= m_ScreenSize.cy;
- } else if (ScanLineDiff < -m_ScreenSize.cy / 2) {
- ScanLineDiff += m_ScreenSize.cy;
- }
- if ((ScanLineDiff >= 0 && ScanLineDiff <= _RasterSize) || (LastLineDiff < 0 && ScanLineDiff > 0)) {
- break;
- }
-
- LastLineDiff = ScanLineDiff;
-
- bWaited = true;
-
- int ScanLineDiffLock = long(ScanLine) - D3DDevLockStart;
- if (ScanLineDiffLock > m_ScreenSize.cy / 2) {
- ScanLineDiffLock -= m_ScreenSize.cy;
- } else if (ScanLineDiffLock < -m_ScreenSize.cy / 2) {
- ScanLineDiffLock += m_ScreenSize.cy;
- }
-
- if (((ScanLineDiffLock >= 0 && ScanLineDiffLock <= D3DDevLockRange) || (LastLineDiffLock < 0 && ScanLineDiffLock > 0))) {
- if (!_bTakenLock && _bMeasure) {
- _bTakenLock = true;
- llPerfLock = GetRenderersData()->GetPerfCounter();
- LockD3DDevice();
- }
- }
- LastLineDiffLock = ScanLineDiffLock;
-
-
- int ScanLineDiffSleep = long(ScanLine) - NoSleepStart;
- if (ScanLineDiffSleep > m_ScreenSize.cy / 2) {
- ScanLineDiffSleep -= m_ScreenSize.cy;
- } else if (ScanLineDiffSleep < -m_ScreenSize.cy / 2) {
- ScanLineDiffSleep += m_ScreenSize.cy;
- }
-
- if (!((ScanLineDiffSleep >= 0 && ScanLineDiffSleep <= NoSleepRange) || (LastLineDiffSleep < 0 && ScanLineDiffSleep > 0)) || !_bNeedAccurate) {
- //TRACE("%d\n", RasterStatus.ScanLine);
- Sleep(1); // Don't sleep for the last 1.5 ms scan lines, so we get maximum precision
- }
- LastLineDiffSleep = ScanLineDiffSleep;
- }
- _RasterStart = ScanLine;
- if (_bMeasure) {
- m_VBlankEndWait = ScanLine;
- m_VBlankWaitTime = GetRenderersData()->GetPerfCounter() - llPerf;
-
- if (_bTakenLock) {
- m_VBlankLockTime = GetRenderersData()->GetPerfCounter() - llPerfLock;
- } else {
- m_VBlankLockTime = 0;
- }
-
- m_RasterStatusWaitTime = m_RasterStatusWaitTimeMaxCalc;
- m_RasterStatusWaitTimeMin = min(m_RasterStatusWaitTimeMin, m_RasterStatusWaitTime);
- m_RasterStatusWaitTimeMax = max(m_RasterStatusWaitTimeMax, m_RasterStatusWaitTime);
- }
-
- return bWaited;
+ if (_bMeasure) {
+ m_RasterStatusWaitTimeMaxCalc = 0;
+ }
+ bool bWaited = false;
+ int ScanLine = 0;
+ int InVBlank = 0;
+ LONGLONG llPerf = 0;
+ if (_bMeasure) {
+ llPerf = GetRenderersData()->GetPerfCounter();
+ }
+ GetVBlank(ScanLine, InVBlank, _bMeasure);
+ if (_bMeasure) {
+ m_VBlankStartWait = ScanLine;
+ }
+
+ static bool bOneWait = true;
+ if (bOneWait && _bMeasure) {
+ bOneWait = false;
+ // If we are already in the wanted interval we need to wait until we aren't, this improves sync when for example you are playing 23.976 Hz material on a 24 Hz refresh rate
+ int nInVBlank = 0;
+ for (;;) {
+ if (!GetVBlank(ScanLine, InVBlank, _bMeasure)) {
+ break;
+ }
+
+ if (InVBlank && nInVBlank == 0) {
+ nInVBlank = 1;
+ } else if (!InVBlank && nInVBlank == 1) {
+ nInVBlank = 2;
+ } else if (InVBlank && nInVBlank == 2) {
+ nInVBlank = 3;
+ } else if (!InVBlank && nInVBlank == 3) {
+ break;
+ }
+ }
+ }
+ if (_bWaitIfInside) {
+ int ScanLineDiff = long(ScanLine) - _RasterStart;
+ if (ScanLineDiff > m_ScreenSize.cy / 2) {
+ ScanLineDiff -= m_ScreenSize.cy;
+ } else if (ScanLineDiff < -m_ScreenSize.cy / 2) {
+ ScanLineDiff += m_ScreenSize.cy;
+ }
+
+ if (ScanLineDiff >= 0 && ScanLineDiff <= _RasterSize) {
+ bWaited = true;
+ // If we are already in the wanted interval we need to wait until we aren't, this improves sync when for example you are playing 23.976 Hz material on a 24 Hz refresh rate
+ int LastLineDiff = ScanLineDiff;
+ for (;;) {
+ if (!GetVBlank(ScanLine, InVBlank, _bMeasure)) {
+ break;
+ }
+ int ScanLineDiff = long(ScanLine) - _RasterStart;
+ if (ScanLineDiff > m_ScreenSize.cy / 2) {
+ ScanLineDiff -= m_ScreenSize.cy;
+ } else if (ScanLineDiff < -m_ScreenSize.cy / 2) {
+ ScanLineDiff += m_ScreenSize.cy;
+ }
+ if (!(ScanLineDiff >= 0 && ScanLineDiff <= _RasterSize) || (LastLineDiff < 0 && ScanLineDiff > 0)) {
+ break;
+ }
+ LastLineDiff = ScanLineDiff;
+ Sleep(1); // Just sleep
+ }
+ }
+ }
+ double RefreshRate = GetRefreshRate();
+ LONG ScanLines = GetScanLines();
+ int MinRange = max(min(int(0.0015 * double(ScanLines) * RefreshRate + 0.5), ScanLines / 3), 5); // 1.5 ms or max 33 % of Time
+ int NoSleepStart = _RasterStart - MinRange;
+ int NoSleepRange = MinRange;
+ if (NoSleepStart < 0) {
+ NoSleepStart += m_ScreenSize.cy;
+ }
+
+ int MinRange2 = max(min(int(0.0050 * double(ScanLines) * RefreshRate + 0.5), ScanLines / 3), 5); // 5 ms or max 33 % of Time
+ int D3DDevLockStart = _RasterStart - MinRange2;
+ int D3DDevLockRange = MinRange2;
+ if (D3DDevLockStart < 0) {
+ D3DDevLockStart += m_ScreenSize.cy;
+ }
+
+ int ScanLineDiff = ScanLine - _RasterStart;
+ if (ScanLineDiff > m_ScreenSize.cy / 2) {
+ ScanLineDiff -= m_ScreenSize.cy;
+ } else if (ScanLineDiff < -m_ScreenSize.cy / 2) {
+ ScanLineDiff += m_ScreenSize.cy;
+ }
+ int LastLineDiff = ScanLineDiff;
+
+
+ int ScanLineDiffSleep = long(ScanLine) - NoSleepStart;
+ if (ScanLineDiffSleep > m_ScreenSize.cy / 2) {
+ ScanLineDiffSleep -= m_ScreenSize.cy;
+ } else if (ScanLineDiffSleep < -m_ScreenSize.cy / 2) {
+ ScanLineDiffSleep += m_ScreenSize.cy;
+ }
+ int LastLineDiffSleep = ScanLineDiffSleep;
+
+
+ int ScanLineDiffLock = long(ScanLine) - D3DDevLockStart;
+ if (ScanLineDiffLock > m_ScreenSize.cy / 2) {
+ ScanLineDiffLock -= m_ScreenSize.cy;
+ } else if (ScanLineDiffLock < -m_ScreenSize.cy / 2) {
+ ScanLineDiffLock += m_ScreenSize.cy;
+ }
+ int LastLineDiffLock = ScanLineDiffLock;
+
+ LONGLONG llPerfLock = 0;
+
+ for (;;) {
+ if (!GetVBlank(ScanLine, InVBlank, _bMeasure)) {
+ break;
+ }
+ int ScanLineDiff = long(ScanLine) - _RasterStart;
+ if (ScanLineDiff > m_ScreenSize.cy / 2) {
+ ScanLineDiff -= m_ScreenSize.cy;
+ } else if (ScanLineDiff < -m_ScreenSize.cy / 2) {
+ ScanLineDiff += m_ScreenSize.cy;
+ }
+ if ((ScanLineDiff >= 0 && ScanLineDiff <= _RasterSize) || (LastLineDiff < 0 && ScanLineDiff > 0)) {
+ break;
+ }
+
+ LastLineDiff = ScanLineDiff;
+
+ bWaited = true;
+
+ int ScanLineDiffLock = long(ScanLine) - D3DDevLockStart;
+ if (ScanLineDiffLock > m_ScreenSize.cy / 2) {
+ ScanLineDiffLock -= m_ScreenSize.cy;
+ } else if (ScanLineDiffLock < -m_ScreenSize.cy / 2) {
+ ScanLineDiffLock += m_ScreenSize.cy;
+ }
+
+ if (((ScanLineDiffLock >= 0 && ScanLineDiffLock <= D3DDevLockRange) || (LastLineDiffLock < 0 && ScanLineDiffLock > 0))) {
+ if (!_bTakenLock && _bMeasure) {
+ _bTakenLock = true;
+ llPerfLock = GetRenderersData()->GetPerfCounter();
+ LockD3DDevice();
+ }
+ }
+ LastLineDiffLock = ScanLineDiffLock;
+
+
+ int ScanLineDiffSleep = long(ScanLine) - NoSleepStart;
+ if (ScanLineDiffSleep > m_ScreenSize.cy / 2) {
+ ScanLineDiffSleep -= m_ScreenSize.cy;
+ } else if (ScanLineDiffSleep < -m_ScreenSize.cy / 2) {
+ ScanLineDiffSleep += m_ScreenSize.cy;
+ }
+
+ if (!((ScanLineDiffSleep >= 0 && ScanLineDiffSleep <= NoSleepRange) || (LastLineDiffSleep < 0 && ScanLineDiffSleep > 0)) || !_bNeedAccurate) {
+ //TRACE("%d\n", RasterStatus.ScanLine);
+ Sleep(1); // Don't sleep for the last 1.5 ms scan lines, so we get maximum precision
+ }
+ LastLineDiffSleep = ScanLineDiffSleep;
+ }
+ _RasterStart = ScanLine;
+ if (_bMeasure) {
+ m_VBlankEndWait = ScanLine;
+ m_VBlankWaitTime = GetRenderersData()->GetPerfCounter() - llPerf;
+
+ if (_bTakenLock) {
+ m_VBlankLockTime = GetRenderersData()->GetPerfCounter() - llPerfLock;
+ } else {
+ m_VBlankLockTime = 0;
+ }
+
+ m_RasterStatusWaitTime = m_RasterStatusWaitTimeMaxCalc;
+ m_RasterStatusWaitTimeMin = min(m_RasterStatusWaitTimeMin, m_RasterStatusWaitTime);
+ m_RasterStatusWaitTimeMax = max(m_RasterStatusWaitTimeMax, m_RasterStatusWaitTime);
+ }
+
+ return bWaited;
}
int CDX9AllocatorPresenter::GetVBlackPos()
{
- CRenderersSettings& s = GetRenderersSettings();
- BOOL bCompositionEnabled = m_bCompositionEnabled;
-
- int WaitRange = max(m_ScreenSize.cy / 40, 5);
- if (!bCompositionEnabled) {
- if (m_bAlternativeVSync) {
- return s.m_RenderSettings.iVMR9VSyncOffset;
- } else {
- int MinRange = max(min(int(0.005 * double(m_ScreenSize.cy) * GetRefreshRate() + 0.5), m_ScreenSize.cy/3), 5); // 5 ms or max 33 % of Time
- int WaitFor = m_ScreenSize.cy - (MinRange + WaitRange);
- return WaitFor;
- }
- } else {
- int WaitFor = m_ScreenSize.cy / 2;
- return WaitFor;
- }
+ CRenderersSettings& s = GetRenderersSettings();
+ BOOL bCompositionEnabled = m_bCompositionEnabled;
+
+ int WaitRange = max(m_ScreenSize.cy / 40, 5);
+ if (!bCompositionEnabled) {
+ if (m_bAlternativeVSync) {
+ return s.m_RenderSettings.iVMR9VSyncOffset;
+ } else {
+ int MinRange = max(min(int(0.005 * double(m_ScreenSize.cy) * GetRefreshRate() + 0.5), m_ScreenSize.cy / 3), 5); // 5 ms or max 33 % of Time
+ int WaitFor = m_ScreenSize.cy - (MinRange + WaitRange);
+ return WaitFor;
+ }
+ } else {
+ int WaitFor = m_ScreenSize.cy / 2;
+ return WaitFor;
+ }
}
-bool CDX9AllocatorPresenter::WaitForVBlank(bool &_Waited, bool &_bTakenLock)
+bool CDX9AllocatorPresenter::WaitForVBlank(bool& _Waited, bool& _bTakenLock)
{
- CRenderersSettings& s = GetRenderersSettings();
- if (!s.m_RenderSettings.iVMR9VSync) {
- _Waited = true;
- m_VBlankWaitTime = 0;
- m_VBlankLockTime = 0;
- m_VBlankEndWait = 0;
- m_VBlankStartWait = 0;
- return true;
- }
- //_Waited = true;
- //return false;
-
- BOOL bCompositionEnabled = m_bCompositionEnabled;
- int WaitFor = GetVBlackPos();
-
- if (!bCompositionEnabled) {
- if (m_bAlternativeVSync) {
- _Waited = WaitForVBlankRange(WaitFor, 0, false, true, true, _bTakenLock);
- return false;
- } else {
- _Waited = WaitForVBlankRange(WaitFor, 0, false, s.m_RenderSettings.iVMR9VSyncAccurate, true, _bTakenLock);
- return true;
- }
- } else {
- // Instead we wait for VBlack after the present, this seems to fix the stuttering problem. It's also possible to fix by removing the Sleep above, but that isn't an option.
- WaitForVBlankRange(WaitFor, 0, false, s.m_RenderSettings.iVMR9VSyncAccurate, true, _bTakenLock);
-
- return false;
- }
+ CRenderersSettings& s = GetRenderersSettings();
+ if (!s.m_RenderSettings.iVMR9VSync) {
+ _Waited = true;
+ m_VBlankWaitTime = 0;
+ m_VBlankLockTime = 0;
+ m_VBlankEndWait = 0;
+ m_VBlankStartWait = 0;
+ return true;
+ }
+ //_Waited = true;
+ //return false;
+
+ BOOL bCompositionEnabled = m_bCompositionEnabled;
+ int WaitFor = GetVBlackPos();
+
+ if (!bCompositionEnabled) {
+ if (m_bAlternativeVSync) {
+ _Waited = WaitForVBlankRange(WaitFor, 0, false, true, true, _bTakenLock);
+ return false;
+ } else {
+ _Waited = WaitForVBlankRange(WaitFor, 0, false, s.m_RenderSettings.iVMR9VSyncAccurate, true, _bTakenLock);
+ return true;
+ }
+ } else {
+ // Instead we wait for VBlack after the present, this seems to fix the stuttering problem. It's also possible to fix by removing the Sleep above, but that isn't an option.
+ WaitForVBlankRange(WaitFor, 0, false, s.m_RenderSettings.iVMR9VSyncAccurate, true, _bTakenLock);
+
+ return false;
+ }
}
void CDX9AllocatorPresenter::UpdateAlphaBitmap()
{
- m_VMR9AlphaBitmapData.Free();
-
- if ((m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_DISABLE) == 0) {
- HBITMAP hBitmap = (HBITMAP)GetCurrentObject (m_VMR9AlphaBitmap.hdc, OBJ_BITMAP);
- if (!hBitmap) {
- return;
- }
- DIBSECTION info = {0};
- if (!::GetObject(hBitmap, sizeof( DIBSECTION ), &info )) {
- return;
- }
-
- m_VMR9AlphaBitmapRect = CRect(0, 0, info.dsBm.bmWidth, info.dsBm.bmHeight);
- m_VMR9AlphaBitmapWidthBytes = info.dsBm.bmWidthBytes;
-
- if (m_VMR9AlphaBitmapData.Allocate(info.dsBm.bmWidthBytes * info.dsBm.bmHeight)) {
- memcpy((BYTE *)m_VMR9AlphaBitmapData, info.dsBm.bmBits, info.dsBm.bmWidthBytes * info.dsBm.bmHeight);
- }
- }
+ m_VMR9AlphaBitmapData.Free();
+
+ if ((m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_DISABLE) == 0) {
+ HBITMAP hBitmap = (HBITMAP)GetCurrentObject(m_VMR9AlphaBitmap.hdc, OBJ_BITMAP);
+ if (!hBitmap) {
+ return;
+ }
+ DIBSECTION info = {0};
+ if (!::GetObject(hBitmap, sizeof(DIBSECTION), &info)) {
+ return;
+ }
+
+ m_VMR9AlphaBitmapRect = CRect(0, 0, info.dsBm.bmWidth, info.dsBm.bmHeight);
+ m_VMR9AlphaBitmapWidthBytes = info.dsBm.bmWidthBytes;
+
+ if (m_VMR9AlphaBitmapData.Allocate(info.dsBm.bmWidthBytes * info.dsBm.bmHeight)) {
+ memcpy((BYTE*)m_VMR9AlphaBitmapData, info.dsBm.bmBits, info.dsBm.bmWidthBytes * info.dsBm.bmHeight);
+ }
+ }
}
STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll)
{
- if (m_bPendingResetDevice) {
- SendResetRequest();
- return false;
- }
+ if (m_bPendingResetDevice) {
+ SendResetRequest();
+ return false;
+ }
- CRenderersSettings& s = GetRenderersSettings();
+ CRenderersSettings& s = GetRenderersSettings();
- //TRACE("Thread: %d\n", (LONG)((CRITICAL_SECTION &)m_RenderLock).OwningThread);
+ //TRACE("Thread: %d\n", (LONG)((CRITICAL_SECTION &)m_RenderLock).OwningThread);
#if 0
- if (TryEnterCriticalSection (&(CRITICAL_SECTION &)(*((CCritSec *)this)))) {
- LeaveCriticalSection((&(CRITICAL_SECTION &)(*((CCritSec *)this))));
- } else {
- __debugbreak();
- }
+ if (TryEnterCriticalSection(&(CRITICAL_SECTION&)(*((CCritSec*)this)))) {
+ LeaveCriticalSection((&(CRITICAL_SECTION&)(*((CCritSec*)this))));
+ } else {
+ __debugbreak();
+ }
#endif
- CRenderersData * pApp = GetRenderersData();
-
- LONGLONG StartPaint = pApp->GetPerfCounter();
- CAutoLock cRenderLock(&m_RenderLock);
-
- if (m_WindowRect.right <= m_WindowRect.left || m_WindowRect.bottom <= m_WindowRect.top
- || m_NativeVideoSize.cx <= 0 || m_NativeVideoSize.cy <= 0
- || !m_pVideoSurface) {
- if (m_OrderedPaint) {
- --m_OrderedPaint;
- } else {
- //TRACE("UNORDERED PAINT!!!!!!\n");
- }
-
-
- return false;
- }
-
- HRESULT hr;
-
- m_pD3DDev->BeginScene();
-
- CComPtr<IDirect3DSurface9> pBackBuffer;
- m_pD3DDev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer);
-
- // Clear the backbuffer
- m_pD3DDev->SetRenderTarget(0, pBackBuffer);
- hr = m_pD3DDev->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0);
-
- CRect rSrcVid(CPoint(0, 0), GetVisibleVideoSize());
- CRect rDstVid(m_VideoRect);
-
- CRect rSrcPri(CPoint(0, 0), m_WindowRect.Size());
- CRect rDstPri(m_WindowRect);
-
- // Render the current video frame
- hr = RenderVideo(pBackBuffer, rSrcVid, rDstVid);
-
- if (FAILED(hr)) {
- if (m_RenderingPath == RENDERING_PATH_STRETCHRECT) {
- // Support ffdshow queueing
- // m_pD3DDev->StretchRect may fail if ffdshow is using queue output samples.
- // Here we don't want to show the black buffer.
- if (m_OrderedPaint) {
- --m_OrderedPaint;
- } else {
- //TRACE("UNORDERED PAINT!!!!!!\n");
- }
-
- return false;
- }
- }
-
- // paint the text on the backbuffer
- AlphaBltSubPic(rSrcPri.Size());
-
- // Casimir666 : show OSD
- if (m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_UPDATE) {
- CAutoLock BitMapLock(&m_VMR9AlphaBitmapLock);
- CRect rcSrc (m_VMR9AlphaBitmap.rSrc);
- m_pOSDTexture = NULL;
- m_pOSDSurface = NULL;
- if ((m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_DISABLE) == 0 && (BYTE *)m_VMR9AlphaBitmapData) {
- if ( (m_pD3DXLoadSurfaceFromMemory != NULL) &&
- SUCCEEDED(hr = m_pD3DDev->CreateTexture(rcSrc.Width(), rcSrc.Height(), 1,
- D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
- D3DPOOL_DEFAULT, &m_pOSDTexture, NULL)) ) {
- if (SUCCEEDED (hr = m_pOSDTexture->GetSurfaceLevel(0, &m_pOSDSurface))) {
- hr = m_pD3DXLoadSurfaceFromMemory (m_pOSDSurface,
- NULL,
- NULL,
- (BYTE *)m_VMR9AlphaBitmapData,
- D3DFMT_A8R8G8B8,
- m_VMR9AlphaBitmapWidthBytes,
- NULL,
- &m_VMR9AlphaBitmapRect,
- D3DX_FILTER_NONE,
- m_VMR9AlphaBitmap.clrSrcKey);
- }
- if (FAILED (hr)) {
- m_pOSDTexture = NULL;
- m_pOSDSurface = NULL;
- }
- }
- }
- m_VMR9AlphaBitmap.dwFlags ^= VMRBITMAP_UPDATE;
-
- }
-
- if (pApp->m_bResetStats) {
- ResetStats();
- pApp->m_bResetStats = false;
- }
-
- if (pApp->m_fDisplayStats) {
- DrawStats();
- }
-
- if (m_pOSDTexture) {
- AlphaBlt(rSrcPri, rDstPri, m_pOSDTexture);
- }
-
- m_pD3DDev->EndScene();
-
- BOOL bCompositionEnabled = m_bCompositionEnabled;
-
- bool bDoVSyncInPresent = (!bCompositionEnabled && !m_bAlternativeVSync) || !s.m_RenderSettings.iVMR9VSync;
-
- LONGLONG PresentWaitTime = 0;
-
- CComPtr<IDirect3DQuery9> pEventQuery;
-
- m_pD3DDev->CreateQuery(D3DQUERYTYPE_EVENT, &pEventQuery);
- if (pEventQuery) {
- pEventQuery->Issue(D3DISSUE_END);
- }
-
- if (s.m_RenderSettings.iVMRFlushGPUBeforeVSync && pEventQuery) {
- LONGLONG llPerf = pApp->GetPerfCounter();
- BOOL Data;
- //Sleep(5);
- LONGLONG FlushStartTime = pApp->GetPerfCounter();
- while (S_FALSE == pEventQuery->GetData( &Data, sizeof(Data), D3DGETDATA_FLUSH )) {
- if (!s.m_RenderSettings.iVMRFlushGPUWait) {
- break;
- }
- Sleep(1);
- if (pApp->GetPerfCounter() - FlushStartTime > 500000) {
- break; // timeout after 50 ms
- }
- }
- if (s.m_RenderSettings.iVMRFlushGPUWait) {
- m_WaitForGPUTime = pApp->GetPerfCounter() - llPerf;
- } else {
- m_WaitForGPUTime = 0;
- }
- } else {
- m_WaitForGPUTime = 0;
- }
-
- if (fAll) {
- m_PaintTime = (GetRenderersData()->GetPerfCounter() - StartPaint);
- m_PaintTimeMin = min(m_PaintTimeMin, m_PaintTime);
- m_PaintTimeMax = max(m_PaintTimeMax, m_PaintTime);
- }
-
- bool bWaited = false;
- bool bTakenLock = false;
- if (fAll) {
- // Only sync to refresh when redrawing all
- bool bTest = WaitForVBlank(bWaited, bTakenLock);
- ASSERT(bTest == bDoVSyncInPresent);
- if (!bDoVSyncInPresent) {
- LONGLONG Time = pApp->GetPerfCounter();
- OnVBlankFinished(fAll, Time);
- if (!m_bIsEVR || m_OrderedPaint) {
- CalculateJitter(Time);
- }
- }
- }
-
- // Create a device pointer m_pd3dDevice
-
- // Create a query object
- {
- CComPtr<IDirect3DQuery9> pEventQuery;
- m_pD3DDev->CreateQuery(D3DQUERYTYPE_EVENT, &pEventQuery);
-
- LONGLONG llPerf = pApp->GetPerfCounter();
- if (m_pD3DDevEx) {
- if (m_bIsFullscreen) {
- hr = m_pD3DDevEx->PresentEx(NULL, NULL, NULL, NULL, NULL);
- } else {
- hr = m_pD3DDevEx->PresentEx(rSrcPri, rDstPri, NULL, NULL, NULL);
- }
- } else {
- if (m_bIsFullscreen) {
- hr = m_pD3DDev->Present(NULL, NULL, NULL, NULL);
- } else {
- hr = m_pD3DDev->Present(rSrcPri, rDstPri, NULL, NULL);
- }
- }
- // Issue an End event
- if (pEventQuery) {
- pEventQuery->Issue(D3DISSUE_END);
- }
-
- BOOL Data;
-
- if (s.m_RenderSettings.iVMRFlushGPUAfterPresent && pEventQuery) {
- LONGLONG FlushStartTime = pApp->GetPerfCounter();
- while (S_FALSE == pEventQuery->GetData( &Data, sizeof(Data), D3DGETDATA_FLUSH )) {
- if (!s.m_RenderSettings.iVMRFlushGPUWait) {
- break;
- }
- if (pApp->GetPerfCounter() - FlushStartTime > 500000) {
- break; // timeout after 50 ms
- }
- }
- }
-
- int ScanLine;
- int bInVBlank;
- GetVBlank(ScanLine, bInVBlank, false);
-
- if (fAll && (!m_bIsEVR || m_OrderedPaint)) {
- m_VBlankEndPresent = ScanLine;
- }
-
- while (ScanLine == 0 || bInVBlank) {
- GetVBlank(ScanLine, bInVBlank, false);
-
- }
- m_VBlankStartMeasureTime = pApp->GetPerfCounter();
- m_VBlankStartMeasure = ScanLine;
-
- if (fAll && bDoVSyncInPresent) {
- m_PresentWaitTime = (pApp->GetPerfCounter() - llPerf) + PresentWaitTime;
- m_PresentWaitTimeMin = min(m_PresentWaitTimeMin, m_PresentWaitTime);
- m_PresentWaitTimeMax = max(m_PresentWaitTimeMax, m_PresentWaitTime);
- } else {
- m_PresentWaitTime = 0;
- m_PresentWaitTimeMin = min(m_PresentWaitTimeMin, m_PresentWaitTime);
- m_PresentWaitTimeMax = max(m_PresentWaitTimeMax, m_PresentWaitTime);
- }
- }
-
- if (bDoVSyncInPresent) {
- LONGLONG Time = pApp->GetPerfCounter();
- if (!m_bIsEVR || m_OrderedPaint) {
- CalculateJitter(Time);
- }
- OnVBlankFinished(fAll, Time);
- }
-
- if (bTakenLock) {
- UnlockD3DDevice();
- }
-
- /*if (!bWaited)
- {
- bWaited = true;
- WaitForVBlank(bWaited);
- TRACE("Double VBlank\n");
- ASSERT(bWaited);
- if (!bDoVSyncInPresent)
- {
- CalculateJitter();
- OnVBlankFinished(fAll);
- }
- }*/
-
- if (!m_bPendingResetDevice) {
- bool fResetDevice = false;
-
- if (hr == D3DERR_DEVICELOST && m_pD3DDev->TestCooperativeLevel() == D3DERR_DEVICENOTRESET) {
- TRACE("Reset Device: D3D Device Lost\n");
- fResetDevice = true;
- }
-
- //if (hr == S_PRESENT_MODE_CHANGED)
- //{
- // TRACE("Reset Device: D3D Device mode changed\n");
- // fResetDevice = true;
- //}
-
- if (SettingsNeedResetDevice()) {
- TRACE("Reset Device: settings changed\n");
- fResetDevice = true;
- }
-
- bCompositionEnabled = false;
- if (m_pDwmIsCompositionEnabled) {
- m_pDwmIsCompositionEnabled(&bCompositionEnabled);
- }
- if ((bCompositionEnabled != 0) != m_bCompositionEnabled) {
- if (m_bIsFullscreen) {
- m_bCompositionEnabled = (bCompositionEnabled != 0);
- } else {
- TRACE("Reset Device: DWM composition changed\n");
- fResetDevice = true;
- }
- }
-
- if (s.fResetDevice) {
- LONGLONG time = GetRenderersData()->GetPerfCounter();
- if (time > m_LastAdapterCheck + 20000000) { // check every 2 sec.
- m_LastAdapterCheck = time;
+ CRenderersData* pApp = GetRenderersData();
+
+ LONGLONG StartPaint = pApp->GetPerfCounter();
+ CAutoLock cRenderLock(&m_RenderLock);
+
+ if (m_WindowRect.right <= m_WindowRect.left || m_WindowRect.bottom <= m_WindowRect.top
+ || m_NativeVideoSize.cx <= 0 || m_NativeVideoSize.cy <= 0
+ || !m_pVideoSurface) {
+ if (m_OrderedPaint) {
+ --m_OrderedPaint;
+ } else {
+ //TRACE("UNORDERED PAINT!!!!!!\n");
+ }
+
+
+ return false;
+ }
+
+ HRESULT hr;
+
+ m_pD3DDev->BeginScene();
+
+ CComPtr<IDirect3DSurface9> pBackBuffer;
+ m_pD3DDev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer);
+
+ // Clear the backbuffer
+ m_pD3DDev->SetRenderTarget(0, pBackBuffer);
+ hr = m_pD3DDev->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0);
+
+ CRect rSrcVid(CPoint(0, 0), GetVisibleVideoSize());
+ CRect rDstVid(m_VideoRect);
+
+ CRect rSrcPri(CPoint(0, 0), m_WindowRect.Size());
+ CRect rDstPri(m_WindowRect);
+
+ // Render the current video frame
+ hr = RenderVideo(pBackBuffer, rSrcVid, rDstVid);
+
+ if (FAILED(hr)) {
+ if (m_RenderingPath == RENDERING_PATH_STRETCHRECT) {
+ // Support ffdshow queueing
+ // m_pD3DDev->StretchRect may fail if ffdshow is using queue output samples.
+ // Here we don't want to show the black buffer.
+ if (m_OrderedPaint) {
+ --m_OrderedPaint;
+ } else {
+ //TRACE("UNORDERED PAINT!!!!!!\n");
+ }
+
+ return false;
+ }
+ }
+
+ // paint the text on the backbuffer
+ AlphaBltSubPic(rSrcPri.Size());
+
+ // Casimir666 : show OSD
+ if (m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_UPDATE) {
+ CAutoLock BitMapLock(&m_VMR9AlphaBitmapLock);
+ CRect rcSrc(m_VMR9AlphaBitmap.rSrc);
+ m_pOSDTexture = NULL;
+ m_pOSDSurface = NULL;
+ if ((m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_DISABLE) == 0 && (BYTE*)m_VMR9AlphaBitmapData) {
+ if ((m_pD3DXLoadSurfaceFromMemory != NULL) &&
+ SUCCEEDED(hr = m_pD3DDev->CreateTexture(rcSrc.Width(), rcSrc.Height(), 1,
+ D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
+ D3DPOOL_DEFAULT, &m_pOSDTexture, NULL))) {
+ if (SUCCEEDED(hr = m_pOSDTexture->GetSurfaceLevel(0, &m_pOSDSurface))) {
+ hr = m_pD3DXLoadSurfaceFromMemory(m_pOSDSurface,
+ NULL,
+ NULL,
+ (BYTE*)m_VMR9AlphaBitmapData,
+ D3DFMT_A8R8G8B8,
+ m_VMR9AlphaBitmapWidthBytes,
+ NULL,
+ &m_VMR9AlphaBitmapRect,
+ D3DX_FILTER_NONE,
+ m_VMR9AlphaBitmap.clrSrcKey);
+ }
+ if (FAILED(hr)) {
+ m_pOSDTexture = NULL;
+ m_pOSDSurface = NULL;
+ }
+ }
+ }
+ m_VMR9AlphaBitmap.dwFlags ^= VMRBITMAP_UPDATE;
+
+ }
+
+ if (pApp->m_bResetStats) {
+ ResetStats();
+ pApp->m_bResetStats = false;
+ }
+
+ if (pApp->m_fDisplayStats) {
+ DrawStats();
+ }
+
+ if (m_pOSDTexture) {
+ AlphaBlt(rSrcPri, rDstPri, m_pOSDTexture);
+ }
+
+ m_pD3DDev->EndScene();
+
+ BOOL bCompositionEnabled = m_bCompositionEnabled;
+
+ bool bDoVSyncInPresent = (!bCompositionEnabled && !m_bAlternativeVSync) || !s.m_RenderSettings.iVMR9VSync;
+
+ LONGLONG PresentWaitTime = 0;
+
+ CComPtr<IDirect3DQuery9> pEventQuery;
+
+ m_pD3DDev->CreateQuery(D3DQUERYTYPE_EVENT, &pEventQuery);
+ if (pEventQuery) {
+ pEventQuery->Issue(D3DISSUE_END);
+ }
+
+ if (s.m_RenderSettings.iVMRFlushGPUBeforeVSync && pEventQuery) {
+ LONGLONG llPerf = pApp->GetPerfCounter();
+ BOOL Data;
+ //Sleep(5);
+ LONGLONG FlushStartTime = pApp->GetPerfCounter();
+ while (S_FALSE == pEventQuery->GetData(&Data, sizeof(Data), D3DGETDATA_FLUSH)) {
+ if (!s.m_RenderSettings.iVMRFlushGPUWait) {
+ break;
+ }
+ Sleep(1);
+ if (pApp->GetPerfCounter() - FlushStartTime > 500000) {
+ break; // timeout after 50 ms
+ }
+ }
+ if (s.m_RenderSettings.iVMRFlushGPUWait) {
+ m_WaitForGPUTime = pApp->GetPerfCounter() - llPerf;
+ } else {
+ m_WaitForGPUTime = 0;
+ }
+ } else {
+ m_WaitForGPUTime = 0;
+ }
+
+ if (fAll) {
+ m_PaintTime = (GetRenderersData()->GetPerfCounter() - StartPaint);
+ m_PaintTimeMin = min(m_PaintTimeMin, m_PaintTime);
+ m_PaintTimeMax = max(m_PaintTimeMax, m_PaintTime);
+ }
+
+ bool bWaited = false;
+ bool bTakenLock = false;
+ if (fAll) {
+ // Only sync to refresh when redrawing all
+ bool bTest = WaitForVBlank(bWaited, bTakenLock);
+ ASSERT(bTest == bDoVSyncInPresent);
+ if (!bDoVSyncInPresent) {
+ LONGLONG Time = pApp->GetPerfCounter();
+ OnVBlankFinished(fAll, Time);
+ if (!m_bIsEVR || m_OrderedPaint) {
+ CalculateJitter(Time);
+ }
+ }
+ }
+
+ // Create a device pointer m_pd3dDevice
+
+ // Create a query object
+ {
+ CComPtr<IDirect3DQuery9> pEventQuery;
+ m_pD3DDev->CreateQuery(D3DQUERYTYPE_EVENT, &pEventQuery);
+
+ LONGLONG llPerf = pApp->GetPerfCounter();
+ if (m_pD3DDevEx) {
+ if (m_bIsFullscreen) {
+ hr = m_pD3DDevEx->PresentEx(NULL, NULL, NULL, NULL, NULL);
+ } else {
+ hr = m_pD3DDevEx->PresentEx(rSrcPri, rDstPri, NULL, NULL, NULL);
+ }
+ } else {
+ if (m_bIsFullscreen) {
+ hr = m_pD3DDev->Present(NULL, NULL, NULL, NULL);
+ } else {
+ hr = m_pD3DDev->Present(rSrcPri, rDstPri, NULL, NULL);
+ }
+ }
+ // Issue an End event
+ if (pEventQuery) {
+ pEventQuery->Issue(D3DISSUE_END);
+ }
+
+ BOOL Data;
+
+ if (s.m_RenderSettings.iVMRFlushGPUAfterPresent && pEventQuery) {
+ LONGLONG FlushStartTime = pApp->GetPerfCounter();
+ while (S_FALSE == pEventQuery->GetData(&Data, sizeof(Data), D3DGETDATA_FLUSH)) {
+ if (!s.m_RenderSettings.iVMRFlushGPUWait) {
+ break;
+ }
+ if (pApp->GetPerfCounter() - FlushStartTime > 500000) {
+ break; // timeout after 50 ms
+ }
+ }
+ }
+
+ int ScanLine;
+ int bInVBlank;
+ GetVBlank(ScanLine, bInVBlank, false);
+
+ if (fAll && (!m_bIsEVR || m_OrderedPaint)) {
+ m_VBlankEndPresent = ScanLine;
+ }
+
+ while (ScanLine == 0 || bInVBlank) {
+ GetVBlank(ScanLine, bInVBlank, false);
+
+ }
+ m_VBlankStartMeasureTime = pApp->GetPerfCounter();
+ m_VBlankStartMeasure = ScanLine;
+
+ if (fAll && bDoVSyncInPresent) {
+ m_PresentWaitTime = (pApp->GetPerfCounter() - llPerf) + PresentWaitTime;
+ m_PresentWaitTimeMin = min(m_PresentWaitTimeMin, m_PresentWaitTime);
+ m_PresentWaitTimeMax = max(m_PresentWaitTimeMax, m_PresentWaitTime);
+ } else {
+ m_PresentWaitTime = 0;
+ m_PresentWaitTimeMin = min(m_PresentWaitTimeMin, m_PresentWaitTime);
+ m_PresentWaitTimeMax = max(m_PresentWaitTimeMax, m_PresentWaitTime);
+ }
+ }
+
+ if (bDoVSyncInPresent) {
+ LONGLONG Time = pApp->GetPerfCounter();
+ if (!m_bIsEVR || m_OrderedPaint) {
+ CalculateJitter(Time);
+ }
+ OnVBlankFinished(fAll, Time);
+ }
+
+ if (bTakenLock) {
+ UnlockD3DDevice();
+ }
+
+ /*if (!bWaited)
+ {
+ bWaited = true;
+ WaitForVBlank(bWaited);
+ TRACE("Double VBlank\n");
+ ASSERT(bWaited);
+ if (!bDoVSyncInPresent)
+ {
+ CalculateJitter();
+ OnVBlankFinished(fAll);
+ }
+ }*/
+
+ if (!m_bPendingResetDevice) {
+ bool fResetDevice = false;
+
+ if (hr == D3DERR_DEVICELOST && m_pD3DDev->TestCooperativeLevel() == D3DERR_DEVICENOTRESET) {
+ TRACE("Reset Device: D3D Device Lost\n");
+ fResetDevice = true;
+ }
+
+ //if (hr == S_PRESENT_MODE_CHANGED)
+ //{
+ // TRACE("Reset Device: D3D Device mode changed\n");
+ // fResetDevice = true;
+ //}
+
+ if (SettingsNeedResetDevice()) {
+ TRACE("Reset Device: settings changed\n");
+ fResetDevice = true;
+ }
+
+ bCompositionEnabled = false;
+ if (m_pDwmIsCompositionEnabled) {
+ m_pDwmIsCompositionEnabled(&bCompositionEnabled);
+ }
+ if ((bCompositionEnabled != 0) != m_bCompositionEnabled) {
+ if (m_bIsFullscreen) {
+ m_bCompositionEnabled = (bCompositionEnabled != 0);
+ } else {
+ TRACE("Reset Device: DWM composition changed\n");
+ fResetDevice = true;
+ }
+ }
+
+ if (s.fResetDevice) {
+ LONGLONG time = GetRenderersData()->GetPerfCounter();
+ if (time > m_LastAdapterCheck + 20000000) { // check every 2 sec.
+ m_LastAdapterCheck = time;
#ifdef _DEBUG
- D3DDEVICE_CREATION_PARAMETERS Parameters;
- if (SUCCEEDED(m_pD3DDev->GetCreationParameters(&Parameters))) {
- ASSERT(Parameters.AdapterOrdinal == m_CurrentAdapter);
- }
+ D3DDEVICE_CREATION_PARAMETERS Parameters;
+ if (SUCCEEDED(m_pD3DDev->GetCreationParameters(&Parameters))) {
+ ASSERT(Parameters.AdapterOrdinal == m_CurrentAdapter);
+ }
#endif
- if (m_CurrentAdapter != GetAdapter(m_pD3D)) {
- TRACE("Reset Device: D3D adapter changed\n");
- fResetDevice = true;
- }
+ if (m_CurrentAdapter != GetAdapter(m_pD3D)) {
+ TRACE("Reset Device: D3D adapter changed\n");
+ fResetDevice = true;
+ }
#ifdef _DEBUG
- else {
- ASSERT(m_pD3D->GetAdapterMonitor(m_CurrentAdapter) == m_pD3D->GetAdapterMonitor(GetAdapter(m_pD3D)));
- }
+ else {
+ ASSERT(m_pD3D->GetAdapterMonitor(m_CurrentAdapter) == m_pD3D->GetAdapterMonitor(GetAdapter(m_pD3D)));
+ }
#endif
- }
- }
-
- if (fResetDevice) {
- m_bPendingResetDevice = true;
- SendResetRequest();
- }
- }
-
- if (m_OrderedPaint) {
- --m_OrderedPaint;
- } else {
- //if (m_bIsEVR)
- // TRACE("UNORDERED PAINT!!!!!!\n");
- }
- return true;
+ }
+ }
+
+ if (fResetDevice) {
+ m_bPendingResetDevice = true;
+ SendResetRequest();
+ }
+ }
+
+ if (m_OrderedPaint) {
+ --m_OrderedPaint;
+ } else {
+ //if (m_bIsEVR)
+ // TRACE("UNORDERED PAINT!!!!!!\n");
+ }
+ return true;
}
double CDX9AllocatorPresenter::GetFrameTime() const
{
- if (m_DetectedLock) {
- return m_DetectedFrameTime;
- }
+ if (m_DetectedLock) {
+ return m_DetectedFrameTime;
+ }
- return m_rtTimePerFrame / 10000000.0;
+ return m_rtTimePerFrame / 10000000.0;
}
double CDX9AllocatorPresenter::GetFrameRate() const
{
- if (m_DetectedLock) {
- return m_DetectedFrameRate;
- }
+ if (m_DetectedLock) {
+ return m_DetectedFrameRate;
+ }
- return 10000000.0 / m_rtTimePerFrame;
+ return 10000000.0 / m_rtTimePerFrame;
}
void CDX9AllocatorPresenter::SendResetRequest()
{
- if (!m_bDeviceResetRequested) {
- m_bDeviceResetRequested = true;
- AfxGetApp()->m_pMainWnd->PostMessage(WM_RESET_DEVICE);
- }
+ if (!m_bDeviceResetRequested) {
+ m_bDeviceResetRequested = true;
+ AfxGetApp()->m_pMainWnd->PostMessage(WM_RESET_DEVICE);
+ }
}
STDMETHODIMP_(bool) CDX9AllocatorPresenter::ResetDevice()
{
- TRACE("ResetDevice\n");
- _ASSERT(m_MainThreadId == GetCurrentThreadId());
- StopWorkerThreads();
-
- // In VMR-9 deleting the surfaces before we are told to is bad !
- // Can't comment out this because CDX9AllocatorPresenter is used by EVR Custom
- // Why is EVR using a presenter for DX9 anyway ?!
- DeleteSurfaces();
-
- HRESULT hr;
- CString Error;
- // TODO: Report error messages here
-
- // In VMR-9 'AllocSurfaces' call is redundant afaik because
- // 'CreateDevice' calls 'm_pIVMRSurfAllocNotify->ChangeD3DDevice' which in turn calls
- // 'CVMR9AllocatorPresenter::InitializeDevice' which calls 'AllocSurfaces'
- if (FAILED(hr = CreateDevice(Error)) || FAILED(hr = AllocSurfaces())) {
- // TODO: We should probably pause player
+ TRACE("ResetDevice\n");
+ _ASSERT(m_MainThreadId == GetCurrentThreadId());
+ StopWorkerThreads();
+
+ // In VMR-9 deleting the surfaces before we are told to is bad !
+ // Can't comment out this because CDX9AllocatorPresenter is used by EVR Custom
+ // Why is EVR using a presenter for DX9 anyway ?!
+ DeleteSurfaces();
+
+ HRESULT hr;
+ CString Error;
+ // TODO: Report error messages here
+
+ // In VMR-9 'AllocSurfaces' call is redundant afaik because
+ // 'CreateDevice' calls 'm_pIVMRSurfAllocNotify->ChangeD3DDevice' which in turn calls
+ // 'CVMR9AllocatorPresenter::InitializeDevice' which calls 'AllocSurfaces'
+ if (FAILED(hr = CreateDevice(Error)) || FAILED(hr = AllocSurfaces())) {
+ // TODO: We should probably pause player
#ifdef _DEBUG
- Error += GetWindowsErrorMessage(hr, NULL);
- TRACE("D3D Reset Error\n%ws\n\n", Error.GetBuffer());
+ Error += GetWindowsErrorMessage(hr, NULL);
+ TRACE("D3D Reset Error\n%ws\n\n", Error.GetBuffer());
#endif
- m_bDeviceResetRequested = false;
- return false;
- }
- OnResetDevice();
- m_bDeviceResetRequested = false;
- m_bPendingResetDevice = false;
-
- return true;
+ m_bDeviceResetRequested = false;
+ return false;
+ }
+ OnResetDevice();
+ m_bDeviceResetRequested = false;
+ m_bPendingResetDevice = false;
+
+ return true;
}
STDMETHODIMP_(bool) CDX9AllocatorPresenter::DisplayChange()
{
- SendResetRequest();
- return true;
+ SendResetRequest();
+ return true;
}
-void CDX9AllocatorPresenter::DrawText(const RECT &rc, const CString &strText, int _Priority)
+void CDX9AllocatorPresenter::DrawText(const RECT& rc, const CString& strText, int _Priority)
{
- if (_Priority < 1) {
- return;
- }
- int Quality = 1;
- D3DXCOLOR Color1( 1.0f, 0.2f, 0.2f, 1.0f );
- D3DXCOLOR Color0( 0.0f, 0.0f, 0.0f, 1.0f );
- RECT Rect1 = rc;
- RECT Rect2 = rc;
- if (Quality == 1) {
- OffsetRect (&Rect2 , 2, 2);
- } else {
- OffsetRect (&Rect2 , -1, -1);
- }
- if (Quality > 0) {
- m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- }
- OffsetRect (&Rect2 , 1, 0);
- if (Quality > 3) {
- m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- }
- OffsetRect (&Rect2 , 1, 0);
- if (Quality > 2) {
- m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- }
- OffsetRect (&Rect2 , 0, 1);
- if (Quality > 3) {
- m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- }
- OffsetRect (&Rect2 , 0, 1);
- if (Quality > 1) {
- m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- }
- OffsetRect (&Rect2 , -1, 0);
- if (Quality > 3) {
- m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- }
- OffsetRect (&Rect2 , -1, 0);
- if (Quality > 2) {
- m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- }
- OffsetRect (&Rect2 , 0, -1);
- if (Quality > 3) {
- m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- }
- m_pFont->DrawText( m_pSprite, strText, -1, &Rect1, DT_NOCLIP, Color1);
+ if (_Priority < 1) {
+ return;
+ }
+ int Quality = 1;
+ D3DXCOLOR Color1(1.0f, 0.2f, 0.2f, 1.0f);
+ D3DXCOLOR Color0(0.0f, 0.0f, 0.0f, 1.0f);
+ RECT Rect1 = rc;
+ RECT Rect2 = rc;
+ if (Quality == 1) {
+ OffsetRect(&Rect2 , 2, 2);
+ } else {
+ OffsetRect(&Rect2 , -1, -1);
+ }
+ if (Quality > 0) {
+ m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
+ OffsetRect(&Rect2 , 1, 0);
+ if (Quality > 3) {
+ m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
+ OffsetRect(&Rect2 , 1, 0);
+ if (Quality > 2) {
+ m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
+ OffsetRect(&Rect2 , 0, 1);
+ if (Quality > 3) {
+ m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
+ OffsetRect(&Rect2 , 0, 1);
+ if (Quality > 1) {
+ m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
+ OffsetRect(&Rect2 , -1, 0);
+ if (Quality > 3) {
+ m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
+ OffsetRect(&Rect2 , -1, 0);
+ if (Quality > 2) {
+ m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
+ OffsetRect(&Rect2 , 0, -1);
+ if (Quality > 3) {
+ m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
+ m_pFont->DrawText(m_pSprite, strText, -1, &Rect1, DT_NOCLIP, Color1);
}
void CDX9AllocatorPresenter::ResetStats()
{
- CRenderersData *pApp = GetRenderersData();
- LONGLONG Time = pApp->GetPerfCounter();
+ CRenderersData* pApp = GetRenderersData();
+ LONGLONG Time = pApp->GetPerfCounter();
- m_PaintTime = 0;
- m_PaintTimeMin = 0;
- m_PaintTimeMax = 0;
+ m_PaintTime = 0;
+ m_PaintTimeMin = 0;
+ m_PaintTimeMax = 0;
- m_RasterStatusWaitTime = 0;
- m_RasterStatusWaitTimeMin = 0;
- m_RasterStatusWaitTimeMax = 0;
+ m_RasterStatusWaitTime = 0;
+ m_RasterStatusWaitTimeMin = 0;
+ m_RasterStatusWaitTimeMax = 0;
- m_MinSyncOffset = 0;
- m_MaxSyncOffset = 0;
- m_fSyncOffsetAvr = 0;
- m_fSyncOffsetStdDev = 0;
+ m_MinSyncOffset = 0;
+ m_MaxSyncOffset = 0;
+ m_fSyncOffsetAvr = 0;
+ m_fSyncOffsetStdDev = 0;
- CalculateJitter(Time);
+ CalculateJitter(Time);
}
void CDX9AllocatorPresenter::DrawStats()
{
- CRenderersSettings& s = GetRenderersSettings();
- CRenderersData *pApp = GetRenderersData();
- int bDetailedStats = 2;
- switch (pApp->m_fDisplayStats) {
- case 1:
- bDetailedStats = 2;
- break;
- case 2:
- bDetailedStats = 1;
- break;
- case 3:
- bDetailedStats = 0;
- break;
- }
-
- LONGLONG llMaxJitter = m_MaxJitter;
- LONGLONG llMinJitter = m_MinJitter;
- LONGLONG llMaxSyncOffset = m_MaxSyncOffset;
- LONGLONG llMinSyncOffset = m_MinSyncOffset;
- RECT rc = {40, 40, 0, 0 };
- if (m_pFont && m_pSprite) {
- m_pSprite->Begin(D3DXSPRITE_ALPHABLEND);
- CString strText;
- int TextHeight = int(25.0*m_TextScale + 0.5);
- //strText.Format(L"Frame rate : %7.03f (%7.3f ms = %.03f, %s) (%7.3f ms = %.03f%s) Clock: %7.3f ms %+1.4f %% %+1.9f %+1.9f", m_fAvrFps, double(m_rtTimePerFrame) / 10000.0, 10000000.0 / (double)(m_rtTimePerFrame), m_bInterlaced ? L"I" : L"P", GetFrameTime() * 1000.0, GetFrameRate(), m_DetectedLock ? L" L" : L"", m_ClockDiff/10000.0, m_ModeratedTimeSpeed*100.0 - 100.0, m_ModeratedTimeSpeedDiff, m_ClockDiffCalc/10000.0);
- if (bDetailedStats > 1) {
- if (m_bIsEVR) {
- if (m_nFrameType != PICT_NONE) {
- strText.Format(L"Frame rate : %7.03f (%7.3f ms = %.03f, %s) (%7.3f ms = %.03f%s, %2.03f StdDev) Clock: %1.4f %%", m_fAvrFps, double(m_rtTimePerFrame) / 10000.0, 10000000.0 / (double)(m_rtTimePerFrame), m_nFrameType == PICT_FRAME ? L"P" : L"I", GetFrameTime() * 1000.0, GetFrameRate(), m_DetectedLock ? L" L" : L"", m_DetectedFrameTimeStdDev / 10000.0, m_ModeratedTimeSpeed*100.0);
- } else {
- strText.Format(L"Frame rate : %7.03f (%7.3f ms = %.03f, %s) (%7.3f ms = %.03f%s, %2.03f StdDev) Clock: %1.4f %%", m_fAvrFps, double(m_rtTimePerFrame) / 10000.0, 10000000.0 / (double)(m_rtTimePerFrame), m_bInterlaced ? L"I" : L"P", GetFrameTime() * 1000.0, GetFrameRate(), m_DetectedLock ? L" L" : L"", m_DetectedFrameTimeStdDev / 10000.0, m_ModeratedTimeSpeed*100.0);
- }
- } else {
- strText.Format(L"Frame rate : %7.03f (%7.3f ms = %.03f, %s)", m_fAvrFps, double(m_rtTimePerFrame) / 10000.0, 10000000.0 / (double)(m_rtTimePerFrame), m_bInterlaced ? L"I" : L"P");
- }
- }
- //strText.Format(L"Frame rate : %7.03f (%7.3f ms = %.03f, %s) (%7.3f ms = %.03f%s, %2.03f StdDev)", m_fAvrFps, double(m_rtTimePerFrame) / 10000.0, 10000000.0 / (double)(m_rtTimePerFrame), m_bInterlaced ? L"I" : L"P", GetFrameTime() * 1000.0, GetFrameRate(), m_DetectedLock ? L" L" : L"", m_DetectedFrameTimeStdDev / 10000.0);
- else {
- strText.Format(L"Frame rate : %7.03f (%.03f%s)", m_fAvrFps, GetFrameRate(), m_DetectedLock ? L" L" : L"");
- }
- DrawText(rc, strText, 1);
- OffsetRect (&rc, 0, TextHeight);
-
- if (m_nFrameType != PICT_NONE) {
- strText.Format(L"Frame type : %s", m_nFrameType == PICT_FRAME ? L"Progressive" : m_nFrameType == PICT_BOTTOM_FIELD ? L"Interlaced : Bottom field first" : L"Interlaced : Top field first");
- DrawText(rc, strText, 1);
- OffsetRect (&rc, 0, TextHeight);
- }
-
- if (bDetailedStats > 1) {
- strText = L"Settings : ";
-
- if (m_bIsEVR) {
- strText += "EVR ";
- } else {
- strText += "VMR9 ";
- }
-
- if (m_bIsFullscreen) {
- strText += "FS ";
- }
- if (s.m_RenderSettings.iVMR9FullscreenGUISupport) {
- strText += "FSGui ";
- }
-
- if (s.m_RenderSettings.iVMRDisableDesktopComposition) {
- strText += "DisDC ";
- }
-
- if (m_bColorManagement) {
- strText += "ColorMan ";
- }
-
- if (s.m_RenderSettings.iVMRFlushGPUBeforeVSync) {
- strText += "GPUFlushBV ";
- }
- if (s.m_RenderSettings.iVMRFlushGPUAfterPresent) {
- strText += "GPUFlushAP ";
- }
-
- if (s.m_RenderSettings.iVMRFlushGPUWait) {
- strText += "GPUFlushWt ";
- }
-
- if (s.m_RenderSettings.iVMR9VSync) {
- strText += "VS ";
- }
- if (s.m_RenderSettings.fVMR9AlterativeVSync) {
- strText += "AltVS ";
- }
- if (s.m_RenderSettings.iVMR9VSyncAccurate) {
- strText += "AccVS ";
- }
- if (s.m_RenderSettings.iVMR9VSyncOffset) {
- strText.AppendFormat(L"VSOfst(%d)", s.m_RenderSettings.iVMR9VSyncOffset);
- }
-
- if (m_bFullFloatingPointProcessing) {
- strText += "FullFP ";
- }
-
- if (m_bHalfFloatingPointProcessing) {
- strText += "HalfFP ";
- }
-
- if (m_bIsEVR) {
- if (m_bHighColorResolution) {
- strText += "10bitOut ";
- }
- if (m_bForceInputHighColorResolution) {
- strText += "For10bitIn ";
- }
- if (s.m_RenderSettings.iEVREnableFrameTimeCorrection) {
- strText += "FTC ";
- }
- if (s.m_RenderSettings.iEVROutputRange == 0) {
- strText += "0-255 ";
- } else if (s.m_RenderSettings.iEVROutputRange == 1) {
- strText += "16-235 ";
- }
- }
-
-
- DrawText(rc, strText, 1);
- OffsetRect (&rc, 0, TextHeight);
-
- }
-
- if (bDetailedStats > 1) {
- strText.Format(L"Formats : Surface %s Backbuffer %s Display %s Device %s D3DExError: %s", GetD3DFormatStr(m_SurfaceType), GetD3DFormatStr(m_BackbufferType), GetD3DFormatStr(m_DisplayType), m_pD3DDevEx ? L"D3DDevEx" : L"D3DDev", m_D3DDevExError.GetString());
- DrawText(rc, strText, 1);
- OffsetRect (&rc, 0, TextHeight);
-
- if (m_bIsEVR) {
- strText.Format(L"Refresh rate : %.05f Hz SL: %4d (%3d Hz) Last Duration: %10.6f Corrected Frame Time: %s", m_DetectedRefreshRate, int(m_DetectedScanlinesPerFrame + 0.5), m_RefreshRate, double(m_LastFrameDuration)/10000.0, m_bCorrectedFrameTime?L"Yes":L"No");
- DrawText(rc, strText, 1);
- OffsetRect (&rc, 0, TextHeight);
- }
- }
-
- if (m_bSyncStatsAvailable) {
- if (bDetailedStats > 1) {
- strText.Format(L"Sync offset : Min = %+8.3f ms, Max = %+8.3f ms, StdDev = %7.3f ms, Avr = %7.3f ms, Mode = %d", (double(llMinSyncOffset)/10000.0), (double(llMaxSyncOffset)/10000.0), m_fSyncOffsetStdDev/10000.0, m_fSyncOffsetAvr/10000.0, m_VSyncMode);
- } else {
- strText.Format(L"Sync offset : Mode = %d", m_VSyncMode);
- }
- DrawText(rc, strText, 1);
- OffsetRect (&rc, 0, TextHeight);
- }
-
- if (bDetailedStats > 1) {
- strText.Format(L"Jitter : Min = %+8.3f ms, Max = %+8.3f ms, StdDev = %7.3f ms", (double(llMinJitter)/10000.0), (double(llMaxJitter)/10000.0), m_fJitterStdDev/10000.0);
- DrawText(rc, strText, 1);
- OffsetRect (&rc, 0, TextHeight);
- }
-
- if (m_pAllocator && bDetailedStats > 1) {
- CDX9SubPicAllocator *pAlloc = (CDX9SubPicAllocator *)m_pAllocator.p;
- int nFree = 0;
- int nAlloc = 0;
- int nSubPic = 0;
- REFERENCE_TIME QueueStart = 0;
- REFERENCE_TIME QueueEnd = 0;
-
- if (m_pSubPicQueue) {
- REFERENCE_TIME QueueNow = 0;
- m_pSubPicQueue->GetStats(nSubPic, QueueNow, QueueStart, QueueEnd);
-
- if (QueueStart) {
- QueueStart -= QueueNow;
- }
-
- if (QueueEnd) {
- QueueEnd -= QueueNow;
- }
- }
-
- pAlloc->GetStats(nFree, nAlloc);
- strText.Format(L"Subtitles : Free %d Allocated %d Buffered %d QueueStart %7.3f QueueEnd %7.3f", nFree, nAlloc, nSubPic, (double(QueueStart)/10000000.0), (double(QueueEnd)/10000000.0));
- DrawText(rc, strText, 1);
- OffsetRect (&rc, 0, TextHeight);
- }
-
- if (bDetailedStats > 1) {
- if (m_VBlankEndPresent == -100000) {
- strText.Format(L"VBlank Wait : Start %4d End %4d Wait %7.3f ms Lock %7.3f ms Offset %4d Max %4d", m_VBlankStartWait, m_VBlankEndWait, (double(m_VBlankWaitTime)/10000.0), (double(m_VBlankLockTime)/10000.0), m_VBlankMin, m_VBlankMax - m_VBlankMin);
- } else {
- strText.Format(L"VBlank Wait : Start %4d End %4d Wait %7.3f ms Lock %7.3f ms Offset %4d Max %4d EndPresent %4d", m_VBlankStartWait, m_VBlankEndWait, (double(m_VBlankWaitTime)/10000.0), (double(m_VBlankLockTime)/10000.0), m_VBlankMin, m_VBlankMax - m_VBlankMin, m_VBlankEndPresent);
- }
- } else {
- if (m_VBlankEndPresent == -100000) {
- strText.Format(L"VBlank Wait : Start %4d End %4d", m_VBlankStartWait, m_VBlankEndWait);
- } else {
- strText.Format(L"VBlank Wait : Start %4d End %4d EP %4d", m_VBlankStartWait, m_VBlankEndWait, m_VBlankEndPresent);
- }
- }
- DrawText(rc, strText, 1);
- OffsetRect (&rc, 0, TextHeight);
-
- BOOL bCompositionEnabled = m_bCompositionEnabled;
-
- bool bDoVSyncInPresent = (!bCompositionEnabled && !m_bAlternativeVSync) || !s.m_RenderSettings.iVMR9VSync;
-
- if (bDetailedStats > 1 && bDoVSyncInPresent) {
- strText.Format(L"Present Wait : Wait %7.3f ms Min %7.3f ms Max %7.3f ms", (double(m_PresentWaitTime)/10000.0), (double(m_PresentWaitTimeMin)/10000.0), (double(m_PresentWaitTimeMax)/10000.0));
- DrawText(rc, strText, 1);
- OffsetRect (&rc, 0, TextHeight);
- }
-
- if (bDetailedStats > 1) {
- if (m_WaitForGPUTime) {
- strText.Format(L"Paint Time : Draw %7.3f ms Min %7.3f ms Max %7.3f ms GPU %7.3f ms", (double(m_PaintTime-m_WaitForGPUTime)/10000.0), (double(m_PaintTimeMin)/10000.0), (double(m_PaintTimeMax)/10000.0), (double(m_WaitForGPUTime)/10000.0));
- } else {
- strText.Format(L"Paint Time : Draw %7.3f ms Min %7.3f ms Max %7.3f ms", (double(m_PaintTime-m_WaitForGPUTime)/10000.0), (double(m_PaintTimeMin)/10000.0), (double(m_PaintTimeMax)/10000.0));
- }
- } else {
- if (m_WaitForGPUTime) {
- strText.Format(L"Paint Time : Draw %7.3f ms GPU %7.3f ms", (double(m_PaintTime - m_WaitForGPUTime)/10000.0), (double(m_WaitForGPUTime)/10000.0));
- } else {
- strText.Format(L"Paint Time : Draw %7.3f ms", (double(m_PaintTime - m_WaitForGPUTime)/10000.0));
- }
- }
- DrawText(rc, strText, 2);
- OffsetRect (&rc, 0, TextHeight);
-
- if (bDetailedStats > 1) {
- strText.Format(L"Raster Status: Wait %7.3f ms Min %7.3f ms Max %7.3f ms", (double(m_RasterStatusWaitTime)/10000.0), (double(m_RasterStatusWaitTimeMin)/10000.0), (double(m_RasterStatusWaitTimeMax)/10000.0));
- DrawText(rc, strText, 1);
- OffsetRect (&rc, 0, TextHeight);
- }
-
- if (bDetailedStats > 1) {
- if (m_bIsEVR) {
- strText.Format(L"Buffering : Buffered %3d Free %3d Current Surface %3d", m_nUsedBuffer, m_nNbDXSurface - m_nUsedBuffer, m_nCurSurface, m_nVMR9Surfaces, m_iVMR9Surface);
- } else {
- strText.Format(L"Buffering : VMR9Surfaces %3d VMR9Surface %3d", m_nVMR9Surfaces, m_iVMR9Surface);
- }
- } else {
- strText.Format(L"Buffered : %3d", m_nUsedBuffer);
- }
- DrawText(rc, strText, 1);
- OffsetRect (&rc, 0, TextHeight);
-
- if (bDetailedStats > 1) {
- strText.Format(L"Video size : %d x %d (AR = %d : %d)", m_NativeVideoSize.cx, m_NativeVideoSize.cy, m_AspectRatio.cx, m_AspectRatio.cy);
- DrawText(rc, strText, 1);
- OffsetRect (&rc, 0, TextHeight);
- if (m_pVideoTexture[0] || m_pVideoSurface[0]) {
- D3DSURFACE_DESC desc;
- if (m_pVideoTexture[0]) {
- m_pVideoTexture[0]->GetLevelDesc(0, &desc);
- } else if (m_pVideoSurface[0]) {
- m_pVideoSurface[0]->GetDesc(&desc);
- }
-
- if (desc.Width != (UINT)m_NativeVideoSize.cx || desc.Height != (UINT)m_NativeVideoSize.cy) {
- strText.Format(L"Texture size : %d x %d", desc.Width, desc.Height);
- DrawText(rc, strText, 1);
- OffsetRect (&rc, 0, TextHeight);
- }
- }
-
-
- strText.Format(L"%-13s: %s", GetDXVAVersion(), GetDXVADecoderDescription());
- DrawText(rc, strText, 1);
- OffsetRect (&rc, 0, TextHeight);
-
- strText.Format(L"DirectX SDK : %u", GetRenderersData()->GetDXSdkRelease());
- DrawText(rc, strText, 1);
- OffsetRect (&rc, 0, TextHeight);
-
- if (m_D3D9Device != _T("")) {
- strText = "Render device: " + m_D3D9Device;
- DrawText(rc, strText, 1);
- OffsetRect (&rc, 0, TextHeight);
- }
-
- if (m_Decoder != _T("")) {
- strText = "Decoder : " + m_Decoder;
- DrawText(rc, strText, 1);
- OffsetRect (&rc, 0, TextHeight);
- }
-
- for (int i=0; i<6; i++) {
- if (m_strStatsMsg[i][0]) {
- DrawText(rc, m_strStatsMsg[i], 1);
- OffsetRect (&rc, 0, TextHeight);
- }
- }
- }
- m_pSprite->End();
- OffsetRect(&rc, 0, TextHeight); // Extra "line feed"
- }
-
- if (m_pLine && bDetailedStats) {
- D3DXVECTOR2 Points[NB_JITTER];
- int nIndex;
-
- int StartX = 0;
- int StartY = 0;
- int ScaleX = 1;
- int ScaleY = 1;
- int DrawWidth = 625 * ScaleX + 50;
- int DrawHeight = 250 * ScaleY;
- int Alpha = 80;
- StartX = m_WindowRect.Width() - (DrawWidth + 20);
- StartY = m_WindowRect.Height() - (DrawHeight + 20);
-
- DrawRect(RGB(0,0,0), Alpha, CRect(StartX, StartY, StartX + DrawWidth, StartY + DrawHeight));
- // === Jitter Graduation
- //m_pLine->SetWidth(2.2); // Width
- //m_pLine->SetAntialias(1);
- m_pLine->SetWidth(2.5); // Width
- m_pLine->SetAntialias(1);
- //m_pLine->SetGLLines(1);
- m_pLine->Begin();
-
- for (int i=10; i<250*ScaleY; i+= 10*ScaleY) {
- Points[0].x = (FLOAT)StartX;
- Points[0].y = (FLOAT)(StartY + i);
- Points[1].x = (FLOAT)(StartX + ((i-10)%40 ? 50 : 625 * ScaleX));
- Points[1].y = (FLOAT)(StartY + i);
- if (i == 130) {
- Points[1].x += 50;
- }
- m_pLine->Draw (Points, 2, D3DCOLOR_XRGB(100,100,255));
- }
-
- // === Jitter curve
- if (m_rtTimePerFrame) {
- for (int i=0; i<NB_JITTER; i++) {
- nIndex = (m_nNextJitter+1+i) % NB_JITTER;
- if (nIndex < 0) {
- nIndex += NB_JITTER;
- }
- double Jitter = m_pllJitter[nIndex] - m_fJitterMean;
- Points[i].x = (FLOAT)(StartX + (i*5*ScaleX+5));
- Points[i].y = (FLOAT)(StartY + ((Jitter*ScaleY)/5000.0 + 125.0* ScaleY));
- }
- m_pLine->Draw (Points, NB_JITTER, D3DCOLOR_XRGB(255,100,100));
-
- if (m_bSyncStatsAvailable) {
- for (int i=0; i<NB_JITTER; i++) {
- nIndex = (m_nNextSyncOffset+1+i) % NB_JITTER;
- if (nIndex < 0) {
- nIndex += NB_JITTER;
- }
- Points[i].x = (FLOAT)(StartX + (i*5*ScaleX+5));
- Points[i].y = (FLOAT)(StartY + ((m_pllSyncOffset[nIndex]*ScaleY)/5000 + 125*ScaleY));
- }
- m_pLine->Draw (Points, NB_JITTER, D3DCOLOR_XRGB(100,200,100));
- }
- }
- m_pLine->End();
- }
-
- // === Text
+ CRenderersSettings& s = GetRenderersSettings();
+ CRenderersData* pApp = GetRenderersData();
+ int bDetailedStats = 2;
+ switch (pApp->m_fDisplayStats) {
+ case 1:
+ bDetailedStats = 2;
+ break;
+ case 2:
+ bDetailedStats = 1;
+ break;
+ case 3:
+ bDetailedStats = 0;
+ break;
+ }
+
+ LONGLONG llMaxJitter = m_MaxJitter;
+ LONGLONG llMinJitter = m_MinJitter;
+ LONGLONG llMaxSyncOffset = m_MaxSyncOffset;
+ LONGLONG llMinSyncOffset = m_MinSyncOffset;
+ RECT rc = {40, 40, 0, 0 };
+ if (m_pFont && m_pSprite) {
+ m_pSprite->Begin(D3DXSPRITE_ALPHABLEND);
+ CString strText;
+ int TextHeight = int(25.0 * m_TextScale + 0.5);
+ //strText.Format(L"Frame rate : %7.03f (%7.3f ms = %.03f, %s) (%7.3f ms = %.03f%s) Clock: %7.3f ms %+1.4f %% %+1.9f %+1.9f", m_fAvrFps, double(m_rtTimePerFrame) / 10000.0, 10000000.0 / (double)(m_rtTimePerFrame), m_bInterlaced ? L"I" : L"P", GetFrameTime() * 1000.0, GetFrameRate(), m_DetectedLock ? L" L" : L"", m_ClockDiff/10000.0, m_ModeratedTimeSpeed*100.0 - 100.0, m_ModeratedTimeSpeedDiff, m_ClockDiffCalc/10000.0);
+ if (bDetailedStats > 1) {
+ if (m_bIsEVR) {
+ if (m_nFrameType != PICT_NONE) {
+ strText.Format(L"Frame rate : %7.03f (%7.3f ms = %.03f, %s) (%7.3f ms = %.03f%s, %2.03f StdDev) Clock: %1.4f %%", m_fAvrFps, double(m_rtTimePerFrame) / 10000.0, 10000000.0 / (double)(m_rtTimePerFrame), m_nFrameType == PICT_FRAME ? L"P" : L"I", GetFrameTime() * 1000.0, GetFrameRate(), m_DetectedLock ? L" L" : L"", m_DetectedFrameTimeStdDev / 10000.0, m_ModeratedTimeSpeed * 100.0);
+ } else {
+ strText.Format(L"Frame rate : %7.03f (%7.3f ms = %.03f, %s) (%7.3f ms = %.03f%s, %2.03f StdDev) Clock: %1.4f %%", m_fAvrFps, double(m_rtTimePerFrame) / 10000.0, 10000000.0 / (double)(m_rtTimePerFrame), m_bInterlaced ? L"I" : L"P", GetFrameTime() * 1000.0, GetFrameRate(), m_DetectedLock ? L" L" : L"", m_DetectedFrameTimeStdDev / 10000.0, m_ModeratedTimeSpeed * 100.0);
+ }
+ } else {
+ strText.Format(L"Frame rate : %7.03f (%7.3f ms = %.03f, %s)", m_fAvrFps, double(m_rtTimePerFrame) / 10000.0, 10000000.0 / (double)(m_rtTimePerFrame), m_bInterlaced ? L"I" : L"P");
+ }
+ }
+ //strText.Format(L"Frame rate : %7.03f (%7.3f ms = %.03f, %s) (%7.3f ms = %.03f%s, %2.03f StdDev)", m_fAvrFps, double(m_rtTimePerFrame) / 10000.0, 10000000.0 / (double)(m_rtTimePerFrame), m_bInterlaced ? L"I" : L"P", GetFrameTime() * 1000.0, GetFrameRate(), m_DetectedLock ? L" L" : L"", m_DetectedFrameTimeStdDev / 10000.0);
+ else {
+ strText.Format(L"Frame rate : %7.03f (%.03f%s)", m_fAvrFps, GetFrameRate(), m_DetectedLock ? L" L" : L"");
+ }
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ if (m_nFrameType != PICT_NONE) {
+ strText.Format(L"Frame type : %s", m_nFrameType == PICT_FRAME ? L"Progressive" : m_nFrameType == PICT_BOTTOM_FIELD ? L"Interlaced : Bottom field first" : L"Interlaced : Top field first");
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ }
+
+ if (bDetailedStats > 1) {
+ strText = L"Settings : ";
+
+ if (m_bIsEVR) {
+ strText += "EVR ";
+ } else {
+ strText += "VMR9 ";
+ }
+
+ if (m_bIsFullscreen) {
+ strText += "FS ";
+ }
+ if (s.m_RenderSettings.iVMR9FullscreenGUISupport) {
+ strText += "FSGui ";
+ }
+
+ if (s.m_RenderSettings.iVMRDisableDesktopComposition) {
+ strText += "DisDC ";
+ }
+
+ if (m_bColorManagement) {
+ strText += "ColorMan ";
+ }
+
+ if (s.m_RenderSettings.iVMRFlushGPUBeforeVSync) {
+ strText += "GPUFlushBV ";
+ }
+ if (s.m_RenderSettings.iVMRFlushGPUAfterPresent) {
+ strText += "GPUFlushAP ";
+ }
+
+ if (s.m_RenderSettings.iVMRFlushGPUWait) {
+ strText += "GPUFlushWt ";
+ }
+
+ if (s.m_RenderSettings.iVMR9VSync) {
+ strText += "VS ";
+ }
+ if (s.m_RenderSettings.fVMR9AlterativeVSync) {
+ strText += "AltVS ";
+ }
+ if (s.m_RenderSettings.iVMR9VSyncAccurate) {
+ strText += "AccVS ";
+ }
+ if (s.m_RenderSettings.iVMR9VSyncOffset) {
+ strText.AppendFormat(L"VSOfst(%d)", s.m_RenderSettings.iVMR9VSyncOffset);
+ }
+
+ if (m_bFullFloatingPointProcessing) {
+ strText += "FullFP ";
+ }
+
+ if (m_bHalfFloatingPointProcessing) {
+ strText += "HalfFP ";
+ }
+
+ if (m_bIsEVR) {
+ if (m_bHighColorResolution) {
+ strText += "10bitOut ";
+ }
+ if (m_bForceInputHighColorResolution) {
+ strText += "For10bitIn ";
+ }
+ if (s.m_RenderSettings.iEVREnableFrameTimeCorrection) {
+ strText += "FTC ";
+ }
+ if (s.m_RenderSettings.iEVROutputRange == 0) {
+ strText += "0-255 ";
+ } else if (s.m_RenderSettings.iEVROutputRange == 1) {
+ strText += "16-235 ";
+ }
+ }
+
+
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ }
+
+ if (bDetailedStats > 1) {
+ strText.Format(L"Formats : Surface %s Backbuffer %s Display %s Device %s D3DExError: %s", GetD3DFormatStr(m_SurfaceType), GetD3DFormatStr(m_BackbufferType), GetD3DFormatStr(m_DisplayType), m_pD3DDevEx ? L"D3DDevEx" : L"D3DDev", m_D3DDevExError.GetString());
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ if (m_bIsEVR) {
+ strText.Format(L"Refresh rate : %.05f Hz SL: %4d (%3d Hz) Last Duration: %10.6f Corrected Frame Time: %s", m_DetectedRefreshRate, int(m_DetectedScanlinesPerFrame + 0.5), m_RefreshRate, double(m_LastFrameDuration) / 10000.0, m_bCorrectedFrameTime ? L"Yes" : L"No");
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ }
+ }
+
+ if (m_bSyncStatsAvailable) {
+ if (bDetailedStats > 1) {
+ strText.Format(L"Sync offset : Min = %+8.3f ms, Max = %+8.3f ms, StdDev = %7.3f ms, Avr = %7.3f ms, Mode = %d", (double(llMinSyncOffset) / 10000.0), (double(llMaxSyncOffset) / 10000.0), m_fSyncOffsetStdDev / 10000.0, m_fSyncOffsetAvr / 10000.0, m_VSyncMode);
+ } else {
+ strText.Format(L"Sync offset : Mode = %d", m_VSyncMode);
+ }
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ }
+
+ if (bDetailedStats > 1) {
+ strText.Format(L"Jitter : Min = %+8.3f ms, Max = %+8.3f ms, StdDev = %7.3f ms", (double(llMinJitter) / 10000.0), (double(llMaxJitter) / 10000.0), m_fJitterStdDev / 10000.0);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ }
+
+ if (m_pAllocator && bDetailedStats > 1) {
+ CDX9SubPicAllocator* pAlloc = (CDX9SubPicAllocator*)m_pAllocator.p;
+ int nFree = 0;
+ int nAlloc = 0;
+ int nSubPic = 0;
+ REFERENCE_TIME QueueStart = 0;
+ REFERENCE_TIME QueueEnd = 0;
+
+ if (m_pSubPicQueue) {
+ REFERENCE_TIME QueueNow = 0;
+ m_pSubPicQueue->GetStats(nSubPic, QueueNow, QueueStart, QueueEnd);
+
+ if (QueueStart) {
+ QueueStart -= QueueNow;
+ }
+
+ if (QueueEnd) {
+ QueueEnd -= QueueNow;
+ }
+ }
+
+ pAlloc->GetStats(nFree, nAlloc);
+ strText.Format(L"Subtitles : Free %d Allocated %d Buffered %d QueueStart %7.3f QueueEnd %7.3f", nFree, nAlloc, nSubPic, (double(QueueStart) / 10000000.0), (double(QueueEnd) / 10000000.0));
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ }
+
+ if (bDetailedStats > 1) {
+ if (m_VBlankEndPresent == -100000) {
+ strText.Format(L"VBlank Wait : Start %4d End %4d Wait %7.3f ms Lock %7.3f ms Offset %4d Max %4d", m_VBlankStartWait, m_VBlankEndWait, (double(m_VBlankWaitTime) / 10000.0), (double(m_VBlankLockTime) / 10000.0), m_VBlankMin, m_VBlankMax - m_VBlankMin);
+ } else {
+ strText.Format(L"VBlank Wait : Start %4d End %4d Wait %7.3f ms Lock %7.3f ms Offset %4d Max %4d EndPresent %4d", m_VBlankStartWait, m_VBlankEndWait, (double(m_VBlankWaitTime) / 10000.0), (double(m_VBlankLockTime) / 10000.0), m_VBlankMin, m_VBlankMax - m_VBlankMin, m_VBlankEndPresent);
+ }
+ } else {
+ if (m_VBlankEndPresent == -100000) {
+ strText.Format(L"VBlank Wait : Start %4d End %4d", m_VBlankStartWait, m_VBlankEndWait);
+ } else {
+ strText.Format(L"VBlank Wait : Start %4d End %4d EP %4d", m_VBlankStartWait, m_VBlankEndWait, m_VBlankEndPresent);
+ }
+ }
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ BOOL bCompositionEnabled = m_bCompositionEnabled;
+
+ bool bDoVSyncInPresent = (!bCompositionEnabled && !m_bAlternativeVSync) || !s.m_RenderSettings.iVMR9VSync;
+
+ if (bDetailedStats > 1 && bDoVSyncInPresent) {
+ strText.Format(L"Present Wait : Wait %7.3f ms Min %7.3f ms Max %7.3f ms", (double(m_PresentWaitTime) / 10000.0), (double(m_PresentWaitTimeMin) / 10000.0), (double(m_PresentWaitTimeMax) / 10000.0));
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ }
+
+ if (bDetailedStats > 1) {
+ if (m_WaitForGPUTime) {
+ strText.Format(L"Paint Time : Draw %7.3f ms Min %7.3f ms Max %7.3f ms GPU %7.3f ms", (double(m_PaintTime - m_WaitForGPUTime) / 10000.0), (double(m_PaintTimeMin) / 10000.0), (double(m_PaintTimeMax) / 10000.0), (double(m_WaitForGPUTime) / 10000.0));
+ } else {
+ strText.Format(L"Paint Time : Draw %7.3f ms Min %7.3f ms Max %7.3f ms", (double(m_PaintTime - m_WaitForGPUTime) / 10000.0), (double(m_PaintTimeMin) / 10000.0), (double(m_PaintTimeMax) / 10000.0));
+ }
+ } else {
+ if (m_WaitForGPUTime) {
+ strText.Format(L"Paint Time : Draw %7.3f ms GPU %7.3f ms", (double(m_PaintTime - m_WaitForGPUTime) / 10000.0), (double(m_WaitForGPUTime) / 10000.0));
+ } else {
+ strText.Format(L"Paint Time : Draw %7.3f ms", (double(m_PaintTime - m_WaitForGPUTime) / 10000.0));
+ }
+ }
+ DrawText(rc, strText, 2);
+ OffsetRect(&rc, 0, TextHeight);
+
+ if (bDetailedStats > 1) {
+ strText.Format(L"Raster Status: Wait %7.3f ms Min %7.3f ms Max %7.3f ms", (double(m_RasterStatusWaitTime) / 10000.0), (double(m_RasterStatusWaitTimeMin) / 10000.0), (double(m_RasterStatusWaitTimeMax) / 10000.0));
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ }
+
+ if (bDetailedStats > 1) {
+ if (m_bIsEVR) {
+ strText.Format(L"Buffering : Buffered %3d Free %3d Current Surface %3d", m_nUsedBuffer, m_nNbDXSurface - m_nUsedBuffer, m_nCurSurface, m_nVMR9Surfaces, m_iVMR9Surface);
+ } else {
+ strText.Format(L"Buffering : VMR9Surfaces %3d VMR9Surface %3d", m_nVMR9Surfaces, m_iVMR9Surface);
+ }
+ } else {
+ strText.Format(L"Buffered : %3d", m_nUsedBuffer);
+ }
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ if (bDetailedStats > 1) {
+ strText.Format(L"Video size : %d x %d (AR = %d : %d)", m_NativeVideoSize.cx, m_NativeVideoSize.cy, m_AspectRatio.cx, m_AspectRatio.cy);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ if (m_pVideoTexture[0] || m_pVideoSurface[0]) {
+ D3DSURFACE_DESC desc;
+ if (m_pVideoTexture[0]) {
+ m_pVideoTexture[0]->GetLevelDesc(0, &desc);
+ } else if (m_pVideoSurface[0]) {
+ m_pVideoSurface[0]->GetDesc(&desc);
+ }
+
+ if (desc.Width != (UINT)m_NativeVideoSize.cx || desc.Height != (UINT)m_NativeVideoSize.cy) {
+ strText.Format(L"Texture size : %d x %d", desc.Width, desc.Height);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ }
+ }
+
+
+ strText.Format(L"%-13s: %s", GetDXVAVersion(), GetDXVADecoderDescription());
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ strText.Format(L"DirectX SDK : %u", GetRenderersData()->GetDXSdkRelease());
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ if (m_D3D9Device != _T("")) {
+ strText = "Render device: " + m_D3D9Device;
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ }
+
+ if (m_Decoder != _T("")) {
+ strText = "Decoder : " + m_Decoder;
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ }
+
+ for (int i = 0; i < 6; i++) {
+ if (m_strStatsMsg[i][0]) {
+ DrawText(rc, m_strStatsMsg[i], 1);
+ OffsetRect(&rc, 0, TextHeight);
+ }
+ }
+ }
+ m_pSprite->End();
+ OffsetRect(&rc, 0, TextHeight); // Extra "line feed"
+ }
+
+ if (m_pLine && bDetailedStats) {
+ D3DXVECTOR2 Points[NB_JITTER];
+ int nIndex;
+
+ int StartX = 0;
+ int StartY = 0;
+ int ScaleX = 1;
+ int ScaleY = 1;
+ int DrawWidth = 625 * ScaleX + 50;
+ int DrawHeight = 250 * ScaleY;
+ int Alpha = 80;
+ StartX = m_WindowRect.Width() - (DrawWidth + 20);
+ StartY = m_WindowRect.Height() - (DrawHeight + 20);
+
+ DrawRect(RGB(0, 0, 0), Alpha, CRect(StartX, StartY, StartX + DrawWidth, StartY + DrawHeight));
+ // === Jitter Graduation
+ //m_pLine->SetWidth(2.2); // Width
+ //m_pLine->SetAntialias(1);
+ m_pLine->SetWidth(2.5); // Width
+ m_pLine->SetAntialias(1);
+ //m_pLine->SetGLLines(1);
+ m_pLine->Begin();
+
+ for (int i = 10; i < 250 * ScaleY; i += 10 * ScaleY) {
+ Points[0].x = (FLOAT)StartX;
+ Points[0].y = (FLOAT)(StartY + i);
+ Points[1].x = (FLOAT)(StartX + ((i - 10) % 40 ? 50 : 625 * ScaleX));
+ Points[1].y = (FLOAT)(StartY + i);
+ if (i == 130) {
+ Points[1].x += 50;
+ }
+ m_pLine->Draw(Points, 2, D3DCOLOR_XRGB(100, 100, 255));
+ }
+
+ // === Jitter curve
+ if (m_rtTimePerFrame) {
+ for (int i = 0; i < NB_JITTER; i++) {
+ nIndex = (m_nNextJitter + 1 + i) % NB_JITTER;
+ if (nIndex < 0) {
+ nIndex += NB_JITTER;
+ }
+ double Jitter = m_pllJitter[nIndex] - m_fJitterMean;
+ Points[i].x = (FLOAT)(StartX + (i * 5 * ScaleX + 5));
+ Points[i].y = (FLOAT)(StartY + ((Jitter * ScaleY) / 5000.0 + 125.0 * ScaleY));
+ }
+ m_pLine->Draw(Points, NB_JITTER, D3DCOLOR_XRGB(255, 100, 100));
+
+ if (m_bSyncStatsAvailable) {
+ for (int i = 0; i < NB_JITTER; i++) {
+ nIndex = (m_nNextSyncOffset + 1 + i) % NB_JITTER;
+ if (nIndex < 0) {
+ nIndex += NB_JITTER;
+ }
+ Points[i].x = (FLOAT)(StartX + (i * 5 * ScaleX + 5));
+ Points[i].y = (FLOAT)(StartY + ((m_pllSyncOffset[nIndex] * ScaleY) / 5000 + 125 * ScaleY));
+ }
+ m_pLine->Draw(Points, NB_JITTER, D3DCOLOR_XRGB(100, 200, 100));
+ }
+ }
+ m_pLine->End();
+ }
+
+ // === Text
}
STDMETHODIMP CDX9AllocatorPresenter::GetDIB(BYTE* lpDib, DWORD* size)
{
- CheckPointer(size, E_POINTER);
-
- HRESULT hr;
-
- D3DSURFACE_DESC desc;
- memset(&desc, 0, sizeof(desc));
- m_pVideoSurface[m_nCurSurface]->GetDesc(&desc);
-
- DWORD required = sizeof(BITMAPINFOHEADER) + (desc.Width * desc.Height * 32 >> 3);
- if (!lpDib) {
- *size = required;
- return S_OK;
- }
- if (*size < required) {
- return E_OUTOFMEMORY;
- }
- *size = required;
-
- D3DLOCKED_RECT r;
- CComPtr<IDirect3DSurface9> pSurface;
- if (m_bFullFloatingPointProcessing || m_bHalfFloatingPointProcessing || m_bHighColorResolution) {
- CComPtr<IDirect3DSurface9> fSurface = m_pVideoSurface[m_nCurSurface];
- if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(desc.Width, desc.Height, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &fSurface, NULL))
- || FAILED(hr = m_pD3DXLoadSurfaceFromSurface(fSurface, NULL, NULL, m_pVideoSurface[m_nCurSurface], NULL, NULL, D3DX_DEFAULT, 0))) return hr;
- pSurface = fSurface;
- if (FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) {
- pSurface = NULL;
- if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(desc.Width, desc.Height, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &pSurface, NULL))
- || FAILED(hr = m_pD3DDev->GetRenderTargetData(fSurface, pSurface))
- || FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) return hr;
- }
- }
- else {
- pSurface = m_pVideoSurface[m_nCurSurface];
- if (FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) {
- pSurface = NULL;
- if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &pSurface, NULL))
- || FAILED(hr = m_pD3DDev->GetRenderTargetData(m_pVideoSurface[m_nCurSurface], pSurface))
- || FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) return hr;
- }
- }
-
- BITMAPINFOHEADER* bih = (BITMAPINFOHEADER*)lpDib;
- memset(bih, 0, sizeof(BITMAPINFOHEADER));
- bih->biSize = sizeof(BITMAPINFOHEADER);
- bih->biWidth = desc.Width;
- bih->biHeight = desc.Height;
- bih->biBitCount = 32;
- bih->biPlanes = 1;
- bih->biSizeImage = bih->biWidth * bih->biHeight * bih->biBitCount >> 3;
-
- BitBltFromRGBToRGB(
- bih->biWidth, bih->biHeight,
- (BYTE*)(bih + 1), bih->biWidth*bih->biBitCount>>3, bih->biBitCount,
- (BYTE*)r.pBits + r.Pitch*(desc.Height-1), -(int)r.Pitch, 32);
-
- pSurface->UnlockRect();
-
- return S_OK;
+ CheckPointer(size, E_POINTER);
+
+ HRESULT hr;
+
+ D3DSURFACE_DESC desc;
+ memset(&desc, 0, sizeof(desc));
+ m_pVideoSurface[m_nCurSurface]->GetDesc(&desc);
+
+ DWORD required = sizeof(BITMAPINFOHEADER) + (desc.Width * desc.Height * 32 >> 3);
+ if (!lpDib) {
+ *size = required;
+ return S_OK;
+ }
+ if (*size < required) {
+ return E_OUTOFMEMORY;
+ }
+ *size = required;
+
+ D3DLOCKED_RECT r;
+ CComPtr<IDirect3DSurface9> pSurface;
+ if (m_bFullFloatingPointProcessing || m_bHalfFloatingPointProcessing || m_bHighColorResolution) {
+ CComPtr<IDirect3DSurface9> fSurface = m_pVideoSurface[m_nCurSurface];
+ if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(desc.Width, desc.Height, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &fSurface, NULL))
+ || FAILED(hr = m_pD3DXLoadSurfaceFromSurface(fSurface, NULL, NULL, m_pVideoSurface[m_nCurSurface], NULL, NULL, D3DX_DEFAULT, 0))) { return hr; }
+ pSurface = fSurface;
+ if (FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) {
+ pSurface = NULL;
+ if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(desc.Width, desc.Height, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &pSurface, NULL))
+ || FAILED(hr = m_pD3DDev->GetRenderTargetData(fSurface, pSurface))
+ || FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) { return hr; }
+ }
+ } else {
+ pSurface = m_pVideoSurface[m_nCurSurface];
+ if (FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) {
+ pSurface = NULL;
+ if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &pSurface, NULL))
+ || FAILED(hr = m_pD3DDev->GetRenderTargetData(m_pVideoSurface[m_nCurSurface], pSurface))
+ || FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) { return hr; }
+ }
+ }
+
+ BITMAPINFOHEADER* bih = (BITMAPINFOHEADER*)lpDib;
+ memset(bih, 0, sizeof(BITMAPINFOHEADER));
+ bih->biSize = sizeof(BITMAPINFOHEADER);
+ bih->biWidth = desc.Width;
+ bih->biHeight = desc.Height;
+ bih->biBitCount = 32;
+ bih->biPlanes = 1;
+ bih->biSizeImage = bih->biWidth * bih->biHeight * bih->biBitCount >> 3;
+
+ BitBltFromRGBToRGB(
+ bih->biWidth, bih->biHeight,
+ (BYTE*)(bih + 1), bih->biWidth * bih->biBitCount >> 3, bih->biBitCount,
+ (BYTE*)r.pBits + r.Pitch * (desc.Height - 1), -(int)r.Pitch, 32);
+
+ pSurface->UnlockRect();
+
+ return S_OK;
}
STDMETHODIMP CDX9AllocatorPresenter::SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget)
{
- return SetPixelShader2(pSrcData, pTarget, false);
+ return SetPixelShader2(pSrcData, pTarget, false);
}
STDMETHODIMP CDX9AllocatorPresenter::SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace)
{
- CAutoLock cRenderLock(&m_RenderLock);
+ CAutoLock cRenderLock(&m_RenderLock);
- return SetCustomPixelShader(pSrcData, pTarget, bScreenSpace);
+ return SetCustomPixelShader(pSrcData, pTarget, bScreenSpace);
}
diff --git a/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.h b/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.h
index 4eee9ec68..9eec7bf06 100644
--- a/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.h
+++ b/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.h
@@ -25,11 +25,11 @@
#include "DX9RenderingEngine.h"
-#define VMRBITMAP_UPDATE 0x80000000
+#define VMRBITMAP_UPDATE 0x80000000
-#define NB_JITTER 126
+#define NB_JITTER 126
-#define PCIV_ATI 0x1002
+#define PCIV_ATI 0x1002
extern bool g_bNoDuration;
extern bool g_bExternalSubtitleTime;
@@ -37,278 +37,278 @@ extern bool g_bExternalSubtitleTime;
namespace DSObjects
{
- class CDX9AllocatorPresenter
- : public CDX9RenderingEngine
- {
- public:
- CCritSec m_VMR9AlphaBitmapLock;
- void UpdateAlphaBitmap();
- protected:
- UINT m_RefreshRate;
- bool m_bAlternativeVSync;
- bool m_bCompositionEnabled;
- bool m_bIsEVR;
- int m_OrderedPaint;
- int m_VSyncMode;
- bool m_bDesktopCompositionDisabled;
- bool m_bIsFullscreen;
- bool m_bNeedCheckSample;
- DWORD m_MainThreadId;
-
- CRenderersSettings::CRendererSettingsEVR m_LastRendererSettings;
-
- HRESULT (__stdcall * m_pDwmIsCompositionEnabled)(__out BOOL* pfEnabled);
- HRESULT (__stdcall * m_pDwmEnableComposition)(UINT uCompositionAction);
-
- HMODULE m_hDWMAPI;
-
- HRESULT (__stdcall * m_pDirect3DCreate9Ex)(UINT SDKVersion, IDirect3D9Ex**);
- HMODULE m_hD3D9;
-
- CCritSec m_RenderLock;
- CComPtr<IDirectDraw> m_pDirectDraw;
-
- void LockD3DDevice() {
- if (m_pD3DDev) {
- _RTL_CRITICAL_SECTION *pCritSec = (_RTL_CRITICAL_SECTION *)((size_t)m_pD3DDev.p + sizeof(size_t));
-
- if (!IsBadReadPtr(pCritSec, sizeof(*pCritSec)) && !IsBadWritePtr(pCritSec, sizeof(*pCritSec))
- && !IsBadReadPtr(pCritSec->DebugInfo, sizeof(*(pCritSec->DebugInfo))) && !IsBadWritePtr(pCritSec->DebugInfo, sizeof(*(pCritSec->DebugInfo)))) {
- if (pCritSec->DebugInfo->CriticalSection == pCritSec) {
- EnterCriticalSection(pCritSec);
- }
- }
- }
- }
-
- void UnlockD3DDevice() {
- if (m_pD3DDev) {
- _RTL_CRITICAL_SECTION *pCritSec = (_RTL_CRITICAL_SECTION *)((size_t)m_pD3DDev.p + sizeof(size_t));
-
- if (!IsBadReadPtr(pCritSec, sizeof(*pCritSec)) && !IsBadWritePtr(pCritSec, sizeof(*pCritSec))
- && !IsBadReadPtr(pCritSec->DebugInfo, sizeof(*(pCritSec->DebugInfo))) && !IsBadWritePtr(pCritSec->DebugInfo, sizeof(*(pCritSec->DebugInfo)))) {
- if (pCritSec->DebugInfo->CriticalSection == pCritSec) {
- LeaveCriticalSection(pCritSec);
- }
- }
- }
- }
-
- CString m_D3DDevExError;
- CComPtr<IDirect3DTexture9> m_pOSDTexture;
- CComPtr<IDirect3DSurface9> m_pOSDSurface;
- CComPtr<ID3DXLine> m_pLine;
- CComPtr<ID3DXFont> m_pFont;
- CComPtr<ID3DXSprite> m_pSprite;
-
- bool SettingsNeedResetDevice();
-
- virtual HRESULT CreateDevice(CString &_Error);
- virtual HRESULT AllocSurfaces();
- virtual void DeleteSurfaces();
-
- // Thread stuff
- HANDLE m_hEvtQuit; // Stop rendering thread event
- HANDLE m_hVSyncThread;
- static DWORD WINAPI VSyncThreadStatic(LPVOID lpParam);
- void VSyncThread();
- void StartWorkerThreads();
- void StopWorkerThreads();
-
- LONGLONG m_LastAdapterCheck;
- UINT GetAdapter(IDirect3D9 *pD3D, bool bGetAdapter = true);
- DWORD GetVertexProcessing();
-
- bool GetVBlank(int &_ScanLine, int &_bInVBlank, bool _bMeasureTime);
- bool WaitForVBlankRange(int &_RasterStart, int _RasterEnd, bool _bWaitIfInside, bool _bNeedAccurate, bool _bMeasure, bool &_bTakenLock);
- bool WaitForVBlank(bool &_Waited, bool &_bTakenLock);
- int GetVBlackPos();
- void CalculateJitter(LONGLONG PerformanceCounter);
- virtual void OnVBlankFinished(bool fAll, LONGLONG PerformanceCounter) {}
-
- // Casimir666
- typedef HRESULT (WINAPI * D3DXLoadSurfaceFromMemoryPtr)(
- LPDIRECT3DSURFACE9 pDestSurface,
- CONST PALETTEENTRY* pDestPalette,
- CONST RECT* pDestRect,
- LPCVOID pSrcMemory,
- D3DFORMAT SrcFormat,
- UINT SrcPitch,
- CONST PALETTEENTRY* pSrcPalette,
- CONST RECT* pSrcRect,
- DWORD Filter,
- D3DCOLOR ColorKey);
-
- typedef HRESULT (WINAPI * D3DXLoadSurfaceFromSurfacePtr)(
- LPDIRECT3DSURFACE9 pDestSurface,
- CONST PALETTEENTRY* pDestPalette,
- CONST RECT* pDestRect,
- LPDIRECT3DSURFACE9 pSrcSurface,
- CONST PALETTEENTRY* pSrcPalette,
- CONST RECT* pSrcRect,
- DWORD Filter,
- D3DCOLOR ColorKey);
-
- typedef HRESULT (WINAPI* D3DXCreateLinePtr) (LPDIRECT3DDEVICE9 pDevice, LPD3DXLINE* ppLine);
-
- typedef HRESULT (WINAPI* D3DXCreateFontPtr)(
- LPDIRECT3DDEVICE9 pDevice,
- int Height,
- UINT Width,
- UINT Weight,
- UINT MipLevels,
- bool Italic,
- DWORD CharSet,
- DWORD OutputPrecision,
- DWORD Quality,
- DWORD PitchAndFamily,
- LPCWSTR pFaceName,
- LPD3DXFONT* ppFont);
-
-
- void DrawText(const RECT &rc, const CString &strText, int _Priority);
- void ResetStats();
- void DrawStats();
- virtual void OnResetDevice() {};
- void SendResetRequest();
-
- double GetFrameTime() const;
- double GetFrameRate() const;
-
-
- int m_nTearingPos;
- VMR9AlphaBitmap m_VMR9AlphaBitmap;
- CAutoVectorPtr<BYTE> m_VMR9AlphaBitmapData;
- CRect m_VMR9AlphaBitmapRect;
- int m_VMR9AlphaBitmapWidthBytes;
-
- D3DXLoadSurfaceFromMemoryPtr m_pD3DXLoadSurfaceFromMemory;
- D3DXLoadSurfaceFromSurfacePtr m_pD3DXLoadSurfaceFromSurface;
- D3DXCreateLinePtr m_pD3DXCreateLine;
- D3DXCreateFontPtr m_pD3DXCreateFont;
- HRESULT (__stdcall *m_pD3DXCreateSprite)(LPDIRECT3DDEVICE9 pDevice, LPD3DXSPRITE * ppSprite);
-
-
-
- int m_nVMR9Surfaces; // Total number of DX Surfaces
- int m_iVMR9Surface;
- long m_nUsedBuffer;
-
- double m_fAvrFps; // Estimate the real FPS
- double m_fJitterStdDev; // Estimate the Jitter std dev
- double m_fJitterMean;
- double m_fSyncOffsetStdDev;
- double m_fSyncOffsetAvr;
- double m_DetectedRefreshRate;
-
- CCritSec m_RefreshRateLock;
- double m_DetectedRefreshTime;
- double m_DetectedRefreshTimePrim;
- double m_DetectedScanlineTime;
- double m_DetectedScanlineTimePrim;
- double m_DetectedScanlinesPerFrame;
-
- double GetRefreshRate() const {
- if (m_DetectedRefreshRate) {
- return m_DetectedRefreshRate;
- }
- return m_RefreshRate;
- }
-
- LONG GetScanLines() const {
- if (m_DetectedRefreshRate) {
- return (LONG)m_DetectedScanlinesPerFrame;
- }
- return m_ScreenSize.cy;
- }
-
- double m_ldDetectedRefreshRateList[100];
- double m_ldDetectedScanlineRateList[100];
- int m_DetectedRefreshRatePos;
- bool m_bSyncStatsAvailable;
- LONGLONG m_pllJitter [NB_JITTER]; // Jitter buffer for stats
- LONGLONG m_pllSyncOffset [NB_JITTER]; // Jitter buffer for stats
- LONGLONG m_llLastPerf;
- LONGLONG m_JitterStdDev;
- LONGLONG m_MaxJitter;
- LONGLONG m_MinJitter;
- LONGLONG m_MaxSyncOffset;
- LONGLONG m_MinSyncOffset;
- int m_nNextJitter;
- int m_nNextSyncOffset;
- REFERENCE_TIME m_rtTimePerFrame;
- double m_DetectedFrameRate;
- double m_DetectedFrameTime;
- double m_DetectedFrameTimeStdDev;
- bool m_DetectedLock;
- LONGLONG m_DetectedFrameTimeHistory[60];
- double m_DetectedFrameTimeHistoryHistory[500];
- int m_DetectedFrameTimePos;
- int m_bInterlaced;
- FF_FIELD_TYPE m_nFrameType;
-
- double m_TextScale;
-
- int m_VBlankEndWait;
- int m_VBlankStartWait;
- LONGLONG m_VBlankWaitTime;
- LONGLONG m_VBlankLockTime;
- int m_VBlankMin;
- int m_VBlankMinCalc;
- int m_VBlankMax;
- int m_VBlankEndPresent;
- LONGLONG m_VBlankStartMeasureTime;
- int m_VBlankStartMeasure;
-
- LONGLONG m_PresentWaitTime;
- LONGLONG m_PresentWaitTimeMin;
- LONGLONG m_PresentWaitTimeMax;
-
- LONGLONG m_PaintTime;
- LONGLONG m_PaintTimeMin;
- LONGLONG m_PaintTimeMax;
-
- LONGLONG m_WaitForGPUTime;
-
- LONGLONG m_RasterStatusWaitTime;
- LONGLONG m_RasterStatusWaitTimeMin;
- LONGLONG m_RasterStatusWaitTimeMax;
- LONGLONG m_RasterStatusWaitTimeMaxCalc;
-
- double m_ClockDiffCalc;
- double m_ClockDiffPrim;
- double m_ClockDiff;
-
- double m_TimeChangeHistory[100];
- double m_ClockChangeHistory[100];
- int m_ClockTimeChangeHistoryPos;
- double m_ModeratedTimeSpeed;
- double m_ModeratedTimeSpeedPrim;
- double m_ModeratedTimeSpeedDiff;
-
- bool m_bCorrectedFrameTime;
- int m_FrameTimeCorrection;
- LONGLONG m_LastFrameDuration;
- LONGLONG m_LastSampleTime;
-
- CString m_strStatsMsg[10];
-
- CString m_D3D9Device;
- DWORD m_nPCIVendor;
-
- CString m_Decoder;
-
- public:
- CDX9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRESULT& hr, bool bIsEVR, CString &_Error);
- ~CDX9AllocatorPresenter();
-
- // ISubPicAllocatorPresenter
- STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
- STDMETHODIMP_(bool) Paint(bool fAll);
- STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size);
- STDMETHODIMP SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget);
- STDMETHODIMP SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace);
- STDMETHODIMP_(bool) ResetDevice();
- STDMETHODIMP_(bool) DisplayChange();
- };
+ class CDX9AllocatorPresenter
+ : public CDX9RenderingEngine
+ {
+ public:
+ CCritSec m_VMR9AlphaBitmapLock;
+ void UpdateAlphaBitmap();
+ protected:
+ UINT m_RefreshRate;
+ bool m_bAlternativeVSync;
+ bool m_bCompositionEnabled;
+ bool m_bIsEVR;
+ int m_OrderedPaint;
+ int m_VSyncMode;
+ bool m_bDesktopCompositionDisabled;
+ bool m_bIsFullscreen;
+ bool m_bNeedCheckSample;
+ DWORD m_MainThreadId;
+
+ CRenderersSettings::CRendererSettingsEVR m_LastRendererSettings;
+
+ HRESULT(__stdcall* m_pDwmIsCompositionEnabled)(__out BOOL* pfEnabled);
+ HRESULT(__stdcall* m_pDwmEnableComposition)(UINT uCompositionAction);
+
+ HMODULE m_hDWMAPI;
+
+ HRESULT(__stdcall* m_pDirect3DCreate9Ex)(UINT SDKVersion, IDirect3D9Ex**);
+ HMODULE m_hD3D9;
+
+ CCritSec m_RenderLock;
+ CComPtr<IDirectDraw> m_pDirectDraw;
+
+ void LockD3DDevice() {
+ if (m_pD3DDev) {
+ _RTL_CRITICAL_SECTION* pCritSec = (_RTL_CRITICAL_SECTION*)((size_t)m_pD3DDev.p + sizeof(size_t));
+
+ if (!IsBadReadPtr(pCritSec, sizeof(*pCritSec)) && !IsBadWritePtr(pCritSec, sizeof(*pCritSec))
+ && !IsBadReadPtr(pCritSec->DebugInfo, sizeof(*(pCritSec->DebugInfo))) && !IsBadWritePtr(pCritSec->DebugInfo, sizeof(*(pCritSec->DebugInfo)))) {
+ if (pCritSec->DebugInfo->CriticalSection == pCritSec) {
+ EnterCriticalSection(pCritSec);
+ }
+ }
+ }
+ }
+
+ void UnlockD3DDevice() {
+ if (m_pD3DDev) {
+ _RTL_CRITICAL_SECTION* pCritSec = (_RTL_CRITICAL_SECTION*)((size_t)m_pD3DDev.p + sizeof(size_t));
+
+ if (!IsBadReadPtr(pCritSec, sizeof(*pCritSec)) && !IsBadWritePtr(pCritSec, sizeof(*pCritSec))
+ && !IsBadReadPtr(pCritSec->DebugInfo, sizeof(*(pCritSec->DebugInfo))) && !IsBadWritePtr(pCritSec->DebugInfo, sizeof(*(pCritSec->DebugInfo)))) {
+ if (pCritSec->DebugInfo->CriticalSection == pCritSec) {
+ LeaveCriticalSection(pCritSec);
+ }
+ }
+ }
+ }
+
+ CString m_D3DDevExError;
+ CComPtr<IDirect3DTexture9> m_pOSDTexture;
+ CComPtr<IDirect3DSurface9> m_pOSDSurface;
+ CComPtr<ID3DXLine> m_pLine;
+ CComPtr<ID3DXFont> m_pFont;
+ CComPtr<ID3DXSprite> m_pSprite;
+
+ bool SettingsNeedResetDevice();
+
+ virtual HRESULT CreateDevice(CString& _Error);
+ virtual HRESULT AllocSurfaces();
+ virtual void DeleteSurfaces();
+
+ // Thread stuff
+ HANDLE m_hEvtQuit; // Stop rendering thread event
+ HANDLE m_hVSyncThread;
+ static DWORD WINAPI VSyncThreadStatic(LPVOID lpParam);
+ void VSyncThread();
+ void StartWorkerThreads();
+ void StopWorkerThreads();
+
+ LONGLONG m_LastAdapterCheck;
+ UINT GetAdapter(IDirect3D9* pD3D, bool bGetAdapter = true);
+ DWORD GetVertexProcessing();
+
+ bool GetVBlank(int& _ScanLine, int& _bInVBlank, bool _bMeasureTime);
+ bool WaitForVBlankRange(int& _RasterStart, int _RasterEnd, bool _bWaitIfInside, bool _bNeedAccurate, bool _bMeasure, bool& _bTakenLock);
+ bool WaitForVBlank(bool& _Waited, bool& _bTakenLock);
+ int GetVBlackPos();
+ void CalculateJitter(LONGLONG PerformanceCounter);
+ virtual void OnVBlankFinished(bool fAll, LONGLONG PerformanceCounter) {}
+
+ // Casimir666
+ typedef HRESULT(WINAPI* D3DXLoadSurfaceFromMemoryPtr)(
+ LPDIRECT3DSURFACE9 pDestSurface,
+ CONST PALETTEENTRY* pDestPalette,
+ CONST RECT* pDestRect,
+ LPCVOID pSrcMemory,
+ D3DFORMAT SrcFormat,
+ UINT SrcPitch,
+ CONST PALETTEENTRY* pSrcPalette,
+ CONST RECT* pSrcRect,
+ DWORD Filter,
+ D3DCOLOR ColorKey);
+
+ typedef HRESULT(WINAPI* D3DXLoadSurfaceFromSurfacePtr)(
+ LPDIRECT3DSURFACE9 pDestSurface,
+ CONST PALETTEENTRY* pDestPalette,
+ CONST RECT* pDestRect,
+ LPDIRECT3DSURFACE9 pSrcSurface,
+ CONST PALETTEENTRY* pSrcPalette,
+ CONST RECT* pSrcRect,
+ DWORD Filter,
+ D3DCOLOR ColorKey);
+
+ typedef HRESULT(WINAPI* D3DXCreateLinePtr)(LPDIRECT3DDEVICE9 pDevice, LPD3DXLINE* ppLine);
+
+ typedef HRESULT(WINAPI* D3DXCreateFontPtr)(
+ LPDIRECT3DDEVICE9 pDevice,
+ int Height,
+ UINT Width,
+ UINT Weight,
+ UINT MipLevels,
+ bool Italic,
+ DWORD CharSet,
+ DWORD OutputPrecision,
+ DWORD Quality,
+ DWORD PitchAndFamily,
+ LPCWSTR pFaceName,
+ LPD3DXFONT* ppFont);
+
+
+ void DrawText(const RECT& rc, const CString& strText, int _Priority);
+ void ResetStats();
+ void DrawStats();
+ virtual void OnResetDevice() {};
+ void SendResetRequest();
+
+ double GetFrameTime() const;
+ double GetFrameRate() const;
+
+
+ int m_nTearingPos;
+ VMR9AlphaBitmap m_VMR9AlphaBitmap;
+ CAutoVectorPtr<BYTE> m_VMR9AlphaBitmapData;
+ CRect m_VMR9AlphaBitmapRect;
+ int m_VMR9AlphaBitmapWidthBytes;
+
+ D3DXLoadSurfaceFromMemoryPtr m_pD3DXLoadSurfaceFromMemory;
+ D3DXLoadSurfaceFromSurfacePtr m_pD3DXLoadSurfaceFromSurface;
+ D3DXCreateLinePtr m_pD3DXCreateLine;
+ D3DXCreateFontPtr m_pD3DXCreateFont;
+ HRESULT(__stdcall* m_pD3DXCreateSprite)(LPDIRECT3DDEVICE9 pDevice, LPD3DXSPRITE* ppSprite);
+
+
+
+ int m_nVMR9Surfaces; // Total number of DX Surfaces
+ int m_iVMR9Surface;
+ long m_nUsedBuffer;
+
+ double m_fAvrFps; // Estimate the real FPS
+ double m_fJitterStdDev; // Estimate the Jitter std dev
+ double m_fJitterMean;
+ double m_fSyncOffsetStdDev;
+ double m_fSyncOffsetAvr;
+ double m_DetectedRefreshRate;
+
+ CCritSec m_RefreshRateLock;
+ double m_DetectedRefreshTime;
+ double m_DetectedRefreshTimePrim;
+ double m_DetectedScanlineTime;
+ double m_DetectedScanlineTimePrim;
+ double m_DetectedScanlinesPerFrame;
+
+ double GetRefreshRate() const {
+ if (m_DetectedRefreshRate) {
+ return m_DetectedRefreshRate;
+ }
+ return m_RefreshRate;
+ }
+
+ LONG GetScanLines() const {
+ if (m_DetectedRefreshRate) {
+ return (LONG)m_DetectedScanlinesPerFrame;
+ }
+ return m_ScreenSize.cy;
+ }
+
+ double m_ldDetectedRefreshRateList[100];
+ double m_ldDetectedScanlineRateList[100];
+ int m_DetectedRefreshRatePos;
+ bool m_bSyncStatsAvailable;
+ LONGLONG m_pllJitter [NB_JITTER]; // Jitter buffer for stats
+ LONGLONG m_pllSyncOffset [NB_JITTER]; // Jitter buffer for stats
+ LONGLONG m_llLastPerf;
+ LONGLONG m_JitterStdDev;
+ LONGLONG m_MaxJitter;
+ LONGLONG m_MinJitter;
+ LONGLONG m_MaxSyncOffset;
+ LONGLONG m_MinSyncOffset;
+ int m_nNextJitter;
+ int m_nNextSyncOffset;
+ REFERENCE_TIME m_rtTimePerFrame;
+ double m_DetectedFrameRate;
+ double m_DetectedFrameTime;
+ double m_DetectedFrameTimeStdDev;
+ bool m_DetectedLock;
+ LONGLONG m_DetectedFrameTimeHistory[60];
+ double m_DetectedFrameTimeHistoryHistory[500];
+ int m_DetectedFrameTimePos;
+ int m_bInterlaced;
+ FF_FIELD_TYPE m_nFrameType;
+
+ double m_TextScale;
+
+ int m_VBlankEndWait;
+ int m_VBlankStartWait;
+ LONGLONG m_VBlankWaitTime;
+ LONGLONG m_VBlankLockTime;
+ int m_VBlankMin;
+ int m_VBlankMinCalc;
+ int m_VBlankMax;
+ int m_VBlankEndPresent;
+ LONGLONG m_VBlankStartMeasureTime;
+ int m_VBlankStartMeasure;
+
+ LONGLONG m_PresentWaitTime;
+ LONGLONG m_PresentWaitTimeMin;
+ LONGLONG m_PresentWaitTimeMax;
+
+ LONGLONG m_PaintTime;
+ LONGLONG m_PaintTimeMin;
+ LONGLONG m_PaintTimeMax;
+
+ LONGLONG m_WaitForGPUTime;
+
+ LONGLONG m_RasterStatusWaitTime;
+ LONGLONG m_RasterStatusWaitTimeMin;
+ LONGLONG m_RasterStatusWaitTimeMax;
+ LONGLONG m_RasterStatusWaitTimeMaxCalc;
+
+ double m_ClockDiffCalc;
+ double m_ClockDiffPrim;
+ double m_ClockDiff;
+
+ double m_TimeChangeHistory[100];
+ double m_ClockChangeHistory[100];
+ int m_ClockTimeChangeHistoryPos;
+ double m_ModeratedTimeSpeed;
+ double m_ModeratedTimeSpeedPrim;
+ double m_ModeratedTimeSpeedDiff;
+
+ bool m_bCorrectedFrameTime;
+ int m_FrameTimeCorrection;
+ LONGLONG m_LastFrameDuration;
+ LONGLONG m_LastSampleTime;
+
+ CString m_strStatsMsg[10];
+
+ CString m_D3D9Device;
+ DWORD m_nPCIVendor;
+
+ CString m_Decoder;
+
+ public:
+ CDX9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRESULT& hr, bool bIsEVR, CString& _Error);
+ ~CDX9AllocatorPresenter();
+
+ // ISubPicAllocatorPresenter
+ STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
+ STDMETHODIMP_(bool) Paint(bool fAll);
+ STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size);
+ STDMETHODIMP SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget);
+ STDMETHODIMP SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace);
+ STDMETHODIMP_(bool) ResetDevice();
+ STDMETHODIMP_(bool) DisplayChange();
+ };
}
diff --git a/src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp b/src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp
index e240ee550..bdbd90b88 100644
--- a/src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp
+++ b/src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp
@@ -30,1650 +30,1653 @@
#pragma pack(push, 1)
template<int texcoords>
struct MYD3DVERTEX {
- float x, y, z, rhw;
- struct {
- float u, v;
- } t[texcoords];
+ float x, y, z, rhw;
+ struct {
+ float u, v;
+ } t[texcoords];
};
template<>
struct MYD3DVERTEX<0> {
- float x, y, z, rhw;
- DWORD Diffuse;
+ float x, y, z, rhw;
+ DWORD Diffuse;
};
#pragma pack(pop)
template<int texcoords>
static void AdjustQuad(MYD3DVERTEX<texcoords>* v, double dx, double dy)
{
- float offset = 0.5;
-
- for (int i = 0; i < 4; i++) {
- v[i].x -= offset;
- v[i].y -= offset;
-
- for (int j = 0; j < max(texcoords-1, 1); j++) {
- v[i].t[j].u -= (float)(offset*dx);
- v[i].t[j].v -= (float)(offset*dy);
- }
-
- if (texcoords > 1) {
- v[i].t[texcoords-1].u -= offset;
- v[i].t[texcoords-1].v -= offset;
- }
- }
+ float offset = 0.5;
+
+ for (int i = 0; i < 4; i++) {
+ v[i].x -= offset;
+ v[i].y -= offset;
+
+ for (int j = 0; j < max(texcoords - 1, 1); j++) {
+ v[i].t[j].u -= (float)(offset * dx);
+ v[i].t[j].v -= (float)(offset * dy);
+ }
+
+ if (texcoords > 1) {
+ v[i].t[texcoords - 1].u -= offset;
+ v[i].t[texcoords - 1].v -= offset;
+ }
+ }
}
template<int texcoords>
static HRESULT TextureBlt(IDirect3DDevice9* pD3DDev, MYD3DVERTEX<texcoords> v[4], D3DTEXTUREFILTERTYPE filter)
{
- if (!pD3DDev) {
- return E_POINTER;
- }
-
- DWORD FVF = 0;
-
- switch (texcoords) {
- case 1:
- FVF = D3DFVF_TEX1;
- break;
- case 2:
- FVF = D3DFVF_TEX2;
- break;
- case 3:
- FVF = D3DFVF_TEX3;
- break;
- case 4:
- FVF = D3DFVF_TEX4;
- break;
- case 5:
- FVF = D3DFVF_TEX5;
- break;
- case 6:
- FVF = D3DFVF_TEX6;
- break;
- case 7:
- FVF = D3DFVF_TEX7;
- break;
- case 8:
- FVF = D3DFVF_TEX8;
- break;
- default:
- return E_FAIL;
- }
-
- HRESULT hr;
-
- hr = pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
- hr = pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_STENCILENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED);
-
- for (int i = 0; i < texcoords; i++) {
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_MAGFILTER, filter);
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_MINFILTER, filter);
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
-
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
- }
-
- //
-
- hr = pD3DDev->SetFVF(D3DFVF_XYZRHW | FVF);
- // hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, v, sizeof(v[0]));
-
- MYD3DVERTEX<texcoords> tmp = v[2];
- v[2] = v[3];
- v[3] = tmp;
- hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
-
- //
-
- for (int i = 0; i < texcoords; i++) {
- pD3DDev->SetTexture(i, NULL);
- }
-
- return S_OK;
+ if (!pD3DDev) {
+ return E_POINTER;
+ }
+
+ DWORD FVF = 0;
+
+ switch (texcoords) {
+ case 1:
+ FVF = D3DFVF_TEX1;
+ break;
+ case 2:
+ FVF = D3DFVF_TEX2;
+ break;
+ case 3:
+ FVF = D3DFVF_TEX3;
+ break;
+ case 4:
+ FVF = D3DFVF_TEX4;
+ break;
+ case 5:
+ FVF = D3DFVF_TEX5;
+ break;
+ case 6:
+ FVF = D3DFVF_TEX6;
+ break;
+ case 7:
+ FVF = D3DFVF_TEX7;
+ break;
+ case 8:
+ FVF = D3DFVF_TEX8;
+ break;
+ default:
+ return E_FAIL;
+ }
+
+ HRESULT hr;
+
+ hr = pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
+ hr = pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_STENCILENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED);
+
+ for (int i = 0; i < texcoords; i++) {
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_MAGFILTER, filter);
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_MINFILTER, filter);
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
+
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
+ }
+
+ //
+
+ hr = pD3DDev->SetFVF(D3DFVF_XYZRHW | FVF);
+ // hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, v, sizeof(v[0]));
+
+ MYD3DVERTEX<texcoords> tmp = v[2];
+ v[2] = v[3];
+ v[3] = tmp;
+ hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
+
+ //
+
+ for (int i = 0; i < texcoords; i++) {
+ pD3DDev->SetTexture(i, NULL);
+ }
+
+ return S_OK;
}
using namespace DSObjects;
-CDX9RenderingEngine::CDX9RenderingEngine(HWND hWnd, HRESULT& hr, CString *_pError)
- : CSubPicAllocatorPresenterImpl(hWnd, hr, _pError)
- , m_ScreenSize(0, 0)
- , m_nNbDXSurface(1)
- , m_nCurSurface(0)
- , m_CurrentAdapter(0)
+CDX9RenderingEngine::CDX9RenderingEngine(HWND hWnd, HRESULT& hr, CString* _pError)
+ : CSubPicAllocatorPresenterImpl(hWnd, hr, _pError)
+ , m_ScreenSize(0, 0)
+ , m_nNbDXSurface(1)
+ , m_nCurSurface(0)
+ , m_CurrentAdapter(0)
{
- HINSTANCE hDll = GetRenderersData()->GetD3X9Dll();
- m_bD3DX = hDll != NULL;
+ HINSTANCE hDll = GetRenderersData()->GetD3X9Dll();
+ m_bD3DX = hDll != NULL;
- if (m_bD3DX) {
- (FARPROC&)m_pD3DXFloat32To16Array = GetProcAddress(hDll, "D3DXFloat32To16Array");
- }
+ if (m_bD3DX) {
+ (FARPROC&)m_pD3DXFloat32To16Array = GetProcAddress(hDll, "D3DXFloat32To16Array");
+ }
}
void CDX9RenderingEngine::InitRenderingEngine()
{
- m_StretchRectFilter = D3DTEXF_LINEAR;// eliminate this chain ASAP
+ m_StretchRectFilter = D3DTEXF_LINEAR;// eliminate this chain ASAP
- // Initialize the pixel shader compiler
- m_pPSC.Attach(DNew CPixelShaderCompiler(m_pD3DDev, true));
+ // Initialize the pixel shader compiler
+ m_pPSC.Attach(DNew CPixelShaderCompiler(m_pD3DDev, true));
- // Initialize settings
- m_BicubicA = 0;
+ // Initialize settings
+ m_BicubicA = 0;
}
void CDX9RenderingEngine::CleanupRenderingEngine()
{
- m_pPSC.Free();
-
- for (int i = 0; i < 4; i++) {
- m_pResizerPixelShaders[i] = NULL;
- }
-
- CleanupFinalPass();
-
- POSITION pos = m_pCustomScreenSpacePixelShaders.GetHeadPosition();
- while (pos) {
- CExternalPixelShader &Shader = m_pCustomScreenSpacePixelShaders.GetNext(pos);
- Shader.m_pPixelShader = NULL;
- }
- pos = m_pCustomPixelShaders.GetHeadPosition();
- while (pos) {
- CExternalPixelShader &Shader = m_pCustomPixelShaders.GetNext(pos);
- Shader.m_pPixelShader = NULL;
- }
-
- for (int i = 0; i < 2; i++) {
- m_pTemporaryVideoTextures[i] = NULL;
- m_pTemporaryScreenSpaceTextures[i] = NULL;
- }
+ m_pPSC.Free();
+
+ for (int i = 0; i < 4; i++) {
+ m_pResizerPixelShaders[i] = NULL;
+ }
+
+ CleanupFinalPass();
+
+ POSITION pos = m_pCustomScreenSpacePixelShaders.GetHeadPosition();
+ while (pos) {
+ CExternalPixelShader& Shader = m_pCustomScreenSpacePixelShaders.GetNext(pos);
+ Shader.m_pPixelShader = NULL;
+ }
+ pos = m_pCustomPixelShaders.GetHeadPosition();
+ while (pos) {
+ CExternalPixelShader& Shader = m_pCustomPixelShaders.GetNext(pos);
+ Shader.m_pPixelShader = NULL;
+ }
+
+ for (int i = 0; i < 2; i++) {
+ m_pTemporaryVideoTextures[i] = NULL;
+ m_pTemporaryScreenSpaceTextures[i] = NULL;
+ }
}
HRESULT CDX9RenderingEngine::CreateVideoSurfaces()
{
- HRESULT hr;
- CRenderersSettings& settings = GetRenderersSettings();
-
- // Free previously allocated video surfaces
- FreeVideoSurfaces();
-
- // Free previously allocated temporary video textures, because the native video size might have been changed!
- for (int i = 0; i < 2; i++) {
- m_pTemporaryVideoTextures[i] = NULL;
- }
-
- if (settings.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D || settings.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) {
- int nTexturesNeeded = settings.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D ? m_nNbDXSurface : 1;
-
- for (int i = 0; i < nTexturesNeeded; i++) {
- if (FAILED(hr = m_pD3DDev->CreateTexture(
- m_NativeVideoSize.cx, m_NativeVideoSize.cy, 1,
- D3DUSAGE_RENDERTARGET, m_SurfaceType,
- D3DPOOL_DEFAULT, &m_pVideoTexture[i], NULL))) {
- return hr;
- }
-
- if (FAILED(hr = m_pVideoTexture[i]->GetSurfaceLevel(0, &m_pVideoSurface[i]))) {
- return hr;
- }
- }
-
- if (settings.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D) {
- m_RenderingPath = RENDERING_PATH_STRETCHRECT;
-
- for (int i = 0; i < m_nNbDXSurface; i++) {
- m_pVideoTexture[i] = NULL;
- }
- } else {
- m_RenderingPath = RENDERING_PATH_DRAW;
- }
- } else {
- m_RenderingPath = RENDERING_PATH_STRETCHRECT;
-
- if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(
- m_NativeVideoSize.cx, m_NativeVideoSize.cy,
- m_SurfaceType,
- D3DPOOL_DEFAULT, &m_pVideoSurface[m_nCurSurface], NULL))) {
- return hr;
- }
- }
-
- hr = m_pD3DDev->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1, 0);
-
- return S_OK;
+ HRESULT hr;
+ CRenderersSettings& settings = GetRenderersSettings();
+
+ // Free previously allocated video surfaces
+ FreeVideoSurfaces();
+
+ // Free previously allocated temporary video textures, because the native video size might have been changed!
+ for (int i = 0; i < 2; i++) {
+ m_pTemporaryVideoTextures[i] = NULL;
+ }
+
+ if (settings.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D || settings.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) {
+ int nTexturesNeeded = settings.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D ? m_nNbDXSurface : 1;
+
+ for (int i = 0; i < nTexturesNeeded; i++) {
+ if (FAILED(hr = m_pD3DDev->CreateTexture(
+ m_NativeVideoSize.cx, m_NativeVideoSize.cy, 1,
+ D3DUSAGE_RENDERTARGET, m_SurfaceType,
+ D3DPOOL_DEFAULT, &m_pVideoTexture[i], NULL))) {
+ return hr;
+ }
+
+ if (FAILED(hr = m_pVideoTexture[i]->GetSurfaceLevel(0, &m_pVideoSurface[i]))) {
+ return hr;
+ }
+ }
+
+ if (settings.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D) {
+ m_RenderingPath = RENDERING_PATH_STRETCHRECT;
+
+ for (int i = 0; i < m_nNbDXSurface; i++) {
+ m_pVideoTexture[i] = NULL;
+ }
+ } else {
+ m_RenderingPath = RENDERING_PATH_DRAW;
+ }
+ } else {
+ m_RenderingPath = RENDERING_PATH_STRETCHRECT;
+
+ if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(
+ m_NativeVideoSize.cx, m_NativeVideoSize.cy,
+ m_SurfaceType,
+ D3DPOOL_DEFAULT, &m_pVideoSurface[m_nCurSurface], NULL))) {
+ return hr;
+ }
+ }
+
+ hr = m_pD3DDev->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1, 0);
+
+ return S_OK;
}
void CDX9RenderingEngine::FreeVideoSurfaces()
{
- for (int i = 0; i < m_nNbDXSurface; i++) {
- m_pVideoTexture[i] = NULL;
- m_pVideoSurface[i] = NULL;
- }
+ for (int i = 0; i < m_nNbDXSurface; i++) {
+ m_pVideoTexture[i] = NULL;
+ m_pVideoSurface[i] = NULL;
+ }
}
HRESULT CDX9RenderingEngine::RenderVideo(IDirect3DSurface9* pRenderTarget, const CRect& srcRect, const CRect& destRect)
{
- if (destRect.IsRectEmpty()) {
- return S_OK;
- }
-
- if (m_RenderingPath == RENDERING_PATH_DRAW) {
- return RenderVideoDrawPath(pRenderTarget, srcRect, destRect);
- } else {
- return RenderVideoStretchRectPath(pRenderTarget, srcRect, destRect);
- }
+ if (destRect.IsRectEmpty()) {
+ return S_OK;
+ }
+
+ if (m_RenderingPath == RENDERING_PATH_DRAW) {
+ return RenderVideoDrawPath(pRenderTarget, srcRect, destRect);
+ } else {
+ return RenderVideoStretchRectPath(pRenderTarget, srcRect, destRect);
+ }
}
HRESULT CDX9RenderingEngine::RenderVideoDrawPath(IDirect3DSurface9* pRenderTarget, const CRect& srcRect, const CRect& destRect)
{
- HRESULT hr;
-
- // Return if the video texture is not initialized
- if (m_pVideoTexture[m_nCurSurface] == 0) {
- return S_OK;
- }
-
- CRenderersSettings& settings = GetRenderersSettings();
-
- // Initialize the processing pipeline
- bool bCustomPixelShaders;
- bool bResizerShaders;
- bool bCustomScreenSpacePixelShaders;
- bool bFinalPass;
-
- int screenSpacePassCount = 0;
- DWORD iDX9Resizer = settings.iDX9Resizer;
-
- if (m_bD3DX) {
- // Final pass. Must be initialized first!
- hr = InitFinalPass();
- if (SUCCEEDED(hr)) {
- bFinalPass = m_bFinalPass;
- } else {
- bFinalPass = false;
- }
-
- if (bFinalPass) {
- ++screenSpacePassCount;
- }
-
- // Resizers
- float bicubicA = 0;
- switch (iDX9Resizer) {
- case 3:
- bicubicA = -0.60f;
- break;
- case 4:
- bicubicA = -0.751f;
- break; // FIXME : 0.75 crash recent D3D, or eat CPU
- case 5:
- bicubicA = -1.00f;
- break;
- }
-
- hr = InitResizers(bicubicA);
- bResizerShaders = SUCCEEDED(hr);
- screenSpacePassCount += 1; // currently all resizers are 1-pass
-
- // Custom screen space pixel shaders
- bCustomScreenSpacePixelShaders = !m_pCustomScreenSpacePixelShaders.IsEmpty();
-
- if (bCustomScreenSpacePixelShaders) {
- screenSpacePassCount += (int)m_pCustomScreenSpacePixelShaders.GetCount();
- }
-
- // Custom pixel shaders
- bCustomPixelShaders = !m_pCustomPixelShaders.IsEmpty();
-
- hr = InitTemporaryVideoTextures(min((int)m_pCustomPixelShaders.GetCount(), 2));
- if (FAILED(hr)) {
- bCustomPixelShaders = false;
- }
- } else {
- bCustomPixelShaders = false;
- bResizerShaders = false;
- bCustomScreenSpacePixelShaders = false;
- bFinalPass = false;
- }
-
- hr = InitScreenSpacePipeline(screenSpacePassCount, pRenderTarget);
- if (FAILED(hr)) {
- bCustomScreenSpacePixelShaders = false;
- bFinalPass = false;
- }
-
- // Apply the custom pixel shaders if there are any. Result: pVideoTexture
- CComPtr<IDirect3DTexture9> pVideoTexture = m_pVideoTexture[m_nCurSurface];
-
- if (bCustomPixelShaders) {
- static __int64 counter = 0;
- static long start = clock();
-
- long stop = clock();
- long diff = stop - start;
-
- if (diff >= 10*60*CLOCKS_PER_SEC) {
- start = stop; // reset after 10 min (ps float has its limits in both range and accuracy)
- }
+ HRESULT hr;
+
+ // Return if the video texture is not initialized
+ if (m_pVideoTexture[m_nCurSurface] == 0) {
+ return S_OK;
+ }
+
+ CRenderersSettings& settings = GetRenderersSettings();
+
+ // Initialize the processing pipeline
+ bool bCustomPixelShaders;
+ bool bResizerShaders;
+ bool bCustomScreenSpacePixelShaders;
+ bool bFinalPass;
+
+ int screenSpacePassCount = 0;
+ DWORD iDX9Resizer = settings.iDX9Resizer;
+
+ if (m_bD3DX) {
+ // Final pass. Must be initialized first!
+ hr = InitFinalPass();
+ if (SUCCEEDED(hr)) {
+ bFinalPass = m_bFinalPass;
+ } else {
+ bFinalPass = false;
+ }
+
+ if (bFinalPass) {
+ ++screenSpacePassCount;
+ }
+
+ // Resizers
+ float bicubicA = 0;
+ switch (iDX9Resizer) {
+ case 3:
+ bicubicA = -0.60f;
+ break;
+ case 4:
+ bicubicA = -0.751f;
+ break; // FIXME : 0.75 crash recent D3D, or eat CPU
+ case 5:
+ bicubicA = -1.00f;
+ break;
+ }
+
+ hr = InitResizers(bicubicA);
+ bResizerShaders = SUCCEEDED(hr);
+ screenSpacePassCount += 1; // currently all resizers are 1-pass
+
+ // Custom screen space pixel shaders
+ bCustomScreenSpacePixelShaders = !m_pCustomScreenSpacePixelShaders.IsEmpty();
+
+ if (bCustomScreenSpacePixelShaders) {
+ screenSpacePassCount += (int)m_pCustomScreenSpacePixelShaders.GetCount();
+ }
+
+ // Custom pixel shaders
+ bCustomPixelShaders = !m_pCustomPixelShaders.IsEmpty();
+
+ hr = InitTemporaryVideoTextures(min((int)m_pCustomPixelShaders.GetCount(), 2));
+ if (FAILED(hr)) {
+ bCustomPixelShaders = false;
+ }
+ } else {
+ bCustomPixelShaders = false;
+ bResizerShaders = false;
+ bCustomScreenSpacePixelShaders = false;
+ bFinalPass = false;
+ }
+
+ hr = InitScreenSpacePipeline(screenSpacePassCount, pRenderTarget);
+ if (FAILED(hr)) {
+ bCustomScreenSpacePixelShaders = false;
+ bFinalPass = false;
+ }
+
+ // Apply the custom pixel shaders if there are any. Result: pVideoTexture
+ CComPtr<IDirect3DTexture9> pVideoTexture = m_pVideoTexture[m_nCurSurface];
+
+ if (bCustomPixelShaders) {
+ static __int64 counter = 0;
+ static long start = clock();
+
+ long stop = clock();
+ long diff = stop - start;
+
+ if (diff >= 10 * 60 * CLOCKS_PER_SEC) {
+ start = stop; // reset after 10 min (ps float has its limits in both range and accuracy)
+ }
#if 1
- D3DSURFACE_DESC desc;
- m_pVideoTexture[m_nCurSurface]->GetLevelDesc(0, &desc);
+ D3DSURFACE_DESC desc;
+ m_pVideoTexture[m_nCurSurface]->GetLevelDesc(0, &desc);
- float fConstData[][4] = {
- {(float)desc.Width, (float)desc.Height, (float)(counter++), (float)diff / CLOCKS_PER_SEC},
- {1.0f / desc.Width, 1.0f / desc.Height, 0, 0},
- };
+ float fConstData[][4] = {
+ {(float)desc.Width, (float)desc.Height, (float)(counter++), (float)diff / CLOCKS_PER_SEC},
+ {1.0f / desc.Width, 1.0f / desc.Height, 0, 0},
+ };
#else
- CSize VideoSize = GetVisibleVideoSize();
+ CSize VideoSize = GetVisibleVideoSize();
- float fConstData[][4] = {
- {(float)VideoSize.cx, (float)VideoSize.cy, (float)(counter++), (float)diff / CLOCKS_PER_SEC},
- {1.0f / VideoSize.cx, 1.0f / VideoSize.cy, 0, 0},
- };
+ float fConstData[][4] = {
+ {(float)VideoSize.cx, (float)VideoSize.cy, (float)(counter++), (float)diff / CLOCKS_PER_SEC},
+ {1.0f / VideoSize.cx, 1.0f / VideoSize.cy, 0, 0},
+ };
#endif
- hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, _countof(fConstData));
-
- int src = 1;
- int dest = 0;
- bool first = true;
-
- POSITION pos = m_pCustomPixelShaders.GetHeadPosition();
- while (pos) {
- CComPtr<IDirect3DSurface9> pTemporarySurface;
- hr = m_pTemporaryVideoTextures[dest]->GetSurfaceLevel(0, &pTemporarySurface);
- hr = m_pD3DDev->SetRenderTarget(0, pTemporarySurface);
-
- CExternalPixelShader &Shader = m_pCustomPixelShaders.GetNext(pos);
- if (!Shader.m_pPixelShader) {
- Shader.Compile(m_pPSC);
- }
- hr = m_pD3DDev->SetPixelShader(Shader.m_pPixelShader);
-
- if (first) {
- TextureCopy(m_pVideoTexture[m_nCurSurface]);
- first = false;
- } else {
- TextureCopy(m_pTemporaryVideoTextures[src]);
- }
-
- std::swap(src, dest);
- }
-
- pVideoTexture = m_pTemporaryVideoTextures[src];
- }
-
- // Resize the frame
- Vector dst[4];
- Transform(destRect, dst);
-
- hr = BeginScreenSpacePass();
-
- if (m_ScreenSpacePassCount > 0) {
- hr = m_pD3DDev->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0);
- }
-
- if (srcRect.Size() != destRect.Size()) {
- if (iDX9Resizer == 0 || iDX9Resizer == 1 || !bResizerShaders) {
- D3DTEXTUREFILTERTYPE Filter = iDX9Resizer == 0 ? D3DTEXF_POINT : D3DTEXF_LINEAR;
- hr = TextureResize(pVideoTexture, dst, Filter, srcRect);
- } else if (iDX9Resizer == 2) {
- hr = TextureResizeBilinear(pVideoTexture, dst, srcRect);
- } else if (iDX9Resizer >= 3) {
- hr = TextureResizeBicubic1pass(pVideoTexture, dst, srcRect);
- }
- } else {
- hr = TextureResize(pVideoTexture, dst, D3DTEXF_POINT, srcRect);
- }
-
- // Apply the custom screen size pixel shaders
- if (bCustomScreenSpacePixelShaders) {
- static __int64 counter = 555;
- static long start = clock() + 333;
-
- long stop = clock() + 333;
- long diff = stop - start;
-
- if (diff >= 10*60*CLOCKS_PER_SEC) {
- start = stop; // reset after 10 min (ps float has its limits in both range and accuracy)
- }
-
- float fConstData[][4] = {
- {(float)m_TemporaryScreenSpaceTextureSize.cx, (float)m_TemporaryScreenSpaceTextureSize.cy, (float)(counter++), (float)diff / CLOCKS_PER_SEC},
- {1.0f / m_TemporaryScreenSpaceTextureSize.cx, 1.0f / m_TemporaryScreenSpaceTextureSize.cy, 0, 0},
- };
-
- hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, _countof(fConstData));
-
- POSITION pos = m_pCustomScreenSpacePixelShaders.GetHeadPosition();
- while (pos) {
- BeginScreenSpacePass();
-
- CExternalPixelShader &Shader = m_pCustomScreenSpacePixelShaders.GetNext(pos);
- if (!Shader.m_pPixelShader) {
- Shader.Compile(m_pPSC);
- }
- hr = m_pD3DDev->SetPixelShader(Shader.m_pPixelShader);
- TextureCopy(m_pTemporaryScreenSpaceTextures[m_ScreenSpacePassSrc]);
- }
- }
-
- // Final pass
- if (bFinalPass) {
- hr = BeginScreenSpacePass();
- hr = FinalPass(m_pTemporaryScreenSpaceTextures[m_ScreenSpacePassSrc]);
- }
-
- hr = m_pD3DDev->SetPixelShader(NULL);
-
- return hr;
+ hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, _countof(fConstData));
+
+ int src = 1;
+ int dest = 0;
+ bool first = true;
+
+ POSITION pos = m_pCustomPixelShaders.GetHeadPosition();
+ while (pos) {
+ CComPtr<IDirect3DSurface9> pTemporarySurface;
+ hr = m_pTemporaryVideoTextures[dest]->GetSurfaceLevel(0, &pTemporarySurface);
+ hr = m_pD3DDev->SetRenderTarget(0, pTemporarySurface);
+
+ CExternalPixelShader& Shader = m_pCustomPixelShaders.GetNext(pos);
+ if (!Shader.m_pPixelShader) {
+ Shader.Compile(m_pPSC);
+ }
+ hr = m_pD3DDev->SetPixelShader(Shader.m_pPixelShader);
+
+ if (first) {
+ TextureCopy(m_pVideoTexture[m_nCurSurface]);
+ first = false;
+ } else {
+ TextureCopy(m_pTemporaryVideoTextures[src]);
+ }
+
+ std::swap(src, dest);
+ }
+
+ pVideoTexture = m_pTemporaryVideoTextures[src];
+ }
+
+ // Resize the frame
+ Vector dst[4];
+ Transform(destRect, dst);
+
+ hr = BeginScreenSpacePass();
+
+ if (m_ScreenSpacePassCount > 0) {
+ hr = m_pD3DDev->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0);
+ }
+
+ if (srcRect.Size() != destRect.Size()) {
+ if (iDX9Resizer == 0 || iDX9Resizer == 1 || !bResizerShaders) {
+ D3DTEXTUREFILTERTYPE Filter = iDX9Resizer == 0 ? D3DTEXF_POINT : D3DTEXF_LINEAR;
+ hr = TextureResize(pVideoTexture, dst, Filter, srcRect);
+ } else if (iDX9Resizer == 2) {
+ hr = TextureResizeBilinear(pVideoTexture, dst, srcRect);
+ } else if (iDX9Resizer >= 3) {
+ hr = TextureResizeBicubic1pass(pVideoTexture, dst, srcRect);
+ }
+ } else {
+ hr = TextureResize(pVideoTexture, dst, D3DTEXF_POINT, srcRect);
+ }
+
+ // Apply the custom screen size pixel shaders
+ if (bCustomScreenSpacePixelShaders) {
+ static __int64 counter = 555;
+ static long start = clock() + 333;
+
+ long stop = clock() + 333;
+ long diff = stop - start;
+
+ if (diff >= 10 * 60 * CLOCKS_PER_SEC) {
+ start = stop; // reset after 10 min (ps float has its limits in both range and accuracy)
+ }
+
+ float fConstData[][4] = {
+ {(float)m_TemporaryScreenSpaceTextureSize.cx, (float)m_TemporaryScreenSpaceTextureSize.cy, (float)(counter++), (float)diff / CLOCKS_PER_SEC},
+ {1.0f / m_TemporaryScreenSpaceTextureSize.cx, 1.0f / m_TemporaryScreenSpaceTextureSize.cy, 0, 0},
+ };
+
+ hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, _countof(fConstData));
+
+ POSITION pos = m_pCustomScreenSpacePixelShaders.GetHeadPosition();
+ while (pos) {
+ BeginScreenSpacePass();
+
+ CExternalPixelShader& Shader = m_pCustomScreenSpacePixelShaders.GetNext(pos);
+ if (!Shader.m_pPixelShader) {
+ Shader.Compile(m_pPSC);
+ }
+ hr = m_pD3DDev->SetPixelShader(Shader.m_pPixelShader);
+ TextureCopy(m_pTemporaryScreenSpaceTextures[m_ScreenSpacePassSrc]);
+ }
+ }
+
+ // Final pass
+ if (bFinalPass) {
+ hr = BeginScreenSpacePass();
+ hr = FinalPass(m_pTemporaryScreenSpaceTextures[m_ScreenSpacePassSrc]);
+ }
+
+ hr = m_pD3DDev->SetPixelShader(NULL);
+
+ return hr;
}
HRESULT CDX9RenderingEngine::RenderVideoStretchRectPath(IDirect3DSurface9* pRenderTarget, const CRect& srcRect, const CRect& destRect)
{
- HRESULT hr;
+ HRESULT hr;
- // Return if the render target or the video surface is not initialized
- if (pRenderTarget == 0 || m_pVideoSurface[m_nCurSurface] == 0) {
- return S_OK;
- }
+ // Return if the render target or the video surface is not initialized
+ if (pRenderTarget == 0 || m_pVideoSurface[m_nCurSurface] == 0) {
+ return S_OK;
+ }
- CRect rSrcVid(srcRect);
- CRect rDstVid(destRect);
+ CRect rSrcVid(srcRect);
+ CRect rDstVid(destRect);
- ClipToSurface(pRenderTarget, rSrcVid, rDstVid); // grrr
- // IMPORTANT: rSrcVid has to be aligned on mod2 for yuy2->rgb conversion with StretchRect!!!
- rSrcVid.left &= ~1;
- rSrcVid.right &= ~1;
- rSrcVid.top &= ~1;
- rSrcVid.bottom &= ~1;
- hr = m_pD3DDev->StretchRect(m_pVideoSurface[m_nCurSurface], rSrcVid, pRenderTarget, rDstVid, m_StretchRectFilter);
+ ClipToSurface(pRenderTarget, rSrcVid, rDstVid); // grrr
+ // IMPORTANT: rSrcVid has to be aligned on mod2 for yuy2->rgb conversion with StretchRect!!!
+ rSrcVid.left &= ~1;
+ rSrcVid.right &= ~1;
+ rSrcVid.top &= ~1;
+ rSrcVid.bottom &= ~1;
+ hr = m_pD3DDev->StretchRect(m_pVideoSurface[m_nCurSurface], rSrcVid, pRenderTarget, rDstVid, m_StretchRectFilter);
- return hr;
+ return hr;
}
HRESULT CDX9RenderingEngine::InitTemporaryVideoTextures(int count)
{
- HRESULT hr = S_OK;
-
- for (int i = 0; i < count; i++) {
- if (m_pTemporaryVideoTextures[i] == NULL) {
- hr = m_pD3DDev->CreateTexture(
- m_NativeVideoSize.cx, m_NativeVideoSize.cy, 1, D3DUSAGE_RENDERTARGET, m_SurfaceType,
- D3DPOOL_DEFAULT, &m_pTemporaryVideoTextures[i], NULL);
-
- if (FAILED(hr)) {
- // Free all textures
- for (int j = 0; j < 2; j++) {
- m_pTemporaryVideoTextures[j] = NULL;
- }
-
- return hr;
- }
- }
- }
-
- // Free unnecessary textures
- for (int i = count; i < 2; i++) {
- m_pTemporaryVideoTextures[i] = NULL;
- }
-
- return hr;
+ HRESULT hr = S_OK;
+
+ for (int i = 0; i < count; i++) {
+ if (m_pTemporaryVideoTextures[i] == NULL) {
+ hr = m_pD3DDev->CreateTexture(
+ m_NativeVideoSize.cx, m_NativeVideoSize.cy, 1, D3DUSAGE_RENDERTARGET, m_SurfaceType,
+ D3DPOOL_DEFAULT, &m_pTemporaryVideoTextures[i], NULL);
+
+ if (FAILED(hr)) {
+ // Free all textures
+ for (int j = 0; j < 2; j++) {
+ m_pTemporaryVideoTextures[j] = NULL;
+ }
+
+ return hr;
+ }
+ }
+ }
+
+ // Free unnecessary textures
+ for (int i = count; i < 2; i++) {
+ m_pTemporaryVideoTextures[i] = NULL;
+ }
+
+ return hr;
}
HRESULT CDX9RenderingEngine::InitScreenSpacePipeline(int passCount, IDirect3DSurface9* pRenderTarget)
{
- m_pRenderTarget = pRenderTarget;
- m_ScreenSpacePassCount = passCount;
- m_ScreenSpacePassSrc = 0;
- m_ScreenSpacePassDest = 1;
+ m_pRenderTarget = pRenderTarget;
+ m_ScreenSpacePassCount = passCount;
+ m_ScreenSpacePassSrc = 0;
+ m_ScreenSpacePassDest = 1;
- HRESULT hr = InitTemporaryScreenSpaceTextures(min(passCount - 1, 2));
+ HRESULT hr = InitTemporaryScreenSpaceTextures(min(passCount - 1, 2));
- // If the initialized have failed, disable the pipeline
- if (FAILED(hr)) {
- m_ScreenSpacePassCount = 1;
- }
+ // If the initialized have failed, disable the pipeline
+ if (FAILED(hr)) {
+ m_ScreenSpacePassCount = 1;
+ }
- return hr;
+ return hr;
}
HRESULT CDX9RenderingEngine::InitTemporaryScreenSpaceTextures(int count)
{
- HRESULT hr = S_OK;
-
- for (int i = 0; i < count; i++) {
- if (m_pTemporaryScreenSpaceTextures[i] == NULL) {
- m_TemporaryScreenSpaceTextureSize = CSize(min(m_ScreenSize.cx, (int)m_Caps.MaxTextureWidth),
- min(max(m_ScreenSize.cy, m_NativeVideoSize.cy), (int)m_Caps.MaxTextureHeight));
- hr = m_pD3DDev->CreateTexture(
- m_TemporaryScreenSpaceTextureSize.cx, m_TemporaryScreenSpaceTextureSize.cy, 1, D3DUSAGE_RENDERTARGET, m_SurfaceType,
- D3DPOOL_DEFAULT, &m_pTemporaryScreenSpaceTextures[i], NULL);
-
- if (FAILED(hr)) {
- // Free all textures
- for (int j = 0; j < 2; j++) {
- m_pTemporaryScreenSpaceTextures[j] = NULL;
- }
-
- return hr;
- }
- }
- }
-
- // Free unnecessary textures
- for (int i = count; i < 2; i++) {
- m_pTemporaryScreenSpaceTextures[i] = NULL;
- }
-
- return hr;
+ HRESULT hr = S_OK;
+
+ for (int i = 0; i < count; i++) {
+ if (m_pTemporaryScreenSpaceTextures[i] == NULL) {
+ m_TemporaryScreenSpaceTextureSize = CSize(min(m_ScreenSize.cx, (int)m_Caps.MaxTextureWidth),
+ min(max(m_ScreenSize.cy, m_NativeVideoSize.cy), (int)m_Caps.MaxTextureHeight));
+ hr = m_pD3DDev->CreateTexture(
+ m_TemporaryScreenSpaceTextureSize.cx, m_TemporaryScreenSpaceTextureSize.cy, 1, D3DUSAGE_RENDERTARGET, m_SurfaceType,
+ D3DPOOL_DEFAULT, &m_pTemporaryScreenSpaceTextures[i], NULL);
+
+ if (FAILED(hr)) {
+ // Free all textures
+ for (int j = 0; j < 2; j++) {
+ m_pTemporaryScreenSpaceTextures[j] = NULL;
+ }
+
+ return hr;
+ }
+ }
+ }
+
+ // Free unnecessary textures
+ for (int i = count; i < 2; i++) {
+ m_pTemporaryScreenSpaceTextures[i] = NULL;
+ }
+
+ return hr;
}
HRESULT CDX9RenderingEngine::BeginScreenSpacePass()
{
- HRESULT hr;
+ HRESULT hr;
- std::swap(m_ScreenSpacePassSrc, m_ScreenSpacePassDest);
- --m_ScreenSpacePassCount;
+ std::swap(m_ScreenSpacePassSrc, m_ScreenSpacePassDest);
+ --m_ScreenSpacePassCount;
- if (m_ScreenSpacePassCount > 0) {
- CComPtr<IDirect3DSurface9> pTemporarySurface;
- hr = m_pTemporaryScreenSpaceTextures[m_ScreenSpacePassDest]->GetSurfaceLevel(0, &pTemporarySurface);
+ if (m_ScreenSpacePassCount > 0) {
+ CComPtr<IDirect3DSurface9> pTemporarySurface;
+ hr = m_pTemporaryScreenSpaceTextures[m_ScreenSpacePassDest]->GetSurfaceLevel(0, &pTemporarySurface);
- if (SUCCEEDED(hr)) {
- hr = m_pD3DDev->SetRenderTarget(0, pTemporarySurface);
- }
- } else {
- hr = m_pD3DDev->SetRenderTarget(0, m_pRenderTarget);
- }
+ if (SUCCEEDED(hr)) {
+ hr = m_pD3DDev->SetRenderTarget(0, pTemporarySurface);
+ }
+ } else {
+ hr = m_pD3DDev->SetRenderTarget(0, m_pRenderTarget);
+ }
- return hr;
+ return hr;
}
HRESULT CDX9RenderingEngine::InitResizers(float bicubicA)
{
- HRESULT hr;
-
- // Check whether the resizer pixel shaders must be initialized
- bool bInitRequired = false;
-
- if (bicubicA) {
- for (int i = 0; i < 4; i++) {
- if (!m_pResizerPixelShaders[i]) {
- bInitRequired = true;
- }
- }
-
- if (m_BicubicA != bicubicA) {
- bInitRequired = true;
- }
- } else {
- if (!m_pResizerPixelShaders[0]) {
- bInitRequired = true;
- }
- }
-
- if (!bInitRequired) {
- return S_OK;
- }
-
- // Initialize the resizer pixel shaders
- m_BicubicA = bicubicA;
-
- for (int i = 0; i < _countof(m_pResizerPixelShaders); i++) {
- m_pResizerPixelShaders[i] = NULL;
- }
-
- if (m_Caps.PixelShaderVersion < D3DPS_VERSION(2, 0)) {
- return E_FAIL;
- }
-
- LPCSTR pProfile = m_Caps.PixelShaderVersion >= D3DPS_VERSION(3, 0) ? "ps_3_0" : "ps_2_0";
-
- CStringA str;
- if (!LoadResource(IDF_SHADER_RESIZER, str, _T("FILE"))) {
- return E_FAIL;
- }
-
- CStringA A;
- A.Format("(%f)", bicubicA);
- str.Replace("_The_Value_Of_A_Is_Set_Here_", A);
-
- LPCSTR pEntries[] = {"main_bilinear", "main_bicubic1pass", "main_bicubic2pass_pass1", "main_bicubic2pass_pass2"};
-
- ASSERT(_countof(pEntries) == _countof(m_pResizerPixelShaders));
-
- for (int i = 0; i < _countof(pEntries); i++) {
- CString ErrorMessage;
- CString DissAssembly;
- hr = m_pPSC->CompileShader(str, pEntries[i], pProfile, 0, &m_pResizerPixelShaders[i], &DissAssembly, &ErrorMessage);
- if (FAILED(hr)) {
- TRACE("%ws", ErrorMessage.GetString());
- ASSERT (0);
- return hr;
- }
- /*
- if (i == 2 || i == 3)
- {
- const wchar_t *pStr = DissAssembly.GetString();
- TRACE("DisAsm: %s\n", pEntries[i]);
- const wchar_t *pStrStart = pStr;
- while (*pStr)
- {
- while (*pStr && *pStr != '\n')
- ++pStr;
- if (*pStr == '\n')
- ++pStr;
- if (*pStr == '\r')
- ++pStr;
- CString Test(pStrStart, pStr - pStrStart);
- TRACE("%ws", Test.GetString());
- pStrStart = pStr;
- }
- }
- */
- }
-
- return S_OK;
+ HRESULT hr;
+
+ // Check whether the resizer pixel shaders must be initialized
+ bool bInitRequired = false;
+
+ if (bicubicA) {
+ for (int i = 0; i < 4; i++) {
+ if (!m_pResizerPixelShaders[i]) {
+ bInitRequired = true;
+ }
+ }
+
+ if (m_BicubicA != bicubicA) {
+ bInitRequired = true;
+ }
+ } else {
+ if (!m_pResizerPixelShaders[0]) {
+ bInitRequired = true;
+ }
+ }
+
+ if (!bInitRequired) {
+ return S_OK;
+ }
+
+ // Initialize the resizer pixel shaders
+ m_BicubicA = bicubicA;
+
+ for (int i = 0; i < _countof(m_pResizerPixelShaders); i++) {
+ m_pResizerPixelShaders[i] = NULL;
+ }
+
+ if (m_Caps.PixelShaderVersion < D3DPS_VERSION(2, 0)) {
+ return E_FAIL;
+ }
+
+ LPCSTR pProfile = m_Caps.PixelShaderVersion >= D3DPS_VERSION(3, 0) ? "ps_3_0" : "ps_2_0";
+
+ CStringA str;
+ if (!LoadResource(IDF_SHADER_RESIZER, str, _T("FILE"))) {
+ return E_FAIL;
+ }
+
+ CStringA A;
+ A.Format("(%f)", bicubicA);
+ str.Replace("_The_Value_Of_A_Is_Set_Here_", A);
+
+ LPCSTR pEntries[] = {"main_bilinear", "main_bicubic1pass", "main_bicubic2pass_pass1", "main_bicubic2pass_pass2"};
+
+ ASSERT(_countof(pEntries) == _countof(m_pResizerPixelShaders));
+
+ for (int i = 0; i < _countof(pEntries); i++) {
+ CString ErrorMessage;
+ CString DissAssembly;
+ hr = m_pPSC->CompileShader(str, pEntries[i], pProfile, 0, &m_pResizerPixelShaders[i], &DissAssembly, &ErrorMessage);
+ if (FAILED(hr)) {
+ TRACE("%ws", ErrorMessage.GetString());
+ ASSERT(0);
+ return hr;
+ }
+ /*
+ if (i == 2 || i == 3)
+ {
+ const wchar_t *pStr = DissAssembly.GetString();
+ TRACE("DisAsm: %s\n", pEntries[i]);
+ const wchar_t *pStrStart = pStr;
+ while (*pStr)
+ {
+ while (*pStr && *pStr != '\n')
+ ++pStr;
+ if (*pStr == '\n')
+ ++pStr;
+ if (*pStr == '\r')
+ ++pStr;
+ CString Test(pStrStart, pStr - pStrStart);
+ TRACE("%ws", Test.GetString());
+ pStrStart = pStr;
+ }
+ }
+ */
+ }
+
+ return S_OK;
}
-HRESULT CDX9RenderingEngine::TextureResize(IDirect3DTexture9* pTexture, Vector dst[4], D3DTEXTUREFILTERTYPE filter, const CRect &srcRect)
+HRESULT CDX9RenderingEngine::TextureResize(IDirect3DTexture9* pTexture, Vector dst[4], D3DTEXTUREFILTERTYPE filter, const CRect& srcRect)
{
- HRESULT hr;
+ HRESULT hr;
- D3DSURFACE_DESC desc;
- if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
- return E_FAIL;
- }
+ D3DSURFACE_DESC desc;
+ if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
+ return E_FAIL;
+ }
- float w = (float)desc.Width;
- float h = (float)desc.Height;
+ float w = (float)desc.Width;
+ float h = (float)desc.Height;
- float dx2 = 1.0f/w;
- float dy2 = 1.0f/h;
+ float dx2 = 1.0f / w;
+ float dy2 = 1.0f / h;
- MYD3DVERTEX<1> v[] = {
- {dst[0].x, dst[0].y, dst[0].z, 1.0f/dst[0].z, srcRect.left * dx2, srcRect.top * dy2},
- {dst[1].x, dst[1].y, dst[1].z, 1.0f/dst[1].z, srcRect.right * dx2, srcRect.top * dy2},
- {dst[2].x, dst[2].y, dst[2].z, 1.0f/dst[2].z, srcRect.left * dx2, srcRect.bottom * dy2},
- {dst[3].x, dst[3].y, dst[3].z, 1.0f/dst[3].z, srcRect.right * dx2, srcRect.bottom * dy2},
- };
+ MYD3DVERTEX<1> v[] = {
+ {dst[0].x, dst[0].y, dst[0].z, 1.0f / dst[0].z, srcRect.left * dx2, srcRect.top * dy2},
+ {dst[1].x, dst[1].y, dst[1].z, 1.0f / dst[1].z, srcRect.right * dx2, srcRect.top * dy2},
+ {dst[2].x, dst[2].y, dst[2].z, 1.0f / dst[2].z, srcRect.left * dx2, srcRect.bottom * dy2},
+ {dst[3].x, dst[3].y, dst[3].z, 1.0f / dst[3].z, srcRect.right * dx2, srcRect.bottom * dy2},
+ };
- AdjustQuad(v, 0, 0);
+ AdjustQuad(v, 0, 0);
- hr = m_pD3DDev->SetTexture(0, pTexture);
- hr = m_pD3DDev->SetPixelShader(NULL);
- hr = TextureBlt(m_pD3DDev, v, filter);
+ hr = m_pD3DDev->SetTexture(0, pTexture);
+ hr = m_pD3DDev->SetPixelShader(NULL);
+ hr = TextureBlt(m_pD3DDev, v, filter);
- return hr;
+ return hr;
}
-HRESULT CDX9RenderingEngine::TextureResizeBilinear(IDirect3DTexture9* pTexture, Vector dst[4], const CRect &srcRect)
+HRESULT CDX9RenderingEngine::TextureResizeBilinear(IDirect3DTexture9* pTexture, Vector dst[4], const CRect& srcRect)
{
- HRESULT hr;
+ HRESULT hr;
- D3DSURFACE_DESC desc;
- if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
- return E_FAIL;
- }
+ D3DSURFACE_DESC desc;
+ if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
+ return E_FAIL;
+ }
- // make const to give compiler a chance of optimising, also float faster than double and converted to float to sent to PS anyway
- const float dx = 1.0f/(float)desc.Width;
- const float dy = 1.0f/(float)desc.Height;
- const float tx0 = (float)srcRect.left;
- const float tx1 = (float)srcRect.right;
- const float ty0 = (float)srcRect.top;
- const float ty1 = (float)srcRect.bottom;
+ // make const to give compiler a chance of optimising, also float faster than double and converted to float to sent to PS anyway
+ const float dx = 1.0f / (float)desc.Width;
+ const float dy = 1.0f / (float)desc.Height;
+ const float tx0 = (float)srcRect.left;
+ const float tx1 = (float)srcRect.right;
+ const float ty0 = (float)srcRect.top;
+ const float ty1 = (float)srcRect.bottom;
- MYD3DVERTEX<1> v[] = {
- {dst[0].x, dst[0].y, dst[0].z, 1.0f/dst[0].z, tx0, ty0},
- {dst[1].x, dst[1].y, dst[1].z, 1.0f/dst[1].z, tx1, ty0},
- {dst[2].x, dst[2].y, dst[2].z, 1.0f/dst[2].z, tx0, ty1},
- {dst[3].x, dst[3].y, dst[3].z, 1.0f/dst[3].z, tx1, ty1},
- };
+ MYD3DVERTEX<1> v[] = {
+ {dst[0].x, dst[0].y, dst[0].z, 1.0f / dst[0].z, tx0, ty0},
+ {dst[1].x, dst[1].y, dst[1].z, 1.0f / dst[1].z, tx1, ty0},
+ {dst[2].x, dst[2].y, dst[2].z, 1.0f / dst[2].z, tx0, ty1},
+ {dst[3].x, dst[3].y, dst[3].z, 1.0f / dst[3].z, tx1, ty1},
+ };
- AdjustQuad(v, 1.0, 1.0);
+ AdjustQuad(v, 1.0, 1.0);
- hr = m_pD3DDev->SetTexture(0, pTexture);
+ hr = m_pD3DDev->SetTexture(0, pTexture);
- float fConstData[][4] = {{dx*0.5f, dy*0.5f, 0, 0}, {dx, dy, 0, 0}, {dx, 0, 0, 0}, {0, dy, 0, 0}};
- hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, _countof(fConstData));
+ float fConstData[][4] = {{dx * 0.5f, dy * 0.5f, 0, 0}, {dx, dy, 0, 0}, {dx, 0, 0, 0}, {0, dy, 0, 0}};
+ hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, _countof(fConstData));
- hr = m_pD3DDev->SetTexture(0, pTexture);
- hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShaders[0]);
+ hr = m_pD3DDev->SetTexture(0, pTexture);
+ hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShaders[0]);
- hr = TextureBlt(m_pD3DDev, v, D3DTEXF_POINT);
- return hr;
+ hr = TextureBlt(m_pD3DDev, v, D3DTEXF_POINT);
+ return hr;
}
-HRESULT CDX9RenderingEngine::TextureResizeBicubic1pass(IDirect3DTexture9* pTexture, Vector dst[4], const CRect &srcRect)
+HRESULT CDX9RenderingEngine::TextureResizeBicubic1pass(IDirect3DTexture9* pTexture, Vector dst[4], const CRect& srcRect)
{
- HRESULT hr;
+ HRESULT hr;
- D3DSURFACE_DESC desc;
- if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
- return E_FAIL;
- }
+ D3DSURFACE_DESC desc;
+ if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
+ return E_FAIL;
+ }
- // make const to give compiler a chance of optimising, also float faster than double and converted to float to sent to PS anyway
- const float dx = 1.0f/(float)desc.Width;
- const float dy = 1.0f/(float)desc.Height;
- const float tx0 = (float)srcRect.left;
- const float tx1 = (float)srcRect.right;
- const float ty0 = (float)srcRect.top;
- const float ty1 = (float)srcRect.bottom;
+ // make const to give compiler a chance of optimising, also float faster than double and converted to float to sent to PS anyway
+ const float dx = 1.0f / (float)desc.Width;
+ const float dy = 1.0f / (float)desc.Height;
+ const float tx0 = (float)srcRect.left;
+ const float tx1 = (float)srcRect.right;
+ const float ty0 = (float)srcRect.top;
+ const float ty1 = (float)srcRect.bottom;
- MYD3DVERTEX<1> v[] = {
- {dst[0].x, dst[0].y, dst[0].z, 1.0f/dst[0].z, tx0, ty0},
- {dst[1].x, dst[1].y, dst[1].z, 1.0f/dst[1].z, tx1, ty0},
- {dst[2].x, dst[2].y, dst[2].z, 1.0f/dst[2].z, tx0, ty1},
- {dst[3].x, dst[3].y, dst[3].z, 1.0f/dst[3].z, tx1, ty1},
- };
+ MYD3DVERTEX<1> v[] = {
+ {dst[0].x, dst[0].y, dst[0].z, 1.0f / dst[0].z, tx0, ty0},
+ {dst[1].x, dst[1].y, dst[1].z, 1.0f / dst[1].z, tx1, ty0},
+ {dst[2].x, dst[2].y, dst[2].z, 1.0f / dst[2].z, tx0, ty1},
+ {dst[3].x, dst[3].y, dst[3].z, 1.0f / dst[3].z, tx1, ty1},
+ };
- AdjustQuad(v, 1.0, 1.0);
+ AdjustQuad(v, 1.0, 1.0);
- hr = m_pD3DDev->SetTexture(0, pTexture);
+ hr = m_pD3DDev->SetTexture(0, pTexture);
- float fConstData[][4] = {{dx*0.5f, dy*0.5f, 0, 0}, {dx, dy, 0, 0}, {dx, 0, 0, 0}, {0, dy, 0, 0}};
- hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, _countof(fConstData));
+ float fConstData[][4] = {{dx * 0.5f, dy * 0.5f, 0, 0}, {dx, dy, 0, 0}, {dx, 0, 0, 0}, {0, dy, 0, 0}};
+ hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, _countof(fConstData));
- hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShaders[1]);
+ hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShaders[1]);
- hr = TextureBlt(m_pD3DDev, v, D3DTEXF_POINT);
- return hr;
+ hr = TextureBlt(m_pD3DDev, v, D3DTEXF_POINT);
+ return hr;
}
/*
// The 2 pass sampler is incorrect in that it only does bilinear resampling in the y direction.
HRESULT CDX9RenderingEngine::TextureResizeBicubic2pass(IDirect3DTexture9* pTexture, Vector dst[4], const CRect &srcRect)
{
- HRESULT hr;
+ HRESULT hr;
- // rotated?
- if (dst[0].z != dst[1].z || dst[2].z != dst[3].z || dst[0].z != dst[3].z
- || dst[0].y != dst[1].y || dst[0].x != dst[2].x || dst[2].y != dst[3].y || dst[1].x != dst[3].x)
- return TextureResizeBicubic1pass(pTexture, dst, srcRect);
+ // rotated?
+ if (dst[0].z != dst[1].z || dst[2].z != dst[3].z || dst[0].z != dst[3].z
+ || dst[0].y != dst[1].y || dst[0].x != dst[2].x || dst[2].y != dst[3].y || dst[1].x != dst[3].x)
+ return TextureResizeBicubic1pass(pTexture, dst, srcRect);
- D3DSURFACE_DESC desc;
- if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
- return E_FAIL;
+ D3DSURFACE_DESC desc;
+ if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
+ return E_FAIL;
- float Tex0_Width = desc.Width;
- float Tex0_Height = desc.Height;
+ float Tex0_Width = desc.Width;
+ float Tex0_Height = desc.Height;
- double dx0 = 1.0/desc.Width;
- UNREFERENCED_PARAMETER(dx0);
- double dy0 = 1.0/desc.Height;
- UNREFERENCED_PARAMETER(dy0);
+ double dx0 = 1.0/desc.Width;
+ UNREFERENCED_PARAMETER(dx0);
+ double dy0 = 1.0/desc.Height;
+ UNREFERENCED_PARAMETER(dy0);
- CSize SrcTextSize = CSize(desc.Width, desc.Height);
- double w = (double)srcRect.Width();
- double h = (double)srcRect.Height();
- UNREFERENCED_PARAMETER(w);
+ CSize SrcTextSize = CSize(desc.Width, desc.Height);
+ double w = (double)srcRect.Width();
+ double h = (double)srcRect.Height();
+ UNREFERENCED_PARAMETER(w);
- CRect dst1(0, 0, (int)(dst[3].x - dst[0].x), (int)h);
+ CRect dst1(0, 0, (int)(dst[3].x - dst[0].x), (int)h);
- if (!m_pTemporaryScreenSpaceTextures[0] || FAILED(m_pTemporaryScreenSpaceTextures[0]->GetLevelDesc(0, &desc)))
- return TextureResizeBicubic1pass(pTexture, dst, srcRect);
+ if (!m_pTemporaryScreenSpaceTextures[0] || FAILED(m_pTemporaryScreenSpaceTextures[0]->GetLevelDesc(0, &desc)))
+ return TextureResizeBicubic1pass(pTexture, dst, srcRect);
- float Tex1_Width = desc.Width;
- float Tex1_Height = desc.Height;
+ float Tex1_Width = desc.Width;
+ float Tex1_Height = desc.Height;
- double dx1 = 1.0/desc.Width;
- UNREFERENCED_PARAMETER(dx1);
- double dy1 = 1.0/desc.Height;
- UNREFERENCED_PARAMETER(dy1);
+ double dx1 = 1.0/desc.Width;
+ UNREFERENCED_PARAMETER(dx1);
+ double dy1 = 1.0/desc.Height;
+ UNREFERENCED_PARAMETER(dy1);
- double dw = (double)dst1.Width() / desc.Width;
- UNREFERENCED_PARAMETER(dw);
- double dh = (double)dst1.Height() / desc.Height;
- UNREFERENCED_PARAMETER(dh);
+ double dw = (double)dst1.Width() / desc.Width;
+ UNREFERENCED_PARAMETER(dw);
+ double dh = (double)dst1.Height() / desc.Height;
+ UNREFERENCED_PARAMETER(dh);
- float dx2 = 1.0f/SrcTextSize.cx;
- UNREFERENCED_PARAMETER(dx2);
- float dy2 = 1.0f/SrcTextSize.cy;
- UNREFERENCED_PARAMETER(dy2);
+ float dx2 = 1.0f/SrcTextSize.cx;
+ UNREFERENCED_PARAMETER(dx2);
+ float dy2 = 1.0f/SrcTextSize.cy;
+ UNREFERENCED_PARAMETER(dy2);
- float tx0 = srcRect.left;
- float tx1 = srcRect.right;
- float ty0 = srcRect.top;
- float ty1 = srcRect.bottom;
+ float tx0 = srcRect.left;
+ float tx1 = srcRect.right;
+ float ty0 = srcRect.top;
+ float ty1 = srcRect.bottom;
- float tx0_2 = 0;
- float tx1_2 = dst1.Width();
- float ty0_2 = 0;
- float ty1_2 = h;
+ float tx0_2 = 0;
+ float tx1_2 = dst1.Width();
+ float ty0_2 = 0;
+ float ty1_2 = h;
- // ASSERT(dst1.Height() == desc.Height);
+ // ASSERT(dst1.Height() == desc.Height);
- if (dst1.Width() > (int)desc.Width || dst1.Height() > (int)desc.Height)
- // if (dst1.Width() != desc.Width || dst1.Height() != desc.Height)
- return TextureResizeBicubic1pass(pTexture, dst, srcRect);
+ if (dst1.Width() > (int)desc.Width || dst1.Height() > (int)desc.Height)
+ // if (dst1.Width() != desc.Width || dst1.Height() != desc.Height)
+ return TextureResizeBicubic1pass(pTexture, dst, srcRect);
- MYD3DVERTEX<1> vx[] =
- {
- {(float)dst1.left, (float)dst1.top, 0.5f, 2.0f, tx0, ty0},
- {(float)dst1.right, (float)dst1.top, 0.5f, 2.0f, tx1, ty0},
- {(float)dst1.left, (float)dst1.bottom, 0.5f, 2.0f, tx0, ty1},
- {(float)dst1.right, (float)dst1.bottom, 0.5f, 2.0f, tx1, ty1},
- };
+ MYD3DVERTEX<1> vx[] =
+ {
+ {(float)dst1.left, (float)dst1.top, 0.5f, 2.0f, tx0, ty0},
+ {(float)dst1.right, (float)dst1.top, 0.5f, 2.0f, tx1, ty0},
+ {(float)dst1.left, (float)dst1.bottom, 0.5f, 2.0f, tx0, ty1},
+ {(float)dst1.right, (float)dst1.bottom, 0.5f, 2.0f, tx1, ty1},
+ };
- AdjustQuad(vx, 1.0, 0.0); // Casimir666 : bug here, create vertical lines ! TODO : why ??????
+ AdjustQuad(vx, 1.0, 0.0); // Casimir666 : bug here, create vertical lines ! TODO : why ??????
- MYD3DVERTEX<1> vy[] =
- {
- {dst[0].x, dst[0].y, dst[0].z, 1.0/dst[0].z, tx0_2, ty0_2},
- {dst[1].x, dst[1].y, dst[1].z, 1.0/dst[1].z, tx1_2, ty0_2},
- {dst[2].x, dst[2].y, dst[2].z, 1.0/dst[2].z, tx0_2, ty1_2},
- {dst[3].x, dst[3].y, dst[3].z, 1.0/dst[3].z, tx1_2, ty1_2},
- };
+ MYD3DVERTEX<1> vy[] =
+ {
+ {dst[0].x, dst[0].y, dst[0].z, 1.0/dst[0].z, tx0_2, ty0_2},
+ {dst[1].x, dst[1].y, dst[1].z, 1.0/dst[1].z, tx1_2, ty0_2},
+ {dst[2].x, dst[2].y, dst[2].z, 1.0/dst[2].z, tx0_2, ty1_2},
+ {dst[3].x, dst[3].y, dst[3].z, 1.0/dst[3].z, tx1_2, ty1_2},
+ };
- AdjustQuad(vy, 0.0, 1.0); // Casimir666 : bug here, create horizontal lines ! TODO : why ??????
+ AdjustQuad(vy, 0.0, 1.0); // Casimir666 : bug here, create horizontal lines ! TODO : why ??????
- hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShaders[2]);
- {
- float fConstData[][4] = {{0.5f / Tex0_Width, 0.5f / Tex0_Height, 0, 0}, {1.0f / Tex0_Width, 1.0f / Tex0_Height, 0, 0}, {1.0f / Tex0_Width, 0, 0, 0}, {0, 1.0f / Tex0_Height, 0, 0}, {Tex0_Width, Tex0_Height, 0, 0}};
- hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, _countof(fConstData));
- }
+ hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShaders[2]);
+ {
+ float fConstData[][4] = {{0.5f / Tex0_Width, 0.5f / Tex0_Height, 0, 0}, {1.0f / Tex0_Width, 1.0f / Tex0_Height, 0, 0}, {1.0f / Tex0_Width, 0, 0, 0}, {0, 1.0f / Tex0_Height, 0, 0}, {Tex0_Width, Tex0_Height, 0, 0}};
+ hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, _countof(fConstData));
+ }
- hr = m_pD3DDev->SetTexture(0, pTexture);
+ hr = m_pD3DDev->SetTexture(0, pTexture);
- CComPtr<IDirect3DSurface9> pRTOld;
- hr = m_pD3DDev->GetRenderTarget(0, &pRTOld);
+ CComPtr<IDirect3DSurface9> pRTOld;
+ hr = m_pD3DDev->GetRenderTarget(0, &pRTOld);
- CComPtr<IDirect3DSurface9> pRT;
- hr = m_pTemporaryScreenSpaceTextures[0]->GetSurfaceLevel(0, &pRT);
- hr = m_pD3DDev->SetRenderTarget(0, pRT);
+ CComPtr<IDirect3DSurface9> pRT;
+ hr = m_pTemporaryScreenSpaceTextures[0]->GetSurfaceLevel(0, &pRT);
+ hr = m_pD3DDev->SetRenderTarget(0, pRT);
- hr = TextureBlt(m_pD3DDev, vx, D3DTEXF_POINT);
+ hr = TextureBlt(m_pD3DDev, vx, D3DTEXF_POINT);
- hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShaders[3]);
- {
- float fConstData[][4] = {{0.5f / Tex1_Width, 0.5f / Tex1_Height, 0, 0}, {1.0f / Tex1_Width, 1.0f / Tex1_Height, 0, 0}, {1.0f / Tex1_Width, 0, 0, 0}, {0, 1.0f / Tex1_Height, 0, 0}, {Tex1_Width, Tex1_Height, 0, 0}};
- hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, _countof(fConstData));
- }
+ hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShaders[3]);
+ {
+ float fConstData[][4] = {{0.5f / Tex1_Width, 0.5f / Tex1_Height, 0, 0}, {1.0f / Tex1_Width, 1.0f / Tex1_Height, 0, 0}, {1.0f / Tex1_Width, 0, 0, 0}, {0, 1.0f / Tex1_Height, 0, 0}, {Tex1_Width, Tex1_Height, 0, 0}};
+ hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, _countof(fConstData));
+ }
- hr = m_pD3DDev->SetTexture(0, m_pTemporaryScreenSpaceTextures[0]);
+ hr = m_pD3DDev->SetTexture(0, m_pTemporaryScreenSpaceTextures[0]);
- hr = m_pD3DDev->SetRenderTarget(0, pRTOld);
+ hr = m_pD3DDev->SetRenderTarget(0, pRTOld);
- hr = TextureBlt(m_pD3DDev, vy, D3DTEXF_POINT);
- return hr;
+ hr = TextureBlt(m_pD3DDev, vy, D3DTEXF_POINT);
+ return hr;
}
*/
HRESULT CDX9RenderingEngine::InitFinalPass()
{
- HRESULT hr;
-
- CRenderersSettings& settings = GetRenderersSettings();
- CRenderersData* data = GetRenderersData();
-
- // Check whether the final pass must be initialized
- bool bColorManagement = settings.m_RenderSettings.iVMR9ColorManagementEnable;
- VideoSystem inputVideoSystem = static_cast<VideoSystem>(settings.m_RenderSettings.iVMR9ColorManagementInput);
- AmbientLight ambientLight = static_cast<AmbientLight>(settings.m_RenderSettings.iVMR9ColorManagementAmbientLight);
- ColorRenderingIntent renderingIntent = static_cast<ColorRenderingIntent>(settings.m_RenderSettings.iVMR9ColorManagementIntent);
-
- bool bInitRequired = false;
-
- if (m_bColorManagement != bColorManagement) {
- bInitRequired = true;
- }
-
- if (m_bColorManagement && bColorManagement) {
- if ((m_InputVideoSystem != inputVideoSystem) ||
- (m_RenderingIntent != renderingIntent) ||
- (m_AmbientLight != ambientLight)) {
- bInitRequired = true;
- }
- }
-
- if (!m_bFinalPass) {
- bInitRequired = true;
- }
-
- if (!bInitRequired) {
- return S_OK;
- }
-
- // Check whether the final pass is supported by the hardware
- m_bFinalPass = data->m_bFP16Support;
- if (!m_bFinalPass) {
- return S_OK;
- }
-
- // Update the settings
- m_bColorManagement = bColorManagement;
- m_InputVideoSystem = inputVideoSystem;
- m_AmbientLight = ambientLight;
- m_RenderingIntent = renderingIntent;
-
- // Check whether the final pass is required
- m_bFinalPass = bColorManagement || m_bFullFloatingPointProcessing || m_bHalfFloatingPointProcessing || ((m_bForceInputHighColorResolution || m_bHighColorResolution) && (m_DisplayType != D3DFMT_A2R10G10B10));
-
- if (!m_bFinalPass) {
- return S_OK;
- }
-
- // Initial cleanup
- m_pLut3DTexture = NULL;
- m_pFinalPixelShader = NULL;
-
- if (!m_pDitherTexture) {
- // Create the dither texture
- hr = m_pD3DDev->CreateTexture(DITHER_MATRIX_SIZE, DITHER_MATRIX_SIZE,
- 1,
- D3DUSAGE_DYNAMIC,
- D3DFMT_A16B16G16R16F,
- D3DPOOL_DEFAULT,
- &m_pDitherTexture,
- NULL);
-
- if (FAILED(hr)) {
- CleanupFinalPass();
- return hr;
- }
-
- D3DLOCKED_RECT lockedRect;
- hr = m_pDitherTexture->LockRect(0, &lockedRect, NULL, D3DLOCK_DISCARD);
- if (FAILED(hr)) {
- CleanupFinalPass();
- return hr;
- }
-
- char* outputRowIterator = static_cast<char*>(lockedRect.pBits);
- for (int y = 0; y < DITHER_MATRIX_SIZE; y++) {
- unsigned short* outputIterator = reinterpret_cast<unsigned short*>(outputRowIterator);
- for (int x = 0; x < DITHER_MATRIX_SIZE; x++) {
- for (int i = 0; i < 4; i++) {
- *outputIterator++ = DITHER_MATRIX[y][x];
- }
- }
-
- outputRowIterator += lockedRect.Pitch;
- }
-
- hr = m_pDitherTexture->UnlockRect(0);
- if (FAILED(hr)) {
- CleanupFinalPass();
- return hr;
- }
- }
-
- // Initialize the color management if necessary
- if (bColorManagement) {
- // Get the ICC profile path
- TCHAR* iccProfilePath = 0;
- HDC hDC = GetDC(m_hWnd);
-
- if (hDC != NULL) {
- DWORD icmProfilePathSize = 0;
- GetICMProfile(hDC, &icmProfilePathSize, NULL);
- iccProfilePath = DNew TCHAR[icmProfilePathSize];
- if (!GetICMProfile(hDC, &icmProfilePathSize, iccProfilePath)) {
- delete[] iccProfilePath;
- iccProfilePath = 0;
- }
-
- ReleaseDC(m_hWnd, hDC);
- }
-
- // Create the 3D LUT texture
- m_Lut3DSize = 64; // 64x64x64 LUT is enough for high-quality color management
- m_Lut3DEntryCount = m_Lut3DSize * m_Lut3DSize * m_Lut3DSize;
-
- hr = m_pD3DDev->CreateVolumeTexture(m_Lut3DSize, m_Lut3DSize, m_Lut3DSize,
- 1,
- D3DUSAGE_DYNAMIC,
- D3DFMT_A16B16G16R16F,
- D3DPOOL_DEFAULT,
- &m_pLut3DTexture,
- NULL);
-
- if (FAILED(hr)) {
- delete[] iccProfilePath;
- CleanupFinalPass();
- return hr;
- }
-
- float* lut3DFloat32 = DNew float[m_Lut3DEntryCount * 3];
- hr = CreateIccProfileLut(iccProfilePath, lut3DFloat32);
- delete[] iccProfilePath;
- if (FAILED(hr)) {
- delete[] lut3DFloat32;
- CleanupFinalPass();
- return hr;
- }
-
- D3DXFLOAT16* lut3DFloat16 = DNew D3DXFLOAT16[m_Lut3DEntryCount * 3];
- m_pD3DXFloat32To16Array(lut3DFloat16, lut3DFloat32, m_Lut3DEntryCount * 3);
- delete[] lut3DFloat32;
-
- const float oneFloat32 = 1.0f;
- D3DXFLOAT16 oneFloat16;
- m_pD3DXFloat32To16Array(&oneFloat16, &oneFloat32, 1);
-
- D3DLOCKED_BOX lockedBox;
- hr = m_pLut3DTexture->LockBox(0, &lockedBox, NULL, D3DLOCK_DISCARD);
- if (FAILED(hr)) {
- delete[] lut3DFloat16;
- CleanupFinalPass();
- return hr;
- }
-
- D3DXFLOAT16* lut3DFloat16Iterator = lut3DFloat16;
- char* outputSliceIterator = static_cast<char*>(lockedBox.pBits);
- for (int b = 0; b < m_Lut3DSize; b++) {
- char* outputRowIterator = outputSliceIterator;
-
- for (int g = 0; g < m_Lut3DSize; g++) {
- D3DXFLOAT16* outputIterator = reinterpret_cast<D3DXFLOAT16*>(outputRowIterator);
-
- for (int r = 0; r < m_Lut3DSize; r++) {
- // R, G, B
- for (int i = 0; i < 3; i++) {
- *outputIterator++ = *lut3DFloat16Iterator++;
- }
-
- // A
- *outputIterator++ = oneFloat16;
- }
-
- outputRowIterator += lockedBox.RowPitch;
- }
-
- outputSliceIterator += lockedBox.SlicePitch;
- }
-
- hr = m_pLut3DTexture->UnlockBox(0);
- delete[] lut3DFloat16;
- if (FAILED(hr)) {
- CleanupFinalPass();
- return hr;
- }
- }
-
- // Compile the final pixel shader
- LPCSTR pProfile = m_Caps.PixelShaderVersion >= D3DPS_VERSION(3, 0) ? "ps_3_0" : "ps_2_0";
-
- CStringA shaderSourceCode;
- if (!LoadResource(IDF_SHADER_FINAL, shaderSourceCode, _T("FILE"))) {
- CleanupFinalPass();
- return E_FAIL;
- }
-
- int quantization;
- if (m_DisplayType == D3DFMT_A2R10G10B10) {
- quantization = 1023; // 10-bit
- } else {
- quantization = 255; // 8-bit
- }
-
- CStringA quantizationString;
- quantizationString.Format("%d.", quantization);
- shaderSourceCode.Replace("_QUANTIZATION_VALUE_", quantizationString);
-
- CStringA lut3DEnabledString;
- lut3DEnabledString.Format("%d", static_cast<int>(bColorManagement));
- shaderSourceCode.Replace("_LUT3D_ENABLED_VALUE_", lut3DEnabledString);
-
- if (bColorManagement) {
- CStringA lut3DSizeString;
- lut3DSizeString.Format("%d.", m_Lut3DSize);
- shaderSourceCode.Replace("_LUT3D_SIZE_VALUE_", lut3DSizeString);
- }
-
- CString ErrorMessage;
- CString DissAssembly;
- hr = m_pPSC->CompileShader(shaderSourceCode, "main", pProfile, 0, &m_pFinalPixelShader, &DissAssembly, &ErrorMessage);
- if (FAILED(hr)) {
- TRACE("%ws", ErrorMessage.GetString());
- ASSERT (0);
- CleanupFinalPass();
- return hr;
- }
-
- return S_OK;
+ HRESULT hr;
+
+ CRenderersSettings& settings = GetRenderersSettings();
+ CRenderersData* data = GetRenderersData();
+
+ // Check whether the final pass must be initialized
+ bool bColorManagement = settings.m_RenderSettings.iVMR9ColorManagementEnable;
+ VideoSystem inputVideoSystem = static_cast<VideoSystem>(settings.m_RenderSettings.iVMR9ColorManagementInput);
+ AmbientLight ambientLight = static_cast<AmbientLight>(settings.m_RenderSettings.iVMR9ColorManagementAmbientLight);
+ ColorRenderingIntent renderingIntent = static_cast<ColorRenderingIntent>(settings.m_RenderSettings.iVMR9ColorManagementIntent);
+
+ bool bInitRequired = false;
+
+ if (m_bColorManagement != bColorManagement) {
+ bInitRequired = true;
+ }
+
+ if (m_bColorManagement && bColorManagement) {
+ if ((m_InputVideoSystem != inputVideoSystem) ||
+ (m_RenderingIntent != renderingIntent) ||
+ (m_AmbientLight != ambientLight)) {
+ bInitRequired = true;
+ }
+ }
+
+ if (!m_bFinalPass) {
+ bInitRequired = true;
+ }
+
+ if (!bInitRequired) {
+ return S_OK;
+ }
+
+ // Check whether the final pass is supported by the hardware
+ m_bFinalPass = data->m_bFP16Support;
+ if (!m_bFinalPass) {
+ return S_OK;
+ }
+
+ // Update the settings
+ m_bColorManagement = bColorManagement;
+ m_InputVideoSystem = inputVideoSystem;
+ m_AmbientLight = ambientLight;
+ m_RenderingIntent = renderingIntent;
+
+ // Check whether the final pass is required
+ m_bFinalPass = bColorManagement || m_bFullFloatingPointProcessing || m_bHalfFloatingPointProcessing || ((m_bForceInputHighColorResolution || m_bHighColorResolution) && (m_DisplayType != D3DFMT_A2R10G10B10));
+
+ if (!m_bFinalPass) {
+ return S_OK;
+ }
+
+ // Initial cleanup
+ m_pLut3DTexture = NULL;
+ m_pFinalPixelShader = NULL;
+
+ if (!m_pDitherTexture) {
+ // Create the dither texture
+ hr = m_pD3DDev->CreateTexture(DITHER_MATRIX_SIZE, DITHER_MATRIX_SIZE,
+ 1,
+ D3DUSAGE_DYNAMIC,
+ D3DFMT_A16B16G16R16F,
+ D3DPOOL_DEFAULT,
+ &m_pDitherTexture,
+ NULL);
+
+ if (FAILED(hr)) {
+ CleanupFinalPass();
+ return hr;
+ }
+
+ D3DLOCKED_RECT lockedRect;
+ hr = m_pDitherTexture->LockRect(0, &lockedRect, NULL, D3DLOCK_DISCARD);
+ if (FAILED(hr)) {
+ CleanupFinalPass();
+ return hr;
+ }
+
+ char* outputRowIterator = static_cast<char*>(lockedRect.pBits);
+ for (int y = 0; y < DITHER_MATRIX_SIZE; y++) {
+ unsigned short* outputIterator = reinterpret_cast<unsigned short*>(outputRowIterator);
+ for (int x = 0; x < DITHER_MATRIX_SIZE; x++) {
+ for (int i = 0; i < 4; i++) {
+ *outputIterator++ = DITHER_MATRIX[y][x];
+ }
+ }
+
+ outputRowIterator += lockedRect.Pitch;
+ }
+
+ hr = m_pDitherTexture->UnlockRect(0);
+ if (FAILED(hr)) {
+ CleanupFinalPass();
+ return hr;
+ }
+ }
+
+ // Initialize the color management if necessary
+ if (bColorManagement) {
+ // Get the ICC profile path
+ TCHAR* iccProfilePath = 0;
+ HDC hDC = GetDC(m_hWnd);
+
+ if (hDC != NULL) {
+ DWORD icmProfilePathSize = 0;
+ GetICMProfile(hDC, &icmProfilePathSize, NULL);
+ iccProfilePath = DNew TCHAR[icmProfilePathSize];
+ if (!GetICMProfile(hDC, &icmProfilePathSize, iccProfilePath)) {
+ delete[] iccProfilePath;
+ iccProfilePath = 0;
+ }
+
+ ReleaseDC(m_hWnd, hDC);
+ }
+
+ // Create the 3D LUT texture
+ m_Lut3DSize = 64; // 64x64x64 LUT is enough for high-quality color management
+ m_Lut3DEntryCount = m_Lut3DSize * m_Lut3DSize * m_Lut3DSize;
+
+ hr = m_pD3DDev->CreateVolumeTexture(m_Lut3DSize, m_Lut3DSize, m_Lut3DSize,
+ 1,
+ D3DUSAGE_DYNAMIC,
+ D3DFMT_A16B16G16R16F,
+ D3DPOOL_DEFAULT,
+ &m_pLut3DTexture,
+ NULL);
+
+ if (FAILED(hr)) {
+ delete[] iccProfilePath;
+ CleanupFinalPass();
+ return hr;
+ }
+
+ float* lut3DFloat32 = DNew float[m_Lut3DEntryCount * 3];
+ hr = CreateIccProfileLut(iccProfilePath, lut3DFloat32);
+ delete[] iccProfilePath;
+ if (FAILED(hr)) {
+ delete[] lut3DFloat32;
+ CleanupFinalPass();
+ return hr;
+ }
+
+ D3DXFLOAT16* lut3DFloat16 = DNew D3DXFLOAT16[m_Lut3DEntryCount * 3];
+ m_pD3DXFloat32To16Array(lut3DFloat16, lut3DFloat32, m_Lut3DEntryCount * 3);
+ delete[] lut3DFloat32;
+
+ const float oneFloat32 = 1.0f;
+ D3DXFLOAT16 oneFloat16;
+ m_pD3DXFloat32To16Array(&oneFloat16, &oneFloat32, 1);
+
+ D3DLOCKED_BOX lockedBox;
+ hr = m_pLut3DTexture->LockBox(0, &lockedBox, NULL, D3DLOCK_DISCARD);
+ if (FAILED(hr)) {
+ delete[] lut3DFloat16;
+ CleanupFinalPass();
+ return hr;
+ }
+
+ D3DXFLOAT16* lut3DFloat16Iterator = lut3DFloat16;
+ char* outputSliceIterator = static_cast<char*>(lockedBox.pBits);
+ for (int b = 0; b < m_Lut3DSize; b++) {
+ char* outputRowIterator = outputSliceIterator;
+
+ for (int g = 0; g < m_Lut3DSize; g++) {
+ D3DXFLOAT16* outputIterator = reinterpret_cast<D3DXFLOAT16*>(outputRowIterator);
+
+ for (int r = 0; r < m_Lut3DSize; r++) {
+ // R, G, B
+ for (int i = 0; i < 3; i++) {
+ *outputIterator++ = *lut3DFloat16Iterator++;
+ }
+
+ // A
+ *outputIterator++ = oneFloat16;
+ }
+
+ outputRowIterator += lockedBox.RowPitch;
+ }
+
+ outputSliceIterator += lockedBox.SlicePitch;
+ }
+
+ hr = m_pLut3DTexture->UnlockBox(0);
+ delete[] lut3DFloat16;
+ if (FAILED(hr)) {
+ CleanupFinalPass();
+ return hr;
+ }
+ }
+
+ // Compile the final pixel shader
+ LPCSTR pProfile = m_Caps.PixelShaderVersion >= D3DPS_VERSION(3, 0) ? "ps_3_0" : "ps_2_0";
+
+ CStringA shaderSourceCode;
+ if (!LoadResource(IDF_SHADER_FINAL, shaderSourceCode, _T("FILE"))) {
+ CleanupFinalPass();
+ return E_FAIL;
+ }
+
+ int quantization;
+ if (m_DisplayType == D3DFMT_A2R10G10B10) {
+ quantization = 1023; // 10-bit
+ } else {
+ quantization = 255; // 8-bit
+ }
+
+ CStringA quantizationString;
+ quantizationString.Format("%d.", quantization);
+ shaderSourceCode.Replace("_QUANTIZATION_VALUE_", quantizationString);
+
+ CStringA lut3DEnabledString;
+ lut3DEnabledString.Format("%d", static_cast<int>(bColorManagement));
+ shaderSourceCode.Replace("_LUT3D_ENABLED_VALUE_", lut3DEnabledString);
+
+ if (bColorManagement) {
+ CStringA lut3DSizeString;
+ lut3DSizeString.Format("%d.", m_Lut3DSize);
+ shaderSourceCode.Replace("_LUT3D_SIZE_VALUE_", lut3DSizeString);
+ }
+
+ CString ErrorMessage;
+ CString DissAssembly;
+ hr = m_pPSC->CompileShader(shaderSourceCode, "main", pProfile, 0, &m_pFinalPixelShader, &DissAssembly, &ErrorMessage);
+ if (FAILED(hr)) {
+ TRACE("%ws", ErrorMessage.GetString());
+ ASSERT(0);
+ CleanupFinalPass();
+ return hr;
+ }
+
+ return S_OK;
}
void CDX9RenderingEngine::CleanupFinalPass()
{
- m_bFinalPass = false;
- m_pDitherTexture = NULL;
- m_pLut3DTexture = NULL;
- m_pFinalPixelShader = NULL;
+ m_bFinalPass = false;
+ m_pDitherTexture = NULL;
+ m_pLut3DTexture = NULL;
+ m_pFinalPixelShader = NULL;
}
HRESULT CDX9RenderingEngine::CreateIccProfileLut(TCHAR* profilePath, float* lut3D)
{
- // Get the input video system
- VideoSystem videoSystem;
-
- if (m_InputVideoSystem == VIDEO_SYSTEM_UNKNOWN) {
- static const int ntscSizes[][2] = {{720, 480}, {720, 486}, {704, 480}};
- static const int palSizes[][2] = {{720, 576}, {704, 576}};
-
- videoSystem = VIDEO_SYSTEM_HDTV; // default
-
- for (int i = 0; i < _countof(ntscSizes); i++) {
- if (m_NativeVideoSize.cx == ntscSizes[i][0] && m_NativeVideoSize.cy == ntscSizes[i][1]) {
- videoSystem = VIDEO_SYSTEM_SDTV_NTSC;
- }
- }
-
- for (int i = 0; i < _countof(palSizes); i++) {
- if (m_NativeVideoSize.cx == palSizes[i][0] && m_NativeVideoSize.cy == palSizes[i][1]) {
- videoSystem = VIDEO_SYSTEM_SDTV_PAL;
- }
- }
- } else {
- videoSystem = m_InputVideoSystem;
- }
-
- // Get the gamma
- double gamma;
-
- switch (m_AmbientLight) {
- case AMBIENT_LIGHT_BRIGHT:
- gamma = 2.2;
- break;
-
- case AMBIENT_LIGHT_DIM:
- gamma = 2.35;
- break;
-
- case AMBIENT_LIGHT_DARK:
- gamma = 2.4;
- break;
-
- default:
- return E_FAIL;
- }
-
- // Get the rendering intent
- cmsUInt32Number intent;
-
- switch (m_RenderingIntent) {
- case COLOR_RENDERING_INTENT_PERCEPTUAL:
- intent = INTENT_PERCEPTUAL;
- break;
-
- case COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC:
- intent = INTENT_RELATIVE_COLORIMETRIC;
- break;
-
- case COLOR_RENDERING_INTENT_SATURATION:
- intent = INTENT_SATURATION;
- break;
-
- case COLOR_RENDERING_INTENT_ABSOLUTE_COLORIMETRIC:
- intent = INTENT_ABSOLUTE_COLORIMETRIC;
- break;
-
- default:
- return E_FAIL;
- }
-
- // Set the input white point. It's D65 in all cases.
- cmsCIExyY whitePoint;
-
- whitePoint.x = 0.312713;
- whitePoint.y = 0.329016;
- whitePoint.Y = 1.0;
-
- // Set the input primaries
- cmsCIExyYTRIPLE primaries;
-
- switch (videoSystem) {
- case VIDEO_SYSTEM_HDTV:
- // Rec. 709
- primaries.Red.x = 0.64;
- primaries.Red.y = 0.33;
- primaries.Green.x = 0.30;
- primaries.Green.y = 0.60;
- primaries.Blue.x = 0.15;
- primaries.Blue.y = 0.06;
- break;
-
- case VIDEO_SYSTEM_SDTV_NTSC:
- // SMPTE-C
- primaries.Red.x = 0.630;
- primaries.Red.y = 0.340;
- primaries.Green.x = 0.310;
- primaries.Green.y = 0.595;
- primaries.Blue.x = 0.155;
- primaries.Blue.y = 0.070;
- break;
-
- case VIDEO_SYSTEM_SDTV_PAL:
- // PAL/SECAM
- primaries.Red.x = 0.64;
- primaries.Red.y = 0.33;
- primaries.Green.x = 0.29;
- primaries.Green.y = 0.60;
- primaries.Blue.x = 0.15;
- primaries.Blue.y = 0.06;
- break;
-
- default:
- return E_FAIL;
- }
-
- primaries.Red.Y = 1.0;
- primaries.Green.Y = 1.0;
- primaries.Blue.Y = 1.0;
-
- // Set the input gamma, which is the gamma of a reference studio display we want to simulate
- // For more information, see the paper at http://www.poynton.com/notes/PU-PR-IS/Poynton-PU-PR-IS.pdf
- cmsToneCurve* transferFunction = cmsBuildGamma(0, gamma);
-
- cmsToneCurve* transferFunctionRGB[3];
- for (int i = 0; i < 3; i++) {
- transferFunctionRGB[i] = transferFunction;
- }
-
- // Create the input profile
- cmsHPROFILE hInputProfile = cmsCreateRGBProfile(&whitePoint, &primaries, transferFunctionRGB);
- cmsFreeToneCurve(transferFunction);
-
- if (hInputProfile == NULL) {
- return E_FAIL;
- }
-
- // Open the output profile
- cmsHPROFILE hOutputProfile;
- FILE* outputProfileStream;
-
- if (profilePath != 0) {
- if (_wfopen_s(&outputProfileStream, T2W(profilePath), L"rb") != 0) {
- cmsCloseProfile(hInputProfile);
- return E_FAIL;
- }
-
- hOutputProfile = cmsOpenProfileFromStream(outputProfileStream, "r");
- } else {
- hOutputProfile = cmsCreate_sRGBProfile();
- }
-
- if (hOutputProfile == NULL) {
- if (profilePath != 0) {
- fclose(outputProfileStream);
- }
-
- cmsCloseProfile(hInputProfile);
- return E_FAIL;
- }
-
- // Create the transform
- cmsHTRANSFORM hTransform = cmsCreateTransform(hInputProfile, TYPE_RGB_16, hOutputProfile, TYPE_RGB_16, intent, cmsFLAGS_HIGHRESPRECALC);
-
- cmsCloseProfile(hOutputProfile);
-
- if (profilePath != 0) {
- fclose(outputProfileStream);
- }
-
- cmsCloseProfile(hInputProfile);
-
- if (hTransform == NULL) {
- return E_FAIL;
- }
-
- // Create the 3D LUT input
- unsigned short* lut3DOutput = DNew unsigned short[m_Lut3DEntryCount * 3];
- unsigned short* lut3DInput = DNew unsigned short[m_Lut3DEntryCount * 3];
-
- unsigned short* lut3DInputIterator = lut3DInput;
-
- for (int b = 0; b < m_Lut3DSize; b++) {
- for (int g = 0; g < m_Lut3DSize; g++) {
- for (int r = 0; r < m_Lut3DSize; r++) {
- *lut3DInputIterator++ = r * 65535 / (m_Lut3DSize - 1);
- *lut3DInputIterator++ = g * 65535 / (m_Lut3DSize - 1);
- *lut3DInputIterator++ = b * 65535 / (m_Lut3DSize - 1);
- }
- }
- }
-
- // Do the transform
- cmsDoTransform(hTransform, lut3DInput, lut3DOutput, m_Lut3DEntryCount);
-
- // Convert the output to floating point
- for (int i = 0; i < m_Lut3DEntryCount * 3; i++) {
- lut3D[i] = static_cast<float>(lut3DOutput[i]) * (1.0f / 65535.0f);
- }
-
- // Cleanup
- delete[] lut3DOutput;
- delete[] lut3DInput;
- cmsDeleteTransform(hTransform);
-
- return S_OK;
+ // Get the input video system
+ VideoSystem videoSystem;
+
+ if (m_InputVideoSystem == VIDEO_SYSTEM_UNKNOWN) {
+ static const int ntscSizes[][2] = {{720, 480}, {720, 486}, {704, 480}};
+ static const int palSizes[][2] = {{720, 576}, {704, 576}};
+
+ videoSystem = VIDEO_SYSTEM_HDTV; // default
+
+ for (int i = 0; i < _countof(ntscSizes); i++) {
+ if (m_NativeVideoSize.cx == ntscSizes[i][0] && m_NativeVideoSize.cy == ntscSizes[i][1]) {
+ videoSystem = VIDEO_SYSTEM_SDTV_NTSC;
+ }
+ }
+
+ for (int i = 0; i < _countof(palSizes); i++) {
+ if (m_NativeVideoSize.cx == palSizes[i][0] && m_NativeVideoSize.cy == palSizes[i][1]) {
+ videoSystem = VIDEO_SYSTEM_SDTV_PAL;
+ }
+ }
+ } else {
+ videoSystem = m_InputVideoSystem;
+ }
+
+ // Get the gamma
+ double gamma;
+
+ switch (m_AmbientLight) {
+ case AMBIENT_LIGHT_BRIGHT:
+ gamma = 2.2;
+ break;
+
+ case AMBIENT_LIGHT_DIM:
+ gamma = 2.35;
+ break;
+
+ case AMBIENT_LIGHT_DARK:
+ gamma = 2.4;
+ break;
+
+ default:
+ return E_FAIL;
+ }
+
+ // Get the rendering intent
+ cmsUInt32Number intent;
+
+ switch (m_RenderingIntent) {
+ case COLOR_RENDERING_INTENT_PERCEPTUAL:
+ intent = INTENT_PERCEPTUAL;
+ break;
+
+ case COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC:
+ intent = INTENT_RELATIVE_COLORIMETRIC;
+ break;
+
+ case COLOR_RENDERING_INTENT_SATURATION:
+ intent = INTENT_SATURATION;
+ break;
+
+ case COLOR_RENDERING_INTENT_ABSOLUTE_COLORIMETRIC:
+ intent = INTENT_ABSOLUTE_COLORIMETRIC;
+ break;
+
+ default:
+ return E_FAIL;
+ }
+
+ // Set the input white point. It's D65 in all cases.
+ cmsCIExyY whitePoint;
+
+ whitePoint.x = 0.312713;
+ whitePoint.y = 0.329016;
+ whitePoint.Y = 1.0;
+
+ // Set the input primaries
+ cmsCIExyYTRIPLE primaries;
+
+ switch (videoSystem) {
+ case VIDEO_SYSTEM_HDTV:
+ // Rec. 709
+ primaries.Red.x = 0.64;
+ primaries.Red.y = 0.33;
+ primaries.Green.x = 0.30;
+ primaries.Green.y = 0.60;
+ primaries.Blue.x = 0.15;
+ primaries.Blue.y = 0.06;
+ break;
+
+ case VIDEO_SYSTEM_SDTV_NTSC:
+ // SMPTE-C
+ primaries.Red.x = 0.630;
+ primaries.Red.y = 0.340;
+ primaries.Green.x = 0.310;
+ primaries.Green.y = 0.595;
+ primaries.Blue.x = 0.155;
+ primaries.Blue.y = 0.070;
+ break;
+
+ case VIDEO_SYSTEM_SDTV_PAL:
+ // PAL/SECAM
+ primaries.Red.x = 0.64;
+ primaries.Red.y = 0.33;
+ primaries.Green.x = 0.29;
+ primaries.Green.y = 0.60;
+ primaries.Blue.x = 0.15;
+ primaries.Blue.y = 0.06;
+ break;
+
+ default:
+ return E_FAIL;
+ }
+
+ primaries.Red.Y = 1.0;
+ primaries.Green.Y = 1.0;
+ primaries.Blue.Y = 1.0;
+
+ // Set the input gamma, which is the gamma of a reference studio display we want to simulate
+ // For more information, see the paper at http://www.poynton.com/notes/PU-PR-IS/Poynton-PU-PR-IS.pdf
+ cmsToneCurve* transferFunction = cmsBuildGamma(0, gamma);
+
+ cmsToneCurve* transferFunctionRGB[3];
+ for (int i = 0; i < 3; i++) {
+ transferFunctionRGB[i] = transferFunction;
+ }
+
+ // Create the input profile
+ cmsHPROFILE hInputProfile = cmsCreateRGBProfile(&whitePoint, &primaries, transferFunctionRGB);
+ cmsFreeToneCurve(transferFunction);
+
+ if (hInputProfile == NULL) {
+ return E_FAIL;
+ }
+
+ // Open the output profile
+ cmsHPROFILE hOutputProfile;
+ FILE* outputProfileStream;
+
+ if (profilePath != 0) {
+ if (_wfopen_s(&outputProfileStream, T2W(profilePath), L"rb") != 0) {
+ cmsCloseProfile(hInputProfile);
+ return E_FAIL;
+ }
+
+ hOutputProfile = cmsOpenProfileFromStream(outputProfileStream, "r");
+ } else {
+ hOutputProfile = cmsCreate_sRGBProfile();
+ }
+
+ if (hOutputProfile == NULL) {
+ if (profilePath != 0) {
+ fclose(outputProfileStream);
+ }
+
+ cmsCloseProfile(hInputProfile);
+ return E_FAIL;
+ }
+
+ // Create the transform
+ cmsHTRANSFORM hTransform = cmsCreateTransform(hInputProfile, TYPE_RGB_16, hOutputProfile, TYPE_RGB_16, intent, cmsFLAGS_HIGHRESPRECALC);
+
+ cmsCloseProfile(hOutputProfile);
+
+ if (profilePath != 0) {
+ fclose(outputProfileStream);
+ }
+
+ cmsCloseProfile(hInputProfile);
+
+ if (hTransform == NULL) {
+ return E_FAIL;
+ }
+
+ // Create the 3D LUT input
+ unsigned short* lut3DOutput = DNew unsigned short[m_Lut3DEntryCount * 3];
+ unsigned short* lut3DInput = DNew unsigned short[m_Lut3DEntryCount * 3];
+
+ unsigned short* lut3DInputIterator = lut3DInput;
+
+ for (int b = 0; b < m_Lut3DSize; b++) {
+ for (int g = 0; g < m_Lut3DSize; g++) {
+ for (int r = 0; r < m_Lut3DSize; r++) {
+ *lut3DInputIterator++ = r * 65535 / (m_Lut3DSize - 1);
+ *lut3DInputIterator++ = g * 65535 / (m_Lut3DSize - 1);
+ *lut3DInputIterator++ = b * 65535 / (m_Lut3DSize - 1);
+ }
+ }
+ }
+
+ // Do the transform
+ cmsDoTransform(hTransform, lut3DInput, lut3DOutput, m_Lut3DEntryCount);
+
+ // Convert the output to floating point
+ for (int i = 0; i < m_Lut3DEntryCount * 3; i++) {
+ lut3D[i] = static_cast<float>(lut3DOutput[i]) * (1.0f / 65535.0f);
+ }
+
+ // Cleanup
+ delete[] lut3DOutput;
+ delete[] lut3DInput;
+ cmsDeleteTransform(hTransform);
+
+ return S_OK;
}
HRESULT CDX9RenderingEngine::FinalPass(IDirect3DTexture9* pTexture)
{
- HRESULT hr;
+ HRESULT hr;
- D3DSURFACE_DESC desc;
- if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
- return E_FAIL;
- }
+ D3DSURFACE_DESC desc;
+ if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
+ return E_FAIL;
+ }
- float w = (float)desc.Width;
- float h = (float)desc.Height;
+ float w = (float)desc.Width;
+ float h = (float)desc.Height;
- MYD3DVERTEX<1> v[] = {
- {0, 0, 0.5f, 2.0f, 0, 0},
- {w, 0, 0.5f, 2.0f, 1, 0},
- {0, h, 0.5f, 2.0f, 0, 1},
- {w, h, 0.5f, 2.0f, 1, 1},
- };
+ MYD3DVERTEX<1> v[] = {
+ {0, 0, 0.5f, 2.0f, 0, 0},
+ {w, 0, 0.5f, 2.0f, 1, 0},
+ {0, h, 0.5f, 2.0f, 0, 1},
+ {w, h, 0.5f, 2.0f, 1, 1},
+ };
- for (int i = 0; i < _countof(v); i++) {
- v[i].x -= 0.5;
- v[i].y -= 0.5;
- }
+ for (int i = 0; i < _countof(v); i++) {
+ v[i].x -= 0.5;
+ v[i].y -= 0.5;
+ }
- hr = m_pD3DDev->SetPixelShader(m_pFinalPixelShader);
+ hr = m_pD3DDev->SetPixelShader(m_pFinalPixelShader);
- // Set sampler: image
- hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
- hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
- hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
+ // Set sampler: image
+ hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
+ hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
+ hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
- hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
- hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
+ hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
+ hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
- hr = m_pD3DDev->SetTexture(0, pTexture);
+ hr = m_pD3DDev->SetTexture(0, pTexture);
- // Set sampler: ditherMap
- hr = m_pD3DDev->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
- hr = m_pD3DDev->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_POINT);
- hr = m_pD3DDev->SetSamplerState(1, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
+ // Set sampler: ditherMap
+ hr = m_pD3DDev->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
+ hr = m_pD3DDev->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_POINT);
+ hr = m_pD3DDev->SetSamplerState(1, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
- hr = m_pD3DDev->SetSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
- hr = m_pD3DDev->SetSamplerState(1, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
+ hr = m_pD3DDev->SetSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
+ hr = m_pD3DDev->SetSamplerState(1, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
- hr = m_pD3DDev->SetTexture(1, m_pDitherTexture);
+ hr = m_pD3DDev->SetTexture(1, m_pDitherTexture);
- if (m_bColorManagement) {
- hr = m_pD3DDev->SetSamplerState(2, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
- hr = m_pD3DDev->SetSamplerState(2, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
- hr = m_pD3DDev->SetSamplerState(2, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
+ if (m_bColorManagement) {
+ hr = m_pD3DDev->SetSamplerState(2, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
+ hr = m_pD3DDev->SetSamplerState(2, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
+ hr = m_pD3DDev->SetSamplerState(2, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
- hr = m_pD3DDev->SetSamplerState(2, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
- hr = m_pD3DDev->SetSamplerState(2, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
- hr = m_pD3DDev->SetSamplerState(2, D3DSAMP_ADDRESSW, D3DTADDRESS_CLAMP);
+ hr = m_pD3DDev->SetSamplerState(2, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
+ hr = m_pD3DDev->SetSamplerState(2, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
+ hr = m_pD3DDev->SetSamplerState(2, D3DSAMP_ADDRESSW, D3DTADDRESS_CLAMP);
- hr = m_pD3DDev->SetTexture(2, m_pLut3DTexture);
- }
+ hr = m_pD3DDev->SetTexture(2, m_pLut3DTexture);
+ }
- // Set constants
- float fConstData[][4] = {{(float)w / DITHER_MATRIX_SIZE, (float)h / DITHER_MATRIX_SIZE, 0, 0}};
- hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, _countof(fConstData));
+ // Set constants
+ float fConstData[][4] = {{(float)w / DITHER_MATRIX_SIZE, (float)h / DITHER_MATRIX_SIZE, 0, 0}};
+ hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, _countof(fConstData));
- hr = TextureBlt(m_pD3DDev, v, D3DTEXF_POINT);
+ hr = TextureBlt(m_pD3DDev, v, D3DTEXF_POINT);
- hr = m_pD3DDev->SetTexture(1, NULL);
+ hr = m_pD3DDev->SetTexture(1, NULL);
- if (m_bColorManagement) {
- hr = m_pD3DDev->SetTexture(2, NULL);
- }
+ if (m_bColorManagement) {
+ hr = m_pD3DDev->SetTexture(2, NULL);
+ }
- return hr;
+ return hr;
}
HRESULT CDX9RenderingEngine::TextureCopy(IDirect3DTexture9* pTexture)
{
- HRESULT hr;
+ HRESULT hr;
- D3DSURFACE_DESC desc;
- if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
- return E_FAIL;
- }
+ D3DSURFACE_DESC desc;
+ if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
+ return E_FAIL;
+ }
- float w = (float)desc.Width;
- float h = (float)desc.Height;
+ float w = (float)desc.Width;
+ float h = (float)desc.Height;
- MYD3DVERTEX<1> v[] = {
- {0, 0, 0.5f, 2.0f, 0, 0},
- {w, 0, 0.5f, 2.0f, 1, 0},
- {0, h, 0.5f, 2.0f, 0, 1},
- {w, h, 0.5f, 2.0f, 1, 1},
- };
+ MYD3DVERTEX<1> v[] = {
+ {0, 0, 0.5f, 2.0f, 0, 0},
+ {w, 0, 0.5f, 2.0f, 1, 0},
+ {0, h, 0.5f, 2.0f, 0, 1},
+ {w, h, 0.5f, 2.0f, 1, 1},
+ };
- for (int i = 0; i < _countof(v); i++) {
- v[i].x -= 0.5;
- v[i].y -= 0.5;
- }
+ for (int i = 0; i < _countof(v); i++) {
+ v[i].x -= 0.5;
+ v[i].y -= 0.5;
+ }
- hr = m_pD3DDev->SetTexture(0, pTexture);
+ hr = m_pD3DDev->SetTexture(0, pTexture);
- return TextureBlt(m_pD3DDev, v, D3DTEXF_POINT);
+ return TextureBlt(m_pD3DDev, v, D3DTEXF_POINT);
}
bool CDX9RenderingEngine::ClipToSurface(IDirect3DSurface9* pSurface, CRect& s, CRect& d)
{
- D3DSURFACE_DESC d3dsd;
- ZeroMemory(&d3dsd, sizeof(d3dsd));
- if (FAILED(pSurface->GetDesc(&d3dsd))) {
- return false;
- }
-
- int w = d3dsd.Width, h = d3dsd.Height;
- int sw = s.Width(), sh = s.Height();
- int dw = d.Width(), dh = d.Height();
-
- if (d.left >= w || d.right < 0 || d.top >= h || d.bottom < 0
- || sw <= 0 || sh <= 0 || dw <= 0 || dh <= 0) {
- s.SetRectEmpty();
- d.SetRectEmpty();
- return true;
- }
-
- if (d.right > w) {
- s.right -= (d.right-w)*sw/dw;
- d.right = w;
- }
- if (d.bottom > h) {
- s.bottom -= (d.bottom-h)*sh/dh;
- d.bottom = h;
- }
- if (d.left < 0) {
- s.left += (0-d.left)*sw/dw;
- d.left = 0;
- }
- if (d.top < 0) {
- s.top += (0-d.top)*sh/dh;
- d.top = 0;
- }
-
- return true;
+ D3DSURFACE_DESC d3dsd;
+ ZeroMemory(&d3dsd, sizeof(d3dsd));
+ if (FAILED(pSurface->GetDesc(&d3dsd))) {
+ return false;
+ }
+
+ int w = d3dsd.Width, h = d3dsd.Height;
+ int sw = s.Width(), sh = s.Height();
+ int dw = d.Width(), dh = d.Height();
+
+ if (d.left >= w || d.right < 0 || d.top >= h || d.bottom < 0
+ || sw <= 0 || sh <= 0 || dw <= 0 || dh <= 0) {
+ s.SetRectEmpty();
+ d.SetRectEmpty();
+ return true;
+ }
+
+ if (d.right > w) {
+ s.right -= (d.right - w) * sw / dw;
+ d.right = w;
+ }
+ if (d.bottom > h) {
+ s.bottom -= (d.bottom - h) * sh / dh;
+ d.bottom = h;
+ }
+ if (d.left < 0) {
+ s.left += (0 - d.left) * sw / dw;
+ d.left = 0;
+ }
+ if (d.top < 0) {
+ s.top += (0 - d.top) * sh / dh;
+ d.top = 0;
+ }
+
+ return true;
}
-HRESULT CDX9RenderingEngine::DrawRect(DWORD _Color, DWORD _Alpha, const CRect &_Rect)
+HRESULT CDX9RenderingEngine::DrawRect(DWORD _Color, DWORD _Alpha, const CRect& _Rect)
{
- if (!m_pD3DDev) {
- return E_POINTER;
- }
-
- DWORD Color = D3DCOLOR_ARGB(_Alpha, GetRValue(_Color), GetGValue(_Color), GetBValue(_Color));
- MYD3DVERTEX<0> v[] = {
- {float(_Rect.left), float(_Rect.top), 0.5f, 2.0f, Color},
- {float(_Rect.right), float(_Rect.top), 0.5f, 2.0f, Color},
- {float(_Rect.left), float(_Rect.bottom), 0.5f, 2.0f, Color},
- {float(_Rect.right), float(_Rect.bottom), 0.5f, 2.0f, Color},
- };
-
- for (int i = 0; i < _countof(v); i++) {
- v[i].x -= 0.5;
- v[i].y -= 0.5;
- }
-
- HRESULT hr = m_pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
- hr = m_pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
- hr = m_pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
- hr = m_pD3DDev->SetRenderState(D3DRS_STENCILENABLE, FALSE);
- hr = m_pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- hr = m_pD3DDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- hr = m_pD3DDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
- //D3DRS_COLORVERTEX
- hr = m_pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
- hr = m_pD3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
-
-
- hr = m_pD3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED);
-
- hr = m_pD3DDev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX0 | D3DFVF_DIFFUSE);
- // hr = m_pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, v, sizeof(v[0]));
-
- MYD3DVERTEX<0> tmp = v[2];
- v[2] = v[3];
- v[3] = tmp;
- hr = m_pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
-
- return S_OK;
+ if (!m_pD3DDev) {
+ return E_POINTER;
+ }
+
+ DWORD Color = D3DCOLOR_ARGB(_Alpha, GetRValue(_Color), GetGValue(_Color), GetBValue(_Color));
+ MYD3DVERTEX<0> v[] = {
+ {float(_Rect.left), float(_Rect.top), 0.5f, 2.0f, Color},
+ {float(_Rect.right), float(_Rect.top), 0.5f, 2.0f, Color},
+ {float(_Rect.left), float(_Rect.bottom), 0.5f, 2.0f, Color},
+ {float(_Rect.right), float(_Rect.bottom), 0.5f, 2.0f, Color},
+ };
+
+ for (int i = 0; i < _countof(v); i++) {
+ v[i].x -= 0.5;
+ v[i].y -= 0.5;
+ }
+
+ HRESULT hr = m_pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
+ hr = m_pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
+ hr = m_pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
+ hr = m_pD3DDev->SetRenderState(D3DRS_STENCILENABLE, FALSE);
+ hr = m_pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ hr = m_pD3DDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
+ hr = m_pD3DDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
+ //D3DRS_COLORVERTEX
+ hr = m_pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
+ hr = m_pD3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
+
+
+ hr = m_pD3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED);
+
+ hr = m_pD3DDev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX0 | D3DFVF_DIFFUSE);
+ // hr = m_pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, v, sizeof(v[0]));
+
+ MYD3DVERTEX<0> tmp = v[2];
+ v[2] = v[3];
+ v[3] = tmp;
+ hr = m_pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
+
+ return S_OK;
}
HRESULT CDX9RenderingEngine::AlphaBlt(RECT* pSrc, RECT* pDst, IDirect3DTexture9* pTexture)
{
- if (!pSrc || !pDst) {
- return E_POINTER;
- }
-
- CRect src(*pSrc), dst(*pDst);
-
- HRESULT hr;
-
- D3DSURFACE_DESC d3dsd;
- ZeroMemory(&d3dsd, sizeof(d3dsd));
- if (FAILED(pTexture->GetLevelDesc(0, &d3dsd)) /*|| d3dsd.Type != D3DRTYPE_TEXTURE*/) {
- return E_FAIL;
- }
-
- float w = (float)d3dsd.Width;
- float h = (float)d3dsd.Height;
-
- struct {
- float x, y, z, rhw;
- float tu, tv;
- }
- pVertices[] = {
- {(float)dst.left, (float)dst.top, 0.5f, 2.0f, (float)src.left / w, (float)src.top / h},
- {(float)dst.right, (float)dst.top, 0.5f, 2.0f, (float)src.right / w, (float)src.top / h},
- {(float)dst.left, (float)dst.bottom, 0.5f, 2.0f, (float)src.left / w, (float)src.bottom / h},
- {(float)dst.right, (float)dst.bottom, 0.5f, 2.0f, (float)src.right / w, (float)src.bottom / h},
- };
-
- for (int i = 0; i < _countof(pVertices); i++) {
- pVertices[i].x -= 0.5;
- pVertices[i].y -= 0.5;
- }
-
- hr = m_pD3DDev->SetTexture(0, pTexture);
-
- // GetRenderState fails for devices created with D3DCREATE_PUREDEVICE
- // so we need to provide default values in case GetRenderState fails
- DWORD abe, sb, db;
- if (FAILED(m_pD3DDev->GetRenderState(D3DRS_ALPHABLENDENABLE, &abe)))
- abe = FALSE;
- if (FAILED(m_pD3DDev->GetRenderState(D3DRS_SRCBLEND, &sb)))
- sb = D3DBLEND_ONE;
- if (FAILED(m_pD3DDev->GetRenderState(D3DRS_DESTBLEND, &db)))
- db = D3DBLEND_ZERO;
-
- hr = m_pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
- hr = m_pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
- hr = m_pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
- hr = m_pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- hr = m_pD3DDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); // pre-multiplied src and ...
- hr = m_pD3DDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_SRCALPHA); // ... inverse alpha channel for dst
-
- hr = m_pD3DDev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
- hr = m_pD3DDev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
- hr = m_pD3DDev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
-
- hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
- hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
- hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
-
- hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
- hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
-
- /*//
-
- D3DCAPS9 d3dcaps9;
- hr = m_pD3DDev->GetDeviceCaps(&d3dcaps9);
- if (d3dcaps9.AlphaCmpCaps & D3DPCMPCAPS_LESS)
- {
- hr = m_pD3DDev->SetRenderState(D3DRS_ALPHAREF, (DWORD)0x000000FE);
- hr = m_pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
- hr = m_pD3DDev->SetRenderState(D3DRS_ALPHAFUNC, D3DPCMPCAPS_LESS);
- }
-
- *///
-
- hr = m_pD3DDev->SetPixelShader(NULL);
-
- hr = m_pD3DDev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
- hr = m_pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pVertices, sizeof(pVertices[0]));
-
- //
-
- m_pD3DDev->SetTexture(0, NULL);
-
- m_pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, abe);
- m_pD3DDev->SetRenderState(D3DRS_SRCBLEND, sb);
- m_pD3DDev->SetRenderState(D3DRS_DESTBLEND, db);
-
- return S_OK;
+ if (!pSrc || !pDst) {
+ return E_POINTER;
+ }
+
+ CRect src(*pSrc), dst(*pDst);
+
+ HRESULT hr;
+
+ D3DSURFACE_DESC d3dsd;
+ ZeroMemory(&d3dsd, sizeof(d3dsd));
+ if (FAILED(pTexture->GetLevelDesc(0, &d3dsd)) /*|| d3dsd.Type != D3DRTYPE_TEXTURE*/) {
+ return E_FAIL;
+ }
+
+ float w = (float)d3dsd.Width;
+ float h = (float)d3dsd.Height;
+
+ struct {
+ float x, y, z, rhw;
+ float tu, tv;
+ }
+ pVertices[] = {
+ {(float)dst.left, (float)dst.top, 0.5f, 2.0f, (float)src.left / w, (float)src.top / h},
+ {(float)dst.right, (float)dst.top, 0.5f, 2.0f, (float)src.right / w, (float)src.top / h},
+ {(float)dst.left, (float)dst.bottom, 0.5f, 2.0f, (float)src.left / w, (float)src.bottom / h},
+ {(float)dst.right, (float)dst.bottom, 0.5f, 2.0f, (float)src.right / w, (float)src.bottom / h},
+ };
+
+ for (int i = 0; i < _countof(pVertices); i++) {
+ pVertices[i].x -= 0.5;
+ pVertices[i].y -= 0.5;
+ }
+
+ hr = m_pD3DDev->SetTexture(0, pTexture);
+
+ // GetRenderState fails for devices created with D3DCREATE_PUREDEVICE
+ // so we need to provide default values in case GetRenderState fails
+ DWORD abe, sb, db;
+ if (FAILED(m_pD3DDev->GetRenderState(D3DRS_ALPHABLENDENABLE, &abe))) {
+ abe = FALSE;
+ }
+ if (FAILED(m_pD3DDev->GetRenderState(D3DRS_SRCBLEND, &sb))) {
+ sb = D3DBLEND_ONE;
+ }
+ if (FAILED(m_pD3DDev->GetRenderState(D3DRS_DESTBLEND, &db))) {
+ db = D3DBLEND_ZERO;
+ }
+
+ hr = m_pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
+ hr = m_pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
+ hr = m_pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
+ hr = m_pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ hr = m_pD3DDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); // pre-multiplied src and ...
+ hr = m_pD3DDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_SRCALPHA); // ... inverse alpha channel for dst
+
+ hr = m_pD3DDev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
+ hr = m_pD3DDev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+ hr = m_pD3DDev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
+
+ hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
+ hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
+ hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
+
+ hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
+ hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
+
+ /*//
+
+ D3DCAPS9 d3dcaps9;
+ hr = m_pD3DDev->GetDeviceCaps(&d3dcaps9);
+ if (d3dcaps9.AlphaCmpCaps & D3DPCMPCAPS_LESS)
+ {
+ hr = m_pD3DDev->SetRenderState(D3DRS_ALPHAREF, (DWORD)0x000000FE);
+ hr = m_pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
+ hr = m_pD3DDev->SetRenderState(D3DRS_ALPHAFUNC, D3DPCMPCAPS_LESS);
+ }
+
+ *///
+
+ hr = m_pD3DDev->SetPixelShader(NULL);
+
+ hr = m_pD3DDev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
+ hr = m_pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pVertices, sizeof(pVertices[0]));
+
+ //
+
+ m_pD3DDev->SetTexture(0, NULL);
+
+ m_pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, abe);
+ m_pD3DDev->SetRenderState(D3DRS_SRCBLEND, sb);
+ m_pD3DDev->SetRenderState(D3DRS_DESTBLEND, db);
+
+ return S_OK;
}
HRESULT CDX9RenderingEngine::SetCustomPixelShader(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace)
{
- CAtlList<CExternalPixelShader> *pPixelShaders;
- if (bScreenSpace) {
- pPixelShaders = &m_pCustomScreenSpacePixelShaders;
- } else {
- pPixelShaders = &m_pCustomPixelShaders;
- }
+ CAtlList<CExternalPixelShader>* pPixelShaders;
+ if (bScreenSpace) {
+ pPixelShaders = &m_pCustomScreenSpacePixelShaders;
+ } else {
+ pPixelShaders = &m_pCustomPixelShaders;
+ }
- if (!pSrcData && !pTarget) {
- pPixelShaders->RemoveAll();
- m_pD3DDev->SetPixelShader(NULL);
- return S_OK;
- }
+ if (!pSrcData && !pTarget) {
+ pPixelShaders->RemoveAll();
+ m_pD3DDev->SetPixelShader(NULL);
+ return S_OK;
+ }
- if (!pSrcData || !pTarget) {
- return E_INVALIDARG;
- }
+ if (!pSrcData || !pTarget) {
+ return E_INVALIDARG;
+ }
- CExternalPixelShader Shader;
- Shader.m_SourceData = pSrcData;
- Shader.m_SourceTarget = pTarget;
+ CExternalPixelShader Shader;
+ Shader.m_SourceData = pSrcData;
+ Shader.m_SourceTarget = pTarget;
- CComPtr<IDirect3DPixelShader9> pPixelShader;
+ CComPtr<IDirect3DPixelShader9> pPixelShader;
- HRESULT hr = Shader.Compile(m_pPSC);
- if (FAILED(hr)) {
- return hr;
- }
+ HRESULT hr = Shader.Compile(m_pPSC);
+ if (FAILED(hr)) {
+ return hr;
+ }
- pPixelShaders->AddTail(Shader);
+ pPixelShaders->AddTail(Shader);
- Paint(false);
+ Paint(false);
- return S_OK;
+ return S_OK;
}
diff --git a/src/filters/renderer/VideoRenderers/DX9RenderingEngine.h b/src/filters/renderer/VideoRenderers/DX9RenderingEngine.h
index f51e0c401..699d5fe85 100644
--- a/src/filters/renderer/VideoRenderers/DX9RenderingEngine.h
+++ b/src/filters/renderer/VideoRenderers/DX9RenderingEngine.h
@@ -32,152 +32,152 @@
namespace DSObjects
{
- class CDX9RenderingEngine
- : public CSubPicAllocatorPresenterImpl
- {
- protected:
- enum RenderingPath {
- RENDERING_PATH_STRETCHRECT,
- RENDERING_PATH_DRAW,
- };
-
- static const int MAX_VIDEO_SURFACES = 60;
-
- // Variables initialized/managed by the allocator-presenter!
- CComPtr<IDirect3D9> m_pD3D;
- CComPtr<IDirect3D9Ex> m_pD3DEx;
- CComPtr<IDirect3DDevice9> m_pD3DDev;
- CComPtr<IDirect3DDevice9Ex> m_pD3DDevEx;
- UINT m_CurrentAdapter;
- D3DCAPS9 m_Caps;
- D3DFORMAT m_BackbufferType;
- D3DFORMAT m_DisplayType;
- CSize m_ScreenSize;
- int m_nNbDXSurface; // Total number of DX Surfaces
- int m_nCurSurface; // Surface currently displayed
-
- bool m_bHighColorResolution;
- bool m_bForceInputHighColorResolution;
-
- // Variables initialized/managed by this class but can be accessed by the allocator-presenter
- bool m_bD3DX;
- RenderingPath m_RenderingPath;
- D3DFORMAT m_SurfaceType;
- CComPtr<IDirect3DTexture9> m_pVideoTexture[MAX_VIDEO_SURFACES];
- CComPtr<IDirect3DSurface9> m_pVideoSurface[MAX_VIDEO_SURFACES];
-
- bool m_bFullFloatingPointProcessing;
- bool m_bHalfFloatingPointProcessing;
- bool m_bColorManagement;
-
- CDX9RenderingEngine(HWND hWnd, HRESULT& hr, CString *_pError);
-
- void InitRenderingEngine();
- void CleanupRenderingEngine();
-
- HRESULT CreateVideoSurfaces();
- void FreeVideoSurfaces();
-
- HRESULT RenderVideo(IDirect3DSurface9* pRenderTarget, const CRect& srcRect, const CRect& destRect);
-
- HRESULT DrawRect(DWORD _Color, DWORD _Alpha, const CRect &_Rect);
- HRESULT AlphaBlt(RECT* pSrc, RECT* pDst, IDirect3DTexture9* pTexture);
-
- HRESULT SetCustomPixelShader(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace);
-
-
- private:
- class CExternalPixelShader
- {
- public:
- CComPtr<IDirect3DPixelShader9> m_pPixelShader;
- CStringA m_SourceData;
- CStringA m_SourceTarget;
- HRESULT Compile(CPixelShaderCompiler *pCompiler) {
- HRESULT hr = pCompiler->CompileShader(m_SourceData, "main", m_SourceTarget, 0, &m_pPixelShader);
- if (FAILED(hr)) {
- return hr;
- }
-
- return S_OK;
- }
- };
-
- // D3DX functions
- typedef D3DXFLOAT16* (WINAPI* D3DXFloat32To16ArrayPtr)(
- D3DXFLOAT16 *pOut,
- CONST FLOAT *pIn,
- UINT n);
-
-
- CAutoPtr<CPixelShaderCompiler> m_pPSC;
-
- // Settings
- VideoSystem m_InputVideoSystem;
- AmbientLight m_AmbientLight;
- ColorRenderingIntent m_RenderingIntent;
-
- // Custom pixel shaders
- CAtlList<CExternalPixelShader> m_pCustomPixelShaders;
- CComPtr<IDirect3DTexture9> m_pTemporaryVideoTextures[2];
-
- // Screen space pipeline
- int m_ScreenSpacePassCount;
- int m_ScreenSpacePassSrc;
- int m_ScreenSpacePassDest;
- CSize m_TemporaryScreenSpaceTextureSize;
- CComPtr<IDirect3DTexture9> m_pTemporaryScreenSpaceTextures[2];
- IDirect3DSurface9* m_pRenderTarget;
-
- // Resizers
- float m_BicubicA;
- CComPtr<IDirect3DPixelShader9> m_pResizerPixelShaders[4]; // bl, bc1, bc2_1, bc2_2
-
- // Final pass
- bool m_bFinalPass;
- int m_Lut3DSize;
- int m_Lut3DEntryCount;
- CComPtr<IDirect3DVolumeTexture9> m_pLut3DTexture;
- CComPtr<IDirect3DTexture9> m_pDitherTexture;
- CComPtr<IDirect3DPixelShader9> m_pFinalPixelShader;
-
- // Custom screen space pixel shaders
- CAtlList<CExternalPixelShader> m_pCustomScreenSpacePixelShaders;
-
- // StetchRect rendering path
- D3DTEXTUREFILTERTYPE m_StretchRectFilter;
-
- // D3DX function pointers
- D3DXFloat32To16ArrayPtr m_pD3DXFloat32To16Array;
-
-
- // Video rendering paths
- HRESULT RenderVideoDrawPath(IDirect3DSurface9* pRenderTarget, const CRect& srcRect, const CRect& destRect);
- HRESULT RenderVideoStretchRectPath(IDirect3DSurface9* pRenderTarget, const CRect& srcRect, const CRect& destRect);
-
- // Custom pixel shaders
- HRESULT InitTemporaryVideoTextures(int count);
-
- // Screen space pipeline
- HRESULT InitScreenSpacePipeline(int passCount, IDirect3DSurface9* pRenderTarget);
- HRESULT InitTemporaryScreenSpaceTextures(int count);
- HRESULT BeginScreenSpacePass();
-
- // Resizers
- HRESULT InitResizers(float bicubicA);
- HRESULT TextureResize(IDirect3DTexture9* pTexture, Vector dst[4], D3DTEXTUREFILTERTYPE filter, const CRect &srcRect);
- HRESULT TextureResizeBilinear(IDirect3DTexture9* pTexture, Vector dst[4], const CRect &srcRect);
- HRESULT TextureResizeBicubic1pass(IDirect3DTexture9* pTexture, Vector dst[4], const CRect &srcRect);
- //HRESULT TextureResizeBicubic2pass(IDirect3DTexture9* pTexture, Vector dst[4], const CRect &srcRect);
+ class CDX9RenderingEngine
+ : public CSubPicAllocatorPresenterImpl
+ {
+ protected:
+ enum RenderingPath {
+ RENDERING_PATH_STRETCHRECT,
+ RENDERING_PATH_DRAW,
+ };
+
+ static const int MAX_VIDEO_SURFACES = 60;
+
+ // Variables initialized/managed by the allocator-presenter!
+ CComPtr<IDirect3D9> m_pD3D;
+ CComPtr<IDirect3D9Ex> m_pD3DEx;
+ CComPtr<IDirect3DDevice9> m_pD3DDev;
+ CComPtr<IDirect3DDevice9Ex> m_pD3DDevEx;
+ UINT m_CurrentAdapter;
+ D3DCAPS9 m_Caps;
+ D3DFORMAT m_BackbufferType;
+ D3DFORMAT m_DisplayType;
+ CSize m_ScreenSize;
+ int m_nNbDXSurface; // Total number of DX Surfaces
+ int m_nCurSurface; // Surface currently displayed
+
+ bool m_bHighColorResolution;
+ bool m_bForceInputHighColorResolution;
+
+ // Variables initialized/managed by this class but can be accessed by the allocator-presenter
+ bool m_bD3DX;
+ RenderingPath m_RenderingPath;
+ D3DFORMAT m_SurfaceType;
+ CComPtr<IDirect3DTexture9> m_pVideoTexture[MAX_VIDEO_SURFACES];
+ CComPtr<IDirect3DSurface9> m_pVideoSurface[MAX_VIDEO_SURFACES];
+
+ bool m_bFullFloatingPointProcessing;
+ bool m_bHalfFloatingPointProcessing;
+ bool m_bColorManagement;
+
+ CDX9RenderingEngine(HWND hWnd, HRESULT& hr, CString* _pError);
+
+ void InitRenderingEngine();
+ void CleanupRenderingEngine();
+
+ HRESULT CreateVideoSurfaces();
+ void FreeVideoSurfaces();
+
+ HRESULT RenderVideo(IDirect3DSurface9* pRenderTarget, const CRect& srcRect, const CRect& destRect);
+
+ HRESULT DrawRect(DWORD _Color, DWORD _Alpha, const CRect& _Rect);
+ HRESULT AlphaBlt(RECT* pSrc, RECT* pDst, IDirect3DTexture9* pTexture);
+
+ HRESULT SetCustomPixelShader(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace);
+
+
+ private:
+ class CExternalPixelShader
+ {
+ public:
+ CComPtr<IDirect3DPixelShader9> m_pPixelShader;
+ CStringA m_SourceData;
+ CStringA m_SourceTarget;
+ HRESULT Compile(CPixelShaderCompiler* pCompiler) {
+ HRESULT hr = pCompiler->CompileShader(m_SourceData, "main", m_SourceTarget, 0, &m_pPixelShader);
+ if (FAILED(hr)) {
+ return hr;
+ }
+
+ return S_OK;
+ }
+ };
+
+ // D3DX functions
+ typedef D3DXFLOAT16* (WINAPI* D3DXFloat32To16ArrayPtr)(
+ D3DXFLOAT16* pOut,
+ CONST FLOAT* pIn,
+ UINT n);
+
+
+ CAutoPtr<CPixelShaderCompiler> m_pPSC;
+
+ // Settings
+ VideoSystem m_InputVideoSystem;
+ AmbientLight m_AmbientLight;
+ ColorRenderingIntent m_RenderingIntent;
+
+ // Custom pixel shaders
+ CAtlList<CExternalPixelShader> m_pCustomPixelShaders;
+ CComPtr<IDirect3DTexture9> m_pTemporaryVideoTextures[2];
+
+ // Screen space pipeline
+ int m_ScreenSpacePassCount;
+ int m_ScreenSpacePassSrc;
+ int m_ScreenSpacePassDest;
+ CSize m_TemporaryScreenSpaceTextureSize;
+ CComPtr<IDirect3DTexture9> m_pTemporaryScreenSpaceTextures[2];
+ IDirect3DSurface9* m_pRenderTarget;
+
+ // Resizers
+ float m_BicubicA;
+ CComPtr<IDirect3DPixelShader9> m_pResizerPixelShaders[4]; // bl, bc1, bc2_1, bc2_2
+
+ // Final pass
+ bool m_bFinalPass;
+ int m_Lut3DSize;
+ int m_Lut3DEntryCount;
+ CComPtr<IDirect3DVolumeTexture9> m_pLut3DTexture;
+ CComPtr<IDirect3DTexture9> m_pDitherTexture;
+ CComPtr<IDirect3DPixelShader9> m_pFinalPixelShader;
+
+ // Custom screen space pixel shaders
+ CAtlList<CExternalPixelShader> m_pCustomScreenSpacePixelShaders;
+
+ // StetchRect rendering path
+ D3DTEXTUREFILTERTYPE m_StretchRectFilter;
+
+ // D3DX function pointers
+ D3DXFloat32To16ArrayPtr m_pD3DXFloat32To16Array;
+
+
+ // Video rendering paths
+ HRESULT RenderVideoDrawPath(IDirect3DSurface9* pRenderTarget, const CRect& srcRect, const CRect& destRect);
+ HRESULT RenderVideoStretchRectPath(IDirect3DSurface9* pRenderTarget, const CRect& srcRect, const CRect& destRect);
+
+ // Custom pixel shaders
+ HRESULT InitTemporaryVideoTextures(int count);
+
+ // Screen space pipeline
+ HRESULT InitScreenSpacePipeline(int passCount, IDirect3DSurface9* pRenderTarget);
+ HRESULT InitTemporaryScreenSpaceTextures(int count);
+ HRESULT BeginScreenSpacePass();
+
+ // Resizers
+ HRESULT InitResizers(float bicubicA);
+ HRESULT TextureResize(IDirect3DTexture9* pTexture, Vector dst[4], D3DTEXTUREFILTERTYPE filter, const CRect& srcRect);
+ HRESULT TextureResizeBilinear(IDirect3DTexture9* pTexture, Vector dst[4], const CRect& srcRect);
+ HRESULT TextureResizeBicubic1pass(IDirect3DTexture9* pTexture, Vector dst[4], const CRect& srcRect);
+ //HRESULT TextureResizeBicubic2pass(IDirect3DTexture9* pTexture, Vector dst[4], const CRect &srcRect);
- // Final pass
- HRESULT InitFinalPass();
- void CleanupFinalPass();
- HRESULT CreateIccProfileLut(TCHAR* profilePath, float* lut3D);
- HRESULT FinalPass(IDirect3DTexture9* pTexture);
-
- HRESULT TextureCopy(IDirect3DTexture9* pTexture);
- bool ClipToSurface(IDirect3DSurface9* pSurface, CRect& s, CRect& d);
- };
+ // Final pass
+ HRESULT InitFinalPass();
+ void CleanupFinalPass();
+ HRESULT CreateIccProfileLut(TCHAR* profilePath, float* lut3D);
+ HRESULT FinalPass(IDirect3DTexture9* pTexture);
+
+ HRESULT TextureCopy(IDirect3DTexture9* pTexture);
+ bool ClipToSurface(IDirect3DSurface9* pSurface, CRect& s, CRect& d);
+ };
}
diff --git a/src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.cpp
index 4be94e482..2cb61d6d2 100644
--- a/src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.cpp
@@ -33,213 +33,213 @@ using namespace DSObjects;
// CDXRAllocatorPresenter
//
-CDXRAllocatorPresenter::CDXRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error)
- : CSubPicAllocatorPresenterImpl(hWnd, hr, &_Error)
- , m_ScreenSize(0, 0)
+CDXRAllocatorPresenter::CDXRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString& _Error)
+ : CSubPicAllocatorPresenterImpl(hWnd, hr, &_Error)
+ , m_ScreenSize(0, 0)
{
- if (FAILED(hr)) {
- _Error += L"ISubPicAllocatorPresenterImpl failed\n";
- return;
- }
+ if (FAILED(hr)) {
+ _Error += L"ISubPicAllocatorPresenterImpl failed\n";
+ return;
+ }
- hr = S_OK;
+ hr = S_OK;
}
CDXRAllocatorPresenter::~CDXRAllocatorPresenter()
{
- if (m_pSRCB) {
- // nasty, but we have to let it know about our death somehow
- ((CSubRenderCallback*)(ISubRenderCallback*)m_pSRCB)->SetDXRAP(NULL);
- }
-
- // the order is important here
- m_pSubPicQueue = NULL;
- m_pAllocator = NULL;
- m_pDXR = NULL;
+ if (m_pSRCB) {
+ // nasty, but we have to let it know about our death somehow
+ ((CSubRenderCallback*)(ISubRenderCallback*)m_pSRCB)->SetDXRAP(NULL);
+ }
+
+ // the order is important here
+ m_pSubPicQueue = NULL;
+ m_pAllocator = NULL;
+ m_pDXR = NULL;
}
STDMETHODIMP CDXRAllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- /*
- if (riid == __uuidof(IVideoWindow))
- return GetInterface((IVideoWindow*)this, ppv);
- if (riid == __uuidof(IBasicVideo))
- return GetInterface((IBasicVideo*)this, ppv);
- if (riid == __uuidof(IBasicVideo2))
- return GetInterface((IBasicVideo2*)this, ppv);
- */
- /*
- if (riid == __uuidof(IVMRWindowlessControl))
- return GetInterface((IVMRWindowlessControl*)this, ppv);
- */
-
- if (riid != IID_IUnknown && m_pDXR) {
- if (SUCCEEDED(m_pDXR->QueryInterface(riid, ppv))) {
- return S_OK;
- }
- }
-
- return __super::NonDelegatingQueryInterface(riid, ppv);
+ /*
+ if (riid == __uuidof(IVideoWindow))
+ return GetInterface((IVideoWindow*)this, ppv);
+ if (riid == __uuidof(IBasicVideo))
+ return GetInterface((IBasicVideo*)this, ppv);
+ if (riid == __uuidof(IBasicVideo2))
+ return GetInterface((IBasicVideo2*)this, ppv);
+ */
+ /*
+ if (riid == __uuidof(IVMRWindowlessControl))
+ return GetInterface((IVMRWindowlessControl*)this, ppv);
+ */
+
+ if (riid != IID_IUnknown && m_pDXR) {
+ if (SUCCEEDED(m_pDXR->QueryInterface(riid, ppv))) {
+ return S_OK;
+ }
+ }
+
+ return __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CDXRAllocatorPresenter::SetDevice(IDirect3DDevice9* pD3DDev)
{
- CheckPointer(pD3DDev, E_POINTER);
-
- CSize size;
- switch (GetRenderersSettings().nSPCMaxRes) {
- case 0:
- default:
- size = m_ScreenSize;
- break;
- case 1:
- size.SetSize(1024, 768);
- break;
- case 2:
- size.SetSize(800, 600);
- break;
- case 3:
- size.SetSize(640, 480);
- break;
- case 4:
- size.SetSize(512, 384);
- break;
- case 5:
- size.SetSize(384, 288);
- break;
- case 6:
- size.SetSize(2560, 1600);
- break;
- case 7:
- size.SetSize(1920, 1080);
- break;
- case 8:
- size.SetSize(1320, 900);
- break;
- case 9:
- size.SetSize(1280, 720);
- break;
- }
-
- if (m_pAllocator) {
- m_pAllocator->ChangeDevice(pD3DDev);
- } else {
- m_pAllocator = DNew CDX9SubPicAllocator(pD3DDev, size, GetRenderersSettings().fSPCPow2Tex, true);
- if (!m_pAllocator) {
- return E_FAIL;
- }
- }
-
- HRESULT hr = S_OK;
-
- m_pSubPicQueue = GetRenderersSettings().nSPCSize > 0
- ? (ISubPicQueue*)DNew CSubPicQueue(GetRenderersSettings().nSPCSize, !GetRenderersSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
- : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
- if (!m_pSubPicQueue || FAILED(hr)) {
- return E_FAIL;
- }
-
- if (m_SubPicProvider) {
- m_pSubPicQueue->SetSubPicProvider(m_SubPicProvider);
- }
-
- return S_OK;
+ CheckPointer(pD3DDev, E_POINTER);
+
+ CSize size;
+ switch (GetRenderersSettings().nSPCMaxRes) {
+ case 0:
+ default:
+ size = m_ScreenSize;
+ break;
+ case 1:
+ size.SetSize(1024, 768);
+ break;
+ case 2:
+ size.SetSize(800, 600);
+ break;
+ case 3:
+ size.SetSize(640, 480);
+ break;
+ case 4:
+ size.SetSize(512, 384);
+ break;
+ case 5:
+ size.SetSize(384, 288);
+ break;
+ case 6:
+ size.SetSize(2560, 1600);
+ break;
+ case 7:
+ size.SetSize(1920, 1080);
+ break;
+ case 8:
+ size.SetSize(1320, 900);
+ break;
+ case 9:
+ size.SetSize(1280, 720);
+ break;
+ }
+
+ if (m_pAllocator) {
+ m_pAllocator->ChangeDevice(pD3DDev);
+ } else {
+ m_pAllocator = DNew CDX9SubPicAllocator(pD3DDev, size, GetRenderersSettings().fSPCPow2Tex, true);
+ if (!m_pAllocator) {
+ return E_FAIL;
+ }
+ }
+
+ HRESULT hr = S_OK;
+
+ m_pSubPicQueue = GetRenderersSettings().nSPCSize > 0
+ ? (ISubPicQueue*)DNew CSubPicQueue(GetRenderersSettings().nSPCSize, !GetRenderersSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
+ : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
+ if (!m_pSubPicQueue || FAILED(hr)) {
+ return E_FAIL;
+ }
+
+ if (m_SubPicProvider) {
+ m_pSubPicQueue->SetSubPicProvider(m_SubPicProvider);
+ }
+
+ return S_OK;
}
HRESULT CDXRAllocatorPresenter::Render(
- REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, REFERENCE_TIME atpf,
- int left, int top, int right, int bottom, int width, int height)
+ REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, REFERENCE_TIME atpf,
+ int left, int top, int right, int bottom, int width, int height)
{
- __super::SetPosition(CRect(0, 0, width, height), CRect(left, top, right, bottom)); // needed? should be already set by the player
- SetTime(rtStart);
- if (atpf > 0 && m_pSubPicQueue) {
- m_pSubPicQueue->SetFPS(10000000.0 / atpf);
- }
- AlphaBltSubPic(CSize(width, height));
- return S_OK;
+ __super::SetPosition(CRect(0, 0, width, height), CRect(left, top, right, bottom)); // needed? should be already set by the player
+ SetTime(rtStart);
+ if (atpf > 0 && m_pSubPicQueue) {
+ m_pSubPicQueue->SetFPS(10000000.0 / atpf);
+ }
+ AlphaBltSubPic(CSize(width, height));
+ return S_OK;
}
// ISubPicAllocatorPresenter
STDMETHODIMP CDXRAllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
{
- CheckPointer(ppRenderer, E_POINTER);
-
- if (m_pDXR) {
- return E_UNEXPECTED;
- }
- m_pDXR.CoCreateInstance(CLSID_DXR, GetOwner());
- if (!m_pDXR) {
- return E_FAIL;
- }
-
- CComQIPtr<ISubRender> pSR = m_pDXR;
- if (!pSR) {
- m_pDXR = NULL;
- return E_FAIL;
- }
-
- m_pSRCB = DNew CSubRenderCallback(this);
- if (FAILED(pSR->SetCallback(m_pSRCB))) {
- m_pDXR = NULL;
- return E_FAIL;
- }
-
- (*ppRenderer = this)->AddRef();
-
- MONITORINFO mi;
- mi.cbSize = sizeof(MONITORINFO);
- if (GetMonitorInfo(MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST), &mi)) {
- m_ScreenSize.SetSize(mi.rcMonitor.right-mi.rcMonitor.left, mi.rcMonitor.bottom-mi.rcMonitor.top);
- }
-
- return S_OK;
+ CheckPointer(ppRenderer, E_POINTER);
+
+ if (m_pDXR) {
+ return E_UNEXPECTED;
+ }
+ m_pDXR.CoCreateInstance(CLSID_DXR, GetOwner());
+ if (!m_pDXR) {
+ return E_FAIL;
+ }
+
+ CComQIPtr<ISubRender> pSR = m_pDXR;
+ if (!pSR) {
+ m_pDXR = NULL;
+ return E_FAIL;
+ }
+
+ m_pSRCB = DNew CSubRenderCallback(this);
+ if (FAILED(pSR->SetCallback(m_pSRCB))) {
+ m_pDXR = NULL;
+ return E_FAIL;
+ }
+
+ (*ppRenderer = this)->AddRef();
+
+ MONITORINFO mi;
+ mi.cbSize = sizeof(MONITORINFO);
+ if (GetMonitorInfo(MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST), &mi)) {
+ m_ScreenSize.SetSize(mi.rcMonitor.right - mi.rcMonitor.left, mi.rcMonitor.bottom - mi.rcMonitor.top);
+ }
+
+ return S_OK;
}
STDMETHODIMP_(void) CDXRAllocatorPresenter::SetPosition(RECT w, RECT v)
{
- if (CComQIPtr<IBasicVideo> pBV = m_pDXR) {
- pBV->SetDefaultSourcePosition();
- pBV->SetDestinationPosition(v.left, v.top, v.right - v.left, v.bottom - v.top);
- }
-
- if (CComQIPtr<IVideoWindow> pVW = m_pDXR) {
- pVW->SetWindowPosition(w.left, w.top, w.right - w.left, w.bottom - w.top);
- }
+ if (CComQIPtr<IBasicVideo> pBV = m_pDXR) {
+ pBV->SetDefaultSourcePosition();
+ pBV->SetDestinationPosition(v.left, v.top, v.right - v.left, v.bottom - v.top);
+ }
+
+ if (CComQIPtr<IVideoWindow> pVW = m_pDXR) {
+ pVW->SetWindowPosition(w.left, w.top, w.right - w.left, w.bottom - w.top);
+ }
}
STDMETHODIMP_(SIZE) CDXRAllocatorPresenter::GetVideoSize(bool fCorrectAR)
{
- SIZE size = {0, 0};
-
- if (!fCorrectAR) {
- if (CComQIPtr<IBasicVideo> pBV = m_pDXR) {
- pBV->GetVideoSize(&size.cx, &size.cy);
- }
- } else {
- if (CComQIPtr<IBasicVideo2> pBV2 = m_pDXR) {
- pBV2->GetPreferredAspectRatio(&size.cx, &size.cy);
- }
- }
-
- return size;
+ SIZE size = {0, 0};
+
+ if (!fCorrectAR) {
+ if (CComQIPtr<IBasicVideo> pBV = m_pDXR) {
+ pBV->GetVideoSize(&size.cx, &size.cy);
+ }
+ } else {
+ if (CComQIPtr<IBasicVideo2> pBV2 = m_pDXR) {
+ pBV2->GetPreferredAspectRatio(&size.cx, &size.cy);
+ }
+ }
+
+ return size;
}
STDMETHODIMP_(bool) CDXRAllocatorPresenter::Paint(bool fAll)
{
- return false; // TODO
+ return false; // TODO
}
STDMETHODIMP CDXRAllocatorPresenter::GetDIB(BYTE* lpDib, DWORD* size)
{
- HRESULT hr = E_NOTIMPL;
- if (CComQIPtr<IBasicVideo> pBV = m_pDXR) {
- hr = pBV->GetCurrentImage((long*)size, (long*)lpDib);
- }
- return hr;
+ HRESULT hr = E_NOTIMPL;
+ if (CComQIPtr<IBasicVideo> pBV = m_pDXR) {
+ hr = pBV->GetCurrentImage((long*)size, (long*)lpDib);
+ }
+ return hr;
}
STDMETHODIMP CDXRAllocatorPresenter::SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget)
{
- return E_NOTIMPL; // TODO
+ return E_NOTIMPL; // TODO
}
diff --git a/src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.h b/src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.h
index a5c177231..341429e8f 100644
--- a/src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.h
+++ b/src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.h
@@ -28,73 +28,73 @@
namespace DSObjects
{
- class CDXRAllocatorPresenter
- : public CSubPicAllocatorPresenterImpl
- {
- class CSubRenderCallback : public CUnknown, public ISubRenderCallback, public CCritSec
- {
- CDXRAllocatorPresenter* m_pDXRAP;
-
- public:
- CSubRenderCallback(CDXRAllocatorPresenter* pDXRAP)
- : CUnknown(_T("CSubRender"), NULL)
- , m_pDXRAP(pDXRAP) {
- }
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
- return
- QI(ISubRenderCallback)
- __super::NonDelegatingQueryInterface(riid, ppv);
- }
-
- void SetDXRAP(CDXRAllocatorPresenter* pDXRAP) {
- CAutoLock cAutoLock(this);
- m_pDXRAP = pDXRAP;
- }
-
- // ISubRenderCallback
-
- STDMETHODIMP SetDevice(IDirect3DDevice9* pD3DDev) {
- CAutoLock cAutoLock(this);
- return m_pDXRAP ? m_pDXRAP->SetDevice(pD3DDev) : E_UNEXPECTED;
- }
-
- STDMETHODIMP Render(REFERENCE_TIME rtStart, int left, int top, int right, int bottom, int width, int height) {
- CAutoLock cAutoLock(this);
- return m_pDXRAP ? m_pDXRAP->Render(rtStart, 0, 0, left, top, right, bottom, width, height) : E_UNEXPECTED;
- }
-
- // ISubRendererCallback2
-
- STDMETHODIMP RenderEx(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, REFERENCE_TIME AvgTimePerFrame, int left, int top, int right, int bottom, int width, int height) {
- CAutoLock cAutoLock(this);
- return m_pDXRAP ? m_pDXRAP->Render(rtStart, rtStop, AvgTimePerFrame, left, top, right, bottom, width, height) : E_UNEXPECTED;
- }
- };
-
- CComPtr<IUnknown> m_pDXR;
- CComPtr<ISubRenderCallback> m_pSRCB;
- CSize m_ScreenSize;
-
- public:
- CDXRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error);
- virtual ~CDXRAllocatorPresenter();
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- HRESULT SetDevice(IDirect3DDevice9* pD3DDev);
- HRESULT Render(
- REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, REFERENCE_TIME atpf,
- int left, int top, int bottom, int right, int width, int height);
-
- // ISubPicAllocatorPresenter
- STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
- STDMETHODIMP_(void) SetPosition(RECT w, RECT v);
- STDMETHODIMP_(SIZE) GetVideoSize(bool fCorrectAR);
- STDMETHODIMP_(bool) Paint(bool fAll);
- STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size);
- STDMETHODIMP SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget);
- };
+ class CDXRAllocatorPresenter
+ : public CSubPicAllocatorPresenterImpl
+ {
+ class CSubRenderCallback : public CUnknown, public ISubRenderCallback, public CCritSec
+ {
+ CDXRAllocatorPresenter* m_pDXRAP;
+
+ public:
+ CSubRenderCallback(CDXRAllocatorPresenter* pDXRAP)
+ : CUnknown(_T("CSubRender"), NULL)
+ , m_pDXRAP(pDXRAP) {
+ }
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
+ return
+ QI(ISubRenderCallback)
+ __super::NonDelegatingQueryInterface(riid, ppv);
+ }
+
+ void SetDXRAP(CDXRAllocatorPresenter* pDXRAP) {
+ CAutoLock cAutoLock(this);
+ m_pDXRAP = pDXRAP;
+ }
+
+ // ISubRenderCallback
+
+ STDMETHODIMP SetDevice(IDirect3DDevice9* pD3DDev) {
+ CAutoLock cAutoLock(this);
+ return m_pDXRAP ? m_pDXRAP->SetDevice(pD3DDev) : E_UNEXPECTED;
+ }
+
+ STDMETHODIMP Render(REFERENCE_TIME rtStart, int left, int top, int right, int bottom, int width, int height) {
+ CAutoLock cAutoLock(this);
+ return m_pDXRAP ? m_pDXRAP->Render(rtStart, 0, 0, left, top, right, bottom, width, height) : E_UNEXPECTED;
+ }
+
+ // ISubRendererCallback2
+
+ STDMETHODIMP RenderEx(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, REFERENCE_TIME AvgTimePerFrame, int left, int top, int right, int bottom, int width, int height) {
+ CAutoLock cAutoLock(this);
+ return m_pDXRAP ? m_pDXRAP->Render(rtStart, rtStop, AvgTimePerFrame, left, top, right, bottom, width, height) : E_UNEXPECTED;
+ }
+ };
+
+ CComPtr<IUnknown> m_pDXR;
+ CComPtr<ISubRenderCallback> m_pSRCB;
+ CSize m_ScreenSize;
+
+ public:
+ CDXRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString& _Error);
+ virtual ~CDXRAllocatorPresenter();
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ HRESULT SetDevice(IDirect3DDevice9* pD3DDev);
+ HRESULT Render(
+ REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, REFERENCE_TIME atpf,
+ int left, int top, int bottom, int right, int width, int height);
+
+ // ISubPicAllocatorPresenter
+ STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
+ STDMETHODIMP_(void) SetPosition(RECT w, RECT v);
+ STDMETHODIMP_(SIZE) GetVideoSize(bool fCorrectAR);
+ STDMETHODIMP_(bool) Paint(bool fAll);
+ STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size);
+ STDMETHODIMP SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget);
+ };
}
diff --git a/src/filters/renderer/VideoRenderers/Dither.cpp b/src/filters/renderer/VideoRenderers/Dither.cpp
index f896bccca..b55330016 100644
--- a/src/filters/renderer/VideoRenderers/Dither.cpp
+++ b/src/filters/renderer/VideoRenderers/Dither.cpp
@@ -25,68 +25,68 @@
// Dither matrix in 16-bit floating point format
const unsigned short DITHER_MATRIX[DITHER_MATRIX_SIZE][DITHER_MATRIX_SIZE] = {
- 0x2c90, 0x38f4, 0x3bba, 0x29e0, 0x35f4, 0x3230, 0x3bbc, 0x3924, 0x3a46, 0x3644, 0x39e2, 0x370c, 0x3444, 0x3b1a, 0x3140, 0x39d2,
- 0x385a, 0x3b24, 0x2c10, 0x38c6, 0x3808, 0x2780, 0x3bbe, 0x37f8, 0x350c, 0x3a6c, 0x3368, 0x3bc0, 0x3000, 0x3886, 0x31b0, 0x3554,
- 0x3a94, 0x3618, 0x3430, 0x3a34, 0x3834, 0x39fe, 0x2740, 0x3758, 0x3494, 0x3b7a, 0x2700, 0x3958, 0x3858, 0x3a24, 0x364c, 0x3bc2,
- 0x3278, 0x3a22, 0x353c, 0x39de, 0x3268, 0x3a98, 0x36fc, 0x2ed0, 0x39e0, 0x30f0, 0x381a, 0x3996, 0x35ac, 0x3af2, 0x39b8, 0x37bc,
- 0x3250, 0x39dc, 0x3800, 0x30e8, 0x3b42, 0x34d4, 0x3970, 0x3afe, 0x3020, 0x3898, 0x33e8, 0x3b34, 0x2e10, 0x3320, 0x391a, 0x26c0,
- 0x3784, 0x38de, 0x3060, 0x3b5c, 0x3600, 0x38e6, 0x3490, 0x3b2a, 0x387a, 0x365c, 0x3b3c, 0x2be0, 0x37ac, 0x33d8, 0x2680, 0x3b98,
- 0x38d6, 0x2a60, 0x3b7e, 0x391e, 0x36d0, 0x2fe0, 0x3812, 0x32a0, 0x3a84, 0x36b0, 0x3a50, 0x357c, 0x37dc, 0x3b68, 0x3594, 0x3aca,
- 0x344c, 0x3a7c, 0x3674, 0x3884, 0x2d30, 0x3a48, 0x3170, 0x398e, 0x2900, 0x3a30, 0x34bc, 0x38ea, 0x3b70, 0x3a3c, 0x3852, 0x3460,
- 0x3b04, 0x37a0, 0x351c, 0x2d40, 0x3a80, 0x394e, 0x3b84, 0x3614, 0x3900, 0x2b20, 0x396c, 0x31b8, 0x38ca, 0x3a0c, 0x3038, 0x385c,
- 0x39a2, 0x2c70, 0x3ba2, 0x3464, 0x3992, 0x36dc, 0x3bc4, 0x3580, 0x3824, 0x32d0, 0x3abc, 0x2ec0, 0x3560, 0x30f8, 0x3974, 0x3610,
- 0x3a12, 0x3110, 0x3aaa, 0x38a2, 0x35e4, 0x341c, 0x28c0, 0x3a02, 0x34a8, 0x3b60, 0x3790, 0x3aa2, 0x2c40, 0x346c, 0x373c, 0x3bc6,
- 0x32f0, 0x37e8, 0x391c, 0x3100, 0x3af6, 0x2640, 0x3868, 0x3098, 0x3b3e, 0x3944, 0x3620, 0x3870, 0x39da, 0x374c, 0x3bc8, 0x2e20,
- 0x3804, 0x3932, 0x3660, 0x3260, 0x3bca, 0x38ce, 0x3ade, 0x382e, 0x30a0, 0x389e, 0x33a0, 0x363c, 0x3b86, 0x3910, 0x3a58, 0x2820,
- 0x36a0, 0x3b28, 0x34e0, 0x3a40, 0x3768, 0x3510, 0x3a54, 0x390e, 0x36e8, 0x2ae0, 0x3bcc, 0x31a0, 0x3aa4, 0x2600, 0x38cc, 0x3400,
- 0x3ac4, 0x2800, 0x3b4a, 0x39ee, 0x2cc0, 0x3764, 0x31c8, 0x35cc, 0x3bb6, 0x39a8, 0x2f30, 0x3a1e, 0x3816, 0x3160, 0x35b0, 0x389a,
- 0x3a86, 0x3070, 0x3848, 0x2d70, 0x38ba, 0x3baa, 0x2e60, 0x3414, 0x3ae4, 0x3544, 0x3a06, 0x37fc, 0x347c, 0x36d8, 0x3b12, 0x35a4,
- 0x3248, 0x3866, 0x34f8, 0x3814, 0x33f8, 0x39c2, 0x3a8a, 0x38e2, 0x25c0, 0x3720, 0x3b26, 0x3508, 0x2980, 0x39b4, 0x3b4c, 0x33a8,
- 0x3976, 0x3534, 0x39c4, 0x3b40, 0x3604, 0x31c0, 0x397c, 0x37b0, 0x39d0, 0x3218, 0x38d8, 0x2e30, 0x3b52, 0x39bc, 0x2fa0, 0x3980,
- 0x3b9a, 0x39d4, 0x2f40, 0x3960, 0x3b64, 0x3680, 0x2f60, 0x34c8, 0x3acc, 0x3228, 0x3850, 0x395c, 0x3bce, 0x354c, 0x3840, 0x2db0,
- 0x37a4, 0x3bd0, 0x2580, 0x33c8, 0x392a, 0x3a82, 0x3530, 0x3b48, 0x2540, 0x3760, 0x3a42, 0x35dc, 0x3890, 0x3308, 0x3844, 0x3710,
- 0x3418, 0x366c, 0x3a9a, 0x3590, 0x2500, 0x3888, 0x3bd2, 0x3984, 0x3668, 0x39e4, 0x345c, 0x2d20, 0x371c, 0x3288, 0x3aae, 0x39d6,
- 0x31e0, 0x38c8, 0x36e4, 0x3ab2, 0x380c, 0x2b00, 0x389c, 0x3280, 0x392c, 0x3bd4, 0x33b8, 0x3ad6, 0x24c0, 0x3bd6, 0x3a32, 0x2c60,
- 0x3b1c, 0x38aa, 0x3238, 0x3902, 0x3ae8, 0x3528, 0x3118, 0x3818, 0x2c50, 0x3ba0, 0x38bc, 0x3ad8, 0x3a20, 0x38f0, 0x2480, 0x36b4,
- 0x3b02, 0x34b0, 0x3a00, 0x30a8, 0x3518, 0x3bd8, 0x3688, 0x3a92, 0x34b4, 0x36c0, 0x2f70, 0x3968, 0x3798, 0x3448, 0x35ec, 0x3930,
- 0x3750, 0x2a40, 0x3bda, 0x3728, 0x32e8, 0x3a4a, 0x38d2, 0x3b38, 0x33d0, 0x3738, 0x30b8, 0x3628, 0x340c, 0x37d4, 0x3bb2, 0x3428,
- 0x3934, 0x2b40, 0x3856, 0x3b0e, 0x3964, 0x31d0, 0x39b0, 0x2e80, 0x38d4, 0x3b1e, 0x3a28, 0x387e, 0x30e0, 0x39a0, 0x3ae2, 0x3208,
- 0x3a56, 0x352c, 0x3a14, 0x2d90, 0x3978, 0x3794, 0x2960, 0x35e0, 0x39c6, 0x3a88, 0x3862, 0x3b76, 0x2e40, 0x3988, 0x3128, 0x3a4c,
- 0x378c, 0x3b8e, 0x359c, 0x2ea0, 0x36ac, 0x383e, 0x3af8, 0x3404, 0x3780, 0x2a20, 0x3360, 0x3598, 0x3b90, 0x37d0, 0x2dd0, 0x3880,
- 0x3358, 0x3946, 0x381c, 0x348c, 0x3b50, 0x3198, 0x3ad4, 0x3940, 0x3050, 0x3540, 0x2440, 0x39cc, 0x3770, 0x3b0a, 0x35d8, 0x386c,
- 0x2f00, 0x3380, 0x3a5a, 0x3948, 0x3ba4, 0x2400, 0x35a0, 0x393e, 0x3ba6, 0x39ea, 0x3838, 0x3ab0, 0x27c0, 0x3a38, 0x3538, 0x3bb4,
- 0x2380, 0x3b62, 0x30d8, 0x3a62, 0x360c, 0x388c, 0x342c, 0x37e0, 0x3bdc, 0x38f2, 0x3ad0, 0x3488, 0x3168, 0x38da, 0x2300, 0x39ca,
- 0x3aee, 0x3630, 0x387c, 0x31a8, 0x34e4, 0x38b8, 0x3a3e, 0x2dc0, 0x3640, 0x3130, 0x34ec, 0x3972, 0x36ec, 0x3318, 0x3950, 0x3714,
- 0x3914, 0x356c, 0x38b6, 0x376c, 0x2280, 0x3b9c, 0x39c8, 0x2d50, 0x35e8, 0x32c0, 0x3704, 0x388a, 0x3a64, 0x3558, 0x3bde, 0x3440,
- 0x3724, 0x3982, 0x28e0, 0x3ada, 0x375c, 0x3b30, 0x3300, 0x384a, 0x3a74, 0x38e8, 0x3b66, 0x2ee0, 0x385e, 0x3b46, 0x2f90, 0x3ab8,
- 0x3178, 0x3a52, 0x2e00, 0x3b08, 0x3918, 0x3150, 0x3678, 0x3aa6, 0x3922, 0x3b14, 0x2fd0, 0x3b8a, 0x2ce0, 0x39a4, 0x379c, 0x2fb0,
- 0x3b5a, 0x3240, 0x3a2e, 0x3390, 0x3916, 0x2e90, 0x36c4, 0x3be0, 0x349c, 0x2200, 0x3694, 0x39b2, 0x3478, 0x39f0, 0x35c4, 0x3828,
- 0x3be2, 0x36d4, 0x3994, 0x3548, 0x3328, 0x3a04, 0x3854, 0x3498, 0x28a0, 0x3810, 0x39fc, 0x3520, 0x3846, 0x32d8, 0x3ab4, 0x393c,
- 0x3864, 0x35b4, 0x380e, 0x3be4, 0x3570, 0x3a96, 0x39ac, 0x3090, 0x3962, 0x37c0, 0x3a9e, 0x3120, 0x3be6, 0x2a00, 0x38f6, 0x3410,
- 0x2180, 0x386e, 0x3088, 0x3b82, 0x37a8, 0x3ae6, 0x2f10, 0x3be8, 0x399a, 0x3634, 0x31e8, 0x3912, 0x3b06, 0x36f0, 0x2c30, 0x3504,
- 0x3a76, 0x2aa0, 0x39e8, 0x3040, 0x3878, 0x2880, 0x383a, 0x35f8, 0x3aec, 0x32a8, 0x3936, 0x3550, 0x3892, 0x3740, 0x3aea, 0x398c,
- 0x3a72, 0x34c4, 0x3a1c, 0x38ac, 0x2860, 0x3584, 0x38fa, 0x372c, 0x3388, 0x3a3a, 0x3b9e, 0x2100, 0x3420, 0x395a, 0x3bae, 0x37d8,
- 0x3398, 0x3b6c, 0x3734, 0x34d0, 0x39c0, 0x3b78, 0x3474, 0x3a2c, 0x2b80, 0x3830, 0x3b56, 0x2cb0, 0x3a78, 0x33b0, 0x3018, 0x3650,
- 0x30d0, 0x3b20, 0x3690, 0x3350, 0x39ae, 0x3a90, 0x3148, 0x3b44, 0x2cd0, 0x38a0, 0x355c, 0x382a, 0x3a8e, 0x35b8, 0x3190, 0x39ec,
- 0x38c4, 0x3068, 0x3938, 0x3b2e, 0x32c8, 0x3748, 0x3008, 0x3894, 0x3bb8, 0x3438, 0x36c8, 0x3904, 0x35fc, 0x396e, 0x3bac, 0x38a6,
- 0x397a, 0x37ec, 0x2ca0, 0x3bea, 0x3754, 0x34a4, 0x3836, 0x3956, 0x362c, 0x3b00, 0x30c0, 0x39a6, 0x2fc0, 0x38ae, 0x3abe, 0x2080,
- 0x3684, 0x3a70, 0x3568, 0x2000, 0x38c2, 0x3af0, 0x3998, 0x368c, 0x30b0, 0x39ba, 0x3aa8, 0x3200, 0x3b16, 0x2d80, 0x377c, 0x3480,
- 0x3b6e, 0x3270, 0x39fa, 0x386a, 0x2ff0, 0x3b10, 0x1f00, 0x3a44, 0x343c, 0x3802, 0x3a66, 0x34b8, 0x3bec, 0x3708, 0x3340, 0x3882,
- 0x3bee, 0x3298, 0x3806, 0x3a08, 0x3638, 0x2d00, 0x34ac, 0x3a60, 0x38ee, 0x35c8, 0x29c0, 0x380a, 0x34f0, 0x38f8, 0x3aac, 0x1e00,
- 0x3564, 0x38fe, 0x3468, 0x3ace, 0x35d0, 0x394a, 0x37b4, 0x31f8, 0x3bf0, 0x2bc0, 0x38d0, 0x36b8, 0x2940, 0x3926, 0x3b32, 0x35a8,
- 0x2d60, 0x38e0, 0x3b58, 0x3078, 0x3a9c, 0x37e4, 0x3bf2, 0x2e50, 0x33f0, 0x3b72, 0x38b4, 0x39e6, 0x3bf4, 0x3290, 0x3670, 0x3a1a,
- 0x3842, 0x3a68, 0x2920, 0x37c4, 0x32b8, 0x3b88, 0x34c0, 0x396a, 0x3664, 0x39b6, 0x3330, 0x3b5e, 0x39ce, 0x3484, 0x3080, 0x39aa,
- 0x3a4e, 0x3700, 0x34e8, 0x395e, 0x3310, 0x3908, 0x3588, 0x384e, 0x3ac6, 0x3730, 0x3220, 0x3574, 0x2de0, 0x37f0, 0x399c, 0x2ef0,
- 0x3188, 0x369c, 0x3bf6, 0x390a, 0x39f2, 0x2b60, 0x3872, 0x3aa0, 0x2df0, 0x3b0c, 0x37cc, 0x2da0, 0x382c, 0x3ae0, 0x38b0, 0x3788,
- 0x33c0, 0x3afa, 0x2ba0, 0x3826, 0x3b6a, 0x1d00, 0x39f8, 0x3108, 0x3920, 0x1c00, 0x3a26, 0x3b22, 0x38ec, 0x3ac2, 0x3458, 0x3b7c,
- 0x3a8c, 0x38a8, 0x34d8, 0x3048, 0x3654, 0x3adc, 0x3138, 0x3744, 0x3450, 0x38be, 0x34f4, 0x3a10, 0x3210, 0x35bc, 0x2840, 0x3b92,
- 0x3058, 0x3986, 0x3698, 0x39d8, 0x3434, 0x36f8, 0x3b18, 0x3524, 0x3a7a, 0x35d4, 0x3822, 0x3408, 0x36bc, 0x2ac0, 0x3896, 0x3624,
- 0x1a00, 0x3378, 0x3a16, 0x3b3a, 0x381e, 0x3338, 0x3906, 0x39f6, 0x3bf8, 0x3158, 0x3ad2, 0x36e0, 0x3bfa, 0x392e, 0x3a5c, 0x3648,
- 0x38dc, 0x34cc, 0x3bfc, 0x30c8, 0x3ab6, 0x3942, 0x32b0, 0x38a4, 0x2d10, 0x3b96, 0x394c, 0x2f80, 0x3bfe, 0x3966, 0x3258, 0x39be,
- 0x3bb0, 0x3928, 0x361c, 0x2c00, 0x3990, 0x3b8c, 0x3578, 0x2a80, 0x36cc, 0x3952, 0x1800, 0x388e, 0x33e0, 0x2f20, 0x384c, 0x31d8,
- 0x3a18, 0x1400, 0x3876, 0x358c, 0x383c, 0x2c20, 0x3b80, 0x3774, 0x3a36, 0x3470, 0x31f0, 0x3a0a, 0x3832, 0x3514, 0x3a6a, 0x37f4,
- 0x367c, 0x3028, 0x3ac8, 0x37b8, 0x34a0, 0x2f50, 0x3a5e, 0x3874, 0x3b36, 0x34fc, 0x3a6e, 0x35f0, 0x399e, 0x3aba, 0x3500, 0x3b74,
- 0x37c8, 0x3ac0, 0x398a, 0x3010, 0x3a7e, 0x3658, 0x38e4, 0x3030, 0x3608, 0x3860, 0x3af4, 0x3718, 0x29a0, 0x3b2c, 0x2eb0, 0x3424,
- 0x3a0e, 0x3820, 0x32f8, 0x3954, 0x3afc, 0x38c0, 0x36a4, 0x3370, 0x2e70, 0x38b2, 0x3180, 0x3ba8, 0x2c80, 0x3778, 0x390c, 0x2cf0,
- 0x35c0, 0x32e0, 0x36f4, 0x3b94, 0x3454, 0x39f4, 0x3348, 0x397e, 0x3b4e, 0x0000, 0x38fc, 0x34dc, 0x3a2a, 0x36a8, 0x393a, 0x3b54,
+ 0x2c90, 0x38f4, 0x3bba, 0x29e0, 0x35f4, 0x3230, 0x3bbc, 0x3924, 0x3a46, 0x3644, 0x39e2, 0x370c, 0x3444, 0x3b1a, 0x3140, 0x39d2,
+ 0x385a, 0x3b24, 0x2c10, 0x38c6, 0x3808, 0x2780, 0x3bbe, 0x37f8, 0x350c, 0x3a6c, 0x3368, 0x3bc0, 0x3000, 0x3886, 0x31b0, 0x3554,
+ 0x3a94, 0x3618, 0x3430, 0x3a34, 0x3834, 0x39fe, 0x2740, 0x3758, 0x3494, 0x3b7a, 0x2700, 0x3958, 0x3858, 0x3a24, 0x364c, 0x3bc2,
+ 0x3278, 0x3a22, 0x353c, 0x39de, 0x3268, 0x3a98, 0x36fc, 0x2ed0, 0x39e0, 0x30f0, 0x381a, 0x3996, 0x35ac, 0x3af2, 0x39b8, 0x37bc,
+ 0x3250, 0x39dc, 0x3800, 0x30e8, 0x3b42, 0x34d4, 0x3970, 0x3afe, 0x3020, 0x3898, 0x33e8, 0x3b34, 0x2e10, 0x3320, 0x391a, 0x26c0,
+ 0x3784, 0x38de, 0x3060, 0x3b5c, 0x3600, 0x38e6, 0x3490, 0x3b2a, 0x387a, 0x365c, 0x3b3c, 0x2be0, 0x37ac, 0x33d8, 0x2680, 0x3b98,
+ 0x38d6, 0x2a60, 0x3b7e, 0x391e, 0x36d0, 0x2fe0, 0x3812, 0x32a0, 0x3a84, 0x36b0, 0x3a50, 0x357c, 0x37dc, 0x3b68, 0x3594, 0x3aca,
+ 0x344c, 0x3a7c, 0x3674, 0x3884, 0x2d30, 0x3a48, 0x3170, 0x398e, 0x2900, 0x3a30, 0x34bc, 0x38ea, 0x3b70, 0x3a3c, 0x3852, 0x3460,
+ 0x3b04, 0x37a0, 0x351c, 0x2d40, 0x3a80, 0x394e, 0x3b84, 0x3614, 0x3900, 0x2b20, 0x396c, 0x31b8, 0x38ca, 0x3a0c, 0x3038, 0x385c,
+ 0x39a2, 0x2c70, 0x3ba2, 0x3464, 0x3992, 0x36dc, 0x3bc4, 0x3580, 0x3824, 0x32d0, 0x3abc, 0x2ec0, 0x3560, 0x30f8, 0x3974, 0x3610,
+ 0x3a12, 0x3110, 0x3aaa, 0x38a2, 0x35e4, 0x341c, 0x28c0, 0x3a02, 0x34a8, 0x3b60, 0x3790, 0x3aa2, 0x2c40, 0x346c, 0x373c, 0x3bc6,
+ 0x32f0, 0x37e8, 0x391c, 0x3100, 0x3af6, 0x2640, 0x3868, 0x3098, 0x3b3e, 0x3944, 0x3620, 0x3870, 0x39da, 0x374c, 0x3bc8, 0x2e20,
+ 0x3804, 0x3932, 0x3660, 0x3260, 0x3bca, 0x38ce, 0x3ade, 0x382e, 0x30a0, 0x389e, 0x33a0, 0x363c, 0x3b86, 0x3910, 0x3a58, 0x2820,
+ 0x36a0, 0x3b28, 0x34e0, 0x3a40, 0x3768, 0x3510, 0x3a54, 0x390e, 0x36e8, 0x2ae0, 0x3bcc, 0x31a0, 0x3aa4, 0x2600, 0x38cc, 0x3400,
+ 0x3ac4, 0x2800, 0x3b4a, 0x39ee, 0x2cc0, 0x3764, 0x31c8, 0x35cc, 0x3bb6, 0x39a8, 0x2f30, 0x3a1e, 0x3816, 0x3160, 0x35b0, 0x389a,
+ 0x3a86, 0x3070, 0x3848, 0x2d70, 0x38ba, 0x3baa, 0x2e60, 0x3414, 0x3ae4, 0x3544, 0x3a06, 0x37fc, 0x347c, 0x36d8, 0x3b12, 0x35a4,
+ 0x3248, 0x3866, 0x34f8, 0x3814, 0x33f8, 0x39c2, 0x3a8a, 0x38e2, 0x25c0, 0x3720, 0x3b26, 0x3508, 0x2980, 0x39b4, 0x3b4c, 0x33a8,
+ 0x3976, 0x3534, 0x39c4, 0x3b40, 0x3604, 0x31c0, 0x397c, 0x37b0, 0x39d0, 0x3218, 0x38d8, 0x2e30, 0x3b52, 0x39bc, 0x2fa0, 0x3980,
+ 0x3b9a, 0x39d4, 0x2f40, 0x3960, 0x3b64, 0x3680, 0x2f60, 0x34c8, 0x3acc, 0x3228, 0x3850, 0x395c, 0x3bce, 0x354c, 0x3840, 0x2db0,
+ 0x37a4, 0x3bd0, 0x2580, 0x33c8, 0x392a, 0x3a82, 0x3530, 0x3b48, 0x2540, 0x3760, 0x3a42, 0x35dc, 0x3890, 0x3308, 0x3844, 0x3710,
+ 0x3418, 0x366c, 0x3a9a, 0x3590, 0x2500, 0x3888, 0x3bd2, 0x3984, 0x3668, 0x39e4, 0x345c, 0x2d20, 0x371c, 0x3288, 0x3aae, 0x39d6,
+ 0x31e0, 0x38c8, 0x36e4, 0x3ab2, 0x380c, 0x2b00, 0x389c, 0x3280, 0x392c, 0x3bd4, 0x33b8, 0x3ad6, 0x24c0, 0x3bd6, 0x3a32, 0x2c60,
+ 0x3b1c, 0x38aa, 0x3238, 0x3902, 0x3ae8, 0x3528, 0x3118, 0x3818, 0x2c50, 0x3ba0, 0x38bc, 0x3ad8, 0x3a20, 0x38f0, 0x2480, 0x36b4,
+ 0x3b02, 0x34b0, 0x3a00, 0x30a8, 0x3518, 0x3bd8, 0x3688, 0x3a92, 0x34b4, 0x36c0, 0x2f70, 0x3968, 0x3798, 0x3448, 0x35ec, 0x3930,
+ 0x3750, 0x2a40, 0x3bda, 0x3728, 0x32e8, 0x3a4a, 0x38d2, 0x3b38, 0x33d0, 0x3738, 0x30b8, 0x3628, 0x340c, 0x37d4, 0x3bb2, 0x3428,
+ 0x3934, 0x2b40, 0x3856, 0x3b0e, 0x3964, 0x31d0, 0x39b0, 0x2e80, 0x38d4, 0x3b1e, 0x3a28, 0x387e, 0x30e0, 0x39a0, 0x3ae2, 0x3208,
+ 0x3a56, 0x352c, 0x3a14, 0x2d90, 0x3978, 0x3794, 0x2960, 0x35e0, 0x39c6, 0x3a88, 0x3862, 0x3b76, 0x2e40, 0x3988, 0x3128, 0x3a4c,
+ 0x378c, 0x3b8e, 0x359c, 0x2ea0, 0x36ac, 0x383e, 0x3af8, 0x3404, 0x3780, 0x2a20, 0x3360, 0x3598, 0x3b90, 0x37d0, 0x2dd0, 0x3880,
+ 0x3358, 0x3946, 0x381c, 0x348c, 0x3b50, 0x3198, 0x3ad4, 0x3940, 0x3050, 0x3540, 0x2440, 0x39cc, 0x3770, 0x3b0a, 0x35d8, 0x386c,
+ 0x2f00, 0x3380, 0x3a5a, 0x3948, 0x3ba4, 0x2400, 0x35a0, 0x393e, 0x3ba6, 0x39ea, 0x3838, 0x3ab0, 0x27c0, 0x3a38, 0x3538, 0x3bb4,
+ 0x2380, 0x3b62, 0x30d8, 0x3a62, 0x360c, 0x388c, 0x342c, 0x37e0, 0x3bdc, 0x38f2, 0x3ad0, 0x3488, 0x3168, 0x38da, 0x2300, 0x39ca,
+ 0x3aee, 0x3630, 0x387c, 0x31a8, 0x34e4, 0x38b8, 0x3a3e, 0x2dc0, 0x3640, 0x3130, 0x34ec, 0x3972, 0x36ec, 0x3318, 0x3950, 0x3714,
+ 0x3914, 0x356c, 0x38b6, 0x376c, 0x2280, 0x3b9c, 0x39c8, 0x2d50, 0x35e8, 0x32c0, 0x3704, 0x388a, 0x3a64, 0x3558, 0x3bde, 0x3440,
+ 0x3724, 0x3982, 0x28e0, 0x3ada, 0x375c, 0x3b30, 0x3300, 0x384a, 0x3a74, 0x38e8, 0x3b66, 0x2ee0, 0x385e, 0x3b46, 0x2f90, 0x3ab8,
+ 0x3178, 0x3a52, 0x2e00, 0x3b08, 0x3918, 0x3150, 0x3678, 0x3aa6, 0x3922, 0x3b14, 0x2fd0, 0x3b8a, 0x2ce0, 0x39a4, 0x379c, 0x2fb0,
+ 0x3b5a, 0x3240, 0x3a2e, 0x3390, 0x3916, 0x2e90, 0x36c4, 0x3be0, 0x349c, 0x2200, 0x3694, 0x39b2, 0x3478, 0x39f0, 0x35c4, 0x3828,
+ 0x3be2, 0x36d4, 0x3994, 0x3548, 0x3328, 0x3a04, 0x3854, 0x3498, 0x28a0, 0x3810, 0x39fc, 0x3520, 0x3846, 0x32d8, 0x3ab4, 0x393c,
+ 0x3864, 0x35b4, 0x380e, 0x3be4, 0x3570, 0x3a96, 0x39ac, 0x3090, 0x3962, 0x37c0, 0x3a9e, 0x3120, 0x3be6, 0x2a00, 0x38f6, 0x3410,
+ 0x2180, 0x386e, 0x3088, 0x3b82, 0x37a8, 0x3ae6, 0x2f10, 0x3be8, 0x399a, 0x3634, 0x31e8, 0x3912, 0x3b06, 0x36f0, 0x2c30, 0x3504,
+ 0x3a76, 0x2aa0, 0x39e8, 0x3040, 0x3878, 0x2880, 0x383a, 0x35f8, 0x3aec, 0x32a8, 0x3936, 0x3550, 0x3892, 0x3740, 0x3aea, 0x398c,
+ 0x3a72, 0x34c4, 0x3a1c, 0x38ac, 0x2860, 0x3584, 0x38fa, 0x372c, 0x3388, 0x3a3a, 0x3b9e, 0x2100, 0x3420, 0x395a, 0x3bae, 0x37d8,
+ 0x3398, 0x3b6c, 0x3734, 0x34d0, 0x39c0, 0x3b78, 0x3474, 0x3a2c, 0x2b80, 0x3830, 0x3b56, 0x2cb0, 0x3a78, 0x33b0, 0x3018, 0x3650,
+ 0x30d0, 0x3b20, 0x3690, 0x3350, 0x39ae, 0x3a90, 0x3148, 0x3b44, 0x2cd0, 0x38a0, 0x355c, 0x382a, 0x3a8e, 0x35b8, 0x3190, 0x39ec,
+ 0x38c4, 0x3068, 0x3938, 0x3b2e, 0x32c8, 0x3748, 0x3008, 0x3894, 0x3bb8, 0x3438, 0x36c8, 0x3904, 0x35fc, 0x396e, 0x3bac, 0x38a6,
+ 0x397a, 0x37ec, 0x2ca0, 0x3bea, 0x3754, 0x34a4, 0x3836, 0x3956, 0x362c, 0x3b00, 0x30c0, 0x39a6, 0x2fc0, 0x38ae, 0x3abe, 0x2080,
+ 0x3684, 0x3a70, 0x3568, 0x2000, 0x38c2, 0x3af0, 0x3998, 0x368c, 0x30b0, 0x39ba, 0x3aa8, 0x3200, 0x3b16, 0x2d80, 0x377c, 0x3480,
+ 0x3b6e, 0x3270, 0x39fa, 0x386a, 0x2ff0, 0x3b10, 0x1f00, 0x3a44, 0x343c, 0x3802, 0x3a66, 0x34b8, 0x3bec, 0x3708, 0x3340, 0x3882,
+ 0x3bee, 0x3298, 0x3806, 0x3a08, 0x3638, 0x2d00, 0x34ac, 0x3a60, 0x38ee, 0x35c8, 0x29c0, 0x380a, 0x34f0, 0x38f8, 0x3aac, 0x1e00,
+ 0x3564, 0x38fe, 0x3468, 0x3ace, 0x35d0, 0x394a, 0x37b4, 0x31f8, 0x3bf0, 0x2bc0, 0x38d0, 0x36b8, 0x2940, 0x3926, 0x3b32, 0x35a8,
+ 0x2d60, 0x38e0, 0x3b58, 0x3078, 0x3a9c, 0x37e4, 0x3bf2, 0x2e50, 0x33f0, 0x3b72, 0x38b4, 0x39e6, 0x3bf4, 0x3290, 0x3670, 0x3a1a,
+ 0x3842, 0x3a68, 0x2920, 0x37c4, 0x32b8, 0x3b88, 0x34c0, 0x396a, 0x3664, 0x39b6, 0x3330, 0x3b5e, 0x39ce, 0x3484, 0x3080, 0x39aa,
+ 0x3a4e, 0x3700, 0x34e8, 0x395e, 0x3310, 0x3908, 0x3588, 0x384e, 0x3ac6, 0x3730, 0x3220, 0x3574, 0x2de0, 0x37f0, 0x399c, 0x2ef0,
+ 0x3188, 0x369c, 0x3bf6, 0x390a, 0x39f2, 0x2b60, 0x3872, 0x3aa0, 0x2df0, 0x3b0c, 0x37cc, 0x2da0, 0x382c, 0x3ae0, 0x38b0, 0x3788,
+ 0x33c0, 0x3afa, 0x2ba0, 0x3826, 0x3b6a, 0x1d00, 0x39f8, 0x3108, 0x3920, 0x1c00, 0x3a26, 0x3b22, 0x38ec, 0x3ac2, 0x3458, 0x3b7c,
+ 0x3a8c, 0x38a8, 0x34d8, 0x3048, 0x3654, 0x3adc, 0x3138, 0x3744, 0x3450, 0x38be, 0x34f4, 0x3a10, 0x3210, 0x35bc, 0x2840, 0x3b92,
+ 0x3058, 0x3986, 0x3698, 0x39d8, 0x3434, 0x36f8, 0x3b18, 0x3524, 0x3a7a, 0x35d4, 0x3822, 0x3408, 0x36bc, 0x2ac0, 0x3896, 0x3624,
+ 0x1a00, 0x3378, 0x3a16, 0x3b3a, 0x381e, 0x3338, 0x3906, 0x39f6, 0x3bf8, 0x3158, 0x3ad2, 0x36e0, 0x3bfa, 0x392e, 0x3a5c, 0x3648,
+ 0x38dc, 0x34cc, 0x3bfc, 0x30c8, 0x3ab6, 0x3942, 0x32b0, 0x38a4, 0x2d10, 0x3b96, 0x394c, 0x2f80, 0x3bfe, 0x3966, 0x3258, 0x39be,
+ 0x3bb0, 0x3928, 0x361c, 0x2c00, 0x3990, 0x3b8c, 0x3578, 0x2a80, 0x36cc, 0x3952, 0x1800, 0x388e, 0x33e0, 0x2f20, 0x384c, 0x31d8,
+ 0x3a18, 0x1400, 0x3876, 0x358c, 0x383c, 0x2c20, 0x3b80, 0x3774, 0x3a36, 0x3470, 0x31f0, 0x3a0a, 0x3832, 0x3514, 0x3a6a, 0x37f4,
+ 0x367c, 0x3028, 0x3ac8, 0x37b8, 0x34a0, 0x2f50, 0x3a5e, 0x3874, 0x3b36, 0x34fc, 0x3a6e, 0x35f0, 0x399e, 0x3aba, 0x3500, 0x3b74,
+ 0x37c8, 0x3ac0, 0x398a, 0x3010, 0x3a7e, 0x3658, 0x38e4, 0x3030, 0x3608, 0x3860, 0x3af4, 0x3718, 0x29a0, 0x3b2c, 0x2eb0, 0x3424,
+ 0x3a0e, 0x3820, 0x32f8, 0x3954, 0x3afc, 0x38c0, 0x36a4, 0x3370, 0x2e70, 0x38b2, 0x3180, 0x3ba8, 0x2c80, 0x3778, 0x390c, 0x2cf0,
+ 0x35c0, 0x32e0, 0x36f4, 0x3b94, 0x3454, 0x39f4, 0x3348, 0x397e, 0x3b4e, 0x0000, 0x38fc, 0x34dc, 0x3a2a, 0x36a8, 0x393a, 0x3b54,
};
diff --git a/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.cpp
index 2764fcb81..04ffbb083 100644
--- a/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.cpp
@@ -29,15 +29,15 @@
#include "../../transform/MPCVideoDec/MPCVideoDecFilter.h"
-#if (0) // Set to 1 to activate EVR traces
-#define TRACE_EVR TRACE
+#if (0) // Set to 1 to activate EVR traces
+#define TRACE_EVR TRACE
#else
-#define TRACE_EVR __noop
+#define TRACE_EVR __noop
#endif
typedef enum {
- MSG_MIXERIN,
- MSG_MIXEROUT
+ MSG_MIXERIN,
+ MSG_MIXEROUT
} EVR_STATS_MSG;
// Guid to tag IMFSample with DirectX surface index
@@ -49,2558 +49,2558 @@ static const GUID GUID_SURFACE_INDEX = { 0x30c8e9f6, 0x415, 0x4b81, { 0xa3, 0x15
MFOffset MakeOffset(float v)
{
- MFOffset offset;
- offset.value = short(v);
- offset.fract = WORD(65536 * (v-offset.value));
- return offset;
+ MFOffset offset;
+ offset.value = short(v);
+ offset.fract = WORD(65536 * (v - offset.value));
+ return offset;
}
MFVideoArea MakeArea(float x, float y, DWORD width, DWORD height)
{
- MFVideoArea area;
- area.OffsetX = MakeOffset(x);
- area.OffsetY = MakeOffset(y);
- area.Area.cx = width;
- area.Area.cy = height;
- return area;
+ MFVideoArea area;
+ area.OffsetX = MakeOffset(x);
+ area.OffsetY = MakeOffset(y);
+ area.Area.cx = width;
+ area.Area.cy = height;
+ return area;
}
using namespace DSObjects;
-CEVRAllocatorPresenter::CEVRAllocatorPresenter(HWND hWnd, bool bFullscreen, HRESULT& hr, CString &_Error)
- : CDX9AllocatorPresenter(hWnd, bFullscreen, hr, true, _Error)
-{
- HMODULE hLib;
- CRenderersSettings& s = GetRenderersSettings();
-
- m_nResetToken = 0;
- m_hThread = INVALID_HANDLE_VALUE;
- m_hGetMixerThread= INVALID_HANDLE_VALUE;
- m_hEvtFlush = INVALID_HANDLE_VALUE;
- m_hEvtQuit = INVALID_HANDLE_VALUE;
- m_bEvtQuit = 0;
- m_bEvtFlush = 0;
- m_ModeratedTime = 0;
- m_ModeratedTimeLast = -1;
- m_ModeratedClockLast = -1;
-
- if (FAILED (hr)) {
- _Error += L"DX9AllocatorPresenter failed\n";
- return;
- }
-
- // Load EVR specifics DLLs
- hLib = LoadLibrary (L"dxva2.dll");
- pfDXVA2CreateDirect3DDeviceManager9 = hLib ? (PTR_DXVA2CreateDirect3DDeviceManager9) GetProcAddress (hLib, "DXVA2CreateDirect3DDeviceManager9") : NULL;
-
- // Load EVR functions
- hLib = LoadLibrary (L"evr.dll");
- pfMFCreateDXSurfaceBuffer = hLib ? (PTR_MFCreateDXSurfaceBuffer) GetProcAddress (hLib, "MFCreateDXSurfaceBuffer") : NULL;
- pfMFCreateVideoSampleFromSurface = hLib ? (PTR_MFCreateVideoSampleFromSurface) GetProcAddress (hLib, "MFCreateVideoSampleFromSurface") : NULL;
- pfMFCreateVideoMediaType = hLib ? (PTR_MFCreateVideoMediaType) GetProcAddress (hLib, "MFCreateVideoMediaType") : NULL;
-
- if (!pfDXVA2CreateDirect3DDeviceManager9 || !pfMFCreateDXSurfaceBuffer || !pfMFCreateVideoSampleFromSurface || !pfMFCreateVideoMediaType) {
- if (!pfDXVA2CreateDirect3DDeviceManager9) {
- _Error += L"Could not find DXVA2CreateDirect3DDeviceManager9 (dxva2.dll)\n";
- }
- if (!pfMFCreateDXSurfaceBuffer) {
- _Error += L"Could not find MFCreateDXSurfaceBuffer (evr.dll)\n";
- }
- if (!pfMFCreateVideoSampleFromSurface) {
- _Error += L"Could not find MFCreateVideoSampleFromSurface (evr.dll)\n";
- }
- if (!pfMFCreateVideoMediaType) {
- _Error += L"Could not find MFCreateVideoMediaType (evr.dll)\n";
- }
- hr = E_FAIL;
- return;
- }
-
- // Load mfplat fuctions
+CEVRAllocatorPresenter::CEVRAllocatorPresenter(HWND hWnd, bool bFullscreen, HRESULT& hr, CString& _Error)
+ : CDX9AllocatorPresenter(hWnd, bFullscreen, hr, true, _Error)
+{
+ HMODULE hLib;
+ CRenderersSettings& s = GetRenderersSettings();
+
+ m_nResetToken = 0;
+ m_hThread = INVALID_HANDLE_VALUE;
+ m_hGetMixerThread = INVALID_HANDLE_VALUE;
+ m_hEvtFlush = INVALID_HANDLE_VALUE;
+ m_hEvtQuit = INVALID_HANDLE_VALUE;
+ m_bEvtQuit = 0;
+ m_bEvtFlush = 0;
+ m_ModeratedTime = 0;
+ m_ModeratedTimeLast = -1;
+ m_ModeratedClockLast = -1;
+
+ if (FAILED(hr)) {
+ _Error += L"DX9AllocatorPresenter failed\n";
+ return;
+ }
+
+ // Load EVR specifics DLLs
+ hLib = LoadLibrary(L"dxva2.dll");
+ pfDXVA2CreateDirect3DDeviceManager9 = hLib ? (PTR_DXVA2CreateDirect3DDeviceManager9) GetProcAddress(hLib, "DXVA2CreateDirect3DDeviceManager9") : NULL;
+
+ // Load EVR functions
+ hLib = LoadLibrary(L"evr.dll");
+ pfMFCreateDXSurfaceBuffer = hLib ? (PTR_MFCreateDXSurfaceBuffer) GetProcAddress(hLib, "MFCreateDXSurfaceBuffer") : NULL;
+ pfMFCreateVideoSampleFromSurface = hLib ? (PTR_MFCreateVideoSampleFromSurface) GetProcAddress(hLib, "MFCreateVideoSampleFromSurface") : NULL;
+ pfMFCreateVideoMediaType = hLib ? (PTR_MFCreateVideoMediaType) GetProcAddress(hLib, "MFCreateVideoMediaType") : NULL;
+
+ if (!pfDXVA2CreateDirect3DDeviceManager9 || !pfMFCreateDXSurfaceBuffer || !pfMFCreateVideoSampleFromSurface || !pfMFCreateVideoMediaType) {
+ if (!pfDXVA2CreateDirect3DDeviceManager9) {
+ _Error += L"Could not find DXVA2CreateDirect3DDeviceManager9 (dxva2.dll)\n";
+ }
+ if (!pfMFCreateDXSurfaceBuffer) {
+ _Error += L"Could not find MFCreateDXSurfaceBuffer (evr.dll)\n";
+ }
+ if (!pfMFCreateVideoSampleFromSurface) {
+ _Error += L"Could not find MFCreateVideoSampleFromSurface (evr.dll)\n";
+ }
+ if (!pfMFCreateVideoMediaType) {
+ _Error += L"Could not find MFCreateVideoMediaType (evr.dll)\n";
+ }
+ hr = E_FAIL;
+ return;
+ }
+
+ // Load mfplat fuctions
#if 0
- hLib = LoadLibrary (L"mfplat.dll");
- (FARPROC &)pMFCreateMediaType = GetProcAddress(hLib, "MFCreateMediaType");
- (FARPROC &)pMFInitMediaTypeFromAMMediaType = GetProcAddress(hLib, "MFInitMediaTypeFromAMMediaType");
- (FARPROC &)pMFInitAMMediaTypeFromMFMediaType = GetProcAddress(hLib, "MFInitAMMediaTypeFromMFMediaType");
-
- if (!pMFCreateMediaType || !pMFInitMediaTypeFromAMMediaType || !pMFInitAMMediaTypeFromMFMediaType) {
- hr = E_FAIL;
- return;
- }
+ hLib = LoadLibrary(L"mfplat.dll");
+ (FARPROC&)pMFCreateMediaType = GetProcAddress(hLib, "MFCreateMediaType");
+ (FARPROC&)pMFInitMediaTypeFromAMMediaType = GetProcAddress(hLib, "MFInitMediaTypeFromAMMediaType");
+ (FARPROC&)pMFInitAMMediaTypeFromMFMediaType = GetProcAddress(hLib, "MFInitAMMediaTypeFromMFMediaType");
+
+ if (!pMFCreateMediaType || !pMFInitMediaTypeFromAMMediaType || !pMFInitAMMediaTypeFromMFMediaType) {
+ hr = E_FAIL;
+ return;
+ }
#endif
- // Load Vista specifics DLLs
- hLib = LoadLibrary (L"avrt.dll");
- pfAvSetMmThreadCharacteristicsW = hLib ? (PTR_AvSetMmThreadCharacteristicsW) GetProcAddress (hLib, "AvSetMmThreadCharacteristicsW") : NULL;
- pfAvSetMmThreadPriority = hLib ? (PTR_AvSetMmThreadPriority) GetProcAddress (hLib, "AvSetMmThreadPriority") : NULL;
- pfAvRevertMmThreadCharacteristics = hLib ? (PTR_AvRevertMmThreadCharacteristics) GetProcAddress (hLib, "AvRevertMmThreadCharacteristics") : NULL;
-
- // Init DXVA manager
- hr = pfDXVA2CreateDirect3DDeviceManager9(&m_nResetToken, &m_pD3DManager);
- if (SUCCEEDED (hr)) {
- hr = m_pD3DManager->ResetDevice(m_pD3DDev, m_nResetToken);
- if (!SUCCEEDED (hr)) {
- _Error += L"m_pD3DManager->ResetDevice failed\n";
- }
- } else {
- _Error += L"DXVA2CreateDirect3DDeviceManager9 failed\n";
- }
-
- CComPtr<IDirectXVideoDecoderService> pDecoderService;
- HANDLE hDevice;
- if (SUCCEEDED (m_pD3DManager->OpenDeviceHandle(&hDevice)) &&
- SUCCEEDED (m_pD3DManager->GetVideoService (hDevice, __uuidof(IDirectXVideoDecoderService), (void**)&pDecoderService))) {
- TRACE_EVR ("EVR: DXVA2 : device handle = 0x%08x", hDevice);
- HookDirectXVideoDecoderService (pDecoderService);
-
- m_pD3DManager->CloseDeviceHandle (hDevice);
- }
-
-
- // Bufferize frame only with 3D texture!
- if (s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) {
- m_nNbDXSurface = max (min (s.iEvrBuffers, MAX_VIDEO_SURFACES), 4);
- } else {
- m_nNbDXSurface = 1;
- }
-
- ResetStats();
- m_nRenderState = Shutdown;
- m_fUseInternalTimer = false;
- m_LastSetOutputRange = -1;
- m_bPendingRenegotiate = false;
- m_bPendingMediaFinished = false;
- m_bWaitingSample = false;
- m_pCurrentDisplaydSample = NULL;
- m_nStepCount = 0;
- m_dwVideoAspectRatioMode = MFVideoARMode_PreservePicture;
- m_dwVideoRenderPrefs = (MFVideoRenderPrefs)0;
- m_BorderColor = RGB (0,0,0);
- m_bSignaledStarvation = false;
- m_StarvationClock = 0;
- m_pOuterEVR = NULL;
- m_LastScheduledSampleTime = -1;
- m_LastScheduledUncorrectedSampleTime = -1;
- m_MaxSampleDuration = 0;
- m_LastSampleOffset = 0;
- ZeroMemory(m_VSyncOffsetHistory, sizeof(m_VSyncOffsetHistory));
- m_VSyncOffsetHistoryPos = 0;
- m_bLastSampleOffsetValid = false;
+ // Load Vista specifics DLLs
+ hLib = LoadLibrary(L"avrt.dll");
+ pfAvSetMmThreadCharacteristicsW = hLib ? (PTR_AvSetMmThreadCharacteristicsW) GetProcAddress(hLib, "AvSetMmThreadCharacteristicsW") : NULL;
+ pfAvSetMmThreadPriority = hLib ? (PTR_AvSetMmThreadPriority) GetProcAddress(hLib, "AvSetMmThreadPriority") : NULL;
+ pfAvRevertMmThreadCharacteristics = hLib ? (PTR_AvRevertMmThreadCharacteristics) GetProcAddress(hLib, "AvRevertMmThreadCharacteristics") : NULL;
+
+ // Init DXVA manager
+ hr = pfDXVA2CreateDirect3DDeviceManager9(&m_nResetToken, &m_pD3DManager);
+ if (SUCCEEDED(hr)) {
+ hr = m_pD3DManager->ResetDevice(m_pD3DDev, m_nResetToken);
+ if (!SUCCEEDED(hr)) {
+ _Error += L"m_pD3DManager->ResetDevice failed\n";
+ }
+ } else {
+ _Error += L"DXVA2CreateDirect3DDeviceManager9 failed\n";
+ }
+
+ CComPtr<IDirectXVideoDecoderService> pDecoderService;
+ HANDLE hDevice;
+ if (SUCCEEDED(m_pD3DManager->OpenDeviceHandle(&hDevice)) &&
+ SUCCEEDED(m_pD3DManager->GetVideoService(hDevice, __uuidof(IDirectXVideoDecoderService), (void**)&pDecoderService))) {
+ TRACE_EVR("EVR: DXVA2 : device handle = 0x%08x", hDevice);
+ HookDirectXVideoDecoderService(pDecoderService);
+
+ m_pD3DManager->CloseDeviceHandle(hDevice);
+ }
+
+
+ // Bufferize frame only with 3D texture!
+ if (s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) {
+ m_nNbDXSurface = max(min(s.iEvrBuffers, MAX_VIDEO_SURFACES), 4);
+ } else {
+ m_nNbDXSurface = 1;
+ }
+
+ ResetStats();
+ m_nRenderState = Shutdown;
+ m_fUseInternalTimer = false;
+ m_LastSetOutputRange = -1;
+ m_bPendingRenegotiate = false;
+ m_bPendingMediaFinished = false;
+ m_bWaitingSample = false;
+ m_pCurrentDisplaydSample = NULL;
+ m_nStepCount = 0;
+ m_dwVideoAspectRatioMode = MFVideoARMode_PreservePicture;
+ m_dwVideoRenderPrefs = (MFVideoRenderPrefs)0;
+ m_BorderColor = RGB(0, 0, 0);
+ m_bSignaledStarvation = false;
+ m_StarvationClock = 0;
+ m_pOuterEVR = NULL;
+ m_LastScheduledSampleTime = -1;
+ m_LastScheduledUncorrectedSampleTime = -1;
+ m_MaxSampleDuration = 0;
+ m_LastSampleOffset = 0;
+ ZeroMemory(m_VSyncOffsetHistory, sizeof(m_VSyncOffsetHistory));
+ m_VSyncOffsetHistoryPos = 0;
+ m_bLastSampleOffsetValid = false;
}
CEVRAllocatorPresenter::~CEVRAllocatorPresenter(void)
{
- StopWorkerThreads(); // If not already done...
- m_pMediaType = NULL;
- m_pClock = NULL;
+ StopWorkerThreads(); // If not already done...
+ m_pMediaType = NULL;
+ m_pClock = NULL;
- m_pD3DManager = NULL;
+ m_pD3DManager = NULL;
}
void CEVRAllocatorPresenter::ResetStats()
{
- m_pcFrames = 0;
- m_nDroppedUpdate = 0;
- m_pcFramesDrawn = 0;
- m_piAvg = 0;
- m_piDev = 0;
+ m_pcFrames = 0;
+ m_nDroppedUpdate = 0;
+ m_pcFramesDrawn = 0;
+ m_piAvg = 0;
+ m_piDev = 0;
}
HRESULT CEVRAllocatorPresenter::CheckShutdown() const
{
- if (m_nRenderState == Shutdown) {
- return MF_E_SHUTDOWN;
- } else {
- return S_OK;
- }
+ if (m_nRenderState == Shutdown) {
+ return MF_E_SHUTDOWN;
+ } else {
+ return S_OK;
+ }
}
void CEVRAllocatorPresenter::StartWorkerThreads()
{
- DWORD dwThreadId;
+ DWORD dwThreadId;
- if (m_nRenderState == Shutdown) {
- m_hEvtQuit = CreateEvent (NULL, TRUE, FALSE, NULL);
- m_hEvtFlush = CreateEvent (NULL, TRUE, FALSE, NULL);
+ if (m_nRenderState == Shutdown) {
+ m_hEvtQuit = CreateEvent(NULL, TRUE, FALSE, NULL);
+ m_hEvtFlush = CreateEvent(NULL, TRUE, FALSE, NULL);
- m_hThread = ::CreateThread(NULL, 0, PresentThread, (LPVOID)this, 0, &dwThreadId);
- SetThreadPriority(m_hThread, THREAD_PRIORITY_TIME_CRITICAL);
- m_hGetMixerThread = ::CreateThread(NULL, 0, GetMixerThreadStatic, (LPVOID)this, 0, &dwThreadId);
- SetThreadPriority(m_hGetMixerThread, THREAD_PRIORITY_HIGHEST);
+ m_hThread = ::CreateThread(NULL, 0, PresentThread, (LPVOID)this, 0, &dwThreadId);
+ SetThreadPriority(m_hThread, THREAD_PRIORITY_TIME_CRITICAL);
+ m_hGetMixerThread = ::CreateThread(NULL, 0, GetMixerThreadStatic, (LPVOID)this, 0, &dwThreadId);
+ SetThreadPriority(m_hGetMixerThread, THREAD_PRIORITY_HIGHEST);
- m_nRenderState = Stopped;
- TRACE_EVR ("EVR: Worker threads started...\n");
- }
+ m_nRenderState = Stopped;
+ TRACE_EVR("EVR: Worker threads started...\n");
+ }
}
void CEVRAllocatorPresenter::StopWorkerThreads()
{
- if (m_nRenderState != Shutdown) {
- SetEvent (m_hEvtFlush);
- m_bEvtFlush = true;
- SetEvent (m_hEvtQuit);
- m_bEvtQuit = true;
- if ((m_hThread != INVALID_HANDLE_VALUE) && (WaitForSingleObject (m_hThread, 10000) == WAIT_TIMEOUT)) {
- ASSERT (FALSE);
- TerminateThread (m_hThread, 0xDEAD);
- }
- if ((m_hGetMixerThread != INVALID_HANDLE_VALUE) && (WaitForSingleObject (m_hGetMixerThread, 10000) == WAIT_TIMEOUT)) {
- ASSERT (FALSE);
- TerminateThread (m_hGetMixerThread, 0xDEAD);
- }
-
- if (m_hThread != INVALID_HANDLE_VALUE) {
- CloseHandle (m_hThread);
- }
- if (m_hGetMixerThread != INVALID_HANDLE_VALUE) {
- CloseHandle (m_hGetMixerThread);
- }
- if (m_hEvtFlush != INVALID_HANDLE_VALUE) {
- CloseHandle (m_hEvtFlush);
- }
- if (m_hEvtQuit != INVALID_HANDLE_VALUE) {
- CloseHandle (m_hEvtQuit);
- }
-
- m_bEvtFlush = false;
- m_bEvtQuit = false;
-
-
- TRACE_EVR ("EVR: Worker threads stopped...\n");
- }
- m_nRenderState = Shutdown;
+ if (m_nRenderState != Shutdown) {
+ SetEvent(m_hEvtFlush);
+ m_bEvtFlush = true;
+ SetEvent(m_hEvtQuit);
+ m_bEvtQuit = true;
+ if ((m_hThread != INVALID_HANDLE_VALUE) && (WaitForSingleObject(m_hThread, 10000) == WAIT_TIMEOUT)) {
+ ASSERT(FALSE);
+ TerminateThread(m_hThread, 0xDEAD);
+ }
+ if ((m_hGetMixerThread != INVALID_HANDLE_VALUE) && (WaitForSingleObject(m_hGetMixerThread, 10000) == WAIT_TIMEOUT)) {
+ ASSERT(FALSE);
+ TerminateThread(m_hGetMixerThread, 0xDEAD);
+ }
+
+ if (m_hThread != INVALID_HANDLE_VALUE) {
+ CloseHandle(m_hThread);
+ }
+ if (m_hGetMixerThread != INVALID_HANDLE_VALUE) {
+ CloseHandle(m_hGetMixerThread);
+ }
+ if (m_hEvtFlush != INVALID_HANDLE_VALUE) {
+ CloseHandle(m_hEvtFlush);
+ }
+ if (m_hEvtQuit != INVALID_HANDLE_VALUE) {
+ CloseHandle(m_hEvtQuit);
+ }
+
+ m_bEvtFlush = false;
+ m_bEvtQuit = false;
+
+
+ TRACE_EVR("EVR: Worker threads stopped...\n");
+ }
+ m_nRenderState = Shutdown;
}
STDMETHODIMP CEVRAllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
{
- CheckPointer(ppRenderer, E_POINTER);
+ CheckPointer(ppRenderer, E_POINTER);
- *ppRenderer = NULL;
+ *ppRenderer = NULL;
- HRESULT hr = E_FAIL;
+ HRESULT hr = E_FAIL;
- do {
- CMacrovisionKicker* pMK = DNew CMacrovisionKicker(NAME("CMacrovisionKicker"), NULL);
- CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)pMK;
+ do {
+ CMacrovisionKicker* pMK = DNew CMacrovisionKicker(NAME("CMacrovisionKicker"), NULL);
+ CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)pMK;
- COuterEVR *pOuterEVR = DNew COuterEVR(NAME("COuterEVR"), pUnk, hr, &m_VMR9AlphaBitmap, this);
- m_pOuterEVR = pOuterEVR;
+ COuterEVR* pOuterEVR = DNew COuterEVR(NAME("COuterEVR"), pUnk, hr, &m_VMR9AlphaBitmap, this);
+ m_pOuterEVR = pOuterEVR;
- pMK->SetInner((IUnknown*)(INonDelegatingUnknown*)pOuterEVR);
- CComQIPtr<IBaseFilter> pBF = pUnk;
+ pMK->SetInner((IUnknown*)(INonDelegatingUnknown*)pOuterEVR);
+ CComQIPtr<IBaseFilter> pBF = pUnk;
- if (FAILED (hr)) {
- break;
- }
+ if (FAILED(hr)) {
+ break;
+ }
- // Set EVR custom presenter
- CComPtr<IMFVideoPresenter> pVP;
- CComPtr<IMFVideoRenderer> pMFVR;
- CComQIPtr<IMFGetService, &__uuidof(IMFGetService)> pMFGS = pBF;
- CComQIPtr<IEVRFilterConfig> pConfig = pBF;
- if (SUCCEEDED(hr)) {
- if (FAILED(pConfig->SetNumberOfStreams(3))) { // TODO - maybe need other number of input stream ...
- break;
- }
- }
+ // Set EVR custom presenter
+ CComPtr<IMFVideoPresenter> pVP;
+ CComPtr<IMFVideoRenderer> pMFVR;
+ CComQIPtr<IMFGetService, &__uuidof(IMFGetService)> pMFGS = pBF;
+ CComQIPtr<IEVRFilterConfig> pConfig = pBF;
+ if (SUCCEEDED(hr)) {
+ if (FAILED(pConfig->SetNumberOfStreams(3))) { // TODO - maybe need other number of input stream ...
+ break;
+ }
+ }
- hr = pMFGS->GetService (MR_VIDEO_RENDER_SERVICE, IID_IMFVideoRenderer, (void**)&pMFVR);
+ hr = pMFGS->GetService(MR_VIDEO_RENDER_SERVICE, IID_IMFVideoRenderer, (void**)&pMFVR);
- if (SUCCEEDED(hr)) {
- hr = QueryInterface (__uuidof(IMFVideoPresenter), (void**)&pVP);
- }
- if (SUCCEEDED(hr)) {
- hr = pMFVR->InitializeRenderer (NULL, pVP);
- }
+ if (SUCCEEDED(hr)) {
+ hr = QueryInterface(__uuidof(IMFVideoPresenter), (void**)&pVP);
+ }
+ if (SUCCEEDED(hr)) {
+ hr = pMFVR->InitializeRenderer(NULL, pVP);
+ }
#if 1
- CComPtr<IPin> pPin = GetFirstPin(pBF);
- CComQIPtr<IMemInputPin> pMemInputPin = pPin;
+ CComPtr<IPin> pPin = GetFirstPin(pBF);
+ CComQIPtr<IMemInputPin> pMemInputPin = pPin;
- // No NewSegment : no chocolate :o)
- m_fUseInternalTimer = HookNewSegmentAndReceive((IPinC*)(IPin*)pPin, (IMemInputPinC*)(IMemInputPin*)pMemInputPin);
+ // No NewSegment : no chocolate :o)
+ m_fUseInternalTimer = HookNewSegmentAndReceive((IPinC*)(IPin*)pPin, (IMemInputPinC*)(IMemInputPin*)pMemInputPin);
#else
- m_fUseInternalTimer = false;
+ m_fUseInternalTimer = false;
#endif
- if (FAILED(hr)) {
- *ppRenderer = NULL;
- } else {
- *ppRenderer = pBF.Detach();
- }
+ if (FAILED(hr)) {
+ *ppRenderer = NULL;
+ } else {
+ *ppRenderer = pBF.Detach();
+ }
- } while (0);
+ } while (0);
- return hr;
+ return hr;
}
STDMETHODIMP_(bool) CEVRAllocatorPresenter::Paint(bool fAll)
{
- return __super::Paint (fAll);
+ return __super::Paint(fAll);
}
STDMETHODIMP CEVRAllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- HRESULT hr;
- if (riid == __uuidof(IMFClockStateSink)) {
- hr = GetInterface((IMFClockStateSink*)this, ppv);
- } else if (riid == __uuidof(IMFVideoPresenter)) {
- hr = GetInterface((IMFVideoPresenter*)this, ppv);
- } else if (riid == __uuidof(IMFTopologyServiceLookupClient)) {
- hr = GetInterface((IMFTopologyServiceLookupClient*)this, ppv);
- } else if (riid == __uuidof(IMFVideoDeviceID)) {
- hr = GetInterface((IMFVideoDeviceID*)this, ppv);
- } else if (riid == __uuidof(IMFGetService)) {
- hr = GetInterface((IMFGetService*)this, ppv);
- } else if (riid == __uuidof(IMFAsyncCallback)) {
- hr = GetInterface((IMFAsyncCallback*)this, ppv);
- } else if (riid == __uuidof(IMFVideoDisplayControl)) {
- hr = GetInterface((IMFVideoDisplayControl*)this, ppv);
- } else if (riid == __uuidof(IEVRTrustedVideoPlugin)) {
- hr = GetInterface((IEVRTrustedVideoPlugin*)this, ppv);
- } else if (riid == IID_IQualProp) {
- hr = GetInterface((IQualProp*)this, ppv);
- } else if (riid == __uuidof(IMFRateSupport)) {
- hr = GetInterface((IMFRateSupport*)this, ppv);
- } else if (riid == __uuidof(IDirect3DDeviceManager9))
- // hr = GetInterface((IDirect3DDeviceManager9*)this, ppv);
- {
- hr = m_pD3DManager->QueryInterface (__uuidof(IDirect3DDeviceManager9), (void**) ppv);
- } else {
- hr = __super::NonDelegatingQueryInterface(riid, ppv);
- }
-
- return hr;
+ HRESULT hr;
+ if (riid == __uuidof(IMFClockStateSink)) {
+ hr = GetInterface((IMFClockStateSink*)this, ppv);
+ } else if (riid == __uuidof(IMFVideoPresenter)) {
+ hr = GetInterface((IMFVideoPresenter*)this, ppv);
+ } else if (riid == __uuidof(IMFTopologyServiceLookupClient)) {
+ hr = GetInterface((IMFTopologyServiceLookupClient*)this, ppv);
+ } else if (riid == __uuidof(IMFVideoDeviceID)) {
+ hr = GetInterface((IMFVideoDeviceID*)this, ppv);
+ } else if (riid == __uuidof(IMFGetService)) {
+ hr = GetInterface((IMFGetService*)this, ppv);
+ } else if (riid == __uuidof(IMFAsyncCallback)) {
+ hr = GetInterface((IMFAsyncCallback*)this, ppv);
+ } else if (riid == __uuidof(IMFVideoDisplayControl)) {
+ hr = GetInterface((IMFVideoDisplayControl*)this, ppv);
+ } else if (riid == __uuidof(IEVRTrustedVideoPlugin)) {
+ hr = GetInterface((IEVRTrustedVideoPlugin*)this, ppv);
+ } else if (riid == IID_IQualProp) {
+ hr = GetInterface((IQualProp*)this, ppv);
+ } else if (riid == __uuidof(IMFRateSupport)) {
+ hr = GetInterface((IMFRateSupport*)this, ppv);
+ } else if (riid == __uuidof(IDirect3DDeviceManager9))
+ // hr = GetInterface((IDirect3DDeviceManager9*)this, ppv);
+ {
+ hr = m_pD3DManager->QueryInterface(__uuidof(IDirect3DDeviceManager9), (void**) ppv);
+ } else {
+ hr = __super::NonDelegatingQueryInterface(riid, ppv);
+ }
+
+ return hr;
}
// IMFClockStateSink
STDMETHODIMP CEVRAllocatorPresenter::OnClockStart(MFTIME hnsSystemTime, LONGLONG llClockStartOffset)
{
- m_nRenderState = Started;
+ m_nRenderState = Started;
- TRACE_EVR ("EVR: OnClockStart hnsSystemTime = %I64d, llClockStartOffset = %I64d\n", hnsSystemTime, llClockStartOffset);
- m_ModeratedTimeLast = -1;
- m_ModeratedClockLast = -1;
+ TRACE_EVR("EVR: OnClockStart hnsSystemTime = %I64d, llClockStartOffset = %I64d\n", hnsSystemTime, llClockStartOffset);
+ m_ModeratedTimeLast = -1;
+ m_ModeratedClockLast = -1;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::OnClockStop(MFTIME hnsSystemTime)
{
- TRACE_EVR ("EVR: OnClockStop hnsSystemTime = %I64d\n", hnsSystemTime);
- m_nRenderState = Stopped;
+ TRACE_EVR("EVR: OnClockStop hnsSystemTime = %I64d\n", hnsSystemTime);
+ m_nRenderState = Stopped;
- m_ModeratedClockLast = -1;
- m_ModeratedTimeLast = -1;
- return S_OK;
+ m_ModeratedClockLast = -1;
+ m_ModeratedTimeLast = -1;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::OnClockPause(MFTIME hnsSystemTime)
{
- TRACE_EVR ("EVR: OnClockPause hnsSystemTime = %I64d\n", hnsSystemTime);
- if (!m_bSignaledStarvation) {
- m_nRenderState = Paused;
- }
- m_ModeratedTimeLast = -1;
- m_ModeratedClockLast = -1;
- return S_OK;
+ TRACE_EVR("EVR: OnClockPause hnsSystemTime = %I64d\n", hnsSystemTime);
+ if (!m_bSignaledStarvation) {
+ m_nRenderState = Paused;
+ }
+ m_ModeratedTimeLast = -1;
+ m_ModeratedClockLast = -1;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::OnClockRestart(MFTIME hnsSystemTime)
{
- m_nRenderState = Started;
+ m_nRenderState = Started;
- m_ModeratedTimeLast = -1;
- m_ModeratedClockLast = -1;
- TRACE_EVR ("EVR: OnClockRestart hnsSystemTime = %I64d\n", hnsSystemTime);
+ m_ModeratedTimeLast = -1;
+ m_ModeratedClockLast = -1;
+ TRACE_EVR("EVR: OnClockRestart hnsSystemTime = %I64d\n", hnsSystemTime);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::OnClockSetRate(MFTIME hnsSystemTime, float flRate)
{
- ASSERT (FALSE);
- return E_NOTIMPL;
+ ASSERT(FALSE);
+ return E_NOTIMPL;
}
// IBaseFilter delegate
-bool CEVRAllocatorPresenter::GetState( DWORD dwMilliSecsTimeout, FILTER_STATE *State, HRESULT &_ReturnValue)
+bool CEVRAllocatorPresenter::GetState(DWORD dwMilliSecsTimeout, FILTER_STATE* State, HRESULT& _ReturnValue)
{
- CAutoLock lock(&m_SampleQueueLock);
+ CAutoLock lock(&m_SampleQueueLock);
- if (m_bSignaledStarvation) {
- size_t nSamples = max(m_nNbDXSurface / 2, 1);
- if ((m_ScheduledSamples.GetCount() < nSamples || m_LastSampleOffset < -m_rtTimePerFrame*2) && !g_bNoDuration) {
- *State = (FILTER_STATE)Paused;
- _ReturnValue = VFW_S_STATE_INTERMEDIATE;
- return true;
- }
- m_bSignaledStarvation = false;
- }
- return false;
+ if (m_bSignaledStarvation) {
+ size_t nSamples = max(m_nNbDXSurface / 2, 1);
+ if ((m_ScheduledSamples.GetCount() < nSamples || m_LastSampleOffset < -m_rtTimePerFrame * 2) && !g_bNoDuration) {
+ *State = (FILTER_STATE)Paused;
+ _ReturnValue = VFW_S_STATE_INTERMEDIATE;
+ return true;
+ }
+ m_bSignaledStarvation = false;
+ }
+ return false;
}
// IQualProp
-STDMETHODIMP CEVRAllocatorPresenter::get_FramesDroppedInRenderer(int *pcFrames)
+STDMETHODIMP CEVRAllocatorPresenter::get_FramesDroppedInRenderer(int* pcFrames)
{
- *pcFrames = m_pcFrames;
- return S_OK;
+ *pcFrames = m_pcFrames;
+ return S_OK;
}
-STDMETHODIMP CEVRAllocatorPresenter::get_FramesDrawn(int *pcFramesDrawn)
+STDMETHODIMP CEVRAllocatorPresenter::get_FramesDrawn(int* pcFramesDrawn)
{
- *pcFramesDrawn = m_pcFramesDrawn;
- return S_OK;
+ *pcFramesDrawn = m_pcFramesDrawn;
+ return S_OK;
}
-STDMETHODIMP CEVRAllocatorPresenter::get_AvgFrameRate(int *piAvgFrameRate)
+STDMETHODIMP CEVRAllocatorPresenter::get_AvgFrameRate(int* piAvgFrameRate)
{
- *piAvgFrameRate = (int)(m_fAvrFps * 100);
- return S_OK;
+ *piAvgFrameRate = (int)(m_fAvrFps * 100);
+ return S_OK;
}
-STDMETHODIMP CEVRAllocatorPresenter::get_Jitter(int *iJitter)
+STDMETHODIMP CEVRAllocatorPresenter::get_Jitter(int* iJitter)
{
- *iJitter = (int)((m_fJitterStdDev/10000.0) + 0.5);
- return S_OK;
+ *iJitter = (int)((m_fJitterStdDev / 10000.0) + 0.5);
+ return S_OK;
}
-STDMETHODIMP CEVRAllocatorPresenter::get_AvgSyncOffset(int *piAvg)
+STDMETHODIMP CEVRAllocatorPresenter::get_AvgSyncOffset(int* piAvg)
{
- *piAvg = (int)((m_fSyncOffsetAvr/10000.0) + 0.5);
- return S_OK;
+ *piAvg = (int)((m_fSyncOffsetAvr / 10000.0) + 0.5);
+ return S_OK;
}
-STDMETHODIMP CEVRAllocatorPresenter::get_DevSyncOffset(int *piDev)
+STDMETHODIMP CEVRAllocatorPresenter::get_DevSyncOffset(int* piDev)
{
- *piDev = (int)((m_fSyncOffsetStdDev/10000.0) + 0.5);
- return S_OK;
+ *piDev = (int)((m_fSyncOffsetStdDev / 10000.0) + 0.5);
+ return S_OK;
}
// IMFRateSupport
-STDMETHODIMP CEVRAllocatorPresenter::GetSlowestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float *pflRate)
+STDMETHODIMP CEVRAllocatorPresenter::GetSlowestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float* pflRate)
{
- // TODO : not finished...
- *pflRate = 0;
- return S_OK;
+ // TODO : not finished...
+ *pflRate = 0;
+ return S_OK;
}
-STDMETHODIMP CEVRAllocatorPresenter::GetFastestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float *pflRate)
+STDMETHODIMP CEVRAllocatorPresenter::GetFastestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float* pflRate)
{
- HRESULT hr = S_OK;
- float fMaxRate = 0.0f;
+ HRESULT hr = S_OK;
+ float fMaxRate = 0.0f;
- CAutoLock lock(this);
+ CAutoLock lock(this);
- CheckPointer(pflRate, E_POINTER);
- CheckHR(CheckShutdown());
+ CheckPointer(pflRate, E_POINTER);
+ CheckHR(CheckShutdown());
- // Get the maximum forward rate.
- fMaxRate = GetMaxRate(fThin);
+ // Get the maximum forward rate.
+ fMaxRate = GetMaxRate(fThin);
- // For reverse playback, swap the sign.
- if (eDirection == MFRATE_REVERSE) {
- fMaxRate = -fMaxRate;
- }
+ // For reverse playback, swap the sign.
+ if (eDirection == MFRATE_REVERSE) {
+ fMaxRate = -fMaxRate;
+ }
- *pflRate = fMaxRate;
+ *pflRate = fMaxRate;
- return hr;
+ return hr;
}
-STDMETHODIMP CEVRAllocatorPresenter::IsRateSupported(BOOL fThin, float flRate, float *pflNearestSupportedRate)
+STDMETHODIMP CEVRAllocatorPresenter::IsRateSupported(BOOL fThin, float flRate, float* pflNearestSupportedRate)
{
- // fRate can be negative for reverse playback.
- // pfNearestSupportedRate can be NULL.
+ // fRate can be negative for reverse playback.
+ // pfNearestSupportedRate can be NULL.
- CAutoLock lock(this);
+ CAutoLock lock(this);
- HRESULT hr = S_OK;
- float fMaxRate = 0.0f;
- float fNearestRate = flRate; // Default.
+ HRESULT hr = S_OK;
+ float fMaxRate = 0.0f;
+ float fNearestRate = flRate; // Default.
- CheckPointer (pflNearestSupportedRate, E_POINTER);
- CheckHR(hr = CheckShutdown());
+ CheckPointer(pflNearestSupportedRate, E_POINTER);
+ CheckHR(hr = CheckShutdown());
- // Find the maximum forward rate.
- fMaxRate = GetMaxRate(fThin);
+ // Find the maximum forward rate.
+ fMaxRate = GetMaxRate(fThin);
- if (fabsf(flRate) > fMaxRate) {
- // The (absolute) requested rate exceeds the maximum rate.
- hr = MF_E_UNSUPPORTED_RATE;
+ if (fabsf(flRate) > fMaxRate) {
+ // The (absolute) requested rate exceeds the maximum rate.
+ hr = MF_E_UNSUPPORTED_RATE;
- // The nearest supported rate is fMaxRate.
- fNearestRate = fMaxRate;
- if (flRate < 0) {
- // For reverse playback, swap the sign.
- fNearestRate = -fNearestRate;
- }
- }
+ // The nearest supported rate is fMaxRate.
+ fNearestRate = fMaxRate;
+ if (flRate < 0) {
+ // For reverse playback, swap the sign.
+ fNearestRate = -fNearestRate;
+ }
+ }
- // Return the nearest supported rate if the caller requested it.
- if (pflNearestSupportedRate != NULL) {
- *pflNearestSupportedRate = fNearestRate;
- }
+ // Return the nearest supported rate if the caller requested it.
+ if (pflNearestSupportedRate != NULL) {
+ *pflNearestSupportedRate = fNearestRate;
+ }
- return hr;
+ return hr;
}
float CEVRAllocatorPresenter::GetMaxRate(BOOL bThin)
{
- float fMaxRate = FLT_MAX; // Default.
- UINT32 fpsNumerator = 0, fpsDenominator = 0;
+ float fMaxRate = FLT_MAX; // Default.
+ UINT32 fpsNumerator = 0, fpsDenominator = 0;
- if (!bThin && (m_pMediaType != NULL)) {
- // Non-thinned: Use the frame rate and monitor refresh rate.
+ if (!bThin && (m_pMediaType != NULL)) {
+ // Non-thinned: Use the frame rate and monitor refresh rate.
- // Frame rate:
- MFGetAttributeRatio(m_pMediaType, MF_MT_FRAME_RATE,
- &fpsNumerator, &fpsDenominator);
+ // Frame rate:
+ MFGetAttributeRatio(m_pMediaType, MF_MT_FRAME_RATE,
+ &fpsNumerator, &fpsDenominator);
- // Monitor refresh rate:
- UINT MonitorRateHz = m_RefreshRate; // D3DDISPLAYMODE
+ // Monitor refresh rate:
+ UINT MonitorRateHz = m_RefreshRate; // D3DDISPLAYMODE
- if (fpsDenominator && fpsNumerator && MonitorRateHz) {
- // Max Rate = Refresh Rate / Frame Rate
- fMaxRate = (float)MulDiv(MonitorRateHz, fpsDenominator, fpsNumerator);
- }
- }
- return fMaxRate;
+ if (fpsDenominator && fpsNumerator && MonitorRateHz) {
+ // Max Rate = Refresh Rate / Frame Rate
+ fMaxRate = (float)MulDiv(MonitorRateHz, fpsDenominator, fpsNumerator);
+ }
+ }
+ return fMaxRate;
}
void CEVRAllocatorPresenter::CompleteFrameStep(bool bCancel)
{
- if (m_nStepCount > 0) {
- if (bCancel || (m_nStepCount == 1)) {
- m_pSink->Notify(EC_STEP_COMPLETE, bCancel ? TRUE : FALSE, 0);
- m_nStepCount = 0;
- } else {
- m_nStepCount--;
- }
- }
+ if (m_nStepCount > 0) {
+ if (bCancel || (m_nStepCount == 1)) {
+ m_pSink->Notify(EC_STEP_COMPLETE, bCancel ? TRUE : FALSE, 0);
+ m_nStepCount = 0;
+ } else {
+ m_nStepCount--;
+ }
+ }
}
// IMFVideoPresenter
STDMETHODIMP CEVRAllocatorPresenter::ProcessMessage(MFVP_MESSAGE_TYPE eMessage, ULONG_PTR ulParam)
{
- HRESULT hr = S_OK;
-
- switch (eMessage) {
- case MFVP_MESSAGE_BEGINSTREAMING : // The EVR switched from stopped to paused. The presenter should allocate resources
- ResetStats();
- TRACE_EVR ("EVR: MFVP_MESSAGE_BEGINSTREAMING\n");
- break;
-
- case MFVP_MESSAGE_CANCELSTEP : // Cancels a frame step
- TRACE_EVR ("EVR: MFVP_MESSAGE_CANCELSTEP\n");
- CompleteFrameStep (true);
- break;
-
- case MFVP_MESSAGE_ENDOFSTREAM : // All input streams have ended.
- TRACE_EVR ("EVR: MFVP_MESSAGE_ENDOFSTREAM\n");
- m_bPendingMediaFinished = true;
- break;
-
- case MFVP_MESSAGE_ENDSTREAMING : // The EVR switched from running or paused to stopped. The presenter should free resources
- TRACE_EVR ("EVR: MFVP_MESSAGE_ENDSTREAMING\n");
- break;
-
- case MFVP_MESSAGE_FLUSH : // The presenter should discard any pending samples
- SetEvent(m_hEvtFlush);
- m_bEvtFlush = true;
- TRACE_EVR ("EVR: MFVP_MESSAGE_FLUSH\n");
- while (WaitForSingleObject(m_hEvtFlush, 1) == WAIT_OBJECT_0) {
- ;
- }
- break;
-
- case MFVP_MESSAGE_INVALIDATEMEDIATYPE : // The mixer's output format has changed. The EVR will initiate format negotiation, as described previously
- /*
- 1) The EVR sets the media type on the reference stream.
- 2) The EVR calls IMFVideoPresenter::ProcessMessage on the presenter with the MFVP_MESSAGE_INVALIDATEMEDIATYPE message.
- 3) The presenter sets the media type on the mixer's output stream.
- 4) The EVR sets the media type on the substreams.
- */
- m_bPendingRenegotiate = true;
- while (*((volatile bool *)&m_bPendingRenegotiate)) {
- Sleep(1);
- }
- break;
-
- case MFVP_MESSAGE_PROCESSINPUTNOTIFY : // One input stream on the mixer has received a new sample
- // GetImageFromMixer();
- break;
-
- case MFVP_MESSAGE_STEP : // Requests a frame step.
- TRACE_EVR ("EVR: MFVP_MESSAGE_STEP\n");
- m_nStepCount = (int)ulParam;
- hr = S_OK;
- break;
-
- default :
- ASSERT (FALSE);
- break;
- }
- return hr;
+ HRESULT hr = S_OK;
+
+ switch (eMessage) {
+ case MFVP_MESSAGE_BEGINSTREAMING : // The EVR switched from stopped to paused. The presenter should allocate resources
+ ResetStats();
+ TRACE_EVR("EVR: MFVP_MESSAGE_BEGINSTREAMING\n");
+ break;
+
+ case MFVP_MESSAGE_CANCELSTEP : // Cancels a frame step
+ TRACE_EVR("EVR: MFVP_MESSAGE_CANCELSTEP\n");
+ CompleteFrameStep(true);
+ break;
+
+ case MFVP_MESSAGE_ENDOFSTREAM : // All input streams have ended.
+ TRACE_EVR("EVR: MFVP_MESSAGE_ENDOFSTREAM\n");
+ m_bPendingMediaFinished = true;
+ break;
+
+ case MFVP_MESSAGE_ENDSTREAMING : // The EVR switched from running or paused to stopped. The presenter should free resources
+ TRACE_EVR("EVR: MFVP_MESSAGE_ENDSTREAMING\n");
+ break;
+
+ case MFVP_MESSAGE_FLUSH : // The presenter should discard any pending samples
+ SetEvent(m_hEvtFlush);
+ m_bEvtFlush = true;
+ TRACE_EVR("EVR: MFVP_MESSAGE_FLUSH\n");
+ while (WaitForSingleObject(m_hEvtFlush, 1) == WAIT_OBJECT_0) {
+ ;
+ }
+ break;
+
+ case MFVP_MESSAGE_INVALIDATEMEDIATYPE : // The mixer's output format has changed. The EVR will initiate format negotiation, as described previously
+ /*
+ 1) The EVR sets the media type on the reference stream.
+ 2) The EVR calls IMFVideoPresenter::ProcessMessage on the presenter with the MFVP_MESSAGE_INVALIDATEMEDIATYPE message.
+ 3) The presenter sets the media type on the mixer's output stream.
+ 4) The EVR sets the media type on the substreams.
+ */
+ m_bPendingRenegotiate = true;
+ while (*((volatile bool*)&m_bPendingRenegotiate)) {
+ Sleep(1);
+ }
+ break;
+
+ case MFVP_MESSAGE_PROCESSINPUTNOTIFY : // One input stream on the mixer has received a new sample
+ // GetImageFromMixer();
+ break;
+
+ case MFVP_MESSAGE_STEP : // Requests a frame step.
+ TRACE_EVR("EVR: MFVP_MESSAGE_STEP\n");
+ m_nStepCount = (int)ulParam;
+ hr = S_OK;
+ break;
+
+ default :
+ ASSERT(FALSE);
+ break;
+ }
+ return hr;
}
HRESULT CEVRAllocatorPresenter::IsMediaTypeSupported(IMFMediaType* pMixerType)
{
- HRESULT hr;
+ HRESULT hr;
- // We support only video types
- GUID MajorType;
- hr = pMixerType->GetMajorType(&MajorType);
+ // We support only video types
+ GUID MajorType;
+ hr = pMixerType->GetMajorType(&MajorType);
- if (SUCCEEDED(hr)) {
- if (MajorType != MFMediaType_Video) {
- hr = MF_E_INVALIDMEDIATYPE;
- }
- }
+ if (SUCCEEDED(hr)) {
+ if (MajorType != MFMediaType_Video) {
+ hr = MF_E_INVALIDMEDIATYPE;
+ }
+ }
- // We support only progressive formats
- MFVideoInterlaceMode InterlaceMode;
+ // We support only progressive formats
+ MFVideoInterlaceMode InterlaceMode;
- if (SUCCEEDED(hr)) {
- hr = pMixerType->GetUINT32(MF_MT_INTERLACE_MODE, (UINT32*)&InterlaceMode);
- }
+ if (SUCCEEDED(hr)) {
+ hr = pMixerType->GetUINT32(MF_MT_INTERLACE_MODE, (UINT32*)&InterlaceMode);
+ }
- if (SUCCEEDED(hr)) {
- if (InterlaceMode != MFVideoInterlace_Progressive) {
- hr = MF_E_INVALIDMEDIATYPE;
- }
- }
+ if (SUCCEEDED(hr)) {
+ if (InterlaceMode != MFVideoInterlace_Progressive) {
+ hr = MF_E_INVALIDMEDIATYPE;
+ }
+ }
- // Check whether we support the surface format
- int Merit = 0;
+ // Check whether we support the surface format
+ int Merit = 0;
- if (SUCCEEDED(hr)) {
- hr = GetMediaTypeMerit(pMixerType, &Merit);
- }
+ if (SUCCEEDED(hr)) {
+ hr = GetMediaTypeMerit(pMixerType, &Merit);
+ }
- if (SUCCEEDED(hr)) {
- if (Merit == 0) {
- hr = MF_E_INVALIDMEDIATYPE;
- }
- }
+ if (SUCCEEDED(hr)) {
+ if (Merit == 0) {
+ hr = MF_E_INVALIDMEDIATYPE;
+ }
+ }
- return hr;
+ return hr;
}
HRESULT CEVRAllocatorPresenter::CreateProposedOutputType(IMFMediaType* pMixerType, IMFMediaType** pType)
{
- HRESULT hr;
- AM_MEDIA_TYPE* pAMMedia = NULL;
- LARGE_INTEGER i64Size;
- MFVIDEOFORMAT* VideoFormat;
-
- CheckHR (pMixerType->GetRepresentation (FORMAT_MFVideoFormat, (void**)&pAMMedia));
-
- VideoFormat = (MFVIDEOFORMAT*)pAMMedia->pbFormat;
- hr = pfMFCreateVideoMediaType (VideoFormat, &m_pMediaType);
-
- if (0) {
- // This code doesn't work, use same method as VMR9 instead
- if (VideoFormat->videoInfo.FramesPerSecond.Numerator != 0) {
- switch (VideoFormat->videoInfo.InterlaceMode) {
- case MFVideoInterlace_Progressive:
- case MFVideoInterlace_MixedInterlaceOrProgressive:
- default: {
- m_rtTimePerFrame = (10000000I64*VideoFormat->videoInfo.FramesPerSecond.Denominator)/VideoFormat->videoInfo.FramesPerSecond.Numerator;
- m_bInterlaced = false;
- }
- break;
- case MFVideoInterlace_FieldSingleUpper:
- case MFVideoInterlace_FieldSingleLower:
- case MFVideoInterlace_FieldInterleavedUpperFirst:
- case MFVideoInterlace_FieldInterleavedLowerFirst: {
- m_rtTimePerFrame = (20000000I64*VideoFormat->videoInfo.FramesPerSecond.Denominator)/VideoFormat->videoInfo.FramesPerSecond.Numerator;
- m_bInterlaced = true;
- }
- break;
- }
- }
- }
-
- m_AspectRatio.cx = VideoFormat->videoInfo.PixelAspectRatio.Numerator;
- m_AspectRatio.cy = VideoFormat->videoInfo.PixelAspectRatio.Denominator;
-
- if (SUCCEEDED (hr)) {
- i64Size.HighPart = VideoFormat->videoInfo.dwWidth;
- i64Size.LowPart = VideoFormat->videoInfo.dwHeight;
- m_pMediaType->SetUINT64 (MF_MT_FRAME_SIZE, i64Size.QuadPart);
-
- m_pMediaType->SetUINT32 (MF_MT_PAN_SCAN_ENABLED, 0);
-
- CRenderersSettings& s = GetRenderersSettings();
+ HRESULT hr;
+ AM_MEDIA_TYPE* pAMMedia = NULL;
+ LARGE_INTEGER i64Size;
+ MFVIDEOFORMAT* VideoFormat;
+
+ CheckHR(pMixerType->GetRepresentation(FORMAT_MFVideoFormat, (void**)&pAMMedia));
+
+ VideoFormat = (MFVIDEOFORMAT*)pAMMedia->pbFormat;
+ hr = pfMFCreateVideoMediaType(VideoFormat, &m_pMediaType);
+
+ if (0) {
+ // This code doesn't work, use same method as VMR9 instead
+ if (VideoFormat->videoInfo.FramesPerSecond.Numerator != 0) {
+ switch (VideoFormat->videoInfo.InterlaceMode) {
+ case MFVideoInterlace_Progressive:
+ case MFVideoInterlace_MixedInterlaceOrProgressive:
+ default: {
+ m_rtTimePerFrame = (10000000I64 * VideoFormat->videoInfo.FramesPerSecond.Denominator) / VideoFormat->videoInfo.FramesPerSecond.Numerator;
+ m_bInterlaced = false;
+ }
+ break;
+ case MFVideoInterlace_FieldSingleUpper:
+ case MFVideoInterlace_FieldSingleLower:
+ case MFVideoInterlace_FieldInterleavedUpperFirst:
+ case MFVideoInterlace_FieldInterleavedLowerFirst: {
+ m_rtTimePerFrame = (20000000I64 * VideoFormat->videoInfo.FramesPerSecond.Denominator) / VideoFormat->videoInfo.FramesPerSecond.Numerator;
+ m_bInterlaced = true;
+ }
+ break;
+ }
+ }
+ }
+
+ m_AspectRatio.cx = VideoFormat->videoInfo.PixelAspectRatio.Numerator;
+ m_AspectRatio.cy = VideoFormat->videoInfo.PixelAspectRatio.Denominator;
+
+ if (SUCCEEDED(hr)) {
+ i64Size.HighPart = VideoFormat->videoInfo.dwWidth;
+ i64Size.LowPart = VideoFormat->videoInfo.dwHeight;
+ m_pMediaType->SetUINT64(MF_MT_FRAME_SIZE, i64Size.QuadPart);
+
+ m_pMediaType->SetUINT32(MF_MT_PAN_SCAN_ENABLED, 0);
+
+ CRenderersSettings& s = GetRenderersSettings();
#if 1
- if (s.m_RenderSettings.iEVROutputRange == 1) {
- m_pMediaType->SetUINT32 (MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_16_235);
- } else {
- m_pMediaType->SetUINT32 (MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_0_255);
- }
+ if (s.m_RenderSettings.iEVROutputRange == 1) {
+ m_pMediaType->SetUINT32(MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_16_235);
+ } else {
+ m_pMediaType->SetUINT32(MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_0_255);
+ }
- // m_pMediaType->SetUINT32 (MF_MT_TRANSFER_FUNCTION, MFVideoTransFunc_10);
+ // m_pMediaType->SetUINT32 (MF_MT_TRANSFER_FUNCTION, MFVideoTransFunc_10);
#else
- m_pMediaType->SetUINT32 (MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_0_255);
- if (s.iEVROutputRange == 1) {
- m_pMediaType->SetUINT32 (MF_MT_YUV_MATRIX, MFVideoTransferMatrix_BT601);
- } else {
- m_pMediaType->SetUINT32 (MF_MT_YUV_MATRIX, MFVideoTransferMatrix_BT709);
- }
+ m_pMediaType->SetUINT32(MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_0_255);
+ if (s.iEVROutputRange == 1) {
+ m_pMediaType->SetUINT32(MF_MT_YUV_MATRIX, MFVideoTransferMatrix_BT601);
+ } else {
+ m_pMediaType->SetUINT32(MF_MT_YUV_MATRIX, MFVideoTransferMatrix_BT709);
+ }
#endif
- m_LastSetOutputRange = s.m_RenderSettings.iEVROutputRange;
+ m_LastSetOutputRange = s.m_RenderSettings.iEVROutputRange;
- i64Size.HighPart = m_AspectRatio.cx;
- i64Size.LowPart = m_AspectRatio.cy;
- m_pMediaType->SetUINT64 (MF_MT_PIXEL_ASPECT_RATIO, i64Size.QuadPart);
+ i64Size.HighPart = m_AspectRatio.cx;
+ i64Size.LowPart = m_AspectRatio.cy;
+ m_pMediaType->SetUINT64(MF_MT_PIXEL_ASPECT_RATIO, i64Size.QuadPart);
- MFVideoArea Area = MakeArea (0, 0, VideoFormat->videoInfo.dwWidth, VideoFormat->videoInfo.dwHeight);
- m_pMediaType->SetBlob(MF_MT_GEOMETRIC_APERTURE, (UINT8*)&Area, sizeof(MFVideoArea));
+ MFVideoArea Area = MakeArea(0, 0, VideoFormat->videoInfo.dwWidth, VideoFormat->videoInfo.dwHeight);
+ m_pMediaType->SetBlob(MF_MT_GEOMETRIC_APERTURE, (UINT8*)&Area, sizeof(MFVideoArea));
- }
+ }
- m_AspectRatio.cx *= VideoFormat->videoInfo.dwWidth;
- m_AspectRatio.cy *= VideoFormat->videoInfo.dwHeight;
+ m_AspectRatio.cx *= VideoFormat->videoInfo.dwWidth;
+ m_AspectRatio.cy *= VideoFormat->videoInfo.dwHeight;
- bool bDoneSomething = true;
+ bool bDoneSomething = true;
- if (m_AspectRatio.cx >= 1 && m_AspectRatio.cy >= 1) { //if any of these is 0, it will stuck into a infinite loop
- while (bDoneSomething) {
- bDoneSomething = false;
- INT MinNum = min(m_AspectRatio.cx, m_AspectRatio.cy);
- INT i;
- for (i = 2; i < MinNum+1; ++i) {
- if (m_AspectRatio.cx%i == 0 && m_AspectRatio.cy%i ==0) {
- break;
- }
- }
- if (i != MinNum + 1) {
- m_AspectRatio.cx = m_AspectRatio.cx / i;
- m_AspectRatio.cy = m_AspectRatio.cy / i;
- bDoneSomething = true;
- }
- }
- }
+ if (m_AspectRatio.cx >= 1 && m_AspectRatio.cy >= 1) { //if any of these is 0, it will stuck into a infinite loop
+ while (bDoneSomething) {
+ bDoneSomething = false;
+ INT MinNum = min(m_AspectRatio.cx, m_AspectRatio.cy);
+ INT i;
+ for (i = 2; i < MinNum + 1; ++i) {
+ if (m_AspectRatio.cx % i == 0 && m_AspectRatio.cy % i == 0) {
+ break;
+ }
+ }
+ if (i != MinNum + 1) {
+ m_AspectRatio.cx = m_AspectRatio.cx / i;
+ m_AspectRatio.cy = m_AspectRatio.cy / i;
+ bDoneSomething = true;
+ }
+ }
+ }
- pMixerType->FreeRepresentation (FORMAT_MFVideoFormat, (void*)pAMMedia);
- m_pMediaType->QueryInterface (__uuidof(IMFMediaType), (void**) pType);
+ pMixerType->FreeRepresentation(FORMAT_MFVideoFormat, (void*)pAMMedia);
+ m_pMediaType->QueryInterface(__uuidof(IMFMediaType), (void**) pType);
- return hr;
+ return hr;
}
HRESULT CEVRAllocatorPresenter::SetMediaType(IMFMediaType* pType)
{
- HRESULT hr;
- AM_MEDIA_TYPE* pAMMedia = NULL;
- CString strTemp, strTemp1;
+ HRESULT hr;
+ AM_MEDIA_TYPE* pAMMedia = NULL;
+ CString strTemp, strTemp1;
- CheckPointer (pType, E_POINTER);
- CheckHR (pType->GetRepresentation(FORMAT_VideoInfo2, (void**)&pAMMedia));
+ CheckPointer(pType, E_POINTER);
+ CheckHR(pType->GetRepresentation(FORMAT_VideoInfo2, (void**)&pAMMedia));
- hr = InitializeDevice (pType);
- if (SUCCEEDED(hr)) {
- strTemp = GetMediaTypeName (pAMMedia->subtype);
- strTemp.Replace (L"MEDIASUBTYPE_", L"");
- strTemp1 = GetMediaTypeFormatDesc(pType);
- strTemp1.Replace (L"D3DFMT_", L"");
- m_strStatsMsg[MSG_MIXEROUT].Format (L"Mixer output : %-10s Type %-10s", strTemp, strTemp1);
- }
+ hr = InitializeDevice(pType);
+ if (SUCCEEDED(hr)) {
+ strTemp = GetMediaTypeName(pAMMedia->subtype);
+ strTemp.Replace(L"MEDIASUBTYPE_", L"");
+ strTemp1 = GetMediaTypeFormatDesc(pType);
+ strTemp1.Replace(L"D3DFMT_", L"");
+ m_strStatsMsg[MSG_MIXEROUT].Format(L"Mixer output : %-10s Type %-10s", strTemp, strTemp1);
+ }
- pType->FreeRepresentation (FORMAT_VideoInfo2, (void*)pAMMedia);
+ pType->FreeRepresentation(FORMAT_VideoInfo2, (void*)pAMMedia);
- return hr;
+ return hr;
}
HRESULT CEVRAllocatorPresenter::GetMediaTypeFourCC(IMFMediaType* pType, DWORD* pFourCC)
{
- if (pFourCC == NULL) {
- return E_POINTER;
- }
+ if (pFourCC == NULL) {
+ return E_POINTER;
+ }
- HRESULT hr = S_OK;
- GUID guidSubType = GUID_NULL;
+ HRESULT hr = S_OK;
+ GUID guidSubType = GUID_NULL;
- if (SUCCEEDED(hr)) {
- hr = pType->GetGUID(MF_MT_SUBTYPE, &guidSubType);
- }
+ if (SUCCEEDED(hr)) {
+ hr = pType->GetGUID(MF_MT_SUBTYPE, &guidSubType);
+ }
- if (SUCCEEDED(hr)) {
- *pFourCC = guidSubType.Data1;
- }
+ if (SUCCEEDED(hr)) {
+ *pFourCC = guidSubType.Data1;
+ }
- return hr;
+ return hr;
}
HRESULT CEVRAllocatorPresenter::GetMediaTypeMerit(IMFMediaType* pType, int* pMerit)
{
- DWORD Format;
- HRESULT hr = GetMediaTypeFourCC(pType, &Format);
-
- if (SUCCEEDED(hr)) {
- switch (Format) {
- case FCC('AI44'):// Palettized, 4:4:4
- *pMerit = 31;
- break;
- case FCC('YVU9'):// 8-bit, 16:1:1
- *pMerit = 30;
- break;
- case FCC('NV11'):// 8-bit, 4:1:1
- *pMerit = 29;
- break;
- case FCC('Y41P'):
- *pMerit = 28;
- break;
- case FCC('Y41T'):
- *pMerit = 27;
- break;
- case FCC('P016'):// 4:2:0
- *pMerit = 26;
- break;
- case FCC('P010'):
- *pMerit = 25;
- break;
- case FCC('IMC1'):
- *pMerit = 24;
- break;
- case FCC('IMC3'):
- *pMerit = 23;
- break;
- case FCC('IMC2'):
- *pMerit = 22;
- break;
- case FCC('IMC4'):
- *pMerit = 21;
- break;
- case FCC('YV12'):
- *pMerit = 20;
- break;
- case FCC('NV12'):
- *pMerit = 19;
- break;
- case FCC('I420'):
- *pMerit = 18;
- break;
- case FCC('IYUV'):
- *pMerit = 17;
- break;
- case FCC('Y216'):// 4:2:2
- *pMerit = 16;
- break;
- case FCC('v216'):
- *pMerit = 15;
- break;
- case FCC('P216'):
- *pMerit = 14;
- break;
- case FCC('Y210'):
- *pMerit = 13;
- break;
- case FCC('v210'):
- *pMerit = 12;
- break;
- case FCC('P210'):
- *pMerit = 11;
- break;
- case FCC('YUY2'):
- *pMerit = 0;// bug: the internal software codecs will always select this, for safety this item is ranked below X8R8G8B8 until the problem is solved
- break;
- case FCC('UYVY'):
- *pMerit = 9;
- break;
- case FCC('Y42T'):
- *pMerit = 8;
- break;
- case FCC('YVYU'):
- *pMerit = 7;
- break;
- case FCC('Y416'):// 4:4:4
- *pMerit = 6;
- break;
- case FCC('Y410'):
- *pMerit = 5;
- break;
- case FCC('v410'):
- *pMerit = 4;
- break;
- case FCC('AYUV'):
- *pMerit = 3;
- break;
- case D3DFMT_X8R8G8B8:
- if (m_bForceInputHighColorResolution) {
- *pMerit = 63;
- } else {
- *pMerit = 1;
- }
- break;
- case D3DFMT_A8R8G8B8:// an accepted format, but fails on most surface types
- case D3DFMT_A8B8G8R8:
- case D3DFMT_X8B8G8R8:
- case D3DFMT_R8G8B8:
- case D3DFMT_R5G6B5:
- case D3DFMT_X1R5G5B5:
- case D3DFMT_A1R5G5B5:
- case D3DFMT_A4R4G4B4:
- case D3DFMT_R3G3B2:
- case D3DFMT_A8R3G3B2:
- case D3DFMT_X4R4G4B4:
- case D3DFMT_A8P8:
- case D3DFMT_P8:
- *pMerit = 0;
- break;
- default:
- *pMerit = 2;
- break;
- }
- }
-
- return hr;
+ DWORD Format;
+ HRESULT hr = GetMediaTypeFourCC(pType, &Format);
+
+ if (SUCCEEDED(hr)) {
+ switch (Format) {
+ case FCC('AI44'):// Palettized, 4:4:4
+ *pMerit = 31;
+ break;
+ case FCC('YVU9'):// 8-bit, 16:1:1
+ *pMerit = 30;
+ break;
+ case FCC('NV11'):// 8-bit, 4:1:1
+ *pMerit = 29;
+ break;
+ case FCC('Y41P'):
+ *pMerit = 28;
+ break;
+ case FCC('Y41T'):
+ *pMerit = 27;
+ break;
+ case FCC('P016'):// 4:2:0
+ *pMerit = 26;
+ break;
+ case FCC('P010'):
+ *pMerit = 25;
+ break;
+ case FCC('IMC1'):
+ *pMerit = 24;
+ break;
+ case FCC('IMC3'):
+ *pMerit = 23;
+ break;
+ case FCC('IMC2'):
+ *pMerit = 22;
+ break;
+ case FCC('IMC4'):
+ *pMerit = 21;
+ break;
+ case FCC('YV12'):
+ *pMerit = 20;
+ break;
+ case FCC('NV12'):
+ *pMerit = 19;
+ break;
+ case FCC('I420'):
+ *pMerit = 18;
+ break;
+ case FCC('IYUV'):
+ *pMerit = 17;
+ break;
+ case FCC('Y216'):// 4:2:2
+ *pMerit = 16;
+ break;
+ case FCC('v216'):
+ *pMerit = 15;
+ break;
+ case FCC('P216'):
+ *pMerit = 14;
+ break;
+ case FCC('Y210'):
+ *pMerit = 13;
+ break;
+ case FCC('v210'):
+ *pMerit = 12;
+ break;
+ case FCC('P210'):
+ *pMerit = 11;
+ break;
+ case FCC('YUY2'):
+ *pMerit = 0;// bug: the internal software codecs will always select this, for safety this item is ranked below X8R8G8B8 until the problem is solved
+ break;
+ case FCC('UYVY'):
+ *pMerit = 9;
+ break;
+ case FCC('Y42T'):
+ *pMerit = 8;
+ break;
+ case FCC('YVYU'):
+ *pMerit = 7;
+ break;
+ case FCC('Y416'):// 4:4:4
+ *pMerit = 6;
+ break;
+ case FCC('Y410'):
+ *pMerit = 5;
+ break;
+ case FCC('v410'):
+ *pMerit = 4;
+ break;
+ case FCC('AYUV'):
+ *pMerit = 3;
+ break;
+ case D3DFMT_X8R8G8B8:
+ if (m_bForceInputHighColorResolution) {
+ *pMerit = 63;
+ } else {
+ *pMerit = 1;
+ }
+ break;
+ case D3DFMT_A8R8G8B8:// an accepted format, but fails on most surface types
+ case D3DFMT_A8B8G8R8:
+ case D3DFMT_X8B8G8R8:
+ case D3DFMT_R8G8B8:
+ case D3DFMT_R5G6B5:
+ case D3DFMT_X1R5G5B5:
+ case D3DFMT_A1R5G5B5:
+ case D3DFMT_A4R4G4B4:
+ case D3DFMT_R3G3B2:
+ case D3DFMT_A8R3G3B2:
+ case D3DFMT_X4R4G4B4:
+ case D3DFMT_A8P8:
+ case D3DFMT_P8:
+ *pMerit = 0;
+ break;
+ default:
+ *pMerit = 2;
+ break;
+ }
+ }
+
+ return hr;
}
LPCTSTR FindD3DFormat(const D3DFORMAT Format);
LPCTSTR CEVRAllocatorPresenter::GetMediaTypeFormatDesc(IMFMediaType* pMediaType)
{
- D3DFORMAT Format = D3DFMT_UNKNOWN;
- GetMediaTypeFourCC(pMediaType, (DWORD*)&Format);
- return FindD3DFormat(Format);
+ D3DFORMAT Format = D3DFMT_UNKNOWN;
+ GetMediaTypeFourCC(pMediaType, (DWORD*)&Format);
+ return FindD3DFormat(Format);
}
HRESULT CEVRAllocatorPresenter::RenegotiateMediaType()
{
- HRESULT hr = S_OK;
-
- CComPtr<IMFMediaType> pMixerType;
- CComPtr<IMFMediaType> pType;
-
- if (!m_pMixer) {
- return MF_E_INVALIDREQUEST;
- }
-
- CInterfaceArray<IMFMediaType> ValidMixerTypes;
-
- // Loop through all of the mixer's proposed output types.
- DWORD iTypeIndex = 0;
- while ((hr != MF_E_NO_MORE_TYPES)) {
- pMixerType = NULL;
- pType = NULL;
- m_pMediaType = NULL;
-
- // Step 1. Get the next media type supported by mixer.
- hr = m_pMixer->GetOutputAvailableType(0, iTypeIndex++, &pMixerType);
- if (FAILED(hr)) {
- break;
- }
-
- // Step 2. Check if we support this media type.
- if (SUCCEEDED(hr)) {
- hr = IsMediaTypeSupported(pMixerType);
- }
-
- if (SUCCEEDED(hr)) {
- hr = CreateProposedOutputType(pMixerType, &pType);
- }
-
- // Step 4. Check if the mixer will accept this media type.
- if (SUCCEEDED(hr)) {
- hr = m_pMixer->SetOutputType(0, pType, MFT_SET_TYPE_TEST_ONLY);
- }
-
- int Merit;
- if (SUCCEEDED(hr)) {
- hr = GetMediaTypeMerit(pType, &Merit);
- }
-
- if (SUCCEEDED(hr)) {
- size_t nTypes = ValidMixerTypes.GetCount();
- size_t iInsertPos = 0;
- for (size_t i = 0; i < nTypes; ++i) {
- int ThisMerit;
- GetMediaTypeMerit(ValidMixerTypes[i], &ThisMerit);
-
- if (Merit > ThisMerit) {
- iInsertPos = i;
- break;
- } else {
- iInsertPos = i+1;
- }
- }
-
- ValidMixerTypes.InsertAt(iInsertPos, pType);
- }
- }
-
-
- size_t nValidTypes = ValidMixerTypes.GetCount();
+ HRESULT hr = S_OK;
+
+ CComPtr<IMFMediaType> pMixerType;
+ CComPtr<IMFMediaType> pType;
+
+ if (!m_pMixer) {
+ return MF_E_INVALIDREQUEST;
+ }
+
+ CInterfaceArray<IMFMediaType> ValidMixerTypes;
+
+ // Loop through all of the mixer's proposed output types.
+ DWORD iTypeIndex = 0;
+ while ((hr != MF_E_NO_MORE_TYPES)) {
+ pMixerType = NULL;
+ pType = NULL;
+ m_pMediaType = NULL;
+
+ // Step 1. Get the next media type supported by mixer.
+ hr = m_pMixer->GetOutputAvailableType(0, iTypeIndex++, &pMixerType);
+ if (FAILED(hr)) {
+ break;
+ }
+
+ // Step 2. Check if we support this media type.
+ if (SUCCEEDED(hr)) {
+ hr = IsMediaTypeSupported(pMixerType);
+ }
+
+ if (SUCCEEDED(hr)) {
+ hr = CreateProposedOutputType(pMixerType, &pType);
+ }
+
+ // Step 4. Check if the mixer will accept this media type.
+ if (SUCCEEDED(hr)) {
+ hr = m_pMixer->SetOutputType(0, pType, MFT_SET_TYPE_TEST_ONLY);
+ }
+
+ int Merit;
+ if (SUCCEEDED(hr)) {
+ hr = GetMediaTypeMerit(pType, &Merit);
+ }
+
+ if (SUCCEEDED(hr)) {
+ size_t nTypes = ValidMixerTypes.GetCount();
+ size_t iInsertPos = 0;
+ for (size_t i = 0; i < nTypes; ++i) {
+ int ThisMerit;
+ GetMediaTypeMerit(ValidMixerTypes[i], &ThisMerit);
+
+ if (Merit > ThisMerit) {
+ iInsertPos = i;
+ break;
+ } else {
+ iInsertPos = i + 1;
+ }
+ }
+
+ ValidMixerTypes.InsertAt(iInsertPos, pType);
+ }
+ }
+
+
+ size_t nValidTypes = ValidMixerTypes.GetCount();
#ifdef _DEBUG
- for (size_t i = 0; i < nValidTypes; ++i) {
- // Step 3. Adjust the mixer's type to match our requirements.
- pType = ValidMixerTypes[i];
- TRACE_EVR("EVR: Valid mixer output type: %ws\n", GetMediaTypeFormatDesc(pType));
- }
+ for (size_t i = 0; i < nValidTypes; ++i) {
+ // Step 3. Adjust the mixer's type to match our requirements.
+ pType = ValidMixerTypes[i];
+ TRACE_EVR("EVR: Valid mixer output type: %ws\n", GetMediaTypeFormatDesc(pType));
+ }
#endif
- for (size_t i = 0; i < nValidTypes; ++i) {
- // Step 3. Adjust the mixer's type to match our requirements.
- pType = ValidMixerTypes[i];
+ for (size_t i = 0; i < nValidTypes; ++i) {
+ // Step 3. Adjust the mixer's type to match our requirements.
+ pType = ValidMixerTypes[i];
- TRACE_EVR("EVR: Trying mixer output type: %ws\n", GetMediaTypeFormatDesc(pType));
+ TRACE_EVR("EVR: Trying mixer output type: %ws\n", GetMediaTypeFormatDesc(pType));
- // Step 5. Try to set the media type on ourselves.
- hr = SetMediaType(pType);
+ // Step 5. Try to set the media type on ourselves.
+ hr = SetMediaType(pType);
- // Step 6. Set output media type on mixer.
- if (SUCCEEDED(hr)) {
- hr = m_pMixer->SetOutputType(0, pType, 0);
+ // Step 6. Set output media type on mixer.
+ if (SUCCEEDED(hr)) {
+ hr = m_pMixer->SetOutputType(0, pType, 0);
- // If something went wrong, clear the media type.
- if (FAILED(hr)) {
- SetMediaType(NULL);
- } else {
- break;
- }
- }
- }
+ // If something went wrong, clear the media type.
+ if (FAILED(hr)) {
+ SetMediaType(NULL);
+ } else {
+ break;
+ }
+ }
+ }
- pMixerType = NULL;
- pType = NULL;
- return hr;
+ pMixerType = NULL;
+ pType = NULL;
+ return hr;
}
bool CEVRAllocatorPresenter::GetImageFromMixer()
{
- MFT_OUTPUT_DATA_BUFFER Buffer;
- HRESULT hr = S_OK;
- DWORD dwStatus;
- REFERENCE_TIME nsSampleTime;
- LONGLONG llClockBefore = 0;
- LONGLONG llClockAfter = 0;
- LONGLONG llMixerLatency;
- UINT dwSurface;
+ MFT_OUTPUT_DATA_BUFFER Buffer;
+ HRESULT hr = S_OK;
+ DWORD dwStatus;
+ REFERENCE_TIME nsSampleTime;
+ LONGLONG llClockBefore = 0;
+ LONGLONG llClockAfter = 0;
+ LONGLONG llMixerLatency;
+ UINT dwSurface;
- bool bDoneSomething = false;
+ bool bDoneSomething = false;
- while (SUCCEEDED(hr)) {
- CComPtr<IMFSample> pSample;
+ while (SUCCEEDED(hr)) {
+ CComPtr<IMFSample> pSample;
- if (FAILED (GetFreeSample (&pSample))) {
- m_bWaitingSample = true;
- break;
- }
+ if (FAILED(GetFreeSample(&pSample))) {
+ m_bWaitingSample = true;
+ break;
+ }
- memset (&Buffer, 0, sizeof(Buffer));
- Buffer.pSample = pSample;
- pSample->GetUINT32 (GUID_SURFACE_INDEX, &dwSurface);
+ memset(&Buffer, 0, sizeof(Buffer));
+ Buffer.pSample = pSample;
+ pSample->GetUINT32(GUID_SURFACE_INDEX, &dwSurface);
- {
- llClockBefore = GetRenderersData()->GetPerfCounter();
- hr = m_pMixer->ProcessOutput (0 , 1, &Buffer, &dwStatus);
- llClockAfter = GetRenderersData()->GetPerfCounter();
- }
+ {
+ llClockBefore = GetRenderersData()->GetPerfCounter();
+ hr = m_pMixer->ProcessOutput(0 , 1, &Buffer, &dwStatus);
+ llClockAfter = GetRenderersData()->GetPerfCounter();
+ }
- if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT) {
- MoveToFreeList (pSample, false);
- break;
- }
+ if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT) {
+ MoveToFreeList(pSample, false);
+ break;
+ }
- if (m_pSink) {
- //CAutoLock autolock(this); We shouldn't need to lock here, m_pSink is thread safe
- llMixerLatency = llClockAfter - llClockBefore;
- m_pSink->Notify (EC_PROCESSING_LATENCY, (LONG_PTR)&llMixerLatency, 0);
- }
+ if (m_pSink) {
+ //CAutoLock autolock(this); We shouldn't need to lock here, m_pSink is thread safe
+ llMixerLatency = llClockAfter - llClockBefore;
+ m_pSink->Notify(EC_PROCESSING_LATENCY, (LONG_PTR)&llMixerLatency, 0);
+ }
- pSample->GetSampleTime (&nsSampleTime);
- REFERENCE_TIME nsDuration;
- pSample->GetSampleDuration (&nsDuration);
+ pSample->GetSampleTime(&nsSampleTime);
+ REFERENCE_TIME nsDuration;
+ pSample->GetSampleDuration(&nsDuration);
- if (GetRenderersData()->m_fTearingTest) {
- RECT rcTearing;
+ if (GetRenderersData()->m_fTearingTest) {
+ RECT rcTearing;
- rcTearing.left = m_nTearingPos;
- rcTearing.top = 0;
- rcTearing.right = rcTearing.left + 4;
- rcTearing.bottom = m_NativeVideoSize.cy;
- m_pD3DDev->ColorFill (m_pVideoSurface[dwSurface], &rcTearing, D3DCOLOR_ARGB (255,255,0,0));
+ rcTearing.left = m_nTearingPos;
+ rcTearing.top = 0;
+ rcTearing.right = rcTearing.left + 4;
+ rcTearing.bottom = m_NativeVideoSize.cy;
+ m_pD3DDev->ColorFill(m_pVideoSurface[dwSurface], &rcTearing, D3DCOLOR_ARGB(255, 255, 0, 0));
- rcTearing.left = (rcTearing.right + 15) % m_NativeVideoSize.cx;
- rcTearing.right = rcTearing.left + 4;
- m_pD3DDev->ColorFill (m_pVideoSurface[dwSurface], &rcTearing, D3DCOLOR_ARGB (255,255,0,0));
- m_nTearingPos = (m_nTearingPos + 7) % m_NativeVideoSize.cx;
- }
+ rcTearing.left = (rcTearing.right + 15) % m_NativeVideoSize.cx;
+ rcTearing.right = rcTearing.left + 4;
+ m_pD3DDev->ColorFill(m_pVideoSurface[dwSurface], &rcTearing, D3DCOLOR_ARGB(255, 255, 0, 0));
+ m_nTearingPos = (m_nTearingPos + 7) % m_NativeVideoSize.cx;
+ }
- TRACE_EVR ("EVR: Get from Mixer : %d (%I64d) (%I64d)\n", dwSurface, nsSampleTime, m_rtTimePerFrame ? nsSampleTime/m_rtTimePerFrame : 0);
+ TRACE_EVR("EVR: Get from Mixer : %d (%I64d) (%I64d)\n", dwSurface, nsSampleTime, m_rtTimePerFrame ? nsSampleTime / m_rtTimePerFrame : 0);
- MoveToScheduledList (pSample, false);
- bDoneSomething = true;
- if (m_rtTimePerFrame == 0) {
- break;
- }
- }
+ MoveToScheduledList(pSample, false);
+ bDoneSomething = true;
+ if (m_rtTimePerFrame == 0) {
+ break;
+ }
+ }
- return bDoneSomething;
+ return bDoneSomething;
}
-STDMETHODIMP CEVRAllocatorPresenter::GetCurrentMediaType(__deref_out IMFVideoMediaType **ppMediaType)
+STDMETHODIMP CEVRAllocatorPresenter::GetCurrentMediaType(__deref_out IMFVideoMediaType** ppMediaType)
{
- HRESULT hr = S_OK;
- CAutoLock lock(this); // Hold the critical section.
+ HRESULT hr = S_OK;
+ CAutoLock lock(this); // Hold the critical section.
- CheckPointer (ppMediaType, E_POINTER);
- CheckHR (CheckShutdown());
+ CheckPointer(ppMediaType, E_POINTER);
+ CheckHR(CheckShutdown());
- if (m_pMediaType == NULL) {
- CheckHR(MF_E_NOT_INITIALIZED);
- }
+ if (m_pMediaType == NULL) {
+ CheckHR(MF_E_NOT_INITIALIZED);
+ }
- CheckHR(m_pMediaType->QueryInterface( __uuidof(IMFVideoMediaType), (void**)&ppMediaType));
+ CheckHR(m_pMediaType->QueryInterface(__uuidof(IMFVideoMediaType), (void**)&ppMediaType));
- return hr;
+ return hr;
}
// IMFTopologyServiceLookupClient
-STDMETHODIMP CEVRAllocatorPresenter::InitServicePointers(/* [in] */ __in IMFTopologyServiceLookup *pLookup)
+STDMETHODIMP CEVRAllocatorPresenter::InitServicePointers(/* [in] */ __in IMFTopologyServiceLookup* pLookup)
{
- HRESULT hr;
- DWORD dwObjects = 1;
+ HRESULT hr;
+ DWORD dwObjects = 1;
- TRACE_EVR ("EVR: CEVRAllocatorPresenter::InitServicePointers\n");
- hr = pLookup->LookupService (MF_SERVICE_LOOKUP_GLOBAL, 0, MR_VIDEO_MIXER_SERVICE,
- __uuidof (IMFTransform), (void**)&m_pMixer, &dwObjects);
+ TRACE_EVR("EVR: CEVRAllocatorPresenter::InitServicePointers\n");
+ hr = pLookup->LookupService(MF_SERVICE_LOOKUP_GLOBAL, 0, MR_VIDEO_MIXER_SERVICE,
+ __uuidof(IMFTransform), (void**)&m_pMixer, &dwObjects);
- hr = pLookup->LookupService (MF_SERVICE_LOOKUP_GLOBAL, 0, MR_VIDEO_RENDER_SERVICE,
- __uuidof (IMediaEventSink ), (void**)&m_pSink, &dwObjects);
+ hr = pLookup->LookupService(MF_SERVICE_LOOKUP_GLOBAL, 0, MR_VIDEO_RENDER_SERVICE,
+ __uuidof(IMediaEventSink), (void**)&m_pSink, &dwObjects);
- hr = pLookup->LookupService (MF_SERVICE_LOOKUP_GLOBAL, 0, MR_VIDEO_RENDER_SERVICE,
- __uuidof (IMFClock ), (void**)&m_pClock, &dwObjects);
+ hr = pLookup->LookupService(MF_SERVICE_LOOKUP_GLOBAL, 0, MR_VIDEO_RENDER_SERVICE,
+ __uuidof(IMFClock), (void**)&m_pClock, &dwObjects);
- StartWorkerThreads();
- return S_OK;
+ StartWorkerThreads();
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::ReleaseServicePointers()
{
- TRACE_EVR ("EVR: CEVRAllocatorPresenter::ReleaseServicePointers\n");
- StopWorkerThreads();
- m_pMixer = NULL;
- m_pSink = NULL;
- m_pClock = NULL;
- return S_OK;
+ TRACE_EVR("EVR: CEVRAllocatorPresenter::ReleaseServicePointers\n");
+ StopWorkerThreads();
+ m_pMixer = NULL;
+ m_pSink = NULL;
+ m_pClock = NULL;
+ return S_OK;
}
// IMFVideoDeviceID
-STDMETHODIMP CEVRAllocatorPresenter::GetDeviceID(/* [out] */ __out IID *pDeviceID)
+STDMETHODIMP CEVRAllocatorPresenter::GetDeviceID(/* [out] */ __out IID* pDeviceID)
{
- CheckPointer(pDeviceID, E_POINTER);
- *pDeviceID = IID_IDirect3DDevice9;
- return S_OK;
+ CheckPointer(pDeviceID, E_POINTER);
+ *pDeviceID = IID_IDirect3DDevice9;
+ return S_OK;
}
// IMFGetService
-STDMETHODIMP CEVRAllocatorPresenter::GetService (/* [in] */ __RPC__in REFGUID guidService,
- /* [in] */ __RPC__in REFIID riid,
- /* [iid_is][out] */ __RPC__deref_out_opt LPVOID *ppvObject)
+STDMETHODIMP CEVRAllocatorPresenter::GetService(/* [in] */ __RPC__in REFGUID guidService,
+ /* [in] */ __RPC__in REFIID riid,
+ /* [iid_is][out] */ __RPC__deref_out_opt LPVOID* ppvObject)
{
- if (guidService == MR_VIDEO_RENDER_SERVICE) {
- return NonDelegatingQueryInterface (riid, ppvObject);
- } else if (guidService == MR_VIDEO_ACCELERATION_SERVICE) {
- return m_pD3DManager->QueryInterface (__uuidof(IDirect3DDeviceManager9), (void**) ppvObject);
- }
+ if (guidService == MR_VIDEO_RENDER_SERVICE) {
+ return NonDelegatingQueryInterface(riid, ppvObject);
+ } else if (guidService == MR_VIDEO_ACCELERATION_SERVICE) {
+ return m_pD3DManager->QueryInterface(__uuidof(IDirect3DDeviceManager9), (void**) ppvObject);
+ }
- return E_NOINTERFACE;
+ return E_NOINTERFACE;
}
// IMFAsyncCallback
-STDMETHODIMP CEVRAllocatorPresenter::GetParameters( /* [out] */ __RPC__out DWORD *pdwFlags, /* [out] */ __RPC__out DWORD *pdwQueue)
+STDMETHODIMP CEVRAllocatorPresenter::GetParameters(/* [out] */ __RPC__out DWORD* pdwFlags, /* [out] */ __RPC__out DWORD* pdwQueue)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
-STDMETHODIMP CEVRAllocatorPresenter::Invoke ( /* [in] */ __RPC__in_opt IMFAsyncResult *pAsyncResult)
+STDMETHODIMP CEVRAllocatorPresenter::Invoke(/* [in] */ __RPC__in_opt IMFAsyncResult* pAsyncResult)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IMFVideoDisplayControl
-STDMETHODIMP CEVRAllocatorPresenter::GetNativeVideoSize(SIZE *pszVideo, SIZE *pszARVideo)
+STDMETHODIMP CEVRAllocatorPresenter::GetNativeVideoSize(SIZE* pszVideo, SIZE* pszARVideo)
{
- if (pszVideo) {
- pszVideo->cx = m_NativeVideoSize.cx;
- pszVideo->cy = m_NativeVideoSize.cy;
- }
- if (pszARVideo) {
- pszARVideo->cx = m_NativeVideoSize.cx * m_AspectRatio.cx;
- pszARVideo->cy = m_NativeVideoSize.cy * m_AspectRatio.cy;
- }
- return S_OK;
+ if (pszVideo) {
+ pszVideo->cx = m_NativeVideoSize.cx;
+ pszVideo->cy = m_NativeVideoSize.cy;
+ }
+ if (pszARVideo) {
+ pszARVideo->cx = m_NativeVideoSize.cx * m_AspectRatio.cx;
+ pszARVideo->cy = m_NativeVideoSize.cy * m_AspectRatio.cy;
+ }
+ return S_OK;
}
-STDMETHODIMP CEVRAllocatorPresenter::GetIdealVideoSize(SIZE *pszMin, SIZE *pszMax)
+STDMETHODIMP CEVRAllocatorPresenter::GetIdealVideoSize(SIZE* pszMin, SIZE* pszMax)
{
- if (pszMin) {
- pszMin->cx = 1;
- pszMin->cy = 1;
- }
+ if (pszMin) {
+ pszMin->cx = 1;
+ pszMin->cy = 1;
+ }
- if (pszMax) {
- D3DDISPLAYMODE d3ddm;
+ if (pszMax) {
+ D3DDISPLAYMODE d3ddm;
- ZeroMemory(&d3ddm, sizeof(d3ddm));
- if (SUCCEEDED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm))) {
- pszMax->cx = d3ddm.Width;
- pszMax->cy = d3ddm.Height;
- }
- }
+ ZeroMemory(&d3ddm, sizeof(d3ddm));
+ if (SUCCEEDED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm))) {
+ pszMax->cx = d3ddm.Width;
+ pszMax->cy = d3ddm.Height;
+ }
+ }
- return S_OK;
+ return S_OK;
}
-STDMETHODIMP CEVRAllocatorPresenter::SetVideoPosition(const MFVideoNormalizedRect *pnrcSource, const LPRECT prcDest)
+STDMETHODIMP CEVRAllocatorPresenter::SetVideoPosition(const MFVideoNormalizedRect* pnrcSource, const LPRECT prcDest)
{
- return S_OK;
+ return S_OK;
}
-STDMETHODIMP CEVRAllocatorPresenter::GetVideoPosition(MFVideoNormalizedRect *pnrcSource, LPRECT prcDest)
+STDMETHODIMP CEVRAllocatorPresenter::GetVideoPosition(MFVideoNormalizedRect* pnrcSource, LPRECT prcDest)
{
- // Always all source rectangle ?
- if (pnrcSource) {
- pnrcSource->left = 0.0;
- pnrcSource->top = 0.0;
- pnrcSource->right = 1.0;
- pnrcSource->bottom = 1.0;
- }
+ // Always all source rectangle ?
+ if (pnrcSource) {
+ pnrcSource->left = 0.0;
+ pnrcSource->top = 0.0;
+ pnrcSource->right = 1.0;
+ pnrcSource->bottom = 1.0;
+ }
- if (prcDest) {
- memcpy (prcDest, &m_VideoRect, sizeof(m_VideoRect)); //GetClientRect (m_hWnd, prcDest);
- }
+ if (prcDest) {
+ memcpy(prcDest, &m_VideoRect, sizeof(m_VideoRect)); //GetClientRect (m_hWnd, prcDest);
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::SetAspectRatioMode(DWORD dwAspectRatioMode)
{
- m_dwVideoAspectRatioMode = (MFVideoAspectRatioMode)dwAspectRatioMode;
- return S_OK;
+ m_dwVideoAspectRatioMode = (MFVideoAspectRatioMode)dwAspectRatioMode;
+ return S_OK;
}
-STDMETHODIMP CEVRAllocatorPresenter::GetAspectRatioMode(DWORD *pdwAspectRatioMode)
+STDMETHODIMP CEVRAllocatorPresenter::GetAspectRatioMode(DWORD* pdwAspectRatioMode)
{
- CheckPointer (pdwAspectRatioMode, E_POINTER);
- *pdwAspectRatioMode = m_dwVideoAspectRatioMode;
- return S_OK;
+ CheckPointer(pdwAspectRatioMode, E_POINTER);
+ *pdwAspectRatioMode = m_dwVideoAspectRatioMode;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::SetVideoWindow(HWND hwndVideo)
{
- ASSERT (m_hWnd == hwndVideo); // What if not ??
- // m_hWnd = hwndVideo;
- return S_OK;
+ ASSERT(m_hWnd == hwndVideo); // What if not ??
+ // m_hWnd = hwndVideo;
+ return S_OK;
}
-STDMETHODIMP CEVRAllocatorPresenter::GetVideoWindow(HWND *phwndVideo)
+STDMETHODIMP CEVRAllocatorPresenter::GetVideoWindow(HWND* phwndVideo)
{
- CheckPointer (phwndVideo, E_POINTER);
- *phwndVideo = m_hWnd;
- return S_OK;
+ CheckPointer(phwndVideo, E_POINTER);
+ *phwndVideo = m_hWnd;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::RepaintVideo()
{
- Paint (true);
- return S_OK;
+ Paint(true);
+ return S_OK;
}
-STDMETHODIMP CEVRAllocatorPresenter::GetCurrentImage(BITMAPINFOHEADER *pBih, BYTE **pDib, DWORD *pcbDib, LONGLONG *pTimeStamp)
+STDMETHODIMP CEVRAllocatorPresenter::GetCurrentImage(BITMAPINFOHEADER* pBih, BYTE** pDib, DWORD* pcbDib, LONGLONG* pTimeStamp)
{
- ASSERT (FALSE);
- return E_NOTIMPL;
+ ASSERT(FALSE);
+ return E_NOTIMPL;
}
STDMETHODIMP CEVRAllocatorPresenter::SetBorderColor(COLORREF Clr)
{
- m_BorderColor = Clr;
- return S_OK;
+ m_BorderColor = Clr;
+ return S_OK;
}
-STDMETHODIMP CEVRAllocatorPresenter::GetBorderColor(COLORREF *pClr)
+STDMETHODIMP CEVRAllocatorPresenter::GetBorderColor(COLORREF* pClr)
{
- CheckPointer (pClr, E_POINTER);
- *pClr = m_BorderColor;
- return S_OK;
+ CheckPointer(pClr, E_POINTER);
+ *pClr = m_BorderColor;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::SetRenderingPrefs(DWORD dwRenderFlags)
{
- m_dwVideoRenderPrefs = (MFVideoRenderPrefs)dwRenderFlags;
- return S_OK;
+ m_dwVideoRenderPrefs = (MFVideoRenderPrefs)dwRenderFlags;
+ return S_OK;
}
-STDMETHODIMP CEVRAllocatorPresenter::GetRenderingPrefs(DWORD *pdwRenderFlags)
+STDMETHODIMP CEVRAllocatorPresenter::GetRenderingPrefs(DWORD* pdwRenderFlags)
{
- CheckPointer(pdwRenderFlags, E_POINTER);
- *pdwRenderFlags = m_dwVideoRenderPrefs;
- return S_OK;
+ CheckPointer(pdwRenderFlags, E_POINTER);
+ *pdwRenderFlags = m_dwVideoRenderPrefs;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::SetFullscreen(BOOL fFullscreen)
{
- ASSERT (FALSE);
- return E_NOTIMPL;
+ ASSERT(FALSE);
+ return E_NOTIMPL;
}
-STDMETHODIMP CEVRAllocatorPresenter::GetFullscreen(BOOL *pfFullscreen)
+STDMETHODIMP CEVRAllocatorPresenter::GetFullscreen(BOOL* pfFullscreen)
{
- ASSERT (FALSE);
- return E_NOTIMPL;
+ ASSERT(FALSE);
+ return E_NOTIMPL;
}
// IEVRTrustedVideoPlugin
-STDMETHODIMP CEVRAllocatorPresenter::IsInTrustedVideoMode(BOOL *pYes)
+STDMETHODIMP CEVRAllocatorPresenter::IsInTrustedVideoMode(BOOL* pYes)
{
- CheckPointer(pYes, E_POINTER);
- *pYes = TRUE;
- return S_OK;
+ CheckPointer(pYes, E_POINTER);
+ *pYes = TRUE;
+ return S_OK;
}
-STDMETHODIMP CEVRAllocatorPresenter::CanConstrict(BOOL *pYes)
+STDMETHODIMP CEVRAllocatorPresenter::CanConstrict(BOOL* pYes)
{
- CheckPointer(pYes, E_POINTER);
- *pYes = TRUE;
- return S_OK;
+ CheckPointer(pYes, E_POINTER);
+ *pYes = TRUE;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::SetConstriction(DWORD dwKPix)
{
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::DisableImageExport(BOOL bDisable)
{
- return S_OK;
+ return S_OK;
}
// IDirect3DDeviceManager9
-STDMETHODIMP CEVRAllocatorPresenter::ResetDevice(IDirect3DDevice9 *pDevice,UINT resetToken)
+STDMETHODIMP CEVRAllocatorPresenter::ResetDevice(IDirect3DDevice9* pDevice, UINT resetToken)
{
- HRESULT hr = m_pD3DManager->ResetDevice (pDevice, resetToken);
- return hr;
+ HRESULT hr = m_pD3DManager->ResetDevice(pDevice, resetToken);
+ return hr;
}
-STDMETHODIMP CEVRAllocatorPresenter::OpenDeviceHandle(HANDLE *phDevice)
+STDMETHODIMP CEVRAllocatorPresenter::OpenDeviceHandle(HANDLE* phDevice)
{
- HRESULT hr = m_pD3DManager->OpenDeviceHandle (phDevice);
- return hr;
+ HRESULT hr = m_pD3DManager->OpenDeviceHandle(phDevice);
+ return hr;
}
STDMETHODIMP CEVRAllocatorPresenter::CloseDeviceHandle(HANDLE hDevice)
{
- HRESULT hr = m_pD3DManager->CloseDeviceHandle(hDevice);
- return hr;
+ HRESULT hr = m_pD3DManager->CloseDeviceHandle(hDevice);
+ return hr;
}
STDMETHODIMP CEVRAllocatorPresenter::TestDevice(HANDLE hDevice)
{
- HRESULT hr = m_pD3DManager->TestDevice(hDevice);
- return hr;
+ HRESULT hr = m_pD3DManager->TestDevice(hDevice);
+ return hr;
}
-STDMETHODIMP CEVRAllocatorPresenter::LockDevice(HANDLE hDevice, IDirect3DDevice9 **ppDevice, BOOL fBlock)
+STDMETHODIMP CEVRAllocatorPresenter::LockDevice(HANDLE hDevice, IDirect3DDevice9** ppDevice, BOOL fBlock)
{
- HRESULT hr = m_pD3DManager->LockDevice(hDevice, ppDevice, fBlock);
- return hr;
+ HRESULT hr = m_pD3DManager->LockDevice(hDevice, ppDevice, fBlock);
+ return hr;
}
STDMETHODIMP CEVRAllocatorPresenter::UnlockDevice(HANDLE hDevice, BOOL fSaveState)
{
- HRESULT hr = m_pD3DManager->UnlockDevice(hDevice, fSaveState);
- return hr;
+ HRESULT hr = m_pD3DManager->UnlockDevice(hDevice, fSaveState);
+ return hr;
}
-STDMETHODIMP CEVRAllocatorPresenter::GetVideoService(HANDLE hDevice, REFIID riid, void **ppService)
+STDMETHODIMP CEVRAllocatorPresenter::GetVideoService(HANDLE hDevice, REFIID riid, void** ppService)
{
- HRESULT hr = m_pD3DManager->GetVideoService(hDevice, riid, ppService);
+ HRESULT hr = m_pD3DManager->GetVideoService(hDevice, riid, ppService);
- if (riid == __uuidof(IDirectXVideoDecoderService)) {
- UINT nNbDecoder = 5;
- GUID* pDecoderGuid;
- IDirectXVideoDecoderService* pDXVAVideoDecoder = (IDirectXVideoDecoderService*) *ppService;
- pDXVAVideoDecoder->GetDecoderDeviceGuids (&nNbDecoder, &pDecoderGuid);
- } else if (riid == __uuidof(IDirectXVideoProcessorService)) {
- IDirectXVideoProcessorService* pDXVAProcessor = (IDirectXVideoProcessorService*) *ppService;
- UNREFERENCED_PARAMETER(pDXVAProcessor);
- }
+ if (riid == __uuidof(IDirectXVideoDecoderService)) {
+ UINT nNbDecoder = 5;
+ GUID* pDecoderGuid;
+ IDirectXVideoDecoderService* pDXVAVideoDecoder = (IDirectXVideoDecoderService*) *ppService;
+ pDXVAVideoDecoder->GetDecoderDeviceGuids(&nNbDecoder, &pDecoderGuid);
+ } else if (riid == __uuidof(IDirectXVideoProcessorService)) {
+ IDirectXVideoProcessorService* pDXVAProcessor = (IDirectXVideoProcessorService*) *ppService;
+ UNREFERENCED_PARAMETER(pDXVAProcessor);
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CEVRAllocatorPresenter::GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight)
{
- // This function should be called...
- ASSERT (FALSE);
+ // This function should be called...
+ ASSERT(FALSE);
- if (lpWidth) {
- *lpWidth = m_NativeVideoSize.cx;
- }
- if (lpHeight) {
- *lpHeight = m_NativeVideoSize.cy;
- }
- if (lpARWidth) {
- *lpARWidth = m_AspectRatio.cx;
- }
- if (lpARHeight) {
- *lpARHeight = m_AspectRatio.cy;
- }
- return S_OK;
+ if (lpWidth) {
+ *lpWidth = m_NativeVideoSize.cx;
+ }
+ if (lpHeight) {
+ *lpHeight = m_NativeVideoSize.cy;
+ }
+ if (lpARWidth) {
+ *lpARWidth = m_AspectRatio.cx;
+ }
+ if (lpARHeight) {
+ *lpARHeight = m_AspectRatio.cy;
+ }
+ return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::InitializeDevice(IMFMediaType* pMediaType)
{
- HRESULT hr;
- CAutoLock lock(this);
- CAutoLock lock2(&m_ImageProcessingLock);
- CAutoLock cRenderLock(&m_RenderLock);
+ HRESULT hr;
+ CAutoLock lock(this);
+ CAutoLock lock2(&m_ImageProcessingLock);
+ CAutoLock cRenderLock(&m_RenderLock);
- RemoveAllSamples();
- DeleteSurfaces();
+ RemoveAllSamples();
+ DeleteSurfaces();
- // Retrieve the surface size and format
- UINT32 Width;
- UINT32 Height;
- hr = MFGetAttributeSize(pMediaType, MF_MT_FRAME_SIZE, &Width, &Height);
+ // Retrieve the surface size and format
+ UINT32 Width;
+ UINT32 Height;
+ hr = MFGetAttributeSize(pMediaType, MF_MT_FRAME_SIZE, &Width, &Height);
- D3DFORMAT Format;
- if (SUCCEEDED(hr)) {
- m_NativeVideoSize = CSize(Width, Height);
- hr = GetMediaTypeFourCC(pMediaType, (DWORD*)&Format);
- }
+ D3DFORMAT Format;
+ if (SUCCEEDED(hr)) {
+ m_NativeVideoSize = CSize(Width, Height);
+ hr = GetMediaTypeFourCC(pMediaType, (DWORD*)&Format);
+ }
- if (SUCCEEDED(hr)) {
- hr = AllocSurfaces();
- }
+ if (SUCCEEDED(hr)) {
+ hr = AllocSurfaces();
+ }
- if (SUCCEEDED(hr)) {
- for (int i = 0; i < m_nNbDXSurface; i++) {
- CComPtr<IMFSample> pMFSample;
- hr = pfMFCreateVideoSampleFromSurface (m_pVideoSurface[i], &pMFSample);
+ if (SUCCEEDED(hr)) {
+ for (int i = 0; i < m_nNbDXSurface; i++) {
+ CComPtr<IMFSample> pMFSample;
+ hr = pfMFCreateVideoSampleFromSurface(m_pVideoSurface[i], &pMFSample);
- if (SUCCEEDED (hr)) {
- pMFSample->SetUINT32 (GUID_SURFACE_INDEX, i);
- m_FreeSamples.AddTail (pMFSample);
- }
- ASSERT (SUCCEEDED (hr));
- }
- }
+ if (SUCCEEDED(hr)) {
+ pMFSample->SetUINT32(GUID_SURFACE_INDEX, i);
+ m_FreeSamples.AddTail(pMFSample);
+ }
+ ASSERT(SUCCEEDED(hr));
+ }
+ }
- return hr;
+ return hr;
}
DWORD WINAPI CEVRAllocatorPresenter::GetMixerThreadStatic(LPVOID lpParam)
{
- SetThreadName((DWORD)-1, "CEVRPresenter::MixerThread");
- CEVRAllocatorPresenter* pThis = (CEVRAllocatorPresenter*) lpParam;
- pThis->GetMixerThread();
- return 0;
+ SetThreadName((DWORD) - 1, "CEVRPresenter::MixerThread");
+ CEVRAllocatorPresenter* pThis = (CEVRAllocatorPresenter*) lpParam;
+ pThis->GetMixerThread();
+ return 0;
}
DWORD WINAPI CEVRAllocatorPresenter::PresentThread(LPVOID lpParam)
{
- SetThreadName((DWORD)-1, "CEVRPresenter::PresentThread");
- CEVRAllocatorPresenter* pThis = (CEVRAllocatorPresenter*) lpParam;
- pThis->RenderThread();
- return 0;
+ SetThreadName((DWORD) - 1, "CEVRPresenter::PresentThread");
+ CEVRAllocatorPresenter* pThis = (CEVRAllocatorPresenter*) lpParam;
+ pThis->RenderThread();
+ return 0;
}
void CEVRAllocatorPresenter::CheckWaitingSampleFromMixer()
{
- if (m_bWaitingSample) {
- m_bWaitingSample = false;
- //GetImageFromMixer(); // Do this in processing thread instead
- }
+ if (m_bWaitingSample) {
+ m_bWaitingSample = false;
+ //GetImageFromMixer(); // Do this in processing thread instead
+ }
}
bool ExtractInterlaced(const AM_MEDIA_TYPE* pmt)
{
- if (pmt->formattype==FORMAT_VideoInfo) {
- return false;
- } else if (pmt->formattype==FORMAT_VideoInfo2) {
- return (((VIDEOINFOHEADER2*)pmt->pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced) != 0;
- } else if (pmt->formattype==FORMAT_MPEGVideo) {
- return false;
- } else if (pmt->formattype==FORMAT_MPEG2Video) {
- return (((MPEG2VIDEOINFO*)pmt->pbFormat)->hdr.dwInterlaceFlags & AMINTERLACE_IsInterlaced) != 0;
- } else {
- return false;
- }
+ if (pmt->formattype == FORMAT_VideoInfo) {
+ return false;
+ } else if (pmt->formattype == FORMAT_VideoInfo2) {
+ return (((VIDEOINFOHEADER2*)pmt->pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced) != 0;
+ } else if (pmt->formattype == FORMAT_MPEGVideo) {
+ return false;
+ } else if (pmt->formattype == FORMAT_MPEG2Video) {
+ return (((MPEG2VIDEOINFO*)pmt->pbFormat)->hdr.dwInterlaceFlags & AMINTERLACE_IsInterlaced) != 0;
+ } else {
+ return false;
+ }
}
void CEVRAllocatorPresenter::GetMixerThread()
{
- //HANDLE hAvrt;
- HANDLE hEvts[] = { m_hEvtQuit};
- bool bQuit = false;
- TIMECAPS tc;
- DWORD dwResolution;
- DWORD dwUser = 0;
- //DWORD dwTaskIndex = 0;
-
- // Tell Vista Multimedia Class Scheduler we are a playback thretad (increase priority)
- // if (pfAvSetMmThreadCharacteristicsW)
- // hAvrt = pfAvSetMmThreadCharacteristicsW (L"Playback", &dwTaskIndex);
- // if (pfAvSetMmThreadPriority)
- // pfAvSetMmThreadPriority (hAvrt, AVRT_PRIORITY_HIGH /*AVRT_PRIORITY_CRITICAL*/);
-
- timeGetDevCaps(&tc, sizeof(TIMECAPS));
- dwResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
- dwUser = timeBeginPeriod(dwResolution);
-
- while (!bQuit) {
- DWORD dwObject = WaitForMultipleObjects (_countof(hEvts), hEvts, FALSE, 1);
- switch (dwObject) {
- case WAIT_OBJECT_0 :
- bQuit = true;
- break;
- case WAIT_TIMEOUT : {
- if (GetRenderersData()->m_fDisplayStats) {
- CComPtr<IPin> pPin;
- CComPtr<IPin> pPinTo;
- if (SUCCEEDED (m_pOuterEVR->FindPin(L"EVR Input0", &pPin)) &&
- SUCCEEDED(pPin->ConnectedTo(&pPinTo)) && pPinTo) {
- if (CComPtr<IBaseFilter> pFilter = GetFilterFromPin(pPinTo) ) {
- if (CComQIPtr<IMPCVideoDecFilter2> MPCVideoDecFilter = pFilter ) {
- m_nFrameType = (FF_FIELD_TYPE)MPCVideoDecFilter->GetFrameType();
- }
- }
- }
- }
-
- bool bDoneSomething = false;
- {
- CAutoLock AutoLock(&m_ImageProcessingLock);
- bDoneSomething = GetImageFromMixer();
- }
- if (m_rtTimePerFrame == 0 && bDoneSomething) {
- //CAutoLock lock(this);
- //CAutoLock lock2(&m_ImageProcessingLock);
- //CAutoLock cRenderLock(&m_RenderLock);
-
- // Use the code from VMR9 to get the movie fps, as this method is reliable.
- CComPtr<IPin> pPin;
- CMediaType mt;
- if (
- SUCCEEDED (m_pOuterEVR->FindPin(L"EVR Input0", &pPin)) &&
- SUCCEEDED (pPin->ConnectionMediaType(&mt)) ) {
-
- ExtractAvgTimePerFrame (&mt, m_rtTimePerFrame);
-
- m_bInterlaced = ExtractInterlaced(&mt);
-
- CComPtr<IPin> pPinTo;
- if (SUCCEEDED(pPin->ConnectedTo(&pPinTo)) && pPinTo) {
- m_Decoder = GetFilterName(GetFilterFromPin(pPinTo));
- }
- }
- // If framerate not set by Video Decoder choose 23.97...
- if (m_rtTimePerFrame == 0) {
- m_rtTimePerFrame = 417166;
- }
-
- // Update internal subtitle clock
- if (m_fUseInternalTimer && m_pSubPicQueue) {
- m_fps = (float)(10000000.0 / m_rtTimePerFrame);
- m_pSubPicQueue->SetFPS(m_fps);
- }
-
- }
-
- }
- break;
- }
- }
-
- timeEndPeriod (dwResolution);
- // if (pfAvRevertMmThreadCharacteristics) pfAvRevertMmThreadCharacteristics (hAvrt);
+ //HANDLE hAvrt;
+ HANDLE hEvts[] = { m_hEvtQuit};
+ bool bQuit = false;
+ TIMECAPS tc;
+ DWORD dwResolution;
+ DWORD dwUser = 0;
+ //DWORD dwTaskIndex = 0;
+
+ // Tell Vista Multimedia Class Scheduler we are a playback thretad (increase priority)
+ // if (pfAvSetMmThreadCharacteristicsW)
+ // hAvrt = pfAvSetMmThreadCharacteristicsW (L"Playback", &dwTaskIndex);
+ // if (pfAvSetMmThreadPriority)
+ // pfAvSetMmThreadPriority (hAvrt, AVRT_PRIORITY_HIGH /*AVRT_PRIORITY_CRITICAL*/);
+
+ timeGetDevCaps(&tc, sizeof(TIMECAPS));
+ dwResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
+ dwUser = timeBeginPeriod(dwResolution);
+
+ while (!bQuit) {
+ DWORD dwObject = WaitForMultipleObjects(_countof(hEvts), hEvts, FALSE, 1);
+ switch (dwObject) {
+ case WAIT_OBJECT_0 :
+ bQuit = true;
+ break;
+ case WAIT_TIMEOUT : {
+ if (GetRenderersData()->m_fDisplayStats) {
+ CComPtr<IPin> pPin;
+ CComPtr<IPin> pPinTo;
+ if (SUCCEEDED(m_pOuterEVR->FindPin(L"EVR Input0", &pPin)) &&
+ SUCCEEDED(pPin->ConnectedTo(&pPinTo)) && pPinTo) {
+ if (CComPtr<IBaseFilter> pFilter = GetFilterFromPin(pPinTo)) {
+ if (CComQIPtr<IMPCVideoDecFilter2> MPCVideoDecFilter = pFilter) {
+ m_nFrameType = (FF_FIELD_TYPE)MPCVideoDecFilter->GetFrameType();
+ }
+ }
+ }
+ }
+
+ bool bDoneSomething = false;
+ {
+ CAutoLock AutoLock(&m_ImageProcessingLock);
+ bDoneSomething = GetImageFromMixer();
+ }
+ if (m_rtTimePerFrame == 0 && bDoneSomething) {
+ //CAutoLock lock(this);
+ //CAutoLock lock2(&m_ImageProcessingLock);
+ //CAutoLock cRenderLock(&m_RenderLock);
+
+ // Use the code from VMR9 to get the movie fps, as this method is reliable.
+ CComPtr<IPin> pPin;
+ CMediaType mt;
+ if (
+ SUCCEEDED(m_pOuterEVR->FindPin(L"EVR Input0", &pPin)) &&
+ SUCCEEDED(pPin->ConnectionMediaType(&mt))) {
+
+ ExtractAvgTimePerFrame(&mt, m_rtTimePerFrame);
+
+ m_bInterlaced = ExtractInterlaced(&mt);
+
+ CComPtr<IPin> pPinTo;
+ if (SUCCEEDED(pPin->ConnectedTo(&pPinTo)) && pPinTo) {
+ m_Decoder = GetFilterName(GetFilterFromPin(pPinTo));
+ }
+ }
+ // If framerate not set by Video Decoder choose 23.97...
+ if (m_rtTimePerFrame == 0) {
+ m_rtTimePerFrame = 417166;
+ }
+
+ // Update internal subtitle clock
+ if (m_fUseInternalTimer && m_pSubPicQueue) {
+ m_fps = (float)(10000000.0 / m_rtTimePerFrame);
+ m_pSubPicQueue->SetFPS(m_fps);
+ }
+
+ }
+
+ }
+ break;
+ }
+ }
+
+ timeEndPeriod(dwResolution);
+ // if (pfAvRevertMmThreadCharacteristics) pfAvRevertMmThreadCharacteristics (hAvrt);
}
void ModerateFloat(double& Value, double Target, double& ValuePrim, double ChangeSpeed)
{
- double xbiss = (-(ChangeSpeed)*(ValuePrim) - (Value-Target)*(ChangeSpeed*ChangeSpeed)*0.25f);
- ValuePrim += xbiss;
- Value += ValuePrim;
+ double xbiss = (-(ChangeSpeed) * (ValuePrim) - (Value - Target) * (ChangeSpeed * ChangeSpeed) * 0.25f);
+ ValuePrim += xbiss;
+ Value += ValuePrim;
}
LONGLONG CEVRAllocatorPresenter::GetClockTime(LONGLONG PerformanceCounter)
{
- LONGLONG llClockTime;
- MFTIME nsCurrentTime;
- m_pClock->GetCorrelatedTime(0, &llClockTime, &nsCurrentTime);
- DWORD Characteristics = 0;
- m_pClock->GetClockCharacteristics(&Characteristics);
- MFCLOCK_STATE State;
- m_pClock->GetState(0, &State);
-
- if (!(Characteristics & MFCLOCK_CHARACTERISTICS_FLAG_FREQUENCY_10MHZ)) {
- MFCLOCK_PROPERTIES Props;
- if (m_pClock->GetProperties(&Props) == S_OK) {
- llClockTime = (llClockTime * 10000000) / Props.qwClockFrequency; // Make 10 MHz
- }
-
- }
- LONGLONG llPerf = PerformanceCounter;
- // return llClockTime + (llPerf - nsCurrentTime);
- double Target = llClockTime + (llPerf - nsCurrentTime) * m_ModeratedTimeSpeed;
-
- bool bReset = false;
- if (m_ModeratedTimeLast < 0 || State != m_LastClockState || m_ModeratedClockLast < 0) {
- bReset = true;
- m_ModeratedTimeLast = llPerf;
- m_ModeratedClockLast = llClockTime;
- }
-
- m_LastClockState = State;
-
- LONGLONG TimeChangeM = llPerf - m_ModeratedTimeLast;
- LONGLONG ClockChangeM = llClockTime - m_ModeratedClockLast;
- UNREFERENCED_PARAMETER(ClockChangeM);
-
- m_ModeratedTimeLast = llPerf;
- m_ModeratedClockLast = llClockTime;
+ LONGLONG llClockTime;
+ MFTIME nsCurrentTime;
+ m_pClock->GetCorrelatedTime(0, &llClockTime, &nsCurrentTime);
+ DWORD Characteristics = 0;
+ m_pClock->GetClockCharacteristics(&Characteristics);
+ MFCLOCK_STATE State;
+ m_pClock->GetState(0, &State);
+
+ if (!(Characteristics & MFCLOCK_CHARACTERISTICS_FLAG_FREQUENCY_10MHZ)) {
+ MFCLOCK_PROPERTIES Props;
+ if (m_pClock->GetProperties(&Props) == S_OK) {
+ llClockTime = (llClockTime * 10000000) / Props.qwClockFrequency; // Make 10 MHz
+ }
+
+ }
+ LONGLONG llPerf = PerformanceCounter;
+ // return llClockTime + (llPerf - nsCurrentTime);
+ double Target = llClockTime + (llPerf - nsCurrentTime) * m_ModeratedTimeSpeed;
+
+ bool bReset = false;
+ if (m_ModeratedTimeLast < 0 || State != m_LastClockState || m_ModeratedClockLast < 0) {
+ bReset = true;
+ m_ModeratedTimeLast = llPerf;
+ m_ModeratedClockLast = llClockTime;
+ }
+
+ m_LastClockState = State;
+
+ LONGLONG TimeChangeM = llPerf - m_ModeratedTimeLast;
+ LONGLONG ClockChangeM = llClockTime - m_ModeratedClockLast;
+ UNREFERENCED_PARAMETER(ClockChangeM);
+
+ m_ModeratedTimeLast = llPerf;
+ m_ModeratedClockLast = llClockTime;
#if 1
- if (bReset) {
- m_ModeratedTimeSpeed = 1.0;
- m_ModeratedTimeSpeedPrim = 0.0;
- ZeroMemory(m_TimeChangeHistory, sizeof(m_TimeChangeHistory));
- ZeroMemory(m_ClockChangeHistory, sizeof(m_ClockChangeHistory));
- m_ClockTimeChangeHistoryPos = 0;
- }
- if (TimeChangeM) {
- int Pos = m_ClockTimeChangeHistoryPos % 100;
- int nHistory = min(m_ClockTimeChangeHistoryPos, 100);
- ++m_ClockTimeChangeHistoryPos;
- if (nHistory > 50) {
- int iLastPos = (Pos - (nHistory)) % 100;
- if (iLastPos < 0) {
- iLastPos += 100;
- }
-
- double TimeChange = llPerf - m_TimeChangeHistory[iLastPos];
- double ClockChange = llClockTime - m_ClockChangeHistory[iLastPos];
-
- double ClockSpeedTarget = ClockChange / TimeChange;
- double ChangeSpeed = 0.1;
- if (ClockSpeedTarget > m_ModeratedTimeSpeed) {
- if (ClockSpeedTarget / m_ModeratedTimeSpeed > 0.1) {
- ChangeSpeed = 0.1;
- } else {
- ChangeSpeed = 0.01;
- }
- } else {
- if (m_ModeratedTimeSpeed / ClockSpeedTarget > 0.1) {
- ChangeSpeed = 0.1;
- } else {
- ChangeSpeed = 0.01;
- }
- }
- ModerateFloat(m_ModeratedTimeSpeed, ClockSpeedTarget, m_ModeratedTimeSpeedPrim, ChangeSpeed);
- // m_ModeratedTimeSpeed = TimeChange / ClockChange;
- }
- m_TimeChangeHistory[Pos] = (double)llPerf;
- m_ClockChangeHistory[Pos] = (double)llClockTime;
- }
-
- return (LONGLONG)Target;
+ if (bReset) {
+ m_ModeratedTimeSpeed = 1.0;
+ m_ModeratedTimeSpeedPrim = 0.0;
+ ZeroMemory(m_TimeChangeHistory, sizeof(m_TimeChangeHistory));
+ ZeroMemory(m_ClockChangeHistory, sizeof(m_ClockChangeHistory));
+ m_ClockTimeChangeHistoryPos = 0;
+ }
+ if (TimeChangeM) {
+ int Pos = m_ClockTimeChangeHistoryPos % 100;
+ int nHistory = min(m_ClockTimeChangeHistoryPos, 100);
+ ++m_ClockTimeChangeHistoryPos;
+ if (nHistory > 50) {
+ int iLastPos = (Pos - (nHistory)) % 100;
+ if (iLastPos < 0) {
+ iLastPos += 100;
+ }
+
+ double TimeChange = llPerf - m_TimeChangeHistory[iLastPos];
+ double ClockChange = llClockTime - m_ClockChangeHistory[iLastPos];
+
+ double ClockSpeedTarget = ClockChange / TimeChange;
+ double ChangeSpeed = 0.1;
+ if (ClockSpeedTarget > m_ModeratedTimeSpeed) {
+ if (ClockSpeedTarget / m_ModeratedTimeSpeed > 0.1) {
+ ChangeSpeed = 0.1;
+ } else {
+ ChangeSpeed = 0.01;
+ }
+ } else {
+ if (m_ModeratedTimeSpeed / ClockSpeedTarget > 0.1) {
+ ChangeSpeed = 0.1;
+ } else {
+ ChangeSpeed = 0.01;
+ }
+ }
+ ModerateFloat(m_ModeratedTimeSpeed, ClockSpeedTarget, m_ModeratedTimeSpeedPrim, ChangeSpeed);
+ // m_ModeratedTimeSpeed = TimeChange / ClockChange;
+ }
+ m_TimeChangeHistory[Pos] = (double)llPerf;
+ m_ClockChangeHistory[Pos] = (double)llClockTime;
+ }
+
+ return (LONGLONG)Target;
#else
- double EstimateTime = m_ModeratedTime + TimeChange * m_ModeratedTimeSpeed + m_ClockDiffCalc;
- double Diff = Target - EstimateTime;
-
- // > 5 ms just set it
- if ((fabs(Diff) > 50000.0 || bReset)) {
-
- // TRACE_EVR("EVR: Reset clock at diff: %f ms\n", (m_ModeratedTime - Target) /10000.0);
- if (State == MFCLOCK_STATE_RUNNING) {
- if (bReset) {
- m_ModeratedTimeSpeed = 1.0;
- m_ModeratedTimeSpeedPrim = 0.0;
- m_ClockDiffCalc = 0;
- m_ClockDiffPrim = 0;
- m_ModeratedTime = Target;
- m_ModeratedTimer = llPerf;
- } else {
- EstimateTime = m_ModeratedTime + TimeChange * m_ModeratedTimeSpeed;
- Diff = Target - EstimateTime;
- m_ClockDiffCalc = Diff;
- m_ClockDiffPrim = 0;
- }
- } else {
- m_ModeratedTimeSpeed = 0.0;
- m_ModeratedTimeSpeedPrim = 0.0;
- m_ClockDiffCalc = 0;
- m_ClockDiffPrim = 0;
- m_ModeratedTime = Target;
- m_ModeratedTimer = llPerf;
- }
- }
-
- {
- LONGLONG ModerateTime = 10000;
- double ChangeSpeed = 1.00;
- /* if (m_ModeratedTimeSpeedPrim != 0.0)
- {
- if (m_ModeratedTimeSpeedPrim < 0.1)
- ChangeSpeed = 0.1;
- }*/
-
- int nModerate = 0;
- double Change = 0;
- while (m_ModeratedTimer < llPerf - ModerateTime) {
- m_ModeratedTimer += ModerateTime;
- m_ModeratedTime += double(ModerateTime) * m_ModeratedTimeSpeed;
-
- double TimerDiff = llPerf - m_ModeratedTimer;
-
- double Diff = (double)(m_ModeratedTime - (Target - TimerDiff));
-
- double TimeSpeedTarget;
- double AbsDiff = fabs(Diff);
- TimeSpeedTarget = 1.0 - (Diff / 1000000.0);
- // TimeSpeedTarget = m_ModeratedTimeSpeed - (Diff / 100000000000.0);
- //if (AbsDiff > 20000.0)
- // TimeSpeedTarget = 1.0 - (Diff / 1000000.0);
- /*else if (AbsDiff > 5000.0)
- TimeSpeedTarget = 1.0 - (Diff / 100000000.0);
- else
- TimeSpeedTarget = 1.0 - (Diff / 500000000.0);*/
- double StartMod = m_ModeratedTimeSpeed;
- ModerateFloat(m_ModeratedTimeSpeed, TimeSpeedTarget, m_ModeratedTimeSpeedPrim, ChangeSpeed);
- m_ModeratedTimeSpeed = TimeSpeedTarget;
- ++nModerate;
- Change += m_ModeratedTimeSpeed - StartMod;
- }
- if (nModerate) {
- m_ModeratedTimeSpeedDiff = Change / nModerate;
- }
-
- double Ret = m_ModeratedTime + double(llPerf - m_ModeratedTimer) * m_ModeratedTimeSpeed;
- double Diff = Target - Ret;
- ModerateFloat(m_ClockDiffCalc, Diff, m_ClockDiffPrim, ChangeSpeed*0.1);
-
- Ret += m_ClockDiffCalc;
- Diff = Target - Ret;
- m_ClockDiff = Diff;
- return LONGLONG(Ret + 0.5);
- }
-
- return Target;
- return LONGLONG(m_ModeratedTime + 0.5);
+ double EstimateTime = m_ModeratedTime + TimeChange * m_ModeratedTimeSpeed + m_ClockDiffCalc;
+ double Diff = Target - EstimateTime;
+
+ // > 5 ms just set it
+ if ((fabs(Diff) > 50000.0 || bReset)) {
+
+ // TRACE_EVR("EVR: Reset clock at diff: %f ms\n", (m_ModeratedTime - Target) /10000.0);
+ if (State == MFCLOCK_STATE_RUNNING) {
+ if (bReset) {
+ m_ModeratedTimeSpeed = 1.0;
+ m_ModeratedTimeSpeedPrim = 0.0;
+ m_ClockDiffCalc = 0;
+ m_ClockDiffPrim = 0;
+ m_ModeratedTime = Target;
+ m_ModeratedTimer = llPerf;
+ } else {
+ EstimateTime = m_ModeratedTime + TimeChange * m_ModeratedTimeSpeed;
+ Diff = Target - EstimateTime;
+ m_ClockDiffCalc = Diff;
+ m_ClockDiffPrim = 0;
+ }
+ } else {
+ m_ModeratedTimeSpeed = 0.0;
+ m_ModeratedTimeSpeedPrim = 0.0;
+ m_ClockDiffCalc = 0;
+ m_ClockDiffPrim = 0;
+ m_ModeratedTime = Target;
+ m_ModeratedTimer = llPerf;
+ }
+ }
+
+ {
+ LONGLONG ModerateTime = 10000;
+ double ChangeSpeed = 1.00;
+ /* if (m_ModeratedTimeSpeedPrim != 0.0)
+ {
+ if (m_ModeratedTimeSpeedPrim < 0.1)
+ ChangeSpeed = 0.1;
+ }*/
+
+ int nModerate = 0;
+ double Change = 0;
+ while (m_ModeratedTimer < llPerf - ModerateTime) {
+ m_ModeratedTimer += ModerateTime;
+ m_ModeratedTime += double(ModerateTime) * m_ModeratedTimeSpeed;
+
+ double TimerDiff = llPerf - m_ModeratedTimer;
+
+ double Diff = (double)(m_ModeratedTime - (Target - TimerDiff));
+
+ double TimeSpeedTarget;
+ double AbsDiff = fabs(Diff);
+ TimeSpeedTarget = 1.0 - (Diff / 1000000.0);
+ // TimeSpeedTarget = m_ModeratedTimeSpeed - (Diff / 100000000000.0);
+ //if (AbsDiff > 20000.0)
+ // TimeSpeedTarget = 1.0 - (Diff / 1000000.0);
+ /*else if (AbsDiff > 5000.0)
+ TimeSpeedTarget = 1.0 - (Diff / 100000000.0);
+ else
+ TimeSpeedTarget = 1.0 - (Diff / 500000000.0);*/
+ double StartMod = m_ModeratedTimeSpeed;
+ ModerateFloat(m_ModeratedTimeSpeed, TimeSpeedTarget, m_ModeratedTimeSpeedPrim, ChangeSpeed);
+ m_ModeratedTimeSpeed = TimeSpeedTarget;
+ ++nModerate;
+ Change += m_ModeratedTimeSpeed - StartMod;
+ }
+ if (nModerate) {
+ m_ModeratedTimeSpeedDiff = Change / nModerate;
+ }
+
+ double Ret = m_ModeratedTime + double(llPerf - m_ModeratedTimer) * m_ModeratedTimeSpeed;
+ double Diff = Target - Ret;
+ ModerateFloat(m_ClockDiffCalc, Diff, m_ClockDiffPrim, ChangeSpeed * 0.1);
+
+ Ret += m_ClockDiffCalc;
+ Diff = Target - Ret;
+ m_ClockDiff = Diff;
+ return LONGLONG(Ret + 0.5);
+ }
+
+ return Target;
+ return LONGLONG(m_ModeratedTime + 0.5);
#endif
}
void CEVRAllocatorPresenter::OnVBlankFinished(bool fAll, LONGLONG PerformanceCounter)
{
- if (!m_pCurrentDisplaydSample || !m_OrderedPaint || !fAll) {
- return;
- }
-
- LONGLONG llClockTime;
- LONGLONG nsSampleTime;
- LONGLONG SampleDuration = 0;
- if (!m_bSignaledStarvation) {
- llClockTime = GetClockTime(PerformanceCounter);
- m_StarvationClock = llClockTime;
- } else {
- llClockTime = m_StarvationClock;
- }
- if (FAILED(m_pCurrentDisplaydSample->GetSampleDuration(&SampleDuration))) {
- SampleDuration = 0;
- }
-
- if (FAILED(m_pCurrentDisplaydSample->GetSampleTime(&nsSampleTime))) {
- nsSampleTime = llClockTime;
- }
- LONGLONG TimePerFrame = m_rtTimePerFrame;
- if (!TimePerFrame) {
- return;
- }
- if (SampleDuration > 1) {
- TimePerFrame = SampleDuration;
- }
- {
- m_nNextSyncOffset = (m_nNextSyncOffset+1) % NB_JITTER;
- LONGLONG SyncOffset = nsSampleTime - llClockTime;
-
- m_pllSyncOffset[m_nNextSyncOffset] = SyncOffset;
- // TRACE_EVR("EVR: SyncOffset(%d, %d): %8I64d %8I64d %8I64d \n", m_nCurSurface, m_VSyncMode, m_LastPredictedSync, -SyncOffset, m_LastPredictedSync - (-SyncOffset));
-
- m_MaxSyncOffset = MINLONG64;
- m_MinSyncOffset = MAXLONG64;
-
- LONGLONG AvrageSum = 0;
- for (int i=0; i<NB_JITTER; i++) {
- LONGLONG Offset = m_pllSyncOffset[i];
- AvrageSum += Offset;
- m_MaxSyncOffset = max(m_MaxSyncOffset, Offset);
- m_MinSyncOffset = min(m_MinSyncOffset, Offset);
- }
- double MeanOffset = double(AvrageSum)/NB_JITTER;
- double DeviationSum = 0;
- for (int i=0; i<NB_JITTER; i++) {
- double Deviation = double(m_pllSyncOffset[i]) - MeanOffset;
- DeviationSum += Deviation*Deviation;
- }
- double StdDev = sqrt(DeviationSum/NB_JITTER);
-
- m_fSyncOffsetAvr = MeanOffset;
- m_bSyncStatsAvailable = true;
- m_fSyncOffsetStdDev = StdDev;
-
-
- }
+ if (!m_pCurrentDisplaydSample || !m_OrderedPaint || !fAll) {
+ return;
+ }
+
+ LONGLONG llClockTime;
+ LONGLONG nsSampleTime;
+ LONGLONG SampleDuration = 0;
+ if (!m_bSignaledStarvation) {
+ llClockTime = GetClockTime(PerformanceCounter);
+ m_StarvationClock = llClockTime;
+ } else {
+ llClockTime = m_StarvationClock;
+ }
+ if (FAILED(m_pCurrentDisplaydSample->GetSampleDuration(&SampleDuration))) {
+ SampleDuration = 0;
+ }
+
+ if (FAILED(m_pCurrentDisplaydSample->GetSampleTime(&nsSampleTime))) {
+ nsSampleTime = llClockTime;
+ }
+ LONGLONG TimePerFrame = m_rtTimePerFrame;
+ if (!TimePerFrame) {
+ return;
+ }
+ if (SampleDuration > 1) {
+ TimePerFrame = SampleDuration;
+ }
+ {
+ m_nNextSyncOffset = (m_nNextSyncOffset + 1) % NB_JITTER;
+ LONGLONG SyncOffset = nsSampleTime - llClockTime;
+
+ m_pllSyncOffset[m_nNextSyncOffset] = SyncOffset;
+ // TRACE_EVR("EVR: SyncOffset(%d, %d): %8I64d %8I64d %8I64d \n", m_nCurSurface, m_VSyncMode, m_LastPredictedSync, -SyncOffset, m_LastPredictedSync - (-SyncOffset));
+
+ m_MaxSyncOffset = MINLONG64;
+ m_MinSyncOffset = MAXLONG64;
+
+ LONGLONG AvrageSum = 0;
+ for (int i = 0; i < NB_JITTER; i++) {
+ LONGLONG Offset = m_pllSyncOffset[i];
+ AvrageSum += Offset;
+ m_MaxSyncOffset = max(m_MaxSyncOffset, Offset);
+ m_MinSyncOffset = min(m_MinSyncOffset, Offset);
+ }
+ double MeanOffset = double(AvrageSum) / NB_JITTER;
+ double DeviationSum = 0;
+ for (int i = 0; i < NB_JITTER; i++) {
+ double Deviation = double(m_pllSyncOffset[i]) - MeanOffset;
+ DeviationSum += Deviation * Deviation;
+ }
+ double StdDev = sqrt(DeviationSum / NB_JITTER);
+
+ m_fSyncOffsetAvr = MeanOffset;
+ m_bSyncStatsAvailable = true;
+ m_fSyncOffsetStdDev = StdDev;
+
+
+ }
}
STDMETHODIMP_(bool) CEVRAllocatorPresenter::ResetDevice()
{
- CAutoLock lock(this);
- CAutoLock lock2(&m_ImageProcessingLock);
- CAutoLock cRenderLock(&m_RenderLock);
+ CAutoLock lock(this);
+ CAutoLock lock2(&m_ImageProcessingLock);
+ CAutoLock cRenderLock(&m_RenderLock);
- RemoveAllSamples();
+ RemoveAllSamples();
- bool bResult = __super::ResetDevice();
+ bool bResult = __super::ResetDevice();
- for (int i = 0; i < m_nNbDXSurface; i++) {
- CComPtr<IMFSample> pMFSample;
- HRESULT hr = pfMFCreateVideoSampleFromSurface (m_pVideoSurface[i], &pMFSample);
+ for (int i = 0; i < m_nNbDXSurface; i++) {
+ CComPtr<IMFSample> pMFSample;
+ HRESULT hr = pfMFCreateVideoSampleFromSurface(m_pVideoSurface[i], &pMFSample);
- if (SUCCEEDED (hr)) {
- pMFSample->SetUINT32 (GUID_SURFACE_INDEX, i);
- m_FreeSamples.AddTail (pMFSample);
- }
- ASSERT (SUCCEEDED (hr));
- }
- return bResult;
+ if (SUCCEEDED(hr)) {
+ pMFSample->SetUINT32(GUID_SURFACE_INDEX, i);
+ m_FreeSamples.AddTail(pMFSample);
+ }
+ ASSERT(SUCCEEDED(hr));
+ }
+ return bResult;
}
STDMETHODIMP_(bool) CEVRAllocatorPresenter::DisplayChange()
{
- CAutoLock lock(this);
- CAutoLock lock2(&m_ImageProcessingLock);
- CAutoLock cRenderLock(&m_RenderLock);
-
- m_DetectedFrameRate = 0.0;
- m_DetectedFrameTime = 0.0;
- m_DetectedFrameTimeStdDev = 0.0;
- m_DetectedLock = false;
- ZeroMemory(m_DetectedFrameTimeHistory, sizeof(m_DetectedFrameTimeHistory));
- ZeroMemory(m_DetectedFrameTimeHistoryHistory, sizeof(m_DetectedFrameTimeHistoryHistory));
- m_DetectedFrameTimePos = 0;
- ZeroMemory(&m_VMR9AlphaBitmap, sizeof(m_VMR9AlphaBitmap));
-
- ZeroMemory(m_ldDetectedRefreshRateList, sizeof(m_ldDetectedRefreshRateList));
- ZeroMemory(m_ldDetectedScanlineRateList, sizeof(m_ldDetectedScanlineRateList));
- m_DetectedRefreshRatePos = 0;
- m_DetectedRefreshTimePrim = 0;
- m_DetectedScanlineTime = 0;
- m_DetectedScanlineTimePrim = 0;
- m_DetectedRefreshRate = 0;
-
- memset (m_pllJitter, 0, sizeof(m_pllJitter));
- memset (m_pllSyncOffset, 0, sizeof(m_pllSyncOffset));
- m_nNextJitter = 0;
- m_nNextSyncOffset = 0;
- m_llLastPerf = 0;
- m_fAvrFps = 0.0;
- m_fJitterStdDev = 0.0;
- m_fSyncOffsetStdDev = 0.0;
- m_fSyncOffsetAvr = 0.0;
- m_bSyncStatsAvailable = false;
-
- bool bResult = __super::DisplayChange();
-
- return bResult;
+ CAutoLock lock(this);
+ CAutoLock lock2(&m_ImageProcessingLock);
+ CAutoLock cRenderLock(&m_RenderLock);
+
+ m_DetectedFrameRate = 0.0;
+ m_DetectedFrameTime = 0.0;
+ m_DetectedFrameTimeStdDev = 0.0;
+ m_DetectedLock = false;
+ ZeroMemory(m_DetectedFrameTimeHistory, sizeof(m_DetectedFrameTimeHistory));
+ ZeroMemory(m_DetectedFrameTimeHistoryHistory, sizeof(m_DetectedFrameTimeHistoryHistory));
+ m_DetectedFrameTimePos = 0;
+ ZeroMemory(&m_VMR9AlphaBitmap, sizeof(m_VMR9AlphaBitmap));
+
+ ZeroMemory(m_ldDetectedRefreshRateList, sizeof(m_ldDetectedRefreshRateList));
+ ZeroMemory(m_ldDetectedScanlineRateList, sizeof(m_ldDetectedScanlineRateList));
+ m_DetectedRefreshRatePos = 0;
+ m_DetectedRefreshTimePrim = 0;
+ m_DetectedScanlineTime = 0;
+ m_DetectedScanlineTimePrim = 0;
+ m_DetectedRefreshRate = 0;
+
+ memset(m_pllJitter, 0, sizeof(m_pllJitter));
+ memset(m_pllSyncOffset, 0, sizeof(m_pllSyncOffset));
+ m_nNextJitter = 0;
+ m_nNextSyncOffset = 0;
+ m_llLastPerf = 0;
+ m_fAvrFps = 0.0;
+ m_fJitterStdDev = 0.0;
+ m_fSyncOffsetStdDev = 0.0;
+ m_fSyncOffsetAvr = 0.0;
+ m_bSyncStatsAvailable = false;
+
+ bool bResult = __super::DisplayChange();
+
+ return bResult;
}
void CEVRAllocatorPresenter::RenderThread()
{
- HANDLE hEvts[] = { m_hEvtQuit, m_hEvtFlush};
- bool bQuit = false;
- TIMECAPS tc;
- DWORD dwResolution;
- MFTIME nsSampleTime;
- LONGLONG llClockTime;
- DWORD dwUser = 0;
- DWORD dwObject;
-
-
- // Tell Vista Multimedia Class Scheduler we are a playback thretad (increase priority)
- HANDLE hAvrt = 0;
- if (pfAvSetMmThreadCharacteristicsW) {
- DWORD dwTaskIndex = 0;
- hAvrt = pfAvSetMmThreadCharacteristicsW (L"Playback", &dwTaskIndex);
- if (pfAvSetMmThreadPriority) {
- pfAvSetMmThreadPriority (hAvrt, AVRT_PRIORITY_HIGH /*AVRT_PRIORITY_CRITICAL*/);
- }
- }
-
- timeGetDevCaps(&tc, sizeof(TIMECAPS));
- dwResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
- dwUser = timeBeginPeriod(dwResolution);
- CRenderersSettings& s = GetRenderersSettings();
-
- int NextSleepTime = 1;
- while (!bQuit) {
- LONGLONG llPerf = GetRenderersData()->GetPerfCounter();
- UNREFERENCED_PARAMETER(llPerf);
- if (!s.m_RenderSettings.iVMR9VSyncAccurate && NextSleepTime == 0) {
- NextSleepTime = 1;
- }
- dwObject = WaitForMultipleObjects (_countof(hEvts), hEvts, FALSE, max(NextSleepTime < 0 ? 1 : NextSleepTime, 0));
- /* dwObject = WAIT_TIMEOUT;
- if (m_bEvtFlush)
- dwObject = WAIT_OBJECT_0 + 1;
- else if (m_bEvtQuit)
- dwObject = WAIT_OBJECT_0;*/
- // if (NextSleepTime)
- // TRACE_EVR("EVR: Sleep: %7.3f\n", double(GetRenderersData()->GetPerfCounter()-llPerf) / 10000.0);
- if (NextSleepTime > 1) {
- NextSleepTime = 0;
- } else if (NextSleepTime == 0) {
- NextSleepTime = -1;
- }
- switch (dwObject) {
- case WAIT_OBJECT_0 :
- bQuit = true;
- break;
- case WAIT_OBJECT_0 + 1 :
- // Flush pending samples!
- FlushSamples();
- m_bEvtFlush = false;
- ResetEvent(m_hEvtFlush);
- TRACE_EVR ("EVR: Flush done!\n");
- break;
-
- case WAIT_TIMEOUT :
-
- if (m_LastSetOutputRange != -1 && m_LastSetOutputRange != s.m_RenderSettings.iEVROutputRange || m_bPendingRenegotiate) {
- FlushSamples();
- RenegotiateMediaType();
- m_bPendingRenegotiate = false;
- }
- if (m_bPendingResetDevice) {
- SendResetRequest();
- }
-
- // Discard timer events if playback stop
- // if ((dwObject == WAIT_OBJECT_0 + 3) && (m_nRenderState != Started)) continue;
-
- // TRACE_EVR ("EVR: RenderThread ==>> Waiting buffer\n");
-
- // if (WaitForMultipleObjects (_countof(hEvtsBuff), hEvtsBuff, FALSE, INFINITE) == WAIT_OBJECT_0+2)
- {
- CComPtr<IMFSample> pMFSample;
- LONGLONG llPerf = GetRenderersData()->GetPerfCounter();
- UNREFERENCED_PARAMETER(llPerf);
- int nSamplesLeft = 0;
- if (SUCCEEDED (GetScheduledSample(&pMFSample, nSamplesLeft))) {
- // pMFSample->GetUINT32 (GUID_SURFACE_INDEX, (UINT32*)&m_nCurSurface);
- m_pCurrentDisplaydSample = pMFSample;
-
- bool bValidSampleTime = true;
- HRESULT hGetSampleTime = pMFSample->GetSampleTime (&nsSampleTime);
- if (hGetSampleTime != S_OK || nsSampleTime == 0) {
- bValidSampleTime = false;
- }
- // We assume that all samples have the same duration
- LONGLONG SampleDuration = 0;
- pMFSample->GetSampleDuration(&SampleDuration);
-
- // TRACE_EVR ("EVR: RenderThread ==>> Presenting surface %d (%I64d)\n", m_nCurSurface, nsSampleTime);
-
- bool bStepForward = false;
-
- if (m_nStepCount < 0) {
- // Drop frame
- TRACE_EVR ("EVR: Dropped frame\n");
- m_pcFrames++;
- bStepForward = true;
- m_nStepCount = 0;
- /*
- } else if (m_nStepCount > 0) {
- pMFSample->GetUINT32(GUID_SURFACE_INDEX, (UINT32 *)&m_nCurSurface);
- ++m_OrderedPaint;
- if (!g_bExternalSubtitleTime) {
- __super::SetTime (g_tSegmentStart + nsSampleTime);
- }
- Paint(true);
- m_nDroppedUpdate = 0;
- CompleteFrameStep (false);
- bStepForward = true;
- */
- } else if ((m_nRenderState == Started)) {
- LONGLONG CurrentCounter = GetRenderersData()->GetPerfCounter();
- // Calculate wake up timer
- if (!m_bSignaledStarvation) {
- llClockTime = GetClockTime(CurrentCounter);
- m_StarvationClock = llClockTime;
- } else {
- llClockTime = m_StarvationClock;
- }
-
- if (!bValidSampleTime) {
- // Just play as fast as possible
- bStepForward = true;
- pMFSample->GetUINT32(GUID_SURFACE_INDEX, (UINT32 *)&m_nCurSurface);
- ++m_OrderedPaint;
- if (!g_bExternalSubtitleTime) {
- __super::SetTime (g_tSegmentStart + nsSampleTime);
- }
- Paint(true);
- } else {
- LONGLONG TimePerFrame = (LONGLONG)(GetFrameTime() * 10000000.0);
- LONGLONG DrawTime = m_PaintTime * 9 / 10 - 20000; // 2 ms offset (= m_PaintTime * 0.9 - 20000)
- //if (!s.iVMR9VSync)
- DrawTime = 0;
-
- LONGLONG SyncOffset = 0;
- LONGLONG VSyncTime = 0;
- LONGLONG TimeToNextVSync = -1;
- bool bVSyncCorrection = false;
- double DetectedRefreshTime;
- double DetectedScanlinesPerFrame;
- double DetectedScanlineTime;
- int DetectedRefreshRatePos;
- {
- CAutoLock Lock(&m_RefreshRateLock);
- DetectedRefreshTime = m_DetectedRefreshTime;
- DetectedRefreshRatePos = m_DetectedRefreshRatePos;
- DetectedScanlinesPerFrame = m_DetectedScanlinesPerFrame;
- DetectedScanlineTime = m_DetectedScanlineTime;
- }
-
- if (DetectedRefreshRatePos < 20 || !DetectedRefreshTime || !DetectedScanlinesPerFrame) {
- DetectedRefreshTime = 1.0/m_RefreshRate;
- DetectedScanlinesPerFrame = m_ScreenSize.cy;
- DetectedScanlineTime = DetectedRefreshTime / double(m_ScreenSize.cy);
- }
-
- if (s.m_RenderSettings.iVMR9VSync) {
- bVSyncCorrection = true;
- double TargetVSyncPos = GetVBlackPos();
- double RefreshLines = DetectedScanlinesPerFrame;
- double ScanlinesPerSecond = 1.0/DetectedScanlineTime;
- double CurrentVSyncPos = fmod(double(m_VBlankStartMeasure) + ScanlinesPerSecond * ((CurrentCounter - m_VBlankStartMeasureTime) / 10000000.0), RefreshLines);
- double LinesUntilVSync = 0;
- //TargetVSyncPos -= ScanlinesPerSecond * (DrawTime/10000000.0);
- //TargetVSyncPos -= 10;
- TargetVSyncPos = fmod(TargetVSyncPos, RefreshLines);
- if (TargetVSyncPos < 0) {
- TargetVSyncPos += RefreshLines;
- }
- if (TargetVSyncPos > CurrentVSyncPos) {
- LinesUntilVSync = TargetVSyncPos - CurrentVSyncPos;
- } else {
- LinesUntilVSync = (RefreshLines - CurrentVSyncPos) + TargetVSyncPos;
- }
- double TimeUntilVSync = LinesUntilVSync * DetectedScanlineTime;
- TimeToNextVSync = (LONGLONG)(TimeUntilVSync * 10000000.0);
- VSyncTime = (LONGLONG)(DetectedRefreshTime * 10000000.0);
-
- LONGLONG ClockTimeAtNextVSync = llClockTime + (LONGLONG)(TimeUntilVSync * 10000000.0 * m_ModeratedTimeSpeed);
-
- SyncOffset = (nsSampleTime - ClockTimeAtNextVSync);
-
- // if (SyncOffset < 0)
- // TRACE_EVR("EVR: SyncOffset(%d): %I64d %I64d %I64d\n", m_nCurSurface, SyncOffset, TimePerFrame, VSyncTime);
- } else {
- SyncOffset = (nsSampleTime - llClockTime);
- }
-
- //LONGLONG SyncOffset = nsSampleTime - llClockTime;
- TRACE_EVR ("EVR: SyncOffset: %I64d SampleFrame: %I64d ClockFrame: %I64d\n", SyncOffset, TimePerFrame!=0 ? nsSampleTime/TimePerFrame : 0, TimePerFrame!=0 ? llClockTime /TimePerFrame : 0);
- if (SampleDuration > 1 && !m_DetectedLock) {
- TimePerFrame = SampleDuration;
- }
-
- LONGLONG MinMargin;
- if (m_FrameTimeCorrection && 0) {
- MinMargin = 15000;
- } else {
- MinMargin = 15000 + min(LONGLONG(m_DetectedFrameTimeStdDev), 20000);
- }
- LONGLONG TimePerFrameMargin = min(max(TimePerFrame*2/100, MinMargin), TimePerFrame*11/100); // (0.02..0.11)TimePerFrame
- LONGLONG TimePerFrameMargin0 = TimePerFrameMargin/2;
- LONGLONG TimePerFrameMargin1 = 0;
-
- if (m_DetectedLock && TimePerFrame < VSyncTime) {
- VSyncTime = TimePerFrame;
- }
-
- if (m_VSyncMode == 1) {
- TimePerFrameMargin1 = -TimePerFrameMargin;
- } else if (m_VSyncMode == 2) {
- TimePerFrameMargin1 = TimePerFrameMargin;
- }
-
- m_LastSampleOffset = SyncOffset;
- m_bLastSampleOffsetValid = true;
-
- LONGLONG VSyncOffset0 = 0;
- bool bDoVSyncCorrection = false;
- if ((SyncOffset < -(TimePerFrame + TimePerFrameMargin0 - TimePerFrameMargin1)) && nSamplesLeft > 0) { // Only drop if we have something else to display at once
- // Drop frame
- TRACE_EVR ("EVR: Dropped frame\n");
- m_pcFrames++;
- bStepForward = true;
- ++m_nDroppedUpdate;
- NextSleepTime = 0;
- // VSyncOffset0 = (-SyncOffset) - VSyncTime;
- //VSyncOffset0 = (-SyncOffset) - VSyncTime + TimePerFrameMargin1;
- //m_LastPredictedSync = VSyncOffset0;
- bDoVSyncCorrection = false;
- } else if (SyncOffset < TimePerFrameMargin1) {
-
- if (bVSyncCorrection) {
- VSyncOffset0 = -SyncOffset;
- bDoVSyncCorrection = true;
- }
-
- // Paint and prepare for next frame
- TRACE_EVR ("EVR: Normalframe\n");
- m_nDroppedUpdate = 0;
- bStepForward = true;
- pMFSample->GetUINT32(GUID_SURFACE_INDEX, (UINT32 *)&m_nCurSurface);
- m_LastFrameDuration = nsSampleTime - m_LastSampleTime;
- m_LastSampleTime = nsSampleTime;
- m_LastPredictedSync = VSyncOffset0;
-
- if (m_nStepCount > 0) {
- CompleteFrameStep (false);
- }
-
- ++m_OrderedPaint;
-
- if (!g_bExternalSubtitleTime) {
- __super::SetTime (g_tSegmentStart + nsSampleTime);
- }
- Paint(true);
-
- NextSleepTime = 0;
- m_pcFramesDrawn++;
- } else {
- if (TimeToNextVSync >= 0 && SyncOffset > 0) {
- NextSleepTime = (int)(TimeToNextVSync/10000 - 2);
- } else {
- NextSleepTime = (int)(SyncOffset/10000 - 2);
- }
-
- if (NextSleepTime > TimePerFrame) {
- NextSleepTime = 1;
- }
-
- if (NextSleepTime < 0) {
- NextSleepTime = 0;
- }
- NextSleepTime = 1;
- //TRACE_EVR ("EVR: Delay\n");
- }
-
- if (bDoVSyncCorrection) {
- //LONGLONG VSyncOffset0 = (((SyncOffset) % VSyncTime) + VSyncTime) % VSyncTime;
- LONGLONG Margin = TimePerFrameMargin;
-
- LONGLONG VSyncOffsetMin = 30000000000000;
- LONGLONG VSyncOffsetMax = -30000000000000;
- for (int i = 0; i < 5; ++i) {
- VSyncOffsetMin = min(m_VSyncOffsetHistory[i], VSyncOffsetMin);
- VSyncOffsetMax = max(m_VSyncOffsetHistory[i], VSyncOffsetMax);
- }
-
- m_VSyncOffsetHistory[m_VSyncOffsetHistoryPos] = VSyncOffset0;
- m_VSyncOffsetHistoryPos = (m_VSyncOffsetHistoryPos + 1) % 5;
-
- // LONGLONG VSyncTime2 = VSyncTime2 + (VSyncOffsetMax - VSyncOffsetMin);
- //VSyncOffsetMin; = (((VSyncOffsetMin) % VSyncTime) + VSyncTime) % VSyncTime;
- //VSyncOffsetMax = (((VSyncOffsetMax) % VSyncTime) + VSyncTime) % VSyncTime;
-
- // TRACE_EVR("EVR: SyncOffset(%d, %d): %8I64d %8I64d %8I64d %8I64d\n", m_nCurSurface, m_VSyncMode,VSyncOffset0, VSyncOffsetMin, VSyncOffsetMax, VSyncOffsetMax - VSyncOffsetMin);
-
- if (m_VSyncMode == 0) {
- // 23.976 in 60 Hz
- if (VSyncOffset0 < Margin && VSyncOffsetMax > (VSyncTime - Margin)) {
- m_VSyncMode = 2;
- } else if (VSyncOffset0 > (VSyncTime - Margin) && VSyncOffsetMin < Margin) {
- m_VSyncMode = 1;
- }
- } else if (m_VSyncMode == 2) {
- if (VSyncOffsetMin > (Margin)) {
- m_VSyncMode = 0;
- }
- } else if (m_VSyncMode == 1) {
- if (VSyncOffsetMax < (VSyncTime - Margin)) {
- m_VSyncMode = 0;
- }
- }
- }
-
- }
- }
-
- m_pCurrentDisplaydSample = NULL;
- if (bStepForward) {
- MoveToFreeList(pMFSample, true);
- CheckWaitingSampleFromMixer();
- m_MaxSampleDuration = max(SampleDuration, m_MaxSampleDuration);
- } else {
- MoveToScheduledList(pMFSample, true);
- }
- } else if (m_bLastSampleOffsetValid && m_LastSampleOffset < -10000000) { // Only starve if we are 1 seconds behind
- if (m_nRenderState == Started && !g_bNoDuration) {
- m_pSink->Notify(EC_STARVATION, 0, 0);
- m_bSignaledStarvation = true;
- }
- }
- //GetImageFromMixer();
- }
- // else
- // {
- // TRACE_EVR ("EVR: RenderThread ==>> Flush before rendering frame!\n");
- // }
-
- break;
- }
- }
-
- timeEndPeriod (dwResolution);
- if (pfAvRevertMmThreadCharacteristics) {
- pfAvRevertMmThreadCharacteristics (hAvrt);
- }
+ HANDLE hEvts[] = { m_hEvtQuit, m_hEvtFlush};
+ bool bQuit = false;
+ TIMECAPS tc;
+ DWORD dwResolution;
+ MFTIME nsSampleTime;
+ LONGLONG llClockTime;
+ DWORD dwUser = 0;
+ DWORD dwObject;
+
+
+ // Tell Vista Multimedia Class Scheduler we are a playback thretad (increase priority)
+ HANDLE hAvrt = 0;
+ if (pfAvSetMmThreadCharacteristicsW) {
+ DWORD dwTaskIndex = 0;
+ hAvrt = pfAvSetMmThreadCharacteristicsW(L"Playback", &dwTaskIndex);
+ if (pfAvSetMmThreadPriority) {
+ pfAvSetMmThreadPriority(hAvrt, AVRT_PRIORITY_HIGH /*AVRT_PRIORITY_CRITICAL*/);
+ }
+ }
+
+ timeGetDevCaps(&tc, sizeof(TIMECAPS));
+ dwResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
+ dwUser = timeBeginPeriod(dwResolution);
+ CRenderersSettings& s = GetRenderersSettings();
+
+ int NextSleepTime = 1;
+ while (!bQuit) {
+ LONGLONG llPerf = GetRenderersData()->GetPerfCounter();
+ UNREFERENCED_PARAMETER(llPerf);
+ if (!s.m_RenderSettings.iVMR9VSyncAccurate && NextSleepTime == 0) {
+ NextSleepTime = 1;
+ }
+ dwObject = WaitForMultipleObjects(_countof(hEvts), hEvts, FALSE, max(NextSleepTime < 0 ? 1 : NextSleepTime, 0));
+ /* dwObject = WAIT_TIMEOUT;
+ if (m_bEvtFlush)
+ dwObject = WAIT_OBJECT_0 + 1;
+ else if (m_bEvtQuit)
+ dwObject = WAIT_OBJECT_0;*/
+ // if (NextSleepTime)
+ // TRACE_EVR("EVR: Sleep: %7.3f\n", double(GetRenderersData()->GetPerfCounter()-llPerf) / 10000.0);
+ if (NextSleepTime > 1) {
+ NextSleepTime = 0;
+ } else if (NextSleepTime == 0) {
+ NextSleepTime = -1;
+ }
+ switch (dwObject) {
+ case WAIT_OBJECT_0 :
+ bQuit = true;
+ break;
+ case WAIT_OBJECT_0 + 1 :
+ // Flush pending samples!
+ FlushSamples();
+ m_bEvtFlush = false;
+ ResetEvent(m_hEvtFlush);
+ TRACE_EVR("EVR: Flush done!\n");
+ break;
+
+ case WAIT_TIMEOUT :
+
+ if (m_LastSetOutputRange != -1 && m_LastSetOutputRange != s.m_RenderSettings.iEVROutputRange || m_bPendingRenegotiate) {
+ FlushSamples();
+ RenegotiateMediaType();
+ m_bPendingRenegotiate = false;
+ }
+ if (m_bPendingResetDevice) {
+ SendResetRequest();
+ }
+
+ // Discard timer events if playback stop
+ // if ((dwObject == WAIT_OBJECT_0 + 3) && (m_nRenderState != Started)) continue;
+
+ // TRACE_EVR ("EVR: RenderThread ==>> Waiting buffer\n");
+
+ // if (WaitForMultipleObjects (_countof(hEvtsBuff), hEvtsBuff, FALSE, INFINITE) == WAIT_OBJECT_0+2)
+ {
+ CComPtr<IMFSample> pMFSample;
+ LONGLONG llPerf = GetRenderersData()->GetPerfCounter();
+ UNREFERENCED_PARAMETER(llPerf);
+ int nSamplesLeft = 0;
+ if (SUCCEEDED(GetScheduledSample(&pMFSample, nSamplesLeft))) {
+ // pMFSample->GetUINT32 (GUID_SURFACE_INDEX, (UINT32*)&m_nCurSurface);
+ m_pCurrentDisplaydSample = pMFSample;
+
+ bool bValidSampleTime = true;
+ HRESULT hGetSampleTime = pMFSample->GetSampleTime(&nsSampleTime);
+ if (hGetSampleTime != S_OK || nsSampleTime == 0) {
+ bValidSampleTime = false;
+ }
+ // We assume that all samples have the same duration
+ LONGLONG SampleDuration = 0;
+ pMFSample->GetSampleDuration(&SampleDuration);
+
+ // TRACE_EVR ("EVR: RenderThread ==>> Presenting surface %d (%I64d)\n", m_nCurSurface, nsSampleTime);
+
+ bool bStepForward = false;
+
+ if (m_nStepCount < 0) {
+ // Drop frame
+ TRACE_EVR("EVR: Dropped frame\n");
+ m_pcFrames++;
+ bStepForward = true;
+ m_nStepCount = 0;
+ /*
+ } else if (m_nStepCount > 0) {
+ pMFSample->GetUINT32(GUID_SURFACE_INDEX, (UINT32 *)&m_nCurSurface);
+ ++m_OrderedPaint;
+ if (!g_bExternalSubtitleTime) {
+ __super::SetTime (g_tSegmentStart + nsSampleTime);
+ }
+ Paint(true);
+ m_nDroppedUpdate = 0;
+ CompleteFrameStep (false);
+ bStepForward = true;
+ */
+ } else if ((m_nRenderState == Started)) {
+ LONGLONG CurrentCounter = GetRenderersData()->GetPerfCounter();
+ // Calculate wake up timer
+ if (!m_bSignaledStarvation) {
+ llClockTime = GetClockTime(CurrentCounter);
+ m_StarvationClock = llClockTime;
+ } else {
+ llClockTime = m_StarvationClock;
+ }
+
+ if (!bValidSampleTime) {
+ // Just play as fast as possible
+ bStepForward = true;
+ pMFSample->GetUINT32(GUID_SURFACE_INDEX, (UINT32*)&m_nCurSurface);
+ ++m_OrderedPaint;
+ if (!g_bExternalSubtitleTime) {
+ __super::SetTime(g_tSegmentStart + nsSampleTime);
+ }
+ Paint(true);
+ } else {
+ LONGLONG TimePerFrame = (LONGLONG)(GetFrameTime() * 10000000.0);
+ LONGLONG DrawTime = m_PaintTime * 9 / 10 - 20000; // 2 ms offset (= m_PaintTime * 0.9 - 20000)
+ //if (!s.iVMR9VSync)
+ DrawTime = 0;
+
+ LONGLONG SyncOffset = 0;
+ LONGLONG VSyncTime = 0;
+ LONGLONG TimeToNextVSync = -1;
+ bool bVSyncCorrection = false;
+ double DetectedRefreshTime;
+ double DetectedScanlinesPerFrame;
+ double DetectedScanlineTime;
+ int DetectedRefreshRatePos;
+ {
+ CAutoLock Lock(&m_RefreshRateLock);
+ DetectedRefreshTime = m_DetectedRefreshTime;
+ DetectedRefreshRatePos = m_DetectedRefreshRatePos;
+ DetectedScanlinesPerFrame = m_DetectedScanlinesPerFrame;
+ DetectedScanlineTime = m_DetectedScanlineTime;
+ }
+
+ if (DetectedRefreshRatePos < 20 || !DetectedRefreshTime || !DetectedScanlinesPerFrame) {
+ DetectedRefreshTime = 1.0 / m_RefreshRate;
+ DetectedScanlinesPerFrame = m_ScreenSize.cy;
+ DetectedScanlineTime = DetectedRefreshTime / double(m_ScreenSize.cy);
+ }
+
+ if (s.m_RenderSettings.iVMR9VSync) {
+ bVSyncCorrection = true;
+ double TargetVSyncPos = GetVBlackPos();
+ double RefreshLines = DetectedScanlinesPerFrame;
+ double ScanlinesPerSecond = 1.0 / DetectedScanlineTime;
+ double CurrentVSyncPos = fmod(double(m_VBlankStartMeasure) + ScanlinesPerSecond * ((CurrentCounter - m_VBlankStartMeasureTime) / 10000000.0), RefreshLines);
+ double LinesUntilVSync = 0;
+ //TargetVSyncPos -= ScanlinesPerSecond * (DrawTime/10000000.0);
+ //TargetVSyncPos -= 10;
+ TargetVSyncPos = fmod(TargetVSyncPos, RefreshLines);
+ if (TargetVSyncPos < 0) {
+ TargetVSyncPos += RefreshLines;
+ }
+ if (TargetVSyncPos > CurrentVSyncPos) {
+ LinesUntilVSync = TargetVSyncPos - CurrentVSyncPos;
+ } else {
+ LinesUntilVSync = (RefreshLines - CurrentVSyncPos) + TargetVSyncPos;
+ }
+ double TimeUntilVSync = LinesUntilVSync * DetectedScanlineTime;
+ TimeToNextVSync = (LONGLONG)(TimeUntilVSync * 10000000.0);
+ VSyncTime = (LONGLONG)(DetectedRefreshTime * 10000000.0);
+
+ LONGLONG ClockTimeAtNextVSync = llClockTime + (LONGLONG)(TimeUntilVSync * 10000000.0 * m_ModeratedTimeSpeed);
+
+ SyncOffset = (nsSampleTime - ClockTimeAtNextVSync);
+
+ // if (SyncOffset < 0)
+ // TRACE_EVR("EVR: SyncOffset(%d): %I64d %I64d %I64d\n", m_nCurSurface, SyncOffset, TimePerFrame, VSyncTime);
+ } else {
+ SyncOffset = (nsSampleTime - llClockTime);
+ }
+
+ //LONGLONG SyncOffset = nsSampleTime - llClockTime;
+ TRACE_EVR("EVR: SyncOffset: %I64d SampleFrame: %I64d ClockFrame: %I64d\n", SyncOffset, TimePerFrame != 0 ? nsSampleTime / TimePerFrame : 0, TimePerFrame != 0 ? llClockTime / TimePerFrame : 0);
+ if (SampleDuration > 1 && !m_DetectedLock) {
+ TimePerFrame = SampleDuration;
+ }
+
+ LONGLONG MinMargin;
+ if (m_FrameTimeCorrection && 0) {
+ MinMargin = 15000;
+ } else {
+ MinMargin = 15000 + min(LONGLONG(m_DetectedFrameTimeStdDev), 20000);
+ }
+ LONGLONG TimePerFrameMargin = min(max(TimePerFrame * 2 / 100, MinMargin), TimePerFrame * 11 / 100); // (0.02..0.11)TimePerFrame
+ LONGLONG TimePerFrameMargin0 = TimePerFrameMargin / 2;
+ LONGLONG TimePerFrameMargin1 = 0;
+
+ if (m_DetectedLock && TimePerFrame < VSyncTime) {
+ VSyncTime = TimePerFrame;
+ }
+
+ if (m_VSyncMode == 1) {
+ TimePerFrameMargin1 = -TimePerFrameMargin;
+ } else if (m_VSyncMode == 2) {
+ TimePerFrameMargin1 = TimePerFrameMargin;
+ }
+
+ m_LastSampleOffset = SyncOffset;
+ m_bLastSampleOffsetValid = true;
+
+ LONGLONG VSyncOffset0 = 0;
+ bool bDoVSyncCorrection = false;
+ if ((SyncOffset < -(TimePerFrame + TimePerFrameMargin0 - TimePerFrameMargin1)) && nSamplesLeft > 0) { // Only drop if we have something else to display at once
+ // Drop frame
+ TRACE_EVR("EVR: Dropped frame\n");
+ m_pcFrames++;
+ bStepForward = true;
+ ++m_nDroppedUpdate;
+ NextSleepTime = 0;
+ // VSyncOffset0 = (-SyncOffset) - VSyncTime;
+ //VSyncOffset0 = (-SyncOffset) - VSyncTime + TimePerFrameMargin1;
+ //m_LastPredictedSync = VSyncOffset0;
+ bDoVSyncCorrection = false;
+ } else if (SyncOffset < TimePerFrameMargin1) {
+
+ if (bVSyncCorrection) {
+ VSyncOffset0 = -SyncOffset;
+ bDoVSyncCorrection = true;
+ }
+
+ // Paint and prepare for next frame
+ TRACE_EVR("EVR: Normalframe\n");
+ m_nDroppedUpdate = 0;
+ bStepForward = true;
+ pMFSample->GetUINT32(GUID_SURFACE_INDEX, (UINT32*)&m_nCurSurface);
+ m_LastFrameDuration = nsSampleTime - m_LastSampleTime;
+ m_LastSampleTime = nsSampleTime;
+ m_LastPredictedSync = VSyncOffset0;
+
+ if (m_nStepCount > 0) {
+ CompleteFrameStep(false);
+ }
+
+ ++m_OrderedPaint;
+
+ if (!g_bExternalSubtitleTime) {
+ __super::SetTime(g_tSegmentStart + nsSampleTime);
+ }
+ Paint(true);
+
+ NextSleepTime = 0;
+ m_pcFramesDrawn++;
+ } else {
+ if (TimeToNextVSync >= 0 && SyncOffset > 0) {
+ NextSleepTime = (int)(TimeToNextVSync / 10000 - 2);
+ } else {
+ NextSleepTime = (int)(SyncOffset / 10000 - 2);
+ }
+
+ if (NextSleepTime > TimePerFrame) {
+ NextSleepTime = 1;
+ }
+
+ if (NextSleepTime < 0) {
+ NextSleepTime = 0;
+ }
+ NextSleepTime = 1;
+ //TRACE_EVR ("EVR: Delay\n");
+ }
+
+ if (bDoVSyncCorrection) {
+ //LONGLONG VSyncOffset0 = (((SyncOffset) % VSyncTime) + VSyncTime) % VSyncTime;
+ LONGLONG Margin = TimePerFrameMargin;
+
+ LONGLONG VSyncOffsetMin = 30000000000000;
+ LONGLONG VSyncOffsetMax = -30000000000000;
+ for (int i = 0; i < 5; ++i) {
+ VSyncOffsetMin = min(m_VSyncOffsetHistory[i], VSyncOffsetMin);
+ VSyncOffsetMax = max(m_VSyncOffsetHistory[i], VSyncOffsetMax);
+ }
+
+ m_VSyncOffsetHistory[m_VSyncOffsetHistoryPos] = VSyncOffset0;
+ m_VSyncOffsetHistoryPos = (m_VSyncOffsetHistoryPos + 1) % 5;
+
+ // LONGLONG VSyncTime2 = VSyncTime2 + (VSyncOffsetMax - VSyncOffsetMin);
+ //VSyncOffsetMin; = (((VSyncOffsetMin) % VSyncTime) + VSyncTime) % VSyncTime;
+ //VSyncOffsetMax = (((VSyncOffsetMax) % VSyncTime) + VSyncTime) % VSyncTime;
+
+ // TRACE_EVR("EVR: SyncOffset(%d, %d): %8I64d %8I64d %8I64d %8I64d\n", m_nCurSurface, m_VSyncMode,VSyncOffset0, VSyncOffsetMin, VSyncOffsetMax, VSyncOffsetMax - VSyncOffsetMin);
+
+ if (m_VSyncMode == 0) {
+ // 23.976 in 60 Hz
+ if (VSyncOffset0 < Margin && VSyncOffsetMax > (VSyncTime - Margin)) {
+ m_VSyncMode = 2;
+ } else if (VSyncOffset0 > (VSyncTime - Margin) && VSyncOffsetMin < Margin) {
+ m_VSyncMode = 1;
+ }
+ } else if (m_VSyncMode == 2) {
+ if (VSyncOffsetMin > (Margin)) {
+ m_VSyncMode = 0;
+ }
+ } else if (m_VSyncMode == 1) {
+ if (VSyncOffsetMax < (VSyncTime - Margin)) {
+ m_VSyncMode = 0;
+ }
+ }
+ }
+
+ }
+ }
+
+ m_pCurrentDisplaydSample = NULL;
+ if (bStepForward) {
+ MoveToFreeList(pMFSample, true);
+ CheckWaitingSampleFromMixer();
+ m_MaxSampleDuration = max(SampleDuration, m_MaxSampleDuration);
+ } else {
+ MoveToScheduledList(pMFSample, true);
+ }
+ } else if (m_bLastSampleOffsetValid && m_LastSampleOffset < -10000000) { // Only starve if we are 1 seconds behind
+ if (m_nRenderState == Started && !g_bNoDuration) {
+ m_pSink->Notify(EC_STARVATION, 0, 0);
+ m_bSignaledStarvation = true;
+ }
+ }
+ //GetImageFromMixer();
+ }
+ // else
+ // {
+ // TRACE_EVR ("EVR: RenderThread ==>> Flush before rendering frame!\n");
+ // }
+
+ break;
+ }
+ }
+
+ timeEndPeriod(dwResolution);
+ if (pfAvRevertMmThreadCharacteristics) {
+ pfAvRevertMmThreadCharacteristics(hAvrt);
+ }
}
void CEVRAllocatorPresenter::OnResetDevice()
{
- HRESULT hr;
+ HRESULT hr;
- // Reset DXVA Manager, and get new buffers
- hr = m_pD3DManager->ResetDevice(m_pD3DDev, m_nResetToken);
+ // Reset DXVA Manager, and get new buffers
+ hr = m_pD3DManager->ResetDevice(m_pD3DDev, m_nResetToken);
- // Not necessary, but Microsoft documentation say Presenter should send this message...
- if (m_pSink) {
- m_pSink->Notify (EC_DISPLAY_CHANGED, 0, 0);
- }
+ // Not necessary, but Microsoft documentation say Presenter should send this message...
+ if (m_pSink) {
+ m_pSink->Notify(EC_DISPLAY_CHANGED, 0, 0);
+ }
}
void CEVRAllocatorPresenter::RemoveAllSamples()
{
- CAutoLock AutoLock(&m_ImageProcessingLock);
+ CAutoLock AutoLock(&m_ImageProcessingLock);
- FlushSamples();
- m_ScheduledSamples.RemoveAll();
- m_FreeSamples.RemoveAll();
- m_LastScheduledSampleTime = -1;
- m_LastScheduledUncorrectedSampleTime = -1;
- m_nUsedBuffer = 0;
+ FlushSamples();
+ m_ScheduledSamples.RemoveAll();
+ m_FreeSamples.RemoveAll();
+ m_LastScheduledSampleTime = -1;
+ m_LastScheduledUncorrectedSampleTime = -1;
+ m_nUsedBuffer = 0;
}
HRESULT CEVRAllocatorPresenter::GetFreeSample(IMFSample** ppSample)
{
- CAutoLock lock(&m_SampleQueueLock);
- HRESULT hr = S_OK;
+ CAutoLock lock(&m_SampleQueueLock);
+ HRESULT hr = S_OK;
- if (m_FreeSamples.GetCount() > 1) { // <= Cannot use first free buffer (can be currently displayed)
- InterlockedIncrement (&m_nUsedBuffer);
- *ppSample = m_FreeSamples.RemoveHead().Detach();
- } else {
- hr = MF_E_SAMPLEALLOCATOR_EMPTY;
- }
+ if (m_FreeSamples.GetCount() > 1) { // <= Cannot use first free buffer (can be currently displayed)
+ InterlockedIncrement(&m_nUsedBuffer);
+ *ppSample = m_FreeSamples.RemoveHead().Detach();
+ } else {
+ hr = MF_E_SAMPLEALLOCATOR_EMPTY;
+ }
- return hr;
+ return hr;
}
-HRESULT CEVRAllocatorPresenter::GetScheduledSample(IMFSample** ppSample, int &_Count)
+HRESULT CEVRAllocatorPresenter::GetScheduledSample(IMFSample** ppSample, int& _Count)
{
- CAutoLock lock(&m_SampleQueueLock);
- HRESULT hr = S_OK;
+ CAutoLock lock(&m_SampleQueueLock);
+ HRESULT hr = S_OK;
- _Count = (int)m_ScheduledSamples.GetCount();
- if (_Count > 0) {
- *ppSample = m_ScheduledSamples.RemoveHead().Detach();
- --_Count;
- } else {
- hr = MF_E_SAMPLEALLOCATOR_EMPTY;
- }
+ _Count = (int)m_ScheduledSamples.GetCount();
+ if (_Count > 0) {
+ *ppSample = m_ScheduledSamples.RemoveHead().Detach();
+ --_Count;
+ } else {
+ hr = MF_E_SAMPLEALLOCATOR_EMPTY;
+ }
- return hr;
+ return hr;
}
void CEVRAllocatorPresenter::MoveToFreeList(IMFSample* pSample, bool bTail)
{
- CAutoLock lock(&m_SampleQueueLock);
- InterlockedDecrement (&m_nUsedBuffer);
- if (m_bPendingMediaFinished && m_nUsedBuffer == 0) {
- m_bPendingMediaFinished = false;
- m_pSink->Notify (EC_COMPLETE, 0, 0);
- }
- if (bTail) {
- m_FreeSamples.AddTail (pSample);
- } else {
- m_FreeSamples.AddHead(pSample);
- }
+ CAutoLock lock(&m_SampleQueueLock);
+ InterlockedDecrement(&m_nUsedBuffer);
+ if (m_bPendingMediaFinished && m_nUsedBuffer == 0) {
+ m_bPendingMediaFinished = false;
+ m_pSink->Notify(EC_COMPLETE, 0, 0);
+ }
+ if (bTail) {
+ m_FreeSamples.AddTail(pSample);
+ } else {
+ m_FreeSamples.AddHead(pSample);
+ }
}
void CEVRAllocatorPresenter::MoveToScheduledList(IMFSample* pSample, bool _bSorted)
{
- if (_bSorted) {
- CAutoLock lock(&m_SampleQueueLock);
- // Insert sorted
- /* POSITION Iterator = m_ScheduledSamples.GetHeadPosition();
-
- LONGLONG NewSampleTime;
- pSample->GetSampleTime(&NewSampleTime);
-
- while (Iterator != NULL)
- {
- POSITION CurrentPos = Iterator;
- IMFSample *pIter = m_ScheduledSamples.GetNext(Iterator);
- LONGLONG SampleTime;
- pIter->GetSampleTime(&SampleTime);
- if (NewSampleTime < SampleTime)
- {
- m_ScheduledSamples.InsertBefore(CurrentPos, pSample);
- return;
- }
- }*/
-
- m_ScheduledSamples.AddHead(pSample);
- } else {
-
- CAutoLock lock(&m_SampleQueueLock);
-
- CRenderersSettings& s = GetRenderersSettings();
- double ForceFPS = 0.0;
- // double ForceFPS = 59.94;
- // double ForceFPS = 23.976;
- if (ForceFPS != 0.0) {
- m_rtTimePerFrame = (REFERENCE_TIME)(10000000.0 / ForceFPS);
- }
- LONGLONG Duration = m_rtTimePerFrame;
- UNREFERENCED_PARAMETER(Duration);
- LONGLONG PrevTime = m_LastScheduledUncorrectedSampleTime;
- LONGLONG Time;
- LONGLONG SetDuration;
- pSample->GetSampleDuration(&SetDuration);
- pSample->GetSampleTime(&Time);
- m_LastScheduledUncorrectedSampleTime = Time;
-
- m_bCorrectedFrameTime = false;
-
- LONGLONG Diff2 = PrevTime - (LONGLONG)(m_LastScheduledSampleTimeFP * 10000000.0);
- LONGLONG Diff = Time - PrevTime;
- if (PrevTime == -1) {
- Diff = 0;
- }
- if (Diff < 0) {
- Diff = -Diff;
- }
- if (Diff2 < 0) {
- Diff2 = -Diff2;
- }
- if (Diff < m_rtTimePerFrame*8 && m_rtTimePerFrame && Diff2 < m_rtTimePerFrame*8) { // Detect seeking
- int iPos = (m_DetectedFrameTimePos++) % 60;
- LONGLONG Diff = Time - PrevTime;
- if (PrevTime == -1) {
- Diff = 0;
- }
- m_DetectedFrameTimeHistory[iPos] = Diff;
-
- if (m_DetectedFrameTimePos >= 10) {
- int nFrames = min(m_DetectedFrameTimePos, 60);
- LONGLONG DectedSum = 0;
- for (int i = 0; i < nFrames; ++i) {
- DectedSum += m_DetectedFrameTimeHistory[i];
- }
-
- double Average = double(DectedSum) / double(nFrames);
- double DeviationSum = 0.0;
- for (int i = 0; i < nFrames; ++i) {
- double Deviation = m_DetectedFrameTimeHistory[i] - Average;
- DeviationSum += Deviation*Deviation;
- }
-
- double StdDev = sqrt(DeviationSum/double(nFrames));
-
- m_DetectedFrameTimeStdDev = StdDev;
-
- double DetectedRate = 1.0/ (double(DectedSum) / (nFrames * 10000000.0) );
-
- double AllowedError = 0.0003;
-
- static double AllowedValues[] = {60.0, 59.94, 50.0, 48.0, 47.952, 30.0, 29.97, 25.0, 24.0, 23.976};
-
- int nAllowed = _countof(AllowedValues);
- for (int i = 0; i < nAllowed; ++i) {
- if (fabs(1.0 - DetectedRate / AllowedValues[i]) < AllowedError) {
- DetectedRate = AllowedValues[i];
- break;
- }
- }
-
- m_DetectedFrameTimeHistoryHistory[m_DetectedFrameTimePos % 500] = DetectedRate;
-
- class CAutoInt
- {
- public:
-
- int m_Int;
-
- CAutoInt() {
- m_Int = 0;
- }
- CAutoInt(int _Other) {
- m_Int = _Other;
- }
-
- operator int () const {
- return m_Int;
- }
-
- CAutoInt &operator ++ () {
- ++m_Int;
- return *this;
- }
- };
-
-
- CMap<double, double, CAutoInt, CAutoInt> Map;
-
- for (int i = 0; i < 500; ++i) {
- ++Map[m_DetectedFrameTimeHistoryHistory[i]];
- }
-
- POSITION Pos = Map.GetStartPosition();
- double BestVal = 0.0;
- int BestNum = 5;
- while (Pos) {
- double Key;
- CAutoInt Value;
- Map.GetNextAssoc(Pos, Key, Value);
- if (Value.m_Int > BestNum && Key != 0.0) {
- BestNum = Value.m_Int;
- BestVal = Key;
- }
- }
-
- m_DetectedLock = false;
- for (int i = 0; i < nAllowed; ++i) {
- if (BestVal == AllowedValues[i]) {
- m_DetectedLock = true;
- break;
- }
- }
- if (BestVal != 0.0) {
- m_DetectedFrameRate = BestVal;
- m_DetectedFrameTime = 1.0 / BestVal;
- }
- }
-
- LONGLONG PredictedNext = PrevTime + m_rtTimePerFrame;
- LONGLONG PredictedDiff = PredictedNext - Time;
- if (PredictedDiff < 0) {
- PredictedDiff = -PredictedDiff;
- }
-
- if (m_DetectedFrameTime != 0.0
- //&& PredictedDiff > 15000
- && m_DetectedLock && s.m_RenderSettings.iEVREnableFrameTimeCorrection) {
- double CurrentTime = Time / 10000000.0;
- double LastTime = m_LastScheduledSampleTimeFP;
- double PredictedTime = LastTime + m_DetectedFrameTime;
- if (fabs(PredictedTime - CurrentTime) > 0.0015) { // 1.5 ms wrong, lets correct
- CurrentTime = PredictedTime;
- Time = (LONGLONG)(CurrentTime * 10000000.0);
- pSample->SetSampleTime(Time);
- pSample->SetSampleDuration(LONGLONG(m_DetectedFrameTime * 10000000.0));
- m_bCorrectedFrameTime = true;
- m_FrameTimeCorrection = 30;
- }
- m_LastScheduledSampleTimeFP = CurrentTime;
- } else {
- m_LastScheduledSampleTimeFP = Time / 10000000.0;
- }
- } else {
- m_LastScheduledSampleTimeFP = Time / 10000000.0;
- if (Diff > m_rtTimePerFrame*8) {
- // Seek
- m_bSignaledStarvation = false;
- m_DetectedFrameTimePos = 0;
- m_DetectedLock = false;
- }
- }
-
- // TRACE_EVR("EVR: Time: %f %f %f\n", Time / 10000000.0, SetDuration / 10000000.0, m_DetectedFrameRate);
- if (!m_bCorrectedFrameTime && m_FrameTimeCorrection) {
- --m_FrameTimeCorrection;
- }
+ if (_bSorted) {
+ CAutoLock lock(&m_SampleQueueLock);
+ // Insert sorted
+ /* POSITION Iterator = m_ScheduledSamples.GetHeadPosition();
+
+ LONGLONG NewSampleTime;
+ pSample->GetSampleTime(&NewSampleTime);
+
+ while (Iterator != NULL)
+ {
+ POSITION CurrentPos = Iterator;
+ IMFSample *pIter = m_ScheduledSamples.GetNext(Iterator);
+ LONGLONG SampleTime;
+ pIter->GetSampleTime(&SampleTime);
+ if (NewSampleTime < SampleTime)
+ {
+ m_ScheduledSamples.InsertBefore(CurrentPos, pSample);
+ return;
+ }
+ }*/
+
+ m_ScheduledSamples.AddHead(pSample);
+ } else {
+
+ CAutoLock lock(&m_SampleQueueLock);
+
+ CRenderersSettings& s = GetRenderersSettings();
+ double ForceFPS = 0.0;
+ // double ForceFPS = 59.94;
+ // double ForceFPS = 23.976;
+ if (ForceFPS != 0.0) {
+ m_rtTimePerFrame = (REFERENCE_TIME)(10000000.0 / ForceFPS);
+ }
+ LONGLONG Duration = m_rtTimePerFrame;
+ UNREFERENCED_PARAMETER(Duration);
+ LONGLONG PrevTime = m_LastScheduledUncorrectedSampleTime;
+ LONGLONG Time;
+ LONGLONG SetDuration;
+ pSample->GetSampleDuration(&SetDuration);
+ pSample->GetSampleTime(&Time);
+ m_LastScheduledUncorrectedSampleTime = Time;
+
+ m_bCorrectedFrameTime = false;
+
+ LONGLONG Diff2 = PrevTime - (LONGLONG)(m_LastScheduledSampleTimeFP * 10000000.0);
+ LONGLONG Diff = Time - PrevTime;
+ if (PrevTime == -1) {
+ Diff = 0;
+ }
+ if (Diff < 0) {
+ Diff = -Diff;
+ }
+ if (Diff2 < 0) {
+ Diff2 = -Diff2;
+ }
+ if (Diff < m_rtTimePerFrame * 8 && m_rtTimePerFrame && Diff2 < m_rtTimePerFrame * 8) { // Detect seeking
+ int iPos = (m_DetectedFrameTimePos++) % 60;
+ LONGLONG Diff = Time - PrevTime;
+ if (PrevTime == -1) {
+ Diff = 0;
+ }
+ m_DetectedFrameTimeHistory[iPos] = Diff;
+
+ if (m_DetectedFrameTimePos >= 10) {
+ int nFrames = min(m_DetectedFrameTimePos, 60);
+ LONGLONG DectedSum = 0;
+ for (int i = 0; i < nFrames; ++i) {
+ DectedSum += m_DetectedFrameTimeHistory[i];
+ }
+
+ double Average = double(DectedSum) / double(nFrames);
+ double DeviationSum = 0.0;
+ for (int i = 0; i < nFrames; ++i) {
+ double Deviation = m_DetectedFrameTimeHistory[i] - Average;
+ DeviationSum += Deviation * Deviation;
+ }
+
+ double StdDev = sqrt(DeviationSum / double(nFrames));
+
+ m_DetectedFrameTimeStdDev = StdDev;
+
+ double DetectedRate = 1.0 / (double(DectedSum) / (nFrames * 10000000.0));
+
+ double AllowedError = 0.0003;
+
+ static double AllowedValues[] = {60.0, 59.94, 50.0, 48.0, 47.952, 30.0, 29.97, 25.0, 24.0, 23.976};
+
+ int nAllowed = _countof(AllowedValues);
+ for (int i = 0; i < nAllowed; ++i) {
+ if (fabs(1.0 - DetectedRate / AllowedValues[i]) < AllowedError) {
+ DetectedRate = AllowedValues[i];
+ break;
+ }
+ }
+
+ m_DetectedFrameTimeHistoryHistory[m_DetectedFrameTimePos % 500] = DetectedRate;
+
+ class CAutoInt
+ {
+ public:
+
+ int m_Int;
+
+ CAutoInt() {
+ m_Int = 0;
+ }
+ CAutoInt(int _Other) {
+ m_Int = _Other;
+ }
+
+ operator int () const {
+ return m_Int;
+ }
+
+ CAutoInt& operator ++ () {
+ ++m_Int;
+ return *this;
+ }
+ };
+
+
+ CMap<double, double, CAutoInt, CAutoInt> Map;
+
+ for (int i = 0; i < 500; ++i) {
+ ++Map[m_DetectedFrameTimeHistoryHistory[i]];
+ }
+
+ POSITION Pos = Map.GetStartPosition();
+ double BestVal = 0.0;
+ int BestNum = 5;
+ while (Pos) {
+ double Key;
+ CAutoInt Value;
+ Map.GetNextAssoc(Pos, Key, Value);
+ if (Value.m_Int > BestNum && Key != 0.0) {
+ BestNum = Value.m_Int;
+ BestVal = Key;
+ }
+ }
+
+ m_DetectedLock = false;
+ for (int i = 0; i < nAllowed; ++i) {
+ if (BestVal == AllowedValues[i]) {
+ m_DetectedLock = true;
+ break;
+ }
+ }
+ if (BestVal != 0.0) {
+ m_DetectedFrameRate = BestVal;
+ m_DetectedFrameTime = 1.0 / BestVal;
+ }
+ }
+
+ LONGLONG PredictedNext = PrevTime + m_rtTimePerFrame;
+ LONGLONG PredictedDiff = PredictedNext - Time;
+ if (PredictedDiff < 0) {
+ PredictedDiff = -PredictedDiff;
+ }
+
+ if (m_DetectedFrameTime != 0.0
+ //&& PredictedDiff > 15000
+ && m_DetectedLock && s.m_RenderSettings.iEVREnableFrameTimeCorrection) {
+ double CurrentTime = Time / 10000000.0;
+ double LastTime = m_LastScheduledSampleTimeFP;
+ double PredictedTime = LastTime + m_DetectedFrameTime;
+ if (fabs(PredictedTime - CurrentTime) > 0.0015) { // 1.5 ms wrong, lets correct
+ CurrentTime = PredictedTime;
+ Time = (LONGLONG)(CurrentTime * 10000000.0);
+ pSample->SetSampleTime(Time);
+ pSample->SetSampleDuration(LONGLONG(m_DetectedFrameTime * 10000000.0));
+ m_bCorrectedFrameTime = true;
+ m_FrameTimeCorrection = 30;
+ }
+ m_LastScheduledSampleTimeFP = CurrentTime;
+ } else {
+ m_LastScheduledSampleTimeFP = Time / 10000000.0;
+ }
+ } else {
+ m_LastScheduledSampleTimeFP = Time / 10000000.0;
+ if (Diff > m_rtTimePerFrame * 8) {
+ // Seek
+ m_bSignaledStarvation = false;
+ m_DetectedFrameTimePos = 0;
+ m_DetectedLock = false;
+ }
+ }
+
+ // TRACE_EVR("EVR: Time: %f %f %f\n", Time / 10000000.0, SetDuration / 10000000.0, m_DetectedFrameRate);
+ if (!m_bCorrectedFrameTime && m_FrameTimeCorrection) {
+ --m_FrameTimeCorrection;
+ }
#if 0
- if (Time <= m_LastScheduledUncorrectedSampleTime && m_LastScheduledSampleTime >= 0) {
- PrevTime = m_LastScheduledSampleTime;
- }
-
- m_bCorrectedFrameTime = false;
- if (PrevTime != -1 && (Time >= PrevTime - ((Duration*20)/9) || Time == 0) || ForceFPS != 0.0) {
- if (Time - PrevTime > ((Duration*20)/9) && Time - PrevTime < Duration * 8 || Time == 0 || ((Time - PrevTime) < (Duration / 11)) || ForceFPS != 0.0) {
- // Error!!!!
- Time = PrevTime + Duration;
- pSample->SetSampleTime(Time);
- pSample->SetSampleDuration(Duration);
- m_bCorrectedFrameTime = true;
- TRACE_EVR("EVR: Corrected invalid sample time\n");
- }
- }
- if (Time+Duration*10 < m_LastScheduledSampleTime) {
- // Flush when repeating movie
- FlushSamplesInternal();
- }
+ if (Time <= m_LastScheduledUncorrectedSampleTime && m_LastScheduledSampleTime >= 0) {
+ PrevTime = m_LastScheduledSampleTime;
+ }
+
+ m_bCorrectedFrameTime = false;
+ if (PrevTime != -1 && (Time >= PrevTime - ((Duration * 20) / 9) || Time == 0) || ForceFPS != 0.0) {
+ if (Time - PrevTime > ((Duration * 20) / 9) && Time - PrevTime < Duration * 8 || Time == 0 || ((Time - PrevTime) < (Duration / 11)) || ForceFPS != 0.0) {
+ // Error!!!!
+ Time = PrevTime + Duration;
+ pSample->SetSampleTime(Time);
+ pSample->SetSampleDuration(Duration);
+ m_bCorrectedFrameTime = true;
+ TRACE_EVR("EVR: Corrected invalid sample time\n");
+ }
+ }
+ if (Time + Duration * 10 < m_LastScheduledSampleTime) {
+ // Flush when repeating movie
+ FlushSamplesInternal();
+ }
#endif
#if 0
- static LONGLONG LastDuration = 0;
- LONGLONG SetDuration = m_rtTimePerFrame;
- pSample->GetSampleDuration(&SetDuration);
- if (SetDuration != LastDuration) {
- TRACE_EVR("EVR: Old duration: %I64d New duration: %I64d\n", LastDuration, SetDuration);
- }
- LastDuration = SetDuration;
+ static LONGLONG LastDuration = 0;
+ LONGLONG SetDuration = m_rtTimePerFrame;
+ pSample->GetSampleDuration(&SetDuration);
+ if (SetDuration != LastDuration) {
+ TRACE_EVR("EVR: Old duration: %I64d New duration: %I64d\n", LastDuration, SetDuration);
+ }
+ LastDuration = SetDuration;
#endif
- m_LastScheduledSampleTime = Time;
+ m_LastScheduledSampleTime = Time;
- m_ScheduledSamples.AddTail(pSample);
+ m_ScheduledSamples.AddTail(pSample);
- }
+ }
}
void CEVRAllocatorPresenter::FlushSamples()
{
- CAutoLock lock(this);
- CAutoLock lock2(&m_SampleQueueLock);
+ CAutoLock lock(this);
+ CAutoLock lock2(&m_SampleQueueLock);
- FlushSamplesInternal();
- m_LastScheduledSampleTime = -1;
+ FlushSamplesInternal();
+ m_LastScheduledSampleTime = -1;
}
void CEVRAllocatorPresenter::FlushSamplesInternal()
{
- while (m_ScheduledSamples.GetCount() > 0) {
- CComPtr<IMFSample> pMFSample;
+ while (m_ScheduledSamples.GetCount() > 0) {
+ CComPtr<IMFSample> pMFSample;
- pMFSample = m_ScheduledSamples.RemoveHead();
- MoveToFreeList (pMFSample, true);
- }
+ pMFSample = m_ScheduledSamples.RemoveHead();
+ MoveToFreeList(pMFSample, true);
+ }
- m_LastSampleOffset = 0;
- m_bLastSampleOffsetValid = false;
- m_bSignaledStarvation = false;
+ m_LastSampleOffset = 0;
+ m_bLastSampleOffsetValid = false;
+ m_bSignaledStarvation = false;
}
diff --git a/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.h b/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.h
index c5bdd72bd..7a0121cb4 100644
--- a/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.h
+++ b/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.h
@@ -23,260 +23,260 @@
#pragma once
#include "DX9AllocatorPresenter.h"
-#include <mfapi.h> // API Media Foundation
+#include <mfapi.h> // API Media Foundation
#include <evr9.h>
namespace DSObjects
{
- // dxva.dll
- typedef HRESULT (__stdcall *PTR_DXVA2CreateDirect3DDeviceManager9)(UINT* pResetToken, IDirect3DDeviceManager9** ppDeviceManager);
-
- // mf.dll
- typedef HRESULT (__stdcall *PTR_MFCreatePresentationClock)(IMFPresentationClock** ppPresentationClock);
-
- // evr.dll
- typedef HRESULT (__stdcall *PTR_MFCreateDXSurfaceBuffer)(REFIID riid, IUnknown* punkSurface, BOOL fBottomUpWhenLinear, IMFMediaBuffer** ppBuffer);
- typedef HRESULT (__stdcall *PTR_MFCreateVideoSampleFromSurface)(IUnknown* pUnkSurface, IMFSample** ppSample);
- typedef HRESULT (__stdcall *PTR_MFCreateVideoMediaType)(const MFVIDEOFORMAT* pVideoFormat, IMFVideoMediaType** ppIVideoMediaType);
-
- // AVRT.dll
- typedef HANDLE (__stdcall *PTR_AvSetMmThreadCharacteristicsW)(LPCWSTR TaskName, LPDWORD TaskIndex);
- typedef BOOL (__stdcall *PTR_AvSetMmThreadPriority)(HANDLE AvrtHandle, AVRT_PRIORITY Priority);
- typedef BOOL (__stdcall *PTR_AvRevertMmThreadCharacteristics)(HANDLE AvrtHandle);
-
- class COuterEVR;
-
- class CEVRAllocatorPresenter :
- public CDX9AllocatorPresenter,
- public IMFGetService,
- public IMFTopologyServiceLookupClient,
- public IMFVideoDeviceID,
- public IMFVideoPresenter,
- public IDirect3DDeviceManager9,
-
- public IMFAsyncCallback,
- public IQualProp,
- public IMFRateSupport,
- public IMFVideoDisplayControl,
- public IEVRTrustedVideoPlugin
- /* public IMFVideoPositionMapper, // Non mandatory EVR Presenter Interfaces (see later...)
- */
- {
- public:
- CEVRAllocatorPresenter(HWND hWnd, bool bFullscreen, HRESULT& hr, CString &_Error);
- ~CEVRAllocatorPresenter(void);
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
- STDMETHODIMP_(bool) Paint(bool fAll);
- STDMETHODIMP GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight);
- STDMETHODIMP InitializeDevice(IMFMediaType* pMediaType);
- STDMETHODIMP_(bool) ResetDevice();
- STDMETHODIMP_(bool) DisplayChange();
-
- // IMFClockStateSink
- STDMETHODIMP OnClockStart(/* [in] */ MFTIME hnsSystemTime, /* [in] */ LONGLONG llClockStartOffset);
- STDMETHODIMP OnClockStop(/* [in] */ MFTIME hnsSystemTime);
- STDMETHODIMP OnClockPause(/* [in] */ MFTIME hnsSystemTime);
- STDMETHODIMP OnClockRestart(/* [in] */ MFTIME hnsSystemTime);
- STDMETHODIMP OnClockSetRate(/* [in] */ MFTIME hnsSystemTime, /* [in] */ float flRate);
-
- // IBaseFilter delegate
- bool GetState( DWORD dwMilliSecsTimeout, FILTER_STATE *State, HRESULT &_ReturnValue);
-
- // IQualProp (EVR statistics window)
- STDMETHODIMP get_FramesDroppedInRenderer (int *pcFrames);
- STDMETHODIMP get_FramesDrawn (int *pcFramesDrawn);
- STDMETHODIMP get_AvgFrameRate (int *piAvgFrameRate);
- STDMETHODIMP get_Jitter (int *iJitter);
- STDMETHODIMP get_AvgSyncOffset (int *piAvg);
- STDMETHODIMP get_DevSyncOffset (int *piDev);
-
-
- // IMFRateSupport
- STDMETHODIMP GetSlowestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float *pflRate);
- STDMETHODIMP GetFastestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float *pflRate);
- STDMETHODIMP IsRateSupported(BOOL fThin, float flRate, float *pflNearestSupportedRate);
-
- float GetMaxRate(BOOL bThin);
-
-
- // IMFVideoPresenter
- STDMETHODIMP ProcessMessage(MFVP_MESSAGE_TYPE eMessage, ULONG_PTR ulParam);
- STDMETHODIMP GetCurrentMediaType(__deref_out IMFVideoMediaType **ppMediaType);
-
- // IMFTopologyServiceLookupClient
- STDMETHODIMP InitServicePointers(/* [in] */ __in IMFTopologyServiceLookup *pLookup);
- STDMETHODIMP ReleaseServicePointers();
-
- // IMFVideoDeviceID
- STDMETHODIMP GetDeviceID(/* [out] */ __out IID *pDeviceID);
-
- // IMFGetService
- STDMETHODIMP GetService (/* [in] */ __RPC__in REFGUID guidService,
- /* [in] */ __RPC__in REFIID riid,
- /* [iid_is][out] */ __RPC__deref_out_opt LPVOID *ppvObject);
-
- // IMFAsyncCallback
- STDMETHODIMP GetParameters( /* [out] */ __RPC__out DWORD *pdwFlags, /* [out] */ __RPC__out DWORD *pdwQueue);
- STDMETHODIMP Invoke ( /* [in] */ __RPC__in_opt IMFAsyncResult *pAsyncResult);
-
- // IMFVideoDisplayControl
- STDMETHODIMP GetNativeVideoSize(SIZE *pszVideo, SIZE *pszARVideo);
- STDMETHODIMP GetIdealVideoSize(SIZE *pszMin, SIZE *pszMax);
- STDMETHODIMP SetVideoPosition(const MFVideoNormalizedRect *pnrcSource, const LPRECT prcDest);
- STDMETHODIMP GetVideoPosition(MFVideoNormalizedRect *pnrcSource, LPRECT prcDest);
- STDMETHODIMP SetAspectRatioMode(DWORD dwAspectRatioMode);
- STDMETHODIMP GetAspectRatioMode(DWORD *pdwAspectRatioMode);
- STDMETHODIMP SetVideoWindow(HWND hwndVideo);
- STDMETHODIMP GetVideoWindow(HWND *phwndVideo);
- STDMETHODIMP RepaintVideo( void);
- STDMETHODIMP GetCurrentImage(BITMAPINFOHEADER *pBih, BYTE **pDib, DWORD *pcbDib, LONGLONG *pTimeStamp);
- STDMETHODIMP SetBorderColor(COLORREF Clr);
- STDMETHODIMP GetBorderColor(COLORREF *pClr);
- STDMETHODIMP SetRenderingPrefs(DWORD dwRenderFlags);
- STDMETHODIMP GetRenderingPrefs(DWORD *pdwRenderFlags);
- STDMETHODIMP SetFullscreen(BOOL fFullscreen);
- STDMETHODIMP GetFullscreen(BOOL *pfFullscreen);
-
- // IEVRTrustedVideoPlugin
- STDMETHODIMP IsInTrustedVideoMode(BOOL *pYes);
- STDMETHODIMP CanConstrict(BOOL *pYes);
- STDMETHODIMP SetConstriction(DWORD dwKPix);
- STDMETHODIMP DisableImageExport(BOOL bDisable);
-
- // IDirect3DDeviceManager9
- STDMETHODIMP ResetDevice(IDirect3DDevice9 *pDevice,UINT resetToken);
- STDMETHODIMP OpenDeviceHandle(HANDLE *phDevice);
- STDMETHODIMP CloseDeviceHandle(HANDLE hDevice);
- STDMETHODIMP TestDevice(HANDLE hDevice);
- STDMETHODIMP LockDevice(HANDLE hDevice, IDirect3DDevice9 **ppDevice, BOOL fBlock);
- STDMETHODIMP UnlockDevice(HANDLE hDevice, BOOL fSaveState);
- STDMETHODIMP GetVideoService(HANDLE hDevice, REFIID riid, void **ppService);
-
- protected :
- void OnResetDevice();
- virtual void OnVBlankFinished(bool fAll, LONGLONG PerformanceCounter);
-
- double m_ModeratedTime;
- LONGLONG m_ModeratedTimeLast;
- LONGLONG m_ModeratedClockLast;
- LONGLONG m_ModeratedTimer;
- MFCLOCK_STATE m_LastClockState;
- LONGLONG GetClockTime(LONGLONG PerformanceCounter);
-
- private :
-
- typedef enum {
- Started = State_Running,
- Stopped = State_Stopped,
- Paused = State_Paused,
- Shutdown = State_Running + 1
- } RENDER_STATE;
-
- COuterEVR* m_pOuterEVR;
- CComPtr<IMFClock> m_pClock;
- CComPtr<IDirect3DDeviceManager9> m_pD3DManager;
- CComPtr<IMFTransform> m_pMixer;
- CComPtr<IMediaEventSink> m_pSink;
- CComPtr<IMFVideoMediaType> m_pMediaType;
- MFVideoAspectRatioMode m_dwVideoAspectRatioMode;
- MFVideoRenderPrefs m_dwVideoRenderPrefs;
- COLORREF m_BorderColor;
-
-
- HANDLE m_hEvtQuit; // Stop rendering thread event
- bool m_bEvtQuit;
- HANDLE m_hEvtFlush; // Discard all buffers
- bool m_bEvtFlush;
-
- bool m_fUseInternalTimer;
- int32 m_LastSetOutputRange;
- bool m_bPendingRenegotiate;
- bool m_bPendingMediaFinished;
-
- HANDLE m_hThread;
- HANDLE m_hGetMixerThread;
- RENDER_STATE m_nRenderState;
-
- CCritSec m_SampleQueueLock;
- CCritSec m_ImageProcessingLock;
-
- CInterfaceList<IMFSample, &IID_IMFSample> m_FreeSamples;
- CInterfaceList<IMFSample, &IID_IMFSample> m_ScheduledSamples;
- IMFSample * m_pCurrentDisplaydSample;
- bool m_bWaitingSample;
- bool m_bLastSampleOffsetValid;
- LONGLONG m_LastScheduledSampleTime;
- double m_LastScheduledSampleTimeFP;
- LONGLONG m_LastScheduledUncorrectedSampleTime;
- LONGLONG m_MaxSampleDuration;
- LONGLONG m_LastSampleOffset;
- LONGLONG m_VSyncOffsetHistory[5];
- LONGLONG m_LastPredictedSync;
- int m_VSyncOffsetHistoryPos;
-
- UINT m_nResetToken;
- int m_nStepCount;
-
- bool m_bSignaledStarvation;
- LONGLONG m_StarvationClock;
-
- // Stats variable for IQualProp
- UINT m_pcFrames;
- UINT m_nDroppedUpdate;
- UINT m_pcFramesDrawn; // Retrieves the number of frames drawn since streaming started
- UINT m_piAvg;
- UINT m_piDev;
-
-
- void GetMixerThread();
- static DWORD WINAPI GetMixerThreadStatic(LPVOID lpParam);
-
- bool GetImageFromMixer();
- void RenderThread();
- static DWORD WINAPI PresentThread(LPVOID lpParam);
- void ResetStats();
- void StartWorkerThreads();
- void StopWorkerThreads();
- HRESULT CheckShutdown() const;
- void CompleteFrameStep(bool bCancel);
- void CheckWaitingSampleFromMixer();
-
- void RemoveAllSamples();
- HRESULT GetFreeSample(IMFSample** ppSample);
- HRESULT GetScheduledSample(IMFSample** ppSample, int &_Count);
- void MoveToFreeList(IMFSample* pSample, bool bTail);
- void MoveToScheduledList(IMFSample* pSample, bool _bSorted);
- void FlushSamples();
- void FlushSamplesInternal();
-
- // === Media type negotiation functions
- HRESULT RenegotiateMediaType();
- HRESULT IsMediaTypeSupported(IMFMediaType* pMixerType);
- HRESULT CreateProposedOutputType(IMFMediaType* pMixerType, IMFMediaType** pType);
- HRESULT SetMediaType(IMFMediaType* pType);
- HRESULT GetMediaTypeFourCC(IMFMediaType* pType, DWORD* pFourCC);
- HRESULT GetMediaTypeMerit(IMFMediaType* pType, int *pMerit);
- LPCTSTR GetMediaTypeFormatDesc(IMFMediaType* pMediaType);
-
- // === Functions pointers on Vista / .Net3 specifics library
- PTR_DXVA2CreateDirect3DDeviceManager9 pfDXVA2CreateDirect3DDeviceManager9;
- PTR_MFCreateDXSurfaceBuffer pfMFCreateDXSurfaceBuffer;
- PTR_MFCreateVideoSampleFromSurface pfMFCreateVideoSampleFromSurface;
- PTR_MFCreateVideoMediaType pfMFCreateVideoMediaType;
+ // dxva.dll
+ typedef HRESULT(__stdcall* PTR_DXVA2CreateDirect3DDeviceManager9)(UINT* pResetToken, IDirect3DDeviceManager9** ppDeviceManager);
+
+ // mf.dll
+ typedef HRESULT(__stdcall* PTR_MFCreatePresentationClock)(IMFPresentationClock** ppPresentationClock);
+
+ // evr.dll
+ typedef HRESULT(__stdcall* PTR_MFCreateDXSurfaceBuffer)(REFIID riid, IUnknown* punkSurface, BOOL fBottomUpWhenLinear, IMFMediaBuffer** ppBuffer);
+ typedef HRESULT(__stdcall* PTR_MFCreateVideoSampleFromSurface)(IUnknown* pUnkSurface, IMFSample** ppSample);
+ typedef HRESULT(__stdcall* PTR_MFCreateVideoMediaType)(const MFVIDEOFORMAT* pVideoFormat, IMFVideoMediaType** ppIVideoMediaType);
+
+ // AVRT.dll
+ typedef HANDLE(__stdcall* PTR_AvSetMmThreadCharacteristicsW)(LPCWSTR TaskName, LPDWORD TaskIndex);
+ typedef BOOL (__stdcall* PTR_AvSetMmThreadPriority)(HANDLE AvrtHandle, AVRT_PRIORITY Priority);
+ typedef BOOL (__stdcall* PTR_AvRevertMmThreadCharacteristics)(HANDLE AvrtHandle);
+
+ class COuterEVR;
+
+ class CEVRAllocatorPresenter :
+ public CDX9AllocatorPresenter,
+ public IMFGetService,
+ public IMFTopologyServiceLookupClient,
+ public IMFVideoDeviceID,
+ public IMFVideoPresenter,
+ public IDirect3DDeviceManager9,
+
+ public IMFAsyncCallback,
+ public IQualProp,
+ public IMFRateSupport,
+ public IMFVideoDisplayControl,
+ public IEVRTrustedVideoPlugin
+ /* public IMFVideoPositionMapper, // Non mandatory EVR Presenter Interfaces (see later...)
+ */
+ {
+ public:
+ CEVRAllocatorPresenter(HWND hWnd, bool bFullscreen, HRESULT& hr, CString& _Error);
+ ~CEVRAllocatorPresenter(void);
+
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
+ STDMETHODIMP_(bool) Paint(bool fAll);
+ STDMETHODIMP GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight);
+ STDMETHODIMP InitializeDevice(IMFMediaType* pMediaType);
+ STDMETHODIMP_(bool) ResetDevice();
+ STDMETHODIMP_(bool) DisplayChange();
+
+ // IMFClockStateSink
+ STDMETHODIMP OnClockStart(/* [in] */ MFTIME hnsSystemTime, /* [in] */ LONGLONG llClockStartOffset);
+ STDMETHODIMP OnClockStop(/* [in] */ MFTIME hnsSystemTime);
+ STDMETHODIMP OnClockPause(/* [in] */ MFTIME hnsSystemTime);
+ STDMETHODIMP OnClockRestart(/* [in] */ MFTIME hnsSystemTime);
+ STDMETHODIMP OnClockSetRate(/* [in] */ MFTIME hnsSystemTime, /* [in] */ float flRate);
+
+ // IBaseFilter delegate
+ bool GetState(DWORD dwMilliSecsTimeout, FILTER_STATE* State, HRESULT& _ReturnValue);
+
+ // IQualProp (EVR statistics window)
+ STDMETHODIMP get_FramesDroppedInRenderer(int* pcFrames);
+ STDMETHODIMP get_FramesDrawn(int* pcFramesDrawn);
+ STDMETHODIMP get_AvgFrameRate(int* piAvgFrameRate);
+ STDMETHODIMP get_Jitter(int* iJitter);
+ STDMETHODIMP get_AvgSyncOffset(int* piAvg);
+ STDMETHODIMP get_DevSyncOffset(int* piDev);
+
+
+ // IMFRateSupport
+ STDMETHODIMP GetSlowestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float* pflRate);
+ STDMETHODIMP GetFastestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float* pflRate);
+ STDMETHODIMP IsRateSupported(BOOL fThin, float flRate, float* pflNearestSupportedRate);
+
+ float GetMaxRate(BOOL bThin);
+
+
+ // IMFVideoPresenter
+ STDMETHODIMP ProcessMessage(MFVP_MESSAGE_TYPE eMessage, ULONG_PTR ulParam);
+ STDMETHODIMP GetCurrentMediaType(__deref_out IMFVideoMediaType** ppMediaType);
+
+ // IMFTopologyServiceLookupClient
+ STDMETHODIMP InitServicePointers(/* [in] */ __in IMFTopologyServiceLookup* pLookup);
+ STDMETHODIMP ReleaseServicePointers();
+
+ // IMFVideoDeviceID
+ STDMETHODIMP GetDeviceID(/* [out] */ __out IID* pDeviceID);
+
+ // IMFGetService
+ STDMETHODIMP GetService(/* [in] */ __RPC__in REFGUID guidService,
+ /* [in] */ __RPC__in REFIID riid,
+ /* [iid_is][out] */ __RPC__deref_out_opt LPVOID* ppvObject);
+
+ // IMFAsyncCallback
+ STDMETHODIMP GetParameters(/* [out] */ __RPC__out DWORD* pdwFlags, /* [out] */ __RPC__out DWORD* pdwQueue);
+ STDMETHODIMP Invoke(/* [in] */ __RPC__in_opt IMFAsyncResult* pAsyncResult);
+
+ // IMFVideoDisplayControl
+ STDMETHODIMP GetNativeVideoSize(SIZE* pszVideo, SIZE* pszARVideo);
+ STDMETHODIMP GetIdealVideoSize(SIZE* pszMin, SIZE* pszMax);
+ STDMETHODIMP SetVideoPosition(const MFVideoNormalizedRect* pnrcSource, const LPRECT prcDest);
+ STDMETHODIMP GetVideoPosition(MFVideoNormalizedRect* pnrcSource, LPRECT prcDest);
+ STDMETHODIMP SetAspectRatioMode(DWORD dwAspectRatioMode);
+ STDMETHODIMP GetAspectRatioMode(DWORD* pdwAspectRatioMode);
+ STDMETHODIMP SetVideoWindow(HWND hwndVideo);
+ STDMETHODIMP GetVideoWindow(HWND* phwndVideo);
+ STDMETHODIMP RepaintVideo(void);
+ STDMETHODIMP GetCurrentImage(BITMAPINFOHEADER* pBih, BYTE** pDib, DWORD* pcbDib, LONGLONG* pTimeStamp);
+ STDMETHODIMP SetBorderColor(COLORREF Clr);
+ STDMETHODIMP GetBorderColor(COLORREF* pClr);
+ STDMETHODIMP SetRenderingPrefs(DWORD dwRenderFlags);
+ STDMETHODIMP GetRenderingPrefs(DWORD* pdwRenderFlags);
+ STDMETHODIMP SetFullscreen(BOOL fFullscreen);
+ STDMETHODIMP GetFullscreen(BOOL* pfFullscreen);
+
+ // IEVRTrustedVideoPlugin
+ STDMETHODIMP IsInTrustedVideoMode(BOOL* pYes);
+ STDMETHODIMP CanConstrict(BOOL* pYes);
+ STDMETHODIMP SetConstriction(DWORD dwKPix);
+ STDMETHODIMP DisableImageExport(BOOL bDisable);
+
+ // IDirect3DDeviceManager9
+ STDMETHODIMP ResetDevice(IDirect3DDevice9* pDevice, UINT resetToken);
+ STDMETHODIMP OpenDeviceHandle(HANDLE* phDevice);
+ STDMETHODIMP CloseDeviceHandle(HANDLE hDevice);
+ STDMETHODIMP TestDevice(HANDLE hDevice);
+ STDMETHODIMP LockDevice(HANDLE hDevice, IDirect3DDevice9** ppDevice, BOOL fBlock);
+ STDMETHODIMP UnlockDevice(HANDLE hDevice, BOOL fSaveState);
+ STDMETHODIMP GetVideoService(HANDLE hDevice, REFIID riid, void** ppService);
+
+ protected :
+ void OnResetDevice();
+ virtual void OnVBlankFinished(bool fAll, LONGLONG PerformanceCounter);
+
+ double m_ModeratedTime;
+ LONGLONG m_ModeratedTimeLast;
+ LONGLONG m_ModeratedClockLast;
+ LONGLONG m_ModeratedTimer;
+ MFCLOCK_STATE m_LastClockState;
+ LONGLONG GetClockTime(LONGLONG PerformanceCounter);
+
+ private :
+
+ typedef enum {
+ Started = State_Running,
+ Stopped = State_Stopped,
+ Paused = State_Paused,
+ Shutdown = State_Running + 1
+ } RENDER_STATE;
+
+ COuterEVR* m_pOuterEVR;
+ CComPtr<IMFClock> m_pClock;
+ CComPtr<IDirect3DDeviceManager9> m_pD3DManager;
+ CComPtr<IMFTransform> m_pMixer;
+ CComPtr<IMediaEventSink> m_pSink;
+ CComPtr<IMFVideoMediaType> m_pMediaType;
+ MFVideoAspectRatioMode m_dwVideoAspectRatioMode;
+ MFVideoRenderPrefs m_dwVideoRenderPrefs;
+ COLORREF m_BorderColor;
+
+
+ HANDLE m_hEvtQuit; // Stop rendering thread event
+ bool m_bEvtQuit;
+ HANDLE m_hEvtFlush; // Discard all buffers
+ bool m_bEvtFlush;
+
+ bool m_fUseInternalTimer;
+ int32 m_LastSetOutputRange;
+ bool m_bPendingRenegotiate;
+ bool m_bPendingMediaFinished;
+
+ HANDLE m_hThread;
+ HANDLE m_hGetMixerThread;
+ RENDER_STATE m_nRenderState;
+
+ CCritSec m_SampleQueueLock;
+ CCritSec m_ImageProcessingLock;
+
+ CInterfaceList<IMFSample, &IID_IMFSample> m_FreeSamples;
+ CInterfaceList<IMFSample, &IID_IMFSample> m_ScheduledSamples;
+ IMFSample* m_pCurrentDisplaydSample;
+ bool m_bWaitingSample;
+ bool m_bLastSampleOffsetValid;
+ LONGLONG m_LastScheduledSampleTime;
+ double m_LastScheduledSampleTimeFP;
+ LONGLONG m_LastScheduledUncorrectedSampleTime;
+ LONGLONG m_MaxSampleDuration;
+ LONGLONG m_LastSampleOffset;
+ LONGLONG m_VSyncOffsetHistory[5];
+ LONGLONG m_LastPredictedSync;
+ int m_VSyncOffsetHistoryPos;
+
+ UINT m_nResetToken;
+ int m_nStepCount;
+
+ bool m_bSignaledStarvation;
+ LONGLONG m_StarvationClock;
+
+ // Stats variable for IQualProp
+ UINT m_pcFrames;
+ UINT m_nDroppedUpdate;
+ UINT m_pcFramesDrawn; // Retrieves the number of frames drawn since streaming started
+ UINT m_piAvg;
+ UINT m_piDev;
+
+
+ void GetMixerThread();
+ static DWORD WINAPI GetMixerThreadStatic(LPVOID lpParam);
+
+ bool GetImageFromMixer();
+ void RenderThread();
+ static DWORD WINAPI PresentThread(LPVOID lpParam);
+ void ResetStats();
+ void StartWorkerThreads();
+ void StopWorkerThreads();
+ HRESULT CheckShutdown() const;
+ void CompleteFrameStep(bool bCancel);
+ void CheckWaitingSampleFromMixer();
+
+ void RemoveAllSamples();
+ HRESULT GetFreeSample(IMFSample** ppSample);
+ HRESULT GetScheduledSample(IMFSample** ppSample, int& _Count);
+ void MoveToFreeList(IMFSample* pSample, bool bTail);
+ void MoveToScheduledList(IMFSample* pSample, bool _bSorted);
+ void FlushSamples();
+ void FlushSamplesInternal();
+
+ // === Media type negotiation functions
+ HRESULT RenegotiateMediaType();
+ HRESULT IsMediaTypeSupported(IMFMediaType* pMixerType);
+ HRESULT CreateProposedOutputType(IMFMediaType* pMixerType, IMFMediaType** pType);
+ HRESULT SetMediaType(IMFMediaType* pType);
+ HRESULT GetMediaTypeFourCC(IMFMediaType* pType, DWORD* pFourCC);
+ HRESULT GetMediaTypeMerit(IMFMediaType* pType, int* pMerit);
+ LPCTSTR GetMediaTypeFormatDesc(IMFMediaType* pMediaType);
+
+ // === Functions pointers on Vista / .Net3 specifics library
+ PTR_DXVA2CreateDirect3DDeviceManager9 pfDXVA2CreateDirect3DDeviceManager9;
+ PTR_MFCreateDXSurfaceBuffer pfMFCreateDXSurfaceBuffer;
+ PTR_MFCreateVideoSampleFromSurface pfMFCreateVideoSampleFromSurface;
+ PTR_MFCreateVideoMediaType pfMFCreateVideoMediaType;
#if 0
- HRESULT (__stdcall *pMFCreateMediaType)(__deref_out IMFMediaType** ppMFType);
- HRESULT (__stdcall *pMFInitMediaTypeFromAMMediaType)(__in IMFMediaType *pMFType, __in const AM_MEDIA_TYPE *pAMType);
- HRESULT (__stdcall *pMFInitAMMediaTypeFromMFMediaType)(__in IMFMediaType *pMFType, __in GUID guidFormatBlockType, __inout AM_MEDIA_TYPE *pAMType);
+ HRESULT(__stdcall* pMFCreateMediaType)(__deref_out IMFMediaType** ppMFType);
+ HRESULT(__stdcall* pMFInitMediaTypeFromAMMediaType)(__in IMFMediaType* pMFType, __in const AM_MEDIA_TYPE* pAMType);
+ HRESULT(__stdcall* pMFInitAMMediaTypeFromMFMediaType)(__in IMFMediaType* pMFType, __in GUID guidFormatBlockType, __inout AM_MEDIA_TYPE* pAMType);
#endif
- PTR_AvSetMmThreadCharacteristicsW pfAvSetMmThreadCharacteristicsW;
- PTR_AvSetMmThreadPriority pfAvSetMmThreadPriority;
- PTR_AvRevertMmThreadCharacteristics pfAvRevertMmThreadCharacteristics;
- };
+ PTR_AvSetMmThreadCharacteristicsW pfAvSetMmThreadCharacteristicsW;
+ PTR_AvSetMmThreadPriority pfAvSetMmThreadPriority;
+ PTR_AvRevertMmThreadCharacteristics pfAvRevertMmThreadCharacteristics;
+ };
}
diff --git a/src/filters/renderer/VideoRenderers/IPinHook.cpp b/src/filters/renderer/VideoRenderers/IPinHook.cpp
index 35f60c66d..006970cfe 100644
--- a/src/filters/renderer/VideoRenderers/IPinHook.cpp
+++ b/src/filters/renderer/VideoRenderers/IPinHook.cpp
@@ -43,620 +43,620 @@
#define LOG_FILE_BITSTREAM _T("bitstream.log")
#endif
-REFERENCE_TIME g_tSegmentStart = 0;
-REFERENCE_TIME g_tSampleStart = 0;
-GUID g_guidDXVADecoder = GUID_NULL;
-int g_nDXVAVersion = 0;
+REFERENCE_TIME g_tSegmentStart = 0;
+REFERENCE_TIME g_tSampleStart = 0;
+GUID g_guidDXVADecoder = GUID_NULL;
+int g_nDXVAVersion = 0;
-IPinCVtbl* g_pPinCVtbl = NULL;
-IMemInputPinCVtbl* g_pMemInputPinCVtbl = NULL;
+IPinCVtbl* g_pPinCVtbl = NULL;
+IMemInputPinCVtbl* g_pMemInputPinCVtbl = NULL;
typedef struct {
- const int Format;
- const LPCTSTR Description;
+ const int Format;
+ const LPCTSTR Description;
} D3DFORMAT_TYPE;
const D3DFORMAT_TYPE D3DFormatType[] = {
- { D3DFMT_UNKNOWN , _T("D3DFMT_UNKNOWN ") },
- { D3DFMT_R8G8B8 , _T("D3DFMT_R8G8B8 ") },
- { D3DFMT_A8R8G8B8 , _T("D3DFMT_A8R8G8B8 ") },
- { D3DFMT_X8R8G8B8 , _T("D3DFMT_X8R8G8B8 ") },
- { D3DFMT_R5G6B5 , _T("D3DFMT_R5G6B5 ") },
- { D3DFMT_X1R5G5B5 , _T("D3DFMT_X1R5G5B5 ") },
- { D3DFMT_A1R5G5B5 , _T("D3DFMT_A1R5G5B5 ") },
- { D3DFMT_A4R4G4B4 , _T("D3DFMT_A4R4G4B4 ") },
- { D3DFMT_R3G3B2 , _T("D3DFMT_R3G3B2 ") },
- { D3DFMT_A8 , _T("D3DFMT_A8 ") },
- { D3DFMT_A8R3G3B2 , _T("D3DFMT_A8R3G3B2 ") },
- { D3DFMT_X4R4G4B4 , _T("D3DFMT_X4R4G4B4 ") },
- { D3DFMT_A2B10G10R10 , _T("D3DFMT_A2B10G10R10 ") },
- { D3DFMT_A8B8G8R8 , _T("D3DFMT_A8B8G8R8 ") },
- { D3DFMT_X8B8G8R8 , _T("D3DFMT_X8B8G8R8 ") },
- { D3DFMT_G16R16 , _T("D3DFMT_G16R16 ") },
- { D3DFMT_A2R10G10B10 , _T("D3DFMT_A2R10G10B10 ") },
- { D3DFMT_A16B16G16R16 , _T("D3DFMT_A16B16G16R16 ") },
- { D3DFMT_A8P8 , _T("D3DFMT_A8P8 ") },
- { D3DFMT_P8 , _T("D3DFMT_P8 ") },
- { D3DFMT_L8 , _T("D3DFMT_L8 ") },
- { D3DFMT_A8L8 , _T("D3DFMT_A8L8 ") },
- { D3DFMT_A4L4 , _T("D3DFMT_A4L4 ") },
- { D3DFMT_X8L8V8U8 , _T("D3DFMT_X8L8V8U8 ") },
- { D3DFMT_Q8W8V8U8 , _T("D3DFMT_Q8W8V8U8 ") },
- { D3DFMT_V16U16 , _T("D3DFMT_V16U16 ") },
- { D3DFMT_A2W10V10U10 , _T("D3DFMT_A2W10V10U10 ") },
- { D3DFMT_UYVY , _T("D3DFMT_UYVY ") },
- { D3DFMT_R8G8_B8G8 , _T("D3DFMT_R8G8_B8G8 ") },
- { D3DFMT_YUY2 , _T("D3DFMT_YUY2 ") },
- { D3DFMT_G8R8_G8B8 , _T("D3DFMT_G8R8_G8B8 ") },
- { D3DFMT_DXT1 , _T("D3DFMT_DXT1 ") },
- { D3DFMT_DXT2 , _T("D3DFMT_DXT2 ") },
- { D3DFMT_DXT3 , _T("D3DFMT_DXT3 ") },
- { D3DFMT_DXT4 , _T("D3DFMT_DXT4 ") },
- { D3DFMT_DXT5 , _T("D3DFMT_DXT5 ") },
- { D3DFMT_D16_LOCKABLE , _T("D3DFMT_D16_LOCKABLE ") },
- { D3DFMT_D32 , _T("D3DFMT_D32 ") },
- { D3DFMT_D15S1 , _T("D3DFMT_D15S1 ") },
- { D3DFMT_D24S8 , _T("D3DFMT_D24S8 ") },
- { D3DFMT_D24X8 , _T("D3DFMT_D24X8 ") },
- { D3DFMT_D24X4S4 , _T("D3DFMT_D24X4S4 ") },
- { D3DFMT_D16 , _T("D3DFMT_D16 ") },
- { D3DFMT_D32F_LOCKABLE , _T("D3DFMT_D32F_LOCKABLE") },
- { D3DFMT_D24FS8 , _T("D3DFMT_D24FS8 ") },
- { D3DFMT_L16 , _T("D3DFMT_L16 ") },
- { D3DFMT_VERTEXDATA , _T("D3DFMT_VERTEXDATA ") },
- { D3DFMT_INDEX16 , _T("D3DFMT_INDEX16 ") },
- { D3DFMT_INDEX32 , _T("D3DFMT_INDEX32 ") },
- { D3DFMT_Q16W16V16U16 , _T("D3DFMT_Q16W16V16U16 ") },
-
- { MAKEFOURCC('N','V','1','2') , _T("D3DFMT_NV12") },
- { MAKEFOURCC('N','V','2','4') , _T("D3DFMT_NV24") },
+ { D3DFMT_UNKNOWN , _T("D3DFMT_UNKNOWN ") },
+ { D3DFMT_R8G8B8 , _T("D3DFMT_R8G8B8 ") },
+ { D3DFMT_A8R8G8B8 , _T("D3DFMT_A8R8G8B8 ") },
+ { D3DFMT_X8R8G8B8 , _T("D3DFMT_X8R8G8B8 ") },
+ { D3DFMT_R5G6B5 , _T("D3DFMT_R5G6B5 ") },
+ { D3DFMT_X1R5G5B5 , _T("D3DFMT_X1R5G5B5 ") },
+ { D3DFMT_A1R5G5B5 , _T("D3DFMT_A1R5G5B5 ") },
+ { D3DFMT_A4R4G4B4 , _T("D3DFMT_A4R4G4B4 ") },
+ { D3DFMT_R3G3B2 , _T("D3DFMT_R3G3B2 ") },
+ { D3DFMT_A8 , _T("D3DFMT_A8 ") },
+ { D3DFMT_A8R3G3B2 , _T("D3DFMT_A8R3G3B2 ") },
+ { D3DFMT_X4R4G4B4 , _T("D3DFMT_X4R4G4B4 ") },
+ { D3DFMT_A2B10G10R10 , _T("D3DFMT_A2B10G10R10 ") },
+ { D3DFMT_A8B8G8R8 , _T("D3DFMT_A8B8G8R8 ") },
+ { D3DFMT_X8B8G8R8 , _T("D3DFMT_X8B8G8R8 ") },
+ { D3DFMT_G16R16 , _T("D3DFMT_G16R16 ") },
+ { D3DFMT_A2R10G10B10 , _T("D3DFMT_A2R10G10B10 ") },
+ { D3DFMT_A16B16G16R16 , _T("D3DFMT_A16B16G16R16 ") },
+ { D3DFMT_A8P8 , _T("D3DFMT_A8P8 ") },
+ { D3DFMT_P8 , _T("D3DFMT_P8 ") },
+ { D3DFMT_L8 , _T("D3DFMT_L8 ") },
+ { D3DFMT_A8L8 , _T("D3DFMT_A8L8 ") },
+ { D3DFMT_A4L4 , _T("D3DFMT_A4L4 ") },
+ { D3DFMT_X8L8V8U8 , _T("D3DFMT_X8L8V8U8 ") },
+ { D3DFMT_Q8W8V8U8 , _T("D3DFMT_Q8W8V8U8 ") },
+ { D3DFMT_V16U16 , _T("D3DFMT_V16U16 ") },
+ { D3DFMT_A2W10V10U10 , _T("D3DFMT_A2W10V10U10 ") },
+ { D3DFMT_UYVY , _T("D3DFMT_UYVY ") },
+ { D3DFMT_R8G8_B8G8 , _T("D3DFMT_R8G8_B8G8 ") },
+ { D3DFMT_YUY2 , _T("D3DFMT_YUY2 ") },
+ { D3DFMT_G8R8_G8B8 , _T("D3DFMT_G8R8_G8B8 ") },
+ { D3DFMT_DXT1 , _T("D3DFMT_DXT1 ") },
+ { D3DFMT_DXT2 , _T("D3DFMT_DXT2 ") },
+ { D3DFMT_DXT3 , _T("D3DFMT_DXT3 ") },
+ { D3DFMT_DXT4 , _T("D3DFMT_DXT4 ") },
+ { D3DFMT_DXT5 , _T("D3DFMT_DXT5 ") },
+ { D3DFMT_D16_LOCKABLE , _T("D3DFMT_D16_LOCKABLE ") },
+ { D3DFMT_D32 , _T("D3DFMT_D32 ") },
+ { D3DFMT_D15S1 , _T("D3DFMT_D15S1 ") },
+ { D3DFMT_D24S8 , _T("D3DFMT_D24S8 ") },
+ { D3DFMT_D24X8 , _T("D3DFMT_D24X8 ") },
+ { D3DFMT_D24X4S4 , _T("D3DFMT_D24X4S4 ") },
+ { D3DFMT_D16 , _T("D3DFMT_D16 ") },
+ { D3DFMT_D32F_LOCKABLE , _T("D3DFMT_D32F_LOCKABLE") },
+ { D3DFMT_D24FS8 , _T("D3DFMT_D24FS8 ") },
+ { D3DFMT_L16 , _T("D3DFMT_L16 ") },
+ { D3DFMT_VERTEXDATA , _T("D3DFMT_VERTEXDATA ") },
+ { D3DFMT_INDEX16 , _T("D3DFMT_INDEX16 ") },
+ { D3DFMT_INDEX32 , _T("D3DFMT_INDEX32 ") },
+ { D3DFMT_Q16W16V16U16 , _T("D3DFMT_Q16W16V16U16 ") },
+
+ { MAKEFOURCC('N', 'V', '1', '2') , _T("D3DFMT_NV12") },
+ { MAKEFOURCC('N', 'V', '2', '4') , _T("D3DFMT_NV24") },
};
const LPCTSTR DXVAVersion[] = { _T("DXVA "), _T("DXVA1"), _T("DXVA2") };
LPCTSTR GetDXVADecoderDescription()
{
- return GetDXVAMode (&g_guidDXVADecoder);
+ return GetDXVAMode(&g_guidDXVADecoder);
}
LPCTSTR GetDXVAVersion()
{
- return DXVAVersion[g_nDXVAVersion];
+ return DXVAVersion[g_nDXVAVersion];
}
void ClearDXVAState()
{
- g_guidDXVADecoder = GUID_NULL;
- g_nDXVAVersion = 0;
+ g_guidDXVADecoder = GUID_NULL;
+ g_nDXVAVersion = 0;
}
LPCTSTR FindD3DFormat(const D3DFORMAT Format)
{
- for (int i=0; i<_countof(D3DFormatType); i++) {
- if (Format == D3DFormatType[i].Format) {
- return D3DFormatType[i].Description;
- }
- }
+ for (int i = 0; i < _countof(D3DFormatType); i++) {
+ if (Format == D3DFormatType[i].Format) {
+ return D3DFormatType[i].Description;
+ }
+ }
- return D3DFormatType[0].Description;
+ return D3DFormatType[0].Description;
}
// === DirectShow hooks
-static HRESULT (STDMETHODCALLTYPE * NewSegmentOrg)(IPinC * This, /* [in] */ REFERENCE_TIME tStart, /* [in] */ REFERENCE_TIME tStop, /* [in] */ double dRate) = NULL;
+static HRESULT(STDMETHODCALLTYPE* NewSegmentOrg)(IPinC* This, /* [in] */ REFERENCE_TIME tStart, /* [in] */ REFERENCE_TIME tStop, /* [in] */ double dRate) = NULL;
-static HRESULT STDMETHODCALLTYPE NewSegmentMine(IPinC * This, /* [in] */ REFERENCE_TIME tStart, /* [in] */ REFERENCE_TIME tStop, /* [in] */ double dRate)
+static HRESULT STDMETHODCALLTYPE NewSegmentMine(IPinC* This, /* [in] */ REFERENCE_TIME tStart, /* [in] */ REFERENCE_TIME tStop, /* [in] */ double dRate)
{
- g_tSegmentStart = tStart;
- return NewSegmentOrg(This, tStart, tStop, dRate);
+ g_tSegmentStart = tStart;
+ return NewSegmentOrg(This, tStart, tStop, dRate);
}
-static HRESULT ( STDMETHODCALLTYPE *ReceiveOrg )( IMemInputPinC * This, IMediaSample *pSample) = NULL;
+static HRESULT(STDMETHODCALLTYPE* ReceiveOrg)(IMemInputPinC* This, IMediaSample* pSample) = NULL;
-static HRESULT STDMETHODCALLTYPE ReceiveMineI(IMemInputPinC * This, IMediaSample *pSample)
+static HRESULT STDMETHODCALLTYPE ReceiveMineI(IMemInputPinC* This, IMediaSample* pSample)
{
- REFERENCE_TIME rtStart, rtStop;
- if (pSample && SUCCEEDED(pSample->GetTime(&rtStart, &rtStop))) {
- g_tSampleStart = rtStart;
- }
- return ReceiveOrg(This, pSample);
+ REFERENCE_TIME rtStart, rtStop;
+ if (pSample && SUCCEEDED(pSample->GetTime(&rtStart, &rtStop))) {
+ g_tSampleStart = rtStart;
+ }
+ return ReceiveOrg(This, pSample);
}
-static HRESULT STDMETHODCALLTYPE ReceiveMine(IMemInputPinC * This, IMediaSample *pSample)
+static HRESULT STDMETHODCALLTYPE ReceiveMine(IMemInputPinC* This, IMediaSample* pSample)
{
- // Support ffdshow queueing.
- // To avoid black out on pause, we have to lock g_ffdshowReceive to synchronize with CMainFrame::OnPlayPause.
- if (queue_ffdshow_support) {
- CAutoLock lck(&g_ffdshowReceive);
- return ReceiveMineI(This,pSample);
- }
- return ReceiveMineI(This,pSample);
+ // Support ffdshow queueing.
+ // To avoid black out on pause, we have to lock g_ffdshowReceive to synchronize with CMainFrame::OnPlayPause.
+ if (queue_ffdshow_support) {
+ CAutoLock lck(&g_ffdshowReceive);
+ return ReceiveMineI(This, pSample);
+ }
+ return ReceiveMineI(This, pSample);
}
void UnhookNewSegmentAndReceive()
{
- BOOL res;
- DWORD flOldProtect = 0;
-
- // Casimir666 : unhook previous VTables
- if (g_pPinCVtbl && g_pMemInputPinCVtbl) {
- res = VirtualProtect(g_pPinCVtbl, sizeof(IPinCVtbl), PAGE_WRITECOPY, &flOldProtect);
- if (g_pPinCVtbl->NewSegment == NewSegmentMine) {
- g_pPinCVtbl->NewSegment = NewSegmentOrg;
- }
- res = VirtualProtect(g_pPinCVtbl, sizeof(IPinCVtbl), flOldProtect, &flOldProtect);
-
- res = VirtualProtect(g_pMemInputPinCVtbl, sizeof(IMemInputPinCVtbl), PAGE_WRITECOPY, &flOldProtect);
- if (g_pMemInputPinCVtbl->Receive == ReceiveMine) {
- g_pMemInputPinCVtbl->Receive = ReceiveOrg;
- }
- res = VirtualProtect(g_pMemInputPinCVtbl, sizeof(IMemInputPinCVtbl), flOldProtect, &flOldProtect);
-
- g_pPinCVtbl = NULL;
- g_pMemInputPinCVtbl = NULL;
- NewSegmentOrg = NULL;
- ReceiveOrg = NULL;
- }
+ BOOL res;
+ DWORD flOldProtect = 0;
+
+ // Casimir666 : unhook previous VTables
+ if (g_pPinCVtbl && g_pMemInputPinCVtbl) {
+ res = VirtualProtect(g_pPinCVtbl, sizeof(IPinCVtbl), PAGE_WRITECOPY, &flOldProtect);
+ if (g_pPinCVtbl->NewSegment == NewSegmentMine) {
+ g_pPinCVtbl->NewSegment = NewSegmentOrg;
+ }
+ res = VirtualProtect(g_pPinCVtbl, sizeof(IPinCVtbl), flOldProtect, &flOldProtect);
+
+ res = VirtualProtect(g_pMemInputPinCVtbl, sizeof(IMemInputPinCVtbl), PAGE_WRITECOPY, &flOldProtect);
+ if (g_pMemInputPinCVtbl->Receive == ReceiveMine) {
+ g_pMemInputPinCVtbl->Receive = ReceiveOrg;
+ }
+ res = VirtualProtect(g_pMemInputPinCVtbl, sizeof(IMemInputPinCVtbl), flOldProtect, &flOldProtect);
+
+ g_pPinCVtbl = NULL;
+ g_pMemInputPinCVtbl = NULL;
+ NewSegmentOrg = NULL;
+ ReceiveOrg = NULL;
+ }
}
bool HookNewSegmentAndReceive(IPinC* pPinC, IMemInputPinC* pMemInputPinC)
{
- if (!pPinC || !pMemInputPinC) {
- return false;
- }
-
- g_tSegmentStart = 0;
- g_tSampleStart = 0;
-
- BOOL res;
- DWORD flOldProtect = 0;
-
- UnhookNewSegmentAndReceive();
-
- // Casimir666 : change sizeof(IPinC) to sizeof(IPinCVtbl) to fix crash with EVR hack on Vista!
- res = VirtualProtect(pPinC->lpVtbl, sizeof(IPinCVtbl), PAGE_WRITECOPY, &flOldProtect);
- if (NewSegmentOrg == NULL) {
- NewSegmentOrg = pPinC->lpVtbl->NewSegment;
- }
- pPinC->lpVtbl->NewSegment = NewSegmentMine; // Function sets global variable(s)
- res = VirtualProtect(pPinC->lpVtbl, sizeof(IPinCVtbl), flOldProtect, &flOldProtect);
-
- // Casimir666 : change sizeof(IMemInputPinC) to sizeof(IMemInputPinCVtbl) to fix crash with EVR hack on Vista!
- res = VirtualProtect(pMemInputPinC->lpVtbl, sizeof(IMemInputPinCVtbl), PAGE_WRITECOPY, &flOldProtect);
- if (ReceiveOrg == NULL) {
- ReceiveOrg = pMemInputPinC->lpVtbl->Receive;
- }
- pMemInputPinC->lpVtbl->Receive = ReceiveMine; // Function sets global variable(s)
- res = VirtualProtect(pMemInputPinC->lpVtbl, sizeof(IMemInputPinCVtbl), flOldProtect, &flOldProtect);
-
- g_pPinCVtbl = pPinC->lpVtbl;
- g_pMemInputPinCVtbl = pMemInputPinC->lpVtbl;
-
- return true;
+ if (!pPinC || !pMemInputPinC) {
+ return false;
+ }
+
+ g_tSegmentStart = 0;
+ g_tSampleStart = 0;
+
+ BOOL res;
+ DWORD flOldProtect = 0;
+
+ UnhookNewSegmentAndReceive();
+
+ // Casimir666 : change sizeof(IPinC) to sizeof(IPinCVtbl) to fix crash with EVR hack on Vista!
+ res = VirtualProtect(pPinC->lpVtbl, sizeof(IPinCVtbl), PAGE_WRITECOPY, &flOldProtect);
+ if (NewSegmentOrg == NULL) {
+ NewSegmentOrg = pPinC->lpVtbl->NewSegment;
+ }
+ pPinC->lpVtbl->NewSegment = NewSegmentMine; // Function sets global variable(s)
+ res = VirtualProtect(pPinC->lpVtbl, sizeof(IPinCVtbl), flOldProtect, &flOldProtect);
+
+ // Casimir666 : change sizeof(IMemInputPinC) to sizeof(IMemInputPinCVtbl) to fix crash with EVR hack on Vista!
+ res = VirtualProtect(pMemInputPinC->lpVtbl, sizeof(IMemInputPinCVtbl), PAGE_WRITECOPY, &flOldProtect);
+ if (ReceiveOrg == NULL) {
+ ReceiveOrg = pMemInputPinC->lpVtbl->Receive;
+ }
+ pMemInputPinC->lpVtbl->Receive = ReceiveMine; // Function sets global variable(s)
+ res = VirtualProtect(pMemInputPinC->lpVtbl, sizeof(IMemInputPinCVtbl), flOldProtect, &flOldProtect);
+
+ g_pPinCVtbl = pPinC->lpVtbl;
+ g_pMemInputPinCVtbl = pMemInputPinC->lpVtbl;
+
+ return true;
}
// === DXVA1 hooks
#ifdef _DEBUG
-#define MAX_BUFFER_TYPE 15
-BYTE* g_ppBuffer[MAX_BUFFER_TYPE]; // Only used for debug logging
+#define MAX_BUFFER_TYPE 15
+BYTE* g_ppBuffer[MAX_BUFFER_TYPE]; // Only used for debug logging
-static HRESULT ( STDMETHODCALLTYPE *GetVideoAcceleratorGUIDsOrg )( IAMVideoAcceleratorC * This,/* [out][in] */ LPDWORD pdwNumGuidsSupported,/* [out][in] */ LPGUID pGuidsSupported) = NULL;
-static HRESULT ( STDMETHODCALLTYPE *GetUncompFormatsSupportedOrg )( IAMVideoAcceleratorC * This,/* [in] */ const GUID *pGuid,/* [out][in] */ LPDWORD pdwNumFormatsSupported,/* [out][in] */ LPDDPIXELFORMAT pFormatsSupported) = NULL;
-static HRESULT ( STDMETHODCALLTYPE *GetInternalMemInfoOrg )( IAMVideoAcceleratorC * This,/* [in] */ const GUID *pGuid,/* [in] */ const AMVAUncompDataInfo *pamvaUncompDataInfo,/* [out][in] */ LPAMVAInternalMemInfo pamvaInternalMemInfo) = NULL;
+static HRESULT(STDMETHODCALLTYPE* GetVideoAcceleratorGUIDsOrg)(IAMVideoAcceleratorC* This,/* [out][in] */ LPDWORD pdwNumGuidsSupported,/* [out][in] */ LPGUID pGuidsSupported) = NULL;
+static HRESULT(STDMETHODCALLTYPE* GetUncompFormatsSupportedOrg)(IAMVideoAcceleratorC* This,/* [in] */ const GUID* pGuid,/* [out][in] */ LPDWORD pdwNumFormatsSupported,/* [out][in] */ LPDDPIXELFORMAT pFormatsSupported) = NULL;
+static HRESULT(STDMETHODCALLTYPE* GetInternalMemInfoOrg)(IAMVideoAcceleratorC* This,/* [in] */ const GUID* pGuid,/* [in] */ const AMVAUncompDataInfo* pamvaUncompDataInfo,/* [out][in] */ LPAMVAInternalMemInfo pamvaInternalMemInfo) = NULL;
#endif
-static HRESULT ( STDMETHODCALLTYPE *GetCompBufferInfoOrg )( IAMVideoAcceleratorC * This,/* [in] */ const GUID *pGuid,/* [in] */ const AMVAUncompDataInfo *pamvaUncompDataInfo,/* [out][in] */ LPDWORD pdwNumTypesCompBuffers,/* [out] */ LPAMVACompBufferInfo pamvaCompBufferInfo) = NULL;
+static HRESULT(STDMETHODCALLTYPE* GetCompBufferInfoOrg)(IAMVideoAcceleratorC* This,/* [in] */ const GUID* pGuid,/* [in] */ const AMVAUncompDataInfo* pamvaUncompDataInfo,/* [out][in] */ LPDWORD pdwNumTypesCompBuffers,/* [out] */ LPAMVACompBufferInfo pamvaCompBufferInfo) = NULL;
#ifdef _DEBUG
-static HRESULT ( STDMETHODCALLTYPE *GetInternalCompBufferInfoOrg )( IAMVideoAcceleratorC * This,/* [out][in] */ LPDWORD pdwNumTypesCompBuffers,/* [out] */ LPAMVACompBufferInfo pamvaCompBufferInfo) = NULL;
-static HRESULT ( STDMETHODCALLTYPE *BeginFrameOrg )( IAMVideoAcceleratorC * This,/* [in] */ const AMVABeginFrameInfo *amvaBeginFrameInfo) = NULL;
-static HRESULT ( STDMETHODCALLTYPE *EndFrameOrg )( IAMVideoAcceleratorC * This,/* [in] */ const AMVAEndFrameInfo *pEndFrameInfo) = NULL;
-static HRESULT ( STDMETHODCALLTYPE *GetBufferOrg )( IAMVideoAcceleratorC * This,/* [in] */ DWORD dwTypeIndex,/* [in] */ DWORD dwBufferIndex,/* [in] */ BOOL bReadOnly,/* [out] */ LPVOID *ppBuffer,/* [out] */ LONG *lpStride) = NULL;
-static HRESULT ( STDMETHODCALLTYPE *ReleaseBufferOrg )( IAMVideoAcceleratorC * This,/* [in] */ DWORD dwTypeIndex,/* [in] */ DWORD dwBufferIndex) = NULL;
-static HRESULT ( STDMETHODCALLTYPE *ExecuteOrg )( IAMVideoAcceleratorC * This,/* [in] */ DWORD dwFunction,/* [in] */ LPVOID lpPrivateInputData,/* [in] */ DWORD cbPrivateInputData,/* [in] */ LPVOID lpPrivateOutputDat,/* [in] */ DWORD cbPrivateOutputData,/* [in] */ DWORD dwNumBuffers,/* [in] */ const AMVABUFFERINFO *pamvaBufferInfo) = NULL;
-static HRESULT ( STDMETHODCALLTYPE *QueryRenderStatusOrg )( IAMVideoAcceleratorC * This,/* [in] */ DWORD dwTypeIndex,/* [in] */ DWORD dwBufferIndex,/* [in] */ DWORD dwFlags) = NULL;
-static HRESULT ( STDMETHODCALLTYPE *DisplayFrameOrg )( IAMVideoAcceleratorC * This,/* [in] */ DWORD dwFlipToIndex,/* [in] */ IMediaSample *pMediaSample) = NULL;
+static HRESULT(STDMETHODCALLTYPE* GetInternalCompBufferInfoOrg)(IAMVideoAcceleratorC* This,/* [out][in] */ LPDWORD pdwNumTypesCompBuffers,/* [out] */ LPAMVACompBufferInfo pamvaCompBufferInfo) = NULL;
+static HRESULT(STDMETHODCALLTYPE* BeginFrameOrg)(IAMVideoAcceleratorC* This,/* [in] */ const AMVABeginFrameInfo* amvaBeginFrameInfo) = NULL;
+static HRESULT(STDMETHODCALLTYPE* EndFrameOrg)(IAMVideoAcceleratorC* This,/* [in] */ const AMVAEndFrameInfo* pEndFrameInfo) = NULL;
+static HRESULT(STDMETHODCALLTYPE* GetBufferOrg)(IAMVideoAcceleratorC* This,/* [in] */ DWORD dwTypeIndex,/* [in] */ DWORD dwBufferIndex,/* [in] */ BOOL bReadOnly,/* [out] */ LPVOID* ppBuffer,/* [out] */ LONG* lpStride) = NULL;
+static HRESULT(STDMETHODCALLTYPE* ReleaseBufferOrg)(IAMVideoAcceleratorC* This,/* [in] */ DWORD dwTypeIndex,/* [in] */ DWORD dwBufferIndex) = NULL;
+static HRESULT(STDMETHODCALLTYPE* ExecuteOrg)(IAMVideoAcceleratorC* This,/* [in] */ DWORD dwFunction,/* [in] */ LPVOID lpPrivateInputData,/* [in] */ DWORD cbPrivateInputData,/* [in] */ LPVOID lpPrivateOutputDat,/* [in] */ DWORD cbPrivateOutputData,/* [in] */ DWORD dwNumBuffers,/* [in] */ const AMVABUFFERINFO* pamvaBufferInfo) = NULL;
+static HRESULT(STDMETHODCALLTYPE* QueryRenderStatusOrg)(IAMVideoAcceleratorC* This,/* [in] */ DWORD dwTypeIndex,/* [in] */ DWORD dwBufferIndex,/* [in] */ DWORD dwFlags) = NULL;
+static HRESULT(STDMETHODCALLTYPE* DisplayFrameOrg)(IAMVideoAcceleratorC* This,/* [in] */ DWORD dwFlipToIndex,/* [in] */ IMediaSample* pMediaSample) = NULL;
#endif
#if defined(_DEBUG) && DXVA_LOGFILE_A
static void LOG_TOFILE(LPCTSTR FileName, LPCTSTR fmt, ...)
{
- va_list args;
- va_start(args, fmt);
- int nCount = _vsctprintf(fmt, args) + 1;
- if (TCHAR* buff = DNew TCHAR[nCount]) {
- FILE* f;
- _vstprintf_s(buff, nCount, fmt, args);
- if (_tfopen_s(&f, FileName, _T("at")) == 0) {
- fseek(f, 0, 2);
- _ftprintf_s(f, _T("%s\n"), buff);
- fclose(f);
- }
- delete [] buff;
- }
- va_end(args);
+ va_list args;
+ va_start(args, fmt);
+ int nCount = _vsctprintf(fmt, args) + 1;
+ if (TCHAR* buff = DNew TCHAR[nCount]) {
+ FILE* f;
+ _vstprintf_s(buff, nCount, fmt, args);
+ if (_tfopen_s(&f, FileName, _T("at")) == 0) {
+ fseek(f, 0, 2);
+ _ftprintf_s(f, _T("%s\n"), buff);
+ fclose(f);
+ }
+ delete [] buff;
+ }
+ va_end(args);
}
static void LOG(LPCTSTR fmt, ...)
{
- va_list args;
- va_start(args, fmt);
- //int nCount = _vsctprintf(fmt, args) + 1;
- TCHAR buff[3000];
- FILE* f;
- _vstprintf_s(buff, _countof(buff), fmt, args);
- if (_tfopen_s(&f, LOG_FILE_DXVA, _T("at")) == 0) {
- fseek(f, 0, 2);
- _ftprintf_s(f, _T("%s\n"), buff);
- fclose(f);
- }
-
- va_end(args);
+ va_list args;
+ va_start(args, fmt);
+ //int nCount = _vsctprintf(fmt, args) + 1;
+ TCHAR buff[3000];
+ FILE* f;
+ _vstprintf_s(buff, _countof(buff), fmt, args);
+ if (_tfopen_s(&f, LOG_FILE_DXVA, _T("at")) == 0) {
+ fseek(f, 0, 2);
+ _ftprintf_s(f, _T("%s\n"), buff);
+ fclose(f);
+ }
+
+ va_end(args);
}
static void LOGPF(LPCTSTR prefix, const DDPIXELFORMAT* p, int n)
{
- for (int i = 0; i < n; i++) {
- LOG(_T("%s[%d].dwSize = %d"), prefix, i, p[i].dwSize);
- LOG(_T("%s[%d].dwFlags = %08x"), prefix, i, p[i].dwFlags);
- LOG(_T("%s[%d].dwFourCC = %4.4hs"), prefix, i, &p[i].dwFourCC);
- LOG(_T("%s[%d].dwRGBBitCount = %08x"), prefix, i, &p[i].dwRGBBitCount);
- LOG(_T("%s[%d].dwRBitMask = %08x"), prefix, i, &p[i].dwRBitMask);
- LOG(_T("%s[%d].dwGBitMask = %08x"), prefix, i, &p[i].dwGBitMask);
- LOG(_T("%s[%d].dwBBitMask = %08x"), prefix, i, &p[i].dwBBitMask);
- LOG(_T("%s[%d].dwRGBAlphaBitMask = %08x"), prefix, i, &p[i].dwRGBAlphaBitMask);
- }
+ for (int i = 0; i < n; i++) {
+ LOG(_T("%s[%d].dwSize = %d"), prefix, i, p[i].dwSize);
+ LOG(_T("%s[%d].dwFlags = %08x"), prefix, i, p[i].dwFlags);
+ LOG(_T("%s[%d].dwFourCC = %4.4hs"), prefix, i, &p[i].dwFourCC);
+ LOG(_T("%s[%d].dwRGBBitCount = %08x"), prefix, i, &p[i].dwRGBBitCount);
+ LOG(_T("%s[%d].dwRBitMask = %08x"), prefix, i, &p[i].dwRBitMask);
+ LOG(_T("%s[%d].dwGBitMask = %08x"), prefix, i, &p[i].dwGBitMask);
+ LOG(_T("%s[%d].dwBBitMask = %08x"), prefix, i, &p[i].dwBBitMask);
+ LOG(_T("%s[%d].dwRGBAlphaBitMask = %08x"), prefix, i, &p[i].dwRGBAlphaBitMask);
+ }
}
static void LOGUDI(LPCTSTR prefix, const AMVAUncompDataInfo* p, int n)
{
- for (int i = 0; i < n; i++) {
- LOG(_T("%s[%d].dwUncompWidth = %d"), prefix, i, p[i].dwUncompWidth);
- LOG(_T("%s[%d].dwUncompHeight = %d"), prefix, i, p[i].dwUncompHeight);
-
- CString prefix2;
- prefix2.Format(_T("%s[%d]"), prefix, i);
- LOGPF(prefix2, &p[i].ddUncompPixelFormat, 1);
- }
+ for (int i = 0; i < n; i++) {
+ LOG(_T("%s[%d].dwUncompWidth = %d"), prefix, i, p[i].dwUncompWidth);
+ LOG(_T("%s[%d].dwUncompHeight = %d"), prefix, i, p[i].dwUncompHeight);
+
+ CString prefix2;
+ prefix2.Format(_T("%s[%d]"), prefix, i);
+ LOGPF(prefix2, &p[i].ddUncompPixelFormat, 1);
+ }
}
-static void LogDXVA_PicParams_H264 (DXVA_PicParams_H264* pPic)
+static void LogDXVA_PicParams_H264(DXVA_PicParams_H264* pPic)
{
- CString strRes;
- int i;
- static bool bFirstParam = true;
-
- if (bFirstParam) {
- LOG_TOFILE (LOG_FILE_PICTURE, _T("RefPicFlag,wFrameWidthInMbsMinus1,wFrameHeightInMbsMinus1,CurrPic.Index7Bits,num_ref_frames,wBitFields,bit_depth_luma_minus8,bit_depth_chroma_minus8,Reserved16Bits,StatusReportFeedbackNumber,RFL.Index7Bits[0],") \
- _T("RFL.Index7Bits[1],RFL.Index7Bits[2],RFL.Index7Bits[3],RFL.Index7Bits[4],RFL.Index7Bits[5],") \
- _T("RFL.Index7Bits[6],RFL.Index7Bits[7],RFL.Index7Bits[8],RFL.Index7Bits[9],RFL.Index7Bits[10],") \
- _T("RFL.Index7Bits[11],RFL.Index7Bits[12],RFL.Index7Bits[13],RFL.Index7Bits[14],RFL.Index7Bits[15],") \
- _T("CurrFieldOrderCnt[0], CurrFieldOrderCnt[1],FieldOrderCntList[0][0], FieldOrderCntList[0][1],FieldOrderCntList[1][0], FieldOrderCntList[1][1],FieldOrderCntList[2][0], FieldOrderCntList[2][1],FieldOrderCntList[3][0], FieldOrderCntList[3][1],FieldOrderCntList[4][0], FieldOrderCntList[4][1],FieldOrderCntList[5][0],") \
- _T("FieldOrderCntList[5][1],FieldOrderCntList[6][0], FieldOrderCntList[6][1],FieldOrderCntList[7][0], FieldOrderCntList[7][1],FieldOrderCntList[8][0], FieldOrderCntList[8][1],FieldOrderCntList[9][0], FieldOrderCntList[9][1],FieldOrderCntList[10][0], FieldOrderCntList[10][1],FieldOrderCntList[11][0],")\
- _T("FieldOrderCntList[11][1],FieldOrderCntList[12][0], FieldOrderCntList[12][1],FieldOrderCntList[13][0], FieldOrderCntList[13][1],FieldOrderCntList[14][0], FieldOrderCntList[14][1],FieldOrderCntList[15][0], FieldOrderCntList[15][1],pic_init_qs_minus26,chroma_qp_index_offset,second_chroma_qp_index_offset,")\
- _T("ContinuationFlag,pic_init_qp_minus26,num_ref_idx_l0_active_minus1,num_ref_idx_l1_active_minus1,Reserved8BitsA,FrameNumList[0],FrameNumList[1],FrameNumList[2],FrameNumList[3],FrameNumList[4],FrameNumList[5],FrameNumList[6],FrameNumList[7],FrameNumList[8],FrameNumList[9],FrameNumList[10],FrameNumList[11],")\
- _T("FrameNumList[12],FrameNumList[13],FrameNumList[14],FrameNumList[15],UsedForReferenceFlags,NonExistingFrameFlags,frame_num,log2_max_frame_num_minus4,pic_order_cnt_type,log2_max_pic_order_cnt_lsb_minus4,delta_pic_order_always_zero_flag,direct_8x8_inference_flag,entropy_coding_mode_flag,pic_order_present_flag,")\
- _T("num_slice_groups_minus1,slice_group_map_type,deblocking_filter_control_present_flag,redundant_pic_cnt_present_flag,Reserved8BitsB,slice_group_change_rate_minus1"));
-
- }
- bFirstParam = false;
-
- strRes.AppendFormat(_T("%d,"), pPic->RefPicFlag);
- strRes.AppendFormat(_T("%d,"), pPic->wFrameWidthInMbsMinus1);
- strRes.AppendFormat(_T("%d,"), pPic->wFrameHeightInMbsMinus1);
-
- // DXVA_PicEntry_H264 CurrPic)); /* flag is bot field flag */
- // strRes.AppendFormat(_T("%d,"), pPic->CurrPic.AssociatedFlag);
- // strRes.AppendFormat(_T("%d,"), pPic->CurrPic.bPicEntry);
- strRes.AppendFormat(_T("%d,"), pPic->CurrPic.Index7Bits);
-
-
- strRes.AppendFormat(_T("%d,"), pPic->num_ref_frames);
- strRes.AppendFormat(_T("%d,"), pPic->wBitFields);
- strRes.AppendFormat(_T("%d,"), pPic->bit_depth_luma_minus8);
- strRes.AppendFormat(_T("%d,"), pPic->bit_depth_chroma_minus8);
-
- strRes.AppendFormat(_T("%d,"), pPic->Reserved16Bits);
- strRes.AppendFormat(_T("%d,"), pPic->StatusReportFeedbackNumber);
-
- for (i =0; i<16; i++) {
- //strRes.AppendFormat(_T("%d,"), pPic->RefFrameList[i].AssociatedFlag);
- //strRes.AppendFormat(_T("%d,"), pPic->RefFrameList[i].bPicEntry);
- strRes.AppendFormat(_T("%d,"), pPic->RefFrameList[i].Index7Bits);
- }
-
- strRes.AppendFormat(_T("%d, %d,"), pPic->CurrFieldOrderCnt[0], pPic->CurrFieldOrderCnt[1]);
-
- for (int i=0; i<16; i++) {
- strRes.AppendFormat(_T("%d, %d,"), pPic->FieldOrderCntList[i][0], pPic->FieldOrderCntList[i][1]);
- }
- //strRes.AppendFormat(_T("%d,"), pPic->FieldOrderCntList[16][2]);
-
- strRes.AppendFormat(_T("%d,"), pPic->pic_init_qs_minus26);
- strRes.AppendFormat(_T("%d,"), pPic->chroma_qp_index_offset); /* also used for QScb */
- strRes.AppendFormat(_T("%d,"), pPic->second_chroma_qp_index_offset); /* also for QScr */
- strRes.AppendFormat(_T("%d,"), pPic->ContinuationFlag);
-
- /* remainder for parsing */
- strRes.AppendFormat(_T("%d,"), pPic->pic_init_qp_minus26);
- strRes.AppendFormat(_T("%d,"), pPic->num_ref_idx_l0_active_minus1);
- strRes.AppendFormat(_T("%d,"), pPic->num_ref_idx_l1_active_minus1);
- strRes.AppendFormat(_T("%d,"), pPic->Reserved8BitsA);
-
- for (int i=0; i<16; i++) {
- strRes.AppendFormat(_T("%d,"), pPic->FrameNumList[i]);
- }
-
- //strRes.AppendFormat(_T("%d,"), pPic->FrameNumList[16]);
- strRes.AppendFormat(_T("%d,"), pPic->UsedForReferenceFlags);
- strRes.AppendFormat(_T("%d,"), pPic->NonExistingFrameFlags);
- strRes.AppendFormat(_T("%d,"), pPic->frame_num);
-
- strRes.AppendFormat(_T("%d,"), pPic->log2_max_frame_num_minus4);
- strRes.AppendFormat(_T("%d,"), pPic->pic_order_cnt_type);
- strRes.AppendFormat(_T("%d,"), pPic->log2_max_pic_order_cnt_lsb_minus4);
- strRes.AppendFormat(_T("%d,"), pPic->delta_pic_order_always_zero_flag);
-
- strRes.AppendFormat(_T("%d,"), pPic->direct_8x8_inference_flag);
- strRes.AppendFormat(_T("%d,"), pPic->entropy_coding_mode_flag);
- strRes.AppendFormat(_T("%d,"), pPic->pic_order_present_flag);
- strRes.AppendFormat(_T("%d,"), pPic->num_slice_groups_minus1);
-
- strRes.AppendFormat(_T("%d,"), pPic->slice_group_map_type);
- strRes.AppendFormat(_T("%d,"), pPic->deblocking_filter_control_present_flag);
- strRes.AppendFormat(_T("%d,"), pPic->redundant_pic_cnt_present_flag);
- strRes.AppendFormat(_T("%d,"), pPic->Reserved8BitsB);
-
- strRes.AppendFormat(_T("%d,"), pPic->slice_group_change_rate_minus1);
-
- //for (int i=0; i<810; i++)
- // strRes.AppendFormat(_T("%d,"), pPic->SliceGroupMap[i]);
- // strRes.AppendFormat(_T("%d,"), pPic->SliceGroupMap[810]);
-
- // SABOTAGE !!!
- //for (int i=0; i<16; i++)
- //{
- // pPic->FieldOrderCntList[i][0] = pPic->FieldOrderCntList[i][1] = 0;
- // pPic->RefFrameList[i].AssociatedFlag = 1;
- // pPic->RefFrameList[i].bPicEntry = 255;
- // pPic->RefFrameList[i].Index7Bits = 127;
- //}
-
- // === Dump PicParams!
- //static FILE* hPict = NULL;
- //if (!hPict) hPict = fopen ("PicParam.bin", "wb");
- //if (hPict)
- //{
- // fwrite (pPic, sizeof (DXVA_PicParams_H264), 1, hPict);
- //}
-
- LOG_TOFILE(LOG_FILE_PICTURE, strRes);
+ CString strRes;
+ int i;
+ static bool bFirstParam = true;
+
+ if (bFirstParam) {
+ LOG_TOFILE(LOG_FILE_PICTURE, _T("RefPicFlag,wFrameWidthInMbsMinus1,wFrameHeightInMbsMinus1,CurrPic.Index7Bits,num_ref_frames,wBitFields,bit_depth_luma_minus8,bit_depth_chroma_minus8,Reserved16Bits,StatusReportFeedbackNumber,RFL.Index7Bits[0],") \
+ _T("RFL.Index7Bits[1],RFL.Index7Bits[2],RFL.Index7Bits[3],RFL.Index7Bits[4],RFL.Index7Bits[5],") \
+ _T("RFL.Index7Bits[6],RFL.Index7Bits[7],RFL.Index7Bits[8],RFL.Index7Bits[9],RFL.Index7Bits[10],") \
+ _T("RFL.Index7Bits[11],RFL.Index7Bits[12],RFL.Index7Bits[13],RFL.Index7Bits[14],RFL.Index7Bits[15],") \
+ _T("CurrFieldOrderCnt[0], CurrFieldOrderCnt[1],FieldOrderCntList[0][0], FieldOrderCntList[0][1],FieldOrderCntList[1][0], FieldOrderCntList[1][1],FieldOrderCntList[2][0], FieldOrderCntList[2][1],FieldOrderCntList[3][0], FieldOrderCntList[3][1],FieldOrderCntList[4][0], FieldOrderCntList[4][1],FieldOrderCntList[5][0],") \
+ _T("FieldOrderCntList[5][1],FieldOrderCntList[6][0], FieldOrderCntList[6][1],FieldOrderCntList[7][0], FieldOrderCntList[7][1],FieldOrderCntList[8][0], FieldOrderCntList[8][1],FieldOrderCntList[9][0], FieldOrderCntList[9][1],FieldOrderCntList[10][0], FieldOrderCntList[10][1],FieldOrderCntList[11][0],")\
+ _T("FieldOrderCntList[11][1],FieldOrderCntList[12][0], FieldOrderCntList[12][1],FieldOrderCntList[13][0], FieldOrderCntList[13][1],FieldOrderCntList[14][0], FieldOrderCntList[14][1],FieldOrderCntList[15][0], FieldOrderCntList[15][1],pic_init_qs_minus26,chroma_qp_index_offset,second_chroma_qp_index_offset,")\
+ _T("ContinuationFlag,pic_init_qp_minus26,num_ref_idx_l0_active_minus1,num_ref_idx_l1_active_minus1,Reserved8BitsA,FrameNumList[0],FrameNumList[1],FrameNumList[2],FrameNumList[3],FrameNumList[4],FrameNumList[5],FrameNumList[6],FrameNumList[7],FrameNumList[8],FrameNumList[9],FrameNumList[10],FrameNumList[11],")\
+ _T("FrameNumList[12],FrameNumList[13],FrameNumList[14],FrameNumList[15],UsedForReferenceFlags,NonExistingFrameFlags,frame_num,log2_max_frame_num_minus4,pic_order_cnt_type,log2_max_pic_order_cnt_lsb_minus4,delta_pic_order_always_zero_flag,direct_8x8_inference_flag,entropy_coding_mode_flag,pic_order_present_flag,")\
+ _T("num_slice_groups_minus1,slice_group_map_type,deblocking_filter_control_present_flag,redundant_pic_cnt_present_flag,Reserved8BitsB,slice_group_change_rate_minus1"));
+
+ }
+ bFirstParam = false;
+
+ strRes.AppendFormat(_T("%d,"), pPic->RefPicFlag);
+ strRes.AppendFormat(_T("%d,"), pPic->wFrameWidthInMbsMinus1);
+ strRes.AppendFormat(_T("%d,"), pPic->wFrameHeightInMbsMinus1);
+
+ // DXVA_PicEntry_H264 CurrPic)); /* flag is bot field flag */
+ // strRes.AppendFormat(_T("%d,"), pPic->CurrPic.AssociatedFlag);
+ // strRes.AppendFormat(_T("%d,"), pPic->CurrPic.bPicEntry);
+ strRes.AppendFormat(_T("%d,"), pPic->CurrPic.Index7Bits);
+
+
+ strRes.AppendFormat(_T("%d,"), pPic->num_ref_frames);
+ strRes.AppendFormat(_T("%d,"), pPic->wBitFields);
+ strRes.AppendFormat(_T("%d,"), pPic->bit_depth_luma_minus8);
+ strRes.AppendFormat(_T("%d,"), pPic->bit_depth_chroma_minus8);
+
+ strRes.AppendFormat(_T("%d,"), pPic->Reserved16Bits);
+ strRes.AppendFormat(_T("%d,"), pPic->StatusReportFeedbackNumber);
+
+ for (i = 0; i < 16; i++) {
+ //strRes.AppendFormat(_T("%d,"), pPic->RefFrameList[i].AssociatedFlag);
+ //strRes.AppendFormat(_T("%d,"), pPic->RefFrameList[i].bPicEntry);
+ strRes.AppendFormat(_T("%d,"), pPic->RefFrameList[i].Index7Bits);
+ }
+
+ strRes.AppendFormat(_T("%d, %d,"), pPic->CurrFieldOrderCnt[0], pPic->CurrFieldOrderCnt[1]);
+
+ for (int i = 0; i < 16; i++) {
+ strRes.AppendFormat(_T("%d, %d,"), pPic->FieldOrderCntList[i][0], pPic->FieldOrderCntList[i][1]);
+ }
+ //strRes.AppendFormat(_T("%d,"), pPic->FieldOrderCntList[16][2]);
+
+ strRes.AppendFormat(_T("%d,"), pPic->pic_init_qs_minus26);
+ strRes.AppendFormat(_T("%d,"), pPic->chroma_qp_index_offset); /* also used for QScb */
+ strRes.AppendFormat(_T("%d,"), pPic->second_chroma_qp_index_offset); /* also for QScr */
+ strRes.AppendFormat(_T("%d,"), pPic->ContinuationFlag);
+
+ /* remainder for parsing */
+ strRes.AppendFormat(_T("%d,"), pPic->pic_init_qp_minus26);
+ strRes.AppendFormat(_T("%d,"), pPic->num_ref_idx_l0_active_minus1);
+ strRes.AppendFormat(_T("%d,"), pPic->num_ref_idx_l1_active_minus1);
+ strRes.AppendFormat(_T("%d,"), pPic->Reserved8BitsA);
+
+ for (int i = 0; i < 16; i++) {
+ strRes.AppendFormat(_T("%d,"), pPic->FrameNumList[i]);
+ }
+
+ //strRes.AppendFormat(_T("%d,"), pPic->FrameNumList[16]);
+ strRes.AppendFormat(_T("%d,"), pPic->UsedForReferenceFlags);
+ strRes.AppendFormat(_T("%d,"), pPic->NonExistingFrameFlags);
+ strRes.AppendFormat(_T("%d,"), pPic->frame_num);
+
+ strRes.AppendFormat(_T("%d,"), pPic->log2_max_frame_num_minus4);
+ strRes.AppendFormat(_T("%d,"), pPic->pic_order_cnt_type);
+ strRes.AppendFormat(_T("%d,"), pPic->log2_max_pic_order_cnt_lsb_minus4);
+ strRes.AppendFormat(_T("%d,"), pPic->delta_pic_order_always_zero_flag);
+
+ strRes.AppendFormat(_T("%d,"), pPic->direct_8x8_inference_flag);
+ strRes.AppendFormat(_T("%d,"), pPic->entropy_coding_mode_flag);
+ strRes.AppendFormat(_T("%d,"), pPic->pic_order_present_flag);
+ strRes.AppendFormat(_T("%d,"), pPic->num_slice_groups_minus1);
+
+ strRes.AppendFormat(_T("%d,"), pPic->slice_group_map_type);
+ strRes.AppendFormat(_T("%d,"), pPic->deblocking_filter_control_present_flag);
+ strRes.AppendFormat(_T("%d,"), pPic->redundant_pic_cnt_present_flag);
+ strRes.AppendFormat(_T("%d,"), pPic->Reserved8BitsB);
+
+ strRes.AppendFormat(_T("%d,"), pPic->slice_group_change_rate_minus1);
+
+ //for (int i=0; i<810; i++)
+ // strRes.AppendFormat(_T("%d,"), pPic->SliceGroupMap[i]);
+ // strRes.AppendFormat(_T("%d,"), pPic->SliceGroupMap[810]);
+
+ // SABOTAGE !!!
+ //for (int i=0; i<16; i++)
+ //{
+ // pPic->FieldOrderCntList[i][0] = pPic->FieldOrderCntList[i][1] = 0;
+ // pPic->RefFrameList[i].AssociatedFlag = 1;
+ // pPic->RefFrameList[i].bPicEntry = 255;
+ // pPic->RefFrameList[i].Index7Bits = 127;
+ //}
+
+ // === Dump PicParams!
+ //static FILE* hPict = NULL;
+ //if (!hPict) hPict = fopen ("PicParam.bin", "wb");
+ //if (hPict)
+ //{
+ // fwrite (pPic, sizeof (DXVA_PicParams_H264), 1, hPict);
+ //}
+
+ LOG_TOFILE(LOG_FILE_PICTURE, strRes);
}
-static void LogH264SliceShort (DXVA_Slice_H264_Short* pSlice, int nCount)
+static void LogH264SliceShort(DXVA_Slice_H264_Short* pSlice, int nCount)
{
- CString strRes;
- static bool bFirstSlice = true;
-
- if (bFirstSlice) {
- strRes = _T("nCnt, BSNALunitDataLocation, SliceBytesInBuffer, wBadSliceChopping");
- LOG_TOFILE (LOG_FILE_SLICESHORT, strRes);
- strRes = "";
- bFirstSlice = false;
- }
-
- for (int i=0; i<nCount; i++) {
- strRes.AppendFormat(_T("%d,"), i);
- strRes.AppendFormat(_T("%d,"), pSlice[i].BSNALunitDataLocation);
- strRes.AppendFormat(_T("%d,"), pSlice[i].SliceBytesInBuffer);
- strRes.AppendFormat(_T("%d"), pSlice[i].wBadSliceChopping);
-
- LOG_TOFILE (LOG_FILE_SLICESHORT, strRes);
- strRes = "";
- }
+ CString strRes;
+ static bool bFirstSlice = true;
+
+ if (bFirstSlice) {
+ strRes = _T("nCnt, BSNALunitDataLocation, SliceBytesInBuffer, wBadSliceChopping");
+ LOG_TOFILE(LOG_FILE_SLICESHORT, strRes);
+ strRes = "";
+ bFirstSlice = false;
+ }
+
+ for (int i = 0; i < nCount; i++) {
+ strRes.AppendFormat(_T("%d,"), i);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].BSNALunitDataLocation);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].SliceBytesInBuffer);
+ strRes.AppendFormat(_T("%d"), pSlice[i].wBadSliceChopping);
+
+ LOG_TOFILE(LOG_FILE_SLICESHORT, strRes);
+ strRes = "";
+ }
}
-static void LogSliceInfo (DXVA_SliceInfo* pSlice, int nCount)
+static void LogSliceInfo(DXVA_SliceInfo* pSlice, int nCount)
{
- CString strRes;
- static bool bFirstSlice = true;
-
- if (bFirstSlice) {
- strRes = _T("nCnt, wHorizontalPosition, wVerticalPosition, dwSliceBitsInBuffer,dwSliceDataLocation, bStartCodeBitOffset, bReservedBits, wMBbitOffset, wNumberMBsInSlice, wQuantizerScaleCode, wBadSliceChopping");
-
- LOG_TOFILE (LOG_FILE_SLICESHORT, strRes);
- strRes = "";
- bFirstSlice = false;
- }
-
- for (int i=0; i<nCount; i++) {
- strRes.AppendFormat(_T("%d,"), i);
- strRes.AppendFormat(_T("%d,"), pSlice[i].wHorizontalPosition);
- strRes.AppendFormat(_T("%d,"), pSlice[i].wVerticalPosition);
- strRes.AppendFormat(_T("%d,"), pSlice[i].dwSliceBitsInBuffer);
- strRes.AppendFormat(_T("%d,"), pSlice[i].dwSliceDataLocation);
- strRes.AppendFormat(_T("%d,"), pSlice[i].bStartCodeBitOffset);
- strRes.AppendFormat(_T("%d,"), pSlice[i].bReservedBits);
- strRes.AppendFormat(_T("%d,"), pSlice[i].wMBbitOffset);
- strRes.AppendFormat(_T("%d,"), pSlice[i].wNumberMBsInSlice);
- strRes.AppendFormat(_T("%d,"), pSlice[i].wQuantizerScaleCode);
- strRes.AppendFormat(_T("%d"), pSlice[i].wBadSliceChopping);
-
- LOG_TOFILE (LOG_FILE_SLICESHORT, strRes);
- strRes = "";
- }
+ CString strRes;
+ static bool bFirstSlice = true;
+
+ if (bFirstSlice) {
+ strRes = _T("nCnt, wHorizontalPosition, wVerticalPosition, dwSliceBitsInBuffer,dwSliceDataLocation, bStartCodeBitOffset, bReservedBits, wMBbitOffset, wNumberMBsInSlice, wQuantizerScaleCode, wBadSliceChopping");
+
+ LOG_TOFILE(LOG_FILE_SLICESHORT, strRes);
+ strRes = "";
+ bFirstSlice = false;
+ }
+
+ for (int i = 0; i < nCount; i++) {
+ strRes.AppendFormat(_T("%d,"), i);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].wHorizontalPosition);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].wVerticalPosition);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].dwSliceBitsInBuffer);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].dwSliceDataLocation);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].bStartCodeBitOffset);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].bReservedBits);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].wMBbitOffset);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].wNumberMBsInSlice);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].wQuantizerScaleCode);
+ strRes.AppendFormat(_T("%d"), pSlice[i].wBadSliceChopping);
+
+ LOG_TOFILE(LOG_FILE_SLICESHORT, strRes);
+ strRes = "";
+ }
}
-static void LogH264SliceLong (DXVA_Slice_H264_Long* pSlice, int nCount)
+static void LogH264SliceLong(DXVA_Slice_H264_Long* pSlice, int nCount)
{
- static bool bFirstSlice = true;
- CString strRes;
-
- if (bFirstSlice) {
- strRes = _T("nCnt, BSNALunitDataLocation, SliceBytesInBuffer, wBadSliceChopping,") \
- _T("first_mb_in_slice, NumMbsForSlice, BitOffsetToSliceData, slice_type,luma_log2_weight_denom,chroma_log2_weight_denom,") \
- _T("num_ref_idx_l0_active_minus1,num_ref_idx_l1_active_minus1,slice_alpha_c0_offset_div2,slice_beta_offset_div2,") \
- _T("Reserved8Bits,slice_qs_delta,slice_qp_delta,redundant_pic_cnt,direct_spatial_mv_pred_flag,cabac_init_idc,") \
- _T("disable_deblocking_filter_idc,slice_id,");
-
- for (int i=0; i<2; i++) { /* L0 & L1 */
- for (int j=0; j<32; j++) {
- strRes.AppendFormat(_T("R[%d][%d].AssociatedFlag,"), i, j);
- strRes.AppendFormat(_T("R[%d][%d].bPicEntry,"), i, j);
- strRes.AppendFormat(_T("R[%d][%d].Index7Bits,"), i, j);
- }
- }
-
- for (int a=0; a<2; a++) { /* L0 & L1; Y, Cb, Cr */
- for (int b=0; b<32; b++) {
- for (int c=0; c<3; c++) {
- for (int d=0; d<2; d++) {
- strRes.AppendFormat(_T("W[%d][%d][%d][%d],"), a,b,c,d);
- }
- }
- }
- }
-
-
- LOG_TOFILE (LOG_FILE_SLICELONG, strRes);
- strRes = "";
- }
- bFirstSlice = false;
-
- for (int i=0; i<nCount; i++) {
- strRes.AppendFormat(_T("%d,"), i);
- strRes.AppendFormat(_T("%d,"), pSlice[i].BSNALunitDataLocation);
- strRes.AppendFormat(_T("%d,"), pSlice[i].SliceBytesInBuffer);
- strRes.AppendFormat(_T("%d,"), pSlice[i].wBadSliceChopping);
-
- strRes.AppendFormat(_T("%d,"), pSlice[i].first_mb_in_slice);
- strRes.AppendFormat(_T("%d,"), pSlice[i].NumMbsForSlice);
-
- strRes.AppendFormat(_T("%d,"), pSlice[i].BitOffsetToSliceData);
-
- strRes.AppendFormat(_T("%d,"), pSlice[i].slice_type);
- strRes.AppendFormat(_T("%d,"), pSlice[i].luma_log2_weight_denom);
- strRes.AppendFormat(_T("%d,"), pSlice[i].chroma_log2_weight_denom);
- strRes.AppendFormat(_T("%d,"), pSlice[i].num_ref_idx_l0_active_minus1);
- strRes.AppendFormat(_T("%d,"), pSlice[i].num_ref_idx_l1_active_minus1);
- strRes.AppendFormat(_T("%d,"), pSlice[i].slice_alpha_c0_offset_div2);
- strRes.AppendFormat(_T("%d,"), pSlice[i].slice_beta_offset_div2);
- strRes.AppendFormat(_T("%d,"), pSlice[i].Reserved8Bits);
-
- strRes.AppendFormat(_T("%d,"), pSlice[i].slice_qs_delta);
-
- strRes.AppendFormat(_T("%d,"), pSlice[i].slice_qp_delta);
- strRes.AppendFormat(_T("%d,"), pSlice[i].redundant_pic_cnt);
- strRes.AppendFormat(_T("%d,"), pSlice[i].direct_spatial_mv_pred_flag);
- strRes.AppendFormat(_T("%d,"), pSlice[i].cabac_init_idc);
- strRes.AppendFormat(_T("%d,"), pSlice[i].disable_deblocking_filter_idc);
- strRes.AppendFormat(_T("%d,"), pSlice[i].slice_id);
-
- for (int a=0; a<2; a++) { /* L0 & L1 */
- for (int b=0; b<32; b++) {
- strRes.AppendFormat(_T("%d,"), pSlice[i].RefPicList[a][b].AssociatedFlag);
- strRes.AppendFormat(_T("%d,"), pSlice[i].RefPicList[a][b].bPicEntry);
- strRes.AppendFormat(_T("%d,"), pSlice[i].RefPicList[a][b].Index7Bits);
- }
- }
-
- for (int a=0; a<2; a++) { /* L0 & L1; Y, Cb, Cr */
- for (int b=0; b<32; b++) {
- for (int c=0; c<3; c++) {
- for (int d=0; d<2; d++) {
- strRes.AppendFormat(_T("%d,"), pSlice[i].Weights[a][b][c][d]);
- }
- }
- }
- }
-
- LOG_TOFILE (LOG_FILE_SLICELONG, strRes);
- strRes = "";
- }
+ static bool bFirstSlice = true;
+ CString strRes;
+
+ if (bFirstSlice) {
+ strRes = _T("nCnt, BSNALunitDataLocation, SliceBytesInBuffer, wBadSliceChopping,") \
+ _T("first_mb_in_slice, NumMbsForSlice, BitOffsetToSliceData, slice_type,luma_log2_weight_denom,chroma_log2_weight_denom,") \
+ _T("num_ref_idx_l0_active_minus1,num_ref_idx_l1_active_minus1,slice_alpha_c0_offset_div2,slice_beta_offset_div2,") \
+ _T("Reserved8Bits,slice_qs_delta,slice_qp_delta,redundant_pic_cnt,direct_spatial_mv_pred_flag,cabac_init_idc,") \
+ _T("disable_deblocking_filter_idc,slice_id,");
+
+ for (int i = 0; i < 2; i++) { /* L0 & L1 */
+ for (int j = 0; j < 32; j++) {
+ strRes.AppendFormat(_T("R[%d][%d].AssociatedFlag,"), i, j);
+ strRes.AppendFormat(_T("R[%d][%d].bPicEntry,"), i, j);
+ strRes.AppendFormat(_T("R[%d][%d].Index7Bits,"), i, j);
+ }
+ }
+
+ for (int a = 0; a < 2; a++) { /* L0 & L1; Y, Cb, Cr */
+ for (int b = 0; b < 32; b++) {
+ for (int c = 0; c < 3; c++) {
+ for (int d = 0; d < 2; d++) {
+ strRes.AppendFormat(_T("W[%d][%d][%d][%d],"), a, b, c, d);
+ }
+ }
+ }
+ }
+
+
+ LOG_TOFILE(LOG_FILE_SLICELONG, strRes);
+ strRes = "";
+ }
+ bFirstSlice = false;
+
+ for (int i = 0; i < nCount; i++) {
+ strRes.AppendFormat(_T("%d,"), i);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].BSNALunitDataLocation);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].SliceBytesInBuffer);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].wBadSliceChopping);
+
+ strRes.AppendFormat(_T("%d,"), pSlice[i].first_mb_in_slice);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].NumMbsForSlice);
+
+ strRes.AppendFormat(_T("%d,"), pSlice[i].BitOffsetToSliceData);
+
+ strRes.AppendFormat(_T("%d,"), pSlice[i].slice_type);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].luma_log2_weight_denom);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].chroma_log2_weight_denom);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].num_ref_idx_l0_active_minus1);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].num_ref_idx_l1_active_minus1);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].slice_alpha_c0_offset_div2);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].slice_beta_offset_div2);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].Reserved8Bits);
+
+ strRes.AppendFormat(_T("%d,"), pSlice[i].slice_qs_delta);
+
+ strRes.AppendFormat(_T("%d,"), pSlice[i].slice_qp_delta);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].redundant_pic_cnt);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].direct_spatial_mv_pred_flag);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].cabac_init_idc);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].disable_deblocking_filter_idc);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].slice_id);
+
+ for (int a = 0; a < 2; a++) { /* L0 & L1 */
+ for (int b = 0; b < 32; b++) {
+ strRes.AppendFormat(_T("%d,"), pSlice[i].RefPicList[a][b].AssociatedFlag);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].RefPicList[a][b].bPicEntry);
+ strRes.AppendFormat(_T("%d,"), pSlice[i].RefPicList[a][b].Index7Bits);
+ }
+ }
+
+ for (int a = 0; a < 2; a++) { /* L0 & L1; Y, Cb, Cr */
+ for (int b = 0; b < 32; b++) {
+ for (int c = 0; c < 3; c++) {
+ for (int d = 0; d < 2; d++) {
+ strRes.AppendFormat(_T("%d,"), pSlice[i].Weights[a][b][c][d]);
+ }
+ }
+ }
+ }
+
+ LOG_TOFILE(LOG_FILE_SLICELONG, strRes);
+ strRes = "";
+ }
}
-static void LogDXVA_PictureParameters (DXVA_PictureParameters* pPic)
+static void LogDXVA_PictureParameters(DXVA_PictureParameters* pPic)
{
- static bool bFirstPictureParam = true;
- CString strRes;
-
- if (bFirstPictureParam) {
- LOG_TOFILE (LOG_FILE_PICTURE, _T("wDecodedPictureIndex,wDeblockedPictureIndex,wForwardRefPictureIndex,wBackwardRefPictureIndex,wPicWidthInMBminus1,wPicHeightInMBminus1,bMacroblockWidthMinus1,bMacroblockHeightMinus1,bBlockWidthMinus1,bBlockHeightMinus1,bBPPminus1,bPicStructure,bSecondField,bPicIntra,bPicBackwardPrediction,bBidirectionalAveragingMode,bMVprecisionAndChromaRelation,bChromaFormat,bPicScanFixed,bPicScanMethod,bPicReadbackRequests,bRcontrol,bPicSpatialResid8,bPicOverflowBlocks,bPicExtrapolation,bPicDeblocked,bPicDeblockConfined,bPic4MVallowed,bPicOBMC,bPicBinPB,bMV_RPS,bReservedBits,wBitstreamFcodes,wBitstreamPCEelements,bBitstreamConcealmentNeed,bBitstreamConcealmentMethod"));
- }
- bFirstPictureParam = false;
-
- strRes.Format (_T("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d"),
- pPic->wDecodedPictureIndex,
- pPic->wDeblockedPictureIndex,
- pPic->wForwardRefPictureIndex,
- pPic->wBackwardRefPictureIndex,
- pPic->wPicWidthInMBminus1,
- pPic->wPicHeightInMBminus1,
- pPic->bMacroblockWidthMinus1,
- pPic->bMacroblockHeightMinus1,
- pPic->bBlockWidthMinus1,
- pPic->bBlockHeightMinus1,
- pPic->bBPPminus1,
- pPic->bPicStructure,
- pPic->bSecondField,
- pPic->bPicIntra,
- pPic->bPicBackwardPrediction,
- pPic->bBidirectionalAveragingMode,
- pPic->bMVprecisionAndChromaRelation,
- pPic->bChromaFormat,
- pPic->bPicScanFixed,
- pPic->bPicScanMethod,
- pPic->bPicReadbackRequests,
- pPic->bRcontrol,
- pPic->bPicSpatialResid8,
- pPic->bPicOverflowBlocks,
- pPic->bPicExtrapolation,
- pPic->bPicDeblocked,
- pPic->bPicDeblockConfined,
- pPic->bPic4MVallowed,
- pPic->bPicOBMC,
- pPic->bPicBinPB,
- pPic->bMV_RPS,
- pPic->bReservedBits,
- pPic->wBitstreamFcodes,
- pPic->wBitstreamPCEelements,
- pPic->bBitstreamConcealmentNeed,
- pPic->bBitstreamConcealmentMethod);
-
- LOG_TOFILE (LOG_FILE_PICTURE, strRes);
+ static bool bFirstPictureParam = true;
+ CString strRes;
+
+ if (bFirstPictureParam) {
+ LOG_TOFILE(LOG_FILE_PICTURE, _T("wDecodedPictureIndex,wDeblockedPictureIndex,wForwardRefPictureIndex,wBackwardRefPictureIndex,wPicWidthInMBminus1,wPicHeightInMBminus1,bMacroblockWidthMinus1,bMacroblockHeightMinus1,bBlockWidthMinus1,bBlockHeightMinus1,bBPPminus1,bPicStructure,bSecondField,bPicIntra,bPicBackwardPrediction,bBidirectionalAveragingMode,bMVprecisionAndChromaRelation,bChromaFormat,bPicScanFixed,bPicScanMethod,bPicReadbackRequests,bRcontrol,bPicSpatialResid8,bPicOverflowBlocks,bPicExtrapolation,bPicDeblocked,bPicDeblockConfined,bPic4MVallowed,bPicOBMC,bPicBinPB,bMV_RPS,bReservedBits,wBitstreamFcodes,wBitstreamPCEelements,bBitstreamConcealmentNeed,bBitstreamConcealmentMethod"));
+ }
+ bFirstPictureParam = false;
+
+ strRes.Format(_T("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d"),
+ pPic->wDecodedPictureIndex,
+ pPic->wDeblockedPictureIndex,
+ pPic->wForwardRefPictureIndex,
+ pPic->wBackwardRefPictureIndex,
+ pPic->wPicWidthInMBminus1,
+ pPic->wPicHeightInMBminus1,
+ pPic->bMacroblockWidthMinus1,
+ pPic->bMacroblockHeightMinus1,
+ pPic->bBlockWidthMinus1,
+ pPic->bBlockHeightMinus1,
+ pPic->bBPPminus1,
+ pPic->bPicStructure,
+ pPic->bSecondField,
+ pPic->bPicIntra,
+ pPic->bPicBackwardPrediction,
+ pPic->bBidirectionalAveragingMode,
+ pPic->bMVprecisionAndChromaRelation,
+ pPic->bChromaFormat,
+ pPic->bPicScanFixed,
+ pPic->bPicScanMethod,
+ pPic->bPicReadbackRequests,
+ pPic->bRcontrol,
+ pPic->bPicSpatialResid8,
+ pPic->bPicOverflowBlocks,
+ pPic->bPicExtrapolation,
+ pPic->bPicDeblocked,
+ pPic->bPicDeblockConfined,
+ pPic->bPic4MVallowed,
+ pPic->bPicOBMC,
+ pPic->bPicBinPB,
+ pPic->bMV_RPS,
+ pPic->bReservedBits,
+ pPic->wBitstreamFcodes,
+ pPic->wBitstreamPCEelements,
+ pPic->bBitstreamConcealmentNeed,
+ pPic->bBitstreamConcealmentMethod);
+
+ LOG_TOFILE(LOG_FILE_PICTURE, strRes);
}
void LogDXVA_Bitstream(BYTE* pBuffer, int nSize)
{
- CString strRes;
- static bool bFirstBitstream = true;
-
- if (bFirstBitstream) {
- LOG_TOFILE (LOG_FILE_BITSTREAM, _T("Size,Start, Stop"));
- }
- bFirstBitstream = false;
-
- strRes.Format (_T("%d, -"), nSize);
-
- for (int i=0; i<20; i++) {
- if (i < nSize) {
- strRes.AppendFormat (_T(" %02x"), pBuffer[i]);
- } else {
- strRes.Append(_T(" --"));
- }
- }
-
- strRes.Append (_T(", -"), nSize);
- for (int i=0; i<20; i++) {
- if (nSize-i >= 0) {
- strRes.AppendFormat (_T(" %02x"), pBuffer[i]);
- } else {
- strRes.Append(_T(" --"));
- }
- }
-
- LOG_TOFILE (LOG_FILE_BITSTREAM, strRes);
+ CString strRes;
+ static bool bFirstBitstream = true;
+
+ if (bFirstBitstream) {
+ LOG_TOFILE(LOG_FILE_BITSTREAM, _T("Size,Start, Stop"));
+ }
+ bFirstBitstream = false;
+
+ strRes.Format(_T("%d, -"), nSize);
+
+ for (int i = 0; i < 20; i++) {
+ if (i < nSize) {
+ strRes.AppendFormat(_T(" %02x"), pBuffer[i]);
+ } else {
+ strRes.Append(_T(" --"));
+ }
+ }
+
+ strRes.Append(_T(", -"), nSize);
+ for (int i = 0; i < 20; i++) {
+ if (nSize - i >= 0) {
+ strRes.AppendFormat(_T(" %02x"), pBuffer[i]);
+ } else {
+ strRes.Append(_T(" --"));
+ }
+ }
+
+ LOG_TOFILE(LOG_FILE_BITSTREAM, strRes);
}
@@ -664,407 +664,407 @@ void LogDXVA_Bitstream(BYTE* pBuffer, int nSize)
inline static void LOG(...) { }
inline static void LOGPF(LPCTSTR prefix, const DDPIXELFORMAT* p, int n) {}
inline static void LOGUDI(LPCTSTR prefix, const AMVAUncompDataInfo* p, int n) {}
-inline static void LogDXVA_PicParams_H264 (DXVA_PicParams_H264* pPic) {}
-inline static void LogDXVA_PictureParameters (DXVA_PictureParameters* pPic) {}
+inline static void LogDXVA_PicParams_H264(DXVA_PicParams_H264* pPic) {}
+inline static void LogDXVA_PictureParameters(DXVA_PictureParameters* pPic) {}
inline static void LogDXVA_Bitstream(BYTE* pBuffer, int nSize) {}
#endif
#ifdef _DEBUG
-static HRESULT STDMETHODCALLTYPE GetVideoAcceleratorGUIDsMine(IAMVideoAcceleratorC * This, LPDWORD pdwNumGuidsSupported, LPGUID pGuidsSupported)
+static HRESULT STDMETHODCALLTYPE GetVideoAcceleratorGUIDsMine(IAMVideoAcceleratorC* This, LPDWORD pdwNumGuidsSupported, LPGUID pGuidsSupported)
{
- LOG(_T("\nGetVideoAcceleratorGUIDs"));
+ LOG(_T("\nGetVideoAcceleratorGUIDs"));
- if (pdwNumGuidsSupported) {
- LOG(_T("[in] *pdwNumGuidsSupported = %d"), *pdwNumGuidsSupported);
- }
+ if (pdwNumGuidsSupported) {
+ LOG(_T("[in] *pdwNumGuidsSupported = %d"), *pdwNumGuidsSupported);
+ }
- HRESULT hr = GetVideoAcceleratorGUIDsOrg(This, pdwNumGuidsSupported, pGuidsSupported);
+ HRESULT hr = GetVideoAcceleratorGUIDsOrg(This, pdwNumGuidsSupported, pGuidsSupported);
- LOG(_T("hr = %08x"), hr);
+ LOG(_T("hr = %08x"), hr);
- if (pdwNumGuidsSupported) {
- LOG(_T("[out] *pdwNumGuidsSupported = %d"), *pdwNumGuidsSupported);
+ if (pdwNumGuidsSupported) {
+ LOG(_T("[out] *pdwNumGuidsSupported = %d"), *pdwNumGuidsSupported);
- if (pGuidsSupported) {
- for (DWORD i = 0; i < *pdwNumGuidsSupported; i++) {
- LOG(_T("[out] pGuidsSupported[%d] = %s"), i, CStringFromGUID(pGuidsSupported[i]));
- }
- }
- }
+ if (pGuidsSupported) {
+ for (DWORD i = 0; i < *pdwNumGuidsSupported; i++) {
+ LOG(_T("[out] pGuidsSupported[%d] = %s"), i, CStringFromGUID(pGuidsSupported[i]));
+ }
+ }
+ }
- return hr;
+ return hr;
}
-static HRESULT STDMETHODCALLTYPE GetUncompFormatsSupportedMine(IAMVideoAcceleratorC * This, const GUID *pGuid, LPDWORD pdwNumFormatsSupported, LPDDPIXELFORMAT pFormatsSupported)
+static HRESULT STDMETHODCALLTYPE GetUncompFormatsSupportedMine(IAMVideoAcceleratorC* This, const GUID* pGuid, LPDWORD pdwNumFormatsSupported, LPDDPIXELFORMAT pFormatsSupported)
{
- LOG(_T("\nGetUncompFormatsSupported"));
+ LOG(_T("\nGetUncompFormatsSupported"));
- if (pGuid) {
- LOG(_T("[in] *pGuid = %s"), CStringFromGUID(*pGuid));
- }
+ if (pGuid) {
+ LOG(_T("[in] *pGuid = %s"), CStringFromGUID(*pGuid));
+ }
- if (pdwNumFormatsSupported) {
- LOG(_T("[in] *pdwNumFormatsSupported = %d"), *pdwNumFormatsSupported);
- }
+ if (pdwNumFormatsSupported) {
+ LOG(_T("[in] *pdwNumFormatsSupported = %d"), *pdwNumFormatsSupported);
+ }
- HRESULT hr = GetUncompFormatsSupportedOrg(This, pGuid, pdwNumFormatsSupported, pFormatsSupported);
+ HRESULT hr = GetUncompFormatsSupportedOrg(This, pGuid, pdwNumFormatsSupported, pFormatsSupported);
- LOG(_T("hr = %08x"), hr);
+ LOG(_T("hr = %08x"), hr);
- if (pdwNumFormatsSupported) {
- LOG(_T("[out] *pdwNumFormatsSupported = %d"), *pdwNumFormatsSupported);
+ if (pdwNumFormatsSupported) {
+ LOG(_T("[out] *pdwNumFormatsSupported = %d"), *pdwNumFormatsSupported);
- if (pFormatsSupported) {
- LOGPF(_T("[out] pFormatsSupported"), pFormatsSupported, *pdwNumFormatsSupported);
- }
- }
+ if (pFormatsSupported) {
+ LOGPF(_T("[out] pFormatsSupported"), pFormatsSupported, *pdwNumFormatsSupported);
+ }
+ }
- return hr;
+ return hr;
}
-static HRESULT STDMETHODCALLTYPE GetInternalMemInfoMine(IAMVideoAcceleratorC * This, const GUID *pGuid, const AMVAUncompDataInfo *pamvaUncompDataInfo, LPAMVAInternalMemInfo pamvaInternalMemInfo)
+static HRESULT STDMETHODCALLTYPE GetInternalMemInfoMine(IAMVideoAcceleratorC* This, const GUID* pGuid, const AMVAUncompDataInfo* pamvaUncompDataInfo, LPAMVAInternalMemInfo pamvaInternalMemInfo)
{
- LOG(_T("\nGetInternalMemInfo"));
+ LOG(_T("\nGetInternalMemInfo"));
- HRESULT hr = GetInternalMemInfoOrg(This, pGuid, pamvaUncompDataInfo, pamvaInternalMemInfo);
+ HRESULT hr = GetInternalMemInfoOrg(This, pGuid, pamvaUncompDataInfo, pamvaInternalMemInfo);
- LOG(_T("hr = %08x"), hr);
+ LOG(_T("hr = %08x"), hr);
- return hr;
+ return hr;
}
#endif
-static HRESULT STDMETHODCALLTYPE GetCompBufferInfoMine(IAMVideoAcceleratorC * This, const GUID *pGuid, const AMVAUncompDataInfo *pamvaUncompDataInfo, LPDWORD pdwNumTypesCompBuffers, LPAMVACompBufferInfo pamvaCompBufferInfo)
+static HRESULT STDMETHODCALLTYPE GetCompBufferInfoMine(IAMVideoAcceleratorC* This, const GUID* pGuid, const AMVAUncompDataInfo* pamvaUncompDataInfo, LPDWORD pdwNumTypesCompBuffers, LPAMVACompBufferInfo pamvaCompBufferInfo)
{
- LOG(_T("\nGetCompBufferInfo"));
+ LOG(_T("\nGetCompBufferInfo"));
- if (pGuid) {
- g_guidDXVADecoder = *pGuid;
- g_nDXVAVersion = 1;
+ if (pGuid) {
+ g_guidDXVADecoder = *pGuid;
+ g_nDXVAVersion = 1;
#ifdef _DEBUG
- LOG(_T("[in] *pGuid = %s"), CStringFromGUID(*pGuid));
+ LOG(_T("[in] *pGuid = %s"), CStringFromGUID(*pGuid));
- if (pdwNumTypesCompBuffers) {
- LOG(_T("[in] *pdwNumTypesCompBuffers = %d"), *pdwNumTypesCompBuffers);
- }
+ if (pdwNumTypesCompBuffers) {
+ LOG(_T("[in] *pdwNumTypesCompBuffers = %d"), *pdwNumTypesCompBuffers);
+ }
#endif
- }
+ }
- HRESULT hr = GetCompBufferInfoOrg(This, pGuid, pamvaUncompDataInfo, pdwNumTypesCompBuffers, pamvaCompBufferInfo);
+ HRESULT hr = GetCompBufferInfoOrg(This, pGuid, pamvaUncompDataInfo, pdwNumTypesCompBuffers, pamvaCompBufferInfo);
- LOG(_T("hr = %08x"), hr);
+ LOG(_T("hr = %08x"), hr);
- //if (pdwNumTypesCompBuffers)
- //{
- // LOG(_T("[out] *pdwNumTypesCompBuffers = %d"), *pdwNumTypesCompBuffers);
+ //if (pdwNumTypesCompBuffers)
+ //{
+ // LOG(_T("[out] *pdwNumTypesCompBuffers = %d"), *pdwNumTypesCompBuffers);
- // if (pamvaUncompDataInfo)
- // {
- // LOGUDI(_T("[out] pamvaUncompDataInfo"), pamvaUncompDataInfo, *pdwNumTypesCompBuffers);
- // }
- //}
+ // if (pamvaUncompDataInfo)
+ // {
+ // LOGUDI(_T("[out] pamvaUncompDataInfo"), pamvaUncompDataInfo, *pdwNumTypesCompBuffers);
+ // }
+ //}
- return hr;
+ return hr;
}
#ifdef _DEBUG
-static HRESULT STDMETHODCALLTYPE GetInternalCompBufferInfoMine(IAMVideoAcceleratorC * This, LPDWORD pdwNumTypesCompBuffers, LPAMVACompBufferInfo pamvaCompBufferInfo)
+static HRESULT STDMETHODCALLTYPE GetInternalCompBufferInfoMine(IAMVideoAcceleratorC* This, LPDWORD pdwNumTypesCompBuffers, LPAMVACompBufferInfo pamvaCompBufferInfo)
{
- LOG(_T("\nGetInternalCompBufferInfo"));
+ LOG(_T("\nGetInternalCompBufferInfo"));
- HRESULT hr = GetInternalCompBufferInfoOrg(This, pdwNumTypesCompBuffers, pamvaCompBufferInfo);
+ HRESULT hr = GetInternalCompBufferInfoOrg(This, pdwNumTypesCompBuffers, pamvaCompBufferInfo);
- LOG(_T("hr = %08x"), hr);
+ LOG(_T("hr = %08x"), hr);
- return hr;
+ return hr;
}
-static HRESULT STDMETHODCALLTYPE BeginFrameMine(IAMVideoAcceleratorC * This, const AMVABeginFrameInfo *amvaBeginFrameInfo)
+static HRESULT STDMETHODCALLTYPE BeginFrameMine(IAMVideoAcceleratorC* This, const AMVABeginFrameInfo* amvaBeginFrameInfo)
{
- LOG(_T("\nBeginFrame"));
+ LOG(_T("\nBeginFrame"));
- if (amvaBeginFrameInfo) {
- LOG(_T("[in] amvaBeginFrameInfo->dwDestSurfaceIndex = %08x"), amvaBeginFrameInfo->dwDestSurfaceIndex);
- LOG(_T("[in] amvaBeginFrameInfo->pInputData = %08x"), amvaBeginFrameInfo->pInputData);
- LOG(_T("[in] amvaBeginFrameInfo->dwSizeInputData = %08x"), amvaBeginFrameInfo->dwSizeInputData);
- LOG(_T("[in] amvaBeginFrameInfo->pOutputData = %08x"), amvaBeginFrameInfo->pOutputData);
- LOG(_T("[in] amvaBeginFrameInfo->dwSizeOutputData = %08x"), amvaBeginFrameInfo->dwSizeOutputData);
- }
- if (amvaBeginFrameInfo && (amvaBeginFrameInfo->dwSizeInputData == 4)) {
- LOG(_T("[in] amvaBeginFrameInfo->pInputData => dwDestSurfaceIndex = %ld "),
- ((DWORD*)amvaBeginFrameInfo->pInputData)[0]);
- }
+ if (amvaBeginFrameInfo) {
+ LOG(_T("[in] amvaBeginFrameInfo->dwDestSurfaceIndex = %08x"), amvaBeginFrameInfo->dwDestSurfaceIndex);
+ LOG(_T("[in] amvaBeginFrameInfo->pInputData = %08x"), amvaBeginFrameInfo->pInputData);
+ LOG(_T("[in] amvaBeginFrameInfo->dwSizeInputData = %08x"), amvaBeginFrameInfo->dwSizeInputData);
+ LOG(_T("[in] amvaBeginFrameInfo->pOutputData = %08x"), amvaBeginFrameInfo->pOutputData);
+ LOG(_T("[in] amvaBeginFrameInfo->dwSizeOutputData = %08x"), amvaBeginFrameInfo->dwSizeOutputData);
+ }
+ if (amvaBeginFrameInfo && (amvaBeginFrameInfo->dwSizeInputData == 4)) {
+ LOG(_T("[in] amvaBeginFrameInfo->pInputData => dwDestSurfaceIndex = %ld "),
+ ((DWORD*)amvaBeginFrameInfo->pInputData)[0]);
+ }
- HRESULT hr = BeginFrameOrg(This, amvaBeginFrameInfo);
+ HRESULT hr = BeginFrameOrg(This, amvaBeginFrameInfo);
- LOG(_T("hr = %08x"), hr);
+ LOG(_T("hr = %08x"), hr);
- return hr;
+ return hr;
}
-static HRESULT STDMETHODCALLTYPE EndFrameMine(IAMVideoAcceleratorC * This, const AMVAEndFrameInfo *pEndFrameInfo)
+static HRESULT STDMETHODCALLTYPE EndFrameMine(IAMVideoAcceleratorC* This, const AMVAEndFrameInfo* pEndFrameInfo)
{
- LOG(_T("\nEndFrame"));
+ LOG(_T("\nEndFrame"));
- if (pEndFrameInfo) {
- LOG(_T("[in] pEndFrameInfo->dwSizeMiscData = %08x"), pEndFrameInfo->dwSizeMiscData);
- LOG(_T("[in] pEndFrameInfo->pMiscData = %08x"), pEndFrameInfo->pMiscData);
+ if (pEndFrameInfo) {
+ LOG(_T("[in] pEndFrameInfo->dwSizeMiscData = %08x"), pEndFrameInfo->dwSizeMiscData);
+ LOG(_T("[in] pEndFrameInfo->pMiscData = %08x"), pEndFrameInfo->pMiscData);
- if (pEndFrameInfo->dwSizeMiscData >= 4)
- LOG(_T("[out] pEndFrameInfo->pMiscData = %02x %02x %02x %02x "),
- ((BYTE*)pEndFrameInfo->pMiscData)[0],
- ((BYTE*)pEndFrameInfo->pMiscData)[1],
- ((BYTE*)pEndFrameInfo->pMiscData)[2],
- ((BYTE*)pEndFrameInfo->pMiscData)[3]);
+ if (pEndFrameInfo->dwSizeMiscData >= 4)
+ LOG(_T("[out] pEndFrameInfo->pMiscData = %02x %02x %02x %02x "),
+ ((BYTE*)pEndFrameInfo->pMiscData)[0],
+ ((BYTE*)pEndFrameInfo->pMiscData)[1],
+ ((BYTE*)pEndFrameInfo->pMiscData)[2],
+ ((BYTE*)pEndFrameInfo->pMiscData)[3]);
- }
+ }
- HRESULT hr = EndFrameOrg(This, pEndFrameInfo);
+ HRESULT hr = EndFrameOrg(This, pEndFrameInfo);
- LOG(_T("hr = %08x"), hr);
+ LOG(_T("hr = %08x"), hr);
- return hr;
+ return hr;
}
-static HRESULT STDMETHODCALLTYPE GetBufferMine(IAMVideoAcceleratorC * This, DWORD dwTypeIndex, DWORD dwBufferIndex, BOOL bReadOnly, LPVOID *ppBuffer, LONG *lpStride)
+static HRESULT STDMETHODCALLTYPE GetBufferMine(IAMVideoAcceleratorC* This, DWORD dwTypeIndex, DWORD dwBufferIndex, BOOL bReadOnly, LPVOID* ppBuffer, LONG* lpStride)
{
- HRESULT hr = GetBufferOrg(This, dwTypeIndex, dwBufferIndex, bReadOnly, ppBuffer, lpStride);
+ HRESULT hr = GetBufferOrg(This, dwTypeIndex, dwBufferIndex, bReadOnly, ppBuffer, lpStride);
- LOG(_T("\nGetBuffer"));
+ LOG(_T("\nGetBuffer"));
- LOG(_T("[in] dwTypeIndex = %08x"), dwTypeIndex);
- LOG(_T("[in] dwBufferIndex = %08x"), dwBufferIndex);
- LOG(_T("[in] bReadOnly = %08x"), bReadOnly);
- LOG(_T("[in] ppBuffer = %08x"), ppBuffer);
- LOG(_T("[out] *lpStride = %08x"), *lpStride);
- LOG(_T("hr = %08x"), hr);
+ LOG(_T("[in] dwTypeIndex = %08x"), dwTypeIndex);
+ LOG(_T("[in] dwBufferIndex = %08x"), dwBufferIndex);
+ LOG(_T("[in] bReadOnly = %08x"), bReadOnly);
+ LOG(_T("[in] ppBuffer = %08x"), ppBuffer);
+ LOG(_T("[out] *lpStride = %08x"), *lpStride);
+ LOG(_T("hr = %08x"), hr);
- g_ppBuffer [dwTypeIndex] = (BYTE*)*ppBuffer;
- //LOG(_T("[out] *ppBuffer = %02x %02x %02x %02x ..."), ((BYTE*)*ppBuffer)[0], ((BYTE*)*ppBuffer)[1], ((BYTE*)*ppBuffer)[2], ((BYTE*)*ppBuffer)[3]);
+ g_ppBuffer [dwTypeIndex] = (BYTE*)*ppBuffer;
+ //LOG(_T("[out] *ppBuffer = %02x %02x %02x %02x ..."), ((BYTE*)*ppBuffer)[0], ((BYTE*)*ppBuffer)[1], ((BYTE*)*ppBuffer)[2], ((BYTE*)*ppBuffer)[3]);
- return hr;
+ return hr;
}
-static HRESULT STDMETHODCALLTYPE ReleaseBufferMine(IAMVideoAcceleratorC * This, DWORD dwTypeIndex, DWORD dwBufferIndex)
+static HRESULT STDMETHODCALLTYPE ReleaseBufferMine(IAMVideoAcceleratorC* This, DWORD dwTypeIndex, DWORD dwBufferIndex)
{
- LOG(_T("\nReleaseBuffer"));
+ LOG(_T("\nReleaseBuffer"));
- LOG(_T("[in] dwTypeIndex = %08x"), dwTypeIndex);
- LOG(_T("[in] dwBufferIndex = %08x"), dwBufferIndex);
+ LOG(_T("[in] dwTypeIndex = %08x"), dwTypeIndex);
+ LOG(_T("[in] dwBufferIndex = %08x"), dwBufferIndex);
- HRESULT hr = ReleaseBufferOrg(This, dwTypeIndex, dwBufferIndex);
+ HRESULT hr = ReleaseBufferOrg(This, dwTypeIndex, dwBufferIndex);
- LOG(_T("hr = %08x"), hr);
+ LOG(_T("hr = %08x"), hr);
- return hr;
+ return hr;
}
static HRESULT STDMETHODCALLTYPE ExecuteMine(IAMVideoAcceleratorC* This, DWORD dwFunction, LPVOID lpPrivateInputData, DWORD cbPrivateInputData,
- LPVOID lpPrivateOutputData, DWORD cbPrivateOutputData, DWORD dwNumBuffers, const AMVABUFFERINFO *pamvaBufferInfo)
+ LPVOID lpPrivateOutputData, DWORD cbPrivateOutputData, DWORD dwNumBuffers, const AMVABUFFERINFO* pamvaBufferInfo)
{
#ifdef _DEBUG
- LOG(_T("\nExecute"));
- LOG(_T("[in] dwFunction = %08x"), dwFunction);
- if (lpPrivateInputData) {
- if (dwFunction == 0x01000000) {
- DXVA_BufferDescription* pBuffDesc = (DXVA_BufferDescription*)lpPrivateInputData;
-
- for (DWORD i=0; i<dwNumBuffers; i++) {
- LOG(_T("[in] lpPrivateInputData, buffer description %d"), i);
- LOG(_T(" pBuffDesc->dwTypeIndex = %d"), pBuffDesc[i].dwTypeIndex);
- LOG(_T(" pBuffDesc->dwBufferIndex = %d"), pBuffDesc[i].dwBufferIndex);
- LOG(_T(" pBuffDesc->dwDataOffset = %d"), pBuffDesc[i].dwDataOffset);
- LOG(_T(" pBuffDesc->dwDataSize = %d"), pBuffDesc[i].dwDataSize);
- LOG(_T(" pBuffDesc->dwFirstMBaddress = %d"), pBuffDesc[i].dwFirstMBaddress);
- LOG(_T(" pBuffDesc->dwHeight = %d"), pBuffDesc[i].dwHeight);
- LOG(_T(" pBuffDesc->dwStride = %d"), pBuffDesc[i].dwStride);
- LOG(_T(" pBuffDesc->dwWidth = %d"), pBuffDesc[i].dwWidth);
- LOG(_T(" pBuffDesc->dwNumMBsInBuffer = %d"), pBuffDesc[i].dwNumMBsInBuffer);
- LOG(_T(" pBuffDesc->dwReservedBits = %d"), pBuffDesc[i].dwReservedBits);
- }
- } else if ((dwFunction == 0xfffff101) || (dwFunction == 0xfffff501)) {
- DXVA_ConfigPictureDecode* ConfigRequested = (DXVA_ConfigPictureDecode*)lpPrivateInputData;
- LOG(_T("[in] lpPrivateInputData, config requested"));
- LOG(_T(" pBuffDesc->dwTypeIndex = %d"), ConfigRequested->bConfig4GroupedCoefs);
- LOG(_T(" ConfigRequested->bConfigBitstreamRaw = %d"), ConfigRequested->bConfigBitstreamRaw);
- LOG(_T(" ConfigRequested->bConfigHostInverseScan = %d"), ConfigRequested->bConfigHostInverseScan);
- LOG(_T(" ConfigRequested->bConfigIntraResidUnsigned = %d"), ConfigRequested->bConfigIntraResidUnsigned);
- LOG(_T(" ConfigRequested->bConfigMBcontrolRasterOrder = %d"), ConfigRequested->bConfigMBcontrolRasterOrder);
- LOG(_T(" ConfigRequested->bConfigResid8Subtraction = %d"), ConfigRequested->bConfigResid8Subtraction);
- LOG(_T(" ConfigRequested->bConfigResidDiffAccelerator = %d"), ConfigRequested->bConfigResidDiffAccelerator);
- LOG(_T(" ConfigRequested->bConfigResidDiffHost = %d"), ConfigRequested->bConfigResidDiffHost);
- LOG(_T(" ConfigRequested->bConfigSpatialHost8or9Clipping= %d"), ConfigRequested->bConfigSpatialHost8or9Clipping);
- LOG(_T(" ConfigRequested->bConfigSpatialResid8 = %d"), ConfigRequested->bConfigSpatialResid8);
- LOG(_T(" ConfigRequested->bConfigSpatialResidInterleaved= %d"), ConfigRequested->bConfigSpatialResidInterleaved);
- LOG(_T(" ConfigRequested->bConfigSpecificIDCT = %d"), ConfigRequested->bConfigSpecificIDCT);
- LOG(_T(" ConfigRequested->dwFunction = %d"), ConfigRequested->dwFunction);
- LOG(_T(" ConfigRequested->guidConfigBitstreamEncryption = %s"), CStringFromGUID (ConfigRequested->guidConfigBitstreamEncryption));
- LOG(_T(" ConfigRequested->guidConfigMBcontrolEncryption = %s"), CStringFromGUID (ConfigRequested->guidConfigMBcontrolEncryption));
- LOG(_T(" ConfigRequested->guidConfigResidDiffEncryption = %s"), CStringFromGUID (ConfigRequested->guidConfigResidDiffEncryption));
- } else
- LOG(_T("[in] lpPrivateInputData = %02x %02x %02x %02x ..."),
- ((BYTE*)lpPrivateInputData)[0],
- ((BYTE*)lpPrivateInputData)[1],
- ((BYTE*)lpPrivateInputData)[2],
- ((BYTE*)lpPrivateInputData)[3]);
- }
- LOG(_T("[in] cbPrivateInputData = %08x"), cbPrivateInputData);
- LOG(_T("[in] lpPrivateOutputData = %08x"), lpPrivateOutputData);
- LOG(_T("[in] cbPrivateOutputData = %08x"), cbPrivateOutputData);
- LOG(_T("[in] dwNumBuffers = %08x"), dwNumBuffers);
- if (pamvaBufferInfo) {
- for (DWORD i=0; i<dwNumBuffers; i++) {
- LOG(_T("[in] pamvaBufferInfo, buffer description %d"), i);
- LOG(_T("[in] pamvaBufferInfo->dwTypeIndex = %08x"), pamvaBufferInfo[i].dwTypeIndex);
- LOG(_T("[in] pamvaBufferInfo->dwBufferIndex = %08x"), pamvaBufferInfo[i].dwBufferIndex);
- LOG(_T("[in] pamvaBufferInfo->dwDataOffset = %08x"), pamvaBufferInfo[i].dwDataOffset);
- LOG(_T("[in] pamvaBufferInfo->dwDataSize = %08x"), pamvaBufferInfo[i].dwDataSize);
- }
- }
-
-
- for (DWORD i=0; i<dwNumBuffers; i++) {
- if (pamvaBufferInfo[i].dwTypeIndex == DXVA_PICTURE_DECODE_BUFFER) {
- if (g_guidDXVADecoder == DXVA2_ModeH264_E || g_guidDXVADecoder == DXVA_Intel_H264_ClearVideo) {
- LogDXVA_PicParams_H264 ((DXVA_PicParams_H264*)g_ppBuffer[pamvaBufferInfo[i].dwTypeIndex]);
- } else if (g_guidDXVADecoder == DXVA2_ModeVC1_D || g_guidDXVADecoder == DXVA_Intel_VC1_ClearVideo) {
- LogDXVA_PictureParameters((DXVA_PictureParameters*)g_ppBuffer[pamvaBufferInfo[i].dwTypeIndex]);
- }
- } else if (pamvaBufferInfo[i].dwTypeIndex == DXVA_SLICE_CONTROL_BUFFER && (pamvaBufferInfo[i].dwDataSize % sizeof(DXVA_Slice_H264_Short)) == 0) {
- for (WORD j=0; j<pamvaBufferInfo[i].dwDataSize / sizeof(DXVA_Slice_H264_Short); j++) {
- DXVA_Slice_H264_Short* pSlice = &(((DXVA_Slice_H264_Short*)g_ppBuffer[pamvaBufferInfo[i].dwTypeIndex])[j]);
- LOG(_T(" - BSNALunitDataLocation %d"), pSlice->BSNALunitDataLocation);
- LOG(_T(" - SliceBytesInBuffer %d"), pSlice->SliceBytesInBuffer);
- LOG(_T(" - wBadSliceChopping %d"), pSlice->wBadSliceChopping);
- }
- } else if (pamvaBufferInfo[i].dwTypeIndex == DXVA_BITSTREAM_DATA_BUFFER) {
-
- LogDXVA_Bitstream(g_ppBuffer[pamvaBufferInfo[i].dwTypeIndex], pamvaBufferInfo[i].dwDataSize);
+ LOG(_T("\nExecute"));
+ LOG(_T("[in] dwFunction = %08x"), dwFunction);
+ if (lpPrivateInputData) {
+ if (dwFunction == 0x01000000) {
+ DXVA_BufferDescription* pBuffDesc = (DXVA_BufferDescription*)lpPrivateInputData;
+
+ for (DWORD i = 0; i < dwNumBuffers; i++) {
+ LOG(_T("[in] lpPrivateInputData, buffer description %d"), i);
+ LOG(_T(" pBuffDesc->dwTypeIndex = %d"), pBuffDesc[i].dwTypeIndex);
+ LOG(_T(" pBuffDesc->dwBufferIndex = %d"), pBuffDesc[i].dwBufferIndex);
+ LOG(_T(" pBuffDesc->dwDataOffset = %d"), pBuffDesc[i].dwDataOffset);
+ LOG(_T(" pBuffDesc->dwDataSize = %d"), pBuffDesc[i].dwDataSize);
+ LOG(_T(" pBuffDesc->dwFirstMBaddress = %d"), pBuffDesc[i].dwFirstMBaddress);
+ LOG(_T(" pBuffDesc->dwHeight = %d"), pBuffDesc[i].dwHeight);
+ LOG(_T(" pBuffDesc->dwStride = %d"), pBuffDesc[i].dwStride);
+ LOG(_T(" pBuffDesc->dwWidth = %d"), pBuffDesc[i].dwWidth);
+ LOG(_T(" pBuffDesc->dwNumMBsInBuffer = %d"), pBuffDesc[i].dwNumMBsInBuffer);
+ LOG(_T(" pBuffDesc->dwReservedBits = %d"), pBuffDesc[i].dwReservedBits);
+ }
+ } else if ((dwFunction == 0xfffff101) || (dwFunction == 0xfffff501)) {
+ DXVA_ConfigPictureDecode* ConfigRequested = (DXVA_ConfigPictureDecode*)lpPrivateInputData;
+ LOG(_T("[in] lpPrivateInputData, config requested"));
+ LOG(_T(" pBuffDesc->dwTypeIndex = %d"), ConfigRequested->bConfig4GroupedCoefs);
+ LOG(_T(" ConfigRequested->bConfigBitstreamRaw = %d"), ConfigRequested->bConfigBitstreamRaw);
+ LOG(_T(" ConfigRequested->bConfigHostInverseScan = %d"), ConfigRequested->bConfigHostInverseScan);
+ LOG(_T(" ConfigRequested->bConfigIntraResidUnsigned = %d"), ConfigRequested->bConfigIntraResidUnsigned);
+ LOG(_T(" ConfigRequested->bConfigMBcontrolRasterOrder = %d"), ConfigRequested->bConfigMBcontrolRasterOrder);
+ LOG(_T(" ConfigRequested->bConfigResid8Subtraction = %d"), ConfigRequested->bConfigResid8Subtraction);
+ LOG(_T(" ConfigRequested->bConfigResidDiffAccelerator = %d"), ConfigRequested->bConfigResidDiffAccelerator);
+ LOG(_T(" ConfigRequested->bConfigResidDiffHost = %d"), ConfigRequested->bConfigResidDiffHost);
+ LOG(_T(" ConfigRequested->bConfigSpatialHost8or9Clipping= %d"), ConfigRequested->bConfigSpatialHost8or9Clipping);
+ LOG(_T(" ConfigRequested->bConfigSpatialResid8 = %d"), ConfigRequested->bConfigSpatialResid8);
+ LOG(_T(" ConfigRequested->bConfigSpatialResidInterleaved= %d"), ConfigRequested->bConfigSpatialResidInterleaved);
+ LOG(_T(" ConfigRequested->bConfigSpecificIDCT = %d"), ConfigRequested->bConfigSpecificIDCT);
+ LOG(_T(" ConfigRequested->dwFunction = %d"), ConfigRequested->dwFunction);
+ LOG(_T(" ConfigRequested->guidConfigBitstreamEncryption = %s"), CStringFromGUID(ConfigRequested->guidConfigBitstreamEncryption));
+ LOG(_T(" ConfigRequested->guidConfigMBcontrolEncryption = %s"), CStringFromGUID(ConfigRequested->guidConfigMBcontrolEncryption));
+ LOG(_T(" ConfigRequested->guidConfigResidDiffEncryption = %s"), CStringFromGUID(ConfigRequested->guidConfigResidDiffEncryption));
+ } else
+ LOG(_T("[in] lpPrivateInputData = %02x %02x %02x %02x ..."),
+ ((BYTE*)lpPrivateInputData)[0],
+ ((BYTE*)lpPrivateInputData)[1],
+ ((BYTE*)lpPrivateInputData)[2],
+ ((BYTE*)lpPrivateInputData)[3]);
+ }
+ LOG(_T("[in] cbPrivateInputData = %08x"), cbPrivateInputData);
+ LOG(_T("[in] lpPrivateOutputData = %08x"), lpPrivateOutputData);
+ LOG(_T("[in] cbPrivateOutputData = %08x"), cbPrivateOutputData);
+ LOG(_T("[in] dwNumBuffers = %08x"), dwNumBuffers);
+ if (pamvaBufferInfo) {
+ for (DWORD i = 0; i < dwNumBuffers; i++) {
+ LOG(_T("[in] pamvaBufferInfo, buffer description %d"), i);
+ LOG(_T("[in] pamvaBufferInfo->dwTypeIndex = %08x"), pamvaBufferInfo[i].dwTypeIndex);
+ LOG(_T("[in] pamvaBufferInfo->dwBufferIndex = %08x"), pamvaBufferInfo[i].dwBufferIndex);
+ LOG(_T("[in] pamvaBufferInfo->dwDataOffset = %08x"), pamvaBufferInfo[i].dwDataOffset);
+ LOG(_T("[in] pamvaBufferInfo->dwDataSize = %08x"), pamvaBufferInfo[i].dwDataSize);
+ }
+ }
+
+
+ for (DWORD i = 0; i < dwNumBuffers; i++) {
+ if (pamvaBufferInfo[i].dwTypeIndex == DXVA_PICTURE_DECODE_BUFFER) {
+ if (g_guidDXVADecoder == DXVA2_ModeH264_E || g_guidDXVADecoder == DXVA_Intel_H264_ClearVideo) {
+ LogDXVA_PicParams_H264((DXVA_PicParams_H264*)g_ppBuffer[pamvaBufferInfo[i].dwTypeIndex]);
+ } else if (g_guidDXVADecoder == DXVA2_ModeVC1_D || g_guidDXVADecoder == DXVA_Intel_VC1_ClearVideo) {
+ LogDXVA_PictureParameters((DXVA_PictureParameters*)g_ppBuffer[pamvaBufferInfo[i].dwTypeIndex]);
+ }
+ } else if (pamvaBufferInfo[i].dwTypeIndex == DXVA_SLICE_CONTROL_BUFFER && (pamvaBufferInfo[i].dwDataSize % sizeof(DXVA_Slice_H264_Short)) == 0) {
+ for (WORD j = 0; j < pamvaBufferInfo[i].dwDataSize / sizeof(DXVA_Slice_H264_Short); j++) {
+ DXVA_Slice_H264_Short* pSlice = &(((DXVA_Slice_H264_Short*)g_ppBuffer[pamvaBufferInfo[i].dwTypeIndex])[j]);
+ LOG(_T(" - BSNALunitDataLocation %d"), pSlice->BSNALunitDataLocation);
+ LOG(_T(" - SliceBytesInBuffer %d"), pSlice->SliceBytesInBuffer);
+ LOG(_T(" - wBadSliceChopping %d"), pSlice->wBadSliceChopping);
+ }
+ } else if (pamvaBufferInfo[i].dwTypeIndex == DXVA_BITSTREAM_DATA_BUFFER) {
+
+ LogDXVA_Bitstream(g_ppBuffer[pamvaBufferInfo[i].dwTypeIndex], pamvaBufferInfo[i].dwDataSize);
#if LOG_BITSTREAM
- char strFile[_MAX_PATH];
- static int nNb = 1;
- sprintf_s(strFile, "BitStream%d.bin", nNb++);
- FILE* hFile = fopen(strFile, "wb");
- if (hFile) {
- fwrite(g_ppBuffer[pamvaBufferInfo[i].dwTypeIndex],
- 1,
- pamvaBufferInfo[i].dwDataSize,
- hFile);
- fclose(hFile);
- }
+ char strFile[_MAX_PATH];
+ static int nNb = 1;
+ sprintf_s(strFile, "BitStream%d.bin", nNb++);
+ FILE* hFile = fopen(strFile, "wb");
+ if (hFile) {
+ fwrite(g_ppBuffer[pamvaBufferInfo[i].dwTypeIndex],
+ 1,
+ pamvaBufferInfo[i].dwDataSize,
+ hFile);
+ fclose(hFile);
+ }
#endif
- }
- }
+ }
+ }
#endif
- HRESULT hr = ExecuteOrg(This, dwFunction, lpPrivateInputData, cbPrivateInputData, lpPrivateOutputData, cbPrivateOutputData, dwNumBuffers, pamvaBufferInfo);
+ HRESULT hr = ExecuteOrg(This, dwFunction, lpPrivateInputData, cbPrivateInputData, lpPrivateOutputData, cbPrivateOutputData, dwNumBuffers, pamvaBufferInfo);
- LOG(_T("hr = %08x"), hr);
+ LOG(_T("hr = %08x"), hr);
- if (lpPrivateOutputData && (dwFunction == 0x01000000)) {
- LOG(_T("[out] *lpPrivateOutputData : Result = %08x"), ((DWORD*)lpPrivateOutputData)[0]);
- }
+ if (lpPrivateOutputData && (dwFunction == 0x01000000)) {
+ LOG(_T("[out] *lpPrivateOutputData : Result = %08x"), ((DWORD*)lpPrivateOutputData)[0]);
+ }
- return hr;
+ return hr;
}
-static HRESULT STDMETHODCALLTYPE QueryRenderStatusMine(IAMVideoAcceleratorC * This, DWORD dwTypeIndex, DWORD dwBufferIndex, DWORD dwFlags)
+static HRESULT STDMETHODCALLTYPE QueryRenderStatusMine(IAMVideoAcceleratorC* This, DWORD dwTypeIndex, DWORD dwBufferIndex, DWORD dwFlags)
{
- HRESULT hr = QueryRenderStatusOrg(This, dwTypeIndex, dwBufferIndex, dwFlags);
- LOG(_T("\nQueryRenderStatus Type=%d Index=%d hr = %08x"), dwTypeIndex, dwBufferIndex, hr);
+ HRESULT hr = QueryRenderStatusOrg(This, dwTypeIndex, dwBufferIndex, dwFlags);
+ LOG(_T("\nQueryRenderStatus Type=%d Index=%d hr = %08x"), dwTypeIndex, dwBufferIndex, hr);
- return hr;
+ return hr;
}
-static HRESULT STDMETHODCALLTYPE DisplayFrameMine(IAMVideoAcceleratorC * This, DWORD dwFlipToIndex, IMediaSample *pMediaSample)
+static HRESULT STDMETHODCALLTYPE DisplayFrameMine(IAMVideoAcceleratorC* This, DWORD dwFlipToIndex, IMediaSample* pMediaSample)
{
- LOG(_T("\nEnter DisplayFrame : %d"), dwFlipToIndex);
+ LOG(_T("\nEnter DisplayFrame : %d"), dwFlipToIndex);
- HRESULT hr = DisplayFrameOrg(This, dwFlipToIndex, pMediaSample);
+ HRESULT hr = DisplayFrameOrg(This, dwFlipToIndex, pMediaSample);
- LOG(_T("Leave DisplayFrame : hr = %08x"), hr);
+ LOG(_T("Leave DisplayFrame : hr = %08x"), hr);
- return hr;
+ return hr;
}
#endif
void HookAMVideoAccelerator(IAMVideoAcceleratorC* pAMVideoAcceleratorC)
{
- g_guidDXVADecoder = GUID_NULL;
- g_nDXVAVersion = 0;
+ g_guidDXVADecoder = GUID_NULL;
+ g_nDXVAVersion = 0;
- BOOL res;
- DWORD flOldProtect = 0;
- res = VirtualProtect(pAMVideoAcceleratorC->lpVtbl, sizeof(IAMVideoAcceleratorC), PAGE_WRITECOPY, &flOldProtect);
+ BOOL res;
+ DWORD flOldProtect = 0;
+ res = VirtualProtect(pAMVideoAcceleratorC->lpVtbl, sizeof(IAMVideoAcceleratorC), PAGE_WRITECOPY, &flOldProtect);
#ifdef _DEBUG
- if (GetVideoAcceleratorGUIDsOrg == NULL) {
- GetVideoAcceleratorGUIDsOrg = pAMVideoAcceleratorC->lpVtbl->GetVideoAcceleratorGUIDs;
- }
- if (GetUncompFormatsSupportedOrg == NULL) {
- GetUncompFormatsSupportedOrg = pAMVideoAcceleratorC->lpVtbl->GetUncompFormatsSupported;
- }
- if (GetInternalMemInfoOrg == NULL) {
- GetInternalMemInfoOrg = pAMVideoAcceleratorC->lpVtbl->GetInternalMemInfo;
- }
+ if (GetVideoAcceleratorGUIDsOrg == NULL) {
+ GetVideoAcceleratorGUIDsOrg = pAMVideoAcceleratorC->lpVtbl->GetVideoAcceleratorGUIDs;
+ }
+ if (GetUncompFormatsSupportedOrg == NULL) {
+ GetUncompFormatsSupportedOrg = pAMVideoAcceleratorC->lpVtbl->GetUncompFormatsSupported;
+ }
+ if (GetInternalMemInfoOrg == NULL) {
+ GetInternalMemInfoOrg = pAMVideoAcceleratorC->lpVtbl->GetInternalMemInfo;
+ }
#endif
- if (GetCompBufferInfoOrg == NULL) {
- GetCompBufferInfoOrg = pAMVideoAcceleratorC->lpVtbl->GetCompBufferInfo;
- }
+ if (GetCompBufferInfoOrg == NULL) {
+ GetCompBufferInfoOrg = pAMVideoAcceleratorC->lpVtbl->GetCompBufferInfo;
+ }
#ifdef _DEBUG
- if (GetInternalCompBufferInfoOrg == NULL) {
- GetInternalCompBufferInfoOrg = pAMVideoAcceleratorC->lpVtbl->GetInternalCompBufferInfo;
- }
- if (BeginFrameOrg == NULL) {
- BeginFrameOrg = pAMVideoAcceleratorC->lpVtbl->BeginFrame;
- }
- if (EndFrameOrg == NULL) {
- EndFrameOrg = pAMVideoAcceleratorC->lpVtbl->EndFrame;
- }
- if (GetBufferOrg == NULL) {
- GetBufferOrg = pAMVideoAcceleratorC->lpVtbl->GetBuffer;
- }
- if (ReleaseBufferOrg == NULL) {
- ReleaseBufferOrg = pAMVideoAcceleratorC->lpVtbl->ReleaseBuffer;
- }
- if (ExecuteOrg == NULL) {
- ExecuteOrg = pAMVideoAcceleratorC->lpVtbl->Execute;
- }
- if (QueryRenderStatusOrg == NULL) {
- QueryRenderStatusOrg = pAMVideoAcceleratorC->lpVtbl->QueryRenderStatus;
- }
- if (DisplayFrameOrg == NULL) {
- DisplayFrameOrg = pAMVideoAcceleratorC->lpVtbl->DisplayFrame;
- }
-
- pAMVideoAcceleratorC->lpVtbl->GetVideoAcceleratorGUIDs = GetVideoAcceleratorGUIDsMine;
- pAMVideoAcceleratorC->lpVtbl->GetUncompFormatsSupported = GetUncompFormatsSupportedMine;
- pAMVideoAcceleratorC->lpVtbl->GetInternalMemInfo = GetInternalMemInfoMine;
+ if (GetInternalCompBufferInfoOrg == NULL) {
+ GetInternalCompBufferInfoOrg = pAMVideoAcceleratorC->lpVtbl->GetInternalCompBufferInfo;
+ }
+ if (BeginFrameOrg == NULL) {
+ BeginFrameOrg = pAMVideoAcceleratorC->lpVtbl->BeginFrame;
+ }
+ if (EndFrameOrg == NULL) {
+ EndFrameOrg = pAMVideoAcceleratorC->lpVtbl->EndFrame;
+ }
+ if (GetBufferOrg == NULL) {
+ GetBufferOrg = pAMVideoAcceleratorC->lpVtbl->GetBuffer;
+ }
+ if (ReleaseBufferOrg == NULL) {
+ ReleaseBufferOrg = pAMVideoAcceleratorC->lpVtbl->ReleaseBuffer;
+ }
+ if (ExecuteOrg == NULL) {
+ ExecuteOrg = pAMVideoAcceleratorC->lpVtbl->Execute;
+ }
+ if (QueryRenderStatusOrg == NULL) {
+ QueryRenderStatusOrg = pAMVideoAcceleratorC->lpVtbl->QueryRenderStatus;
+ }
+ if (DisplayFrameOrg == NULL) {
+ DisplayFrameOrg = pAMVideoAcceleratorC->lpVtbl->DisplayFrame;
+ }
+
+ pAMVideoAcceleratorC->lpVtbl->GetVideoAcceleratorGUIDs = GetVideoAcceleratorGUIDsMine;
+ pAMVideoAcceleratorC->lpVtbl->GetUncompFormatsSupported = GetUncompFormatsSupportedMine;
+ pAMVideoAcceleratorC->lpVtbl->GetInternalMemInfo = GetInternalMemInfoMine;
#endif
- pAMVideoAcceleratorC->lpVtbl->GetCompBufferInfo = GetCompBufferInfoMine; // Function sets global variable(s)
+ pAMVideoAcceleratorC->lpVtbl->GetCompBufferInfo = GetCompBufferInfoMine; // Function sets global variable(s)
#ifdef _DEBUG
- pAMVideoAcceleratorC->lpVtbl->GetInternalCompBufferInfo = GetInternalCompBufferInfoMine;
- pAMVideoAcceleratorC->lpVtbl->BeginFrame = BeginFrameMine;
- pAMVideoAcceleratorC->lpVtbl->EndFrame = EndFrameMine;
- pAMVideoAcceleratorC->lpVtbl->GetBuffer = GetBufferMine;
- pAMVideoAcceleratorC->lpVtbl->ReleaseBuffer = ReleaseBufferMine;
- pAMVideoAcceleratorC->lpVtbl->Execute = ExecuteMine;
- pAMVideoAcceleratorC->lpVtbl->QueryRenderStatus = QueryRenderStatusMine;
- pAMVideoAcceleratorC->lpVtbl->DisplayFrame = DisplayFrameMine;
+ pAMVideoAcceleratorC->lpVtbl->GetInternalCompBufferInfo = GetInternalCompBufferInfoMine;
+ pAMVideoAcceleratorC->lpVtbl->BeginFrame = BeginFrameMine;
+ pAMVideoAcceleratorC->lpVtbl->EndFrame = EndFrameMine;
+ pAMVideoAcceleratorC->lpVtbl->GetBuffer = GetBufferMine;
+ pAMVideoAcceleratorC->lpVtbl->ReleaseBuffer = ReleaseBufferMine;
+ pAMVideoAcceleratorC->lpVtbl->Execute = ExecuteMine;
+ pAMVideoAcceleratorC->lpVtbl->QueryRenderStatus = QueryRenderStatusMine;
+ pAMVideoAcceleratorC->lpVtbl->DisplayFrame = DisplayFrameMine;
- res = VirtualProtect(pAMVideoAcceleratorC->lpVtbl, sizeof(IAMVideoAcceleratorC), PAGE_EXECUTE, &flOldProtect);
+ res = VirtualProtect(pAMVideoAcceleratorC->lpVtbl, sizeof(IAMVideoAcceleratorC), PAGE_EXECUTE, &flOldProtect);
#if DXVA_LOGFILE_A
- ::DeleteFile (LOG_FILE_DXVA);
- ::DeleteFile (LOG_FILE_PICTURE);
- ::DeleteFile (LOG_FILE_SLICELONG);
- ::DeleteFile (LOG_FILE_SLICESHORT);
- ::DeleteFile (LOG_FILE_BITSTREAM);
+ ::DeleteFile(LOG_FILE_DXVA);
+ ::DeleteFile(LOG_FILE_PICTURE);
+ ::DeleteFile(LOG_FILE_SLICELONG);
+ ::DeleteFile(LOG_FILE_SLICESHORT);
+ ::DeleteFile(LOG_FILE_BITSTREAM);
#endif
#endif
}
@@ -1075,186 +1075,184 @@ void HookAMVideoAccelerator(IAMVideoAcceleratorC* pAMVideoAcceleratorC)
#ifdef _DEBUG
static void LogDecodeBufferDesc(DXVA2_DecodeBufferDesc* pDecodeBuff)
{
- LOG(_T("DecodeBufferDesc type : %d Size=%d NumMBsInBuffer=%d"), pDecodeBuff->CompressedBufferType, pDecodeBuff->DataSize, pDecodeBuff->NumMBsInBuffer);
- //LOG(_T(" - BufferIndex %d"), pDecodeBuff->BufferIndex);
- //LOG(_T(" - DataOffset %d"), pDecodeBuff->DataOffset);
- //LOG(_T(" - DataSize %d"), pDecodeBuff->DataSize);
- //LOG(_T(" - FirstMBaddress %d"), pDecodeBuff->FirstMBaddress);
- //LOG(_T(" - NumMBsInBuffer %d"), pDecodeBuff->NumMBsInBuffer);
- //LOG(_T(" - Width %d"), pDecodeBuff->Width);
- //LOG(_T(" - Height %d"), pDecodeBuff->Height);
- //LOG(_T(" - Stride %d"), pDecodeBuff->Stride);
- //LOG(_T(" - ReservedBits %d"), pDecodeBuff->ReservedBits);
- //LOG(_T(" - pvPVPState %d"), pDecodeBuff->pvPVPState);
+ LOG(_T("DecodeBufferDesc type : %d Size=%d NumMBsInBuffer=%d"), pDecodeBuff->CompressedBufferType, pDecodeBuff->DataSize, pDecodeBuff->NumMBsInBuffer);
+ //LOG(_T(" - BufferIndex %d"), pDecodeBuff->BufferIndex);
+ //LOG(_T(" - DataOffset %d"), pDecodeBuff->DataOffset);
+ //LOG(_T(" - DataSize %d"), pDecodeBuff->DataSize);
+ //LOG(_T(" - FirstMBaddress %d"), pDecodeBuff->FirstMBaddress);
+ //LOG(_T(" - NumMBsInBuffer %d"), pDecodeBuff->NumMBsInBuffer);
+ //LOG(_T(" - Width %d"), pDecodeBuff->Width);
+ //LOG(_T(" - Height %d"), pDecodeBuff->Height);
+ //LOG(_T(" - Stride %d"), pDecodeBuff->Stride);
+ //LOG(_T(" - ReservedBits %d"), pDecodeBuff->ReservedBits);
+ //LOG(_T(" - pvPVPState %d"), pDecodeBuff->pvPVPState);
}
class CFakeDirectXVideoDecoder : public CUnknown, public IDirectXVideoDecoder
{
private :
- CComPtr<IDirectXVideoDecoder> m_pDec;
- BYTE* m_ppBuffer[MAX_BUFFER_TYPE];
- UINT m_ppBufferLen[MAX_BUFFER_TYPE];
+ CComPtr<IDirectXVideoDecoder> m_pDec;
+ BYTE* m_ppBuffer[MAX_BUFFER_TYPE];
+ UINT m_ppBufferLen[MAX_BUFFER_TYPE];
public :
- CFakeDirectXVideoDecoder(LPUNKNOWN pUnk, IDirectXVideoDecoder* pDec) : CUnknown(_T("Fake DXVA2 Dec"), pUnk) {
- m_pDec.Attach (pDec);
- memset (m_ppBuffer, 0, sizeof(m_ppBuffer));
- }
-
- ~CFakeDirectXVideoDecoder() {
- LOG(_T("CFakeDirectXVideoDecoder destroyed !\n"));
- }
-
- DECLARE_IUNKNOWN;
-
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
- if (riid == __uuidof(IDirectXVideoDecoder)) {
- return GetInterface((IDirectXVideoDecoder*)this, ppv);
- } else {
- return __super::NonDelegatingQueryInterface(riid, ppv);
- }
- }
-
- virtual HRESULT STDMETHODCALLTYPE GetVideoDecoderService(IDirectXVideoDecoderService **ppService) {
- HRESULT hr = m_pDec->GetVideoDecoderService (ppService);
- LOG(_T("IDirectXVideoDecoder::GetVideoDecoderService hr = %08x\n"), hr);
- return hr;
- }
-
- virtual HRESULT STDMETHODCALLTYPE GetCreationParameters(GUID *pDeviceGuid, DXVA2_VideoDesc *pVideoDesc, DXVA2_ConfigPictureDecode *pConfig, IDirect3DSurface9 ***pDecoderRenderTargets, UINT *pNumSurfaces) {
- HRESULT hr = m_pDec->GetCreationParameters(pDeviceGuid, pVideoDesc, pConfig, pDecoderRenderTargets, pNumSurfaces);
- LOG(_T("IDirectXVideoDecoder::GetCreationParameters hr = %08x\n"), hr);
- return hr;
- }
-
-
- virtual HRESULT STDMETHODCALLTYPE GetBuffer(UINT BufferType, void **ppBuffer, UINT *pBufferSize) {
- HRESULT hr = m_pDec->GetBuffer(BufferType, ppBuffer, pBufferSize);
-
- if (BufferType < MAX_BUFFER_TYPE) {
- m_ppBuffer[BufferType] = (BYTE*)*ppBuffer;
- m_ppBufferLen[BufferType] = *pBufferSize;
- }
- // LOG(_T("IDirectXVideoDecoder::GetBuffer Type = %d, hr = %08x"), BufferType, hr);
-
- return hr;
- }
-
- virtual HRESULT STDMETHODCALLTYPE ReleaseBuffer(UINT BufferType) {
- HRESULT hr = m_pDec->ReleaseBuffer (BufferType);
- // LOG(_T("IDirectXVideoDecoder::ReleaseBuffer Type = %d, hr = %08x"), BufferType, hr);
- return hr;
- }
-
- virtual HRESULT STDMETHODCALLTYPE BeginFrame(IDirect3DSurface9 *pRenderTarget, void *pvPVPData) {
- HRESULT hr = m_pDec->BeginFrame (pRenderTarget, pvPVPData);
- LOG(_T("IDirectXVideoDecoder::BeginFrame pRenderTarget = %08x, hr = %08x"), pRenderTarget, hr);
- return hr;
- }
-
- virtual HRESULT STDMETHODCALLTYPE EndFrame(HANDLE *pHandleComplete) {
- HRESULT hr = m_pDec->EndFrame (pHandleComplete);
- LOG(_T("IDirectXVideoDecoder::EndFrame Handle=0x%08x hr = %08x\n"), pHandleComplete, hr);
- return hr;
- }
-
- virtual HRESULT STDMETHODCALLTYPE Execute(const DXVA2_DecodeExecuteParams *pExecuteParams) {
+ CFakeDirectXVideoDecoder(LPUNKNOWN pUnk, IDirectXVideoDecoder* pDec) : CUnknown(_T("Fake DXVA2 Dec"), pUnk) {
+ m_pDec.Attach(pDec);
+ memset(m_ppBuffer, 0, sizeof(m_ppBuffer));
+ }
+
+ ~CFakeDirectXVideoDecoder() {
+ LOG(_T("CFakeDirectXVideoDecoder destroyed !\n"));
+ }
+
+ DECLARE_IUNKNOWN;
+
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
+ if (riid == __uuidof(IDirectXVideoDecoder)) {
+ return GetInterface((IDirectXVideoDecoder*)this, ppv);
+ } else {
+ return __super::NonDelegatingQueryInterface(riid, ppv);
+ }
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE GetVideoDecoderService(IDirectXVideoDecoderService** ppService) {
+ HRESULT hr = m_pDec->GetVideoDecoderService(ppService);
+ LOG(_T("IDirectXVideoDecoder::GetVideoDecoderService hr = %08x\n"), hr);
+ return hr;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE GetCreationParameters(GUID* pDeviceGuid, DXVA2_VideoDesc* pVideoDesc, DXVA2_ConfigPictureDecode* pConfig, IDirect3DSurface9** *pDecoderRenderTargets, UINT* pNumSurfaces) {
+ HRESULT hr = m_pDec->GetCreationParameters(pDeviceGuid, pVideoDesc, pConfig, pDecoderRenderTargets, pNumSurfaces);
+ LOG(_T("IDirectXVideoDecoder::GetCreationParameters hr = %08x\n"), hr);
+ return hr;
+ }
+
+
+ virtual HRESULT STDMETHODCALLTYPE GetBuffer(UINT BufferType, void** ppBuffer, UINT* pBufferSize) {
+ HRESULT hr = m_pDec->GetBuffer(BufferType, ppBuffer, pBufferSize);
+
+ if (BufferType < MAX_BUFFER_TYPE) {
+ m_ppBuffer[BufferType] = (BYTE*)*ppBuffer;
+ m_ppBufferLen[BufferType] = *pBufferSize;
+ }
+ // LOG(_T("IDirectXVideoDecoder::GetBuffer Type = %d, hr = %08x"), BufferType, hr);
+
+ return hr;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE ReleaseBuffer(UINT BufferType) {
+ HRESULT hr = m_pDec->ReleaseBuffer(BufferType);
+ // LOG(_T("IDirectXVideoDecoder::ReleaseBuffer Type = %d, hr = %08x"), BufferType, hr);
+ return hr;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE BeginFrame(IDirect3DSurface9* pRenderTarget, void* pvPVPData) {
+ HRESULT hr = m_pDec->BeginFrame(pRenderTarget, pvPVPData);
+ LOG(_T("IDirectXVideoDecoder::BeginFrame pRenderTarget = %08x, hr = %08x"), pRenderTarget, hr);
+ return hr;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE EndFrame(HANDLE* pHandleComplete) {
+ HRESULT hr = m_pDec->EndFrame(pHandleComplete);
+ LOG(_T("IDirectXVideoDecoder::EndFrame Handle=0x%08x hr = %08x\n"), pHandleComplete, hr);
+ return hr;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE Execute(const DXVA2_DecodeExecuteParams* pExecuteParams) {
#if defined(_DEBUG) && DXVA_LOGFILE_A
- for (DWORD i=0; i<pExecuteParams->NumCompBuffers; i++) {
- CString strBuffer;
-
- LogDecodeBufferDesc (&pExecuteParams->pCompressedBuffers[i]);
- /*
- for (int j=0; j<4000 && j<pExecuteParams->pCompressedBuffers[i].DataSize; j++)
- strBuffer.AppendFormat (_T("%02x "), m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType][j]);
-
- LOG (_T(" - Buffer type=%d, offset=%d, size=%d"),
- pExecuteParams->pCompressedBuffers[i].CompressedBufferType,
- pExecuteParams->pCompressedBuffers[i].DataOffset,
- pExecuteParams->pCompressedBuffers[i].DataSize);
-
- LOG (strBuffer);*/
-
- if (pExecuteParams->pCompressedBuffers[i].CompressedBufferType == DXVA2_PictureParametersBufferType) {
- if (g_guidDXVADecoder == DXVA2_ModeH264_E || g_guidDXVADecoder == DXVA_Intel_H264_ClearVideo) {
- LogDXVA_PicParams_H264 ((DXVA_PicParams_H264*)m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType]);
- } else if (g_guidDXVADecoder == DXVA2_ModeVC1_D || g_guidDXVADecoder == DXVA2_ModeMPEG2_VLD || g_guidDXVADecoder == DXVA_Intel_VC1_ClearVideo) {
- LogDXVA_PictureParameters((DXVA_PictureParameters*)m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType]);
- }
- }
-
- if (g_guidDXVADecoder == DXVA2_ModeH264_E || g_guidDXVADecoder == DXVA_Intel_H264_ClearVideo) {
- if (pExecuteParams->pCompressedBuffers[i].CompressedBufferType == DXVA2_SliceControlBufferType) {
- if (pExecuteParams->pCompressedBuffers[i].DataSize % sizeof(DXVA_Slice_H264_Long) == 0) {
- DXVA_Slice_H264_Long* pSlice = (DXVA_Slice_H264_Long*)m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType];
- LogH264SliceLong (pSlice, pExecuteParams->pCompressedBuffers[i].DataSize / sizeof(DXVA_Slice_H264_Long));
- } else if (pExecuteParams->pCompressedBuffers[i].DataSize % sizeof(DXVA_Slice_H264_Short) == 0) {
- DXVA_Slice_H264_Short* pSlice = (DXVA_Slice_H264_Short*)m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType];
- LogH264SliceShort (pSlice, pExecuteParams->pCompressedBuffers[i].DataSize / sizeof(DXVA_Slice_H264_Short));
- }
- }
- } else if (g_guidDXVADecoder == DXVA2_ModeVC1_D || g_guidDXVADecoder == DXVA2_ModeMPEG2_VLD || g_guidDXVADecoder == DXVA_Intel_VC1_ClearVideo) {
- if (pExecuteParams->pCompressedBuffers[i].CompressedBufferType == DXVA2_SliceControlBufferType) {
- DXVA_SliceInfo* pSlice = (DXVA_SliceInfo*)m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType];
- LogSliceInfo (pSlice, pExecuteParams->pCompressedBuffers[i].DataSize / sizeof(DXVA_SliceInfo));
- }
- }
+ for (DWORD i = 0; i < pExecuteParams->NumCompBuffers; i++) {
+ CString strBuffer;
+
+ LogDecodeBufferDesc(&pExecuteParams->pCompressedBuffers[i]);
+ /*
+ for (int j=0; j<4000 && j<pExecuteParams->pCompressedBuffers[i].DataSize; j++)
+ strBuffer.AppendFormat (_T("%02x "), m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType][j]);
+
+ LOG (_T(" - Buffer type=%d, offset=%d, size=%d"),
+ pExecuteParams->pCompressedBuffers[i].CompressedBufferType,
+ pExecuteParams->pCompressedBuffers[i].DataOffset,
+ pExecuteParams->pCompressedBuffers[i].DataSize);
+
+ LOG (strBuffer);*/
+
+ if (pExecuteParams->pCompressedBuffers[i].CompressedBufferType == DXVA2_PictureParametersBufferType) {
+ if (g_guidDXVADecoder == DXVA2_ModeH264_E || g_guidDXVADecoder == DXVA_Intel_H264_ClearVideo) {
+ LogDXVA_PicParams_H264((DXVA_PicParams_H264*)m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType]);
+ } else if (g_guidDXVADecoder == DXVA2_ModeVC1_D || g_guidDXVADecoder == DXVA2_ModeMPEG2_VLD || g_guidDXVADecoder == DXVA_Intel_VC1_ClearVideo) {
+ LogDXVA_PictureParameters((DXVA_PictureParameters*)m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType]);
+ }
+ }
+
+ if (g_guidDXVADecoder == DXVA2_ModeH264_E || g_guidDXVADecoder == DXVA_Intel_H264_ClearVideo) {
+ if (pExecuteParams->pCompressedBuffers[i].CompressedBufferType == DXVA2_SliceControlBufferType) {
+ if (pExecuteParams->pCompressedBuffers[i].DataSize % sizeof(DXVA_Slice_H264_Long) == 0) {
+ DXVA_Slice_H264_Long* pSlice = (DXVA_Slice_H264_Long*)m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType];
+ LogH264SliceLong(pSlice, pExecuteParams->pCompressedBuffers[i].DataSize / sizeof(DXVA_Slice_H264_Long));
+ } else if (pExecuteParams->pCompressedBuffers[i].DataSize % sizeof(DXVA_Slice_H264_Short) == 0) {
+ DXVA_Slice_H264_Short* pSlice = (DXVA_Slice_H264_Short*)m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType];
+ LogH264SliceShort(pSlice, pExecuteParams->pCompressedBuffers[i].DataSize / sizeof(DXVA_Slice_H264_Short));
+ }
+ }
+ } else if (g_guidDXVADecoder == DXVA2_ModeVC1_D || g_guidDXVADecoder == DXVA2_ModeMPEG2_VLD || g_guidDXVADecoder == DXVA_Intel_VC1_ClearVideo) {
+ if (pExecuteParams->pCompressedBuffers[i].CompressedBufferType == DXVA2_SliceControlBufferType) {
+ DXVA_SliceInfo* pSlice = (DXVA_SliceInfo*)m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType];
+ LogSliceInfo(pSlice, pExecuteParams->pCompressedBuffers[i].DataSize / sizeof(DXVA_SliceInfo));
+ }
+ }
#if LOG_MATRIX
- if (pExecuteParams->pCompressedBuffers[i].CompressedBufferType == DXVA2_InverseQuantizationMatrixBufferType) {
- char strFile[_MAX_PATH];
- static int nNb = 1;
- sprintf_s(strFile, "Matrix%d.bin", nNb++);
- FILE* hFile = fopen(strFile, "wb");
- if (hFile) {
- fwrite(m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType],
- 1,
- pExecuteParams->pCompressedBuffers[i].DataSize,
- hFile);
- fclose(hFile);
- }
- }
+ if (pExecuteParams->pCompressedBuffers[i].CompressedBufferType == DXVA2_InverseQuantizationMatrixBufferType) {
+ char strFile[_MAX_PATH];
+ static int nNb = 1;
+ sprintf_s(strFile, "Matrix%d.bin", nNb++);
+ FILE* hFile = fopen(strFile, "wb");
+ if (hFile) {
+ fwrite(m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType],
+ 1,
+ pExecuteParams->pCompressedBuffers[i].DataSize,
+ hFile);
+ fclose(hFile);
+ }
+ }
#endif
- if (pExecuteParams->pCompressedBuffers[i].CompressedBufferType == DXVA2_BitStreamDateBufferType) {
- LogDXVA_Bitstream(m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType], pExecuteParams->pCompressedBuffers[i].DataSize);
+ if (pExecuteParams->pCompressedBuffers[i].CompressedBufferType == DXVA2_BitStreamDateBufferType) {
+ LogDXVA_Bitstream(m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType], pExecuteParams->pCompressedBuffers[i].DataSize);
#if LOG_BITSTREAM
- char strFile[_MAX_PATH];
- static int nNb = 1;
- sprintf_s(strFile, "BitStream%d.bin", nNb++);
- FILE* hFile = fopen(strFile, "wb");
- if (hFile) {
- fwrite(m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType],
- 1,
- pExecuteParams->pCompressedBuffers[i].DataSize,
- hFile);
- fclose(hFile);
- }
+ char strFile[_MAX_PATH];
+ static int nNb = 1;
+ sprintf_s(strFile, "BitStream%d.bin", nNb++);
+ FILE* hFile = fopen(strFile, "wb");
+ if (hFile) {
+ fwrite(m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType],
+ 1,
+ pExecuteParams->pCompressedBuffers[i].DataSize,
+ hFile);
+ fclose(hFile);
+ }
#endif
- }
- }
+ }
+ }
#endif
- HRESULT hr = m_pDec->Execute (pExecuteParams);
+ HRESULT hr = m_pDec->Execute(pExecuteParams);
#ifdef _DEBUG
- if (pExecuteParams->pExtensionData)
- {
- LOG(_T("IDirectXVideoDecoder::Execute %d buffer, fct = %d (in=%d, out=%d), hr = %08x"),
- pExecuteParams->NumCompBuffers,
- pExecuteParams->pExtensionData->Function,
- pExecuteParams->pExtensionData->PrivateInputDataSize,
- pExecuteParams->pExtensionData->PrivateOutputDataSize,
- hr);
- }
- else {
- LOG(_T("IDirectXVideoDecoder::Execute %d buffer, hr = %08x"), pExecuteParams->NumCompBuffers, hr);
- }
+ if (pExecuteParams->pExtensionData) {
+ LOG(_T("IDirectXVideoDecoder::Execute %d buffer, fct = %d (in=%d, out=%d), hr = %08x"),
+ pExecuteParams->NumCompBuffers,
+ pExecuteParams->pExtensionData->Function,
+ pExecuteParams->pExtensionData->PrivateInputDataSize,
+ pExecuteParams->pExtensionData->PrivateOutputDataSize,
+ hr);
+ } else {
+ LOG(_T("IDirectXVideoDecoder::Execute %d buffer, hr = %08x"), pExecuteParams->NumCompBuffers, hr);
+ }
#endif
- return hr;
- }
+ return hr;
+ }
};
#endif
@@ -1263,88 +1261,88 @@ public :
// Why was the code duplicated ?
interface IDirectXVideoDecoderServiceC;
struct IDirectXVideoDecoderServiceCVtbl {
- BEGIN_INTERFACE
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )( IDirectXVideoDecoderServiceC* pThis, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppvObject );
- ULONG ( STDMETHODCALLTYPE *AddRef )(IDirectXVideoDecoderServiceC* pThis);
- ULONG ( STDMETHODCALLTYPE *Release )(IDirectXVideoDecoderServiceC* pThis);
- HRESULT (STDMETHODCALLTYPE* CreateSurface)(IDirectXVideoDecoderServiceC* pThis, __in UINT Width, __in UINT Height, __in UINT BackBuffers, __in D3DFORMAT Format, __in D3DPOOL Pool, __in DWORD Usage, __in DWORD DxvaType, __out_ecount(BackBuffers+1) IDirect3DSurface9 **ppSurface, __inout_opt HANDLE *pSharedHandle);
-
- HRESULT (STDMETHODCALLTYPE* GetDecoderDeviceGuids)(
- IDirectXVideoDecoderServiceC* pThis,
- __out UINT* pCount,
- __deref_out_ecount_opt(*pCount) GUID** pGuids);
-
- HRESULT (STDMETHODCALLTYPE* GetDecoderRenderTargets)(
- IDirectXVideoDecoderServiceC* pThis,
- __in REFGUID Guid,
- __out UINT* pCount,
- __deref_out_ecount_opt(*pCount) D3DFORMAT** pFormats);
-
- HRESULT (STDMETHODCALLTYPE* GetDecoderConfigurations)(
- IDirectXVideoDecoderServiceC* pThis,
- __in REFGUID Guid,
- __in const DXVA2_VideoDesc* pVideoDesc,
- __reserved void* pReserved,
- __out UINT* pCount,
- __deref_out_ecount_opt(*pCount) DXVA2_ConfigPictureDecode **ppConfigs);
-
- HRESULT (STDMETHODCALLTYPE* CreateVideoDecoder)(
- IDirectXVideoDecoderServiceC* pThis,
- __in REFGUID Guid,
- __in const DXVA2_VideoDesc* pVideoDesc,
- __in const DXVA2_ConfigPictureDecode* pConfig,
- __in_ecount(NumRenderTargets) IDirect3DSurface9 **ppDecoderRenderTargets,
- __in UINT NumRenderTargets,
- __deref_out IDirectXVideoDecoder** ppDecode);
-
- END_INTERFACE
+ BEGIN_INTERFACE
+ HRESULT(STDMETHODCALLTYPE* QueryInterface)(IDirectXVideoDecoderServiceC* pThis, /* [in] */ REFIID riid, /* [iid_is][out] */ void** ppvObject);
+ ULONG(STDMETHODCALLTYPE* AddRef)(IDirectXVideoDecoderServiceC* pThis);
+ ULONG(STDMETHODCALLTYPE* Release)(IDirectXVideoDecoderServiceC* pThis);
+ HRESULT(STDMETHODCALLTYPE* CreateSurface)(IDirectXVideoDecoderServiceC* pThis, __in UINT Width, __in UINT Height, __in UINT BackBuffers, __in D3DFORMAT Format, __in D3DPOOL Pool, __in DWORD Usage, __in DWORD DxvaType, __out_ecount(BackBuffers + 1) IDirect3DSurface9** ppSurface, __inout_opt HANDLE* pSharedHandle);
+
+ HRESULT(STDMETHODCALLTYPE* GetDecoderDeviceGuids)(
+ IDirectXVideoDecoderServiceC* pThis,
+ __out UINT* pCount,
+ __deref_out_ecount_opt(*pCount) GUID** pGuids);
+
+ HRESULT(STDMETHODCALLTYPE* GetDecoderRenderTargets)(
+ IDirectXVideoDecoderServiceC* pThis,
+ __in REFGUID Guid,
+ __out UINT* pCount,
+ __deref_out_ecount_opt(*pCount) D3DFORMAT** pFormats);
+
+ HRESULT(STDMETHODCALLTYPE* GetDecoderConfigurations)(
+ IDirectXVideoDecoderServiceC* pThis,
+ __in REFGUID Guid,
+ __in const DXVA2_VideoDesc* pVideoDesc,
+ __reserved void* pReserved,
+ __out UINT* pCount,
+ __deref_out_ecount_opt(*pCount) DXVA2_ConfigPictureDecode** ppConfigs);
+
+ HRESULT(STDMETHODCALLTYPE* CreateVideoDecoder)(
+ IDirectXVideoDecoderServiceC* pThis,
+ __in REFGUID Guid,
+ __in const DXVA2_VideoDesc* pVideoDesc,
+ __in const DXVA2_ConfigPictureDecode* pConfig,
+ __in_ecount(NumRenderTargets) IDirect3DSurface9** ppDecoderRenderTargets,
+ __in UINT NumRenderTargets,
+ __deref_out IDirectXVideoDecoder** ppDecode);
+
+ END_INTERFACE
};
interface IDirectXVideoDecoderServiceC {
- CONST_VTBL struct IDirectXVideoDecoderServiceCVtbl *lpVtbl;
+ CONST_VTBL struct IDirectXVideoDecoderServiceCVtbl* lpVtbl;
};
-IDirectXVideoDecoderServiceCVtbl* g_pIDirectXVideoDecoderServiceCVtbl = NULL;
-static HRESULT (STDMETHODCALLTYPE* CreateVideoDecoderOrg ) (IDirectXVideoDecoderServiceC* pThis, __in REFGUID Guid, __in const DXVA2_VideoDesc* pVideoDesc, __in const DXVA2_ConfigPictureDecode* pConfig, __in_ecount(NumRenderTargets) IDirect3DSurface9 **ppDecoderRenderTargets, __in UINT NumRenderTargets, __deref_out IDirectXVideoDecoder** ppDecode) = NULL;
+IDirectXVideoDecoderServiceCVtbl* g_pIDirectXVideoDecoderServiceCVtbl = NULL;
+static HRESULT(STDMETHODCALLTYPE* CreateVideoDecoderOrg)(IDirectXVideoDecoderServiceC* pThis, __in REFGUID Guid, __in const DXVA2_VideoDesc* pVideoDesc, __in const DXVA2_ConfigPictureDecode* pConfig, __in_ecount(NumRenderTargets) IDirect3DSurface9** ppDecoderRenderTargets, __in UINT NumRenderTargets, __deref_out IDirectXVideoDecoder** ppDecode) = NULL;
#ifdef _DEBUG
-static HRESULT (STDMETHODCALLTYPE* GetDecoderDeviceGuidsOrg)(IDirectXVideoDecoderServiceC* pThis, __out UINT* pCount, __deref_out_ecount_opt(*pCount) GUID** pGuids) = NULL;
-static HRESULT (STDMETHODCALLTYPE* GetDecoderConfigurationsOrg) (IDirectXVideoDecoderServiceC* pThis, __in REFGUID Guid, __in const DXVA2_VideoDesc* pVideoDesc, __reserved void* pReserved, __out UINT* pCount, __deref_out_ecount_opt(*pCount) DXVA2_ConfigPictureDecode **ppConfigs) = NULL;
+static HRESULT(STDMETHODCALLTYPE* GetDecoderDeviceGuidsOrg)(IDirectXVideoDecoderServiceC* pThis, __out UINT* pCount, __deref_out_ecount_opt(*pCount) GUID** pGuids) = NULL;
+static HRESULT(STDMETHODCALLTYPE* GetDecoderConfigurationsOrg)(IDirectXVideoDecoderServiceC* pThis, __in REFGUID Guid, __in const DXVA2_VideoDesc* pVideoDesc, __reserved void* pReserved, __out UINT* pCount, __deref_out_ecount_opt(*pCount) DXVA2_ConfigPictureDecode** ppConfigs) = NULL;
#endif
#ifdef _DEBUG
-static void LogDXVA2Config (const DXVA2_ConfigPictureDecode* pConfig)
+static void LogDXVA2Config(const DXVA2_ConfigPictureDecode* pConfig)
{
- LOG(_T("Config"));
- LOG(_T(" - Config4GroupedCoefs %d"), pConfig->Config4GroupedCoefs);
- LOG(_T(" - ConfigBitstreamRaw %d"), pConfig->ConfigBitstreamRaw);
- LOG(_T(" - ConfigDecoderSpecific %d"), pConfig->ConfigDecoderSpecific);
- LOG(_T(" - ConfigHostInverseScan %d"), pConfig->ConfigHostInverseScan);
- LOG(_T(" - ConfigIntraResidUnsigned %d"), pConfig->ConfigIntraResidUnsigned);
- LOG(_T(" - ConfigMBcontrolRasterOrder %d"), pConfig->ConfigMBcontrolRasterOrder);
- LOG(_T(" - ConfigMinRenderTargetBuffCount %d"), pConfig->ConfigMinRenderTargetBuffCount);
- LOG(_T(" - ConfigResid8Subtraction %d"), pConfig->ConfigResid8Subtraction);
- LOG(_T(" - ConfigResidDiffAccelerator %d"), pConfig->ConfigResidDiffAccelerator);
- LOG(_T(" - ConfigResidDiffHost %d"), pConfig->ConfigResidDiffHost);
- LOG(_T(" - ConfigSpatialHost8or9Clipping %d"), pConfig->ConfigSpatialHost8or9Clipping);
- LOG(_T(" - ConfigSpatialResid8 %d"), pConfig->ConfigSpatialResid8);
- LOG(_T(" - ConfigSpatialResidInterleaved %d"), pConfig->ConfigSpatialResidInterleaved);
- LOG(_T(" - ConfigSpecificIDCT %d"), pConfig->ConfigSpecificIDCT);
- LOG(_T(" - guidConfigBitstreamEncryption %s"), CStringFromGUID(pConfig->guidConfigBitstreamEncryption));
- LOG(_T(" - guidConfigMBcontrolEncryption %s"), CStringFromGUID(pConfig->guidConfigMBcontrolEncryption));
- LOG(_T(" - guidConfigResidDiffEncryption %s"), CStringFromGUID(pConfig->guidConfigResidDiffEncryption));
+ LOG(_T("Config"));
+ LOG(_T(" - Config4GroupedCoefs %d"), pConfig->Config4GroupedCoefs);
+ LOG(_T(" - ConfigBitstreamRaw %d"), pConfig->ConfigBitstreamRaw);
+ LOG(_T(" - ConfigDecoderSpecific %d"), pConfig->ConfigDecoderSpecific);
+ LOG(_T(" - ConfigHostInverseScan %d"), pConfig->ConfigHostInverseScan);
+ LOG(_T(" - ConfigIntraResidUnsigned %d"), pConfig->ConfigIntraResidUnsigned);
+ LOG(_T(" - ConfigMBcontrolRasterOrder %d"), pConfig->ConfigMBcontrolRasterOrder);
+ LOG(_T(" - ConfigMinRenderTargetBuffCount %d"), pConfig->ConfigMinRenderTargetBuffCount);
+ LOG(_T(" - ConfigResid8Subtraction %d"), pConfig->ConfigResid8Subtraction);
+ LOG(_T(" - ConfigResidDiffAccelerator %d"), pConfig->ConfigResidDiffAccelerator);
+ LOG(_T(" - ConfigResidDiffHost %d"), pConfig->ConfigResidDiffHost);
+ LOG(_T(" - ConfigSpatialHost8or9Clipping %d"), pConfig->ConfigSpatialHost8or9Clipping);
+ LOG(_T(" - ConfigSpatialResid8 %d"), pConfig->ConfigSpatialResid8);
+ LOG(_T(" - ConfigSpatialResidInterleaved %d"), pConfig->ConfigSpatialResidInterleaved);
+ LOG(_T(" - ConfigSpecificIDCT %d"), pConfig->ConfigSpecificIDCT);
+ LOG(_T(" - guidConfigBitstreamEncryption %s"), CStringFromGUID(pConfig->guidConfigBitstreamEncryption));
+ LOG(_T(" - guidConfigMBcontrolEncryption %s"), CStringFromGUID(pConfig->guidConfigMBcontrolEncryption));
+ LOG(_T(" - guidConfigResidDiffEncryption %s"), CStringFromGUID(pConfig->guidConfigResidDiffEncryption));
}
-static void LogDXVA2VideoDesc (const DXVA2_VideoDesc* pVideoDesc)
+static void LogDXVA2VideoDesc(const DXVA2_VideoDesc* pVideoDesc)
{
- LOG(_T("VideoDesc"));
- LOG(_T(" - Format %s (0x%08x)"), FindD3DFormat(pVideoDesc->Format), pVideoDesc->Format);
- LOG(_T(" - InputSampleFreq %d/%d"), pVideoDesc->InputSampleFreq.Numerator, pVideoDesc->InputSampleFreq.Denominator);
- LOG(_T(" - OutputFrameFreq %d/%d"), pVideoDesc->OutputFrameFreq.Numerator, pVideoDesc->OutputFrameFreq.Denominator);
- LOG(_T(" - SampleFormat %d"), pVideoDesc->SampleFormat.value);
- LOG(_T(" - SampleHeight %d"), pVideoDesc->SampleHeight);
- LOG(_T(" - SampleWidth %d"), pVideoDesc->SampleWidth);
- LOG(_T(" - UABProtectionLevel %d"), pVideoDesc->UABProtectionLevel);
+ LOG(_T("VideoDesc"));
+ LOG(_T(" - Format %s (0x%08x)"), FindD3DFormat(pVideoDesc->Format), pVideoDesc->Format);
+ LOG(_T(" - InputSampleFreq %d/%d"), pVideoDesc->InputSampleFreq.Numerator, pVideoDesc->InputSampleFreq.Denominator);
+ LOG(_T(" - OutputFrameFreq %d/%d"), pVideoDesc->OutputFrameFreq.Numerator, pVideoDesc->OutputFrameFreq.Denominator);
+ LOG(_T(" - SampleFormat %d"), pVideoDesc->SampleFormat.value);
+ LOG(_T(" - SampleHeight %d"), pVideoDesc->SampleHeight);
+ LOG(_T(" - SampleWidth %d"), pVideoDesc->SampleWidth);
+ LOG(_T(" - UABProtectionLevel %d"), pVideoDesc->UABProtectionLevel);
}
#endif
@@ -1352,190 +1350,190 @@ static void LogDXVA2VideoDesc (const DXVA2_VideoDesc* pVideoDesc)
// Function not used yet
static void LogVideoCardCaps(IDirectXVideoDecoderService* pDecoderService)
{
- HRESULT hr;
- UINT cDecoderGuids = 0;
- GUID* pDecoderGuids = NULL;
-
- hr = pDecoderService->GetDecoderDeviceGuids(&cDecoderGuids, &pDecoderGuids);
- if (SUCCEEDED(hr)) {
- // Look for the decoder GUIDs we want.
- for (UINT iGuid = 0; iGuid < cDecoderGuids; iGuid++) {
- LOG (_T("=== New mode : %s"), GetDXVAMode (&pDecoderGuids[iGuid]));
-
- // Find a configuration that we support.
- UINT cFormats = 0;
- UINT cConfigurations = 0;
- D3DFORMAT* pFormats = NULL;
- DXVA2_ConfigPictureDecode* pConfig = NULL;
- DXVA2_VideoDesc m_VideoDesc;
-
- hr = pDecoderService->GetDecoderRenderTargets(pDecoderGuids[iGuid], &cFormats, &pFormats);
-
- if (SUCCEEDED(hr)) {
- // Look for a format that matches our output format.
- for (UINT iFormat = 0; iFormat < cFormats; iFormat++) {
- LOG (_T("Direct 3D format : %s"), FindD3DFormat(pFormats[iFormat]));
- // Fill in the video description. Set the width, height, format, and frame rate.
- memset(&m_VideoDesc, 0, sizeof(m_VideoDesc));
- m_VideoDesc.SampleWidth = 1280;
- m_VideoDesc.SampleHeight = 720;
- m_VideoDesc.Format = pFormats[iFormat];
-
- // Get the available configurations.
- hr = pDecoderService->GetDecoderConfigurations(pDecoderGuids[iGuid], &m_VideoDesc, NULL, &cConfigurations, &pConfig);
-
- if (SUCCEEDED(hr)) {
-
- // Find a supported configuration.
- for (UINT iConfig = 0; iConfig < cConfigurations; iConfig++) {
- LogDXVA2Config (&pConfig[iConfig]);
- }
-
- CoTaskMemFree(pConfig);
- }
- }
- }
-
- LOG(_T("\n"));
- CoTaskMemFree(pFormats);
- }
- }
+ HRESULT hr;
+ UINT cDecoderGuids = 0;
+ GUID* pDecoderGuids = NULL;
+
+ hr = pDecoderService->GetDecoderDeviceGuids(&cDecoderGuids, &pDecoderGuids);
+ if (SUCCEEDED(hr)) {
+ // Look for the decoder GUIDs we want.
+ for (UINT iGuid = 0; iGuid < cDecoderGuids; iGuid++) {
+ LOG(_T("=== New mode : %s"), GetDXVAMode(&pDecoderGuids[iGuid]));
+
+ // Find a configuration that we support.
+ UINT cFormats = 0;
+ UINT cConfigurations = 0;
+ D3DFORMAT* pFormats = NULL;
+ DXVA2_ConfigPictureDecode* pConfig = NULL;
+ DXVA2_VideoDesc m_VideoDesc;
+
+ hr = pDecoderService->GetDecoderRenderTargets(pDecoderGuids[iGuid], &cFormats, &pFormats);
+
+ if (SUCCEEDED(hr)) {
+ // Look for a format that matches our output format.
+ for (UINT iFormat = 0; iFormat < cFormats; iFormat++) {
+ LOG(_T("Direct 3D format : %s"), FindD3DFormat(pFormats[iFormat]));
+ // Fill in the video description. Set the width, height, format, and frame rate.
+ memset(&m_VideoDesc, 0, sizeof(m_VideoDesc));
+ m_VideoDesc.SampleWidth = 1280;
+ m_VideoDesc.SampleHeight = 720;
+ m_VideoDesc.Format = pFormats[iFormat];
+
+ // Get the available configurations.
+ hr = pDecoderService->GetDecoderConfigurations(pDecoderGuids[iGuid], &m_VideoDesc, NULL, &cConfigurations, &pConfig);
+
+ if (SUCCEEDED(hr)) {
+
+ // Find a supported configuration.
+ for (UINT iConfig = 0; iConfig < cConfigurations; iConfig++) {
+ LogDXVA2Config(&pConfig[iConfig]);
+ }
+
+ CoTaskMemFree(pConfig);
+ }
+ }
+ }
+
+ LOG(_T("\n"));
+ CoTaskMemFree(pFormats);
+ }
+ }
}
#endif
static HRESULT STDMETHODCALLTYPE CreateVideoDecoderMine(
- IDirectXVideoDecoderServiceC* pThis,
- __in REFGUID Guid,
- __in const DXVA2_VideoDesc* pVideoDesc,
- __in const DXVA2_ConfigPictureDecode* pConfig,
- __in_ecount(NumRenderTargets) IDirect3DSurface9 **ppDecoderRenderTargets,
- __in UINT NumRenderTargets,
- __deref_out IDirectXVideoDecoder** ppDecode)
+ IDirectXVideoDecoderServiceC* pThis,
+ __in REFGUID Guid,
+ __in const DXVA2_VideoDesc* pVideoDesc,
+ __in const DXVA2_ConfigPictureDecode* pConfig,
+ __in_ecount(NumRenderTargets) IDirect3DSurface9** ppDecoderRenderTargets,
+ __in UINT NumRenderTargets,
+ __deref_out IDirectXVideoDecoder** ppDecode)
{
- // DebugBreak();
- // ((DXVA2_VideoDesc*)pVideoDesc)->Format = (D3DFORMAT)0x3231564E;
- g_guidDXVADecoder = Guid;
- g_nDXVAVersion = 2;
+ // DebugBreak();
+ // ((DXVA2_VideoDesc*)pVideoDesc)->Format = (D3DFORMAT)0x3231564E;
+ g_guidDXVADecoder = Guid;
+ g_nDXVAVersion = 2;
#ifdef _DEBUG
- LOG(_T("\n\n"));
- LogDXVA2VideoDesc(pVideoDesc);
- LogDXVA2Config(pConfig);
+ LOG(_T("\n\n"));
+ LogDXVA2VideoDesc(pVideoDesc);
+ LogDXVA2Config(pConfig);
#endif
- HRESULT hr = CreateVideoDecoderOrg(pThis, Guid, pVideoDesc, pConfig, ppDecoderRenderTargets, NumRenderTargets, ppDecode);
+ HRESULT hr = CreateVideoDecoderOrg(pThis, Guid, pVideoDesc, pConfig, ppDecoderRenderTargets, NumRenderTargets, ppDecode);
- if (FAILED (hr)) {
- g_guidDXVADecoder = GUID_NULL;
- }
+ if (FAILED(hr)) {
+ g_guidDXVADecoder = GUID_NULL;
+ }
#ifdef _DEBUG
- else {
- if ((Guid == DXVA2_ModeH264_E) ||
- (Guid == DXVA2_ModeVC1_D) ||
- (Guid == DXVA_Intel_H264_ClearVideo) ||
- (Guid == DXVA_Intel_VC1_ClearVideo) ||
- (Guid == DXVA2_ModeMPEG2_VLD)) {
- *ppDecode = DNew CFakeDirectXVideoDecoder (NULL, *ppDecode);
- (*ppDecode)->AddRef();
- }
-
- for (DWORD i=0; i<NumRenderTargets; i++) {
- LOG(_T(" - Surf %d : %08x"), i, ppDecoderRenderTargets[i]);
- }
- }
+ else {
+ if ((Guid == DXVA2_ModeH264_E) ||
+ (Guid == DXVA2_ModeVC1_D) ||
+ (Guid == DXVA_Intel_H264_ClearVideo) ||
+ (Guid == DXVA_Intel_VC1_ClearVideo) ||
+ (Guid == DXVA2_ModeMPEG2_VLD)) {
+ *ppDecode = DNew CFakeDirectXVideoDecoder(NULL, *ppDecode);
+ (*ppDecode)->AddRef();
+ }
+
+ for (DWORD i = 0; i < NumRenderTargets; i++) {
+ LOG(_T(" - Surf %d : %08x"), i, ppDecoderRenderTargets[i]);
+ }
+ }
#endif
- TRACE(_T("DXVA Decoder : %s\n"), GetDXVADecoderDescription());
+ TRACE(_T("DXVA Decoder : %s\n"), GetDXVADecoderDescription());
#ifdef _DEBUG
- LOG(_T("IDirectXVideoDecoderService::CreateVideoDecoder %s (%d render targets) hr = %08x"), GetDXVAMode(&g_guidDXVADecoder), NumRenderTargets, hr);
+ LOG(_T("IDirectXVideoDecoderService::CreateVideoDecoder %s (%d render targets) hr = %08x"), GetDXVAMode(&g_guidDXVADecoder), NumRenderTargets, hr);
#endif
- return hr;
+ return hr;
}
#ifdef _DEBUG
-static HRESULT STDMETHODCALLTYPE GetDecoderDeviceGuidsMine (IDirectXVideoDecoderServiceC* pThis,
- __out UINT* pCount,
- __deref_out_ecount_opt(*pCount) GUID** pGuids)
+static HRESULT STDMETHODCALLTYPE GetDecoderDeviceGuidsMine(IDirectXVideoDecoderServiceC* pThis,
+ __out UINT* pCount,
+ __deref_out_ecount_opt(*pCount) GUID** pGuids)
{
- HRESULT hr = GetDecoderDeviceGuidsOrg(pThis, pCount, pGuids);
- LOG(_T("IDirectXVideoDecoderService::GetDecoderDeviceGuids hr = %08x\n"), hr);
+ HRESULT hr = GetDecoderDeviceGuidsOrg(pThis, pCount, pGuids);
+ LOG(_T("IDirectXVideoDecoderService::GetDecoderDeviceGuids hr = %08x\n"), hr);
- return hr;
+ return hr;
}
-static HRESULT STDMETHODCALLTYPE GetDecoderConfigurationsMine (IDirectXVideoDecoderServiceC* pThis,
- __in REFGUID Guid,
- __in const DXVA2_VideoDesc* pVideoDesc,
- __reserved void* pReserved,
- __out UINT* pCount,
- __deref_out_ecount_opt(*pCount) DXVA2_ConfigPictureDecode **ppConfigs)
+static HRESULT STDMETHODCALLTYPE GetDecoderConfigurationsMine(IDirectXVideoDecoderServiceC* pThis,
+ __in REFGUID Guid,
+ __in const DXVA2_VideoDesc* pVideoDesc,
+ __reserved void* pReserved,
+ __out UINT* pCount,
+ __deref_out_ecount_opt(*pCount) DXVA2_ConfigPictureDecode** ppConfigs)
{
- HRESULT hr = GetDecoderConfigurationsOrg(pThis, Guid, pVideoDesc, pReserved, pCount, ppConfigs);
+ HRESULT hr = GetDecoderConfigurationsOrg(pThis, Guid, pVideoDesc, pReserved, pCount, ppConfigs);
- // Force LongSlice decoding !
- // memcpy (&(*ppConfigs)[1], &(*ppConfigs)[0], sizeof(DXVA2_ConfigPictureDecode));
+ // Force LongSlice decoding !
+ // memcpy (&(*ppConfigs)[1], &(*ppConfigs)[0], sizeof(DXVA2_ConfigPictureDecode));
- return hr;
+ return hr;
}
#endif
void HookDirectXVideoDecoderService(void* pIDirectXVideoDecoderService)
{
- IDirectXVideoDecoderServiceC* pIDirectXVideoDecoderServiceC = (IDirectXVideoDecoderServiceC*) pIDirectXVideoDecoderService;
+ IDirectXVideoDecoderServiceC* pIDirectXVideoDecoderServiceC = (IDirectXVideoDecoderServiceC*) pIDirectXVideoDecoderService;
- BOOL res;
- DWORD flOldProtect = 0;
+ BOOL res;
+ DWORD flOldProtect = 0;
- // Casimir666 : unhook previous VTables
- if (g_pIDirectXVideoDecoderServiceCVtbl) {
- res = VirtualProtect(g_pIDirectXVideoDecoderServiceCVtbl, sizeof(g_pIDirectXVideoDecoderServiceCVtbl), PAGE_WRITECOPY, &flOldProtect);
- if (g_pIDirectXVideoDecoderServiceCVtbl->CreateVideoDecoder == CreateVideoDecoderMine) {
- g_pIDirectXVideoDecoderServiceCVtbl->CreateVideoDecoder = CreateVideoDecoderOrg;
- }
+ // Casimir666 : unhook previous VTables
+ if (g_pIDirectXVideoDecoderServiceCVtbl) {
+ res = VirtualProtect(g_pIDirectXVideoDecoderServiceCVtbl, sizeof(g_pIDirectXVideoDecoderServiceCVtbl), PAGE_WRITECOPY, &flOldProtect);
+ if (g_pIDirectXVideoDecoderServiceCVtbl->CreateVideoDecoder == CreateVideoDecoderMine) {
+ g_pIDirectXVideoDecoderServiceCVtbl->CreateVideoDecoder = CreateVideoDecoderOrg;
+ }
#ifdef _DEBUG
- if (g_pIDirectXVideoDecoderServiceCVtbl->GetDecoderConfigurations == GetDecoderConfigurationsMine) {
- g_pIDirectXVideoDecoderServiceCVtbl->GetDecoderConfigurations = GetDecoderConfigurationsOrg;
- }
+ if (g_pIDirectXVideoDecoderServiceCVtbl->GetDecoderConfigurations == GetDecoderConfigurationsMine) {
+ g_pIDirectXVideoDecoderServiceCVtbl->GetDecoderConfigurations = GetDecoderConfigurationsOrg;
+ }
- //if (g_pIDirectXVideoDecoderServiceCVtbl->GetDecoderDeviceGuids == GetDecoderDeviceGuidsMine)
- // g_pIDirectXVideoDecoderServiceCVtbl->GetDecoderDeviceGuids = GetDecoderDeviceGuidsOrg;
+ //if (g_pIDirectXVideoDecoderServiceCVtbl->GetDecoderDeviceGuids == GetDecoderDeviceGuidsMine)
+ // g_pIDirectXVideoDecoderServiceCVtbl->GetDecoderDeviceGuids = GetDecoderDeviceGuidsOrg;
#endif
- res = VirtualProtect(g_pIDirectXVideoDecoderServiceCVtbl, sizeof(g_pIDirectXVideoDecoderServiceCVtbl), flOldProtect, &flOldProtect);
+ res = VirtualProtect(g_pIDirectXVideoDecoderServiceCVtbl, sizeof(g_pIDirectXVideoDecoderServiceCVtbl), flOldProtect, &flOldProtect);
- g_pIDirectXVideoDecoderServiceCVtbl = NULL;
- CreateVideoDecoderOrg = NULL;
+ g_pIDirectXVideoDecoderServiceCVtbl = NULL;
+ CreateVideoDecoderOrg = NULL;
#ifdef _DEBUG
- GetDecoderConfigurationsOrg = NULL;
+ GetDecoderConfigurationsOrg = NULL;
#endif
- g_guidDXVADecoder = GUID_NULL;
- g_nDXVAVersion = 0;
- }
+ g_guidDXVADecoder = GUID_NULL;
+ g_nDXVAVersion = 0;
+ }
#if defined(_DEBUG) && DXVA_LOGFILE_A
- ::DeleteFile (LOG_FILE_DXVA);
- ::DeleteFile (LOG_FILE_PICTURE);
- ::DeleteFile (LOG_FILE_SLICELONG);
+ ::DeleteFile(LOG_FILE_DXVA);
+ ::DeleteFile(LOG_FILE_PICTURE);
+ ::DeleteFile(LOG_FILE_SLICELONG);
#endif
- if (!g_pIDirectXVideoDecoderServiceCVtbl && pIDirectXVideoDecoderService) {
- res = VirtualProtect(pIDirectXVideoDecoderServiceC->lpVtbl, sizeof(IDirectXVideoDecoderServiceCVtbl), PAGE_WRITECOPY, &flOldProtect);
+ if (!g_pIDirectXVideoDecoderServiceCVtbl && pIDirectXVideoDecoderService) {
+ res = VirtualProtect(pIDirectXVideoDecoderServiceC->lpVtbl, sizeof(IDirectXVideoDecoderServiceCVtbl), PAGE_WRITECOPY, &flOldProtect);
- CreateVideoDecoderOrg = pIDirectXVideoDecoderServiceC->lpVtbl->CreateVideoDecoder;
- pIDirectXVideoDecoderServiceC->lpVtbl->CreateVideoDecoder = CreateVideoDecoderMine;
+ CreateVideoDecoderOrg = pIDirectXVideoDecoderServiceC->lpVtbl->CreateVideoDecoder;
+ pIDirectXVideoDecoderServiceC->lpVtbl->CreateVideoDecoder = CreateVideoDecoderMine;
#ifdef _DEBUG
- GetDecoderConfigurationsOrg = pIDirectXVideoDecoderServiceC->lpVtbl->GetDecoderConfigurations;
- pIDirectXVideoDecoderServiceC->lpVtbl->GetDecoderConfigurations = GetDecoderConfigurationsMine;
+ GetDecoderConfigurationsOrg = pIDirectXVideoDecoderServiceC->lpVtbl->GetDecoderConfigurations;
+ pIDirectXVideoDecoderServiceC->lpVtbl->GetDecoderConfigurations = GetDecoderConfigurationsMine;
- //GetDecoderDeviceGuidsOrg = pIDirectXVideoDecoderServiceC->lpVtbl->GetDecoderDeviceGuids;
- //pIDirectXVideoDecoderServiceC->lpVtbl->GetDecoderDeviceGuids = GetDecoderDeviceGuidsMine;
+ //GetDecoderDeviceGuidsOrg = pIDirectXVideoDecoderServiceC->lpVtbl->GetDecoderDeviceGuids;
+ //pIDirectXVideoDecoderServiceC->lpVtbl->GetDecoderDeviceGuids = GetDecoderDeviceGuidsMine;
#endif
- res = VirtualProtect(pIDirectXVideoDecoderServiceC->lpVtbl, sizeof(IDirectXVideoDecoderServiceCVtbl), flOldProtect, &flOldProtect);
+ res = VirtualProtect(pIDirectXVideoDecoderServiceC->lpVtbl, sizeof(IDirectXVideoDecoderServiceCVtbl), flOldProtect, &flOldProtect);
- g_pIDirectXVideoDecoderServiceCVtbl = pIDirectXVideoDecoderServiceC->lpVtbl;
- }
+ g_pIDirectXVideoDecoderServiceCVtbl = pIDirectXVideoDecoderServiceC->lpVtbl;
+ }
} \ No newline at end of file
diff --git a/src/filters/renderer/VideoRenderers/IPinHook.h b/src/filters/renderer/VideoRenderers/IPinHook.h
index 67b6f82ad..784b5e333 100644
--- a/src/filters/renderer/VideoRenderers/IPinHook.h
+++ b/src/filters/renderer/VideoRenderers/IPinHook.h
@@ -28,50 +28,50 @@
interface IPinC;
typedef struct IPinCVtbl {
- BEGIN_INTERFACE
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )( IPinC * This, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppvObject );
- ULONG ( STDMETHODCALLTYPE *AddRef )( IPinC * This );
- ULONG ( STDMETHODCALLTYPE *Release )( IPinC * This );
- HRESULT ( STDMETHODCALLTYPE *Connect )( IPinC * This, /* [in] */ IPinC *pReceivePin, /* [in] */ const AM_MEDIA_TYPE *pmt );
- HRESULT ( STDMETHODCALLTYPE *ReceiveConnection )( IPinC * This, /* [in] */ IPinC *pConnector, /* [in] */ const AM_MEDIA_TYPE *pmt );
- HRESULT ( STDMETHODCALLTYPE *Disconnect )( IPinC * This );
- HRESULT ( STDMETHODCALLTYPE *ConnectedTo )( IPinC * This, /* [out] */ IPinC **pPin );
- HRESULT ( STDMETHODCALLTYPE *ConnectionMediaType )( IPinC * This, /* [out] */ AM_MEDIA_TYPE *pmt );
- HRESULT ( STDMETHODCALLTYPE *QueryPinInfo )( IPinC * This, /* [out] */ PIN_INFO *pInfo );
- HRESULT ( STDMETHODCALLTYPE *QueryDirection )( IPinC * This, /* [out] */ PIN_DIRECTION *pPinDir );
- HRESULT ( STDMETHODCALLTYPE *QueryId )( IPinC * This, /* [out] */ LPWSTR *Id );
- HRESULT ( STDMETHODCALLTYPE *QueryAccept )( IPinC * This, /* [in] */ const AM_MEDIA_TYPE *pmt );
- HRESULT ( STDMETHODCALLTYPE *EnumMediaTypes )( IPinC * This, /* [out] */ IEnumMediaTypes **ppEnum );
- HRESULT ( STDMETHODCALLTYPE *QueryInternalConnections )( IPinC * This, /* [out] */ IPinC **apPin, /* [out][in] */ ULONG *nPin );
- HRESULT ( STDMETHODCALLTYPE *EndOfStream )( IPinC * This );
- HRESULT ( STDMETHODCALLTYPE *BeginFlush )( IPinC * This );
- HRESULT ( STDMETHODCALLTYPE *EndFlush )( IPinC * This );
- HRESULT ( STDMETHODCALLTYPE *NewSegment )( IPinC * This, /* [in] */ REFERENCE_TIME tStart, /* [in] */ REFERENCE_TIME tStop, /* [in] */ double dRate );
- END_INTERFACE
+ BEGIN_INTERFACE
+ HRESULT(STDMETHODCALLTYPE* QueryInterface)(IPinC* This, /* [in] */ REFIID riid, /* [iid_is][out] */ void** ppvObject);
+ ULONG(STDMETHODCALLTYPE* AddRef)(IPinC* This);
+ ULONG(STDMETHODCALLTYPE* Release)(IPinC* This);
+ HRESULT(STDMETHODCALLTYPE* Connect)(IPinC* This, /* [in] */ IPinC* pReceivePin, /* [in] */ const AM_MEDIA_TYPE* pmt);
+ HRESULT(STDMETHODCALLTYPE* ReceiveConnection)(IPinC* This, /* [in] */ IPinC* pConnector, /* [in] */ const AM_MEDIA_TYPE* pmt);
+ HRESULT(STDMETHODCALLTYPE* Disconnect)(IPinC* This);
+ HRESULT(STDMETHODCALLTYPE* ConnectedTo)(IPinC* This, /* [out] */ IPinC** pPin);
+ HRESULT(STDMETHODCALLTYPE* ConnectionMediaType)(IPinC* This, /* [out] */ AM_MEDIA_TYPE* pmt);
+ HRESULT(STDMETHODCALLTYPE* QueryPinInfo)(IPinC* This, /* [out] */ PIN_INFO* pInfo);
+ HRESULT(STDMETHODCALLTYPE* QueryDirection)(IPinC* This, /* [out] */ PIN_DIRECTION* pPinDir);
+ HRESULT(STDMETHODCALLTYPE* QueryId)(IPinC* This, /* [out] */ LPWSTR* Id);
+ HRESULT(STDMETHODCALLTYPE* QueryAccept)(IPinC* This, /* [in] */ const AM_MEDIA_TYPE* pmt);
+ HRESULT(STDMETHODCALLTYPE* EnumMediaTypes)(IPinC* This, /* [out] */ IEnumMediaTypes** ppEnum);
+ HRESULT(STDMETHODCALLTYPE* QueryInternalConnections)(IPinC* This, /* [out] */ IPinC** apPin, /* [out][in] */ ULONG* nPin);
+ HRESULT(STDMETHODCALLTYPE* EndOfStream)(IPinC* This);
+ HRESULT(STDMETHODCALLTYPE* BeginFlush)(IPinC* This);
+ HRESULT(STDMETHODCALLTYPE* EndFlush)(IPinC* This);
+ HRESULT(STDMETHODCALLTYPE* NewSegment)(IPinC* This, /* [in] */ REFERENCE_TIME tStart, /* [in] */ REFERENCE_TIME tStop, /* [in] */ double dRate);
+ END_INTERFACE
} IPinCVtbl;
interface IPinC {
- CONST_VTBL struct IPinCVtbl *lpVtbl;
+ CONST_VTBL struct IPinCVtbl* lpVtbl;
};
interface IMemInputPinC;
typedef struct IMemInputPinCVtbl {
- BEGIN_INTERFACE
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )( IPinC * This, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppvObject );
- ULONG ( STDMETHODCALLTYPE *AddRef )( IPinC * This );
- ULONG ( STDMETHODCALLTYPE *Release )( IPinC * This );
- HRESULT ( STDMETHODCALLTYPE *GetAllocator )( IMemInputPinC * This, IMemAllocator **ppAllocator);
- HRESULT ( STDMETHODCALLTYPE *NotifyAllocator )( IMemInputPinC * This, IMemAllocator *pAllocator, BOOL bReadOnly);
- HRESULT ( STDMETHODCALLTYPE *GetAllocatorRequirements )( IMemInputPinC * This, ALLOCATOR_PROPERTIES *pProps);
- HRESULT ( STDMETHODCALLTYPE *Receive )( IMemInputPinC * This, IMediaSample *pSample);
- HRESULT ( STDMETHODCALLTYPE *ReceiveMultiple )( IMemInputPinC * This, IMediaSample **pSamples, long nSamples, long *nSamplesProcessed);
- HRESULT ( STDMETHODCALLTYPE *ReceiveCanBlock )( IMemInputPinC * This);
- END_INTERFACE
+ BEGIN_INTERFACE
+ HRESULT(STDMETHODCALLTYPE* QueryInterface)(IPinC* This, /* [in] */ REFIID riid, /* [iid_is][out] */ void** ppvObject);
+ ULONG(STDMETHODCALLTYPE* AddRef)(IPinC* This);
+ ULONG(STDMETHODCALLTYPE* Release)(IPinC* This);
+ HRESULT(STDMETHODCALLTYPE* GetAllocator)(IMemInputPinC* This, IMemAllocator** ppAllocator);
+ HRESULT(STDMETHODCALLTYPE* NotifyAllocator)(IMemInputPinC* This, IMemAllocator* pAllocator, BOOL bReadOnly);
+ HRESULT(STDMETHODCALLTYPE* GetAllocatorRequirements)(IMemInputPinC* This, ALLOCATOR_PROPERTIES* pProps);
+ HRESULT(STDMETHODCALLTYPE* Receive)(IMemInputPinC* This, IMediaSample* pSample);
+ HRESULT(STDMETHODCALLTYPE* ReceiveMultiple)(IMemInputPinC* This, IMediaSample** pSamples, long nSamples, long* nSamplesProcessed);
+ HRESULT(STDMETHODCALLTYPE* ReceiveCanBlock)(IMemInputPinC* This);
+ END_INTERFACE
} IMemInputPinCVtbl;
interface IMemInputPinC {
- CONST_VTBL struct IMemInputPinCVtbl *lpVtbl;
+ CONST_VTBL struct IMemInputPinCVtbl* lpVtbl;
};
extern bool HookNewSegmentAndReceive(IPinC* pPinC, IMemInputPinC* pMemInputPin);
@@ -83,95 +83,95 @@ extern REFERENCE_TIME g_tSegmentStart, g_tSampleStart, g_rtTimePerFrame;
interface IAMVideoAcceleratorC;
typedef struct IAMVideoAcceleratorCVtbl {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IAMVideoAcceleratorC * This,
- /* [in] */ REFIID riid,
- /* [iid_is][out] */ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IAMVideoAcceleratorC * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IAMVideoAcceleratorC * This);
-
- HRESULT ( STDMETHODCALLTYPE *GetVideoAcceleratorGUIDs )(
- IAMVideoAcceleratorC * This,
- /* [out][in] */ LPDWORD pdwNumGuidsSupported,
- /* [out][in] */ LPGUID pGuidsSupported);
-
- HRESULT ( STDMETHODCALLTYPE *GetUncompFormatsSupported )(
- IAMVideoAcceleratorC * This,
- /* [in] */ const GUID *pGuid,
- /* [out][in] */ LPDWORD pdwNumFormatsSupported,
- /* [out][in] */ LPDDPIXELFORMAT pFormatsSupported);
-
- HRESULT ( STDMETHODCALLTYPE *GetInternalMemInfo )(
- IAMVideoAcceleratorC * This,
- /* [in] */ const GUID *pGuid,
- /* [in] */ const AMVAUncompDataInfo *pamvaUncompDataInfo,
- /* [out][in] */ LPAMVAInternalMemInfo pamvaInternalMemInfo);
-
- HRESULT ( STDMETHODCALLTYPE *GetCompBufferInfo )(
- IAMVideoAcceleratorC * This,
- /* [in] */ const GUID *pGuid,
- /* [in] */ const AMVAUncompDataInfo *pamvaUncompDataInfo,
- /* [out][in] */ LPDWORD pdwNumTypesCompBuffers,
- /* [out] */ LPAMVACompBufferInfo pamvaCompBufferInfo);
-
- HRESULT ( STDMETHODCALLTYPE *GetInternalCompBufferInfo )(
- IAMVideoAcceleratorC * This,
- /* [out][in] */ LPDWORD pdwNumTypesCompBuffers,
- /* [out] */ LPAMVACompBufferInfo pamvaCompBufferInfo);
-
- HRESULT ( STDMETHODCALLTYPE *BeginFrame )(
- IAMVideoAcceleratorC * This,
- /* [in] */ const AMVABeginFrameInfo *amvaBeginFrameInfo);
-
- HRESULT ( STDMETHODCALLTYPE *EndFrame )(
- IAMVideoAcceleratorC * This,
- /* [in] */ const AMVAEndFrameInfo *pEndFrameInfo);
-
- HRESULT ( STDMETHODCALLTYPE *GetBuffer )(
- IAMVideoAcceleratorC * This,
- /* [in] */ DWORD dwTypeIndex,
- /* [in] */ DWORD dwBufferIndex,
- /* [in] */ BOOL bReadOnly,
- /* [out] */ LPVOID *ppBuffer,
- /* [out] */ LONG *lpStride);
-
- HRESULT ( STDMETHODCALLTYPE *ReleaseBuffer )(
- IAMVideoAcceleratorC * This,
- /* [in] */ DWORD dwTypeIndex,
- /* [in] */ DWORD dwBufferIndex);
-
- HRESULT ( STDMETHODCALLTYPE *Execute )(
- IAMVideoAcceleratorC * This,
- /* [in] */ DWORD dwFunction,
- /* [in] */ LPVOID lpPrivateInputData,
- /* [in] */ DWORD cbPrivateInputData,
- /* [in] */ LPVOID lpPrivateOutputDat,
- /* [in] */ DWORD cbPrivateOutputData,
- /* [in] */ DWORD dwNumBuffers,
- /* [in] */ const AMVABUFFERINFO *pamvaBufferInfo);
-
- HRESULT ( STDMETHODCALLTYPE *QueryRenderStatus )(
- IAMVideoAcceleratorC * This,
- /* [in] */ DWORD dwTypeIndex,
- /* [in] */ DWORD dwBufferIndex,
- /* [in] */ DWORD dwFlags);
-
- HRESULT ( STDMETHODCALLTYPE *DisplayFrame )(
- IAMVideoAcceleratorC * This,
- /* [in] */ DWORD dwFlipToIndex,
- /* [in] */ IMediaSample *pMediaSample);
-
- END_INTERFACE
+ BEGIN_INTERFACE
+
+ HRESULT(STDMETHODCALLTYPE* QueryInterface)(
+ IAMVideoAcceleratorC* This,
+ /* [in] */ REFIID riid,
+ /* [iid_is][out] */ void** ppvObject);
+
+ ULONG(STDMETHODCALLTYPE* AddRef)(
+ IAMVideoAcceleratorC* This);
+
+ ULONG(STDMETHODCALLTYPE* Release)(
+ IAMVideoAcceleratorC* This);
+
+ HRESULT(STDMETHODCALLTYPE* GetVideoAcceleratorGUIDs)(
+ IAMVideoAcceleratorC* This,
+ /* [out][in] */ LPDWORD pdwNumGuidsSupported,
+ /* [out][in] */ LPGUID pGuidsSupported);
+
+ HRESULT(STDMETHODCALLTYPE* GetUncompFormatsSupported)(
+ IAMVideoAcceleratorC* This,
+ /* [in] */ const GUID* pGuid,
+ /* [out][in] */ LPDWORD pdwNumFormatsSupported,
+ /* [out][in] */ LPDDPIXELFORMAT pFormatsSupported);
+
+ HRESULT(STDMETHODCALLTYPE* GetInternalMemInfo)(
+ IAMVideoAcceleratorC* This,
+ /* [in] */ const GUID* pGuid,
+ /* [in] */ const AMVAUncompDataInfo* pamvaUncompDataInfo,
+ /* [out][in] */ LPAMVAInternalMemInfo pamvaInternalMemInfo);
+
+ HRESULT(STDMETHODCALLTYPE* GetCompBufferInfo)(
+ IAMVideoAcceleratorC* This,
+ /* [in] */ const GUID* pGuid,
+ /* [in] */ const AMVAUncompDataInfo* pamvaUncompDataInfo,
+ /* [out][in] */ LPDWORD pdwNumTypesCompBuffers,
+ /* [out] */ LPAMVACompBufferInfo pamvaCompBufferInfo);
+
+ HRESULT(STDMETHODCALLTYPE* GetInternalCompBufferInfo)(
+ IAMVideoAcceleratorC* This,
+ /* [out][in] */ LPDWORD pdwNumTypesCompBuffers,
+ /* [out] */ LPAMVACompBufferInfo pamvaCompBufferInfo);
+
+ HRESULT(STDMETHODCALLTYPE* BeginFrame)(
+ IAMVideoAcceleratorC* This,
+ /* [in] */ const AMVABeginFrameInfo* amvaBeginFrameInfo);
+
+ HRESULT(STDMETHODCALLTYPE* EndFrame)(
+ IAMVideoAcceleratorC* This,
+ /* [in] */ const AMVAEndFrameInfo* pEndFrameInfo);
+
+ HRESULT(STDMETHODCALLTYPE* GetBuffer)(
+ IAMVideoAcceleratorC* This,
+ /* [in] */ DWORD dwTypeIndex,
+ /* [in] */ DWORD dwBufferIndex,
+ /* [in] */ BOOL bReadOnly,
+ /* [out] */ LPVOID* ppBuffer,
+ /* [out] */ LONG* lpStride);
+
+ HRESULT(STDMETHODCALLTYPE* ReleaseBuffer)(
+ IAMVideoAcceleratorC* This,
+ /* [in] */ DWORD dwTypeIndex,
+ /* [in] */ DWORD dwBufferIndex);
+
+ HRESULT(STDMETHODCALLTYPE* Execute)(
+ IAMVideoAcceleratorC* This,
+ /* [in] */ DWORD dwFunction,
+ /* [in] */ LPVOID lpPrivateInputData,
+ /* [in] */ DWORD cbPrivateInputData,
+ /* [in] */ LPVOID lpPrivateOutputDat,
+ /* [in] */ DWORD cbPrivateOutputData,
+ /* [in] */ DWORD dwNumBuffers,
+ /* [in] */ const AMVABUFFERINFO* pamvaBufferInfo);
+
+ HRESULT(STDMETHODCALLTYPE* QueryRenderStatus)(
+ IAMVideoAcceleratorC* This,
+ /* [in] */ DWORD dwTypeIndex,
+ /* [in] */ DWORD dwBufferIndex,
+ /* [in] */ DWORD dwFlags);
+
+ HRESULT(STDMETHODCALLTYPE* DisplayFrame)(
+ IAMVideoAcceleratorC* This,
+ /* [in] */ DWORD dwFlipToIndex,
+ /* [in] */ IMediaSample* pMediaSample);
+
+ END_INTERFACE
} IAMVideoAcceleratorCVtbl;
interface IAMVideoAcceleratorC {
- CONST_VTBL struct IAMVideoAcceleratorCVtbl *lpVtbl;
+ CONST_VTBL struct IAMVideoAcceleratorCVtbl* lpVtbl;
};
void HookAMVideoAccelerator(IAMVideoAcceleratorC* pAMVideoAcceleratorC);
diff --git a/src/filters/renderer/VideoRenderers/IQTVideoSurface.h b/src/filters/renderer/VideoRenderers/IQTVideoSurface.h
index f15b026a5..bd4c65c17 100644
--- a/src/filters/renderer/VideoRenderers/IQTVideoSurface.h
+++ b/src/filters/renderer/VideoRenderers/IQTVideoSurface.h
@@ -30,6 +30,6 @@
interface __declspec(uuid("A6AE36F7-A6F2-4157-AF54-6599857E4E20"))
IQTVideoSurface :
public IUnknown {
- STDMETHOD (BeginBlt) (const BITMAP& bm) PURE;
- STDMETHOD (DoBlt) (const BITMAP& bm) PURE;
+ STDMETHOD(BeginBlt)(const BITMAP & bm) PURE;
+ STDMETHOD(DoBlt)(const BITMAP & bm) PURE;
};
diff --git a/src/filters/renderer/VideoRenderers/MacrovisionKicker.cpp b/src/filters/renderer/VideoRenderers/MacrovisionKicker.cpp
index 1de2398c5..ccb42643b 100644
--- a/src/filters/renderer/VideoRenderers/MacrovisionKicker.cpp
+++ b/src/filters/renderer/VideoRenderers/MacrovisionKicker.cpp
@@ -30,7 +30,7 @@
//
CMacrovisionKicker::CMacrovisionKicker(const TCHAR* pName, LPUNKNOWN pUnk)
- : CUnknown(pName, pUnk)
+ : CUnknown(pName, pUnk)
{
}
@@ -40,54 +40,54 @@ CMacrovisionKicker::~CMacrovisionKicker()
void CMacrovisionKicker::SetInner(IUnknown* pUnk)
{
- m_pInner = pUnk;
+ m_pInner = pUnk;
}
STDMETHODIMP CMacrovisionKicker::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- if (riid == __uuidof(IUnknown)) {
- return __super::NonDelegatingQueryInterface(riid, ppv);
- }
- if (riid == __uuidof(IKsPropertySet) && CComQIPtr<IKsPropertySet>(m_pInner)) {
- return GetInterface((IKsPropertySet*)this, ppv);
- }
+ if (riid == __uuidof(IUnknown)) {
+ return __super::NonDelegatingQueryInterface(riid, ppv);
+ }
+ if (riid == __uuidof(IKsPropertySet) && CComQIPtr<IKsPropertySet>(m_pInner)) {
+ return GetInterface((IKsPropertySet*)this, ppv);
+ }
- HRESULT hr = m_pInner ? m_pInner->QueryInterface(riid, ppv) : E_NOINTERFACE;
+ HRESULT hr = m_pInner ? m_pInner->QueryInterface(riid, ppv) : E_NOINTERFACE;
- return SUCCEEDED(hr) ? hr : __super::NonDelegatingQueryInterface(riid, ppv);
+ return SUCCEEDED(hr) ? hr : __super::NonDelegatingQueryInterface(riid, ppv);
}
// IKsPropertySet
STDMETHODIMP CMacrovisionKicker::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength)
{
- if (CComQIPtr<IKsPropertySet> pKsPS = m_pInner) {
- if (PropSet == AM_KSPROPSETID_CopyProt && Id == AM_PROPERTY_COPY_MACROVISION
- /*&& DataLength == 4 && *(DWORD*)pPropertyData*/) {
- TRACE(_T("Oops, no-no-no, no macrovision please\n"));
- return S_OK;
- }
+ if (CComQIPtr<IKsPropertySet> pKsPS = m_pInner) {
+ if (PropSet == AM_KSPROPSETID_CopyProt && Id == AM_PROPERTY_COPY_MACROVISION
+ /*&& DataLength == 4 && *(DWORD*)pPropertyData*/) {
+ TRACE(_T("Oops, no-no-no, no macrovision please\n"));
+ return S_OK;
+ }
- return pKsPS->Set(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength);
- }
+ return pKsPS->Set(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength);
+ }
- return E_UNEXPECTED;
+ return E_UNEXPECTED;
}
STDMETHODIMP CMacrovisionKicker::Get(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength, ULONG* pBytesReturned)
{
- if (CComQIPtr<IKsPropertySet> pKsPS = m_pInner) {
- return pKsPS->Get(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength, pBytesReturned);
- }
+ if (CComQIPtr<IKsPropertySet> pKsPS = m_pInner) {
+ return pKsPS->Get(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength, pBytesReturned);
+ }
- return E_UNEXPECTED;
+ return E_UNEXPECTED;
}
STDMETHODIMP CMacrovisionKicker::QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport)
{
- if (CComQIPtr<IKsPropertySet> pKsPS = m_pInner) {
- return pKsPS->QuerySupported(PropSet, Id, pTypeSupport);
- }
+ if (CComQIPtr<IKsPropertySet> pKsPS = m_pInner) {
+ return pKsPS->QuerySupported(PropSet, Id, pTypeSupport);
+ }
- return E_UNEXPECTED;
+ return E_UNEXPECTED;
}
diff --git a/src/filters/renderer/VideoRenderers/MacrovisionKicker.h b/src/filters/renderer/VideoRenderers/MacrovisionKicker.h
index d26ff0141..c05807f29 100644
--- a/src/filters/renderer/VideoRenderers/MacrovisionKicker.h
+++ b/src/filters/renderer/VideoRenderers/MacrovisionKicker.h
@@ -24,22 +24,22 @@
#pragma once
class CMacrovisionKicker
- : public CUnknown
- , public IKsPropertySet
+ : public CUnknown
+ , public IKsPropertySet
{
- CComPtr<IUnknown> m_pInner;
+ CComPtr<IUnknown> m_pInner;
public:
- CMacrovisionKicker(const TCHAR* pName, LPUNKNOWN pUnk);
- virtual ~CMacrovisionKicker();
+ CMacrovisionKicker(const TCHAR* pName, LPUNKNOWN pUnk);
+ virtual ~CMacrovisionKicker();
- void SetInner(IUnknown* pUnk);
+ void SetInner(IUnknown* pUnk);
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // IKsPropertySet
- STDMETHODIMP Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength);
- STDMETHODIMP Get(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength, ULONG* pBytesReturned);
- STDMETHODIMP QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport);
+ // IKsPropertySet
+ STDMETHODIMP Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength);
+ STDMETHODIMP Get(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength, ULONG* pBytesReturned);
+ STDMETHODIMP QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport);
};
diff --git a/src/filters/renderer/VideoRenderers/OuterEVR.cpp b/src/filters/renderer/VideoRenderers/OuterEVR.cpp
index 277da1f82..23538496f 100644
--- a/src/filters/renderer/VideoRenderers/OuterEVR.cpp
+++ b/src/filters/renderer/VideoRenderers/OuterEVR.cpp
@@ -27,167 +27,178 @@
using namespace DSObjects;
-STDMETHODIMP COuterEVR::EnumPins(__out IEnumPins **ppEnum) {
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR) {
- m_pEVR->QueryInterface(&pEVRBase);
- }
- if (pEVRBase) {
- return pEVRBase->EnumPins(ppEnum);
- }
- return E_NOTIMPL;
+STDMETHODIMP COuterEVR::EnumPins(__out IEnumPins** ppEnum)
+{
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->EnumPins(ppEnum);
+ }
+ return E_NOTIMPL;
}
-STDMETHODIMP COuterEVR::FindPin(LPCWSTR Id, __out IPin **ppPin) {
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR) {
- m_pEVR->QueryInterface(&pEVRBase);
- }
- if (pEVRBase) {
- return pEVRBase->FindPin(Id, ppPin);
- }
- return E_NOTIMPL;
+STDMETHODIMP COuterEVR::FindPin(LPCWSTR Id, __out IPin** ppPin)
+{
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->FindPin(Id, ppPin);
+ }
+ return E_NOTIMPL;
}
-STDMETHODIMP COuterEVR::QueryFilterInfo(__out FILTER_INFO *pInfo) {
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR) {
- m_pEVR->QueryInterface(&pEVRBase);
- }
- if (pEVRBase) {
- return pEVRBase->QueryFilterInfo(pInfo);
- }
- return E_NOTIMPL;
+STDMETHODIMP COuterEVR::QueryFilterInfo(__out FILTER_INFO* pInfo)
+{
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->QueryFilterInfo(pInfo);
+ }
+ return E_NOTIMPL;
}
-STDMETHODIMP COuterEVR::JoinFilterGraph(__in_opt IFilterGraph *pGraph, __in_opt LPCWSTR pName) {
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR) {
- m_pEVR->QueryInterface(&pEVRBase);
- }
- if (pEVRBase) {
- return pEVRBase->JoinFilterGraph(pGraph, pName);
- }
- return E_NOTIMPL;
+STDMETHODIMP COuterEVR::JoinFilterGraph(__in_opt IFilterGraph* pGraph, __in_opt LPCWSTR pName)
+{
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->JoinFilterGraph(pGraph, pName);
+ }
+ return E_NOTIMPL;
}
-STDMETHODIMP COuterEVR::QueryVendorInfo(__out LPWSTR *pVendorInfo) {
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR) {
- m_pEVR->QueryInterface(&pEVRBase);
- }
- if (pEVRBase) {
- return pEVRBase->QueryVendorInfo(pVendorInfo);
- }
- return E_NOTIMPL;
+STDMETHODIMP COuterEVR::QueryVendorInfo(__out LPWSTR* pVendorInfo)
+{
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->QueryVendorInfo(pVendorInfo);
+ }
+ return E_NOTIMPL;
}
-STDMETHODIMP COuterEVR::Stop() {
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR) {
- m_pEVR->QueryInterface(&pEVRBase);
- }
- if (pEVRBase) {
- return pEVRBase->Stop();
- }
- return E_NOTIMPL;
+STDMETHODIMP COuterEVR::Stop()
+{
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->Stop();
+ }
+ return E_NOTIMPL;
}
-STDMETHODIMP COuterEVR::Pause() {
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR) {
- m_pEVR->QueryInterface(&pEVRBase);
- }
- if (pEVRBase) {
- return pEVRBase->Pause();
- }
- return E_NOTIMPL;
+STDMETHODIMP COuterEVR::Pause()
+{
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->Pause();
+ }
+ return E_NOTIMPL;
}
-STDMETHODIMP COuterEVR::Run(REFERENCE_TIME tStart) {
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR) {
- m_pEVR->QueryInterface(&pEVRBase);
- }
- if (pEVRBase) {
- return pEVRBase->Run(tStart);
- }
- return E_NOTIMPL;
+STDMETHODIMP COuterEVR::Run(REFERENCE_TIME tStart)
+{
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->Run(tStart);
+ }
+ return E_NOTIMPL;
}
-STDMETHODIMP COuterEVR::GetState(DWORD dwMilliSecsTimeout, __out FILTER_STATE *State)
+STDMETHODIMP COuterEVR::GetState(DWORD dwMilliSecsTimeout, __out FILTER_STATE* State)
{
- HRESULT ReturnValue;
- if (m_pAllocatorPresenter->GetState(dwMilliSecsTimeout, State, ReturnValue)) {
- return ReturnValue;
- }
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR) {
- m_pEVR->QueryInterface(&pEVRBase);
- }
- if (pEVRBase) {
- return pEVRBase->GetState(dwMilliSecsTimeout, State);
- }
- return E_NOTIMPL;
+ HRESULT ReturnValue;
+ if (m_pAllocatorPresenter->GetState(dwMilliSecsTimeout, State, ReturnValue)) {
+ return ReturnValue;
+ }
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->GetState(dwMilliSecsTimeout, State);
+ }
+ return E_NOTIMPL;
}
-STDMETHODIMP COuterEVR::SetSyncSource(__in_opt IReferenceClock *pClock) {
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR) {
- m_pEVR->QueryInterface(&pEVRBase);
- }
- if (pEVRBase) {
- return pEVRBase->SetSyncSource(pClock);
- }
- return E_NOTIMPL;
+STDMETHODIMP COuterEVR::SetSyncSource(__in_opt IReferenceClock* pClock)
+{
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->SetSyncSource(pClock);
+ }
+ return E_NOTIMPL;
}
-STDMETHODIMP COuterEVR::GetSyncSource(__deref_out_opt IReferenceClock **pClock) {
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR) {
- m_pEVR->QueryInterface(&pEVRBase);
- }
- if (pEVRBase) {
- return pEVRBase->GetSyncSource(pClock);
- }
- return E_NOTIMPL;
+STDMETHODIMP COuterEVR::GetSyncSource(__deref_out_opt IReferenceClock** pClock)
+{
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->GetSyncSource(pClock);
+ }
+ return E_NOTIMPL;
}
-STDMETHODIMP COuterEVR::GetClassID(__RPC__out CLSID *pClassID) {
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR) {
- m_pEVR->QueryInterface(&pEVRBase);
- }
- if (pEVRBase) {
- return pEVRBase->GetClassID(pClassID);
- }
- return E_NOTIMPL;
+STDMETHODIMP COuterEVR::GetClassID(__RPC__out CLSID* pClassID)
+{
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->GetClassID(pClassID);
+ }
+ return E_NOTIMPL;
}
STDMETHODIMP COuterEVR::GetAlphaBitmapParameters(VMR9AlphaBitmap* pBmpParms)
{
- CheckPointer(pBmpParms, E_POINTER);
- CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
- memcpy (pBmpParms, m_pVMR9AlphaBitmap, sizeof(VMR9AlphaBitmap));
- return S_OK;
+ CheckPointer(pBmpParms, E_POINTER);
+ CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
+ memcpy(pBmpParms, m_pVMR9AlphaBitmap, sizeof(VMR9AlphaBitmap));
+ return S_OK;
}
STDMETHODIMP COuterEVR::SetAlphaBitmap(const VMR9AlphaBitmap* pBmpParms)
{
- CheckPointer(pBmpParms, E_POINTER);
- CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
- memcpy (m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
- m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
- m_pAllocatorPresenter->UpdateAlphaBitmap();
- return S_OK;
+ CheckPointer(pBmpParms, E_POINTER);
+ CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
+ memcpy(m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
+ m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
+ m_pAllocatorPresenter->UpdateAlphaBitmap();
+ return S_OK;
}
STDMETHODIMP COuterEVR::UpdateAlphaBitmapParameters(const VMR9AlphaBitmap* pBmpParms)
{
- CheckPointer(pBmpParms, E_POINTER);
- CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
- memcpy (m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
- m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
- m_pAllocatorPresenter->UpdateAlphaBitmap();
- return S_OK;
+ CheckPointer(pBmpParms, E_POINTER);
+ CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
+ memcpy(m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
+ m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
+ m_pAllocatorPresenter->UpdateAlphaBitmap();
+ return S_OK;
}
diff --git a/src/filters/renderer/VideoRenderers/OuterEVR.h b/src/filters/renderer/VideoRenderers/OuterEVR.h
index 5abab719e..45e6dee97 100644
--- a/src/filters/renderer/VideoRenderers/OuterEVR.h
+++ b/src/filters/renderer/VideoRenderers/OuterEVR.h
@@ -25,75 +25,75 @@
/// === Outer EVR
namespace DSObjects
{
- class COuterEVR
- : public CUnknown
- , public IVMRffdshow9
- , public IVMRMixerBitmap9
- , public IBaseFilter
- {
- CComPtr<IUnknown> m_pEVR;
- VMR9AlphaBitmap* m_pVMR9AlphaBitmap;
- CEVRAllocatorPresenter *m_pAllocatorPresenter;
+ class COuterEVR
+ : public CUnknown
+ , public IVMRffdshow9
+ , public IVMRMixerBitmap9
+ , public IBaseFilter
+ {
+ CComPtr<IUnknown> m_pEVR;
+ VMR9AlphaBitmap* m_pVMR9AlphaBitmap;
+ CEVRAllocatorPresenter* m_pAllocatorPresenter;
- public:
- COuterEVR(const TCHAR* pName, LPUNKNOWN pUnk, HRESULT& hr, VMR9AlphaBitmap* pVMR9AlphaBitmap, CEVRAllocatorPresenter *pAllocatorPresenter) : CUnknown(pName, pUnk) {
- hr = m_pEVR.CoCreateInstance(CLSID_EnhancedVideoRenderer, GetOwner());
- m_pVMR9AlphaBitmap = pVMR9AlphaBitmap;
- m_pAllocatorPresenter = pAllocatorPresenter;
- }
+ public:
+ COuterEVR(const TCHAR* pName, LPUNKNOWN pUnk, HRESULT& hr, VMR9AlphaBitmap* pVMR9AlphaBitmap, CEVRAllocatorPresenter* pAllocatorPresenter) : CUnknown(pName, pUnk) {
+ hr = m_pEVR.CoCreateInstance(CLSID_EnhancedVideoRenderer, GetOwner());
+ m_pVMR9AlphaBitmap = pVMR9AlphaBitmap;
+ m_pAllocatorPresenter = pAllocatorPresenter;
+ }
- ~COuterEVR() {}
+ ~COuterEVR() {}
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
- HRESULT hr;
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
+ HRESULT hr;
- if (riid == __uuidof(IVMRMixerBitmap9)) {
- return GetInterface((IVMRMixerBitmap9*)this, ppv);
- }
- if (riid == __uuidof(IMediaFilter)) {
- return GetInterface((IMediaFilter*)this, ppv);
- }
- if (riid == __uuidof(IPersist)) {
- return GetInterface((IPersist*)this, ppv);
- }
- if (riid == __uuidof(IBaseFilter)) {
- return GetInterface((IBaseFilter*)this, ppv);
- }
+ if (riid == __uuidof(IVMRMixerBitmap9)) {
+ return GetInterface((IVMRMixerBitmap9*)this, ppv);
+ }
+ if (riid == __uuidof(IMediaFilter)) {
+ return GetInterface((IMediaFilter*)this, ppv);
+ }
+ if (riid == __uuidof(IPersist)) {
+ return GetInterface((IPersist*)this, ppv);
+ }
+ if (riid == __uuidof(IBaseFilter)) {
+ return GetInterface((IBaseFilter*)this, ppv);
+ }
- hr = m_pEVR ? m_pEVR->QueryInterface(riid, ppv) : E_NOINTERFACE;
- if (m_pEVR && FAILED(hr)) {
- if (riid == __uuidof(IVMRffdshow9)) { // Support ffdshow queueing. We show ffdshow that this is patched Media Player Classic.
- return GetInterface((IVMRffdshow9*)this, ppv);
- }
- }
+ hr = m_pEVR ? m_pEVR->QueryInterface(riid, ppv) : E_NOINTERFACE;
+ if (m_pEVR && FAILED(hr)) {
+ if (riid == __uuidof(IVMRffdshow9)) { // Support ffdshow queueing. We show ffdshow that this is patched Media Player Classic.
+ return GetInterface((IVMRffdshow9*)this, ppv);
+ }
+ }
- return SUCCEEDED(hr) ? hr : __super::NonDelegatingQueryInterface(riid, ppv);
- }
+ return SUCCEEDED(hr) ? hr : __super::NonDelegatingQueryInterface(riid, ppv);
+ }
- // IBaseFilter
- STDMETHODIMP EnumPins(__out IEnumPins **ppEnum);
- STDMETHODIMP FindPin(LPCWSTR Id, __out IPin **ppPin);
- STDMETHODIMP QueryFilterInfo(__out FILTER_INFO *pInfo);
- STDMETHODIMP JoinFilterGraph(__in_opt IFilterGraph *pGraph, __in_opt LPCWSTR pName);
- STDMETHODIMP QueryVendorInfo(__out LPWSTR *pVendorInfo);
- STDMETHODIMP Stop();
- STDMETHODIMP Pause();
- STDMETHODIMP Run(REFERENCE_TIME tStart);
- STDMETHODIMP GetState( DWORD dwMilliSecsTimeout, __out FILTER_STATE *State);
- STDMETHODIMP SetSyncSource(__in_opt IReferenceClock *pClock);
- STDMETHODIMP GetSyncSource(__deref_out_opt IReferenceClock **pClock);
- STDMETHODIMP GetClassID(__RPC__out CLSID *pClassID);
+ // IBaseFilter
+ STDMETHODIMP EnumPins(__out IEnumPins** ppEnum);
+ STDMETHODIMP FindPin(LPCWSTR Id, __out IPin** ppPin);
+ STDMETHODIMP QueryFilterInfo(__out FILTER_INFO* pInfo);
+ STDMETHODIMP JoinFilterGraph(__in_opt IFilterGraph* pGraph, __in_opt LPCWSTR pName);
+ STDMETHODIMP QueryVendorInfo(__out LPWSTR* pVendorInfo);
+ STDMETHODIMP Stop();
+ STDMETHODIMP Pause();
+ STDMETHODIMP Run(REFERENCE_TIME tStart);
+ STDMETHODIMP GetState(DWORD dwMilliSecsTimeout, __out FILTER_STATE* State);
+ STDMETHODIMP SetSyncSource(__in_opt IReferenceClock* pClock);
+ STDMETHODIMP GetSyncSource(__deref_out_opt IReferenceClock** pClock);
+ STDMETHODIMP GetClassID(__RPC__out CLSID* pClassID);
- // IVMRffdshow9
- STDMETHODIMP support_ffdshow() {
- queue_ffdshow_support = true;
- return S_OK;
- }
+ // IVMRffdshow9
+ STDMETHODIMP support_ffdshow() {
+ queue_ffdshow_support = true;
+ return S_OK;
+ }
- // IVMRMixerBitmap9
- STDMETHODIMP GetAlphaBitmapParameters(VMR9AlphaBitmap* pBmpParms);
- STDMETHODIMP SetAlphaBitmap(const VMR9AlphaBitmap* pBmpParms);
- STDMETHODIMP UpdateAlphaBitmapParameters(const VMR9AlphaBitmap* pBmpParms);
- };
+ // IVMRMixerBitmap9
+ STDMETHODIMP GetAlphaBitmapParameters(VMR9AlphaBitmap* pBmpParms);
+ STDMETHODIMP SetAlphaBitmap(const VMR9AlphaBitmap* pBmpParms);
+ STDMETHODIMP UpdateAlphaBitmapParameters(const VMR9AlphaBitmap* pBmpParms);
+ };
}
diff --git a/src/filters/renderer/VideoRenderers/OuterVMR.cpp b/src/filters/renderer/VideoRenderers/OuterVMR.cpp
index a5f5738cb..af4a2c910 100644
--- a/src/filters/renderer/VideoRenderers/OuterVMR.cpp
+++ b/src/filters/renderer/VideoRenderers/OuterVMR.cpp
@@ -27,134 +27,146 @@
using namespace DSObjects;
-STDMETHODIMP COuterVMR9::GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight) {
- if (CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
- return pWC9->GetNativeVideoSize(lpWidth, lpHeight, lpARWidth, lpARHeight);
- }
+STDMETHODIMP COuterVMR9::GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight)
+{
+ if (CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
+ return pWC9->GetNativeVideoSize(lpWidth, lpHeight, lpARWidth, lpARHeight);
+ }
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
-STDMETHODIMP COuterVMR9::GetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect) {
- if (CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
- return pWC9->GetVideoPosition(lpSRCRect, lpDSTRect);
- }
+STDMETHODIMP COuterVMR9::GetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect)
+{
+ if (CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
+ return pWC9->GetVideoPosition(lpSRCRect, lpDSTRect);
+ }
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
-STDMETHODIMP COuterVMR9::GetAspectRatioMode(DWORD* lpAspectRatioMode) {
- if (CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
- *lpAspectRatioMode = VMR_ARMODE_NONE;
- return S_OK;
- }
+STDMETHODIMP COuterVMR9::GetAspectRatioMode(DWORD* lpAspectRatioMode)
+{
+ if (CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
+ *lpAspectRatioMode = VMR_ARMODE_NONE;
+ return S_OK;
+ }
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IVideoWindow
-STDMETHODIMP COuterVMR9::get_Width(long* pWidth) {
- if (CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
- CRect s, d;
- HRESULT hr = pWC9->GetVideoPosition(&s, &d);
- *pWidth = d.Width();
- return hr;
- }
-
- return E_NOTIMPL;
+STDMETHODIMP COuterVMR9::get_Width(long* pWidth)
+{
+ if (CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
+ CRect s, d;
+ HRESULT hr = pWC9->GetVideoPosition(&s, &d);
+ *pWidth = d.Width();
+ return hr;
+ }
+
+ return E_NOTIMPL;
}
-STDMETHODIMP COuterVMR9::get_Height(long* pHeight) {
- if (CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
- CRect s, d;
- HRESULT hr = pWC9->GetVideoPosition(&s, &d);
- *pHeight = d.Height();
- return hr;
- }
+STDMETHODIMP COuterVMR9::get_Height(long* pHeight)
+{
+ if (CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
+ CRect s, d;
+ HRESULT hr = pWC9->GetVideoPosition(&s, &d);
+ *pHeight = d.Height();
+ return hr;
+ }
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IBasicVideo2
-STDMETHODIMP COuterVMR9::GetSourcePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight) {
- // DVD Nav. bug workaround fix
- {
- *pLeft = *pTop = 0;
- return GetVideoSize(pWidth, pHeight);
- }
- /*
- if (CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR)
- {
- CRect s, d;
- HRESULT hr = pWC9->GetVideoPosition(&s, &d);
- *pLeft = s.left;
- *pTop = s.top;
- *pWidth = s.Width();
- *pHeight = s.Height();
- return hr;
- }
- return E_NOTIMPL;
- */
+STDMETHODIMP COuterVMR9::GetSourcePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight)
+{
+ // DVD Nav. bug workaround fix
+ {
+ *pLeft = *pTop = 0;
+ return GetVideoSize(pWidth, pHeight);
+ }
+ /*
+ if (CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR)
+ {
+ CRect s, d;
+ HRESULT hr = pWC9->GetVideoPosition(&s, &d);
+ *pLeft = s.left;
+ *pTop = s.top;
+ *pWidth = s.Width();
+ *pHeight = s.Height();
+ return hr;
+ }
+ return E_NOTIMPL;
+ */
}
-STDMETHODIMP COuterVMR9::GetDestinationPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight) {
- if (CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
- CRect s, d;
- HRESULT hr = pWC9->GetVideoPosition(&s, &d);
- *pLeft = d.left;
- *pTop = d.top;
- *pWidth = d.Width();
- *pHeight = d.Height();
- return hr;
- }
-
- return E_NOTIMPL;
+STDMETHODIMP COuterVMR9::GetDestinationPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight)
+{
+ if (CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
+ CRect s, d;
+ HRESULT hr = pWC9->GetVideoPosition(&s, &d);
+ *pLeft = d.left;
+ *pTop = d.top;
+ *pWidth = d.Width();
+ *pHeight = d.Height();
+ return hr;
+ }
+
+ return E_NOTIMPL;
}
-STDMETHODIMP COuterVMR9::GetVideoSize(long* pWidth, long* pHeight) {
- if (CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
- LONG aw, ah;
- // return pWC9->GetNativeVideoSize(pWidth, pHeight, &aw, &ah);
- // DVD Nav. bug workaround fix
- HRESULT hr = pWC9->GetNativeVideoSize(pWidth, pHeight, &aw, &ah);
- *pWidth = *pHeight * aw / ah;
- return hr;
- }
-
- return E_NOTIMPL;
+STDMETHODIMP COuterVMR9::GetVideoSize(long* pWidth, long* pHeight)
+{
+ if (CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
+ LONG aw, ah;
+ // return pWC9->GetNativeVideoSize(pWidth, pHeight, &aw, &ah);
+ // DVD Nav. bug workaround fix
+ HRESULT hr = pWC9->GetNativeVideoSize(pWidth, pHeight, &aw, &ah);
+ *pWidth = *pHeight * aw / ah;
+ return hr;
+ }
+
+ return E_NOTIMPL;
}
-STDMETHODIMP COuterVMR9::GetPreferredAspectRatio(long* plAspectX, long* plAspectY) {
- if (CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
- LONG w, h;
- return pWC9->GetNativeVideoSize(&w, &h, plAspectX, plAspectY);
- }
+STDMETHODIMP COuterVMR9::GetPreferredAspectRatio(long* plAspectX, long* plAspectY)
+{
+ if (CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
+ LONG w, h;
+ return pWC9->GetNativeVideoSize(&w, &h, plAspectX, plAspectY);
+ }
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IVMRMixerBitmap9
-STDMETHODIMP COuterVMR9::GetAlphaBitmapParameters(VMR9AlphaBitmap* pBmpParms) {
- CheckPointer(pBmpParms, E_POINTER);
- CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
- memcpy (pBmpParms, m_pVMR9AlphaBitmap, sizeof(VMR9AlphaBitmap));
- return S_OK;
+STDMETHODIMP COuterVMR9::GetAlphaBitmapParameters(VMR9AlphaBitmap* pBmpParms)
+{
+ CheckPointer(pBmpParms, E_POINTER);
+ CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
+ memcpy(pBmpParms, m_pVMR9AlphaBitmap, sizeof(VMR9AlphaBitmap));
+ return S_OK;
}
-STDMETHODIMP COuterVMR9::SetAlphaBitmap(const VMR9AlphaBitmap* pBmpParms) {
- CheckPointer(pBmpParms, E_POINTER);
- CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
- memcpy (m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
- m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
- m_pAllocatorPresenter->UpdateAlphaBitmap();
- return S_OK;
+STDMETHODIMP COuterVMR9::SetAlphaBitmap(const VMR9AlphaBitmap* pBmpParms)
+{
+ CheckPointer(pBmpParms, E_POINTER);
+ CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
+ memcpy(m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
+ m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
+ m_pAllocatorPresenter->UpdateAlphaBitmap();
+ return S_OK;
}
-STDMETHODIMP COuterVMR9::UpdateAlphaBitmapParameters(const VMR9AlphaBitmap* pBmpParms) {
- CheckPointer(pBmpParms, E_POINTER);
- CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
- memcpy (m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
- m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
- m_pAllocatorPresenter->UpdateAlphaBitmap();
- return S_OK;
+STDMETHODIMP COuterVMR9::UpdateAlphaBitmapParameters(const VMR9AlphaBitmap* pBmpParms)
+{
+ CheckPointer(pBmpParms, E_POINTER);
+ CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
+ memcpy(m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
+ m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
+ m_pAllocatorPresenter->UpdateAlphaBitmap();
+ return S_OK;
}
diff --git a/src/filters/renderer/VideoRenderers/OuterVMR.h b/src/filters/renderer/VideoRenderers/OuterVMR.h
index 8b71014d4..153a068cd 100644
--- a/src/filters/renderer/VideoRenderers/OuterVMR.h
+++ b/src/filters/renderer/VideoRenderers/OuterVMR.h
@@ -24,343 +24,343 @@
namespace DSObjects
{
- class COuterVMR9
- : public CUnknown
- , public IVideoWindow
- , public IBasicVideo2
- , public IVMRWindowlessControl
- , public IVMRffdshow9
- , public IVMRMixerBitmap9
- {
- CComPtr<IUnknown> m_pVMR;
- VMR9AlphaBitmap* m_pVMR9AlphaBitmap;
- CDX9AllocatorPresenter *m_pAllocatorPresenter;
+ class COuterVMR9
+ : public CUnknown
+ , public IVideoWindow
+ , public IBasicVideo2
+ , public IVMRWindowlessControl
+ , public IVMRffdshow9
+ , public IVMRMixerBitmap9
+ {
+ CComPtr<IUnknown> m_pVMR;
+ VMR9AlphaBitmap* m_pVMR9AlphaBitmap;
+ CDX9AllocatorPresenter* m_pAllocatorPresenter;
- public:
+ public:
- COuterVMR9(const TCHAR* pName, LPUNKNOWN pUnk, VMR9AlphaBitmap* pVMR9AlphaBitmap, CDX9AllocatorPresenter *_pAllocatorPresenter) : CUnknown(pName, pUnk) {
- m_pVMR.CoCreateInstance(CLSID_VideoMixingRenderer9, GetOwner());
- m_pVMR9AlphaBitmap = pVMR9AlphaBitmap;
- m_pAllocatorPresenter = _pAllocatorPresenter;
- }
+ COuterVMR9(const TCHAR* pName, LPUNKNOWN pUnk, VMR9AlphaBitmap* pVMR9AlphaBitmap, CDX9AllocatorPresenter* _pAllocatorPresenter) : CUnknown(pName, pUnk) {
+ m_pVMR.CoCreateInstance(CLSID_VideoMixingRenderer9, GetOwner());
+ m_pVMR9AlphaBitmap = pVMR9AlphaBitmap;
+ m_pAllocatorPresenter = _pAllocatorPresenter;
+ }
- ~COuterVMR9() {
- m_pVMR = NULL;
- }
+ ~COuterVMR9() {
+ m_pVMR = NULL;
+ }
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
- HRESULT hr;
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
+ HRESULT hr;
- // Casimir666 : in renderless mode, do the inlaying in place of VMR
- if (riid == __uuidof(IVMRMixerBitmap9)) {
- return GetInterface((IVMRMixerBitmap9*)this, ppv);
- }
+ // Casimir666 : in renderless mode, do the inlaying in place of VMR
+ if (riid == __uuidof(IVMRMixerBitmap9)) {
+ return GetInterface((IVMRMixerBitmap9*)this, ppv);
+ }
- hr = m_pVMR ? m_pVMR->QueryInterface(riid, ppv) : E_NOINTERFACE;
- if (m_pVMR && FAILED(hr)) {
- if (riid == __uuidof(IVideoWindow)) {
- return GetInterface((IVideoWindow*)this, ppv);
- }
- if (riid == __uuidof(IBasicVideo)) {
- return GetInterface((IBasicVideo*)this, ppv);
- }
- if (riid == __uuidof(IBasicVideo2)) {
- return GetInterface((IBasicVideo2*)this, ppv);
- }
- if (riid == __uuidof(IVMRffdshow9)) { // Support ffdshow queueing. We show ffdshow that this is patched Media Player Classic.
- return GetInterface((IVMRffdshow9*)this, ppv);
- }
- /* if (riid == __uuidof(IVMRWindowlessControl))
- return GetInterface((IVMRWindowlessControl*)this, ppv);
- */
- }
+ hr = m_pVMR ? m_pVMR->QueryInterface(riid, ppv) : E_NOINTERFACE;
+ if (m_pVMR && FAILED(hr)) {
+ if (riid == __uuidof(IVideoWindow)) {
+ return GetInterface((IVideoWindow*)this, ppv);
+ }
+ if (riid == __uuidof(IBasicVideo)) {
+ return GetInterface((IBasicVideo*)this, ppv);
+ }
+ if (riid == __uuidof(IBasicVideo2)) {
+ return GetInterface((IBasicVideo2*)this, ppv);
+ }
+ if (riid == __uuidof(IVMRffdshow9)) { // Support ffdshow queueing. We show ffdshow that this is patched Media Player Classic.
+ return GetInterface((IVMRffdshow9*)this, ppv);
+ }
+ /* if (riid == __uuidof(IVMRWindowlessControl))
+ return GetInterface((IVMRWindowlessControl*)this, ppv);
+ */
+ }
- return SUCCEEDED(hr) ? hr : __super::NonDelegatingQueryInterface(riid, ppv);
- }
+ return SUCCEEDED(hr) ? hr : __super::NonDelegatingQueryInterface(riid, ppv);
+ }
- // IVMRWindowlessControl
+ // IVMRWindowlessControl
- STDMETHODIMP GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight);
+ STDMETHODIMP GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight);
- STDMETHODIMP GetMinIdealVideoSize(LONG* lpWidth, LONG* lpHeight) {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetMaxIdealVideoSize(LONG* lpWidth, LONG* lpHeight) {
- return E_NOTIMPL;
- }
- STDMETHODIMP SetVideoPosition(const LPRECT lpSRCRect, const LPRECT lpDSTRect) {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect);
+ STDMETHODIMP GetMinIdealVideoSize(LONG* lpWidth, LONG* lpHeight) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP GetMaxIdealVideoSize(LONG* lpWidth, LONG* lpHeight) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP SetVideoPosition(const LPRECT lpSRCRect, const LPRECT lpDSTRect) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP GetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect);
- STDMETHODIMP GetAspectRatioMode(DWORD* lpAspectRatioMode);
+ STDMETHODIMP GetAspectRatioMode(DWORD* lpAspectRatioMode);
- STDMETHODIMP SetAspectRatioMode(DWORD AspectRatioMode) {
- return E_NOTIMPL;
- }
- STDMETHODIMP SetVideoClippingWindow(HWND hwnd) {
- return E_NOTIMPL;
- }
- STDMETHODIMP RepaintVideo(HWND hwnd, HDC hdc) {
- return E_NOTIMPL;
- }
- STDMETHODIMP DisplayModeChanged() {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetCurrentImage(BYTE** lpDib) {
- return E_NOTIMPL;
- }
- STDMETHODIMP SetBorderColor(COLORREF Clr) {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetBorderColor(COLORREF* lpClr) {
- return E_NOTIMPL;
- }
- STDMETHODIMP SetColorKey(COLORREF Clr) {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetColorKey(COLORREF* lpClr) {
- return E_NOTIMPL;
- }
+ STDMETHODIMP SetAspectRatioMode(DWORD AspectRatioMode) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP SetVideoClippingWindow(HWND hwnd) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP RepaintVideo(HWND hwnd, HDC hdc) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP DisplayModeChanged() {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP GetCurrentImage(BYTE** lpDib) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP SetBorderColor(COLORREF Clr) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP GetBorderColor(COLORREF* lpClr) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP SetColorKey(COLORREF Clr) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP GetColorKey(COLORREF* lpClr) {
+ return E_NOTIMPL;
+ }
- // IVideoWindow
- STDMETHODIMP GetTypeInfoCount(UINT* pctinfo) {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo) {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId) {
- return E_NOTIMPL;
- }
- STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr) {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_Caption(BSTR strCaption) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_Caption(BSTR* strCaption) {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_WindowStyle(long WindowStyle) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_WindowStyle(long* WindowStyle) {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_WindowStyleEx(long WindowStyleEx) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_WindowStyleEx(long* WindowStyleEx) {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_AutoShow(long AutoShow) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_AutoShow(long* AutoShow) {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_WindowState(long WindowState) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_WindowState(long* WindowState) {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_BackgroundPalette(long BackgroundPalette) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_BackgroundPalette(long* pBackgroundPalette) {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_Visible(long Visible) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_Visible(long* pVisible) {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_Left(long Left) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_Left(long* pLeft) {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_Width(long Width) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_Width(long* pWidth);
+ // IVideoWindow
+ STDMETHODIMP GetTypeInfoCount(UINT* pctinfo) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP put_Caption(BSTR strCaption) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_Caption(BSTR* strCaption) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP put_WindowStyle(long WindowStyle) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_WindowStyle(long* WindowStyle) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP put_WindowStyleEx(long WindowStyleEx) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_WindowStyleEx(long* WindowStyleEx) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP put_AutoShow(long AutoShow) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_AutoShow(long* AutoShow) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP put_WindowState(long WindowState) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_WindowState(long* WindowState) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP put_BackgroundPalette(long BackgroundPalette) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_BackgroundPalette(long* pBackgroundPalette) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP put_Visible(long Visible) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_Visible(long* pVisible) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP put_Left(long Left) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_Left(long* pLeft) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP put_Width(long Width) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_Width(long* pWidth);
- STDMETHODIMP put_Top(long Top) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_Top(long* pTop) {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_Height(long Height) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_Height(long* pHeight);
+ STDMETHODIMP put_Top(long Top) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_Top(long* pTop) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP put_Height(long Height) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_Height(long* pHeight);
- STDMETHODIMP put_Owner(OAHWND Owner) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_Owner(OAHWND* Owner) {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_MessageDrain(OAHWND Drain) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_MessageDrain(OAHWND* Drain) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_BorderColor(long* Color) {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_BorderColor(long Color) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_FullScreenMode(long* FullScreenMode) {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_FullScreenMode(long FullScreenMode) {
- return E_NOTIMPL;
- }
- STDMETHODIMP SetWindowForeground(long Focus) {
- return E_NOTIMPL;
- }
- STDMETHODIMP NotifyOwnerMessage(OAHWND hwnd, long uMsg, LONG_PTR wParam, LONG_PTR lParam) {
- return E_NOTIMPL;
- }
- STDMETHODIMP SetWindowPosition(long Left, long Top, long Width, long Height) {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetWindowPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight) {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetMinIdealImageSize(long* pWidth, long* pHeight) {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetMaxIdealImageSize(long* pWidth, long* pHeight) {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetRestorePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight) {
- return E_NOTIMPL;
- }
- STDMETHODIMP HideCursor(long HideCursor) {
- return E_NOTIMPL;
- }
- STDMETHODIMP IsCursorHidden(long* CursorHidden) {
- return E_NOTIMPL;
- }
+ STDMETHODIMP put_Owner(OAHWND Owner) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_Owner(OAHWND* Owner) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP put_MessageDrain(OAHWND Drain) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_MessageDrain(OAHWND* Drain) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_BorderColor(long* Color) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP put_BorderColor(long Color) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_FullScreenMode(long* FullScreenMode) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP put_FullScreenMode(long FullScreenMode) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP SetWindowForeground(long Focus) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP NotifyOwnerMessage(OAHWND hwnd, long uMsg, LONG_PTR wParam, LONG_PTR lParam) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP SetWindowPosition(long Left, long Top, long Width, long Height) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP GetWindowPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP GetMinIdealImageSize(long* pWidth, long* pHeight) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP GetMaxIdealImageSize(long* pWidth, long* pHeight) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP GetRestorePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP HideCursor(long HideCursor) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP IsCursorHidden(long* CursorHidden) {
+ return E_NOTIMPL;
+ }
- // IBasicVideo2
- STDMETHODIMP get_AvgTimePerFrame(REFTIME* pAvgTimePerFrame) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_BitRate(long* pBitRate) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_BitErrorRate(long* pBitErrorRate) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_VideoWidth(long* pVideoWidth) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_VideoHeight(long* pVideoHeight) {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_SourceLeft(long SourceLeft) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_SourceLeft(long* pSourceLeft) {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_SourceWidth(long SourceWidth) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_SourceWidth(long* pSourceWidth) {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_SourceTop(long SourceTop) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_SourceTop(long* pSourceTop) {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_SourceHeight(long SourceHeight) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_SourceHeight(long* pSourceHeight) {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_DestinationLeft(long DestinationLeft) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_DestinationLeft(long* pDestinationLeft) {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_DestinationWidth(long DestinationWidth) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_DestinationWidth(long* pDestinationWidth) {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_DestinationTop(long DestinationTop) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_DestinationTop(long* pDestinationTop) {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_DestinationHeight(long DestinationHeight) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_DestinationHeight(long* pDestinationHeight) {
- return E_NOTIMPL;
- }
- STDMETHODIMP SetSourcePosition(long Left, long Top, long Width, long Height) {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetSourcePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight);
+ // IBasicVideo2
+ STDMETHODIMP get_AvgTimePerFrame(REFTIME* pAvgTimePerFrame) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_BitRate(long* pBitRate) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_BitErrorRate(long* pBitErrorRate) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_VideoWidth(long* pVideoWidth) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_VideoHeight(long* pVideoHeight) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP put_SourceLeft(long SourceLeft) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_SourceLeft(long* pSourceLeft) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP put_SourceWidth(long SourceWidth) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_SourceWidth(long* pSourceWidth) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP put_SourceTop(long SourceTop) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_SourceTop(long* pSourceTop) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP put_SourceHeight(long SourceHeight) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_SourceHeight(long* pSourceHeight) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP put_DestinationLeft(long DestinationLeft) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_DestinationLeft(long* pDestinationLeft) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP put_DestinationWidth(long DestinationWidth) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_DestinationWidth(long* pDestinationWidth) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP put_DestinationTop(long DestinationTop) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_DestinationTop(long* pDestinationTop) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP put_DestinationHeight(long DestinationHeight) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_DestinationHeight(long* pDestinationHeight) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP SetSourcePosition(long Left, long Top, long Width, long Height) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP GetSourcePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight);
- STDMETHODIMP SetDefaultSourcePosition() {
- return E_NOTIMPL;
- }
- STDMETHODIMP SetDestinationPosition(long Left, long Top, long Width, long Height) {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetDestinationPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight);
+ STDMETHODIMP SetDefaultSourcePosition() {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP SetDestinationPosition(long Left, long Top, long Width, long Height) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP GetDestinationPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight);
- STDMETHODIMP SetDefaultDestinationPosition() {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetVideoSize(long* pWidth, long* pHeight);
+ STDMETHODIMP SetDefaultDestinationPosition() {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP GetVideoSize(long* pWidth, long* pHeight);
- // IVMRffdshow9
- STDMETHODIMP support_ffdshow() {
- queue_ffdshow_support = true;
- return S_OK;
- }
+ // IVMRffdshow9
+ STDMETHODIMP support_ffdshow() {
+ queue_ffdshow_support = true;
+ return S_OK;
+ }
- STDMETHODIMP GetVideoPaletteEntries(long StartIndex, long Entries, long* pRetrieved, long* pPalette) {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetCurrentImage(long* pBufferSize, long* pDIBImage) {
- return E_NOTIMPL;
- }
- STDMETHODIMP IsUsingDefaultSource() {
- return E_NOTIMPL;
- }
- STDMETHODIMP IsUsingDefaultDestination() {
- return E_NOTIMPL;
- }
+ STDMETHODIMP GetVideoPaletteEntries(long StartIndex, long Entries, long* pRetrieved, long* pPalette) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP GetCurrentImage(long* pBufferSize, long* pDIBImage) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP IsUsingDefaultSource() {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP IsUsingDefaultDestination() {
+ return E_NOTIMPL;
+ }
- STDMETHODIMP GetPreferredAspectRatio(long* plAspectX, long* plAspectY);
+ STDMETHODIMP GetPreferredAspectRatio(long* plAspectX, long* plAspectY);
- // IVMRMixerBitmap9
- STDMETHODIMP GetAlphaBitmapParameters(VMR9AlphaBitmap* pBmpParms);
+ // IVMRMixerBitmap9
+ STDMETHODIMP GetAlphaBitmapParameters(VMR9AlphaBitmap* pBmpParms);
- STDMETHODIMP SetAlphaBitmap(const VMR9AlphaBitmap* pBmpParms);
+ STDMETHODIMP SetAlphaBitmap(const VMR9AlphaBitmap* pBmpParms);
- STDMETHODIMP UpdateAlphaBitmapParameters(const VMR9AlphaBitmap* pBmpParms);
- };
+ STDMETHODIMP UpdateAlphaBitmapParameters(const VMR9AlphaBitmap* pBmpParms);
+ };
}
diff --git a/src/filters/renderer/VideoRenderers/PixelShaderCompiler.cpp b/src/filters/renderer/VideoRenderers/PixelShaderCompiler.cpp
index adb353346..95cfa7d1e 100644
--- a/src/filters/renderer/VideoRenderers/PixelShaderCompiler.cpp
+++ b/src/filters/renderer/VideoRenderers/PixelShaderCompiler.cpp
@@ -28,25 +28,25 @@
CPixelShaderCompiler::CPixelShaderCompiler(IDirect3DDevice9* pD3DDev, bool fStaySilent)
- : m_pD3DDev(pD3DDev)
- , m_pD3DXCompileShader(NULL)
- , m_pD3DXDisassembleShader(NULL)
+ : m_pD3DDev(pD3DDev)
+ , m_pD3DXCompileShader(NULL)
+ , m_pD3DXDisassembleShader(NULL)
{
- HINSTANCE hDll;
- hDll = GetRenderersData()->GetD3X9Dll();
-
- if (hDll) {
- m_pD3DXCompileShader = (D3DXCompileShaderPtr)GetProcAddress(hDll, "D3DXCompileShader");
- m_pD3DXDisassembleShader = (D3DXDisassembleShaderPtr)GetProcAddress(hDll, "D3DXDisassembleShader");
- }
-
- if (!fStaySilent) {
- if (!hDll) {
- AfxMessageBox(IDS_PIXELSHADERCOMPILER_0, MB_ICONWARNING | MB_OK, 0);
- } else if (!m_pD3DXCompileShader || !m_pD3DXDisassembleShader) {
- AfxMessageBox(IDS_PIXELSHADERCOMPILER_1, MB_ICONWARNING | MB_OK, 0);
- }
- }
+ HINSTANCE hDll;
+ hDll = GetRenderersData()->GetD3X9Dll();
+
+ if (hDll) {
+ m_pD3DXCompileShader = (D3DXCompileShaderPtr)GetProcAddress(hDll, "D3DXCompileShader");
+ m_pD3DXDisassembleShader = (D3DXDisassembleShaderPtr)GetProcAddress(hDll, "D3DXDisassembleShader");
+ }
+
+ if (!fStaySilent) {
+ if (!hDll) {
+ AfxMessageBox(IDS_PIXELSHADERCOMPILER_0, MB_ICONWARNING | MB_OK, 0);
+ } else if (!m_pD3DXCompileShader || !m_pD3DXDisassembleShader) {
+ AfxMessageBox(IDS_PIXELSHADERCOMPILER_1, MB_ICONWARNING | MB_OK, 0);
+ }
+ }
}
CPixelShaderCompiler::~CPixelShaderCompiler()
@@ -54,54 +54,54 @@ CPixelShaderCompiler::~CPixelShaderCompiler()
}
HRESULT CPixelShaderCompiler::CompileShader(
- LPCSTR pSrcData,
- LPCSTR pFunctionName,
- LPCSTR pProfile,
- DWORD Flags,
- IDirect3DPixelShader9** ppPixelShader,
- CString* disasm,
- CString* errmsg)
+ LPCSTR pSrcData,
+ LPCSTR pFunctionName,
+ LPCSTR pProfile,
+ DWORD Flags,
+ IDirect3DPixelShader9** ppPixelShader,
+ CString* disasm,
+ CString* errmsg)
{
- if (!m_pD3DXCompileShader || !m_pD3DXDisassembleShader) {
- return E_FAIL;
- }
-
- HRESULT hr;
-
- CComPtr<ID3DXBuffer> pShader, pDisAsm, pErrorMsgs;
- hr = m_pD3DXCompileShader(pSrcData, (UINT)strlen(pSrcData), NULL, NULL, pFunctionName, pProfile, Flags, &pShader, &pErrorMsgs, NULL);
-
- if (FAILED(hr)) {
- if (errmsg) {
- CStringA msg = "Unexpected compiler error";
-
- if (pErrorMsgs) {
- int len = pErrorMsgs->GetBufferSize();
- memcpy(msg.GetBufferSetLength(len), pErrorMsgs->GetBufferPointer(), len);
- }
-
- *errmsg = msg;
- }
-
- return hr;
- }
-
- if (ppPixelShader) {
- if (!m_pD3DDev) {
- return E_FAIL;
- }
- hr = m_pD3DDev->CreatePixelShader((DWORD*)pShader->GetBufferPointer(), ppPixelShader);
- if (FAILED(hr)) {
- return hr;
- }
- }
-
- if (disasm) {
- hr = m_pD3DXDisassembleShader((DWORD*)pShader->GetBufferPointer(), FALSE, NULL, &pDisAsm);
- if (SUCCEEDED(hr) && pDisAsm) {
- *disasm = CStringA((const char*)pDisAsm->GetBufferPointer());
- }
- }
-
- return S_OK;
+ if (!m_pD3DXCompileShader || !m_pD3DXDisassembleShader) {
+ return E_FAIL;
+ }
+
+ HRESULT hr;
+
+ CComPtr<ID3DXBuffer> pShader, pDisAsm, pErrorMsgs;
+ hr = m_pD3DXCompileShader(pSrcData, (UINT)strlen(pSrcData), NULL, NULL, pFunctionName, pProfile, Flags, &pShader, &pErrorMsgs, NULL);
+
+ if (FAILED(hr)) {
+ if (errmsg) {
+ CStringA msg = "Unexpected compiler error";
+
+ if (pErrorMsgs) {
+ int len = pErrorMsgs->GetBufferSize();
+ memcpy(msg.GetBufferSetLength(len), pErrorMsgs->GetBufferPointer(), len);
+ }
+
+ *errmsg = msg;
+ }
+
+ return hr;
+ }
+
+ if (ppPixelShader) {
+ if (!m_pD3DDev) {
+ return E_FAIL;
+ }
+ hr = m_pD3DDev->CreatePixelShader((DWORD*)pShader->GetBufferPointer(), ppPixelShader);
+ if (FAILED(hr)) {
+ return hr;
+ }
+ }
+
+ if (disasm) {
+ hr = m_pD3DXDisassembleShader((DWORD*)pShader->GetBufferPointer(), FALSE, NULL, &pDisAsm);
+ if (SUCCEEDED(hr) && pDisAsm) {
+ *disasm = CStringA((const char*)pDisAsm->GetBufferPointer());
+ }
+ }
+
+ return S_OK;
}
diff --git a/src/filters/renderer/VideoRenderers/PixelShaderCompiler.h b/src/filters/renderer/VideoRenderers/PixelShaderCompiler.h
index 5c429fb82..45bc68b06 100644
--- a/src/filters/renderer/VideoRenderers/PixelShaderCompiler.h
+++ b/src/filters/renderer/VideoRenderers/PixelShaderCompiler.h
@@ -28,39 +28,39 @@
class CPixelShaderCompiler
{
- typedef HRESULT (WINAPI * D3DXCompileShaderPtr) (
- LPCSTR pSrcData,
- UINT SrcDataLen,
- CONST D3DXMACRO* pDefines,
- LPD3DXINCLUDE pInclude,
- LPCSTR pFunctionName,
- LPCSTR pProfile,
- DWORD Flags,
- LPD3DXBUFFER* ppShader,
- LPD3DXBUFFER* ppErrorMsgs,
- LPD3DXCONSTANTTABLE* ppConstantTable);
+ typedef HRESULT(WINAPI* D3DXCompileShaderPtr)(
+ LPCSTR pSrcData,
+ UINT SrcDataLen,
+ CONST D3DXMACRO* pDefines,
+ LPD3DXINCLUDE pInclude,
+ LPCSTR pFunctionName,
+ LPCSTR pProfile,
+ DWORD Flags,
+ LPD3DXBUFFER* ppShader,
+ LPD3DXBUFFER* ppErrorMsgs,
+ LPD3DXCONSTANTTABLE* ppConstantTable);
- typedef HRESULT (WINAPI * D3DXDisassembleShaderPtr) (
- CONST DWORD* pShader,
- bool EnableColorCode,
- LPCSTR pComments,
- LPD3DXBUFFER* ppDisassembly);
+ typedef HRESULT(WINAPI* D3DXDisassembleShaderPtr)(
+ CONST DWORD* pShader,
+ bool EnableColorCode,
+ LPCSTR pComments,
+ LPD3DXBUFFER* ppDisassembly);
- D3DXCompileShaderPtr m_pD3DXCompileShader;
- D3DXDisassembleShaderPtr m_pD3DXDisassembleShader;
+ D3DXCompileShaderPtr m_pD3DXCompileShader;
+ D3DXDisassembleShaderPtr m_pD3DXDisassembleShader;
- CComPtr<IDirect3DDevice9> m_pD3DDev;
+ CComPtr<IDirect3DDevice9> m_pD3DDev;
public:
- CPixelShaderCompiler(IDirect3DDevice9* pD3DDev, bool fStaySilent = false);
- virtual ~CPixelShaderCompiler();
+ CPixelShaderCompiler(IDirect3DDevice9* pD3DDev, bool fStaySilent = false);
+ virtual ~CPixelShaderCompiler();
- HRESULT CompileShader(
- LPCSTR pSrcData,
- LPCSTR pFunctionName,
- LPCSTR pProfile,
- DWORD Flags,
- IDirect3DPixelShader9** ppPixelShader,
- CString* disasm = NULL,
- CString* errmsg = NULL);
+ HRESULT CompileShader(
+ LPCSTR pSrcData,
+ LPCSTR pFunctionName,
+ LPCSTR pProfile,
+ DWORD Flags,
+ IDirect3DPixelShader9** ppPixelShader,
+ CString* disasm = NULL,
+ CString* errmsg = NULL);
};
diff --git a/src/filters/renderer/VideoRenderers/QT7AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/QT7AllocatorPresenter.cpp
index b9fc43ef5..2920a1176 100644
--- a/src/filters/renderer/VideoRenderers/QT7AllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/QT7AllocatorPresenter.cpp
@@ -31,131 +31,131 @@ using namespace DSObjects;
//
CQT7AllocatorPresenter::CQT7AllocatorPresenter(HWND hWnd, HRESULT& hr)
- : CDX7AllocatorPresenter(hWnd, hr)
+ : CDX7AllocatorPresenter(hWnd, hr)
{
}
STDMETHODIMP CQT7AllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- QI(IQTVideoSurface)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IQTVideoSurface)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CQT7AllocatorPresenter::AllocSurfaces()
{
- CAutoLock cAutoLock(this);
-
- m_pVideoSurfaceOff = NULL;
-
- DDSURFACEDESC2 ddsd;
- INITDDSTRUCT(ddsd);
- ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT;
- ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
- ddsd.dwWidth = m_NativeVideoSize.cx;
- ddsd.dwHeight = m_NativeVideoSize.cy;
- ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
- ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
- ddsd.ddpfPixelFormat.dwRGBBitCount = 32;
- ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = 0xFF000000;
- ddsd.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
- ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
- ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
-
- HRESULT hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurfaceOff, NULL);
- if (FAILED(hr)) {
- return E_FAIL;
- }
-
- DDBLTFX fx;
- INITDDSTRUCT(fx);
- fx.dwFillColor = 0;
- m_pVideoSurfaceOff->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
-
- return __super::AllocSurfaces();
+ CAutoLock cAutoLock(this);
+
+ m_pVideoSurfaceOff = NULL;
+
+ DDSURFACEDESC2 ddsd;
+ INITDDSTRUCT(ddsd);
+ ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
+ ddsd.dwWidth = m_NativeVideoSize.cx;
+ ddsd.dwHeight = m_NativeVideoSize.cy;
+ ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
+ ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
+ ddsd.ddpfPixelFormat.dwRGBBitCount = 32;
+ ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = 0xFF000000;
+ ddsd.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
+ ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
+ ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
+
+ HRESULT hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurfaceOff, NULL);
+ if (FAILED(hr)) {
+ return E_FAIL;
+ }
+
+ DDBLTFX fx;
+ INITDDSTRUCT(fx);
+ fx.dwFillColor = 0;
+ m_pVideoSurfaceOff->Blt(NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx);
+
+ return __super::AllocSurfaces();
}
void CQT7AllocatorPresenter::DeleteSurfaces()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- m_pVideoSurfaceOff = NULL;
+ m_pVideoSurfaceOff = NULL;
- __super::DeleteSurfaces();
+ __super::DeleteSurfaces();
}
// IQTVideoSurface
STDMETHODIMP CQT7AllocatorPresenter::BeginBlt(const BITMAP& bm)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- DeleteSurfaces();
+ DeleteSurfaces();
- m_NativeVideoSize = m_AspectRatio = CSize(bm.bmWidth, abs(bm.bmHeight));
+ m_NativeVideoSize = m_AspectRatio = CSize(bm.bmWidth, abs(bm.bmHeight));
- HRESULT hr;
- if (FAILED(hr = AllocSurfaces())) {
- return hr;
- }
+ HRESULT hr;
+ if (FAILED(hr = AllocSurfaces())) {
+ return hr;
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CQT7AllocatorPresenter::DoBlt(const BITMAP& bm)
{
- if (!m_pVideoSurface || !m_pVideoSurfaceOff) {
- return E_FAIL;
- }
-
- bool fOk = false;
-
- DDSURFACEDESC2 ddsd;
- INITDDSTRUCT(ddsd);
- if (FAILED(m_pVideoSurfaceOff->GetSurfaceDesc(&ddsd))) {
- return E_FAIL;
- }
-
- UINT w = (UINT)bm.bmWidth;
- UINT h = abs(bm.bmHeight);
- int bpp = bm.bmBitsPixel;
-
- if ((bpp == 16 || bpp == 24 || bpp == 32) && w == ddsd.dwWidth && h == ddsd.dwHeight) {
- INITDDSTRUCT(ddsd);
- if (SUCCEEDED(m_pVideoSurfaceOff->Lock(NULL, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL))) {
- BitBltFromRGBToRGB(
- w, h,
- (BYTE*)ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount,
- (BYTE*)bm.bmBits, bm.bmWidthBytes, bm.bmBitsPixel);
- m_pVideoSurfaceOff->Unlock(NULL);
- fOk = true;
- }
- }
-
- if (!fOk) {
- DDBLTFX fx;
- INITDDSTRUCT(fx);
- fx.dwFillColor = 0;
- m_pVideoSurfaceOff->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
-
- HDC hDC;
- if (SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC))) {
- CString str;
- str.Format(_T("Sorry, this format is not supported"));
-
- SetBkColor(hDC, 0);
- SetTextColor(hDC, 0x404040);
- TextOut(hDC, 10, 10, str, str.GetLength());
-
- m_pVideoSurfaceOff->ReleaseDC(hDC);
- }
- }
-
- m_pVideoSurface->Blt(NULL, m_pVideoSurfaceOff, NULL, DDBLT_WAIT, NULL);
-
- Paint(true);
-
- return S_OK;
+ if (!m_pVideoSurface || !m_pVideoSurfaceOff) {
+ return E_FAIL;
+ }
+
+ bool fOk = false;
+
+ DDSURFACEDESC2 ddsd;
+ INITDDSTRUCT(ddsd);
+ if (FAILED(m_pVideoSurfaceOff->GetSurfaceDesc(&ddsd))) {
+ return E_FAIL;
+ }
+
+ UINT w = (UINT)bm.bmWidth;
+ UINT h = abs(bm.bmHeight);
+ int bpp = bm.bmBitsPixel;
+
+ if ((bpp == 16 || bpp == 24 || bpp == 32) && w == ddsd.dwWidth && h == ddsd.dwHeight) {
+ INITDDSTRUCT(ddsd);
+ if (SUCCEEDED(m_pVideoSurfaceOff->Lock(NULL, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY, NULL))) {
+ BitBltFromRGBToRGB(
+ w, h,
+ (BYTE*)ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount,
+ (BYTE*)bm.bmBits, bm.bmWidthBytes, bm.bmBitsPixel);
+ m_pVideoSurfaceOff->Unlock(NULL);
+ fOk = true;
+ }
+ }
+
+ if (!fOk) {
+ DDBLTFX fx;
+ INITDDSTRUCT(fx);
+ fx.dwFillColor = 0;
+ m_pVideoSurfaceOff->Blt(NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx);
+
+ HDC hDC;
+ if (SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC))) {
+ CString str;
+ str.Format(_T("Sorry, this format is not supported"));
+
+ SetBkColor(hDC, 0);
+ SetTextColor(hDC, 0x404040);
+ TextOut(hDC, 10, 10, str, str.GetLength());
+
+ m_pVideoSurfaceOff->ReleaseDC(hDC);
+ }
+ }
+
+ m_pVideoSurface->Blt(NULL, m_pVideoSurfaceOff, NULL, DDBLT_WAIT, NULL);
+
+ Paint(true);
+
+ return S_OK;
}
diff --git a/src/filters/renderer/VideoRenderers/QT7AllocatorPresenter.h b/src/filters/renderer/VideoRenderers/QT7AllocatorPresenter.h
index 65dd39ba7..a89f6b90b 100644
--- a/src/filters/renderer/VideoRenderers/QT7AllocatorPresenter.h
+++ b/src/filters/renderer/VideoRenderers/QT7AllocatorPresenter.h
@@ -29,25 +29,25 @@
namespace DSObjects
{
- class CQT7AllocatorPresenter
- : public CDX7AllocatorPresenter
- , public IQTVideoSurface
- {
- CComPtr<IDirectDrawSurface7> m_pVideoSurfaceOff;
-
- protected:
- HRESULT AllocSurfaces();
- void DeleteSurfaces();
-
- public:
- CQT7AllocatorPresenter(HWND hWnd, HRESULT& hr);
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // IQTVideoSurface
- STDMETHODIMP BeginBlt(const BITMAP& bm);
- STDMETHODIMP DoBlt(const BITMAP& bm);
- };
+ class CQT7AllocatorPresenter
+ : public CDX7AllocatorPresenter
+ , public IQTVideoSurface
+ {
+ CComPtr<IDirectDrawSurface7> m_pVideoSurfaceOff;
+
+ protected:
+ HRESULT AllocSurfaces();
+ void DeleteSurfaces();
+
+ public:
+ CQT7AllocatorPresenter(HWND hWnd, HRESULT& hr);
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ // IQTVideoSurface
+ STDMETHODIMP BeginBlt(const BITMAP& bm);
+ STDMETHODIMP DoBlt(const BITMAP& bm);
+ };
}
diff --git a/src/filters/renderer/VideoRenderers/QT9AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/QT9AllocatorPresenter.cpp
index 85111716a..e3ae99134 100644
--- a/src/filters/renderer/VideoRenderers/QT9AllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/QT9AllocatorPresenter.cpp
@@ -29,108 +29,108 @@ using namespace DSObjects;
// CQT9AllocatorPresenter
//
-CQT9AllocatorPresenter::CQT9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRESULT& hr, CString &_Error)
- : CDX9AllocatorPresenter(hWnd, bFullscreen, hr, false, _Error)
+CQT9AllocatorPresenter::CQT9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRESULT& hr, CString& _Error)
+ : CDX9AllocatorPresenter(hWnd, bFullscreen, hr, false, _Error)
{
}
STDMETHODIMP CQT9AllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- QI(IQTVideoSurface)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IQTVideoSurface)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CQT9AllocatorPresenter::AllocSurfaces()
{
- HRESULT hr;
+ HRESULT hr;
- m_pVideoSurfaceOff = NULL;
+ m_pVideoSurfaceOff = NULL;
- if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(
- m_NativeVideoSize.cx, m_NativeVideoSize.cy, D3DFMT_X8R8G8B8,
- D3DPOOL_DEFAULT, &m_pVideoSurfaceOff, NULL))) {
- return hr;
- }
+ if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(
+ m_NativeVideoSize.cx, m_NativeVideoSize.cy, D3DFMT_X8R8G8B8,
+ D3DPOOL_DEFAULT, &m_pVideoSurfaceOff, NULL))) {
+ return hr;
+ }
- return __super::AllocSurfaces();
+ return __super::AllocSurfaces();
}
void CQT9AllocatorPresenter::DeleteSurfaces()
{
- m_pVideoSurfaceOff = NULL;
+ m_pVideoSurfaceOff = NULL;
- __super::DeleteSurfaces();
+ __super::DeleteSurfaces();
}
// IQTVideoSurface
STDMETHODIMP CQT9AllocatorPresenter::BeginBlt(const BITMAP& bm)
{
- CAutoLock cAutoLock(this);
- CAutoLock cRenderLock(&m_RenderLock);
- DeleteSurfaces();
- m_NativeVideoSize = m_AspectRatio = CSize(bm.bmWidth, abs(bm.bmHeight));
- if (FAILED(AllocSurfaces())) {
- return E_FAIL;
- }
- return S_OK;
+ CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
+ DeleteSurfaces();
+ m_NativeVideoSize = m_AspectRatio = CSize(bm.bmWidth, abs(bm.bmHeight));
+ if (FAILED(AllocSurfaces())) {
+ return E_FAIL;
+ }
+ return S_OK;
}
STDMETHODIMP CQT9AllocatorPresenter::DoBlt(const BITMAP& bm)
{
- if (!m_pVideoSurface || !m_pVideoSurfaceOff) {
- return E_FAIL;
- }
-
- bool fOk = false;
-
- D3DSURFACE_DESC d3dsd;
- ZeroMemory(&d3dsd, sizeof(d3dsd));
- if (FAILED(m_pVideoSurfaceOff->GetDesc(&d3dsd))) {
- return E_FAIL;
- }
-
- UINT w = (UINT)bm.bmWidth;
- UINT h = abs(bm.bmHeight);
- int bpp = bm.bmBitsPixel;
- int dbpp =
- d3dsd.Format == D3DFMT_R8G8B8 || d3dsd.Format == D3DFMT_X8R8G8B8 || d3dsd.Format == D3DFMT_A8R8G8B8 ? 32 :
- d3dsd.Format == D3DFMT_R5G6B5 ? 16 : 0;
-
- if ((bpp == 16 || bpp == 24 || bpp == 32) && w == d3dsd.Width && h == d3dsd.Height) {
- D3DLOCKED_RECT r;
- if (SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, NULL, 0))) {
- BitBltFromRGBToRGB(
- w, h,
- (BYTE*)r.pBits, r.Pitch, dbpp,
- (BYTE*)bm.bmBits, bm.bmWidthBytes, bm.bmBitsPixel);
- m_pVideoSurfaceOff->UnlockRect();
- fOk = true;
- }
- }
-
- if (!fOk) {
- m_pD3DDev->ColorFill(m_pVideoSurfaceOff, NULL, 0);
-
- HDC hDC;
- if (SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC))) {
- CString str;
- str.Format(_T("Sorry, this color format is not supported"));
-
- SetBkColor(hDC, 0);
- SetTextColor(hDC, 0x404040);
- TextOut(hDC, 10, 10, str, str.GetLength());
-
- m_pVideoSurfaceOff->ReleaseDC(hDC);
- }
- }
-
- m_pD3DDev->StretchRect(m_pVideoSurfaceOff, NULL, m_pVideoSurface[m_nCurSurface], NULL, D3DTEXF_NONE);
-
- Paint(true);
-
- return S_OK;
+ if (!m_pVideoSurface || !m_pVideoSurfaceOff) {
+ return E_FAIL;
+ }
+
+ bool fOk = false;
+
+ D3DSURFACE_DESC d3dsd;
+ ZeroMemory(&d3dsd, sizeof(d3dsd));
+ if (FAILED(m_pVideoSurfaceOff->GetDesc(&d3dsd))) {
+ return E_FAIL;
+ }
+
+ UINT w = (UINT)bm.bmWidth;
+ UINT h = abs(bm.bmHeight);
+ int bpp = bm.bmBitsPixel;
+ int dbpp =
+ d3dsd.Format == D3DFMT_R8G8B8 || d3dsd.Format == D3DFMT_X8R8G8B8 || d3dsd.Format == D3DFMT_A8R8G8B8 ? 32 :
+ d3dsd.Format == D3DFMT_R5G6B5 ? 16 : 0;
+
+ if ((bpp == 16 || bpp == 24 || bpp == 32) && w == d3dsd.Width && h == d3dsd.Height) {
+ D3DLOCKED_RECT r;
+ if (SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, NULL, 0))) {
+ BitBltFromRGBToRGB(
+ w, h,
+ (BYTE*)r.pBits, r.Pitch, dbpp,
+ (BYTE*)bm.bmBits, bm.bmWidthBytes, bm.bmBitsPixel);
+ m_pVideoSurfaceOff->UnlockRect();
+ fOk = true;
+ }
+ }
+
+ if (!fOk) {
+ m_pD3DDev->ColorFill(m_pVideoSurfaceOff, NULL, 0);
+
+ HDC hDC;
+ if (SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC))) {
+ CString str;
+ str.Format(_T("Sorry, this color format is not supported"));
+
+ SetBkColor(hDC, 0);
+ SetTextColor(hDC, 0x404040);
+ TextOut(hDC, 10, 10, str, str.GetLength());
+
+ m_pVideoSurfaceOff->ReleaseDC(hDC);
+ }
+ }
+
+ m_pD3DDev->StretchRect(m_pVideoSurfaceOff, NULL, m_pVideoSurface[m_nCurSurface], NULL, D3DTEXF_NONE);
+
+ Paint(true);
+
+ return S_OK;
}
diff --git a/src/filters/renderer/VideoRenderers/QT9AllocatorPresenter.h b/src/filters/renderer/VideoRenderers/QT9AllocatorPresenter.h
index 026ec54d1..f34bcb6b2 100644
--- a/src/filters/renderer/VideoRenderers/QT9AllocatorPresenter.h
+++ b/src/filters/renderer/VideoRenderers/QT9AllocatorPresenter.h
@@ -27,24 +27,24 @@
namespace DSObjects
{
- class CQT9AllocatorPresenter
- : public CDX9AllocatorPresenter
- , public IQTVideoSurface
- {
- CComPtr<IDirect3DSurface9> m_pVideoSurfaceOff;
+ class CQT9AllocatorPresenter
+ : public CDX9AllocatorPresenter
+ , public IQTVideoSurface
+ {
+ CComPtr<IDirect3DSurface9> m_pVideoSurfaceOff;
- protected:
- HRESULT AllocSurfaces();
- void DeleteSurfaces();
+ protected:
+ HRESULT AllocSurfaces();
+ void DeleteSurfaces();
- public:
- CQT9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRESULT& hr, CString &_Error);
+ public:
+ CQT9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRESULT& hr, CString& _Error);
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // IQTVideoSurface
- STDMETHODIMP BeginBlt(const BITMAP& bm);
- STDMETHODIMP DoBlt(const BITMAP& bm);
- };
+ // IQTVideoSurface
+ STDMETHODIMP BeginBlt(const BITMAP& bm);
+ STDMETHODIMP DoBlt(const BITMAP& bm);
+ };
}
diff --git a/src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.cpp
index b4f5c4616..db8961f37 100644
--- a/src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.cpp
@@ -31,238 +31,238 @@ using namespace DSObjects;
//
CRM7AllocatorPresenter::CRM7AllocatorPresenter(HWND hWnd, HRESULT& hr)
- : CDX7AllocatorPresenter(hWnd, hr)
+ : CDX7AllocatorPresenter(hWnd, hr)
{
}
STDMETHODIMP CRM7AllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- QI2(IRMAVideoSurface)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI2(IRMAVideoSurface)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CRM7AllocatorPresenter::AllocSurfaces()
{
- CAutoLock cAutoLock(this);
-
- m_pVideoSurfaceOff = NULL;
- m_pVideoSurfaceYUY2 = NULL;
-
- DDSURFACEDESC2 ddsd;
- DDBLTFX fx;
-
- INITDDSTRUCT(ddsd);
- ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT;
- ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
- ddsd.dwWidth = m_NativeVideoSize.cx;
- ddsd.dwHeight = m_NativeVideoSize.cy;
- ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
- ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
- ddsd.ddpfPixelFormat.dwRGBBitCount = 32;
- ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = 0xFF000000;
- ddsd.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
- ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
- ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
-
- HRESULT hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurfaceOff, NULL);
- if (FAILED(hr)) {
- return E_FAIL;
- }
-
- INITDDSTRUCT(fx);
- fx.dwFillColor = 0;
- m_pVideoSurfaceOff->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
-
- INITDDSTRUCT(ddsd);
- ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT;
- ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
- ddsd.dwWidth = m_NativeVideoSize.cx;
- ddsd.dwHeight = m_NativeVideoSize.cy;
- ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
- ddsd.ddpfPixelFormat.dwFlags = DDPF_FOURCC;
- ddsd.ddpfPixelFormat.dwYUVBitCount = 16;
- ddsd.ddpfPixelFormat.dwFourCC = '2YUY';
-
- hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurfaceYUY2, NULL);
-
- if (FAILED(m_pVideoSurfaceOff->Blt(NULL, m_pVideoSurfaceYUY2, NULL, DDBLT_WAIT, NULL))) {
- m_pVideoSurfaceYUY2 = NULL;
- }
-
- if (m_pVideoSurfaceYUY2) {
- INITDDSTRUCT(fx);
- fx.dwFillColor = 0x80108010;
- m_pVideoSurfaceYUY2->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
- }
-
- return __super::AllocSurfaces();
+ CAutoLock cAutoLock(this);
+
+ m_pVideoSurfaceOff = NULL;
+ m_pVideoSurfaceYUY2 = NULL;
+
+ DDSURFACEDESC2 ddsd;
+ DDBLTFX fx;
+
+ INITDDSTRUCT(ddsd);
+ ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
+ ddsd.dwWidth = m_NativeVideoSize.cx;
+ ddsd.dwHeight = m_NativeVideoSize.cy;
+ ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
+ ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
+ ddsd.ddpfPixelFormat.dwRGBBitCount = 32;
+ ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = 0xFF000000;
+ ddsd.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
+ ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
+ ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
+
+ HRESULT hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurfaceOff, NULL);
+ if (FAILED(hr)) {
+ return E_FAIL;
+ }
+
+ INITDDSTRUCT(fx);
+ fx.dwFillColor = 0;
+ m_pVideoSurfaceOff->Blt(NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx);
+
+ INITDDSTRUCT(ddsd);
+ ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
+ ddsd.dwWidth = m_NativeVideoSize.cx;
+ ddsd.dwHeight = m_NativeVideoSize.cy;
+ ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
+ ddsd.ddpfPixelFormat.dwFlags = DDPF_FOURCC;
+ ddsd.ddpfPixelFormat.dwYUVBitCount = 16;
+ ddsd.ddpfPixelFormat.dwFourCC = '2YUY';
+
+ hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurfaceYUY2, NULL);
+
+ if (FAILED(m_pVideoSurfaceOff->Blt(NULL, m_pVideoSurfaceYUY2, NULL, DDBLT_WAIT, NULL))) {
+ m_pVideoSurfaceYUY2 = NULL;
+ }
+
+ if (m_pVideoSurfaceYUY2) {
+ INITDDSTRUCT(fx);
+ fx.dwFillColor = 0x80108010;
+ m_pVideoSurfaceYUY2->Blt(NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx);
+ }
+
+ return __super::AllocSurfaces();
}
void CRM7AllocatorPresenter::DeleteSurfaces()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- m_pVideoSurfaceOff = NULL;
- m_pVideoSurfaceYUY2 = NULL;
+ m_pVideoSurfaceOff = NULL;
+ m_pVideoSurfaceYUY2 = NULL;
- __super::DeleteSurfaces();
+ __super::DeleteSurfaces();
}
// IRMAVideoSurface
STDMETHODIMP CRM7AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* pBitmapInfo, REF(PNxRect) inDestRect, REF(PNxRect) inSrcRect)
{
- if (!m_pVideoSurface || !m_pVideoSurfaceOff) {
- return E_FAIL;
- }
-
- bool fRGB = false;
- bool fYUY2 = false;
-
- CRect src((RECT*)&inSrcRect), dst((RECT*)&inDestRect), src2(CPoint(0,0), src.Size());
- if (src.Width() > dst.Width() || src.Height() > dst.Height()) {
- return E_FAIL;
- }
-
- DDSURFACEDESC2 ddsd;
-
- if (pBitmapInfo->biCompression == '024I') {
- DWORD pitch = pBitmapInfo->biWidth;
- DWORD size = pitch*abs(pBitmapInfo->biHeight);
-
- BYTE* y = pImageData + src.top*pitch + src.left;
- BYTE* u = pImageData + size + src.top*(pitch/2) + src.left/2;
- BYTE* v = pImageData + size + size/4 + src.top*(pitch/2) + src.left/2;
-
- if (m_pVideoSurfaceYUY2) {
- INITDDSTRUCT(ddsd);
- if (SUCCEEDED(m_pVideoSurfaceYUY2->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL))) {
- BitBltFromI420ToYUY2(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, y, u, v, pitch);
- m_pVideoSurfaceYUY2->Unlock(src2);
- fYUY2 = true;
- }
- } else {
- INITDDSTRUCT(ddsd);
- if (SUCCEEDED(m_pVideoSurfaceOff->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL))) {
- BitBltFromI420ToRGB(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount, y, u, v, pitch);
- m_pVideoSurfaceOff->Unlock(src2);
- fRGB = true;
- }
- }
- } else if (pBitmapInfo->biCompression == '2YUY') {
- DWORD w = pBitmapInfo->biWidth;
- DWORD h = abs(pBitmapInfo->biHeight);
- DWORD pitch = pBitmapInfo->biWidth*2;
- UNREFERENCED_PARAMETER(w);
- UNREFERENCED_PARAMETER(h);
-
- BYTE* yvyu = pImageData + src.top*pitch + src.left*2;
-
- if (m_pVideoSurfaceYUY2) {
- INITDDSTRUCT(ddsd);
- if (SUCCEEDED(m_pVideoSurfaceYUY2->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL))) {
- BitBltFromYUY2ToYUY2(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, yvyu, pitch);
- m_pVideoSurfaceYUY2->Unlock(src2);
- fYUY2 = true;
- }
- } else {
- INITDDSTRUCT(ddsd);
- if (SUCCEEDED(m_pVideoSurfaceOff->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL))) {
- BitBltFromYUY2ToRGB(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount, yvyu, pitch);
- m_pVideoSurfaceOff->Unlock(src2);
- fRGB = true;
- }
- }
- } else if (pBitmapInfo->biCompression == 0 || pBitmapInfo->biCompression == 3
- || pBitmapInfo->biCompression == 'BGRA') {
- DWORD w = pBitmapInfo->biWidth;
- DWORD h = abs(pBitmapInfo->biHeight);
- DWORD pitch = pBitmapInfo->biWidth*pBitmapInfo->biBitCount>>3;
- UNREFERENCED_PARAMETER(w);
- UNREFERENCED_PARAMETER(h);
-
- BYTE* rgb = pImageData + src.top*pitch + src.left*(pBitmapInfo->biBitCount>>3);
-
- INITDDSTRUCT(ddsd);
- if (SUCCEEDED(m_pVideoSurfaceOff->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL))) {
- BYTE* lpSurface = (BYTE*)ddsd.lpSurface;
- if (pBitmapInfo->biHeight > 0) {
- lpSurface += ddsd.lPitch*(src.Height()-1);
- ddsd.lPitch = -ddsd.lPitch;
- }
- BitBltFromRGBToRGB(src.Width(), src.Height(), lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount, rgb, pitch, pBitmapInfo->biBitCount);
- fRGB = true;
- m_pVideoSurfaceOff->Unlock(src2);
- }
- }
-
- if (!fRGB && !fYUY2) {
- DDBLTFX fx;
- INITDDSTRUCT(fx);
- fx.dwFillColor = 0;
- m_pVideoSurfaceOff->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
-
- HDC hDC;
- if (SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC))) {
- CString str;
- str.Format(_T("Sorry, this format is not supported"));
-
- SetBkColor(hDC, 0);
- SetTextColor(hDC, 0x404040);
- TextOut(hDC, 10, 10, str, str.GetLength());
-
- m_pVideoSurfaceOff->ReleaseDC(hDC);
-
- fRGB = true;
- }
- }
-
-
- HRESULT hr;
-
- if (fRGB) {
- hr = m_pVideoSurface->Blt(dst, m_pVideoSurfaceOff, src2, DDBLT_WAIT, NULL);
- }
- if (fYUY2) {
- hr = m_pVideoSurface->Blt(dst, m_pVideoSurfaceYUY2, src2, DDBLT_WAIT, NULL);
- }
-
- Paint(true);
-
- return PNR_OK;
+ if (!m_pVideoSurface || !m_pVideoSurfaceOff) {
+ return E_FAIL;
+ }
+
+ bool fRGB = false;
+ bool fYUY2 = false;
+
+ CRect src((RECT*)&inSrcRect), dst((RECT*)&inDestRect), src2(CPoint(0, 0), src.Size());
+ if (src.Width() > dst.Width() || src.Height() > dst.Height()) {
+ return E_FAIL;
+ }
+
+ DDSURFACEDESC2 ddsd;
+
+ if (pBitmapInfo->biCompression == '024I') {
+ DWORD pitch = pBitmapInfo->biWidth;
+ DWORD size = pitch * abs(pBitmapInfo->biHeight);
+
+ BYTE* y = pImageData + src.top * pitch + src.left;
+ BYTE* u = pImageData + size + src.top * (pitch / 2) + src.left / 2;
+ BYTE* v = pImageData + size + size / 4 + src.top * (pitch / 2) + src.left / 2;
+
+ if (m_pVideoSurfaceYUY2) {
+ INITDDSTRUCT(ddsd);
+ if (SUCCEEDED(m_pVideoSurfaceYUY2->Lock(src2, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY, NULL))) {
+ BitBltFromI420ToYUY2(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, y, u, v, pitch);
+ m_pVideoSurfaceYUY2->Unlock(src2);
+ fYUY2 = true;
+ }
+ } else {
+ INITDDSTRUCT(ddsd);
+ if (SUCCEEDED(m_pVideoSurfaceOff->Lock(src2, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY, NULL))) {
+ BitBltFromI420ToRGB(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount, y, u, v, pitch);
+ m_pVideoSurfaceOff->Unlock(src2);
+ fRGB = true;
+ }
+ }
+ } else if (pBitmapInfo->biCompression == '2YUY') {
+ DWORD w = pBitmapInfo->biWidth;
+ DWORD h = abs(pBitmapInfo->biHeight);
+ DWORD pitch = pBitmapInfo->biWidth * 2;
+ UNREFERENCED_PARAMETER(w);
+ UNREFERENCED_PARAMETER(h);
+
+ BYTE* yvyu = pImageData + src.top * pitch + src.left * 2;
+
+ if (m_pVideoSurfaceYUY2) {
+ INITDDSTRUCT(ddsd);
+ if (SUCCEEDED(m_pVideoSurfaceYUY2->Lock(src2, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY, NULL))) {
+ BitBltFromYUY2ToYUY2(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, yvyu, pitch);
+ m_pVideoSurfaceYUY2->Unlock(src2);
+ fYUY2 = true;
+ }
+ } else {
+ INITDDSTRUCT(ddsd);
+ if (SUCCEEDED(m_pVideoSurfaceOff->Lock(src2, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY, NULL))) {
+ BitBltFromYUY2ToRGB(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount, yvyu, pitch);
+ m_pVideoSurfaceOff->Unlock(src2);
+ fRGB = true;
+ }
+ }
+ } else if (pBitmapInfo->biCompression == 0 || pBitmapInfo->biCompression == 3
+ || pBitmapInfo->biCompression == 'BGRA') {
+ DWORD w = pBitmapInfo->biWidth;
+ DWORD h = abs(pBitmapInfo->biHeight);
+ DWORD pitch = pBitmapInfo->biWidth * pBitmapInfo->biBitCount >> 3;
+ UNREFERENCED_PARAMETER(w);
+ UNREFERENCED_PARAMETER(h);
+
+ BYTE* rgb = pImageData + src.top * pitch + src.left * (pBitmapInfo->biBitCount >> 3);
+
+ INITDDSTRUCT(ddsd);
+ if (SUCCEEDED(m_pVideoSurfaceOff->Lock(src2, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY, NULL))) {
+ BYTE* lpSurface = (BYTE*)ddsd.lpSurface;
+ if (pBitmapInfo->biHeight > 0) {
+ lpSurface += ddsd.lPitch * (src.Height() - 1);
+ ddsd.lPitch = -ddsd.lPitch;
+ }
+ BitBltFromRGBToRGB(src.Width(), src.Height(), lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount, rgb, pitch, pBitmapInfo->biBitCount);
+ fRGB = true;
+ m_pVideoSurfaceOff->Unlock(src2);
+ }
+ }
+
+ if (!fRGB && !fYUY2) {
+ DDBLTFX fx;
+ INITDDSTRUCT(fx);
+ fx.dwFillColor = 0;
+ m_pVideoSurfaceOff->Blt(NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx);
+
+ HDC hDC;
+ if (SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC))) {
+ CString str;
+ str.Format(_T("Sorry, this format is not supported"));
+
+ SetBkColor(hDC, 0);
+ SetTextColor(hDC, 0x404040);
+ TextOut(hDC, 10, 10, str, str.GetLength());
+
+ m_pVideoSurfaceOff->ReleaseDC(hDC);
+
+ fRGB = true;
+ }
+ }
+
+
+ HRESULT hr;
+
+ if (fRGB) {
+ hr = m_pVideoSurface->Blt(dst, m_pVideoSurfaceOff, src2, DDBLT_WAIT, NULL);
+ }
+ if (fYUY2) {
+ hr = m_pVideoSurface->Blt(dst, m_pVideoSurfaceYUY2, src2, DDBLT_WAIT, NULL);
+ }
+
+ Paint(true);
+
+ return PNR_OK;
}
STDMETHODIMP CRM7AllocatorPresenter::BeginOptimizedBlt(RMABitmapInfoHeader* pBitmapInfo)
{
- CAutoLock cAutoLock(this);
- DeleteSurfaces();
- m_NativeVideoSize = m_AspectRatio = CSize(pBitmapInfo->biWidth, abs(pBitmapInfo->biHeight));
- if (FAILED(AllocSurfaces())) {
- return E_FAIL;
- }
- return PNR_NOTIMPL;
+ CAutoLock cAutoLock(this);
+ DeleteSurfaces();
+ m_NativeVideoSize = m_AspectRatio = CSize(pBitmapInfo->biWidth, abs(pBitmapInfo->biHeight));
+ if (FAILED(AllocSurfaces())) {
+ return E_FAIL;
+ }
+ return PNR_NOTIMPL;
}
STDMETHODIMP CRM7AllocatorPresenter::OptimizedBlt(UCHAR* pImageBits, REF(PNxRect) rDestRect, REF(PNxRect) rSrcRect)
{
- return PNR_NOTIMPL;
+ return PNR_NOTIMPL;
}
STDMETHODIMP CRM7AllocatorPresenter::EndOptimizedBlt()
{
- return PNR_NOTIMPL;
+ return PNR_NOTIMPL;
}
STDMETHODIMP CRM7AllocatorPresenter::GetOptimizedFormat(REF(RMA_COMPRESSION_TYPE) ulType)
{
- return PNR_NOTIMPL;
+ return PNR_NOTIMPL;
}
STDMETHODIMP CRM7AllocatorPresenter::GetPreferredFormat(REF(RMA_COMPRESSION_TYPE) ulType)
{
- ulType = RMA_I420;
- return PNR_OK;
+ ulType = RMA_I420;
+ return PNR_OK;
}
diff --git a/src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.h b/src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.h
index a84bf49e9..998181f6e 100644
--- a/src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.h
+++ b/src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.h
@@ -32,33 +32,33 @@
namespace DSObjects
{
- class CRM7AllocatorPresenter
- : public CDX7AllocatorPresenter
- , public IRMAVideoSurface
- {
- CComPtr<IDirectDrawSurface7> m_pVideoSurfaceOff;
- CComPtr<IDirectDrawSurface7> m_pVideoSurfaceYUY2;
+ class CRM7AllocatorPresenter
+ : public CDX7AllocatorPresenter
+ , public IRMAVideoSurface
+ {
+ CComPtr<IDirectDrawSurface7> m_pVideoSurfaceOff;
+ CComPtr<IDirectDrawSurface7> m_pVideoSurfaceYUY2;
- RMABitmapInfoHeader m_bitmapInfo;
- RMABitmapInfoHeader m_lastBitmapInfo;
+ RMABitmapInfoHeader m_bitmapInfo;
+ RMABitmapInfoHeader m_lastBitmapInfo;
- protected:
- HRESULT AllocSurfaces();
- void DeleteSurfaces();
+ protected:
+ HRESULT AllocSurfaces();
+ void DeleteSurfaces();
- public:
- CRM7AllocatorPresenter(HWND hWnd, HRESULT& hr);
+ public:
+ CRM7AllocatorPresenter(HWND hWnd, HRESULT& hr);
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // IRMAVideoSurface
- STDMETHODIMP Blt(UCHAR* pImageData, RMABitmapInfoHeader* pBitmapInfo, REF(PNxRect) inDestRect, REF(PNxRect) inSrcRect);
- STDMETHODIMP BeginOptimizedBlt(RMABitmapInfoHeader* pBitmapInfo);
- STDMETHODIMP OptimizedBlt(UCHAR* pImageBits, REF(PNxRect) rDestRect, REF(PNxRect) rSrcRect);
- STDMETHODIMP EndOptimizedBlt();
- STDMETHODIMP GetOptimizedFormat(REF(RMA_COMPRESSION_TYPE) ulType);
- STDMETHODIMP GetPreferredFormat(REF(RMA_COMPRESSION_TYPE) ulType);
- };
+ // IRMAVideoSurface
+ STDMETHODIMP Blt(UCHAR* pImageData, RMABitmapInfoHeader* pBitmapInfo, REF(PNxRect) inDestRect, REF(PNxRect) inSrcRect);
+ STDMETHODIMP BeginOptimizedBlt(RMABitmapInfoHeader* pBitmapInfo);
+ STDMETHODIMP OptimizedBlt(UCHAR* pImageBits, REF(PNxRect) rDestRect, REF(PNxRect) rSrcRect);
+ STDMETHODIMP EndOptimizedBlt();
+ STDMETHODIMP GetOptimizedFormat(REF(RMA_COMPRESSION_TYPE) ulType);
+ STDMETHODIMP GetPreferredFormat(REF(RMA_COMPRESSION_TYPE) ulType);
+ };
}
diff --git a/src/filters/renderer/VideoRenderers/RM9AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/RM9AllocatorPresenter.cpp
index 579c6a5cb..37cff11f8 100644
--- a/src/filters/renderer/VideoRenderers/RM9AllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/RM9AllocatorPresenter.cpp
@@ -29,217 +29,217 @@ using namespace DSObjects;
// CRM9AllocatorPresenter
//
-CRM9AllocatorPresenter::CRM9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRESULT& hr, CString &_Error)
- : CDX9AllocatorPresenter(hWnd, bFullscreen, hr, false, _Error)
+CRM9AllocatorPresenter::CRM9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRESULT& hr, CString& _Error)
+ : CDX9AllocatorPresenter(hWnd, bFullscreen, hr, false, _Error)
{
}
STDMETHODIMP CRM9AllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- QI2(IRMAVideoSurface)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI2(IRMAVideoSurface)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CRM9AllocatorPresenter::AllocSurfaces()
{
- CAutoLock cAutoLock(this);
- CAutoLock cRenderLock(&m_RenderLock);
+ CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
- m_pVideoSurfaceOff = NULL;
- m_pVideoSurfaceYUY2 = NULL;
+ m_pVideoSurfaceOff = NULL;
+ m_pVideoSurfaceYUY2 = NULL;
- HRESULT hr;
+ HRESULT hr;
- if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(
- m_NativeVideoSize.cx, m_NativeVideoSize.cy, D3DFMT_X8R8G8B8,
- D3DPOOL_DEFAULT, &m_pVideoSurfaceOff, NULL))) {
- return hr;
- }
+ if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(
+ m_NativeVideoSize.cx, m_NativeVideoSize.cy, D3DFMT_X8R8G8B8,
+ D3DPOOL_DEFAULT, &m_pVideoSurfaceOff, NULL))) {
+ return hr;
+ }
- m_pD3DDev->ColorFill(m_pVideoSurfaceOff, NULL, 0);
+ m_pD3DDev->ColorFill(m_pVideoSurfaceOff, NULL, 0);
- if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(
- m_NativeVideoSize.cx, m_NativeVideoSize.cy, D3DFMT_YUY2,
- D3DPOOL_DEFAULT, &m_pVideoSurfaceYUY2, NULL))) {
- m_pVideoSurfaceYUY2 = NULL;
- }
+ if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(
+ m_NativeVideoSize.cx, m_NativeVideoSize.cy, D3DFMT_YUY2,
+ D3DPOOL_DEFAULT, &m_pVideoSurfaceYUY2, NULL))) {
+ m_pVideoSurfaceYUY2 = NULL;
+ }
- if (m_pVideoSurfaceYUY2) {
- m_pD3DDev->ColorFill(m_pVideoSurfaceOff, NULL, 0x80108010);
- }
+ if (m_pVideoSurfaceYUY2) {
+ m_pD3DDev->ColorFill(m_pVideoSurfaceOff, NULL, 0x80108010);
+ }
- return __super::AllocSurfaces();
+ return __super::AllocSurfaces();
}
void CRM9AllocatorPresenter::DeleteSurfaces()
{
- CAutoLock cAutoLock(this);
- CAutoLock cRenderLock(&m_RenderLock);
- m_pVideoSurfaceOff = NULL;
- m_pVideoSurfaceYUY2 = NULL;
- __super::DeleteSurfaces();
+ CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
+ m_pVideoSurfaceOff = NULL;
+ m_pVideoSurfaceYUY2 = NULL;
+ __super::DeleteSurfaces();
}
// IRMAVideoSurface
STDMETHODIMP CRM9AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* pBitmapInfo, REF(PNxRect) inDestRect, REF(PNxRect) inSrcRect)
{
- if (!m_pVideoSurface || !m_pVideoSurfaceOff) {
- return E_FAIL;
- }
-
- bool fRGB = false;
- bool fYUY2 = false;
-
- CRect src((RECT*)&inSrcRect), dst((RECT*)&inDestRect), src2(CPoint(0,0), src.Size());
- if (src.Width() > dst.Width() || src.Height() > dst.Height()) {
- return E_FAIL;
- }
-
- D3DSURFACE_DESC d3dsd;
- ZeroMemory(&d3dsd, sizeof(d3dsd));
- if (FAILED(m_pVideoSurfaceOff->GetDesc(&d3dsd))) {
- return E_FAIL;
- }
-
- int dbpp =
- d3dsd.Format == D3DFMT_R8G8B8 || d3dsd.Format == D3DFMT_X8R8G8B8 || d3dsd.Format == D3DFMT_A8R8G8B8 ? 32 :
- d3dsd.Format == D3DFMT_R5G6B5 ? 16 : 0;
-
- if (pBitmapInfo->biCompression == '024I') {
- DWORD pitch = pBitmapInfo->biWidth;
- DWORD size = pitch*abs(pBitmapInfo->biHeight);
-
- BYTE* y = pImageData + src.top*pitch + src.left;
- BYTE* u = pImageData + size + src.top*(pitch/2) + src.left/2;
- BYTE* v = pImageData + size + size/4 + src.top*(pitch/2) + src.left/2;
-
- if (m_pVideoSurfaceYUY2) {
- D3DLOCKED_RECT r;
- if (SUCCEEDED(m_pVideoSurfaceYUY2->LockRect(&r, src2, 0))) {
- BitBltFromI420ToYUY2(src.Width(), src.Height(), (BYTE*)r.pBits, r.Pitch, y, u, v, pitch);
- m_pVideoSurfaceYUY2->UnlockRect();
- fYUY2 = true;
- }
- } else {
- D3DLOCKED_RECT r;
- if (SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, src2, 0))) {
- BitBltFromI420ToRGB(src.Width(), src.Height(), (BYTE*)r.pBits, r.Pitch, dbpp, y, u, v, pitch);
- m_pVideoSurfaceOff->UnlockRect();
- fRGB = true;
- }
- }
- } else if (pBitmapInfo->biCompression == '2YUY') {
- DWORD w = pBitmapInfo->biWidth;
- DWORD h = abs(pBitmapInfo->biHeight);
- DWORD pitch = pBitmapInfo->biWidth*2;
- UNREFERENCED_PARAMETER(w);
- UNREFERENCED_PARAMETER(h);
-
- BYTE* yvyu = pImageData + src.top*pitch + src.left*2;
-
- if (m_pVideoSurfaceYUY2) {
- D3DLOCKED_RECT r;
- if (SUCCEEDED(m_pVideoSurfaceYUY2->LockRect(&r, src2, 0))) {
- BitBltFromYUY2ToYUY2(src.Width(), src.Height(), (BYTE*)r.pBits, r.Pitch, yvyu, pitch);
- m_pVideoSurfaceYUY2->UnlockRect();
- fYUY2 = true;
- }
- } else {
- D3DLOCKED_RECT r;
- if (SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, src2, 0))) {
- BitBltFromYUY2ToRGB(src.Width(), src.Height(), (BYTE*)r.pBits, r.Pitch, dbpp, yvyu, pitch);
- m_pVideoSurfaceOff->UnlockRect();
- fRGB = true;
- }
- }
- } else if (pBitmapInfo->biCompression == 0 || pBitmapInfo->biCompression == 3
- || pBitmapInfo->biCompression == 'BGRA') {
- DWORD w = pBitmapInfo->biWidth;
- DWORD h = abs(pBitmapInfo->biHeight);
- DWORD pitch = pBitmapInfo->biWidth*pBitmapInfo->biBitCount>>3;
- UNREFERENCED_PARAMETER(w);
- UNREFERENCED_PARAMETER(h);
-
- BYTE* rgb = pImageData + src.top*pitch + src.left*(pBitmapInfo->biBitCount>>3);
-
- D3DLOCKED_RECT r;
- if (SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, src2, 0))) {
- BYTE* pBits = (BYTE*)r.pBits;
- if (pBitmapInfo->biHeight > 0) {
- pBits += r.Pitch*(src.Height()-1);
- r.Pitch = -r.Pitch;
- }
- BitBltFromRGBToRGB(src.Width(), src.Height(), pBits, r.Pitch, dbpp, rgb, pitch, pBitmapInfo->biBitCount);
- m_pVideoSurfaceOff->UnlockRect();
- fRGB = true;
- }
- }
-
- if (!fRGB && !fYUY2) {
- m_pD3DDev->ColorFill(m_pVideoSurfaceOff, NULL, 0);
-
- HDC hDC;
- if (SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC))) {
- CString str;
- str.Format(_T("Sorry, this format is not supported"));
-
- SetBkColor(hDC, 0);
- SetTextColor(hDC, 0x404040);
- TextOut(hDC, 10, 10, str, str.GetLength());
-
- m_pVideoSurfaceOff->ReleaseDC(hDC);
-
- fRGB = true;
- }
- }
-
- HRESULT hr;
-
- if (fRGB) {
- hr = m_pD3DDev->StretchRect(m_pVideoSurfaceOff, src2, m_pVideoSurface[m_nCurSurface], dst, D3DTEXF_NONE);
- }
- if (fYUY2) {
- hr = m_pD3DDev->StretchRect(m_pVideoSurfaceYUY2, src2, m_pVideoSurface[m_nCurSurface], dst, D3DTEXF_NONE);
- }
-
- Paint(true);
-
- return PNR_OK;
+ if (!m_pVideoSurface || !m_pVideoSurfaceOff) {
+ return E_FAIL;
+ }
+
+ bool fRGB = false;
+ bool fYUY2 = false;
+
+ CRect src((RECT*)&inSrcRect), dst((RECT*)&inDestRect), src2(CPoint(0, 0), src.Size());
+ if (src.Width() > dst.Width() || src.Height() > dst.Height()) {
+ return E_FAIL;
+ }
+
+ D3DSURFACE_DESC d3dsd;
+ ZeroMemory(&d3dsd, sizeof(d3dsd));
+ if (FAILED(m_pVideoSurfaceOff->GetDesc(&d3dsd))) {
+ return E_FAIL;
+ }
+
+ int dbpp =
+ d3dsd.Format == D3DFMT_R8G8B8 || d3dsd.Format == D3DFMT_X8R8G8B8 || d3dsd.Format == D3DFMT_A8R8G8B8 ? 32 :
+ d3dsd.Format == D3DFMT_R5G6B5 ? 16 : 0;
+
+ if (pBitmapInfo->biCompression == '024I') {
+ DWORD pitch = pBitmapInfo->biWidth;
+ DWORD size = pitch * abs(pBitmapInfo->biHeight);
+
+ BYTE* y = pImageData + src.top * pitch + src.left;
+ BYTE* u = pImageData + size + src.top * (pitch / 2) + src.left / 2;
+ BYTE* v = pImageData + size + size / 4 + src.top * (pitch / 2) + src.left / 2;
+
+ if (m_pVideoSurfaceYUY2) {
+ D3DLOCKED_RECT r;
+ if (SUCCEEDED(m_pVideoSurfaceYUY2->LockRect(&r, src2, 0))) {
+ BitBltFromI420ToYUY2(src.Width(), src.Height(), (BYTE*)r.pBits, r.Pitch, y, u, v, pitch);
+ m_pVideoSurfaceYUY2->UnlockRect();
+ fYUY2 = true;
+ }
+ } else {
+ D3DLOCKED_RECT r;
+ if (SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, src2, 0))) {
+ BitBltFromI420ToRGB(src.Width(), src.Height(), (BYTE*)r.pBits, r.Pitch, dbpp, y, u, v, pitch);
+ m_pVideoSurfaceOff->UnlockRect();
+ fRGB = true;
+ }
+ }
+ } else if (pBitmapInfo->biCompression == '2YUY') {
+ DWORD w = pBitmapInfo->biWidth;
+ DWORD h = abs(pBitmapInfo->biHeight);
+ DWORD pitch = pBitmapInfo->biWidth * 2;
+ UNREFERENCED_PARAMETER(w);
+ UNREFERENCED_PARAMETER(h);
+
+ BYTE* yvyu = pImageData + src.top * pitch + src.left * 2;
+
+ if (m_pVideoSurfaceYUY2) {
+ D3DLOCKED_RECT r;
+ if (SUCCEEDED(m_pVideoSurfaceYUY2->LockRect(&r, src2, 0))) {
+ BitBltFromYUY2ToYUY2(src.Width(), src.Height(), (BYTE*)r.pBits, r.Pitch, yvyu, pitch);
+ m_pVideoSurfaceYUY2->UnlockRect();
+ fYUY2 = true;
+ }
+ } else {
+ D3DLOCKED_RECT r;
+ if (SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, src2, 0))) {
+ BitBltFromYUY2ToRGB(src.Width(), src.Height(), (BYTE*)r.pBits, r.Pitch, dbpp, yvyu, pitch);
+ m_pVideoSurfaceOff->UnlockRect();
+ fRGB = true;
+ }
+ }
+ } else if (pBitmapInfo->biCompression == 0 || pBitmapInfo->biCompression == 3
+ || pBitmapInfo->biCompression == 'BGRA') {
+ DWORD w = pBitmapInfo->biWidth;
+ DWORD h = abs(pBitmapInfo->biHeight);
+ DWORD pitch = pBitmapInfo->biWidth * pBitmapInfo->biBitCount >> 3;
+ UNREFERENCED_PARAMETER(w);
+ UNREFERENCED_PARAMETER(h);
+
+ BYTE* rgb = pImageData + src.top * pitch + src.left * (pBitmapInfo->biBitCount >> 3);
+
+ D3DLOCKED_RECT r;
+ if (SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, src2, 0))) {
+ BYTE* pBits = (BYTE*)r.pBits;
+ if (pBitmapInfo->biHeight > 0) {
+ pBits += r.Pitch * (src.Height() - 1);
+ r.Pitch = -r.Pitch;
+ }
+ BitBltFromRGBToRGB(src.Width(), src.Height(), pBits, r.Pitch, dbpp, rgb, pitch, pBitmapInfo->biBitCount);
+ m_pVideoSurfaceOff->UnlockRect();
+ fRGB = true;
+ }
+ }
+
+ if (!fRGB && !fYUY2) {
+ m_pD3DDev->ColorFill(m_pVideoSurfaceOff, NULL, 0);
+
+ HDC hDC;
+ if (SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC))) {
+ CString str;
+ str.Format(_T("Sorry, this format is not supported"));
+
+ SetBkColor(hDC, 0);
+ SetTextColor(hDC, 0x404040);
+ TextOut(hDC, 10, 10, str, str.GetLength());
+
+ m_pVideoSurfaceOff->ReleaseDC(hDC);
+
+ fRGB = true;
+ }
+ }
+
+ HRESULT hr;
+
+ if (fRGB) {
+ hr = m_pD3DDev->StretchRect(m_pVideoSurfaceOff, src2, m_pVideoSurface[m_nCurSurface], dst, D3DTEXF_NONE);
+ }
+ if (fYUY2) {
+ hr = m_pD3DDev->StretchRect(m_pVideoSurfaceYUY2, src2, m_pVideoSurface[m_nCurSurface], dst, D3DTEXF_NONE);
+ }
+
+ Paint(true);
+
+ return PNR_OK;
}
STDMETHODIMP CRM9AllocatorPresenter::BeginOptimizedBlt(RMABitmapInfoHeader* pBitmapInfo)
{
- CAutoLock cAutoLock(this);
- CAutoLock cRenderLock(&m_RenderLock);
- DeleteSurfaces();
- m_NativeVideoSize = m_AspectRatio = CSize(pBitmapInfo->biWidth, abs(pBitmapInfo->biHeight));
- if (FAILED(AllocSurfaces())) {
- return E_FAIL;
- }
- return PNR_NOTIMPL;
+ CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
+ DeleteSurfaces();
+ m_NativeVideoSize = m_AspectRatio = CSize(pBitmapInfo->biWidth, abs(pBitmapInfo->biHeight));
+ if (FAILED(AllocSurfaces())) {
+ return E_FAIL;
+ }
+ return PNR_NOTIMPL;
}
STDMETHODIMP CRM9AllocatorPresenter::OptimizedBlt(UCHAR* pImageBits, REF(PNxRect) rDestRect, REF(PNxRect) rSrcRect)
{
- return PNR_NOTIMPL;
+ return PNR_NOTIMPL;
}
STDMETHODIMP CRM9AllocatorPresenter::EndOptimizedBlt()
{
- return PNR_NOTIMPL;
+ return PNR_NOTIMPL;
}
STDMETHODIMP CRM9AllocatorPresenter::GetOptimizedFormat(REF(RMA_COMPRESSION_TYPE) ulType)
{
- return PNR_NOTIMPL;
+ return PNR_NOTIMPL;
}
STDMETHODIMP CRM9AllocatorPresenter::GetPreferredFormat(REF(RMA_COMPRESSION_TYPE) ulType)
{
- ulType = RMA_I420;
- return PNR_OK;
+ ulType = RMA_I420;
+ return PNR_OK;
}
diff --git a/src/filters/renderer/VideoRenderers/RM9AllocatorPresenter.h b/src/filters/renderer/VideoRenderers/RM9AllocatorPresenter.h
index 8536c3d44..859b04282 100644
--- a/src/filters/renderer/VideoRenderers/RM9AllocatorPresenter.h
+++ b/src/filters/renderer/VideoRenderers/RM9AllocatorPresenter.h
@@ -31,32 +31,32 @@
namespace DSObjects
{
- class CRM9AllocatorPresenter
- : public CDX9AllocatorPresenter
- , public IRMAVideoSurface
- {
- CComPtr<IDirect3DSurface9> m_pVideoSurfaceOff;
- CComPtr<IDirect3DSurface9> m_pVideoSurfaceYUY2;
-
- RMABitmapInfoHeader m_bitmapInfo;
- RMABitmapInfoHeader m_lastBitmapInfo;
-
- protected:
- HRESULT AllocSurfaces();
- void DeleteSurfaces();
-
- public:
- CRM9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRESULT& hr, CString &_Error);
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // IRMAVideoSurface
- STDMETHODIMP Blt(UCHAR* pImageData, RMABitmapInfoHeader* pBitmapInfo, REF(PNxRect) inDestRect, REF(PNxRect) inSrcRect);
- STDMETHODIMP BeginOptimizedBlt(RMABitmapInfoHeader* pBitmapInfo);
- STDMETHODIMP OptimizedBlt(UCHAR* pImageBits, REF(PNxRect) rDestRect, REF(PNxRect) rSrcRect);
- STDMETHODIMP EndOptimizedBlt();
- STDMETHODIMP GetOptimizedFormat(REF(RMA_COMPRESSION_TYPE) ulType);
- STDMETHODIMP GetPreferredFormat(REF(RMA_COMPRESSION_TYPE) ulType);
- };
+ class CRM9AllocatorPresenter
+ : public CDX9AllocatorPresenter
+ , public IRMAVideoSurface
+ {
+ CComPtr<IDirect3DSurface9> m_pVideoSurfaceOff;
+ CComPtr<IDirect3DSurface9> m_pVideoSurfaceYUY2;
+
+ RMABitmapInfoHeader m_bitmapInfo;
+ RMABitmapInfoHeader m_lastBitmapInfo;
+
+ protected:
+ HRESULT AllocSurfaces();
+ void DeleteSurfaces();
+
+ public:
+ CRM9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRESULT& hr, CString& _Error);
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ // IRMAVideoSurface
+ STDMETHODIMP Blt(UCHAR* pImageData, RMABitmapInfoHeader* pBitmapInfo, REF(PNxRect) inDestRect, REF(PNxRect) inSrcRect);
+ STDMETHODIMP BeginOptimizedBlt(RMABitmapInfoHeader* pBitmapInfo);
+ STDMETHODIMP OptimizedBlt(UCHAR* pImageBits, REF(PNxRect) rDestRect, REF(PNxRect) rSrcRect);
+ STDMETHODIMP EndOptimizedBlt();
+ STDMETHODIMP GetOptimizedFormat(REF(RMA_COMPRESSION_TYPE) ulType);
+ STDMETHODIMP GetPreferredFormat(REF(RMA_COMPRESSION_TYPE) ulType);
+ };
}
diff --git a/src/filters/renderer/VideoRenderers/RenderersSettings.cpp b/src/filters/renderer/VideoRenderers/RenderersSettings.cpp
index 181724a36..40db3b7a5 100644
--- a/src/filters/renderer/VideoRenderers/RenderersSettings.cpp
+++ b/src/filters/renderer/VideoRenderers/RenderersSettings.cpp
@@ -29,75 +29,75 @@
void CRenderersSettings::UpdateData(bool fSave)
{
- AfxGetAppSettings().UpdateRenderersData(fSave);
+ AfxGetAppSettings().UpdateRenderersData(fSave);
}
void CRenderersSettings::CRendererSettingsShared::SetDefault()
{
- fVMR9AlterativeVSync = 0;
- iVMR9VSyncOffset = 0;
- iVMR9VSyncAccurate = 1;
- iVMR9FullscreenGUISupport = 0;
- iVMR9VSync = 1;
- iVMR9FullFloatingPointProcessing = 0;
- iVMR9HalfFloatingPointProcessing = 0;
- iVMR9ColorManagementEnable = 0;
- iVMR9ColorManagementInput = VIDEO_SYSTEM_UNKNOWN;
- iVMR9ColorManagementAmbientLight = AMBIENT_LIGHT_BRIGHT;
- iVMR9ColorManagementIntent = COLOR_RENDERING_INTENT_PERCEPTUAL;
- iVMRDisableDesktopComposition = 0;
- iVMRFlushGPUBeforeVSync = 1;
- iVMRFlushGPUAfterPresent = 1;
- iVMRFlushGPUWait = 0;
- bSynchronizeVideo = 0;
- bSynchronizeDisplay = 0;
- bSynchronizeNearest = 1;
- iLineDelta = 0;
- iColumnDelta = 0;
- fCycleDelta = 0.0012;
- fTargetSyncOffset = 12.0;
- fControlLimit = 2.0;
+ fVMR9AlterativeVSync = 0;
+ iVMR9VSyncOffset = 0;
+ iVMR9VSyncAccurate = 1;
+ iVMR9FullscreenGUISupport = 0;
+ iVMR9VSync = 1;
+ iVMR9FullFloatingPointProcessing = 0;
+ iVMR9HalfFloatingPointProcessing = 0;
+ iVMR9ColorManagementEnable = 0;
+ iVMR9ColorManagementInput = VIDEO_SYSTEM_UNKNOWN;
+ iVMR9ColorManagementAmbientLight = AMBIENT_LIGHT_BRIGHT;
+ iVMR9ColorManagementIntent = COLOR_RENDERING_INTENT_PERCEPTUAL;
+ iVMRDisableDesktopComposition = 0;
+ iVMRFlushGPUBeforeVSync = 1;
+ iVMRFlushGPUAfterPresent = 1;
+ iVMRFlushGPUWait = 0;
+ bSynchronizeVideo = 0;
+ bSynchronizeDisplay = 0;
+ bSynchronizeNearest = 1;
+ iLineDelta = 0;
+ iColumnDelta = 0;
+ fCycleDelta = 0.0012;
+ fTargetSyncOffset = 12.0;
+ fControlLimit = 2.0;
}
void CRenderersSettings::CRendererSettingsShared::SetOptimal()
{
- fVMR9AlterativeVSync = 1;
- iVMR9VSyncAccurate = 1;
- iVMR9VSync = 1;
- iVMR9FullFloatingPointProcessing = 1;
- iVMR9HalfFloatingPointProcessing = 0;
- iVMR9ColorManagementEnable = 0;
- iVMR9ColorManagementInput = VIDEO_SYSTEM_UNKNOWN;
- iVMR9ColorManagementAmbientLight = AMBIENT_LIGHT_BRIGHT;
- iVMR9ColorManagementIntent = COLOR_RENDERING_INTENT_PERCEPTUAL;
- iVMRDisableDesktopComposition = 1;
- iVMRFlushGPUBeforeVSync = 1;
- iVMRFlushGPUAfterPresent = 1;
- iVMRFlushGPUWait = 0;
- bSynchronizeVideo = 0;
- bSynchronizeDisplay = 0;
- bSynchronizeNearest = 1;
- iLineDelta = 0;
- iColumnDelta = 0;
- fCycleDelta = 0.0012;
- fTargetSyncOffset = 12.0;
- fControlLimit = 2.0;
+ fVMR9AlterativeVSync = 1;
+ iVMR9VSyncAccurate = 1;
+ iVMR9VSync = 1;
+ iVMR9FullFloatingPointProcessing = 1;
+ iVMR9HalfFloatingPointProcessing = 0;
+ iVMR9ColorManagementEnable = 0;
+ iVMR9ColorManagementInput = VIDEO_SYSTEM_UNKNOWN;
+ iVMR9ColorManagementAmbientLight = AMBIENT_LIGHT_BRIGHT;
+ iVMR9ColorManagementIntent = COLOR_RENDERING_INTENT_PERCEPTUAL;
+ iVMRDisableDesktopComposition = 1;
+ iVMRFlushGPUBeforeVSync = 1;
+ iVMRFlushGPUAfterPresent = 1;
+ iVMRFlushGPUWait = 0;
+ bSynchronizeVideo = 0;
+ bSynchronizeDisplay = 0;
+ bSynchronizeNearest = 1;
+ iLineDelta = 0;
+ iColumnDelta = 0;
+ fCycleDelta = 0.0012;
+ fTargetSyncOffset = 12.0;
+ fControlLimit = 2.0;
}
void CRenderersSettings::CRendererSettingsEVR::SetDefault()
{
- CRendererSettingsShared::SetDefault();
- iEVRHighColorResolution = 0;
- iEVRForceInputHighColorResolution = 0;
- iEVREnableFrameTimeCorrection = 0;
- iEVROutputRange = 0;
+ CRendererSettingsShared::SetDefault();
+ iEVRHighColorResolution = 0;
+ iEVRForceInputHighColorResolution = 0;
+ iEVREnableFrameTimeCorrection = 0;
+ iEVROutputRange = 0;
}
void CRenderersSettings::CRendererSettingsEVR::SetOptimal()
{
- CRendererSettingsShared::SetOptimal();
- iEVRHighColorResolution = 0;
- iEVRForceInputHighColorResolution = 0;
+ CRendererSettingsShared::SetOptimal();
+ iEVRHighColorResolution = 0;
+ iEVRForceInputHighColorResolution = 0;
}
/////////////////////////////////////////////////////////////////////////////
@@ -105,30 +105,30 @@ void CRenderersSettings::CRendererSettingsEVR::SetOptimal()
CRenderersData::CRenderersData()
{
- m_fTearingTest = false;
- m_fDisplayStats = false;
- m_bResetStats = false;
- m_hD3DX9Dll = NULL;
- m_nDXSdkRelease = 0;
+ m_fTearingTest = false;
+ m_fDisplayStats = false;
+ m_bResetStats = false;
+ m_hD3DX9Dll = NULL;
+ m_nDXSdkRelease = 0;
- // Don't disable hardware features before initializing a renderer
- m_bFP16Support = true;
- m_b10bitSupport = true;
+ // Don't disable hardware features before initializing a renderer
+ m_bFP16Support = true;
+ m_b10bitSupport = true;
}
LONGLONG CRenderersData::GetPerfCounter()
{
- LARGE_INTEGER i64Ticks100ns;
- LARGE_INTEGER llPerfFrequency;
+ LARGE_INTEGER i64Ticks100ns;
+ LARGE_INTEGER llPerfFrequency;
- QueryPerformanceFrequency(&llPerfFrequency);
- if (llPerfFrequency.QuadPart != 0) {
- QueryPerformanceCounter(&i64Ticks100ns);
- return llMulDiv(i64Ticks100ns.QuadPart, 10000000, llPerfFrequency.QuadPart, 0);
- } else {
- // ms to 100ns units
- return timeGetTime() * 10000;
- }
+ QueryPerformanceFrequency(&llPerfFrequency);
+ if (llPerfFrequency.QuadPart != 0) {
+ QueryPerformanceCounter(&i64Ticks100ns);
+ return llMulDiv(i64Ticks100ns.QuadPart, 10000000, llPerfFrequency.QuadPart, 0);
+ } else {
+ // ms to 100ns units
+ return timeGetTime() * 10000;
+ }
}
HINSTANCE CRenderersData::GetD3X9Dll()
@@ -137,19 +137,19 @@ HINSTANCE CRenderersData::GetD3X9Dll()
#pragma message("ERROR: DirectX SDK " MPC_DX_SDK_MONTH " " MAKE_STR(MPC_DX_SDK_YEAR) " (v" MAKE_STR(MPC_DX_SDK_NUMBER) ") or newer is required to build MPC-HC")
#endif
- if (m_hD3DX9Dll == NULL) {
- m_nDXSdkRelease = 0;
+ if (m_hD3DX9Dll == NULL) {
+ m_nDXSdkRelease = 0;
- // load latest compatible version of the DLL that is available
- for (UINT i=D3DX_SDK_VERSION; i>=MPC_DX_SDK_NUMBER; i--) {
- m_strD3DX9Version.Format(_T("d3dx9_%u.dll"), i);
- m_hD3DX9Dll = LoadLibrary(m_strD3DX9Version);
- if (m_hD3DX9Dll) {
- m_nDXSdkRelease = i;
- break;
- }
- }
- }
+ // load latest compatible version of the DLL that is available
+ for (UINT i = D3DX_SDK_VERSION; i >= MPC_DX_SDK_NUMBER; i--) {
+ m_strD3DX9Version.Format(_T("d3dx9_%u.dll"), i);
+ m_hD3DX9Dll = LoadLibrary(m_strD3DX9Version);
+ if (m_hD3DX9Dll) {
+ m_nDXSdkRelease = i;
+ break;
+ }
+ }
+ }
- return m_hD3DX9Dll;
+ return m_hD3DX9Dll;
}
diff --git a/src/filters/renderer/VideoRenderers/RenderersSettings.h b/src/filters/renderer/VideoRenderers/RenderersSettings.h
index 2744dc0f3..867b644af 100644
--- a/src/filters/renderer/VideoRenderers/RenderersSettings.h
+++ b/src/filters/renderer/VideoRenderers/RenderersSettings.h
@@ -24,143 +24,143 @@
#pragma once
enum {
- WM_REARRANGERENDERLESS = WM_APP+1,
- WM_RESET_DEVICE,
+ WM_REARRANGERENDERLESS = WM_APP + 1,
+ WM_RESET_DEVICE,
};
#define WM_MYMOUSELAST WM_XBUTTONDBLCLK
enum {
- VIDRNDT_RM_DEFAULT,
- VIDRNDT_RM_DX7,
- VIDRNDT_RM_DX9,
+ VIDRNDT_RM_DEFAULT,
+ VIDRNDT_RM_DX7,
+ VIDRNDT_RM_DX9,
};
enum {
- VIDRNDT_QT_DEFAULT,
- VIDRNDT_QT_DX7,
- VIDRNDT_QT_DX9,
+ VIDRNDT_QT_DEFAULT,
+ VIDRNDT_QT_DX7,
+ VIDRNDT_QT_DX9,
};
enum {
- VIDRNDT_AP_SURFACE,
- VIDRNDT_AP_TEXTURE2D,
- VIDRNDT_AP_TEXTURE3D,
+ VIDRNDT_AP_SURFACE,
+ VIDRNDT_AP_TEXTURE2D,
+ VIDRNDT_AP_TEXTURE3D,
};
enum VideoSystem {
- VIDEO_SYSTEM_UNKNOWN,
- VIDEO_SYSTEM_HDTV,
- VIDEO_SYSTEM_SDTV_NTSC,
- VIDEO_SYSTEM_SDTV_PAL,
+ VIDEO_SYSTEM_UNKNOWN,
+ VIDEO_SYSTEM_HDTV,
+ VIDEO_SYSTEM_SDTV_NTSC,
+ VIDEO_SYSTEM_SDTV_PAL,
};
enum AmbientLight {
- AMBIENT_LIGHT_BRIGHT,
- AMBIENT_LIGHT_DIM,
- AMBIENT_LIGHT_DARK,
+ AMBIENT_LIGHT_BRIGHT,
+ AMBIENT_LIGHT_DIM,
+ AMBIENT_LIGHT_DARK,
};
enum ColorRenderingIntent {
- COLOR_RENDERING_INTENT_PERCEPTUAL,
- COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC,
- COLOR_RENDERING_INTENT_SATURATION,
- COLOR_RENDERING_INTENT_ABSOLUTE_COLORIMETRIC,
+ COLOR_RENDERING_INTENT_PERCEPTUAL,
+ COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC,
+ COLOR_RENDERING_INTENT_SATURATION,
+ COLOR_RENDERING_INTENT_ABSOLUTE_COLORIMETRIC,
};
class CRenderersSettings
{
public:
- bool fResetDevice;
-
- class CRendererSettingsShared
- {
- public:
- CRendererSettingsShared() {SetDefault();}
- bool fVMR9AlterativeVSync;
- int iVMR9VSyncOffset;
- bool iVMR9VSyncAccurate;
- bool iVMR9FullscreenGUISupport;
- bool iVMR9VSync;
- bool iVMR9FullFloatingPointProcessing;
- bool iVMR9HalfFloatingPointProcessing;
- bool iVMR9ColorManagementEnable;
- int iVMR9ColorManagementInput;
- int iVMR9ColorManagementAmbientLight;
- int iVMR9ColorManagementIntent;
- bool iVMRDisableDesktopComposition;
- int iVMRFlushGPUBeforeVSync;
- int iVMRFlushGPUAfterPresent;
- int iVMRFlushGPUWait;
-
- // SyncRenderer settings
- int bSynchronizeVideo;
- int bSynchronizeDisplay;
- int bSynchronizeNearest;
- int iLineDelta;
- int iColumnDelta;
- double fCycleDelta;
- double fTargetSyncOffset;
- double fControlLimit;
- protected:
- void SetDefault();
- void SetOptimal();
- };
- class CRendererSettingsEVR : public CRendererSettingsShared
- {
- public:
- bool iEVRHighColorResolution;
- bool iEVRForceInputHighColorResolution;
- bool iEVREnableFrameTimeCorrection;
- int iEVROutputRange;
-
- CRendererSettingsEVR() {SetDefault();}
- void SetDefault();
- void SetOptimal();
- };
-
- CRendererSettingsEVR m_RenderSettings;
-
- int iAPSurfaceUsage;
- int iDX9Resizer;
- bool fVMR9MixerMode;
- bool fVMR9MixerYUV;
- int iEvrBuffers;
-
- int nSPCSize;
- int nSPCMaxRes;
- bool fSPCPow2Tex;
- bool fSPCAllowAnimationWhenBuffering;
-
- CString D3D9RenderDevice;
- void UpdateData(bool fSave);
+ bool fResetDevice;
+
+ class CRendererSettingsShared
+ {
+ public:
+ CRendererSettingsShared() {SetDefault();}
+ bool fVMR9AlterativeVSync;
+ int iVMR9VSyncOffset;
+ bool iVMR9VSyncAccurate;
+ bool iVMR9FullscreenGUISupport;
+ bool iVMR9VSync;
+ bool iVMR9FullFloatingPointProcessing;
+ bool iVMR9HalfFloatingPointProcessing;
+ bool iVMR9ColorManagementEnable;
+ int iVMR9ColorManagementInput;
+ int iVMR9ColorManagementAmbientLight;
+ int iVMR9ColorManagementIntent;
+ bool iVMRDisableDesktopComposition;
+ int iVMRFlushGPUBeforeVSync;
+ int iVMRFlushGPUAfterPresent;
+ int iVMRFlushGPUWait;
+
+ // SyncRenderer settings
+ int bSynchronizeVideo;
+ int bSynchronizeDisplay;
+ int bSynchronizeNearest;
+ int iLineDelta;
+ int iColumnDelta;
+ double fCycleDelta;
+ double fTargetSyncOffset;
+ double fControlLimit;
+ protected:
+ void SetDefault();
+ void SetOptimal();
+ };
+ class CRendererSettingsEVR : public CRendererSettingsShared
+ {
+ public:
+ bool iEVRHighColorResolution;
+ bool iEVRForceInputHighColorResolution;
+ bool iEVREnableFrameTimeCorrection;
+ int iEVROutputRange;
+
+ CRendererSettingsEVR() {SetDefault();}
+ void SetDefault();
+ void SetOptimal();
+ };
+
+ CRendererSettingsEVR m_RenderSettings;
+
+ int iAPSurfaceUsage;
+ int iDX9Resizer;
+ bool fVMR9MixerMode;
+ bool fVMR9MixerYUV;
+ int iEvrBuffers;
+
+ int nSPCSize;
+ int nSPCMaxRes;
+ bool fSPCPow2Tex;
+ bool fSPCAllowAnimationWhenBuffering;
+
+ CString D3D9RenderDevice;
+ void UpdateData(bool fSave);
};
class CRenderersData
{
- HINSTANCE m_hD3DX9Dll;
- UINT m_nDXSdkRelease;
+ HINSTANCE m_hD3DX9Dll;
+ UINT m_nDXSdkRelease;
public:
- CRenderersData();
+ CRenderersData();
- // Casimir666
- bool m_fTearingTest;
- int m_fDisplayStats;
- bool m_bResetStats; // Set to reset the presentation statistics
- CString m_strD3DX9Version;
+ // Casimir666
+ bool m_fTearingTest;
+ int m_fDisplayStats;
+ bool m_bResetStats; // Set to reset the presentation statistics
+ CString m_strD3DX9Version;
- // Hardware feature support
- bool m_bFP16Support;
- bool m_b10bitSupport;
+ // Hardware feature support
+ bool m_bFP16Support;
+ bool m_b10bitSupport;
- LONGLONG GetPerfCounter();
- HINSTANCE GetD3X9Dll();
- UINT GetDXSdkRelease() {return m_nDXSdkRelease;};
+ LONGLONG GetPerfCounter();
+ HINSTANCE GetD3X9Dll();
+ UINT GetDXSdkRelease() {return m_nDXSdkRelease;};
};
-extern CRenderersData* GetRenderersData();
-extern CRenderersSettings& GetRenderersSettings();
+extern CRenderersData* GetRenderersData();
+extern CRenderersSettings& GetRenderersSettings();
extern bool LoadResource(UINT resid, CStringA& str, LPCTSTR restype);
diff --git a/src/filters/renderer/VideoRenderers/SyncAllocatorPresenter.h b/src/filters/renderer/VideoRenderers/SyncAllocatorPresenter.h
index 52a0aab4b..baca58d3f 100644
--- a/src/filters/renderer/VideoRenderers/SyncAllocatorPresenter.h
+++ b/src/filters/renderer/VideoRenderers/SyncAllocatorPresenter.h
@@ -29,7 +29,7 @@ DEFINE_GUID(CLSID_SyncAllocatorPresenter, 0xf9f62627, 0xe3ef, 0x4a2e, 0xb6, 0xc9
interface __declspec(uuid("F891C2A9-1DFF-45e0-9129-30C0990C5A9F"))
ISyncClockAdviser :
public IUnknown {
- STDMETHOD (AdviseSyncClock)(ISyncClock* sC) PURE;
+ STDMETHOD(AdviseSyncClock)(ISyncClock * sC) PURE;
};
HRESULT CreateSyncRenderer(const CLSID& clsid, HWND hWnd, bool bFullscreen, ISubPicAllocatorPresenter** ppAP);
diff --git a/src/filters/renderer/VideoRenderers/SyncRenderer.cpp b/src/filters/renderer/VideoRenderers/SyncRenderer.cpp
index ea8601b6f..829c2559b 100644
--- a/src/filters/renderer/VideoRenderers/SyncRenderer.cpp
+++ b/src/filters/renderer/VideoRenderers/SyncRenderer.cpp
@@ -53,4325 +53,4328 @@ using namespace GothSync;
extern bool LoadResource(UINT resid, CStringA& str, LPCTSTR restype);
-CBaseAP::CBaseAP(HWND hWnd, bool bFullscreen, HRESULT& hr, CString &_Error):
- CSubPicAllocatorPresenterImpl(hWnd, hr, &_Error),
- m_ScreenSize(0, 0),
- m_bicubicA(0),
- m_nDXSurface(1),
- m_nVMR9Surfaces(0),
- m_iVMR9Surface(0),
- m_nCurSurface(0),
- m_bSnapToVSync(false),
- m_bInterlaced(0),
- m_nUsedBuffer(0),
- m_TextScale(1.0),
- m_dMainThreadId(0),
- m_bNeedCheckSample(true),
- m_hEvtQuit(INVALID_HANDLE_VALUE),
- m_bIsFullscreen(bFullscreen),
- m_uSyncGlitches(0),
- m_pGenlock(NULL),
- m_lAudioLag(0),
- m_lAudioLagMin(10000),
- m_lAudioLagMax(-10000),
- m_pAudioStats(NULL),
- m_nNextJitter(0),
- m_nNextSyncOffset(0),
- m_llLastSyncTime(0),
- m_fAvrFps(0.0),
- m_fJitterStdDev(0.0),
- m_fSyncOffsetStdDev(0.0),
- m_fSyncOffsetAvr(0.0),
- m_llHysteresis(0),
- m_uD3DRefreshRate(0),
- m_dD3DRefreshCycle(0),
- m_dDetectedScanlineTime(0.0),
- m_dEstRefreshCycle(0.0),
- m_dFrameCycle(0.0),
- m_dOptimumDisplayCycle(0.0),
- m_dCycleDifference(1.0),
- m_llEstVBlankTime(0),
- m_CurrentAdapter(0)
-{
- if (FAILED(hr)) {
- _Error += L"ISubPicAllocatorPresenterImpl failed\n";
- return;
- }
-
- HINSTANCE hDll;
- m_pD3DXLoadSurfaceFromMemory = NULL;
- m_pD3DXCreateLine = NULL;
- m_pD3DXCreateFont = NULL;
- m_pD3DXCreateSprite = NULL;
- hDll = GetRenderersData()->GetD3X9Dll();
- if (hDll) {
- (FARPROC &)m_pD3DXLoadSurfaceFromMemory = GetProcAddress(hDll, "D3DXLoadSurfaceFromMemory");
- (FARPROC &)m_pD3DXCreateLine = GetProcAddress(hDll, "D3DXCreateLine");
- (FARPROC &)m_pD3DXCreateFont = GetProcAddress(hDll, "D3DXCreateFontW");
- (FARPROC &)m_pD3DXCreateSprite = GetProcAddress(hDll, "D3DXCreateSprite");
- } else {
- _Error += L"The installed DirectX End-User Runtime is outdated. Please download and install the ";
- _Error += MPC_DX_SDK_MONTH " " MAKE_STR(MPC_DX_SDK_YEAR);
- _Error += L" release or newer in order for MPC-HC to function properly.\n";
- }
-
- m_pDwmIsCompositionEnabled = NULL;
- m_pDwmEnableComposition = NULL;
- m_hDWMAPI = LoadLibrary(L"dwmapi.dll");
- if (m_hDWMAPI) {
- (FARPROC &)m_pDwmIsCompositionEnabled = GetProcAddress(m_hDWMAPI, "DwmIsCompositionEnabled");
- (FARPROC &)m_pDwmEnableComposition = GetProcAddress(m_hDWMAPI, "DwmEnableComposition");
- }
-
- m_pDirect3DCreate9Ex = NULL;
- m_hD3D9 = LoadLibrary(L"d3d9.dll");
+CBaseAP::CBaseAP(HWND hWnd, bool bFullscreen, HRESULT& hr, CString& _Error):
+ CSubPicAllocatorPresenterImpl(hWnd, hr, &_Error),
+ m_ScreenSize(0, 0),
+ m_bicubicA(0),
+ m_nDXSurface(1),
+ m_nVMR9Surfaces(0),
+ m_iVMR9Surface(0),
+ m_nCurSurface(0),
+ m_bSnapToVSync(false),
+ m_bInterlaced(0),
+ m_nUsedBuffer(0),
+ m_TextScale(1.0),
+ m_dMainThreadId(0),
+ m_bNeedCheckSample(true),
+ m_hEvtQuit(INVALID_HANDLE_VALUE),
+ m_bIsFullscreen(bFullscreen),
+ m_uSyncGlitches(0),
+ m_pGenlock(NULL),
+ m_lAudioLag(0),
+ m_lAudioLagMin(10000),
+ m_lAudioLagMax(-10000),
+ m_pAudioStats(NULL),
+ m_nNextJitter(0),
+ m_nNextSyncOffset(0),
+ m_llLastSyncTime(0),
+ m_fAvrFps(0.0),
+ m_fJitterStdDev(0.0),
+ m_fSyncOffsetStdDev(0.0),
+ m_fSyncOffsetAvr(0.0),
+ m_llHysteresis(0),
+ m_uD3DRefreshRate(0),
+ m_dD3DRefreshCycle(0),
+ m_dDetectedScanlineTime(0.0),
+ m_dEstRefreshCycle(0.0),
+ m_dFrameCycle(0.0),
+ m_dOptimumDisplayCycle(0.0),
+ m_dCycleDifference(1.0),
+ m_llEstVBlankTime(0),
+ m_CurrentAdapter(0)
+{
+ if (FAILED(hr)) {
+ _Error += L"ISubPicAllocatorPresenterImpl failed\n";
+ return;
+ }
+
+ HINSTANCE hDll;
+ m_pD3DXLoadSurfaceFromMemory = NULL;
+ m_pD3DXCreateLine = NULL;
+ m_pD3DXCreateFont = NULL;
+ m_pD3DXCreateSprite = NULL;
+ hDll = GetRenderersData()->GetD3X9Dll();
+ if (hDll) {
+ (FARPROC&)m_pD3DXLoadSurfaceFromMemory = GetProcAddress(hDll, "D3DXLoadSurfaceFromMemory");
+ (FARPROC&)m_pD3DXCreateLine = GetProcAddress(hDll, "D3DXCreateLine");
+ (FARPROC&)m_pD3DXCreateFont = GetProcAddress(hDll, "D3DXCreateFontW");
+ (FARPROC&)m_pD3DXCreateSprite = GetProcAddress(hDll, "D3DXCreateSprite");
+ } else {
+ _Error += L"The installed DirectX End-User Runtime is outdated. Please download and install the ";
+ _Error += MPC_DX_SDK_MONTH " " MAKE_STR(MPC_DX_SDK_YEAR);
+ _Error += L" release or newer in order for MPC-HC to function properly.\n";
+ }
+
+ m_pDwmIsCompositionEnabled = NULL;
+ m_pDwmEnableComposition = NULL;
+ m_hDWMAPI = LoadLibrary(L"dwmapi.dll");
+ if (m_hDWMAPI) {
+ (FARPROC&)m_pDwmIsCompositionEnabled = GetProcAddress(m_hDWMAPI, "DwmIsCompositionEnabled");
+ (FARPROC&)m_pDwmEnableComposition = GetProcAddress(m_hDWMAPI, "DwmEnableComposition");
+ }
+
+ m_pDirect3DCreate9Ex = NULL;
+ m_hD3D9 = LoadLibrary(L"d3d9.dll");
#ifndef DISABLE_USING_D3D9EX
- if (m_hD3D9) {
- (FARPROC &)m_pDirect3DCreate9Ex = GetProcAddress(m_hD3D9, "Direct3DCreate9Ex");
- }
+ if (m_hD3D9) {
+ (FARPROC&)m_pDirect3DCreate9Ex = GetProcAddress(m_hD3D9, "Direct3DCreate9Ex");
+ }
#endif
- if (m_pDirect3DCreate9Ex) {
- DEBUG_ONLY(_tprintf_s(_T("m_pDirect3DCreate9Ex\n")));
- m_pDirect3DCreate9Ex(D3D_SDK_VERSION, &m_pD3DEx);
- if (!m_pD3DEx) {
- m_pDirect3DCreate9Ex(D3D9b_SDK_VERSION, &m_pD3DEx);
- }
- }
- if (!m_pD3DEx) {
- m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
- if (!m_pD3D) {
- m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
- }
- if (m_pD3D) {
- DEBUG_ONLY(_tprintf_s(_T("m_pDirect3DCreate9\n")));
- }
- } else {
- m_pD3D = m_pD3DEx;
- }
-
- ZeroMemory(&m_VMR9AlphaBitmap, sizeof(m_VMR9AlphaBitmap));
-
- CRenderersSettings& s = GetRenderersSettings();
- if (s.m_RenderSettings.iVMRDisableDesktopComposition) {
- m_bDesktopCompositionDisabled = true;
- if (m_pDwmEnableComposition) {
- m_pDwmEnableComposition(0);
- }
- } else {
- m_bDesktopCompositionDisabled = false;
- }
-
- m_pGenlock = DNew CGenlock(s.m_RenderSettings.fTargetSyncOffset, s.m_RenderSettings.fControlLimit, s.m_RenderSettings.iLineDelta, s.m_RenderSettings.iColumnDelta, s.m_RenderSettings.fCycleDelta, 0); // Must be done before CreateDXDevice
- hr = CreateDXDevice(_Error);
- memset (m_pllJitter, 0, sizeof(m_pllJitter));
- memset (m_pllSyncOffset, 0, sizeof(m_pllSyncOffset));
+ if (m_pDirect3DCreate9Ex) {
+ DEBUG_ONLY(_tprintf_s(_T("m_pDirect3DCreate9Ex\n")));
+ m_pDirect3DCreate9Ex(D3D_SDK_VERSION, &m_pD3DEx);
+ if (!m_pD3DEx) {
+ m_pDirect3DCreate9Ex(D3D9b_SDK_VERSION, &m_pD3DEx);
+ }
+ }
+ if (!m_pD3DEx) {
+ m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
+ if (!m_pD3D) {
+ m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
+ }
+ if (m_pD3D) {
+ DEBUG_ONLY(_tprintf_s(_T("m_pDirect3DCreate9\n")));
+ }
+ } else {
+ m_pD3D = m_pD3DEx;
+ }
+
+ ZeroMemory(&m_VMR9AlphaBitmap, sizeof(m_VMR9AlphaBitmap));
+
+ CRenderersSettings& s = GetRenderersSettings();
+ if (s.m_RenderSettings.iVMRDisableDesktopComposition) {
+ m_bDesktopCompositionDisabled = true;
+ if (m_pDwmEnableComposition) {
+ m_pDwmEnableComposition(0);
+ }
+ } else {
+ m_bDesktopCompositionDisabled = false;
+ }
+
+ m_pGenlock = DNew CGenlock(s.m_RenderSettings.fTargetSyncOffset, s.m_RenderSettings.fControlLimit, s.m_RenderSettings.iLineDelta, s.m_RenderSettings.iColumnDelta, s.m_RenderSettings.fCycleDelta, 0); // Must be done before CreateDXDevice
+ hr = CreateDXDevice(_Error);
+ memset(m_pllJitter, 0, sizeof(m_pllJitter));
+ memset(m_pllSyncOffset, 0, sizeof(m_pllSyncOffset));
}
CBaseAP::~CBaseAP()
{
- if (m_bDesktopCompositionDisabled) {
- m_bDesktopCompositionDisabled = false;
- if (m_pDwmEnableComposition) {
- m_pDwmEnableComposition(1);
- }
- }
-
- m_pFont = NULL;
- m_pLine = NULL;
- m_pD3DDev = NULL;
- m_pD3DDevEx = NULL;
- m_pPSC.Free();
- m_pD3D = NULL;
- m_pD3DEx = NULL;
- if (m_hDWMAPI) {
- FreeLibrary(m_hDWMAPI);
- m_hDWMAPI = NULL;
- }
- if (m_hD3D9) {
- FreeLibrary(m_hD3D9);
- m_hD3D9 = NULL;
- }
- m_pAudioStats = NULL;
- if (m_pGenlock) {
- delete m_pGenlock;
- m_pGenlock = NULL;
- }
+ if (m_bDesktopCompositionDisabled) {
+ m_bDesktopCompositionDisabled = false;
+ if (m_pDwmEnableComposition) {
+ m_pDwmEnableComposition(1);
+ }
+ }
+
+ m_pFont = NULL;
+ m_pLine = NULL;
+ m_pD3DDev = NULL;
+ m_pD3DDevEx = NULL;
+ m_pPSC.Free();
+ m_pD3D = NULL;
+ m_pD3DEx = NULL;
+ if (m_hDWMAPI) {
+ FreeLibrary(m_hDWMAPI);
+ m_hDWMAPI = NULL;
+ }
+ if (m_hD3D9) {
+ FreeLibrary(m_hD3D9);
+ m_hD3D9 = NULL;
+ }
+ m_pAudioStats = NULL;
+ if (m_pGenlock) {
+ delete m_pGenlock;
+ m_pGenlock = NULL;
+ }
}
template<int texcoords>
void CBaseAP::AdjustQuad(MYD3DVERTEX<texcoords>* v, double dx, double dy)
{
- float offset = 0.5;
+ float offset = 0.5;
- for (int i = 0; i < 4; i++) {
- v[i].x -= offset;
- v[i].y -= offset;
+ for (int i = 0; i < 4; i++) {
+ v[i].x -= offset;
+ v[i].y -= offset;
- for (int j = 0; j < max(texcoords-1, 1); j++) {
- v[i].t[j].u -= (float)(offset*dx);
- v[i].t[j].v -= (float)(offset*dy);
- }
+ for (int j = 0; j < max(texcoords - 1, 1); j++) {
+ v[i].t[j].u -= (float)(offset * dx);
+ v[i].t[j].v -= (float)(offset * dy);
+ }
- if (texcoords > 1) {
- v[i].t[texcoords-1].u -= offset;
- v[i].t[texcoords-1].v -= offset;
- }
- }
+ if (texcoords > 1) {
+ v[i].t[texcoords - 1].u -= offset;
+ v[i].t[texcoords - 1].v -= offset;
+ }
+ }
}
template<int texcoords>
HRESULT CBaseAP::TextureBlt(IDirect3DDevice9* pD3DDev, MYD3DVERTEX<texcoords> v[4], D3DTEXTUREFILTERTYPE filter = D3DTEXF_LINEAR)
{
- if (!pD3DDev) {
- return E_POINTER;
- }
-
- DWORD FVF = 0;
- switch (texcoords) {
- case 1:
- FVF = D3DFVF_TEX1;
- break;
- case 2:
- FVF = D3DFVF_TEX2;
- break;
- case 3:
- FVF = D3DFVF_TEX3;
- break;
- case 4:
- FVF = D3DFVF_TEX4;
- break;
- case 5:
- FVF = D3DFVF_TEX5;
- break;
- case 6:
- FVF = D3DFVF_TEX6;
- break;
- case 7:
- FVF = D3DFVF_TEX7;
- break;
- case 8:
- FVF = D3DFVF_TEX8;
- break;
- default:
- return E_FAIL;
- }
-
- HRESULT hr;
- hr = pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
- hr = pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_STENCILENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED);
-
- for (int i = 0; i < texcoords; i++) {
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_MAGFILTER, filter);
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_MINFILTER, filter);
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
-
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
- hr = pD3DDev->SetSamplerState(i, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
- }
-
- hr = pD3DDev->SetFVF(D3DFVF_XYZRHW | FVF);
-
- MYD3DVERTEX<texcoords> tmp = v[2];
- v[2] = v[3];
- v[3] = tmp;
- hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
-
- for (int i = 0; i < texcoords; i++) {
- pD3DDev->SetTexture(i, NULL);
- }
-
- return S_OK;
+ if (!pD3DDev) {
+ return E_POINTER;
+ }
+
+ DWORD FVF = 0;
+ switch (texcoords) {
+ case 1:
+ FVF = D3DFVF_TEX1;
+ break;
+ case 2:
+ FVF = D3DFVF_TEX2;
+ break;
+ case 3:
+ FVF = D3DFVF_TEX3;
+ break;
+ case 4:
+ FVF = D3DFVF_TEX4;
+ break;
+ case 5:
+ FVF = D3DFVF_TEX5;
+ break;
+ case 6:
+ FVF = D3DFVF_TEX6;
+ break;
+ case 7:
+ FVF = D3DFVF_TEX7;
+ break;
+ case 8:
+ FVF = D3DFVF_TEX8;
+ break;
+ default:
+ return E_FAIL;
+ }
+
+ HRESULT hr;
+ hr = pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
+ hr = pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_STENCILENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED);
+
+ for (int i = 0; i < texcoords; i++) {
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_MAGFILTER, filter);
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_MINFILTER, filter);
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
+
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
+ hr = pD3DDev->SetSamplerState(i, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
+ }
+
+ hr = pD3DDev->SetFVF(D3DFVF_XYZRHW | FVF);
+
+ MYD3DVERTEX<texcoords> tmp = v[2];
+ v[2] = v[3];
+ v[3] = tmp;
+ hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
+
+ for (int i = 0; i < texcoords; i++) {
+ pD3DDev->SetTexture(i, NULL);
+ }
+
+ return S_OK;
}
HRESULT CBaseAP::DrawRectBase(IDirect3DDevice9* pD3DDev, MYD3DVERTEX<0> v[4])
{
- if (!pD3DDev) {
- return E_POINTER;
- }
+ if (!pD3DDev) {
+ return E_POINTER;
+ }
- HRESULT hr = pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
- hr = pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_STENCILENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- hr = pD3DDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- hr = pD3DDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
- hr = pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
+ HRESULT hr = pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
+ hr = pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_STENCILENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ hr = pD3DDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
+ hr = pD3DDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
+ hr = pD3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
+ hr = pD3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
- hr = pD3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED);
+ hr = pD3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED);
- hr = pD3DDev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX0 | D3DFVF_DIFFUSE);
+ hr = pD3DDev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX0 | D3DFVF_DIFFUSE);
- MYD3DVERTEX<0> tmp = v[2];
- v[2] = v[3];
- v[3] = tmp;
- hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
+ MYD3DVERTEX<0> tmp = v[2];
+ v[2] = v[3];
+ v[3] = tmp;
+ hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
- return S_OK;
+ return S_OK;
}
MFOffset CBaseAP::GetOffset(float v)
{
- MFOffset offset;
- offset.value = short(v);
- offset.fract = WORD(65536 * (v-offset.value));
- return offset;
+ MFOffset offset;
+ offset.value = short(v);
+ offset.fract = WORD(65536 * (v - offset.value));
+ return offset;
}
MFVideoArea CBaseAP::GetArea(float x, float y, DWORD width, DWORD height)
{
- MFVideoArea area;
- area.OffsetX = GetOffset(x);
- area.OffsetY = GetOffset(y);
- area.Area.cx = width;
- area.Area.cy = height;
- return area;
+ MFVideoArea area;
+ area.OffsetX = GetOffset(x);
+ area.OffsetY = GetOffset(y);
+ area.Area.cx = width;
+ area.Area.cy = height;
+ return area;
}
void CBaseAP::ResetStats()
{
- m_pGenlock->ResetStats();
- m_lAudioLag = 0;
- m_lAudioLagMin = 10000;
- m_lAudioLagMax = -10000;
- m_MinJitter = MAXLONG64;
- m_MaxJitter = MINLONG64;
- m_MinSyncOffset = MAXLONG64;
- m_MaxSyncOffset = MINLONG64;
- m_uSyncGlitches = 0;
- m_pcFramesDropped = 0;
+ m_pGenlock->ResetStats();
+ m_lAudioLag = 0;
+ m_lAudioLagMin = 10000;
+ m_lAudioLagMax = -10000;
+ m_MinJitter = MAXLONG64;
+ m_MaxJitter = MINLONG64;
+ m_MinSyncOffset = MAXLONG64;
+ m_MaxSyncOffset = MINLONG64;
+ m_uSyncGlitches = 0;
+ m_pcFramesDropped = 0;
}
bool CBaseAP::SettingsNeedResetDevice()
{
- CRenderersSettings& s = GetRenderersSettings();
- CRenderersSettings::CRendererSettingsEVR & New = s.m_RenderSettings;
- CRenderersSettings::CRendererSettingsEVR & Current = m_LastRendererSettings;
-
- bool bRet = false;
- if (!m_bIsFullscreen) {
- if (Current.iVMRDisableDesktopComposition) {
- if (!m_bDesktopCompositionDisabled) {
- m_bDesktopCompositionDisabled = true;
- if (m_pDwmEnableComposition) {
- m_pDwmEnableComposition(0);
- }
- }
- } else {
- if (m_bDesktopCompositionDisabled) {
- m_bDesktopCompositionDisabled = false;
- if (m_pDwmEnableComposition) {
- m_pDwmEnableComposition(1);
- }
- }
- }
- }
- bRet = bRet || New.iEVRHighColorResolution != Current.iEVRHighColorResolution;
- m_LastRendererSettings = s.m_RenderSettings;
- return bRet;
-}
-
-HRESULT CBaseAP::CreateDXDevice(CString &_Error)
-{
- TRACE("--> CBaseAP::CreateDXDevice on thread: %d\n", GetCurrentThreadId());
- CRenderersSettings& s = GetRenderersSettings();
- m_LastRendererSettings = s.m_RenderSettings;
- HRESULT hr = E_FAIL;
-
- m_pFont = NULL;
- m_pSprite = NULL;
- m_pLine = NULL;
-
- m_pPSC.Free();
- m_pD3DDev = NULL;
- m_pD3DDevEx = NULL;
-
- m_pResizerPixelShader[0] = 0;
- m_pResizerPixelShader[1] = 0;
- m_pResizerPixelShader[2] = 0;
- m_pResizerPixelShader[3] = 0;
-
- POSITION pos = m_pPixelShadersScreenSpace.GetHeadPosition();
- while (pos) {
- CExternalPixelShader &Shader = m_pPixelShadersScreenSpace.GetNext(pos);
- Shader.m_pPixelShader = NULL;
- }
- pos = m_pPixelShaders.GetHeadPosition();
- while (pos) {
- CExternalPixelShader &Shader = m_pPixelShaders.GetNext(pos);
- Shader.m_pPixelShader = NULL;
- }
-
- if (!m_pD3D) {
- _Error += L"Failed to create Direct3D device\n";
- return E_UNEXPECTED;
- }
-
- D3DDISPLAYMODE d3ddm;
- ZeroMemory(&d3ddm, sizeof(d3ddm));
- m_CurrentAdapter = GetAdapter(m_pD3D);
- if (FAILED(m_pD3D->GetAdapterDisplayMode(m_CurrentAdapter, &d3ddm))) {
- _Error += L"Can not retrieve display mode data\n";
- return E_UNEXPECTED;
- }
-
- if (FAILED(m_pD3D->GetDeviceCaps(m_CurrentAdapter, D3DDEVTYPE_HAL, &m_caps)))
- if ((m_caps.Caps & D3DCAPS_READ_SCANLINE) == 0) {
- _Error += L"Video card does not have scanline access. Display synchronization is not possible.\n";
- return E_UNEXPECTED;
- }
-
- m_uD3DRefreshRate = d3ddm.RefreshRate;
- m_dD3DRefreshCycle = 1000.0 / (double)m_uD3DRefreshRate; // In ms
- m_ScreenSize.SetSize(d3ddm.Width, d3ddm.Height);
- m_pGenlock->SetDisplayResolution(d3ddm.Width, d3ddm.Height);
-
- BOOL bCompositionEnabled = false;
- if (m_pDwmIsCompositionEnabled) {
- m_pDwmIsCompositionEnabled(&bCompositionEnabled);
- }
- m_bCompositionEnabled = bCompositionEnabled != 0;
-
- ZeroMemory(&pp, sizeof(pp));
- if (m_bIsFullscreen) { // Exclusive mode fullscreen
- pp.Windowed = FALSE;
- pp.BackBufferWidth = d3ddm.Width;
- pp.BackBufferHeight = d3ddm.Height;
- pp.hDeviceWindow = m_hWnd;
- DEBUG_ONLY(_tprintf_s(_T("Wnd in CreateDXDevice: %p\n"), m_hWnd));
- pp.BackBufferCount = 3;
- pp.SwapEffect = D3DSWAPEFFECT_DISCARD;
- pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
- pp.Flags = D3DPRESENTFLAG_VIDEO;
- m_bHighColorResolution = s.m_RenderSettings.iEVRHighColorResolution;
- if (m_bHighColorResolution) {
- if (FAILED(m_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format, D3DFMT_A2R10G10B10, false))) {
- m_strStatsMsg[MSG_ERROR] = L"10 bit RGB is not supported by this graphics device in this resolution.";
- m_bHighColorResolution = false;
- }
- }
-
- if (m_bHighColorResolution) {
- pp.BackBufferFormat = D3DFMT_A2R10G10B10;
- } else {
- pp.BackBufferFormat = d3ddm.Format;
- }
-
- if (m_pD3DEx) {
- D3DDISPLAYMODEEX DisplayMode;
- ZeroMemory(&DisplayMode, sizeof(DisplayMode));
- DisplayMode.Size = sizeof(DisplayMode);
- m_pD3DEx->GetAdapterDisplayModeEx(m_CurrentAdapter, &DisplayMode, NULL);
-
- DisplayMode.Format = pp.BackBufferFormat;
- pp.FullScreen_RefreshRateInHz = DisplayMode.RefreshRate;
-
- if FAILED(hr = m_pD3DEx->CreateDeviceEx(m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd,
- D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_FPU_PRESERVE|D3DCREATE_MULTITHREADED|D3DCREATE_ENABLE_PRESENTSTATS,
- &pp, &DisplayMode, &m_pD3DDevEx)) {
- _Error += GetWindowsErrorMessage(hr, m_hD3D9);
- return hr;
- }
- if (m_pD3DDevEx) {
- m_pD3DDev = m_pD3DDevEx;
- m_BackbufferType = pp.BackBufferFormat;
- m_DisplayType = DisplayMode.Format;
- }
- } else {
- if FAILED(hr = m_pD3D->CreateDevice(m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_FPU_PRESERVE|D3DCREATE_MULTITHREADED, &pp, &m_pD3DDev)) {
- _Error += GetWindowsErrorMessage(hr, m_hD3D9);
- return hr;
- }
- DEBUG_ONLY(_tprintf_s(_T("Created full-screen device\n")));
- if (m_pD3DDev) {
- m_BackbufferType = pp.BackBufferFormat;
- m_DisplayType = d3ddm.Format;
- }
- }
- } else { // Windowed
- pp.Windowed = TRUE;
- pp.hDeviceWindow = m_hWnd;
- pp.SwapEffect = D3DSWAPEFFECT_COPY;
- pp.Flags = D3DPRESENTFLAG_VIDEO;
- pp.BackBufferCount = 1;
- pp.BackBufferWidth = d3ddm.Width;
- pp.BackBufferHeight = d3ddm.Height;
- m_BackbufferType = d3ddm.Format;
- m_DisplayType = d3ddm.Format;
- m_bHighColorResolution = s.m_RenderSettings.iEVRHighColorResolution;
- if (m_bHighColorResolution) {
- if (FAILED(m_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format, D3DFMT_A2R10G10B10, false))) {
- m_strStatsMsg[MSG_ERROR] = L"10 bit RGB is not supported by this graphics device in this resolution.";
- m_bHighColorResolution = false;
- }
- }
-
- if (m_bHighColorResolution) {
- m_BackbufferType = D3DFMT_A2R10G10B10;
- pp.BackBufferFormat = D3DFMT_A2R10G10B10;
- }
- if (bCompositionEnabled) {
- // Desktop composition presents the whole desktop
- pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
- } else {
- pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
- }
- if (m_pD3DEx) {
- if FAILED(hr = m_pD3DEx->CreateDeviceEx(m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd,
- D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_FPU_PRESERVE|D3DCREATE_MULTITHREADED|D3DCREATE_ENABLE_PRESENTSTATS,
- &pp, NULL, &m_pD3DDevEx)) {
- _Error += GetWindowsErrorMessage(hr, m_hD3D9);
- return hr;
- }
- if (m_pD3DDevEx) {
- m_pD3DDev = m_pD3DDevEx;
- }
- } else {
- if FAILED(hr = m_pD3D->CreateDevice(m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd,
- D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_FPU_PRESERVE|D3DCREATE_MULTITHREADED,
- &pp, &m_pD3DDev)) {
- _Error += GetWindowsErrorMessage(hr, m_hD3D9);
- return hr;
- }
- DEBUG_ONLY(_tprintf_s(_T("Created windowed device\n")));
- }
- }
-
- while (hr == D3DERR_DEVICELOST) {
- TRACE("D3DERR_DEVICELOST. Trying to Reset.\n");
- hr = m_pD3DDev->TestCooperativeLevel();
- }
- if (hr == D3DERR_DEVICENOTRESET) {
- TRACE("D3DERR_DEVICENOTRESET\n");
- hr = m_pD3DDev->Reset(&pp);
- }
-
- TRACE("CreateDevice: %d\n", (LONG)hr);
- ASSERT (SUCCEEDED (hr));
-
- if (m_pD3DDevEx) {
- m_pD3DDevEx->SetGPUThreadPriority(7);
- }
-
- m_pPSC.Attach(DNew CPixelShaderCompiler(m_pD3DDev, true));
- m_filter = D3DTEXF_NONE;
-
- if (m_caps.StretchRectFilterCaps&D3DPTFILTERCAPS_MINFLINEAR && m_caps.StretchRectFilterCaps&D3DPTFILTERCAPS_MAGFLINEAR) {
- m_filter = D3DTEXF_LINEAR;
- }
-
- m_bicubicA = 0;
-
- CSize size;
- switch (GetRenderersSettings().nSPCMaxRes) {
- case 0:
- default:
- size = m_ScreenSize;
- break;
- case 1:
- size.SetSize(1024, 768);
- break;
- case 2:
- size.SetSize(800, 600);
- break;
- case 3:
- size.SetSize(640, 480);
- break;
- case 4:
- size.SetSize(512, 384);
- break;
- case 5:
- size.SetSize(384, 288);
- break;
- case 6:
- size.SetSize(2560, 1600);
- break;
- case 7:
- size.SetSize(1920, 1080);
- break;
- case 8:
- size.SetSize(1320, 900);
- break;
- case 9:
- size.SetSize(1280, 720);
- break;
- }
-
- if (m_pAllocator) {
- m_pAllocator->ChangeDevice(m_pD3DDev);
- } else {
- m_pAllocator = DNew CDX9SubPicAllocator(m_pD3DDev, size, GetRenderersSettings().fSPCPow2Tex, false);
- if (!m_pAllocator) {
- _Error += L"CDX9SubPicAllocator failed\n";
- return E_FAIL;
- }
- }
-
- hr = S_OK;
-
- CComPtr<ISubPicProvider> pSubPicProvider;
- if (m_pSubPicQueue) {
- DEBUG_ONLY(_tprintf_s(_T("m_pSubPicQueue != NULL\n")));
- m_pSubPicQueue->GetSubPicProvider(&pSubPicProvider);
- }
-
- m_pSubPicQueue = NULL;
- m_pSubPicQueue = GetRenderersSettings().nSPCSize > 0
- ? (ISubPicQueue*)DNew CSubPicQueue(GetRenderersSettings().nSPCSize, !GetRenderersSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
- : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
- if (!m_pSubPicQueue || FAILED(hr)) {
- _Error += L"m_pSubPicQueue failed\n";
- return E_FAIL;
- }
-
- if (pSubPicProvider) {
- m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
- }
-
- if (m_pD3DXCreateFont) {
- int MinSize = 1600;
- int CurrentSize = min(m_ScreenSize.cx, MinSize);
- double Scale = double(CurrentSize) / double(MinSize);
- m_TextScale = Scale;
- m_pD3DXCreateFont(m_pD3DDev, (int)(-24.0*Scale), (UINT)(-11.0*Scale), CurrentSize < 800 ? FW_NORMAL : FW_BOLD, 0, FALSE,
- DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FIXED_PITCH | FF_DONTCARE, L"Lucida Console", &m_pFont);
- }
- if (m_pD3DXCreateSprite) {
- m_pD3DXCreateSprite(m_pD3DDev, &m_pSprite);
- }
- if (m_pD3DXCreateLine) {
- m_pD3DXCreateLine (m_pD3DDev, &m_pLine);
- }
- m_LastAdapterCheck = GetRenderersData()->GetPerfCounter();
- return S_OK;
-}
-
-HRESULT CBaseAP::ResetDXDevice(CString &_Error)
-{
- CRenderersSettings& s = GetRenderersSettings();
- m_LastRendererSettings = s.m_RenderSettings;
- HRESULT hr = E_FAIL;
-
- hr = m_pD3DDev->TestCooperativeLevel();
- if ((hr != D3DERR_DEVICENOTRESET) && (hr != D3D_OK)) {
- return hr;
- }
-
- CComPtr<IEnumPins> rendererInputEnum;
- std::vector<CComPtr<IPin>> decoderOutput;
- std::vector<CComPtr<IPin>> rendererInput;
- FILTER_INFO filterInfo;
-
- bool disconnected = FALSE;
-
- // Disconnect all pins to release video memory resources
- if (m_pD3DDev) {
- ZeroMemory(&filterInfo, sizeof(filterInfo));
- m_pOuterEVR->QueryFilterInfo(&filterInfo); // This addref's the pGraph member
- if (SUCCEEDED(m_pOuterEVR->EnumPins(&rendererInputEnum))) {
- CComPtr<IPin> input;
- CComPtr<IPin> output;
- while (hr = rendererInputEnum->Next(1, &input.p, 0), hr == S_OK) { // Must have .p here
- DEBUG_ONLY(_tprintf_s(_T("Pin found\n")));
- input->ConnectedTo(&output.p);
- if (output != NULL) {
- rendererInput.push_back(input);
- decoderOutput.push_back(output);
- }
- input.Release();
- output.Release();
- }
- } else {
- return hr;
- }
- for (DWORD i = 0; i < decoderOutput.size(); i++) {
- DEBUG_ONLY(_tprintf_s(_T("Disconnecting pin\n")));
- filterInfo.pGraph->Disconnect(decoderOutput.at(i).p);
- filterInfo.pGraph->Disconnect(rendererInput.at(i).p);
- DEBUG_ONLY(_tprintf_s(_T("Pin disconnected\n")));
- }
- disconnected = true;
- }
-
- // Release more resources
- m_pSubPicQueue = NULL;
- m_pFont = NULL;
- m_pSprite = NULL;
- m_pLine = NULL;
- m_pPSC.Free();
-
- m_pResizerPixelShader[0] = 0;
- m_pResizerPixelShader[1] = 0;
- m_pResizerPixelShader[2] = 0;
- m_pResizerPixelShader[3] = 0;
-
- POSITION pos = m_pPixelShadersScreenSpace.GetHeadPosition();
- while (pos) {
- CExternalPixelShader &Shader = m_pPixelShadersScreenSpace.GetNext(pos);
- Shader.m_pPixelShader = NULL;
- }
- pos = m_pPixelShaders.GetHeadPosition();
- while (pos) {
- CExternalPixelShader &Shader = m_pPixelShaders.GetNext(pos);
- Shader.m_pPixelShader = NULL;
- }
-
- D3DDISPLAYMODE d3ddm;
- ZeroMemory(&d3ddm, sizeof(d3ddm));
- if (FAILED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm))) {
- _Error += L"Can not retrieve display mode data\n";
- return E_UNEXPECTED;
- }
-
- m_uD3DRefreshRate = d3ddm.RefreshRate;
- m_dD3DRefreshCycle = 1000.0 / (double)m_uD3DRefreshRate; // In ms
- m_ScreenSize.SetSize(d3ddm.Width, d3ddm.Height);
- m_pGenlock->SetDisplayResolution(d3ddm.Width, d3ddm.Height);
-
- D3DPRESENT_PARAMETERS pp;
- ZeroMemory(&pp, sizeof(pp));
-
- BOOL bCompositionEnabled = false;
- if (m_pDwmIsCompositionEnabled) {
- m_pDwmIsCompositionEnabled(&bCompositionEnabled);
- }
- m_bCompositionEnabled = bCompositionEnabled != 0;
- m_bHighColorResolution = s.m_RenderSettings.iEVRHighColorResolution;
-
- if (m_bIsFullscreen) { // Exclusive mode fullscreen
- pp.BackBufferWidth = d3ddm.Width;
- pp.BackBufferHeight = d3ddm.Height;
- if (m_bHighColorResolution) {
- pp.BackBufferFormat = D3DFMT_A2R10G10B10;
- } else {
- pp.BackBufferFormat = d3ddm.Format;
- }
- if (FAILED(m_pD3DEx->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, pp.BackBufferFormat, pp.BackBufferFormat, false))) {
- _Error += L"10 bit RGB is not supported by this graphics device in exclusive mode fullscreen.\n";
- return hr;
- }
-
- D3DDISPLAYMODEEX DisplayMode;
- ZeroMemory(&DisplayMode, sizeof(DisplayMode));
- DisplayMode.Size = sizeof(DisplayMode);
- if (m_pD3DDevEx) {
- m_pD3DEx->GetAdapterDisplayModeEx(GetAdapter(m_pD3DEx), &DisplayMode, NULL);
- DisplayMode.Format = pp.BackBufferFormat;
- pp.FullScreen_RefreshRateInHz = DisplayMode.RefreshRate;
- if FAILED(m_pD3DDevEx->Reset(&pp)) {
- _Error += GetWindowsErrorMessage(hr, m_hD3D9);
- return hr;
- }
- } else if (m_pD3DDev) {
- if FAILED(m_pD3DDev->Reset(&pp)) {
- _Error += GetWindowsErrorMessage(hr, m_hD3D9);
- return hr;
- }
- } else {
- _Error += L"No device.\n";
- return hr;
- }
- m_BackbufferType = pp.BackBufferFormat;
- m_DisplayType = d3ddm.Format;
- } else { // Windowed
- pp.BackBufferWidth = d3ddm.Width;
- pp.BackBufferHeight = d3ddm.Height;
- m_BackbufferType = d3ddm.Format;
- m_DisplayType = d3ddm.Format;
- if (m_bHighColorResolution) {
- m_BackbufferType = D3DFMT_A2R10G10B10;
- pp.BackBufferFormat = D3DFMT_A2R10G10B10;
- }
- if (FAILED(m_pD3DEx->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, pp.BackBufferFormat, pp.BackBufferFormat, false))) {
- _Error += L"10 bit RGB is not supported by this graphics device in windowed mode.\n";
- return hr;
- }
- if (bCompositionEnabled) {
- // Desktop composition presents the whole desktop
- pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
- } else {
- pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
- }
- if (m_pD3DDevEx)
- if FAILED(m_pD3DDevEx->Reset(&pp)) {
- _Error += GetWindowsErrorMessage(hr, m_hD3D9);
- return hr;
- } else if (m_pD3DDev)
- if FAILED(m_pD3DDevEx->Reset(&pp)) {
- _Error += GetWindowsErrorMessage(hr, m_hD3D9);
- return hr;
- } else {
- _Error += L"No device.\n";
- return hr;
- }
- }
-
- if (disconnected) {
- for (DWORD i = 0; i < decoderOutput.size(); i++) {
- if (FAILED(filterInfo.pGraph->ConnectDirect(decoderOutput.at(i).p, rendererInput.at(i).p, NULL))) {
- return hr;
- }
- }
-
- if (filterInfo.pGraph != NULL) {
- filterInfo.pGraph->Release();
- }
- }
-
- m_pPSC.Attach(DNew CPixelShaderCompiler(m_pD3DDev, true));
- m_filter = D3DTEXF_NONE;
-
- if ((m_caps.StretchRectFilterCaps&D3DPTFILTERCAPS_MINFLINEAR)
- && (m_caps.StretchRectFilterCaps&D3DPTFILTERCAPS_MAGFLINEAR)) {
- m_filter = D3DTEXF_LINEAR;
- }
-
- m_bicubicA = 0;
-
- CComPtr<ISubPicProvider> pSubPicProvider;
- if (m_pSubPicQueue) {
- m_pSubPicQueue->GetSubPicProvider(&pSubPicProvider);
- }
- CSize size;
- switch (GetRenderersSettings().nSPCMaxRes) {
- case 0:
- default:
- size = m_ScreenSize;
- break;
- case 1:
- size.SetSize(1024, 768);
- break;
- case 2:
- size.SetSize(800, 600);
- break;
- case 3:
- size.SetSize(640, 480);
- break;
- case 4:
- size.SetSize(512, 384);
- break;
- case 5:
- size.SetSize(384, 288);
- break;
- case 6:
- size.SetSize(2560, 1600);
- break;
- case 7:
- size.SetSize(1920, 1080);
- break;
- case 8:
- size.SetSize(1320, 900);
- break;
- case 9:
- size.SetSize(1280, 720);
- break;
- }
-
- if (m_pAllocator) {
- m_pAllocator->ChangeDevice(m_pD3DDev);
- } else {
- m_pAllocator = DNew CDX9SubPicAllocator(m_pD3DDev, size, GetRenderersSettings().fSPCPow2Tex, false);
- if (!m_pAllocator) {
- _Error += L"CDX9SubPicAllocator failed\n";
-
- return E_FAIL;
- }
- }
-
- hr = S_OK;
- m_pSubPicQueue = GetRenderersSettings().nSPCSize > 0
- ? (ISubPicQueue*)DNew CSubPicQueue(GetRenderersSettings().nSPCSize, !GetRenderersSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
- : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
- if (!m_pSubPicQueue || FAILED(hr)) {
- _Error += L"m_pSubPicQueue failed\n";
-
- return E_FAIL;
- }
-
- if (pSubPicProvider) {
- m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
- }
-
- m_pFont = NULL;
- if (m_pD3DXCreateFont) {
- int MinSize = 1600;
- int CurrentSize = min(m_ScreenSize.cx, MinSize);
- double Scale = double(CurrentSize) / double(MinSize);
- m_TextScale = Scale;
- m_pD3DXCreateFont(m_pD3DDev, (int)(-24.0*Scale), (UINT)(-11.0*Scale), CurrentSize < 800 ? FW_NORMAL : FW_BOLD, 0, FALSE,
- DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FIXED_PITCH | FF_DONTCARE, L"Lucida Console", &m_pFont);
- }
- m_pSprite = NULL;
- if (m_pD3DXCreateSprite) {
- m_pD3DXCreateSprite(m_pD3DDev, &m_pSprite);
- }
- m_pLine = NULL;
- if (m_pD3DXCreateLine) {
- m_pD3DXCreateLine (m_pD3DDev, &m_pLine);
- }
- return S_OK;
+ CRenderersSettings& s = GetRenderersSettings();
+ CRenderersSettings::CRendererSettingsEVR& New = s.m_RenderSettings;
+ CRenderersSettings::CRendererSettingsEVR& Current = m_LastRendererSettings;
+
+ bool bRet = false;
+ if (!m_bIsFullscreen) {
+ if (Current.iVMRDisableDesktopComposition) {
+ if (!m_bDesktopCompositionDisabled) {
+ m_bDesktopCompositionDisabled = true;
+ if (m_pDwmEnableComposition) {
+ m_pDwmEnableComposition(0);
+ }
+ }
+ } else {
+ if (m_bDesktopCompositionDisabled) {
+ m_bDesktopCompositionDisabled = false;
+ if (m_pDwmEnableComposition) {
+ m_pDwmEnableComposition(1);
+ }
+ }
+ }
+ }
+ bRet = bRet || New.iEVRHighColorResolution != Current.iEVRHighColorResolution;
+ m_LastRendererSettings = s.m_RenderSettings;
+ return bRet;
+}
+
+HRESULT CBaseAP::CreateDXDevice(CString& _Error)
+{
+ TRACE("--> CBaseAP::CreateDXDevice on thread: %d\n", GetCurrentThreadId());
+ CRenderersSettings& s = GetRenderersSettings();
+ m_LastRendererSettings = s.m_RenderSettings;
+ HRESULT hr = E_FAIL;
+
+ m_pFont = NULL;
+ m_pSprite = NULL;
+ m_pLine = NULL;
+
+ m_pPSC.Free();
+ m_pD3DDev = NULL;
+ m_pD3DDevEx = NULL;
+
+ m_pResizerPixelShader[0] = 0;
+ m_pResizerPixelShader[1] = 0;
+ m_pResizerPixelShader[2] = 0;
+ m_pResizerPixelShader[3] = 0;
+
+ POSITION pos = m_pPixelShadersScreenSpace.GetHeadPosition();
+ while (pos) {
+ CExternalPixelShader& Shader = m_pPixelShadersScreenSpace.GetNext(pos);
+ Shader.m_pPixelShader = NULL;
+ }
+ pos = m_pPixelShaders.GetHeadPosition();
+ while (pos) {
+ CExternalPixelShader& Shader = m_pPixelShaders.GetNext(pos);
+ Shader.m_pPixelShader = NULL;
+ }
+
+ if (!m_pD3D) {
+ _Error += L"Failed to create Direct3D device\n";
+ return E_UNEXPECTED;
+ }
+
+ D3DDISPLAYMODE d3ddm;
+ ZeroMemory(&d3ddm, sizeof(d3ddm));
+ m_CurrentAdapter = GetAdapter(m_pD3D);
+ if (FAILED(m_pD3D->GetAdapterDisplayMode(m_CurrentAdapter, &d3ddm))) {
+ _Error += L"Can not retrieve display mode data\n";
+ return E_UNEXPECTED;
+ }
+
+ if (FAILED(m_pD3D->GetDeviceCaps(m_CurrentAdapter, D3DDEVTYPE_HAL, &m_caps)))
+ if ((m_caps.Caps & D3DCAPS_READ_SCANLINE) == 0) {
+ _Error += L"Video card does not have scanline access. Display synchronization is not possible.\n";
+ return E_UNEXPECTED;
+ }
+
+ m_uD3DRefreshRate = d3ddm.RefreshRate;
+ m_dD3DRefreshCycle = 1000.0 / (double)m_uD3DRefreshRate; // In ms
+ m_ScreenSize.SetSize(d3ddm.Width, d3ddm.Height);
+ m_pGenlock->SetDisplayResolution(d3ddm.Width, d3ddm.Height);
+
+ BOOL bCompositionEnabled = false;
+ if (m_pDwmIsCompositionEnabled) {
+ m_pDwmIsCompositionEnabled(&bCompositionEnabled);
+ }
+ m_bCompositionEnabled = bCompositionEnabled != 0;
+
+ ZeroMemory(&pp, sizeof(pp));
+ if (m_bIsFullscreen) { // Exclusive mode fullscreen
+ pp.Windowed = FALSE;
+ pp.BackBufferWidth = d3ddm.Width;
+ pp.BackBufferHeight = d3ddm.Height;
+ pp.hDeviceWindow = m_hWnd;
+ DEBUG_ONLY(_tprintf_s(_T("Wnd in CreateDXDevice: %p\n"), m_hWnd));
+ pp.BackBufferCount = 3;
+ pp.SwapEffect = D3DSWAPEFFECT_DISCARD;
+ pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
+ pp.Flags = D3DPRESENTFLAG_VIDEO;
+ m_bHighColorResolution = s.m_RenderSettings.iEVRHighColorResolution;
+ if (m_bHighColorResolution) {
+ if (FAILED(m_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format, D3DFMT_A2R10G10B10, false))) {
+ m_strStatsMsg[MSG_ERROR] = L"10 bit RGB is not supported by this graphics device in this resolution.";
+ m_bHighColorResolution = false;
+ }
+ }
+
+ if (m_bHighColorResolution) {
+ pp.BackBufferFormat = D3DFMT_A2R10G10B10;
+ } else {
+ pp.BackBufferFormat = d3ddm.Format;
+ }
+
+ if (m_pD3DEx) {
+ D3DDISPLAYMODEEX DisplayMode;
+ ZeroMemory(&DisplayMode, sizeof(DisplayMode));
+ DisplayMode.Size = sizeof(DisplayMode);
+ m_pD3DEx->GetAdapterDisplayModeEx(m_CurrentAdapter, &DisplayMode, NULL);
+
+ DisplayMode.Format = pp.BackBufferFormat;
+ pp.FullScreen_RefreshRateInHz = DisplayMode.RefreshRate;
+
+ if FAILED(hr = m_pD3DEx->CreateDeviceEx(m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd,
+ D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_FPU_PRESERVE | D3DCREATE_MULTITHREADED | D3DCREATE_ENABLE_PRESENTSTATS,
+ &pp, &DisplayMode, &m_pD3DDevEx)) {
+ _Error += GetWindowsErrorMessage(hr, m_hD3D9);
+ return hr;
+ }
+ if (m_pD3DDevEx) {
+ m_pD3DDev = m_pD3DDevEx;
+ m_BackbufferType = pp.BackBufferFormat;
+ m_DisplayType = DisplayMode.Format;
+ }
+ } else {
+ if FAILED(hr = m_pD3D->CreateDevice(m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_FPU_PRESERVE | D3DCREATE_MULTITHREADED, &pp, &m_pD3DDev)) {
+ _Error += GetWindowsErrorMessage(hr, m_hD3D9);
+ return hr;
+ }
+ DEBUG_ONLY(_tprintf_s(_T("Created full-screen device\n")));
+ if (m_pD3DDev) {
+ m_BackbufferType = pp.BackBufferFormat;
+ m_DisplayType = d3ddm.Format;
+ }
+ }
+ } else { // Windowed
+ pp.Windowed = TRUE;
+ pp.hDeviceWindow = m_hWnd;
+ pp.SwapEffect = D3DSWAPEFFECT_COPY;
+ pp.Flags = D3DPRESENTFLAG_VIDEO;
+ pp.BackBufferCount = 1;
+ pp.BackBufferWidth = d3ddm.Width;
+ pp.BackBufferHeight = d3ddm.Height;
+ m_BackbufferType = d3ddm.Format;
+ m_DisplayType = d3ddm.Format;
+ m_bHighColorResolution = s.m_RenderSettings.iEVRHighColorResolution;
+ if (m_bHighColorResolution) {
+ if (FAILED(m_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format, D3DFMT_A2R10G10B10, false))) {
+ m_strStatsMsg[MSG_ERROR] = L"10 bit RGB is not supported by this graphics device in this resolution.";
+ m_bHighColorResolution = false;
+ }
+ }
+
+ if (m_bHighColorResolution) {
+ m_BackbufferType = D3DFMT_A2R10G10B10;
+ pp.BackBufferFormat = D3DFMT_A2R10G10B10;
+ }
+ if (bCompositionEnabled) {
+ // Desktop composition presents the whole desktop
+ pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
+ } else {
+ pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
+ }
+ if (m_pD3DEx) {
+ if FAILED(hr = m_pD3DEx->CreateDeviceEx(m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd,
+ D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_FPU_PRESERVE | D3DCREATE_MULTITHREADED | D3DCREATE_ENABLE_PRESENTSTATS,
+ &pp, NULL, &m_pD3DDevEx)) {
+ _Error += GetWindowsErrorMessage(hr, m_hD3D9);
+ return hr;
+ }
+ if (m_pD3DDevEx) {
+ m_pD3DDev = m_pD3DDevEx;
+ }
+ } else {
+ if FAILED(hr = m_pD3D->CreateDevice(m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd,
+ D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_FPU_PRESERVE | D3DCREATE_MULTITHREADED,
+ &pp, &m_pD3DDev)) {
+ _Error += GetWindowsErrorMessage(hr, m_hD3D9);
+ return hr;
+ }
+ DEBUG_ONLY(_tprintf_s(_T("Created windowed device\n")));
+ }
+ }
+
+ while (hr == D3DERR_DEVICELOST) {
+ TRACE("D3DERR_DEVICELOST. Trying to Reset.\n");
+ hr = m_pD3DDev->TestCooperativeLevel();
+ }
+ if (hr == D3DERR_DEVICENOTRESET) {
+ TRACE("D3DERR_DEVICENOTRESET\n");
+ hr = m_pD3DDev->Reset(&pp);
+ }
+
+ TRACE("CreateDevice: %d\n", (LONG)hr);
+ ASSERT(SUCCEEDED(hr));
+
+ if (m_pD3DDevEx) {
+ m_pD3DDevEx->SetGPUThreadPriority(7);
+ }
+
+ m_pPSC.Attach(DNew CPixelShaderCompiler(m_pD3DDev, true));
+ m_filter = D3DTEXF_NONE;
+
+ if (m_caps.StretchRectFilterCaps & D3DPTFILTERCAPS_MINFLINEAR && m_caps.StretchRectFilterCaps & D3DPTFILTERCAPS_MAGFLINEAR) {
+ m_filter = D3DTEXF_LINEAR;
+ }
+
+ m_bicubicA = 0;
+
+ CSize size;
+ switch (GetRenderersSettings().nSPCMaxRes) {
+ case 0:
+ default:
+ size = m_ScreenSize;
+ break;
+ case 1:
+ size.SetSize(1024, 768);
+ break;
+ case 2:
+ size.SetSize(800, 600);
+ break;
+ case 3:
+ size.SetSize(640, 480);
+ break;
+ case 4:
+ size.SetSize(512, 384);
+ break;
+ case 5:
+ size.SetSize(384, 288);
+ break;
+ case 6:
+ size.SetSize(2560, 1600);
+ break;
+ case 7:
+ size.SetSize(1920, 1080);
+ break;
+ case 8:
+ size.SetSize(1320, 900);
+ break;
+ case 9:
+ size.SetSize(1280, 720);
+ break;
+ }
+
+ if (m_pAllocator) {
+ m_pAllocator->ChangeDevice(m_pD3DDev);
+ } else {
+ m_pAllocator = DNew CDX9SubPicAllocator(m_pD3DDev, size, GetRenderersSettings().fSPCPow2Tex, false);
+ if (!m_pAllocator) {
+ _Error += L"CDX9SubPicAllocator failed\n";
+ return E_FAIL;
+ }
+ }
+
+ hr = S_OK;
+
+ CComPtr<ISubPicProvider> pSubPicProvider;
+ if (m_pSubPicQueue) {
+ DEBUG_ONLY(_tprintf_s(_T("m_pSubPicQueue != NULL\n")));
+ m_pSubPicQueue->GetSubPicProvider(&pSubPicProvider);
+ }
+
+ m_pSubPicQueue = NULL;
+ m_pSubPicQueue = GetRenderersSettings().nSPCSize > 0
+ ? (ISubPicQueue*)DNew CSubPicQueue(GetRenderersSettings().nSPCSize, !GetRenderersSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
+ : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
+ if (!m_pSubPicQueue || FAILED(hr)) {
+ _Error += L"m_pSubPicQueue failed\n";
+ return E_FAIL;
+ }
+
+ if (pSubPicProvider) {
+ m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
+ }
+
+ if (m_pD3DXCreateFont) {
+ int MinSize = 1600;
+ int CurrentSize = min(m_ScreenSize.cx, MinSize);
+ double Scale = double(CurrentSize) / double(MinSize);
+ m_TextScale = Scale;
+ m_pD3DXCreateFont(m_pD3DDev, (int)(-24.0 * Scale), (UINT)(-11.0 * Scale), CurrentSize < 800 ? FW_NORMAL : FW_BOLD, 0, FALSE,
+ DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FIXED_PITCH | FF_DONTCARE, L"Lucida Console", &m_pFont);
+ }
+ if (m_pD3DXCreateSprite) {
+ m_pD3DXCreateSprite(m_pD3DDev, &m_pSprite);
+ }
+ if (m_pD3DXCreateLine) {
+ m_pD3DXCreateLine(m_pD3DDev, &m_pLine);
+ }
+ m_LastAdapterCheck = GetRenderersData()->GetPerfCounter();
+ return S_OK;
+}
+
+HRESULT CBaseAP::ResetDXDevice(CString& _Error)
+{
+ CRenderersSettings& s = GetRenderersSettings();
+ m_LastRendererSettings = s.m_RenderSettings;
+ HRESULT hr = E_FAIL;
+
+ hr = m_pD3DDev->TestCooperativeLevel();
+ if ((hr != D3DERR_DEVICENOTRESET) && (hr != D3D_OK)) {
+ return hr;
+ }
+
+ CComPtr<IEnumPins> rendererInputEnum;
+ std::vector<CComPtr<IPin>> decoderOutput;
+ std::vector<CComPtr<IPin>> rendererInput;
+ FILTER_INFO filterInfo;
+
+ bool disconnected = FALSE;
+
+ // Disconnect all pins to release video memory resources
+ if (m_pD3DDev) {
+ ZeroMemory(&filterInfo, sizeof(filterInfo));
+ m_pOuterEVR->QueryFilterInfo(&filterInfo); // This addref's the pGraph member
+ if (SUCCEEDED(m_pOuterEVR->EnumPins(&rendererInputEnum))) {
+ CComPtr<IPin> input;
+ CComPtr<IPin> output;
+ while (hr = rendererInputEnum->Next(1, &input.p, 0), hr == S_OK) { // Must have .p here
+ DEBUG_ONLY(_tprintf_s(_T("Pin found\n")));
+ input->ConnectedTo(&output.p);
+ if (output != NULL) {
+ rendererInput.push_back(input);
+ decoderOutput.push_back(output);
+ }
+ input.Release();
+ output.Release();
+ }
+ } else {
+ return hr;
+ }
+ for (DWORD i = 0; i < decoderOutput.size(); i++) {
+ DEBUG_ONLY(_tprintf_s(_T("Disconnecting pin\n")));
+ filterInfo.pGraph->Disconnect(decoderOutput.at(i).p);
+ filterInfo.pGraph->Disconnect(rendererInput.at(i).p);
+ DEBUG_ONLY(_tprintf_s(_T("Pin disconnected\n")));
+ }
+ disconnected = true;
+ }
+
+ // Release more resources
+ m_pSubPicQueue = NULL;
+ m_pFont = NULL;
+ m_pSprite = NULL;
+ m_pLine = NULL;
+ m_pPSC.Free();
+
+ m_pResizerPixelShader[0] = 0;
+ m_pResizerPixelShader[1] = 0;
+ m_pResizerPixelShader[2] = 0;
+ m_pResizerPixelShader[3] = 0;
+
+ POSITION pos = m_pPixelShadersScreenSpace.GetHeadPosition();
+ while (pos) {
+ CExternalPixelShader& Shader = m_pPixelShadersScreenSpace.GetNext(pos);
+ Shader.m_pPixelShader = NULL;
+ }
+ pos = m_pPixelShaders.GetHeadPosition();
+ while (pos) {
+ CExternalPixelShader& Shader = m_pPixelShaders.GetNext(pos);
+ Shader.m_pPixelShader = NULL;
+ }
+
+ D3DDISPLAYMODE d3ddm;
+ ZeroMemory(&d3ddm, sizeof(d3ddm));
+ if (FAILED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm))) {
+ _Error += L"Can not retrieve display mode data\n";
+ return E_UNEXPECTED;
+ }
+
+ m_uD3DRefreshRate = d3ddm.RefreshRate;
+ m_dD3DRefreshCycle = 1000.0 / (double)m_uD3DRefreshRate; // In ms
+ m_ScreenSize.SetSize(d3ddm.Width, d3ddm.Height);
+ m_pGenlock->SetDisplayResolution(d3ddm.Width, d3ddm.Height);
+
+ D3DPRESENT_PARAMETERS pp;
+ ZeroMemory(&pp, sizeof(pp));
+
+ BOOL bCompositionEnabled = false;
+ if (m_pDwmIsCompositionEnabled) {
+ m_pDwmIsCompositionEnabled(&bCompositionEnabled);
+ }
+ m_bCompositionEnabled = bCompositionEnabled != 0;
+ m_bHighColorResolution = s.m_RenderSettings.iEVRHighColorResolution;
+
+ if (m_bIsFullscreen) { // Exclusive mode fullscreen
+ pp.BackBufferWidth = d3ddm.Width;
+ pp.BackBufferHeight = d3ddm.Height;
+ if (m_bHighColorResolution) {
+ pp.BackBufferFormat = D3DFMT_A2R10G10B10;
+ } else {
+ pp.BackBufferFormat = d3ddm.Format;
+ }
+ if (FAILED(m_pD3DEx->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, pp.BackBufferFormat, pp.BackBufferFormat, false))) {
+ _Error += L"10 bit RGB is not supported by this graphics device in exclusive mode fullscreen.\n";
+ return hr;
+ }
+
+ D3DDISPLAYMODEEX DisplayMode;
+ ZeroMemory(&DisplayMode, sizeof(DisplayMode));
+ DisplayMode.Size = sizeof(DisplayMode);
+ if (m_pD3DDevEx) {
+ m_pD3DEx->GetAdapterDisplayModeEx(GetAdapter(m_pD3DEx), &DisplayMode, NULL);
+ DisplayMode.Format = pp.BackBufferFormat;
+ pp.FullScreen_RefreshRateInHz = DisplayMode.RefreshRate;
+ if FAILED(m_pD3DDevEx->Reset(&pp)) {
+ _Error += GetWindowsErrorMessage(hr, m_hD3D9);
+ return hr;
+ }
+ } else if (m_pD3DDev) {
+ if FAILED(m_pD3DDev->Reset(&pp)) {
+ _Error += GetWindowsErrorMessage(hr, m_hD3D9);
+ return hr;
+ }
+ } else {
+ _Error += L"No device.\n";
+ return hr;
+ }
+ m_BackbufferType = pp.BackBufferFormat;
+ m_DisplayType = d3ddm.Format;
+ } else { // Windowed
+ pp.BackBufferWidth = d3ddm.Width;
+ pp.BackBufferHeight = d3ddm.Height;
+ m_BackbufferType = d3ddm.Format;
+ m_DisplayType = d3ddm.Format;
+ if (m_bHighColorResolution) {
+ m_BackbufferType = D3DFMT_A2R10G10B10;
+ pp.BackBufferFormat = D3DFMT_A2R10G10B10;
+ }
+ if (FAILED(m_pD3DEx->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, pp.BackBufferFormat, pp.BackBufferFormat, false))) {
+ _Error += L"10 bit RGB is not supported by this graphics device in windowed mode.\n";
+ return hr;
+ }
+ if (bCompositionEnabled) {
+ // Desktop composition presents the whole desktop
+ pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
+ } else {
+ pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
+ }
+ if (m_pD3DDevEx)
+ if FAILED(m_pD3DDevEx->Reset(&pp)) {
+ _Error += GetWindowsErrorMessage(hr, m_hD3D9);
+ return hr;
+ } else if (m_pD3DDev)
+ if FAILED(m_pD3DDevEx->Reset(&pp)) {
+ _Error += GetWindowsErrorMessage(hr, m_hD3D9);
+ return hr;
+ } else {
+ _Error += L"No device.\n";
+ return hr;
+ }
+ }
+
+ if (disconnected) {
+ for (DWORD i = 0; i < decoderOutput.size(); i++) {
+ if (FAILED(filterInfo.pGraph->ConnectDirect(decoderOutput.at(i).p, rendererInput.at(i).p, NULL))) {
+ return hr;
+ }
+ }
+
+ if (filterInfo.pGraph != NULL) {
+ filterInfo.pGraph->Release();
+ }
+ }
+
+ m_pPSC.Attach(DNew CPixelShaderCompiler(m_pD3DDev, true));
+ m_filter = D3DTEXF_NONE;
+
+ if ((m_caps.StretchRectFilterCaps & D3DPTFILTERCAPS_MINFLINEAR)
+ && (m_caps.StretchRectFilterCaps & D3DPTFILTERCAPS_MAGFLINEAR)) {
+ m_filter = D3DTEXF_LINEAR;
+ }
+
+ m_bicubicA = 0;
+
+ CComPtr<ISubPicProvider> pSubPicProvider;
+ if (m_pSubPicQueue) {
+ m_pSubPicQueue->GetSubPicProvider(&pSubPicProvider);
+ }
+ CSize size;
+ switch (GetRenderersSettings().nSPCMaxRes) {
+ case 0:
+ default:
+ size = m_ScreenSize;
+ break;
+ case 1:
+ size.SetSize(1024, 768);
+ break;
+ case 2:
+ size.SetSize(800, 600);
+ break;
+ case 3:
+ size.SetSize(640, 480);
+ break;
+ case 4:
+ size.SetSize(512, 384);
+ break;
+ case 5:
+ size.SetSize(384, 288);
+ break;
+ case 6:
+ size.SetSize(2560, 1600);
+ break;
+ case 7:
+ size.SetSize(1920, 1080);
+ break;
+ case 8:
+ size.SetSize(1320, 900);
+ break;
+ case 9:
+ size.SetSize(1280, 720);
+ break;
+ }
+
+ if (m_pAllocator) {
+ m_pAllocator->ChangeDevice(m_pD3DDev);
+ } else {
+ m_pAllocator = DNew CDX9SubPicAllocator(m_pD3DDev, size, GetRenderersSettings().fSPCPow2Tex, false);
+ if (!m_pAllocator) {
+ _Error += L"CDX9SubPicAllocator failed\n";
+
+ return E_FAIL;
+ }
+ }
+
+ hr = S_OK;
+ m_pSubPicQueue = GetRenderersSettings().nSPCSize > 0
+ ? (ISubPicQueue*)DNew CSubPicQueue(GetRenderersSettings().nSPCSize, !GetRenderersSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
+ : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
+ if (!m_pSubPicQueue || FAILED(hr)) {
+ _Error += L"m_pSubPicQueue failed\n";
+
+ return E_FAIL;
+ }
+
+ if (pSubPicProvider) {
+ m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
+ }
+
+ m_pFont = NULL;
+ if (m_pD3DXCreateFont) {
+ int MinSize = 1600;
+ int CurrentSize = min(m_ScreenSize.cx, MinSize);
+ double Scale = double(CurrentSize) / double(MinSize);
+ m_TextScale = Scale;
+ m_pD3DXCreateFont(m_pD3DDev, (int)(-24.0 * Scale), (UINT)(-11.0 * Scale), CurrentSize < 800 ? FW_NORMAL : FW_BOLD, 0, FALSE,
+ DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FIXED_PITCH | FF_DONTCARE, L"Lucida Console", &m_pFont);
+ }
+ m_pSprite = NULL;
+ if (m_pD3DXCreateSprite) {
+ m_pD3DXCreateSprite(m_pD3DDev, &m_pSprite);
+ }
+ m_pLine = NULL;
+ if (m_pD3DXCreateLine) {
+ m_pD3DXCreateLine(m_pD3DDev, &m_pLine);
+ }
+ return S_OK;
}
HRESULT CBaseAP::AllocSurfaces(D3DFORMAT Format)
{
- CAutoLock cAutoLock(this);
- CAutoLock cRenderLock(&m_allocatorLock);
-
- CRenderersSettings& s = GetRenderersSettings();
-
- for (int i = 0; i < m_nDXSurface+2; i++) {
- m_pVideoTexture[i] = NULL;
- m_pVideoSurface[i] = NULL;
- }
-
- m_pScreenSizeTemporaryTexture[0] = NULL;
- m_pScreenSizeTemporaryTexture[1] = NULL;
- m_SurfaceType = Format;
-
- HRESULT hr;
- if (s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D || s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) {
- int nTexturesNeeded = s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D ? m_nDXSurface+2 : 1;
-
- for (int i = 0; i < nTexturesNeeded; i++) {
- if (FAILED(hr = m_pD3DDev->CreateTexture(
- m_NativeVideoSize.cx, m_NativeVideoSize.cy, 1, D3DUSAGE_RENDERTARGET, Format, D3DPOOL_DEFAULT, &m_pVideoTexture[i], NULL))) {
- return hr;
- }
-
- if (FAILED(hr = m_pVideoTexture[i]->GetSurfaceLevel(0, &m_pVideoSurface[i]))) {
- return hr;
- }
- }
- if (s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D) {
- for (int i = 0; i < m_nDXSurface+2; i++) {
- m_pVideoTexture[i] = NULL;
- }
- }
- } else {
- if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(m_NativeVideoSize.cx, m_NativeVideoSize.cy, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &m_pVideoSurface[m_nCurSurface], NULL))) {
- return hr;
- }
- }
-
- hr = m_pD3DDev->ColorFill(m_pVideoSurface[m_nCurSurface], NULL, 0);
- return S_OK;
+ CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_allocatorLock);
+
+ CRenderersSettings& s = GetRenderersSettings();
+
+ for (int i = 0; i < m_nDXSurface + 2; i++) {
+ m_pVideoTexture[i] = NULL;
+ m_pVideoSurface[i] = NULL;
+ }
+
+ m_pScreenSizeTemporaryTexture[0] = NULL;
+ m_pScreenSizeTemporaryTexture[1] = NULL;
+ m_SurfaceType = Format;
+
+ HRESULT hr;
+ if (s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D || s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) {
+ int nTexturesNeeded = s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D ? m_nDXSurface + 2 : 1;
+
+ for (int i = 0; i < nTexturesNeeded; i++) {
+ if (FAILED(hr = m_pD3DDev->CreateTexture(
+ m_NativeVideoSize.cx, m_NativeVideoSize.cy, 1, D3DUSAGE_RENDERTARGET, Format, D3DPOOL_DEFAULT, &m_pVideoTexture[i], NULL))) {
+ return hr;
+ }
+
+ if (FAILED(hr = m_pVideoTexture[i]->GetSurfaceLevel(0, &m_pVideoSurface[i]))) {
+ return hr;
+ }
+ }
+ if (s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D) {
+ for (int i = 0; i < m_nDXSurface + 2; i++) {
+ m_pVideoTexture[i] = NULL;
+ }
+ }
+ } else {
+ if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(m_NativeVideoSize.cx, m_NativeVideoSize.cy, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &m_pVideoSurface[m_nCurSurface], NULL))) {
+ return hr;
+ }
+ }
+
+ hr = m_pD3DDev->ColorFill(m_pVideoSurface[m_nCurSurface], NULL, 0);
+ return S_OK;
}
void CBaseAP::DeleteSurfaces()
{
- CAutoLock cAutoLock(this);
- CAutoLock cRenderLock(&m_allocatorLock);
+ CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_allocatorLock);
- for (int i = 0; i < m_nDXSurface+2; i++) {
- m_pVideoTexture[i] = NULL;
- m_pVideoSurface[i] = NULL;
- }
+ for (int i = 0; i < m_nDXSurface + 2; i++) {
+ m_pVideoTexture[i] = NULL;
+ m_pVideoSurface[i] = NULL;
+ }
}
UINT CBaseAP::GetAdapter(IDirect3D9* pD3D)
{
- if (m_hWnd == NULL || pD3D == NULL) {
- return D3DADAPTER_DEFAULT;
- }
+ if (m_hWnd == NULL || pD3D == NULL) {
+ return D3DADAPTER_DEFAULT;
+ }
- HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- if (hMonitor == NULL) {
- return D3DADAPTER_DEFAULT;
- }
+ HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+ if (hMonitor == NULL) {
+ return D3DADAPTER_DEFAULT;
+ }
- for (UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp) {
- HMONITOR hAdpMon = pD3D->GetAdapterMonitor(adp);
- if (hAdpMon == hMonitor) {
- return adp;
- }
- }
- return D3DADAPTER_DEFAULT;
+ for (UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp) {
+ HMONITOR hAdpMon = pD3D->GetAdapterMonitor(adp);
+ if (hAdpMon == hMonitor) {
+ return adp;
+ }
+ }
+ return D3DADAPTER_DEFAULT;
}
// ISubPicAllocatorPresenter
STDMETHODIMP CBaseAP::CreateRenderer(IUnknown** ppRenderer)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
bool CBaseAP::ClipToSurface(IDirect3DSurface9* pSurface, CRect& s, CRect& d)
{
- D3DSURFACE_DESC d3dsd;
- ZeroMemory(&d3dsd, sizeof(d3dsd));
- if (FAILED(pSurface->GetDesc(&d3dsd))) {
- return false;
- }
-
- int w = d3dsd.Width, h = d3dsd.Height;
- int sw = s.Width(), sh = s.Height();
- int dw = d.Width(), dh = d.Height();
-
- if (d.left >= w || d.right < 0 || d.top >= h || d.bottom < 0
- || sw <= 0 || sh <= 0 || dw <= 0 || dh <= 0) {
- s.SetRectEmpty();
- d.SetRectEmpty();
- return true;
- }
- if (d.right > w) {
- s.right -= (d.right-w)*sw/dw;
- d.right = w;
- }
- if (d.bottom > h) {
- s.bottom -= (d.bottom-h)*sh/dh;
- d.bottom = h;
- }
- if (d.left < 0) {
- s.left += (0-d.left)*sw/dw;
- d.left = 0;
- }
- if (d.top < 0) {
- s.top += (0-d.top)*sh/dh;
- d.top = 0;
- }
- return true;
+ D3DSURFACE_DESC d3dsd;
+ ZeroMemory(&d3dsd, sizeof(d3dsd));
+ if (FAILED(pSurface->GetDesc(&d3dsd))) {
+ return false;
+ }
+
+ int w = d3dsd.Width, h = d3dsd.Height;
+ int sw = s.Width(), sh = s.Height();
+ int dw = d.Width(), dh = d.Height();
+
+ if (d.left >= w || d.right < 0 || d.top >= h || d.bottom < 0
+ || sw <= 0 || sh <= 0 || dw <= 0 || dh <= 0) {
+ s.SetRectEmpty();
+ d.SetRectEmpty();
+ return true;
+ }
+ if (d.right > w) {
+ s.right -= (d.right - w) * sw / dw;
+ d.right = w;
+ }
+ if (d.bottom > h) {
+ s.bottom -= (d.bottom - h) * sh / dh;
+ d.bottom = h;
+ }
+ if (d.left < 0) {
+ s.left += (0 - d.left) * sw / dw;
+ d.left = 0;
+ }
+ if (d.top < 0) {
+ s.top += (0 - d.top) * sh / dh;
+ d.top = 0;
+ }
+ return true;
}
HRESULT CBaseAP::InitResizers(float bicubicA, bool bNeedScreenSizeTexture)
{
- HRESULT hr;
- do {
- if (bicubicA) {
- if (!m_pResizerPixelShader[0]) {
- break;
- }
- if (!m_pResizerPixelShader[1]) {
- break;
- }
- if (!m_pResizerPixelShader[2]) {
- break;
- }
- if (!m_pResizerPixelShader[3]) {
- break;
- }
- if (m_bicubicA != bicubicA) {
- break;
- }
- if (!m_pScreenSizeTemporaryTexture[0]) {
- break;
- }
- if (bNeedScreenSizeTexture) {
- if (!m_pScreenSizeTemporaryTexture[1]) {
- break;
- }
- }
- } else {
- if (!m_pResizerPixelShader[0]) {
- break;
- }
- if (bNeedScreenSizeTexture) {
- if (!m_pScreenSizeTemporaryTexture[0]) {
- break;
- }
- if (!m_pScreenSizeTemporaryTexture[1]) {
- break;
- }
- }
- }
- return S_OK;
- } while (0);
-
- m_bicubicA = bicubicA;
- m_pScreenSizeTemporaryTexture[0] = NULL;
- m_pScreenSizeTemporaryTexture[1] = NULL;
-
- for (int i = 0; i < _countof(m_pResizerPixelShader); i++) {
- m_pResizerPixelShader[i] = NULL;
- }
-
- if (m_caps.PixelShaderVersion < D3DPS_VERSION(2, 0)) {
- return E_FAIL;
- }
-
- LPCSTR pProfile = m_caps.PixelShaderVersion >= D3DPS_VERSION(3, 0) ? "ps_3_0" : "ps_2_0";
-
- CStringA str;
- if (!LoadResource(IDF_SHADER_RESIZER, str, _T("FILE"))) {
- return E_FAIL;
- }
-
- CStringA A;
- A.Format("(%f)", bicubicA);
- str.Replace("_The_Value_Of_A_Is_Set_Here_", A);
-
- LPCSTR pEntries[] = {"main_bilinear", "main_bicubic1pass", "main_bicubic2pass_pass1", "main_bicubic2pass_pass2"};
-
- ASSERT(_countof(pEntries) == _countof(m_pResizerPixelShader));
- for (int i = 0; i < _countof(pEntries); i++) {
- CString ErrorMessage;
- CString DissAssembly;
- hr = m_pPSC->CompileShader(str, pEntries[i], pProfile, 0, &m_pResizerPixelShader[i], &DissAssembly, &ErrorMessage);
- if (FAILED(hr)) {
- TRACE("%ws", ErrorMessage.GetString());
- ASSERT (0);
- return hr;
- }
- }
- if (m_bicubicA || bNeedScreenSizeTexture) {
- if (FAILED(m_pD3DDev->CreateTexture(
- min(m_ScreenSize.cx, (int)m_caps.MaxTextureWidth), min(max(m_ScreenSize.cy, m_NativeVideoSize.cy), (int)m_caps.MaxTextureHeight), 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
- D3DPOOL_DEFAULT, &m_pScreenSizeTemporaryTexture[0], NULL))) {
- ASSERT(0);
- m_pScreenSizeTemporaryTexture[0] = NULL; // will do 1 pass then
- }
- }
- if (m_bicubicA || bNeedScreenSizeTexture) {
- if (FAILED(m_pD3DDev->CreateTexture(
- min(m_ScreenSize.cx, (int)m_caps.MaxTextureWidth), min(max(m_ScreenSize.cy, m_NativeVideoSize.cy), (int)m_caps.MaxTextureHeight), 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
- D3DPOOL_DEFAULT, &m_pScreenSizeTemporaryTexture[1], NULL))) {
- ASSERT(0);
- m_pScreenSizeTemporaryTexture[1] = NULL; // will do 1 pass then
- }
- }
- return S_OK;
+ HRESULT hr;
+ do {
+ if (bicubicA) {
+ if (!m_pResizerPixelShader[0]) {
+ break;
+ }
+ if (!m_pResizerPixelShader[1]) {
+ break;
+ }
+ if (!m_pResizerPixelShader[2]) {
+ break;
+ }
+ if (!m_pResizerPixelShader[3]) {
+ break;
+ }
+ if (m_bicubicA != bicubicA) {
+ break;
+ }
+ if (!m_pScreenSizeTemporaryTexture[0]) {
+ break;
+ }
+ if (bNeedScreenSizeTexture) {
+ if (!m_pScreenSizeTemporaryTexture[1]) {
+ break;
+ }
+ }
+ } else {
+ if (!m_pResizerPixelShader[0]) {
+ break;
+ }
+ if (bNeedScreenSizeTexture) {
+ if (!m_pScreenSizeTemporaryTexture[0]) {
+ break;
+ }
+ if (!m_pScreenSizeTemporaryTexture[1]) {
+ break;
+ }
+ }
+ }
+ return S_OK;
+ } while (0);
+
+ m_bicubicA = bicubicA;
+ m_pScreenSizeTemporaryTexture[0] = NULL;
+ m_pScreenSizeTemporaryTexture[1] = NULL;
+
+ for (int i = 0; i < _countof(m_pResizerPixelShader); i++) {
+ m_pResizerPixelShader[i] = NULL;
+ }
+
+ if (m_caps.PixelShaderVersion < D3DPS_VERSION(2, 0)) {
+ return E_FAIL;
+ }
+
+ LPCSTR pProfile = m_caps.PixelShaderVersion >= D3DPS_VERSION(3, 0) ? "ps_3_0" : "ps_2_0";
+
+ CStringA str;
+ if (!LoadResource(IDF_SHADER_RESIZER, str, _T("FILE"))) {
+ return E_FAIL;
+ }
+
+ CStringA A;
+ A.Format("(%f)", bicubicA);
+ str.Replace("_The_Value_Of_A_Is_Set_Here_", A);
+
+ LPCSTR pEntries[] = {"main_bilinear", "main_bicubic1pass", "main_bicubic2pass_pass1", "main_bicubic2pass_pass2"};
+
+ ASSERT(_countof(pEntries) == _countof(m_pResizerPixelShader));
+ for (int i = 0; i < _countof(pEntries); i++) {
+ CString ErrorMessage;
+ CString DissAssembly;
+ hr = m_pPSC->CompileShader(str, pEntries[i], pProfile, 0, &m_pResizerPixelShader[i], &DissAssembly, &ErrorMessage);
+ if (FAILED(hr)) {
+ TRACE("%ws", ErrorMessage.GetString());
+ ASSERT(0);
+ return hr;
+ }
+ }
+ if (m_bicubicA || bNeedScreenSizeTexture) {
+ if (FAILED(m_pD3DDev->CreateTexture(
+ min(m_ScreenSize.cx, (int)m_caps.MaxTextureWidth), min(max(m_ScreenSize.cy, m_NativeVideoSize.cy), (int)m_caps.MaxTextureHeight), 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
+ D3DPOOL_DEFAULT, &m_pScreenSizeTemporaryTexture[0], NULL))) {
+ ASSERT(0);
+ m_pScreenSizeTemporaryTexture[0] = NULL; // will do 1 pass then
+ }
+ }
+ if (m_bicubicA || bNeedScreenSizeTexture) {
+ if (FAILED(m_pD3DDev->CreateTexture(
+ min(m_ScreenSize.cx, (int)m_caps.MaxTextureWidth), min(max(m_ScreenSize.cy, m_NativeVideoSize.cy), (int)m_caps.MaxTextureHeight), 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
+ D3DPOOL_DEFAULT, &m_pScreenSizeTemporaryTexture[1], NULL))) {
+ ASSERT(0);
+ m_pScreenSizeTemporaryTexture[1] = NULL; // will do 1 pass then
+ }
+ }
+ return S_OK;
}
HRESULT CBaseAP::TextureCopy(IDirect3DTexture9* pTexture)
{
- HRESULT hr;
-
- D3DSURFACE_DESC desc;
- if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
- return E_FAIL;
- }
-
- float w = (float)desc.Width;
- float h = (float)desc.Height;
- MYD3DVERTEX<1> v[] = {
- {0, 0, 0.5f, 2.0f, 0, 0},
- {w, 0, 0.5f, 2.0f, 1, 0},
- {0, h, 0.5f, 2.0f, 0, 1},
- {w, h, 0.5f, 2.0f, 1, 1},
- };
- for (int i = 0; i < _countof(v); i++) {
- v[i].x -= 0.5;
- v[i].y -= 0.5;
- }
- hr = m_pD3DDev->SetTexture(0, pTexture);
- return TextureBlt(m_pD3DDev, v, D3DTEXF_POINT);
-}
-
-HRESULT CBaseAP::DrawRect(DWORD _Color, DWORD _Alpha, const CRect &_Rect)
-{
- DWORD Color = D3DCOLOR_ARGB(_Alpha, GetRValue(_Color), GetGValue(_Color), GetBValue(_Color));
- MYD3DVERTEX<0> v[] = {
- {float(_Rect.left), float(_Rect.top), 0.5f, 2.0f, Color},
- {float(_Rect.right), float(_Rect.top), 0.5f, 2.0f, Color},
- {float(_Rect.left), float(_Rect.bottom), 0.5f, 2.0f, Color},
- {float(_Rect.right), float(_Rect.bottom), 0.5f, 2.0f, Color},
- };
- for (int i = 0; i < _countof(v); i++) {
- v[i].x -= 0.5;
- v[i].y -= 0.5;
- }
- return DrawRectBase(m_pD3DDev, v);
-}
-
-HRESULT CBaseAP::TextureResize(IDirect3DTexture9* pTexture, Vector dst[4], D3DTEXTUREFILTERTYPE filter, const CRect &SrcRect)
-{
- HRESULT hr;
-
- D3DSURFACE_DESC desc;
- if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
- return E_FAIL;
- }
-
- float w = (float)desc.Width;
- float h = (float)desc.Height;
-
- float dx2 = 1.0f/w;
- float dy2 = 1.0f/h;
-
- MYD3DVERTEX<1> v[] = {
- {dst[0].x, dst[0].y, dst[0].z, 1.0f/dst[0].z, SrcRect.left * dx2, SrcRect.top * dy2},
- {dst[1].x, dst[1].y, dst[1].z, 1.0f/dst[1].z, SrcRect.right * dx2, SrcRect.top * dy2},
- {dst[2].x, dst[2].y, dst[2].z, 1.0f/dst[2].z, SrcRect.left * dx2, SrcRect.bottom * dy2},
- {dst[3].x, dst[3].y, dst[3].z, 1.0f/dst[3].z, SrcRect.right * dx2, SrcRect.bottom * dy2},
- };
- AdjustQuad(v, 0, 0);
- hr = m_pD3DDev->SetTexture(0, pTexture);
- hr = m_pD3DDev->SetPixelShader(NULL);
- hr = TextureBlt(m_pD3DDev, v, filter);
- return hr;
-}
-
-HRESULT CBaseAP::TextureResizeBilinear(IDirect3DTexture9* pTexture, Vector dst[4], const CRect &SrcRect)
-{
- HRESULT hr;
-
- D3DSURFACE_DESC desc;
- if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
- return E_FAIL;
- }
-
- float w = (float)desc.Width;
- float h = (float)desc.Height;
-
- float tx0 = (float)SrcRect.left;
- float tx1 = (float)SrcRect.right;
- float ty0 = (float)SrcRect.top;
- float ty1 = (float)SrcRect.bottom;
-
- MYD3DVERTEX<1> v[] = {
- {dst[0].x, dst[0].y, dst[0].z, 1.0f/dst[0].z, tx0, ty0},
- {dst[1].x, dst[1].y, dst[1].z, 1.0f/dst[1].z, tx1, ty0},
- {dst[2].x, dst[2].y, dst[2].z, 1.0f/dst[2].z, tx0, ty1},
- {dst[3].x, dst[3].y, dst[3].z, 1.0f/dst[3].z, tx1, ty1},
- };
- AdjustQuad(v, 1.0, 1.0);
- float fConstData[][4] = {{0.5f / w, 0.5f / h, 0, 0}, {1.0f / w, 1.0f / h, 0, 0}, {1.0f / w, 0, 0, 0}, {0, 1.0f / h, 0, 0}, {w, h, 0, 0}};
- hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, _countof(fConstData));
- hr = m_pD3DDev->SetTexture(0, pTexture);
- hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShader[0]);
- hr = TextureBlt(m_pD3DDev, v, D3DTEXF_POINT);
- m_pD3DDev->SetPixelShader(NULL);
- return hr;
-}
-
-HRESULT CBaseAP::TextureResizeBicubic1pass(IDirect3DTexture9* pTexture, Vector dst[4], const CRect &SrcRect)
-{
- HRESULT hr;
-
- D3DSURFACE_DESC desc;
- if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
- return E_FAIL;
- }
-
- float w = (float)desc.Width;
- float h = (float)desc.Height;
-
- float tx0 = (float)SrcRect.left;
- float tx1 = (float)SrcRect.right;
- float ty0 = (float)SrcRect.top;
- float ty1 = (float)SrcRect.bottom;
-
- MYD3DVERTEX<1> v[] = {
- {dst[0].x, dst[0].y, dst[0].z, 1.0f/dst[0].z, tx0, ty0},
- {dst[1].x, dst[1].y, dst[1].z, 1.0f/dst[1].z, tx1, ty0},
- {dst[2].x, dst[2].y, dst[2].z, 1.0f/dst[2].z, tx0, ty1},
- {dst[3].x, dst[3].y, dst[3].z, 1.0f/dst[3].z, tx1, ty1},
- };
- AdjustQuad(v, 1.0, 1.0);
- hr = m_pD3DDev->SetTexture(0, pTexture);
- float fConstData[][4] = {{0.5f / w, 0.5f / h, 0, 0}, {1.0f / w, 1.0f / h, 0, 0}, {1.0f / w, 0, 0, 0}, {0, 1.0f / h, 0, 0}, {w, h, 0, 0}};
- hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, _countof(fConstData));
- hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShader[1]);
- hr = TextureBlt(m_pD3DDev, v, D3DTEXF_POINT);
- m_pD3DDev->SetPixelShader(NULL);
- return hr;
-}
-
-HRESULT CBaseAP::TextureResizeBicubic2pass(IDirect3DTexture9* pTexture, Vector dst[4], const CRect &SrcRect)
-{
- // The 2 pass sampler is incorrect in that it only does bilinear resampling in the y direction.
- return TextureResizeBicubic1pass(pTexture, dst, SrcRect);
-
- /*HRESULT hr;
-
- // rotated?
- if (dst[0].z != dst[1].z || dst[2].z != dst[3].z || dst[0].z != dst[3].z
- || dst[0].y != dst[1].y || dst[0].x != dst[2].x || dst[2].y != dst[3].y || dst[1].x != dst[3].x)
- return TextureResizeBicubic1pass(pTexture, dst, SrcRect);
-
- D3DSURFACE_DESC desc;
- if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
- return E_FAIL;
-
- float Tex0_Width = desc.Width;
- float Tex0_Height = desc.Height;
-
- CSize SrcTextSize = CSize(desc.Width, desc.Height);
- double w = (double)SrcRect.Width();
- double h = (double)SrcRect.Height();
- UNREFERENCED_PARAMETER(w);
-
- CRect dst1(0, 0, (int)(dst[3].x - dst[0].x), (int)h);
-
- if (!m_pScreenSizeTemporaryTexture[0] || FAILED(m_pScreenSizeTemporaryTexture[0]->GetLevelDesc(0, &desc)))
- return TextureResizeBicubic1pass(pTexture, dst, SrcRect);
-
- float Tex1_Width = desc.Width;
- float Tex1_Height = desc.Height;
-
- float tx0 = SrcRect.left;
- float tx1 = SrcRect.right;
- float ty0 = SrcRect.top;
- float ty1 = SrcRect.bottom;
-
- float tx0_2 = 0;
- float tx1_2 = dst1.Width();
- float ty0_2 = 0;
- float ty1_2 = h;
-
- if (dst1.Width() > (int)desc.Width || dst1.Height() > (int)desc.Height)
- return TextureResizeBicubic1pass(pTexture, dst, SrcRect);
-
- MYD3DVERTEX<1> vx[] =
- {
- {(float)dst1.left, (float)dst1.top, 0.5f, 2.0f, tx0, ty0},
- {(float)dst1.right, (float)dst1.top, 0.5f, 2.0f, tx1, ty0},
- {(float)dst1.left, (float)dst1.bottom, 0.5f, 2.0f, tx0, ty1},
- {(float)dst1.right, (float)dst1.bottom, 0.5f, 2.0f, tx1, ty1},
- };
- AdjustQuad(vx, 1.0, 0.0); // Casimir666 : bug here, create vertical lines ! TODO : why ??????
- MYD3DVERTEX<1> vy[] =
- {
- {dst[0].x, dst[0].y, dst[0].z, 1.0/dst[0].z, tx0_2, ty0_2},
- {dst[1].x, dst[1].y, dst[1].z, 1.0/dst[1].z, tx1_2, ty0_2},
- {dst[2].x, dst[2].y, dst[2].z, 1.0/dst[2].z, tx0_2, ty1_2},
- {dst[3].x, dst[3].y, dst[3].z, 1.0/dst[3].z, tx1_2, ty1_2},
- };
- AdjustQuad(vy, 0.0, 1.0);
- hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShader[2]);
- {
- float fConstData[][4] = {{0.5f / Tex0_Width, 0.5f / Tex0_Height, 0, 0}, {1.0f / Tex0_Width, 1.0f / Tex0_Height, 0, 0}, {1.0f / Tex0_Width, 0, 0, 0}, {0, 1.0f / Tex0_Height, 0, 0}, {Tex0_Width, Tex0_Height, 0, 0}};
- hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, _countof(fConstData));
- }
- hr = m_pD3DDev->SetTexture(0, pTexture);
- CComPtr<IDirect3DSurface9> pRTOld;
- hr = m_pD3DDev->GetRenderTarget(0, &pRTOld);
- CComPtr<IDirect3DSurface9> pRT;
- hr = m_pScreenSizeTemporaryTexture[0]->GetSurfaceLevel(0, &pRT);
- hr = m_pD3DDev->SetRenderTarget(0, pRT);
- hr = TextureBlt(m_pD3DDev, vx, D3DTEXF_POINT);
- hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShader[3]);
- {
- float fConstData[][4] = {{0.5f / Tex1_Width, 0.5f / Tex1_Height, 0, 0}, {1.0f / Tex1_Width, 1.0f / Tex1_Height, 0, 0}, {1.0f / Tex1_Width, 0, 0, 0}, {0, 1.0f / Tex1_Height, 0, 0}, {Tex1_Width, Tex1_Height, 0, 0}};
- hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, _countof(fConstData));
- }
- hr = m_pD3DDev->SetTexture(0, m_pScreenSizeTemporaryTexture[0]);
- hr = m_pD3DDev->SetRenderTarget(0, pRTOld);
- hr = TextureBlt(m_pD3DDev, vy, D3DTEXF_POINT);
- m_pD3DDev->SetPixelShader(NULL);
- return hr;*/
+ HRESULT hr;
+
+ D3DSURFACE_DESC desc;
+ if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
+ return E_FAIL;
+ }
+
+ float w = (float)desc.Width;
+ float h = (float)desc.Height;
+ MYD3DVERTEX<1> v[] = {
+ {0, 0, 0.5f, 2.0f, 0, 0},
+ {w, 0, 0.5f, 2.0f, 1, 0},
+ {0, h, 0.5f, 2.0f, 0, 1},
+ {w, h, 0.5f, 2.0f, 1, 1},
+ };
+ for (int i = 0; i < _countof(v); i++) {
+ v[i].x -= 0.5;
+ v[i].y -= 0.5;
+ }
+ hr = m_pD3DDev->SetTexture(0, pTexture);
+ return TextureBlt(m_pD3DDev, v, D3DTEXF_POINT);
+}
+
+HRESULT CBaseAP::DrawRect(DWORD _Color, DWORD _Alpha, const CRect& _Rect)
+{
+ DWORD Color = D3DCOLOR_ARGB(_Alpha, GetRValue(_Color), GetGValue(_Color), GetBValue(_Color));
+ MYD3DVERTEX<0> v[] = {
+ {float(_Rect.left), float(_Rect.top), 0.5f, 2.0f, Color},
+ {float(_Rect.right), float(_Rect.top), 0.5f, 2.0f, Color},
+ {float(_Rect.left), float(_Rect.bottom), 0.5f, 2.0f, Color},
+ {float(_Rect.right), float(_Rect.bottom), 0.5f, 2.0f, Color},
+ };
+ for (int i = 0; i < _countof(v); i++) {
+ v[i].x -= 0.5;
+ v[i].y -= 0.5;
+ }
+ return DrawRectBase(m_pD3DDev, v);
+}
+
+HRESULT CBaseAP::TextureResize(IDirect3DTexture9* pTexture, Vector dst[4], D3DTEXTUREFILTERTYPE filter, const CRect& SrcRect)
+{
+ HRESULT hr;
+
+ D3DSURFACE_DESC desc;
+ if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
+ return E_FAIL;
+ }
+
+ float w = (float)desc.Width;
+ float h = (float)desc.Height;
+
+ float dx2 = 1.0f / w;
+ float dy2 = 1.0f / h;
+
+ MYD3DVERTEX<1> v[] = {
+ {dst[0].x, dst[0].y, dst[0].z, 1.0f / dst[0].z, SrcRect.left * dx2, SrcRect.top * dy2},
+ {dst[1].x, dst[1].y, dst[1].z, 1.0f / dst[1].z, SrcRect.right * dx2, SrcRect.top * dy2},
+ {dst[2].x, dst[2].y, dst[2].z, 1.0f / dst[2].z, SrcRect.left * dx2, SrcRect.bottom * dy2},
+ {dst[3].x, dst[3].y, dst[3].z, 1.0f / dst[3].z, SrcRect.right * dx2, SrcRect.bottom * dy2},
+ };
+ AdjustQuad(v, 0, 0);
+ hr = m_pD3DDev->SetTexture(0, pTexture);
+ hr = m_pD3DDev->SetPixelShader(NULL);
+ hr = TextureBlt(m_pD3DDev, v, filter);
+ return hr;
+}
+
+HRESULT CBaseAP::TextureResizeBilinear(IDirect3DTexture9* pTexture, Vector dst[4], const CRect& SrcRect)
+{
+ HRESULT hr;
+
+ D3DSURFACE_DESC desc;
+ if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
+ return E_FAIL;
+ }
+
+ float w = (float)desc.Width;
+ float h = (float)desc.Height;
+
+ float tx0 = (float)SrcRect.left;
+ float tx1 = (float)SrcRect.right;
+ float ty0 = (float)SrcRect.top;
+ float ty1 = (float)SrcRect.bottom;
+
+ MYD3DVERTEX<1> v[] = {
+ {dst[0].x, dst[0].y, dst[0].z, 1.0f / dst[0].z, tx0, ty0},
+ {dst[1].x, dst[1].y, dst[1].z, 1.0f / dst[1].z, tx1, ty0},
+ {dst[2].x, dst[2].y, dst[2].z, 1.0f / dst[2].z, tx0, ty1},
+ {dst[3].x, dst[3].y, dst[3].z, 1.0f / dst[3].z, tx1, ty1},
+ };
+ AdjustQuad(v, 1.0, 1.0);
+ float fConstData[][4] = {{0.5f / w, 0.5f / h, 0, 0}, {1.0f / w, 1.0f / h, 0, 0}, {1.0f / w, 0, 0, 0}, {0, 1.0f / h, 0, 0}, {w, h, 0, 0}};
+ hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, _countof(fConstData));
+ hr = m_pD3DDev->SetTexture(0, pTexture);
+ hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShader[0]);
+ hr = TextureBlt(m_pD3DDev, v, D3DTEXF_POINT);
+ m_pD3DDev->SetPixelShader(NULL);
+ return hr;
+}
+
+HRESULT CBaseAP::TextureResizeBicubic1pass(IDirect3DTexture9* pTexture, Vector dst[4], const CRect& SrcRect)
+{
+ HRESULT hr;
+
+ D3DSURFACE_DESC desc;
+ if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
+ return E_FAIL;
+ }
+
+ float w = (float)desc.Width;
+ float h = (float)desc.Height;
+
+ float tx0 = (float)SrcRect.left;
+ float tx1 = (float)SrcRect.right;
+ float ty0 = (float)SrcRect.top;
+ float ty1 = (float)SrcRect.bottom;
+
+ MYD3DVERTEX<1> v[] = {
+ {dst[0].x, dst[0].y, dst[0].z, 1.0f / dst[0].z, tx0, ty0},
+ {dst[1].x, dst[1].y, dst[1].z, 1.0f / dst[1].z, tx1, ty0},
+ {dst[2].x, dst[2].y, dst[2].z, 1.0f / dst[2].z, tx0, ty1},
+ {dst[3].x, dst[3].y, dst[3].z, 1.0f / dst[3].z, tx1, ty1},
+ };
+ AdjustQuad(v, 1.0, 1.0);
+ hr = m_pD3DDev->SetTexture(0, pTexture);
+ float fConstData[][4] = {{0.5f / w, 0.5f / h, 0, 0}, {1.0f / w, 1.0f / h, 0, 0}, {1.0f / w, 0, 0, 0}, {0, 1.0f / h, 0, 0}, {w, h, 0, 0}};
+ hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, _countof(fConstData));
+ hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShader[1]);
+ hr = TextureBlt(m_pD3DDev, v, D3DTEXF_POINT);
+ m_pD3DDev->SetPixelShader(NULL);
+ return hr;
+}
+
+HRESULT CBaseAP::TextureResizeBicubic2pass(IDirect3DTexture9* pTexture, Vector dst[4], const CRect& SrcRect)
+{
+ // The 2 pass sampler is incorrect in that it only does bilinear resampling in the y direction.
+ return TextureResizeBicubic1pass(pTexture, dst, SrcRect);
+
+ /*HRESULT hr;
+
+ // rotated?
+ if (dst[0].z != dst[1].z || dst[2].z != dst[3].z || dst[0].z != dst[3].z
+ || dst[0].y != dst[1].y || dst[0].x != dst[2].x || dst[2].y != dst[3].y || dst[1].x != dst[3].x)
+ return TextureResizeBicubic1pass(pTexture, dst, SrcRect);
+
+ D3DSURFACE_DESC desc;
+ if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
+ return E_FAIL;
+
+ float Tex0_Width = desc.Width;
+ float Tex0_Height = desc.Height;
+
+ CSize SrcTextSize = CSize(desc.Width, desc.Height);
+ double w = (double)SrcRect.Width();
+ double h = (double)SrcRect.Height();
+ UNREFERENCED_PARAMETER(w);
+
+ CRect dst1(0, 0, (int)(dst[3].x - dst[0].x), (int)h);
+
+ if (!m_pScreenSizeTemporaryTexture[0] || FAILED(m_pScreenSizeTemporaryTexture[0]->GetLevelDesc(0, &desc)))
+ return TextureResizeBicubic1pass(pTexture, dst, SrcRect);
+
+ float Tex1_Width = desc.Width;
+ float Tex1_Height = desc.Height;
+
+ float tx0 = SrcRect.left;
+ float tx1 = SrcRect.right;
+ float ty0 = SrcRect.top;
+ float ty1 = SrcRect.bottom;
+
+ float tx0_2 = 0;
+ float tx1_2 = dst1.Width();
+ float ty0_2 = 0;
+ float ty1_2 = h;
+
+ if (dst1.Width() > (int)desc.Width || dst1.Height() > (int)desc.Height)
+ return TextureResizeBicubic1pass(pTexture, dst, SrcRect);
+
+ MYD3DVERTEX<1> vx[] =
+ {
+ {(float)dst1.left, (float)dst1.top, 0.5f, 2.0f, tx0, ty0},
+ {(float)dst1.right, (float)dst1.top, 0.5f, 2.0f, tx1, ty0},
+ {(float)dst1.left, (float)dst1.bottom, 0.5f, 2.0f, tx0, ty1},
+ {(float)dst1.right, (float)dst1.bottom, 0.5f, 2.0f, tx1, ty1},
+ };
+ AdjustQuad(vx, 1.0, 0.0); // Casimir666 : bug here, create vertical lines ! TODO : why ??????
+ MYD3DVERTEX<1> vy[] =
+ {
+ {dst[0].x, dst[0].y, dst[0].z, 1.0/dst[0].z, tx0_2, ty0_2},
+ {dst[1].x, dst[1].y, dst[1].z, 1.0/dst[1].z, tx1_2, ty0_2},
+ {dst[2].x, dst[2].y, dst[2].z, 1.0/dst[2].z, tx0_2, ty1_2},
+ {dst[3].x, dst[3].y, dst[3].z, 1.0/dst[3].z, tx1_2, ty1_2},
+ };
+ AdjustQuad(vy, 0.0, 1.0);
+ hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShader[2]);
+ {
+ float fConstData[][4] = {{0.5f / Tex0_Width, 0.5f / Tex0_Height, 0, 0}, {1.0f / Tex0_Width, 1.0f / Tex0_Height, 0, 0}, {1.0f / Tex0_Width, 0, 0, 0}, {0, 1.0f / Tex0_Height, 0, 0}, {Tex0_Width, Tex0_Height, 0, 0}};
+ hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, _countof(fConstData));
+ }
+ hr = m_pD3DDev->SetTexture(0, pTexture);
+ CComPtr<IDirect3DSurface9> pRTOld;
+ hr = m_pD3DDev->GetRenderTarget(0, &pRTOld);
+ CComPtr<IDirect3DSurface9> pRT;
+ hr = m_pScreenSizeTemporaryTexture[0]->GetSurfaceLevel(0, &pRT);
+ hr = m_pD3DDev->SetRenderTarget(0, pRT);
+ hr = TextureBlt(m_pD3DDev, vx, D3DTEXF_POINT);
+ hr = m_pD3DDev->SetPixelShader(m_pResizerPixelShader[3]);
+ {
+ float fConstData[][4] = {{0.5f / Tex1_Width, 0.5f / Tex1_Height, 0, 0}, {1.0f / Tex1_Width, 1.0f / Tex1_Height, 0, 0}, {1.0f / Tex1_Width, 0, 0, 0}, {0, 1.0f / Tex1_Height, 0, 0}, {Tex1_Width, Tex1_Height, 0, 0}};
+ hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, _countof(fConstData));
+ }
+ hr = m_pD3DDev->SetTexture(0, m_pScreenSizeTemporaryTexture[0]);
+ hr = m_pD3DDev->SetRenderTarget(0, pRTOld);
+ hr = TextureBlt(m_pD3DDev, vy, D3DTEXF_POINT);
+ m_pD3DDev->SetPixelShader(NULL);
+ return hr;*/
}
HRESULT CBaseAP::AlphaBlt(RECT* pSrc, RECT* pDst, IDirect3DTexture9* pTexture)
{
- if (!pSrc || !pDst) {
- return E_POINTER;
- }
+ if (!pSrc || !pDst) {
+ return E_POINTER;
+ }
- CRect src(*pSrc), dst(*pDst);
+ CRect src(*pSrc), dst(*pDst);
- HRESULT hr;
+ HRESULT hr;
- do {
- D3DSURFACE_DESC d3dsd;
- ZeroMemory(&d3dsd, sizeof(d3dsd));
- if (FAILED(pTexture->GetLevelDesc(0, &d3dsd)) /*|| d3dsd.Type != D3DRTYPE_TEXTURE*/) {
- break;
- }
+ do {
+ D3DSURFACE_DESC d3dsd;
+ ZeroMemory(&d3dsd, sizeof(d3dsd));
+ if (FAILED(pTexture->GetLevelDesc(0, &d3dsd)) /*|| d3dsd.Type != D3DRTYPE_TEXTURE*/) {
+ break;
+ }
- float w = (float)d3dsd.Width;
- float h = (float)d3dsd.Height;
+ float w = (float)d3dsd.Width;
+ float h = (float)d3dsd.Height;
- struct {
- float x, y, z, rhw;
- float tu, tv;
- }
- pVertices[] = {
- {(float)dst.left, (float)dst.top, 0.5f, 2.0f, (float)src.left / w, (float)src.top / h},
- {(float)dst.right, (float)dst.top, 0.5f, 2.0f, (float)src.right / w, (float)src.top / h},
- {(float)dst.left, (float)dst.bottom, 0.5f, 2.0f, (float)src.left / w, (float)src.bottom / h},
- {(float)dst.right, (float)dst.bottom, 0.5f, 2.0f, (float)src.right / w, (float)src.bottom / h},
- };
+ struct {
+ float x, y, z, rhw;
+ float tu, tv;
+ }
+ pVertices[] = {
+ {(float)dst.left, (float)dst.top, 0.5f, 2.0f, (float)src.left / w, (float)src.top / h},
+ {(float)dst.right, (float)dst.top, 0.5f, 2.0f, (float)src.right / w, (float)src.top / h},
+ {(float)dst.left, (float)dst.bottom, 0.5f, 2.0f, (float)src.left / w, (float)src.bottom / h},
+ {(float)dst.right, (float)dst.bottom, 0.5f, 2.0f, (float)src.right / w, (float)src.bottom / h},
+ };
- hr = m_pD3DDev->SetTexture(0, pTexture);
+ hr = m_pD3DDev->SetTexture(0, pTexture);
- // GetRenderState fails for devices created with D3DCREATE_PUREDEVICE
- // so we need to provide default values in case GetRenderState fails
- DWORD abe, sb, db;
- if (FAILED(m_pD3DDev->GetRenderState(D3DRS_ALPHABLENDENABLE, &abe)))
- abe = FALSE;
- if (FAILED(m_pD3DDev->GetRenderState(D3DRS_SRCBLEND, &sb)))
- sb = D3DBLEND_ONE;
- if (FAILED(m_pD3DDev->GetRenderState(D3DRS_DESTBLEND, &db)))
- db = D3DBLEND_ZERO;
+ // GetRenderState fails for devices created with D3DCREATE_PUREDEVICE
+ // so we need to provide default values in case GetRenderState fails
+ DWORD abe, sb, db;
+ if (FAILED(m_pD3DDev->GetRenderState(D3DRS_ALPHABLENDENABLE, &abe))) {
+ abe = FALSE;
+ }
+ if (FAILED(m_pD3DDev->GetRenderState(D3DRS_SRCBLEND, &sb))) {
+ sb = D3DBLEND_ONE;
+ }
+ if (FAILED(m_pD3DDev->GetRenderState(D3DRS_DESTBLEND, &db))) {
+ db = D3DBLEND_ZERO;
+ }
- hr = m_pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
- hr = m_pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
- hr = m_pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
- hr = m_pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- hr = m_pD3DDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); // pre-multiplied src and ...
- hr = m_pD3DDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_SRCALPHA); // ... inverse alpha channel for dst
+ hr = m_pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
+ hr = m_pD3DDev->SetRenderState(D3DRS_LIGHTING, FALSE);
+ hr = m_pD3DDev->SetRenderState(D3DRS_ZENABLE, FALSE);
+ hr = m_pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ hr = m_pD3DDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); // pre-multiplied src and ...
+ hr = m_pD3DDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_SRCALPHA); // ... inverse alpha channel for dst
- hr = m_pD3DDev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
- hr = m_pD3DDev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
- hr = m_pD3DDev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
+ hr = m_pD3DDev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
+ hr = m_pD3DDev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+ hr = m_pD3DDev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
- hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
- hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
- hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
+ hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
+ hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
+ hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
- hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
- hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
+ hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
+ hr = m_pD3DDev->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
- hr = m_pD3DDev->SetPixelShader(NULL);
+ hr = m_pD3DDev->SetPixelShader(NULL);
- hr = m_pD3DDev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
- hr = m_pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pVertices, sizeof(pVertices[0]));
+ hr = m_pD3DDev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
+ hr = m_pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pVertices, sizeof(pVertices[0]));
- m_pD3DDev->SetTexture(0, NULL);
+ m_pD3DDev->SetTexture(0, NULL);
- m_pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, abe);
- m_pD3DDev->SetRenderState(D3DRS_SRCBLEND, sb);
- m_pD3DDev->SetRenderState(D3DRS_DESTBLEND, db);
+ m_pD3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, abe);
+ m_pD3DDev->SetRenderState(D3DRS_SRCBLEND, sb);
+ m_pD3DDev->SetRenderState(D3DRS_DESTBLEND, db);
- return S_OK;
- } while (0);
- return E_FAIL;
+ return S_OK;
+ } while (0);
+ return E_FAIL;
}
// Update the array m_pllJitter with a new vsync period. Calculate min, max and stddev.
void CBaseAP::SyncStats(LONGLONG syncTime)
{
- m_nNextJitter = (m_nNextJitter+1) % NB_JITTER;
- LONGLONG jitter = syncTime - m_llLastSyncTime;
- m_pllJitter[m_nNextJitter] = jitter;
- double syncDeviation = ((double)m_pllJitter[m_nNextJitter] - m_fJitterMean) / 10000.0;
- if (abs(syncDeviation) > (GetDisplayCycle() / 2)) {
- m_uSyncGlitches++;
- }
-
- LONGLONG llJitterSum = 0;
- LONGLONG llJitterSumAvg = 0;
- for (int i=0; i<NB_JITTER; i++) {
- LONGLONG Jitter = m_pllJitter[i];
- llJitterSum += Jitter;
- llJitterSumAvg += Jitter;
- }
- m_fJitterMean = double(llJitterSumAvg) / NB_JITTER;
- double DeviationSum = 0;
-
- for (int i=0; i<NB_JITTER; i++) {
- LONGLONG DevInt = m_pllJitter[i] - (LONGLONG)m_fJitterMean;
- double Deviation = (double)DevInt;
- DeviationSum += Deviation*Deviation;
- m_MaxJitter = max(m_MaxJitter, DevInt);
- m_MinJitter = min(m_MinJitter, DevInt);
- }
-
- m_fJitterStdDev = sqrt(DeviationSum/NB_JITTER);
- m_fAvrFps = 10000000.0/(double(llJitterSum)/NB_JITTER);
- m_llLastSyncTime = syncTime;
+ m_nNextJitter = (m_nNextJitter + 1) % NB_JITTER;
+ LONGLONG jitter = syncTime - m_llLastSyncTime;
+ m_pllJitter[m_nNextJitter] = jitter;
+ double syncDeviation = ((double)m_pllJitter[m_nNextJitter] - m_fJitterMean) / 10000.0;
+ if (abs(syncDeviation) > (GetDisplayCycle() / 2)) {
+ m_uSyncGlitches++;
+ }
+
+ LONGLONG llJitterSum = 0;
+ LONGLONG llJitterSumAvg = 0;
+ for (int i = 0; i < NB_JITTER; i++) {
+ LONGLONG Jitter = m_pllJitter[i];
+ llJitterSum += Jitter;
+ llJitterSumAvg += Jitter;
+ }
+ m_fJitterMean = double(llJitterSumAvg) / NB_JITTER;
+ double DeviationSum = 0;
+
+ for (int i = 0; i < NB_JITTER; i++) {
+ LONGLONG DevInt = m_pllJitter[i] - (LONGLONG)m_fJitterMean;
+ double Deviation = (double)DevInt;
+ DeviationSum += Deviation * Deviation;
+ m_MaxJitter = max(m_MaxJitter, DevInt);
+ m_MinJitter = min(m_MinJitter, DevInt);
+ }
+
+ m_fJitterStdDev = sqrt(DeviationSum / NB_JITTER);
+ m_fAvrFps = 10000000.0 / (double(llJitterSum) / NB_JITTER);
+ m_llLastSyncTime = syncTime;
}
// Collect the difference between periodEnd and periodStart in an array, calculate mean and stddev.
void CBaseAP::SyncOffsetStats(LONGLONG syncOffset)
{
- m_nNextSyncOffset = (m_nNextSyncOffset+1) % NB_JITTER;
- m_pllSyncOffset[m_nNextSyncOffset] = syncOffset;
+ m_nNextSyncOffset = (m_nNextSyncOffset + 1) % NB_JITTER;
+ m_pllSyncOffset[m_nNextSyncOffset] = syncOffset;
- LONGLONG AvrageSum = 0;
- for (int i=0; i<NB_JITTER; i++) {
- LONGLONG Offset = m_pllSyncOffset[i];
- AvrageSum += Offset;
- m_MaxSyncOffset = max(m_MaxSyncOffset, Offset);
- m_MinSyncOffset = min(m_MinSyncOffset, Offset);
- }
- double MeanOffset = double(AvrageSum)/NB_JITTER;
- double DeviationSum = 0;
- for (int i=0; i<NB_JITTER; i++) {
- double Deviation = double(m_pllSyncOffset[i]) - MeanOffset;
- DeviationSum += Deviation*Deviation;
- }
- double StdDev = sqrt(DeviationSum/NB_JITTER);
+ LONGLONG AvrageSum = 0;
+ for (int i = 0; i < NB_JITTER; i++) {
+ LONGLONG Offset = m_pllSyncOffset[i];
+ AvrageSum += Offset;
+ m_MaxSyncOffset = max(m_MaxSyncOffset, Offset);
+ m_MinSyncOffset = min(m_MinSyncOffset, Offset);
+ }
+ double MeanOffset = double(AvrageSum) / NB_JITTER;
+ double DeviationSum = 0;
+ for (int i = 0; i < NB_JITTER; i++) {
+ double Deviation = double(m_pllSyncOffset[i]) - MeanOffset;
+ DeviationSum += Deviation * Deviation;
+ }
+ double StdDev = sqrt(DeviationSum / NB_JITTER);
- m_fSyncOffsetAvr = MeanOffset;
- m_fSyncOffsetStdDev = StdDev;
+ m_fSyncOffsetAvr = MeanOffset;
+ m_fSyncOffsetStdDev = StdDev;
}
void CBaseAP::UpdateAlphaBitmap()
{
- m_VMR9AlphaBitmapData.Free();
+ m_VMR9AlphaBitmapData.Free();
- if ((m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_DISABLE) == 0) {
- HBITMAP hBitmap = (HBITMAP)GetCurrentObject (m_VMR9AlphaBitmap.hdc, OBJ_BITMAP);
- if (!hBitmap) {
- return;
- }
- DIBSECTION info = {0};
- if (!::GetObject(hBitmap, sizeof( DIBSECTION ), &info )) {
- return;
- }
+ if ((m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_DISABLE) == 0) {
+ HBITMAP hBitmap = (HBITMAP)GetCurrentObject(m_VMR9AlphaBitmap.hdc, OBJ_BITMAP);
+ if (!hBitmap) {
+ return;
+ }
+ DIBSECTION info = {0};
+ if (!::GetObject(hBitmap, sizeof(DIBSECTION), &info)) {
+ return;
+ }
- m_VMR9AlphaBitmapRect = CRect(0, 0, info.dsBm.bmWidth, info.dsBm.bmHeight);
- m_VMR9AlphaBitmapWidthBytes = info.dsBm.bmWidthBytes;
+ m_VMR9AlphaBitmapRect = CRect(0, 0, info.dsBm.bmWidth, info.dsBm.bmHeight);
+ m_VMR9AlphaBitmapWidthBytes = info.dsBm.bmWidthBytes;
- if (m_VMR9AlphaBitmapData.Allocate(info.dsBm.bmWidthBytes * info.dsBm.bmHeight)) {
- memcpy((BYTE *)m_VMR9AlphaBitmapData, info.dsBm.bmBits, info.dsBm.bmWidthBytes * info.dsBm.bmHeight);
- }
- }
+ if (m_VMR9AlphaBitmapData.Allocate(info.dsBm.bmWidthBytes * info.dsBm.bmHeight)) {
+ memcpy((BYTE*)m_VMR9AlphaBitmapData, info.dsBm.bmBits, info.dsBm.bmWidthBytes * info.dsBm.bmHeight);
+ }
+ }
}
// Present a sample (frame) using DirectX.
STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll)
{
- if (m_bPendingResetDevice) {
- SendResetRequest();
- return false;
- }
-
- CRenderersSettings& s = GetRenderersSettings();
- CRenderersData *pApp = GetRenderersData();
- D3DRASTER_STATUS rasterStatus;
- REFERENCE_TIME llCurRefTime = 0;
- REFERENCE_TIME llSyncOffset = 0;
- double dSyncOffset = 0.0;
-
- CAutoLock cRenderLock(&m_allocatorLock);
-
- // Estimate time for next vblank based on number of remaining lines in this frame. This algorithm seems to be
- // accurate within one ms why there should not be any need for a more accurate one. The wiggly line seen
- // when using sync to nearest and sync display is most likely due to inaccuracies in the audio-card-based
- // reference clock. The wiggles are not seen with the perfcounter-based reference clock of the sync to video option.
- m_pD3DDev->GetRasterStatus(0, &rasterStatus);
- m_uScanLineEnteringPaint = rasterStatus.ScanLine;
- if (m_pRefClock) {
- m_pRefClock->GetTime(&llCurRefTime);
- }
- int dScanLines = max((int)m_ScreenSize.cy - m_uScanLineEnteringPaint, 0);
- dSyncOffset = dScanLines * m_dDetectedScanlineTime; // ms
- llSyncOffset = REFERENCE_TIME(10000.0 * dSyncOffset); // Reference time units (100 ns)
- m_llEstVBlankTime = llCurRefTime + llSyncOffset; // Estimated time for the start of next vblank
-
- if (m_WindowRect.right <= m_WindowRect.left || m_WindowRect.bottom <= m_WindowRect.top
- || m_NativeVideoSize.cx <= 0 || m_NativeVideoSize.cy <= 0
- || !m_pVideoSurface) {
- return false;
- }
-
- HRESULT hr;
- CRect rSrcVid(CPoint(0, 0), m_NativeVideoSize);
- CRect rDstVid(m_VideoRect);
- CRect rSrcPri(CPoint(0, 0), m_WindowRect.Size());
- CRect rDstPri(m_WindowRect);
-
- m_pD3DDev->BeginScene();
- CComPtr<IDirect3DSurface9> pBackBuffer;
- m_pD3DDev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer);
- m_pD3DDev->SetRenderTarget(0, pBackBuffer);
- hr = m_pD3DDev->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0);
- if (!rDstVid.IsRectEmpty()) {
- if (m_pVideoTexture[m_nCurSurface]) {
- CComPtr<IDirect3DTexture9> pVideoTexture = m_pVideoTexture[m_nCurSurface];
-
- if (m_pVideoTexture[m_nDXSurface] && m_pVideoTexture[m_nDXSurface+1] && !m_pPixelShaders.IsEmpty()) {
- static __int64 counter = 0;
- static long start = clock();
-
- long stop = clock();
- long diff = stop - start;
-
- if (diff >= 10*60*CLOCKS_PER_SEC) {
- start = stop; // reset after 10 min (ps float has its limits in both range and accuracy)
- }
-
- int src = m_nCurSurface, dst = m_nDXSurface;
-
- D3DSURFACE_DESC desc;
- m_pVideoTexture[src]->GetLevelDesc(0, &desc);
-
- float fConstData[][4] = {
- {(float)desc.Width, (float)desc.Height, (float)(counter++), (float)diff / CLOCKS_PER_SEC},
- {1.0f / desc.Width, 1.0f / desc.Height, 0, 0},
- };
-
- hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, _countof(fConstData));
-
- CComPtr<IDirect3DSurface9> pRT;
- hr = m_pD3DDev->GetRenderTarget(0, &pRT);
-
- POSITION pos = m_pPixelShaders.GetHeadPosition();
- while (pos) {
- pVideoTexture = m_pVideoTexture[dst];
-
- hr = m_pD3DDev->SetRenderTarget(0, m_pVideoSurface[dst]);
- CExternalPixelShader &Shader = m_pPixelShaders.GetNext(pos);
- if (!Shader.m_pPixelShader) {
- Shader.Compile(m_pPSC);
- }
- hr = m_pD3DDev->SetPixelShader(Shader.m_pPixelShader);
- TextureCopy(m_pVideoTexture[src]);
-
- src = dst;
- if (++dst >= m_nDXSurface+2) {
- dst = m_nDXSurface;
- }
- }
-
- hr = m_pD3DDev->SetRenderTarget(0, pRT);
- hr = m_pD3DDev->SetPixelShader(NULL);
- }
-
- Vector dst[4];
- Transform(rDstVid, dst);
-
- DWORD iDX9Resizer = s.iDX9Resizer;
-
- float A = 0;
-
- switch (iDX9Resizer) {
- case 3:
- A = -0.60f;
- break;
- case 4:
- A = -0.751f;
- break; // FIXME : 0.75 crash recent D3D, or eat CPU
- case 5:
- A = -1.00f;
- break;
- }
- bool bScreenSpacePixelShaders = !m_pPixelShadersScreenSpace.IsEmpty();
-
- hr = InitResizers(A, bScreenSpacePixelShaders);
-
- if (!m_pScreenSizeTemporaryTexture[0] || !m_pScreenSizeTemporaryTexture[1]) {
- bScreenSpacePixelShaders = false;
- }
-
- if (bScreenSpacePixelShaders) {
- CComPtr<IDirect3DSurface9> pRT;
- hr = m_pScreenSizeTemporaryTexture[1]->GetSurfaceLevel(0, &pRT);
- if (hr != S_OK) {
- bScreenSpacePixelShaders = false;
- }
- if (bScreenSpacePixelShaders) {
- hr = m_pD3DDev->SetRenderTarget(0, pRT);
- if (hr != S_OK) {
- bScreenSpacePixelShaders = false;
- }
- hr = m_pD3DDev->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0);
- }
- }
-
- if (rSrcVid.Size() != rDstVid.Size()) {
- if (iDX9Resizer == 0 || iDX9Resizer == 1) {
- D3DTEXTUREFILTERTYPE Filter = iDX9Resizer == 0 ? D3DTEXF_POINT : D3DTEXF_LINEAR;
- hr = TextureResize(pVideoTexture, dst, Filter, rSrcVid);
- } else if (iDX9Resizer == 2) {
- hr = TextureResizeBilinear(pVideoTexture, dst, rSrcVid);
- } else if (iDX9Resizer >= 3) {
- hr = TextureResizeBicubic2pass(pVideoTexture, dst, rSrcVid);
- }
- } else {
- hr = TextureResize(pVideoTexture, dst, D3DTEXF_POINT, rSrcVid);
- }
-
- if (bScreenSpacePixelShaders) {
- static __int64 counter = 555;
- static long start = clock() + 333;
-
- long stop = clock() + 333;
- long diff = stop - start;
-
- if (diff >= 10*60*CLOCKS_PER_SEC) {
- start = stop; // reset after 10 min (ps float has its limits in both range and accuracy)
- }
-
- D3DSURFACE_DESC desc;
- m_pScreenSizeTemporaryTexture[0]->GetLevelDesc(0, &desc);
-
- float fConstData[][4] = {
- {(float)desc.Width, (float)desc.Height, (float)(counter++), (float)diff / CLOCKS_PER_SEC},
- {1.0f / desc.Width, 1.0f / desc.Height, 0, 0},
- };
-
- hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, _countof(fConstData));
-
- int src = 1, dst = 0;
-
- POSITION pos = m_pPixelShadersScreenSpace.GetHeadPosition();
- while (pos) {
- if (m_pPixelShadersScreenSpace.GetTailPosition() == pos) {
- m_pD3DDev->SetRenderTarget(0, pBackBuffer);
- } else {
- CComPtr<IDirect3DSurface9> pRT;
- hr = m_pScreenSizeTemporaryTexture[dst]->GetSurfaceLevel(0, &pRT);
- m_pD3DDev->SetRenderTarget(0, pRT);
- }
-
- CExternalPixelShader &Shader = m_pPixelShadersScreenSpace.GetNext(pos);
- if (!Shader.m_pPixelShader) {
- Shader.Compile(m_pPSC);
- }
- hr = m_pD3DDev->SetPixelShader(Shader.m_pPixelShader);
- TextureCopy(m_pScreenSizeTemporaryTexture[src]);
-
- std::swap(src, dst);
- }
-
- hr = m_pD3DDev->SetPixelShader(NULL);
- }
- } else {
- if (pBackBuffer) {
- ClipToSurface(pBackBuffer, rSrcVid, rDstVid);
- // rSrcVid has to be aligned on mod2 for yuy2->rgb conversion with StretchRect
- rSrcVid.left &= ~1;
- rSrcVid.right &= ~1;
- rSrcVid.top &= ~1;
- rSrcVid.bottom &= ~1;
- hr = m_pD3DDev->StretchRect(m_pVideoSurface[m_nCurSurface], rSrcVid, pBackBuffer, rDstVid, m_filter);
- if (FAILED(hr)) {
- return false;
- }
- }
- }
- }
- AlphaBltSubPic(rSrcPri.Size());
- if (m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_UPDATE) {
- CAutoLock BitMapLock(&m_VMR9AlphaBitmapLock);
- CRect rcSrc (m_VMR9AlphaBitmap.rSrc);
- m_pOSDTexture = NULL;
- m_pOSDSurface = NULL;
- if ((m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_DISABLE) == 0 && (BYTE *)m_VMR9AlphaBitmapData) {
- if ( (m_pD3DXLoadSurfaceFromMemory != NULL) &&
- SUCCEEDED(hr = m_pD3DDev->CreateTexture(rcSrc.Width(), rcSrc.Height(), 1,
- D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
- D3DPOOL_DEFAULT, &m_pOSDTexture, NULL)) ) {
- if (SUCCEEDED (hr = m_pOSDTexture->GetSurfaceLevel(0, &m_pOSDSurface))) {
- hr = m_pD3DXLoadSurfaceFromMemory (m_pOSDSurface, NULL, NULL, (BYTE *)m_VMR9AlphaBitmapData, D3DFMT_A8R8G8B8, m_VMR9AlphaBitmapWidthBytes,
- NULL, &m_VMR9AlphaBitmapRect, D3DX_FILTER_NONE, m_VMR9AlphaBitmap.clrSrcKey);
- }
- if (FAILED (hr)) {
- m_pOSDTexture = NULL;
- m_pOSDSurface = NULL;
- }
- }
- }
- m_VMR9AlphaBitmap.dwFlags ^= VMRBITMAP_UPDATE;
- }
- if (pApp->m_fDisplayStats) {
- DrawStats();
- }
- if (m_pOSDTexture) {
- AlphaBlt(rSrcPri, rDstPri, m_pOSDTexture);
- }
- m_pD3DDev->EndScene();
-
- if (m_pD3DDevEx) {
- if (m_bIsFullscreen) {
- hr = m_pD3DDevEx->PresentEx(NULL, NULL, NULL, NULL, NULL);
- } else {
- hr = m_pD3DDevEx->PresentEx(rSrcPri, rDstPri, NULL, NULL, NULL);
- }
- } else {
- if (m_bIsFullscreen) {
- hr = m_pD3DDev->Present(NULL, NULL, NULL, NULL);
- } else {
- hr = m_pD3DDev->Present(rSrcPri, rDstPri, NULL, NULL);
- }
- }
- if (FAILED(hr)) {
- DEBUG_ONLY(_tprintf_s(_T("Device lost or something\n")));
- }
- // Calculate timing statistics
- if (m_pRefClock) {
- m_pRefClock->GetTime(&llCurRefTime); // To check if we called Present too late to hit the right vsync
- }
- m_llEstVBlankTime = max(m_llEstVBlankTime, llCurRefTime); // Sometimes the real value is larger than the estimated value (but never smaller)
- if (pApp->m_fDisplayStats < 3) { // Partial on-screen statistics
- SyncStats(m_llEstVBlankTime); // Max of estimate and real. Sometimes Present may actually return immediately so we need the estimate as a lower bound
- }
- if (pApp->m_fDisplayStats == 1) { // Full on-screen statistics
- SyncOffsetStats(-llSyncOffset); // Minus because we want time to flow downward in the graph in DrawStats
- }
-
- // Adjust sync
- double frameCycle = (double)((m_llSampleTime - m_llLastSampleTime) / 10000.0);
- if (frameCycle < 0) {
- frameCycle = 0.0; // Happens when searching.
- }
-
- if (s.m_RenderSettings.bSynchronizeVideo) {
- m_pGenlock->ControlClock(dSyncOffset, frameCycle);
- } else if (s.m_RenderSettings.bSynchronizeDisplay) {
- m_pGenlock->ControlDisplay(dSyncOffset, frameCycle);
- } else {
- m_pGenlock->UpdateStats(dSyncOffset, frameCycle); // No sync or sync to nearest neighbor
- }
-
- m_dFrameCycle = m_pGenlock->frameCycleAvg;
- if (m_dFrameCycle > 0.0) {
- m_fps = 1000.0 / m_dFrameCycle;
- }
- m_dCycleDifference = GetCycleDifference();
- if (abs(m_dCycleDifference) < 0.05) { // If less than 5% speed difference
- m_bSnapToVSync = true;
- } else {
- m_bSnapToVSync = false;
- }
-
- // Check how well audio is matching rate (if at all)
- DWORD tmp;
- if (m_pAudioStats != NULL) {
- m_pAudioStats->GetStatParam(AM_AUDREND_STAT_PARAM_SLAVE_ACCUMERROR, &m_lAudioLag, &tmp);
- m_lAudioLagMin = min((long)m_lAudioLag, m_lAudioLagMin);
- m_lAudioLagMax = max((long)m_lAudioLag, m_lAudioLagMax);
- m_pAudioStats->GetStatParam(AM_AUDREND_STAT_PARAM_SLAVE_MODE, &m_lAudioSlaveMode, &tmp);
- }
-
- if (pApp->m_bResetStats) {
- ResetStats();
- pApp->m_bResetStats = false;
- }
-
- bool fResetDevice = m_bPendingResetDevice;
- if (hr == D3DERR_DEVICELOST && m_pD3DDev->TestCooperativeLevel() == D3DERR_DEVICENOTRESET || hr == S_PRESENT_MODE_CHANGED) {
- fResetDevice = true;
- }
- if (SettingsNeedResetDevice()) {
- fResetDevice = true;
- }
-
- BOOL bCompositionEnabled = false;
- if (m_pDwmIsCompositionEnabled) {
- m_pDwmIsCompositionEnabled(&bCompositionEnabled);
- }
- if ((bCompositionEnabled != 0) != m_bCompositionEnabled) {
- if (m_bIsFullscreen) {
- m_bCompositionEnabled = (bCompositionEnabled != 0);
- } else {
- fResetDevice = true;
- }
- }
-
- if (s.fResetDevice) {
- LONGLONG time = GetRenderersData()->GetPerfCounter();
- if (time > m_LastAdapterCheck + 20000000) { // check every 2 sec.
- m_LastAdapterCheck = time;
+ if (m_bPendingResetDevice) {
+ SendResetRequest();
+ return false;
+ }
+
+ CRenderersSettings& s = GetRenderersSettings();
+ CRenderersData* pApp = GetRenderersData();
+ D3DRASTER_STATUS rasterStatus;
+ REFERENCE_TIME llCurRefTime = 0;
+ REFERENCE_TIME llSyncOffset = 0;
+ double dSyncOffset = 0.0;
+
+ CAutoLock cRenderLock(&m_allocatorLock);
+
+ // Estimate time for next vblank based on number of remaining lines in this frame. This algorithm seems to be
+ // accurate within one ms why there should not be any need for a more accurate one. The wiggly line seen
+ // when using sync to nearest and sync display is most likely due to inaccuracies in the audio-card-based
+ // reference clock. The wiggles are not seen with the perfcounter-based reference clock of the sync to video option.
+ m_pD3DDev->GetRasterStatus(0, &rasterStatus);
+ m_uScanLineEnteringPaint = rasterStatus.ScanLine;
+ if (m_pRefClock) {
+ m_pRefClock->GetTime(&llCurRefTime);
+ }
+ int dScanLines = max((int)m_ScreenSize.cy - m_uScanLineEnteringPaint, 0);
+ dSyncOffset = dScanLines * m_dDetectedScanlineTime; // ms
+ llSyncOffset = REFERENCE_TIME(10000.0 * dSyncOffset); // Reference time units (100 ns)
+ m_llEstVBlankTime = llCurRefTime + llSyncOffset; // Estimated time for the start of next vblank
+
+ if (m_WindowRect.right <= m_WindowRect.left || m_WindowRect.bottom <= m_WindowRect.top
+ || m_NativeVideoSize.cx <= 0 || m_NativeVideoSize.cy <= 0
+ || !m_pVideoSurface) {
+ return false;
+ }
+
+ HRESULT hr;
+ CRect rSrcVid(CPoint(0, 0), m_NativeVideoSize);
+ CRect rDstVid(m_VideoRect);
+ CRect rSrcPri(CPoint(0, 0), m_WindowRect.Size());
+ CRect rDstPri(m_WindowRect);
+
+ m_pD3DDev->BeginScene();
+ CComPtr<IDirect3DSurface9> pBackBuffer;
+ m_pD3DDev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer);
+ m_pD3DDev->SetRenderTarget(0, pBackBuffer);
+ hr = m_pD3DDev->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0);
+ if (!rDstVid.IsRectEmpty()) {
+ if (m_pVideoTexture[m_nCurSurface]) {
+ CComPtr<IDirect3DTexture9> pVideoTexture = m_pVideoTexture[m_nCurSurface];
+
+ if (m_pVideoTexture[m_nDXSurface] && m_pVideoTexture[m_nDXSurface + 1] && !m_pPixelShaders.IsEmpty()) {
+ static __int64 counter = 0;
+ static long start = clock();
+
+ long stop = clock();
+ long diff = stop - start;
+
+ if (diff >= 10 * 60 * CLOCKS_PER_SEC) {
+ start = stop; // reset after 10 min (ps float has its limits in both range and accuracy)
+ }
+
+ int src = m_nCurSurface, dst = m_nDXSurface;
+
+ D3DSURFACE_DESC desc;
+ m_pVideoTexture[src]->GetLevelDesc(0, &desc);
+
+ float fConstData[][4] = {
+ {(float)desc.Width, (float)desc.Height, (float)(counter++), (float)diff / CLOCKS_PER_SEC},
+ {1.0f / desc.Width, 1.0f / desc.Height, 0, 0},
+ };
+
+ hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, _countof(fConstData));
+
+ CComPtr<IDirect3DSurface9> pRT;
+ hr = m_pD3DDev->GetRenderTarget(0, &pRT);
+
+ POSITION pos = m_pPixelShaders.GetHeadPosition();
+ while (pos) {
+ pVideoTexture = m_pVideoTexture[dst];
+
+ hr = m_pD3DDev->SetRenderTarget(0, m_pVideoSurface[dst]);
+ CExternalPixelShader& Shader = m_pPixelShaders.GetNext(pos);
+ if (!Shader.m_pPixelShader) {
+ Shader.Compile(m_pPSC);
+ }
+ hr = m_pD3DDev->SetPixelShader(Shader.m_pPixelShader);
+ TextureCopy(m_pVideoTexture[src]);
+
+ src = dst;
+ if (++dst >= m_nDXSurface + 2) {
+ dst = m_nDXSurface;
+ }
+ }
+
+ hr = m_pD3DDev->SetRenderTarget(0, pRT);
+ hr = m_pD3DDev->SetPixelShader(NULL);
+ }
+
+ Vector dst[4];
+ Transform(rDstVid, dst);
+
+ DWORD iDX9Resizer = s.iDX9Resizer;
+
+ float A = 0;
+
+ switch (iDX9Resizer) {
+ case 3:
+ A = -0.60f;
+ break;
+ case 4:
+ A = -0.751f;
+ break; // FIXME : 0.75 crash recent D3D, or eat CPU
+ case 5:
+ A = -1.00f;
+ break;
+ }
+ bool bScreenSpacePixelShaders = !m_pPixelShadersScreenSpace.IsEmpty();
+
+ hr = InitResizers(A, bScreenSpacePixelShaders);
+
+ if (!m_pScreenSizeTemporaryTexture[0] || !m_pScreenSizeTemporaryTexture[1]) {
+ bScreenSpacePixelShaders = false;
+ }
+
+ if (bScreenSpacePixelShaders) {
+ CComPtr<IDirect3DSurface9> pRT;
+ hr = m_pScreenSizeTemporaryTexture[1]->GetSurfaceLevel(0, &pRT);
+ if (hr != S_OK) {
+ bScreenSpacePixelShaders = false;
+ }
+ if (bScreenSpacePixelShaders) {
+ hr = m_pD3DDev->SetRenderTarget(0, pRT);
+ if (hr != S_OK) {
+ bScreenSpacePixelShaders = false;
+ }
+ hr = m_pD3DDev->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0);
+ }
+ }
+
+ if (rSrcVid.Size() != rDstVid.Size()) {
+ if (iDX9Resizer == 0 || iDX9Resizer == 1) {
+ D3DTEXTUREFILTERTYPE Filter = iDX9Resizer == 0 ? D3DTEXF_POINT : D3DTEXF_LINEAR;
+ hr = TextureResize(pVideoTexture, dst, Filter, rSrcVid);
+ } else if (iDX9Resizer == 2) {
+ hr = TextureResizeBilinear(pVideoTexture, dst, rSrcVid);
+ } else if (iDX9Resizer >= 3) {
+ hr = TextureResizeBicubic2pass(pVideoTexture, dst, rSrcVid);
+ }
+ } else {
+ hr = TextureResize(pVideoTexture, dst, D3DTEXF_POINT, rSrcVid);
+ }
+
+ if (bScreenSpacePixelShaders) {
+ static __int64 counter = 555;
+ static long start = clock() + 333;
+
+ long stop = clock() + 333;
+ long diff = stop - start;
+
+ if (diff >= 10 * 60 * CLOCKS_PER_SEC) {
+ start = stop; // reset after 10 min (ps float has its limits in both range and accuracy)
+ }
+
+ D3DSURFACE_DESC desc;
+ m_pScreenSizeTemporaryTexture[0]->GetLevelDesc(0, &desc);
+
+ float fConstData[][4] = {
+ {(float)desc.Width, (float)desc.Height, (float)(counter++), (float)diff / CLOCKS_PER_SEC},
+ {1.0f / desc.Width, 1.0f / desc.Height, 0, 0},
+ };
+
+ hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, _countof(fConstData));
+
+ int src = 1, dst = 0;
+
+ POSITION pos = m_pPixelShadersScreenSpace.GetHeadPosition();
+ while (pos) {
+ if (m_pPixelShadersScreenSpace.GetTailPosition() == pos) {
+ m_pD3DDev->SetRenderTarget(0, pBackBuffer);
+ } else {
+ CComPtr<IDirect3DSurface9> pRT;
+ hr = m_pScreenSizeTemporaryTexture[dst]->GetSurfaceLevel(0, &pRT);
+ m_pD3DDev->SetRenderTarget(0, pRT);
+ }
+
+ CExternalPixelShader& Shader = m_pPixelShadersScreenSpace.GetNext(pos);
+ if (!Shader.m_pPixelShader) {
+ Shader.Compile(m_pPSC);
+ }
+ hr = m_pD3DDev->SetPixelShader(Shader.m_pPixelShader);
+ TextureCopy(m_pScreenSizeTemporaryTexture[src]);
+
+ std::swap(src, dst);
+ }
+
+ hr = m_pD3DDev->SetPixelShader(NULL);
+ }
+ } else {
+ if (pBackBuffer) {
+ ClipToSurface(pBackBuffer, rSrcVid, rDstVid);
+ // rSrcVid has to be aligned on mod2 for yuy2->rgb conversion with StretchRect
+ rSrcVid.left &= ~1;
+ rSrcVid.right &= ~1;
+ rSrcVid.top &= ~1;
+ rSrcVid.bottom &= ~1;
+ hr = m_pD3DDev->StretchRect(m_pVideoSurface[m_nCurSurface], rSrcVid, pBackBuffer, rDstVid, m_filter);
+ if (FAILED(hr)) {
+ return false;
+ }
+ }
+ }
+ }
+ AlphaBltSubPic(rSrcPri.Size());
+ if (m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_UPDATE) {
+ CAutoLock BitMapLock(&m_VMR9AlphaBitmapLock);
+ CRect rcSrc(m_VMR9AlphaBitmap.rSrc);
+ m_pOSDTexture = NULL;
+ m_pOSDSurface = NULL;
+ if ((m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_DISABLE) == 0 && (BYTE*)m_VMR9AlphaBitmapData) {
+ if ((m_pD3DXLoadSurfaceFromMemory != NULL) &&
+ SUCCEEDED(hr = m_pD3DDev->CreateTexture(rcSrc.Width(), rcSrc.Height(), 1,
+ D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
+ D3DPOOL_DEFAULT, &m_pOSDTexture, NULL))) {
+ if (SUCCEEDED(hr = m_pOSDTexture->GetSurfaceLevel(0, &m_pOSDSurface))) {
+ hr = m_pD3DXLoadSurfaceFromMemory(m_pOSDSurface, NULL, NULL, (BYTE*)m_VMR9AlphaBitmapData, D3DFMT_A8R8G8B8, m_VMR9AlphaBitmapWidthBytes,
+ NULL, &m_VMR9AlphaBitmapRect, D3DX_FILTER_NONE, m_VMR9AlphaBitmap.clrSrcKey);
+ }
+ if (FAILED(hr)) {
+ m_pOSDTexture = NULL;
+ m_pOSDSurface = NULL;
+ }
+ }
+ }
+ m_VMR9AlphaBitmap.dwFlags ^= VMRBITMAP_UPDATE;
+ }
+ if (pApp->m_fDisplayStats) {
+ DrawStats();
+ }
+ if (m_pOSDTexture) {
+ AlphaBlt(rSrcPri, rDstPri, m_pOSDTexture);
+ }
+ m_pD3DDev->EndScene();
+
+ if (m_pD3DDevEx) {
+ if (m_bIsFullscreen) {
+ hr = m_pD3DDevEx->PresentEx(NULL, NULL, NULL, NULL, NULL);
+ } else {
+ hr = m_pD3DDevEx->PresentEx(rSrcPri, rDstPri, NULL, NULL, NULL);
+ }
+ } else {
+ if (m_bIsFullscreen) {
+ hr = m_pD3DDev->Present(NULL, NULL, NULL, NULL);
+ } else {
+ hr = m_pD3DDev->Present(rSrcPri, rDstPri, NULL, NULL);
+ }
+ }
+ if (FAILED(hr)) {
+ DEBUG_ONLY(_tprintf_s(_T("Device lost or something\n")));
+ }
+ // Calculate timing statistics
+ if (m_pRefClock) {
+ m_pRefClock->GetTime(&llCurRefTime); // To check if we called Present too late to hit the right vsync
+ }
+ m_llEstVBlankTime = max(m_llEstVBlankTime, llCurRefTime); // Sometimes the real value is larger than the estimated value (but never smaller)
+ if (pApp->m_fDisplayStats < 3) { // Partial on-screen statistics
+ SyncStats(m_llEstVBlankTime); // Max of estimate and real. Sometimes Present may actually return immediately so we need the estimate as a lower bound
+ }
+ if (pApp->m_fDisplayStats == 1) { // Full on-screen statistics
+ SyncOffsetStats(-llSyncOffset); // Minus because we want time to flow downward in the graph in DrawStats
+ }
+
+ // Adjust sync
+ double frameCycle = (double)((m_llSampleTime - m_llLastSampleTime) / 10000.0);
+ if (frameCycle < 0) {
+ frameCycle = 0.0; // Happens when searching.
+ }
+
+ if (s.m_RenderSettings.bSynchronizeVideo) {
+ m_pGenlock->ControlClock(dSyncOffset, frameCycle);
+ } else if (s.m_RenderSettings.bSynchronizeDisplay) {
+ m_pGenlock->ControlDisplay(dSyncOffset, frameCycle);
+ } else {
+ m_pGenlock->UpdateStats(dSyncOffset, frameCycle); // No sync or sync to nearest neighbor
+ }
+
+ m_dFrameCycle = m_pGenlock->frameCycleAvg;
+ if (m_dFrameCycle > 0.0) {
+ m_fps = 1000.0 / m_dFrameCycle;
+ }
+ m_dCycleDifference = GetCycleDifference();
+ if (abs(m_dCycleDifference) < 0.05) { // If less than 5% speed difference
+ m_bSnapToVSync = true;
+ } else {
+ m_bSnapToVSync = false;
+ }
+
+ // Check how well audio is matching rate (if at all)
+ DWORD tmp;
+ if (m_pAudioStats != NULL) {
+ m_pAudioStats->GetStatParam(AM_AUDREND_STAT_PARAM_SLAVE_ACCUMERROR, &m_lAudioLag, &tmp);
+ m_lAudioLagMin = min((long)m_lAudioLag, m_lAudioLagMin);
+ m_lAudioLagMax = max((long)m_lAudioLag, m_lAudioLagMax);
+ m_pAudioStats->GetStatParam(AM_AUDREND_STAT_PARAM_SLAVE_MODE, &m_lAudioSlaveMode, &tmp);
+ }
+
+ if (pApp->m_bResetStats) {
+ ResetStats();
+ pApp->m_bResetStats = false;
+ }
+
+ bool fResetDevice = m_bPendingResetDevice;
+ if (hr == D3DERR_DEVICELOST && m_pD3DDev->TestCooperativeLevel() == D3DERR_DEVICENOTRESET || hr == S_PRESENT_MODE_CHANGED) {
+ fResetDevice = true;
+ }
+ if (SettingsNeedResetDevice()) {
+ fResetDevice = true;
+ }
+
+ BOOL bCompositionEnabled = false;
+ if (m_pDwmIsCompositionEnabled) {
+ m_pDwmIsCompositionEnabled(&bCompositionEnabled);
+ }
+ if ((bCompositionEnabled != 0) != m_bCompositionEnabled) {
+ if (m_bIsFullscreen) {
+ m_bCompositionEnabled = (bCompositionEnabled != 0);
+ } else {
+ fResetDevice = true;
+ }
+ }
+
+ if (s.fResetDevice) {
+ LONGLONG time = GetRenderersData()->GetPerfCounter();
+ if (time > m_LastAdapterCheck + 20000000) { // check every 2 sec.
+ m_LastAdapterCheck = time;
#ifdef _DEBUG
- D3DDEVICE_CREATION_PARAMETERS Parameters;
- if (SUCCEEDED(m_pD3DDev->GetCreationParameters(&Parameters))) {
- ASSERT(Parameters.AdapterOrdinal == m_CurrentAdapter);
- }
+ D3DDEVICE_CREATION_PARAMETERS Parameters;
+ if (SUCCEEDED(m_pD3DDev->GetCreationParameters(&Parameters))) {
+ ASSERT(Parameters.AdapterOrdinal == m_CurrentAdapter);
+ }
#endif
- if (m_CurrentAdapter != GetAdapter(m_pD3D)) {
- fResetDevice = true;
- }
+ if (m_CurrentAdapter != GetAdapter(m_pD3D)) {
+ fResetDevice = true;
+ }
#ifdef _DEBUG
- else {
- ASSERT(m_pD3D->GetAdapterMonitor(m_CurrentAdapter) == m_pD3D->GetAdapterMonitor(GetAdapter(m_pD3D)));
- }
+ else {
+ ASSERT(m_pD3D->GetAdapterMonitor(m_CurrentAdapter) == m_pD3D->GetAdapterMonitor(GetAdapter(m_pD3D)));
+ }
#endif
- }
- }
+ }
+ }
- if (fResetDevice) {
- m_bPendingResetDevice = true;
- SendResetRequest();
- }
- return true;
+ if (fResetDevice) {
+ m_bPendingResetDevice = true;
+ SendResetRequest();
+ }
+ return true;
}
void CBaseAP::SendResetRequest()
{
- if (!m_bDeviceResetRequested) {
- m_bDeviceResetRequested = true;
- AfxGetApp()->m_pMainWnd->PostMessage(WM_RESET_DEVICE);
- }
+ if (!m_bDeviceResetRequested) {
+ m_bDeviceResetRequested = true;
+ AfxGetApp()->m_pMainWnd->PostMessage(WM_RESET_DEVICE);
+ }
}
STDMETHODIMP_(bool) CBaseAP::ResetDevice()
{
- DeleteSurfaces();
- HRESULT hr;
- CString Error;
- if (FAILED(hr = CreateDXDevice(Error)) || FAILED(hr = AllocSurfaces())) {
- m_bDeviceResetRequested = false;
- return false;
- }
- m_pGenlock->SetMonitor(GetAdapter(m_pD3D));
- m_pGenlock->GetTiming();
- OnResetDevice();
- m_bDeviceResetRequested = false;
- m_bPendingResetDevice = false;
- return true;
+ DeleteSurfaces();
+ HRESULT hr;
+ CString Error;
+ if (FAILED(hr = CreateDXDevice(Error)) || FAILED(hr = AllocSurfaces())) {
+ m_bDeviceResetRequested = false;
+ return false;
+ }
+ m_pGenlock->SetMonitor(GetAdapter(m_pD3D));
+ m_pGenlock->GetTiming();
+ OnResetDevice();
+ m_bDeviceResetRequested = false;
+ m_bPendingResetDevice = false;
+ return true;
}
STDMETHODIMP_(bool) CBaseAP::DisplayChange()
{
- return true;
-}
-
-void CBaseAP::DrawText(const RECT &rc, const CString &strText, int _Priority)
-{
- if (_Priority < 1) {
- return;
- }
- int Quality = 1;
- D3DXCOLOR Color1(1.0f, 0.2f, 0.2f, 1.0f );
- D3DXCOLOR Color0(0.0f, 0.0f, 0.0f, 1.0f );
- RECT Rect1 = rc;
- RECT Rect2 = rc;
- if (Quality == 1) {
- OffsetRect(&Rect2 , 2, 2);
- } else {
- OffsetRect(&Rect2 , -1, -1);
- }
- if (Quality > 0) {
- m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- }
- OffsetRect (&Rect2 , 1, 0);
- if (Quality > 3) {
- m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- }
- OffsetRect (&Rect2 , 1, 0);
- if (Quality > 2) {
- m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- }
- OffsetRect (&Rect2 , 0, 1);
- if (Quality > 3) {
- m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- }
- OffsetRect (&Rect2 , 0, 1);
- if (Quality > 1) {
- m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- }
- OffsetRect (&Rect2 , -1, 0);
- if (Quality > 3) {
- m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- }
- OffsetRect (&Rect2 , -1, 0);
- if (Quality > 2) {
- m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- }
- OffsetRect (&Rect2 , 0, -1);
- if (Quality > 3) {
- m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
- }
- m_pFont->DrawText( m_pSprite, strText, -1, &Rect1, DT_NOCLIP, Color1);
+ return true;
+}
+
+void CBaseAP::DrawText(const RECT& rc, const CString& strText, int _Priority)
+{
+ if (_Priority < 1) {
+ return;
+ }
+ int Quality = 1;
+ D3DXCOLOR Color1(1.0f, 0.2f, 0.2f, 1.0f);
+ D3DXCOLOR Color0(0.0f, 0.0f, 0.0f, 1.0f);
+ RECT Rect1 = rc;
+ RECT Rect2 = rc;
+ if (Quality == 1) {
+ OffsetRect(&Rect2 , 2, 2);
+ } else {
+ OffsetRect(&Rect2 , -1, -1);
+ }
+ if (Quality > 0) {
+ m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
+ OffsetRect(&Rect2 , 1, 0);
+ if (Quality > 3) {
+ m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
+ OffsetRect(&Rect2 , 1, 0);
+ if (Quality > 2) {
+ m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
+ OffsetRect(&Rect2 , 0, 1);
+ if (Quality > 3) {
+ m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
+ OffsetRect(&Rect2 , 0, 1);
+ if (Quality > 1) {
+ m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
+ OffsetRect(&Rect2 , -1, 0);
+ if (Quality > 3) {
+ m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
+ OffsetRect(&Rect2 , -1, 0);
+ if (Quality > 2) {
+ m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
+ OffsetRect(&Rect2 , 0, -1);
+ if (Quality > 3) {
+ m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
+ m_pFont->DrawText(m_pSprite, strText, -1, &Rect1, DT_NOCLIP, Color1);
}
void CBaseAP::DrawStats()
{
- CRenderersSettings& s = GetRenderersSettings();
- CRenderersData * pApp = GetRenderersData();
+ CRenderersSettings& s = GetRenderersSettings();
+ CRenderersData* pApp = GetRenderersData();
- LONGLONG llMaxJitter = m_MaxJitter;
- LONGLONG llMinJitter = m_MinJitter;
+ LONGLONG llMaxJitter = m_MaxJitter;
+ LONGLONG llMinJitter = m_MinJitter;
- RECT rc = {20, 20, 520, 520 };
- // pApp->m_fDisplayStats = 1 for full stats, 2 for little less, 3 for basic, 0 for no stats
- if (m_pFont && m_pSprite) {
- m_pSprite->Begin(D3DXSPRITE_ALPHABLEND);
- CString strText;
- int TextHeight = (int)(25.0*m_TextScale + 0.5);
+ RECT rc = {20, 20, 520, 520 };
+ // pApp->m_fDisplayStats = 1 for full stats, 2 for little less, 3 for basic, 0 for no stats
+ if (m_pFont && m_pSprite) {
+ m_pSprite->Begin(D3DXSPRITE_ALPHABLEND);
+ CString strText;
+ int TextHeight = (int)(25.0 * m_TextScale + 0.5);
- strText.Format(L"Frames drawn from stream start: %d | Sample time stamp: %d ms", m_pcFramesDrawn, (LONG)(m_llSampleTime / 10000));
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
+ strText.Format(L"Frames drawn from stream start: %d | Sample time stamp: %d ms", m_pcFramesDrawn, (LONG)(m_llSampleTime / 10000));
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
- if (pApp->m_fDisplayStats == 1) {
- strText.Format(L"Frame cycle : %.3f ms [%.3f ms, %.3f ms] Actual %+5.3f ms [%+.3f ms, %+.3f ms]", m_dFrameCycle, m_pGenlock->minFrameCycle, m_pGenlock->maxFrameCycle, m_fJitterMean / 10000.0, (double(llMinJitter)/10000.0), (double(llMaxJitter)/10000.0));
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
+ if (pApp->m_fDisplayStats == 1) {
+ strText.Format(L"Frame cycle : %.3f ms [%.3f ms, %.3f ms] Actual %+5.3f ms [%+.3f ms, %+.3f ms]", m_dFrameCycle, m_pGenlock->minFrameCycle, m_pGenlock->maxFrameCycle, m_fJitterMean / 10000.0, (double(llMinJitter) / 10000.0), (double(llMaxJitter) / 10000.0));
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
- strText.Format(L"Display cycle: Measured closest match %.3f ms Measured base %.3f ms", m_dOptimumDisplayCycle, m_dEstRefreshCycle);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
+ strText.Format(L"Display cycle: Measured closest match %.3f ms Measured base %.3f ms", m_dOptimumDisplayCycle, m_dEstRefreshCycle);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
- strText.Format(L"Frame rate : %.3f fps Actual frame rate: %.3f fps", m_fps, 10000000.0 / m_fJitterMean);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
+ strText.Format(L"Frame rate : %.3f fps Actual frame rate: %.3f fps", m_fps, 10000000.0 / m_fJitterMean);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
- strText.Format(L"Windows : Display cycle %.3f ms Display refresh rate %d Hz", m_dD3DRefreshCycle, m_uD3DRefreshRate);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
+ strText.Format(L"Windows : Display cycle %.3f ms Display refresh rate %d Hz", m_dD3DRefreshCycle, m_uD3DRefreshRate);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
- if (m_pGenlock->powerstripTimingExists) {
- strText.Format(L"Powerstrip : Display cycle %.3f ms Display refresh rate %.3f Hz", 1000.0 / m_pGenlock->curDisplayFreq, m_pGenlock->curDisplayFreq);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
- }
+ if (m_pGenlock->powerstripTimingExists) {
+ strText.Format(L"Powerstrip : Display cycle %.3f ms Display refresh rate %.3f Hz", 1000.0 / m_pGenlock->curDisplayFreq, m_pGenlock->curDisplayFreq);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ }
- if ((m_caps.Caps & D3DCAPS_READ_SCANLINE) == 0) {
- strText = L"Scan line err: Graphics device does not support scan line access. No sync is possible";
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
- }
+ if ((m_caps.Caps & D3DCAPS_READ_SCANLINE) == 0) {
+ strText = L"Scan line err: Graphics device does not support scan line access. No sync is possible";
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ }
#ifdef _DEBUG
- if (m_pD3DDevEx) {
- CComPtr<IDirect3DSwapChain9> pSC;
- HRESULT hr = m_pD3DDevEx->GetSwapChain(0, &pSC);
- CComQIPtr<IDirect3DSwapChain9Ex> pSCEx = pSC;
- if (pSCEx) {
- D3DPRESENTSTATS stats;
- hr = pSCEx->GetPresentStats(&stats);
- if (SUCCEEDED(hr)) {
- strText = L"Graphics device present stats:";
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- strText.Format(L" PresentCount %d PresentRefreshCount %d SyncRefreshCount %d",
- stats.PresentCount, stats.PresentRefreshCount, stats.SyncRefreshCount);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- LARGE_INTEGER Freq;
- QueryPerformanceFrequency (&Freq);
- Freq.QuadPart /= 1000;
- strText.Format(L" SyncQPCTime %dms SyncGPUTime %dms",
- stats.SyncQPCTime.QuadPart / Freq.QuadPart, stats.SyncGPUTime.QuadPart / Freq.QuadPart);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
- } else {
- strText = L"Graphics device does not support present stats";
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
- }
- }
- }
+ if (m_pD3DDevEx) {
+ CComPtr<IDirect3DSwapChain9> pSC;
+ HRESULT hr = m_pD3DDevEx->GetSwapChain(0, &pSC);
+ CComQIPtr<IDirect3DSwapChain9Ex> pSCEx = pSC;
+ if (pSCEx) {
+ D3DPRESENTSTATS stats;
+ hr = pSCEx->GetPresentStats(&stats);
+ if (SUCCEEDED(hr)) {
+ strText = L"Graphics device present stats:";
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ strText.Format(L" PresentCount %d PresentRefreshCount %d SyncRefreshCount %d",
+ stats.PresentCount, stats.PresentRefreshCount, stats.SyncRefreshCount);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ LARGE_INTEGER Freq;
+ QueryPerformanceFrequency(&Freq);
+ Freq.QuadPart /= 1000;
+ strText.Format(L" SyncQPCTime %dms SyncGPUTime %dms",
+ stats.SyncQPCTime.QuadPart / Freq.QuadPart, stats.SyncGPUTime.QuadPart / Freq.QuadPart);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ } else {
+ strText = L"Graphics device does not support present stats";
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ }
+ }
+ }
#endif
- strText.Format(L"Video size : %d x %d (AR = %d : %d) Display resolution %d x %d ", m_NativeVideoSize.cx, m_NativeVideoSize.cy, m_AspectRatio.cx, m_AspectRatio.cy, m_ScreenSize.cx, m_ScreenSize.cy);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- if (s.m_RenderSettings.bSynchronizeDisplay || s.m_RenderSettings.bSynchronizeVideo) {
- if (s.m_RenderSettings.bSynchronizeDisplay && !m_pGenlock->PowerstripRunning()) {
- strText = L"Sync error : PowerStrip is not running. No display sync is possible.";
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
- } else {
- strText.Format(L"Sync adjust : %d | # of adjustments: %d", m_pGenlock->adjDelta, (m_pGenlock->clockAdjustmentsMade + m_pGenlock->displayAdjustmentsMade) / 2);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
- }
- }
- }
-
- strText.Format(L"Sync offset : Average %3.1f ms [%.1f ms, %.1f ms] Target %3.1f ms", m_pGenlock->syncOffsetAvg, m_pGenlock->minSyncOffset, m_pGenlock->maxSyncOffset, s.m_RenderSettings.fTargetSyncOffset);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- strText.Format(L"Sync status : glitches %d, display-frame cycle mismatch: %7.3f %%, dropped frames %d", m_uSyncGlitches, 100 * m_dCycleDifference, m_pcFramesDropped);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- if (pApp->m_fDisplayStats == 1) {
- if (m_pAudioStats && s.m_RenderSettings.bSynchronizeVideo) {
- strText.Format(L"Audio lag : %3d ms [%d ms, %d ms] | %s", m_lAudioLag, m_lAudioLagMin, m_lAudioLagMax, (m_lAudioSlaveMode == 4) ? _T("Audio renderer is matching rate (for analog sound output)") : _T("Audio renderer is not matching rate"));
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
- }
-
- strText.Format(L"Sample time : waiting %3d ms", m_lNextSampleWait);
- if (s.m_RenderSettings.bSynchronizeNearest) {
- CString temp;
- temp.Format(L" paint time correction: %3d ms Hysteresis: %d", m_lShiftToNearest, m_llHysteresis /10000);
- strText += temp;
- }
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- strText.Format(L"Buffering : Buffered %3d Free %3d Current Surface %3d", m_nUsedBuffer, m_nDXSurface - m_nUsedBuffer, m_nCurSurface, m_nVMR9Surfaces, m_iVMR9Surface);
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- strText = L"Settings : ";
-
- if (m_bIsFullscreen) {
- strText += "D3DFS ";
- }
- if (s.m_RenderSettings.iVMRDisableDesktopComposition) {
- strText += "DisDC ";
- }
- if (s.m_RenderSettings.bSynchronizeVideo) {
- strText += "SyncVideo ";
- }
- if (s.m_RenderSettings.bSynchronizeDisplay) {
- strText += "SyncDisplay ";
- }
- if (s.m_RenderSettings.bSynchronizeNearest) {
- strText += "SyncNearest ";
- }
- if (m_bHighColorResolution) {
- strText += "10 bit ";
- }
- if (s.m_RenderSettings.iEVROutputRange == 0) {
- strText += "0-255 ";
- } else if (s.m_RenderSettings.iEVROutputRange == 1) {
- strText += "16-235 ";
- }
-
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- strText.Format(L"%-13s: %s", GetDXVAVersion(), GetDXVADecoderDescription());
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- strText.Format(L"DirectX SDK : %u", GetRenderersData()->GetDXSdkRelease());
- DrawText(rc, strText, 1);
- OffsetRect(&rc, 0, TextHeight);
-
- for (int i=0; i<6; i++) {
- if (m_strStatsMsg[i][0]) {
- DrawText(rc, m_strStatsMsg[i], 1);
- OffsetRect(&rc, 0, TextHeight);
- }
- }
- }
- OffsetRect(&rc, 0, TextHeight); // Extra "line feed"
- m_pSprite->End();
- }
-
- if (m_pLine && (pApp->m_fDisplayStats < 3)) {
- D3DXVECTOR2 Points[NB_JITTER];
- int nIndex;
-
- int DrawWidth = 625;
- int DrawHeight = 250;
- int Alpha = 80;
- int StartX = m_WindowRect.Width() - (DrawWidth + 20);
- int StartY = m_WindowRect.Height() - (DrawHeight + 20);
-
- DrawRect(RGB(0, 0, 0), Alpha, CRect(StartX, StartY, StartX + DrawWidth, StartY + DrawHeight));
- m_pLine->SetWidth(2.5);
- m_pLine->SetAntialias(1);
- m_pLine->Begin();
-
- for (int i = 0; i <= DrawHeight; i += 5) {
- Points[0].x = (FLOAT)StartX;
- Points[0].y = (FLOAT)(StartY + i);
- Points[1].x = (FLOAT)(StartX + (((i + 25) % 25) ? 50 : 625));
- Points[1].y = (FLOAT)(StartY + i);
- m_pLine->Draw(Points, 2, D3DCOLOR_XRGB(100, 100, 255));
- }
-
- for (int i = 0; i < DrawWidth; i += 125) { // Every 25:th sample
- Points[0].x = (FLOAT)(StartX + i);
- Points[0].y = (FLOAT)(StartY + DrawHeight / 2);
- Points[1].x = (FLOAT)(StartX + i);
- Points[1].y = (FLOAT)(StartY + DrawHeight / 2 + 10);
- m_pLine->Draw(Points, 2, D3DCOLOR_XRGB(100, 100, 255));
- }
-
- for (int i = 0; i < NB_JITTER; i++) {
- nIndex = (m_nNextJitter + 1 + i) % NB_JITTER;
- if (nIndex < 0) {
- nIndex += NB_JITTER;
- }
- double Jitter = m_pllJitter[nIndex] - m_fJitterMean;
- Points[i].x = (FLOAT)(StartX + (i * 5));
- Points[i].y = (FLOAT)(StartY + (Jitter / 2000.0 + 125.0));
- }
- m_pLine->Draw(Points, NB_JITTER, D3DCOLOR_XRGB(255, 100, 100));
-
- if (pApp->m_fDisplayStats == 1) { // Full on-screen statistics
- for (int i = 0; i < NB_JITTER; i++) {
- nIndex = (m_nNextSyncOffset + 1 + i) % NB_JITTER;
- if (nIndex < 0) {
- nIndex += NB_JITTER;
- }
- Points[i].x = (FLOAT)(StartX + (i * 5));
- Points[i].y = (FLOAT)(StartY + ((m_pllSyncOffset[nIndex]) / 2000 + 125));
- }
- m_pLine->Draw(Points, NB_JITTER, D3DCOLOR_XRGB(100, 200, 100));
- }
- m_pLine->End();
- }
+ strText.Format(L"Video size : %d x %d (AR = %d : %d) Display resolution %d x %d ", m_NativeVideoSize.cx, m_NativeVideoSize.cy, m_AspectRatio.cx, m_AspectRatio.cy, m_ScreenSize.cx, m_ScreenSize.cy);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ if (s.m_RenderSettings.bSynchronizeDisplay || s.m_RenderSettings.bSynchronizeVideo) {
+ if (s.m_RenderSettings.bSynchronizeDisplay && !m_pGenlock->PowerstripRunning()) {
+ strText = L"Sync error : PowerStrip is not running. No display sync is possible.";
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ } else {
+ strText.Format(L"Sync adjust : %d | # of adjustments: %d", m_pGenlock->adjDelta, (m_pGenlock->clockAdjustmentsMade + m_pGenlock->displayAdjustmentsMade) / 2);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ }
+ }
+ }
+
+ strText.Format(L"Sync offset : Average %3.1f ms [%.1f ms, %.1f ms] Target %3.1f ms", m_pGenlock->syncOffsetAvg, m_pGenlock->minSyncOffset, m_pGenlock->maxSyncOffset, s.m_RenderSettings.fTargetSyncOffset);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ strText.Format(L"Sync status : glitches %d, display-frame cycle mismatch: %7.3f %%, dropped frames %d", m_uSyncGlitches, 100 * m_dCycleDifference, m_pcFramesDropped);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ if (pApp->m_fDisplayStats == 1) {
+ if (m_pAudioStats && s.m_RenderSettings.bSynchronizeVideo) {
+ strText.Format(L"Audio lag : %3d ms [%d ms, %d ms] | %s", m_lAudioLag, m_lAudioLagMin, m_lAudioLagMax, (m_lAudioSlaveMode == 4) ? _T("Audio renderer is matching rate (for analog sound output)") : _T("Audio renderer is not matching rate"));
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+ }
+
+ strText.Format(L"Sample time : waiting %3d ms", m_lNextSampleWait);
+ if (s.m_RenderSettings.bSynchronizeNearest) {
+ CString temp;
+ temp.Format(L" paint time correction: %3d ms Hysteresis: %d", m_lShiftToNearest, m_llHysteresis / 10000);
+ strText += temp;
+ }
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ strText.Format(L"Buffering : Buffered %3d Free %3d Current Surface %3d", m_nUsedBuffer, m_nDXSurface - m_nUsedBuffer, m_nCurSurface, m_nVMR9Surfaces, m_iVMR9Surface);
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ strText = L"Settings : ";
+
+ if (m_bIsFullscreen) {
+ strText += "D3DFS ";
+ }
+ if (s.m_RenderSettings.iVMRDisableDesktopComposition) {
+ strText += "DisDC ";
+ }
+ if (s.m_RenderSettings.bSynchronizeVideo) {
+ strText += "SyncVideo ";
+ }
+ if (s.m_RenderSettings.bSynchronizeDisplay) {
+ strText += "SyncDisplay ";
+ }
+ if (s.m_RenderSettings.bSynchronizeNearest) {
+ strText += "SyncNearest ";
+ }
+ if (m_bHighColorResolution) {
+ strText += "10 bit ";
+ }
+ if (s.m_RenderSettings.iEVROutputRange == 0) {
+ strText += "0-255 ";
+ } else if (s.m_RenderSettings.iEVROutputRange == 1) {
+ strText += "16-235 ";
+ }
+
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ strText.Format(L"%-13s: %s", GetDXVAVersion(), GetDXVADecoderDescription());
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ strText.Format(L"DirectX SDK : %u", GetRenderersData()->GetDXSdkRelease());
+ DrawText(rc, strText, 1);
+ OffsetRect(&rc, 0, TextHeight);
+
+ for (int i = 0; i < 6; i++) {
+ if (m_strStatsMsg[i][0]) {
+ DrawText(rc, m_strStatsMsg[i], 1);
+ OffsetRect(&rc, 0, TextHeight);
+ }
+ }
+ }
+ OffsetRect(&rc, 0, TextHeight); // Extra "line feed"
+ m_pSprite->End();
+ }
+
+ if (m_pLine && (pApp->m_fDisplayStats < 3)) {
+ D3DXVECTOR2 Points[NB_JITTER];
+ int nIndex;
+
+ int DrawWidth = 625;
+ int DrawHeight = 250;
+ int Alpha = 80;
+ int StartX = m_WindowRect.Width() - (DrawWidth + 20);
+ int StartY = m_WindowRect.Height() - (DrawHeight + 20);
+
+ DrawRect(RGB(0, 0, 0), Alpha, CRect(StartX, StartY, StartX + DrawWidth, StartY + DrawHeight));
+ m_pLine->SetWidth(2.5);
+ m_pLine->SetAntialias(1);
+ m_pLine->Begin();
+
+ for (int i = 0; i <= DrawHeight; i += 5) {
+ Points[0].x = (FLOAT)StartX;
+ Points[0].y = (FLOAT)(StartY + i);
+ Points[1].x = (FLOAT)(StartX + (((i + 25) % 25) ? 50 : 625));
+ Points[1].y = (FLOAT)(StartY + i);
+ m_pLine->Draw(Points, 2, D3DCOLOR_XRGB(100, 100, 255));
+ }
+
+ for (int i = 0; i < DrawWidth; i += 125) { // Every 25:th sample
+ Points[0].x = (FLOAT)(StartX + i);
+ Points[0].y = (FLOAT)(StartY + DrawHeight / 2);
+ Points[1].x = (FLOAT)(StartX + i);
+ Points[1].y = (FLOAT)(StartY + DrawHeight / 2 + 10);
+ m_pLine->Draw(Points, 2, D3DCOLOR_XRGB(100, 100, 255));
+ }
+
+ for (int i = 0; i < NB_JITTER; i++) {
+ nIndex = (m_nNextJitter + 1 + i) % NB_JITTER;
+ if (nIndex < 0) {
+ nIndex += NB_JITTER;
+ }
+ double Jitter = m_pllJitter[nIndex] - m_fJitterMean;
+ Points[i].x = (FLOAT)(StartX + (i * 5));
+ Points[i].y = (FLOAT)(StartY + (Jitter / 2000.0 + 125.0));
+ }
+ m_pLine->Draw(Points, NB_JITTER, D3DCOLOR_XRGB(255, 100, 100));
+
+ if (pApp->m_fDisplayStats == 1) { // Full on-screen statistics
+ for (int i = 0; i < NB_JITTER; i++) {
+ nIndex = (m_nNextSyncOffset + 1 + i) % NB_JITTER;
+ if (nIndex < 0) {
+ nIndex += NB_JITTER;
+ }
+ Points[i].x = (FLOAT)(StartX + (i * 5));
+ Points[i].y = (FLOAT)(StartY + ((m_pllSyncOffset[nIndex]) / 2000 + 125));
+ }
+ m_pLine->Draw(Points, NB_JITTER, D3DCOLOR_XRGB(100, 200, 100));
+ }
+ m_pLine->End();
+ }
}
double CBaseAP::GetRefreshRate()
{
- if (m_pGenlock->powerstripTimingExists) {
- return m_pGenlock->curDisplayFreq;
- } else {
- return (double)m_uD3DRefreshRate;
- }
+ if (m_pGenlock->powerstripTimingExists) {
+ return m_pGenlock->curDisplayFreq;
+ } else {
+ return (double)m_uD3DRefreshRate;
+ }
}
double CBaseAP::GetDisplayCycle()
{
- if (m_pGenlock->powerstripTimingExists) {
- return 1000.0 / m_pGenlock->curDisplayFreq;
- } else {
- return (double)m_dD3DRefreshCycle;
- }
+ if (m_pGenlock->powerstripTimingExists) {
+ return 1000.0 / m_pGenlock->curDisplayFreq;
+ } else {
+ return (double)m_dD3DRefreshCycle;
+ }
}
double CBaseAP::GetCycleDifference()
{
- double dBaseDisplayCycle = GetDisplayCycle();
- UINT i;
- double minDiff = 1.0;
- if (dBaseDisplayCycle == 0.0 || m_dFrameCycle == 0.0) {
- return 1.0;
- } else {
- for (i = 1; i <= 8; i++) { // Try a lot of multiples of the display frequency
- double dDisplayCycle = i * dBaseDisplayCycle;
- double diff = (dDisplayCycle - m_dFrameCycle) / m_dFrameCycle;
- if (abs(diff) < abs(minDiff)) {
- minDiff = diff;
- m_dOptimumDisplayCycle = dDisplayCycle;
- }
- }
- }
- return minDiff;
+ double dBaseDisplayCycle = GetDisplayCycle();
+ UINT i;
+ double minDiff = 1.0;
+ if (dBaseDisplayCycle == 0.0 || m_dFrameCycle == 0.0) {
+ return 1.0;
+ } else {
+ for (i = 1; i <= 8; i++) { // Try a lot of multiples of the display frequency
+ double dDisplayCycle = i * dBaseDisplayCycle;
+ double diff = (dDisplayCycle - m_dFrameCycle) / m_dFrameCycle;
+ if (abs(diff) < abs(minDiff)) {
+ minDiff = diff;
+ m_dOptimumDisplayCycle = dDisplayCycle;
+ }
+ }
+ }
+ return minDiff;
}
void CBaseAP::EstimateRefreshTimings()
{
- if (m_pD3DDev) {
- CRenderersData *pApp = GetRenderersData();
- D3DRASTER_STATUS rasterStatus;
- m_pD3DDev->GetRasterStatus(0, &rasterStatus);
- while (rasterStatus.ScanLine != 0) {
- m_pD3DDev->GetRasterStatus(0, &rasterStatus);
- }
- while (rasterStatus.ScanLine == 0) {
- m_pD3DDev->GetRasterStatus(0, &rasterStatus);
- }
- m_pD3DDev->GetRasterStatus(0, &rasterStatus);
- LONGLONG startTime = pApp->GetPerfCounter();
- UINT startLine = rasterStatus.ScanLine;
- LONGLONG endTime = 0;
- LONGLONG time = 0;
- UINT endLine = 0;
- UINT line = 0;
- bool done = false;
- while (!done) { // Estimate time for one scan line
- m_pD3DDev->GetRasterStatus(0, &rasterStatus);
- line = rasterStatus.ScanLine;
- time = pApp->GetPerfCounter();
- if (line > 0) {
- endLine = line;
- endTime = time;
- } else {
- done = true;
- }
- }
- m_dDetectedScanlineTime = (double)(endTime - startTime) / (double)((endLine - startLine) * 10000.0);
-
- // Estimate the display refresh rate from the vsyncs
- m_pD3DDev->GetRasterStatus(0, &rasterStatus);
- while (rasterStatus.ScanLine != 0) {
- m_pD3DDev->GetRasterStatus(0, &rasterStatus);
- }
- // Now we're at the start of a vsync
- startTime = pApp->GetPerfCounter();
- UINT i;
- for (i = 1; i <= 50; i++) {
- m_pD3DDev->GetRasterStatus(0, &rasterStatus);
- while (rasterStatus.ScanLine == 0) {
- m_pD3DDev->GetRasterStatus(0, &rasterStatus);
- }
- while (rasterStatus.ScanLine != 0) {
- m_pD3DDev->GetRasterStatus(0, &rasterStatus);
- }
- // Now we're at the next vsync
- }
- endTime = pApp->GetPerfCounter();
- m_dEstRefreshCycle = (double)(endTime - startTime) / ((i - 1) * 10000.0);
- }
+ if (m_pD3DDev) {
+ CRenderersData* pApp = GetRenderersData();
+ D3DRASTER_STATUS rasterStatus;
+ m_pD3DDev->GetRasterStatus(0, &rasterStatus);
+ while (rasterStatus.ScanLine != 0) {
+ m_pD3DDev->GetRasterStatus(0, &rasterStatus);
+ }
+ while (rasterStatus.ScanLine == 0) {
+ m_pD3DDev->GetRasterStatus(0, &rasterStatus);
+ }
+ m_pD3DDev->GetRasterStatus(0, &rasterStatus);
+ LONGLONG startTime = pApp->GetPerfCounter();
+ UINT startLine = rasterStatus.ScanLine;
+ LONGLONG endTime = 0;
+ LONGLONG time = 0;
+ UINT endLine = 0;
+ UINT line = 0;
+ bool done = false;
+ while (!done) { // Estimate time for one scan line
+ m_pD3DDev->GetRasterStatus(0, &rasterStatus);
+ line = rasterStatus.ScanLine;
+ time = pApp->GetPerfCounter();
+ if (line > 0) {
+ endLine = line;
+ endTime = time;
+ } else {
+ done = true;
+ }
+ }
+ m_dDetectedScanlineTime = (double)(endTime - startTime) / (double)((endLine - startLine) * 10000.0);
+
+ // Estimate the display refresh rate from the vsyncs
+ m_pD3DDev->GetRasterStatus(0, &rasterStatus);
+ while (rasterStatus.ScanLine != 0) {
+ m_pD3DDev->GetRasterStatus(0, &rasterStatus);
+ }
+ // Now we're at the start of a vsync
+ startTime = pApp->GetPerfCounter();
+ UINT i;
+ for (i = 1; i <= 50; i++) {
+ m_pD3DDev->GetRasterStatus(0, &rasterStatus);
+ while (rasterStatus.ScanLine == 0) {
+ m_pD3DDev->GetRasterStatus(0, &rasterStatus);
+ }
+ while (rasterStatus.ScanLine != 0) {
+ m_pD3DDev->GetRasterStatus(0, &rasterStatus);
+ }
+ // Now we're at the next vsync
+ }
+ endTime = pApp->GetPerfCounter();
+ m_dEstRefreshCycle = (double)(endTime - startTime) / ((i - 1) * 10000.0);
+ }
}
bool CBaseAP::ExtractInterlaced(const AM_MEDIA_TYPE* pmt)
{
- if (pmt->formattype==FORMAT_VideoInfo) {
- return false;
- } else if (pmt->formattype==FORMAT_VideoInfo2) {
- return (((VIDEOINFOHEADER2*)pmt->pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced) != 0;
- } else if (pmt->formattype==FORMAT_MPEGVideo) {
- return false;
- } else if (pmt->formattype==FORMAT_MPEG2Video) {
- return (((MPEG2VIDEOINFO*)pmt->pbFormat)->hdr.dwInterlaceFlags & AMINTERLACE_IsInterlaced) != 0;
- } else {
- return false;
- }
+ if (pmt->formattype == FORMAT_VideoInfo) {
+ return false;
+ } else if (pmt->formattype == FORMAT_VideoInfo2) {
+ return (((VIDEOINFOHEADER2*)pmt->pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced) != 0;
+ } else if (pmt->formattype == FORMAT_MPEGVideo) {
+ return false;
+ } else if (pmt->formattype == FORMAT_MPEG2Video) {
+ return (((MPEG2VIDEOINFO*)pmt->pbFormat)->hdr.dwInterlaceFlags & AMINTERLACE_IsInterlaced) != 0;
+ } else {
+ return false;
+ }
}
STDMETHODIMP CBaseAP::GetDIB(BYTE* lpDib, DWORD* size)
{
- CheckPointer(size, E_POINTER);
-
- HRESULT hr;
-
- D3DSURFACE_DESC desc;
- memset(&desc, 0, sizeof(desc));
- m_pVideoSurface[m_nCurSurface]->GetDesc(&desc);
-
- DWORD required = sizeof(BITMAPINFOHEADER) + (desc.Width * desc.Height * 32 >> 3);
- if (!lpDib) {
- *size = required;
- return S_OK;
- }
- if (*size < required) {
- return E_OUTOFMEMORY;
- }
- *size = required;
-
- CComPtr<IDirect3DSurface9> pSurface = m_pVideoSurface[m_nCurSurface];
- D3DLOCKED_RECT r;
- if (FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) {
- pSurface = NULL;
- if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &pSurface, NULL))
- || FAILED(hr = m_pD3DDev->GetRenderTargetData(m_pVideoSurface[m_nCurSurface], pSurface))
- || FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) {
- return hr;
- }
- }
-
- BITMAPINFOHEADER* bih = (BITMAPINFOHEADER*)lpDib;
- memset(bih, 0, sizeof(BITMAPINFOHEADER));
- bih->biSize = sizeof(BITMAPINFOHEADER);
- bih->biWidth = desc.Width;
- bih->biHeight = desc.Height;
- bih->biBitCount = 32;
- bih->biPlanes = 1;
- bih->biSizeImage = bih->biWidth * bih->biHeight * bih->biBitCount >> 3;
-
- BitBltFromRGBToRGB(
- bih->biWidth, bih->biHeight,
- (BYTE*)(bih + 1), bih->biWidth*bih->biBitCount>>3, bih->biBitCount,
- (BYTE*)r.pBits + r.Pitch*(desc.Height-1), -(int)r.Pitch, 32);
-
- pSurface->UnlockRect();
-
- return S_OK;
+ CheckPointer(size, E_POINTER);
+
+ HRESULT hr;
+
+ D3DSURFACE_DESC desc;
+ memset(&desc, 0, sizeof(desc));
+ m_pVideoSurface[m_nCurSurface]->GetDesc(&desc);
+
+ DWORD required = sizeof(BITMAPINFOHEADER) + (desc.Width * desc.Height * 32 >> 3);
+ if (!lpDib) {
+ *size = required;
+ return S_OK;
+ }
+ if (*size < required) {
+ return E_OUTOFMEMORY;
+ }
+ *size = required;
+
+ CComPtr<IDirect3DSurface9> pSurface = m_pVideoSurface[m_nCurSurface];
+ D3DLOCKED_RECT r;
+ if (FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) {
+ pSurface = NULL;
+ if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &pSurface, NULL))
+ || FAILED(hr = m_pD3DDev->GetRenderTargetData(m_pVideoSurface[m_nCurSurface], pSurface))
+ || FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) {
+ return hr;
+ }
+ }
+
+ BITMAPINFOHEADER* bih = (BITMAPINFOHEADER*)lpDib;
+ memset(bih, 0, sizeof(BITMAPINFOHEADER));
+ bih->biSize = sizeof(BITMAPINFOHEADER);
+ bih->biWidth = desc.Width;
+ bih->biHeight = desc.Height;
+ bih->biBitCount = 32;
+ bih->biPlanes = 1;
+ bih->biSizeImage = bih->biWidth * bih->biHeight * bih->biBitCount >> 3;
+
+ BitBltFromRGBToRGB(
+ bih->biWidth, bih->biHeight,
+ (BYTE*)(bih + 1), bih->biWidth * bih->biBitCount >> 3, bih->biBitCount,
+ (BYTE*)r.pBits + r.Pitch * (desc.Height - 1), -(int)r.Pitch, 32);
+
+ pSurface->UnlockRect();
+
+ return S_OK;
}
STDMETHODIMP CBaseAP::SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget)
{
- return SetPixelShader2(pSrcData, pTarget, false);
+ return SetPixelShader2(pSrcData, pTarget, false);
}
STDMETHODIMP CBaseAP::SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace)
{
- CAutoLock cRenderLock(&m_allocatorLock);
-
- CAtlList<CExternalPixelShader> *pPixelShaders;
- if (bScreenSpace) {
- pPixelShaders = &m_pPixelShadersScreenSpace;
- } else {
- pPixelShaders = &m_pPixelShaders;
- }
-
- if (!pSrcData && !pTarget) {
- pPixelShaders->RemoveAll();
- m_pD3DDev->SetPixelShader(NULL);
- return S_OK;
- }
-
- if (!pSrcData || !pTarget) {
- return E_INVALIDARG;
- }
-
- CExternalPixelShader Shader;
- Shader.m_SourceData = pSrcData;
- Shader.m_SourceTarget = pTarget;
-
- CComPtr<IDirect3DPixelShader9> pPixelShader;
-
- HRESULT hr = Shader.Compile(m_pPSC);
- if (FAILED(hr)) {
- return hr;
- }
-
- pPixelShaders->AddTail(Shader);
- Paint(true);
- return S_OK;
-}
-
-CSyncAP::CSyncAP(HWND hWnd, bool bFullscreen, HRESULT& hr, CString &_Error): CBaseAP(hWnd, bFullscreen, hr, _Error)
-{
- HMODULE hLib;
- CRenderersSettings& s = GetRenderersSettings();
-
- m_nResetToken = 0;
- m_hRenderThread = INVALID_HANDLE_VALUE;
- m_hMixerThread= INVALID_HANDLE_VALUE;
- m_hEvtFlush = INVALID_HANDLE_VALUE;
- m_hEvtQuit = INVALID_HANDLE_VALUE;
- m_hEvtSkip = INVALID_HANDLE_VALUE;
- m_bEvtQuit = 0;
- m_bEvtFlush = 0;
-
- if (FAILED (hr)) {
- _Error += L"SyncAP failed\n";
- return;
- }
-
- // Load EVR specifics DLLs
- hLib = LoadLibrary (L"dxva2.dll");
- pfDXVA2CreateDirect3DDeviceManager9 = hLib ? (PTR_DXVA2CreateDirect3DDeviceManager9) GetProcAddress (hLib, "DXVA2CreateDirect3DDeviceManager9") : NULL;
-
- // Load EVR functions
- hLib = LoadLibrary (L"evr.dll");
- pfMFCreateDXSurfaceBuffer = hLib ? (PTR_MFCreateDXSurfaceBuffer)GetProcAddress (hLib, "MFCreateDXSurfaceBuffer") : NULL;
- pfMFCreateVideoSampleFromSurface = hLib ? (PTR_MFCreateVideoSampleFromSurface)GetProcAddress (hLib, "MFCreateVideoSampleFromSurface") : NULL;
- pfMFCreateVideoMediaType = hLib ? (PTR_MFCreateVideoMediaType)GetProcAddress (hLib, "MFCreateVideoMediaType") : NULL;
-
- if (!pfDXVA2CreateDirect3DDeviceManager9 || !pfMFCreateDXSurfaceBuffer || !pfMFCreateVideoSampleFromSurface || !pfMFCreateVideoMediaType) {
- if (!pfDXVA2CreateDirect3DDeviceManager9) {
- _Error += L"Could not find DXVA2CreateDirect3DDeviceManager9 (dxva2.dll)\n";
- }
- if (!pfMFCreateDXSurfaceBuffer) {
- _Error += L"Could not find MFCreateDXSurfaceBuffer (evr.dll)\n";
- }
- if (!pfMFCreateVideoSampleFromSurface) {
- _Error += L"Could not find MFCreateVideoSampleFromSurface (evr.dll)\n";
- }
- if (!pfMFCreateVideoMediaType) {
- _Error += L"Could not find MFCreateVideoMediaType (evr.dll)\n";
- }
- hr = E_FAIL;
- return;
- }
-
- // Load Vista specific DLLs
- hLib = LoadLibrary (L"avrt.dll");
- pfAvSetMmThreadCharacteristicsW = hLib ? (PTR_AvSetMmThreadCharacteristicsW) GetProcAddress (hLib, "AvSetMmThreadCharacteristicsW") : NULL;
- pfAvSetMmThreadPriority = hLib ? (PTR_AvSetMmThreadPriority) GetProcAddress (hLib, "AvSetMmThreadPriority") : NULL;
- pfAvRevertMmThreadCharacteristics = hLib ? (PTR_AvRevertMmThreadCharacteristics) GetProcAddress (hLib, "AvRevertMmThreadCharacteristics") : NULL;
-
- // Init DXVA manager
- hr = pfDXVA2CreateDirect3DDeviceManager9(&m_nResetToken, &m_pD3DManager);
- if (SUCCEEDED (hr)) {
- hr = m_pD3DManager->ResetDevice(m_pD3DDev, m_nResetToken);
- if (!SUCCEEDED (hr)) {
- _Error += L"m_pD3DManager->ResetDevice failed\n";
- }
- } else {
- _Error += L"DXVA2CreateDirect3DDeviceManager9 failed\n";
- }
-
- CComPtr<IDirectXVideoDecoderService> pDecoderService;
- HANDLE hDevice;
- if (SUCCEEDED (m_pD3DManager->OpenDeviceHandle(&hDevice)) &&
- SUCCEEDED (m_pD3DManager->GetVideoService (hDevice, __uuidof(IDirectXVideoDecoderService), (void**)&pDecoderService))) {
- HookDirectXVideoDecoderService (pDecoderService);
- m_pD3DManager->CloseDeviceHandle (hDevice);
- }
-
- // Bufferize frame only with 3D texture
- if (s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) {
- m_nDXSurface = max(min (s.iEvrBuffers, MAX_PICTURE_SLOTS-2), 4);
- } else {
- m_nDXSurface = 1;
- }
-
- m_nRenderState = Shutdown;
- m_bStepping = false;
- m_bUseInternalTimer = false;
- m_LastSetOutputRange = -1;
- m_bPendingRenegotiate = false;
- m_bPendingMediaFinished = false;
- m_pCurrentDisplaydSample = NULL;
- m_nStepCount = 0;
- m_dwVideoAspectRatioMode = MFVideoARMode_PreservePicture;
- m_dwVideoRenderPrefs = (MFVideoRenderPrefs)0;
- m_BorderColor = RGB (0,0,0);
- m_pOuterEVR = NULL;
- m_bPrerolled = false;
- m_lShiftToNearest = -1; // Illegal value to start with
+ CAutoLock cRenderLock(&m_allocatorLock);
+
+ CAtlList<CExternalPixelShader>* pPixelShaders;
+ if (bScreenSpace) {
+ pPixelShaders = &m_pPixelShadersScreenSpace;
+ } else {
+ pPixelShaders = &m_pPixelShaders;
+ }
+
+ if (!pSrcData && !pTarget) {
+ pPixelShaders->RemoveAll();
+ m_pD3DDev->SetPixelShader(NULL);
+ return S_OK;
+ }
+
+ if (!pSrcData || !pTarget) {
+ return E_INVALIDARG;
+ }
+
+ CExternalPixelShader Shader;
+ Shader.m_SourceData = pSrcData;
+ Shader.m_SourceTarget = pTarget;
+
+ CComPtr<IDirect3DPixelShader9> pPixelShader;
+
+ HRESULT hr = Shader.Compile(m_pPSC);
+ if (FAILED(hr)) {
+ return hr;
+ }
+
+ pPixelShaders->AddTail(Shader);
+ Paint(true);
+ return S_OK;
+}
+
+CSyncAP::CSyncAP(HWND hWnd, bool bFullscreen, HRESULT& hr, CString& _Error): CBaseAP(hWnd, bFullscreen, hr, _Error)
+{
+ HMODULE hLib;
+ CRenderersSettings& s = GetRenderersSettings();
+
+ m_nResetToken = 0;
+ m_hRenderThread = INVALID_HANDLE_VALUE;
+ m_hMixerThread = INVALID_HANDLE_VALUE;
+ m_hEvtFlush = INVALID_HANDLE_VALUE;
+ m_hEvtQuit = INVALID_HANDLE_VALUE;
+ m_hEvtSkip = INVALID_HANDLE_VALUE;
+ m_bEvtQuit = 0;
+ m_bEvtFlush = 0;
+
+ if (FAILED(hr)) {
+ _Error += L"SyncAP failed\n";
+ return;
+ }
+
+ // Load EVR specifics DLLs
+ hLib = LoadLibrary(L"dxva2.dll");
+ pfDXVA2CreateDirect3DDeviceManager9 = hLib ? (PTR_DXVA2CreateDirect3DDeviceManager9) GetProcAddress(hLib, "DXVA2CreateDirect3DDeviceManager9") : NULL;
+
+ // Load EVR functions
+ hLib = LoadLibrary(L"evr.dll");
+ pfMFCreateDXSurfaceBuffer = hLib ? (PTR_MFCreateDXSurfaceBuffer)GetProcAddress(hLib, "MFCreateDXSurfaceBuffer") : NULL;
+ pfMFCreateVideoSampleFromSurface = hLib ? (PTR_MFCreateVideoSampleFromSurface)GetProcAddress(hLib, "MFCreateVideoSampleFromSurface") : NULL;
+ pfMFCreateVideoMediaType = hLib ? (PTR_MFCreateVideoMediaType)GetProcAddress(hLib, "MFCreateVideoMediaType") : NULL;
+
+ if (!pfDXVA2CreateDirect3DDeviceManager9 || !pfMFCreateDXSurfaceBuffer || !pfMFCreateVideoSampleFromSurface || !pfMFCreateVideoMediaType) {
+ if (!pfDXVA2CreateDirect3DDeviceManager9) {
+ _Error += L"Could not find DXVA2CreateDirect3DDeviceManager9 (dxva2.dll)\n";
+ }
+ if (!pfMFCreateDXSurfaceBuffer) {
+ _Error += L"Could not find MFCreateDXSurfaceBuffer (evr.dll)\n";
+ }
+ if (!pfMFCreateVideoSampleFromSurface) {
+ _Error += L"Could not find MFCreateVideoSampleFromSurface (evr.dll)\n";
+ }
+ if (!pfMFCreateVideoMediaType) {
+ _Error += L"Could not find MFCreateVideoMediaType (evr.dll)\n";
+ }
+ hr = E_FAIL;
+ return;
+ }
+
+ // Load Vista specific DLLs
+ hLib = LoadLibrary(L"avrt.dll");
+ pfAvSetMmThreadCharacteristicsW = hLib ? (PTR_AvSetMmThreadCharacteristicsW) GetProcAddress(hLib, "AvSetMmThreadCharacteristicsW") : NULL;
+ pfAvSetMmThreadPriority = hLib ? (PTR_AvSetMmThreadPriority) GetProcAddress(hLib, "AvSetMmThreadPriority") : NULL;
+ pfAvRevertMmThreadCharacteristics = hLib ? (PTR_AvRevertMmThreadCharacteristics) GetProcAddress(hLib, "AvRevertMmThreadCharacteristics") : NULL;
+
+ // Init DXVA manager
+ hr = pfDXVA2CreateDirect3DDeviceManager9(&m_nResetToken, &m_pD3DManager);
+ if (SUCCEEDED(hr)) {
+ hr = m_pD3DManager->ResetDevice(m_pD3DDev, m_nResetToken);
+ if (!SUCCEEDED(hr)) {
+ _Error += L"m_pD3DManager->ResetDevice failed\n";
+ }
+ } else {
+ _Error += L"DXVA2CreateDirect3DDeviceManager9 failed\n";
+ }
+
+ CComPtr<IDirectXVideoDecoderService> pDecoderService;
+ HANDLE hDevice;
+ if (SUCCEEDED(m_pD3DManager->OpenDeviceHandle(&hDevice)) &&
+ SUCCEEDED(m_pD3DManager->GetVideoService(hDevice, __uuidof(IDirectXVideoDecoderService), (void**)&pDecoderService))) {
+ HookDirectXVideoDecoderService(pDecoderService);
+ m_pD3DManager->CloseDeviceHandle(hDevice);
+ }
+
+ // Bufferize frame only with 3D texture
+ if (s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) {
+ m_nDXSurface = max(min(s.iEvrBuffers, MAX_PICTURE_SLOTS - 2), 4);
+ } else {
+ m_nDXSurface = 1;
+ }
+
+ m_nRenderState = Shutdown;
+ m_bStepping = false;
+ m_bUseInternalTimer = false;
+ m_LastSetOutputRange = -1;
+ m_bPendingRenegotiate = false;
+ m_bPendingMediaFinished = false;
+ m_pCurrentDisplaydSample = NULL;
+ m_nStepCount = 0;
+ m_dwVideoAspectRatioMode = MFVideoARMode_PreservePicture;
+ m_dwVideoRenderPrefs = (MFVideoRenderPrefs)0;
+ m_BorderColor = RGB(0, 0, 0);
+ m_pOuterEVR = NULL;
+ m_bPrerolled = false;
+ m_lShiftToNearest = -1; // Illegal value to start with
}
CSyncAP::~CSyncAP(void)
{
- StopWorkerThreads();
- m_pMediaType = NULL;
- m_pClock = NULL;
- m_pD3DManager = NULL;
+ StopWorkerThreads();
+ m_pMediaType = NULL;
+ m_pClock = NULL;
+ m_pD3DManager = NULL;
}
HRESULT CSyncAP::CheckShutdown() const
{
- if (m_nRenderState == Shutdown) {
- return MF_E_SHUTDOWN;
- } else {
- return S_OK;
- }
+ if (m_nRenderState == Shutdown) {
+ return MF_E_SHUTDOWN;
+ } else {
+ return S_OK;
+ }
}
void CSyncAP::StartWorkerThreads()
{
- DWORD dwThreadId;
- if (m_nRenderState == Shutdown) {
- m_hEvtQuit = CreateEvent(NULL, TRUE, FALSE, NULL);
- m_hEvtFlush = CreateEvent(NULL, TRUE, FALSE, NULL);
- m_hEvtSkip = CreateEvent(NULL, TRUE, FALSE, NULL);
- m_hMixerThread = ::CreateThread(NULL, 0, MixerThreadStatic, (LPVOID)this, 0, &dwThreadId);
- SetThreadPriority(m_hMixerThread, THREAD_PRIORITY_HIGHEST);
- m_hRenderThread = ::CreateThread(NULL, 0, RenderThreadStatic, (LPVOID)this, 0, &dwThreadId);
- SetThreadPriority(m_hRenderThread, THREAD_PRIORITY_TIME_CRITICAL);
- m_nRenderState = Stopped;
- }
+ DWORD dwThreadId;
+ if (m_nRenderState == Shutdown) {
+ m_hEvtQuit = CreateEvent(NULL, TRUE, FALSE, NULL);
+ m_hEvtFlush = CreateEvent(NULL, TRUE, FALSE, NULL);
+ m_hEvtSkip = CreateEvent(NULL, TRUE, FALSE, NULL);
+ m_hMixerThread = ::CreateThread(NULL, 0, MixerThreadStatic, (LPVOID)this, 0, &dwThreadId);
+ SetThreadPriority(m_hMixerThread, THREAD_PRIORITY_HIGHEST);
+ m_hRenderThread = ::CreateThread(NULL, 0, RenderThreadStatic, (LPVOID)this, 0, &dwThreadId);
+ SetThreadPriority(m_hRenderThread, THREAD_PRIORITY_TIME_CRITICAL);
+ m_nRenderState = Stopped;
+ }
}
void CSyncAP::StopWorkerThreads()
{
- if (m_nRenderState != Shutdown) {
- SetEvent(m_hEvtFlush);
- m_bEvtFlush = true;
- SetEvent(m_hEvtQuit);
- m_bEvtQuit = true;
- SetEvent(m_hEvtSkip);
- m_bEvtSkip = true;
- if ((m_hRenderThread != INVALID_HANDLE_VALUE) && (WaitForSingleObject (m_hRenderThread, 10000) == WAIT_TIMEOUT)) {
- ASSERT (FALSE);
- TerminateThread (m_hRenderThread, 0xDEAD);
- }
- if (m_hRenderThread != INVALID_HANDLE_VALUE) {
- CloseHandle (m_hRenderThread);
- }
- if ((m_hMixerThread != INVALID_HANDLE_VALUE) && (WaitForSingleObject (m_hMixerThread, 10000) == WAIT_TIMEOUT)) {
- ASSERT (FALSE);
- TerminateThread (m_hMixerThread, 0xDEAD);
- }
- if (m_hMixerThread != INVALID_HANDLE_VALUE) {
- CloseHandle (m_hMixerThread);
- }
-
- if (m_hEvtFlush != INVALID_HANDLE_VALUE) {
- CloseHandle(m_hEvtFlush);
- }
- if (m_hEvtQuit != INVALID_HANDLE_VALUE) {
- CloseHandle(m_hEvtQuit);
- }
- if (m_hEvtSkip != INVALID_HANDLE_VALUE) {
- CloseHandle(m_hEvtSkip);
- }
-
- m_bEvtFlush = false;
- m_bEvtQuit = false;
- m_bEvtSkip = false;
- }
- m_nRenderState = Shutdown;
+ if (m_nRenderState != Shutdown) {
+ SetEvent(m_hEvtFlush);
+ m_bEvtFlush = true;
+ SetEvent(m_hEvtQuit);
+ m_bEvtQuit = true;
+ SetEvent(m_hEvtSkip);
+ m_bEvtSkip = true;
+ if ((m_hRenderThread != INVALID_HANDLE_VALUE) && (WaitForSingleObject(m_hRenderThread, 10000) == WAIT_TIMEOUT)) {
+ ASSERT(FALSE);
+ TerminateThread(m_hRenderThread, 0xDEAD);
+ }
+ if (m_hRenderThread != INVALID_HANDLE_VALUE) {
+ CloseHandle(m_hRenderThread);
+ }
+ if ((m_hMixerThread != INVALID_HANDLE_VALUE) && (WaitForSingleObject(m_hMixerThread, 10000) == WAIT_TIMEOUT)) {
+ ASSERT(FALSE);
+ TerminateThread(m_hMixerThread, 0xDEAD);
+ }
+ if (m_hMixerThread != INVALID_HANDLE_VALUE) {
+ CloseHandle(m_hMixerThread);
+ }
+
+ if (m_hEvtFlush != INVALID_HANDLE_VALUE) {
+ CloseHandle(m_hEvtFlush);
+ }
+ if (m_hEvtQuit != INVALID_HANDLE_VALUE) {
+ CloseHandle(m_hEvtQuit);
+ }
+ if (m_hEvtSkip != INVALID_HANDLE_VALUE) {
+ CloseHandle(m_hEvtSkip);
+ }
+
+ m_bEvtFlush = false;
+ m_bEvtQuit = false;
+ m_bEvtSkip = false;
+ }
+ m_nRenderState = Shutdown;
}
STDMETHODIMP CSyncAP::CreateRenderer(IUnknown** ppRenderer)
{
- CheckPointer(ppRenderer, E_POINTER);
- *ppRenderer = NULL;
- HRESULT hr = E_FAIL;
+ CheckPointer(ppRenderer, E_POINTER);
+ *ppRenderer = NULL;
+ HRESULT hr = E_FAIL;
- do {
- CMacrovisionKicker* pMK = DNew CMacrovisionKicker(NAME("CMacrovisionKicker"), NULL);
- CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)pMK;
+ do {
+ CMacrovisionKicker* pMK = DNew CMacrovisionKicker(NAME("CMacrovisionKicker"), NULL);
+ CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)pMK;
- CSyncRenderer *pOuterEVR = DNew CSyncRenderer(NAME("CSyncRenderer"), pUnk, hr, &m_VMR9AlphaBitmap, this);
- m_pOuterEVR = pOuterEVR;
+ CSyncRenderer* pOuterEVR = DNew CSyncRenderer(NAME("CSyncRenderer"), pUnk, hr, &m_VMR9AlphaBitmap, this);
+ m_pOuterEVR = pOuterEVR;
- pMK->SetInner((IUnknown*)(INonDelegatingUnknown*)pOuterEVR);
- CComQIPtr<IBaseFilter> pBF = pUnk;
+ pMK->SetInner((IUnknown*)(INonDelegatingUnknown*)pOuterEVR);
+ CComQIPtr<IBaseFilter> pBF = pUnk;
- if (FAILED(hr)) {
- break;
- }
+ if (FAILED(hr)) {
+ break;
+ }
- // Set EVR custom presenter
- CComPtr<IMFVideoPresenter> pVP;
- CComPtr<IMFVideoRenderer> pMFVR;
- CComQIPtr<IMFGetService, &__uuidof(IMFGetService)> pMFGS = pBF;
- CComQIPtr<IEVRFilterConfig> pConfig = pBF;
- if (SUCCEEDED(hr)) {
- if (FAILED(pConfig->SetNumberOfStreams(3))) { // TODO - maybe need other number of input stream ...
- break;
- }
- }
+ // Set EVR custom presenter
+ CComPtr<IMFVideoPresenter> pVP;
+ CComPtr<IMFVideoRenderer> pMFVR;
+ CComQIPtr<IMFGetService, &__uuidof(IMFGetService)> pMFGS = pBF;
+ CComQIPtr<IEVRFilterConfig> pConfig = pBF;
+ if (SUCCEEDED(hr)) {
+ if (FAILED(pConfig->SetNumberOfStreams(3))) { // TODO - maybe need other number of input stream ...
+ break;
+ }
+ }
- hr = pMFGS->GetService (MR_VIDEO_RENDER_SERVICE, IID_IMFVideoRenderer, (void**)&pMFVR);
+ hr = pMFGS->GetService(MR_VIDEO_RENDER_SERVICE, IID_IMFVideoRenderer, (void**)&pMFVR);
- if (SUCCEEDED(hr)) {
- hr = QueryInterface(__uuidof(IMFVideoPresenter), (void**)&pVP);
- }
- if (SUCCEEDED(hr)) {
- hr = pMFVR->InitializeRenderer(NULL, pVP);
- }
+ if (SUCCEEDED(hr)) {
+ hr = QueryInterface(__uuidof(IMFVideoPresenter), (void**)&pVP);
+ }
+ if (SUCCEEDED(hr)) {
+ hr = pMFVR->InitializeRenderer(NULL, pVP);
+ }
- CComPtr<IPin> pPin = GetFirstPin(pBF);
- CComQIPtr<IMemInputPin> pMemInputPin = pPin;
+ CComPtr<IPin> pPin = GetFirstPin(pBF);
+ CComQIPtr<IMemInputPin> pMemInputPin = pPin;
- m_bUseInternalTimer = HookNewSegmentAndReceive((IPinC*)(IPin*)pPin, (IMemInputPinC*)(IMemInputPin*)pMemInputPin);
- if (FAILED(hr)) {
- *ppRenderer = NULL;
- } else {
- *ppRenderer = pBF.Detach();
- }
- } while (0);
+ m_bUseInternalTimer = HookNewSegmentAndReceive((IPinC*)(IPin*)pPin, (IMemInputPinC*)(IMemInputPin*)pMemInputPin);
+ if (FAILED(hr)) {
+ *ppRenderer = NULL;
+ } else {
+ *ppRenderer = pBF.Detach();
+ }
+ } while (0);
- return hr;
+ return hr;
}
STDMETHODIMP_(bool) CSyncAP::Paint(bool fAll)
{
- return __super::Paint(fAll);
+ return __super::Paint(fAll);
}
STDMETHODIMP CSyncAP::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- HRESULT hr;
- if (riid == __uuidof(IMFClockStateSink)) {
- hr = GetInterface((IMFClockStateSink*)this, ppv);
- } else if (riid == __uuidof(IMFVideoPresenter)) {
- hr = GetInterface((IMFVideoPresenter*)this, ppv);
- } else if (riid == __uuidof(IMFTopologyServiceLookupClient)) {
- hr = GetInterface((IMFTopologyServiceLookupClient*)this, ppv);
- } else if (riid == __uuidof(IMFVideoDeviceID)) {
- hr = GetInterface((IMFVideoDeviceID*)this, ppv);
- } else if (riid == __uuidof(IMFGetService)) {
- hr = GetInterface((IMFGetService*)this, ppv);
- } else if (riid == __uuidof(IMFAsyncCallback)) {
- hr = GetInterface((IMFAsyncCallback*)this, ppv);
- } else if (riid == __uuidof(IMFVideoDisplayControl)) {
- hr = GetInterface((IMFVideoDisplayControl*)this, ppv);
- } else if (riid == __uuidof(IEVRTrustedVideoPlugin)) {
- hr = GetInterface((IEVRTrustedVideoPlugin*)this, ppv);
- } else if (riid == IID_IQualProp) {
- hr = GetInterface((IQualProp*)this, ppv);
- } else if (riid == __uuidof(IMFRateSupport)) {
- hr = GetInterface((IMFRateSupport*)this, ppv);
- } else if (riid == __uuidof(IDirect3DDeviceManager9)) {
- hr = m_pD3DManager->QueryInterface (__uuidof(IDirect3DDeviceManager9), (void**) ppv);
- } else if (riid == __uuidof(ISyncClockAdviser)) {
- hr = GetInterface((ISyncClockAdviser*)this, ppv);
- } else {
- hr = __super::NonDelegatingQueryInterface(riid, ppv);
- }
-
- return hr;
+ HRESULT hr;
+ if (riid == __uuidof(IMFClockStateSink)) {
+ hr = GetInterface((IMFClockStateSink*)this, ppv);
+ } else if (riid == __uuidof(IMFVideoPresenter)) {
+ hr = GetInterface((IMFVideoPresenter*)this, ppv);
+ } else if (riid == __uuidof(IMFTopologyServiceLookupClient)) {
+ hr = GetInterface((IMFTopologyServiceLookupClient*)this, ppv);
+ } else if (riid == __uuidof(IMFVideoDeviceID)) {
+ hr = GetInterface((IMFVideoDeviceID*)this, ppv);
+ } else if (riid == __uuidof(IMFGetService)) {
+ hr = GetInterface((IMFGetService*)this, ppv);
+ } else if (riid == __uuidof(IMFAsyncCallback)) {
+ hr = GetInterface((IMFAsyncCallback*)this, ppv);
+ } else if (riid == __uuidof(IMFVideoDisplayControl)) {
+ hr = GetInterface((IMFVideoDisplayControl*)this, ppv);
+ } else if (riid == __uuidof(IEVRTrustedVideoPlugin)) {
+ hr = GetInterface((IEVRTrustedVideoPlugin*)this, ppv);
+ } else if (riid == IID_IQualProp) {
+ hr = GetInterface((IQualProp*)this, ppv);
+ } else if (riid == __uuidof(IMFRateSupport)) {
+ hr = GetInterface((IMFRateSupport*)this, ppv);
+ } else if (riid == __uuidof(IDirect3DDeviceManager9)) {
+ hr = m_pD3DManager->QueryInterface(__uuidof(IDirect3DDeviceManager9), (void**) ppv);
+ } else if (riid == __uuidof(ISyncClockAdviser)) {
+ hr = GetInterface((ISyncClockAdviser*)this, ppv);
+ } else {
+ hr = __super::NonDelegatingQueryInterface(riid, ppv);
+ }
+
+ return hr;
}
// IMFClockStateSink
STDMETHODIMP CSyncAP::OnClockStart(MFTIME hnsSystemTime, LONGLONG llClockStartOffset)
{
- m_nRenderState = Started;
- return S_OK;
+ m_nRenderState = Started;
+ return S_OK;
}
STDMETHODIMP CSyncAP::OnClockStop(MFTIME hnsSystemTime)
{
- m_nRenderState = Stopped;
- return S_OK;
+ m_nRenderState = Stopped;
+ return S_OK;
}
STDMETHODIMP CSyncAP::OnClockPause(MFTIME hnsSystemTime)
{
- m_nRenderState = Paused;
- return S_OK;
+ m_nRenderState = Paused;
+ return S_OK;
}
STDMETHODIMP CSyncAP::OnClockRestart(MFTIME hnsSystemTime)
{
- m_nRenderState = Started;
- return S_OK;
+ m_nRenderState = Started;
+ return S_OK;
}
STDMETHODIMP CSyncAP::OnClockSetRate(MFTIME hnsSystemTime, float flRate)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IBaseFilter delegate
-bool CSyncAP::GetState(DWORD dwMilliSecsTimeout, FILTER_STATE *State, HRESULT &_ReturnValue)
-{
- CAutoLock lock(&m_SampleQueueLock);
- switch (m_nRenderState) {
- case Started:
- *State = State_Running;
- break;
- case Paused:
- *State = State_Paused;
- break;
- case Stopped:
- *State = State_Stopped;
- break;
- default:
- *State = State_Stopped;
- _ReturnValue = E_FAIL;
- }
- _ReturnValue = S_OK;
- return true;
+bool CSyncAP::GetState(DWORD dwMilliSecsTimeout, FILTER_STATE* State, HRESULT& _ReturnValue)
+{
+ CAutoLock lock(&m_SampleQueueLock);
+ switch (m_nRenderState) {
+ case Started:
+ *State = State_Running;
+ break;
+ case Paused:
+ *State = State_Paused;
+ break;
+ case Stopped:
+ *State = State_Stopped;
+ break;
+ default:
+ *State = State_Stopped;
+ _ReturnValue = E_FAIL;
+ }
+ _ReturnValue = S_OK;
+ return true;
}
// IQualProp
-STDMETHODIMP CSyncAP::get_FramesDroppedInRenderer(int *pcFrames)
+STDMETHODIMP CSyncAP::get_FramesDroppedInRenderer(int* pcFrames)
{
- *pcFrames = m_pcFramesDropped;
- return S_OK;
+ *pcFrames = m_pcFramesDropped;
+ return S_OK;
}
-STDMETHODIMP CSyncAP::get_FramesDrawn(int *pcFramesDrawn)
+STDMETHODIMP CSyncAP::get_FramesDrawn(int* pcFramesDrawn)
{
- *pcFramesDrawn = m_pcFramesDrawn;
- return S_OK;
+ *pcFramesDrawn = m_pcFramesDrawn;
+ return S_OK;
}
-STDMETHODIMP CSyncAP::get_AvgFrameRate(int *piAvgFrameRate)
+STDMETHODIMP CSyncAP::get_AvgFrameRate(int* piAvgFrameRate)
{
- *piAvgFrameRate = (int)(m_fAvrFps * 100);
- return S_OK;
+ *piAvgFrameRate = (int)(m_fAvrFps * 100);
+ return S_OK;
}
-STDMETHODIMP CSyncAP::get_Jitter(int *iJitter)
+STDMETHODIMP CSyncAP::get_Jitter(int* iJitter)
{
- *iJitter = (int)((m_fJitterStdDev/10000.0) + 0.5);
- return S_OK;
+ *iJitter = (int)((m_fJitterStdDev / 10000.0) + 0.5);
+ return S_OK;
}
-STDMETHODIMP CSyncAP::get_AvgSyncOffset(int *piAvg)
+STDMETHODIMP CSyncAP::get_AvgSyncOffset(int* piAvg)
{
- *piAvg = (int)((m_fSyncOffsetAvr/10000.0) + 0.5);
- return S_OK;
+ *piAvg = (int)((m_fSyncOffsetAvr / 10000.0) + 0.5);
+ return S_OK;
}
-STDMETHODIMP CSyncAP::get_DevSyncOffset(int *piDev)
+STDMETHODIMP CSyncAP::get_DevSyncOffset(int* piDev)
{
- *piDev = (int)((m_fSyncOffsetStdDev/10000.0) + 0.5);
- return S_OK;
+ *piDev = (int)((m_fSyncOffsetStdDev / 10000.0) + 0.5);
+ return S_OK;
}
// IMFRateSupport
-STDMETHODIMP CSyncAP::GetSlowestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float *pflRate)
+STDMETHODIMP CSyncAP::GetSlowestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float* pflRate)
{
- *pflRate = 0;
- return S_OK;
+ *pflRate = 0;
+ return S_OK;
}
-STDMETHODIMP CSyncAP::GetFastestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float *pflRate)
+STDMETHODIMP CSyncAP::GetFastestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float* pflRate)
{
- HRESULT hr = S_OK;
- float fMaxRate = 0.0f;
+ HRESULT hr = S_OK;
+ float fMaxRate = 0.0f;
- CAutoLock lock(this);
+ CAutoLock lock(this);
- CheckPointer(pflRate, E_POINTER);
- CheckHR(CheckShutdown());
+ CheckPointer(pflRate, E_POINTER);
+ CheckHR(CheckShutdown());
- // Get the maximum forward rate.
- fMaxRate = GetMaxRate(fThin);
+ // Get the maximum forward rate.
+ fMaxRate = GetMaxRate(fThin);
- // For reverse playback, swap the sign.
- if (eDirection == MFRATE_REVERSE) {
- fMaxRate = -fMaxRate;
- }
+ // For reverse playback, swap the sign.
+ if (eDirection == MFRATE_REVERSE) {
+ fMaxRate = -fMaxRate;
+ }
- *pflRate = fMaxRate;
- return hr;
+ *pflRate = fMaxRate;
+ return hr;
}
-STDMETHODIMP CSyncAP::IsRateSupported(BOOL fThin, float flRate, float *pflNearestSupportedRate)
+STDMETHODIMP CSyncAP::IsRateSupported(BOOL fThin, float flRate, float* pflNearestSupportedRate)
{
- // fRate can be negative for reverse playback.
- // pfNearestSupportedRate can be NULL.
- CAutoLock lock(this);
- HRESULT hr = S_OK;
- float fMaxRate = 0.0f;
- float fNearestRate = flRate; // Default.
+ // fRate can be negative for reverse playback.
+ // pfNearestSupportedRate can be NULL.
+ CAutoLock lock(this);
+ HRESULT hr = S_OK;
+ float fMaxRate = 0.0f;
+ float fNearestRate = flRate; // Default.
- CheckPointer (pflNearestSupportedRate, E_POINTER);
- CheckHR(hr = CheckShutdown());
+ CheckPointer(pflNearestSupportedRate, E_POINTER);
+ CheckHR(hr = CheckShutdown());
- // Find the maximum forward rate.
- fMaxRate = GetMaxRate(fThin);
+ // Find the maximum forward rate.
+ fMaxRate = GetMaxRate(fThin);
- if (fabsf(flRate) > fMaxRate) {
- // The (absolute) requested rate exceeds the maximum rate.
- hr = MF_E_UNSUPPORTED_RATE;
+ if (fabsf(flRate) > fMaxRate) {
+ // The (absolute) requested rate exceeds the maximum rate.
+ hr = MF_E_UNSUPPORTED_RATE;
- // The nearest supported rate is fMaxRate.
- fNearestRate = fMaxRate;
- if (flRate < 0) {
- // For reverse playback, swap the sign.
- fNearestRate = -fNearestRate;
- }
- }
- // Return the nearest supported rate if the caller requested it.
- if (pflNearestSupportedRate != NULL) {
- *pflNearestSupportedRate = fNearestRate;
- }
- return hr;
+ // The nearest supported rate is fMaxRate.
+ fNearestRate = fMaxRate;
+ if (flRate < 0) {
+ // For reverse playback, swap the sign.
+ fNearestRate = -fNearestRate;
+ }
+ }
+ // Return the nearest supported rate if the caller requested it.
+ if (pflNearestSupportedRate != NULL) {
+ *pflNearestSupportedRate = fNearestRate;
+ }
+ return hr;
}
float CSyncAP::GetMaxRate(BOOL bThin)
{
- float fMaxRate = FLT_MAX; // Default.
- UINT32 fpsNumerator = 0, fpsDenominator = 0;
- UINT MonitorRateHz = 0;
+ float fMaxRate = FLT_MAX; // Default.
+ UINT32 fpsNumerator = 0, fpsDenominator = 0;
+ UINT MonitorRateHz = 0;
- if (!bThin && (m_pMediaType != NULL)) {
- // Non-thinned: Use the frame rate and monitor refresh rate.
+ if (!bThin && (m_pMediaType != NULL)) {
+ // Non-thinned: Use the frame rate and monitor refresh rate.
- // Frame rate:
- MFGetAttributeRatio(m_pMediaType, MF_MT_FRAME_RATE,
- &fpsNumerator, &fpsDenominator);
+ // Frame rate:
+ MFGetAttributeRatio(m_pMediaType, MF_MT_FRAME_RATE,
+ &fpsNumerator, &fpsDenominator);
- // Monitor refresh rate:
- MonitorRateHz = m_uD3DRefreshRate; // D3DDISPLAYMODE
+ // Monitor refresh rate:
+ MonitorRateHz = m_uD3DRefreshRate; // D3DDISPLAYMODE
- if (fpsDenominator && fpsNumerator && MonitorRateHz) {
- // Max Rate = Refresh Rate / Frame Rate
- fMaxRate = (float)MulDiv(MonitorRateHz, fpsDenominator, fpsNumerator);
- }
- }
- return fMaxRate;
+ if (fpsDenominator && fpsNumerator && MonitorRateHz) {
+ // Max Rate = Refresh Rate / Frame Rate
+ fMaxRate = (float)MulDiv(MonitorRateHz, fpsDenominator, fpsNumerator);
+ }
+ }
+ return fMaxRate;
}
void CSyncAP::CompleteFrameStep(bool bCancel)
{
- if (m_nStepCount > 0) {
- if (bCancel || (m_nStepCount == 1)) {
- m_pSink->Notify(EC_STEP_COMPLETE, bCancel ? TRUE : FALSE, 0);
- m_nStepCount = 0;
- } else {
- m_nStepCount--;
- }
- }
+ if (m_nStepCount > 0) {
+ if (bCancel || (m_nStepCount == 1)) {
+ m_pSink->Notify(EC_STEP_COMPLETE, bCancel ? TRUE : FALSE, 0);
+ m_nStepCount = 0;
+ } else {
+ m_nStepCount--;
+ }
+ }
}
// IMFVideoPresenter
STDMETHODIMP CSyncAP::ProcessMessage(MFVP_MESSAGE_TYPE eMessage, ULONG_PTR ulParam)
{
- HRESULT hr = S_OK;
-
- switch (eMessage) {
- case MFVP_MESSAGE_BEGINSTREAMING:
- hr = BeginStreaming();
- m_llHysteresis = 0;
- m_lShiftToNearest = 0;
- m_bStepping = false;
- break;
-
- case MFVP_MESSAGE_CANCELSTEP:
- m_bStepping = false;
- CompleteFrameStep(true);
- break;
-
- case MFVP_MESSAGE_ENDOFSTREAM:
- m_bPendingMediaFinished = true;
- break;
-
- case MFVP_MESSAGE_ENDSTREAMING:
- m_pGenlock->ResetTiming();
- m_pRefClock = NULL;
- break;
-
- case MFVP_MESSAGE_FLUSH:
- SetEvent(m_hEvtFlush);
- m_bEvtFlush = true;
- while (WaitForSingleObject(m_hEvtFlush, 1) == WAIT_OBJECT_0) {
- ;
- }
- break;
-
- case MFVP_MESSAGE_INVALIDATEMEDIATYPE:
- m_bPendingRenegotiate = true;
- while (*((volatile bool *)&m_bPendingRenegotiate)) {
- Sleep(1);
- }
- break;
-
- case MFVP_MESSAGE_PROCESSINPUTNOTIFY:
- break;
-
- case MFVP_MESSAGE_STEP:
- m_nStepCount = (int)ulParam;
- m_bStepping = true;
- break;
-
- default :
- ASSERT(FALSE);
- break;
- }
- return hr;
+ HRESULT hr = S_OK;
+
+ switch (eMessage) {
+ case MFVP_MESSAGE_BEGINSTREAMING:
+ hr = BeginStreaming();
+ m_llHysteresis = 0;
+ m_lShiftToNearest = 0;
+ m_bStepping = false;
+ break;
+
+ case MFVP_MESSAGE_CANCELSTEP:
+ m_bStepping = false;
+ CompleteFrameStep(true);
+ break;
+
+ case MFVP_MESSAGE_ENDOFSTREAM:
+ m_bPendingMediaFinished = true;
+ break;
+
+ case MFVP_MESSAGE_ENDSTREAMING:
+ m_pGenlock->ResetTiming();
+ m_pRefClock = NULL;
+ break;
+
+ case MFVP_MESSAGE_FLUSH:
+ SetEvent(m_hEvtFlush);
+ m_bEvtFlush = true;
+ while (WaitForSingleObject(m_hEvtFlush, 1) == WAIT_OBJECT_0) {
+ ;
+ }
+ break;
+
+ case MFVP_MESSAGE_INVALIDATEMEDIATYPE:
+ m_bPendingRenegotiate = true;
+ while (*((volatile bool*)&m_bPendingRenegotiate)) {
+ Sleep(1);
+ }
+ break;
+
+ case MFVP_MESSAGE_PROCESSINPUTNOTIFY:
+ break;
+
+ case MFVP_MESSAGE_STEP:
+ m_nStepCount = (int)ulParam;
+ m_bStepping = true;
+ break;
+
+ default :
+ ASSERT(FALSE);
+ break;
+ }
+ return hr;
}
HRESULT CSyncAP::IsMediaTypeSupported(IMFMediaType* pMixerType)
{
- HRESULT hr;
- AM_MEDIA_TYPE* pAMMedia;
- UINT nInterlaceMode;
+ HRESULT hr;
+ AM_MEDIA_TYPE* pAMMedia;
+ UINT nInterlaceMode;
- CheckHR (pMixerType->GetRepresentation(FORMAT_VideoInfo2, (void**)&pAMMedia));
- CheckHR (pMixerType->GetUINT32 (MF_MT_INTERLACE_MODE, &nInterlaceMode));
+ CheckHR(pMixerType->GetRepresentation(FORMAT_VideoInfo2, (void**)&pAMMedia));
+ CheckHR(pMixerType->GetUINT32(MF_MT_INTERLACE_MODE, &nInterlaceMode));
- if ( (pAMMedia->majortype != MEDIATYPE_Video)) {
- hr = MF_E_INVALIDMEDIATYPE;
- }
- pMixerType->FreeRepresentation(FORMAT_VideoInfo2, (void*)pAMMedia);
- return hr;
+ if ((pAMMedia->majortype != MEDIATYPE_Video)) {
+ hr = MF_E_INVALIDMEDIATYPE;
+ }
+ pMixerType->FreeRepresentation(FORMAT_VideoInfo2, (void*)pAMMedia);
+ return hr;
}
HRESULT CSyncAP::CreateProposedOutputType(IMFMediaType* pMixerType, IMFMediaType** pType)
{
- HRESULT hr;
- AM_MEDIA_TYPE *pAMMedia = NULL;
- LARGE_INTEGER i64Size;
- MFVIDEOFORMAT *VideoFormat;
-
- CheckHR(pMixerType->GetRepresentation(FORMAT_MFVideoFormat, (void**)&pAMMedia));
-
- VideoFormat = (MFVIDEOFORMAT*)pAMMedia->pbFormat;
- hr = pfMFCreateVideoMediaType(VideoFormat, &m_pMediaType);
-
- m_AspectRatio.cx = VideoFormat->videoInfo.PixelAspectRatio.Numerator;
- m_AspectRatio.cy = VideoFormat->videoInfo.PixelAspectRatio.Denominator;
-
- if (SUCCEEDED (hr)) {
- i64Size.HighPart = VideoFormat->videoInfo.dwWidth;
- i64Size.LowPart = VideoFormat->videoInfo.dwHeight;
- m_pMediaType->SetUINT64(MF_MT_FRAME_SIZE, i64Size.QuadPart);
- m_pMediaType->SetUINT32(MF_MT_PAN_SCAN_ENABLED, 0);
- CRenderersSettings& s = GetRenderersSettings();
-
- if (s.m_RenderSettings.iEVROutputRange == 1) {
- m_pMediaType->SetUINT32(MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_16_235);
- } else {
- m_pMediaType->SetUINT32(MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_0_255);
- }
-
- m_LastSetOutputRange = s.m_RenderSettings.iEVROutputRange;
- i64Size.HighPart = m_AspectRatio.cx;
- i64Size.LowPart = m_AspectRatio.cy;
- m_pMediaType->SetUINT64(MF_MT_PIXEL_ASPECT_RATIO, i64Size.QuadPart);
-
- MFVideoArea Area = GetArea(0, 0, VideoFormat->videoInfo.dwWidth, VideoFormat->videoInfo.dwHeight);
- m_pMediaType->SetBlob(MF_MT_GEOMETRIC_APERTURE, (UINT8*)&Area, sizeof(MFVideoArea));
- }
-
- m_AspectRatio.cx *= VideoFormat->videoInfo.dwWidth;
- m_AspectRatio.cy *= VideoFormat->videoInfo.dwHeight;
-
- bool bDoneSomething = true;
-
- if (m_AspectRatio.cx >= 1 && m_AspectRatio.cy >= 1) {
- while (bDoneSomething) {
- bDoneSomething = false;
- INT MinNum = min(m_AspectRatio.cx, m_AspectRatio.cy);
- INT i;
- for (i = 2; i < MinNum+1; ++i) {
- if (m_AspectRatio.cx%i == 0 && m_AspectRatio.cy%i ==0) {
- break;
- }
- }
- if (i != MinNum + 1) {
- m_AspectRatio.cx = m_AspectRatio.cx / i;
- m_AspectRatio.cy = m_AspectRatio.cy / i;
- bDoneSomething = true;
- }
- }
- }
-
- pMixerType->FreeRepresentation(FORMAT_MFVideoFormat, (void*)pAMMedia);
- m_pMediaType->QueryInterface(__uuidof(IMFMediaType), (void**) pType);
-
- return hr;
+ HRESULT hr;
+ AM_MEDIA_TYPE* pAMMedia = NULL;
+ LARGE_INTEGER i64Size;
+ MFVIDEOFORMAT* VideoFormat;
+
+ CheckHR(pMixerType->GetRepresentation(FORMAT_MFVideoFormat, (void**)&pAMMedia));
+
+ VideoFormat = (MFVIDEOFORMAT*)pAMMedia->pbFormat;
+ hr = pfMFCreateVideoMediaType(VideoFormat, &m_pMediaType);
+
+ m_AspectRatio.cx = VideoFormat->videoInfo.PixelAspectRatio.Numerator;
+ m_AspectRatio.cy = VideoFormat->videoInfo.PixelAspectRatio.Denominator;
+
+ if (SUCCEEDED(hr)) {
+ i64Size.HighPart = VideoFormat->videoInfo.dwWidth;
+ i64Size.LowPart = VideoFormat->videoInfo.dwHeight;
+ m_pMediaType->SetUINT64(MF_MT_FRAME_SIZE, i64Size.QuadPart);
+ m_pMediaType->SetUINT32(MF_MT_PAN_SCAN_ENABLED, 0);
+ CRenderersSettings& s = GetRenderersSettings();
+
+ if (s.m_RenderSettings.iEVROutputRange == 1) {
+ m_pMediaType->SetUINT32(MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_16_235);
+ } else {
+ m_pMediaType->SetUINT32(MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_0_255);
+ }
+
+ m_LastSetOutputRange = s.m_RenderSettings.iEVROutputRange;
+ i64Size.HighPart = m_AspectRatio.cx;
+ i64Size.LowPart = m_AspectRatio.cy;
+ m_pMediaType->SetUINT64(MF_MT_PIXEL_ASPECT_RATIO, i64Size.QuadPart);
+
+ MFVideoArea Area = GetArea(0, 0, VideoFormat->videoInfo.dwWidth, VideoFormat->videoInfo.dwHeight);
+ m_pMediaType->SetBlob(MF_MT_GEOMETRIC_APERTURE, (UINT8*)&Area, sizeof(MFVideoArea));
+ }
+
+ m_AspectRatio.cx *= VideoFormat->videoInfo.dwWidth;
+ m_AspectRatio.cy *= VideoFormat->videoInfo.dwHeight;
+
+ bool bDoneSomething = true;
+
+ if (m_AspectRatio.cx >= 1 && m_AspectRatio.cy >= 1) {
+ while (bDoneSomething) {
+ bDoneSomething = false;
+ INT MinNum = min(m_AspectRatio.cx, m_AspectRatio.cy);
+ INT i;
+ for (i = 2; i < MinNum + 1; ++i) {
+ if (m_AspectRatio.cx % i == 0 && m_AspectRatio.cy % i == 0) {
+ break;
+ }
+ }
+ if (i != MinNum + 1) {
+ m_AspectRatio.cx = m_AspectRatio.cx / i;
+ m_AspectRatio.cy = m_AspectRatio.cy / i;
+ bDoneSomething = true;
+ }
+ }
+ }
+
+ pMixerType->FreeRepresentation(FORMAT_MFVideoFormat, (void*)pAMMedia);
+ m_pMediaType->QueryInterface(__uuidof(IMFMediaType), (void**) pType);
+
+ return hr;
}
HRESULT CSyncAP::SetMediaType(IMFMediaType* pType)
{
- HRESULT hr;
- AM_MEDIA_TYPE* pAMMedia = NULL;
- CString strTemp;
+ HRESULT hr;
+ AM_MEDIA_TYPE* pAMMedia = NULL;
+ CString strTemp;
- CheckPointer(pType, E_POINTER);
- CheckHR(pType->GetRepresentation(FORMAT_VideoInfo2, (void**)&pAMMedia));
+ CheckPointer(pType, E_POINTER);
+ CheckHR(pType->GetRepresentation(FORMAT_VideoInfo2, (void**)&pAMMedia));
- hr = InitializeDevice(pAMMedia);
- if (SUCCEEDED(hr)) {
- strTemp = GetMediaTypeName(pAMMedia->subtype);
- strTemp.Replace(L"MEDIASUBTYPE_", L"");
- m_strStatsMsg[MSG_MIXEROUT].Format (L"Mixer output : %s", strTemp);
- }
+ hr = InitializeDevice(pAMMedia);
+ if (SUCCEEDED(hr)) {
+ strTemp = GetMediaTypeName(pAMMedia->subtype);
+ strTemp.Replace(L"MEDIASUBTYPE_", L"");
+ m_strStatsMsg[MSG_MIXEROUT].Format(L"Mixer output : %s", strTemp);
+ }
- pType->FreeRepresentation(FORMAT_VideoInfo2, (void*)pAMMedia);
+ pType->FreeRepresentation(FORMAT_VideoInfo2, (void*)pAMMedia);
- return hr;
+ return hr;
}
typedef struct {
- const int Format;
- const LPCTSTR Description;
+ const int Format;
+ const LPCTSTR Description;
} D3DFORMAT_TYPE;
-LONGLONG CSyncAP::GetMediaTypeMerit(IMFMediaType *pMediaType)
-{
- AM_MEDIA_TYPE *pAMMedia = NULL;
- MFVIDEOFORMAT *VideoFormat;
-
- HRESULT hr;
- CheckHR(pMediaType->GetRepresentation (FORMAT_MFVideoFormat, (void**)&pAMMedia));
- VideoFormat = (MFVIDEOFORMAT*)pAMMedia->pbFormat;
-
- LONGLONG Merit = 0;
- switch (VideoFormat->surfaceInfo.Format) {
- case FCC('NV12'):
- Merit = 90000000;
- break;
- case FCC('YV12'):
- Merit = 80000000;
- break;
- case FCC('YUY2'):
- Merit = 70000000;
- break;
- case FCC('UYVY'):
- Merit = 60000000;
- break;
-
- case D3DFMT_X8R8G8B8: // Never opt for RGB
- case D3DFMT_A8R8G8B8:
- case D3DFMT_R8G8B8:
- case D3DFMT_R5G6B5:
- Merit = 0;
- break;
- default:
- Merit = 1000;
- break;
- }
- pMediaType->FreeRepresentation(FORMAT_MFVideoFormat, (void*)pAMMedia);
- return Merit;
+LONGLONG CSyncAP::GetMediaTypeMerit(IMFMediaType* pMediaType)
+{
+ AM_MEDIA_TYPE* pAMMedia = NULL;
+ MFVIDEOFORMAT* VideoFormat;
+
+ HRESULT hr;
+ CheckHR(pMediaType->GetRepresentation(FORMAT_MFVideoFormat, (void**)&pAMMedia));
+ VideoFormat = (MFVIDEOFORMAT*)pAMMedia->pbFormat;
+
+ LONGLONG Merit = 0;
+ switch (VideoFormat->surfaceInfo.Format) {
+ case FCC('NV12'):
+ Merit = 90000000;
+ break;
+ case FCC('YV12'):
+ Merit = 80000000;
+ break;
+ case FCC('YUY2'):
+ Merit = 70000000;
+ break;
+ case FCC('UYVY'):
+ Merit = 60000000;
+ break;
+
+ case D3DFMT_X8R8G8B8: // Never opt for RGB
+ case D3DFMT_A8R8G8B8:
+ case D3DFMT_R8G8B8:
+ case D3DFMT_R5G6B5:
+ Merit = 0;
+ break;
+ default:
+ Merit = 1000;
+ break;
+ }
+ pMediaType->FreeRepresentation(FORMAT_MFVideoFormat, (void*)pAMMedia);
+ return Merit;
}
HRESULT CSyncAP::RenegotiateMediaType()
{
- HRESULT hr = S_OK;
-
- CComPtr<IMFMediaType> pMixerType;
- CComPtr<IMFMediaType> pType;
-
- if (!m_pMixer) {
- return MF_E_INVALIDREQUEST;
- }
-
- CInterfaceArray<IMFMediaType> ValidMixerTypes;
- // Loop through all of the mixer's proposed output types.
- DWORD iTypeIndex = 0;
- while ((hr != MF_E_NO_MORE_TYPES)) {
- pMixerType = NULL;
- pType = NULL;
- m_pMediaType = NULL;
-
- // Step 1. Get the next media type supported by mixer.
- hr = m_pMixer->GetOutputAvailableType(0, iTypeIndex++, &pMixerType);
- if (FAILED(hr)) {
- break;
- }
- // Step 2. Check if we support this media type.
- if (SUCCEEDED(hr)) {
- hr = IsMediaTypeSupported(pMixerType);
- }
- if (SUCCEEDED(hr)) {
- hr = CreateProposedOutputType(pMixerType, &pType);
- }
- // Step 4. Check if the mixer will accept this media type.
- if (SUCCEEDED(hr)) {
- hr = m_pMixer->SetOutputType(0, pType, MFT_SET_TYPE_TEST_ONLY);
- }
- if (SUCCEEDED(hr)) {
- LONGLONG Merit = GetMediaTypeMerit(pType);
-
- size_t nTypes = ValidMixerTypes.GetCount();
- size_t iInsertPos = 0;
- for (size_t i = 0; i < nTypes; ++i) {
- LONGLONG ThisMerit = GetMediaTypeMerit(ValidMixerTypes[i]);
- if (Merit > ThisMerit) {
- iInsertPos = i;
- break;
- } else {
- iInsertPos = i+1;
- }
- }
- ValidMixerTypes.InsertAt(iInsertPos, pType);
- }
- }
-
- size_t nValidTypes = ValidMixerTypes.GetCount();
- for (size_t i = 0; i < nValidTypes; ++i) {
- pType = ValidMixerTypes[i];
- }
-
- for (size_t i = 0; i < nValidTypes; ++i) {
- pType = ValidMixerTypes[i];
- hr = SetMediaType(pType);
- if (SUCCEEDED(hr)) {
- hr = m_pMixer->SetOutputType(0, pType, 0);
- // If something went wrong, clear the media type.
- if (FAILED(hr)) {
- SetMediaType(NULL);
- } else {
- break;
- }
- }
- }
-
- pMixerType = NULL;
- pType = NULL;
- return hr;
+ HRESULT hr = S_OK;
+
+ CComPtr<IMFMediaType> pMixerType;
+ CComPtr<IMFMediaType> pType;
+
+ if (!m_pMixer) {
+ return MF_E_INVALIDREQUEST;
+ }
+
+ CInterfaceArray<IMFMediaType> ValidMixerTypes;
+ // Loop through all of the mixer's proposed output types.
+ DWORD iTypeIndex = 0;
+ while ((hr != MF_E_NO_MORE_TYPES)) {
+ pMixerType = NULL;
+ pType = NULL;
+ m_pMediaType = NULL;
+
+ // Step 1. Get the next media type supported by mixer.
+ hr = m_pMixer->GetOutputAvailableType(0, iTypeIndex++, &pMixerType);
+ if (FAILED(hr)) {
+ break;
+ }
+ // Step 2. Check if we support this media type.
+ if (SUCCEEDED(hr)) {
+ hr = IsMediaTypeSupported(pMixerType);
+ }
+ if (SUCCEEDED(hr)) {
+ hr = CreateProposedOutputType(pMixerType, &pType);
+ }
+ // Step 4. Check if the mixer will accept this media type.
+ if (SUCCEEDED(hr)) {
+ hr = m_pMixer->SetOutputType(0, pType, MFT_SET_TYPE_TEST_ONLY);
+ }
+ if (SUCCEEDED(hr)) {
+ LONGLONG Merit = GetMediaTypeMerit(pType);
+
+ size_t nTypes = ValidMixerTypes.GetCount();
+ size_t iInsertPos = 0;
+ for (size_t i = 0; i < nTypes; ++i) {
+ LONGLONG ThisMerit = GetMediaTypeMerit(ValidMixerTypes[i]);
+ if (Merit > ThisMerit) {
+ iInsertPos = i;
+ break;
+ } else {
+ iInsertPos = i + 1;
+ }
+ }
+ ValidMixerTypes.InsertAt(iInsertPos, pType);
+ }
+ }
+
+ size_t nValidTypes = ValidMixerTypes.GetCount();
+ for (size_t i = 0; i < nValidTypes; ++i) {
+ pType = ValidMixerTypes[i];
+ }
+
+ for (size_t i = 0; i < nValidTypes; ++i) {
+ pType = ValidMixerTypes[i];
+ hr = SetMediaType(pType);
+ if (SUCCEEDED(hr)) {
+ hr = m_pMixer->SetOutputType(0, pType, 0);
+ // If something went wrong, clear the media type.
+ if (FAILED(hr)) {
+ SetMediaType(NULL);
+ } else {
+ break;
+ }
+ }
+ }
+
+ pMixerType = NULL;
+ pType = NULL;
+ return hr;
}
bool CSyncAP::GetSampleFromMixer()
{
- MFT_OUTPUT_DATA_BUFFER Buffer;
- HRESULT hr = S_OK;
- DWORD dwStatus;
- LONGLONG llClockBefore = 0;
- LONGLONG llClockAfter = 0;
- LONGLONG llMixerLatency;
-
- UINT dwSurface;
- bool newSample = false;
-
- while (SUCCEEDED(hr)) { // Get as many frames as there are and that we have samples for
- CComPtr<IMFSample> pSample;
- CComPtr<IMFSample> pNewSample;
- if (FAILED(GetFreeSample(&pSample))) { // All samples are taken for the moment. Better luck next time
- break;
- }
-
- memset(&Buffer, 0, sizeof(Buffer));
- Buffer.pSample = pSample;
- pSample->GetUINT32(GUID_SURFACE_INDEX, &dwSurface);
- {
- llClockBefore = GetRenderersData()->GetPerfCounter();
- hr = m_pMixer->ProcessOutput(0 , 1, &Buffer, &dwStatus);
- llClockAfter = GetRenderersData()->GetPerfCounter();
- }
-
- if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT) { // There are no samples left in the mixer
- MoveToFreeList(pSample, false);
- break;
- }
- if (m_pSink) {
- llMixerLatency = llClockAfter - llClockBefore;
- m_pSink->Notify (EC_PROCESSING_LATENCY, (LONG_PTR)&llMixerLatency, 0);
- }
-
- newSample = true;
-
- if (GetRenderersData()->m_fTearingTest) {
- RECT rcTearing;
-
- rcTearing.left = m_nTearingPos;
- rcTearing.top = 0;
- rcTearing.right = rcTearing.left + 4;
- rcTearing.bottom = m_NativeVideoSize.cy;
- m_pD3DDev->ColorFill(m_pVideoSurface[dwSurface], &rcTearing, D3DCOLOR_ARGB (255,255,0,0));
-
- rcTearing.left = (rcTearing.right + 15) % m_NativeVideoSize.cx;
- rcTearing.right = rcTearing.left + 4;
- m_pD3DDev->ColorFill(m_pVideoSurface[dwSurface], &rcTearing, D3DCOLOR_ARGB (255,255,0,0));
- m_nTearingPos = (m_nTearingPos + 7) % m_NativeVideoSize.cx;
- }
- MoveToScheduledList(pSample, false); // Schedule, then go back to see if there is more where that came from
- }
- return newSample;
-}
-
-STDMETHODIMP CSyncAP::GetCurrentMediaType(__deref_out IMFVideoMediaType **ppMediaType)
-{
- HRESULT hr = S_OK;
- CAutoLock lock(this);
- CheckPointer(ppMediaType, E_POINTER);
- CheckHR(CheckShutdown());
-
- if (m_pMediaType == NULL) {
- CheckHR(MF_E_NOT_INITIALIZED);
- }
-
- CheckHR(m_pMediaType->QueryInterface(__uuidof(IMFVideoMediaType), (void**)&ppMediaType));
- return hr;
+ MFT_OUTPUT_DATA_BUFFER Buffer;
+ HRESULT hr = S_OK;
+ DWORD dwStatus;
+ LONGLONG llClockBefore = 0;
+ LONGLONG llClockAfter = 0;
+ LONGLONG llMixerLatency;
+
+ UINT dwSurface;
+ bool newSample = false;
+
+ while (SUCCEEDED(hr)) { // Get as many frames as there are and that we have samples for
+ CComPtr<IMFSample> pSample;
+ CComPtr<IMFSample> pNewSample;
+ if (FAILED(GetFreeSample(&pSample))) { // All samples are taken for the moment. Better luck next time
+ break;
+ }
+
+ memset(&Buffer, 0, sizeof(Buffer));
+ Buffer.pSample = pSample;
+ pSample->GetUINT32(GUID_SURFACE_INDEX, &dwSurface);
+ {
+ llClockBefore = GetRenderersData()->GetPerfCounter();
+ hr = m_pMixer->ProcessOutput(0 , 1, &Buffer, &dwStatus);
+ llClockAfter = GetRenderersData()->GetPerfCounter();
+ }
+
+ if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT) { // There are no samples left in the mixer
+ MoveToFreeList(pSample, false);
+ break;
+ }
+ if (m_pSink) {
+ llMixerLatency = llClockAfter - llClockBefore;
+ m_pSink->Notify(EC_PROCESSING_LATENCY, (LONG_PTR)&llMixerLatency, 0);
+ }
+
+ newSample = true;
+
+ if (GetRenderersData()->m_fTearingTest) {
+ RECT rcTearing;
+
+ rcTearing.left = m_nTearingPos;
+ rcTearing.top = 0;
+ rcTearing.right = rcTearing.left + 4;
+ rcTearing.bottom = m_NativeVideoSize.cy;
+ m_pD3DDev->ColorFill(m_pVideoSurface[dwSurface], &rcTearing, D3DCOLOR_ARGB(255, 255, 0, 0));
+
+ rcTearing.left = (rcTearing.right + 15) % m_NativeVideoSize.cx;
+ rcTearing.right = rcTearing.left + 4;
+ m_pD3DDev->ColorFill(m_pVideoSurface[dwSurface], &rcTearing, D3DCOLOR_ARGB(255, 255, 0, 0));
+ m_nTearingPos = (m_nTearingPos + 7) % m_NativeVideoSize.cx;
+ }
+ MoveToScheduledList(pSample, false); // Schedule, then go back to see if there is more where that came from
+ }
+ return newSample;
+}
+
+STDMETHODIMP CSyncAP::GetCurrentMediaType(__deref_out IMFVideoMediaType** ppMediaType)
+{
+ HRESULT hr = S_OK;
+ CAutoLock lock(this);
+ CheckPointer(ppMediaType, E_POINTER);
+ CheckHR(CheckShutdown());
+
+ if (m_pMediaType == NULL) {
+ CheckHR(MF_E_NOT_INITIALIZED);
+ }
+
+ CheckHR(m_pMediaType->QueryInterface(__uuidof(IMFVideoMediaType), (void**)&ppMediaType));
+ return hr;
}
// IMFTopologyServiceLookupClient
-STDMETHODIMP CSyncAP::InitServicePointers(__in IMFTopologyServiceLookup *pLookup)
+STDMETHODIMP CSyncAP::InitServicePointers(__in IMFTopologyServiceLookup* pLookup)
{
- HRESULT hr;
- DWORD dwObjects = 1;
- hr = pLookup->LookupService(MF_SERVICE_LOOKUP_GLOBAL, 0, MR_VIDEO_MIXER_SERVICE, __uuidof (IMFTransform), (void**)&m_pMixer, &dwObjects);
- hr = pLookup->LookupService(MF_SERVICE_LOOKUP_GLOBAL, 0, MR_VIDEO_RENDER_SERVICE, __uuidof (IMediaEventSink ), (void**)&m_pSink, &dwObjects);
- hr = pLookup->LookupService(MF_SERVICE_LOOKUP_GLOBAL, 0, MR_VIDEO_RENDER_SERVICE, __uuidof (IMFClock ), (void**)&m_pClock, &dwObjects);
- StartWorkerThreads();
- return S_OK;
+ HRESULT hr;
+ DWORD dwObjects = 1;
+ hr = pLookup->LookupService(MF_SERVICE_LOOKUP_GLOBAL, 0, MR_VIDEO_MIXER_SERVICE, __uuidof(IMFTransform), (void**)&m_pMixer, &dwObjects);
+ hr = pLookup->LookupService(MF_SERVICE_LOOKUP_GLOBAL, 0, MR_VIDEO_RENDER_SERVICE, __uuidof(IMediaEventSink), (void**)&m_pSink, &dwObjects);
+ hr = pLookup->LookupService(MF_SERVICE_LOOKUP_GLOBAL, 0, MR_VIDEO_RENDER_SERVICE, __uuidof(IMFClock), (void**)&m_pClock, &dwObjects);
+ StartWorkerThreads();
+ return S_OK;
}
STDMETHODIMP CSyncAP::ReleaseServicePointers()
{
- StopWorkerThreads();
- m_pMixer = NULL;
- m_pSink = NULL;
- m_pClock = NULL;
- return S_OK;
+ StopWorkerThreads();
+ m_pMixer = NULL;
+ m_pSink = NULL;
+ m_pClock = NULL;
+ return S_OK;
}
// IMFVideoDeviceID
-STDMETHODIMP CSyncAP::GetDeviceID( __out IID *pDeviceID)
+STDMETHODIMP CSyncAP::GetDeviceID(__out IID* pDeviceID)
{
- CheckPointer(pDeviceID, E_POINTER);
- *pDeviceID = IID_IDirect3DDevice9;
- return S_OK;
+ CheckPointer(pDeviceID, E_POINTER);
+ *pDeviceID = IID_IDirect3DDevice9;
+ return S_OK;
}
// IMFGetService
-STDMETHODIMP CSyncAP::GetService( __RPC__in REFGUID guidService, __RPC__in REFIID riid, __RPC__deref_out_opt LPVOID *ppvObject)
+STDMETHODIMP CSyncAP::GetService(__RPC__in REFGUID guidService, __RPC__in REFIID riid, __RPC__deref_out_opt LPVOID* ppvObject)
{
- if (guidService == MR_VIDEO_RENDER_SERVICE) {
- return NonDelegatingQueryInterface (riid, ppvObject);
- } else if (guidService == MR_VIDEO_ACCELERATION_SERVICE) {
- return m_pD3DManager->QueryInterface (__uuidof(IDirect3DDeviceManager9), (void**) ppvObject);
- }
+ if (guidService == MR_VIDEO_RENDER_SERVICE) {
+ return NonDelegatingQueryInterface(riid, ppvObject);
+ } else if (guidService == MR_VIDEO_ACCELERATION_SERVICE) {
+ return m_pD3DManager->QueryInterface(__uuidof(IDirect3DDeviceManager9), (void**) ppvObject);
+ }
- return E_NOINTERFACE;
+ return E_NOINTERFACE;
}
// IMFAsyncCallback
-STDMETHODIMP CSyncAP::GetParameters( __RPC__out DWORD *pdwFlags, __RPC__out DWORD *pdwQueue)
+STDMETHODIMP CSyncAP::GetParameters(__RPC__out DWORD* pdwFlags, __RPC__out DWORD* pdwQueue)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
-STDMETHODIMP CSyncAP::Invoke( __RPC__in_opt IMFAsyncResult *pAsyncResult)
+STDMETHODIMP CSyncAP::Invoke(__RPC__in_opt IMFAsyncResult* pAsyncResult)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IMFVideoDisplayControl
-STDMETHODIMP CSyncAP::GetNativeVideoSize(SIZE *pszVideo, SIZE *pszARVideo)
+STDMETHODIMP CSyncAP::GetNativeVideoSize(SIZE* pszVideo, SIZE* pszARVideo)
{
- if (pszVideo) {
- pszVideo->cx = m_NativeVideoSize.cx;
- pszVideo->cy = m_NativeVideoSize.cy;
- }
- if (pszARVideo) {
- pszARVideo->cx = m_NativeVideoSize.cx * m_AspectRatio.cx;
- pszARVideo->cy = m_NativeVideoSize.cy * m_AspectRatio.cy;
- }
- return S_OK;
+ if (pszVideo) {
+ pszVideo->cx = m_NativeVideoSize.cx;
+ pszVideo->cy = m_NativeVideoSize.cy;
+ }
+ if (pszARVideo) {
+ pszARVideo->cx = m_NativeVideoSize.cx * m_AspectRatio.cx;
+ pszARVideo->cy = m_NativeVideoSize.cy * m_AspectRatio.cy;
+ }
+ return S_OK;
}
-STDMETHODIMP CSyncAP::GetIdealVideoSize(SIZE *pszMin, SIZE *pszMax)
+STDMETHODIMP CSyncAP::GetIdealVideoSize(SIZE* pszMin, SIZE* pszMax)
{
- if (pszMin) {
- pszMin->cx = 1;
- pszMin->cy = 1;
- }
+ if (pszMin) {
+ pszMin->cx = 1;
+ pszMin->cy = 1;
+ }
- if (pszMax) {
- D3DDISPLAYMODE d3ddm;
+ if (pszMax) {
+ D3DDISPLAYMODE d3ddm;
- ZeroMemory(&d3ddm, sizeof(d3ddm));
- if (SUCCEEDED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm))) {
- pszMax->cx = d3ddm.Width;
- pszMax->cy = d3ddm.Height;
- }
- }
- return S_OK;
+ ZeroMemory(&d3ddm, sizeof(d3ddm));
+ if (SUCCEEDED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm))) {
+ pszMax->cx = d3ddm.Width;
+ pszMax->cy = d3ddm.Height;
+ }
+ }
+ return S_OK;
}
-STDMETHODIMP CSyncAP::SetVideoPosition(const MFVideoNormalizedRect *pnrcSource, const LPRECT prcDest)
+STDMETHODIMP CSyncAP::SetVideoPosition(const MFVideoNormalizedRect* pnrcSource, const LPRECT prcDest)
{
- return S_OK;
+ return S_OK;
}
-STDMETHODIMP CSyncAP::GetVideoPosition(MFVideoNormalizedRect *pnrcSource, LPRECT prcDest)
+STDMETHODIMP CSyncAP::GetVideoPosition(MFVideoNormalizedRect* pnrcSource, LPRECT prcDest)
{
- if (pnrcSource) {
- pnrcSource->left = 0.0;
- pnrcSource->top = 0.0;
- pnrcSource->right = 1.0;
- pnrcSource->bottom = 1.0;
- }
- if (prcDest) {
- memcpy (prcDest, &m_VideoRect, sizeof(m_VideoRect)); //GetClientRect (m_hWnd, prcDest);
- }
- return S_OK;
+ if (pnrcSource) {
+ pnrcSource->left = 0.0;
+ pnrcSource->top = 0.0;
+ pnrcSource->right = 1.0;
+ pnrcSource->bottom = 1.0;
+ }
+ if (prcDest) {
+ memcpy(prcDest, &m_VideoRect, sizeof(m_VideoRect)); //GetClientRect (m_hWnd, prcDest);
+ }
+ return S_OK;
}
STDMETHODIMP CSyncAP::SetAspectRatioMode(DWORD dwAspectRatioMode)
{
- m_dwVideoAspectRatioMode = (MFVideoAspectRatioMode)dwAspectRatioMode;
- return S_OK;
+ m_dwVideoAspectRatioMode = (MFVideoAspectRatioMode)dwAspectRatioMode;
+ return S_OK;
}
-STDMETHODIMP CSyncAP::GetAspectRatioMode(DWORD *pdwAspectRatioMode)
+STDMETHODIMP CSyncAP::GetAspectRatioMode(DWORD* pdwAspectRatioMode)
{
- CheckPointer (pdwAspectRatioMode, E_POINTER);
- *pdwAspectRatioMode = m_dwVideoAspectRatioMode;
- return S_OK;
+ CheckPointer(pdwAspectRatioMode, E_POINTER);
+ *pdwAspectRatioMode = m_dwVideoAspectRatioMode;
+ return S_OK;
}
STDMETHODIMP CSyncAP::SetVideoWindow(HWND hwndVideo)
{
- ASSERT (m_hWnd == hwndVideo);
- return S_OK;
+ ASSERT(m_hWnd == hwndVideo);
+ return S_OK;
}
-STDMETHODIMP CSyncAP::GetVideoWindow(HWND *phwndVideo)
+STDMETHODIMP CSyncAP::GetVideoWindow(HWND* phwndVideo)
{
- CheckPointer(phwndVideo, E_POINTER);
- *phwndVideo = m_hWnd;
- return S_OK;
+ CheckPointer(phwndVideo, E_POINTER);
+ *phwndVideo = m_hWnd;
+ return S_OK;
}
STDMETHODIMP CSyncAP::RepaintVideo()
{
- Paint(true);
- return S_OK;
+ Paint(true);
+ return S_OK;
}
-STDMETHODIMP CSyncAP::GetCurrentImage(BITMAPINFOHEADER *pBih, BYTE **pDib, DWORD *pcbDib, LONGLONG *pTimeStamp)
+STDMETHODIMP CSyncAP::GetCurrentImage(BITMAPINFOHEADER* pBih, BYTE** pDib, DWORD* pcbDib, LONGLONG* pTimeStamp)
{
- ASSERT (FALSE);
- return E_NOTIMPL;
+ ASSERT(FALSE);
+ return E_NOTIMPL;
}
STDMETHODIMP CSyncAP::SetBorderColor(COLORREF Clr)
{
- m_BorderColor = Clr;
- return S_OK;
+ m_BorderColor = Clr;
+ return S_OK;
}
-STDMETHODIMP CSyncAP::GetBorderColor(COLORREF *pClr)
+STDMETHODIMP CSyncAP::GetBorderColor(COLORREF* pClr)
{
- CheckPointer (pClr, E_POINTER);
- *pClr = m_BorderColor;
- return S_OK;
+ CheckPointer(pClr, E_POINTER);
+ *pClr = m_BorderColor;
+ return S_OK;
}
STDMETHODIMP CSyncAP::SetRenderingPrefs(DWORD dwRenderFlags)
{
- m_dwVideoRenderPrefs = (MFVideoRenderPrefs)dwRenderFlags;
- return S_OK;
+ m_dwVideoRenderPrefs = (MFVideoRenderPrefs)dwRenderFlags;
+ return S_OK;
}
-STDMETHODIMP CSyncAP::GetRenderingPrefs(DWORD *pdwRenderFlags)
+STDMETHODIMP CSyncAP::GetRenderingPrefs(DWORD* pdwRenderFlags)
{
- CheckPointer(pdwRenderFlags, E_POINTER);
- *pdwRenderFlags = m_dwVideoRenderPrefs;
- return S_OK;
+ CheckPointer(pdwRenderFlags, E_POINTER);
+ *pdwRenderFlags = m_dwVideoRenderPrefs;
+ return S_OK;
}
STDMETHODIMP CSyncAP::SetFullscreen(BOOL fFullscreen)
{
- ASSERT (FALSE);
- return E_NOTIMPL;
+ ASSERT(FALSE);
+ return E_NOTIMPL;
}
-STDMETHODIMP CSyncAP::GetFullscreen(BOOL *pfFullscreen)
+STDMETHODIMP CSyncAP::GetFullscreen(BOOL* pfFullscreen)
{
- ASSERT (FALSE);
- return E_NOTIMPL;
+ ASSERT(FALSE);
+ return E_NOTIMPL;
}
// IEVRTrustedVideoPlugin
-STDMETHODIMP CSyncAP::IsInTrustedVideoMode(BOOL *pYes)
+STDMETHODIMP CSyncAP::IsInTrustedVideoMode(BOOL* pYes)
{
- CheckPointer(pYes, E_POINTER);
- *pYes = TRUE;
- return S_OK;
+ CheckPointer(pYes, E_POINTER);
+ *pYes = TRUE;
+ return S_OK;
}
-STDMETHODIMP CSyncAP::CanConstrict(BOOL *pYes)
+STDMETHODIMP CSyncAP::CanConstrict(BOOL* pYes)
{
- CheckPointer(pYes, E_POINTER);
- *pYes = TRUE;
- return S_OK;
+ CheckPointer(pYes, E_POINTER);
+ *pYes = TRUE;
+ return S_OK;
}
STDMETHODIMP CSyncAP::SetConstriction(DWORD dwKPix)
{
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CSyncAP::DisableImageExport(BOOL bDisable)
{
- return S_OK;
+ return S_OK;
}
// IDirect3DDeviceManager9
-STDMETHODIMP CSyncAP::ResetDevice(IDirect3DDevice9 *pDevice,UINT resetToken)
+STDMETHODIMP CSyncAP::ResetDevice(IDirect3DDevice9* pDevice, UINT resetToken)
{
- HRESULT hr = m_pD3DManager->ResetDevice (pDevice, resetToken);
- return hr;
+ HRESULT hr = m_pD3DManager->ResetDevice(pDevice, resetToken);
+ return hr;
}
-STDMETHODIMP CSyncAP::OpenDeviceHandle(HANDLE *phDevice)
+STDMETHODIMP CSyncAP::OpenDeviceHandle(HANDLE* phDevice)
{
- HRESULT hr = m_pD3DManager->OpenDeviceHandle (phDevice);
- return hr;
+ HRESULT hr = m_pD3DManager->OpenDeviceHandle(phDevice);
+ return hr;
}
STDMETHODIMP CSyncAP::CloseDeviceHandle(HANDLE hDevice)
{
- HRESULT hr = m_pD3DManager->CloseDeviceHandle(hDevice);
- return hr;
+ HRESULT hr = m_pD3DManager->CloseDeviceHandle(hDevice);
+ return hr;
}
STDMETHODIMP CSyncAP::TestDevice(HANDLE hDevice)
{
- HRESULT hr = m_pD3DManager->TestDevice(hDevice);
- return hr;
+ HRESULT hr = m_pD3DManager->TestDevice(hDevice);
+ return hr;
}
-STDMETHODIMP CSyncAP::LockDevice(HANDLE hDevice, IDirect3DDevice9 **ppDevice, BOOL fBlock)
+STDMETHODIMP CSyncAP::LockDevice(HANDLE hDevice, IDirect3DDevice9** ppDevice, BOOL fBlock)
{
- HRESULT hr = m_pD3DManager->LockDevice(hDevice, ppDevice, fBlock);
- return hr;
+ HRESULT hr = m_pD3DManager->LockDevice(hDevice, ppDevice, fBlock);
+ return hr;
}
STDMETHODIMP CSyncAP::UnlockDevice(HANDLE hDevice, BOOL fSaveState)
{
- HRESULT hr = m_pD3DManager->UnlockDevice(hDevice, fSaveState);
- return hr;
+ HRESULT hr = m_pD3DManager->UnlockDevice(hDevice, fSaveState);
+ return hr;
}
-STDMETHODIMP CSyncAP::GetVideoService(HANDLE hDevice, REFIID riid, void **ppService)
+STDMETHODIMP CSyncAP::GetVideoService(HANDLE hDevice, REFIID riid, void** ppService)
{
- HRESULT hr = m_pD3DManager->GetVideoService(hDevice, riid, ppService);
+ HRESULT hr = m_pD3DManager->GetVideoService(hDevice, riid, ppService);
- if (riid == __uuidof(IDirectXVideoDecoderService)) {
- UINT nNbDecoder = 5;
- GUID* pDecoderGuid;
- IDirectXVideoDecoderService* pDXVAVideoDecoder = (IDirectXVideoDecoderService*) *ppService;
- pDXVAVideoDecoder->GetDecoderDeviceGuids (&nNbDecoder, &pDecoderGuid);
- } else if (riid == __uuidof(IDirectXVideoProcessorService)) {
- IDirectXVideoProcessorService* pDXVAProcessor = (IDirectXVideoProcessorService*) *ppService;
- UNREFERENCED_PARAMETER(pDXVAProcessor);
- }
+ if (riid == __uuidof(IDirectXVideoDecoderService)) {
+ UINT nNbDecoder = 5;
+ GUID* pDecoderGuid;
+ IDirectXVideoDecoderService* pDXVAVideoDecoder = (IDirectXVideoDecoderService*) *ppService;
+ pDXVAVideoDecoder->GetDecoderDeviceGuids(&nNbDecoder, &pDecoderGuid);
+ } else if (riid == __uuidof(IDirectXVideoProcessorService)) {
+ IDirectXVideoProcessorService* pDXVAProcessor = (IDirectXVideoProcessorService*) *ppService;
+ UNREFERENCED_PARAMETER(pDXVAProcessor);
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CSyncAP::GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight)
{
- // This function should be called...
- ASSERT (FALSE);
+ // This function should be called...
+ ASSERT(FALSE);
- if (lpWidth) {
- *lpWidth = m_NativeVideoSize.cx;
- }
- if (lpHeight) {
- *lpHeight = m_NativeVideoSize.cy;
- }
- if (lpARWidth) {
- *lpARWidth = m_AspectRatio.cx;
- }
- if (lpARHeight) {
- *lpARHeight = m_AspectRatio.cy;
- }
- return S_OK;
+ if (lpWidth) {
+ *lpWidth = m_NativeVideoSize.cx;
+ }
+ if (lpHeight) {
+ *lpHeight = m_NativeVideoSize.cy;
+ }
+ if (lpARWidth) {
+ *lpARWidth = m_AspectRatio.cx;
+ }
+ if (lpARHeight) {
+ *lpARHeight = m_AspectRatio.cy;
+ }
+ return S_OK;
}
STDMETHODIMP CSyncAP::InitializeDevice(AM_MEDIA_TYPE* pMediaType)
{
- HRESULT hr;
- CAutoLock lock(this);
- CAutoLock lock2(&m_ImageProcessingLock);
- CAutoLock cRenderLock(&m_allocatorLock);
-
- RemoveAllSamples();
- DeleteSurfaces();
-
- VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*) pMediaType->pbFormat;
- int w = vih2->bmiHeader.biWidth;
- int h = abs(vih2->bmiHeader.biHeight);
-
- m_NativeVideoSize = CSize(w, h);
- if (m_bHighColorResolution) {
- hr = AllocSurfaces(D3DFMT_A2R10G10B10);
- } else {
- hr = AllocSurfaces(D3DFMT_X8R8G8B8);
- }
-
- for (int i = 0; i < m_nDXSurface; i++) {
- CComPtr<IMFSample> pMFSample;
- hr = pfMFCreateVideoSampleFromSurface(m_pVideoSurface[i], &pMFSample);
- if (SUCCEEDED (hr)) {
- pMFSample->SetUINT32(GUID_SURFACE_INDEX, i);
- m_FreeSamples.AddTail (pMFSample);
- }
- ASSERT (SUCCEEDED (hr));
- }
- return hr;
+ HRESULT hr;
+ CAutoLock lock(this);
+ CAutoLock lock2(&m_ImageProcessingLock);
+ CAutoLock cRenderLock(&m_allocatorLock);
+
+ RemoveAllSamples();
+ DeleteSurfaces();
+
+ VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*) pMediaType->pbFormat;
+ int w = vih2->bmiHeader.biWidth;
+ int h = abs(vih2->bmiHeader.biHeight);
+
+ m_NativeVideoSize = CSize(w, h);
+ if (m_bHighColorResolution) {
+ hr = AllocSurfaces(D3DFMT_A2R10G10B10);
+ } else {
+ hr = AllocSurfaces(D3DFMT_X8R8G8B8);
+ }
+
+ for (int i = 0; i < m_nDXSurface; i++) {
+ CComPtr<IMFSample> pMFSample;
+ hr = pfMFCreateVideoSampleFromSurface(m_pVideoSurface[i], &pMFSample);
+ if (SUCCEEDED(hr)) {
+ pMFSample->SetUINT32(GUID_SURFACE_INDEX, i);
+ m_FreeSamples.AddTail(pMFSample);
+ }
+ ASSERT(SUCCEEDED(hr));
+ }
+ return hr;
}
DWORD WINAPI CSyncAP::MixerThreadStatic(LPVOID lpParam)
{
- CSyncAP *pThis = (CSyncAP*) lpParam;
- pThis->MixerThread();
- return 0;
+ CSyncAP* pThis = (CSyncAP*) lpParam;
+ pThis->MixerThread();
+ return 0;
}
void CSyncAP::MixerThread()
{
- HANDLE hEvts[] = {m_hEvtQuit};
- bool bQuit = false;
- TIMECAPS tc;
- DWORD dwResolution;
- DWORD dwUser = 0;
-
- timeGetDevCaps(&tc, sizeof(TIMECAPS));
- dwResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
- dwUser = timeBeginPeriod(dwResolution);
-
- while (!bQuit) {
- DWORD dwObject = WaitForMultipleObjects (_countof(hEvts), hEvts, FALSE, 1);
- switch (dwObject) {
- case WAIT_OBJECT_0 :
- bQuit = true;
- break;
- case WAIT_TIMEOUT : {
- bool bNewSample = false;
- {
- CAutoLock AutoLock(&m_ImageProcessingLock);
- bNewSample = GetSampleFromMixer();
- }
- if (m_bUseInternalTimer && m_pSubPicQueue) {
- m_pSubPicQueue->SetFPS(m_fps);
- }
- }
- break;
- }
- }
- timeEndPeriod (dwResolution);
+ HANDLE hEvts[] = {m_hEvtQuit};
+ bool bQuit = false;
+ TIMECAPS tc;
+ DWORD dwResolution;
+ DWORD dwUser = 0;
+
+ timeGetDevCaps(&tc, sizeof(TIMECAPS));
+ dwResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
+ dwUser = timeBeginPeriod(dwResolution);
+
+ while (!bQuit) {
+ DWORD dwObject = WaitForMultipleObjects(_countof(hEvts), hEvts, FALSE, 1);
+ switch (dwObject) {
+ case WAIT_OBJECT_0 :
+ bQuit = true;
+ break;
+ case WAIT_TIMEOUT : {
+ bool bNewSample = false;
+ {
+ CAutoLock AutoLock(&m_ImageProcessingLock);
+ bNewSample = GetSampleFromMixer();
+ }
+ if (m_bUseInternalTimer && m_pSubPicQueue) {
+ m_pSubPicQueue->SetFPS(m_fps);
+ }
+ }
+ break;
+ }
+ }
+ timeEndPeriod(dwResolution);
}
DWORD WINAPI CSyncAP::RenderThreadStatic(LPVOID lpParam)
{
- CSyncAP *pThis = (CSyncAP*)lpParam;
- pThis->RenderThread();
- return 0;
+ CSyncAP* pThis = (CSyncAP*)lpParam;
+ pThis->RenderThread();
+ return 0;
}
// Get samples that have been received and queued up by MixerThread() and present them at the correct time by calling Paint().
void CSyncAP::RenderThread()
{
- HANDLE hEvts[] = {m_hEvtQuit, m_hEvtFlush, m_hEvtSkip};
- bool bQuit = false;
- TIMECAPS tc;
- DWORD dwResolution;
- LONGLONG llRefClockTime;
- double dTargetSyncOffset;
- MFTIME llSystemTime;
- DWORD dwUser = 0;
- DWORD dwObject;
- int nSamplesLeft;
- CComPtr<IMFSample>pNewSample = NULL; // The sample next in line to be presented
-
- // Tell Vista Multimedia Class Scheduler we are doing threaded playback (increase priority)
- HANDLE hAvrt = 0;
- if (pfAvSetMmThreadCharacteristicsW) {
- DWORD dwTaskIndex = 0;
- hAvrt = pfAvSetMmThreadCharacteristicsW (L"Playback", &dwTaskIndex);
- if (pfAvSetMmThreadPriority) {
- pfAvSetMmThreadPriority (hAvrt, AVRT_PRIORITY_HIGH);
- }
- }
-
- // Set timer resolution
- timeGetDevCaps(&tc, sizeof(TIMECAPS));
- dwResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
- dwUser = timeBeginPeriod(dwResolution);
- pNewSample = NULL;
-
- while (!bQuit) {
- m_lNextSampleWait = 1; // Default value for running this loop
- nSamplesLeft = 0;
- bool stepForward = false;
- LONG lDisplayCycle = (LONG)(GetDisplayCycle());
- LONG lDisplayCycle2 = (LONG)(GetDisplayCycle() / 2.0); // These are a couple of empirically determined constants used the control the "snap" function
- LONG lDisplayCycle4 = (LONG)(GetDisplayCycle() / 4.0);
-
- CRenderersSettings& s = GetRenderersSettings();
- dTargetSyncOffset = s.m_RenderSettings.fTargetSyncOffset;
-
- if ((m_nRenderState == Started || !m_bPrerolled) && !pNewSample) { // If either streaming or the pre-roll sample and no sample yet fetched
- if (SUCCEEDED(GetScheduledSample(&pNewSample, nSamplesLeft))) { // Get the next sample
- m_llLastSampleTime = m_llSampleTime;
- if (!m_bPrerolled) {
- m_bPrerolled = true; // m_bPrerolled is a ticket to show one (1) frame immediately
- m_lNextSampleWait = 0; // Present immediately
- } else if (SUCCEEDED(pNewSample->GetSampleTime(&m_llSampleTime))) { // Get zero-based sample due time
- if (m_llLastSampleTime == m_llSampleTime) { // In the rare case there are duplicate frames in the movie. There really shouldn't be but it happens.
- MoveToFreeList(pNewSample, true);
- pNewSample = NULL;
- m_lNextSampleWait = 0;
- } else {
- m_pClock->GetCorrelatedTime(0, &llRefClockTime, &llSystemTime); // Get zero-based reference clock time. llSystemTime is not used for anything here
- m_lNextSampleWait = (LONG)((m_llSampleTime - llRefClockTime) / 10000); // Time left until sample is due, in ms
- if (m_bStepping) {
- m_lNextSampleWait = 0;
- } else if (s.m_RenderSettings.bSynchronizeNearest) { // Present at the closest "safe" occasion at dTargetSyncOffset ms before vsync to avoid tearing
- if (m_lNextSampleWait < -lDisplayCycle) { // We have to allow slightly negative numbers at this stage. Otherwise we get "choking" when frame rate > refresh rate
- SetEvent(m_hEvtSkip);
- m_bEvtSkip = true;
- }
- REFERENCE_TIME rtRefClockTimeNow;
- if (m_pRefClock) {
- m_pRefClock->GetTime(&rtRefClockTimeNow); // Reference clock time now
- }
- LONG lLastVsyncTime = (LONG)((m_llEstVBlankTime - rtRefClockTimeNow) / 10000); // Last vsync time relative to now
- if (abs(lLastVsyncTime) > lDisplayCycle) {
- lLastVsyncTime = - lDisplayCycle; // To even out glitches in the beginning
- }
-
- LONGLONG llNextSampleWait = (LONGLONG)(((double)lLastVsyncTime + GetDisplayCycle() - dTargetSyncOffset) * 10000); // Time from now util next safe time to Paint()
- while ((llRefClockTime + llNextSampleWait) < (m_llSampleTime + m_llHysteresis)) { // While the proposed time is in the past of sample presentation time
- llNextSampleWait = llNextSampleWait + (LONGLONG)(GetDisplayCycle() * 10000); // Try the next possible time, one display cycle ahead
- }
- m_lNextSampleWait = (LONG)(llNextSampleWait / 10000);
- m_lShiftToNearestPrev = m_lShiftToNearest;
- m_lShiftToNearest = (LONG)((llRefClockTime + llNextSampleWait - m_llSampleTime) / 10000); // The adjustment made to get to the sweet point in time, in ms
-
- // If m_lShiftToNearest is pushed a whole cycle into the future, then we are getting more frames
- // than we can chew and we need to throw one away. We don't want to wait many cycles and skip many
- // frames.
- if (m_lShiftToNearest > (lDisplayCycle + 1)) {
- SetEvent(m_hEvtSkip);
- m_bEvtSkip = true;
- }
-
- // We need to add a hysteresis to the control of the timing adjustment to avoid judder when
- // presentation time is close to vsync and the renderer couldn't otherwise make up its mind
- // whether to present before the vsync or after. That kind of indecisiveness leads to judder.
- if (m_bSnapToVSync) {
-
- if ((m_lShiftToNearestPrev - m_lShiftToNearest) > lDisplayCycle2) { // If a step down in the m_lShiftToNearest function. Display slower than video.
- m_bVideoSlowerThanDisplay = false;
- m_llHysteresis = -(LONGLONG)(10000 * lDisplayCycle4);
- } else if ((m_lShiftToNearest - m_lShiftToNearestPrev) > lDisplayCycle2) { // If a step up
- m_bVideoSlowerThanDisplay = true;
- m_llHysteresis = (LONGLONG)(10000 * lDisplayCycle4);
- } else if ((m_lShiftToNearest < (3 * lDisplayCycle4)) && (m_lShiftToNearest > lDisplayCycle4)) {
- m_llHysteresis = 0; // Reset when between 1/4 and 3/4 of the way either way
- }
-
- if ((m_lShiftToNearest < lDisplayCycle2) && (m_llHysteresis > 0)) {
- m_llHysteresis = 0; // Should never really be in this territory.
- }
- if (m_lShiftToNearest < 0) {
- m_llHysteresis = 0; // A glitch might get us to a sticky state where both these numbers are negative.
- }
- if ((m_lShiftToNearest > lDisplayCycle2) && (m_llHysteresis < 0)) {
- m_llHysteresis = 0;
- }
- }
- }
-
- if (m_lNextSampleWait < 0) { // Skip late or duplicate sample.
- SetEvent(m_hEvtSkip);
- m_bEvtSkip = true;
- }
-
- if (m_lNextSampleWait > 1000) {
- m_lNextSampleWait = 1000; // So as to avoid full a full stop when sample is far in the future (shouldn't really happen).
- }
- }
- } // if got new sample
- }
- }
- // Wait for the next presentation time (m_lNextSampleWait) or some other event.
- dwObject = WaitForMultipleObjects(_countof(hEvts), hEvts, FALSE, (DWORD)m_lNextSampleWait);
- switch (dwObject) {
- case WAIT_OBJECT_0: // Quit
- bQuit = true;
- break;
-
- case WAIT_OBJECT_0 + 1: // Flush
- if (pNewSample) {
- MoveToFreeList(pNewSample, true);
- }
- pNewSample = NULL;
- FlushSamples();
- m_bEvtFlush = false;
- ResetEvent(m_hEvtFlush);
- m_bPrerolled = false;
- m_lShiftToNearest = 0;
- stepForward = true;
- break;
-
- case WAIT_OBJECT_0 + 2: // Skip sample
- m_pcFramesDropped++;
- m_llSampleTime = m_llLastSampleTime; // This sample will never be shown
- m_bEvtSkip = false;
- ResetEvent(m_hEvtSkip);
- stepForward = true;
- break;
-
- case WAIT_TIMEOUT: // Time to show the sample or something
- if (m_LastSetOutputRange != -1 && m_LastSetOutputRange != s.m_RenderSettings.iEVROutputRange || m_bPendingRenegotiate) {
- if (pNewSample) {
- MoveToFreeList(pNewSample, true);
- }
- pNewSample = NULL;
- FlushSamples();
- RenegotiateMediaType();
- m_bPendingRenegotiate = false;
- }
-
- if (m_bPendingResetDevice) {
- if (pNewSample) {
- MoveToFreeList(pNewSample, true);
- }
- pNewSample = NULL;
- SendResetRequest();
- } else if (m_nStepCount < 0) {
- m_nStepCount = 0;
- m_pcFramesDropped++;
- stepForward = true;
- } else if (pNewSample && (m_nStepCount > 0)) {
- pNewSample->GetUINT32(GUID_SURFACE_INDEX, (UINT32 *)&m_nCurSurface);
- if (!g_bExternalSubtitleTime) {
- __super::SetTime (g_tSegmentStart + m_llSampleTime);
- }
- Paint(true);
- CompleteFrameStep(false);
- m_pcFramesDrawn++;
- stepForward = true;
- } else if (pNewSample && !m_bStepping) { // When a stepped frame is shown, a new one is fetched that we don't want to show here while stepping
- pNewSample->GetUINT32(GUID_SURFACE_INDEX, (UINT32*)&m_nCurSurface);
- if (!g_bExternalSubtitleTime) {
- __super::SetTime (g_tSegmentStart + m_llSampleTime);
- }
- Paint(true);
- m_pcFramesDrawn++;
- stepForward = true;
- }
- break;
- } // switch
- if (pNewSample && stepForward) {
- MoveToFreeList(pNewSample, true);
- pNewSample = NULL;
- }
- } // while
- if (pNewSample) {
- MoveToFreeList(pNewSample, true);
- pNewSample = NULL;
- }
- timeEndPeriod (dwResolution);
- if (pfAvRevertMmThreadCharacteristics) {
- pfAvRevertMmThreadCharacteristics(hAvrt);
- }
+ HANDLE hEvts[] = {m_hEvtQuit, m_hEvtFlush, m_hEvtSkip};
+ bool bQuit = false;
+ TIMECAPS tc;
+ DWORD dwResolution;
+ LONGLONG llRefClockTime;
+ double dTargetSyncOffset;
+ MFTIME llSystemTime;
+ DWORD dwUser = 0;
+ DWORD dwObject;
+ int nSamplesLeft;
+ CComPtr<IMFSample>pNewSample = NULL; // The sample next in line to be presented
+
+ // Tell Vista Multimedia Class Scheduler we are doing threaded playback (increase priority)
+ HANDLE hAvrt = 0;
+ if (pfAvSetMmThreadCharacteristicsW) {
+ DWORD dwTaskIndex = 0;
+ hAvrt = pfAvSetMmThreadCharacteristicsW(L"Playback", &dwTaskIndex);
+ if (pfAvSetMmThreadPriority) {
+ pfAvSetMmThreadPriority(hAvrt, AVRT_PRIORITY_HIGH);
+ }
+ }
+
+ // Set timer resolution
+ timeGetDevCaps(&tc, sizeof(TIMECAPS));
+ dwResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
+ dwUser = timeBeginPeriod(dwResolution);
+ pNewSample = NULL;
+
+ while (!bQuit) {
+ m_lNextSampleWait = 1; // Default value for running this loop
+ nSamplesLeft = 0;
+ bool stepForward = false;
+ LONG lDisplayCycle = (LONG)(GetDisplayCycle());
+ LONG lDisplayCycle2 = (LONG)(GetDisplayCycle() / 2.0); // These are a couple of empirically determined constants used the control the "snap" function
+ LONG lDisplayCycle4 = (LONG)(GetDisplayCycle() / 4.0);
+
+ CRenderersSettings& s = GetRenderersSettings();
+ dTargetSyncOffset = s.m_RenderSettings.fTargetSyncOffset;
+
+ if ((m_nRenderState == Started || !m_bPrerolled) && !pNewSample) { // If either streaming or the pre-roll sample and no sample yet fetched
+ if (SUCCEEDED(GetScheduledSample(&pNewSample, nSamplesLeft))) { // Get the next sample
+ m_llLastSampleTime = m_llSampleTime;
+ if (!m_bPrerolled) {
+ m_bPrerolled = true; // m_bPrerolled is a ticket to show one (1) frame immediately
+ m_lNextSampleWait = 0; // Present immediately
+ } else if (SUCCEEDED(pNewSample->GetSampleTime(&m_llSampleTime))) { // Get zero-based sample due time
+ if (m_llLastSampleTime == m_llSampleTime) { // In the rare case there are duplicate frames in the movie. There really shouldn't be but it happens.
+ MoveToFreeList(pNewSample, true);
+ pNewSample = NULL;
+ m_lNextSampleWait = 0;
+ } else {
+ m_pClock->GetCorrelatedTime(0, &llRefClockTime, &llSystemTime); // Get zero-based reference clock time. llSystemTime is not used for anything here
+ m_lNextSampleWait = (LONG)((m_llSampleTime - llRefClockTime) / 10000); // Time left until sample is due, in ms
+ if (m_bStepping) {
+ m_lNextSampleWait = 0;
+ } else if (s.m_RenderSettings.bSynchronizeNearest) { // Present at the closest "safe" occasion at dTargetSyncOffset ms before vsync to avoid tearing
+ if (m_lNextSampleWait < -lDisplayCycle) { // We have to allow slightly negative numbers at this stage. Otherwise we get "choking" when frame rate > refresh rate
+ SetEvent(m_hEvtSkip);
+ m_bEvtSkip = true;
+ }
+ REFERENCE_TIME rtRefClockTimeNow;
+ if (m_pRefClock) {
+ m_pRefClock->GetTime(&rtRefClockTimeNow); // Reference clock time now
+ }
+ LONG lLastVsyncTime = (LONG)((m_llEstVBlankTime - rtRefClockTimeNow) / 10000); // Last vsync time relative to now
+ if (abs(lLastVsyncTime) > lDisplayCycle) {
+ lLastVsyncTime = - lDisplayCycle; // To even out glitches in the beginning
+ }
+
+ LONGLONG llNextSampleWait = (LONGLONG)(((double)lLastVsyncTime + GetDisplayCycle() - dTargetSyncOffset) * 10000); // Time from now util next safe time to Paint()
+ while ((llRefClockTime + llNextSampleWait) < (m_llSampleTime + m_llHysteresis)) { // While the proposed time is in the past of sample presentation time
+ llNextSampleWait = llNextSampleWait + (LONGLONG)(GetDisplayCycle() * 10000); // Try the next possible time, one display cycle ahead
+ }
+ m_lNextSampleWait = (LONG)(llNextSampleWait / 10000);
+ m_lShiftToNearestPrev = m_lShiftToNearest;
+ m_lShiftToNearest = (LONG)((llRefClockTime + llNextSampleWait - m_llSampleTime) / 10000); // The adjustment made to get to the sweet point in time, in ms
+
+ // If m_lShiftToNearest is pushed a whole cycle into the future, then we are getting more frames
+ // than we can chew and we need to throw one away. We don't want to wait many cycles and skip many
+ // frames.
+ if (m_lShiftToNearest > (lDisplayCycle + 1)) {
+ SetEvent(m_hEvtSkip);
+ m_bEvtSkip = true;
+ }
+
+ // We need to add a hysteresis to the control of the timing adjustment to avoid judder when
+ // presentation time is close to vsync and the renderer couldn't otherwise make up its mind
+ // whether to present before the vsync or after. That kind of indecisiveness leads to judder.
+ if (m_bSnapToVSync) {
+
+ if ((m_lShiftToNearestPrev - m_lShiftToNearest) > lDisplayCycle2) { // If a step down in the m_lShiftToNearest function. Display slower than video.
+ m_bVideoSlowerThanDisplay = false;
+ m_llHysteresis = -(LONGLONG)(10000 * lDisplayCycle4);
+ } else if ((m_lShiftToNearest - m_lShiftToNearestPrev) > lDisplayCycle2) { // If a step up
+ m_bVideoSlowerThanDisplay = true;
+ m_llHysteresis = (LONGLONG)(10000 * lDisplayCycle4);
+ } else if ((m_lShiftToNearest < (3 * lDisplayCycle4)) && (m_lShiftToNearest > lDisplayCycle4)) {
+ m_llHysteresis = 0; // Reset when between 1/4 and 3/4 of the way either way
+ }
+
+ if ((m_lShiftToNearest < lDisplayCycle2) && (m_llHysteresis > 0)) {
+ m_llHysteresis = 0; // Should never really be in this territory.
+ }
+ if (m_lShiftToNearest < 0) {
+ m_llHysteresis = 0; // A glitch might get us to a sticky state where both these numbers are negative.
+ }
+ if ((m_lShiftToNearest > lDisplayCycle2) && (m_llHysteresis < 0)) {
+ m_llHysteresis = 0;
+ }
+ }
+ }
+
+ if (m_lNextSampleWait < 0) { // Skip late or duplicate sample.
+ SetEvent(m_hEvtSkip);
+ m_bEvtSkip = true;
+ }
+
+ if (m_lNextSampleWait > 1000) {
+ m_lNextSampleWait = 1000; // So as to avoid full a full stop when sample is far in the future (shouldn't really happen).
+ }
+ }
+ } // if got new sample
+ }
+ }
+ // Wait for the next presentation time (m_lNextSampleWait) or some other event.
+ dwObject = WaitForMultipleObjects(_countof(hEvts), hEvts, FALSE, (DWORD)m_lNextSampleWait);
+ switch (dwObject) {
+ case WAIT_OBJECT_0: // Quit
+ bQuit = true;
+ break;
+
+ case WAIT_OBJECT_0 + 1: // Flush
+ if (pNewSample) {
+ MoveToFreeList(pNewSample, true);
+ }
+ pNewSample = NULL;
+ FlushSamples();
+ m_bEvtFlush = false;
+ ResetEvent(m_hEvtFlush);
+ m_bPrerolled = false;
+ m_lShiftToNearest = 0;
+ stepForward = true;
+ break;
+
+ case WAIT_OBJECT_0 + 2: // Skip sample
+ m_pcFramesDropped++;
+ m_llSampleTime = m_llLastSampleTime; // This sample will never be shown
+ m_bEvtSkip = false;
+ ResetEvent(m_hEvtSkip);
+ stepForward = true;
+ break;
+
+ case WAIT_TIMEOUT: // Time to show the sample or something
+ if (m_LastSetOutputRange != -1 && m_LastSetOutputRange != s.m_RenderSettings.iEVROutputRange || m_bPendingRenegotiate) {
+ if (pNewSample) {
+ MoveToFreeList(pNewSample, true);
+ }
+ pNewSample = NULL;
+ FlushSamples();
+ RenegotiateMediaType();
+ m_bPendingRenegotiate = false;
+ }
+
+ if (m_bPendingResetDevice) {
+ if (pNewSample) {
+ MoveToFreeList(pNewSample, true);
+ }
+ pNewSample = NULL;
+ SendResetRequest();
+ } else if (m_nStepCount < 0) {
+ m_nStepCount = 0;
+ m_pcFramesDropped++;
+ stepForward = true;
+ } else if (pNewSample && (m_nStepCount > 0)) {
+ pNewSample->GetUINT32(GUID_SURFACE_INDEX, (UINT32*)&m_nCurSurface);
+ if (!g_bExternalSubtitleTime) {
+ __super::SetTime(g_tSegmentStart + m_llSampleTime);
+ }
+ Paint(true);
+ CompleteFrameStep(false);
+ m_pcFramesDrawn++;
+ stepForward = true;
+ } else if (pNewSample && !m_bStepping) { // When a stepped frame is shown, a new one is fetched that we don't want to show here while stepping
+ pNewSample->GetUINT32(GUID_SURFACE_INDEX, (UINT32*)&m_nCurSurface);
+ if (!g_bExternalSubtitleTime) {
+ __super::SetTime(g_tSegmentStart + m_llSampleTime);
+ }
+ Paint(true);
+ m_pcFramesDrawn++;
+ stepForward = true;
+ }
+ break;
+ } // switch
+ if (pNewSample && stepForward) {
+ MoveToFreeList(pNewSample, true);
+ pNewSample = NULL;
+ }
+ } // while
+ if (pNewSample) {
+ MoveToFreeList(pNewSample, true);
+ pNewSample = NULL;
+ }
+ timeEndPeriod(dwResolution);
+ if (pfAvRevertMmThreadCharacteristics) {
+ pfAvRevertMmThreadCharacteristics(hAvrt);
+ }
}
STDMETHODIMP_(bool) CSyncAP::ResetDevice()
{
- CAutoLock lock(this);
- CAutoLock lock2(&m_ImageProcessingLock);
- CAutoLock cRenderLock(&m_allocatorLock);
- RemoveAllSamples();
+ CAutoLock lock(this);
+ CAutoLock lock2(&m_ImageProcessingLock);
+ CAutoLock cRenderLock(&m_allocatorLock);
+ RemoveAllSamples();
- bool bResult = __super::ResetDevice();
+ bool bResult = __super::ResetDevice();
- for (int i = 0; i < m_nDXSurface; i++) {
- CComPtr<IMFSample> pMFSample;
- HRESULT hr = pfMFCreateVideoSampleFromSurface (m_pVideoSurface[i], &pMFSample);
- if (SUCCEEDED (hr)) {
- pMFSample->SetUINT32(GUID_SURFACE_INDEX, i);
- m_FreeSamples.AddTail(pMFSample);
- }
- ASSERT(SUCCEEDED (hr));
- }
- return bResult;
+ for (int i = 0; i < m_nDXSurface; i++) {
+ CComPtr<IMFSample> pMFSample;
+ HRESULT hr = pfMFCreateVideoSampleFromSurface(m_pVideoSurface[i], &pMFSample);
+ if (SUCCEEDED(hr)) {
+ pMFSample->SetUINT32(GUID_SURFACE_INDEX, i);
+ m_FreeSamples.AddTail(pMFSample);
+ }
+ ASSERT(SUCCEEDED(hr));
+ }
+ return bResult;
}
void CSyncAP::OnResetDevice()
{
- TRACE("--> CSyncAP::OnResetDevice on thread: %d\n", GetCurrentThreadId());
- HRESULT hr;
- hr = m_pD3DManager->ResetDevice(m_pD3DDev, m_nResetToken);
- if (m_pSink) {
- m_pSink->Notify(EC_DISPLAY_CHANGED, 0, 0);
- }
- CSize videoSize = GetVisibleVideoSize();
- if (m_pSink) {
- m_pSink->Notify(EC_VIDEO_SIZE_CHANGED, MAKELPARAM(videoSize.cx, videoSize.cy), 0);
- }
+ TRACE("--> CSyncAP::OnResetDevice on thread: %d\n", GetCurrentThreadId());
+ HRESULT hr;
+ hr = m_pD3DManager->ResetDevice(m_pD3DDev, m_nResetToken);
+ if (m_pSink) {
+ m_pSink->Notify(EC_DISPLAY_CHANGED, 0, 0);
+ }
+ CSize videoSize = GetVisibleVideoSize();
+ if (m_pSink) {
+ m_pSink->Notify(EC_VIDEO_SIZE_CHANGED, MAKELPARAM(videoSize.cx, videoSize.cy), 0);
+ }
}
void CSyncAP::RemoveAllSamples()
{
- CAutoLock AutoLock(&m_ImageProcessingLock);
- FlushSamples();
- m_ScheduledSamples.RemoveAll();
- m_FreeSamples.RemoveAll();
- m_nUsedBuffer = 0;
+ CAutoLock AutoLock(&m_ImageProcessingLock);
+ FlushSamples();
+ m_ScheduledSamples.RemoveAll();
+ m_FreeSamples.RemoveAll();
+ m_nUsedBuffer = 0;
}
HRESULT CSyncAP::GetFreeSample(IMFSample** ppSample)
{
- CAutoLock lock(&m_SampleQueueLock);
- HRESULT hr = S_OK;
+ CAutoLock lock(&m_SampleQueueLock);
+ HRESULT hr = S_OK;
- if (m_FreeSamples.GetCount() > 1) { // Cannot use first free buffer (can be currently displayed)
- InterlockedIncrement(&m_nUsedBuffer);
- *ppSample = m_FreeSamples.RemoveHead().Detach();
- } else {
- hr = MF_E_SAMPLEALLOCATOR_EMPTY;
- }
+ if (m_FreeSamples.GetCount() > 1) { // Cannot use first free buffer (can be currently displayed)
+ InterlockedIncrement(&m_nUsedBuffer);
+ *ppSample = m_FreeSamples.RemoveHead().Detach();
+ } else {
+ hr = MF_E_SAMPLEALLOCATOR_EMPTY;
+ }
- return hr;
+ return hr;
}
-HRESULT CSyncAP::GetScheduledSample(IMFSample** ppSample, int &_Count)
+HRESULT CSyncAP::GetScheduledSample(IMFSample** ppSample, int& _Count)
{
- CAutoLock lock(&m_SampleQueueLock);
- HRESULT hr = S_OK;
+ CAutoLock lock(&m_SampleQueueLock);
+ HRESULT hr = S_OK;
- _Count = (int)m_ScheduledSamples.GetCount();
- if (_Count > 0) {
- *ppSample = m_ScheduledSamples.RemoveHead().Detach();
- --_Count;
- } else {
- hr = MF_E_SAMPLEALLOCATOR_EMPTY;
- }
+ _Count = (int)m_ScheduledSamples.GetCount();
+ if (_Count > 0) {
+ *ppSample = m_ScheduledSamples.RemoveHead().Detach();
+ --_Count;
+ } else {
+ hr = MF_E_SAMPLEALLOCATOR_EMPTY;
+ }
- return hr;
+ return hr;
}
void CSyncAP::MoveToFreeList(IMFSample* pSample, bool bTail)
{
- CAutoLock lock(&m_SampleQueueLock);
- InterlockedDecrement(&m_nUsedBuffer);
- if (m_bPendingMediaFinished && m_nUsedBuffer == 0) {
- m_bPendingMediaFinished = false;
- m_pSink->Notify(EC_COMPLETE, 0, 0);
- }
- if (bTail) {
- m_FreeSamples.AddTail(pSample);
- } else {
- m_FreeSamples.AddHead(pSample);
- }
+ CAutoLock lock(&m_SampleQueueLock);
+ InterlockedDecrement(&m_nUsedBuffer);
+ if (m_bPendingMediaFinished && m_nUsedBuffer == 0) {
+ m_bPendingMediaFinished = false;
+ m_pSink->Notify(EC_COMPLETE, 0, 0);
+ }
+ if (bTail) {
+ m_FreeSamples.AddTail(pSample);
+ } else {
+ m_FreeSamples.AddHead(pSample);
+ }
}
void CSyncAP::MoveToScheduledList(IMFSample* pSample, bool _bSorted)
{
- if (_bSorted) {
- CAutoLock lock(&m_SampleQueueLock);
- m_ScheduledSamples.AddHead(pSample);
- } else {
- CAutoLock lock(&m_SampleQueueLock);
- m_ScheduledSamples.AddTail(pSample);
- }
+ if (_bSorted) {
+ CAutoLock lock(&m_SampleQueueLock);
+ m_ScheduledSamples.AddHead(pSample);
+ } else {
+ CAutoLock lock(&m_SampleQueueLock);
+ m_ScheduledSamples.AddTail(pSample);
+ }
}
void CSyncAP::FlushSamples()
{
- CAutoLock lock(this);
- CAutoLock lock2(&m_SampleQueueLock);
- FlushSamplesInternal();
+ CAutoLock lock(this);
+ CAutoLock lock2(&m_SampleQueueLock);
+ FlushSamplesInternal();
}
void CSyncAP::FlushSamplesInternal()
{
- m_bPrerolled = false;
- while (m_ScheduledSamples.GetCount() > 0) {
- CComPtr<IMFSample> pMFSample;
- pMFSample = m_ScheduledSamples.RemoveHead();
- MoveToFreeList(pMFSample, true);
- }
+ m_bPrerolled = false;
+ while (m_ScheduledSamples.GetCount() > 0) {
+ CComPtr<IMFSample> pMFSample;
+ pMFSample = m_ScheduledSamples.RemoveHead();
+ MoveToFreeList(pMFSample, true);
+ }
}
HRESULT CSyncAP::AdviseSyncClock(ISyncClock* sC)
{
- return m_pGenlock->AdviseSyncClock(sC);
+ return m_pGenlock->AdviseSyncClock(sC);
}
HRESULT CSyncAP::BeginStreaming()
{
- m_pcFramesDropped = 0;
- m_pcFramesDrawn = 0;
+ m_pcFramesDropped = 0;
+ m_pcFramesDrawn = 0;
- CComPtr<IBaseFilter> pEVR;
- FILTER_INFO filterInfo;
- ZeroMemory(&filterInfo, sizeof(filterInfo));
- m_pOuterEVR->QueryInterface (__uuidof(IBaseFilter), (void**)&pEVR);
- pEVR->QueryFilterInfo(&filterInfo); // This addref's the pGraph member
+ CComPtr<IBaseFilter> pEVR;
+ FILTER_INFO filterInfo;
+ ZeroMemory(&filterInfo, sizeof(filterInfo));
+ m_pOuterEVR->QueryInterface(__uuidof(IBaseFilter), (void**)&pEVR);
+ pEVR->QueryFilterInfo(&filterInfo); // This addref's the pGraph member
- BeginEnumFilters(filterInfo.pGraph, pEF, pBF)
- if (CComQIPtr<IAMAudioRendererStats> pAS = pBF) {
- m_pAudioStats = pAS;
- };
- EndEnumFilters
+ BeginEnumFilters(filterInfo.pGraph, pEF, pBF)
+ if (CComQIPtr<IAMAudioRendererStats> pAS = pBF) {
+ m_pAudioStats = pAS;
+ };
+ EndEnumFilters
- pEVR->GetSyncSource(&m_pRefClock);
- if (filterInfo.pGraph) {
- filterInfo.pGraph->Release();
- }
- m_pGenlock->SetMonitor(GetAdapter(m_pD3D));
- m_pGenlock->GetTiming();
+ pEVR->GetSyncSource(&m_pRefClock);
+ if (filterInfo.pGraph) {
+ filterInfo.pGraph->Release();
+ }
+ m_pGenlock->SetMonitor(GetAdapter(m_pD3D));
+ m_pGenlock->GetTiming();
- ResetStats();
- EstimateRefreshTimings();
- if (m_dFrameCycle > 0.0) {
- m_dCycleDifference = GetCycleDifference(); // Might have moved to another display
- }
- return S_OK;
+ ResetStats();
+ EstimateRefreshTimings();
+ if (m_dFrameCycle > 0.0) {
+ m_dCycleDifference = GetCycleDifference(); // Might have moved to another display
+ }
+ return S_OK;
}
HRESULT CreateSyncRenderer(const CLSID& clsid, HWND hWnd, bool bFullscreen, ISubPicAllocatorPresenter** ppAP)
{
- HRESULT hr = E_FAIL;
- if (clsid == CLSID_SyncAllocatorPresenter) {
- CString Error;
- *ppAP = DNew CSyncAP(hWnd, bFullscreen, hr, Error);
- (*ppAP)->AddRef();
+ HRESULT hr = E_FAIL;
+ if (clsid == CLSID_SyncAllocatorPresenter) {
+ CString Error;
+ *ppAP = DNew CSyncAP(hWnd, bFullscreen, hr, Error);
+ (*ppAP)->AddRef();
- if (FAILED(hr)) {
- Error += L"\n";
- Error += GetWindowsErrorMessage(hr, NULL);
- MessageBox(hWnd, Error, L"Error creating EVR Sync", MB_OK | MB_ICONERROR);
- (*ppAP)->Release();
- *ppAP = NULL;
- } else if (!Error.IsEmpty()) {
- MessageBox(hWnd, Error, L"Warning creating EVR Sync", MB_OK|MB_ICONWARNING);
- }
- }
- return hr;
+ if (FAILED(hr)) {
+ Error += L"\n";
+ Error += GetWindowsErrorMessage(hr, NULL);
+ MessageBox(hWnd, Error, L"Error creating EVR Sync", MB_OK | MB_ICONERROR);
+ (*ppAP)->Release();
+ *ppAP = NULL;
+ } else if (!Error.IsEmpty()) {
+ MessageBox(hWnd, Error, L"Warning creating EVR Sync", MB_OK | MB_ICONWARNING);
+ }
+ }
+ return hr;
}
-CSyncRenderer::CSyncRenderer(const TCHAR* pName, LPUNKNOWN pUnk, HRESULT& hr, VMR9AlphaBitmap* pVMR9AlphaBitmap, CSyncAP *pAllocatorPresenter): CUnknown(pName, pUnk)
+CSyncRenderer::CSyncRenderer(const TCHAR* pName, LPUNKNOWN pUnk, HRESULT& hr, VMR9AlphaBitmap* pVMR9AlphaBitmap, CSyncAP* pAllocatorPresenter): CUnknown(pName, pUnk)
{
- hr = m_pEVR.CoCreateInstance(CLSID_EnhancedVideoRenderer, GetOwner());
- m_pVMR9AlphaBitmap = pVMR9AlphaBitmap;
- m_pAllocatorPresenter = pAllocatorPresenter;
+ hr = m_pEVR.CoCreateInstance(CLSID_EnhancedVideoRenderer, GetOwner());
+ m_pVMR9AlphaBitmap = pVMR9AlphaBitmap;
+ m_pAllocatorPresenter = pAllocatorPresenter;
}
CSyncRenderer::~CSyncRenderer()
{
}
-HRESULT STDMETHODCALLTYPE CSyncRenderer::GetState(DWORD dwMilliSecsTimeout, __out FILTER_STATE *State)
+HRESULT STDMETHODCALLTYPE CSyncRenderer::GetState(DWORD dwMilliSecsTimeout, __out FILTER_STATE* State)
{
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR) {
- m_pEVR->QueryInterface(&pEVRBase);
- }
- if (pEVRBase) {
- return pEVRBase->GetState(dwMilliSecsTimeout, State);
- }
- return E_NOTIMPL;
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->GetState(dwMilliSecsTimeout, State);
+ }
+ return E_NOTIMPL;
}
-STDMETHODIMP CSyncRenderer::EnumPins(__out IEnumPins **ppEnum)
+STDMETHODIMP CSyncRenderer::EnumPins(__out IEnumPins** ppEnum)
{
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR) {
- m_pEVR->QueryInterface(&pEVRBase);
- }
- if (pEVRBase) {
- return pEVRBase->EnumPins(ppEnum);
- }
- return E_NOTIMPL;
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->EnumPins(ppEnum);
+ }
+ return E_NOTIMPL;
}
-STDMETHODIMP CSyncRenderer::FindPin(LPCWSTR Id, __out IPin **ppPin)
+STDMETHODIMP CSyncRenderer::FindPin(LPCWSTR Id, __out IPin** ppPin)
{
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR) {
- m_pEVR->QueryInterface(&pEVRBase);
- }
- if (pEVRBase) {
- return pEVRBase->FindPin(Id, ppPin);
- }
- return E_NOTIMPL;
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->FindPin(Id, ppPin);
+ }
+ return E_NOTIMPL;
}
-STDMETHODIMP CSyncRenderer::QueryFilterInfo(__out FILTER_INFO *pInfo)
+STDMETHODIMP CSyncRenderer::QueryFilterInfo(__out FILTER_INFO* pInfo)
{
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR) {
- m_pEVR->QueryInterface(&pEVRBase);
- }
- if (pEVRBase) {
- return pEVRBase->QueryFilterInfo(pInfo);
- }
- return E_NOTIMPL;
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->QueryFilterInfo(pInfo);
+ }
+ return E_NOTIMPL;
}
-STDMETHODIMP CSyncRenderer::JoinFilterGraph(__in_opt IFilterGraph *pGraph, __in_opt LPCWSTR pName)
+STDMETHODIMP CSyncRenderer::JoinFilterGraph(__in_opt IFilterGraph* pGraph, __in_opt LPCWSTR pName)
{
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR) {
- m_pEVR->QueryInterface(&pEVRBase);
- }
- if (pEVRBase) {
- return pEVRBase->JoinFilterGraph(pGraph, pName);
- }
- return E_NOTIMPL;
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->JoinFilterGraph(pGraph, pName);
+ }
+ return E_NOTIMPL;
}
-STDMETHODIMP CSyncRenderer::QueryVendorInfo(__out LPWSTR *pVendorInfo)
+STDMETHODIMP CSyncRenderer::QueryVendorInfo(__out LPWSTR* pVendorInfo)
{
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR) {
- m_pEVR->QueryInterface(&pEVRBase);
- }
- if (pEVRBase) {
- return pEVRBase->QueryVendorInfo(pVendorInfo);
- }
- return E_NOTIMPL;
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->QueryVendorInfo(pVendorInfo);
+ }
+ return E_NOTIMPL;
}
-STDMETHODIMP CSyncRenderer::Stop( void)
+STDMETHODIMP CSyncRenderer::Stop(void)
{
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR) {
- m_pEVR->QueryInterface(&pEVRBase);
- }
- if (pEVRBase) {
- return pEVRBase->Stop();
- }
- return E_NOTIMPL;
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->Stop();
+ }
+ return E_NOTIMPL;
}
STDMETHODIMP CSyncRenderer::Pause(void)
{
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR) {
- m_pEVR->QueryInterface(&pEVRBase);
- }
- if (pEVRBase) {
- return pEVRBase->Pause();
- }
- return E_NOTIMPL;
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->Pause();
+ }
+ return E_NOTIMPL;
}
STDMETHODIMP CSyncRenderer::Run(REFERENCE_TIME tStart)
{
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR) {
- m_pEVR->QueryInterface(&pEVRBase);
- }
- if (pEVRBase) {
- return pEVRBase->Run(tStart);
- }
- return E_NOTIMPL;
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->Run(tStart);
+ }
+ return E_NOTIMPL;
}
-STDMETHODIMP CSyncRenderer::SetSyncSource(__in_opt IReferenceClock *pClock)
+STDMETHODIMP CSyncRenderer::SetSyncSource(__in_opt IReferenceClock* pClock)
{
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR) {
- m_pEVR->QueryInterface(&pEVRBase);
- }
- if (pEVRBase) {
- return pEVRBase->SetSyncSource(pClock);
- }
- return E_NOTIMPL;
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->SetSyncSource(pClock);
+ }
+ return E_NOTIMPL;
}
-STDMETHODIMP CSyncRenderer::GetSyncSource(__deref_out_opt IReferenceClock **pClock)
+STDMETHODIMP CSyncRenderer::GetSyncSource(__deref_out_opt IReferenceClock** pClock)
{
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR) {
- m_pEVR->QueryInterface(&pEVRBase);
- }
- if (pEVRBase) {
- return pEVRBase->GetSyncSource(pClock);
- }
- return E_NOTIMPL;
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->GetSyncSource(pClock);
+ }
+ return E_NOTIMPL;
}
-STDMETHODIMP CSyncRenderer::GetClassID(__RPC__out CLSID *pClassID)
+STDMETHODIMP CSyncRenderer::GetClassID(__RPC__out CLSID* pClassID)
{
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR) {
- m_pEVR->QueryInterface(&pEVRBase);
- }
- if (pEVRBase) {
- return pEVRBase->GetClassID(pClassID);
- }
- return E_NOTIMPL;
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->GetClassID(pClassID);
+ }
+ return E_NOTIMPL;
}
STDMETHODIMP CSyncRenderer::GetAlphaBitmapParameters(VMR9AlphaBitmap* pBmpParms)
{
- CheckPointer(pBmpParms, E_POINTER);
- CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
- memcpy (pBmpParms, m_pVMR9AlphaBitmap, sizeof(VMR9AlphaBitmap));
- return S_OK;
+ CheckPointer(pBmpParms, E_POINTER);
+ CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
+ memcpy(pBmpParms, m_pVMR9AlphaBitmap, sizeof(VMR9AlphaBitmap));
+ return S_OK;
}
STDMETHODIMP CSyncRenderer::SetAlphaBitmap(const VMR9AlphaBitmap* pBmpParms)
{
- CheckPointer(pBmpParms, E_POINTER);
- CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
- memcpy (m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
- m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
- m_pAllocatorPresenter->UpdateAlphaBitmap();
- return S_OK;
+ CheckPointer(pBmpParms, E_POINTER);
+ CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
+ memcpy(m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
+ m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
+ m_pAllocatorPresenter->UpdateAlphaBitmap();
+ return S_OK;
}
STDMETHODIMP CSyncRenderer::UpdateAlphaBitmapParameters(const VMR9AlphaBitmap* pBmpParms)
{
- CheckPointer(pBmpParms, E_POINTER);
- CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
- memcpy (m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
- m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
- m_pAllocatorPresenter->UpdateAlphaBitmap();
- return S_OK;
+ CheckPointer(pBmpParms, E_POINTER);
+ CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
+ memcpy(m_pVMR9AlphaBitmap, pBmpParms, sizeof(VMR9AlphaBitmap));
+ m_pVMR9AlphaBitmap->dwFlags |= VMRBITMAP_UPDATE;
+ m_pAllocatorPresenter->UpdateAlphaBitmap();
+ return S_OK;
}
STDMETHODIMP CSyncRenderer::support_ffdshow()
{
- queue_ffdshow_support = true;
- return S_OK;
+ queue_ffdshow_support = true;
+ return S_OK;
}
STDMETHODIMP CSyncRenderer::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- HRESULT hr;
+ HRESULT hr;
- if (riid == __uuidof(IVMRMixerBitmap9)) {
- return GetInterface((IVMRMixerBitmap9*)this, ppv);
- }
+ if (riid == __uuidof(IVMRMixerBitmap9)) {
+ return GetInterface((IVMRMixerBitmap9*)this, ppv);
+ }
- if (riid == __uuidof(IBaseFilter)) {
- return GetInterface((IBaseFilter*)this, ppv);
- }
+ if (riid == __uuidof(IBaseFilter)) {
+ return GetInterface((IBaseFilter*)this, ppv);
+ }
- if (riid == __uuidof(IMediaFilter)) {
- return GetInterface((IMediaFilter*)this, ppv);
- }
- if (riid == __uuidof(IPersist)) {
- return GetInterface((IPersist*)this, ppv);
- }
- if (riid == __uuidof(IBaseFilter)) {
- return GetInterface((IBaseFilter*)this, ppv);
- }
+ if (riid == __uuidof(IMediaFilter)) {
+ return GetInterface((IMediaFilter*)this, ppv);
+ }
+ if (riid == __uuidof(IPersist)) {
+ return GetInterface((IPersist*)this, ppv);
+ }
+ if (riid == __uuidof(IBaseFilter)) {
+ return GetInterface((IBaseFilter*)this, ppv);
+ }
- hr = m_pEVR ? m_pEVR->QueryInterface(riid, ppv) : E_NOINTERFACE;
- if (m_pEVR && FAILED(hr)) {
- if (riid == __uuidof(IVMRffdshow9)) { // Support ffdshow queueing. We show ffdshow that this is patched Media Player Classic.
- return GetInterface((IVMRffdshow9*)this, ppv);
- }
- }
- return SUCCEEDED(hr) ? hr : __super::NonDelegatingQueryInterface(riid, ppv);
+ hr = m_pEVR ? m_pEVR->QueryInterface(riid, ppv) : E_NOINTERFACE;
+ if (m_pEVR && FAILED(hr)) {
+ if (riid == __uuidof(IVMRffdshow9)) { // Support ffdshow queueing. We show ffdshow that this is patched Media Player Classic.
+ return GetInterface((IVMRffdshow9*)this, ppv);
+ }
+ }
+ return SUCCEEDED(hr) ? hr : __super::NonDelegatingQueryInterface(riid, ppv);
}
CGenlock::CGenlock(DOUBLE target, DOUBLE limit, INT lineD, INT colD, DOUBLE clockD, UINT mon):
- targetSyncOffset(target), // Target sync offset, typically around 10 ms
- controlLimit(limit), // How much sync offset is allowed to drift from target sync offset before control kicks in
- lineDelta(lineD), // Number of rows used in display frequency adjustment, typically 1 (one)
- columnDelta(colD), // Number of columns used in display frequency adjustment, typically 1 - 2
- cycleDelta(clockD), // Delta used in clock speed adjustment. In fractions of 1.0. Typically around 0.001
- monitor(mon) // The monitor to be adjusted if the display refresh rate is the controlled parameter
-{
- lowSyncOffset = targetSyncOffset - controlLimit;
- highSyncOffset = targetSyncOffset + controlLimit;
- adjDelta = 0;
- displayAdjustmentsMade = 0;
- clockAdjustmentsMade = 0;
- displayFreqCruise = 0;
- displayFreqFaster = 0;
- displayFreqSlower = 0;
- curDisplayFreq = 0;
- psWnd = NULL;
- liveSource = FALSE;
- powerstripTimingExists = FALSE;
- syncOffsetFifo = DNew MovingAverage(64);
- frameCycleFifo = DNew MovingAverage(4);
+ targetSyncOffset(target), // Target sync offset, typically around 10 ms
+ controlLimit(limit), // How much sync offset is allowed to drift from target sync offset before control kicks in
+ lineDelta(lineD), // Number of rows used in display frequency adjustment, typically 1 (one)
+ columnDelta(colD), // Number of columns used in display frequency adjustment, typically 1 - 2
+ cycleDelta(clockD), // Delta used in clock speed adjustment. In fractions of 1.0. Typically around 0.001
+ monitor(mon) // The monitor to be adjusted if the display refresh rate is the controlled parameter
+{
+ lowSyncOffset = targetSyncOffset - controlLimit;
+ highSyncOffset = targetSyncOffset + controlLimit;
+ adjDelta = 0;
+ displayAdjustmentsMade = 0;
+ clockAdjustmentsMade = 0;
+ displayFreqCruise = 0;
+ displayFreqFaster = 0;
+ displayFreqSlower = 0;
+ curDisplayFreq = 0;
+ psWnd = NULL;
+ liveSource = FALSE;
+ powerstripTimingExists = FALSE;
+ syncOffsetFifo = DNew MovingAverage(64);
+ frameCycleFifo = DNew MovingAverage(4);
}
CGenlock::~CGenlock()
{
- ResetTiming();
- if (syncOffsetFifo != NULL) {
- delete syncOffsetFifo;
- syncOffsetFifo = NULL;
- }
- if (frameCycleFifo != NULL) {
- delete frameCycleFifo;
- frameCycleFifo = NULL;
- }
- syncClock = NULL;
+ ResetTiming();
+ if (syncOffsetFifo != NULL) {
+ delete syncOffsetFifo;
+ syncOffsetFifo = NULL;
+ }
+ if (frameCycleFifo != NULL) {
+ delete frameCycleFifo;
+ frameCycleFifo = NULL;
+ }
+ syncClock = NULL;
};
BOOL CGenlock::PowerstripRunning()
{
- psWnd = FindWindow(_T("TPShidden"), NULL);
- if (!psWnd) {
- return FALSE; // Powerstrip is not running
- } else {
- return TRUE;
- }
+ psWnd = FindWindow(_T("TPShidden"), NULL);
+ if (!psWnd) {
+ return FALSE; // Powerstrip is not running
+ } else {
+ return TRUE;
+ }
}
// Get the display timing parameters through PowerStrip (if running).
HRESULT CGenlock::GetTiming()
{
- ATOM getTiming;
- LPARAM lParam = NULL;
- WPARAM wParam = monitor;
- INT i = 0;
- INT j = 0;
- INT params = 0;
- TCHAR tmpStr[MAX_LOADSTRING];
-
- CAutoLock lock(&csGenlockLock);
- if (!PowerstripRunning()) {
- return E_FAIL;
- }
-
- getTiming = static_cast<ATOM>(SendMessage(psWnd, UM_GETTIMING, wParam, lParam));
- GlobalGetAtomName(getTiming, savedTiming, MAX_LOADSTRING);
-
- while (params < TIMING_PARAM_CNT) {
- while (savedTiming[i] != _T(',') && savedTiming[i] != _T('\0')) {
- tmpStr[j++] = savedTiming[i];
- tmpStr[j] = _T('\0');
- i++;
- }
- i++; // Skip trailing comma
- j = 0;
- displayTiming[params] = _ttoi(tmpStr);
- displayTimingSave[params] = displayTiming[params];
- params++;
- }
-
- // The display update frequency is controlled by adding and subtracting pixels form the
- // image. This is done by either subtracting columns or rows or both. Some displays like
- // row adjustments and some column adjustments. One should probably not do both.
- StringCchPrintf(faster, MAX_LOADSTRING, _T("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\0"),
- displayTiming[0],
- displayTiming[HFRONTPORCH] - columnDelta,
- displayTiming[2],
- displayTiming[3],
- displayTiming[4],
- displayTiming[VFRONTPORCH] - lineDelta,
- displayTiming[6],
- displayTiming[7],
- displayTiming[PIXELCLOCK],
- displayTiming[9]
- );
-
- // Nominal update frequency
- StringCchPrintf(cruise, MAX_LOADSTRING, _T("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\0"),
- displayTiming[0],
- displayTiming[HFRONTPORCH],
- displayTiming[2],
- displayTiming[3],
- displayTiming[4],
- displayTiming[VFRONTPORCH],
- displayTiming[6],
- displayTiming[7],
- displayTiming[PIXELCLOCK],
- displayTiming[9]
- );
-
- // Lower than nominal update frequency
- StringCchPrintf(slower, MAX_LOADSTRING, _T("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\0"),
- displayTiming[0],
- displayTiming[HFRONTPORCH] + columnDelta,
- displayTiming[2],
- displayTiming[3],
- displayTiming[4],
- displayTiming[VFRONTPORCH] + lineDelta,
- displayTiming[6],
- displayTiming[7],
- displayTiming[PIXELCLOCK],
- displayTiming[9]
- );
-
- totalColumns = displayTiming[HACTIVE] + displayTiming[HFRONTPORCH] + displayTiming[HSYNCWIDTH] + displayTiming[HBACKPORCH];
- totalLines = displayTiming[VACTIVE] + displayTiming[VFRONTPORCH] + displayTiming[VSYNCWIDTH] + displayTiming[VBACKPORCH];
- pixelClock = 1000 * displayTiming[PIXELCLOCK]; // Pixels/s
- displayFreqCruise = (DOUBLE)pixelClock / (totalLines * totalColumns); // Frames/s
- displayFreqSlower = (DOUBLE)pixelClock / ((totalLines + lineDelta) * (totalColumns + columnDelta));
- displayFreqFaster = (DOUBLE)pixelClock / ((totalLines - lineDelta) * (totalColumns - columnDelta));
- curDisplayFreq = displayFreqCruise;
- GlobalDeleteAtom(getTiming);
- adjDelta = 0;
- powerstripTimingExists = TRUE;
- return S_OK;
+ ATOM getTiming;
+ LPARAM lParam = NULL;
+ WPARAM wParam = monitor;
+ INT i = 0;
+ INT j = 0;
+ INT params = 0;
+ TCHAR tmpStr[MAX_LOADSTRING];
+
+ CAutoLock lock(&csGenlockLock);
+ if (!PowerstripRunning()) {
+ return E_FAIL;
+ }
+
+ getTiming = static_cast<ATOM>(SendMessage(psWnd, UM_GETTIMING, wParam, lParam));
+ GlobalGetAtomName(getTiming, savedTiming, MAX_LOADSTRING);
+
+ while (params < TIMING_PARAM_CNT) {
+ while (savedTiming[i] != _T(',') && savedTiming[i] != _T('\0')) {
+ tmpStr[j++] = savedTiming[i];
+ tmpStr[j] = _T('\0');
+ i++;
+ }
+ i++; // Skip trailing comma
+ j = 0;
+ displayTiming[params] = _ttoi(tmpStr);
+ displayTimingSave[params] = displayTiming[params];
+ params++;
+ }
+
+ // The display update frequency is controlled by adding and subtracting pixels form the
+ // image. This is done by either subtracting columns or rows or both. Some displays like
+ // row adjustments and some column adjustments. One should probably not do both.
+ StringCchPrintf(faster, MAX_LOADSTRING, _T("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\0"),
+ displayTiming[0],
+ displayTiming[HFRONTPORCH] - columnDelta,
+ displayTiming[2],
+ displayTiming[3],
+ displayTiming[4],
+ displayTiming[VFRONTPORCH] - lineDelta,
+ displayTiming[6],
+ displayTiming[7],
+ displayTiming[PIXELCLOCK],
+ displayTiming[9]
+ );
+
+ // Nominal update frequency
+ StringCchPrintf(cruise, MAX_LOADSTRING, _T("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\0"),
+ displayTiming[0],
+ displayTiming[HFRONTPORCH],
+ displayTiming[2],
+ displayTiming[3],
+ displayTiming[4],
+ displayTiming[VFRONTPORCH],
+ displayTiming[6],
+ displayTiming[7],
+ displayTiming[PIXELCLOCK],
+ displayTiming[9]
+ );
+
+ // Lower than nominal update frequency
+ StringCchPrintf(slower, MAX_LOADSTRING, _T("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\0"),
+ displayTiming[0],
+ displayTiming[HFRONTPORCH] + columnDelta,
+ displayTiming[2],
+ displayTiming[3],
+ displayTiming[4],
+ displayTiming[VFRONTPORCH] + lineDelta,
+ displayTiming[6],
+ displayTiming[7],
+ displayTiming[PIXELCLOCK],
+ displayTiming[9]
+ );
+
+ totalColumns = displayTiming[HACTIVE] + displayTiming[HFRONTPORCH] + displayTiming[HSYNCWIDTH] + displayTiming[HBACKPORCH];
+ totalLines = displayTiming[VACTIVE] + displayTiming[VFRONTPORCH] + displayTiming[VSYNCWIDTH] + displayTiming[VBACKPORCH];
+ pixelClock = 1000 * displayTiming[PIXELCLOCK]; // Pixels/s
+ displayFreqCruise = (DOUBLE)pixelClock / (totalLines * totalColumns); // Frames/s
+ displayFreqSlower = (DOUBLE)pixelClock / ((totalLines + lineDelta) * (totalColumns + columnDelta));
+ displayFreqFaster = (DOUBLE)pixelClock / ((totalLines - lineDelta) * (totalColumns - columnDelta));
+ curDisplayFreq = displayFreqCruise;
+ GlobalDeleteAtom(getTiming);
+ adjDelta = 0;
+ powerstripTimingExists = TRUE;
+ return S_OK;
}
// Reset display timing parameters to nominal.
HRESULT CGenlock::ResetTiming()
{
- LPARAM lParam = NULL;
- WPARAM wParam = monitor;
- ATOM setTiming;
- LRESULT ret;
- CAutoLock lock(&csGenlockLock);
+ LPARAM lParam = NULL;
+ WPARAM wParam = monitor;
+ ATOM setTiming;
+ LRESULT ret;
+ CAutoLock lock(&csGenlockLock);
- if (!PowerstripRunning()) {
- return E_FAIL;
- }
+ if (!PowerstripRunning()) {
+ return E_FAIL;
+ }
- if (displayAdjustmentsMade > 0) {
- setTiming = GlobalAddAtom(cruise);
- lParam = setTiming;
- ret = SendMessage(psWnd, UM_SETCUSTOMTIMINGFAST, wParam, lParam);
- GlobalDeleteAtom(setTiming);
- curDisplayFreq = displayFreqCruise;
- }
- adjDelta = 0;
- return S_OK;
+ if (displayAdjustmentsMade > 0) {
+ setTiming = GlobalAddAtom(cruise);
+ lParam = setTiming;
+ ret = SendMessage(psWnd, UM_SETCUSTOMTIMINGFAST, wParam, lParam);
+ GlobalDeleteAtom(setTiming);
+ curDisplayFreq = displayFreqCruise;
+ }
+ adjDelta = 0;
+ return S_OK;
}
// Reset reference clock speed to nominal.
HRESULT CGenlock::ResetClock()
{
- adjDelta = 0;
- if (syncClock == NULL) {
- return E_FAIL;
- } else {
- return syncClock->AdjustClock(1.0);
- }
+ adjDelta = 0;
+ if (syncClock == NULL) {
+ return E_FAIL;
+ } else {
+ return syncClock->AdjustClock(1.0);
+ }
}
HRESULT CGenlock::SetTargetSyncOffset(DOUBLE targetD)
{
- targetSyncOffset = targetD;
- lowSyncOffset = targetD - controlLimit;
- highSyncOffset = targetD + controlLimit;
- return S_OK;
+ targetSyncOffset = targetD;
+ lowSyncOffset = targetD - controlLimit;
+ highSyncOffset = targetD + controlLimit;
+ return S_OK;
}
-HRESULT CGenlock::GetTargetSyncOffset(DOUBLE *targetD)
+HRESULT CGenlock::GetTargetSyncOffset(DOUBLE* targetD)
{
- *targetD = targetSyncOffset;
- return S_OK;
+ *targetD = targetSyncOffset;
+ return S_OK;
}
HRESULT CGenlock::SetControlLimit(DOUBLE cL)
{
- controlLimit = cL;
- return S_OK;
+ controlLimit = cL;
+ return S_OK;
}
-HRESULT CGenlock::GetControlLimit(DOUBLE *cL)
+HRESULT CGenlock::GetControlLimit(DOUBLE* cL)
{
- *cL = controlLimit;
- return S_OK;
+ *cL = controlLimit;
+ return S_OK;
}
HRESULT CGenlock::SetDisplayResolution(UINT columns, UINT lines)
{
- visibleColumns = columns;
- visibleLines = lines;
- return S_OK;
+ visibleColumns = columns;
+ visibleLines = lines;
+ return S_OK;
}
HRESULT CGenlock::AdviseSyncClock(ISyncClock* sC)
{
- if (!sC) {
- return E_FAIL;
- }
- if (syncClock) {
- syncClock = NULL; // Release any outstanding references if this is called repeatedly
- }
- syncClock = sC;
- return S_OK;
+ if (!sC) {
+ return E_FAIL;
+ }
+ if (syncClock) {
+ syncClock = NULL; // Release any outstanding references if this is called repeatedly
+ }
+ syncClock = sC;
+ return S_OK;
}
// Set the monitor to control. This is best done manually as not all monitors can be controlled
@@ -4379,141 +4382,141 @@ HRESULT CGenlock::AdviseSyncClock(ISyncClock* sC)
// The PowerStrip API uses zero-based monitor numbers, i.e. the default monitor is 0.
HRESULT CGenlock::SetMonitor(UINT mon)
{
- monitor = mon;
- return S_OK;
+ monitor = mon;
+ return S_OK;
}
HRESULT CGenlock::ResetStats()
{
- CAutoLock lock(&csGenlockLock);
- minSyncOffset = 1000000.0;
- maxSyncOffset = -1000000.0;
- minFrameCycle = 1000000.0;
- maxFrameCycle = -1000000.0;
- displayAdjustmentsMade = 0;
- clockAdjustmentsMade = 0;
- return S_OK;
+ CAutoLock lock(&csGenlockLock);
+ minSyncOffset = 1000000.0;
+ maxSyncOffset = -1000000.0;
+ minFrameCycle = 1000000.0;
+ maxFrameCycle = -1000000.0;
+ displayAdjustmentsMade = 0;
+ clockAdjustmentsMade = 0;
+ return S_OK;
}
// Synchronize by adjusting display refresh rate
HRESULT CGenlock::ControlDisplay(double syncOffset, double frameCycle)
{
- LPARAM lParam = NULL;
- WPARAM wParam = monitor;
- ATOM setTiming;
-
- CRenderersSettings& s = GetRenderersSettings();
- targetSyncOffset = s.m_RenderSettings.fTargetSyncOffset;
- lowSyncOffset = targetSyncOffset - s.m_RenderSettings.fControlLimit;
- highSyncOffset = targetSyncOffset + s.m_RenderSettings.fControlLimit;
-
- syncOffsetAvg = syncOffsetFifo->Average(syncOffset);
- minSyncOffset = min(minSyncOffset, syncOffset);
- maxSyncOffset = max(maxSyncOffset, syncOffset);
- frameCycleAvg = frameCycleFifo->Average(frameCycle);
- minFrameCycle = min(minFrameCycle, frameCycle);
- maxFrameCycle = max(maxFrameCycle, frameCycle);
-
- if (!PowerstripRunning() || !powerstripTimingExists) {
- return E_FAIL;
- }
- // Adjust as seldom as possible by checking the current controlState before changing it.
- if ((syncOffsetAvg > highSyncOffset) && (adjDelta != 1))
- // Speed up display refresh rate by subtracting pixels from the image.
- {
- adjDelta = 1; // Increase refresh rate
- curDisplayFreq = displayFreqFaster;
- setTiming = GlobalAddAtom(faster);
- lParam = setTiming;
- SendMessage(psWnd, UM_SETCUSTOMTIMINGFAST, wParam, lParam);
- GlobalDeleteAtom(setTiming);
- displayAdjustmentsMade++;
- } else
- // Slow down display refresh rate by adding pixels to the image.
- if ((syncOffsetAvg < lowSyncOffset) && (adjDelta != -1)) {
- adjDelta = -1;
- curDisplayFreq = displayFreqSlower;
- setTiming = GlobalAddAtom(slower);
- lParam = setTiming;
- SendMessage(psWnd, UM_SETCUSTOMTIMINGFAST, wParam, lParam);
- GlobalDeleteAtom(setTiming);
- displayAdjustmentsMade++;
- } else
- // Cruise.
- if ((syncOffsetAvg < targetSyncOffset) && (adjDelta == 1)) {
- adjDelta = 0;
- curDisplayFreq = displayFreqCruise;
- setTiming = GlobalAddAtom(cruise);
- lParam = setTiming;
- SendMessage(psWnd, UM_SETCUSTOMTIMINGFAST, wParam, lParam);
- GlobalDeleteAtom(setTiming);
- displayAdjustmentsMade++;
- } else if ((syncOffsetAvg > targetSyncOffset) && (adjDelta == -1)) {
- adjDelta = 0;
- curDisplayFreq = displayFreqCruise;
- setTiming = GlobalAddAtom(cruise);
- lParam = setTiming;
- SendMessage(psWnd, UM_SETCUSTOMTIMINGFAST, wParam, lParam);
- GlobalDeleteAtom(setTiming);
- displayAdjustmentsMade++;
- }
- return S_OK;
+ LPARAM lParam = NULL;
+ WPARAM wParam = monitor;
+ ATOM setTiming;
+
+ CRenderersSettings& s = GetRenderersSettings();
+ targetSyncOffset = s.m_RenderSettings.fTargetSyncOffset;
+ lowSyncOffset = targetSyncOffset - s.m_RenderSettings.fControlLimit;
+ highSyncOffset = targetSyncOffset + s.m_RenderSettings.fControlLimit;
+
+ syncOffsetAvg = syncOffsetFifo->Average(syncOffset);
+ minSyncOffset = min(minSyncOffset, syncOffset);
+ maxSyncOffset = max(maxSyncOffset, syncOffset);
+ frameCycleAvg = frameCycleFifo->Average(frameCycle);
+ minFrameCycle = min(minFrameCycle, frameCycle);
+ maxFrameCycle = max(maxFrameCycle, frameCycle);
+
+ if (!PowerstripRunning() || !powerstripTimingExists) {
+ return E_FAIL;
+ }
+ // Adjust as seldom as possible by checking the current controlState before changing it.
+ if ((syncOffsetAvg > highSyncOffset) && (adjDelta != 1))
+ // Speed up display refresh rate by subtracting pixels from the image.
+ {
+ adjDelta = 1; // Increase refresh rate
+ curDisplayFreq = displayFreqFaster;
+ setTiming = GlobalAddAtom(faster);
+ lParam = setTiming;
+ SendMessage(psWnd, UM_SETCUSTOMTIMINGFAST, wParam, lParam);
+ GlobalDeleteAtom(setTiming);
+ displayAdjustmentsMade++;
+ } else
+ // Slow down display refresh rate by adding pixels to the image.
+ if ((syncOffsetAvg < lowSyncOffset) && (adjDelta != -1)) {
+ adjDelta = -1;
+ curDisplayFreq = displayFreqSlower;
+ setTiming = GlobalAddAtom(slower);
+ lParam = setTiming;
+ SendMessage(psWnd, UM_SETCUSTOMTIMINGFAST, wParam, lParam);
+ GlobalDeleteAtom(setTiming);
+ displayAdjustmentsMade++;
+ } else
+ // Cruise.
+ if ((syncOffsetAvg < targetSyncOffset) && (adjDelta == 1)) {
+ adjDelta = 0;
+ curDisplayFreq = displayFreqCruise;
+ setTiming = GlobalAddAtom(cruise);
+ lParam = setTiming;
+ SendMessage(psWnd, UM_SETCUSTOMTIMINGFAST, wParam, lParam);
+ GlobalDeleteAtom(setTiming);
+ displayAdjustmentsMade++;
+ } else if ((syncOffsetAvg > targetSyncOffset) && (adjDelta == -1)) {
+ adjDelta = 0;
+ curDisplayFreq = displayFreqCruise;
+ setTiming = GlobalAddAtom(cruise);
+ lParam = setTiming;
+ SendMessage(psWnd, UM_SETCUSTOMTIMINGFAST, wParam, lParam);
+ GlobalDeleteAtom(setTiming);
+ displayAdjustmentsMade++;
+ }
+ return S_OK;
}
// Synchronize by adjusting reference clock rate (and therefore video FPS).
// Todo: check so that we don't have a live source
HRESULT CGenlock::ControlClock(double syncOffset, double frameCycle)
{
- CRenderersSettings& s = GetRenderersSettings();
- targetSyncOffset = s.m_RenderSettings.fTargetSyncOffset;
- lowSyncOffset = targetSyncOffset - s.m_RenderSettings.fControlLimit;
- highSyncOffset = targetSyncOffset + s.m_RenderSettings.fControlLimit;
-
- syncOffsetAvg = syncOffsetFifo->Average(syncOffset);
- minSyncOffset = min(minSyncOffset, syncOffset);
- maxSyncOffset = max(maxSyncOffset, syncOffset);
- frameCycleAvg = frameCycleFifo->Average(frameCycle);
- minFrameCycle = min(minFrameCycle, frameCycle);
- maxFrameCycle = max(maxFrameCycle, frameCycle);
-
- if (!syncClock) {
- return E_FAIL;
- }
- // Adjust as seldom as possible by checking the current controlState before changing it.
- if ((syncOffsetAvg > highSyncOffset) && (adjDelta != 1))
- // Slow down video stream.
- {
- adjDelta = 1;
- syncClock->AdjustClock(1.0 - cycleDelta); // Makes the clock move slower by providing smaller increments
- clockAdjustmentsMade++;
- } else
- // Speed up video stream.
- if ((syncOffsetAvg < lowSyncOffset) && (adjDelta != -1)) {
- adjDelta = -1;
- syncClock->AdjustClock(1.0 + cycleDelta);
- clockAdjustmentsMade++;
- } else
- // Cruise.
- if ((syncOffsetAvg < targetSyncOffset) && (adjDelta == 1)) {
- adjDelta = 0;
- syncClock->AdjustClock(1.0);
- clockAdjustmentsMade++;
- } else if ((syncOffsetAvg > targetSyncOffset) && (adjDelta == -1)) {
- adjDelta = 0;
- syncClock->AdjustClock(1.0);
- clockAdjustmentsMade++;
- }
- return S_OK;
+ CRenderersSettings& s = GetRenderersSettings();
+ targetSyncOffset = s.m_RenderSettings.fTargetSyncOffset;
+ lowSyncOffset = targetSyncOffset - s.m_RenderSettings.fControlLimit;
+ highSyncOffset = targetSyncOffset + s.m_RenderSettings.fControlLimit;
+
+ syncOffsetAvg = syncOffsetFifo->Average(syncOffset);
+ minSyncOffset = min(minSyncOffset, syncOffset);
+ maxSyncOffset = max(maxSyncOffset, syncOffset);
+ frameCycleAvg = frameCycleFifo->Average(frameCycle);
+ minFrameCycle = min(minFrameCycle, frameCycle);
+ maxFrameCycle = max(maxFrameCycle, frameCycle);
+
+ if (!syncClock) {
+ return E_FAIL;
+ }
+ // Adjust as seldom as possible by checking the current controlState before changing it.
+ if ((syncOffsetAvg > highSyncOffset) && (adjDelta != 1))
+ // Slow down video stream.
+ {
+ adjDelta = 1;
+ syncClock->AdjustClock(1.0 - cycleDelta); // Makes the clock move slower by providing smaller increments
+ clockAdjustmentsMade++;
+ } else
+ // Speed up video stream.
+ if ((syncOffsetAvg < lowSyncOffset) && (adjDelta != -1)) {
+ adjDelta = -1;
+ syncClock->AdjustClock(1.0 + cycleDelta);
+ clockAdjustmentsMade++;
+ } else
+ // Cruise.
+ if ((syncOffsetAvg < targetSyncOffset) && (adjDelta == 1)) {
+ adjDelta = 0;
+ syncClock->AdjustClock(1.0);
+ clockAdjustmentsMade++;
+ } else if ((syncOffsetAvg > targetSyncOffset) && (adjDelta == -1)) {
+ adjDelta = 0;
+ syncClock->AdjustClock(1.0);
+ clockAdjustmentsMade++;
+ }
+ return S_OK;
}
// Don't adjust anything, just update the syncOffset stats
HRESULT CGenlock::UpdateStats(double syncOffset, double frameCycle)
{
- syncOffsetAvg = syncOffsetFifo->Average(syncOffset);
- minSyncOffset = min(minSyncOffset, syncOffset);
- maxSyncOffset = max(maxSyncOffset, syncOffset);
- frameCycleAvg = frameCycleFifo->Average(frameCycle);
- minFrameCycle = min(minFrameCycle, frameCycle);
- maxFrameCycle = max(maxFrameCycle, frameCycle);
- return S_OK;
+ syncOffsetAvg = syncOffsetFifo->Average(syncOffset);
+ minSyncOffset = min(minSyncOffset, syncOffset);
+ maxSyncOffset = max(maxSyncOffset, syncOffset);
+ frameCycleAvg = frameCycleFifo->Average(frameCycle);
+ minFrameCycle = min(minFrameCycle, frameCycle);
+ maxFrameCycle = max(maxFrameCycle, frameCycle);
+ return S_OK;
} \ No newline at end of file
diff --git a/src/filters/renderer/VideoRenderers/SyncRenderer.h b/src/filters/renderer/VideoRenderers/SyncRenderer.h
index 337defcd9..fed422851 100644
--- a/src/filters/renderer/VideoRenderers/SyncRenderer.h
+++ b/src/filters/renderer/VideoRenderers/SyncRenderer.h
@@ -76,610 +76,610 @@ static const GUID GUID_SURFACE_INDEX = { 0x30c8e9f6, 0x415, 0x4b81, { 0xa3, 0x15
namespace GothSync
{
- typedef enum {
- MSG_MIXERIN,
- MSG_MIXEROUT,
- MSG_ERROR
- } EVR_STATS_MSG;
+ typedef enum {
+ MSG_MIXERIN,
+ MSG_MIXEROUT,
+ MSG_ERROR
+ } EVR_STATS_MSG;
#pragma pack(push, 1)
- template<int texcoords>
- struct MYD3DVERTEX {
- float x, y, z, rhw;
- struct {
- float u, v;
- } t[texcoords];
- };
+ template<int texcoords>
+ struct MYD3DVERTEX {
+ float x, y, z, rhw;
+ struct {
+ float u, v;
+ } t[texcoords];
+ };
- template<>
- struct MYD3DVERTEX<0> {
- float x, y, z, rhw;
- DWORD Diffuse;
- };
+ template<>
+ struct MYD3DVERTEX<0> {
+ float x, y, z, rhw;
+ DWORD Diffuse;
+ };
#pragma pack(pop)
- class CGenlock;
- class CSyncRenderer;
-
- // Base allocator-presenter
- class CBaseAP:
- public CSubPicAllocatorPresenterImpl
- {
- protected:
- CRenderersSettings::CRendererSettingsEVR m_LastRendererSettings;
-
- HMODULE m_hDWMAPI;
- HRESULT (__stdcall * m_pDwmIsCompositionEnabled)(__out BOOL* pfEnabled);
- HRESULT (__stdcall * m_pDwmEnableComposition)(UINT uCompositionAction);
- HMODULE m_hD3D9;
- HRESULT (__stdcall * m_pDirect3DCreate9Ex)(UINT SDKVersion, IDirect3D9Ex**);
-
- CCritSec m_allocatorLock;
- CComPtr<IDirect3D9Ex> m_pD3DEx;
- CComPtr<IDirect3D9> m_pD3D;
- CComPtr<IDirect3DDevice9Ex> m_pD3DDevEx;
- CComPtr<IDirect3DDevice9> m_pD3DDev;
-
- CComPtr<IDirect3DTexture9> m_pVideoTexture[MAX_PICTURE_SLOTS];
- CComPtr<IDirect3DSurface9> m_pVideoSurface[MAX_PICTURE_SLOTS];
- CComPtr<IDirect3DTexture9> m_pOSDTexture;
- CComPtr<IDirect3DSurface9> m_pOSDSurface;
- CComPtr<ID3DXLine> m_pLine;
- CComPtr<ID3DXFont> m_pFont;
- CComPtr<ID3DXSprite> m_pSprite;
- CSyncRenderer *m_pOuterEVR;
-
- class CExternalPixelShader
- {
- public:
- CComPtr<IDirect3DPixelShader9> m_pPixelShader;
- CStringA m_SourceData;
- CStringA m_SourceTarget;
- HRESULT Compile(CPixelShaderCompiler *pCompiler) {
- HRESULT hr = pCompiler->CompileShader(m_SourceData, "main", m_SourceTarget, 0, &m_pPixelShader);
- if (FAILED(hr)) {
- return hr;
- }
- return S_OK;
- }
- };
-
- CAutoPtr<CPixelShaderCompiler> m_pPSC;
- CAtlList<CExternalPixelShader> m_pPixelShaders;
- CAtlList<CExternalPixelShader> m_pPixelShadersScreenSpace;
- CComPtr<IDirect3DPixelShader9> m_pResizerPixelShader[4]; // bl, bc1, bc2_1, bc2_2
- CComPtr<IDirect3DTexture9> m_pScreenSizeTemporaryTexture[2];
-
- D3DFORMAT m_SurfaceType;
- D3DFORMAT m_BackbufferType;
- D3DFORMAT m_DisplayType;
- D3DTEXTUREFILTERTYPE m_filter;
- D3DCAPS9 m_caps;
- D3DPRESENT_PARAMETERS pp;
-
- bool SettingsNeedResetDevice();
- void SendResetRequest();
- virtual HRESULT CreateDXDevice(CString &_Error);
- virtual HRESULT ResetDXDevice(CString &_Error);
- virtual HRESULT AllocSurfaces(D3DFORMAT Format = D3DFMT_A8R8G8B8);
- virtual void DeleteSurfaces();
-
- HANDLE m_hEvtQuit; // Stop rendering thread event
- LONGLONG m_LastAdapterCheck;
- UINT m_CurrentAdapter;
- UINT GetAdapter(IDirect3D9 *pD3D);
-
- float m_bicubicA;
- HRESULT InitResizers(float bicubicA, bool bNeedScreenSizeTexture);
-
- // Functions to trace timing performance
- void SyncStats(LONGLONG syncTime);
- void SyncOffsetStats(LONGLONG syncOffset);
- void DrawText(const RECT &rc, const CString &strText, int _Priority);
- void DrawStats();
-
- template<int texcoords>
- void AdjustQuad(MYD3DVERTEX<texcoords>* v, double dx, double dy);
- template<int texcoords>
- HRESULT TextureBlt(IDirect3DDevice9* pD3DDev, MYD3DVERTEX<texcoords> v[4], D3DTEXTUREFILTERTYPE filter);
- MFOffset GetOffset(float v);
- MFVideoArea GetArea(float x, float y, DWORD width, DWORD height);
- bool ClipToSurface(IDirect3DSurface9* pSurface, CRect& s, CRect& d);
-
- HRESULT DrawRectBase(IDirect3DDevice9* pD3DDev, MYD3DVERTEX<0> v[4]);
- HRESULT DrawRect(DWORD _Color, DWORD _Alpha, const CRect &_Rect);
- HRESULT TextureCopy(IDirect3DTexture9* pTexture);
- HRESULT TextureResize(IDirect3DTexture9* pTexture, Vector dst[4], D3DTEXTUREFILTERTYPE filter, const CRect &SrcRect);
- HRESULT TextureResizeBilinear(IDirect3DTexture9* pTexture, Vector dst[4], const CRect &SrcRect);
- HRESULT TextureResizeBicubic1pass(IDirect3DTexture9* pTexture, Vector dst[4], const CRect &SrcRect);
- HRESULT TextureResizeBicubic2pass(IDirect3DTexture9* pTexture, Vector dst[4], const CRect &SrcRect);
-
- typedef HRESULT (WINAPI * D3DXLoadSurfaceFromMemoryPtr)(
- LPDIRECT3DSURFACE9 pDestSurface,
- CONST PALETTEENTRY* pDestPalette,
- CONST RECT* pDestRect,
- LPCVOID pSrcMemory,
- D3DFORMAT SrcFormat,
- UINT SrcPitch,
- CONST PALETTEENTRY* pSrcPalette,
- CONST RECT* pSrcRect,
- DWORD Filter,
- D3DCOLOR ColorKey);
-
- typedef HRESULT (WINAPI* D3DXCreateLinePtr)
- (LPDIRECT3DDEVICE9 pDevice,
- LPD3DXLINE* ppLine);
-
- typedef HRESULT (WINAPI* D3DXCreateFontPtr)(
- LPDIRECT3DDEVICE9 pDevice,
- int Height,
- UINT Width,
- UINT Weight,
- UINT MipLevels,
- bool Italic,
- DWORD CharSet,
- DWORD OutputPrecision,
- DWORD Quality,
- DWORD PitchAndFamily,
- LPCWSTR pFaceName,
- LPD3DXFONT* ppFont);
-
- HRESULT AlphaBlt(RECT* pSrc, RECT* pDst, IDirect3DTexture9* pTexture);
-
- virtual void OnResetDevice() {};
-
- int m_nTearingPos;
- VMR9AlphaBitmap m_VMR9AlphaBitmap;
- CAutoVectorPtr<BYTE> m_VMR9AlphaBitmapData;
- CRect m_VMR9AlphaBitmapRect;
- int m_VMR9AlphaBitmapWidthBytes;
-
- D3DXLoadSurfaceFromMemoryPtr m_pD3DXLoadSurfaceFromMemory;
- D3DXCreateLinePtr m_pD3DXCreateLine;
- D3DXCreateFontPtr m_pD3DXCreateFont;
- HRESULT (__stdcall *m_pD3DXCreateSprite)(LPDIRECT3DDEVICE9 pDevice, LPD3DXSPRITE * ppSprite);
-
- int m_nDXSurface; // Total number of DX Surfaces
- int m_nVMR9Surfaces;
- int m_iVMR9Surface;
- int m_nCurSurface; // Surface currently displayed
- long m_nUsedBuffer;
-
- LONG m_lNextSampleWait; // Waiting time for next sample in EVR
- bool m_bSnapToVSync; // True if framerate is low enough so that snap to vsync makes sense
-
- UINT m_uScanLineEnteringPaint; // The active scan line when entering Paint()
- REFERENCE_TIME m_llEstVBlankTime; // Next vblank start time in reference clock "coordinates"
-
- double m_fAvrFps; // Estimate the true FPS as given by the distance between vsyncs when a frame has been presented
- double m_fJitterStdDev; // VSync estimate std dev
- double m_fJitterMean; // Mean time between two syncpulses when a frame has been presented (i.e. when Paint() has been called
-
- double m_fSyncOffsetAvr; // Mean time between the call of Paint() and vsync. To avoid tearing this should be several ms at least
- double m_fSyncOffsetStdDev; // The std dev of the above
-
- bool m_bHighColorResolution;
- bool m_bCompositionEnabled;
- bool m_bDesktopCompositionDisabled;
- bool m_bIsFullscreen;
- bool m_bNeedCheckSample;
- DWORD m_dMainThreadId;
-
- CSize m_ScreenSize;
-
- // Display and frame rates and cycles
- double m_dDetectedScanlineTime; // Time for one (horizontal) scan line. Extracted at stream start and used to calculate vsync time
- UINT m_uD3DRefreshRate; // As got when creating the d3d device
- double m_dD3DRefreshCycle; // Display refresh cycle ms
- double m_dEstRefreshCycle; // As estimated from scan lines
- double m_dFrameCycle; // Average sample time, extracted from the samples themselves
- // double m_fps is defined in ISubPic.h
- double m_dOptimumDisplayCycle; // The display cycle that is closest to the frame rate. A multiple of the actual display cycle
- double m_dCycleDifference; // Difference in video and display cycle time relative to the video cycle time
-
- UINT m_pcFramesDropped;
- UINT m_pcFramesDuplicated;
- UINT m_pcFramesDrawn;
-
- LONGLONG m_pllJitter [NB_JITTER]; // Vertical sync time stats
- LONGLONG m_pllSyncOffset [NB_JITTER]; // Sync offset time stats
- int m_nNextJitter;
- int m_nNextSyncOffset;
- LONGLONG m_JitterStdDev;
-
- LONGLONG m_llLastSyncTime;
-
- LONGLONG m_MaxJitter;
- LONGLONG m_MinJitter;
- LONGLONG m_MaxSyncOffset;
- LONGLONG m_MinSyncOffset;
- UINT m_uSyncGlitches;
-
- LONGLONG m_llSampleTime, m_llLastSampleTime; // Present time for the current sample
- LONG m_lSampleLatency, m_lLastSampleLatency; // Time between intended and actual presentation time
- LONG m_lMinSampleLatency, m_lLastMinSampleLatency;
- LONGLONG m_llHysteresis;
- LONG m_lHysteresis;
- LONG m_lShiftToNearest, m_lShiftToNearestPrev;
- bool m_bVideoSlowerThanDisplay;
-
- int m_bInterlaced;
- double m_TextScale;
- CString m_strStatsMsg[10];
-
- CGenlock *m_pGenlock; // The video - display synchronizer class
- CComPtr<IReferenceClock> m_pRefClock; // The reference clock. Used in Paint()
- CComPtr<IAMAudioRendererStats> m_pAudioStats; // Audio statistics from audio renderer. To check so that audio is in sync
- DWORD m_lAudioLag; // Time difference between audio and video when the audio renderer is matching rate to the external reference clock
- long m_lAudioLagMin, m_lAudioLagMax; // The accumulated difference between the audio renderer and the master clock
- DWORD m_lAudioSlaveMode; // To check whether the audio renderer matches rate with SyncClock (returns the value 4 if it does)
-
- double GetRefreshRate(); // Get the best estimate of the display refresh rate in Hz
- double GetDisplayCycle(); // Get the best estimate of the display cycle time in milliseconds
- double GetCycleDifference(); // Get the difference in video and display cycle times.
- void EstimateRefreshTimings(); // Estimate the times for one scan line and one frame respectively from the actual refresh data
- bool ExtractInterlaced(const AM_MEDIA_TYPE* pmt);
-
- public:
- CBaseAP(HWND hWnd, bool bFullscreen, HRESULT& hr, CString &_Error);
- ~CBaseAP();
-
- CCritSec m_VMR9AlphaBitmapLock;
- void UpdateAlphaBitmap();
- void ResetStats();
-
- // ISubPicAllocatorPresenter
- STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
- STDMETHODIMP_(bool) Paint(bool fAll);
- STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size);
- STDMETHODIMP SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget);
- STDMETHODIMP SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace);
- STDMETHODIMP_(bool) ResetDevice();
- STDMETHODIMP_(bool) DisplayChange();
- };
-
- class CSyncAP:
- public CBaseAP,
- public IMFGetService,
- public IMFTopologyServiceLookupClient,
- public IMFVideoDeviceID,
- public IMFVideoPresenter,
- public IDirect3DDeviceManager9,
- public IMFAsyncCallback,
- public IQualProp,
- public IMFRateSupport,
- public IMFVideoDisplayControl,
- public IEVRTrustedVideoPlugin,
- public ISyncClockAdviser
-
- {
- public:
- CSyncAP(HWND hWnd, bool bFullscreen, HRESULT& hr, CString &_Error);
- ~CSyncAP(void);
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
- STDMETHODIMP_(bool) Paint(bool fAll);
- STDMETHODIMP GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight);
- STDMETHODIMP InitializeDevice(AM_MEDIA_TYPE* pMediaType);
- STDMETHODIMP_(bool) ResetDevice();
-
- // IMFClockStateSink
- STDMETHODIMP OnClockStart(MFTIME hnsSystemTime, LONGLONG llClockStartOffset);
- STDMETHODIMP OnClockStop(MFTIME hnsSystemTime);
- STDMETHODIMP OnClockPause(MFTIME hnsSystemTime);
- STDMETHODIMP OnClockRestart(MFTIME hnsSystemTime);
- STDMETHODIMP OnClockSetRate(MFTIME hnsSystemTime, float flRate);
-
- // IBaseFilter delegate
- bool GetState( DWORD dwMilliSecsTimeout, FILTER_STATE *State, HRESULT &_ReturnValue);
-
- // IQualProp (EVR statistics window). These are incompletely implemented currently
- STDMETHODIMP get_FramesDroppedInRenderer(int *pcFrames);
- STDMETHODIMP get_FramesDrawn(int *pcFramesDrawn);
- STDMETHODIMP get_AvgFrameRate(int *piAvgFrameRate);
- STDMETHODIMP get_Jitter(int *iJitter);
- STDMETHODIMP get_AvgSyncOffset(int *piAvg);
- STDMETHODIMP get_DevSyncOffset(int *piDev);
-
- // IMFRateSupport
- STDMETHODIMP GetSlowestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float *pflRate);
- STDMETHODIMP GetFastestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float *pflRate);
- STDMETHODIMP IsRateSupported(BOOL fThin, float flRate, float *pflNearestSupportedRate);
- float GetMaxRate(BOOL bThin);
-
- // IMFVideoPresenter
- STDMETHODIMP ProcessMessage(MFVP_MESSAGE_TYPE eMessage, ULONG_PTR ulParam);
- STDMETHODIMP GetCurrentMediaType(__deref_out IMFVideoMediaType **ppMediaType);
-
- // IMFTopologyServiceLookupClient
- STDMETHODIMP InitServicePointers(__in IMFTopologyServiceLookup *pLookup);
- STDMETHODIMP ReleaseServicePointers();
-
- // IMFVideoDeviceID
- STDMETHODIMP GetDeviceID(__out IID *pDeviceID);
-
- // IMFGetService
- STDMETHODIMP GetService (__RPC__in REFGUID guidService, __RPC__in REFIID riid, __RPC__deref_out_opt LPVOID *ppvObject);
-
- // IMFAsyncCallback
- STDMETHODIMP GetParameters(__RPC__out DWORD *pdwFlags, /* [out] */ __RPC__out DWORD *pdwQueue);
- STDMETHODIMP Invoke(__RPC__in_opt IMFAsyncResult *pAsyncResult);
-
- // IMFVideoDisplayControl
- STDMETHODIMP GetNativeVideoSize(SIZE *pszVideo, SIZE *pszARVideo);
- STDMETHODIMP GetIdealVideoSize(SIZE *pszMin, SIZE *pszMax);
- STDMETHODIMP SetVideoPosition(const MFVideoNormalizedRect *pnrcSource, const LPRECT prcDest);
- STDMETHODIMP GetVideoPosition(MFVideoNormalizedRect *pnrcSource, LPRECT prcDest);
- STDMETHODIMP SetAspectRatioMode(DWORD dwAspectRatioMode);
- STDMETHODIMP GetAspectRatioMode(DWORD *pdwAspectRatioMode);
- STDMETHODIMP SetVideoWindow(HWND hwndVideo);
- STDMETHODIMP GetVideoWindow(HWND *phwndVideo);
- STDMETHODIMP RepaintVideo( void);
- STDMETHODIMP GetCurrentImage(BITMAPINFOHEADER *pBih, BYTE **pDib, DWORD *pcbDib, LONGLONG *pTimeStamp);
- STDMETHODIMP SetBorderColor(COLORREF Clr);
- STDMETHODIMP GetBorderColor(COLORREF *pClr);
- STDMETHODIMP SetRenderingPrefs(DWORD dwRenderFlags);
- STDMETHODIMP GetRenderingPrefs(DWORD *pdwRenderFlags);
- STDMETHODIMP SetFullscreen(BOOL fFullscreen);
- STDMETHODIMP GetFullscreen(BOOL *pfFullscreen);
-
- // IEVRTrustedVideoPlugin
- STDMETHODIMP IsInTrustedVideoMode(BOOL *pYes);
- STDMETHODIMP CanConstrict(BOOL *pYes);
- STDMETHODIMP SetConstriction(DWORD dwKPix);
- STDMETHODIMP DisableImageExport(BOOL bDisable);
-
- // IDirect3DDeviceManager9
- STDMETHODIMP ResetDevice(IDirect3DDevice9 *pDevice,UINT resetToken);
- STDMETHODIMP OpenDeviceHandle(HANDLE *phDevice);
- STDMETHODIMP CloseDeviceHandle(HANDLE hDevice);
- STDMETHODIMP TestDevice(HANDLE hDevice);
- STDMETHODIMP LockDevice(HANDLE hDevice, IDirect3DDevice9 **ppDevice, BOOL fBlock);
- STDMETHODIMP UnlockDevice(HANDLE hDevice, BOOL fSaveState);
- STDMETHODIMP GetVideoService(HANDLE hDevice, REFIID riid, void **ppService);
-
- protected:
- void OnResetDevice();
- MFCLOCK_STATE m_LastClockState;
-
- private:
- // dxva.dll
- typedef HRESULT (__stdcall *PTR_DXVA2CreateDirect3DDeviceManager9)(UINT* pResetToken, IDirect3DDeviceManager9** ppDeviceManager);
- // mf.dll
- typedef HRESULT (__stdcall *PTR_MFCreatePresentationClock)(IMFPresentationClock** ppPresentationClock);
- // evr.dll
- typedef HRESULT (__stdcall *PTR_MFCreateDXSurfaceBuffer)(REFIID riid, IUnknown* punkSurface, BOOL fBottomUpWhenLinear, IMFMediaBuffer** ppBuffer);
- typedef HRESULT (__stdcall *PTR_MFCreateVideoSampleFromSurface)(IUnknown* pUnkSurface, IMFSample** ppSample);
- typedef HRESULT (__stdcall *PTR_MFCreateVideoMediaType)(const MFVIDEOFORMAT* pVideoFormat, IMFVideoMediaType** ppIVideoMediaType);
- // avrt.dll
- typedef HANDLE (__stdcall *PTR_AvSetMmThreadCharacteristicsW)(LPCWSTR TaskName, LPDWORD TaskIndex);
- typedef BOOL (__stdcall *PTR_AvSetMmThreadPriority)(HANDLE AvrtHandle, AVRT_PRIORITY Priority);
- typedef BOOL (__stdcall *PTR_AvRevertMmThreadCharacteristics)(HANDLE AvrtHandle);
-
- typedef enum {
- Started = State_Running,
- Stopped = State_Stopped,
- Paused = State_Paused,
- Shutdown = State_Running + 1
- } RENDER_STATE;
-
- CComPtr<IMFClock> m_pClock;
- CComPtr<IDirect3DDeviceManager9> m_pD3DManager;
- CComPtr<IMFTransform> m_pMixer;
- CComPtr<IMediaEventSink> m_pSink;
- CComPtr<IMFVideoMediaType> m_pMediaType;
- MFVideoAspectRatioMode m_dwVideoAspectRatioMode;
- MFVideoRenderPrefs m_dwVideoRenderPrefs;
- COLORREF m_BorderColor;
-
- HANDLE m_hEvtQuit; // Stop rendering thread event
- bool m_bEvtQuit;
- HANDLE m_hEvtFlush; // Discard all buffers
- bool m_bEvtFlush;
- HANDLE m_hEvtSkip; // Skip frame
- bool m_bEvtSkip;
-
- bool m_bUseInternalTimer;
- int32 m_LastSetOutputRange;
- bool m_bPendingRenegotiate;
- bool m_bPendingMediaFinished;
- bool m_bPrerolled; // true if first sample has been displayed.
-
- HANDLE m_hRenderThread;
- HANDLE m_hMixerThread;
- RENDER_STATE m_nRenderState;
- bool m_bStepping;
-
- CCritSec m_SampleQueueLock;
- CCritSec m_ImageProcessingLock;
-
- CInterfaceList<IMFSample, &IID_IMFSample> m_FreeSamples;
- CInterfaceList<IMFSample, &IID_IMFSample> m_ScheduledSamples;
- IMFSample *m_pCurrentDisplaydSample;
- UINT m_nResetToken;
- int m_nStepCount;
-
- bool GetSampleFromMixer();
- void MixerThread();
- static DWORD WINAPI MixerThreadStatic(LPVOID lpParam);
- void RenderThread();
- static DWORD WINAPI RenderThreadStatic(LPVOID lpParam);
-
- void StartWorkerThreads();
- void StopWorkerThreads();
- HRESULT CheckShutdown() const;
- void CompleteFrameStep(bool bCancel);
-
- void RemoveAllSamples();
- STDMETHODIMP AdviseSyncClock(ISyncClock* sC);
- HRESULT BeginStreaming();
- HRESULT GetFreeSample(IMFSample** ppSample);
- HRESULT GetScheduledSample(IMFSample** ppSample, int &_Count);
- void MoveToFreeList(IMFSample* pSample, bool bTail);
- void MoveToScheduledList(IMFSample* pSample, bool _bSorted);
- void FlushSamples();
- void FlushSamplesInternal();
-
- LONGLONG GetMediaTypeMerit(IMFMediaType *pMediaType);
- HRESULT RenegotiateMediaType();
- HRESULT IsMediaTypeSupported(IMFMediaType* pMixerType);
- HRESULT CreateProposedOutputType(IMFMediaType* pMixerType, IMFMediaType** pType);
- HRESULT SetMediaType(IMFMediaType* pType);
-
- // Functions pointers for Vista/.NET3 specific library
- PTR_DXVA2CreateDirect3DDeviceManager9 pfDXVA2CreateDirect3DDeviceManager9;
- PTR_MFCreateDXSurfaceBuffer pfMFCreateDXSurfaceBuffer;
- PTR_MFCreateVideoSampleFromSurface pfMFCreateVideoSampleFromSurface;
- PTR_MFCreateVideoMediaType pfMFCreateVideoMediaType;
-
- PTR_AvSetMmThreadCharacteristicsW pfAvSetMmThreadCharacteristicsW;
- PTR_AvSetMmThreadPriority pfAvSetMmThreadPriority;
- PTR_AvRevertMmThreadCharacteristics pfAvRevertMmThreadCharacteristics;
- };
-
- class CSyncRenderer:
- public CUnknown,
- public IVMRffdshow9,
- public IVMRMixerBitmap9,
- public IBaseFilter
- {
- CComPtr<IUnknown> m_pEVR;
- VMR9AlphaBitmap *m_pVMR9AlphaBitmap;
- CSyncAP *m_pAllocatorPresenter;
-
- public:
- CSyncRenderer(const TCHAR* pName, LPUNKNOWN pUnk, HRESULT& hr, VMR9AlphaBitmap* pVMR9AlphaBitmap, CSyncAP *pAllocatorPresenter);
- ~CSyncRenderer();
-
- // IBaseFilter
- virtual HRESULT STDMETHODCALLTYPE EnumPins(__out IEnumPins **ppEnum);
- virtual HRESULT STDMETHODCALLTYPE FindPin(LPCWSTR Id, __out IPin **ppPin);
- virtual HRESULT STDMETHODCALLTYPE QueryFilterInfo(__out FILTER_INFO *pInfo);
- virtual HRESULT STDMETHODCALLTYPE JoinFilterGraph(__in_opt IFilterGraph *pGraph, __in_opt LPCWSTR pName);
- virtual HRESULT STDMETHODCALLTYPE QueryVendorInfo(__out LPWSTR *pVendorInfo);
- virtual HRESULT STDMETHODCALLTYPE Stop(void);
- virtual HRESULT STDMETHODCALLTYPE Pause(void);
- virtual HRESULT STDMETHODCALLTYPE Run(REFERENCE_TIME tStart);
- virtual HRESULT STDMETHODCALLTYPE GetState(DWORD dwMilliSecsTimeout, __out FILTER_STATE *State);
- virtual HRESULT STDMETHODCALLTYPE SetSyncSource(__in_opt IReferenceClock *pClock);
- virtual HRESULT STDMETHODCALLTYPE GetSyncSource(__deref_out_opt IReferenceClock **pClock);
- virtual HRESULT STDMETHODCALLTYPE GetClassID(__RPC__out CLSID *pClassID);
-
- // IVMRffdshow9
- virtual HRESULT STDMETHODCALLTYPE support_ffdshow();
-
- // IVMRMixerBitmap9
- STDMETHODIMP GetAlphaBitmapParameters(VMR9AlphaBitmap* pBmpParms);
- STDMETHODIMP SetAlphaBitmap(const VMR9AlphaBitmap* pBmpParms);
- STDMETHODIMP UpdateAlphaBitmapParameters(const VMR9AlphaBitmap* pBmpParms);
-
- DECLARE_IUNKNOWN;
- virtual HRESULT STDMETHODCALLTYPE NonDelegatingQueryInterface(REFIID riid, void** ppvObject);
- };
-
- class CGenlock
- {
- public:
- class MovingAverage
- {
- public:
- MovingAverage(INT size):
- fifoSize(size),
- oldestSample(0),
- sum(0) {
- if (fifoSize > MAX_FIFO_SIZE) {
- fifoSize = MAX_FIFO_SIZE;
- }
- for (INT i = 0; i < MAX_FIFO_SIZE; i++) {
- fifo[i] = 0;
- }
- }
-
- ~MovingAverage() {
- }
-
- double Average(double sample) {
- sum = sum + sample - fifo[oldestSample];
- fifo[oldestSample] = sample;
- oldestSample++;
- if (oldestSample == fifoSize) {
- oldestSample = 0;
- }
- return sum / fifoSize;
- }
-
- private:
- INT fifoSize;
- double fifo[MAX_FIFO_SIZE];
- INT oldestSample;
- double sum;
- };
-
- CGenlock(DOUBLE target, DOUBLE limit, INT rowD, INT colD, DOUBLE clockD, UINT mon);
- ~CGenlock();
-
- BOOL PowerstripRunning(); // TRUE if PowerStrip is running
- HRESULT GetTiming(); // Get the string representing the display's current timing parameters
- HRESULT ResetTiming(); // Reset timing to what was last registered by GetTiming()
- HRESULT ResetClock(); // Reset reference clock speed to nominal
- HRESULT SetTargetSyncOffset(DOUBLE targetD);
- HRESULT GetTargetSyncOffset(DOUBLE *targetD);
- HRESULT SetControlLimit(DOUBLE cL);
- HRESULT GetControlLimit(DOUBLE *cL);
- HRESULT SetDisplayResolution(UINT columns, UINT lines);
- HRESULT AdviseSyncClock(ISyncClock* sC);
- HRESULT SetMonitor(UINT mon); // Set the number of the monitor to synchronize
- HRESULT ResetStats(); // Reset timing statistics
-
- HRESULT ControlDisplay(double syncOffset, double frameCycle); // Adjust the frequency of the display if needed
- HRESULT ControlClock(double syncOffset, double frameCycle); // Adjust the frequency of the clock if needed
- HRESULT UpdateStats(double syncOffset, double frameCycle); // Don't adjust anything, just update the syncOffset stats
-
- BOOL powerstripTimingExists; // TRUE if display timing has been got through Powerstrip
- BOOL liveSource; // TRUE if live source -> display sync is the only option
- INT adjDelta; // -1 for display slower in relation to video, 0 for keep, 1 for faster
- INT lineDelta; // The number of rows added or subtracted when adjusting display fps
- INT columnDelta; // The number of colums added or subtracted when adjusting display fps
- DOUBLE cycleDelta; // Adjustment factor for cycle time as fraction of nominal value
- UINT displayAdjustmentsMade; // The number of adjustments made to display refresh rate
- UINT clockAdjustmentsMade; // The number of adjustments made to clock frequency
-
- UINT totalLines, totalColumns; // Including the porches and sync widths
- UINT visibleLines, visibleColumns; // The nominal resolution
- MovingAverage *syncOffsetFifo;
- MovingAverage *frameCycleFifo;
- DOUBLE minSyncOffset, maxSyncOffset;
- DOUBLE syncOffsetAvg; // Average of the above
- DOUBLE minFrameCycle, maxFrameCycle;
- DOUBLE frameCycleAvg;
-
- UINT pixelClock; // In pixels/s
- DOUBLE displayFreqCruise; // Nominal display frequency in frames/s
- DOUBLE displayFreqSlower;
- DOUBLE displayFreqFaster;
- DOUBLE curDisplayFreq; // Current (adjusted) display frequency
- DOUBLE controlLimit; // How much the sync offset is allowed to drift from target sync offset
- WPARAM monitor; // The monitor to be controlled. 0-based.
- CComPtr<ISyncClock> syncClock; // Interface to an adjustable reference clock
-
- private:
- HWND psWnd; // PowerStrip window
- const static INT TIMING_PARAM_CNT = 10;
- const static INT MAX_LOADSTRING = 100;
- UINT displayTiming[TIMING_PARAM_CNT]; // Display timing parameters
- UINT displayTimingSave[TIMING_PARAM_CNT]; // So that we can reset the display at exit
- TCHAR faster[MAX_LOADSTRING]; // String corresponding to faster display frequency
- TCHAR cruise[MAX_LOADSTRING]; // String corresponding to nominal display frequency
- TCHAR slower[MAX_LOADSTRING]; // String corresponding to slower display frequency
- TCHAR savedTiming[MAX_LOADSTRING]; // String version of saved timing (to be restored upon exit)
- DOUBLE lowSyncOffset; // The closest we want to let the scheduled render time to get to the next vsync. In % of the frame time
- DOUBLE targetSyncOffset; // Where we want the scheduled render time to be in relation to the next vsync
- DOUBLE highSyncOffset; // The furthers we want to let the scheduled render time to get to the next vsync
- CCritSec csGenlockLock;
- };
+ class CGenlock;
+ class CSyncRenderer;
+
+ // Base allocator-presenter
+ class CBaseAP:
+ public CSubPicAllocatorPresenterImpl
+ {
+ protected:
+ CRenderersSettings::CRendererSettingsEVR m_LastRendererSettings;
+
+ HMODULE m_hDWMAPI;
+ HRESULT(__stdcall* m_pDwmIsCompositionEnabled)(__out BOOL* pfEnabled);
+ HRESULT(__stdcall* m_pDwmEnableComposition)(UINT uCompositionAction);
+ HMODULE m_hD3D9;
+ HRESULT(__stdcall* m_pDirect3DCreate9Ex)(UINT SDKVersion, IDirect3D9Ex**);
+
+ CCritSec m_allocatorLock;
+ CComPtr<IDirect3D9Ex> m_pD3DEx;
+ CComPtr<IDirect3D9> m_pD3D;
+ CComPtr<IDirect3DDevice9Ex> m_pD3DDevEx;
+ CComPtr<IDirect3DDevice9> m_pD3DDev;
+
+ CComPtr<IDirect3DTexture9> m_pVideoTexture[MAX_PICTURE_SLOTS];
+ CComPtr<IDirect3DSurface9> m_pVideoSurface[MAX_PICTURE_SLOTS];
+ CComPtr<IDirect3DTexture9> m_pOSDTexture;
+ CComPtr<IDirect3DSurface9> m_pOSDSurface;
+ CComPtr<ID3DXLine> m_pLine;
+ CComPtr<ID3DXFont> m_pFont;
+ CComPtr<ID3DXSprite> m_pSprite;
+ CSyncRenderer* m_pOuterEVR;
+
+ class CExternalPixelShader
+ {
+ public:
+ CComPtr<IDirect3DPixelShader9> m_pPixelShader;
+ CStringA m_SourceData;
+ CStringA m_SourceTarget;
+ HRESULT Compile(CPixelShaderCompiler* pCompiler) {
+ HRESULT hr = pCompiler->CompileShader(m_SourceData, "main", m_SourceTarget, 0, &m_pPixelShader);
+ if (FAILED(hr)) {
+ return hr;
+ }
+ return S_OK;
+ }
+ };
+
+ CAutoPtr<CPixelShaderCompiler> m_pPSC;
+ CAtlList<CExternalPixelShader> m_pPixelShaders;
+ CAtlList<CExternalPixelShader> m_pPixelShadersScreenSpace;
+ CComPtr<IDirect3DPixelShader9> m_pResizerPixelShader[4]; // bl, bc1, bc2_1, bc2_2
+ CComPtr<IDirect3DTexture9> m_pScreenSizeTemporaryTexture[2];
+
+ D3DFORMAT m_SurfaceType;
+ D3DFORMAT m_BackbufferType;
+ D3DFORMAT m_DisplayType;
+ D3DTEXTUREFILTERTYPE m_filter;
+ D3DCAPS9 m_caps;
+ D3DPRESENT_PARAMETERS pp;
+
+ bool SettingsNeedResetDevice();
+ void SendResetRequest();
+ virtual HRESULT CreateDXDevice(CString& _Error);
+ virtual HRESULT ResetDXDevice(CString& _Error);
+ virtual HRESULT AllocSurfaces(D3DFORMAT Format = D3DFMT_A8R8G8B8);
+ virtual void DeleteSurfaces();
+
+ HANDLE m_hEvtQuit; // Stop rendering thread event
+ LONGLONG m_LastAdapterCheck;
+ UINT m_CurrentAdapter;
+ UINT GetAdapter(IDirect3D9* pD3D);
+
+ float m_bicubicA;
+ HRESULT InitResizers(float bicubicA, bool bNeedScreenSizeTexture);
+
+ // Functions to trace timing performance
+ void SyncStats(LONGLONG syncTime);
+ void SyncOffsetStats(LONGLONG syncOffset);
+ void DrawText(const RECT& rc, const CString& strText, int _Priority);
+ void DrawStats();
+
+ template<int texcoords>
+ void AdjustQuad(MYD3DVERTEX<texcoords>* v, double dx, double dy);
+ template<int texcoords>
+ HRESULT TextureBlt(IDirect3DDevice9* pD3DDev, MYD3DVERTEX<texcoords> v[4], D3DTEXTUREFILTERTYPE filter);
+ MFOffset GetOffset(float v);
+ MFVideoArea GetArea(float x, float y, DWORD width, DWORD height);
+ bool ClipToSurface(IDirect3DSurface9* pSurface, CRect& s, CRect& d);
+
+ HRESULT DrawRectBase(IDirect3DDevice9* pD3DDev, MYD3DVERTEX<0> v[4]);
+ HRESULT DrawRect(DWORD _Color, DWORD _Alpha, const CRect& _Rect);
+ HRESULT TextureCopy(IDirect3DTexture9* pTexture);
+ HRESULT TextureResize(IDirect3DTexture9* pTexture, Vector dst[4], D3DTEXTUREFILTERTYPE filter, const CRect& SrcRect);
+ HRESULT TextureResizeBilinear(IDirect3DTexture9* pTexture, Vector dst[4], const CRect& SrcRect);
+ HRESULT TextureResizeBicubic1pass(IDirect3DTexture9* pTexture, Vector dst[4], const CRect& SrcRect);
+ HRESULT TextureResizeBicubic2pass(IDirect3DTexture9* pTexture, Vector dst[4], const CRect& SrcRect);
+
+ typedef HRESULT(WINAPI* D3DXLoadSurfaceFromMemoryPtr)(
+ LPDIRECT3DSURFACE9 pDestSurface,
+ CONST PALETTEENTRY* pDestPalette,
+ CONST RECT* pDestRect,
+ LPCVOID pSrcMemory,
+ D3DFORMAT SrcFormat,
+ UINT SrcPitch,
+ CONST PALETTEENTRY* pSrcPalette,
+ CONST RECT* pSrcRect,
+ DWORD Filter,
+ D3DCOLOR ColorKey);
+
+ typedef HRESULT(WINAPI* D3DXCreateLinePtr)
+ (LPDIRECT3DDEVICE9 pDevice,
+ LPD3DXLINE* ppLine);
+
+ typedef HRESULT(WINAPI* D3DXCreateFontPtr)(
+ LPDIRECT3DDEVICE9 pDevice,
+ int Height,
+ UINT Width,
+ UINT Weight,
+ UINT MipLevels,
+ bool Italic,
+ DWORD CharSet,
+ DWORD OutputPrecision,
+ DWORD Quality,
+ DWORD PitchAndFamily,
+ LPCWSTR pFaceName,
+ LPD3DXFONT* ppFont);
+
+ HRESULT AlphaBlt(RECT* pSrc, RECT* pDst, IDirect3DTexture9* pTexture);
+
+ virtual void OnResetDevice() {};
+
+ int m_nTearingPos;
+ VMR9AlphaBitmap m_VMR9AlphaBitmap;
+ CAutoVectorPtr<BYTE> m_VMR9AlphaBitmapData;
+ CRect m_VMR9AlphaBitmapRect;
+ int m_VMR9AlphaBitmapWidthBytes;
+
+ D3DXLoadSurfaceFromMemoryPtr m_pD3DXLoadSurfaceFromMemory;
+ D3DXCreateLinePtr m_pD3DXCreateLine;
+ D3DXCreateFontPtr m_pD3DXCreateFont;
+ HRESULT(__stdcall* m_pD3DXCreateSprite)(LPDIRECT3DDEVICE9 pDevice, LPD3DXSPRITE* ppSprite);
+
+ int m_nDXSurface; // Total number of DX Surfaces
+ int m_nVMR9Surfaces;
+ int m_iVMR9Surface;
+ int m_nCurSurface; // Surface currently displayed
+ long m_nUsedBuffer;
+
+ LONG m_lNextSampleWait; // Waiting time for next sample in EVR
+ bool m_bSnapToVSync; // True if framerate is low enough so that snap to vsync makes sense
+
+ UINT m_uScanLineEnteringPaint; // The active scan line when entering Paint()
+ REFERENCE_TIME m_llEstVBlankTime; // Next vblank start time in reference clock "coordinates"
+
+ double m_fAvrFps; // Estimate the true FPS as given by the distance between vsyncs when a frame has been presented
+ double m_fJitterStdDev; // VSync estimate std dev
+ double m_fJitterMean; // Mean time between two syncpulses when a frame has been presented (i.e. when Paint() has been called
+
+ double m_fSyncOffsetAvr; // Mean time between the call of Paint() and vsync. To avoid tearing this should be several ms at least
+ double m_fSyncOffsetStdDev; // The std dev of the above
+
+ bool m_bHighColorResolution;
+ bool m_bCompositionEnabled;
+ bool m_bDesktopCompositionDisabled;
+ bool m_bIsFullscreen;
+ bool m_bNeedCheckSample;
+ DWORD m_dMainThreadId;
+
+ CSize m_ScreenSize;
+
+ // Display and frame rates and cycles
+ double m_dDetectedScanlineTime; // Time for one (horizontal) scan line. Extracted at stream start and used to calculate vsync time
+ UINT m_uD3DRefreshRate; // As got when creating the d3d device
+ double m_dD3DRefreshCycle; // Display refresh cycle ms
+ double m_dEstRefreshCycle; // As estimated from scan lines
+ double m_dFrameCycle; // Average sample time, extracted from the samples themselves
+ // double m_fps is defined in ISubPic.h
+ double m_dOptimumDisplayCycle; // The display cycle that is closest to the frame rate. A multiple of the actual display cycle
+ double m_dCycleDifference; // Difference in video and display cycle time relative to the video cycle time
+
+ UINT m_pcFramesDropped;
+ UINT m_pcFramesDuplicated;
+ UINT m_pcFramesDrawn;
+
+ LONGLONG m_pllJitter [NB_JITTER]; // Vertical sync time stats
+ LONGLONG m_pllSyncOffset [NB_JITTER]; // Sync offset time stats
+ int m_nNextJitter;
+ int m_nNextSyncOffset;
+ LONGLONG m_JitterStdDev;
+
+ LONGLONG m_llLastSyncTime;
+
+ LONGLONG m_MaxJitter;
+ LONGLONG m_MinJitter;
+ LONGLONG m_MaxSyncOffset;
+ LONGLONG m_MinSyncOffset;
+ UINT m_uSyncGlitches;
+
+ LONGLONG m_llSampleTime, m_llLastSampleTime; // Present time for the current sample
+ LONG m_lSampleLatency, m_lLastSampleLatency; // Time between intended and actual presentation time
+ LONG m_lMinSampleLatency, m_lLastMinSampleLatency;
+ LONGLONG m_llHysteresis;
+ LONG m_lHysteresis;
+ LONG m_lShiftToNearest, m_lShiftToNearestPrev;
+ bool m_bVideoSlowerThanDisplay;
+
+ int m_bInterlaced;
+ double m_TextScale;
+ CString m_strStatsMsg[10];
+
+ CGenlock* m_pGenlock; // The video - display synchronizer class
+ CComPtr<IReferenceClock> m_pRefClock; // The reference clock. Used in Paint()
+ CComPtr<IAMAudioRendererStats> m_pAudioStats; // Audio statistics from audio renderer. To check so that audio is in sync
+ DWORD m_lAudioLag; // Time difference between audio and video when the audio renderer is matching rate to the external reference clock
+ long m_lAudioLagMin, m_lAudioLagMax; // The accumulated difference between the audio renderer and the master clock
+ DWORD m_lAudioSlaveMode; // To check whether the audio renderer matches rate with SyncClock (returns the value 4 if it does)
+
+ double GetRefreshRate(); // Get the best estimate of the display refresh rate in Hz
+ double GetDisplayCycle(); // Get the best estimate of the display cycle time in milliseconds
+ double GetCycleDifference(); // Get the difference in video and display cycle times.
+ void EstimateRefreshTimings(); // Estimate the times for one scan line and one frame respectively from the actual refresh data
+ bool ExtractInterlaced(const AM_MEDIA_TYPE* pmt);
+
+ public:
+ CBaseAP(HWND hWnd, bool bFullscreen, HRESULT& hr, CString& _Error);
+ ~CBaseAP();
+
+ CCritSec m_VMR9AlphaBitmapLock;
+ void UpdateAlphaBitmap();
+ void ResetStats();
+
+ // ISubPicAllocatorPresenter
+ STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
+ STDMETHODIMP_(bool) Paint(bool fAll);
+ STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size);
+ STDMETHODIMP SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget);
+ STDMETHODIMP SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace);
+ STDMETHODIMP_(bool) ResetDevice();
+ STDMETHODIMP_(bool) DisplayChange();
+ };
+
+ class CSyncAP:
+ public CBaseAP,
+ public IMFGetService,
+ public IMFTopologyServiceLookupClient,
+ public IMFVideoDeviceID,
+ public IMFVideoPresenter,
+ public IDirect3DDeviceManager9,
+ public IMFAsyncCallback,
+ public IQualProp,
+ public IMFRateSupport,
+ public IMFVideoDisplayControl,
+ public IEVRTrustedVideoPlugin,
+ public ISyncClockAdviser
+
+ {
+ public:
+ CSyncAP(HWND hWnd, bool bFullscreen, HRESULT& hr, CString& _Error);
+ ~CSyncAP(void);
+
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
+ STDMETHODIMP_(bool) Paint(bool fAll);
+ STDMETHODIMP GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight);
+ STDMETHODIMP InitializeDevice(AM_MEDIA_TYPE* pMediaType);
+ STDMETHODIMP_(bool) ResetDevice();
+
+ // IMFClockStateSink
+ STDMETHODIMP OnClockStart(MFTIME hnsSystemTime, LONGLONG llClockStartOffset);
+ STDMETHODIMP OnClockStop(MFTIME hnsSystemTime);
+ STDMETHODIMP OnClockPause(MFTIME hnsSystemTime);
+ STDMETHODIMP OnClockRestart(MFTIME hnsSystemTime);
+ STDMETHODIMP OnClockSetRate(MFTIME hnsSystemTime, float flRate);
+
+ // IBaseFilter delegate
+ bool GetState(DWORD dwMilliSecsTimeout, FILTER_STATE* State, HRESULT& _ReturnValue);
+
+ // IQualProp (EVR statistics window). These are incompletely implemented currently
+ STDMETHODIMP get_FramesDroppedInRenderer(int* pcFrames);
+ STDMETHODIMP get_FramesDrawn(int* pcFramesDrawn);
+ STDMETHODIMP get_AvgFrameRate(int* piAvgFrameRate);
+ STDMETHODIMP get_Jitter(int* iJitter);
+ STDMETHODIMP get_AvgSyncOffset(int* piAvg);
+ STDMETHODIMP get_DevSyncOffset(int* piDev);
+
+ // IMFRateSupport
+ STDMETHODIMP GetSlowestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float* pflRate);
+ STDMETHODIMP GetFastestRate(MFRATE_DIRECTION eDirection, BOOL fThin, float* pflRate);
+ STDMETHODIMP IsRateSupported(BOOL fThin, float flRate, float* pflNearestSupportedRate);
+ float GetMaxRate(BOOL bThin);
+
+ // IMFVideoPresenter
+ STDMETHODIMP ProcessMessage(MFVP_MESSAGE_TYPE eMessage, ULONG_PTR ulParam);
+ STDMETHODIMP GetCurrentMediaType(__deref_out IMFVideoMediaType** ppMediaType);
+
+ // IMFTopologyServiceLookupClient
+ STDMETHODIMP InitServicePointers(__in IMFTopologyServiceLookup* pLookup);
+ STDMETHODIMP ReleaseServicePointers();
+
+ // IMFVideoDeviceID
+ STDMETHODIMP GetDeviceID(__out IID* pDeviceID);
+
+ // IMFGetService
+ STDMETHODIMP GetService(__RPC__in REFGUID guidService, __RPC__in REFIID riid, __RPC__deref_out_opt LPVOID* ppvObject);
+
+ // IMFAsyncCallback
+ STDMETHODIMP GetParameters(__RPC__out DWORD* pdwFlags, /* [out] */ __RPC__out DWORD* pdwQueue);
+ STDMETHODIMP Invoke(__RPC__in_opt IMFAsyncResult* pAsyncResult);
+
+ // IMFVideoDisplayControl
+ STDMETHODIMP GetNativeVideoSize(SIZE* pszVideo, SIZE* pszARVideo);
+ STDMETHODIMP GetIdealVideoSize(SIZE* pszMin, SIZE* pszMax);
+ STDMETHODIMP SetVideoPosition(const MFVideoNormalizedRect* pnrcSource, const LPRECT prcDest);
+ STDMETHODIMP GetVideoPosition(MFVideoNormalizedRect* pnrcSource, LPRECT prcDest);
+ STDMETHODIMP SetAspectRatioMode(DWORD dwAspectRatioMode);
+ STDMETHODIMP GetAspectRatioMode(DWORD* pdwAspectRatioMode);
+ STDMETHODIMP SetVideoWindow(HWND hwndVideo);
+ STDMETHODIMP GetVideoWindow(HWND* phwndVideo);
+ STDMETHODIMP RepaintVideo(void);
+ STDMETHODIMP GetCurrentImage(BITMAPINFOHEADER* pBih, BYTE** pDib, DWORD* pcbDib, LONGLONG* pTimeStamp);
+ STDMETHODIMP SetBorderColor(COLORREF Clr);
+ STDMETHODIMP GetBorderColor(COLORREF* pClr);
+ STDMETHODIMP SetRenderingPrefs(DWORD dwRenderFlags);
+ STDMETHODIMP GetRenderingPrefs(DWORD* pdwRenderFlags);
+ STDMETHODIMP SetFullscreen(BOOL fFullscreen);
+ STDMETHODIMP GetFullscreen(BOOL* pfFullscreen);
+
+ // IEVRTrustedVideoPlugin
+ STDMETHODIMP IsInTrustedVideoMode(BOOL* pYes);
+ STDMETHODIMP CanConstrict(BOOL* pYes);
+ STDMETHODIMP SetConstriction(DWORD dwKPix);
+ STDMETHODIMP DisableImageExport(BOOL bDisable);
+
+ // IDirect3DDeviceManager9
+ STDMETHODIMP ResetDevice(IDirect3DDevice9* pDevice, UINT resetToken);
+ STDMETHODIMP OpenDeviceHandle(HANDLE* phDevice);
+ STDMETHODIMP CloseDeviceHandle(HANDLE hDevice);
+ STDMETHODIMP TestDevice(HANDLE hDevice);
+ STDMETHODIMP LockDevice(HANDLE hDevice, IDirect3DDevice9** ppDevice, BOOL fBlock);
+ STDMETHODIMP UnlockDevice(HANDLE hDevice, BOOL fSaveState);
+ STDMETHODIMP GetVideoService(HANDLE hDevice, REFIID riid, void** ppService);
+
+ protected:
+ void OnResetDevice();
+ MFCLOCK_STATE m_LastClockState;
+
+ private:
+ // dxva.dll
+ typedef HRESULT(__stdcall* PTR_DXVA2CreateDirect3DDeviceManager9)(UINT* pResetToken, IDirect3DDeviceManager9** ppDeviceManager);
+ // mf.dll
+ typedef HRESULT(__stdcall* PTR_MFCreatePresentationClock)(IMFPresentationClock** ppPresentationClock);
+ // evr.dll
+ typedef HRESULT(__stdcall* PTR_MFCreateDXSurfaceBuffer)(REFIID riid, IUnknown* punkSurface, BOOL fBottomUpWhenLinear, IMFMediaBuffer** ppBuffer);
+ typedef HRESULT(__stdcall* PTR_MFCreateVideoSampleFromSurface)(IUnknown* pUnkSurface, IMFSample** ppSample);
+ typedef HRESULT(__stdcall* PTR_MFCreateVideoMediaType)(const MFVIDEOFORMAT* pVideoFormat, IMFVideoMediaType** ppIVideoMediaType);
+ // avrt.dll
+ typedef HANDLE(__stdcall* PTR_AvSetMmThreadCharacteristicsW)(LPCWSTR TaskName, LPDWORD TaskIndex);
+ typedef BOOL (__stdcall* PTR_AvSetMmThreadPriority)(HANDLE AvrtHandle, AVRT_PRIORITY Priority);
+ typedef BOOL (__stdcall* PTR_AvRevertMmThreadCharacteristics)(HANDLE AvrtHandle);
+
+ typedef enum {
+ Started = State_Running,
+ Stopped = State_Stopped,
+ Paused = State_Paused,
+ Shutdown = State_Running + 1
+ } RENDER_STATE;
+
+ CComPtr<IMFClock> m_pClock;
+ CComPtr<IDirect3DDeviceManager9> m_pD3DManager;
+ CComPtr<IMFTransform> m_pMixer;
+ CComPtr<IMediaEventSink> m_pSink;
+ CComPtr<IMFVideoMediaType> m_pMediaType;
+ MFVideoAspectRatioMode m_dwVideoAspectRatioMode;
+ MFVideoRenderPrefs m_dwVideoRenderPrefs;
+ COLORREF m_BorderColor;
+
+ HANDLE m_hEvtQuit; // Stop rendering thread event
+ bool m_bEvtQuit;
+ HANDLE m_hEvtFlush; // Discard all buffers
+ bool m_bEvtFlush;
+ HANDLE m_hEvtSkip; // Skip frame
+ bool m_bEvtSkip;
+
+ bool m_bUseInternalTimer;
+ int32 m_LastSetOutputRange;
+ bool m_bPendingRenegotiate;
+ bool m_bPendingMediaFinished;
+ bool m_bPrerolled; // true if first sample has been displayed.
+
+ HANDLE m_hRenderThread;
+ HANDLE m_hMixerThread;
+ RENDER_STATE m_nRenderState;
+ bool m_bStepping;
+
+ CCritSec m_SampleQueueLock;
+ CCritSec m_ImageProcessingLock;
+
+ CInterfaceList<IMFSample, &IID_IMFSample> m_FreeSamples;
+ CInterfaceList<IMFSample, &IID_IMFSample> m_ScheduledSamples;
+ IMFSample* m_pCurrentDisplaydSample;
+ UINT m_nResetToken;
+ int m_nStepCount;
+
+ bool GetSampleFromMixer();
+ void MixerThread();
+ static DWORD WINAPI MixerThreadStatic(LPVOID lpParam);
+ void RenderThread();
+ static DWORD WINAPI RenderThreadStatic(LPVOID lpParam);
+
+ void StartWorkerThreads();
+ void StopWorkerThreads();
+ HRESULT CheckShutdown() const;
+ void CompleteFrameStep(bool bCancel);
+
+ void RemoveAllSamples();
+ STDMETHODIMP AdviseSyncClock(ISyncClock* sC);
+ HRESULT BeginStreaming();
+ HRESULT GetFreeSample(IMFSample** ppSample);
+ HRESULT GetScheduledSample(IMFSample** ppSample, int& _Count);
+ void MoveToFreeList(IMFSample* pSample, bool bTail);
+ void MoveToScheduledList(IMFSample* pSample, bool _bSorted);
+ void FlushSamples();
+ void FlushSamplesInternal();
+
+ LONGLONG GetMediaTypeMerit(IMFMediaType* pMediaType);
+ HRESULT RenegotiateMediaType();
+ HRESULT IsMediaTypeSupported(IMFMediaType* pMixerType);
+ HRESULT CreateProposedOutputType(IMFMediaType* pMixerType, IMFMediaType** pType);
+ HRESULT SetMediaType(IMFMediaType* pType);
+
+ // Functions pointers for Vista/.NET3 specific library
+ PTR_DXVA2CreateDirect3DDeviceManager9 pfDXVA2CreateDirect3DDeviceManager9;
+ PTR_MFCreateDXSurfaceBuffer pfMFCreateDXSurfaceBuffer;
+ PTR_MFCreateVideoSampleFromSurface pfMFCreateVideoSampleFromSurface;
+ PTR_MFCreateVideoMediaType pfMFCreateVideoMediaType;
+
+ PTR_AvSetMmThreadCharacteristicsW pfAvSetMmThreadCharacteristicsW;
+ PTR_AvSetMmThreadPriority pfAvSetMmThreadPriority;
+ PTR_AvRevertMmThreadCharacteristics pfAvRevertMmThreadCharacteristics;
+ };
+
+ class CSyncRenderer:
+ public CUnknown,
+ public IVMRffdshow9,
+ public IVMRMixerBitmap9,
+ public IBaseFilter
+ {
+ CComPtr<IUnknown> m_pEVR;
+ VMR9AlphaBitmap* m_pVMR9AlphaBitmap;
+ CSyncAP* m_pAllocatorPresenter;
+
+ public:
+ CSyncRenderer(const TCHAR* pName, LPUNKNOWN pUnk, HRESULT& hr, VMR9AlphaBitmap* pVMR9AlphaBitmap, CSyncAP* pAllocatorPresenter);
+ ~CSyncRenderer();
+
+ // IBaseFilter
+ virtual HRESULT STDMETHODCALLTYPE EnumPins(__out IEnumPins** ppEnum);
+ virtual HRESULT STDMETHODCALLTYPE FindPin(LPCWSTR Id, __out IPin** ppPin);
+ virtual HRESULT STDMETHODCALLTYPE QueryFilterInfo(__out FILTER_INFO* pInfo);
+ virtual HRESULT STDMETHODCALLTYPE JoinFilterGraph(__in_opt IFilterGraph* pGraph, __in_opt LPCWSTR pName);
+ virtual HRESULT STDMETHODCALLTYPE QueryVendorInfo(__out LPWSTR* pVendorInfo);
+ virtual HRESULT STDMETHODCALLTYPE Stop(void);
+ virtual HRESULT STDMETHODCALLTYPE Pause(void);
+ virtual HRESULT STDMETHODCALLTYPE Run(REFERENCE_TIME tStart);
+ virtual HRESULT STDMETHODCALLTYPE GetState(DWORD dwMilliSecsTimeout, __out FILTER_STATE* State);
+ virtual HRESULT STDMETHODCALLTYPE SetSyncSource(__in_opt IReferenceClock* pClock);
+ virtual HRESULT STDMETHODCALLTYPE GetSyncSource(__deref_out_opt IReferenceClock** pClock);
+ virtual HRESULT STDMETHODCALLTYPE GetClassID(__RPC__out CLSID* pClassID);
+
+ // IVMRffdshow9
+ virtual HRESULT STDMETHODCALLTYPE support_ffdshow();
+
+ // IVMRMixerBitmap9
+ STDMETHODIMP GetAlphaBitmapParameters(VMR9AlphaBitmap* pBmpParms);
+ STDMETHODIMP SetAlphaBitmap(const VMR9AlphaBitmap* pBmpParms);
+ STDMETHODIMP UpdateAlphaBitmapParameters(const VMR9AlphaBitmap* pBmpParms);
+
+ DECLARE_IUNKNOWN;
+ virtual HRESULT STDMETHODCALLTYPE NonDelegatingQueryInterface(REFIID riid, void** ppvObject);
+ };
+
+ class CGenlock
+ {
+ public:
+ class MovingAverage
+ {
+ public:
+ MovingAverage(INT size):
+ fifoSize(size),
+ oldestSample(0),
+ sum(0) {
+ if (fifoSize > MAX_FIFO_SIZE) {
+ fifoSize = MAX_FIFO_SIZE;
+ }
+ for (INT i = 0; i < MAX_FIFO_SIZE; i++) {
+ fifo[i] = 0;
+ }
+ }
+
+ ~MovingAverage() {
+ }
+
+ double Average(double sample) {
+ sum = sum + sample - fifo[oldestSample];
+ fifo[oldestSample] = sample;
+ oldestSample++;
+ if (oldestSample == fifoSize) {
+ oldestSample = 0;
+ }
+ return sum / fifoSize;
+ }
+
+ private:
+ INT fifoSize;
+ double fifo[MAX_FIFO_SIZE];
+ INT oldestSample;
+ double sum;
+ };
+
+ CGenlock(DOUBLE target, DOUBLE limit, INT rowD, INT colD, DOUBLE clockD, UINT mon);
+ ~CGenlock();
+
+ BOOL PowerstripRunning(); // TRUE if PowerStrip is running
+ HRESULT GetTiming(); // Get the string representing the display's current timing parameters
+ HRESULT ResetTiming(); // Reset timing to what was last registered by GetTiming()
+ HRESULT ResetClock(); // Reset reference clock speed to nominal
+ HRESULT SetTargetSyncOffset(DOUBLE targetD);
+ HRESULT GetTargetSyncOffset(DOUBLE* targetD);
+ HRESULT SetControlLimit(DOUBLE cL);
+ HRESULT GetControlLimit(DOUBLE* cL);
+ HRESULT SetDisplayResolution(UINT columns, UINT lines);
+ HRESULT AdviseSyncClock(ISyncClock* sC);
+ HRESULT SetMonitor(UINT mon); // Set the number of the monitor to synchronize
+ HRESULT ResetStats(); // Reset timing statistics
+
+ HRESULT ControlDisplay(double syncOffset, double frameCycle); // Adjust the frequency of the display if needed
+ HRESULT ControlClock(double syncOffset, double frameCycle); // Adjust the frequency of the clock if needed
+ HRESULT UpdateStats(double syncOffset, double frameCycle); // Don't adjust anything, just update the syncOffset stats
+
+ BOOL powerstripTimingExists; // TRUE if display timing has been got through Powerstrip
+ BOOL liveSource; // TRUE if live source -> display sync is the only option
+ INT adjDelta; // -1 for display slower in relation to video, 0 for keep, 1 for faster
+ INT lineDelta; // The number of rows added or subtracted when adjusting display fps
+ INT columnDelta; // The number of colums added or subtracted when adjusting display fps
+ DOUBLE cycleDelta; // Adjustment factor for cycle time as fraction of nominal value
+ UINT displayAdjustmentsMade; // The number of adjustments made to display refresh rate
+ UINT clockAdjustmentsMade; // The number of adjustments made to clock frequency
+
+ UINT totalLines, totalColumns; // Including the porches and sync widths
+ UINT visibleLines, visibleColumns; // The nominal resolution
+ MovingAverage* syncOffsetFifo;
+ MovingAverage* frameCycleFifo;
+ DOUBLE minSyncOffset, maxSyncOffset;
+ DOUBLE syncOffsetAvg; // Average of the above
+ DOUBLE minFrameCycle, maxFrameCycle;
+ DOUBLE frameCycleAvg;
+
+ UINT pixelClock; // In pixels/s
+ DOUBLE displayFreqCruise; // Nominal display frequency in frames/s
+ DOUBLE displayFreqSlower;
+ DOUBLE displayFreqFaster;
+ DOUBLE curDisplayFreq; // Current (adjusted) display frequency
+ DOUBLE controlLimit; // How much the sync offset is allowed to drift from target sync offset
+ WPARAM monitor; // The monitor to be controlled. 0-based.
+ CComPtr<ISyncClock> syncClock; // Interface to an adjustable reference clock
+
+ private:
+ HWND psWnd; // PowerStrip window
+ const static INT TIMING_PARAM_CNT = 10;
+ const static INT MAX_LOADSTRING = 100;
+ UINT displayTiming[TIMING_PARAM_CNT]; // Display timing parameters
+ UINT displayTimingSave[TIMING_PARAM_CNT]; // So that we can reset the display at exit
+ TCHAR faster[MAX_LOADSTRING]; // String corresponding to faster display frequency
+ TCHAR cruise[MAX_LOADSTRING]; // String corresponding to nominal display frequency
+ TCHAR slower[MAX_LOADSTRING]; // String corresponding to slower display frequency
+ TCHAR savedTiming[MAX_LOADSTRING]; // String version of saved timing (to be restored upon exit)
+ DOUBLE lowSyncOffset; // The closest we want to let the scheduled render time to get to the next vsync. In % of the frame time
+ DOUBLE targetSyncOffset; // Where we want the scheduled render time to be in relation to the next vsync
+ DOUBLE highSyncOffset; // The furthers we want to let the scheduled render time to get to the next vsync
+ CCritSec csGenlockLock;
+ };
}
diff --git a/src/filters/renderer/VideoRenderers/VMR7AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/VMR7AllocatorPresenter.cpp
index 4425fb592..03023bab5 100644
--- a/src/filters/renderer/VideoRenderers/VMR7AllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/VMR7AllocatorPresenter.cpp
@@ -39,259 +39,259 @@ using namespace DSObjects;
#define MY_USER_ID 0x6ABE51
CVMR7AllocatorPresenter::CVMR7AllocatorPresenter(HWND hWnd, HRESULT& hr)
- : CDX7AllocatorPresenter(hWnd, hr)
- , m_fUseInternalTimer(false)
+ : CDX7AllocatorPresenter(hWnd, hr)
+ , m_fUseInternalTimer(false)
{
- if (FAILED(hr)) {
- return;
- }
-
- if (FAILED(hr = m_pSA.CoCreateInstance(CLSID_AllocPresenter))) {
- hr = E_FAIL;
- return;
- }
+ if (FAILED(hr)) {
+ return;
+ }
+
+ if (FAILED(hr = m_pSA.CoCreateInstance(CLSID_AllocPresenter))) {
+ hr = E_FAIL;
+ return;
+ }
}
STDMETHODIMP CVMR7AllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- QI(IVMRSurfaceAllocator)
- QI(IVMRImagePresenter)
- QI(IVMRWindowlessControl)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IVMRSurfaceAllocator)
+ QI(IVMRImagePresenter)
+ QI(IVMRWindowlessControl)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CVMR7AllocatorPresenter::CreateDevice()
{
- HRESULT hr = __super::CreateDevice();
- if (FAILED(hr)) {
- return hr;
- }
-
- if (m_pIVMRSurfAllocNotify) {
- HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- if (FAILED(hr = m_pIVMRSurfAllocNotify->ChangeDDrawDevice(m_pDD, hMonitor))) {
- return hr; //return false;
- }
- }
-
- return hr;
+ HRESULT hr = __super::CreateDevice();
+ if (FAILED(hr)) {
+ return hr;
+ }
+
+ if (m_pIVMRSurfAllocNotify) {
+ HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+ if (FAILED(hr = m_pIVMRSurfAllocNotify->ChangeDDrawDevice(m_pDD, hMonitor))) {
+ return hr; //return false;
+ }
+ }
+
+ return hr;
}
void CVMR7AllocatorPresenter::DeleteSurfaces()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- m_pSA->FreeSurface(MY_USER_ID);
+ m_pSA->FreeSurface(MY_USER_ID);
- __super::DeleteSurfaces();
+ __super::DeleteSurfaces();
}
// ISubPicAllocatorPresenter
STDMETHODIMP CVMR7AllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
{
- CheckPointer(ppRenderer, E_POINTER);
+ CheckPointer(ppRenderer, E_POINTER);
- *ppRenderer = NULL;
+ *ppRenderer = NULL;
- HRESULT hr;
+ HRESULT hr;
- do {
- CComPtr<IBaseFilter> pBF;
+ do {
+ CComPtr<IBaseFilter> pBF;
- if (FAILED(hr = pBF.CoCreateInstance(CLSID_VideoMixingRenderer))) {
- break;
- }
+ if (FAILED(hr = pBF.CoCreateInstance(CLSID_VideoMixingRenderer))) {
+ break;
+ }
- CComQIPtr<IVMRFilterConfig> pConfig = pBF;
- if (!pConfig) {
- break;
- }
+ CComQIPtr<IVMRFilterConfig> pConfig = pBF;
+ if (!pConfig) {
+ break;
+ }
- if (FAILED(hr = pConfig->SetRenderingMode(VMRMode_Renderless))) {
- break;
- }
+ if (FAILED(hr = pConfig->SetRenderingMode(VMRMode_Renderless))) {
+ break;
+ }
- CComQIPtr<IVMRSurfaceAllocatorNotify> pSAN = pBF;
- if (!pSAN) {
- break;
- }
+ CComQIPtr<IVMRSurfaceAllocatorNotify> pSAN = pBF;
+ if (!pSAN) {
+ break;
+ }
- if (FAILED(hr = pSAN->AdviseSurfaceAllocator(MY_USER_ID, static_cast<IVMRSurfaceAllocator*>(this)))
- || FAILED(hr = AdviseNotify(pSAN))) {
- break;
- }
+ if (FAILED(hr = pSAN->AdviseSurfaceAllocator(MY_USER_ID, static_cast<IVMRSurfaceAllocator*>(this)))
+ || FAILED(hr = AdviseNotify(pSAN))) {
+ break;
+ }
- CComPtr<IPin> pPin = GetFirstPin(pBF);
- CComQIPtr<IMemInputPin> pMemInputPin = pPin;
- m_fUseInternalTimer = HookNewSegmentAndReceive((IPinC*)(IPin*)pPin, (IMemInputPinC*)(IMemInputPin*)pMemInputPin);
+ CComPtr<IPin> pPin = GetFirstPin(pBF);
+ CComQIPtr<IMemInputPin> pMemInputPin = pPin;
+ m_fUseInternalTimer = HookNewSegmentAndReceive((IPinC*)(IPin*)pPin, (IMemInputPinC*)(IMemInputPin*)pMemInputPin);
- *ppRenderer = (IUnknown*)pBF.Detach();
+ *ppRenderer = (IUnknown*)pBF.Detach();
- return S_OK;
- } while (0);
+ return S_OK;
+ } while (0);
- return E_FAIL;
+ return E_FAIL;
}
STDMETHODIMP_(void) CVMR7AllocatorPresenter::SetTime(REFERENCE_TIME rtNow)
{
- __super::SetTime(rtNow);
- // m_fUseInternalTimer = false;
+ __super::SetTime(rtNow);
+ // m_fUseInternalTimer = false;
}
// IVMRSurfaceAllocator
STDMETHODIMP CVMR7AllocatorPresenter::AllocateSurface(DWORD_PTR dwUserID, VMRALLOCATIONINFO* lpAllocInfo, DWORD* lpdwBuffer, LPDIRECTDRAWSURFACE7* lplpSurface)
{
- if (!lpAllocInfo || !lpdwBuffer || !lplpSurface) {
- return E_POINTER;
- }
-
- if (!m_pIVMRSurfAllocNotify) {
- return E_FAIL;
- }
-
- HRESULT hr;
-
- DeleteSurfaces();
-
- // HACK: yv12 will fail to blt onto the backbuffer anyway, but if we first
- // allocate it and then let our FreeSurface callback call m_pSA->FreeSurface,
- // then that might stall for about 30 seconds because of some unknown buggy code
- // behind <ddraw surface>->Release()
-
- if (lpAllocInfo->lpHdr->biBitCount < 16) {
- return E_FAIL;
- }
-
- hr = m_pSA->AllocateSurface(dwUserID, lpAllocInfo, lpdwBuffer, lplpSurface);
- if (FAILED(hr)) {
- return hr;
- }
-
- m_NativeVideoSize = CSize(abs(lpAllocInfo->lpHdr->biWidth), abs(lpAllocInfo->lpHdr->biHeight));
- m_AspectRatio = m_NativeVideoSize;
- int arx = lpAllocInfo->szAspectRatio.cx, ary = lpAllocInfo->szAspectRatio.cy;
- if (arx > 0 && ary > 0) {
- m_AspectRatio.SetSize(arx, ary);
- }
-
- if (FAILED(hr = AllocSurfaces())) {
- return hr;
- }
-
- // test if the colorspace is acceptable
- if (FAILED(hr = m_pVideoSurface->Blt(NULL, *lplpSurface, NULL, DDBLT_WAIT, NULL))) {
- DeleteSurfaces();
- return hr;
- }
-
- DDBLTFX fx;
- INITDDSTRUCT(fx);
- fx.dwFillColor = 0;
- m_pVideoSurface->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
-
- return hr;
+ if (!lpAllocInfo || !lpdwBuffer || !lplpSurface) {
+ return E_POINTER;
+ }
+
+ if (!m_pIVMRSurfAllocNotify) {
+ return E_FAIL;
+ }
+
+ HRESULT hr;
+
+ DeleteSurfaces();
+
+ // HACK: yv12 will fail to blt onto the backbuffer anyway, but if we first
+ // allocate it and then let our FreeSurface callback call m_pSA->FreeSurface,
+ // then that might stall for about 30 seconds because of some unknown buggy code
+ // behind <ddraw surface>->Release()
+
+ if (lpAllocInfo->lpHdr->biBitCount < 16) {
+ return E_FAIL;
+ }
+
+ hr = m_pSA->AllocateSurface(dwUserID, lpAllocInfo, lpdwBuffer, lplpSurface);
+ if (FAILED(hr)) {
+ return hr;
+ }
+
+ m_NativeVideoSize = CSize(abs(lpAllocInfo->lpHdr->biWidth), abs(lpAllocInfo->lpHdr->biHeight));
+ m_AspectRatio = m_NativeVideoSize;
+ int arx = lpAllocInfo->szAspectRatio.cx, ary = lpAllocInfo->szAspectRatio.cy;
+ if (arx > 0 && ary > 0) {
+ m_AspectRatio.SetSize(arx, ary);
+ }
+
+ if (FAILED(hr = AllocSurfaces())) {
+ return hr;
+ }
+
+ // test if the colorspace is acceptable
+ if (FAILED(hr = m_pVideoSurface->Blt(NULL, *lplpSurface, NULL, DDBLT_WAIT, NULL))) {
+ DeleteSurfaces();
+ return hr;
+ }
+
+ DDBLTFX fx;
+ INITDDSTRUCT(fx);
+ fx.dwFillColor = 0;
+ m_pVideoSurface->Blt(NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx);
+
+ return hr;
}
STDMETHODIMP CVMR7AllocatorPresenter::FreeSurface(DWORD_PTR dwUserID)
{
- DeleteSurfaces();
- return S_OK;
+ DeleteSurfaces();
+ return S_OK;
}
STDMETHODIMP CVMR7AllocatorPresenter::PrepareSurface(DWORD_PTR dwUserID, IDirectDrawSurface7* lpSurface, DWORD dwSurfaceFlags)
{
- SetThreadName((DWORD)-1, "CVMR7AllocatorPresenter");
-
- if (!lpSurface) {
- return E_POINTER;
- }
-
- // FIXME: sometimes the msmpeg4/divx3/wmv decoder wants to reuse our
- // surface (expects it to point to the same mem every time), and to avoid
- // problems we can't call m_pSA->PrepareSurface (flips? clears?).
- return S_OK;
- /*
- return m_pSA->PrepareSurface(dwUserID, lpSurface, dwSurfaceFlags);
- */
+ SetThreadName((DWORD) - 1, "CVMR7AllocatorPresenter");
+
+ if (!lpSurface) {
+ return E_POINTER;
+ }
+
+ // FIXME: sometimes the msmpeg4/divx3/wmv decoder wants to reuse our
+ // surface (expects it to point to the same mem every time), and to avoid
+ // problems we can't call m_pSA->PrepareSurface (flips? clears?).
+ return S_OK;
+ /*
+ return m_pSA->PrepareSurface(dwUserID, lpSurface, dwSurfaceFlags);
+ */
}
STDMETHODIMP CVMR7AllocatorPresenter::AdviseNotify(IVMRSurfaceAllocatorNotify* lpIVMRSurfAllocNotify)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- m_pIVMRSurfAllocNotify = lpIVMRSurfAllocNotify;
+ m_pIVMRSurfAllocNotify = lpIVMRSurfAllocNotify;
- HRESULT hr;
- HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- if (FAILED(hr = m_pIVMRSurfAllocNotify->SetDDrawDevice(m_pDD, hMonitor))) {
- return hr;
- }
+ HRESULT hr;
+ HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+ if (FAILED(hr = m_pIVMRSurfAllocNotify->SetDDrawDevice(m_pDD, hMonitor))) {
+ return hr;
+ }
- return m_pSA->AdviseNotify(lpIVMRSurfAllocNotify);
+ return m_pSA->AdviseNotify(lpIVMRSurfAllocNotify);
}
// IVMRImagePresenter
STDMETHODIMP CVMR7AllocatorPresenter::StartPresenting(DWORD_PTR dwUserID)
{
- if (!m_bPendingResetDevice) {
- ASSERT(m_pD3DDev);
- }
+ if (!m_bPendingResetDevice) {
+ ASSERT(m_pD3DDev);
+ }
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return m_pD3DDev ? S_OK : E_FAIL;
+ return m_pD3DDev ? S_OK : E_FAIL;
}
STDMETHODIMP CVMR7AllocatorPresenter::StopPresenting(DWORD_PTR dwUserID)
{
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CVMR7AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMRPRESENTATIONINFO* lpPresInfo)
{
- if (!lpPresInfo || !lpPresInfo->lpSurf) {
- return E_POINTER;
- }
-
- CAutoLock cAutoLock(this);
-
- if (!m_bPendingResetDevice) {
- m_pVideoSurface->Blt(NULL, lpPresInfo->lpSurf, NULL, DDBLT_WAIT, NULL);
- }
-
- if (lpPresInfo->rtEnd > lpPresInfo->rtStart) {
- REFERENCE_TIME rtTimePerFrame = lpPresInfo->rtEnd - lpPresInfo->rtStart;
- m_fps = 10000000.0 / rtTimePerFrame;
-
- if (m_pSubPicQueue) {
- m_pSubPicQueue->SetFPS(m_fps);
-
- if (m_fUseInternalTimer && !g_bExternalSubtitleTime) {
- __super::SetTime(g_tSegmentStart + g_tSampleStart);
- }
- }
- }
-
- CSize VideoSize = m_NativeVideoSize;
- int arx = lpPresInfo->szAspectRatio.cx, ary = lpPresInfo->szAspectRatio.cy;
- if (arx > 0 && ary > 0) {
- VideoSize.cx = VideoSize.cy*arx/ary;
- }
- if (VideoSize != GetVideoSize()) {
- m_AspectRatio.SetSize(arx, ary);
- AfxGetApp()->m_pMainWnd->PostMessage(WM_REARRANGERENDERLESS);
- }
-
- Paint(true);
-
- return S_OK;
+ if (!lpPresInfo || !lpPresInfo->lpSurf) {
+ return E_POINTER;
+ }
+
+ CAutoLock cAutoLock(this);
+
+ if (!m_bPendingResetDevice) {
+ m_pVideoSurface->Blt(NULL, lpPresInfo->lpSurf, NULL, DDBLT_WAIT, NULL);
+ }
+
+ if (lpPresInfo->rtEnd > lpPresInfo->rtStart) {
+ REFERENCE_TIME rtTimePerFrame = lpPresInfo->rtEnd - lpPresInfo->rtStart;
+ m_fps = 10000000.0 / rtTimePerFrame;
+
+ if (m_pSubPicQueue) {
+ m_pSubPicQueue->SetFPS(m_fps);
+
+ if (m_fUseInternalTimer && !g_bExternalSubtitleTime) {
+ __super::SetTime(g_tSegmentStart + g_tSampleStart);
+ }
+ }
+ }
+
+ CSize VideoSize = m_NativeVideoSize;
+ int arx = lpPresInfo->szAspectRatio.cx, ary = lpPresInfo->szAspectRatio.cy;
+ if (arx > 0 && ary > 0) {
+ VideoSize.cx = VideoSize.cy * arx / ary;
+ }
+ if (VideoSize != GetVideoSize()) {
+ m_AspectRatio.SetSize(arx, ary);
+ AfxGetApp()->m_pMainWnd->PostMessage(WM_REARRANGERENDERLESS);
+ }
+
+ Paint(true);
+
+ return S_OK;
}
// IVMRWindowlessControl
@@ -302,100 +302,100 @@ STDMETHODIMP CVMR7AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMRPRESEN
STDMETHODIMP CVMR7AllocatorPresenter::GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight)
{
- CSize vs = m_NativeVideoSize, ar = m_AspectRatio;
- // DVD Nav. bug workaround fix
- vs.cx = vs.cy * ar.cx / ar.cy;
- if (lpWidth) {
- *lpWidth = vs.cx;
- }
- if (lpHeight) {
- *lpHeight = vs.cy;
- }
- if (lpARWidth) {
- *lpARWidth = ar.cx;
- }
- if (lpARHeight) {
- *lpARHeight = ar.cy;
- }
- return S_OK;
+ CSize vs = m_NativeVideoSize, ar = m_AspectRatio;
+ // DVD Nav. bug workaround fix
+ vs.cx = vs.cy * ar.cx / ar.cy;
+ if (lpWidth) {
+ *lpWidth = vs.cx;
+ }
+ if (lpHeight) {
+ *lpHeight = vs.cy;
+ }
+ if (lpARWidth) {
+ *lpARWidth = ar.cx;
+ }
+ if (lpARHeight) {
+ *lpARHeight = ar.cy;
+ }
+ return S_OK;
}
STDMETHODIMP CVMR7AllocatorPresenter::GetMinIdealVideoSize(LONG* lpWidth, LONG* lpHeight)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CVMR7AllocatorPresenter::GetMaxIdealVideoSize(LONG* lpWidth, LONG* lpHeight)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CVMR7AllocatorPresenter::SetVideoPosition(const LPRECT lpSRCRect, const LPRECT lpDSTRect)
{
- return E_NOTIMPL; // we have our own method for this
+ return E_NOTIMPL; // we have our own method for this
}
STDMETHODIMP CVMR7AllocatorPresenter::GetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect)
{
- CopyRect(lpSRCRect, CRect(CPoint(0, 0), m_NativeVideoSize));
- CopyRect(lpDSTRect, &m_VideoRect);
- // DVD Nav. bug workaround fix
- GetNativeVideoSize(&lpSRCRect->right, &lpSRCRect->bottom, NULL, NULL);
- return S_OK;
+ CopyRect(lpSRCRect, CRect(CPoint(0, 0), m_NativeVideoSize));
+ CopyRect(lpDSTRect, &m_VideoRect);
+ // DVD Nav. bug workaround fix
+ GetNativeVideoSize(&lpSRCRect->right, &lpSRCRect->bottom, NULL, NULL);
+ return S_OK;
}
STDMETHODIMP CVMR7AllocatorPresenter::GetAspectRatioMode(DWORD* lpAspectRatioMode)
{
- if (lpAspectRatioMode) {
- *lpAspectRatioMode = AM_ARMODE_STRETCHED;
- }
- return S_OK;
+ if (lpAspectRatioMode) {
+ *lpAspectRatioMode = AM_ARMODE_STRETCHED;
+ }
+ return S_OK;
}
STDMETHODIMP CVMR7AllocatorPresenter::SetAspectRatioMode(DWORD AspectRatioMode)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CVMR7AllocatorPresenter::SetVideoClippingWindow(HWND hwnd)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CVMR7AllocatorPresenter::RepaintVideo(HWND hwnd, HDC hdc)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CVMR7AllocatorPresenter::DisplayModeChanged()
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CVMR7AllocatorPresenter::GetCurrentImage(BYTE** lpDib)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CVMR7AllocatorPresenter::SetBorderColor(COLORREF Clr)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CVMR7AllocatorPresenter::GetBorderColor(COLORREF* lpClr)
{
- if (lpClr) {
- *lpClr = 0;
- }
- return S_OK;
+ if (lpClr) {
+ *lpClr = 0;
+ }
+ return S_OK;
}
STDMETHODIMP CVMR7AllocatorPresenter::SetColorKey(COLORREF Clr)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CVMR7AllocatorPresenter::GetColorKey(COLORREF* lpClr)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
diff --git a/src/filters/renderer/VideoRenderers/VMR7AllocatorPresenter.h b/src/filters/renderer/VideoRenderers/VMR7AllocatorPresenter.h
index bb3c215d8..c62cc939b 100644
--- a/src/filters/renderer/VideoRenderers/VMR7AllocatorPresenter.h
+++ b/src/filters/renderer/VideoRenderers/VMR7AllocatorPresenter.h
@@ -28,57 +28,57 @@
namespace DSObjects
{
- class CVMR7AllocatorPresenter
- : public CDX7AllocatorPresenter
- , public IVMRSurfaceAllocator
- , public IVMRImagePresenter
- , public IVMRWindowlessControl
- {
- CComPtr<IVMRSurfaceAllocatorNotify> m_pIVMRSurfAllocNotify;
- CComPtr<IVMRSurfaceAllocator> m_pSA;
+ class CVMR7AllocatorPresenter
+ : public CDX7AllocatorPresenter
+ , public IVMRSurfaceAllocator
+ , public IVMRImagePresenter
+ , public IVMRWindowlessControl
+ {
+ CComPtr<IVMRSurfaceAllocatorNotify> m_pIVMRSurfAllocNotify;
+ CComPtr<IVMRSurfaceAllocator> m_pSA;
- HRESULT CreateDevice();
- void DeleteSurfaces();
+ HRESULT CreateDevice();
+ void DeleteSurfaces();
- bool m_fUseInternalTimer;
+ bool m_fUseInternalTimer;
- public:
- CVMR7AllocatorPresenter(HWND hWnd, HRESULT& hr);
+ public:
+ CVMR7AllocatorPresenter(HWND hWnd, HRESULT& hr);
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // ISubPicAllocatorPresenter
- STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
- STDMETHODIMP_(void) SetTime(REFERENCE_TIME rtNow);
+ // ISubPicAllocatorPresenter
+ STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
+ STDMETHODIMP_(void) SetTime(REFERENCE_TIME rtNow);
- // IVMRSurfaceAllocator
- STDMETHODIMP AllocateSurface(DWORD_PTR dwUserID, VMRALLOCATIONINFO* lpAllocInfo, DWORD* lpdwBuffer, LPDIRECTDRAWSURFACE7* lplpSurface);
- STDMETHODIMP FreeSurface(DWORD_PTR dwUserID);
- STDMETHODIMP PrepareSurface(DWORD_PTR dwUserID, IDirectDrawSurface7* lpSurface, DWORD dwSurfaceFlags);
- STDMETHODIMP AdviseNotify(IVMRSurfaceAllocatorNotify* lpIVMRSurfAllocNotify);
+ // IVMRSurfaceAllocator
+ STDMETHODIMP AllocateSurface(DWORD_PTR dwUserID, VMRALLOCATIONINFO* lpAllocInfo, DWORD* lpdwBuffer, LPDIRECTDRAWSURFACE7* lplpSurface);
+ STDMETHODIMP FreeSurface(DWORD_PTR dwUserID);
+ STDMETHODIMP PrepareSurface(DWORD_PTR dwUserID, IDirectDrawSurface7* lpSurface, DWORD dwSurfaceFlags);
+ STDMETHODIMP AdviseNotify(IVMRSurfaceAllocatorNotify* lpIVMRSurfAllocNotify);
- // IVMRImagePresenter
- STDMETHODIMP StartPresenting(DWORD_PTR dwUserID);
- STDMETHODIMP StopPresenting(DWORD_PTR dwUserID);
- STDMETHODIMP PresentImage(DWORD_PTR dwUserID, VMRPRESENTATIONINFO* lpPresInfo);
+ // IVMRImagePresenter
+ STDMETHODIMP StartPresenting(DWORD_PTR dwUserID);
+ STDMETHODIMP StopPresenting(DWORD_PTR dwUserID);
+ STDMETHODIMP PresentImage(DWORD_PTR dwUserID, VMRPRESENTATIONINFO* lpPresInfo);
- // IVMRWindowlessControl
- STDMETHODIMP GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight);
- STDMETHODIMP GetMinIdealVideoSize(LONG* lpWidth, LONG* lpHeight);
- STDMETHODIMP GetMaxIdealVideoSize(LONG* lpWidth, LONG* lpHeight);
- STDMETHODIMP SetVideoPosition(const LPRECT lpSRCRect, const LPRECT lpDSTRect);
- STDMETHODIMP GetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect);
- STDMETHODIMP GetAspectRatioMode(DWORD* lpAspectRatioMode);
- STDMETHODIMP SetAspectRatioMode(DWORD AspectRatioMode);
- STDMETHODIMP SetVideoClippingWindow(HWND hwnd);
- STDMETHODIMP RepaintVideo(HWND hwnd, HDC hdc);
- STDMETHODIMP DisplayModeChanged();
- STDMETHODIMP GetCurrentImage(BYTE** lpDib);
- STDMETHODIMP SetBorderColor(COLORREF Clr);
- STDMETHODIMP GetBorderColor(COLORREF* lpClr);
- STDMETHODIMP SetColorKey(COLORREF Clr);
- STDMETHODIMP GetColorKey(COLORREF* lpClr);
- };
+ // IVMRWindowlessControl
+ STDMETHODIMP GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight);
+ STDMETHODIMP GetMinIdealVideoSize(LONG* lpWidth, LONG* lpHeight);
+ STDMETHODIMP GetMaxIdealVideoSize(LONG* lpWidth, LONG* lpHeight);
+ STDMETHODIMP SetVideoPosition(const LPRECT lpSRCRect, const LPRECT lpDSTRect);
+ STDMETHODIMP GetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect);
+ STDMETHODIMP GetAspectRatioMode(DWORD* lpAspectRatioMode);
+ STDMETHODIMP SetAspectRatioMode(DWORD AspectRatioMode);
+ STDMETHODIMP SetVideoClippingWindow(HWND hwnd);
+ STDMETHODIMP RepaintVideo(HWND hwnd, HDC hdc);
+ STDMETHODIMP DisplayModeChanged();
+ STDMETHODIMP GetCurrentImage(BYTE** lpDib);
+ STDMETHODIMP SetBorderColor(COLORREF Clr);
+ STDMETHODIMP GetBorderColor(COLORREF* lpClr);
+ STDMETHODIMP SetColorKey(COLORREF Clr);
+ STDMETHODIMP GetColorKey(COLORREF* lpClr);
+ };
}
diff --git a/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.cpp
index 1683ed216..ba552aade 100644
--- a/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.cpp
@@ -40,442 +40,442 @@ using namespace DSObjects;
#define MY_USER_ID 0x6ABE51
-CVMR9AllocatorPresenter::CVMR9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRESULT& hr, CString &_Error)
- : CDX9AllocatorPresenter(hWnd, bFullscreen, hr, false, _Error)
- , m_fUseInternalTimer(false)
- , m_rtPrevStart(-1)
+CVMR9AllocatorPresenter::CVMR9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRESULT& hr, CString& _Error)
+ : CDX9AllocatorPresenter(hWnd, bFullscreen, hr, false, _Error)
+ , m_fUseInternalTimer(false)
+ , m_rtPrevStart(-1)
{
}
STDMETHODIMP CVMR9AllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- QI(IVMRSurfaceAllocator9)
- QI(IVMRImagePresenter9)
- QI(IVMRWindowlessControl9)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IVMRSurfaceAllocator9)
+ QI(IVMRImagePresenter9)
+ QI(IVMRWindowlessControl9)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
-HRESULT CVMR9AllocatorPresenter::CreateDevice(CString &_Error)
+HRESULT CVMR9AllocatorPresenter::CreateDevice(CString& _Error)
{
- HRESULT hr = __super::CreateDevice(_Error);
- if (FAILED(hr)) {
- return hr;
- }
-
- if (m_pIVMRSurfAllocNotify) {
- HMONITOR hMonitor = m_pD3D->GetAdapterMonitor(m_CurrentAdapter);
- if (FAILED(hr = m_pIVMRSurfAllocNotify->ChangeD3DDevice(m_pD3DDev, hMonitor))) {
- _Error += L"m_pIVMRSurfAllocNotify->ChangeD3DDevice failed";
- return hr; //return false;
- }
- }
-
- return hr;
+ HRESULT hr = __super::CreateDevice(_Error);
+ if (FAILED(hr)) {
+ return hr;
+ }
+
+ if (m_pIVMRSurfAllocNotify) {
+ HMONITOR hMonitor = m_pD3D->GetAdapterMonitor(m_CurrentAdapter);
+ if (FAILED(hr = m_pIVMRSurfAllocNotify->ChangeD3DDevice(m_pD3DDev, hMonitor))) {
+ _Error += L"m_pIVMRSurfAllocNotify->ChangeD3DDevice failed";
+ return hr; //return false;
+ }
+ }
+
+ return hr;
}
void CVMR9AllocatorPresenter::DeleteSurfaces()
{
- CAutoLock cAutoLock(this);
- CAutoLock cRenderLock(&m_RenderLock);
+ CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
- m_pSurfaces.RemoveAll();
+ m_pSurfaces.RemoveAll();
- return __super::DeleteSurfaces();
+ return __super::DeleteSurfaces();
}
STDMETHODIMP CVMR9AllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
{
- CheckPointer(ppRenderer, E_POINTER);
+ CheckPointer(ppRenderer, E_POINTER);
- *ppRenderer = NULL;
+ *ppRenderer = NULL;
- HRESULT hr;
+ HRESULT hr;
- do {
- CMacrovisionKicker* pMK = DNew CMacrovisionKicker(NAME("CMacrovisionKicker"), NULL);
- CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)pMK;
+ do {
+ CMacrovisionKicker* pMK = DNew CMacrovisionKicker(NAME("CMacrovisionKicker"), NULL);
+ CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)pMK;
- COuterVMR9 *pOuter = DNew COuterVMR9(NAME("COuterVMR9"), pUnk, &m_VMR9AlphaBitmap, this);
+ COuterVMR9* pOuter = DNew COuterVMR9(NAME("COuterVMR9"), pUnk, &m_VMR9AlphaBitmap, this);
- pMK->SetInner((IUnknown*)(INonDelegatingUnknown*)pOuter);
- CComQIPtr<IBaseFilter> pBF = pUnk;
+ pMK->SetInner((IUnknown*)(INonDelegatingUnknown*)pOuter);
+ CComQIPtr<IBaseFilter> pBF = pUnk;
- CComPtr<IPin> pPin = GetFirstPin(pBF);
- CComQIPtr<IMemInputPin> pMemInputPin = pPin;
- m_fUseInternalTimer = HookNewSegmentAndReceive((IPinC*)(IPin*)pPin, (IMemInputPinC*)(IMemInputPin*)pMemInputPin);
+ CComPtr<IPin> pPin = GetFirstPin(pBF);
+ CComQIPtr<IMemInputPin> pMemInputPin = pPin;
+ m_fUseInternalTimer = HookNewSegmentAndReceive((IPinC*)(IPin*)pPin, (IMemInputPinC*)(IMemInputPin*)pMemInputPin);
- if (CComQIPtr<IAMVideoAccelerator> pAMVA = pPin) {
- HookAMVideoAccelerator((IAMVideoAcceleratorC*)(IAMVideoAccelerator*)pAMVA);
- }
+ if (CComQIPtr<IAMVideoAccelerator> pAMVA = pPin) {
+ HookAMVideoAccelerator((IAMVideoAcceleratorC*)(IAMVideoAccelerator*)pAMVA);
+ }
- CComQIPtr<IVMRFilterConfig9> pConfig = pBF;
- if (!pConfig) {
- break;
- }
+ CComQIPtr<IVMRFilterConfig9> pConfig = pBF;
+ if (!pConfig) {
+ break;
+ }
- CRenderersSettings& s = GetRenderersSettings();
+ CRenderersSettings& s = GetRenderersSettings();
- if (s.fVMR9MixerMode) {
- if (FAILED(hr = pConfig->SetNumberOfStreams(1))) {
- break;
- }
+ if (s.fVMR9MixerMode) {
+ if (FAILED(hr = pConfig->SetNumberOfStreams(1))) {
+ break;
+ }
- if (CComQIPtr<IVMRMixerControl9> pMC = pBF) {
- DWORD dwPrefs;
- pMC->GetMixingPrefs(&dwPrefs);
+ if (CComQIPtr<IVMRMixerControl9> pMC = pBF) {
+ DWORD dwPrefs;
+ pMC->GetMixingPrefs(&dwPrefs);
- // See http://msdn.microsoft.com/en-us/library/dd390928(VS.85).aspx
- dwPrefs |= MixerPref9_NonSquareMixing;
- dwPrefs |= MixerPref9_NoDecimation;
- if (s.fVMR9MixerYUV && !SysVersion::IsVistaOrLater()) {
- dwPrefs &= ~MixerPref9_RenderTargetMask;
- dwPrefs |= MixerPref9_RenderTargetYUV;
- }
- pMC->SetMixingPrefs(dwPrefs);
- }
- }
+ // See http://msdn.microsoft.com/en-us/library/dd390928(VS.85).aspx
+ dwPrefs |= MixerPref9_NonSquareMixing;
+ dwPrefs |= MixerPref9_NoDecimation;
+ if (s.fVMR9MixerYUV && !SysVersion::IsVistaOrLater()) {
+ dwPrefs &= ~MixerPref9_RenderTargetMask;
+ dwPrefs |= MixerPref9_RenderTargetYUV;
+ }
+ pMC->SetMixingPrefs(dwPrefs);
+ }
+ }
- if (FAILED(hr = pConfig->SetRenderingMode(VMR9Mode_Renderless))) {
- break;
- }
+ if (FAILED(hr = pConfig->SetRenderingMode(VMR9Mode_Renderless))) {
+ break;
+ }
- CComQIPtr<IVMRSurfaceAllocatorNotify9> pSAN = pBF;
- if (!pSAN) {
- break;
- }
+ CComQIPtr<IVMRSurfaceAllocatorNotify9> pSAN = pBF;
+ if (!pSAN) {
+ break;
+ }
- if (FAILED(hr = pSAN->AdviseSurfaceAllocator(MY_USER_ID, static_cast<IVMRSurfaceAllocator9*>(this)))
- || FAILED(hr = AdviseNotify(pSAN))) {
- break;
- }
+ if (FAILED(hr = pSAN->AdviseSurfaceAllocator(MY_USER_ID, static_cast<IVMRSurfaceAllocator9*>(this)))
+ || FAILED(hr = AdviseNotify(pSAN))) {
+ break;
+ }
- *ppRenderer = (IUnknown*)pBF.Detach();
+ *ppRenderer = (IUnknown*)pBF.Detach();
- return S_OK;
- } while (0);
+ return S_OK;
+ } while (0);
- return E_FAIL;
+ return E_FAIL;
}
STDMETHODIMP_(void) CVMR9AllocatorPresenter::SetTime(REFERENCE_TIME rtNow)
{
- __super::SetTime(rtNow);
- //m_fUseInternalTimer = false;
+ __super::SetTime(rtNow);
+ //m_fUseInternalTimer = false;
}
// IVMRSurfaceAllocator9
STDMETHODIMP CVMR9AllocatorPresenter::InitializeDevice(DWORD_PTR dwUserID, VMR9AllocationInfo* lpAllocInfo, DWORD* lpNumBuffers)
{
- CAutoLock lock(this);
- CAutoLock cRenderLock(&m_RenderLock);
-
- if (!lpAllocInfo || !lpNumBuffers) {
- return E_POINTER;
- }
-
- if (!m_pIVMRSurfAllocNotify) {
- return E_FAIL;
- }
-
- // WTF: Is this some kind of forgotten debug code ?
- if ((GetAsyncKeyState(VK_CONTROL)&0x80000000))
- if (lpAllocInfo->Format == '21VY' || lpAllocInfo->Format == '024I') {
- return E_FAIL;
- }
-
- // The surfaces should already be free when InitializeDevice is called
- DeleteSurfaces();
-
- DWORD nOriginal = *lpNumBuffers;
-
- if (*lpNumBuffers == 1) {
- *lpNumBuffers = 4;
- m_nVMR9Surfaces = 4;
- } else {
- m_nVMR9Surfaces = 0;
- }
- m_pSurfaces.SetCount(*lpNumBuffers);
-
- int w = lpAllocInfo->dwWidth;
- int h = abs((int)lpAllocInfo->dwHeight);
-
- HRESULT hr;
-
- if (lpAllocInfo->dwFlags & VMR9AllocFlag_3DRenderTarget) {
- lpAllocInfo->dwFlags |= VMR9AllocFlag_TextureSurface;
- }
-
- hr = m_pIVMRSurfAllocNotify->AllocateSurfaceHelper(lpAllocInfo, lpNumBuffers, &m_pSurfaces[0]);
- if (FAILED(hr)) {
- return hr;
- }
-
- m_pSurfaces.SetCount(*lpNumBuffers);
-
- m_bNeedCheckSample = true;
- m_NativeVideoSize = CSize(w, h);
- CSize VideoSize = GetVisibleVideoSize();
- int arx = lpAllocInfo->szAspectRatio.cx;
- int ary = lpAllocInfo->szAspectRatio.cy;
- if (arx > 0 && ary > 0) {
- arx = arx * VideoSize.cx / m_NativeVideoSize.cx;
- ary = ary * VideoSize.cy / m_NativeVideoSize.cy;
- m_AspectRatio.SetSize(arx, ary);
- } else {
- m_AspectRatio = VideoSize;
- }
-
- if (FAILED(hr = AllocSurfaces())) {
- return hr;
- }
-
- if (!(lpAllocInfo->dwFlags & VMR9AllocFlag_TextureSurface)) {
- // test if the colorspace is acceptable
- if (FAILED(hr = m_pD3DDev->StretchRect(m_pSurfaces[0], NULL, m_pVideoSurface[m_nCurSurface], NULL, D3DTEXF_NONE))) {
- DeleteSurfaces();
- return E_FAIL;
- }
- }
-
- hr = m_pD3DDev->ColorFill(m_pVideoSurface[m_nCurSurface], NULL, 0);
-
- if (m_nVMR9Surfaces && m_nVMR9Surfaces != (int)*lpNumBuffers) {
- m_nVMR9Surfaces = *lpNumBuffers;
- }
- *lpNumBuffers = min(nOriginal, *lpNumBuffers);
- m_iVMR9Surface = 0;
-
- return hr;
+ CAutoLock lock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
+
+ if (!lpAllocInfo || !lpNumBuffers) {
+ return E_POINTER;
+ }
+
+ if (!m_pIVMRSurfAllocNotify) {
+ return E_FAIL;
+ }
+
+ // WTF: Is this some kind of forgotten debug code ?
+ if ((GetAsyncKeyState(VK_CONTROL) & 0x80000000))
+ if (lpAllocInfo->Format == '21VY' || lpAllocInfo->Format == '024I') {
+ return E_FAIL;
+ }
+
+ // The surfaces should already be free when InitializeDevice is called
+ DeleteSurfaces();
+
+ DWORD nOriginal = *lpNumBuffers;
+
+ if (*lpNumBuffers == 1) {
+ *lpNumBuffers = 4;
+ m_nVMR9Surfaces = 4;
+ } else {
+ m_nVMR9Surfaces = 0;
+ }
+ m_pSurfaces.SetCount(*lpNumBuffers);
+
+ int w = lpAllocInfo->dwWidth;
+ int h = abs((int)lpAllocInfo->dwHeight);
+
+ HRESULT hr;
+
+ if (lpAllocInfo->dwFlags & VMR9AllocFlag_3DRenderTarget) {
+ lpAllocInfo->dwFlags |= VMR9AllocFlag_TextureSurface;
+ }
+
+ hr = m_pIVMRSurfAllocNotify->AllocateSurfaceHelper(lpAllocInfo, lpNumBuffers, &m_pSurfaces[0]);
+ if (FAILED(hr)) {
+ return hr;
+ }
+
+ m_pSurfaces.SetCount(*lpNumBuffers);
+
+ m_bNeedCheckSample = true;
+ m_NativeVideoSize = CSize(w, h);
+ CSize VideoSize = GetVisibleVideoSize();
+ int arx = lpAllocInfo->szAspectRatio.cx;
+ int ary = lpAllocInfo->szAspectRatio.cy;
+ if (arx > 0 && ary > 0) {
+ arx = arx * VideoSize.cx / m_NativeVideoSize.cx;
+ ary = ary * VideoSize.cy / m_NativeVideoSize.cy;
+ m_AspectRatio.SetSize(arx, ary);
+ } else {
+ m_AspectRatio = VideoSize;
+ }
+
+ if (FAILED(hr = AllocSurfaces())) {
+ return hr;
+ }
+
+ if (!(lpAllocInfo->dwFlags & VMR9AllocFlag_TextureSurface)) {
+ // test if the colorspace is acceptable
+ if (FAILED(hr = m_pD3DDev->StretchRect(m_pSurfaces[0], NULL, m_pVideoSurface[m_nCurSurface], NULL, D3DTEXF_NONE))) {
+ DeleteSurfaces();
+ return E_FAIL;
+ }
+ }
+
+ hr = m_pD3DDev->ColorFill(m_pVideoSurface[m_nCurSurface], NULL, 0);
+
+ if (m_nVMR9Surfaces && m_nVMR9Surfaces != (int)*lpNumBuffers) {
+ m_nVMR9Surfaces = *lpNumBuffers;
+ }
+ *lpNumBuffers = min(nOriginal, *lpNumBuffers);
+ m_iVMR9Surface = 0;
+
+ return hr;
}
STDMETHODIMP CVMR9AllocatorPresenter::TerminateDevice(DWORD_PTR dwUserID)
{
- // We should not free the surfaces until we are told to !
- // Thats what TerminateDevice is for
- DeleteSurfaces();
- return S_OK;
+ // We should not free the surfaces until we are told to !
+ // Thats what TerminateDevice is for
+ DeleteSurfaces();
+ return S_OK;
}
STDMETHODIMP CVMR9AllocatorPresenter::GetSurface(DWORD_PTR dwUserID, DWORD SurfaceIndex, DWORD SurfaceFlags, IDirect3DSurface9** lplpSurface)
{
- if (!lplpSurface) {
- return E_POINTER;
- }
-
- CAutoLock cAutoLock(this);
- CAutoLock cRenderLock(&m_RenderLock);
-
- /*
- SurfaceIndex = 0
- m_pSurfaces.GetCount() = 0
-
- Scenario:
- Thread 1:
- Wait on m_RenderLock in this function
- Thread 2:
- Have m_RenderLock and removes all m_pSurfaces
- (Happens by calling ex CDX9AllocatorPresenter::ResetDevice)
-
- When thread 2 releases the lock thread 1 gets it and boom!
-
- Possible solution: Adding object lock and moving m_RenderLock to try to fix this threading issue.
- This problem occurs when moving the window from display a to display b.
-
- NOTE: This is just a workaround.
- CDX9AllocatorPresenter doesn't follow the rules which is why this happened.
- And it is used by EVR custom (which it really shouldn't) so i can't easily fix it without breaking EVR custom.
- */
- if (SurfaceIndex >= m_pSurfaces.GetCount()) {
- return E_FAIL;
- }
-
- if (m_nVMR9Surfaces) {
- ++m_iVMR9Surface;
- m_iVMR9Surface = m_iVMR9Surface % m_nVMR9Surfaces;
- *lplpSurface = m_pSurfaces[m_iVMR9Surface + SurfaceIndex];
- (*lplpSurface)->AddRef();
- } else {
- m_iVMR9Surface = SurfaceIndex;
- *lplpSurface = m_pSurfaces[SurfaceIndex];
- (*lplpSurface)->AddRef();
- }
-
- return S_OK;
+ if (!lplpSurface) {
+ return E_POINTER;
+ }
+
+ CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
+
+ /*
+ SurfaceIndex = 0
+ m_pSurfaces.GetCount() = 0
+
+ Scenario:
+ Thread 1:
+ Wait on m_RenderLock in this function
+ Thread 2:
+ Have m_RenderLock and removes all m_pSurfaces
+ (Happens by calling ex CDX9AllocatorPresenter::ResetDevice)
+
+ When thread 2 releases the lock thread 1 gets it and boom!
+
+ Possible solution: Adding object lock and moving m_RenderLock to try to fix this threading issue.
+ This problem occurs when moving the window from display a to display b.
+
+ NOTE: This is just a workaround.
+ CDX9AllocatorPresenter doesn't follow the rules which is why this happened.
+ And it is used by EVR custom (which it really shouldn't) so i can't easily fix it without breaking EVR custom.
+ */
+ if (SurfaceIndex >= m_pSurfaces.GetCount()) {
+ return E_FAIL;
+ }
+
+ if (m_nVMR9Surfaces) {
+ ++m_iVMR9Surface;
+ m_iVMR9Surface = m_iVMR9Surface % m_nVMR9Surfaces;
+ *lplpSurface = m_pSurfaces[m_iVMR9Surface + SurfaceIndex];
+ (*lplpSurface)->AddRef();
+ } else {
+ m_iVMR9Surface = SurfaceIndex;
+ *lplpSurface = m_pSurfaces[SurfaceIndex];
+ (*lplpSurface)->AddRef();
+ }
+
+ return S_OK;
}
STDMETHODIMP CVMR9AllocatorPresenter::AdviseNotify(IVMRSurfaceAllocatorNotify9* lpIVMRSurfAllocNotify)
{
- CAutoLock cAutoLock(this);
- CAutoLock cRenderLock(&m_RenderLock);
+ CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
- m_pIVMRSurfAllocNotify = lpIVMRSurfAllocNotify;
+ m_pIVMRSurfAllocNotify = lpIVMRSurfAllocNotify;
- HRESULT hr;
- HMONITOR hMonitor = m_pD3D->GetAdapterMonitor(GetAdapter(m_pD3D));
- if (FAILED(hr = m_pIVMRSurfAllocNotify->SetD3DDevice(m_pD3DDev, hMonitor))) {
- return hr;
- }
+ HRESULT hr;
+ HMONITOR hMonitor = m_pD3D->GetAdapterMonitor(GetAdapter(m_pD3D));
+ if (FAILED(hr = m_pIVMRSurfAllocNotify->SetD3DDevice(m_pD3DDev, hMonitor))) {
+ return hr;
+ }
- return S_OK;
+ return S_OK;
}
// IVMRImagePresenter9
STDMETHODIMP CVMR9AllocatorPresenter::StartPresenting(DWORD_PTR dwUserID)
{
- if (!m_bPendingResetDevice) {
- ASSERT(m_pD3DDev);
- }
+ if (!m_bPendingResetDevice) {
+ ASSERT(m_pD3DDev);
+ }
- CAutoLock cAutoLock(this);
- CAutoLock cRenderLock(&m_RenderLock);
+ CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
- return m_pD3DDev ? S_OK : E_FAIL;
+ return m_pD3DDev ? S_OK : E_FAIL;
}
STDMETHODIMP CVMR9AllocatorPresenter::StopPresenting(DWORD_PTR dwUserID)
{
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CVMR9AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMR9PresentationInfo* lpPresInfo)
{
- SetThreadName((DWORD)-1, "CVMR9AllocatorPresenter");
- CheckPointer(m_pIVMRSurfAllocNotify, E_UNEXPECTED);
-
- if (m_rtTimePerFrame == 0 || m_bNeedCheckSample) {
- m_bNeedCheckSample = false;
- CComPtr<IBaseFilter> pVMR9;
- CComPtr<IPin> pPin;
- CMediaType mt;
-
- if (SUCCEEDED (m_pIVMRSurfAllocNotify->QueryInterface (__uuidof(IBaseFilter), (void**)&pVMR9)) &&
- SUCCEEDED (pVMR9->FindPin(L"VMR Input0", &pPin)) &&
- SUCCEEDED (pPin->ConnectionMediaType(&mt)) ) {
- ExtractAvgTimePerFrame (&mt, m_rtTimePerFrame);
-
- CSize NativeVideoSize = m_NativeVideoSize;
- CSize AspectRatio = m_AspectRatio;
- if (mt.formattype==FORMAT_VideoInfo || mt.formattype==FORMAT_MPEGVideo) {
- VIDEOINFOHEADER *vh = (VIDEOINFOHEADER*)mt.pbFormat;
-
- NativeVideoSize = CSize(vh->bmiHeader.biWidth, abs(vh->bmiHeader.biHeight));
- if (vh->rcTarget.right - vh->rcTarget.left > 0) {
- NativeVideoSize.cx = vh->rcTarget.right - vh->rcTarget.left;
- } else if (vh->rcSource.right - vh->rcSource.left > 0) {
- NativeVideoSize.cx = vh->rcSource.right - vh->rcSource.left;
- }
-
- if (vh->rcTarget.bottom - vh->rcTarget.top > 0) {
- NativeVideoSize.cy = vh->rcTarget.bottom - vh->rcTarget.top;
- } else if (vh->rcSource.bottom - vh->rcSource.top > 0) {
- NativeVideoSize.cy = vh->rcSource.bottom - vh->rcSource.top;
- }
- } else if (mt.formattype==FORMAT_VideoInfo2 || mt.formattype==FORMAT_MPEG2Video) {
- VIDEOINFOHEADER2 *vh = (VIDEOINFOHEADER2*)mt.pbFormat;
-
- if (vh->dwPictAspectRatioX && vh->dwPictAspectRatioY) {
- AspectRatio = CSize(vh->dwPictAspectRatioX, vh->dwPictAspectRatioY);
- }
-
- NativeVideoSize = CSize(vh->bmiHeader.biWidth, abs(vh->bmiHeader.biHeight));
- if (vh->rcTarget.right - vh->rcTarget.left > 0) {
- NativeVideoSize.cx = vh->rcTarget.right - vh->rcTarget.left;
- } else if (vh->rcSource.right - vh->rcSource.left > 0) {
- NativeVideoSize.cx = vh->rcSource.right - vh->rcSource.left;
- }
-
- if (vh->rcTarget.bottom - vh->rcTarget.top > 0) {
- NativeVideoSize.cy = vh->rcTarget.bottom - vh->rcTarget.top;
- } else if (vh->rcSource.bottom - vh->rcSource.top > 0) {
- NativeVideoSize.cy = vh->rcSource.bottom - vh->rcSource.top;
- }
- }
- if (m_NativeVideoSize != NativeVideoSize || m_AspectRatio != AspectRatio) {
- m_NativeVideoSize = NativeVideoSize;
- m_AspectRatio = AspectRatio;
- AfxGetApp()->m_pMainWnd->PostMessage(WM_REARRANGERENDERLESS);
- }
- }
- // If framerate not set by Video Decoder choose 23.97...
- if (m_rtTimePerFrame == 0) {
- m_rtTimePerFrame = 417166;
- }
-
- m_fps = 10000000.0 / m_rtTimePerFrame;
- }
-
- HRESULT hr;
-
- if (!lpPresInfo || !lpPresInfo->lpSurf) {
- return E_POINTER;
- }
-
- CAutoLock cAutoLock(this);
- CAutoLock cRenderLock(&m_RenderLock);
-
- if (lpPresInfo->rtEnd > lpPresInfo->rtStart) {
- if (m_pSubPicQueue) {
- m_pSubPicQueue->SetFPS(m_fps);
-
- if (m_fUseInternalTimer && !g_bExternalSubtitleTime) {
- __super::SetTime(g_tSegmentStart + g_tSampleStart);
- }
- }
- }
-
- CSize VideoSize = GetVisibleVideoSize();
- int arx = lpPresInfo->szAspectRatio.cx;
- int ary = lpPresInfo->szAspectRatio.cy;
- if (arx > 0 && ary > 0) {
- arx = arx * VideoSize.cx / m_NativeVideoSize.cx;
- ary = ary * VideoSize.cy / m_NativeVideoSize.cy;
- VideoSize.cx = VideoSize.cy*arx/ary;
- }
- if (VideoSize != GetVideoSize()) {
- m_AspectRatio.SetSize(arx, ary);
- AfxGetApp()->m_pMainWnd->PostMessage(WM_REARRANGERENDERLESS);
- }
-
- if (!m_bPendingResetDevice) {
- CComPtr<IDirect3DTexture9> pTexture;
- lpPresInfo->lpSurf->GetContainer(IID_IDirect3DTexture9, (void**)&pTexture);
-
- if (pTexture) {
- m_pVideoSurface[m_nCurSurface] = lpPresInfo->lpSurf;
- if (m_pVideoTexture[m_nCurSurface]) {
- m_pVideoTexture[m_nCurSurface] = pTexture;
- }
- } else {
- hr = m_pD3DDev->StretchRect(lpPresInfo->lpSurf, NULL, m_pVideoSurface[m_nCurSurface], NULL, D3DTEXF_NONE);
- }
-
- // Tear test bars
- if (GetRenderersData()->m_fTearingTest) {
- RECT rcTearing;
-
- rcTearing.left = m_nTearingPos;
- rcTearing.top = 0;
- rcTearing.right = rcTearing.left + 4;
- rcTearing.bottom = m_NativeVideoSize.cy;
- m_pD3DDev->ColorFill (m_pVideoSurface[m_nCurSurface], &rcTearing, D3DCOLOR_ARGB (255,255,0,0));
-
- rcTearing.left = (rcTearing.right + 15) % m_NativeVideoSize.cx;
- rcTearing.right = rcTearing.left + 4;
- m_pD3DDev->ColorFill (m_pVideoSurface[m_nCurSurface], &rcTearing, D3DCOLOR_ARGB (255,255,0,0));
-
- m_nTearingPos = (m_nTearingPos + 7) % m_NativeVideoSize.cx;
- }
- }
-
- Paint(true);
-
- return S_OK;
+ SetThreadName((DWORD) - 1, "CVMR9AllocatorPresenter");
+ CheckPointer(m_pIVMRSurfAllocNotify, E_UNEXPECTED);
+
+ if (m_rtTimePerFrame == 0 || m_bNeedCheckSample) {
+ m_bNeedCheckSample = false;
+ CComPtr<IBaseFilter> pVMR9;
+ CComPtr<IPin> pPin;
+ CMediaType mt;
+
+ if (SUCCEEDED(m_pIVMRSurfAllocNotify->QueryInterface(__uuidof(IBaseFilter), (void**)&pVMR9)) &&
+ SUCCEEDED(pVMR9->FindPin(L"VMR Input0", &pPin)) &&
+ SUCCEEDED(pPin->ConnectionMediaType(&mt))) {
+ ExtractAvgTimePerFrame(&mt, m_rtTimePerFrame);
+
+ CSize NativeVideoSize = m_NativeVideoSize;
+ CSize AspectRatio = m_AspectRatio;
+ if (mt.formattype == FORMAT_VideoInfo || mt.formattype == FORMAT_MPEGVideo) {
+ VIDEOINFOHEADER* vh = (VIDEOINFOHEADER*)mt.pbFormat;
+
+ NativeVideoSize = CSize(vh->bmiHeader.biWidth, abs(vh->bmiHeader.biHeight));
+ if (vh->rcTarget.right - vh->rcTarget.left > 0) {
+ NativeVideoSize.cx = vh->rcTarget.right - vh->rcTarget.left;
+ } else if (vh->rcSource.right - vh->rcSource.left > 0) {
+ NativeVideoSize.cx = vh->rcSource.right - vh->rcSource.left;
+ }
+
+ if (vh->rcTarget.bottom - vh->rcTarget.top > 0) {
+ NativeVideoSize.cy = vh->rcTarget.bottom - vh->rcTarget.top;
+ } else if (vh->rcSource.bottom - vh->rcSource.top > 0) {
+ NativeVideoSize.cy = vh->rcSource.bottom - vh->rcSource.top;
+ }
+ } else if (mt.formattype == FORMAT_VideoInfo2 || mt.formattype == FORMAT_MPEG2Video) {
+ VIDEOINFOHEADER2* vh = (VIDEOINFOHEADER2*)mt.pbFormat;
+
+ if (vh->dwPictAspectRatioX && vh->dwPictAspectRatioY) {
+ AspectRatio = CSize(vh->dwPictAspectRatioX, vh->dwPictAspectRatioY);
+ }
+
+ NativeVideoSize = CSize(vh->bmiHeader.biWidth, abs(vh->bmiHeader.biHeight));
+ if (vh->rcTarget.right - vh->rcTarget.left > 0) {
+ NativeVideoSize.cx = vh->rcTarget.right - vh->rcTarget.left;
+ } else if (vh->rcSource.right - vh->rcSource.left > 0) {
+ NativeVideoSize.cx = vh->rcSource.right - vh->rcSource.left;
+ }
+
+ if (vh->rcTarget.bottom - vh->rcTarget.top > 0) {
+ NativeVideoSize.cy = vh->rcTarget.bottom - vh->rcTarget.top;
+ } else if (vh->rcSource.bottom - vh->rcSource.top > 0) {
+ NativeVideoSize.cy = vh->rcSource.bottom - vh->rcSource.top;
+ }
+ }
+ if (m_NativeVideoSize != NativeVideoSize || m_AspectRatio != AspectRatio) {
+ m_NativeVideoSize = NativeVideoSize;
+ m_AspectRatio = AspectRatio;
+ AfxGetApp()->m_pMainWnd->PostMessage(WM_REARRANGERENDERLESS);
+ }
+ }
+ // If framerate not set by Video Decoder choose 23.97...
+ if (m_rtTimePerFrame == 0) {
+ m_rtTimePerFrame = 417166;
+ }
+
+ m_fps = 10000000.0 / m_rtTimePerFrame;
+ }
+
+ HRESULT hr;
+
+ if (!lpPresInfo || !lpPresInfo->lpSurf) {
+ return E_POINTER;
+ }
+
+ CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
+
+ if (lpPresInfo->rtEnd > lpPresInfo->rtStart) {
+ if (m_pSubPicQueue) {
+ m_pSubPicQueue->SetFPS(m_fps);
+
+ if (m_fUseInternalTimer && !g_bExternalSubtitleTime) {
+ __super::SetTime(g_tSegmentStart + g_tSampleStart);
+ }
+ }
+ }
+
+ CSize VideoSize = GetVisibleVideoSize();
+ int arx = lpPresInfo->szAspectRatio.cx;
+ int ary = lpPresInfo->szAspectRatio.cy;
+ if (arx > 0 && ary > 0) {
+ arx = arx * VideoSize.cx / m_NativeVideoSize.cx;
+ ary = ary * VideoSize.cy / m_NativeVideoSize.cy;
+ VideoSize.cx = VideoSize.cy * arx / ary;
+ }
+ if (VideoSize != GetVideoSize()) {
+ m_AspectRatio.SetSize(arx, ary);
+ AfxGetApp()->m_pMainWnd->PostMessage(WM_REARRANGERENDERLESS);
+ }
+
+ if (!m_bPendingResetDevice) {
+ CComPtr<IDirect3DTexture9> pTexture;
+ lpPresInfo->lpSurf->GetContainer(IID_IDirect3DTexture9, (void**)&pTexture);
+
+ if (pTexture) {
+ m_pVideoSurface[m_nCurSurface] = lpPresInfo->lpSurf;
+ if (m_pVideoTexture[m_nCurSurface]) {
+ m_pVideoTexture[m_nCurSurface] = pTexture;
+ }
+ } else {
+ hr = m_pD3DDev->StretchRect(lpPresInfo->lpSurf, NULL, m_pVideoSurface[m_nCurSurface], NULL, D3DTEXF_NONE);
+ }
+
+ // Tear test bars
+ if (GetRenderersData()->m_fTearingTest) {
+ RECT rcTearing;
+
+ rcTearing.left = m_nTearingPos;
+ rcTearing.top = 0;
+ rcTearing.right = rcTearing.left + 4;
+ rcTearing.bottom = m_NativeVideoSize.cy;
+ m_pD3DDev->ColorFill(m_pVideoSurface[m_nCurSurface], &rcTearing, D3DCOLOR_ARGB(255, 255, 0, 0));
+
+ rcTearing.left = (rcTearing.right + 15) % m_NativeVideoSize.cx;
+ rcTearing.right = rcTearing.left + 4;
+ m_pD3DDev->ColorFill(m_pVideoSurface[m_nCurSurface], &rcTearing, D3DCOLOR_ARGB(255, 255, 0, 0));
+
+ m_nTearingPos = (m_nTearingPos + 7) % m_NativeVideoSize.cx;
+ }
+ }
+
+ Paint(true);
+
+ return S_OK;
}
// IVMRWindowlessControl9
@@ -486,85 +486,85 @@ STDMETHODIMP CVMR9AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMR9Prese
STDMETHODIMP CVMR9AllocatorPresenter::GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight)
{
- if (lpWidth) {
- *lpWidth = m_NativeVideoSize.cx;
- }
- if (lpHeight) {
- *lpHeight = m_NativeVideoSize.cy;
- }
- if (lpARWidth) {
- *lpARWidth = m_AspectRatio.cx;
- }
- if (lpARHeight) {
- *lpARHeight = m_AspectRatio.cy;
- }
- return S_OK;
+ if (lpWidth) {
+ *lpWidth = m_NativeVideoSize.cx;
+ }
+ if (lpHeight) {
+ *lpHeight = m_NativeVideoSize.cy;
+ }
+ if (lpARWidth) {
+ *lpARWidth = m_AspectRatio.cx;
+ }
+ if (lpARHeight) {
+ *lpARHeight = m_AspectRatio.cy;
+ }
+ return S_OK;
}
STDMETHODIMP CVMR9AllocatorPresenter::GetMinIdealVideoSize(LONG* lpWidth, LONG* lpHeight)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CVMR9AllocatorPresenter::GetMaxIdealVideoSize(LONG* lpWidth, LONG* lpHeight)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CVMR9AllocatorPresenter::SetVideoPosition(const LPRECT lpSRCRect, const LPRECT lpDSTRect)
{
- return E_NOTIMPL; // we have our own method for this
+ return E_NOTIMPL; // we have our own method for this
}
STDMETHODIMP CVMR9AllocatorPresenter::GetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect)
{
- CopyRect(lpSRCRect, CRect(CPoint(0, 0), GetVisibleVideoSize()));
- CopyRect(lpDSTRect, &m_VideoRect);
- return S_OK;
+ CopyRect(lpSRCRect, CRect(CPoint(0, 0), GetVisibleVideoSize()));
+ CopyRect(lpDSTRect, &m_VideoRect);
+ return S_OK;
}
STDMETHODIMP CVMR9AllocatorPresenter::GetAspectRatioMode(DWORD* lpAspectRatioMode)
{
- if (lpAspectRatioMode) {
- *lpAspectRatioMode = AM_ARMODE_STRETCHED;
- }
- return S_OK;
+ if (lpAspectRatioMode) {
+ *lpAspectRatioMode = AM_ARMODE_STRETCHED;
+ }
+ return S_OK;
}
STDMETHODIMP CVMR9AllocatorPresenter::SetAspectRatioMode(DWORD AspectRatioMode)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CVMR9AllocatorPresenter::SetVideoClippingWindow(HWND hwnd)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CVMR9AllocatorPresenter::RepaintVideo(HWND hwnd, HDC hdc)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CVMR9AllocatorPresenter::DisplayModeChanged()
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CVMR9AllocatorPresenter::GetCurrentImage(BYTE** lpDib)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CVMR9AllocatorPresenter::SetBorderColor(COLORREF Clr)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CVMR9AllocatorPresenter::GetBorderColor(COLORREF* lpClr)
{
- if (lpClr) {
- *lpClr = 0;
- }
- return S_OK;
+ if (lpClr) {
+ *lpClr = 0;
+ }
+ return S_OK;
}
diff --git a/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.h b/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.h
index 5eeeddf46..be2e4f911 100644
--- a/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.h
+++ b/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.h
@@ -26,56 +26,56 @@
namespace DSObjects
{
- class CVMR9AllocatorPresenter
- : public CDX9AllocatorPresenter
- , public IVMRSurfaceAllocator9
- , public IVMRImagePresenter9
- , public IVMRWindowlessControl9
- {
- protected:
- CComPtr<IVMRSurfaceAllocatorNotify9> m_pIVMRSurfAllocNotify;
- CInterfaceArray<IDirect3DSurface9> m_pSurfaces;
+ class CVMR9AllocatorPresenter
+ : public CDX9AllocatorPresenter
+ , public IVMRSurfaceAllocator9
+ , public IVMRImagePresenter9
+ , public IVMRWindowlessControl9
+ {
+ protected:
+ CComPtr<IVMRSurfaceAllocatorNotify9> m_pIVMRSurfAllocNotify;
+ CInterfaceArray<IDirect3DSurface9> m_pSurfaces;
- HRESULT CreateDevice(CString &_Error);
- void DeleteSurfaces();
+ HRESULT CreateDevice(CString& _Error);
+ void DeleteSurfaces();
- bool m_fUseInternalTimer;
- REFERENCE_TIME m_rtPrevStart;
+ bool m_fUseInternalTimer;
+ REFERENCE_TIME m_rtPrevStart;
- public:
- CVMR9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRESULT& hr, CString &_Error);
+ public:
+ CVMR9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRESULT& hr, CString& _Error);
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // ISubPicAllocatorPresenter
- STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
- STDMETHODIMP_(void) SetTime(REFERENCE_TIME rtNow);
+ // ISubPicAllocatorPresenter
+ STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
+ STDMETHODIMP_(void) SetTime(REFERENCE_TIME rtNow);
- // IVMRSurfaceAllocator9
- STDMETHODIMP InitializeDevice(DWORD_PTR dwUserID, VMR9AllocationInfo* lpAllocInfo, DWORD* lpNumBuffers);
- STDMETHODIMP TerminateDevice(DWORD_PTR dwID);
- STDMETHODIMP GetSurface(DWORD_PTR dwUserID, DWORD SurfaceIndex, DWORD SurfaceFlags, IDirect3DSurface9** lplpSurface);
- STDMETHODIMP AdviseNotify(IVMRSurfaceAllocatorNotify9* lpIVMRSurfAllocNotify);
+ // IVMRSurfaceAllocator9
+ STDMETHODIMP InitializeDevice(DWORD_PTR dwUserID, VMR9AllocationInfo* lpAllocInfo, DWORD* lpNumBuffers);
+ STDMETHODIMP TerminateDevice(DWORD_PTR dwID);
+ STDMETHODIMP GetSurface(DWORD_PTR dwUserID, DWORD SurfaceIndex, DWORD SurfaceFlags, IDirect3DSurface9** lplpSurface);
+ STDMETHODIMP AdviseNotify(IVMRSurfaceAllocatorNotify9* lpIVMRSurfAllocNotify);
- // IVMRImagePresenter9
- STDMETHODIMP StartPresenting(DWORD_PTR dwUserID);
- STDMETHODIMP StopPresenting(DWORD_PTR dwUserID);
- STDMETHODIMP PresentImage(DWORD_PTR dwUserID, VMR9PresentationInfo* lpPresInfo);
+ // IVMRImagePresenter9
+ STDMETHODIMP StartPresenting(DWORD_PTR dwUserID);
+ STDMETHODIMP StopPresenting(DWORD_PTR dwUserID);
+ STDMETHODIMP PresentImage(DWORD_PTR dwUserID, VMR9PresentationInfo* lpPresInfo);
- // IVMRWindowlessControl9
- STDMETHODIMP GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight);
- STDMETHODIMP GetMinIdealVideoSize(LONG* lpWidth, LONG* lpHeight);
- STDMETHODIMP GetMaxIdealVideoSize(LONG* lpWidth, LONG* lpHeight);
- STDMETHODIMP SetVideoPosition(const LPRECT lpSRCRect, const LPRECT lpDSTRect);
- STDMETHODIMP GetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect);
- STDMETHODIMP GetAspectRatioMode(DWORD* lpAspectRatioMode);
- STDMETHODIMP SetAspectRatioMode(DWORD AspectRatioMode);
- STDMETHODIMP SetVideoClippingWindow(HWND hwnd);
- STDMETHODIMP RepaintVideo(HWND hwnd, HDC hdc);
- STDMETHODIMP DisplayModeChanged();
- STDMETHODIMP GetCurrentImage(BYTE** lpDib);
- STDMETHODIMP SetBorderColor(COLORREF Clr);
- STDMETHODIMP GetBorderColor(COLORREF* lpClr);
- };
+ // IVMRWindowlessControl9
+ STDMETHODIMP GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight);
+ STDMETHODIMP GetMinIdealVideoSize(LONG* lpWidth, LONG* lpHeight);
+ STDMETHODIMP GetMaxIdealVideoSize(LONG* lpWidth, LONG* lpHeight);
+ STDMETHODIMP SetVideoPosition(const LPRECT lpSRCRect, const LPRECT lpDSTRect);
+ STDMETHODIMP GetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect);
+ STDMETHODIMP GetAspectRatioMode(DWORD* lpAspectRatioMode);
+ STDMETHODIMP SetAspectRatioMode(DWORD AspectRatioMode);
+ STDMETHODIMP SetVideoClippingWindow(HWND hwnd);
+ STDMETHODIMP RepaintVideo(HWND hwnd, HDC hdc);
+ STDMETHODIMP DisplayModeChanged();
+ STDMETHODIMP GetCurrentImage(BYTE** lpDib);
+ STDMETHODIMP SetBorderColor(COLORREF Clr);
+ STDMETHODIMP GetBorderColor(COLORREF* lpClr);
+ };
}
diff --git a/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.cpp
index de77b1524..a304476b2 100644
--- a/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.cpp
@@ -33,8 +33,8 @@ using namespace DSObjects;
interface __declspec(uuid("D6EE8031-214E-4E9E-A3A7-458925F933AB"))
IMadVRExclusiveModeInfo :
public IUnknown {
- STDMETHOD_(BOOL, IsExclusiveModeActive)(void) = 0;
- STDMETHOD_(BOOL, IsMadVRSeekbarEnabled)(void) = 0;
+ STDMETHOD_(BOOL, IsExclusiveModeActive)(void) = 0;
+ STDMETHOD_(BOOL, IsMadVRSeekbarEnabled)(void) = 0;
};
@@ -42,220 +42,219 @@ public IUnknown {
// CmadVRAllocatorPresenter
//
-CmadVRAllocatorPresenter::CmadVRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error)
- : CSubPicAllocatorPresenterImpl(hWnd, hr, &_Error)
- , m_ScreenSize(0, 0)
+CmadVRAllocatorPresenter::CmadVRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString& _Error)
+ : CSubPicAllocatorPresenterImpl(hWnd, hr, &_Error)
+ , m_ScreenSize(0, 0)
{
- if (FAILED(hr)) {
- _Error += L"ISubPicAllocatorPresenterImpl failed\n";
- return;
- }
+ if (FAILED(hr)) {
+ _Error += L"ISubPicAllocatorPresenterImpl failed\n";
+ return;
+ }
- hr = S_OK;
+ hr = S_OK;
}
CmadVRAllocatorPresenter::~CmadVRAllocatorPresenter()
{
- if (m_pSRCB) {
- // nasty, but we have to let it know about our death somehow
- ((CSubRenderCallback*)(ISubRenderCallback2*)m_pSRCB)->SetDXRAP(NULL);
- }
-
- // the order is important here
- m_pSubPicQueue = NULL;
- m_pAllocator = NULL;
- m_pDXR = NULL;
+ if (m_pSRCB) {
+ // nasty, but we have to let it know about our death somehow
+ ((CSubRenderCallback*)(ISubRenderCallback2*)m_pSRCB)->SetDXRAP(NULL);
+ }
+
+ // the order is important here
+ m_pSubPicQueue = NULL;
+ m_pAllocator = NULL;
+ m_pDXR = NULL;
}
STDMETHODIMP CmadVRAllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- /*
- if (riid == __uuidof(IVideoWindow))
- return GetInterface((IVideoWindow*)this, ppv);
- if (riid == __uuidof(IBasicVideo))
- return GetInterface((IBasicVideo*)this, ppv);
- if (riid == __uuidof(IBasicVideo2))
- return GetInterface((IBasicVideo2*)this, ppv);
- */
- /*
- if (riid == __uuidof(IVMRWindowlessControl))
- return GetInterface((IVMRWindowlessControl*)this, ppv);
- */
-
- if (riid != IID_IUnknown && m_pDXR) {
- if (SUCCEEDED(m_pDXR->QueryInterface(riid, ppv))) {
- return S_OK;
- }
- }
-
- return __super::NonDelegatingQueryInterface(riid, ppv);
+ /*
+ if (riid == __uuidof(IVideoWindow))
+ return GetInterface((IVideoWindow*)this, ppv);
+ if (riid == __uuidof(IBasicVideo))
+ return GetInterface((IBasicVideo*)this, ppv);
+ if (riid == __uuidof(IBasicVideo2))
+ return GetInterface((IBasicVideo2*)this, ppv);
+ */
+ /*
+ if (riid == __uuidof(IVMRWindowlessControl))
+ return GetInterface((IVMRWindowlessControl*)this, ppv);
+ */
+
+ if (riid != IID_IUnknown && m_pDXR) {
+ if (SUCCEEDED(m_pDXR->QueryInterface(riid, ppv))) {
+ return S_OK;
+ }
+ }
+
+ return __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CmadVRAllocatorPresenter::SetDevice(IDirect3DDevice9* pD3DDev)
{
- if (!pD3DDev)
- {
- // release all resources
- m_pSubPicQueue = NULL;
- m_pAllocator = NULL;
- return S_OK;
- }
-
- CSize size;
- switch (GetRenderersSettings().nSPCMaxRes) {
- case 0:
- default:
- size = m_ScreenSize;
- break;
- case 1:
- size.SetSize(1024, 768);
- break;
- case 2:
- size.SetSize(800, 600);
- break;
- case 3:
- size.SetSize(640, 480);
- break;
- case 4:
- size.SetSize(512, 384);
- break;
- case 5:
- size.SetSize(384, 288);
- break;
- case 6:
- size.SetSize(2560, 1600);
- break;
- case 7:
- size.SetSize(1920, 1080);
- break;
- case 8:
- size.SetSize(1320, 900);
- break;
- case 9:
- size.SetSize(1280, 720);
- break;
- }
-
- if (m_pAllocator) {
- m_pAllocator->ChangeDevice(pD3DDev);
- } else {
- m_pAllocator = DNew CDX9SubPicAllocator(pD3DDev, size, GetRenderersSettings().fSPCPow2Tex, true);
- if (!m_pAllocator) {
- return E_FAIL;
- }
- }
-
- HRESULT hr = S_OK;
-
- m_pSubPicQueue = GetRenderersSettings().nSPCSize > 0
- ? (ISubPicQueue*)DNew CSubPicQueue(GetRenderersSettings().nSPCSize, !GetRenderersSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
- : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
- if (!m_pSubPicQueue || FAILED(hr)) {
- return E_FAIL;
- }
-
- if (m_SubPicProvider) {
- m_pSubPicQueue->SetSubPicProvider(m_SubPicProvider);
- }
-
- return S_OK;
+ if (!pD3DDev) {
+ // release all resources
+ m_pSubPicQueue = NULL;
+ m_pAllocator = NULL;
+ return S_OK;
+ }
+
+ CSize size;
+ switch (GetRenderersSettings().nSPCMaxRes) {
+ case 0:
+ default:
+ size = m_ScreenSize;
+ break;
+ case 1:
+ size.SetSize(1024, 768);
+ break;
+ case 2:
+ size.SetSize(800, 600);
+ break;
+ case 3:
+ size.SetSize(640, 480);
+ break;
+ case 4:
+ size.SetSize(512, 384);
+ break;
+ case 5:
+ size.SetSize(384, 288);
+ break;
+ case 6:
+ size.SetSize(2560, 1600);
+ break;
+ case 7:
+ size.SetSize(1920, 1080);
+ break;
+ case 8:
+ size.SetSize(1320, 900);
+ break;
+ case 9:
+ size.SetSize(1280, 720);
+ break;
+ }
+
+ if (m_pAllocator) {
+ m_pAllocator->ChangeDevice(pD3DDev);
+ } else {
+ m_pAllocator = DNew CDX9SubPicAllocator(pD3DDev, size, GetRenderersSettings().fSPCPow2Tex, true);
+ if (!m_pAllocator) {
+ return E_FAIL;
+ }
+ }
+
+ HRESULT hr = S_OK;
+
+ m_pSubPicQueue = GetRenderersSettings().nSPCSize > 0
+ ? (ISubPicQueue*)DNew CSubPicQueue(GetRenderersSettings().nSPCSize, !GetRenderersSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr)
+ : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr);
+ if (!m_pSubPicQueue || FAILED(hr)) {
+ return E_FAIL;
+ }
+
+ if (m_SubPicProvider) {
+ m_pSubPicQueue->SetSubPicProvider(m_SubPicProvider);
+ }
+
+ return S_OK;
}
HRESULT CmadVRAllocatorPresenter::Render(
- REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, REFERENCE_TIME atpf,
- int left, int top, int right, int bottom, int width, int height)
+ REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, REFERENCE_TIME atpf,
+ int left, int top, int right, int bottom, int width, int height)
{
- __super::SetPosition(CRect(0, 0, width, height), CRect(left, top, right, bottom)); // needed? should be already set by the player
- SetTime(rtStart);
- if (atpf > 0 && m_pSubPicQueue) {
- m_fps = (double)(10000000.0 / atpf);
- m_pSubPicQueue->SetFPS(m_fps);
- }
- AlphaBltSubPic(CSize(width, height));
- return S_OK;
+ __super::SetPosition(CRect(0, 0, width, height), CRect(left, top, right, bottom)); // needed? should be already set by the player
+ SetTime(rtStart);
+ if (atpf > 0 && m_pSubPicQueue) {
+ m_fps = (double)(10000000.0 / atpf);
+ m_pSubPicQueue->SetFPS(m_fps);
+ }
+ AlphaBltSubPic(CSize(width, height));
+ return S_OK;
}
// ISubPicAllocatorPresenter
STDMETHODIMP CmadVRAllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
{
- CheckPointer(ppRenderer, E_POINTER);
-
- if (m_pDXR) {
- return E_UNEXPECTED;
- }
- m_pDXR.CoCreateInstance(CLSID_madVR, GetOwner());
- if (!m_pDXR) {
- return E_FAIL;
- }
-
- CComQIPtr<ISubRender> pSR = m_pDXR;
- if (!pSR) {
- m_pDXR = NULL;
- return E_FAIL;
- }
-
- m_pSRCB = DNew CSubRenderCallback(this);
- if (FAILED(pSR->SetCallback(m_pSRCB))) {
- m_pDXR = NULL;
- return E_FAIL;
- }
-
- (*ppRenderer = this)->AddRef();
-
- MONITORINFO mi;
- mi.cbSize = sizeof(MONITORINFO);
- if (GetMonitorInfo(MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST), &mi)) {
- m_ScreenSize.SetSize(mi.rcMonitor.right-mi.rcMonitor.left, mi.rcMonitor.bottom-mi.rcMonitor.top);
- }
-
- return S_OK;
+ CheckPointer(ppRenderer, E_POINTER);
+
+ if (m_pDXR) {
+ return E_UNEXPECTED;
+ }
+ m_pDXR.CoCreateInstance(CLSID_madVR, GetOwner());
+ if (!m_pDXR) {
+ return E_FAIL;
+ }
+
+ CComQIPtr<ISubRender> pSR = m_pDXR;
+ if (!pSR) {
+ m_pDXR = NULL;
+ return E_FAIL;
+ }
+
+ m_pSRCB = DNew CSubRenderCallback(this);
+ if (FAILED(pSR->SetCallback(m_pSRCB))) {
+ m_pDXR = NULL;
+ return E_FAIL;
+ }
+
+ (*ppRenderer = this)->AddRef();
+
+ MONITORINFO mi;
+ mi.cbSize = sizeof(MONITORINFO);
+ if (GetMonitorInfo(MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST), &mi)) {
+ m_ScreenSize.SetSize(mi.rcMonitor.right - mi.rcMonitor.left, mi.rcMonitor.bottom - mi.rcMonitor.top);
+ }
+
+ return S_OK;
}
STDMETHODIMP_(void) CmadVRAllocatorPresenter::SetPosition(RECT w, RECT v)
{
- if (CComQIPtr<IBasicVideo> pBV = m_pDXR) {
- pBV->SetDefaultSourcePosition();
- pBV->SetDestinationPosition(v.left, v.top, v.right - v.left, v.bottom - v.top);
- }
-
- if (CComQIPtr<IVideoWindow> pVW = m_pDXR) {
- pVW->SetWindowPosition(w.left, w.top, w.right - w.left, w.bottom - w.top);
- }
+ if (CComQIPtr<IBasicVideo> pBV = m_pDXR) {
+ pBV->SetDefaultSourcePosition();
+ pBV->SetDestinationPosition(v.left, v.top, v.right - v.left, v.bottom - v.top);
+ }
+
+ if (CComQIPtr<IVideoWindow> pVW = m_pDXR) {
+ pVW->SetWindowPosition(w.left, w.top, w.right - w.left, w.bottom - w.top);
+ }
}
STDMETHODIMP_(SIZE) CmadVRAllocatorPresenter::GetVideoSize(bool fCorrectAR)
{
- SIZE size = {0, 0};
-
- if (!fCorrectAR) {
- if (CComQIPtr<IBasicVideo> pBV = m_pDXR) {
- pBV->GetVideoSize(&size.cx, &size.cy);
- }
- } else {
- if (CComQIPtr<IBasicVideo2> pBV2 = m_pDXR) {
- pBV2->GetPreferredAspectRatio(&size.cx, &size.cy);
- }
- }
-
- return size;
+ SIZE size = {0, 0};
+
+ if (!fCorrectAR) {
+ if (CComQIPtr<IBasicVideo> pBV = m_pDXR) {
+ pBV->GetVideoSize(&size.cx, &size.cy);
+ }
+ } else {
+ if (CComQIPtr<IBasicVideo2> pBV2 = m_pDXR) {
+ pBV2->GetPreferredAspectRatio(&size.cx, &size.cy);
+ }
+ }
+
+ return size;
}
STDMETHODIMP_(bool) CmadVRAllocatorPresenter::Paint(bool fAll)
{
- return false; // TODO
+ return false; // TODO
}
STDMETHODIMP CmadVRAllocatorPresenter::GetDIB(BYTE* lpDib, DWORD* size)
{
- HRESULT hr = E_NOTIMPL;
- if (CComQIPtr<IBasicVideo> pBV = m_pDXR) {
- hr = pBV->GetCurrentImage((long*)size, (long*)lpDib);
- }
- return hr;
+ HRESULT hr = E_NOTIMPL;
+ if (CComQIPtr<IBasicVideo> pBV = m_pDXR) {
+ hr = pBV->GetCurrentImage((long*)size, (long*)lpDib);
+ }
+ return hr;
}
STDMETHODIMP CmadVRAllocatorPresenter::SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget)
{
- return E_NOTIMPL; // TODO
+ return E_NOTIMPL; // TODO
}
diff --git a/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.h b/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.h
index b37cdfe89..650d5f6b0 100644
--- a/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.h
+++ b/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.h
@@ -29,81 +29,81 @@
interface __declspec(uuid("ABA34FDA-DD22-4E00-9AB4-4ABF927D0B0C"))
IMadVRTextOsd :
public IUnknown {
- STDMETHOD(OsdDisplayMessage)(LPCWSTR text, DWORD milliseconds) = 0;
- STDMETHOD(OsdClearMessage)(void) = 0;
+ STDMETHOD(OsdDisplayMessage)(LPCWSTR text, DWORD milliseconds) = 0;
+ STDMETHOD(OsdClearMessage)(void) = 0;
};
namespace DSObjects
{
- class CmadVRAllocatorPresenter
- : public CSubPicAllocatorPresenterImpl
- {
- class CSubRenderCallback : public CUnknown, public ISubRenderCallback2, public CCritSec
- {
- CmadVRAllocatorPresenter* m_pDXRAP;
-
- public:
- CSubRenderCallback(CmadVRAllocatorPresenter* pDXRAP)
- : CUnknown(_T("CSubRender"), NULL)
- , m_pDXRAP(pDXRAP) {
- }
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
- return
- QI(ISubRenderCallback)
- QI(ISubRenderCallback2)
- __super::NonDelegatingQueryInterface(riid, ppv);
- }
-
- void SetDXRAP(CmadVRAllocatorPresenter* pDXRAP) {
- CAutoLock cAutoLock(this);
- m_pDXRAP = pDXRAP;
- }
-
- // ISubRenderCallback
-
- STDMETHODIMP SetDevice(IDirect3DDevice9* pD3DDev) {
- CAutoLock cAutoLock(this);
- return m_pDXRAP ? m_pDXRAP->SetDevice(pD3DDev) : E_UNEXPECTED;
- }
-
- STDMETHODIMP Render(REFERENCE_TIME rtStart, int left, int top, int right, int bottom, int width, int height) {
- CAutoLock cAutoLock(this);
- return m_pDXRAP ? m_pDXRAP->Render(rtStart, 0, 0, left, top, right, bottom, width, height) : E_UNEXPECTED;
- }
-
- // ISubRendererCallback2
-
- STDMETHODIMP RenderEx(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, REFERENCE_TIME AvgTimePerFrame, int left, int top, int right, int bottom, int width, int height) {
- CAutoLock cAutoLock(this);
- return m_pDXRAP ? m_pDXRAP->Render(rtStart, rtStop, AvgTimePerFrame, left, top, right, bottom, width, height) : E_UNEXPECTED;
- }
- };
-
- CComPtr<IUnknown> m_pDXR;
- CComPtr<ISubRenderCallback2> m_pSRCB;
- CSize m_ScreenSize;
- bool m_bIsFullscreen;
-
- public:
- CmadVRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error);
- virtual ~CmadVRAllocatorPresenter();
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- HRESULT SetDevice(IDirect3DDevice9* pD3DDev);
- HRESULT Render(
- REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, REFERENCE_TIME atpf,
- int left, int top, int bottom, int right, int width, int height);
-
- // ISubPicAllocatorPresenter
- STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
- STDMETHODIMP_(void) SetPosition(RECT w, RECT v);
- STDMETHODIMP_(SIZE) GetVideoSize(bool fCorrectAR);
- STDMETHODIMP_(bool) Paint(bool fAll);
- STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size);
- STDMETHODIMP SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget);
- };
+ class CmadVRAllocatorPresenter
+ : public CSubPicAllocatorPresenterImpl
+ {
+ class CSubRenderCallback : public CUnknown, public ISubRenderCallback2, public CCritSec
+ {
+ CmadVRAllocatorPresenter* m_pDXRAP;
+
+ public:
+ CSubRenderCallback(CmadVRAllocatorPresenter* pDXRAP)
+ : CUnknown(_T("CSubRender"), NULL)
+ , m_pDXRAP(pDXRAP) {
+ }
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
+ return
+ QI(ISubRenderCallback)
+ QI(ISubRenderCallback2)
+ __super::NonDelegatingQueryInterface(riid, ppv);
+ }
+
+ void SetDXRAP(CmadVRAllocatorPresenter* pDXRAP) {
+ CAutoLock cAutoLock(this);
+ m_pDXRAP = pDXRAP;
+ }
+
+ // ISubRenderCallback
+
+ STDMETHODIMP SetDevice(IDirect3DDevice9* pD3DDev) {
+ CAutoLock cAutoLock(this);
+ return m_pDXRAP ? m_pDXRAP->SetDevice(pD3DDev) : E_UNEXPECTED;
+ }
+
+ STDMETHODIMP Render(REFERENCE_TIME rtStart, int left, int top, int right, int bottom, int width, int height) {
+ CAutoLock cAutoLock(this);
+ return m_pDXRAP ? m_pDXRAP->Render(rtStart, 0, 0, left, top, right, bottom, width, height) : E_UNEXPECTED;
+ }
+
+ // ISubRendererCallback2
+
+ STDMETHODIMP RenderEx(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, REFERENCE_TIME AvgTimePerFrame, int left, int top, int right, int bottom, int width, int height) {
+ CAutoLock cAutoLock(this);
+ return m_pDXRAP ? m_pDXRAP->Render(rtStart, rtStop, AvgTimePerFrame, left, top, right, bottom, width, height) : E_UNEXPECTED;
+ }
+ };
+
+ CComPtr<IUnknown> m_pDXR;
+ CComPtr<ISubRenderCallback2> m_pSRCB;
+ CSize m_ScreenSize;
+ bool m_bIsFullscreen;
+
+ public:
+ CmadVRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString& _Error);
+ virtual ~CmadVRAllocatorPresenter();
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ HRESULT SetDevice(IDirect3DDevice9* pD3DDev);
+ HRESULT Render(
+ REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, REFERENCE_TIME atpf,
+ int left, int top, int bottom, int right, int width, int height);
+
+ // ISubPicAllocatorPresenter
+ STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
+ STDMETHODIMP_(void) SetPosition(RECT w, RECT v);
+ STDMETHODIMP_(SIZE) GetVideoSize(bool fCorrectAR);
+ STDMETHODIMP_(bool) Paint(bool fAll);
+ STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size);
+ STDMETHODIMP SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget);
+ };
}
diff --git a/src/filters/renderer/VideoRenderers/stdafx.h b/src/filters/renderer/VideoRenderers/stdafx.h
index 6e1286783..9796ec998 100644
--- a/src/filters/renderer/VideoRenderers/stdafx.h
+++ b/src/filters/renderer/VideoRenderers/stdafx.h
@@ -26,7 +26,7 @@
#include "../../../DSUtil/SharedInclude.h"
#ifndef VC_EXTRALEAN
-#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
+#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
#define ResStr(id) CString(MAKEINTRESOURCE(id))
diff --git a/src/filters/source/BaseSource/BaseSource.cpp b/src/filters/source/BaseSource/BaseSource.cpp
index 7a5f6bca7..7a6354d1e 100644
--- a/src/filters/source/BaseSource/BaseSource.cpp
+++ b/src/filters/source/BaseSource/BaseSource.cpp
@@ -34,161 +34,161 @@
//
CBaseStream::CBaseStream(TCHAR* name, CSource* pParent, HRESULT* phr)
- : CSourceStream(name, phr, pParent, L"Output")
- , CSourceSeeking(name, (IPin*)this, phr, &m_cSharedState)
- , m_bDiscontinuity(FALSE), m_bFlushing(FALSE)
+ : CSourceStream(name, phr, pParent, L"Output")
+ , CSourceSeeking(name, (IPin*)this, phr, &m_cSharedState)
+ , m_bDiscontinuity(FALSE), m_bFlushing(FALSE)
{
- CAutoLock cAutoLock(&m_cSharedState);
+ CAutoLock cAutoLock(&m_cSharedState);
- m_AvgTimePerFrame = 0;
- m_rtDuration = 0;
- m_rtStop = m_rtDuration;
+ m_AvgTimePerFrame = 0;
+ m_rtDuration = 0;
+ m_rtStop = m_rtDuration;
}
CBaseStream::~CBaseStream()
{
- CAutoLock cAutoLock(&m_cSharedState);
+ CAutoLock cAutoLock(&m_cSharedState);
}
STDMETHODIMP CBaseStream::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return (riid == IID_IMediaSeeking) ? CSourceSeeking::NonDelegatingQueryInterface(riid, ppv)
- : CSourceStream::NonDelegatingQueryInterface(riid, ppv);
+ return (riid == IID_IMediaSeeking) ? CSourceSeeking::NonDelegatingQueryInterface(riid, ppv)
+ : CSourceStream::NonDelegatingQueryInterface(riid, ppv);
}
void CBaseStream::UpdateFromSeek()
{
- if (ThreadExists()) {
- // next time around the loop, the worker thread will
- // pick up the position change.
- // We need to flush all the existing data - we must do that here
- // as our thread will probably be blocked in GetBuffer otherwise
+ if (ThreadExists()) {
+ // next time around the loop, the worker thread will
+ // pick up the position change.
+ // We need to flush all the existing data - we must do that here
+ // as our thread will probably be blocked in GetBuffer otherwise
- m_bFlushing = TRUE;
+ m_bFlushing = TRUE;
- DeliverBeginFlush();
- // make sure we have stopped pushing
- Stop();
- // complete the flush
- DeliverEndFlush();
+ DeliverBeginFlush();
+ // make sure we have stopped pushing
+ Stop();
+ // complete the flush
+ DeliverEndFlush();
- m_bFlushing = FALSE;
+ m_bFlushing = FALSE;
- // restart
- Run();
- }
+ // restart
+ Run();
+ }
}
HRESULT CBaseStream::SetRate(double dRate)
{
- if (dRate <= 0) {
- return E_INVALIDARG;
- }
+ if (dRate <= 0) {
+ return E_INVALIDARG;
+ }
- {
- CAutoLock lock(CSourceSeeking::m_pLock);
- m_dRateSeeking = dRate;
- }
+ {
+ CAutoLock lock(CSourceSeeking::m_pLock);
+ m_dRateSeeking = dRate;
+ }
- UpdateFromSeek();
+ UpdateFromSeek();
- return S_OK;
+ return S_OK;
}
HRESULT CBaseStream::OnThreadStartPlay()
{
- m_bDiscontinuity = TRUE;
- return DeliverNewSegment(m_rtStart, m_rtStop, m_dRateSeeking);
+ m_bDiscontinuity = TRUE;
+ return DeliverNewSegment(m_rtStart, m_rtStop, m_dRateSeeking);
}
HRESULT CBaseStream::ChangeStart()
{
- {
- CAutoLock lock(CSourceSeeking::m_pLock);
- m_rtSampleTime = 0;
- m_rtPosition = m_rtStart;
- }
+ {
+ CAutoLock lock(CSourceSeeking::m_pLock);
+ m_rtSampleTime = 0;
+ m_rtPosition = m_rtStart;
+ }
- UpdateFromSeek();
+ UpdateFromSeek();
- return S_OK;
+ return S_OK;
}
HRESULT CBaseStream::ChangeStop()
{
- {
- CAutoLock lock(CSourceSeeking::m_pLock);
- if (m_rtPosition < m_rtStop) {
- return S_OK;
- }
- }
+ {
+ CAutoLock lock(CSourceSeeking::m_pLock);
+ if (m_rtPosition < m_rtStop) {
+ return S_OK;
+ }
+ }
- // We're already past the new stop time -- better flush the graph.
- UpdateFromSeek();
+ // We're already past the new stop time -- better flush the graph.
+ UpdateFromSeek();
- return S_OK;
+ return S_OK;
}
HRESULT CBaseStream::OnThreadCreate()
{
- CAutoLock cAutoLockShared(&m_cSharedState);
+ CAutoLock cAutoLockShared(&m_cSharedState);
- m_rtSampleTime = 0;
- m_rtPosition = m_rtStart;
+ m_rtSampleTime = 0;
+ m_rtPosition = m_rtStart;
- return CSourceStream::OnThreadCreate();
+ return CSourceStream::OnThreadCreate();
}
HRESULT CBaseStream::FillBuffer(IMediaSample* pSample)
{
- HRESULT hr;
+ HRESULT hr;
- {
- CAutoLock cAutoLockShared(&m_cSharedState);
+ {
+ CAutoLock cAutoLockShared(&m_cSharedState);
- if (m_rtPosition >= m_rtStop) {
- return S_FALSE;
- }
+ if (m_rtPosition >= m_rtStop) {
+ return S_FALSE;
+ }
- BYTE* pOut = NULL;
- if (FAILED(hr = pSample->GetPointer(&pOut)) || !pOut) {
- return S_FALSE;
- }
+ BYTE* pOut = NULL;
+ if (FAILED(hr = pSample->GetPointer(&pOut)) || !pOut) {
+ return S_FALSE;
+ }
- int nFrame = (int)(m_rtPosition / m_AvgTimePerFrame);
+ int nFrame = (int)(m_rtPosition / m_AvgTimePerFrame);
- long len = pSample->GetSize();
+ long len = pSample->GetSize();
- hr = FillBuffer(pSample, nFrame, pOut, len);
- if (hr != S_OK) {
- return hr;
- }
+ hr = FillBuffer(pSample, nFrame, pOut, len);
+ if (hr != S_OK) {
+ return hr;
+ }
- pSample->SetActualDataLength(len);
+ pSample->SetActualDataLength(len);
- REFERENCE_TIME rtStart, rtStop;
- // The sample times are modified by the current rate.
- rtStart = static_cast<REFERENCE_TIME>(m_rtSampleTime / m_dRateSeeking);
- rtStop = rtStart + static_cast<int>(m_AvgTimePerFrame / m_dRateSeeking);
- pSample->SetTime(&rtStart, &rtStop);
+ REFERENCE_TIME rtStart, rtStop;
+ // The sample times are modified by the current rate.
+ rtStart = static_cast<REFERENCE_TIME>(m_rtSampleTime / m_dRateSeeking);
+ rtStop = rtStart + static_cast<int>(m_AvgTimePerFrame / m_dRateSeeking);
+ pSample->SetTime(&rtStart, &rtStop);
- m_rtSampleTime += m_AvgTimePerFrame;
- m_rtPosition += m_AvgTimePerFrame;
- }
+ m_rtSampleTime += m_AvgTimePerFrame;
+ m_rtPosition += m_AvgTimePerFrame;
+ }
- pSample->SetSyncPoint(TRUE);
+ pSample->SetSyncPoint(TRUE);
- if (m_bDiscontinuity) {
- pSample->SetDiscontinuity(TRUE);
- m_bDiscontinuity = FALSE;
- }
+ if (m_bDiscontinuity) {
+ pSample->SetDiscontinuity(TRUE);
+ m_bDiscontinuity = FALSE;
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CBaseStream::Notify(IBaseFilter* pSender, Quality q)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
diff --git a/src/filters/source/BaseSource/BaseSource.h b/src/filters/source/BaseSource/BaseSource.h
index 3388ba083..a0c4d6071 100644
--- a/src/filters/source/BaseSource/BaseSource.h
+++ b/src/filters/source/BaseSource/BaseSource.h
@@ -27,111 +27,111 @@
template<class TStream>
class CBaseSource
- : public CSource
- , public IFileSourceFilter
- , public IAMFilterMiscFlags
+ : public CSource
+ , public IFileSourceFilter
+ , public IAMFilterMiscFlags
{
protected:
- CStringW m_fn;
+ CStringW m_fn;
public:
- CBaseSource(TCHAR* name, LPUNKNOWN lpunk, HRESULT* phr, const CLSID& clsid)
- : CSource(name, lpunk, clsid) {
- if (phr) {
- *phr = S_OK;
- }
- }
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
- CheckPointer(ppv, E_POINTER);
-
- return
- QI(IFileSourceFilter)
- QI(IAMFilterMiscFlags)
- __super::NonDelegatingQueryInterface(riid, ppv);
- }
-
- // IFileSourceFilter
-
- STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt) {
- // TODO: destroy any already existing pins and create new, now we are just going die nicely instead of doing it :)
- if (GetPinCount() > 0) {
- return VFW_E_ALREADY_CONNECTED;
- }
-
- HRESULT hr = S_OK;
- if (!(DNew TStream(pszFileName, this, &hr))) {
- return E_OUTOFMEMORY;
- }
-
- if (FAILED(hr)) {
- return hr;
- }
-
- m_fn = pszFileName;
-
- return S_OK;
- }
-
- STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt) {
- size_t nCount;
- if (!ppszFileName) {
- return E_POINTER;
- }
-
- nCount = m_fn.GetLength()+1;
- *ppszFileName = (LPOLESTR)CoTaskMemAlloc(nCount*sizeof(WCHAR));
- if (!(*ppszFileName)) {
- return E_OUTOFMEMORY;
- }
-
- wcscpy_s(*ppszFileName, nCount, m_fn);
-
- return S_OK;
- }
-
- // IAMFilterMiscFlags
-
- STDMETHODIMP_(ULONG) GetMiscFlags() {
- return AM_FILTER_MISC_FLAGS_IS_SOURCE;
- }
+ CBaseSource(TCHAR* name, LPUNKNOWN lpunk, HRESULT* phr, const CLSID& clsid)
+ : CSource(name, lpunk, clsid) {
+ if (phr) {
+ *phr = S_OK;
+ }
+ }
+
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
+ CheckPointer(ppv, E_POINTER);
+
+ return
+ QI(IFileSourceFilter)
+ QI(IAMFilterMiscFlags)
+ __super::NonDelegatingQueryInterface(riid, ppv);
+ }
+
+ // IFileSourceFilter
+
+ STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt) {
+ // TODO: destroy any already existing pins and create new, now we are just going die nicely instead of doing it :)
+ if (GetPinCount() > 0) {
+ return VFW_E_ALREADY_CONNECTED;
+ }
+
+ HRESULT hr = S_OK;
+ if (!(DNew TStream(pszFileName, this, &hr))) {
+ return E_OUTOFMEMORY;
+ }
+
+ if (FAILED(hr)) {
+ return hr;
+ }
+
+ m_fn = pszFileName;
+
+ return S_OK;
+ }
+
+ STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt) {
+ size_t nCount;
+ if (!ppszFileName) {
+ return E_POINTER;
+ }
+
+ nCount = m_fn.GetLength() + 1;
+ *ppszFileName = (LPOLESTR)CoTaskMemAlloc(nCount * sizeof(WCHAR));
+ if (!(*ppszFileName)) {
+ return E_OUTOFMEMORY;
+ }
+
+ wcscpy_s(*ppszFileName, nCount, m_fn);
+
+ return S_OK;
+ }
+
+ // IAMFilterMiscFlags
+
+ STDMETHODIMP_(ULONG) GetMiscFlags() {
+ return AM_FILTER_MISC_FLAGS_IS_SOURCE;
+ }
};
class CBaseStream
- : public CSourceStream
- , public CSourceSeeking
+ : public CSourceStream
+ , public CSourceSeeking
{
protected:
- CCritSec m_cSharedState;
+ CCritSec m_cSharedState;
- REFERENCE_TIME m_AvgTimePerFrame;
- REFERENCE_TIME m_rtSampleTime, m_rtPosition;
+ REFERENCE_TIME m_AvgTimePerFrame;
+ REFERENCE_TIME m_rtSampleTime, m_rtPosition;
- BOOL m_bDiscontinuity, m_bFlushing;
+ BOOL m_bDiscontinuity, m_bFlushing;
- HRESULT OnThreadStartPlay();
- HRESULT OnThreadCreate();
+ HRESULT OnThreadStartPlay();
+ HRESULT OnThreadCreate();
private:
- void UpdateFromSeek();
- STDMETHODIMP SetRate(double dRate);
+ void UpdateFromSeek();
+ STDMETHODIMP SetRate(double dRate);
- HRESULT ChangeStart();
- HRESULT ChangeStop();
- HRESULT ChangeRate() {
- return S_OK;
- }
+ HRESULT ChangeStart();
+ HRESULT ChangeStop();
+ HRESULT ChangeRate() {
+ return S_OK;
+ }
public:
- CBaseStream(TCHAR* name, CSource* pParent, HRESULT* phr);
- virtual ~CBaseStream();
+ CBaseStream(TCHAR* name, CSource* pParent, HRESULT* phr);
+ virtual ~CBaseStream();
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- HRESULT FillBuffer(IMediaSample* pSample);
+ HRESULT FillBuffer(IMediaSample* pSample);
- virtual HRESULT FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, long& len /*in+out*/) = 0;
+ virtual HRESULT FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, long& len /*in+out*/) = 0;
- STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
+ STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
};
diff --git a/src/filters/source/BaseSource/stdafx.h b/src/filters/source/BaseSource/stdafx.h
index 1a68ff4c6..51281debe 100644
--- a/src/filters/source/BaseSource/stdafx.h
+++ b/src/filters/source/BaseSource/stdafx.h
@@ -25,16 +25,16 @@
#include "../../../DSUtil/SharedInclude.h"
#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#endif
-#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
#ifndef VC_EXTRALEAN
-#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
+#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
#include <afx.h>
-#include <afxwin.h> // MFC core and standard components
+#include <afxwin.h> // MFC core and standard components
#include <dshow.h>
#include <BaseClasses/streams.h>
diff --git a/src/filters/source/D2VSource/D2VSource.cpp b/src/filters/source/D2VSource/D2VSource.cpp
index 20570b179..5e3db93fb 100644
--- a/src/filters/source/D2VSource/D2VSource.cpp
+++ b/src/filters/source/D2VSource/D2VSource.cpp
@@ -29,46 +29,46 @@
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
- {&MEDIATYPE_Video, &MEDIASUBTYPE_YUY2}
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_YUY2}
};
const AMOVIESETUP_PIN sudOpPin[] = {
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CD2VSource), D2VSourceName, MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
+ {&__uuidof(CD2VSource), D2VSourceName, MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CD2VSource>, NULL, &sudFilter[0]}
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CD2VSource>, NULL, &sudFilter[0]}
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{47CE0591-C4D5-4b41-BED7-28F59AD76228}"),
- _T("0"), _T("0,18,,4456443241564950726F6A65637446696C65")); // "DVD2AVIProjectFile"
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{47CE0591-C4D5-4b41-BED7-28F59AD76228}"),
+ _T("0"), _T("0,18,,4456443241564950726F6A65637446696C65")); // "DVD2AVIProjectFile"
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{47CE0591-C4D5-4b41-BED7-28F59AD76228}"),
- _T("Source Filter"), _T("{47CE0591-C4D5-4b41-BED7-28F59AD76228}"));
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{47CE0591-C4D5-4b41-BED7-28F59AD76228}"),
+ _T("Source Filter"), _T("{47CE0591-C4D5-4b41-BED7-28F59AD76228}"));
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".d2v"),
- _T("Source Filter"), _T("{47CE0591-C4D5-4b41-BED7-28F59AD76228}"));
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".d2v"),
+ _T("Source Filter"), _T("{47CE0591-C4D5-4b41-BED7-28F59AD76228}"));
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{47CE0591-C4D5-4b41-BED7-28F59AD76228}"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".d2v"));
+ DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{47CE0591-C4D5-4b41-BED7-28F59AD76228}"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".d2v"));
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -82,11 +82,11 @@ CFilterApp theApp;
//
CD2VSource::CD2VSource(LPUNKNOWN lpunk, HRESULT* phr)
- : CBaseSource<CD2VStream>(NAME("CD2VSource"), lpunk, phr, __uuidof(this))
+ : CBaseSource<CD2VStream>(NAME("CD2VSource"), lpunk, phr, __uuidof(this))
{
- if (phr) {
- *phr = S_OK;
- }
+ if (phr) {
+ *phr = S_OK;
+ }
}
CD2VSource::~CD2VSource()
@@ -95,15 +95,15 @@ CD2VSource::~CD2VSource()
STDMETHODIMP CD2VSource::QueryFilterInfo(FILTER_INFO* pInfo)
{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
- wcscpy_s(pInfo->achName, D2VSourceName);
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
+ CheckPointer(pInfo, E_POINTER);
+ ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
+ wcscpy_s(pInfo->achName, D2VSourceName);
+ pInfo->pGraph = m_pGraph;
+ if (m_pGraph) {
+ m_pGraph->AddRef();
+ }
+
+ return S_OK;
}
//
@@ -111,196 +111,196 @@ STDMETHODIMP CD2VSource::QueryFilterInfo(FILTER_INFO* pInfo)
//
CD2VStream::CD2VStream(const WCHAR* fn, CSource* pParent, HRESULT* phr)
- : CBaseStream(NAME("D2VSourceStream"), pParent, phr)
- , m_pFrameBuffer(NULL)
+ : CBaseStream(NAME("D2VSourceStream"), pParent, phr)
+ , m_pFrameBuffer(NULL)
{
- CAutoLock cAutoLock(&m_cSharedState);
-
- m_pDecoder.Attach(DNew CMPEG2Dec());
- if (!m_pDecoder) {
- if (phr) {
- *phr = E_OUTOFMEMORY;
- }
- return;
- }
-
- if (!m_pDecoder->Open(CString(fn), CMPEG2Dec::YUY2)) {
- if (phr) {
- *phr = E_FAIL;
- }
- return;
- }
-
- if (!m_pFrameBuffer.Allocate(m_pDecoder->Clip_Width*m_pDecoder->Clip_Height*4)) {
- if (phr) {
- *phr = E_OUTOFMEMORY;
- }
- return;
- }
-
- m_AvgTimePerFrame = 10000000000i64/m_pDecoder->VF_FrameRate;
- m_rtDuration = m_rtStop = m_AvgTimePerFrame*m_pDecoder->VF_FrameLimit;
-
- if (phr) {
- *phr = m_rtDuration > 0 ? S_OK : E_FAIL;
- }
+ CAutoLock cAutoLock(&m_cSharedState);
+
+ m_pDecoder.Attach(DNew CMPEG2Dec());
+ if (!m_pDecoder) {
+ if (phr) {
+ *phr = E_OUTOFMEMORY;
+ }
+ return;
+ }
+
+ if (!m_pDecoder->Open(CString(fn), CMPEG2Dec::YUY2)) {
+ if (phr) {
+ *phr = E_FAIL;
+ }
+ return;
+ }
+
+ if (!m_pFrameBuffer.Allocate(m_pDecoder->Clip_Width * m_pDecoder->Clip_Height * 4)) {
+ if (phr) {
+ *phr = E_OUTOFMEMORY;
+ }
+ return;
+ }
+
+ m_AvgTimePerFrame = 10000000000i64 / m_pDecoder->VF_FrameRate;
+ m_rtDuration = m_rtStop = m_AvgTimePerFrame * m_pDecoder->VF_FrameLimit;
+
+ if (phr) {
+ *phr = m_rtDuration > 0 ? S_OK : E_FAIL;
+ }
}
CD2VStream::~CD2VStream()
{
- CAutoLock cAutoLock(&m_cSharedState);
+ CAutoLock cAutoLock(&m_cSharedState);
}
HRESULT CD2VStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties)
{
- // CAutoLock cAutoLock(m_pFilter->pStateLock());
+ // CAutoLock cAutoLock(m_pFilter->pStateLock());
- ASSERT(pAlloc);
- ASSERT(pProperties);
+ ASSERT(pAlloc);
+ ASSERT(pProperties);
- HRESULT hr = NOERROR;
+ HRESULT hr = NOERROR;
- int w, h, bpp;
- if (!GetDim(w, h, bpp)) {
- return E_FAIL;
- }
+ int w, h, bpp;
+ if (!GetDim(w, h, bpp)) {
+ return E_FAIL;
+ }
- pProperties->cBuffers = 1;
- pProperties->cbBuffer = w*h*bpp>>3;
+ pProperties->cBuffers = 1;
+ pProperties->cbBuffer = w * h * bpp >> 3;
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
- return hr;
- }
+ ALLOCATOR_PROPERTIES Actual;
+ if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
- if (Actual.cbBuffer < pProperties->cbBuffer) {
- return E_FAIL;
- }
- ASSERT(Actual.cBuffers == pProperties->cBuffers);
+ if (Actual.cbBuffer < pProperties->cbBuffer) {
+ return E_FAIL;
+ }
+ ASSERT(Actual.cBuffers == pProperties->cBuffers);
- return NOERROR;
+ return NOERROR;
}
HRESULT CD2VStream::FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, long& len)
{
- if (!m_pDecoder) {
- return S_FALSE;
- }
+ if (!m_pDecoder) {
+ return S_FALSE;
+ }
- AM_MEDIA_TYPE* pmt;
- if (SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
- CMediaType mt(*pmt);
- SetMediaType(&mt);
+ AM_MEDIA_TYPE* pmt;
+ if (SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
+ CMediaType mt(*pmt);
+ SetMediaType(&mt);
- DeleteMediaType(pmt);
- }
+ DeleteMediaType(pmt);
+ }
- int w, h, bpp;
- if (!GetDim(w, h, bpp)) {
- return S_FALSE;
- }
+ int w, h, bpp;
+ if (!GetDim(w, h, bpp)) {
+ return S_FALSE;
+ }
- BYTE* pIn = m_pFrameBuffer;
+ BYTE* pIn = m_pFrameBuffer;
- int pitchIn, pitchOut = 0;
+ int pitchIn, pitchOut = 0;
- pitchIn = m_pDecoder->Clip_Width*bpp>>3;
- pitchOut = w*bpp>>3;
+ pitchIn = m_pDecoder->Clip_Width * bpp >> 3;
+ pitchOut = w * bpp >> 3;
- m_pDecoder->Decode(pIn, (unsigned long)(nFrame), pitchIn);
+ m_pDecoder->Decode(pIn, (unsigned long)(nFrame), pitchIn);
- for (int y = 0, p = min(pitchIn, pitchOut);
- y < h;
- y++, pIn += pitchIn, pOut += pitchOut) {
- memcpy(pOut, pIn, p);
- }
+ for (int y = 0, p = min(pitchIn, pitchOut);
+ y < h;
+ y++, pIn += pitchIn, pOut += pitchOut) {
+ memcpy(pOut, pIn, p);
+ }
- len = pitchOut*h;
+ len = pitchOut * h;
- return S_OK;
+ return S_OK;
}
HRESULT CD2VStream::GetMediaType(int iPosition, CMediaType* pmt)
{
- CAutoLock cAutoLock(m_pFilter->pStateLock());
-
- if (iPosition < 0) {
- return E_INVALIDARG;
- }
- if (iPosition > 0) {
- return VFW_S_NO_MORE_ITEMS;
- }
-
- pmt->SetType(&MEDIATYPE_Video);
- pmt->SetSubtype(&MEDIASUBTYPE_YUY2);
- pmt->SetFormatType(&FORMAT_VideoInfo);
- pmt->SetTemporalCompression(FALSE);
-
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
- memset(vih, 0, sizeof(VIDEOINFOHEADER));
- vih->AvgTimePerFrame = m_AvgTimePerFrame;
- vih->bmiHeader.biSize = sizeof(vih->bmiHeader);
- vih->bmiHeader.biWidth = m_pDecoder->Clip_Width;
- vih->bmiHeader.biHeight = m_pDecoder->Clip_Height;
- vih->bmiHeader.biPlanes = 1;
- vih->bmiHeader.biBitCount = 16;
- vih->bmiHeader.biCompression = '2YUY';
- vih->bmiHeader.biSizeImage = vih->bmiHeader.biWidth*abs(vih->bmiHeader.biHeight)*vih->bmiHeader.biBitCount>>3;
-
- pmt->SetSampleSize(vih->bmiHeader.biSizeImage);
-
- return NOERROR;
+ CAutoLock cAutoLock(m_pFilter->pStateLock());
+
+ if (iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if (iPosition > 0) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
+
+ pmt->SetType(&MEDIATYPE_Video);
+ pmt->SetSubtype(&MEDIASUBTYPE_YUY2);
+ pmt->SetFormatType(&FORMAT_VideoInfo);
+ pmt->SetTemporalCompression(FALSE);
+
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
+ memset(vih, 0, sizeof(VIDEOINFOHEADER));
+ vih->AvgTimePerFrame = m_AvgTimePerFrame;
+ vih->bmiHeader.biSize = sizeof(vih->bmiHeader);
+ vih->bmiHeader.biWidth = m_pDecoder->Clip_Width;
+ vih->bmiHeader.biHeight = m_pDecoder->Clip_Height;
+ vih->bmiHeader.biPlanes = 1;
+ vih->bmiHeader.biBitCount = 16;
+ vih->bmiHeader.biCompression = '2YUY';
+ vih->bmiHeader.biSizeImage = vih->bmiHeader.biWidth * abs(vih->bmiHeader.biHeight) * vih->bmiHeader.biBitCount >> 3;
+
+ pmt->SetSampleSize(vih->bmiHeader.biSizeImage);
+
+ return NOERROR;
}
HRESULT CD2VStream::SetMediaType(const CMediaType* pmt)
{
- if (m_pDecoder) {
- if (pmt->subtype == MEDIASUBTYPE_YUY2) {
- m_pDecoder->m_dstFormat = CMPEG2Dec::YUY2;
- } else {
- return E_FAIL;
- }
- }
-
- return CSourceStream::SetMediaType(pmt);
+ if (m_pDecoder) {
+ if (pmt->subtype == MEDIASUBTYPE_YUY2) {
+ m_pDecoder->m_dstFormat = CMPEG2Dec::YUY2;
+ } else {
+ return E_FAIL;
+ }
+ }
+
+ return CSourceStream::SetMediaType(pmt);
}
HRESULT CD2VStream::CheckMediaType(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Video
- && pmt->subtype == MEDIASUBTYPE_YUY2
- && pmt->formattype == FORMAT_VideoInfo
- ? S_OK
- : E_INVALIDARG;
+ return pmt->majortype == MEDIATYPE_Video
+ && pmt->subtype == MEDIASUBTYPE_YUY2
+ && pmt->formattype == FORMAT_VideoInfo
+ ? S_OK
+ : E_INVALIDARG;
}
STDMETHODIMP CD2VStream::Notify(IBaseFilter* pSender, Quality q)
{
- if (q.Late > 0 && q.Late < 100000000) {
- CAutoLock cAutoLockShared(&m_cSharedState);
+ if (q.Late > 0 && q.Late < 100000000) {
+ CAutoLock cAutoLockShared(&m_cSharedState);
- m_rtSampleTime += (q.Late/m_AvgTimePerFrame)*m_AvgTimePerFrame;
- m_rtPosition += (q.Late/m_AvgTimePerFrame)*m_AvgTimePerFrame;
- }
+ m_rtSampleTime += (q.Late / m_AvgTimePerFrame) * m_AvgTimePerFrame;
+ m_rtPosition += (q.Late / m_AvgTimePerFrame) * m_AvgTimePerFrame;
+ }
- return S_OK;
+ return S_OK;
}
//
bool CD2VStream::GetDim(int& w, int& h, int& bpp)
{
- if (m_mt.formattype == FORMAT_VideoInfo) {
- w = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biWidth;
- h = abs(((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biHeight);
- bpp = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biBitCount;
- } else if (m_mt.formattype == FORMAT_VideoInfo2) {
- w = ((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biWidth;
- h = abs(((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biHeight);
- bpp = ((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biBitCount;
- } else {
- return false;
- }
-
- return true;
+ if (m_mt.formattype == FORMAT_VideoInfo) {
+ w = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biWidth;
+ h = abs(((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biHeight);
+ bpp = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biBitCount;
+ } else if (m_mt.formattype == FORMAT_VideoInfo2) {
+ w = ((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biWidth;
+ h = abs(((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biHeight);
+ bpp = ((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biBitCount;
+ } else {
+ return false;
+ }
+
+ return true;
}
diff --git a/src/filters/source/D2VSource/D2VSource.h b/src/filters/source/D2VSource/D2VSource.h
index e3a8fdec0..d696ed95c 100644
--- a/src/filters/source/D2VSource/D2VSource.h
+++ b/src/filters/source/D2VSource/D2VSource.h
@@ -30,14 +30,14 @@
class CD2VStream;
class __declspec(uuid("47CE0591-C4D5-4b41-BED7-28F59AD76228"))
- CD2VSource : public CBaseSource<CD2VStream>
+ CD2VSource : public CBaseSource<CD2VStream>
{
public:
- CD2VSource(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CD2VSource();
+ CD2VSource(LPUNKNOWN lpunk, HRESULT* phr);
+ virtual ~CD2VSource();
- // CBaseFilter
- STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
+ // CBaseFilter
+ STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
};
class CMPEG2Dec;
@@ -45,21 +45,21 @@ class CMPEG2Dec;
class CD2VStream : public CBaseStream
{
private:
- CAutoPtr<CMPEG2Dec> m_pDecoder;
- CAutoVectorPtr<BYTE> m_pFrameBuffer;
+ CAutoPtr<CMPEG2Dec> m_pDecoder;
+ CAutoVectorPtr<BYTE> m_pFrameBuffer;
- bool GetDim(int& w, int& h, int& bpp);
+ bool GetDim(int& w, int& h, int& bpp);
public:
- CD2VStream(const WCHAR* fn, CSource* pParent, HRESULT* phr);
- virtual ~CD2VStream();
+ CD2VStream(const WCHAR* fn, CSource* pParent, HRESULT* phr);
+ virtual ~CD2VStream();
- HRESULT FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, long& len /*in+out*/);
+ HRESULT FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, long& len /*in+out*/);
- HRESULT DecideBufferSize(IMemAllocator* pIMemAlloc, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT CheckMediaType(const CMediaType* pMediaType);
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
- HRESULT SetMediaType(const CMediaType* pmt);
+ HRESULT DecideBufferSize(IMemAllocator* pIMemAlloc, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT CheckMediaType(const CMediaType* pMediaType);
+ HRESULT GetMediaType(int iPosition, CMediaType* pmt);
+ HRESULT SetMediaType(const CMediaType* pmt);
- STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
+ STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
};
diff --git a/src/filters/source/DTSAC3Source/DTSAC3Source.cpp b/src/filters/source/DTSAC3Source/DTSAC3Source.cpp
index c48508510..11b0c928d 100644
--- a/src/filters/source/DTSAC3Source/DTSAC3Source.cpp
+++ b/src/filters/source/DTSAC3Source/DTSAC3Source.cpp
@@ -41,132 +41,133 @@
#include <libdca/include/dts.h>
enum {
- unknown,
- AC3,
- EAC3,
- //TrueHD,
- //TrueHDAC3,
- MLP,
- DTS,
- DTSHD,
- DTSPaded,
- SPDIF_AC3,
+ unknown,
+ AC3,
+ EAC3,
+ //TrueHD,
+ //TrueHDAC3,
+ MLP,
+ DTS,
+ DTSHD,
+ DTSPaded,
+ SPDIF_AC3,
};
bool isDTSSync(const DWORD sync)
{
- if (sync == 0x0180fe7f || // '7FFE8001' 16 bits and big endian bitstream
- sync == 0x80017ffe || // 'FE7F0180' 16 bits and little endian bitstream
- sync == 0x00e8ff1f || // '1FFFE800' 14 bits and big endian bitstream
- sync == 0xe8001fff) // 'FF1F00E8' 14 bits and little endian bitstream
- return true;
- else
- return false;
+ if (sync == 0x0180fe7f || // '7FFE8001' 16 bits and big endian bitstream
+ sync == 0x80017ffe || // 'FE7F0180' 16 bits and little endian bitstream
+ sync == 0x00e8ff1f || // '1FFFE800' 14 bits and big endian bitstream
+ sync == 0xe8001fff) { // 'FF1F00E8' 14 bits and little endian bitstream
+ return true;
+ } else {
+ return false;
+ }
}
DWORD ParseWAVECDHeader(const BYTE wh[44])
{
- if (*(DWORD*)wh != 0x46464952 //"RIFF"
- || *(DWORDLONG*)(wh+8) != 0x20746d6645564157 //"WAVEfmt "
- || *(DWORD*)(wh+36) != 0x61746164) { //"data"
- return 0;
- }
- PCMWAVEFORMAT pcmwf = *(PCMWAVEFORMAT*)(wh+20);
- if (pcmwf.wf.wFormatTag != 1
- || pcmwf.wf.nChannels != 2
- || pcmwf.wf.nSamplesPerSec != 44100
- || pcmwf.wf.nAvgBytesPerSec != 176400
- || pcmwf.wf.nBlockAlign != 4
- || pcmwf.wBitsPerSample != 16) {
- return 0;
- }
- return *(DWORD*)(wh+40); //return size of "data"
+ if (*(DWORD*)wh != 0x46464952 //"RIFF"
+ || *(DWORDLONG*)(wh + 8) != 0x20746d6645564157 //"WAVEfmt "
+ || *(DWORD*)(wh + 36) != 0x61746164) { //"data"
+ return 0;
+ }
+ PCMWAVEFORMAT pcmwf = *(PCMWAVEFORMAT*)(wh + 20);
+ if (pcmwf.wf.wFormatTag != 1
+ || pcmwf.wf.nChannels != 2
+ || pcmwf.wf.nSamplesPerSec != 44100
+ || pcmwf.wf.nAvgBytesPerSec != 176400
+ || pcmwf.wf.nBlockAlign != 4
+ || pcmwf.wBitsPerSample != 16) {
+ return 0;
+ }
+ return *(DWORD*)(wh + 40); //return size of "data"
}
-int ParseAC3IEC61937Header(const BYTE *buf)
+int ParseAC3IEC61937Header(const BYTE* buf)
{
- WORD* wbuf = (WORD*)buf;
- if (*(DWORD*)buf == IEC61937_SYNC_WORD
- && wbuf[2] == 0x0001
- && wbuf[3] > 0 && wbuf[3] < (6144-8)*8
- && wbuf[4] == 0x0B77 ) {
- return 6144;
- }
- return 0;
+ WORD* wbuf = (WORD*)buf;
+ if (*(DWORD*)buf == IEC61937_SYNC_WORD
+ && wbuf[2] == 0x0001
+ && wbuf[3] > 0 && wbuf[3] < (6144 - 8) * 8
+ && wbuf[4] == 0x0B77) {
+ return 6144;
+ }
+ return 0;
}
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_DTS},
- {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_DTS},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_DOLBY_AC3},
- {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_DOLBY_AC3},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_DTS},
+ {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_DTS},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_DOLBY_AC3},
+ {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_DOLBY_AC3},
};
const AMOVIESETUP_PIN sudOpPin[] = {
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CDTSAC3Source), DTSAC3SourceName, MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
+ {&__uuidof(CDTSAC3Source), DTSAC3SourceName, MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDTSAC3Source>, NULL, &sudFilter[0]}
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDTSAC3Source>, NULL, &sudFilter[0]}
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
- _T("0"), _T("0,4,,7FFE8001")); // DTS
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
+ _T("0"), _T("0,4,,7FFE8001")); // DTS
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
- _T("0"), _T("0,4,,fE7f0180")); // DTS LE
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
+ _T("0"), _T("0,4,,fE7f0180")); // DTS LE
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
- _T("1"), _T("0,2,,0B77")); // AC3, E-AC3
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
+ _T("1"), _T("0,2,,0B77")); // AC3, E-AC3
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
- _T("2"), _T("0,16,,52494646xxxx57415645666D7420")); // RIFFxxxxWAVEfmt_ for DTSWAV
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
+ _T("2"), _T("0,16,,52494646xxxx57415645666D7420")); // RIFFxxxxWAVEfmt_ for DTSWAV
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
- _T("0"), _T("4,4,,F8726FBB")); // MLP
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
+ _T("0"), _T("4,4,,F8726FBB")); // MLP
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
- _T("Source Filter"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
+ _T("Source Filter"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".dts"),
- _T("Source Filter"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".dts"),
+ _T("Source Filter"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".ac3"),
- _T("Source Filter"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".ac3"),
+ _T("Source Filter"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".eac3"),
- _T("Source Filter"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".eac3"),
+ _T("Source Filter"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".dts"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".ac3"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".eac3"));
+ DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".dts"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".ac3"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".eac3"));
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -180,7 +181,7 @@ CFilterApp theApp;
//
CDTSAC3Source::CDTSAC3Source(LPUNKNOWN lpunk, HRESULT* phr)
- : CBaseSource<CDTSAC3Stream>(NAME("CDTSAC3Source"), lpunk, phr, __uuidof(this))
+ : CBaseSource<CDTSAC3Stream>(NAME("CDTSAC3Source"), lpunk, phr, __uuidof(this))
{
}
@@ -190,337 +191,348 @@ CDTSAC3Source::~CDTSAC3Source()
STDMETHODIMP CDTSAC3Source::QueryFilterInfo(FILTER_INFO* pInfo)
{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
- wcscpy_s(pInfo->achName, DTSAC3SourceName);
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
+ CheckPointer(pInfo, E_POINTER);
+ ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
+ wcscpy_s(pInfo->achName, DTSAC3SourceName);
+ pInfo->pGraph = m_pGraph;
+ if (m_pGraph) {
+ m_pGraph->AddRef();
+ }
+
+ return S_OK;
}
// CDTSAC3Stream
CDTSAC3Stream::CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr)
- : CBaseStream(NAME("CDTSAC3Stream"), pParent, phr)
- , m_dataOffset(0)
- , m_subtype(GUID_NULL)
- , m_wFormatTag(WAVE_FORMAT_UNKNOWN)
- , m_channels(0)
- , m_samplerate(0)
- , m_bitrate(0)
- , m_framesize(0)
- , m_fixedframesize(true)
- , m_framelength(0)
- , m_bitdepth(0)
- , m_streamtype(unknown)
+ : CBaseStream(NAME("CDTSAC3Stream"), pParent, phr)
+ , m_dataOffset(0)
+ , m_subtype(GUID_NULL)
+ , m_wFormatTag(WAVE_FORMAT_UNKNOWN)
+ , m_channels(0)
+ , m_samplerate(0)
+ , m_bitrate(0)
+ , m_framesize(0)
+ , m_fixedframesize(true)
+ , m_framelength(0)
+ , m_bitdepth(0)
+ , m_streamtype(unknown)
{
- CAutoLock cAutoLock(&m_cSharedState);
- CString fn(wfn);
- CFileException ex;
- HRESULT hr = E_FAIL;
- m_AvgTimePerFrame = 0;
-
- bool waveheader = false;
-
- do {
- if (!m_file.Open(fn, CFile::modeRead|CFile::shareDenyNone, &ex)) {
- hr = AmHresultFromWin32 (ex.m_lOsError);
- break;
- }
- const CString path = m_file.GetFilePath();
- const CString ext = CPath(m_file.GetFileName()).GetExtension().MakeLower();
-
- DWORD id = 0;
- DWORD id2 = 0;
- if (m_file.Read(&id, sizeof(id)) != sizeof(id) ||
- m_file.Read(&id2, sizeof(id2)) != sizeof(id2))
- break;
-
- // WAVE-CD header
- if (id == RIFF_DWORD) {
- if (ext != _T(".dtswav") && ext != _T(".dts") && ext != _T(".wav")) //check only specific extensions
- break;
- BYTE buf[44];
- m_file.SeekToBegin();
- if (m_file.Read(&buf, 44) != 44
- || ParseWAVECDHeader(buf) == 0
- || m_file.Read(&id, sizeof(id)) != sizeof(id))
- break;
- waveheader = true;
- }
-
- m_dataOffset = m_file.GetPosition() - sizeof(id) - (!waveheader ? sizeof(id2) : 0);
-
- bool isFound = isDTSSync(id) || (WORD)id==AC3_SYNC_WORD || id==IEC61937_SYNC_WORD || id2==MLP_SYNC_WORD /*|| id2!=TRUEHD_SYNC_WORD*/;
-
- // search DTS and AC3 headers (skip garbage in the beginning)
- if (!isFound) {
- UINT buflen = 0;
- if (waveheader && ext == _T(".wav") && PathFileExists(path.Left(path.GetLength()-ext.GetLength()) + _T(".cue"))) {
- buflen = 64 * 1024; // for .wav+.cue sometimes need to use a more deep search
- }
- else if (ext == _T(".dtswav") || ext == _T(".dts") || ext == _T(".wav") || ext == _T(".ac3") || ext == _T(".eac3")) { //check only specific extensions
- buflen = 6 * 1024;
- }
- else break;
-
- if (m_dataOffset < buflen) buflen -= (UINT)m_dataOffset; // tiny optimization
- m_file.Seek(m_dataOffset, CFile::begin);
-
- BYTE* buf = new BYTE[buflen];
- int len = m_file.Read(buf, buflen);
- if (len<100) break; // file is very small
-
- for (int i = 1; i < len - 4; i++) { // looking for DTS or AC3 sync
- id = *(DWORD*)(buf+i);
- if (isDTSSync(id) || (WORD)id==AC3_SYNC_WORD) {
- isFound = true;
- m_dataOffset += i;
- break;
- }
- }
- delete [] buf;
- }
- if (!isFound) break;
-
- m_file.Seek(m_dataOffset, CFile::begin);
-
- // DTS & DTS-HD
- if (isDTSSync(id)) {
- BYTE buf[16];
- if (m_file.Read(&buf, 16) != 16)
- break;
-
- // DTS header
- dts_state_t* m_dts_state;
- m_dts_state = dts_init(0);
- int fsize = 0, flags, targeted_bitrate;
- if ((fsize = dts_syncinfo(m_dts_state, buf, &flags, &m_samplerate, &targeted_bitrate, &m_framelength)) < 96) { //minimal valid fsize = 96
- break;
- }
- m_streamtype = DTS;
-
- // DTS-HD header and zero padded
- unsigned long sync = -1;
- unsigned int HD_size = 0;
- int zero_bytes = 0;
-
- m_file.Seek(m_dataOffset+fsize, CFile::begin);
- m_file.Read(&sync, sizeof(sync));
- if (id == DTS_SYNC_WORD && sync == DTSHD_SYNC_WORD && m_file.Read(&buf, 8)==8) {
- unsigned char isBlownUpHeader = (buf[1]>>5)&1;
- if (isBlownUpHeader)
- HD_size = ((buf[2]&1)<<19 | buf[3]<<11 | buf[4]<<3 | buf[5]>>5) + 1;
- else
- HD_size = ((buf[2]&31)<<11 | buf[3]<<3 | buf[4]>>5) + 1;
- //TODO: get more information about DTS-HD
- m_streamtype = DTSHD;
- m_fixedframesize = false;
- } else if (sync == 0 && fsize < 2048) { // zero padded?
- m_file.Seek(m_dataOffset+2048, CFile::begin);
- m_file.Read(&sync, sizeof(sync));
- if (sync == id) {
- zero_bytes = 2048 - fsize;
- m_streamtype = DTSPaded;
- }
- }
-
- /*const int bitratetbl[32] = {
- 32000, 56000, 64000, 96000,
- 112000, 128000, 192000, 224000,
- 256000, 320000, 384000, 448000,
- 512000, 576000, 640000, 768000,
- 960000, 1024000, 1152000, 1280000,
- 1344000, 1408000, 1411200, 1472000,
- 1536000, 1920000, 2048000, 3072000,
- 3840000, 0, 0, 0 //open, variable, lossless
- // [15] 768000 is actually 754500 for DVD
- // [24] 1536000 is actually 1509000 for ???
- // [24] 1536000 is actually 1509750 for DVD
- // [22] 1411200 is actually 1234800 for 14-bit DTS-CD audio
- };*/
- const int channels[16] = {1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8};
-
- // calculate actual bitrate
- m_framesize = fsize + HD_size + zero_bytes;
- m_bitrate = int ((m_framesize) * 8i64 * m_samplerate / m_framelength);
-
- // calculate framesize to support a sonic audio decoder 4.3 (TODO: make otherwise)
- // sonicDTSminsize = fsize + HD_size + 4096
- int k = (m_framesize + 4096 + m_framesize - 1) / m_framesize;
- m_framesize *= k;
- m_framelength *= k;
-
- if (flags & 0x70) //unknown number of channels
- m_channels = 6;
- else {
- m_channels = channels[flags & 0x0f];
- if (flags & DCA_LFE) m_channels += 1; //+LFE
- }
-
- if (m_bitrate!=0)
- m_AvgTimePerFrame = 10000000i64 * m_framesize * 8 / m_bitrate;
-
- m_wFormatTag = WAVE_FORMAT_DTS;
- m_subtype = MEDIASUBTYPE_DTS;
- }
- // AC3 & E-AC3
- else if ((WORD)id == AC3_SYNC_WORD) {
- BYTE buf[20];
- if (m_file.Read(&buf, 8) != 8)
- break;
-
- BYTE bsid = (buf[5] >> 3);
- int fsize = 0;
- int HD_size = 0;
-
- // AC3 header
- if (bsid < 12) {
- fsize = ParseAC3Header(buf, &m_samplerate, &m_channels, &m_framelength, &m_bitrate);
- if (fsize == 0) {
- break;
- }
- m_streamtype = AC3;
- /*
- // TrueHD+AC3
- m_file.Seek(m_dataOffset+fsize, CFile::begin);
- if (m_file.Read(&buf, 20) == 20) {
- int samplerate2, channels2, framelength2;
- HD_size = ParseTrueHDHeader(buf, &samplerate2, &channels2, &framelength2);
- if (HD_size > 0) {
- m_streamtype = TrueHDAC3;
- m_fixedframesize = false;
- }
- }
- */
- }
- // E-AC3 header
- else if (bsid == 16) {
- int frametype;
- fsize = ParseEAC3Header(buf, &m_samplerate, &m_channels, &m_framelength, &frametype);
- if (fsize == 0) {
- break;
- }
-
- m_file.Seek(m_dataOffset+fsize, CFile::begin);
- if (m_file.Read(&buf, 8) == 8) {
- int samplerate2, channels2, samples2, frametype2;
- int fsize2 = ParseEAC3Header(buf, &samplerate2, &channels2, &samples2, &frametype2);
- if (fsize2 > 0 && frametype2 == EAC3_FRAME_TYPE_DEPENDENT)
- fsize += fsize2;
- }
- m_bitrate = int (fsize * 8i64 * m_samplerate / m_framelength);
- m_streamtype = EAC3;
- } else { //unknown bsid
- break;
- }
-
- // calculate framesize to support a sonic audio decoder 4.3 (TODO: make otherwise)
- // sonicAC3minsize = framesize + 64
- m_framesize = fsize * 2;
- m_framelength *= 2;
-
- if (m_bitrate!=0)
- m_AvgTimePerFrame = 10000000i64 * m_framesize * 8 / m_bitrate;
-
- m_wFormatTag = WAVE_FORMAT_UNKNOWN;
- m_subtype = MEDIASUBTYPE_DOLBY_AC3;
- }
- // SPDIF AC3
- else if (waveheader && id == IEC61937_SYNC_WORD) {
- BYTE buf[16];
- if (m_file.Read(&buf, 16) != 16)
- break;
- m_framesize = ParseAC3IEC61937Header(buf);
- if (m_framesize == 0)
- break;
-
- m_wFormatTag = WAVE_FORMAT_DOLBY_AC3_SPDIF;
- m_channels = 2;
- m_samplerate = 44100;
- m_bitrate = 1411200;
- m_bitdepth = 16;
-
- m_AvgTimePerFrame = 10000000i64 * 1536 / 44100;
-
- m_subtype = MEDIASUBTYPE_DOLBY_AC3_SPDIF;
- m_streamtype = SPDIF_AC3;
- }
- // MLP
- else if (id2 == MLP_SYNC_WORD) {
- BYTE buf[20];
- if (m_file.Read(&buf, 20) != 20)
- break;
-
- bool istruehd;
- m_framesize = ParseMLPHeader(buf, &m_samplerate, &m_channels, &m_framelength, &m_bitdepth, &istruehd);
- if (m_framesize == 0) {
- break;
- }
-
- m_streamtype = MLP;
- m_fixedframesize = false;
-
- if (m_samplerate!=0)
- m_AvgTimePerFrame = 10000000i64 * m_framelength / m_samplerate;
-
- m_bitrate = (int)(m_framesize * 8i64 * m_samplerate / m_framelength); // inaccurate, because framesize is not constant
-
- m_wFormatTag = WAVE_FORMAT_UNKNOWN;
- m_subtype = MEDIASUBTYPE_MLP;
- }
- /*
- // TrueHD
- else if (id2 == TRUEHD_SYNC_WORD) {
- BYTE buf[20];
- if (m_file.Read(&buf, 20) != 20)
- break;
- int fsize = 0;
- int fsize2 = 0;
- fsize = ParseTrueHDHeader(buf, &m_samplerate, &m_channels, &m_framelength);
- if (fsize == 0)
- break;
- m_streamtype = TrueHD;
- m_fixedframesize = false;
-
- if (m_samplerate!=0)
- m_AvgTimePerFrame = 10000000i64 * m_framelength / m_samplerate;
-
- // TrueHD+AC3
- if (m_file.Read(&buf, 8) == 8) {
- int samplerate2, channels2, framelength2, bitrate2;
- fsize2 = ParseAC3Header(buf, &samplerate2, &channels2, &framelength2, &bitrate2);
- if (fsize2 > 0) {
- m_streamtype = TrueHDAC3;
-
- if (samplerate2!=0)
- m_AvgTimePerFrame = 10000000i64 * framelength2 / samplerate2;
- }
- }
-
- m_framesize = fsize + fsize2;
- m_bitrate = int ((m_framesize) * 8i64 * m_samplerate / m_framelength);
- //m_bitdepth = 24;
-
- m_wFormatTag = WAVE_FORMAT_UNKNOWN;
- m_subtype = MEDIASUBTYPE_DOLBY_TRUEHD;
- */
- else {
- break;
- }
-
- m_rtDuration = m_AvgTimePerFrame * (m_file.GetLength() - m_dataOffset) / m_framesize;
- m_rtStop = m_rtDuration;
-
- hr = S_OK;
- } while (false);
-
- if (phr) {
- *phr = hr;
- }
+ CAutoLock cAutoLock(&m_cSharedState);
+ CString fn(wfn);
+ CFileException ex;
+ HRESULT hr = E_FAIL;
+ m_AvgTimePerFrame = 0;
+
+ bool waveheader = false;
+
+ do {
+ if (!m_file.Open(fn, CFile::modeRead | CFile::shareDenyNone, &ex)) {
+ hr = AmHresultFromWin32(ex.m_lOsError);
+ break;
+ }
+ const CString path = m_file.GetFilePath();
+ const CString ext = CPath(m_file.GetFileName()).GetExtension().MakeLower();
+
+ DWORD id = 0;
+ DWORD id2 = 0;
+ if (m_file.Read(&id, sizeof(id)) != sizeof(id) ||
+ m_file.Read(&id2, sizeof(id2)) != sizeof(id2)) {
+ break;
+ }
+
+ // WAVE-CD header
+ if (id == RIFF_DWORD) {
+ if (ext != _T(".dtswav") && ext != _T(".dts") && ext != _T(".wav")) { //check only specific extensions
+ break;
+ }
+ BYTE buf[44];
+ m_file.SeekToBegin();
+ if (m_file.Read(&buf, 44) != 44
+ || ParseWAVECDHeader(buf) == 0
+ || m_file.Read(&id, sizeof(id)) != sizeof(id)) {
+ break;
+ }
+ waveheader = true;
+ }
+
+ m_dataOffset = m_file.GetPosition() - sizeof(id) - (!waveheader ? sizeof(id2) : 0);
+
+ bool isFound = isDTSSync(id) || (WORD)id == AC3_SYNC_WORD || id == IEC61937_SYNC_WORD || id2 == MLP_SYNC_WORD /*|| id2!=TRUEHD_SYNC_WORD*/;
+
+ // search DTS and AC3 headers (skip garbage in the beginning)
+ if (!isFound) {
+ UINT buflen = 0;
+ if (waveheader && ext == _T(".wav") && PathFileExists(path.Left(path.GetLength() - ext.GetLength()) + _T(".cue"))) {
+ buflen = 64 * 1024; // for .wav+.cue sometimes need to use a more deep search
+ } else if (ext == _T(".dtswav") || ext == _T(".dts") || ext == _T(".wav") || ext == _T(".ac3") || ext == _T(".eac3")) { //check only specific extensions
+ buflen = 6 * 1024;
+ } else { break; }
+
+ if (m_dataOffset < buflen) { buflen -= (UINT)m_dataOffset; } // tiny optimization
+ m_file.Seek(m_dataOffset, CFile::begin);
+
+ BYTE* buf = new BYTE[buflen];
+ int len = m_file.Read(buf, buflen);
+ if (len < 100) { break; } // file is very small
+
+ for (int i = 1; i < len - 4; i++) { // looking for DTS or AC3 sync
+ id = *(DWORD*)(buf + i);
+ if (isDTSSync(id) || (WORD)id == AC3_SYNC_WORD) {
+ isFound = true;
+ m_dataOffset += i;
+ break;
+ }
+ }
+ delete [] buf;
+ }
+ if (!isFound) { break; }
+
+ m_file.Seek(m_dataOffset, CFile::begin);
+
+ // DTS & DTS-HD
+ if (isDTSSync(id)) {
+ BYTE buf[16];
+ if (m_file.Read(&buf, 16) != 16) {
+ break;
+ }
+
+ // DTS header
+ dts_state_t* m_dts_state;
+ m_dts_state = dts_init(0);
+ int fsize = 0, flags, targeted_bitrate;
+ if ((fsize = dts_syncinfo(m_dts_state, buf, &flags, &m_samplerate, &targeted_bitrate, &m_framelength)) < 96) { //minimal valid fsize = 96
+ break;
+ }
+ m_streamtype = DTS;
+
+ // DTS-HD header and zero padded
+ unsigned long sync = -1;
+ unsigned int HD_size = 0;
+ int zero_bytes = 0;
+
+ m_file.Seek(m_dataOffset + fsize, CFile::begin);
+ m_file.Read(&sync, sizeof(sync));
+ if (id == DTS_SYNC_WORD && sync == DTSHD_SYNC_WORD && m_file.Read(&buf, 8) == 8) {
+ unsigned char isBlownUpHeader = (buf[1] >> 5) & 1;
+ if (isBlownUpHeader) {
+ HD_size = ((buf[2] & 1) << 19 | buf[3] << 11 | buf[4] << 3 | buf[5] >> 5) + 1;
+ } else {
+ HD_size = ((buf[2] & 31) << 11 | buf[3] << 3 | buf[4] >> 5) + 1;
+ }
+ //TODO: get more information about DTS-HD
+ m_streamtype = DTSHD;
+ m_fixedframesize = false;
+ } else if (sync == 0 && fsize < 2048) { // zero padded?
+ m_file.Seek(m_dataOffset + 2048, CFile::begin);
+ m_file.Read(&sync, sizeof(sync));
+ if (sync == id) {
+ zero_bytes = 2048 - fsize;
+ m_streamtype = DTSPaded;
+ }
+ }
+
+ /*const int bitratetbl[32] = {
+ 32000, 56000, 64000, 96000,
+ 112000, 128000, 192000, 224000,
+ 256000, 320000, 384000, 448000,
+ 512000, 576000, 640000, 768000,
+ 960000, 1024000, 1152000, 1280000,
+ 1344000, 1408000, 1411200, 1472000,
+ 1536000, 1920000, 2048000, 3072000,
+ 3840000, 0, 0, 0 //open, variable, lossless
+ // [15] 768000 is actually 754500 for DVD
+ // [24] 1536000 is actually 1509000 for ???
+ // [24] 1536000 is actually 1509750 for DVD
+ // [22] 1411200 is actually 1234800 for 14-bit DTS-CD audio
+ };*/
+ const int channels[16] = {1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8};
+
+ // calculate actual bitrate
+ m_framesize = fsize + HD_size + zero_bytes;
+ m_bitrate = int ((m_framesize) * 8i64 * m_samplerate / m_framelength);
+
+ // calculate framesize to support a sonic audio decoder 4.3 (TODO: make otherwise)
+ // sonicDTSminsize = fsize + HD_size + 4096
+ int k = (m_framesize + 4096 + m_framesize - 1) / m_framesize;
+ m_framesize *= k;
+ m_framelength *= k;
+
+ if (flags & 0x70) { //unknown number of channels
+ m_channels = 6;
+ } else {
+ m_channels = channels[flags & 0x0f];
+ if (flags & DCA_LFE) { m_channels += 1; } //+LFE
+ }
+
+ if (m_bitrate != 0) {
+ m_AvgTimePerFrame = 10000000i64 * m_framesize * 8 / m_bitrate;
+ }
+
+ m_wFormatTag = WAVE_FORMAT_DTS;
+ m_subtype = MEDIASUBTYPE_DTS;
+ }
+ // AC3 & E-AC3
+ else if ((WORD)id == AC3_SYNC_WORD) {
+ BYTE buf[20];
+ if (m_file.Read(&buf, 8) != 8) {
+ break;
+ }
+
+ BYTE bsid = (buf[5] >> 3);
+ int fsize = 0;
+ int HD_size = 0;
+
+ // AC3 header
+ if (bsid < 12) {
+ fsize = ParseAC3Header(buf, &m_samplerate, &m_channels, &m_framelength, &m_bitrate);
+ if (fsize == 0) {
+ break;
+ }
+ m_streamtype = AC3;
+ /*
+ // TrueHD+AC3
+ m_file.Seek(m_dataOffset+fsize, CFile::begin);
+ if (m_file.Read(&buf, 20) == 20) {
+ int samplerate2, channels2, framelength2;
+ HD_size = ParseTrueHDHeader(buf, &samplerate2, &channels2, &framelength2);
+ if (HD_size > 0) {
+ m_streamtype = TrueHDAC3;
+ m_fixedframesize = false;
+ }
+ }
+ */
+ }
+ // E-AC3 header
+ else if (bsid == 16) {
+ int frametype;
+ fsize = ParseEAC3Header(buf, &m_samplerate, &m_channels, &m_framelength, &frametype);
+ if (fsize == 0) {
+ break;
+ }
+
+ m_file.Seek(m_dataOffset + fsize, CFile::begin);
+ if (m_file.Read(&buf, 8) == 8) {
+ int samplerate2, channels2, samples2, frametype2;
+ int fsize2 = ParseEAC3Header(buf, &samplerate2, &channels2, &samples2, &frametype2);
+ if (fsize2 > 0 && frametype2 == EAC3_FRAME_TYPE_DEPENDENT) {
+ fsize += fsize2;
+ }
+ }
+ m_bitrate = int (fsize * 8i64 * m_samplerate / m_framelength);
+ m_streamtype = EAC3;
+ } else { //unknown bsid
+ break;
+ }
+
+ // calculate framesize to support a sonic audio decoder 4.3 (TODO: make otherwise)
+ // sonicAC3minsize = framesize + 64
+ m_framesize = fsize * 2;
+ m_framelength *= 2;
+
+ if (m_bitrate != 0) {
+ m_AvgTimePerFrame = 10000000i64 * m_framesize * 8 / m_bitrate;
+ }
+
+ m_wFormatTag = WAVE_FORMAT_UNKNOWN;
+ m_subtype = MEDIASUBTYPE_DOLBY_AC3;
+ }
+ // SPDIF AC3
+ else if (waveheader && id == IEC61937_SYNC_WORD) {
+ BYTE buf[16];
+ if (m_file.Read(&buf, 16) != 16) {
+ break;
+ }
+ m_framesize = ParseAC3IEC61937Header(buf);
+ if (m_framesize == 0) {
+ break;
+ }
+
+ m_wFormatTag = WAVE_FORMAT_DOLBY_AC3_SPDIF;
+ m_channels = 2;
+ m_samplerate = 44100;
+ m_bitrate = 1411200;
+ m_bitdepth = 16;
+
+ m_AvgTimePerFrame = 10000000i64 * 1536 / 44100;
+
+ m_subtype = MEDIASUBTYPE_DOLBY_AC3_SPDIF;
+ m_streamtype = SPDIF_AC3;
+ }
+ // MLP
+ else if (id2 == MLP_SYNC_WORD) {
+ BYTE buf[20];
+ if (m_file.Read(&buf, 20) != 20) {
+ break;
+ }
+
+ bool istruehd;
+ m_framesize = ParseMLPHeader(buf, &m_samplerate, &m_channels, &m_framelength, &m_bitdepth, &istruehd);
+ if (m_framesize == 0) {
+ break;
+ }
+
+ m_streamtype = MLP;
+ m_fixedframesize = false;
+
+ if (m_samplerate != 0) {
+ m_AvgTimePerFrame = 10000000i64 * m_framelength / m_samplerate;
+ }
+
+ m_bitrate = (int)(m_framesize * 8i64 * m_samplerate / m_framelength); // inaccurate, because framesize is not constant
+
+ m_wFormatTag = WAVE_FORMAT_UNKNOWN;
+ m_subtype = MEDIASUBTYPE_MLP;
+ }
+ /*
+ // TrueHD
+ else if (id2 == TRUEHD_SYNC_WORD) {
+ BYTE buf[20];
+ if (m_file.Read(&buf, 20) != 20)
+ break;
+ int fsize = 0;
+ int fsize2 = 0;
+ fsize = ParseTrueHDHeader(buf, &m_samplerate, &m_channels, &m_framelength);
+ if (fsize == 0)
+ break;
+ m_streamtype = TrueHD;
+ m_fixedframesize = false;
+
+ if (m_samplerate!=0)
+ m_AvgTimePerFrame = 10000000i64 * m_framelength / m_samplerate;
+
+ // TrueHD+AC3
+ if (m_file.Read(&buf, 8) == 8) {
+ int samplerate2, channels2, framelength2, bitrate2;
+ fsize2 = ParseAC3Header(buf, &samplerate2, &channels2, &framelength2, &bitrate2);
+ if (fsize2 > 0) {
+ m_streamtype = TrueHDAC3;
+
+ if (samplerate2!=0)
+ m_AvgTimePerFrame = 10000000i64 * framelength2 / samplerate2;
+ }
+ }
+
+ m_framesize = fsize + fsize2;
+ m_bitrate = int ((m_framesize) * 8i64 * m_samplerate / m_framelength);
+ //m_bitdepth = 24;
+
+ m_wFormatTag = WAVE_FORMAT_UNKNOWN;
+ m_subtype = MEDIASUBTYPE_DOLBY_TRUEHD;
+ */
+ else {
+ break;
+ }
+
+ m_rtDuration = m_AvgTimePerFrame * (m_file.GetLength() - m_dataOffset) / m_framesize;
+ m_rtStop = m_rtDuration;
+
+ hr = S_OK;
+ } while (false);
+
+ if (phr) {
+ *phr = hr;
+ }
}
CDTSAC3Stream::~CDTSAC3Stream()
@@ -529,141 +541,141 @@ CDTSAC3Stream::~CDTSAC3Stream()
HRESULT CDTSAC3Stream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties)
{
- ASSERT(pAlloc);
- ASSERT(pProperties);
+ ASSERT(pAlloc);
+ ASSERT(pProperties);
- HRESULT hr = NOERROR;
+ HRESULT hr = NOERROR;
- pProperties->cBuffers = 1;
- pProperties->cbBuffer = m_framesize;
+ pProperties->cBuffers = 1;
+ pProperties->cbBuffer = m_framesize;
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
- return hr;
- }
+ ALLOCATOR_PROPERTIES Actual;
+ if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
- if (Actual.cbBuffer < pProperties->cbBuffer) {
- return E_FAIL;
- }
- ASSERT(Actual.cBuffers == pProperties->cBuffers);
+ if (Actual.cbBuffer < pProperties->cbBuffer) {
+ return E_FAIL;
+ }
+ ASSERT(Actual.cBuffers == pProperties->cBuffers);
- return NOERROR;
+ return NOERROR;
}
HRESULT CDTSAC3Stream::FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, long& len)
{
- BYTE* pOutOrg = pOut;
+ BYTE* pOutOrg = pOut;
- const GUID* majortype = &m_mt.majortype;
- const GUID* subtype = &m_mt.subtype;
- UNREFERENCED_PARAMETER(subtype);
+ const GUID* majortype = &m_mt.majortype;
+ const GUID* subtype = &m_mt.subtype;
+ UNREFERENCED_PARAMETER(subtype);
- if (*majortype == MEDIATYPE_Audio) {
- m_file.Seek(m_dataOffset + nFrame*m_framesize, CFile::begin);
- if ((int)m_file.Read(pOut, m_framesize) < m_framesize) {
- return S_FALSE;
- }
- pOut += m_framesize;
- }
+ if (*majortype == MEDIATYPE_Audio) {
+ m_file.Seek(m_dataOffset + nFrame * m_framesize, CFile::begin);
+ if ((int)m_file.Read(pOut, m_framesize) < m_framesize) {
+ return S_FALSE;
+ }
+ pOut += m_framesize;
+ }
- len = (long)(pOut - pOutOrg);
+ len = (long)(pOut - pOutOrg);
- return S_OK;
+ return S_OK;
}
bool CDTSAC3Stream::CheckDTS(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Audio
- && pmt->subtype == MEDIASUBTYPE_DTS
- && pmt->formattype == FORMAT_WaveFormatEx
- && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_DTS;
+ return pmt->majortype == MEDIATYPE_Audio
+ && pmt->subtype == MEDIASUBTYPE_DTS
+ && pmt->formattype == FORMAT_WaveFormatEx
+ && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_DTS;
}
bool CDTSAC3Stream::CheckDTS2(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Audio
- && pmt->subtype == MEDIASUBTYPE_WAVE_DTS
- && pmt->formattype == FORMAT_WaveFormatEx
- && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_DVD_DTS;
+ return pmt->majortype == MEDIATYPE_Audio
+ && pmt->subtype == MEDIASUBTYPE_WAVE_DTS
+ && pmt->formattype == FORMAT_WaveFormatEx
+ && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_DVD_DTS;
}
bool CDTSAC3Stream::CheckAC3(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Audio
- && pmt->subtype == MEDIASUBTYPE_DOLBY_AC3
- && pmt->formattype == FORMAT_WaveFormatEx
- && (((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_UNKNOWN
- || ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_DOLBY_AC3);
+ return pmt->majortype == MEDIATYPE_Audio
+ && pmt->subtype == MEDIASUBTYPE_DOLBY_AC3
+ && pmt->formattype == FORMAT_WaveFormatEx
+ && (((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_UNKNOWN
+ || ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_DOLBY_AC3);
}
bool CDTSAC3Stream::CheckSPDIFAC3(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Audio
- && pmt->subtype == MEDIASUBTYPE_DOLBY_AC3_SPDIF
- && pmt->formattype == FORMAT_WaveFormatEx
- && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_DOLBY_AC3_SPDIF;
+ return pmt->majortype == MEDIATYPE_Audio
+ && pmt->subtype == MEDIASUBTYPE_DOLBY_AC3_SPDIF
+ && pmt->formattype == FORMAT_WaveFormatEx
+ && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_DOLBY_AC3_SPDIF;
}
bool CDTSAC3Stream::CheckMLP(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Audio
- && pmt->subtype == MEDIASUBTYPE_MLP
- && pmt->formattype == FORMAT_WaveFormatEx
- && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_UNKNOWN;
+ return pmt->majortype == MEDIATYPE_Audio
+ && pmt->subtype == MEDIASUBTYPE_MLP
+ && pmt->formattype == FORMAT_WaveFormatEx
+ && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_UNKNOWN;
}
/*
bool CDTSAC3Stream::CheckTrueHD(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Audio
- && pmt->subtype == MEDIASUBTYPE_DOLBY_TRUEHD
- && pmt->formattype == FORMAT_WaveFormatEx
- && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_UNKNOWN;
+ return pmt->majortype == MEDIATYPE_Audio
+ && pmt->subtype == MEDIASUBTYPE_DOLBY_TRUEHD
+ && pmt->formattype == FORMAT_WaveFormatEx
+ && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_UNKNOWN;
}
*/
HRESULT CDTSAC3Stream::GetMediaType(int iPosition, CMediaType* pmt)
{
- CAutoLock cAutoLock(m_pFilter->pStateLock());
-
- if (iPosition == 0) {
- pmt->majortype = MEDIATYPE_Audio;
- pmt->subtype = m_subtype;
- pmt->formattype = FORMAT_WaveFormatEx;
-
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
- wfe->wFormatTag = m_wFormatTag;
- wfe->nChannels = m_channels;
- wfe->nSamplesPerSec = m_samplerate;
- wfe->nAvgBytesPerSec = (m_bitrate + 4) /8;
- wfe->nBlockAlign = m_framesize < WORD_MAX ? m_framesize : WORD_MAX;
- wfe->wBitsPerSample = m_bitdepth;
- wfe->cbSize = 0;
-
- if (m_streamtype == SPDIF_AC3) {
- wfe->nBlockAlign = 4;
- pmt->SetSampleSize(m_framesize);
- } else if (m_streamtype == MLP /*|| m_streamtype == TrueHD*/) {
- pmt->SetSampleSize(0);
- }
-
- } else {
- return VFW_S_NO_MORE_ITEMS;
- }
-
- pmt->SetTemporalCompression(FALSE);
-
- return S_OK;
+ CAutoLock cAutoLock(m_pFilter->pStateLock());
+
+ if (iPosition == 0) {
+ pmt->majortype = MEDIATYPE_Audio;
+ pmt->subtype = m_subtype;
+ pmt->formattype = FORMAT_WaveFormatEx;
+
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
+ wfe->wFormatTag = m_wFormatTag;
+ wfe->nChannels = m_channels;
+ wfe->nSamplesPerSec = m_samplerate;
+ wfe->nAvgBytesPerSec = (m_bitrate + 4) / 8;
+ wfe->nBlockAlign = m_framesize < WORD_MAX ? m_framesize : WORD_MAX;
+ wfe->wBitsPerSample = m_bitdepth;
+ wfe->cbSize = 0;
+
+ if (m_streamtype == SPDIF_AC3) {
+ wfe->nBlockAlign = 4;
+ pmt->SetSampleSize(m_framesize);
+ } else if (m_streamtype == MLP /*|| m_streamtype == TrueHD*/) {
+ pmt->SetSampleSize(0);
+ }
+
+ } else {
+ return VFW_S_NO_MORE_ITEMS;
+ }
+
+ pmt->SetTemporalCompression(FALSE);
+
+ return S_OK;
}
HRESULT CDTSAC3Stream::CheckMediaType(const CMediaType* pmt)
{
- return CheckDTS(pmt)
- || CheckDTS2(pmt)
- || CheckAC3(pmt)
- || CheckSPDIFAC3(pmt)
- || CheckMLP(pmt)
- //|| CheckTrueHD(pmt)
- ? S_OK
- : E_INVALIDARG;
+ return CheckDTS(pmt)
+ || CheckDTS2(pmt)
+ || CheckAC3(pmt)
+ || CheckSPDIFAC3(pmt)
+ || CheckMLP(pmt)
+ //|| CheckTrueHD(pmt)
+ ? S_OK
+ : E_INVALIDARG;
}
diff --git a/src/filters/source/DTSAC3Source/DTSAC3Source.h b/src/filters/source/DTSAC3Source/DTSAC3Source.h
index 75cd92b94..8da838b12 100644
--- a/src/filters/source/DTSAC3Source/DTSAC3Source.h
+++ b/src/filters/source/DTSAC3Source/DTSAC3Source.h
@@ -31,46 +31,46 @@
class CDTSAC3Stream;
class __declspec(uuid("B4A7BE85-551D-4594-BDC7-832B09185041"))
- CDTSAC3Source : public CBaseSource<CDTSAC3Stream>
+ CDTSAC3Source : public CBaseSource<CDTSAC3Stream>
{
public:
- CDTSAC3Source(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CDTSAC3Source();
+ CDTSAC3Source(LPUNKNOWN lpunk, HRESULT* phr);
+ virtual ~CDTSAC3Source();
- // CBaseFilter
- STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
+ // CBaseFilter
+ STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
};
class CDTSAC3Stream : public CBaseStream
{
- CFile m_file;
- LONGLONG m_dataOffset;
+ CFile m_file;
+ LONGLONG m_dataOffset;
- GUID m_subtype;
- WORD m_wFormatTag;
- int m_channels; // number of channels
- int m_samplerate; // samples per second
- int m_bitrate; // bits per second
- int m_framesize; // bytes per frame
- bool m_fixedframesize; // constant frame size
- int m_framelength; // sample per frame
- WORD m_bitdepth; // bits per sample
- BYTE m_streamtype;
+ GUID m_subtype;
+ WORD m_wFormatTag;
+ int m_channels; // number of channels
+ int m_samplerate; // samples per second
+ int m_bitrate; // bits per second
+ int m_framesize; // bytes per frame
+ bool m_fixedframesize; // constant frame size
+ int m_framelength; // sample per frame
+ WORD m_bitdepth; // bits per sample
+ BYTE m_streamtype;
- bool CheckDTS(const CMediaType* pmt);
- bool CheckDTS2(const CMediaType* pmt);
- bool CheckAC3(const CMediaType* pmt);
- bool CheckSPDIFAC3(const CMediaType* pmt);
- bool CheckMLP(const CMediaType* pmt);
- //bool CheckTrueHD(const CMediaType* pmt);
+ bool CheckDTS(const CMediaType* pmt);
+ bool CheckDTS2(const CMediaType* pmt);
+ bool CheckAC3(const CMediaType* pmt);
+ bool CheckSPDIFAC3(const CMediaType* pmt);
+ bool CheckMLP(const CMediaType* pmt);
+ //bool CheckTrueHD(const CMediaType* pmt);
public:
- CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr);
- virtual ~CDTSAC3Stream();
+ CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr);
+ virtual ~CDTSAC3Stream();
- HRESULT FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, long& len);
+ HRESULT FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, long& len);
- HRESULT DecideBufferSize(IMemAllocator* pIMemAlloc, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT CheckMediaType(const CMediaType* pMediaType);
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
+ HRESULT DecideBufferSize(IMemAllocator* pIMemAlloc, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT CheckMediaType(const CMediaType* pMediaType);
+ HRESULT GetMediaType(int iPosition, CMediaType* pmt);
};
diff --git a/src/filters/source/FLACSource/FLACSource.cpp b/src/filters/source/FLACSource/FLACSource.cpp
index 56315d67c..3dba4bd8a 100644
--- a/src/filters/source/FLACSource/FLACSource.cpp
+++ b/src/filters/source/FLACSource/FLACSource.cpp
@@ -38,46 +38,46 @@
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_FLAC_FRAMED}
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_FLAC_FRAMED}
};
const AMOVIESETUP_PIN sudOpPin[] = {
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CFLACSource), FlacSourceName, MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
+ {&__uuidof(CFLACSource), FlacSourceName, MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CFLACSource>, NULL, &sudFilter[0]}
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CFLACSource>, NULL, &sudFilter[0]}
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{1930D8FF-4739-4e42-9199-3B2EDEAA3BF2}"),
- _T("0"), _T("0,4,,664C6143"));
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{1930D8FF-4739-4e42-9199-3B2EDEAA3BF2}"),
+ _T("0"), _T("0,4,,664C6143"));
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{1930D8FF-4739-4e42-9199-3B2EDEAA3BF2}"),
- _T("Source Filter"), _T("{1930D8FF-4739-4e42-9199-3B2EDEAA3BF2}"));
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{1930D8FF-4739-4e42-9199-3B2EDEAA3BF2}"),
+ _T("Source Filter"), _T("{1930D8FF-4739-4e42-9199-3B2EDEAA3BF2}"));
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".flac"),
- _T("Source Filter"), _T("{1930D8FF-4739-4e42-9199-3B2EDEAA3BF2}"));
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".flac"),
+ _T("Source Filter"), _T("{1930D8FF-4739-4e42-9199-3B2EDEAA3BF2}"));
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{1930D8FF-4739-4e42-9199-3B2EDEAA3BF2}"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".flac"));
+ DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{1930D8FF-4739-4e42-9199-3B2EDEAA3BF2}"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".flac"));
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -88,14 +88,14 @@ CFilterApp theApp;
// Declaration for FLAC callbacks
-static FLAC__StreamDecoderReadStatus StreamDecoderRead(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
-static FLAC__StreamDecoderSeekStatus StreamDecoderSeek(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
-static FLAC__StreamDecoderTellStatus StreamDecoderTell(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
-static FLAC__StreamDecoderLengthStatus StreamDecoderLength(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data);
-static FLAC__bool StreamDecoderEof(const FLAC__StreamDecoder *decoder, void *client_data);
-static FLAC__StreamDecoderWriteStatus StreamDecoderWrite(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
-static void StreamDecoderError(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
-static void StreamDecoderMetadata(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
+static FLAC__StreamDecoderReadStatus StreamDecoderRead(const FLAC__StreamDecoder* decoder, FLAC__byte buffer[], size_t* bytes, void* client_data);
+static FLAC__StreamDecoderSeekStatus StreamDecoderSeek(const FLAC__StreamDecoder* decoder, FLAC__uint64 absolute_byte_offset, void* client_data);
+static FLAC__StreamDecoderTellStatus StreamDecoderTell(const FLAC__StreamDecoder* decoder, FLAC__uint64* absolute_byte_offset, void* client_data);
+static FLAC__StreamDecoderLengthStatus StreamDecoderLength(const FLAC__StreamDecoder* decoder, FLAC__uint64* stream_length, void* client_data);
+static FLAC__bool StreamDecoderEof(const FLAC__StreamDecoder* decoder, void* client_data);
+static FLAC__StreamDecoderWriteStatus StreamDecoderWrite(const FLAC__StreamDecoder* decoder, const FLAC__Frame* frame, const FLAC__int32* const buffer[], void* client_data);
+static void StreamDecoderError(const FLAC__StreamDecoder* decoder, FLAC__StreamDecoderErrorStatus status, void* client_data);
+static void StreamDecoderMetadata(const FLAC__StreamDecoder* decoder, const FLAC__StreamMetadata* metadata, void* client_data);
//
@@ -103,7 +103,7 @@ static void StreamDecoderMetadata(const FLAC__StreamDecoder *decoder, con
//
CFLACSource::CFLACSource(LPUNKNOWN lpunk, HRESULT* phr)
- : CBaseSource<CFLACStream>(NAME("CFLACSource"), lpunk, phr, __uuidof(this))
+ : CBaseSource<CFLACStream>(NAME("CFLACSource"), lpunk, phr, __uuidof(this))
{
}
@@ -113,253 +113,253 @@ CFLACSource::~CFLACSource()
STDMETHODIMP CFLACSource::QueryFilterInfo(FILTER_INFO* pInfo)
{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
- wcscpy_s(pInfo->achName, FlacSourceName);
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
+ CheckPointer(pInfo, E_POINTER);
+ ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
+ wcscpy_s(pInfo->achName, FlacSourceName);
+ pInfo->pGraph = m_pGraph;
+ if (m_pGraph) {
+ m_pGraph->AddRef();
+ }
+
+ return S_OK;
}
// CFLACStream
CFLACStream::CFLACStream(const WCHAR* wfn, CSource* pParent, HRESULT* phr)
- : CBaseStream(NAME("CFLACStream"), pParent, phr)
- , m_bIsEOF (false)
- , m_pDecoder (NULL)
+ : CBaseStream(NAME("CFLACStream"), pParent, phr)
+ , m_bIsEOF(false)
+ , m_pDecoder(NULL)
{
- CAutoLock cAutoLock(&m_cSharedState);
- CString fn(wfn);
- CFileException ex;
- HRESULT hr = E_FAIL;
-
- do {
- if (!m_file.Open(fn, CFile::modeRead|CFile::shareDenyNone, &ex)) {
- hr = AmHresultFromWin32 (ex.m_lOsError);
- break;
- }
-
- m_pDecoder = FLAC__stream_decoder_new();
- if (!m_pDecoder) {
- break;
- }
-
- if (FLAC__STREAM_DECODER_INIT_STATUS_OK != FLAC__stream_decoder_init_stream (_DECODER_,
- StreamDecoderRead,
- StreamDecoderSeek,
- StreamDecoderTell,
- StreamDecoderLength,
- StreamDecoderEof,
- StreamDecoderWrite,
- StreamDecoderMetadata,
- StreamDecoderError,
- this)) {
- break;
- }
-
-
- if (!FLAC__stream_decoder_process_until_end_of_metadata (_DECODER_) ||
- !FLAC__stream_decoder_seek_absolute (_DECODER_, 0)) {
- break;
- }
-
- FLAC__stream_decoder_get_decode_position(_DECODER_, &m_llOffset);
-
- hr = S_OK;
- } while (false);
-
- if (phr) {
- *phr = hr;
- }
+ CAutoLock cAutoLock(&m_cSharedState);
+ CString fn(wfn);
+ CFileException ex;
+ HRESULT hr = E_FAIL;
+
+ do {
+ if (!m_file.Open(fn, CFile::modeRead | CFile::shareDenyNone, &ex)) {
+ hr = AmHresultFromWin32(ex.m_lOsError);
+ break;
+ }
+
+ m_pDecoder = FLAC__stream_decoder_new();
+ if (!m_pDecoder) {
+ break;
+ }
+
+ if (FLAC__STREAM_DECODER_INIT_STATUS_OK != FLAC__stream_decoder_init_stream(_DECODER_,
+ StreamDecoderRead,
+ StreamDecoderSeek,
+ StreamDecoderTell,
+ StreamDecoderLength,
+ StreamDecoderEof,
+ StreamDecoderWrite,
+ StreamDecoderMetadata,
+ StreamDecoderError,
+ this)) {
+ break;
+ }
+
+
+ if (!FLAC__stream_decoder_process_until_end_of_metadata(_DECODER_) ||
+ !FLAC__stream_decoder_seek_absolute(_DECODER_, 0)) {
+ break;
+ }
+
+ FLAC__stream_decoder_get_decode_position(_DECODER_, &m_llOffset);
+
+ hr = S_OK;
+ } while (false);
+
+ if (phr) {
+ *phr = hr;
+ }
}
CFLACStream::~CFLACStream()
{
- if (m_pDecoder) {
- FLAC__stream_decoder_delete (_DECODER_);
- m_pDecoder = NULL;
- }
+ if (m_pDecoder) {
+ FLAC__stream_decoder_delete(_DECODER_);
+ m_pDecoder = NULL;
+ }
}
HRESULT CFLACStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties)
{
- ASSERT(pAlloc);
- ASSERT(pProperties);
+ ASSERT(pAlloc);
+ ASSERT(pProperties);
- HRESULT hr = NOERROR;
+ HRESULT hr = NOERROR;
- pProperties->cBuffers = 1;
- pProperties->cbBuffer = m_nMaxFrameSize;
+ pProperties->cBuffers = 1;
+ pProperties->cbBuffer = m_nMaxFrameSize;
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
- return hr;
- }
+ ALLOCATOR_PROPERTIES Actual;
+ if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
- if (Actual.cbBuffer < pProperties->cbBuffer) {
- return E_FAIL;
- }
- ASSERT(Actual.cBuffers == pProperties->cBuffers);
+ if (Actual.cbBuffer < pProperties->cbBuffer) {
+ return E_FAIL;
+ }
+ ASSERT(Actual.cBuffers == pProperties->cBuffers);
- return NOERROR;
+ return NOERROR;
}
HRESULT CFLACStream::FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, long& len)
{
- FLAC__uint64 llCurPos;
- FLAC__uint64 llNextPos;
+ FLAC__uint64 llCurPos;
+ FLAC__uint64 llNextPos;
- if (m_bDiscontinuity) {
- FLAC__stream_decoder_seek_absolute (_DECODER_, (m_rtPosition * m_i64TotalNumSamples) / m_rtDuration);
- }
+ if (m_bDiscontinuity) {
+ FLAC__stream_decoder_seek_absolute(_DECODER_, (m_rtPosition * m_i64TotalNumSamples) / m_rtDuration);
+ }
- FLAC__stream_decoder_get_decode_position(_DECODER_, &llCurPos);
+ FLAC__stream_decoder_get_decode_position(_DECODER_, &llCurPos);
- FLAC__stream_decoder_skip_single_frame (_DECODER_);
- if (m_bIsEOF) {
- return S_FALSE;
- }
- FLAC__stream_decoder_get_decode_position(_DECODER_, &llNextPos);
+ FLAC__stream_decoder_skip_single_frame(_DECODER_);
+ if (m_bIsEOF) {
+ return S_FALSE;
+ }
+ FLAC__stream_decoder_get_decode_position(_DECODER_, &llNextPos);
- FLAC__uint64 llCurFile = m_file.GetPosition();
- len = (long)(llNextPos - llCurPos);
- ASSERT (len > 0);
- if (len <= 0) {
- return S_FALSE;
- }
+ FLAC__uint64 llCurFile = m_file.GetPosition();
+ len = (long)(llNextPos - llCurPos);
+ ASSERT(len > 0);
+ if (len <= 0) {
+ return S_FALSE;
+ }
- m_file.Seek (llCurPos, CFile::begin);
- m_file.Read (pOut, len);
- m_file.Seek (llCurFile, CFile::begin);
+ m_file.Seek(llCurPos, CFile::begin);
+ m_file.Read(pOut, len);
+ m_file.Seek(llCurFile, CFile::begin);
- m_AvgTimePerFrame = m_rtDuration * len / (m_llFileSize-m_llOffset);
+ m_AvgTimePerFrame = m_rtDuration * len / (m_llFileSize - m_llOffset);
- return S_OK;
+ return S_OK;
}
HRESULT CFLACStream::GetMediaType(int iPosition, CMediaType* pmt)
{
- CAutoLock cAutoLock(m_pFilter->pStateLock());
-
- if (iPosition == 0) {
- pmt->majortype = MEDIATYPE_Audio;
- pmt->subtype = MEDIASUBTYPE_FLAC_FRAMED;
- pmt->formattype = FORMAT_WaveFormatEx;
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
- memset(wfe, 0, sizeof(WAVEFORMATEX));
- wfe->wFormatTag = WAVE_FORMAT_FLAC;
- wfe->nChannels = m_nChannels;
- wfe->nSamplesPerSec = m_nSamplesPerSec;
- wfe->nAvgBytesPerSec = m_nAvgBytesPerSec;
- wfe->nBlockAlign = 1;
- wfe->wBitsPerSample = m_wBitsPerSample;
- wfe->cbSize = 0;
- } else {
- return VFW_S_NO_MORE_ITEMS;
- }
-
- pmt->SetTemporalCompression(FALSE);
-
- return S_OK;
+ CAutoLock cAutoLock(m_pFilter->pStateLock());
+
+ if (iPosition == 0) {
+ pmt->majortype = MEDIATYPE_Audio;
+ pmt->subtype = MEDIASUBTYPE_FLAC_FRAMED;
+ pmt->formattype = FORMAT_WaveFormatEx;
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
+ memset(wfe, 0, sizeof(WAVEFORMATEX));
+ wfe->wFormatTag = WAVE_FORMAT_FLAC;
+ wfe->nChannels = m_nChannels;
+ wfe->nSamplesPerSec = m_nSamplesPerSec;
+ wfe->nAvgBytesPerSec = m_nAvgBytesPerSec;
+ wfe->nBlockAlign = 1;
+ wfe->wBitsPerSample = m_wBitsPerSample;
+ wfe->cbSize = 0;
+ } else {
+ return VFW_S_NO_MORE_ITEMS;
+ }
+
+ pmt->SetTemporalCompression(FALSE);
+
+ return S_OK;
}
HRESULT CFLACStream::CheckMediaType(const CMediaType* pmt)
{
- if ( pmt->majortype == MEDIATYPE_Audio
- && pmt->subtype == MEDIASUBTYPE_FLAC_FRAMED
- && pmt->formattype == FORMAT_WaveFormatEx
- && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_FLAC) {
- return S_OK;
- } else {
- return E_INVALIDARG;
- }
+ if (pmt->majortype == MEDIATYPE_Audio
+ && pmt->subtype == MEDIASUBTYPE_FLAC_FRAMED
+ && pmt->formattype == FORMAT_WaveFormatEx
+ && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_FLAC) {
+ return S_OK;
+ } else {
+ return E_INVALIDARG;
+ }
}
-void CFLACStream::UpdateFromMetadata (void* pBuffer)
+void CFLACStream::UpdateFromMetadata(void* pBuffer)
{
- const FLAC__StreamMetadata* pMetadata = (const FLAC__StreamMetadata*) pBuffer;
-
- m_nMaxFrameSize = pMetadata->data.stream_info.max_framesize;
- m_nSamplesPerSec = pMetadata->data.stream_info.sample_rate;
- m_nChannels = pMetadata->data.stream_info.channels;
- m_wBitsPerSample = pMetadata->data.stream_info.bits_per_sample;
- m_i64TotalNumSamples = pMetadata->data.stream_info.total_samples;
- m_nAvgBytesPerSec = (m_nChannels * (m_wBitsPerSample >> 3)) * m_nSamplesPerSec;
-
- // === Init members from base classes
- GetFileSizeEx (m_file.m_hFile, (LARGE_INTEGER*)&m_llFileSize);
- m_rtDuration = (m_i64TotalNumSamples * UNITS) / m_nSamplesPerSec;
- m_rtStop = m_rtDuration;
- m_AvgTimePerFrame = (m_nMaxFrameSize + pMetadata->data.stream_info.min_framesize) * m_rtDuration / 2 / m_llFileSize;
+ const FLAC__StreamMetadata* pMetadata = (const FLAC__StreamMetadata*) pBuffer;
+
+ m_nMaxFrameSize = pMetadata->data.stream_info.max_framesize;
+ m_nSamplesPerSec = pMetadata->data.stream_info.sample_rate;
+ m_nChannels = pMetadata->data.stream_info.channels;
+ m_wBitsPerSample = pMetadata->data.stream_info.bits_per_sample;
+ m_i64TotalNumSamples = pMetadata->data.stream_info.total_samples;
+ m_nAvgBytesPerSec = (m_nChannels * (m_wBitsPerSample >> 3)) * m_nSamplesPerSec;
+
+ // === Init members from base classes
+ GetFileSizeEx(m_file.m_hFile, (LARGE_INTEGER*)&m_llFileSize);
+ m_rtDuration = (m_i64TotalNumSamples * UNITS) / m_nSamplesPerSec;
+ m_rtStop = m_rtDuration;
+ m_AvgTimePerFrame = (m_nMaxFrameSize + pMetadata->data.stream_info.min_framesize) * m_rtDuration / 2 / m_llFileSize;
}
-FLAC__StreamDecoderReadStatus StreamDecoderRead(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
+FLAC__StreamDecoderReadStatus StreamDecoderRead(const FLAC__StreamDecoder* decoder, FLAC__byte buffer[], size_t* bytes, void* client_data)
{
- CFLACStream* pThis = static_cast<CFLACStream*>(client_data);
- UINT nRead = pThis->GetFile()->Read(buffer, (UINT)*bytes);
+ CFLACStream* pThis = static_cast<CFLACStream*>(client_data);
+ UINT nRead = pThis->GetFile()->Read(buffer, (UINT) * bytes);
- pThis->m_bIsEOF = (nRead != *bytes);
- *bytes = nRead;
+ pThis->m_bIsEOF = (nRead != *bytes);
+ *bytes = nRead;
- return (*bytes == 0) ? FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM : FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
+ return (*bytes == 0) ? FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM : FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
}
-FLAC__StreamDecoderSeekStatus StreamDecoderSeek(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data)
+FLAC__StreamDecoderSeekStatus StreamDecoderSeek(const FLAC__StreamDecoder* decoder, FLAC__uint64 absolute_byte_offset, void* client_data)
{
- CFLACStream* pThis = static_cast<CFLACStream*> (client_data);
+ CFLACStream* pThis = static_cast<CFLACStream*>(client_data);
- pThis->m_bIsEOF = false;
- pThis->GetFile()->Seek (absolute_byte_offset, CFile::begin);
- return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
+ pThis->m_bIsEOF = false;
+ pThis->GetFile()->Seek(absolute_byte_offset, CFile::begin);
+ return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
}
-FLAC__StreamDecoderTellStatus StreamDecoderTell(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data)
+FLAC__StreamDecoderTellStatus StreamDecoderTell(const FLAC__StreamDecoder* decoder, FLAC__uint64* absolute_byte_offset, void* client_data)
{
- CFLACStream* pThis = static_cast<CFLACStream*> (client_data);
- *absolute_byte_offset = pThis->GetFile()->GetPosition();
- return FLAC__STREAM_DECODER_TELL_STATUS_OK;
+ CFLACStream* pThis = static_cast<CFLACStream*>(client_data);
+ *absolute_byte_offset = pThis->GetFile()->GetPosition();
+ return FLAC__STREAM_DECODER_TELL_STATUS_OK;
}
-FLAC__StreamDecoderLengthStatus StreamDecoderLength(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data)
+FLAC__StreamDecoderLengthStatus StreamDecoderLength(const FLAC__StreamDecoder* decoder, FLAC__uint64* stream_length, void* client_data)
{
- CFLACStream* pThis = static_cast<CFLACStream*> (client_data);
- CFile* pFile = pThis->GetFile();
-
- if (pFile == NULL) {
- return FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED;
- } else {
- *stream_length = pFile->GetLength();
- return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
- }
+ CFLACStream* pThis = static_cast<CFLACStream*>(client_data);
+ CFile* pFile = pThis->GetFile();
+
+ if (pFile == NULL) {
+ return FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED;
+ } else {
+ *stream_length = pFile->GetLength();
+ return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
+ }
}
-FLAC__bool StreamDecoderEof(const FLAC__StreamDecoder *decoder, void *client_data)
+FLAC__bool StreamDecoderEof(const FLAC__StreamDecoder* decoder, void* client_data)
{
- CFLACStream* pThis = static_cast<CFLACStream*> (client_data);
+ CFLACStream* pThis = static_cast<CFLACStream*>(client_data);
- return pThis->m_bIsEOF;
+ return pThis->m_bIsEOF;
}
-FLAC__StreamDecoderWriteStatus StreamDecoderWrite(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data)
+FLAC__StreamDecoderWriteStatus StreamDecoderWrite(const FLAC__StreamDecoder* decoder, const FLAC__Frame* frame, const FLAC__int32* const buffer[], void* client_data)
{
- CFLACStream* pThis = static_cast<CFLACStream*> (client_data);
- UNREFERENCED_PARAMETER(pThis);
+ CFLACStream* pThis = static_cast<CFLACStream*>(client_data);
+ UNREFERENCED_PARAMETER(pThis);
- return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
+ return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
}
-void StreamDecoderError(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)
+void StreamDecoderError(const FLAC__StreamDecoder* decoder, FLAC__StreamDecoderErrorStatus status, void* client_data)
{
}
-void StreamDecoderMetadata(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data)
+void StreamDecoderMetadata(const FLAC__StreamDecoder* decoder, const FLAC__StreamMetadata* metadata, void* client_data)
{
- CFLACStream* pThis = static_cast<CFLACStream*> (client_data);
+ CFLACStream* pThis = static_cast<CFLACStream*>(client_data);
- if (pThis) {
- pThis->UpdateFromMetadata ((void*)metadata);
- }
+ if (pThis) {
+ pThis->UpdateFromMetadata((void*)metadata);
+ }
}
diff --git a/src/filters/source/FLACSource/FLACSource.h b/src/filters/source/FLACSource/FLACSource.h
index 164ced2b9..f009b27b9 100644
--- a/src/filters/source/FLACSource/FLACSource.h
+++ b/src/filters/source/FLACSource/FLACSource.h
@@ -31,48 +31,48 @@
class CFLACStream;
class __declspec(uuid("1930D8FF-4739-4e42-9199-3B2EDEAA3BF2"))
- CFLACSource : public CBaseSource<CFLACStream>
+ CFLACSource : public CBaseSource<CFLACStream>
{
public:
- CFLACSource(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CFLACSource();
+ CFLACSource(LPUNKNOWN lpunk, HRESULT* phr);
+ virtual ~CFLACSource();
- // CBaseFilter
- STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
+ // CBaseFilter
+ STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
};
class CGolombBuffer;
class CFLACStream : public CBaseStream
{
- CFile m_file;
- void* m_pDecoder;
+ CFile m_file;
+ void* m_pDecoder;
- int m_nMaxFrameSize;
- int m_nSamplesPerSec;
- int m_nChannels;
- WORD m_wBitsPerSample;
- __int64 m_i64TotalNumSamples;
- int m_nAvgBytesPerSec;
+ int m_nMaxFrameSize;
+ int m_nSamplesPerSec;
+ int m_nChannels;
+ WORD m_wBitsPerSample;
+ __int64 m_i64TotalNumSamples;
+ int m_nAvgBytesPerSec;
- ULONGLONG m_llOffset; // Position of first frame in file
- ULONGLONG m_llFileSize; // Size of the file
+ ULONGLONG m_llOffset; // Position of first frame in file
+ ULONGLONG m_llFileSize; // Size of the file
public:
- CFLACStream(const WCHAR* wfn, CSource* pParent, HRESULT* phr);
- virtual ~CFLACStream();
+ CFLACStream(const WCHAR* wfn, CSource* pParent, HRESULT* phr);
+ virtual ~CFLACStream();
- HRESULT FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, long& len);
+ HRESULT FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, long& len);
- HRESULT DecideBufferSize(IMemAllocator* pIMemAlloc, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT CheckMediaType(const CMediaType* pMediaType);
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
+ HRESULT DecideBufferSize(IMemAllocator* pIMemAlloc, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT CheckMediaType(const CMediaType* pMediaType);
+ HRESULT GetMediaType(int iPosition, CMediaType* pmt);
- void UpdateFromMetadata (void* pBuffer);
- inline CFile* GetFile() {
- return &m_file;
- };
+ void UpdateFromMetadata(void* pBuffer);
+ inline CFile* GetFile() {
+ return &m_file;
+ };
- bool m_bIsEOF;
+ bool m_bIsEOF;
};
diff --git a/src/filters/source/FLICSource/FLICSource.cpp b/src/filters/source/FLICSource/FLICSource.cpp
index 733294321..6ad5407b3 100644
--- a/src/filters/source/FLICSource/FLICSource.cpp
+++ b/src/filters/source/FLICSource/FLICSource.cpp
@@ -28,55 +28,55 @@
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
- {&MEDIATYPE_Video, &MEDIASUBTYPE_RGB32},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_RGB32},
};
const AMOVIESETUP_PIN sudOpPin[] = {
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CFLICSource), FlicSourceName, MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
+ {&__uuidof(CFLICSource), FlicSourceName, MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CFLICSource>, NULL, &sudFilter[0]}
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CFLICSource>, NULL, &sudFilter[0]}
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"),
- _T("0"), _T("4,2,,11AF"));
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"),
+ _T("0"), _T("4,2,,11AF"));
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"),
- _T("1"), _T("4,2,,12AF"));
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"),
+ _T("1"), _T("4,2,,12AF"));
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"),
- _T("Source Filter"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"));
+ SetRegKeyValue(
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"),
+ _T("Source Filter"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"));
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".fli"),
- _T("Source Filter"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"));
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".fli"),
+ _T("Source Filter"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"));
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".flc"),
- _T("Source Filter"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"));
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".flc"),
+ _T("Source Filter"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"));
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".fli"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".flc"));
+ DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".fli"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".flc"));
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -90,7 +90,7 @@ CFilterApp theApp;
//
CFLICSource::CFLICSource(LPUNKNOWN lpunk, HRESULT* phr)
- : CSource(NAME("CFLICSource"), lpunk, __uuidof(this))
+ : CSource(NAME("CFLICSource"), lpunk, __uuidof(this))
{
}
@@ -100,683 +100,683 @@ CFLICSource::~CFLICSource()
STDMETHODIMP CFLICSource::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- QI(IFileSourceFilter)
- QI(IAMFilterMiscFlags)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IFileSourceFilter)
+ QI(IAMFilterMiscFlags)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// IFileSourceFilter
STDMETHODIMP CFLICSource::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
- if (GetPinCount() > 0) {
- return VFW_E_ALREADY_CONNECTED;
- }
+ if (GetPinCount() > 0) {
+ return VFW_E_ALREADY_CONNECTED;
+ }
- HRESULT hr = S_OK;
- if (!(DNew CFLICStream(pszFileName, this, &hr))) {
- return E_OUTOFMEMORY;
- }
+ HRESULT hr = S_OK;
+ if (!(DNew CFLICStream(pszFileName, this, &hr))) {
+ return E_OUTOFMEMORY;
+ }
- if (FAILED(hr)) {
- return hr;
- }
+ if (FAILED(hr)) {
+ return hr;
+ }
- m_fn = pszFileName;
+ m_fn = pszFileName;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CFLICSource::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
{
- if (!ppszFileName) {
- return E_POINTER;
- }
+ if (!ppszFileName) {
+ return E_POINTER;
+ }
- *ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR));
- if (!(*ppszFileName)) {
- return E_OUTOFMEMORY;
- }
+ *ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength() + 1) * sizeof(WCHAR));
+ if (!(*ppszFileName)) {
+ return E_OUTOFMEMORY;
+ }
- wcscpy_s(*ppszFileName, m_fn.GetLength() + 1, m_fn);
+ wcscpy_s(*ppszFileName, m_fn.GetLength() + 1, m_fn);
- return S_OK;
+ return S_OK;
}
// IAMFilterMiscFlags
ULONG CFLICSource::GetMiscFlags()
{
- return AM_FILTER_MISC_FLAGS_IS_SOURCE;
+ return AM_FILTER_MISC_FLAGS_IS_SOURCE;
}
STDMETHODIMP CFLICSource::QueryFilterInfo(FILTER_INFO* pInfo)
{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
- wcscpy_s(pInfo->achName, FlicSourceName);
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
+ CheckPointer(pInfo, E_POINTER);
+ ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
+ wcscpy_s(pInfo->achName, FlicSourceName);
+ pInfo->pGraph = m_pGraph;
+ if (m_pGraph) {
+ m_pGraph->AddRef();
+ }
- return S_OK;
+ return S_OK;
}
// CFLICStream
CFLICStream::CFLICStream(const WCHAR* wfn, CFLICSource* pParent, HRESULT* phr)
- : CSourceStream(NAME("FLICStream"), phr, pParent, L"Output")
- , CSourceSeeking(NAME("FLICStream"), (IPin*)this, phr, &m_cSharedState)
- , m_bDiscontinuity(FALSE), m_bFlushing(FALSE)
-{
- CAutoLock cAutoLock(&m_cSharedState);
-
- CString fn(wfn);
-
- if (!m_flic.Open(fn, CFile::modeRead|CFile::shareDenyNone)) {
- if (phr) *phr = E_FAIL;
- return;
- }
-
- if (m_flic.Read(&m_hdr, sizeof(m_hdr)) != sizeof(m_hdr)
- || (m_hdr.type != 0xAF11 && m_hdr.type != 0xAF12)
- || m_hdr.depth != 8) {
- if (phr) *phr = E_FAIL;
- return;
- }
-
- if (m_hdr.speed == 0) {
- m_hdr.speed = (m_hdr.type == 0xAF11) ? 5 : 67;
- }
- m_AvgTimePerFrame = (m_hdr.type == 0xAF11)
- ? 10000000i64 * m_hdr.speed / 70
- : 10000000i64 * m_hdr.speed / 1000;
-
- // not tested (lack of test files)
- {
- __int64 pos = m_flic.GetPosition();
- FLIC_PREFIX fp;
- if (m_flic.Read(&fp, sizeof(fp)) != sizeof(fp) || fp.type != 0xF100) {
- m_flic.Seek(pos, CFile::begin);
- } else {
- m_flic.Seek(pos + fp.size, CFile::begin);
- }
- }
-
- FLIC_FRAME_ENTRY ffe;
- unsigned int nFrames = 0;
- m_frames.SetCount(m_hdr.frames);
- while (nFrames < m_hdr.frames && m_flic.Read(&ffe.hdr, sizeof(ffe.hdr)) == sizeof(ffe.hdr) && ffe.hdr.type == 0xF1FA) {
-
- ffe.pos = m_flic.GetPosition();
- ffe.fKeyframe = false;
-
- int chunk = 0;
- while (chunk < ffe.hdr.chunks) {
- FLIC_CHUNK fc;
- if (m_flic.Read(&fc, sizeof(fc)) != sizeof(fc)) {
- break;
- }
- ffe.fKeyframe = ffe.fKeyframe
- || fc.type == FLIC_BRUN
- || fc.type == FLIC_BLACK
- || fc.type == FLIC_COPY
- || fc.type == DTA_BRUN
- || fc.type == DTA_COPY
- || fc.type == KEY_IMAGE;
-
- ULONGLONG pos = m_flic.GetPosition() + fc.size - sizeof(fc);
- if (pos < m_flic.GetLength()) {
- m_flic.Seek(pos, CFile::begin);
- } else break;
-
- chunk++;
- }
- if (chunk < ffe.hdr.chunks) {
- break;
- }
-
- ULONGLONG pos = ffe.pos + ffe.hdr.size - sizeof(ffe.hdr);
- if (pos < m_flic.GetLength()) {
- m_flic.Seek(pos, CFile::begin);
- } else break;
-
- m_frames[nFrames] = ffe;
- nFrames++;
- }
- if (nFrames>0) {
- m_frames.SetCount(nFrames); // if the file is incomplete, then truncate the index
- m_frames[0].fKeyframe = true;
- } else {
- if (phr) *phr = E_FAIL;
- return;
- }
-
- m_nLastFrameNum = -1;
- memset(m_pPalette, 0, sizeof(m_pPalette));
- m_nBufferSize = m_hdr.width*m_hdr.height*32>>3;
- if (!m_pFrameBuffer.Allocate(m_nBufferSize)) {
- if (phr) *phr = E_OUTOFMEMORY;
- return;
- }
-
- m_rtDuration = m_rtStop = m_AvgTimePerFrame*nFrames;
-
- if (phr) {
- *phr = m_rtDuration > 0 ? S_OK : E_FAIL;
- }
+ : CSourceStream(NAME("FLICStream"), phr, pParent, L"Output")
+ , CSourceSeeking(NAME("FLICStream"), (IPin*)this, phr, &m_cSharedState)
+ , m_bDiscontinuity(FALSE), m_bFlushing(FALSE)
+{
+ CAutoLock cAutoLock(&m_cSharedState);
+
+ CString fn(wfn);
+
+ if (!m_flic.Open(fn, CFile::modeRead | CFile::shareDenyNone)) {
+ if (phr) { *phr = E_FAIL; }
+ return;
+ }
+
+ if (m_flic.Read(&m_hdr, sizeof(m_hdr)) != sizeof(m_hdr)
+ || (m_hdr.type != 0xAF11 && m_hdr.type != 0xAF12)
+ || m_hdr.depth != 8) {
+ if (phr) { *phr = E_FAIL; }
+ return;
+ }
+
+ if (m_hdr.speed == 0) {
+ m_hdr.speed = (m_hdr.type == 0xAF11) ? 5 : 67;
+ }
+ m_AvgTimePerFrame = (m_hdr.type == 0xAF11)
+ ? 10000000i64 * m_hdr.speed / 70
+ : 10000000i64 * m_hdr.speed / 1000;
+
+ // not tested (lack of test files)
+ {
+ __int64 pos = m_flic.GetPosition();
+ FLIC_PREFIX fp;
+ if (m_flic.Read(&fp, sizeof(fp)) != sizeof(fp) || fp.type != 0xF100) {
+ m_flic.Seek(pos, CFile::begin);
+ } else {
+ m_flic.Seek(pos + fp.size, CFile::begin);
+ }
+ }
+
+ FLIC_FRAME_ENTRY ffe;
+ unsigned int nFrames = 0;
+ m_frames.SetCount(m_hdr.frames);
+ while (nFrames < m_hdr.frames && m_flic.Read(&ffe.hdr, sizeof(ffe.hdr)) == sizeof(ffe.hdr) && ffe.hdr.type == 0xF1FA) {
+
+ ffe.pos = m_flic.GetPosition();
+ ffe.fKeyframe = false;
+
+ int chunk = 0;
+ while (chunk < ffe.hdr.chunks) {
+ FLIC_CHUNK fc;
+ if (m_flic.Read(&fc, sizeof(fc)) != sizeof(fc)) {
+ break;
+ }
+ ffe.fKeyframe = ffe.fKeyframe
+ || fc.type == FLIC_BRUN
+ || fc.type == FLIC_BLACK
+ || fc.type == FLIC_COPY
+ || fc.type == DTA_BRUN
+ || fc.type == DTA_COPY
+ || fc.type == KEY_IMAGE;
+
+ ULONGLONG pos = m_flic.GetPosition() + fc.size - sizeof(fc);
+ if (pos < m_flic.GetLength()) {
+ m_flic.Seek(pos, CFile::begin);
+ } else { break; }
+
+ chunk++;
+ }
+ if (chunk < ffe.hdr.chunks) {
+ break;
+ }
+
+ ULONGLONG pos = ffe.pos + ffe.hdr.size - sizeof(ffe.hdr);
+ if (pos < m_flic.GetLength()) {
+ m_flic.Seek(pos, CFile::begin);
+ } else { break; }
+
+ m_frames[nFrames] = ffe;
+ nFrames++;
+ }
+ if (nFrames > 0) {
+ m_frames.SetCount(nFrames); // if the file is incomplete, then truncate the index
+ m_frames[0].fKeyframe = true;
+ } else {
+ if (phr) { *phr = E_FAIL; }
+ return;
+ }
+
+ m_nLastFrameNum = -1;
+ memset(m_pPalette, 0, sizeof(m_pPalette));
+ m_nBufferSize = m_hdr.width * m_hdr.height * 32 >> 3;
+ if (!m_pFrameBuffer.Allocate(m_nBufferSize)) {
+ if (phr) { *phr = E_OUTOFMEMORY; }
+ return;
+ }
+
+ m_rtDuration = m_rtStop = m_AvgTimePerFrame * nFrames;
+
+ if (phr) {
+ *phr = m_rtDuration > 0 ? S_OK : E_FAIL;
+ }
}
CFLICStream::~CFLICStream()
{
- CAutoLock cAutoLock(&m_cSharedState);
+ CAutoLock cAutoLock(&m_cSharedState);
}
STDMETHODIMP CFLICStream::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return (riid == IID_IMediaSeeking) ? CSourceSeeking::NonDelegatingQueryInterface(riid, ppv) //GetInterface((IMediaSeeking*)this, ppv)
- : CSourceStream::NonDelegatingQueryInterface(riid, ppv);
+ return (riid == IID_IMediaSeeking) ? CSourceSeeking::NonDelegatingQueryInterface(riid, ppv) //GetInterface((IMediaSeeking*)this, ppv)
+ : CSourceStream::NonDelegatingQueryInterface(riid, ppv);
}
void CFLICStream::UpdateFromSeek()
{
- if (ThreadExists()) {
- // next time around the loop, the worker thread will
- // pick up the position change.
- // We need to flush all the existing data - we must do that here
- // as our thread will probably be blocked in GetBuffer otherwise
+ if (ThreadExists()) {
+ // next time around the loop, the worker thread will
+ // pick up the position change.
+ // We need to flush all the existing data - we must do that here
+ // as our thread will probably be blocked in GetBuffer otherwise
- m_bFlushing = TRUE;
+ m_bFlushing = TRUE;
- DeliverBeginFlush();
- // make sure we have stopped pushing
- Stop();
- // complete the flush
- DeliverEndFlush();
+ DeliverBeginFlush();
+ // make sure we have stopped pushing
+ Stop();
+ // complete the flush
+ DeliverEndFlush();
- m_bFlushing = FALSE;
+ m_bFlushing = FALSE;
- // restart
- Run();
- }
+ // restart
+ Run();
+ }
}
HRESULT CFLICStream::SetRate(double dRate)
{
- if (dRate <= 0) {
- return E_INVALIDARG;
- }
+ if (dRate <= 0) {
+ return E_INVALIDARG;
+ }
- {
- CAutoLock lock(CSourceSeeking::m_pLock);
- m_dRateSeeking = dRate;
- }
+ {
+ CAutoLock lock(CSourceSeeking::m_pLock);
+ m_dRateSeeking = dRate;
+ }
- UpdateFromSeek();
+ UpdateFromSeek();
- return S_OK;
+ return S_OK;
}
HRESULT CFLICStream::OnThreadStartPlay()
{
- m_bDiscontinuity = TRUE;
- return DeliverNewSegment(m_rtStart, m_rtStop, m_dRateSeeking);
+ m_bDiscontinuity = TRUE;
+ return DeliverNewSegment(m_rtStart, m_rtStop, m_dRateSeeking);
}
HRESULT CFLICStream::ChangeStart()
{
- {
- CAutoLock lock(CSourceSeeking::m_pLock);
- m_rtSampleTime = 0;
- m_rtPosition = m_rtStart;
- }
+ {
+ CAutoLock lock(CSourceSeeking::m_pLock);
+ m_rtSampleTime = 0;
+ m_rtPosition = m_rtStart;
+ }
- UpdateFromSeek();
+ UpdateFromSeek();
- return S_OK;
+ return S_OK;
}
HRESULT CFLICStream::ChangeStop()
{
- {
- CAutoLock lock(CSourceSeeking::m_pLock);
- if (m_rtPosition < m_rtStop) {
- return S_OK;
- }
- }
+ {
+ CAutoLock lock(CSourceSeeking::m_pLock);
+ if (m_rtPosition < m_rtStop) {
+ return S_OK;
+ }
+ }
- // We're already past the new stop time -- better flush the graph.
- UpdateFromSeek();
+ // We're already past the new stop time -- better flush the graph.
+ UpdateFromSeek();
- return S_OK;
+ return S_OK;
}
HRESULT CFLICStream::OnThreadCreate()
{
- CAutoLock cAutoLockShared(&m_cSharedState);
- m_rtSampleTime = 0;
- m_rtPosition = m_rtStart;
+ CAutoLock cAutoLockShared(&m_cSharedState);
+ m_rtSampleTime = 0;
+ m_rtPosition = m_rtStart;
- return CSourceStream::OnThreadCreate();
+ return CSourceStream::OnThreadCreate();
}
HRESULT CFLICStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties)
{
- // CAutoLock cAutoLock(m_pFilter->pStateLock());
+ // CAutoLock cAutoLock(m_pFilter->pStateLock());
- ASSERT(pAlloc);
- ASSERT(pProperties);
+ ASSERT(pAlloc);
+ ASSERT(pProperties);
- HRESULT hr = NOERROR;
+ HRESULT hr = NOERROR;
- pProperties->cBuffers = 1;
- pProperties->cbBuffer = m_nBufferSize;
+ pProperties->cBuffers = 1;
+ pProperties->cbBuffer = m_nBufferSize;
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
- return hr;
- }
+ ALLOCATOR_PROPERTIES Actual;
+ if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
- if (Actual.cbBuffer < pProperties->cbBuffer) {
- return E_FAIL;
- }
- ASSERT(Actual.cBuffers == pProperties->cBuffers);
+ if (Actual.cbBuffer < pProperties->cbBuffer) {
+ return E_FAIL;
+ }
+ ASSERT(Actual.cBuffers == pProperties->cBuffers);
- return NOERROR;
+ return NOERROR;
}
HRESULT CFLICStream::FillBuffer(IMediaSample* pSample)
{
- HRESULT hr;
+ HRESULT hr;
- {
- CAutoLock cAutoLockShared(&m_cSharedState);
+ {
+ CAutoLock cAutoLockShared(&m_cSharedState);
- if (m_rtPosition >= m_rtStop) {
- return S_FALSE;
- }
+ if (m_rtPosition >= m_rtStop) {
+ return S_FALSE;
+ }
- BYTE* pDataIn = m_pFrameBuffer;
- BYTE* pDataOut = NULL;
- if (!pDataIn || FAILED(hr = pSample->GetPointer(&pDataOut)) || !pDataOut) {
- return S_FALSE;
- }
+ BYTE* pDataIn = m_pFrameBuffer;
+ BYTE* pDataOut = NULL;
+ if (!pDataIn || FAILED(hr = pSample->GetPointer(&pDataOut)) || !pDataOut) {
+ return S_FALSE;
+ }
- AM_MEDIA_TYPE* pmt;
- if (SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
- CMediaType mt(*pmt);
- SetMediaType(&mt);
+ AM_MEDIA_TYPE* pmt;
+ if (SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
+ CMediaType mt(*pmt);
+ SetMediaType(&mt);
- DeleteMediaType(pmt);
- }
+ DeleteMediaType(pmt);
+ }
- int w, h, bpp;
- if (m_mt.formattype == FORMAT_VideoInfo) {
- w = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biWidth;
- h = abs(((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biHeight);
- bpp = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biBitCount;
- } else if (m_mt.formattype == FORMAT_VideoInfo2) {
- w = ((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biWidth;
- h = abs(((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biHeight);
- bpp = ((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biBitCount;
- } else {
- return S_FALSE;
- }
+ int w, h, bpp;
+ if (m_mt.formattype == FORMAT_VideoInfo) {
+ w = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biWidth;
+ h = abs(((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biHeight);
+ bpp = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biBitCount;
+ } else if (m_mt.formattype == FORMAT_VideoInfo2) {
+ w = ((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biWidth;
+ h = abs(((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biHeight);
+ bpp = ((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biBitCount;
+ } else {
+ return S_FALSE;
+ }
- int pitchIn = m_hdr.width;
- int pitchOut = w*bpp>>3;
+ int pitchIn = m_hdr.width;
+ int pitchOut = w * bpp >> 3;
- int nFrame = (int)(m_rtPosition / m_AvgTimePerFrame);
+ int nFrame = (int)(m_rtPosition / m_AvgTimePerFrame);
- {
- SeekToNearestKeyFrame(nFrame);
+ {
+ SeekToNearestKeyFrame(nFrame);
- while (m_nLastFrameNum < nFrame && !m_bFlushing) {
- ExtractFrame(++m_nLastFrameNum);
- }
+ while (m_nLastFrameNum < nFrame && !m_bFlushing) {
+ ExtractFrame(++m_nLastFrameNum);
+ }
- for (int y = 0, p = min(pitchIn, pitchOut);
- y < h;
- y++, pDataIn += pitchIn, pDataOut += pitchOut) {
- BYTE* src = pDataIn;
- BYTE* end = src + p;
- DWORD* dst = (DWORD*)pDataOut;
- while (src < end) {
- *dst++ = m_pPalette[*src++];
- }
- }
- }
+ for (int y = 0, p = min(pitchIn, pitchOut);
+ y < h;
+ y++, pDataIn += pitchIn, pDataOut += pitchOut) {
+ BYTE* src = pDataIn;
+ BYTE* end = src + p;
+ DWORD* dst = (DWORD*)pDataOut;
+ while (src < end) {
+ *dst++ = m_pPalette[*src++];
+ }
+ }
+ }
- pSample->SetActualDataLength(pitchOut*h);
+ pSample->SetActualDataLength(pitchOut * h);
- REFERENCE_TIME rtStart, rtStop;
- // The sample times are modified by the current rate.
- rtStart = static_cast<REFERENCE_TIME>(m_rtSampleTime / m_dRateSeeking);
- rtStop = rtStart + static_cast<int>(m_AvgTimePerFrame / m_dRateSeeking);
- pSample->SetTime(&rtStart, &rtStop);
+ REFERENCE_TIME rtStart, rtStop;
+ // The sample times are modified by the current rate.
+ rtStart = static_cast<REFERENCE_TIME>(m_rtSampleTime / m_dRateSeeking);
+ rtStop = rtStart + static_cast<int>(m_AvgTimePerFrame / m_dRateSeeking);
+ pSample->SetTime(&rtStart, &rtStop);
- m_rtSampleTime += m_AvgTimePerFrame;
- m_rtPosition += m_AvgTimePerFrame;
- }
+ m_rtSampleTime += m_AvgTimePerFrame;
+ m_rtPosition += m_AvgTimePerFrame;
+ }
- pSample->SetSyncPoint(TRUE);
+ pSample->SetSyncPoint(TRUE);
- if (m_bDiscontinuity) {
- pSample->SetDiscontinuity(TRUE);
- m_bDiscontinuity = FALSE;
- }
+ if (m_bDiscontinuity) {
+ pSample->SetDiscontinuity(TRUE);
+ m_bDiscontinuity = FALSE;
+ }
- return S_OK;
+ return S_OK;
}
HRESULT CFLICStream::GetMediaType(int iPosition, CMediaType* pmt)
{
- CAutoLock cAutoLock(m_pFilter->pStateLock());
+ CAutoLock cAutoLock(m_pFilter->pStateLock());
- if (iPosition < 0) {
- return E_INVALIDARG;
- }
- if (iPosition > 0) {
- return VFW_S_NO_MORE_ITEMS;
- }
+ if (iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if (iPosition > 0) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
- pmt->SetType(&MEDIATYPE_Video);
- pmt->SetSubtype(&MEDIASUBTYPE_RGB32);
- pmt->SetFormatType(&FORMAT_VideoInfo);
- pmt->SetTemporalCompression(TRUE);
+ pmt->SetType(&MEDIATYPE_Video);
+ pmt->SetSubtype(&MEDIASUBTYPE_RGB32);
+ pmt->SetFormatType(&FORMAT_VideoInfo);
+ pmt->SetTemporalCompression(TRUE);
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
- memset(vih, 0, sizeof(VIDEOINFOHEADER));
- vih->AvgTimePerFrame = m_AvgTimePerFrame;
- vih->bmiHeader.biSize = sizeof(vih->bmiHeader);
- vih->bmiHeader.biWidth = m_hdr.width;
- vih->bmiHeader.biHeight = -m_hdr.height;
- vih->bmiHeader.biPlanes = 1;
- vih->bmiHeader.biBitCount = 32;
- vih->bmiHeader.biCompression = BI_RGB;
- vih->bmiHeader.biSizeImage = m_nBufferSize;
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
+ memset(vih, 0, sizeof(VIDEOINFOHEADER));
+ vih->AvgTimePerFrame = m_AvgTimePerFrame;
+ vih->bmiHeader.biSize = sizeof(vih->bmiHeader);
+ vih->bmiHeader.biWidth = m_hdr.width;
+ vih->bmiHeader.biHeight = -m_hdr.height;
+ vih->bmiHeader.biPlanes = 1;
+ vih->bmiHeader.biBitCount = 32;
+ vih->bmiHeader.biCompression = BI_RGB;
+ vih->bmiHeader.biSizeImage = m_nBufferSize;
- pmt->SetSampleSize(vih->bmiHeader.biSizeImage);
+ pmt->SetSampleSize(vih->bmiHeader.biSizeImage);
- return NOERROR;
+ return NOERROR;
}
HRESULT CFLICStream::CheckConnect(IPin* pPin)
{
- return CSourceStream::CheckConnect(pPin);
+ return CSourceStream::CheckConnect(pPin);
}
HRESULT CFLICStream::CheckMediaType(const CMediaType* pmt)
{
- if (pmt->majortype == MEDIATYPE_Video
- && pmt->subtype == MEDIASUBTYPE_RGB32
- && pmt->formattype == FORMAT_VideoInfo) {
- return S_OK;
- }
+ if (pmt->majortype == MEDIATYPE_Video
+ && pmt->subtype == MEDIASUBTYPE_RGB32
+ && pmt->formattype == FORMAT_VideoInfo) {
+ return S_OK;
+ }
- return E_INVALIDARG;
+ return E_INVALIDARG;
}
STDMETHODIMP CFLICStream::Notify(IBaseFilter* pSender, Quality q)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
////////
void CFLICStream::SeekToNearestKeyFrame(int nFrame)
{
- if (m_nLastFrameNum == nFrame) {
- return;
- }
+ if (m_nLastFrameNum == nFrame) {
+ return;
+ }
- if (m_nLastFrameNum > nFrame) {
- m_nLastFrameNum = -1;
- }
+ if (m_nLastFrameNum > nFrame) {
+ m_nLastFrameNum = -1;
+ }
- for (int i = m_nLastFrameNum+1, j = min((int)m_frames.GetCount(), nFrame); i < j; i++) {
- FLIC_FRAME_ENTRY& ffe = m_frames[i];
- if (ffe.fKeyframe) {
- m_nLastFrameNum = i-1;
- }
- }
+ for (int i = m_nLastFrameNum + 1, j = min((int)m_frames.GetCount(), nFrame); i < j; i++) {
+ FLIC_FRAME_ENTRY& ffe = m_frames[i];
+ if (ffe.fKeyframe) {
+ m_nLastFrameNum = i - 1;
+ }
+ }
}
void CFLICStream::ExtractFrame(int nFrame)
{
- FLIC_FRAME_ENTRY& ffe = m_frames[nFrame];
-
- bool fNewPalette = false;
- bool fNewFrame = false;
-
- m_flic.Seek(ffe.pos, CFile::begin);
-
- int chunk = 0;
- while (chunk < ffe.hdr.chunks) {
- FLIC_CHUNK fc;
- if (m_flic.Read(&fc, sizeof(fc)) != sizeof(fc)) {
- break;
- }
-
- ULONGLONG next = m_flic.GetPosition() + fc.size - sizeof(fc);
- if (next >= m_flic.GetLength()) {
- break;
- }
-
- switch (fc.type) {
- case FLIC_64_COLOR:
- fNewPalette = _colorchunk(true);
- break;
- case FLIC_256_COLOR:
- fNewPalette = _colorchunk(false);
- break;
- case FLIC_BRUN:
- _brunchunk();
- fNewFrame = true;
- break;
- case FLIC_LC:
- _lcchunk();
- break;
- case FLIC_DELTA:
- _deltachunk();
- break;
- case FLIC_BLACK:
- _blackchunk();
- fNewFrame = true;
- break;
- case FLIC_COPY:
- _copychunk();
- fNewFrame = true;
- break;
- case FLIC_MINI:
- break;
- default:
- break;
- }
-
- m_flic.Seek(next, CFile::begin);
-
- chunk++;
- }
-
- if (chunk < ffe.hdr.chunks) {
- ASSERT(0);
- }
-
- ffe.fKeyframe = (fNewPalette && fNewFrame);
+ FLIC_FRAME_ENTRY& ffe = m_frames[nFrame];
+
+ bool fNewPalette = false;
+ bool fNewFrame = false;
+
+ m_flic.Seek(ffe.pos, CFile::begin);
+
+ int chunk = 0;
+ while (chunk < ffe.hdr.chunks) {
+ FLIC_CHUNK fc;
+ if (m_flic.Read(&fc, sizeof(fc)) != sizeof(fc)) {
+ break;
+ }
+
+ ULONGLONG next = m_flic.GetPosition() + fc.size - sizeof(fc);
+ if (next >= m_flic.GetLength()) {
+ break;
+ }
+
+ switch (fc.type) {
+ case FLIC_64_COLOR:
+ fNewPalette = _colorchunk(true);
+ break;
+ case FLIC_256_COLOR:
+ fNewPalette = _colorchunk(false);
+ break;
+ case FLIC_BRUN:
+ _brunchunk();
+ fNewFrame = true;
+ break;
+ case FLIC_LC:
+ _lcchunk();
+ break;
+ case FLIC_DELTA:
+ _deltachunk();
+ break;
+ case FLIC_BLACK:
+ _blackchunk();
+ fNewFrame = true;
+ break;
+ case FLIC_COPY:
+ _copychunk();
+ fNewFrame = true;
+ break;
+ case FLIC_MINI:
+ break;
+ default:
+ break;
+ }
+
+ m_flic.Seek(next, CFile::begin);
+
+ chunk++;
+ }
+
+ if (chunk < ffe.hdr.chunks) {
+ ASSERT(0);
+ }
+
+ ffe.fKeyframe = (fNewPalette && fNewFrame);
}
void CFLICStream::_blackchunk()
{
- memset(m_pFrameBuffer, 0, m_nBufferSize);
+ memset(m_pFrameBuffer, 0, m_nBufferSize);
}
void CFLICStream::_copychunk()
{
- m_flic.Read(m_pFrameBuffer, m_nBufferSize);
+ m_flic.Read(m_pFrameBuffer, m_nBufferSize);
}
bool CFLICStream::_colorchunk(bool f64)
{
- int nColorsUpdated = 0;
+ int nColorsUpdated = 0;
- BYTE skip = 0;
+ BYTE skip = 0;
- WORD packets;
- m_flic.Read(&packets, sizeof(packets));
+ WORD packets;
+ m_flic.Read(&packets, sizeof(packets));
- while (packets--) {
- BYTE skip2;
- m_flic.Read(&skip2, sizeof(skip2));
- skip += skip2;
+ while (packets--) {
+ BYTE skip2;
+ m_flic.Read(&skip2, sizeof(skip2));
+ skip += skip2;
- BYTE count;
- m_flic.Read(&count, sizeof(count));
+ BYTE count;
+ m_flic.Read(&count, sizeof(count));
- int len = (count == 0 ? (256-skip) : count);
- while (len-- > 0) {
- BYTE r, g, b;
- m_flic.Read(&r, sizeof(r));
- m_flic.Read(&g, sizeof(g));
- m_flic.Read(&b, sizeof(b));
- m_pPalette[skip++] = f64
- ? ((r << 18)&0xff0000) | ((g << 10)&0xff00) | ((b << 2)&0xff)
- : ((r << 16)&0xff0000) | ((g << 8)&0xff00) | ((b << 0)&0xff);
- nColorsUpdated++;
- }
- }
+ int len = (count == 0 ? (256 - skip) : count);
+ while (len-- > 0) {
+ BYTE r, g, b;
+ m_flic.Read(&r, sizeof(r));
+ m_flic.Read(&g, sizeof(g));
+ m_flic.Read(&b, sizeof(b));
+ m_pPalette[skip++] = f64
+ ? ((r << 18) & 0xff0000) | ((g << 10) & 0xff00) | ((b << 2) & 0xff)
+ : ((r << 16) & 0xff0000) | ((g << 8) & 0xff00) | ((b << 0) & 0xff);
+ nColorsUpdated++;
+ }
+ }
- return (nColorsUpdated == 256);
+ return (nColorsUpdated == 256);
}
void CFLICStream::_brunchunk()
{
- BYTE* tmp = m_pFrameBuffer;
+ BYTE* tmp = m_pFrameBuffer;
- int lines = m_hdr.height;
- while (lines--) {
- BYTE packets;
- m_flic.Read(&packets, sizeof(packets));
+ int lines = m_hdr.height;
+ while (lines--) {
+ BYTE packets;
+ m_flic.Read(&packets, sizeof(packets));
- BYTE* ptr = tmp;
+ BYTE* ptr = tmp;
- while (ptr < tmp + m_hdr.width) {
- signed char count;
- m_flic.Read(&count, sizeof(count));
+ while (ptr < tmp + m_hdr.width) {
+ signed char count;
+ m_flic.Read(&count, sizeof(count));
- if (count >= 0) {
- BYTE c;
- m_flic.Read(&c, sizeof(c));
- memset(ptr, c, count);
- ptr += count;
- } else {
- m_flic.Read(ptr, -count);
- ptr += -count;
- }
- }
+ if (count >= 0) {
+ BYTE c;
+ m_flic.Read(&c, sizeof(c));
+ memset(ptr, c, count);
+ ptr += count;
+ } else {
+ m_flic.Read(ptr, -count);
+ ptr += -count;
+ }
+ }
- tmp += m_hdr.width;
- }
+ tmp += m_hdr.width;
+ }
}
void CFLICStream::_lcchunk()
{
- WORD y;
- m_flic.Read(&y, sizeof(y));
+ WORD y;
+ m_flic.Read(&y, sizeof(y));
- BYTE* tmp = &m_pFrameBuffer[y*m_hdr.width];
+ BYTE* tmp = &m_pFrameBuffer[y * m_hdr.width];
- WORD lines;
- m_flic.Read(&lines, sizeof(lines));
+ WORD lines;
+ m_flic.Read(&lines, sizeof(lines));
- while (lines--) {
- BYTE* ptr = tmp;
+ while (lines--) {
+ BYTE* ptr = tmp;
- BYTE packets;
- m_flic.Read(&packets, sizeof(packets));
+ BYTE packets;
+ m_flic.Read(&packets, sizeof(packets));
- while (packets--) {
- BYTE skip;
- m_flic.Read(&skip, sizeof(skip));
+ while (packets--) {
+ BYTE skip;
+ m_flic.Read(&skip, sizeof(skip));
- ptr += skip;
+ ptr += skip;
- signed char count;
- m_flic.Read(&count, sizeof(count));
+ signed char count;
+ m_flic.Read(&count, sizeof(count));
- if (count >= 0) {
- m_flic.Read(ptr, count);
- ptr += count;
- } else {
- BYTE c;
- m_flic.Read(&c, sizeof(c));
- memset(ptr, c, -count);
- ptr += -count;
- }
- }
+ if (count >= 0) {
+ m_flic.Read(ptr, count);
+ ptr += count;
+ } else {
+ BYTE c;
+ m_flic.Read(&c, sizeof(c));
+ memset(ptr, c, -count);
+ ptr += -count;
+ }
+ }
- tmp += m_hdr.width;
- }
+ tmp += m_hdr.width;
+ }
}
void CFLICStream::_deltachunk()
{
- BYTE* tmp = m_pFrameBuffer;
-
- WORD lines;
- m_flic.Read(&lines, sizeof(lines));
-
- while (lines--) {
- signed short packets;
- m_flic.Read(&packets, sizeof(packets));
-
- if (packets < 0) {
- if (packets&0x4000) {
- tmp += -packets * m_hdr.width;
- lines++;
- } else {
- signed char count;
- m_flic.Read(&count, sizeof(count));
- tmp[m_hdr.width-1] = (BYTE)packets;
- }
- } else {
- BYTE* ptr = tmp;
-
- while (packets--) {
- BYTE skip;
- m_flic.Read(&skip, sizeof(skip));
-
- ptr += skip;
-
- signed char count;
- m_flic.Read(&count, sizeof(count));
-
- if (count >= 0) {
- // Fix vulnerability : http://www.team509.com/modules.php?name=News&file=article&sid=38
- if ((count << 1) + (long)(ptr - m_pFrameBuffer) < m_nBufferSize) {
- m_flic.Read(ptr, count << 1);
- } else {
- ASSERT(FALSE);
- }
- ptr += count << 1;
- } else {
- WORD c;
- m_flic.Read(&c, sizeof(c));
- count = -count;
- while (count-- > 0) {
- *ptr++ = c>>8;
- *ptr++ = c&0xff;
- }
- }
- }
-
- tmp += m_hdr.width;
- }
- }
+ BYTE* tmp = m_pFrameBuffer;
+
+ WORD lines;
+ m_flic.Read(&lines, sizeof(lines));
+
+ while (lines--) {
+ signed short packets;
+ m_flic.Read(&packets, sizeof(packets));
+
+ if (packets < 0) {
+ if (packets & 0x4000) {
+ tmp += -packets * m_hdr.width;
+ lines++;
+ } else {
+ signed char count;
+ m_flic.Read(&count, sizeof(count));
+ tmp[m_hdr.width - 1] = (BYTE)packets;
+ }
+ } else {
+ BYTE* ptr = tmp;
+
+ while (packets--) {
+ BYTE skip;
+ m_flic.Read(&skip, sizeof(skip));
+
+ ptr += skip;
+
+ signed char count;
+ m_flic.Read(&count, sizeof(count));
+
+ if (count >= 0) {
+ // Fix vulnerability : http://www.team509.com/modules.php?name=News&file=article&sid=38
+ if ((count << 1) + (long)(ptr - m_pFrameBuffer) < m_nBufferSize) {
+ m_flic.Read(ptr, count << 1);
+ } else {
+ ASSERT(FALSE);
+ }
+ ptr += count << 1;
+ } else {
+ WORD c;
+ m_flic.Read(&c, sizeof(c));
+ count = -count;
+ while (count-- > 0) {
+ *ptr++ = c >> 8;
+ *ptr++ = c & 0xff;
+ }
+ }
+ }
+
+ tmp += m_hdr.width;
+ }
+ }
}
diff --git a/src/filters/source/FLICSource/FLICSource.h b/src/filters/source/FLICSource/FLICSource.h
index bd33f4b61..481d7db13 100644
--- a/src/filters/source/FLICSource/FLICSource.h
+++ b/src/filters/source/FLICSource/FLICSource.h
@@ -29,156 +29,156 @@
#pragma pack(push, 1)
enum {
- FLIC_256_COLOR = 4,
- FLIC_DELTA = 7,
- FLIC_64_COLOR = 11,
- FLIC_LC = 12,
- FLIC_BLACK = 13,
- FLIC_BRUN = 15,
- FLIC_COPY = 16,
- FLIC_MINI = 18,
- DTA_BRUN = 25,
- DTA_COPY = 26,
- KEY_IMAGE = 35,
+ FLIC_256_COLOR = 4,
+ FLIC_DELTA = 7,
+ FLIC_64_COLOR = 11,
+ FLIC_LC = 12,
+ FLIC_BLACK = 13,
+ FLIC_BRUN = 15,
+ FLIC_COPY = 16,
+ FLIC_MINI = 18,
+ DTA_BRUN = 25,
+ DTA_COPY = 26,
+ KEY_IMAGE = 35,
};
// http://www.compuphase.com/flic.htm
struct FLIC {
- DWORD size; // Size of FLIC including this header
- WORD type; // File type 0xAF11, 0xAF12, 0xAF30, 0xAF44, ...
- WORD frames; // Number of frames in first segment
- WORD width; // FLIC width in pixels
- WORD height; // FLIC height in pixels
- WORD depth; // Bits per pixel (usually 8)
- WORD flags; // Set to zero or to three
- DWORD speed; // Delay between frames
- WORD reserved1; // Set to zero
- DWORD created; // Date of FLIC creation (FLC only)
- DWORD creator; // Serial number or compiler id (FLC only)
- DWORD updated; // Date of FLIC update (FLC only)
- DWORD updater; // Serial number (FLC only), see creator
- WORD aspect_dx; // Width of square rectangle (FLC only)
- WORD aspect_dy; // Height of square rectangle (FLC only)
- WORD ext_flags; // EGI: flags for specific EGI extensions
- WORD keyframes; // EGI: key-image frequency
- WORD totalframes; // EGI: total number of frames (segments)
- DWORD req_memory; // EGI: maximum chunk size (uncompressed)
- WORD max_regions; // EGI: max. number of regions in a CHK_REGION chunk
- WORD transp_num; // EGI: number of transparent levels
- BYTE reserved2[24]; // Set to zero
- DWORD oframe1; // Offset to frame 1 (FLC only)
- DWORD oframe2; // Offset to frame 2 (FLC only)
- BYTE reserved3[40]; // Set to zero
+ DWORD size; // Size of FLIC including this header
+ WORD type; // File type 0xAF11, 0xAF12, 0xAF30, 0xAF44, ...
+ WORD frames; // Number of frames in first segment
+ WORD width; // FLIC width in pixels
+ WORD height; // FLIC height in pixels
+ WORD depth; // Bits per pixel (usually 8)
+ WORD flags; // Set to zero or to three
+ DWORD speed; // Delay between frames
+ WORD reserved1; // Set to zero
+ DWORD created; // Date of FLIC creation (FLC only)
+ DWORD creator; // Serial number or compiler id (FLC only)
+ DWORD updated; // Date of FLIC update (FLC only)
+ DWORD updater; // Serial number (FLC only), see creator
+ WORD aspect_dx; // Width of square rectangle (FLC only)
+ WORD aspect_dy; // Height of square rectangle (FLC only)
+ WORD ext_flags; // EGI: flags for specific EGI extensions
+ WORD keyframes; // EGI: key-image frequency
+ WORD totalframes; // EGI: total number of frames (segments)
+ DWORD req_memory; // EGI: maximum chunk size (uncompressed)
+ WORD max_regions; // EGI: max. number of regions in a CHK_REGION chunk
+ WORD transp_num; // EGI: number of transparent levels
+ BYTE reserved2[24]; // Set to zero
+ DWORD oframe1; // Offset to frame 1 (FLC only)
+ DWORD oframe2; // Offset to frame 2 (FLC only)
+ BYTE reserved3[40]; // Set to zero
};
struct FLIC_PREFIX {
- DWORD size; // Size of the chunk, including subchunks
- WORD type; // Chunk type: 0xF100
- WORD chunks; // Number of subchunks
- BYTE reserved[8]; // Reserved, set to 0
+ DWORD size; // Size of the chunk, including subchunks
+ WORD type; // Chunk type: 0xF100
+ WORD chunks; // Number of subchunks
+ BYTE reserved[8]; // Reserved, set to 0
};
struct FLIC_FRAME {
- DWORD size; // Size of the chunk, including subchunks
- WORD type; // Chunk type: 0xF1FA
- WORD chunks; // Number of subchunks
- WORD delay; // Delay in milliseconds
- SHORT reserved; // Always zero
- USHORT width; // Frame width override (if non-zero)
- USHORT height; // Frame height override (if non-zero)
+ DWORD size; // Size of the chunk, including subchunks
+ WORD type; // Chunk type: 0xF1FA
+ WORD chunks; // Number of subchunks
+ WORD delay; // Delay in milliseconds
+ SHORT reserved; // Always zero
+ USHORT width; // Frame width override (if non-zero)
+ USHORT height; // Frame height override (if non-zero)
};
struct FLIC_CHUNK {
- DWORD size; // Bytes in this chunk.
- WORD type; // Type of chunk
+ DWORD size; // Bytes in this chunk.
+ WORD type; // Type of chunk
};
#pragma pack(pop)
struct FLIC_FRAME_ENTRY {
- __int64 pos;
- bool fKeyframe;
- FLIC_FRAME hdr;
+ __int64 pos;
+ bool fKeyframe;
+ FLIC_FRAME hdr;
};
class __declspec(uuid("17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4"))
- CFLICSource
- : public CSource
- , public IFileSourceFilter
- , public IAMFilterMiscFlags
+ CFLICSource
+ : public CSource
+ , public IFileSourceFilter
+ , public IAMFilterMiscFlags
{
- CStringW m_fn;
+ CStringW m_fn;
public:
- CFLICSource(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CFLICSource();
+ CFLICSource(LPUNKNOWN lpunk, HRESULT* phr);
+ virtual ~CFLICSource();
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // IFileSourceFilter
- STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
+ // IFileSourceFilter
+ STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
- // IAMFilterMiscFlags
- STDMETHODIMP_(ULONG) GetMiscFlags();
+ // IAMFilterMiscFlags
+ STDMETHODIMP_(ULONG) GetMiscFlags();
- // CBaseFilter
- STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
+ // CBaseFilter
+ STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
};
class CFLICStream
- : public CSourceStream
- , public CSourceSeeking
+ : public CSourceStream
+ , public CSourceSeeking
{
- CFile m_flic;
- FLIC m_hdr;
- CAtlArray<FLIC_FRAME_ENTRY> m_frames;
+ CFile m_flic;
+ FLIC m_hdr;
+ CAtlArray<FLIC_FRAME_ENTRY> m_frames;
- CCritSec m_cSharedState;
+ CCritSec m_cSharedState;
- REFERENCE_TIME m_AvgTimePerFrame;
- REFERENCE_TIME m_rtSampleTime, m_rtPosition;
+ REFERENCE_TIME m_AvgTimePerFrame;
+ REFERENCE_TIME m_rtSampleTime, m_rtPosition;
- BOOL m_bDiscontinuity, m_bFlushing;
+ BOOL m_bDiscontinuity, m_bFlushing;
- HRESULT OnThreadStartPlay();
- HRESULT OnThreadCreate();
+ HRESULT OnThreadStartPlay();
+ HRESULT OnThreadCreate();
- void UpdateFromSeek();
- STDMETHODIMP SetRate(double dRate);
+ void UpdateFromSeek();
+ STDMETHODIMP SetRate(double dRate);
- HRESULT ChangeStart();
- HRESULT ChangeStop();
- HRESULT ChangeRate() {
- return S_OK;
- }
+ HRESULT ChangeStart();
+ HRESULT ChangeStop();
+ HRESULT ChangeRate() {
+ return S_OK;
+ }
private:
- int m_nLastFrameNum;
- DWORD m_pPalette[256];
- CAutoVectorPtr<BYTE> m_pFrameBuffer;
- int m_nBufferSize;
-
- void SeekToNearestKeyFrame(int nFrame);
- void ExtractFrame(int nFrame);
- void _blackchunk();
- void _copychunk();
- bool _colorchunk(bool f64);
- void _brunchunk();
- void _lcchunk();
- void _deltachunk();
+ int m_nLastFrameNum;
+ DWORD m_pPalette[256];
+ CAutoVectorPtr<BYTE> m_pFrameBuffer;
+ int m_nBufferSize;
+
+ void SeekToNearestKeyFrame(int nFrame);
+ void ExtractFrame(int nFrame);
+ void _blackchunk();
+ void _copychunk();
+ bool _colorchunk(bool f64);
+ void _brunchunk();
+ void _lcchunk();
+ void _deltachunk();
public:
- CFLICStream(const WCHAR* wfn, CFLICSource* pParent, HRESULT* phr);
- virtual ~CFLICStream();
+ CFLICStream(const WCHAR* wfn, CFLICSource* pParent, HRESULT* phr);
+ virtual ~CFLICStream();
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- HRESULT DecideBufferSize(IMemAllocator* pIMemAlloc, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT FillBuffer(IMediaSample* pSample);
- HRESULT CheckConnect(IPin* pPin);
- HRESULT CheckMediaType(const CMediaType* pMediaType);
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
+ HRESULT DecideBufferSize(IMemAllocator* pIMemAlloc, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT FillBuffer(IMediaSample* pSample);
+ HRESULT CheckConnect(IPin* pPin);
+ HRESULT CheckMediaType(const CMediaType* pMediaType);
+ HRESULT GetMediaType(int iPosition, CMediaType* pmt);
- STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
+ STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
};
diff --git a/src/filters/source/ShoutcastSource/ShoutcastSource.cpp b/src/filters/source/ShoutcastSource/ShoutcastSource.cpp
index 4083d06f5..b7d9c6d80 100644
--- a/src/filters/source/ShoutcastSource/ShoutcastSource.cpp
+++ b/src/filters/source/ShoutcastSource/ShoutcastSource.cpp
@@ -36,77 +36,77 @@
#define MAXBUFFERLENGTH 100000000i64
static const DWORD s_bitrate[2][16] = {
- {1,8,16,24,32,40,48,56,64,80,96,112,128,144,160,0},
- {1,32,40,48,56,64,80,96,112,128,160,192,224,256,320,0}
+ {1, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0},
+ {1, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 0}
};
static const DWORD s_freq[4][4] = {
- {11025,12000,8000,0},
- {0,0,0,0},
- {22050,24000,16000,0},
- {44100,48000,32000,0}
+ {11025, 12000, 8000, 0},
+ {0, 0, 0, 0},
+ {22050, 24000, 16000, 0},
+ {44100, 48000, 32000, 0}
};
static const BYTE s_channels[4] = {
- 2,2,2,1 // stereo, joint stereo, dual, mono
+ 2, 2, 2, 1 // stereo, joint stereo, dual, mono
};
typedef struct {
- WORD sync;
- BYTE version;
- BYTE layer;
- DWORD bitrate;
- DWORD freq;
- BYTE channels;
- DWORD framesize;
-
- bool ExtractHeader(CSocket& socket) {
- BYTE buff[4];
- if (4 != socket.Receive(buff, 4, MSG_PEEK)) {
- return false;
- }
-
- sync = (buff[0]<<4)|(buff[1]>>4)|1;
- version = (buff[1]>>3)&3;
- layer = 4 - ((buff[1]>>1)&3);
- bitrate = s_bitrate[version&1][buff[2]>>4]*1000;
- freq = s_freq[version][(buff[2]>>2)&3];
- channels = s_channels[(buff[3]>>6)&3];
- framesize = freq ? ((((version&1)?144:72) * bitrate / freq) + ((buff[2]>>1)&1)) : 0;
-
- return (sync == 0xfff && layer == 3 && bitrate != 0 && freq != 0);
- }
+ WORD sync;
+ BYTE version;
+ BYTE layer;
+ DWORD bitrate;
+ DWORD freq;
+ BYTE channels;
+ DWORD framesize;
+
+ bool ExtractHeader(CSocket& socket) {
+ BYTE buff[4];
+ if (4 != socket.Receive(buff, 4, MSG_PEEK)) {
+ return false;
+ }
+
+ sync = (buff[0] << 4) | (buff[1] >> 4) | 1;
+ version = (buff[1] >> 3) & 3;
+ layer = 4 - ((buff[1] >> 1) & 3);
+ bitrate = s_bitrate[version & 1][buff[2] >> 4] * 1000;
+ freq = s_freq[version][(buff[2] >> 2) & 3];
+ channels = s_channels[(buff[3] >> 6) & 3];
+ framesize = freq ? ((((version & 1) ? 144 : 72) * bitrate / freq) + ((buff[2] >> 1) & 1)) : 0;
+
+ return (sync == 0xfff && layer == 3 && bitrate != 0 && freq != 0);
+ }
} mp3hdr;
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_MP3},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_MP3},
};
const AMOVIESETUP_PIN sudOpPin[] = {
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CShoutcastSource), ShoutcastSourceName, MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
+ {&__uuidof(CShoutcastSource), ShoutcastSourceName, MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CShoutcastSource>, NULL, &sudFilter[0]}
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CShoutcastSource>, NULL, &sudFilter[0]}
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -114,24 +114,24 @@ STDAPI DllUnregisterServer()
class CShoutcastSourceApp : public CFilterApp
{
public:
- BOOL InitInstance() {
- if (!__super::InitInstance()) {
- return FALSE;
- }
- /*
- if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
- {
- AfxMessageBox(_T("AfxWinInit failed!"));
- return FALSE;
- }
- */
- if (!AfxSocketInit(NULL)) {
- AfxMessageBox(_T("AfxSocketInit failed!"));
- return FALSE;
- }
-
- return TRUE;
- }
+ BOOL InitInstance() {
+ if (!__super::InitInstance()) {
+ return FALSE;
+ }
+ /*
+ if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
+ {
+ AfxMessageBox(_T("AfxWinInit failed!"));
+ return FALSE;
+ }
+ */
+ if (!AfxSocketInit(NULL)) {
+ AfxMessageBox(_T("AfxSocketInit failed!"));
+ return FALSE;
+ }
+
+ return TRUE;
+ }
};
CShoutcastSourceApp theApp;
@@ -143,10 +143,10 @@ CShoutcastSourceApp theApp;
//
CShoutcastSource::CShoutcastSource(LPUNKNOWN lpunk, HRESULT* phr)
- : CSource(NAME("CShoutcastSource"), lpunk, __uuidof(this))
+ : CSource(NAME("CShoutcastSource"), lpunk, __uuidof(this))
{
#ifndef REGISTER_FILTER
- AfxSocketInit();
+ AfxSocketInit();
#endif
}
@@ -156,146 +156,146 @@ CShoutcastSource::~CShoutcastSource()
STDMETHODIMP CShoutcastSource::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
-
- return
- QI(IFileSourceFilter)
- QI(IAMFilterMiscFlags)
- QI(IAMOpenProgress)
- QI2(IAMMediaContent)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ CheckPointer(ppv, E_POINTER);
+
+ return
+ QI(IFileSourceFilter)
+ QI(IAMFilterMiscFlags)
+ QI(IAMOpenProgress)
+ QI2(IAMMediaContent)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// IFileSourceFilter
STDMETHODIMP CShoutcastSource::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
- if (GetPinCount() > 0) {
- return VFW_E_ALREADY_CONNECTED;
- }
+ if (GetPinCount() > 0) {
+ return VFW_E_ALREADY_CONNECTED;
+ }
- HRESULT hr = E_OUTOFMEMORY;
+ HRESULT hr = E_OUTOFMEMORY;
- if (!(DNew CShoutcastStream(pszFileName, this, &hr)) || FAILED(hr)) {
- return hr;
- }
+ if (!(DNew CShoutcastStream(pszFileName, this, &hr)) || FAILED(hr)) {
+ return hr;
+ }
- m_fn = pszFileName;
+ m_fn = pszFileName;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CShoutcastSource::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
{
- if (!ppszFileName) {
- return E_POINTER;
- }
+ if (!ppszFileName) {
+ return E_POINTER;
+ }
- *ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR));
- if (!(*ppszFileName)) {
- return E_OUTOFMEMORY;
- }
+ *ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength() + 1) * sizeof(WCHAR));
+ if (!(*ppszFileName)) {
+ return E_OUTOFMEMORY;
+ }
- wcscpy_s(*ppszFileName, m_fn.GetLength() + 1, m_fn);
+ wcscpy_s(*ppszFileName, m_fn.GetLength() + 1, m_fn);
- return S_OK;
+ return S_OK;
}
// IAMFilterMiscFlags
ULONG CShoutcastSource::GetMiscFlags()
{
- return AM_FILTER_MISC_FLAGS_IS_SOURCE;
+ return AM_FILTER_MISC_FLAGS_IS_SOURCE;
}
// IAMOpenProgress
STDMETHODIMP CShoutcastSource::QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent)
{
- if (m_iPins == 1) {
- if (pllTotal) {
- *pllTotal = 100;
- }
- if (pllCurrent) {
- *pllCurrent = (static_cast<CShoutcastStream*>(m_paStreams[0]))->GetBufferFullness();
- }
- return S_OK;
- }
-
- return E_UNEXPECTED;
+ if (m_iPins == 1) {
+ if (pllTotal) {
+ *pllTotal = 100;
+ }
+ if (pllCurrent) {
+ *pllCurrent = (static_cast<CShoutcastStream*>(m_paStreams[0]))->GetBufferFullness();
+ }
+ return S_OK;
+ }
+
+ return E_UNEXPECTED;
}
STDMETHODIMP CShoutcastSource::AbortOperation()
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IAMMediaContent
STDMETHODIMP CShoutcastSource::get_Title(BSTR* pbstrTitle)
{
- CheckPointer(pbstrTitle, E_POINTER);
+ CheckPointer(pbstrTitle, E_POINTER);
- if (m_iPins == 1) {
- *pbstrTitle = (static_cast<CShoutcastStream*>(m_paStreams[0]))->GetTitle().AllocSysString();
- return S_OK;
- }
+ if (m_iPins == 1) {
+ *pbstrTitle = (static_cast<CShoutcastStream*>(m_paStreams[0]))->GetTitle().AllocSysString();
+ return S_OK;
+ }
- return E_UNEXPECTED;
+ return E_UNEXPECTED;
}
STDMETHODIMP CShoutcastSource::QueryFilterInfo(FILTER_INFO* pInfo)
{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
- wcscpy_s(pInfo->achName, ShoutcastSourceName);
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
+ CheckPointer(pInfo, E_POINTER);
+ ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
+ wcscpy_s(pInfo->achName, ShoutcastSourceName);
+ pInfo->pGraph = m_pGraph;
+ if (m_pGraph) {
+ m_pGraph->AddRef();
+ }
+
+ return S_OK;
}
// CShoutcastStream
CShoutcastStream::CShoutcastStream(const WCHAR* wfn, CShoutcastSource* pParent, HRESULT* phr)
- : CSourceStream(NAME("ShoutcastStream"), phr, pParent, L"Output")
- , m_fBuffering(false)
+ : CSourceStream(NAME("ShoutcastStream"), phr, pParent, L"Output")
+ , m_fBuffering(false)
{
- ASSERT(phr);
+ ASSERT(phr);
- *phr = S_OK;
+ *phr = S_OK;
- CString fn(wfn);
- if (fn.Find(_T("://")) < 0) {
- fn = _T("http://") + fn;
- }
+ CString fn(wfn);
+ if (fn.Find(_T("://")) < 0) {
+ fn = _T("http://") + fn;
+ }
- if (!m_url.CrackUrl(fn)) {
- *phr = E_FAIL;
- return;
- }
+ if (!m_url.CrackUrl(fn)) {
+ *phr = E_FAIL;
+ return;
+ }
- if (m_url.GetUrlPathLength() == 0) {
- m_url.SetUrlPath(_T("/"));
- }
+ if (m_url.GetUrlPathLength() == 0) {
+ m_url.SetUrlPath(_T("/"));
+ }
- if (m_url.GetPortNumber() == ATL_URL_INVALID_PORT_NUMBER) {
- m_url.SetPortNumber(ATL_URL_DEFAULT_HTTP_PORT);
- }
+ if (m_url.GetPortNumber() == ATL_URL_INVALID_PORT_NUMBER) {
+ m_url.SetPortNumber(ATL_URL_DEFAULT_HTTP_PORT);
+ }
- if (m_url.GetScheme() != ATL_URL_SCHEME_HTTP) {
- *phr = E_FAIL;
- return;
- }
+ if (m_url.GetScheme() != ATL_URL_SCHEME_HTTP) {
+ *phr = E_FAIL;
+ return;
+ }
- if (!m_socket.Create() || !m_socket.Connect(m_url)) {
- *phr = E_FAIL;
- return;
- }
+ if (!m_socket.Create() || !m_socket.Connect(m_url)) {
+ *phr = E_FAIL;
+ return;
+ }
- m_socket.Close();
+ m_socket.Close();
}
CShoutcastStream::~CShoutcastStream()
@@ -304,420 +304,420 @@ CShoutcastStream::~CShoutcastStream()
void CShoutcastStream::EmptyBuffer()
{
- CAutoLock cAutoLock(&m_queue);
- m_queue.RemoveAll();
+ CAutoLock cAutoLock(&m_queue);
+ m_queue.RemoveAll();
}
LONGLONG CShoutcastStream::GetBufferFullness()
{
- CAutoLock cAutoLock(&m_queue);
- if (!m_fBuffering) {
- return 100;
- }
- if (m_queue.IsEmpty()) {
- return 0;
- }
- LONGLONG ret = 100i64*(m_queue.GetTail().rtStart - m_queue.GetHead().rtStart) / AVGBUFFERLENGTH;
- return min(ret, 100);
+ CAutoLock cAutoLock(&m_queue);
+ if (!m_fBuffering) {
+ return 100;
+ }
+ if (m_queue.IsEmpty()) {
+ return 0;
+ }
+ LONGLONG ret = 100i64 * (m_queue.GetTail().rtStart - m_queue.GetHead().rtStart) / AVGBUFFERLENGTH;
+ return min(ret, 100);
}
CString CShoutcastStream::GetTitle()
{
- CAutoLock cAutoLock(&m_queue);
- return m_title;
+ CAutoLock cAutoLock(&m_queue);
+ return m_title;
}
HRESULT CShoutcastStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties)
{
- ASSERT(pAlloc);
- ASSERT(pProperties);
+ ASSERT(pAlloc);
+ ASSERT(pProperties);
- HRESULT hr = NOERROR;
+ HRESULT hr = NOERROR;
- pProperties->cBuffers = BUFFERS;
- pProperties->cbBuffer = MAXFRAMESIZE;
+ pProperties->cBuffers = BUFFERS;
+ pProperties->cbBuffer = MAXFRAMESIZE;
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
- return hr;
- }
+ ALLOCATOR_PROPERTIES Actual;
+ if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
- if (Actual.cbBuffer < pProperties->cbBuffer) {
- return E_FAIL;
- }
- ASSERT(Actual.cBuffers == pProperties->cBuffers);
+ if (Actual.cbBuffer < pProperties->cbBuffer) {
+ return E_FAIL;
+ }
+ ASSERT(Actual.cBuffers == pProperties->cBuffers);
- return NOERROR;
+ return NOERROR;
}
HRESULT CShoutcastStream::FillBuffer(IMediaSample* pSample)
{
- HRESULT hr;
-
- BYTE* pData = NULL;
- if (FAILED(hr = pSample->GetPointer(&pData)) || !pData) {
- return S_FALSE;
- }
-
- do {
- // do we have to refill our buffer?
- {
- CAutoLock cAutoLock(&m_queue);
- if (!m_queue.IsEmpty() && m_queue.GetHead().rtStart < m_queue.GetTail().rtStart - MINBUFFERLENGTH) {
- break; // nope, that's great
- }
- }
-
- TRACE(_T("START BUFFERING\n"));
- m_fBuffering = true;
-
- for (;;) {
- if (fExitThread) { // playback stopped?
- return S_FALSE;
- }
-
- Sleep(50);
-
- CAutoLock cAutoLock(&m_queue);
- if (!m_queue.IsEmpty() && m_queue.GetHead().rtStart < m_queue.GetTail().rtStart - AVGBUFFERLENGTH) {
- break; // this is enough
- }
- }
-
- pSample->SetDiscontinuity(TRUE);
-
- DeliverBeginFlush();
- DeliverEndFlush();
-
- DeliverNewSegment(0, ~0, 1.0);
-
- TRACE(_T("END BUFFERING\n"));
- m_fBuffering = false;
- } while (false);
-
- {
- CAutoLock cAutoLock(&m_queue);
- ASSERT(!m_queue.IsEmpty());
- if (!m_queue.IsEmpty()) {
- mp3frame f = m_queue.RemoveHead();
- DWORD len = min((DWORD)pSample->GetSize(), f.len);
- memcpy(pData, f.pData, len);
- pSample->SetActualDataLength(len);
- pSample->SetTime(&f.rtStart, &f.rtStop);
- m_title = f.title;
- }
- }
-
- pSample->SetSyncPoint(TRUE);
-
- return S_OK;
+ HRESULT hr;
+
+ BYTE* pData = NULL;
+ if (FAILED(hr = pSample->GetPointer(&pData)) || !pData) {
+ return S_FALSE;
+ }
+
+ do {
+ // do we have to refill our buffer?
+ {
+ CAutoLock cAutoLock(&m_queue);
+ if (!m_queue.IsEmpty() && m_queue.GetHead().rtStart < m_queue.GetTail().rtStart - MINBUFFERLENGTH) {
+ break; // nope, that's great
+ }
+ }
+
+ TRACE(_T("START BUFFERING\n"));
+ m_fBuffering = true;
+
+ for (;;) {
+ if (fExitThread) { // playback stopped?
+ return S_FALSE;
+ }
+
+ Sleep(50);
+
+ CAutoLock cAutoLock(&m_queue);
+ if (!m_queue.IsEmpty() && m_queue.GetHead().rtStart < m_queue.GetTail().rtStart - AVGBUFFERLENGTH) {
+ break; // this is enough
+ }
+ }
+
+ pSample->SetDiscontinuity(TRUE);
+
+ DeliverBeginFlush();
+ DeliverEndFlush();
+
+ DeliverNewSegment(0, ~0, 1.0);
+
+ TRACE(_T("END BUFFERING\n"));
+ m_fBuffering = false;
+ } while (false);
+
+ {
+ CAutoLock cAutoLock(&m_queue);
+ ASSERT(!m_queue.IsEmpty());
+ if (!m_queue.IsEmpty()) {
+ mp3frame f = m_queue.RemoveHead();
+ DWORD len = min((DWORD)pSample->GetSize(), f.len);
+ memcpy(pData, f.pData, len);
+ pSample->SetActualDataLength(len);
+ pSample->SetTime(&f.rtStart, &f.rtStop);
+ m_title = f.title;
+ }
+ }
+
+ pSample->SetSyncPoint(TRUE);
+
+ return S_OK;
}
HRESULT CShoutcastStream::GetMediaType(int iPosition, CMediaType* pmt)
{
- CAutoLock cAutoLock(m_pFilter->pStateLock());
-
- if (iPosition < 0) {
- return E_INVALIDARG;
- }
- if (iPosition > 0) {
- return VFW_S_NO_MORE_ITEMS;
- }
-
- pmt->SetType(&MEDIATYPE_Audio);
- pmt->SetSubtype(&MEDIASUBTYPE_MP3);
- pmt->SetFormatType(&FORMAT_WaveFormatEx);
-
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
- memset(wfe, 0, sizeof(WAVEFORMATEX));
- wfe->wFormatTag = (WORD)MEDIASUBTYPE_MP3.Data1;
- wfe->nChannels = (WORD)m_socket.m_channels;
- wfe->nSamplesPerSec = m_socket.m_freq;
- wfe->nAvgBytesPerSec = m_socket.m_bitrate/8;
- wfe->nBlockAlign = 1;
- wfe->wBitsPerSample = 0;
-
- return NOERROR;
+ CAutoLock cAutoLock(m_pFilter->pStateLock());
+
+ if (iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if (iPosition > 0) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
+
+ pmt->SetType(&MEDIATYPE_Audio);
+ pmt->SetSubtype(&MEDIASUBTYPE_MP3);
+ pmt->SetFormatType(&FORMAT_WaveFormatEx);
+
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
+ memset(wfe, 0, sizeof(WAVEFORMATEX));
+ wfe->wFormatTag = (WORD)MEDIASUBTYPE_MP3.Data1;
+ wfe->nChannels = (WORD)m_socket.m_channels;
+ wfe->nSamplesPerSec = m_socket.m_freq;
+ wfe->nAvgBytesPerSec = m_socket.m_bitrate / 8;
+ wfe->nBlockAlign = 1;
+ wfe->wBitsPerSample = 0;
+
+ return NOERROR;
}
HRESULT CShoutcastStream::CheckMediaType(const CMediaType* pmt)
{
- if (pmt->majortype == MEDIATYPE_Audio
- && pmt->subtype == MEDIASUBTYPE_MP3
- && pmt->formattype == FORMAT_WaveFormatEx) {
- return S_OK;
- }
+ if (pmt->majortype == MEDIATYPE_Audio
+ && pmt->subtype == MEDIASUBTYPE_MP3
+ && pmt->formattype == FORMAT_WaveFormatEx) {
+ return S_OK;
+ }
- return E_INVALIDARG;
+ return E_INVALIDARG;
}
static UINT SocketThreadProc(LPVOID pParam)
{
- return (static_cast<CShoutcastStream*>(pParam))->SocketThreadProc();
+ return (static_cast<CShoutcastStream*>(pParam))->SocketThreadProc();
}
UINT CShoutcastStream::SocketThreadProc()
{
- fExitThread = false;
+ fExitThread = false;
- SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
+ SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
- AfxSocketInit();
+ AfxSocketInit();
- CAutoVectorPtr<BYTE> pData;
- if (!m_socket.Create() || !m_socket.Connect(m_url)
- || !pData.Allocate(max(m_socket.m_metaint, MAXFRAMESIZE))) {
- m_socket.Close();
- return 1;
- }
+ CAutoVectorPtr<BYTE> pData;
+ if (!m_socket.Create() || !m_socket.Connect(m_url)
+ || !pData.Allocate(max(m_socket.m_metaint, MAXFRAMESIZE))) {
+ m_socket.Close();
+ return 1;
+ }
- REFERENCE_TIME m_rtSampleTime = 0;
+ REFERENCE_TIME m_rtSampleTime = 0;
- while (!fExitThread) {
- int len = MAXFRAMESIZE;
- len = m_socket.Receive(pData, len);
- if (len <= 0) {
- break;
- }
+ while (!fExitThread) {
+ int len = MAXFRAMESIZE;
+ len = m_socket.Receive(pData, len);
+ if (len <= 0) {
+ break;
+ }
- mp3frame f(len);
- memcpy(f.pData, pData, len);
- f.rtStop = (f.rtStart = m_rtSampleTime) + (10000000i64 * len * 8/m_socket.m_bitrate);
- m_rtSampleTime = f.rtStop;
- f.title = m_socket.m_title;
- if (f.title.IsEmpty()) {
- f.title = m_socket.m_url;
- }
+ mp3frame f(len);
+ memcpy(f.pData, pData, len);
+ f.rtStop = (f.rtStart = m_rtSampleTime) + (10000000i64 * len * 8 / m_socket.m_bitrate);
+ m_rtSampleTime = f.rtStop;
+ f.title = m_socket.m_title;
+ if (f.title.IsEmpty()) {
+ f.title = m_socket.m_url;
+ }
- CAutoLock cAutoLock(&m_queue);
- m_queue.AddTail(f);
- }
+ CAutoLock cAutoLock(&m_queue);
+ m_queue.AddTail(f);
+ }
- m_socket.Close();
+ m_socket.Close();
- return 0;
+ return 0;
}
HRESULT CShoutcastStream::OnThreadCreate()
{
- EmptyBuffer();
+ EmptyBuffer();
- fExitThread = true;
- m_hSocketThread = AfxBeginThread(::SocketThreadProc, this)->m_hThread;
- while (fExitThread) {
- Sleep(10);
- }
+ fExitThread = true;
+ m_hSocketThread = AfxBeginThread(::SocketThreadProc, this)->m_hThread;
+ while (fExitThread) {
+ Sleep(10);
+ }
- return NOERROR;
+ return NOERROR;
}
HRESULT CShoutcastStream::OnThreadDestroy()
{
- EmptyBuffer();
+ EmptyBuffer();
- fExitThread = true;
- m_socket.CancelBlockingCall();
- WaitForSingleObject(m_hSocketThread, (DWORD)-1);
+ fExitThread = true;
+ m_socket.CancelBlockingCall();
+ WaitForSingleObject(m_hSocketThread, (DWORD) - 1);
- return NOERROR;
+ return NOERROR;
}
HRESULT CShoutcastStream::Inactive()
{
- fExitThread = true;
- return __super::Inactive();
+ fExitThread = true;
+ return __super::Inactive();
}
//
int CShoutcastStream::CShoutcastSocket::Receive(void* lpBuf, int nBufLen, int nFlags)
{
- if (nFlags&MSG_PEEK) {
- return __super::Receive(lpBuf, nBufLen, nFlags);
- }
-
- if (m_metaint > 0 && m_nBytesRead + nBufLen > m_metaint) {
- nBufLen = m_metaint - m_nBytesRead;
- }
-
- int len = __super::Receive(lpBuf, nBufLen, nFlags);
- if (len <= 0) {
- return len;
- }
-
- if ((m_nBytesRead += len) == m_metaint) {
- m_nBytesRead = 0;
-
- static BYTE buff[255*16], b = 0;
- memset(buff, 0, sizeof(buff));
- if (1 == __super::Receive(&b, 1) && b && b*16 == __super::Receive(buff, b*16)) {
- CStringA str = (LPCSTR)buff;
-
- TRACE(_T("Metainfo: %s\n"), CString(str));
-
- CStringA title("StreamTitle='"), url("StreamUrl='");
-
- int i = str.Find(title);
- if (i >= 0) {
- i += title.GetLength();
- int j = str.Find('\'', i);
- if (j > i) {
- m_title = str.Mid(i, j - i);
- }
- } else {
- TRACE(_T("!!!!!!!!!Missing StreamTitle!!!!!!!!!\n"));
- }
-
- i = str.Find(url);
- if (i >= 0) {
- i += url.GetLength();
- int j = str.Find('\'', i);
- if (j > i) {
- m_url = str.Mid(i, j - i);
- }
- }
- }
- } else if (m_metaint > 0) {
- char* p = (char*)lpBuf;
- char* p0 = p;
- char* pend = p + len - 13;
- for (; p < pend; p++) {
- if (strncmp(p, "StreamTitle='", 13)) {
- continue;
- }
-
- TRACE(_T("!!!!!!!!!StreamTitle found inside mp3 data!!!!!!!!! offset=%d\n"), p - p0);
- TRACE(_T("resyncing...\n"));
- while (p-- > p0) {
- if ((BYTE)*p >= 0x20) {
- continue;
- }
-
- TRACE(_T("found possible length byte: %d, skipping %d bytes\n"), *p, 1 + *p*16);
- p += 1 + *p*16;
- len = (int)(p0 + len - p);
- TRACE(_T("returning the remaining bytes in the packet: %d\n"), len);
- if (len <= 0) {
- TRACE(_T("nothing to return, reading a bit more in\n"));
- if (len < 0) {
- __super::Receive(lpBuf, -len, nFlags);
- }
-
- int len = __super::Receive(lpBuf, nBufLen, nFlags);
- if (len <= 0) {
- return len;
- }
- }
-
- m_nBytesRead = len;
- memcpy(lpBuf, p, len);
-
- break;
- }
-
- break;
- }
- }
-
- return len;
+ if (nFlags & MSG_PEEK) {
+ return __super::Receive(lpBuf, nBufLen, nFlags);
+ }
+
+ if (m_metaint > 0 && m_nBytesRead + nBufLen > m_metaint) {
+ nBufLen = m_metaint - m_nBytesRead;
+ }
+
+ int len = __super::Receive(lpBuf, nBufLen, nFlags);
+ if (len <= 0) {
+ return len;
+ }
+
+ if ((m_nBytesRead += len) == m_metaint) {
+ m_nBytesRead = 0;
+
+ static BYTE buff[255 * 16], b = 0;
+ memset(buff, 0, sizeof(buff));
+ if (1 == __super::Receive(&b, 1) && b && b * 16 == __super::Receive(buff, b * 16)) {
+ CStringA str = (LPCSTR)buff;
+
+ TRACE(_T("Metainfo: %s\n"), CString(str));
+
+ CStringA title("StreamTitle='"), url("StreamUrl='");
+
+ int i = str.Find(title);
+ if (i >= 0) {
+ i += title.GetLength();
+ int j = str.Find('\'', i);
+ if (j > i) {
+ m_title = str.Mid(i, j - i);
+ }
+ } else {
+ TRACE(_T("!!!!!!!!!Missing StreamTitle!!!!!!!!!\n"));
+ }
+
+ i = str.Find(url);
+ if (i >= 0) {
+ i += url.GetLength();
+ int j = str.Find('\'', i);
+ if (j > i) {
+ m_url = str.Mid(i, j - i);
+ }
+ }
+ }
+ } else if (m_metaint > 0) {
+ char* p = (char*)lpBuf;
+ char* p0 = p;
+ char* pend = p + len - 13;
+ for (; p < pend; p++) {
+ if (strncmp(p, "StreamTitle='", 13)) {
+ continue;
+ }
+
+ TRACE(_T("!!!!!!!!!StreamTitle found inside mp3 data!!!!!!!!! offset=%d\n"), p - p0);
+ TRACE(_T("resyncing...\n"));
+ while (p-- > p0) {
+ if ((BYTE)*p >= 0x20) {
+ continue;
+ }
+
+ TRACE(_T("found possible length byte: %d, skipping %d bytes\n"), *p, 1 + *p * 16);
+ p += 1 + *p * 16;
+ len = (int)(p0 + len - p);
+ TRACE(_T("returning the remaining bytes in the packet: %d\n"), len);
+ if (len <= 0) {
+ TRACE(_T("nothing to return, reading a bit more in\n"));
+ if (len < 0) {
+ __super::Receive(lpBuf, -len, nFlags);
+ }
+
+ int len = __super::Receive(lpBuf, nBufLen, nFlags);
+ if (len <= 0) {
+ return len;
+ }
+ }
+
+ m_nBytesRead = len;
+ memcpy(lpBuf, p, len);
+
+ break;
+ }
+
+ break;
+ }
+ }
+
+ return len;
}
bool CShoutcastStream::CShoutcastSocket::Connect(CUrl& url)
{
- if (!__super::Connect(url.GetHostName(), url.GetPortNumber())) {
- return false;
- }
-
- CStringA str;
- str.Format(
- "GET %s HTTP/1.0\r\n"
- "Icy-MetaData:1\r\n"
- "User-Agent: shoutcastsource\r\n"
- "Host: %s\r\n"
- "Accept: */*\r\n"
- "Connection: Keep-Alive\r\n"
- "\r\n", CStringA(url.GetUrlPath()), CStringA(url.GetHostName()));
-
- bool fOK = false;
- bool fTryAgain = false;
- int metaint = 0;
-
- do {
- int len = Send((BYTE*)(LPCSTR)str, str.GetLength());
- UNREFERENCED_PARAMETER(len);
-
- m_nBytesRead = 0;
- m_metaint = metaint = 0;
- m_bitrate = 0;
-
- str.Empty();
- BYTE cur = 0, prev = 0;
- while (Receive(&cur, 1) == 1 && cur && !(cur == '\n' && prev == '\n')) {
- if (cur == '\r') {
- continue;
- }
-
- if (cur == '\n') {
- str.MakeLower();
- if (str.Find("icy 200 ok") >= 0) {
- fOK = true;
- } else if (1 == sscanf_s(str, "icy-br:%d", &m_bitrate)) {
- m_bitrate *= 1000;
- } else if (1 == sscanf_s(str, "icy-metaint:%d", &metaint)) {
- metaint = metaint;
- }
- str.Empty();
- } else {
- str += cur;
- }
-
- prev = cur;
- cur = 0;
- }
-
- if (!fOK && GetLastError() == WSAECONNRESET && !fTryAgain) {
- str.Format(
- "GET %s HTTP/1.0\r\n"
- "Icy-MetaData:1\r\n"
- "Host: %s\r\n"
- "Accept: */*\r\n"
- "Connection: Keep-Alive\r\n"
- "\r\n", CStringA(url.GetUrlPath()), CStringA(url.GetHostName()));
-
- fTryAgain = true;
- } else {
- fTryAgain = false;
- }
- } while (fTryAgain);
-
- if (!fOK || m_bitrate == 0) {
- Close();
- return false;
- }
-
- m_metaint = metaint;
- m_nBytesRead = 0;
-
- return FindSync();
+ if (!__super::Connect(url.GetHostName(), url.GetPortNumber())) {
+ return false;
+ }
+
+ CStringA str;
+ str.Format(
+ "GET %s HTTP/1.0\r\n"
+ "Icy-MetaData:1\r\n"
+ "User-Agent: shoutcastsource\r\n"
+ "Host: %s\r\n"
+ "Accept: */*\r\n"
+ "Connection: Keep-Alive\r\n"
+ "\r\n", CStringA(url.GetUrlPath()), CStringA(url.GetHostName()));
+
+ bool fOK = false;
+ bool fTryAgain = false;
+ int metaint = 0;
+
+ do {
+ int len = Send((BYTE*)(LPCSTR)str, str.GetLength());
+ UNREFERENCED_PARAMETER(len);
+
+ m_nBytesRead = 0;
+ m_metaint = metaint = 0;
+ m_bitrate = 0;
+
+ str.Empty();
+ BYTE cur = 0, prev = 0;
+ while (Receive(&cur, 1) == 1 && cur && !(cur == '\n' && prev == '\n')) {
+ if (cur == '\r') {
+ continue;
+ }
+
+ if (cur == '\n') {
+ str.MakeLower();
+ if (str.Find("icy 200 ok") >= 0) {
+ fOK = true;
+ } else if (1 == sscanf_s(str, "icy-br:%d", &m_bitrate)) {
+ m_bitrate *= 1000;
+ } else if (1 == sscanf_s(str, "icy-metaint:%d", &metaint)) {
+ metaint = metaint;
+ }
+ str.Empty();
+ } else {
+ str += cur;
+ }
+
+ prev = cur;
+ cur = 0;
+ }
+
+ if (!fOK && GetLastError() == WSAECONNRESET && !fTryAgain) {
+ str.Format(
+ "GET %s HTTP/1.0\r\n"
+ "Icy-MetaData:1\r\n"
+ "Host: %s\r\n"
+ "Accept: */*\r\n"
+ "Connection: Keep-Alive\r\n"
+ "\r\n", CStringA(url.GetUrlPath()), CStringA(url.GetHostName()));
+
+ fTryAgain = true;
+ } else {
+ fTryAgain = false;
+ }
+ } while (fTryAgain);
+
+ if (!fOK || m_bitrate == 0) {
+ Close();
+ return false;
+ }
+
+ m_metaint = metaint;
+ m_nBytesRead = 0;
+
+ return FindSync();
}
bool CShoutcastStream::CShoutcastSocket::FindSync()
{
- m_freq = (DWORD)-1;
- m_channels = (DWORD)-1;
-
- BYTE b;
- for (int i = MAXFRAMESIZE; i > 0; i--, Receive(&b, 1)) {
- mp3hdr h;
- if (h.ExtractHeader(*this) && m_bitrate == h.bitrate) {
- if (h.bitrate > 1) {
- m_bitrate = h.bitrate;
- }
- m_freq = h.freq;
- m_channels = h.channels;
- return true;
- }
- }
-
- return false;
+ m_freq = (DWORD) - 1;
+ m_channels = (DWORD) - 1;
+
+ BYTE b;
+ for (int i = MAXFRAMESIZE; i > 0; i--, Receive(&b, 1)) {
+ mp3hdr h;
+ if (h.ExtractHeader(*this) && m_bitrate == h.bitrate) {
+ if (h.bitrate > 1) {
+ m_bitrate = h.bitrate;
+ }
+ m_freq = h.freq;
+ m_channels = h.channels;
+ return true;
+ }
+ }
+
+ return false;
}
diff --git a/src/filters/source/ShoutcastSource/ShoutcastSource.h b/src/filters/source/ShoutcastSource/ShoutcastSource.h
index 3848409c0..9b7294957 100644
--- a/src/filters/source/ShoutcastSource/ShoutcastSource.h
+++ b/src/filters/source/ShoutcastSource/ShoutcastSource.h
@@ -32,168 +32,168 @@
#define ShoutcastSourceName L"MPC ShoutCast Source"
class __declspec(uuid("68F540E9-766F-44d2-AB07-E26CC6D27A79"))
- CShoutcastSource
- : public CSource
- , public IFileSourceFilter
- , public IAMFilterMiscFlags
- , public IAMOpenProgress
- , public IAMMediaContent
+ CShoutcastSource
+ : public CSource
+ , public IFileSourceFilter
+ , public IAMFilterMiscFlags
+ , public IAMOpenProgress
+ , public IAMMediaContent
{
- CStringW m_fn;
+ CStringW m_fn;
public:
- CShoutcastSource(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CShoutcastSource();
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // IFileSourceFilter
- STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
-
- // IAMFilterMiscFlags
- STDMETHODIMP_(ULONG) GetMiscFlags();
-
- // IAMOpenProgress
- STDMETHODIMP QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent);
- STDMETHODIMP AbortOperation();
-
- // IAMMediaContent
- STDMETHODIMP GetTypeInfoCount(UINT* pctinfo) {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo) {
- return E_NOTIMPL;
- }
- STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** rgszNames, UINT cNames, LCID lcid, DISPID* rgdispid) {
- return E_NOTIMPL;
- }
- STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult, EXCEPINFO* pexcepinfo, UINT* puArgErr) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_AuthorName(BSTR* pbstrAuthorName) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_Title(BSTR* pbstrTitle);
- STDMETHODIMP get_Rating(BSTR* pbstrRating) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_Description(BSTR* pbstrDescription) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_Copyright(BSTR* pbstrCopyright) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_BaseURL(BSTR* pbstrBaseURL) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_LogoURL(BSTR* pbstrLogoURL) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_LogoIconURL(BSTR* pbstrLogoURL) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_WatermarkURL(BSTR* pbstrWatermarkURL) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_MoreInfoURL(BSTR* pbstrMoreInfoURL) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_MoreInfoBannerImage(BSTR* pbstrMoreInfoBannerImage) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_MoreInfoBannerURL(BSTR* pbstrMoreInfoBannerURL) {
- return E_NOTIMPL;
- }
- STDMETHODIMP get_MoreInfoText(BSTR* pbstrMoreInfoText) {
- return E_NOTIMPL;
- }
-
- // CBaseFilter
- STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
+ CShoutcastSource(LPUNKNOWN lpunk, HRESULT* phr);
+ virtual ~CShoutcastSource();
+
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ // IFileSourceFilter
+ STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
+
+ // IAMFilterMiscFlags
+ STDMETHODIMP_(ULONG) GetMiscFlags();
+
+ // IAMOpenProgress
+ STDMETHODIMP QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent);
+ STDMETHODIMP AbortOperation();
+
+ // IAMMediaContent
+ STDMETHODIMP GetTypeInfoCount(UINT* pctinfo) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** rgszNames, UINT cNames, LCID lcid, DISPID* rgdispid) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult, EXCEPINFO* pexcepinfo, UINT* puArgErr) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_AuthorName(BSTR* pbstrAuthorName) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_Title(BSTR* pbstrTitle);
+ STDMETHODIMP get_Rating(BSTR* pbstrRating) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_Description(BSTR* pbstrDescription) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_Copyright(BSTR* pbstrCopyright) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_BaseURL(BSTR* pbstrBaseURL) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_LogoURL(BSTR* pbstrLogoURL) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_LogoIconURL(BSTR* pbstrLogoURL) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_WatermarkURL(BSTR* pbstrWatermarkURL) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_MoreInfoURL(BSTR* pbstrMoreInfoURL) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_MoreInfoBannerImage(BSTR* pbstrMoreInfoBannerImage) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_MoreInfoBannerURL(BSTR* pbstrMoreInfoBannerURL) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_MoreInfoText(BSTR* pbstrMoreInfoText) {
+ return E_NOTIMPL;
+ }
+
+ // CBaseFilter
+ STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
};
class CShoutcastStream : public CSourceStream
{
- class mp3frame
- {
- public:
- DWORD len;
- BYTE* pData;
- REFERENCE_TIME rtStart, rtStop;
- CString title;
- mp3frame(DWORD len = 0) {
- this->len = len;
- pData = len ? DNew BYTE[len] : NULL;
- rtStart = rtStop = 0;
- }
- mp3frame(const mp3frame& f) {
- *this = f;
- }
- ~mp3frame() {
- delete pData;
- }
- mp3frame& operator = (const mp3frame& f) {
- if (this != &f) {
- len = f.len;
- pData = f.pData;
- rtStart = f.rtStart;
- rtStop = f.rtStop;
- title = f.title;
- ((mp3frame*)&f)->pData = NULL;
- }
- return *this;
- }
- };
-
- class mp3queue : public CAtlList<mp3frame>, public CCritSec {} m_queue;
-
- class CShoutcastSocket : public CSocket
- {
- DWORD m_nBytesRead;
-
- public:
- CShoutcastSocket() {
- m_metaint = m_bitrate = m_freq = m_channels = 0;
- }
- int Receive(void* lpBuf, int nBufLen, int nFlags = 0);
-
- DWORD m_metaint, m_bitrate, m_freq, m_channels;
- CString m_title, m_url;
- bool Connect(CUrl& url);
- bool FindSync();
- } m_socket;
-
- HANDLE m_hSocketThread;
-
- CUrl m_url;
-
- bool m_fBuffering;
- CString m_title;
+ class mp3frame
+ {
+ public:
+ DWORD len;
+ BYTE* pData;
+ REFERENCE_TIME rtStart, rtStop;
+ CString title;
+ mp3frame(DWORD len = 0) {
+ this->len = len;
+ pData = len ? DNew BYTE[len] : NULL;
+ rtStart = rtStop = 0;
+ }
+ mp3frame(const mp3frame& f) {
+ *this = f;
+ }
+ ~mp3frame() {
+ delete pData;
+ }
+ mp3frame& operator = (const mp3frame& f) {
+ if (this != &f) {
+ len = f.len;
+ pData = f.pData;
+ rtStart = f.rtStart;
+ rtStop = f.rtStop;
+ title = f.title;
+ ((mp3frame*)&f)->pData = NULL;
+ }
+ return *this;
+ }
+ };
+
+ class mp3queue : public CAtlList<mp3frame>, public CCritSec {} m_queue;
+
+ class CShoutcastSocket : public CSocket
+ {
+ DWORD m_nBytesRead;
+
+ public:
+ CShoutcastSocket() {
+ m_metaint = m_bitrate = m_freq = m_channels = 0;
+ }
+ int Receive(void* lpBuf, int nBufLen, int nFlags = 0);
+
+ DWORD m_metaint, m_bitrate, m_freq, m_channels;
+ CString m_title, m_url;
+ bool Connect(CUrl& url);
+ bool FindSync();
+ } m_socket;
+
+ HANDLE m_hSocketThread;
+
+ CUrl m_url;
+
+ bool m_fBuffering;
+ CString m_title;
public:
- CShoutcastStream(const WCHAR* wfn, CShoutcastSource* pParent, HRESULT* phr);
- virtual ~CShoutcastStream();
+ CShoutcastStream(const WCHAR* wfn, CShoutcastSource* pParent, HRESULT* phr);
+ virtual ~CShoutcastStream();
- bool fExitThread;
- UINT SocketThreadProc();
+ bool fExitThread;
+ UINT SocketThreadProc();
- void EmptyBuffer();
- LONGLONG GetBufferFullness();
- CString GetTitle();
+ void EmptyBuffer();
+ LONGLONG GetBufferFullness();
+ CString GetTitle();
- HRESULT DecideBufferSize(IMemAllocator* pIMemAlloc, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT FillBuffer(IMediaSample* pSample);
- HRESULT CheckMediaType(const CMediaType* pMediaType);
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
+ HRESULT DecideBufferSize(IMemAllocator* pIMemAlloc, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT FillBuffer(IMediaSample* pSample);
+ HRESULT CheckMediaType(const CMediaType* pMediaType);
+ HRESULT GetMediaType(int iPosition, CMediaType* pmt);
- STDMETHODIMP Notify(IBaseFilter* pSender, Quality q) {
- return E_NOTIMPL;
- }
+ STDMETHODIMP Notify(IBaseFilter* pSender, Quality q) {
+ return E_NOTIMPL;
+ }
- HRESULT OnThreadCreate();
- HRESULT OnThreadDestroy();
- HRESULT Inactive();
- HRESULT Pause();
+ HRESULT OnThreadCreate();
+ HRESULT OnThreadDestroy();
+ HRESULT Inactive();
+ HRESULT Pause();
};
diff --git a/src/filters/source/SubtitleSource/SubtitleSource.cpp b/src/filters/source/SubtitleSource/SubtitleSource.cpp
index 1d7e9acd0..cf6424169 100644
--- a/src/filters/source/SubtitleSource/SubtitleSource.cpp
+++ b/src/filters/source/SubtitleSource/SubtitleSource.cpp
@@ -37,82 +37,82 @@ static int _ATPF = 400000;
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
- {&MEDIATYPE_Subtitle, &MEDIASUBTYPE_NULL},
- {&MEDIATYPE_Text, &MEDIASUBTYPE_NULL},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_RGB32},
+ {&MEDIATYPE_Subtitle, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_Text, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_RGB32},
};
const AMOVIESETUP_PIN sudOpPin[] = {
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut},
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CSubtitleSourceASCII), L"MPC SubtitleSource (S_TEXT/ASCII)", MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CSubtitleSourceUTF8), L"MPC SubtitleSource (S_TEXT/UTF8)", MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CSubtitleSourceSSA), L"MPC SubtitleSource (S_TEXT/SSA)", MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CSubtitleSourceASS), L"MPC SubtitleSource (S_TEXT/ASS)", MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CSubtitleSourceUSF), L"MPC SubtitleSource (S_TEXT/USF)", MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CSubtitleSourcePreview), L"MPC SubtitleSource (Preview)", MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CSubtitleSourceARGB), L"MPC SubtitleSource (ARGB)", MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CSubtitleSourceASCII), L"MPC SubtitleSource (S_TEXT/ASCII)", MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CSubtitleSourceUTF8), L"MPC SubtitleSource (S_TEXT/UTF8)", MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CSubtitleSourceSSA), L"MPC SubtitleSource (S_TEXT/SSA)", MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CSubtitleSourceASS), L"MPC SubtitleSource (S_TEXT/ASS)", MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CSubtitleSourceUSF), L"MPC SubtitleSource (S_TEXT/USF)", MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CSubtitleSourcePreview), L"MPC SubtitleSource (Preview)", MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CSubtitleSourceARGB), L"MPC SubtitleSource (ARGB)", MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CSubtitleSourceASCII>, NULL, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CSubtitleSourceUTF8>, NULL, &sudFilter[1]},
- {sudFilter[2].strName, sudFilter[2].clsID, CreateInstance<CSubtitleSourceSSA>, NULL, &sudFilter[2]},
- {sudFilter[3].strName, sudFilter[3].clsID, CreateInstance<CSubtitleSourceASS>, NULL, &sudFilter[3]},
- // {sudFilter[4].strName, sudFilter[4].clsID, CreateInstance<CSubtitleSourceUSF>, NULL, &sudFilter[4]},
- {sudFilter[5].strName, sudFilter[5].clsID, CreateInstance<CSubtitleSourcePreview>, NULL, &sudFilter[5]},
- {sudFilter[6].strName, sudFilter[6].clsID, CreateInstance<CSubtitleSourceARGB>, NULL, &sudFilter[6]},
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CSubtitleSourceASCII>, NULL, &sudFilter[0]},
+ {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CSubtitleSourceUTF8>, NULL, &sudFilter[1]},
+ {sudFilter[2].strName, sudFilter[2].clsID, CreateInstance<CSubtitleSourceSSA>, NULL, &sudFilter[2]},
+ {sudFilter[3].strName, sudFilter[3].clsID, CreateInstance<CSubtitleSourceASS>, NULL, &sudFilter[3]},
+ // {sudFilter[4].strName, sudFilter[4].clsID, CreateInstance<CSubtitleSourceUSF>, NULL, &sudFilter[4]},
+ {sudFilter[5].strName, sudFilter[5].clsID, CreateInstance<CSubtitleSourcePreview>, NULL, &sudFilter[5]},
+ {sudFilter[6].strName, sudFilter[6].clsID, CreateInstance<CSubtitleSourceARGB>, NULL, &sudFilter[6]},
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- /*CString clsid = CStringFromGUID(__uuidof(CSubtitleSourcePreview));
+ /*CString clsid = CStringFromGUID(__uuidof(CSubtitleSourcePreview));
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".sub"),
- _T("Source Filter"), clsid);
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".sub"),
+ _T("Source Filter"), clsid);
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".srt"),
- _T("Source Filter"), clsid);
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".srt"),
+ _T("Source Filter"), clsid);
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".smi"),
- _T("Source Filter"), clsid);
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".smi"),
+ _T("Source Filter"), clsid);
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".ssa"),
- _T("Source Filter"), clsid);
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".ssa"),
+ _T("Source Filter"), clsid);
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".ass"),
- _T("Source Filter"), clsid);
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".ass"),
+ _T("Source Filter"), clsid);
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".xss"),
- _T("Source Filter"), clsid);
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".xss"),
+ _T("Source Filter"), clsid);
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".usf"),
- _T("Source Filter"), clsid);*/
- return AMovieDllRegisterServer2(TRUE);
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".usf"),
+ _T("Source Filter"), clsid);*/
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".sub"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".srt"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".smi"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".ssa"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".ass"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".xss"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".usf"));
- /**/
- return AMovieDllRegisterServer2(FALSE);
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".sub"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".srt"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".smi"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".ssa"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".ass"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".xss"));
+ DeleteRegKey(_T("Media Type\\Extensions"), _T(".usf"));
+ /**/
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -120,23 +120,23 @@ STDAPI DllUnregisterServer()
class CSubtitleSourceApp : public CFilterApp
{
public:
- BOOL InitInstance() {
- if (!__super::InitInstance()) {
- return FALSE;
- }
-
- _WIDTH = GetProfileInt(_T("SubtitleSource"), _T("w"), 640);
- _HEIGHT = GetProfileInt(_T("SubtitleSource"), _T("h"), 480);
- _ATPF = GetProfileInt(_T("SubtitleSource"), _T("atpf"), 400000);
- if (_ATPF <= 0) {
- _ATPF = 400000;
- }
- WriteProfileInt(_T("SubtitleSource"), _T("w"), _WIDTH);
- WriteProfileInt(_T("SubtitleSource"), _T("h"), _HEIGHT);
- WriteProfileInt(_T("SubtitleSource"), _T("atpf"), _ATPF);
-
- return TRUE;
- }
+ BOOL InitInstance() {
+ if (!__super::InitInstance()) {
+ return FALSE;
+ }
+
+ _WIDTH = GetProfileInt(_T("SubtitleSource"), _T("w"), 640);
+ _HEIGHT = GetProfileInt(_T("SubtitleSource"), _T("h"), 480);
+ _ATPF = GetProfileInt(_T("SubtitleSource"), _T("atpf"), 400000);
+ if (_ATPF <= 0) {
+ _ATPF = 400000;
+ }
+ WriteProfileInt(_T("SubtitleSource"), _T("w"), _WIDTH);
+ WriteProfileInt(_T("SubtitleSource"), _T("h"), _HEIGHT);
+ WriteProfileInt(_T("SubtitleSource"), _T("atpf"), _ATPF);
+
+ return TRUE;
+ }
};
CSubtitleSourceApp theApp;
@@ -148,7 +148,7 @@ CSubtitleSourceApp theApp;
//
CSubtitleSource::CSubtitleSource(LPUNKNOWN lpunk, HRESULT* phr, const CLSID& clsid)
- : CSource(NAME("CSubtitleSource"), lpunk, clsid)
+ : CSource(NAME("CSubtitleSource"), lpunk, clsid)
{
}
@@ -158,70 +158,70 @@ CSubtitleSource::~CSubtitleSource()
STDMETHODIMP CSubtitleSource::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- QI(IFileSourceFilter)
- QI(IAMFilterMiscFlags)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IFileSourceFilter)
+ QI(IAMFilterMiscFlags)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// IFileSourceFilter
STDMETHODIMP CSubtitleSource::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
- if (GetPinCount() > 0) {
- return VFW_E_ALREADY_CONNECTED;
- }
+ if (GetPinCount() > 0) {
+ return VFW_E_ALREADY_CONNECTED;
+ }
- HRESULT hr = S_OK;
- if (!(DNew CSubtitleStream(pszFileName, this, &hr))) {
- return E_OUTOFMEMORY;
- }
+ HRESULT hr = S_OK;
+ if (!(DNew CSubtitleStream(pszFileName, this, &hr))) {
+ return E_OUTOFMEMORY;
+ }
- if (FAILED(hr)) {
- return hr;
- }
+ if (FAILED(hr)) {
+ return hr;
+ }
- m_fn = pszFileName;
+ m_fn = pszFileName;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CSubtitleSource::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
{
- if (!ppszFileName) {
- return E_POINTER;
- }
+ if (!ppszFileName) {
+ return E_POINTER;
+ }
- *ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength() + 1) * sizeof(WCHAR));
- if (!*ppszFileName) {
- return E_OUTOFMEMORY;
- }
+ *ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength() + 1) * sizeof(WCHAR));
+ if (!*ppszFileName) {
+ return E_OUTOFMEMORY;
+ }
- wcscpy_s(*ppszFileName, m_fn.GetLength() + 1, m_fn);
+ wcscpy_s(*ppszFileName, m_fn.GetLength() + 1, m_fn);
- return S_OK;
+ return S_OK;
}
// IAMFilterMiscFlags
ULONG CSubtitleSource::GetMiscFlags()
{
- return AM_FILTER_MISC_FLAGS_IS_SOURCE;
+ return AM_FILTER_MISC_FLAGS_IS_SOURCE;
}
STDMETHODIMP CSubtitleSource::QueryFilterInfo(FILTER_INFO* pInfo)
{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
- wcscpy_s(pInfo->achName, SubtitleSourceName);
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
+ CheckPointer(pInfo, E_POINTER);
+ ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
+ wcscpy_s(pInfo->achName, SubtitleSourceName);
+ pInfo->pGraph = m_pGraph;
+ if (m_pGraph) {
+ m_pGraph->AddRef();
+ }
- return S_OK;
+ return S_OK;
}
//
@@ -229,350 +229,350 @@ STDMETHODIMP CSubtitleSource::QueryFilterInfo(FILTER_INFO* pInfo)
//
CSubtitleStream::CSubtitleStream(const WCHAR* wfn, CSubtitleSource* pParent, HRESULT* phr)
- : CSourceStream(NAME("SubtitleStream"), phr, pParent, L"Output")
- , CSourceSeeking(NAME("SubtitleStream"), (IPin*)this, phr, &m_cSharedState)
- , m_bDiscontinuity(FALSE), m_bFlushing(FALSE)
- , m_nPosition(0)
- , m_rts(NULL)
+ : CSourceStream(NAME("SubtitleStream"), phr, pParent, L"Output")
+ , CSourceSeeking(NAME("SubtitleStream"), (IPin*)this, phr, &m_cSharedState)
+ , m_bDiscontinuity(FALSE), m_bFlushing(FALSE)
+ , m_nPosition(0)
+ , m_rts(NULL)
{
- CAutoLock cAutoLock(&m_cSharedState);
+ CAutoLock cAutoLock(&m_cSharedState);
- CString fn(wfn);
+ CString fn(wfn);
- if (!m_rts.Open(fn, DEFAULT_CHARSET)) {
- if (phr) {
- *phr = E_FAIL;
- }
- return;
- }
+ if (!m_rts.Open(fn, DEFAULT_CHARSET)) {
+ if (phr) {
+ *phr = E_FAIL;
+ }
+ return;
+ }
- m_rts.CreateDefaultStyle(DEFAULT_CHARSET);
- m_rts.ConvertToTimeBased(25);
- m_rts.Sort();
+ m_rts.CreateDefaultStyle(DEFAULT_CHARSET);
+ m_rts.ConvertToTimeBased(25);
+ m_rts.Sort();
- m_rtDuration = 0;
- for (size_t i = 0, cnt = m_rts.GetCount(); i < cnt; i++) {
- m_rtDuration = max(m_rtDuration, 10000i64*m_rts[i].end);
- }
+ m_rtDuration = 0;
+ for (size_t i = 0, cnt = m_rts.GetCount(); i < cnt; i++) {
+ m_rtDuration = max(m_rtDuration, 10000i64 * m_rts[i].end);
+ }
- m_rtStop = m_rtDuration;
+ m_rtStop = m_rtDuration;
- if (phr) {
- *phr = m_rtDuration > 0 ? S_OK : E_FAIL;
- }
+ if (phr) {
+ *phr = m_rtDuration > 0 ? S_OK : E_FAIL;
+ }
}
CSubtitleStream::~CSubtitleStream()
{
- CAutoLock cAutoLock(&m_cSharedState);
+ CAutoLock cAutoLock(&m_cSharedState);
}
STDMETHODIMP CSubtitleStream::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return (riid == IID_IMediaSeeking) ? CSourceSeeking::NonDelegatingQueryInterface(riid, ppv) //GetInterface((IMediaSeeking*)this, ppv)
- : CSourceStream::NonDelegatingQueryInterface(riid, ppv);
+ return (riid == IID_IMediaSeeking) ? CSourceSeeking::NonDelegatingQueryInterface(riid, ppv) //GetInterface((IMediaSeeking*)this, ppv)
+ : CSourceStream::NonDelegatingQueryInterface(riid, ppv);
}
void CSubtitleStream::UpdateFromSeek()
{
- if (ThreadExists()) {
- // next time around the loop, the worker thread will
- // pick up the position change.
- // We need to flush all the existing data - we must do that here
- // as our thread will probably be blocked in GetBuffer otherwise
+ if (ThreadExists()) {
+ // next time around the loop, the worker thread will
+ // pick up the position change.
+ // We need to flush all the existing data - we must do that here
+ // as our thread will probably be blocked in GetBuffer otherwise
- m_bFlushing = TRUE;
+ m_bFlushing = TRUE;
- DeliverBeginFlush();
- // make sure we have stopped pushing
- Stop();
- // complete the flush
- DeliverEndFlush();
+ DeliverBeginFlush();
+ // make sure we have stopped pushing
+ Stop();
+ // complete the flush
+ DeliverEndFlush();
- m_bFlushing = FALSE;
+ m_bFlushing = FALSE;
- // restart
- Run();
- }
+ // restart
+ Run();
+ }
}
HRESULT CSubtitleStream::SetRate(double dRate)
{
- if (dRate <= 0) {
- return E_INVALIDARG;
- }
+ if (dRate <= 0) {
+ return E_INVALIDARG;
+ }
- {
- CAutoLock lock(CSourceSeeking::m_pLock);
- m_dRateSeeking = dRate;
- }
+ {
+ CAutoLock lock(CSourceSeeking::m_pLock);
+ m_dRateSeeking = dRate;
+ }
- UpdateFromSeek();
+ UpdateFromSeek();
- return S_OK;
+ return S_OK;
}
HRESULT CSubtitleStream::OnThreadStartPlay()
{
- m_bDiscontinuity = TRUE;
- return DeliverNewSegment(m_rtStart, m_rtStop, m_dRateSeeking);
+ m_bDiscontinuity = TRUE;
+ return DeliverNewSegment(m_rtStart, m_rtStop, m_dRateSeeking);
}
HRESULT CSubtitleStream::ChangeStart()
{
- {
- CAutoLock lock(CSourceSeeking::m_pLock);
-
- OnThreadCreate();
- /*if (m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_ARGB32)
- {
- m_nPosition = (int)(m_rtStart/10000)*1/1000;
- }
- else if (m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_RGB32)
- {
- int m_nSegments = 0;
- if (!m_rts.SearchSubs((int)(m_rtStart/10000), 25, &m_nPosition, &m_nSegments))
- m_nPosition = m_nSegments;
- }
- else
- {
- m_nPosition = m_rts.SearchSub((int)(m_rtStart/10000), 25);
- if (m_nPosition < 0) m_nPosition = 0;
- else if (m_rts[m_nPosition].end <= (int)(m_rtStart/10000)) m_nPosition++;
- }*/
- }
-
- UpdateFromSeek();
-
- return S_OK;
+ {
+ CAutoLock lock(CSourceSeeking::m_pLock);
+
+ OnThreadCreate();
+ /*if (m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_ARGB32)
+ {
+ m_nPosition = (int)(m_rtStart/10000)*1/1000;
+ }
+ else if (m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_RGB32)
+ {
+ int m_nSegments = 0;
+ if (!m_rts.SearchSubs((int)(m_rtStart/10000), 25, &m_nPosition, &m_nSegments))
+ m_nPosition = m_nSegments;
+ }
+ else
+ {
+ m_nPosition = m_rts.SearchSub((int)(m_rtStart/10000), 25);
+ if (m_nPosition < 0) m_nPosition = 0;
+ else if (m_rts[m_nPosition].end <= (int)(m_rtStart/10000)) m_nPosition++;
+ }*/
+ }
+
+ UpdateFromSeek();
+
+ return S_OK;
}
HRESULT CSubtitleStream::ChangeStop()
{
-/*{
- CAutoLock lock(CSourceSeeking::m_pLock);
- if (m_rtPosition < m_rtStop)
- return S_OK;
-}*/
- // We're already past the new stop time -- better flush the graph.
- UpdateFromSeek();
+ /*{
+ CAutoLock lock(CSourceSeeking::m_pLock);
+ if (m_rtPosition < m_rtStop)
+ return S_OK;
+ }*/
+ // We're already past the new stop time -- better flush the graph.
+ UpdateFromSeek();
- return S_OK;
+ return S_OK;
}
HRESULT CSubtitleStream::OnThreadCreate()
{
- CAutoLock cAutoLockShared(&m_cSharedState);
+ CAutoLock cAutoLockShared(&m_cSharedState);
- if (m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_ARGB32) {
- m_nPosition = (int)(m_rtStart/_ATPF);
- } else if (m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_RGB32) {
- int m_nSegments = 0;
- if (!m_rts.SearchSubs((int)(m_rtStart/10000), 10000000.0/_ATPF, &m_nPosition, &m_nSegments)) {
- m_nPosition = m_nSegments;
- }
- } else {
- m_nPosition = m_rts.SearchSub((int)(m_rtStart/10000), 25);
- if (m_nPosition < 0) {
- m_nPosition = 0;
- } else if (m_rts[m_nPosition].end <= (int)(m_rtStart/10000)) {
- m_nPosition++;
- }
- }
+ if (m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_ARGB32) {
+ m_nPosition = (int)(m_rtStart / _ATPF);
+ } else if (m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_RGB32) {
+ int m_nSegments = 0;
+ if (!m_rts.SearchSubs((int)(m_rtStart / 10000), 10000000.0 / _ATPF, &m_nPosition, &m_nSegments)) {
+ m_nPosition = m_nSegments;
+ }
+ } else {
+ m_nPosition = m_rts.SearchSub((int)(m_rtStart / 10000), 25);
+ if (m_nPosition < 0) {
+ m_nPosition = 0;
+ } else if (m_rts[m_nPosition].end <= (int)(m_rtStart / 10000)) {
+ m_nPosition++;
+ }
+ }
- return CSourceStream::OnThreadCreate();
+ return CSourceStream::OnThreadCreate();
}
HRESULT CSubtitleStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties)
{
- //CAutoLock cAutoLock(m_pFilter->pStateLock());
+ //CAutoLock cAutoLock(m_pFilter->pStateLock());
- ASSERT(pAlloc);
- ASSERT(pProperties);
+ ASSERT(pAlloc);
+ ASSERT(pProperties);
- HRESULT hr = NOERROR;
+ HRESULT hr = NOERROR;
- if (m_mt.majortype == MEDIATYPE_Video) {
- pProperties->cBuffers = 2;
- pProperties->cbBuffer = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biSizeImage;
- } else {
- pProperties->cBuffers = 1;
- pProperties->cbBuffer = 0x10000;
- }
+ if (m_mt.majortype == MEDIATYPE_Video) {
+ pProperties->cBuffers = 2;
+ pProperties->cbBuffer = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biSizeImage;
+ } else {
+ pProperties->cBuffers = 1;
+ pProperties->cbBuffer = 0x10000;
+ }
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
- return hr;
- }
+ ALLOCATOR_PROPERTIES Actual;
+ if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
- if (Actual.cbBuffer < pProperties->cbBuffer) {
- return E_FAIL;
- }
- ASSERT(Actual.cBuffers == pProperties->cBuffers);
+ if (Actual.cbBuffer < pProperties->cbBuffer) {
+ return E_FAIL;
+ }
+ ASSERT(Actual.cBuffers == pProperties->cBuffers);
- return NOERROR;
+ return NOERROR;
}
HRESULT CSubtitleStream::FillBuffer(IMediaSample* pSample)
{
- HRESULT hr;
-
- {
- CAutoLock cAutoLockShared(&m_cSharedState);
-
- BYTE* pData = NULL;
- if (FAILED(hr = pSample->GetPointer(&pData)) || !pData) {
- return S_FALSE;
- }
-
- AM_MEDIA_TYPE* pmt;
- if (SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
- CMediaType mt(*pmt);
- SetMediaType(&mt);
- DeleteMediaType(pmt);
- }
-
- int len = 0;
- REFERENCE_TIME rtStart, rtStop;
-
- if (m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_ARGB32) {
- rtStart = (REFERENCE_TIME)((m_nPosition*_ATPF - m_rtStart) / m_dRateSeeking);
- rtStop = (REFERENCE_TIME)(((m_nPosition+1)*_ATPF - m_rtStart) / m_dRateSeeking);
- if (m_rtStart+rtStart >= m_rtDuration) {
- return S_FALSE;
- }
-
- BITMAPINFOHEADER& bmi = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader;
-
- SubPicDesc spd;
- spd.w = _WIDTH;
- spd.h = _HEIGHT;
- spd.bpp = 32;
- spd.pitch = bmi.biWidth*4;
- spd.bits = pData;
-
- len = spd.h*spd.pitch;
-
- for (int y = 0; y < spd.h; y++) {
- memsetd((DWORD*)(pData + spd.pitch*y), 0xff000000, spd.w*4);
- }
-
- RECT bbox;
- m_rts.Render(spd, m_nPosition*_ATPF, 10000000.0/_ATPF, bbox);
-
- for (int y = 0; y < spd.h; y++) {
- DWORD* p = (DWORD*)(pData + spd.pitch*y);
- for (int x = 0; x < spd.w; x++, p++) {
- *p = (0xff000000-(*p&0xff000000))|(*p&0xffffff);
- }
- }
- } else if (m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_RGB32) {
- const STSSegment* stss = m_rts.GetSegment(m_nPosition);
- if (!stss) {
- return S_FALSE;
- }
-
- BITMAPINFOHEADER& bmi = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader;
-
- SubPicDesc spd;
- spd.w = _WIDTH;
- spd.h = _HEIGHT;
- spd.bpp = 32;
- spd.pitch = bmi.biWidth*4;
- spd.bits = pData;
-
- len = spd.h*spd.pitch;
-
- for (int y = 0; y < spd.h; y++) {
- DWORD c1 = 0xff606060, c2 = 0xffa0a0a0;
- if (y&32) {
- c1 ^= c2, c2 ^= c1, c1 ^= c2;
- }
- DWORD* p = (DWORD*)(pData + spd.pitch*y);
- for (int x = 0; x < spd.w; x+=32, p+=32) {
- memsetd(p, (x&32) ? c1 : c2, min(spd.w-x,32)*4);
- }
- }
-
- RECT bbox;
- m_rts.Render(spd, 10000i64*(stss->start+stss->end)/2, 10000000.0/_ATPF, bbox);
-
- rtStart = (REFERENCE_TIME)((10000i64*stss->start - m_rtStart) / m_dRateSeeking);
- rtStop = (REFERENCE_TIME)((10000i64*stss->end - m_rtStart) / m_dRateSeeking);
- } else {
- if ((size_t)m_nPosition >= m_rts.GetCount()) {
- return S_FALSE;
- }
-
- STSEntry& stse = m_rts[m_nPosition];
-
- if (stse.start >= m_rtStop/10000) {
- return S_FALSE;
- }
-
- if (m_mt.majortype == MEDIATYPE_Subtitle && m_mt.subtype == MEDIASUBTYPE_UTF8) {
- CStringA str = UTF16To8(m_rts.GetStrW(m_nPosition, false));
- memcpy((char*)pData, str, len = str.GetLength());
- } else if (m_mt.majortype == MEDIATYPE_Subtitle && (m_mt.subtype == MEDIASUBTYPE_SSA || m_mt.subtype == MEDIASUBTYPE_ASS)) {
- CStringW line;
- line.Format(L"%d,%d,%s,%s,%d,%d,%d,%s,%s",
- stse.readorder, stse.layer, CStringW(stse.style), CStringW(stse.actor),
- stse.marginRect.left, stse.marginRect.right, (stse.marginRect.top+stse.marginRect.bottom)/2,
- CStringW(stse.effect), m_rts.GetStrW(m_nPosition, true));
-
- CStringA str = UTF16To8(line);
- memcpy((char*)pData, str, len = str.GetLength());
- } else if (m_mt.majortype == MEDIATYPE_Text && m_mt.subtype == MEDIASUBTYPE_NULL) {
- CStringA str = m_rts.GetStrA(m_nPosition, false);
- memcpy((char*)pData, str, len = str.GetLength());
- } else {
- return S_FALSE;
- }
-
- rtStart = (REFERENCE_TIME)((10000i64*stse.start - m_rtStart) / m_dRateSeeking);
- rtStop = (REFERENCE_TIME)((10000i64*stse.end - m_rtStart) / m_dRateSeeking);
- }
-
- pSample->SetTime(&rtStart, &rtStop);
- pSample->SetActualDataLength(len);
-
- m_nPosition++;
- }
-
- pSample->SetSyncPoint(TRUE);
-
- if (m_bDiscontinuity) {
- pSample->SetDiscontinuity(TRUE);
- m_bDiscontinuity = FALSE;
- }
-
- return S_OK;
+ HRESULT hr;
+
+ {
+ CAutoLock cAutoLockShared(&m_cSharedState);
+
+ BYTE* pData = NULL;
+ if (FAILED(hr = pSample->GetPointer(&pData)) || !pData) {
+ return S_FALSE;
+ }
+
+ AM_MEDIA_TYPE* pmt;
+ if (SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
+ CMediaType mt(*pmt);
+ SetMediaType(&mt);
+ DeleteMediaType(pmt);
+ }
+
+ int len = 0;
+ REFERENCE_TIME rtStart, rtStop;
+
+ if (m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_ARGB32) {
+ rtStart = (REFERENCE_TIME)((m_nPosition * _ATPF - m_rtStart) / m_dRateSeeking);
+ rtStop = (REFERENCE_TIME)(((m_nPosition + 1) * _ATPF - m_rtStart) / m_dRateSeeking);
+ if (m_rtStart + rtStart >= m_rtDuration) {
+ return S_FALSE;
+ }
+
+ BITMAPINFOHEADER& bmi = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader;
+
+ SubPicDesc spd;
+ spd.w = _WIDTH;
+ spd.h = _HEIGHT;
+ spd.bpp = 32;
+ spd.pitch = bmi.biWidth * 4;
+ spd.bits = pData;
+
+ len = spd.h * spd.pitch;
+
+ for (int y = 0; y < spd.h; y++) {
+ memsetd((DWORD*)(pData + spd.pitch * y), 0xff000000, spd.w * 4);
+ }
+
+ RECT bbox;
+ m_rts.Render(spd, m_nPosition * _ATPF, 10000000.0 / _ATPF, bbox);
+
+ for (int y = 0; y < spd.h; y++) {
+ DWORD* p = (DWORD*)(pData + spd.pitch * y);
+ for (int x = 0; x < spd.w; x++, p++) {
+ *p = (0xff000000 - (*p & 0xff000000)) | (*p & 0xffffff);
+ }
+ }
+ } else if (m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_RGB32) {
+ const STSSegment* stss = m_rts.GetSegment(m_nPosition);
+ if (!stss) {
+ return S_FALSE;
+ }
+
+ BITMAPINFOHEADER& bmi = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader;
+
+ SubPicDesc spd;
+ spd.w = _WIDTH;
+ spd.h = _HEIGHT;
+ spd.bpp = 32;
+ spd.pitch = bmi.biWidth * 4;
+ spd.bits = pData;
+
+ len = spd.h * spd.pitch;
+
+ for (int y = 0; y < spd.h; y++) {
+ DWORD c1 = 0xff606060, c2 = 0xffa0a0a0;
+ if (y & 32) {
+ c1 ^= c2, c2 ^= c1, c1 ^= c2;
+ }
+ DWORD* p = (DWORD*)(pData + spd.pitch * y);
+ for (int x = 0; x < spd.w; x += 32, p += 32) {
+ memsetd(p, (x & 32) ? c1 : c2, min(spd.w - x, 32) * 4);
+ }
+ }
+
+ RECT bbox;
+ m_rts.Render(spd, 10000i64 * (stss->start + stss->end) / 2, 10000000.0 / _ATPF, bbox);
+
+ rtStart = (REFERENCE_TIME)((10000i64 * stss->start - m_rtStart) / m_dRateSeeking);
+ rtStop = (REFERENCE_TIME)((10000i64 * stss->end - m_rtStart) / m_dRateSeeking);
+ } else {
+ if ((size_t)m_nPosition >= m_rts.GetCount()) {
+ return S_FALSE;
+ }
+
+ STSEntry& stse = m_rts[m_nPosition];
+
+ if (stse.start >= m_rtStop / 10000) {
+ return S_FALSE;
+ }
+
+ if (m_mt.majortype == MEDIATYPE_Subtitle && m_mt.subtype == MEDIASUBTYPE_UTF8) {
+ CStringA str = UTF16To8(m_rts.GetStrW(m_nPosition, false));
+ memcpy((char*)pData, str, len = str.GetLength());
+ } else if (m_mt.majortype == MEDIATYPE_Subtitle && (m_mt.subtype == MEDIASUBTYPE_SSA || m_mt.subtype == MEDIASUBTYPE_ASS)) {
+ CStringW line;
+ line.Format(L"%d,%d,%s,%s,%d,%d,%d,%s,%s",
+ stse.readorder, stse.layer, CStringW(stse.style), CStringW(stse.actor),
+ stse.marginRect.left, stse.marginRect.right, (stse.marginRect.top + stse.marginRect.bottom) / 2,
+ CStringW(stse.effect), m_rts.GetStrW(m_nPosition, true));
+
+ CStringA str = UTF16To8(line);
+ memcpy((char*)pData, str, len = str.GetLength());
+ } else if (m_mt.majortype == MEDIATYPE_Text && m_mt.subtype == MEDIASUBTYPE_NULL) {
+ CStringA str = m_rts.GetStrA(m_nPosition, false);
+ memcpy((char*)pData, str, len = str.GetLength());
+ } else {
+ return S_FALSE;
+ }
+
+ rtStart = (REFERENCE_TIME)((10000i64 * stse.start - m_rtStart) / m_dRateSeeking);
+ rtStop = (REFERENCE_TIME)((10000i64 * stse.end - m_rtStart) / m_dRateSeeking);
+ }
+
+ pSample->SetTime(&rtStart, &rtStop);
+ pSample->SetActualDataLength(len);
+
+ m_nPosition++;
+ }
+
+ pSample->SetSyncPoint(TRUE);
+
+ if (m_bDiscontinuity) {
+ pSample->SetDiscontinuity(TRUE);
+ m_bDiscontinuity = FALSE;
+ }
+
+ return S_OK;
}
HRESULT CSubtitleStream::GetMediaType(CMediaType* pmt)
{
- return (static_cast<CSubtitleSource*>(m_pFilter))->GetMediaType(pmt);
+ return (static_cast<CSubtitleSource*>(m_pFilter))->GetMediaType(pmt);
}
HRESULT CSubtitleStream::CheckMediaType(const CMediaType* pmt)
{
- CAutoLock lock(m_pFilter->pStateLock());
+ CAutoLock lock(m_pFilter->pStateLock());
- CMediaType mt;
- GetMediaType(&mt);
+ CMediaType mt;
+ GetMediaType(&mt);
- if (mt.majortype == pmt->majortype && mt.subtype == pmt->subtype) {
- return NOERROR;
- }
+ if (mt.majortype == pmt->majortype && mt.subtype == pmt->subtype) {
+ return NOERROR;
+ }
- return E_FAIL;
+ return E_FAIL;
}
STDMETHODIMP CSubtitleStream::Notify(IBaseFilter* pSender, Quality q)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
//
@@ -580,21 +580,21 @@ STDMETHODIMP CSubtitleStream::Notify(IBaseFilter* pSender, Quality q)
//
CSubtitleSourceASCII::CSubtitleSourceASCII(LPUNKNOWN lpunk, HRESULT* phr)
- : CSubtitleSource(lpunk, phr, __uuidof(this))
+ : CSubtitleSource(lpunk, phr, __uuidof(this))
{
}
HRESULT CSubtitleSourceASCII::GetMediaType(CMediaType* pmt)
{
- CAutoLock cAutoLock(pStateLock());
+ CAutoLock cAutoLock(pStateLock());
- pmt->InitMediaType();
- pmt->SetType(&MEDIATYPE_Text);
- pmt->SetSubtype(&MEDIASUBTYPE_NULL);
- pmt->SetFormatType(&FORMAT_None);
- pmt->ResetFormatBuffer();
+ pmt->InitMediaType();
+ pmt->SetType(&MEDIATYPE_Text);
+ pmt->SetSubtype(&MEDIASUBTYPE_NULL);
+ pmt->SetFormatType(&FORMAT_None);
+ pmt->ResetFormatBuffer();
- return NOERROR;
+ return NOERROR;
}
//
@@ -602,23 +602,23 @@ HRESULT CSubtitleSourceASCII::GetMediaType(CMediaType* pmt)
//
CSubtitleSourceUTF8::CSubtitleSourceUTF8(LPUNKNOWN lpunk, HRESULT* phr)
- : CSubtitleSource(lpunk, phr, __uuidof(this))
+ : CSubtitleSource(lpunk, phr, __uuidof(this))
{
}
HRESULT CSubtitleSourceUTF8::GetMediaType(CMediaType* pmt)
{
- CAutoLock cAutoLock(pStateLock());
+ CAutoLock cAutoLock(pStateLock());
- pmt->InitMediaType();
- pmt->SetType(&MEDIATYPE_Subtitle);
- pmt->SetSubtype(&MEDIASUBTYPE_UTF8);
- pmt->SetFormatType(&FORMAT_SubtitleInfo);
- SUBTITLEINFO* psi = (SUBTITLEINFO*)pmt->AllocFormatBuffer(sizeof(SUBTITLEINFO));
- memset(psi, 0, pmt->FormatLength());
- strcpy_s(psi->IsoLang, "eng");
+ pmt->InitMediaType();
+ pmt->SetType(&MEDIATYPE_Subtitle);
+ pmt->SetSubtype(&MEDIASUBTYPE_UTF8);
+ pmt->SetFormatType(&FORMAT_SubtitleInfo);
+ SUBTITLEINFO* psi = (SUBTITLEINFO*)pmt->AllocFormatBuffer(sizeof(SUBTITLEINFO));
+ memset(psi, 0, pmt->FormatLength());
+ strcpy_s(psi->IsoLang, "eng");
- return NOERROR;
+ return NOERROR;
}
//
@@ -626,50 +626,50 @@ HRESULT CSubtitleSourceUTF8::GetMediaType(CMediaType* pmt)
//
CSubtitleSourceSSA::CSubtitleSourceSSA(LPUNKNOWN lpunk, HRESULT* phr)
- : CSubtitleSource(lpunk, phr, __uuidof(this))
+ : CSubtitleSource(lpunk, phr, __uuidof(this))
{
}
HRESULT CSubtitleSourceSSA::GetMediaType(CMediaType* pmt)
{
- CAutoLock cAutoLock(pStateLock());
+ CAutoLock cAutoLock(pStateLock());
- pmt->InitMediaType();
- pmt->SetType(&MEDIATYPE_Subtitle);
- pmt->SetSubtype(&MEDIASUBTYPE_SSA);
- pmt->SetFormatType(&FORMAT_SubtitleInfo);
+ pmt->InitMediaType();
+ pmt->SetType(&MEDIATYPE_Subtitle);
+ pmt->SetSubtype(&MEDIASUBTYPE_SSA);
+ pmt->SetFormatType(&FORMAT_SubtitleInfo);
- CSimpleTextSubtitle sts;
- sts.Open(CString(m_fn), DEFAULT_CHARSET);
- sts.RemoveAll();
+ CSimpleTextSubtitle sts;
+ sts.Open(CString(m_fn), DEFAULT_CHARSET);
+ sts.RemoveAll();
- CFile f;
- TCHAR path[_MAX_PATH], fn[_MAX_PATH];
- if (!GetTempPath(_MAX_PATH, path) || !GetTempFileName(path, _T("mpc_sts"), 0, fn)) {
- return E_FAIL;
- }
+ CFile f;
+ TCHAR path[_MAX_PATH], fn[_MAX_PATH];
+ if (!GetTempPath(_MAX_PATH, path) || !GetTempFileName(path, _T("mpc_sts"), 0, fn)) {
+ return E_FAIL;
+ }
- _tremove(fn);
+ _tremove(fn);
- _tcscat_s(fn, _T(".ssa"));
+ _tcscat_s(fn, _T(".ssa"));
- if (!sts.SaveAs(fn, EXTSSA, -1, CTextFile::UTF8) || !f.Open(fn, CFile::modeRead)) {
- return E_FAIL;
- }
+ if (!sts.SaveAs(fn, EXTSSA, -1, CTextFile::UTF8) || !f.Open(fn, CFile::modeRead)) {
+ return E_FAIL;
+ }
- int len = (int)f.GetLength()-3;
- f.Seek(3, CFile::begin);
+ int len = (int)f.GetLength() - 3;
+ f.Seek(3, CFile::begin);
- SUBTITLEINFO* psi = (SUBTITLEINFO*)pmt->AllocFormatBuffer(sizeof(SUBTITLEINFO) + len);
- memset(psi, 0, pmt->FormatLength());
- psi->dwOffset = sizeof(SUBTITLEINFO);
- strcpy_s(psi->IsoLang, "eng");
- f.Read(pmt->pbFormat + psi->dwOffset, len);
- f.Close();
+ SUBTITLEINFO* psi = (SUBTITLEINFO*)pmt->AllocFormatBuffer(sizeof(SUBTITLEINFO) + len);
+ memset(psi, 0, pmt->FormatLength());
+ psi->dwOffset = sizeof(SUBTITLEINFO);
+ strcpy_s(psi->IsoLang, "eng");
+ f.Read(pmt->pbFormat + psi->dwOffset, len);
+ f.Close();
- _tremove(fn);
+ _tremove(fn);
- return NOERROR;
+ return NOERROR;
}
//
@@ -677,49 +677,49 @@ HRESULT CSubtitleSourceSSA::GetMediaType(CMediaType* pmt)
//
CSubtitleSourceASS::CSubtitleSourceASS(LPUNKNOWN lpunk, HRESULT* phr)
- : CSubtitleSource(lpunk, phr, __uuidof(this))
+ : CSubtitleSource(lpunk, phr, __uuidof(this))
{
}
HRESULT CSubtitleSourceASS::GetMediaType(CMediaType* pmt)
{
- CAutoLock cAutoLock(pStateLock());
+ CAutoLock cAutoLock(pStateLock());
- pmt->InitMediaType();
- pmt->SetType(&MEDIATYPE_Subtitle);
- pmt->SetSubtype(&MEDIASUBTYPE_ASS);
- pmt->SetFormatType(&FORMAT_SubtitleInfo);
+ pmt->InitMediaType();
+ pmt->SetType(&MEDIATYPE_Subtitle);
+ pmt->SetSubtype(&MEDIASUBTYPE_ASS);
+ pmt->SetFormatType(&FORMAT_SubtitleInfo);
- CSimpleTextSubtitle sts;
- sts.Open(CString(m_fn), DEFAULT_CHARSET);
- sts.RemoveAll();
+ CSimpleTextSubtitle sts;
+ sts.Open(CString(m_fn), DEFAULT_CHARSET);
+ sts.RemoveAll();
- CFile f;
- TCHAR path[_MAX_PATH], fn[_MAX_PATH];
- if (!GetTempPath(_MAX_PATH, path) || !GetTempFileName(path, _T("mpc_sts"), 0, fn)) {
- return E_FAIL;
- }
+ CFile f;
+ TCHAR path[_MAX_PATH], fn[_MAX_PATH];
+ if (!GetTempPath(_MAX_PATH, path) || !GetTempFileName(path, _T("mpc_sts"), 0, fn)) {
+ return E_FAIL;
+ }
- _tremove(fn);
+ _tremove(fn);
- _tcscat_s(fn, _T(".ass"));
+ _tcscat_s(fn, _T(".ass"));
- if (!sts.SaveAs(fn, EXTASS, -1, CTextFile::UTF8) || !f.Open(fn, CFile::modeRead)) {
- return E_FAIL;
- }
+ if (!sts.SaveAs(fn, EXTASS, -1, CTextFile::UTF8) || !f.Open(fn, CFile::modeRead)) {
+ return E_FAIL;
+ }
- int len = (int)f.GetLength();
+ int len = (int)f.GetLength();
- SUBTITLEINFO* psi = (SUBTITLEINFO*)pmt->AllocFormatBuffer(sizeof(SUBTITLEINFO) + len);
- memset(psi, 0, pmt->FormatLength());
- psi->dwOffset = sizeof(SUBTITLEINFO);
- strcpy_s(psi->IsoLang, "eng");
- f.Read(pmt->pbFormat + psi->dwOffset, len);
- f.Close();
+ SUBTITLEINFO* psi = (SUBTITLEINFO*)pmt->AllocFormatBuffer(sizeof(SUBTITLEINFO) + len);
+ memset(psi, 0, pmt->FormatLength());
+ psi->dwOffset = sizeof(SUBTITLEINFO);
+ strcpy_s(psi->IsoLang, "eng");
+ f.Read(pmt->pbFormat + psi->dwOffset, len);
+ f.Close();
- _tremove(fn);
+ _tremove(fn);
- return NOERROR;
+ return NOERROR;
}
//
@@ -727,24 +727,24 @@ HRESULT CSubtitleSourceASS::GetMediaType(CMediaType* pmt)
//
CSubtitleSourceUSF::CSubtitleSourceUSF(LPUNKNOWN lpunk, HRESULT* phr)
- : CSubtitleSource(lpunk, phr, __uuidof(this))
+ : CSubtitleSource(lpunk, phr, __uuidof(this))
{
}
HRESULT CSubtitleSourceUSF::GetMediaType(CMediaType* pmt)
{
- CAutoLock cAutoLock(pStateLock());
+ CAutoLock cAutoLock(pStateLock());
- pmt->InitMediaType();
- pmt->SetType(&MEDIATYPE_Subtitle);
- pmt->SetSubtype(&MEDIASUBTYPE_USF);
- pmt->SetFormatType(&FORMAT_SubtitleInfo);
- SUBTITLEINFO* psi = (SUBTITLEINFO*)pmt->AllocFormatBuffer(sizeof(SUBTITLEINFO));
- memset(psi, 0, pmt->FormatLength());
- strcpy_s(psi->IsoLang, "eng");
- // TODO: ...
+ pmt->InitMediaType();
+ pmt->SetType(&MEDIATYPE_Subtitle);
+ pmt->SetSubtype(&MEDIASUBTYPE_USF);
+ pmt->SetFormatType(&FORMAT_SubtitleInfo);
+ SUBTITLEINFO* psi = (SUBTITLEINFO*)pmt->AllocFormatBuffer(sizeof(SUBTITLEINFO));
+ memset(psi, 0, pmt->FormatLength());
+ strcpy_s(psi->IsoLang, "eng");
+ // TODO: ...
- return NOERROR;
+ return NOERROR;
}
//
@@ -752,29 +752,29 @@ HRESULT CSubtitleSourceUSF::GetMediaType(CMediaType* pmt)
//
CSubtitleSourcePreview::CSubtitleSourcePreview(LPUNKNOWN lpunk, HRESULT* phr)
- : CSubtitleSource(lpunk, phr, __uuidof(this))
+ : CSubtitleSource(lpunk, phr, __uuidof(this))
{
}
HRESULT CSubtitleSourcePreview::GetMediaType(CMediaType* pmt)
{
- CAutoLock cAutoLock(pStateLock());
+ CAutoLock cAutoLock(pStateLock());
- pmt->InitMediaType();
- pmt->SetType(&MEDIATYPE_Video);
- pmt->SetSubtype(&MEDIASUBTYPE_RGB32);
- pmt->SetFormatType(&FORMAT_VideoInfo);
- VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
- memset(pvih, 0, pmt->FormatLength());
- pvih->bmiHeader.biSize = sizeof(pvih->bmiHeader);
- pvih->bmiHeader.biWidth = _WIDTH;
- pvih->bmiHeader.biHeight = _HEIGHT;
- pvih->bmiHeader.biBitCount = 32;
- pvih->bmiHeader.biCompression = BI_RGB;
- pvih->bmiHeader.biPlanes = 1;
- pvih->bmiHeader.biSizeImage = pvih->bmiHeader.biWidth*abs(pvih->bmiHeader.biHeight)*pvih->bmiHeader.biBitCount>>3;
+ pmt->InitMediaType();
+ pmt->SetType(&MEDIATYPE_Video);
+ pmt->SetSubtype(&MEDIASUBTYPE_RGB32);
+ pmt->SetFormatType(&FORMAT_VideoInfo);
+ VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
+ memset(pvih, 0, pmt->FormatLength());
+ pvih->bmiHeader.biSize = sizeof(pvih->bmiHeader);
+ pvih->bmiHeader.biWidth = _WIDTH;
+ pvih->bmiHeader.biHeight = _HEIGHT;
+ pvih->bmiHeader.biBitCount = 32;
+ pvih->bmiHeader.biCompression = BI_RGB;
+ pvih->bmiHeader.biPlanes = 1;
+ pvih->bmiHeader.biSizeImage = pvih->bmiHeader.biWidth * abs(pvih->bmiHeader.biHeight) * pvih->bmiHeader.biBitCount >> 3;
- return NOERROR;
+ return NOERROR;
}
//
@@ -782,28 +782,28 @@ HRESULT CSubtitleSourcePreview::GetMediaType(CMediaType* pmt)
//
CSubtitleSourceARGB::CSubtitleSourceARGB(LPUNKNOWN lpunk, HRESULT* phr)
- : CSubtitleSource(lpunk, phr, __uuidof(this))
+ : CSubtitleSource(lpunk, phr, __uuidof(this))
{
}
HRESULT CSubtitleSourceARGB::GetMediaType(CMediaType* pmt)
{
- CAutoLock cAutoLock(pStateLock());
-
- pmt->InitMediaType();
- pmt->SetType(&MEDIATYPE_Video);
- pmt->SetSubtype(&MEDIASUBTYPE_ARGB32);
- pmt->SetFormatType(&FORMAT_VideoInfo);
- VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
- memset(pvih, 0, pmt->FormatLength());
- pvih->bmiHeader.biSize = sizeof(pvih->bmiHeader);
- // TODO: read w,h,fps from a config file or registry
- pvih->bmiHeader.biWidth = _WIDTH;
- pvih->bmiHeader.biHeight = _HEIGHT;
- pvih->bmiHeader.biBitCount = 32;
- pvih->bmiHeader.biCompression = BI_RGB;
- pvih->bmiHeader.biPlanes = 1;
- pvih->bmiHeader.biSizeImage = pvih->bmiHeader.biWidth*abs(pvih->bmiHeader.biHeight)*pvih->bmiHeader.biBitCount>>3;
-
- return NOERROR;
+ CAutoLock cAutoLock(pStateLock());
+
+ pmt->InitMediaType();
+ pmt->SetType(&MEDIATYPE_Video);
+ pmt->SetSubtype(&MEDIASUBTYPE_ARGB32);
+ pmt->SetFormatType(&FORMAT_VideoInfo);
+ VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
+ memset(pvih, 0, pmt->FormatLength());
+ pvih->bmiHeader.biSize = sizeof(pvih->bmiHeader);
+ // TODO: read w,h,fps from a config file or registry
+ pvih->bmiHeader.biWidth = _WIDTH;
+ pvih->bmiHeader.biHeight = _HEIGHT;
+ pvih->bmiHeader.biBitCount = 32;
+ pvih->bmiHeader.biCompression = BI_RGB;
+ pvih->bmiHeader.biPlanes = 1;
+ pvih->bmiHeader.biSizeImage = pvih->bmiHeader.biWidth * abs(pvih->bmiHeader.biHeight) * pvih->bmiHeader.biBitCount >> 3;
+
+ return NOERROR;
}
diff --git a/src/filters/source/SubtitleSource/SubtitleSource.h b/src/filters/source/SubtitleSource/SubtitleSource.h
index 747e8c8d6..9f42d933a 100644
--- a/src/filters/source/SubtitleSource/SubtitleSource.h
+++ b/src/filters/source/SubtitleSource/SubtitleSource.h
@@ -29,131 +29,131 @@
#define SubtitleSourceName L"MPC Subtitle Source"
class CSubtitleSource
- : public CSource
- , public IFileSourceFilter
- , public IAMFilterMiscFlags
+ : public CSource
+ , public IFileSourceFilter
+ , public IAMFilterMiscFlags
{
protected:
- CStringW m_fn;
+ CStringW m_fn;
public:
- CSubtitleSource(LPUNKNOWN lpunk, HRESULT* phr, const CLSID& clsid);
- virtual ~CSubtitleSource();
+ CSubtitleSource(LPUNKNOWN lpunk, HRESULT* phr, const CLSID& clsid);
+ virtual ~CSubtitleSource();
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // IFileSourceFilter
- STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
+ // IFileSourceFilter
+ STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
- // IAMFilterMiscFlags
- STDMETHODIMP_(ULONG) GetMiscFlags();
+ // IAMFilterMiscFlags
+ STDMETHODIMP_(ULONG) GetMiscFlags();
- virtual HRESULT GetMediaType(CMediaType* pmt) = 0;
+ virtual HRESULT GetMediaType(CMediaType* pmt) = 0;
- // CBaseFilter
- STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
+ // CBaseFilter
+ STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
};
class CSubtitleStream
- : public CSourceStream
- , public CSourceSeeking
+ : public CSourceStream
+ , public CSourceSeeking
{
- CCritSec m_cSharedState;
+ CCritSec m_cSharedState;
- int m_nPosition;
+ int m_nPosition;
- BOOL m_bDiscontinuity, m_bFlushing;
+ BOOL m_bDiscontinuity, m_bFlushing;
- HRESULT OnThreadStartPlay();
- HRESULT OnThreadCreate();
+ HRESULT OnThreadStartPlay();
+ HRESULT OnThreadCreate();
- void UpdateFromSeek();
- STDMETHODIMP SetRate(double dRate);
+ void UpdateFromSeek();
+ STDMETHODIMP SetRate(double dRate);
- HRESULT ChangeStart();
- HRESULT ChangeStop();
- HRESULT ChangeRate() {
- return S_OK;
- }
+ HRESULT ChangeStart();
+ HRESULT ChangeStop();
+ HRESULT ChangeRate() {
+ return S_OK;
+ }
protected:
- CRenderedTextSubtitle m_rts;
+ CRenderedTextSubtitle m_rts;
public:
- CSubtitleStream(const WCHAR* wfn, CSubtitleSource* pParent, HRESULT* phr);
- virtual ~CSubtitleStream();
+ CSubtitleStream(const WCHAR* wfn, CSubtitleSource* pParent, HRESULT* phr);
+ virtual ~CSubtitleStream();
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- HRESULT DecideBufferSize(IMemAllocator* pIMemAlloc, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT FillBuffer(IMediaSample* pSample);
- HRESULT GetMediaType(CMediaType* pmt);
- HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT DecideBufferSize(IMemAllocator* pIMemAlloc, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT FillBuffer(IMediaSample* pSample);
+ HRESULT GetMediaType(CMediaType* pmt);
+ HRESULT CheckMediaType(const CMediaType* pmt);
- STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
+ STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
};
class __declspec(uuid("E44CA3B5-A0FF-41A0-AF16-42429B1095EA"))
- CSubtitleSourceASCII : public CSubtitleSource
+ CSubtitleSourceASCII : public CSubtitleSource
{
public:
- CSubtitleSourceASCII(LPUNKNOWN lpunk, HRESULT* phr);
+ CSubtitleSourceASCII(LPUNKNOWN lpunk, HRESULT* phr);
- HRESULT GetMediaType(CMediaType* pmt);
+ HRESULT GetMediaType(CMediaType* pmt);
};
class __declspec(uuid("87864E0F-7073-4E39-B802-143DE0ED4964"))
- CSubtitleSourceUTF8 : public CSubtitleSource
+ CSubtitleSourceUTF8 : public CSubtitleSource
{
public:
- CSubtitleSourceUTF8(LPUNKNOWN lpunk, HRESULT* phr);
+ CSubtitleSourceUTF8(LPUNKNOWN lpunk, HRESULT* phr);
- HRESULT GetMediaType(CMediaType* pmt);
+ HRESULT GetMediaType(CMediaType* pmt);
};
class __declspec(uuid("18316B1A-5877-4CC4-85FD-EDE65CD489EC"))
- CSubtitleSourceSSA : public CSubtitleSource
+ CSubtitleSourceSSA : public CSubtitleSource
{
public:
- CSubtitleSourceSSA(LPUNKNOWN lpunk, HRESULT* phr);
+ CSubtitleSourceSSA(LPUNKNOWN lpunk, HRESULT* phr);
- HRESULT GetMediaType(CMediaType* pmt);
+ HRESULT GetMediaType(CMediaType* pmt);
};
class __declspec(uuid("416782BC-1D87-48C0-8F65-F113A5CB8E15"))
- CSubtitleSourceASS : public CSubtitleSource
+ CSubtitleSourceASS : public CSubtitleSource
{
public:
- CSubtitleSourceASS(LPUNKNOWN lpunk, HRESULT* phr);
+ CSubtitleSourceASS(LPUNKNOWN lpunk, HRESULT* phr);
- HRESULT GetMediaType(CMediaType* pmt);
+ HRESULT GetMediaType(CMediaType* pmt);
};
class __declspec(uuid("D7215AFC-DFE6-483B-9AF3-6BBECFF14CF4"))
- CSubtitleSourceUSF : public CSubtitleSource
+ CSubtitleSourceUSF : public CSubtitleSource
{
public:
- CSubtitleSourceUSF(LPUNKNOWN lpunk, HRESULT* phr);
+ CSubtitleSourceUSF(LPUNKNOWN lpunk, HRESULT* phr);
- HRESULT GetMediaType(CMediaType* pmt);
+ HRESULT GetMediaType(CMediaType* pmt);
};
class __declspec(uuid("932E75D4-BBD4-4A0F-9071-6728FBDC4C98"))
- CSubtitleSourcePreview : public CSubtitleSource
+ CSubtitleSourcePreview : public CSubtitleSource
{
public:
- CSubtitleSourcePreview(LPUNKNOWN lpunk, HRESULT* phr);
+ CSubtitleSourcePreview(LPUNKNOWN lpunk, HRESULT* phr);
- HRESULT GetMediaType(CMediaType* pmt);
+ HRESULT GetMediaType(CMediaType* pmt);
};
class __declspec(uuid("CF0D7280-527D-415E-BA02-56017484D73E"))
- CSubtitleSourceARGB : public CSubtitleSource
+ CSubtitleSourceARGB : public CSubtitleSource
{
public:
- CSubtitleSourceARGB(LPUNKNOWN lpunk, HRESULT* phr);
+ CSubtitleSourceARGB(LPUNKNOWN lpunk, HRESULT* phr);
- HRESULT GetMediaType(CMediaType* pmt);
+ HRESULT GetMediaType(CMediaType* pmt);
};
diff --git a/src/filters/switcher/AudioSwitcher/Audio.cpp b/src/filters/switcher/AudioSwitcher/Audio.cpp
index 7a400dde5..0ef740e6a 100644
--- a/src/filters/switcher/AudioSwitcher/Audio.cpp
+++ b/src/filters/switcher/AudioSwitcher/Audio.cpp
@@ -25,300 +25,300 @@
#include "stdafx.h"
#include "Audio.h"
-static long audio_pointsample_8(void *dst, void *src, long accum, long samp_frac, long cnt)
+static long audio_pointsample_8(void* dst, void* src, long accum, long samp_frac, long cnt)
{
- unsigned char *d = (unsigned char *)dst;
- unsigned char *s = (unsigned char *)src;
+ unsigned char* d = (unsigned char*)dst;
+ unsigned char* s = (unsigned char*)src;
- do {
- *d++ = s[accum>>19];
- accum += samp_frac;
- } while (--cnt);
+ do {
+ *d++ = s[accum >> 19];
+ accum += samp_frac;
+ } while (--cnt);
- return accum;
+ return accum;
}
-static long audio_pointsample_16(void *dst, void *src, long accum, long samp_frac, long cnt)
+static long audio_pointsample_16(void* dst, void* src, long accum, long samp_frac, long cnt)
{
- unsigned short *d = (unsigned short *)dst;
- unsigned short *s = (unsigned short *)src;
+ unsigned short* d = (unsigned short*)dst;
+ unsigned short* s = (unsigned short*)src;
- do {
- *d++ = s[accum>>19];
- accum += samp_frac;
- } while (--cnt);
+ do {
+ *d++ = s[accum >> 19];
+ accum += samp_frac;
+ } while (--cnt);
- return accum;
+ return accum;
}
-static long audio_pointsample_32(void *dst, void *src, long accum, long samp_frac, long cnt)
+static long audio_pointsample_32(void* dst, void* src, long accum, long samp_frac, long cnt)
{
- unsigned long *d = (unsigned long *)dst;
- unsigned long *s = (unsigned long *)src;
+ unsigned long* d = (unsigned long*)dst;
+ unsigned long* s = (unsigned long*)src;
- do {
- *d++ = s[accum>>19];
- accum += samp_frac;
- } while (--cnt);
+ do {
+ *d++ = s[accum >> 19];
+ accum += samp_frac;
+ } while (--cnt);
- return accum;
+ return accum;
}
-static long audio_downsample_mono8(void *dst, void *src, long *filter_bank, int filter_width, long accum, long samp_frac, long cnt)
+static long audio_downsample_mono8(void* dst, void* src, long* filter_bank, int filter_width, long accum, long samp_frac, long cnt)
{
- unsigned char *d = (unsigned char *)dst;
- unsigned char *s = (unsigned char *)src;
-
- do {
- long sum = 0;
- int w;
- long *fb_ptr;
- unsigned char *s_ptr;
-
- w = filter_width;
- fb_ptr = filter_bank + filter_width * ((accum>>11)&0xff);
- s_ptr = s + (accum>>19);
- do {
- sum += *fb_ptr++ * (int)*s_ptr++;
- } while (--w);
-
- if (sum < 0) {
- *d++ = 0;
- } else if (sum > 0x3fffff) {
- *d++ = 0xff;
- } else {
- *d++ = (unsigned char)((sum + 0x2000) >> 14);
- }
-
- accum += samp_frac;
- } while (--cnt);
-
- return accum;
+ unsigned char* d = (unsigned char*)dst;
+ unsigned char* s = (unsigned char*)src;
+
+ do {
+ long sum = 0;
+ int w;
+ long* fb_ptr;
+ unsigned char* s_ptr;
+
+ w = filter_width;
+ fb_ptr = filter_bank + filter_width * ((accum >> 11) & 0xff);
+ s_ptr = s + (accum >> 19);
+ do {
+ sum += *fb_ptr++ * (int) * s_ptr++;
+ } while (--w);
+
+ if (sum < 0) {
+ *d++ = 0;
+ } else if (sum > 0x3fffff) {
+ *d++ = 0xff;
+ } else {
+ *d++ = (unsigned char)((sum + 0x2000) >> 14);
+ }
+
+ accum += samp_frac;
+ } while (--cnt);
+
+ return accum;
}
-static long audio_downsample_mono16(void *dst, void *src, long *filter_bank, int filter_width, long accum, long samp_frac, long cnt)
+static long audio_downsample_mono16(void* dst, void* src, long* filter_bank, int filter_width, long accum, long samp_frac, long cnt)
{
- signed short *d = (signed short *)dst;
- signed short *s = (signed short *)src;
-
- do {
- long sum = 0;
- int w;
- long *fb_ptr;
- signed short *s_ptr;
-
- w = filter_width;
- fb_ptr = filter_bank + filter_width * ((accum>>11)&0xff);
- s_ptr = s + (accum>>19);
- do {
- sum += *fb_ptr++ * (int)*s_ptr++;
- } while (--w);
-
- if (sum < -0x20000000) {
- *d++ = -0x8000;
- } else if (sum > 0x1fffffff) {
- *d++ = 0x7fff;
- } else {
- *d++ = (signed short)((sum + 0x2000) >> 14);
- }
-
- accum += samp_frac;
- } while (--cnt);
-
- return accum;
+ signed short* d = (signed short*)dst;
+ signed short* s = (signed short*)src;
+
+ do {
+ long sum = 0;
+ int w;
+ long* fb_ptr;
+ signed short* s_ptr;
+
+ w = filter_width;
+ fb_ptr = filter_bank + filter_width * ((accum >> 11) & 0xff);
+ s_ptr = s + (accum >> 19);
+ do {
+ sum += *fb_ptr++ * (int) * s_ptr++;
+ } while (--w);
+
+ if (sum < -0x20000000) {
+ *d++ = -0x8000;
+ } else if (sum > 0x1fffffff) {
+ *d++ = 0x7fff;
+ } else {
+ *d++ = (signed short)((sum + 0x2000) >> 14);
+ }
+
+ accum += samp_frac;
+ } while (--cnt);
+
+ return accum;
}
static int permute_index(int a, int b)
{
- return (b-(a>>8)-1) + (a&255)*b;
+ return (b - (a >> 8) - 1) + (a & 255) * b;
}
-static void make_downsample_filter(long *filter_bank, int filter_width, long samp_frac)
+static void make_downsample_filter(long* filter_bank, int filter_width, long samp_frac)
{
- int i, j, v;
- double filt_max;
- double filtwidth_frac;
+ int i, j, v;
+ double filt_max;
+ double filtwidth_frac;
- filtwidth_frac = samp_frac/2048.0;
+ filtwidth_frac = samp_frac / 2048.0;
- filter_bank[filter_width-1] = 0;
+ filter_bank[filter_width - 1] = 0;
- filt_max = (16384.0 * 524288.0) / samp_frac;
+ filt_max = (16384.0 * 524288.0) / samp_frac;
- for (i=0; i<128*filter_width; i++) {
- int y = 0;
- double d = i / filtwidth_frac;
+ for (i = 0; i < 128 * filter_width; i++) {
+ int y = 0;
+ double d = i / filtwidth_frac;
- if (d<1.0) {
- y = (int)(0.5 + filt_max*(1.0 - d));
- }
+ if (d < 1.0) {
+ y = (int)(0.5 + filt_max * (1.0 - d));
+ }
- filter_bank[permute_index(128*filter_width + i, filter_width)]
- = filter_bank[permute_index(128*filter_width - i, filter_width)]
- = y;
- }
+ filter_bank[permute_index(128 * filter_width + i, filter_width)]
+ = filter_bank[permute_index(128 * filter_width - i, filter_width)]
+ = y;
+ }
- // Normalize the filter to correct for integer roundoff errors
+ // Normalize the filter to correct for integer roundoff errors
- for (i=0; i<256*filter_width; i+=filter_width) {
- v=0;
- for (j=0; j<filter_width; j++) {
- v += filter_bank[i+j];
- }
+ for (i = 0; i < 256 * filter_width; i += filter_width) {
+ v = 0;
+ for (j = 0; j < filter_width; j++) {
+ v += filter_bank[i + j];
+ }
- // _RPT2(0,"error[%02x] = %04x\n", i/filter_width, 0x4000 - v);
+ // _RPT2(0,"error[%02x] = %04x\n", i/filter_width, 0x4000 - v);
- v = (0x4000 - v)/filter_width;
- for (j=0; j<filter_width; j++) {
- filter_bank[i+j] += v;
- }
- }
+ v = (0x4000 - v) / filter_width;
+ for (j = 0; j < filter_width; j++) {
+ filter_bank[i + j] += v;
+ }
+ }
- // _CrtCheckMemory();
+ // _CrtCheckMemory();
}
AudioStreamResampler::AudioStreamResampler(int bps, long org_rate, long new_rate, bool fHighQuality)
{
- samp_frac = 0x80000;
+ samp_frac = 0x80000;
- this->bps = bps;
+ this->bps = bps;
- if (bps == 1) {
- ptsampleRout = audio_pointsample_8;
- dnsampleRout = audio_downsample_mono8;
- } else if (bps >= 2) {
- ptsampleRout = audio_pointsample_16;
- dnsampleRout = audio_downsample_mono16;
- } else {
- return;
- }
+ if (bps == 1) {
+ ptsampleRout = audio_pointsample_8;
+ dnsampleRout = audio_downsample_mono8;
+ } else if (bps >= 2) {
+ ptsampleRout = audio_pointsample_16;
+ dnsampleRout = audio_downsample_mono16;
+ } else {
+ return;
+ }
- // org_rate > new_rate!
- samp_frac = MulDiv(org_rate, 0x80000, new_rate);
+ // org_rate > new_rate!
+ samp_frac = MulDiv(org_rate, 0x80000, new_rate);
- holdover = 0;
- filter_bank = NULL;
- filter_width = 1;
- accum = 0;
+ holdover = 0;
+ filter_bank = NULL;
+ filter_width = 1;
+ accum = 0;
- // If this is a high-quality downsample, allocate memory for the filter bank
+ // If this is a high-quality downsample, allocate memory for the filter bank
- if (fHighQuality) {
- if (samp_frac>0x80000) {
- // HQ downsample: allocate filter bank
+ if (fHighQuality) {
+ if (samp_frac > 0x80000) {
+ // HQ downsample: allocate filter bank
- filter_width = ((samp_frac + 0x7ffff)>>19)<<1 <<1;
+ filter_width = ((samp_frac + 0x7ffff) >> 19) << 1 << 1;
- filter_bank = DNew long[filter_width * 256];
- if (!filter_bank) {
- filter_width = 1;
- return;
- }
+ filter_bank = DNew long[filter_width * 256];
+ if (!filter_bank) {
+ filter_width = 1;
+ return;
+ }
- make_downsample_filter(filter_bank, filter_width, samp_frac);
+ make_downsample_filter(filter_bank, filter_width, samp_frac);
- // Clear lower samples
+ // Clear lower samples
- memset(cbuffer, bps >= 2 ? 0 : 0x80, bps*filter_width);
+ memset(cbuffer, bps >= 2 ? 0 : 0x80, bps * filter_width);
- holdover = filter_width/2;
- }
- }
+ holdover = filter_width / 2;
+ }
+ }
}
AudioStreamResampler::~AudioStreamResampler()
{
- delete [] filter_bank;
+ delete [] filter_bank;
}
long AudioStreamResampler::Downsample(void* input, long samplesin, void* output, long samplesout)
{
- long lActualSamples = 0;
+ long lActualSamples = 0;
- // Downsampling is even worse because we have overlap to the left and to the
- // right of the interpolated point.
- //
- // We need (n/2) points to the left and (n/2-1) points to the right.
+ // Downsampling is even worse because we have overlap to the left and to the
+ // right of the interpolated point.
+ //
+ // We need (n/2) points to the left and (n/2-1) points to the right.
- while (samplesin > 0 && samplesout > 0) {
- long srcSamples, dstSamples;
- int nhold;
+ while (samplesin > 0 && samplesout > 0) {
+ long srcSamples, dstSamples;
+ int nhold;
- // Figure out how many source samples we need.
- //
- // To do this, compute the highest fixed-point accumulator we'll reach.
- // Truncate that, and add the filter width. Then subtract however many
- // samples are sitting at the bottom of the buffer.
+ // Figure out how many source samples we need.
+ //
+ // To do this, compute the highest fixed-point accumulator we'll reach.
+ // Truncate that, and add the filter width. Then subtract however many
+ // samples are sitting at the bottom of the buffer.
- srcSamples = (long)(((__int64)samp_frac*(samplesout-1) + accum) >> 19) + filter_width - holdover;
+ srcSamples = (long)(((__int64)samp_frac * (samplesout - 1) + accum) >> 19) + filter_width - holdover;
- // Don't exceed the buffer (BUFFER_SIZE - holdover).
+ // Don't exceed the buffer (BUFFER_SIZE - holdover).
- if (srcSamples > BUFFER_SIZE - holdover) {
- srcSamples = BUFFER_SIZE - holdover;
- }
+ if (srcSamples > BUFFER_SIZE - holdover) {
+ srcSamples = BUFFER_SIZE - holdover;
+ }
- // Read into buffer.
+ // Read into buffer.
- srcSamples = min(srcSamples, samplesin);
- if (!srcSamples) {
- break;
- }
+ srcSamples = min(srcSamples, samplesin);
+ if (!srcSamples) {
+ break;
+ }
- memcpy((char*)cbuffer + holdover*bps, (char*)input, srcSamples*bps);
- input = (void *)((char *)input + srcSamples*bps);
+ memcpy((char*)cbuffer + holdover * bps, (char*)input, srcSamples * bps);
+ input = (void*)((char*)input + srcSamples * bps);
- // Figure out how many destination samples we'll get out of what we
- // read. We'll have (srcSamples+holdover) bytes, so the maximum
- // fixed-pt accumulator we can hit is
- // (srcSamples+holdover-filter_width)<<16 + 0xffff.
+ // Figure out how many destination samples we'll get out of what we
+ // read. We'll have (srcSamples+holdover) bytes, so the maximum
+ // fixed-pt accumulator we can hit is
+ // (srcSamples+holdover-filter_width)<<16 + 0xffff.
- dstSamples = (((__int64)(srcSamples+holdover-filter_width)<<19) + 0x7ffff - accum) / samp_frac + 1;
+ dstSamples = (((__int64)(srcSamples + holdover - filter_width) << 19) + 0x7ffff - accum) / samp_frac + 1;
- if (dstSamples > samplesout) {
- dstSamples = samplesout;
- }
+ if (dstSamples > samplesout) {
+ dstSamples = samplesout;
+ }
- if (dstSamples >= 1) {
- if (filter_bank) {
- accum = dnsampleRout(output, cbuffer, filter_bank, filter_width, accum, samp_frac, dstSamples);
- } else {
- accum = ptsampleRout(output, cbuffer, accum, samp_frac, dstSamples);
- }
+ if (dstSamples >= 1) {
+ if (filter_bank) {
+ accum = dnsampleRout(output, cbuffer, filter_bank, filter_width, accum, samp_frac, dstSamples);
+ } else {
+ accum = ptsampleRout(output, cbuffer, accum, samp_frac, dstSamples);
+ }
- output = (void *)((char *)output + bps * dstSamples);
- lActualSamples += dstSamples;
- samplesout -= dstSamples;
- }
+ output = (void*)((char*)output + bps * dstSamples);
+ lActualSamples += dstSamples;
+ samplesout -= dstSamples;
+ }
- // We're "shifting" the new samples down to the bottom by discarding
- // all the samples in the buffer, so adjust the fixed-pt accum
- // accordingly.
+ // We're "shifting" the new samples down to the bottom by discarding
+ // all the samples in the buffer, so adjust the fixed-pt accum
+ // accordingly.
- accum -= ((srcSamples+holdover)<<19);
+ accum -= ((srcSamples + holdover) << 19);
- // Oops, did we need some of those?
- //
- // If accum=0, we need (n/2) samples back. accum>=0x10000 is fewer,
- // accum<0 is more.
+ // Oops, did we need some of those?
+ //
+ // If accum=0, we need (n/2) samples back. accum>=0x10000 is fewer,
+ // accum<0 is more.
- nhold = - (accum>>19);
+ nhold = - (accum >> 19);
- //_ASSERT(nhold<=(filter_width/2));
+ //_ASSERT(nhold<=(filter_width/2));
- if (nhold>0) {
- memmove(cbuffer, (char *)cbuffer+bps*(srcSamples+holdover-nhold), bps*nhold);
- holdover = nhold;
- accum += nhold<<19;
- } else {
- holdover = 0;
- }
+ if (nhold > 0) {
+ memmove(cbuffer, (char*)cbuffer + bps * (srcSamples + holdover - nhold), bps * nhold);
+ holdover = nhold;
+ accum += nhold << 19;
+ } else {
+ holdover = 0;
+ }
- //_ASSERT(accum>=0);
- }
+ //_ASSERT(accum>=0);
+ }
- int Bytes = lActualSamples * bps;
- UNREFERENCED_PARAMETER(Bytes);
+ int Bytes = lActualSamples * bps;
+ UNREFERENCED_PARAMETER(Bytes);
- return lActualSamples;
+ return lActualSamples;
}
diff --git a/src/filters/switcher/AudioSwitcher/Audio.h b/src/filters/switcher/AudioSwitcher/Audio.h
index d5230e74a..1611bda44 100644
--- a/src/filters/switcher/AudioSwitcher/Audio.h
+++ b/src/filters/switcher/AudioSwitcher/Audio.h
@@ -28,28 +28,28 @@
#include <mmsystem.h>
#include <msacm.h>
-typedef long (*AudioPointSampler)(void *, void *, long, long, long);
-typedef long (*AudioDownSampler)(void *, void *, long *, int, long, long, long);
+typedef long(*AudioPointSampler)(void*, void*, long, long, long);
+typedef long(*AudioDownSampler)(void*, void*, long*, int, long, long, long);
class AudioStreamResampler
{
private:
- AudioPointSampler ptsampleRout;
- AudioDownSampler dnsampleRout;
- long samp_frac;
- long accum;
- int holdover;
- long *filter_bank;
- int filter_width;
- bool fHighQuality;
+ AudioPointSampler ptsampleRout;
+ AudioDownSampler dnsampleRout;
+ long samp_frac;
+ long accum;
+ int holdover;
+ long* filter_bank;
+ int filter_width;
+ bool fHighQuality;
- enum { BUFFER_SIZE=512 };
- BYTE cbuffer[4*BUFFER_SIZE];
- int bps;
+ enum { BUFFER_SIZE = 512 };
+ BYTE cbuffer[4 * BUFFER_SIZE];
+ int bps;
public:
- AudioStreamResampler(int bps, long org_rate, long new_rate, bool fHighQuality);
- ~AudioStreamResampler();
+ AudioStreamResampler(int bps, long org_rate, long new_rate, bool fHighQuality);
+ ~AudioStreamResampler();
- long Downsample(void* input, long samplesin, void* output, long samplesout);
+ long Downsample(void* input, long samplesin, void* output, long samplesout);
};
diff --git a/src/filters/switcher/AudioSwitcher/AudioSwitcher.cpp b/src/filters/switcher/AudioSwitcher/AudioSwitcher.cpp
index 883a58fbe..4ba2ff5d4 100644
--- a/src/filters/switcher/AudioSwitcher/AudioSwitcher.cpp
+++ b/src/filters/switcher/AudioSwitcher/AudioSwitcher.cpp
@@ -44,36 +44,36 @@
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_NULL}
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_NULL}
};
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_NULL}
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_NULL}
};
const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CAudioSwitcherFilter), AudioSwitcherName, MERIT_DO_NOT_USE, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory}
+ {&__uuidof(CAudioSwitcherFilter), AudioSwitcherName, MERIT_DO_NOT_USE, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory}
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CAudioSwitcherFilter>, NULL, &sudFilter[0]}
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CAudioSwitcherFilter>, NULL, &sudFilter[0]}
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -87,577 +87,577 @@ CFilterApp theApp;
//
CAudioSwitcherFilter::CAudioSwitcherFilter(LPUNKNOWN lpunk, HRESULT* phr)
- : CStreamSwitcherFilter(lpunk, phr, __uuidof(this))
- , m_fCustomChannelMapping(false)
- , m_fDownSampleTo441(false)
- , m_rtAudioTimeShift(0)
- , m_rtNextStart(0)
- , m_rtNextStop(1)
- , m_fNormalize(false)
- , m_fNormalizeRecover(false)
- , m_boost_mul(1)
- , m_sample_max(0.1f)
+ : CStreamSwitcherFilter(lpunk, phr, __uuidof(this))
+ , m_fCustomChannelMapping(false)
+ , m_fDownSampleTo441(false)
+ , m_rtAudioTimeShift(0)
+ , m_rtNextStart(0)
+ , m_rtNextStop(1)
+ , m_fNormalize(false)
+ , m_fNormalizeRecover(false)
+ , m_boost_mul(1)
+ , m_sample_max(0.1f)
{
- memset(m_pSpeakerToChannelMap, 0, sizeof(m_pSpeakerToChannelMap));
-
- if (phr) {
- if (FAILED(*phr)) {
- return;
- } else {
- *phr = S_OK;
- }
- }
+ memset(m_pSpeakerToChannelMap, 0, sizeof(m_pSpeakerToChannelMap));
+
+ if (phr) {
+ if (FAILED(*phr)) {
+ return;
+ } else {
+ *phr = S_OK;
+ }
+ }
}
STDMETHODIMP CAudioSwitcherFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- return
- QI(IAudioSwitcherFilter)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IAudioSwitcherFilter)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CAudioSwitcherFilter::CheckMediaType(const CMediaType* pmt)
{
- if (pmt->formattype == FORMAT_WaveFormatEx
- && ((WAVEFORMATEX*)pmt->pbFormat)->nChannels > 2
- && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag != WAVE_FORMAT_EXTENSIBLE) {
- return VFW_E_INVALIDMEDIATYPE; // stupid iviaudio tries to fool us
- }
-
- return (pmt->majortype == MEDIATYPE_Audio
- && pmt->formattype == FORMAT_WaveFormatEx
- && (((WAVEFORMATEX*)pmt->pbFormat)->wBitsPerSample == 8
- || ((WAVEFORMATEX*)pmt->pbFormat)->wBitsPerSample == 16
- || ((WAVEFORMATEX*)pmt->pbFormat)->wBitsPerSample == 24
- || ((WAVEFORMATEX*)pmt->pbFormat)->wBitsPerSample == 32)
- && (((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_PCM
- || ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_IEEE_FLOAT
- || ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_DOLBY_AC3_SPDIF
- || ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_EXTENSIBLE))
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ if (pmt->formattype == FORMAT_WaveFormatEx
+ && ((WAVEFORMATEX*)pmt->pbFormat)->nChannels > 2
+ && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag != WAVE_FORMAT_EXTENSIBLE) {
+ return VFW_E_INVALIDMEDIATYPE; // stupid iviaudio tries to fool us
+ }
+
+ return (pmt->majortype == MEDIATYPE_Audio
+ && pmt->formattype == FORMAT_WaveFormatEx
+ && (((WAVEFORMATEX*)pmt->pbFormat)->wBitsPerSample == 8
+ || ((WAVEFORMATEX*)pmt->pbFormat)->wBitsPerSample == 16
+ || ((WAVEFORMATEX*)pmt->pbFormat)->wBitsPerSample == 24
+ || ((WAVEFORMATEX*)pmt->pbFormat)->wBitsPerSample == 32)
+ && (((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_PCM
+ || ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_IEEE_FLOAT
+ || ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_DOLBY_AC3_SPDIF
+ || ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_EXTENSIBLE))
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
template<class T, class U, int Umin, int Umax>
__forceinline void mix(DWORD mask, int ch, int bps, BYTE* src, BYTE* dst)
{
- U sum = 0;
+ U sum = 0;
- for (int i = 0, j = ch; i < j; i++) {
- if (mask & (1<<i)) {
- sum += *(T*)&src[bps*i];
- }
- }
+ for (int i = 0, j = ch; i < j; i++) {
+ if (mask & (1 << i)) {
+ sum += *(T*)&src[bps * i];
+ }
+ }
- if (sum < Umin) {
- sum = Umin;
- } else if (sum > Umax) {
- sum = Umax;
- }
+ if (sum < Umin) {
+ sum = Umin;
+ } else if (sum > Umax) {
+ sum = Umax;
+ }
- *(T*)dst = (T)sum;
+ *(T*)dst = (T)sum;
}
template<>
__forceinline void mix<int, INT64, INT24_MIN, INT24_MAX>(DWORD mask, int ch, int bps, BYTE* src, BYTE* dst)
{
- INT64 sum = 0;
+ INT64 sum = 0;
- for (int i = 0, j = ch; i < j; i++) {
- if (mask & (1<<i)) {
- int tmp;
- memcpy((BYTE*)&tmp+1, &src[bps*i], 3);
- sum += tmp >> 8;
- }
- }
+ for (int i = 0, j = ch; i < j; i++) {
+ if (mask & (1 << i)) {
+ int tmp;
+ memcpy((BYTE*)&tmp + 1, &src[bps * i], 3);
+ sum += tmp >> 8;
+ }
+ }
- sum = min(max(sum, INT24_MIN), INT24_MAX);
+ sum = min(max(sum, INT24_MIN), INT24_MAX);
- memcpy(dst, (BYTE*)&sum, 3);
+ memcpy(dst, (BYTE*)&sum, 3);
}
template<class T, class U, int Umin, int Umax>
__forceinline void mix4(DWORD mask, BYTE* src, BYTE* dst)
{
- U sum = 0;
- int bps = sizeof T;
-
- if (mask & (1<<0)) {
- sum += *(T*)&src[bps*0];
- }
- if (mask & (1<<1)) {
- sum += *(T*)&src[bps*1];
- }
- if (mask & (1<<2)) {
- sum += *(T*)&src[bps*2];
- }
- if (mask & (1<<3)) {
- sum += *(T*)&src[bps*3];
- }
-
- if (sum < Umin) {
- sum = Umin;
- } else if (sum > Umax) {
- sum = Umax;
- }
-
- *(T*)dst = (T)sum;
+ U sum = 0;
+ int bps = sizeof T;
+
+ if (mask & (1 << 0)) {
+ sum += *(T*)&src[bps * 0];
+ }
+ if (mask & (1 << 1)) {
+ sum += *(T*)&src[bps * 1];
+ }
+ if (mask & (1 << 2)) {
+ sum += *(T*)&src[bps * 2];
+ }
+ if (mask & (1 << 3)) {
+ sum += *(T*)&src[bps * 3];
+ }
+
+ if (sum < Umin) {
+ sum = Umin;
+ } else if (sum > Umax) {
+ sum = Umax;
+ }
+
+ *(T*)dst = (T)sum;
}
template<class T>
T clamp(double s, T smin, T smax)
{
- if (s < -1) {
- s = -1;
- } else if (s > 1) {
- s = 1;
- }
- T t = (T)(s * smax);
- if (t < smin) {
- t = smin;
- } else if (t > smax) {
- t = smax;
- }
- return t;
+ if (s < -1) {
+ s = -1;
+ } else if (s > 1) {
+ s = 1;
+ }
+ T t = (T)(s * smax);
+ if (t < smin) {
+ t = smin;
+ } else if (t > smax) {
+ t = smax;
+ }
+ return t;
}
HRESULT CAudioSwitcherFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
{
- CStreamSwitcherInputPin* pInPin = GetInputPin();
- CStreamSwitcherOutputPin* pOutPin = GetOutputPin();
- if (!pInPin || !pOutPin) {
- return __super::Transform(pIn, pOut);
- }
-
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)pInPin->CurrentMediaType().pbFormat;
- WAVEFORMATEX* wfeout = (WAVEFORMATEX*)pOutPin->CurrentMediaType().pbFormat;
- WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)wfe;
-
- int bps = wfe->wBitsPerSample>>3;
-
- int len = pIn->GetActualDataLength() / (bps*wfe->nChannels);
- int lenout = (UINT64)len * wfeout->nSamplesPerSec / wfe->nSamplesPerSec;
-
- REFERENCE_TIME rtStart, rtStop;
- if (SUCCEEDED(pIn->GetTime(&rtStart, &rtStop))) {
- rtStart += m_rtAudioTimeShift;
- rtStop += m_rtAudioTimeShift;
- pOut->SetTime(&rtStart, &rtStop);
-
- m_rtNextStart = rtStart;
- m_rtNextStop = rtStop;
- } else {
- pOut->SetTime(&m_rtNextStart, &m_rtNextStop);
- }
-
- REFERENCE_TIME rtDur = 10000000i64*len/wfe->nSamplesPerSec;
-
- m_rtNextStart += rtDur;
- m_rtNextStop += rtDur;
-
- if (pIn->IsDiscontinuity() == S_OK) {
- m_sample_max = 0.1f;
- }
-
- WORD tag = wfe->wFormatTag;
- bool fPCM = tag == WAVE_FORMAT_PCM || tag == WAVE_FORMAT_EXTENSIBLE && wfex->SubFormat == KSDATAFORMAT_SUBTYPE_PCM;
- bool fFloat = tag == WAVE_FORMAT_IEEE_FLOAT || tag == WAVE_FORMAT_EXTENSIBLE && wfex->SubFormat == KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
- if (!fPCM && !fFloat) {
- return __super::Transform(pIn, pOut);
- }
-
- BYTE* pDataIn = NULL;
- BYTE* pDataOut = NULL;
-
- HRESULT hr;
- if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
- return hr;
- }
- if (FAILED(hr = pOut->GetPointer(&pDataOut))) {
- return hr;
- }
-
- if (!pDataIn || !pDataOut || len < 0 || lenout < 0) {
- return S_FALSE;
- }
- // len = 0 doesn't mean it's failed, return S_OK otherwise might screw the sound
- if (len == 0) {
- pOut->SetActualDataLength(0);
- return S_OK;
- }
-
- if (m_fCustomChannelMapping) {
- size_t channelsCount = m_chs[wfe->nChannels-1].GetCount();
- if (channelsCount > 0 && wfeout->nChannels <= channelsCount) {
- for (int i = 0; i < wfeout->nChannels; i++) {
- DWORD mask = m_chs[wfe->nChannels-1][i].Channel;
-
- BYTE* src = pDataIn;
- BYTE* dst = &pDataOut[bps*i];
-
- int srcstep = bps*wfe->nChannels;
- int dststep = bps*wfeout->nChannels;
- int channels = min(18, wfe->nChannels);
- if (fPCM && wfe->wBitsPerSample == 8) {
- for (int k = 0; k < len; k++, src += srcstep, dst += dststep) {
- mix<unsigned char, INT64, 0, UCHAR_MAX>(mask, channels, bps, src, dst);
- }
- } else if (fPCM && wfe->wBitsPerSample == 16) {
- if (wfe->nChannels != 4 || wfeout->nChannels != 4) {
- for (int k = 0; k < len; k++, src += srcstep, dst += dststep) {
- mix<short, INT64, SHRT_MIN, SHRT_MAX>(mask, channels, bps, src, dst);
- }
- } else { // most popular channels count
- for (int k = 0; k < len; k++, src += srcstep, dst += dststep) {
- mix4<short, INT64, SHRT_MIN, SHRT_MAX>(mask, src, dst);
- }
- }
- } else if (fPCM && wfe->wBitsPerSample == 24) {
- for (int k = 0; k < len; k++, src += srcstep, dst += dststep) {
- mix<int, INT64, INT24_MIN, INT24_MAX>(mask, channels, bps, src, dst);
- }
- } else if (fPCM && wfe->wBitsPerSample == 32) {
- for (int k = 0; k < len; k++, src += srcstep, dst += dststep) {
- mix<int, __int64, INT_MIN, INT_MAX>(mask, channels, bps, src, dst);
- }
- } else if (fFloat && wfe->wBitsPerSample == 32) {
- for (int k = 0; k < len; k++, src += srcstep, dst += dststep) {
- mix<float, double, -1, 1>(mask, channels, bps, src, dst);
- }
- } else if (fFloat && wfe->wBitsPerSample == 64) {
- for (int k = 0; k < len; k++, src += srcstep, dst += dststep) {
- mix<double, double, -1, 1>(mask, channels, bps, src, dst);
- }
- }
- }
- } else {
- BYTE* pDataOut = NULL;
- HRESULT hr;
- if (FAILED(hr = pOut->GetPointer(&pDataOut)) || !pDataOut) {
- return hr;
- }
- memset(pDataOut, 0, pOut->GetSize());
- }
- } else {
- HRESULT hr;
- if (S_OK != (hr = __super::Transform(pIn, pOut))) {
- return hr;
- }
- }
-
- if (m_fDownSampleTo441
- && wfe->nSamplesPerSec > 44100 && wfeout->nSamplesPerSec == 44100
- && wfe->wBitsPerSample <= 16 && fPCM) {
- if (BYTE* buff = DNew BYTE[len*bps]) {
- for (int ch = 0; ch < wfeout->nChannels; ch++) {
- memset(buff, 0, len*bps);
-
- for (int i = 0; i < len; i++) {
- memcpy(buff + i*bps, (char*)pDataOut + (ch + i*wfeout->nChannels)*bps, bps);
- }
-
- m_pResamplers[ch]->Downsample(buff, len, buff, lenout);
-
- for (int i = 0; i < lenout; i++) {
- memcpy((char*)pDataOut + (ch + i*wfeout->nChannels)*bps, buff + i*bps, bps);
- }
- }
-
- delete [] buff;
- }
- }
-
- if (m_fNormalize || m_boost_mul > 1) {
- int samples = lenout*wfeout->nChannels;
-
- if (double* buff = DNew double[samples]) {
- for (int i = 0; i < samples; i++) {
- if (fPCM && wfe->wBitsPerSample == 8) {
- buff[i] = (double)((BYTE*)pDataOut)[i] / UCHAR_MAX;
- } else if (fPCM && wfe->wBitsPerSample == 16) {
- buff[i] = (double)((short*)pDataOut)[i] / SHRT_MAX;
- } else if (fPCM && wfe->wBitsPerSample == 24) {
- int tmp;
- memcpy(((BYTE*)&tmp)+1, &pDataOut[i*3], 3);
- buff[i] = (float)(tmp >> 8) / ((1<<23)-1);
- } else if (fPCM && wfe->wBitsPerSample == 32) {
- buff[i] = (double)((int*)pDataOut)[i] / INT_MAX;
- } else if (fFloat && wfe->wBitsPerSample == 32) {
- buff[i] = (double)((float*)pDataOut)[i];
- } else if (fFloat && wfe->wBitsPerSample == 64) {
- buff[i] = ((double*)pDataOut)[i];
- }
- }
-
- double sample_mul = 1;
-
- if (m_fNormalize) {
- for (int i = 0; i < samples; i++) {
- double s = buff[i];
- if (s < 0) {
- s = -s;
- }
- if (s > 1) {
- s = 1;
- }
- if (m_sample_max < s) {
- m_sample_max = s;
- }
- }
-
- sample_mul = 1.0f / m_sample_max;
-
- if (m_fNormalizeRecover) {
- m_sample_max -= 1.0*rtDur/200000000; // -5%/sec
- }
- if (m_sample_max < 0.1) {
- m_sample_max = 0.1;
- }
- }
-
- if (m_boost_mul > 1) {
- sample_mul *= m_boost_mul;
- }
-
- for (int i = 0; i < samples; i++) {
- double s = buff[i] * sample_mul;
-
- if (fPCM && wfe->wBitsPerSample == 8) {
- ((BYTE*)pDataOut)[i] = clamp<BYTE>(s, 0, UCHAR_MAX);
- } else if (fPCM && wfe->wBitsPerSample == 16) {
- ((short*)pDataOut)[i] = clamp<short>(s, SHRT_MIN, SHRT_MAX);
- } else if (fPCM && wfe->wBitsPerSample == 24) {
- int tmp = clamp<int>(s, -1<<23, (1<<23)-1);
- memcpy(&pDataOut[i*3], &tmp, 3);
- } else if (fPCM && wfe->wBitsPerSample == 32) {
- ((int*)pDataOut)[i] = clamp<int>(s, INT_MIN, INT_MAX);
- } else if (fFloat && wfe->wBitsPerSample == 32) {
- ((float*)pDataOut)[i] = clamp<float>(s, -1, +1);
- } else if (fFloat && wfe->wBitsPerSample == 64) {
- ((double*)pDataOut)[i] = clamp<double>(s, -1, +1);
- }
- }
-
- delete [] buff;
- }
- }
-
- pOut->SetActualDataLength(lenout*bps*wfeout->nChannels);
-
- return S_OK;
+ CStreamSwitcherInputPin* pInPin = GetInputPin();
+ CStreamSwitcherOutputPin* pOutPin = GetOutputPin();
+ if (!pInPin || !pOutPin) {
+ return __super::Transform(pIn, pOut);
+ }
+
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)pInPin->CurrentMediaType().pbFormat;
+ WAVEFORMATEX* wfeout = (WAVEFORMATEX*)pOutPin->CurrentMediaType().pbFormat;
+ WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)wfe;
+
+ int bps = wfe->wBitsPerSample >> 3;
+
+ int len = pIn->GetActualDataLength() / (bps * wfe->nChannels);
+ int lenout = (UINT64)len * wfeout->nSamplesPerSec / wfe->nSamplesPerSec;
+
+ REFERENCE_TIME rtStart, rtStop;
+ if (SUCCEEDED(pIn->GetTime(&rtStart, &rtStop))) {
+ rtStart += m_rtAudioTimeShift;
+ rtStop += m_rtAudioTimeShift;
+ pOut->SetTime(&rtStart, &rtStop);
+
+ m_rtNextStart = rtStart;
+ m_rtNextStop = rtStop;
+ } else {
+ pOut->SetTime(&m_rtNextStart, &m_rtNextStop);
+ }
+
+ REFERENCE_TIME rtDur = 10000000i64 * len / wfe->nSamplesPerSec;
+
+ m_rtNextStart += rtDur;
+ m_rtNextStop += rtDur;
+
+ if (pIn->IsDiscontinuity() == S_OK) {
+ m_sample_max = 0.1f;
+ }
+
+ WORD tag = wfe->wFormatTag;
+ bool fPCM = tag == WAVE_FORMAT_PCM || tag == WAVE_FORMAT_EXTENSIBLE && wfex->SubFormat == KSDATAFORMAT_SUBTYPE_PCM;
+ bool fFloat = tag == WAVE_FORMAT_IEEE_FLOAT || tag == WAVE_FORMAT_EXTENSIBLE && wfex->SubFormat == KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
+ if (!fPCM && !fFloat) {
+ return __super::Transform(pIn, pOut);
+ }
+
+ BYTE* pDataIn = NULL;
+ BYTE* pDataOut = NULL;
+
+ HRESULT hr;
+ if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
+ return hr;
+ }
+ if (FAILED(hr = pOut->GetPointer(&pDataOut))) {
+ return hr;
+ }
+
+ if (!pDataIn || !pDataOut || len < 0 || lenout < 0) {
+ return S_FALSE;
+ }
+ // len = 0 doesn't mean it's failed, return S_OK otherwise might screw the sound
+ if (len == 0) {
+ pOut->SetActualDataLength(0);
+ return S_OK;
+ }
+
+ if (m_fCustomChannelMapping) {
+ size_t channelsCount = m_chs[wfe->nChannels - 1].GetCount();
+ if (channelsCount > 0 && wfeout->nChannels <= channelsCount) {
+ for (int i = 0; i < wfeout->nChannels; i++) {
+ DWORD mask = m_chs[wfe->nChannels - 1][i].Channel;
+
+ BYTE* src = pDataIn;
+ BYTE* dst = &pDataOut[bps * i];
+
+ int srcstep = bps * wfe->nChannels;
+ int dststep = bps * wfeout->nChannels;
+ int channels = min(18, wfe->nChannels);
+ if (fPCM && wfe->wBitsPerSample == 8) {
+ for (int k = 0; k < len; k++, src += srcstep, dst += dststep) {
+ mix<unsigned char, INT64, 0, UCHAR_MAX>(mask, channels, bps, src, dst);
+ }
+ } else if (fPCM && wfe->wBitsPerSample == 16) {
+ if (wfe->nChannels != 4 || wfeout->nChannels != 4) {
+ for (int k = 0; k < len; k++, src += srcstep, dst += dststep) {
+ mix<short, INT64, SHRT_MIN, SHRT_MAX>(mask, channels, bps, src, dst);
+ }
+ } else { // most popular channels count
+ for (int k = 0; k < len; k++, src += srcstep, dst += dststep) {
+ mix4<short, INT64, SHRT_MIN, SHRT_MAX>(mask, src, dst);
+ }
+ }
+ } else if (fPCM && wfe->wBitsPerSample == 24) {
+ for (int k = 0; k < len; k++, src += srcstep, dst += dststep) {
+ mix<int, INT64, INT24_MIN, INT24_MAX>(mask, channels, bps, src, dst);
+ }
+ } else if (fPCM && wfe->wBitsPerSample == 32) {
+ for (int k = 0; k < len; k++, src += srcstep, dst += dststep) {
+ mix<int, __int64, INT_MIN, INT_MAX>(mask, channels, bps, src, dst);
+ }
+ } else if (fFloat && wfe->wBitsPerSample == 32) {
+ for (int k = 0; k < len; k++, src += srcstep, dst += dststep) {
+ mix < float, double, -1, 1 > (mask, channels, bps, src, dst);
+ }
+ } else if (fFloat && wfe->wBitsPerSample == 64) {
+ for (int k = 0; k < len; k++, src += srcstep, dst += dststep) {
+ mix < double, double, -1, 1 > (mask, channels, bps, src, dst);
+ }
+ }
+ }
+ } else {
+ BYTE* pDataOut = NULL;
+ HRESULT hr;
+ if (FAILED(hr = pOut->GetPointer(&pDataOut)) || !pDataOut) {
+ return hr;
+ }
+ memset(pDataOut, 0, pOut->GetSize());
+ }
+ } else {
+ HRESULT hr;
+ if (S_OK != (hr = __super::Transform(pIn, pOut))) {
+ return hr;
+ }
+ }
+
+ if (m_fDownSampleTo441
+ && wfe->nSamplesPerSec > 44100 && wfeout->nSamplesPerSec == 44100
+ && wfe->wBitsPerSample <= 16 && fPCM) {
+ if (BYTE* buff = DNew BYTE[len * bps]) {
+ for (int ch = 0; ch < wfeout->nChannels; ch++) {
+ memset(buff, 0, len * bps);
+
+ for (int i = 0; i < len; i++) {
+ memcpy(buff + i * bps, (char*)pDataOut + (ch + i * wfeout->nChannels)*bps, bps);
+ }
+
+ m_pResamplers[ch]->Downsample(buff, len, buff, lenout);
+
+ for (int i = 0; i < lenout; i++) {
+ memcpy((char*)pDataOut + (ch + i * wfeout->nChannels)*bps, buff + i * bps, bps);
+ }
+ }
+
+ delete [] buff;
+ }
+ }
+
+ if (m_fNormalize || m_boost_mul > 1) {
+ int samples = lenout * wfeout->nChannels;
+
+ if (double* buff = DNew double[samples]) {
+ for (int i = 0; i < samples; i++) {
+ if (fPCM && wfe->wBitsPerSample == 8) {
+ buff[i] = (double)((BYTE*)pDataOut)[i] / UCHAR_MAX;
+ } else if (fPCM && wfe->wBitsPerSample == 16) {
+ buff[i] = (double)((short*)pDataOut)[i] / SHRT_MAX;
+ } else if (fPCM && wfe->wBitsPerSample == 24) {
+ int tmp;
+ memcpy(((BYTE*)&tmp) + 1, &pDataOut[i * 3], 3);
+ buff[i] = (float)(tmp >> 8) / ((1 << 23) - 1);
+ } else if (fPCM && wfe->wBitsPerSample == 32) {
+ buff[i] = (double)((int*)pDataOut)[i] / INT_MAX;
+ } else if (fFloat && wfe->wBitsPerSample == 32) {
+ buff[i] = (double)((float*)pDataOut)[i];
+ } else if (fFloat && wfe->wBitsPerSample == 64) {
+ buff[i] = ((double*)pDataOut)[i];
+ }
+ }
+
+ double sample_mul = 1;
+
+ if (m_fNormalize) {
+ for (int i = 0; i < samples; i++) {
+ double s = buff[i];
+ if (s < 0) {
+ s = -s;
+ }
+ if (s > 1) {
+ s = 1;
+ }
+ if (m_sample_max < s) {
+ m_sample_max = s;
+ }
+ }
+
+ sample_mul = 1.0f / m_sample_max;
+
+ if (m_fNormalizeRecover) {
+ m_sample_max -= 1.0 * rtDur / 200000000; // -5%/sec
+ }
+ if (m_sample_max < 0.1) {
+ m_sample_max = 0.1;
+ }
+ }
+
+ if (m_boost_mul > 1) {
+ sample_mul *= m_boost_mul;
+ }
+
+ for (int i = 0; i < samples; i++) {
+ double s = buff[i] * sample_mul;
+
+ if (fPCM && wfe->wBitsPerSample == 8) {
+ ((BYTE*)pDataOut)[i] = clamp<BYTE>(s, 0, UCHAR_MAX);
+ } else if (fPCM && wfe->wBitsPerSample == 16) {
+ ((short*)pDataOut)[i] = clamp<short>(s, SHRT_MIN, SHRT_MAX);
+ } else if (fPCM && wfe->wBitsPerSample == 24) {
+ int tmp = clamp<int>(s, -1 << 23, (1 << 23) - 1);
+ memcpy(&pDataOut[i * 3], &tmp, 3);
+ } else if (fPCM && wfe->wBitsPerSample == 32) {
+ ((int*)pDataOut)[i] = clamp<int>(s, INT_MIN, INT_MAX);
+ } else if (fFloat && wfe->wBitsPerSample == 32) {
+ ((float*)pDataOut)[i] = clamp<float>(s, -1, +1);
+ } else if (fFloat && wfe->wBitsPerSample == 64) {
+ ((double*)pDataOut)[i] = clamp<double>(s, -1, +1);
+ }
+ }
+
+ delete [] buff;
+ }
+ }
+
+ pOut->SetActualDataLength(lenout * bps * wfeout->nChannels);
+
+ return S_OK;
}
CMediaType CAudioSwitcherFilter::CreateNewOutputMediaType(CMediaType mt, long& cbBuffer)
{
- CStreamSwitcherInputPin* pInPin = GetInputPin();
- CStreamSwitcherOutputPin* pOutPin = GetOutputPin();
- if (!pInPin || !pOutPin || ((WAVEFORMATEX*)mt.pbFormat)->wFormatTag == WAVE_FORMAT_DOLBY_AC3_SPDIF) {
- return __super::CreateNewOutputMediaType(mt, cbBuffer);
- }
-
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)pInPin->CurrentMediaType().pbFormat;
-
- if (m_fCustomChannelMapping) {
- m_chs[wfe->nChannels-1].RemoveAll();
-
- DWORD mask = DWORD((__int64(1)<<wfe->nChannels)-1);
- for (int i = 0; i < 18; i++) {
- if (m_pSpeakerToChannelMap[wfe->nChannels-1][i]&mask) {
- ChMap cm = {1<<i, m_pSpeakerToChannelMap[wfe->nChannels-1][i]};
- m_chs[wfe->nChannels-1].Add(cm);
- }
- }
-
- if (m_chs[wfe->nChannels-1].GetCount() > 0) {
- mt.ReallocFormatBuffer(sizeof(WAVEFORMATEXTENSIBLE));
- WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)mt.pbFormat;
- wfex->Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE)-sizeof(WAVEFORMATEX);
- wfex->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
- wfex->Samples.wValidBitsPerSample = wfe->wBitsPerSample;
- wfex->SubFormat =
- wfe->wFormatTag == WAVE_FORMAT_PCM ? KSDATAFORMAT_SUBTYPE_PCM :
- wfe->wFormatTag == WAVE_FORMAT_IEEE_FLOAT ? KSDATAFORMAT_SUBTYPE_IEEE_FLOAT :
- wfe->wFormatTag == WAVE_FORMAT_EXTENSIBLE ? ((WAVEFORMATEXTENSIBLE*)wfe)->SubFormat :
- KSDATAFORMAT_SUBTYPE_PCM; // can't happen
-
- wfex->dwChannelMask = 0;
- for (size_t i = 0; i < m_chs[wfe->nChannels-1].GetCount(); i++) {
- wfex->dwChannelMask |= m_chs[wfe->nChannels-1][i].Speaker;
- }
-
- wfex->Format.nChannels = (WORD)m_chs[wfe->nChannels-1].GetCount();
- wfex->Format.nBlockAlign = wfex->Format.nChannels*wfex->Format.wBitsPerSample>>3;
- wfex->Format.nAvgBytesPerSec = wfex->Format.nBlockAlign*wfex->Format.nSamplesPerSec;
- }
- }
-
- WAVEFORMATEX* wfeout = (WAVEFORMATEX*)mt.pbFormat;
-
- if (m_fDownSampleTo441) {
- if (wfeout->nSamplesPerSec > 44100 && wfeout->wBitsPerSample <= 16) {
- wfeout->nSamplesPerSec = 44100;
- wfeout->nAvgBytesPerSec = wfeout->nBlockAlign*wfeout->nSamplesPerSec;
- }
- }
-
- int bps = wfe->wBitsPerSample>>3;
- int len = cbBuffer / (bps*wfe->nChannels);
- int lenout = len * wfeout->nSamplesPerSec / wfe->nSamplesPerSec;
- cbBuffer = lenout*bps*wfeout->nChannels;
-
- // mt.lSampleSize = (ULONG)max(mt.lSampleSize, wfe->nAvgBytesPerSec * rtLen / 10000000i64);
- // mt.lSampleSize = (mt.lSampleSize + (wfe->nBlockAlign-1)) & ~(wfe->nBlockAlign-1);
-
- return mt;
+ CStreamSwitcherInputPin* pInPin = GetInputPin();
+ CStreamSwitcherOutputPin* pOutPin = GetOutputPin();
+ if (!pInPin || !pOutPin || ((WAVEFORMATEX*)mt.pbFormat)->wFormatTag == WAVE_FORMAT_DOLBY_AC3_SPDIF) {
+ return __super::CreateNewOutputMediaType(mt, cbBuffer);
+ }
+
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)pInPin->CurrentMediaType().pbFormat;
+
+ if (m_fCustomChannelMapping) {
+ m_chs[wfe->nChannels - 1].RemoveAll();
+
+ DWORD mask = DWORD((__int64(1) << wfe->nChannels) - 1);
+ for (int i = 0; i < 18; i++) {
+ if (m_pSpeakerToChannelMap[wfe->nChannels - 1][i]&mask) {
+ ChMap cm = {1 << i, m_pSpeakerToChannelMap[wfe->nChannels - 1][i]};
+ m_chs[wfe->nChannels - 1].Add(cm);
+ }
+ }
+
+ if (m_chs[wfe->nChannels - 1].GetCount() > 0) {
+ mt.ReallocFormatBuffer(sizeof(WAVEFORMATEXTENSIBLE));
+ WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)mt.pbFormat;
+ wfex->Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX);
+ wfex->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
+ wfex->Samples.wValidBitsPerSample = wfe->wBitsPerSample;
+ wfex->SubFormat =
+ wfe->wFormatTag == WAVE_FORMAT_PCM ? KSDATAFORMAT_SUBTYPE_PCM :
+ wfe->wFormatTag == WAVE_FORMAT_IEEE_FLOAT ? KSDATAFORMAT_SUBTYPE_IEEE_FLOAT :
+ wfe->wFormatTag == WAVE_FORMAT_EXTENSIBLE ? ((WAVEFORMATEXTENSIBLE*)wfe)->SubFormat :
+ KSDATAFORMAT_SUBTYPE_PCM; // can't happen
+
+ wfex->dwChannelMask = 0;
+ for (size_t i = 0; i < m_chs[wfe->nChannels - 1].GetCount(); i++) {
+ wfex->dwChannelMask |= m_chs[wfe->nChannels - 1][i].Speaker;
+ }
+
+ wfex->Format.nChannels = (WORD)m_chs[wfe->nChannels - 1].GetCount();
+ wfex->Format.nBlockAlign = wfex->Format.nChannels * wfex->Format.wBitsPerSample >> 3;
+ wfex->Format.nAvgBytesPerSec = wfex->Format.nBlockAlign * wfex->Format.nSamplesPerSec;
+ }
+ }
+
+ WAVEFORMATEX* wfeout = (WAVEFORMATEX*)mt.pbFormat;
+
+ if (m_fDownSampleTo441) {
+ if (wfeout->nSamplesPerSec > 44100 && wfeout->wBitsPerSample <= 16) {
+ wfeout->nSamplesPerSec = 44100;
+ wfeout->nAvgBytesPerSec = wfeout->nBlockAlign * wfeout->nSamplesPerSec;
+ }
+ }
+
+ int bps = wfe->wBitsPerSample >> 3;
+ int len = cbBuffer / (bps * wfe->nChannels);
+ int lenout = len * wfeout->nSamplesPerSec / wfe->nSamplesPerSec;
+ cbBuffer = lenout * bps * wfeout->nChannels;
+
+ // mt.lSampleSize = (ULONG)max(mt.lSampleSize, wfe->nAvgBytesPerSec * rtLen / 10000000i64);
+ // mt.lSampleSize = (mt.lSampleSize + (wfe->nBlockAlign-1)) & ~(wfe->nBlockAlign-1);
+
+ return mt;
}
void CAudioSwitcherFilter::OnNewOutputMediaType(const CMediaType& mtIn, const CMediaType& mtOut)
{
- const WAVEFORMATEX* wfe = (WAVEFORMATEX*)mtIn.pbFormat;
- const WAVEFORMATEX* wfeout = (WAVEFORMATEX*)mtOut.pbFormat;
-
- m_pResamplers.RemoveAll();
- for (int i = 0; i < wfeout->nChannels; i++) {
- CAutoPtr<AudioStreamResampler> pResampler;
- pResampler.Attach(DNew AudioStreamResampler(wfeout->wBitsPerSample>>3, wfe->nSamplesPerSec, wfeout->nSamplesPerSec, true));
- m_pResamplers.Add(pResampler);
- }
-
- TRACE(_T("CAudioSwitcherFilter::OnNewOutputMediaType\n"));
- m_sample_max = 0.1f;
+ const WAVEFORMATEX* wfe = (WAVEFORMATEX*)mtIn.pbFormat;
+ const WAVEFORMATEX* wfeout = (WAVEFORMATEX*)mtOut.pbFormat;
+
+ m_pResamplers.RemoveAll();
+ for (int i = 0; i < wfeout->nChannels; i++) {
+ CAutoPtr<AudioStreamResampler> pResampler;
+ pResampler.Attach(DNew AudioStreamResampler(wfeout->wBitsPerSample >> 3, wfe->nSamplesPerSec, wfeout->nSamplesPerSec, true));
+ m_pResamplers.Add(pResampler);
+ }
+
+ TRACE(_T("CAudioSwitcherFilter::OnNewOutputMediaType\n"));
+ m_sample_max = 0.1f;
}
HRESULT CAudioSwitcherFilter::DeliverEndFlush()
{
- TRACE(_T("CAudioSwitcherFilter::DeliverEndFlush\n"));
- m_sample_max = 0.1f;
- return __super::DeliverEndFlush();
+ TRACE(_T("CAudioSwitcherFilter::DeliverEndFlush\n"));
+ m_sample_max = 0.1f;
+ return __super::DeliverEndFlush();
}
HRESULT CAudioSwitcherFilter::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- TRACE(_T("CAudioSwitcherFilter::DeliverNewSegment\n"));
- m_sample_max = 0.1f;
- return __super::DeliverNewSegment(tStart, tStop, dRate);
+ TRACE(_T("CAudioSwitcherFilter::DeliverNewSegment\n"));
+ m_sample_max = 0.1f;
+ return __super::DeliverNewSegment(tStart, tStop, dRate);
}
// IAudioSwitcherFilter
STDMETHODIMP CAudioSwitcherFilter::GetInputSpeakerConfig(DWORD* pdwChannelMask)
{
- if (!pdwChannelMask) {
- return E_POINTER;
- }
+ if (!pdwChannelMask) {
+ return E_POINTER;
+ }
- *pdwChannelMask = 0;
+ *pdwChannelMask = 0;
- CStreamSwitcherInputPin* pInPin = GetInputPin();
- if (!pInPin || !pInPin->IsConnected()) {
- return E_UNEXPECTED;
- }
+ CStreamSwitcherInputPin* pInPin = GetInputPin();
+ if (!pInPin || !pInPin->IsConnected()) {
+ return E_UNEXPECTED;
+ }
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)pInPin->CurrentMediaType().pbFormat;
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)pInPin->CurrentMediaType().pbFormat;
- if (wfe->wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
- WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)wfe;
- *pdwChannelMask = wfex->dwChannelMask;
- } else {
- *pdwChannelMask = 0/*wfe->nChannels == 1 ? 4 : wfe->nChannels == 2 ? 3 : 0*/;
- }
+ if (wfe->wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
+ WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)wfe;
+ *pdwChannelMask = wfex->dwChannelMask;
+ } else {
+ *pdwChannelMask = 0/*wfe->nChannels == 1 ? 4 : wfe->nChannels == 2 ? 3 : 0*/;
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CAudioSwitcherFilter::GetSpeakerConfig(bool* pfCustomChannelMapping, DWORD pSpeakerToChannelMap[18][18])
{
- if (pfCustomChannelMapping) {
- *pfCustomChannelMapping = m_fCustomChannelMapping;
- }
- memcpy(pSpeakerToChannelMap, m_pSpeakerToChannelMap, sizeof(m_pSpeakerToChannelMap));
+ if (pfCustomChannelMapping) {
+ *pfCustomChannelMapping = m_fCustomChannelMapping;
+ }
+ memcpy(pSpeakerToChannelMap, m_pSpeakerToChannelMap, sizeof(m_pSpeakerToChannelMap));
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CAudioSwitcherFilter::SetSpeakerConfig(bool fCustomChannelMapping, DWORD pSpeakerToChannelMap[18][18])
{
- if (m_State == State_Stopped || m_fCustomChannelMapping != fCustomChannelMapping
- || memcmp(m_pSpeakerToChannelMap, pSpeakerToChannelMap, sizeof(m_pSpeakerToChannelMap))) {
- PauseGraph;
+ if (m_State == State_Stopped || m_fCustomChannelMapping != fCustomChannelMapping
+ || memcmp(m_pSpeakerToChannelMap, pSpeakerToChannelMap, sizeof(m_pSpeakerToChannelMap))) {
+ PauseGraph;
- CStreamSwitcherInputPin* pInput = GetInputPin();
+ CStreamSwitcherInputPin* pInput = GetInputPin();
- SelectInput(NULL);
+ SelectInput(NULL);
- m_fCustomChannelMapping = fCustomChannelMapping;
- memcpy(m_pSpeakerToChannelMap, pSpeakerToChannelMap, sizeof(m_pSpeakerToChannelMap));
+ m_fCustomChannelMapping = fCustomChannelMapping;
+ memcpy(m_pSpeakerToChannelMap, pSpeakerToChannelMap, sizeof(m_pSpeakerToChannelMap));
- SelectInput(pInput);
+ SelectInput(pInput);
- ResumeGraph;
- }
+ ResumeGraph;
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP_(int) CAudioSwitcherFilter::GetNumberOfInputChannels()
{
- CStreamSwitcherInputPin* pInPin = GetInputPin();
- return pInPin ? ((WAVEFORMATEX*)pInPin->CurrentMediaType().pbFormat)->nChannels : 0;
+ CStreamSwitcherInputPin* pInPin = GetInputPin();
+ return pInPin ? ((WAVEFORMATEX*)pInPin->CurrentMediaType().pbFormat)->nChannels : 0;
}
STDMETHODIMP_(bool) CAudioSwitcherFilter::IsDownSamplingTo441Enabled()
{
- return m_fDownSampleTo441;
+ return m_fDownSampleTo441;
}
STDMETHODIMP CAudioSwitcherFilter::EnableDownSamplingTo441(bool fEnable)
{
- if (m_fDownSampleTo441 != fEnable) {
- PauseGraph;
- m_fDownSampleTo441 = fEnable;
- ResumeGraph;
- }
+ if (m_fDownSampleTo441 != fEnable) {
+ PauseGraph;
+ m_fDownSampleTo441 = fEnable;
+ ResumeGraph;
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP_(REFERENCE_TIME) CAudioSwitcherFilter::GetAudioTimeShift()
{
- return m_rtAudioTimeShift;
+ return m_rtAudioTimeShift;
}
STDMETHODIMP CAudioSwitcherFilter::SetAudioTimeShift(REFERENCE_TIME rtAudioTimeShift)
{
- m_rtAudioTimeShift = rtAudioTimeShift;
- return S_OK;
+ m_rtAudioTimeShift = rtAudioTimeShift;
+ return S_OK;
}
STDMETHODIMP CAudioSwitcherFilter::GetNormalizeBoost(bool& fNormalize, bool& fNormalizeRecover, float& boost_dB)
{
- fNormalize = m_fNormalize;
- fNormalizeRecover = m_fNormalizeRecover;
- boost_dB = 20*log10(m_boost_mul);
- return S_OK;
+ fNormalize = m_fNormalize;
+ fNormalizeRecover = m_fNormalizeRecover;
+ boost_dB = 20 * log10(m_boost_mul);
+ return S_OK;
}
STDMETHODIMP CAudioSwitcherFilter::SetNormalizeBoost(bool fNormalize, bool fNormalizeRecover, float boost_dB)
{
- if (m_fNormalize != fNormalize) {
- m_sample_max = 0.1f;
- }
- m_fNormalize = fNormalize;
- m_fNormalizeRecover = fNormalizeRecover;
- m_boost_mul = pow(10.0f, boost_dB/20);
- return S_OK;
+ if (m_fNormalize != fNormalize) {
+ m_sample_max = 0.1f;
+ }
+ m_fNormalize = fNormalize;
+ m_fNormalizeRecover = fNormalizeRecover;
+ m_boost_mul = pow(10.0f, boost_dB / 20);
+ return S_OK;
}
// IAMStreamSelect
STDMETHODIMP CAudioSwitcherFilter::Enable(long lIndex, DWORD dwFlags)
{
- HRESULT hr = __super::Enable(lIndex, dwFlags);
- if (S_OK == hr) {
- m_sample_max = 0.1f;
- }
- return hr;
+ HRESULT hr = __super::Enable(lIndex, dwFlags);
+ if (S_OK == hr) {
+ m_sample_max = 0.1f;
+ }
+ return hr;
}
diff --git a/src/filters/switcher/AudioSwitcher/AudioSwitcher.h b/src/filters/switcher/AudioSwitcher/AudioSwitcher.h
index aa895355c..09006bce0 100644
--- a/src/filters/switcher/AudioSwitcher/AudioSwitcher.h
+++ b/src/filters/switcher/AudioSwitcher/AudioSwitcher.h
@@ -30,65 +30,65 @@
interface __declspec(uuid("CEDB2890-53AE-4231-91A3-B0AAFCD1DBDE"))
IAudioSwitcherFilter :
public IUnknown {
- STDMETHOD(GetInputSpeakerConfig) (DWORD* pdwChannelMask) = 0;
- STDMETHOD(GetSpeakerConfig) (bool* pfCustomChannelMapping, DWORD pSpeakerToChannelMap[18][18]) = 0;
- STDMETHOD(SetSpeakerConfig) (bool fCustomChannelMapping, DWORD pSpeakerToChannelMap[18][18]) = 0;
- STDMETHOD_(int, GetNumberOfInputChannels) () = 0;
- STDMETHOD_(bool, IsDownSamplingTo441Enabled) () = 0;
- STDMETHOD(EnableDownSamplingTo441) (bool fEnable) = 0;
- STDMETHOD_(REFERENCE_TIME, GetAudioTimeShift) () = 0;
- STDMETHOD(SetAudioTimeShift) (REFERENCE_TIME rtAudioTimeShift) = 0;
- STDMETHOD(GetNormalizeBoost) (bool& fNormalize, bool& fNormalizeRecover, float& boost) = 0;
- STDMETHOD(SetNormalizeBoost) (bool fNormalize, bool fNormalizeRecover, float boost) = 0;
+ STDMETHOD(GetInputSpeakerConfig)(DWORD * pdwChannelMask) = 0;
+ STDMETHOD(GetSpeakerConfig)(bool * pfCustomChannelMapping, DWORD pSpeakerToChannelMap[18][18]) = 0;
+ STDMETHOD(SetSpeakerConfig)(bool fCustomChannelMapping, DWORD pSpeakerToChannelMap[18][18]) = 0;
+ STDMETHOD_(int, GetNumberOfInputChannels)() = 0;
+ STDMETHOD_(bool, IsDownSamplingTo441Enabled)() = 0;
+ STDMETHOD(EnableDownSamplingTo441)(bool fEnable) = 0;
+ STDMETHOD_(REFERENCE_TIME, GetAudioTimeShift)() = 0;
+ STDMETHOD(SetAudioTimeShift)(REFERENCE_TIME rtAudioTimeShift) = 0;
+ STDMETHOD(GetNormalizeBoost)(bool & fNormalize, bool & fNormalizeRecover, float & boost) = 0;
+ STDMETHOD(SetNormalizeBoost)(bool fNormalize, bool fNormalizeRecover, float boost) = 0;
};
class AudioStreamResampler;
class __declspec(uuid("18C16B08-6497-420e-AD14-22D21C2CEAB7"))
- CAudioSwitcherFilter : public CStreamSwitcherFilter, public IAudioSwitcherFilter
+ CAudioSwitcherFilter : public CStreamSwitcherFilter, public IAudioSwitcherFilter
{
- typedef struct {
- DWORD Speaker, Channel;
- } ChMap;
- CAtlArray<ChMap> m_chs[18];
+ typedef struct {
+ DWORD Speaker, Channel;
+ } ChMap;
+ CAtlArray<ChMap> m_chs[18];
- bool m_fCustomChannelMapping;
- DWORD m_pSpeakerToChannelMap[18][18];
- bool m_fDownSampleTo441;
- REFERENCE_TIME m_rtAudioTimeShift;
- CAutoPtrArray<AudioStreamResampler> m_pResamplers;
- double m_sample_max;
- bool m_fNormalize, m_fNormalizeRecover;
- float m_boost_mul;
+ bool m_fCustomChannelMapping;
+ DWORD m_pSpeakerToChannelMap[18][18];
+ bool m_fDownSampleTo441;
+ REFERENCE_TIME m_rtAudioTimeShift;
+ CAutoPtrArray<AudioStreamResampler> m_pResamplers;
+ double m_sample_max;
+ bool m_fNormalize, m_fNormalizeRecover;
+ float m_boost_mul;
- REFERENCE_TIME m_rtNextStart, m_rtNextStop;
+ REFERENCE_TIME m_rtNextStart, m_rtNextStop;
public:
- CAudioSwitcherFilter(LPUNKNOWN lpunk, HRESULT* phr);
+ CAudioSwitcherFilter(LPUNKNOWN lpunk, HRESULT* phr);
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- HRESULT CheckMediaType(const CMediaType* pmt);
- HRESULT Transform(IMediaSample* pIn, IMediaSample* pOut);
- CMediaType CreateNewOutputMediaType(CMediaType mt, long& cbBuffer);
- void OnNewOutputMediaType(const CMediaType& mtIn, const CMediaType& mtOut);
+ HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT Transform(IMediaSample* pIn, IMediaSample* pOut);
+ CMediaType CreateNewOutputMediaType(CMediaType mt, long& cbBuffer);
+ void OnNewOutputMediaType(const CMediaType& mtIn, const CMediaType& mtOut);
- HRESULT DeliverEndFlush();
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ HRESULT DeliverEndFlush();
+ HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
- // IAudioSwitcherFilter
- STDMETHODIMP GetInputSpeakerConfig(DWORD* pdwChannelMask);
- STDMETHODIMP GetSpeakerConfig(bool* pfCustomChannelMapping, DWORD pSpeakerToChannelMap[18][18]);
- STDMETHODIMP SetSpeakerConfig(bool fCustomChannelMapping, DWORD pSpeakerToChannelMap[18][18]);
- STDMETHODIMP_(int) GetNumberOfInputChannels();
- STDMETHODIMP_(bool) IsDownSamplingTo441Enabled();
- STDMETHODIMP EnableDownSamplingTo441(bool fEnable);
- STDMETHODIMP_(REFERENCE_TIME) GetAudioTimeShift();
- STDMETHODIMP SetAudioTimeShift(REFERENCE_TIME rtAudioTimeShift);
- STDMETHODIMP GetNormalizeBoost(bool& fNormalize, bool& fNormalizeRecover, float& boost);
- STDMETHODIMP SetNormalizeBoost(bool fNormalize, bool fNormalizeRecover, float boost);
+ // IAudioSwitcherFilter
+ STDMETHODIMP GetInputSpeakerConfig(DWORD* pdwChannelMask);
+ STDMETHODIMP GetSpeakerConfig(bool* pfCustomChannelMapping, DWORD pSpeakerToChannelMap[18][18]);
+ STDMETHODIMP SetSpeakerConfig(bool fCustomChannelMapping, DWORD pSpeakerToChannelMap[18][18]);
+ STDMETHODIMP_(int) GetNumberOfInputChannels();
+ STDMETHODIMP_(bool) IsDownSamplingTo441Enabled();
+ STDMETHODIMP EnableDownSamplingTo441(bool fEnable);
+ STDMETHODIMP_(REFERENCE_TIME) GetAudioTimeShift();
+ STDMETHODIMP SetAudioTimeShift(REFERENCE_TIME rtAudioTimeShift);
+ STDMETHODIMP GetNormalizeBoost(bool& fNormalize, bool& fNormalizeRecover, float& boost);
+ STDMETHODIMP SetNormalizeBoost(bool fNormalize, bool fNormalizeRecover, float boost);
- // IAMStreamSelect
- STDMETHODIMP Enable(long lIndex, DWORD dwFlags);
+ // IAMStreamSelect
+ STDMETHODIMP Enable(long lIndex, DWORD dwFlags);
};
diff --git a/src/filters/switcher/AudioSwitcher/StreamSwitcher.cpp b/src/filters/switcher/AudioSwitcher/StreamSwitcher.cpp
index 4b40e604e..ffa66a1b7 100644
--- a/src/filters/switcher/AudioSwitcher/StreamSwitcher.cpp
+++ b/src/filters/switcher/AudioSwitcher/StreamSwitcher.cpp
@@ -45,42 +45,42 @@
//
CStreamSwitcherPassThru::CStreamSwitcherPassThru(LPUNKNOWN pUnk, HRESULT* phr, CStreamSwitcherFilter* pFilter)
- : CMediaPosition(NAME("CStreamSwitcherPassThru"), pUnk)
- , m_pFilter(pFilter)
+ : CMediaPosition(NAME("CStreamSwitcherPassThru"), pUnk)
+ , m_pFilter(pFilter)
{
}
STDMETHODIMP CStreamSwitcherPassThru::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
- *ppv = NULL;
+ CheckPointer(ppv, E_POINTER);
+ *ppv = NULL;
- return
- QI(IMediaSeeking)
- CMediaPosition::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IMediaSeeking)
+ CMediaPosition::NonDelegatingQueryInterface(riid, ppv);
}
template<class T>
HRESULT GetPeer(CStreamSwitcherFilter* pFilter, T** ppT)
{
- *ppT = NULL;
+ *ppT = NULL;
- CBasePin* pPin = pFilter->GetInputPin();
- if (!pPin) {
- return E_NOTIMPL;
- }
+ CBasePin* pPin = pFilter->GetInputPin();
+ if (!pPin) {
+ return E_NOTIMPL;
+ }
- CComPtr<IPin> pConnected;
- if (FAILED(pPin->ConnectedTo(&pConnected))) {
- return E_NOTIMPL;
- }
+ CComPtr<IPin> pConnected;
+ if (FAILED(pPin->ConnectedTo(&pConnected))) {
+ return E_NOTIMPL;
+ }
- if (CComQIPtr<T> pT = pConnected) {
- *ppT = pT.Detach();
- return S_OK;
- }
+ if (CComQIPtr<T> pT = pConnected) {
+ *ppT = pT.Detach();
+ return S_OK;
+ }
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
@@ -135,150 +135,150 @@ HRESULT GetPeer(CStreamSwitcherFilter* pFilter, T** ppT)
STDMETHODIMP CStreamSwitcherPassThru::GetCapabilities(DWORD* pCaps)
{
- CallPeerSeeking(GetCapabilities(pCaps));
+ CallPeerSeeking(GetCapabilities(pCaps));
}
STDMETHODIMP CStreamSwitcherPassThru::CheckCapabilities(DWORD* pCaps)
{
- CallPeerSeeking(CheckCapabilities(pCaps));
+ CallPeerSeeking(CheckCapabilities(pCaps));
}
STDMETHODIMP CStreamSwitcherPassThru::IsFormatSupported(const GUID* pFormat)
{
- CallPeerSeeking(IsFormatSupported(pFormat));
+ CallPeerSeeking(IsFormatSupported(pFormat));
}
STDMETHODIMP CStreamSwitcherPassThru::QueryPreferredFormat(GUID* pFormat)
{
- CallPeerSeeking(QueryPreferredFormat(pFormat));
+ CallPeerSeeking(QueryPreferredFormat(pFormat));
}
STDMETHODIMP CStreamSwitcherPassThru::SetTimeFormat(const GUID* pFormat)
{
- CallPeerSeeking(SetTimeFormat(pFormat));
+ CallPeerSeeking(SetTimeFormat(pFormat));
}
STDMETHODIMP CStreamSwitcherPassThru::GetTimeFormat(GUID* pFormat)
{
- CallPeerSeeking(GetTimeFormat(pFormat));
+ CallPeerSeeking(GetTimeFormat(pFormat));
}
STDMETHODIMP CStreamSwitcherPassThru::IsUsingTimeFormat(const GUID* pFormat)
{
- CallPeerSeeking(IsUsingTimeFormat(pFormat));
+ CallPeerSeeking(IsUsingTimeFormat(pFormat));
}
STDMETHODIMP CStreamSwitcherPassThru::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat)
{
- CallPeerSeeking(ConvertTimeFormat(pTarget, pTargetFormat, Source, pSourceFormat));
+ CallPeerSeeking(ConvertTimeFormat(pTarget, pTargetFormat, Source, pSourceFormat));
}
STDMETHODIMP CStreamSwitcherPassThru::SetPositions(LONGLONG* pCurrent, DWORD CurrentFlags, LONGLONG* pStop, DWORD StopFlags)
{
- CallPeerSeekingAll(SetPositions(pCurrent, CurrentFlags, pStop, StopFlags));
+ CallPeerSeekingAll(SetPositions(pCurrent, CurrentFlags, pStop, StopFlags));
}
STDMETHODIMP CStreamSwitcherPassThru::GetPositions(LONGLONG* pCurrent, LONGLONG* pStop)
{
- CallPeerSeeking(GetPositions(pCurrent, pStop));
+ CallPeerSeeking(GetPositions(pCurrent, pStop));
}
STDMETHODIMP CStreamSwitcherPassThru::GetCurrentPosition(LONGLONG* pCurrent)
{
- CallPeerSeeking(GetCurrentPosition(pCurrent));
+ CallPeerSeeking(GetCurrentPosition(pCurrent));
}
STDMETHODIMP CStreamSwitcherPassThru::GetStopPosition(LONGLONG* pStop)
{
- CallPeerSeeking(GetStopPosition(pStop));
+ CallPeerSeeking(GetStopPosition(pStop));
}
STDMETHODIMP CStreamSwitcherPassThru::GetDuration(LONGLONG* pDuration)
{
- CallPeerSeeking(GetDuration(pDuration));
+ CallPeerSeeking(GetDuration(pDuration));
}
STDMETHODIMP CStreamSwitcherPassThru::GetPreroll(LONGLONG* pllPreroll)
{
- CallPeerSeeking(GetPreroll(pllPreroll));
+ CallPeerSeeking(GetPreroll(pllPreroll));
}
STDMETHODIMP CStreamSwitcherPassThru::GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest)
{
- CallPeerSeeking(GetAvailable(pEarliest, pLatest));
+ CallPeerSeeking(GetAvailable(pEarliest, pLatest));
}
STDMETHODIMP CStreamSwitcherPassThru::GetRate(double* pdRate)
{
- CallPeerSeeking(GetRate(pdRate));
+ CallPeerSeeking(GetRate(pdRate));
}
STDMETHODIMP CStreamSwitcherPassThru::SetRate(double dRate)
{
- if (0.0 == dRate) {
- return E_INVALIDARG;
- }
- CallPeerSeekingAll(SetRate(dRate));
+ if (0.0 == dRate) {
+ return E_INVALIDARG;
+ }
+ CallPeerSeekingAll(SetRate(dRate));
}
// IMediaPosition
STDMETHODIMP CStreamSwitcherPassThru::get_Duration(REFTIME* plength)
{
- CallPeer(get_Duration(plength));
+ CallPeer(get_Duration(plength));
}
STDMETHODIMP CStreamSwitcherPassThru::get_CurrentPosition(REFTIME* pllTime)
{
- CallPeer(get_CurrentPosition(pllTime));
+ CallPeer(get_CurrentPosition(pllTime));
}
STDMETHODIMP CStreamSwitcherPassThru::put_CurrentPosition(REFTIME llTime)
{
- CallPeerAll(put_CurrentPosition(llTime));
+ CallPeerAll(put_CurrentPosition(llTime));
}
STDMETHODIMP CStreamSwitcherPassThru::get_StopTime(REFTIME* pllTime)
{
- CallPeer(get_StopTime(pllTime));
+ CallPeer(get_StopTime(pllTime));
}
STDMETHODIMP CStreamSwitcherPassThru::put_StopTime(REFTIME llTime)
{
- CallPeerAll(put_StopTime(llTime));
+ CallPeerAll(put_StopTime(llTime));
}
-STDMETHODIMP CStreamSwitcherPassThru::get_PrerollTime(REFTIME * pllTime)
+STDMETHODIMP CStreamSwitcherPassThru::get_PrerollTime(REFTIME* pllTime)
{
- CallPeer(get_PrerollTime(pllTime));
+ CallPeer(get_PrerollTime(pllTime));
}
STDMETHODIMP CStreamSwitcherPassThru::put_PrerollTime(REFTIME llTime)
{
- CallPeerAll(put_PrerollTime(llTime));
+ CallPeerAll(put_PrerollTime(llTime));
}
STDMETHODIMP CStreamSwitcherPassThru::get_Rate(double* pdRate)
{
- CallPeer(get_Rate(pdRate));
+ CallPeer(get_Rate(pdRate));
}
STDMETHODIMP CStreamSwitcherPassThru::put_Rate(double dRate)
{
- if (0.0 == dRate) {
- return E_INVALIDARG;
- }
- CallPeerAll(put_Rate(dRate));
+ if (0.0 == dRate) {
+ return E_INVALIDARG;
+ }
+ CallPeerAll(put_Rate(dRate));
}
STDMETHODIMP CStreamSwitcherPassThru::CanSeekForward(LONG* pCanSeekForward)
{
- CallPeer(CanSeekForward(pCanSeekForward));
+ CallPeer(CanSeekForward(pCanSeekForward));
}
STDMETHODIMP CStreamSwitcherPassThru::CanSeekBackward(LONG* pCanSeekBackward)
{
- CallPeer(CanSeekBackward(pCanSeekBackward));
+ CallPeer(CanSeekBackward(pCanSeekBackward));
}
//
@@ -286,96 +286,96 @@ STDMETHODIMP CStreamSwitcherPassThru::CanSeekBackward(LONG* pCanSeekBackward)
//
CStreamSwitcherAllocator::CStreamSwitcherAllocator(CStreamSwitcherInputPin* pPin, HRESULT* phr)
- : CMemAllocator(NAME("CStreamSwitcherAllocator"), NULL, phr)
- , m_pPin(pPin)
- , m_fMediaTypeChanged(false)
+ : CMemAllocator(NAME("CStreamSwitcherAllocator"), NULL, phr)
+ , m_pPin(pPin)
+ , m_fMediaTypeChanged(false)
{
- ASSERT(phr);
- ASSERT(pPin);
+ ASSERT(phr);
+ ASSERT(pPin);
}
#ifdef _DEBUG
CStreamSwitcherAllocator::~CStreamSwitcherAllocator()
{
- ASSERT(m_bCommitted == FALSE);
+ ASSERT(m_bCommitted == FALSE);
}
#endif
STDMETHODIMP_(ULONG) CStreamSwitcherAllocator::NonDelegatingAddRef()
{
- return m_pPin->m_pFilter->AddRef();
+ return m_pPin->m_pFilter->AddRef();
}
STDMETHODIMP_(ULONG) CStreamSwitcherAllocator::NonDelegatingRelease()
{
- return m_pPin->m_pFilter->Release();
+ return m_pPin->m_pFilter->Release();
}
STDMETHODIMP CStreamSwitcherAllocator::GetBuffer(
- IMediaSample** ppBuffer,
- REFERENCE_TIME* pStartTime, REFERENCE_TIME* pEndTime,
- DWORD dwFlags)
-{
- HRESULT hr = VFW_E_NOT_COMMITTED;
-
- if (!m_bCommitted) {
- return hr;
- }
- /*
- TRACE(_T("CStreamSwitcherAllocator::GetBuffer m_pPin->m_evBlock.Wait() + %x\n"), this);
- m_pPin->m_evBlock.Wait();
- TRACE(_T("CStreamSwitcherAllocator::GetBuffer m_pPin->m_evBlock.Wait() - %x\n"), this);
- */
- if (m_fMediaTypeChanged) {
- if (!m_pPin || !m_pPin->m_pFilter) {
- return hr;
- }
-
- CStreamSwitcherOutputPin* pOut = (static_cast<CStreamSwitcherFilter*>(m_pPin->m_pFilter))->GetOutputPin();
- if (!pOut || !pOut->CurrentAllocator()) {
- return hr;
- }
-
- ALLOCATOR_PROPERTIES Properties, Actual;
- if (FAILED(pOut->CurrentAllocator()->GetProperties(&Actual))) {
- return hr;
- }
- if (FAILED(GetProperties(&Properties))) {
- return hr;
- }
-
- if (!m_bCommitted || Properties.cbBuffer < Actual.cbBuffer) {
- Properties.cbBuffer = Actual.cbBuffer;
- if (FAILED(Decommit())) {
- return hr;
- }
- if (FAILED(SetProperties(&Properties, &Actual))) {
- return hr;
- }
- if (FAILED(Commit())) {
- return hr;
- }
- ASSERT(Actual.cbBuffer >= Properties.cbBuffer);
- if (Actual.cbBuffer < Properties.cbBuffer) {
- return hr;
- }
- }
- }
-
- hr = CMemAllocator::GetBuffer(ppBuffer, pStartTime, pEndTime, dwFlags);
-
- if (m_fMediaTypeChanged && SUCCEEDED(hr)) {
- (*ppBuffer)->SetMediaType(&m_mt);
- m_fMediaTypeChanged = false;
- }
-
- return hr;
+ IMediaSample** ppBuffer,
+ REFERENCE_TIME* pStartTime, REFERENCE_TIME* pEndTime,
+ DWORD dwFlags)
+{
+ HRESULT hr = VFW_E_NOT_COMMITTED;
+
+ if (!m_bCommitted) {
+ return hr;
+ }
+ /*
+ TRACE(_T("CStreamSwitcherAllocator::GetBuffer m_pPin->m_evBlock.Wait() + %x\n"), this);
+ m_pPin->m_evBlock.Wait();
+ TRACE(_T("CStreamSwitcherAllocator::GetBuffer m_pPin->m_evBlock.Wait() - %x\n"), this);
+ */
+ if (m_fMediaTypeChanged) {
+ if (!m_pPin || !m_pPin->m_pFilter) {
+ return hr;
+ }
+
+ CStreamSwitcherOutputPin* pOut = (static_cast<CStreamSwitcherFilter*>(m_pPin->m_pFilter))->GetOutputPin();
+ if (!pOut || !pOut->CurrentAllocator()) {
+ return hr;
+ }
+
+ ALLOCATOR_PROPERTIES Properties, Actual;
+ if (FAILED(pOut->CurrentAllocator()->GetProperties(&Actual))) {
+ return hr;
+ }
+ if (FAILED(GetProperties(&Properties))) {
+ return hr;
+ }
+
+ if (!m_bCommitted || Properties.cbBuffer < Actual.cbBuffer) {
+ Properties.cbBuffer = Actual.cbBuffer;
+ if (FAILED(Decommit())) {
+ return hr;
+ }
+ if (FAILED(SetProperties(&Properties, &Actual))) {
+ return hr;
+ }
+ if (FAILED(Commit())) {
+ return hr;
+ }
+ ASSERT(Actual.cbBuffer >= Properties.cbBuffer);
+ if (Actual.cbBuffer < Properties.cbBuffer) {
+ return hr;
+ }
+ }
+ }
+
+ hr = CMemAllocator::GetBuffer(ppBuffer, pStartTime, pEndTime, dwFlags);
+
+ if (m_fMediaTypeChanged && SUCCEEDED(hr)) {
+ (*ppBuffer)->SetMediaType(&m_mt);
+ m_fMediaTypeChanged = false;
+ }
+
+ return hr;
}
void CStreamSwitcherAllocator::NotifyMediaType(const CMediaType& mt)
{
- CopyMediaType(&m_mt, &mt);
- m_fMediaTypeChanged = true;
+ CopyMediaType(&m_mt, &mt);
+ m_fMediaTypeChanged = true;
}
@@ -384,565 +384,565 @@ void CStreamSwitcherAllocator::NotifyMediaType(const CMediaType& mt)
//
CStreamSwitcherInputPin::CStreamSwitcherInputPin(CStreamSwitcherFilter* pFilter, HRESULT* phr, LPCWSTR pName)
- : CBaseInputPin(NAME("CStreamSwitcherInputPin"), pFilter, &pFilter->m_csState, phr, pName)
- , m_Allocator(this, phr)
- , m_bSampleSkipped(FALSE)
- , m_bQualityChanged(FALSE)
- , m_bUsingOwnAllocator(FALSE)
- , m_evBlock(TRUE)
- , m_fCanBlock(false)
- , m_hNotifyEvent(NULL)
+ : CBaseInputPin(NAME("CStreamSwitcherInputPin"), pFilter, &pFilter->m_csState, phr, pName)
+ , m_Allocator(this, phr)
+ , m_bSampleSkipped(FALSE)
+ , m_bQualityChanged(FALSE)
+ , m_bUsingOwnAllocator(FALSE)
+ , m_evBlock(TRUE)
+ , m_fCanBlock(false)
+ , m_hNotifyEvent(NULL)
{
- m_bCanReconnectWhenActive = TRUE;
+ m_bCanReconnectWhenActive = TRUE;
}
class __declspec(uuid("138130AF-A79B-45D5-B4AA-87697457BA87"))
- NeroAudioDecoder {};
+ NeroAudioDecoder {};
STDMETHODIMP CStreamSwitcherInputPin::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- return
- QI(IStreamSwitcherInputPin)
- IsConnected() && GetCLSID(GetFilterFromPin(GetConnected())) == __uuidof(NeroAudioDecoder) && QI(IPinConnection)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IStreamSwitcherInputPin)
+ IsConnected() && GetCLSID(GetFilterFromPin(GetConnected())) == __uuidof(NeroAudioDecoder) && QI(IPinConnection)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// IPinConnection
STDMETHODIMP CStreamSwitcherInputPin::DynamicQueryAccept(const AM_MEDIA_TYPE* pmt)
{
- return QueryAccept(pmt);
+ return QueryAccept(pmt);
}
STDMETHODIMP CStreamSwitcherInputPin::NotifyEndOfStream(HANDLE hNotifyEvent)
{
- if (m_hNotifyEvent) {
- SetEvent(m_hNotifyEvent);
- }
- m_hNotifyEvent = hNotifyEvent;
- return S_OK;
+ if (m_hNotifyEvent) {
+ SetEvent(m_hNotifyEvent);
+ }
+ m_hNotifyEvent = hNotifyEvent;
+ return S_OK;
}
STDMETHODIMP CStreamSwitcherInputPin::IsEndPin()
{
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CStreamSwitcherInputPin::DynamicDisconnect()
{
- CAutoLock cAutoLock(&m_csReceive);
- Disconnect();
- return S_OK;
+ CAutoLock cAutoLock(&m_csReceive);
+ Disconnect();
+ return S_OK;
}
// IStreamSwitcherInputPin
STDMETHODIMP_(bool) CStreamSwitcherInputPin::IsActive()
{
- // TODO: lock onto something here
- return (this == (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetInputPin());
+ // TODO: lock onto something here
+ return (this == (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetInputPin());
}
//
HRESULT CStreamSwitcherInputPin::QueryAcceptDownstream(const AM_MEDIA_TYPE* pmt)
{
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- CStreamSwitcherOutputPin* pOut = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetOutputPin();
+ CStreamSwitcherOutputPin* pOut = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetOutputPin();
- if (pOut && pOut->IsConnected()) {
- if (CComPtr<IPinConnection> pPC = pOut->CurrentPinConnection()) {
- hr = pPC->DynamicQueryAccept(pmt);
- if (hr == S_OK) {
- return S_OK;
- }
- }
+ if (pOut && pOut->IsConnected()) {
+ if (CComPtr<IPinConnection> pPC = pOut->CurrentPinConnection()) {
+ hr = pPC->DynamicQueryAccept(pmt);
+ if (hr == S_OK) {
+ return S_OK;
+ }
+ }
- hr = pOut->GetConnected()->QueryAccept(pmt);
- }
+ hr = pOut->GetConnected()->QueryAccept(pmt);
+ }
- return hr;
+ return hr;
}
void CStreamSwitcherInputPin::Block(bool fBlock)
{
- if (fBlock) {
- m_evBlock.Reset();
- } else {
- m_evBlock.Set();
- }
+ if (fBlock) {
+ m_evBlock.Reset();
+ } else {
+ m_evBlock.Set();
+ }
}
HRESULT CStreamSwitcherInputPin::InitializeOutputSample(IMediaSample* pInSample, IMediaSample** ppOutSample)
{
- if (!pInSample || !ppOutSample) {
- return E_POINTER;
- }
+ if (!pInSample || !ppOutSample) {
+ return E_POINTER;
+ }
- CStreamSwitcherOutputPin* pOut = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetOutputPin();
- ASSERT(pOut->GetConnected());
+ CStreamSwitcherOutputPin* pOut = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetOutputPin();
+ ASSERT(pOut->GetConnected());
- CComPtr<IMediaSample> pOutSample;
+ CComPtr<IMediaSample> pOutSample;
- DWORD dwFlags = m_bSampleSkipped ? AM_GBF_PREVFRAMESKIPPED : 0;
+ DWORD dwFlags = m_bSampleSkipped ? AM_GBF_PREVFRAMESKIPPED : 0;
- if (!(m_SampleProps.dwSampleFlags & AM_SAMPLE_SPLICEPOINT)) {
- dwFlags |= AM_GBF_NOTASYNCPOINT;
- }
+ if (!(m_SampleProps.dwSampleFlags & AM_SAMPLE_SPLICEPOINT)) {
+ dwFlags |= AM_GBF_NOTASYNCPOINT;
+ }
- HRESULT hr = pOut->GetDeliveryBuffer(&pOutSample
- , m_SampleProps.dwSampleFlags & AM_SAMPLE_TIMEVALID ? &m_SampleProps.tStart : NULL
- , m_SampleProps.dwSampleFlags & AM_SAMPLE_STOPVALID ? &m_SampleProps.tStop : NULL
- , dwFlags);
+ HRESULT hr = pOut->GetDeliveryBuffer(&pOutSample
+ , m_SampleProps.dwSampleFlags & AM_SAMPLE_TIMEVALID ? &m_SampleProps.tStart : NULL
+ , m_SampleProps.dwSampleFlags & AM_SAMPLE_STOPVALID ? &m_SampleProps.tStop : NULL
+ , dwFlags);
- if (FAILED(hr)) {
- return hr;
- }
+ if (FAILED(hr)) {
+ return hr;
+ }
- if (!pOutSample) {
- return E_FAIL;
- }
+ if (!pOutSample) {
+ return E_FAIL;
+ }
- if (CComQIPtr<IMediaSample2> pOutSample2 = pOutSample) {
- AM_SAMPLE2_PROPERTIES OutProps;
- EXECUTE_ASSERT(SUCCEEDED(pOutSample2->GetProperties(FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, tStart), (PBYTE)&OutProps)));
- OutProps.dwTypeSpecificFlags = m_SampleProps.dwTypeSpecificFlags;
- OutProps.dwSampleFlags =
- (OutProps.dwSampleFlags & AM_SAMPLE_TYPECHANGED) |
- (m_SampleProps.dwSampleFlags & ~AM_SAMPLE_TYPECHANGED);
+ if (CComQIPtr<IMediaSample2> pOutSample2 = pOutSample) {
+ AM_SAMPLE2_PROPERTIES OutProps;
+ EXECUTE_ASSERT(SUCCEEDED(pOutSample2->GetProperties(FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, tStart), (PBYTE)&OutProps)));
+ OutProps.dwTypeSpecificFlags = m_SampleProps.dwTypeSpecificFlags;
+ OutProps.dwSampleFlags =
+ (OutProps.dwSampleFlags & AM_SAMPLE_TYPECHANGED) |
+ (m_SampleProps.dwSampleFlags & ~AM_SAMPLE_TYPECHANGED);
- OutProps.tStart = m_SampleProps.tStart;
- OutProps.tStop = m_SampleProps.tStop;
- OutProps.cbData = FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, dwStreamId);
+ OutProps.tStart = m_SampleProps.tStart;
+ OutProps.tStop = m_SampleProps.tStop;
+ OutProps.cbData = FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, dwStreamId);
- hr = pOutSample2->SetProperties(FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, dwStreamId), (PBYTE)&OutProps);
- if (m_SampleProps.dwSampleFlags & AM_SAMPLE_DATADISCONTINUITY) {
- m_bSampleSkipped = FALSE;
- }
- } else {
- if (m_SampleProps.dwSampleFlags & AM_SAMPLE_TIMEVALID) {
- pOutSample->SetTime(&m_SampleProps.tStart, &m_SampleProps.tStop);
- }
+ hr = pOutSample2->SetProperties(FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, dwStreamId), (PBYTE)&OutProps);
+ if (m_SampleProps.dwSampleFlags & AM_SAMPLE_DATADISCONTINUITY) {
+ m_bSampleSkipped = FALSE;
+ }
+ } else {
+ if (m_SampleProps.dwSampleFlags & AM_SAMPLE_TIMEVALID) {
+ pOutSample->SetTime(&m_SampleProps.tStart, &m_SampleProps.tStop);
+ }
- if (m_SampleProps.dwSampleFlags & AM_SAMPLE_SPLICEPOINT) {
- pOutSample->SetSyncPoint(TRUE);
- }
+ if (m_SampleProps.dwSampleFlags & AM_SAMPLE_SPLICEPOINT) {
+ pOutSample->SetSyncPoint(TRUE);
+ }
- if (m_SampleProps.dwSampleFlags & AM_SAMPLE_DATADISCONTINUITY) {
- pOutSample->SetDiscontinuity(TRUE);
- m_bSampleSkipped = FALSE;
- }
+ if (m_SampleProps.dwSampleFlags & AM_SAMPLE_DATADISCONTINUITY) {
+ pOutSample->SetDiscontinuity(TRUE);
+ m_bSampleSkipped = FALSE;
+ }
- LONGLONG MediaStart, MediaEnd;
- if (pInSample->GetMediaTime(&MediaStart, &MediaEnd) == NOERROR) {
- pOutSample->SetMediaTime(&MediaStart, &MediaEnd);
- }
- }
+ LONGLONG MediaStart, MediaEnd;
+ if (pInSample->GetMediaTime(&MediaStart, &MediaEnd) == NOERROR) {
+ pOutSample->SetMediaTime(&MediaStart, &MediaEnd);
+ }
+ }
- *ppOutSample = pOutSample.Detach();
+ *ppOutSample = pOutSample.Detach();
- return S_OK;
+ return S_OK;
}
// pure virtual
HRESULT CStreamSwitcherInputPin::CheckMediaType(const CMediaType* pmt)
{
- return (static_cast<CStreamSwitcherFilter*>(m_pFilter))->CheckMediaType(pmt);
+ return (static_cast<CStreamSwitcherFilter*>(m_pFilter))->CheckMediaType(pmt);
}
// virtual
HRESULT CStreamSwitcherInputPin::CheckConnect(IPin* pPin)
{
- return (IPin*)(static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetOutputPin() == pPin
- ? E_FAIL
- : __super::CheckConnect(pPin);
+ return (IPin*)(static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetOutputPin() == pPin
+ ? E_FAIL
+ : __super::CheckConnect(pPin);
}
HRESULT CStreamSwitcherInputPin::CompleteConnect(IPin* pReceivePin)
{
- HRESULT hr = __super::CompleteConnect(pReceivePin);
- if (FAILED(hr)) {
- return hr;
- }
-
- (static_cast<CStreamSwitcherFilter*>(m_pFilter))->CompleteConnect(PINDIR_INPUT, this, pReceivePin);
-
- m_fCanBlock = false;
- bool fForkedSomewhere = false;
-
- CStringW fileName;
- CStringW pinName;
-
- IPin* pPin = (IPin*)this;
- IBaseFilter* pBF = (IBaseFilter*)m_pFilter;
-
- pPin = GetUpStreamPin(pBF, pPin);
- if (pPin) {
- pBF = GetFilterFromPin(pPin);
- }
- while (pPin && pBF) {
- if (IsSplitter(pBF)) {
- pinName = GetPinName(pPin);
- }
-
- CLSID clsid = GetCLSID(pBF);
- if (clsid == CLSID_AviSplitter || clsid == CLSID_OggSplitter) {
- m_fCanBlock = true;
- }
-
- int nIn, nOut, nInC, nOutC;
- CountPins(pBF, nIn, nOut, nInC, nOutC);
- fForkedSomewhere = fForkedSomewhere || nIn > 1 || nOut > 1;
-
- if (CComQIPtr<IFileSourceFilter> pFSF = pBF) {
- WCHAR* pszName = NULL;
- AM_MEDIA_TYPE mt;
- if (SUCCEEDED(pFSF->GetCurFile(&pszName, &mt)) && pszName) {
- fileName = pszName;
- CoTaskMemFree(pszName);
-
- fileName.Replace('\\', '/');
- CStringW fn = fileName.Mid(fileName.ReverseFind('/')+1);
- if (!fn.IsEmpty()) {
- fileName = fn;
- }
-
- // Haali & LAVFSplitter return only one "Audio" pin name, cause CMainFrame::OnInitMenuPopup lookup find the wrong popmenu,
- // add space at the end to prevent this, internal filter never return "Audio" only.
- if (!pinName.IsEmpty()) {
- fileName = pinName + L" ";
- }
-
- WCHAR* pName = DNew WCHAR[fileName.GetLength()+1];
- if (pName) {
- wcscpy_s(pName, fileName.GetLength() + 1, fileName);
- if (m_pName) {
- delete [] m_pName;
- }
- m_pName = pName;
- }
- }
-
- break;
- }
-
- pPin = GetFirstPin(pBF);
-
- pPin = GetUpStreamPin(pBF, pPin);
- if (pPin) {
- pBF = GetFilterFromPin(pPin);
- }
- }
-
- if (!fForkedSomewhere) {
- m_fCanBlock = true;
- }
-
- m_hNotifyEvent = NULL;
-
- return S_OK;
+ HRESULT hr = __super::CompleteConnect(pReceivePin);
+ if (FAILED(hr)) {
+ return hr;
+ }
+
+ (static_cast<CStreamSwitcherFilter*>(m_pFilter))->CompleteConnect(PINDIR_INPUT, this, pReceivePin);
+
+ m_fCanBlock = false;
+ bool fForkedSomewhere = false;
+
+ CStringW fileName;
+ CStringW pinName;
+
+ IPin* pPin = (IPin*)this;
+ IBaseFilter* pBF = (IBaseFilter*)m_pFilter;
+
+ pPin = GetUpStreamPin(pBF, pPin);
+ if (pPin) {
+ pBF = GetFilterFromPin(pPin);
+ }
+ while (pPin && pBF) {
+ if (IsSplitter(pBF)) {
+ pinName = GetPinName(pPin);
+ }
+
+ CLSID clsid = GetCLSID(pBF);
+ if (clsid == CLSID_AviSplitter || clsid == CLSID_OggSplitter) {
+ m_fCanBlock = true;
+ }
+
+ int nIn, nOut, nInC, nOutC;
+ CountPins(pBF, nIn, nOut, nInC, nOutC);
+ fForkedSomewhere = fForkedSomewhere || nIn > 1 || nOut > 1;
+
+ if (CComQIPtr<IFileSourceFilter> pFSF = pBF) {
+ WCHAR* pszName = NULL;
+ AM_MEDIA_TYPE mt;
+ if (SUCCEEDED(pFSF->GetCurFile(&pszName, &mt)) && pszName) {
+ fileName = pszName;
+ CoTaskMemFree(pszName);
+
+ fileName.Replace('\\', '/');
+ CStringW fn = fileName.Mid(fileName.ReverseFind('/') + 1);
+ if (!fn.IsEmpty()) {
+ fileName = fn;
+ }
+
+ // Haali & LAVFSplitter return only one "Audio" pin name, cause CMainFrame::OnInitMenuPopup lookup find the wrong popmenu,
+ // add space at the end to prevent this, internal filter never return "Audio" only.
+ if (!pinName.IsEmpty()) {
+ fileName = pinName + L" ";
+ }
+
+ WCHAR* pName = DNew WCHAR[fileName.GetLength() + 1];
+ if (pName) {
+ wcscpy_s(pName, fileName.GetLength() + 1, fileName);
+ if (m_pName) {
+ delete [] m_pName;
+ }
+ m_pName = pName;
+ }
+ }
+
+ break;
+ }
+
+ pPin = GetFirstPin(pBF);
+
+ pPin = GetUpStreamPin(pBF, pPin);
+ if (pPin) {
+ pBF = GetFilterFromPin(pPin);
+ }
+ }
+
+ if (!fForkedSomewhere) {
+ m_fCanBlock = true;
+ }
+
+ m_hNotifyEvent = NULL;
+
+ return S_OK;
}
HRESULT CStreamSwitcherInputPin::Active()
{
- Block(!IsActive());
+ Block(!IsActive());
- return __super::Active();
+ return __super::Active();
}
HRESULT CStreamSwitcherInputPin::Inactive()
{
- Block(false);
+ Block(false);
- return __super::Inactive();
+ return __super::Inactive();
}
// IPin
STDMETHODIMP CStreamSwitcherInputPin::QueryAccept(const AM_MEDIA_TYPE* pmt)
{
- HRESULT hr = __super::QueryAccept(pmt);
- if (S_OK != hr) {
- return hr;
- }
+ HRESULT hr = __super::QueryAccept(pmt);
+ if (S_OK != hr) {
+ return hr;
+ }
- return QueryAcceptDownstream(pmt);
+ return QueryAcceptDownstream(pmt);
}
STDMETHODIMP CStreamSwitcherInputPin::ReceiveConnection(IPin* pConnector, const AM_MEDIA_TYPE* pmt)
{
- // FIXME: this locked up once
- // CAutoLock cAutoLock(&((CStreamSwitcherFilter*)m_pFilter)->m_csReceive);
+ // FIXME: this locked up once
+ // CAutoLock cAutoLock(&((CStreamSwitcherFilter*)m_pFilter)->m_csReceive);
- HRESULT hr;
- if (S_OK != (hr = QueryAcceptDownstream(pmt))) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
+ HRESULT hr;
+ if (S_OK != (hr = QueryAcceptDownstream(pmt))) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
- if (m_Connected && m_Connected != pConnector) {
- return VFW_E_ALREADY_CONNECTED;
- }
+ if (m_Connected && m_Connected != pConnector) {
+ return VFW_E_ALREADY_CONNECTED;
+ }
- if (m_Connected) {
- m_Connected->Release(), m_Connected = NULL;
- }
+ if (m_Connected) {
+ m_Connected->Release(), m_Connected = NULL;
+ }
- return SUCCEEDED(__super::ReceiveConnection(pConnector, pmt)) ? S_OK : E_FAIL;
+ return SUCCEEDED(__super::ReceiveConnection(pConnector, pmt)) ? S_OK : E_FAIL;
}
STDMETHODIMP CStreamSwitcherInputPin::GetAllocator(IMemAllocator** ppAllocator)
{
- CheckPointer(ppAllocator, E_POINTER);
+ CheckPointer(ppAllocator, E_POINTER);
- if (m_pAllocator == NULL) {
- (m_pAllocator = &m_Allocator)->AddRef();
- }
+ if (m_pAllocator == NULL) {
+ (m_pAllocator = &m_Allocator)->AddRef();
+ }
- (*ppAllocator = m_pAllocator)->AddRef();
+ (*ppAllocator = m_pAllocator)->AddRef();
- return NOERROR;
+ return NOERROR;
}
STDMETHODIMP CStreamSwitcherInputPin::NotifyAllocator(IMemAllocator* pAllocator, BOOL bReadOnly)
{
- HRESULT hr = __super::NotifyAllocator(pAllocator, bReadOnly);
- if (FAILED(hr)) {
- return hr;
- }
+ HRESULT hr = __super::NotifyAllocator(pAllocator, bReadOnly);
+ if (FAILED(hr)) {
+ return hr;
+ }
- m_bUsingOwnAllocator = (pAllocator == (IMemAllocator*)&m_Allocator);
+ m_bUsingOwnAllocator = (pAllocator == (IMemAllocator*)&m_Allocator);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CStreamSwitcherInputPin::BeginFlush()
{
- CAutoLock cAutoLock(&(static_cast<CStreamSwitcherFilter*>(m_pFilter))->m_csState);
+ CAutoLock cAutoLock(&(static_cast<CStreamSwitcherFilter*>(m_pFilter))->m_csState);
- HRESULT hr;
+ HRESULT hr;
- CStreamSwitcherFilter* pSSF = static_cast<CStreamSwitcherFilter*>(m_pFilter);
+ CStreamSwitcherFilter* pSSF = static_cast<CStreamSwitcherFilter*>(m_pFilter);
- CStreamSwitcherOutputPin* pOut = pSSF->GetOutputPin();
- if (!IsConnected() || !pOut || !pOut->IsConnected()) {
- return VFW_E_NOT_CONNECTED;
- }
+ CStreamSwitcherOutputPin* pOut = pSSF->GetOutputPin();
+ if (!IsConnected() || !pOut || !pOut->IsConnected()) {
+ return VFW_E_NOT_CONNECTED;
+ }
- if (FAILED(hr = __super::BeginFlush())) {
- return hr;
- }
+ if (FAILED(hr = __super::BeginFlush())) {
+ return hr;
+ }
- return IsActive() ? pSSF->DeliverBeginFlush() : Block(false), S_OK;
+ return IsActive() ? pSSF->DeliverBeginFlush() : Block(false), S_OK;
}
STDMETHODIMP CStreamSwitcherInputPin::EndFlush()
{
- CAutoLock cAutoLock(&(static_cast<CStreamSwitcherFilter*>(m_pFilter))->m_csState);
+ CAutoLock cAutoLock(&(static_cast<CStreamSwitcherFilter*>(m_pFilter))->m_csState);
- HRESULT hr;
+ HRESULT hr;
- CStreamSwitcherFilter* pSSF = static_cast<CStreamSwitcherFilter*>(m_pFilter);
+ CStreamSwitcherFilter* pSSF = static_cast<CStreamSwitcherFilter*>(m_pFilter);
- CStreamSwitcherOutputPin* pOut = pSSF->GetOutputPin();
- if (!IsConnected() || !pOut || !pOut->IsConnected()) {
- return VFW_E_NOT_CONNECTED;
- }
+ CStreamSwitcherOutputPin* pOut = pSSF->GetOutputPin();
+ if (!IsConnected() || !pOut || !pOut->IsConnected()) {
+ return VFW_E_NOT_CONNECTED;
+ }
- if (FAILED(hr = __super::EndFlush())) {
- return hr;
- }
+ if (FAILED(hr = __super::EndFlush())) {
+ return hr;
+ }
- return IsActive() ? pSSF->DeliverEndFlush() : Block(true), S_OK;
+ return IsActive() ? pSSF->DeliverEndFlush() : Block(true), S_OK;
}
STDMETHODIMP CStreamSwitcherInputPin::EndOfStream()
{
- CAutoLock cAutoLock(&m_csReceive);
+ CAutoLock cAutoLock(&m_csReceive);
- CStreamSwitcherFilter* pSSF = static_cast<CStreamSwitcherFilter*>(m_pFilter);
+ CStreamSwitcherFilter* pSSF = static_cast<CStreamSwitcherFilter*>(m_pFilter);
- CStreamSwitcherOutputPin* pOut = pSSF->GetOutputPin();
- if (!IsConnected() || !pOut || !pOut->IsConnected()) {
- return VFW_E_NOT_CONNECTED;
- }
+ CStreamSwitcherOutputPin* pOut = pSSF->GetOutputPin();
+ if (!IsConnected() || !pOut || !pOut->IsConnected()) {
+ return VFW_E_NOT_CONNECTED;
+ }
- if (m_hNotifyEvent) {
- SetEvent(m_hNotifyEvent), m_hNotifyEvent = NULL;
- return S_OK;
- }
+ if (m_hNotifyEvent) {
+ SetEvent(m_hNotifyEvent), m_hNotifyEvent = NULL;
+ return S_OK;
+ }
- return IsActive() ? pSSF->DeliverEndOfStream() : S_OK;
+ return IsActive() ? pSSF->DeliverEndOfStream() : S_OK;
}
// IMemInputPin
STDMETHODIMP CStreamSwitcherInputPin::Receive(IMediaSample* pSample)
{
- AM_MEDIA_TYPE* pmt = NULL;
- if (SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
- const CMediaType mt(*pmt);
- DeleteMediaType(pmt), pmt = NULL;
- SetMediaType(&mt);
- }
+ AM_MEDIA_TYPE* pmt = NULL;
+ if (SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
+ const CMediaType mt(*pmt);
+ DeleteMediaType(pmt), pmt = NULL;
+ SetMediaType(&mt);
+ }
- // DAMN!!!!!! this doesn't work if the stream we are blocking
- // shares the same thread with another stream, mpeg splitters
- // are usually like that. Our nicely built up multithreaded
- // strategy is useless because of this, ARRRRRRGHHHHHH.
+ // DAMN!!!!!! this doesn't work if the stream we are blocking
+ // shares the same thread with another stream, mpeg splitters
+ // are usually like that. Our nicely built up multithreaded
+ // strategy is useless because of this, ARRRRRRGHHHHHH.
#ifdef BLOCKSTREAM
- if (m_fCanBlock) {
- m_evBlock.Wait();
- }
+ if (m_fCanBlock) {
+ m_evBlock.Wait();
+ }
#endif
- if (!IsActive()) {
+ if (!IsActive()) {
#ifdef BLOCKSTREAM
- if (m_fCanBlock) {
- return S_FALSE;
- }
+ if (m_fCanBlock) {
+ return S_FALSE;
+ }
#endif
- TRACE(_T("&^$#@ : a stupid fix for this stupid problem\n"));
- //Sleep(32);
- return E_FAIL; // a stupid fix for this stupid problem
- }
-
- CAutoLock cAutoLock(&m_csReceive);
-
- CStreamSwitcherOutputPin* pOut = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetOutputPin();
- ASSERT(pOut->GetConnected());
-
- HRESULT hr = __super::Receive(pSample);
- if (S_OK != hr) {
- return hr;
- }
-
- if (m_SampleProps.dwStreamId != AM_STREAM_MEDIA) {
- return pOut->Deliver(pSample);
- }
-
- //
-
- ALLOCATOR_PROPERTIES props, actual;
- hr = m_pAllocator->GetProperties(&props);
- hr = pOut->CurrentAllocator()->GetProperties(&actual);
-
- REFERENCE_TIME rtStart = 0, rtStop = 0;
- if (S_OK == pSample->GetTime(&rtStart, &rtStop)) {
- //
- }
-
- long cbBuffer = pSample->GetActualDataLength();
-
- CMediaType mtOut = m_mt;
- mtOut = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->CreateNewOutputMediaType(mtOut, cbBuffer);
-
- bool fTypeChanged = false;
-
- if (mtOut != pOut->CurrentMediaType() || cbBuffer > actual.cbBuffer) {
- fTypeChanged = true;
-
- m_SampleProps.dwSampleFlags |= AM_SAMPLE_TYPECHANGED/*|AM_SAMPLE_DATADISCONTINUITY|AM_SAMPLE_TIMEDISCONTINUITY*/;
-
- /*
- if (CComQIPtr<IPinConnection> pPC = pOut->CurrentPinConnection())
- {
- HANDLE hEOS = CreateEvent(NULL, FALSE, FALSE, NULL);
- hr = pPC->NotifyEndOfStream(hEOS);
- hr = pOut->DeliverEndOfStream();
- WaitForSingleObject(hEOS, 3000);
- CloseHandle(hEOS);
- hr = pOut->DeliverBeginFlush();
- hr = pOut->DeliverEndFlush();
- }
- */
-
- if (props.cBuffers < 8 && mtOut.majortype == MEDIATYPE_Audio) {
- props.cBuffers = 8;
- }
-
- props.cbBuffer = cbBuffer;
-
- if (actual.cbAlign != props.cbAlign
- || actual.cbPrefix != props.cbPrefix
- || actual.cBuffers < props.cBuffers
- || actual.cbBuffer < props.cbBuffer) {
- hr = pOut->DeliverBeginFlush();
- hr = pOut->DeliverEndFlush();
- hr = pOut->CurrentAllocator()->Decommit();
- hr = pOut->CurrentAllocator()->SetProperties(&props, &actual);
- hr = pOut->CurrentAllocator()->Commit();
- }
- }
-
- CComPtr<IMediaSample> pOutSample;
- if (FAILED(InitializeOutputSample(pSample, &pOutSample))) {
- return E_FAIL;
- }
-
- pmt = NULL;
- if (SUCCEEDED(pOutSample->GetMediaType(&pmt)) && pmt) {
- const CMediaType mt(*pmt);
- DeleteMediaType(pmt), pmt = NULL;
- // TODO
- ASSERT(0);
- }
-
- if (fTypeChanged) {
- pOut->SetMediaType(&mtOut);
- (static_cast<CStreamSwitcherFilter*>(m_pFilter))->OnNewOutputMediaType(m_mt, mtOut);
- pOutSample->SetMediaType(&mtOut);
- }
-
- // Transform
-
- hr = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->Transform(pSample, pOutSample);
-
- //
-
- if (S_OK == hr) {
- hr = pOut->Deliver(pOutSample);
- m_bSampleSkipped = FALSE;
- /*
- if (FAILED(hr))
- {
- ASSERT(0);
- }
- */
- } else if (S_FALSE == hr) {
- hr = S_OK;
- pOutSample = NULL;
- m_bSampleSkipped = TRUE;
-
- if (!m_bQualityChanged) {
- m_pFilter->NotifyEvent(EC_QUALITY_CHANGE, 0, 0);
- m_bQualityChanged = TRUE;
- }
- }
-
- return hr;
+ TRACE(_T("&^$#@ : a stupid fix for this stupid problem\n"));
+ //Sleep(32);
+ return E_FAIL; // a stupid fix for this stupid problem
+ }
+
+ CAutoLock cAutoLock(&m_csReceive);
+
+ CStreamSwitcherOutputPin* pOut = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetOutputPin();
+ ASSERT(pOut->GetConnected());
+
+ HRESULT hr = __super::Receive(pSample);
+ if (S_OK != hr) {
+ return hr;
+ }
+
+ if (m_SampleProps.dwStreamId != AM_STREAM_MEDIA) {
+ return pOut->Deliver(pSample);
+ }
+
+ //
+
+ ALLOCATOR_PROPERTIES props, actual;
+ hr = m_pAllocator->GetProperties(&props);
+ hr = pOut->CurrentAllocator()->GetProperties(&actual);
+
+ REFERENCE_TIME rtStart = 0, rtStop = 0;
+ if (S_OK == pSample->GetTime(&rtStart, &rtStop)) {
+ //
+ }
+
+ long cbBuffer = pSample->GetActualDataLength();
+
+ CMediaType mtOut = m_mt;
+ mtOut = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->CreateNewOutputMediaType(mtOut, cbBuffer);
+
+ bool fTypeChanged = false;
+
+ if (mtOut != pOut->CurrentMediaType() || cbBuffer > actual.cbBuffer) {
+ fTypeChanged = true;
+
+ m_SampleProps.dwSampleFlags |= AM_SAMPLE_TYPECHANGED/*|AM_SAMPLE_DATADISCONTINUITY|AM_SAMPLE_TIMEDISCONTINUITY*/;
+
+ /*
+ if (CComQIPtr<IPinConnection> pPC = pOut->CurrentPinConnection())
+ {
+ HANDLE hEOS = CreateEvent(NULL, FALSE, FALSE, NULL);
+ hr = pPC->NotifyEndOfStream(hEOS);
+ hr = pOut->DeliverEndOfStream();
+ WaitForSingleObject(hEOS, 3000);
+ CloseHandle(hEOS);
+ hr = pOut->DeliverBeginFlush();
+ hr = pOut->DeliverEndFlush();
+ }
+ */
+
+ if (props.cBuffers < 8 && mtOut.majortype == MEDIATYPE_Audio) {
+ props.cBuffers = 8;
+ }
+
+ props.cbBuffer = cbBuffer;
+
+ if (actual.cbAlign != props.cbAlign
+ || actual.cbPrefix != props.cbPrefix
+ || actual.cBuffers < props.cBuffers
+ || actual.cbBuffer < props.cbBuffer) {
+ hr = pOut->DeliverBeginFlush();
+ hr = pOut->DeliverEndFlush();
+ hr = pOut->CurrentAllocator()->Decommit();
+ hr = pOut->CurrentAllocator()->SetProperties(&props, &actual);
+ hr = pOut->CurrentAllocator()->Commit();
+ }
+ }
+
+ CComPtr<IMediaSample> pOutSample;
+ if (FAILED(InitializeOutputSample(pSample, &pOutSample))) {
+ return E_FAIL;
+ }
+
+ pmt = NULL;
+ if (SUCCEEDED(pOutSample->GetMediaType(&pmt)) && pmt) {
+ const CMediaType mt(*pmt);
+ DeleteMediaType(pmt), pmt = NULL;
+ // TODO
+ ASSERT(0);
+ }
+
+ if (fTypeChanged) {
+ pOut->SetMediaType(&mtOut);
+ (static_cast<CStreamSwitcherFilter*>(m_pFilter))->OnNewOutputMediaType(m_mt, mtOut);
+ pOutSample->SetMediaType(&mtOut);
+ }
+
+ // Transform
+
+ hr = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->Transform(pSample, pOutSample);
+
+ //
+
+ if (S_OK == hr) {
+ hr = pOut->Deliver(pOutSample);
+ m_bSampleSkipped = FALSE;
+ /*
+ if (FAILED(hr))
+ {
+ ASSERT(0);
+ }
+ */
+ } else if (S_FALSE == hr) {
+ hr = S_OK;
+ pOutSample = NULL;
+ m_bSampleSkipped = TRUE;
+
+ if (!m_bQualityChanged) {
+ m_pFilter->NotifyEvent(EC_QUALITY_CHANGE, 0, 0);
+ m_bQualityChanged = TRUE;
+ }
+ }
+
+ return hr;
}
STDMETHODIMP CStreamSwitcherInputPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- if (!IsConnected()) {
- return S_OK;
- }
+ if (!IsConnected()) {
+ return S_OK;
+ }
- CAutoLock cAutoLock(&m_csReceive);
+ CAutoLock cAutoLock(&m_csReceive);
- CStreamSwitcherFilter* pSSF = static_cast<CStreamSwitcherFilter*>(m_pFilter);
+ CStreamSwitcherFilter* pSSF = static_cast<CStreamSwitcherFilter*>(m_pFilter);
- CStreamSwitcherOutputPin* pOut = pSSF->GetOutputPin();
- if (!pOut || !pOut->IsConnected()) {
- return VFW_E_NOT_CONNECTED;
- }
+ CStreamSwitcherOutputPin* pOut = pSSF->GetOutputPin();
+ if (!pOut || !pOut->IsConnected()) {
+ return VFW_E_NOT_CONNECTED;
+ }
- return pSSF->DeliverNewSegment(tStart, tStop, dRate);
+ return pSSF->DeliverNewSegment(tStart, tStop, dRate);
}
//
@@ -950,206 +950,206 @@ STDMETHODIMP CStreamSwitcherInputPin::NewSegment(REFERENCE_TIME tStart, REFERENC
//
CStreamSwitcherOutputPin::CStreamSwitcherOutputPin(CStreamSwitcherFilter* pFilter, HRESULT* phr)
- : CBaseOutputPin(NAME("CStreamSwitcherOutputPin"), pFilter, &pFilter->m_csState, phr, L"Out")
+ : CBaseOutputPin(NAME("CStreamSwitcherOutputPin"), pFilter, &pFilter->m_csState, phr, L"Out")
{
- // m_bCanReconnectWhenActive = TRUE;
+ // m_bCanReconnectWhenActive = TRUE;
}
-STDMETHODIMP CStreamSwitcherOutputPin::NonDelegatingQueryInterface(REFIID riid, void **ppv)
+STDMETHODIMP CStreamSwitcherOutputPin::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv,E_POINTER);
- ValidateReadWritePtr(ppv, sizeof(PVOID));
- *ppv = NULL;
+ CheckPointer(ppv, E_POINTER);
+ ValidateReadWritePtr(ppv, sizeof(PVOID));
+ *ppv = NULL;
- if (riid == IID_IMediaPosition || riid == IID_IMediaSeeking) {
- if (m_pStreamSwitcherPassThru == NULL) {
- HRESULT hr = S_OK;
- m_pStreamSwitcherPassThru = (IUnknown*)(INonDelegatingUnknown*)
- DNew CStreamSwitcherPassThru(GetOwner(), &hr, static_cast<CStreamSwitcherFilter*>(m_pFilter));
+ if (riid == IID_IMediaPosition || riid == IID_IMediaSeeking) {
+ if (m_pStreamSwitcherPassThru == NULL) {
+ HRESULT hr = S_OK;
+ m_pStreamSwitcherPassThru = (IUnknown*)(INonDelegatingUnknown*)
+ DNew CStreamSwitcherPassThru(GetOwner(), &hr, static_cast<CStreamSwitcherFilter*>(m_pFilter));
- if (!m_pStreamSwitcherPassThru) {
- return E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- return hr;
- }
- }
+ if (!m_pStreamSwitcherPassThru) {
+ return E_OUTOFMEMORY;
+ }
+ if (FAILED(hr)) {
+ return hr;
+ }
+ }
- return m_pStreamSwitcherPassThru->QueryInterface(riid, ppv);
- }
- /*
- else if (riid == IID_IStreamBuilder)
- {
- return GetInterface((IStreamBuilder*)this, ppv);
- }
- */
- return CBaseOutputPin::NonDelegatingQueryInterface(riid, ppv);
+ return m_pStreamSwitcherPassThru->QueryInterface(riid, ppv);
+ }
+ /*
+ else if (riid == IID_IStreamBuilder)
+ {
+ return GetInterface((IStreamBuilder*)this, ppv);
+ }
+ */
+ return CBaseOutputPin::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CStreamSwitcherOutputPin::QueryAcceptUpstream(const AM_MEDIA_TYPE* pmt)
{
- HRESULT hr = S_FALSE;
+ HRESULT hr = S_FALSE;
- CStreamSwitcherInputPin* pIn = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetInputPin();
+ CStreamSwitcherInputPin* pIn = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetInputPin();
- if (pIn && pIn->IsConnected() && (pIn->IsUsingOwnAllocator() || pIn->CurrentMediaType() == *pmt)) {
- if (CComQIPtr<IPin> pPinTo = pIn->GetConnected()) {
- if (S_OK != (hr = pPinTo->QueryAccept(pmt))) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- } else {
- return E_FAIL;
- }
- }
+ if (pIn && pIn->IsConnected() && (pIn->IsUsingOwnAllocator() || pIn->CurrentMediaType() == *pmt)) {
+ if (CComQIPtr<IPin> pPinTo = pIn->GetConnected()) {
+ if (S_OK != (hr = pPinTo->QueryAccept(pmt))) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+ } else {
+ return E_FAIL;
+ }
+ }
- return hr;
+ return hr;
}
// pure virtual
HRESULT CStreamSwitcherOutputPin::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- CStreamSwitcherInputPin* pIn = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetInputPin();
- if (!pIn || !pIn->IsConnected()) {
- return E_UNEXPECTED;
- }
+ CStreamSwitcherInputPin* pIn = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetInputPin();
+ if (!pIn || !pIn->IsConnected()) {
+ return E_UNEXPECTED;
+ }
- CComPtr<IMemAllocator> pAllocatorIn;
- pIn->GetAllocator(&pAllocatorIn);
- if (!pAllocatorIn) {
- return E_UNEXPECTED;
- }
+ CComPtr<IMemAllocator> pAllocatorIn;
+ pIn->GetAllocator(&pAllocatorIn);
+ if (!pAllocatorIn) {
+ return E_UNEXPECTED;
+ }
- HRESULT hr;
- if (FAILED(hr = pAllocatorIn->GetProperties(pProperties))) {
- return hr;
- }
+ HRESULT hr;
+ if (FAILED(hr = pAllocatorIn->GetProperties(pProperties))) {
+ return hr;
+ }
- if (pProperties->cBuffers < 8 && pIn->CurrentMediaType().majortype == MEDIATYPE_Audio) {
- pProperties->cBuffers = 8;
- }
+ if (pProperties->cBuffers < 8 && pIn->CurrentMediaType().majortype == MEDIATYPE_Audio) {
+ pProperties->cBuffers = 8;
+ }
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
- return hr;
- }
+ ALLOCATOR_PROPERTIES Actual;
+ if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
- return (pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
- ? E_FAIL
- : NOERROR);
+ return (pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
+ ? E_FAIL
+ : NOERROR);
}
// virtual
class __declspec(uuid("AEFA5024-215A-4FC7-97A4-1043C86FD0B8"))
- MatrixMixer {};
+ MatrixMixer {};
HRESULT CStreamSwitcherOutputPin::CheckConnect(IPin* pPin)
{
- CComPtr<IBaseFilter> pBF = GetFilterFromPin(pPin);
+ CComPtr<IBaseFilter> pBF = GetFilterFromPin(pPin);
- return
- IsAudioWaveRenderer(pBF) || GetCLSID(pBF) == __uuidof(MatrixMixer)
- ? __super::CheckConnect(pPin)
- : E_FAIL;
+ return
+ IsAudioWaveRenderer(pBF) || GetCLSID(pBF) == __uuidof(MatrixMixer)
+ ? __super::CheckConnect(pPin)
+ : E_FAIL;
- // return CComQIPtr<IPinConnection>(pPin) ? CBaseOutputPin::CheckConnect(pPin) : E_NOINTERFACE;
- // return CBaseOutputPin::CheckConnect(pPin);
+ // return CComQIPtr<IPinConnection>(pPin) ? CBaseOutputPin::CheckConnect(pPin) : E_NOINTERFACE;
+ // return CBaseOutputPin::CheckConnect(pPin);
}
HRESULT CStreamSwitcherOutputPin::BreakConnect()
{
- m_pPinConnection = NULL;
- return __super::BreakConnect();
+ m_pPinConnection = NULL;
+ return __super::BreakConnect();
}
HRESULT CStreamSwitcherOutputPin::CompleteConnect(IPin* pReceivePin)
{
- m_pPinConnection = CComQIPtr<IPinConnection>(pReceivePin);
- return __super::CompleteConnect(pReceivePin);
+ m_pPinConnection = CComQIPtr<IPinConnection>(pReceivePin);
+ return __super::CompleteConnect(pReceivePin);
}
HRESULT CStreamSwitcherOutputPin::CheckMediaType(const CMediaType* pmt)
{
- return (static_cast<CStreamSwitcherFilter*>(m_pFilter))->CheckMediaType(pmt);
+ return (static_cast<CStreamSwitcherFilter*>(m_pFilter))->CheckMediaType(pmt);
}
HRESULT CStreamSwitcherOutputPin::GetMediaType(int iPosition, CMediaType* pmt)
{
- CStreamSwitcherInputPin* pIn = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetInputPin();
- if (!pIn || !pIn->IsConnected()) {
- return E_UNEXPECTED;
- }
+ CStreamSwitcherInputPin* pIn = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetInputPin();
+ if (!pIn || !pIn->IsConnected()) {
+ return E_UNEXPECTED;
+ }
- CComPtr<IEnumMediaTypes> pEM;
- if (FAILED(pIn->GetConnected()->EnumMediaTypes(&pEM))) {
- return VFW_S_NO_MORE_ITEMS;
- }
+ CComPtr<IEnumMediaTypes> pEM;
+ if (FAILED(pIn->GetConnected()->EnumMediaTypes(&pEM))) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
- if (iPosition > 0 && FAILED(pEM->Skip(iPosition))) {
- return VFW_S_NO_MORE_ITEMS;
- }
+ if (iPosition > 0 && FAILED(pEM->Skip(iPosition))) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
- AM_MEDIA_TYPE* tmp = NULL;
- if (S_OK != pEM->Next(1, &tmp, NULL) || !tmp) {
- return VFW_S_NO_MORE_ITEMS;
- }
+ AM_MEDIA_TYPE* tmp = NULL;
+ if (S_OK != pEM->Next(1, &tmp, NULL) || !tmp) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
- CopyMediaType(pmt, tmp);
- DeleteMediaType(tmp);
- /*
- if (iPosition < 0) return E_INVALIDARG;
- if (iPosition > 0) return VFW_S_NO_MORE_ITEMS;
+ CopyMediaType(pmt, tmp);
+ DeleteMediaType(tmp);
+ /*
+ if (iPosition < 0) return E_INVALIDARG;
+ if (iPosition > 0) return VFW_S_NO_MORE_ITEMS;
- CopyMediaType(pmt, &pIn->CurrentMediaType());
- */
- return S_OK;
+ CopyMediaType(pmt, &pIn->CurrentMediaType());
+ */
+ return S_OK;
}
// IPin
STDMETHODIMP CStreamSwitcherOutputPin::QueryAccept(const AM_MEDIA_TYPE* pmt)
{
- HRESULT hr = __super::QueryAccept(pmt);
- if (S_OK != hr) {
- return hr;
- }
+ HRESULT hr = __super::QueryAccept(pmt);
+ if (S_OK != hr) {
+ return hr;
+ }
- return QueryAcceptUpstream(pmt);
+ return QueryAcceptUpstream(pmt);
}
// IQualityControl
STDMETHODIMP CStreamSwitcherOutputPin::Notify(IBaseFilter* pSender, Quality q)
{
- CStreamSwitcherInputPin* pIn = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetInputPin();
- if (!pIn || !pIn->IsConnected()) {
- return VFW_E_NOT_CONNECTED;
- }
- return pIn->PassNotify(q);
+ CStreamSwitcherInputPin* pIn = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetInputPin();
+ if (!pIn || !pIn->IsConnected()) {
+ return VFW_E_NOT_CONNECTED;
+ }
+ return pIn->PassNotify(q);
}
// IStreamBuilder
STDMETHODIMP CStreamSwitcherOutputPin::Render(IPin* ppinOut, IGraphBuilder* pGraph)
{
- CComPtr<IBaseFilter> pBF;
- pBF.CoCreateInstance(CLSID_DSoundRender);
- if (!pBF || FAILED(pGraph->AddFilter(pBF, L"Default DirectSound Device"))) {
- return E_FAIL;
- }
+ CComPtr<IBaseFilter> pBF;
+ pBF.CoCreateInstance(CLSID_DSoundRender);
+ if (!pBF || FAILED(pGraph->AddFilter(pBF, L"Default DirectSound Device"))) {
+ return E_FAIL;
+ }
- if (FAILED(pGraph->ConnectDirect(ppinOut, GetFirstDisconnectedPin(pBF, PINDIR_INPUT), NULL))) {
- pGraph->RemoveFilter(pBF);
- return E_FAIL;
- }
+ if (FAILED(pGraph->ConnectDirect(ppinOut, GetFirstDisconnectedPin(pBF, PINDIR_INPUT), NULL))) {
+ pGraph->RemoveFilter(pBF);
+ return E_FAIL;
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CStreamSwitcherOutputPin::Backout(IPin* ppinOut, IGraphBuilder* pGraph)
{
- return S_OK;
+ return S_OK;
}
//
@@ -1157,321 +1157,321 @@ STDMETHODIMP CStreamSwitcherOutputPin::Backout(IPin* ppinOut, IGraphBuilder* pGr
//
CStreamSwitcherFilter::CStreamSwitcherFilter(LPUNKNOWN lpunk, HRESULT* phr, const CLSID& clsid)
- : CBaseFilter(NAME("CStreamSwitcherFilter"), lpunk, &m_csState, clsid)
+ : CBaseFilter(NAME("CStreamSwitcherFilter"), lpunk, &m_csState, clsid)
{
- if (phr) {
- *phr = S_OK;
- }
+ if (phr) {
+ *phr = S_OK;
+ }
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- do {
- CAutoPtr<CStreamSwitcherInputPin> pInput;
- CAutoPtr<CStreamSwitcherOutputPin> pOutput;
+ do {
+ CAutoPtr<CStreamSwitcherInputPin> pInput;
+ CAutoPtr<CStreamSwitcherOutputPin> pOutput;
- hr = S_OK;
- pInput.Attach(DNew CStreamSwitcherInputPin(this, &hr, L"Channel 1"));
- if (!pInput || FAILED(hr)) {
- break;
- }
+ hr = S_OK;
+ pInput.Attach(DNew CStreamSwitcherInputPin(this, &hr, L"Channel 1"));
+ if (!pInput || FAILED(hr)) {
+ break;
+ }
- hr = S_OK;
- pOutput.Attach(DNew CStreamSwitcherOutputPin(this, &hr));
- if (!pOutput || FAILED(hr)) {
- break;
- }
+ hr = S_OK;
+ pOutput.Attach(DNew CStreamSwitcherOutputPin(this, &hr));
+ if (!pOutput || FAILED(hr)) {
+ break;
+ }
- CAutoLock cAutoLock(&m_csPins);
+ CAutoLock cAutoLock(&m_csPins);
- m_pInputs.AddHead(m_pInput = pInput.Detach());
- m_pOutput = pOutput.Detach();
+ m_pInputs.AddHead(m_pInput = pInput.Detach());
+ m_pOutput = pOutput.Detach();
- return;
- } while (false);
+ return;
+ } while (false);
- if (phr) {
- *phr = E_FAIL;
- }
+ if (phr) {
+ *phr = E_FAIL;
+ }
}
CStreamSwitcherFilter::~CStreamSwitcherFilter()
{
- CAutoLock cAutoLock(&m_csPins);
+ CAutoLock cAutoLock(&m_csPins);
- POSITION pos = m_pInputs.GetHeadPosition();
- while (pos) {
- delete m_pInputs.GetNext(pos);
- }
- m_pInputs.RemoveAll();
- m_pInput = NULL;
+ POSITION pos = m_pInputs.GetHeadPosition();
+ while (pos) {
+ delete m_pInputs.GetNext(pos);
+ }
+ m_pInputs.RemoveAll();
+ m_pInput = NULL;
- delete m_pOutput;
- m_pOutput = NULL;
+ delete m_pOutput;
+ m_pOutput = NULL;
}
STDMETHODIMP CStreamSwitcherFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- return
- QI(IAMStreamSelect)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IAMStreamSelect)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
//
int CStreamSwitcherFilter::GetPinCount()
{
- CAutoLock cAutoLock(&m_csPins);
+ CAutoLock cAutoLock(&m_csPins);
- return (1 + (int)m_pInputs.GetCount());
+ return (1 + (int)m_pInputs.GetCount());
}
CBasePin* CStreamSwitcherFilter::GetPin(int n)
{
- CAutoLock cAutoLock(&m_csPins);
+ CAutoLock cAutoLock(&m_csPins);
- if (n < 0 || n >= GetPinCount()) {
- return NULL;
- } else if (n == 0) {
- return m_pOutput;
- } else {
- return m_pInputs.GetAt(m_pInputs.FindIndex(n-1));
- }
+ if (n < 0 || n >= GetPinCount()) {
+ return NULL;
+ } else if (n == 0) {
+ return m_pOutput;
+ } else {
+ return m_pInputs.GetAt(m_pInputs.FindIndex(n - 1));
+ }
}
int CStreamSwitcherFilter::GetConnectedInputPinCount()
{
- CAutoLock cAutoLock(&m_csPins);
+ CAutoLock cAutoLock(&m_csPins);
- int nConnected = 0;
+ int nConnected = 0;
- POSITION pos = m_pInputs.GetHeadPosition();
- while (pos) {
- if (m_pInputs.GetNext(pos)->IsConnected()) {
- nConnected++;
- }
- }
+ POSITION pos = m_pInputs.GetHeadPosition();
+ while (pos) {
+ if (m_pInputs.GetNext(pos)->IsConnected()) {
+ nConnected++;
+ }
+ }
- return nConnected;
+ return nConnected;
}
CStreamSwitcherInputPin* CStreamSwitcherFilter::GetConnectedInputPin(int n)
{
- if (n >= 0) {
- POSITION pos = m_pInputs.GetHeadPosition();
- while (pos) {
- CStreamSwitcherInputPin* pPin = m_pInputs.GetNext(pos);
- if (pPin->IsConnected()) {
- if (n == 0) {
- return pPin;
- }
- n--;
- }
- }
- }
+ if (n >= 0) {
+ POSITION pos = m_pInputs.GetHeadPosition();
+ while (pos) {
+ CStreamSwitcherInputPin* pPin = m_pInputs.GetNext(pos);
+ if (pPin->IsConnected()) {
+ if (n == 0) {
+ return pPin;
+ }
+ n--;
+ }
+ }
+ }
- return NULL;
+ return NULL;
}
CStreamSwitcherInputPin* CStreamSwitcherFilter::GetInputPin()
{
- return m_pInput;
+ return m_pInput;
}
CStreamSwitcherOutputPin* CStreamSwitcherFilter::GetOutputPin()
{
- return m_pOutput;
+ return m_pOutput;
}
//
HRESULT CStreamSwitcherFilter::CompleteConnect(PIN_DIRECTION dir, CBasePin* pPin, IPin* pReceivePin)
{
- if (dir == PINDIR_INPUT) {
- CAutoLock cAutoLock(&m_csPins);
+ if (dir == PINDIR_INPUT) {
+ CAutoLock cAutoLock(&m_csPins);
- int nConnected = GetConnectedInputPinCount();
+ int nConnected = GetConnectedInputPinCount();
- if (nConnected == 1) {
- m_pInput = static_cast<CStreamSwitcherInputPin*>(pPin);
- }
+ if (nConnected == 1) {
+ m_pInput = static_cast<CStreamSwitcherInputPin*>(pPin);
+ }
- if ((size_t)nConnected == m_pInputs.GetCount()) {
- CStringW name;
- name.Format(L"Channel %d", ++m_PinVersion);
+ if ((size_t)nConnected == m_pInputs.GetCount()) {
+ CStringW name;
+ name.Format(L"Channel %d", ++m_PinVersion);
- HRESULT hr = S_OK;
- CStreamSwitcherInputPin* pPin = DNew CStreamSwitcherInputPin(this, &hr, name);
- if (!pPin || FAILED(hr)) {
- delete pPin;
- return E_FAIL;
- }
- m_pInputs.AddTail(pPin);
- }
- }
+ HRESULT hr = S_OK;
+ CStreamSwitcherInputPin* pPin = DNew CStreamSwitcherInputPin(this, &hr, name);
+ if (!pPin || FAILED(hr)) {
+ delete pPin;
+ return E_FAIL;
+ }
+ m_pInputs.AddTail(pPin);
+ }
+ }
- return S_OK;
+ return S_OK;
}
// this should be very thread safe, I hope it is, it must be... :)
void CStreamSwitcherFilter::SelectInput(CStreamSwitcherInputPin* pInput)
{
- // make sure no input thinks it is active
- m_pInput = NULL;
+ // make sure no input thinks it is active
+ m_pInput = NULL;
- // release blocked GetBuffer in our own allocator & block all Receive
- POSITION pos = m_pInputs.GetHeadPosition();
- while (pos) {
- CStreamSwitcherInputPin* pPin = m_pInputs.GetNext(pos);
- pPin->Block(false);
- // a few Receive calls can arrive here, but since m_pInput == NULL neighter of them gets delivered
- pPin->Block(true);
- }
+ // release blocked GetBuffer in our own allocator & block all Receive
+ POSITION pos = m_pInputs.GetHeadPosition();
+ while (pos) {
+ CStreamSwitcherInputPin* pPin = m_pInputs.GetNext(pos);
+ pPin->Block(false);
+ // a few Receive calls can arrive here, but since m_pInput == NULL neighter of them gets delivered
+ pPin->Block(true);
+ }
- // this will let waiting GetBuffer() calls go on inside our Receive()
- if (m_pOutput) {
- m_pOutput->DeliverBeginFlush();
- m_pOutput->DeliverEndFlush();
- }
+ // this will let waiting GetBuffer() calls go on inside our Receive()
+ if (m_pOutput) {
+ m_pOutput->DeliverBeginFlush();
+ m_pOutput->DeliverEndFlush();
+ }
- if (!pInput) {
- return;
- }
+ if (!pInput) {
+ return;
+ }
- // set new input
- m_pInput = pInput;
+ // set new input
+ m_pInput = pInput;
- // let it go
- m_pInput->Block(false);
+ // let it go
+ m_pInput->Block(false);
}
//
HRESULT CStreamSwitcherFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
{
- BYTE* pDataIn = NULL;
- BYTE* pDataOut = NULL;
+ BYTE* pDataIn = NULL;
+ BYTE* pDataOut = NULL;
- HRESULT hr;
- if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
- return hr;
- }
- if (FAILED(hr = pOut->GetPointer(&pDataOut))) {
- return hr;
- }
+ HRESULT hr;
+ if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
+ return hr;
+ }
+ if (FAILED(hr = pOut->GetPointer(&pDataOut))) {
+ return hr;
+ }
- long len = pIn->GetActualDataLength();
- long size = pOut->GetSize();
+ long len = pIn->GetActualDataLength();
+ long size = pOut->GetSize();
- if (!pDataIn || !pDataOut /*|| len > size || len <= 0*/) {
- return S_FALSE; // FIXME
- }
+ if (!pDataIn || !pDataOut /*|| len > size || len <= 0*/) {
+ return S_FALSE; // FIXME
+ }
- memcpy(pDataOut, pDataIn, min(len, size));
- pOut->SetActualDataLength(min(len, size));
+ memcpy(pDataOut, pDataIn, min(len, size));
+ pOut->SetActualDataLength(min(len, size));
- return S_OK;
+ return S_OK;
}
CMediaType CStreamSwitcherFilter::CreateNewOutputMediaType(CMediaType mt, long& cbBuffer)
{
- return mt;
+ return mt;
}
HRESULT CStreamSwitcherFilter::DeliverEndOfStream()
{
- return m_pOutput ? m_pOutput->DeliverEndOfStream() : E_FAIL;
+ return m_pOutput ? m_pOutput->DeliverEndOfStream() : E_FAIL;
}
HRESULT CStreamSwitcherFilter::DeliverBeginFlush()
{
- return m_pOutput ? m_pOutput->DeliverBeginFlush() : E_FAIL;
+ return m_pOutput ? m_pOutput->DeliverBeginFlush() : E_FAIL;
}
HRESULT CStreamSwitcherFilter::DeliverEndFlush()
{
- return m_pOutput ? m_pOutput->DeliverEndFlush() : E_FAIL;
+ return m_pOutput ? m_pOutput->DeliverEndFlush() : E_FAIL;
}
HRESULT CStreamSwitcherFilter::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- return m_pOutput ? m_pOutput->DeliverNewSegment(tStart, tStop, dRate) : E_FAIL;
+ return m_pOutput ? m_pOutput->DeliverNewSegment(tStart, tStop, dRate) : E_FAIL;
}
// IAMStreamSelect
STDMETHODIMP CStreamSwitcherFilter::Count(DWORD* pcStreams)
{
- if (!pcStreams) {
- return E_POINTER;
- }
+ if (!pcStreams) {
+ return E_POINTER;
+ }
- CAutoLock cAutoLock(&m_csPins);
+ CAutoLock cAutoLock(&m_csPins);
- *pcStreams = GetConnectedInputPinCount();
+ *pcStreams = GetConnectedInputPinCount();
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CStreamSwitcherFilter::Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* pdwFlags, LCID* plcid, DWORD* pdwGroup, WCHAR** ppszName, IUnknown** ppObject, IUnknown** ppUnk)
{
- CAutoLock cAutoLock(&m_csPins);
+ CAutoLock cAutoLock(&m_csPins);
- CBasePin* pPin = GetConnectedInputPin(lIndex);
- if (!pPin) {
- return E_INVALIDARG;
- }
+ CBasePin* pPin = GetConnectedInputPin(lIndex);
+ if (!pPin) {
+ return E_INVALIDARG;
+ }
- if (ppmt) {
- *ppmt = CreateMediaType(&m_pOutput->CurrentMediaType());
- }
+ if (ppmt) {
+ *ppmt = CreateMediaType(&m_pOutput->CurrentMediaType());
+ }
- if (pdwFlags) {
- *pdwFlags = (m_pInput == pPin) ? AMSTREAMSELECTINFO_EXCLUSIVE : 0;
- }
+ if (pdwFlags) {
+ *pdwFlags = (m_pInput == pPin) ? AMSTREAMSELECTINFO_EXCLUSIVE : 0;
+ }
- if (plcid) {
- *plcid = 0;
- }
+ if (plcid) {
+ *plcid = 0;
+ }
- if (pdwGroup) {
- *pdwGroup = 0;
- }
+ if (pdwGroup) {
+ *pdwGroup = 0;
+ }
- if (ppszName) {
- *ppszName = (WCHAR*)CoTaskMemAlloc((wcslen(pPin->Name())+1)*sizeof(WCHAR));
- if (*ppszName) {
- wcscpy_s(*ppszName, wcslen(pPin->Name()) + 1, pPin->Name());
- }
- }
+ if (ppszName) {
+ *ppszName = (WCHAR*)CoTaskMemAlloc((wcslen(pPin->Name()) + 1) * sizeof(WCHAR));
+ if (*ppszName) {
+ wcscpy_s(*ppszName, wcslen(pPin->Name()) + 1, pPin->Name());
+ }
+ }
- if (ppObject) {
- *ppObject = NULL;
- }
+ if (ppObject) {
+ *ppObject = NULL;
+ }
- if (ppUnk) {
- *ppUnk = NULL;
- }
+ if (ppUnk) {
+ *ppUnk = NULL;
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CStreamSwitcherFilter::Enable(long lIndex, DWORD dwFlags)
{
- if (dwFlags != AMSTREAMSELECTENABLE_ENABLE) {
- return E_NOTIMPL;
- }
+ if (dwFlags != AMSTREAMSELECTENABLE_ENABLE) {
+ return E_NOTIMPL;
+ }
- PauseGraph;
+ PauseGraph;
- CStreamSwitcherInputPin* pNewInput = GetConnectedInputPin(lIndex);
- if (!pNewInput) {
- return E_INVALIDARG;
- }
+ CStreamSwitcherInputPin* pNewInput = GetConnectedInputPin(lIndex);
+ if (!pNewInput) {
+ return E_INVALIDARG;
+ }
- SelectInput(pNewInput);
+ SelectInput(pNewInput);
- ResumeGraph;
+ ResumeGraph;
- return S_OK;
+ return S_OK;
}
diff --git a/src/filters/switcher/AudioSwitcher/StreamSwitcher.h b/src/filters/switcher/AudioSwitcher/StreamSwitcher.h
index de2309285..5e5cd89c7 100644
--- a/src/filters/switcher/AudioSwitcher/StreamSwitcher.h
+++ b/src/filters/switcher/AudioSwitcher/StreamSwitcher.h
@@ -52,45 +52,45 @@ class CStreamSwitcherFilter;
class CStreamSwitcherPassThru : public IMediaSeeking, public CMediaPosition
{
protected:
- CStreamSwitcherFilter* m_pFilter;
+ CStreamSwitcherFilter* m_pFilter;
public:
- CStreamSwitcherPassThru(LPUNKNOWN, HRESULT* phr, CStreamSwitcherFilter* pFilter);
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // IMediaSeeking methods
- STDMETHODIMP GetCapabilities(DWORD* pCapabilities);
- STDMETHODIMP CheckCapabilities(DWORD* pCapabilities);
- STDMETHODIMP SetTimeFormat(const GUID* pFormat);
- STDMETHODIMP GetTimeFormat(GUID* pFormat);
- STDMETHODIMP IsUsingTimeFormat(const GUID* pFormat);
- STDMETHODIMP IsFormatSupported(const GUID* pFormat);
- STDMETHODIMP QueryPreferredFormat(GUID* pFormat);
- STDMETHODIMP ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat);
- STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD CurrentFlags, LONGLONG* pStop, DWORD StopFlags);
- STDMETHODIMP GetPositions(LONGLONG* pCurrent, LONGLONG* pStop);
- STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
- STDMETHODIMP GetStopPosition(LONGLONG* pStop);
- STDMETHODIMP SetRate(double dRate);
- STDMETHODIMP GetRate(double* pdRate);
- STDMETHODIMP GetDuration(LONGLONG* pDuration);
- STDMETHODIMP GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest);
- STDMETHODIMP GetPreroll(LONGLONG* pllPreroll);
-
- // IMediaPosition properties
- STDMETHODIMP get_Duration(REFTIME* plength);
- STDMETHODIMP put_CurrentPosition(REFTIME llTime);
- STDMETHODIMP get_StopTime(REFTIME* pllTime);
- STDMETHODIMP put_StopTime(REFTIME llTime);
- STDMETHODIMP get_PrerollTime(REFTIME* pllTime);
- STDMETHODIMP put_PrerollTime(REFTIME llTime);
- STDMETHODIMP get_Rate(double* pdRate);
- STDMETHODIMP put_Rate(double dRate);
- STDMETHODIMP get_CurrentPosition(REFTIME* pllTime);
- STDMETHODIMP CanSeekForward(LONG* pCanSeekForward);
- STDMETHODIMP CanSeekBackward(LONG* pCanSeekBackward);
+ CStreamSwitcherPassThru(LPUNKNOWN, HRESULT* phr, CStreamSwitcherFilter* pFilter);
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ // IMediaSeeking methods
+ STDMETHODIMP GetCapabilities(DWORD* pCapabilities);
+ STDMETHODIMP CheckCapabilities(DWORD* pCapabilities);
+ STDMETHODIMP SetTimeFormat(const GUID* pFormat);
+ STDMETHODIMP GetTimeFormat(GUID* pFormat);
+ STDMETHODIMP IsUsingTimeFormat(const GUID* pFormat);
+ STDMETHODIMP IsFormatSupported(const GUID* pFormat);
+ STDMETHODIMP QueryPreferredFormat(GUID* pFormat);
+ STDMETHODIMP ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat);
+ STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD CurrentFlags, LONGLONG* pStop, DWORD StopFlags);
+ STDMETHODIMP GetPositions(LONGLONG* pCurrent, LONGLONG* pStop);
+ STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
+ STDMETHODIMP GetStopPosition(LONGLONG* pStop);
+ STDMETHODIMP SetRate(double dRate);
+ STDMETHODIMP GetRate(double* pdRate);
+ STDMETHODIMP GetDuration(LONGLONG* pDuration);
+ STDMETHODIMP GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest);
+ STDMETHODIMP GetPreroll(LONGLONG* pllPreroll);
+
+ // IMediaPosition properties
+ STDMETHODIMP get_Duration(REFTIME* plength);
+ STDMETHODIMP put_CurrentPosition(REFTIME llTime);
+ STDMETHODIMP get_StopTime(REFTIME* pllTime);
+ STDMETHODIMP put_StopTime(REFTIME llTime);
+ STDMETHODIMP get_PrerollTime(REFTIME* pllTime);
+ STDMETHODIMP put_PrerollTime(REFTIME llTime);
+ STDMETHODIMP get_Rate(double* pdRate);
+ STDMETHODIMP put_Rate(double dRate);
+ STDMETHODIMP get_CurrentPosition(REFTIME* pllTime);
+ STDMETHODIMP CanSeekForward(LONG* pCanSeekForward);
+ STDMETHODIMP CanSeekBackward(LONG* pCanSeekBackward);
};
class CStreamSwitcherInputPin;
@@ -98,202 +98,202 @@ class CStreamSwitcherInputPin;
class CStreamSwitcherAllocator : public CMemAllocator
{
protected:
- CStreamSwitcherInputPin* m_pPin;
+ CStreamSwitcherInputPin* m_pPin;
- CMediaType m_mt;
- bool m_fMediaTypeChanged;
+ CMediaType m_mt;
+ bool m_fMediaTypeChanged;
public:
- CStreamSwitcherAllocator(CStreamSwitcherInputPin* pPin, HRESULT* phr);
+ CStreamSwitcherAllocator(CStreamSwitcherInputPin* pPin, HRESULT* phr);
#ifdef _DEBUG
- ~CStreamSwitcherAllocator();
+ ~CStreamSwitcherAllocator();
#endif
- STDMETHODIMP_(ULONG) NonDelegatingAddRef();
- STDMETHODIMP_(ULONG) NonDelegatingRelease();
+ STDMETHODIMP_(ULONG) NonDelegatingAddRef();
+ STDMETHODIMP_(ULONG) NonDelegatingRelease();
- STDMETHODIMP GetBuffer(
- IMediaSample** ppBuffer,
- REFERENCE_TIME* pStartTime, REFERENCE_TIME* pEndTime,
- DWORD dwFlags);
+ STDMETHODIMP GetBuffer(
+ IMediaSample** ppBuffer,
+ REFERENCE_TIME* pStartTime, REFERENCE_TIME* pEndTime,
+ DWORD dwFlags);
- void NotifyMediaType(const CMediaType& mt);
+ void NotifyMediaType(const CMediaType& mt);
};
interface __declspec(uuid("DA395FA3-4A3E-4D85-805E-0BEFF53D4BCD"))
IStreamSwitcherInputPin :
public IUnknown {
- STDMETHOD_(bool, IsActive)() = 0;
+ STDMETHOD_(bool, IsActive)() = 0;
};
class CStreamSwitcherInputPin : public CBaseInputPin, public IPinConnection, public IStreamSwitcherInputPin
{
- friend class CStreamSwitcherAllocator;
+ friend class CStreamSwitcherAllocator;
- CStreamSwitcherAllocator m_Allocator;
+ CStreamSwitcherAllocator m_Allocator;
- BOOL m_bSampleSkipped;
- BOOL m_bQualityChanged;
- BOOL m_bUsingOwnAllocator;
+ BOOL m_bSampleSkipped;
+ BOOL m_bQualityChanged;
+ BOOL m_bUsingOwnAllocator;
- CAMEvent m_evBlock;
- bool m_fCanBlock;
- HRESULT Active();
- HRESULT Inactive();
+ CAMEvent m_evBlock;
+ bool m_fCanBlock;
+ HRESULT Active();
+ HRESULT Inactive();
- HRESULT QueryAcceptDownstream(const AM_MEDIA_TYPE* pmt);
+ HRESULT QueryAcceptDownstream(const AM_MEDIA_TYPE* pmt);
- HRESULT InitializeOutputSample(IMediaSample* pInSample, IMediaSample** ppOutSample);
+ HRESULT InitializeOutputSample(IMediaSample* pInSample, IMediaSample** ppOutSample);
- HANDLE m_hNotifyEvent;
+ HANDLE m_hNotifyEvent;
public:
- CStreamSwitcherInputPin(CStreamSwitcherFilter* pFilter, HRESULT* phr, LPCWSTR pName);
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- CMediaType& CurrentMediaType() {
- return m_mt;
- }
- IMemAllocator* CurrentAllocator() {
- return m_pAllocator;
- }
-
- bool IsUsingOwnAllocator() {
- return m_bUsingOwnAllocator == TRUE;
- }
-
- void Block(bool fBlock);
-
- CCritSec m_csReceive;
-
- // pure virtual
- HRESULT CheckMediaType(const CMediaType* pmt);
-
- // virtual
- HRESULT CheckConnect(IPin* pPin);
- HRESULT CompleteConnect(IPin* pReceivePin);
-
- // IPin
- STDMETHODIMP QueryAccept(const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP ReceiveConnection(IPin* pConnector, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP GetAllocator(IMemAllocator** ppAllocator);
- STDMETHODIMP NotifyAllocator(IMemAllocator* pAllocator, BOOL bReadOnly);
- STDMETHODIMP BeginFlush();
- STDMETHODIMP EndFlush();
- STDMETHODIMP EndOfStream();
-
- // IMemInputPin
- STDMETHODIMP Receive(IMediaSample* pSample);
- STDMETHODIMP NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
-
- // IPinConnection
- STDMETHODIMP DynamicQueryAccept(const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP NotifyEndOfStream(HANDLE hNotifyEvent);
- STDMETHODIMP IsEndPin();
- STDMETHODIMP DynamicDisconnect();
-
- // IStreamSwitcherInputPin
- STDMETHODIMP_(bool) IsActive();
+ CStreamSwitcherInputPin(CStreamSwitcherFilter* pFilter, HRESULT* phr, LPCWSTR pName);
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ CMediaType& CurrentMediaType() {
+ return m_mt;
+ }
+ IMemAllocator* CurrentAllocator() {
+ return m_pAllocator;
+ }
+
+ bool IsUsingOwnAllocator() {
+ return m_bUsingOwnAllocator == TRUE;
+ }
+
+ void Block(bool fBlock);
+
+ CCritSec m_csReceive;
+
+ // pure virtual
+ HRESULT CheckMediaType(const CMediaType* pmt);
+
+ // virtual
+ HRESULT CheckConnect(IPin* pPin);
+ HRESULT CompleteConnect(IPin* pReceivePin);
+
+ // IPin
+ STDMETHODIMP QueryAccept(const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP ReceiveConnection(IPin* pConnector, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP GetAllocator(IMemAllocator** ppAllocator);
+ STDMETHODIMP NotifyAllocator(IMemAllocator* pAllocator, BOOL bReadOnly);
+ STDMETHODIMP BeginFlush();
+ STDMETHODIMP EndFlush();
+ STDMETHODIMP EndOfStream();
+
+ // IMemInputPin
+ STDMETHODIMP Receive(IMediaSample* pSample);
+ STDMETHODIMP NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+
+ // IPinConnection
+ STDMETHODIMP DynamicQueryAccept(const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP NotifyEndOfStream(HANDLE hNotifyEvent);
+ STDMETHODIMP IsEndPin();
+ STDMETHODIMP DynamicDisconnect();
+
+ // IStreamSwitcherInputPin
+ STDMETHODIMP_(bool) IsActive();
};
class CStreamSwitcherOutputPin : public CBaseOutputPin, public IStreamBuilder
{
- CComPtr<IUnknown> m_pStreamSwitcherPassThru;
- CComPtr<IPinConnection> m_pPinConnection;
+ CComPtr<IUnknown> m_pStreamSwitcherPassThru;
+ CComPtr<IPinConnection> m_pPinConnection;
- HRESULT QueryAcceptUpstream(const AM_MEDIA_TYPE* pmt);
+ HRESULT QueryAcceptUpstream(const AM_MEDIA_TYPE* pmt);
public:
- CStreamSwitcherOutputPin(CStreamSwitcherFilter* pFilter, HRESULT* phr);
+ CStreamSwitcherOutputPin(CStreamSwitcherFilter* pFilter, HRESULT* phr);
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- CMediaType& CurrentMediaType() {
- return m_mt;
- }
- IMemAllocator* CurrentAllocator() {
- return m_pAllocator;
- }
- IPinConnection* CurrentPinConnection() {
- return m_pPinConnection;
- }
+ CMediaType& CurrentMediaType() {
+ return m_mt;
+ }
+ IMemAllocator* CurrentAllocator() {
+ return m_pAllocator;
+ }
+ IPinConnection* CurrentPinConnection() {
+ return m_pPinConnection;
+ }
- // pure virtual
- HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
+ // pure virtual
+ HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
- // virtual
- HRESULT CheckConnect(IPin* pPin);
- HRESULT BreakConnect();
- HRESULT CompleteConnect(IPin* pReceivePin);
+ // virtual
+ HRESULT CheckConnect(IPin* pPin);
+ HRESULT BreakConnect();
+ HRESULT CompleteConnect(IPin* pReceivePin);
- HRESULT CheckMediaType(const CMediaType* pmt);
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
+ HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT GetMediaType(int iPosition, CMediaType* pmt);
- // IPin
- STDMETHODIMP QueryAccept(const AM_MEDIA_TYPE* pmt);
+ // IPin
+ STDMETHODIMP QueryAccept(const AM_MEDIA_TYPE* pmt);
- // IQualityControl
- STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
+ // IQualityControl
+ STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
- // IStreamBuilder
- STDMETHODIMP Render(IPin* ppinOut, IGraphBuilder* pGraph);
- STDMETHODIMP Backout(IPin* ppinOut, IGraphBuilder* pGraph);
+ // IStreamBuilder
+ STDMETHODIMP Render(IPin* ppinOut, IGraphBuilder* pGraph);
+ STDMETHODIMP Backout(IPin* ppinOut, IGraphBuilder* pGraph);
};
class CStreamSwitcherFilter : public CBaseFilter, public IAMStreamSelect
{
- friend class CStreamSwitcherInputPin;
- friend class CStreamSwitcherOutputPin;
- friend class CStreamSwitcherPassThru;
+ friend class CStreamSwitcherInputPin;
+ friend class CStreamSwitcherOutputPin;
+ friend class CStreamSwitcherPassThru;
- CAtlList<CStreamSwitcherInputPin*> m_pInputs;
- CStreamSwitcherInputPin* m_pInput;
- CStreamSwitcherOutputPin* m_pOutput;
+ CAtlList<CStreamSwitcherInputPin*> m_pInputs;
+ CStreamSwitcherInputPin* m_pInput;
+ CStreamSwitcherOutputPin* m_pOutput;
- CCritSec m_csState, m_csPins;
+ CCritSec m_csState, m_csPins;
- HRESULT CompleteConnect(PIN_DIRECTION dir, CBasePin* pPin, IPin* pReceivePin);
+ HRESULT CompleteConnect(PIN_DIRECTION dir, CBasePin* pPin, IPin* pReceivePin);
protected:
- void SelectInput(CStreamSwitcherInputPin* pInput);
+ void SelectInput(CStreamSwitcherInputPin* pInput);
public:
- CStreamSwitcherFilter(LPUNKNOWN lpunk, HRESULT* phr, const CLSID& clsid);
- virtual ~CStreamSwitcherFilter();
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- int GetPinCount();
- CBasePin* GetPin(int n);
-
- int GetConnectedInputPinCount();
- CStreamSwitcherInputPin* GetConnectedInputPin(int n);
- CStreamSwitcherInputPin* GetInputPin();
- CStreamSwitcherOutputPin* GetOutputPin();
-
- bool m_fResetOutputMediaType;
- void ResetOutputMediaType() {
- m_fResetOutputMediaType = true;
- }
-
- // override these
- virtual HRESULT CheckMediaType(const CMediaType* pmt) = 0;
- virtual HRESULT Transform(IMediaSample* pIn, IMediaSample* pOut);
- virtual CMediaType CreateNewOutputMediaType(CMediaType mt, long& cbBuffer);
- virtual void OnNewOutputMediaType(const CMediaType& mtIn, const CMediaType& mtOut) {}
-
- // and maybe these
- virtual HRESULT DeliverEndOfStream();
- virtual HRESULT DeliverBeginFlush();
- virtual HRESULT DeliverEndFlush();
- virtual HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
-
- // IAMStreamSelect
- STDMETHODIMP Count(DWORD* pcStreams);
- STDMETHODIMP Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* pdwFlags, LCID* plcid, DWORD* pdwGroup, WCHAR** ppszName, IUnknown** ppObject, IUnknown** ppUnk);
- STDMETHODIMP Enable(long lIndex, DWORD dwFlags);
+ CStreamSwitcherFilter(LPUNKNOWN lpunk, HRESULT* phr, const CLSID& clsid);
+ virtual ~CStreamSwitcherFilter();
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ int GetPinCount();
+ CBasePin* GetPin(int n);
+
+ int GetConnectedInputPinCount();
+ CStreamSwitcherInputPin* GetConnectedInputPin(int n);
+ CStreamSwitcherInputPin* GetInputPin();
+ CStreamSwitcherOutputPin* GetOutputPin();
+
+ bool m_fResetOutputMediaType;
+ void ResetOutputMediaType() {
+ m_fResetOutputMediaType = true;
+ }
+
+ // override these
+ virtual HRESULT CheckMediaType(const CMediaType* pmt) = 0;
+ virtual HRESULT Transform(IMediaSample* pIn, IMediaSample* pOut);
+ virtual CMediaType CreateNewOutputMediaType(CMediaType mt, long& cbBuffer);
+ virtual void OnNewOutputMediaType(const CMediaType& mtIn, const CMediaType& mtOut) {}
+
+ // and maybe these
+ virtual HRESULT DeliverEndOfStream();
+ virtual HRESULT DeliverBeginFlush();
+ virtual HRESULT DeliverEndFlush();
+ virtual HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+
+ // IAMStreamSelect
+ STDMETHODIMP Count(DWORD* pcStreams);
+ STDMETHODIMP Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* pdwFlags, LCID* plcid, DWORD* pdwGroup, WCHAR** ppszName, IUnknown** ppObject, IUnknown** ppUnk);
+ STDMETHODIMP Enable(long lIndex, DWORD dwFlags);
};
diff --git a/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.cpp b/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.cpp
index da74226a0..37d212064 100644
--- a/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.cpp
+++ b/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.cpp
@@ -34,37 +34,37 @@
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_WAVE_DOLBY_AC3},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_WAVE_DTS},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_WAVE_DOLBY_AC3},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_WAVE_DTS},
};
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_NULL},
};
const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CAVI2AC3Filter), AVI2AC3FilterName, MERIT_NORMAL, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory}
+ {&__uuidof(CAVI2AC3Filter), AVI2AC3FilterName, MERIT_NORMAL, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory}
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CAVI2AC3Filter>, NULL, &sudFilter[0]}
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CAVI2AC3Filter>, NULL, &sudFilter[0]}
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -78,11 +78,11 @@ CFilterApp theApp;
//
CAVI2AC3Filter::CAVI2AC3Filter(LPUNKNOWN lpunk, HRESULT* phr)
- : CTransformFilter(NAME("CAVI2AC3Filter"), lpunk, __uuidof(this))
+ : CTransformFilter(NAME("CAVI2AC3Filter"), lpunk, __uuidof(this))
{
- if (phr) {
- *phr = S_OK;
- }
+ if (phr) {
+ *phr = S_OK;
+ }
}
CAVI2AC3Filter::~CAVI2AC3Filter()
@@ -91,420 +91,420 @@ CAVI2AC3Filter::~CAVI2AC3Filter()
HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSample)
{
- HRESULT hr;
-
- BYTE* pIn = NULL;
- if (FAILED(hr = pSample->GetPointer(&pIn))) {
- return hr;
- }
- BYTE* pInOrg = pIn;
-
- long len = pSample->GetActualDataLength();
- if (len <= 0) {
- return S_FALSE;
- }
-
- BYTE* pOut = NULL;
- if (FAILED(hr = pOutSample->GetPointer(&pOut))) {
- return hr;
- }
- BYTE* pOutOrg = pOut;
-
- int size = pOutSample->GetSize();
-
- if ((CheckAC3(&m_pInput->CurrentMediaType()) || CheckDTS(&m_pInput->CurrentMediaType()))
- && (CheckWAVEAC3(&m_pOutput->CurrentMediaType()) || CheckWAVEDTS(&m_pOutput->CurrentMediaType()))) {
- if (*(DWORD*)pIn == 0xBA010000) {
- pIn += 14;
- }
-
- if (*(DWORD*)pIn == 0xBD010000) {
- pIn += 8 + 1 + pIn[8] + 1 + 3;
- }
-
- len -= (pInOrg - pIn);
-
- if (size < len) {
- return E_FAIL;
- }
-
- memcpy(pOut, pIn, len);
- pOut += len;
- } else if ((CheckWAVEAC3(&m_pInput->CurrentMediaType()) || CheckWAVEDTS(&m_pInput->CurrentMediaType()))
- && (CheckAC3(&m_pOutput->CurrentMediaType()) || CheckDTS(&m_pOutput->CurrentMediaType()))) {
- if ((m_pOutput->CurrentMediaType().majortype == MEDIATYPE_DVD_ENCRYPTED_PACK
- || m_pOutput->CurrentMediaType().majortype == MEDIATYPE_MPEG2_PES)
- && (len + 12 + 3) >= 0x10000) { // damn, this can happen if the interleave time is too big
- REFERENCE_TIME rtStart = 0, rtStop = 1;
- bool fHasTime = (S_OK == pSample->GetTime(&rtStart, &rtStop));
-
- bool fDiscontinuity = (S_OK == pOutSample->IsDiscontinuity());
-
- int pos = 0;
- while (pos < len) {
- int curlen = min(len - pos, 2013);
- pos += 2013;
-
- CComPtr<IMediaSample> pOutSample;
- hr = InitializeOutputSample(pSample, &pOutSample);
-
- if (fDiscontinuity) {
- if (fHasTime) {
- rtStop = rtStart + (rtStop - rtStart) * curlen / len;
- pOutSample->SetTime(&rtStart, &rtStop);
- }
-
- fDiscontinuity = false;
- } else {
- pOutSample->SetTime(NULL, NULL);
- pOutSample->SetDiscontinuity(FALSE);
- }
-
- BYTE* pOut = NULL;
- if (FAILED(hr = pOutSample->GetPointer(&pOut))) {
- return hr;
- }
- BYTE* pOutOrg = pOut;
-
- int size = pOutSample->GetSize();
-
- const GUID* majortype = &m_pOutput->CurrentMediaType().majortype;
- const GUID* subtype = &m_pOutput->CurrentMediaType().subtype;
-
- if (*majortype == MEDIATYPE_DVD_ENCRYPTED_PACK) {
- if (size < curlen + 32 + 3) {
- return E_FAIL;
- }
-
- BYTE PESHeader[] = {
- 0x00,0x00,0x01,0xBA, // PES id
- 0x44,0x00,0x04,0x00,0x04,0x01, // SCR (0)
- 0x01,0x89,0xC3,0xF8, // mux rate (1260000 bytes/sec, 22bits), marker (2bits), reserved (~0, 5bits), stuffing (0, 3bits)
- };
-
- memcpy(pOut, &PESHeader, sizeof(PESHeader));
- pOut += sizeof(PESHeader);
-
- majortype = &MEDIATYPE_MPEG2_PES;
- }
-
- if (*majortype == MEDIATYPE_MPEG2_PES) {
- if (size < curlen + 20 + 3) {
- return E_FAIL;
- }
-
- BYTE Private1Header[] = {
- 0x00,0x00,0x01,0xBD, // private stream 1 id
- 0x07,0xEC, // packet length (TODO: modify it later)
- 0x81,0x80, // marker, original, PTS - flags
- 0x08, // packet data starting offset
- 0x21,0x00,0x01,0x00,0x01, // PTS (0)
- 0xFF,0xFF,0xFF, // stuffing
- 0x80, // stream id (0)
- 0x01,0x00,0x01, // no idea about the first byte, the sencond+third seem to show the ac3/dts header sync offset plus one (dvd2avi doesn't output it to the ac3/dts file so we have to put it back)
- };
-
- int packetlen = curlen + 12 + 3;
- ASSERT(packetlen <= 0xffff);
- Private1Header[4] = (packetlen>>8)&0xff;
- Private1Header[5] = packetlen&0xff;
-
- if (*subtype == MEDIASUBTYPE_DTS) {
- Private1Header[17] += 8;
- }
-
- if (*subtype == MEDIASUBTYPE_DOLBY_AC3) {
- for (int i = 0; i < curlen; i++) {
- if (*(DWORD*)&pIn[i] == 0x770B) {
- i++;
- Private1Header[19] = (i>>8)&0xff;
- Private1Header[20] = i&0xff;
- break;
- }
- }
- } else if (*subtype == MEDIASUBTYPE_DTS) {
- for (int i = 0; i < curlen; i++) {
- if (*(DWORD*)&pIn[i] == 0x0180FE7F) {
- i++;
- Private1Header[19] = (i>>8)&0xff;
- Private1Header[20] = i&0xff;
- break;
- }
- }
- }
-
- memcpy(pOut, &Private1Header, sizeof(Private1Header));
- pOut += sizeof(Private1Header);
-
- majortype = &MEDIATYPE_Audio;
- }
-
- if (*majortype == MEDIATYPE_Audio) {
- if (size < curlen) {
- return E_FAIL;
- }
- memcpy(pOut, pIn, curlen);
- pIn += curlen;
- pOut += curlen;
- }
-
- pOutSample->SetActualDataLength(pOut - pOutOrg);
-
- hr = m_pOutput->Deliver(pOutSample);
- }
-
- return S_FALSE;
- } else { // phew, we can do the easier way
- const GUID* majortype = &m_pOutput->CurrentMediaType().majortype;
- const GUID* subtype = &m_pOutput->CurrentMediaType().subtype;
-
- if (*majortype == MEDIATYPE_DVD_ENCRYPTED_PACK) {
- if (size < len + 32 + 3) {
- return E_FAIL;
- }
-
- BYTE PESHeader[] = {
- 0x00,0x00,0x01,0xBA, // PES id
- 0x44,0x00,0x04,0x00,0x04,0x01, // SCR (0)
- 0x01,0x89,0xC3,0xF8, // mux rate (1260000 bytes/sec, 22bits), marker (2bits), reserved (~0, 5bits), stuffing (0, 3bits)
- };
-
- memcpy(pOut, &PESHeader, sizeof(PESHeader));
- pOut += sizeof(PESHeader);
-
- majortype = &MEDIATYPE_MPEG2_PES;
- }
-
- if (*majortype == MEDIATYPE_MPEG2_PES) {
- if (size < len + 20 + 3) {
- return E_FAIL;
- }
-
- BYTE Private1Header[] = {
- 0x00,0x00,0x01,0xBD, // private stream 1 id
- 0x07,0xEC, // packet length (TODO: modify it later)
- 0x81,0x80, // marker, original, PTS - flags
- 0x08, // packet data starting offset
- 0x21,0x00,0x01,0x00,0x01, // PTS (0)
- 0xFF,0xFF,0xFF, // stuffing
- 0x80, // stream id (0)
- 0x01,0x00,0x01, // no idea about the first byte, the sencond+third seem to show the ac3/dts header sync offset plus one (dvd2avi doesn't output it to the ac3/dts file so we have to put it back)
- };
-
- int packetlen = len + 12 + 3;
- ASSERT(packetlen <= 0xffff);
- Private1Header[4] = (packetlen>>8)&0xff;
- Private1Header[5] = packetlen&0xff;
-
- if (*subtype == MEDIASUBTYPE_DTS) {
- Private1Header[17] += 8;
- }
-
- memcpy(pOut, &Private1Header, sizeof(Private1Header));
- pOut += sizeof(Private1Header);
-
- majortype = &MEDIATYPE_Audio;
- }
-
- if (*majortype == MEDIATYPE_Audio) {
- if (size < len) {
- return E_FAIL;
- }
-
- memcpy(pOut, pIn, len);
- pIn += len;
- pOut += len;
- }
- }
- } else {
- return E_FAIL;
- }
-
- pOutSample->SetActualDataLength(pOut - pOutOrg);
-
- return S_OK;
+ HRESULT hr;
+
+ BYTE* pIn = NULL;
+ if (FAILED(hr = pSample->GetPointer(&pIn))) {
+ return hr;
+ }
+ BYTE* pInOrg = pIn;
+
+ long len = pSample->GetActualDataLength();
+ if (len <= 0) {
+ return S_FALSE;
+ }
+
+ BYTE* pOut = NULL;
+ if (FAILED(hr = pOutSample->GetPointer(&pOut))) {
+ return hr;
+ }
+ BYTE* pOutOrg = pOut;
+
+ int size = pOutSample->GetSize();
+
+ if ((CheckAC3(&m_pInput->CurrentMediaType()) || CheckDTS(&m_pInput->CurrentMediaType()))
+ && (CheckWAVEAC3(&m_pOutput->CurrentMediaType()) || CheckWAVEDTS(&m_pOutput->CurrentMediaType()))) {
+ if (*(DWORD*)pIn == 0xBA010000) {
+ pIn += 14;
+ }
+
+ if (*(DWORD*)pIn == 0xBD010000) {
+ pIn += 8 + 1 + pIn[8] + 1 + 3;
+ }
+
+ len -= (pInOrg - pIn);
+
+ if (size < len) {
+ return E_FAIL;
+ }
+
+ memcpy(pOut, pIn, len);
+ pOut += len;
+ } else if ((CheckWAVEAC3(&m_pInput->CurrentMediaType()) || CheckWAVEDTS(&m_pInput->CurrentMediaType()))
+ && (CheckAC3(&m_pOutput->CurrentMediaType()) || CheckDTS(&m_pOutput->CurrentMediaType()))) {
+ if ((m_pOutput->CurrentMediaType().majortype == MEDIATYPE_DVD_ENCRYPTED_PACK
+ || m_pOutput->CurrentMediaType().majortype == MEDIATYPE_MPEG2_PES)
+ && (len + 12 + 3) >= 0x10000) { // damn, this can happen if the interleave time is too big
+ REFERENCE_TIME rtStart = 0, rtStop = 1;
+ bool fHasTime = (S_OK == pSample->GetTime(&rtStart, &rtStop));
+
+ bool fDiscontinuity = (S_OK == pOutSample->IsDiscontinuity());
+
+ int pos = 0;
+ while (pos < len) {
+ int curlen = min(len - pos, 2013);
+ pos += 2013;
+
+ CComPtr<IMediaSample> pOutSample;
+ hr = InitializeOutputSample(pSample, &pOutSample);
+
+ if (fDiscontinuity) {
+ if (fHasTime) {
+ rtStop = rtStart + (rtStop - rtStart) * curlen / len;
+ pOutSample->SetTime(&rtStart, &rtStop);
+ }
+
+ fDiscontinuity = false;
+ } else {
+ pOutSample->SetTime(NULL, NULL);
+ pOutSample->SetDiscontinuity(FALSE);
+ }
+
+ BYTE* pOut = NULL;
+ if (FAILED(hr = pOutSample->GetPointer(&pOut))) {
+ return hr;
+ }
+ BYTE* pOutOrg = pOut;
+
+ int size = pOutSample->GetSize();
+
+ const GUID* majortype = &m_pOutput->CurrentMediaType().majortype;
+ const GUID* subtype = &m_pOutput->CurrentMediaType().subtype;
+
+ if (*majortype == MEDIATYPE_DVD_ENCRYPTED_PACK) {
+ if (size < curlen + 32 + 3) {
+ return E_FAIL;
+ }
+
+ BYTE PESHeader[] = {
+ 0x00, 0x00, 0x01, 0xBA, // PES id
+ 0x44, 0x00, 0x04, 0x00, 0x04, 0x01, // SCR (0)
+ 0x01, 0x89, 0xC3, 0xF8, // mux rate (1260000 bytes/sec, 22bits), marker (2bits), reserved (~0, 5bits), stuffing (0, 3bits)
+ };
+
+ memcpy(pOut, &PESHeader, sizeof(PESHeader));
+ pOut += sizeof(PESHeader);
+
+ majortype = &MEDIATYPE_MPEG2_PES;
+ }
+
+ if (*majortype == MEDIATYPE_MPEG2_PES) {
+ if (size < curlen + 20 + 3) {
+ return E_FAIL;
+ }
+
+ BYTE Private1Header[] = {
+ 0x00, 0x00, 0x01, 0xBD, // private stream 1 id
+ 0x07, 0xEC, // packet length (TODO: modify it later)
+ 0x81, 0x80, // marker, original, PTS - flags
+ 0x08, // packet data starting offset
+ 0x21, 0x00, 0x01, 0x00, 0x01, // PTS (0)
+ 0xFF, 0xFF, 0xFF, // stuffing
+ 0x80, // stream id (0)
+ 0x01, 0x00, 0x01, // no idea about the first byte, the sencond+third seem to show the ac3/dts header sync offset plus one (dvd2avi doesn't output it to the ac3/dts file so we have to put it back)
+ };
+
+ int packetlen = curlen + 12 + 3;
+ ASSERT(packetlen <= 0xffff);
+ Private1Header[4] = (packetlen >> 8) & 0xff;
+ Private1Header[5] = packetlen & 0xff;
+
+ if (*subtype == MEDIASUBTYPE_DTS) {
+ Private1Header[17] += 8;
+ }
+
+ if (*subtype == MEDIASUBTYPE_DOLBY_AC3) {
+ for (int i = 0; i < curlen; i++) {
+ if (*(DWORD*)&pIn[i] == 0x770B) {
+ i++;
+ Private1Header[19] = (i >> 8) & 0xff;
+ Private1Header[20] = i & 0xff;
+ break;
+ }
+ }
+ } else if (*subtype == MEDIASUBTYPE_DTS) {
+ for (int i = 0; i < curlen; i++) {
+ if (*(DWORD*)&pIn[i] == 0x0180FE7F) {
+ i++;
+ Private1Header[19] = (i >> 8) & 0xff;
+ Private1Header[20] = i & 0xff;
+ break;
+ }
+ }
+ }
+
+ memcpy(pOut, &Private1Header, sizeof(Private1Header));
+ pOut += sizeof(Private1Header);
+
+ majortype = &MEDIATYPE_Audio;
+ }
+
+ if (*majortype == MEDIATYPE_Audio) {
+ if (size < curlen) {
+ return E_FAIL;
+ }
+ memcpy(pOut, pIn, curlen);
+ pIn += curlen;
+ pOut += curlen;
+ }
+
+ pOutSample->SetActualDataLength(pOut - pOutOrg);
+
+ hr = m_pOutput->Deliver(pOutSample);
+ }
+
+ return S_FALSE;
+ } else { // phew, we can do the easier way
+ const GUID* majortype = &m_pOutput->CurrentMediaType().majortype;
+ const GUID* subtype = &m_pOutput->CurrentMediaType().subtype;
+
+ if (*majortype == MEDIATYPE_DVD_ENCRYPTED_PACK) {
+ if (size < len + 32 + 3) {
+ return E_FAIL;
+ }
+
+ BYTE PESHeader[] = {
+ 0x00, 0x00, 0x01, 0xBA, // PES id
+ 0x44, 0x00, 0x04, 0x00, 0x04, 0x01, // SCR (0)
+ 0x01, 0x89, 0xC3, 0xF8, // mux rate (1260000 bytes/sec, 22bits), marker (2bits), reserved (~0, 5bits), stuffing (0, 3bits)
+ };
+
+ memcpy(pOut, &PESHeader, sizeof(PESHeader));
+ pOut += sizeof(PESHeader);
+
+ majortype = &MEDIATYPE_MPEG2_PES;
+ }
+
+ if (*majortype == MEDIATYPE_MPEG2_PES) {
+ if (size < len + 20 + 3) {
+ return E_FAIL;
+ }
+
+ BYTE Private1Header[] = {
+ 0x00, 0x00, 0x01, 0xBD, // private stream 1 id
+ 0x07, 0xEC, // packet length (TODO: modify it later)
+ 0x81, 0x80, // marker, original, PTS - flags
+ 0x08, // packet data starting offset
+ 0x21, 0x00, 0x01, 0x00, 0x01, // PTS (0)
+ 0xFF, 0xFF, 0xFF, // stuffing
+ 0x80, // stream id (0)
+ 0x01, 0x00, 0x01, // no idea about the first byte, the sencond+third seem to show the ac3/dts header sync offset plus one (dvd2avi doesn't output it to the ac3/dts file so we have to put it back)
+ };
+
+ int packetlen = len + 12 + 3;
+ ASSERT(packetlen <= 0xffff);
+ Private1Header[4] = (packetlen >> 8) & 0xff;
+ Private1Header[5] = packetlen & 0xff;
+
+ if (*subtype == MEDIASUBTYPE_DTS) {
+ Private1Header[17] += 8;
+ }
+
+ memcpy(pOut, &Private1Header, sizeof(Private1Header));
+ pOut += sizeof(Private1Header);
+
+ majortype = &MEDIATYPE_Audio;
+ }
+
+ if (*majortype == MEDIATYPE_Audio) {
+ if (size < len) {
+ return E_FAIL;
+ }
+
+ memcpy(pOut, pIn, len);
+ pIn += len;
+ pOut += len;
+ }
+ }
+ } else {
+ return E_FAIL;
+ }
+
+ pOutSample->SetActualDataLength(pOut - pOutOrg);
+
+ return S_OK;
}
bool CAVI2AC3Filter::CheckAC3(const CMediaType* pmt)
{
- return (pmt->majortype == MEDIATYPE_Audio
- || pmt->majortype == MEDIATYPE_MPEG2_PES
- || pmt->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK)
- && pmt->subtype == MEDIASUBTYPE_DOLBY_AC3;
+ return (pmt->majortype == MEDIATYPE_Audio
+ || pmt->majortype == MEDIATYPE_MPEG2_PES
+ || pmt->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK)
+ && pmt->subtype == MEDIASUBTYPE_DOLBY_AC3;
}
bool CAVI2AC3Filter::CheckDTS(const CMediaType* pmt)
{
- return (pmt->majortype == MEDIATYPE_Audio
- || pmt->majortype == MEDIATYPE_MPEG2_PES
- || pmt->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK)
- && pmt->subtype == MEDIASUBTYPE_DTS;
+ return (pmt->majortype == MEDIATYPE_Audio
+ || pmt->majortype == MEDIATYPE_MPEG2_PES
+ || pmt->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK)
+ && pmt->subtype == MEDIASUBTYPE_DTS;
}
bool CAVI2AC3Filter::CheckWAVEAC3(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Audio
- && pmt->subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3
- && pmt->formattype == FORMAT_WaveFormatEx
- && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_DOLBY_AC3;
+ return pmt->majortype == MEDIATYPE_Audio
+ && pmt->subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3
+ && pmt->formattype == FORMAT_WaveFormatEx
+ && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_DOLBY_AC3;
}
bool CAVI2AC3Filter::CheckWAVEDTS(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Audio
- && pmt->subtype == MEDIASUBTYPE_WAVE_DTS
- && pmt->formattype == FORMAT_WaveFormatEx
- && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_DVD_DTS;
+ return pmt->majortype == MEDIATYPE_Audio
+ && pmt->subtype == MEDIASUBTYPE_WAVE_DTS
+ && pmt->formattype == FORMAT_WaveFormatEx
+ && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_DVD_DTS;
}
HRESULT CAVI2AC3Filter::CheckInputType(const CMediaType* mtIn)
{
- bool fWaveFormatEx = !!(mtIn->formattype == FORMAT_WaveFormatEx);
+ bool fWaveFormatEx = !!(mtIn->formattype == FORMAT_WaveFormatEx);
- return CheckAC3(mtIn) && fWaveFormatEx || CheckDTS(mtIn) && fWaveFormatEx
- || CheckWAVEAC3(mtIn) || CheckWAVEDTS(mtIn)
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ return CheckAC3(mtIn) && fWaveFormatEx || CheckDTS(mtIn) && fWaveFormatEx
+ || CheckWAVEAC3(mtIn) || CheckWAVEDTS(mtIn)
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CAVI2AC3Filter::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
{
- return CheckAC3(mtIn) && CheckWAVEAC3(mtOut)
- || CheckWAVEAC3(mtIn) && CheckAC3(mtOut)
- || CheckDTS(mtIn) && CheckWAVEDTS(mtOut)
- || CheckWAVEDTS(mtIn) && CheckDTS(mtOut)
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ return CheckAC3(mtIn) && CheckWAVEAC3(mtOut)
+ || CheckWAVEAC3(mtIn) && CheckAC3(mtOut)
+ || CheckDTS(mtIn) && CheckWAVEDTS(mtOut)
+ || CheckWAVEDTS(mtIn) && CheckDTS(mtOut)
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CAVI2AC3Filter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if (m_pInput->IsConnected() == FALSE) {
- return E_UNEXPECTED;
- }
-
- CComPtr<IMemAllocator> pAllocatorIn;
- m_pInput->GetAllocator(&pAllocatorIn);
- if (!pAllocatorIn) {
- return E_UNEXPECTED;
- }
-
- pAllocatorIn->GetProperties(pProperties);
-
- pProperties->cBuffers = 2;
- pProperties->cbBuffer = max(pProperties->cbBuffer, 1024*1024); // this should be enough...
- pProperties->cbAlign = 1;
- pProperties->cbPrefix = 0;
-
- HRESULT hr;
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
- return hr;
- }
-
- return (pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
- ? E_FAIL
- : NOERROR);
+ if (m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
+
+ CComPtr<IMemAllocator> pAllocatorIn;
+ m_pInput->GetAllocator(&pAllocatorIn);
+ if (!pAllocatorIn) {
+ return E_UNEXPECTED;
+ }
+
+ pAllocatorIn->GetProperties(pProperties);
+
+ pProperties->cBuffers = 2;
+ pProperties->cbBuffer = max(pProperties->cbBuffer, 1024 * 1024); // this should be enough...
+ pProperties->cbAlign = 1;
+ pProperties->cbPrefix = 0;
+
+ HRESULT hr;
+ ALLOCATOR_PROPERTIES Actual;
+ if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
+
+ return (pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
+ ? E_FAIL
+ : NOERROR);
}
HRESULT CAVI2AC3Filter::GetMediaType(int iPosition, CMediaType* pMediaType)
{
- if (m_pInput->IsConnected() == FALSE) {
- return E_UNEXPECTED;
- }
-
- const GUID& majortype = m_pInput->CurrentMediaType().majortype;
- const GUID& subtype = m_pInput->CurrentMediaType().subtype;
- UNREFERENCED_PARAMETER(majortype);
-
- if (CheckAC3(&m_pInput->CurrentMediaType()) || CheckDTS(&m_pInput->CurrentMediaType())) {
- if (iPosition < 0) {
- return E_INVALIDARG;
- }
- if (iPosition > 0) {
- return VFW_S_NO_MORE_ITEMS;
- }
-
- pMediaType->majortype = MEDIATYPE_Audio;
-
- pMediaType->formattype = FORMAT_WaveFormatEx;
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)pMediaType->AllocFormatBuffer(sizeof(WAVEFORMATEX));
- memset(wfe, 0, sizeof(WAVEFORMATEX));
- wfe->cbSize = sizeof(WAVEFORMATEX);
- wfe->nAvgBytesPerSec = ((WAVEFORMATEX*)m_pInput->CurrentMediaType().pbFormat)->nAvgBytesPerSec;
- wfe->nSamplesPerSec = ((WAVEFORMATEX*)m_pInput->CurrentMediaType().pbFormat)->nSamplesPerSec;
- wfe->wBitsPerSample = ((WAVEFORMATEX*)m_pInput->CurrentMediaType().pbFormat)->wBitsPerSample;
- wfe->nChannels = 2;
- wfe->nBlockAlign = 1;
-
- if (subtype == MEDIASUBTYPE_DOLBY_AC3) {
- pMediaType->subtype = MEDIASUBTYPE_WAVE_DOLBY_AC3;
- wfe->wFormatTag = WAVE_FORMAT_DOLBY_AC3;
- } else if (subtype == MEDIASUBTYPE_DTS) {
- pMediaType->subtype = MEDIASUBTYPE_WAVE_DTS;
- wfe->wFormatTag = WAVE_FORMAT_DVD_DTS;
- } else {
- return E_INVALIDARG;
- }
- } else if (CheckWAVEAC3(&m_pInput->CurrentMediaType()) || CheckWAVEDTS(&m_pInput->CurrentMediaType())) {
- if (iPosition < 0) {
- return E_INVALIDARG;
- }
- if (iPosition > 4) {
- return VFW_S_NO_MORE_ITEMS;
- }
-
- if (subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3) {
- pMediaType->subtype = MEDIASUBTYPE_DOLBY_AC3;
-
- pMediaType->formattype = FORMAT_WaveFormatEx;
- DOLBYAC3WAVEFORMAT* wfe = (DOLBYAC3WAVEFORMAT*)pMediaType->AllocFormatBuffer(sizeof(DOLBYAC3WAVEFORMAT));
- memset(wfe, 0, sizeof(DOLBYAC3WAVEFORMAT));
- // unfortunately we can't tell what we are going to get in transform,
- // so we just set the most common values and hope that the ac3 decoder
- // is flexible enough (it is usually :) to find out these from the bitstream
- wfe->wfx.cbSize = sizeof(DOLBYAC3WAVEFORMAT) - sizeof(WAVEFORMATEX);
- wfe->wfx.wFormatTag = WAVE_FORMAT_DOLBY_AC3;
- wfe->wfx.nSamplesPerSec = 48000;
- wfe->wfx.nChannels = 6;
- wfe->bBigEndian = TRUE;
- } else if (subtype == MEDIASUBTYPE_WAVE_DTS) {
- pMediaType->subtype = MEDIASUBTYPE_DTS;
-
- pMediaType->formattype = FORMAT_WaveFormatEx;
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)pMediaType->AllocFormatBuffer(sizeof(WAVEFORMATEX));
- memset(wfe, 0, sizeof(WAVEFORMATEX));
- // same case as with ac3, but this time we don't even know the structure
- wfe->cbSize = sizeof(WAVEFORMATEX);
- wfe->wFormatTag = WAVE_FORMAT_PCM;
- wfe->nSamplesPerSec = 48000;
- wfe->nChannels = 6;
- } else {
- return E_INVALIDARG;
- }
-
- switch (iPosition) {
- case 0:
- pMediaType->majortype = MEDIATYPE_Audio;
- break;
- case 1:
- pMediaType->ResetFormatBuffer();
- pMediaType->formattype = FORMAT_None;
- case 2:
- pMediaType->majortype = MEDIATYPE_MPEG2_PES;
- break;
- case 3:
- pMediaType->ResetFormatBuffer();
- pMediaType->formattype = FORMAT_None;
- case 4:
- pMediaType->majortype = MEDIATYPE_DVD_ENCRYPTED_PACK;
- break;
- default:
- return E_INVALIDARG;
- }
- } else {
- return VFW_S_NO_MORE_ITEMS;
- }
-
- return S_OK;
+ if (m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
+
+ const GUID& majortype = m_pInput->CurrentMediaType().majortype;
+ const GUID& subtype = m_pInput->CurrentMediaType().subtype;
+ UNREFERENCED_PARAMETER(majortype);
+
+ if (CheckAC3(&m_pInput->CurrentMediaType()) || CheckDTS(&m_pInput->CurrentMediaType())) {
+ if (iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if (iPosition > 0) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
+
+ pMediaType->majortype = MEDIATYPE_Audio;
+
+ pMediaType->formattype = FORMAT_WaveFormatEx;
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)pMediaType->AllocFormatBuffer(sizeof(WAVEFORMATEX));
+ memset(wfe, 0, sizeof(WAVEFORMATEX));
+ wfe->cbSize = sizeof(WAVEFORMATEX);
+ wfe->nAvgBytesPerSec = ((WAVEFORMATEX*)m_pInput->CurrentMediaType().pbFormat)->nAvgBytesPerSec;
+ wfe->nSamplesPerSec = ((WAVEFORMATEX*)m_pInput->CurrentMediaType().pbFormat)->nSamplesPerSec;
+ wfe->wBitsPerSample = ((WAVEFORMATEX*)m_pInput->CurrentMediaType().pbFormat)->wBitsPerSample;
+ wfe->nChannels = 2;
+ wfe->nBlockAlign = 1;
+
+ if (subtype == MEDIASUBTYPE_DOLBY_AC3) {
+ pMediaType->subtype = MEDIASUBTYPE_WAVE_DOLBY_AC3;
+ wfe->wFormatTag = WAVE_FORMAT_DOLBY_AC3;
+ } else if (subtype == MEDIASUBTYPE_DTS) {
+ pMediaType->subtype = MEDIASUBTYPE_WAVE_DTS;
+ wfe->wFormatTag = WAVE_FORMAT_DVD_DTS;
+ } else {
+ return E_INVALIDARG;
+ }
+ } else if (CheckWAVEAC3(&m_pInput->CurrentMediaType()) || CheckWAVEDTS(&m_pInput->CurrentMediaType())) {
+ if (iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if (iPosition > 4) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
+
+ if (subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3) {
+ pMediaType->subtype = MEDIASUBTYPE_DOLBY_AC3;
+
+ pMediaType->formattype = FORMAT_WaveFormatEx;
+ DOLBYAC3WAVEFORMAT* wfe = (DOLBYAC3WAVEFORMAT*)pMediaType->AllocFormatBuffer(sizeof(DOLBYAC3WAVEFORMAT));
+ memset(wfe, 0, sizeof(DOLBYAC3WAVEFORMAT));
+ // unfortunately we can't tell what we are going to get in transform,
+ // so we just set the most common values and hope that the ac3 decoder
+ // is flexible enough (it is usually :) to find out these from the bitstream
+ wfe->wfx.cbSize = sizeof(DOLBYAC3WAVEFORMAT) - sizeof(WAVEFORMATEX);
+ wfe->wfx.wFormatTag = WAVE_FORMAT_DOLBY_AC3;
+ wfe->wfx.nSamplesPerSec = 48000;
+ wfe->wfx.nChannels = 6;
+ wfe->bBigEndian = TRUE;
+ } else if (subtype == MEDIASUBTYPE_WAVE_DTS) {
+ pMediaType->subtype = MEDIASUBTYPE_DTS;
+
+ pMediaType->formattype = FORMAT_WaveFormatEx;
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)pMediaType->AllocFormatBuffer(sizeof(WAVEFORMATEX));
+ memset(wfe, 0, sizeof(WAVEFORMATEX));
+ // same case as with ac3, but this time we don't even know the structure
+ wfe->cbSize = sizeof(WAVEFORMATEX);
+ wfe->wFormatTag = WAVE_FORMAT_PCM;
+ wfe->nSamplesPerSec = 48000;
+ wfe->nChannels = 6;
+ } else {
+ return E_INVALIDARG;
+ }
+
+ switch (iPosition) {
+ case 0:
+ pMediaType->majortype = MEDIATYPE_Audio;
+ break;
+ case 1:
+ pMediaType->ResetFormatBuffer();
+ pMediaType->formattype = FORMAT_None;
+ case 2:
+ pMediaType->majortype = MEDIATYPE_MPEG2_PES;
+ break;
+ case 3:
+ pMediaType->ResetFormatBuffer();
+ pMediaType->formattype = FORMAT_None;
+ case 4:
+ pMediaType->majortype = MEDIATYPE_DVD_ENCRYPTED_PACK;
+ break;
+ default:
+ return E_INVALIDARG;
+ }
+ } else {
+ return VFW_S_NO_MORE_ITEMS;
+ }
+
+ return S_OK;
}
diff --git a/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.h b/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.h
index 91c5990d7..56d49dc67 100644
--- a/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.h
+++ b/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.h
@@ -37,12 +37,12 @@
*/
typedef struct tagDOLBYAC3WAVEFORMAT {
- WAVEFORMATEX wfx;
- BYTE bBigEndian; // TRUE = Big Endian, FALSE little endian
- BYTE bsid;
- BYTE lfeon;
- BYTE copyrightb;
- BYTE nAuxBitsCode; // Aux bits per frame
+ WAVEFORMATEX wfx;
+ BYTE bBigEndian; // TRUE = Big Endian, FALSE little endian
+ BYTE bsid;
+ BYTE lfeon;
+ BYTE copyrightb;
+ BYTE nAuxBitsCode; // Aux bits per frame
} DOLBYAC3WAVEFORMAT;
//
@@ -50,20 +50,20 @@ typedef struct tagDOLBYAC3WAVEFORMAT {
//
class __declspec(uuid("93230DD0-7B3C-4efb-AFBB-DC380FEC9E6B"))
- CAVI2AC3Filter : public CTransformFilter
+ CAVI2AC3Filter : public CTransformFilter
{
- bool CheckAC3(const CMediaType* pmt);
- bool CheckDTS(const CMediaType* pmt);
- bool CheckWAVEAC3(const CMediaType* pmt);
- bool CheckWAVEDTS(const CMediaType* pmt);
+ bool CheckAC3(const CMediaType* pmt);
+ bool CheckDTS(const CMediaType* pmt);
+ bool CheckWAVEAC3(const CMediaType* pmt);
+ bool CheckWAVEDTS(const CMediaType* pmt);
public:
- CAVI2AC3Filter(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CAVI2AC3Filter();
+ CAVI2AC3Filter(LPUNKNOWN lpunk, HRESULT* phr);
+ virtual ~CAVI2AC3Filter();
- HRESULT Transform(IMediaSample* pIn, IMediaSample* pOut);
- HRESULT CheckInputType(const CMediaType* mtIn);
- HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
- HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT GetMediaType(int iPosition, CMediaType* pMediaType);
+ HRESULT Transform(IMediaSample* pIn, IMediaSample* pOut);
+ HRESULT CheckInputType(const CMediaType* mtIn);
+ HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
+ HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT GetMediaType(int iPosition, CMediaType* pMediaType);
};
diff --git a/src/filters/transform/BaseVideoFilter/BaseVideoFilter.cpp b/src/filters/transform/BaseVideoFilter/BaseVideoFilter.cpp
index 62f002a58..9465047cb 100644
--- a/src/filters/transform/BaseVideoFilter/BaseVideoFilter.cpp
+++ b/src/filters/transform/BaseVideoFilter/BaseVideoFilter.cpp
@@ -36,36 +36,36 @@
bool f_need_set_aspect;
CBaseVideoFilter::CBaseVideoFilter(TCHAR* pName, LPUNKNOWN lpunk, HRESULT* phr, REFCLSID clsid, long cBuffers)
- : CTransformFilter(pName, lpunk, clsid)
- , m_cBuffers(cBuffers)
+ : CTransformFilter(pName, lpunk, clsid)
+ , m_cBuffers(cBuffers)
{
- if (phr) {
- *phr = S_OK;
- }
-
- m_pInput = DNew CBaseVideoInputPin(NAME("CBaseVideoInputPin"), this, phr, L"Video");
- if (!m_pInput) {
- *phr = E_OUTOFMEMORY;
- }
- if (FAILED(*phr)) {
- return;
- }
-
- m_pOutput = DNew CBaseVideoOutputPin(NAME("CBaseVideoOutputPin"), this, phr, L"Output");
- if (!m_pOutput) {
- *phr = E_OUTOFMEMORY;
- }
- if (FAILED(*phr)) {
- delete m_pInput, m_pInput = NULL;
- return;
- }
-
- m_wout = m_win = m_w = 0;
- m_hout = m_hin = m_h = 0;
- m_arxout = m_arxin = m_arx = 0;
- m_aryout = m_aryin = m_ary = 0;
-
- f_need_set_aspect = false;
+ if (phr) {
+ *phr = S_OK;
+ }
+
+ m_pInput = DNew CBaseVideoInputPin(NAME("CBaseVideoInputPin"), this, phr, L"Video");
+ if (!m_pInput) {
+ *phr = E_OUTOFMEMORY;
+ }
+ if (FAILED(*phr)) {
+ return;
+ }
+
+ m_pOutput = DNew CBaseVideoOutputPin(NAME("CBaseVideoOutputPin"), this, phr, L"Output");
+ if (!m_pOutput) {
+ *phr = E_OUTOFMEMORY;
+ }
+ if (FAILED(*phr)) {
+ delete m_pInput, m_pInput = NULL;
+ return;
+ }
+
+ m_wout = m_win = m_w = 0;
+ m_hout = m_hin = m_h = 0;
+ m_arxout = m_arxin = m_arx = 0;
+ m_aryout = m_aryin = m_ary = 0;
+
+ f_need_set_aspect = false;
}
CBaseVideoFilter::~CBaseVideoFilter()
@@ -74,567 +74,567 @@ CBaseVideoFilter::~CBaseVideoFilter()
void CBaseVideoFilter::SetAspect(CSize aspect)
{
- f_need_set_aspect = true;
- m_arx = aspect.cx;
- m_ary = aspect.cy;
+ f_need_set_aspect = true;
+ m_arx = aspect.cx;
+ m_ary = aspect.cy;
}
int CBaseVideoFilter::GetPinCount()
{
- return 2;
+ return 2;
}
CBasePin* CBaseVideoFilter::GetPin(int n)
{
- switch (n) {
- case 0:
- return m_pInput;
- case 1:
- return m_pOutput;
- }
- return NULL;
+ switch (n) {
+ case 0:
+ return m_pInput;
+ case 1:
+ return m_pOutput;
+ }
+ return NULL;
}
HRESULT CBaseVideoFilter::Receive(IMediaSample* pIn)
{
#ifndef _WIN64
- // TODOX64 : fixme!
- _mm_empty(); // just for safety
+ // TODOX64 : fixme!
+ _mm_empty(); // just for safety
#endif
- CAutoLock cAutoLock(&m_csReceive);
+ CAutoLock cAutoLock(&m_csReceive);
- HRESULT hr;
+ HRESULT hr;
- AM_SAMPLE2_PROPERTIES* const pProps = m_pInput->SampleProps();
- if (pProps->dwStreamId != AM_STREAM_MEDIA) {
- return m_pOutput->Deliver(pIn);
- }
+ AM_SAMPLE2_PROPERTIES* const pProps = m_pInput->SampleProps();
+ if (pProps->dwStreamId != AM_STREAM_MEDIA) {
+ return m_pOutput->Deliver(pIn);
+ }
- AM_MEDIA_TYPE* pmt;
- if (SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt) {
- CMediaType mt(*pmt);
- m_pInput->SetMediaType(&mt);
- DeleteMediaType(pmt);
- }
+ AM_MEDIA_TYPE* pmt;
+ if (SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt) {
+ CMediaType mt(*pmt);
+ m_pInput->SetMediaType(&mt);
+ DeleteMediaType(pmt);
+ }
- if (FAILED(hr = Transform(pIn))) {
- return hr;
- }
+ if (FAILED(hr = Transform(pIn))) {
+ return hr;
+ }
- return S_OK;
+ return S_OK;
}
HRESULT CBaseVideoFilter::GetDeliveryBuffer(int w, int h, IMediaSample** ppOut)
{
- CheckPointer(ppOut, E_POINTER);
+ CheckPointer(ppOut, E_POINTER);
- HRESULT hr;
+ HRESULT hr;
- if (FAILED(hr = ReconnectOutput(w, h))) {
- return hr;
- }
+ if (FAILED(hr = ReconnectOutput(w, h))) {
+ return hr;
+ }
- if (FAILED(hr = m_pOutput->GetDeliveryBuffer(ppOut, NULL, NULL, 0))) {
- return hr;
- }
+ if (FAILED(hr = m_pOutput->GetDeliveryBuffer(ppOut, NULL, NULL, 0))) {
+ return hr;
+ }
- AM_MEDIA_TYPE* pmt;
- if (SUCCEEDED((*ppOut)->GetMediaType(&pmt)) && pmt) {
- CMediaType mt = *pmt;
- m_pOutput->SetMediaType(&mt);
- DeleteMediaType(pmt);
- }
+ AM_MEDIA_TYPE* pmt;
+ if (SUCCEEDED((*ppOut)->GetMediaType(&pmt)) && pmt) {
+ CMediaType mt = *pmt;
+ m_pOutput->SetMediaType(&mt);
+ DeleteMediaType(pmt);
+ }
- (*ppOut)->SetDiscontinuity(FALSE);
- (*ppOut)->SetSyncPoint(TRUE);
+ (*ppOut)->SetDiscontinuity(FALSE);
+ (*ppOut)->SetSyncPoint(TRUE);
- // FIXME: hell knows why but without this the overlay mixer starts very skippy
- // (don't enable this for other renderers, the old for example will go crazy if you do)
- if (GetCLSID(m_pOutput->GetConnected()) == CLSID_OverlayMixer) {
- (*ppOut)->SetDiscontinuity(TRUE);
- }
+ // FIXME: hell knows why but without this the overlay mixer starts very skippy
+ // (don't enable this for other renderers, the old for example will go crazy if you do)
+ if (GetCLSID(m_pOutput->GetConnected()) == CLSID_OverlayMixer) {
+ (*ppOut)->SetDiscontinuity(TRUE);
+ }
- return S_OK;
+ return S_OK;
}
HRESULT CBaseVideoFilter::ReconnectOutput(int w, int h, bool bSendSample, int realWidth, int realHeight)
{
- CMediaType& mt = m_pOutput->CurrentMediaType();
-
- bool m_update_aspect = false;
- if (f_need_set_aspect) {
- int wout = 0, hout = 0, arxout = 0, aryout = 0;
- ExtractDim(&mt, wout, hout, arxout, aryout);
- if (arxout != m_arx || aryout != m_ary) {
- TRACE(_T("\nCBaseVideoFilter::ReconnectOutput; wout = %d, hout = %d, current = %dx%d, set = %dx%d\n"), wout, hout, arxout, aryout, m_arx, m_ary);
- m_update_aspect = true;
- }
- }
-
- int w_org = m_w;
- int h_org = m_h;
-
- bool fForceReconnection = false;
- if (w != m_w || h != m_h) {
- fForceReconnection = true;
- m_w = w;
- m_h = h;
- }
-
- HRESULT hr = S_OK;
-
- if (m_update_aspect || fForceReconnection || m_w != m_wout || m_h != m_hout || m_arx != m_arxout || m_ary != m_aryout) {
- if (GetCLSID(m_pOutput->GetConnected()) == CLSID_VideoRenderer) {
- NotifyEvent(EC_ERRORABORT, 0, 0);
- return E_FAIL;
- }
-
- BITMAPINFOHEADER* bmi = NULL;
-
- if (mt.formattype == FORMAT_VideoInfo) {
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mt.Format();
- if (realWidth > 0 && realHeight > 0) {
- SetRect(&vih->rcSource, 0, 0, realWidth, realHeight);
- SetRect(&vih->rcTarget, 0, 0, realWidth, realHeight);
- } else {
- SetRect(&vih->rcSource, 0, 0, m_w, m_h);
- SetRect(&vih->rcTarget, 0, 0, m_w, m_h);
- }
- bmi = &vih->bmiHeader;
- bmi->biXPelsPerMeter = m_w * m_ary;
- bmi->biYPelsPerMeter = m_h * m_arx;
- } else if (mt.formattype == FORMAT_VideoInfo2) {
- VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)mt.Format();
- if (realWidth > 0 && realHeight > 0) {
- SetRect(&vih->rcSource, 0, 0, realWidth, realHeight);
- SetRect(&vih->rcTarget, 0, 0, realWidth, realHeight);
- } else {
- SetRect(&vih->rcSource, 0, 0, m_w, m_h);
- SetRect(&vih->rcTarget, 0, 0, m_w, m_h);
- }
- bmi = &vih->bmiHeader;
- vih->dwPictAspectRatioX = m_arx;
- vih->dwPictAspectRatioY = m_ary;
- } else {
- return E_FAIL; //should never be here? prevent null pointer refs for bmi
- }
-
- bmi->biWidth = m_w;
- bmi->biHeight = m_h;
- bmi->biSizeImage = m_w*m_h*bmi->biBitCount>>3;
-
- hr = m_pOutput->GetConnected()->QueryAccept(&mt);
- ASSERT(SUCCEEDED(hr)); // should better not fail, after all "mt" is the current media type, just with a different resolution
- HRESULT hr1 = 0;
- CComPtr<IMediaSample> pOut;
- if (SUCCEEDED(hr1 = m_pOutput->GetConnected()->ReceiveConnection(m_pOutput, &mt))) {
- if (bSendSample) {
- HRESULT hr2 = 0;
- if (SUCCEEDED(hr2 = m_pOutput->GetDeliveryBuffer(&pOut, NULL, NULL, 0))) {
- AM_MEDIA_TYPE* pmt;
- if (SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt) {
- CMediaType mt = *pmt;
- m_pOutput->SetMediaType(&mt);
- DeleteMediaType(pmt);
- } else { // stupid overlay mixer won't let us know the new pitch...
- long size = pOut->GetSize();
- bmi->biWidth = size ? (size / abs(bmi->biHeight) * 8 / bmi->biBitCount) : bmi->biWidth;
- }
- } else {
- m_w = w_org;
- m_h = h_org;
- return E_FAIL;
- }
- }
- }
-
- m_wout = m_w;
- m_hout = m_h;
- m_arxout = m_arx;
- m_aryout = m_ary;
-
- // some renderers don't send this
- NotifyEvent(EC_VIDEO_SIZE_CHANGED, MAKELPARAM(m_w, m_h), 0);
-
- return S_OK;
- }
-
- return S_FALSE;
+ CMediaType& mt = m_pOutput->CurrentMediaType();
+
+ bool m_update_aspect = false;
+ if (f_need_set_aspect) {
+ int wout = 0, hout = 0, arxout = 0, aryout = 0;
+ ExtractDim(&mt, wout, hout, arxout, aryout);
+ if (arxout != m_arx || aryout != m_ary) {
+ TRACE(_T("\nCBaseVideoFilter::ReconnectOutput; wout = %d, hout = %d, current = %dx%d, set = %dx%d\n"), wout, hout, arxout, aryout, m_arx, m_ary);
+ m_update_aspect = true;
+ }
+ }
+
+ int w_org = m_w;
+ int h_org = m_h;
+
+ bool fForceReconnection = false;
+ if (w != m_w || h != m_h) {
+ fForceReconnection = true;
+ m_w = w;
+ m_h = h;
+ }
+
+ HRESULT hr = S_OK;
+
+ if (m_update_aspect || fForceReconnection || m_w != m_wout || m_h != m_hout || m_arx != m_arxout || m_ary != m_aryout) {
+ if (GetCLSID(m_pOutput->GetConnected()) == CLSID_VideoRenderer) {
+ NotifyEvent(EC_ERRORABORT, 0, 0);
+ return E_FAIL;
+ }
+
+ BITMAPINFOHEADER* bmi = NULL;
+
+ if (mt.formattype == FORMAT_VideoInfo) {
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mt.Format();
+ if (realWidth > 0 && realHeight > 0) {
+ SetRect(&vih->rcSource, 0, 0, realWidth, realHeight);
+ SetRect(&vih->rcTarget, 0, 0, realWidth, realHeight);
+ } else {
+ SetRect(&vih->rcSource, 0, 0, m_w, m_h);
+ SetRect(&vih->rcTarget, 0, 0, m_w, m_h);
+ }
+ bmi = &vih->bmiHeader;
+ bmi->biXPelsPerMeter = m_w * m_ary;
+ bmi->biYPelsPerMeter = m_h * m_arx;
+ } else if (mt.formattype == FORMAT_VideoInfo2) {
+ VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)mt.Format();
+ if (realWidth > 0 && realHeight > 0) {
+ SetRect(&vih->rcSource, 0, 0, realWidth, realHeight);
+ SetRect(&vih->rcTarget, 0, 0, realWidth, realHeight);
+ } else {
+ SetRect(&vih->rcSource, 0, 0, m_w, m_h);
+ SetRect(&vih->rcTarget, 0, 0, m_w, m_h);
+ }
+ bmi = &vih->bmiHeader;
+ vih->dwPictAspectRatioX = m_arx;
+ vih->dwPictAspectRatioY = m_ary;
+ } else {
+ return E_FAIL; //should never be here? prevent null pointer refs for bmi
+ }
+
+ bmi->biWidth = m_w;
+ bmi->biHeight = m_h;
+ bmi->biSizeImage = m_w * m_h * bmi->biBitCount >> 3;
+
+ hr = m_pOutput->GetConnected()->QueryAccept(&mt);
+ ASSERT(SUCCEEDED(hr)); // should better not fail, after all "mt" is the current media type, just with a different resolution
+ HRESULT hr1 = 0;
+ CComPtr<IMediaSample> pOut;
+ if (SUCCEEDED(hr1 = m_pOutput->GetConnected()->ReceiveConnection(m_pOutput, &mt))) {
+ if (bSendSample) {
+ HRESULT hr2 = 0;
+ if (SUCCEEDED(hr2 = m_pOutput->GetDeliveryBuffer(&pOut, NULL, NULL, 0))) {
+ AM_MEDIA_TYPE* pmt;
+ if (SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt) {
+ CMediaType mt = *pmt;
+ m_pOutput->SetMediaType(&mt);
+ DeleteMediaType(pmt);
+ } else { // stupid overlay mixer won't let us know the new pitch...
+ long size = pOut->GetSize();
+ bmi->biWidth = size ? (size / abs(bmi->biHeight) * 8 / bmi->biBitCount) : bmi->biWidth;
+ }
+ } else {
+ m_w = w_org;
+ m_h = h_org;
+ return E_FAIL;
+ }
+ }
+ }
+
+ m_wout = m_w;
+ m_hout = m_h;
+ m_arxout = m_arx;
+ m_aryout = m_ary;
+
+ // some renderers don't send this
+ NotifyEvent(EC_VIDEO_SIZE_CHANGED, MAKELPARAM(m_w, m_h), 0);
+
+ return S_OK;
+ }
+
+ return S_FALSE;
}
HRESULT CBaseVideoFilter::CopyBuffer(BYTE* pOut, BYTE* pIn, int w, int h, int pitchIn, const GUID& subtype, bool fInterlaced)
{
- int abs_h = abs(h);
- BYTE* pInYUV[3] = {pIn, pIn + pitchIn*abs_h, pIn + pitchIn*abs_h + (pitchIn>>1)*(abs_h>>1)};
- return CopyBuffer(pOut, pInYUV, w, h, pitchIn, subtype, fInterlaced);
+ int abs_h = abs(h);
+ BYTE* pInYUV[3] = {pIn, pIn + pitchIn * abs_h, pIn + pitchIn* abs_h + (pitchIn >> 1)* (abs_h >> 1)};
+ return CopyBuffer(pOut, pInYUV, w, h, pitchIn, subtype, fInterlaced);
}
HRESULT CBaseVideoFilter::CopyBuffer(BYTE* pOut, BYTE** ppIn, int w, int h, int pitchIn, const GUID& subtype, bool fInterlaced)
{
- BITMAPINFOHEADER bihOut;
- ExtractBIH(&m_pOutput->CurrentMediaType(), &bihOut);
-
- int pitchOut = 0;
-
- if (bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
- pitchOut = bihOut.biWidth*bihOut.biBitCount>>3;
-
- if (bihOut.biHeight > 0) {
- pOut += pitchOut*(h-1);
- pitchOut = -pitchOut;
- if (h < 0) {
- h = -h;
- }
- }
- }
-
- if (h < 0) {
- h = -h;
- ppIn[0] += pitchIn*(h-1);
- ppIn[1] += (pitchIn>>1)*((h>>1)-1);
- ppIn[2] += (pitchIn>>1)*((h>>1)-1);
- pitchIn = -pitchIn;
- }
-
- if (subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV || subtype == MEDIASUBTYPE_YV12) {
- BYTE* pIn = ppIn[0];
- BYTE* pInU = ppIn[1];
- BYTE* pInV = ppIn[2];
-
- if (subtype == MEDIASUBTYPE_YV12) {
- BYTE* tmp = pInU;
- pInU = pInV;
- pInV = tmp;
- }
-
- BYTE* pOutU = pOut + bihOut.biWidth*h;
- BYTE* pOutV = pOut + bihOut.biWidth*h*5/4;
-
- if (bihOut.biCompression == '21VY') {
- BYTE* tmp = pOutU;
- pOutU = pOutV;
- pOutV = tmp;
- }
-
- ASSERT(w <= abs(pitchIn));
-
- if (bihOut.biCompression == '2YUY') {
- if (!fInterlaced) {
- BitBltFromI420ToYUY2(w, h, pOut, bihOut.biWidth*2, pIn, pInU, pInV, pitchIn);
- } else {
- BitBltFromI420ToYUY2Interlaced(w, h, pOut, bihOut.biWidth*2, pIn, pInU, pInV, pitchIn);
- }
- } else if (bihOut.biCompression == '024I' || bihOut.biCompression == 'VUYI' || bihOut.biCompression == '21VY') {
- BitBltFromI420ToI420(w, h, pOut, pOutU, pOutV, bihOut.biWidth, pIn, pInU, pInV, pitchIn);
- } else if (bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
- if (!BitBltFromI420ToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, pIn, pInU, pInV, pitchIn)) {
- for (int y = 0; y < h; y++, pOut += pitchOut) {
- memset(pOut, 0, pitchOut);
- }
- }
- }
- } else if (subtype == MEDIASUBTYPE_YUY2) {
- if (bihOut.biCompression == '2YUY') {
- BitBltFromYUY2ToYUY2(w, h, pOut, bihOut.biWidth*2, ppIn[0], pitchIn);
- } else if (bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
- if (!BitBltFromYUY2ToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, ppIn[0], pitchIn)) {
- for (int y = 0; y < h; y++, pOut += pitchOut) {
- memset(pOut, 0, pitchOut);
- }
- }
- }
- } else if (subtype == MEDIASUBTYPE_ARGB32 || subtype == MEDIASUBTYPE_RGB32 || subtype == MEDIASUBTYPE_RGB24 || subtype == MEDIASUBTYPE_RGB565) {
- int sbpp =
- subtype == MEDIASUBTYPE_ARGB32 || subtype == MEDIASUBTYPE_RGB32 ? 32 :
- subtype == MEDIASUBTYPE_RGB24 ? 24 :
- subtype == MEDIASUBTYPE_RGB565 ? 16 : 0;
-
- if (bihOut.biCompression == '2YUY') {
- // TODO
- // BitBltFromRGBToYUY2();
- } else if (bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
- if (!BitBltFromRGBToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, ppIn[0], pitchIn, sbpp)) {
- for (int y = 0; y < h; y++, pOut += pitchOut) {
- memset(pOut, 0, pitchOut);
- }
- }
- }
- } else {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- return S_OK;
+ BITMAPINFOHEADER bihOut;
+ ExtractBIH(&m_pOutput->CurrentMediaType(), &bihOut);
+
+ int pitchOut = 0;
+
+ if (bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
+ pitchOut = bihOut.biWidth * bihOut.biBitCount >> 3;
+
+ if (bihOut.biHeight > 0) {
+ pOut += pitchOut * (h - 1);
+ pitchOut = -pitchOut;
+ if (h < 0) {
+ h = -h;
+ }
+ }
+ }
+
+ if (h < 0) {
+ h = -h;
+ ppIn[0] += pitchIn * (h - 1);
+ ppIn[1] += (pitchIn >> 1) * ((h >> 1) - 1);
+ ppIn[2] += (pitchIn >> 1) * ((h >> 1) - 1);
+ pitchIn = -pitchIn;
+ }
+
+ if (subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV || subtype == MEDIASUBTYPE_YV12) {
+ BYTE* pIn = ppIn[0];
+ BYTE* pInU = ppIn[1];
+ BYTE* pInV = ppIn[2];
+
+ if (subtype == MEDIASUBTYPE_YV12) {
+ BYTE* tmp = pInU;
+ pInU = pInV;
+ pInV = tmp;
+ }
+
+ BYTE* pOutU = pOut + bihOut.biWidth * h;
+ BYTE* pOutV = pOut + bihOut.biWidth * h * 5 / 4;
+
+ if (bihOut.biCompression == '21VY') {
+ BYTE* tmp = pOutU;
+ pOutU = pOutV;
+ pOutV = tmp;
+ }
+
+ ASSERT(w <= abs(pitchIn));
+
+ if (bihOut.biCompression == '2YUY') {
+ if (!fInterlaced) {
+ BitBltFromI420ToYUY2(w, h, pOut, bihOut.biWidth * 2, pIn, pInU, pInV, pitchIn);
+ } else {
+ BitBltFromI420ToYUY2Interlaced(w, h, pOut, bihOut.biWidth * 2, pIn, pInU, pInV, pitchIn);
+ }
+ } else if (bihOut.biCompression == '024I' || bihOut.biCompression == 'VUYI' || bihOut.biCompression == '21VY') {
+ BitBltFromI420ToI420(w, h, pOut, pOutU, pOutV, bihOut.biWidth, pIn, pInU, pInV, pitchIn);
+ } else if (bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
+ if (!BitBltFromI420ToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, pIn, pInU, pInV, pitchIn)) {
+ for (int y = 0; y < h; y++, pOut += pitchOut) {
+ memset(pOut, 0, pitchOut);
+ }
+ }
+ }
+ } else if (subtype == MEDIASUBTYPE_YUY2) {
+ if (bihOut.biCompression == '2YUY') {
+ BitBltFromYUY2ToYUY2(w, h, pOut, bihOut.biWidth * 2, ppIn[0], pitchIn);
+ } else if (bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
+ if (!BitBltFromYUY2ToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, ppIn[0], pitchIn)) {
+ for (int y = 0; y < h; y++, pOut += pitchOut) {
+ memset(pOut, 0, pitchOut);
+ }
+ }
+ }
+ } else if (subtype == MEDIASUBTYPE_ARGB32 || subtype == MEDIASUBTYPE_RGB32 || subtype == MEDIASUBTYPE_RGB24 || subtype == MEDIASUBTYPE_RGB565) {
+ int sbpp =
+ subtype == MEDIASUBTYPE_ARGB32 || subtype == MEDIASUBTYPE_RGB32 ? 32 :
+ subtype == MEDIASUBTYPE_RGB24 ? 24 :
+ subtype == MEDIASUBTYPE_RGB565 ? 16 : 0;
+
+ if (bihOut.biCompression == '2YUY') {
+ // TODO
+ // BitBltFromRGBToYUY2();
+ } else if (bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
+ if (!BitBltFromRGBToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, ppIn[0], pitchIn, sbpp)) {
+ for (int y = 0; y < h; y++, pOut += pitchOut) {
+ memset(pOut, 0, pitchOut);
+ }
+ }
+ }
+ } else {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+
+ return S_OK;
}
HRESULT CBaseVideoFilter::CheckInputType(const CMediaType* mtIn)
{
- BITMAPINFOHEADER bih;
- ExtractBIH(mtIn, &bih);
-
- return mtIn->majortype == MEDIATYPE_Video
- && (mtIn->subtype == MEDIASUBTYPE_YV12
- || mtIn->subtype == MEDIASUBTYPE_I420
- || mtIn->subtype == MEDIASUBTYPE_IYUV
- || mtIn->subtype == MEDIASUBTYPE_YUY2
- || mtIn->subtype == MEDIASUBTYPE_ARGB32
- || mtIn->subtype == MEDIASUBTYPE_RGB32
- || mtIn->subtype == MEDIASUBTYPE_RGB24
- || mtIn->subtype == MEDIASUBTYPE_RGB565)
- && (mtIn->formattype == FORMAT_VideoInfo
- || mtIn->formattype == FORMAT_VideoInfo2)
- && bih.biHeight > 0
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ BITMAPINFOHEADER bih;
+ ExtractBIH(mtIn, &bih);
+
+ return mtIn->majortype == MEDIATYPE_Video
+ && (mtIn->subtype == MEDIASUBTYPE_YV12
+ || mtIn->subtype == MEDIASUBTYPE_I420
+ || mtIn->subtype == MEDIASUBTYPE_IYUV
+ || mtIn->subtype == MEDIASUBTYPE_YUY2
+ || mtIn->subtype == MEDIASUBTYPE_ARGB32
+ || mtIn->subtype == MEDIASUBTYPE_RGB32
+ || mtIn->subtype == MEDIASUBTYPE_RGB24
+ || mtIn->subtype == MEDIASUBTYPE_RGB565)
+ && (mtIn->formattype == FORMAT_VideoInfo
+ || mtIn->formattype == FORMAT_VideoInfo2)
+ && bih.biHeight > 0
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CBaseVideoFilter::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
{
- if (FAILED(CheckInputType(mtIn)) || mtOut->majortype != MEDIATYPE_Video) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- if (mtIn->majortype == MEDIATYPE_Video
- && (mtIn->subtype == MEDIASUBTYPE_YV12
- || mtIn->subtype == MEDIASUBTYPE_I420
- || mtIn->subtype == MEDIASUBTYPE_IYUV)) {
- if (mtOut->subtype != MEDIASUBTYPE_YV12
- && mtOut->subtype != MEDIASUBTYPE_I420
- && mtOut->subtype != MEDIASUBTYPE_IYUV
- && mtOut->subtype != MEDIASUBTYPE_YUY2
- && mtOut->subtype != MEDIASUBTYPE_ARGB32
- && mtOut->subtype != MEDIASUBTYPE_RGB32
- && mtOut->subtype != MEDIASUBTYPE_RGB24
- && mtOut->subtype != MEDIASUBTYPE_RGB565) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- } else if (mtIn->majortype == MEDIATYPE_Video
- && (mtIn->subtype == MEDIASUBTYPE_YUY2)) {
- if (mtOut->subtype != MEDIASUBTYPE_YUY2
- && mtOut->subtype != MEDIASUBTYPE_ARGB32
- && mtOut->subtype != MEDIASUBTYPE_RGB32
- && mtOut->subtype != MEDIASUBTYPE_RGB24
- && mtOut->subtype != MEDIASUBTYPE_RGB565) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- } else if (mtIn->majortype == MEDIATYPE_Video
- && (mtIn->subtype == MEDIASUBTYPE_ARGB32
- || mtIn->subtype == MEDIASUBTYPE_RGB32
- || mtIn->subtype == MEDIASUBTYPE_RGB24
- || mtIn->subtype == MEDIASUBTYPE_RGB565)) {
- if (mtOut->subtype != MEDIASUBTYPE_ARGB32
- && mtOut->subtype != MEDIASUBTYPE_RGB32
- && mtOut->subtype != MEDIASUBTYPE_RGB24
- && mtOut->subtype != MEDIASUBTYPE_RGB565) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- }
-
- return S_OK;
+ if (FAILED(CheckInputType(mtIn)) || mtOut->majortype != MEDIATYPE_Video) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+
+ if (mtIn->majortype == MEDIATYPE_Video
+ && (mtIn->subtype == MEDIASUBTYPE_YV12
+ || mtIn->subtype == MEDIASUBTYPE_I420
+ || mtIn->subtype == MEDIASUBTYPE_IYUV)) {
+ if (mtOut->subtype != MEDIASUBTYPE_YV12
+ && mtOut->subtype != MEDIASUBTYPE_I420
+ && mtOut->subtype != MEDIASUBTYPE_IYUV
+ && mtOut->subtype != MEDIASUBTYPE_YUY2
+ && mtOut->subtype != MEDIASUBTYPE_ARGB32
+ && mtOut->subtype != MEDIASUBTYPE_RGB32
+ && mtOut->subtype != MEDIASUBTYPE_RGB24
+ && mtOut->subtype != MEDIASUBTYPE_RGB565) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+ } else if (mtIn->majortype == MEDIATYPE_Video
+ && (mtIn->subtype == MEDIASUBTYPE_YUY2)) {
+ if (mtOut->subtype != MEDIASUBTYPE_YUY2
+ && mtOut->subtype != MEDIASUBTYPE_ARGB32
+ && mtOut->subtype != MEDIASUBTYPE_RGB32
+ && mtOut->subtype != MEDIASUBTYPE_RGB24
+ && mtOut->subtype != MEDIASUBTYPE_RGB565) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+ } else if (mtIn->majortype == MEDIATYPE_Video
+ && (mtIn->subtype == MEDIASUBTYPE_ARGB32
+ || mtIn->subtype == MEDIASUBTYPE_RGB32
+ || mtIn->subtype == MEDIASUBTYPE_RGB24
+ || mtIn->subtype == MEDIASUBTYPE_RGB565)) {
+ if (mtOut->subtype != MEDIASUBTYPE_ARGB32
+ && mtOut->subtype != MEDIASUBTYPE_RGB32
+ && mtOut->subtype != MEDIASUBTYPE_RGB24
+ && mtOut->subtype != MEDIASUBTYPE_RGB565) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+ }
+
+ return S_OK;
}
HRESULT CBaseVideoFilter::CheckOutputType(const CMediaType& mtOut)
{
- int wout = 0, hout = 0, arxout = 0, aryout = 0;
- return ExtractDim(&mtOut, wout, hout, arxout, aryout)
- && m_h == abs((int)hout)
- && mtOut.subtype != MEDIASUBTYPE_ARGB32
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ int wout = 0, hout = 0, arxout = 0, aryout = 0;
+ return ExtractDim(&mtOut, wout, hout, arxout, aryout)
+ && m_h == abs((int)hout)
+ && mtOut.subtype != MEDIASUBTYPE_ARGB32
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CBaseVideoFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if (m_pInput->IsConnected() == FALSE) {
- return E_UNEXPECTED;
- }
-
- BITMAPINFOHEADER bih;
- ExtractBIH(&m_pOutput->CurrentMediaType(), &bih);
-
- long cBuffers = m_pOutput->CurrentMediaType().formattype == FORMAT_VideoInfo ? 1 : m_cBuffers;
- UNREFERENCED_PARAMETER(cBuffers);
-
- pProperties->cBuffers = m_cBuffers;
- pProperties->cbBuffer = bih.biSizeImage;
- pProperties->cbAlign = 1;
- pProperties->cbPrefix = 0;
-
- HRESULT hr;
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
- return hr;
- }
-
- return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
- ? E_FAIL
- : NOERROR;
+ if (m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
+
+ BITMAPINFOHEADER bih;
+ ExtractBIH(&m_pOutput->CurrentMediaType(), &bih);
+
+ long cBuffers = m_pOutput->CurrentMediaType().formattype == FORMAT_VideoInfo ? 1 : m_cBuffers;
+ UNREFERENCED_PARAMETER(cBuffers);
+
+ pProperties->cBuffers = m_cBuffers;
+ pProperties->cbBuffer = bih.biSizeImage;
+ pProperties->cbAlign = 1;
+ pProperties->cbPrefix = 0;
+
+ HRESULT hr;
+ ALLOCATOR_PROPERTIES Actual;
+ if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
+
+ return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
+ ? E_FAIL
+ : NOERROR;
}
VIDEO_OUTPUT_FORMATS DefaultFormats[] = {
- {&MEDIASUBTYPE_YV12, 3, 12, '21VY'},
- {&MEDIASUBTYPE_I420, 3, 12, '024I'},
- {&MEDIASUBTYPE_IYUV, 3, 12, 'VUYI'},
- {&MEDIASUBTYPE_YUY2, 1, 16, '2YUY'},
- {&MEDIASUBTYPE_ARGB32, 1, 32, BI_RGB},
- {&MEDIASUBTYPE_RGB32, 1, 32, BI_RGB},
- {&MEDIASUBTYPE_RGB24, 1, 24, BI_RGB},
- {&MEDIASUBTYPE_RGB565, 1, 16, BI_RGB},
- {&MEDIASUBTYPE_RGB555, 1, 16, BI_RGB},
- {&MEDIASUBTYPE_ARGB32, 1, 32, BI_BITFIELDS},
- {&MEDIASUBTYPE_RGB32, 1, 32, BI_BITFIELDS},
- {&MEDIASUBTYPE_RGB24, 1, 24, BI_BITFIELDS},
- {&MEDIASUBTYPE_RGB565, 1, 16, BI_BITFIELDS},
- {&MEDIASUBTYPE_RGB555, 1, 16, BI_BITFIELDS},
+ {&MEDIASUBTYPE_YV12, 3, 12, '21VY'},
+ {&MEDIASUBTYPE_I420, 3, 12, '024I'},
+ {&MEDIASUBTYPE_IYUV, 3, 12, 'VUYI'},
+ {&MEDIASUBTYPE_YUY2, 1, 16, '2YUY'},
+ {&MEDIASUBTYPE_ARGB32, 1, 32, BI_RGB},
+ {&MEDIASUBTYPE_RGB32, 1, 32, BI_RGB},
+ {&MEDIASUBTYPE_RGB24, 1, 24, BI_RGB},
+ {&MEDIASUBTYPE_RGB565, 1, 16, BI_RGB},
+ {&MEDIASUBTYPE_RGB555, 1, 16, BI_RGB},
+ {&MEDIASUBTYPE_ARGB32, 1, 32, BI_BITFIELDS},
+ {&MEDIASUBTYPE_RGB32, 1, 32, BI_BITFIELDS},
+ {&MEDIASUBTYPE_RGB24, 1, 24, BI_BITFIELDS},
+ {&MEDIASUBTYPE_RGB565, 1, 16, BI_BITFIELDS},
+ {&MEDIASUBTYPE_RGB555, 1, 16, BI_BITFIELDS},
};
-void CBaseVideoFilter::GetOutputFormats (int& nNumber, VIDEO_OUTPUT_FORMATS** ppFormats)
+void CBaseVideoFilter::GetOutputFormats(int& nNumber, VIDEO_OUTPUT_FORMATS** ppFormats)
{
- nNumber = _countof(DefaultFormats);
- *ppFormats = DefaultFormats;
+ nNumber = _countof(DefaultFormats);
+ *ppFormats = DefaultFormats;
}
HRESULT CBaseVideoFilter::GetMediaType(int iPosition, CMediaType* pmt)
{
- VIDEO_OUTPUT_FORMATS* fmts;
- int nFormatCount;
-
- if (m_pInput->IsConnected() == FALSE) {
- return E_UNEXPECTED;
- }
-
-
- // this will make sure we won't connect to the old renderer in dvd mode
- // that renderer can't switch the format dynamically
-
- bool fFoundDVDNavigator = false;
- CComPtr<IBaseFilter> pBF = this;
- CComPtr<IPin> pPin = m_pInput;
- for (; !fFoundDVDNavigator && (pBF = GetUpStreamFilter(pBF, pPin)); pPin = GetFirstPin(pBF)) {
- fFoundDVDNavigator = !!(GetCLSID(pBF) == CLSID_DVDNavigator);
- }
-
- if (fFoundDVDNavigator || m_pInput->CurrentMediaType().formattype == FORMAT_VideoInfo2) {
- iPosition = iPosition*2;
- }
-
- //
- GetOutputFormats (nFormatCount, &fmts);
- if (iPosition < 0) {
- return E_INVALIDARG;
- }
- if (iPosition >= 2*nFormatCount) {
- return VFW_S_NO_MORE_ITEMS;
- }
-
- pmt->majortype = MEDIATYPE_Video;
- pmt->subtype = *fmts[iPosition/2].subtype;
-
- int w = m_win, h = m_hin, arx = m_arxin, ary = m_aryin;
- int RealWidth = -1;
- int RealHeight = -1;
- int vsfilter = 0;
- GetOutputSize(w, h, arx, ary, RealWidth, RealHeight, vsfilter);
-
- BITMAPINFOHEADER bihOut;
- memset(&bihOut, 0, sizeof(bihOut));
- bihOut.biSize = sizeof(bihOut);
- bihOut.biWidth = w;
- bihOut.biHeight = h;
- bihOut.biPlanes = fmts[iPosition/2].biPlanes;
- bihOut.biBitCount = fmts[iPosition/2].biBitCount;
- bihOut.biCompression = fmts[iPosition/2].biCompression;
- bihOut.biSizeImage = w*h*bihOut.biBitCount>>3;
-
- if (iPosition&1) {
- pmt->formattype = FORMAT_VideoInfo;
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
- memset(vih, 0, sizeof(VIDEOINFOHEADER));
- vih->bmiHeader = bihOut;
- vih->bmiHeader.biXPelsPerMeter = vih->bmiHeader.biWidth * ary;
- vih->bmiHeader.biYPelsPerMeter = vih->bmiHeader.biHeight * arx;
- } else {
- pmt->formattype = FORMAT_VideoInfo2;
- VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER2));
- memset(vih, 0, sizeof(VIDEOINFOHEADER2));
- vih->bmiHeader = bihOut;
- vih->dwPictAspectRatioX = arx;
- vih->dwPictAspectRatioY = ary;
- if (IsVideoInterlaced()) {
- vih->dwInterlaceFlags = AMINTERLACE_IsInterlaced | AMINTERLACE_DisplayModeBobOrWeave;
- }
- }
-
- CMediaType& mt = m_pInput->CurrentMediaType();
-
- // these fields have the same field offset in all four structs
- ((VIDEOINFOHEADER*)pmt->Format())->AvgTimePerFrame = ((VIDEOINFOHEADER*)mt.Format())->AvgTimePerFrame;
- ((VIDEOINFOHEADER*)pmt->Format())->dwBitRate = ((VIDEOINFOHEADER*)mt.Format())->dwBitRate;
- ((VIDEOINFOHEADER*)pmt->Format())->dwBitErrorRate = ((VIDEOINFOHEADER*)mt.Format())->dwBitErrorRate;
-
- CorrectMediaType(pmt);
-
- if (!vsfilter) {
- // copy source and target rectangles from input pin
- CMediaType& pmtInput = m_pInput->CurrentMediaType();
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->Format();
- VIDEOINFOHEADER* vihInput = (VIDEOINFOHEADER*)pmtInput.Format();
-
- ASSERT(vih);
- if (vihInput && (vihInput->rcSource.right != 0) && (vihInput->rcSource.bottom != 0)) {
- vih->rcSource = vihInput->rcSource;
- vih->rcTarget = vihInput->rcTarget;
- } else {
- vih->rcSource.right = vih->rcTarget.right = m_win;
- vih->rcSource.bottom = vih->rcTarget.bottom = m_hin;
- }
-
- if (RealWidth > 0 && vih->rcSource.right > RealWidth) {
- vih->rcSource.right = RealWidth;
- }
- if (RealHeight > 0 && vih->rcSource.bottom > RealHeight) {
- vih->rcSource.bottom = RealHeight;
- }
- }
-
- return S_OK;
+ VIDEO_OUTPUT_FORMATS* fmts;
+ int nFormatCount;
+
+ if (m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
+
+
+ // this will make sure we won't connect to the old renderer in dvd mode
+ // that renderer can't switch the format dynamically
+
+ bool fFoundDVDNavigator = false;
+ CComPtr<IBaseFilter> pBF = this;
+ CComPtr<IPin> pPin = m_pInput;
+ for (; !fFoundDVDNavigator && (pBF = GetUpStreamFilter(pBF, pPin)); pPin = GetFirstPin(pBF)) {
+ fFoundDVDNavigator = !!(GetCLSID(pBF) == CLSID_DVDNavigator);
+ }
+
+ if (fFoundDVDNavigator || m_pInput->CurrentMediaType().formattype == FORMAT_VideoInfo2) {
+ iPosition = iPosition * 2;
+ }
+
+ //
+ GetOutputFormats(nFormatCount, &fmts);
+ if (iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if (iPosition >= 2 * nFormatCount) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
+
+ pmt->majortype = MEDIATYPE_Video;
+ pmt->subtype = *fmts[iPosition / 2].subtype;
+
+ int w = m_win, h = m_hin, arx = m_arxin, ary = m_aryin;
+ int RealWidth = -1;
+ int RealHeight = -1;
+ int vsfilter = 0;
+ GetOutputSize(w, h, arx, ary, RealWidth, RealHeight, vsfilter);
+
+ BITMAPINFOHEADER bihOut;
+ memset(&bihOut, 0, sizeof(bihOut));
+ bihOut.biSize = sizeof(bihOut);
+ bihOut.biWidth = w;
+ bihOut.biHeight = h;
+ bihOut.biPlanes = fmts[iPosition / 2].biPlanes;
+ bihOut.biBitCount = fmts[iPosition / 2].biBitCount;
+ bihOut.biCompression = fmts[iPosition / 2].biCompression;
+ bihOut.biSizeImage = w * h * bihOut.biBitCount >> 3;
+
+ if (iPosition & 1) {
+ pmt->formattype = FORMAT_VideoInfo;
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
+ memset(vih, 0, sizeof(VIDEOINFOHEADER));
+ vih->bmiHeader = bihOut;
+ vih->bmiHeader.biXPelsPerMeter = vih->bmiHeader.biWidth * ary;
+ vih->bmiHeader.biYPelsPerMeter = vih->bmiHeader.biHeight * arx;
+ } else {
+ pmt->formattype = FORMAT_VideoInfo2;
+ VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER2));
+ memset(vih, 0, sizeof(VIDEOINFOHEADER2));
+ vih->bmiHeader = bihOut;
+ vih->dwPictAspectRatioX = arx;
+ vih->dwPictAspectRatioY = ary;
+ if (IsVideoInterlaced()) {
+ vih->dwInterlaceFlags = AMINTERLACE_IsInterlaced | AMINTERLACE_DisplayModeBobOrWeave;
+ }
+ }
+
+ CMediaType& mt = m_pInput->CurrentMediaType();
+
+ // these fields have the same field offset in all four structs
+ ((VIDEOINFOHEADER*)pmt->Format())->AvgTimePerFrame = ((VIDEOINFOHEADER*)mt.Format())->AvgTimePerFrame;
+ ((VIDEOINFOHEADER*)pmt->Format())->dwBitRate = ((VIDEOINFOHEADER*)mt.Format())->dwBitRate;
+ ((VIDEOINFOHEADER*)pmt->Format())->dwBitErrorRate = ((VIDEOINFOHEADER*)mt.Format())->dwBitErrorRate;
+
+ CorrectMediaType(pmt);
+
+ if (!vsfilter) {
+ // copy source and target rectangles from input pin
+ CMediaType& pmtInput = m_pInput->CurrentMediaType();
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->Format();
+ VIDEOINFOHEADER* vihInput = (VIDEOINFOHEADER*)pmtInput.Format();
+
+ ASSERT(vih);
+ if (vihInput && (vihInput->rcSource.right != 0) && (vihInput->rcSource.bottom != 0)) {
+ vih->rcSource = vihInput->rcSource;
+ vih->rcTarget = vihInput->rcTarget;
+ } else {
+ vih->rcSource.right = vih->rcTarget.right = m_win;
+ vih->rcSource.bottom = vih->rcTarget.bottom = m_hin;
+ }
+
+ if (RealWidth > 0 && vih->rcSource.right > RealWidth) {
+ vih->rcSource.right = RealWidth;
+ }
+ if (RealHeight > 0 && vih->rcSource.bottom > RealHeight) {
+ vih->rcSource.bottom = RealHeight;
+ }
+ }
+
+ return S_OK;
}
HRESULT CBaseVideoFilter::SetMediaType(PIN_DIRECTION dir, const CMediaType* pmt)
{
- if (dir == PINDIR_INPUT) {
- m_w = m_h = m_arx = m_ary = 0;
- ExtractDim(pmt, m_w, m_h, m_arx, m_ary);
- m_win = m_w;
- m_hin = m_h;
- m_arxin = m_arx;
- m_aryin = m_ary;
- int RealWidth = -1;
- int RealHeight = -1;
- int vsfilter = 0;
- GetOutputSize(m_w, m_h, m_arx, m_ary, RealWidth, RealHeight, vsfilter);
-
- DWORD a = m_arx, b = m_ary;
- while (a) {
- int tmp = a;
- a = b % tmp;
- b = tmp;
- }
- if (b) {
- m_arx /= b, m_ary /= b;
- }
- } else if (dir == PINDIR_OUTPUT) {
- int wout = 0, hout = 0, arxout = 0, aryout = 0;
- ExtractDim(pmt, wout, hout, arxout, aryout);
- if (m_w == wout && m_h == hout && m_arx == arxout && m_ary == aryout) {
- m_wout = wout;
- m_hout = hout;
- m_arxout = arxout;
- m_aryout = aryout;
- }
- }
-
- return __super::SetMediaType(dir, pmt);
+ if (dir == PINDIR_INPUT) {
+ m_w = m_h = m_arx = m_ary = 0;
+ ExtractDim(pmt, m_w, m_h, m_arx, m_ary);
+ m_win = m_w;
+ m_hin = m_h;
+ m_arxin = m_arx;
+ m_aryin = m_ary;
+ int RealWidth = -1;
+ int RealHeight = -1;
+ int vsfilter = 0;
+ GetOutputSize(m_w, m_h, m_arx, m_ary, RealWidth, RealHeight, vsfilter);
+
+ DWORD a = m_arx, b = m_ary;
+ while (a) {
+ int tmp = a;
+ a = b % tmp;
+ b = tmp;
+ }
+ if (b) {
+ m_arx /= b, m_ary /= b;
+ }
+ } else if (dir == PINDIR_OUTPUT) {
+ int wout = 0, hout = 0, arxout = 0, aryout = 0;
+ ExtractDim(pmt, wout, hout, arxout, aryout);
+ if (m_w == wout && m_h == hout && m_arx == arxout && m_ary == aryout) {
+ m_wout = wout;
+ m_hout = hout;
+ m_arxout = arxout;
+ m_aryout = aryout;
+ }
+ }
+
+ return __super::SetMediaType(dir, pmt);
}
//
@@ -642,32 +642,32 @@ HRESULT CBaseVideoFilter::SetMediaType(PIN_DIRECTION dir, const CMediaType* pmt)
//
CBaseVideoInputAllocator::CBaseVideoInputAllocator(HRESULT* phr)
- : CMemAllocator(NAME("CBaseVideoInputAllocator"), NULL, phr)
+ : CMemAllocator(NAME("CBaseVideoInputAllocator"), NULL, phr)
{
- if (phr) {
- *phr = S_OK;
- }
+ if (phr) {
+ *phr = S_OK;
+ }
}
void CBaseVideoInputAllocator::SetMediaType(const CMediaType& mt)
{
- m_mt = mt;
+ m_mt = mt;
}
STDMETHODIMP CBaseVideoInputAllocator::GetBuffer(IMediaSample** ppBuffer, REFERENCE_TIME* pStartTime, REFERENCE_TIME* pEndTime, DWORD dwFlags)
{
- if (!m_bCommitted) {
- return VFW_E_NOT_COMMITTED;
- }
+ if (!m_bCommitted) {
+ return VFW_E_NOT_COMMITTED;
+ }
- HRESULT hr = __super::GetBuffer(ppBuffer, pStartTime, pEndTime, dwFlags);
+ HRESULT hr = __super::GetBuffer(ppBuffer, pStartTime, pEndTime, dwFlags);
- if (SUCCEEDED(hr) && m_mt.majortype != GUID_NULL) {
- (*ppBuffer)->SetMediaType(&m_mt);
- m_mt.majortype = GUID_NULL;
- }
+ if (SUCCEEDED(hr) && m_mt.majortype != GUID_NULL) {
+ (*ppBuffer)->SetMediaType(&m_mt);
+ m_mt.majortype = GUID_NULL;
+ }
- return hr;
+ return hr;
}
//
@@ -675,72 +675,72 @@ STDMETHODIMP CBaseVideoInputAllocator::GetBuffer(IMediaSample** ppBuffer, REFERE
//
CBaseVideoInputPin::CBaseVideoInputPin(TCHAR* pObjectName, CBaseVideoFilter* pFilter, HRESULT* phr, LPCWSTR pName)
- : CTransformInputPin(pObjectName, pFilter, phr, pName)
- , m_pAllocator(NULL)
+ : CTransformInputPin(pObjectName, pFilter, phr, pName)
+ , m_pAllocator(NULL)
{
}
CBaseVideoInputPin::~CBaseVideoInputPin()
{
- delete m_pAllocator;
+ delete m_pAllocator;
}
STDMETHODIMP CBaseVideoInputPin::GetAllocator(IMemAllocator** ppAllocator)
{
- CheckPointer(ppAllocator, E_POINTER);
+ CheckPointer(ppAllocator, E_POINTER);
- if (m_pAllocator == NULL) {
- HRESULT hr = S_OK;
- m_pAllocator = DNew CBaseVideoInputAllocator(&hr);
- m_pAllocator->AddRef();
- }
+ if (m_pAllocator == NULL) {
+ HRESULT hr = S_OK;
+ m_pAllocator = DNew CBaseVideoInputAllocator(&hr);
+ m_pAllocator->AddRef();
+ }
- (*ppAllocator = m_pAllocator)->AddRef();
+ (*ppAllocator = m_pAllocator)->AddRef();
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CBaseVideoInputPin::ReceiveConnection(IPin* pConnector, const AM_MEDIA_TYPE* pmt)
{
- CAutoLock cObjectLock(m_pLock);
+ CAutoLock cObjectLock(m_pLock);
- if (m_Connected) {
- CMediaType mt(*pmt);
+ if (m_Connected) {
+ CMediaType mt(*pmt);
- if (FAILED(CheckMediaType(&mt))) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
+ if (FAILED(CheckMediaType(&mt))) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
- ALLOCATOR_PROPERTIES props, actual;
+ ALLOCATOR_PROPERTIES props, actual;
- CComPtr<IMemAllocator> pMemAllocator;
- if (FAILED(GetAllocator(&pMemAllocator))
- || FAILED(pMemAllocator->Decommit())
- || FAILED(pMemAllocator->GetProperties(&props))) {
- return E_FAIL;
- }
+ CComPtr<IMemAllocator> pMemAllocator;
+ if (FAILED(GetAllocator(&pMemAllocator))
+ || FAILED(pMemAllocator->Decommit())
+ || FAILED(pMemAllocator->GetProperties(&props))) {
+ return E_FAIL;
+ }
- BITMAPINFOHEADER bih;
- if (ExtractBIH(pmt, &bih) && bih.biSizeImage) {
- props.cbBuffer = bih.biSizeImage;
- }
+ BITMAPINFOHEADER bih;
+ if (ExtractBIH(pmt, &bih) && bih.biSizeImage) {
+ props.cbBuffer = bih.biSizeImage;
+ }
- if (FAILED(pMemAllocator->SetProperties(&props, &actual))
- || FAILED(pMemAllocator->Commit())
- || props.cbBuffer != actual.cbBuffer) {
- return E_FAIL;
- }
+ if (FAILED(pMemAllocator->SetProperties(&props, &actual))
+ || FAILED(pMemAllocator->Commit())
+ || props.cbBuffer != actual.cbBuffer) {
+ return E_FAIL;
+ }
- if (m_pAllocator) {
- m_pAllocator->SetMediaType(mt);
- }
+ if (m_pAllocator) {
+ m_pAllocator->SetMediaType(mt);
+ }
- return SetMediaType(&mt) == S_OK
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
- }
+ return SetMediaType(&mt) == S_OK
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
+ }
- return __super::ReceiveConnection(pConnector, pmt);
+ return __super::ReceiveConnection(pConnector, pmt);
}
//
@@ -748,18 +748,18 @@ STDMETHODIMP CBaseVideoInputPin::ReceiveConnection(IPin* pConnector, const AM_ME
//
CBaseVideoOutputPin::CBaseVideoOutputPin(TCHAR* pObjectName, CBaseVideoFilter* pFilter, HRESULT* phr, LPCWSTR pName)
- : CTransformOutputPin(pObjectName, pFilter, phr, pName)
+ : CTransformOutputPin(pObjectName, pFilter, phr, pName)
{
}
HRESULT CBaseVideoOutputPin::CheckMediaType(const CMediaType* mtOut)
{
- if (IsConnected()) {
- HRESULT hr = (static_cast<CBaseVideoFilter*>(m_pFilter))->CheckOutputType(*mtOut);
- if (FAILED(hr)) {
- return hr;
- }
- }
-
- return __super::CheckMediaType(mtOut);
+ if (IsConnected()) {
+ HRESULT hr = (static_cast<CBaseVideoFilter*>(m_pFilter))->CheckOutputType(*mtOut);
+ if (FAILED(hr)) {
+ return hr;
+ }
+ }
+
+ return __super::CheckMediaType(mtOut);
}
diff --git a/src/filters/transform/BaseVideoFilter/BaseVideoFilter.h b/src/filters/transform/BaseVideoFilter/BaseVideoFilter.h
index 9613bbac7..079ee8e8a 100644
--- a/src/filters/transform/BaseVideoFilter/BaseVideoFilter.h
+++ b/src/filters/transform/BaseVideoFilter/BaseVideoFilter.h
@@ -25,81 +25,81 @@
typedef struct {
- const GUID* subtype;
- WORD biPlanes;
- WORD biBitCount;
- DWORD biCompression;
+ const GUID* subtype;
+ WORD biPlanes;
+ WORD biBitCount;
+ DWORD biCompression;
} VIDEO_OUTPUT_FORMATS;
class CBaseVideoFilter : public CTransformFilter
{
private:
- HRESULT Receive(IMediaSample* pIn);
+ HRESULT Receive(IMediaSample* pIn);
- // these are private for a reason, don't bother them
- int m_win, m_hin, m_arxin, m_aryin;
- int m_wout, m_hout, m_arxout, m_aryout;
+ // these are private for a reason, don't bother them
+ int m_win, m_hin, m_arxin, m_aryin;
+ int m_wout, m_hout, m_arxout, m_aryout;
- long m_cBuffers;
+ long m_cBuffers;
protected:
- CCritSec m_csReceive;
+ CCritSec m_csReceive;
- int m_w, m_h, m_arx, m_ary;
+ int m_w, m_h, m_arx, m_ary;
- HRESULT GetDeliveryBuffer(int w, int h, IMediaSample** ppOut);
- HRESULT CopyBuffer(BYTE* pOut, BYTE* pIn, int w, int h, int pitchIn, const GUID& subtype, bool fInterlaced = false);
- HRESULT CopyBuffer(BYTE* pOut, BYTE** ppIn, int w, int h, int pitchIn, const GUID& subtype, bool fInterlaced = false);
+ HRESULT GetDeliveryBuffer(int w, int h, IMediaSample** ppOut);
+ HRESULT CopyBuffer(BYTE* pOut, BYTE* pIn, int w, int h, int pitchIn, const GUID& subtype, bool fInterlaced = false);
+ HRESULT CopyBuffer(BYTE* pOut, BYTE** ppIn, int w, int h, int pitchIn, const GUID& subtype, bool fInterlaced = false);
- virtual void GetOutputSize(int& w, int& h, int& arx, int& ary, int &RealWidth, int &RealHeight, int& vsfilter) {}
- virtual HRESULT Transform(IMediaSample* pIn) = 0;
- virtual bool IsVideoInterlaced() {return false;}
- virtual void GetOutputFormats (int& nNumber, VIDEO_OUTPUT_FORMATS** ppFormats);
+ virtual void GetOutputSize(int& w, int& h, int& arx, int& ary, int& RealWidth, int& RealHeight, int& vsfilter) {}
+ virtual HRESULT Transform(IMediaSample* pIn) = 0;
+ virtual bool IsVideoInterlaced() {return false;}
+ virtual void GetOutputFormats(int& nNumber, VIDEO_OUTPUT_FORMATS** ppFormats);
public:
- CBaseVideoFilter(TCHAR* pName, LPUNKNOWN lpunk, HRESULT* phr, REFCLSID clsid, long cBuffers = 1);
- virtual ~CBaseVideoFilter();
+ CBaseVideoFilter(TCHAR* pName, LPUNKNOWN lpunk, HRESULT* phr, REFCLSID clsid, long cBuffers = 1);
+ virtual ~CBaseVideoFilter();
- HRESULT ReconnectOutput(int w, int h, bool bSendSample = true, int realWidth = -1, int realHeight = -1);
- int GetPinCount();
- CBasePin* GetPin(int n);
+ HRESULT ReconnectOutput(int w, int h, bool bSendSample = true, int realWidth = -1, int realHeight = -1);
+ int GetPinCount();
+ CBasePin* GetPin(int n);
- HRESULT CheckInputType(const CMediaType* mtIn);
- HRESULT CheckOutputType(const CMediaType& mtOut);
- HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
- HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT GetMediaType(int iPosition, CMediaType* pMediaType);
- HRESULT SetMediaType(PIN_DIRECTION dir, const CMediaType* pmt);
+ HRESULT CheckInputType(const CMediaType* mtIn);
+ HRESULT CheckOutputType(const CMediaType& mtOut);
+ HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
+ HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT GetMediaType(int iPosition, CMediaType* pMediaType);
+ HRESULT SetMediaType(PIN_DIRECTION dir, const CMediaType* pmt);
- void SetAspect(CSize aspect);
+ void SetAspect(CSize aspect);
};
class CBaseVideoInputAllocator : public CMemAllocator
{
- CMediaType m_mt;
+ CMediaType m_mt;
public:
- CBaseVideoInputAllocator(HRESULT* phr);
- void SetMediaType(const CMediaType& mt);
- STDMETHODIMP GetBuffer(IMediaSample** ppBuffer, REFERENCE_TIME* pStartTime, REFERENCE_TIME* pEndTime, DWORD dwFlags);
+ CBaseVideoInputAllocator(HRESULT* phr);
+ void SetMediaType(const CMediaType& mt);
+ STDMETHODIMP GetBuffer(IMediaSample** ppBuffer, REFERENCE_TIME* pStartTime, REFERENCE_TIME* pEndTime, DWORD dwFlags);
};
class CBaseVideoInputPin : public CTransformInputPin
{
- CBaseVideoInputAllocator* m_pAllocator;
+ CBaseVideoInputAllocator* m_pAllocator;
public:
- CBaseVideoInputPin(TCHAR* pObjectName, CBaseVideoFilter* pFilter, HRESULT* phr, LPCWSTR pName);
- ~CBaseVideoInputPin();
+ CBaseVideoInputPin(TCHAR* pObjectName, CBaseVideoFilter* pFilter, HRESULT* phr, LPCWSTR pName);
+ ~CBaseVideoInputPin();
- STDMETHODIMP GetAllocator(IMemAllocator** ppAllocator);
- STDMETHODIMP ReceiveConnection(IPin* pConnector, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP GetAllocator(IMemAllocator** ppAllocator);
+ STDMETHODIMP ReceiveConnection(IPin* pConnector, const AM_MEDIA_TYPE* pmt);
};
class CBaseVideoOutputPin : public CTransformOutputPin
{
public:
- CBaseVideoOutputPin(TCHAR* pObjectName, CBaseVideoFilter* pFilter, HRESULT* phr, LPCWSTR pName);
+ CBaseVideoOutputPin(TCHAR* pObjectName, CBaseVideoFilter* pFilter, HRESULT* phr, LPCWSTR pName);
- HRESULT CheckMediaType(const CMediaType* mtOut);
+ HRESULT CheckMediaType(const CMediaType* mtOut);
};
diff --git a/src/filters/transform/BufferFilter/BufferFilter.cpp b/src/filters/transform/BufferFilter/BufferFilter.cpp
index f22aef795..77ff60f7a 100644
--- a/src/filters/transform/BufferFilter/BufferFilter.cpp
+++ b/src/filters/transform/BufferFilter/BufferFilter.cpp
@@ -28,36 +28,36 @@
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_NULL, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_NULL, &MEDIASUBTYPE_NULL},
};
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
- {&MEDIATYPE_NULL, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_NULL, &MEDIASUBTYPE_NULL},
};
const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CBufferFilter), BufferFilterName, MERIT_DO_NOT_USE, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory}
+ {&__uuidof(CBufferFilter), BufferFilterName, MERIT_DO_NOT_USE, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory}
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CBufferFilter>, NULL, &sudFilter[0]}
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CBufferFilter>, NULL, &sudFilter[0]}
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -71,33 +71,33 @@ CFilterApp theApp;
//
CBufferFilter::CBufferFilter(LPUNKNOWN lpunk, HRESULT* phr)
- : CTransformFilter(NAME("CBufferFilter"), lpunk, __uuidof(this))
- , m_nSamplesToBuffer(2)
+ : CTransformFilter(NAME("CBufferFilter"), lpunk, __uuidof(this))
+ , m_nSamplesToBuffer(2)
{
- HRESULT hr = S_OK;
-
- do {
- m_pInput = DNew CTransformInputPin(NAME("Transform input pin"), this, &hr, L"In");
- if (!m_pInput) {
- hr = E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- break;
- }
-
- m_pOutput = DNew CBufferFilterOutputPin(this, &hr);
- if (!m_pOutput) {
- hr = E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- delete m_pInput, m_pInput = NULL;
- break;
- }
- } while (false);
-
- if (phr) {
- *phr = hr;
- }
+ HRESULT hr = S_OK;
+
+ do {
+ m_pInput = DNew CTransformInputPin(NAME("Transform input pin"), this, &hr, L"In");
+ if (!m_pInput) {
+ hr = E_OUTOFMEMORY;
+ }
+ if (FAILED(hr)) {
+ break;
+ }
+
+ m_pOutput = DNew CBufferFilterOutputPin(this, &hr);
+ if (!m_pOutput) {
+ hr = E_OUTOFMEMORY;
+ }
+ if (FAILED(hr)) {
+ delete m_pInput, m_pInput = NULL;
+ break;
+ }
+ } while (false);
+
+ if (phr) {
+ *phr = hr;
+ }
}
CBufferFilter::~CBufferFilter()
@@ -106,203 +106,203 @@ CBufferFilter::~CBufferFilter()
STDMETHODIMP CBufferFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- return
- QI(IBufferFilter)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IBufferFilter)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// IBufferFilter
STDMETHODIMP CBufferFilter::SetBuffers(int nBuffers)
{
- if (!m_pOutput) {
- return E_FAIL;
- }
+ if (!m_pOutput) {
+ return E_FAIL;
+ }
- if (m_pOutput->IsConnected()) { // TODO: allow "on-the-fly" changes
- return VFW_E_ALREADY_CONNECTED;
- }
+ if (m_pOutput->IsConnected()) { // TODO: allow "on-the-fly" changes
+ return VFW_E_ALREADY_CONNECTED;
+ }
- m_nSamplesToBuffer = nBuffers;
+ m_nSamplesToBuffer = nBuffers;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP_(int) CBufferFilter::GetBuffers()
{
- return m_nSamplesToBuffer;
+ return m_nSamplesToBuffer;
}
STDMETHODIMP_(int) CBufferFilter::GetFreeBuffers()
{
- CBufferFilterOutputPin* pPin = static_cast<CBufferFilterOutputPin*>(m_pOutput);
- return (pPin && pPin->m_pOutputQueue ? (m_nSamplesToBuffer - pPin->m_pOutputQueue->GetQueueCount()) : 0);
+ CBufferFilterOutputPin* pPin = static_cast<CBufferFilterOutputPin*>(m_pOutput);
+ return (pPin && pPin->m_pOutputQueue ? (m_nSamplesToBuffer - pPin->m_pOutputQueue->GetQueueCount()) : 0);
}
STDMETHODIMP CBufferFilter::SetPriority(DWORD dwPriority)
{
- CBufferFilterOutputPin* pPin = static_cast<CBufferFilterOutputPin*>(m_pOutput);
- return (pPin && pPin->m_pOutputQueue ? (pPin->m_pOutputQueue->SetPriority(dwPriority) ? S_OK : E_FAIL) : E_UNEXPECTED);
+ CBufferFilterOutputPin* pPin = static_cast<CBufferFilterOutputPin*>(m_pOutput);
+ return (pPin && pPin->m_pOutputQueue ? (pPin->m_pOutputQueue->SetPriority(dwPriority) ? S_OK : E_FAIL) : E_UNEXPECTED);
}
//
HRESULT CBufferFilter::Receive(IMediaSample* pSample)
{
- /* Check for other streams and pass them on */
- AM_SAMPLE2_PROPERTIES* const pProps = m_pInput->SampleProps();
- if (pProps->dwStreamId != AM_STREAM_MEDIA) {
- return m_pOutput->Deliver(pSample);
- }
-
- HRESULT hr;
- ASSERT(pSample);
- IMediaSample* pOutSample;
-
- ASSERT(m_pOutput != NULL);
-
- // Set up the output sample
- hr = InitializeOutputSample(pSample, &pOutSample);
-
- if (FAILED(hr)) {
- return hr;
- }
-
- // Start timing the transform (if PERF is defined)
- MSR_START(m_idTransform);
-
- // have the derived class transform the data
-
- hr = Transform(pSample, pOutSample);
-
- // Stop the clock and log it (if PERF is defined)
- MSR_STOP(m_idTransform);
-
- if (FAILED(hr)) {
- DbgLog((LOG_TRACE,1,_T("Error from transform")));
- } else {
- // the Transform() function can return S_FALSE to indicate that the
- // sample should not be delivered; we only deliver the sample if it's
- // really S_OK (same as NOERROR, of course.)
- if (hr == NOERROR) {
- hr = m_pOutput->Deliver(pOutSample);
- m_bSampleSkipped = FALSE; // last thing no longer dropped
- } else {
- // S_FALSE returned from Transform is a PRIVATE agreement
- // We should return NOERROR from Receive() in this cause because returning S_FALSE
- // from Receive() means that this is the end of the stream and no more data should
- // be sent.
- if (S_FALSE == hr) {
-
- // Release the sample before calling notify to avoid
- // deadlocks if the sample holds a lock on the system
- // such as DirectDraw buffers do
- pOutSample->Release();
- m_bSampleSkipped = TRUE;
- if (!m_bQualityChanged) {
- NotifyEvent(EC_QUALITY_CHANGE,0,0);
- m_bQualityChanged = TRUE;
- }
- return NOERROR;
- }
- }
- }
-
- // release the output buffer. If the connected pin still needs it,
- // it will have addrefed it itself.
- pOutSample->Release();
-
- return hr;
+ /* Check for other streams and pass them on */
+ AM_SAMPLE2_PROPERTIES* const pProps = m_pInput->SampleProps();
+ if (pProps->dwStreamId != AM_STREAM_MEDIA) {
+ return m_pOutput->Deliver(pSample);
+ }
+
+ HRESULT hr;
+ ASSERT(pSample);
+ IMediaSample* pOutSample;
+
+ ASSERT(m_pOutput != NULL);
+
+ // Set up the output sample
+ hr = InitializeOutputSample(pSample, &pOutSample);
+
+ if (FAILED(hr)) {
+ return hr;
+ }
+
+ // Start timing the transform (if PERF is defined)
+ MSR_START(m_idTransform);
+
+ // have the derived class transform the data
+
+ hr = Transform(pSample, pOutSample);
+
+ // Stop the clock and log it (if PERF is defined)
+ MSR_STOP(m_idTransform);
+
+ if (FAILED(hr)) {
+ DbgLog((LOG_TRACE, 1, _T("Error from transform")));
+ } else {
+ // the Transform() function can return S_FALSE to indicate that the
+ // sample should not be delivered; we only deliver the sample if it's
+ // really S_OK (same as NOERROR, of course.)
+ if (hr == NOERROR) {
+ hr = m_pOutput->Deliver(pOutSample);
+ m_bSampleSkipped = FALSE; // last thing no longer dropped
+ } else {
+ // S_FALSE returned from Transform is a PRIVATE agreement
+ // We should return NOERROR from Receive() in this cause because returning S_FALSE
+ // from Receive() means that this is the end of the stream and no more data should
+ // be sent.
+ if (S_FALSE == hr) {
+
+ // Release the sample before calling notify to avoid
+ // deadlocks if the sample holds a lock on the system
+ // such as DirectDraw buffers do
+ pOutSample->Release();
+ m_bSampleSkipped = TRUE;
+ if (!m_bQualityChanged) {
+ NotifyEvent(EC_QUALITY_CHANGE, 0, 0);
+ m_bQualityChanged = TRUE;
+ }
+ return NOERROR;
+ }
+ }
+ }
+
+ // release the output buffer. If the connected pin still needs it,
+ // it will have addrefed it itself.
+ pOutSample->Release();
+
+ return hr;
}
HRESULT CBufferFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
{
- BYTE* pDataIn = NULL;
- BYTE* pDataOut = NULL;
+ BYTE* pDataIn = NULL;
+ BYTE* pDataOut = NULL;
- pIn->GetPointer(&pDataIn);
- pOut->GetPointer(&pDataOut);
+ pIn->GetPointer(&pDataIn);
+ pOut->GetPointer(&pDataOut);
- long len = pIn->GetActualDataLength();
- long size = pOut->GetSize();
+ long len = pIn->GetActualDataLength();
+ long size = pOut->GetSize();
- if (!pDataIn || !pDataOut || len > size || len <= 0) {
- return S_FALSE;
- }
+ if (!pDataIn || !pDataOut || len > size || len <= 0) {
+ return S_FALSE;
+ }
- memcpy(pDataOut, pDataIn, min(len, size));
+ memcpy(pDataOut, pDataIn, min(len, size));
- pOut->SetActualDataLength(min(len, size));
+ pOut->SetActualDataLength(min(len, size));
- return S_OK;
+ return S_OK;
}
HRESULT CBufferFilter::CheckInputType(const CMediaType* mtIn)
{
- return S_OK;
+ return S_OK;
}
HRESULT CBufferFilter::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
{
- return mtIn->MatchesPartial(mtOut) ? S_OK : VFW_E_TYPE_NOT_ACCEPTED;
+ return mtIn->MatchesPartial(mtOut) ? S_OK : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CBufferFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if (m_pInput->IsConnected() == FALSE) {
- return E_UNEXPECTED;
- }
+ if (m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
- CComPtr<IMemAllocator> pAllocatorIn;
- m_pInput->GetAllocator(&pAllocatorIn);
- if (!pAllocatorIn) {
- return E_UNEXPECTED;
- }
+ CComPtr<IMemAllocator> pAllocatorIn;
+ m_pInput->GetAllocator(&pAllocatorIn);
+ if (!pAllocatorIn) {
+ return E_UNEXPECTED;
+ }
- pAllocatorIn->GetProperties(pProperties);
+ pAllocatorIn->GetProperties(pProperties);
- pProperties->cBuffers = max(m_nSamplesToBuffer, pProperties->cBuffers);
+ pProperties->cBuffers = max(m_nSamplesToBuffer, pProperties->cBuffers);
- HRESULT hr;
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
- return hr;
- }
+ HRESULT hr;
+ ALLOCATOR_PROPERTIES Actual;
+ if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
- return (pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
- ? E_FAIL
- : NOERROR);
+ return (pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
+ ? E_FAIL
+ : NOERROR);
}
HRESULT CBufferFilter::GetMediaType(int iPosition, CMediaType* pMediaType)
{
- if (m_pInput->IsConnected() == FALSE) {
- return E_UNEXPECTED;
- }
+ if (m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
- // TODO: offer all input types from upstream and allow reconnection at least in stopped state
- if (iPosition < 0) {
- return E_INVALIDARG;
- }
- if (iPosition > 0) {
- return VFW_S_NO_MORE_ITEMS;
- }
+ // TODO: offer all input types from upstream and allow reconnection at least in stopped state
+ if (iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if (iPosition > 0) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
- CopyMediaType(pMediaType, &m_pInput->CurrentMediaType());
+ CopyMediaType(pMediaType, &m_pInput->CurrentMediaType());
- return S_OK;
+ return S_OK;
}
HRESULT CBufferFilter::StopStreaming()
{
- CBufferFilterOutputPin* pPin = static_cast<CBufferFilterOutputPin*>(m_pOutput);
- if (m_pInput && pPin && pPin->m_pOutputQueue) {
- while (!m_pInput->IsFlushing() && pPin->m_pOutputQueue->GetQueueCount() > 0) {
- Sleep(50);
- }
- }
-
- return __super::StopStreaming();
+ CBufferFilterOutputPin* pPin = static_cast<CBufferFilterOutputPin*>(m_pOutput);
+ if (m_pInput && pPin && pPin->m_pOutputQueue) {
+ while (!m_pInput->IsFlushing() && pPin->m_pOutputQueue->GetQueueCount() > 0) {
+ Sleep(50);
+ }
+ }
+
+ return __super::StopStreaming();
}
//
@@ -310,45 +310,45 @@ HRESULT CBufferFilter::StopStreaming()
//
CBufferFilterOutputPin::CBufferFilterOutputPin(CTransformFilter* pFilter, HRESULT* phr)
- : CTransformOutputPin(NAME("CBufferFilterOutputPin"), pFilter, phr, L"Out")
+ : CTransformOutputPin(NAME("CBufferFilterOutputPin"), pFilter, phr, L"Out")
{
}
HRESULT CBufferFilterOutputPin::Active()
{
- CAutoLock lock_it(m_pLock);
+ CAutoLock lock_it(m_pLock);
- if (m_Connected && !m_pOutputQueue) {
- HRESULT hr = NOERROR;
+ if (m_Connected && !m_pOutputQueue) {
+ HRESULT hr = NOERROR;
- m_pOutputQueue.Attach(DNew CBufferFilterOutputQueue(m_Connected, &hr));
- if (!m_pOutputQueue) {
- hr = E_OUTOFMEMORY;
- }
+ m_pOutputQueue.Attach(DNew CBufferFilterOutputQueue(m_Connected, &hr));
+ if (!m_pOutputQueue) {
+ hr = E_OUTOFMEMORY;
+ }
- if (FAILED(hr)) {
- m_pOutputQueue.Free();
- return hr;
- }
- }
+ if (FAILED(hr)) {
+ m_pOutputQueue.Free();
+ return hr;
+ }
+ }
- return __super::Active();
+ return __super::Active();
}
HRESULT CBufferFilterOutputPin::Inactive()
{
- CAutoLock lock_it(m_pLock);
- m_pOutputQueue.Free();
- return __super::Inactive();
+ CAutoLock lock_it(m_pLock);
+ m_pOutputQueue.Free();
+ return __super::Inactive();
}
HRESULT CBufferFilterOutputPin::Deliver(IMediaSample* pMediaSample)
{
- if (!m_pOutputQueue) {
- return NOERROR;
- }
- pMediaSample->AddRef();
- return m_pOutputQueue->Receive(pMediaSample);
+ if (!m_pOutputQueue) {
+ return NOERROR;
+ }
+ pMediaSample->AddRef();
+ return m_pOutputQueue->Receive(pMediaSample);
}
#define CallQueue(call) \
@@ -358,20 +358,20 @@ HRESULT CBufferFilterOutputPin::Deliver(IMediaSample* pMediaSample)
HRESULT CBufferFilterOutputPin::DeliverEndOfStream()
{
- CallQueue(EOS());
+ CallQueue(EOS());
}
HRESULT CBufferFilterOutputPin::DeliverBeginFlush()
{
- CallQueue(BeginFlush());
+ CallQueue(BeginFlush());
}
HRESULT CBufferFilterOutputPin::DeliverEndFlush()
{
- CallQueue(EndFlush());
+ CallQueue(EndFlush());
}
HRESULT CBufferFilterOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- CallQueue(NewSegment(tStart, tStop, dRate));
+ CallQueue(NewSegment(tStart, tStop, dRate));
}
diff --git a/src/filters/transform/BufferFilter/BufferFilter.h b/src/filters/transform/BufferFilter/BufferFilter.h
index 3d2acc511..45ae16ef2 100644
--- a/src/filters/transform/BufferFilter/BufferFilter.h
+++ b/src/filters/transform/BufferFilter/BufferFilter.h
@@ -30,73 +30,73 @@
interface __declspec(uuid("63EF0035-3FFE-4c41-9230-4346E028BE20"))
IBufferFilter :
public IUnknown {
- STDMETHOD(SetBuffers) (int nBuffers) = 0;
- STDMETHOD_(int, GetBuffers) () = 0;
- STDMETHOD_(int, GetFreeBuffers) () = 0;
- STDMETHOD(SetPriority) (DWORD dwPriority = THREAD_PRIORITY_NORMAL) = 0;
+ STDMETHOD(SetBuffers)(int nBuffers) = 0;
+ STDMETHOD_(int, GetBuffers)() = 0;
+ STDMETHOD_(int, GetFreeBuffers)() = 0;
+ STDMETHOD(SetPriority)(DWORD dwPriority = THREAD_PRIORITY_NORMAL) = 0;
};
class __declspec(uuid("DA2B3D77-2F29-4fd2-AC99-DEE4A8A13BF0"))
- CBufferFilter : public CTransformFilter, public IBufferFilter
+ CBufferFilter : public CTransformFilter, public IBufferFilter
{
- int m_nSamplesToBuffer;
+ int m_nSamplesToBuffer;
public:
- CBufferFilter(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CBufferFilter();
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // IBufferFilter
- STDMETHODIMP SetBuffers(int nBuffers);
- STDMETHODIMP_(int) GetBuffers();
- STDMETHODIMP_(int) GetFreeBuffers();
- STDMETHODIMP SetPriority(DWORD dwPriority = THREAD_PRIORITY_NORMAL);
-
- HRESULT Receive(IMediaSample* pSample);
- HRESULT Transform(IMediaSample* pIn, IMediaSample* pOut);
- HRESULT CheckInputType(const CMediaType* mtIn);
- HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
- HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT GetMediaType(int iPosition, CMediaType* pMediaType);
- HRESULT StopStreaming();
+ CBufferFilter(LPUNKNOWN lpunk, HRESULT* phr);
+ virtual ~CBufferFilter();
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ // IBufferFilter
+ STDMETHODIMP SetBuffers(int nBuffers);
+ STDMETHODIMP_(int) GetBuffers();
+ STDMETHODIMP_(int) GetFreeBuffers();
+ STDMETHODIMP SetPriority(DWORD dwPriority = THREAD_PRIORITY_NORMAL);
+
+ HRESULT Receive(IMediaSample* pSample);
+ HRESULT Transform(IMediaSample* pIn, IMediaSample* pOut);
+ HRESULT CheckInputType(const CMediaType* mtIn);
+ HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
+ HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT GetMediaType(int iPosition, CMediaType* pMediaType);
+ HRESULT StopStreaming();
};
class CBufferFilterOutputPin : public CTransformOutputPin
{
- class CBufferFilterOutputQueue : public COutputQueue
- {
- public:
- CBufferFilterOutputQueue(IPin* pInputPin, HRESULT* phr,
- DWORD dwPriority = THREAD_PRIORITY_NORMAL,
- BOOL bAuto = FALSE, BOOL bQueue = TRUE,
- LONG lBatchSize = 1, BOOL bBatchExact = FALSE,
- LONG lListSize = DEFAULTCACHE,
- bool bFlushingOpt = false)
- : COutputQueue(pInputPin, phr, bAuto, bQueue, lBatchSize, bBatchExact, lListSize, dwPriority, bFlushingOpt) {
- }
-
- int GetQueueCount() {
- return m_List ? m_List->GetCount() : -1;
- }
-
- bool SetPriority(DWORD dwPriority) {
- return m_hThread ? !!::SetThreadPriority(m_hThread, dwPriority) : false;
- }
- };
+ class CBufferFilterOutputQueue : public COutputQueue
+ {
+ public:
+ CBufferFilterOutputQueue(IPin* pInputPin, HRESULT* phr,
+ DWORD dwPriority = THREAD_PRIORITY_NORMAL,
+ BOOL bAuto = FALSE, BOOL bQueue = TRUE,
+ LONG lBatchSize = 1, BOOL bBatchExact = FALSE,
+ LONG lListSize = DEFAULTCACHE,
+ bool bFlushingOpt = false)
+ : COutputQueue(pInputPin, phr, bAuto, bQueue, lBatchSize, bBatchExact, lListSize, dwPriority, bFlushingOpt) {
+ }
+
+ int GetQueueCount() {
+ return m_List ? m_List->GetCount() : -1;
+ }
+
+ bool SetPriority(DWORD dwPriority) {
+ return m_hThread ? !!::SetThreadPriority(m_hThread, dwPriority) : false;
+ }
+ };
public:
- CBufferFilterOutputPin(CTransformFilter* pFilter, HRESULT* phr);
+ CBufferFilterOutputPin(CTransformFilter* pFilter, HRESULT* phr);
- CAutoPtr<CBufferFilterOutputQueue> m_pOutputQueue;
+ CAutoPtr<CBufferFilterOutputQueue> m_pOutputQueue;
- HRESULT Active();
- HRESULT Inactive();
+ HRESULT Active();
+ HRESULT Inactive();
- HRESULT Deliver(IMediaSample* pMediaSample);
- HRESULT DeliverEndOfStream();
- HRESULT DeliverBeginFlush();
- HRESULT DeliverEndFlush();
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ HRESULT Deliver(IMediaSample* pMediaSample);
+ HRESULT DeliverEndOfStream();
+ HRESULT DeliverBeginFlush();
+ HRESULT DeliverEndFlush();
+ HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
};
diff --git a/src/filters/transform/DeCSSFilter/DeCSSFilter.cpp b/src/filters/transform/DeCSSFilter/DeCSSFilter.cpp
index 544c5763e..8af610d9a 100644
--- a/src/filters/transform/DeCSSFilter/DeCSSFilter.cpp
+++ b/src/filters/transform/DeCSSFilter/DeCSSFilter.cpp
@@ -30,37 +30,37 @@
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_NULL},
};
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
- {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_NULL},
- {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_NULL},
};
const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CDeCSSFilter), DeCSSFilterName, MERIT_DO_NOT_USE, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CDeCSSFilter), DeCSSFilterName, MERIT_DO_NOT_USE, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDeCSSFilter>, NULL, &sudFilter[0]},
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDeCSSFilter>, NULL, &sudFilter[0]},
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -76,54 +76,54 @@ CFilterApp theApp;
class CKsPSInputPin : public CDeCSSInputPin
{
public:
- CKsPSInputPin(TCHAR* pObjectName, CTransformFilter* pFilter, HRESULT* phr, LPWSTR pName)
- : CDeCSSInputPin(pObjectName, pFilter, phr, pName) {
- }
-
- // IKsPropertySet
- STDMETHODIMP Set(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData, ULONG DataLength) {
- if (CComQIPtr<IKsPropertySet> pKsPS = (static_cast<CDeCSSFilter*>(m_pFilter))->m_pOutput->GetConnected()) {
- return pKsPS->Set(PropSet, Id, InstanceData, InstanceLength, PropertyData, DataLength);
- }
- return E_NOTIMPL;
- }
- STDMETHODIMP Get(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData, ULONG DataLength, ULONG* pBytesReturned) {
- if (CComQIPtr<IKsPropertySet> pKsPS = (static_cast<CDeCSSFilter*>(m_pFilter))->m_pOutput->GetConnected()) {
- return pKsPS->Get(PropSet, Id, InstanceData, InstanceLength, PropertyData, DataLength, pBytesReturned);
- }
- return E_NOTIMPL;
- }
- STDMETHODIMP QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport) {
- if (CComQIPtr<IKsPropertySet> pKsPS = (static_cast<CDeCSSFilter*>(m_pFilter))->m_pOutput->GetConnected()) {
- return pKsPS->QuerySupported(PropSet, Id, pTypeSupport);
- }
- return E_NOTIMPL;
- }
+ CKsPSInputPin(TCHAR* pObjectName, CTransformFilter* pFilter, HRESULT* phr, LPWSTR pName)
+ : CDeCSSInputPin(pObjectName, pFilter, phr, pName) {
+ }
+
+ // IKsPropertySet
+ STDMETHODIMP Set(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData, ULONG DataLength) {
+ if (CComQIPtr<IKsPropertySet> pKsPS = (static_cast<CDeCSSFilter*>(m_pFilter))->m_pOutput->GetConnected()) {
+ return pKsPS->Set(PropSet, Id, InstanceData, InstanceLength, PropertyData, DataLength);
+ }
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP Get(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData, ULONG DataLength, ULONG* pBytesReturned) {
+ if (CComQIPtr<IKsPropertySet> pKsPS = (static_cast<CDeCSSFilter*>(m_pFilter))->m_pOutput->GetConnected()) {
+ return pKsPS->Get(PropSet, Id, InstanceData, InstanceLength, PropertyData, DataLength, pBytesReturned);
+ }
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport) {
+ if (CComQIPtr<IKsPropertySet> pKsPS = (static_cast<CDeCSSFilter*>(m_pFilter))->m_pOutput->GetConnected()) {
+ return pKsPS->QuerySupported(PropSet, Id, pTypeSupport);
+ }
+ return E_NOTIMPL;
+ }
};
CDeCSSFilter::CDeCSSFilter(LPUNKNOWN lpunk, HRESULT* phr)
- : CTransformFilter(NAME("CDeCSSFilter"), lpunk, __uuidof(this))
+ : CTransformFilter(NAME("CDeCSSFilter"), lpunk, __uuidof(this))
{
- if (phr) {
- *phr = S_OK;
- }
-
- m_pInput = DNew CKsPSInputPin(NAME("CKsPSInputPin"), this, phr, L"In");
- if (!m_pInput) {
- *phr = E_OUTOFMEMORY;
- }
- if (FAILED(*phr)) {
- return;
- }
-
- m_pOutput = DNew CTransformOutputPin(NAME("CTransformOutputPin"), this, phr, L"Out");
- if (!m_pOutput) {
- *phr = E_OUTOFMEMORY;
- }
- if (FAILED(*phr)) {
- delete m_pInput, m_pInput = NULL;
- return;
- }
+ if (phr) {
+ *phr = S_OK;
+ }
+
+ m_pInput = DNew CKsPSInputPin(NAME("CKsPSInputPin"), this, phr, L"In");
+ if (!m_pInput) {
+ *phr = E_OUTOFMEMORY;
+ }
+ if (FAILED(*phr)) {
+ return;
+ }
+
+ m_pOutput = DNew CTransformOutputPin(NAME("CTransformOutputPin"), this, phr, L"Out");
+ if (!m_pOutput) {
+ *phr = E_OUTOFMEMORY;
+ }
+ if (FAILED(*phr)) {
+ delete m_pInput, m_pInput = NULL;
+ return;
+ }
}
CDeCSSFilter::~CDeCSSFilter()
@@ -132,121 +132,121 @@ CDeCSSFilter::~CDeCSSFilter()
HRESULT CDeCSSFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
{
- AM_MEDIA_TYPE* pmt;
- if (SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt) {
- CMediaType mt = *pmt;
- m_pInput->SetMediaType(&mt);
- mt.majortype = m_pOutput->CurrentMediaType().majortype;
- m_pOutput->SetMediaType(&mt);
- pOut->SetMediaType(&mt);
- DeleteMediaType(pmt);
- }
-
- BYTE* pDataIn = NULL;
- BYTE* pDataOut = NULL;
-
- pIn->GetPointer(&pDataIn);
- pOut->GetPointer(&pDataOut);
-
- long len = pIn->GetActualDataLength();
- long size = pOut->GetSize();
-
- if (len == 0 || pDataIn == NULL) { // format changes do not carry any data
- pOut->SetActualDataLength(0);
- return S_OK;
- }
-
- if (m_pOutput->CurrentMediaType().majortype == MEDIATYPE_MPEG2_PES) {
- if (*(DWORD*)pDataIn == 0xBA010000) {
- len -= 14;
- pDataIn += 14;
- if (int stuffing = (pDataIn[-1]&7)) {
- len -= stuffing;
- pDataIn += stuffing;
- }
- }
- if (len <= 0) {
- return S_FALSE;
- }
- if (*(DWORD*)pDataIn == 0xBB010000) {
- len -= 4;
- pDataIn += 4;
- int hdrlen = ((pDataIn[0]<<8)|pDataIn[1]) + 2;
- len -= hdrlen;
- pDataIn += hdrlen;
- }
- if (len <= 0) {
- return S_FALSE;
- }
- }
-
- if (!pDataIn || !pDataOut || len > size || len < 0) {
- return S_FALSE;
- }
-
- memcpy(pDataOut, pDataIn, min(len, size));
- pOut->SetActualDataLength(min(len, size));
-
- return S_OK;
+ AM_MEDIA_TYPE* pmt;
+ if (SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt) {
+ CMediaType mt = *pmt;
+ m_pInput->SetMediaType(&mt);
+ mt.majortype = m_pOutput->CurrentMediaType().majortype;
+ m_pOutput->SetMediaType(&mt);
+ pOut->SetMediaType(&mt);
+ DeleteMediaType(pmt);
+ }
+
+ BYTE* pDataIn = NULL;
+ BYTE* pDataOut = NULL;
+
+ pIn->GetPointer(&pDataIn);
+ pOut->GetPointer(&pDataOut);
+
+ long len = pIn->GetActualDataLength();
+ long size = pOut->GetSize();
+
+ if (len == 0 || pDataIn == NULL) { // format changes do not carry any data
+ pOut->SetActualDataLength(0);
+ return S_OK;
+ }
+
+ if (m_pOutput->CurrentMediaType().majortype == MEDIATYPE_MPEG2_PES) {
+ if (*(DWORD*)pDataIn == 0xBA010000) {
+ len -= 14;
+ pDataIn += 14;
+ if (int stuffing = (pDataIn[-1] & 7)) {
+ len -= stuffing;
+ pDataIn += stuffing;
+ }
+ }
+ if (len <= 0) {
+ return S_FALSE;
+ }
+ if (*(DWORD*)pDataIn == 0xBB010000) {
+ len -= 4;
+ pDataIn += 4;
+ int hdrlen = ((pDataIn[0] << 8) | pDataIn[1]) + 2;
+ len -= hdrlen;
+ pDataIn += hdrlen;
+ }
+ if (len <= 0) {
+ return S_FALSE;
+ }
+ }
+
+ if (!pDataIn || !pDataOut || len > size || len < 0) {
+ return S_FALSE;
+ }
+
+ memcpy(pDataOut, pDataIn, min(len, size));
+ pOut->SetActualDataLength(min(len, size));
+
+ return S_OK;
}
HRESULT CDeCSSFilter::CheckInputType(const CMediaType* mtIn)
{
- return mtIn->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ return mtIn->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CDeCSSFilter::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
{
- return SUCCEEDED(CheckInputType(mtIn))
- && mtOut->majortype == MEDIATYPE_MPEG2_PACK || mtOut->majortype == MEDIATYPE_MPEG2_PES
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ return SUCCEEDED(CheckInputType(mtIn))
+ && mtOut->majortype == MEDIATYPE_MPEG2_PACK || mtOut->majortype == MEDIATYPE_MPEG2_PES
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CDeCSSFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if (m_pInput->IsConnected() == FALSE) {
- return E_UNEXPECTED;
- }
-
- pProperties->cbAlign = 1;
- pProperties->cBuffers = 1;
- pProperties->cbBuffer = 2048;
- pProperties->cbPrefix = 0;
-
- HRESULT hr;
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
- return hr;
- }
-
- return (pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
- ? E_FAIL
- : NOERROR);
+ if (m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
+
+ pProperties->cbAlign = 1;
+ pProperties->cBuffers = 1;
+ pProperties->cbBuffer = 2048;
+ pProperties->cbPrefix = 0;
+
+ HRESULT hr;
+ ALLOCATOR_PROPERTIES Actual;
+ if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
+
+ return (pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
+ ? E_FAIL
+ : NOERROR);
}
HRESULT CDeCSSFilter::GetMediaType(int iPosition, CMediaType* pmt)
{
- if (m_pInput->IsConnected() == FALSE) {
- return E_UNEXPECTED;
- }
-
- if (iPosition < 0) {
- return E_INVALIDARG;
- }
- if (iPosition > 1) {
- return VFW_S_NO_MORE_ITEMS;
- }
-
- CopyMediaType(pmt, &m_pInput->CurrentMediaType());
- if (iPosition == 0) {
- pmt->majortype = MEDIATYPE_MPEG2_PACK;
- }
- if (iPosition == 1) {
- pmt->majortype = MEDIATYPE_MPEG2_PES;
- }
-
- return S_OK;
+ if (m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
+
+ if (iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if (iPosition > 1) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
+
+ CopyMediaType(pmt, &m_pInput->CurrentMediaType());
+ if (iPosition == 0) {
+ pmt->majortype = MEDIATYPE_MPEG2_PACK;
+ }
+ if (iPosition == 1) {
+ pmt->majortype = MEDIATYPE_MPEG2_PES;
+ }
+
+ return S_OK;
}
diff --git a/src/filters/transform/DeCSSFilter/DeCSSFilter.h b/src/filters/transform/DeCSSFilter/DeCSSFilter.h
index 921c1375c..446eb2017 100644
--- a/src/filters/transform/DeCSSFilter/DeCSSFilter.h
+++ b/src/filters/transform/DeCSSFilter/DeCSSFilter.h
@@ -26,17 +26,17 @@
#define DeCSSFilterName L"MPC DeCSSFilter"
class __declspec(uuid("7B3BD419-FE03-4820-BE94-A22A4F844895"))
- CDeCSSFilter : public CTransformFilter
+ CDeCSSFilter : public CTransformFilter
{
- friend class CKsPSInputPin;
+ friend class CKsPSInputPin;
public:
- CDeCSSFilter(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CDeCSSFilter();
+ CDeCSSFilter(LPUNKNOWN lpunk, HRESULT* phr);
+ virtual ~CDeCSSFilter();
- HRESULT Transform(IMediaSample* pIn, IMediaSample* pOut);
- HRESULT CheckInputType(const CMediaType* mtIn);
- HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
- HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
+ HRESULT Transform(IMediaSample* pIn, IMediaSample* pOut);
+ HRESULT CheckInputType(const CMediaType* mtIn);
+ HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
+ HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT GetMediaType(int iPosition, CMediaType* pmt);
};
diff --git a/src/filters/transform/MPCVideoDec/CpuId.cpp b/src/filters/transform/MPCVideoDec/CpuId.cpp
index 7f58bd94b..93145142d 100644
--- a/src/filters/transform/MPCVideoDec/CpuId.cpp
+++ b/src/filters/transform/MPCVideoDec/CpuId.cpp
@@ -42,162 +42,159 @@
CCpuId::CCpuId(void)
{
- unsigned nHighestFeature;
- unsigned nHighestFeatureEx;
- int nBuff[4];
- char szMan[13];
- //char szFeatures[256];
-
- // Get CPU manufacturer and highest CPUID
- __cpuid(nBuff, 0);
- nHighestFeature = (unsigned)nBuff[0];
- *(int*)&szMan[0] = nBuff[1];
- *(int*)&szMan[4] = nBuff[3];
- *(int*)&szMan[8] = nBuff[2];
- szMan[12] = 0;
- if (strcmp(szMan, "AuthenticAMD") == 0)
- m_nType = PROCESSOR_AMD;
- else if (strcmp(szMan, "GenuineIntel") == 0)
- m_nType = PROCESSOR_INTEL;
- else
- m_nType = PROCESSOR_UNKNOWN;
-
- // Get highest extended feature
- __cpuid(nBuff, 0x80000000);
- nHighestFeatureEx = (unsigned)nBuff[0];
-
- // Get processor brand name
- /*
- if (nHighestFeatureEx >= 0x80000004)
- {
- char szCPUName[49];
- szCPUName[0] = 0;
- __cpuid((int*)&szCPUName[0], 0x80000002);
- __cpuid((int*)&szCPUName[16], 0x80000003);
- __cpuid((int*)&szCPUName[32], 0x80000004);
- szCPUName[48] = 0;
- for (int i = (int)strlen(szCPUName) - 1; i >= 0; --i)
- {
- if (szCPUName[i] == ' ')
- szCPUName[i] = '\0';
- else
- break;
- }
-
- ELog::Get().SystemFormat(L"PERF : CPU: %S (%S)\n", szCPUName, szMan);
- }
- else
- ELog::Get().SystemFormat(L"PERF : CPU: %S\n", szMan);
- */
-
- // Get CPU features
- m_nCPUFeatures = 0;
- //szFeatures[0] = 0;
- if (nHighestFeature >= 1)
- {
- __cpuid(nBuff, 1);
- if (nBuff[3] & CPUID_MMX) m_nCPUFeatures |= MPC_MM_MMX;
- if (nBuff[3] & CPUID_SSE) m_nCPUFeatures |= MPC_MM_SSE;
- if (nBuff[3] & CPUID_SSE2) m_nCPUFeatures |= MPC_MM_SSE2;
- if (nBuff[2] & CPUID_SSE3) m_nCPUFeatures |= MPC_MM_SSE3;
-
- // Intel specific:
- if (m_nType == PROCESSOR_INTEL)
- {
- if (nBuff[2] & CPUID_SSSE3) m_nCPUFeatures |= MPC_MM_SSSE3;
- //if (nBuff[2] & CPUID_EST) strcat(szFeatures, "EST ");
- }
-
- //if (nBuff[3] & CPUID_HTT)
- // strcat(szFeatures, "HTT ");
- }
-
- // AMD specific:
- if (m_nType == PROCESSOR_AMD)
- {
- // Get extended features
- __cpuid(nBuff, 0x80000000);
- if (nHighestFeatureEx >= 0x80000001)
- {
- __cpuid(nBuff, 0x80000001);
- if (nBuff[3] & CPUID_3DNOW) m_nCPUFeatures |= MPC_MM_3DNOW;
- //if (nBuff[3] & CPUID_3DNOWEXT) strcat(szFeatures, "Ex3DNow! ");
- if (nBuff[3] & CPUID_MMXEXT) m_nCPUFeatures |= MPC_MM_MMXEXT;
- }
-
- // Get level 1 cache size
- //if (nHighestFeatureEx >= 0x80000005)
- //{
- // __cpuid(nBuff, 0x80000005);
- // ELog::Get().SystemFormat(L"PERF : L1 cache size: %dK\n", ((unsigned)nBuff[2])>>24);
- //}
- }
-
- /*
- // Get cache size
- if (nHighestFeatureEx >= 0x80000006)
- {
- __cpuid(nBuff, 0x80000006);
- ELog::Get().SystemFormat(L"PERF : L2 cache size: %dK\n", ((unsigned)nBuff[2])>>16);
- }
-
- // Log features
- ELog::Get().SystemFormat(L"PERF : CPU Features: %S\n", szFeatures);
-
- // Get misc system info
- SYSTEM_INFO theInfo;
- GetSystemInfo(&theInfo);
-
- // Log number of CPUs and speeds
- ELog::Get().SystemFormat(L"PERF : Number of CPUs: %d\n", theInfo.dwNumberOfProcessors);
- for (DWORD i = 0; i < theInfo.dwNumberOfProcessors; ++i)
- {
- DWORD dwCPUSpeed = ReadCPUSpeedFromRegistry(i);
- ELog::Get().SystemFormat(L"PERF : * CPU %d speed: ~%dMHz\n", i, dwCPUSpeed);
- }
- */
-
- /*
- unsigned nHighestFeature;
- unsigned nHighestFeatureEx;
-
- m_CPUInfo[0] = -1;
- m_CPUInfoEx[0] = -1;
- m_CPUAMDInfo[0] = -1;
-
- __cpuid(m_CPUInfo, 0);
- nHighestFeature = (unsigned)m_CPUInfo[0];
-
- __cpuid(nBuff, 0x80000000);
- nHighestFeatureEx = (unsigned)nBuff[0];
-
- m_nDSPFlags = 0;
- if (m_CPUInfo[3] & CPUID_MMX) m_nDSPFlags |= MPC_MM_MMX;
- if (m_CPUInfo[3] & CPUID_SSE) m_nDSPFlags |= MPC_MM_SSE;
- if (m_CPUInfo[3] & CPUID_SSE2) m_nDSPFlags |= MPC_MM_SSE2;
- if (m_CPUInfo[2] & CPUID_SSE3) m_nDSPFlags |= MPC_MM_SSE3;
-
- switch (m_nType)
- {
- case PROCESSOR_AMD :
- __cpuid(m_CPUAMDInfo, 0x80000000);
- if (nHighestFeatureEx >= 0x80000001)
- {
- if (m_CPUAMDInfo[3] & CPUID_MMXEXT) m_nDSPFlags |= MPC_MM_MMXEXT;
- if (m_CPUAMDInfo[3] & CPUID_3DNOW) m_nDSPFlags |= MPC_MM_3DNOW;
- }
- break;
- case PROCESSOR_INTEL :
- if (m_CPUInfo[2] & CPUID_SSSE3) m_nDSPFlags |= MPC_MM_SSSE3;
- break;
- }
- */
+ unsigned nHighestFeature;
+ unsigned nHighestFeatureEx;
+ int nBuff[4];
+ char szMan[13];
+ //char szFeatures[256];
+
+ // Get CPU manufacturer and highest CPUID
+ __cpuid(nBuff, 0);
+ nHighestFeature = (unsigned)nBuff[0];
+ *(int*)&szMan[0] = nBuff[1];
+ *(int*)&szMan[4] = nBuff[3];
+ *(int*)&szMan[8] = nBuff[2];
+ szMan[12] = 0;
+ if (strcmp(szMan, "AuthenticAMD") == 0) {
+ m_nType = PROCESSOR_AMD;
+ } else if (strcmp(szMan, "GenuineIntel") == 0) {
+ m_nType = PROCESSOR_INTEL;
+ } else {
+ m_nType = PROCESSOR_UNKNOWN;
+ }
+
+ // Get highest extended feature
+ __cpuid(nBuff, 0x80000000);
+ nHighestFeatureEx = (unsigned)nBuff[0];
+
+ // Get processor brand name
+ /*
+ if (nHighestFeatureEx >= 0x80000004)
+ {
+ char szCPUName[49];
+ szCPUName[0] = 0;
+ __cpuid((int*)&szCPUName[0], 0x80000002);
+ __cpuid((int*)&szCPUName[16], 0x80000003);
+ __cpuid((int*)&szCPUName[32], 0x80000004);
+ szCPUName[48] = 0;
+ for (int i = (int)strlen(szCPUName) - 1; i >= 0; --i)
+ {
+ if (szCPUName[i] == ' ')
+ szCPUName[i] = '\0';
+ else
+ break;
+ }
+
+ ELog::Get().SystemFormat(L"PERF : CPU: %S (%S)\n", szCPUName, szMan);
+ }
+ else
+ ELog::Get().SystemFormat(L"PERF : CPU: %S\n", szMan);
+ */
+
+ // Get CPU features
+ m_nCPUFeatures = 0;
+ //szFeatures[0] = 0;
+ if (nHighestFeature >= 1) {
+ __cpuid(nBuff, 1);
+ if (nBuff[3] & CPUID_MMX) { m_nCPUFeatures |= MPC_MM_MMX; }
+ if (nBuff[3] & CPUID_SSE) { m_nCPUFeatures |= MPC_MM_SSE; }
+ if (nBuff[3] & CPUID_SSE2) { m_nCPUFeatures |= MPC_MM_SSE2; }
+ if (nBuff[2] & CPUID_SSE3) { m_nCPUFeatures |= MPC_MM_SSE3; }
+
+ // Intel specific:
+ if (m_nType == PROCESSOR_INTEL) {
+ if (nBuff[2] & CPUID_SSSE3) { m_nCPUFeatures |= MPC_MM_SSSE3; }
+ //if (nBuff[2] & CPUID_EST) strcat(szFeatures, "EST ");
+ }
+
+ //if (nBuff[3] & CPUID_HTT)
+ // strcat(szFeatures, "HTT ");
+ }
+
+ // AMD specific:
+ if (m_nType == PROCESSOR_AMD) {
+ // Get extended features
+ __cpuid(nBuff, 0x80000000);
+ if (nHighestFeatureEx >= 0x80000001) {
+ __cpuid(nBuff, 0x80000001);
+ if (nBuff[3] & CPUID_3DNOW) { m_nCPUFeatures |= MPC_MM_3DNOW; }
+ //if (nBuff[3] & CPUID_3DNOWEXT) strcat(szFeatures, "Ex3DNow! ");
+ if (nBuff[3] & CPUID_MMXEXT) { m_nCPUFeatures |= MPC_MM_MMXEXT; }
+ }
+
+ // Get level 1 cache size
+ //if (nHighestFeatureEx >= 0x80000005)
+ //{
+ // __cpuid(nBuff, 0x80000005);
+ // ELog::Get().SystemFormat(L"PERF : L1 cache size: %dK\n", ((unsigned)nBuff[2])>>24);
+ //}
+ }
+
+ /*
+ // Get cache size
+ if (nHighestFeatureEx >= 0x80000006)
+ {
+ __cpuid(nBuff, 0x80000006);
+ ELog::Get().SystemFormat(L"PERF : L2 cache size: %dK\n", ((unsigned)nBuff[2])>>16);
+ }
+
+ // Log features
+ ELog::Get().SystemFormat(L"PERF : CPU Features: %S\n", szFeatures);
+
+ // Get misc system info
+ SYSTEM_INFO theInfo;
+ GetSystemInfo(&theInfo);
+
+ // Log number of CPUs and speeds
+ ELog::Get().SystemFormat(L"PERF : Number of CPUs: %d\n", theInfo.dwNumberOfProcessors);
+ for (DWORD i = 0; i < theInfo.dwNumberOfProcessors; ++i)
+ {
+ DWORD dwCPUSpeed = ReadCPUSpeedFromRegistry(i);
+ ELog::Get().SystemFormat(L"PERF : * CPU %d speed: ~%dMHz\n", i, dwCPUSpeed);
+ }
+ */
+
+ /*
+ unsigned nHighestFeature;
+ unsigned nHighestFeatureEx;
+
+ m_CPUInfo[0] = -1;
+ m_CPUInfoEx[0] = -1;
+ m_CPUAMDInfo[0] = -1;
+
+ __cpuid(m_CPUInfo, 0);
+ nHighestFeature = (unsigned)m_CPUInfo[0];
+
+ __cpuid(nBuff, 0x80000000);
+ nHighestFeatureEx = (unsigned)nBuff[0];
+
+ m_nDSPFlags = 0;
+ if (m_CPUInfo[3] & CPUID_MMX) m_nDSPFlags |= MPC_MM_MMX;
+ if (m_CPUInfo[3] & CPUID_SSE) m_nDSPFlags |= MPC_MM_SSE;
+ if (m_CPUInfo[3] & CPUID_SSE2) m_nDSPFlags |= MPC_MM_SSE2;
+ if (m_CPUInfo[2] & CPUID_SSE3) m_nDSPFlags |= MPC_MM_SSE3;
+
+ switch (m_nType)
+ {
+ case PROCESSOR_AMD :
+ __cpuid(m_CPUAMDInfo, 0x80000000);
+ if (nHighestFeatureEx >= 0x80000001)
+ {
+ if (m_CPUAMDInfo[3] & CPUID_MMXEXT) m_nDSPFlags |= MPC_MM_MMXEXT;
+ if (m_CPUAMDInfo[3] & CPUID_3DNOW) m_nDSPFlags |= MPC_MM_3DNOW;
+ }
+ break;
+ case PROCESSOR_INTEL :
+ if (m_CPUInfo[2] & CPUID_SSSE3) m_nDSPFlags |= MPC_MM_SSSE3;
+ break;
+ }
+ */
}
int CCpuId::GetProcessorNumber()
{
- SYSTEM_INFO SystemInfo;
- GetSystemInfo(&SystemInfo);
+ SYSTEM_INFO SystemInfo;
+ GetSystemInfo(&SystemInfo);
- return SystemInfo.dwNumberOfProcessors;
+ return SystemInfo.dwNumberOfProcessors;
}
diff --git a/src/filters/transform/MPCVideoDec/CpuId.h b/src/filters/transform/MPCVideoDec/CpuId.h
index dfc916cce..1c3e8a0c0 100644
--- a/src/filters/transform/MPCVideoDec/CpuId.h
+++ b/src/filters/transform/MPCVideoDec/CpuId.h
@@ -26,31 +26,31 @@ class CCpuId
{
public:
- typedef enum {
- PROCESSOR_AMD,
- PROCESSOR_INTEL,
- PROCESSOR_UNKNOWN
- } PROCESSOR_TYPE;
+ typedef enum {
+ PROCESSOR_AMD,
+ PROCESSOR_INTEL,
+ PROCESSOR_UNKNOWN
+ } PROCESSOR_TYPE;
- // Enum codes identicals to FFMpeg cpu features define !
- typedef enum {
- MPC_MM_MMX = 0x0001, /* standard MMX */
- MPC_MM_3DNOW = 0x0004, /* AMD 3DNOW */
- MPC_MM_MMXEXT = 0x0002, /* SSE integer functions or AMD MMX ext */
- MPC_MM_SSE = 0x0008, /* SSE functions */
- MPC_MM_SSE2 = 0x0010, /* PIV SSE2 functions */
- MPC_MM_3DNOWEXT = 0x0020, /* AMD 3DNowExt */
- MPC_MM_SSE3 = 0x0040, /* AMD64 & PIV SSE3 functions*/
- MPC_MM_SSSE3 = 0x0080 /* PIV Core 2 SSSE3 functions*/
- } PROCESSOR_FEATURES;
+ // Enum codes identicals to FFMpeg cpu features define !
+ typedef enum {
+ MPC_MM_MMX = 0x0001, /* standard MMX */
+ MPC_MM_3DNOW = 0x0004, /* AMD 3DNOW */
+ MPC_MM_MMXEXT = 0x0002, /* SSE integer functions or AMD MMX ext */
+ MPC_MM_SSE = 0x0008, /* SSE functions */
+ MPC_MM_SSE2 = 0x0010, /* PIV SSE2 functions */
+ MPC_MM_3DNOWEXT = 0x0020, /* AMD 3DNowExt */
+ MPC_MM_SSE3 = 0x0040, /* AMD64 & PIV SSE3 functions*/
+ MPC_MM_SSSE3 = 0x0080 /* PIV Core 2 SSSE3 functions*/
+ } PROCESSOR_FEATURES;
- CCpuId();
+ CCpuId();
- int GetFeatures() const {return m_nCPUFeatures;};
- PROCESSOR_TYPE GetType() const {return m_nType;};
- int GetProcessorNumber();
+ int GetFeatures() const {return m_nCPUFeatures;};
+ PROCESSOR_TYPE GetType() const {return m_nType;};
+ int GetProcessorNumber();
private:
- int m_nCPUFeatures;
- PROCESSOR_TYPE m_nType;
+ int m_nCPUFeatures;
+ PROCESSOR_TYPE m_nType;
};
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoder.cpp b/src/filters/transform/MPCVideoDec/DXVADecoder.cpp
index 9daac52d0..a16a991a9 100644
--- a/src/filters/transform/MPCVideoDec/DXVADecoder.cpp
+++ b/src/filters/transform/MPCVideoDec/DXVADecoder.cpp
@@ -40,702 +40,702 @@
nTry++; \
}
-CDXVADecoder::CDXVADecoder (CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber)
+CDXVADecoder::CDXVADecoder(CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber)
{
- m_nEngine = ENGINE_DXVA1;
- m_pAMVideoAccelerator = pAMVideoAccelerator;
- m_dwBufferIndex = 0;
- m_nMaxWaiting = 3;
+ m_nEngine = ENGINE_DXVA1;
+ m_pAMVideoAccelerator = pAMVideoAccelerator;
+ m_dwBufferIndex = 0;
+ m_nMaxWaiting = 3;
- Init (pFilter, nMode, nPicEntryNumber);
+ Init(pFilter, nMode, nPicEntryNumber);
}
-CDXVADecoder::CDXVADecoder (CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config)
+CDXVADecoder::CDXVADecoder(CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config)
{
- m_nEngine = ENGINE_DXVA2;
- m_pDirectXVideoDec = pDirectXVideoDec;
- memcpy (&m_DXVA2Config, pDXVA2Config, sizeof(DXVA2_ConfigPictureDecode));
+ m_nEngine = ENGINE_DXVA2;
+ m_pDirectXVideoDec = pDirectXVideoDec;
+ memcpy(&m_DXVA2Config, pDXVA2Config, sizeof(DXVA2_ConfigPictureDecode));
- Init (pFilter, nMode, nPicEntryNumber);
+ Init(pFilter, nMode, nPicEntryNumber);
};
CDXVADecoder::~CDXVADecoder()
{
- SAFE_DELETE_ARRAY (m_pPictureStore);
- SAFE_DELETE_ARRAY (m_ExecuteParams.pCompressedBuffers);
+ SAFE_DELETE_ARRAY(m_pPictureStore);
+ SAFE_DELETE_ARRAY(m_ExecuteParams.pCompressedBuffers);
}
void CDXVADecoder::Init(CMPCVideoDecFilter* pFilter, DXVAMode nMode, int nPicEntryNumber)
{
- m_pFilter = pFilter;
- m_nMode = nMode;
- m_nPicEntryNumber = nPicEntryNumber;
- m_pPictureStore = DNew PICTURE_STORE[nPicEntryNumber];
- m_dwNumBuffersInfo = 0;
- m_bNeedChangeAspect = true;
-
- memset (&m_DXVA1Config, 0, sizeof(m_DXVA1Config));
- memset (&m_DXVA1BufferDesc, 0, sizeof(m_DXVA1BufferDesc));
- m_DXVA1Config.guidConfigBitstreamEncryption = DXVA_NoEncrypt;
- m_DXVA1Config.guidConfigMBcontrolEncryption = DXVA_NoEncrypt;
- m_DXVA1Config.guidConfigResidDiffEncryption = DXVA_NoEncrypt;
- m_DXVA1Config.bConfigBitstreamRaw = 2;
-
- memset (&m_DXVA1BufferInfo, 0, sizeof(m_DXVA1BufferInfo));
- memset (&m_ExecuteParams, 0, sizeof(m_ExecuteParams));
- Flush();
+ m_pFilter = pFilter;
+ m_nMode = nMode;
+ m_nPicEntryNumber = nPicEntryNumber;
+ m_pPictureStore = DNew PICTURE_STORE[nPicEntryNumber];
+ m_dwNumBuffersInfo = 0;
+ m_bNeedChangeAspect = true;
+
+ memset(&m_DXVA1Config, 0, sizeof(m_DXVA1Config));
+ memset(&m_DXVA1BufferDesc, 0, sizeof(m_DXVA1BufferDesc));
+ m_DXVA1Config.guidConfigBitstreamEncryption = DXVA_NoEncrypt;
+ m_DXVA1Config.guidConfigMBcontrolEncryption = DXVA_NoEncrypt;
+ m_DXVA1Config.guidConfigResidDiffEncryption = DXVA_NoEncrypt;
+ m_DXVA1Config.bConfigBitstreamRaw = 2;
+
+ memset(&m_DXVA1BufferInfo, 0, sizeof(m_DXVA1BufferInfo));
+ memset(&m_ExecuteParams, 0, sizeof(m_ExecuteParams));
+ Flush();
}
// === Public functions
-void CDXVADecoder::AllocExecuteParams (int nSize)
+void CDXVADecoder::AllocExecuteParams(int nSize)
{
- m_ExecuteParams.pCompressedBuffers = DNew DXVA2_DecodeBufferDesc[nSize];
+ m_ExecuteParams.pCompressedBuffers = DNew DXVA2_DecodeBufferDesc[nSize];
- for (int i=0; i<nSize; i++) {
- memset (&m_ExecuteParams.pCompressedBuffers[i], 0, sizeof(DXVA2_DecodeBufferDesc));
- }
+ for (int i = 0; i < nSize; i++) {
+ memset(&m_ExecuteParams.pCompressedBuffers[i], 0, sizeof(DXVA2_DecodeBufferDesc));
+ }
}
-void CDXVADecoder::SetExtraData (BYTE* pDataIn, UINT nSize)
+void CDXVADecoder::SetExtraData(BYTE* pDataIn, UINT nSize)
{
- // Extradata is codec dependant
- UNREFERENCED_PARAMETER (pDataIn);
- UNREFERENCED_PARAMETER (nSize);
+ // Extradata is codec dependant
+ UNREFERENCED_PARAMETER(pDataIn);
+ UNREFERENCED_PARAMETER(nSize);
}
void CDXVADecoder::CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize)
{
- memcpy (pDXVABuffer, (BYTE*)pBuffer, nSize);
+ memcpy(pDXVABuffer, (BYTE*)pBuffer, nSize);
}
void CDXVADecoder::Flush()
{
- TRACE ("CDXVADecoder::Flush\n");
- for (int i=0; i<m_nPicEntryNumber; i++) {
- m_pPictureStore[i].bRefPicture = false;
- m_pPictureStore[i].bInUse = false;
- m_pPictureStore[i].bDisplayed = false;
- m_pPictureStore[i].pSample = NULL;
- m_pPictureStore[i].nCodecSpecific = -1;
- m_pPictureStore[i].dwDisplayCount = 0;
- }
-
- m_nWaitingPics = 0;
- m_bFlushed = true;
- m_nFieldSurface = -1;
- m_dwDisplayCount= 1;
- m_pFieldSample = NULL;
+ TRACE("CDXVADecoder::Flush\n");
+ for (int i = 0; i < m_nPicEntryNumber; i++) {
+ m_pPictureStore[i].bRefPicture = false;
+ m_pPictureStore[i].bInUse = false;
+ m_pPictureStore[i].bDisplayed = false;
+ m_pPictureStore[i].pSample = NULL;
+ m_pPictureStore[i].nCodecSpecific = -1;
+ m_pPictureStore[i].dwDisplayCount = 0;
+ }
+
+ m_nWaitingPics = 0;
+ m_bFlushed = true;
+ m_nFieldSurface = -1;
+ m_dwDisplayCount = 1;
+ m_pFieldSample = NULL;
}
HRESULT CDXVADecoder::ConfigureDXVA1()
{
- HRESULT hr = S_FALSE;
- DXVA_ConfigPictureDecode ConfigRequested;
-
- if (m_pAMVideoAccelerator) {
- memset (&ConfigRequested, 0, sizeof(ConfigRequested));
- ConfigRequested.guidConfigBitstreamEncryption = DXVA_NoEncrypt;
- ConfigRequested.guidConfigMBcontrolEncryption = DXVA_NoEncrypt;
- ConfigRequested.guidConfigResidDiffEncryption = DXVA_NoEncrypt;
- ConfigRequested.bConfigBitstreamRaw = 2;
-
- writeDXVA_QueryOrReplyFunc (&ConfigRequested.dwFunction, DXVA_QUERYORREPLYFUNCFLAG_DECODER_PROBE_QUERY, DXVA_PICTURE_DECODING_FUNCTION);
- hr = m_pAMVideoAccelerator->Execute (ConfigRequested.dwFunction, &ConfigRequested, sizeof(DXVA_ConfigPictureDecode), &m_DXVA1Config, sizeof(DXVA_ConfigPictureDecode), 0, NULL);
-
- // Copy to DXVA2 structure (simplify code based on accelerator config)
- m_DXVA2Config.guidConfigBitstreamEncryption = m_DXVA1Config.guidConfigBitstreamEncryption;
- m_DXVA2Config.guidConfigMBcontrolEncryption = m_DXVA1Config.guidConfigMBcontrolEncryption;
- m_DXVA2Config.guidConfigResidDiffEncryption = m_DXVA1Config.guidConfigResidDiffEncryption;
- m_DXVA2Config.ConfigBitstreamRaw = m_DXVA1Config.bConfigBitstreamRaw;
- m_DXVA2Config.ConfigMBcontrolRasterOrder = m_DXVA1Config.bConfigMBcontrolRasterOrder;
- m_DXVA2Config.ConfigResidDiffHost = m_DXVA1Config.bConfigResidDiffHost;
- m_DXVA2Config.ConfigSpatialResid8 = m_DXVA1Config.bConfigSpatialResid8;
- m_DXVA2Config.ConfigResid8Subtraction = m_DXVA1Config.bConfigResid8Subtraction;
- m_DXVA2Config.ConfigSpatialHost8or9Clipping = m_DXVA1Config.bConfigSpatialHost8or9Clipping;
- m_DXVA2Config.ConfigSpatialResidInterleaved = m_DXVA1Config.bConfigSpatialResidInterleaved;
- m_DXVA2Config.ConfigIntraResidUnsigned = m_DXVA1Config.bConfigIntraResidUnsigned;
- m_DXVA2Config.ConfigResidDiffAccelerator = m_DXVA1Config.bConfigResidDiffAccelerator;
- m_DXVA2Config.ConfigHostInverseScan = m_DXVA1Config.bConfigHostInverseScan;
- m_DXVA2Config.ConfigSpecificIDCT = m_DXVA1Config.bConfigSpecificIDCT;
- m_DXVA2Config.Config4GroupedCoefs = m_DXVA1Config.bConfig4GroupedCoefs;
-
- if (SUCCEEDED (hr)) {
- writeDXVA_QueryOrReplyFunc (&m_DXVA1Config.dwFunction, DXVA_QUERYORREPLYFUNCFLAG_DECODER_LOCK_QUERY, DXVA_PICTURE_DECODING_FUNCTION);
- hr = m_pAMVideoAccelerator->Execute (m_DXVA1Config.dwFunction, &m_DXVA1Config, sizeof(DXVA_ConfigPictureDecode), &ConfigRequested, sizeof(DXVA_ConfigPictureDecode), 0, NULL);
-
- // TODO : check config!
- // ASSERT (ConfigRequested.bConfigBitstreamRaw == 2);
-
- AMVAUncompDataInfo DataInfo;
- DWORD dwNum = COMP_BUFFER_COUNT;
- DataInfo.dwUncompWidth = m_pFilter->PictWidthRounded();
- DataInfo.dwUncompHeight = m_pFilter->PictHeightRounded();
- memcpy (&DataInfo.ddUncompPixelFormat, m_pFilter->GetPixelFormat(), sizeof (DDPIXELFORMAT));
- hr = m_pAMVideoAccelerator->GetCompBufferInfo (m_pFilter->GetDXVADecoderGuid(), &DataInfo, &dwNum, m_ComBufferInfo);
- }
- }
- return hr;
+ HRESULT hr = S_FALSE;
+ DXVA_ConfigPictureDecode ConfigRequested;
+
+ if (m_pAMVideoAccelerator) {
+ memset(&ConfigRequested, 0, sizeof(ConfigRequested));
+ ConfigRequested.guidConfigBitstreamEncryption = DXVA_NoEncrypt;
+ ConfigRequested.guidConfigMBcontrolEncryption = DXVA_NoEncrypt;
+ ConfigRequested.guidConfigResidDiffEncryption = DXVA_NoEncrypt;
+ ConfigRequested.bConfigBitstreamRaw = 2;
+
+ writeDXVA_QueryOrReplyFunc(&ConfigRequested.dwFunction, DXVA_QUERYORREPLYFUNCFLAG_DECODER_PROBE_QUERY, DXVA_PICTURE_DECODING_FUNCTION);
+ hr = m_pAMVideoAccelerator->Execute(ConfigRequested.dwFunction, &ConfigRequested, sizeof(DXVA_ConfigPictureDecode), &m_DXVA1Config, sizeof(DXVA_ConfigPictureDecode), 0, NULL);
+
+ // Copy to DXVA2 structure (simplify code based on accelerator config)
+ m_DXVA2Config.guidConfigBitstreamEncryption = m_DXVA1Config.guidConfigBitstreamEncryption;
+ m_DXVA2Config.guidConfigMBcontrolEncryption = m_DXVA1Config.guidConfigMBcontrolEncryption;
+ m_DXVA2Config.guidConfigResidDiffEncryption = m_DXVA1Config.guidConfigResidDiffEncryption;
+ m_DXVA2Config.ConfigBitstreamRaw = m_DXVA1Config.bConfigBitstreamRaw;
+ m_DXVA2Config.ConfigMBcontrolRasterOrder = m_DXVA1Config.bConfigMBcontrolRasterOrder;
+ m_DXVA2Config.ConfigResidDiffHost = m_DXVA1Config.bConfigResidDiffHost;
+ m_DXVA2Config.ConfigSpatialResid8 = m_DXVA1Config.bConfigSpatialResid8;
+ m_DXVA2Config.ConfigResid8Subtraction = m_DXVA1Config.bConfigResid8Subtraction;
+ m_DXVA2Config.ConfigSpatialHost8or9Clipping = m_DXVA1Config.bConfigSpatialHost8or9Clipping;
+ m_DXVA2Config.ConfigSpatialResidInterleaved = m_DXVA1Config.bConfigSpatialResidInterleaved;
+ m_DXVA2Config.ConfigIntraResidUnsigned = m_DXVA1Config.bConfigIntraResidUnsigned;
+ m_DXVA2Config.ConfigResidDiffAccelerator = m_DXVA1Config.bConfigResidDiffAccelerator;
+ m_DXVA2Config.ConfigHostInverseScan = m_DXVA1Config.bConfigHostInverseScan;
+ m_DXVA2Config.ConfigSpecificIDCT = m_DXVA1Config.bConfigSpecificIDCT;
+ m_DXVA2Config.Config4GroupedCoefs = m_DXVA1Config.bConfig4GroupedCoefs;
+
+ if (SUCCEEDED(hr)) {
+ writeDXVA_QueryOrReplyFunc(&m_DXVA1Config.dwFunction, DXVA_QUERYORREPLYFUNCFLAG_DECODER_LOCK_QUERY, DXVA_PICTURE_DECODING_FUNCTION);
+ hr = m_pAMVideoAccelerator->Execute(m_DXVA1Config.dwFunction, &m_DXVA1Config, sizeof(DXVA_ConfigPictureDecode), &ConfigRequested, sizeof(DXVA_ConfigPictureDecode), 0, NULL);
+
+ // TODO : check config!
+ // ASSERT (ConfigRequested.bConfigBitstreamRaw == 2);
+
+ AMVAUncompDataInfo DataInfo;
+ DWORD dwNum = COMP_BUFFER_COUNT;
+ DataInfo.dwUncompWidth = m_pFilter->PictWidthRounded();
+ DataInfo.dwUncompHeight = m_pFilter->PictHeightRounded();
+ memcpy(&DataInfo.ddUncompPixelFormat, m_pFilter->GetPixelFormat(), sizeof(DDPIXELFORMAT));
+ hr = m_pAMVideoAccelerator->GetCompBufferInfo(m_pFilter->GetDXVADecoderGuid(), &DataInfo, &dwNum, m_ComBufferInfo);
+ }
+ }
+ return hr;
}
-CDXVADecoder* CDXVADecoder::CreateDecoder (CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, const GUID* guidDecoder, int nPicEntryNumber)
+CDXVADecoder* CDXVADecoder::CreateDecoder(CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, const GUID* guidDecoder, int nPicEntryNumber)
{
- CDXVADecoder* pDecoder = NULL;
-
- if ((*guidDecoder == DXVA2_ModeH264_E) || (*guidDecoder == DXVA2_ModeH264_F) || (*guidDecoder == DXVA_Intel_H264_ClearVideo)) {
- pDecoder = DNew CDXVADecoderH264 (pFilter, pAMVideoAccelerator, H264_VLD, nPicEntryNumber);
- } else if (*guidDecoder == DXVA2_ModeVC1_D) {
- pDecoder = DNew CDXVADecoderVC1 (pFilter, pAMVideoAccelerator, VC1_VLD, nPicEntryNumber);
- } else if (*guidDecoder == DXVA2_ModeMPEG2_VLD) {
- pDecoder = DNew CDXVADecoderMpeg2 (pFilter, pAMVideoAccelerator, MPEG2_VLD, nPicEntryNumber);
- } else {
- ASSERT (FALSE); // Unknown decoder !!
- }
-
- return pDecoder;
+ CDXVADecoder* pDecoder = NULL;
+
+ if ((*guidDecoder == DXVA2_ModeH264_E) || (*guidDecoder == DXVA2_ModeH264_F) || (*guidDecoder == DXVA_Intel_H264_ClearVideo)) {
+ pDecoder = DNew CDXVADecoderH264(pFilter, pAMVideoAccelerator, H264_VLD, nPicEntryNumber);
+ } else if (*guidDecoder == DXVA2_ModeVC1_D) {
+ pDecoder = DNew CDXVADecoderVC1(pFilter, pAMVideoAccelerator, VC1_VLD, nPicEntryNumber);
+ } else if (*guidDecoder == DXVA2_ModeMPEG2_VLD) {
+ pDecoder = DNew CDXVADecoderMpeg2(pFilter, pAMVideoAccelerator, MPEG2_VLD, nPicEntryNumber);
+ } else {
+ ASSERT(FALSE); // Unknown decoder !!
+ }
+
+ return pDecoder;
}
-CDXVADecoder* CDXVADecoder::CreateDecoder (CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, const GUID* guidDecoder, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config)
+CDXVADecoder* CDXVADecoder::CreateDecoder(CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, const GUID* guidDecoder, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config)
{
- CDXVADecoder* pDecoder = NULL;
-
- if ((*guidDecoder == DXVA2_ModeH264_E) || (*guidDecoder == DXVA2_ModeH264_F) || (*guidDecoder == DXVA_Intel_H264_ClearVideo)) {
- pDecoder = DNew CDXVADecoderH264 (pFilter, pDirectXVideoDec, H264_VLD, nPicEntryNumber, pDXVA2Config);
- } else if (*guidDecoder == DXVA2_ModeVC1_D) {
- pDecoder = DNew CDXVADecoderVC1 (pFilter, pDirectXVideoDec, VC1_VLD, nPicEntryNumber, pDXVA2Config);
- } else if (*guidDecoder == DXVA2_ModeMPEG2_VLD) {
- pDecoder = DNew CDXVADecoderMpeg2 (pFilter, pDirectXVideoDec, MPEG2_VLD, nPicEntryNumber, pDXVA2Config);
- } else {
- ASSERT (FALSE); // Unknown decoder !!
- }
-
- return pDecoder;
+ CDXVADecoder* pDecoder = NULL;
+
+ if ((*guidDecoder == DXVA2_ModeH264_E) || (*guidDecoder == DXVA2_ModeH264_F) || (*guidDecoder == DXVA_Intel_H264_ClearVideo)) {
+ pDecoder = DNew CDXVADecoderH264(pFilter, pDirectXVideoDec, H264_VLD, nPicEntryNumber, pDXVA2Config);
+ } else if (*guidDecoder == DXVA2_ModeVC1_D) {
+ pDecoder = DNew CDXVADecoderVC1(pFilter, pDirectXVideoDec, VC1_VLD, nPicEntryNumber, pDXVA2Config);
+ } else if (*guidDecoder == DXVA2_ModeMPEG2_VLD) {
+ pDecoder = DNew CDXVADecoderMpeg2(pFilter, pDirectXVideoDec, MPEG2_VLD, nPicEntryNumber, pDXVA2Config);
+ } else {
+ ASSERT(FALSE); // Unknown decoder !!
+ }
+
+ return pDecoder;
}
// === DXVA functions
-HRESULT CDXVADecoder::AddExecuteBuffer (DWORD CompressedBufferType, UINT nSize, void* pBuffer, UINT* pRealSize)
+HRESULT CDXVADecoder::AddExecuteBuffer(DWORD CompressedBufferType, UINT nSize, void* pBuffer, UINT* pRealSize)
{
- HRESULT hr = E_INVALIDARG;
- DWORD dwNumMBs = 0;
- BYTE* pDXVABuffer;
-
- //if (CompressedBufferType != DXVA2_PictureParametersBufferType && CompressedBufferType != DXVA2_InverseQuantizationMatrixBufferType)
- // dwNumMBs = FFGetMBNumber (m_pFilter->GetAVCtx());
-
- switch (m_nEngine) {
- case ENGINE_DXVA1 :
- DWORD dwTypeIndex;
- LONG lStride;
- dwTypeIndex = GetDXVA1CompressedType (CompressedBufferType);
-
- // TRACE ("Fill : %d - %d\n", dwTypeIndex, m_dwBufferIndex);
- hr = m_pAMVideoAccelerator->GetBuffer(dwTypeIndex, m_dwBufferIndex, FALSE, (void**)&pDXVABuffer, &lStride);
- ASSERT (SUCCEEDED (hr));
-
- if (SUCCEEDED (hr)) {
- if (CompressedBufferType == DXVA2_BitStreamDateBufferType) {
- CopyBitstream (pDXVABuffer, (BYTE*)pBuffer, nSize);
- } else {
- memcpy (pDXVABuffer, (BYTE*)pBuffer, nSize);
- }
- m_DXVA1BufferInfo[m_dwNumBuffersInfo].dwTypeIndex = dwTypeIndex;
- m_DXVA1BufferInfo[m_dwNumBuffersInfo].dwBufferIndex = m_dwBufferIndex;
- m_DXVA1BufferInfo[m_dwNumBuffersInfo].dwDataSize = nSize;
-
- m_DXVA1BufferDesc[m_dwNumBuffersInfo].dwTypeIndex = dwTypeIndex;
- m_DXVA1BufferDesc[m_dwNumBuffersInfo].dwBufferIndex = m_dwBufferIndex;
- m_DXVA1BufferDesc[m_dwNumBuffersInfo].dwDataSize = nSize;
- m_DXVA1BufferDesc[m_dwNumBuffersInfo].dwNumMBsInBuffer = dwNumMBs;
-
- m_dwNumBuffersInfo++;
- }
- break;
-
- case ENGINE_DXVA2 :
- UINT nDXVASize;
- hr = m_pDirectXVideoDec->GetBuffer (CompressedBufferType, (void**)&pDXVABuffer, &nDXVASize);
- ASSERT (nSize <= nDXVASize);
-
- if (SUCCEEDED (hr) && (nSize <= nDXVASize)) {
- if (CompressedBufferType == DXVA2_BitStreamDateBufferType) {
- CopyBitstream (pDXVABuffer, (BYTE*)pBuffer, nSize);
- } else {
- memcpy (pDXVABuffer, (BYTE*)pBuffer, nSize);
- }
-
- m_ExecuteParams.pCompressedBuffers[m_ExecuteParams.NumCompBuffers].CompressedBufferType = CompressedBufferType;
- m_ExecuteParams.pCompressedBuffers[m_ExecuteParams.NumCompBuffers].DataSize = nSize;
- m_ExecuteParams.pCompressedBuffers[m_ExecuteParams.NumCompBuffers].NumMBsInBuffer = dwNumMBs;
- m_ExecuteParams.NumCompBuffers++;
-
- }
- break;
- default :
- ASSERT (FALSE);
- break;
- }
- if (pRealSize) {
- *pRealSize = nSize;
- }
-
- return hr;
+ HRESULT hr = E_INVALIDARG;
+ DWORD dwNumMBs = 0;
+ BYTE* pDXVABuffer;
+
+ //if (CompressedBufferType != DXVA2_PictureParametersBufferType && CompressedBufferType != DXVA2_InverseQuantizationMatrixBufferType)
+ // dwNumMBs = FFGetMBNumber (m_pFilter->GetAVCtx());
+
+ switch (m_nEngine) {
+ case ENGINE_DXVA1 :
+ DWORD dwTypeIndex;
+ LONG lStride;
+ dwTypeIndex = GetDXVA1CompressedType(CompressedBufferType);
+
+ // TRACE ("Fill : %d - %d\n", dwTypeIndex, m_dwBufferIndex);
+ hr = m_pAMVideoAccelerator->GetBuffer(dwTypeIndex, m_dwBufferIndex, FALSE, (void**)&pDXVABuffer, &lStride);
+ ASSERT(SUCCEEDED(hr));
+
+ if (SUCCEEDED(hr)) {
+ if (CompressedBufferType == DXVA2_BitStreamDateBufferType) {
+ CopyBitstream(pDXVABuffer, (BYTE*)pBuffer, nSize);
+ } else {
+ memcpy(pDXVABuffer, (BYTE*)pBuffer, nSize);
+ }
+ m_DXVA1BufferInfo[m_dwNumBuffersInfo].dwTypeIndex = dwTypeIndex;
+ m_DXVA1BufferInfo[m_dwNumBuffersInfo].dwBufferIndex = m_dwBufferIndex;
+ m_DXVA1BufferInfo[m_dwNumBuffersInfo].dwDataSize = nSize;
+
+ m_DXVA1BufferDesc[m_dwNumBuffersInfo].dwTypeIndex = dwTypeIndex;
+ m_DXVA1BufferDesc[m_dwNumBuffersInfo].dwBufferIndex = m_dwBufferIndex;
+ m_DXVA1BufferDesc[m_dwNumBuffersInfo].dwDataSize = nSize;
+ m_DXVA1BufferDesc[m_dwNumBuffersInfo].dwNumMBsInBuffer = dwNumMBs;
+
+ m_dwNumBuffersInfo++;
+ }
+ break;
+
+ case ENGINE_DXVA2 :
+ UINT nDXVASize;
+ hr = m_pDirectXVideoDec->GetBuffer(CompressedBufferType, (void**)&pDXVABuffer, &nDXVASize);
+ ASSERT(nSize <= nDXVASize);
+
+ if (SUCCEEDED(hr) && (nSize <= nDXVASize)) {
+ if (CompressedBufferType == DXVA2_BitStreamDateBufferType) {
+ CopyBitstream(pDXVABuffer, (BYTE*)pBuffer, nSize);
+ } else {
+ memcpy(pDXVABuffer, (BYTE*)pBuffer, nSize);
+ }
+
+ m_ExecuteParams.pCompressedBuffers[m_ExecuteParams.NumCompBuffers].CompressedBufferType = CompressedBufferType;
+ m_ExecuteParams.pCompressedBuffers[m_ExecuteParams.NumCompBuffers].DataSize = nSize;
+ m_ExecuteParams.pCompressedBuffers[m_ExecuteParams.NumCompBuffers].NumMBsInBuffer = dwNumMBs;
+ m_ExecuteParams.NumCompBuffers++;
+
+ }
+ break;
+ default :
+ ASSERT(FALSE);
+ break;
+ }
+ if (pRealSize) {
+ *pRealSize = nSize;
+ }
+
+ return hr;
}
HRESULT CDXVADecoder::GetDeliveryBuffer(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, IMediaSample** ppSampleToDeliver)
{
- HRESULT hr;
- CComPtr<IMediaSample> pNewSample;
-
- // Change aspect ratio for DXVA2
- if (m_nEngine == ENGINE_DXVA2) {
- if (m_bNeedChangeAspect) {
- m_pFilter->UpdateAspectRatio();
- m_pFilter->ReconnectOutput(m_pFilter->PictWidthRounded(), m_pFilter->PictHeightRounded(), true, m_pFilter->PictWidth(), m_pFilter->PictHeight());
- }
- }
- hr = m_pFilter->GetOutputPin()->GetDeliveryBuffer(&pNewSample, 0, 0, 0);
-
- if (SUCCEEDED (hr)) {
- pNewSample->SetTime(&rtStart, &rtStop);
- pNewSample->SetMediaTime(NULL, NULL);
- *ppSampleToDeliver = pNewSample.Detach();
- }
- return hr;
+ HRESULT hr;
+ CComPtr<IMediaSample> pNewSample;
+
+ // Change aspect ratio for DXVA2
+ if (m_nEngine == ENGINE_DXVA2) {
+ if (m_bNeedChangeAspect) {
+ m_pFilter->UpdateAspectRatio();
+ m_pFilter->ReconnectOutput(m_pFilter->PictWidthRounded(), m_pFilter->PictHeightRounded(), true, m_pFilter->PictWidth(), m_pFilter->PictHeight());
+ }
+ }
+ hr = m_pFilter->GetOutputPin()->GetDeliveryBuffer(&pNewSample, 0, 0, 0);
+
+ if (SUCCEEDED(hr)) {
+ pNewSample->SetTime(&rtStart, &rtStop);
+ pNewSample->SetMediaTime(NULL, NULL);
+ *ppSampleToDeliver = pNewSample.Detach();
+ }
+ return hr;
}
HRESULT CDXVADecoder::Execute()
{
- HRESULT hr = E_INVALIDARG;
-
- switch (m_nEngine) {
- case ENGINE_DXVA1 :
- DWORD dwFunction;
- HRESULT hr2;
-
- // writeDXVA_QueryOrReplyFunc (&dwFunction, DXVA_QUERYORREPLYFUNCFLAG_DECODER_LOCK_QUERY, DXVA_PICTURE_DECODING_FUNCTION);
- // hr = m_pAMVideoAccelerator->Execute (dwFunction, &m_DXVA1Config, sizeof(DXVA_ConfigPictureDecode), NULL, 0, m_dwNumBuffersInfo, m_DXVA1BufferInfo);
-
- DWORD dwResult;
- dwFunction = 0x01000000;
- hr = m_pAMVideoAccelerator->Execute (dwFunction, m_DXVA1BufferDesc, sizeof(DXVA_BufferDescription)*m_dwNumBuffersInfo,&dwResult, sizeof(dwResult), m_dwNumBuffersInfo, m_DXVA1BufferInfo);
- ASSERT (SUCCEEDED (hr));
-
- for (DWORD i=0; i<m_dwNumBuffersInfo; i++) {
- hr2 = m_pAMVideoAccelerator->ReleaseBuffer (m_DXVA1BufferInfo[i].dwTypeIndex, m_DXVA1BufferInfo[i].dwBufferIndex);
- ASSERT (SUCCEEDED (hr2));
- }
-
- m_dwNumBuffersInfo = 0;
- break;
- case ENGINE_DXVA2 :
-
- for (DWORD i=0; i<m_ExecuteParams.NumCompBuffers; i++) {
- hr2 = m_pDirectXVideoDec->ReleaseBuffer (m_ExecuteParams.pCompressedBuffers[i].CompressedBufferType);
- ASSERT (SUCCEEDED (hr2));
- }
-
- hr = m_pDirectXVideoDec->Execute(&m_ExecuteParams);
- m_ExecuteParams.NumCompBuffers = 0;
- break;
- default :
- ASSERT (FALSE);
- break;
- }
-
- return hr;
+ HRESULT hr = E_INVALIDARG;
+
+ switch (m_nEngine) {
+ case ENGINE_DXVA1 :
+ DWORD dwFunction;
+ HRESULT hr2;
+
+ // writeDXVA_QueryOrReplyFunc (&dwFunction, DXVA_QUERYORREPLYFUNCFLAG_DECODER_LOCK_QUERY, DXVA_PICTURE_DECODING_FUNCTION);
+ // hr = m_pAMVideoAccelerator->Execute (dwFunction, &m_DXVA1Config, sizeof(DXVA_ConfigPictureDecode), NULL, 0, m_dwNumBuffersInfo, m_DXVA1BufferInfo);
+
+ DWORD dwResult;
+ dwFunction = 0x01000000;
+ hr = m_pAMVideoAccelerator->Execute(dwFunction, m_DXVA1BufferDesc, sizeof(DXVA_BufferDescription) * m_dwNumBuffersInfo, &dwResult, sizeof(dwResult), m_dwNumBuffersInfo, m_DXVA1BufferInfo);
+ ASSERT(SUCCEEDED(hr));
+
+ for (DWORD i = 0; i < m_dwNumBuffersInfo; i++) {
+ hr2 = m_pAMVideoAccelerator->ReleaseBuffer(m_DXVA1BufferInfo[i].dwTypeIndex, m_DXVA1BufferInfo[i].dwBufferIndex);
+ ASSERT(SUCCEEDED(hr2));
+ }
+
+ m_dwNumBuffersInfo = 0;
+ break;
+ case ENGINE_DXVA2 :
+
+ for (DWORD i = 0; i < m_ExecuteParams.NumCompBuffers; i++) {
+ hr2 = m_pDirectXVideoDec->ReleaseBuffer(m_ExecuteParams.pCompressedBuffers[i].CompressedBufferType);
+ ASSERT(SUCCEEDED(hr2));
+ }
+
+ hr = m_pDirectXVideoDec->Execute(&m_ExecuteParams);
+ m_ExecuteParams.NumCompBuffers = 0;
+ break;
+ default :
+ ASSERT(FALSE);
+ break;
+ }
+
+ return hr;
}
HRESULT CDXVADecoder::QueryStatus(PVOID LPDXVAStatus, UINT nSize)
{
- HRESULT hr = E_INVALIDARG;
- DXVA2_DecodeExecuteParams ExecuteParams;
- DXVA2_DecodeExtensionData ExtensionData;
- DWORD dwFunction = 0x07000000;
-
- switch (m_nEngine) {
- case ENGINE_DXVA1 :
- hr = m_pAMVideoAccelerator->Execute (dwFunction, NULL, 0, LPDXVAStatus, nSize, 0, NULL);
- break;
-
- case ENGINE_DXVA2 :
- memset (&ExecuteParams, 0, sizeof(ExecuteParams));
- memset (&ExtensionData, 0, sizeof(ExtensionData));
- ExecuteParams.pExtensionData = &ExtensionData;
- ExtensionData.pPrivateOutputData = LPDXVAStatus;
- ExtensionData.PrivateOutputDataSize = nSize;
- ExtensionData.Function = 7;
- hr = m_pDirectXVideoDec->Execute(&ExecuteParams);
- break;
- default :
- ASSERT (FALSE);
- break;
- }
-
- return hr;
+ HRESULT hr = E_INVALIDARG;
+ DXVA2_DecodeExecuteParams ExecuteParams;
+ DXVA2_DecodeExtensionData ExtensionData;
+ DWORD dwFunction = 0x07000000;
+
+ switch (m_nEngine) {
+ case ENGINE_DXVA1 :
+ hr = m_pAMVideoAccelerator->Execute(dwFunction, NULL, 0, LPDXVAStatus, nSize, 0, NULL);
+ break;
+
+ case ENGINE_DXVA2 :
+ memset(&ExecuteParams, 0, sizeof(ExecuteParams));
+ memset(&ExtensionData, 0, sizeof(ExtensionData));
+ ExecuteParams.pExtensionData = &ExtensionData;
+ ExtensionData.pPrivateOutputData = LPDXVAStatus;
+ ExtensionData.PrivateOutputDataSize = nSize;
+ ExtensionData.Function = 7;
+ hr = m_pDirectXVideoDec->Execute(&ExecuteParams);
+ break;
+ default :
+ ASSERT(FALSE);
+ break;
+ }
+
+ return hr;
}
-DWORD CDXVADecoder::GetDXVA1CompressedType (DWORD dwDXVA2CompressedType)
+DWORD CDXVADecoder::GetDXVA1CompressedType(DWORD dwDXVA2CompressedType)
{
- if (dwDXVA2CompressedType <= DXVA2_BitStreamDateBufferType) {
- return dwDXVA2CompressedType + 1;
- } else {
- switch (dwDXVA2CompressedType) {
- case DXVA2_MotionVectorBuffer :
- return DXVA_MOTION_VECTOR_BUFFER;
- break;
- case DXVA2_FilmGrainBuffer :
- return DXVA_FILM_GRAIN_BUFFER;
- break;
- default :
- ASSERT (FALSE);
- return DXVA_COMPBUFFER_TYPE_THAT_IS_NOT_USED;
- }
- }
+ if (dwDXVA2CompressedType <= DXVA2_BitStreamDateBufferType) {
+ return dwDXVA2CompressedType + 1;
+ } else {
+ switch (dwDXVA2CompressedType) {
+ case DXVA2_MotionVectorBuffer :
+ return DXVA_MOTION_VECTOR_BUFFER;
+ break;
+ case DXVA2_FilmGrainBuffer :
+ return DXVA_FILM_GRAIN_BUFFER;
+ break;
+ default :
+ ASSERT(FALSE);
+ return DXVA_COMPBUFFER_TYPE_THAT_IS_NOT_USED;
+ }
+ }
}
HRESULT CDXVADecoder::FindFreeDXVA1Buffer(DWORD dwTypeIndex, DWORD& dwBufferIndex)
{
- HRESULT hr = E_INVALIDARG;
- int nTry = 0;
+ HRESULT hr = E_INVALIDARG;
+ int nTry = 0;
- dwBufferIndex = 0; //(dwBufferIndex + 1) % m_ComBufferInfo[DXVA_PICTURE_DECODE_BUFFER].dwNumCompBuffers;
- DO_DXVA_PENDING_LOOP (m_pAMVideoAccelerator->QueryRenderStatus ((DWORD)-1, dwBufferIndex, 0));
+ dwBufferIndex = 0; //(dwBufferIndex + 1) % m_ComBufferInfo[DXVA_PICTURE_DECODE_BUFFER].dwNumCompBuffers;
+ DO_DXVA_PENDING_LOOP(m_pAMVideoAccelerator->QueryRenderStatus((DWORD) - 1, dwBufferIndex, 0));
- return hr;
+ return hr;
}
HRESULT CDXVADecoder::BeginFrame(int nSurfaceIndex, IMediaSample* pSampleToDeliver)
{
- HRESULT hr = E_INVALIDARG;
- int nTry = 0;
-
- for (int i=0; i<20; i++) {
- switch (m_nEngine) {
- case ENGINE_DXVA1 :
- AMVABeginFrameInfo BeginFrameInfo;
-
- BeginFrameInfo.dwDestSurfaceIndex = nSurfaceIndex;
- BeginFrameInfo.dwSizeInputData = sizeof(nSurfaceIndex);
- BeginFrameInfo.pInputData = &nSurfaceIndex;
- BeginFrameInfo.dwSizeOutputData = 0;
- BeginFrameInfo.pOutputData = NULL;
-
- DO_DXVA_PENDING_LOOP (m_pAMVideoAccelerator->BeginFrame(&BeginFrameInfo));
-
- ASSERT (SUCCEEDED (hr));
- if (SUCCEEDED (hr)) {
- hr = FindFreeDXVA1Buffer ((DWORD)-1, m_dwBufferIndex);
- }
- break;
-
- case ENGINE_DXVA2 : {
- CComQIPtr<IMFGetService> pSampleService;
- CComPtr<IDirect3DSurface9> pDecoderRenderTarget;
- pSampleService = pSampleToDeliver;
- if (pSampleService) {
- hr = pSampleService->GetService (MR_BUFFER_SERVICE, __uuidof(IDirect3DSurface9), (void**) &pDecoderRenderTarget);
- if (SUCCEEDED (hr)) {
- DO_DXVA_PENDING_LOOP (m_pDirectXVideoDec->BeginFrame(pDecoderRenderTarget, NULL));
- }
- }
- }
- break;
- default :
- ASSERT (FALSE);
- break;
- }
-
- // For slow accelerator wait a little...
- if (SUCCEEDED (hr)) {
- break;
- }
- Sleep(1);
- }
-
- return hr;
+ HRESULT hr = E_INVALIDARG;
+ int nTry = 0;
+
+ for (int i = 0; i < 20; i++) {
+ switch (m_nEngine) {
+ case ENGINE_DXVA1 :
+ AMVABeginFrameInfo BeginFrameInfo;
+
+ BeginFrameInfo.dwDestSurfaceIndex = nSurfaceIndex;
+ BeginFrameInfo.dwSizeInputData = sizeof(nSurfaceIndex);
+ BeginFrameInfo.pInputData = &nSurfaceIndex;
+ BeginFrameInfo.dwSizeOutputData = 0;
+ BeginFrameInfo.pOutputData = NULL;
+
+ DO_DXVA_PENDING_LOOP(m_pAMVideoAccelerator->BeginFrame(&BeginFrameInfo));
+
+ ASSERT(SUCCEEDED(hr));
+ if (SUCCEEDED(hr)) {
+ hr = FindFreeDXVA1Buffer((DWORD) - 1, m_dwBufferIndex);
+ }
+ break;
+
+ case ENGINE_DXVA2 : {
+ CComQIPtr<IMFGetService> pSampleService;
+ CComPtr<IDirect3DSurface9> pDecoderRenderTarget;
+ pSampleService = pSampleToDeliver;
+ if (pSampleService) {
+ hr = pSampleService->GetService(MR_BUFFER_SERVICE, __uuidof(IDirect3DSurface9), (void**) &pDecoderRenderTarget);
+ if (SUCCEEDED(hr)) {
+ DO_DXVA_PENDING_LOOP(m_pDirectXVideoDec->BeginFrame(pDecoderRenderTarget, NULL));
+ }
+ }
+ }
+ break;
+ default :
+ ASSERT(FALSE);
+ break;
+ }
+
+ // For slow accelerator wait a little...
+ if (SUCCEEDED(hr)) {
+ break;
+ }
+ Sleep(1);
+ }
+
+ return hr;
}
HRESULT CDXVADecoder::EndFrame(int nSurfaceIndex)
{
- HRESULT hr = E_INVALIDARG;
- DWORD dwDummy = nSurfaceIndex;
-
- switch (m_nEngine) {
- case ENGINE_DXVA1 :
- AMVAEndFrameInfo EndFrameInfo;
-
- EndFrameInfo.dwSizeMiscData = sizeof (dwDummy); // TODO : usefull ??
- EndFrameInfo.pMiscData = &dwDummy;
- hr = m_pAMVideoAccelerator->EndFrame(&EndFrameInfo);
- ASSERT (SUCCEEDED (hr));
- break;
-
- case ENGINE_DXVA2 :
- hr = m_pDirectXVideoDec->EndFrame(NULL);
- break;
- default :
- ASSERT (FALSE);
- break;
- }
-
- return hr;
+ HRESULT hr = E_INVALIDARG;
+ DWORD dwDummy = nSurfaceIndex;
+
+ switch (m_nEngine) {
+ case ENGINE_DXVA1 :
+ AMVAEndFrameInfo EndFrameInfo;
+
+ EndFrameInfo.dwSizeMiscData = sizeof(dwDummy); // TODO : usefull ??
+ EndFrameInfo.pMiscData = &dwDummy;
+ hr = m_pAMVideoAccelerator->EndFrame(&EndFrameInfo);
+ ASSERT(SUCCEEDED(hr));
+ break;
+
+ case ENGINE_DXVA2 :
+ hr = m_pDirectXVideoDec->EndFrame(NULL);
+ break;
+ default :
+ ASSERT(FALSE);
+ break;
+ }
+
+ return hr;
}
// === Picture store functions
-bool CDXVADecoder::AddToStore (int nSurfaceIndex, IMediaSample* pSample, bool bRefPicture,
- REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, bool bIsField,
- FF_FIELD_TYPE nFieldType, FF_SLICE_TYPE nSliceType, int nCodecSpecific)
+bool CDXVADecoder::AddToStore(int nSurfaceIndex, IMediaSample* pSample, bool bRefPicture,
+ REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, bool bIsField,
+ FF_FIELD_TYPE nFieldType, FF_SLICE_TYPE nSliceType, int nCodecSpecific)
{
- if (bIsField && (m_nFieldSurface == -1)) {
- m_nFieldSurface = nSurfaceIndex;
- m_pFieldSample = pSample;
- m_pPictureStore[nSurfaceIndex].n1FieldType = nFieldType;
- m_pPictureStore[nSurfaceIndex].rtStart = rtStart;
- m_pPictureStore[nSurfaceIndex].rtStop = rtStop;
- m_pPictureStore[nSurfaceIndex].nCodecSpecific = nCodecSpecific;
- return false;
- } else {
- //TRACE ("Add Stor: [%10I64d - %10I64d], Ind = %d, Codec=%d\n", rtStart, rtStop, nSurfaceIndex, nCodecSpecific);
- /*
- ASSERT (m_pPictureStore[nSurfaceIndex].pSample == NULL);
- ASSERT (!m_pPictureStore[nSurfaceIndex].bInUse);
- ASSERT ((nSurfaceIndex < m_nPicEntryNumber) && (m_pPictureStore[nSurfaceIndex].pSample == NULL));
- */
-
- m_pPictureStore[nSurfaceIndex].bRefPicture = bRefPicture;
- m_pPictureStore[nSurfaceIndex].bInUse = true;
- m_pPictureStore[nSurfaceIndex].bDisplayed = false;
- m_pPictureStore[nSurfaceIndex].pSample = pSample;
- m_pPictureStore[nSurfaceIndex].nSliceType = nSliceType;
-
- if (!bIsField) {
- m_pPictureStore[nSurfaceIndex].rtStart = rtStart;
- m_pPictureStore[nSurfaceIndex].rtStop = rtStop;
- m_pPictureStore[nSurfaceIndex].n1FieldType = nFieldType;
- m_pPictureStore[nSurfaceIndex].nCodecSpecific = nCodecSpecific;
- }
-
- m_nFieldSurface = -1;
- m_nWaitingPics++;
- return true;
- }
+ if (bIsField && (m_nFieldSurface == -1)) {
+ m_nFieldSurface = nSurfaceIndex;
+ m_pFieldSample = pSample;
+ m_pPictureStore[nSurfaceIndex].n1FieldType = nFieldType;
+ m_pPictureStore[nSurfaceIndex].rtStart = rtStart;
+ m_pPictureStore[nSurfaceIndex].rtStop = rtStop;
+ m_pPictureStore[nSurfaceIndex].nCodecSpecific = nCodecSpecific;
+ return false;
+ } else {
+ //TRACE ("Add Stor: [%10I64d - %10I64d], Ind = %d, Codec=%d\n", rtStart, rtStop, nSurfaceIndex, nCodecSpecific);
+ /*
+ ASSERT (m_pPictureStore[nSurfaceIndex].pSample == NULL);
+ ASSERT (!m_pPictureStore[nSurfaceIndex].bInUse);
+ ASSERT ((nSurfaceIndex < m_nPicEntryNumber) && (m_pPictureStore[nSurfaceIndex].pSample == NULL));
+ */
+
+ m_pPictureStore[nSurfaceIndex].bRefPicture = bRefPicture;
+ m_pPictureStore[nSurfaceIndex].bInUse = true;
+ m_pPictureStore[nSurfaceIndex].bDisplayed = false;
+ m_pPictureStore[nSurfaceIndex].pSample = pSample;
+ m_pPictureStore[nSurfaceIndex].nSliceType = nSliceType;
+
+ if (!bIsField) {
+ m_pPictureStore[nSurfaceIndex].rtStart = rtStart;
+ m_pPictureStore[nSurfaceIndex].rtStop = rtStop;
+ m_pPictureStore[nSurfaceIndex].n1FieldType = nFieldType;
+ m_pPictureStore[nSurfaceIndex].nCodecSpecific = nCodecSpecific;
+ }
+
+ m_nFieldSurface = -1;
+ m_nWaitingPics++;
+ return true;
+ }
}
-void CDXVADecoder::UpdateStore (int nSurfaceIndex, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
+void CDXVADecoder::UpdateStore(int nSurfaceIndex, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
{
- ASSERT ((nSurfaceIndex < m_nPicEntryNumber) && m_pPictureStore[nSurfaceIndex].bInUse && !m_pPictureStore[nSurfaceIndex].bDisplayed);
+ ASSERT((nSurfaceIndex < m_nPicEntryNumber) && m_pPictureStore[nSurfaceIndex].bInUse && !m_pPictureStore[nSurfaceIndex].bDisplayed);
- m_pPictureStore[nSurfaceIndex].rtStart = rtStart;
- m_pPictureStore[nSurfaceIndex].rtStop = rtStop;
+ m_pPictureStore[nSurfaceIndex].rtStart = rtStart;
+ m_pPictureStore[nSurfaceIndex].rtStop = rtStop;
}
-void CDXVADecoder::RemoveRefFrame (int nSurfaceIndex)
+void CDXVADecoder::RemoveRefFrame(int nSurfaceIndex)
{
- //ASSERT ((nSurfaceIndex < m_nPicEntryNumber) && m_pPictureStore[nSurfaceIndex].bInUse);
+ //ASSERT ((nSurfaceIndex < m_nPicEntryNumber) && m_pPictureStore[nSurfaceIndex].bInUse);
- m_pPictureStore[nSurfaceIndex].bRefPicture = false;
- if (m_pPictureStore[nSurfaceIndex].bDisplayed) {
- FreePictureSlot (nSurfaceIndex);
- }
+ m_pPictureStore[nSurfaceIndex].bRefPicture = false;
+ if (m_pPictureStore[nSurfaceIndex].bDisplayed) {
+ FreePictureSlot(nSurfaceIndex);
+ }
}
int CDXVADecoder::FindOldestFrame()
{
- REFERENCE_TIME rtMin = _I64_MAX;
- int nPos = -1;
-
- // TODO : find better solution...
- if (m_nWaitingPics > m_nMaxWaiting) {
- for (int i=0; i<m_nPicEntryNumber; i++) {
- if (!m_pPictureStore[i].bDisplayed && m_pPictureStore[i].bInUse && (m_pPictureStore[i].rtStart < rtMin)) {
- rtMin = m_pPictureStore[i].rtStart;
- nPos = i;
- }
- }
- }
- return nPos;
+ REFERENCE_TIME rtMin = _I64_MAX;
+ int nPos = -1;
+
+ // TODO : find better solution...
+ if (m_nWaitingPics > m_nMaxWaiting) {
+ for (int i = 0; i < m_nPicEntryNumber; i++) {
+ if (!m_pPictureStore[i].bDisplayed && m_pPictureStore[i].bInUse && (m_pPictureStore[i].rtStart < rtMin)) {
+ rtMin = m_pPictureStore[i].rtStart;
+ nPos = i;
+ }
+ }
+ }
+ return nPos;
}
void CDXVADecoder::SetTypeSpecificFlags(PICTURE_STORE* pPicture, IMediaSample* pMS)
{
- if (CComQIPtr<IMediaSample2> pMS2 = pMS) {
- AM_SAMPLE2_PROPERTIES props;
- if (SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props))) {
- props.dwTypeSpecificFlags &= ~0x7f;
-
- m_pFilter->SetFrameType(pPicture->n1FieldType);
-
- if (pPicture->n1FieldType == PICT_FRAME) {
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;
- } else if (pPicture->n1FieldType == PICT_TOP_FIELD) {
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_FIELD1FIRST;
- }
-
- switch (pPicture->nSliceType) {
- case I_TYPE :
- case SI_TYPE :
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_I_SAMPLE;
- break;
- case P_TYPE :
- case SP_TYPE :
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_P_SAMPLE;
- break;
- default :
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_B_SAMPLE;
- break;
- }
-
- pMS2->SetProperties(sizeof(props), (BYTE*)&props);
- }
- }
- pMS->SetTime(&pPicture->rtStart, &pPicture->rtStop);
+ if (CComQIPtr<IMediaSample2> pMS2 = pMS) {
+ AM_SAMPLE2_PROPERTIES props;
+ if (SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props))) {
+ props.dwTypeSpecificFlags &= ~0x7f;
+
+ m_pFilter->SetFrameType(pPicture->n1FieldType);
+
+ if (pPicture->n1FieldType == PICT_FRAME) {
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;
+ } else if (pPicture->n1FieldType == PICT_TOP_FIELD) {
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_FIELD1FIRST;
+ }
+
+ switch (pPicture->nSliceType) {
+ case I_TYPE :
+ case SI_TYPE :
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_I_SAMPLE;
+ break;
+ case P_TYPE :
+ case SP_TYPE :
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_P_SAMPLE;
+ break;
+ default :
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_B_SAMPLE;
+ break;
+ }
+
+ pMS2->SetProperties(sizeof(props), (BYTE*)&props);
+ }
+ }
+ pMS->SetTime(&pPicture->rtStart, &pPicture->rtStop);
}
HRESULT CDXVADecoder::DisplayNextFrame()
{
- HRESULT hr = S_FALSE;
- CComPtr<IMediaSample> pSampleToDeliver;
- int nPicIndex = FindOldestFrame();
-
- if (nPicIndex != -1) {
- if (m_pPictureStore[nPicIndex].rtStart >= 0) {
- switch (m_nEngine) {
- case ENGINE_DXVA1 :
- // For DXVA1, query a media sample at the last time (only one in the allocator)
- hr = GetDeliveryBuffer (m_pPictureStore[nPicIndex].rtStart, m_pPictureStore[nPicIndex].rtStop, &pSampleToDeliver);
- SetTypeSpecificFlags(&m_pPictureStore[nPicIndex], pSampleToDeliver);
- if (SUCCEEDED (hr)) {
- hr = m_pAMVideoAccelerator->DisplayFrame(nPicIndex, pSampleToDeliver);
- }
- break;
- case ENGINE_DXVA2 :
- // For DXVA2 media sample is in the picture store
- m_pPictureStore[nPicIndex].pSample->SetTime (&m_pPictureStore[nPicIndex].rtStart, &m_pPictureStore[nPicIndex].rtStop);
- SetTypeSpecificFlags(&m_pPictureStore[nPicIndex], m_pPictureStore[nPicIndex].pSample);
- hr = m_pFilter->GetOutputPin()->Deliver(m_pPictureStore[nPicIndex].pSample);
- break;
- }
+ HRESULT hr = S_FALSE;
+ CComPtr<IMediaSample> pSampleToDeliver;
+ int nPicIndex = FindOldestFrame();
+
+ if (nPicIndex != -1) {
+ if (m_pPictureStore[nPicIndex].rtStart >= 0) {
+ switch (m_nEngine) {
+ case ENGINE_DXVA1 :
+ // For DXVA1, query a media sample at the last time (only one in the allocator)
+ hr = GetDeliveryBuffer(m_pPictureStore[nPicIndex].rtStart, m_pPictureStore[nPicIndex].rtStop, &pSampleToDeliver);
+ SetTypeSpecificFlags(&m_pPictureStore[nPicIndex], pSampleToDeliver);
+ if (SUCCEEDED(hr)) {
+ hr = m_pAMVideoAccelerator->DisplayFrame(nPicIndex, pSampleToDeliver);
+ }
+ break;
+ case ENGINE_DXVA2 :
+ // For DXVA2 media sample is in the picture store
+ m_pPictureStore[nPicIndex].pSample->SetTime(&m_pPictureStore[nPicIndex].rtStart, &m_pPictureStore[nPicIndex].rtStop);
+ SetTypeSpecificFlags(&m_pPictureStore[nPicIndex], m_pPictureStore[nPicIndex].pSample);
+ hr = m_pFilter->GetOutputPin()->Deliver(m_pPictureStore[nPicIndex].pSample);
+ break;
+ }
#if defined(_DEBUG) && 0
- static REFERENCE_TIME rtLast = 0;
- TRACE ("Deliver : %10I64d - %10I64d (Dur = %10I64d) {Delta = %10I64d} Ind = %02d Codec=%d Ref=%d\n",
- m_pPictureStore[nPicIndex].rtStart,
- m_pPictureStore[nPicIndex].rtStop,
- m_pPictureStore[nPicIndex].rtStop - m_pPictureStore[nPicIndex].rtStart,
- m_pPictureStore[nPicIndex].rtStart - rtLast, nPicIndex,
- m_pPictureStore[nPicIndex].nCodecSpecific,
- m_pPictureStore[nPicIndex].bRefPicture);
- rtLast = m_pPictureStore[nPicIndex].rtStart;
+ static REFERENCE_TIME rtLast = 0;
+ TRACE("Deliver : %10I64d - %10I64d (Dur = %10I64d) {Delta = %10I64d} Ind = %02d Codec=%d Ref=%d\n",
+ m_pPictureStore[nPicIndex].rtStart,
+ m_pPictureStore[nPicIndex].rtStop,
+ m_pPictureStore[nPicIndex].rtStop - m_pPictureStore[nPicIndex].rtStart,
+ m_pPictureStore[nPicIndex].rtStart - rtLast, nPicIndex,
+ m_pPictureStore[nPicIndex].nCodecSpecific,
+ m_pPictureStore[nPicIndex].bRefPicture);
+ rtLast = m_pPictureStore[nPicIndex].rtStart;
#endif
- }
- m_bNeedChangeAspect = false;
+ }
+ m_bNeedChangeAspect = false;
- m_pPictureStore[nPicIndex].bDisplayed = true;
- if (!m_pPictureStore[nPicIndex].bRefPicture) {
- FreePictureSlot (nPicIndex);
- }
- }
+ m_pPictureStore[nPicIndex].bDisplayed = true;
+ if (!m_pPictureStore[nPicIndex].bRefPicture) {
+ FreePictureSlot(nPicIndex);
+ }
+ }
- return hr;
+ return hr;
}
HRESULT CDXVADecoder::GetFreeSurfaceIndex(int& nSurfaceIndex, IMediaSample** ppSampleToDeliver, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
{
- HRESULT hr = E_UNEXPECTED;
- int nPos = -1;
- DWORD dwMinDisplay = MAXDWORD;
-
- if (m_nFieldSurface != -1) {
- nSurfaceIndex = m_nFieldSurface;
- *ppSampleToDeliver = m_pFieldSample.Detach();
- return S_FALSE;
- }
-
- switch (m_nEngine) {
- case ENGINE_DXVA1 :
- for (int i=0; i<m_nPicEntryNumber; i++) {
- if (!m_pPictureStore[i].bInUse && m_pPictureStore[i].dwDisplayCount < dwMinDisplay) {
- dwMinDisplay = m_pPictureStore[i].dwDisplayCount;
- nPos = i;
- }
- }
-
- if (nPos != -1) {
- nSurfaceIndex = nPos;
- return S_OK;
- }
-
- // Ho ho...
- ASSERT (FALSE);
- Flush();
- break;
- case ENGINE_DXVA2 :
- CComPtr<IMediaSample> pNewSample;
- CComQIPtr<IMPCDXVA2Sample> pMPCDXVA2Sample;
- // TODO : test IDirect3DDeviceManager9::TestDevice !!!
- if (SUCCEEDED (hr = GetDeliveryBuffer(rtStart, rtStop, &pNewSample))) {
- pMPCDXVA2Sample = pNewSample;
- nSurfaceIndex = pMPCDXVA2Sample ? pMPCDXVA2Sample->GetDXSurfaceId() : 0;
- *ppSampleToDeliver = pNewSample.Detach();
- }
- break;
- }
-
- return hr;
+ HRESULT hr = E_UNEXPECTED;
+ int nPos = -1;
+ DWORD dwMinDisplay = MAXDWORD;
+
+ if (m_nFieldSurface != -1) {
+ nSurfaceIndex = m_nFieldSurface;
+ *ppSampleToDeliver = m_pFieldSample.Detach();
+ return S_FALSE;
+ }
+
+ switch (m_nEngine) {
+ case ENGINE_DXVA1 :
+ for (int i = 0; i < m_nPicEntryNumber; i++) {
+ if (!m_pPictureStore[i].bInUse && m_pPictureStore[i].dwDisplayCount < dwMinDisplay) {
+ dwMinDisplay = m_pPictureStore[i].dwDisplayCount;
+ nPos = i;
+ }
+ }
+
+ if (nPos != -1) {
+ nSurfaceIndex = nPos;
+ return S_OK;
+ }
+
+ // Ho ho...
+ ASSERT(FALSE);
+ Flush();
+ break;
+ case ENGINE_DXVA2 :
+ CComPtr<IMediaSample> pNewSample;
+ CComQIPtr<IMPCDXVA2Sample> pMPCDXVA2Sample;
+ // TODO : test IDirect3DDeviceManager9::TestDevice !!!
+ if (SUCCEEDED(hr = GetDeliveryBuffer(rtStart, rtStop, &pNewSample))) {
+ pMPCDXVA2Sample = pNewSample;
+ nSurfaceIndex = pMPCDXVA2Sample ? pMPCDXVA2Sample->GetDXSurfaceId() : 0;
+ *ppSampleToDeliver = pNewSample.Detach();
+ }
+ break;
+ }
+
+ return hr;
}
-void CDXVADecoder::FreePictureSlot (int nSurfaceIndex)
+void CDXVADecoder::FreePictureSlot(int nSurfaceIndex)
{
- m_pPictureStore[nSurfaceIndex].dwDisplayCount = m_dwDisplayCount++;
- m_pPictureStore[nSurfaceIndex].bInUse = false;
- m_pPictureStore[nSurfaceIndex].bDisplayed = false;
- m_pPictureStore[nSurfaceIndex].pSample = NULL;
- m_pPictureStore[nSurfaceIndex].nCodecSpecific = -1;
- m_nWaitingPics--;
+ m_pPictureStore[nSurfaceIndex].dwDisplayCount = m_dwDisplayCount++;
+ m_pPictureStore[nSurfaceIndex].bInUse = false;
+ m_pPictureStore[nSurfaceIndex].bDisplayed = false;
+ m_pPictureStore[nSurfaceIndex].pSample = NULL;
+ m_pPictureStore[nSurfaceIndex].nCodecSpecific = -1;
+ m_nWaitingPics--;
}
BYTE CDXVADecoder::GetConfigResidDiffAccelerator()
{
- switch (m_nEngine) {
- case ENGINE_DXVA1 :
- return m_DXVA1Config.bConfigResidDiffAccelerator;
- case ENGINE_DXVA2 :
- return m_DXVA2Config.ConfigResidDiffAccelerator;
- }
- return 0;
+ switch (m_nEngine) {
+ case ENGINE_DXVA1 :
+ return m_DXVA1Config.bConfigResidDiffAccelerator;
+ case ENGINE_DXVA2 :
+ return m_DXVA2Config.ConfigResidDiffAccelerator;
+ }
+ return 0;
}
BYTE CDXVADecoder::GetConfigIntraResidUnsigned()
{
- switch (m_nEngine) {
- case ENGINE_DXVA1 :
- return m_DXVA1Config.bConfigIntraResidUnsigned;
- case ENGINE_DXVA2 :
- return m_DXVA2Config.ConfigIntraResidUnsigned;
- }
- return 0;
+ switch (m_nEngine) {
+ case ENGINE_DXVA1 :
+ return m_DXVA1Config.bConfigIntraResidUnsigned;
+ case ENGINE_DXVA2 :
+ return m_DXVA2Config.ConfigIntraResidUnsigned;
+ }
+ return 0;
}
void CDXVADecoder::EndOfStream()
{
- CComPtr<IMediaSample> pSampleToDeliver;
-
- for (int nPicIndex=0; nPicIndex<m_nPicEntryNumber; nPicIndex++) {
- if (m_pPictureStore[nPicIndex].bInUse && !m_pPictureStore[nPicIndex].bDisplayed) {
- switch (m_nEngine) {
- // TODO - need check under WinXP on DXVA1
- /*
- case ENGINE_DXVA1 :
- if (SUCCEEDED (GetDeliveryBuffer (m_pPictureStore[nPicIndex].rtStart, m_pPictureStore[nPicIndex].rtStop, &pSampleToDeliver)) && pSampleToDeliver) {
- m_pAMVideoAccelerator->DisplayFrame(nPicIndex, pSampleToDeliver);
- }
- break;
- */
- case ENGINE_DXVA2 :
- SetTypeSpecificFlags(&m_pPictureStore[nPicIndex], m_pPictureStore[nPicIndex].pSample);
- m_pFilter->GetOutputPin()->Deliver(m_pPictureStore[nPicIndex].pSample);
- break;
- }
- }
- }
+ CComPtr<IMediaSample> pSampleToDeliver;
+
+ for (int nPicIndex = 0; nPicIndex < m_nPicEntryNumber; nPicIndex++) {
+ if (m_pPictureStore[nPicIndex].bInUse && !m_pPictureStore[nPicIndex].bDisplayed) {
+ switch (m_nEngine) {
+ // TODO - need check under WinXP on DXVA1
+ /*
+ case ENGINE_DXVA1 :
+ if (SUCCEEDED (GetDeliveryBuffer (m_pPictureStore[nPicIndex].rtStart, m_pPictureStore[nPicIndex].rtStop, &pSampleToDeliver)) && pSampleToDeliver) {
+ m_pAMVideoAccelerator->DisplayFrame(nPicIndex, pSampleToDeliver);
+ }
+ break;
+ */
+ case ENGINE_DXVA2 :
+ SetTypeSpecificFlags(&m_pPictureStore[nPicIndex], m_pPictureStore[nPicIndex].pSample);
+ m_pFilter->GetOutputPin()->Deliver(m_pPictureStore[nPicIndex].pSample);
+ break;
+ }
+ }
+ }
} \ No newline at end of file
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoder.h b/src/filters/transform/MPCVideoDec/DXVADecoder.h
index 53ba320f6..07923ca03 100644
--- a/src/filters/transform/MPCVideoDec/DXVADecoder.h
+++ b/src/filters/transform/MPCVideoDec/DXVADecoder.h
@@ -27,136 +27,136 @@
#include "../../../DSUtil/DSUtil.h"
typedef enum {
- ENGINE_DXVA1,
- ENGINE_DXVA2
+ ENGINE_DXVA1,
+ ENGINE_DXVA2
} DXVA_ENGINE;
typedef enum {
- H264_VLD,
- VC1_VLD,
- MPEG2_VLD
+ H264_VLD,
+ VC1_VLD,
+ MPEG2_VLD
} DXVAMode;
typedef enum {
- I_TYPE = 1, ///< Intra
- P_TYPE = 2, ///< Predicted
- B_TYPE = 3, ///< Bi-dir predicted
- S_TYPE = 4, ///< S(GMC)-VOP MPEG4
- SI_TYPE = 5, ///< Switching Intra
- SP_TYPE = 6, ///< Switching Predicted
- BI_TYPE = 7
+ I_TYPE = 1, ///< Intra
+ P_TYPE = 2, ///< Predicted
+ B_TYPE = 3, ///< Bi-dir predicted
+ S_TYPE = 4, ///< S(GMC)-VOP MPEG4
+ SI_TYPE = 5, ///< Switching Intra
+ SP_TYPE = 6, ///< Switching Predicted
+ BI_TYPE = 7
} FF_SLICE_TYPE;
typedef struct {
- bool bRefPicture; // True if reference picture
- bool bInUse; // Slot in use
- bool bDisplayed; // True if picture have been presented
- CComPtr<IMediaSample> pSample; // Only for DXVA2 !
- REFERENCE_TIME rtStart;
- REFERENCE_TIME rtStop;
- FF_FIELD_TYPE n1FieldType; // Top or bottom for the 1st field
- FF_SLICE_TYPE nSliceType;
- int nCodecSpecific;
- DWORD dwDisplayCount;
+ bool bRefPicture; // True if reference picture
+ bool bInUse; // Slot in use
+ bool bDisplayed; // True if picture have been presented
+ CComPtr<IMediaSample> pSample; // Only for DXVA2 !
+ REFERENCE_TIME rtStart;
+ REFERENCE_TIME rtStop;
+ FF_FIELD_TYPE n1FieldType; // Top or bottom for the 1st field
+ FF_SLICE_TYPE nSliceType;
+ int nCodecSpecific;
+ DWORD dwDisplayCount;
} PICTURE_STORE;
-#define MAX_COM_BUFFER 6 // Max uncompressed buffer for an Execute command (DXVA1)
-#define COMP_BUFFER_COUNT 18
-#define NO_REF_FRAME 0xFFFF
+#define MAX_COM_BUFFER 6 // Max uncompressed buffer for an Execute command (DXVA1)
+#define COMP_BUFFER_COUNT 18
+#define NO_REF_FRAME 0xFFFF
class CMPCVideoDecFilter;
class CDXVADecoder
{
public :
- // === Public functions
- virtual ~CDXVADecoder();
- DXVAMode GetMode() const {
- return m_nMode;
- };
- DXVA_ENGINE GetEngine() const {
- return m_nEngine;
- };
- void AllocExecuteParams (int nSize);
- void SetDirectXVideoDec (IDirectXVideoDecoder* pDirectXVideoDec) {
- m_pDirectXVideoDec = pDirectXVideoDec;
- };
-
- virtual HRESULT DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop) = NULL;
- virtual void SetExtraData (BYTE* pDataIn, UINT nSize);
- virtual void CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize);
- virtual void Flush();
- HRESULT ConfigureDXVA1();
-
- static CDXVADecoder* CreateDecoder (CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, const GUID* guidDecoder, int nPicEntryNumber);
- static CDXVADecoder* CreateDecoder (CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, const GUID* guidDecoder, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config);
-
- void EndOfStream();
+ // === Public functions
+ virtual ~CDXVADecoder();
+ DXVAMode GetMode() const {
+ return m_nMode;
+ };
+ DXVA_ENGINE GetEngine() const {
+ return m_nEngine;
+ };
+ void AllocExecuteParams(int nSize);
+ void SetDirectXVideoDec(IDirectXVideoDecoder* pDirectXVideoDec) {
+ m_pDirectXVideoDec = pDirectXVideoDec;
+ };
+
+ virtual HRESULT DecodeFrame(BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop) = NULL;
+ virtual void SetExtraData(BYTE* pDataIn, UINT nSize);
+ virtual void CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize);
+ virtual void Flush();
+ HRESULT ConfigureDXVA1();
+
+ static CDXVADecoder* CreateDecoder(CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, const GUID* guidDecoder, int nPicEntryNumber);
+ static CDXVADecoder* CreateDecoder(CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, const GUID* guidDecoder, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config);
+
+ void EndOfStream();
protected :
- CDXVADecoder (CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber);
- CDXVADecoder (CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config);
-
- CMPCVideoDecFilter* m_pFilter;
- bool m_bFlushed;
- int m_nMaxWaiting;
-
- PICTURE_STORE* m_pPictureStore; // Store reference picture, and delayed B-frames
- int m_nPicEntryNumber; // Total number of picture in store
- int m_nWaitingPics; // Number of picture not yet displayed
-
- bool m_bNeedChangeAspect;
-
- // === DXVA functions
- HRESULT AddExecuteBuffer (DWORD CompressedBufferType, UINT nSize, void* pBuffer, UINT* pRealSize = NULL);
- HRESULT GetDeliveryBuffer(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, IMediaSample** ppSampleToDeliver);
- HRESULT Execute();
- DWORD GetDXVA1CompressedType (DWORD dwDXVA2CompressedType);
- HRESULT FindFreeDXVA1Buffer(DWORD dwTypeIndex, DWORD& dwBufferIndex);
- HRESULT BeginFrame(int nSurfaceIndex, IMediaSample* pSampleToDeliver);
- HRESULT EndFrame(int nSurfaceIndex);
- HRESULT QueryStatus(PVOID LPDXVAStatus, UINT nSize);
- BYTE GetConfigIntraResidUnsigned();
- BYTE GetConfigResidDiffAccelerator();
- DXVA_ConfigPictureDecode* GetDXVA1Config() {
- return &m_DXVA1Config;
- };
- DXVA2_ConfigPictureDecode* GetDXVA2Config() {
- return &m_DXVA2Config;
- };
-
- // === Picture store functions
- bool AddToStore (int nSurfaceIndex, IMediaSample* pSample, bool bRefPicture, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, bool bIsField, FF_FIELD_TYPE nFieldType, FF_SLICE_TYPE nSliceType, int nCodecSpecific);
- void UpdateStore (int nSurfaceIndex, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
- void RemoveRefFrame (int nSurfaceIndex);
- HRESULT DisplayNextFrame();
- HRESULT GetFreeSurfaceIndex(int& nSurfaceIndex, IMediaSample** ppSampleToDeliver, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
- virtual int FindOldestFrame();
+ CDXVADecoder(CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber);
+ CDXVADecoder(CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config);
+
+ CMPCVideoDecFilter* m_pFilter;
+ bool m_bFlushed;
+ int m_nMaxWaiting;
+
+ PICTURE_STORE* m_pPictureStore; // Store reference picture, and delayed B-frames
+ int m_nPicEntryNumber; // Total number of picture in store
+ int m_nWaitingPics; // Number of picture not yet displayed
+
+ bool m_bNeedChangeAspect;
+
+ // === DXVA functions
+ HRESULT AddExecuteBuffer(DWORD CompressedBufferType, UINT nSize, void* pBuffer, UINT* pRealSize = NULL);
+ HRESULT GetDeliveryBuffer(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, IMediaSample** ppSampleToDeliver);
+ HRESULT Execute();
+ DWORD GetDXVA1CompressedType(DWORD dwDXVA2CompressedType);
+ HRESULT FindFreeDXVA1Buffer(DWORD dwTypeIndex, DWORD& dwBufferIndex);
+ HRESULT BeginFrame(int nSurfaceIndex, IMediaSample* pSampleToDeliver);
+ HRESULT EndFrame(int nSurfaceIndex);
+ HRESULT QueryStatus(PVOID LPDXVAStatus, UINT nSize);
+ BYTE GetConfigIntraResidUnsigned();
+ BYTE GetConfigResidDiffAccelerator();
+ DXVA_ConfigPictureDecode* GetDXVA1Config() {
+ return &m_DXVA1Config;
+ };
+ DXVA2_ConfigPictureDecode* GetDXVA2Config() {
+ return &m_DXVA2Config;
+ };
+
+ // === Picture store functions
+ bool AddToStore(int nSurfaceIndex, IMediaSample* pSample, bool bRefPicture, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, bool bIsField, FF_FIELD_TYPE nFieldType, FF_SLICE_TYPE nSliceType, int nCodecSpecific);
+ void UpdateStore(int nSurfaceIndex, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
+ void RemoveRefFrame(int nSurfaceIndex);
+ HRESULT DisplayNextFrame();
+ HRESULT GetFreeSurfaceIndex(int& nSurfaceIndex, IMediaSample** ppSampleToDeliver, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
+ virtual int FindOldestFrame();
private :
- DXVAMode m_nMode;
- DXVA_ENGINE m_nEngine;
-
- CComPtr<IMediaSample> m_pFieldSample;
- int m_nFieldSurface;
-
- // === DXVA1 variables
- CComQIPtr<IAMVideoAccelerator> m_pAMVideoAccelerator;
- AMVABUFFERINFO m_DXVA1BufferInfo[MAX_COM_BUFFER];
- DXVA_BufferDescription m_DXVA1BufferDesc[MAX_COM_BUFFER];
- DWORD m_dwNumBuffersInfo;
- DXVA_ConfigPictureDecode m_DXVA1Config;
- AMVACompBufferInfo m_ComBufferInfo[COMP_BUFFER_COUNT];
- DWORD m_dwBufferIndex;
- DWORD m_dwDisplayCount;
-
- // === DXVA2 variables
- CComPtr<IDirectXVideoDecoder> m_pDirectXVideoDec;
- DXVA2_ConfigPictureDecode m_DXVA2Config;
- DXVA2_DecodeExecuteParams m_ExecuteParams;
-
- void Init(CMPCVideoDecFilter* pFilter, DXVAMode nMode, int nPicEntryNumber);
- void FreePictureSlot (int nSurfaceIndex);
- void SetTypeSpecificFlags(PICTURE_STORE* pPicture, IMediaSample* pMS);
+ DXVAMode m_nMode;
+ DXVA_ENGINE m_nEngine;
+
+ CComPtr<IMediaSample> m_pFieldSample;
+ int m_nFieldSurface;
+
+ // === DXVA1 variables
+ CComQIPtr<IAMVideoAccelerator> m_pAMVideoAccelerator;
+ AMVABUFFERINFO m_DXVA1BufferInfo[MAX_COM_BUFFER];
+ DXVA_BufferDescription m_DXVA1BufferDesc[MAX_COM_BUFFER];
+ DWORD m_dwNumBuffersInfo;
+ DXVA_ConfigPictureDecode m_DXVA1Config;
+ AMVACompBufferInfo m_ComBufferInfo[COMP_BUFFER_COUNT];
+ DWORD m_dwBufferIndex;
+ DWORD m_dwDisplayCount;
+
+ // === DXVA2 variables
+ CComPtr<IDirectXVideoDecoder> m_pDirectXVideoDec;
+ DXVA2_ConfigPictureDecode m_DXVA2Config;
+ DXVA2_DecodeExecuteParams m_ExecuteParams;
+
+ void Init(CMPCVideoDecFilter* pFilter, DXVAMode nMode, int nPicEntryNumber);
+ void FreePictureSlot(int nSurfaceIndex);
+ void SetTypeSpecificFlags(PICTURE_STORE* pPicture, IMediaSample* pMS);
};
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp b/src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp
index 4e7fb9e17..e6d2a5e0c 100644
--- a/src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp
+++ b/src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp
@@ -35,18 +35,18 @@
#define TRACE_H264(...)
#endif
-CDXVADecoderH264::CDXVADecoderH264 (CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber)
- : CDXVADecoder (pFilter, pAMVideoAccelerator, nMode, nPicEntryNumber)
+CDXVADecoderH264::CDXVADecoderH264(CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber)
+ : CDXVADecoder(pFilter, pAMVideoAccelerator, nMode, nPicEntryNumber)
{
- m_bUseLongSlice = (GetDXVA1Config()->bConfigBitstreamRaw != 2);
- Init();
+ m_bUseLongSlice = (GetDXVA1Config()->bConfigBitstreamRaw != 2);
+ Init();
}
-CDXVADecoderH264::CDXVADecoderH264 (CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config)
- : CDXVADecoder (pFilter, pDirectXVideoDec, nMode, nPicEntryNumber, pDXVA2Config)
+CDXVADecoderH264::CDXVADecoderH264(CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config)
+ : CDXVADecoder(pFilter, pDirectXVideoDec, nMode, nPicEntryNumber, pDXVA2Config)
{
- m_bUseLongSlice = (m_pFilter->GetDXVA2Config()->ConfigBitstreamRaw != 2);
- Init();
+ m_bUseLongSlice = (m_pFilter->GetDXVA2Config()->ConfigBitstreamRaw != 2);
+ Init();
}
CDXVADecoderH264::~CDXVADecoderH264()
@@ -55,337 +55,338 @@ CDXVADecoderH264::~CDXVADecoderH264()
void CDXVADecoderH264::Init()
{
- memset (&m_DXVAPicParams, 0, sizeof (m_DXVAPicParams));
- memset (&m_DXVAPicParams, 0, sizeof (DXVA_PicParams_H264));
- memset (&m_pSliceLong, 0, sizeof (DXVA_Slice_H264_Long) *MAX_SLICES);
- memset (&m_pSliceShort, 0, sizeof (DXVA_Slice_H264_Short)*MAX_SLICES);
-
- m_DXVAPicParams.MbsConsecutiveFlag = 1;
- if (m_pFilter->GetPCIVendor() == PCIV_Intel) {
- m_DXVAPicParams.Reserved16Bits = 0x534c;
- } else {
- m_DXVAPicParams.Reserved16Bits = 0;
- }
- m_DXVAPicParams.ContinuationFlag = 1;
- m_DXVAPicParams.Reserved8BitsA = 0;
- m_DXVAPicParams.Reserved8BitsB = 0;
- m_DXVAPicParams.MinLumaBipredSize8x8Flag = 1; // Improve accelerator performances
- m_DXVAPicParams.StatusReportFeedbackNumber = 0; // Use to report status
-
- for (int i =0; i<16; i++) {
- m_DXVAPicParams.RefFrameList[i].AssociatedFlag = 1;
- m_DXVAPicParams.RefFrameList[i].bPicEntry = 255;
- m_DXVAPicParams.RefFrameList[i].Index7Bits = 127;
- }
-
-
- m_nNALLength = 4;
- m_nMaxSlices = 0;
-
- switch (GetMode()) {
- case H264_VLD :
- AllocExecuteParams (3);
- break;
- default :
- ASSERT(FALSE);
- }
+ memset(&m_DXVAPicParams, 0, sizeof(m_DXVAPicParams));
+ memset(&m_DXVAPicParams, 0, sizeof(DXVA_PicParams_H264));
+ memset(&m_pSliceLong, 0, sizeof(DXVA_Slice_H264_Long) *MAX_SLICES);
+ memset(&m_pSliceShort, 0, sizeof(DXVA_Slice_H264_Short)*MAX_SLICES);
+
+ m_DXVAPicParams.MbsConsecutiveFlag = 1;
+ if (m_pFilter->GetPCIVendor() == PCIV_Intel) {
+ m_DXVAPicParams.Reserved16Bits = 0x534c;
+ } else {
+ m_DXVAPicParams.Reserved16Bits = 0;
+ }
+ m_DXVAPicParams.ContinuationFlag = 1;
+ m_DXVAPicParams.Reserved8BitsA = 0;
+ m_DXVAPicParams.Reserved8BitsB = 0;
+ m_DXVAPicParams.MinLumaBipredSize8x8Flag = 1; // Improve accelerator performances
+ m_DXVAPicParams.StatusReportFeedbackNumber = 0; // Use to report status
+
+ for (int i = 0; i < 16; i++) {
+ m_DXVAPicParams.RefFrameList[i].AssociatedFlag = 1;
+ m_DXVAPicParams.RefFrameList[i].bPicEntry = 255;
+ m_DXVAPicParams.RefFrameList[i].Index7Bits = 127;
+ }
+
+
+ m_nNALLength = 4;
+ m_nMaxSlices = 0;
+
+ switch (GetMode()) {
+ case H264_VLD :
+ AllocExecuteParams(3);
+ break;
+ default :
+ ASSERT(FALSE);
+ }
}
void CDXVADecoderH264::CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize)
{
- CH264Nalu Nalu;
- int nDummy;
- int nSlices = 0;
- UINT m_nSize = nSize;
- int slice_step = 1;
- int nDxvaNalLength;
-
- while (!nSlices && slice_step <= 2) {
- Nalu.SetBuffer (pBuffer, m_nSize, slice_step == 1 ? m_nNALLength : 0);
- nSize = 0;
- while (Nalu.ReadNext()) {
- switch (Nalu.GetType()) {
- case NALU_TYPE_SLICE:
- case NALU_TYPE_IDR:
- // Skip the NALU if the data length is below 0
- if (Nalu.GetDataLength() < 0) {
- break;
- }
-
- // For AVC1, put startcode 0x000001
- pDXVABuffer[0]=pDXVABuffer[1]=0; pDXVABuffer[2]=1;
- if (Nalu.GetDataLength() < 0)
- break;
-
- // Copy NALU
- __try {
- memcpy (pDXVABuffer+3, Nalu.GetDataBuffer(), Nalu.GetDataLength());
- } __except (EXCEPTION_EXECUTE_HANDLER) { break; }
-
- // Update slice control buffer
- nDxvaNalLength = Nalu.GetDataLength()+3;
- m_pSliceShort[nSlices].BSNALunitDataLocation = nSize;
- m_pSliceShort[nSlices].SliceBytesInBuffer = nDxvaNalLength;
-
- nSize += nDxvaNalLength;
- pDXVABuffer += nDxvaNalLength;
- nSlices++;
- break;
- }
- }
- slice_step++;
- }
-
- // Complete with zero padding (buffer size should be a multiple of 128)
- nDummy = 128 - (nSize %128);
-
- memset (pDXVABuffer, 0, nDummy);
- m_pSliceShort[nSlices-1].SliceBytesInBuffer += nDummy;
- nSize += nDummy;
+ CH264Nalu Nalu;
+ int nDummy;
+ int nSlices = 0;
+ UINT m_nSize = nSize;
+ int slice_step = 1;
+ int nDxvaNalLength;
+
+ while (!nSlices && slice_step <= 2) {
+ Nalu.SetBuffer(pBuffer, m_nSize, slice_step == 1 ? m_nNALLength : 0);
+ nSize = 0;
+ while (Nalu.ReadNext()) {
+ switch (Nalu.GetType()) {
+ case NALU_TYPE_SLICE:
+ case NALU_TYPE_IDR:
+ // Skip the NALU if the data length is below 0
+ if (Nalu.GetDataLength() < 0) {
+ break;
+ }
+
+ // For AVC1, put startcode 0x000001
+ pDXVABuffer[0] = pDXVABuffer[1] = 0; pDXVABuffer[2] = 1;
+ if (Nalu.GetDataLength() < 0) {
+ break;
+ }
+
+ // Copy NALU
+ __try {
+ memcpy(pDXVABuffer + 3, Nalu.GetDataBuffer(), Nalu.GetDataLength());
+ } __except (EXCEPTION_EXECUTE_HANDLER) { break; }
+
+ // Update slice control buffer
+ nDxvaNalLength = Nalu.GetDataLength() + 3;
+ m_pSliceShort[nSlices].BSNALunitDataLocation = nSize;
+ m_pSliceShort[nSlices].SliceBytesInBuffer = nDxvaNalLength;
+
+ nSize += nDxvaNalLength;
+ pDXVABuffer += nDxvaNalLength;
+ nSlices++;
+ break;
+ }
+ }
+ slice_step++;
+ }
+
+ // Complete with zero padding (buffer size should be a multiple of 128)
+ nDummy = 128 - (nSize % 128);
+
+ memset(pDXVABuffer, 0, nDummy);
+ m_pSliceShort[nSlices - 1].SliceBytesInBuffer += nDummy;
+ nSize += nDummy;
}
void CDXVADecoderH264::Flush()
{
- ClearRefFramesList();
- m_DXVAPicParams.UsedForReferenceFlags = 0;
- m_nOutPOC = INT_MIN;
- m_nPrevOutPOC = INT_MIN;
+ ClearRefFramesList();
+ m_DXVAPicParams.UsedForReferenceFlags = 0;
+ m_nOutPOC = INT_MIN;
+ m_nPrevOutPOC = INT_MIN;
- m_nfield_pic_flag = 1;
- m_nRefPicFlag = 1;
- m_nBrokenFramesFlag = 0;
- m_nBrokenFramesFlag_POC = 0;
+ m_nfield_pic_flag = 1;
+ m_nRefPicFlag = 1;
+ m_nBrokenFramesFlag = 0;
+ m_nBrokenFramesFlag_POC = 0;
- __super::Flush();
+ __super::Flush();
}
-HRESULT CDXVADecoderH264::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
+HRESULT CDXVADecoderH264::DecodeFrame(BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
{
- HRESULT hr = S_FALSE;
- UINT nSlices = 0;
- int nSurfaceIndex = -1;
- int nFieldType = -1;
- int nSliceType = -1;
- int nFramePOC = INT_MIN;
- int nOutPOC = INT_MIN;
- REFERENCE_TIME rtOutStart = _I64_MIN;
- CH264Nalu Nalu;
- UINT nNalOffset = 0;
- CComPtr<IMediaSample> pSampleToDeliver;
- CComQIPtr<IMPCDXVA2Sample> pDXVA2Sample;
- int slice_step = 1;
-
- if (FFH264DecodeBuffer (m_pFilter->GetAVCtx(), pDataIn, nSize, &nFramePOC, &nOutPOC, &rtOutStart) == -1) {
- return S_FALSE;
- }
-
- while (!nSlices && slice_step <= 2) {
- Nalu.SetBuffer (pDataIn, nSize, slice_step == 1 ? m_nNALLength : 0);
- while (Nalu.ReadNext()) {
- switch (Nalu.GetType()) {
- case NALU_TYPE_SLICE:
- case NALU_TYPE_IDR:
- if (m_bUseLongSlice) {
- m_pSliceLong[nSlices].BSNALunitDataLocation = nNalOffset;
- m_pSliceLong[nSlices].SliceBytesInBuffer = Nalu.GetDataLength()+3; //.GetRoundedDataLength();
- m_pSliceLong[nSlices].slice_id = nSlices;
- FF264UpdateRefFrameSliceLong(&m_DXVAPicParams, &m_pSliceLong[nSlices], m_pFilter->GetAVCtx());
-
- if (nSlices>0) {
- m_pSliceLong[nSlices-1].NumMbsForSlice = m_pSliceLong[nSlices].NumMbsForSlice = m_pSliceLong[nSlices].first_mb_in_slice - m_pSliceLong[nSlices-1].first_mb_in_slice;
- }
- }
- nSlices++;
- nNalOffset += (UINT)(Nalu.GetDataLength() + 3);
- if (nSlices > MAX_SLICES) {
- break;
- }
- break;
- }
- }
- slice_step++;
- }
-
- if (!nSlices) {
- return S_FALSE;
- }
-
- m_nMaxWaiting = min (max (m_DXVAPicParams.num_ref_frames, 3), 8);
-
- // If parsing fail (probably no PPS/SPS), continue anyway it may arrived later (happen on truncated streams)
- if (FAILED (FFH264BuildPicParams (&m_DXVAPicParams, &m_DXVAScalingMatrix, &nFieldType, &nSliceType, m_pFilter->GetAVCtx(), m_pFilter->GetPCIVendor()))) {
- return S_FALSE;
- }
-
- TRACE_H264 ("CDXVADecoderH264::DecodeFrame() : nFramePOC = %11d, nOutPOC = %11d[%11d], [%d - %d], rtOutStart = [%20I64d]\n", nFramePOC, nOutPOC, m_nOutPOC, m_DXVAPicParams.field_pic_flag, m_DXVAPicParams.RefPicFlag, rtOutStart);
-
- // Wait I frame after a flush
- if (m_bFlushed && !m_DXVAPicParams.IntraPicFlag) {
- TRACE_H264 ("CDXVADecoderH264::DecodeFrame() : Flush - wait I frame\n");
- m_nBrokenFramesFlag = 0;
- m_nBrokenFramesFlag_POC = 0;
- m_nfield_pic_flag = m_DXVAPicParams.field_pic_flag;
- m_nRefPicFlag = m_DXVAPicParams.RefPicFlag;
- m_nPrevOutPOC = INT_MIN;
- return S_FALSE;
- }
-
- // Some magic code for detecting the incorrect decoding of interlaced frames ...
- // TODO : necessary to make it better, and preferably on the side of ffmpeg ...
- if (m_nfield_pic_flag && m_nfield_pic_flag == m_DXVAPicParams.field_pic_flag && m_nRefPicFlag == m_DXVAPicParams.RefPicFlag) {
- if (m_nPrevOutPOC == m_nOutPOC && m_nOutPOC == INT_MIN) {
- m_nBrokenFramesFlag_POC++;
- }
- m_nBrokenFramesFlag++;
- } else {
- m_nBrokenFramesFlag = 0;
- m_nBrokenFramesFlag_POC = 0;
- }
- m_nfield_pic_flag = m_DXVAPicParams.field_pic_flag;
- m_nRefPicFlag = m_DXVAPicParams.RefPicFlag;
- m_nPrevOutPOC = m_nOutPOC;
-
- if (m_nBrokenFramesFlag > 4) {
- m_nBrokenFramesFlag = 0;
- if (m_nBrokenFramesFlag_POC > 1) {
- TRACE_H264 ("CDXVADecoderH264::DecodeFrame() : Detected broken frames ... flush data\n");
- m_nBrokenFramesFlag_POC = 0;
- Flush();
- return S_FALSE;
- }
- }
- //
-
- CHECK_HR (GetFreeSurfaceIndex (nSurfaceIndex, &pSampleToDeliver, rtStart, rtStop));
- FFH264SetCurrentPicture (nSurfaceIndex, &m_DXVAPicParams, m_pFilter->GetAVCtx());
-
- CHECK_HR (BeginFrame(nSurfaceIndex, pSampleToDeliver));
-
- m_DXVAPicParams.StatusReportFeedbackNumber++;
-
- // Send picture parameters
- CHECK_HR (AddExecuteBuffer (DXVA2_PictureParametersBufferType, sizeof(m_DXVAPicParams), &m_DXVAPicParams));
- CHECK_HR (Execute());
-
- // Add bitstream, slice control and quantization matrix
- CHECK_HR (AddExecuteBuffer (DXVA2_BitStreamDateBufferType, nSize, pDataIn, &nSize));
-
- if (m_bUseLongSlice) {
- CHECK_HR(AddExecuteBuffer(DXVA2_SliceControlBufferType, sizeof(DXVA_Slice_H264_Long)*nSlices, m_pSliceLong));
- } else {
- CHECK_HR (AddExecuteBuffer (DXVA2_SliceControlBufferType, sizeof (DXVA_Slice_H264_Short)*nSlices, m_pSliceShort));
- }
-
- CHECK_HR (AddExecuteBuffer (DXVA2_InverseQuantizationMatrixBufferType, sizeof (DXVA_Qmatrix_H264), (void*)&m_DXVAScalingMatrix));
-
- // Decode bitstream
- CHECK_HR (Execute());
-
- CHECK_HR (EndFrame(nSurfaceIndex));
+ HRESULT hr = S_FALSE;
+ UINT nSlices = 0;
+ int nSurfaceIndex = -1;
+ int nFieldType = -1;
+ int nSliceType = -1;
+ int nFramePOC = INT_MIN;
+ int nOutPOC = INT_MIN;
+ REFERENCE_TIME rtOutStart = _I64_MIN;
+ CH264Nalu Nalu;
+ UINT nNalOffset = 0;
+ CComPtr<IMediaSample> pSampleToDeliver;
+ CComQIPtr<IMPCDXVA2Sample> pDXVA2Sample;
+ int slice_step = 1;
+
+ if (FFH264DecodeBuffer(m_pFilter->GetAVCtx(), pDataIn, nSize, &nFramePOC, &nOutPOC, &rtOutStart) == -1) {
+ return S_FALSE;
+ }
+
+ while (!nSlices && slice_step <= 2) {
+ Nalu.SetBuffer(pDataIn, nSize, slice_step == 1 ? m_nNALLength : 0);
+ while (Nalu.ReadNext()) {
+ switch (Nalu.GetType()) {
+ case NALU_TYPE_SLICE:
+ case NALU_TYPE_IDR:
+ if (m_bUseLongSlice) {
+ m_pSliceLong[nSlices].BSNALunitDataLocation = nNalOffset;
+ m_pSliceLong[nSlices].SliceBytesInBuffer = Nalu.GetDataLength() + 3; //.GetRoundedDataLength();
+ m_pSliceLong[nSlices].slice_id = nSlices;
+ FF264UpdateRefFrameSliceLong(&m_DXVAPicParams, &m_pSliceLong[nSlices], m_pFilter->GetAVCtx());
+
+ if (nSlices > 0) {
+ m_pSliceLong[nSlices - 1].NumMbsForSlice = m_pSliceLong[nSlices].NumMbsForSlice = m_pSliceLong[nSlices].first_mb_in_slice - m_pSliceLong[nSlices - 1].first_mb_in_slice;
+ }
+ }
+ nSlices++;
+ nNalOffset += (UINT)(Nalu.GetDataLength() + 3);
+ if (nSlices > MAX_SLICES) {
+ break;
+ }
+ break;
+ }
+ }
+ slice_step++;
+ }
+
+ if (!nSlices) {
+ return S_FALSE;
+ }
+
+ m_nMaxWaiting = min(max(m_DXVAPicParams.num_ref_frames, 3), 8);
+
+ // If parsing fail (probably no PPS/SPS), continue anyway it may arrived later (happen on truncated streams)
+ if (FAILED(FFH264BuildPicParams(&m_DXVAPicParams, &m_DXVAScalingMatrix, &nFieldType, &nSliceType, m_pFilter->GetAVCtx(), m_pFilter->GetPCIVendor()))) {
+ return S_FALSE;
+ }
+
+ TRACE_H264("CDXVADecoderH264::DecodeFrame() : nFramePOC = %11d, nOutPOC = %11d[%11d], [%d - %d], rtOutStart = [%20I64d]\n", nFramePOC, nOutPOC, m_nOutPOC, m_DXVAPicParams.field_pic_flag, m_DXVAPicParams.RefPicFlag, rtOutStart);
+
+ // Wait I frame after a flush
+ if (m_bFlushed && !m_DXVAPicParams.IntraPicFlag) {
+ TRACE_H264("CDXVADecoderH264::DecodeFrame() : Flush - wait I frame\n");
+ m_nBrokenFramesFlag = 0;
+ m_nBrokenFramesFlag_POC = 0;
+ m_nfield_pic_flag = m_DXVAPicParams.field_pic_flag;
+ m_nRefPicFlag = m_DXVAPicParams.RefPicFlag;
+ m_nPrevOutPOC = INT_MIN;
+ return S_FALSE;
+ }
+
+ // Some magic code for detecting the incorrect decoding of interlaced frames ...
+ // TODO : necessary to make it better, and preferably on the side of ffmpeg ...
+ if (m_nfield_pic_flag && m_nfield_pic_flag == m_DXVAPicParams.field_pic_flag && m_nRefPicFlag == m_DXVAPicParams.RefPicFlag) {
+ if (m_nPrevOutPOC == m_nOutPOC && m_nOutPOC == INT_MIN) {
+ m_nBrokenFramesFlag_POC++;
+ }
+ m_nBrokenFramesFlag++;
+ } else {
+ m_nBrokenFramesFlag = 0;
+ m_nBrokenFramesFlag_POC = 0;
+ }
+ m_nfield_pic_flag = m_DXVAPicParams.field_pic_flag;
+ m_nRefPicFlag = m_DXVAPicParams.RefPicFlag;
+ m_nPrevOutPOC = m_nOutPOC;
+
+ if (m_nBrokenFramesFlag > 4) {
+ m_nBrokenFramesFlag = 0;
+ if (m_nBrokenFramesFlag_POC > 1) {
+ TRACE_H264("CDXVADecoderH264::DecodeFrame() : Detected broken frames ... flush data\n");
+ m_nBrokenFramesFlag_POC = 0;
+ Flush();
+ return S_FALSE;
+ }
+ }
+ //
+
+ CHECK_HR(GetFreeSurfaceIndex(nSurfaceIndex, &pSampleToDeliver, rtStart, rtStop));
+ FFH264SetCurrentPicture(nSurfaceIndex, &m_DXVAPicParams, m_pFilter->GetAVCtx());
+
+ CHECK_HR(BeginFrame(nSurfaceIndex, pSampleToDeliver));
+
+ m_DXVAPicParams.StatusReportFeedbackNumber++;
+
+ // Send picture parameters
+ CHECK_HR(AddExecuteBuffer(DXVA2_PictureParametersBufferType, sizeof(m_DXVAPicParams), &m_DXVAPicParams));
+ CHECK_HR(Execute());
+
+ // Add bitstream, slice control and quantization matrix
+ CHECK_HR(AddExecuteBuffer(DXVA2_BitStreamDateBufferType, nSize, pDataIn, &nSize));
+
+ if (m_bUseLongSlice) {
+ CHECK_HR(AddExecuteBuffer(DXVA2_SliceControlBufferType, sizeof(DXVA_Slice_H264_Long)*nSlices, m_pSliceLong));
+ } else {
+ CHECK_HR(AddExecuteBuffer(DXVA2_SliceControlBufferType, sizeof(DXVA_Slice_H264_Short)*nSlices, m_pSliceShort));
+ }
+
+ CHECK_HR(AddExecuteBuffer(DXVA2_InverseQuantizationMatrixBufferType, sizeof(DXVA_Qmatrix_H264), (void*)&m_DXVAScalingMatrix));
+
+ // Decode bitstream
+ CHECK_HR(Execute());
+
+ CHECK_HR(EndFrame(nSurfaceIndex));
#if defined(_DEBUG) && 0
- DisplayStatus();
+ DisplayStatus();
#endif
- bool bAdded = AddToStore (nSurfaceIndex, pSampleToDeliver, m_DXVAPicParams.RefPicFlag, rtStart, rtStop,
- m_DXVAPicParams.field_pic_flag, (FF_FIELD_TYPE)nFieldType,
- (FF_SLICE_TYPE)nSliceType, nFramePOC);
+ bool bAdded = AddToStore(nSurfaceIndex, pSampleToDeliver, m_DXVAPicParams.RefPicFlag, rtStart, rtStop,
+ m_DXVAPicParams.field_pic_flag, (FF_FIELD_TYPE)nFieldType,
+ (FF_SLICE_TYPE)nSliceType, nFramePOC);
- FFH264UpdateRefFramesList (&m_DXVAPicParams, m_pFilter->GetAVCtx());
- ClearUnusedRefFrames();
+ FFH264UpdateRefFramesList(&m_DXVAPicParams, m_pFilter->GetAVCtx());
+ ClearUnusedRefFrames();
- if (bAdded) {
- hr = DisplayNextFrame();
- }
+ if (bAdded) {
+ hr = DisplayNextFrame();
+ }
- if (nOutPOC != INT_MIN) {
- m_nOutPOC = nOutPOC;
- m_rtOutStart = rtOutStart;
- }
+ if (nOutPOC != INT_MIN) {
+ m_nOutPOC = nOutPOC;
+ m_rtOutStart = rtOutStart;
+ }
- m_bFlushed = false;
- return hr;
+ m_bFlushed = false;
+ return hr;
}
void CDXVADecoderH264::RemoveUndisplayedFrame(int nPOC)
{
- // Find frame with given POC, and free the slot
- for (int i=0; i<m_nPicEntryNumber; i++) {
- if (m_pPictureStore[i].bInUse && m_pPictureStore[i].nCodecSpecific == nPOC) {
- m_pPictureStore[i].bDisplayed = true;
- RemoveRefFrame (i);
- return;
- }
- }
+ // Find frame with given POC, and free the slot
+ for (int i = 0; i < m_nPicEntryNumber; i++) {
+ if (m_pPictureStore[i].bInUse && m_pPictureStore[i].nCodecSpecific == nPOC) {
+ m_pPictureStore[i].bDisplayed = true;
+ RemoveRefFrame(i);
+ return;
+ }
+ }
}
void CDXVADecoderH264::ClearUnusedRefFrames()
{
- // Remove old reference frames (not anymore a short or long ref frame)
- for (int i=0; i<m_nPicEntryNumber; i++) {
- if (m_pPictureStore[i].bRefPicture && m_pPictureStore[i].bDisplayed) {
- if (!FFH264IsRefFrameInUse (i, m_pFilter->GetAVCtx())) {
- RemoveRefFrame (i);
- }
- }
- }
+ // Remove old reference frames (not anymore a short or long ref frame)
+ for (int i = 0; i < m_nPicEntryNumber; i++) {
+ if (m_pPictureStore[i].bRefPicture && m_pPictureStore[i].bDisplayed) {
+ if (!FFH264IsRefFrameInUse(i, m_pFilter->GetAVCtx())) {
+ RemoveRefFrame(i);
+ }
+ }
+ }
}
-void CDXVADecoderH264::SetExtraData (BYTE* pDataIn, UINT nSize)
+void CDXVADecoderH264::SetExtraData(BYTE* pDataIn, UINT nSize)
{
- AVCodecContext* pAVCtx = m_pFilter->GetAVCtx();
- m_nNALLength = pAVCtx->nal_length_size;
+ AVCodecContext* pAVCtx = m_pFilter->GetAVCtx();
+ m_nNALLength = pAVCtx->nal_length_size;
- FFH264DecodeBuffer (pAVCtx, pDataIn, nSize, NULL, NULL, NULL);
- FFH264SetDxvaSliceLong (pAVCtx, m_pSliceLong);
+ FFH264DecodeBuffer(pAVCtx, pDataIn, nSize, NULL, NULL, NULL);
+ FFH264SetDxvaSliceLong(pAVCtx, m_pSliceLong);
}
void CDXVADecoderH264::ClearRefFramesList()
{
- for (int i=0; i<m_nPicEntryNumber; i++) {
- if (m_pPictureStore[i].bInUse) {
- m_pPictureStore[i].bDisplayed = true;
- RemoveRefFrame (i);
- }
- }
+ for (int i = 0; i < m_nPicEntryNumber; i++) {
+ if (m_pPictureStore[i].bInUse) {
+ m_pPictureStore[i].bDisplayed = true;
+ RemoveRefFrame(i);
+ }
+ }
}
HRESULT CDXVADecoderH264::DisplayStatus()
{
- HRESULT hr = E_INVALIDARG;
- DXVA_Status_H264 Status;
+ HRESULT hr = E_INVALIDARG;
+ DXVA_Status_H264 Status;
- memset (&Status, 0, sizeof(Status));
- CHECK_HR (hr = CDXVADecoder::QueryStatus(&Status, sizeof(Status)));
+ memset(&Status, 0, sizeof(Status));
+ CHECK_HR(hr = CDXVADecoder::QueryStatus(&Status, sizeof(Status)));
- TRACE_H264 ("CDXVADecoderH264::DisplayStatus() : Status for the frame %u : bBufType = %u, bStatus = %u, wNumMbsAffected = %u\n",
- Status.StatusReportFeedbackNumber,
- Status.bBufType,
- Status.bStatus,
- Status.wNumMbsAffected);
+ TRACE_H264("CDXVADecoderH264::DisplayStatus() : Status for the frame %u : bBufType = %u, bStatus = %u, wNumMbsAffected = %u\n",
+ Status.StatusReportFeedbackNumber,
+ Status.bBufType,
+ Status.bStatus,
+ Status.wNumMbsAffected);
- return hr;
+ return hr;
}
int CDXVADecoderH264::FindOldestFrame()
{
- int nPos = -1;
- REFERENCE_TIME rtPos = _I64_MAX;
-
- for (int i=0; i<m_nPicEntryNumber; i++) {
- if (m_pPictureStore[i].bInUse && !m_pPictureStore[i].bDisplayed) {
- if ((m_pPictureStore[i].nCodecSpecific == m_nOutPOC) && (m_pPictureStore[i].rtStart < rtPos) && (m_pPictureStore[i].rtStart >= m_rtOutStart)) {
- nPos = i;
- rtPos = m_pPictureStore[i].rtStart;
- }
- }
- }
-
- if (nPos != -1) {
- m_pPictureStore[nPos].rtStart = m_rtOutStart;
- m_pFilter->UpdateFrameTime(m_pPictureStore[nPos].rtStart, m_pPictureStore[nPos].rtStop);
- m_pFilter->ReorderBFrames (m_pPictureStore[nPos].rtStart, m_pPictureStore[nPos].rtStop);
- }
-
- return nPos;
+ int nPos = -1;
+ REFERENCE_TIME rtPos = _I64_MAX;
+
+ for (int i = 0; i < m_nPicEntryNumber; i++) {
+ if (m_pPictureStore[i].bInUse && !m_pPictureStore[i].bDisplayed) {
+ if ((m_pPictureStore[i].nCodecSpecific == m_nOutPOC) && (m_pPictureStore[i].rtStart < rtPos) && (m_pPictureStore[i].rtStart >= m_rtOutStart)) {
+ nPos = i;
+ rtPos = m_pPictureStore[i].rtStart;
+ }
+ }
+ }
+
+ if (nPos != -1) {
+ m_pPictureStore[nPos].rtStart = m_rtOutStart;
+ m_pFilter->UpdateFrameTime(m_pPictureStore[nPos].rtStart, m_pPictureStore[nPos].rtStop);
+ m_pFilter->ReorderBFrames(m_pPictureStore[nPos].rtStart, m_pPictureStore[nPos].rtStop);
+ }
+
+ return nPos;
}
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderH264.h b/src/filters/transform/MPCVideoDec/DXVADecoderH264.h
index 1f5bd1091..7d00093f0 100644
--- a/src/filters/transform/MPCVideoDec/DXVADecoderH264.h
+++ b/src/filters/transform/MPCVideoDec/DXVADecoderH264.h
@@ -26,45 +26,45 @@
#include <dxva.h>
#include "DXVADecoder.h"
-#define MAX_SLICES 16 // Also defined in libavcodec/h264.h
+#define MAX_SLICES 16 // Also defined in libavcodec/h264.h
class CDXVADecoderH264 : public CDXVADecoder
{
public:
- CDXVADecoderH264 (CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber);
- CDXVADecoderH264 (CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config);
- virtual ~CDXVADecoderH264();
+ CDXVADecoderH264(CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber);
+ CDXVADecoderH264(CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config);
+ virtual ~CDXVADecoderH264();
- virtual HRESULT DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
- virtual void SetExtraData (BYTE* pDataIn, UINT nSize);
- virtual void CopyBitstream (BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize);
- virtual void Flush();
+ virtual HRESULT DecodeFrame(BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
+ virtual void SetExtraData(BYTE* pDataIn, UINT nSize);
+ virtual void CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize);
+ virtual void Flush();
protected :
- virtual int FindOldestFrame();
+ virtual int FindOldestFrame();
private:
- DXVA_PicParams_H264 m_DXVAPicParams;
- DXVA_Qmatrix_H264 m_DXVAScalingMatrix;
- DXVA_Slice_H264_Short m_pSliceShort[MAX_SLICES];
- DXVA_Slice_H264_Long m_pSliceLong[MAX_SLICES];
- UINT m_nMaxSlices;
- int m_nNALLength;
- bool m_bUseLongSlice;
- int m_nOutPOC, m_nPrevOutPOC;
- REFERENCE_TIME m_rtOutStart;
+ DXVA_PicParams_H264 m_DXVAPicParams;
+ DXVA_Qmatrix_H264 m_DXVAScalingMatrix;
+ DXVA_Slice_H264_Short m_pSliceShort[MAX_SLICES];
+ DXVA_Slice_H264_Long m_pSliceLong[MAX_SLICES];
+ UINT m_nMaxSlices;
+ int m_nNALLength;
+ bool m_bUseLongSlice;
+ int m_nOutPOC, m_nPrevOutPOC;
+ REFERENCE_TIME m_rtOutStart;
- USHORT m_nfield_pic_flag;
- USHORT m_nRefPicFlag;
- UINT m_nBrokenFramesFlag, m_nBrokenFramesFlag_POC;
+ USHORT m_nfield_pic_flag;
+ USHORT m_nRefPicFlag;
+ UINT m_nBrokenFramesFlag, m_nBrokenFramesFlag_POC;
- // Private functions
- void Init();
- HRESULT DisplayStatus();
+ // Private functions
+ void Init();
+ HRESULT DisplayStatus();
- // DXVA functions
- void RemoveUndisplayedFrame(int nPOC);
- void ClearRefFramesList();
- void ClearUnusedRefFrames();
+ // DXVA functions
+ void RemoveUndisplayedFrame(int nPOC);
+ void ClearRefFramesList();
+ void ClearUnusedRefFrames();
};
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.cpp b/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.cpp
index 7f21aa75e..0bc11ae2d 100644
--- a/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.cpp
+++ b/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.cpp
@@ -32,252 +32,252 @@
#define TRACE_MPEG2(...)
#endif
-CDXVADecoderMpeg2::CDXVADecoderMpeg2 (CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber)
- : CDXVADecoder (pFilter, pAMVideoAccelerator, nMode, nPicEntryNumber)
+CDXVADecoderMpeg2::CDXVADecoderMpeg2(CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber)
+ : CDXVADecoder(pFilter, pAMVideoAccelerator, nMode, nPicEntryNumber)
{
- Init();
+ Init();
}
-CDXVADecoderMpeg2::CDXVADecoderMpeg2 (CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config)
- : CDXVADecoder (pFilter, pDirectXVideoDec, nMode, nPicEntryNumber, pDXVA2Config)
+CDXVADecoderMpeg2::CDXVADecoderMpeg2(CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config)
+ : CDXVADecoder(pFilter, pDirectXVideoDec, nMode, nPicEntryNumber, pDXVA2Config)
{
- Init();
+ Init();
}
CDXVADecoderMpeg2::~CDXVADecoderMpeg2(void)
{
- Flush();
+ Flush();
}
void CDXVADecoderMpeg2::Init()
{
- memset (&m_PictureParams, 0, sizeof(m_PictureParams));
- memset (&m_SliceInfo, 0, sizeof(m_SliceInfo));
- memset (&m_QMatrixData, 0, sizeof(m_QMatrixData));
-
- m_nMaxWaiting = 5;
- m_wRefPictureIndex[0] = NO_REF_FRAME;
- m_wRefPictureIndex[1] = NO_REF_FRAME;
- m_nSliceCount = 0;
-
- switch (GetMode()) {
- case MPEG2_VLD :
- AllocExecuteParams (4);
- break;
- default :
- ASSERT(FALSE);
- }
+ memset(&m_PictureParams, 0, sizeof(m_PictureParams));
+ memset(&m_SliceInfo, 0, sizeof(m_SliceInfo));
+ memset(&m_QMatrixData, 0, sizeof(m_QMatrixData));
+
+ m_nMaxWaiting = 5;
+ m_wRefPictureIndex[0] = NO_REF_FRAME;
+ m_wRefPictureIndex[1] = NO_REF_FRAME;
+ m_nSliceCount = 0;
+
+ switch (GetMode()) {
+ case MPEG2_VLD :
+ AllocExecuteParams(4);
+ break;
+ default :
+ ASSERT(FALSE);
+ }
}
// === Public functions
-HRESULT CDXVADecoderMpeg2::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
+HRESULT CDXVADecoderMpeg2::DecodeFrame(BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
{
- HRESULT hr;
- int nFieldType;
- int nSliceType;
-
- FFMpeg2DecodeFrame (&m_PictureParams, &m_QMatrixData, m_SliceInfo, &m_nSliceCount, m_pFilter->GetAVCtx(),
- m_pFilter->GetFrame(), &m_nNextCodecIndex, &nFieldType, &nSliceType, pDataIn, nSize);
-
- if (m_PictureParams.bSecondField && !m_bSecondField) {
- m_bSecondField = true;
- }
-
- // Wait I frame after a flush
- if (m_bFlushed && (!m_PictureParams.bPicIntra || (m_bSecondField && m_PictureParams.bSecondField))) {
- TRACE_MPEG2 ("CDXVADecoderMpeg2::DecodeFrame() : Flush - wait I frame\n");
- return S_FALSE;
- }
-
- if (m_bSecondField) {
- if (!m_PictureParams.bSecondField) {
- m_rtStart = rtStart;
- m_rtStop = rtStop;
- m_pSampleToDeliver = NULL;
- hr = GetFreeSurfaceIndex (m_nSurfaceIndex, &m_pSampleToDeliver, rtStart, rtStop);
- if (FAILED (hr)) {
- ASSERT (hr == VFW_E_NOT_COMMITTED); // Normal when stop playing
- return hr;
- }
- }
- } else {
- m_rtStart = rtStart;
- m_rtStop = rtStop;
- m_pSampleToDeliver = NULL;
- hr = GetFreeSurfaceIndex (m_nSurfaceIndex, &m_pSampleToDeliver, rtStart, rtStop);
- if (FAILED (hr)) {
- ASSERT (hr == VFW_E_NOT_COMMITTED); // Normal when stop playing
- return hr;
- }
- }
-
- if (m_pSampleToDeliver == NULL) {
- return S_FALSE;
- }
-
- CHECK_HR (BeginFrame(m_nSurfaceIndex, m_pSampleToDeliver));
-
- if (m_bSecondField) {
- if (!m_PictureParams.bSecondField) {
- UpdatePictureParams(m_nSurfaceIndex);
- }
- } else {
- UpdatePictureParams(m_nSurfaceIndex);
- }
-
- TRACE_MPEG2 ("CDXVADecoderMpeg2::DecodeFrame() : Surf = %d, PictureType = %d, SecondField = %d, m_nNextCodecIndex = %d, rtStart = [%I64d]\n", m_nSurfaceIndex, nSliceType, m_PictureParams.bSecondField, m_nNextCodecIndex, rtStart);
-
- CHECK_HR (AddExecuteBuffer (DXVA2_PictureParametersBufferType, sizeof(m_PictureParams), &m_PictureParams));
-
- CHECK_HR (AddExecuteBuffer (DXVA2_InverseQuantizationMatrixBufferType, sizeof(m_QMatrixData), &m_QMatrixData));
-
- // Send bitstream to accelerator
- CHECK_HR (AddExecuteBuffer (DXVA2_SliceControlBufferType, sizeof (DXVA_SliceInfo)*m_nSliceCount, &m_SliceInfo));
- CHECK_HR (AddExecuteBuffer (DXVA2_BitStreamDateBufferType, nSize, pDataIn, &nSize));
-
- // Decode frame
- CHECK_HR (Execute());
- CHECK_HR (EndFrame(m_nSurfaceIndex));
-
- if (m_bSecondField) {
- if (m_PictureParams.bSecondField) {
- AddToStore (m_nSurfaceIndex, m_pSampleToDeliver, (m_PictureParams.bPicBackwardPrediction != 1), m_rtStart, m_rtStop,
- false, (FF_FIELD_TYPE)nFieldType, (FF_SLICE_TYPE)nSliceType, FFGetCodedPicture(m_pFilter->GetAVCtx()));
- hr = DisplayNextFrame();
- }
- } else {
- AddToStore (m_nSurfaceIndex, m_pSampleToDeliver, (m_PictureParams.bPicBackwardPrediction != 1), m_rtStart, m_rtStop,
- false, (FF_FIELD_TYPE)nFieldType, (FF_SLICE_TYPE)nSliceType, FFGetCodedPicture(m_pFilter->GetAVCtx()));
- hr = DisplayNextFrame();
- }
-
- m_bFlushed = false;
-
- return hr;
+ HRESULT hr;
+ int nFieldType;
+ int nSliceType;
+
+ FFMpeg2DecodeFrame(&m_PictureParams, &m_QMatrixData, m_SliceInfo, &m_nSliceCount, m_pFilter->GetAVCtx(),
+ m_pFilter->GetFrame(), &m_nNextCodecIndex, &nFieldType, &nSliceType, pDataIn, nSize);
+
+ if (m_PictureParams.bSecondField && !m_bSecondField) {
+ m_bSecondField = true;
+ }
+
+ // Wait I frame after a flush
+ if (m_bFlushed && (!m_PictureParams.bPicIntra || (m_bSecondField && m_PictureParams.bSecondField))) {
+ TRACE_MPEG2("CDXVADecoderMpeg2::DecodeFrame() : Flush - wait I frame\n");
+ return S_FALSE;
+ }
+
+ if (m_bSecondField) {
+ if (!m_PictureParams.bSecondField) {
+ m_rtStart = rtStart;
+ m_rtStop = rtStop;
+ m_pSampleToDeliver = NULL;
+ hr = GetFreeSurfaceIndex(m_nSurfaceIndex, &m_pSampleToDeliver, rtStart, rtStop);
+ if (FAILED(hr)) {
+ ASSERT(hr == VFW_E_NOT_COMMITTED); // Normal when stop playing
+ return hr;
+ }
+ }
+ } else {
+ m_rtStart = rtStart;
+ m_rtStop = rtStop;
+ m_pSampleToDeliver = NULL;
+ hr = GetFreeSurfaceIndex(m_nSurfaceIndex, &m_pSampleToDeliver, rtStart, rtStop);
+ if (FAILED(hr)) {
+ ASSERT(hr == VFW_E_NOT_COMMITTED); // Normal when stop playing
+ return hr;
+ }
+ }
+
+ if (m_pSampleToDeliver == NULL) {
+ return S_FALSE;
+ }
+
+ CHECK_HR(BeginFrame(m_nSurfaceIndex, m_pSampleToDeliver));
+
+ if (m_bSecondField) {
+ if (!m_PictureParams.bSecondField) {
+ UpdatePictureParams(m_nSurfaceIndex);
+ }
+ } else {
+ UpdatePictureParams(m_nSurfaceIndex);
+ }
+
+ TRACE_MPEG2("CDXVADecoderMpeg2::DecodeFrame() : Surf = %d, PictureType = %d, SecondField = %d, m_nNextCodecIndex = %d, rtStart = [%I64d]\n", m_nSurfaceIndex, nSliceType, m_PictureParams.bSecondField, m_nNextCodecIndex, rtStart);
+
+ CHECK_HR(AddExecuteBuffer(DXVA2_PictureParametersBufferType, sizeof(m_PictureParams), &m_PictureParams));
+
+ CHECK_HR(AddExecuteBuffer(DXVA2_InverseQuantizationMatrixBufferType, sizeof(m_QMatrixData), &m_QMatrixData));
+
+ // Send bitstream to accelerator
+ CHECK_HR(AddExecuteBuffer(DXVA2_SliceControlBufferType, sizeof(DXVA_SliceInfo)*m_nSliceCount, &m_SliceInfo));
+ CHECK_HR(AddExecuteBuffer(DXVA2_BitStreamDateBufferType, nSize, pDataIn, &nSize));
+
+ // Decode frame
+ CHECK_HR(Execute());
+ CHECK_HR(EndFrame(m_nSurfaceIndex));
+
+ if (m_bSecondField) {
+ if (m_PictureParams.bSecondField) {
+ AddToStore(m_nSurfaceIndex, m_pSampleToDeliver, (m_PictureParams.bPicBackwardPrediction != 1), m_rtStart, m_rtStop,
+ false, (FF_FIELD_TYPE)nFieldType, (FF_SLICE_TYPE)nSliceType, FFGetCodedPicture(m_pFilter->GetAVCtx()));
+ hr = DisplayNextFrame();
+ }
+ } else {
+ AddToStore(m_nSurfaceIndex, m_pSampleToDeliver, (m_PictureParams.bPicBackwardPrediction != 1), m_rtStart, m_rtStop,
+ false, (FF_FIELD_TYPE)nFieldType, (FF_SLICE_TYPE)nSliceType, FFGetCodedPicture(m_pFilter->GetAVCtx()));
+ hr = DisplayNextFrame();
+ }
+
+ m_bFlushed = false;
+
+ return hr;
}
void CDXVADecoderMpeg2::UpdatePictureParams(int nSurfaceIndex)
{
- DXVA2_ConfigPictureDecode* cpd = GetDXVA2Config(); // Ok for DXVA1 too (parameters have been copied)
-
- m_PictureParams.wDecodedPictureIndex = nSurfaceIndex;
-
- // Manage reference picture list
- if (!m_PictureParams.bPicBackwardPrediction) {
- if (m_wRefPictureIndex[0] != NO_REF_FRAME) {
- RemoveRefFrame (m_wRefPictureIndex[0]);
- }
- m_wRefPictureIndex[0] = m_wRefPictureIndex[1];
- m_wRefPictureIndex[1] = nSurfaceIndex;
- }
- m_PictureParams.wForwardRefPictureIndex = (m_PictureParams.bPicIntra == 0) ? m_wRefPictureIndex[0] : NO_REF_FRAME;
- m_PictureParams.wBackwardRefPictureIndex = (m_PictureParams.bPicBackwardPrediction == 1) ? m_wRefPictureIndex[1] : NO_REF_FRAME;
-
- // Shall be 0 if bConfigResidDiffHost is 0 or if BPP > 8
- if (cpd->ConfigResidDiffHost == 0 || m_PictureParams.bBPPminus1 > 7) {
- m_PictureParams.bPicSpatialResid8 = 0;
- } else {
- if (m_PictureParams.bBPPminus1 == 7 && m_PictureParams.bPicIntra && cpd->ConfigResidDiffHost)
- // Shall be 1 if BPP is 8 and bPicIntra is 1 and bConfigResidDiffHost is 1
- {
- m_PictureParams.bPicSpatialResid8 = 1;
- } else
- // Shall be 1 if bConfigSpatialResid8 is 1
- {
- m_PictureParams.bPicSpatialResid8 = cpd->ConfigSpatialResid8;
- }
- }
-
- // Shall be 0 if bConfigResidDiffHost is 0 or if bConfigSpatialResid8 is 0 or if BPP > 8
- if (cpd->ConfigResidDiffHost == 0 || cpd->ConfigSpatialResid8 == 0 || m_PictureParams.bBPPminus1 > 7) {
- m_PictureParams.bPicOverflowBlocks = 0;
- }
-
- // Shall be 1 if bConfigHostInverseScan is 1 or if bConfigResidDiffAccelerator is 0.
-
- if (cpd->ConfigHostInverseScan == 1 || cpd->ConfigResidDiffAccelerator == 0) {
- m_PictureParams.bPicScanFixed = 1;
-
- if (cpd->ConfigHostInverseScan != 0) {
- m_PictureParams.bPicScanMethod = 3; // 11 = Arbitrary scan with absolute coefficient address.
- } else if (FFGetAlternateScan(m_pFilter->GetAVCtx())) {
- m_PictureParams.bPicScanMethod = 1; // 00 = Zig-zag scan (MPEG-2 Figure 7-2)
- } else {
- m_PictureParams.bPicScanMethod = 0; // 01 = Alternate-vertical (MPEG-2 Figure 7-3),
- }
- }
+ DXVA2_ConfigPictureDecode* cpd = GetDXVA2Config(); // Ok for DXVA1 too (parameters have been copied)
+
+ m_PictureParams.wDecodedPictureIndex = nSurfaceIndex;
+
+ // Manage reference picture list
+ if (!m_PictureParams.bPicBackwardPrediction) {
+ if (m_wRefPictureIndex[0] != NO_REF_FRAME) {
+ RemoveRefFrame(m_wRefPictureIndex[0]);
+ }
+ m_wRefPictureIndex[0] = m_wRefPictureIndex[1];
+ m_wRefPictureIndex[1] = nSurfaceIndex;
+ }
+ m_PictureParams.wForwardRefPictureIndex = (m_PictureParams.bPicIntra == 0) ? m_wRefPictureIndex[0] : NO_REF_FRAME;
+ m_PictureParams.wBackwardRefPictureIndex = (m_PictureParams.bPicBackwardPrediction == 1) ? m_wRefPictureIndex[1] : NO_REF_FRAME;
+
+ // Shall be 0 if bConfigResidDiffHost is 0 or if BPP > 8
+ if (cpd->ConfigResidDiffHost == 0 || m_PictureParams.bBPPminus1 > 7) {
+ m_PictureParams.bPicSpatialResid8 = 0;
+ } else {
+ if (m_PictureParams.bBPPminus1 == 7 && m_PictureParams.bPicIntra && cpd->ConfigResidDiffHost)
+ // Shall be 1 if BPP is 8 and bPicIntra is 1 and bConfigResidDiffHost is 1
+ {
+ m_PictureParams.bPicSpatialResid8 = 1;
+ } else
+ // Shall be 1 if bConfigSpatialResid8 is 1
+ {
+ m_PictureParams.bPicSpatialResid8 = cpd->ConfigSpatialResid8;
+ }
+ }
+
+ // Shall be 0 if bConfigResidDiffHost is 0 or if bConfigSpatialResid8 is 0 or if BPP > 8
+ if (cpd->ConfigResidDiffHost == 0 || cpd->ConfigSpatialResid8 == 0 || m_PictureParams.bBPPminus1 > 7) {
+ m_PictureParams.bPicOverflowBlocks = 0;
+ }
+
+ // Shall be 1 if bConfigHostInverseScan is 1 or if bConfigResidDiffAccelerator is 0.
+
+ if (cpd->ConfigHostInverseScan == 1 || cpd->ConfigResidDiffAccelerator == 0) {
+ m_PictureParams.bPicScanFixed = 1;
+
+ if (cpd->ConfigHostInverseScan != 0) {
+ m_PictureParams.bPicScanMethod = 3; // 11 = Arbitrary scan with absolute coefficient address.
+ } else if (FFGetAlternateScan(m_pFilter->GetAVCtx())) {
+ m_PictureParams.bPicScanMethod = 1; // 00 = Zig-zag scan (MPEG-2 Figure 7-2)
+ } else {
+ m_PictureParams.bPicScanMethod = 0; // 01 = Alternate-vertical (MPEG-2 Figure 7-3),
+ }
+ }
}
void CDXVADecoderMpeg2::CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize)
{
- while (*((DWORD*)pBuffer) != 0x01010000) {
- pBuffer++;
- nSize--;
+ while (*((DWORD*)pBuffer) != 0x01010000) {
+ pBuffer++;
+ nSize--;
- if (nSize <= 0) {
- return;
- }
- }
+ if (nSize <= 0) {
+ return;
+ }
+ }
- memcpy (pDXVABuffer, pBuffer, nSize);
+ memcpy(pDXVABuffer, pBuffer, nSize);
}
void CDXVADecoderMpeg2::Flush()
{
- m_nNextCodecIndex = INT_MIN;
+ m_nNextCodecIndex = INT_MIN;
- if (m_wRefPictureIndex[0] != NO_REF_FRAME) {
- RemoveRefFrame (m_wRefPictureIndex[0]);
- }
- if (m_wRefPictureIndex[1] != NO_REF_FRAME) {
- RemoveRefFrame (m_wRefPictureIndex[1]);
- }
+ if (m_wRefPictureIndex[0] != NO_REF_FRAME) {
+ RemoveRefFrame(m_wRefPictureIndex[0]);
+ }
+ if (m_wRefPictureIndex[1] != NO_REF_FRAME) {
+ RemoveRefFrame(m_wRefPictureIndex[1]);
+ }
- m_wRefPictureIndex[0] = NO_REF_FRAME;
- m_wRefPictureIndex[1] = NO_REF_FRAME;
+ m_wRefPictureIndex[0] = NO_REF_FRAME;
+ m_wRefPictureIndex[1] = NO_REF_FRAME;
- m_nSurfaceIndex = 0;
- m_pSampleToDeliver = NULL;
- m_bSecondField = false;
+ m_nSurfaceIndex = 0;
+ m_pSampleToDeliver = NULL;
+ m_bSecondField = false;
- m_rtStart = _I64_MIN;
- m_rtStop = _I64_MIN;
+ m_rtStart = _I64_MIN;
+ m_rtStop = _I64_MIN;
- m_rtLastStart = 0;
+ m_rtLastStart = 0;
- __super::Flush();
+ __super::Flush();
}
int CDXVADecoderMpeg2::FindOldestFrame()
{
- int nPos = -1;
-
- for (int i=0; i<m_nPicEntryNumber; i++) {
- if (!m_pPictureStore[i].bDisplayed &&
- m_pPictureStore[i].bInUse &&
- (m_pPictureStore[i].nCodecSpecific == m_nNextCodecIndex)) {
- m_nNextCodecIndex = INT_MIN;
- nPos = i;
- }
- }
-
- if (nPos != -1) {
- UpdateFrameTime(m_pPictureStore[nPos].rtStart, m_pPictureStore[nPos].rtStop);
- }
-
- return nPos;
+ int nPos = -1;
+
+ for (int i = 0; i < m_nPicEntryNumber; i++) {
+ if (!m_pPictureStore[i].bDisplayed &&
+ m_pPictureStore[i].bInUse &&
+ (m_pPictureStore[i].nCodecSpecific == m_nNextCodecIndex)) {
+ m_nNextCodecIndex = INT_MIN;
+ nPos = i;
+ }
+ }
+
+ if (nPos != -1) {
+ UpdateFrameTime(m_pPictureStore[nPos].rtStart, m_pPictureStore[nPos].rtStop);
+ }
+
+ return nPos;
}
-void CDXVADecoderMpeg2::UpdateFrameTime (REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop)
+void CDXVADecoderMpeg2::UpdateFrameTime(REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop)
{
- TRACE(_T("\n\nrtStart = [%10I64d - %10I64d] // "), rtStart, rtStop);
+ TRACE(_T("\n\nrtStart = [%10I64d - %10I64d] // "), rtStart, rtStop);
- if (m_rtLastStart && (rtStart == _I64_MIN || (rtStart < m_rtLastStart))) {
- rtStart = m_rtLastStart;
- }
+ if (m_rtLastStart && (rtStart == _I64_MIN || (rtStart < m_rtLastStart))) {
+ rtStart = m_rtLastStart;
+ }
- rtStop = rtStart + m_pFilter->GetAvrTimePerFrame() / m_pFilter->GetRate();
- m_rtLastStart = rtStop;
+ rtStop = rtStart + m_pFilter->GetAvrTimePerFrame() / m_pFilter->GetRate();
+ m_rtLastStart = rtStop;
- TRACE(_T("rtStart = [%10I64d - %10I64d]\n"), rtStart, rtStop);
+ TRACE(_T("rtStart = [%10I64d - %10I64d]\n"), rtStart, rtStop);
}
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.h b/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.h
index fa766a661..f50575fb1 100644
--- a/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.h
+++ b/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.h
@@ -26,41 +26,41 @@
#include <dxva.h>
#include "DXVADecoder.h"
-#define MAX_SLICE 1024 // Max slice number for Mpeg2 streams
+#define MAX_SLICE 1024 // Max slice number for Mpeg2 streams
-class CDXVADecoderMpeg2 : public CDXVADecoder
+class CDXVADecoderMpeg2 : public CDXVADecoder
{
public:
- CDXVADecoderMpeg2 (CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber);
- CDXVADecoderMpeg2 (CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config);
- virtual ~CDXVADecoderMpeg2(void);
+ CDXVADecoderMpeg2(CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber);
+ CDXVADecoderMpeg2(CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config);
+ virtual ~CDXVADecoderMpeg2(void);
- // === Public functions
- virtual HRESULT DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
- virtual void CopyBitstream (BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize);
- virtual void Flush();
+ // === Public functions
+ virtual HRESULT DecodeFrame(BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
+ virtual void CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize);
+ virtual void Flush();
protected :
- virtual int FindOldestFrame();
+ virtual int FindOldestFrame();
private:
- DXVA_PictureParameters m_PictureParams;
- DXVA_QmatrixData m_QMatrixData;
- WORD m_wRefPictureIndex[2];
- DXVA_SliceInfo m_SliceInfo[MAX_SLICE];
- int m_nSliceCount;
+ DXVA_PictureParameters m_PictureParams;
+ DXVA_QmatrixData m_QMatrixData;
+ WORD m_wRefPictureIndex[2];
+ DXVA_SliceInfo m_SliceInfo[MAX_SLICE];
+ int m_nSliceCount;
- int m_nNextCodecIndex;
+ int m_nNextCodecIndex;
- int m_nSurfaceIndex;
- CComPtr<IMediaSample> m_pSampleToDeliver;
- bool m_bSecondField;
- REFERENCE_TIME m_rtStart, m_rtStop;
+ int m_nSurfaceIndex;
+ CComPtr<IMediaSample> m_pSampleToDeliver;
+ bool m_bSecondField;
+ REFERENCE_TIME m_rtStart, m_rtStop;
- REFERENCE_TIME m_rtLastStart;
+ REFERENCE_TIME m_rtLastStart;
- // Private functions
- void Init();
- void UpdatePictureParams(int nSurfaceIndex);
- void UpdateFrameTime (REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
+ // Private functions
+ void Init();
+ void UpdatePictureParams(int nSurfaceIndex);
+ void UpdateFrameTime(REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
};
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderVC1.cpp b/src/filters/transform/MPCVideoDec/DXVADecoderVC1.cpp
index 0f05301e6..6996bccff 100644
--- a/src/filters/transform/MPCVideoDec/DXVADecoderVC1.cpp
+++ b/src/filters/transform/MPCVideoDec/DXVADecoderVC1.cpp
@@ -35,300 +35,300 @@
inline void SwapRT(REFERENCE_TIME& rtFirst, REFERENCE_TIME& rtSecond)
{
- REFERENCE_TIME rtTemp = rtFirst;
- rtFirst = rtSecond;
- rtSecond = rtTemp;
+ REFERENCE_TIME rtTemp = rtFirst;
+ rtFirst = rtSecond;
+ rtSecond = rtTemp;
}
-CDXVADecoderVC1::CDXVADecoderVC1 (CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber)
- : CDXVADecoder (pFilter, pAMVideoAccelerator, nMode, nPicEntryNumber)
+CDXVADecoderVC1::CDXVADecoderVC1(CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber)
+ : CDXVADecoder(pFilter, pAMVideoAccelerator, nMode, nPicEntryNumber)
{
- Init();
+ Init();
}
-CDXVADecoderVC1::CDXVADecoderVC1 (CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config)
- : CDXVADecoder (pFilter, pDirectXVideoDec, nMode, nPicEntryNumber, pDXVA2Config)
+CDXVADecoderVC1::CDXVADecoderVC1(CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config)
+ : CDXVADecoder(pFilter, pDirectXVideoDec, nMode, nPicEntryNumber, pDXVA2Config)
{
- Init();
+ Init();
}
CDXVADecoderVC1::~CDXVADecoderVC1(void)
{
- Flush();
+ Flush();
}
void CDXVADecoderVC1::Init()
{
- memset (&m_PictureParams, 0, sizeof(m_PictureParams));
- memset (&m_SliceInfo, 0, sizeof(m_SliceInfo));
-
- m_nMaxWaiting = 5;
- m_wRefPictureIndex[0] = NO_REF_FRAME;
- m_wRefPictureIndex[1] = NO_REF_FRAME;
-
- switch (GetMode()) {
- case VC1_VLD :
- AllocExecuteParams (3);
- break;
- default :
- ASSERT(FALSE);
- }
-
- m_bFrame_repeat_pict = FALSE;
+ memset(&m_PictureParams, 0, sizeof(m_PictureParams));
+ memset(&m_SliceInfo, 0, sizeof(m_SliceInfo));
+
+ m_nMaxWaiting = 5;
+ m_wRefPictureIndex[0] = NO_REF_FRAME;
+ m_wRefPictureIndex[1] = NO_REF_FRAME;
+
+ switch (GetMode()) {
+ case VC1_VLD :
+ AllocExecuteParams(3);
+ break;
+ default :
+ ASSERT(FALSE);
+ }
+
+ m_bFrame_repeat_pict = FALSE;
}
// === Public functions
-HRESULT CDXVADecoderVC1::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
+HRESULT CDXVADecoderVC1::DecodeFrame(BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
{
- HRESULT hr;
- int nSurfaceIndex;
- CComPtr<IMediaSample> pSampleToDeliver;
- int nFieldType, nSliceType;
- UINT nFrameSize, nSize_Result;
+ HRESULT hr;
+ int nSurfaceIndex;
+ CComPtr<IMediaSample> pSampleToDeliver;
+ int nFieldType, nSliceType;
+ UINT nFrameSize, nSize_Result;
- FFVC1UpdatePictureParam (&m_PictureParams, m_pFilter->GetAVCtx(), &nFieldType, &nSliceType, pDataIn, nSize, &nFrameSize, FALSE, &m_bFrame_repeat_pict);
+ FFVC1UpdatePictureParam(&m_PictureParams, m_pFilter->GetAVCtx(), &nFieldType, &nSliceType, pDataIn, nSize, &nFrameSize, FALSE, &m_bFrame_repeat_pict);
- if (FFIsSkipped (m_pFilter->GetAVCtx())) {
- return S_OK;
- }
+ if (FFIsSkipped(m_pFilter->GetAVCtx())) {
+ return S_OK;
+ }
- // Wait I frame after a flush
- if (m_bFlushed && ! m_PictureParams.bPicIntra) {
- return S_FALSE;
- }
+ // Wait I frame after a flush
+ if (m_bFlushed && ! m_PictureParams.bPicIntra) {
+ return S_FALSE;
+ }
- hr = GetFreeSurfaceIndex (nSurfaceIndex, &pSampleToDeliver, rtStart, rtStop);
- if (FAILED (hr)) {
- ASSERT (hr == VFW_E_NOT_COMMITTED); // Normal when stop playing
- return hr;
- }
+ hr = GetFreeSurfaceIndex(nSurfaceIndex, &pSampleToDeliver, rtStart, rtStop);
+ if (FAILED(hr)) {
+ ASSERT(hr == VFW_E_NOT_COMMITTED); // Normal when stop playing
+ return hr;
+ }
- CHECK_HR (BeginFrame(nSurfaceIndex, pSampleToDeliver));
+ CHECK_HR(BeginFrame(nSurfaceIndex, pSampleToDeliver));
- TRACE_VC1 ("CDXVADecoderVC1::DecodeFrame() : PictureType = %d, rtStart = %I64d, Surf = %d\n", nSliceType, rtStart, nSurfaceIndex);
+ TRACE_VC1("CDXVADecoderVC1::DecodeFrame() : PictureType = %d, rtStart = %I64d, Surf = %d\n", nSliceType, rtStart, nSurfaceIndex);
- m_PictureParams.wDecodedPictureIndex = nSurfaceIndex;
- m_PictureParams.wDeblockedPictureIndex = m_PictureParams.wDecodedPictureIndex;
+ m_PictureParams.wDecodedPictureIndex = nSurfaceIndex;
+ m_PictureParams.wDeblockedPictureIndex = m_PictureParams.wDecodedPictureIndex;
- // Manage reference picture list
- if (!m_PictureParams.bPicBackwardPrediction) {
- if (m_wRefPictureIndex[0] != NO_REF_FRAME) {
- RemoveRefFrame (m_wRefPictureIndex[0]);
- }
- m_wRefPictureIndex[0] = m_wRefPictureIndex[1];
- m_wRefPictureIndex[1] = nSurfaceIndex;
- }
- m_PictureParams.wForwardRefPictureIndex = (m_PictureParams.bPicIntra == 0) ? m_wRefPictureIndex[0] : NO_REF_FRAME;
- m_PictureParams.wBackwardRefPictureIndex = (m_PictureParams.bPicBackwardPrediction == 1) ? m_wRefPictureIndex[1] : NO_REF_FRAME;
+ // Manage reference picture list
+ if (!m_PictureParams.bPicBackwardPrediction) {
+ if (m_wRefPictureIndex[0] != NO_REF_FRAME) {
+ RemoveRefFrame(m_wRefPictureIndex[0]);
+ }
+ m_wRefPictureIndex[0] = m_wRefPictureIndex[1];
+ m_wRefPictureIndex[1] = nSurfaceIndex;
+ }
+ m_PictureParams.wForwardRefPictureIndex = (m_PictureParams.bPicIntra == 0) ? m_wRefPictureIndex[0] : NO_REF_FRAME;
+ m_PictureParams.wBackwardRefPictureIndex = (m_PictureParams.bPicBackwardPrediction == 1) ? m_wRefPictureIndex[1] : NO_REF_FRAME;
- m_PictureParams.bPic4MVallowed = (m_PictureParams.wBackwardRefPictureIndex == NO_REF_FRAME && m_PictureParams.bPicStructure == 3) ? 1 : 0;
- m_PictureParams.bPicDeblockConfined |= (m_PictureParams.wBackwardRefPictureIndex == NO_REF_FRAME) ? 0x04 : 0;
+ m_PictureParams.bPic4MVallowed = (m_PictureParams.wBackwardRefPictureIndex == NO_REF_FRAME && m_PictureParams.bPicStructure == 3) ? 1 : 0;
+ m_PictureParams.bPicDeblockConfined |= (m_PictureParams.wBackwardRefPictureIndex == NO_REF_FRAME) ? 0x04 : 0;
- m_PictureParams.bPicScanMethod++; // Use for status reporting sections 3.8.1 and 3.8.2
+ m_PictureParams.bPicScanMethod++; // Use for status reporting sections 3.8.1 and 3.8.2
- TRACE_VC1 ("CDXVADecoderVC1::DecodeFrame() : Decode frame %i\n", m_PictureParams.bPicScanMethod);
+ TRACE_VC1("CDXVADecoderVC1::DecodeFrame() : Decode frame %i\n", m_PictureParams.bPicScanMethod);
- // Send picture params to accelerator
- CHECK_HR (AddExecuteBuffer (DXVA2_PictureParametersBufferType, sizeof(m_PictureParams), &m_PictureParams));
+ // Send picture params to accelerator
+ CHECK_HR(AddExecuteBuffer(DXVA2_PictureParametersBufferType, sizeof(m_PictureParams), &m_PictureParams));
- // Send bitstream to accelerator
- CHECK_HR (AddExecuteBuffer (DXVA2_BitStreamDateBufferType, nFrameSize ? nFrameSize : nSize, pDataIn, &nSize_Result));
+ // Send bitstream to accelerator
+ CHECK_HR(AddExecuteBuffer(DXVA2_BitStreamDateBufferType, nFrameSize ? nFrameSize : nSize, pDataIn, &nSize_Result));
- m_SliceInfo.wQuantizerScaleCode = 1; // TODO : 1->31 ???
- m_SliceInfo.dwSliceBitsInBuffer = nSize_Result * 8;
- CHECK_HR (AddExecuteBuffer (DXVA2_SliceControlBufferType, sizeof (m_SliceInfo), &m_SliceInfo));
+ m_SliceInfo.wQuantizerScaleCode = 1; // TODO : 1->31 ???
+ m_SliceInfo.dwSliceBitsInBuffer = nSize_Result * 8;
+ CHECK_HR(AddExecuteBuffer(DXVA2_SliceControlBufferType, sizeof(m_SliceInfo), &m_SliceInfo));
- // Decode frame
- CHECK_HR (Execute());
- CHECK_HR (EndFrame(nSurfaceIndex));
+ // Decode frame
+ CHECK_HR(Execute());
+ CHECK_HR(EndFrame(nSurfaceIndex));
- // ***************
- if (nFrameSize) { // Decoding Second Field
- FFVC1UpdatePictureParam (&m_PictureParams, m_pFilter->GetAVCtx(), NULL, NULL, pDataIn, nSize, NULL, TRUE, &m_bFrame_repeat_pict);
+ // ***************
+ if (nFrameSize) { // Decoding Second Field
+ FFVC1UpdatePictureParam(&m_PictureParams, m_pFilter->GetAVCtx(), NULL, NULL, pDataIn, nSize, NULL, TRUE, &m_bFrame_repeat_pict);
- CHECK_HR (BeginFrame(nSurfaceIndex, pSampleToDeliver));
+ CHECK_HR(BeginFrame(nSurfaceIndex, pSampleToDeliver));
- TRACE_VC1 ("CDXVADecoderVC1::DecodeFrame() : PictureType = %d\n", nSliceType);
+ TRACE_VC1("CDXVADecoderVC1::DecodeFrame() : PictureType = %d\n", nSliceType);
- CHECK_HR (AddExecuteBuffer (DXVA2_PictureParametersBufferType, sizeof(m_PictureParams), &m_PictureParams));
+ CHECK_HR(AddExecuteBuffer(DXVA2_PictureParametersBufferType, sizeof(m_PictureParams), &m_PictureParams));
- // Send bitstream to accelerator
- CHECK_HR (AddExecuteBuffer (DXVA2_BitStreamDateBufferType, nSize - nFrameSize, pDataIn + nFrameSize, &nSize_Result));
+ // Send bitstream to accelerator
+ CHECK_HR(AddExecuteBuffer(DXVA2_BitStreamDateBufferType, nSize - nFrameSize, pDataIn + nFrameSize, &nSize_Result));
- m_SliceInfo.wQuantizerScaleCode = 1; // TODO : 1->31 ???
- m_SliceInfo.dwSliceBitsInBuffer = nSize_Result * 8;
- CHECK_HR (AddExecuteBuffer (DXVA2_SliceControlBufferType, sizeof (m_SliceInfo), &m_SliceInfo));
+ m_SliceInfo.wQuantizerScaleCode = 1; // TODO : 1->31 ???
+ m_SliceInfo.dwSliceBitsInBuffer = nSize_Result * 8;
+ CHECK_HR(AddExecuteBuffer(DXVA2_SliceControlBufferType, sizeof(m_SliceInfo), &m_SliceInfo));
- // Decode frame
- CHECK_HR (Execute());
- CHECK_HR (EndFrame(nSurfaceIndex));
- }
- // ***************
+ // Decode frame
+ CHECK_HR(Execute());
+ CHECK_HR(EndFrame(nSurfaceIndex));
+ }
+ // ***************
#ifdef _DEBUG
- DisplayStatus();
+ DisplayStatus();
#endif
- // Update timestamp & Re-order B frames
- if (m_bFrame_repeat_pict || m_pFilter->IsReorderBFrame()) {
- if (m_bFrame_repeat_pict) {
- m_pFilter->UpdateFrameTime(rtStart, rtStop, !!m_bFrame_repeat_pict);
- }
- if (m_pFilter->IsReorderBFrame() || m_pFilter->IsEvo()) {
- if (m_PictureParams.bPicBackwardPrediction == 1) {
- SwapRT (rtStart, m_rtStartDelayed);
- SwapRT (rtStop, m_rtStopDelayed);
- } else {
- // Save I or P reference time (swap later)
- if (!m_bFlushed) {
- if (m_nDelayedSurfaceIndex != -1) {
- UpdateStore (m_nDelayedSurfaceIndex, m_rtStartDelayed, m_rtStopDelayed);
- }
- m_rtStartDelayed = m_rtStopDelayed = _I64_MAX;
- SwapRT (rtStart, m_rtStartDelayed);
- SwapRT (rtStop, m_rtStopDelayed);
- m_nDelayedSurfaceIndex = nSurfaceIndex;
- }
- }
- }
- }
-
- AddToStore (nSurfaceIndex, pSampleToDeliver, (m_PictureParams.bPicBackwardPrediction != 1), rtStart, rtStop,
- false,(FF_FIELD_TYPE)nFieldType, (FF_SLICE_TYPE)nSliceType, 0);
- m_bFlushed = false;
-
- return DisplayNextFrame();
+ // Update timestamp & Re-order B frames
+ if (m_bFrame_repeat_pict || m_pFilter->IsReorderBFrame()) {
+ if (m_bFrame_repeat_pict) {
+ m_pFilter->UpdateFrameTime(rtStart, rtStop, !!m_bFrame_repeat_pict);
+ }
+ if (m_pFilter->IsReorderBFrame() || m_pFilter->IsEvo()) {
+ if (m_PictureParams.bPicBackwardPrediction == 1) {
+ SwapRT(rtStart, m_rtStartDelayed);
+ SwapRT(rtStop, m_rtStopDelayed);
+ } else {
+ // Save I or P reference time (swap later)
+ if (!m_bFlushed) {
+ if (m_nDelayedSurfaceIndex != -1) {
+ UpdateStore(m_nDelayedSurfaceIndex, m_rtStartDelayed, m_rtStopDelayed);
+ }
+ m_rtStartDelayed = m_rtStopDelayed = _I64_MAX;
+ SwapRT(rtStart, m_rtStartDelayed);
+ SwapRT(rtStop, m_rtStopDelayed);
+ m_nDelayedSurfaceIndex = nSurfaceIndex;
+ }
+ }
+ }
+ }
+
+ AddToStore(nSurfaceIndex, pSampleToDeliver, (m_PictureParams.bPicBackwardPrediction != 1), rtStart, rtStop,
+ false, (FF_FIELD_TYPE)nFieldType, (FF_SLICE_TYPE)nSliceType, 0);
+ m_bFlushed = false;
+
+ return DisplayNextFrame();
}
-void CDXVADecoderVC1::SetExtraData (BYTE* pDataIn, UINT nSize)
+void CDXVADecoderVC1::SetExtraData(BYTE* pDataIn, UINT nSize)
{
- m_PictureParams.bMacroblockWidthMinus1 = 15;
- m_PictureParams.bMacroblockHeightMinus1 = 15;
- m_PictureParams.bBlockWidthMinus1 = 7;
- m_PictureParams.bBlockHeightMinus1 = 7;
- m_PictureParams.bBPPminus1 = 7;
+ m_PictureParams.bMacroblockWidthMinus1 = 15;
+ m_PictureParams.bMacroblockHeightMinus1 = 15;
+ m_PictureParams.bBlockWidthMinus1 = 7;
+ m_PictureParams.bBlockHeightMinus1 = 7;
+ m_PictureParams.bBPPminus1 = 7;
- m_PictureParams.bChromaFormat = VC1_CHROMA_420;
+ m_PictureParams.bChromaFormat = VC1_CHROMA_420;
- m_PictureParams.bPicScanFixed = 0; // Use for status reporting sections 3.8.1 and 3.8.2
- m_PictureParams.bPicReadbackRequests = 0;
+ m_PictureParams.bPicScanFixed = 0; // Use for status reporting sections 3.8.1 and 3.8.2
+ m_PictureParams.bPicReadbackRequests = 0;
- m_PictureParams.bPicBinPB = 0; // TODO
- m_PictureParams.bMV_RPS = 0; // TODO
+ m_PictureParams.bPicBinPB = 0; // TODO
+ m_PictureParams.bMV_RPS = 0; // TODO
- m_PictureParams.bReservedBits = 0;
+ m_PictureParams.bReservedBits = 0;
- // iWMV9 - i9IRU - iOHIT - iINSO - iWMVA - 0 - 0 - 0 | Section 3.2.5
- m_PictureParams.bBidirectionalAveragingMode = (1 << 7) |
- (GetConfigIntraResidUnsigned() << 6) | // i9IRU
- (GetConfigResidDiffAccelerator() << 5); // iOHIT
+ // iWMV9 - i9IRU - iOHIT - iINSO - iWMVA - 0 - 0 - 0 | Section 3.2.5
+ m_PictureParams.bBidirectionalAveragingMode = (1 << 7) |
+ (GetConfigIntraResidUnsigned() << 6) | // i9IRU
+ (GetConfigResidDiffAccelerator() << 5); // iOHIT
}
BYTE* CDXVADecoderVC1::FindNextStartCode(BYTE* pBuffer, UINT nSize, UINT& nPacketSize)
{
- BYTE* pStart = pBuffer;
- BYTE bCode = 0;
- for (UINT i=0; i<nSize-4; i++) {
- if ( ((*((DWORD*)(pBuffer+i)) & 0x00FFFFFF) == 0x00010000) || (i >= nSize-5) ) {
- if (bCode == 0) {
- bCode = pBuffer[i+3];
- if ((nSize == 5) && (bCode == 0x0D)) {
- nPacketSize = nSize;
- return pBuffer;
- }
- } else {
- if (bCode == 0x0D) {
- // Start code found!
- nPacketSize = i - (pStart - pBuffer) + (i >= nSize-5 ? 5 : 1);
- return pStart;
- } else {
- // Other stuff, ignore it
- pStart = pBuffer + i;
- bCode = pBuffer[i+3];
- }
- }
- }
- }
-
- ASSERT (FALSE); // Should never happen!
-
- return NULL;
+ BYTE* pStart = pBuffer;
+ BYTE bCode = 0;
+ for (UINT i = 0; i < nSize - 4; i++) {
+ if (((*((DWORD*)(pBuffer + i)) & 0x00FFFFFF) == 0x00010000) || (i >= nSize - 5)) {
+ if (bCode == 0) {
+ bCode = pBuffer[i + 3];
+ if ((nSize == 5) && (bCode == 0x0D)) {
+ nPacketSize = nSize;
+ return pBuffer;
+ }
+ } else {
+ if (bCode == 0x0D) {
+ // Start code found!
+ nPacketSize = i - (pStart - pBuffer) + (i >= nSize - 5 ? 5 : 1);
+ return pStart;
+ } else {
+ // Other stuff, ignore it
+ pStart = pBuffer + i;
+ bCode = pBuffer[i + 3];
+ }
+ }
+ }
+ }
+
+ ASSERT(FALSE); // Should never happen!
+
+ return NULL;
}
void CDXVADecoderVC1::CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize)
{
- int nDummy;
-
- if (m_PictureParams.bSecondField) {
- memcpy (pDXVABuffer, (BYTE*)pBuffer, nSize);
- } else {
- if ( (*((DWORD*)pBuffer) & 0x00FFFFFF) != 0x00010000) {
- if (m_pFilter->GetCodec() == CODEC_ID_WMV3) {
- memcpy (pDXVABuffer, (BYTE*)pBuffer, nSize);
- } else {
- pDXVABuffer[0]=pDXVABuffer[1]=0;
- pDXVABuffer[2]=1;
- pDXVABuffer[3]=0x0D;
- pDXVABuffer +=4;
- memcpy (pDXVABuffer, (BYTE*)pBuffer, nSize);
- nSize +=4;
- }
- } else {
- BYTE* pStart;
- UINT nPacketSize;
-
- pStart = FindNextStartCode (pBuffer, nSize, nPacketSize);
- if (pStart) {
- // Startcode already present
- memcpy (pDXVABuffer, (BYTE*)pStart, nPacketSize);
- nSize = nPacketSize;
- }
- }
- }
-
- // Copy bitstream buffer, with zero padding (buffer is rounded to multiple of 128)
- nDummy = 128 - (nSize %128);
-
- pDXVABuffer += nSize;
- memset (pDXVABuffer, 0, nDummy);
- nSize += nDummy;
+ int nDummy;
+
+ if (m_PictureParams.bSecondField) {
+ memcpy(pDXVABuffer, (BYTE*)pBuffer, nSize);
+ } else {
+ if ((*((DWORD*)pBuffer) & 0x00FFFFFF) != 0x00010000) {
+ if (m_pFilter->GetCodec() == CODEC_ID_WMV3) {
+ memcpy(pDXVABuffer, (BYTE*)pBuffer, nSize);
+ } else {
+ pDXVABuffer[0] = pDXVABuffer[1] = 0;
+ pDXVABuffer[2] = 1;
+ pDXVABuffer[3] = 0x0D;
+ pDXVABuffer += 4;
+ memcpy(pDXVABuffer, (BYTE*)pBuffer, nSize);
+ nSize += 4;
+ }
+ } else {
+ BYTE* pStart;
+ UINT nPacketSize;
+
+ pStart = FindNextStartCode(pBuffer, nSize, nPacketSize);
+ if (pStart) {
+ // Startcode already present
+ memcpy(pDXVABuffer, (BYTE*)pStart, nPacketSize);
+ nSize = nPacketSize;
+ }
+ }
+ }
+
+ // Copy bitstream buffer, with zero padding (buffer is rounded to multiple of 128)
+ nDummy = 128 - (nSize % 128);
+
+ pDXVABuffer += nSize;
+ memset(pDXVABuffer, 0, nDummy);
+ nSize += nDummy;
}
void CDXVADecoderVC1::Flush()
{
- m_nDelayedSurfaceIndex = -1;
- m_rtStartDelayed = _I64_MAX;
- m_rtStopDelayed = _I64_MAX;
+ m_nDelayedSurfaceIndex = -1;
+ m_rtStartDelayed = _I64_MAX;
+ m_rtStopDelayed = _I64_MAX;
- if (m_wRefPictureIndex[0] != NO_REF_FRAME) {
- RemoveRefFrame (m_wRefPictureIndex[0]);
- }
- if (m_wRefPictureIndex[1] != NO_REF_FRAME) {
- RemoveRefFrame (m_wRefPictureIndex[1]);
- }
+ if (m_wRefPictureIndex[0] != NO_REF_FRAME) {
+ RemoveRefFrame(m_wRefPictureIndex[0]);
+ }
+ if (m_wRefPictureIndex[1] != NO_REF_FRAME) {
+ RemoveRefFrame(m_wRefPictureIndex[1]);
+ }
- m_wRefPictureIndex[0] = NO_REF_FRAME;
- m_wRefPictureIndex[1] = NO_REF_FRAME;
+ m_wRefPictureIndex[0] = NO_REF_FRAME;
+ m_wRefPictureIndex[1] = NO_REF_FRAME;
- __super::Flush();
+ __super::Flush();
}
HRESULT CDXVADecoderVC1::DisplayStatus()
{
- HRESULT hr = E_INVALIDARG;
- DXVA_Status_VC1 Status;
+ HRESULT hr = E_INVALIDARG;
+ DXVA_Status_VC1 Status;
- memset (&Status, 0, sizeof(Status));
+ memset(&Status, 0, sizeof(Status));
- if (SUCCEEDED (hr = CDXVADecoder::QueryStatus(&Status, sizeof(Status)))) {
- Status.StatusReportFeedbackNumber = 0x00FF & Status.StatusReportFeedbackNumber;
+ if (SUCCEEDED(hr = CDXVADecoder::QueryStatus(&Status, sizeof(Status)))) {
+ Status.StatusReportFeedbackNumber = 0x00FF & Status.StatusReportFeedbackNumber;
- TRACE_VC1 ("CDXVADecoderVC1::DisplayStatus() : Status for the frame %u : bBufType = %u, bStatus = %u, wNumMbsAffected = %u\n",
- Status.StatusReportFeedbackNumber,
- Status.bBufType,
- Status.bStatus,
- Status.wNumMbsAffected);
- }
+ TRACE_VC1("CDXVADecoderVC1::DisplayStatus() : Status for the frame %u : bBufType = %u, bStatus = %u, wNumMbsAffected = %u\n",
+ Status.StatusReportFeedbackNumber,
+ Status.bBufType,
+ Status.bStatus,
+ Status.wNumMbsAffected);
+ }
- return hr;
+ return hr;
}
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderVC1.h b/src/filters/transform/MPCVideoDec/DXVADecoderVC1.h
index 21df8fbc8..fb2e8710b 100644
--- a/src/filters/transform/MPCVideoDec/DXVADecoderVC1.h
+++ b/src/filters/transform/MPCVideoDec/DXVADecoderVC1.h
@@ -29,80 +29,80 @@
class CDXVADecoderVC1 : public CDXVADecoder
{
public:
- CDXVADecoderVC1 (CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber);
- CDXVADecoderVC1 (CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config);
- virtual ~CDXVADecoderVC1(void);
-
- // === Public functions
- virtual HRESULT DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
- virtual void SetExtraData (BYTE* pDataIn, UINT nSize);
- virtual void CopyBitstream (BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize);
- virtual void Flush();
-
- typedef enum {
- VC1_PS_TOP_FIELD = 1,
- VC1_PS_BOTTOM_FIELD = 2,
- VC1_PS_PROGRESSIVE = 3
- } VC1_INTERLACING;
-
- typedef enum {
- VC1_CHROMA_420 = 1,
- VC1_CHROMA_422 = 2,
- VC1_CHROMA_444 = 3
- } VC1_CHROMA_FORMAT;
-
- typedef enum {
- VC1_CR_BICUBIC_QUARTER_CHROMA = 4,
- VC1_CR_BICUBIC_HALF_CHROMA = 5,
- VC1_CR_BILINEAR_QUARTER_CHROMA = 12,
- VC1_CR_BILINEAR_HALF_CHROMA = 13,
- } VC1_CHROMA_RESIZE;
-
- typedef enum {
- VC1_SCAN_ZIGZAG = 0,
- VC1_SCAN_ALTERNATE_VERTICAL = 1,
- VC1_SCAN_ALTERNATE_HORIZONTAL = 2,
- VC1_SCAN_ARBITRARY = 3 // Use when bConfigHostInverseScan = 1
- } VC1_PIC_SCAN_METHOD;
-
- typedef enum { // Values for bPicDeblockConfined when bConfigBitstreamRaw = 1
- VC1_EXTENDED_DMV = 0x0001,
- VC1_PSF = 0x0002,
- VC1_REFPICFLAG = 0x0004,
- VC1_FINTERPFLAG = 0x0008,
- VC1_TFCNTRFLAG = 0x0010,
- VC1_INTERLACE = 0x0020,
- VC1_PULLDOWN = 0x0040,
- VC1_POSTPROCFLAG = 0x0080
- } VC1_DEBLOCK_CONFINED;
-
- typedef enum { // Values for bPicSpatialResid8
- VC1_VSTRANSFORM = 0x0001,
- VC1_DQUANT = 0x0002,
- VC1_EXTENDED_MV = 0x0004,
- VC1_FASTUVMC = 0x0008,
- VC1_LOOPFILTER = 0x0010,
- VC1_REDIST_FLAG = 0x0020,
- VC1_PANSCAN_FLAG = 0x0040,
- } VC1_PIC_SPATIAL_RESID8;
+ CDXVADecoderVC1(CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber);
+ CDXVADecoderVC1(CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config);
+ virtual ~CDXVADecoderVC1(void);
+
+ // === Public functions
+ virtual HRESULT DecodeFrame(BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
+ virtual void SetExtraData(BYTE* pDataIn, UINT nSize);
+ virtual void CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize);
+ virtual void Flush();
+
+ typedef enum {
+ VC1_PS_TOP_FIELD = 1,
+ VC1_PS_BOTTOM_FIELD = 2,
+ VC1_PS_PROGRESSIVE = 3
+ } VC1_INTERLACING;
+
+ typedef enum {
+ VC1_CHROMA_420 = 1,
+ VC1_CHROMA_422 = 2,
+ VC1_CHROMA_444 = 3
+ } VC1_CHROMA_FORMAT;
+
+ typedef enum {
+ VC1_CR_BICUBIC_QUARTER_CHROMA = 4,
+ VC1_CR_BICUBIC_HALF_CHROMA = 5,
+ VC1_CR_BILINEAR_QUARTER_CHROMA = 12,
+ VC1_CR_BILINEAR_HALF_CHROMA = 13,
+ } VC1_CHROMA_RESIZE;
+
+ typedef enum {
+ VC1_SCAN_ZIGZAG = 0,
+ VC1_SCAN_ALTERNATE_VERTICAL = 1,
+ VC1_SCAN_ALTERNATE_HORIZONTAL = 2,
+ VC1_SCAN_ARBITRARY = 3 // Use when bConfigHostInverseScan = 1
+ } VC1_PIC_SCAN_METHOD;
+
+ typedef enum { // Values for bPicDeblockConfined when bConfigBitstreamRaw = 1
+ VC1_EXTENDED_DMV = 0x0001,
+ VC1_PSF = 0x0002,
+ VC1_REFPICFLAG = 0x0004,
+ VC1_FINTERPFLAG = 0x0008,
+ VC1_TFCNTRFLAG = 0x0010,
+ VC1_INTERLACE = 0x0020,
+ VC1_PULLDOWN = 0x0040,
+ VC1_POSTPROCFLAG = 0x0080
+ } VC1_DEBLOCK_CONFINED;
+
+ typedef enum { // Values for bPicSpatialResid8
+ VC1_VSTRANSFORM = 0x0001,
+ VC1_DQUANT = 0x0002,
+ VC1_EXTENDED_MV = 0x0004,
+ VC1_FASTUVMC = 0x0008,
+ VC1_LOOPFILTER = 0x0010,
+ VC1_REDIST_FLAG = 0x0020,
+ VC1_PANSCAN_FLAG = 0x0040,
+ } VC1_PIC_SPATIAL_RESID8;
protected :
private:
- DXVA_PictureParameters m_PictureParams;
- DXVA_SliceInfo m_SliceInfo;
- WORD m_wRefPictureIndex[2];
+ DXVA_PictureParameters m_PictureParams;
+ DXVA_SliceInfo m_SliceInfo;
+ WORD m_wRefPictureIndex[2];
- int m_nDelayedSurfaceIndex;
- REFERENCE_TIME m_rtStartDelayed;
- REFERENCE_TIME m_rtStopDelayed;
+ int m_nDelayedSurfaceIndex;
+ REFERENCE_TIME m_rtStartDelayed;
+ REFERENCE_TIME m_rtStopDelayed;
- BOOL m_bFrame_repeat_pict;
+ BOOL m_bFrame_repeat_pict;
- // Private functions
- void Init();
- HRESULT DisplayStatus();
- BYTE* FindNextStartCode(BYTE* pBuffer, UINT nSize, UINT& nPacketSize);
+ // Private functions
+ void Init();
+ HRESULT DisplayStatus();
+ BYTE* FindNextStartCode(BYTE* pBuffer, UINT nSize, UINT& nPacketSize);
};
diff --git a/src/filters/transform/MPCVideoDec/FfmpegContext.cpp b/src/filters/transform/MPCVideoDec/FfmpegContext.cpp
index 2bf679e0f..4660e79e2 100644
--- a/src/filters/transform/MPCVideoDec/FfmpegContext.cpp
+++ b/src/filters/transform/MPCVideoDec/FfmpegContext.cpp
@@ -34,779 +34,782 @@
#include "../../../DSUtil/SysVersion.h"
extern "C" {
- #include <ffmpeg/libavcodec/dsputil.h>
- #include <ffmpeg/libavcodec/avcodec.h>
-// This is kind of an hack but it avoids using a C++ keyword as a struct member name
+#include <ffmpeg/libavcodec/dsputil.h>
+#include <ffmpeg/libavcodec/avcodec.h>
+ // This is kind of an hack but it avoids using a C++ keyword as a struct member name
#define class classFFMPEG
- #include <ffmpeg/libavcodec/mpegvideo.h>
+#include <ffmpeg/libavcodec/mpegvideo.h>
#undef class
- #include <ffmpeg/libavcodec/golomb.h>
+#include <ffmpeg/libavcodec/golomb.h>
- #include <ffmpeg/libavcodec/h264.h>
- #include <ffmpeg/libavcodec/h264data.h>
- #include <ffmpeg/libavcodec/vc1.h>
- #include <ffmpeg/libavcodec/mpeg12.h>
+#include <ffmpeg/libavcodec/h264.h>
+#include <ffmpeg/libavcodec/h264data.h>
+#include <ffmpeg/libavcodec/vc1.h>
+#include <ffmpeg/libavcodec/mpeg12.h>
- int av_h264_decode_frame(struct AVCodecContext* avctx, int* nOutPOC, int64_t* rtStartTime, uint8_t *buf, int buf_size);
- int av_vc1_decode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_size, int *nFrameSize);
- void av_init_packet(AVPacket *pkt);
+ int av_h264_decode_frame(struct AVCodecContext* avctx, int* nOutPOC, int64_t* rtStartTime, uint8_t* buf, int buf_size);
+ int av_vc1_decode_frame(AVCodecContext* avctx, uint8_t* buf, int buf_size, int* nFrameSize);
+ void av_init_packet(AVPacket* pkt);
- #ifdef _WIN64
- // Hack to use MinGW64 from 2.x branch
- void __mingw_raise_matherr(int typ, const char *name, double a1, double a2, double rslt) {}
- #endif
+#ifdef _WIN64
+ // Hack to use MinGW64 from 2.x branch
+ void __mingw_raise_matherr(int typ, const char* name, double a1, double a2, double rslt) {}
+#endif
}
#if defined(REGISTER_FILTER) && _WIN64
-void *__imp_toupper = toupper;
-void *__imp_time64 = _time64;
+void* __imp_toupper = toupper;
+void* __imp_time64 = _time64;
#endif
const byte ZZ_SCAN[16] = {
- 0, 1, 4, 8,
- 5, 2, 3, 6,
- 9, 12, 13, 10,
- 7, 11, 14, 15
+ 0, 1, 4, 8,
+ 5, 2, 3, 6,
+ 9, 12, 13, 10,
+ 7, 11, 14, 15
};
const byte ZZ_SCAN8[64] = {
- 0, 1, 8, 16, 9, 2, 3, 10,
- 17, 24, 32, 25, 18, 11, 4, 5,
- 12, 19, 26, 33, 40, 48, 41, 34,
- 27, 20, 13, 6, 7, 14, 21, 28,
- 35, 42, 49, 56, 57, 50, 43, 36,
- 29, 22, 15, 23, 30, 37, 44, 51,
- 58, 59, 52, 45, 38, 31, 39, 46,
- 53, 60, 61, 54, 47, 55, 62, 63
+ 0, 1, 8, 16, 9, 2, 3, 10,
+ 17, 24, 32, 25, 18, 11, 4, 5,
+ 12, 19, 26, 33, 40, 48, 41, 34,
+ 27, 20, 13, 6, 7, 14, 21, 28,
+ 35, 42, 49, 56, 57, 50, 43, 36,
+ 29, 22, 15, 23, 30, 37, 44, 51,
+ 58, 59, 52, 45, 38, 31, 39, 46,
+ 53, 60, 61, 54, 47, 55, 62, 63
};
inline MpegEncContext* GetMpegEncContext(struct AVCodecContext* pAVCtx)
{
- Mpeg1Context* s1;
- MpegEncContext* s = NULL;
-
- switch (pAVCtx->codec_id) {
- case CODEC_ID_VC1 :
- case CODEC_ID_H264 :
- s = (MpegEncContext*)pAVCtx->priv_data;
- break;
- case CODEC_ID_MPEG2VIDEO:
- s1 = (Mpeg1Context*)pAVCtx->priv_data;
- s = (MpegEncContext*)&s1->mpeg_enc_ctx;
- break;
- }
- return s;
+ Mpeg1Context* s1;
+ MpegEncContext* s = NULL;
+
+ switch (pAVCtx->codec_id) {
+ case CODEC_ID_VC1 :
+ case CODEC_ID_H264 :
+ s = (MpegEncContext*)pAVCtx->priv_data;
+ break;
+ case CODEC_ID_MPEG2VIDEO:
+ s1 = (Mpeg1Context*)pAVCtx->priv_data;
+ s = (MpegEncContext*)&s1->mpeg_enc_ctx;
+ break;
+ }
+ return s;
}
-int FFH264DecodeBuffer (struct AVCodecContext* pAVCtx, BYTE* pBuffer, UINT nSize, int* pFramePOC, int* pOutPOC, REFERENCE_TIME* pOutrtStart)
+int FFH264DecodeBuffer(struct AVCodecContext* pAVCtx, BYTE* pBuffer, UINT nSize, int* pFramePOC, int* pOutPOC, REFERENCE_TIME* pOutrtStart)
{
- int result = -1;
- if (pBuffer != NULL) {
- H264Context* h = (H264Context*) pAVCtx->priv_data;
- result = av_h264_decode_frame (pAVCtx, pOutPOC, pOutrtStart, pBuffer, nSize);
-
- if (result != -1 && h->s.current_picture_ptr != NULL && pFramePOC) {
- *pFramePOC = h->s.current_picture_ptr->poc;
- }
- }
- return result;
+ int result = -1;
+ if (pBuffer != NULL) {
+ H264Context* h = (H264Context*) pAVCtx->priv_data;
+ result = av_h264_decode_frame(pAVCtx, pOutPOC, pOutrtStart, pBuffer, nSize);
+
+ if (result != -1 && h->s.current_picture_ptr != NULL && pFramePOC) {
+ *pFramePOC = h->s.current_picture_ptr->poc;
+ }
+ }
+ return result;
}
// returns TRUE if version is equal to or higher than A.B.C.D, returns FALSE otherwise
BOOL DriverVersionCheck(LARGE_INTEGER VideoDriverVersion, int A, int B, int C, int D)
{
- if (HIWORD(VideoDriverVersion.HighPart) > A) {
- return TRUE;
- } else if (HIWORD(VideoDriverVersion.HighPart) == A) {
- if (LOWORD(VideoDriverVersion.HighPart) > B) {
- return TRUE;
- } else if (LOWORD(VideoDriverVersion.HighPart) == B) {
- if (HIWORD(VideoDriverVersion.LowPart) > C) {
- return TRUE;
- } else if (HIWORD(VideoDriverVersion.LowPart) == C) {
- if (LOWORD(VideoDriverVersion.LowPart) >= D) {
- return TRUE;
- }
- }
- }
- }
- return FALSE;
+ if (HIWORD(VideoDriverVersion.HighPart) > A) {
+ return TRUE;
+ } else if (HIWORD(VideoDriverVersion.HighPart) == A) {
+ if (LOWORD(VideoDriverVersion.HighPart) > B) {
+ return TRUE;
+ } else if (LOWORD(VideoDriverVersion.HighPart) == B) {
+ if (HIWORD(VideoDriverVersion.LowPart) > C) {
+ return TRUE;
+ } else if (HIWORD(VideoDriverVersion.LowPart) == C) {
+ if (LOWORD(VideoDriverVersion.LowPart) >= D) {
+ return TRUE;
+ }
+ }
+ }
+ }
+ return FALSE;
}
int FFH264CheckCompatibility(int nWidth, int nHeight, struct AVCodecContext* pAVCtx, BYTE* pBuffer, UINT nSize, DWORD nPCIVendor, DWORD nPCIDevice, LARGE_INTEGER VideoDriverVersion)
{
- H264Context* pContext = (H264Context*) pAVCtx->priv_data;
- SPS* cur_sps;
- PPS* cur_pps;
-
- int video_is_level51 = 0;
- int no_level51_support = 1;
- int too_much_ref_frames = 0;
- int profile_higher_than_high = 0;
- int max_ref_frames_dpb41 = min(11, 8388608/(nWidth * nHeight) );
-
- if (pBuffer != NULL) {
- av_h264_decode_frame (pAVCtx, NULL, NULL, pBuffer, nSize);
- }
-
- cur_sps = pContext->sps_buffers[0];
- cur_pps = pContext->pps_buffers[0];
-
- if (cur_sps != NULL) {
- int max_ref_frames = 0;
-
- if (cur_sps->bit_depth_luma > 8 || cur_sps->chroma_format_idc > 1) {
- return DXVA_HIGH_BIT;
- }
-
- video_is_level51 = cur_sps->level_idc >= 51 ? 1 : 0;
- profile_higher_than_high = (cur_sps->profile_idc > 100);
- max_ref_frames = max_ref_frames_dpb41; // default value is calculate
-
- if (nPCIVendor == PCIV_nVidia) {
- // nVidia cards support level 5.1 since drivers v6.14.11.7800 for XP and drivers v7.15.11.7800 for Vista/7
- if (SysVersion::IsVistaOrLater()) {
- if (DriverVersionCheck(VideoDriverVersion, 7, 15, 11, 7800)) {
- no_level51_support = 0;
-
- // max ref frames is 16 for HD and 11 otherwise
- if (nWidth >= 1280) {
- max_ref_frames = 16;
- } else {
- max_ref_frames = 11;
- }
- }
- } else {
- if (DriverVersionCheck(VideoDriverVersion, 6, 14, 11, 7800)) {
- no_level51_support = 0;
-
- // max ref frames is 14
- max_ref_frames = 14;
- }
- }
- } else if (nPCIVendor == PCIV_S3_Graphics) {
- no_level51_support = 0;
- } else if (nPCIVendor == PCIV_ATI) {
- // HD4xxx, HD5xxx, and HD6xxx AMD/ATI cards support level 5.1 since drivers v8.14.1.6105 (Catalyst 10.4)
- if (nPCIDevice > 0x6700) {
- if (DriverVersionCheck(VideoDriverVersion, 8, 14, 1, 6105)) {
- no_level51_support = 0;
- max_ref_frames = 16;
- }
- }
- }
-
- // Check maximum allowed number reference frames
- if (cur_sps->ref_frame_count > max_ref_frames) {
- too_much_ref_frames = 1;
- }
- }
-
- return (video_is_level51 * no_level51_support * DXVA_UNSUPPORTED_LEVEL) + (too_much_ref_frames * DXVA_TOO_MANY_REF_FRAMES) + (profile_higher_than_high * DXVA_PROFILE_HIGHER_THAN_HIGH);
+ H264Context* pContext = (H264Context*) pAVCtx->priv_data;
+ SPS* cur_sps;
+ PPS* cur_pps;
+
+ int video_is_level51 = 0;
+ int no_level51_support = 1;
+ int too_much_ref_frames = 0;
+ int profile_higher_than_high = 0;
+ int max_ref_frames_dpb41 = min(11, 8388608 / (nWidth * nHeight));
+
+ if (pBuffer != NULL) {
+ av_h264_decode_frame(pAVCtx, NULL, NULL, pBuffer, nSize);
+ }
+
+ cur_sps = pContext->sps_buffers[0];
+ cur_pps = pContext->pps_buffers[0];
+
+ if (cur_sps != NULL) {
+ int max_ref_frames = 0;
+
+ if (cur_sps->bit_depth_luma > 8 || cur_sps->chroma_format_idc > 1) {
+ return DXVA_HIGH_BIT;
+ }
+
+ video_is_level51 = cur_sps->level_idc >= 51 ? 1 : 0;
+ profile_higher_than_high = (cur_sps->profile_idc > 100);
+ max_ref_frames = max_ref_frames_dpb41; // default value is calculate
+
+ if (nPCIVendor == PCIV_nVidia) {
+ // nVidia cards support level 5.1 since drivers v6.14.11.7800 for XP and drivers v7.15.11.7800 for Vista/7
+ if (SysVersion::IsVistaOrLater()) {
+ if (DriverVersionCheck(VideoDriverVersion, 7, 15, 11, 7800)) {
+ no_level51_support = 0;
+
+ // max ref frames is 16 for HD and 11 otherwise
+ if (nWidth >= 1280) {
+ max_ref_frames = 16;
+ } else {
+ max_ref_frames = 11;
+ }
+ }
+ } else {
+ if (DriverVersionCheck(VideoDriverVersion, 6, 14, 11, 7800)) {
+ no_level51_support = 0;
+
+ // max ref frames is 14
+ max_ref_frames = 14;
+ }
+ }
+ } else if (nPCIVendor == PCIV_S3_Graphics) {
+ no_level51_support = 0;
+ } else if (nPCIVendor == PCIV_ATI) {
+ // HD4xxx, HD5xxx, and HD6xxx AMD/ATI cards support level 5.1 since drivers v8.14.1.6105 (Catalyst 10.4)
+ if (nPCIDevice > 0x6700) {
+ if (DriverVersionCheck(VideoDriverVersion, 8, 14, 1, 6105)) {
+ no_level51_support = 0;
+ max_ref_frames = 16;
+ }
+ }
+ }
+
+ // Check maximum allowed number reference frames
+ if (cur_sps->ref_frame_count > max_ref_frames) {
+ too_much_ref_frames = 1;
+ }
+ }
+
+ return (video_is_level51 * no_level51_support * DXVA_UNSUPPORTED_LEVEL) + (too_much_ref_frames * DXVA_TOO_MANY_REF_FRAMES) + (profile_higher_than_high * DXVA_PROFILE_HIGHER_THAN_HIGH);
}
void CopyScalingMatrix(DXVA_Qmatrix_H264* pDest, PPS* pps, DWORD nPCIVendor)
{
- int i, j;
- memset(pDest, 0, sizeof(DXVA_Qmatrix_H264));
- if (nPCIVendor == PCIV_ATI) {
- for (i = 0; i < 6; i++)
- for (j = 0; j < 16; j++)
- pDest->bScalingLists4x4[i][j] = pps->scaling_matrix4[i][j];
-
- for (i = 0; i < 64; i++) {
- pDest->bScalingLists8x8[0][i] = pps->scaling_matrix8[0][i];
- pDest->bScalingLists8x8[1][i] = pps->scaling_matrix8[3][i];
- }
- } else {
- for (i = 0; i < 6; i++)
- for (j = 0; j < 16; j++)
- pDest->bScalingLists4x4[i][j] = pps->scaling_matrix4[i][ZZ_SCAN[j]];
-
- for (i = 0; i < 64; i++) {
- pDest->bScalingLists8x8[0][i] = pps->scaling_matrix8[0][ZZ_SCAN8[i]];
- pDest->bScalingLists8x8[1][i] = pps->scaling_matrix8[3][ZZ_SCAN8[i]];
- }
- }
+ int i, j;
+ memset(pDest, 0, sizeof(DXVA_Qmatrix_H264));
+ if (nPCIVendor == PCIV_ATI) {
+ for (i = 0; i < 6; i++)
+ for (j = 0; j < 16; j++) {
+ pDest->bScalingLists4x4[i][j] = pps->scaling_matrix4[i][j];
+ }
+
+ for (i = 0; i < 64; i++) {
+ pDest->bScalingLists8x8[0][i] = pps->scaling_matrix8[0][i];
+ pDest->bScalingLists8x8[1][i] = pps->scaling_matrix8[3][i];
+ }
+ } else {
+ for (i = 0; i < 6; i++)
+ for (j = 0; j < 16; j++) {
+ pDest->bScalingLists4x4[i][j] = pps->scaling_matrix4[i][ZZ_SCAN[j]];
+ }
+
+ for (i = 0; i < 64; i++) {
+ pDest->bScalingLists8x8[0][i] = pps->scaling_matrix8[0][ZZ_SCAN8[i]];
+ pDest->bScalingLists8x8[1][i] = pps->scaling_matrix8[3][ZZ_SCAN8[i]];
+ }
+ }
}
USHORT FFH264FindRefFrameIndex(USHORT num_frame, DXVA_PicParams_H264* pDXVAPicParams)
{
- int i;
- for (i=0; i<pDXVAPicParams->num_ref_frames; i++) {
- if (pDXVAPicParams->FrameNumList[i] == num_frame) {
- return pDXVAPicParams->RefFrameList[i].Index7Bits;
- }
- }
+ int i;
+ for (i = 0; i < pDXVAPicParams->num_ref_frames; i++) {
+ if (pDXVAPicParams->FrameNumList[i] == num_frame) {
+ return pDXVAPicParams->RefFrameList[i].Index7Bits;
+ }
+ }
#ifdef _DEBUG
- // DebugBreak(); // Ref frame not found !
+ // DebugBreak(); // Ref frame not found !
#endif
- return 127;
+ return 127;
}
-HRESULT FFH264BuildPicParams (DXVA_PicParams_H264* pDXVAPicParams, DXVA_Qmatrix_H264* pDXVAScalingMatrix, int* nFieldType, int* nSliceType, struct AVCodecContext* pAVCtx, DWORD nPCIVendor)
+HRESULT FFH264BuildPicParams(DXVA_PicParams_H264* pDXVAPicParams, DXVA_Qmatrix_H264* pDXVAScalingMatrix, int* nFieldType, int* nSliceType, struct AVCodecContext* pAVCtx, DWORD nPCIVendor)
{
- H264Context* h = (H264Context*) pAVCtx->priv_data;
- SPS* cur_sps;
- PPS* cur_pps;
- MpegEncContext* const s = &h->s;
- int field_pic_flag;
- HRESULT hr = E_FAIL;
- const Picture *current_picture = s->current_picture_ptr;
-
- field_pic_flag = (h->s.picture_structure != PICT_FRAME);
-
- cur_sps = &h->sps;
- cur_pps = &h->pps;
-
- if (cur_sps && cur_pps) {
- *nFieldType = h->s.picture_structure;
- if (h->sps.pic_struct_present_flag) {
- switch (h->sei_pic_struct) {
- case SEI_PIC_STRUCT_TOP_FIELD:
- case SEI_PIC_STRUCT_TOP_BOTTOM:
- case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
- *nFieldType = PICT_TOP_FIELD;
- break;
- case SEI_PIC_STRUCT_BOTTOM_FIELD:
- case SEI_PIC_STRUCT_BOTTOM_TOP:
- case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:
- *nFieldType = PICT_BOTTOM_FIELD;
- break;
- case SEI_PIC_STRUCT_FRAME_DOUBLING:
- case SEI_PIC_STRUCT_FRAME_TRIPLING:
- case SEI_PIC_STRUCT_FRAME:
- *nFieldType = PICT_FRAME;
- break;
- }
- }
-
- *nSliceType = h->slice_type;
-
- if (cur_sps->mb_width==0 || cur_sps->mb_height==0) {
- return VFW_E_INVALID_FILE_FORMAT;
- }
-
- pDXVAPicParams->wFrameWidthInMbsMinus1 = cur_sps->mb_width - 1; // pic_width_in_mbs_minus1;
- pDXVAPicParams->wFrameHeightInMbsMinus1 = cur_sps->mb_height * (2 - cur_sps->frame_mbs_only_flag) - 1; // pic_height_in_map_units_minus1;
- pDXVAPicParams->num_ref_frames = cur_sps->ref_frame_count; // num_ref_frames;
- pDXVAPicParams->field_pic_flag = field_pic_flag;
- pDXVAPicParams->MbaffFrameFlag = (h->sps.mb_aff && (field_pic_flag==0));
- pDXVAPicParams->residual_colour_transform_flag = cur_sps->residual_color_transform_flag;
- pDXVAPicParams->sp_for_switch_flag = h->sp_for_switch_flag;
- pDXVAPicParams->chroma_format_idc = cur_sps->chroma_format_idc;
- pDXVAPicParams->RefPicFlag = h->ref_pic_flag;
- pDXVAPicParams->constrained_intra_pred_flag = cur_pps->constrained_intra_pred;
- pDXVAPicParams->weighted_pred_flag = cur_pps->weighted_pred;
- pDXVAPicParams->weighted_bipred_idc = cur_pps->weighted_bipred_idc;
- pDXVAPicParams->frame_mbs_only_flag = cur_sps->frame_mbs_only_flag;
- pDXVAPicParams->transform_8x8_mode_flag = cur_pps->transform_8x8_mode;
- pDXVAPicParams->MinLumaBipredSize8x8Flag = h->sps.level_idc >= 31;
- pDXVAPicParams->IntraPicFlag = (h->slice_type == AV_PICTURE_TYPE_I || h->slice_type == AV_PICTURE_TYPE_SI);
-
- pDXVAPicParams->bit_depth_luma_minus8 = cur_sps->bit_depth_luma - 8; // bit_depth_luma_minus8
- pDXVAPicParams->bit_depth_chroma_minus8 = cur_sps->bit_depth_chroma - 8; // bit_depth_chroma_minus8
-
- // pDXVAPicParams->StatusReportFeedbackNumber = SET IN DecodeFrame;
- // pDXVAPicParams->CurrFieldOrderCnt = SET IN UpdateRefFramesList;
- // pDXVAPicParams->FieldOrderCntList = SET IN UpdateRefFramesList;
- // pDXVAPicParams->FrameNumList = SET IN UpdateRefFramesList;
- // pDXVAPicParams->UsedForReferenceFlags = SET IN UpdateRefFramesList;
- // pDXVAPicParams->NonExistingFrameFlags
-
- pDXVAPicParams->frame_num = h->frame_num;
-
- pDXVAPicParams->log2_max_frame_num_minus4 = cur_sps->log2_max_frame_num - 4; // log2_max_frame_num_minus4;
- pDXVAPicParams->pic_order_cnt_type = cur_sps->poc_type; // pic_order_cnt_type;
- if (cur_sps->poc_type == 0)
- pDXVAPicParams->log2_max_pic_order_cnt_lsb_minus4 = cur_sps->log2_max_poc_lsb - 4; // log2_max_pic_order_cnt_lsb_minus4;
- else if (cur_sps->poc_type == 1)
- pDXVAPicParams->delta_pic_order_always_zero_flag = cur_sps->delta_pic_order_always_zero_flag;
- pDXVAPicParams->direct_8x8_inference_flag = cur_sps->direct_8x8_inference_flag;
- pDXVAPicParams->entropy_coding_mode_flag = cur_pps->cabac; // entropy_coding_mode_flag;
- pDXVAPicParams->pic_order_present_flag = cur_pps->pic_order_present; // pic_order_present_flag;
- pDXVAPicParams->num_slice_groups_minus1 = cur_pps->slice_group_count - 1; // num_slice_groups_minus1;
- pDXVAPicParams->slice_group_map_type = cur_pps->mb_slice_group_map_type; // slice_group_map_type;
- pDXVAPicParams->deblocking_filter_control_present_flag = cur_pps->deblocking_filter_parameters_present; // deblocking_filter_control_present_flag;
- pDXVAPicParams->redundant_pic_cnt_present_flag = cur_pps->redundant_pic_cnt_present; // redundant_pic_cnt_present_flag;
-
- pDXVAPicParams->chroma_qp_index_offset = cur_pps->chroma_qp_index_offset[0];
- pDXVAPicParams->second_chroma_qp_index_offset = cur_pps->chroma_qp_index_offset[1];
- pDXVAPicParams->num_ref_idx_l0_active_minus1 = cur_pps->ref_count[0]-1; // num_ref_idx_l0_active_minus1;
- pDXVAPicParams->num_ref_idx_l1_active_minus1 = cur_pps->ref_count[1]-1; // num_ref_idx_l1_active_minus1;
- pDXVAPicParams->pic_init_qp_minus26 = cur_pps->init_qp - 26;
- pDXVAPicParams->pic_init_qs_minus26 = cur_pps->init_qs - 26;
-
- pDXVAPicParams->CurrPic.AssociatedFlag = field_pic_flag && (h->s.picture_structure == PICT_BOTTOM_FIELD);
- pDXVAPicParams->CurrFieldOrderCnt[0] = 0;
- if ((h->s.picture_structure & PICT_TOP_FIELD) && current_picture->field_poc[0] != INT_MAX) {
- pDXVAPicParams->CurrFieldOrderCnt[0] = current_picture->field_poc[0];
- }
- pDXVAPicParams->CurrFieldOrderCnt[1] = 0;
- if ((h->s.picture_structure & PICT_BOTTOM_FIELD) && current_picture->field_poc[1] != INT_MAX) {
- pDXVAPicParams->CurrFieldOrderCnt[1] = current_picture->field_poc[1];
- }
-
- CopyScalingMatrix (pDXVAScalingMatrix, cur_pps, nPCIVendor);
- hr = S_OK;
- }
-
- return hr;
+ H264Context* h = (H264Context*) pAVCtx->priv_data;
+ SPS* cur_sps;
+ PPS* cur_pps;
+ MpegEncContext* const s = &h->s;
+ int field_pic_flag;
+ HRESULT hr = E_FAIL;
+ const Picture* current_picture = s->current_picture_ptr;
+
+ field_pic_flag = (h->s.picture_structure != PICT_FRAME);
+
+ cur_sps = &h->sps;
+ cur_pps = &h->pps;
+
+ if (cur_sps && cur_pps) {
+ *nFieldType = h->s.picture_structure;
+ if (h->sps.pic_struct_present_flag) {
+ switch (h->sei_pic_struct) {
+ case SEI_PIC_STRUCT_TOP_FIELD:
+ case SEI_PIC_STRUCT_TOP_BOTTOM:
+ case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
+ *nFieldType = PICT_TOP_FIELD;
+ break;
+ case SEI_PIC_STRUCT_BOTTOM_FIELD:
+ case SEI_PIC_STRUCT_BOTTOM_TOP:
+ case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:
+ *nFieldType = PICT_BOTTOM_FIELD;
+ break;
+ case SEI_PIC_STRUCT_FRAME_DOUBLING:
+ case SEI_PIC_STRUCT_FRAME_TRIPLING:
+ case SEI_PIC_STRUCT_FRAME:
+ *nFieldType = PICT_FRAME;
+ break;
+ }
+ }
+
+ *nSliceType = h->slice_type;
+
+ if (cur_sps->mb_width == 0 || cur_sps->mb_height == 0) {
+ return VFW_E_INVALID_FILE_FORMAT;
+ }
+
+ pDXVAPicParams->wFrameWidthInMbsMinus1 = cur_sps->mb_width - 1; // pic_width_in_mbs_minus1;
+ pDXVAPicParams->wFrameHeightInMbsMinus1 = cur_sps->mb_height * (2 - cur_sps->frame_mbs_only_flag) - 1; // pic_height_in_map_units_minus1;
+ pDXVAPicParams->num_ref_frames = cur_sps->ref_frame_count; // num_ref_frames;
+ pDXVAPicParams->field_pic_flag = field_pic_flag;
+ pDXVAPicParams->MbaffFrameFlag = (h->sps.mb_aff && (field_pic_flag == 0));
+ pDXVAPicParams->residual_colour_transform_flag = cur_sps->residual_color_transform_flag;
+ pDXVAPicParams->sp_for_switch_flag = h->sp_for_switch_flag;
+ pDXVAPicParams->chroma_format_idc = cur_sps->chroma_format_idc;
+ pDXVAPicParams->RefPicFlag = h->ref_pic_flag;
+ pDXVAPicParams->constrained_intra_pred_flag = cur_pps->constrained_intra_pred;
+ pDXVAPicParams->weighted_pred_flag = cur_pps->weighted_pred;
+ pDXVAPicParams->weighted_bipred_idc = cur_pps->weighted_bipred_idc;
+ pDXVAPicParams->frame_mbs_only_flag = cur_sps->frame_mbs_only_flag;
+ pDXVAPicParams->transform_8x8_mode_flag = cur_pps->transform_8x8_mode;
+ pDXVAPicParams->MinLumaBipredSize8x8Flag = h->sps.level_idc >= 31;
+ pDXVAPicParams->IntraPicFlag = (h->slice_type == AV_PICTURE_TYPE_I || h->slice_type == AV_PICTURE_TYPE_SI);
+
+ pDXVAPicParams->bit_depth_luma_minus8 = cur_sps->bit_depth_luma - 8; // bit_depth_luma_minus8
+ pDXVAPicParams->bit_depth_chroma_minus8 = cur_sps->bit_depth_chroma - 8; // bit_depth_chroma_minus8
+
+ // pDXVAPicParams->StatusReportFeedbackNumber = SET IN DecodeFrame;
+ // pDXVAPicParams->CurrFieldOrderCnt = SET IN UpdateRefFramesList;
+ // pDXVAPicParams->FieldOrderCntList = SET IN UpdateRefFramesList;
+ // pDXVAPicParams->FrameNumList = SET IN UpdateRefFramesList;
+ // pDXVAPicParams->UsedForReferenceFlags = SET IN UpdateRefFramesList;
+ // pDXVAPicParams->NonExistingFrameFlags
+
+ pDXVAPicParams->frame_num = h->frame_num;
+
+ pDXVAPicParams->log2_max_frame_num_minus4 = cur_sps->log2_max_frame_num - 4; // log2_max_frame_num_minus4;
+ pDXVAPicParams->pic_order_cnt_type = cur_sps->poc_type; // pic_order_cnt_type;
+ if (cur_sps->poc_type == 0) {
+ pDXVAPicParams->log2_max_pic_order_cnt_lsb_minus4 = cur_sps->log2_max_poc_lsb - 4; // log2_max_pic_order_cnt_lsb_minus4;
+ } else if (cur_sps->poc_type == 1) {
+ pDXVAPicParams->delta_pic_order_always_zero_flag = cur_sps->delta_pic_order_always_zero_flag;
+ }
+ pDXVAPicParams->direct_8x8_inference_flag = cur_sps->direct_8x8_inference_flag;
+ pDXVAPicParams->entropy_coding_mode_flag = cur_pps->cabac; // entropy_coding_mode_flag;
+ pDXVAPicParams->pic_order_present_flag = cur_pps->pic_order_present; // pic_order_present_flag;
+ pDXVAPicParams->num_slice_groups_minus1 = cur_pps->slice_group_count - 1; // num_slice_groups_minus1;
+ pDXVAPicParams->slice_group_map_type = cur_pps->mb_slice_group_map_type; // slice_group_map_type;
+ pDXVAPicParams->deblocking_filter_control_present_flag = cur_pps->deblocking_filter_parameters_present; // deblocking_filter_control_present_flag;
+ pDXVAPicParams->redundant_pic_cnt_present_flag = cur_pps->redundant_pic_cnt_present; // redundant_pic_cnt_present_flag;
+
+ pDXVAPicParams->chroma_qp_index_offset = cur_pps->chroma_qp_index_offset[0];
+ pDXVAPicParams->second_chroma_qp_index_offset = cur_pps->chroma_qp_index_offset[1];
+ pDXVAPicParams->num_ref_idx_l0_active_minus1 = cur_pps->ref_count[0] - 1; // num_ref_idx_l0_active_minus1;
+ pDXVAPicParams->num_ref_idx_l1_active_minus1 = cur_pps->ref_count[1] - 1; // num_ref_idx_l1_active_minus1;
+ pDXVAPicParams->pic_init_qp_minus26 = cur_pps->init_qp - 26;
+ pDXVAPicParams->pic_init_qs_minus26 = cur_pps->init_qs - 26;
+
+ pDXVAPicParams->CurrPic.AssociatedFlag = field_pic_flag && (h->s.picture_structure == PICT_BOTTOM_FIELD);
+ pDXVAPicParams->CurrFieldOrderCnt[0] = 0;
+ if ((h->s.picture_structure & PICT_TOP_FIELD) && current_picture->field_poc[0] != INT_MAX) {
+ pDXVAPicParams->CurrFieldOrderCnt[0] = current_picture->field_poc[0];
+ }
+ pDXVAPicParams->CurrFieldOrderCnt[1] = 0;
+ if ((h->s.picture_structure & PICT_BOTTOM_FIELD) && current_picture->field_poc[1] != INT_MAX) {
+ pDXVAPicParams->CurrFieldOrderCnt[1] = current_picture->field_poc[1];
+ }
+
+ CopyScalingMatrix(pDXVAScalingMatrix, cur_pps, nPCIVendor);
+ hr = S_OK;
+ }
+
+ return hr;
}
-void FFH264SetCurrentPicture (int nIndex, DXVA_PicParams_H264* pDXVAPicParams, struct AVCodecContext* pAVCtx)
+void FFH264SetCurrentPicture(int nIndex, DXVA_PicParams_H264* pDXVAPicParams, struct AVCodecContext* pAVCtx)
{
- H264Context* h = (H264Context*) pAVCtx->priv_data;
+ H264Context* h = (H264Context*) pAVCtx->priv_data;
- pDXVAPicParams->CurrPic.Index7Bits = nIndex;
- if (h->s.current_picture_ptr) {
- h->s.current_picture_ptr->f.opaque = (void*)nIndex;
- }
+ pDXVAPicParams->CurrPic.Index7Bits = nIndex;
+ if (h->s.current_picture_ptr) {
+ h->s.current_picture_ptr->f.opaque = (void*)nIndex;
+ }
}
-void FFH264UpdateRefFramesList (DXVA_PicParams_H264* pDXVAPicParams, struct AVCodecContext* pAVCtx)
+void FFH264UpdateRefFramesList(DXVA_PicParams_H264* pDXVAPicParams, struct AVCodecContext* pAVCtx)
{
- H264Context* h = (H264Context*) pAVCtx->priv_data;
- UINT nUsedForReferenceFlags = 0;
- int i, j;
- Picture* pic;
- UCHAR AssociatedFlag;
-
- for (i=0, j=0; i<16; i++) {
- if (i < h->short_ref_count) {
- // Short list reference frames
- pic = h->short_ref[h->short_ref_count - i - 1];
- AssociatedFlag = pic->long_ref != 0;
- } else {
- // Long list reference frames
- pic = NULL;
- while (!pic && j < h->short_ref_count + 16) {
- pic = h->long_ref[j++ - h->short_ref_count];
- }
- AssociatedFlag = 1;
- }
-
- if (pic != NULL) {
- pDXVAPicParams->FrameNumList[i] = pic->long_ref ? pic->pic_id : pic->frame_num;
- pDXVAPicParams->FieldOrderCntList[i][0] = 0;
- pDXVAPicParams->FieldOrderCntList[i][1] = 0;
-
- if (pic->field_poc[0] != INT_MAX) {
- pDXVAPicParams->FieldOrderCntList[i][0] = pic->field_poc [0];
- nUsedForReferenceFlags |= 1<<(i*2);
- }
-
- if (pic->field_poc[1] != INT_MAX) {
- pDXVAPicParams->FieldOrderCntList[i][1] = pic->field_poc [1];
- nUsedForReferenceFlags |= 2<<(i*2);
- }
-
- pDXVAPicParams->RefFrameList[i].AssociatedFlag = AssociatedFlag;
- pDXVAPicParams->RefFrameList[i].Index7Bits = (UCHAR)pic->f.opaque;
- } else {
- pDXVAPicParams->FrameNumList[i] = 0;
- pDXVAPicParams->FieldOrderCntList[i][0] = 0;
- pDXVAPicParams->FieldOrderCntList[i][1] = 0;
- pDXVAPicParams->RefFrameList[i].AssociatedFlag = 1;
- pDXVAPicParams->RefFrameList[i].Index7Bits = 127;
- }
- }
-
- pDXVAPicParams->UsedForReferenceFlags = nUsedForReferenceFlags;
+ H264Context* h = (H264Context*) pAVCtx->priv_data;
+ UINT nUsedForReferenceFlags = 0;
+ int i, j;
+ Picture* pic;
+ UCHAR AssociatedFlag;
+
+ for (i = 0, j = 0; i < 16; i++) {
+ if (i < h->short_ref_count) {
+ // Short list reference frames
+ pic = h->short_ref[h->short_ref_count - i - 1];
+ AssociatedFlag = pic->long_ref != 0;
+ } else {
+ // Long list reference frames
+ pic = NULL;
+ while (!pic && j < h->short_ref_count + 16) {
+ pic = h->long_ref[j++ - h->short_ref_count];
+ }
+ AssociatedFlag = 1;
+ }
+
+ if (pic != NULL) {
+ pDXVAPicParams->FrameNumList[i] = pic->long_ref ? pic->pic_id : pic->frame_num;
+ pDXVAPicParams->FieldOrderCntList[i][0] = 0;
+ pDXVAPicParams->FieldOrderCntList[i][1] = 0;
+
+ if (pic->field_poc[0] != INT_MAX) {
+ pDXVAPicParams->FieldOrderCntList[i][0] = pic->field_poc [0];
+ nUsedForReferenceFlags |= 1 << (i * 2);
+ }
+
+ if (pic->field_poc[1] != INT_MAX) {
+ pDXVAPicParams->FieldOrderCntList[i][1] = pic->field_poc [1];
+ nUsedForReferenceFlags |= 2 << (i * 2);
+ }
+
+ pDXVAPicParams->RefFrameList[i].AssociatedFlag = AssociatedFlag;
+ pDXVAPicParams->RefFrameList[i].Index7Bits = (UCHAR)pic->f.opaque;
+ } else {
+ pDXVAPicParams->FrameNumList[i] = 0;
+ pDXVAPicParams->FieldOrderCntList[i][0] = 0;
+ pDXVAPicParams->FieldOrderCntList[i][1] = 0;
+ pDXVAPicParams->RefFrameList[i].AssociatedFlag = 1;
+ pDXVAPicParams->RefFrameList[i].Index7Bits = 127;
+ }
+ }
+
+ pDXVAPicParams->UsedForReferenceFlags = nUsedForReferenceFlags;
}
-BOOL FFH264IsRefFrameInUse (int nFrameNum, struct AVCodecContext* pAVCtx)
+BOOL FFH264IsRefFrameInUse(int nFrameNum, struct AVCodecContext* pAVCtx)
{
- H264Context* h = (H264Context*) pAVCtx->priv_data;
- int i;
-
- for (i=0; i<h->short_ref_count; i++) {
- if ((int)h->short_ref[i]->f.opaque == nFrameNum) {
- return TRUE;
- }
- }
-
- for (i=0; i<h->long_ref_count; i++) {
- if ((int)h->long_ref[i]->f.opaque == nFrameNum) {
- return TRUE;
- }
- }
-
- return FALSE;
+ H264Context* h = (H264Context*) pAVCtx->priv_data;
+ int i;
+
+ for (i = 0; i < h->short_ref_count; i++) {
+ if ((int)h->short_ref[i]->f.opaque == nFrameNum) {
+ return TRUE;
+ }
+ }
+
+ for (i = 0; i < h->long_ref_count; i++) {
+ if ((int)h->long_ref[i]->f.opaque == nFrameNum) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
}
void FF264UpdateRefFrameSliceLong(DXVA_PicParams_H264* pDXVAPicParams, DXVA_Slice_H264_Long* pSlice, struct AVCodecContext* pAVCtx)
{
- H264Context* h = (H264Context*) pAVCtx->priv_data;
- MpegEncContext* const s = &h->s;
- HRESULT hr = E_FAIL;
- unsigned i, list;
-
- for (list = 0; list < 2; list++) {
- for (i = 0; i < 32; i++) {
- pSlice->RefPicList[list][i].AssociatedFlag = 1;
- pSlice->RefPicList[list][i].Index7Bits = 127;
- pSlice->RefPicList[list][i].bPicEntry = 255;
- }
- }
-
- for (list = 0; list < 2; list++) {
- for (i = 0; i < 32; i++) {
- if (list < h->list_count && i < h->ref_count[list]) {
- const Picture *r = &h->ref_list[list][i];
- pSlice->RefPicList[list][i].Index7Bits = FFH264FindRefFrameIndex (h->ref_list[list][i].frame_num, pDXVAPicParams);
- pSlice->RefPicList[list][i].AssociatedFlag = r->f.reference == PICT_BOTTOM_FIELD;
- }
- }
- }
+ H264Context* h = (H264Context*) pAVCtx->priv_data;
+ MpegEncContext* const s = &h->s;
+ HRESULT hr = E_FAIL;
+ unsigned i, list;
+
+ for (list = 0; list < 2; list++) {
+ for (i = 0; i < 32; i++) {
+ pSlice->RefPicList[list][i].AssociatedFlag = 1;
+ pSlice->RefPicList[list][i].Index7Bits = 127;
+ pSlice->RefPicList[list][i].bPicEntry = 255;
+ }
+ }
+
+ for (list = 0; list < 2; list++) {
+ for (i = 0; i < 32; i++) {
+ if (list < h->list_count && i < h->ref_count[list]) {
+ const Picture* r = &h->ref_list[list][i];
+ pSlice->RefPicList[list][i].Index7Bits = FFH264FindRefFrameIndex(h->ref_list[list][i].frame_num, pDXVAPicParams);
+ pSlice->RefPicList[list][i].AssociatedFlag = r->f.reference == PICT_BOTTOM_FIELD;
+ }
+ }
+ }
}
-void FFH264SetDxvaSliceLong (struct AVCodecContext* pAVCtx, void* pSliceLong)
+void FFH264SetDxvaSliceLong(struct AVCodecContext* pAVCtx, void* pSliceLong)
{
- H264Context* h = (H264Context*) pAVCtx->priv_data;
- h->dxva_slice_long = pSliceLong;
+ H264Context* h = (H264Context*) pAVCtx->priv_data;
+ h->dxva_slice_long = pSliceLong;
}
-HRESULT FFVC1UpdatePictureParam (DXVA_PictureParameters* pPicParams, struct AVCodecContext* pAVCtx, int* nFieldType, int* nSliceType, BYTE* pBuffer, UINT nSize, UINT* nFrameSize, BOOL b_SecondField, BOOL* b_repeat_pict)
+HRESULT FFVC1UpdatePictureParam(DXVA_PictureParameters* pPicParams, struct AVCodecContext* pAVCtx, int* nFieldType, int* nSliceType, BYTE* pBuffer, UINT nSize, UINT* nFrameSize, BOOL b_SecondField, BOOL* b_repeat_pict)
{
- VC1Context* vc1 = (VC1Context*) pAVCtx->priv_data;
- int out_nFrameSize = 0;
-
- if (pBuffer && !b_SecondField) {
- av_vc1_decode_frame (pAVCtx, pBuffer, nSize, &out_nFrameSize);
- }
-
- // WARNING : vc1->interlace is not reliable (always set for progressive video on HD-DVD material)
- if (vc1->fcm == 0) {
- if (nFieldType) {
- *nFieldType = PICT_FRAME;
- }
- } else { // fcm : 2 or 3 frame or field interlaced
- if (nFieldType) {
- *nFieldType = (vc1->tff ? PICT_TOP_FIELD : PICT_BOTTOM_FIELD);
- }
- }
-
- if (b_SecondField) {
- vc1->second_field = 1;
- vc1->s.picture_structure = PICT_TOP_FIELD + vc1->tff;
- vc1->s.pict_type = (vc1->fptype & 1) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
- if (vc1->fptype & 4)
- vc1->s.pict_type = (vc1->fptype & 1) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B;
- }
-
- if (nFrameSize) {
- *nFrameSize = out_nFrameSize;
- }
-
- if (vc1->profile == PROFILE_ADVANCED) {
- /* It is the cropped width/height -1 of the frame */
- pPicParams->wPicWidthInMBminus1 = pAVCtx->width - 1;
- pPicParams->wPicHeightInMBminus1= pAVCtx->height - 1;
- } else {
- /* It is the coded width/height in macroblock -1 of the frame */
- pPicParams->wPicWidthInMBminus1 = vc1->s.mb_width - 1;
- pPicParams->wPicHeightInMBminus1= vc1->s.mb_height - 1;
- }
-
- pPicParams->bSecondField = (vc1->interlace && vc1->fcm == ILACE_FIELD && vc1->second_field);
- pPicParams->bPicIntra = vc1->s.pict_type == AV_PICTURE_TYPE_I;
- pPicParams->bPicBackwardPrediction = vc1->s.pict_type == AV_PICTURE_TYPE_B;
-
-
- // Init Init Init Todo
- // iWMV9 - i9IRU - iOHIT - iINSO - iWMVA - 0 - 0 - 0 | Section 3.2.5
- pPicParams->bBidirectionalAveragingMode = (pPicParams->bBidirectionalAveragingMode & 0xE0) | // init in SetExtraData
- ((vc1->lumshift!=0 || vc1->lumscale!=32) ? 0x10 : 0)| // iINSO
- ((vc1->profile == PROFILE_ADVANCED) <<3 ); // iWMVA
-
- // Section 3.2.20.3
- pPicParams->bPicSpatialResid8 = (vc1->panscanflag << 7) | (vc1->refdist_flag << 6) |
- (vc1->s.loop_filter << 5) | (vc1->fastuvmc << 4) |
- (vc1->extended_mv << 3) | (vc1->dquant << 1) |
- (vc1->vstransform);
-
- // Section 3.2.20.4
- pPicParams->bPicOverflowBlocks = (vc1->quantizer_mode << 6) | (vc1->multires << 5) |
- (vc1->s.resync_marker << 4) | (vc1->rangered << 3) |
- (vc1->s.max_b_frames);
-
- // Section 3.2.20.2
- pPicParams->bPicDeblockConfined = (vc1->postprocflag << 7) | (vc1->broadcast << 6) |
- (vc1->interlace << 5) | (vc1->tfcntrflag << 4) |
- (vc1->finterpflag << 3) | // (refpic << 2) set in DecodeFrame !
- (vc1->psf << 1) | vc1->extended_dmv;
-
-
- pPicParams->bPicStructure = 0;
- if (vc1->s.picture_structure & PICT_TOP_FIELD) {
- pPicParams->bPicStructure |= 0x01;
- }
- if (vc1->s.picture_structure & PICT_BOTTOM_FIELD) {
- pPicParams->bPicStructure |= 0x02;
- }
-
- pPicParams->bMVprecisionAndChromaRelation = ((vc1->mv_mode == MV_PMODE_1MV_HPEL_BILIN) << 3) |
- (1 << 2) |
- (0 << 1) |
- (!vc1->s.quarter_sample );
-
- // Cf page 17 : 2 for interlaced, 0 for progressive
- pPicParams->bPicExtrapolation = (!vc1->interlace || vc1->fcm == PROGRESSIVE) ? 1 : 2;
-
- if (vc1->s.picture_structure == PICT_FRAME) {
- pPicParams->wBitstreamFcodes = vc1->lumscale;
- pPicParams->wBitstreamPCEelements = vc1->lumshift;
- } else {
- /* Syntax: (top_field_param << 8) | bottom_field_param */
- pPicParams->wBitstreamFcodes = (vc1->lumscale << 8) | vc1->lumscale;
- pPicParams->wBitstreamPCEelements = (vc1->lumshift << 8) | vc1->lumshift;
- }
-
- if (vc1->profile == PROFILE_ADVANCED) {
- pPicParams->bPicOBMC = (vc1->range_mapy_flag << 7) |
- (vc1->range_mapy << 4) |
- (vc1->range_mapuv_flag << 3) |
- (vc1->range_mapuv );
- }
-
- // Section 3.2.16
- if (nSliceType) {
- *nSliceType = vc1->s.pict_type;
- }
-
- // Cf section 7.1.1.25 in VC1 specification, section 3.2.14.3 in DXVA spec
- pPicParams->bRcontrol = vc1->rnd;
-
- pPicParams->bPicDeblocked = ((vc1->profile == PROFILE_ADVANCED && vc1->overlap == 1 &&
- pPicParams->bPicBackwardPrediction == 0) << 6) |
- ((vc1->profile != PROFILE_ADVANCED && vc1->rangeredfrm) << 5) |
- (vc1->s.loop_filter << 1);
-
- if (vc1->profile == PROFILE_ADVANCED && (vc1->rff || vc1->rptfrm)) {
- *b_repeat_pict = TRUE;
- }
-
- return S_OK;
+ VC1Context* vc1 = (VC1Context*) pAVCtx->priv_data;
+ int out_nFrameSize = 0;
+
+ if (pBuffer && !b_SecondField) {
+ av_vc1_decode_frame(pAVCtx, pBuffer, nSize, &out_nFrameSize);
+ }
+
+ // WARNING : vc1->interlace is not reliable (always set for progressive video on HD-DVD material)
+ if (vc1->fcm == 0) {
+ if (nFieldType) {
+ *nFieldType = PICT_FRAME;
+ }
+ } else { // fcm : 2 or 3 frame or field interlaced
+ if (nFieldType) {
+ *nFieldType = (vc1->tff ? PICT_TOP_FIELD : PICT_BOTTOM_FIELD);
+ }
+ }
+
+ if (b_SecondField) {
+ vc1->second_field = 1;
+ vc1->s.picture_structure = PICT_TOP_FIELD + vc1->tff;
+ vc1->s.pict_type = (vc1->fptype & 1) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
+ if (vc1->fptype & 4) {
+ vc1->s.pict_type = (vc1->fptype & 1) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B;
+ }
+ }
+
+ if (nFrameSize) {
+ *nFrameSize = out_nFrameSize;
+ }
+
+ if (vc1->profile == PROFILE_ADVANCED) {
+ /* It is the cropped width/height -1 of the frame */
+ pPicParams->wPicWidthInMBminus1 = pAVCtx->width - 1;
+ pPicParams->wPicHeightInMBminus1 = pAVCtx->height - 1;
+ } else {
+ /* It is the coded width/height in macroblock -1 of the frame */
+ pPicParams->wPicWidthInMBminus1 = vc1->s.mb_width - 1;
+ pPicParams->wPicHeightInMBminus1 = vc1->s.mb_height - 1;
+ }
+
+ pPicParams->bSecondField = (vc1->interlace && vc1->fcm == ILACE_FIELD && vc1->second_field);
+ pPicParams->bPicIntra = vc1->s.pict_type == AV_PICTURE_TYPE_I;
+ pPicParams->bPicBackwardPrediction = vc1->s.pict_type == AV_PICTURE_TYPE_B;
+
+
+ // Init Init Init Todo
+ // iWMV9 - i9IRU - iOHIT - iINSO - iWMVA - 0 - 0 - 0 | Section 3.2.5
+ pPicParams->bBidirectionalAveragingMode = (pPicParams->bBidirectionalAveragingMode & 0xE0) | // init in SetExtraData
+ ((vc1->lumshift != 0 || vc1->lumscale != 32) ? 0x10 : 0) | // iINSO
+ ((vc1->profile == PROFILE_ADVANCED) << 3); // iWMVA
+
+ // Section 3.2.20.3
+ pPicParams->bPicSpatialResid8 = (vc1->panscanflag << 7) | (vc1->refdist_flag << 6) |
+ (vc1->s.loop_filter << 5) | (vc1->fastuvmc << 4) |
+ (vc1->extended_mv << 3) | (vc1->dquant << 1) |
+ (vc1->vstransform);
+
+ // Section 3.2.20.4
+ pPicParams->bPicOverflowBlocks = (vc1->quantizer_mode << 6) | (vc1->multires << 5) |
+ (vc1->s.resync_marker << 4) | (vc1->rangered << 3) |
+ (vc1->s.max_b_frames);
+
+ // Section 3.2.20.2
+ pPicParams->bPicDeblockConfined = (vc1->postprocflag << 7) | (vc1->broadcast << 6) |
+ (vc1->interlace << 5) | (vc1->tfcntrflag << 4) |
+ (vc1->finterpflag << 3) | // (refpic << 2) set in DecodeFrame !
+ (vc1->psf << 1) | vc1->extended_dmv;
+
+
+ pPicParams->bPicStructure = 0;
+ if (vc1->s.picture_structure & PICT_TOP_FIELD) {
+ pPicParams->bPicStructure |= 0x01;
+ }
+ if (vc1->s.picture_structure & PICT_BOTTOM_FIELD) {
+ pPicParams->bPicStructure |= 0x02;
+ }
+
+ pPicParams->bMVprecisionAndChromaRelation = ((vc1->mv_mode == MV_PMODE_1MV_HPEL_BILIN) << 3) |
+ (1 << 2) |
+ (0 << 1) |
+ (!vc1->s.quarter_sample);
+
+ // Cf page 17 : 2 for interlaced, 0 for progressive
+ pPicParams->bPicExtrapolation = (!vc1->interlace || vc1->fcm == PROGRESSIVE) ? 1 : 2;
+
+ if (vc1->s.picture_structure == PICT_FRAME) {
+ pPicParams->wBitstreamFcodes = vc1->lumscale;
+ pPicParams->wBitstreamPCEelements = vc1->lumshift;
+ } else {
+ /* Syntax: (top_field_param << 8) | bottom_field_param */
+ pPicParams->wBitstreamFcodes = (vc1->lumscale << 8) | vc1->lumscale;
+ pPicParams->wBitstreamPCEelements = (vc1->lumshift << 8) | vc1->lumshift;
+ }
+
+ if (vc1->profile == PROFILE_ADVANCED) {
+ pPicParams->bPicOBMC = (vc1->range_mapy_flag << 7) |
+ (vc1->range_mapy << 4) |
+ (vc1->range_mapuv_flag << 3) |
+ (vc1->range_mapuv);
+ }
+
+ // Section 3.2.16
+ if (nSliceType) {
+ *nSliceType = vc1->s.pict_type;
+ }
+
+ // Cf section 7.1.1.25 in VC1 specification, section 3.2.14.3 in DXVA spec
+ pPicParams->bRcontrol = vc1->rnd;
+
+ pPicParams->bPicDeblocked = ((vc1->profile == PROFILE_ADVANCED && vc1->overlap == 1 &&
+ pPicParams->bPicBackwardPrediction == 0) << 6) |
+ ((vc1->profile != PROFILE_ADVANCED && vc1->rangeredfrm) << 5) |
+ (vc1->s.loop_filter << 1);
+
+ if (vc1->profile == PROFILE_ADVANCED && (vc1->rff || vc1->rptfrm)) {
+ *b_repeat_pict = TRUE;
+ }
+
+ return S_OK;
}
-int MPEG2CheckCompatibility(struct AVCodecContext* pAVCtx, struct AVFrame* pFrame)
+int MPEG2CheckCompatibility(struct AVCodecContext* pAVCtx, struct AVFrame* pFrame)
{
- int got_picture = 0;
- Mpeg1Context* s1 = (Mpeg1Context*)pAVCtx->priv_data;
- MpegEncContext* s = (MpegEncContext*)&s1->mpeg_enc_ctx;
- AVPacket avpkt;
+ int got_picture = 0;
+ Mpeg1Context* s1 = (Mpeg1Context*)pAVCtx->priv_data;
+ MpegEncContext* s = (MpegEncContext*)&s1->mpeg_enc_ctx;
+ AVPacket avpkt;
- av_init_packet(&avpkt);
- avpkt.data = (BYTE*)pAVCtx->extradata;
- avpkt.size = pAVCtx->extradata_size;
- avpkt.flags = AV_PKT_FLAG_KEY;
+ av_init_packet(&avpkt);
+ avpkt.data = (BYTE*)pAVCtx->extradata;
+ avpkt.size = pAVCtx->extradata_size;
+ avpkt.flags = AV_PKT_FLAG_KEY;
- avcodec_decode_video2(pAVCtx, pFrame, &got_picture, &avpkt);
+ avcodec_decode_video2(pAVCtx, pFrame, &got_picture, &avpkt);
- return (s->chroma_format<2);
+ return (s->chroma_format < 2);
}
-HRESULT FFMpeg2DecodeFrame (DXVA_PictureParameters* pPicParams, DXVA_QmatrixData* pQMatrixData, DXVA_SliceInfo* pSliceInfo, int* nSliceCount,
- struct AVCodecContext* pAVCtx, struct AVFrame* pFrame, int* nNextCodecIndex, int* nFieldType, int* nSliceType, BYTE* pBuffer, UINT nSize)
+HRESULT FFMpeg2DecodeFrame(DXVA_PictureParameters* pPicParams, DXVA_QmatrixData* pQMatrixData, DXVA_SliceInfo* pSliceInfo, int* nSliceCount,
+ struct AVCodecContext* pAVCtx, struct AVFrame* pFrame, int* nNextCodecIndex, int* nFieldType, int* nSliceType, BYTE* pBuffer, UINT nSize)
{
- int i;
- int got_picture = 0;
- Mpeg1Context* s1 = (Mpeg1Context*)pAVCtx->priv_data;
- MpegEncContext* s = (MpegEncContext*)&s1->mpeg_enc_ctx;
- int is_field = 0;
- unsigned mb_count = 0;
-
- AVPacket avpkt;
-
- if (pBuffer) {
- s1->pSliceInfo = pSliceInfo;
-
- av_init_packet(&avpkt);
- avpkt.data = pBuffer;
- avpkt.size = nSize;
- avpkt.flags = AV_PKT_FLAG_KEY;
- avcodec_decode_video2(pAVCtx, pFrame, &got_picture, &avpkt);
-
- *nSliceCount = s1->slice_count;
- *nFieldType = s->progressive_frame ? PICT_FRAME : s->current_picture.f.top_field_first ? PICT_TOP_FIELD : PICT_BOTTOM_FIELD;
- *nSliceType = s->pict_type;
- }
-
- // pPicParams->wDecodedPictureIndex; set in DecodeFrame
- // pPicParams->wDeblockedPictureIndex; 0 for Mpeg2
- // pPicParams->wForwardRefPictureIndex; set in DecodeFrame
- // pPicParams->wBackwardRefPictureIndex; set in DecodeFrame
-
- is_field = s->picture_structure != PICT_FRAME;
-
- pPicParams->wPicWidthInMBminus1 = s->mb_width-1;
- pPicParams->wPicHeightInMBminus1 = (s->mb_height >> is_field) - 1;
-
- pPicParams->bMacroblockWidthMinus1 = 15; // This is equal to "15" for MPEG-1, MPEG-2, H.263, and MPEG-4
- pPicParams->bMacroblockHeightMinus1 = 15; // This is equal to "15" for MPEG-1, MPEG-2, H.261, H.263, and MPEG-4
-
- pPicParams->bBlockWidthMinus1 = 7; // This is equal to "7" for MPEG-1, MPEG-2, H.261, H.263, and MPEG-4
- pPicParams->bBlockHeightMinus1 = 7; // This is equal to "7" for MPEG-1, MPEG-2, H.261, H.263, and MPEG-4
-
- pPicParams->bBPPminus1 = 7; // It is equal to "7" for MPEG-1, MPEG-2, H.261, and H.263
-
- pPicParams->bPicStructure = s->picture_structure;
- pPicParams->bSecondField = is_field && !s->first_field;
- pPicParams->bPicIntra = (s->current_picture.f.pict_type == AV_PICTURE_TYPE_I);
- pPicParams->bPicBackwardPrediction = (s->current_picture.f.pict_type == AV_PICTURE_TYPE_B);
-
- pPicParams->bBidirectionalAveragingMode = 0; // The value "0" indicates MPEG-1 and MPEG-2 rounded averaging (//2),
- //pPicParams->bMVprecisionAndChromaRelation = 0; // Indicates that luminance motion vectors have half-sample precision and that chrominance motion vectors are derived from luminance motion vectors according to the rules in MPEG-2
- pPicParams->bChromaFormat = 0x01; // For MPEG-1, MPEG-2 "Main Profile," H.261 and H.263 bitstreams, this value shall always be set to "01", indicating "4:2:0" format
-
- // pPicParams->bPicScanFixed = 1; // set in UpdatePicParams
- // pPicParams->bPicScanMethod = 1; // set in UpdatePicParams
- // pPicParams->bPicReadbackRequests; // ??
-
- // pPicParams->bRcontrol = 0; // It shall be set to "0" for all MPEG-1, and MPEG-2 bitstreams in order to conform with the rounding operator defined by those standards
- // pPicParams->bPicSpatialResid8; // set in UpdatePicParams
- // pPicParams->bPicOverflowBlocks; // set in UpdatePicParams
- // pPicParams->bPicExtrapolation; = 0; // by H.263 Annex D and MPEG-4
-
- // pPicParams->bPicDeblocked; = 0; // MPEG2_A Restricted Profile
- // pPicParams->bPicDeblockConfined; // ??
- // pPicParams->bPic4MVallowed; // See H.263 Annexes F and J
- // pPicParams->bPicOBMC; // H.263 Annex F
- // pPicParams->bPicBinPB; // Annexes G and M of H.263
- // pPicParams->bMV_RPS; // ???
- // pPicParams->bReservedBits; // ??
-
- pPicParams->wBitstreamFcodes = (s->mpeg_f_code[0][0]<<12) | (s->mpeg_f_code[0][1]<<8) |
- (s->mpeg_f_code[1][0]<<4) | (s->mpeg_f_code[1][1]);
-
- pPicParams->wBitstreamPCEelements = (s->intra_dc_precision<<14) | (s->picture_structure<<12) |
- (s->top_field_first<<11) | (s->frame_pred_frame_dct<<10)|
- (s->concealment_motion_vectors<<9) | (s->q_scale_type<<8)|
- (s->intra_vlc_format<<7) | (s->alternate_scan<<6)|
- (s->repeat_first_field<<5) | (s->chroma_420_type<<4)|
- (s->progressive_frame<<3);
-
- pPicParams->bBitstreamConcealmentNeed = 0;
- pPicParams->bBitstreamConcealmentMethod = 0;
-
- pQMatrixData->bNewQmatrix[0] = 1;
- pQMatrixData->bNewQmatrix[1] = 1;
- pQMatrixData->bNewQmatrix[2] = 1;
- pQMatrixData->bNewQmatrix[3] = 1;
- for (i = 0; i < 64; i++) {
- int n = s->dsp.idct_permutation[ZZ_SCAN8[i]];
- pQMatrixData->Qmatrix[0][i] = s->intra_matrix[n];
- pQMatrixData->Qmatrix[1][i] = s->inter_matrix[n];
- pQMatrixData->Qmatrix[2][i] = s->chroma_intra_matrix[n];
- pQMatrixData->Qmatrix[3][i] = s->chroma_inter_matrix[n];
- }
-
- mb_count = s->mb_width * (s->mb_height >> is_field);
- for (i = 0; i < s1->slice_count; i++) {
- DXVA_SliceInfo *slice = &s1->pSliceInfo[i];
-
- if (i < s1->slice_count - 1) {
- slice->wNumberMBsInSlice = slice[1].wNumberMBsInSlice - slice[0].wNumberMBsInSlice;
- } else {
- slice->wNumberMBsInSlice = mb_count - slice[0].wNumberMBsInSlice;
- }
- }
-
- if (got_picture) {
- *nNextCodecIndex = pFrame->coded_picture_number;
- }
-
- return S_OK;
+ int i;
+ int got_picture = 0;
+ Mpeg1Context* s1 = (Mpeg1Context*)pAVCtx->priv_data;
+ MpegEncContext* s = (MpegEncContext*)&s1->mpeg_enc_ctx;
+ int is_field = 0;
+ unsigned mb_count = 0;
+
+ AVPacket avpkt;
+
+ if (pBuffer) {
+ s1->pSliceInfo = pSliceInfo;
+
+ av_init_packet(&avpkt);
+ avpkt.data = pBuffer;
+ avpkt.size = nSize;
+ avpkt.flags = AV_PKT_FLAG_KEY;
+ avcodec_decode_video2(pAVCtx, pFrame, &got_picture, &avpkt);
+
+ *nSliceCount = s1->slice_count;
+ *nFieldType = s->progressive_frame ? PICT_FRAME : s->current_picture.f.top_field_first ? PICT_TOP_FIELD : PICT_BOTTOM_FIELD;
+ *nSliceType = s->pict_type;
+ }
+
+ // pPicParams->wDecodedPictureIndex; set in DecodeFrame
+ // pPicParams->wDeblockedPictureIndex; 0 for Mpeg2
+ // pPicParams->wForwardRefPictureIndex; set in DecodeFrame
+ // pPicParams->wBackwardRefPictureIndex; set in DecodeFrame
+
+ is_field = s->picture_structure != PICT_FRAME;
+
+ pPicParams->wPicWidthInMBminus1 = s->mb_width - 1;
+ pPicParams->wPicHeightInMBminus1 = (s->mb_height >> is_field) - 1;
+
+ pPicParams->bMacroblockWidthMinus1 = 15; // This is equal to "15" for MPEG-1, MPEG-2, H.263, and MPEG-4
+ pPicParams->bMacroblockHeightMinus1 = 15; // This is equal to "15" for MPEG-1, MPEG-2, H.261, H.263, and MPEG-4
+
+ pPicParams->bBlockWidthMinus1 = 7; // This is equal to "7" for MPEG-1, MPEG-2, H.261, H.263, and MPEG-4
+ pPicParams->bBlockHeightMinus1 = 7; // This is equal to "7" for MPEG-1, MPEG-2, H.261, H.263, and MPEG-4
+
+ pPicParams->bBPPminus1 = 7; // It is equal to "7" for MPEG-1, MPEG-2, H.261, and H.263
+
+ pPicParams->bPicStructure = s->picture_structure;
+ pPicParams->bSecondField = is_field && !s->first_field;
+ pPicParams->bPicIntra = (s->current_picture.f.pict_type == AV_PICTURE_TYPE_I);
+ pPicParams->bPicBackwardPrediction = (s->current_picture.f.pict_type == AV_PICTURE_TYPE_B);
+
+ pPicParams->bBidirectionalAveragingMode = 0; // The value "0" indicates MPEG-1 and MPEG-2 rounded averaging (//2),
+ //pPicParams->bMVprecisionAndChromaRelation = 0; // Indicates that luminance motion vectors have half-sample precision and that chrominance motion vectors are derived from luminance motion vectors according to the rules in MPEG-2
+ pPicParams->bChromaFormat = 0x01; // For MPEG-1, MPEG-2 "Main Profile," H.261 and H.263 bitstreams, this value shall always be set to "01", indicating "4:2:0" format
+
+ // pPicParams->bPicScanFixed = 1; // set in UpdatePicParams
+ // pPicParams->bPicScanMethod = 1; // set in UpdatePicParams
+ // pPicParams->bPicReadbackRequests; // ??
+
+ // pPicParams->bRcontrol = 0; // It shall be set to "0" for all MPEG-1, and MPEG-2 bitstreams in order to conform with the rounding operator defined by those standards
+ // pPicParams->bPicSpatialResid8; // set in UpdatePicParams
+ // pPicParams->bPicOverflowBlocks; // set in UpdatePicParams
+ // pPicParams->bPicExtrapolation; = 0; // by H.263 Annex D and MPEG-4
+
+ // pPicParams->bPicDeblocked; = 0; // MPEG2_A Restricted Profile
+ // pPicParams->bPicDeblockConfined; // ??
+ // pPicParams->bPic4MVallowed; // See H.263 Annexes F and J
+ // pPicParams->bPicOBMC; // H.263 Annex F
+ // pPicParams->bPicBinPB; // Annexes G and M of H.263
+ // pPicParams->bMV_RPS; // ???
+ // pPicParams->bReservedBits; // ??
+
+ pPicParams->wBitstreamFcodes = (s->mpeg_f_code[0][0] << 12) | (s->mpeg_f_code[0][1] << 8) |
+ (s->mpeg_f_code[1][0] << 4) | (s->mpeg_f_code[1][1]);
+
+ pPicParams->wBitstreamPCEelements = (s->intra_dc_precision << 14) | (s->picture_structure << 12) |
+ (s->top_field_first << 11) | (s->frame_pred_frame_dct << 10) |
+ (s->concealment_motion_vectors << 9) | (s->q_scale_type << 8) |
+ (s->intra_vlc_format << 7) | (s->alternate_scan << 6) |
+ (s->repeat_first_field << 5) | (s->chroma_420_type << 4) |
+ (s->progressive_frame << 3);
+
+ pPicParams->bBitstreamConcealmentNeed = 0;
+ pPicParams->bBitstreamConcealmentMethod = 0;
+
+ pQMatrixData->bNewQmatrix[0] = 1;
+ pQMatrixData->bNewQmatrix[1] = 1;
+ pQMatrixData->bNewQmatrix[2] = 1;
+ pQMatrixData->bNewQmatrix[3] = 1;
+ for (i = 0; i < 64; i++) {
+ int n = s->dsp.idct_permutation[ZZ_SCAN8[i]];
+ pQMatrixData->Qmatrix[0][i] = s->intra_matrix[n];
+ pQMatrixData->Qmatrix[1][i] = s->inter_matrix[n];
+ pQMatrixData->Qmatrix[2][i] = s->chroma_intra_matrix[n];
+ pQMatrixData->Qmatrix[3][i] = s->chroma_inter_matrix[n];
+ }
+
+ mb_count = s->mb_width * (s->mb_height >> is_field);
+ for (i = 0; i < s1->slice_count; i++) {
+ DXVA_SliceInfo* slice = &s1->pSliceInfo[i];
+
+ if (i < s1->slice_count - 1) {
+ slice->wNumberMBsInSlice = slice[1].wNumberMBsInSlice - slice[0].wNumberMBsInSlice;
+ } else {
+ slice->wNumberMBsInSlice = mb_count - slice[0].wNumberMBsInSlice;
+ }
+ }
+
+ if (got_picture) {
+ *nNextCodecIndex = pFrame->coded_picture_number;
+ }
+
+ return S_OK;
}
unsigned long FFGetMBNumber(struct AVCodecContext* pAVCtx)
{
- MpegEncContext* s = GetMpegEncContext(pAVCtx);
+ MpegEncContext* s = GetMpegEncContext(pAVCtx);
- return (s != NULL) ? s->mb_num : 0;
+ return (s != NULL) ? s->mb_num : 0;
}
int FFIsSkipped(struct AVCodecContext* pAVCtx)
{
- VC1Context* vc1 = (VC1Context*) pAVCtx->priv_data;
- return vc1->p_frame_skipped;
+ VC1Context* vc1 = (VC1Context*) pAVCtx->priv_data;
+ return vc1->p_frame_skipped;
}
int FFGetThreadType(enum CodecID nCodecId, int nThreadCount)
{
- if (!nThreadCount) {
- return 0;
- }
- switch (nCodecId)
- {
- case CODEC_ID_H264 :
- return FF_THREAD_FRAME|FF_THREAD_SLICE;
- break;
- case CODEC_ID_MPEG1VIDEO :
- case CODEC_ID_DVVIDEO :
- case CODEC_ID_FFV1 :
- return FF_THREAD_SLICE;
- break;
- case CODEC_ID_VP3 :
- case CODEC_ID_VP8 :
- case CODEC_ID_THEORA :
- case CODEC_ID_RV30 :
- case CODEC_ID_RV40 :
- return FF_THREAD_FRAME;
- break;
- default :
- return 0;
- }
+ if (!nThreadCount) {
+ return 0;
+ }
+ switch (nCodecId) {
+ case CODEC_ID_H264 :
+ return FF_THREAD_FRAME | FF_THREAD_SLICE;
+ break;
+ case CODEC_ID_MPEG1VIDEO :
+ case CODEC_ID_DVVIDEO :
+ case CODEC_ID_FFV1 :
+ return FF_THREAD_SLICE;
+ break;
+ case CODEC_ID_VP3 :
+ case CODEC_ID_VP8 :
+ case CODEC_ID_THEORA :
+ case CODEC_ID_RV30 :
+ case CODEC_ID_RV40 :
+ return FF_THREAD_FRAME;
+ break;
+ default :
+ return 0;
+ }
}
void FFSetThreadNumber(struct AVCodecContext* pAVCtx, enum CodecID nCodecId, int nThreadCount)
{
- pAVCtx->thread_count = nThreadCount;
- pAVCtx->thread_type = FFGetThreadType (nCodecId, nThreadCount);
+ pAVCtx->thread_count = nThreadCount;
+ pAVCtx->thread_type = FFGetThreadType(nCodecId, nThreadCount);
}
BOOL FFSoftwareCheckCompatibility(struct AVCodecContext* pAVCtx)
{
- if (pAVCtx->codec_id == CODEC_ID_VC1) {
- VC1Context* vc1 = (VC1Context*) pAVCtx->priv_data;
- return !vc1->interlace;
- } else {
- return TRUE;
- }
+ if (pAVCtx->codec_id == CODEC_ID_VC1) {
+ VC1Context* vc1 = (VC1Context*) pAVCtx->priv_data;
+ return !vc1->interlace;
+ } else {
+ return TRUE;
+ }
}
int FFGetCodedPicture(struct AVCodecContext* pAVCtx)
{
- MpegEncContext* s = GetMpegEncContext(pAVCtx);
+ MpegEncContext* s = GetMpegEncContext(pAVCtx);
- return (s != NULL) ? s->current_picture.f.coded_picture_number : 0;
+ return (s != NULL) ? s->current_picture.f.coded_picture_number : 0;
}
BOOL FFGetAlternateScan(struct AVCodecContext* pAVCtx)
{
- MpegEncContext* s = GetMpegEncContext(pAVCtx);
+ MpegEncContext* s = GetMpegEncContext(pAVCtx);
- return (s != NULL) ? s->alternate_scan : 0;
+ return (s != NULL) ? s->alternate_scan : 0;
}
BOOL DXVACheckFramesize(int width, int height, DWORD nPCIVendor/*, DWORD nPCIDevice*/)
{
- width = (width + 15)&0xFFFFFFF0; // (width + 15) / 16 * 16;
- height = (height + 15)&0xFFFFFFF0; // (height + 15) / 16 * 16;
-
- if ((nPCIVendor == PCIV_nVidia) && (width <= 2032 && height <= 2032 && width*height <= 8190*16*16)) {
- // tested H.264, VC-1 and MPEG-2 on VP4 (feature set C) (G210M, GT220)
- return TRUE;
- } else if ((nPCIVendor == PCIV_ATI) && (width <= 2048 && height <= 2304 && width*height <= 2048*2048)) {
- // tested H.264 on UVD 2.2 (HD5670, HD5770, HD5850)
- // it may also work if width = 2064, but unstable
- return TRUE;
- } else if (width <= 1920 && height <= 1088) {
- return TRUE;
- }
-
- return FALSE;
+ width = (width + 15) & 0xFFFFFFF0; // (width + 15) / 16 * 16;
+ height = (height + 15) & 0xFFFFFFF0; // (height + 15) / 16 * 16;
+
+ if ((nPCIVendor == PCIV_nVidia) && (width <= 2032 && height <= 2032 && width * height <= 8190 * 16 * 16)) {
+ // tested H.264, VC-1 and MPEG-2 on VP4 (feature set C) (G210M, GT220)
+ return TRUE;
+ } else if ((nPCIVendor == PCIV_ATI) && (width <= 2048 && height <= 2304 && width * height <= 2048 * 2048)) {
+ // tested H.264 on UVD 2.2 (HD5670, HD5770, HD5850)
+ // it may also work if width = 2064, but unstable
+ return TRUE;
+ } else if (width <= 1920 && height <= 1088) {
+ return TRUE;
+ }
+
+ return FALSE;
}
diff --git a/src/filters/transform/MPCVideoDec/FfmpegContext.h b/src/filters/transform/MPCVideoDec/FfmpegContext.h
index a2ffd414e..4e4983b52 100644
--- a/src/filters/transform/MPCVideoDec/FfmpegContext.h
+++ b/src/filters/transform/MPCVideoDec/FfmpegContext.h
@@ -28,50 +28,50 @@ struct AVCodecContext;
struct AVFrame;
enum PCI_Vendors {
- PCIV_ATI = 0x1002,
- PCIV_nVidia = 0x10DE,
- PCIV_Intel = 0x8086,
- PCIV_S3_Graphics = 0x5333
+ PCIV_ATI = 0x1002,
+ PCIV_nVidia = 0x10DE,
+ PCIV_Intel = 0x8086,
+ PCIV_S3_Graphics = 0x5333
};
// Bitmasks for DXVA compatibility check
-#define DXVA_UNSUPPORTED_LEVEL 1
-#define DXVA_TOO_MANY_REF_FRAMES 2
-#define DXVA_INCOMPATIBLE_SAR 4
-#define DXVA_PROFILE_HIGHER_THAN_HIGH 8
-#define DXVA_HIGH_BIT 16
+#define DXVA_UNSUPPORTED_LEVEL 1
+#define DXVA_TOO_MANY_REF_FRAMES 2
+#define DXVA_INCOMPATIBLE_SAR 4
+#define DXVA_PROFILE_HIGHER_THAN_HIGH 8
+#define DXVA_HIGH_BIT 16
// === H264 functions
-int FFH264DecodeBuffer(struct AVCodecContext* pAVCtx, BYTE* pBuffer, UINT nSize, int* pFramePOC,
- int* pOutPOC, REFERENCE_TIME* pOutrtStart);
+int FFH264DecodeBuffer(struct AVCodecContext* pAVCtx, BYTE* pBuffer, UINT nSize, int* pFramePOC,
+ int* pOutPOC, REFERENCE_TIME* pOutrtStart);
HRESULT FFH264BuildPicParams(DXVA_PicParams_H264* pDXVAPicParams, DXVA_Qmatrix_H264* pDXVAScalingMatrix,
- int* nFieldType, int* nSliceType, struct AVCodecContext* pAVCtx, DWORD nPCIVendor);
-int FFH264CheckCompatibility(int nWidth, int nHeight, struct AVCodecContext* pAVCtx, BYTE* pBuffer,
- UINT nSize, DWORD nPCIVendor, DWORD nPCIDevice, LARGE_INTEGER VideoDriverVersion);
-void FFH264SetCurrentPicture(int nIndex, DXVA_PicParams_H264* pDXVAPicParams, struct AVCodecContext* pAVCtx);
-void FFH264UpdateRefFramesList(DXVA_PicParams_H264* pDXVAPicParams, struct AVCodecContext* pAVCtx);
-BOOL FFH264IsRefFrameInUse(int nFrameNum, struct AVCodecContext* pAVCtx);
-void FF264UpdateRefFrameSliceLong(DXVA_PicParams_H264* pDXVAPicParams, DXVA_Slice_H264_Long* pSlice,
- struct AVCodecContext* pAVCtx);
-void FFH264SetDxvaSliceLong(struct AVCodecContext* pAVCtx, void* pSliceLong);
+ int* nFieldType, int* nSliceType, struct AVCodecContext* pAVCtx, DWORD nPCIVendor);
+int FFH264CheckCompatibility(int nWidth, int nHeight, struct AVCodecContext* pAVCtx, BYTE* pBuffer,
+ UINT nSize, DWORD nPCIVendor, DWORD nPCIDevice, LARGE_INTEGER VideoDriverVersion);
+void FFH264SetCurrentPicture(int nIndex, DXVA_PicParams_H264* pDXVAPicParams, struct AVCodecContext* pAVCtx);
+void FFH264UpdateRefFramesList(DXVA_PicParams_H264* pDXVAPicParams, struct AVCodecContext* pAVCtx);
+BOOL FFH264IsRefFrameInUse(int nFrameNum, struct AVCodecContext* pAVCtx);
+void FF264UpdateRefFrameSliceLong(DXVA_PicParams_H264* pDXVAPicParams, DXVA_Slice_H264_Long* pSlice,
+ struct AVCodecContext* pAVCtx);
+void FFH264SetDxvaSliceLong(struct AVCodecContext* pAVCtx, void* pSliceLong);
// === VC1 functions
HRESULT FFVC1UpdatePictureParam(DXVA_PictureParameters* pPicParams, struct AVCodecContext* pAVCtx,
- int* nFieldType, int* nSliceType, BYTE* pBuffer, UINT nSize,
- UINT* nFrameSize, BOOL b_SecondField, BOOL* b_repeat_pict);
-int FFIsSkipped(struct AVCodecContext* pAVCtx);
+ int* nFieldType, int* nSliceType, BYTE* pBuffer, UINT nSize,
+ UINT* nFrameSize, BOOL b_SecondField, BOOL* b_repeat_pict);
+int FFIsSkipped(struct AVCodecContext* pAVCtx);
// === Mpeg2 functions
-int MPEG2CheckCompatibility(struct AVCodecContext* pAVCtx, struct AVFrame* pFrame);
+int MPEG2CheckCompatibility(struct AVCodecContext* pAVCtx, struct AVFrame* pFrame);
HRESULT FFMpeg2DecodeFrame(DXVA_PictureParameters* pPicParams, DXVA_QmatrixData* m_QMatrixData,
- DXVA_SliceInfo* pSliceInfo, int* nSliceCount, struct AVCodecContext* pAVCtx,
- struct AVFrame* pFrame, int* nNextCodecIndex, int* nFieldType, int* nSliceType,
- BYTE* pBuffer, UINT nSize);
+ DXVA_SliceInfo* pSliceInfo, int* nSliceCount, struct AVCodecContext* pAVCtx,
+ struct AVFrame* pFrame, int* nNextCodecIndex, int* nFieldType, int* nSliceType,
+ BYTE* pBuffer, UINT nSize);
// === Common functions
-unsigned long FFGetMBNumber(struct AVCodecContext* pAVCtx);
-void FFSetThreadNumber(struct AVCodecContext* pAVCtx, enum CodecID nCodecId, int nThreadCount);
-BOOL FFSoftwareCheckCompatibility(struct AVCodecContext* pAVCtx);
-int FFGetCodedPicture(struct AVCodecContext* pAVCtx);
-BOOL FFGetAlternateScan(struct AVCodecContext* pAVCtx);
-BOOL DXVACheckFramesize(int width, int height, DWORD nPCIVendor/*, DWORD nPCIDevice*/);
+unsigned long FFGetMBNumber(struct AVCodecContext* pAVCtx);
+void FFSetThreadNumber(struct AVCodecContext* pAVCtx, enum CodecID nCodecId, int nThreadCount);
+BOOL FFSoftwareCheckCompatibility(struct AVCodecContext* pAVCtx);
+int FFGetCodedPicture(struct AVCodecContext* pAVCtx);
+BOOL FFGetAlternateScan(struct AVCodecContext* pAVCtx);
+BOOL DXVACheckFramesize(int width, int height, DWORD nPCIVendor/*, DWORD nPCIDevice*/);
diff --git a/src/filters/transform/MPCVideoDec/IMPCVideoDecFilter.h b/src/filters/transform/MPCVideoDec/IMPCVideoDecFilter.h
index 17466b81d..f262d9bf6 100644
--- a/src/filters/transform/MPCVideoDec/IMPCVideoDecFilter.h
+++ b/src/filters/transform/MPCVideoDec/IMPCVideoDecFilter.h
@@ -25,64 +25,64 @@
// Internal codec list (use to enable/disable codec in standalone mode)
typedef enum {
- MPCVD_H264 = 1 << 0,
- MPCVD_VC1 = 1 << 1,
- MPCVD_XVID = 1 << 2,
- MPCVD_DIVX = 1 << 3,
- MPCVD_WMV = 1 << 4,
- MPCVD_MSMPEG4 = 1 << 5,
- MPCVD_H263 = 1 << 6,
- MPCVD_SVQ3 = 1 << 7,
- MPCVD_THEORA = 1 << 8,
- MPCVD_AMVV = 1 << 9,
- MPCVD_FLASH = 1 << 10,
- MPCVD_H264_DXVA = 1 << 11,
- MPCVD_VC1_DXVA = 1 << 12,
- MPCVD_VP356 = 1 << 13,
- MPCVD_VP8 = 1 << 14,
- MPCVD_MJPEG = 1 << 15,
- MPCVD_INDEO = 1 << 16,
- MPCVD_RV = 1 << 17,
- MPCVD_WMV3_DXVA = 1 << 19,
- MPCVD_MPEG2_DXVA = 1 << 20,
+ MPCVD_H264 = 1 << 0,
+ MPCVD_VC1 = 1 << 1,
+ MPCVD_XVID = 1 << 2,
+ MPCVD_DIVX = 1 << 3,
+ MPCVD_WMV = 1 << 4,
+ MPCVD_MSMPEG4 = 1 << 5,
+ MPCVD_H263 = 1 << 6,
+ MPCVD_SVQ3 = 1 << 7,
+ MPCVD_THEORA = 1 << 8,
+ MPCVD_AMVV = 1 << 9,
+ MPCVD_FLASH = 1 << 10,
+ MPCVD_H264_DXVA = 1 << 11,
+ MPCVD_VC1_DXVA = 1 << 12,
+ MPCVD_VP356 = 1 << 13,
+ MPCVD_VP8 = 1 << 14,
+ MPCVD_MJPEG = 1 << 15,
+ MPCVD_INDEO = 1 << 16,
+ MPCVD_RV = 1 << 17,
+ MPCVD_WMV3_DXVA = 1 << 19,
+ MPCVD_MPEG2_DXVA = 1 << 20,
} MPC_VIDEO_CODEC;
interface __declspec(uuid("CDC3B5B3-A8B0-4c70-A805-9FC80CDEF262"))
IMPCVideoDecFilter :
public IUnknown {
- STDMETHOD(Apply()) = 0;
+ STDMETHOD(Apply()) = 0;
- STDMETHOD(SetThreadNumber(int nValue)) = 0;
- STDMETHOD_(int, GetThreadNumber()) = 0;
+ STDMETHOD(SetThreadNumber(int nValue)) = 0;
+ STDMETHOD_(int, GetThreadNumber()) = 0;
- STDMETHOD(SetDiscardMode(int nValue)) = 0;
- STDMETHOD_(int, GetDiscardMode()) = 0;
+ STDMETHOD(SetDiscardMode(int nValue)) = 0;
+ STDMETHOD_(int, GetDiscardMode()) = 0;
- STDMETHOD(SetErrorRecognition(int nValue)) = 0;
- STDMETHOD_(int, GetErrorRecognition()) = 0;
+ STDMETHOD(SetErrorRecognition(int nValue)) = 0;
+ STDMETHOD_(int, GetErrorRecognition()) = 0;
- STDMETHOD(SetIDCTAlgo(int nValue)) = 0;
- STDMETHOD_(int, GetIDCTAlgo()) = 0;
+ STDMETHOD(SetIDCTAlgo(int nValue)) = 0;
+ STDMETHOD_(int, GetIDCTAlgo()) = 0;
- STDMETHOD_(GUID*, GetDXVADecoderGuid()) = 0;
+ STDMETHOD_(GUID*, GetDXVADecoderGuid()) = 0;
- STDMETHOD(SetActiveCodecs(MPC_VIDEO_CODEC nValue)) = 0;
- STDMETHOD_(MPC_VIDEO_CODEC, GetActiveCodecs()) = 0;
+ STDMETHOD(SetActiveCodecs(MPC_VIDEO_CODEC nValue)) = 0;
+ STDMETHOD_(MPC_VIDEO_CODEC, GetActiveCodecs()) = 0;
- STDMETHOD_(LPCTSTR, GetVideoCardDescription()) = 0;
+ STDMETHOD_(LPCTSTR, GetVideoCardDescription()) = 0;
- STDMETHOD(SetARMode(int nValue)) = 0;
- STDMETHOD_(int, GetARMode()) = 0;
+ STDMETHOD(SetARMode(int nValue)) = 0;
+ STDMETHOD_(int, GetARMode()) = 0;
- STDMETHOD(SetDXVACheckCompatibility(int nValue)) = 0;
- STDMETHOD_(int, GetDXVACheckCompatibility()) = 0;
+ STDMETHOD(SetDXVACheckCompatibility(int nValue)) = 0;
+ STDMETHOD_(int, GetDXVACheckCompatibility()) = 0;
- STDMETHOD(SetDXVA_SD(int nValue)) = 0;
- STDMETHOD_(int, GetDXVA_SD()) = 0;
+ STDMETHOD(SetDXVA_SD(int nValue)) = 0;
+ STDMETHOD_(int, GetDXVA_SD()) = 0;
};
interface __declspec(uuid("F0ABC515-19ED-4D65-9D5F-59E36AE7F2AF"))
IMPCVideoDecFilter2 :
public IUnknown {
- STDMETHOD_(int, GetFrameType()) = 0;
+ STDMETHOD_(int, GetFrameType()) = 0;
};
diff --git a/src/filters/transform/MPCVideoDec/MPCFfmpegDec.cpp b/src/filters/transform/MPCVideoDec/MPCFfmpegDec.cpp
index f2c3be1a3..acdc587a3 100644
--- a/src/filters/transform/MPCVideoDec/MPCFfmpegDec.cpp
+++ b/src/filters/transform/MPCVideoDec/MPCFfmpegDec.cpp
@@ -28,30 +28,30 @@
// Workaround: graphedit crashes when a filter exposes more than 115 input MediaTypes!
const AMOVIESETUP_PIN sudpPinsVideoDec[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, CMPCVideoDecFilter::sudPinTypesInCount > 115 ? 115 : CMPCVideoDecFilter::sudPinTypesInCount, CMPCVideoDecFilter::sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, CMPCVideoDecFilter::sudPinTypesOutCount, CMPCVideoDecFilter::sudPinTypesOut}
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, CMPCVideoDecFilter::sudPinTypesInCount > 115 ? 115 : CMPCVideoDecFilter::sudPinTypesInCount, CMPCVideoDecFilter::sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, CMPCVideoDecFilter::sudPinTypesOutCount, CMPCVideoDecFilter::sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilters[] = {
- {&__uuidof(CMPCVideoDecFilter), MPCVideoDecName, /*MERIT_DO_NOT_USE*/0x40000001, _countof(sudpPinsVideoDec), sudpPinsVideoDec, CLSID_LegacyAmFilterCategory}
+ {&__uuidof(CMPCVideoDecFilter), MPCVideoDecName, /*MERIT_DO_NOT_USE*/0x40000001, _countof(sudpPinsVideoDec), sudpPinsVideoDec, CLSID_LegacyAmFilterCategory}
};
CFactoryTemplate g_Templates[] = {
- {sudFilters[0].strName, &__uuidof(CMPCVideoDecFilter), CreateInstance<CMPCVideoDecFilter>, NULL, &sudFilters[0]},
- {L"CMPCVideoDecPropertyPage", &__uuidof(CMPCVideoDecSettingsWnd), CreateInstance<CInternalPropertyPageTempl<CMPCVideoDecSettingsWnd> >},
- {L"CMPCVideoDecPropertyPage2", &__uuidof(CMPCVideoDecCodecWnd), CreateInstance<CInternalPropertyPageTempl<CMPCVideoDecCodecWnd> >},
+ {sudFilters[0].strName, &__uuidof(CMPCVideoDecFilter), CreateInstance<CMPCVideoDecFilter>, NULL, &sudFilters[0]},
+ {L"CMPCVideoDecPropertyPage", &__uuidof(CMPCVideoDecSettingsWnd), CreateInstance<CInternalPropertyPageTempl<CMPCVideoDecSettingsWnd> >},
+ {L"CMPCVideoDecPropertyPage2", &__uuidof(CMPCVideoDecCodecWnd), CreateInstance<CInternalPropertyPageTempl<CMPCVideoDecCodecWnd> >},
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp b/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp
index 41d84a5dc..421a7abc0 100644
--- a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp
+++ b/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp
@@ -52,2586 +52,2589 @@ extern "C"
#include "DXVADecoderH264.h"
#include "../../../mpc-hc/FilterEnum.h"
-#define MAX_SUPPORTED_MODE 5
-#define ROUND_FRAMERATE(var,FrameRate) if (labs ((long)(var - FrameRate)) < FrameRate*1/100) var = FrameRate;
+#define MAX_SUPPORTED_MODE 5
+#define ROUND_FRAMERATE(var,FrameRate) if (labs ((long)(var - FrameRate)) < FrameRate*1/100) var = FrameRate;
#define AVRTIMEPERFRAME_VC1_EVO 417083
typedef struct {
- const int PicEntryNumber;
- const UINT PreferedConfigBitstream;
- const GUID* Decoder[MAX_SUPPORTED_MODE];
- const WORD RestrictedMode[MAX_SUPPORTED_MODE];
+ const int PicEntryNumber;
+ const UINT PreferedConfigBitstream;
+ const GUID* Decoder[MAX_SUPPORTED_MODE];
+ const WORD RestrictedMode[MAX_SUPPORTED_MODE];
} DXVA_PARAMS;
typedef struct {
- const CLSID* clsMinorType;
- const enum CodecID nFFCodec;
- const DXVA_PARAMS* DXVAModes;
-
- int DXVAModeCount() {
- if (!DXVAModes) {
- return 0;
- }
- for (int i=0; i<MAX_SUPPORTED_MODE; i++) {
- if (DXVAModes->Decoder[i] == &GUID_NULL) {
- return i;
- }
- }
- return MAX_SUPPORTED_MODE;
- }
+ const CLSID* clsMinorType;
+ const enum CodecID nFFCodec;
+ const DXVA_PARAMS* DXVAModes;
+
+ int DXVAModeCount() {
+ if (!DXVAModes) {
+ return 0;
+ }
+ for (int i = 0; i < MAX_SUPPORTED_MODE; i++) {
+ if (DXVAModes->Decoder[i] == &GUID_NULL) {
+ return i;
+ }
+ }
+ return MAX_SUPPORTED_MODE;
+ }
} FFMPEG_CODECS;
// DXVA modes supported for Mpeg2
-DXVA_PARAMS DXVA_Mpeg2 = {
- 9, // PicEntryNumber
- 1, // PreferedConfigBitstream
- { &DXVA2_ModeMPEG2_VLD, &GUID_NULL },
- { DXVA_RESTRICTED_MODE_UNRESTRICTED, 0 } // Restricted mode for DXVA1?
+DXVA_PARAMS DXVA_Mpeg2 = {
+ 9, // PicEntryNumber
+ 1, // PreferedConfigBitstream
+ { &DXVA2_ModeMPEG2_VLD, &GUID_NULL },
+ { DXVA_RESTRICTED_MODE_UNRESTRICTED, 0 } // Restricted mode for DXVA1?
};
// DXVA modes supported for H264
-DXVA_PARAMS DXVA_H264 = {
- 16, // PicEntryNumber
- 2, // PreferedConfigBitstream
- { &DXVA2_ModeH264_E, &DXVA2_ModeH264_F, &DXVA_Intel_H264_ClearVideo, &GUID_NULL },
- { DXVA_RESTRICTED_MODE_H264_E, 0}
+DXVA_PARAMS DXVA_H264 = {
+ 16, // PicEntryNumber
+ 2, // PreferedConfigBitstream
+ { &DXVA2_ModeH264_E, &DXVA2_ModeH264_F, &DXVA_Intel_H264_ClearVideo, &GUID_NULL },
+ { DXVA_RESTRICTED_MODE_H264_E, 0}
};
-DXVA_PARAMS DXVA_H264_VISTA = {
- 22, // PicEntryNumber
- 2, // PreferedConfigBitstream
- { &DXVA2_ModeH264_E, &DXVA2_ModeH264_F, &DXVA_Intel_H264_ClearVideo, &GUID_NULL },
- { DXVA_RESTRICTED_MODE_H264_E, 0}
+DXVA_PARAMS DXVA_H264_VISTA = {
+ 22, // PicEntryNumber
+ 2, // PreferedConfigBitstream
+ { &DXVA2_ModeH264_E, &DXVA2_ModeH264_F, &DXVA_Intel_H264_ClearVideo, &GUID_NULL },
+ { DXVA_RESTRICTED_MODE_H264_E, 0}
};
// DXVA modes supported for VC1
-DXVA_PARAMS DXVA_VC1 = {
- 14, // PicEntryNumber
- 1, // PreferedConfigBitstream
- { &DXVA2_ModeVC1_D, &GUID_NULL },
- { DXVA_RESTRICTED_MODE_VC1_D, 0}
+DXVA_PARAMS DXVA_VC1 = {
+ 14, // PicEntryNumber
+ 1, // PreferedConfigBitstream
+ { &DXVA2_ModeVC1_D, &GUID_NULL },
+ { DXVA_RESTRICTED_MODE_VC1_D, 0}
};
-FFMPEG_CODECS ffCodecs[] = {
+FFMPEG_CODECS ffCodecs[] = {
#if HAS_FFMPEG_VIDEO_DECODERS
- // Flash video
- { &MEDIASUBTYPE_FLV1, CODEC_ID_FLV1, NULL },
- { &MEDIASUBTYPE_flv1, CODEC_ID_FLV1, NULL },
- { &MEDIASUBTYPE_FLV4, CODEC_ID_VP6F, NULL },
- { &MEDIASUBTYPE_flv4, CODEC_ID_VP6F, NULL },
- { &MEDIASUBTYPE_VP6F, CODEC_ID_VP6F, NULL },
- { &MEDIASUBTYPE_vp6f, CODEC_ID_VP6F, NULL },
-
- // VP3
- { &MEDIASUBTYPE_VP30, CODEC_ID_VP3, NULL },
- { &MEDIASUBTYPE_VP31, CODEC_ID_VP3, NULL },
-
- // VP5
- { &MEDIASUBTYPE_VP50, CODEC_ID_VP5, NULL },
- { &MEDIASUBTYPE_vp50, CODEC_ID_VP5, NULL },
-
- // VP6
- { &MEDIASUBTYPE_VP60, CODEC_ID_VP6, NULL },
- { &MEDIASUBTYPE_vp60, CODEC_ID_VP6, NULL },
- { &MEDIASUBTYPE_VP61, CODEC_ID_VP6, NULL },
- { &MEDIASUBTYPE_vp61, CODEC_ID_VP6, NULL },
- { &MEDIASUBTYPE_VP62, CODEC_ID_VP6, NULL },
- { &MEDIASUBTYPE_vp62, CODEC_ID_VP6, NULL },
- { &MEDIASUBTYPE_VP6A, CODEC_ID_VP6A, NULL },
- { &MEDIASUBTYPE_vp6a, CODEC_ID_VP6A, NULL },
-
- // VP8
- { &MEDIASUBTYPE_VP80, CODEC_ID_VP8, NULL },
-
- // Xvid
- { &MEDIASUBTYPE_XVID, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_xvid, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_XVIX, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_xvix, CODEC_ID_MPEG4, NULL },
-
- // DivX
- { &MEDIASUBTYPE_DX50, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_dx50, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_DIVX, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_divx, CODEC_ID_MPEG4, NULL },
-
- // WMV1/2/3
- { &MEDIASUBTYPE_WMV1, CODEC_ID_WMV1, NULL },
- { &MEDIASUBTYPE_wmv1, CODEC_ID_WMV1, NULL },
- { &MEDIASUBTYPE_WMV2, CODEC_ID_WMV2, NULL },
- { &MEDIASUBTYPE_wmv2, CODEC_ID_WMV2, NULL },
- { &MEDIASUBTYPE_WMV3, CODEC_ID_WMV3, &DXVA_VC1 },
- { &MEDIASUBTYPE_wmv3, CODEC_ID_WMV3, &DXVA_VC1 },
-
- // MPEG-2
- { &MEDIASUBTYPE_MPEG2_VIDEO, CODEC_ID_MPEG2VIDEO, &DXVA_Mpeg2 },
- { &MEDIASUBTYPE_MPG2, CODEC_ID_MPEG2VIDEO, &DXVA_Mpeg2 },
-
- // MSMPEG-4
- { &MEDIASUBTYPE_DIV3, CODEC_ID_MSMPEG4V3, NULL },
- { &MEDIASUBTYPE_div3, CODEC_ID_MSMPEG4V3, NULL },
- { &MEDIASUBTYPE_DVX3, CODEC_ID_MSMPEG4V3, NULL },
- { &MEDIASUBTYPE_dvx3, CODEC_ID_MSMPEG4V3, NULL },
- { &MEDIASUBTYPE_MP43, CODEC_ID_MSMPEG4V3, NULL },
- { &MEDIASUBTYPE_mp43, CODEC_ID_MSMPEG4V3, NULL },
- { &MEDIASUBTYPE_COL1, CODEC_ID_MSMPEG4V3, NULL },
- { &MEDIASUBTYPE_col1, CODEC_ID_MSMPEG4V3, NULL },
- { &MEDIASUBTYPE_DIV4, CODEC_ID_MSMPEG4V3, NULL },
- { &MEDIASUBTYPE_div4, CODEC_ID_MSMPEG4V3, NULL },
- { &MEDIASUBTYPE_DIV5, CODEC_ID_MSMPEG4V3, NULL },
- { &MEDIASUBTYPE_div5, CODEC_ID_MSMPEG4V3, NULL },
- { &MEDIASUBTYPE_DIV6, CODEC_ID_MSMPEG4V3, NULL },
- { &MEDIASUBTYPE_div6, CODEC_ID_MSMPEG4V3, NULL },
- { &MEDIASUBTYPE_AP41, CODEC_ID_MSMPEG4V3, NULL },
- { &MEDIASUBTYPE_ap41, CODEC_ID_MSMPEG4V3, NULL },
- { &MEDIASUBTYPE_MPG3, CODEC_ID_MSMPEG4V3, NULL },
- { &MEDIASUBTYPE_mpg3, CODEC_ID_MSMPEG4V3, NULL },
- { &MEDIASUBTYPE_DIV2, CODEC_ID_MSMPEG4V2, NULL },
- { &MEDIASUBTYPE_div2, CODEC_ID_MSMPEG4V2, NULL },
- { &MEDIASUBTYPE_MP42, CODEC_ID_MSMPEG4V2, NULL },
- { &MEDIASUBTYPE_mp42, CODEC_ID_MSMPEG4V2, NULL },
- { &MEDIASUBTYPE_MPG4, CODEC_ID_MSMPEG4V1, NULL },
- { &MEDIASUBTYPE_mpg4, CODEC_ID_MSMPEG4V1, NULL },
- { &MEDIASUBTYPE_DIV1, CODEC_ID_MSMPEG4V1, NULL },
- { &MEDIASUBTYPE_div1, CODEC_ID_MSMPEG4V1, NULL },
- { &MEDIASUBTYPE_MP41, CODEC_ID_MSMPEG4V1, NULL },
- { &MEDIASUBTYPE_mp41, CODEC_ID_MSMPEG4V1, NULL },
-
- // AMV Video
- { &MEDIASUBTYPE_AMVV, CODEC_ID_AMV, NULL },
-
- // MJPEG
- { &MEDIASUBTYPE_MJPG, CODEC_ID_MJPEG, NULL },
- { &MEDIASUBTYPE_QTJpeg, CODEC_ID_MJPEG, NULL },
- { &MEDIASUBTYPE_MJPA, CODEC_ID_MJPEG, NULL },
- { &MEDIASUBTYPE_MJPB, CODEC_ID_MJPEGB, NULL },
-
- // TSCC
- { &MEDIASUBTYPE_TSCC, CODEC_ID_TSCC, NULL },
-
- // Indeo 3/4/5
- { &MEDIASUBTYPE_IV31, CODEC_ID_INDEO3, NULL },
- { &MEDIASUBTYPE_IV32, CODEC_ID_INDEO3, NULL },
- { &MEDIASUBTYPE_IV41, CODEC_ID_INDEO4, NULL },
- { &MEDIASUBTYPE_IV50, CODEC_ID_INDEO5, NULL },
+ // Flash video
+ { &MEDIASUBTYPE_FLV1, CODEC_ID_FLV1, NULL },
+ { &MEDIASUBTYPE_flv1, CODEC_ID_FLV1, NULL },
+ { &MEDIASUBTYPE_FLV4, CODEC_ID_VP6F, NULL },
+ { &MEDIASUBTYPE_flv4, CODEC_ID_VP6F, NULL },
+ { &MEDIASUBTYPE_VP6F, CODEC_ID_VP6F, NULL },
+ { &MEDIASUBTYPE_vp6f, CODEC_ID_VP6F, NULL },
+
+ // VP3
+ { &MEDIASUBTYPE_VP30, CODEC_ID_VP3, NULL },
+ { &MEDIASUBTYPE_VP31, CODEC_ID_VP3, NULL },
+
+ // VP5
+ { &MEDIASUBTYPE_VP50, CODEC_ID_VP5, NULL },
+ { &MEDIASUBTYPE_vp50, CODEC_ID_VP5, NULL },
+
+ // VP6
+ { &MEDIASUBTYPE_VP60, CODEC_ID_VP6, NULL },
+ { &MEDIASUBTYPE_vp60, CODEC_ID_VP6, NULL },
+ { &MEDIASUBTYPE_VP61, CODEC_ID_VP6, NULL },
+ { &MEDIASUBTYPE_vp61, CODEC_ID_VP6, NULL },
+ { &MEDIASUBTYPE_VP62, CODEC_ID_VP6, NULL },
+ { &MEDIASUBTYPE_vp62, CODEC_ID_VP6, NULL },
+ { &MEDIASUBTYPE_VP6A, CODEC_ID_VP6A, NULL },
+ { &MEDIASUBTYPE_vp6a, CODEC_ID_VP6A, NULL },
+
+ // VP8
+ { &MEDIASUBTYPE_VP80, CODEC_ID_VP8, NULL },
+
+ // Xvid
+ { &MEDIASUBTYPE_XVID, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_xvid, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_XVIX, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_xvix, CODEC_ID_MPEG4, NULL },
+
+ // DivX
+ { &MEDIASUBTYPE_DX50, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_dx50, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_DIVX, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_divx, CODEC_ID_MPEG4, NULL },
+
+ // WMV1/2/3
+ { &MEDIASUBTYPE_WMV1, CODEC_ID_WMV1, NULL },
+ { &MEDIASUBTYPE_wmv1, CODEC_ID_WMV1, NULL },
+ { &MEDIASUBTYPE_WMV2, CODEC_ID_WMV2, NULL },
+ { &MEDIASUBTYPE_wmv2, CODEC_ID_WMV2, NULL },
+ { &MEDIASUBTYPE_WMV3, CODEC_ID_WMV3, &DXVA_VC1 },
+ { &MEDIASUBTYPE_wmv3, CODEC_ID_WMV3, &DXVA_VC1 },
+
+ // MPEG-2
+ { &MEDIASUBTYPE_MPEG2_VIDEO, CODEC_ID_MPEG2VIDEO, &DXVA_Mpeg2 },
+ { &MEDIASUBTYPE_MPG2, CODEC_ID_MPEG2VIDEO, &DXVA_Mpeg2 },
+
+ // MSMPEG-4
+ { &MEDIASUBTYPE_DIV3, CODEC_ID_MSMPEG4V3, NULL },
+ { &MEDIASUBTYPE_div3, CODEC_ID_MSMPEG4V3, NULL },
+ { &MEDIASUBTYPE_DVX3, CODEC_ID_MSMPEG4V3, NULL },
+ { &MEDIASUBTYPE_dvx3, CODEC_ID_MSMPEG4V3, NULL },
+ { &MEDIASUBTYPE_MP43, CODEC_ID_MSMPEG4V3, NULL },
+ { &MEDIASUBTYPE_mp43, CODEC_ID_MSMPEG4V3, NULL },
+ { &MEDIASUBTYPE_COL1, CODEC_ID_MSMPEG4V3, NULL },
+ { &MEDIASUBTYPE_col1, CODEC_ID_MSMPEG4V3, NULL },
+ { &MEDIASUBTYPE_DIV4, CODEC_ID_MSMPEG4V3, NULL },
+ { &MEDIASUBTYPE_div4, CODEC_ID_MSMPEG4V3, NULL },
+ { &MEDIASUBTYPE_DIV5, CODEC_ID_MSMPEG4V3, NULL },
+ { &MEDIASUBTYPE_div5, CODEC_ID_MSMPEG4V3, NULL },
+ { &MEDIASUBTYPE_DIV6, CODEC_ID_MSMPEG4V3, NULL },
+ { &MEDIASUBTYPE_div6, CODEC_ID_MSMPEG4V3, NULL },
+ { &MEDIASUBTYPE_AP41, CODEC_ID_MSMPEG4V3, NULL },
+ { &MEDIASUBTYPE_ap41, CODEC_ID_MSMPEG4V3, NULL },
+ { &MEDIASUBTYPE_MPG3, CODEC_ID_MSMPEG4V3, NULL },
+ { &MEDIASUBTYPE_mpg3, CODEC_ID_MSMPEG4V3, NULL },
+ { &MEDIASUBTYPE_DIV2, CODEC_ID_MSMPEG4V2, NULL },
+ { &MEDIASUBTYPE_div2, CODEC_ID_MSMPEG4V2, NULL },
+ { &MEDIASUBTYPE_MP42, CODEC_ID_MSMPEG4V2, NULL },
+ { &MEDIASUBTYPE_mp42, CODEC_ID_MSMPEG4V2, NULL },
+ { &MEDIASUBTYPE_MPG4, CODEC_ID_MSMPEG4V1, NULL },
+ { &MEDIASUBTYPE_mpg4, CODEC_ID_MSMPEG4V1, NULL },
+ { &MEDIASUBTYPE_DIV1, CODEC_ID_MSMPEG4V1, NULL },
+ { &MEDIASUBTYPE_div1, CODEC_ID_MSMPEG4V1, NULL },
+ { &MEDIASUBTYPE_MP41, CODEC_ID_MSMPEG4V1, NULL },
+ { &MEDIASUBTYPE_mp41, CODEC_ID_MSMPEG4V1, NULL },
+
+ // AMV Video
+ { &MEDIASUBTYPE_AMVV, CODEC_ID_AMV, NULL },
+
+ // MJPEG
+ { &MEDIASUBTYPE_MJPG, CODEC_ID_MJPEG, NULL },
+ { &MEDIASUBTYPE_QTJpeg, CODEC_ID_MJPEG, NULL },
+ { &MEDIASUBTYPE_MJPA, CODEC_ID_MJPEG, NULL },
+ { &MEDIASUBTYPE_MJPB, CODEC_ID_MJPEGB, NULL },
+
+ // TSCC
+ { &MEDIASUBTYPE_TSCC, CODEC_ID_TSCC, NULL },
+
+ // Indeo 3/4/5
+ { &MEDIASUBTYPE_IV31, CODEC_ID_INDEO3, NULL },
+ { &MEDIASUBTYPE_IV32, CODEC_ID_INDEO3, NULL },
+ { &MEDIASUBTYPE_IV41, CODEC_ID_INDEO4, NULL },
+ { &MEDIASUBTYPE_IV50, CODEC_ID_INDEO5, NULL },
#endif /* HAS_FFMPEG_VIDEO_DECODERS */
- // H264/AVC
- { &MEDIASUBTYPE_H264, CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_h264, CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_X264, CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_x264, CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_VSSH, CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_vssh, CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_DAVC, CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_davc, CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_PAVC, CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_pavc, CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_AVC1, CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_avc1, CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_H264_bis, CODEC_ID_H264, &DXVA_H264 },
+ // H264/AVC
+ { &MEDIASUBTYPE_H264, CODEC_ID_H264, &DXVA_H264 },
+ { &MEDIASUBTYPE_h264, CODEC_ID_H264, &DXVA_H264 },
+ { &MEDIASUBTYPE_X264, CODEC_ID_H264, &DXVA_H264 },
+ { &MEDIASUBTYPE_x264, CODEC_ID_H264, &DXVA_H264 },
+ { &MEDIASUBTYPE_VSSH, CODEC_ID_H264, &DXVA_H264 },
+ { &MEDIASUBTYPE_vssh, CODEC_ID_H264, &DXVA_H264 },
+ { &MEDIASUBTYPE_DAVC, CODEC_ID_H264, &DXVA_H264 },
+ { &MEDIASUBTYPE_davc, CODEC_ID_H264, &DXVA_H264 },
+ { &MEDIASUBTYPE_PAVC, CODEC_ID_H264, &DXVA_H264 },
+ { &MEDIASUBTYPE_pavc, CODEC_ID_H264, &DXVA_H264 },
+ { &MEDIASUBTYPE_AVC1, CODEC_ID_H264, &DXVA_H264 },
+ { &MEDIASUBTYPE_avc1, CODEC_ID_H264, &DXVA_H264 },
+ { &MEDIASUBTYPE_H264_bis, CODEC_ID_H264, &DXVA_H264 },
#if HAS_FFMPEG_VIDEO_DECODERS
- // SVQ3
- { &MEDIASUBTYPE_SVQ3, CODEC_ID_SVQ3, NULL },
+ // SVQ3
+ { &MEDIASUBTYPE_SVQ3, CODEC_ID_SVQ3, NULL },
- // SVQ1
- { &MEDIASUBTYPE_SVQ1, CODEC_ID_SVQ1, NULL },
+ // SVQ1
+ { &MEDIASUBTYPE_SVQ1, CODEC_ID_SVQ1, NULL },
- // H263
- { &MEDIASUBTYPE_H263, CODEC_ID_H263, NULL },
- { &MEDIASUBTYPE_h263, CODEC_ID_H263, NULL },
+ // H263
+ { &MEDIASUBTYPE_H263, CODEC_ID_H263, NULL },
+ { &MEDIASUBTYPE_h263, CODEC_ID_H263, NULL },
- { &MEDIASUBTYPE_S263, CODEC_ID_H263, NULL },
- { &MEDIASUBTYPE_s263, CODEC_ID_H263, NULL },
+ { &MEDIASUBTYPE_S263, CODEC_ID_H263, NULL },
+ { &MEDIASUBTYPE_s263, CODEC_ID_H263, NULL },
- // Real Video
- { &MEDIASUBTYPE_RV10, CODEC_ID_RV10, NULL },
- { &MEDIASUBTYPE_RV20, CODEC_ID_RV20, NULL },
- { &MEDIASUBTYPE_RV30, CODEC_ID_RV30, NULL },
- { &MEDIASUBTYPE_RV40, CODEC_ID_RV40, NULL },
+ // Real Video
+ { &MEDIASUBTYPE_RV10, CODEC_ID_RV10, NULL },
+ { &MEDIASUBTYPE_RV20, CODEC_ID_RV20, NULL },
+ { &MEDIASUBTYPE_RV30, CODEC_ID_RV30, NULL },
+ { &MEDIASUBTYPE_RV40, CODEC_ID_RV40, NULL },
- // Theora
- { &MEDIASUBTYPE_THEORA, CODEC_ID_THEORA, NULL },
- { &MEDIASUBTYPE_theora, CODEC_ID_THEORA, NULL },
+ // Theora
+ { &MEDIASUBTYPE_THEORA, CODEC_ID_THEORA, NULL },
+ { &MEDIASUBTYPE_theora, CODEC_ID_THEORA, NULL },
#endif /* HAS_FFMPEG_VIDEO_DECODERS */
- // WVC1
- { &MEDIASUBTYPE_WVC1, CODEC_ID_VC1, &DXVA_VC1 },
- { &MEDIASUBTYPE_wvc1, CODEC_ID_VC1, &DXVA_VC1 },
+ // WVC1
+ { &MEDIASUBTYPE_WVC1, CODEC_ID_VC1, &DXVA_VC1 },
+ { &MEDIASUBTYPE_wvc1, CODEC_ID_VC1, &DXVA_VC1 },
#if HAS_FFMPEG_VIDEO_DECODERS
- // Other MPEG-4
- { &MEDIASUBTYPE_MP4V, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_mp4v, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_M4S2, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_m4s2, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_MP4S, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_mp4s, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_3IV1, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_3iv1, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_3IV2, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_3iv2, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_3IVX, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_3ivx, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_BLZ0, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_blz0, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_DM4V, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_dm4v, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_FFDS, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_ffds, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_FVFW, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_fvfw, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_DXGM, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_dxgm, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_FMP4, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_fmp4, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_HDX4, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_hdx4, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_LMP4, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_lmp4, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_NDIG, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_ndig, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_RMP4, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_rmp4, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_SMP4, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_smp4, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_SEDG, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_sedg, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_UMP4, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_ump4, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_WV1F, CODEC_ID_MPEG4, NULL },
- { &MEDIASUBTYPE_wv1f, CODEC_ID_MPEG4, NULL }
+ // Other MPEG-4
+ { &MEDIASUBTYPE_MP4V, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_mp4v, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_M4S2, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_m4s2, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_MP4S, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_mp4s, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_3IV1, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_3iv1, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_3IV2, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_3iv2, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_3IVX, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_3ivx, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_BLZ0, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_blz0, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_DM4V, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_dm4v, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_FFDS, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_ffds, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_FVFW, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_fvfw, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_DXGM, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_dxgm, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_FMP4, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_fmp4, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_HDX4, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_hdx4, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_LMP4, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_lmp4, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_NDIG, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_ndig, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_RMP4, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_rmp4, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_SMP4, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_smp4, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_SEDG, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_sedg, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_UMP4, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_ump4, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_WV1F, CODEC_ID_MPEG4, NULL },
+ { &MEDIASUBTYPE_wv1f, CODEC_ID_MPEG4, NULL }
#endif /* HAS_FFMPEG_VIDEO_DECODERS */
};
/* Important: the order should be exactly the same as in ffCodecs[] */
const AMOVIESETUP_MEDIATYPE CMPCVideoDecFilter::sudPinTypesIn[] = {
#if HAS_FFMPEG_VIDEO_DECODERS
- // Flash video
- { &MEDIATYPE_Video, &MEDIASUBTYPE_FLV1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_flv1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_FLV4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_flv4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VP6F },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_vp6f },
-
- // VP3
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VP30 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VP31 },
-
- // VP5
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VP50 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_vp50 },
-
- // VP6
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VP60 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_vp60 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VP61 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_vp61 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VP62 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_vp62 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VP6A },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_vp6a },
-
- // VP8
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VP80 },
-
- // Xvid
- { &MEDIATYPE_Video, &MEDIASUBTYPE_XVID },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_xvid },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_XVIX },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_xvix },
-
- // DivX
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DX50 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_dx50 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DIVX },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_divx },
-
- // WMV1/2/3
- { &MEDIATYPE_Video, &MEDIASUBTYPE_WMV1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_wmv1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_WMV2 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_wmv2 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_WMV3 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_wmv3 },
-
- // MPEG-2
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MPEG2_VIDEO },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MPG2 },
-
- // MSMPEG-4
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV3 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_div3 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DVX3 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_dvx3 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MP43 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_mp43 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_COL1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_col1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_div4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV5 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_div5 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV6 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_div6 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_AP41 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_ap41 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MPG3 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_mpg3 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV2 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_div2 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MP42 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_mp42 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MPG4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_mpg4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_div1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MP41 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_mp41 },
-
- // AMV Video
- { &MEDIATYPE_Video, &MEDIASUBTYPE_AMVV },
-
- // MJPEG
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MJPG },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_QTJpeg },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MJPA },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MJPB },
-
- // TSCC
- { &MEDIATYPE_Video, &MEDIASUBTYPE_TSCC },
-
- // Indeo 3/4/5
- { &MEDIATYPE_Video, &MEDIASUBTYPE_IV31 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_IV32 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_IV41 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_IV50 },
+ // Flash video
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_FLV1 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_flv1 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_FLV4 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_flv4 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_VP6F },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_vp6f },
+
+ // VP3
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_VP30 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_VP31 },
+
+ // VP5
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_VP50 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_vp50 },
+
+ // VP6
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_VP60 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_vp60 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_VP61 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_vp61 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_VP62 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_vp62 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_VP6A },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_vp6a },
+
+ // VP8
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_VP80 },
+
+ // Xvid
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_XVID },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_xvid },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_XVIX },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_xvix },
+
+ // DivX
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_DX50 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_dx50 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_DIVX },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_divx },
+
+ // WMV1/2/3
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_WMV1 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_wmv1 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_WMV2 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_wmv2 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_WMV3 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_wmv3 },
+
+ // MPEG-2
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_MPEG2_VIDEO },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_MPG2 },
+
+ // MSMPEG-4
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV3 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_div3 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_DVX3 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_dvx3 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_MP43 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_mp43 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_COL1 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_col1 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV4 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_div4 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV5 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_div5 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV6 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_div6 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_AP41 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_ap41 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_MPG3 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_mpg3 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV2 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_div2 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_MP42 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_mp42 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_MPG4 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_mpg4 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV1 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_div1 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_MP41 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_mp41 },
+
+ // AMV Video
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_AMVV },
+
+ // MJPEG
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_MJPG },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_QTJpeg },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_MJPA },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_MJPB },
+
+ // TSCC
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_TSCC },
+
+ // Indeo 3/4/5
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_IV31 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_IV32 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_IV41 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_IV50 },
#endif /* HAS_FFMPEG_VIDEO_DECODERS */
- // H264/AVC
- { &MEDIATYPE_Video, &MEDIASUBTYPE_H264 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_h264 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_X264 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_x264 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VSSH },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_vssh },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DAVC },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_davc },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_PAVC },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_pavc },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_AVC1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_avc1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_H264_bis },
+ // H264/AVC
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_H264 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_h264 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_X264 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_x264 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_VSSH },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_vssh },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_DAVC },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_davc },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_PAVC },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_pavc },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_AVC1 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_avc1 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_H264_bis },
#if HAS_FFMPEG_VIDEO_DECODERS
- // SVQ3
- { &MEDIATYPE_Video, &MEDIASUBTYPE_SVQ3 },
+ // SVQ3
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_SVQ3 },
- // SVQ1
- { &MEDIATYPE_Video, &MEDIASUBTYPE_SVQ1 },
+ // SVQ1
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_SVQ1 },
- // H263
- { &MEDIATYPE_Video, &MEDIASUBTYPE_H263 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_h263 },
+ // H263
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_H263 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_h263 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_S263 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_s263 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_S263 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_s263 },
- // Real video
- { &MEDIATYPE_Video, &MEDIASUBTYPE_RV10 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_RV20 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_RV30 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_RV40 },
+ // Real video
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_RV10 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_RV20 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_RV30 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_RV40 },
- // Theora
- { &MEDIATYPE_Video, &MEDIASUBTYPE_THEORA },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_theora },
+ // Theora
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_THEORA },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_theora },
#endif /* HAS_FFMPEG_VIDEO_DECODERS */
- // VC1
- { &MEDIATYPE_Video, &MEDIASUBTYPE_WVC1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_wvc1 },
+ // VC1
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_WVC1 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_wvc1 },
#if HAS_FFMPEG_VIDEO_DECODERS
- // IMPORTANT : some of the last MediaTypes present in next group may be not available in
- // the standalone filter (workaround to prevent GraphEdit crash).
- // Other MPEG-4
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MP4V },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_mp4v },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_M4S2 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_m4s2 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MP4S },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_mp4s },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_3IV1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_3iv1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_3IV2 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_3iv2 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_3IVX },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_3ivx },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_BLZ0 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_blz0 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DM4V },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_dm4v },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_FFDS },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_ffds },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_FVFW },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_fvfw },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DXGM },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_dxgm },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_FMP4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_fmp4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_HDX4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_hdx4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_LMP4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_lmp4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_NDIG },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_ndig },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_RMP4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_rmp4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_SMP4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_smp4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_SEDG },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_sedg },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_UMP4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_ump4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_WV1F },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_wv1f }
+ // IMPORTANT : some of the last MediaTypes present in next group may be not available in
+ // the standalone filter (workaround to prevent GraphEdit crash).
+ // Other MPEG-4
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_MP4V },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_mp4v },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_M4S2 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_m4s2 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_MP4S },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_mp4s },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_3IV1 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_3iv1 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_3IV2 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_3iv2 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_3IVX },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_3ivx },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_BLZ0 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_blz0 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_DM4V },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_dm4v },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_FFDS },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_ffds },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_FVFW },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_fvfw },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_DXGM },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_dxgm },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_FMP4 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_fmp4 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_HDX4 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_hdx4 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_LMP4 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_lmp4 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_NDIG },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_ndig },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_RMP4 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_rmp4 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_SMP4 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_smp4 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_SEDG },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_sedg },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_UMP4 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_ump4 },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_WV1F },
+ { &MEDIATYPE_Video, &MEDIASUBTYPE_wv1f }
#endif /* HAS_FFMPEG_VIDEO_DECODERS */
};
const int CMPCVideoDecFilter::sudPinTypesInCount = _countof(CMPCVideoDecFilter::sudPinTypesIn);
-bool* CMPCVideoDecFilter::FFmpegFilters = NULL;
-bool* CMPCVideoDecFilter::DXVAFilters = NULL;
+bool* CMPCVideoDecFilter::FFmpegFilters = NULL;
+bool* CMPCVideoDecFilter::DXVAFilters = NULL;
const AMOVIESETUP_MEDIATYPE CMPCVideoDecFilter::sudPinTypesOut[] = {
- {&MEDIATYPE_Video, &MEDIASUBTYPE_NV12},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_NV24}
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_NV12},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_NV24}
};
const int CMPCVideoDecFilter::sudPinTypesOutCount = _countof(CMPCVideoDecFilter::sudPinTypesOut);
-BOOL CALLBACK EnumFindProcessWnd (HWND hwnd, LPARAM lParam)
+BOOL CALLBACK EnumFindProcessWnd(HWND hwnd, LPARAM lParam)
{
- DWORD procid = 0;
- TCHAR WindowClass [40];
- GetWindowThreadProcessId (hwnd, &procid);
- GetClassName (hwnd, WindowClass, _countof(WindowClass));
+ DWORD procid = 0;
+ TCHAR WindowClass [40];
+ GetWindowThreadProcessId(hwnd, &procid);
+ GetClassName(hwnd, WindowClass, _countof(WindowClass));
- if (procid == GetCurrentProcessId() && _tcscmp (WindowClass, _T("MediaPlayerClassicW")) == 0) {
- HWND* pWnd = (HWND*)lParam;
- *pWnd = hwnd;
- return FALSE;
- }
- return TRUE;
+ if (procid == GetCurrentProcessId() && _tcscmp(WindowClass, _T("MediaPlayerClassicW")) == 0) {
+ HWND* pWnd = (HWND*)lParam;
+ *pWnd = hwnd;
+ return FALSE;
+ }
+ return TRUE;
}
CMPCVideoDecFilter::CMPCVideoDecFilter(LPUNKNOWN lpunk, HRESULT* phr)
- : CBaseVideoFilter(MPCVideoDecName, lpunk, phr, __uuidof(this))
-{
- HWND hWnd = NULL;
-
- if (SysVersion::IsVistaOrLater()) {
- for (int i=0; i<_countof(ffCodecs); i++) {
- if (ffCodecs[i].nFFCodec == CODEC_ID_H264) {
- ffCodecs[i].DXVAModes = &DXVA_H264_VISTA;
- }
- }
- }
-
- if (phr) {
- *phr = S_OK;
- }
-
- if (m_pOutput) {
- delete m_pOutput;
- }
- m_pOutput = DNew CVideoDecOutputPin(NAME("CVideoDecOutputPin"), this, phr, L"Output");
- if (!m_pOutput) {
- *phr = E_OUTOFMEMORY;
- }
-
- m_pCpuId = DNew CCpuId();
- m_pAVCodec = NULL;
- m_pAVCtx = NULL;
- m_pFrame = NULL;
- m_nCodecNb = -1;
- m_nCodecId = CODEC_ID_NONE;
- m_bReorderBFrame = true;
- m_DXVADecoderGUID = GUID_NULL;
- m_nActiveCodecs = MPCVD_H264|MPCVD_VC1|MPCVD_XVID|MPCVD_DIVX|MPCVD_MSMPEG4|MPCVD_FLASH|MPCVD_WMV|MPCVD_H263|MPCVD_SVQ3|MPCVD_AMVV|MPCVD_THEORA|MPCVD_H264_DXVA|MPCVD_VC1_DXVA|MPCVD_VP356|MPCVD_VP8|MPCVD_MJPEG|MPCVD_INDEO|MPCVD_RV|MPCVD_WMV3_DXVA|MPCVD_MPEG2_DXVA;
-
- m_rtAvrTimePerFrame = 0;
- m_rtLastStart = 0;
- m_nCountEstimated = 0;
- m_rtPrevStop = 0;
-
- m_nWorkaroundBug = FF_BUG_AUTODETECT;
- m_nErrorConcealment = FF_EC_DEBLOCK | FF_EC_GUESS_MVS;
-
- m_nThreadNumber = 0;
- m_nDiscardMode = AVDISCARD_DEFAULT;
- m_nErrorRecognition = AV_EF_CAREFUL;
- m_nIDCTAlgo = FF_IDCT_AUTO;
- m_bDXVACompatible = true;
- m_pFFBuffer = NULL;
- m_nFFBufferSize = 0;
- m_pAlignedFFBuffer = NULL;
- m_nAlignedFFBufferSize = 0;
- ResetBuffer();
-
- m_nWidth = 0;
- m_nHeight = 0;
- m_pSwsContext = NULL;
-
- m_bUseDXVA = true;
- m_bUseFFmpeg = true;
-
- m_nDXVAMode = MODE_SOFTWARE;
- m_pDXVADecoder = NULL;
- m_pVideoOutputFormat = NULL;
- m_nVideoOutputCount = 0;
- m_hDevice = INVALID_HANDLE_VALUE;
-
- m_nARMode = 1;
- m_nDXVACheckCompatibility = 1; // skip level check by default
- m_nDXVA_SD = 0;
- m_sar.SetSize(1,1);
-
- m_bTheoraMTSupport = true;
- m_bWaitingForKeyFrame = TRUE;
- m_nPosB = 1;
- m_bFrame_repeat_pict = false;
- m_bIsEVO = false;
+ : CBaseVideoFilter(MPCVideoDecName, lpunk, phr, __uuidof(this))
+{
+ HWND hWnd = NULL;
+
+ if (SysVersion::IsVistaOrLater()) {
+ for (int i = 0; i < _countof(ffCodecs); i++) {
+ if (ffCodecs[i].nFFCodec == CODEC_ID_H264) {
+ ffCodecs[i].DXVAModes = &DXVA_H264_VISTA;
+ }
+ }
+ }
+
+ if (phr) {
+ *phr = S_OK;
+ }
+
+ if (m_pOutput) {
+ delete m_pOutput;
+ }
+ m_pOutput = DNew CVideoDecOutputPin(NAME("CVideoDecOutputPin"), this, phr, L"Output");
+ if (!m_pOutput) {
+ *phr = E_OUTOFMEMORY;
+ }
+
+ m_pCpuId = DNew CCpuId();
+ m_pAVCodec = NULL;
+ m_pAVCtx = NULL;
+ m_pFrame = NULL;
+ m_nCodecNb = -1;
+ m_nCodecId = CODEC_ID_NONE;
+ m_bReorderBFrame = true;
+ m_DXVADecoderGUID = GUID_NULL;
+ m_nActiveCodecs = MPCVD_H264 | MPCVD_VC1 | MPCVD_XVID | MPCVD_DIVX | MPCVD_MSMPEG4 | MPCVD_FLASH | MPCVD_WMV | MPCVD_H263 | MPCVD_SVQ3 | MPCVD_AMVV | MPCVD_THEORA | MPCVD_H264_DXVA | MPCVD_VC1_DXVA | MPCVD_VP356 | MPCVD_VP8 | MPCVD_MJPEG | MPCVD_INDEO | MPCVD_RV | MPCVD_WMV3_DXVA | MPCVD_MPEG2_DXVA;
+
+ m_rtAvrTimePerFrame = 0;
+ m_rtLastStart = 0;
+ m_nCountEstimated = 0;
+ m_rtPrevStop = 0;
+
+ m_nWorkaroundBug = FF_BUG_AUTODETECT;
+ m_nErrorConcealment = FF_EC_DEBLOCK | FF_EC_GUESS_MVS;
+
+ m_nThreadNumber = 0;
+ m_nDiscardMode = AVDISCARD_DEFAULT;
+ m_nErrorRecognition = AV_EF_CAREFUL;
+ m_nIDCTAlgo = FF_IDCT_AUTO;
+ m_bDXVACompatible = true;
+ m_pFFBuffer = NULL;
+ m_nFFBufferSize = 0;
+ m_pAlignedFFBuffer = NULL;
+ m_nAlignedFFBufferSize = 0;
+ ResetBuffer();
+
+ m_nWidth = 0;
+ m_nHeight = 0;
+ m_pSwsContext = NULL;
+
+ m_bUseDXVA = true;
+ m_bUseFFmpeg = true;
+
+ m_nDXVAMode = MODE_SOFTWARE;
+ m_pDXVADecoder = NULL;
+ m_pVideoOutputFormat = NULL;
+ m_nVideoOutputCount = 0;
+ m_hDevice = INVALID_HANDLE_VALUE;
+
+ m_nARMode = 1;
+ m_nDXVACheckCompatibility = 1; // skip level check by default
+ m_nDXVA_SD = 0;
+ m_sar.SetSize(1, 1);
+
+ m_bTheoraMTSupport = true;
+ m_bWaitingForKeyFrame = TRUE;
+ m_nPosB = 1;
+ m_bFrame_repeat_pict = false;
+ m_bIsEVO = false;
#ifdef REGISTER_FILTER
- CRegKey key;
- if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPC Video Decoder"), KEY_READ)) {
- DWORD dw;
+ CRegKey key;
+ if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPC Video Decoder"), KEY_READ)) {
+ DWORD dw;
#if HAS_FFMPEG_VIDEO_DECODERS
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("ThreadNumber"), dw)) {
- m_nThreadNumber = dw;
- }
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("ThreadNumber"), dw)) {
+ m_nThreadNumber = dw;
+ }
#if INTERNAL_DECODER_H264
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("DiscardMode"), dw)) {
- m_nDiscardMode = dw;
- }
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("DiscardMode"), dw)) {
+ m_nDiscardMode = dw;
+ }
#endif
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("ErrorRecognition"), dw)) {
- m_nErrorRecognition = dw;
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("IDCTAlgo"), dw)) {
- m_nIDCTAlgo = dw;
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("ActiveCodecs"), dw)) {
- m_nActiveCodecs = dw;
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("ARMode"), dw)) {
- m_nARMode = dw;
- }
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("ErrorRecognition"), dw)) {
+ m_nErrorRecognition = dw;
+ }
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("IDCTAlgo"), dw)) {
+ m_nIDCTAlgo = dw;
+ }
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("ActiveCodecs"), dw)) {
+ m_nActiveCodecs = dw;
+ }
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("ARMode"), dw)) {
+ m_nARMode = dw;
+ }
#endif
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("DXVACheckCompatibility"), dw)) {
- m_nDXVACheckCompatibility = dw;
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("DisableDXVA_SD"), dw)) {
- m_nDXVA_SD = dw;
- }
- }
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("DXVACheckCompatibility"), dw)) {
+ m_nDXVACheckCompatibility = dw;
+ }
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("DisableDXVA_SD"), dw)) {
+ m_nDXVA_SD = dw;
+ }
+ }
#else
#if HAS_FFMPEG_VIDEO_DECODERS
- m_nThreadNumber = AfxGetApp()->GetProfileInt(_T("Filters\\MPC Video Decoder"), _T("ThreadNumber"), m_nThreadNumber);
+ m_nThreadNumber = AfxGetApp()->GetProfileInt(_T("Filters\\MPC Video Decoder"), _T("ThreadNumber"), m_nThreadNumber);
#if INTERNAL_DECODER_H264
- m_nDiscardMode = AfxGetApp()->GetProfileInt(_T("Filters\\MPC Video Decoder"), _T("DiscardMode"), m_nDiscardMode);
+ m_nDiscardMode = AfxGetApp()->GetProfileInt(_T("Filters\\MPC Video Decoder"), _T("DiscardMode"), m_nDiscardMode);
#endif
- m_nErrorRecognition = AfxGetApp()->GetProfileInt(_T("Filters\\MPC Video Decoder"), _T("ErrorRecognition"), m_nErrorRecognition);
- m_nIDCTAlgo = AfxGetApp()->GetProfileInt(_T("Filters\\MPC Video Decoder"), _T("IDCTAlgo"), m_nIDCTAlgo);
- m_nARMode = AfxGetApp()->GetProfileInt(_T("Filters\\MPC Video Decoder"), _T("ARMode"), m_nARMode);
+ m_nErrorRecognition = AfxGetApp()->GetProfileInt(_T("Filters\\MPC Video Decoder"), _T("ErrorRecognition"), m_nErrorRecognition);
+ m_nIDCTAlgo = AfxGetApp()->GetProfileInt(_T("Filters\\MPC Video Decoder"), _T("IDCTAlgo"), m_nIDCTAlgo);
+ m_nARMode = AfxGetApp()->GetProfileInt(_T("Filters\\MPC Video Decoder"), _T("ARMode"), m_nARMode);
#endif
- m_nDXVACheckCompatibility = AfxGetApp()->GetProfileInt(_T("Filters\\MPC Video Decoder"), _T("DXVACheckCompatibility"), m_nDXVACheckCompatibility);
- m_nDXVA_SD = AfxGetApp()->GetProfileInt(_T("Filters\\MPC Video Decoder"), _T("DisableDXVA_SD"), m_nDXVA_SD);
+ m_nDXVACheckCompatibility = AfxGetApp()->GetProfileInt(_T("Filters\\MPC Video Decoder"), _T("DXVACheckCompatibility"), m_nDXVACheckCompatibility);
+ m_nDXVA_SD = AfxGetApp()->GetProfileInt(_T("Filters\\MPC Video Decoder"), _T("DisableDXVA_SD"), m_nDXVA_SD);
#endif
- if (m_nErrorRecognition != AV_EF_CAREFUL && m_nErrorRecognition != AV_EF_COMPLIANT && m_nErrorRecognition != AV_EF_AGGRESSIVE) {
- m_nErrorRecognition = AV_EF_CAREFUL;
- }
- if (m_nDXVACheckCompatibility > 3) {
- m_nDXVACheckCompatibility = 1; // skip level check by default
- }
+ if (m_nErrorRecognition != AV_EF_CAREFUL && m_nErrorRecognition != AV_EF_COMPLIANT && m_nErrorRecognition != AV_EF_AGGRESSIVE) {
+ m_nErrorRecognition = AV_EF_CAREFUL;
+ }
+ if (m_nDXVACheckCompatibility > 3) {
+ m_nDXVACheckCompatibility = 1; // skip level check by default
+ }
- ff_avcodec_default_get_buffer = avcodec_default_get_buffer;
- ff_avcodec_default_release_buffer = avcodec_default_release_buffer;
- ff_avcodec_default_reget_buffer = avcodec_default_reget_buffer;
+ ff_avcodec_default_get_buffer = avcodec_default_get_buffer;
+ ff_avcodec_default_release_buffer = avcodec_default_release_buffer;
+ ff_avcodec_default_reget_buffer = avcodec_default_reget_buffer;
- avcodec_register_all();
- av_log_set_callback(LogLibavcodec);
+ avcodec_register_all();
+ av_log_set_callback(LogLibavcodec);
- EnumWindows(EnumFindProcessWnd, (LPARAM)&hWnd);
- DetectVideoCard(hWnd);
+ EnumWindows(EnumFindProcessWnd, (LPARAM)&hWnd);
+ DetectVideoCard(hWnd);
#ifdef _DEBUG
- // Check codec definition table
- int nCodecs = _countof(ffCodecs);
- int nPinTypes = _countof(sudPinTypesIn);
- ASSERT (nCodecs == nPinTypes);
- for (int i=0; i<nPinTypes; i++) {
- ASSERT (ffCodecs[i].clsMinorType == sudPinTypesIn[i].clsMinorType);
- }
+ // Check codec definition table
+ int nCodecs = _countof(ffCodecs);
+ int nPinTypes = _countof(sudPinTypesIn);
+ ASSERT(nCodecs == nPinTypes);
+ for (int i = 0; i < nPinTypes; i++) {
+ ASSERT(ffCodecs[i].clsMinorType == sudPinTypesIn[i].clsMinorType);
+ }
#endif
}
void CMPCVideoDecFilter::DetectVideoCard(HWND hWnd)
{
- IDirect3D9* pD3D9;
- m_nPCIVendor = 0;
- m_nPCIDevice = 0;
- m_VideoDriverVersion.HighPart = 0;
- m_VideoDriverVersion.LowPart = 0;
-
- pD3D9 = Direct3DCreate9(D3D_SDK_VERSION);
- if (pD3D9) {
- D3DADAPTER_IDENTIFIER9 adapterIdentifier;
- if (pD3D9->GetAdapterIdentifier(GetAdapter(pD3D9, hWnd), 0, &adapterIdentifier) == S_OK) {
- m_nPCIVendor = adapterIdentifier.VendorId;
- m_nPCIDevice = adapterIdentifier.DeviceId;
- m_VideoDriverVersion = adapterIdentifier.DriverVersion;
- m_strDeviceDescription = adapterIdentifier.Description;
- m_strDeviceDescription.AppendFormat (_T(" (%04X:%04X)"), m_nPCIVendor, m_nPCIDevice);
- }
- pD3D9->Release();
- }
+ IDirect3D9* pD3D9;
+ m_nPCIVendor = 0;
+ m_nPCIDevice = 0;
+ m_VideoDriverVersion.HighPart = 0;
+ m_VideoDriverVersion.LowPart = 0;
+
+ pD3D9 = Direct3DCreate9(D3D_SDK_VERSION);
+ if (pD3D9) {
+ D3DADAPTER_IDENTIFIER9 adapterIdentifier;
+ if (pD3D9->GetAdapterIdentifier(GetAdapter(pD3D9, hWnd), 0, &adapterIdentifier) == S_OK) {
+ m_nPCIVendor = adapterIdentifier.VendorId;
+ m_nPCIDevice = adapterIdentifier.DeviceId;
+ m_VideoDriverVersion = adapterIdentifier.DriverVersion;
+ m_strDeviceDescription = adapterIdentifier.Description;
+ m_strDeviceDescription.AppendFormat(_T(" (%04X:%04X)"), m_nPCIVendor, m_nPCIDevice);
+ }
+ pD3D9->Release();
+ }
}
CMPCVideoDecFilter::~CMPCVideoDecFilter()
{
- Cleanup();
+ Cleanup();
- SAFE_DELETE(m_pCpuId);
+ SAFE_DELETE(m_pCpuId);
}
bool CMPCVideoDecFilter::IsVideoInterlaced()
{
- // NOT A BUG : always tell DirectShow it's interlaced (progressive flags set in
- // SetTypeSpecificFlags function)
- return true;
+ // NOT A BUG : always tell DirectShow it's interlaced (progressive flags set in
+ // SetTypeSpecificFlags function)
+ return true;
};
-void CMPCVideoDecFilter::UpdateFrameTime (REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop, bool b_repeat_pict)
+void CMPCVideoDecFilter::UpdateFrameTime(REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop, bool b_repeat_pict)
{
- bool m_PullDownFlag = (m_nCodecId == CODEC_ID_VC1 && b_repeat_pict && m_rtAvrTimePerFrame == 333666);
- REFERENCE_TIME m_rtFrameDuration = m_PullDownFlag ? AVRTIMEPERFRAME_VC1_EVO : m_rtAvrTimePerFrame;
+ bool m_PullDownFlag = (m_nCodecId == CODEC_ID_VC1 && b_repeat_pict && m_rtAvrTimePerFrame == 333666);
+ REFERENCE_TIME m_rtFrameDuration = m_PullDownFlag ? AVRTIMEPERFRAME_VC1_EVO : m_rtAvrTimePerFrame;
- if ((rtStart == _I64_MIN) || (m_PullDownFlag && m_rtPrevStop && (rtStart <= m_rtPrevStop))) {
- rtStart = m_rtLastStart + (m_rtFrameDuration / m_dRate) * m_nCountEstimated;
- m_nCountEstimated++;
- } else {
- m_rtLastStart = rtStart;
- m_nCountEstimated = 1;
- }
+ if ((rtStart == _I64_MIN) || (m_PullDownFlag && m_rtPrevStop && (rtStart <= m_rtPrevStop))) {
+ rtStart = m_rtLastStart + (m_rtFrameDuration / m_dRate) * m_nCountEstimated;
+ m_nCountEstimated++;
+ } else {
+ m_rtLastStart = rtStart;
+ m_nCountEstimated = 1;
+ }
- rtStop = rtStart + (m_rtFrameDuration / m_dRate);
+ rtStop = rtStart + (m_rtFrameDuration / m_dRate);
}
void CMPCVideoDecFilter::GetOutputSize(int& w, int& h, int& arx, int& ary, int& RealWidth, int& RealHeight)
{
#if 1
- RealWidth = m_nWidth;
- RealHeight = m_nHeight;
- w = PictWidthRounded();
- h = PictHeightRounded();
+ RealWidth = m_nWidth;
+ RealHeight = m_nHeight;
+ w = PictWidthRounded();
+ h = PictHeightRounded();
#else
- if (m_nDXVAMode == MODE_SOFTWARE) {
- w = m_nWidth;
- h = m_nHeight;
- } else {
- // DXVA surface are multiple of 16 pixels!
- w = PictWidthRounded();
- h = PictHeightRounded();
- }
+ if (m_nDXVAMode == MODE_SOFTWARE) {
+ w = m_nWidth;
+ h = m_nHeight;
+ } else {
+ // DXVA surface are multiple of 16 pixels!
+ w = PictWidthRounded();
+ h = PictHeightRounded();
+ }
#endif
}
int CMPCVideoDecFilter::PictWidth()
{
- return m_nWidth;
+ return m_nWidth;
}
int CMPCVideoDecFilter::PictHeight()
{
- return m_nHeight;
+ return m_nHeight;
}
int CMPCVideoDecFilter::PictWidthRounded()
{
- // Picture height should be rounded to 16 for DXVA
- return ((m_nWidth + 15) / 16) * 16;
+ // Picture height should be rounded to 16 for DXVA
+ return ((m_nWidth + 15) / 16) * 16;
}
int CMPCVideoDecFilter::PictHeightRounded()
{
- // Picture height should be rounded to 16 for DXVA
- return ((m_nHeight + 15) / 16) * 16;
+ // Picture height should be rounded to 16 for DXVA
+ return ((m_nHeight + 15) / 16) * 16;
}
int CMPCVideoDecFilter::FindCodec(const CMediaType* mtIn)
{
- for (int i=0; i<_countof(ffCodecs); i++)
- if (mtIn->subtype == *ffCodecs[i].clsMinorType) {
+ for (int i = 0; i < _countof(ffCodecs); i++)
+ if (mtIn->subtype == *ffCodecs[i].clsMinorType) {
#ifndef REGISTER_FILTER
- switch (ffCodecs[i].nFFCodec) {
- case CODEC_ID_H264 :
+ switch (ffCodecs[i].nFFCodec) {
+ case CODEC_ID_H264 :
#if INTERNAL_DECODER_H264_DXVA
- m_bUseDXVA = DXVAFilters && DXVAFilters[TRA_DXVA_H264];
+ m_bUseDXVA = DXVAFilters && DXVAFilters[TRA_DXVA_H264];
#else
- m_bUseDXVA = false;
+ m_bUseDXVA = false;
#endif
#if INTERNAL_DECODER_H264
- m_bUseFFmpeg = FFmpegFilters && FFmpegFilters[FFM_H264];
+ m_bUseFFmpeg = FFmpegFilters && FFmpegFilters[FFM_H264];
#else
- m_bUseFFmpeg = false;
+ m_bUseFFmpeg = false;
#endif
- break;
- case CODEC_ID_VC1 :
+ break;
+ case CODEC_ID_VC1 :
#if INTERNAL_DECODER_VC1_DXVA
- m_bUseDXVA = DXVAFilters && DXVAFilters[TRA_DXVA_VC1];
+ m_bUseDXVA = DXVAFilters && DXVAFilters[TRA_DXVA_VC1];
#else
- m_bUseDXVA = false;
+ m_bUseDXVA = false;
#endif
#if INTERNAL_DECODER_VC1
- m_bUseFFmpeg = FFmpegFilters && FFmpegFilters[FFM_VC1];
+ m_bUseFFmpeg = FFmpegFilters && FFmpegFilters[FFM_VC1];
#else
- m_bUseFFmpeg = false;
+ m_bUseFFmpeg = false;
#endif
- break;
- case CODEC_ID_WMV3 :
+ break;
+ case CODEC_ID_WMV3 :
#if INTERNAL_DECODER_WMV3_DXVA
- m_bUseDXVA = DXVAFilters && DXVAFilters[TRA_DXVA_WMV3];
+ m_bUseDXVA = DXVAFilters && DXVAFilters[TRA_DXVA_WMV3];
#else
- m_bUseDXVA = false;
+ m_bUseDXVA = false;
#endif
#if INTERNAL_DECODER_WMV
- m_bUseFFmpeg = FFmpegFilters && FFmpegFilters[FFM_WMV];
+ m_bUseFFmpeg = FFmpegFilters && FFmpegFilters[FFM_WMV];
#else
- m_bUseFFmpeg = false;
+ m_bUseFFmpeg = false;
#endif
- break;
- case CODEC_ID_MPEG2VIDEO :
+ break;
+ case CODEC_ID_MPEG2VIDEO :
#if INTERNAL_DECODER_MPEG2_DXVA
- m_bUseDXVA = true;
+ m_bUseDXVA = true;
#endif
- m_bUseFFmpeg = false; // No Mpeg2 software support with ffmpeg!
- break;
- default :
- m_bUseDXVA = false;
- }
+ m_bUseFFmpeg = false; // No Mpeg2 software support with ffmpeg!
+ break;
+ default :
+ m_bUseDXVA = false;
+ }
- return ((m_bUseDXVA || m_bUseFFmpeg) ? i : -1);
+ return ((m_bUseDXVA || m_bUseFFmpeg) ? i : -1);
#else
- bool bCodecActivated = false;
- switch (ffCodecs[i].nFFCodec) {
- case CODEC_ID_FLV1 :
- case CODEC_ID_VP6F :
- bCodecActivated = (m_nActiveCodecs & MPCVD_FLASH) != 0;
- break;
- case CODEC_ID_MPEG4 :
- if ((*ffCodecs[i].clsMinorType == MEDIASUBTYPE_DX50) || // DivX
- (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_dx50) ||
- (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_DIVX) ||
- (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_divx) ) {
- bCodecActivated = (m_nActiveCodecs & MPCVD_DIVX) != 0;
- } else {
- bCodecActivated = (m_nActiveCodecs & MPCVD_XVID) != 0; // Xvid/MPEG-4
- }
- break;
- case CODEC_ID_WMV1 :
- case CODEC_ID_WMV2 :
- bCodecActivated = (m_nActiveCodecs & MPCVD_WMV) != 0;
- break;
- case CODEC_ID_WMV3 :
- m_bUseDXVA = (m_nActiveCodecs & MPCVD_WMV3_DXVA) != 0;
- m_bUseFFmpeg = (m_nActiveCodecs & MPCVD_WMV) != 0;
- bCodecActivated = m_bUseDXVA || m_bUseFFmpeg;
- break;
- case CODEC_ID_MSMPEG4V3 :
- case CODEC_ID_MSMPEG4V2 :
- case CODEC_ID_MSMPEG4V1 :
- bCodecActivated = (m_nActiveCodecs & MPCVD_MSMPEG4) != 0;
- break;
- case CODEC_ID_H264 :
- m_bUseDXVA = (m_nActiveCodecs & MPCVD_H264_DXVA) != 0;
- m_bUseFFmpeg = (m_nActiveCodecs & MPCVD_H264) != 0;
- bCodecActivated = m_bUseDXVA || m_bUseFFmpeg;
- break;
- case CODEC_ID_SVQ3 :
- case CODEC_ID_SVQ1 :
- bCodecActivated = (m_nActiveCodecs & MPCVD_SVQ3) != 0;
- break;
- case CODEC_ID_H263 :
- bCodecActivated = (m_nActiveCodecs & MPCVD_H263) != 0;
- break;
- case CODEC_ID_THEORA :
- bCodecActivated = (m_nActiveCodecs & MPCVD_THEORA) != 0;
- break;
- case CODEC_ID_VC1 :
- m_bUseDXVA = (m_nActiveCodecs & MPCVD_VC1_DXVA) != 0;
- m_bUseFFmpeg = (m_nActiveCodecs & MPCVD_VC1) != 0;
- bCodecActivated = m_bUseDXVA || m_bUseFFmpeg;
- break;
- case CODEC_ID_AMV :
- bCodecActivated = (m_nActiveCodecs & MPCVD_AMVV) != 0;
- break;
- case CODEC_ID_VP3 :
- case CODEC_ID_VP5 :
- case CODEC_ID_VP6 :
- case CODEC_ID_VP6A :
- bCodecActivated = (m_nActiveCodecs & MPCVD_VP356) != 0;
- break;
- case CODEC_ID_VP8 :
- bCodecActivated = (m_nActiveCodecs & MPCVD_VP8) != 0;
- break;
- case CODEC_ID_MJPEG :
- case CODEC_ID_MJPEGB :
- bCodecActivated = (m_nActiveCodecs & MPCVD_MJPEG) != 0;
- break;
- case CODEC_ID_INDEO3 :
- case CODEC_ID_INDEO4 :
- case CODEC_ID_INDEO5 :
- bCodecActivated = (m_nActiveCodecs & MPCVD_INDEO) != 0;
- break;
- case CODEC_ID_TSCC :
- bCodecActivated = 1;
- break;
- case CODEC_ID_RV10 :
- case CODEC_ID_RV20 :
- case CODEC_ID_RV30 :
- case CODEC_ID_RV40 :
- bCodecActivated = (m_nActiveCodecs & MPCVD_RV) != 0;
- break;
- case CODEC_ID_MPEG2VIDEO :
- m_bUseDXVA = (m_nActiveCodecs & MPCVD_MPEG2_DXVA) != 0;
- m_bUseFFmpeg = false;
- bCodecActivated = m_bUseDXVA;
- break;
- }
- return (bCodecActivated ? i : -1);
+ bool bCodecActivated = false;
+ switch (ffCodecs[i].nFFCodec) {
+ case CODEC_ID_FLV1 :
+ case CODEC_ID_VP6F :
+ bCodecActivated = (m_nActiveCodecs & MPCVD_FLASH) != 0;
+ break;
+ case CODEC_ID_MPEG4 :
+ if ((*ffCodecs[i].clsMinorType == MEDIASUBTYPE_DX50) || // DivX
+ (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_dx50) ||
+ (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_DIVX) ||
+ (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_divx)) {
+ bCodecActivated = (m_nActiveCodecs & MPCVD_DIVX) != 0;
+ } else {
+ bCodecActivated = (m_nActiveCodecs & MPCVD_XVID) != 0; // Xvid/MPEG-4
+ }
+ break;
+ case CODEC_ID_WMV1 :
+ case CODEC_ID_WMV2 :
+ bCodecActivated = (m_nActiveCodecs & MPCVD_WMV) != 0;
+ break;
+ case CODEC_ID_WMV3 :
+ m_bUseDXVA = (m_nActiveCodecs & MPCVD_WMV3_DXVA) != 0;
+ m_bUseFFmpeg = (m_nActiveCodecs & MPCVD_WMV) != 0;
+ bCodecActivated = m_bUseDXVA || m_bUseFFmpeg;
+ break;
+ case CODEC_ID_MSMPEG4V3 :
+ case CODEC_ID_MSMPEG4V2 :
+ case CODEC_ID_MSMPEG4V1 :
+ bCodecActivated = (m_nActiveCodecs & MPCVD_MSMPEG4) != 0;
+ break;
+ case CODEC_ID_H264 :
+ m_bUseDXVA = (m_nActiveCodecs & MPCVD_H264_DXVA) != 0;
+ m_bUseFFmpeg = (m_nActiveCodecs & MPCVD_H264) != 0;
+ bCodecActivated = m_bUseDXVA || m_bUseFFmpeg;
+ break;
+ case CODEC_ID_SVQ3 :
+ case CODEC_ID_SVQ1 :
+ bCodecActivated = (m_nActiveCodecs & MPCVD_SVQ3) != 0;
+ break;
+ case CODEC_ID_H263 :
+ bCodecActivated = (m_nActiveCodecs & MPCVD_H263) != 0;
+ break;
+ case CODEC_ID_THEORA :
+ bCodecActivated = (m_nActiveCodecs & MPCVD_THEORA) != 0;
+ break;
+ case CODEC_ID_VC1 :
+ m_bUseDXVA = (m_nActiveCodecs & MPCVD_VC1_DXVA) != 0;
+ m_bUseFFmpeg = (m_nActiveCodecs & MPCVD_VC1) != 0;
+ bCodecActivated = m_bUseDXVA || m_bUseFFmpeg;
+ break;
+ case CODEC_ID_AMV :
+ bCodecActivated = (m_nActiveCodecs & MPCVD_AMVV) != 0;
+ break;
+ case CODEC_ID_VP3 :
+ case CODEC_ID_VP5 :
+ case CODEC_ID_VP6 :
+ case CODEC_ID_VP6A :
+ bCodecActivated = (m_nActiveCodecs & MPCVD_VP356) != 0;
+ break;
+ case CODEC_ID_VP8 :
+ bCodecActivated = (m_nActiveCodecs & MPCVD_VP8) != 0;
+ break;
+ case CODEC_ID_MJPEG :
+ case CODEC_ID_MJPEGB :
+ bCodecActivated = (m_nActiveCodecs & MPCVD_MJPEG) != 0;
+ break;
+ case CODEC_ID_INDEO3 :
+ case CODEC_ID_INDEO4 :
+ case CODEC_ID_INDEO5 :
+ bCodecActivated = (m_nActiveCodecs & MPCVD_INDEO) != 0;
+ break;
+ case CODEC_ID_TSCC :
+ bCodecActivated = 1;
+ break;
+ case CODEC_ID_RV10 :
+ case CODEC_ID_RV20 :
+ case CODEC_ID_RV30 :
+ case CODEC_ID_RV40 :
+ bCodecActivated = (m_nActiveCodecs & MPCVD_RV) != 0;
+ break;
+ case CODEC_ID_MPEG2VIDEO :
+ m_bUseDXVA = (m_nActiveCodecs & MPCVD_MPEG2_DXVA) != 0;
+ m_bUseFFmpeg = false;
+ bCodecActivated = m_bUseDXVA;
+ break;
+ }
+ return (bCodecActivated ? i : -1);
#endif
- }
+ }
- return -1;
+ return -1;
}
void CMPCVideoDecFilter::Cleanup()
{
- SAFE_DELETE (m_pDXVADecoder);
+ SAFE_DELETE(m_pDXVADecoder);
- // Release FFMpeg
- if (m_pAVCtx) {
- if (m_pAVCtx->extradata) {
- av_freep(&m_pAVCtx->extradata);
- }
- if (m_pFFBuffer) {
- av_freep(&m_pFFBuffer);
- }
- m_nFFBufferSize = 0;
- if (m_pAlignedFFBuffer) {
- av_freep(&m_pAlignedFFBuffer);
- }
- m_nAlignedFFBufferSize = 0;
+ // Release FFMpeg
+ if (m_pAVCtx) {
+ if (m_pAVCtx->extradata) {
+ av_freep(&m_pAVCtx->extradata);
+ }
+ if (m_pFFBuffer) {
+ av_freep(&m_pFFBuffer);
+ }
+ m_nFFBufferSize = 0;
+ if (m_pAlignedFFBuffer) {
+ av_freep(&m_pAlignedFFBuffer);
+ }
+ m_nAlignedFFBufferSize = 0;
- if (m_pAVCtx->codec) {
- avcodec_close(m_pAVCtx);
- }
+ if (m_pAVCtx->codec) {
+ avcodec_close(m_pAVCtx);
+ }
- // Free thread resource if necessary
- FFSetThreadNumber (m_pAVCtx, m_pAVCtx->codec_id, 0);
+ // Free thread resource if necessary
+ FFSetThreadNumber(m_pAVCtx, m_pAVCtx->codec_id, 0);
- av_freep(&m_pAVCtx);
- }
+ av_freep(&m_pAVCtx);
+ }
- if (m_pFrame) {
- av_freep(&m_pFrame);
- }
+ if (m_pFrame) {
+ av_freep(&m_pFrame);
+ }
#if HAS_FFMPEG_VIDEO_DECODERS
- if (m_pSwsContext) {
- sws_freeContext(m_pSwsContext);
- m_pSwsContext = NULL;
- }
+ if (m_pSwsContext) {
+ sws_freeContext(m_pSwsContext);
+ m_pSwsContext = NULL;
+ }
#endif /* HAS_FFMPEG_VIDEO_DECODERS */
- m_pAVCodec = NULL;
- m_pAVCtx = NULL;
- m_pFrame = NULL;
- m_pFFBuffer = NULL;
- m_nFFBufferSize = 0;
- m_nFFBufferPos = 0;
- m_nFFPicEnd = INT_MIN;
- m_nCodecNb = -1;
- m_nCodecId = CODEC_ID_NONE;
- SAFE_DELETE_ARRAY (m_pVideoOutputFormat);
+ m_pAVCodec = NULL;
+ m_pAVCtx = NULL;
+ m_pFrame = NULL;
+ m_pFFBuffer = NULL;
+ m_nFFBufferSize = 0;
+ m_nFFBufferPos = 0;
+ m_nFFPicEnd = INT_MIN;
+ m_nCodecNb = -1;
+ m_nCodecId = CODEC_ID_NONE;
+ SAFE_DELETE_ARRAY(m_pVideoOutputFormat);
- // Release DXVA ressources
- if (m_hDevice != INVALID_HANDLE_VALUE) {
- m_pDeviceManager->CloseDeviceHandle(m_hDevice);
- m_hDevice = INVALID_HANDLE_VALUE;
- }
+ // Release DXVA ressources
+ if (m_hDevice != INVALID_HANDLE_VALUE) {
+ m_pDeviceManager->CloseDeviceHandle(m_hDevice);
+ m_hDevice = INVALID_HANDLE_VALUE;
+ }
- m_pDeviceManager = NULL;
- m_pDecoderService = NULL;
- m_pDecoderRenderTarget = NULL;
+ m_pDeviceManager = NULL;
+ m_pDecoderService = NULL;
+ m_pDecoderRenderTarget = NULL;
}
void CMPCVideoDecFilter::CalcAvgTimePerFrame()
{
- CMediaType &mt = m_pInput->CurrentMediaType();
- if (mt.formattype==FORMAT_VideoInfo) {
- m_rtAvrTimePerFrame = ((VIDEOINFOHEADER*)mt.pbFormat)->AvgTimePerFrame;
- } else if (mt.formattype==FORMAT_VideoInfo2) {
- m_rtAvrTimePerFrame = ((VIDEOINFOHEADER2*)mt.pbFormat)->AvgTimePerFrame;
- } else if (mt.formattype==FORMAT_MPEGVideo) {
- m_rtAvrTimePerFrame = ((MPEG1VIDEOINFO*)mt.pbFormat)->hdr.AvgTimePerFrame;
- } else if (mt.formattype==FORMAT_MPEG2Video) {
- m_rtAvrTimePerFrame = ((MPEG2VIDEOINFO*)mt.pbFormat)->hdr.AvgTimePerFrame;
- } else {
- ASSERT (FALSE);
- m_rtAvrTimePerFrame = 1;
- }
+ CMediaType& mt = m_pInput->CurrentMediaType();
+ if (mt.formattype == FORMAT_VideoInfo) {
+ m_rtAvrTimePerFrame = ((VIDEOINFOHEADER*)mt.pbFormat)->AvgTimePerFrame;
+ } else if (mt.formattype == FORMAT_VideoInfo2) {
+ m_rtAvrTimePerFrame = ((VIDEOINFOHEADER2*)mt.pbFormat)->AvgTimePerFrame;
+ } else if (mt.formattype == FORMAT_MPEGVideo) {
+ m_rtAvrTimePerFrame = ((MPEG1VIDEOINFO*)mt.pbFormat)->hdr.AvgTimePerFrame;
+ } else if (mt.formattype == FORMAT_MPEG2Video) {
+ m_rtAvrTimePerFrame = ((MPEG2VIDEOINFO*)mt.pbFormat)->hdr.AvgTimePerFrame;
+ } else {
+ ASSERT(FALSE);
+ m_rtAvrTimePerFrame = 1;
+ }
- m_rtAvrTimePerFrame = max (1, m_rtAvrTimePerFrame);
+ m_rtAvrTimePerFrame = max(1, m_rtAvrTimePerFrame);
}
-void CMPCVideoDecFilter::LogLibavcodec(void* par,int level,const char *fmt,va_list valist)
+void CMPCVideoDecFilter::LogLibavcodec(void* par, int level, const char* fmt, va_list valist)
{
#if defined(_DEBUG) && 0
- char Msg [500];
- vsnprintf_s (Msg, sizeof(Msg), _TRUNCATE, fmt, valist);
- TRACE("AVLIB : %s", Msg);
+ char Msg [500];
+ vsnprintf_s(Msg, sizeof(Msg), _TRUNCATE, fmt, valist);
+ TRACE("AVLIB : %s", Msg);
#endif
}
-void CMPCVideoDecFilter::OnGetBuffer(AVFrame *pic)
+void CMPCVideoDecFilter::OnGetBuffer(AVFrame* pic)
{
- // Callback from FFMpeg to store Ref Time in frame (needed to have correct rtStart after avcodec_decode_video calls)
- // pic->rtStart = m_rtStart;
+ // Callback from FFMpeg to store Ref Time in frame (needed to have correct rtStart after avcodec_decode_video calls)
+ // pic->rtStart = m_rtStart;
}
STDMETHODIMP CMPCVideoDecFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- return
- QI(IMPCVideoDecFilter)
- QI(IMPCVideoDecFilter2)
- QI(ISpecifyPropertyPages)
- QI(ISpecifyPropertyPages2)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IMPCVideoDecFilter)
+ QI(IMPCVideoDecFilter2)
+ QI(ISpecifyPropertyPages)
+ QI(ISpecifyPropertyPages2)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CMPCVideoDecFilter::CheckInputType(const CMediaType* mtIn)
{
- for (int i=0; i<_countof(sudPinTypesIn); i++) {
- if ((mtIn->majortype == *sudPinTypesIn[i].clsMajorType) &&
- (mtIn->subtype == *sudPinTypesIn[i].clsMinorType)) {
- return S_OK;
- }
- }
+ for (int i = 0; i < _countof(sudPinTypesIn); i++) {
+ if ((mtIn->majortype == *sudPinTypesIn[i].clsMajorType) &&
+ (mtIn->subtype == *sudPinTypesIn[i].clsMinorType)) {
+ return S_OK;
+ }
+ }
- return VFW_E_TYPE_NOT_ACCEPTED;
+ return VFW_E_TYPE_NOT_ACCEPTED;
}
bool CMPCVideoDecFilter::IsMultiThreadSupported(enum CodecID nCodec)
{
- return
- (
- nCodec==CODEC_ID_H264 ||
- nCodec==CODEC_ID_MPEG1VIDEO ||
- nCodec==CODEC_ID_FFV1 ||
- nCodec==CODEC_ID_DVVIDEO ||
- nCodec==CODEC_ID_VP3 ||
- nCodec==CODEC_ID_VP8 ||
- nCodec==CODEC_ID_THEORA ||
- nCodec==CODEC_ID_RV30 ||
- nCodec==CODEC_ID_RV40
- );
+ return
+ (
+ nCodec == CODEC_ID_H264 ||
+ nCodec == CODEC_ID_MPEG1VIDEO ||
+ nCodec == CODEC_ID_FFV1 ||
+ nCodec == CODEC_ID_DVVIDEO ||
+ nCodec == CODEC_ID_VP3 ||
+ nCodec == CODEC_ID_VP8 ||
+ nCodec == CODEC_ID_THEORA ||
+ nCodec == CODEC_ID_RV30 ||
+ nCodec == CODEC_ID_RV40
+ );
}
CString CMPCVideoDecFilter::GetFileExtension()
{
- CString ext = _T("");
-
- BeginEnumFilters(m_pGraph, pEF, pBF) {
- CComQIPtr<IFileSourceFilter> pFSF = pBF;
- if (pFSF) {
- LPOLESTR pFN = NULL;
- AM_MEDIA_TYPE mt;
- if (SUCCEEDED(pFSF->GetCurFile(&pFN, &mt)) && pFN && *pFN) {
- ext = CPath(CStringW(pFN)).GetExtension();
- ext.MakeLower();
- CoTaskMemFree(pFN);
- }
- break;
- }
- }
- EndEnumFilters
-
- return ext;
-}
-
-HRESULT CMPCVideoDecFilter::SetMediaType(PIN_DIRECTION direction,const CMediaType *pmt)
-{
- if (direction == PINDIR_INPUT) {
-
- int nNewCodec = FindCodec(pmt);
-
- if (nNewCodec == -1) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- if (nNewCodec != m_nCodecNb) {
- m_nCodecNb = nNewCodec;
- m_nCodecId = ffCodecs[nNewCodec].nFFCodec;
-
- CLSID ClsidSourceFilter = GetCLSID(m_pInput->GetConnected());
- if ((ClsidSourceFilter == __uuidof(COggSourceFilter)) || (ClsidSourceFilter == __uuidof(COggSplitterFilter))) {
- m_bTheoraMTSupport = false;
- } else if ((ClsidSourceFilter == __uuidof(CMpegSourceFilter)) || (ClsidSourceFilter == __uuidof(CMpegSplitterFilter))) {
- if (CComPtr<IBaseFilter> pFilter = GetFilterFromPin(m_pInput->GetConnected()) ) {
- if (CComQIPtr<IMpegSplitterFilter> MpegSplitterFilter = pFilter ) {
- m_bIsEVO = (m_nCodecId == CODEC_ID_VC1 && mpeg_ps == MpegSplitterFilter->GetMPEGType());
- }
- }
- }
-
- m_bReorderBFrame = true;
- m_pAVCodec = avcodec_find_decoder(m_nCodecId);
- CheckPointer (m_pAVCodec, VFW_E_UNSUPPORTED_VIDEO);
-
- m_pAVCtx = avcodec_alloc_context3(m_pAVCodec);
- CheckPointer (m_pAVCtx, E_POINTER);
-
- int nThreadNumber = m_nThreadNumber ? m_nThreadNumber : m_pCpuId->GetProcessorNumber() * 3 / 2;
- if ((nThreadNumber > 1) && IsMultiThreadSupported (m_nCodecId)) {
- FFSetThreadNumber(m_pAVCtx, m_nCodecId, (IsDXVASupported() || (m_nCodecId == CODEC_ID_THEORA && !m_bTheoraMTSupport)) ? 1 : nThreadNumber);
- }
-
- m_pFrame = avcodec_alloc_frame();
- CheckPointer (m_pFrame, E_POINTER);
-
- m_h264RandomAccess.flush(m_pAVCtx->thread_count);
-
- if (pmt->formattype == FORMAT_VideoInfo) {
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
- m_pAVCtx->width = vih->bmiHeader.biWidth;
- m_pAVCtx->height = abs(vih->bmiHeader.biHeight);
- m_pAVCtx->codec_tag = vih->bmiHeader.biCompression;
- m_pAVCtx->bits_per_coded_sample = vih->bmiHeader.biBitCount;
- } else if (pmt->formattype == FORMAT_VideoInfo2) {
- VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)pmt->pbFormat;
- m_pAVCtx->width = vih2->bmiHeader.biWidth;
- m_pAVCtx->height = abs(vih2->bmiHeader.biHeight);
- m_pAVCtx->codec_tag = vih2->bmiHeader.biCompression;
- m_pAVCtx->bits_per_coded_sample = vih2->bmiHeader.biBitCount;
- } else if (pmt->formattype == FORMAT_MPEGVideo) {
- MPEG1VIDEOINFO* mpgv = (MPEG1VIDEOINFO*)pmt->pbFormat;
- m_pAVCtx->width = mpgv->hdr.bmiHeader.biWidth;
- m_pAVCtx->height = abs(mpgv->hdr.bmiHeader.biHeight);
- m_pAVCtx->codec_tag = mpgv->hdr.bmiHeader.biCompression;
- m_pAVCtx->bits_per_coded_sample = mpgv->hdr.bmiHeader.biBitCount;
- } else if (pmt->formattype == FORMAT_MPEG2Video) {
- MPEG2VIDEOINFO* mpg2v = (MPEG2VIDEOINFO*)pmt->pbFormat;
- m_pAVCtx->width = mpg2v->hdr.bmiHeader.biWidth;
- m_pAVCtx->height = abs(mpg2v->hdr.bmiHeader.biHeight);
- m_pAVCtx->codec_tag = mpg2v->hdr.bmiHeader.biCompression;
- m_pAVCtx->bits_per_coded_sample = mpg2v->hdr.bmiHeader.biBitCount;
-
- if (mpg2v->hdr.bmiHeader.biCompression == NULL) {
- m_pAVCtx->codec_tag = pmt->subtype.Data1;
- } else if ( (m_pAVCtx->codec_tag == MAKEFOURCC('a','v','c','1')) || (m_pAVCtx->codec_tag == MAKEFOURCC('A','V','C','1'))) {
- m_pAVCtx->nal_length_size = mpg2v->dwFlags;
- m_bReorderBFrame = (GetFileExtension() == _T(".avi")) ? true : false;
- } else if ( (m_pAVCtx->codec_tag == MAKEFOURCC('m','p','4','v')) || (m_pAVCtx->codec_tag == MAKEFOURCC('M','P','4','V'))) {
- m_bReorderBFrame = false;
- }
- } else {
- return VFW_E_INVALIDMEDIATYPE;
- }
- m_nWidth = m_pAVCtx->width;
- m_nHeight = m_pAVCtx->height;
-
- if (m_pAVCtx->codec_tag == MAKEFOURCC('m','p','g','2')) {
- m_pAVCtx->codec_tag = MAKEFOURCC('M','P','E','G');
- }
-
- if (m_nCodecId == CODEC_ID_RV10 || m_nCodecId == CODEC_ID_RV20 || m_nCodecId == CODEC_ID_RV30 || m_nCodecId == CODEC_ID_RV40) {
- m_bReorderBFrame = false;
- }
-
- m_pAVCtx->codec_id = m_nCodecId;
- m_pAVCtx->workaround_bugs = m_nWorkaroundBug;
- m_pAVCtx->error_concealment = m_nErrorConcealment;
- m_pAVCtx->err_recognition = m_nErrorRecognition;
- m_pAVCtx->idct_algo = m_nIDCTAlgo;
- m_pAVCtx->skip_loop_filter = (AVDiscard)m_nDiscardMode;
- m_pAVCtx->dsp_mask = AV_CPU_FLAG_FORCE | m_pCpuId->GetFeatures();
-
- m_pAVCtx->debug_mv = 0;
-
- m_pAVCtx->opaque = this;
- m_pAVCtx->get_buffer = get_buffer;
-
- if (m_nCodecId == CODEC_ID_H264) {
- m_pAVCtx->flags2 |= CODEC_FLAG2_SHOW_ALL;
- }
-
- AllocExtradata (m_pAVCtx, pmt);
- ConnectTo (m_pAVCtx);
- CalcAvgTimePerFrame();
-
- if (avcodec_open2(m_pAVCtx, m_pAVCodec, NULL)<0) {
- return VFW_E_INVALIDMEDIATYPE;
- }
-
- // if DXVA is supported in theory the file can still be incompatible
- bool bDXVAAvailableButUnused = IsDXVASupported();
- if (IsDXVASupported()) {
- do {
- m_bDXVACompatible = false;
-
- if (!DXVACheckFramesize(PictWidth(), PictHeight(), m_nPCIVendor)) { // check frame size
- break;
- }
-
- if (m_nCodecId == CODEC_ID_H264) {
- if (m_nDXVA_SD && PictWidthRounded() < 1280) { // check "Disable DXVA for SD" option
- break;
- }
- int nCompat = FFH264CheckCompatibility (PictWidthRounded(), PictHeightRounded(), m_pAVCtx, (BYTE*)m_pAVCtx->extradata, m_pAVCtx->extradata_size, m_nPCIVendor, m_nPCIDevice, m_VideoDriverVersion);
- if (nCompat) {
- if ( nCompat == DXVA_HIGH_BIT ||
- m_nDXVACheckCompatibility == 0 || // full check
- m_nDXVACheckCompatibility == 1 && nCompat != DXVA_UNSUPPORTED_LEVEL || // skip level check
- m_nDXVACheckCompatibility == 2 && nCompat != DXVA_TOO_MANY_REF_FRAMES) { // skip reference frame check
- break;
- }
- }
- } else if (m_nCodecId == CODEC_ID_MPEG2VIDEO) {
- // DSP is disable for DXVA decoding (to keep default idct_permutation)
- m_pAVCtx->dsp_mask ^= AV_CPU_FLAG_FORCE;
- if (!MPEG2CheckCompatibility(m_pAVCtx, m_pFrame)) {
- break;
- }
- }
-
- m_bDXVACompatible = true;
- bDXVAAvailableButUnused = false;
- } while (false);
- }
-
- if (bDXVAAvailableButUnused) { // reset the threads count
- m_bUseDXVA = false;
- avcodec_close (m_pAVCtx);
- if ((nThreadNumber > 1) && IsMultiThreadSupported (m_nCodecId)) {
- FFSetThreadNumber(m_pAVCtx, m_nCodecId, nThreadNumber);
- }
- if (avcodec_open2(m_pAVCtx, m_pAVCodec, NULL)<0) {
- return VFW_E_INVALIDMEDIATYPE;
- }
- }
-
- BuildDXVAOutputFormat();
- }
- }
-
- return __super::SetMediaType(direction, pmt);
+ CString ext = _T("");
+
+ BeginEnumFilters(m_pGraph, pEF, pBF) {
+ CComQIPtr<IFileSourceFilter> pFSF = pBF;
+ if (pFSF) {
+ LPOLESTR pFN = NULL;
+ AM_MEDIA_TYPE mt;
+ if (SUCCEEDED(pFSF->GetCurFile(&pFN, &mt)) && pFN && *pFN) {
+ ext = CPath(CStringW(pFN)).GetExtension();
+ ext.MakeLower();
+ CoTaskMemFree(pFN);
+ }
+ break;
+ }
+ }
+ EndEnumFilters
+
+ return ext;
+}
+
+HRESULT CMPCVideoDecFilter::SetMediaType(PIN_DIRECTION direction, const CMediaType* pmt)
+{
+ if (direction == PINDIR_INPUT) {
+
+ int nNewCodec = FindCodec(pmt);
+
+ if (nNewCodec == -1) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+
+ if (nNewCodec != m_nCodecNb) {
+ m_nCodecNb = nNewCodec;
+ m_nCodecId = ffCodecs[nNewCodec].nFFCodec;
+
+ CLSID ClsidSourceFilter = GetCLSID(m_pInput->GetConnected());
+ if ((ClsidSourceFilter == __uuidof(COggSourceFilter)) || (ClsidSourceFilter == __uuidof(COggSplitterFilter))) {
+ m_bTheoraMTSupport = false;
+ } else if ((ClsidSourceFilter == __uuidof(CMpegSourceFilter)) || (ClsidSourceFilter == __uuidof(CMpegSplitterFilter))) {
+ if (CComPtr<IBaseFilter> pFilter = GetFilterFromPin(m_pInput->GetConnected())) {
+ if (CComQIPtr<IMpegSplitterFilter> MpegSplitterFilter = pFilter) {
+ m_bIsEVO = (m_nCodecId == CODEC_ID_VC1 && mpeg_ps == MpegSplitterFilter->GetMPEGType());
+ }
+ }
+ }
+
+ m_bReorderBFrame = true;
+ m_pAVCodec = avcodec_find_decoder(m_nCodecId);
+ CheckPointer(m_pAVCodec, VFW_E_UNSUPPORTED_VIDEO);
+
+ m_pAVCtx = avcodec_alloc_context3(m_pAVCodec);
+ CheckPointer(m_pAVCtx, E_POINTER);
+
+ int nThreadNumber = m_nThreadNumber ? m_nThreadNumber : m_pCpuId->GetProcessorNumber() * 3 / 2;
+ if ((nThreadNumber > 1) && IsMultiThreadSupported(m_nCodecId)) {
+ FFSetThreadNumber(m_pAVCtx, m_nCodecId, (IsDXVASupported() || (m_nCodecId == CODEC_ID_THEORA && !m_bTheoraMTSupport)) ? 1 : nThreadNumber);
+ }
+
+ m_pFrame = avcodec_alloc_frame();
+ CheckPointer(m_pFrame, E_POINTER);
+
+ m_h264RandomAccess.flush(m_pAVCtx->thread_count);
+
+ if (pmt->formattype == FORMAT_VideoInfo) {
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
+ m_pAVCtx->width = vih->bmiHeader.biWidth;
+ m_pAVCtx->height = abs(vih->bmiHeader.biHeight);
+ m_pAVCtx->codec_tag = vih->bmiHeader.biCompression;
+ m_pAVCtx->bits_per_coded_sample = vih->bmiHeader.biBitCount;
+ } else if (pmt->formattype == FORMAT_VideoInfo2) {
+ VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)pmt->pbFormat;
+ m_pAVCtx->width = vih2->bmiHeader.biWidth;
+ m_pAVCtx->height = abs(vih2->bmiHeader.biHeight);
+ m_pAVCtx->codec_tag = vih2->bmiHeader.biCompression;
+ m_pAVCtx->bits_per_coded_sample = vih2->bmiHeader.biBitCount;
+ } else if (pmt->formattype == FORMAT_MPEGVideo) {
+ MPEG1VIDEOINFO* mpgv = (MPEG1VIDEOINFO*)pmt->pbFormat;
+ m_pAVCtx->width = mpgv->hdr.bmiHeader.biWidth;
+ m_pAVCtx->height = abs(mpgv->hdr.bmiHeader.biHeight);
+ m_pAVCtx->codec_tag = mpgv->hdr.bmiHeader.biCompression;
+ m_pAVCtx->bits_per_coded_sample = mpgv->hdr.bmiHeader.biBitCount;
+ } else if (pmt->formattype == FORMAT_MPEG2Video) {
+ MPEG2VIDEOINFO* mpg2v = (MPEG2VIDEOINFO*)pmt->pbFormat;
+ m_pAVCtx->width = mpg2v->hdr.bmiHeader.biWidth;
+ m_pAVCtx->height = abs(mpg2v->hdr.bmiHeader.biHeight);
+ m_pAVCtx->codec_tag = mpg2v->hdr.bmiHeader.biCompression;
+ m_pAVCtx->bits_per_coded_sample = mpg2v->hdr.bmiHeader.biBitCount;
+
+ if (mpg2v->hdr.bmiHeader.biCompression == NULL) {
+ m_pAVCtx->codec_tag = pmt->subtype.Data1;
+ } else if ((m_pAVCtx->codec_tag == MAKEFOURCC('a', 'v', 'c', '1')) || (m_pAVCtx->codec_tag == MAKEFOURCC('A', 'V', 'C', '1'))) {
+ m_pAVCtx->nal_length_size = mpg2v->dwFlags;
+ m_bReorderBFrame = (GetFileExtension() == _T(".avi")) ? true : false;
+ } else if ((m_pAVCtx->codec_tag == MAKEFOURCC('m', 'p', '4', 'v')) || (m_pAVCtx->codec_tag == MAKEFOURCC('M', 'P', '4', 'V'))) {
+ m_bReorderBFrame = false;
+ }
+ } else {
+ return VFW_E_INVALIDMEDIATYPE;
+ }
+ m_nWidth = m_pAVCtx->width;
+ m_nHeight = m_pAVCtx->height;
+
+ if (m_pAVCtx->codec_tag == MAKEFOURCC('m', 'p', 'g', '2')) {
+ m_pAVCtx->codec_tag = MAKEFOURCC('M', 'P', 'E', 'G');
+ }
+
+ if (m_nCodecId == CODEC_ID_RV10 || m_nCodecId == CODEC_ID_RV20 || m_nCodecId == CODEC_ID_RV30 || m_nCodecId == CODEC_ID_RV40) {
+ m_bReorderBFrame = false;
+ }
+
+ m_pAVCtx->codec_id = m_nCodecId;
+ m_pAVCtx->workaround_bugs = m_nWorkaroundBug;
+ m_pAVCtx->error_concealment = m_nErrorConcealment;
+ m_pAVCtx->err_recognition = m_nErrorRecognition;
+ m_pAVCtx->idct_algo = m_nIDCTAlgo;
+ m_pAVCtx->skip_loop_filter = (AVDiscard)m_nDiscardMode;
+ m_pAVCtx->dsp_mask = AV_CPU_FLAG_FORCE | m_pCpuId->GetFeatures();
+
+ m_pAVCtx->debug_mv = 0;
+
+ m_pAVCtx->opaque = this;
+ m_pAVCtx->get_buffer = get_buffer;
+
+ if (m_nCodecId == CODEC_ID_H264) {
+ m_pAVCtx->flags2 |= CODEC_FLAG2_SHOW_ALL;
+ }
+
+ AllocExtradata(m_pAVCtx, pmt);
+ ConnectTo(m_pAVCtx);
+ CalcAvgTimePerFrame();
+
+ if (avcodec_open2(m_pAVCtx, m_pAVCodec, NULL) < 0) {
+ return VFW_E_INVALIDMEDIATYPE;
+ }
+
+ // if DXVA is supported in theory the file can still be incompatible
+ bool bDXVAAvailableButUnused = IsDXVASupported();
+ if (IsDXVASupported()) {
+ do {
+ m_bDXVACompatible = false;
+
+ if (!DXVACheckFramesize(PictWidth(), PictHeight(), m_nPCIVendor)) { // check frame size
+ break;
+ }
+
+ if (m_nCodecId == CODEC_ID_H264) {
+ if (m_nDXVA_SD && PictWidthRounded() < 1280) { // check "Disable DXVA for SD" option
+ break;
+ }
+ int nCompat = FFH264CheckCompatibility(PictWidthRounded(), PictHeightRounded(), m_pAVCtx, (BYTE*)m_pAVCtx->extradata, m_pAVCtx->extradata_size, m_nPCIVendor, m_nPCIDevice, m_VideoDriverVersion);
+ if (nCompat) {
+ if (nCompat == DXVA_HIGH_BIT ||
+ m_nDXVACheckCompatibility == 0 || // full check
+ m_nDXVACheckCompatibility == 1 && nCompat != DXVA_UNSUPPORTED_LEVEL || // skip level check
+ m_nDXVACheckCompatibility == 2 && nCompat != DXVA_TOO_MANY_REF_FRAMES) { // skip reference frame check
+ break;
+ }
+ }
+ } else if (m_nCodecId == CODEC_ID_MPEG2VIDEO) {
+ // DSP is disable for DXVA decoding (to keep default idct_permutation)
+ m_pAVCtx->dsp_mask ^= AV_CPU_FLAG_FORCE;
+ if (!MPEG2CheckCompatibility(m_pAVCtx, m_pFrame)) {
+ break;
+ }
+ }
+
+ m_bDXVACompatible = true;
+ bDXVAAvailableButUnused = false;
+ } while (false);
+ }
+
+ if (bDXVAAvailableButUnused) { // reset the threads count
+ m_bUseDXVA = false;
+ avcodec_close(m_pAVCtx);
+ if ((nThreadNumber > 1) && IsMultiThreadSupported(m_nCodecId)) {
+ FFSetThreadNumber(m_pAVCtx, m_nCodecId, nThreadNumber);
+ }
+ if (avcodec_open2(m_pAVCtx, m_pAVCodec, NULL) < 0) {
+ return VFW_E_INVALIDMEDIATYPE;
+ }
+ }
+
+ BuildDXVAOutputFormat();
+ }
+ }
+
+ return __super::SetMediaType(direction, pmt);
}
VIDEO_OUTPUT_FORMATS DXVAFormats[] = { // DXVA2
- {&MEDIASUBTYPE_NV12, 1, 12, 'avxd'},
- {&MEDIASUBTYPE_NV12, 1, 12, 'AVXD'},
- {&MEDIASUBTYPE_NV12, 1, 12, 'AVxD'},
- {&MEDIASUBTYPE_NV12, 1, 12, 'AvXD'}
+ {&MEDIASUBTYPE_NV12, 1, 12, 'avxd'},
+ {&MEDIASUBTYPE_NV12, 1, 12, 'AVXD'},
+ {&MEDIASUBTYPE_NV12, 1, 12, 'AVxD'},
+ {&MEDIASUBTYPE_NV12, 1, 12, 'AvXD'}
};
VIDEO_OUTPUT_FORMATS SoftwareFormats1[] = { // Software
- {&MEDIASUBTYPE_NV12, 2, 12, '21VN'},
- {&MEDIASUBTYPE_YV12, 3, 12, '21VY'},
- {&MEDIASUBTYPE_YUY2, 1, 16, '2YUY'},
+ {&MEDIASUBTYPE_NV12, 2, 12, '21VN'},
+ {&MEDIASUBTYPE_YV12, 3, 12, '21VY'},
+ {&MEDIASUBTYPE_YUY2, 1, 16, '2YUY'},
};
VIDEO_OUTPUT_FORMATS SoftwareFormats2[] = { // Software
- {&MEDIASUBTYPE_RGB32, 1, 32, BI_RGB},
+ {&MEDIASUBTYPE_RGB32, 1, 32, BI_RGB},
};
bool CMPCVideoDecFilter::IsDXVASupported()
{
- if (m_nCodecNb != -1) {
- // Does the codec suppport DXVA ?
- if (ffCodecs[m_nCodecNb].DXVAModes != NULL) {
- // Enabled by user ?
- if (m_bUseDXVA) {
- // is the file compatible ?
- if (m_bDXVACompatible) {
- return true;
- }
- }
- }
- }
- return false;
+ if (m_nCodecNb != -1) {
+ // Does the codec suppport DXVA ?
+ if (ffCodecs[m_nCodecNb].DXVAModes != NULL) {
+ // Enabled by user ?
+ if (m_bUseDXVA) {
+ // is the file compatible ?
+ if (m_bDXVACompatible) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
}
void CMPCVideoDecFilter::BuildDXVAOutputFormat()
{
- SAFE_DELETE_ARRAY (m_pVideoOutputFormat);
-
- m_nVideoOutputCount = IsDXVASupported() ? ffCodecs[m_nCodecNb].DXVAModeCount() + _countof (DXVAFormats) : 0;
- if (m_bUseFFmpeg) {
- if (!(m_pAVCtx->width&1 || m_pAVCtx->height&1)) { // Do not use NV12, YV12 and YUY2 if width or height is not even
- m_nVideoOutputCount += _countof(SoftwareFormats1);
- }
- m_nVideoOutputCount += _countof(SoftwareFormats2);
- }
- m_pVideoOutputFormat = DNew VIDEO_OUTPUT_FORMATS[m_nVideoOutputCount];
-
- int nPos = 0;
- if (IsDXVASupported()) {
- // Dynamic DXVA media types for DXVA1
- for (nPos=0; nPos<ffCodecs[m_nCodecNb].DXVAModeCount(); nPos++) {
- m_pVideoOutputFormat[nPos].subtype = ffCodecs[m_nCodecNb].DXVAModes->Decoder[nPos];
- m_pVideoOutputFormat[nPos].biCompression = 'avxd';
- m_pVideoOutputFormat[nPos].biBitCount = 12;
- m_pVideoOutputFormat[nPos].biPlanes = 1;
- }
-
- // Static list for DXVA2
- memcpy (&m_pVideoOutputFormat[nPos], DXVAFormats, sizeof(DXVAFormats));
- nPos += _countof (DXVAFormats);
- }
- // Software rendering
- if (m_bUseFFmpeg) {
- if (!(m_pAVCtx->width&1 || m_pAVCtx->height&1)) { // Do not use NV12, YV12 and YUY2 if width or height is not even
- memcpy (&m_pVideoOutputFormat[nPos], SoftwareFormats1, sizeof(SoftwareFormats1));
- nPos += _countof (SoftwareFormats1);
- }
- memcpy (&m_pVideoOutputFormat[nPos], SoftwareFormats2, sizeof(SoftwareFormats2));
- }
+ SAFE_DELETE_ARRAY(m_pVideoOutputFormat);
+
+ m_nVideoOutputCount = IsDXVASupported() ? ffCodecs[m_nCodecNb].DXVAModeCount() + _countof(DXVAFormats) : 0;
+ if (m_bUseFFmpeg) {
+ if (!(m_pAVCtx->width & 1 || m_pAVCtx->height & 1)) { // Do not use NV12, YV12 and YUY2 if width or height is not even
+ m_nVideoOutputCount += _countof(SoftwareFormats1);
+ }
+ m_nVideoOutputCount += _countof(SoftwareFormats2);
+ }
+ m_pVideoOutputFormat = DNew VIDEO_OUTPUT_FORMATS[m_nVideoOutputCount];
+
+ int nPos = 0;
+ if (IsDXVASupported()) {
+ // Dynamic DXVA media types for DXVA1
+ for (nPos = 0; nPos < ffCodecs[m_nCodecNb].DXVAModeCount(); nPos++) {
+ m_pVideoOutputFormat[nPos].subtype = ffCodecs[m_nCodecNb].DXVAModes->Decoder[nPos];
+ m_pVideoOutputFormat[nPos].biCompression = 'avxd';
+ m_pVideoOutputFormat[nPos].biBitCount = 12;
+ m_pVideoOutputFormat[nPos].biPlanes = 1;
+ }
+
+ // Static list for DXVA2
+ memcpy(&m_pVideoOutputFormat[nPos], DXVAFormats, sizeof(DXVAFormats));
+ nPos += _countof(DXVAFormats);
+ }
+ // Software rendering
+ if (m_bUseFFmpeg) {
+ if (!(m_pAVCtx->width & 1 || m_pAVCtx->height & 1)) { // Do not use NV12, YV12 and YUY2 if width or height is not even
+ memcpy(&m_pVideoOutputFormat[nPos], SoftwareFormats1, sizeof(SoftwareFormats1));
+ nPos += _countof(SoftwareFormats1);
+ }
+ memcpy(&m_pVideoOutputFormat[nPos], SoftwareFormats2, sizeof(SoftwareFormats2));
+ }
}
int CMPCVideoDecFilter::GetPicEntryNumber()
{
- if (IsDXVASupported()) {
- return ffCodecs[m_nCodecNb].DXVAModes->PicEntryNumber;
- } else {
- return 0;
- }
+ if (IsDXVASupported()) {
+ return ffCodecs[m_nCodecNb].DXVAModes->PicEntryNumber;
+ } else {
+ return 0;
+ }
}
-void CMPCVideoDecFilter::GetOutputFormats (int& nNumber, VIDEO_OUTPUT_FORMATS** ppFormats)
+void CMPCVideoDecFilter::GetOutputFormats(int& nNumber, VIDEO_OUTPUT_FORMATS** ppFormats)
{
- nNumber = m_nVideoOutputCount;
- *ppFormats = m_pVideoOutputFormat;
+ nNumber = m_nVideoOutputCount;
+ *ppFormats = m_pVideoOutputFormat;
}
void CMPCVideoDecFilter::AllocExtradata(AVCodecContext* pAVCtx, const CMediaType* pmt)
{
- // code from LAV ...
- // Process Extradata
- BYTE *extra = NULL;
- unsigned int extralen = 0;
- getExtraData((const BYTE *)pmt->Format(), pmt->FormatType(), pmt->FormatLength(), NULL, &extralen);
-
- BOOL bH264avc = FALSE;
- if (extralen > 0) {
- TRACE(_T("CMPCVideoDecFilter::AllocExtradata() : processing extradata of %d bytes"), extralen);
- // Reconstruct AVC1 extradata format
- if (pmt->formattype == FORMAT_MPEG2Video && (m_pAVCtx->codec_tag == MAKEFOURCC('a','v','c','1') || m_pAVCtx->codec_tag == MAKEFOURCC('A','V','C','1') || m_pAVCtx->codec_tag == MAKEFOURCC('C','C','V','1'))) {
- MPEG2VIDEOINFO *mp2vi = (MPEG2VIDEOINFO *)pmt->Format();
- extralen += 7;
- extra = (uint8_t *)av_mallocz(extralen + FF_INPUT_BUFFER_PADDING_SIZE);
- extra[0] = 1;
- extra[1] = (BYTE)mp2vi->dwProfile;
- extra[2] = 0;
- extra[3] = (BYTE)mp2vi->dwLevel;
- extra[4] = (BYTE)(mp2vi->dwFlags ? mp2vi->dwFlags : 2) - 1;
-
- // Actually copy the metadata into our new buffer
- unsigned int actual_len;
- getExtraData((const BYTE *)pmt->Format(), pmt->FormatType(), pmt->FormatLength(), extra+6, &actual_len);
-
- // Count the number of SPS/PPS in them and set the length
- // We'll put them all into one block and add a second block with 0 elements afterwards
- // The parsing logic does not care what type they are, it just expects 2 blocks.
- BYTE *p = extra+6, *end = extra+6+actual_len;
- BOOL bSPS = FALSE, bPPS = FALSE;
- int count = 0;
- while (p+1 < end) {
- unsigned len = (((unsigned)p[0] << 8) | p[1]) + 2;
- if (p + len > end) {
- break;
- }
- if ((p[2] & 0x1F) == 7)
- bSPS = TRUE;
- if ((p[2] & 0x1F) == 8)
- bPPS = TRUE;
- count++;
- p += len;
- }
- extra[5] = count;
- extra[extralen-1] = 0;
-
- bH264avc = TRUE;
- if (!bSPS) {
- TRACE(_T("CMPCVideoDecFilter::AllocExtradata() : AVC1 extradata doesn't contain a SPS, setting thread_count = 1"));
- m_pAVCtx->thread_count = 1;
- }
- } else {
- // Just copy extradata for other formats
- extra = (uint8_t *)av_mallocz(extralen + FF_INPUT_BUFFER_PADDING_SIZE);
- getExtraData((const BYTE *)pmt->Format(), pmt->FormatType(), pmt->FormatLength(), extra, NULL);
- }
- // Hack to discard invalid MP4 metadata with AnnexB style video
- if (m_nCodecId == CODEC_ID_H264 && !bH264avc && extra[0] == 1) {
- av_freep(&extra);
- extralen = 0;
- }
- m_pAVCtx->extradata = extra;
- m_pAVCtx->extradata_size = (int)extralen;
- }
+ // code from LAV ...
+ // Process Extradata
+ BYTE* extra = NULL;
+ unsigned int extralen = 0;
+ getExtraData((const BYTE*)pmt->Format(), pmt->FormatType(), pmt->FormatLength(), NULL, &extralen);
+
+ BOOL bH264avc = FALSE;
+ if (extralen > 0) {
+ TRACE(_T("CMPCVideoDecFilter::AllocExtradata() : processing extradata of %d bytes"), extralen);
+ // Reconstruct AVC1 extradata format
+ if (pmt->formattype == FORMAT_MPEG2Video && (m_pAVCtx->codec_tag == MAKEFOURCC('a', 'v', 'c', '1') || m_pAVCtx->codec_tag == MAKEFOURCC('A', 'V', 'C', '1') || m_pAVCtx->codec_tag == MAKEFOURCC('C', 'C', 'V', '1'))) {
+ MPEG2VIDEOINFO* mp2vi = (MPEG2VIDEOINFO*)pmt->Format();
+ extralen += 7;
+ extra = (uint8_t*)av_mallocz(extralen + FF_INPUT_BUFFER_PADDING_SIZE);
+ extra[0] = 1;
+ extra[1] = (BYTE)mp2vi->dwProfile;
+ extra[2] = 0;
+ extra[3] = (BYTE)mp2vi->dwLevel;
+ extra[4] = (BYTE)(mp2vi->dwFlags ? mp2vi->dwFlags : 2) - 1;
+
+ // Actually copy the metadata into our new buffer
+ unsigned int actual_len;
+ getExtraData((const BYTE*)pmt->Format(), pmt->FormatType(), pmt->FormatLength(), extra + 6, &actual_len);
+
+ // Count the number of SPS/PPS in them and set the length
+ // We'll put them all into one block and add a second block with 0 elements afterwards
+ // The parsing logic does not care what type they are, it just expects 2 blocks.
+ BYTE* p = extra + 6, *end = extra + 6 + actual_len;
+ BOOL bSPS = FALSE, bPPS = FALSE;
+ int count = 0;
+ while (p + 1 < end) {
+ unsigned len = (((unsigned)p[0] << 8) | p[1]) + 2;
+ if (p + len > end) {
+ break;
+ }
+ if ((p[2] & 0x1F) == 7) {
+ bSPS = TRUE;
+ }
+ if ((p[2] & 0x1F) == 8) {
+ bPPS = TRUE;
+ }
+ count++;
+ p += len;
+ }
+ extra[5] = count;
+ extra[extralen - 1] = 0;
+
+ bH264avc = TRUE;
+ if (!bSPS) {
+ TRACE(_T("CMPCVideoDecFilter::AllocExtradata() : AVC1 extradata doesn't contain a SPS, setting thread_count = 1"));
+ m_pAVCtx->thread_count = 1;
+ }
+ } else {
+ // Just copy extradata for other formats
+ extra = (uint8_t*)av_mallocz(extralen + FF_INPUT_BUFFER_PADDING_SIZE);
+ getExtraData((const BYTE*)pmt->Format(), pmt->FormatType(), pmt->FormatLength(), extra, NULL);
+ }
+ // Hack to discard invalid MP4 metadata with AnnexB style video
+ if (m_nCodecId == CODEC_ID_H264 && !bH264avc && extra[0] == 1) {
+ av_freep(&extra);
+ extralen = 0;
+ }
+ m_pAVCtx->extradata = extra;
+ m_pAVCtx->extradata_size = (int)extralen;
+ }
}
HRESULT CMPCVideoDecFilter::CompleteConnect(PIN_DIRECTION direction, IPin* pReceivePin)
{
- LOG(_T("CMPCVideoDecFilter::CompleteConnect"));
+ LOG(_T("CMPCVideoDecFilter::CompleteConnect"));
- if (direction==PINDIR_INPUT && m_pOutput->IsConnected()) {
- ReconnectOutput (m_nWidth, m_nHeight);
- } else if (direction==PINDIR_OUTPUT) {
- if (IsDXVASupported()) {
- if (m_nDXVAMode == MODE_DXVA1) {
- m_pDXVADecoder->ConfigureDXVA1();
- } else if (SUCCEEDED (ConfigureDXVA2 (pReceivePin)) && SUCCEEDED (SetEVRForDXVA2 (pReceivePin)) ) {
- m_nDXVAMode = MODE_DXVA2;
- }
- }
- if (m_nDXVAMode == MODE_SOFTWARE && (!m_bUseFFmpeg || !FFSoftwareCheckCompatibility(m_pAVCtx))) {
- return VFW_E_INVALIDMEDIATYPE;
- }
+ if (direction == PINDIR_INPUT && m_pOutput->IsConnected()) {
+ ReconnectOutput(m_nWidth, m_nHeight);
+ } else if (direction == PINDIR_OUTPUT) {
+ if (IsDXVASupported()) {
+ if (m_nDXVAMode == MODE_DXVA1) {
+ m_pDXVADecoder->ConfigureDXVA1();
+ } else if (SUCCEEDED(ConfigureDXVA2(pReceivePin)) && SUCCEEDED(SetEVRForDXVA2(pReceivePin))) {
+ m_nDXVAMode = MODE_DXVA2;
+ }
+ }
+ if (m_nDXVAMode == MODE_SOFTWARE && (!m_bUseFFmpeg || !FFSoftwareCheckCompatibility(m_pAVCtx))) {
+ return VFW_E_INVALIDMEDIATYPE;
+ }
- CLSID ClsidSourceFilter = GetCLSID(m_pInput->GetConnected());
- if ((ClsidSourceFilter == __uuidof(CMpegSourceFilter)) || (ClsidSourceFilter == __uuidof(CMpegSplitterFilter))) {
- m_bReorderBFrame = false;
- }
- }
+ CLSID ClsidSourceFilter = GetCLSID(m_pInput->GetConnected());
+ if ((ClsidSourceFilter == __uuidof(CMpegSourceFilter)) || (ClsidSourceFilter == __uuidof(CMpegSplitterFilter))) {
+ m_bReorderBFrame = false;
+ }
+ }
- return __super::CompleteConnect (direction, pReceivePin);
+ return __super::CompleteConnect(direction, pReceivePin);
}
HRESULT CMPCVideoDecFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if (UseDXVA2()) {
- HRESULT hr;
- ALLOCATOR_PROPERTIES Actual;
+ if (UseDXVA2()) {
+ HRESULT hr;
+ ALLOCATOR_PROPERTIES Actual;
- if (m_pInput->IsConnected() == FALSE) {
- return E_UNEXPECTED;
- }
+ if (m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
- pProperties->cBuffers = GetPicEntryNumber();
+ pProperties->cBuffers = GetPicEntryNumber();
- if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
- return hr;
- }
+ if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
- return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
- ? E_FAIL
- : NOERROR;
- } else {
- return __super::DecideBufferSize (pAllocator, pProperties);
- }
+ return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
+ ? E_FAIL
+ : NOERROR;
+ } else {
+ return __super::DecideBufferSize(pAllocator, pProperties);
+ }
}
HRESULT CMPCVideoDecFilter::BeginFlush()
{
- return __super::BeginFlush();
+ return __super::BeginFlush();
}
HRESULT CMPCVideoDecFilter::EndFlush()
{
- CAutoLock cAutoLock(&m_csReceive);
- return __super::EndFlush();
+ CAutoLock cAutoLock(&m_csReceive);
+ return __super::EndFlush();
}
HRESULT CMPCVideoDecFilter::NewSegment(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, double dRate)
{
- CAutoLock cAutoLock(&m_csReceive);
+ CAutoLock cAutoLock(&m_csReceive);
- if (m_pAVCtx) {
- avcodec_flush_buffers (m_pAVCtx);
- }
+ if (m_pAVCtx) {
+ avcodec_flush_buffers(m_pAVCtx);
+ }
- if (m_pDXVADecoder) {
- m_pDXVADecoder->Flush();
- }
+ if (m_pDXVADecoder) {
+ m_pDXVADecoder->Flush();
+ }
- m_nPosB = 1;
- memset (&m_BFrames, 0, sizeof(m_BFrames));
- m_rtLastStart = 0;
- m_nCountEstimated = 0;
- m_dRate = dRate;
+ m_nPosB = 1;
+ memset(&m_BFrames, 0, sizeof(m_BFrames));
+ m_rtLastStart = 0;
+ m_nCountEstimated = 0;
+ m_dRate = dRate;
- ResetBuffer();
+ ResetBuffer();
- m_h264RandomAccess.flush (m_pAVCtx->thread_count);
+ m_h264RandomAccess.flush(m_pAVCtx->thread_count);
- m_bWaitingForKeyFrame = TRUE;
+ m_bWaitingForKeyFrame = TRUE;
- m_rtPrevStop = 0;
+ m_rtPrevStop = 0;
- rm.video_after_seek = true;
- m_rtStart = rtStart;
+ rm.video_after_seek = true;
+ m_rtStart = rtStart;
- return __super::NewSegment (rtStart, rtStop, dRate);
+ return __super::NewSegment(rtStart, rtStop, dRate);
}
HRESULT CMPCVideoDecFilter::EndOfStream()
{
- CAutoLock cAutoLock(&m_csReceive);
+ CAutoLock cAutoLock(&m_csReceive);
#if HAS_FFMPEG_VIDEO_DECODERS
- if (m_nDXVAMode == MODE_SOFTWARE) {
- REFERENCE_TIME rtStart = 0, rtStop = 0;
- SoftwareDecode(NULL, NULL, 0, rtStart, rtStop);
- } else
+ if (m_nDXVAMode == MODE_SOFTWARE) {
+ REFERENCE_TIME rtStart = 0, rtStop = 0;
+ SoftwareDecode(NULL, NULL, 0, rtStart, rtStop);
+ } else
#endif
- if (m_nDXVAMode == MODE_DXVA2) { // TODO - need to check DXVA1 on WinXP
- m_pDXVADecoder->EndOfStream();
- }
+ if (m_nDXVAMode == MODE_DXVA2) { // TODO - need to check DXVA1 on WinXP
+ m_pDXVADecoder->EndOfStream();
+ }
- return __super::EndOfStream();
+ return __super::EndOfStream();
}
HRESULT CMPCVideoDecFilter::BreakConnect(PIN_DIRECTION dir)
{
- if (dir == PINDIR_INPUT) {
- Cleanup();
- }
+ if (dir == PINDIR_INPUT) {
+ Cleanup();
+ }
- return __super::BreakConnect (dir);
+ return __super::BreakConnect(dir);
}
void CMPCVideoDecFilter::SetTypeSpecificFlags(IMediaSample* pMS)
{
- if (CComQIPtr<IMediaSample2> pMS2 = pMS) {
- AM_SAMPLE2_PROPERTIES props;
- if (SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props))) {
- props.dwTypeSpecificFlags &= ~0x7f;
-
- m_nFrameType = PICT_BOTTOM_FIELD;
- if (!m_pFrame->interlaced_frame) {
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;
- m_nFrameType = PICT_FRAME;
- } else {
- if (m_pFrame->top_field_first) {
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_FIELD1FIRST;
- m_nFrameType = PICT_TOP_FIELD;
- }
- }
-
- switch (m_pFrame->pict_type) {
- case AV_PICTURE_TYPE_I :
- case AV_PICTURE_TYPE_SI :
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_I_SAMPLE;
- break;
- case AV_PICTURE_TYPE_P :
- case AV_PICTURE_TYPE_SP :
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_P_SAMPLE;
- break;
- default :
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_B_SAMPLE;
- break;
- }
-
- pMS2->SetProperties(sizeof(props), (BYTE*)&props);
- }
- }
+ if (CComQIPtr<IMediaSample2> pMS2 = pMS) {
+ AM_SAMPLE2_PROPERTIES props;
+ if (SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props))) {
+ props.dwTypeSpecificFlags &= ~0x7f;
+
+ m_nFrameType = PICT_BOTTOM_FIELD;
+ if (!m_pFrame->interlaced_frame) {
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;
+ m_nFrameType = PICT_FRAME;
+ } else {
+ if (m_pFrame->top_field_first) {
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_FIELD1FIRST;
+ m_nFrameType = PICT_TOP_FIELD;
+ }
+ }
+
+ switch (m_pFrame->pict_type) {
+ case AV_PICTURE_TYPE_I :
+ case AV_PICTURE_TYPE_SI :
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_I_SAMPLE;
+ break;
+ case AV_PICTURE_TYPE_P :
+ case AV_PICTURE_TYPE_SP :
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_P_SAMPLE;
+ break;
+ default :
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_B_SAMPLE;
+ break;
+ }
+
+ pMS2->SetProperties(sizeof(props), (BYTE*)&props);
+ }
+ }
}
#if HAS_FFMPEG_VIDEO_DECODERS
unsigned __int64 CMPCVideoDecFilter::GetCspFromMediaType(GUID& subtype)
{
- if (subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV || subtype == MEDIASUBTYPE_YV12) {
- return (FF_CSP_420P|FF_CSP_FLAGS_YUV_ADJ);
- } else if (subtype == MEDIASUBTYPE_NV12) {
- return FF_CSP_NV12;
- } else if (subtype == MEDIASUBTYPE_RGB32) {
- return FF_CSP_RGB32;
- } else if (subtype == MEDIASUBTYPE_YUY2) {
- return FF_CSP_YUY2;
- }
+ if (subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV || subtype == MEDIASUBTYPE_YV12) {
+ return (FF_CSP_420P | FF_CSP_FLAGS_YUV_ADJ);
+ } else if (subtype == MEDIASUBTYPE_NV12) {
+ return FF_CSP_NV12;
+ } else if (subtype == MEDIASUBTYPE_RGB32) {
+ return FF_CSP_RGB32;
+ } else if (subtype == MEDIASUBTYPE_YUY2) {
+ return FF_CSP_YUY2;
+ }
- ASSERT (FALSE);
- return FF_CSP_NULL;
+ ASSERT(FALSE);
+ return FF_CSP_NULL;
}
void CMPCVideoDecFilter::InitSwscale()
{
- if (m_pSwsContext == NULL) {
- BITMAPINFOHEADER bihOut;
- ExtractBIH(&m_pOutput->CurrentMediaType(), &bihOut);
-
- int sws_Flags = SWS_BILINEAR | SWS_FULL_CHR_H_INT | SWS_FULL_CHR_H_INP | SWS_ACCURATE_RND;
-
- m_nOutCsp = GetCspFromMediaType(m_pOutput->CurrentMediaType().subtype);
-
- PixelFormat pix_fmt = csp_ffdshow2lavc(csp_lavc2ffdshow(m_pAVCtx->pix_fmt));
- if (pix_fmt == PIX_FMT_NB) {
- pix_fmt = m_pAVCtx->pix_fmt;
- }
-
- m_pSwsContext = sws_getCachedContext(
- NULL,
- m_pAVCtx->width,
- m_pAVCtx->height,
- pix_fmt,
- m_pAVCtx->width,
- m_pAVCtx->height,
- csp_ffdshow2lavc(m_nOutCsp),
- sws_Flags | SWS_PRINT_INFO,
- NULL,
- NULL,
- NULL);
-
- m_nSwOutBpp = bihOut.biBitCount;
- m_pOutSize.cx = bihOut.biWidth;
- m_pOutSize.cy = abs(bihOut.biHeight);
-
- int *inv_tbl = NULL, *tbl = NULL;
- int srcRange, dstRange, brightness, contrast, saturation;
- int ret = sws_getColorspaceDetails(m_pSwsContext, &inv_tbl, &srcRange, &tbl, &dstRange, &brightness, &contrast, &saturation);
- if (ret >= 0) {
- sws_setColorspaceDetails(m_pSwsContext, sws_getCoefficients((PictWidthRounded() > 768) ? SWS_CS_ITU709 : SWS_CS_ITU601), srcRange, tbl, dstRange, brightness, contrast, saturation);
- }
- }
-}
-
-#define RM_SKIP_BITS(n) (buffer<<=n)
-#define RM_SHOW_BITS(n) ((buffer)>>(32-(n)))
-static int rm_fix_timestamp(uint8_t *buf, int64_t timestamp, enum CodecID nCodecId, int64_t *kf_base, int *kf_pts)
-{
- uint8_t *s = buf + 1 + (*buf+1)*8;
- uint32_t buffer = (s[0]<<24) + (s[1]<<16) + (s[2]<<8) + s[3];
- uint32_t kf = timestamp;
- int pict_type;
- uint32_t orig_kf;
-
- if (nCodecId == CODEC_ID_RV30) {
- RM_SKIP_BITS(3);
- pict_type = RM_SHOW_BITS(2);
- RM_SKIP_BITS(2 + 7);
- } else {
- RM_SKIP_BITS(1);
- pict_type = RM_SHOW_BITS(2);
- RM_SKIP_BITS(2 + 7 + 3);
- }
- orig_kf = kf = RM_SHOW_BITS(13); // kf= 2*RM_SHOW_BITS(12);
- if (pict_type <= 1) {
- // I frame, sync timestamps:
- *kf_base = (int64_t)timestamp-kf;
- kf = timestamp;
- } else {
- // P/B frame, merge timestamps:
- int64_t tmp = (int64_t)timestamp - *kf_base;
- kf |= tmp&(~0x1fff); // combine with packet timestamp
- if (kf<tmp-4096) {
- kf += 8192;
- } else if (kf>tmp+4096) { // workaround wrap-around problems
- kf -= 8192;
- }
- kf += *kf_base;
- }
- if (pict_type != 3) { // P || I frame -> swap timestamps
- uint32_t tmp=kf;
- kf = *kf_pts;
- *kf_pts = tmp;
- }
-
- return kf;
-}
-
-static int64_t process_rv_timestamp(RMDemuxContext *rm, enum CodecID nCodecId, uint8_t *buf, int64_t timestamp)
-{
- if (rm->video_after_seek) {
- rm->kf_base = 0;
- rm->kf_pts = timestamp;
- rm->video_after_seek = false;
- }
- return rm_fix_timestamp(buf, timestamp, nCodecId, &rm->kf_base, &rm->kf_pts);
-}
-
-void copyPlane(BYTE *dstp, stride_t dst_pitch, const BYTE *srcp, stride_t src_pitch, int row_size, int height, bool flip = false)
-{
- if (!flip) {
- for (int y=height; y>0; --y) {
- memcpy(dstp, srcp, row_size);
- dstp += dst_pitch;
- srcp += src_pitch;
- }
- } else {
- dstp += dst_pitch * (height - 1);
- for (int y=height; y>0; --y) {
- memcpy(dstp, srcp, row_size);
- dstp -= dst_pitch;
- srcp += src_pitch;
- }
- }
+ if (m_pSwsContext == NULL) {
+ BITMAPINFOHEADER bihOut;
+ ExtractBIH(&m_pOutput->CurrentMediaType(), &bihOut);
+
+ int sws_Flags = SWS_BILINEAR | SWS_FULL_CHR_H_INT | SWS_FULL_CHR_H_INP | SWS_ACCURATE_RND;
+
+ m_nOutCsp = GetCspFromMediaType(m_pOutput->CurrentMediaType().subtype);
+
+ PixelFormat pix_fmt = csp_ffdshow2lavc(csp_lavc2ffdshow(m_pAVCtx->pix_fmt));
+ if (pix_fmt == PIX_FMT_NB) {
+ pix_fmt = m_pAVCtx->pix_fmt;
+ }
+
+ m_pSwsContext = sws_getCachedContext(
+ NULL,
+ m_pAVCtx->width,
+ m_pAVCtx->height,
+ pix_fmt,
+ m_pAVCtx->width,
+ m_pAVCtx->height,
+ csp_ffdshow2lavc(m_nOutCsp),
+ sws_Flags | SWS_PRINT_INFO,
+ NULL,
+ NULL,
+ NULL);
+
+ m_nSwOutBpp = bihOut.biBitCount;
+ m_pOutSize.cx = bihOut.biWidth;
+ m_pOutSize.cy = abs(bihOut.biHeight);
+
+ int* inv_tbl = NULL, *tbl = NULL;
+ int srcRange, dstRange, brightness, contrast, saturation;
+ int ret = sws_getColorspaceDetails(m_pSwsContext, &inv_tbl, &srcRange, &tbl, &dstRange, &brightness, &contrast, &saturation);
+ if (ret >= 0) {
+ sws_setColorspaceDetails(m_pSwsContext, sws_getCoefficients((PictWidthRounded() > 768) ? SWS_CS_ITU709 : SWS_CS_ITU601), srcRange, tbl, dstRange, brightness, contrast, saturation);
+ }
+ }
+}
+
+#define RM_SKIP_BITS(n) (buffer<<=n)
+#define RM_SHOW_BITS(n) ((buffer)>>(32-(n)))
+static int rm_fix_timestamp(uint8_t* buf, int64_t timestamp, enum CodecID nCodecId, int64_t* kf_base, int* kf_pts)
+{
+ uint8_t* s = buf + 1 + (*buf + 1) * 8;
+ uint32_t buffer = (s[0] << 24) + (s[1] << 16) + (s[2] << 8) + s[3];
+ uint32_t kf = timestamp;
+ int pict_type;
+ uint32_t orig_kf;
+
+ if (nCodecId == CODEC_ID_RV30) {
+ RM_SKIP_BITS(3);
+ pict_type = RM_SHOW_BITS(2);
+ RM_SKIP_BITS(2 + 7);
+ } else {
+ RM_SKIP_BITS(1);
+ pict_type = RM_SHOW_BITS(2);
+ RM_SKIP_BITS(2 + 7 + 3);
+ }
+ orig_kf = kf = RM_SHOW_BITS(13); // kf= 2*RM_SHOW_BITS(12);
+ if (pict_type <= 1) {
+ // I frame, sync timestamps:
+ *kf_base = (int64_t)timestamp - kf;
+ kf = timestamp;
+ } else {
+ // P/B frame, merge timestamps:
+ int64_t tmp = (int64_t)timestamp - *kf_base;
+ kf |= tmp & (~0x1fff); // combine with packet timestamp
+ if (kf < tmp - 4096) {
+ kf += 8192;
+ } else if (kf > tmp + 4096) { // workaround wrap-around problems
+ kf -= 8192;
+ }
+ kf += *kf_base;
+ }
+ if (pict_type != 3) { // P || I frame -> swap timestamps
+ uint32_t tmp = kf;
+ kf = *kf_pts;
+ *kf_pts = tmp;
+ }
+
+ return kf;
+}
+
+static int64_t process_rv_timestamp(RMDemuxContext* rm, enum CodecID nCodecId, uint8_t* buf, int64_t timestamp)
+{
+ if (rm->video_after_seek) {
+ rm->kf_base = 0;
+ rm->kf_pts = timestamp;
+ rm->video_after_seek = false;
+ }
+ return rm_fix_timestamp(buf, timestamp, nCodecId, &rm->kf_base, &rm->kf_pts);
+}
+
+void copyPlane(BYTE* dstp, stride_t dst_pitch, const BYTE* srcp, stride_t src_pitch, int row_size, int height, bool flip = false)
+{
+ if (!flip) {
+ for (int y = height; y > 0; --y) {
+ memcpy(dstp, srcp, row_size);
+ dstp += dst_pitch;
+ srcp += src_pitch;
+ }
+ } else {
+ dstp += dst_pitch * (height - 1);
+ for (int y = height; y > 0; --y) {
+ memcpy(dstp, srcp, row_size);
+ dstp -= dst_pitch;
+ srcp += src_pitch;
+ }
+ }
}
#define FFALIGN(x, a) (((x)+(a)-1)&~((a)-1))
HRESULT CMPCVideoDecFilter::SoftwareDecode(IMediaSample* pIn, BYTE* pDataIn, int nSize, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop)
{
- HRESULT hr = S_OK;
- int got_picture;
- int used_bytes;
- BOOL bFlush = (pDataIn == NULL);
-
- AVPacket avpkt;
- av_init_packet(&avpkt);
-
- if (!bFlush && m_nCodecId == CODEC_ID_H264) {
- if (!m_h264RandomAccess.searchRecoveryPoint(m_pAVCtx, pDataIn, nSize)) {
- return S_OK;
- }
- }
-
- while (nSize > 0 || bFlush) {
- if (!bFlush) {
- if (nSize+FF_INPUT_BUFFER_PADDING_SIZE > m_nFFBufferSize) {
- m_nFFBufferSize = nSize+FF_INPUT_BUFFER_PADDING_SIZE;
- m_pFFBuffer = (BYTE*)av_realloc(m_pFFBuffer, m_nFFBufferSize);
- if (!m_pFFBuffer) {
- m_nFFBufferSize = 0;
- return E_FAIL;
- }
- }
-
- // Required number of additionally allocated bytes at the end of the input bitstream for decoding.
- // This is mainly needed because some optimized bitstream readers read
- // 32 or 64 bit at once and could read over the end.
- // Note: If the first 23 bits of the additional bytes are not 0, then damaged
- // MPEG bitstreams could cause overread and segfault.
- memcpy(m_pFFBuffer, pDataIn, nSize);
- memset(m_pFFBuffer+nSize,0,FF_INPUT_BUFFER_PADDING_SIZE);
-
- avpkt.data = m_pFFBuffer;
- avpkt.size = nSize;
- avpkt.pts = rtStart;
- avpkt.dts = rtStop;
- avpkt.flags = AV_PKT_FLAG_KEY;
- } else {
- avpkt.data = NULL;
- avpkt.size = 0;
- }
- used_bytes = avcodec_decode_video2 (m_pAVCtx, m_pFrame, &got_picture, &avpkt);
-
- if (used_bytes < 0) {
- return S_OK;
- }
-
- // Comment from LAV Video code:
- // When Frame Threading, we won't know how much data has been consumed, so it by default eats everything.
- // In addition, if no data got consumed, and no picture was extracted, the frame probably isn't all that useufl.
- // The MJPEB decoder is somewhat buggy and doesn't let us know how much data was consumed really...
- if ((m_pAVCtx->active_thread_type & FF_THREAD_FRAME || (!got_picture && used_bytes == 0)) || m_nCodecId == CODEC_ID_MJPEGB || bFlush) {
- nSize = 0;
- } else {
- nSize -= used_bytes;
- pDataIn += used_bytes;
- }
-
- if (m_nCodecId == CODEC_ID_H264) {
- m_h264RandomAccess.judgeFrameUsability(m_pFrame, &got_picture);
- } else if (m_nCodecId == CODEC_ID_VC1 || m_nCodecId == CODEC_ID_RV30 || m_nCodecId == CODEC_ID_RV40) {
- if (m_bWaitingForKeyFrame && got_picture) {
- if (m_pFrame->key_frame) {
- m_bWaitingForKeyFrame = FALSE;
- } else {
- got_picture = 0;
- }
- }
- }
-
- if (!got_picture || !m_pFrame->data[0]) {
- bFlush = FALSE;
- continue;
- }
-
- if ((pIn && pIn->IsPreroll() == S_OK) || rtStart < 0) {
- return S_OK;
- }
-
- if (!m_bFrame_repeat_pict && m_pFrame->repeat_pict) {
- m_bFrame_repeat_pict = true;
- }
-
- CComPtr<IMediaSample> pOut;
- BYTE* pDataOut = NULL;
-
- UpdateAspectRatio();
- if (FAILED(hr = GetDeliveryBuffer(m_pAVCtx->width, m_pAVCtx->height, &pOut)) || FAILED(hr = pOut->GetPointer(&pDataOut))) {
- return hr;
- }
-
- if (m_nCodecId == CODEC_ID_THEORA || (m_nCodecId == CODEC_ID_VP8 && m_rtAvrTimePerFrame == 10000)) { // need more tests
- rtStart = m_pFrame->pkt_pts;
- rtStop = m_pFrame->pkt_dts;
- } else if ((m_nCodecId == CODEC_ID_RV10 || m_nCodecId == CODEC_ID_RV20) && m_pFrame->pict_type == AV_PICTURE_TYPE_B) {
- rtStart = m_rtPrevStop;
- rtStop = rtStart + m_rtAvrTimePerFrame;
- } else if ((m_nCodecId == CODEC_ID_RV30 || m_nCodecId == CODEC_ID_RV40) && avpkt.data) {
- rtStart = (rtStart == _I64_MIN) ? m_rtPrevStop : (10000i64*process_rv_timestamp(&rm, m_nCodecId, avpkt.data, (rtStart + m_rtStart)/10000) - m_rtStart);
- rtStop = rtStart + m_rtAvrTimePerFrame;
- } else if (!(m_nCodecId == CODEC_ID_VC1 && m_bFrame_repeat_pict && m_rtAvrTimePerFrame == 333666)) {
- rtStart = m_pFrame->reordered_opaque;
- rtStop = m_pFrame->reordered_opaque2;
- }
-
- m_rtPrevStop = rtStop;
-
- ReorderBFrames(rtStart, rtStop);
-
- pOut->SetTime(&rtStart, &rtStop);
- pOut->SetMediaTime(NULL, NULL);
-
- if (m_pSwsContext == NULL) {
- InitSwscale();
- }
- if (m_pSwsContext != NULL) {
-
- int outStride = m_pOutSize.cx;
- BYTE *outData = pDataOut;
-
- // From LAVVideo ...
- // Check if we have proper pixel alignment and the dst memory is actually aligned
- if (FFALIGN(outStride, 16) != outStride || ((uintptr_t)pDataOut % 16u)) {
- outStride = FFALIGN(outStride, 16);
- int requiredSize = (outStride * m_pAVCtx->height * m_nSwOutBpp) << 3;
- if (requiredSize > m_nAlignedFFBufferSize) {
- av_freep(&m_pAlignedFFBuffer);
- m_nAlignedFFBufferSize = requiredSize;
- m_pAlignedFFBuffer = (BYTE*)av_malloc(m_nAlignedFFBufferSize+FF_INPUT_BUFFER_PADDING_SIZE);
- }
- outData = m_pAlignedFFBuffer;
- }
-
- uint8_t* dst[4] = {NULL, NULL, NULL, NULL};
- stride_t dstStride[4] = {0, 0, 0, 0};
- const TcspInfo *outcspInfo=csp_getInfo(m_nOutCsp);
-
- if (m_nOutCsp == FF_CSP_YUY2 || m_nOutCsp == FF_CSP_RGB32) {
- dst[0] = outData;
- dstStride[0] = (m_nSwOutBpp>>3) * (outStride);
- } else {
- for (unsigned int i=0; i<outcspInfo->numPlanes; i++) {
- dstStride[i] = outStride >> outcspInfo->shiftX[i];
- dst[i] = !i ? outData : dst[i-1] + dstStride[i-1] * (m_pOutSize.cy >> outcspInfo->shiftY[i-1]) ;
- }
-
- if (m_nOutCsp & FF_CSP_420P) {
- std::swap(dst[1], dst[2]);
- }
- }
-
- sws_scale(m_pSwsContext, m_pFrame->data, m_pFrame->linesize, 0, m_pAVCtx->height, dst, dstStride);
-
- if (outData != pDataOut) {
- if (m_nOutCsp & FF_CSP_420P) {
- std::swap(dst[1], dst[2]);
- }
- int rowsize = 0, height = 0;
- for (unsigned int i=0; i<outcspInfo->numPlanes; i++) {
- rowsize = (m_pOutSize.cx*outcspInfo->Bpp) >> outcspInfo->shiftX[i];
- height = m_pAVCtx->height >> outcspInfo->shiftY[i];
- copyPlane(pDataOut, rowsize, dst[i], (outStride*outcspInfo->Bpp) >> outcspInfo->shiftX[i], rowsize, height, (m_nOutCsp == FF_CSP_RGB32));
- pDataOut += rowsize * height;
- }
- }
- }
+ HRESULT hr = S_OK;
+ int got_picture;
+ int used_bytes;
+ BOOL bFlush = (pDataIn == NULL);
+
+ AVPacket avpkt;
+ av_init_packet(&avpkt);
+
+ if (!bFlush && m_nCodecId == CODEC_ID_H264) {
+ if (!m_h264RandomAccess.searchRecoveryPoint(m_pAVCtx, pDataIn, nSize)) {
+ return S_OK;
+ }
+ }
+
+ while (nSize > 0 || bFlush) {
+ if (!bFlush) {
+ if (nSize + FF_INPUT_BUFFER_PADDING_SIZE > m_nFFBufferSize) {
+ m_nFFBufferSize = nSize + FF_INPUT_BUFFER_PADDING_SIZE;
+ m_pFFBuffer = (BYTE*)av_realloc(m_pFFBuffer, m_nFFBufferSize);
+ if (!m_pFFBuffer) {
+ m_nFFBufferSize = 0;
+ return E_FAIL;
+ }
+ }
+
+ // Required number of additionally allocated bytes at the end of the input bitstream for decoding.
+ // This is mainly needed because some optimized bitstream readers read
+ // 32 or 64 bit at once and could read over the end.
+ // Note: If the first 23 bits of the additional bytes are not 0, then damaged
+ // MPEG bitstreams could cause overread and segfault.
+ memcpy(m_pFFBuffer, pDataIn, nSize);
+ memset(m_pFFBuffer + nSize, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+
+ avpkt.data = m_pFFBuffer;
+ avpkt.size = nSize;
+ avpkt.pts = rtStart;
+ avpkt.dts = rtStop;
+ avpkt.flags = AV_PKT_FLAG_KEY;
+ } else {
+ avpkt.data = NULL;
+ avpkt.size = 0;
+ }
+ used_bytes = avcodec_decode_video2(m_pAVCtx, m_pFrame, &got_picture, &avpkt);
+
+ if (used_bytes < 0) {
+ return S_OK;
+ }
+
+ // Comment from LAV Video code:
+ // When Frame Threading, we won't know how much data has been consumed, so it by default eats everything.
+ // In addition, if no data got consumed, and no picture was extracted, the frame probably isn't all that useufl.
+ // The MJPEB decoder is somewhat buggy and doesn't let us know how much data was consumed really...
+ if ((m_pAVCtx->active_thread_type & FF_THREAD_FRAME || (!got_picture && used_bytes == 0)) || m_nCodecId == CODEC_ID_MJPEGB || bFlush) {
+ nSize = 0;
+ } else {
+ nSize -= used_bytes;
+ pDataIn += used_bytes;
+ }
+
+ if (m_nCodecId == CODEC_ID_H264) {
+ m_h264RandomAccess.judgeFrameUsability(m_pFrame, &got_picture);
+ } else if (m_nCodecId == CODEC_ID_VC1 || m_nCodecId == CODEC_ID_RV30 || m_nCodecId == CODEC_ID_RV40) {
+ if (m_bWaitingForKeyFrame && got_picture) {
+ if (m_pFrame->key_frame) {
+ m_bWaitingForKeyFrame = FALSE;
+ } else {
+ got_picture = 0;
+ }
+ }
+ }
+
+ if (!got_picture || !m_pFrame->data[0]) {
+ bFlush = FALSE;
+ continue;
+ }
+
+ if ((pIn && pIn->IsPreroll() == S_OK) || rtStart < 0) {
+ return S_OK;
+ }
+
+ if (!m_bFrame_repeat_pict && m_pFrame->repeat_pict) {
+ m_bFrame_repeat_pict = true;
+ }
+
+ CComPtr<IMediaSample> pOut;
+ BYTE* pDataOut = NULL;
+
+ UpdateAspectRatio();
+ if (FAILED(hr = GetDeliveryBuffer(m_pAVCtx->width, m_pAVCtx->height, &pOut)) || FAILED(hr = pOut->GetPointer(&pDataOut))) {
+ return hr;
+ }
+
+ if (m_nCodecId == CODEC_ID_THEORA || (m_nCodecId == CODEC_ID_VP8 && m_rtAvrTimePerFrame == 10000)) { // need more tests
+ rtStart = m_pFrame->pkt_pts;
+ rtStop = m_pFrame->pkt_dts;
+ } else if ((m_nCodecId == CODEC_ID_RV10 || m_nCodecId == CODEC_ID_RV20) && m_pFrame->pict_type == AV_PICTURE_TYPE_B) {
+ rtStart = m_rtPrevStop;
+ rtStop = rtStart + m_rtAvrTimePerFrame;
+ } else if ((m_nCodecId == CODEC_ID_RV30 || m_nCodecId == CODEC_ID_RV40) && avpkt.data) {
+ rtStart = (rtStart == _I64_MIN) ? m_rtPrevStop : (10000i64 * process_rv_timestamp(&rm, m_nCodecId, avpkt.data, (rtStart + m_rtStart) / 10000) - m_rtStart);
+ rtStop = rtStart + m_rtAvrTimePerFrame;
+ } else if (!(m_nCodecId == CODEC_ID_VC1 && m_bFrame_repeat_pict && m_rtAvrTimePerFrame == 333666)) {
+ rtStart = m_pFrame->reordered_opaque;
+ rtStop = m_pFrame->reordered_opaque2;
+ }
+
+ m_rtPrevStop = rtStop;
+
+ ReorderBFrames(rtStart, rtStop);
+
+ pOut->SetTime(&rtStart, &rtStop);
+ pOut->SetMediaTime(NULL, NULL);
+
+ if (m_pSwsContext == NULL) {
+ InitSwscale();
+ }
+ if (m_pSwsContext != NULL) {
+
+ int outStride = m_pOutSize.cx;
+ BYTE* outData = pDataOut;
+
+ // From LAVVideo ...
+ // Check if we have proper pixel alignment and the dst memory is actually aligned
+ if (FFALIGN(outStride, 16) != outStride || ((uintptr_t)pDataOut % 16u)) {
+ outStride = FFALIGN(outStride, 16);
+ int requiredSize = (outStride * m_pAVCtx->height * m_nSwOutBpp) << 3;
+ if (requiredSize > m_nAlignedFFBufferSize) {
+ av_freep(&m_pAlignedFFBuffer);
+ m_nAlignedFFBufferSize = requiredSize;
+ m_pAlignedFFBuffer = (BYTE*)av_malloc(m_nAlignedFFBufferSize + FF_INPUT_BUFFER_PADDING_SIZE);
+ }
+ outData = m_pAlignedFFBuffer;
+ }
+
+ uint8_t* dst[4] = {NULL, NULL, NULL, NULL};
+ stride_t dstStride[4] = {0, 0, 0, 0};
+ const TcspInfo* outcspInfo = csp_getInfo(m_nOutCsp);
+
+ if (m_nOutCsp == FF_CSP_YUY2 || m_nOutCsp == FF_CSP_RGB32) {
+ dst[0] = outData;
+ dstStride[0] = (m_nSwOutBpp >> 3) * (outStride);
+ } else {
+ for (unsigned int i = 0; i < outcspInfo->numPlanes; i++) {
+ dstStride[i] = outStride >> outcspInfo->shiftX[i];
+ dst[i] = !i ? outData : dst[i - 1] + dstStride[i - 1] * (m_pOutSize.cy >> outcspInfo->shiftY[i - 1]) ;
+ }
+
+ if (m_nOutCsp & FF_CSP_420P) {
+ std::swap(dst[1], dst[2]);
+ }
+ }
+
+ sws_scale(m_pSwsContext, m_pFrame->data, m_pFrame->linesize, 0, m_pAVCtx->height, dst, dstStride);
+
+ if (outData != pDataOut) {
+ if (m_nOutCsp & FF_CSP_420P) {
+ std::swap(dst[1], dst[2]);
+ }
+ int rowsize = 0, height = 0;
+ for (unsigned int i = 0; i < outcspInfo->numPlanes; i++) {
+ rowsize = (m_pOutSize.cx * outcspInfo->Bpp) >> outcspInfo->shiftX[i];
+ height = m_pAVCtx->height >> outcspInfo->shiftY[i];
+ copyPlane(pDataOut, rowsize, dst[i], (outStride * outcspInfo->Bpp) >> outcspInfo->shiftX[i], rowsize, height, (m_nOutCsp == FF_CSP_RGB32));
+ pDataOut += rowsize * height;
+ }
+ }
+ }
#if defined(_DEBUG) && 0
- static REFERENCE_TIME rtLast = 0;
- TRACE ("Deliver : %10I64d - %10I64d (%10I64d) {%10I64d}\n", rtStart, rtStop,
- rtStop - rtStart, rtStart - rtLast);
- rtLast = rtStart;
+ static REFERENCE_TIME rtLast = 0;
+ TRACE("Deliver : %10I64d - %10I64d (%10I64d) {%10I64d}\n", rtStart, rtStop,
+ rtStop - rtStart, rtStart - rtLast);
+ rtLast = rtStart;
#endif
- SetTypeSpecificFlags (pOut);
- hr = m_pOutput->Deliver(pOut);
- }
+ SetTypeSpecificFlags(pOut);
+ hr = m_pOutput->Deliver(pOut);
+ }
- return hr;
+ return hr;
}
#endif /* HAS_FFMPEG_VIDEO_DECODERS */
bool CMPCVideoDecFilter::FindPicture(int nIndex, int nStartCode)
{
- DWORD dw = 0;
+ DWORD dw = 0;
- for (int i=0; i<m_nFFBufferPos-nIndex; i++) {
- dw = (dw<<8) + m_pFFBuffer[i+nIndex];
- if (i >= 4) {
- if (m_nFFPicEnd == INT_MIN) {
- if ( (dw & 0xffffff00) == 0x00000100 &&
- (dw & 0x000000FF) == (DWORD)nStartCode ) {
- m_nFFPicEnd = i+nIndex-3;
- }
- } else {
- if ( (dw & 0xffffff00) == 0x00000100 &&
- ((dw & 0x000000FF) == (DWORD)nStartCode || (dw & 0x000000FF) == 0xB3 )) {
- m_nFFPicEnd = i+nIndex-3;
- return true;
- }
- }
- }
+ for (int i = 0; i < m_nFFBufferPos - nIndex; i++) {
+ dw = (dw << 8) + m_pFFBuffer[i + nIndex];
+ if (i >= 4) {
+ if (m_nFFPicEnd == INT_MIN) {
+ if ((dw & 0xffffff00) == 0x00000100 &&
+ (dw & 0x000000FF) == (DWORD)nStartCode) {
+ m_nFFPicEnd = i + nIndex - 3;
+ }
+ } else {
+ if ((dw & 0xffffff00) == 0x00000100 &&
+ ((dw & 0x000000FF) == (DWORD)nStartCode || (dw & 0x000000FF) == 0xB3)) {
+ m_nFFPicEnd = i + nIndex - 3;
+ return true;
+ }
+ }
+ }
- }
+ }
- return false;
+ return false;
}
void CMPCVideoDecFilter::ResetBuffer()
{
- m_nFFBufferPos = 0;
- m_nFFPicEnd = INT_MIN;
+ m_nFFBufferPos = 0;
+ m_nFFPicEnd = INT_MIN;
- for (int i=0; i<MAX_BUFF_TIME; i++) {
- m_FFBufferTime[i].nBuffPos = INT_MIN;
- m_FFBufferTime[i].rtStart = _I64_MIN;
- m_FFBufferTime[i].rtStop = _I64_MIN;
- }
+ for (int i = 0; i < MAX_BUFF_TIME; i++) {
+ m_FFBufferTime[i].nBuffPos = INT_MIN;
+ m_FFBufferTime[i].rtStart = _I64_MIN;
+ m_FFBufferTime[i].rtStop = _I64_MIN;
+ }
}
void CMPCVideoDecFilter::PushBufferTime(int nPos, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop)
{
- for (int i=0; i<MAX_BUFF_TIME; i++) {
- if (m_FFBufferTime[i].nBuffPos == INT_MIN) {
- m_FFBufferTime[i].nBuffPos = nPos;
- m_FFBufferTime[i].rtStart = rtStart;
- m_FFBufferTime[i].rtStop = rtStop;
- break;
- }
- }
+ for (int i = 0; i < MAX_BUFF_TIME; i++) {
+ if (m_FFBufferTime[i].nBuffPos == INT_MIN) {
+ m_FFBufferTime[i].nBuffPos = nPos;
+ m_FFBufferTime[i].rtStart = rtStart;
+ m_FFBufferTime[i].rtStop = rtStop;
+ break;
+ }
+ }
}
void CMPCVideoDecFilter::PopBufferTime(int nPos)
{
- int nDestPos = 0;
- int i = 0;
+ int nDestPos = 0;
+ int i = 0;
- // Shift buffer time list
- while (i<MAX_BUFF_TIME && m_FFBufferTime[i].nBuffPos!=INT_MIN) {
- if (m_FFBufferTime[i].nBuffPos >= nPos) {
- m_FFBufferTime[nDestPos].nBuffPos = m_FFBufferTime[i].nBuffPos - nPos;
- m_FFBufferTime[nDestPos].rtStart = m_FFBufferTime[i].rtStart;
- m_FFBufferTime[nDestPos].rtStop = m_FFBufferTime[i].rtStop;
- nDestPos++;
- }
- i++;
- }
+ // Shift buffer time list
+ while (i < MAX_BUFF_TIME && m_FFBufferTime[i].nBuffPos != INT_MIN) {
+ if (m_FFBufferTime[i].nBuffPos >= nPos) {
+ m_FFBufferTime[nDestPos].nBuffPos = m_FFBufferTime[i].nBuffPos - nPos;
+ m_FFBufferTime[nDestPos].rtStart = m_FFBufferTime[i].rtStart;
+ m_FFBufferTime[nDestPos].rtStop = m_FFBufferTime[i].rtStop;
+ nDestPos++;
+ }
+ i++;
+ }
- // Free unused slots
- for (i=nDestPos; i<MAX_BUFF_TIME; i++) {
- m_FFBufferTime[i].nBuffPos = INT_MIN;
- m_FFBufferTime[i].rtStart = _I64_MIN;
- m_FFBufferTime[i].rtStop = _I64_MIN;
- }
+ // Free unused slots
+ for (i = nDestPos; i < MAX_BUFF_TIME; i++) {
+ m_FFBufferTime[i].nBuffPos = INT_MIN;
+ m_FFBufferTime[i].rtStart = _I64_MIN;
+ m_FFBufferTime[i].rtStop = _I64_MIN;
+ }
}
-bool CMPCVideoDecFilter::AppendBuffer (BYTE* pDataIn, int nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
+bool CMPCVideoDecFilter::AppendBuffer(BYTE* pDataIn, int nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
{
- if (rtStart != _I64_MIN) {
- PushBufferTime (m_nFFBufferPos, rtStart, rtStop);
- }
+ if (rtStart != _I64_MIN) {
+ PushBufferTime(m_nFFBufferPos, rtStart, rtStop);
+ }
- if (m_nFFBufferPos+nSize+FF_INPUT_BUFFER_PADDING_SIZE > m_nFFBufferSize) {
- m_nFFBufferSize = m_nFFBufferPos+nSize+FF_INPUT_BUFFER_PADDING_SIZE;
- m_pFFBuffer = (BYTE*)av_realloc(m_pFFBuffer, m_nFFBufferSize);
- }
+ if (m_nFFBufferPos + nSize + FF_INPUT_BUFFER_PADDING_SIZE > m_nFFBufferSize) {
+ m_nFFBufferSize = m_nFFBufferPos + nSize + FF_INPUT_BUFFER_PADDING_SIZE;
+ m_pFFBuffer = (BYTE*)av_realloc(m_pFFBuffer, m_nFFBufferSize);
+ }
- memcpy(m_pFFBuffer+m_nFFBufferPos, pDataIn, nSize);
+ memcpy(m_pFFBuffer + m_nFFBufferPos, pDataIn, nSize);
- m_nFFBufferPos += nSize;
+ m_nFFBufferPos += nSize;
- return true;
+ return true;
}
void CMPCVideoDecFilter::ShrinkBuffer()
{
- int nRemaining = m_nFFBufferPos-m_nFFPicEnd;
+ int nRemaining = m_nFFBufferPos - m_nFFPicEnd;
- ASSERT (m_nFFPicEnd != INT_MIN);
+ ASSERT(m_nFFPicEnd != INT_MIN);
- PopBufferTime (m_nFFPicEnd);
- memcpy (m_pFFBuffer, m_pFFBuffer+m_nFFPicEnd, nRemaining);
- m_nFFBufferPos = nRemaining;
+ PopBufferTime(m_nFFPicEnd);
+ memcpy(m_pFFBuffer, m_pFFBuffer + m_nFFPicEnd, nRemaining);
+ m_nFFBufferPos = nRemaining;
- m_nFFPicEnd = (m_pFFBuffer[3] == 0x00) ? 0 : INT_MIN;
+ m_nFFPicEnd = (m_pFFBuffer[3] == 0x00) ? 0 : INT_MIN;
}
HRESULT CMPCVideoDecFilter::Transform(IMediaSample* pIn)
{
- CAutoLock cAutoLock(&m_csReceive);
- HRESULT hr;
- BYTE* pDataIn;
- int nSize;
- REFERENCE_TIME rtStart = _I64_MIN;
- REFERENCE_TIME rtStop = _I64_MIN;
+ CAutoLock cAutoLock(&m_csReceive);
+ HRESULT hr;
+ BYTE* pDataIn;
+ int nSize;
+ REFERENCE_TIME rtStart = _I64_MIN;
+ REFERENCE_TIME rtStop = _I64_MIN;
- if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
- return hr;
- }
+ if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
+ return hr;
+ }
- nSize = pIn->GetActualDataLength();
- hr = pIn->GetTime(&rtStart, &rtStop);
+ nSize = pIn->GetActualDataLength();
+ hr = pIn->GetTime(&rtStart, &rtStop);
- if (FAILED(hr)) {
- rtStart = rtStop = _I64_MIN;
- }
+ if (FAILED(hr)) {
+ rtStart = rtStop = _I64_MIN;
+ }
- if (m_nDXVAMode == MODE_SOFTWARE || (m_nCodecId == CODEC_ID_VC1 && !m_bIsEVO)) {
- UpdateFrameTime(rtStart, rtStop, m_bFrame_repeat_pict);
- }
+ if (m_nDXVAMode == MODE_SOFTWARE || (m_nCodecId == CODEC_ID_VC1 && !m_bIsEVO)) {
+ UpdateFrameTime(rtStart, rtStop, m_bFrame_repeat_pict);
+ }
- m_pAVCtx->reordered_opaque = rtStart;
- m_pAVCtx->reordered_opaque2 = rtStop;
+ m_pAVCtx->reordered_opaque = rtStart;
+ m_pAVCtx->reordered_opaque2 = rtStop;
- if (m_pAVCtx->has_b_frames) {
- m_BFrames[m_nPosB].rtStart = rtStart;
- m_BFrames[m_nPosB].rtStop = rtStop;
- m_nPosB = 1-m_nPosB;
- }
+ if (m_pAVCtx->has_b_frames) {
+ m_BFrames[m_nPosB].rtStart = rtStart;
+ m_BFrames[m_nPosB].rtStop = rtStop;
+ m_nPosB = 1 - m_nPosB;
+ }
- switch (m_nDXVAMode) {
+ switch (m_nDXVAMode) {
#if HAS_FFMPEG_VIDEO_DECODERS
- case MODE_SOFTWARE :
- hr = SoftwareDecode (pIn, pDataIn, nSize, rtStart, rtStop);
- break;
+ case MODE_SOFTWARE :
+ hr = SoftwareDecode(pIn, pDataIn, nSize, rtStart, rtStop);
+ break;
#endif
- case MODE_DXVA1 :
- case MODE_DXVA2 :
- CheckPointer (m_pDXVADecoder, E_UNEXPECTED);
- UpdateAspectRatio();
-
- // Change aspect ratio for DXVA1
- if ((m_nDXVAMode == MODE_DXVA1) &&
- ReconnectOutput(PictWidthRounded(), PictHeightRounded(), true, PictWidth(), PictHeight()) == S_OK) {
- m_pDXVADecoder->ConfigureDXVA1();
- }
-
- if (m_pAVCtx->codec_id == CODEC_ID_MPEG2VIDEO) {
- AppendBuffer (pDataIn, nSize, rtStart, rtStop);
- hr = S_OK;
-
- while (FindPicture (max (m_nFFBufferPos-nSize-4, 0), 0x00)) {
- if (m_FFBufferTime[0].nBuffPos != INT_MIN && m_FFBufferTime[0].nBuffPos < m_nFFPicEnd) {
- rtStart = m_FFBufferTime[0].rtStart;
- rtStop = m_FFBufferTime[0].rtStop;
- } else {
- rtStart = rtStop = _I64_MIN;
- }
- hr = m_pDXVADecoder->DecodeFrame (m_pFFBuffer, m_nFFPicEnd, rtStart, rtStop);
- ShrinkBuffer();
- }
- } else {
- hr = m_pDXVADecoder->DecodeFrame (pDataIn, nSize, rtStart, rtStop);
- }
- break;
- default :
- ASSERT (FALSE);
- hr = E_UNEXPECTED;
- }
-
- return hr;
+ case MODE_DXVA1 :
+ case MODE_DXVA2 :
+ CheckPointer(m_pDXVADecoder, E_UNEXPECTED);
+ UpdateAspectRatio();
+
+ // Change aspect ratio for DXVA1
+ if ((m_nDXVAMode == MODE_DXVA1) &&
+ ReconnectOutput(PictWidthRounded(), PictHeightRounded(), true, PictWidth(), PictHeight()) == S_OK) {
+ m_pDXVADecoder->ConfigureDXVA1();
+ }
+
+ if (m_pAVCtx->codec_id == CODEC_ID_MPEG2VIDEO) {
+ AppendBuffer(pDataIn, nSize, rtStart, rtStop);
+ hr = S_OK;
+
+ while (FindPicture(max(m_nFFBufferPos - nSize - 4, 0), 0x00)) {
+ if (m_FFBufferTime[0].nBuffPos != INT_MIN && m_FFBufferTime[0].nBuffPos < m_nFFPicEnd) {
+ rtStart = m_FFBufferTime[0].rtStart;
+ rtStop = m_FFBufferTime[0].rtStop;
+ } else {
+ rtStart = rtStop = _I64_MIN;
+ }
+ hr = m_pDXVADecoder->DecodeFrame(m_pFFBuffer, m_nFFPicEnd, rtStart, rtStop);
+ ShrinkBuffer();
+ }
+ } else {
+ hr = m_pDXVADecoder->DecodeFrame(pDataIn, nSize, rtStart, rtStop);
+ }
+ break;
+ default :
+ ASSERT(FALSE);
+ hr = E_UNEXPECTED;
+ }
+
+ return hr;
}
void CMPCVideoDecFilter::UpdateAspectRatio()
{
- if (((m_nARMode) && (m_pAVCtx)) && ((m_pAVCtx->sample_aspect_ratio.num>0) && (m_pAVCtx->sample_aspect_ratio.den>0))) {
- CSize SAR(m_pAVCtx->sample_aspect_ratio.num, m_pAVCtx->sample_aspect_ratio.den);
- if (m_sar != SAR) {
- m_sar = SAR;
- CSize aspect(m_nWidth * SAR.cx, m_nHeight * SAR.cy);
- int lnko = LNKO(aspect.cx, aspect.cy);
- if (lnko > 1) {
- aspect.cx /= lnko, aspect.cy /= lnko;
- }
- SetAspect(aspect);
- }
- }
+ if (((m_nARMode) && (m_pAVCtx)) && ((m_pAVCtx->sample_aspect_ratio.num > 0) && (m_pAVCtx->sample_aspect_ratio.den > 0))) {
+ CSize SAR(m_pAVCtx->sample_aspect_ratio.num, m_pAVCtx->sample_aspect_ratio.den);
+ if (m_sar != SAR) {
+ m_sar = SAR;
+ CSize aspect(m_nWidth * SAR.cx, m_nHeight * SAR.cy);
+ int lnko = LNKO(aspect.cx, aspect.cy);
+ if (lnko > 1) {
+ aspect.cx /= lnko, aspect.cy /= lnko;
+ }
+ SetAspect(aspect);
+ }
+ }
}
void CMPCVideoDecFilter::ReorderBFrames(REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop)
{
- // Re-order B-frames if needed
- if (m_pAVCtx->has_b_frames && m_bReorderBFrame) {
- rtStart = m_BFrames [m_nPosB].rtStart;
- rtStop = m_BFrames [m_nPosB].rtStop;
- }
+ // Re-order B-frames if needed
+ if (m_pAVCtx->has_b_frames && m_bReorderBFrame) {
+ rtStart = m_BFrames [m_nPosB].rtStart;
+ rtStop = m_BFrames [m_nPosB].rtStop;
+ }
}
-void CMPCVideoDecFilter::FillInVideoDescription(DXVA2_VideoDesc *pDesc)
+void CMPCVideoDecFilter::FillInVideoDescription(DXVA2_VideoDesc* pDesc)
{
- memset (pDesc, 0, sizeof(DXVA2_VideoDesc));
- pDesc->SampleWidth = PictWidthRounded();
- pDesc->SampleHeight = PictHeightRounded();
- pDesc->Format = D3DFMT_A8R8G8B8;
- pDesc->UABProtectionLevel = 1;
+ memset(pDesc, 0, sizeof(DXVA2_VideoDesc));
+ pDesc->SampleWidth = PictWidthRounded();
+ pDesc->SampleHeight = PictHeightRounded();
+ pDesc->Format = D3DFMT_A8R8G8B8;
+ pDesc->UABProtectionLevel = 1;
}
BOOL CMPCVideoDecFilter::IsSupportedDecoderMode(const GUID& mode)
{
- if (IsDXVASupported()) {
- for (int i=0; i<MAX_SUPPORTED_MODE; i++) {
- if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == GUID_NULL) {
- break;
- } else if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == mode) {
- return true;
- }
- }
- }
+ if (IsDXVASupported()) {
+ for (int i = 0; i < MAX_SUPPORTED_MODE; i++) {
+ if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == GUID_NULL) {
+ break;
+ } else if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == mode) {
+ return true;
+ }
+ }
+ }
- return false;
+ return false;
}
BOOL CMPCVideoDecFilter::IsSupportedDecoderConfig(const D3DFORMAT nD3DFormat, const DXVA2_ConfigPictureDecode& config, bool& bIsPrefered)
{
- bool bRet = false;
+ bool bRet = false;
- bRet = (nD3DFormat == MAKEFOURCC('N', 'V', '1', '2') || nD3DFormat == MAKEFOURCC('I', 'M', 'C', '3'));
+ bRet = (nD3DFormat == MAKEFOURCC('N', 'V', '1', '2') || nD3DFormat == MAKEFOURCC('I', 'M', 'C', '3'));
- bIsPrefered = (config.ConfigBitstreamRaw == ffCodecs[m_nCodecNb].DXVAModes->PreferedConfigBitstream);
- LOG (_T("IsSupportedDecoderConfig 0x%08x %d"), nD3DFormat, bRet);
- return bRet;
+ bIsPrefered = (config.ConfigBitstreamRaw == ffCodecs[m_nCodecNb].DXVAModes->PreferedConfigBitstream);
+ LOG(_T("IsSupportedDecoderConfig 0x%08x %d"), nD3DFormat, bRet);
+ return bRet;
}
-HRESULT CMPCVideoDecFilter::FindDXVA2DecoderConfiguration(IDirectXVideoDecoderService *pDecoderService,
- const GUID& guidDecoder,
- DXVA2_ConfigPictureDecode *pSelectedConfig,
- BOOL *pbFoundDXVA2Configuration)
+HRESULT CMPCVideoDecFilter::FindDXVA2DecoderConfiguration(IDirectXVideoDecoderService* pDecoderService,
+ const GUID& guidDecoder,
+ DXVA2_ConfigPictureDecode* pSelectedConfig,
+ BOOL* pbFoundDXVA2Configuration)
{
- HRESULT hr = S_OK;
- UINT cFormats = 0;
- UINT cConfigurations = 0;
- bool bIsPrefered = false;
-
- D3DFORMAT *pFormats = NULL; // size = cFormats
- DXVA2_ConfigPictureDecode *pConfig = NULL; // size = cConfigurations
-
- // Find the valid render target formats for this decoder GUID.
- hr = pDecoderService->GetDecoderRenderTargets(guidDecoder, &cFormats, &pFormats);
- LOG (_T("GetDecoderRenderTargets => %d"), cFormats);
-
- if (SUCCEEDED(hr)) {
- // Look for a format that matches our output format.
- for (UINT iFormat = 0; iFormat < cFormats; iFormat++) {
- LOG (_T("Try to negociate => 0x%08x"), pFormats[iFormat]);
-
- // Fill in the video description. Set the width, height, format, and frame rate.
- FillInVideoDescription(&m_VideoDesc); // Private helper function.
- m_VideoDesc.Format = pFormats[iFormat];
-
- // Get the available configurations.
- hr = pDecoderService->GetDecoderConfigurations(guidDecoder, &m_VideoDesc, NULL, &cConfigurations, &pConfig);
-
- if (FAILED(hr)) {
- continue;
- }
-
- // Find a supported configuration.
- for (UINT iConfig = 0; iConfig < cConfigurations; iConfig++) {
- if (IsSupportedDecoderConfig(pFormats[iFormat], pConfig[iConfig], bIsPrefered)) {
- // This configuration is good.
- if (bIsPrefered || !*pbFoundDXVA2Configuration) {
- *pbFoundDXVA2Configuration = TRUE;
- *pSelectedConfig = pConfig[iConfig];
- }
-
- if (bIsPrefered) {
- break;
- }
- }
- }
-
- CoTaskMemFree(pConfig);
- } // End of formats loop.
- }
-
- CoTaskMemFree(pFormats);
-
- // Note: It is possible to return S_OK without finding a configuration.
- return hr;
-}
-
-HRESULT CMPCVideoDecFilter::ConfigureDXVA2(IPin *pPin)
-{
- HRESULT hr = S_OK;
- UINT cDecoderGuids = 0;
- BOOL bFoundDXVA2Configuration = FALSE;
- BOOL bHasIntelGuid = FALSE;
- GUID guidDecoder = GUID_NULL;
-
- DXVA2_ConfigPictureDecode config;
- ZeroMemory(&config, sizeof(config));
-
- CComPtr<IMFGetService> pGetService;
- CComPtr<IDirect3DDeviceManager9> pDeviceManager;
- CComPtr<IDirectXVideoDecoderService> pDecoderService;
- GUID* pDecoderGuids = NULL;
- HANDLE hDevice = INVALID_HANDLE_VALUE;
-
- // Query the pin for IMFGetService.
- hr = pPin->QueryInterface(__uuidof(IMFGetService), (void**)&pGetService);
-
- // Get the Direct3D device manager.
- if (SUCCEEDED(hr)) {
- hr = pGetService->GetService(
- MR_VIDEO_ACCELERATION_SERVICE,
- __uuidof(IDirect3DDeviceManager9),
- (void**)&pDeviceManager);
- }
-
- // Open a new device handle.
- if (SUCCEEDED(hr)) {
- hr = pDeviceManager->OpenDeviceHandle(&hDevice);
- }
-
- // Get the video decoder service.
- if (SUCCEEDED(hr)) {
- hr = pDeviceManager->GetVideoService(
- hDevice,
- __uuidof(IDirectXVideoDecoderService),
- (void**)&pDecoderService);
- }
-
- // Get the decoder GUIDs.
- if (SUCCEEDED(hr)) {
- hr = pDecoderService->GetDecoderDeviceGuids(&cDecoderGuids, &pDecoderGuids);
- }
-
- if (SUCCEEDED(hr)) {
-
- //Intel patch for Ivy Bridge and Sandy Bridge
- if (m_nPCIVendor == PCIV_Intel) {
- for (UINT iCnt = 0; iCnt < cDecoderGuids; iCnt++) {
- if (pDecoderGuids[iCnt] == DXVA_Intel_H264_ClearVideo)
- bHasIntelGuid = TRUE;
- }
- }
- // Look for the decoder GUIDs we want.
- for (UINT iGuid = 0; iGuid < cDecoderGuids; iGuid++) {
- // Do we support this mode?
- if (!IsSupportedDecoderMode(pDecoderGuids[iGuid])) {
- continue;
- }
-
- // Find a configuration that we support.
- hr = FindDXVA2DecoderConfiguration(pDecoderService, pDecoderGuids[iGuid], &config, &bFoundDXVA2Configuration);
-
- if (FAILED(hr)) {
- break;
- }
-
- // Patch for the Sandy Bridge (prevent crash on Mode_E, fixme later)
- if (m_nPCIVendor == PCIV_Intel && pDecoderGuids[iGuid] == DXVA2_ModeH264_E && bHasIntelGuid) {
- continue;
- }
-
- if (bFoundDXVA2Configuration) {
- // Found a good configuration. Save the GUID.
- guidDecoder = pDecoderGuids[iGuid];
- if (!bHasIntelGuid) break;
- }
- }
- }
-
- if (pDecoderGuids) {
- CoTaskMemFree(pDecoderGuids);
- }
- if (!bFoundDXVA2Configuration) {
- hr = E_FAIL; // Unable to find a configuration.
- }
-
- if (SUCCEEDED(hr)) {
- // Store the things we will need later.
- m_pDeviceManager = pDeviceManager;
- m_pDecoderService = pDecoderService;
-
- m_DXVA2Config = config;
- m_DXVADecoderGUID = guidDecoder;
- m_hDevice = hDevice;
- }
-
- if (FAILED(hr)) {
- if (hDevice != INVALID_HANDLE_VALUE) {
- pDeviceManager->CloseDeviceHandle(hDevice);
- }
- }
-
- return hr;
-}
-
-HRESULT CMPCVideoDecFilter::SetEVRForDXVA2(IPin *pPin)
-{
- HRESULT hr = S_OK;
-
- CComPtr<IMFGetService> pGetService;
- CComPtr<IDirectXVideoMemoryConfiguration> pVideoConfig;
- CComPtr<IMFVideoDisplayControl> pVdc;
-
- // Query the pin for IMFGetService.
- hr = pPin->QueryInterface(__uuidof(IMFGetService), (void**)&pGetService);
-
- // Get the IDirectXVideoMemoryConfiguration interface.
- if (SUCCEEDED(hr)) {
- hr = pGetService->GetService(
- MR_VIDEO_ACCELERATION_SERVICE,
- __uuidof(IDirectXVideoMemoryConfiguration),
- (void**)&pVideoConfig);
-
- if (SUCCEEDED (pGetService->GetService(MR_VIDEO_RENDER_SERVICE, __uuidof(IMFVideoDisplayControl), (void**)&pVdc))) {
- HWND hWnd;
- if (SUCCEEDED (pVdc->GetVideoWindow(&hWnd))) {
- DetectVideoCard(hWnd);
- }
- }
- }
-
- // Notify the EVR.
- if (SUCCEEDED(hr)) {
- DXVA2_SurfaceType surfaceType;
-
- for (DWORD iTypeIndex = 0; ; iTypeIndex++) {
- hr = pVideoConfig->GetAvailableSurfaceTypeByIndex(iTypeIndex, &surfaceType);
-
- if (FAILED(hr)) {
- break;
- }
-
- if (surfaceType == DXVA2_SurfaceType_DecoderRenderTarget) {
- hr = pVideoConfig->SetSurfaceType(DXVA2_SurfaceType_DecoderRenderTarget);
- break;
- }
- }
- }
-
- return hr;
+ HRESULT hr = S_OK;
+ UINT cFormats = 0;
+ UINT cConfigurations = 0;
+ bool bIsPrefered = false;
+
+ D3DFORMAT* pFormats = NULL; // size = cFormats
+ DXVA2_ConfigPictureDecode* pConfig = NULL; // size = cConfigurations
+
+ // Find the valid render target formats for this decoder GUID.
+ hr = pDecoderService->GetDecoderRenderTargets(guidDecoder, &cFormats, &pFormats);
+ LOG(_T("GetDecoderRenderTargets => %d"), cFormats);
+
+ if (SUCCEEDED(hr)) {
+ // Look for a format that matches our output format.
+ for (UINT iFormat = 0; iFormat < cFormats; iFormat++) {
+ LOG(_T("Try to negociate => 0x%08x"), pFormats[iFormat]);
+
+ // Fill in the video description. Set the width, height, format, and frame rate.
+ FillInVideoDescription(&m_VideoDesc); // Private helper function.
+ m_VideoDesc.Format = pFormats[iFormat];
+
+ // Get the available configurations.
+ hr = pDecoderService->GetDecoderConfigurations(guidDecoder, &m_VideoDesc, NULL, &cConfigurations, &pConfig);
+
+ if (FAILED(hr)) {
+ continue;
+ }
+
+ // Find a supported configuration.
+ for (UINT iConfig = 0; iConfig < cConfigurations; iConfig++) {
+ if (IsSupportedDecoderConfig(pFormats[iFormat], pConfig[iConfig], bIsPrefered)) {
+ // This configuration is good.
+ if (bIsPrefered || !*pbFoundDXVA2Configuration) {
+ *pbFoundDXVA2Configuration = TRUE;
+ *pSelectedConfig = pConfig[iConfig];
+ }
+
+ if (bIsPrefered) {
+ break;
+ }
+ }
+ }
+
+ CoTaskMemFree(pConfig);
+ } // End of formats loop.
+ }
+
+ CoTaskMemFree(pFormats);
+
+ // Note: It is possible to return S_OK without finding a configuration.
+ return hr;
+}
+
+HRESULT CMPCVideoDecFilter::ConfigureDXVA2(IPin* pPin)
+{
+ HRESULT hr = S_OK;
+ UINT cDecoderGuids = 0;
+ BOOL bFoundDXVA2Configuration = FALSE;
+ BOOL bHasIntelGuid = FALSE;
+ GUID guidDecoder = GUID_NULL;
+
+ DXVA2_ConfigPictureDecode config;
+ ZeroMemory(&config, sizeof(config));
+
+ CComPtr<IMFGetService> pGetService;
+ CComPtr<IDirect3DDeviceManager9> pDeviceManager;
+ CComPtr<IDirectXVideoDecoderService> pDecoderService;
+ GUID* pDecoderGuids = NULL;
+ HANDLE hDevice = INVALID_HANDLE_VALUE;
+
+ // Query the pin for IMFGetService.
+ hr = pPin->QueryInterface(__uuidof(IMFGetService), (void**)&pGetService);
+
+ // Get the Direct3D device manager.
+ if (SUCCEEDED(hr)) {
+ hr = pGetService->GetService(
+ MR_VIDEO_ACCELERATION_SERVICE,
+ __uuidof(IDirect3DDeviceManager9),
+ (void**)&pDeviceManager);
+ }
+
+ // Open a new device handle.
+ if (SUCCEEDED(hr)) {
+ hr = pDeviceManager->OpenDeviceHandle(&hDevice);
+ }
+
+ // Get the video decoder service.
+ if (SUCCEEDED(hr)) {
+ hr = pDeviceManager->GetVideoService(
+ hDevice,
+ __uuidof(IDirectXVideoDecoderService),
+ (void**)&pDecoderService);
+ }
+
+ // Get the decoder GUIDs.
+ if (SUCCEEDED(hr)) {
+ hr = pDecoderService->GetDecoderDeviceGuids(&cDecoderGuids, &pDecoderGuids);
+ }
+
+ if (SUCCEEDED(hr)) {
+
+ //Intel patch for Ivy Bridge and Sandy Bridge
+ if (m_nPCIVendor == PCIV_Intel) {
+ for (UINT iCnt = 0; iCnt < cDecoderGuids; iCnt++) {
+ if (pDecoderGuids[iCnt] == DXVA_Intel_H264_ClearVideo) {
+ bHasIntelGuid = TRUE;
+ }
+ }
+ }
+ // Look for the decoder GUIDs we want.
+ for (UINT iGuid = 0; iGuid < cDecoderGuids; iGuid++) {
+ // Do we support this mode?
+ if (!IsSupportedDecoderMode(pDecoderGuids[iGuid])) {
+ continue;
+ }
+
+ // Find a configuration that we support.
+ hr = FindDXVA2DecoderConfiguration(pDecoderService, pDecoderGuids[iGuid], &config, &bFoundDXVA2Configuration);
+
+ if (FAILED(hr)) {
+ break;
+ }
+
+ // Patch for the Sandy Bridge (prevent crash on Mode_E, fixme later)
+ if (m_nPCIVendor == PCIV_Intel && pDecoderGuids[iGuid] == DXVA2_ModeH264_E && bHasIntelGuid) {
+ continue;
+ }
+
+ if (bFoundDXVA2Configuration) {
+ // Found a good configuration. Save the GUID.
+ guidDecoder = pDecoderGuids[iGuid];
+ if (!bHasIntelGuid) { break; }
+ }
+ }
+ }
+
+ if (pDecoderGuids) {
+ CoTaskMemFree(pDecoderGuids);
+ }
+ if (!bFoundDXVA2Configuration) {
+ hr = E_FAIL; // Unable to find a configuration.
+ }
+
+ if (SUCCEEDED(hr)) {
+ // Store the things we will need later.
+ m_pDeviceManager = pDeviceManager;
+ m_pDecoderService = pDecoderService;
+
+ m_DXVA2Config = config;
+ m_DXVADecoderGUID = guidDecoder;
+ m_hDevice = hDevice;
+ }
+
+ if (FAILED(hr)) {
+ if (hDevice != INVALID_HANDLE_VALUE) {
+ pDeviceManager->CloseDeviceHandle(hDevice);
+ }
+ }
+
+ return hr;
+}
+
+HRESULT CMPCVideoDecFilter::SetEVRForDXVA2(IPin* pPin)
+{
+ HRESULT hr = S_OK;
+
+ CComPtr<IMFGetService> pGetService;
+ CComPtr<IDirectXVideoMemoryConfiguration> pVideoConfig;
+ CComPtr<IMFVideoDisplayControl> pVdc;
+
+ // Query the pin for IMFGetService.
+ hr = pPin->QueryInterface(__uuidof(IMFGetService), (void**)&pGetService);
+
+ // Get the IDirectXVideoMemoryConfiguration interface.
+ if (SUCCEEDED(hr)) {
+ hr = pGetService->GetService(
+ MR_VIDEO_ACCELERATION_SERVICE,
+ __uuidof(IDirectXVideoMemoryConfiguration),
+ (void**)&pVideoConfig);
+
+ if (SUCCEEDED(pGetService->GetService(MR_VIDEO_RENDER_SERVICE, __uuidof(IMFVideoDisplayControl), (void**)&pVdc))) {
+ HWND hWnd;
+ if (SUCCEEDED(pVdc->GetVideoWindow(&hWnd))) {
+ DetectVideoCard(hWnd);
+ }
+ }
+ }
+
+ // Notify the EVR.
+ if (SUCCEEDED(hr)) {
+ DXVA2_SurfaceType surfaceType;
+
+ for (DWORD iTypeIndex = 0; ; iTypeIndex++) {
+ hr = pVideoConfig->GetAvailableSurfaceTypeByIndex(iTypeIndex, &surfaceType);
+
+ if (FAILED(hr)) {
+ break;
+ }
+
+ if (surfaceType == DXVA2_SurfaceType_DecoderRenderTarget) {
+ hr = pVideoConfig->SetSurfaceType(DXVA2_SurfaceType_DecoderRenderTarget);
+ break;
+ }
+ }
+ }
+
+ return hr;
}
HRESULT CMPCVideoDecFilter::CreateDXVA2Decoder(UINT nNumRenderTargets, IDirect3DSurface9** pDecoderRenderTargets)
{
- HRESULT hr;
- CComPtr<IDirectXVideoDecoder> pDirectXVideoDec;
+ HRESULT hr;
+ CComPtr<IDirectXVideoDecoder> pDirectXVideoDec;
- m_pDecoderRenderTarget = NULL;
+ m_pDecoderRenderTarget = NULL;
- if (m_pDXVADecoder) {
- m_pDXVADecoder->SetDirectXVideoDec (NULL);
- }
+ if (m_pDXVADecoder) {
+ m_pDXVADecoder->SetDirectXVideoDec(NULL);
+ }
- hr = m_pDecoderService->CreateVideoDecoder (m_DXVADecoderGUID, &m_VideoDesc, &m_DXVA2Config,
- pDecoderRenderTargets, nNumRenderTargets, &pDirectXVideoDec);
+ hr = m_pDecoderService->CreateVideoDecoder(m_DXVADecoderGUID, &m_VideoDesc, &m_DXVA2Config,
+ pDecoderRenderTargets, nNumRenderTargets, &pDirectXVideoDec);
- if (SUCCEEDED (hr)) {
- if (!m_pDXVADecoder) {
- m_pDXVADecoder = CDXVADecoder::CreateDecoder (this, pDirectXVideoDec, &m_DXVADecoderGUID, GetPicEntryNumber(), &m_DXVA2Config);
- if (m_pDXVADecoder) {
- m_pDXVADecoder->SetExtraData ((BYTE*)m_pAVCtx->extradata, m_pAVCtx->extradata_size);
- }
- }
+ if (SUCCEEDED(hr)) {
+ if (!m_pDXVADecoder) {
+ m_pDXVADecoder = CDXVADecoder::CreateDecoder(this, pDirectXVideoDec, &m_DXVADecoderGUID, GetPicEntryNumber(), &m_DXVA2Config);
+ if (m_pDXVADecoder) {
+ m_pDXVADecoder->SetExtraData((BYTE*)m_pAVCtx->extradata, m_pAVCtx->extradata_size);
+ }
+ }
- m_pDXVADecoder->SetDirectXVideoDec (pDirectXVideoDec);
- }
+ m_pDXVADecoder->SetDirectXVideoDec(pDirectXVideoDec);
+ }
- return hr;
+ return hr;
}
HRESULT CMPCVideoDecFilter::FindDXVA1DecoderConfiguration(IAMVideoAccelerator* pAMVideoAccelerator, const GUID* guidDecoder, DDPIXELFORMAT* pPixelFormat)
{
- HRESULT hr = E_FAIL;
- DWORD dwFormats = 0;
- DDPIXELFORMAT* pPixelFormats = NULL;
+ HRESULT hr = E_FAIL;
+ DWORD dwFormats = 0;
+ DDPIXELFORMAT* pPixelFormats = NULL;
- pAMVideoAccelerator->GetUncompFormatsSupported (guidDecoder, &dwFormats, NULL);
- if (dwFormats > 0) {
- // Find the valid render target formats for this decoder GUID.
- pPixelFormats = DNew DDPIXELFORMAT[dwFormats];
- hr = pAMVideoAccelerator->GetUncompFormatsSupported (guidDecoder, &dwFormats, pPixelFormats);
- if (SUCCEEDED(hr)) {
- // Look for a format that matches our output format.
- for (DWORD iFormat = 0; iFormat < dwFormats; iFormat++) {
- if (pPixelFormats[iFormat].dwFourCC == MAKEFOURCC ('N', 'V', '1', '2')) {
- memcpy (pPixelFormat, &pPixelFormats[iFormat], sizeof(DDPIXELFORMAT));
- SAFE_DELETE_ARRAY(pPixelFormats)
- return S_OK;
- }
- }
+ pAMVideoAccelerator->GetUncompFormatsSupported(guidDecoder, &dwFormats, NULL);
+ if (dwFormats > 0) {
+ // Find the valid render target formats for this decoder GUID.
+ pPixelFormats = DNew DDPIXELFORMAT[dwFormats];
+ hr = pAMVideoAccelerator->GetUncompFormatsSupported(guidDecoder, &dwFormats, pPixelFormats);
+ if (SUCCEEDED(hr)) {
+ // Look for a format that matches our output format.
+ for (DWORD iFormat = 0; iFormat < dwFormats; iFormat++) {
+ if (pPixelFormats[iFormat].dwFourCC == MAKEFOURCC('N', 'V', '1', '2')) {
+ memcpy(pPixelFormat, &pPixelFormats[iFormat], sizeof(DDPIXELFORMAT));
+ SAFE_DELETE_ARRAY(pPixelFormats)
+ return S_OK;
+ }
+ }
- SAFE_DELETE_ARRAY(pPixelFormats);
- hr = E_FAIL;
- }
- }
+ SAFE_DELETE_ARRAY(pPixelFormats);
+ hr = E_FAIL;
+ }
+ }
- return hr;
+ return hr;
}
-HRESULT CMPCVideoDecFilter::CheckDXVA1Decoder(const GUID *pGuid)
+HRESULT CMPCVideoDecFilter::CheckDXVA1Decoder(const GUID* pGuid)
{
- if (m_nCodecNb != -1) {
- for (int i=0; i<MAX_SUPPORTED_MODE; i++)
- if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == *pGuid) {
- return S_OK;
- }
- }
+ if (m_nCodecNb != -1) {
+ for (int i = 0; i < MAX_SUPPORTED_MODE; i++)
+ if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == *pGuid) {
+ return S_OK;
+ }
+ }
- return E_INVALIDARG;
+ return E_INVALIDARG;
}
void CMPCVideoDecFilter::SetDXVA1Params(const GUID* pGuid, DDPIXELFORMAT* pPixelFormat)
{
- m_DXVADecoderGUID = *pGuid;
- memcpy (&m_PixelFormat, pPixelFormat, sizeof (DDPIXELFORMAT));
+ m_DXVADecoderGUID = *pGuid;
+ memcpy(&m_PixelFormat, pPixelFormat, sizeof(DDPIXELFORMAT));
}
WORD CMPCVideoDecFilter::GetDXVA1RestrictedMode()
{
- if (m_nCodecNb != -1) {
- for (int i=0; i<MAX_SUPPORTED_MODE; i++)
- if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == m_DXVADecoderGUID) {
- return ffCodecs[m_nCodecNb].DXVAModes->RestrictedMode [i];
- }
- }
+ if (m_nCodecNb != -1) {
+ for (int i = 0; i < MAX_SUPPORTED_MODE; i++)
+ if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == m_DXVADecoderGUID) {
+ return ffCodecs[m_nCodecNb].DXVAModes->RestrictedMode [i];
+ }
+ }
- return DXVA_RESTRICTED_MODE_UNRESTRICTED;
+ return DXVA_RESTRICTED_MODE_UNRESTRICTED;
}
HRESULT CMPCVideoDecFilter::CreateDXVA1Decoder(IAMVideoAccelerator* pAMVideoAccelerator, const GUID* pDecoderGuid, DWORD dwSurfaceCount)
{
- if (m_pDXVADecoder && m_DXVADecoderGUID == *pDecoderGuid) {
- return S_OK;
- }
- SAFE_DELETE (m_pDXVADecoder);
+ if (m_pDXVADecoder && m_DXVADecoderGUID == *pDecoderGuid) {
+ return S_OK;
+ }
+ SAFE_DELETE(m_pDXVADecoder);
- if (!m_bUseDXVA) {
- return E_FAIL;
- }
+ if (!m_bUseDXVA) {
+ return E_FAIL;
+ }
- m_nDXVAMode = MODE_DXVA1;
- m_DXVADecoderGUID = *pDecoderGuid;
- m_pDXVADecoder = CDXVADecoder::CreateDecoder (this, pAMVideoAccelerator, &m_DXVADecoderGUID, dwSurfaceCount);
- if (m_pDXVADecoder) {
- m_pDXVADecoder->SetExtraData ((BYTE*)m_pAVCtx->extradata, m_pAVCtx->extradata_size);
- }
+ m_nDXVAMode = MODE_DXVA1;
+ m_DXVADecoderGUID = *pDecoderGuid;
+ m_pDXVADecoder = CDXVADecoder::CreateDecoder(this, pAMVideoAccelerator, &m_DXVADecoderGUID, dwSurfaceCount);
+ if (m_pDXVADecoder) {
+ m_pDXVADecoder->SetExtraData((BYTE*)m_pAVCtx->extradata, m_pAVCtx->extradata_size);
+ }
- return S_OK;
+ return S_OK;
}
// ISpecifyPropertyPages2
STDMETHODIMP CMPCVideoDecFilter::GetPages(CAUUID* pPages)
{
- CheckPointer(pPages, E_POINTER);
+ CheckPointer(pPages, E_POINTER);
#ifdef REGISTER_FILTER
- pPages->cElems = 2;
+ pPages->cElems = 2;
#else
- pPages->cElems = 1;
+ pPages->cElems = 1;
#endif
- pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID) * pPages->cElems);
- pPages->pElems[0] = __uuidof(CMPCVideoDecSettingsWnd);
- if (pPages->cElems>1) {
- pPages->pElems[1] = __uuidof(CMPCVideoDecCodecWnd);
- }
+ pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID) * pPages->cElems);
+ pPages->pElems[0] = __uuidof(CMPCVideoDecSettingsWnd);
+ if (pPages->cElems > 1) {
+ pPages->pElems[1] = __uuidof(CMPCVideoDecCodecWnd);
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CMPCVideoDecFilter::CreatePage(const GUID& guid, IPropertyPage** ppPage)
{
- CheckPointer(ppPage, E_POINTER);
+ CheckPointer(ppPage, E_POINTER);
- if (*ppPage != NULL) {
- return E_INVALIDARG;
- }
+ if (*ppPage != NULL) {
+ return E_INVALIDARG;
+ }
- HRESULT hr;
+ HRESULT hr;
- if (guid == __uuidof(CMPCVideoDecSettingsWnd)) {
- (*ppPage = DNew CInternalPropertyPageTempl<CMPCVideoDecSettingsWnd>(NULL, &hr))->AddRef();
- } else if (guid == __uuidof(CMPCVideoDecCodecWnd)) {
- (*ppPage = DNew CInternalPropertyPageTempl<CMPCVideoDecCodecWnd>(NULL, &hr))->AddRef();
- }
+ if (guid == __uuidof(CMPCVideoDecSettingsWnd)) {
+ (*ppPage = DNew CInternalPropertyPageTempl<CMPCVideoDecSettingsWnd>(NULL, &hr))->AddRef();
+ } else if (guid == __uuidof(CMPCVideoDecCodecWnd)) {
+ (*ppPage = DNew CInternalPropertyPageTempl<CMPCVideoDecCodecWnd>(NULL, &hr))->AddRef();
+ }
- return *ppPage ? S_OK : E_FAIL;
+ return *ppPage ? S_OK : E_FAIL;
}
void CMPCVideoDecFilter::SetFrameType(FF_FIELD_TYPE nFrameType)
{
- m_nFrameType = nFrameType;
+ m_nFrameType = nFrameType;
}
// IFFmpegDecFilter
STDMETHODIMP CMPCVideoDecFilter::Apply()
{
#ifdef REGISTER_FILTER
- CRegKey key;
- if (ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPC Video Decoder"))) {
- key.SetDWORDValue(_T("ThreadNumber"), m_nThreadNumber);
- key.SetDWORDValue(_T("DiscardMode"), m_nDiscardMode);
- key.SetDWORDValue(_T("ErrorRecognition"), m_nErrorRecognition);
- key.SetDWORDValue(_T("IDCTAlgo"), m_nIDCTAlgo);
- key.SetDWORDValue(_T("ActiveCodecs"), m_nActiveCodecs);
- key.SetDWORDValue(_T("ARMode"), m_nARMode);
- key.SetDWORDValue(_T("DXVACheckCompatibility"), m_nDXVACheckCompatibility);
- key.SetDWORDValue(_T("DisableDXVA_SD"), m_nDXVA_SD);
- }
+ CRegKey key;
+ if (ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPC Video Decoder"))) {
+ key.SetDWORDValue(_T("ThreadNumber"), m_nThreadNumber);
+ key.SetDWORDValue(_T("DiscardMode"), m_nDiscardMode);
+ key.SetDWORDValue(_T("ErrorRecognition"), m_nErrorRecognition);
+ key.SetDWORDValue(_T("IDCTAlgo"), m_nIDCTAlgo);
+ key.SetDWORDValue(_T("ActiveCodecs"), m_nActiveCodecs);
+ key.SetDWORDValue(_T("ARMode"), m_nARMode);
+ key.SetDWORDValue(_T("DXVACheckCompatibility"), m_nDXVACheckCompatibility);
+ key.SetDWORDValue(_T("DisableDXVA_SD"), m_nDXVA_SD);
+ }
#else
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPC Video Decoder"), _T("ThreadNumber"), m_nThreadNumber);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPC Video Decoder"), _T("DiscardMode"), m_nDiscardMode);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPC Video Decoder"), _T("ErrorRecognition"), m_nErrorRecognition);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPC Video Decoder"), _T("IDCTAlgo"), m_nIDCTAlgo);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPC Video Decoder"), _T("ARMode"), m_nARMode);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPC Video Decoder"), _T("DXVACheckCompatibility"), m_nDXVACheckCompatibility);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPC Video Decoder"), _T("DisableDXVA_SD"), m_nDXVA_SD);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPC Video Decoder"), _T("ThreadNumber"), m_nThreadNumber);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPC Video Decoder"), _T("DiscardMode"), m_nDiscardMode);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPC Video Decoder"), _T("ErrorRecognition"), m_nErrorRecognition);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPC Video Decoder"), _T("IDCTAlgo"), m_nIDCTAlgo);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPC Video Decoder"), _T("ARMode"), m_nARMode);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPC Video Decoder"), _T("DXVACheckCompatibility"), m_nDXVACheckCompatibility);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPC Video Decoder"), _T("DisableDXVA_SD"), m_nDXVA_SD);
#endif
- return S_OK;
+ return S_OK;
}
// === IMPCVideoDecFilter
STDMETHODIMP CMPCVideoDecFilter::SetThreadNumber(int nValue)
{
- CAutoLock cAutoLock(&m_csProps);
- m_nThreadNumber = nValue;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_nThreadNumber = nValue;
+ return S_OK;
}
STDMETHODIMP_(int) CMPCVideoDecFilter::GetThreadNumber()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_nThreadNumber;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_nThreadNumber;
}
STDMETHODIMP CMPCVideoDecFilter::SetDiscardMode(int nValue)
{
- CAutoLock cAutoLock(&m_csProps);
- m_nDiscardMode = nValue;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_nDiscardMode = nValue;
+ return S_OK;
}
STDMETHODIMP_(int) CMPCVideoDecFilter::GetDiscardMode()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_nDiscardMode;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_nDiscardMode;
}
STDMETHODIMP CMPCVideoDecFilter::SetErrorRecognition(int nValue)
{
- CAutoLock cAutoLock(&m_csProps);
- m_nErrorRecognition = nValue;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_nErrorRecognition = nValue;
+ return S_OK;
}
STDMETHODIMP_(int) CMPCVideoDecFilter::GetErrorRecognition()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_nErrorRecognition;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_nErrorRecognition;
}
STDMETHODIMP CMPCVideoDecFilter::SetIDCTAlgo(int nValue)
{
- CAutoLock cAutoLock(&m_csProps);
- m_nIDCTAlgo = nValue;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_nIDCTAlgo = nValue;
+ return S_OK;
}
STDMETHODIMP_(int) CMPCVideoDecFilter::GetIDCTAlgo()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_nIDCTAlgo;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_nIDCTAlgo;
}
STDMETHODIMP_(GUID*) CMPCVideoDecFilter::GetDXVADecoderGuid()
{
- if (m_pGraph == NULL) {
- return NULL;
- } else {
- return &m_DXVADecoderGUID;
- }
+ if (m_pGraph == NULL) {
+ return NULL;
+ } else {
+ return &m_DXVADecoderGUID;
+ }
}
STDMETHODIMP CMPCVideoDecFilter::SetActiveCodecs(MPC_VIDEO_CODEC nValue)
{
- CAutoLock cAutoLock(&m_csProps);
- m_nActiveCodecs = (int)nValue;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_nActiveCodecs = (int)nValue;
+ return S_OK;
}
STDMETHODIMP_(MPC_VIDEO_CODEC) CMPCVideoDecFilter::GetActiveCodecs()
{
- CAutoLock cAutoLock(&m_csProps);
- return (MPC_VIDEO_CODEC)m_nActiveCodecs;
+ CAutoLock cAutoLock(&m_csProps);
+ return (MPC_VIDEO_CODEC)m_nActiveCodecs;
}
STDMETHODIMP_(LPCTSTR) CMPCVideoDecFilter::GetVideoCardDescription()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_strDeviceDescription;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_strDeviceDescription;
}
STDMETHODIMP CMPCVideoDecFilter::SetARMode(int nValue)
{
- CAutoLock cAutoLock(&m_csProps);
- m_nARMode = nValue;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_nARMode = nValue;
+ return S_OK;
}
STDMETHODIMP_(int) CMPCVideoDecFilter::GetARMode()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_nARMode;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_nARMode;
}
STDMETHODIMP CMPCVideoDecFilter::SetDXVACheckCompatibility(int nValue)
{
- CAutoLock cAutoLock(&m_csProps);
- m_nDXVACheckCompatibility = nValue;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_nDXVACheckCompatibility = nValue;
+ return S_OK;
}
STDMETHODIMP_(int) CMPCVideoDecFilter::GetDXVACheckCompatibility()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_nDXVACheckCompatibility;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_nDXVACheckCompatibility;
}
STDMETHODIMP CMPCVideoDecFilter::SetDXVA_SD(int nValue)
{
- CAutoLock cAutoLock(&m_csProps);
- m_nDXVA_SD = nValue;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_nDXVA_SD = nValue;
+ return S_OK;
}
STDMETHODIMP_(int) CMPCVideoDecFilter::GetDXVA_SD()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_nDXVA_SD;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_nDXVA_SD;
}
// === IMPCVideoDecFilter2
STDMETHODIMP_(int) CMPCVideoDecFilter::GetFrameType()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_nFrameType;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_nFrameType;
}
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.h b/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.h
index 1444d4ba0..0aea7ed57 100644
--- a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.h
+++ b/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.h
@@ -23,9 +23,9 @@
#pragma once
#include <d3dx9.h>
-#include <videoacc.h> // DXVA1
+#include <videoacc.h> // DXVA1
#include <dxva.h>
-#include <dxva2api.h> // DXVA2
+#include <dxva2api.h> // DXVA2
#include "../BaseVideoFilter/BaseVideoFilter.h"
#include "IMPCVideoDecFilter.h"
@@ -51,269 +51,269 @@ struct SwsContext;
class CCpuId;
typedef enum {
- MODE_SOFTWARE,
- MODE_DXVA1,
- MODE_DXVA2
+ MODE_SOFTWARE,
+ MODE_DXVA1,
+ MODE_DXVA2
} DXVA_MODE;
typedef struct {
- REFERENCE_TIME rtStart;
- REFERENCE_TIME rtStop;
+ REFERENCE_TIME rtStart;
+ REFERENCE_TIME rtStop;
} B_FRAME;
typedef struct {
- REFERENCE_TIME rtStart;
- REFERENCE_TIME rtStop;
- int nBuffPos;
+ REFERENCE_TIME rtStart;
+ REFERENCE_TIME rtStop;
+ int nBuffPos;
} BUFFER_TIME;
typedef struct {
- bool video_after_seek;
- __int32 kf_pts; ///< timestamp of next video keyframe
- __int64 kf_base; ///< timestamp of the prev. video keyframe
+ bool video_after_seek;
+ __int32 kf_pts; ///< timestamp of next video keyframe
+ __int64 kf_base; ///< timestamp of the prev. video keyframe
} RMDemuxContext;
class __declspec(uuid("008BAC12-FBAF-497b-9670-BC6F6FBAE2C4"))
- CMPCVideoDecFilter
- : public CBaseVideoFilter
- , public TlibavcodecExt
- , public ISpecifyPropertyPages2
- , public IMPCVideoDecFilter
- , public IMPCVideoDecFilter2
+ CMPCVideoDecFilter
+ : public CBaseVideoFilter
+ , public TlibavcodecExt
+ , public ISpecifyPropertyPages2
+ , public IMPCVideoDecFilter
+ , public IMPCVideoDecFilter2
{
protected:
- // === FFMpeg callbacks
- static void LogLibavcodec(void* par,int level,const char *fmt,va_list valist);
- virtual void OnGetBuffer(AVFrame *pic);
-
- friend class CVideoDecDXVAAllocator;
-
- CCpuId* m_pCpuId;
- CCritSec m_csProps;
-
- // === Persistants parameters (registry)
- int m_nThreadNumber;
- int m_nDiscardMode;
- int m_nErrorRecognition;
- int m_nIDCTAlgo;
- bool m_bDXVACompatible;
- int m_nActiveCodecs;
- int m_nARMode;
- int m_nDXVACheckCompatibility;
- int m_nDXVA_SD;
-
- FF_FIELD_TYPE m_nFrameType;
-
- // === FFMpeg variables
- AVCodec* m_pAVCodec;
- AVCodecContext* m_pAVCtx;
- AVFrame* m_pFrame;
- int m_nCodecNb;
- enum CodecID m_nCodecId;
- int m_nWorkaroundBug;
- int m_nErrorConcealment;
- REFERENCE_TIME m_rtAvrTimePerFrame;
- bool m_bReorderBFrame;
- B_FRAME m_BFrames[2];
- int m_nPosB;
- int m_nWidth; // Frame width give to input pin
- int m_nHeight; // Frame height give to input pin
-
- bool m_bTheoraMTSupport;
- bool m_bIsEVO;
-
- // Buffer management for truncated stream (store stream chunks & reference time sent by splitter)
- BYTE* m_pFFBuffer;
- int m_nFFBufferSize;
- BYTE* m_pAlignedFFBuffer;
- int m_nAlignedFFBufferSize;
-
- int m_nFFBufferPos;
- int m_nFFPicEnd;
- BUFFER_TIME m_FFBufferTime[MAX_BUFF_TIME];
-
- REFERENCE_TIME m_rtLastStart; // rtStart for last delivered frame
- int m_nCountEstimated; // Number of rtStart estimated since last rtStart received
- double m_dRate;
- REFERENCE_TIME m_rtPrevStop;
- bool m_bFrame_repeat_pict;
-
- bool m_bUseDXVA;
- bool m_bUseFFmpeg;
- CSize m_sar;
- SwsContext* m_pSwsContext;
- unsigned __int64 m_nOutCsp;
- CSize m_pOutSize; // Picture size on output pin
- int m_nSwOutBpp;
-
- // === DXVA common variables
- VIDEO_OUTPUT_FORMATS* m_pVideoOutputFormat;
- int m_nVideoOutputCount;
- DXVA_MODE m_nDXVAMode;
- CDXVADecoder* m_pDXVADecoder;
- GUID m_DXVADecoderGUID;
-
- DWORD m_nPCIVendor;
- DWORD m_nPCIDevice;
- LARGE_INTEGER m_VideoDriverVersion;
- CString m_strDeviceDescription;
-
- // === DXVA1 variables
- DDPIXELFORMAT m_PixelFormat;
-
- // === DXVA2 variables
- CComPtr<IDirect3DDeviceManager9> m_pDeviceManager;
- CComPtr<IDirectXVideoDecoderService> m_pDecoderService;
- CComPtr<IDirect3DSurface9> m_pDecoderRenderTarget;
- DXVA2_ConfigPictureDecode m_DXVA2Config;
- HANDLE m_hDevice;
- DXVA2_VideoDesc m_VideoDesc;
-
- CH264RandomAccess m_h264RandomAccess;
-
- BOOL m_bWaitingForKeyFrame;
-
- RMDemuxContext rm;
- REFERENCE_TIME m_rtStart;
-
- // === Private functions
- void Cleanup();
- int FindCodec(const CMediaType* mtIn);
- void AllocExtradata(AVCodecContext* pAVCtx, const CMediaType* mt);
- bool IsMultiThreadSupported(enum CodecID nCodec);
- void GetOutputFormats (int& nNumber, VIDEO_OUTPUT_FORMATS** ppFormats);
- void CalcAvgTimePerFrame();
- void DetectVideoCard(HWND hWnd);
- unsigned __int64 GetCspFromMediaType(GUID& subtype);
- void InitSwscale();
-
- void SetTypeSpecificFlags(IMediaSample* pMS);
- HRESULT SoftwareDecode(IMediaSample* pIn, BYTE* pDataIn, int nSize, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
- bool AppendBuffer (BYTE* pDataIn, int nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
- bool FindPicture(int nIndex, int nStartCode);
- void ShrinkBuffer();
- void ResetBuffer();
- void PushBufferTime(int nPos, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
- void PopBufferTime(int nPos);
+ // === FFMpeg callbacks
+ static void LogLibavcodec(void* par, int level, const char* fmt, va_list valist);
+ virtual void OnGetBuffer(AVFrame* pic);
+
+ friend class CVideoDecDXVAAllocator;
+
+ CCpuId* m_pCpuId;
+ CCritSec m_csProps;
+
+ // === Persistants parameters (registry)
+ int m_nThreadNumber;
+ int m_nDiscardMode;
+ int m_nErrorRecognition;
+ int m_nIDCTAlgo;
+ bool m_bDXVACompatible;
+ int m_nActiveCodecs;
+ int m_nARMode;
+ int m_nDXVACheckCompatibility;
+ int m_nDXVA_SD;
+
+ FF_FIELD_TYPE m_nFrameType;
+
+ // === FFMpeg variables
+ AVCodec* m_pAVCodec;
+ AVCodecContext* m_pAVCtx;
+ AVFrame* m_pFrame;
+ int m_nCodecNb;
+ enum CodecID m_nCodecId;
+ int m_nWorkaroundBug;
+ int m_nErrorConcealment;
+ REFERENCE_TIME m_rtAvrTimePerFrame;
+ bool m_bReorderBFrame;
+ B_FRAME m_BFrames[2];
+ int m_nPosB;
+ int m_nWidth; // Frame width give to input pin
+ int m_nHeight; // Frame height give to input pin
+
+ bool m_bTheoraMTSupport;
+ bool m_bIsEVO;
+
+ // Buffer management for truncated stream (store stream chunks & reference time sent by splitter)
+ BYTE* m_pFFBuffer;
+ int m_nFFBufferSize;
+ BYTE* m_pAlignedFFBuffer;
+ int m_nAlignedFFBufferSize;
+
+ int m_nFFBufferPos;
+ int m_nFFPicEnd;
+ BUFFER_TIME m_FFBufferTime[MAX_BUFF_TIME];
+
+ REFERENCE_TIME m_rtLastStart; // rtStart for last delivered frame
+ int m_nCountEstimated; // Number of rtStart estimated since last rtStart received
+ double m_dRate;
+ REFERENCE_TIME m_rtPrevStop;
+ bool m_bFrame_repeat_pict;
+
+ bool m_bUseDXVA;
+ bool m_bUseFFmpeg;
+ CSize m_sar;
+ SwsContext* m_pSwsContext;
+ unsigned __int64 m_nOutCsp;
+ CSize m_pOutSize; // Picture size on output pin
+ int m_nSwOutBpp;
+
+ // === DXVA common variables
+ VIDEO_OUTPUT_FORMATS* m_pVideoOutputFormat;
+ int m_nVideoOutputCount;
+ DXVA_MODE m_nDXVAMode;
+ CDXVADecoder* m_pDXVADecoder;
+ GUID m_DXVADecoderGUID;
+
+ DWORD m_nPCIVendor;
+ DWORD m_nPCIDevice;
+ LARGE_INTEGER m_VideoDriverVersion;
+ CString m_strDeviceDescription;
+
+ // === DXVA1 variables
+ DDPIXELFORMAT m_PixelFormat;
+
+ // === DXVA2 variables
+ CComPtr<IDirect3DDeviceManager9> m_pDeviceManager;
+ CComPtr<IDirectXVideoDecoderService> m_pDecoderService;
+ CComPtr<IDirect3DSurface9> m_pDecoderRenderTarget;
+ DXVA2_ConfigPictureDecode m_DXVA2Config;
+ HANDLE m_hDevice;
+ DXVA2_VideoDesc m_VideoDesc;
+
+ CH264RandomAccess m_h264RandomAccess;
+
+ BOOL m_bWaitingForKeyFrame;
+
+ RMDemuxContext rm;
+ REFERENCE_TIME m_rtStart;
+
+ // === Private functions
+ void Cleanup();
+ int FindCodec(const CMediaType* mtIn);
+ void AllocExtradata(AVCodecContext* pAVCtx, const CMediaType* mt);
+ bool IsMultiThreadSupported(enum CodecID nCodec);
+ void GetOutputFormats(int& nNumber, VIDEO_OUTPUT_FORMATS** ppFormats);
+ void CalcAvgTimePerFrame();
+ void DetectVideoCard(HWND hWnd);
+ unsigned __int64 GetCspFromMediaType(GUID& subtype);
+ void InitSwscale();
+
+ void SetTypeSpecificFlags(IMediaSample* pMS);
+ HRESULT SoftwareDecode(IMediaSample* pIn, BYTE* pDataIn, int nSize, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
+ bool AppendBuffer(BYTE* pDataIn, int nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
+ bool FindPicture(int nIndex, int nStartCode);
+ void ShrinkBuffer();
+ void ResetBuffer();
+ void PushBufferTime(int nPos, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
+ void PopBufferTime(int nPos);
public:
- const static AMOVIESETUP_MEDIATYPE sudPinTypesIn[];
- const static int sudPinTypesInCount;
- const static AMOVIESETUP_MEDIATYPE sudPinTypesOut[];
- const static int sudPinTypesOutCount;
-
- static bool* FFmpegFilters;
- static bool* DXVAFilters;
-
- CMPCVideoDecFilter(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CMPCVideoDecFilter();
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- virtual bool IsVideoInterlaced();
- virtual void GetOutputSize(int& w, int& h, int& arx, int& ary, int& RealWidth, int& RealHeight);
- CTransformOutputPin* GetOutputPin() {
- return m_pOutput;
- }
-
- void UpdateFrameTime (REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop, bool b_repeat_pict = false);
- CString GetFileExtension();
-
- // === Overriden DirectShow functions
- HRESULT SetMediaType(PIN_DIRECTION direction,const CMediaType *pmt);
- HRESULT CheckInputType(const CMediaType* mtIn);
- HRESULT Transform(IMediaSample* pIn);
- HRESULT CompleteConnect(PIN_DIRECTION direction,IPin *pReceivePin);
- HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT BeginFlush();
- HRESULT EndFlush();
- HRESULT NewSegment(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, double dRate);
- HRESULT EndOfStream();
-
- HRESULT BreakConnect(PIN_DIRECTION dir);
-
-
- // === ISpecifyPropertyPages2
-
- STDMETHODIMP GetPages(CAUUID* pPages);
- STDMETHODIMP CreatePage(const GUID& guid, IPropertyPage** ppPage);
-
- // === IMPCVideoDecFilter
- STDMETHODIMP Apply();
- STDMETHODIMP SetThreadNumber(int nValue);
- STDMETHODIMP_(int) GetThreadNumber();
- STDMETHOD(SetDiscardMode(int nValue));
- STDMETHOD_(int, GetDiscardMode());
- STDMETHOD(SetErrorRecognition(int nValue));
- STDMETHOD_(int, GetErrorRecognition());
- STDMETHOD(SetIDCTAlgo(int nValue));
- STDMETHOD_(int, GetIDCTAlgo());
- STDMETHOD_(GUID*, GetDXVADecoderGuid());
- STDMETHOD(SetActiveCodecs(MPC_VIDEO_CODEC nValue));
- STDMETHOD_(MPC_VIDEO_CODEC, GetActiveCodecs());
- STDMETHODIMP_(LPCTSTR) GetVideoCardDescription();
-
- STDMETHOD(SetARMode(int nValue));
- STDMETHOD_(int, GetARMode());
-
- STDMETHOD(SetDXVACheckCompatibility(int nValue));
- STDMETHOD_(int, GetDXVACheckCompatibility());
-
- STDMETHOD(SetDXVA_SD(int nValue));
- STDMETHOD_(int, GetDXVA_SD());
-
- // === IMPCVideoDecFilter2
- STDMETHOD_(int, GetFrameType());
-
- // === DXVA common functions
- BOOL IsSupportedDecoderConfig(const D3DFORMAT nD3DFormat, const DXVA2_ConfigPictureDecode& config, bool& bIsPrefered);
- BOOL IsSupportedDecoderMode(const GUID& mode);
- void BuildDXVAOutputFormat();
- int GetPicEntryNumber();
- int PictWidth();
- int PictHeight();
- int PictWidthRounded();
- int PictHeightRounded();
-
- inline bool UseDXVA2() { return (m_nDXVAMode == MODE_DXVA2); };
- inline AVCodecContext* GetAVCtx() { return m_pAVCtx; };
- inline AVFrame* GetFrame() { return m_pFrame; };
- inline enum CodecID GetCodec() { return m_nCodecId; };
- inline bool IsReorderBFrame() { return m_bReorderBFrame; };
- inline bool IsEvo() { return m_bIsEVO; };
- inline DWORD GetPCIVendor() { return m_nPCIVendor; };
- inline REFERENCE_TIME GetAvrTimePerFrame() { return m_rtAvrTimePerFrame; };
- inline double GetRate() { return m_dRate; };
- bool IsDXVASupported();
- void UpdateAspectRatio();
- void ReorderBFrames(REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
- void FlushDXVADecoder() {
- if (m_pDXVADecoder) {
- m_pDXVADecoder->Flush();
- }
- }
-
- void SetFrameType(FF_FIELD_TYPE nFrameType);
-
- // === DXVA1 functions
- DDPIXELFORMAT* GetPixelFormat() { return &m_PixelFormat; }
- HRESULT FindDXVA1DecoderConfiguration(IAMVideoAccelerator* pAMVideoAccelerator, const GUID* guidDecoder, DDPIXELFORMAT* pPixelFormat);
- HRESULT CheckDXVA1Decoder(const GUID *pGuid);
- void SetDXVA1Params(const GUID* pGuid, DDPIXELFORMAT* pPixelFormat);
- WORD GetDXVA1RestrictedMode();
- HRESULT CreateDXVA1Decoder(IAMVideoAccelerator* pAMVideoAccelerator, const GUID* pDecoderGuid, DWORD dwSurfaceCount);
-
-
- // === DXVA2 functions
- void FillInVideoDescription(DXVA2_VideoDesc *pDesc);
- DXVA2_ConfigPictureDecode* GetDXVA2Config() { return &m_DXVA2Config; };
- HRESULT ConfigureDXVA2(IPin *pPin);
- HRESULT SetEVRForDXVA2(IPin *pPin);
- HRESULT FindDXVA2DecoderConfiguration(IDirectXVideoDecoderService *pDecoderService,
- const GUID& guidDecoder,
- DXVA2_ConfigPictureDecode *pSelectedConfig,
- BOOL *pbFoundDXVA2Configuration);
- HRESULT CreateDXVA2Decoder(UINT nNumRenderTargets, IDirect3DSurface9** pDecoderRenderTargets);
+ const static AMOVIESETUP_MEDIATYPE sudPinTypesIn[];
+ const static int sudPinTypesInCount;
+ const static AMOVIESETUP_MEDIATYPE sudPinTypesOut[];
+ const static int sudPinTypesOutCount;
+
+ static bool* FFmpegFilters;
+ static bool* DXVAFilters;
+
+ CMPCVideoDecFilter(LPUNKNOWN lpunk, HRESULT* phr);
+ virtual ~CMPCVideoDecFilter();
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ virtual bool IsVideoInterlaced();
+ virtual void GetOutputSize(int& w, int& h, int& arx, int& ary, int& RealWidth, int& RealHeight);
+ CTransformOutputPin* GetOutputPin() {
+ return m_pOutput;
+ }
+
+ void UpdateFrameTime(REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop, bool b_repeat_pict = false);
+ CString GetFileExtension();
+
+ // === Overriden DirectShow functions
+ HRESULT SetMediaType(PIN_DIRECTION direction, const CMediaType* pmt);
+ HRESULT CheckInputType(const CMediaType* mtIn);
+ HRESULT Transform(IMediaSample* pIn);
+ HRESULT CompleteConnect(PIN_DIRECTION direction, IPin* pReceivePin);
+ HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT BeginFlush();
+ HRESULT EndFlush();
+ HRESULT NewSegment(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, double dRate);
+ HRESULT EndOfStream();
+
+ HRESULT BreakConnect(PIN_DIRECTION dir);
+
+
+ // === ISpecifyPropertyPages2
+
+ STDMETHODIMP GetPages(CAUUID* pPages);
+ STDMETHODIMP CreatePage(const GUID& guid, IPropertyPage** ppPage);
+
+ // === IMPCVideoDecFilter
+ STDMETHODIMP Apply();
+ STDMETHODIMP SetThreadNumber(int nValue);
+ STDMETHODIMP_(int) GetThreadNumber();
+ STDMETHOD(SetDiscardMode(int nValue));
+ STDMETHOD_(int, GetDiscardMode());
+ STDMETHOD(SetErrorRecognition(int nValue));
+ STDMETHOD_(int, GetErrorRecognition());
+ STDMETHOD(SetIDCTAlgo(int nValue));
+ STDMETHOD_(int, GetIDCTAlgo());
+ STDMETHOD_(GUID*, GetDXVADecoderGuid());
+ STDMETHOD(SetActiveCodecs(MPC_VIDEO_CODEC nValue));
+ STDMETHOD_(MPC_VIDEO_CODEC, GetActiveCodecs());
+ STDMETHODIMP_(LPCTSTR) GetVideoCardDescription();
+
+ STDMETHOD(SetARMode(int nValue));
+ STDMETHOD_(int, GetARMode());
+
+ STDMETHOD(SetDXVACheckCompatibility(int nValue));
+ STDMETHOD_(int, GetDXVACheckCompatibility());
+
+ STDMETHOD(SetDXVA_SD(int nValue));
+ STDMETHOD_(int, GetDXVA_SD());
+
+ // === IMPCVideoDecFilter2
+ STDMETHOD_(int, GetFrameType());
+
+ // === DXVA common functions
+ BOOL IsSupportedDecoderConfig(const D3DFORMAT nD3DFormat, const DXVA2_ConfigPictureDecode& config, bool& bIsPrefered);
+ BOOL IsSupportedDecoderMode(const GUID& mode);
+ void BuildDXVAOutputFormat();
+ int GetPicEntryNumber();
+ int PictWidth();
+ int PictHeight();
+ int PictWidthRounded();
+ int PictHeightRounded();
+
+ inline bool UseDXVA2() { return (m_nDXVAMode == MODE_DXVA2); };
+ inline AVCodecContext* GetAVCtx() { return m_pAVCtx; };
+ inline AVFrame* GetFrame() { return m_pFrame; };
+ inline enum CodecID GetCodec() { return m_nCodecId; };
+ inline bool IsReorderBFrame() { return m_bReorderBFrame; };
+ inline bool IsEvo() { return m_bIsEVO; };
+ inline DWORD GetPCIVendor() { return m_nPCIVendor; };
+ inline REFERENCE_TIME GetAvrTimePerFrame() { return m_rtAvrTimePerFrame; };
+ inline double GetRate() { return m_dRate; };
+ bool IsDXVASupported();
+ void UpdateAspectRatio();
+ void ReorderBFrames(REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
+ void FlushDXVADecoder() {
+ if (m_pDXVADecoder) {
+ m_pDXVADecoder->Flush();
+ }
+ }
+
+ void SetFrameType(FF_FIELD_TYPE nFrameType);
+
+ // === DXVA1 functions
+ DDPIXELFORMAT* GetPixelFormat() { return &m_PixelFormat; }
+ HRESULT FindDXVA1DecoderConfiguration(IAMVideoAccelerator* pAMVideoAccelerator, const GUID* guidDecoder, DDPIXELFORMAT* pPixelFormat);
+ HRESULT CheckDXVA1Decoder(const GUID* pGuid);
+ void SetDXVA1Params(const GUID* pGuid, DDPIXELFORMAT* pPixelFormat);
+ WORD GetDXVA1RestrictedMode();
+ HRESULT CreateDXVA1Decoder(IAMVideoAccelerator* pAMVideoAccelerator, const GUID* pDecoderGuid, DWORD dwSurfaceCount);
+
+
+ // === DXVA2 functions
+ void FillInVideoDescription(DXVA2_VideoDesc* pDesc);
+ DXVA2_ConfigPictureDecode* GetDXVA2Config() { return &m_DXVA2Config; };
+ HRESULT ConfigureDXVA2(IPin* pPin);
+ HRESULT SetEVRForDXVA2(IPin* pPin);
+ HRESULT FindDXVA2DecoderConfiguration(IDirectXVideoDecoderService* pDecoderService,
+ const GUID& guidDecoder,
+ DXVA2_ConfigPictureDecode* pSelectedConfig,
+ BOOL* pbFoundDXVA2Configuration);
+ HRESULT CreateDXVA2Decoder(UINT nNumRenderTargets, IDirect3DSurface9** pDecoderRenderTargets);
};
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.cpp b/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.cpp
index eecf3e6b3..a8b8d6a12 100644
--- a/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.cpp
+++ b/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.cpp
@@ -32,44 +32,44 @@
// ==>>> Resource identifier from "resource.h" present in mplayerc project!
#define ResStr(id) CString(MAKEINTRESOURCE(id))
-#define LEFT_SPACING 20
-#define VERTICAL_SPACING 25
+#define LEFT_SPACING 20
+#define VERTICAL_SPACING 25
//
// CMPCVideoDecSettingsWnd
//
int g_AVDiscard[] = {
- AVDISCARD_NONE,
- AVDISCARD_DEFAULT,
- AVDISCARD_NONREF,
- AVDISCARD_BIDIR,
- AVDISCARD_NONKEY,
- AVDISCARD_ALL,
+ AVDISCARD_NONE,
+ AVDISCARD_DEFAULT,
+ AVDISCARD_NONREF,
+ AVDISCARD_BIDIR,
+ AVDISCARD_NONKEY,
+ AVDISCARD_ALL,
};
int FindDiscardIndex(int nValue)
{
- for (int i=0; i<_countof (g_AVDiscard); i++)
- if (g_AVDiscard[i] == nValue) {
- return i;
- }
- return 1;
+ for (int i = 0; i < _countof(g_AVDiscard); i++)
+ if (g_AVDiscard[i] == nValue) {
+ return i;
+ }
+ return 1;
}
int g_AVErrRecognition[] = {
- AV_EF_CAREFUL,
- AV_EF_COMPLIANT,
- AV_EF_AGGRESSIVE,
+ AV_EF_CAREFUL,
+ AV_EF_COMPLIANT,
+ AV_EF_AGGRESSIVE,
};
int FindErrRecognitionIndex(int nValue)
{
- for (int i=0; i<_countof (g_AVErrRecognition); i++)
- if (g_AVErrRecognition[i] == nValue) {
- return i;
- }
- return 1;
+ for (int i = 0; i < _countof(g_AVErrRecognition); i++)
+ if (g_AVErrRecognition[i] == nValue) {
+ return i;
+ }
+ return 1;
}
CMPCVideoDecSettingsWnd::CMPCVideoDecSettingsWnd()
@@ -78,146 +78,146 @@ CMPCVideoDecSettingsWnd::CMPCVideoDecSettingsWnd()
bool CMPCVideoDecSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
{
- ASSERT(!m_pMDF);
+ ASSERT(!m_pMDF);
- m_pMDF.Release();
+ m_pMDF.Release();
- POSITION pos = pUnks.GetHeadPosition();
- while (pos && !(m_pMDF = pUnks.GetNext(pos))) {
- ;
- }
+ POSITION pos = pUnks.GetHeadPosition();
+ while (pos && !(m_pMDF = pUnks.GetNext(pos))) {
+ ;
+ }
- if (!m_pMDF) {
- return false;
- }
+ if (!m_pMDF) {
+ return false;
+ }
- return true;
+ return true;
}
void CMPCVideoDecSettingsWnd::OnDisconnect()
{
- m_pMDF.Release();
+ m_pMDF.Release();
}
bool CMPCVideoDecSettingsWnd::OnActivate()
{
- int nPosY = 10;
- GUID* DxvaGui = NULL;
+ int nPosY = 10;
+ GUID* DxvaGui = NULL;
#if HAS_FFMPEG_VIDEO_DECODERS
- m_grpFFMpeg.Create (ResStr (IDS_VDF_FFSETTINGS), WS_VISIBLE|WS_CHILD | BS_GROUPBOX, CRect (5, nPosY, 350, nPosY+150), this, (UINT)IDC_STATIC);
-
- // Decoding threads
- nPosY += VERTICAL_SPACING;
- m_txtThreadNumber.Create (ResStr (IDS_VDF_THREADNUMBER), WS_VISIBLE|WS_CHILD, CRect (LEFT_SPACING, nPosY, 220, nPosY+15), this, (UINT)IDC_STATIC);
- m_cbThreadNumber.Create (WS_VISIBLE|WS_CHILD|CBS_DROPDOWNLIST|WS_VSCROLL, CRect (230, nPosY-4, 345, nPosY+90), this, IDC_PP_THREAD_NUMBER);
- m_cbThreadNumber.AddString(ResStr(IDS_VDF_IDCT_AUTO));
- CString ThreadNumberStr;
- for (int i=0; i<16; i++) {
- ThreadNumberStr.Format(_T("%d"), i+1);
- m_cbThreadNumber.AddString(ThreadNumberStr);
- }
+ m_grpFFMpeg.Create(ResStr(IDS_VDF_FFSETTINGS), WS_VISIBLE | WS_CHILD | BS_GROUPBOX, CRect(5, nPosY, 350, nPosY + 150), this, (UINT)IDC_STATIC);
+
+ // Decoding threads
+ nPosY += VERTICAL_SPACING;
+ m_txtThreadNumber.Create(ResStr(IDS_VDF_THREADNUMBER), WS_VISIBLE | WS_CHILD, CRect(LEFT_SPACING, nPosY, 220, nPosY + 15), this, (UINT)IDC_STATIC);
+ m_cbThreadNumber.Create(WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST | WS_VSCROLL, CRect(230, nPosY - 4, 345, nPosY + 90), this, IDC_PP_THREAD_NUMBER);
+ m_cbThreadNumber.AddString(ResStr(IDS_VDF_IDCT_AUTO));
+ CString ThreadNumberStr;
+ for (int i = 0; i < 16; i++) {
+ ThreadNumberStr.Format(_T("%d"), i + 1);
+ m_cbThreadNumber.AddString(ThreadNumberStr);
+ }
#if INTERNAL_DECODER_H264
- // H264 deblocking mode
- nPosY += VERTICAL_SPACING;
- m_txtDiscardMode.Create (ResStr (IDS_VDF_SKIPDEBLOCK), WS_VISIBLE|WS_CHILD, CRect (LEFT_SPACING, nPosY, 220, nPosY+15), this, (UINT)IDC_STATIC);
- m_cbDiscardMode.Create (WS_VISIBLE|WS_CHILD|CBS_DROPDOWNLIST|WS_VSCROLL, CRect (230, nPosY-4, 345, nPosY+90), this, IDC_PP_DISCARD_MODE);
- m_cbDiscardMode.AddString (ResStr (IDS_VDF_DBLK_NONE));
- m_cbDiscardMode.AddString (ResStr (IDS_VDF_DBLK_DEFAULT));
- m_cbDiscardMode.AddString (ResStr (IDS_VDF_DBLK_NONREF));
- m_cbDiscardMode.AddString (ResStr (IDS_VDF_DBLK_BIDIR));
- m_cbDiscardMode.AddString (ResStr (IDS_VDF_DBLK_NONKFRM));
- m_cbDiscardMode.AddString (ResStr (IDS_VDF_DBLK_ALL));
+ // H264 deblocking mode
+ nPosY += VERTICAL_SPACING;
+ m_txtDiscardMode.Create(ResStr(IDS_VDF_SKIPDEBLOCK), WS_VISIBLE | WS_CHILD, CRect(LEFT_SPACING, nPosY, 220, nPosY + 15), this, (UINT)IDC_STATIC);
+ m_cbDiscardMode.Create(WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST | WS_VSCROLL, CRect(230, nPosY - 4, 345, nPosY + 90), this, IDC_PP_DISCARD_MODE);
+ m_cbDiscardMode.AddString(ResStr(IDS_VDF_DBLK_NONE));
+ m_cbDiscardMode.AddString(ResStr(IDS_VDF_DBLK_DEFAULT));
+ m_cbDiscardMode.AddString(ResStr(IDS_VDF_DBLK_NONREF));
+ m_cbDiscardMode.AddString(ResStr(IDS_VDF_DBLK_BIDIR));
+ m_cbDiscardMode.AddString(ResStr(IDS_VDF_DBLK_NONKFRM));
+ m_cbDiscardMode.AddString(ResStr(IDS_VDF_DBLK_ALL));
#endif /* INTERNAL_DECODER_H264 */
- // Error recognition
- nPosY += VERTICAL_SPACING;
- m_txtErrorRecognition.Create (ResStr (IDS_VDF_ERROR_RECOGNITION), WS_VISIBLE|WS_CHILD, CRect (LEFT_SPACING, nPosY, 220, nPosY+15), this, (UINT)IDC_STATIC);
- m_cbErrorRecognition.Create (WS_VISIBLE|WS_CHILD|CBS_DROPDOWNLIST|WS_VSCROLL, CRect (230, nPosY-4, 345, nPosY+90), this, IDC_PP_DISCARD_MODE);
- m_cbErrorRecognition.AddString (ResStr (IDS_VDF_ERR_CAREFUL));
- m_cbErrorRecognition.AddString (ResStr (IDS_VDF_ERR_COMPLIANT));
- m_cbErrorRecognition.AddString (ResStr (IDS_VDF_ERR_AGGRESSIVE));
-
- // IDCT Algo
- nPosY += VERTICAL_SPACING;
- m_txtIDCTAlgo.Create (ResStr (IDS_VDF_IDCT_ALGO), WS_VISIBLE|WS_CHILD, CRect (LEFT_SPACING, nPosY, 220, nPosY+15), this, (UINT)IDC_STATIC);
- m_cbIDCTAlgo.Create (WS_VISIBLE|WS_CHILD|CBS_DROPDOWNLIST|WS_VSCROLL, CRect (230, nPosY-4, 345, nPosY+90), this, IDC_PP_DISCARD_MODE);
- m_cbIDCTAlgo.AddString (ResStr (IDS_VDF_IDCT_AUTO));
- m_cbIDCTAlgo.AddString (ResStr (IDS_VDF_IDCT_LIBMPEG2));
- m_cbIDCTAlgo.AddString (ResStr (IDS_VDF_IDCT_SIMPLE_MMX));
- m_cbIDCTAlgo.AddString (ResStr (IDS_VDF_IDCT_XVID));
- m_cbIDCTAlgo.AddString (ResStr (IDS_VDF_IDCT_SIMPLE));
-
- nPosY += VERTICAL_SPACING;
- m_cbARMode.Create (ResStr (IDS_VDF_AR_MODE), WS_VISIBLE|WS_CHILD|BS_AUTOCHECKBOX|BS_LEFTTEXT, CRect (LEFT_SPACING, nPosY, 345, nPosY+15), this, IDC_PP_AR);
- m_cbARMode.SetCheck(FALSE);
-
- nPosY = 170;
+ // Error recognition
+ nPosY += VERTICAL_SPACING;
+ m_txtErrorRecognition.Create(ResStr(IDS_VDF_ERROR_RECOGNITION), WS_VISIBLE | WS_CHILD, CRect(LEFT_SPACING, nPosY, 220, nPosY + 15), this, (UINT)IDC_STATIC);
+ m_cbErrorRecognition.Create(WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST | WS_VSCROLL, CRect(230, nPosY - 4, 345, nPosY + 90), this, IDC_PP_DISCARD_MODE);
+ m_cbErrorRecognition.AddString(ResStr(IDS_VDF_ERR_CAREFUL));
+ m_cbErrorRecognition.AddString(ResStr(IDS_VDF_ERR_COMPLIANT));
+ m_cbErrorRecognition.AddString(ResStr(IDS_VDF_ERR_AGGRESSIVE));
+
+ // IDCT Algo
+ nPosY += VERTICAL_SPACING;
+ m_txtIDCTAlgo.Create(ResStr(IDS_VDF_IDCT_ALGO), WS_VISIBLE | WS_CHILD, CRect(LEFT_SPACING, nPosY, 220, nPosY + 15), this, (UINT)IDC_STATIC);
+ m_cbIDCTAlgo.Create(WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST | WS_VSCROLL, CRect(230, nPosY - 4, 345, nPosY + 90), this, IDC_PP_DISCARD_MODE);
+ m_cbIDCTAlgo.AddString(ResStr(IDS_VDF_IDCT_AUTO));
+ m_cbIDCTAlgo.AddString(ResStr(IDS_VDF_IDCT_LIBMPEG2));
+ m_cbIDCTAlgo.AddString(ResStr(IDS_VDF_IDCT_SIMPLE_MMX));
+ m_cbIDCTAlgo.AddString(ResStr(IDS_VDF_IDCT_XVID));
+ m_cbIDCTAlgo.AddString(ResStr(IDS_VDF_IDCT_SIMPLE));
+
+ nPosY += VERTICAL_SPACING;
+ m_cbARMode.Create(ResStr(IDS_VDF_AR_MODE), WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX | BS_LEFTTEXT, CRect(LEFT_SPACING, nPosY, 345, nPosY + 15), this, IDC_PP_AR);
+ m_cbARMode.SetCheck(FALSE);
+
+ nPosY = 170;
#endif /* HAS_FFMPEG_VIDEO_DECODERS */
- m_grpDXVA.Create (ResStr (IDS_VDF_DXVA_SETTING), WS_VISIBLE|WS_CHILD | BS_GROUPBOX, CRect (5, nPosY, 350, nPosY+135), this, (UINT)IDC_STATIC);
-
- // DXVA Compatibility check
- nPosY += VERTICAL_SPACING;
- m_txtDXVACompatibilityCheck.Create (ResStr (IDS_VDF_DXVACOMPATIBILITY), WS_VISIBLE|WS_CHILD, CRect (LEFT_SPACING, nPosY, 225, nPosY+15), this, (UINT)IDC_STATIC);
- m_cbDXVACompatibilityCheck.Create (WS_VISIBLE|WS_CHILD|CBS_DROPDOWNLIST|WS_VSCROLL, CRect (230, nPosY-4, 345, nPosY+90), this, IDC_PP_DXVA_CHECK);
- m_cbDXVACompatibilityCheck.AddString(ResStr(IDS_VDF_DXVA_FULLCHECK));
- m_cbDXVACompatibilityCheck.AddString(ResStr(IDS_VDF_DXVA_SKIP_LEVELCHECK));
- m_cbDXVACompatibilityCheck.AddString(ResStr(IDS_VDF_DXVA_SKIP_REFCHECK));
- m_cbDXVACompatibilityCheck.AddString(ResStr(IDS_VDF_DXVA_SKIP_ALLCHECK));
-
- nPosY += VERTICAL_SPACING;
- m_cbDXVA_SD.Create (ResStr (IDS_VDF_DXVA_SD), WS_VISIBLE|WS_CHILD|BS_AUTOCHECKBOX|BS_LEFTTEXT, CRect (LEFT_SPACING, nPosY, 345, nPosY+15), this, IDC_PP_DXVA_SD);
- m_cbDXVA_SD.SetCheck(FALSE);
-
- // DXVA mode
- nPosY += VERTICAL_SPACING;
- m_txtDXVAMode.Create (ResStr (IDS_VDF_DXVA_MODE), WS_VISIBLE|WS_CHILD, CRect (LEFT_SPACING, nPosY, 120, nPosY+15), this, (UINT)IDC_STATIC);
- m_edtDXVAMode.Create (WS_CHILD|WS_VISIBLE|WS_DISABLED, CRect (120, nPosY, 345, nPosY+20), this, 0);
-
- // Video card description
- nPosY += VERTICAL_SPACING;
- m_txtVideoCardDescription.Create (ResStr (IDS_VDF_VIDEOCARD), WS_VISIBLE|WS_CHILD, CRect (LEFT_SPACING, nPosY, 120, nPosY+15), this, (UINT)IDC_STATIC);
- m_edtVideoCardDescription.Create (ES_MULTILINE|WS_CHILD|WS_VISIBLE|WS_DISABLED, CRect (120, nPosY, 345, nPosY+30), this, 0);
- m_edtVideoCardDescription.SetWindowText (m_pMDF->GetVideoCardDescription());
-
-
- DxvaGui = m_pMDF->GetDXVADecoderGuid();
- if (DxvaGui != NULL) {
- CString DXVAMode = GetDXVAMode (DxvaGui);
- m_edtDXVAMode.SetWindowText (DXVAMode);
- } else {
- m_txtDXVAMode.ShowWindow (SW_HIDE);
- m_edtDXVAMode.ShowWindow (SW_HIDE);
- }
-
- for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
- pWnd->SetFont(&m_font, FALSE);
- }
-
- CorrectComboListWidth(m_cbDXVACompatibilityCheck);
+ m_grpDXVA.Create(ResStr(IDS_VDF_DXVA_SETTING), WS_VISIBLE | WS_CHILD | BS_GROUPBOX, CRect(5, nPosY, 350, nPosY + 135), this, (UINT)IDC_STATIC);
+
+ // DXVA Compatibility check
+ nPosY += VERTICAL_SPACING;
+ m_txtDXVACompatibilityCheck.Create(ResStr(IDS_VDF_DXVACOMPATIBILITY), WS_VISIBLE | WS_CHILD, CRect(LEFT_SPACING, nPosY, 225, nPosY + 15), this, (UINT)IDC_STATIC);
+ m_cbDXVACompatibilityCheck.Create(WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST | WS_VSCROLL, CRect(230, nPosY - 4, 345, nPosY + 90), this, IDC_PP_DXVA_CHECK);
+ m_cbDXVACompatibilityCheck.AddString(ResStr(IDS_VDF_DXVA_FULLCHECK));
+ m_cbDXVACompatibilityCheck.AddString(ResStr(IDS_VDF_DXVA_SKIP_LEVELCHECK));
+ m_cbDXVACompatibilityCheck.AddString(ResStr(IDS_VDF_DXVA_SKIP_REFCHECK));
+ m_cbDXVACompatibilityCheck.AddString(ResStr(IDS_VDF_DXVA_SKIP_ALLCHECK));
+
+ nPosY += VERTICAL_SPACING;
+ m_cbDXVA_SD.Create(ResStr(IDS_VDF_DXVA_SD), WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX | BS_LEFTTEXT, CRect(LEFT_SPACING, nPosY, 345, nPosY + 15), this, IDC_PP_DXVA_SD);
+ m_cbDXVA_SD.SetCheck(FALSE);
+
+ // DXVA mode
+ nPosY += VERTICAL_SPACING;
+ m_txtDXVAMode.Create(ResStr(IDS_VDF_DXVA_MODE), WS_VISIBLE | WS_CHILD, CRect(LEFT_SPACING, nPosY, 120, nPosY + 15), this, (UINT)IDC_STATIC);
+ m_edtDXVAMode.Create(WS_CHILD | WS_VISIBLE | WS_DISABLED, CRect(120, nPosY, 345, nPosY + 20), this, 0);
+
+ // Video card description
+ nPosY += VERTICAL_SPACING;
+ m_txtVideoCardDescription.Create(ResStr(IDS_VDF_VIDEOCARD), WS_VISIBLE | WS_CHILD, CRect(LEFT_SPACING, nPosY, 120, nPosY + 15), this, (UINT)IDC_STATIC);
+ m_edtVideoCardDescription.Create(ES_MULTILINE | WS_CHILD | WS_VISIBLE | WS_DISABLED, CRect(120, nPosY, 345, nPosY + 30), this, 0);
+ m_edtVideoCardDescription.SetWindowText(m_pMDF->GetVideoCardDescription());
+
+
+ DxvaGui = m_pMDF->GetDXVADecoderGuid();
+ if (DxvaGui != NULL) {
+ CString DXVAMode = GetDXVAMode(DxvaGui);
+ m_edtDXVAMode.SetWindowText(DXVAMode);
+ } else {
+ m_txtDXVAMode.ShowWindow(SW_HIDE);
+ m_edtDXVAMode.ShowWindow(SW_HIDE);
+ }
+
+ for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
+ pWnd->SetFont(&m_font, FALSE);
+ }
+
+ CorrectComboListWidth(m_cbDXVACompatibilityCheck);
#if INTERNAL_DECODER_H264
- CorrectComboListWidth(m_cbDiscardMode);
+ CorrectComboListWidth(m_cbDiscardMode);
#endif
- if (m_pMDF) {
+ if (m_pMDF) {
#if HAS_FFMPEG_VIDEO_DECODERS
#if INTERNAL_DECODER_H264
- m_cbThreadNumber.SetCurSel (m_pMDF->GetThreadNumber());
- m_cbDiscardMode.SetCurSel (FindDiscardIndex (m_pMDF->GetDiscardMode()));
+ m_cbThreadNumber.SetCurSel(m_pMDF->GetThreadNumber());
+ m_cbDiscardMode.SetCurSel(FindDiscardIndex(m_pMDF->GetDiscardMode()));
#endif
- m_cbErrorRecognition.SetCurSel (FindErrRecognitionIndex (m_pMDF->GetErrorRecognition()));
- m_cbIDCTAlgo.SetCurSel (m_pMDF->GetIDCTAlgo());
+ m_cbErrorRecognition.SetCurSel(FindErrRecognitionIndex(m_pMDF->GetErrorRecognition()));
+ m_cbIDCTAlgo.SetCurSel(m_pMDF->GetIDCTAlgo());
- m_cbARMode.SetCheck(m_pMDF->GetARMode());
+ m_cbARMode.SetCheck(m_pMDF->GetARMode());
#endif /* HAS_FFMPEG_VIDEO_DECODERS */
- m_cbDXVACompatibilityCheck.SetCurSel(m_pMDF->GetDXVACheckCompatibility());
- m_cbDXVA_SD.SetCheck(m_pMDF->GetDXVA_SD());
- }
+ m_cbDXVACompatibilityCheck.SetCurSel(m_pMDF->GetDXVACheckCompatibility());
+ m_cbDXVA_SD.SetCheck(m_pMDF->GetDXVA_SD());
+ }
- return true;
+ return true;
}
void CMPCVideoDecSettingsWnd::OnDeactivate()
@@ -226,28 +226,28 @@ void CMPCVideoDecSettingsWnd::OnDeactivate()
bool CMPCVideoDecSettingsWnd::OnApply()
{
- OnDeactivate();
+ OnDeactivate();
- if (m_pMDF && m_cbDXVACompatibilityCheck.m_hWnd) {
+ if (m_pMDF && m_cbDXVACompatibilityCheck.m_hWnd) {
#if HAS_FFMPEG_VIDEO_DECODERS
#if INTERNAL_DECODER_H264
- m_pMDF->SetThreadNumber (m_cbThreadNumber.GetCurSel());
- m_pMDF->SetDiscardMode (g_AVDiscard[m_cbDiscardMode.GetCurSel()]);
+ m_pMDF->SetThreadNumber(m_cbThreadNumber.GetCurSel());
+ m_pMDF->SetDiscardMode(g_AVDiscard[m_cbDiscardMode.GetCurSel()]);
#endif /* INTERNAL_DECODER_H264 */
- m_pMDF->SetErrorRecognition (g_AVErrRecognition[m_cbErrorRecognition.GetCurSel()]);
- m_pMDF->SetIDCTAlgo (m_cbIDCTAlgo.GetCurSel());
+ m_pMDF->SetErrorRecognition(g_AVErrRecognition[m_cbErrorRecognition.GetCurSel()]);
+ m_pMDF->SetIDCTAlgo(m_cbIDCTAlgo.GetCurSel());
- m_pMDF->SetARMode(m_cbARMode.GetCheck());
+ m_pMDF->SetARMode(m_cbARMode.GetCheck());
#endif /* HAS_FFMPEG_VIDEO_DECODERS */
- m_pMDF->SetDXVACheckCompatibility(m_cbDXVACompatibilityCheck.GetCurSel());
+ m_pMDF->SetDXVACheckCompatibility(m_cbDXVACompatibilityCheck.GetCurSel());
- m_pMDF->SetDXVA_SD(m_cbDXVA_SD.GetCheck());
+ m_pMDF->SetDXVA_SD(m_cbDXVA_SD.GetCheck());
- m_pMDF->Apply();
- }
+ m_pMDF->Apply();
+ }
- return true;
+ return true;
}
@@ -263,99 +263,99 @@ CMPCVideoDecCodecWnd::CMPCVideoDecCodecWnd()
bool CMPCVideoDecCodecWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
{
- ASSERT(!m_pMDF);
+ ASSERT(!m_pMDF);
- m_pMDF.Release();
+ m_pMDF.Release();
- POSITION pos = pUnks.GetHeadPosition();
- while (pos && !(m_pMDF = pUnks.GetNext(pos))) {
- ;
- }
+ POSITION pos = pUnks.GetHeadPosition();
+ while (pos && !(m_pMDF = pUnks.GetNext(pos))) {
+ ;
+ }
- if (!m_pMDF) {
- return false;
- }
+ if (!m_pMDF) {
+ return false;
+ }
- return true;
+ return true;
}
void CMPCVideoDecCodecWnd::OnDisconnect()
{
- m_pMDF.Release();
+ m_pMDF.Release();
}
bool CMPCVideoDecCodecWnd::OnActivate()
{
- DWORD dwStyle = WS_VISIBLE|WS_CHILD|WS_BORDER;
- int nPos = 0;
- MPC_VIDEO_CODEC nActiveCodecs = (MPC_VIDEO_CODEC)(m_pMDF ? m_pMDF->GetActiveCodecs() : 0);
+ DWORD dwStyle = WS_VISIBLE | WS_CHILD | WS_BORDER;
+ int nPos = 0;
+ MPC_VIDEO_CODEC nActiveCodecs = (MPC_VIDEO_CODEC)(m_pMDF ? m_pMDF->GetActiveCodecs() : 0);
- m_grpSelectedCodec.Create (_T("Selected codecs"), WS_VISIBLE|WS_CHILD | BS_GROUPBOX, CRect (10, 10, 330, 280), this, (UINT)IDC_STATIC);
+ m_grpSelectedCodec.Create(_T("Selected codecs"), WS_VISIBLE | WS_CHILD | BS_GROUPBOX, CRect(10, 10, 330, 280), this, (UINT)IDC_STATIC);
- m_lstCodecs.Create (dwStyle | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP, CRect (20,30, 320, 270), this, 0);
+ m_lstCodecs.Create(dwStyle | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP, CRect(20, 30, 320, 270), this, 0);
#if INTERNAL_DECODER_H264_DXVA
- m_lstCodecs.AddString (_T("H.264/AVC (DXVA)"));
- m_lstCodecs.SetCheck (nPos++, (nActiveCodecs & MPCVD_H264_DXVA) != 0);
+ m_lstCodecs.AddString(_T("H.264/AVC (DXVA)"));
+ m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_H264_DXVA) != 0);
#endif
#if INTERNAL_DECODER_VC1_DXVA
- m_lstCodecs.AddString (_T("VC1 (DXVA)"));
- m_lstCodecs.SetCheck (nPos++, (nActiveCodecs & MPCVD_VC1_DXVA) != 0);
+ m_lstCodecs.AddString(_T("VC1 (DXVA)"));
+ m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_VC1_DXVA) != 0);
#endif
#if INTERNAL_DECODER_WMV3_DXVA
- m_lstCodecs.AddString (_T("WMV3 (DXVA)"));
- m_lstCodecs.SetCheck (nPos++, (nActiveCodecs & MPCVD_WMV3_DXVA) != 0);
+ m_lstCodecs.AddString(_T("WMV3 (DXVA)"));
+ m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_WMV3_DXVA) != 0);
#endif
#if INTERNAL_DECODER_MPEG2_DXVA
- m_lstCodecs.AddString (_T("MPEG2 (DXVA)"));
- m_lstCodecs.SetCheck (nPos++, (nActiveCodecs & MPCVD_MPEG2_DXVA) != 0);
+ m_lstCodecs.AddString(_T("MPEG2 (DXVA)"));
+ m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_MPEG2_DXVA) != 0);
#endif
#if INTERNAL_DECODER_H264
- m_lstCodecs.AddString (_T("H.264/AVC (FFmpeg)"));
- m_lstCodecs.SetCheck (nPos++, (nActiveCodecs & MPCVD_H264) != 0);
+ m_lstCodecs.AddString(_T("H.264/AVC (FFmpeg)"));
+ m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_H264) != 0);
#endif
#if INTERNAL_DECODER_VC1
- m_lstCodecs.AddString (_T("VC1 (FFmpeg)"));
- m_lstCodecs.SetCheck (nPos++, (nActiveCodecs & MPCVD_VC1) != 0);
+ m_lstCodecs.AddString(_T("VC1 (FFmpeg)"));
+ m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_VC1) != 0);
#endif
#if HAS_FFMPEG_VIDEO_DECODERS
- m_lstCodecs.AddString (_T("Xvid/MPEG-4"));
- m_lstCodecs.SetCheck (nPos++, (nActiveCodecs & MPCVD_XVID) != 0);
- m_lstCodecs.AddString (_T("DivX"));
- m_lstCodecs.SetCheck (nPos++, (nActiveCodecs & MPCVD_DIVX) != 0);
- m_lstCodecs.AddString (_T("MS-MPEG4"));
- m_lstCodecs.SetCheck (nPos++, (nActiveCodecs & MPCVD_MSMPEG4) != 0);
- m_lstCodecs.AddString (_T("FLV1/4"));
- m_lstCodecs.SetCheck (nPos++, (nActiveCodecs & MPCVD_FLASH) != 0);
- m_lstCodecs.AddString (_T("VP3/5/6"));
- m_lstCodecs.SetCheck (nPos++, (nActiveCodecs & MPCVD_VP356) != 0);
- m_lstCodecs.AddString (_T("VP8"));
- m_lstCodecs.SetCheck (nPos++, (nActiveCodecs & MPCVD_VP8) != 0);
- m_lstCodecs.AddString (_T("WMV1/2/3"));
- m_lstCodecs.SetCheck (nPos++, (nActiveCodecs & MPCVD_WMV) != 0);
- m_lstCodecs.AddString (_T("H.263"));
- m_lstCodecs.SetCheck (nPos++, (nActiveCodecs & MPCVD_H263) != 0);
- m_lstCodecs.AddString (_T("SVQ1/3"));
- m_lstCodecs.SetCheck (nPos++, (nActiveCodecs & MPCVD_SVQ3) != 0);
- m_lstCodecs.AddString (_T("AMV video"));
- m_lstCodecs.SetCheck (nPos++, (nActiveCodecs & MPCVD_AMVV) != 0);
- m_lstCodecs.AddString (_T("Theora"));
- m_lstCodecs.SetCheck (nPos++, (nActiveCodecs & MPCVD_THEORA) != 0);
- m_lstCodecs.AddString (_T("MJPEG"));
- m_lstCodecs.SetCheck (nPos++, (nActiveCodecs & MPCVD_MJPEG) != 0);
- m_lstCodecs.AddString (_T("Indeo 3/4/5"));
- m_lstCodecs.SetCheck (nPos++, (nActiveCodecs & MPCVD_INDEO) != 0);
- m_lstCodecs.AddString (_T("Real Video"));
- m_lstCodecs.SetCheck (nPos++, (nActiveCodecs & MPCVD_RV) != 0);
+ m_lstCodecs.AddString(_T("Xvid/MPEG-4"));
+ m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_XVID) != 0);
+ m_lstCodecs.AddString(_T("DivX"));
+ m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_DIVX) != 0);
+ m_lstCodecs.AddString(_T("MS-MPEG4"));
+ m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_MSMPEG4) != 0);
+ m_lstCodecs.AddString(_T("FLV1/4"));
+ m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_FLASH) != 0);
+ m_lstCodecs.AddString(_T("VP3/5/6"));
+ m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_VP356) != 0);
+ m_lstCodecs.AddString(_T("VP8"));
+ m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_VP8) != 0);
+ m_lstCodecs.AddString(_T("WMV1/2/3"));
+ m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_WMV) != 0);
+ m_lstCodecs.AddString(_T("H.263"));
+ m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_H263) != 0);
+ m_lstCodecs.AddString(_T("SVQ1/3"));
+ m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_SVQ3) != 0);
+ m_lstCodecs.AddString(_T("AMV video"));
+ m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_AMVV) != 0);
+ m_lstCodecs.AddString(_T("Theora"));
+ m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_THEORA) != 0);
+ m_lstCodecs.AddString(_T("MJPEG"));
+ m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_MJPEG) != 0);
+ m_lstCodecs.AddString(_T("Indeo 3/4/5"));
+ m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_INDEO) != 0);
+ m_lstCodecs.AddString(_T("Real Video"));
+ m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_RV) != 0);
#endif
- for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
- pWnd->SetFont(&m_font, FALSE);
- }
+ for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
+ pWnd->SetFont(&m_font, FALSE);
+ }
- return true;
+ return true;
}
void CMPCVideoDecCodecWnd::OnDeactivate()
@@ -364,92 +364,92 @@ void CMPCVideoDecCodecWnd::OnDeactivate()
bool CMPCVideoDecCodecWnd::OnApply()
{
- OnDeactivate();
+ OnDeactivate();
- if (m_pMDF) {
- int nActiveCodecs = 0;
- int nPos = 0;
+ if (m_pMDF) {
+ int nActiveCodecs = 0;
+ int nPos = 0;
#if INTERNAL_DECODER_H264_DXVA
- if (m_lstCodecs.GetCheck (nPos++)) {
- nActiveCodecs |= MPCVD_H264_DXVA;
- }
+ if (m_lstCodecs.GetCheck(nPos++)) {
+ nActiveCodecs |= MPCVD_H264_DXVA;
+ }
#endif
#if INTERNAL_DECODER_VC1_DXVA
- if (m_lstCodecs.GetCheck (nPos++)) {
- nActiveCodecs |= MPCVD_VC1_DXVA;
- }
+ if (m_lstCodecs.GetCheck(nPos++)) {
+ nActiveCodecs |= MPCVD_VC1_DXVA;
+ }
#endif
#if INTERNAL_DECODER_WMV3_DXVA
- if (m_lstCodecs.GetCheck (nPos++)) {
- nActiveCodecs |= MPCVD_WMV3_DXVA;
- }
+ if (m_lstCodecs.GetCheck(nPos++)) {
+ nActiveCodecs |= MPCVD_WMV3_DXVA;
+ }
#endif
#if INTERNAL_DECODER_MPEG2_DXVA
- if (m_lstCodecs.GetCheck (nPos++)) {
- nActiveCodecs |= MPCVD_MPEG2_DXVA;
- }
+ if (m_lstCodecs.GetCheck(nPos++)) {
+ nActiveCodecs |= MPCVD_MPEG2_DXVA;
+ }
#endif
#if INTERNAL_DECODER_H264
- if (m_lstCodecs.GetCheck (nPos++)) {
- nActiveCodecs |= MPCVD_H264;
- }
+ if (m_lstCodecs.GetCheck(nPos++)) {
+ nActiveCodecs |= MPCVD_H264;
+ }
#endif
#if INTERNAL_DECODER_VC1
- if (m_lstCodecs.GetCheck (nPos++)) {
- nActiveCodecs |= MPCVD_VC1;
- }
+ if (m_lstCodecs.GetCheck(nPos++)) {
+ nActiveCodecs |= MPCVD_VC1;
+ }
#endif
#if HAS_FFMPEG_VIDEO_DECODERS
- if (m_lstCodecs.GetCheck (nPos++)) {
- nActiveCodecs |= MPCVD_XVID;
- }
- if (m_lstCodecs.GetCheck (nPos++)) {
- nActiveCodecs |= MPCVD_DIVX;
- }
- if (m_lstCodecs.GetCheck (nPos++)) {
- nActiveCodecs |= MPCVD_MSMPEG4;
- }
- if (m_lstCodecs.GetCheck (nPos++)) {
- nActiveCodecs |= MPCVD_FLASH;
- }
- if (m_lstCodecs.GetCheck (nPos++)) {
- nActiveCodecs |= MPCVD_VP356;
- }
- if (m_lstCodecs.GetCheck (nPos++)) {
- nActiveCodecs |= MPCVD_VP8;
- }
- if (m_lstCodecs.GetCheck (nPos++)) {
- nActiveCodecs |= MPCVD_WMV;
- }
- if (m_lstCodecs.GetCheck (nPos++)) {
- nActiveCodecs |= MPCVD_H263;
- }
- if (m_lstCodecs.GetCheck (nPos++)) {
- nActiveCodecs |= MPCVD_SVQ3;
- }
- if (m_lstCodecs.GetCheck (nPos++)) {
- nActiveCodecs |= MPCVD_AMVV;
- }
- if (m_lstCodecs.GetCheck (nPos++)) {
- nActiveCodecs |= MPCVD_THEORA;
- }
- if (m_lstCodecs.GetCheck (nPos++)) {
- nActiveCodecs |= MPCVD_MJPEG;
- }
- if (m_lstCodecs.GetCheck (nPos++)) {
- nActiveCodecs |= MPCVD_INDEO;
- }
- if (m_lstCodecs.GetCheck (nPos++)) {
- nActiveCodecs |= MPCVD_RV;
- }
+ if (m_lstCodecs.GetCheck(nPos++)) {
+ nActiveCodecs |= MPCVD_XVID;
+ }
+ if (m_lstCodecs.GetCheck(nPos++)) {
+ nActiveCodecs |= MPCVD_DIVX;
+ }
+ if (m_lstCodecs.GetCheck(nPos++)) {
+ nActiveCodecs |= MPCVD_MSMPEG4;
+ }
+ if (m_lstCodecs.GetCheck(nPos++)) {
+ nActiveCodecs |= MPCVD_FLASH;
+ }
+ if (m_lstCodecs.GetCheck(nPos++)) {
+ nActiveCodecs |= MPCVD_VP356;
+ }
+ if (m_lstCodecs.GetCheck(nPos++)) {
+ nActiveCodecs |= MPCVD_VP8;
+ }
+ if (m_lstCodecs.GetCheck(nPos++)) {
+ nActiveCodecs |= MPCVD_WMV;
+ }
+ if (m_lstCodecs.GetCheck(nPos++)) {
+ nActiveCodecs |= MPCVD_H263;
+ }
+ if (m_lstCodecs.GetCheck(nPos++)) {
+ nActiveCodecs |= MPCVD_SVQ3;
+ }
+ if (m_lstCodecs.GetCheck(nPos++)) {
+ nActiveCodecs |= MPCVD_AMVV;
+ }
+ if (m_lstCodecs.GetCheck(nPos++)) {
+ nActiveCodecs |= MPCVD_THEORA;
+ }
+ if (m_lstCodecs.GetCheck(nPos++)) {
+ nActiveCodecs |= MPCVD_MJPEG;
+ }
+ if (m_lstCodecs.GetCheck(nPos++)) {
+ nActiveCodecs |= MPCVD_INDEO;
+ }
+ if (m_lstCodecs.GetCheck(nPos++)) {
+ nActiveCodecs |= MPCVD_RV;
+ }
#endif
- m_pMDF->SetActiveCodecs ((MPC_VIDEO_CODEC)nActiveCodecs);
+ m_pMDF->SetActiveCodecs((MPC_VIDEO_CODEC)nActiveCodecs);
- m_pMDF->Apply();
- }
+ m_pMDF->Apply();
+ }
- return true;
+ return true;
}
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.h b/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.h
index a035b2436..54e6f5bfd 100644
--- a/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.h
+++ b/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.h
@@ -27,87 +27,87 @@
#include <afxcmn.h>
class __declspec(uuid("D5AA0389-D274-48e1-BF50-ACB05A56DDE0"))
- CMPCVideoDecSettingsWnd : public CInternalPropertyPageWnd
+ CMPCVideoDecSettingsWnd : public CInternalPropertyPageWnd
{
- CComQIPtr<IMPCVideoDecFilter> m_pMDF;
-
- CButton m_grpFFMpeg;
- CStatic m_txtThreadNumber;
- CComboBox m_cbThreadNumber;
- CStatic m_txtDiscardMode;
- CComboBox m_cbDiscardMode;
- CStatic m_txtErrorRecognition;
- CComboBox m_cbErrorRecognition;
- CStatic m_txtIDCTAlgo;
- CComboBox m_cbIDCTAlgo;
-
- CButton m_grpDXVA;
- CStatic m_txtDXVAMode;
- CEdit m_edtDXVAMode;
- CStatic m_txtVideoCardDescription;
- CEdit m_edtVideoCardDescription;
-
- CButton m_cbARMode;
-
- CStatic m_txtDXVACompatibilityCheck;
- CComboBox m_cbDXVACompatibilityCheck;
-
- CButton m_cbDXVA_SD;
-
- enum {
- IDC_PP_THREAD_NUMBER = 10000,
- IDC_PP_ENABLE_DEBLOCKING,
- IDC_PP_DISCARD_MODE,
- IDC_PP_ERROR_RECOGNITION,
- IDC_PP_AR,
- IDC_PP_DXVA_CHECK,
- IDC_PP_DXVA_SD
- };
+ CComQIPtr<IMPCVideoDecFilter> m_pMDF;
+
+ CButton m_grpFFMpeg;
+ CStatic m_txtThreadNumber;
+ CComboBox m_cbThreadNumber;
+ CStatic m_txtDiscardMode;
+ CComboBox m_cbDiscardMode;
+ CStatic m_txtErrorRecognition;
+ CComboBox m_cbErrorRecognition;
+ CStatic m_txtIDCTAlgo;
+ CComboBox m_cbIDCTAlgo;
+
+ CButton m_grpDXVA;
+ CStatic m_txtDXVAMode;
+ CEdit m_edtDXVAMode;
+ CStatic m_txtVideoCardDescription;
+ CEdit m_edtVideoCardDescription;
+
+ CButton m_cbARMode;
+
+ CStatic m_txtDXVACompatibilityCheck;
+ CComboBox m_cbDXVACompatibilityCheck;
+
+ CButton m_cbDXVA_SD;
+
+ enum {
+ IDC_PP_THREAD_NUMBER = 10000,
+ IDC_PP_ENABLE_DEBLOCKING,
+ IDC_PP_DISCARD_MODE,
+ IDC_PP_ERROR_RECOGNITION,
+ IDC_PP_AR,
+ IDC_PP_DXVA_CHECK,
+ IDC_PP_DXVA_SD
+ };
public:
- CMPCVideoDecSettingsWnd();
-
- bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
- void OnDisconnect();
- bool OnActivate();
- void OnDeactivate();
- bool OnApply();
-
- static LPCTSTR GetWindowTitle() {
- return _T("Settings");
- }
- static CSize GetWindowSize() {
- return CSize(350, 325);
- }
-
- DECLARE_MESSAGE_MAP()
+ CMPCVideoDecSettingsWnd();
+
+ bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
+ void OnDisconnect();
+ bool OnActivate();
+ void OnDeactivate();
+ bool OnApply();
+
+ static LPCTSTR GetWindowTitle() {
+ return _T("Settings");
+ }
+ static CSize GetWindowSize() {
+ return CSize(350, 325);
+ }
+
+ DECLARE_MESSAGE_MAP()
};
class __declspec(uuid("3C395D46-8B0F-440d-B962-2F4A97355453"))
- CMPCVideoDecCodecWnd : public CInternalPropertyPageWnd
+ CMPCVideoDecCodecWnd : public CInternalPropertyPageWnd
{
- CComQIPtr<IMPCVideoDecFilter> m_pMDF;
+ CComQIPtr<IMPCVideoDecFilter> m_pMDF;
- CButton m_grpSelectedCodec;
- CCheckListBox m_lstCodecs;
- CImageList m_onoff;
+ CButton m_grpSelectedCodec;
+ CCheckListBox m_lstCodecs;
+ CImageList m_onoff;
public:
- CMPCVideoDecCodecWnd();
-
- bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
- void OnDisconnect();
- bool OnActivate();
- void OnDeactivate();
- bool OnApply();
-
- static LPCTSTR GetWindowTitle() {
- return _T("Codecs");
- }
- static CSize GetWindowSize() {
- return CSize(350, 300);
- }
-
- DECLARE_MESSAGE_MAP()
+ CMPCVideoDecCodecWnd();
+
+ bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
+ void OnDisconnect();
+ bool OnActivate();
+ void OnDeactivate();
+ bool OnApply();
+
+ static LPCTSTR GetWindowTitle() {
+ return _T("Codecs");
+ }
+ static CSize GetWindowSize() {
+ return CSize(350, 300);
+ }
+
+ DECLARE_MESSAGE_MAP()
};
diff --git a/src/filters/transform/MPCVideoDec/TlibavcodecExt.cpp b/src/filters/transform/MPCVideoDec/TlibavcodecExt.cpp
index 47a7e3c22..383c0c08b 100644
--- a/src/filters/transform/MPCVideoDec/TlibavcodecExt.cpp
+++ b/src/filters/transform/MPCVideoDec/TlibavcodecExt.cpp
@@ -27,34 +27,34 @@
#include "TlibavcodecExt.h"
-void TlibavcodecExt::ConnectTo(AVCodecContext *pAVCtx)
+void TlibavcodecExt::ConnectTo(AVCodecContext* pAVCtx)
{
- pAVCtx->opaque = this;
- pAVCtx->get_buffer = get_buffer;
- pAVCtx->reget_buffer = reget_buffer;
- pAVCtx->release_buffer = release_buffer;
+ pAVCtx->opaque = this;
+ pAVCtx->get_buffer = get_buffer;
+ pAVCtx->reget_buffer = reget_buffer;
+ pAVCtx->release_buffer = release_buffer;
}
-int TlibavcodecExt::get_buffer(AVCodecContext *c, AVFrame *pic)
+int TlibavcodecExt::get_buffer(AVCodecContext* c, AVFrame* pic)
{
- int ret=c->opaque->ff_avcodec_default_get_buffer(c,pic);
- if (ret==0) {
- c->opaque->OnGetBuffer(pic);
- }
- return ret;
+ int ret = c->opaque->ff_avcodec_default_get_buffer(c, pic);
+ if (ret == 0) {
+ c->opaque->OnGetBuffer(pic);
+ }
+ return ret;
}
-int TlibavcodecExt::reget_buffer(AVCodecContext *c, AVFrame *pic)
+int TlibavcodecExt::reget_buffer(AVCodecContext* c, AVFrame* pic)
{
- int ret=c->opaque->ff_avcodec_default_reget_buffer(c,pic);
- if (ret==0) {
- c->opaque->OnRegetBuffer(pic);
- }
- return ret;
+ int ret = c->opaque->ff_avcodec_default_reget_buffer(c, pic);
+ if (ret == 0) {
+ c->opaque->OnRegetBuffer(pic);
+ }
+ return ret;
}
-void TlibavcodecExt::release_buffer(AVCodecContext *c, AVFrame *pic)
+void TlibavcodecExt::release_buffer(AVCodecContext* c, AVFrame* pic)
{
- c->opaque->ff_avcodec_default_release_buffer(c,pic);
- c->opaque->OnReleaseBuffer(pic);
+ c->opaque->ff_avcodec_default_release_buffer(c, pic);
+ c->opaque->OnReleaseBuffer(pic);
}
diff --git a/src/filters/transform/MPCVideoDec/TlibavcodecExt.h b/src/filters/transform/MPCVideoDec/TlibavcodecExt.h
index 5d862f8a2..19d05c353 100644
--- a/src/filters/transform/MPCVideoDec/TlibavcodecExt.h
+++ b/src/filters/transform/MPCVideoDec/TlibavcodecExt.h
@@ -26,25 +26,25 @@
struct AVCodecContext;
struct AVFrame;
-typedef int (*FUNC_AV_DEFAULT_GET_BUFFER)(AVCodecContext *s, AVFrame *pic);
-typedef void (*FUNC_AV_DEFAULT_RELEASE_BUFFER)(AVCodecContext *s, AVFrame *pic);
-typedef int (*FUNC_AV_DEFAULT_REGET_BUFFER)(AVCodecContext *s, AVFrame *pic);
+typedef int (*FUNC_AV_DEFAULT_GET_BUFFER)(AVCodecContext* s, AVFrame* pic);
+typedef void (*FUNC_AV_DEFAULT_RELEASE_BUFFER)(AVCodecContext* s, AVFrame* pic);
+typedef int (*FUNC_AV_DEFAULT_REGET_BUFFER)(AVCodecContext* s, AVFrame* pic);
struct TlibavcodecExt {
protected:
- static int get_buffer(AVCodecContext *s, AVFrame *pic);
- static void release_buffer(AVCodecContext *s, AVFrame *pic);
- static int reget_buffer(AVCodecContext *s, AVFrame *pic);
+ static int get_buffer(AVCodecContext* s, AVFrame* pic);
+ static void release_buffer(AVCodecContext* s, AVFrame* pic);
+ static int reget_buffer(AVCodecContext* s, AVFrame* pic);
- FUNC_AV_DEFAULT_GET_BUFFER ff_avcodec_default_get_buffer;
- FUNC_AV_DEFAULT_RELEASE_BUFFER ff_avcodec_default_release_buffer;
- FUNC_AV_DEFAULT_REGET_BUFFER ff_avcodec_default_reget_buffer;
+ FUNC_AV_DEFAULT_GET_BUFFER ff_avcodec_default_get_buffer;
+ FUNC_AV_DEFAULT_RELEASE_BUFFER ff_avcodec_default_release_buffer;
+ FUNC_AV_DEFAULT_REGET_BUFFER ff_avcodec_default_reget_buffer;
public:
- virtual ~TlibavcodecExt() {}
- void ConnectTo(AVCodecContext *pAVCtx);
- virtual void OnGetBuffer(AVFrame *pic) {}
- virtual void OnRegetBuffer(AVFrame *pic) {}
- virtual void OnReleaseBuffer(AVFrame *pic) {}
+ virtual ~TlibavcodecExt() {}
+ void ConnectTo(AVCodecContext* pAVCtx);
+ virtual void OnGetBuffer(AVFrame* pic) {}
+ virtual void OnRegetBuffer(AVFrame* pic) {}
+ virtual void OnReleaseBuffer(AVFrame* pic) {}
};
diff --git a/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.cpp b/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.cpp
index d7c0a2af7..3119dd29a 100644
--- a/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.cpp
+++ b/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.cpp
@@ -26,182 +26,182 @@
#include "MPCVideoDecFilter.h"
-CDXVA2Sample::CDXVA2Sample(CVideoDecDXVAAllocator *pAlloc, HRESULT *phr)
- : CMediaSample(NAME("CDXVA2Sample"), (CBaseAllocator*)pAlloc, phr, NULL, 0)
- , m_dwSurfaceId(0)
+CDXVA2Sample::CDXVA2Sample(CVideoDecDXVAAllocator* pAlloc, HRESULT* phr)
+ : CMediaSample(NAME("CDXVA2Sample"), (CBaseAllocator*)pAlloc, phr, NULL, 0)
+ , m_dwSurfaceId(0)
{
}
//Note: CMediaSample does not derive from CUnknown, so we cannot use the
-// DECLARE_IUNKNOWN macro that is used by most of the filter classes.
+// DECLARE_IUNKNOWN macro that is used by most of the filter classes.
-STDMETHODIMP CDXVA2Sample::QueryInterface(REFIID riid, __deref_out void **ppv)
+STDMETHODIMP CDXVA2Sample::QueryInterface(REFIID riid, __deref_out void** ppv)
{
- CheckPointer(ppv,E_POINTER);
- ValidateReadWritePtr(ppv,sizeof(PVOID));
-
- if (riid == __uuidof(IMFGetService)) {
- return GetInterface((IMFGetService*) this, ppv);
- }
- if (riid == __uuidof(IMPCDXVA2Sample)) {
- return GetInterface((IMPCDXVA2Sample*) this, ppv);
- } else {
- return CMediaSample::QueryInterface(riid, ppv);
- }
+ CheckPointer(ppv, E_POINTER);
+ ValidateReadWritePtr(ppv, sizeof(PVOID));
+
+ if (riid == __uuidof(IMFGetService)) {
+ return GetInterface((IMFGetService*) this, ppv);
+ }
+ if (riid == __uuidof(IMPCDXVA2Sample)) {
+ return GetInterface((IMPCDXVA2Sample*) this, ppv);
+ } else {
+ return CMediaSample::QueryInterface(riid, ppv);
+ }
}
STDMETHODIMP_(ULONG) CDXVA2Sample::AddRef()
{
- return __super::AddRef();
+ return __super::AddRef();
}
STDMETHODIMP_(ULONG) CDXVA2Sample::Release()
{
- // Return a temporary variable for thread safety.
- ULONG cRef = __super::Release();
- return cRef;
+ // Return a temporary variable for thread safety.
+ ULONG cRef = __super::Release();
+ return cRef;
}
// IMFGetService::GetService
-STDMETHODIMP CDXVA2Sample::GetService(REFGUID guidService, REFIID riid, LPVOID *ppv)
+STDMETHODIMP CDXVA2Sample::GetService(REFGUID guidService, REFIID riid, LPVOID* ppv)
{
- if (guidService != MR_BUFFER_SERVICE) {
- return MF_E_UNSUPPORTED_SERVICE;
- } else if (m_pSurface == NULL) {
- return E_NOINTERFACE;
- } else {
- return m_pSurface->QueryInterface(riid, ppv);
- }
+ if (guidService != MR_BUFFER_SERVICE) {
+ return MF_E_UNSUPPORTED_SERVICE;
+ } else if (m_pSurface == NULL) {
+ return E_NOINTERFACE;
+ } else {
+ return m_pSurface->QueryInterface(riid, ppv);
+ }
}
// Override GetPointer because this class does not manage a system memory buffer.
// The EVR uses the MR_BUFFER_SERVICE service to get the Direct3D surface.
-STDMETHODIMP CDXVA2Sample::GetPointer(BYTE ** ppBuffer)
+STDMETHODIMP CDXVA2Sample::GetPointer(BYTE** ppBuffer)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// Sets the pointer to the Direct3D surface.
-void CDXVA2Sample::SetSurface(DWORD surfaceId, IDirect3DSurface9 *pSurf)
+void CDXVA2Sample::SetSurface(DWORD surfaceId, IDirect3DSurface9* pSurf)
{
- m_pSurface = pSurf;
- m_dwSurfaceId = surfaceId;
+ m_pSurface = pSurf;
+ m_dwSurfaceId = surfaceId;
}
STDMETHODIMP_(int) CDXVA2Sample::GetDXSurfaceId()
{
- return m_dwSurfaceId;
+ return m_dwSurfaceId;
}
CVideoDecDXVAAllocator::CVideoDecDXVAAllocator(CMPCVideoDecFilter* pVideoDecFilter, HRESULT* phr)
- : CBaseAllocator(NAME("CVideoDecDXVAAllocator"), NULL, phr)
+ : CBaseAllocator(NAME("CVideoDecDXVAAllocator"), NULL, phr)
{
- m_pVideoDecFilter = pVideoDecFilter;
- m_ppRTSurfaceArray = NULL;
+ m_pVideoDecFilter = pVideoDecFilter;
+ m_ppRTSurfaceArray = NULL;
}
CVideoDecDXVAAllocator::~CVideoDecDXVAAllocator()
{
- Free();
+ Free();
}
HRESULT CVideoDecDXVAAllocator::Alloc()
{
- HRESULT hr;
- CComPtr<IDirectXVideoAccelerationService> pDXVA2Service;
-
- CheckPointer(m_pVideoDecFilter->m_pDeviceManager, E_UNEXPECTED);
- hr = m_pVideoDecFilter->m_pDeviceManager->GetVideoService (m_pVideoDecFilter->m_hDevice, IID_IDirectXVideoAccelerationService, (void**)&pDXVA2Service);
- CheckPointer (pDXVA2Service, E_UNEXPECTED);
- CAutoLock lock(this);
-
-
- hr = __super::Alloc();
-
- if (SUCCEEDED(hr)) {
- // Free the old resources.
- Free();
-
- m_nSurfaceArrayCount = m_lCount;
-
- // Allocate a new array of pointers.
- m_ppRTSurfaceArray = DNew IDirect3DSurface9*[m_lCount];
- if (m_ppRTSurfaceArray == NULL) {
- hr = E_OUTOFMEMORY;
- } else {
- ZeroMemory(m_ppRTSurfaceArray, sizeof(IDirect3DSurface9*) * m_lCount);
- }
- }
-
- // Allocate the surfaces.
- D3DFORMAT m_dwFormat = m_pVideoDecFilter->m_VideoDesc.Format;
- if (SUCCEEDED(hr)) {
- hr = pDXVA2Service->CreateSurface(
- m_pVideoDecFilter->PictWidthRounded(),
- m_pVideoDecFilter->PictHeightRounded(),
- m_lCount - 1,
- (D3DFORMAT)m_dwFormat,
- D3DPOOL_DEFAULT,
- 0,
- DXVA2_VideoDecoderRenderTarget,
- m_ppRTSurfaceArray,
- NULL
- );
- }
-
- if (SUCCEEDED(hr)) {
- // Important : create samples in reverse order !
- for (m_lAllocated = m_lCount-1; m_lAllocated >= 0; m_lAllocated--) {
- CDXVA2Sample *pSample = DNew CDXVA2Sample(this, &hr);
- if (pSample == NULL) {
- hr = E_OUTOFMEMORY;
- break;
- }
- if (FAILED(hr)) {
- break;
- }
- // Assign the Direct3D surface pointer and the index.
- pSample->SetSurface(m_lAllocated, m_ppRTSurfaceArray[m_lAllocated]);
-
- // Add to the sample list.
- m_lFree.Add(pSample);
- }
-
- hr = m_pVideoDecFilter->CreateDXVA2Decoder (m_lCount, m_ppRTSurfaceArray);
- if (FAILED (hr)) {
- Free();
- }
- }
-
- if (SUCCEEDED(hr)) {
- m_bChanged = FALSE;
- }
- return hr;
+ HRESULT hr;
+ CComPtr<IDirectXVideoAccelerationService> pDXVA2Service;
+
+ CheckPointer(m_pVideoDecFilter->m_pDeviceManager, E_UNEXPECTED);
+ hr = m_pVideoDecFilter->m_pDeviceManager->GetVideoService(m_pVideoDecFilter->m_hDevice, IID_IDirectXVideoAccelerationService, (void**)&pDXVA2Service);
+ CheckPointer(pDXVA2Service, E_UNEXPECTED);
+ CAutoLock lock(this);
+
+
+ hr = __super::Alloc();
+
+ if (SUCCEEDED(hr)) {
+ // Free the old resources.
+ Free();
+
+ m_nSurfaceArrayCount = m_lCount;
+
+ // Allocate a new array of pointers.
+ m_ppRTSurfaceArray = DNew IDirect3DSurface9 * [m_lCount];
+ if (m_ppRTSurfaceArray == NULL) {
+ hr = E_OUTOFMEMORY;
+ } else {
+ ZeroMemory(m_ppRTSurfaceArray, sizeof(IDirect3DSurface9*) * m_lCount);
+ }
+ }
+
+ // Allocate the surfaces.
+ D3DFORMAT m_dwFormat = m_pVideoDecFilter->m_VideoDesc.Format;
+ if (SUCCEEDED(hr)) {
+ hr = pDXVA2Service->CreateSurface(
+ m_pVideoDecFilter->PictWidthRounded(),
+ m_pVideoDecFilter->PictHeightRounded(),
+ m_lCount - 1,
+ (D3DFORMAT)m_dwFormat,
+ D3DPOOL_DEFAULT,
+ 0,
+ DXVA2_VideoDecoderRenderTarget,
+ m_ppRTSurfaceArray,
+ NULL
+ );
+ }
+
+ if (SUCCEEDED(hr)) {
+ // Important : create samples in reverse order !
+ for (m_lAllocated = m_lCount - 1; m_lAllocated >= 0; m_lAllocated--) {
+ CDXVA2Sample* pSample = DNew CDXVA2Sample(this, &hr);
+ if (pSample == NULL) {
+ hr = E_OUTOFMEMORY;
+ break;
+ }
+ if (FAILED(hr)) {
+ break;
+ }
+ // Assign the Direct3D surface pointer and the index.
+ pSample->SetSurface(m_lAllocated, m_ppRTSurfaceArray[m_lAllocated]);
+
+ // Add to the sample list.
+ m_lFree.Add(pSample);
+ }
+
+ hr = m_pVideoDecFilter->CreateDXVA2Decoder(m_lCount, m_ppRTSurfaceArray);
+ if (FAILED(hr)) {
+ Free();
+ }
+ }
+
+ if (SUCCEEDED(hr)) {
+ m_bChanged = FALSE;
+ }
+ return hr;
}
void CVideoDecDXVAAllocator::Free()
{
- CMediaSample *pSample = NULL;
-
- m_pVideoDecFilter->FlushDXVADecoder();
- // m_FreeSurface.RemoveAll();
- do {
- pSample = m_lFree.RemoveHead();
- if (pSample) {
- delete pSample;
- }
- } while (pSample);
-
- if (m_ppRTSurfaceArray) {
- for (UINT i = 0; i < m_nSurfaceArrayCount; i++) {
- if (m_ppRTSurfaceArray[i] != NULL) {
- m_ppRTSurfaceArray[i]->Release();
- }
- }
-
- delete [] m_ppRTSurfaceArray;
- m_ppRTSurfaceArray = NULL;
- }
- m_lAllocated = 0;
- m_nSurfaceArrayCount = 0;
+ CMediaSample* pSample = NULL;
+
+ m_pVideoDecFilter->FlushDXVADecoder();
+ // m_FreeSurface.RemoveAll();
+ do {
+ pSample = m_lFree.RemoveHead();
+ if (pSample) {
+ delete pSample;
+ }
+ } while (pSample);
+
+ if (m_ppRTSurfaceArray) {
+ for (UINT i = 0; i < m_nSurfaceArrayCount; i++) {
+ if (m_ppRTSurfaceArray[i] != NULL) {
+ m_ppRTSurfaceArray[i]->Release();
+ }
+ }
+
+ delete [] m_ppRTSurfaceArray;
+ m_ppRTSurfaceArray = NULL;
+ }
+ m_lAllocated = 0;
+ m_nSurfaceArrayCount = 0;
}
diff --git a/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.h b/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.h
index 08a0cb7c9..bd6794dab 100644
--- a/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.h
+++ b/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.h
@@ -34,68 +34,68 @@ class CVideoDecDXVAAllocator;
interface __declspec(uuid("AE7EC2A2-1913-4a80-8DD6-DF1497ABA494"))
IMPCDXVA2Sample :
public IUnknown {
- STDMETHOD_(int, GetDXSurfaceId()) = 0;
+ STDMETHOD_(int, GetDXSurfaceId()) = 0;
};
class CDXVA2Sample : public CMediaSample, public IMFGetService, public IMPCDXVA2Sample
{
- friend class CVideoDecDXVAAllocator;
+ friend class CVideoDecDXVAAllocator;
public:
- CDXVA2Sample(CVideoDecDXVAAllocator *pAlloc, HRESULT *phr);
+ CDXVA2Sample(CVideoDecDXVAAllocator* pAlloc, HRESULT* phr);
- //Note: CMediaSample does not derive from CUnknown, so we cannot use the
- // DECLARE_IUNKNOWN macro that is used by most of the filter classes.
+ //Note: CMediaSample does not derive from CUnknown, so we cannot use the
+ // DECLARE_IUNKNOWN macro that is used by most of the filter classes.
- STDMETHODIMP QueryInterface(REFIID riid, __deref_out void **ppv);
- STDMETHODIMP_(ULONG) AddRef();
- STDMETHODIMP_(ULONG) Release();
+ STDMETHODIMP QueryInterface(REFIID riid, __deref_out void** ppv);
+ STDMETHODIMP_(ULONG) AddRef();
+ STDMETHODIMP_(ULONG) Release();
- // IMFGetService::GetService
- STDMETHODIMP GetService(REFGUID guidService, REFIID riid, LPVOID *ppv);
+ // IMFGetService::GetService
+ STDMETHODIMP GetService(REFGUID guidService, REFIID riid, LPVOID* ppv);
- // IMPCDXVA2Sample
- STDMETHODIMP_(int) GetDXSurfaceId();
+ // IMPCDXVA2Sample
+ STDMETHODIMP_(int) GetDXSurfaceId();
- // Override GetPointer because this class does not manage a system memory buffer.
- // The EVR uses the MR_BUFFER_SERVICE service to get the Direct3D surface.
- STDMETHODIMP GetPointer(BYTE ** ppBuffer);
+ // Override GetPointer because this class does not manage a system memory buffer.
+ // The EVR uses the MR_BUFFER_SERVICE service to get the Direct3D surface.
+ STDMETHODIMP GetPointer(BYTE** ppBuffer);
private:
- // Sets the pointer to the Direct3D surface.
- void SetSurface(DWORD surfaceId, IDirect3DSurface9 *pSurf);
+ // Sets the pointer to the Direct3D surface.
+ void SetSurface(DWORD surfaceId, IDirect3DSurface9* pSurf);
- CComPtr<IDirect3DSurface9> m_pSurface;
- DWORD m_dwSurfaceId;
+ CComPtr<IDirect3DSurface9> m_pSurface;
+ DWORD m_dwSurfaceId;
};
class CVideoDecDXVAAllocator : public CBaseAllocator
{
public:
- CVideoDecDXVAAllocator(CMPCVideoDecFilter* pVideoDecFilter, HRESULT* phr);
- virtual ~CVideoDecDXVAAllocator();
+ CVideoDecDXVAAllocator(CMPCVideoDecFilter* pVideoDecFilter, HRESULT* phr);
+ virtual ~CVideoDecDXVAAllocator();
- // STDMETHODIMP GetBuffer(__deref_out IMediaSample **ppBuffer, // Try for a circular buffer!
- // __in_opt REFERENCE_TIME * pStartTime,
- // __in_opt REFERENCE_TIME * pEndTime,
- // DWORD dwFlags);
- //
- // STDMETHODIMP ReleaseBuffer(IMediaSample *pBuffer);
- // CAtlList<int> m_FreeSurface;
+ // STDMETHODIMP GetBuffer(__deref_out IMediaSample **ppBuffer, // Try for a circular buffer!
+ // __in_opt REFERENCE_TIME * pStartTime,
+ // __in_opt REFERENCE_TIME * pEndTime,
+ // DWORD dwFlags);
+ //
+ // STDMETHODIMP ReleaseBuffer(IMediaSample *pBuffer);
+ // CAtlList<int> m_FreeSurface;
protected:
- HRESULT Alloc(void);
- void Free(void);
+ HRESULT Alloc(void);
+ void Free(void);
private :
- CMPCVideoDecFilter* m_pVideoDecFilter;
+ CMPCVideoDecFilter* m_pVideoDecFilter;
- IDirect3DSurface9** m_ppRTSurfaceArray;
- UINT m_nSurfaceArrayCount;
+ IDirect3DSurface9** m_ppRTSurfaceArray;
+ UINT m_nSurfaceArrayCount;
};
diff --git a/src/filters/transform/MPCVideoDec/VideoDecOutputPin.cpp b/src/filters/transform/MPCVideoDec/VideoDecOutputPin.cpp
index 030c4a799..a64e13571 100644
--- a/src/filters/transform/MPCVideoDec/VideoDecOutputPin.cpp
+++ b/src/filters/transform/MPCVideoDec/VideoDecOutputPin.cpp
@@ -27,104 +27,104 @@
#include "../../../DSUtil/DSUtil.h"
CVideoDecOutputPin::CVideoDecOutputPin(TCHAR* pObjectName, CBaseVideoFilter* pFilter, HRESULT* phr, LPCWSTR pName)
- : CBaseVideoOutputPin(pObjectName, pFilter, phr, pName)
+ : CBaseVideoOutputPin(pObjectName, pFilter, phr, pName)
{
- m_pVideoDecFilter = static_cast<CMPCVideoDecFilter*> (pFilter);
- m_pDXVA2Allocator = NULL;
- m_dwDXVA1SurfaceCount = 0;
- m_GuidDecoderDXVA1 = GUID_NULL;
- memset (&m_ddUncompPixelFormat, 0, sizeof(m_ddUncompPixelFormat));
+ m_pVideoDecFilter = static_cast<CMPCVideoDecFilter*>(pFilter);
+ m_pDXVA2Allocator = NULL;
+ m_dwDXVA1SurfaceCount = 0;
+ m_GuidDecoderDXVA1 = GUID_NULL;
+ memset(&m_ddUncompPixelFormat, 0, sizeof(m_ddUncompPixelFormat));
}
CVideoDecOutputPin::~CVideoDecOutputPin(void)
{
}
-HRESULT CVideoDecOutputPin::InitAllocator(IMemAllocator **ppAlloc)
+HRESULT CVideoDecOutputPin::InitAllocator(IMemAllocator** ppAlloc)
{
- TRACE("CVideoDecOutputPin::InitAllocator");
- if (m_pVideoDecFilter->UseDXVA2()) {
- HRESULT hr = S_FALSE;
- m_pDXVA2Allocator = DNew CVideoDecDXVAAllocator(m_pVideoDecFilter, &hr);
- if (!m_pDXVA2Allocator) {
- return E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- delete m_pDXVA2Allocator;
- return hr;
- }
- // Return the IMemAllocator interface.
- return m_pDXVA2Allocator->QueryInterface(__uuidof(IMemAllocator), (void **)ppAlloc);
- } else {
- return __super::InitAllocator(ppAlloc);
- }
+ TRACE("CVideoDecOutputPin::InitAllocator");
+ if (m_pVideoDecFilter->UseDXVA2()) {
+ HRESULT hr = S_FALSE;
+ m_pDXVA2Allocator = DNew CVideoDecDXVAAllocator(m_pVideoDecFilter, &hr);
+ if (!m_pDXVA2Allocator) {
+ return E_OUTOFMEMORY;
+ }
+ if (FAILED(hr)) {
+ delete m_pDXVA2Allocator;
+ return hr;
+ }
+ // Return the IMemAllocator interface.
+ return m_pDXVA2Allocator->QueryInterface(__uuidof(IMemAllocator), (void**)ppAlloc);
+ } else {
+ return __super::InitAllocator(ppAlloc);
+ }
}
STDMETHODIMP CVideoDecOutputPin::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- return
- QI(IAMVideoAcceleratorNotify)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IAMVideoAcceleratorNotify)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// === IAMVideoAcceleratorNotify
-STDMETHODIMP CVideoDecOutputPin::GetUncompSurfacesInfo(const GUID *pGuid, LPAMVAUncompBufferInfo pUncompBufferInfo)
+STDMETHODIMP CVideoDecOutputPin::GetUncompSurfacesInfo(const GUID* pGuid, LPAMVAUncompBufferInfo pUncompBufferInfo)
{
- HRESULT hr = E_INVALIDARG;
-
- if (SUCCEEDED (m_pVideoDecFilter->CheckDXVA1Decoder (pGuid))) {
- CComQIPtr<IAMVideoAccelerator> pAMVideoAccelerator = GetConnected();
-
- if (pAMVideoAccelerator) {
- pUncompBufferInfo->dwMaxNumSurfaces = m_pVideoDecFilter->GetPicEntryNumber();
- pUncompBufferInfo->dwMinNumSurfaces = m_pVideoDecFilter->GetPicEntryNumber();
-
- hr = m_pVideoDecFilter->FindDXVA1DecoderConfiguration (pAMVideoAccelerator, pGuid, &pUncompBufferInfo->ddUncompPixelFormat);
- if (SUCCEEDED (hr)) {
- memcpy (&m_ddUncompPixelFormat, &pUncompBufferInfo->ddUncompPixelFormat, sizeof(DDPIXELFORMAT));
- m_GuidDecoderDXVA1 = *pGuid;
- }
- }
- }
- return hr;
+ HRESULT hr = E_INVALIDARG;
+
+ if (SUCCEEDED(m_pVideoDecFilter->CheckDXVA1Decoder(pGuid))) {
+ CComQIPtr<IAMVideoAccelerator> pAMVideoAccelerator = GetConnected();
+
+ if (pAMVideoAccelerator) {
+ pUncompBufferInfo->dwMaxNumSurfaces = m_pVideoDecFilter->GetPicEntryNumber();
+ pUncompBufferInfo->dwMinNumSurfaces = m_pVideoDecFilter->GetPicEntryNumber();
+
+ hr = m_pVideoDecFilter->FindDXVA1DecoderConfiguration(pAMVideoAccelerator, pGuid, &pUncompBufferInfo->ddUncompPixelFormat);
+ if (SUCCEEDED(hr)) {
+ memcpy(&m_ddUncompPixelFormat, &pUncompBufferInfo->ddUncompPixelFormat, sizeof(DDPIXELFORMAT));
+ m_GuidDecoderDXVA1 = *pGuid;
+ }
+ }
+ }
+ return hr;
}
STDMETHODIMP CVideoDecOutputPin::SetUncompSurfacesInfo(DWORD dwActualUncompSurfacesAllocated)
{
- m_dwDXVA1SurfaceCount = dwActualUncompSurfacesAllocated;
- return S_OK;
+ m_dwDXVA1SurfaceCount = dwActualUncompSurfacesAllocated;
+ return S_OK;
}
-STDMETHODIMP CVideoDecOutputPin::GetCreateVideoAcceleratorData(const GUID *pGuid, LPDWORD pdwSizeMiscData, LPVOID *ppMiscData)
+STDMETHODIMP CVideoDecOutputPin::GetCreateVideoAcceleratorData(const GUID* pGuid, LPDWORD pdwSizeMiscData, LPVOID* ppMiscData)
{
- HRESULT hr = E_UNEXPECTED;
- AMVAUncompDataInfo UncompInfo;
- AMVACompBufferInfo CompInfo[30];
- DWORD dwNumTypesCompBuffers = _countof(CompInfo);
- CComQIPtr<IAMVideoAccelerator> pAMVideoAccelerator = GetConnected();
- DXVA_ConnectMode* pConnectMode;
-
- if (pAMVideoAccelerator) {
- memcpy (&UncompInfo.ddUncompPixelFormat, &m_ddUncompPixelFormat, sizeof (DDPIXELFORMAT));
- UncompInfo.dwUncompWidth = m_pVideoDecFilter->PictWidthRounded();
- UncompInfo.dwUncompHeight = m_pVideoDecFilter->PictHeightRounded();
- hr = pAMVideoAccelerator->GetCompBufferInfo(&m_GuidDecoderDXVA1, &UncompInfo, &dwNumTypesCompBuffers, CompInfo);
-
- if (SUCCEEDED (hr)) {
- hr = m_pVideoDecFilter->CreateDXVA1Decoder (pAMVideoAccelerator, pGuid, m_dwDXVA1SurfaceCount);
-
- if (SUCCEEDED (hr)) {
- m_pVideoDecFilter->SetDXVA1Params (&m_GuidDecoderDXVA1, &m_ddUncompPixelFormat);
-
- pConnectMode = (DXVA_ConnectMode*)CoTaskMemAlloc (sizeof(DXVA_ConnectMode));
- pConnectMode->guidMode = m_GuidDecoderDXVA1;
- pConnectMode->wRestrictedMode = m_pVideoDecFilter->GetDXVA1RestrictedMode();
- *pdwSizeMiscData = sizeof(DXVA_ConnectMode);
- *ppMiscData = pConnectMode;
- }
- }
- }
-
-
- return hr;
+ HRESULT hr = E_UNEXPECTED;
+ AMVAUncompDataInfo UncompInfo;
+ AMVACompBufferInfo CompInfo[30];
+ DWORD dwNumTypesCompBuffers = _countof(CompInfo);
+ CComQIPtr<IAMVideoAccelerator> pAMVideoAccelerator = GetConnected();
+ DXVA_ConnectMode* pConnectMode;
+
+ if (pAMVideoAccelerator) {
+ memcpy(&UncompInfo.ddUncompPixelFormat, &m_ddUncompPixelFormat, sizeof(DDPIXELFORMAT));
+ UncompInfo.dwUncompWidth = m_pVideoDecFilter->PictWidthRounded();
+ UncompInfo.dwUncompHeight = m_pVideoDecFilter->PictHeightRounded();
+ hr = pAMVideoAccelerator->GetCompBufferInfo(&m_GuidDecoderDXVA1, &UncompInfo, &dwNumTypesCompBuffers, CompInfo);
+
+ if (SUCCEEDED(hr)) {
+ hr = m_pVideoDecFilter->CreateDXVA1Decoder(pAMVideoAccelerator, pGuid, m_dwDXVA1SurfaceCount);
+
+ if (SUCCEEDED(hr)) {
+ m_pVideoDecFilter->SetDXVA1Params(&m_GuidDecoderDXVA1, &m_ddUncompPixelFormat);
+
+ pConnectMode = (DXVA_ConnectMode*)CoTaskMemAlloc(sizeof(DXVA_ConnectMode));
+ pConnectMode->guidMode = m_GuidDecoderDXVA1;
+ pConnectMode->wRestrictedMode = m_pVideoDecFilter->GetDXVA1RestrictedMode();
+ *pdwSizeMiscData = sizeof(DXVA_ConnectMode);
+ *ppMiscData = pConnectMode;
+ }
+ }
+ }
+
+
+ return hr;
}
diff --git a/src/filters/transform/MPCVideoDec/VideoDecOutputPin.h b/src/filters/transform/MPCVideoDec/VideoDecOutputPin.h
index cb3a91750..d731f2afe 100644
--- a/src/filters/transform/MPCVideoDec/VideoDecOutputPin.h
+++ b/src/filters/transform/MPCVideoDec/VideoDecOutputPin.h
@@ -32,27 +32,27 @@ class CVideoDecDXVAAllocator;
class CVideoDecOutputPin : public CBaseVideoOutputPin
- , public IAMVideoAcceleratorNotify
+ , public IAMVideoAcceleratorNotify
{
public:
- CVideoDecOutputPin(TCHAR* pObjectName, CBaseVideoFilter* pFilter, HRESULT* phr, LPCWSTR pName);
+ CVideoDecOutputPin(TCHAR* pObjectName, CBaseVideoFilter* pFilter, HRESULT* phr, LPCWSTR pName);
- ~CVideoDecOutputPin();
+ ~CVideoDecOutputPin();
- HRESULT InitAllocator(IMemAllocator **ppAlloc);
+ HRESULT InitAllocator(IMemAllocator** ppAlloc);
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // IAMVideoAcceleratorNotify
- STDMETHODIMP GetUncompSurfacesInfo(const GUID *pGuid, LPAMVAUncompBufferInfo pUncompBufferInfo);
- STDMETHODIMP SetUncompSurfacesInfo(DWORD dwActualUncompSurfacesAllocated);
- STDMETHODIMP GetCreateVideoAcceleratorData(const GUID *pGuid, LPDWORD pdwSizeMiscData, LPVOID *ppMiscData);
+ // IAMVideoAcceleratorNotify
+ STDMETHODIMP GetUncompSurfacesInfo(const GUID* pGuid, LPAMVAUncompBufferInfo pUncompBufferInfo);
+ STDMETHODIMP SetUncompSurfacesInfo(DWORD dwActualUncompSurfacesAllocated);
+ STDMETHODIMP GetCreateVideoAcceleratorData(const GUID* pGuid, LPDWORD pdwSizeMiscData, LPVOID* ppMiscData);
private :
- CMPCVideoDecFilter* m_pVideoDecFilter;
- CVideoDecDXVAAllocator* m_pDXVA2Allocator;
- DWORD m_dwDXVA1SurfaceCount;
- GUID m_GuidDecoderDXVA1;
- DDPIXELFORMAT m_ddUncompPixelFormat;
+ CMPCVideoDecFilter* m_pVideoDecFilter;
+ CVideoDecDXVAAllocator* m_pDXVA2Allocator;
+ DWORD m_dwDXVA1SurfaceCount;
+ GUID m_GuidDecoderDXVA1;
+ DDPIXELFORMAT m_ddUncompPixelFormat;
};
diff --git a/src/filters/transform/MPCVideoDec/stdafx.cpp b/src/filters/transform/MPCVideoDec/stdafx.cpp
index 31f851930..fd127471b 100644
--- a/src/filters/transform/MPCVideoDec/stdafx.cpp
+++ b/src/filters/transform/MPCVideoDec/stdafx.cpp
@@ -31,18 +31,18 @@
void LOG(LPCTSTR fmt, ...)
{
- va_list args;
- va_start(args, fmt);
- if (TCHAR* buff = DNew TCHAR[_vsctprintf(fmt, args) + 1]) {
- _vstprintf(buff, fmt, args);
- if (FILE* f = _tfopen(LOG_FILE, _T("at"))) {
- fseek(f, 0, 2);
- _ftprintf_s(f, _T("%s\n"), buff);
- fclose(f);
- }
- delete [] buff;
- }
- va_end(args);
+ va_list args;
+ va_start(args, fmt);
+ if (TCHAR* buff = DNew TCHAR[_vsctprintf(fmt, args) + 1]) {
+ _vstprintf(buff, fmt, args);
+ if (FILE* f = _tfopen(LOG_FILE, _T("at"))) {
+ fseek(f, 0, 2);
+ _ftprintf_s(f, _T("%s\n"), buff);
+ fclose(f);
+ }
+ delete [] buff;
+ }
+ va_end(args);
}
#endif
diff --git a/src/filters/transform/MpaDecFilter/IMpaDecFilter.h b/src/filters/transform/MpaDecFilter/IMpaDecFilter.h
index 4bbbda817..424b0c6e8 100644
--- a/src/filters/transform/MpaDecFilter/IMpaDecFilter.h
+++ b/src/filters/transform/MpaDecFilter/IMpaDecFilter.h
@@ -26,26 +26,26 @@
enum MPCSampleFormat {SF_PCM16, SF_PCM24, SF_PCM32, SF_FLOAT32};
enum DolbyDigitalMode {
- DD_Unknown,
- DD_AC3, // Standard AC3
- DD_EAC3, // Dolby Digital +
- DD_TRUEHD, // Dolby True HD
- DD_MLP // Meridian Lossless Packing
+ DD_Unknown,
+ DD_AC3, // Standard AC3
+ DD_EAC3, // Dolby Digital +
+ DD_TRUEHD, // Dolby True HD
+ DD_MLP // Meridian Lossless Packing
};
interface __declspec(uuid("2067C60F-752F-4EBD-B0B1-4CBC5E00741C"))
IMpaDecFilter :
public IUnknown {
- enum enctype {ac3, dts, etlast};
+ enum enctype {ac3, dts, etlast};
- STDMETHOD(SetSampleFormat(MPCSampleFormat sf)) = 0;
- STDMETHOD_(MPCSampleFormat, GetSampleFormat()) = 0;
- STDMETHOD(SetSpeakerConfig(enctype et, int sc)) = 0; // sign of sc tells if spdif is active
- STDMETHOD_(int, GetSpeakerConfig(enctype et)) = 0;
- STDMETHOD(SetDynamicRangeControl(enctype et, bool fDRC)) = 0;
- STDMETHOD_(bool, GetDynamicRangeControl(enctype et)) = 0;
- STDMETHOD_(DolbyDigitalMode, GetDolbyDigitalMode()) = 0;
+ STDMETHOD(SetSampleFormat(MPCSampleFormat sf)) = 0;
+ STDMETHOD_(MPCSampleFormat, GetSampleFormat()) = 0;
+ STDMETHOD(SetSpeakerConfig(enctype et, int sc)) = 0; // sign of sc tells if spdif is active
+ STDMETHOD_(int, GetSpeakerConfig(enctype et)) = 0;
+ STDMETHOD(SetDynamicRangeControl(enctype et, bool fDRC)) = 0;
+ STDMETHOD_(bool, GetDynamicRangeControl(enctype et)) = 0;
+ STDMETHOD_(DolbyDigitalMode, GetDolbyDigitalMode()) = 0;
- STDMETHOD(SaveSettings()) = 0;
+ STDMETHOD(SaveSettings()) = 0;
};
diff --git a/src/filters/transform/MpaDecFilter/MpaDecFilter.cpp b/src/filters/transform/MpaDecFilter/MpaDecFilter.cpp
index bf8562444..1cbed4940 100644
--- a/src/filters/transform/MpaDecFilter/MpaDecFilter.cpp
+++ b/src/filters/transform/MpaDecFilter/MpaDecFilter.cpp
@@ -36,8 +36,8 @@
#ifdef _DEBUG
extern "C" int mingw_app_type = 1; /* 0:console, 1:windows. */
#endif
-void *__imp_toupper = toupper;
-void *__imp_time64 = _time64;
+void* __imp_toupper = toupper;
+void* __imp_time64 = _time64;
#endif
#include <InitGuid.h>
@@ -61,224 +61,224 @@ void *__imp_time64 = _time64;
#if HAS_FFMPEG_AUDIO_DECODERS
typedef struct {
- const CLSID* clsMinorType;
- const enum CodecID nFFCodec;
+ const CLSID* clsMinorType;
+ const enum CodecID nFFCodec;
} FFMPEG_AUDIO_CODECS;
static const FFMPEG_AUDIO_CODECS ffAudioCodecs[] = {
#if INTERNAL_DECODER_AMR
- // AMR
- { &MEDIASUBTYPE_AMR, CODEC_ID_AMR_NB },
- { &MEDIASUBTYPE_SAMR, CODEC_ID_AMR_NB },
- { &MEDIASUBTYPE_SAWB, CODEC_ID_AMR_WB },
+ // AMR
+ { &MEDIASUBTYPE_AMR, CODEC_ID_AMR_NB },
+ { &MEDIASUBTYPE_SAMR, CODEC_ID_AMR_NB },
+ { &MEDIASUBTYPE_SAWB, CODEC_ID_AMR_WB },
#endif
#if INTERNAL_DECODER_AAC
- // AAC
- { &MEDIASUBTYPE_AAC, CODEC_ID_AAC },
- { &MEDIASUBTYPE_MP4A, CODEC_ID_AAC },
- { &MEDIASUBTYPE_mp4a, CODEC_ID_AAC },
- { &MEDIASUBTYPE_AAC_ADTS, CODEC_ID_AAC },
- { &MEDIASUBTYPE_LATM_AAC, CODEC_ID_AAC_LATM },
+ // AAC
+ { &MEDIASUBTYPE_AAC, CODEC_ID_AAC },
+ { &MEDIASUBTYPE_MP4A, CODEC_ID_AAC },
+ { &MEDIASUBTYPE_mp4a, CODEC_ID_AAC },
+ { &MEDIASUBTYPE_AAC_ADTS, CODEC_ID_AAC },
+ { &MEDIASUBTYPE_LATM_AAC, CODEC_ID_AAC_LATM },
#endif
#if INTERNAL_DECODER_ALAC
- // ALAC
- { &MEDIASUBTYPE_ALAC, CODEC_ID_ALAC },
+ // ALAC
+ { &MEDIASUBTYPE_ALAC, CODEC_ID_ALAC },
#endif
#if INTERNAL_DECODER_ALS
- // MPEG-4 ALS
- { &MEDIASUBTYPE_ALS, CODEC_ID_MP4ALS },
+ // MPEG-4 ALS
+ { &MEDIASUBTYPE_ALS, CODEC_ID_MP4ALS },
#endif
#if INTERNAL_DECODER_VORBIS
- // Ogg Vorbis
- { &MEDIASUBTYPE_Vorbis2, CODEC_ID_VORBIS },
+ // Ogg Vorbis
+ { &MEDIASUBTYPE_Vorbis2, CODEC_ID_VORBIS },
#endif
#if INTERNAL_DECODER_NELLYMOSER
- // NellyMoser
- { &MEDIASUBTYPE_NELLYMOSER, CODEC_ID_NELLYMOSER },
+ // NellyMoser
+ { &MEDIASUBTYPE_NELLYMOSER, CODEC_ID_NELLYMOSER },
#endif
#if INTERNAL_DECODER_ADPCM
- // Qt ADPCM
- { &MEDIASUBTYPE_IMA4, CODEC_ID_ADPCM_IMA_QT },
- // FLV ADPCM
- { &MEDIASUBTYPE_ADPCM_SWF, CODEC_ID_ADPCM_SWF },
- // AMV IMA ADPCM
- { &MEDIASUBTYPE_ADPCM_AMV, CODEC_ID_ADPCM_IMA_AMV},
+ // Qt ADPCM
+ { &MEDIASUBTYPE_IMA4, CODEC_ID_ADPCM_IMA_QT },
+ // FLV ADPCM
+ { &MEDIASUBTYPE_ADPCM_SWF, CODEC_ID_ADPCM_SWF },
+ // AMV IMA ADPCM
+ { &MEDIASUBTYPE_ADPCM_AMV, CODEC_ID_ADPCM_IMA_AMV},
#endif
#if INTERNAL_DECODER_MPEGAUDIO
- // MPEG Audio
- { &MEDIASUBTYPE_MPEG1Packet, CODEC_ID_MP2 },
- { &MEDIASUBTYPE_MPEG1Payload, CODEC_ID_MP2 },
- { &MEDIASUBTYPE_MPEG1AudioPayload, CODEC_ID_MP2 },
- { &MEDIASUBTYPE_MPEG2_AUDIO, CODEC_ID_MP2 },
- { &MEDIASUBTYPE_MP3, CODEC_ID_MP3 },
+ // MPEG Audio
+ { &MEDIASUBTYPE_MPEG1Packet, CODEC_ID_MP2 },
+ { &MEDIASUBTYPE_MPEG1Payload, CODEC_ID_MP2 },
+ { &MEDIASUBTYPE_MPEG1AudioPayload, CODEC_ID_MP2 },
+ { &MEDIASUBTYPE_MPEG2_AUDIO, CODEC_ID_MP2 },
+ { &MEDIASUBTYPE_MP3, CODEC_ID_MP3 },
#endif
#if INTERNAL_DECODER_REALAUDIO
- // RealMedia Audio
- { &MEDIASUBTYPE_14_4, CODEC_ID_RA_144 },
- { &MEDIASUBTYPE_28_8, CODEC_ID_RA_288 },
- { &MEDIASUBTYPE_ATRC, CODEC_ID_ATRAC3 },
- { &MEDIASUBTYPE_COOK, CODEC_ID_COOK },
- { &MEDIASUBTYPE_SIPR, CODEC_ID_SIPR },
- { &MEDIASUBTYPE_RAAC, CODEC_ID_AAC },
- { &MEDIASUBTYPE_RACP, CODEC_ID_AAC },
+ // RealMedia Audio
+ { &MEDIASUBTYPE_14_4, CODEC_ID_RA_144 },
+ { &MEDIASUBTYPE_28_8, CODEC_ID_RA_288 },
+ { &MEDIASUBTYPE_ATRC, CODEC_ID_ATRAC3 },
+ { &MEDIASUBTYPE_COOK, CODEC_ID_COOK },
+ { &MEDIASUBTYPE_SIPR, CODEC_ID_SIPR },
+ { &MEDIASUBTYPE_RAAC, CODEC_ID_AAC },
+ { &MEDIASUBTYPE_RACP, CODEC_ID_AAC },
#endif
#if INTERNAL_DECODER_AC3
- { &MEDIASUBTYPE_DOLBY_DDPLUS, CODEC_ID_EAC3 },
- { &MEDIASUBTYPE_DOLBY_TRUEHD, CODEC_ID_TRUEHD },
- { &MEDIASUBTYPE_MLP, CODEC_ID_MLP },
+ { &MEDIASUBTYPE_DOLBY_DDPLUS, CODEC_ID_EAC3 },
+ { &MEDIASUBTYPE_DOLBY_TRUEHD, CODEC_ID_TRUEHD },
+ { &MEDIASUBTYPE_MLP, CODEC_ID_MLP },
#endif
#if INTERNAL_DECODER_FLAC
- { &MEDIASUBTYPE_FLAC_FRAMED, CODEC_ID_FLAC },
+ { &MEDIASUBTYPE_FLAC_FRAMED, CODEC_ID_FLAC },
#endif
- { &MEDIASUBTYPE_None, CODEC_ID_NONE },
+ { &MEDIASUBTYPE_None, CODEC_ID_NONE },
};
#endif
const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
#if INTERNAL_DECODER_MPEGAUDIO
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_MP3},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG1AudioPayload},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG1Payload},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG1Packet},
- {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_MPEG2_AUDIO},
- {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_MPEG2_AUDIO},
- {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_MPEG2_AUDIO},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG2_AUDIO},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_MP3},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG1AudioPayload},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG1Payload},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG1Packet},
+ {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_MPEG2_AUDIO},
+ {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_MPEG2_AUDIO},
+ {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_MPEG2_AUDIO},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG2_AUDIO},
#endif
#if INTERNAL_DECODER_AC3
- {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_DOLBY_AC3},
- {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_DOLBY_AC3},
- {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_DOLBY_AC3},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_DOLBY_AC3},
- {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_DOLBY_DDPLUS},
- {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_DOLBY_DDPLUS},
- {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_DOLBY_DDPLUS},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_DOLBY_DDPLUS},
- {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_DOLBY_TRUEHD},
- {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_DOLBY_TRUEHD},
- {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_DOLBY_TRUEHD},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_DOLBY_TRUEHD},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_WAVE_DOLBY_AC3},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_MLP},
+ {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_DOLBY_AC3},
+ {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_DOLBY_AC3},
+ {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_DOLBY_AC3},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_DOLBY_AC3},
+ {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_DOLBY_DDPLUS},
+ {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_DOLBY_DDPLUS},
+ {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_DOLBY_DDPLUS},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_DOLBY_DDPLUS},
+ {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_DOLBY_TRUEHD},
+ {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_DOLBY_TRUEHD},
+ {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_DOLBY_TRUEHD},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_DOLBY_TRUEHD},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_WAVE_DOLBY_AC3},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_MLP},
#endif
#if INTERNAL_DECODER_DTS
- {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_DTS},
- {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_DTS},
- {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_DTS},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_DTS},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_WAVE_DTS},
+ {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_DTS},
+ {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_DTS},
+ {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_DTS},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_DTS},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_WAVE_DTS},
#endif
#if INTERNAL_DECODER_LPCM
- {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_DVD_LPCM_AUDIO},
- {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_DVD_LPCM_AUDIO},
- {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_DVD_LPCM_AUDIO},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_DVD_LPCM_AUDIO},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_HDMV_LPCM_AUDIO},
+ {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_DVD_LPCM_AUDIO},
+ {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_DVD_LPCM_AUDIO},
+ {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_DVD_LPCM_AUDIO},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_DVD_LPCM_AUDIO},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_HDMV_LPCM_AUDIO},
#endif
#if INTERNAL_DECODER_AAC
- {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_AAC},
- {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_AAC},
- {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_AAC},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_AAC},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_LATM_AAC},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_AAC_ADTS},
- {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_MP4A},
- {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_MP4A},
- {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_MP4A},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_MP4A},
- {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_mp4a},
- {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_mp4a},
- {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_mp4a},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_mp4a},
+ {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_AAC},
+ {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_AAC},
+ {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_AAC},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_AAC},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_LATM_AAC},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_AAC_ADTS},
+ {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_MP4A},
+ {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_MP4A},
+ {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_MP4A},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_MP4A},
+ {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_mp4a},
+ {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_mp4a},
+ {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_mp4a},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_mp4a},
#endif
#if INTERNAL_DECODER_AMR
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_AMR},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_SAMR},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_SAWB},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_AMR},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_SAMR},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_SAWB},
#endif
#if INTERNAL_DECODER_PS2AUDIO
- {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_PS2_PCM},
- {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_PS2_PCM},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_PS2_PCM},
- {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_PS2_ADPCM},
- {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_PS2_ADPCM},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_PS2_ADPCM},
+ {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_PS2_PCM},
+ {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_PS2_PCM},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_PS2_PCM},
+ {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_PS2_ADPCM},
+ {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_PS2_ADPCM},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_PS2_ADPCM},
#endif
#if INTERNAL_DECODER_VORBIS
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_Vorbis2},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_Vorbis2},
#endif
#if INTERNAL_DECODER_FLAC
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_FLAC_FRAMED},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_FLAC_FRAMED},
#endif
#if INTERNAL_DECODER_NELLYMOSER
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_NELLYMOSER},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_NELLYMOSER},
#endif
#if INTERNAL_DECODER_PCM
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_NONE},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_RAW},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_TWOS},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_SOWT},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_IN24},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_IN32},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_FL32},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_FL64},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_IEEE_FLOAT}, // only for 64-bit float PCM
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_NONE},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_RAW},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_TWOS},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_SOWT},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_IN24},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_IN32},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_FL32},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_FL64},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_IEEE_FLOAT}, // only for 64-bit float PCM
#endif
#if INTERNAL_DECODER_ADPCM
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_IMA4},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_ADPCM_SWF},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_ADPCM_AMV},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_IMA4},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_ADPCM_SWF},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_ADPCM_AMV},
#endif
#if INTERNAL_DECODER_REALAUDIO
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_14_4},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_28_8},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_ATRC},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_COOK},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_DNET},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_SIPR},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_RAAC},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_RACP},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_14_4},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_28_8},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_ATRC},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_COOK},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_DNET},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_SIPR},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_RAAC},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_RACP},
#endif
#if INTERNAL_DECODER_ALAC
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_ALAC},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_ALAC},
#endif
#if INTERNAL_DECODER_ALS
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_ALS},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_ALS},
#endif
#if !HAS_OTHER_AUDIO_DECODERS && !HAS_FFMPEG_AUDIO_DECODERS
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_None} // just to prevent compilation error
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_None} // just to prevent compilation error
#endif
};
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM},
+ {&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM},
};
const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CMpaDecFilter), MPCAudioDecName, /*MERIT_DO_NOT_USE*/0x40000001, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CMpaDecFilter), MPCAudioDecName, /*MERIT_DO_NOT_USE*/0x40000001, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, &__uuidof(CMpaDecFilter), CreateInstance<CMpaDecFilter>, NULL, &sudFilter[0]},
- {L"CMpaDecPropertyPage", &__uuidof(CMpaDecSettingsWnd), CreateInstance<CInternalPropertyPageTempl<CMpaDecSettingsWnd> >},
+ {sudFilter[0].strName, &__uuidof(CMpaDecFilter), CreateInstance<CMpaDecFilter>, NULL, &sudFilter[0]},
+ {L"CMpaDecPropertyPage", &__uuidof(CMpaDecSettingsWnd), CreateInstance<CInternalPropertyPageTempl<CMpaDecSettingsWnd> >},
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
//
@@ -291,9 +291,9 @@ CFilterApp theApp;
#pragma warning(disable : 4245)
static struct scmap_t {
- WORD nChannels;
- BYTE ch[8];
- DWORD dwChannelMask;
+ WORD nChannels;
+ BYTE ch[8];
+ DWORD dwChannelMask;
}
// dshow: left, right, center, LFE, left surround, right surround
// a52dec: LFE, left, center, right, left surround, right surround
@@ -301,1253 +301,1257 @@ static struct scmap_t {
// lets see how we can map these things to dshow (oh the joy!)
-s_scmap_a52dec[2*11] = {
- {2, {0, 1,-1,-1,-1,-1,-1,-1}, 0}, // A52_CHANNEL
- {1, {0,-1,-1,-1,-1,-1,-1,-1}, 0}, // A52_MONO
- {2, {0, 1,-1,-1,-1,-1,-1,-1}, 0}, // A52_STEREO
- {3, {0, 2, 1,-1,-1,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER}, // A52_3F
- {3, {0, 1, 2,-1,-1,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_BACK_CENTER}, // A52_2F1R
- {4, {0, 2, 1, 3,-1,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_BACK_CENTER}, // A52_3F1R
- {4, {0, 1, 2, 3,-1,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT}, // A52_2F2R
- {5, {0, 2, 1, 3, 4,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT}, // A52_3F2R
- {1, {0,-1,-1,-1,-1,-1,-1,-1}, 0}, // A52_CHANNEL1
- {1, {0,-1,-1,-1,-1,-1,-1,-1}, 0}, // A52_CHANNEL2
- {2, {0, 1,-1,-1,-1,-1,-1,-1}, 0}, // A52_DOLBY
-
- {3, {1, 2, 0,-1,-1,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_LOW_FREQUENCY}, // A52_CHANNEL|A52_LFE
- {2, {1, 0,-1,-1,-1,-1,-1,-1}, SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY}, // A52_MONO|A52_LFE
- {3, {1, 2, 0,-1,-1,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_LOW_FREQUENCY}, // A52_STEREO|A52_LFE
- {4, {1, 3, 2, 0,-1,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY}, // A52_3F|A52_LFE
- {4, {1, 2, 0, 3,-1,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_CENTER}, // A52_2F1R|A52_LFE
- {5, {1, 3, 2, 0, 4,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_CENTER}, // A52_3F1R|A52_LFE
- {5, {1, 2, 0, 3, 4,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT}, // A52_2F2R|A52_LFE
- {6, {1, 3, 2, 0, 4, 5,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT}, // A52_3F2R|A52_LFE
- {2, {1, 0,-1,-1,-1,-1,-1,-1}, SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY}, // A52_CHANNEL1|A52_LFE
- {2, {1, 0,-1,-1,-1,-1,-1,-1}, SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY}, // A52_CHANNEL2|A52_LFE
- {3, {1, 2, 0,-1,-1,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_LOW_FREQUENCY}, // A52_DOLBY|A52_LFE
+s_scmap_a52dec[2 * 11] = {
+ {2, {0, 1, -1, -1, -1, -1, -1, -1}, 0}, // A52_CHANNEL
+ {1, {0, -1, -1, -1, -1, -1, -1, -1}, 0}, // A52_MONO
+ {2, {0, 1, -1, -1, -1, -1, -1, -1}, 0}, // A52_STEREO
+ {3, {0, 2, 1, -1, -1, -1, -1, -1}, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER}, // A52_3F
+ {3, {0, 1, 2, -1, -1, -1, -1, -1}, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_CENTER}, // A52_2F1R
+ {4, {0, 2, 1, 3, -1, -1, -1, -1}, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_BACK_CENTER}, // A52_3F1R
+ {4, {0, 1, 2, 3, -1, -1, -1, -1}, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT}, // A52_2F2R
+ {5, {0, 2, 1, 3, 4, -1, -1, -1}, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT}, // A52_3F2R
+ {1, {0, -1, -1, -1, -1, -1, -1, -1}, 0}, // A52_CHANNEL1
+ {1, {0, -1, -1, -1, -1, -1, -1, -1}, 0}, // A52_CHANNEL2
+ {2, {0, 1, -1, -1, -1, -1, -1, -1}, 0}, // A52_DOLBY
+
+ {3, {1, 2, 0, -1, -1, -1, -1, -1}, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY}, // A52_CHANNEL|A52_LFE
+ {2, {1, 0, -1, -1, -1, -1, -1, -1}, SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY}, // A52_MONO|A52_LFE
+ {3, {1, 2, 0, -1, -1, -1, -1, -1}, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY}, // A52_STEREO|A52_LFE
+ {4, {1, 3, 2, 0, -1, -1, -1, -1}, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY}, // A52_3F|A52_LFE
+ {4, {1, 2, 0, 3, -1, -1, -1, -1}, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_CENTER}, // A52_2F1R|A52_LFE
+ {5, {1, 3, 2, 0, 4, -1, -1, -1}, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_CENTER}, // A52_3F1R|A52_LFE
+ {5, {1, 2, 0, 3, 4, -1, -1, -1}, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT}, // A52_2F2R|A52_LFE
+ {6, {1, 3, 2, 0, 4, 5, -1, -1}, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT}, // A52_3F2R|A52_LFE
+ {2, {1, 0, -1, -1, -1, -1, -1, -1}, SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY}, // A52_CHANNEL1|A52_LFE
+ {2, {1, 0, -1, -1, -1, -1, -1, -1}, SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY}, // A52_CHANNEL2|A52_LFE
+ {3, {1, 2, 0, -1, -1, -1, -1, -1}, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY}, // A52_DOLBY|A52_LFE
},
-s_scmap_libdca[2*10] = {
- {1, {0,-1,-1,-1,-1,-1,-1,-1}, 0}, // DTS_MONO
- {2, {0, 1,-1,-1,-1,-1,-1,-1}, 0}, // DTS_CHANNEL
- {2, {0, 1,-1,-1,-1,-1,-1,-1}, 0}, // DTS_STEREO
- {2, {0, 1,-1,-1,-1,-1,-1,-1}, 0}, // DTS_STEREO_SUMDIFF
- {2, {0, 1,-1,-1,-1,-1,-1,-1}, 0}, // DTS_STEREO_TOTAL
- {3, {1, 2, 0,-1,-1,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER}, // DTS_3F
- {3, {0, 1, 2,-1,-1,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_BACK_CENTER}, // DTS_2F1R
- {4, {1, 2, 0, 3,-1,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_BACK_CENTER}, // DTS_3F1R
- {4, {0, 1, 2, 3,-1,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT}, // DTS_2F2R
- {5, {1, 2, 0, 3, 4,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT}, // DTS_3F2R
-
- {2, {0, 1,-1,-1,-1,-1,-1,-1}, SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY}, // DTS_MONO|DTS_LFE
- {3, {0, 1, 2,-1,-1,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_LOW_FREQUENCY}, // DTS_CHANNEL|DTS_LFE
- {3, {0, 1, 2,-1,-1,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_LOW_FREQUENCY}, // DTS_STEREO|DTS_LFE
- {3, {0, 1, 2,-1,-1,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_LOW_FREQUENCY}, // DTS_STEREO_SUMDIFF|DTS_LFE
- {3, {0, 1, 2,-1,-1,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_LOW_FREQUENCY}, // DTS_STEREO_TOTAL|DTS_LFE
- {4, {1, 2, 0, 3,-1,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY}, // DTS_3F|DTS_LFE
- {4, {0, 1, 3, 2,-1,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_CENTER}, // DTS_2F1R|DTS_LFE
- {5, {1, 2, 0, 4, 3,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_CENTER}, // DTS_3F1R|DTS_LFE
- {5, {0, 1, 4, 2, 3,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT}, // DTS_2F2R|DTS_LFE
- {6, {1, 2, 0, 5, 3, 4,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT}, // DTS_3F2R|DTS_LFE
+s_scmap_libdca[2 * 10] = {
+ {1, {0, -1, -1, -1, -1, -1, -1, -1}, 0}, // DTS_MONO
+ {2, {0, 1, -1, -1, -1, -1, -1, -1}, 0}, // DTS_CHANNEL
+ {2, {0, 1, -1, -1, -1, -1, -1, -1}, 0}, // DTS_STEREO
+ {2, {0, 1, -1, -1, -1, -1, -1, -1}, 0}, // DTS_STEREO_SUMDIFF
+ {2, {0, 1, -1, -1, -1, -1, -1, -1}, 0}, // DTS_STEREO_TOTAL
+ {3, {1, 2, 0, -1, -1, -1, -1, -1}, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER}, // DTS_3F
+ {3, {0, 1, 2, -1, -1, -1, -1, -1}, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_CENTER}, // DTS_2F1R
+ {4, {1, 2, 0, 3, -1, -1, -1, -1}, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_BACK_CENTER}, // DTS_3F1R
+ {4, {0, 1, 2, 3, -1, -1, -1, -1}, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT}, // DTS_2F2R
+ {5, {1, 2, 0, 3, 4, -1, -1, -1}, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT}, // DTS_3F2R
+
+ {2, {0, 1, -1, -1, -1, -1, -1, -1}, SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY}, // DTS_MONO|DTS_LFE
+ {3, {0, 1, 2, -1, -1, -1, -1, -1}, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY}, // DTS_CHANNEL|DTS_LFE
+ {3, {0, 1, 2, -1, -1, -1, -1, -1}, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY}, // DTS_STEREO|DTS_LFE
+ {3, {0, 1, 2, -1, -1, -1, -1, -1}, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY}, // DTS_STEREO_SUMDIFF|DTS_LFE
+ {3, {0, 1, 2, -1, -1, -1, -1, -1}, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY}, // DTS_STEREO_TOTAL|DTS_LFE
+ {4, {1, 2, 0, 3, -1, -1, -1, -1}, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY}, // DTS_3F|DTS_LFE
+ {4, {0, 1, 3, 2, -1, -1, -1, -1}, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_CENTER}, // DTS_2F1R|DTS_LFE
+ {5, {1, 2, 0, 4, 3, -1, -1, -1}, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_CENTER}, // DTS_3F1R|DTS_LFE
+ {5, {0, 1, 4, 2, 3, -1, -1, -1}, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT}, // DTS_2F2R|DTS_LFE
+ {6, {1, 2, 0, 5, 3, 4, -1, -1}, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT}, // DTS_3F2R|DTS_LFE
},
s_scmap_hdmv[] = {
- // FL FR FC LFe BL BR FLC FRC
- {0, {-1,-1,-1,-1,-1,-1,-1,-1 }, 0}, // INVALID
- {1, { 0,-1,-1,-1,-1,-1,-1,-1 }, 0}, // Mono M1, 0
- {0, {-1,-1,-1,-1,-1,-1,-1,-1 }, 0}, // INVALID
- {2, { 0, 1,-1,-1,-1,-1,-1,-1 }, 0}, // Stereo FL, FR
- {4, { 0, 1, 2,-1,-1,-1,-1,-1 }, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER}, // 3/0 FL, FR, FC
- {4, { 0, 1, 2,-1,-1,-1,-1,-1 }, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_LOW_FREQUENCY}, // 2/1 FL, FR, Surround
- {4, { 0, 1, 2, 3,-1,-1,-1,-1 }, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY}, // 3/1 FL, FR, FC, Surround
- {4, { 0, 1, 2, 3,-1,-1,-1,-1 }, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT}, // 2/2 FL, FR, BL, BR
- {6, { 0, 1, 2, 3, 4,-1,-1,-1 }, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT}, // 3/2 FL, FR, FC, BL, BR
- {6, { 0, 1, 2, 5, 3, 4,-1,-1 }, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT},// 3/2+LFe FL, FR, FC, BL, BR, LFe
- {8, { 0, 1, 2, 3, 6, 4, 5,-1 }, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT|SPEAKER_SIDE_LEFT|SPEAKER_SIDE_RIGHT},// 3/4 FL, FR, FC, BL, Bls, Brs, BR
- {8, { 0, 1, 2, 7, 4, 5, 3, 6 }, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT|SPEAKER_SIDE_LEFT|SPEAKER_SIDE_RIGHT},// 3/4+LFe FL, FR, FC, BL, Bls, Brs, BR, LFe
+ // FL FR FC LFe BL BR FLC FRC
+ {0, { -1, -1, -1, -1, -1, -1, -1, -1 }, 0}, // INVALID
+ {1, { 0, -1, -1, -1, -1, -1, -1, -1 }, 0}, // Mono M1, 0
+ {0, { -1, -1, -1, -1, -1, -1, -1, -1 }, 0}, // INVALID
+ {2, { 0, 1, -1, -1, -1, -1, -1, -1 }, 0}, // Stereo FL, FR
+ {4, { 0, 1, 2, -1, -1, -1, -1, -1 }, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER}, // 3/0 FL, FR, FC
+ {4, { 0, 1, 2, -1, -1, -1, -1, -1 }, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY}, // 2/1 FL, FR, Surround
+ {4, { 0, 1, 2, 3, -1, -1, -1, -1 }, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY}, // 3/1 FL, FR, FC, Surround
+ {4, { 0, 1, 2, 3, -1, -1, -1, -1 }, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT}, // 2/2 FL, FR, BL, BR
+ {6, { 0, 1, 2, 3, 4, -1, -1, -1 }, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT}, // 3/2 FL, FR, FC, BL, BR
+ {6, { 0, 1, 2, 5, 3, 4, -1, -1 }, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT}, // 3/2+LFe FL, FR, FC, BL, BR, LFe
+ {8, { 0, 1, 2, 3, 6, 4, 5, -1 }, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT}, // 3/4 FL, FR, FC, BL, Bls, Brs, BR
+ {8, { 0, 1, 2, 7, 4, 5, 3, 6 }, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT}, // 3/4+LFe FL, FR, FC, BL, Bls, Brs, BR, LFe
};
#pragma warning(default : 4245)
static DWORD get_lav_channel_layout(uint64_t layout)
{
- if (layout > UINT32_MAX) {
- if (layout & AV_CH_WIDE_LEFT)
- layout = (layout & ~AV_CH_WIDE_LEFT) | AV_CH_FRONT_LEFT_OF_CENTER;
- if (layout & AV_CH_WIDE_RIGHT)
- layout = (layout & ~AV_CH_WIDE_RIGHT) | AV_CH_FRONT_RIGHT_OF_CENTER;
-
- if (layout & AV_CH_SURROUND_DIRECT_LEFT)
- layout = (layout & ~AV_CH_SURROUND_DIRECT_LEFT) | AV_CH_SIDE_LEFT;
- if (layout & AV_CH_SURROUND_DIRECT_RIGHT)
- layout = (layout & ~AV_CH_SURROUND_DIRECT_RIGHT) | AV_CH_SIDE_RIGHT;
- }
-
- return (DWORD)layout;
+ if (layout > UINT32_MAX) {
+ if (layout & AV_CH_WIDE_LEFT) {
+ layout = (layout & ~AV_CH_WIDE_LEFT) | AV_CH_FRONT_LEFT_OF_CENTER;
+ }
+ if (layout & AV_CH_WIDE_RIGHT) {
+ layout = (layout & ~AV_CH_WIDE_RIGHT) | AV_CH_FRONT_RIGHT_OF_CENTER;
+ }
+
+ if (layout & AV_CH_SURROUND_DIRECT_LEFT) {
+ layout = (layout & ~AV_CH_SURROUND_DIRECT_LEFT) | AV_CH_SIDE_LEFT;
+ }
+ if (layout & AV_CH_SURROUND_DIRECT_RIGHT) {
+ layout = (layout & ~AV_CH_SURROUND_DIRECT_RIGHT) | AV_CH_SIDE_RIGHT;
+ }
+ }
+
+ return (DWORD)layout;
}
CMpaDecFilter::CMpaDecFilter(LPUNKNOWN lpunk, HRESULT* phr)
- : CTransformFilter(NAME("CMpaDecFilter"), lpunk, __uuidof(this))
- , m_iSampleFormat(SF_PCM16)
- , m_bResync(false)
+ : CTransformFilter(NAME("CMpaDecFilter"), lpunk, __uuidof(this))
+ , m_iSampleFormat(SF_PCM16)
+ , m_bResync(false)
{
- if (phr) {
- *phr = S_OK;
- }
-
- m_pInput = DNew CMpaDecInputPin(this, phr, L"In");
- if (!m_pInput) {
- *phr = E_OUTOFMEMORY;
- }
- if (FAILED(*phr)) {
- return;
- }
-
- m_pOutput = DNew CTransformOutputPin(NAME("CTransformOutputPin"), this, phr, L"Out");
- if (!m_pOutput) {
- *phr = E_OUTOFMEMORY;
- }
- if (FAILED(*phr)) {
- delete m_pInput, m_pInput = NULL;
- return;
- }
-
- m_iSpeakerConfig[ac3] = A52_STEREO;
- m_iSpeakerConfig[dts] = DTS_STEREO;
- m_fDynamicRangeControl[ac3] = false;
- m_fDynamicRangeControl[dts] = false;
- m_DolbyDigitalMode = DD_Unknown;
+ if (phr) {
+ *phr = S_OK;
+ }
+
+ m_pInput = DNew CMpaDecInputPin(this, phr, L"In");
+ if (!m_pInput) {
+ *phr = E_OUTOFMEMORY;
+ }
+ if (FAILED(*phr)) {
+ return;
+ }
+
+ m_pOutput = DNew CTransformOutputPin(NAME("CTransformOutputPin"), this, phr, L"Out");
+ if (!m_pOutput) {
+ *phr = E_OUTOFMEMORY;
+ }
+ if (FAILED(*phr)) {
+ delete m_pInput, m_pInput = NULL;
+ return;
+ }
+
+ m_iSpeakerConfig[ac3] = A52_STEREO;
+ m_iSpeakerConfig[dts] = DTS_STEREO;
+ m_fDynamicRangeControl[ac3] = false;
+ m_fDynamicRangeControl[dts] = false;
+ m_DolbyDigitalMode = DD_Unknown;
#if defined(REGISTER_FILTER) || HAS_FFMPEG_AUDIO_DECODERS
- m_pAVCodec = NULL;
- m_pAVCtx = NULL;
- m_pParser = NULL;
- m_pFrame = NULL;
- m_pFFBuffer = NULL;
- m_nFFBufferSize = 0;
+ m_pAVCodec = NULL;
+ m_pAVCtx = NULL;
+ m_pParser = NULL;
+ m_pFrame = NULL;
+ m_pFFBuffer = NULL;
+ m_nFFBufferSize = 0;
#endif
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_AC3
- m_a52_state = NULL;
+ m_a52_state = NULL;
#endif
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_DTS
- m_dts_state = NULL;
+ m_dts_state = NULL;
#endif
#ifdef REGISTER_FILTER
- CRegKey key;
- if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Audio Decoder"), KEY_READ)) {
- DWORD dw;
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("SampleFormat"), dw)) {
- m_iSampleFormat = (MPCSampleFormat)dw;
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Ac3SpeakerConfig"), dw)) {
- m_iSpeakerConfig[ac3] = (int)dw;
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("DtsSpeakerConfig"), dw)) {
- m_iSpeakerConfig[dts] = (int)dw;
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Ac3DynamicRangeControl"), dw)) {
- m_fDynamicRangeControl[ac3] = !!dw;
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("DtsDynamicRangeControl"), dw)) {
- m_fDynamicRangeControl[dts] = !!dw;
- }
- }
+ CRegKey key;
+ if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Audio Decoder"), KEY_READ)) {
+ DWORD dw;
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("SampleFormat"), dw)) {
+ m_iSampleFormat = (MPCSampleFormat)dw;
+ }
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Ac3SpeakerConfig"), dw)) {
+ m_iSpeakerConfig[ac3] = (int)dw;
+ }
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("DtsSpeakerConfig"), dw)) {
+ m_iSpeakerConfig[dts] = (int)dw;
+ }
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Ac3DynamicRangeControl"), dw)) {
+ m_fDynamicRangeControl[ac3] = !!dw;
+ }
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("DtsDynamicRangeControl"), dw)) {
+ m_fDynamicRangeControl[dts] = !!dw;
+ }
+ }
#else
- m_iSampleFormat = (MPCSampleFormat)AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Audio Decoder"), _T("SampleFormat"), m_iSampleFormat);
- m_iSpeakerConfig[ac3] = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Audio Decoder"), _T("Ac3SpeakerConfig"), m_iSpeakerConfig[ac3]);
- m_iSpeakerConfig[dts] = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Audio Decoder"), _T("DtsSpeakerConfig"), m_iSpeakerConfig[dts]);
- m_fDynamicRangeControl[ac3] = !!AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Audio Decoder"), _T("Ac3DynamicRangeControl"), m_fDynamicRangeControl[ac3]);
- m_fDynamicRangeControl[dts] = !!AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Audio Decoder"), _T("DtsDynamicRangeControl"), m_fDynamicRangeControl[dts]);
+ m_iSampleFormat = (MPCSampleFormat)AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Audio Decoder"), _T("SampleFormat"), m_iSampleFormat);
+ m_iSpeakerConfig[ac3] = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Audio Decoder"), _T("Ac3SpeakerConfig"), m_iSpeakerConfig[ac3]);
+ m_iSpeakerConfig[dts] = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Audio Decoder"), _T("DtsSpeakerConfig"), m_iSpeakerConfig[dts]);
+ m_fDynamicRangeControl[ac3] = !!AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Audio Decoder"), _T("Ac3DynamicRangeControl"), m_fDynamicRangeControl[ac3]);
+ m_fDynamicRangeControl[dts] = !!AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Audio Decoder"), _T("DtsDynamicRangeControl"), m_fDynamicRangeControl[dts]);
#endif
}
CMpaDecFilter::~CMpaDecFilter()
{
- StopStreaming();
+ StopStreaming();
}
STDMETHODIMP CMpaDecFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- return
- QI(IMpaDecFilter)
- QI(ISpecifyPropertyPages)
- QI(ISpecifyPropertyPages2)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IMpaDecFilter)
+ QI(ISpecifyPropertyPages)
+ QI(ISpecifyPropertyPages2)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CMpaDecFilter::EndOfStream()
{
- CAutoLock cAutoLock(&m_csReceive);
- return __super::EndOfStream();
+ CAutoLock cAutoLock(&m_csReceive);
+ return __super::EndOfStream();
}
HRESULT CMpaDecFilter::BeginFlush()
{
- return __super::BeginFlush();
+ return __super::BeginFlush();
}
HRESULT CMpaDecFilter::EndFlush()
{
- CAutoLock cAutoLock(&m_csReceive);
- m_buff.RemoveAll();
- return __super::EndFlush();
+ CAutoLock cAutoLock(&m_csReceive);
+ m_buff.RemoveAll();
+ return __super::EndFlush();
}
HRESULT CMpaDecFilter::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- CAutoLock cAutoLock(&m_csReceive);
- m_buff.RemoveAll();
- m_ps2_state.sync = false;
- m_DolbyDigitalMode = DD_Unknown;
+ CAutoLock cAutoLock(&m_csReceive);
+ m_buff.RemoveAll();
+ m_ps2_state.sync = false;
+ m_DolbyDigitalMode = DD_Unknown;
#if defined(REGISTER_FILTER) || HAS_FFMPEG_AUDIO_DECODERS
- if (m_pAVCtx) {
- avcodec_flush_buffers (m_pAVCtx);
- }
+ if (m_pAVCtx) {
+ avcodec_flush_buffers(m_pAVCtx);
+ }
#endif
- m_bResync = true;
+ m_bResync = true;
- return __super::NewSegment(tStart, tStop, dRate);
+ return __super::NewSegment(tStart, tStop, dRate);
}
#if defined(REGISTER_FILTER) || HAS_FFMPEG_AUDIO_DECODERS
enum CodecID CMpaDecFilter::FindCodec(const GUID subtype)
{
- for (int i=0; i<_countof(ffAudioCodecs); i++)
- if (subtype == *ffAudioCodecs[i].clsMinorType) {
- return ffAudioCodecs[i].nFFCodec;
- }
+ for (int i = 0; i < _countof(ffAudioCodecs); i++)
+ if (subtype == *ffAudioCodecs[i].clsMinorType) {
+ return ffAudioCodecs[i].nFFCodec;
+ }
- return CODEC_ID_NONE;
+ return CODEC_ID_NONE;
}
#endif
HRESULT CMpaDecFilter::Receive(IMediaSample* pIn)
{
- CAutoLock cAutoLock(&m_csReceive);
+ CAutoLock cAutoLock(&m_csReceive);
- HRESULT hr;
+ HRESULT hr;
- AM_SAMPLE2_PROPERTIES* const pProps = m_pInput->SampleProps();
- if (pProps->dwStreamId != AM_STREAM_MEDIA) {
- return m_pOutput->Deliver(pIn);
- }
+ AM_SAMPLE2_PROPERTIES* const pProps = m_pInput->SampleProps();
+ if (pProps->dwStreamId != AM_STREAM_MEDIA) {
+ return m_pOutput->Deliver(pIn);
+ }
- AM_MEDIA_TYPE* pmt;
- if (SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt) {
- CMediaType mt(*pmt);
- m_pInput->SetMediaType(&mt);
- DeleteMediaType(pmt);
- pmt = NULL;
- m_DolbyDigitalMode = DD_Unknown;
- }
+ AM_MEDIA_TYPE* pmt;
+ if (SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt) {
+ CMediaType mt(*pmt);
+ m_pInput->SetMediaType(&mt);
+ DeleteMediaType(pmt);
+ pmt = NULL;
+ m_DolbyDigitalMode = DD_Unknown;
+ }
- BYTE* pDataIn = NULL;
- if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
- return hr;
- }
+ BYTE* pDataIn = NULL;
+ if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
+ return hr;
+ }
- long len = pIn->GetActualDataLength();
+ long len = pIn->GetActualDataLength();
- (static_cast<CDeCSSInputPin*>(m_pInput))->StripPacket(pDataIn, len);
+ (static_cast<CDeCSSInputPin*>(m_pInput))->StripPacket(pDataIn, len);
- REFERENCE_TIME rtStart = _I64_MIN, rtStop = _I64_MIN;
- hr = pIn->GetTime(&rtStart, &rtStop);
+ REFERENCE_TIME rtStart = _I64_MIN, rtStop = _I64_MIN;
+ hr = pIn->GetTime(&rtStart, &rtStop);
#if 0
- if (SUCCEEDED(hr)) {
- TRACE(_T("CMpaDecFilter::Receive(): rtStart = %10I64d, rtStop = %10I64d\n"), rtStart, rtStop);
- } else {
- TRACE(_T("CMpaDecFilter::Receive(): frame without timestamp\n"));
- }
+ if (SUCCEEDED(hr)) {
+ TRACE(_T("CMpaDecFilter::Receive(): rtStart = %10I64d, rtStop = %10I64d\n"), rtStart, rtStop);
+ } else {
+ TRACE(_T("CMpaDecFilter::Receive(): frame without timestamp\n"));
+ }
#endif
- if (pIn->IsDiscontinuity() == S_OK) {
- m_fDiscontinuity = true;
- m_buff.RemoveAll();
- m_rtStart = rtStart;
- m_bResync = true;
- if (FAILED(hr)) {
- TRACE(_T("CMpaDecFilter::Receive() : Discontinuity without timestamp\n"));
- return S_OK;
- }
- }
-
- const GUID& subtype = m_pInput->CurrentMediaType().subtype;
-
- if ((subtype == MEDIASUBTYPE_COOK && (S_OK == pIn->IsSyncPoint())) || ((_abs64((m_rtStart - rtStart)) > MAX_JITTER) && ((subtype != MEDIASUBTYPE_COOK) && (subtype != MEDIASUBTYPE_ATRC) && (subtype != MEDIASUBTYPE_SIPR)))) {
- m_bResync = true;
- }
-
- if (SUCCEEDED(hr) && m_bResync) {
- m_buff.RemoveAll();
- m_rtStart = rtStart;
- m_bResync = false;
- }
-
- int bufflen = m_buff.GetCount();
- m_buff.SetCount(bufflen + len, 4096);
- memcpy(m_buff.GetData() + bufflen, pDataIn, len);
- len += bufflen;
+ if (pIn->IsDiscontinuity() == S_OK) {
+ m_fDiscontinuity = true;
+ m_buff.RemoveAll();
+ m_rtStart = rtStart;
+ m_bResync = true;
+ if (FAILED(hr)) {
+ TRACE(_T("CMpaDecFilter::Receive() : Discontinuity without timestamp\n"));
+ return S_OK;
+ }
+ }
+
+ const GUID& subtype = m_pInput->CurrentMediaType().subtype;
+
+ if ((subtype == MEDIASUBTYPE_COOK && (S_OK == pIn->IsSyncPoint())) || ((_abs64((m_rtStart - rtStart)) > MAX_JITTER) && ((subtype != MEDIASUBTYPE_COOK) && (subtype != MEDIASUBTYPE_ATRC) && (subtype != MEDIASUBTYPE_SIPR)))) {
+ m_bResync = true;
+ }
+
+ if (SUCCEEDED(hr) && m_bResync) {
+ m_buff.RemoveAll();
+ m_rtStart = rtStart;
+ m_bResync = false;
+ }
+
+ int bufflen = m_buff.GetCount();
+ m_buff.SetCount(bufflen + len, 4096);
+ memcpy(m_buff.GetData() + bufflen, pDataIn, len);
+ len += bufflen;
#if defined(REGISTER_FILTER) || HAS_FFMPEG_AUDIO_DECODERS
- enum CodecID nCodecId = FindCodec(subtype);
- if (nCodecId != CODEC_ID_NONE) {
- return ProcessFFmpeg(nCodecId);
- }
+ enum CodecID nCodecId = FindCodec(subtype);
+ if (nCodecId != CODEC_ID_NONE) {
+ return ProcessFFmpeg(nCodecId);
+ }
#endif
- if (0) {} // needed if decoders are disabled below
+ if (0) {} // needed if decoders are disabled below
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_LPCM
- else if (subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
- hr = ProcessLPCM();
- } else if (subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
- hr = ProcessHdmvLPCM(!!pIn->IsSyncPoint());
- }
+ else if (subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
+ hr = ProcessLPCM();
+ } else if (subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
+ hr = ProcessHdmvLPCM(!!pIn->IsSyncPoint());
+ }
#endif
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_AC3
- else if (subtype == MEDIASUBTYPE_DOLBY_AC3 ||
- subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3 ||
- subtype == MEDIASUBTYPE_DNET) {
- hr = ProcessAC3();
- }
+ else if (subtype == MEDIASUBTYPE_DOLBY_AC3 ||
+ subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3 ||
+ subtype == MEDIASUBTYPE_DNET) {
+ hr = ProcessAC3();
+ }
#endif
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_DTS
- else if (subtype == MEDIASUBTYPE_DTS || subtype == MEDIASUBTYPE_WAVE_DTS) {
- hr = ProcessDTS();
- }
+ else if (subtype == MEDIASUBTYPE_DTS || subtype == MEDIASUBTYPE_WAVE_DTS) {
+ hr = ProcessDTS();
+ }
#endif
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_PS2AUDIO
- else if (subtype == MEDIASUBTYPE_PS2_PCM) {
- hr = ProcessPS2PCM();
- } else if (subtype == MEDIASUBTYPE_PS2_ADPCM) {
- hr = ProcessPS2ADPCM();
- }
+ else if (subtype == MEDIASUBTYPE_PS2_PCM) {
+ hr = ProcessPS2PCM();
+ } else if (subtype == MEDIASUBTYPE_PS2_ADPCM) {
+ hr = ProcessPS2ADPCM();
+ }
#endif
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_PCM
- else if (subtype == MEDIASUBTYPE_PCM_NONE ||
- subtype == MEDIASUBTYPE_PCM_RAW) {
- hr = ProcessPCMraw();
- } else if (subtype == MEDIASUBTYPE_PCM_TWOS ||
- subtype == MEDIASUBTYPE_PCM_IN24 ||
- subtype == MEDIASUBTYPE_PCM_IN32) {
- hr = ProcessPCMintBE();
- } else if (subtype == MEDIASUBTYPE_PCM_SOWT) {
- hr = ProcessPCMintLE();
- } else if (subtype == MEDIASUBTYPE_PCM_FL32 ||
- subtype == MEDIASUBTYPE_PCM_FL64) {
- hr = ProcessPCMfloatBE();
- } else if (subtype == MEDIASUBTYPE_IEEE_FLOAT) {
- hr = ProcessPCMfloatLE();
- }
+ else if (subtype == MEDIASUBTYPE_PCM_NONE ||
+ subtype == MEDIASUBTYPE_PCM_RAW) {
+ hr = ProcessPCMraw();
+ } else if (subtype == MEDIASUBTYPE_PCM_TWOS ||
+ subtype == MEDIASUBTYPE_PCM_IN24 ||
+ subtype == MEDIASUBTYPE_PCM_IN32) {
+ hr = ProcessPCMintBE();
+ } else if (subtype == MEDIASUBTYPE_PCM_SOWT) {
+ hr = ProcessPCMintLE();
+ } else if (subtype == MEDIASUBTYPE_PCM_FL32 ||
+ subtype == MEDIASUBTYPE_PCM_FL64) {
+ hr = ProcessPCMfloatBE();
+ } else if (subtype == MEDIASUBTYPE_IEEE_FLOAT) {
+ hr = ProcessPCMfloatLE();
+ }
#endif
- return hr;
+ return hr;
}
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_LPCM
HRESULT CMpaDecFilter::ProcessLPCM()
{
- WAVEFORMATEX* wfein = (WAVEFORMATEX*)m_pInput->CurrentMediaType().Format();
-
- if (wfein->nChannels < 1 || wfein->nChannels > 8) {
- return ERROR_NOT_SUPPORTED;
- }
-
- int nChannels = wfein->nChannels;
-
- BYTE* pDataIn = m_buff.GetData();
- int BytesPerDoubleSample = (wfein->wBitsPerSample * 2)/8;
- int BytesPerDoubleChannelSample = BytesPerDoubleSample * nChannels;
- int nInBytes = m_buff.GetCount();
- int len = (nInBytes / BytesPerDoubleChannelSample) * (BytesPerDoubleChannelSample); // We always code 2 samples at a time
-
- CAtlArray<float> pBuff;
- pBuff.SetCount((len/BytesPerDoubleSample) * 2);
-
- float* pDataOut = pBuff.GetData();
-
- switch (wfein->wBitsPerSample) {
- case 16 : {
- long nSamples = len/(BytesPerDoubleChannelSample);
- int16 Temp[2][8];
- for (int i=0; i<nSamples; i++) {
- for (int j = 0; j < nChannels; j++) {
- uint16 All = *((uint16 *)pDataIn);
- pDataIn += 2;
- int16 Part1 = (All & 0xFF) << 8 | (All & 0xFF00) >> 8;
- Temp[0][j] = Part1;
- }
- for (int j = 0; j < nChannels; j++) {
- uint16 All = *((uint16 *)pDataIn);
- pDataIn += 2;
- int16 Part1 = (All & 0xFF) << 8 | (All & 0xFF00) >> 8;
- Temp[1][j] = Part1;
- }
-
- for (int j = 0; j < nChannels; j++) {
- *pDataOut = float(Temp[0][j]) / INT16_PEAK;
- ++pDataOut;
- }
- for (int j = 0; j < nChannels; j++) {
- *pDataOut = float(Temp[1][j]) / INT16_PEAK;
- ++pDataOut;
- }
- }
- }
- break;
-
- case 24 : {
- long nSamples = len/(BytesPerDoubleChannelSample);
- int32 Temp[2][8];
- for (int i=0; i<nSamples; i++) {
- // Start by upper 16 bits
- for (int j = 0; j < nChannels; j++) {
- uint32 All = *((uint16 *)pDataIn);
- pDataIn += 2;
- uint32 Part1 = (All & 0xFF) << 24 | (All & 0xFF00) << 8;
- Temp[0][j] = Part1;
- }
- for (int j = 0; j < nChannels; j++) {
- uint32 All = *((uint16 *)pDataIn);
- pDataIn += 2;
- uint32 Part1 = (All & 0xFF) << 24 | (All & 0xFF00) << 8;
- Temp[1][j] = Part1;
- }
-
- // Continue with lower bits
- for (int j = 0; j < nChannels; j++) {
- uint32 All = *((uint8 *)pDataIn);
- pDataIn += 1;
- Temp[0][j] = int32(Temp[0][j] | (All << 8)) >> 8;
- }
- for (int j = 0; j < nChannels; j++) {
- uint32 All = *((uint8 *)pDataIn);
- pDataIn += 1;
- Temp[1][j] = int32(Temp[1][j] | (All << 8)) >> 8;
- }
-
- // Convert into float
- for (int j = 0; j < nChannels; j++) {
- *pDataOut = float(Temp[0][j]) / INT24_PEAK;
- ++pDataOut;
- }
- for (int j = 0; j < nChannels; j++) {
- *pDataOut = float(Temp[1][j]) / INT24_PEAK;
- ++pDataOut;
- }
- }
- }
- break;
- case 20 : {
- long nSamples = len/(BytesPerDoubleChannelSample);
- int32 Temp[2][8];
- for (int i=0; i<nSamples; i++) {
- // Start by upper 16 bits
- for (int j = 0; j < nChannels; j++) {
- uint32 All = *((uint16 *)pDataIn);
- pDataIn += 2;
- uint32 Part1 = (All & 0xFF) << 24 | (All & 0xFF00) << 8;
- Temp[0][j] = Part1;
- }
- for (int j = 0; j < nChannels; j++) {
- uint32 All = *((uint16 *)pDataIn);
- pDataIn += 2;
- uint32 Part1 = (All & 0xFF) << 24 | (All & 0xFF00) << 8;
- Temp[1][j] = Part1;
- }
-
- // Continue with lower bits
- for (int j = 0; j < nChannels; j++) {
- uint32 All = *((uint8 *)pDataIn);
- pDataIn += 1;
- Temp[0][j] = int32(Temp[0][j] | ((All&0xf0) << 8)) >> 8;
- Temp[1][j] = int32(Temp[1][j] | ((All&0x0f) << 12)) >> 8;
- }
-
- // Convert into float
- for (int j = 0; j < nChannels; j++) {
- *pDataOut = float(Temp[0][j]) / INT24_PEAK;
- ++pDataOut;
- }
- for (int j = 0; j < nChannels; j++) {
- *pDataOut = float(Temp[1][j]) / INT24_PEAK;
- ++pDataOut;
- }
- }
- }
- break;
- }
-
- memmove(m_buff.GetData(), pDataIn, m_buff.GetCount() - len );
- m_buff.SetCount(m_buff.GetCount() - len);
-
- return Deliver(pBuff, wfein->nSamplesPerSec, wfein->nChannels, GetDefChannelMask(wfein->nChannels));
+ WAVEFORMATEX* wfein = (WAVEFORMATEX*)m_pInput->CurrentMediaType().Format();
+
+ if (wfein->nChannels < 1 || wfein->nChannels > 8) {
+ return ERROR_NOT_SUPPORTED;
+ }
+
+ int nChannels = wfein->nChannels;
+
+ BYTE* pDataIn = m_buff.GetData();
+ int BytesPerDoubleSample = (wfein->wBitsPerSample * 2) / 8;
+ int BytesPerDoubleChannelSample = BytesPerDoubleSample * nChannels;
+ int nInBytes = m_buff.GetCount();
+ int len = (nInBytes / BytesPerDoubleChannelSample) * (BytesPerDoubleChannelSample); // We always code 2 samples at a time
+
+ CAtlArray<float> pBuff;
+ pBuff.SetCount((len / BytesPerDoubleSample) * 2);
+
+ float* pDataOut = pBuff.GetData();
+
+ switch (wfein->wBitsPerSample) {
+ case 16 : {
+ long nSamples = len / (BytesPerDoubleChannelSample);
+ int16 Temp[2][8];
+ for (int i = 0; i < nSamples; i++) {
+ for (int j = 0; j < nChannels; j++) {
+ uint16 All = *((uint16*)pDataIn);
+ pDataIn += 2;
+ int16 Part1 = (All & 0xFF) << 8 | (All & 0xFF00) >> 8;
+ Temp[0][j] = Part1;
+ }
+ for (int j = 0; j < nChannels; j++) {
+ uint16 All = *((uint16*)pDataIn);
+ pDataIn += 2;
+ int16 Part1 = (All & 0xFF) << 8 | (All & 0xFF00) >> 8;
+ Temp[1][j] = Part1;
+ }
+
+ for (int j = 0; j < nChannels; j++) {
+ *pDataOut = float(Temp[0][j]) / INT16_PEAK;
+ ++pDataOut;
+ }
+ for (int j = 0; j < nChannels; j++) {
+ *pDataOut = float(Temp[1][j]) / INT16_PEAK;
+ ++pDataOut;
+ }
+ }
+ }
+ break;
+
+ case 24 : {
+ long nSamples = len / (BytesPerDoubleChannelSample);
+ int32 Temp[2][8];
+ for (int i = 0; i < nSamples; i++) {
+ // Start by upper 16 bits
+ for (int j = 0; j < nChannels; j++) {
+ uint32 All = *((uint16*)pDataIn);
+ pDataIn += 2;
+ uint32 Part1 = (All & 0xFF) << 24 | (All & 0xFF00) << 8;
+ Temp[0][j] = Part1;
+ }
+ for (int j = 0; j < nChannels; j++) {
+ uint32 All = *((uint16*)pDataIn);
+ pDataIn += 2;
+ uint32 Part1 = (All & 0xFF) << 24 | (All & 0xFF00) << 8;
+ Temp[1][j] = Part1;
+ }
+
+ // Continue with lower bits
+ for (int j = 0; j < nChannels; j++) {
+ uint32 All = *((uint8*)pDataIn);
+ pDataIn += 1;
+ Temp[0][j] = int32(Temp[0][j] | (All << 8)) >> 8;
+ }
+ for (int j = 0; j < nChannels; j++) {
+ uint32 All = *((uint8*)pDataIn);
+ pDataIn += 1;
+ Temp[1][j] = int32(Temp[1][j] | (All << 8)) >> 8;
+ }
+
+ // Convert into float
+ for (int j = 0; j < nChannels; j++) {
+ *pDataOut = float(Temp[0][j]) / INT24_PEAK;
+ ++pDataOut;
+ }
+ for (int j = 0; j < nChannels; j++) {
+ *pDataOut = float(Temp[1][j]) / INT24_PEAK;
+ ++pDataOut;
+ }
+ }
+ }
+ break;
+ case 20 : {
+ long nSamples = len / (BytesPerDoubleChannelSample);
+ int32 Temp[2][8];
+ for (int i = 0; i < nSamples; i++) {
+ // Start by upper 16 bits
+ for (int j = 0; j < nChannels; j++) {
+ uint32 All = *((uint16*)pDataIn);
+ pDataIn += 2;
+ uint32 Part1 = (All & 0xFF) << 24 | (All & 0xFF00) << 8;
+ Temp[0][j] = Part1;
+ }
+ for (int j = 0; j < nChannels; j++) {
+ uint32 All = *((uint16*)pDataIn);
+ pDataIn += 2;
+ uint32 Part1 = (All & 0xFF) << 24 | (All & 0xFF00) << 8;
+ Temp[1][j] = Part1;
+ }
+
+ // Continue with lower bits
+ for (int j = 0; j < nChannels; j++) {
+ uint32 All = *((uint8*)pDataIn);
+ pDataIn += 1;
+ Temp[0][j] = int32(Temp[0][j] | ((All & 0xf0) << 8)) >> 8;
+ Temp[1][j] = int32(Temp[1][j] | ((All & 0x0f) << 12)) >> 8;
+ }
+
+ // Convert into float
+ for (int j = 0; j < nChannels; j++) {
+ *pDataOut = float(Temp[0][j]) / INT24_PEAK;
+ ++pDataOut;
+ }
+ for (int j = 0; j < nChannels; j++) {
+ *pDataOut = float(Temp[1][j]) / INT24_PEAK;
+ ++pDataOut;
+ }
+ }
+ }
+ break;
+ }
+
+ memmove(m_buff.GetData(), pDataIn, m_buff.GetCount() - len);
+ m_buff.SetCount(m_buff.GetCount() - len);
+
+ return Deliver(pBuff, wfein->nSamplesPerSec, wfein->nChannels, GetDefChannelMask(wfein->nChannels));
}
HRESULT CMpaDecFilter::ProcessHdmvLPCM(bool bAlignOldBuffer) // Blu ray LPCM
{
- WAVEFORMATEX_HDMV_LPCM* wfein = (WAVEFORMATEX_HDMV_LPCM*)m_pInput->CurrentMediaType().Format();
-
- scmap_t* remap = &s_scmap_hdmv [wfein->channel_conf];
- int nChannels = wfein->nChannels;
- int xChannels = nChannels + (nChannels % 2);
- int BytesPerSample = (wfein->wBitsPerSample + 7) / 8;
- int BytesPerFrame = BytesPerSample * xChannels;
-
- BYTE* pDataIn = m_buff.GetData();
- int len = m_buff.GetCount() - (m_buff.GetCount() % BytesPerFrame);
- if (bAlignOldBuffer) {
- m_buff.SetCount(len);
- }
- int nFrames = len/xChannels/BytesPerSample;
-
- CAtlArray<float> pBuff;
- pBuff.SetCount(nFrames*nChannels); //nSamples
- float* pDataOut = pBuff.GetData();
-
- switch (wfein->wBitsPerSample) {
- case 16 :
- for (int i=0; i<nFrames; i++) {
- for (int j = 0; j < nChannels; j++) {
- BYTE nRemap = remap->ch[j];
- *pDataOut = (float)(int16_t)(pDataIn[nRemap*2]<<8 | pDataIn[nRemap*2+1]) / INT16_PEAK;
- pDataOut++;
- }
- pDataIn += xChannels*2;
- }
- break;
- case 24 :
- case 20 :
- for (int i=0; i<nFrames; i++) {
- for (int j = 0; j < nChannels; j++) {
- BYTE nRemap = remap->ch[j];
- *pDataOut = (float)(int32_t)(pDataIn[nRemap*3]<<24 | pDataIn[nRemap*3+1]<<16 | pDataIn[nRemap*3+2]<<8) / INT32_PEAK;
- pDataOut++;
- }
- pDataIn += xChannels*3;
- }
- break;
- }
- memmove(m_buff.GetData(), pDataIn, m_buff.GetCount() - len );
- m_buff.SetCount(m_buff.GetCount() - len);
-
- return Deliver(pBuff, wfein->nSamplesPerSec, wfein->nChannels, remap->dwChannelMask);
+ WAVEFORMATEX_HDMV_LPCM* wfein = (WAVEFORMATEX_HDMV_LPCM*)m_pInput->CurrentMediaType().Format();
+
+ scmap_t* remap = &s_scmap_hdmv [wfein->channel_conf];
+ int nChannels = wfein->nChannels;
+ int xChannels = nChannels + (nChannels % 2);
+ int BytesPerSample = (wfein->wBitsPerSample + 7) / 8;
+ int BytesPerFrame = BytesPerSample * xChannels;
+
+ BYTE* pDataIn = m_buff.GetData();
+ int len = m_buff.GetCount() - (m_buff.GetCount() % BytesPerFrame);
+ if (bAlignOldBuffer) {
+ m_buff.SetCount(len);
+ }
+ int nFrames = len / xChannels / BytesPerSample;
+
+ CAtlArray<float> pBuff;
+ pBuff.SetCount(nFrames * nChannels); //nSamples
+ float* pDataOut = pBuff.GetData();
+
+ switch (wfein->wBitsPerSample) {
+ case 16 :
+ for (int i = 0; i < nFrames; i++) {
+ for (int j = 0; j < nChannels; j++) {
+ BYTE nRemap = remap->ch[j];
+ *pDataOut = (float)(int16_t)(pDataIn[nRemap * 2] << 8 | pDataIn[nRemap * 2 + 1]) / INT16_PEAK;
+ pDataOut++;
+ }
+ pDataIn += xChannels * 2;
+ }
+ break;
+ case 24 :
+ case 20 :
+ for (int i = 0; i < nFrames; i++) {
+ for (int j = 0; j < nChannels; j++) {
+ BYTE nRemap = remap->ch[j];
+ *pDataOut = (float)(int32_t)(pDataIn[nRemap * 3] << 24 | pDataIn[nRemap * 3 + 1] << 16 | pDataIn[nRemap * 3 + 2] << 8) / INT32_PEAK;
+ pDataOut++;
+ }
+ pDataIn += xChannels * 3;
+ }
+ break;
+ }
+ memmove(m_buff.GetData(), pDataIn, m_buff.GetCount() - len);
+ m_buff.SetCount(m_buff.GetCount() - len);
+
+ return Deliver(pBuff, wfein->nSamplesPerSec, wfein->nChannels, remap->dwChannelMask);
}
#endif /* INTERNAL_DECODER_LPCM */
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_AC3
HRESULT CMpaDecFilter::ProcessA52(BYTE* p, int buffsize, int& size, bool& fEnoughData)
{
- int flags, sample_rate, bit_rate;
-
- if ((size = a52_syncinfo(p, &flags, &sample_rate, &bit_rate)) > 0) {
- // TRACE(_T("ac3: size=%d, flags=%08x, sample_rate=%d, bit_rate=%d\n"), size, flags, sample_rate, bit_rate);
-
- fEnoughData = size <= buffsize;
-
- if (fEnoughData) {
- int iSpeakerConfig = GetSpeakerConfig(ac3);
-
- if (iSpeakerConfig < 0) {
- HRESULT hr;
- if (S_OK != (hr = DeliverBitstream(p, size, sample_rate, 1536, 0x0001))) {
- return hr;
- }
- } else {
- flags = iSpeakerConfig&(A52_CHANNEL_MASK|A52_LFE);
- flags |= A52_ADJUST_LEVEL;
-
- sample_t level = 1, gain = 1, bias = 0;
- level *= gain;
-
- if (a52_frame(m_a52_state, p, &flags, &level, bias) == 0) {
- if (GetDynamicRangeControl(ac3)) {
- a52_dynrng(m_a52_state, NULL, NULL);
- }
-
- int scmapidx = min(flags&A52_CHANNEL_MASK, _countof(s_scmap_a52dec)/2);
- scmap_t& scmap = s_scmap_a52dec[scmapidx + ((flags&A52_LFE)?(_countof(s_scmap_a52dec)/2):0)];
-
- CAtlArray<float> pBuff;
- pBuff.SetCount(6*256*scmap.nChannels);
- float* p = pBuff.GetData();
-
- int i = 0;
-
- for (; i < 6 && a52_block(m_a52_state) == 0; i++) {
- sample_t* samples = a52_samples(m_a52_state);
-
- for (int j = 0; j < 256; j++, samples++) {
- for (int ch = 0; ch < scmap.nChannels; ch++) {
- ASSERT(scmap.ch[ch] != -1);
- *p++ = (float)(*(samples + 256*scmap.ch[ch]) / level);
- }
- }
- }
-
- if (i == 6) {
- HRESULT hr;
- if (S_OK != (hr = Deliver(pBuff, sample_rate, scmap.nChannels, scmap.dwChannelMask))) {
- return hr;
- }
- }
- }
- }
- }
- }
-
- return S_OK;
+ int flags, sample_rate, bit_rate;
+
+ if ((size = a52_syncinfo(p, &flags, &sample_rate, &bit_rate)) > 0) {
+ // TRACE(_T("ac3: size=%d, flags=%08x, sample_rate=%d, bit_rate=%d\n"), size, flags, sample_rate, bit_rate);
+
+ fEnoughData = size <= buffsize;
+
+ if (fEnoughData) {
+ int iSpeakerConfig = GetSpeakerConfig(ac3);
+
+ if (iSpeakerConfig < 0) {
+ HRESULT hr;
+ if (S_OK != (hr = DeliverBitstream(p, size, sample_rate, 1536, 0x0001))) {
+ return hr;
+ }
+ } else {
+ flags = iSpeakerConfig & (A52_CHANNEL_MASK | A52_LFE);
+ flags |= A52_ADJUST_LEVEL;
+
+ sample_t level = 1, gain = 1, bias = 0;
+ level *= gain;
+
+ if (a52_frame(m_a52_state, p, &flags, &level, bias) == 0) {
+ if (GetDynamicRangeControl(ac3)) {
+ a52_dynrng(m_a52_state, NULL, NULL);
+ }
+
+ int scmapidx = min(flags & A52_CHANNEL_MASK, _countof(s_scmap_a52dec) / 2);
+ scmap_t& scmap = s_scmap_a52dec[scmapidx + ((flags & A52_LFE) ? (_countof(s_scmap_a52dec) / 2) : 0)];
+
+ CAtlArray<float> pBuff;
+ pBuff.SetCount(6 * 256 * scmap.nChannels);
+ float* p = pBuff.GetData();
+
+ int i = 0;
+
+ for (; i < 6 && a52_block(m_a52_state) == 0; i++) {
+ sample_t* samples = a52_samples(m_a52_state);
+
+ for (int j = 0; j < 256; j++, samples++) {
+ for (int ch = 0; ch < scmap.nChannels; ch++) {
+ ASSERT(scmap.ch[ch] != -1);
+ *p++ = (float)(*(samples + 256 * scmap.ch[ch]) / level);
+ }
+ }
+ }
+
+ if (i == 6) {
+ HRESULT hr;
+ if (S_OK != (hr = Deliver(pBuff, sample_rate, scmap.nChannels, scmap.dwChannelMask))) {
+ return hr;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return S_OK;
}
HRESULT CMpaDecFilter::ProcessAC3()
{
- HRESULT hr;
- BYTE* p = m_buff.GetData();
- BYTE* base = p;
- BYTE* end = p + m_buff.GetCount();
-
- while (p < end && end - p >= AC3_HEADER_SIZE) {
- int size = 0;
- bool fEnoughData = true;
-
- if (m_DolbyDigitalMode != DD_TRUEHD && m_DolbyDigitalMode != DD_MLP && (*((__int16*)p) == 0x770b)) { /* AC3-EAC3 syncword */
- BYTE bsid = p[5] >> 3;
- if (bsid <= 10) {
- if (FAILED (hr = ProcessA52 (p, int(end-p), size, fEnoughData))) {
- return hr;
- }
- m_DolbyDigitalMode = DD_AC3;
- } else if (bsid <= 16) {
- DeliverFFmpeg(CODEC_ID_EAC3, p, int(end-p), size);
- if (size > 0) {
- m_DolbyDigitalMode = DD_EAC3;
- }
- } else {
- p++;
- continue;
- }
- } else if ( (*((__int32*)(p+4)) == 0xba6f72f8) || // TrueHD major sync frame
- m_DolbyDigitalMode == DD_TRUEHD ) {
- int nLenght = (((p[0]<<8) + p[1]) & 0x0FFF)*2;
-
- m_DolbyDigitalMode = DD_TRUEHD;
-
- if (nLenght >= 4) {
- DeliverFFmpeg(CODEC_ID_TRUEHD, p, int(end-p), size);
- if (size<0) {
- size = (int)(end-p);
- }
- }
- } else if ( (*((__int32*)(p+4)) == 0xbb6f72f8) || // MLP major sync frame
- m_DolbyDigitalMode == DD_MLP ) {
- int nLenght = (((p[0]<<8) + p[1]) & 0x0FFF)*2;
-
- m_DolbyDigitalMode = DD_MLP;
-
- if (nLenght >= 4) {
- DeliverFFmpeg(CODEC_ID_MLP, p, int(end-p), size);
- if (size<0) {
- size = (int)(end-p);
- }
- }
- } else {
- p++;
- continue;
- }
-
- // Update buffer position
- if (fEnoughData) {
- ASSERT (size <= end-p);
- if (size <= 0 || size > end-p) {
- break;
- }
- p += size;
- }
- memmove(base, p, end - p);
- end = base + (end - p);
- p = base;
- if (!fEnoughData) {
- break;
- }
- }
-
- m_buff.SetCount(end - p);
-
- return S_OK;
+ HRESULT hr;
+ BYTE* p = m_buff.GetData();
+ BYTE* base = p;
+ BYTE* end = p + m_buff.GetCount();
+
+ while (p < end && end - p >= AC3_HEADER_SIZE) {
+ int size = 0;
+ bool fEnoughData = true;
+
+ if (m_DolbyDigitalMode != DD_TRUEHD && m_DolbyDigitalMode != DD_MLP && (*((__int16*)p) == 0x770b)) { /* AC3-EAC3 syncword */
+ BYTE bsid = p[5] >> 3;
+ if (bsid <= 10) {
+ if (FAILED(hr = ProcessA52(p, int(end - p), size, fEnoughData))) {
+ return hr;
+ }
+ m_DolbyDigitalMode = DD_AC3;
+ } else if (bsid <= 16) {
+ DeliverFFmpeg(CODEC_ID_EAC3, p, int(end - p), size);
+ if (size > 0) {
+ m_DolbyDigitalMode = DD_EAC3;
+ }
+ } else {
+ p++;
+ continue;
+ }
+ } else if ((*((__int32*)(p + 4)) == 0xba6f72f8) || // TrueHD major sync frame
+ m_DolbyDigitalMode == DD_TRUEHD) {
+ int nLenght = (((p[0] << 8) + p[1]) & 0x0FFF) * 2;
+
+ m_DolbyDigitalMode = DD_TRUEHD;
+
+ if (nLenght >= 4) {
+ DeliverFFmpeg(CODEC_ID_TRUEHD, p, int(end - p), size);
+ if (size < 0) {
+ size = (int)(end - p);
+ }
+ }
+ } else if ((*((__int32*)(p + 4)) == 0xbb6f72f8) || // MLP major sync frame
+ m_DolbyDigitalMode == DD_MLP) {
+ int nLenght = (((p[0] << 8) + p[1]) & 0x0FFF) * 2;
+
+ m_DolbyDigitalMode = DD_MLP;
+
+ if (nLenght >= 4) {
+ DeliverFFmpeg(CODEC_ID_MLP, p, int(end - p), size);
+ if (size < 0) {
+ size = (int)(end - p);
+ }
+ }
+ } else {
+ p++;
+ continue;
+ }
+
+ // Update buffer position
+ if (fEnoughData) {
+ ASSERT(size <= end - p);
+ if (size <= 0 || size > end - p) {
+ break;
+ }
+ p += size;
+ }
+ memmove(base, p, end - p);
+ end = base + (end - p);
+ p = base;
+ if (!fEnoughData) {
+ break;
+ }
+ }
+
+ m_buff.SetCount(end - p);
+
+ return S_OK;
}
#endif /* INTERNAL_DECODER_AC3 */
#if defined(REGISTER_FILTER) || HAS_FFMPEG_AUDIO_DECODERS
HRESULT CMpaDecFilter::ProcessFFmpeg(enum CodecID nCodecId)
{
- HRESULT hr;
- BYTE* p = m_buff.GetData();
- BYTE* base = p;
- BYTE* end = p + m_buff.GetCount();
-
- int size = 0;
- hr = DeliverFFmpeg(nCodecId, p, int(end-p), size);
- if (FAILED(hr)) {
- if (!(nCodecId == CODEC_ID_AAC || nCodecId == CODEC_ID_AAC_LATM)) {
- m_buff.RemoveAll();
- m_bResync = true;
- }
- return S_OK;
- }
-
- if (size <= 0) {
- return hr;
- }
-
- m_DolbyDigitalMode = (nCodecId == CODEC_ID_TRUEHD) ? DD_TRUEHD : (nCodecId == CODEC_ID_EAC3) ? DD_EAC3 : DD_Unknown;
-
- p += size;
- memmove(base, p, end - p);
- end = base + (end - p);
- p = base;
- m_buff.SetCount(end - p);
-
- return hr;
+ HRESULT hr;
+ BYTE* p = m_buff.GetData();
+ BYTE* base = p;
+ BYTE* end = p + m_buff.GetCount();
+
+ int size = 0;
+ hr = DeliverFFmpeg(nCodecId, p, int(end - p), size);
+ if (FAILED(hr)) {
+ if (!(nCodecId == CODEC_ID_AAC || nCodecId == CODEC_ID_AAC_LATM)) {
+ m_buff.RemoveAll();
+ m_bResync = true;
+ }
+ return S_OK;
+ }
+
+ if (size <= 0) {
+ return hr;
+ }
+
+ m_DolbyDigitalMode = (nCodecId == CODEC_ID_TRUEHD) ? DD_TRUEHD : (nCodecId == CODEC_ID_EAC3) ? DD_EAC3 : DD_Unknown;
+
+ p += size;
+ memmove(base, p, end - p);
+ end = base + (end - p);
+ p = base;
+ m_buff.SetCount(end - p);
+
+ return hr;
}
#endif /* HAS_FFMPEG_AUDIO_DECODERS */
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_DTS
HRESULT CMpaDecFilter::ProcessDTS()
{
- BYTE* p = m_buff.GetData();
- BYTE* base = p;
- BYTE* end = p + m_buff.GetCount();
-
- while (end - p >= 14) {
- int size = 0, flags, sample_rate, bit_rate, frame_length;
-
- if ((size = dts_syncinfo(m_dts_state, p, &flags, &sample_rate, &bit_rate, &frame_length)) > 0) {
- // TRACE(_T("dts: size=%d, flags=%08x, sample_rate=%d, bit_rate=%d, frame_length=%d\n"), size, flags, sample_rate, bit_rate, frame_length);
- bit_rate = int (size * 8i64 * sample_rate / frame_length); // calculate actual bitrate
-
- bool fEnoughData = p + size <= end;
-
- if (fEnoughData) {
- int iSpeakerConfig = GetSpeakerConfig(dts);
-
- if (iSpeakerConfig < 0) {
- HRESULT hr;
- if (S_OK != (hr = DeliverBitstream(p, size, sample_rate, frame_length, 0x000b))) {
- return hr;
- }
- } else {
- flags = iSpeakerConfig&(DTS_CHANNEL_MASK|DTS_LFE);
- flags |= DTS_ADJUST_LEVEL;
-
- sample_t level = 1, gain = 1, bias = 0;
- level *= gain;
-
- if (dts_frame(m_dts_state, p, &flags, &level, bias) == 0) {
- if (GetDynamicRangeControl(dts)) {
- dts_dynrng(m_dts_state, NULL, NULL);
- }
-
- int scmapidx = min(flags&DTS_CHANNEL_MASK, _countof(s_scmap_libdca)/2);
- scmap_t& scmap = s_scmap_libdca[scmapidx + ((flags&DTS_LFE)?(_countof(s_scmap_libdca)/2):0)];
-
- int blocks = dts_blocks_num(m_dts_state);
-
- CAtlArray<float> pBuff;
- pBuff.SetCount(blocks*256*scmap.nChannels);
- float* p = pBuff.GetData();
-
- int i = 0;
-
- for (; i < blocks && dts_block(m_dts_state) == 0; i++) {
- sample_t* samples = dts_samples(m_dts_state);
-
- for (int j = 0; j < 256; j++, samples++) {
- for (int ch = 0; ch < scmap.nChannels; ch++) {
- ASSERT(scmap.ch[ch] != -1);
- *p++ = (float)(*(samples + 256*scmap.ch[ch]) / level);
- }
- }
- }
-
- if (i == blocks) {
- HRESULT hr;
- if (S_OK != (hr = Deliver(pBuff, sample_rate, scmap.nChannels, scmap.dwChannelMask))) {
- return hr;
- }
- }
- }
- }
-
- p += size;
- }
-
- memmove(base, p, end - p);
- end = base + (end - p);
- p = base;
-
- if (!fEnoughData) {
- break;
- }
- } else {
- p++;
- }
- }
-
- m_buff.SetCount(end - p);
-
- return S_OK;
+ BYTE* p = m_buff.GetData();
+ BYTE* base = p;
+ BYTE* end = p + m_buff.GetCount();
+
+ while (end - p >= 14) {
+ int size = 0, flags, sample_rate, bit_rate, frame_length;
+
+ if ((size = dts_syncinfo(m_dts_state, p, &flags, &sample_rate, &bit_rate, &frame_length)) > 0) {
+ // TRACE(_T("dts: size=%d, flags=%08x, sample_rate=%d, bit_rate=%d, frame_length=%d\n"), size, flags, sample_rate, bit_rate, frame_length);
+ bit_rate = int (size * 8i64 * sample_rate / frame_length); // calculate actual bitrate
+
+ bool fEnoughData = p + size <= end;
+
+ if (fEnoughData) {
+ int iSpeakerConfig = GetSpeakerConfig(dts);
+
+ if (iSpeakerConfig < 0) {
+ HRESULT hr;
+ if (S_OK != (hr = DeliverBitstream(p, size, sample_rate, frame_length, 0x000b))) {
+ return hr;
+ }
+ } else {
+ flags = iSpeakerConfig & (DTS_CHANNEL_MASK | DTS_LFE);
+ flags |= DTS_ADJUST_LEVEL;
+
+ sample_t level = 1, gain = 1, bias = 0;
+ level *= gain;
+
+ if (dts_frame(m_dts_state, p, &flags, &level, bias) == 0) {
+ if (GetDynamicRangeControl(dts)) {
+ dts_dynrng(m_dts_state, NULL, NULL);
+ }
+
+ int scmapidx = min(flags & DTS_CHANNEL_MASK, _countof(s_scmap_libdca) / 2);
+ scmap_t& scmap = s_scmap_libdca[scmapidx + ((flags & DTS_LFE) ? (_countof(s_scmap_libdca) / 2) : 0)];
+
+ int blocks = dts_blocks_num(m_dts_state);
+
+ CAtlArray<float> pBuff;
+ pBuff.SetCount(blocks * 256 * scmap.nChannels);
+ float* p = pBuff.GetData();
+
+ int i = 0;
+
+ for (; i < blocks && dts_block(m_dts_state) == 0; i++) {
+ sample_t* samples = dts_samples(m_dts_state);
+
+ for (int j = 0; j < 256; j++, samples++) {
+ for (int ch = 0; ch < scmap.nChannels; ch++) {
+ ASSERT(scmap.ch[ch] != -1);
+ *p++ = (float)(*(samples + 256 * scmap.ch[ch]) / level);
+ }
+ }
+ }
+
+ if (i == blocks) {
+ HRESULT hr;
+ if (S_OK != (hr = Deliver(pBuff, sample_rate, scmap.nChannels, scmap.dwChannelMask))) {
+ return hr;
+ }
+ }
+ }
+ }
+
+ p += size;
+ }
+
+ memmove(base, p, end - p);
+ end = base + (end - p);
+ p = base;
+
+ if (!fEnoughData) {
+ break;
+ }
+ } else {
+ p++;
+ }
+ }
+
+ m_buff.SetCount(end - p);
+
+ return S_OK;
}
#endif /* INTERNAL_DECODER_DTS */
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_PCM
HRESULT CMpaDecFilter::ProcessPCMraw() //'raw '
{
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_pInput->CurrentMediaType().Format();
- unsigned int nSamples = m_buff.GetCount() * 8 / wfe->wBitsPerSample;
-
- CAtlArray<float> pBuff;
- pBuff.SetCount(nSamples);
- float* f = pBuff.GetData();
-
- switch (wfe->wBitsPerSample) {
- case 8: { //unsigned 8-bit
- uint8_t* b = (uint8_t*)m_buff.GetData();
- for (unsigned int i = 0; i < nSamples; i++) {
- f[i] = (float)(int8_t)(b[i] + 128) / INT8_PEAK;
- }
- }
- break;
- case 16: { //signed big-endian 16 bit
- uint16_t* d = (uint16_t*)m_buff.GetData();//signed take as an unsigned to shift operations.
- for (unsigned int i = 0; i < nSamples; i++) {
- f[i] = (float)(int16_t)(d[i] << 8 | d[i] >> 8) / INT16_PEAK;
- }
- }
- break;
- }
-
- HRESULT hr;
- if (S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
- return hr;
- }
-
- m_buff.RemoveAll();
- return S_OK;
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_pInput->CurrentMediaType().Format();
+ unsigned int nSamples = m_buff.GetCount() * 8 / wfe->wBitsPerSample;
+
+ CAtlArray<float> pBuff;
+ pBuff.SetCount(nSamples);
+ float* f = pBuff.GetData();
+
+ switch (wfe->wBitsPerSample) {
+ case 8: { //unsigned 8-bit
+ uint8_t* b = (uint8_t*)m_buff.GetData();
+ for (unsigned int i = 0; i < nSamples; i++) {
+ f[i] = (float)(int8_t)(b[i] + 128) / INT8_PEAK;
+ }
+ }
+ break;
+ case 16: { //signed big-endian 16 bit
+ uint16_t* d = (uint16_t*)m_buff.GetData();//signed take as an unsigned to shift operations.
+ for (unsigned int i = 0; i < nSamples; i++) {
+ f[i] = (float)(int16_t)(d[i] << 8 | d[i] >> 8) / INT16_PEAK;
+ }
+ }
+ break;
+ }
+
+ HRESULT hr;
+ if (S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
+ return hr;
+ }
+
+ m_buff.RemoveAll();
+ return S_OK;
}
HRESULT CMpaDecFilter::ProcessPCMintBE() //'twos', big-endian 'in24' and 'in32'
{
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_pInput->CurrentMediaType().Format();
- unsigned int nSamples = m_buff.GetCount() * 8 / wfe->wBitsPerSample;
-
- CAtlArray<float> pBuff;
- pBuff.SetCount(nSamples);
- float* f = pBuff.GetData();
-
- switch (wfe->wBitsPerSample) {
- case 8: { //signed 8-bit
- int8_t* b = (int8_t*)m_buff.GetData();
- for (unsigned int i = 0; i < nSamples; i++) {
- f[i] = (float)b[i] / INT8_PEAK;
- }
- }
- break;
- case 16: { //signed big-endian 16-bit
- uint16_t* d = (uint16_t*)m_buff.GetData();//signed take as an unsigned to shift operations.
- for (unsigned int i = 0; i < nSamples; i++) {
- f[i] = (float)(int16_t)(d[i] << 8 | d[i] >> 8) / INT16_PEAK;
- }
- }
- break;
- case 24: { //signed big-endian 24-bit
- uint8_t* b = (uint8_t*)m_buff.GetData();
- for (unsigned int i = 0; i < nSamples; i++) {
- f[i] = (float)(int32_t)((uint32_t)b[3*i] << 24 |
- (uint32_t)b[3*i+1] << 16 |
- (uint32_t)b[3*i+2] << 8) / INT32_PEAK;
- }
- }
- break;
- case 32: { //signed big-endian 32-bit
- uint32_t* q = (uint32_t*)m_buff.GetData();//signed take as an unsigned to shift operations.
- for (unsigned int i = 0; i < nSamples; i++) {
- f[i] = (float)(int32_t)(q[i] >> 24 |
- (q[i] & 0x00ff0000) >> 8 |
- (q[i] & 0x0000ff00) << 8 |
- q[i] << 24) / INT32_PEAK;
- }
- }
- break;
- }
-
- HRESULT hr;
- if (S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
- return hr;
- }
-
- m_buff.RemoveAll();
- return S_OK;
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_pInput->CurrentMediaType().Format();
+ unsigned int nSamples = m_buff.GetCount() * 8 / wfe->wBitsPerSample;
+
+ CAtlArray<float> pBuff;
+ pBuff.SetCount(nSamples);
+ float* f = pBuff.GetData();
+
+ switch (wfe->wBitsPerSample) {
+ case 8: { //signed 8-bit
+ int8_t* b = (int8_t*)m_buff.GetData();
+ for (unsigned int i = 0; i < nSamples; i++) {
+ f[i] = (float)b[i] / INT8_PEAK;
+ }
+ }
+ break;
+ case 16: { //signed big-endian 16-bit
+ uint16_t* d = (uint16_t*)m_buff.GetData();//signed take as an unsigned to shift operations.
+ for (unsigned int i = 0; i < nSamples; i++) {
+ f[i] = (float)(int16_t)(d[i] << 8 | d[i] >> 8) / INT16_PEAK;
+ }
+ }
+ break;
+ case 24: { //signed big-endian 24-bit
+ uint8_t* b = (uint8_t*)m_buff.GetData();
+ for (unsigned int i = 0; i < nSamples; i++) {
+ f[i] = (float)(int32_t)((uint32_t)b[3 * i] << 24 |
+ (uint32_t)b[3 * i + 1] << 16 |
+ (uint32_t)b[3 * i + 2] << 8) / INT32_PEAK;
+ }
+ }
+ break;
+ case 32: { //signed big-endian 32-bit
+ uint32_t* q = (uint32_t*)m_buff.GetData();//signed take as an unsigned to shift operations.
+ for (unsigned int i = 0; i < nSamples; i++) {
+ f[i] = (float)(int32_t)(q[i] >> 24 |
+ (q[i] & 0x00ff0000) >> 8 |
+ (q[i] & 0x0000ff00) << 8 |
+ q[i] << 24) / INT32_PEAK;
+ }
+ }
+ break;
+ }
+
+ HRESULT hr;
+ if (S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
+ return hr;
+ }
+
+ m_buff.RemoveAll();
+ return S_OK;
}
HRESULT CMpaDecFilter::ProcessPCMintLE() //'sowt', little-endian 'in24' and 'in32'
{
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_pInput->CurrentMediaType().Format();
- unsigned int nSamples = m_buff.GetCount() * 8 / wfe->wBitsPerSample;
-
- CAtlArray<float> pBuff;
- pBuff.SetCount(nSamples);
- float* f = pBuff.GetData();
-
- switch (wfe->wBitsPerSample) {
- case 8: { //signed 8-bit
- int8_t* b = (int8_t*)m_buff.GetData();
- for (unsigned int i = 0; i < nSamples; i++) {
- f[i] = (float)b[i] / INT8_PEAK;
- }
- }
- break;
- case 16: { //signed little-endian 16-bit
- int16_t* d = (int16_t*)m_buff.GetData();
- for (unsigned int i = 0; i < nSamples; i++) {
- f[i] = (float)d[i] / INT16_PEAK;
- }
- }
- break;
- case 24: { //signed little-endian 32-bit
- uint8_t* b = (uint8_t*)m_buff.GetData();
- for (unsigned int i = 0; i < nSamples; i++) {
- f[i] = (float)(int32_t)((uint32_t)b[3*i] << 8 |
- (uint32_t)b[3*i+1] << 16 |
- (uint32_t)b[3*i+2] << 24) / INT32_PEAK;
- }
- }
- break;
- case 32: { //signed little-endian 32-bit
- int32_t* q = (int32_t*)m_buff.GetData();
- for (unsigned int i = 0; i < nSamples; i++) {
- f[i] = (float)q[i] / INT32_PEAK;
- }
- }
- break;
- }
-
- HRESULT hr;
- if (S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
- return hr;
- }
-
- m_buff.RemoveAll();
- return S_OK;
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_pInput->CurrentMediaType().Format();
+ unsigned int nSamples = m_buff.GetCount() * 8 / wfe->wBitsPerSample;
+
+ CAtlArray<float> pBuff;
+ pBuff.SetCount(nSamples);
+ float* f = pBuff.GetData();
+
+ switch (wfe->wBitsPerSample) {
+ case 8: { //signed 8-bit
+ int8_t* b = (int8_t*)m_buff.GetData();
+ for (unsigned int i = 0; i < nSamples; i++) {
+ f[i] = (float)b[i] / INT8_PEAK;
+ }
+ }
+ break;
+ case 16: { //signed little-endian 16-bit
+ int16_t* d = (int16_t*)m_buff.GetData();
+ for (unsigned int i = 0; i < nSamples; i++) {
+ f[i] = (float)d[i] / INT16_PEAK;
+ }
+ }
+ break;
+ case 24: { //signed little-endian 32-bit
+ uint8_t* b = (uint8_t*)m_buff.GetData();
+ for (unsigned int i = 0; i < nSamples; i++) {
+ f[i] = (float)(int32_t)((uint32_t)b[3 * i] << 8 |
+ (uint32_t)b[3 * i + 1] << 16 |
+ (uint32_t)b[3 * i + 2] << 24) / INT32_PEAK;
+ }
+ }
+ break;
+ case 32: { //signed little-endian 32-bit
+ int32_t* q = (int32_t*)m_buff.GetData();
+ for (unsigned int i = 0; i < nSamples; i++) {
+ f[i] = (float)q[i] / INT32_PEAK;
+ }
+ }
+ break;
+ }
+
+ HRESULT hr;
+ if (S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
+ return hr;
+ }
+
+ m_buff.RemoveAll();
+ return S_OK;
}
HRESULT CMpaDecFilter::ProcessPCMfloatBE() //big-endian 'fl32' and 'fl64'
{
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_pInput->CurrentMediaType().Format();
- unsigned int nSamples = m_buff.GetCount() * 8 / wfe->wBitsPerSample;
-
- CAtlArray<float> pBuff;
- pBuff.SetCount(nSamples);
- float* f = pBuff.GetData();
-
- switch (wfe->wBitsPerSample) {
- case 32: {
- uint32_t* q = (uint32_t*)m_buff.GetData();
- uint32_t* vf = (uint32_t*)f;
- for (unsigned int i = 0; i < nSamples; i++) {
- vf[i] = q[i] >> 24 |
- (q[i] & 0x00ff0000) >> 8 |
- (q[i] & 0x0000ff00) << 8 |
- q[i] << 24;
- }
- }
- break;
- case 64: {
- uint64_t* q = (uint64_t*)m_buff.GetData();
- uint64_t x;
- for (unsigned int i = 0; i < nSamples; i++) {
- x = q[i] >>56 |
- (q[i] & 0x00FF000000000000) >> 40 |
- (q[i] & 0x0000FF0000000000) >> 24 |
- (q[i] & 0x000000FF00000000) >> 8 |
- (q[i] & 0x00000000FF000000) << 8 |
- (q[i] & 0x0000000000FF0000) << 24 |
- (q[i] & 0x000000000000FF00) << 40 |
- q[i] << 56;
- f[i] = (float)*(double*)&x;
- }
- }
- break;
- }
-
- HRESULT hr;
- if (S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
- return hr;
- }
-
- m_buff.RemoveAll();
- return S_OK;
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_pInput->CurrentMediaType().Format();
+ unsigned int nSamples = m_buff.GetCount() * 8 / wfe->wBitsPerSample;
+
+ CAtlArray<float> pBuff;
+ pBuff.SetCount(nSamples);
+ float* f = pBuff.GetData();
+
+ switch (wfe->wBitsPerSample) {
+ case 32: {
+ uint32_t* q = (uint32_t*)m_buff.GetData();
+ uint32_t* vf = (uint32_t*)f;
+ for (unsigned int i = 0; i < nSamples; i++) {
+ vf[i] = q[i] >> 24 |
+ (q[i] & 0x00ff0000) >> 8 |
+ (q[i] & 0x0000ff00) << 8 |
+ q[i] << 24;
+ }
+ }
+ break;
+ case 64: {
+ uint64_t* q = (uint64_t*)m_buff.GetData();
+ uint64_t x;
+ for (unsigned int i = 0; i < nSamples; i++) {
+ x = q[i] >> 56 |
+ (q[i] & 0x00FF000000000000) >> 40 |
+ (q[i] & 0x0000FF0000000000) >> 24 |
+ (q[i] & 0x000000FF00000000) >> 8 |
+ (q[i] & 0x00000000FF000000) << 8 |
+ (q[i] & 0x0000000000FF0000) << 24 |
+ (q[i] & 0x000000000000FF00) << 40 |
+ q[i] << 56;
+ f[i] = (float) * (double*)&x;
+ }
+ }
+ break;
+ }
+
+ HRESULT hr;
+ if (S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
+ return hr;
+ }
+
+ m_buff.RemoveAll();
+ return S_OK;
}
HRESULT CMpaDecFilter::ProcessPCMfloatLE() //little-endian 'fl32' and 'fl64'
{
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_pInput->CurrentMediaType().Format();
- unsigned int nSamples = m_buff.GetCount() * 8 / wfe->wBitsPerSample;
-
- CAtlArray<float> pBuff;
- pBuff.SetCount(nSamples);
- float* f = pBuff.GetData();
-
- switch (wfe->wBitsPerSample) {
- case 32: {
- float* q = (float*)m_buff.GetData();
- memcpy(f, q, nSamples * 4);
- }
- break;
- case 64: {
- double* q = (double*)m_buff.GetData();
- for (unsigned int i = 0; i < nSamples; i++) {
- f[i] = (float)q[i];
- }
- }
- break;
- }
-
- HRESULT hr;
- if (S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
- return hr;
- }
-
- m_buff.RemoveAll();
- return S_OK;
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_pInput->CurrentMediaType().Format();
+ unsigned int nSamples = m_buff.GetCount() * 8 / wfe->wBitsPerSample;
+
+ CAtlArray<float> pBuff;
+ pBuff.SetCount(nSamples);
+ float* f = pBuff.GetData();
+
+ switch (wfe->wBitsPerSample) {
+ case 32: {
+ float* q = (float*)m_buff.GetData();
+ memcpy(f, q, nSamples * 4);
+ }
+ break;
+ case 64: {
+ double* q = (double*)m_buff.GetData();
+ for (unsigned int i = 0; i < nSamples; i++) {
+ f[i] = (float)q[i];
+ }
+ }
+ break;
+ }
+
+ HRESULT hr;
+ if (S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
+ return hr;
+ }
+
+ m_buff.RemoveAll();
+ return S_OK;
}
#endif /* INTERNAL_DECODER_PCM */
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_PS2AUDIO
HRESULT CMpaDecFilter::ProcessPS2PCM()
{
- BYTE* p = m_buff.GetData();
- BYTE* base = p;
- BYTE* end = p + m_buff.GetCount();
-
- WAVEFORMATEXPS2* wfe = (WAVEFORMATEXPS2*)m_pInput->CurrentMediaType().Format();
- int size = wfe->dwInterleave*wfe->nChannels;
- int samples = wfe->dwInterleave/(wfe->wBitsPerSample>>3);
- int channels = wfe->nChannels;
-
- CAtlArray<float> pBuff;
- pBuff.SetCount(samples*channels);
- float* f = pBuff.GetData();
-
- while (end - p >= size) {
- DWORD* dw = (DWORD*)p;
-
- if (dw[0] == 'dhSS') {
- p += dw[1] + 8;
- } else if (dw[0] == 'dbSS') {
- p += 8;
- m_ps2_state.sync = true;
- } else {
- if (m_ps2_state.sync) {
- short* s = (short*)p;
-
- for (int i = 0; i < samples; i++)
- for (int j = 0; j < channels; j++) {
- f[i*channels+j] = (float)s[j*samples+i] / INT16_PEAK;
- }
- } else {
- for (int i = 0, j = samples*channels; i < j; i++) {
- f[i] = 0;
- }
- }
-
- HRESULT hr;
- if (S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
- return hr;
- }
-
- p += size;
-
- memmove(base, p, end - p);
- end = base + (end - p);
- p = base;
- }
- }
-
- m_buff.SetCount(end - p);
-
- return S_OK;
+ BYTE* p = m_buff.GetData();
+ BYTE* base = p;
+ BYTE* end = p + m_buff.GetCount();
+
+ WAVEFORMATEXPS2* wfe = (WAVEFORMATEXPS2*)m_pInput->CurrentMediaType().Format();
+ int size = wfe->dwInterleave * wfe->nChannels;
+ int samples = wfe->dwInterleave / (wfe->wBitsPerSample >> 3);
+ int channels = wfe->nChannels;
+
+ CAtlArray<float> pBuff;
+ pBuff.SetCount(samples * channels);
+ float* f = pBuff.GetData();
+
+ while (end - p >= size) {
+ DWORD* dw = (DWORD*)p;
+
+ if (dw[0] == 'dhSS') {
+ p += dw[1] + 8;
+ } else if (dw[0] == 'dbSS') {
+ p += 8;
+ m_ps2_state.sync = true;
+ } else {
+ if (m_ps2_state.sync) {
+ short* s = (short*)p;
+
+ for (int i = 0; i < samples; i++)
+ for (int j = 0; j < channels; j++) {
+ f[i * channels + j] = (float)s[j * samples + i] / INT16_PEAK;
+ }
+ } else {
+ for (int i = 0, j = samples * channels; i < j; i++) {
+ f[i] = 0;
+ }
+ }
+
+ HRESULT hr;
+ if (S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
+ return hr;
+ }
+
+ p += size;
+
+ memmove(base, p, end - p);
+ end = base + (end - p);
+ p = base;
+ }
+ }
+
+ m_buff.SetCount(end - p);
+
+ return S_OK;
}
static void decodeps2adpcm(ps2_state_t& s, int channel, BYTE* pin, double* pout)
{
- int tbl_index = pin[0]>>4;
- int shift = pin[0]&0xf;
- int unk = pin[1]; // ?
- UNREFERENCED_PARAMETER(unk);
-
- if (tbl_index >= 10) {
- ASSERT(0);
- return;
- }
- // if (unk == 7) {ASSERT(0); return;} // ???
-
- static double s_tbl[] = {
- 0.0, 0.0, 0.9375, 0.0, 1.796875, -0.8125, 1.53125, -0.859375, 1.90625, -0.9375,
- 0.0, 0.0, -0.9375, 0.0, -1.796875, 0.8125, -1.53125, 0.859375 -1.90625, 0.9375
- };
-
- double* tbl = &s_tbl[tbl_index*2];
- double& a = s.a[channel];
- double& b = s.b[channel];
-
- for (int i = 0; i < 28; i++) {
- short input = (short)(((pin[2+i/2] >> ((i&1) << 2)) & 0xf) << 12) >> shift;
- double output = a * tbl[1] + b * tbl[0] + input;
-
- a = b;
- b = output;
-
- *pout++ = output / INT16_PEAK;
- }
+ int tbl_index = pin[0] >> 4;
+ int shift = pin[0] & 0xf;
+ int unk = pin[1]; // ?
+ UNREFERENCED_PARAMETER(unk);
+
+ if (tbl_index >= 10) {
+ ASSERT(0);
+ return;
+ }
+ // if (unk == 7) {ASSERT(0); return;} // ???
+
+ static double s_tbl[] = {
+ 0.0, 0.0, 0.9375, 0.0, 1.796875, -0.8125, 1.53125, -0.859375, 1.90625, -0.9375,
+ 0.0, 0.0, -0.9375, 0.0, -1.796875, 0.8125, -1.53125, 0.859375 - 1.90625, 0.9375
+ };
+
+ double* tbl = &s_tbl[tbl_index * 2];
+ double& a = s.a[channel];
+ double& b = s.b[channel];
+
+ for (int i = 0; i < 28; i++) {
+ short input = (short)(((pin[2 + i / 2] >> ((i & 1) << 2)) & 0xf) << 12) >> shift;
+ double output = a * tbl[1] + b * tbl[0] + input;
+
+ a = b;
+ b = output;
+
+ *pout++ = output / INT16_PEAK;
+ }
}
HRESULT CMpaDecFilter::ProcessPS2ADPCM()
{
- BYTE* p = m_buff.GetData();
- BYTE* base = p;
- BYTE* end = p + m_buff.GetCount();
-
- WAVEFORMATEXPS2* wfe = (WAVEFORMATEXPS2*)m_pInput->CurrentMediaType().Format();
- int size = wfe->dwInterleave*wfe->nChannels;
- int samples = wfe->dwInterleave * 14 / 16 * 2;
- int channels = wfe->nChannels;
-
- CAtlArray<float> pBuff;
- pBuff.SetCount(samples*channels);
- float* f = pBuff.GetData();
-
- while (end - p >= size) {
- DWORD* dw = (DWORD*)p;
-
- if (dw[0] == 'dhSS') {
- p += dw[1] + 8;
- } else if (dw[0] == 'dbSS') {
- p += 8;
- m_ps2_state.sync = true;
- } else {
- if (m_ps2_state.sync) {
- double* tmp = DNew double[samples*channels];
-
- for (int channel = 0, j = 0, k = 0; channel < channels; channel++, j += wfe->dwInterleave)
- for (DWORD i = 0; i < wfe->dwInterleave; i += 16, k += 28) {
- decodeps2adpcm(m_ps2_state, channel, p + i + j, tmp + k);
- }
-
- for (int i = 0, k = 0; i < samples; i++)
- for (int j = 0; j < channels; j++, k++) {
- f[k] = (float)tmp[j*samples+i];
- }
-
- delete [] tmp;
- } else {
- for (int i = 0, j = samples*channels; i < j; i++) {
- f[i] = 0;
- }
- }
-
- HRESULT hr;
- if (S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
- return hr;
- }
-
- p += size;
- }
- }
-
- memmove(base, p, end - p);
- end = base + (end - p);
- p = base;
-
- m_buff.SetCount(end - p);
-
- return S_OK;
+ BYTE* p = m_buff.GetData();
+ BYTE* base = p;
+ BYTE* end = p + m_buff.GetCount();
+
+ WAVEFORMATEXPS2* wfe = (WAVEFORMATEXPS2*)m_pInput->CurrentMediaType().Format();
+ int size = wfe->dwInterleave * wfe->nChannels;
+ int samples = wfe->dwInterleave * 14 / 16 * 2;
+ int channels = wfe->nChannels;
+
+ CAtlArray<float> pBuff;
+ pBuff.SetCount(samples * channels);
+ float* f = pBuff.GetData();
+
+ while (end - p >= size) {
+ DWORD* dw = (DWORD*)p;
+
+ if (dw[0] == 'dhSS') {
+ p += dw[1] + 8;
+ } else if (dw[0] == 'dbSS') {
+ p += 8;
+ m_ps2_state.sync = true;
+ } else {
+ if (m_ps2_state.sync) {
+ double* tmp = DNew double[samples * channels];
+
+ for (int channel = 0, j = 0, k = 0; channel < channels; channel++, j += wfe->dwInterleave)
+ for (DWORD i = 0; i < wfe->dwInterleave; i += 16, k += 28) {
+ decodeps2adpcm(m_ps2_state, channel, p + i + j, tmp + k);
+ }
+
+ for (int i = 0, k = 0; i < samples; i++)
+ for (int j = 0; j < channels; j++, k++) {
+ f[k] = (float)tmp[j * samples + i];
+ }
+
+ delete [] tmp;
+ } else {
+ for (int i = 0, j = samples * channels; i < j; i++) {
+ f[i] = 0;
+ }
+ }
+
+ HRESULT hr;
+ if (S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
+ return hr;
+ }
+
+ p += size;
+ }
+ }
+
+ memmove(base, p, end - p);
+ end = base + (end - p);
+ p = base;
+
+ m_buff.SetCount(end - p);
+
+ return S_OK;
}
#endif /* INTERNAL_DECODER_PS2AUDIO */
HRESULT CMpaDecFilter::GetDeliveryBuffer(IMediaSample** pSample, BYTE** pData)
{
- HRESULT hr;
-
- *pData = NULL;
- if (FAILED(hr = m_pOutput->GetDeliveryBuffer(pSample, NULL, NULL, 0))
- || FAILED(hr = (*pSample)->GetPointer(pData))) {
- return hr;
- }
-
- AM_MEDIA_TYPE* pmt = NULL;
- if (SUCCEEDED((*pSample)->GetMediaType(&pmt)) && pmt) {
- CMediaType mt = *pmt;
- m_pOutput->SetMediaType(&mt);
- DeleteMediaType(pmt);
- pmt = NULL;
- }
-
- return S_OK;
+ HRESULT hr;
+
+ *pData = NULL;
+ if (FAILED(hr = m_pOutput->GetDeliveryBuffer(pSample, NULL, NULL, 0))
+ || FAILED(hr = (*pSample)->GetPointer(pData))) {
+ return hr;
+ }
+
+ AM_MEDIA_TYPE* pmt = NULL;
+ if (SUCCEEDED((*pSample)->GetMediaType(&pmt)) && pmt) {
+ CMediaType mt = *pmt;
+ m_pOutput->SetMediaType(&mt);
+ DeleteMediaType(pmt);
+ pmt = NULL;
+ }
+
+ return S_OK;
}
HRESULT CMpaDecFilter::Deliver(CAtlArray<float>& pBuff, DWORD nSamplesPerSec, WORD nChannels, DWORD dwChannelMask)
{
- HRESULT hr;
+ HRESULT hr;
- MPCSampleFormat sf = GetSampleFormat();
+ MPCSampleFormat sf = GetSampleFormat();
- CMediaType mt = CreateMediaType(sf, nSamplesPerSec, nChannels, dwChannelMask);
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
+ CMediaType mt = CreateMediaType(sf, nSamplesPerSec, nChannels, dwChannelMask);
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
- int nSamples = pBuff.GetCount()/wfe->nChannels;
+ int nSamples = pBuff.GetCount() / wfe->nChannels;
- if (FAILED(hr = ReconnectOutput(nSamples, mt))) {
- return hr;
- }
+ if (FAILED(hr = ReconnectOutput(nSamples, mt))) {
+ return hr;
+ }
- CComPtr<IMediaSample> pOut;
- BYTE* pDataOut = NULL;
- if (FAILED(GetDeliveryBuffer(&pOut, &pDataOut))) {
- return E_FAIL;
- }
+ CComPtr<IMediaSample> pOut;
+ BYTE* pDataOut = NULL;
+ if (FAILED(GetDeliveryBuffer(&pOut, &pDataOut))) {
+ return E_FAIL;
+ }
- REFERENCE_TIME rtDur = 10000000i64*nSamples/wfe->nSamplesPerSec;
- REFERENCE_TIME rtStart = m_rtStart, rtStop = m_rtStart + rtDur;
- m_rtStart += rtDur;
- //TRACE(_T("CMpaDecFilter: %I64d - %I64d\n"), rtStart/10000, rtStop/10000);
- if (rtStart < 0 /*200000*/ /* < 0, FIXME: 0 makes strange noises */) {
- return S_OK;
- }
+ REFERENCE_TIME rtDur = 10000000i64 * nSamples / wfe->nSamplesPerSec;
+ REFERENCE_TIME rtStart = m_rtStart, rtStop = m_rtStart + rtDur;
+ m_rtStart += rtDur;
+ //TRACE(_T("CMpaDecFilter: %I64d - %I64d\n"), rtStart/10000, rtStop/10000);
+ if (rtStart < 0 /*200000*/ /* < 0, FIXME: 0 makes strange noises */) {
+ return S_OK;
+ }
- if (hr == S_OK) {
- m_pOutput->SetMediaType(&mt);
- pOut->SetMediaType(&mt);
- }
+ if (hr == S_OK) {
+ m_pOutput->SetMediaType(&mt);
+ pOut->SetMediaType(&mt);
+ }
- pOut->SetTime(&rtStart, &rtStop);
- pOut->SetMediaTime(NULL, NULL);
+ pOut->SetTime(&rtStart, &rtStop);
+ pOut->SetMediaTime(NULL, NULL);
- pOut->SetPreroll(FALSE);
- pOut->SetDiscontinuity(m_fDiscontinuity);
- m_fDiscontinuity = false;
- pOut->SetSyncPoint(TRUE);
+ pOut->SetPreroll(FALSE);
+ pOut->SetDiscontinuity(m_fDiscontinuity);
+ m_fDiscontinuity = false;
+ pOut->SetSyncPoint(TRUE);
- pOut->SetActualDataLength(pBuff.GetCount()*wfe->wBitsPerSample/8);
+ pOut->SetActualDataLength(pBuff.GetCount()*wfe->wBitsPerSample / 8);
- WAVEFORMATEX* wfeout = (WAVEFORMATEX*)m_pOutput->CurrentMediaType().Format();
- ASSERT(wfeout->nChannels == wfe->nChannels);
- ASSERT(wfeout->nSamplesPerSec == wfe->nSamplesPerSec);
- UNREFERENCED_PARAMETER(wfeout);
+ WAVEFORMATEX* wfeout = (WAVEFORMATEX*)m_pOutput->CurrentMediaType().Format();
+ ASSERT(wfeout->nChannels == wfe->nChannels);
+ ASSERT(wfeout->nSamplesPerSec == wfe->nSamplesPerSec);
+ UNREFERENCED_PARAMETER(wfeout);
- float* pDataIn = pBuff.GetData();
+ float* pDataIn = pBuff.GetData();
#define f16max (float(INT16_MAX)/INT16_PEAK)
#define f24max (float(INT24_MAX)/INT24_PEAK)
@@ -1555,509 +1559,507 @@ HRESULT CMpaDecFilter::Deliver(CAtlArray<float>& pBuff, DWORD nSamplesPerSec, WO
#define round_f(x) ((x) > 0 ? (x) + 0.5f : (x) - 0.5f)
#define round_d(x) ((x) > 0 ? (x) + 0.5 : (x) - 0.5)
- for (unsigned int i = 0, len = pBuff.GetCount(); i < len; i++) {
- float f = *pDataIn++;
-
- if (f < -1) f = -1;
- switch (sf) {
- default:
- case SF_PCM16:
- if (f > f16max) f = f16max;
- *(int16_t*)pDataOut = (int16_t)round_f(f * INT16_PEAK);
- pDataOut += sizeof(int16_t);
- break;
- case SF_PCM24: {
- if (f > f24max) f = f24max;
- DWORD i24 = (DWORD)(int32_t)round_f(f * INT24_PEAK);
- *pDataOut++ = (BYTE)(i24);
- *pDataOut++ = (BYTE)(i24>>8);
- *pDataOut++ = (BYTE)(i24>>16);
- }
- break;
- case SF_PCM32: {
- double d = (double)f;
- if (d > d32max) d = d32max;
- *(int32_t*)pDataOut = (int32_t)round_d(d * INT32_PEAK);
- pDataOut += sizeof(int32_t);
- }
- break;
- case SF_FLOAT32:
- if (f > 1) f = 1;
- *(float*)pDataOut = f;
- pDataOut += sizeof(float);
- break;
- }
- }
-
- return m_pOutput->Deliver(pOut);
+ for (unsigned int i = 0, len = pBuff.GetCount(); i < len; i++) {
+ float f = *pDataIn++;
+
+ if (f < -1) { f = -1; }
+ switch (sf) {
+ default:
+ case SF_PCM16:
+ if (f > f16max) { f = f16max; }
+ *(int16_t*)pDataOut = (int16_t)round_f(f * INT16_PEAK);
+ pDataOut += sizeof(int16_t);
+ break;
+ case SF_PCM24: {
+ if (f > f24max) { f = f24max; }
+ DWORD i24 = (DWORD)(int32_t)round_f(f * INT24_PEAK);
+ *pDataOut++ = (BYTE)(i24);
+ *pDataOut++ = (BYTE)(i24 >> 8);
+ *pDataOut++ = (BYTE)(i24 >> 16);
+ }
+ break;
+ case SF_PCM32: {
+ double d = (double)f;
+ if (d > d32max) { d = d32max; }
+ *(int32_t*)pDataOut = (int32_t)round_d(d * INT32_PEAK);
+ pDataOut += sizeof(int32_t);
+ }
+ break;
+ case SF_FLOAT32:
+ if (f > 1) { f = 1; }
+ *(float*)pDataOut = f;
+ pDataOut += sizeof(float);
+ break;
+ }
+ }
+
+ return m_pOutput->Deliver(pOut);
}
HRESULT CMpaDecFilter::DeliverBitstream(BYTE* pBuff, int size, int sample_rate, int samples, BYTE type)
{
- HRESULT hr;
- bool isDTSWAV = false;
-
- int length = 0;
-
- if (type == 0x0b) { // DTS
- if (size == 4096 && sample_rate == 44100 && samples == 1024) { // DTSWAV
- length = size;
- isDTSWAV = true;
- }
- else while (length < size+16) {
- length += 2048;
- }
- } else { //if (type == 0x01) { // AC3
- length = samples*4;
- }
-
- CMediaType mt;
- if (isDTSWAV) {
- mt = CreateMediaTypeSPDIF(sample_rate);
- } else {
- mt = CreateMediaTypeSPDIF();
- }
-
- if (FAILED(hr = ReconnectOutput(length, mt))) {
- return hr;
- }
-
- CComPtr<IMediaSample> pOut;
- BYTE* pDataOut = NULL;
- if (FAILED(GetDeliveryBuffer(&pOut, &pDataOut))) {
- return E_FAIL;
- }
-
- if (isDTSWAV) {
- memcpy(pDataOut, pBuff, size);
- }
- else {
- WORD* pDataOutW = (WORD*)pDataOut;
- pDataOutW[0] = 0xf872;
- pDataOutW[1] = 0x4e1f;
- pDataOutW[2] = type;
- pDataOutW[3] = size*8;
- _swab((char*)pBuff, (char*)&pDataOutW[4], size+1); //if the size is odd, the function "_swab" lose the last byte. need add one.
- }
-
- REFERENCE_TIME rtDur;
- rtDur = 10000000i64 * samples / sample_rate;
- REFERENCE_TIME rtStart = m_rtStart, rtStop = m_rtStart + rtDur;
- m_rtStart += rtDur;
-
- if (rtStart < 0) {
- return S_OK;
- }
-
- if (hr == S_OK) {
- m_pOutput->SetMediaType(&mt);
- pOut->SetMediaType(&mt);
- }
-
- pOut->SetTime(&rtStart, &rtStop);
- pOut->SetMediaTime(NULL, NULL);
-
- pOut->SetPreroll(FALSE);
- pOut->SetDiscontinuity(m_fDiscontinuity);
- m_fDiscontinuity = false;
- pOut->SetSyncPoint(TRUE);
-
- pOut->SetActualDataLength(length);
-
- return m_pOutput->Deliver(pOut);
+ HRESULT hr;
+ bool isDTSWAV = false;
+
+ int length = 0;
+
+ if (type == 0x0b) { // DTS
+ if (size == 4096 && sample_rate == 44100 && samples == 1024) { // DTSWAV
+ length = size;
+ isDTSWAV = true;
+ } else while (length < size + 16) {
+ length += 2048;
+ }
+ } else { //if (type == 0x01) { // AC3
+ length = samples * 4;
+ }
+
+ CMediaType mt;
+ if (isDTSWAV) {
+ mt = CreateMediaTypeSPDIF(sample_rate);
+ } else {
+ mt = CreateMediaTypeSPDIF();
+ }
+
+ if (FAILED(hr = ReconnectOutput(length, mt))) {
+ return hr;
+ }
+
+ CComPtr<IMediaSample> pOut;
+ BYTE* pDataOut = NULL;
+ if (FAILED(GetDeliveryBuffer(&pOut, &pDataOut))) {
+ return E_FAIL;
+ }
+
+ if (isDTSWAV) {
+ memcpy(pDataOut, pBuff, size);
+ } else {
+ WORD* pDataOutW = (WORD*)pDataOut;
+ pDataOutW[0] = 0xf872;
+ pDataOutW[1] = 0x4e1f;
+ pDataOutW[2] = type;
+ pDataOutW[3] = size * 8;
+ _swab((char*)pBuff, (char*)&pDataOutW[4], size + 1); //if the size is odd, the function "_swab" lose the last byte. need add one.
+ }
+
+ REFERENCE_TIME rtDur;
+ rtDur = 10000000i64 * samples / sample_rate;
+ REFERENCE_TIME rtStart = m_rtStart, rtStop = m_rtStart + rtDur;
+ m_rtStart += rtDur;
+
+ if (rtStart < 0) {
+ return S_OK;
+ }
+
+ if (hr == S_OK) {
+ m_pOutput->SetMediaType(&mt);
+ pOut->SetMediaType(&mt);
+ }
+
+ pOut->SetTime(&rtStart, &rtStop);
+ pOut->SetMediaTime(NULL, NULL);
+
+ pOut->SetPreroll(FALSE);
+ pOut->SetDiscontinuity(m_fDiscontinuity);
+ m_fDiscontinuity = false;
+ pOut->SetSyncPoint(TRUE);
+
+ pOut->SetActualDataLength(length);
+
+ return m_pOutput->Deliver(pOut);
}
HRESULT CMpaDecFilter::ReconnectOutput(int nSamples, CMediaType& mt)
{
- HRESULT hr;
-
- CComQIPtr<IMemInputPin> pPin = m_pOutput->GetConnected();
- if (!pPin) {
- return E_NOINTERFACE;
- }
-
- CComPtr<IMemAllocator> pAllocator;
- if (FAILED(hr = pPin->GetAllocator(&pAllocator)) || !pAllocator) {
- return hr;
- }
-
- ALLOCATOR_PROPERTIES props, actual;
- if (FAILED(hr = pAllocator->GetProperties(&props))) {
- return hr;
- }
-
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
- long cbBuffer = nSamples * wfe->nBlockAlign;
-
- if (mt != m_pOutput->CurrentMediaType() || cbBuffer > props.cbBuffer) {
- if (cbBuffer > props.cbBuffer) {
- props.cBuffers = 4;
- props.cbBuffer = cbBuffer*3/2;
-
- if (FAILED(hr = m_pOutput->DeliverBeginFlush())
- || FAILED(hr = m_pOutput->DeliverEndFlush())
- || FAILED(hr = pAllocator->Decommit())
- || FAILED(hr = pAllocator->SetProperties(&props, &actual))
- || FAILED(hr = pAllocator->Commit())) {
- return hr;
- }
-
- if (props.cBuffers > actual.cBuffers || props.cbBuffer > actual.cbBuffer) {
- NotifyEvent(EC_ERRORABORT, hr, 0);
- return E_FAIL;
- }
- }
-
- return S_OK;
- }
-
- return S_FALSE;
+ HRESULT hr;
+
+ CComQIPtr<IMemInputPin> pPin = m_pOutput->GetConnected();
+ if (!pPin) {
+ return E_NOINTERFACE;
+ }
+
+ CComPtr<IMemAllocator> pAllocator;
+ if (FAILED(hr = pPin->GetAllocator(&pAllocator)) || !pAllocator) {
+ return hr;
+ }
+
+ ALLOCATOR_PROPERTIES props, actual;
+ if (FAILED(hr = pAllocator->GetProperties(&props))) {
+ return hr;
+ }
+
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
+ long cbBuffer = nSamples * wfe->nBlockAlign;
+
+ if (mt != m_pOutput->CurrentMediaType() || cbBuffer > props.cbBuffer) {
+ if (cbBuffer > props.cbBuffer) {
+ props.cBuffers = 4;
+ props.cbBuffer = cbBuffer * 3 / 2;
+
+ if (FAILED(hr = m_pOutput->DeliverBeginFlush())
+ || FAILED(hr = m_pOutput->DeliverEndFlush())
+ || FAILED(hr = pAllocator->Decommit())
+ || FAILED(hr = pAllocator->SetProperties(&props, &actual))
+ || FAILED(hr = pAllocator->Commit())) {
+ return hr;
+ }
+
+ if (props.cBuffers > actual.cBuffers || props.cbBuffer > actual.cbBuffer) {
+ NotifyEvent(EC_ERRORABORT, hr, 0);
+ return E_FAIL;
+ }
+ }
+
+ return S_OK;
+ }
+
+ return S_FALSE;
}
CMediaType CMpaDecFilter::CreateMediaType(MPCSampleFormat sf, DWORD nSamplesPerSec, WORD nChannels, DWORD dwChannelMask)
{
- CMediaType mt;
-
- mt.majortype = MEDIATYPE_Audio;
- mt.subtype = sf == SF_FLOAT32 ? MEDIASUBTYPE_IEEE_FLOAT : MEDIASUBTYPE_PCM;
- mt.formattype = FORMAT_WaveFormatEx;
-
- WAVEFORMATEXTENSIBLE wfex;
- memset(&wfex, 0, sizeof(wfex));
- WAVEFORMATEX* wfe = &wfex.Format;
- wfe->wFormatTag = (WORD)mt.subtype.Data1;
- wfe->nChannels = nChannels;
- wfe->nSamplesPerSec = nSamplesPerSec;
- switch (sf) {
- default:
- case SF_PCM16:
- wfe->wBitsPerSample = 16;
- break;
- case SF_PCM24:
- wfe->wBitsPerSample = 24;
- break;
- case SF_PCM32:
- case SF_FLOAT32:
- wfe->wBitsPerSample = 32;
- break;
- }
- wfe->nBlockAlign = wfe->nChannels*wfe->wBitsPerSample/8;
- wfe->nAvgBytesPerSec = wfe->nSamplesPerSec*wfe->nBlockAlign;
- mt.SetSampleSize (wfe->wBitsPerSample*wfe->nChannels/8);
-
- // FIXME: 24/32 bit only seems to work with WAVE_FORMAT_EXTENSIBLE
- if (dwChannelMask == 0 && (sf == SF_PCM24 || sf == SF_PCM32)) {
- dwChannelMask = nChannels == 2 ? (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT) : SPEAKER_FRONT_CENTER;
- }
-
- if (dwChannelMask) {
- wfex.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
- wfex.Format.cbSize = sizeof(wfex) - sizeof(wfex.Format);
- wfex.dwChannelMask = dwChannelMask;
- wfex.Samples.wValidBitsPerSample = wfex.Format.wBitsPerSample;
- wfex.SubFormat = mt.subtype;
- }
-
- mt.SetFormat((BYTE*)&wfex, sizeof(wfex.Format) + wfex.Format.cbSize);
-
- return mt;
+ CMediaType mt;
+
+ mt.majortype = MEDIATYPE_Audio;
+ mt.subtype = sf == SF_FLOAT32 ? MEDIASUBTYPE_IEEE_FLOAT : MEDIASUBTYPE_PCM;
+ mt.formattype = FORMAT_WaveFormatEx;
+
+ WAVEFORMATEXTENSIBLE wfex;
+ memset(&wfex, 0, sizeof(wfex));
+ WAVEFORMATEX* wfe = &wfex.Format;
+ wfe->wFormatTag = (WORD)mt.subtype.Data1;
+ wfe->nChannels = nChannels;
+ wfe->nSamplesPerSec = nSamplesPerSec;
+ switch (sf) {
+ default:
+ case SF_PCM16:
+ wfe->wBitsPerSample = 16;
+ break;
+ case SF_PCM24:
+ wfe->wBitsPerSample = 24;
+ break;
+ case SF_PCM32:
+ case SF_FLOAT32:
+ wfe->wBitsPerSample = 32;
+ break;
+ }
+ wfe->nBlockAlign = wfe->nChannels * wfe->wBitsPerSample / 8;
+ wfe->nAvgBytesPerSec = wfe->nSamplesPerSec * wfe->nBlockAlign;
+ mt.SetSampleSize(wfe->wBitsPerSample * wfe->nChannels / 8);
+
+ // FIXME: 24/32 bit only seems to work with WAVE_FORMAT_EXTENSIBLE
+ if (dwChannelMask == 0 && (sf == SF_PCM24 || sf == SF_PCM32)) {
+ dwChannelMask = nChannels == 2 ? (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT) : SPEAKER_FRONT_CENTER;
+ }
+
+ if (dwChannelMask) {
+ wfex.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
+ wfex.Format.cbSize = sizeof(wfex) - sizeof(wfex.Format);
+ wfex.dwChannelMask = dwChannelMask;
+ wfex.Samples.wValidBitsPerSample = wfex.Format.wBitsPerSample;
+ wfex.SubFormat = mt.subtype;
+ }
+
+ mt.SetFormat((BYTE*)&wfex, sizeof(wfex.Format) + wfex.Format.cbSize);
+
+ return mt;
}
CMediaType CMpaDecFilter::CreateMediaTypeSPDIF(DWORD nSamplesPerSec)
{
- CMediaType mt = CreateMediaType(SF_PCM16, nSamplesPerSec, 2);
- ((WAVEFORMATEX*)mt.pbFormat)->wFormatTag = WAVE_FORMAT_DOLBY_AC3_SPDIF;
- return mt;
+ CMediaType mt = CreateMediaType(SF_PCM16, nSamplesPerSec, 2);
+ ((WAVEFORMATEX*)mt.pbFormat)->wFormatTag = WAVE_FORMAT_DOLBY_AC3_SPDIF;
+ return mt;
}
HRESULT CMpaDecFilter::CheckInputType(const CMediaType* mtIn)
{
- if (0) {}
+ if (0) {}
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_LPCM
- else if (mtIn->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mtIn->Format();
- if (wfe->nChannels < 1 || wfe->nChannels > 8 || (wfe->wBitsPerSample != 16 && wfe->wBitsPerSample != 20 && wfe->wBitsPerSample != 24)) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- }
+ else if (mtIn->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)mtIn->Format();
+ if (wfe->nChannels < 1 || wfe->nChannels > 8 || (wfe->wBitsPerSample != 16 && wfe->wBitsPerSample != 20 && wfe->wBitsPerSample != 24)) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+ }
#endif
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_PS2AUDIO
- else if (mtIn->subtype == MEDIASUBTYPE_PS2_ADPCM) {
- WAVEFORMATEXPS2* wfe = (WAVEFORMATEXPS2*)mtIn->Format();
- if (wfe->dwInterleave & 0xf) { // has to be a multiple of the block size (16 bytes)
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- }
+ else if (mtIn->subtype == MEDIASUBTYPE_PS2_ADPCM) {
+ WAVEFORMATEXPS2* wfe = (WAVEFORMATEXPS2*)mtIn->Format();
+ if (wfe->dwInterleave & 0xf) { // has to be a multiple of the block size (16 bytes)
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+ }
#endif
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_PCM
- else if (mtIn->subtype == MEDIASUBTYPE_IEEE_FLOAT) {
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mtIn->Format();
- if (wfe->wBitsPerSample != 64) { // only for 64-bit float PCM
- return VFW_E_TYPE_NOT_ACCEPTED; // not needed any decoders for 32-bit float
- }
- }
+ else if (mtIn->subtype == MEDIASUBTYPE_IEEE_FLOAT) {
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)mtIn->Format();
+ if (wfe->wBitsPerSample != 64) { // only for 64-bit float PCM
+ return VFW_E_TYPE_NOT_ACCEPTED; // not needed any decoders for 32-bit float
+ }
+ }
#endif
- for (int i = 0; i < _countof(sudPinTypesIn); i++) {
- if (*sudPinTypesIn[i].clsMajorType == mtIn->majortype
- && *sudPinTypesIn[i].clsMinorType == mtIn->subtype) {
- return S_OK;
- }
- }
+ for (int i = 0; i < _countof(sudPinTypesIn); i++) {
+ if (*sudPinTypesIn[i].clsMajorType == mtIn->majortype
+ && *sudPinTypesIn[i].clsMinorType == mtIn->subtype) {
+ return S_OK;
+ }
+ }
- return VFW_E_TYPE_NOT_ACCEPTED;
+ return VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CMpaDecFilter::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
{
- return SUCCEEDED(CheckInputType(mtIn))
- && mtOut->majortype == MEDIATYPE_Audio && mtOut->subtype == MEDIASUBTYPE_PCM
- || mtOut->majortype == MEDIATYPE_Audio && mtOut->subtype == MEDIASUBTYPE_IEEE_FLOAT
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ return SUCCEEDED(CheckInputType(mtIn))
+ && mtOut->majortype == MEDIATYPE_Audio && mtOut->subtype == MEDIASUBTYPE_PCM
+ || mtOut->majortype == MEDIATYPE_Audio && mtOut->subtype == MEDIASUBTYPE_IEEE_FLOAT
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CMpaDecFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if (m_pInput->IsConnected() == FALSE) {
- return E_UNEXPECTED;
- }
-
- CMediaType& mt = m_pInput->CurrentMediaType();
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
- UNREFERENCED_PARAMETER(wfe);
-
- pProperties->cBuffers = 4;
- // pProperties->cbBuffer = 1;
- pProperties->cbBuffer = 48000*6*(32/8)/10; // 48KHz 6ch 32bps 100ms
- pProperties->cbAlign = 1;
- pProperties->cbPrefix = 0;
-
- HRESULT hr;
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
- return hr;
- }
-
- return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
- ? E_FAIL
- : NOERROR;
+ if (m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
+
+ CMediaType& mt = m_pInput->CurrentMediaType();
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
+ UNREFERENCED_PARAMETER(wfe);
+
+ pProperties->cBuffers = 4;
+ // pProperties->cbBuffer = 1;
+ pProperties->cbBuffer = 48000 * 6 * (32 / 8) / 10; // 48KHz 6ch 32bps 100ms
+ pProperties->cbAlign = 1;
+ pProperties->cbPrefix = 0;
+
+ HRESULT hr;
+ ALLOCATOR_PROPERTIES Actual;
+ if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
+
+ return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
+ ? E_FAIL
+ : NOERROR;
}
HRESULT CMpaDecFilter::GetMediaType(int iPosition, CMediaType* pmt)
{
- if (m_pInput->IsConnected() == FALSE) {
- return E_UNEXPECTED;
- }
-
- if (iPosition < 0) {
- return E_INVALIDARG;
- }
- if (iPosition > 0) {
- return VFW_S_NO_MORE_ITEMS;
- }
-
- CMediaType mt = m_pInput->CurrentMediaType();
- const GUID& subtype = mt.subtype;
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
- if (wfe == NULL) {
- return E_INVALIDARG;
- }
+ if (m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
+
+ if (iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if (iPosition > 0) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
+
+ CMediaType mt = m_pInput->CurrentMediaType();
+ const GUID& subtype = mt.subtype;
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
+ if (wfe == NULL) {
+ return E_INVALIDARG;
+ }
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_AC3 || INTERNAL_DECODER_DTS
- if (GetSpeakerConfig(ac3) < 0 && (subtype == MEDIASUBTYPE_DOLBY_AC3 ||
- subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3 ||
- subtype == MEDIASUBTYPE_DOLBY_DDPLUS ||
- subtype == MEDIASUBTYPE_DOLBY_TRUEHD)
- || GetSpeakerConfig(dts) < 0 && (subtype == MEDIASUBTYPE_DTS || subtype == MEDIASUBTYPE_WAVE_DTS)) {
- *pmt = CreateMediaTypeSPDIF();
- }
+ if (GetSpeakerConfig(ac3) < 0 && (subtype == MEDIASUBTYPE_DOLBY_AC3 ||
+ subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3 ||
+ subtype == MEDIASUBTYPE_DOLBY_DDPLUS ||
+ subtype == MEDIASUBTYPE_DOLBY_TRUEHD)
+ || GetSpeakerConfig(dts) < 0 && (subtype == MEDIASUBTYPE_DTS || subtype == MEDIASUBTYPE_WAVE_DTS)) {
+ *pmt = CreateMediaTypeSPDIF();
+ }
#else
- if (0) {}
+ if (0) {}
#endif
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_VORBIS
- else if (subtype == MEDIASUBTYPE_Vorbis2) {
- VORBISFORMAT2 *vf2 = (VORBISFORMAT2 *)mt.Format();
- WORD nChannels = (WORD)vf2->Channels;
- *pmt = CreateMediaType(GetSampleFormat(), vf2->SamplesPerSec, nChannels, GetVorbisChannelMask(nChannels));
- }
+ else if (subtype == MEDIASUBTYPE_Vorbis2) {
+ VORBISFORMAT2* vf2 = (VORBISFORMAT2*)mt.Format();
+ WORD nChannels = (WORD)vf2->Channels;
+ *pmt = CreateMediaType(GetSampleFormat(), vf2->SamplesPerSec, nChannels, GetVorbisChannelMask(nChannels));
+ }
#endif
- else {
- *pmt = CreateMediaType(GetSampleFormat(), wfe->nSamplesPerSec, min(2, wfe->nChannels));
- }
+ else {
+ *pmt = CreateMediaType(GetSampleFormat(), wfe->nSamplesPerSec, min(2, wfe->nChannels));
+ }
- return S_OK;
+ return S_OK;
}
HRESULT CMpaDecFilter::StartStreaming()
{
- HRESULT hr = __super::StartStreaming();
- if (FAILED(hr)) {
- return hr;
- }
+ HRESULT hr = __super::StartStreaming();
+ if (FAILED(hr)) {
+ return hr;
+ }
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_AC3
- m_a52_state = a52_init(0);
+ m_a52_state = a52_init(0);
#endif
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_DTS
- m_dts_state = dts_init(0);
+ m_dts_state = dts_init(0);
#endif
- m_ps2_state.reset();
+ m_ps2_state.reset();
- m_fDiscontinuity = false;
+ m_fDiscontinuity = false;
- return S_OK;
+ return S_OK;
}
HRESULT CMpaDecFilter::StopStreaming()
{
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_AC3
- if (m_a52_state != NULL) {
- a52_free(m_a52_state);
- m_a52_state = NULL;
- }
+ if (m_a52_state != NULL) {
+ a52_free(m_a52_state);
+ m_a52_state = NULL;
+ }
#endif
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_DTS
- if (m_dts_state != NULL) {
- dts_free(m_dts_state);
- m_dts_state = NULL;
- }
+ if (m_dts_state != NULL) {
+ dts_free(m_dts_state);
+ m_dts_state = NULL;
+ }
#endif
#if defined(REGISTER_FILTER) || HAS_FFMPEG_AUDIO_DECODERS
- ffmpeg_stream_finish();
+ ffmpeg_stream_finish();
#endif
- return __super::StopStreaming();
+ return __super::StopStreaming();
}
-HRESULT CMpaDecFilter::SetMediaType(PIN_DIRECTION dir, const CMediaType *pmt)
+HRESULT CMpaDecFilter::SetMediaType(PIN_DIRECTION dir, const CMediaType* pmt)
{
#if defined(REGISTER_FILTER) || HAS_FFMPEG_AUDIO_DECODERS
- if (dir == PINDIR_INPUT) {
- enum CodecID nCodecId = FindCodec(pmt->subtype);
- if (nCodecId != CODEC_ID_NONE && !InitFFmpeg(nCodecId)) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- }
+ if (dir == PINDIR_INPUT) {
+ enum CodecID nCodecId = FindCodec(pmt->subtype);
+ if (nCodecId != CODEC_ID_NONE && !InitFFmpeg(nCodecId)) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+ }
#endif
- return __super::SetMediaType(dir, pmt);
+ return __super::SetMediaType(dir, pmt);
}
// IMpaDecFilter
STDMETHODIMP CMpaDecFilter::SetSampleFormat(MPCSampleFormat sf)
{
- CAutoLock cAutoLock(&m_csProps);
- m_iSampleFormat = sf;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_iSampleFormat = sf;
+ return S_OK;
}
STDMETHODIMP_(MPCSampleFormat) CMpaDecFilter::GetSampleFormat()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_iSampleFormat;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_iSampleFormat;
}
STDMETHODIMP CMpaDecFilter::SetSpeakerConfig(enctype et, int sc)
{
- CAutoLock cAutoLock(&m_csProps);
- if (et >= 0 && et < etlast) {
- m_iSpeakerConfig[et] = sc;
- }
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ if (et >= 0 && et < etlast) {
+ m_iSpeakerConfig[et] = sc;
+ }
+ return S_OK;
}
STDMETHODIMP_(int) CMpaDecFilter::GetSpeakerConfig(enctype et)
{
- CAutoLock cAutoLock(&m_csProps);
- if (et >= 0 && et < etlast) {
- return m_iSpeakerConfig[et];
- }
- return -1;
+ CAutoLock cAutoLock(&m_csProps);
+ if (et >= 0 && et < etlast) {
+ return m_iSpeakerConfig[et];
+ }
+ return -1;
}
STDMETHODIMP CMpaDecFilter::SetDynamicRangeControl(enctype et, bool fDRC)
{
- CAutoLock cAutoLock(&m_csProps);
- if (et >= 0 && et < etlast) {
- m_fDynamicRangeControl[et] = fDRC;
- } else {
- return E_INVALIDARG;
- }
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ if (et >= 0 && et < etlast) {
+ m_fDynamicRangeControl[et] = fDRC;
+ } else {
+ return E_INVALIDARG;
+ }
+ return S_OK;
}
STDMETHODIMP_(bool) CMpaDecFilter::GetDynamicRangeControl(enctype et)
{
- CAutoLock cAutoLock(&m_csProps);
- if (et >= 0 && et < etlast) {
- return m_fDynamicRangeControl[et];
- }
- return false;
+ CAutoLock cAutoLock(&m_csProps);
+ if (et >= 0 && et < etlast) {
+ return m_fDynamicRangeControl[et];
+ }
+ return false;
}
STDMETHODIMP_(DolbyDigitalMode) CMpaDecFilter::GetDolbyDigitalMode()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_DolbyDigitalMode;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_DolbyDigitalMode;
}
STDMETHODIMP CMpaDecFilter::SaveSettings()
{
- CAutoLock cAutoLock(&m_csProps);
+ CAutoLock cAutoLock(&m_csProps);
#ifdef REGISTER_FILTER
- CRegKey key;
- if (ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Audio Decoder"))) {
- key.SetDWORDValue(_T("SampleFormat"), m_iSampleFormat);
- key.SetDWORDValue(_T("Ac3SpeakerConfig"), m_iSpeakerConfig[ac3]);
- key.SetDWORDValue(_T("DtsSpeakerConfig"), m_iSpeakerConfig[dts]);
- key.SetDWORDValue(_T("Ac3DynamicRangeControl"), m_fDynamicRangeControl[ac3]);
- key.SetDWORDValue(_T("DtsDynamicRangeControl"), m_fDynamicRangeControl[dts]);
- }
+ CRegKey key;
+ if (ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Audio Decoder"))) {
+ key.SetDWORDValue(_T("SampleFormat"), m_iSampleFormat);
+ key.SetDWORDValue(_T("Ac3SpeakerConfig"), m_iSpeakerConfig[ac3]);
+ key.SetDWORDValue(_T("DtsSpeakerConfig"), m_iSpeakerConfig[dts]);
+ key.SetDWORDValue(_T("Ac3DynamicRangeControl"), m_fDynamicRangeControl[ac3]);
+ key.SetDWORDValue(_T("DtsDynamicRangeControl"), m_fDynamicRangeControl[dts]);
+ }
#else
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Audio Decoder"), _T("SampleFormat"), m_iSampleFormat);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Audio Decoder"), _T("Ac3SpeakerConfig"), m_iSpeakerConfig[ac3]);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Audio Decoder"), _T("DtsSpeakerConfig"), m_iSpeakerConfig[dts]);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Audio Decoder"), _T("Ac3DynamicRangeControl"), m_fDynamicRangeControl[ac3]);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Audio Decoder"), _T("DtsDynamicRangeControl"), m_fDynamicRangeControl[dts]);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Audio Decoder"), _T("SampleFormat"), m_iSampleFormat);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Audio Decoder"), _T("Ac3SpeakerConfig"), m_iSpeakerConfig[ac3]);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Audio Decoder"), _T("DtsSpeakerConfig"), m_iSpeakerConfig[dts]);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Audio Decoder"), _T("Ac3DynamicRangeControl"), m_fDynamicRangeControl[ac3]);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Audio Decoder"), _T("DtsDynamicRangeControl"), m_fDynamicRangeControl[dts]);
#endif
- return S_OK;
+ return S_OK;
}
// ISpecifyPropertyPages2
STDMETHODIMP CMpaDecFilter::GetPages(CAUUID* pPages)
{
- CheckPointer(pPages, E_POINTER);
+ CheckPointer(pPages, E_POINTER);
- pPages->cElems = 1;
- pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID) * pPages->cElems);
- pPages->pElems[0] = __uuidof(CMpaDecSettingsWnd);
+ pPages->cElems = 1;
+ pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID) * pPages->cElems);
+ pPages->pElems[0] = __uuidof(CMpaDecSettingsWnd);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CMpaDecFilter::CreatePage(const GUID& guid, IPropertyPage** ppPage)
{
- CheckPointer(ppPage, E_POINTER);
+ CheckPointer(ppPage, E_POINTER);
- if (*ppPage != NULL) {
- return E_INVALIDARG;
- }
+ if (*ppPage != NULL) {
+ return E_INVALIDARG;
+ }
- HRESULT hr;
+ HRESULT hr;
- if (guid == __uuidof(CMpaDecSettingsWnd)) {
- (*ppPage = DNew CInternalPropertyPageTempl<CMpaDecSettingsWnd>(NULL, &hr))->AddRef();
- }
+ if (guid == __uuidof(CMpaDecSettingsWnd)) {
+ (*ppPage = DNew CInternalPropertyPageTempl<CMpaDecSettingsWnd>(NULL, &hr))->AddRef();
+ }
- return *ppPage ? S_OK : E_FAIL;
+ return *ppPage ? S_OK : E_FAIL;
}
//
@@ -2065,7 +2067,7 @@ STDMETHODIMP CMpaDecFilter::CreatePage(const GUID& guid, IPropertyPage** ppPage)
//
CMpaDecInputPin::CMpaDecInputPin(CTransformFilter* pFilter, HRESULT* phr, LPWSTR pName)
- : CDeCSSInputPin(NAME("CMpaDecInputPin"), pFilter, phr, pName)
+ : CDeCSSInputPin(NAME("CMpaDecInputPin"), pFilter, phr, pName)
{
}
@@ -2089,408 +2091,409 @@ CMpaDecInputPin::CMpaDecInputPin(CTransformFilter* pFilter, HRESULT* phr, LPWSTR
HRESULT CMpaDecFilter::DeliverFFmpeg(enum CodecID nCodecId, BYTE* p, int buffsize, int& size)
{
- HRESULT hr = S_OK;
- int got_frame = 0;
- if (!m_pAVCtx || nCodecId != m_pAVCtx->codec_id) {
- if (!InitFFmpeg (nCodecId)) {
- size = 0;
- return E_FAIL;
- }
- }
-
- bool b_use_parse = m_pParser && ((nCodecId == CODEC_ID_TRUEHD) ? ((buffsize > 2000) ? true : false) : true); // Dirty hack for use with MPC MPEGSplitter
-
- BYTE* pDataInBuff = p;
- CAtlArray<float> pBuffOut;
-
- WORD nChannels = 0;
- DWORD dwChannelMask = 0;
-
- BYTE *tmpProcessBuf = NULL;
-
- AVPacket avpkt;
- av_init_packet(&avpkt);
-
- if (m_raData.deint_id == MAKEFOURCC('r','n','e','g') || m_raData.deint_id == MAKEFOURCC('r','p','i','s')) {
-
- int w = m_raData.coded_frame_size;
- int h = m_raData.sub_packet_h;
- int sps = m_raData.sub_packet_size;
- int len = w * h;
-
- if (buffsize >= len) {
- tmpProcessBuf = (BYTE *)av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE);
- if (sps > 0 && m_raData.deint_id == MAKEFOURCC('r','n','e','g')) { // COOK and ATRAC codec
- const BYTE *srcBuf = pDataInBuff;
- for (int y = 0; y < h; y++) {
- for (int x = 0, w2 = w / sps; x < w2; x++) {
- memcpy(tmpProcessBuf + sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), srcBuf, sps);
- srcBuf += sps;
- }
- }
- } else if (m_raData.deint_id == MAKEFOURCC('r','p','i','s')) { // SIPR codec
- memcpy(tmpProcessBuf, pDataInBuff, len);
-
- // http://mplayerhq.hu/pipermail/mplayer-dev-eng/2002-August/010569.html
- static BYTE sipr_swaps[38][2]= {
- {0,63},{1,22},{2,44},{3,90},{5,81},{7,31},{8,86},{9,58},{10,36},{12,68},
- {13,39},{14,73},{15,53},{16,69},{17,57},{19,88},{20,34},{21,71},{24,46},
- {25,94},{26,54},{28,75},{29,50},{32,70},{33,92},{35,74},{38,85},{40,56},
- {42,87},{43,65},{45,59},{48,79},{49,93},{51,89},{55,95},{61,76},{67,83},
- {77,80}
- };
-
- int bs=h*w*2/96; // nibbles per subpacket
- for (int n=0; n<38; n++) {
- int i=bs*sipr_swaps[n][0];
- int o=bs*sipr_swaps[n][1];
- // swap nibbles of block 'i' with 'o'
- for (int j=0; j<bs; j++) {
- int x=(i&1) ? (tmpProcessBuf[(i>>1)]>>4) : (tmpProcessBuf[(i>>1)]&15);
- int y=(o&1) ? (tmpProcessBuf[(o>>1)]>>4) : (tmpProcessBuf[(o>>1)]&15);
- if (o&1) {
- tmpProcessBuf[(o>>1)]=(tmpProcessBuf[(o>>1)]&0x0F)|(x<<4);
- } else {
- tmpProcessBuf[(o>>1)]=(tmpProcessBuf[(o>>1)]&0xF0)|x;
- }
- if (i&1) {
- tmpProcessBuf[(i>>1)]=(tmpProcessBuf[(i>>1)]&0x0F)|(y<<4);
- } else {
- tmpProcessBuf[(i>>1)]=(tmpProcessBuf[(i>>1)]&0xF0)|y;
- }
- ++i;
- ++o;
- }
- }
- }
- pDataInBuff = tmpProcessBuf;
- buffsize = len;
- } else {
- size = 0;
- return S_OK;
- }
- }
-
- while (buffsize > 0) {
- got_frame = 0;
- COPY_TO_BUFFER(pDataInBuff, buffsize);
-
- if (b_use_parse) {
- BYTE *pOut = NULL;
- int pOut_size = 0;
- int used_bytes = av_parser_parse2(m_pParser, m_pAVCtx, &pOut, &pOut_size, m_pFFBuffer, buffsize, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0);
- if (used_bytes < 0) {
- TRACE(_T("CMpaDecFilter::DeliverFFmpeg() - audio parsing failed (ret: %d)\n"), -used_bytes);
- goto fail;
- } else if (used_bytes == 0 && pOut_size == 0) {
- TRACE(_T("CMpaDecFilter::DeliverFFmpeg() - could not process buffer while parsing\n"));
- break;
- }
-
- if (used_bytes > 0) {
- size += used_bytes;
- buffsize -= used_bytes;
- pDataInBuff += used_bytes;
- }
- if (pOut_size > 0) {
- COPY_TO_BUFFER(pOut, pOut_size);
- avpkt.data = (uint8_t *)m_pFFBuffer;
- avpkt.size = pOut_size;
-
- int ret2 = avcodec_decode_audio4(m_pAVCtx, m_pFrame, &got_frame, &avpkt);
- if (ret2 < 0) {
- TRACE(_T("CMpaDecFilter::DeliverFFmpeg() - decoding failed despite successfull parsing\n"));
- m_bResync = true;
- continue;
- }
- } else {
- continue;
- }
- } else {
- avpkt.data = (uint8_t *)m_pFFBuffer;
- avpkt.size = buffsize;
-
- int used_bytes = avcodec_decode_audio4(m_pAVCtx, m_pFrame, &got_frame, &avpkt);
-
- if (used_bytes < 0 || (used_bytes == 0 && !got_frame)) {
- TRACE(_T("CMpaDecFilter::DeliverFFmpeg() - decoding failed\n"));
- size = used_bytes;
- goto fail;
- } else if (used_bytes == 0) {
- TRACE(_T("CMpaDecFilter::DeliverFFmpeg() - could not process buffer while decoding\n"));
- break;
- } else if (m_pAVCtx->channels>8) {
- // sometimes avcodec_decode_audio4 can not identify the garbage and produces incorrect data.
- // this code does not solve the problem, it only reduces the likelihood of crash.
- // do it better!
- got_frame = 0;
- }
-
- size += used_bytes;
- buffsize -= used_bytes;
- pDataInBuff += used_bytes;
- }
-
- if (got_frame) {
- CAtlArray<float> pBuff;
- float* pDataOut;
-
- nChannels = m_pAVCtx->channels;
- if (m_pAVCtx->channel_layout)
- dwChannelMask = get_lav_channel_layout(m_pAVCtx->channel_layout);
- else
- dwChannelMask = GetDefChannelMask(nChannels);
-
- if (nChannels && dwChannelMask) {
-
- DWORD dwPCMSize = m_pFrame->nb_samples * nChannels * av_get_bytes_per_sample(m_pAVCtx->sample_fmt);
- switch (m_pAVCtx->sample_fmt) {
- case AV_SAMPLE_FMT_S16 :
- pBuff.SetCount (dwPCMSize / 2);
- pDataOut = pBuff.GetData();
-
- for (size_t i = 0; i < pBuff.GetCount(); ++i) {
- *pDataOut = (float)((int16_t*)m_pFrame->data[0])[i] / INT16_PEAK;
- pDataOut++;
- }
- break;
-
- case AV_SAMPLE_FMT_S32 :
- pBuff.SetCount (dwPCMSize / 4);
- pDataOut = pBuff.GetData();
-
- for (size_t i = 0; i < pBuff.GetCount(); ++i) {
- *pDataOut = (float)((int32_t*)m_pFrame->data[0])[i] / INT32_PEAK;
- pDataOut++;
- }
- break;
- case AV_SAMPLE_FMT_FLT:
- pBuff.SetCount (dwPCMSize / 4);
- pDataOut = pBuff.GetData();
- memcpy(pDataOut, m_pFrame->data[0], dwPCMSize);
- break;
- default :
- ASSERT(FALSE);
- break;
- }
-
- if (pBuff.GetCount() > 0) {
- hr = Deliver(pBuff, m_pAVCtx->sample_rate, nChannels, dwChannelMask);
- if (FAILED(hr)) {
- TRACE(_T("CMpaDecFilter::DeliverFFmpeg() - Deliver failed\n"));
- goto fail;
- }
- }
-
- }
- }
- }
-
- av_free(tmpProcessBuf);
- return hr;
+ HRESULT hr = S_OK;
+ int got_frame = 0;
+ if (!m_pAVCtx || nCodecId != m_pAVCtx->codec_id) {
+ if (!InitFFmpeg(nCodecId)) {
+ size = 0;
+ return E_FAIL;
+ }
+ }
+
+ bool b_use_parse = m_pParser && ((nCodecId == CODEC_ID_TRUEHD) ? ((buffsize > 2000) ? true : false) : true); // Dirty hack for use with MPC MPEGSplitter
+
+ BYTE* pDataInBuff = p;
+ CAtlArray<float> pBuffOut;
+
+ WORD nChannels = 0;
+ DWORD dwChannelMask = 0;
+
+ BYTE* tmpProcessBuf = NULL;
+
+ AVPacket avpkt;
+ av_init_packet(&avpkt);
+
+ if (m_raData.deint_id == MAKEFOURCC('r', 'n', 'e', 'g') || m_raData.deint_id == MAKEFOURCC('r', 'p', 'i', 's')) {
+
+ int w = m_raData.coded_frame_size;
+ int h = m_raData.sub_packet_h;
+ int sps = m_raData.sub_packet_size;
+ int len = w * h;
+
+ if (buffsize >= len) {
+ tmpProcessBuf = (BYTE*)av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE);
+ if (sps > 0 && m_raData.deint_id == MAKEFOURCC('r', 'n', 'e', 'g')) { // COOK and ATRAC codec
+ const BYTE* srcBuf = pDataInBuff;
+ for (int y = 0; y < h; y++) {
+ for (int x = 0, w2 = w / sps; x < w2; x++) {
+ memcpy(tmpProcessBuf + sps * (h * x + ((h + 1) / 2) * (y & 1) + (y >> 1)), srcBuf, sps);
+ srcBuf += sps;
+ }
+ }
+ } else if (m_raData.deint_id == MAKEFOURCC('r', 'p', 'i', 's')) { // SIPR codec
+ memcpy(tmpProcessBuf, pDataInBuff, len);
+
+ // http://mplayerhq.hu/pipermail/mplayer-dev-eng/2002-August/010569.html
+ static BYTE sipr_swaps[38][2] = {
+ {0, 63}, {1, 22}, {2, 44}, {3, 90}, {5, 81}, {7, 31}, {8, 86}, {9, 58}, {10, 36}, {12, 68},
+ {13, 39}, {14, 73}, {15, 53}, {16, 69}, {17, 57}, {19, 88}, {20, 34}, {21, 71}, {24, 46},
+ {25, 94}, {26, 54}, {28, 75}, {29, 50}, {32, 70}, {33, 92}, {35, 74}, {38, 85}, {40, 56},
+ {42, 87}, {43, 65}, {45, 59}, {48, 79}, {49, 93}, {51, 89}, {55, 95}, {61, 76}, {67, 83},
+ {77, 80}
+ };
+
+ int bs = h * w * 2 / 96; // nibbles per subpacket
+ for (int n = 0; n < 38; n++) {
+ int i = bs * sipr_swaps[n][0];
+ int o = bs * sipr_swaps[n][1];
+ // swap nibbles of block 'i' with 'o'
+ for (int j = 0; j < bs; j++) {
+ int x = (i & 1) ? (tmpProcessBuf[(i >> 1)] >> 4) : (tmpProcessBuf[(i >> 1)] & 15);
+ int y = (o & 1) ? (tmpProcessBuf[(o >> 1)] >> 4) : (tmpProcessBuf[(o >> 1)] & 15);
+ if (o & 1) {
+ tmpProcessBuf[(o >> 1)] = (tmpProcessBuf[(o >> 1)] & 0x0F) | (x << 4);
+ } else {
+ tmpProcessBuf[(o >> 1)] = (tmpProcessBuf[(o >> 1)] & 0xF0) | x;
+ }
+ if (i & 1) {
+ tmpProcessBuf[(i >> 1)] = (tmpProcessBuf[(i >> 1)] & 0x0F) | (y << 4);
+ } else {
+ tmpProcessBuf[(i >> 1)] = (tmpProcessBuf[(i >> 1)] & 0xF0) | y;
+ }
+ ++i;
+ ++o;
+ }
+ }
+ }
+ pDataInBuff = tmpProcessBuf;
+ buffsize = len;
+ } else {
+ size = 0;
+ return S_OK;
+ }
+ }
+
+ while (buffsize > 0) {
+ got_frame = 0;
+ COPY_TO_BUFFER(pDataInBuff, buffsize);
+
+ if (b_use_parse) {
+ BYTE* pOut = NULL;
+ int pOut_size = 0;
+ int used_bytes = av_parser_parse2(m_pParser, m_pAVCtx, &pOut, &pOut_size, m_pFFBuffer, buffsize, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0);
+ if (used_bytes < 0) {
+ TRACE(_T("CMpaDecFilter::DeliverFFmpeg() - audio parsing failed (ret: %d)\n"), -used_bytes);
+ goto fail;
+ } else if (used_bytes == 0 && pOut_size == 0) {
+ TRACE(_T("CMpaDecFilter::DeliverFFmpeg() - could not process buffer while parsing\n"));
+ break;
+ }
+
+ if (used_bytes > 0) {
+ size += used_bytes;
+ buffsize -= used_bytes;
+ pDataInBuff += used_bytes;
+ }
+ if (pOut_size > 0) {
+ COPY_TO_BUFFER(pOut, pOut_size);
+ avpkt.data = (uint8_t*)m_pFFBuffer;
+ avpkt.size = pOut_size;
+
+ int ret2 = avcodec_decode_audio4(m_pAVCtx, m_pFrame, &got_frame, &avpkt);
+ if (ret2 < 0) {
+ TRACE(_T("CMpaDecFilter::DeliverFFmpeg() - decoding failed despite successfull parsing\n"));
+ m_bResync = true;
+ continue;
+ }
+ } else {
+ continue;
+ }
+ } else {
+ avpkt.data = (uint8_t*)m_pFFBuffer;
+ avpkt.size = buffsize;
+
+ int used_bytes = avcodec_decode_audio4(m_pAVCtx, m_pFrame, &got_frame, &avpkt);
+
+ if (used_bytes < 0 || (used_bytes == 0 && !got_frame)) {
+ TRACE(_T("CMpaDecFilter::DeliverFFmpeg() - decoding failed\n"));
+ size = used_bytes;
+ goto fail;
+ } else if (used_bytes == 0) {
+ TRACE(_T("CMpaDecFilter::DeliverFFmpeg() - could not process buffer while decoding\n"));
+ break;
+ } else if (m_pAVCtx->channels > 8) {
+ // sometimes avcodec_decode_audio4 can not identify the garbage and produces incorrect data.
+ // this code does not solve the problem, it only reduces the likelihood of crash.
+ // do it better!
+ got_frame = 0;
+ }
+
+ size += used_bytes;
+ buffsize -= used_bytes;
+ pDataInBuff += used_bytes;
+ }
+
+ if (got_frame) {
+ CAtlArray<float> pBuff;
+ float* pDataOut;
+
+ nChannels = m_pAVCtx->channels;
+ if (m_pAVCtx->channel_layout) {
+ dwChannelMask = get_lav_channel_layout(m_pAVCtx->channel_layout);
+ } else {
+ dwChannelMask = GetDefChannelMask(nChannels);
+ }
+
+ if (nChannels && dwChannelMask) {
+
+ DWORD dwPCMSize = m_pFrame->nb_samples * nChannels * av_get_bytes_per_sample(m_pAVCtx->sample_fmt);
+ switch (m_pAVCtx->sample_fmt) {
+ case AV_SAMPLE_FMT_S16 :
+ pBuff.SetCount(dwPCMSize / 2);
+ pDataOut = pBuff.GetData();
+
+ for (size_t i = 0; i < pBuff.GetCount(); ++i) {
+ *pDataOut = (float)((int16_t*)m_pFrame->data[0])[i] / INT16_PEAK;
+ pDataOut++;
+ }
+ break;
+
+ case AV_SAMPLE_FMT_S32 :
+ pBuff.SetCount(dwPCMSize / 4);
+ pDataOut = pBuff.GetData();
+
+ for (size_t i = 0; i < pBuff.GetCount(); ++i) {
+ *pDataOut = (float)((int32_t*)m_pFrame->data[0])[i] / INT32_PEAK;
+ pDataOut++;
+ }
+ break;
+ case AV_SAMPLE_FMT_FLT:
+ pBuff.SetCount(dwPCMSize / 4);
+ pDataOut = pBuff.GetData();
+ memcpy(pDataOut, m_pFrame->data[0], dwPCMSize);
+ break;
+ default :
+ ASSERT(FALSE);
+ break;
+ }
+
+ if (pBuff.GetCount() > 0) {
+ hr = Deliver(pBuff, m_pAVCtx->sample_rate, nChannels, dwChannelMask);
+ if (FAILED(hr)) {
+ TRACE(_T("CMpaDecFilter::DeliverFFmpeg() - Deliver failed\n"));
+ goto fail;
+ }
+ }
+
+ }
+ }
+ }
+
+ av_free(tmpProcessBuf);
+ return hr;
fail:
- av_free(tmpProcessBuf);
- return E_FAIL;
+ av_free(tmpProcessBuf);
+ return E_FAIL;
}
bool CMpaDecFilter::InitFFmpeg(enum CodecID nCodecId)
{
- if (nCodecId == CODEC_ID_NONE) {
- return false;
- }
-
- bool bRet = false;
-
- avcodec_register_all();
- av_log_set_callback(LogLibavcodec);
-
- if (m_pAVCodec) {
- ffmpeg_stream_finish();
- }
- switch (nCodecId) {
- case CODEC_ID_MP1 :
- m_pAVCodec = avcodec_find_decoder_by_name("mp1float");
- case CODEC_ID_MP2 :
- m_pAVCodec = avcodec_find_decoder_by_name("mp2float");
- case CODEC_ID_MP3 :
- m_pAVCodec = avcodec_find_decoder_by_name("mp3float");
- default :
- m_pAVCodec = avcodec_find_decoder(nCodecId);
- }
-
- if (m_pAVCodec) {
- DWORD nSamples, nBytesPerSec;
- WORD nChannels, nBitsPerSample, nBlockAlign;
- audioFormatTypeHandler((BYTE *)m_pInput->CurrentMediaType().Format(), m_pInput->CurrentMediaType().FormatType(), &nSamples, &nChannels, &nBitsPerSample, &nBlockAlign, &nBytesPerSec);
-
- if (nCodecId == CODEC_ID_AMR_NB || nCodecId == CODEC_ID_AMR_WB) {
- nChannels = 1;
- nSamples = 8000;
- }
-
- m_pAVCtx = avcodec_alloc_context3(m_pAVCodec);
- CheckPointer(m_pAVCtx, false);
-
- m_pAVCtx->sample_rate = nSamples;
- m_pAVCtx->channels = nChannels;
- m_pAVCtx->bit_rate = nBytesPerSec << 3;
- m_pAVCtx->bits_per_coded_sample = nBitsPerSample;
- m_pAVCtx->block_align = nBlockAlign;
-
- m_pAVCtx->err_recognition = AV_EF_CAREFUL;
- m_pAVCtx->codec_id = nCodecId;
- if (m_pAVCodec->capabilities & CODEC_CAP_TRUNCATED) {
- m_pAVCtx->flags |= CODEC_FLAG_TRUNCATED;
- }
-
- if (nCodecId != CODEC_ID_AAC && nCodecId != CODEC_ID_AAC_LATM) {
- m_pParser = av_parser_init(nCodecId);
- }
-
- const void *format = m_pInput->CurrentMediaType().Format();
- GUID format_type = m_pInput->CurrentMediaType().formattype;
- DWORD formatlen = m_pInput->CurrentMediaType().cbFormat;
- unsigned extralen = 0;
- getExtraData((BYTE *)format, &format_type, formatlen, NULL, &extralen);
-
- memset(&m_raData, 0, sizeof(m_raData));
-
- if (extralen) {
- if (nCodecId == CODEC_ID_COOK || nCodecId == CODEC_ID_ATRAC3 || nCodecId == CODEC_ID_SIPR) {
- uint8_t *extra = (uint8_t *)av_mallocz(extralen + FF_INPUT_BUFFER_PADDING_SIZE);
- getExtraData((BYTE *)format, &format_type, formatlen, extra, NULL);
-
- if (extra[0] == '.' && extra[1] == 'r' && extra[2] == 'a' && extra[3] == 0xfd) {
- HRESULT hr = ParseRealAudioHeader(extra, extralen);
- av_freep(&extra);
- if (FAILED(hr)) {
- return false;
- }
- if (nCodecId == CODEC_ID_SIPR) {
- if (m_raData.flavor > 3) {
- TRACE(_T("CMpaDecFilter::InitFFmpeg() : Invalid SIPR flavor (%d)"), m_raData.flavor);
- return false;
- }
- static BYTE sipr_subpk_size[4] = { 29, 19, 37, 20 };
- m_pAVCtx->block_align = sipr_subpk_size[m_raData.flavor];
- }
- } else {
- // Try without any processing?
- m_pAVCtx->extradata_size = extralen;
- m_pAVCtx->extradata = extra;
- }
- } else {
- m_pAVCtx->extradata_size = extralen;
- m_pAVCtx->extradata = (uint8_t *)av_mallocz(m_pAVCtx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
- getExtraData((BYTE *)format, &format_type, formatlen, (BYTE *)m_pAVCtx->extradata, NULL);
- }
- }
-
- if (avcodec_open2(m_pAVCtx, m_pAVCodec, NULL)>=0) {
- m_pFrame = avcodec_alloc_frame();
- bRet = true;
- }
- }
-
- if (!bRet) {
- ffmpeg_stream_finish();
- }
-
- return bRet;
+ if (nCodecId == CODEC_ID_NONE) {
+ return false;
+ }
+
+ bool bRet = false;
+
+ avcodec_register_all();
+ av_log_set_callback(LogLibavcodec);
+
+ if (m_pAVCodec) {
+ ffmpeg_stream_finish();
+ }
+ switch (nCodecId) {
+ case CODEC_ID_MP1 :
+ m_pAVCodec = avcodec_find_decoder_by_name("mp1float");
+ case CODEC_ID_MP2 :
+ m_pAVCodec = avcodec_find_decoder_by_name("mp2float");
+ case CODEC_ID_MP3 :
+ m_pAVCodec = avcodec_find_decoder_by_name("mp3float");
+ default :
+ m_pAVCodec = avcodec_find_decoder(nCodecId);
+ }
+
+ if (m_pAVCodec) {
+ DWORD nSamples, nBytesPerSec;
+ WORD nChannels, nBitsPerSample, nBlockAlign;
+ audioFormatTypeHandler((BYTE*)m_pInput->CurrentMediaType().Format(), m_pInput->CurrentMediaType().FormatType(), &nSamples, &nChannels, &nBitsPerSample, &nBlockAlign, &nBytesPerSec);
+
+ if (nCodecId == CODEC_ID_AMR_NB || nCodecId == CODEC_ID_AMR_WB) {
+ nChannels = 1;
+ nSamples = 8000;
+ }
+
+ m_pAVCtx = avcodec_alloc_context3(m_pAVCodec);
+ CheckPointer(m_pAVCtx, false);
+
+ m_pAVCtx->sample_rate = nSamples;
+ m_pAVCtx->channels = nChannels;
+ m_pAVCtx->bit_rate = nBytesPerSec << 3;
+ m_pAVCtx->bits_per_coded_sample = nBitsPerSample;
+ m_pAVCtx->block_align = nBlockAlign;
+
+ m_pAVCtx->err_recognition = AV_EF_CAREFUL;
+ m_pAVCtx->codec_id = nCodecId;
+ if (m_pAVCodec->capabilities & CODEC_CAP_TRUNCATED) {
+ m_pAVCtx->flags |= CODEC_FLAG_TRUNCATED;
+ }
+
+ if (nCodecId != CODEC_ID_AAC && nCodecId != CODEC_ID_AAC_LATM) {
+ m_pParser = av_parser_init(nCodecId);
+ }
+
+ const void* format = m_pInput->CurrentMediaType().Format();
+ GUID format_type = m_pInput->CurrentMediaType().formattype;
+ DWORD formatlen = m_pInput->CurrentMediaType().cbFormat;
+ unsigned extralen = 0;
+ getExtraData((BYTE*)format, &format_type, formatlen, NULL, &extralen);
+
+ memset(&m_raData, 0, sizeof(m_raData));
+
+ if (extralen) {
+ if (nCodecId == CODEC_ID_COOK || nCodecId == CODEC_ID_ATRAC3 || nCodecId == CODEC_ID_SIPR) {
+ uint8_t* extra = (uint8_t*)av_mallocz(extralen + FF_INPUT_BUFFER_PADDING_SIZE);
+ getExtraData((BYTE*)format, &format_type, formatlen, extra, NULL);
+
+ if (extra[0] == '.' && extra[1] == 'r' && extra[2] == 'a' && extra[3] == 0xfd) {
+ HRESULT hr = ParseRealAudioHeader(extra, extralen);
+ av_freep(&extra);
+ if (FAILED(hr)) {
+ return false;
+ }
+ if (nCodecId == CODEC_ID_SIPR) {
+ if (m_raData.flavor > 3) {
+ TRACE(_T("CMpaDecFilter::InitFFmpeg() : Invalid SIPR flavor (%d)"), m_raData.flavor);
+ return false;
+ }
+ static BYTE sipr_subpk_size[4] = { 29, 19, 37, 20 };
+ m_pAVCtx->block_align = sipr_subpk_size[m_raData.flavor];
+ }
+ } else {
+ // Try without any processing?
+ m_pAVCtx->extradata_size = extralen;
+ m_pAVCtx->extradata = extra;
+ }
+ } else {
+ m_pAVCtx->extradata_size = extralen;
+ m_pAVCtx->extradata = (uint8_t*)av_mallocz(m_pAVCtx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
+ getExtraData((BYTE*)format, &format_type, formatlen, (BYTE*)m_pAVCtx->extradata, NULL);
+ }
+ }
+
+ if (avcodec_open2(m_pAVCtx, m_pAVCodec, NULL) >= 0) {
+ m_pFrame = avcodec_alloc_frame();
+ bRet = true;
+ }
+ }
+
+ if (!bRet) {
+ ffmpeg_stream_finish();
+ }
+
+ return bRet;
}
-void CMpaDecFilter::LogLibavcodec(void* par,int level,const char *fmt,va_list valist)
+void CMpaDecFilter::LogLibavcodec(void* par, int level, const char* fmt, va_list valist)
{
#if defined(_DEBUG) && 0
- char Msg [500];
- vsnprintf_s (Msg, sizeof(Msg), _TRUNCATE, fmt, valist);
- TRACE("AVLIB : %s", Msg);
+ char Msg [500];
+ vsnprintf_s(Msg, sizeof(Msg), _TRUNCATE, fmt, valist);
+ TRACE("AVLIB : %s", Msg);
#endif
}
void CMpaDecFilter::ffmpeg_stream_finish()
{
- m_pAVCodec = NULL;
- if (m_pAVCtx) {
- if (m_pAVCtx->extradata) {
- av_freep(&m_pAVCtx->extradata);
- }
- if (m_pAVCtx->codec) {
- avcodec_close(m_pAVCtx);
- }
- av_freep(&m_pAVCtx);
- }
-
- if (m_pParser) {
- av_parser_close(m_pParser);
- m_pParser = NULL;
- }
-
- if (m_pFrame) {
- av_freep(&m_pFrame);
- }
-
- if (m_pFFBuffer) {
- av_freep(&m_pFFBuffer);
- }
- m_nFFBufferSize = 0;
+ m_pAVCodec = NULL;
+ if (m_pAVCtx) {
+ if (m_pAVCtx->extradata) {
+ av_freep(&m_pAVCtx->extradata);
+ }
+ if (m_pAVCtx->codec) {
+ avcodec_close(m_pAVCtx);
+ }
+ av_freep(&m_pAVCtx);
+ }
+
+ if (m_pParser) {
+ av_parser_close(m_pParser);
+ m_pParser = NULL;
+ }
+
+ if (m_pFrame) {
+ av_freep(&m_pFrame);
+ }
+
+ if (m_pFFBuffer) {
+ av_freep(&m_pFFBuffer);
+ }
+ m_nFFBufferSize = 0;
}
-HRESULT CMpaDecFilter::ParseRealAudioHeader(const BYTE *extra, const int extralen)
+HRESULT CMpaDecFilter::ParseRealAudioHeader(const BYTE* extra, const int extralen)
{
- const uint8_t *fmt = extra+4;
- uint16_t version = AV_RB16(fmt);
- fmt += 2;
- if (version == 3) {
- TRACE(_T("RealAudio Header version 3 unsupported\n"));
- return VFW_E_UNSUPPORTED_AUDIO;
- } else if (version == 4 || version == 5 && extralen > 50) {
- // main format block
- fmt += 2; // word - unused (always 0)
- fmt += 4; // byte[4] - .ra4/.ra5 signature
- fmt += 4; // dword - unknown
- fmt += 2; // word - Version2
- fmt += 4; // dword - header size
- m_raData.flavor = AV_RB16(fmt); fmt += 2; // word - codec flavor
- m_raData.coded_frame_size = AV_RB32(fmt); fmt += 4; // dword - coded frame size
- fmt += 12; // byte[12] - unknown
- m_raData.sub_packet_h = AV_RB16(fmt); fmt += 2; // word - sub packet h
- fmt += 2; // word - frame size
- m_raData.sub_packet_size = m_pAVCtx->block_align = AV_RB16(fmt); fmt += 2; // word - subpacket size
- fmt += 2; // word - unknown
- // 6 Unknown bytes in ver 5
- if (version == 5) {
- fmt += 6;
- }
- // Audio format block
- fmt += 8;
- // Tag info in v4
- if (version == 4) {
- int len = *fmt++;
- m_raData.deint_id = AV_RB32(fmt); fmt += len;
- len = *fmt++;
- fmt += len;
- } else if (version == 5) {
- m_raData.deint_id = AV_RB32(fmt); fmt += 4;
- fmt += 4;
- }
- fmt += 3;
- if (version == 5) {
- fmt++;
- }
-
- int ra_extralen = AV_RB32(fmt);
- if (ra_extralen > 0) {
- m_pAVCtx->extradata_size = ra_extralen;
- m_pAVCtx->extradata = (uint8_t *)av_mallocz(ra_extralen + FF_INPUT_BUFFER_PADDING_SIZE);
- memcpy((void *)m_pAVCtx->extradata, fmt+4, ra_extralen);
- }
- } else {
- TRACE(_T("Unknown RealAudio Header version: %d\n"), version);
- return VFW_E_UNSUPPORTED_AUDIO;
- }
-
- return S_OK;
+ const uint8_t* fmt = extra + 4;
+ uint16_t version = AV_RB16(fmt);
+ fmt += 2;
+ if (version == 3) {
+ TRACE(_T("RealAudio Header version 3 unsupported\n"));
+ return VFW_E_UNSUPPORTED_AUDIO;
+ } else if (version == 4 || version == 5 && extralen > 50) {
+ // main format block
+ fmt += 2; // word - unused (always 0)
+ fmt += 4; // byte[4] - .ra4/.ra5 signature
+ fmt += 4; // dword - unknown
+ fmt += 2; // word - Version2
+ fmt += 4; // dword - header size
+ m_raData.flavor = AV_RB16(fmt); fmt += 2; // word - codec flavor
+ m_raData.coded_frame_size = AV_RB32(fmt); fmt += 4; // dword - coded frame size
+ fmt += 12; // byte[12] - unknown
+ m_raData.sub_packet_h = AV_RB16(fmt); fmt += 2; // word - sub packet h
+ fmt += 2; // word - frame size
+ m_raData.sub_packet_size = m_pAVCtx->block_align = AV_RB16(fmt); fmt += 2; // word - subpacket size
+ fmt += 2; // word - unknown
+ // 6 Unknown bytes in ver 5
+ if (version == 5) {
+ fmt += 6;
+ }
+ // Audio format block
+ fmt += 8;
+ // Tag info in v4
+ if (version == 4) {
+ int len = *fmt++;
+ m_raData.deint_id = AV_RB32(fmt); fmt += len;
+ len = *fmt++;
+ fmt += len;
+ } else if (version == 5) {
+ m_raData.deint_id = AV_RB32(fmt); fmt += 4;
+ fmt += 4;
+ }
+ fmt += 3;
+ if (version == 5) {
+ fmt++;
+ }
+
+ int ra_extralen = AV_RB32(fmt);
+ if (ra_extralen > 0) {
+ m_pAVCtx->extradata_size = ra_extralen;
+ m_pAVCtx->extradata = (uint8_t*)av_mallocz(ra_extralen + FF_INPUT_BUFFER_PADDING_SIZE);
+ memcpy((void*)m_pAVCtx->extradata, fmt + 4, ra_extralen);
+ }
+ } else {
+ TRACE(_T("Unknown RealAudio Header version: %d\n"), version);
+ return VFW_E_UNSUPPORTED_AUDIO;
+ }
+
+ return S_OK;
}
#pragma endregion
diff --git a/src/filters/transform/MpaDecFilter/MpaDecFilter.h b/src/filters/transform/MpaDecFilter/MpaDecFilter.h
index 1dca25af7..8aaf1deb1 100644
--- a/src/filters/transform/MpaDecFilter/MpaDecFilter.h
+++ b/src/filters/transform/MpaDecFilter/MpaDecFilter.h
@@ -40,15 +40,15 @@
#define MPCAudioDecName L"MPC Audio Decoder"
struct ps2_state_t {
- bool sync;
- double a[2], b[2];
- ps2_state_t() {
- reset();
- }
- void reset() {
- sync = false;
- a[0] = a[1] = b[0] = b[1] = 0;
- }
+ bool sync;
+ double a[2], b[2];
+ ps2_state_t() {
+ reset();
+ }
+ void reset() {
+ sync = false;
+ a[0] = a[1] = b[0] = b[1] = 0;
+ }
};
struct AVCodec;
@@ -57,140 +57,140 @@ struct AVFrame;
struct AVCodecParserContext;
class __declspec(uuid("3D446B6F-71DE-4437-BE15-8CE47174340F"))
- CMpaDecFilter
- : public CTransformFilter
- , public IMpaDecFilter
- , public ISpecifyPropertyPages2
+ CMpaDecFilter
+ : public CTransformFilter
+ , public IMpaDecFilter
+ , public ISpecifyPropertyPages2
{
protected:
- CCritSec m_csReceive;
+ CCritSec m_csReceive;
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_AC3
- a52_state_t* m_a52_state;
+ a52_state_t* m_a52_state;
#endif
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_DTS
- dts_state_t* m_dts_state;
+ dts_state_t* m_dts_state;
#endif
- ps2_state_t m_ps2_state;
+ ps2_state_t m_ps2_state;
- DolbyDigitalMode m_DolbyDigitalMode;
+ DolbyDigitalMode m_DolbyDigitalMode;
#if defined(REGISTER_FILTER) || HAS_FFMPEG_AUDIO_DECODERS
- // === FFMpeg variables
- AVCodec* m_pAVCodec;
- AVCodecContext* m_pAVCtx;
- AVCodecParserContext* m_pParser;
- AVFrame* m_pFrame;
+ // === FFMpeg variables
+ AVCodec* m_pAVCodec;
+ AVCodecContext* m_pAVCtx;
+ AVCodecParserContext* m_pParser;
+ AVFrame* m_pFrame;
#endif
- CAtlArray<BYTE> m_buff;
- REFERENCE_TIME m_rtStart;
- bool m_fDiscontinuity;
+ CAtlArray<BYTE> m_buff;
+ REFERENCE_TIME m_rtStart;
+ bool m_fDiscontinuity;
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_LPCM
- HRESULT ProcessLPCM();
- HRESULT ProcessHdmvLPCM(bool bAlignOldBuffer);
+ HRESULT ProcessLPCM();
+ HRESULT ProcessHdmvLPCM(bool bAlignOldBuffer);
#endif
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_AC3
- HRESULT ProcessAC3();
- HRESULT ProcessA52(BYTE* p, int buffsize, int& size, bool& fEnoughData);
+ HRESULT ProcessAC3();
+ HRESULT ProcessA52(BYTE* p, int buffsize, int& size, bool& fEnoughData);
#endif
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_DTS
- HRESULT ProcessDTS();
+ HRESULT ProcessDTS();
#endif
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_PS2AUDIO
- HRESULT ProcessPS2PCM();
- HRESULT ProcessPS2ADPCM();
+ HRESULT ProcessPS2PCM();
+ HRESULT ProcessPS2ADPCM();
#endif
#if defined(REGISTER_FILTER) || INTERNAL_DECODER_PCM
- HRESULT ProcessPCMraw();
- HRESULT ProcessPCMintBE();
- HRESULT ProcessPCMintLE();
- HRESULT ProcessPCMfloatBE();
- HRESULT ProcessPCMfloatLE();
+ HRESULT ProcessPCMraw();
+ HRESULT ProcessPCMintBE();
+ HRESULT ProcessPCMintLE();
+ HRESULT ProcessPCMfloatBE();
+ HRESULT ProcessPCMfloatLE();
#endif
- HRESULT GetDeliveryBuffer(IMediaSample** pSample, BYTE** pData);
- HRESULT Deliver(CAtlArray<float>& pBuff, DWORD nSamplesPerSec, WORD nChannels, DWORD dwChannelMask = 0);
- HRESULT DeliverBitstream(BYTE* pBuff, int size, int sample_rate, int frame_length, BYTE type);
- HRESULT ReconnectOutput(int nSamples, CMediaType& mt);
- CMediaType CreateMediaType(MPCSampleFormat sf, DWORD nSamplesPerSec, WORD nChannels, DWORD dwChannelMask = 0);
- CMediaType CreateMediaTypeSPDIF(DWORD nSamplesPerSec = 48000);
+ HRESULT GetDeliveryBuffer(IMediaSample** pSample, BYTE** pData);
+ HRESULT Deliver(CAtlArray<float>& pBuff, DWORD nSamplesPerSec, WORD nChannels, DWORD dwChannelMask = 0);
+ HRESULT DeliverBitstream(BYTE* pBuff, int size, int sample_rate, int frame_length, BYTE type);
+ HRESULT ReconnectOutput(int nSamples, CMediaType& mt);
+ CMediaType CreateMediaType(MPCSampleFormat sf, DWORD nSamplesPerSec, WORD nChannels, DWORD dwChannelMask = 0);
+ CMediaType CreateMediaTypeSPDIF(DWORD nSamplesPerSec = 48000);
#if defined(REGISTER_FILTER) || HAS_FFMPEG_AUDIO_DECODERS
- bool InitFFmpeg(enum CodecID nCodecId);
- void ffmpeg_stream_finish();
- HRESULT DeliverFFmpeg(enum CodecID nCodecId, BYTE* p, int samples, int& size);
- HRESULT ProcessFFmpeg(enum CodecID nCodecId);
- static void LogLibavcodec(void* par,int level,const char *fmt,va_list valist);
-
- BYTE* m_pFFBuffer;
- int m_nFFBufferSize;
-
- enum CodecID FindCodec(const GUID subtype);
-
- struct {
- int flavor;
- int coded_frame_size;
- int sub_packet_h;
- int sub_packet_size;
- unsigned int deint_id;
- } m_raData;
-
- HRESULT ParseRealAudioHeader(const BYTE *extra, const int extralen);
+ bool InitFFmpeg(enum CodecID nCodecId);
+ void ffmpeg_stream_finish();
+ HRESULT DeliverFFmpeg(enum CodecID nCodecId, BYTE* p, int samples, int& size);
+ HRESULT ProcessFFmpeg(enum CodecID nCodecId);
+ static void LogLibavcodec(void* par, int level, const char* fmt, va_list valist);
+
+ BYTE* m_pFFBuffer;
+ int m_nFFBufferSize;
+
+ enum CodecID FindCodec(const GUID subtype);
+
+ struct {
+ int flavor;
+ int coded_frame_size;
+ int sub_packet_h;
+ int sub_packet_size;
+ unsigned int deint_id;
+ } m_raData;
+
+ HRESULT ParseRealAudioHeader(const BYTE* extra, const int extralen);
#endif
protected:
- CCritSec m_csProps;
- MPCSampleFormat m_iSampleFormat;
- int m_iSpeakerConfig[etlast];
- bool m_fDynamicRangeControl[etlast];
+ CCritSec m_csProps;
+ MPCSampleFormat m_iSampleFormat;
+ int m_iSpeakerConfig[etlast];
+ bool m_fDynamicRangeControl[etlast];
- bool m_bResync;
+ bool m_bResync;
public:
- CMpaDecFilter(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CMpaDecFilter();
+ CMpaDecFilter(LPUNKNOWN lpunk, HRESULT* phr);
+ virtual ~CMpaDecFilter();
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- HRESULT EndOfStream();
- HRESULT BeginFlush();
- HRESULT EndFlush();
- HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
- HRESULT Receive(IMediaSample* pIn);
+ HRESULT EndOfStream();
+ HRESULT BeginFlush();
+ HRESULT EndFlush();
+ HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ HRESULT Receive(IMediaSample* pIn);
- HRESULT CheckInputType(const CMediaType* mtIn);
- HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
- HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT GetMediaType(int iPosition, CMediaType* pMediaType);
+ HRESULT CheckInputType(const CMediaType* mtIn);
+ HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
+ HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT GetMediaType(int iPosition, CMediaType* pMediaType);
- HRESULT StartStreaming();
- HRESULT StopStreaming();
+ HRESULT StartStreaming();
+ HRESULT StopStreaming();
- HRESULT SetMediaType(PIN_DIRECTION dir, const CMediaType *pmt);
+ HRESULT SetMediaType(PIN_DIRECTION dir, const CMediaType* pmt);
- // ISpecifyPropertyPages2
+ // ISpecifyPropertyPages2
- STDMETHODIMP GetPages(CAUUID* pPages);
- STDMETHODIMP CreatePage(const GUID& guid, IPropertyPage** ppPage);
+ STDMETHODIMP GetPages(CAUUID* pPages);
+ STDMETHODIMP CreatePage(const GUID& guid, IPropertyPage** ppPage);
- // IMpaDecFilter
+ // IMpaDecFilter
- STDMETHODIMP SetSampleFormat(MPCSampleFormat sf);
- STDMETHODIMP_(MPCSampleFormat) GetSampleFormat();
- STDMETHODIMP SetSpeakerConfig(enctype et, int sc);
- STDMETHODIMP_(int) GetSpeakerConfig(enctype et);
- STDMETHODIMP SetDynamicRangeControl(enctype et, bool fDRC);
- STDMETHODIMP_(bool) GetDynamicRangeControl(enctype et);
- STDMETHODIMP_(DolbyDigitalMode) GetDolbyDigitalMode();
+ STDMETHODIMP SetSampleFormat(MPCSampleFormat sf);
+ STDMETHODIMP_(MPCSampleFormat) GetSampleFormat();
+ STDMETHODIMP SetSpeakerConfig(enctype et, int sc);
+ STDMETHODIMP_(int) GetSpeakerConfig(enctype et);
+ STDMETHODIMP SetDynamicRangeControl(enctype et, bool fDRC);
+ STDMETHODIMP_(bool) GetDynamicRangeControl(enctype et);
+ STDMETHODIMP_(DolbyDigitalMode) GetDolbyDigitalMode();
- STDMETHODIMP SaveSettings();
+ STDMETHODIMP SaveSettings();
};
class CMpaDecInputPin : public CDeCSSInputPin
{
public:
- CMpaDecInputPin(CTransformFilter* pFilter, HRESULT* phr, LPWSTR pName);
+ CMpaDecInputPin(CTransformFilter* pFilter, HRESULT* phr, LPWSTR pName);
};
diff --git a/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.cpp b/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.cpp
index 9273c9d85..243a7759b 100644
--- a/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.cpp
+++ b/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.cpp
@@ -38,207 +38,207 @@ static TCHAR m_strDecodeToSpeaker[50];
CMpaDecSettingsWnd::CMpaDecSettingsWnd()
{
- wcscpy_s(m_strDecodeToSpeaker, ResStr(IDS_MPADECSETTINGSWND_5));
+ wcscpy_s(m_strDecodeToSpeaker, ResStr(IDS_MPADECSETTINGSWND_5));
}
bool CMpaDecSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
{
- ASSERT(!m_pMDF);
+ ASSERT(!m_pMDF);
- m_pMDF.Release();
+ m_pMDF.Release();
- POSITION pos = pUnks.GetHeadPosition();
- while (pos && !(m_pMDF = pUnks.GetNext(pos))) {
- ;
- }
+ POSITION pos = pUnks.GetHeadPosition();
+ while (pos && !(m_pMDF = pUnks.GetNext(pos))) {
+ ;
+ }
- if (!m_pMDF) {
- return false;
- }
+ if (!m_pMDF) {
+ return false;
+ }
- m_outputformat = m_pMDF->GetSampleFormat();
- m_ac3spkcfg = m_pMDF->GetSpeakerConfig(IMpaDecFilter::ac3);
- m_ac3drc = m_pMDF->GetDynamicRangeControl(IMpaDecFilter::ac3);
- m_dtsspkcfg = m_pMDF->GetSpeakerConfig(IMpaDecFilter::dts);
- m_dtsdrc = m_pMDF->GetDynamicRangeControl(IMpaDecFilter::dts);
- m_ddmode = m_pMDF->GetDolbyDigitalMode();
+ m_outputformat = m_pMDF->GetSampleFormat();
+ m_ac3spkcfg = m_pMDF->GetSpeakerConfig(IMpaDecFilter::ac3);
+ m_ac3drc = m_pMDF->GetDynamicRangeControl(IMpaDecFilter::ac3);
+ m_dtsspkcfg = m_pMDF->GetSpeakerConfig(IMpaDecFilter::dts);
+ m_dtsdrc = m_pMDF->GetDynamicRangeControl(IMpaDecFilter::dts);
+ m_ddmode = m_pMDF->GetDolbyDigitalMode();
- return true;
+ return true;
}
void CMpaDecSettingsWnd::OnDisconnect()
{
- m_pMDF.Release();
+ m_pMDF.Release();
}
-LPCTSTR CMpaDecSettingsWnd::GetDolbyMode (DolbyDigitalMode ddmode)
+LPCTSTR CMpaDecSettingsWnd::GetDolbyMode(DolbyDigitalMode ddmode)
{
- switch (ddmode) {
- case DD_AC3 :
- return _T(" (AC3)");
- case DD_EAC3 :
- return _T(" (Dolby Digital Plus)");
- case DD_TRUEHD :
- return _T(" (Dolby True HD)");
- case DD_MLP :
- return _T(" (MLP)");
- default :
- return _T("");
- }
+ switch (ddmode) {
+ case DD_AC3 :
+ return _T(" (AC3)");
+ case DD_EAC3 :
+ return _T(" (Dolby Digital Plus)");
+ case DD_TRUEHD :
+ return _T(" (Dolby True HD)");
+ case DD_MLP :
+ return _T(" (MLP)");
+ default :
+ return _T("");
+ }
}
bool CMpaDecSettingsWnd::OnActivate()
{
- DWORD dwStyle = WS_VISIBLE|WS_CHILD|WS_TABSTOP;
+ DWORD dwStyle = WS_VISIBLE | WS_CHILD | WS_TABSTOP;
- CRect r;
+ CRect r;
- CPoint p(10, 10);
+ CPoint p(10, 10);
- m_outputformat_static.Create(ResStr(IDS_MPADECSETTINGSWND_0), dwStyle, CRect(p, CSize(120, m_fontheight)), this);
+ m_outputformat_static.Create(ResStr(IDS_MPADECSETTINGSWND_0), dwStyle, CRect(p, CSize(120, m_fontheight)), this);
- p.y += m_fontheight + 5;
+ p.y += m_fontheight + 5;
- m_outputformat_combo.Create(dwStyle|CBS_DROPDOWNLIST, CRect(p + CSize(10, 0), CSize(100, 200)), this, IDC_PP_COMBO1);
- m_outputformat_combo.SetItemData(m_outputformat_combo.AddString(_T("PCM 16 Bit")), SF_PCM16);
- m_outputformat_combo.SetItemData(m_outputformat_combo.AddString(_T("PCM 24 Bit")), SF_PCM24);
- m_outputformat_combo.SetItemData(m_outputformat_combo.AddString(_T("PCM 32 Bit")), SF_PCM32);
- m_outputformat_combo.SetItemData(m_outputformat_combo.AddString(_T("IEEE Float")), SF_FLOAT32);
- m_outputformat_combo.SetCurSel(0);
+ m_outputformat_combo.Create(dwStyle | CBS_DROPDOWNLIST, CRect(p + CSize(10, 0), CSize(100, 200)), this, IDC_PP_COMBO1);
+ m_outputformat_combo.SetItemData(m_outputformat_combo.AddString(_T("PCM 16 Bit")), SF_PCM16);
+ m_outputformat_combo.SetItemData(m_outputformat_combo.AddString(_T("PCM 24 Bit")), SF_PCM24);
+ m_outputformat_combo.SetItemData(m_outputformat_combo.AddString(_T("PCM 32 Bit")), SF_PCM32);
+ m_outputformat_combo.SetItemData(m_outputformat_combo.AddString(_T("IEEE Float")), SF_FLOAT32);
+ m_outputformat_combo.SetCurSel(0);
- for (int i = 0; i < m_outputformat_combo.GetCount(); i++)
- if ((int)m_outputformat_combo.GetItemData(i) == m_outputformat) {
- m_outputformat_combo.SetCurSel(i);
- }
+ for (int i = 0; i < m_outputformat_combo.GetCount(); i++)
+ if ((int)m_outputformat_combo.GetItemData(i) == m_outputformat) {
+ m_outputformat_combo.SetCurSel(i);
+ }
- p.y += 30;
+ p.y += 30;
- CString strSpeak;
- strSpeak.Format (_T("%s%s"), ResStr(IDS_MPADECSETTINGSWND_1), GetDolbyMode(m_ddmode));
- m_ac3spkcfg_static.Create(ResStr(IDS_MPADECSETTINGSWND_1) + GetDolbyMode(m_ddmode), dwStyle, CRect(p, CSize(220, m_fontheight)), this);
+ CString strSpeak;
+ strSpeak.Format(_T("%s%s"), ResStr(IDS_MPADECSETTINGSWND_1), GetDolbyMode(m_ddmode));
+ m_ac3spkcfg_static.Create(ResStr(IDS_MPADECSETTINGSWND_1) + GetDolbyMode(m_ddmode), dwStyle, CRect(p, CSize(220, m_fontheight)), this);
- p.y += m_fontheight + 5;
+ p.y += m_fontheight + 5;
- m_ac3spkcfg_combo.Create(dwStyle|CBS_DROPDOWNLIST, CRect(p + CSize(150, 0), CSize(100, 200)), this, IDC_PP_COMBO2);
- m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(_T("Mono")), A52_MONO);
- m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(_T("Dual Mono")), A52_CHANNEL);
- m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(_T("Stereo")), A52_STEREO);
- m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(_T("Dolby Stereo")), A52_DOLBY);
- m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(ResStr(IDS_MPA_3F)), A52_3F);
- m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(ResStr(IDS_MPA_2F_1R)), A52_2F1R);
- m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(ResStr(IDS_MPA_3F_1R)), A52_3F1R);
- m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(ResStr(IDS_MPA_2F_2R)), A52_2F2R);
- m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(ResStr(IDS_MPA_3F_2R)), A52_3F2R);
- m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(ResStr(IDS_MPA_CHANNEL_1)), A52_CHANNEL1);
- m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(ResStr(IDS_MPA_CHANNEL_2)), A52_CHANNEL2);
+ m_ac3spkcfg_combo.Create(dwStyle | CBS_DROPDOWNLIST, CRect(p + CSize(150, 0), CSize(100, 200)), this, IDC_PP_COMBO2);
+ m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(_T("Mono")), A52_MONO);
+ m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(_T("Dual Mono")), A52_CHANNEL);
+ m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(_T("Stereo")), A52_STEREO);
+ m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(_T("Dolby Stereo")), A52_DOLBY);
+ m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(ResStr(IDS_MPA_3F)), A52_3F);
+ m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(ResStr(IDS_MPA_2F_1R)), A52_2F1R);
+ m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(ResStr(IDS_MPA_3F_1R)), A52_3F1R);
+ m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(ResStr(IDS_MPA_2F_2R)), A52_2F2R);
+ m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(ResStr(IDS_MPA_3F_2R)), A52_3F2R);
+ m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(ResStr(IDS_MPA_CHANNEL_1)), A52_CHANNEL1);
+ m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(ResStr(IDS_MPA_CHANNEL_2)), A52_CHANNEL2);
- for (int i = 0, sel = abs(m_ac3spkcfg) & A52_CHANNEL_MASK; i < m_ac3spkcfg_combo.GetCount(); i++)
- if ((int)m_ac3spkcfg_combo.GetItemData(i) == sel) {
- m_ac3spkcfg_combo.SetCurSel(i);
- }
+ for (int i = 0, sel = abs(m_ac3spkcfg) & A52_CHANNEL_MASK; i < m_ac3spkcfg_combo.GetCount(); i++)
+ if ((int)m_ac3spkcfg_combo.GetItemData(i) == sel) {
+ m_ac3spkcfg_combo.SetCurSel(i);
+ }
- m_ac3spkcfg_combo.GetWindowRect(r);
- ScreenToClient(r);
+ m_ac3spkcfg_combo.GetWindowRect(r);
+ ScreenToClient(r);
- m_ac3lfe_check.Create(_T("LFE"), dwStyle|BS_AUTOCHECKBOX, CRect(CPoint(r.left, r.bottom + 3), CSize(50, m_fontheight)), this, IDC_PP_CHECK4);
- m_ac3lfe_check.SetCheck(!!(abs(m_ac3spkcfg) & A52_LFE));
+ m_ac3lfe_check.Create(_T("LFE"), dwStyle | BS_AUTOCHECKBOX, CRect(CPoint(r.left, r.bottom + 3), CSize(50, m_fontheight)), this, IDC_PP_CHECK4);
+ m_ac3lfe_check.SetCheck(!!(abs(m_ac3spkcfg) & A52_LFE));
- for (int i = 0, h = max(20, m_fontheight)+1; i < _countof(m_ac3spkcfg_radio); i++, p.y += h) {
- static const TCHAR* labels[] = {m_strDecodeToSpeaker, _T("SPDIF")};
- m_ac3spkcfg_radio[i].Create(labels[i], dwStyle|BS_AUTORADIOBUTTON|(i == 0 ? WS_GROUP : 0), CRect(p + CPoint(10, 0), CSize(140, h)), this, IDC_PP_RADIO1+i);
- }
+ for (int i = 0, h = max(20, m_fontheight) + 1; i < _countof(m_ac3spkcfg_radio); i++, p.y += h) {
+ static const TCHAR* labels[] = {m_strDecodeToSpeaker, _T("SPDIF")};
+ m_ac3spkcfg_radio[i].Create(labels[i], dwStyle | BS_AUTORADIOBUTTON | (i == 0 ? WS_GROUP : 0), CRect(p + CPoint(10, 0), CSize(140, h)), this, IDC_PP_RADIO1 + i);
+ }
- CheckRadioButton(IDC_PP_RADIO1, IDC_PP_RADIO2, m_ac3spkcfg >= 0 ? IDC_PP_RADIO1 : IDC_PP_RADIO2);
+ CheckRadioButton(IDC_PP_RADIO1, IDC_PP_RADIO2, m_ac3spkcfg >= 0 ? IDC_PP_RADIO1 : IDC_PP_RADIO2);
- p.y += 5;
+ p.y += 5;
- m_ac3spkcfg_check.Create(ResStr(IDS_MPA_DYNRANGE), dwStyle|BS_AUTOCHECKBOX, CRect(p + CPoint(10, 0), CSize(205, m_fontheight)), this, IDC_PP_CHECK1);
- m_ac3spkcfg_check.SetCheck(m_ac3drc);
+ m_ac3spkcfg_check.Create(ResStr(IDS_MPA_DYNRANGE), dwStyle | BS_AUTOCHECKBOX, CRect(p + CPoint(10, 0), CSize(205, m_fontheight)), this, IDC_PP_CHECK1);
+ m_ac3spkcfg_check.SetCheck(m_ac3drc);
- p.y += m_fontheight + 10;
+ p.y += m_fontheight + 10;
- m_dtsspkcfg_static.Create(ResStr(IDS_MPADECSETTINGSWND_7), dwStyle, CRect(p, CSize(120, m_fontheight)), this);
+ m_dtsspkcfg_static.Create(ResStr(IDS_MPADECSETTINGSWND_7), dwStyle, CRect(p, CSize(120, m_fontheight)), this);
- p.y += m_fontheight + 5;
+ p.y += m_fontheight + 5;
- m_dtsspkcfg_combo.Create(dwStyle|CBS_DROPDOWNLIST, CRect(p + CSize(150, 0), CSize(100, 200)), this, IDC_PP_COMBO3);
- m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(_T("Mono")), DTS_MONO);
- m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(_T("Dual Mono")), DTS_CHANNEL);
- m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(_T("Stereo")), DTS_STEREO);
- //m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(_T("Stereo ..")), DTS_STEREO_SUMDIFF);
- //m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(_T("Stereo ..")), DTS_STEREO_TOTAL);
- m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(ResStr(IDS_MPA_3F)), DTS_3F);
- m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(ResStr(IDS_MPA_2F_1R)), DTS_2F1R);
- m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(ResStr(IDS_MPA_3F_1R)), DTS_3F1R);
- m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(ResStr(IDS_MPA_2F_2R)), DTS_2F2R);
- m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(ResStr(IDS_MPA_3F_2R)), DTS_3F2R);
+ m_dtsspkcfg_combo.Create(dwStyle | CBS_DROPDOWNLIST, CRect(p + CSize(150, 0), CSize(100, 200)), this, IDC_PP_COMBO3);
+ m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(_T("Mono")), DTS_MONO);
+ m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(_T("Dual Mono")), DTS_CHANNEL);
+ m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(_T("Stereo")), DTS_STEREO);
+ //m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(_T("Stereo ..")), DTS_STEREO_SUMDIFF);
+ //m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(_T("Stereo ..")), DTS_STEREO_TOTAL);
+ m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(ResStr(IDS_MPA_3F)), DTS_3F);
+ m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(ResStr(IDS_MPA_2F_1R)), DTS_2F1R);
+ m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(ResStr(IDS_MPA_3F_1R)), DTS_3F1R);
+ m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(ResStr(IDS_MPA_2F_2R)), DTS_2F2R);
+ m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(ResStr(IDS_MPA_3F_2R)), DTS_3F2R);
- for (int i = 0, sel = abs(m_dtsspkcfg) & DTS_CHANNEL_MASK; i < m_dtsspkcfg_combo.GetCount(); i++)
- if ((int)m_dtsspkcfg_combo.GetItemData(i) == sel) {
- m_dtsspkcfg_combo.SetCurSel(i);
- }
+ for (int i = 0, sel = abs(m_dtsspkcfg) & DTS_CHANNEL_MASK; i < m_dtsspkcfg_combo.GetCount(); i++)
+ if ((int)m_dtsspkcfg_combo.GetItemData(i) == sel) {
+ m_dtsspkcfg_combo.SetCurSel(i);
+ }
- m_dtsspkcfg_combo.GetWindowRect(r);
- ScreenToClient(r);
+ m_dtsspkcfg_combo.GetWindowRect(r);
+ ScreenToClient(r);
- m_dtslfe_check.Create(_T("LFE"), dwStyle|BS_AUTOCHECKBOX, CRect(CPoint(r.left, r.bottom + 3), CSize(50, m_fontheight)), this, IDC_PP_CHECK5);
- m_dtslfe_check.SetCheck(!!(abs(m_dtsspkcfg) & DTS_LFE));
+ m_dtslfe_check.Create(_T("LFE"), dwStyle | BS_AUTOCHECKBOX, CRect(CPoint(r.left, r.bottom + 3), CSize(50, m_fontheight)), this, IDC_PP_CHECK5);
+ m_dtslfe_check.SetCheck(!!(abs(m_dtsspkcfg) & DTS_LFE));
- for (int i = 0, h = max(20, m_fontheight)+1; i < _countof(m_dtsspkcfg_radio); i++, p.y += h) {
- static const TCHAR* labels[] = {m_strDecodeToSpeaker, _T("SPDIF")};
- m_dtsspkcfg_radio[i].Create(labels[i], dwStyle|BS_AUTORADIOBUTTON|(i == 0 ? WS_GROUP : 0), CRect(p + CPoint(10, 0), CSize(140, h)), this, IDC_PP_RADIO3+i);
- }
+ for (int i = 0, h = max(20, m_fontheight) + 1; i < _countof(m_dtsspkcfg_radio); i++, p.y += h) {
+ static const TCHAR* labels[] = {m_strDecodeToSpeaker, _T("SPDIF")};
+ m_dtsspkcfg_radio[i].Create(labels[i], dwStyle | BS_AUTORADIOBUTTON | (i == 0 ? WS_GROUP : 0), CRect(p + CPoint(10, 0), CSize(140, h)), this, IDC_PP_RADIO3 + i);
+ }
- CheckRadioButton(IDC_PP_RADIO3, IDC_PP_RADIO4, m_dtsspkcfg >= 0 ? IDC_PP_RADIO3 : IDC_PP_RADIO4);
+ CheckRadioButton(IDC_PP_RADIO3, IDC_PP_RADIO4, m_dtsspkcfg >= 0 ? IDC_PP_RADIO3 : IDC_PP_RADIO4);
- p.y += 5;
+ p.y += 5;
- m_dtsspkcfg_check.Create(ResStr(IDS_MPA_DYNRANGE), dwStyle|WS_DISABLED|BS_AUTOCHECKBOX, CRect(p + CPoint(10, 0), CSize(205, m_fontheight)), this, IDC_PP_CHECK2);
- m_dtsspkcfg_check.SetCheck(m_dtsdrc);
+ m_dtsspkcfg_check.Create(ResStr(IDS_MPA_DYNRANGE), dwStyle | WS_DISABLED | BS_AUTOCHECKBOX, CRect(p + CPoint(10, 0), CSize(205, m_fontheight)), this, IDC_PP_CHECK2);
+ m_dtsspkcfg_check.SetCheck(m_dtsdrc);
- for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
- pWnd->SetFont(&m_font, FALSE);
- }
+ for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
+ pWnd->SetFont(&m_font, FALSE);
+ }
- return true;
+ return true;
}
void CMpaDecSettingsWnd::OnDeactivate()
{
- m_outputformat = (int)m_outputformat_combo.GetItemData(m_outputformat_combo.GetCurSel());
- m_ac3spkcfg = (int)m_ac3spkcfg_combo.GetItemData(m_ac3spkcfg_combo.GetCurSel());
- if (!!m_ac3lfe_check.GetCheck()) {
- m_ac3spkcfg |= A52_LFE;
- }
- if (IsDlgButtonChecked(IDC_PP_RADIO2)) {
- m_ac3spkcfg = -m_ac3spkcfg;
- }
- m_ac3drc = !!m_ac3spkcfg_check.GetCheck();
- m_dtsspkcfg = (int)m_dtsspkcfg_combo.GetItemData(m_dtsspkcfg_combo.GetCurSel());
- if (!!m_dtslfe_check.GetCheck()) {
- m_dtsspkcfg |= DTS_LFE;
- }
- if (IsDlgButtonChecked(IDC_PP_RADIO4)) {
- m_dtsspkcfg = -m_dtsspkcfg;
- }
- m_dtsdrc = !!m_dtsspkcfg_check.GetCheck();
+ m_outputformat = (int)m_outputformat_combo.GetItemData(m_outputformat_combo.GetCurSel());
+ m_ac3spkcfg = (int)m_ac3spkcfg_combo.GetItemData(m_ac3spkcfg_combo.GetCurSel());
+ if (!!m_ac3lfe_check.GetCheck()) {
+ m_ac3spkcfg |= A52_LFE;
+ }
+ if (IsDlgButtonChecked(IDC_PP_RADIO2)) {
+ m_ac3spkcfg = -m_ac3spkcfg;
+ }
+ m_ac3drc = !!m_ac3spkcfg_check.GetCheck();
+ m_dtsspkcfg = (int)m_dtsspkcfg_combo.GetItemData(m_dtsspkcfg_combo.GetCurSel());
+ if (!!m_dtslfe_check.GetCheck()) {
+ m_dtsspkcfg |= DTS_LFE;
+ }
+ if (IsDlgButtonChecked(IDC_PP_RADIO4)) {
+ m_dtsspkcfg = -m_dtsspkcfg;
+ }
+ m_dtsdrc = !!m_dtsspkcfg_check.GetCheck();
}
bool CMpaDecSettingsWnd::OnApply()
{
- OnDeactivate();
+ OnDeactivate();
- if (m_pMDF) {
- m_pMDF->SetSampleFormat((MPCSampleFormat)m_outputformat);
- m_pMDF->SetSpeakerConfig(IMpaDecFilter::ac3, m_ac3spkcfg);
- m_pMDF->SetDynamicRangeControl(IMpaDecFilter::ac3, m_ac3drc);
- m_pMDF->SetSpeakerConfig(IMpaDecFilter::dts, m_dtsspkcfg);
- m_pMDF->SetDynamicRangeControl(IMpaDecFilter::dts, m_dtsdrc);
+ if (m_pMDF) {
+ m_pMDF->SetSampleFormat((MPCSampleFormat)m_outputformat);
+ m_pMDF->SetSpeakerConfig(IMpaDecFilter::ac3, m_ac3spkcfg);
+ m_pMDF->SetDynamicRangeControl(IMpaDecFilter::ac3, m_ac3drc);
+ m_pMDF->SetSpeakerConfig(IMpaDecFilter::dts, m_dtsspkcfg);
+ m_pMDF->SetDynamicRangeControl(IMpaDecFilter::dts, m_dtsdrc);
- m_pMDF->SaveSettings();
- }
+ m_pMDF->SaveSettings();
+ }
- return true;
+ return true;
}
BEGIN_MESSAGE_MAP(CMpaDecSettingsWnd, CInternalPropertyPageWnd)
diff --git a/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.h b/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.h
index 95263852b..87443f49c 100644
--- a/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.h
+++ b/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.h
@@ -28,60 +28,60 @@
#include <afxcmn.h>
class __declspec(uuid("24103041-884B-4772-B0D3-A600E7CBFEC7"))
- CMpaDecSettingsWnd : public CInternalPropertyPageWnd
+ CMpaDecSettingsWnd : public CInternalPropertyPageWnd
{
- CComQIPtr<IMpaDecFilter> m_pMDF;
+ CComQIPtr<IMpaDecFilter> m_pMDF;
- int m_outputformat;
- int m_ac3spkcfg;
- bool m_ac3drc;
- int m_dtsspkcfg;
- bool m_dtsdrc;
- DolbyDigitalMode m_ddmode;
+ int m_outputformat;
+ int m_ac3spkcfg;
+ bool m_ac3drc;
+ int m_dtsspkcfg;
+ bool m_dtsdrc;
+ DolbyDigitalMode m_ddmode;
- enum {
- IDC_PP_RADIO1 = 10000,
- IDC_PP_RADIO2,
- IDC_PP_RADIO3,
- IDC_PP_RADIO4,
- IDC_PP_COMBO1,
- IDC_PP_COMBO2,
- IDC_PP_COMBO3,
- IDC_PP_CHECK1,
- IDC_PP_CHECK2,
- IDC_PP_CHECK4,
- IDC_PP_CHECK5
- };
+ enum {
+ IDC_PP_RADIO1 = 10000,
+ IDC_PP_RADIO2,
+ IDC_PP_RADIO3,
+ IDC_PP_RADIO4,
+ IDC_PP_COMBO1,
+ IDC_PP_COMBO2,
+ IDC_PP_COMBO3,
+ IDC_PP_CHECK1,
+ IDC_PP_CHECK2,
+ IDC_PP_CHECK4,
+ IDC_PP_CHECK5
+ };
- CStatic m_outputformat_static;
- CComboBox m_outputformat_combo;
- CStatic m_ac3spkcfg_static;
- CButton m_ac3spkcfg_radio[2];
- CComboBox m_ac3spkcfg_combo;
- CButton m_ac3spkcfg_check;
- CButton m_ac3lfe_check;
- CStatic m_dtsspkcfg_static;
- CButton m_dtsspkcfg_radio[2];
- CComboBox m_dtsspkcfg_combo;
- CButton m_dtsspkcfg_check;
- CButton m_dtslfe_check;
+ CStatic m_outputformat_static;
+ CComboBox m_outputformat_combo;
+ CStatic m_ac3spkcfg_static;
+ CButton m_ac3spkcfg_radio[2];
+ CComboBox m_ac3spkcfg_combo;
+ CButton m_ac3spkcfg_check;
+ CButton m_ac3lfe_check;
+ CStatic m_dtsspkcfg_static;
+ CButton m_dtsspkcfg_radio[2];
+ CComboBox m_dtsspkcfg_combo;
+ CButton m_dtsspkcfg_check;
+ CButton m_dtslfe_check;
public:
- CMpaDecSettingsWnd();
+ CMpaDecSettingsWnd();
- bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
- void OnDisconnect();
- bool OnActivate();
- void OnDeactivate();
- bool OnApply();
- LPCTSTR GetDolbyMode (DolbyDigitalMode ddmode);
+ bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
+ void OnDisconnect();
+ bool OnActivate();
+ void OnDeactivate();
+ bool OnApply();
+ LPCTSTR GetDolbyMode(DolbyDigitalMode ddmode);
- static LPCTSTR GetWindowTitle() {
- return _T("Settings");
- }
- static CSize GetWindowSize() {
- return CSize(320, 305);
- }
+ static LPCTSTR GetWindowTitle() {
+ return _T("Settings");
+ }
+ static CSize GetWindowSize() {
+ return CSize(320, 305);
+ }
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
}; \ No newline at end of file
diff --git a/src/filters/transform/Mpeg2DecFilter/IMpeg2DecFilter.h b/src/filters/transform/Mpeg2DecFilter/IMpeg2DecFilter.h
index 00a1d4fcc..a7d23fc65 100644
--- a/src/filters/transform/Mpeg2DecFilter/IMpeg2DecFilter.h
+++ b/src/filters/transform/Mpeg2DecFilter/IMpeg2DecFilter.h
@@ -28,33 +28,33 @@ typedef enum {DIAuto, DIWeave, DIBlend, DIBob, DIFieldShift, DIELA} ditype;
interface __declspec(uuid("0ABEAA65-0317-47B9-AE1D-D9EA905AFD25"))
IMpeg2DecFilter :
public IUnknown {
- STDMETHOD(SetDeinterlaceMethod(ditype di)) = 0;
- STDMETHOD_(ditype, GetDeinterlaceMethod()) = 0;
- // Brightness: -255.0 to 255.0, default 0.0
- // Contrast: 0.0 to 10.0, default 1.0
- // Hue: -180.0 to +180.0, default 0.0
- // Saturation: 0.0 to 10.0, default 1.0
-
- STDMETHOD(SetBrightness(float brightness)) = 0;
- STDMETHOD(SetContrast(float contrast)) = 0;
- STDMETHOD(SetHue(float hue)) = 0;
- STDMETHOD(SetSaturation(float saturation)) = 0;
- STDMETHOD_(float, GetBrightness()) = 0;
- STDMETHOD_(float, GetContrast()) = 0;
- STDMETHOD_(float, GetHue()) = 0;
- STDMETHOD_(float, GetSaturation()) = 0;
-
- STDMETHOD(EnableForcedSubtitles(bool fEnable)) = 0;
- STDMETHOD_(bool, IsForcedSubtitlesEnabled()) = 0;
-
- STDMETHOD(EnablePlanarYUV(bool fEnable)) = 0;
- STDMETHOD_(bool, IsPlanarYUVEnabled()) = 0;
-
- STDMETHOD(EnableInterlaced(bool fEnable)) = 0;
- STDMETHOD_(bool, IsInterlacedEnabled()) = 0;
-
- STDMETHOD(EnableReadARFromStream(bool fEnable)) = 0;
- STDMETHOD_(bool, IsReadARFromStreamEnabled()) = 0;
-
- STDMETHOD(Apply()) = 0;
+ STDMETHOD(SetDeinterlaceMethod(ditype di)) = 0;
+ STDMETHOD_(ditype, GetDeinterlaceMethod()) = 0;
+ // Brightness: -255.0 to 255.0, default 0.0
+ // Contrast: 0.0 to 10.0, default 1.0
+ // Hue: -180.0 to +180.0, default 0.0
+ // Saturation: 0.0 to 10.0, default 1.0
+
+ STDMETHOD(SetBrightness(float brightness)) = 0;
+ STDMETHOD(SetContrast(float contrast)) = 0;
+ STDMETHOD(SetHue(float hue)) = 0;
+ STDMETHOD(SetSaturation(float saturation)) = 0;
+ STDMETHOD_(float, GetBrightness()) = 0;
+ STDMETHOD_(float, GetContrast()) = 0;
+ STDMETHOD_(float, GetHue()) = 0;
+ STDMETHOD_(float, GetSaturation()) = 0;
+
+ STDMETHOD(EnableForcedSubtitles(bool fEnable)) = 0;
+ STDMETHOD_(bool, IsForcedSubtitlesEnabled()) = 0;
+
+ STDMETHOD(EnablePlanarYUV(bool fEnable)) = 0;
+ STDMETHOD_(bool, IsPlanarYUVEnabled()) = 0;
+
+ STDMETHOD(EnableInterlaced(bool fEnable)) = 0;
+ STDMETHOD_(bool, IsInterlacedEnabled()) = 0;
+
+ STDMETHOD(EnableReadARFromStream(bool fEnable)) = 0;
+ STDMETHOD_(bool, IsReadARFromStreamEnabled()) = 0;
+
+ STDMETHOD(Apply()) = 0;
};
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp
index 243ab4856..db8c7a9a4 100644
--- a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp
+++ b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp
@@ -47,103 +47,103 @@
#ifdef REGISTER_FILTER
const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_MPEG2_VIDEO},
- {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_MPEG2_VIDEO},
- {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_MPEG2_VIDEO},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_MPEG2_VIDEO},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_MPG2},
+ {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_MPEG2_VIDEO},
+ {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_MPEG2_VIDEO},
+ {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_MPEG2_VIDEO},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_MPEG2_VIDEO},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_MPG2},
#ifndef MPEG2ONLY
- {&MEDIATYPE_Video, &MEDIASUBTYPE_MPEG1Packet},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_MPEG1Payload},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_MPEG1Packet},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_MPEG1Payload},
#endif
};
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
- {&MEDIATYPE_Video, &MEDIASUBTYPE_IYUV},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_IYUV},
};
const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CMpeg2DecFilter), Mpeg2DecFilterName, 0x00600001, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CMpeg2DecFilter), Mpeg2DecFilterName, 0x00600001, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMpeg2DecFilter>, NULL, &sudFilter[0]},
- {L"CMpeg2DecPropertyPage", &__uuidof(CMpeg2DecSettingsWnd), CreateInstance<CInternalPropertyPageTempl<CMpeg2DecSettingsWnd> >},
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMpeg2DecFilter>, NULL, &sudFilter[0]},
+ {L"CMpeg2DecPropertyPage", &__uuidof(CMpeg2DecSettingsWnd), CreateInstance<CInternalPropertyPageTempl<CMpeg2DecSettingsWnd> >},
};
int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
//
#include <detours/detours.h>
-BOOL (__stdcall * Real_IsDebuggerPresent)(void)
- = IsDebuggerPresent;
+BOOL (__stdcall* Real_IsDebuggerPresent)(void)
+ = IsDebuggerPresent;
-LONG (__stdcall * Real_ChangeDisplaySettingsExA)(LPCSTR a0,
- LPDEVMODEA a1,
- HWND a2,
- DWORD a3,
- LPVOID a4)
- = ChangeDisplaySettingsExA;
+LONG(__stdcall* Real_ChangeDisplaySettingsExA)(LPCSTR a0,
+ LPDEVMODEA a1,
+ HWND a2,
+ DWORD a3,
+ LPVOID a4)
+ = ChangeDisplaySettingsExA;
-LONG (__stdcall * Real_ChangeDisplaySettingsExW)(LPCWSTR a0,
- LPDEVMODEW a1,
- HWND a2,
- DWORD a3,
- LPVOID a4)
- = ChangeDisplaySettingsExW;
+LONG(__stdcall* Real_ChangeDisplaySettingsExW)(LPCWSTR a0,
+ LPDEVMODEW a1,
+ HWND a2,
+ DWORD a3,
+ LPVOID a4)
+ = ChangeDisplaySettingsExW;
BOOL WINAPI Mine_IsDebuggerPresent()
{
- TRACE(_T("Oops, somebody was trying to be naughty! (called IsDebuggerPresent)\n"));
- return FALSE;
+ TRACE(_T("Oops, somebody was trying to be naughty! (called IsDebuggerPresent)\n"));
+ return FALSE;
}
LONG WINAPI Mine_ChangeDisplaySettingsEx(LONG ret, DWORD dwFlags, LPVOID lParam)
{
- if (dwFlags&CDS_VIDEOPARAMETERS) {
- VIDEOPARAMETERS* vp = (VIDEOPARAMETERS*)lParam;
-
- if (vp->Guid == GUIDFromCString(_T("{02C62061-1097-11d1-920F-00A024DF156E}"))
- && (vp->dwFlags&VP_FLAGS_COPYPROTECT)) {
- if (vp->dwCommand == VP_COMMAND_GET) {
- if ((vp->dwTVStandard&VP_TV_STANDARD_WIN_VGA) && vp->dwTVStandard != VP_TV_STANDARD_WIN_VGA) {
- TRACE(_T("Ooops, tv-out enabled? macrovision checks suck..."));
- vp->dwTVStandard = VP_TV_STANDARD_WIN_VGA;
- }
- } else if (vp->dwCommand == VP_COMMAND_SET) {
- TRACE(_T("Ooops, as I already told ya, no need for any macrovision bs here"));
- return 0;
- }
- }
- }
-
- return ret;
+ if (dwFlags & CDS_VIDEOPARAMETERS) {
+ VIDEOPARAMETERS* vp = (VIDEOPARAMETERS*)lParam;
+
+ if (vp->Guid == GUIDFromCString(_T("{02C62061-1097-11d1-920F-00A024DF156E}"))
+ && (vp->dwFlags & VP_FLAGS_COPYPROTECT)) {
+ if (vp->dwCommand == VP_COMMAND_GET) {
+ if ((vp->dwTVStandard & VP_TV_STANDARD_WIN_VGA) && vp->dwTVStandard != VP_TV_STANDARD_WIN_VGA) {
+ TRACE(_T("Ooops, tv-out enabled? macrovision checks suck..."));
+ vp->dwTVStandard = VP_TV_STANDARD_WIN_VGA;
+ }
+ } else if (vp->dwCommand == VP_COMMAND_SET) {
+ TRACE(_T("Ooops, as I already told ya, no need for any macrovision bs here"));
+ return 0;
+ }
+ }
+ }
+
+ return ret;
}
LONG WINAPI Mine_ChangeDisplaySettingsExA(LPCSTR lpszDeviceName, LPDEVMODEA lpDevMode, HWND hwnd, DWORD dwFlags, LPVOID lParam)
{
- return Mine_ChangeDisplaySettingsEx(Real_ChangeDisplaySettingsExA(lpszDeviceName, lpDevMode, hwnd, dwFlags, lParam), dwFlags, lParam);
+ return Mine_ChangeDisplaySettingsEx(Real_ChangeDisplaySettingsExA(lpszDeviceName, lpDevMode, hwnd, dwFlags, lParam), dwFlags, lParam);
}
LONG WINAPI Mine_ChangeDisplaySettingsExW(LPCWSTR lpszDeviceName, LPDEVMODEW lpDevMode, HWND hwnd, DWORD dwFlags, LPVOID lParam)
{
- return Mine_ChangeDisplaySettingsEx(Real_ChangeDisplaySettingsExW(lpszDeviceName, lpDevMode, hwnd, dwFlags, lParam), dwFlags, lParam);
+ return Mine_ChangeDisplaySettingsEx(Real_ChangeDisplaySettingsExW(lpszDeviceName, lpDevMode, hwnd, dwFlags, lParam), dwFlags, lParam);
}
//
@@ -153,26 +153,26 @@ LONG WINAPI Mine_ChangeDisplaySettingsExW(LPCWSTR lpszDeviceName, LPDEVMODEW lpD
class CMpeg2DecFilterApp : public CFilterApp
{
public:
- BOOL InitInstance() {
- long lError;
+ BOOL InitInstance() {
+ long lError;
- if (!__super::InitInstance()) {
- return FALSE;
- }
+ if (!__super::InitInstance()) {
+ return FALSE;
+ }
- DetourRestoreAfterWith();
- DetourTransactionBegin();
- DetourUpdateThread(GetCurrentThread());
+ DetourRestoreAfterWith();
+ DetourTransactionBegin();
+ DetourUpdateThread(GetCurrentThread());
- DetourAttach(&(PVOID&)Real_IsDebuggerPresent, (PVOID)Mine_IsDebuggerPresent);
- DetourAttach(&(PVOID&)Real_ChangeDisplaySettingsExA, (PVOID)Mine_ChangeDisplaySettingsExA);
- DetourAttach(&(PVOID&)Real_ChangeDisplaySettingsExW, (PVOID)Mine_ChangeDisplaySettingsExW);
+ DetourAttach(&(PVOID&)Real_IsDebuggerPresent, (PVOID)Mine_IsDebuggerPresent);
+ DetourAttach(&(PVOID&)Real_ChangeDisplaySettingsExA, (PVOID)Mine_ChangeDisplaySettingsExA);
+ DetourAttach(&(PVOID&)Real_ChangeDisplaySettingsExW, (PVOID)Mine_ChangeDisplaySettingsExW);
- lError = DetourTransactionCommit();
- ASSERT (lError == NOERROR);
+ lError = DetourTransactionCommit();
+ ASSERT(lError == NOERROR);
- return TRUE;
- }
+ return TRUE;
+ }
};
CMpeg2DecFilterApp theApp;
@@ -184,1143 +184,1143 @@ CMpeg2DecFilterApp theApp;
//
CMpeg2DecFilter::CMpeg2DecFilter(LPUNKNOWN lpunk, HRESULT* phr)
- : CBaseVideoFilter(NAME("CMpeg2DecFilter"), lpunk, phr, __uuidof(this), 1)
- , m_fWaitForKeyFrame(true)
- , m_fInitializedBuffer(true)
-{
- delete m_pInput;
- // delete m_pOutput;
-
- if (FAILED(*phr)) {
- return;
- }
-
- m_pInput = DNew CMpeg2DecInputPin(this, phr, L"Video");
- if (!m_pInput) {
- *phr = E_OUTOFMEMORY;
- }
- if (FAILED(*phr)) {
- return;
- }
-
- // m_pOutput = DNew CMpeg2DecOutputPin(this, phr, L"Output");
- // if (!m_pOutput) *phr = E_OUTOFMEMORY;
- // if (FAILED(*phr)) return;
-
- m_pSubpicInput = DNew CSubpicInputPin(this, phr);
- if (!m_pSubpicInput) {
- *phr = E_OUTOFMEMORY;
- }
- if (FAILED(*phr)) {
- return;
- }
-
- m_pClosedCaptionOutput = DNew CClosedCaptionOutputPin(this, m_pLock, phr);
- if (!m_pClosedCaptionOutput) {
- *phr = E_OUTOFMEMORY;
- }
- if (FAILED(*phr)) {
- return;
- }
-
- SetDeinterlaceMethod(DIAuto);
- SetBrightness(0.0f);
- SetContrast(1.0f);
- SetHue(0.0f);
- SetSaturation(1.0f);
- EnableForcedSubtitles(true);
- EnablePlanarYUV(true);
- EnableInterlaced(false);
- EnableReadARFromStream(true);
+ : CBaseVideoFilter(NAME("CMpeg2DecFilter"), lpunk, phr, __uuidof(this), 1)
+ , m_fWaitForKeyFrame(true)
+ , m_fInitializedBuffer(true)
+{
+ delete m_pInput;
+ // delete m_pOutput;
+
+ if (FAILED(*phr)) {
+ return;
+ }
+
+ m_pInput = DNew CMpeg2DecInputPin(this, phr, L"Video");
+ if (!m_pInput) {
+ *phr = E_OUTOFMEMORY;
+ }
+ if (FAILED(*phr)) {
+ return;
+ }
+
+ // m_pOutput = DNew CMpeg2DecOutputPin(this, phr, L"Output");
+ // if (!m_pOutput) *phr = E_OUTOFMEMORY;
+ // if (FAILED(*phr)) return;
+
+ m_pSubpicInput = DNew CSubpicInputPin(this, phr);
+ if (!m_pSubpicInput) {
+ *phr = E_OUTOFMEMORY;
+ }
+ if (FAILED(*phr)) {
+ return;
+ }
+
+ m_pClosedCaptionOutput = DNew CClosedCaptionOutputPin(this, m_pLock, phr);
+ if (!m_pClosedCaptionOutput) {
+ *phr = E_OUTOFMEMORY;
+ }
+ if (FAILED(*phr)) {
+ return;
+ }
+
+ SetDeinterlaceMethod(DIAuto);
+ SetBrightness(0.0f);
+ SetContrast(1.0f);
+ SetHue(0.0f);
+ SetSaturation(1.0f);
+ EnableForcedSubtitles(true);
+ EnablePlanarYUV(true);
+ EnableInterlaced(false);
+ EnableReadARFromStream(true);
#ifdef REGISTER_FILTER
- CRegKey key;
- if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Video Decoder"), KEY_READ)) {
- DWORD dw;
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("DeinterlaceMethod"), dw)) {
- SetDeinterlaceMethod((ditype)dw);
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Brightness"), dw)) {
- SetBrightness(*(float*)&dw);
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Contrast"), dw)) {
- SetContrast(*(float*)&dw);
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Hue"), dw)) {
- SetHue(*(float*)&dw);
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Saturation"), dw)) {
- SetSaturation(*(float*)&dw);
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("ForcedSubtitles"), dw)) {
- EnableForcedSubtitles(!!dw);
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("PlanarYUV"), dw)) {
- EnablePlanarYUV(!!dw);
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Interlaced"), dw)) {
- EnableInterlaced(!!dw);
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("ReadARFromStream"), dw)) {
- EnableReadARFromStream(!!dw);
- }
- }
+ CRegKey key;
+ if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Video Decoder"), KEY_READ)) {
+ DWORD dw;
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("DeinterlaceMethod"), dw)) {
+ SetDeinterlaceMethod((ditype)dw);
+ }
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Brightness"), dw)) {
+ SetBrightness(*(float*)&dw);
+ }
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Contrast"), dw)) {
+ SetContrast(*(float*)&dw);
+ }
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Hue"), dw)) {
+ SetHue(*(float*)&dw);
+ }
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Saturation"), dw)) {
+ SetSaturation(*(float*)&dw);
+ }
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("ForcedSubtitles"), dw)) {
+ EnableForcedSubtitles(!!dw);
+ }
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("PlanarYUV"), dw)) {
+ EnablePlanarYUV(!!dw);
+ }
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Interlaced"), dw)) {
+ EnableInterlaced(!!dw);
+ }
+ if (ERROR_SUCCESS == key.QueryDWORDValue(_T("ReadARFromStream"), dw)) {
+ EnableReadARFromStream(!!dw);
+ }
+ }
#else
- DWORD dw;
- dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("DeinterlaceMethod"), m_ditype);
- SetDeinterlaceMethod((ditype)dw);
- dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Brightness"), *(DWORD*)&m_bright);
- SetBrightness(*(float*)&dw);
- dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Contrast"), *(DWORD*)&m_cont);
- SetContrast(*(float*)&dw);
- dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Hue"), *(DWORD*)&m_hue);
- SetHue(*(float*)&dw);
- dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Saturation"), *(DWORD*)&m_sat);
- SetSaturation(*(float*)&dw);
- dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("ForcedSubtitles"), m_fForcedSubs);
- EnableForcedSubtitles(!!dw);
- dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("PlanarYUV"), m_fPlanarYUV);
- EnablePlanarYUV(!!dw);
- dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Interlaced"), m_fInterlaced);
- EnableInterlaced(!!dw);
- dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("ReadARFromStream"), m_bReadARFromStream);
- EnableReadARFromStream(!!dw);
+ DWORD dw;
+ dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("DeinterlaceMethod"), m_ditype);
+ SetDeinterlaceMethod((ditype)dw);
+ dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Brightness"), *(DWORD*)&m_bright);
+ SetBrightness(*(float*)&dw);
+ dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Contrast"), *(DWORD*)&m_cont);
+ SetContrast(*(float*)&dw);
+ dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Hue"), *(DWORD*)&m_hue);
+ SetHue(*(float*)&dw);
+ dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Saturation"), *(DWORD*)&m_sat);
+ SetSaturation(*(float*)&dw);
+ dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("ForcedSubtitles"), m_fForcedSubs);
+ EnableForcedSubtitles(!!dw);
+ dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("PlanarYUV"), m_fPlanarYUV);
+ EnablePlanarYUV(!!dw);
+ dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Interlaced"), m_fInterlaced);
+ EnableInterlaced(!!dw);
+ dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("ReadARFromStream"), m_bReadARFromStream);
+ EnableReadARFromStream(!!dw);
#endif
- m_rate.Rate = 10000;
- m_rate.StartTime = 0;
+ m_rate.Rate = 10000;
+ m_rate.StartTime = 0;
- m_par.SetSize(1,1);
+ m_par.SetSize(1, 1);
}
CMpeg2DecFilter::~CMpeg2DecFilter()
{
- delete m_pSubpicInput;
- delete m_pClosedCaptionOutput;
+ delete m_pSubpicInput;
+ delete m_pClosedCaptionOutput;
}
STDMETHODIMP CMpeg2DecFilter::Apply()
{
#ifdef REGISTER_FILTER
- CRegKey key;
- if (ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Video Decoder"))) {
- key.SetDWORDValue(_T("DeinterlaceMethod"), m_ditype);
- key.SetDWORDValue(_T("Brightness"), *(DWORD*)&m_bright);
- key.SetDWORDValue(_T("Contrast"), *(DWORD*)&m_cont);
- key.SetDWORDValue(_T("Hue"), *(DWORD*)&m_hue);
- key.SetDWORDValue(_T("Saturation"), *(DWORD*)&m_sat);
- key.SetDWORDValue(_T("ForcedSubtitles"), m_fForcedSubs);
- key.SetDWORDValue(_T("PlanarYUV"), m_fPlanarYUV);
- key.SetDWORDValue(_T("Interlaced"), m_fInterlaced);
- key.SetDWORDValue(_T("ReadARFromStream"), m_bReadARFromStream);
- }
+ CRegKey key;
+ if (ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Video Decoder"))) {
+ key.SetDWORDValue(_T("DeinterlaceMethod"), m_ditype);
+ key.SetDWORDValue(_T("Brightness"), *(DWORD*)&m_bright);
+ key.SetDWORDValue(_T("Contrast"), *(DWORD*)&m_cont);
+ key.SetDWORDValue(_T("Hue"), *(DWORD*)&m_hue);
+ key.SetDWORDValue(_T("Saturation"), *(DWORD*)&m_sat);
+ key.SetDWORDValue(_T("ForcedSubtitles"), m_fForcedSubs);
+ key.SetDWORDValue(_T("PlanarYUV"), m_fPlanarYUV);
+ key.SetDWORDValue(_T("Interlaced"), m_fInterlaced);
+ key.SetDWORDValue(_T("ReadARFromStream"), m_bReadARFromStream);
+ }
#else
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Video Decoder"), _T("DeinterlaceMethod"), m_ditype);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Brightness"), *(DWORD*)&m_bright);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Contrast"), *(DWORD*)&m_cont);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Hue"), *(DWORD*)&m_hue);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Saturation"), *(DWORD*)&m_sat);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Video Decoder"), _T("ForcedSubtitles"), m_fForcedSubs);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Video Decoder"), _T("PlanarYUV"), m_fPlanarYUV);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Interlaced"), m_fInterlaced);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Video Decoder"), _T("ReadARFromStream"), m_bReadARFromStream);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Video Decoder"), _T("DeinterlaceMethod"), m_ditype);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Brightness"), *(DWORD*)&m_bright);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Contrast"), *(DWORD*)&m_cont);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Hue"), *(DWORD*)&m_hue);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Saturation"), *(DWORD*)&m_sat);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Video Decoder"), _T("ForcedSubtitles"), m_fForcedSubs);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Video Decoder"), _T("PlanarYUV"), m_fPlanarYUV);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Interlaced"), m_fInterlaced);
+ AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Video Decoder"), _T("ReadARFromStream"), m_bReadARFromStream);
#endif
- return S_OK;
+ return S_OK;
}
-void CMpeg2DecFilter::GetOutputSize(int& w, int& h, int& arx, int& ary, int &RealWidth, int &RealHeight)
+void CMpeg2DecFilter::GetOutputSize(int& w, int& h, int& arx, int& ary, int& RealWidth, int& RealHeight)
{
- w = m_dec->m_info.m_sequence->picture_width;
- h = m_dec->m_info.m_sequence->picture_height;
+ w = m_dec->m_info.m_sequence->picture_width;
+ h = m_dec->m_info.m_sequence->picture_height;
}
STDMETHODIMP CMpeg2DecFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- return
- QI(IMpeg2DecFilter)
- QI(ISpecifyPropertyPages)
- QI(ISpecifyPropertyPages2)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IMpeg2DecFilter)
+ QI(ISpecifyPropertyPages)
+ QI(ISpecifyPropertyPages2)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
int CMpeg2DecFilter::GetPinCount()
{
- return 4;
+ return 4;
}
CBasePin* CMpeg2DecFilter::GetPin(int n)
{
- switch (n) {
- case 0:
- return m_pInput;
- case 1:
- return m_pOutput;
- case 2:
- return m_pSubpicInput;
- case 3:
- return m_pClosedCaptionOutput;
- }
- return NULL;
+ switch (n) {
+ case 0:
+ return m_pInput;
+ case 1:
+ return m_pOutput;
+ case 2:
+ return m_pSubpicInput;
+ case 3:
+ return m_pClosedCaptionOutput;
+ }
+ return NULL;
}
HRESULT CMpeg2DecFilter::EndOfStream()
{
- CAutoLock cAutoLock(&m_csReceive);
- m_pClosedCaptionOutput->EndOfStream();
- return __super::EndOfStream();
+ CAutoLock cAutoLock(&m_csReceive);
+ m_pClosedCaptionOutput->EndOfStream();
+ return __super::EndOfStream();
}
HRESULT CMpeg2DecFilter::BeginFlush()
{
- m_pClosedCaptionOutput->DeliverBeginFlush();
- return __super::BeginFlush();
+ m_pClosedCaptionOutput->DeliverBeginFlush();
+ return __super::BeginFlush();
}
HRESULT CMpeg2DecFilter::EndFlush()
{
- m_pClosedCaptionOutput->DeliverEndFlush();
- return __super::EndFlush();
+ m_pClosedCaptionOutput->DeliverEndFlush();
+ return __super::EndFlush();
}
HRESULT CMpeg2DecFilter::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- CAutoLock cAutoLock(&m_csReceive);
- m_pClosedCaptionOutput->DeliverNewSegment(tStart, tStop, dRate);
- m_fDropFrames = false;
- return __super::NewSegment(tStart, tStop, dRate);
+ CAutoLock cAutoLock(&m_csReceive);
+ m_pClosedCaptionOutput->DeliverNewSegment(tStart, tStop, dRate);
+ m_fDropFrames = false;
+ return __super::NewSegment(tStart, tStop, dRate);
}
void CMpeg2DecFilter::InputTypeChanged()
{
- CAutoLock cAutoLock(&m_csReceive);
+ CAutoLock cAutoLock(&m_csReceive);
- TRACE(_T("ResetMpeg2Decoder()\n"));
+ TRACE(_T("ResetMpeg2Decoder()\n"));
- for (int i = 0; i < _countof(m_dec->m_pictures); i++) {
- m_dec->m_pictures[i].rtStart = m_dec->m_pictures[i].rtStop = _I64_MIN+1;
- m_dec->m_pictures[i].fDelivered = false;
- m_dec->m_pictures[i].flags &= ~PIC_MASK_CODING_TYPE;
- }
+ for (int i = 0; i < _countof(m_dec->m_pictures); i++) {
+ m_dec->m_pictures[i].rtStart = m_dec->m_pictures[i].rtStop = _I64_MIN + 1;
+ m_dec->m_pictures[i].fDelivered = false;
+ m_dec->m_pictures[i].flags &= ~PIC_MASK_CODING_TYPE;
+ }
- const CMediaType& mt = m_pInput->CurrentMediaType();
+ const CMediaType& mt = m_pInput->CurrentMediaType();
- BYTE* pSequenceHeader = NULL;
- DWORD cbSequenceHeader = 0;
+ BYTE* pSequenceHeader = NULL;
+ DWORD cbSequenceHeader = 0;
- if (mt.formattype == FORMAT_MPEGVideo) {
- pSequenceHeader = ((MPEG1VIDEOINFO*)mt.Format())->bSequenceHeader;
- cbSequenceHeader = ((MPEG1VIDEOINFO*)mt.Format())->cbSequenceHeader;
- } else if (mt.formattype == FORMAT_MPEG2_VIDEO) {
- pSequenceHeader = (BYTE*)((MPEG2VIDEOINFO*)mt.Format())->dwSequenceHeader;
- cbSequenceHeader = ((MPEG2VIDEOINFO*)mt.Format())->cbSequenceHeader;
- }
+ if (mt.formattype == FORMAT_MPEGVideo) {
+ pSequenceHeader = ((MPEG1VIDEOINFO*)mt.Format())->bSequenceHeader;
+ cbSequenceHeader = ((MPEG1VIDEOINFO*)mt.Format())->cbSequenceHeader;
+ } else if (mt.formattype == FORMAT_MPEG2_VIDEO) {
+ pSequenceHeader = (BYTE*)((MPEG2VIDEOINFO*)mt.Format())->dwSequenceHeader;
+ cbSequenceHeader = ((MPEG2VIDEOINFO*)mt.Format())->cbSequenceHeader;
+ }
- m_dec->mpeg2_close();
- m_dec->mpeg2_init();
+ m_dec->mpeg2_close();
+ m_dec->mpeg2_init();
- m_dec->mpeg2_buffer(pSequenceHeader, pSequenceHeader + cbSequenceHeader);
+ m_dec->mpeg2_buffer(pSequenceHeader, pSequenceHeader + cbSequenceHeader);
- m_fWaitForKeyFrame = true;
+ m_fWaitForKeyFrame = true;
- m_fFilm = false;
- m_fb.flags = 0;
+ m_fFilm = false;
+ m_fb.flags = 0;
}
void CMpeg2DecFilter::SetDeinterlaceMethod()
{
- ASSERT(m_dec->m_info.m_sequence);
- ASSERT(m_dec->m_info.m_display_picture);
-
- DWORD seqflags = m_dec->m_info.m_sequence->flags;
- DWORD oldflags = m_fb.flags;
- DWORD newflags = m_dec->m_info.m_display_picture->flags;
-
- if (!(seqflags & SEQ_FLAG_PROGRESSIVE_SEQUENCE)
- && !(oldflags & PIC_FLAG_REPEAT_FIRST_FIELD)
- && (newflags & PIC_FLAG_PROGRESSIVE_FRAME)) {
- if (!m_fFilm && (newflags & PIC_FLAG_REPEAT_FIRST_FIELD)) {
- TRACE(_T("m_fFilm = true\n"));
- m_fFilm = true;
- } else if (m_fFilm && !(newflags & PIC_FLAG_REPEAT_FIRST_FIELD)) {
- TRACE(_T("m_fFilm = false\n"));
- m_fFilm = false;
- }
- }
-
- const CMediaType& mt = m_pOutput->CurrentMediaType();
-
- if (mt.formattype == FORMAT_VideoInfo2 && (((VIDEOINFOHEADER2*)mt.pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced)) {
- m_fb.di = DIWeave;
- } else {
- m_fb.di = GetDeinterlaceMethod();
-
- if (m_fb.di == DIAuto || m_fb.di != DIWeave && m_fb.di != DIBlend && m_fb.di != DIBob && m_fb.di != DIFieldShift && m_fb.di != DIELA) {
- if (seqflags & SEQ_FLAG_PROGRESSIVE_SEQUENCE) {
- m_fb.di = DIWeave; // hurray!
- } else if (m_fFilm) {
- m_fb.di = DIWeave; // we are lucky
- } else if (!(m_fb.flags & PIC_FLAG_PROGRESSIVE_FRAME)) {
- m_fb.di = DIBlend; // ok, clear thing
- } else
- // big trouble here, the progressive_frame bit is not reliable :'(
- // frames without temporal field diffs can be only detected when ntsc
- // uses the repeat field flag (signaled with m_fFilm), if it's not set
- // or we have pal then we might end up blending the fields unnecessarily...
- {
- m_fb.di = DIBlend;
- }
- }
- }
-
- m_fb.flags = newflags;
+ ASSERT(m_dec->m_info.m_sequence);
+ ASSERT(m_dec->m_info.m_display_picture);
+
+ DWORD seqflags = m_dec->m_info.m_sequence->flags;
+ DWORD oldflags = m_fb.flags;
+ DWORD newflags = m_dec->m_info.m_display_picture->flags;
+
+ if (!(seqflags & SEQ_FLAG_PROGRESSIVE_SEQUENCE)
+ && !(oldflags & PIC_FLAG_REPEAT_FIRST_FIELD)
+ && (newflags & PIC_FLAG_PROGRESSIVE_FRAME)) {
+ if (!m_fFilm && (newflags & PIC_FLAG_REPEAT_FIRST_FIELD)) {
+ TRACE(_T("m_fFilm = true\n"));
+ m_fFilm = true;
+ } else if (m_fFilm && !(newflags & PIC_FLAG_REPEAT_FIRST_FIELD)) {
+ TRACE(_T("m_fFilm = false\n"));
+ m_fFilm = false;
+ }
+ }
+
+ const CMediaType& mt = m_pOutput->CurrentMediaType();
+
+ if (mt.formattype == FORMAT_VideoInfo2 && (((VIDEOINFOHEADER2*)mt.pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced)) {
+ m_fb.di = DIWeave;
+ } else {
+ m_fb.di = GetDeinterlaceMethod();
+
+ if (m_fb.di == DIAuto || m_fb.di != DIWeave && m_fb.di != DIBlend && m_fb.di != DIBob && m_fb.di != DIFieldShift && m_fb.di != DIELA) {
+ if (seqflags & SEQ_FLAG_PROGRESSIVE_SEQUENCE) {
+ m_fb.di = DIWeave; // hurray!
+ } else if (m_fFilm) {
+ m_fb.di = DIWeave; // we are lucky
+ } else if (!(m_fb.flags & PIC_FLAG_PROGRESSIVE_FRAME)) {
+ m_fb.di = DIBlend; // ok, clear thing
+ } else
+ // big trouble here, the progressive_frame bit is not reliable :'(
+ // frames without temporal field diffs can be only detected when ntsc
+ // uses the repeat field flag (signaled with m_fFilm), if it's not set
+ // or we have pal then we might end up blending the fields unnecessarily...
+ {
+ m_fb.di = DIBlend;
+ }
+ }
+ }
+
+ m_fb.flags = newflags;
}
void CMpeg2DecFilter::SetTypeSpecificFlags(IMediaSample* pMS)
{
- if (CComQIPtr<IMediaSample2> pMS2 = pMS) {
- AM_SAMPLE2_PROPERTIES props;
- if (SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props))) {
- props.dwTypeSpecificFlags &= ~0x7f;
-
- const CMediaType& mt = m_pOutput->CurrentMediaType();
- if (mt.formattype == FORMAT_VideoInfo2 && (((VIDEOINFOHEADER2*)mt.pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced)) {
- // props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;
-
- if (m_dec->m_info.m_sequence->flags & SEQ_FLAG_PROGRESSIVE_SEQUENCE) {
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;
- }
-
- if (m_fb.flags & PIC_FLAG_TOP_FIELD_FIRST) {
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_FIELD1FIRST;
- }
- if (m_fb.flags & PIC_FLAG_REPEAT_FIRST_FIELD) {
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_REPEAT_FIELD;
- }
-
- if ((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I) {
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_I_SAMPLE;
- }
- if ((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_P) {
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_P_SAMPLE;
- }
- if ((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_B) {
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_B_SAMPLE;
- }
- }
-
- pMS2->SetProperties(sizeof(props), (BYTE*)&props);
- }
- }
+ if (CComQIPtr<IMediaSample2> pMS2 = pMS) {
+ AM_SAMPLE2_PROPERTIES props;
+ if (SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props))) {
+ props.dwTypeSpecificFlags &= ~0x7f;
+
+ const CMediaType& mt = m_pOutput->CurrentMediaType();
+ if (mt.formattype == FORMAT_VideoInfo2 && (((VIDEOINFOHEADER2*)mt.pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced)) {
+ // props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;
+
+ if (m_dec->m_info.m_sequence->flags & SEQ_FLAG_PROGRESSIVE_SEQUENCE) {
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;
+ }
+
+ if (m_fb.flags & PIC_FLAG_TOP_FIELD_FIRST) {
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_FIELD1FIRST;
+ }
+ if (m_fb.flags & PIC_FLAG_REPEAT_FIRST_FIELD) {
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_REPEAT_FIELD;
+ }
+
+ if ((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I) {
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_I_SAMPLE;
+ }
+ if ((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_P) {
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_P_SAMPLE;
+ }
+ if ((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_B) {
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_B_SAMPLE;
+ }
+ }
+
+ pMS2->SetProperties(sizeof(props), (BYTE*)&props);
+ }
+ }
}
HRESULT CMpeg2DecFilter::Transform(IMediaSample* pIn)
{
- HRESULT hr;
+ HRESULT hr;
- BYTE* pDataIn = NULL;
- if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
- return hr;
- }
+ BYTE* pDataIn = NULL;
+ if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
+ return hr;
+ }
- long len = pIn->GetActualDataLength();
+ long len = pIn->GetActualDataLength();
- (static_cast<CDeCSSInputPin*>(m_pInput))->StripPacket(pDataIn, len);
+ (static_cast<CDeCSSInputPin*>(m_pInput))->StripPacket(pDataIn, len);
- if (pIn->IsDiscontinuity() == S_OK) {
- InputTypeChanged();
- }
+ if (pIn->IsDiscontinuity() == S_OK) {
+ InputTypeChanged();
+ }
- REFERENCE_TIME rtStart = _I64_MIN, rtStop = _I64_MIN;
- hr = pIn->GetTime(&rtStart, &rtStop);
- if (FAILED(hr)) {
- rtStart = rtStop = _I64_MIN;
- }
+ REFERENCE_TIME rtStart = _I64_MIN, rtStop = _I64_MIN;
+ hr = pIn->GetTime(&rtStart, &rtStop);
+ if (FAILED(hr)) {
+ rtStart = rtStop = _I64_MIN;
+ }
- while (len >= 0) {
- mpeg2_state_t state = m_dec->mpeg2_parse();
+ while (len >= 0) {
+ mpeg2_state_t state = m_dec->mpeg2_parse();
#ifndef _WIN64
- __asm emms; // this one is missing somewhere in the precompiled mmx obj files
+ __asm emms; // this one is missing somewhere in the precompiled mmx obj files
#endif
- switch (state) {
- case STATE_BUFFER:
- if (len > 0) {
- m_dec->mpeg2_buffer(pDataIn, pDataIn + len);
- len = 0;
- } else {
- len = -1;
- }
- break;
- case STATE_INVALID:
- TRACE(_T("*** STATE_INVALID\n"));
- break;
- case STATE_GOP:
- m_pClosedCaptionOutput->Deliver(m_dec->m_info.m_user_data, m_dec->m_info.m_user_data_len);
- break;
- case STATE_SEQUENCE:
- m_AvgTimePerFrame = m_dec->m_info.m_sequence->frame_period
- ? 10i64 * m_dec->m_info.m_sequence->frame_period / 27
- : ((VIDEOINFOHEADER*)m_pInput->CurrentMediaType().Format())->AvgTimePerFrame;
- break;
- case STATE_PICTURE:
- m_dec->m_picture->rtStart = rtStart;
- rtStart = _I64_MIN;
- m_dec->m_picture->fDelivered = false;
- m_dec->mpeg2_skip(m_fDropFrames && (m_dec->m_picture->flags&PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_B);
- break;
- case STATE_SLICE:
- case STATE_END: {
- mpeg2_picture_t* picture = m_dec->m_info.m_display_picture;
- mpeg2_fbuf_t* fbuf = m_dec->m_info.m_display_fbuf;
-
- if (picture && !(picture->flags&PIC_FLAG_SKIP) && fbuf) {
- ASSERT(!picture->fDelivered);
-
- picture->fDelivered = true;
-
- // frame buffer
-
- int w = m_dec->m_info.m_sequence->picture_width;
- int h = m_dec->m_info.m_sequence->picture_height;
- int pitch = (m_dec->m_info.m_sequence->width + 31) & ~31;
-
- if (m_fb.w != w || m_fb.h != h || m_fb.pitch != pitch) {
- m_fb.Alloc(w, h, pitch);
- m_fInitializedBuffer = false;
- }
-
- // start - end
-
- m_fb.rtStart = picture->rtStart;
- if (m_fb.rtStart == _I64_MIN) {
- m_fb.rtStart = m_fb.rtStop;
- }
- m_fb.rtStop = m_fb.rtStart + m_AvgTimePerFrame * picture->nb_fields / (m_dec->m_info.m_display_picture_2nd ? 1 : 2);
-
- REFERENCE_TIME rtStart = m_fb.rtStart;
- REFERENCE_TIME rtStop = m_fb.rtStop;
- UNREFERENCED_PARAMETER(rtStart);
- UNREFERENCED_PARAMETER(rtStop);
-
- //
-
- SetDeinterlaceMethod();
- UpdateAspectRatio();
-
- hr = DeliverFast();
- if (hr != S_OK) {
- hr = DeliverNormal();
- }
- if (hr != S_OK) {
- return hr;
- }
- if (hr == S_OK && !m_fWaitForKeyFrame) {
- m_fInitializedBuffer = true;
- }
- }
- }
- break;
- default:
- break;
- }
- }
-
- return S_OK;
+ switch (state) {
+ case STATE_BUFFER:
+ if (len > 0) {
+ m_dec->mpeg2_buffer(pDataIn, pDataIn + len);
+ len = 0;
+ } else {
+ len = -1;
+ }
+ break;
+ case STATE_INVALID:
+ TRACE(_T("*** STATE_INVALID\n"));
+ break;
+ case STATE_GOP:
+ m_pClosedCaptionOutput->Deliver(m_dec->m_info.m_user_data, m_dec->m_info.m_user_data_len);
+ break;
+ case STATE_SEQUENCE:
+ m_AvgTimePerFrame = m_dec->m_info.m_sequence->frame_period
+ ? 10i64 * m_dec->m_info.m_sequence->frame_period / 27
+ : ((VIDEOINFOHEADER*)m_pInput->CurrentMediaType().Format())->AvgTimePerFrame;
+ break;
+ case STATE_PICTURE:
+ m_dec->m_picture->rtStart = rtStart;
+ rtStart = _I64_MIN;
+ m_dec->m_picture->fDelivered = false;
+ m_dec->mpeg2_skip(m_fDropFrames && (m_dec->m_picture->flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_B);
+ break;
+ case STATE_SLICE:
+ case STATE_END: {
+ mpeg2_picture_t* picture = m_dec->m_info.m_display_picture;
+ mpeg2_fbuf_t* fbuf = m_dec->m_info.m_display_fbuf;
+
+ if (picture && !(picture->flags & PIC_FLAG_SKIP) && fbuf) {
+ ASSERT(!picture->fDelivered);
+
+ picture->fDelivered = true;
+
+ // frame buffer
+
+ int w = m_dec->m_info.m_sequence->picture_width;
+ int h = m_dec->m_info.m_sequence->picture_height;
+ int pitch = (m_dec->m_info.m_sequence->width + 31) & ~31;
+
+ if (m_fb.w != w || m_fb.h != h || m_fb.pitch != pitch) {
+ m_fb.Alloc(w, h, pitch);
+ m_fInitializedBuffer = false;
+ }
+
+ // start - end
+
+ m_fb.rtStart = picture->rtStart;
+ if (m_fb.rtStart == _I64_MIN) {
+ m_fb.rtStart = m_fb.rtStop;
+ }
+ m_fb.rtStop = m_fb.rtStart + m_AvgTimePerFrame * picture->nb_fields / (m_dec->m_info.m_display_picture_2nd ? 1 : 2);
+
+ REFERENCE_TIME rtStart = m_fb.rtStart;
+ REFERENCE_TIME rtStop = m_fb.rtStop;
+ UNREFERENCED_PARAMETER(rtStart);
+ UNREFERENCED_PARAMETER(rtStop);
+
+ //
+
+ SetDeinterlaceMethod();
+ UpdateAspectRatio();
+
+ hr = DeliverFast();
+ if (hr != S_OK) {
+ hr = DeliverNormal();
+ }
+ if (hr != S_OK) {
+ return hr;
+ }
+ if (hr == S_OK && !m_fWaitForKeyFrame) {
+ m_fInitializedBuffer = true;
+ }
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ return S_OK;
}
bool CMpeg2DecFilter::IsVideoInterlaced()
{
- return IsInterlacedEnabled();
+ return IsInterlacedEnabled();
}
void CMpeg2DecFilter::UpdateAspectRatio()
{
- if (m_bReadARFromStream && ((unsigned int)m_par.cx != m_dec->m_info.m_sequence->pixel_width || (unsigned int)m_par.cy != m_dec->m_info.m_sequence->pixel_height)) {
- m_par.cx = m_dec->m_info.m_sequence->pixel_width;
- m_par.cy = m_dec->m_info.m_sequence->pixel_height;
- CSize dar(m_dec->m_info.m_sequence->picture_width * m_par.cx,
- m_dec->m_info.m_sequence->picture_height * m_par.cy);
- int lnko = LNKO(dar.cx, dar.cy);
- if (lnko > 1) {
- dar.cx /= lnko, dar.cy /= lnko;
- }
- SetAspect(dar);
- }
+ if (m_bReadARFromStream && ((unsigned int)m_par.cx != m_dec->m_info.m_sequence->pixel_width || (unsigned int)m_par.cy != m_dec->m_info.m_sequence->pixel_height)) {
+ m_par.cx = m_dec->m_info.m_sequence->pixel_width;
+ m_par.cy = m_dec->m_info.m_sequence->pixel_height;
+ CSize dar(m_dec->m_info.m_sequence->picture_width * m_par.cx,
+ m_dec->m_info.m_sequence->picture_height * m_par.cy);
+ int lnko = LNKO(dar.cx, dar.cy);
+ if (lnko > 1) {
+ dar.cx /= lnko, dar.cy /= lnko;
+ }
+ SetAspect(dar);
+ }
}
HRESULT CMpeg2DecFilter::DeliverFast()
{
- HRESULT hr;
+ HRESULT hr;
- CAutoLock cAutoLock(&m_csReceive);
+ CAutoLock cAutoLock(&m_csReceive);
- mpeg2_fbuf_t* fbuf = m_dec->m_info.m_display_fbuf;
- if (!fbuf) {
- return S_FALSE;
- }
+ mpeg2_fbuf_t* fbuf = m_dec->m_info.m_display_fbuf;
+ if (!fbuf) {
+ return S_FALSE;
+ }
- {
+ {
- CAutoLock cAutoLock2(&m_csProps);
+ CAutoLock cAutoLock2(&m_csProps);
- if (GetCLSID(m_pInput->GetConnected()) == CLSID_DVDNavigator
- || m_pSubpicInput->HasAnythingToRender(m_fb.rtStart)
- || fabs(m_bright) > EPSILON || fabs(m_cont-1.0) > EPSILON
- || fabs(m_hue) > EPSILON || fabs(m_sat-1.0) > EPSILON) {
- return S_FALSE;
- }
- }
+ if (GetCLSID(m_pInput->GetConnected()) == CLSID_DVDNavigator
+ || m_pSubpicInput->HasAnythingToRender(m_fb.rtStart)
+ || fabs(m_bright) > EPSILON || fabs(m_cont - 1.0) > EPSILON
+ || fabs(m_hue) > EPSILON || fabs(m_sat - 1.0) > EPSILON) {
+ return S_FALSE;
+ }
+ }
- if ((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I) {
- m_fWaitForKeyFrame = false;
- }
+ if ((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I) {
+ m_fWaitForKeyFrame = false;
+ }
- if (m_fb.rtStart < 0 || m_fWaitForKeyFrame) {
- return S_OK;
- }
+ if (m_fb.rtStart < 0 || m_fWaitForKeyFrame) {
+ return S_OK;
+ }
- const CMediaType& mt = m_pOutput->CurrentMediaType();
+ const CMediaType& mt = m_pOutput->CurrentMediaType();
- if (mt.subtype != MEDIASUBTYPE_I420 && mt.subtype != MEDIASUBTYPE_IYUV && mt.subtype != MEDIASUBTYPE_YV12) {
- return S_FALSE;
- }
+ if (mt.subtype != MEDIASUBTYPE_I420 && mt.subtype != MEDIASUBTYPE_IYUV && mt.subtype != MEDIASUBTYPE_YV12) {
+ return S_FALSE;
+ }
- CComPtr<IMediaSample> pOut;
- BYTE* pDataOut = NULL;
- if (FAILED(hr = GetDeliveryBuffer(m_fb.w, m_fb.h, &pOut))
- || FAILED(hr = pOut->GetPointer(&pDataOut))) {
- return hr;
- }
+ CComPtr<IMediaSample> pOut;
+ BYTE* pDataOut = NULL;
+ if (FAILED(hr = GetDeliveryBuffer(m_fb.w, m_fb.h, &pOut))
+ || FAILED(hr = pOut->GetPointer(&pDataOut))) {
+ return hr;
+ }
- if (mt.subtype != MEDIASUBTYPE_I420 && mt.subtype != MEDIASUBTYPE_IYUV && mt.subtype != MEDIASUBTYPE_YV12) {
- return S_FALSE;
- }
+ if (mt.subtype != MEDIASUBTYPE_I420 && mt.subtype != MEDIASUBTYPE_IYUV && mt.subtype != MEDIASUBTYPE_YV12) {
+ return S_FALSE;
+ }
- BITMAPINFOHEADER bihOut;
- ExtractBIH(&mt, &bihOut);
+ BITMAPINFOHEADER bihOut;
+ ExtractBIH(&mt, &bihOut);
- int w = bihOut.biWidth;
- int h = abs(bihOut.biHeight);
- int srcpitch = m_dec->m_info.m_sequence->width; // TODO (..+7)&~7; ?
- int dstpitch = bihOut.biWidth;
+ int w = bihOut.biWidth;
+ int h = abs(bihOut.biHeight);
+ int srcpitch = m_dec->m_info.m_sequence->width; // TODO (..+7)&~7; ?
+ int dstpitch = bihOut.biWidth;
- BYTE* y = pDataOut;
- BYTE* u = y + dstpitch*h;
- BYTE* v = y + dstpitch*h*5/4;
+ BYTE* y = pDataOut;
+ BYTE* u = y + dstpitch * h;
+ BYTE* v = y + dstpitch * h * 5 / 4;
- if (bihOut.biCompression == '21VY') {
- BYTE* tmp = u;
- u = v;
- v = tmp;
- }
+ if (bihOut.biCompression == '21VY') {
+ BYTE* tmp = u;
+ u = v;
+ v = tmp;
+ }
- if (m_fb.di == DIWeave) {
- BitBltFromI420ToI420(w, h, y, u, v, dstpitch, fbuf->buf[0], fbuf->buf[1], fbuf->buf[2], srcpitch);
- } else if (m_fb.di == DIBlend) {
- DeinterlaceBlend(y, fbuf->buf[0], w, h, dstpitch, srcpitch);
- DeinterlaceBlend(u, fbuf->buf[1], w/2, h/2, dstpitch/2, srcpitch/2);
- DeinterlaceBlend(v, fbuf->buf[2], w/2, h/2, dstpitch/2, srcpitch/2);
- } else { // TODO
- return S_FALSE;
- }
+ if (m_fb.di == DIWeave) {
+ BitBltFromI420ToI420(w, h, y, u, v, dstpitch, fbuf->buf[0], fbuf->buf[1], fbuf->buf[2], srcpitch);
+ } else if (m_fb.di == DIBlend) {
+ DeinterlaceBlend(y, fbuf->buf[0], w, h, dstpitch, srcpitch);
+ DeinterlaceBlend(u, fbuf->buf[1], w / 2, h / 2, dstpitch / 2, srcpitch / 2);
+ DeinterlaceBlend(v, fbuf->buf[2], w / 2, h / 2, dstpitch / 2, srcpitch / 2);
+ } else { // TODO
+ return S_FALSE;
+ }
- if (h == 1088) {
- memset(y + dstpitch*(h-8), 0xff, dstpitch*8);
- memset(u + dstpitch*(h-8)/4, 0x80, dstpitch*8/4);
- memset(v + dstpitch*(h-8)/4, 0x80, dstpitch*8/4);
- }
+ if (h == 1088) {
+ memset(y + dstpitch * (h - 8), 0xff, dstpitch * 8);
+ memset(u + dstpitch * (h - 8) / 4, 0x80, dstpitch * 8 / 4);
+ memset(v + dstpitch * (h - 8) / 4, 0x80, dstpitch * 8 / 4);
+ }
- if (CMpeg2DecInputPin* pPin = dynamic_cast<CMpeg2DecInputPin*>(m_pInput)) {
- CAutoLock cAutoLock(&pPin->m_csRateLock);
+ if (CMpeg2DecInputPin* pPin = dynamic_cast<CMpeg2DecInputPin*>(m_pInput)) {
+ CAutoLock cAutoLock(&pPin->m_csRateLock);
- if (m_rate.Rate != pPin->m_ratechange.Rate) {
- m_rate.Rate = pPin->m_ratechange.Rate;
- m_rate.StartTime = m_fb.rtStart;
- }
- }
+ if (m_rate.Rate != pPin->m_ratechange.Rate) {
+ m_rate.Rate = pPin->m_ratechange.Rate;
+ m_rate.StartTime = m_fb.rtStart;
+ }
+ }
- REFERENCE_TIME rtStart = m_fb.rtStart;
- REFERENCE_TIME rtStop = m_fb.rtStop;
+ REFERENCE_TIME rtStart = m_fb.rtStart;
+ REFERENCE_TIME rtStop = m_fb.rtStop;
- rtStart = m_rate.StartTime + (rtStart - m_rate.StartTime) * m_rate.Rate / 10000;
- rtStop = m_rate.StartTime + (rtStop - m_rate.StartTime) * m_rate.Rate / 10000;
+ rtStart = m_rate.StartTime + (rtStart - m_rate.StartTime) * m_rate.Rate / 10000;
+ rtStop = m_rate.StartTime + (rtStop - m_rate.StartTime) * m_rate.Rate / 10000;
- pOut->SetTime(&rtStart, &rtStop);
- pOut->SetMediaTime(NULL, NULL);
+ pOut->SetTime(&rtStart, &rtStop);
+ pOut->SetMediaTime(NULL, NULL);
- //
+ //
- SetTypeSpecificFlags(pOut);
+ SetTypeSpecificFlags(pOut);
- //
+ //
- return m_pOutput->Deliver(pOut);
+ return m_pOutput->Deliver(pOut);
}
HRESULT CMpeg2DecFilter::DeliverNormal()
{
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- CAutoLock cAutoLock(&m_csReceive);
+ CAutoLock cAutoLock(&m_csReceive);
- mpeg2_fbuf_t* fbuf = m_dec->m_info.m_display_fbuf;
- if (!fbuf) {
- return S_FALSE;
- }
+ mpeg2_fbuf_t* fbuf = m_dec->m_info.m_display_fbuf;
+ if (!fbuf) {
+ return S_FALSE;
+ }
- int w = m_fb.w;
- int h = m_fb.h;
- int spitch = m_dec->m_info.m_sequence->width; // TODO (..+7)&~7; ?
- int dpitch = m_fb.pitch;
+ int w = m_fb.w;
+ int h = m_fb.h;
+ int spitch = m_dec->m_info.m_sequence->width; // TODO (..+7)&~7; ?
+ int dpitch = m_fb.pitch;
- REFERENCE_TIME rtStart = m_fb.rtStart;
- REFERENCE_TIME rtStop = m_fb.rtStop;
+ REFERENCE_TIME rtStart = m_fb.rtStart;
+ REFERENCE_TIME rtStop = m_fb.rtStop;
- bool tff = !!(m_fb.flags&PIC_FLAG_TOP_FIELD_FIRST);
+ bool tff = !!(m_fb.flags & PIC_FLAG_TOP_FIELD_FIRST);
- // deinterlace
+ // deinterlace
- if (m_fb.di == DIWeave) {
- BitBltFromI420ToI420(w, h, m_fb.buf[0], m_fb.buf[1], m_fb.buf[2], dpitch, fbuf->buf[0], fbuf->buf[1], fbuf->buf[2], spitch);
- } else if (m_fb.di == DIBlend) {
- DeinterlaceBlend(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch);
- DeinterlaceBlend(m_fb.buf[1], fbuf->buf[1], w/2, h/2, dpitch/2, spitch/2);
- DeinterlaceBlend(m_fb.buf[2], fbuf->buf[2], w/2, h/2, dpitch/2, spitch/2);
- } else if (m_fb.di == DIBob) {
- DeinterlaceBob(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch, tff);
- DeinterlaceBob(m_fb.buf[1], fbuf->buf[1], w/2, h/2, dpitch/2, spitch/2, tff);
- DeinterlaceBob(m_fb.buf[2], fbuf->buf[2], w/2, h/2, dpitch/2, spitch/2, tff);
+ if (m_fb.di == DIWeave) {
+ BitBltFromI420ToI420(w, h, m_fb.buf[0], m_fb.buf[1], m_fb.buf[2], dpitch, fbuf->buf[0], fbuf->buf[1], fbuf->buf[2], spitch);
+ } else if (m_fb.di == DIBlend) {
+ DeinterlaceBlend(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch);
+ DeinterlaceBlend(m_fb.buf[1], fbuf->buf[1], w / 2, h / 2, dpitch / 2, spitch / 2);
+ DeinterlaceBlend(m_fb.buf[2], fbuf->buf[2], w / 2, h / 2, dpitch / 2, spitch / 2);
+ } else if (m_fb.di == DIBob) {
+ DeinterlaceBob(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch, tff);
+ DeinterlaceBob(m_fb.buf[1], fbuf->buf[1], w / 2, h / 2, dpitch / 2, spitch / 2, tff);
+ DeinterlaceBob(m_fb.buf[2], fbuf->buf[2], w / 2, h / 2, dpitch / 2, spitch / 2, tff);
- m_fb.rtStart = rtStart;
- m_fb.rtStop = (rtStart + rtStop) / 2;
- } else if (m_fb.di == DIFieldShift) {
- int soffset = tff ? 0 : spitch;
- int doffset = tff ? 0 : dpitch;
- BitBltFromRGBToRGB(w, h/2, m_fb.buf[0] + doffset, dpitch*2, 8, fbuf->buf[0] + soffset, spitch*2, 8);
- BitBltFromRGBToRGB(w/2, h/4, m_fb.buf[1] + doffset/2, dpitch, 8, fbuf->buf[1] + soffset/2, spitch, 8);
- BitBltFromRGBToRGB(w/2, h/4, m_fb.buf[2] + doffset/2, dpitch, 8, fbuf->buf[2] + soffset/2, spitch, 8);
- } else if (m_fb.di == DIELA) {
- DeinterlaceELA(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch, tff);
- DeinterlaceELA(m_fb.buf[1], fbuf->buf[1], w/2, h/2, dpitch/2, spitch/2, tff);
- DeinterlaceELA(m_fb.buf[2], fbuf->buf[2], w/2, h/2, dpitch/2, spitch/2, tff);
- }
+ m_fb.rtStart = rtStart;
+ m_fb.rtStop = (rtStart + rtStop) / 2;
+ } else if (m_fb.di == DIFieldShift) {
+ int soffset = tff ? 0 : spitch;
+ int doffset = tff ? 0 : dpitch;
+ BitBltFromRGBToRGB(w, h / 2, m_fb.buf[0] + doffset, dpitch * 2, 8, fbuf->buf[0] + soffset, spitch * 2, 8);
+ BitBltFromRGBToRGB(w / 2, h / 4, m_fb.buf[1] + doffset / 2, dpitch, 8, fbuf->buf[1] + soffset / 2, spitch, 8);
+ BitBltFromRGBToRGB(w / 2, h / 4, m_fb.buf[2] + doffset / 2, dpitch, 8, fbuf->buf[2] + soffset / 2, spitch, 8);
+ } else if (m_fb.di == DIELA) {
+ DeinterlaceELA(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch, tff);
+ DeinterlaceELA(m_fb.buf[1], fbuf->buf[1], w / 2, h / 2, dpitch / 2, spitch / 2, tff);
+ DeinterlaceELA(m_fb.buf[2], fbuf->buf[2], w / 2, h / 2, dpitch / 2, spitch / 2, tff);
+ }
- // postproc
+ // postproc
- ApplyBrContHueSat(m_fb.buf[0], m_fb.buf[1], m_fb.buf[2], w, h, dpitch);
+ ApplyBrContHueSat(m_fb.buf[0], m_fb.buf[1], m_fb.buf[2], w, h, dpitch);
- // deliver
+ // deliver
- if (m_fb.di == DIWeave || m_fInitializedBuffer) {
- hr = Deliver(false);
- if (FAILED(hr)) {
- return hr;
- }
- }
+ if (m_fb.di == DIWeave || m_fInitializedBuffer) {
+ hr = Deliver(false);
+ if (FAILED(hr)) {
+ return hr;
+ }
+ }
- if (m_fb.di == DIBob) {
- DeinterlaceBob(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch, !tff);
- DeinterlaceBob(m_fb.buf[1], fbuf->buf[1], w/2, h/2, dpitch/2, spitch/2, !tff);
- DeinterlaceBob(m_fb.buf[2], fbuf->buf[2], w/2, h/2, dpitch/2, spitch/2, !tff);
+ if (m_fb.di == DIBob) {
+ DeinterlaceBob(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch, !tff);
+ DeinterlaceBob(m_fb.buf[1], fbuf->buf[1], w / 2, h / 2, dpitch / 2, spitch / 2, !tff);
+ DeinterlaceBob(m_fb.buf[2], fbuf->buf[2], w / 2, h / 2, dpitch / 2, spitch / 2, !tff);
- m_fb.rtStart = (rtStart + rtStop) / 2;
- m_fb.rtStop = rtStop;
+ m_fb.rtStart = (rtStart + rtStop) / 2;
+ m_fb.rtStop = rtStop;
- // postproc
+ // postproc
- ApplyBrContHueSat(m_fb.buf[0], m_fb.buf[1], m_fb.buf[2], w, h, dpitch);
+ ApplyBrContHueSat(m_fb.buf[0], m_fb.buf[1], m_fb.buf[2], w, h, dpitch);
- // deliver
+ // deliver
- hr = Deliver(false);
- } else if (m_fb.di == DIFieldShift) {
- int soffset = !tff ? 0 : spitch;
- int doffset = !tff ? 0 : dpitch;
- BitBltFromRGBToRGB(w, h/2, m_fb.buf[0] + doffset, dpitch*2, 8, fbuf->buf[0] + soffset, spitch*2, 8);
- BitBltFromRGBToRGB(w/2, h/4, m_fb.buf[1] + doffset/2, dpitch, 8, fbuf->buf[1] + soffset/2, spitch, 8);
- BitBltFromRGBToRGB(w/2, h/4, m_fb.buf[2] + doffset/2, dpitch, 8, fbuf->buf[2] + soffset/2, spitch, 8);
- } else if (m_fb.di == DIELA) {
- DeinterlaceELA(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch, !tff);
- DeinterlaceELA(m_fb.buf[1], fbuf->buf[1], w/2, h/2, dpitch/2, spitch/2, !tff);
- DeinterlaceELA(m_fb.buf[2], fbuf->buf[2], w/2, h/2, dpitch/2, spitch/2, !tff);
- }
+ hr = Deliver(false);
+ } else if (m_fb.di == DIFieldShift) {
+ int soffset = !tff ? 0 : spitch;
+ int doffset = !tff ? 0 : dpitch;
+ BitBltFromRGBToRGB(w, h / 2, m_fb.buf[0] + doffset, dpitch * 2, 8, fbuf->buf[0] + soffset, spitch * 2, 8);
+ BitBltFromRGBToRGB(w / 2, h / 4, m_fb.buf[1] + doffset / 2, dpitch, 8, fbuf->buf[1] + soffset / 2, spitch, 8);
+ BitBltFromRGBToRGB(w / 2, h / 4, m_fb.buf[2] + doffset / 2, dpitch, 8, fbuf->buf[2] + soffset / 2, spitch, 8);
+ } else if (m_fb.di == DIELA) {
+ DeinterlaceELA(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch, !tff);
+ DeinterlaceELA(m_fb.buf[1], fbuf->buf[1], w / 2, h / 2, dpitch / 2, spitch / 2, !tff);
+ DeinterlaceELA(m_fb.buf[2], fbuf->buf[2], w / 2, h / 2, dpitch / 2, spitch / 2, !tff);
+ }
- if (!m_fInitializedBuffer) {
- hr = Deliver(false);
- }
+ if (!m_fInitializedBuffer) {
+ hr = Deliver(false);
+ }
- return hr;
+ return hr;
}
HRESULT CMpeg2DecFilter::Deliver(bool fRepeatLast)
{
- CAutoLock cAutoLock(&m_csReceive);
+ CAutoLock cAutoLock(&m_csReceive);
- if ((m_fb.flags&PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I) {
- m_fWaitForKeyFrame = false;
- }
+ if ((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I) {
+ m_fWaitForKeyFrame = false;
+ }
- if (m_fb.rtStart < 0 || m_fWaitForKeyFrame) {
- return S_OK;
- }
+ if (m_fb.rtStart < 0 || m_fWaitForKeyFrame) {
+ return S_OK;
+ }
- HRESULT hr;
+ HRESULT hr;
- CComPtr<IMediaSample> pOut;
- BYTE* pDataOut = NULL;
- if (FAILED(hr = GetDeliveryBuffer(m_fb.w, m_fb.h, &pOut))
- || FAILED(hr = pOut->GetPointer(&pDataOut))) {
- return hr;
- }
+ CComPtr<IMediaSample> pOut;
+ BYTE* pDataOut = NULL;
+ if (FAILED(hr = GetDeliveryBuffer(m_fb.w, m_fb.h, &pOut))
+ || FAILED(hr = pOut->GetPointer(&pDataOut))) {
+ return hr;
+ }
- if (m_fb.h == 1088) {
- memset(m_fb.buf[0] + m_fb.w*(m_fb.h-8), 0xff, m_fb.pitch*8);
- memset(m_fb.buf[1] + m_fb.w*(m_fb.h-8)/4, 0x80, m_fb.pitch*8/4);
- memset(m_fb.buf[2] + m_fb.w*(m_fb.h-8)/4, 0x80, m_fb.pitch*8/4);
- }
+ if (m_fb.h == 1088) {
+ memset(m_fb.buf[0] + m_fb.w * (m_fb.h - 8), 0xff, m_fb.pitch * 8);
+ memset(m_fb.buf[1] + m_fb.w * (m_fb.h - 8) / 4, 0x80, m_fb.pitch * 8 / 4);
+ memset(m_fb.buf[2] + m_fb.w * (m_fb.h - 8) / 4, 0x80, m_fb.pitch * 8 / 4);
+ }
- BYTE** buf = &m_fb.buf[0];
+ BYTE** buf = &m_fb.buf[0];
- if (m_pSubpicInput->HasAnythingToRender(m_fb.rtStart)) {
- BitBltFromI420ToI420(m_fb.w, m_fb.h,
- m_fb.buf[3], m_fb.buf[4], m_fb.buf[5], m_fb.pitch,
- m_fb.buf[0], m_fb.buf[1], m_fb.buf[2], m_fb.pitch);
+ if (m_pSubpicInput->HasAnythingToRender(m_fb.rtStart)) {
+ BitBltFromI420ToI420(m_fb.w, m_fb.h,
+ m_fb.buf[3], m_fb.buf[4], m_fb.buf[5], m_fb.pitch,
+ m_fb.buf[0], m_fb.buf[1], m_fb.buf[2], m_fb.pitch);
- buf = &m_fb.buf[3];
+ buf = &m_fb.buf[3];
- m_pSubpicInput->RenderSubpics(m_fb.rtStart, buf, m_fb.pitch, m_fb.h);
- }
+ m_pSubpicInput->RenderSubpics(m_fb.rtStart, buf, m_fb.pitch, m_fb.h);
+ }
- CopyBuffer(pDataOut, buf, (m_fb.w+7)&~7, m_fb.h, m_fb.pitch, MEDIASUBTYPE_I420, !(m_fb.flags & PIC_FLAG_PROGRESSIVE_FRAME));
+ CopyBuffer(pDataOut, buf, (m_fb.w + 7)&~7, m_fb.h, m_fb.pitch, MEDIASUBTYPE_I420, !(m_fb.flags & PIC_FLAG_PROGRESSIVE_FRAME));
- //
+ //
- if (CMpeg2DecInputPin* pPin = dynamic_cast<CMpeg2DecInputPin*>(m_pInput)) {
- CAutoLock cAutoLock(&pPin->m_csRateLock);
+ if (CMpeg2DecInputPin* pPin = dynamic_cast<CMpeg2DecInputPin*>(m_pInput)) {
+ CAutoLock cAutoLock(&pPin->m_csRateLock);
- if (m_rate.Rate != pPin->m_ratechange.Rate) {
- m_rate.Rate = pPin->m_ratechange.Rate;
- m_rate.StartTime = m_fb.rtStart;
- }
- }
+ if (m_rate.Rate != pPin->m_ratechange.Rate) {
+ m_rate.Rate = pPin->m_ratechange.Rate;
+ m_rate.StartTime = m_fb.rtStart;
+ }
+ }
- REFERENCE_TIME rtStart = m_fb.rtStart;
- REFERENCE_TIME rtStop = m_fb.rtStop;
+ REFERENCE_TIME rtStart = m_fb.rtStart;
+ REFERENCE_TIME rtStop = m_fb.rtStop;
- rtStart = m_rate.StartTime + (rtStart - m_rate.StartTime) * m_rate.Rate / 10000;
- rtStop = m_rate.StartTime + (rtStop - m_rate.StartTime) * m_rate.Rate / 10000;
+ rtStart = m_rate.StartTime + (rtStart - m_rate.StartTime) * m_rate.Rate / 10000;
+ rtStop = m_rate.StartTime + (rtStop - m_rate.StartTime) * m_rate.Rate / 10000;
- pOut->SetTime(&rtStart, &rtStop);
- pOut->SetMediaTime(NULL, NULL);
+ pOut->SetTime(&rtStart, &rtStop);
+ pOut->SetMediaTime(NULL, NULL);
- //
+ //
- SetTypeSpecificFlags(pOut);
+ SetTypeSpecificFlags(pOut);
- //
+ //
- hr = m_pOutput->Deliver(pOut);
+ hr = m_pOutput->Deliver(pOut);
- return hr;
+ return hr;
}
HRESULT CMpeg2DecFilter::CheckConnect(PIN_DIRECTION dir, IPin* pPin)
{
- if (dir == PINDIR_OUTPUT) {
- if (GetCLSID(m_pInput->GetConnected()) == CLSID_DVDNavigator) {
- // one of these needed for dynamic format changes
+ if (dir == PINDIR_OUTPUT) {
+ if (GetCLSID(m_pInput->GetConnected()) == CLSID_DVDNavigator) {
+ // one of these needed for dynamic format changes
- CLSID clsid = GetCLSID(pPin);
+ CLSID clsid = GetCLSID(pPin);
- DWORD ver = 0;
- if (CComQIPtr<IFilterVersion> pFV = GetFilterFromPin(pPin)) {
- ver = pFV->GetFilterVersion();
- }
+ DWORD ver = 0;
+ if (CComQIPtr<IFilterVersion> pFV = GetFilterFromPin(pPin)) {
+ ver = pFV->GetFilterVersion();
+ }
- if (clsid != CLSID_OverlayMixer
- /*&& clsid != CLSID_OverlayMixer2*/
- && clsid != CLSID_VideoMixingRenderer
- && clsid != CLSID_VideoMixingRenderer9
- && clsid != GUIDFromCString(_T("{FA10746C-9B63-4b6c-BC49-FC300EA5F256}")) // EVR
- && clsid != GUIDFromCString(_T("{04FE9017-F873-410E-871E-AB91661A4EF7}")) // ffdshow
- && (clsid != GUIDFromCString(_T("{93A22E7A-5091-45ef-BA61-6DA26156A5D0}")) || ver < 0x0234) // dvobsub
- && (clsid != GUIDFromCString(_T("{9852A670-F845-491b-9BE6-EBD841B8A613}")) || ver < 0x0234) // dvobsub auto
- && clsid != CLSID_madVR
- && clsid != CLSID_DXR) { // Haali's video renderer
- return E_FAIL;
- }
- }
- }
+ if (clsid != CLSID_OverlayMixer
+ /*&& clsid != CLSID_OverlayMixer2*/
+ && clsid != CLSID_VideoMixingRenderer
+ && clsid != CLSID_VideoMixingRenderer9
+ && clsid != GUIDFromCString(_T("{FA10746C-9B63-4b6c-BC49-FC300EA5F256}")) // EVR
+ && clsid != GUIDFromCString(_T("{04FE9017-F873-410E-871E-AB91661A4EF7}")) // ffdshow
+ && (clsid != GUIDFromCString(_T("{93A22E7A-5091-45ef-BA61-6DA26156A5D0}")) || ver < 0x0234) // dvobsub
+ && (clsid != GUIDFromCString(_T("{9852A670-F845-491b-9BE6-EBD841B8A613}")) || ver < 0x0234) // dvobsub auto
+ && clsid != CLSID_madVR
+ && clsid != CLSID_DXR) { // Haali's video renderer
+ return E_FAIL;
+ }
+ }
+ }
- return __super::CheckConnect(dir, pPin);
+ return __super::CheckConnect(dir, pPin);
}
int NextMpegStartCode(CGolombBuffer& gb, BYTE& code, __int64 len)
{
- gb.BitByteAlign();
- DWORD dw = (DWORD)-1;
- do {
- if (len-- == 0) {
- return false;
- }
- dw = (dw << 8) | (BYTE)gb.BitRead(8);
- } while ((dw&0xffffff00) != 0x00000100);
- code = (BYTE)(dw&0xff);
- return true;
+ gb.BitByteAlign();
+ DWORD dw = (DWORD) - 1;
+ do {
+ if (len-- == 0) {
+ return false;
+ }
+ dw = (dw << 8) | (BYTE)gb.BitRead(8);
+ } while ((dw & 0xffffff00) != 0x00000100);
+ code = (BYTE)(dw & 0xff);
+ return true;
}
HRESULT CMpeg2DecFilter::CheckInputType(const CMediaType* mtIn)
{
- if (mtIn->formattype == FORMAT_MPEG2_VIDEO && mtIn->pbFormat) {
- MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mtIn->pbFormat;
- if (vih->cbSequenceHeader > 0 && (vih->dwSequenceHeader[0] & 0x00ffffff) != 0x00010000) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- BYTE* pSequenceHeader = (BYTE*)vih->dwSequenceHeader;
- DWORD cbSequenceHeader = vih->cbSequenceHeader;
-
- BYTE id = 0;
- CGolombBuffer gb(pSequenceHeader, cbSequenceHeader);
- while (gb.GetPos() < gb.GetSize() && id != 0xb5) {
- if (!NextMpegStartCode(gb, id, cbSequenceHeader)) {
- break;
- }
- }
- if (id == 0xb5) {
- gb.BitRead(4); // startcodeid
- gb.BitRead(1); // profile_levelescape
- gb.BitRead(3); // profile
- gb.BitRead(4); // level
- gb.BitRead(1); // interlaced
- BYTE chroma = (BYTE)gb.BitRead(2);
- if (chroma >= 2) { // current support only 4:2:0 profile
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- }
- }
-
- return (mtIn->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK && mtIn->subtype == MEDIASUBTYPE_MPEG2_VIDEO
- || mtIn->majortype == MEDIATYPE_MPEG2_PACK && mtIn->subtype == MEDIASUBTYPE_MPEG2_VIDEO
- || mtIn->majortype == MEDIATYPE_MPEG2_PES && mtIn->subtype == MEDIASUBTYPE_MPEG2_VIDEO
- || mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_MPEG2_VIDEO
- || mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_MPG2
- || mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_MPEG1Packet
- || mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_MPEG1Payload)
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ if (mtIn->formattype == FORMAT_MPEG2_VIDEO && mtIn->pbFormat) {
+ MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mtIn->pbFormat;
+ if (vih->cbSequenceHeader > 0 && (vih->dwSequenceHeader[0] & 0x00ffffff) != 0x00010000) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+ BYTE* pSequenceHeader = (BYTE*)vih->dwSequenceHeader;
+ DWORD cbSequenceHeader = vih->cbSequenceHeader;
+
+ BYTE id = 0;
+ CGolombBuffer gb(pSequenceHeader, cbSequenceHeader);
+ while (gb.GetPos() < gb.GetSize() && id != 0xb5) {
+ if (!NextMpegStartCode(gb, id, cbSequenceHeader)) {
+ break;
+ }
+ }
+ if (id == 0xb5) {
+ gb.BitRead(4); // startcodeid
+ gb.BitRead(1); // profile_levelescape
+ gb.BitRead(3); // profile
+ gb.BitRead(4); // level
+ gb.BitRead(1); // interlaced
+ BYTE chroma = (BYTE)gb.BitRead(2);
+ if (chroma >= 2) { // current support only 4:2:0 profile
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
+ }
+ }
+
+ return (mtIn->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK && mtIn->subtype == MEDIASUBTYPE_MPEG2_VIDEO
+ || mtIn->majortype == MEDIATYPE_MPEG2_PACK && mtIn->subtype == MEDIASUBTYPE_MPEG2_VIDEO
+ || mtIn->majortype == MEDIATYPE_MPEG2_PES && mtIn->subtype == MEDIASUBTYPE_MPEG2_VIDEO
+ || mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_MPEG2_VIDEO
+ || mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_MPG2
+ || mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_MPEG1Packet
+ || mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_MPEG1Payload)
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CMpeg2DecFilter::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
{
- bool fPlanarYUV = mtOut->subtype == MEDIASUBTYPE_YV12
- || mtOut->subtype == MEDIASUBTYPE_I420
- || mtOut->subtype == MEDIASUBTYPE_IYUV;
+ bool fPlanarYUV = mtOut->subtype == MEDIASUBTYPE_YV12
+ || mtOut->subtype == MEDIASUBTYPE_I420
+ || mtOut->subtype == MEDIASUBTYPE_IYUV;
- return SUCCEEDED(__super::CheckTransform(mtIn, mtOut))
- && (!fPlanarYUV || IsPlanarYUVEnabled())
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ return SUCCEEDED(__super::CheckTransform(mtIn, mtOut))
+ && (!fPlanarYUV || IsPlanarYUVEnabled())
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
DWORD g_clock;
HRESULT CMpeg2DecFilter::StartStreaming()
{
- HRESULT hr = __super::StartStreaming();
- if (FAILED(hr)) {
- return hr;
- }
+ HRESULT hr = __super::StartStreaming();
+ if (FAILED(hr)) {
+ return hr;
+ }
- m_dec.Attach(DNew CMpeg2Dec());
- if (!m_dec) {
- return E_OUTOFMEMORY;
- }
+ m_dec.Attach(DNew CMpeg2Dec());
+ if (!m_dec) {
+ return E_OUTOFMEMORY;
+ }
- InputTypeChanged();
+ InputTypeChanged();
- // g_clock = clock();
+ // g_clock = clock();
- return S_OK;
+ return S_OK;
}
HRESULT CMpeg2DecFilter::StopStreaming()
{
- /*
- CString str;
- str.Format(_T("%d"), clock()-g_clock);
- AfxMessageBox(str);
- */
- m_dec.Free();
+ /*
+ CString str;
+ str.Format(_T("%d"), clock()-g_clock);
+ AfxMessageBox(str);
+ */
+ m_dec.Free();
- return __super::StopStreaming();
+ return __super::StopStreaming();
}
HRESULT CMpeg2DecFilter::AlterQuality(Quality q)
{
- if (q.Late > 100*10000i64) {
- m_fDropFrames = true;
- } else if (q.Late <= 0) {
- m_fDropFrames = false;
- }
+ if (q.Late > 100 * 10000i64) {
+ m_fDropFrames = true;
+ } else if (q.Late <= 0) {
+ m_fDropFrames = false;
+ }
- //TRACE(_T("CMpeg2DecFilter::AlterQuality: Type=%d, Proportion=%d, Late=%I64d, TimeStamp=%I64d\n"), q.Type, q.Proportion, q.Late, q.TimeStamp);
- return S_OK;
+ //TRACE(_T("CMpeg2DecFilter::AlterQuality: Type=%d, Proportion=%d, Late=%I64d, TimeStamp=%I64d\n"), q.Type, q.Proportion, q.Late, q.TimeStamp);
+ return S_OK;
}
// ISpecifyPropertyPages2
STDMETHODIMP CMpeg2DecFilter::GetPages(CAUUID* pPages)
{
- CheckPointer(pPages, E_POINTER);
+ CheckPointer(pPages, E_POINTER);
- pPages->cElems = 1;
- pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID) * pPages->cElems);
- pPages->pElems[0] = __uuidof(CMpeg2DecSettingsWnd);
+ pPages->cElems = 1;
+ pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID) * pPages->cElems);
+ pPages->pElems[0] = __uuidof(CMpeg2DecSettingsWnd);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CMpeg2DecFilter::CreatePage(const GUID& guid, IPropertyPage** ppPage)
{
- CheckPointer(ppPage, E_POINTER);
+ CheckPointer(ppPage, E_POINTER);
- if (*ppPage != NULL) {
- return E_INVALIDARG;
- }
+ if (*ppPage != NULL) {
+ return E_INVALIDARG;
+ }
- HRESULT hr;
+ HRESULT hr;
- if (guid == __uuidof(CMpeg2DecSettingsWnd)) {
- (*ppPage = DNew CInternalPropertyPageTempl<CMpeg2DecSettingsWnd>(NULL, &hr))->AddRef();
- }
+ if (guid == __uuidof(CMpeg2DecSettingsWnd)) {
+ (*ppPage = DNew CInternalPropertyPageTempl<CMpeg2DecSettingsWnd>(NULL, &hr))->AddRef();
+ }
- return *ppPage ? S_OK : E_FAIL;
+ return *ppPage ? S_OK : E_FAIL;
}
// IMpeg2DecFilter
STDMETHODIMP CMpeg2DecFilter::SetDeinterlaceMethod(ditype di)
{
- CAutoLock cAutoLock(&m_csProps);
- m_ditype = di;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_ditype = di;
+ return S_OK;
}
STDMETHODIMP_(ditype) CMpeg2DecFilter::GetDeinterlaceMethod()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_ditype;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_ditype;
}
void CMpeg2DecFilter::CalcBrCont(BYTE* YTbl, float bright, float cont)
{
- int Cont = (int)(cont * 512);
- int Bright = (int)bright;
+ int Cont = (int)(cont * 512);
+ int Bright = (int)bright;
- for (int i = 0; i < 256; i++) {
- int y = ((Cont * (i - 16)) >> 9) + Bright + 16;
- YTbl[i] = min(max(y, 0), 255);
- //YTbl[i] = min(max(y, 16), 235);
- }
+ for (int i = 0; i < 256; i++) {
+ int y = ((Cont * (i - 16)) >> 9) + Bright + 16;
+ YTbl[i] = min(max(y, 0), 255);
+ //YTbl[i] = min(max(y, 16), 235);
+ }
}
void CMpeg2DecFilter::CalcHueSat(BYTE* UTbl, BYTE* VTbl, float hue, float sat)
{
- int Sat = (int)(sat * 512);
- double Hue = (hue * 3.1415926) / 180.0;
- int Sin = (int)(sin(Hue) * 4096);
- int Cos = (int)(cos(Hue) * 4096);
-
- for (int y = 0; y < 256; y++) {
- for (int x = 0; x < 256; x++) {
- int u = x - 128;
- int v = y - 128;
- int ux = (u * Cos + v * Sin) >> 12;
- v = (v * Cos - u * Sin) >> 12;
- u = ((ux * Sat) >> 9) + 128;
- v = ((v * Sat) >> 9) + 128;
- u = min(max(u, 16), 235);
- v = min(max(v, 16), 235);
- UTbl[(y << 8) | x] = u;
- VTbl[(y << 8) | x] = v;
- }
- }
+ int Sat = (int)(sat * 512);
+ double Hue = (hue * 3.1415926) / 180.0;
+ int Sin = (int)(sin(Hue) * 4096);
+ int Cos = (int)(cos(Hue) * 4096);
+
+ for (int y = 0; y < 256; y++) {
+ for (int x = 0; x < 256; x++) {
+ int u = x - 128;
+ int v = y - 128;
+ int ux = (u * Cos + v * Sin) >> 12;
+ v = (v * Cos - u * Sin) >> 12;
+ u = ((ux * Sat) >> 9) + 128;
+ v = ((v * Sat) >> 9) + 128;
+ u = min(max(u, 16), 235);
+ v = min(max(v, 16), 235);
+ UTbl[(y << 8) | x] = u;
+ VTbl[(y << 8) | x] = v;
+ }
+ }
}
void CMpeg2DecFilter::ApplyBrContHueSat(BYTE* srcy, BYTE* srcu, BYTE* srcv, int w, int h, int pitch)
{
- CAutoLock cAutoLock(&m_csProps);
+ CAutoLock cAutoLock(&m_csProps);
- if (fabs(m_bright) > EPSILON || fabs(m_cont-1.0) > EPSILON) {
- int size = pitch*h;
+ if (fabs(m_bright) > EPSILON || fabs(m_cont - 1.0) > EPSILON) {
+ int size = pitch * h;
- if ((g_cpuid.m_flags&CCpuID::sse2) && ((DWORD_PTR)srcy & 15) == 0) {
- short Cont = (short)(min(max(m_cont, 0) * 512, (1<<16)-1));
- short Bright = (short)(m_bright + 16);
+ if ((g_cpuid.m_flags & CCpuID::sse2) && ((DWORD_PTR)srcy & 15) == 0) {
+ short Cont = (short)(min(max(m_cont, 0) * 512, (1 << 16) - 1));
+ short Bright = (short)(m_bright + 16);
- __m128i bc = _mm_set_epi16(Bright, Cont, Bright, Cont, Bright, Cont, Bright, Cont);
+ __m128i bc = _mm_set_epi16(Bright, Cont, Bright, Cont, Bright, Cont, Bright, Cont);
- __m128i zero = _mm_setzero_si128();
- __m128i _16 = _mm_set1_epi16(16);
- __m128i _512 = _mm_set1_epi16(512);
+ __m128i zero = _mm_setzero_si128();
+ __m128i _16 = _mm_set1_epi16(16);
+ __m128i _512 = _mm_set1_epi16(512);
- for (int i = 0, j = size>>4; i < j; i++) {
- __m128i r = _mm_load_si128((__m128i*)&srcy[i*16]);
+ for (int i = 0, j = size >> 4; i < j; i++) {
+ __m128i r = _mm_load_si128((__m128i*)&srcy[i * 16]);
- __m128i rl = _mm_unpacklo_epi8(r, zero);
- __m128i rh = _mm_unpackhi_epi8(r, zero);
+ __m128i rl = _mm_unpacklo_epi8(r, zero);
+ __m128i rh = _mm_unpackhi_epi8(r, zero);
- rl = _mm_subs_epi16(rl, _16);
- rh = _mm_subs_epi16(rh, _16);
+ rl = _mm_subs_epi16(rl, _16);
+ rh = _mm_subs_epi16(rh, _16);
- __m128i rll = _mm_unpacklo_epi16(rl, _512);
- __m128i rlh = _mm_unpackhi_epi16(rl, _512);
- __m128i rhl = _mm_unpacklo_epi16(rh, _512);
- __m128i rhh = _mm_unpackhi_epi16(rh, _512);
+ __m128i rll = _mm_unpacklo_epi16(rl, _512);
+ __m128i rlh = _mm_unpackhi_epi16(rl, _512);
+ __m128i rhl = _mm_unpacklo_epi16(rh, _512);
+ __m128i rhh = _mm_unpackhi_epi16(rh, _512);
- rll = _mm_madd_epi16(rll, bc);
- rlh = _mm_madd_epi16(rlh, bc);
- rhl = _mm_madd_epi16(rhl, bc);
- rhh = _mm_madd_epi16(rhh, bc);
+ rll = _mm_madd_epi16(rll, bc);
+ rlh = _mm_madd_epi16(rlh, bc);
+ rhl = _mm_madd_epi16(rhl, bc);
+ rhh = _mm_madd_epi16(rhh, bc);
- rll = _mm_srai_epi32(rll, 9);
- rlh = _mm_srai_epi32(rlh, 9);
- rhl = _mm_srai_epi32(rhl, 9);
- rhh = _mm_srai_epi32(rhh, 9);
+ rll = _mm_srai_epi32(rll, 9);
+ rlh = _mm_srai_epi32(rlh, 9);
+ rhl = _mm_srai_epi32(rhl, 9);
+ rhh = _mm_srai_epi32(rhh, 9);
- rl = _mm_packs_epi32(rll, rlh);
- rh = _mm_packs_epi32(rhl, rhh);
+ rl = _mm_packs_epi32(rll, rlh);
+ rh = _mm_packs_epi32(rhl, rhh);
- r = _mm_packus_epi16(rl, rh);
+ r = _mm_packus_epi16(rl, rh);
- _mm_store_si128((__m128i*)&srcy[i*16], r);
- }
+ _mm_store_si128((__m128i*)&srcy[i * 16], r);
+ }
- srcy += size>>4;
- size &= 15;
- }
+ srcy += size >> 4;
+ size &= 15;
+ }
- for (; size > 0; size--) {
- *srcy++ = m_YTbl[*srcy];
- }
- }
+ for (; size > 0; size--) {
+ *srcy++ = m_YTbl[*srcy];
+ }
+ }
- pitch /= 2;
- w /= 2;
- h /= 2;
+ pitch /= 2;
+ w /= 2;
+ h /= 2;
- if (fabs(m_hue) > EPSILON || fabs(m_sat-1.0) > EPSILON) {
- for (int size = pitch*h; size > 0; size--) {
- WORD uv = (*srcv<<8)|*srcu;
- *srcu++ = m_UTbl[uv];
- *srcv++ = m_VTbl[uv];
- }
- }
+ if (fabs(m_hue) > EPSILON || fabs(m_sat - 1.0) > EPSILON) {
+ for (int size = pitch * h; size > 0; size--) {
+ WORD uv = (*srcv << 8) | *srcu;
+ *srcu++ = m_UTbl[uv];
+ *srcv++ = m_VTbl[uv];
+ }
+ }
}
STDMETHODIMP CMpeg2DecFilter::SetBrightness(float bright)
{
- CAutoLock cAutoLock(&m_csProps);
- CalcBrCont(m_YTbl, m_bright = bright, m_cont);
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ CalcBrCont(m_YTbl, m_bright = bright, m_cont);
+ return S_OK;
}
STDMETHODIMP CMpeg2DecFilter::SetContrast(float cont)
{
- CAutoLock cAutoLock(&m_csProps);
- CalcBrCont(m_YTbl, m_bright, m_cont = cont);
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ CalcBrCont(m_YTbl, m_bright, m_cont = cont);
+ return S_OK;
}
STDMETHODIMP CMpeg2DecFilter::SetHue(float hue)
{
- CAutoLock cAutoLock(&m_csProps);
- CalcHueSat(m_UTbl, m_VTbl, m_hue = hue, m_sat);
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ CalcHueSat(m_UTbl, m_VTbl, m_hue = hue, m_sat);
+ return S_OK;
}
STDMETHODIMP CMpeg2DecFilter::SetSaturation(float sat)
{
- CAutoLock cAutoLock(&m_csProps);
- CalcHueSat(m_UTbl, m_VTbl, m_hue, m_sat = sat);
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ CalcHueSat(m_UTbl, m_VTbl, m_hue, m_sat = sat);
+ return S_OK;
}
STDMETHODIMP_(float) CMpeg2DecFilter::GetBrightness()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_bright;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_bright;
}
STDMETHODIMP_(float) CMpeg2DecFilter::GetContrast()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_cont;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_cont;
}
STDMETHODIMP_(float) CMpeg2DecFilter::GetHue()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_hue;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_hue;
}
STDMETHODIMP_(float) CMpeg2DecFilter::GetSaturation()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_sat;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_sat;
}
STDMETHODIMP CMpeg2DecFilter::EnableForcedSubtitles(bool fEnable)
{
- CAutoLock cAutoLock(&m_csProps);
- m_fForcedSubs = fEnable;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_fForcedSubs = fEnable;
+ return S_OK;
}
STDMETHODIMP_(bool) CMpeg2DecFilter::IsForcedSubtitlesEnabled()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_fForcedSubs;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_fForcedSubs;
}
STDMETHODIMP CMpeg2DecFilter::EnablePlanarYUV(bool fEnable)
{
- CAutoLock cAutoLock(&m_csProps);
- m_fPlanarYUV = fEnable;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_fPlanarYUV = fEnable;
+ return S_OK;
}
STDMETHODIMP_(bool) CMpeg2DecFilter::IsPlanarYUVEnabled()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_fPlanarYUV;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_fPlanarYUV;
}
STDMETHODIMP CMpeg2DecFilter::EnableInterlaced(bool fEnable)
{
- CAutoLock cAutoLock(&m_csProps);
- m_fInterlaced = fEnable;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_fInterlaced = fEnable;
+ return S_OK;
}
STDMETHODIMP_(bool) CMpeg2DecFilter::IsInterlacedEnabled()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_fInterlaced;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_fInterlaced;
}
STDMETHODIMP CMpeg2DecFilter::EnableReadARFromStream(bool fEnable)
{
- CAutoLock cAutoLock(&m_csProps);
- m_bReadARFromStream = fEnable;
- return S_OK;
+ CAutoLock cAutoLock(&m_csProps);
+ m_bReadARFromStream = fEnable;
+ return S_OK;
}
STDMETHODIMP_(bool) CMpeg2DecFilter::IsReadARFromStreamEnabled()
{
- CAutoLock cAutoLock(&m_csProps);
- return m_bReadARFromStream;
+ CAutoLock cAutoLock(&m_csProps);
+ return m_bReadARFromStream;
}
//
@@ -1328,184 +1328,184 @@ STDMETHODIMP_(bool) CMpeg2DecFilter::IsReadARFromStreamEnabled()
//
CMpeg2DecInputPin::CMpeg2DecInputPin(CTransformFilter* pFilter, HRESULT* phr, LPWSTR pName)
- : CDeCSSInputPin(NAME("CMpeg2DecInputPin"), pFilter, phr, pName)
+ : CDeCSSInputPin(NAME("CMpeg2DecInputPin"), pFilter, phr, pName)
{
- m_CorrectTS = 0;
- m_ratechange.Rate = 10000;
- m_ratechange.StartTime = _I64_MAX;
+ m_CorrectTS = 0;
+ m_ratechange.Rate = 10000;
+ m_ratechange.StartTime = _I64_MAX;
}
// IKsPropertySet
STDMETHODIMP CMpeg2DecInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength)
{
- if (PropSet != AM_KSPROPSETID_TSRateChange /*&& PropSet != AM_KSPROPSETID_DVD_RateChange*/) {
- return __super::Set(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength);
- }
-
- if (PropSet == AM_KSPROPSETID_TSRateChange)
- switch (Id) {
- case AM_RATE_SimpleRateChange: {
- AM_SimpleRateChange* p = (AM_SimpleRateChange*)pPropertyData;
- if (!m_CorrectTS) {
- return E_PROP_ID_UNSUPPORTED;
- }
- CAutoLock cAutoLock(&m_csRateLock);
- m_ratechange = *p;
- DbgLog((LOG_TRACE, 0, _T("StartTime=%I64d, Rate=%d"), p->StartTime, p->Rate));
- }
- break;
- case AM_RATE_UseRateVersion: {
- WORD* p = (WORD*)pPropertyData;
- if (*p > 0x0101) {
- return E_PROP_ID_UNSUPPORTED;
- }
- }
- break;
- case AM_RATE_CorrectTS: {
- LONG* p = (LONG*)pPropertyData;
- m_CorrectTS = *p;
- }
- break;
- default:
- return E_PROP_ID_UNSUPPORTED;
- }
- /*
- if (PropSet == AM_KSPROPSETID_DVD_RateChange)
- switch (Id)
- {
- case AM_RATE_ChangeRate:
- {
- AM_DVD_ChangeRate* p = (AM_DVD_ChangeRate*)pPropertyData;
- }
- break;
- default:
- return E_PROP_ID_UNSUPPORTED;
- }
- */
- return S_OK;
+ if (PropSet != AM_KSPROPSETID_TSRateChange /*&& PropSet != AM_KSPROPSETID_DVD_RateChange*/) {
+ return __super::Set(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength);
+ }
+
+ if (PropSet == AM_KSPROPSETID_TSRateChange)
+ switch (Id) {
+ case AM_RATE_SimpleRateChange: {
+ AM_SimpleRateChange* p = (AM_SimpleRateChange*)pPropertyData;
+ if (!m_CorrectTS) {
+ return E_PROP_ID_UNSUPPORTED;
+ }
+ CAutoLock cAutoLock(&m_csRateLock);
+ m_ratechange = *p;
+ DbgLog((LOG_TRACE, 0, _T("StartTime=%I64d, Rate=%d"), p->StartTime, p->Rate));
+ }
+ break;
+ case AM_RATE_UseRateVersion: {
+ WORD* p = (WORD*)pPropertyData;
+ if (*p > 0x0101) {
+ return E_PROP_ID_UNSUPPORTED;
+ }
+ }
+ break;
+ case AM_RATE_CorrectTS: {
+ LONG* p = (LONG*)pPropertyData;
+ m_CorrectTS = *p;
+ }
+ break;
+ default:
+ return E_PROP_ID_UNSUPPORTED;
+ }
+ /*
+ if (PropSet == AM_KSPROPSETID_DVD_RateChange)
+ switch (Id)
+ {
+ case AM_RATE_ChangeRate:
+ {
+ AM_DVD_ChangeRate* p = (AM_DVD_ChangeRate*)pPropertyData;
+ }
+ break;
+ default:
+ return E_PROP_ID_UNSUPPORTED;
+ }
+ */
+ return S_OK;
}
STDMETHODIMP CMpeg2DecInputPin::Get(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength, ULONG* pBytesReturned)
{
- if (PropSet != AM_KSPROPSETID_TSRateChange /*&& PropSet != AM_KSPROPSETID_DVD_RateChange*/) {
- return __super::Get(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength, pBytesReturned);
- }
-
- if (PropSet == AM_KSPROPSETID_TSRateChange)
- switch (Id) {
- case AM_RATE_SimpleRateChange: {
- AM_SimpleRateChange* p = (AM_SimpleRateChange*)pPropertyData;
- UNREFERENCED_PARAMETER(p);
- return E_PROP_ID_UNSUPPORTED;
- }
- break;
- case AM_RATE_MaxFullDataRate: {
- AM_MaxFullDataRate* p = (AM_MaxFullDataRate*)pPropertyData;
- UNREFERENCED_PARAMETER(p);
- *p = 8*10000;
- *pBytesReturned = sizeof(AM_MaxFullDataRate);
- }
- break;
- case AM_RATE_QueryFullFrameRate: {
- AM_QueryRate* p = (AM_QueryRate*)pPropertyData;
- p->lMaxForwardFullFrame = 8*10000;
- p->lMaxReverseFullFrame = 8*10000;
- *pBytesReturned = sizeof(AM_QueryRate);
- }
- break;
- case AM_RATE_QueryLastRateSegPTS: {
- //REFERENCE_TIME* p = (REFERENCE_TIME*)pPropertyData;
- return E_PROP_ID_UNSUPPORTED;
- }
- break;
- default:
- return E_PROP_ID_UNSUPPORTED;
- }
- /*
- if (PropSet == AM_KSPROPSETID_DVD_RateChange)
- switch (Id)
- {
- case AM_RATE_FullDataRateMax:
- {
- AM_MaxFullDataRate* p = (AM_MaxFullDataRate*)pPropertyData;
- }
- break;
- case AM_RATE_ReverseDecode:
- {
- LONG* p = (LONG*)pPropertyData;
- }
- break;
- case AM_RATE_DecoderPosition:
- {
- AM_DVD_DecoderPosition* p = (AM_DVD_DecoderPosition*)pPropertyData;
- }
- break;
- case AM_RATE_DecoderVersion:
- {
- LONG* p = (LONG*)pPropertyData;
- }
- break;
- default:
- return E_PROP_ID_UNSUPPORTED;
- }
- */
- return S_OK;
+ if (PropSet != AM_KSPROPSETID_TSRateChange /*&& PropSet != AM_KSPROPSETID_DVD_RateChange*/) {
+ return __super::Get(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength, pBytesReturned);
+ }
+
+ if (PropSet == AM_KSPROPSETID_TSRateChange)
+ switch (Id) {
+ case AM_RATE_SimpleRateChange: {
+ AM_SimpleRateChange* p = (AM_SimpleRateChange*)pPropertyData;
+ UNREFERENCED_PARAMETER(p);
+ return E_PROP_ID_UNSUPPORTED;
+ }
+ break;
+ case AM_RATE_MaxFullDataRate: {
+ AM_MaxFullDataRate* p = (AM_MaxFullDataRate*)pPropertyData;
+ UNREFERENCED_PARAMETER(p);
+ *p = 8 * 10000;
+ *pBytesReturned = sizeof(AM_MaxFullDataRate);
+ }
+ break;
+ case AM_RATE_QueryFullFrameRate: {
+ AM_QueryRate* p = (AM_QueryRate*)pPropertyData;
+ p->lMaxForwardFullFrame = 8 * 10000;
+ p->lMaxReverseFullFrame = 8 * 10000;
+ *pBytesReturned = sizeof(AM_QueryRate);
+ }
+ break;
+ case AM_RATE_QueryLastRateSegPTS: {
+ //REFERENCE_TIME* p = (REFERENCE_TIME*)pPropertyData;
+ return E_PROP_ID_UNSUPPORTED;
+ }
+ break;
+ default:
+ return E_PROP_ID_UNSUPPORTED;
+ }
+ /*
+ if (PropSet == AM_KSPROPSETID_DVD_RateChange)
+ switch (Id)
+ {
+ case AM_RATE_FullDataRateMax:
+ {
+ AM_MaxFullDataRate* p = (AM_MaxFullDataRate*)pPropertyData;
+ }
+ break;
+ case AM_RATE_ReverseDecode:
+ {
+ LONG* p = (LONG*)pPropertyData;
+ }
+ break;
+ case AM_RATE_DecoderPosition:
+ {
+ AM_DVD_DecoderPosition* p = (AM_DVD_DecoderPosition*)pPropertyData;
+ }
+ break;
+ case AM_RATE_DecoderVersion:
+ {
+ LONG* p = (LONG*)pPropertyData;
+ }
+ break;
+ default:
+ return E_PROP_ID_UNSUPPORTED;
+ }
+ */
+ return S_OK;
}
STDMETHODIMP CMpeg2DecInputPin::QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport)
{
- if (PropSet != AM_KSPROPSETID_TSRateChange /*&& PropSet != AM_KSPROPSETID_DVD_RateChange*/) {
- return __super::QuerySupported(PropSet, Id, pTypeSupport);
- }
-
- if (PropSet == AM_KSPROPSETID_TSRateChange)
- switch (Id) {
- case AM_RATE_SimpleRateChange:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET | KSPROPERTY_SUPPORT_SET;
- break;
- case AM_RATE_MaxFullDataRate:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET;
- break;
- case AM_RATE_UseRateVersion:
- *pTypeSupport = KSPROPERTY_SUPPORT_SET;
- break;
- case AM_RATE_QueryFullFrameRate:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET;
- break;
- case AM_RATE_QueryLastRateSegPTS:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET;
- break;
- case AM_RATE_CorrectTS:
- *pTypeSupport = KSPROPERTY_SUPPORT_SET;
- break;
- default:
- return E_PROP_ID_UNSUPPORTED;
- }
- /*
- if (PropSet == AM_KSPROPSETID_DVD_RateChange)
- switch (Id)
- {
- case AM_RATE_ChangeRate:
- *pTypeSupport = KSPROPERTY_SUPPORT_SET;
- break;
- case AM_RATE_FullDataRateMax:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET;
- break;
- case AM_RATE_ReverseDecode:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET;
- break;
- case AM_RATE_DecoderPosition:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET;
- break;
- case AM_RATE_DecoderVersion:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET;
- break;
- default:
- return E_PROP_ID_UNSUPPORTED;
- }
- */
- return S_OK;
+ if (PropSet != AM_KSPROPSETID_TSRateChange /*&& PropSet != AM_KSPROPSETID_DVD_RateChange*/) {
+ return __super::QuerySupported(PropSet, Id, pTypeSupport);
+ }
+
+ if (PropSet == AM_KSPROPSETID_TSRateChange)
+ switch (Id) {
+ case AM_RATE_SimpleRateChange:
+ *pTypeSupport = KSPROPERTY_SUPPORT_GET | KSPROPERTY_SUPPORT_SET;
+ break;
+ case AM_RATE_MaxFullDataRate:
+ *pTypeSupport = KSPROPERTY_SUPPORT_GET;
+ break;
+ case AM_RATE_UseRateVersion:
+ *pTypeSupport = KSPROPERTY_SUPPORT_SET;
+ break;
+ case AM_RATE_QueryFullFrameRate:
+ *pTypeSupport = KSPROPERTY_SUPPORT_GET;
+ break;
+ case AM_RATE_QueryLastRateSegPTS:
+ *pTypeSupport = KSPROPERTY_SUPPORT_GET;
+ break;
+ case AM_RATE_CorrectTS:
+ *pTypeSupport = KSPROPERTY_SUPPORT_SET;
+ break;
+ default:
+ return E_PROP_ID_UNSUPPORTED;
+ }
+ /*
+ if (PropSet == AM_KSPROPSETID_DVD_RateChange)
+ switch (Id)
+ {
+ case AM_RATE_ChangeRate:
+ *pTypeSupport = KSPROPERTY_SUPPORT_SET;
+ break;
+ case AM_RATE_FullDataRateMax:
+ *pTypeSupport = KSPROPERTY_SUPPORT_GET;
+ break;
+ case AM_RATE_ReverseDecode:
+ *pTypeSupport = KSPROPERTY_SUPPORT_GET;
+ break;
+ case AM_RATE_DecoderPosition:
+ *pTypeSupport = KSPROPERTY_SUPPORT_GET;
+ break;
+ case AM_RATE_DecoderVersion:
+ *pTypeSupport = KSPROPERTY_SUPPORT_GET;
+ break;
+ default:
+ return E_PROP_ID_UNSUPPORTED;
+ }
+ */
+ return S_OK;
}
//
@@ -1513,47 +1513,47 @@ STDMETHODIMP CMpeg2DecInputPin::QuerySupported(REFGUID PropSet, ULONG Id, ULONG*
//
CMpeg2DecOutputPin::CMpeg2DecOutputPin(CBaseVideoFilter* pFilter, HRESULT* phr, LPWSTR pName)
- : CBaseVideoOutputPin(NAME("CMpeg2DecOutputPin"), pFilter, phr, pName)
+ : CBaseVideoOutputPin(NAME("CMpeg2DecOutputPin"), pFilter, phr, pName)
{
}
HRESULT CMpeg2DecOutputPin::Active()
{
- CAutoLock cAutoLock(m_pLock);
+ CAutoLock cAutoLock(m_pLock);
- // TODO
+ // TODO
- if (m_Connected && !m_pOutputQueue) {
- HRESULT hr = NOERROR;
+ if (m_Connected && !m_pOutputQueue) {
+ HRESULT hr = NOERROR;
- m_pOutputQueue.Attach(DNew COutputQueue(m_Connected, &hr));
- if (!m_pOutputQueue) {
- hr = E_OUTOFMEMORY;
- }
+ m_pOutputQueue.Attach(DNew COutputQueue(m_Connected, &hr));
+ if (!m_pOutputQueue) {
+ hr = E_OUTOFMEMORY;
+ }
- if (FAILED(hr)) {
- m_pOutputQueue.Free();
- return hr;
- }
- }
+ if (FAILED(hr)) {
+ m_pOutputQueue.Free();
+ return hr;
+ }
+ }
- return __super::Active();
+ return __super::Active();
}
HRESULT CMpeg2DecOutputPin::Inactive()
{
- CAutoLock cAutoLock(m_pLock);
- m_pOutputQueue.Free();
- return __super::Inactive();
+ CAutoLock cAutoLock(m_pLock);
+ m_pOutputQueue.Free();
+ return __super::Inactive();
}
HRESULT CMpeg2DecOutputPin::Deliver(IMediaSample* pMediaSample)
{
- if (!m_pOutputQueue) {
- return NOERROR;
- }
- pMediaSample->AddRef();
- return m_pOutputQueue->Receive(pMediaSample);
+ if (!m_pOutputQueue) {
+ return NOERROR;
+ }
+ pMediaSample->AddRef();
+ return m_pOutputQueue->Receive(pMediaSample);
}
#define CallQueue(call) \
@@ -1563,22 +1563,22 @@ HRESULT CMpeg2DecOutputPin::Deliver(IMediaSample* pMediaSample)
HRESULT CMpeg2DecOutputPin::DeliverEndOfStream()
{
- CallQueue(EOS());
+ CallQueue(EOS());
}
HRESULT CMpeg2DecOutputPin::DeliverBeginFlush()
{
- CallQueue(BeginFlush());
+ CallQueue(BeginFlush());
}
HRESULT CMpeg2DecOutputPin::DeliverEndFlush()
{
- CallQueue(EndFlush());
+ CallQueue(EndFlush());
}
HRESULT CMpeg2DecOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- CallQueue(NewSegment(tStart, tStop, dRate));
+ CallQueue(NewSegment(tStart, tStop, dRate));
}
@@ -1589,767 +1589,767 @@ HRESULT CMpeg2DecOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_T
#define PTS2RT(pts) (10000i64*pts/90)
CSubpicInputPin::CSubpicInputPin(CTransformFilter* pFilter, HRESULT* phr)
- : CMpeg2DecInputPin(pFilter, phr, L"SubPicture")
- , m_spon(TRUE)
- , m_fsppal(false)
+ : CMpeg2DecInputPin(pFilter, phr, L"SubPicture")
+ , m_spon(TRUE)
+ , m_fsppal(false)
{
- m_sppal[0].Y = 0x00;
- m_sppal[0].U = m_sppal[0].V = 0x80;
- m_sppal[1].Y = 0xe0;
- m_sppal[1].U = m_sppal[1].V = 0x80;
- m_sppal[2].Y = 0x80;
- m_sppal[2].U = m_sppal[2].V = 0x80;
- m_sppal[3].Y = 0x20;
- m_sppal[3].U = m_sppal[3].V = 0x80;
+ m_sppal[0].Y = 0x00;
+ m_sppal[0].U = m_sppal[0].V = 0x80;
+ m_sppal[1].Y = 0xe0;
+ m_sppal[1].U = m_sppal[1].V = 0x80;
+ m_sppal[2].Y = 0x80;
+ m_sppal[2].U = m_sppal[2].V = 0x80;
+ m_sppal[3].Y = 0x20;
+ m_sppal[3].U = m_sppal[3].V = 0x80;
}
HRESULT CSubpicInputPin::CheckMediaType(const CMediaType* mtIn)
{
- return (mtIn->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK
- || mtIn->majortype == MEDIATYPE_MPEG2_PACK
- || mtIn->majortype == MEDIATYPE_MPEG2_PES
- || mtIn->majortype == MEDIATYPE_Video)
- && (mtIn->subtype == MEDIASUBTYPE_DVD_SUBPICTURE
- || mtIn->subtype == MEDIASUBTYPE_CVD_SUBPICTURE
- || mtIn->subtype == MEDIASUBTYPE_SVCD_SUBPICTURE)
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ return (mtIn->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK
+ || mtIn->majortype == MEDIATYPE_MPEG2_PACK
+ || mtIn->majortype == MEDIATYPE_MPEG2_PES
+ || mtIn->majortype == MEDIATYPE_Video)
+ && (mtIn->subtype == MEDIASUBTYPE_DVD_SUBPICTURE
+ || mtIn->subtype == MEDIASUBTYPE_CVD_SUBPICTURE
+ || mtIn->subtype == MEDIASUBTYPE_SVCD_SUBPICTURE)
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CSubpicInputPin::SetMediaType(const CMediaType* mtIn)
{
- return CBasePin::SetMediaType(mtIn);
+ return CBasePin::SetMediaType(mtIn);
}
bool CSubpicInputPin::HasAnythingToRender(REFERENCE_TIME rt)
{
- if (!IsConnected()) {
- return false;
- }
+ if (!IsConnected()) {
+ return false;
+ }
- CAutoLock cAutoLock(&m_csReceive);
+ CAutoLock cAutoLock(&m_csReceive);
- POSITION pos = m_sps.GetHeadPosition();
- while (pos) {
- spu* sp = m_sps.GetNext(pos);
- if (sp->m_rtStart <= rt && rt < sp->m_rtStop && (/*sp->m_psphli ||*/ sp->m_fForced || m_spon)) {
- return true;
- }
- }
+ POSITION pos = m_sps.GetHeadPosition();
+ while (pos) {
+ spu* sp = m_sps.GetNext(pos);
+ if (sp->m_rtStart <= rt && rt < sp->m_rtStop && (/*sp->m_psphli ||*/ sp->m_fForced || m_spon)) {
+ return true;
+ }
+ }
- return false;
+ return false;
}
void CSubpicInputPin::RenderSubpics(REFERENCE_TIME rt, BYTE** yuv, int w, int h)
{
- CAutoLock cAutoLock(&m_csReceive);
+ CAutoLock cAutoLock(&m_csReceive);
- POSITION pos;
+ POSITION pos;
- // remove no longer needed things first
- pos = m_sps.GetHeadPosition();
- while (pos) {
- POSITION cur = pos;
- spu* sp = m_sps.GetNext(pos);
- if (sp->m_rtStop <= rt) {
- m_sps.RemoveAt(cur);
- }
- }
+ // remove no longer needed things first
+ pos = m_sps.GetHeadPosition();
+ while (pos) {
+ POSITION cur = pos;
+ spu* sp = m_sps.GetNext(pos);
+ if (sp->m_rtStop <= rt) {
+ m_sps.RemoveAt(cur);
+ }
+ }
- pos = m_sps.GetHeadPosition();
- while (pos) {
- spu* sp = m_sps.GetNext(pos);
- if (sp->m_rtStart <= rt && rt < sp->m_rtStop
- && (m_spon || sp->m_fForced && ((static_cast<CMpeg2DecFilter*>(m_pFilter))->IsForcedSubtitlesEnabled() || sp->m_psphli))) {
- sp->Render(rt, yuv, w, h, m_sppal, m_fsppal);
- }
- }
+ pos = m_sps.GetHeadPosition();
+ while (pos) {
+ spu* sp = m_sps.GetNext(pos);
+ if (sp->m_rtStart <= rt && rt < sp->m_rtStop
+ && (m_spon || sp->m_fForced && ((static_cast<CMpeg2DecFilter*>(m_pFilter))->IsForcedSubtitlesEnabled() || sp->m_psphli))) {
+ sp->Render(rt, yuv, w, h, m_sppal, m_fsppal);
+ }
+ }
}
HRESULT CSubpicInputPin::Transform(IMediaSample* pSample)
{
- HRESULT hr;
+ HRESULT hr;
- AM_MEDIA_TYPE* pmt;
- if (SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
- CMediaType mt(*pmt);
- SetMediaType(&mt);
- DeleteMediaType(pmt);
- }
+ AM_MEDIA_TYPE* pmt;
+ if (SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
+ CMediaType mt(*pmt);
+ SetMediaType(&mt);
+ DeleteMediaType(pmt);
+ }
- BYTE* pDataIn = NULL;
- if (FAILED(hr = pSample->GetPointer(&pDataIn))) {
- return hr;
- }
+ BYTE* pDataIn = NULL;
+ if (FAILED(hr = pSample->GetPointer(&pDataIn))) {
+ return hr;
+ }
- long len = pSample->GetActualDataLength();
+ long len = pSample->GetActualDataLength();
- StripPacket(pDataIn, len);
+ StripPacket(pDataIn, len);
- if (len <= 0) {
- return S_FALSE;
- }
+ if (len <= 0) {
+ return S_FALSE;
+ }
- if (m_mt.subtype == MEDIASUBTYPE_SVCD_SUBPICTURE) {
- pDataIn += 4;
- len -= 4;
- }
+ if (m_mt.subtype == MEDIASUBTYPE_SVCD_SUBPICTURE) {
+ pDataIn += 4;
+ len -= 4;
+ }
- if (len <= 0) {
- return S_FALSE;
- }
+ if (len <= 0) {
+ return S_FALSE;
+ }
- CAutoLock cAutoLock(&m_csReceive);
+ CAutoLock cAutoLock(&m_csReceive);
- REFERENCE_TIME rtStart = 0, rtStop = 0;
- hr = pSample->GetTime(&rtStart, &rtStop);
+ REFERENCE_TIME rtStart = 0, rtStop = 0;
+ hr = pSample->GetTime(&rtStart, &rtStop);
- bool fRefresh = false;
+ bool fRefresh = false;
- if (FAILED(hr)) {
- if (!m_sps.IsEmpty()) {
- spu* sp = m_sps.GetTail();
- sp->SetCount(sp->GetCount() + len);
- memcpy(sp->GetData() + sp->GetCount() - len, pDataIn, len);
- }
- } else {
- POSITION pos = m_sps.GetTailPosition();
- while (pos) {
- spu* sp = m_sps.GetPrev(pos);
- if (sp->m_rtStop == _I64_MAX) {
- sp->m_rtStop = rtStart;
- break;
- }
- }
+ if (FAILED(hr)) {
+ if (!m_sps.IsEmpty()) {
+ spu* sp = m_sps.GetTail();
+ sp->SetCount(sp->GetCount() + len);
+ memcpy(sp->GetData() + sp->GetCount() - len, pDataIn, len);
+ }
+ } else {
+ POSITION pos = m_sps.GetTailPosition();
+ while (pos) {
+ spu* sp = m_sps.GetPrev(pos);
+ if (sp->m_rtStop == _I64_MAX) {
+ sp->m_rtStop = rtStart;
+ break;
+ }
+ }
- CAutoPtr<spu> p;
+ CAutoPtr<spu> p;
- if (m_mt.subtype == MEDIASUBTYPE_DVD_SUBPICTURE) {
- p.Attach(DNew dvdspu());
- } else if (m_mt.subtype == MEDIASUBTYPE_CVD_SUBPICTURE) {
- p.Attach(DNew cvdspu());
- } else if (m_mt.subtype == MEDIASUBTYPE_SVCD_SUBPICTURE) {
- p.Attach(DNew svcdspu());
- } else {
- return E_FAIL;
- }
+ if (m_mt.subtype == MEDIASUBTYPE_DVD_SUBPICTURE) {
+ p.Attach(DNew dvdspu());
+ } else if (m_mt.subtype == MEDIASUBTYPE_CVD_SUBPICTURE) {
+ p.Attach(DNew cvdspu());
+ } else if (m_mt.subtype == MEDIASUBTYPE_SVCD_SUBPICTURE) {
+ p.Attach(DNew svcdspu());
+ } else {
+ return E_FAIL;
+ }
- p->m_rtStart = rtStart;
- p->m_rtStop = _I64_MAX;
+ p->m_rtStart = rtStart;
+ p->m_rtStop = _I64_MAX;
- p->SetCount(len);
- memcpy(p->GetData(), pDataIn, len);
+ p->SetCount(len);
+ memcpy(p->GetData(), pDataIn, len);
- if (m_sphli && p->m_rtStart == PTS2RT(m_sphli->StartPTM)) {
- p->m_psphli = m_sphli;
- fRefresh = true;
- }
+ if (m_sphli && p->m_rtStart == PTS2RT(m_sphli->StartPTM)) {
+ p->m_psphli = m_sphli;
+ fRefresh = true;
+ }
- m_sps.AddTail(p);
- }
+ m_sps.AddTail(p);
+ }
- if (!m_sps.IsEmpty()) {
- m_sps.GetTail()->Parse();
- }
+ if (!m_sps.IsEmpty()) {
+ m_sps.GetTail()->Parse();
+ }
- if (fRefresh) {
- //((CMpeg2DecFilter*)m_pFilter)->Deliver(true);
- }
+ if (fRefresh) {
+ //((CMpeg2DecFilter*)m_pFilter)->Deliver(true);
+ }
- return S_FALSE;
+ return S_FALSE;
}
STDMETHODIMP CSubpicInputPin::EndFlush()
{
- CAutoLock cAutoLock(&m_csReceive);
- m_sps.RemoveAll();
- return S_OK;
+ CAutoLock cAutoLock(&m_csReceive);
+ m_sps.RemoveAll();
+ return S_OK;
}
// IKsPropertySet
STDMETHODIMP CSubpicInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength)
{
- if (PropSet != AM_KSPROPSETID_DvdSubPic) {
- return __super::Set(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength);
- }
-
- bool fRefresh = false;
-
- switch (Id) {
- case AM_PROPERTY_DVDSUBPIC_PALETTE: {
- CAutoLock cAutoLock(&m_csReceive);
-
- AM_PROPERTY_SPPAL* pSPPAL = (AM_PROPERTY_SPPAL*)pPropertyData;
- memcpy(m_sppal, pSPPAL->sppal, sizeof(AM_PROPERTY_SPPAL));
- m_fsppal = true;
-
- DbgLog((LOG_TRACE, 0, _T("new palette")));
- }
- break;
- case AM_PROPERTY_DVDSUBPIC_HLI: {
- CAutoLock cAutoLock(&m_csReceive);
-
- AM_PROPERTY_SPHLI* pSPHLI = (AM_PROPERTY_SPHLI*)pPropertyData;
-
- m_sphli.Free();
-
- if (pSPHLI->HLISS) {
- POSITION pos = m_sps.GetHeadPosition();
- while (pos) {
- spu* sp = m_sps.GetNext(pos);
- if (sp->m_rtStart <= PTS2RT(pSPHLI->StartPTM) && PTS2RT(pSPHLI->StartPTM) < sp->m_rtStop) {
- fRefresh = true;
- sp->m_psphli.Free();
- sp->m_psphli.Attach(DNew AM_PROPERTY_SPHLI);
- memcpy((AM_PROPERTY_SPHLI*)sp->m_psphli, pSPHLI, sizeof(AM_PROPERTY_SPHLI));
- }
- }
-
- if (!fRefresh) { // save it for later, a subpic might be late for this hli
- m_sphli.Attach(DNew AM_PROPERTY_SPHLI);
- memcpy((AM_PROPERTY_SPHLI*)m_sphli, pSPHLI, sizeof(AM_PROPERTY_SPHLI));
- }
- } else {
- POSITION pos = m_sps.GetHeadPosition();
- while (pos) {
- spu* sp = m_sps.GetNext(pos);
- fRefresh |= !!sp->m_psphli;
- sp->m_psphli.Free();
- }
- }
-
- if (pSPHLI->HLISS)
- DbgLog((LOG_TRACE, 0, _T("hli: %I64d - %I64d, (%d,%d) - (%d,%d)"),
- PTS2RT(pSPHLI->StartPTM)/10000, PTS2RT(pSPHLI->EndPTM)/10000,
- pSPHLI->StartX, pSPHLI->StartY, pSPHLI->StopX, pSPHLI->StopY));
- }
- break;
- case AM_PROPERTY_DVDSUBPIC_COMPOSIT_ON: {
- CAutoLock cAutoLock(&m_csReceive);
-
- AM_PROPERTY_COMPOSIT_ON* pCompositOn = (AM_PROPERTY_COMPOSIT_ON*)pPropertyData;
- m_spon = *pCompositOn;
- }
- break;
- default:
- return E_PROP_ID_UNSUPPORTED;
- }
-
- if (fRefresh) {
- (static_cast<CMpeg2DecFilter*>(m_pFilter))->Deliver(true);
- }
-
- return S_OK;
+ if (PropSet != AM_KSPROPSETID_DvdSubPic) {
+ return __super::Set(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength);
+ }
+
+ bool fRefresh = false;
+
+ switch (Id) {
+ case AM_PROPERTY_DVDSUBPIC_PALETTE: {
+ CAutoLock cAutoLock(&m_csReceive);
+
+ AM_PROPERTY_SPPAL* pSPPAL = (AM_PROPERTY_SPPAL*)pPropertyData;
+ memcpy(m_sppal, pSPPAL->sppal, sizeof(AM_PROPERTY_SPPAL));
+ m_fsppal = true;
+
+ DbgLog((LOG_TRACE, 0, _T("new palette")));
+ }
+ break;
+ case AM_PROPERTY_DVDSUBPIC_HLI: {
+ CAutoLock cAutoLock(&m_csReceive);
+
+ AM_PROPERTY_SPHLI* pSPHLI = (AM_PROPERTY_SPHLI*)pPropertyData;
+
+ m_sphli.Free();
+
+ if (pSPHLI->HLISS) {
+ POSITION pos = m_sps.GetHeadPosition();
+ while (pos) {
+ spu* sp = m_sps.GetNext(pos);
+ if (sp->m_rtStart <= PTS2RT(pSPHLI->StartPTM) && PTS2RT(pSPHLI->StartPTM) < sp->m_rtStop) {
+ fRefresh = true;
+ sp->m_psphli.Free();
+ sp->m_psphli.Attach(DNew AM_PROPERTY_SPHLI);
+ memcpy((AM_PROPERTY_SPHLI*)sp->m_psphli, pSPHLI, sizeof(AM_PROPERTY_SPHLI));
+ }
+ }
+
+ if (!fRefresh) { // save it for later, a subpic might be late for this hli
+ m_sphli.Attach(DNew AM_PROPERTY_SPHLI);
+ memcpy((AM_PROPERTY_SPHLI*)m_sphli, pSPHLI, sizeof(AM_PROPERTY_SPHLI));
+ }
+ } else {
+ POSITION pos = m_sps.GetHeadPosition();
+ while (pos) {
+ spu* sp = m_sps.GetNext(pos);
+ fRefresh |= !!sp->m_psphli;
+ sp->m_psphli.Free();
+ }
+ }
+
+ if (pSPHLI->HLISS)
+ DbgLog((LOG_TRACE, 0, _T("hli: %I64d - %I64d, (%d,%d) - (%d,%d)"),
+ PTS2RT(pSPHLI->StartPTM) / 10000, PTS2RT(pSPHLI->EndPTM) / 10000,
+ pSPHLI->StartX, pSPHLI->StartY, pSPHLI->StopX, pSPHLI->StopY));
+ }
+ break;
+ case AM_PROPERTY_DVDSUBPIC_COMPOSIT_ON: {
+ CAutoLock cAutoLock(&m_csReceive);
+
+ AM_PROPERTY_COMPOSIT_ON* pCompositOn = (AM_PROPERTY_COMPOSIT_ON*)pPropertyData;
+ m_spon = *pCompositOn;
+ }
+ break;
+ default:
+ return E_PROP_ID_UNSUPPORTED;
+ }
+
+ if (fRefresh) {
+ (static_cast<CMpeg2DecFilter*>(m_pFilter))->Deliver(true);
+ }
+
+ return S_OK;
}
STDMETHODIMP CSubpicInputPin::QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport)
{
- if (PropSet != AM_KSPROPSETID_DvdSubPic) {
- return __super::QuerySupported(PropSet, Id, pTypeSupport);
- }
+ if (PropSet != AM_KSPROPSETID_DvdSubPic) {
+ return __super::QuerySupported(PropSet, Id, pTypeSupport);
+ }
- switch (Id) {
- case AM_PROPERTY_DVDSUBPIC_PALETTE:
- *pTypeSupport = KSPROPERTY_SUPPORT_SET;
- break;
- case AM_PROPERTY_DVDSUBPIC_HLI:
- *pTypeSupport = KSPROPERTY_SUPPORT_SET;
- break;
- case AM_PROPERTY_DVDSUBPIC_COMPOSIT_ON:
- *pTypeSupport = KSPROPERTY_SUPPORT_SET;
- break;
- default:
- return E_PROP_ID_UNSUPPORTED;
- }
+ switch (Id) {
+ case AM_PROPERTY_DVDSUBPIC_PALETTE:
+ *pTypeSupport = KSPROPERTY_SUPPORT_SET;
+ break;
+ case AM_PROPERTY_DVDSUBPIC_HLI:
+ *pTypeSupport = KSPROPERTY_SUPPORT_SET;
+ break;
+ case AM_PROPERTY_DVDSUBPIC_COMPOSIT_ON:
+ *pTypeSupport = KSPROPERTY_SUPPORT_SET;
+ break;
+ default:
+ return E_PROP_ID_UNSUPPORTED;
+ }
- return S_OK;
+ return S_OK;
}
// CSubpicInputPin::spu
static __inline BYTE GetNibble(BYTE* p, DWORD* offset, int& nField, int& fAligned)
{
- BYTE ret = (p[offset[nField]] >> (fAligned << 2)) & 0x0f;
- offset[nField] += 1-fAligned;
- fAligned = !fAligned;
- return ret;
+ BYTE ret = (p[offset[nField]] >> (fAligned << 2)) & 0x0f;
+ offset[nField] += 1 - fAligned;
+ fAligned = !fAligned;
+ return ret;
}
static __inline BYTE GetHalfNibble(BYTE* p, DWORD* offset, int& nField, int& n)
{
- BYTE ret = (p[offset[nField]] >> (n << 1)) & 0x03;
- if (!n) {
- offset[nField]++;
- }
- n = (n-1+4)&3;
- return ret;
+ BYTE ret = (p[offset[nField]] >> (n << 1)) & 0x03;
+ if (!n) {
+ offset[nField]++;
+ }
+ n = (n - 1 + 4) & 3;
+ return ret;
}
static __inline void DrawPixel(BYTE** yuv, CPoint pt, int pitch, AM_DVD_YUV& c)
{
- if (c.Reserved == 0) {
- return;
- }
+ if (c.Reserved == 0) {
+ return;
+ }
- BYTE* p = &yuv[0][pt.y*pitch + pt.x];
- //*p = (*p*(15-contrast) + sppal[color].Y*contrast)>>4;
- *p -= (*p - c.Y) * c.Reserved >> 4;
+ BYTE* p = &yuv[0][pt.y * pitch + pt.x];
+ //*p = (*p*(15-contrast) + sppal[color].Y*contrast)>>4;
+ *p -= (*p - c.Y) * c.Reserved >> 4;
- if (pt.y&1) {
- return; // since U/V is half res there is no need to overwrite the same line again
- }
+ if (pt.y & 1) {
+ return; // since U/V is half res there is no need to overwrite the same line again
+ }
- pt.x = (pt.x + 1) / 2;
- pt.y = (pt.y /*+ 1*/) / 2; // only paint the upper field always, don't round it
- pitch /= 2;
+ pt.x = (pt.x + 1) / 2;
+ pt.y = (pt.y /*+ 1*/) / 2; // only paint the upper field always, don't round it
+ pitch /= 2;
- // U/V is exchanged? wierd but looks true when comparing the outputted colors from other decoders
+ // U/V is exchanged? wierd but looks true when comparing the outputted colors from other decoders
- p = &yuv[1][pt.y*pitch + pt.x];
- //*p = (BYTE)(((((int)*p-0x80)*(15-contrast) + ((int)sppal[color].V-0x80)*contrast) >> 4) + 0x80);
- *p -= (*p - c.V) * c.Reserved >> 4;
+ p = &yuv[1][pt.y * pitch + pt.x];
+ //*p = (BYTE)(((((int)*p-0x80)*(15-contrast) + ((int)sppal[color].V-0x80)*contrast) >> 4) + 0x80);
+ *p -= (*p - c.V) * c.Reserved >> 4;
- p = &yuv[2][pt.y*pitch + pt.x];
- //*p = (BYTE)(((((int)*p-0x80)*(15-contrast) + ((int)sppal[color].U-0x80)*contrast) >> 4) + 0x80);
- *p -= (*p - c.U) * c.Reserved >> 4;
+ p = &yuv[2][pt.y * pitch + pt.x];
+ //*p = (BYTE)(((((int)*p-0x80)*(15-contrast) + ((int)sppal[color].U-0x80)*contrast) >> 4) + 0x80);
+ *p -= (*p - c.U) * c.Reserved >> 4;
- // Neighter of the blending formulas are accurate (">>4" should be "/15").
- // Even though the second one is a bit worse, since we are scaling the difference only,
- // the error is still not noticable.
+ // Neighter of the blending formulas are accurate (">>4" should be "/15").
+ // Even though the second one is a bit worse, since we are scaling the difference only,
+ // the error is still not noticable.
}
static __inline void DrawPixels(BYTE** yuv, int pitch, CPoint pt, int len, AM_DVD_YUV& c, CRect& rc)
{
- if (pt.y < rc.top || pt.y >= rc.bottom) {
- return;
- }
- if (pt.x < rc.left) {
- len -= rc.left - pt.x;
- pt.x = rc.left;
- }
- if (pt.x + len > rc.right) {
- len = rc.right - pt.x;
- }
- if (len <= 0 || pt.x >= rc.right) {
- return;
- }
-
- if (c.Reserved == 0) {
- if (rc.IsRectEmpty()) {
- return;
- }
-
- if (pt.y < rc.top || pt.y >= rc.bottom
- || pt.x+len < rc.left || pt.x >= rc.right) {
- return;
- }
- }
-
- while (len-- > 0) {
- DrawPixel(yuv, pt, pitch, c);
- pt.x++;
- }
+ if (pt.y < rc.top || pt.y >= rc.bottom) {
+ return;
+ }
+ if (pt.x < rc.left) {
+ len -= rc.left - pt.x;
+ pt.x = rc.left;
+ }
+ if (pt.x + len > rc.right) {
+ len = rc.right - pt.x;
+ }
+ if (len <= 0 || pt.x >= rc.right) {
+ return;
+ }
+
+ if (c.Reserved == 0) {
+ if (rc.IsRectEmpty()) {
+ return;
+ }
+
+ if (pt.y < rc.top || pt.y >= rc.bottom
+ || pt.x + len < rc.left || pt.x >= rc.right) {
+ return;
+ }
+ }
+
+ while (len-- > 0) {
+ DrawPixel(yuv, pt, pitch, c);
+ pt.x++;
+ }
}
// CSubpicInputPin::dvdspu
bool CSubpicInputPin::dvdspu::Parse()
{
- m_offsets.RemoveAll();
+ m_offsets.RemoveAll();
- BYTE* p = GetData();
+ BYTE* p = GetData();
- WORD packetsize = (p[0]<<8)|p[1];
- WORD datasize = (p[2]<<8)|p[3];
+ WORD packetsize = (p[0] << 8) | p[1];
+ WORD datasize = (p[2] << 8) | p[3];
- if (packetsize > GetCount() || datasize > packetsize) {
- return false;
- }
+ if (packetsize > GetCount() || datasize > packetsize) {
+ return false;
+ }
- int i, next = datasize;
+ int i, next = datasize;
#define GetWORD (p[i]<<8)|p[i+1]; i += 2
- do {
- i = next;
-
- int pts = GetWORD;
- next = GetWORD;
-
- if (next > packetsize || next < datasize) {
- return false;
- }
-
- REFERENCE_TIME rt = m_rtStart + 1024*PTS2RT(pts);
-
- for (bool fBreak = false; !fBreak; ) {
- int len = 0;
-
- switch (p[i]) {
- case 0x00:
- len = 0;
- break;
- case 0x01:
- len = 0;
- break;
- case 0x02:
- len = 0;
- break;
- case 0x03:
- len = 2;
- break;
- case 0x04:
- len = 2;
- break;
- case 0x05:
- len = 6;
- break;
- case 0x06:
- len = 4;
- break;
- case 0x07:
- len = 0;
- break; // TODO
- default:
- len = 0;
- break;
- }
-
- if (i+len >= packetsize) {
- TRACE(_T("Warning: Wrong subpicture parameter block ending\n"));
- break;
- }
-
- switch (p[i++]) {
- case 0x00: // forced start displaying
- m_fForced = true;
- break;
- case 0x01: // normal start displaying
- m_fForced = false;
- break;
- case 0x02: // stop displaying
- m_rtStop = rt;
- break;
- case 0x03:
- m_sphli.ColCon.emph2col = p[i]>>4;
- m_sphli.ColCon.emph1col = p[i]&0xf;
- m_sphli.ColCon.patcol = p[i+1]>>4;
- m_sphli.ColCon.backcol = p[i+1]&0xf;
- i += 2;
- break;
- case 0x04:
- m_sphli.ColCon.emph2con = p[i]>>4;
- m_sphli.ColCon.emph1con = p[i]&0xf;
- m_sphli.ColCon.patcon = p[i+1]>>4;
- m_sphli.ColCon.backcon = p[i+1]&0xf;
- i += 2;
- break;
- case 0x05:
- m_sphli.StartX = (p[i]<<4) + (p[i+1]>>4);
- m_sphli.StopX = ((p[i+1]&0x0f)<<8) + p[i+2]+1;
- m_sphli.StartY = (p[i+3]<<4) + (p[i+4]>>4);
- m_sphli.StopY = ((p[i+4]&0x0f)<<8) + p[i+5]+1;
- i += 6;
- break;
- case 0x06:
- m_offset[0] = GetWORD;
- m_offset[1] = GetWORD;
- break;
- case 0x07:
- // TODO
- break;
- case 0xff: // end of ctrlblk
- fBreak = true;
- continue;
- default: // skip this ctrlblk
- fBreak = true;
- break;
- }
- }
-
- offset_t o = {rt, m_sphli};
- m_offsets.AddTail(o); // is it always going to be sorted?
- } while (i <= next && i < packetsize);
-
- return true;
+ do {
+ i = next;
+
+ int pts = GetWORD;
+ next = GetWORD;
+
+ if (next > packetsize || next < datasize) {
+ return false;
+ }
+
+ REFERENCE_TIME rt = m_rtStart + 1024 * PTS2RT(pts);
+
+ for (bool fBreak = false; !fBreak;) {
+ int len = 0;
+
+ switch (p[i]) {
+ case 0x00:
+ len = 0;
+ break;
+ case 0x01:
+ len = 0;
+ break;
+ case 0x02:
+ len = 0;
+ break;
+ case 0x03:
+ len = 2;
+ break;
+ case 0x04:
+ len = 2;
+ break;
+ case 0x05:
+ len = 6;
+ break;
+ case 0x06:
+ len = 4;
+ break;
+ case 0x07:
+ len = 0;
+ break; // TODO
+ default:
+ len = 0;
+ break;
+ }
+
+ if (i + len >= packetsize) {
+ TRACE(_T("Warning: Wrong subpicture parameter block ending\n"));
+ break;
+ }
+
+ switch (p[i++]) {
+ case 0x00: // forced start displaying
+ m_fForced = true;
+ break;
+ case 0x01: // normal start displaying
+ m_fForced = false;
+ break;
+ case 0x02: // stop displaying
+ m_rtStop = rt;
+ break;
+ case 0x03:
+ m_sphli.ColCon.emph2col = p[i] >> 4;
+ m_sphli.ColCon.emph1col = p[i] & 0xf;
+ m_sphli.ColCon.patcol = p[i + 1] >> 4;
+ m_sphli.ColCon.backcol = p[i + 1] & 0xf;
+ i += 2;
+ break;
+ case 0x04:
+ m_sphli.ColCon.emph2con = p[i] >> 4;
+ m_sphli.ColCon.emph1con = p[i] & 0xf;
+ m_sphli.ColCon.patcon = p[i + 1] >> 4;
+ m_sphli.ColCon.backcon = p[i + 1] & 0xf;
+ i += 2;
+ break;
+ case 0x05:
+ m_sphli.StartX = (p[i] << 4) + (p[i + 1] >> 4);
+ m_sphli.StopX = ((p[i + 1] & 0x0f) << 8) + p[i + 2] + 1;
+ m_sphli.StartY = (p[i + 3] << 4) + (p[i + 4] >> 4);
+ m_sphli.StopY = ((p[i + 4] & 0x0f) << 8) + p[i + 5] + 1;
+ i += 6;
+ break;
+ case 0x06:
+ m_offset[0] = GetWORD;
+ m_offset[1] = GetWORD;
+ break;
+ case 0x07:
+ // TODO
+ break;
+ case 0xff: // end of ctrlblk
+ fBreak = true;
+ continue;
+ default: // skip this ctrlblk
+ fBreak = true;
+ break;
+ }
+ }
+
+ offset_t o = {rt, m_sphli};
+ m_offsets.AddTail(o); // is it always going to be sorted?
+ } while (i <= next && i < packetsize);
+
+ return true;
}
void CSubpicInputPin::dvdspu::Render(REFERENCE_TIME rt, BYTE** yuv, int w, int h, AM_DVD_YUV* sppal, bool fsppal)
{
- BYTE* p = GetData();
- DWORD offset[2] = {m_offset[0], m_offset[1]};
-
- AM_PROPERTY_SPHLI sphli = m_sphli;
- CPoint pt(sphli.StartX, sphli.StartY);
- CRect rc(pt, CPoint(sphli.StopX, sphli.StopY));
-
- CRect rcclip(0, 0, w, h);
- rcclip &= rc;
-
- if (m_psphli) {
- rcclip &= CRect(m_psphli->StartX, m_psphli->StartY, m_psphli->StopX, m_psphli->StopY);
- sphli = *m_psphli;
- } else if (m_offsets.GetCount() > 1) {
- POSITION pos = m_offsets.GetTailPosition();
- while (pos) {
- const offset_t& o = m_offsets.GetPrev(pos);
- if (rt >= o.rt) {
- sphli = o.sphli;
- break;
- }
- }
- }
-
- AM_DVD_YUV pal[4];
- pal[0] = sppal[fsppal ? sphli.ColCon.backcol : 0];
- pal[0].Reserved = sphli.ColCon.backcon;
- pal[1] = sppal[fsppal ? sphli.ColCon.patcol : 1];
- pal[1].Reserved = sphli.ColCon.patcon;
- pal[2] = sppal[fsppal ? sphli.ColCon.emph1col : 2];
- pal[2].Reserved = sphli.ColCon.emph1con;
- pal[3] = sppal[fsppal ? sphli.ColCon.emph2col : 3];
- pal[3].Reserved = sphli.ColCon.emph2con;
-
- int nField = 0;
- int fAligned = 1;
-
- DWORD end[2] = {offset[1], (p[2]<<8)|p[3]};
-
- while ((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1])) {
- DWORD code;
-
- if ((code = GetNibble(p, offset, nField, fAligned)) >= 0x4
- || (code = (code << 4) | GetNibble(p, offset, nField, fAligned)) >= 0x10
- || (code = (code << 4) | GetNibble(p, offset, nField, fAligned)) >= 0x40
- || (code = (code << 4) | GetNibble(p, offset, nField, fAligned)) >= 0x100) {
- DrawPixels(yuv, w, pt, code >> 2, pal[code&3], rcclip);
- if ((pt.x += code >> 2) < rc.right) {
- continue;
- }
- }
-
- DrawPixels(yuv, w, pt, rc.right - pt.x, pal[code&3], rcclip);
-
- if (!fAligned) {
- GetNibble(p, offset, nField, fAligned); // align to byte
- }
-
- pt.x = rc.left;
- pt.y++;
- nField = 1 - nField;
- }
+ BYTE* p = GetData();
+ DWORD offset[2] = {m_offset[0], m_offset[1]};
+
+ AM_PROPERTY_SPHLI sphli = m_sphli;
+ CPoint pt(sphli.StartX, sphli.StartY);
+ CRect rc(pt, CPoint(sphli.StopX, sphli.StopY));
+
+ CRect rcclip(0, 0, w, h);
+ rcclip &= rc;
+
+ if (m_psphli) {
+ rcclip &= CRect(m_psphli->StartX, m_psphli->StartY, m_psphli->StopX, m_psphli->StopY);
+ sphli = *m_psphli;
+ } else if (m_offsets.GetCount() > 1) {
+ POSITION pos = m_offsets.GetTailPosition();
+ while (pos) {
+ const offset_t& o = m_offsets.GetPrev(pos);
+ if (rt >= o.rt) {
+ sphli = o.sphli;
+ break;
+ }
+ }
+ }
+
+ AM_DVD_YUV pal[4];
+ pal[0] = sppal[fsppal ? sphli.ColCon.backcol : 0];
+ pal[0].Reserved = sphli.ColCon.backcon;
+ pal[1] = sppal[fsppal ? sphli.ColCon.patcol : 1];
+ pal[1].Reserved = sphli.ColCon.patcon;
+ pal[2] = sppal[fsppal ? sphli.ColCon.emph1col : 2];
+ pal[2].Reserved = sphli.ColCon.emph1con;
+ pal[3] = sppal[fsppal ? sphli.ColCon.emph2col : 3];
+ pal[3].Reserved = sphli.ColCon.emph2con;
+
+ int nField = 0;
+ int fAligned = 1;
+
+ DWORD end[2] = {offset[1], (p[2] << 8) | p[3]};
+
+ while ((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1])) {
+ DWORD code;
+
+ if ((code = GetNibble(p, offset, nField, fAligned)) >= 0x4
+ || (code = (code << 4) | GetNibble(p, offset, nField, fAligned)) >= 0x10
+ || (code = (code << 4) | GetNibble(p, offset, nField, fAligned)) >= 0x40
+ || (code = (code << 4) | GetNibble(p, offset, nField, fAligned)) >= 0x100) {
+ DrawPixels(yuv, w, pt, code >> 2, pal[code & 3], rcclip);
+ if ((pt.x += code >> 2) < rc.right) {
+ continue;
+ }
+ }
+
+ DrawPixels(yuv, w, pt, rc.right - pt.x, pal[code & 3], rcclip);
+
+ if (!fAligned) {
+ GetNibble(p, offset, nField, fAligned); // align to byte
+ }
+
+ pt.x = rc.left;
+ pt.y++;
+ nField = 1 - nField;
+ }
}
// CSubpicInputPin::cvdspu
bool CSubpicInputPin::cvdspu::Parse()
{
- BYTE* p = GetData();
-
- WORD packetsize = (p[0]<<8)|p[1];
- WORD datasize = (p[2]<<8)|p[3];
-
- if (packetsize > GetCount() || datasize > packetsize) {
- return false;
- }
-
- p = GetData() + datasize;
-
- for (int i = datasize, j = packetsize-4; i <= j; i+=4, p+=4) {
- switch (p[0]) {
- case 0x0c:
- break;
- case 0x04:
- m_rtStop = m_rtStart + 10000i64*((p[1]<<16)|(p[2]<<8)|p[3])/90;
- break;
- case 0x17:
- m_sphli.StartX = ((p[1]&0x0f)<<6) + (p[2]>>2);
- m_sphli.StartY = ((p[2]&0x03)<<8) + p[3];
- break;
- case 0x1f:
- m_sphli.StopX = ((p[1]&0x0f)<<6) + (p[2]>>2);
- m_sphli.StopY = ((p[2]&0x03)<<8) + p[3];
- break;
- case 0x24:
- case 0x25:
- case 0x26:
- case 0x27:
- m_sppal[0][p[0]-0x24].Y = p[1];
- m_sppal[0][p[0]-0x24].U = p[2];
- m_sppal[0][p[0]-0x24].V = p[3];
- break;
- case 0x2c:
- case 0x2d:
- case 0x2e:
- case 0x2f:
- m_sppal[1][p[0]-0x2c].Y = p[1];
- m_sppal[1][p[0]-0x2c].U = p[2];
- m_sppal[1][p[0]-0x2c].V = p[3];
- break;
- case 0x37:
- m_sppal[0][3].Reserved = p[2]>>4;
- m_sppal[0][2].Reserved = p[2]&0xf;
- m_sppal[0][1].Reserved = p[3]>>4;
- m_sppal[0][0].Reserved = p[3]&0xf;
- break;
- case 0x3f:
- m_sppal[1][3].Reserved = p[2]>>4;
- m_sppal[1][2].Reserved = p[2]&0xf;
- m_sppal[1][1].Reserved = p[3]>>4;
- m_sppal[1][0].Reserved = p[3]&0xf;
- break;
- case 0x47:
- m_offset[0] = (p[2]<<8)|p[3];
- break;
- case 0x4f:
- m_offset[1] = (p[2]<<8)|p[3];
- break;
- default:
- break;
- }
- }
-
- return true;
+ BYTE* p = GetData();
+
+ WORD packetsize = (p[0] << 8) | p[1];
+ WORD datasize = (p[2] << 8) | p[3];
+
+ if (packetsize > GetCount() || datasize > packetsize) {
+ return false;
+ }
+
+ p = GetData() + datasize;
+
+ for (int i = datasize, j = packetsize - 4; i <= j; i += 4, p += 4) {
+ switch (p[0]) {
+ case 0x0c:
+ break;
+ case 0x04:
+ m_rtStop = m_rtStart + 10000i64 * ((p[1] << 16) | (p[2] << 8) | p[3]) / 90;
+ break;
+ case 0x17:
+ m_sphli.StartX = ((p[1] & 0x0f) << 6) + (p[2] >> 2);
+ m_sphli.StartY = ((p[2] & 0x03) << 8) + p[3];
+ break;
+ case 0x1f:
+ m_sphli.StopX = ((p[1] & 0x0f) << 6) + (p[2] >> 2);
+ m_sphli.StopY = ((p[2] & 0x03) << 8) + p[3];
+ break;
+ case 0x24:
+ case 0x25:
+ case 0x26:
+ case 0x27:
+ m_sppal[0][p[0] - 0x24].Y = p[1];
+ m_sppal[0][p[0] - 0x24].U = p[2];
+ m_sppal[0][p[0] - 0x24].V = p[3];
+ break;
+ case 0x2c:
+ case 0x2d:
+ case 0x2e:
+ case 0x2f:
+ m_sppal[1][p[0] - 0x2c].Y = p[1];
+ m_sppal[1][p[0] - 0x2c].U = p[2];
+ m_sppal[1][p[0] - 0x2c].V = p[3];
+ break;
+ case 0x37:
+ m_sppal[0][3].Reserved = p[2] >> 4;
+ m_sppal[0][2].Reserved = p[2] & 0xf;
+ m_sppal[0][1].Reserved = p[3] >> 4;
+ m_sppal[0][0].Reserved = p[3] & 0xf;
+ break;
+ case 0x3f:
+ m_sppal[1][3].Reserved = p[2] >> 4;
+ m_sppal[1][2].Reserved = p[2] & 0xf;
+ m_sppal[1][1].Reserved = p[3] >> 4;
+ m_sppal[1][0].Reserved = p[3] & 0xf;
+ break;
+ case 0x47:
+ m_offset[0] = (p[2] << 8) | p[3];
+ break;
+ case 0x4f:
+ m_offset[1] = (p[2] << 8) | p[3];
+ break;
+ default:
+ break;
+ }
+ }
+
+ return true;
}
void CSubpicInputPin::cvdspu::Render(REFERENCE_TIME rt, BYTE** yuv, int w, int h, AM_DVD_YUV* sppal, bool fsppal)
{
- BYTE* p = GetData();
- DWORD offset[2] = {m_offset[0], m_offset[1]};
+ BYTE* p = GetData();
+ DWORD offset[2] = {m_offset[0], m_offset[1]};
- CRect rcclip(0, 0, w, h);
+ CRect rcclip(0, 0, w, h);
- /* FIXME: startx/y looks to be wrong in the sample I tested
- CPoint pt(m_sphli.StartX, m_sphli.StartY);
- CRect rc(pt, CPoint(m_sphli.StopX, m_sphli.StopY));
- */
+ /* FIXME: startx/y looks to be wrong in the sample I tested
+ CPoint pt(m_sphli.StartX, m_sphli.StartY);
+ CRect rc(pt, CPoint(m_sphli.StopX, m_sphli.StopY));
+ */
- CSize size(m_sphli.StopX - m_sphli.StartX, m_sphli.StopY - m_sphli.StartY);
- CPoint pt((rcclip.Width() - size.cx) / 2, (rcclip.Height()*3 - size.cy*1) / 4);
- CRect rc(pt, size);
+ CSize size(m_sphli.StopX - m_sphli.StartX, m_sphli.StopY - m_sphli.StartY);
+ CPoint pt((rcclip.Width() - size.cx) / 2, (rcclip.Height() * 3 - size.cy * 1) / 4);
+ CRect rc(pt, size);
- int nField = 0;
- int fAligned = 1;
+ int nField = 0;
+ int fAligned = 1;
- DWORD end[2] = {offset[1], (p[2]<<8)|p[3]};
+ DWORD end[2] = {offset[1], (p[2] << 8) | p[3]};
- while ((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1])) {
- BYTE code;
+ while ((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1])) {
+ BYTE code;
- if ((code = GetNibble(p, offset, nField, fAligned)) >= 0x4) {
- DrawPixels(yuv, w, pt, code >> 2, m_sppal[0][code&3], rcclip);
- pt.x += code >> 2;
- continue;
- }
+ if ((code = GetNibble(p, offset, nField, fAligned)) >= 0x4) {
+ DrawPixels(yuv, w, pt, code >> 2, m_sppal[0][code & 3], rcclip);
+ pt.x += code >> 2;
+ continue;
+ }
- code = GetNibble(p, offset, nField, fAligned);
- DrawPixels(yuv, w, pt, rc.right - pt.x, m_sppal[0][code&3], rcclip);
+ code = GetNibble(p, offset, nField, fAligned);
+ DrawPixels(yuv, w, pt, rc.right - pt.x, m_sppal[0][code & 3], rcclip);
- if (!fAligned) {
- GetNibble(p, offset, nField, fAligned); // align to byte
- }
+ if (!fAligned) {
+ GetNibble(p, offset, nField, fAligned); // align to byte
+ }
- pt.x = rc.left;
- pt.y++;
- nField = 1 - nField;
- }
+ pt.x = rc.left;
+ pt.y++;
+ nField = 1 - nField;
+ }
}
// CSubpicInputPin::svcdspu
bool CSubpicInputPin::svcdspu::Parse()
{
- BYTE* p = GetData();
- BYTE* p0 = p;
+ BYTE* p = GetData();
+ BYTE* p0 = p;
- if (GetCount() < 2) {
- return false;
- }
+ if (GetCount() < 2) {
+ return false;
+ }
- WORD packetsize = (p[0]<<8)|p[1];
- p += 2;
+ WORD packetsize = (p[0] << 8) | p[1];
+ p += 2;
- if (packetsize > GetCount()) {
- return false;
- }
+ if (packetsize > GetCount()) {
+ return false;
+ }
- bool duration = !!(*p++&0x04);
+ bool duration = !!(*p++ & 0x04);
- *p++; // unknown
+ *p++; // unknown
- if (duration) {
- m_rtStop = m_rtStart + 10000i64*((p[0]<<24)|(p[1]<<16)|(p[2]<<8)|p[3])/90;
- p += 4;
- }
+ if (duration) {
+ m_rtStop = m_rtStart + 10000i64 * ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]) / 90;
+ p += 4;
+ }
- m_sphli.StartX = m_sphli.StopX = (p[0]<<8)|p[1];
- p += 2;
- m_sphli.StartY = m_sphli.StopY = (p[0]<<8)|p[1];
- p += 2;
- m_sphli.StopX += (p[0]<<8)|p[1];
- p += 2;
- m_sphli.StopY += (p[0]<<8)|p[1];
- p += 2;
+ m_sphli.StartX = m_sphli.StopX = (p[0] << 8) | p[1];
+ p += 2;
+ m_sphli.StartY = m_sphli.StopY = (p[0] << 8) | p[1];
+ p += 2;
+ m_sphli.StopX += (p[0] << 8) | p[1];
+ p += 2;
+ m_sphli.StopY += (p[0] << 8) | p[1];
+ p += 2;
- for (int i = 0; i < 4; i++) {
- m_sppal[i].Y = *p++;
- m_sppal[i].U = *p++;
- m_sppal[i].V = *p++;
- m_sppal[i].Reserved = *p++ >> 4;
- }
+ for (int i = 0; i < 4; i++) {
+ m_sppal[i].Y = *p++;
+ m_sppal[i].U = *p++;
+ m_sppal[i].V = *p++;
+ m_sppal[i].Reserved = *p++ >> 4;
+ }
- if (*p++&0xc0) {
- p += 4; // duration of the shift operation should be here, but it is untested
- }
+ if (*p++ & 0xc0) {
+ p += 4; // duration of the shift operation should be here, but it is untested
+ }
- m_offset[1] = (p[0]<<8)|p[1];
- p += 2;
+ m_offset[1] = (p[0] << 8) | p[1];
+ p += 2;
- m_offset[0] = p - p0;
- m_offset[1] += m_offset[0];
+ m_offset[0] = p - p0;
+ m_offset[1] += m_offset[0];
- return true;
+ return true;
}
void CSubpicInputPin::svcdspu::Render(REFERENCE_TIME rt, BYTE** yuv, int w, int h, AM_DVD_YUV* sppal, bool fsppal)
{
- BYTE* p = GetData();
- DWORD offset[2] = {m_offset[0], m_offset[1]};
+ BYTE* p = GetData();
+ DWORD offset[2] = {m_offset[0], m_offset[1]};
- CRect rcclip(0, 0, w, h);
+ CRect rcclip(0, 0, w, h);
- /* FIXME: startx/y looks to be wrong in the sample I tested (yes, this one too!)
- CPoint pt(m_sphli.StartX, m_sphli.StartY);
- CRect rc(pt, CPoint(m_sphli.StopX, m_sphli.StopY));
- */
+ /* FIXME: startx/y looks to be wrong in the sample I tested (yes, this one too!)
+ CPoint pt(m_sphli.StartX, m_sphli.StartY);
+ CRect rc(pt, CPoint(m_sphli.StopX, m_sphli.StopY));
+ */
- CSize size(m_sphli.StopX - m_sphli.StartX, m_sphli.StopY - m_sphli.StartY);
- CPoint pt((rcclip.Width() - size.cx) / 2, (rcclip.Height()*3 - size.cy*1) / 4);
- CRect rc(pt, size);
+ CSize size(m_sphli.StopX - m_sphli.StartX, m_sphli.StopY - m_sphli.StartY);
+ CPoint pt((rcclip.Width() - size.cx) / 2, (rcclip.Height() * 3 - size.cy * 1) / 4);
+ CRect rc(pt, size);
- int nField = 0;
- int n = 3;
+ int nField = 0;
+ int n = 3;
- DWORD end[2] = {offset[1], (p[2]<<8)|p[3]};
+ DWORD end[2] = {offset[1], (p[2] << 8) | p[3]};
- while ((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1])) {
- BYTE code = GetHalfNibble(p, offset, nField, n);
- BYTE repeat = 1 + (code == 0 ? GetHalfNibble(p, offset, nField, n) : 0);
+ while ((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1])) {
+ BYTE code = GetHalfNibble(p, offset, nField, n);
+ BYTE repeat = 1 + (code == 0 ? GetHalfNibble(p, offset, nField, n) : 0);
- DrawPixels(yuv, w, pt, repeat, m_sppal[code&3], rcclip);
- if ((pt.x += repeat) < rc.right) {
- continue;
- }
+ DrawPixels(yuv, w, pt, repeat, m_sppal[code & 3], rcclip);
+ if ((pt.x += repeat) < rc.right) {
+ continue;
+ }
- while (n != 3) {
- GetHalfNibble(p, offset, nField, n); // align to byte
- }
+ while (n != 3) {
+ GetHalfNibble(p, offset, nField, n); // align to byte
+ }
- pt.x = rc.left;
- pt.y++;
- nField = 1 - nField;
- }
+ pt.x = rc.left;
+ pt.y++;
+ nField = 1 - nField;
+ }
}
//
@@ -2357,66 +2357,66 @@ void CSubpicInputPin::svcdspu::Render(REFERENCE_TIME rt, BYTE** yuv, int w, int
//
CClosedCaptionOutputPin::CClosedCaptionOutputPin(CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseOutputPin(NAME("CClosedCaptionOutputPin"), pFilter, pLock, phr, L"~CC")
+ : CBaseOutputPin(NAME("CClosedCaptionOutputPin"), pFilter, pLock, phr, L"~CC")
{
}
HRESULT CClosedCaptionOutputPin::CheckMediaType(const CMediaType* mtOut)
{
- return mtOut->majortype == MEDIATYPE_AUXLine21Data && mtOut->subtype == MEDIASUBTYPE_Line21_GOPPacket
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ return mtOut->majortype == MEDIATYPE_AUXLine21Data && mtOut->subtype == MEDIASUBTYPE_Line21_GOPPacket
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CClosedCaptionOutputPin::GetMediaType(int iPosition, CMediaType* pmt)
{
- if (iPosition < 0) {
- return E_INVALIDARG;
- }
- if (iPosition > 0) {
- return VFW_S_NO_MORE_ITEMS;
- }
+ if (iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if (iPosition > 0) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
- pmt->InitMediaType();
- pmt->majortype = MEDIATYPE_AUXLine21Data;
- pmt->subtype = MEDIASUBTYPE_Line21_GOPPacket;
- pmt->formattype = FORMAT_None;
+ pmt->InitMediaType();
+ pmt->majortype = MEDIATYPE_AUXLine21Data;
+ pmt->subtype = MEDIASUBTYPE_Line21_GOPPacket;
+ pmt->formattype = FORMAT_None;
- return S_OK;
+ return S_OK;
}
HRESULT CClosedCaptionOutputPin::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- pProperties->cBuffers = 1;
- pProperties->cbBuffer = 2048;
- pProperties->cbAlign = 1;
- pProperties->cbPrefix = 0;
+ pProperties->cBuffers = 1;
+ pProperties->cbBuffer = 2048;
+ pProperties->cbAlign = 1;
+ pProperties->cbPrefix = 0;
- HRESULT hr;
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
- return hr;
- }
+ HRESULT hr;
+ ALLOCATOR_PROPERTIES Actual;
+ if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
- return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
- ? E_FAIL
- : NOERROR;
+ return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
+ ? E_FAIL
+ : NOERROR;
}
HRESULT CClosedCaptionOutputPin::Deliver(const void* ptr, int len)
{
- HRESULT hr = S_FALSE;
+ HRESULT hr = S_FALSE;
- if (len > 4 && ptr && *(DWORD*)ptr == 0xf8014343 && IsConnected()) {
- CComPtr<IMediaSample> pSample;
- GetDeliveryBuffer(&pSample, NULL, NULL, 0);
- BYTE* pData = NULL;
- pSample->GetPointer(&pData);
- *(DWORD*)pData = 0xb2010000;
- memcpy(pData + 4, ptr, len);
- pSample->SetActualDataLength(len + 4);
- hr = __super::Deliver(pSample);
- }
+ if (len > 4 && ptr && *(DWORD*)ptr == 0xf8014343 && IsConnected()) {
+ CComPtr<IMediaSample> pSample;
+ GetDeliveryBuffer(&pSample, NULL, NULL, 0);
+ BYTE* pData = NULL;
+ pSample->GetPointer(&pData);
+ *(DWORD*)pData = 0xb2010000;
+ memcpy(pData + 4, ptr, len);
+ pSample->SetActualDataLength(len + 4);
+ hr = __super::Deliver(pSample);
+ }
- return hr;
+ return hr;
}
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.h b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.h
index f5b4a88a2..713e8cfda 100644
--- a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.h
+++ b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.h
@@ -41,296 +41,296 @@ class CClosedCaptionOutputPin;
class CMpeg2Dec;
class __declspec(uuid("39F498AF-1A09-4275-B193-673B0BA3D478"))
- CMpeg2DecFilter
- : public CBaseVideoFilter
- , public IMpeg2DecFilter
- , public ISpecifyPropertyPages2
+ CMpeg2DecFilter
+ : public CBaseVideoFilter
+ , public IMpeg2DecFilter
+ , public ISpecifyPropertyPages2
{
- CSubpicInputPin* m_pSubpicInput;
- CClosedCaptionOutputPin* m_pClosedCaptionOutput;
-
- CAutoPtr<CMpeg2Dec> m_dec;
-
- REFERENCE_TIME m_AvgTimePerFrame;
- bool m_fWaitForKeyFrame;
- bool m_fInitializedBuffer;
- CSize m_par;
-
- struct framebuf {
- int w, h, pitch;
- BYTE* buf_base;
- BYTE* buf[6];
- REFERENCE_TIME rtStart, rtStop;
- DWORD flags;
- ditype di;
- framebuf() {
- w = h = pitch = 0;
- buf_base = NULL;
- memset(&buf, 0, sizeof(buf));
- rtStart = rtStop = 0;
- flags = 0;
- }
- ~framebuf() {
- Free();
- }
- void Alloc(int w, int h, int pitch) {
- this->w = w;
- this->h = h;
- this->pitch = pitch;
- int size = pitch*h;
- buf_base = (BYTE*)_aligned_malloc(size*3+6*32, 32);
- BYTE* p = buf_base;
- buf[0] = p;
- p += (size + 31) & ~31;
- buf[3] = p;
- p += (size + 31) & ~31;
- buf[1] = p;
- p += (size/4 + 31) & ~31;
- buf[4] = p;
- p += (size/4 + 31) & ~31;
- buf[2] = p;
- p += (size/4 + 31) & ~31;
- buf[5] = p;
- p += (size/4 + 31) & ~31;
- }
- void Free() {
- if (buf_base) {
- _aligned_free(buf_base);
- }
- buf_base = NULL;
- }
- } m_fb;
-
- bool m_fFilm;
- void SetDeinterlaceMethod();
- void SetTypeSpecificFlags(IMediaSample* pMS);
-
- AM_SimpleRateChange m_rate;
+ CSubpicInputPin* m_pSubpicInput;
+ CClosedCaptionOutputPin* m_pClosedCaptionOutput;
+
+ CAutoPtr<CMpeg2Dec> m_dec;
+
+ REFERENCE_TIME m_AvgTimePerFrame;
+ bool m_fWaitForKeyFrame;
+ bool m_fInitializedBuffer;
+ CSize m_par;
+
+ struct framebuf {
+ int w, h, pitch;
+ BYTE* buf_base;
+ BYTE* buf[6];
+ REFERENCE_TIME rtStart, rtStop;
+ DWORD flags;
+ ditype di;
+ framebuf() {
+ w = h = pitch = 0;
+ buf_base = NULL;
+ memset(&buf, 0, sizeof(buf));
+ rtStart = rtStop = 0;
+ flags = 0;
+ }
+ ~framebuf() {
+ Free();
+ }
+ void Alloc(int w, int h, int pitch) {
+ this->w = w;
+ this->h = h;
+ this->pitch = pitch;
+ int size = pitch * h;
+ buf_base = (BYTE*)_aligned_malloc(size * 3 + 6 * 32, 32);
+ BYTE* p = buf_base;
+ buf[0] = p;
+ p += (size + 31) & ~31;
+ buf[3] = p;
+ p += (size + 31) & ~31;
+ buf[1] = p;
+ p += (size / 4 + 31) & ~31;
+ buf[4] = p;
+ p += (size / 4 + 31) & ~31;
+ buf[2] = p;
+ p += (size / 4 + 31) & ~31;
+ buf[5] = p;
+ p += (size / 4 + 31) & ~31;
+ }
+ void Free() {
+ if (buf_base) {
+ _aligned_free(buf_base);
+ }
+ buf_base = NULL;
+ }
+ } m_fb;
+
+ bool m_fFilm;
+ void SetDeinterlaceMethod();
+ void SetTypeSpecificFlags(IMediaSample* pMS);
+
+ AM_SimpleRateChange m_rate;
protected:
- void InputTypeChanged();
- HRESULT Transform(IMediaSample* pIn);
- bool IsVideoInterlaced();
- void UpdateAspectRatio();
+ void InputTypeChanged();
+ HRESULT Transform(IMediaSample* pIn);
+ bool IsVideoInterlaced();
+ void UpdateAspectRatio();
public:
- CMpeg2DecFilter(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CMpeg2DecFilter();
+ CMpeg2DecFilter(LPUNKNOWN lpunk, HRESULT* phr);
+ virtual ~CMpeg2DecFilter();
- virtual void GetOutputSize(int& w, int& h, int& arx, int& ary, int &RealWidth, int &RealHeight);
+ virtual void GetOutputSize(int& w, int& h, int& arx, int& ary, int& RealWidth, int& RealHeight);
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- HRESULT DeliverFast();
- HRESULT DeliverNormal();
- HRESULT Deliver(bool fRepeatLast);
+ HRESULT DeliverFast();
+ HRESULT DeliverNormal();
+ HRESULT Deliver(bool fRepeatLast);
- int GetPinCount();
- CBasePin* GetPin(int n);
+ int GetPinCount();
+ CBasePin* GetPin(int n);
- HRESULT EndOfStream();
- HRESULT BeginFlush();
- HRESULT EndFlush();
- HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ HRESULT EndOfStream();
+ HRESULT BeginFlush();
+ HRESULT EndFlush();
+ HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
- HRESULT CheckConnect(PIN_DIRECTION dir, IPin* pPin);
- HRESULT CheckInputType(const CMediaType* mtIn);
- HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
+ HRESULT CheckConnect(PIN_DIRECTION dir, IPin* pPin);
+ HRESULT CheckInputType(const CMediaType* mtIn);
+ HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
- HRESULT StartStreaming();
- HRESULT StopStreaming();
+ HRESULT StartStreaming();
+ HRESULT StopStreaming();
- bool m_fDropFrames;
- HRESULT AlterQuality(Quality q);
+ bool m_fDropFrames;
+ HRESULT AlterQuality(Quality q);
protected:
- CCritSec m_csProps;
- ditype m_ditype;
- float m_bright, m_cont, m_hue, m_sat;
- BYTE m_YTbl[256], m_UTbl[256*256], m_VTbl[256*256];
- bool m_fForcedSubs;
- bool m_fPlanarYUV;
- bool m_fInterlaced;
- bool m_bReadARFromStream;
-
- static void CalcBrCont(BYTE* YTbl, float bright, float cont);
- static void CalcHueSat(BYTE* UTbl, BYTE* VTbl, float hue, float sat);
- void ApplyBrContHueSat(BYTE* srcy, BYTE* srcu, BYTE* srcv, int w, int h, int pitch);
+ CCritSec m_csProps;
+ ditype m_ditype;
+ float m_bright, m_cont, m_hue, m_sat;
+ BYTE m_YTbl[256], m_UTbl[256 * 256], m_VTbl[256 * 256];
+ bool m_fForcedSubs;
+ bool m_fPlanarYUV;
+ bool m_fInterlaced;
+ bool m_bReadARFromStream;
+
+ static void CalcBrCont(BYTE* YTbl, float bright, float cont);
+ static void CalcHueSat(BYTE* UTbl, BYTE* VTbl, float hue, float sat);
+ void ApplyBrContHueSat(BYTE* srcy, BYTE* srcu, BYTE* srcv, int w, int h, int pitch);
public:
- // ISpecifyPropertyPages2
+ // ISpecifyPropertyPages2
- STDMETHODIMP GetPages(CAUUID* pPages);
- STDMETHODIMP CreatePage(const GUID& guid, IPropertyPage** ppPage);
+ STDMETHODIMP GetPages(CAUUID* pPages);
+ STDMETHODIMP CreatePage(const GUID& guid, IPropertyPage** ppPage);
- // IMpeg2DecFilter
+ // IMpeg2DecFilter
- STDMETHODIMP SetDeinterlaceMethod(ditype di);
- STDMETHODIMP_(ditype) GetDeinterlaceMethod();
+ STDMETHODIMP SetDeinterlaceMethod(ditype di);
+ STDMETHODIMP_(ditype) GetDeinterlaceMethod();
- STDMETHODIMP SetBrightness(float bright);
- STDMETHODIMP SetContrast(float cont);
- STDMETHODIMP SetHue(float hue);
- STDMETHODIMP SetSaturation(float sat);
- STDMETHODIMP_(float) GetBrightness();
- STDMETHODIMP_(float) GetContrast();
- STDMETHODIMP_(float) GetHue();
- STDMETHODIMP_(float) GetSaturation();
+ STDMETHODIMP SetBrightness(float bright);
+ STDMETHODIMP SetContrast(float cont);
+ STDMETHODIMP SetHue(float hue);
+ STDMETHODIMP SetSaturation(float sat);
+ STDMETHODIMP_(float) GetBrightness();
+ STDMETHODIMP_(float) GetContrast();
+ STDMETHODIMP_(float) GetHue();
+ STDMETHODIMP_(float) GetSaturation();
- STDMETHODIMP EnableForcedSubtitles(bool fEnable);
- STDMETHODIMP_(bool) IsForcedSubtitlesEnabled();
+ STDMETHODIMP EnableForcedSubtitles(bool fEnable);
+ STDMETHODIMP_(bool) IsForcedSubtitlesEnabled();
- STDMETHODIMP EnablePlanarYUV(bool fEnable);
- STDMETHODIMP_(bool) IsPlanarYUVEnabled();
- STDMETHODIMP Apply();
- // IMpeg2DecFilter2
+ STDMETHODIMP EnablePlanarYUV(bool fEnable);
+ STDMETHODIMP_(bool) IsPlanarYUVEnabled();
+ STDMETHODIMP Apply();
+ // IMpeg2DecFilter2
- STDMETHODIMP EnableInterlaced(bool fEnable);
- STDMETHODIMP_(bool) IsInterlacedEnabled();
+ STDMETHODIMP EnableInterlaced(bool fEnable);
+ STDMETHODIMP_(bool) IsInterlacedEnabled();
- STDMETHODIMP EnableReadARFromStream(bool fEnable);
- STDMETHODIMP_(bool) IsReadARFromStreamEnabled();
+ STDMETHODIMP EnableReadARFromStream(bool fEnable);
+ STDMETHODIMP_(bool) IsReadARFromStreamEnabled();
};
class CMpeg2DecInputPin : public CDeCSSInputPin
{
- LONG m_CorrectTS;
+ LONG m_CorrectTS;
public:
- CMpeg2DecInputPin(CTransformFilter* pFilter, HRESULT* phr, LPWSTR pName);
+ CMpeg2DecInputPin(CTransformFilter* pFilter, HRESULT* phr, LPWSTR pName);
- CCritSec m_csRateLock;
- AM_SimpleRateChange m_ratechange;
+ CCritSec m_csRateLock;
+ AM_SimpleRateChange m_ratechange;
- // IKsPropertySet
- STDMETHODIMP Set(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData, ULONG DataLength);
- STDMETHODIMP Get(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData, ULONG DataLength, ULONG* pBytesReturned);
- STDMETHODIMP QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport);
+ // IKsPropertySet
+ STDMETHODIMP Set(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData, ULONG DataLength);
+ STDMETHODIMP Get(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData, ULONG DataLength, ULONG* pBytesReturned);
+ STDMETHODIMP QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport);
};
class CMpeg2DecOutputPin : public CBaseVideoOutputPin
{
public:
- CMpeg2DecOutputPin(CBaseVideoFilter* pFilter, HRESULT* phr, LPWSTR pName);
+ CMpeg2DecOutputPin(CBaseVideoFilter* pFilter, HRESULT* phr, LPWSTR pName);
- CAutoPtr<COutputQueue> m_pOutputQueue;
+ CAutoPtr<COutputQueue> m_pOutputQueue;
- HRESULT Active();
- HRESULT Inactive();
+ HRESULT Active();
+ HRESULT Inactive();
- HRESULT Deliver(IMediaSample* pMediaSample);
- HRESULT DeliverEndOfStream();
- HRESULT DeliverBeginFlush();
- HRESULT DeliverEndFlush();
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ HRESULT Deliver(IMediaSample* pMediaSample);
+ HRESULT DeliverEndOfStream();
+ HRESULT DeliverBeginFlush();
+ HRESULT DeliverEndFlush();
+ HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
};
class CSubpicInputPin : public CMpeg2DecInputPin
{
- CCritSec m_csReceive;
-
- AM_PROPERTY_COMPOSIT_ON m_spon;
- AM_DVD_YUV m_sppal[16];
- bool m_fsppal;
- CAutoPtr<AM_PROPERTY_SPHLI> m_sphli; // temp
-
- class spu : public CAtlArray<BYTE>
- {
- public:
- bool m_fForced;
- REFERENCE_TIME m_rtStart, m_rtStop;
- DWORD m_offset[2];
- AM_PROPERTY_SPHLI m_sphli; // parsed
- CAutoPtr<AM_PROPERTY_SPHLI> m_psphli; // for the menu (optional)
- spu() {
- memset(&m_sphli, 0, sizeof(m_sphli));
- m_fForced = false;
- m_rtStart = m_rtStop = 0;
- }
- virtual ~spu() {}
- virtual bool Parse() = 0;
- virtual void Render(REFERENCE_TIME rt, BYTE** p, int w, int h, AM_DVD_YUV* sppal, bool fsppal) = 0;
- };
-
- class dvdspu : public spu
- {
- public:
- struct offset_t {
- REFERENCE_TIME rt;
- AM_PROPERTY_SPHLI sphli;
- };
- CAtlList<offset_t> m_offsets;
- bool Parse();
- void Render(REFERENCE_TIME rt, BYTE** p, int w, int h, AM_DVD_YUV* sppal, bool fsppal);
- };
-
- class cvdspu : public spu
- {
- public:
- AM_DVD_YUV m_sppal[2][4];
- cvdspu() {
- memset(m_sppal, 0, sizeof(m_sppal));
- }
- bool Parse();
- void Render(REFERENCE_TIME rt, BYTE** p, int w, int h, AM_DVD_YUV* sppal, bool fsppal);
- };
-
- class svcdspu : public spu
- {
- public:
- AM_DVD_YUV m_sppal[4];
- svcdspu() {
- memset(m_sppal, 0, sizeof(m_sppal));
- }
- bool Parse();
- void Render(REFERENCE_TIME rt, BYTE** p, int w, int h, AM_DVD_YUV* sppal, bool fsppal);
- };
-
- CAutoPtrList<spu> m_sps;
+ CCritSec m_csReceive;
+
+ AM_PROPERTY_COMPOSIT_ON m_spon;
+ AM_DVD_YUV m_sppal[16];
+ bool m_fsppal;
+ CAutoPtr<AM_PROPERTY_SPHLI> m_sphli; // temp
+
+ class spu : public CAtlArray<BYTE>
+ {
+ public:
+ bool m_fForced;
+ REFERENCE_TIME m_rtStart, m_rtStop;
+ DWORD m_offset[2];
+ AM_PROPERTY_SPHLI m_sphli; // parsed
+ CAutoPtr<AM_PROPERTY_SPHLI> m_psphli; // for the menu (optional)
+ spu() {
+ memset(&m_sphli, 0, sizeof(m_sphli));
+ m_fForced = false;
+ m_rtStart = m_rtStop = 0;
+ }
+ virtual ~spu() {}
+ virtual bool Parse() = 0;
+ virtual void Render(REFERENCE_TIME rt, BYTE** p, int w, int h, AM_DVD_YUV* sppal, bool fsppal) = 0;
+ };
+
+ class dvdspu : public spu
+ {
+ public:
+ struct offset_t {
+ REFERENCE_TIME rt;
+ AM_PROPERTY_SPHLI sphli;
+ };
+ CAtlList<offset_t> m_offsets;
+ bool Parse();
+ void Render(REFERENCE_TIME rt, BYTE** p, int w, int h, AM_DVD_YUV* sppal, bool fsppal);
+ };
+
+ class cvdspu : public spu
+ {
+ public:
+ AM_DVD_YUV m_sppal[2][4];
+ cvdspu() {
+ memset(m_sppal, 0, sizeof(m_sppal));
+ }
+ bool Parse();
+ void Render(REFERENCE_TIME rt, BYTE** p, int w, int h, AM_DVD_YUV* sppal, bool fsppal);
+ };
+
+ class svcdspu : public spu
+ {
+ public:
+ AM_DVD_YUV m_sppal[4];
+ svcdspu() {
+ memset(m_sppal, 0, sizeof(m_sppal));
+ }
+ bool Parse();
+ void Render(REFERENCE_TIME rt, BYTE** p, int w, int h, AM_DVD_YUV* sppal, bool fsppal);
+ };
+
+ CAutoPtrList<spu> m_sps;
protected:
- HRESULT Transform(IMediaSample* pSample);
+ HRESULT Transform(IMediaSample* pSample);
public:
- CSubpicInputPin(CTransformFilter* pFilter, HRESULT* phr);
-
- bool HasAnythingToRender(REFERENCE_TIME rt);
- void RenderSubpics(REFERENCE_TIME rt, BYTE** p, int w, int h);
-
- HRESULT CheckMediaType(const CMediaType* mtIn);
- HRESULT SetMediaType(const CMediaType* mtIn);
-
- // we shouldn't pass these to the filter from this pin
- STDMETHODIMP EndOfStream() {
- return S_OK;
- }
- STDMETHODIMP BeginFlush() {
- return S_OK;
- }
- STDMETHODIMP EndFlush();
- STDMETHODIMP NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate) {
- return S_OK;
- }
-
- // IKsPropertySet
- STDMETHODIMP Set(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData, ULONG DataLength);
- STDMETHODIMP QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport);
+ CSubpicInputPin(CTransformFilter* pFilter, HRESULT* phr);
+
+ bool HasAnythingToRender(REFERENCE_TIME rt);
+ void RenderSubpics(REFERENCE_TIME rt, BYTE** p, int w, int h);
+
+ HRESULT CheckMediaType(const CMediaType* mtIn);
+ HRESULT SetMediaType(const CMediaType* mtIn);
+
+ // we shouldn't pass these to the filter from this pin
+ STDMETHODIMP EndOfStream() {
+ return S_OK;
+ }
+ STDMETHODIMP BeginFlush() {
+ return S_OK;
+ }
+ STDMETHODIMP EndFlush();
+ STDMETHODIMP NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate) {
+ return S_OK;
+ }
+
+ // IKsPropertySet
+ STDMETHODIMP Set(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData, ULONG DataLength);
+ STDMETHODIMP QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport);
};
class CClosedCaptionOutputPin : public CBaseOutputPin
{
public:
- CClosedCaptionOutputPin(CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
+ CClosedCaptionOutputPin(CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
- HRESULT CheckMediaType(const CMediaType* mtOut);
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
- HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT CheckMediaType(const CMediaType* mtOut);
+ HRESULT GetMediaType(int iPosition, CMediaType* pmt);
+ HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
- CMediaType& CurrentMediaType() {
- return m_mt;
- }
+ CMediaType& CurrentMediaType() {
+ return m_mt;
+ }
- HRESULT Deliver(const void* ptr, int len);
+ HRESULT Deliver(const void* ptr, int len);
};
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.cpp b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.cpp
index e51a4997f..c6271f6e4 100644
--- a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.cpp
+++ b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.cpp
@@ -40,208 +40,208 @@ static TCHAR m_strSaturation[100];
CMpeg2DecSettingsWnd::CMpeg2DecSettingsWnd()
{
- wcscpy_s(m_strBrightness, ResStr(IDS_MPEG2_BRIGHTNESS));
- wcscpy_s(m_strContrast, ResStr(IDS_MPEG2_CONTRAST));
- wcscpy_s(m_strHue, ResStr(IDS_MPEG2_HUE));
- wcscpy_s(m_strSaturation, ResStr(IDS_MPEG2_SATURATION));
+ wcscpy_s(m_strBrightness, ResStr(IDS_MPEG2_BRIGHTNESS));
+ wcscpy_s(m_strContrast, ResStr(IDS_MPEG2_CONTRAST));
+ wcscpy_s(m_strHue, ResStr(IDS_MPEG2_HUE));
+ wcscpy_s(m_strSaturation, ResStr(IDS_MPEG2_SATURATION));
}
bool CMpeg2DecSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
{
- ASSERT(!m_pM2DF);
-
- m_pM2DF.Release();
-
- POSITION pos = pUnks.GetHeadPosition();
- while (pos && !(m_pM2DF = pUnks.GetNext(pos))) {
- ;
- }
-
- if (!m_pM2DF) {
- return false;
- }
-
- m_ditype = m_pM2DF->GetDeinterlaceMethod();
- m_procamp[0] = m_pM2DF->GetBrightness();
- m_procamp[1] = m_pM2DF->GetContrast();
- m_procamp[2] = m_pM2DF->GetHue();
- m_procamp[3] = m_pM2DF->GetSaturation();
- m_forcedsubs = m_pM2DF->IsForcedSubtitlesEnabled();
- m_planaryuv = m_pM2DF->IsPlanarYUVEnabled();
- m_interlaced = m_pM2DF->IsInterlacedEnabled();
- m_readARFromStream = m_pM2DF->IsReadARFromStreamEnabled();
-
- return true;
+ ASSERT(!m_pM2DF);
+
+ m_pM2DF.Release();
+
+ POSITION pos = pUnks.GetHeadPosition();
+ while (pos && !(m_pM2DF = pUnks.GetNext(pos))) {
+ ;
+ }
+
+ if (!m_pM2DF) {
+ return false;
+ }
+
+ m_ditype = m_pM2DF->GetDeinterlaceMethod();
+ m_procamp[0] = m_pM2DF->GetBrightness();
+ m_procamp[1] = m_pM2DF->GetContrast();
+ m_procamp[2] = m_pM2DF->GetHue();
+ m_procamp[3] = m_pM2DF->GetSaturation();
+ m_forcedsubs = m_pM2DF->IsForcedSubtitlesEnabled();
+ m_planaryuv = m_pM2DF->IsPlanarYUVEnabled();
+ m_interlaced = m_pM2DF->IsInterlacedEnabled();
+ m_readARFromStream = m_pM2DF->IsReadARFromStreamEnabled();
+
+ return true;
}
void CMpeg2DecSettingsWnd::OnDisconnect()
{
- m_pM2DF.Release();
+ m_pM2DF.Release();
}
bool CMpeg2DecSettingsWnd::OnActivate()
{
- DWORD dwStyle = WS_VISIBLE|WS_CHILD|WS_TABSTOP;
-
- CPoint p(10, 10);
-
- m_planaryuv_check.Create(ResStr(IDS_MPEG2DECSETTINGSWND_0), dwStyle|BS_AUTOCHECKBOX, CRect(p, CSize(300, m_fontheight)), this, IDC_PP_CHECK1);
- m_planaryuv_check.SetCheck(m_planaryuv ? BST_CHECKED : BST_UNCHECKED);
- p.y += m_fontheight + 5;
-
- m_interlaced_check.Create(ResStr(IDS_MPEG2DECSETTINGSWND_1), dwStyle|BS_AUTOCHECKBOX, CRect(p, CSize(300, m_fontheight)), this, IDC_PP_CHECK2);
- m_interlaced_check.SetCheck(m_interlaced ? BST_CHECKED : BST_UNCHECKED);
- p.y += m_fontheight + 5;
-
- m_forcedsubs_check.Create(ResStr(IDS_MPEG2DECSETTINGSWND_2), dwStyle|BS_AUTOCHECKBOX, CRect(p, CSize(300, m_fontheight)), this, IDC_PP_CHECK3);
- m_forcedsubs_check.SetCheck(m_forcedsubs ? BST_CHECKED : BST_UNCHECKED);
- p.y += m_fontheight + 5;
-
- m_readARFromStream_check.Create(ResStr(IDS_MPEG2DECSETTINGSWND_3), dwStyle|BS_AUTOCHECKBOX, CRect(p, CSize(300, m_fontheight)), this, IDC_PP_CHECK4);
- m_readARFromStream_check.SetCheck(m_readARFromStream ? BST_CHECKED : BST_UNCHECKED);
- p.y += m_fontheight + 5;
-
- p.y += 10;
-
- m_ditype_static.Create(ResStr(IDS_MPEG2_DEINTERLACING), dwStyle, CRect(p, CSize(100, m_fontheight)), this);
- m_ditype_combo.Create(dwStyle|CBS_DROPDOWNLIST, CRect(p + CSize(110, -3), CSize(100, 200)), this, IDC_PP_COMBO1);
- m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Auto")), (DWORD)DIAuto);
- m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Weave")), (DWORD)DIWeave);
- m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Blend")), (DWORD)DIBlend);
- m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Bob")), (DWORD)DIBob);
- m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Field Shift")), (DWORD)DIFieldShift);
- m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("ELA")), (DWORD)DIELA);
- m_ditype_combo.SetCurSel(0);
- for (int i = 0; i < m_ditype_combo.GetCount(); i++)
- if ((int)m_ditype_combo.GetItemData(i) == m_ditype) {
- m_ditype_combo.SetCurSel(i);
- }
-
- m_ditype_combo.EnableWindow(!IsDlgButtonChecked(m_interlaced_check.GetDlgCtrlID()));
-
- p.y += m_fontheight + 20;
-
- for (int i = 0, h = max(20, m_fontheight)+1; i < _countof(m_procamp_slider); i++, p.y += h) {
- static const TCHAR* labels[] = {m_strBrightness, m_strContrast, m_strHue, m_strSaturation};
- m_procamp_static[i].Create(labels[i], dwStyle, CRect(p, CSize(70, h)), this);
- m_procamp_slider[i].Create(dwStyle, CRect(p + CPoint(80, 0), CSize(201, h)), this, IDC_PP_SLIDER1+i);
- m_procamp_value[i].Create(_T(""), dwStyle, CRect(p + CPoint(280, 0), CSize(40, h)), this);
- }
-
- m_procamp_slider[0].SetRange(0, 2*128);
- m_procamp_slider[0].SetTic(128);
- m_procamp_slider[0].SetPos((int)(m_procamp[0] + (m_procamp[0] >= 0 ? 0.5f : -0.5f)) + 128);
- m_procamp_slider[1].SetRange(0, 200);
- m_procamp_slider[1].SetTic(100);
- m_procamp_slider[1].SetPos((int)(100*m_procamp[1] + 0.5f));
- m_procamp_slider[2].SetRange(0, 2*180);
- m_procamp_slider[2].SetTic(180);
- m_procamp_slider[2].SetPos((int)(m_procamp[2] + (m_procamp[2] >= 0 ? 0.5f : -0.5f)) + 180);
- m_procamp_slider[3].SetRange(0, 200);
- m_procamp_slider[3].SetTic(100);
- m_procamp_slider[3].SetPos((int)(100*m_procamp[3] + 0.5f));
-
- p.y += 5;
-
- m_procamp_tv2pc.Create(_T("TV->PC"), dwStyle, CRect(p + CPoint(50 + 200/2 - 55, 0), CSize(80, 20)), this, IDC_PP_BUTTON1);
- m_procamp_reset.Create(ResStr(IDS_MPEG2_RESET), dwStyle, CRect(p + CPoint(80 + 200/2 + 5, 0), CSize(80, 20)), this, IDC_PP_BUTTON2);
-
- p.y += 30;
-
- UpdateProcampValues();
-
- m_note_static.Create(
- ResStr(IDS_MPEG2DECSETTINGSWND_7) +
- ResStr(IDS_MPEG2DECSETTINGSWND_8),
- dwStyle, CRect(p, CSize(320, m_fontheight * 4)), this);
-
- for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
- pWnd->SetFont(&m_font, FALSE);
- }
-
- return true;
+ DWORD dwStyle = WS_VISIBLE | WS_CHILD | WS_TABSTOP;
+
+ CPoint p(10, 10);
+
+ m_planaryuv_check.Create(ResStr(IDS_MPEG2DECSETTINGSWND_0), dwStyle | BS_AUTOCHECKBOX, CRect(p, CSize(300, m_fontheight)), this, IDC_PP_CHECK1);
+ m_planaryuv_check.SetCheck(m_planaryuv ? BST_CHECKED : BST_UNCHECKED);
+ p.y += m_fontheight + 5;
+
+ m_interlaced_check.Create(ResStr(IDS_MPEG2DECSETTINGSWND_1), dwStyle | BS_AUTOCHECKBOX, CRect(p, CSize(300, m_fontheight)), this, IDC_PP_CHECK2);
+ m_interlaced_check.SetCheck(m_interlaced ? BST_CHECKED : BST_UNCHECKED);
+ p.y += m_fontheight + 5;
+
+ m_forcedsubs_check.Create(ResStr(IDS_MPEG2DECSETTINGSWND_2), dwStyle | BS_AUTOCHECKBOX, CRect(p, CSize(300, m_fontheight)), this, IDC_PP_CHECK3);
+ m_forcedsubs_check.SetCheck(m_forcedsubs ? BST_CHECKED : BST_UNCHECKED);
+ p.y += m_fontheight + 5;
+
+ m_readARFromStream_check.Create(ResStr(IDS_MPEG2DECSETTINGSWND_3), dwStyle | BS_AUTOCHECKBOX, CRect(p, CSize(300, m_fontheight)), this, IDC_PP_CHECK4);
+ m_readARFromStream_check.SetCheck(m_readARFromStream ? BST_CHECKED : BST_UNCHECKED);
+ p.y += m_fontheight + 5;
+
+ p.y += 10;
+
+ m_ditype_static.Create(ResStr(IDS_MPEG2_DEINTERLACING), dwStyle, CRect(p, CSize(100, m_fontheight)), this);
+ m_ditype_combo.Create(dwStyle | CBS_DROPDOWNLIST, CRect(p + CSize(110, -3), CSize(100, 200)), this, IDC_PP_COMBO1);
+ m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Auto")), (DWORD)DIAuto);
+ m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Weave")), (DWORD)DIWeave);
+ m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Blend")), (DWORD)DIBlend);
+ m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Bob")), (DWORD)DIBob);
+ m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Field Shift")), (DWORD)DIFieldShift);
+ m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("ELA")), (DWORD)DIELA);
+ m_ditype_combo.SetCurSel(0);
+ for (int i = 0; i < m_ditype_combo.GetCount(); i++)
+ if ((int)m_ditype_combo.GetItemData(i) == m_ditype) {
+ m_ditype_combo.SetCurSel(i);
+ }
+
+ m_ditype_combo.EnableWindow(!IsDlgButtonChecked(m_interlaced_check.GetDlgCtrlID()));
+
+ p.y += m_fontheight + 20;
+
+ for (int i = 0, h = max(20, m_fontheight) + 1; i < _countof(m_procamp_slider); i++, p.y += h) {
+ static const TCHAR* labels[] = {m_strBrightness, m_strContrast, m_strHue, m_strSaturation};
+ m_procamp_static[i].Create(labels[i], dwStyle, CRect(p, CSize(70, h)), this);
+ m_procamp_slider[i].Create(dwStyle, CRect(p + CPoint(80, 0), CSize(201, h)), this, IDC_PP_SLIDER1 + i);
+ m_procamp_value[i].Create(_T(""), dwStyle, CRect(p + CPoint(280, 0), CSize(40, h)), this);
+ }
+
+ m_procamp_slider[0].SetRange(0, 2 * 128);
+ m_procamp_slider[0].SetTic(128);
+ m_procamp_slider[0].SetPos((int)(m_procamp[0] + (m_procamp[0] >= 0 ? 0.5f : -0.5f)) + 128);
+ m_procamp_slider[1].SetRange(0, 200);
+ m_procamp_slider[1].SetTic(100);
+ m_procamp_slider[1].SetPos((int)(100 * m_procamp[1] + 0.5f));
+ m_procamp_slider[2].SetRange(0, 2 * 180);
+ m_procamp_slider[2].SetTic(180);
+ m_procamp_slider[2].SetPos((int)(m_procamp[2] + (m_procamp[2] >= 0 ? 0.5f : -0.5f)) + 180);
+ m_procamp_slider[3].SetRange(0, 200);
+ m_procamp_slider[3].SetTic(100);
+ m_procamp_slider[3].SetPos((int)(100 * m_procamp[3] + 0.5f));
+
+ p.y += 5;
+
+ m_procamp_tv2pc.Create(_T("TV->PC"), dwStyle, CRect(p + CPoint(50 + 200 / 2 - 55, 0), CSize(80, 20)), this, IDC_PP_BUTTON1);
+ m_procamp_reset.Create(ResStr(IDS_MPEG2_RESET), dwStyle, CRect(p + CPoint(80 + 200 / 2 + 5, 0), CSize(80, 20)), this, IDC_PP_BUTTON2);
+
+ p.y += 30;
+
+ UpdateProcampValues();
+
+ m_note_static.Create(
+ ResStr(IDS_MPEG2DECSETTINGSWND_7) +
+ ResStr(IDS_MPEG2DECSETTINGSWND_8),
+ dwStyle, CRect(p, CSize(320, m_fontheight * 4)), this);
+
+ for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
+ pWnd->SetFont(&m_font, FALSE);
+ }
+
+ return true;
}
void CMpeg2DecSettingsWnd::OnDeactivate()
{
- m_ditype = (ditype)m_ditype_combo.GetItemData(m_ditype_combo.GetCurSel());
- m_procamp[0] = (float)m_procamp_slider[0].GetPos() - 128;
- m_procamp[1] = (float)m_procamp_slider[1].GetPos() / 100;
- m_procamp[2] = (float)m_procamp_slider[2].GetPos() - 180;
- m_procamp[3] = (float)m_procamp_slider[3].GetPos() / 100;
- m_planaryuv = !!IsDlgButtonChecked(m_planaryuv_check.GetDlgCtrlID());
- m_interlaced = !!IsDlgButtonChecked(m_interlaced_check.GetDlgCtrlID());
- m_forcedsubs = !!IsDlgButtonChecked(m_forcedsubs_check.GetDlgCtrlID());
- m_readARFromStream = !!IsDlgButtonChecked(m_readARFromStream_check.GetDlgCtrlID());
+ m_ditype = (ditype)m_ditype_combo.GetItemData(m_ditype_combo.GetCurSel());
+ m_procamp[0] = (float)m_procamp_slider[0].GetPos() - 128;
+ m_procamp[1] = (float)m_procamp_slider[1].GetPos() / 100;
+ m_procamp[2] = (float)m_procamp_slider[2].GetPos() - 180;
+ m_procamp[3] = (float)m_procamp_slider[3].GetPos() / 100;
+ m_planaryuv = !!IsDlgButtonChecked(m_planaryuv_check.GetDlgCtrlID());
+ m_interlaced = !!IsDlgButtonChecked(m_interlaced_check.GetDlgCtrlID());
+ m_forcedsubs = !!IsDlgButtonChecked(m_forcedsubs_check.GetDlgCtrlID());
+ m_readARFromStream = !!IsDlgButtonChecked(m_readARFromStream_check.GetDlgCtrlID());
}
bool CMpeg2DecSettingsWnd::OnApply()
{
- OnDeactivate();
-
- if (m_pM2DF) {
- m_pM2DF->SetDeinterlaceMethod(m_ditype);
- m_pM2DF->SetBrightness(m_procamp[0]);
- m_pM2DF->SetContrast(m_procamp[1]);
- m_pM2DF->SetHue(m_procamp[2]);
- m_pM2DF->SetSaturation(m_procamp[3]);
- m_pM2DF->EnableForcedSubtitles(m_forcedsubs);
- m_pM2DF->EnablePlanarYUV(m_planaryuv);
- m_pM2DF->EnableInterlaced(m_interlaced);
- m_pM2DF->EnableReadARFromStream(m_readARFromStream);
- m_pM2DF->Apply();
- }
-
- return true;
+ OnDeactivate();
+
+ if (m_pM2DF) {
+ m_pM2DF->SetDeinterlaceMethod(m_ditype);
+ m_pM2DF->SetBrightness(m_procamp[0]);
+ m_pM2DF->SetContrast(m_procamp[1]);
+ m_pM2DF->SetHue(m_procamp[2]);
+ m_pM2DF->SetSaturation(m_procamp[3]);
+ m_pM2DF->EnableForcedSubtitles(m_forcedsubs);
+ m_pM2DF->EnablePlanarYUV(m_planaryuv);
+ m_pM2DF->EnableInterlaced(m_interlaced);
+ m_pM2DF->EnableReadARFromStream(m_readARFromStream);
+ m_pM2DF->Apply();
+ }
+
+ return true;
}
void CMpeg2DecSettingsWnd::UpdateProcampValues()
{
- CString str;
-
- str.Format(_T("%d"), m_procamp_slider[0].GetPos() - 128);
- m_procamp_value[0].SetWindowText(str);
- str.Format(_T("%d%%"), m_procamp_slider[1].GetPos());
- m_procamp_value[1].SetWindowText(str);
- str.Format(_T("%d"), m_procamp_slider[2].GetPos() - 180);
- m_procamp_value[2].SetWindowText(str);
- str.Format(_T("%d%%"), m_procamp_slider[3].GetPos());
- m_procamp_value[3].SetWindowText(str);
+ CString str;
+
+ str.Format(_T("%d"), m_procamp_slider[0].GetPos() - 128);
+ m_procamp_value[0].SetWindowText(str);
+ str.Format(_T("%d%%"), m_procamp_slider[1].GetPos());
+ m_procamp_value[1].SetWindowText(str);
+ str.Format(_T("%d"), m_procamp_slider[2].GetPos() - 180);
+ m_procamp_value[2].SetWindowText(str);
+ str.Format(_T("%d%%"), m_procamp_slider[3].GetPos());
+ m_procamp_value[3].SetWindowText(str);
}
BEGIN_MESSAGE_MAP(CMpeg2DecSettingsWnd, CInternalPropertyPageWnd)
- ON_BN_CLICKED(IDC_PP_BUTTON1, OnButtonProcampPc2Tv)
- ON_BN_CLICKED(IDC_PP_BUTTON2, OnButtonProcampReset)
- ON_BN_CLICKED(IDC_PP_CHECK2, OnButtonInterlaced)
- ON_WM_HSCROLL()
+ ON_BN_CLICKED(IDC_PP_BUTTON1, OnButtonProcampPc2Tv)
+ ON_BN_CLICKED(IDC_PP_BUTTON2, OnButtonProcampReset)
+ ON_BN_CLICKED(IDC_PP_CHECK2, OnButtonInterlaced)
+ ON_WM_HSCROLL()
END_MESSAGE_MAP()
void CMpeg2DecSettingsWnd::OnButtonProcampPc2Tv()
{
- m_procamp_slider[0].SetPos(128 - 16);
- m_procamp_slider[1].SetPos(100 * 255/(235-16));
+ m_procamp_slider[0].SetPos(128 - 16);
+ m_procamp_slider[1].SetPos(100 * 255 / (235 - 16));
- UpdateProcampValues();
+ UpdateProcampValues();
}
void CMpeg2DecSettingsWnd::OnButtonProcampReset()
{
- m_procamp_slider[0].SetPos(128);
- m_procamp_slider[1].SetPos(100);
- m_procamp_slider[2].SetPos(180);
- m_procamp_slider[3].SetPos(100);
+ m_procamp_slider[0].SetPos(128);
+ m_procamp_slider[1].SetPos(100);
+ m_procamp_slider[2].SetPos(180);
+ m_procamp_slider[3].SetPos(100);
- UpdateProcampValues();
+ UpdateProcampValues();
}
void CMpeg2DecSettingsWnd::OnButtonInterlaced()
{
- m_ditype_combo.EnableWindow(!IsDlgButtonChecked(m_interlaced_check.GetDlgCtrlID()));
+ m_ditype_combo.EnableWindow(!IsDlgButtonChecked(m_interlaced_check.GetDlgCtrlID()));
}
void CMpeg2DecSettingsWnd::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
- UpdateProcampValues();
+ UpdateProcampValues();
- __super::OnHScroll(nSBCode, nPos, pScrollBar);
+ __super::OnHScroll(nSBCode, nPos, pScrollBar);
}
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.h b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.h
index 6aa9f16df..c2665c15c 100644
--- a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.h
+++ b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.h
@@ -28,66 +28,66 @@
#include <afxcmn.h>
class __declspec(uuid("E5FB6957-65E6-491B-BB37-B25C9FE3BEA7"))
- CMpeg2DecSettingsWnd : public CInternalPropertyPageWnd
+ CMpeg2DecSettingsWnd : public CInternalPropertyPageWnd
{
- CComQIPtr<IMpeg2DecFilter> m_pM2DF;
+ CComQIPtr<IMpeg2DecFilter> m_pM2DF;
- ditype m_ditype;
- float m_procamp[4];
- bool m_planaryuv;
- bool m_interlaced;
- bool m_forcedsubs;
- bool m_readARFromStream;
+ ditype m_ditype;
+ float m_procamp[4];
+ bool m_planaryuv;
+ bool m_interlaced;
+ bool m_forcedsubs;
+ bool m_readARFromStream;
- enum {
- IDC_PP_COMBO1 = 10000,
- IDC_PP_SLIDER1,
- IDC_PP_SLIDER2,
- IDC_PP_SLIDER3,
- IDC_PP_SLIDER4,
- IDC_PP_CHECK1,
- IDC_PP_CHECK2,
- IDC_PP_CHECK3,
- IDC_PP_CHECK4,
- IDC_PP_BUTTON1,
- IDC_PP_BUTTON2,
- };
+ enum {
+ IDC_PP_COMBO1 = 10000,
+ IDC_PP_SLIDER1,
+ IDC_PP_SLIDER2,
+ IDC_PP_SLIDER3,
+ IDC_PP_SLIDER4,
+ IDC_PP_CHECK1,
+ IDC_PP_CHECK2,
+ IDC_PP_CHECK3,
+ IDC_PP_CHECK4,
+ IDC_PP_BUTTON1,
+ IDC_PP_BUTTON2,
+ };
- CStatic m_ditype_static;
- CComboBox m_ditype_combo;
- CStatic m_procamp_static[4];
- CSliderCtrl m_procamp_slider[4];
- CStatic m_procamp_value[4];
- CButton m_procamp_tv2pc;
- CButton m_procamp_reset;
- CButton m_planaryuv_check;
- CButton m_interlaced_check;
- CButton m_forcedsubs_check;
- CButton m_readARFromStream_check;
- CStatic m_note_static;
+ CStatic m_ditype_static;
+ CComboBox m_ditype_combo;
+ CStatic m_procamp_static[4];
+ CSliderCtrl m_procamp_slider[4];
+ CStatic m_procamp_value[4];
+ CButton m_procamp_tv2pc;
+ CButton m_procamp_reset;
+ CButton m_planaryuv_check;
+ CButton m_interlaced_check;
+ CButton m_forcedsubs_check;
+ CButton m_readARFromStream_check;
+ CStatic m_note_static;
- void UpdateProcampValues();
+ void UpdateProcampValues();
public:
- CMpeg2DecSettingsWnd();
+ CMpeg2DecSettingsWnd();
- bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
- void OnDisconnect();
- bool OnActivate();
- void OnDeactivate();
- bool OnApply();
+ bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
+ void OnDisconnect();
+ bool OnActivate();
+ void OnDeactivate();
+ bool OnApply();
- static LPCTSTR GetWindowTitle() {
- return _T("Settings");
- }
- static CSize GetWindowSize() {
- return CSize(320, 240);
- }
+ static LPCTSTR GetWindowTitle() {
+ return _T("Settings");
+ }
+ static CSize GetWindowSize() {
+ return CSize(320, 240);
+ }
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
- afx_msg void OnButtonProcampPc2Tv();
- afx_msg void OnButtonProcampReset();
- afx_msg void OnButtonInterlaced();
- afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
+ afx_msg void OnButtonProcampPc2Tv();
+ afx_msg void OnButtonProcampReset();
+ afx_msg void OnButtonInterlaced();
+ afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
}; \ No newline at end of file
diff --git a/src/filters/transform/Mpeg2DecFilter/idct_sse2.cpp b/src/filters/transform/Mpeg2DecFilter/idct_sse2.cpp
index da555e2ce..df1dd7748 100644
--- a/src/filters/transform/Mpeg2DecFilter/idct_sse2.cpp
+++ b/src/filters/transform/Mpeg2DecFilter/idct_sse2.cpp
@@ -31,292 +31,292 @@
// AP-945
// http://cache-www.intel.com/cd/00/00/01/76/17680_w_idct.pdf
-static const int BITS_INV_ACC=4;
-static const int SHIFT_INV_ROW=16-BITS_INV_ACC;
-static const int SHIFT_INV_COL=1+BITS_INV_ACC;
-static const int RND_INV_ROW =1024*(6-BITS_INV_ACC);
-static const int RND_INV_COL =16*(BITS_INV_ACC-3);
-static const int RND_INV_CORR =RND_INV_COL-1;
+static const int BITS_INV_ACC = 4;
+static const int SHIFT_INV_ROW = 16 - BITS_INV_ACC;
+static const int SHIFT_INV_COL = 1 + BITS_INV_ACC;
+static const int RND_INV_ROW = 1024 * (6 - BITS_INV_ACC);
+static const int RND_INV_COL = 16 * (BITS_INV_ACC - 3);
+static const int RND_INV_CORR = RND_INV_COL - 1;
-static __align16(const short,M128_round_inv_row[8]) = {RND_INV_ROW, 0, RND_INV_ROW, 0, RND_INV_ROW, 0, RND_INV_ROW, 0};
-static __align16(const short,M128_one_corr[8]) = {1,1,1,1,1,1,1,1};
-static __align16(const short,M128_round_inv_col[8]) = {RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL};
-static __align16(const short,M128_round_inv_corr[8])= {RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR};
-static __align16(const short,M128_tg_1_16[8]) = {13036, 13036, 13036, 13036, 13036, 13036, 13036, 13036}; // tg * (2<<16) + 0.5
-static __align16(const short,M128_tg_2_16[8]) = {27146, 27146, 27146, 27146, 27146, 27146, 27146, 27146}; // tg * (2<<16) + 0.5
-static __align16(const short,M128_tg_3_16[8]) = {-21746, -21746, -21746, -21746, -21746, -21746, -21746, -21746}; // tg * (2<<16) + 0.5
-static __align16(const short,M128_cos_4_16[8]) = {-19195, -19195, -19195, -19195, -19195, -19195, -19195, -19195};// cos * (2<<16) + 0.5
+static __align16(const short, M128_round_inv_row[8]) = {RND_INV_ROW, 0, RND_INV_ROW, 0, RND_INV_ROW, 0, RND_INV_ROW, 0};
+static __align16(const short, M128_one_corr[8]) = {1, 1, 1, 1, 1, 1, 1, 1};
+static __align16(const short, M128_round_inv_col[8]) = {RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL};
+static __align16(const short, M128_round_inv_corr[8]) = {RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR};
+static __align16(const short, M128_tg_1_16[8]) = {13036, 13036, 13036, 13036, 13036, 13036, 13036, 13036}; // tg * (2<<16) + 0.5
+static __align16(const short, M128_tg_2_16[8]) = {27146, 27146, 27146, 27146, 27146, 27146, 27146, 27146}; // tg * (2<<16) + 0.5
+static __align16(const short, M128_tg_3_16[8]) = { -21746, -21746, -21746, -21746, -21746, -21746, -21746, -21746}; // tg * (2<<16) + 0.5
+static __align16(const short, M128_cos_4_16[8]) = { -19195, -19195, -19195, -19195, -19195, -19195, -19195, -19195}; // cos * (2<<16) + 0.5
-static __align16(const int16_t,M128_tab_i_04[])= {16384, 21407, 16384, 8867, 16384, -8867, 16384, -21407, 16384, 8867, -16384, -21407, -16384, 21407, 16384, -8867, 22725, 19266, 19266, -4520, 12873, -22725, 4520, -12873, 12873, 4520, -22725, -12873, 4520, 19266, 19266, -22725};
-static __align16(const int16_t,M128_tab_i_17[])= {22725, 29692, 22725, 12299, 22725, -12299, 22725, -29692, 22725, 12299, -22725, -29692, -22725, 29692, 22725, -12299, 31521, 26722, 26722, -6270, 17855, -31521, 6270, -17855, 17855, 6270, -31521, -17855, 6270, 26722, 26722, -31521};
-static __align16(const int16_t,M128_tab_i_26[])= {21407, 27969, 21407, 11585, 21407, -11585, 21407, -27969, 21407, 11585, -21407, -27969, -21407, 27969, 21407, -11585, 29692, 25172, 25172, -5906, 16819, -29692, 5906, -16819, 16819, 5906, -29692, -16819, 5906, 25172, 25172, -29692};
-static __align16(const int16_t,M128_tab_i_35[])= {19266, 25172, 19266, 10426, 19266, -10426, 19266, -25172, 19266, 10426, -19266, -25172, -19266, 25172, 19266, -10426, 26722, 22654, 22654, -5315, 15137, -26722, 5315, -15137, 15137, 5315, -26722, -15137, 5315, 22654, 22654, -26722};
+static __align16(const int16_t, M128_tab_i_04[]) = {16384, 21407, 16384, 8867, 16384, -8867, 16384, -21407, 16384, 8867, -16384, -21407, -16384, 21407, 16384, -8867, 22725, 19266, 19266, -4520, 12873, -22725, 4520, -12873, 12873, 4520, -22725, -12873, 4520, 19266, 19266, -22725};
+static __align16(const int16_t, M128_tab_i_17[]) = {22725, 29692, 22725, 12299, 22725, -12299, 22725, -29692, 22725, 12299, -22725, -29692, -22725, 29692, 22725, -12299, 31521, 26722, 26722, -6270, 17855, -31521, 6270, -17855, 17855, 6270, -31521, -17855, 6270, 26722, 26722, -31521};
+static __align16(const int16_t, M128_tab_i_26[]) = {21407, 27969, 21407, 11585, 21407, -11585, 21407, -27969, 21407, 11585, -21407, -27969, -21407, 27969, 21407, -11585, 29692, 25172, 25172, -5906, 16819, -29692, 5906, -16819, 16819, 5906, -29692, -16819, 5906, 25172, 25172, -29692};
+static __align16(const int16_t, M128_tab_i_35[]) = {19266, 25172, 19266, 10426, 19266, -10426, 19266, -25172, 19266, 10426, -19266, -25172, -19266, 25172, 19266, -10426, 26722, 22654, 22654, -5315, 15137, -26722, 5315, -15137, 15137, 5315, -26722, -15137, 5315, 22654, 22654, -26722};
-static __forceinline void DCT_8_INV_ROW(const uint8_t * const ecx,const uint8_t * const esi,__m128i &xmm0,__m128i &xmm1,__m128i &xmm2,__m128i &xmm3,__m128i &xmm4,__m128i &xmm5,__m128i &xmm6,__m128i &xmm7)
+static __forceinline void DCT_8_INV_ROW(const uint8_t* const ecx, const uint8_t* const esi, __m128i& xmm0, __m128i& xmm1, __m128i& xmm2, __m128i& xmm3, __m128i& xmm4, __m128i& xmm5, __m128i& xmm6, __m128i& xmm7)
{
- xmm0=_mm_shufflelo_epi16(xmm0, 0xD8 );
- xmm1=_mm_shuffle_epi32( xmm0, 0 );
- pmaddwd (xmm1, esi);
- xmm3=_mm_shuffle_epi32( xmm0, 0x55);
- xmm0=_mm_shufflehi_epi16( xmm0, 0xD8 );
- pmaddwd( xmm3, esi+32 );
- xmm2=_mm_shuffle_epi32( xmm0, 0xAA );
- xmm0=_mm_shuffle_epi32( xmm0, 0xFF );
- pmaddwd( xmm2, esi+16 );
- xmm4=_mm_shufflehi_epi16( xmm4, 0xD8 );
- paddd (xmm1, M128_round_inv_row);
- xmm4=_mm_shufflelo_epi16 (xmm4, 0xD8 );
- pmaddwd (xmm0, esi+48 );
- xmm5=_mm_shuffle_epi32( xmm4, 0 );
- xmm6=_mm_shuffle_epi32( xmm4, 0xAA );
- pmaddwd (xmm5, ecx );
- paddd (xmm1, xmm2 );
- movdqa (xmm2, xmm1 );
- xmm7=_mm_shuffle_epi32( xmm4, 0x55 );
- pmaddwd (xmm6, ecx+16 );
- paddd (xmm0, xmm3 );
- xmm4=_mm_shuffle_epi32( xmm4, 0xFF );
- psubd (xmm2, xmm0 );
- pmaddwd (xmm7, ecx+32 );
- paddd (xmm0, xmm1 );
- psrad (xmm2, 12 );
- paddd (xmm5, M128_round_inv_row);
- pmaddwd (xmm4, ecx+48 );
- paddd (xmm5, xmm6 );
- movdqa (xmm6, xmm5 );
- psrad (xmm0, 12 );
- xmm2=_mm_shuffle_epi32( xmm2, 0x1B );
- packssdw (xmm0, xmm2 );
- paddd (xmm4, xmm7 );
- psubd (xmm6, xmm4 );
- paddd (xmm4, xmm5 );
- psrad (xmm6, 12 );
- psrad (xmm4, 12 );
- xmm6=_mm_shuffle_epi32( xmm6, 0x1B );
- packssdw (xmm4, xmm6 );
+ xmm0 = _mm_shufflelo_epi16(xmm0, 0xD8);
+ xmm1 = _mm_shuffle_epi32(xmm0, 0);
+ pmaddwd(xmm1, esi);
+ xmm3 = _mm_shuffle_epi32(xmm0, 0x55);
+ xmm0 = _mm_shufflehi_epi16(xmm0, 0xD8);
+ pmaddwd(xmm3, esi + 32);
+ xmm2 = _mm_shuffle_epi32(xmm0, 0xAA);
+ xmm0 = _mm_shuffle_epi32(xmm0, 0xFF);
+ pmaddwd(xmm2, esi + 16);
+ xmm4 = _mm_shufflehi_epi16(xmm4, 0xD8);
+ paddd(xmm1, M128_round_inv_row);
+ xmm4 = _mm_shufflelo_epi16(xmm4, 0xD8);
+ pmaddwd(xmm0, esi + 48);
+ xmm5 = _mm_shuffle_epi32(xmm4, 0);
+ xmm6 = _mm_shuffle_epi32(xmm4, 0xAA);
+ pmaddwd(xmm5, ecx);
+ paddd(xmm1, xmm2);
+ movdqa(xmm2, xmm1);
+ xmm7 = _mm_shuffle_epi32(xmm4, 0x55);
+ pmaddwd(xmm6, ecx + 16);
+ paddd(xmm0, xmm3);
+ xmm4 = _mm_shuffle_epi32(xmm4, 0xFF);
+ psubd(xmm2, xmm0);
+ pmaddwd(xmm7, ecx + 32);
+ paddd(xmm0, xmm1);
+ psrad(xmm2, 12);
+ paddd(xmm5, M128_round_inv_row);
+ pmaddwd(xmm4, ecx + 48);
+ paddd(xmm5, xmm6);
+ movdqa(xmm6, xmm5);
+ psrad(xmm0, 12);
+ xmm2 = _mm_shuffle_epi32(xmm2, 0x1B);
+ packssdw(xmm0, xmm2);
+ paddd(xmm4, xmm7);
+ psubd(xmm6, xmm4);
+ paddd(xmm4, xmm5);
+ psrad(xmm6, 12);
+ psrad(xmm4, 12);
+ xmm6 = _mm_shuffle_epi32(xmm6, 0x1B);
+ packssdw(xmm4, xmm6);
}
-static __forceinline void DCT_8_INV_COL_8(__m128i &src0,__m128i &src1,__m128i &src2,__m128i &src3,__m128i &src4,__m128i &src5,__m128i &src6,__m128i &src7,
- __m128i &xmm0,__m128i &xmm1,__m128i &xmm2,__m128i &xmm3,__m128i &xmm4,__m128i &xmm5,__m128i &xmm6,__m128i &xmm7)
+static __forceinline void DCT_8_INV_COL_8(__m128i& src0, __m128i& src1, __m128i& src2, __m128i& src3, __m128i& src4, __m128i& src5, __m128i& src6, __m128i& src7,
+ __m128i& xmm0, __m128i& xmm1, __m128i& xmm2, __m128i& xmm3, __m128i& xmm4, __m128i& xmm5, __m128i& xmm6, __m128i& xmm7)
{
- movdqa( xmm1, M128_tg_3_16 );
- movdqa( xmm2, xmm0 );
- movdqa( xmm3, src3 );
- pmulhw( xmm0, xmm1 );
- pmulhw( xmm1, xmm3 );
- movdqa( xmm5, M128_tg_1_16 );
- movdqa( xmm6, xmm4 );
- pmulhw( xmm4, xmm5 );
- paddsw( xmm0, xmm2 );
- pmulhw( xmm5, src1 );
- paddsw( xmm1, xmm3 );
- movdqa( xmm7, src6 );
- paddsw( xmm0, xmm3 );
- movdqa( xmm3, M128_tg_2_16 );
- psubsw( xmm2, xmm1 );
- pmulhw( xmm7, xmm3 );
- movdqa( xmm1, xmm0 );
- pmulhw( xmm3, src2 );
- psubsw( xmm5, xmm6 );
- paddsw( xmm4, src1 );
- paddsw( xmm0, xmm4 );
- paddsw( xmm0, M128_one_corr );
- psubsw( xmm4, xmm1 );
- movdqa( xmm6, xmm5 );
- psubsw( xmm5, xmm2 );
- paddsw( xmm5, M128_one_corr );
- paddsw( xmm6, xmm2 );
- movdqa( src7, xmm0 );
- movdqa( xmm1, xmm4 );
- movdqa( xmm0, M128_cos_4_16 );
- paddsw( xmm4, xmm5 );
- movdqa( xmm2, M128_cos_4_16 );
- pmulhw( xmm2, xmm4 );
- movdqa( src3, xmm6 );
- psubsw( xmm1, xmm5 );
- paddsw( xmm7, src2 );
- psubsw( xmm3, src6 );
- movdqa( xmm6, src0 );
- pmulhw( xmm0, xmm1 );
- movdqa( xmm5, src4 );
- paddsw( xmm5, xmm6 );
- psubsw( xmm6, src4 );
- paddsw( xmm4, xmm2 );
- por ( xmm4, M128_one_corr );
- paddsw( xmm0, xmm1 );
- por ( xmm0, M128_one_corr );
- movdqa( xmm2, xmm5 );
- paddsw( xmm5, xmm7 );
- movdqa( xmm1, xmm6 );
- paddsw( xmm5, M128_round_inv_col );
- psubsw( xmm2, xmm7 );
- movdqa( xmm7, src7 );
- paddsw( xmm6, xmm3 );
- paddsw( xmm6, M128_round_inv_col );
- paddsw( xmm7, xmm5 );
- psraw ( xmm7, SHIFT_INV_COL );
- psubsw( xmm1, xmm3 );
- paddsw( xmm1, M128_round_inv_corr );
- movdqa( xmm3, xmm6 );
- paddsw( xmm2, M128_round_inv_corr );
- paddsw( xmm6, xmm4 );
- movdqa( src0,xmm7 );
- psraw (xmm6, SHIFT_INV_COL );
- movdqa( xmm7, xmm1 );
- paddsw( xmm1, xmm0 );
- movdqa( src1, xmm6 );
- psraw (xmm1, SHIFT_INV_COL );
- movdqa( xmm6, src3 );
- psubsw( xmm7, xmm0 );
- psraw (xmm7, SHIFT_INV_COL );
- movdqa( src2, xmm1 );
- psubsw( xmm5, src7 );
- psraw (xmm5, SHIFT_INV_COL );
- movdqa( src7, xmm5 );
- psubsw( xmm3, xmm4 );
- paddsw( xmm6, xmm2 );
- psubsw( xmm2, src3 );
- psraw (xmm6, SHIFT_INV_COL );
- psraw (xmm2, SHIFT_INV_COL );
- movdqa( src3, xmm6 );
- psraw (xmm3, SHIFT_INV_COL );
- movdqa( src4, xmm2 );
- movdqa( src5, xmm7 );
- movdqa( src6, xmm3 );
+ movdqa(xmm1, M128_tg_3_16);
+ movdqa(xmm2, xmm0);
+ movdqa(xmm3, src3);
+ pmulhw(xmm0, xmm1);
+ pmulhw(xmm1, xmm3);
+ movdqa(xmm5, M128_tg_1_16);
+ movdqa(xmm6, xmm4);
+ pmulhw(xmm4, xmm5);
+ paddsw(xmm0, xmm2);
+ pmulhw(xmm5, src1);
+ paddsw(xmm1, xmm3);
+ movdqa(xmm7, src6);
+ paddsw(xmm0, xmm3);
+ movdqa(xmm3, M128_tg_2_16);
+ psubsw(xmm2, xmm1);
+ pmulhw(xmm7, xmm3);
+ movdqa(xmm1, xmm0);
+ pmulhw(xmm3, src2);
+ psubsw(xmm5, xmm6);
+ paddsw(xmm4, src1);
+ paddsw(xmm0, xmm4);
+ paddsw(xmm0, M128_one_corr);
+ psubsw(xmm4, xmm1);
+ movdqa(xmm6, xmm5);
+ psubsw(xmm5, xmm2);
+ paddsw(xmm5, M128_one_corr);
+ paddsw(xmm6, xmm2);
+ movdqa(src7, xmm0);
+ movdqa(xmm1, xmm4);
+ movdqa(xmm0, M128_cos_4_16);
+ paddsw(xmm4, xmm5);
+ movdqa(xmm2, M128_cos_4_16);
+ pmulhw(xmm2, xmm4);
+ movdqa(src3, xmm6);
+ psubsw(xmm1, xmm5);
+ paddsw(xmm7, src2);
+ psubsw(xmm3, src6);
+ movdqa(xmm6, src0);
+ pmulhw(xmm0, xmm1);
+ movdqa(xmm5, src4);
+ paddsw(xmm5, xmm6);
+ psubsw(xmm6, src4);
+ paddsw(xmm4, xmm2);
+ por(xmm4, M128_one_corr);
+ paddsw(xmm0, xmm1);
+ por(xmm0, M128_one_corr);
+ movdqa(xmm2, xmm5);
+ paddsw(xmm5, xmm7);
+ movdqa(xmm1, xmm6);
+ paddsw(xmm5, M128_round_inv_col);
+ psubsw(xmm2, xmm7);
+ movdqa(xmm7, src7);
+ paddsw(xmm6, xmm3);
+ paddsw(xmm6, M128_round_inv_col);
+ paddsw(xmm7, xmm5);
+ psraw(xmm7, SHIFT_INV_COL);
+ psubsw(xmm1, xmm3);
+ paddsw(xmm1, M128_round_inv_corr);
+ movdqa(xmm3, xmm6);
+ paddsw(xmm2, M128_round_inv_corr);
+ paddsw(xmm6, xmm4);
+ movdqa(src0, xmm7);
+ psraw(xmm6, SHIFT_INV_COL);
+ movdqa(xmm7, xmm1);
+ paddsw(xmm1, xmm0);
+ movdqa(src1, xmm6);
+ psraw(xmm1, SHIFT_INV_COL);
+ movdqa(xmm6, src3);
+ psubsw(xmm7, xmm0);
+ psraw(xmm7, SHIFT_INV_COL);
+ movdqa(src2, xmm1);
+ psubsw(xmm5, src7);
+ psraw(xmm5, SHIFT_INV_COL);
+ movdqa(src7, xmm5);
+ psubsw(xmm3, xmm4);
+ paddsw(xmm6, xmm2);
+ psubsw(xmm2, src3);
+ psraw(xmm6, SHIFT_INV_COL);
+ psraw(xmm2, SHIFT_INV_COL);
+ movdqa(src3, xmm6);
+ psraw(xmm3, SHIFT_INV_COL);
+ movdqa(src4, xmm2);
+ movdqa(src5, xmm7);
+ movdqa(src6, xmm3);
}
-static __forceinline void idct_M128ASM(__m128i &src0,__m128i &src1,__m128i &src2,__m128i &src3,__m128i &src4,__m128i &src5,__m128i &src6,__m128i &src7)
+static __forceinline void idct_M128ASM(__m128i& src0, __m128i& src1, __m128i& src2, __m128i& src3, __m128i& src4, __m128i& src5, __m128i& src6, __m128i& src7)
{
- __m128i xmm0,xmm1,xmm2,xmm3,xmm4,xmm5,xmm6,xmm7;
- movdqa (xmm0, src0);
- uint8_t *esi=(uint8_t*)M128_tab_i_04;
- movdqa (xmm4, src2);
- uint8_t *ecx=(uint8_t*)M128_tab_i_26;
- DCT_8_INV_ROW(ecx,esi,xmm0,xmm1,xmm2,xmm3,xmm4,xmm5,xmm6,xmm7);
- movdqa (src0, xmm0);
- movdqa (src2, xmm4);
+ __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;
+ movdqa(xmm0, src0);
+ uint8_t* esi = (uint8_t*)M128_tab_i_04;
+ movdqa(xmm4, src2);
+ uint8_t* ecx = (uint8_t*)M128_tab_i_26;
+ DCT_8_INV_ROW(ecx, esi, xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7);
+ movdqa(src0, xmm0);
+ movdqa(src2, xmm4);
- movdqa (xmm0, src4);
- movdqa (xmm4, src6);
- DCT_8_INV_ROW(ecx,esi,xmm0,xmm1,xmm2,xmm3,xmm4,xmm5,xmm6,xmm7);
- movdqa (src4, xmm0);
- movdqa (src6, xmm4);
+ movdqa(xmm0, src4);
+ movdqa(xmm4, src6);
+ DCT_8_INV_ROW(ecx, esi, xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7);
+ movdqa(src4, xmm0);
+ movdqa(src6, xmm4);
- movdqa (xmm0, src3);
- esi=(uint8_t*)M128_tab_i_35;
- movdqa (xmm4, src1);
- ecx=(uint8_t*)M128_tab_i_17;
- DCT_8_INV_ROW(ecx,esi,xmm0,xmm1,xmm2,xmm3,xmm4,xmm5,xmm6,xmm7);
- movdqa (src3, xmm0);
- movdqa (src1, xmm4);
+ movdqa(xmm0, src3);
+ esi = (uint8_t*)M128_tab_i_35;
+ movdqa(xmm4, src1);
+ ecx = (uint8_t*)M128_tab_i_17;
+ DCT_8_INV_ROW(ecx, esi, xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7);
+ movdqa(src3, xmm0);
+ movdqa(src1, xmm4);
- movdqa (xmm0, src5);
- movdqa (xmm4, src7);
- DCT_8_INV_ROW(ecx,esi,xmm0,xmm1,xmm2,xmm3,xmm4,xmm5,xmm6,xmm7);
- DCT_8_INV_COL_8(src0,src1,src2,src3,src4,src5,src6,src7,
- xmm0,xmm1,xmm2,xmm3,xmm4,xmm5,xmm6,xmm7);
+ movdqa(xmm0, src5);
+ movdqa(xmm4, src7);
+ DCT_8_INV_ROW(ecx, esi, xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7);
+ DCT_8_INV_COL_8(src0, src1, src2, src3, src4, src5, src6, src7,
+ xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7);
}
void mpeg2_idct_copy_sse2(int16_t* block, uint8_t* dest, const int stride)
{
- __m128i &src0=*(__m128i*)(block+0*16/2);
- __m128i &src1=*(__m128i*)(block+1*16/2);
- __m128i &src2=*(__m128i*)(block+2*16/2);
- __m128i &src3=*(__m128i*)(block+3*16/2);
- __m128i &src4=*(__m128i*)(block+4*16/2);
- __m128i &src5=*(__m128i*)(block+5*16/2);
- __m128i &src6=*(__m128i*)(block+6*16/2);
- __m128i &src7=*(__m128i*)(block+7*16/2);
- idct_M128ASM (src0,src1,src2,src3,src4,src5,src6,src7);
+ __m128i& src0 = *(__m128i*)(block + 0 * 16 / 2);
+ __m128i& src1 = *(__m128i*)(block + 1 * 16 / 2);
+ __m128i& src2 = *(__m128i*)(block + 2 * 16 / 2);
+ __m128i& src3 = *(__m128i*)(block + 3 * 16 / 2);
+ __m128i& src4 = *(__m128i*)(block + 4 * 16 / 2);
+ __m128i& src5 = *(__m128i*)(block + 5 * 16 / 2);
+ __m128i& src6 = *(__m128i*)(block + 6 * 16 / 2);
+ __m128i& src7 = *(__m128i*)(block + 7 * 16 / 2);
+ idct_M128ASM(src0, src1, src2, src3, src4, src5, src6, src7);
- __m128i zero = _mm_setzero_si128();
+ __m128i zero = _mm_setzero_si128();
- __m128i r0 = _mm_packus_epi16(_mm_load_si128(&src0), _mm_load_si128(&src1));
- __m128i r1 = _mm_packus_epi16(_mm_load_si128(&src2), _mm_load_si128(&src3));
- __m128i r2 = _mm_packus_epi16(_mm_load_si128(&src4), _mm_load_si128(&src5));
- __m128i r3 = _mm_packus_epi16(_mm_load_si128(&src6), _mm_load_si128(&src7));
+ __m128i r0 = _mm_packus_epi16(_mm_load_si128(&src0), _mm_load_si128(&src1));
+ __m128i r1 = _mm_packus_epi16(_mm_load_si128(&src2), _mm_load_si128(&src3));
+ __m128i r2 = _mm_packus_epi16(_mm_load_si128(&src4), _mm_load_si128(&src5));
+ __m128i r3 = _mm_packus_epi16(_mm_load_si128(&src6), _mm_load_si128(&src7));
- _mm_storel_pi((__m64*)&dest[0*stride], *(__m128*)&r0);
- _mm_storeh_pi((__m64*)&dest[1*stride], *(__m128*)&r0);
- _mm_storel_pi((__m64*)&dest[2*stride], *(__m128*)&r1);
- _mm_storeh_pi((__m64*)&dest[3*stride], *(__m128*)&r1);
- _mm_storel_pi((__m64*)&dest[4*stride], *(__m128*)&r2);
- _mm_storeh_pi((__m64*)&dest[5*stride], *(__m128*)&r2);
- _mm_storel_pi((__m64*)&dest[6*stride], *(__m128*)&r3);
- _mm_storeh_pi((__m64*)&dest[7*stride], *(__m128*)&r3);
+ _mm_storel_pi((__m64*)&dest[0 * stride], *(__m128*)&r0);
+ _mm_storeh_pi((__m64*)&dest[1 * stride], *(__m128*)&r0);
+ _mm_storel_pi((__m64*)&dest[2 * stride], *(__m128*)&r1);
+ _mm_storeh_pi((__m64*)&dest[3 * stride], *(__m128*)&r1);
+ _mm_storel_pi((__m64*)&dest[4 * stride], *(__m128*)&r2);
+ _mm_storeh_pi((__m64*)&dest[5 * stride], *(__m128*)&r2);
+ _mm_storel_pi((__m64*)&dest[6 * stride], *(__m128*)&r3);
+ _mm_storeh_pi((__m64*)&dest[7 * stride], *(__m128*)&r3);
- _mm_store_si128(&src0, zero);
- _mm_store_si128(&src1, zero);
- _mm_store_si128(&src2, zero);
- _mm_store_si128(&src3, zero);
- _mm_store_si128(&src4, zero);
- _mm_store_si128(&src5, zero);
- _mm_store_si128(&src6, zero);
- _mm_store_si128(&src7, zero);
+ _mm_store_si128(&src0, zero);
+ _mm_store_si128(&src1, zero);
+ _mm_store_si128(&src2, zero);
+ _mm_store_si128(&src3, zero);
+ _mm_store_si128(&src4, zero);
+ _mm_store_si128(&src5, zero);
+ _mm_store_si128(&src6, zero);
+ _mm_store_si128(&src7, zero);
}
-void mpeg2_idct_add_sse2(int,int16_t* block, uint8_t* dest, const int stride)
+void mpeg2_idct_add_sse2(int, int16_t* block, uint8_t* dest, const int stride)
{
- __m128i &src0=*(__m128i*)(block+0*16/2);
- __m128i &src1=*(__m128i*)(block+1*16/2);
- __m128i &src2=*(__m128i*)(block+2*16/2);
- __m128i &src3=*(__m128i*)(block+3*16/2);
- __m128i &src4=*(__m128i*)(block+4*16/2);
- __m128i &src5=*(__m128i*)(block+5*16/2);
- __m128i &src6=*(__m128i*)(block+6*16/2);
- __m128i &src7=*(__m128i*)(block+7*16/2);
- idct_M128ASM (src0,src1,src2,src3,src4,src5,src6,src7);
+ __m128i& src0 = *(__m128i*)(block + 0 * 16 / 2);
+ __m128i& src1 = *(__m128i*)(block + 1 * 16 / 2);
+ __m128i& src2 = *(__m128i*)(block + 2 * 16 / 2);
+ __m128i& src3 = *(__m128i*)(block + 3 * 16 / 2);
+ __m128i& src4 = *(__m128i*)(block + 4 * 16 / 2);
+ __m128i& src5 = *(__m128i*)(block + 5 * 16 / 2);
+ __m128i& src6 = *(__m128i*)(block + 6 * 16 / 2);
+ __m128i& src7 = *(__m128i*)(block + 7 * 16 / 2);
+ idct_M128ASM(src0, src1, src2, src3, src4, src5, src6, src7);
- __m128i zero = _mm_setzero_si128();
+ __m128i zero = _mm_setzero_si128();
- __m128i r0 = _mm_load_si128(&src0);
- __m128i r1 = _mm_load_si128(&src1);
- __m128i r2 = _mm_load_si128(&src2);
- __m128i r3 = _mm_load_si128(&src3);
- __m128i r4 = _mm_load_si128(&src4);
- __m128i r5 = _mm_load_si128(&src5);
- __m128i r6 = _mm_load_si128(&src6);
- __m128i r7 = _mm_load_si128(&src7);
+ __m128i r0 = _mm_load_si128(&src0);
+ __m128i r1 = _mm_load_si128(&src1);
+ __m128i r2 = _mm_load_si128(&src2);
+ __m128i r3 = _mm_load_si128(&src3);
+ __m128i r4 = _mm_load_si128(&src4);
+ __m128i r5 = _mm_load_si128(&src5);
+ __m128i r6 = _mm_load_si128(&src6);
+ __m128i r7 = _mm_load_si128(&src7);
- __m128 q0 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[0*stride]);
- __m128 q1 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[1*stride]);
- __m128 q2 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[2*stride]);
- __m128 q3 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[3*stride]);
- __m128 q4 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[4*stride]);
- __m128 q5 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[5*stride]);
- __m128 q6 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[6*stride]);
- __m128 q7 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[7*stride]);
+ __m128 q0 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[0 * stride]);
+ __m128 q1 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[1 * stride]);
+ __m128 q2 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[2 * stride]);
+ __m128 q3 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[3 * stride]);
+ __m128 q4 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[4 * stride]);
+ __m128 q5 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[5 * stride]);
+ __m128 q6 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[6 * stride]);
+ __m128 q7 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[7 * stride]);
- r0 = _mm_adds_epi16(r0, _mm_unpacklo_epi8(*(__m128i*)&q0, zero));
- r1 = _mm_adds_epi16(r1, _mm_unpacklo_epi8(*(__m128i*)&q1, zero));
- r2 = _mm_adds_epi16(r2, _mm_unpacklo_epi8(*(__m128i*)&q2, zero));
- r3 = _mm_adds_epi16(r3, _mm_unpacklo_epi8(*(__m128i*)&q3, zero));
- r4 = _mm_adds_epi16(r4, _mm_unpacklo_epi8(*(__m128i*)&q4, zero));
- r5 = _mm_adds_epi16(r5, _mm_unpacklo_epi8(*(__m128i*)&q5, zero));
- r6 = _mm_adds_epi16(r6, _mm_unpacklo_epi8(*(__m128i*)&q6, zero));
- r7 = _mm_adds_epi16(r7, _mm_unpacklo_epi8(*(__m128i*)&q7, zero));
+ r0 = _mm_adds_epi16(r0, _mm_unpacklo_epi8(*(__m128i*)&q0, zero));
+ r1 = _mm_adds_epi16(r1, _mm_unpacklo_epi8(*(__m128i*)&q1, zero));
+ r2 = _mm_adds_epi16(r2, _mm_unpacklo_epi8(*(__m128i*)&q2, zero));
+ r3 = _mm_adds_epi16(r3, _mm_unpacklo_epi8(*(__m128i*)&q3, zero));
+ r4 = _mm_adds_epi16(r4, _mm_unpacklo_epi8(*(__m128i*)&q4, zero));
+ r5 = _mm_adds_epi16(r5, _mm_unpacklo_epi8(*(__m128i*)&q5, zero));
+ r6 = _mm_adds_epi16(r6, _mm_unpacklo_epi8(*(__m128i*)&q6, zero));
+ r7 = _mm_adds_epi16(r7, _mm_unpacklo_epi8(*(__m128i*)&q7, zero));
- r0 = _mm_packus_epi16(r0, r1);
- r1 = _mm_packus_epi16(r2, r3);
- r2 = _mm_packus_epi16(r4, r5);
- r3 = _mm_packus_epi16(r6, r7);
+ r0 = _mm_packus_epi16(r0, r1);
+ r1 = _mm_packus_epi16(r2, r3);
+ r2 = _mm_packus_epi16(r4, r5);
+ r3 = _mm_packus_epi16(r6, r7);
- _mm_storel_pi((__m64*)&dest[0*stride], *(__m128*)&r0);
- _mm_storeh_pi((__m64*)&dest[1*stride], *(__m128*)&r0);
- _mm_storel_pi((__m64*)&dest[2*stride], *(__m128*)&r1);
- _mm_storeh_pi((__m64*)&dest[3*stride], *(__m128*)&r1);
- _mm_storel_pi((__m64*)&dest[4*stride], *(__m128*)&r2);
- _mm_storeh_pi((__m64*)&dest[5*stride], *(__m128*)&r2);
- _mm_storel_pi((__m64*)&dest[6*stride], *(__m128*)&r3);
- _mm_storeh_pi((__m64*)&dest[7*stride], *(__m128*)&r3);
+ _mm_storel_pi((__m64*)&dest[0 * stride], *(__m128*)&r0);
+ _mm_storeh_pi((__m64*)&dest[1 * stride], *(__m128*)&r0);
+ _mm_storel_pi((__m64*)&dest[2 * stride], *(__m128*)&r1);
+ _mm_storeh_pi((__m64*)&dest[3 * stride], *(__m128*)&r1);
+ _mm_storel_pi((__m64*)&dest[4 * stride], *(__m128*)&r2);
+ _mm_storeh_pi((__m64*)&dest[5 * stride], *(__m128*)&r2);
+ _mm_storel_pi((__m64*)&dest[6 * stride], *(__m128*)&r3);
+ _mm_storeh_pi((__m64*)&dest[7 * stride], *(__m128*)&r3);
- _mm_store_si128(&src0, zero);
- _mm_store_si128(&src1, zero);
- _mm_store_si128(&src2, zero);
- _mm_store_si128(&src3, zero);
- _mm_store_si128(&src4, zero);
- _mm_store_si128(&src5, zero);
- _mm_store_si128(&src6, zero);
- _mm_store_si128(&src7, zero);
+ _mm_store_si128(&src0, zero);
+ _mm_store_si128(&src1, zero);
+ _mm_store_si128(&src2, zero);
+ _mm_store_si128(&src3, zero);
+ _mm_store_si128(&src4, zero);
+ _mm_store_si128(&src5, zero);
+ _mm_store_si128(&src6, zero);
+ _mm_store_si128(&src7, zero);
}
void mpeg2_idct_init_sse2()
diff --git a/src/filters/transform/Mpeg2DecFilter/mc_sse2.cpp b/src/filters/transform/Mpeg2DecFilter/mc_sse2.cpp
index ff0de812e..33fedcbb5 100644
--- a/src/filters/transform/Mpeg2DecFilter/mc_sse2.cpp
+++ b/src/filters/transform/Mpeg2DecFilter/mc_sse2.cpp
@@ -30,456 +30,456 @@
#include "attributes.h"
#include "../../../DSUtil/simd.h"
-static const __m128i const_1_16_bytes=_mm_set1_epi16(1);
+static const __m128i const_1_16_bytes = _mm_set1_epi16(1);
static void MC_put_o_16_sse2(uint8_t* ecx, const uint8_t* edx, const int eax, int esi)
{
- const int edi= eax+eax;
- const int ebx= edi+eax;
- for (; esi; edx+=edi*2,ecx+=edi*2,esi-=4) {
- __m128i xmm0,xmm1,xmm2,xmm3;
- movdqu (xmm0, edx );
- movdqu (xmm1, edx+eax);
- movdqu (xmm2, edx+edi);
- movdqu (xmm3, edx+ebx);
- movdqa (ecx, xmm0 );
- movdqa (ecx+eax, xmm1 );
- movdqa (ecx+edi, xmm2 );
- movdqa (ecx+ebx, xmm3 );
- }
+ const int edi = eax + eax;
+ const int ebx = edi + eax;
+ for (; esi; edx += edi * 2, ecx += edi * 2, esi -= 4) {
+ __m128i xmm0, xmm1, xmm2, xmm3;
+ movdqu(xmm0, edx);
+ movdqu(xmm1, edx + eax);
+ movdqu(xmm2, edx + edi);
+ movdqu(xmm3, edx + ebx);
+ movdqa(ecx, xmm0);
+ movdqa(ecx + eax, xmm1);
+ movdqa(ecx + edi, xmm2);
+ movdqa(ecx + ebx, xmm3);
+ }
}
static void MC_put_o_8_sse2(uint8_t* ecx, const uint8_t* edx, const int eax, int esi)
{
- const int edi= eax+eax;
- const int ebx= edi+eax;
- for (; esi; edx+=edi*2,ecx+=edi*2,esi-=4) {
- __m128d xmm0,xmm1,xmm2,xmm3;
- movlpd (xmm0, edx);
- movlpd (xmm1, edx+eax);
- movlpd (xmm2, edx+edi);
- movlpd (xmm3, edx+ebx);
- movlpd (ecx, xmm0);
- movlpd (ecx+eax, xmm1 );
- movlpd (ecx+edi, xmm2);
- movlpd (ecx+ebx, xmm3 );
- }
+ const int edi = eax + eax;
+ const int ebx = edi + eax;
+ for (; esi; edx += edi * 2, ecx += edi * 2, esi -= 4) {
+ __m128d xmm0, xmm1, xmm2, xmm3;
+ movlpd(xmm0, edx);
+ movlpd(xmm1, edx + eax);
+ movlpd(xmm2, edx + edi);
+ movlpd(xmm3, edx + ebx);
+ movlpd(ecx, xmm0);
+ movlpd(ecx + eax, xmm1);
+ movlpd(ecx + edi, xmm2);
+ movlpd(ecx + ebx, xmm3);
+ }
}
static void MC_put_x_16_sse2(uint8_t* ecx, const uint8_t* edx, const int eax, int esi)
{
- const int edi= eax+eax;
- const int ebx= edi+eax;
- for (; esi; edx+=edi*2,ecx+=edi*2,esi-=4) {
- __m128i xmm0,xmm1,xmm2,xmm3,xmm4,xmm5,xmm6,xmm7;
- movdqu (xmm0, edx);
- movdqu (xmm1, edx+1);
- movdqu (xmm2, edx+eax);
- movdqu (xmm3, edx+eax+1);
- movdqu (xmm4, edx+edi);
- movdqu( xmm5, edx+edi+1);
- movdqu( xmm6, edx+ebx );
- movdqu( xmm7, edx+ebx+1 );
- pavgb (xmm0, xmm1);
- pavgb (xmm2, xmm3);
- pavgb (xmm4, xmm5);
- pavgb (xmm6, xmm7);
- movdqa (ecx, xmm0);
- movdqa (ecx+eax, xmm2);
- movdqa (ecx+edi, xmm4);
- movdqa (ecx+ebx, xmm6);
- }
+ const int edi = eax + eax;
+ const int ebx = edi + eax;
+ for (; esi; edx += edi * 2, ecx += edi * 2, esi -= 4) {
+ __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;
+ movdqu(xmm0, edx);
+ movdqu(xmm1, edx + 1);
+ movdqu(xmm2, edx + eax);
+ movdqu(xmm3, edx + eax + 1);
+ movdqu(xmm4, edx + edi);
+ movdqu(xmm5, edx + edi + 1);
+ movdqu(xmm6, edx + ebx);
+ movdqu(xmm7, edx + ebx + 1);
+ pavgb(xmm0, xmm1);
+ pavgb(xmm2, xmm3);
+ pavgb(xmm4, xmm5);
+ pavgb(xmm6, xmm7);
+ movdqa(ecx, xmm0);
+ movdqa(ecx + eax, xmm2);
+ movdqa(ecx + edi, xmm4);
+ movdqa(ecx + ebx, xmm6);
+ }
}
static void MC_put_x_8_sse2(uint8_t* ecx, const uint8_t* edx, const int eax, int esi)
{
- const int edi= eax+eax;
- const int ebx= edi+eax;
- __m128i xmm0,xmm1,xmm2,xmm3;
- for (; esi; edx+=edi*2,ecx+=edi*2,esi-=4) {
- movlpd (xmm0, edx);
- movlpd (xmm1, edx+1);
- movhpd (xmm0, edx+eax);
- movhpd (xmm1, edx+eax+1);
- movlpd (xmm2, edx+edi);
- movlpd (xmm3, edx+edi+1);
- movhpd (xmm2, edx+ebx);
- movhpd (xmm3, edx+ebx+1);
- pavgb (xmm0, xmm1);
- pavgb (xmm2, xmm3);
- movlpd (ecx, xmm0);
- movhpd (ecx+eax, xmm0);
- movlpd (ecx+edi, xmm2);
- movhpd (ecx+ebx, xmm2);
- }
+ const int edi = eax + eax;
+ const int ebx = edi + eax;
+ __m128i xmm0, xmm1, xmm2, xmm3;
+ for (; esi; edx += edi * 2, ecx += edi * 2, esi -= 4) {
+ movlpd(xmm0, edx);
+ movlpd(xmm1, edx + 1);
+ movhpd(xmm0, edx + eax);
+ movhpd(xmm1, edx + eax + 1);
+ movlpd(xmm2, edx + edi);
+ movlpd(xmm3, edx + edi + 1);
+ movhpd(xmm2, edx + ebx);
+ movhpd(xmm3, edx + ebx + 1);
+ pavgb(xmm0, xmm1);
+ pavgb(xmm2, xmm3);
+ movlpd(ecx, xmm0);
+ movhpd(ecx + eax, xmm0);
+ movlpd(ecx + edi, xmm2);
+ movhpd(ecx + ebx, xmm2);
+ }
}
static void MC_put_y_16_sse2(uint8_t* ecx, const uint8_t* edx, const int eax, int esi)
{
- const int edi= eax+eax;
- const int ebx= edi+eax;
- __m128i xmm0;
- movdqu (xmm0, edx);
- for (; esi; edx+=edi*2,ecx+=edi*2,esi-=4) {
- __m128i xmm1,xmm2,xmm3,xmm4;
- movdqu (xmm1, edx+eax);
- movdqu (xmm2, edx+edi );
- movdqu (xmm3, edx+ebx );
- movdqu (xmm4, edx+edi*2 );
- pavgb (xmm0, xmm1 );
- pavgb (xmm1, xmm2 );
- pavgb (xmm2, xmm3 );
- pavgb (xmm3, xmm4 );
- movdqa (ecx, xmm0 );
- movdqa (ecx+eax, xmm1 );
- movdqa (ecx+edi, xmm2 );
- movdqa (ecx+ebx, xmm3 );
- movdqa (xmm0, xmm4 );
- }
+ const int edi = eax + eax;
+ const int ebx = edi + eax;
+ __m128i xmm0;
+ movdqu(xmm0, edx);
+ for (; esi; edx += edi * 2, ecx += edi * 2, esi -= 4) {
+ __m128i xmm1, xmm2, xmm3, xmm4;
+ movdqu(xmm1, edx + eax);
+ movdqu(xmm2, edx + edi);
+ movdqu(xmm3, edx + ebx);
+ movdqu(xmm4, edx + edi * 2);
+ pavgb(xmm0, xmm1);
+ pavgb(xmm1, xmm2);
+ pavgb(xmm2, xmm3);
+ pavgb(xmm3, xmm4);
+ movdqa(ecx, xmm0);
+ movdqa(ecx + eax, xmm1);
+ movdqa(ecx + edi, xmm2);
+ movdqa(ecx + ebx, xmm3);
+ movdqa(xmm0, xmm4);
+ }
}
static void MC_put_y_8_sse2(uint8_t* ecx, const uint8_t* edx, const int eax, int esi)
{
- const int edi= eax+eax;
- const int ebx= edi+eax;
- __m128i xmm0;
- movlpd (xmm0, edx);
+ const int edi = eax + eax;
+ const int ebx = edi + eax;
+ __m128i xmm0;
+ movlpd(xmm0, edx);
- for (; esi; edx+=edi*2,ecx+=edi*2,esi-=4) {
- __m128i xmm1,xmm2,xmm3,xmm4;
- movlpd (xmm1, edx+eax );
- movlpd (xmm2, edx+edi );
- movlpd (xmm3, edx+ebx );
- movlpd (xmm4, edx+edi*2 );
- pavgb (xmm0, xmm1 );
- pavgb (xmm1, xmm2);
- pavgb (xmm2, xmm3 );
- pavgb (xmm3, xmm4 );
- movlpd (ecx, xmm0 );
- movlpd (ecx+eax, xmm1 );
- movlpd (ecx+edi, xmm2 );
- movlpd (ecx+ebx, xmm3 );
- movdqa (xmm0, xmm4 );
- }
+ for (; esi; edx += edi * 2, ecx += edi * 2, esi -= 4) {
+ __m128i xmm1, xmm2, xmm3, xmm4;
+ movlpd(xmm1, edx + eax);
+ movlpd(xmm2, edx + edi);
+ movlpd(xmm3, edx + ebx);
+ movlpd(xmm4, edx + edi * 2);
+ pavgb(xmm0, xmm1);
+ pavgb(xmm1, xmm2);
+ pavgb(xmm2, xmm3);
+ pavgb(xmm3, xmm4);
+ movlpd(ecx, xmm0);
+ movlpd(ecx + eax, xmm1);
+ movlpd(ecx + edi, xmm2);
+ movlpd(ecx + ebx, xmm3);
+ movdqa(xmm0, xmm4);
+ }
}
static void MC_put_xy_16_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
{
- const uint8_t *edx= ref ;
- uint8_t *ecx= dest;
- int eax= stride;
- int esi= height;
- int edi= eax+eax;
- __m128i xmm7,xmm0,xmm1,xmm4,xmm5,xmm2,xmm3;
- movdqa (xmm7, const_1_16_bytes );
- movdqu (xmm0, edx );
- movdqu (xmm1, edx+1 );
- for (; esi; edx+= edi,ecx+= edi,esi-= 2) {
- movdqu (xmm2, edx+eax );
- movdqu (xmm3, edx+eax+1 );
- movdqu (xmm4, edx+edi );
- movdqu (xmm5, edx+edi+1 );
- pavgb (xmm0, xmm1 );
- pavgb (xmm2, xmm3 );
- movdqa( xmm1, xmm5 );
- pavgb (xmm5, xmm4 );
- psubusb( xmm2, xmm7 );
- pavgb (xmm0, xmm2 );
- pavgb (xmm2, xmm5);
- movdqa (ecx, xmm0);
- movdqa (xmm0, xmm4);
- movdqa (ecx+eax, xmm2);
- }
+ const uint8_t* edx = ref ;
+ uint8_t* ecx = dest;
+ int eax = stride;
+ int esi = height;
+ int edi = eax + eax;
+ __m128i xmm7, xmm0, xmm1, xmm4, xmm5, xmm2, xmm3;
+ movdqa(xmm7, const_1_16_bytes);
+ movdqu(xmm0, edx);
+ movdqu(xmm1, edx + 1);
+ for (; esi; edx += edi, ecx += edi, esi -= 2) {
+ movdqu(xmm2, edx + eax);
+ movdqu(xmm3, edx + eax + 1);
+ movdqu(xmm4, edx + edi);
+ movdqu(xmm5, edx + edi + 1);
+ pavgb(xmm0, xmm1);
+ pavgb(xmm2, xmm3);
+ movdqa(xmm1, xmm5);
+ pavgb(xmm5, xmm4);
+ psubusb(xmm2, xmm7);
+ pavgb(xmm0, xmm2);
+ pavgb(xmm2, xmm5);
+ movdqa(ecx, xmm0);
+ movdqa(xmm0, xmm4);
+ movdqa(ecx + eax, xmm2);
+ }
}
static void MC_put_xy_8_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
{
- const uint8_t *edx= ref;
- uint8_t *ecx= dest;
- int eax= stride;
- int esi= height;
- int edi= eax+eax;
- __m128i xmm7,xmm0,xmm2,xmm1,xmm3,xmm4,xmm5;
- movdqa (xmm7, const_1_16_bytes);
- movlpd (xmm0, edx);
- movlpd (xmm1, edx+1);
- for (; esi; edx+= edi,ecx+= edi,esi-= 2) {
- movlpd (xmm2, edx+eax);
- movlpd (xmm3, edx+eax+1);
- movlpd (xmm4, edx+edi);
- movlpd (xmm5, edx+edi+1);
- pavgb (xmm0, xmm1 );
- pavgb (xmm2, xmm3 );
- movdqa( xmm1, xmm5 );
- pavgb (xmm5, xmm4 );
- psubusb( xmm2, xmm7 );
- pavgb (xmm0, xmm2 );
- pavgb (xmm2, xmm5);
- movlpd (ecx, xmm0);
- movdqa (xmm0, xmm4);
- movlpd (ecx+eax, xmm2);
- }
+ const uint8_t* edx = ref;
+ uint8_t* ecx = dest;
+ int eax = stride;
+ int esi = height;
+ int edi = eax + eax;
+ __m128i xmm7, xmm0, xmm2, xmm1, xmm3, xmm4, xmm5;
+ movdqa(xmm7, const_1_16_bytes);
+ movlpd(xmm0, edx);
+ movlpd(xmm1, edx + 1);
+ for (; esi; edx += edi, ecx += edi, esi -= 2) {
+ movlpd(xmm2, edx + eax);
+ movlpd(xmm3, edx + eax + 1);
+ movlpd(xmm4, edx + edi);
+ movlpd(xmm5, edx + edi + 1);
+ pavgb(xmm0, xmm1);
+ pavgb(xmm2, xmm3);
+ movdqa(xmm1, xmm5);
+ pavgb(xmm5, xmm4);
+ psubusb(xmm2, xmm7);
+ pavgb(xmm0, xmm2);
+ pavgb(xmm2, xmm5);
+ movlpd(ecx, xmm0);
+ movdqa(xmm0, xmm4);
+ movlpd(ecx + eax, xmm2);
+ }
}
static void MC_avg_o_16_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
{
- const uint8_t *edx= ref;
- uint8_t *ecx= dest;
- int esi= height;
- int eax= stride;
- int edi= eax+eax;
- int ebx= edi+eax;
+ const uint8_t* edx = ref;
+ uint8_t* ecx = dest;
+ int esi = height;
+ int eax = stride;
+ int edi = eax + eax;
+ int ebx = edi + eax;
- for (; esi; edx+=edi*2,ecx+=edi*2,esi-=4) {
- __m128i xmm0,xmm1,xmm2,xmm3;
- movdqu (xmm0, edx);
- movdqu (xmm1, edx+eax );
- movdqu (xmm2, edx+edi);
- movdqu (xmm3, edx+ebx );
- pavgb (xmm0, ecx);
- pavgb (xmm1, ecx+eax);
- pavgb (xmm2, ecx+edi);
- pavgb (xmm3, ecx+ebx);
- movdqa (ecx, xmm0);
- movdqa (ecx+eax, xmm1 );
- movdqa (ecx+edi, xmm2);
- movdqa (ecx+ebx, xmm3 );
- }
+ for (; esi; edx += edi * 2, ecx += edi * 2, esi -= 4) {
+ __m128i xmm0, xmm1, xmm2, xmm3;
+ movdqu(xmm0, edx);
+ movdqu(xmm1, edx + eax);
+ movdqu(xmm2, edx + edi);
+ movdqu(xmm3, edx + ebx);
+ pavgb(xmm0, ecx);
+ pavgb(xmm1, ecx + eax);
+ pavgb(xmm2, ecx + edi);
+ pavgb(xmm3, ecx + ebx);
+ movdqa(ecx, xmm0);
+ movdqa(ecx + eax, xmm1);
+ movdqa(ecx + edi, xmm2);
+ movdqa(ecx + ebx, xmm3);
+ }
}
static void MC_avg_o_8_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
{
- const uint8_t *edx= ref;
- uint8_t *ecx= dest;
- int esi= height;
- int eax= stride;
- int edi= eax+eax;
- int ebx= edi+eax;
+ const uint8_t* edx = ref;
+ uint8_t* ecx = dest;
+ int esi = height;
+ int eax = stride;
+ int edi = eax + eax;
+ int ebx = edi + eax;
- __m128i xmm0,xmm1,xmm2,xmm3;
- for (; esi; edx+=edi*2,ecx+=edi*2,esi-=4) {
- movlpd (xmm0, edx);
- movhpd (xmm0, edx+eax );
- movlpd (xmm2, edx+edi);
- movhpd (xmm2, edx+ebx );
- movlpd (xmm1, ecx);
- movhpd (xmm1, ecx+eax);
- movlpd (xmm3, ecx+edi);
- movhpd (xmm3, ecx+ebx);
- pavgb (xmm0, xmm1);
- pavgb (xmm2, xmm3);
- movlpd (ecx, xmm0);
- movhpd (ecx+eax, xmm0);
- movlpd (ecx+edi, xmm2);
- movhpd (ecx+ebx, xmm2);
- }
+ __m128i xmm0, xmm1, xmm2, xmm3;
+ for (; esi; edx += edi * 2, ecx += edi * 2, esi -= 4) {
+ movlpd(xmm0, edx);
+ movhpd(xmm0, edx + eax);
+ movlpd(xmm2, edx + edi);
+ movhpd(xmm2, edx + ebx);
+ movlpd(xmm1, ecx);
+ movhpd(xmm1, ecx + eax);
+ movlpd(xmm3, ecx + edi);
+ movhpd(xmm3, ecx + ebx);
+ pavgb(xmm0, xmm1);
+ pavgb(xmm2, xmm3);
+ movlpd(ecx, xmm0);
+ movhpd(ecx + eax, xmm0);
+ movlpd(ecx + edi, xmm2);
+ movhpd(ecx + ebx, xmm2);
+ }
}
static void MC_avg_x_16_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
{
- const uint8_t *edx= ref;
- uint8_t *ecx= dest;
- int esi= height;
- int eax= stride;
- int edi= eax+eax;
- int ebx= edi+eax;
+ const uint8_t* edx = ref;
+ uint8_t* ecx = dest;
+ int esi = height;
+ int eax = stride;
+ int edi = eax + eax;
+ int ebx = edi + eax;
- __m128i xmm0,xmm1,xmm2,xmm3,xmm4,xmm5,xmm6,xmm7;
- for (; esi; edx+=edi*2,ecx+=edi*2,esi-=4) {
- movdqu (xmm0, edx);
- movdqu (xmm1, edx+1);
- movdqu (xmm2, edx+eax);
- movdqu (xmm3, edx+eax+1);
- movdqu (xmm4, edx+edi);
- movdqu (xmm5, edx+edi+1);
- movdqu (xmm6, edx+ebx);
- movdqu (xmm7, edx+ebx+1);
- pavgb (xmm0, xmm1);
- pavgb (xmm2, xmm3);
- pavgb (xmm4, xmm5);
- pavgb (xmm6, xmm7);
- pavgb (xmm0, ecx);
- pavgb (xmm2, ecx+eax);
- pavgb (xmm4, ecx+edi);
- pavgb (xmm6, ecx+ebx);
- movdqa (ecx, xmm0);
- movdqa (ecx+eax, xmm2);
- movdqa (ecx+edi, xmm4);
- movdqa (ecx+ebx, xmm6);
- }
+ __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;
+ for (; esi; edx += edi * 2, ecx += edi * 2, esi -= 4) {
+ movdqu(xmm0, edx);
+ movdqu(xmm1, edx + 1);
+ movdqu(xmm2, edx + eax);
+ movdqu(xmm3, edx + eax + 1);
+ movdqu(xmm4, edx + edi);
+ movdqu(xmm5, edx + edi + 1);
+ movdqu(xmm6, edx + ebx);
+ movdqu(xmm7, edx + ebx + 1);
+ pavgb(xmm0, xmm1);
+ pavgb(xmm2, xmm3);
+ pavgb(xmm4, xmm5);
+ pavgb(xmm6, xmm7);
+ pavgb(xmm0, ecx);
+ pavgb(xmm2, ecx + eax);
+ pavgb(xmm4, ecx + edi);
+ pavgb(xmm6, ecx + ebx);
+ movdqa(ecx, xmm0);
+ movdqa(ecx + eax, xmm2);
+ movdqa(ecx + edi, xmm4);
+ movdqa(ecx + ebx, xmm6);
+ }
}
static void MC_avg_x_8_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
{
- const uint8_t *edx= ref;
- uint8_t *ecx= dest;
- int esi= height;
- int eax= stride;
- int edi= eax+eax;
- int ebx= edi+eax;
+ const uint8_t* edx = ref;
+ uint8_t* ecx = dest;
+ int esi = height;
+ int eax = stride;
+ int edi = eax + eax;
+ int ebx = edi + eax;
- __m128i xmm0,xmm1,xmm2,xmm3,xmm4,xmm5;
- for (; esi; edx+=edi*2,ecx+=edi*2,esi-=4) {
- movlpd (xmm0, edx);
- movlpd (xmm1, edx+1);
- movhpd (xmm0, edx+eax);
- movhpd (xmm1, edx+eax+1);
- movlpd (xmm2, edx+edi);
- movlpd (xmm3, edx+edi+1);
- movhpd (xmm2, edx+ebx);
- movhpd (xmm3, edx+ebx+1);
- movlpd (xmm4, ecx);
- movhpd (xmm4, ecx+eax);
- movlpd (xmm5, ecx+edi);
- movhpd (xmm5, ecx+ebx);
- pavgb (xmm0, xmm1);
- pavgb (xmm2, xmm3);
- pavgb (xmm0, xmm4);
- pavgb (xmm2, xmm5);
- movlpd (ecx, xmm0);
- movhpd (ecx+eax, xmm0);
- movlpd (ecx+edi, xmm2);
- movhpd (ecx+ebx, xmm2);
- }
+ __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5;
+ for (; esi; edx += edi * 2, ecx += edi * 2, esi -= 4) {
+ movlpd(xmm0, edx);
+ movlpd(xmm1, edx + 1);
+ movhpd(xmm0, edx + eax);
+ movhpd(xmm1, edx + eax + 1);
+ movlpd(xmm2, edx + edi);
+ movlpd(xmm3, edx + edi + 1);
+ movhpd(xmm2, edx + ebx);
+ movhpd(xmm3, edx + ebx + 1);
+ movlpd(xmm4, ecx);
+ movhpd(xmm4, ecx + eax);
+ movlpd(xmm5, ecx + edi);
+ movhpd(xmm5, ecx + ebx);
+ pavgb(xmm0, xmm1);
+ pavgb(xmm2, xmm3);
+ pavgb(xmm0, xmm4);
+ pavgb(xmm2, xmm5);
+ movlpd(ecx, xmm0);
+ movhpd(ecx + eax, xmm0);
+ movlpd(ecx + edi, xmm2);
+ movhpd(ecx + ebx, xmm2);
+ }
}
static void MC_avg_y_16_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
{
- const uint8_t *edx= ref;
- uint8_t *ecx= dest;
- int esi= height;
- int eax= stride;
- int edi= eax+eax;
- int ebx= edi+eax;
- __m128i xmm0,xmm1,xmm2,xmm3,xmm4;
+ const uint8_t* edx = ref;
+ uint8_t* ecx = dest;
+ int esi = height;
+ int eax = stride;
+ int edi = eax + eax;
+ int ebx = edi + eax;
+ __m128i xmm0, xmm1, xmm2, xmm3, xmm4;
- movdqu (xmm0,edx);
- for (; esi; edx+=edi*2,ecx+=edi*2,esi-=4) {
- movdqu (xmm1, edx+eax );
- movdqu (xmm2, edx+edi );
- movdqu (xmm3, edx+ebx );
- movdqu (xmm4, edx+edi*2 );
- pavgb (xmm0, xmm1 );
- pavgb (xmm1, xmm2 );
- pavgb (xmm2, xmm3 );
- pavgb (xmm3, xmm4 );
- pavgb (xmm0, ecx);
- pavgb (xmm1, ecx+eax );
- pavgb (xmm2, ecx+edi);
- pavgb (xmm3, ecx+ebx );
- movdqa (ecx, xmm0 );
- movdqa (ecx+eax, xmm1 );
- movdqa (ecx+edi, xmm2 );
- movdqa (ecx+ebx, xmm3 );
- movdqa (xmm0, xmm4 );
- }
+ movdqu(xmm0, edx);
+ for (; esi; edx += edi * 2, ecx += edi * 2, esi -= 4) {
+ movdqu(xmm1, edx + eax);
+ movdqu(xmm2, edx + edi);
+ movdqu(xmm3, edx + ebx);
+ movdqu(xmm4, edx + edi * 2);
+ pavgb(xmm0, xmm1);
+ pavgb(xmm1, xmm2);
+ pavgb(xmm2, xmm3);
+ pavgb(xmm3, xmm4);
+ pavgb(xmm0, ecx);
+ pavgb(xmm1, ecx + eax);
+ pavgb(xmm2, ecx + edi);
+ pavgb(xmm3, ecx + ebx);
+ movdqa(ecx, xmm0);
+ movdqa(ecx + eax, xmm1);
+ movdqa(ecx + edi, xmm2);
+ movdqa(ecx + ebx, xmm3);
+ movdqa(xmm0, xmm4);
+ }
}
static void MC_avg_y_8_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
{
- const uint8_t *edx= ref;
- uint8_t *ecx= dest;
- int esi= height;
- int eax= stride;
- int edi= eax+eax;
- int ebx= edi+eax;
- __m128i xmm0,xmm1,xmm2,xmm3,xmm4,xmm5;
- movhpd (xmm0, edx );
- movlpd (xmm0, edx+eax );
- for (; esi; edx+=edi*2,ecx+=edi*2,esi-=4) {
- movlhps (xmm1, xmm0);
- movlpd (xmm1, edx+edi );
- movlhps (xmm2, xmm1);
- movlpd (xmm2, edx+ebx );
- movlhps (xmm3, xmm2);
- movlpd (xmm3, edx+edi*2 );
- movhpd (xmm4, ecx );
- movlpd (xmm4, ecx+eax );
- movhpd (xmm5, ecx+edi );
- movlpd (xmm5, ecx+ebx );
- pavgb (xmm0, xmm1 );
- pavgb (xmm2, xmm3);
- pavgb (xmm0, xmm4);
- pavgb (xmm2, xmm5);
- movhpd (ecx, xmm0 );
- movlpd (ecx+eax, xmm0 );
- movhpd (ecx+edi, xmm2 );
- movlpd (ecx+ebx, xmm2);
- movdqa (xmm0, xmm3 );
- }
+ const uint8_t* edx = ref;
+ uint8_t* ecx = dest;
+ int esi = height;
+ int eax = stride;
+ int edi = eax + eax;
+ int ebx = edi + eax;
+ __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5;
+ movhpd(xmm0, edx);
+ movlpd(xmm0, edx + eax);
+ for (; esi; edx += edi * 2, ecx += edi * 2, esi -= 4) {
+ movlhps(xmm1, xmm0);
+ movlpd(xmm1, edx + edi);
+ movlhps(xmm2, xmm1);
+ movlpd(xmm2, edx + ebx);
+ movlhps(xmm3, xmm2);
+ movlpd(xmm3, edx + edi * 2);
+ movhpd(xmm4, ecx);
+ movlpd(xmm4, ecx + eax);
+ movhpd(xmm5, ecx + edi);
+ movlpd(xmm5, ecx + ebx);
+ pavgb(xmm0, xmm1);
+ pavgb(xmm2, xmm3);
+ pavgb(xmm0, xmm4);
+ pavgb(xmm2, xmm5);
+ movhpd(ecx, xmm0);
+ movlpd(ecx + eax, xmm0);
+ movhpd(ecx + edi, xmm2);
+ movlpd(ecx + ebx, xmm2);
+ movdqa(xmm0, xmm3);
+ }
}
static void MC_avg_xy_16_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
{
- const uint8_t *edx= ref;
- uint8_t *ecx= dest;
- int esi= height;
- int eax= stride;
- int edi= eax+eax;
- __m128i xmm7,xmm0,xmm1,xmm2,xmm3,xmm4,xmm5;
- movdqa (xmm7, const_1_16_bytes );
- movdqu (xmm0, edx );
- movdqu (xmm1, edx+1 );
- for (; esi; edx+=edi,ecx+=edi,esi-=2) {
- movdqu (xmm2, edx+eax );
- movdqu (xmm3, edx+eax+1 );
- movdqu (xmm4, edx+edi );
- movdqu (xmm5, edx+edi+1 );
- pavgb (xmm0, xmm1 );
- pavgb (xmm2, xmm3 );
- movdqa (xmm1, xmm5 );
- pavgb (xmm5, xmm4 );
- psubusb (xmm2, xmm7 );
- pavgb (xmm0, xmm2 );
- pavgb (xmm2, xmm5);
- pavgb (xmm0, ecx );
- pavgb (xmm2, ecx+eax);
- movdqa (ecx, xmm0);
- movdqa (xmm0, xmm4);
- movdqa (ecx+eax, xmm2);
- }
+ const uint8_t* edx = ref;
+ uint8_t* ecx = dest;
+ int esi = height;
+ int eax = stride;
+ int edi = eax + eax;
+ __m128i xmm7, xmm0, xmm1, xmm2, xmm3, xmm4, xmm5;
+ movdqa(xmm7, const_1_16_bytes);
+ movdqu(xmm0, edx);
+ movdqu(xmm1, edx + 1);
+ for (; esi; edx += edi, ecx += edi, esi -= 2) {
+ movdqu(xmm2, edx + eax);
+ movdqu(xmm3, edx + eax + 1);
+ movdqu(xmm4, edx + edi);
+ movdqu(xmm5, edx + edi + 1);
+ pavgb(xmm0, xmm1);
+ pavgb(xmm2, xmm3);
+ movdqa(xmm1, xmm5);
+ pavgb(xmm5, xmm4);
+ psubusb(xmm2, xmm7);
+ pavgb(xmm0, xmm2);
+ pavgb(xmm2, xmm5);
+ pavgb(xmm0, ecx);
+ pavgb(xmm2, ecx + eax);
+ movdqa(ecx, xmm0);
+ movdqa(xmm0, xmm4);
+ movdqa(ecx + eax, xmm2);
+ }
}
static void MC_avg_xy_8_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
{
- const uint8_t *edx= ref;
- uint8_t *ecx= dest;
- int esi= height;
- int eax= stride;
- int edi= eax+eax;
- __m128i xmm7,xmm0,xmm2,xmm1,xmm3,xmm4;
- movdqa (xmm7, const_1_16_bytes );
- movhpd (xmm0, edx );
- movlpd (xmm0, edx+eax );
- movhpd (xmm2, edx+1 );
- movlpd (xmm2, edx+eax+1 );
- for (; esi; edx+=edi,ecx+=edi,esi-=2) {
+ const uint8_t* edx = ref;
+ uint8_t* ecx = dest;
+ int esi = height;
+ int eax = stride;
+ int edi = eax + eax;
+ __m128i xmm7, xmm0, xmm2, xmm1, xmm3, xmm4;
+ movdqa(xmm7, const_1_16_bytes);
+ movhpd(xmm0, edx);
+ movlpd(xmm0, edx + eax);
+ movhpd(xmm2, edx + 1);
+ movlpd(xmm2, edx + eax + 1);
+ for (; esi; edx += edi, ecx += edi, esi -= 2) {
- movhpd (xmm1, edx+eax );
- movlpd (xmm1, edx+edi );
- movhpd (xmm3, edx+eax+1 );
- movlpd (xmm3, edx+edi+1 );
- pavgb (xmm0, xmm1 );
- pavgb (xmm2, xmm3 );
- psubusb( xmm0, xmm7 );
- pavgb (xmm0, xmm2 );
- movhpd( xmm4, ecx);
- movlpd( xmm4, ecx+eax);
- pavgb (xmm0, xmm4 );
- movhpd (ecx, xmm0 );
- movlpd (ecx+eax, xmm0 );
- movdqa (xmm0, xmm1 );
- movdqa (xmm2, xmm3 );
- }
+ movhpd(xmm1, edx + eax);
+ movlpd(xmm1, edx + edi);
+ movhpd(xmm3, edx + eax + 1);
+ movlpd(xmm3, edx + edi + 1);
+ pavgb(xmm0, xmm1);
+ pavgb(xmm2, xmm3);
+ psubusb(xmm0, xmm7);
+ pavgb(xmm0, xmm2);
+ movhpd(xmm4, ecx);
+ movlpd(xmm4, ecx + eax);
+ pavgb(xmm0, xmm4);
+ movhpd(ecx, xmm0);
+ movlpd(ecx + eax, xmm0);
+ movdqa(xmm0, xmm1);
+ movdqa(xmm2, xmm3);
+ }
}
mpeg2_mc_t mpeg2_mc_sse2 = {
- {
- MC_put_o_16_sse2, MC_put_x_16_sse2, MC_put_y_16_sse2, MC_put_xy_16_sse2,
- MC_put_o_8_sse2, MC_put_x_8_sse2, MC_put_y_8_sse2, MC_put_xy_8_sse2
- },
- {
- MC_avg_o_16_sse2, MC_avg_x_16_sse2, MC_avg_y_16_sse2, MC_avg_xy_16_sse2,
- MC_avg_o_8_sse2, MC_avg_x_8_sse2, MC_avg_y_8_sse2, MC_avg_xy_8_sse2
- }
+ {
+ MC_put_o_16_sse2, MC_put_x_16_sse2, MC_put_y_16_sse2, MC_put_xy_16_sse2,
+ MC_put_o_8_sse2, MC_put_x_8_sse2, MC_put_y_8_sse2, MC_put_xy_8_sse2
+ },
+ {
+ MC_avg_o_16_sse2, MC_avg_x_16_sse2, MC_avg_y_16_sse2, MC_avg_xy_16_sse2,
+ MC_avg_o_8_sse2, MC_avg_x_8_sse2, MC_avg_y_8_sse2, MC_avg_xy_8_sse2
+ }
};
diff --git a/src/filters/transform/VSFilter/AvgLines.cpp b/src/filters/transform/VSFilter/AvgLines.cpp
index a8bc535aa..8379128c6 100644
--- a/src/filters/transform/VSFilter/AvgLines.cpp
+++ b/src/filters/transform/VSFilter/AvgLines.cpp
@@ -1,298 +1,298 @@
-// VirtualDub - Video processing and capture application
-// Copyright (C) 1998-2001 Avery Lee
+// VirtualDub - Video processing and capture application
+// Copyright (C) 1998-2001 Avery Lee
//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "stdafx.h"
void AvgLines8(BYTE* dst, DWORD h, DWORD pitch)
{
- if (h <= 1) {
- return;
- }
+ if (h <= 1) {
+ return;
+ }
- BYTE* s = dst;
- BYTE* d = dst + (h-2)*pitch;
+ BYTE* s = dst;
+ BYTE* d = dst + (h - 2) * pitch;
- for (; s < d; s += pitch*2) {
- BYTE* tmp = s;
+ for (; s < d; s += pitch * 2) {
+ BYTE* tmp = s;
#ifndef _WIN64
- if ((g_cpuid.m_flags & CCpuID::sse2) && !((DWORD)tmp&0xf) && !((DWORD)pitch&0xf)) {
- __asm {
- mov esi, tmp
- mov ebx, pitch
+ if ((g_cpuid.m_flags & CCpuID::sse2) && !((DWORD)tmp & 0xf) && !((DWORD)pitch & 0xf)) {
+ __asm {
+ mov esi, tmp
+ mov ebx, pitch
- mov ecx, ebx
- shr ecx, 4
+ mov ecx, ebx
+ shr ecx, 4
- AvgLines8_sse2_loop:
- movdqa xmm0, [esi]
- pavgb xmm0, [esi+ebx*2]
- movdqa [esi+ebx], xmm0
- add esi, 16
+ AvgLines8_sse2_loop:
+ movdqa xmm0, [esi]
+ pavgb xmm0, [esi+ebx*2]
+ movdqa [esi+ebx], xmm0
+ add esi, 16
- dec ecx
- jnz AvgLines8_sse2_loop
+ dec ecx
+ jnz AvgLines8_sse2_loop
- mov tmp, esi
- }
+ mov tmp, esi
+ }
- for (ptrdiff_t i = pitch&7; i--; tmp++) {
- tmp[pitch] = (tmp[0] + tmp[pitch<<1] + 1) >> 1;
- }
- } else if (g_cpuid.m_flags & CCpuID::mmx) {
- __asm {
- mov esi, tmp
- mov ebx, pitch
+ for (ptrdiff_t i = pitch & 7; i--; tmp++) {
+ tmp[pitch] = (tmp[0] + tmp[pitch << 1] + 1) >> 1;
+ }
+ } else if (g_cpuid.m_flags & CCpuID::mmx) {
+ __asm {
+ mov esi, tmp
+ mov ebx, pitch
- mov ecx, ebx
- shr ecx, 3
+ mov ecx, ebx
+ shr ecx, 3
- pxor mm7, mm7
- AvgLines8_mmx_loop:
- movq mm0, [esi]
- movq mm1, mm0
+ pxor mm7, mm7
+ AvgLines8_mmx_loop:
+ movq mm0, [esi]
+ movq mm1, mm0
- punpcklbw mm0, mm7
- punpckhbw mm1, mm7
+ punpcklbw mm0, mm7
+ punpckhbw mm1, mm7
- movq mm2, [esi+ebx*2]
- movq mm3, mm2
+ movq mm2, [esi+ebx*2]
+ movq mm3, mm2
- punpcklbw mm2, mm7
- punpckhbw mm3, mm7
+ punpcklbw mm2, mm7
+ punpckhbw mm3, mm7
- paddw mm0, mm2
- psrlw mm0, 1
+ paddw mm0, mm2
+ psrlw mm0, 1
- paddw mm1, mm3
- psrlw mm1, 1
+ paddw mm1, mm3
+ psrlw mm1, 1
- packuswb mm0, mm1
+ packuswb mm0, mm1
- movq [esi+ebx], mm0
+ movq [esi+ebx], mm0
- lea esi, [esi+8]
+ lea esi, [esi+8]
- dec ecx
- jnz AvgLines8_mmx_loop
+ dec ecx
+ jnz AvgLines8_mmx_loop
- mov tmp, esi
- }
+ mov tmp, esi
+ }
- for (ptrdiff_t i = pitch&7; i--; tmp++) {
- tmp[pitch] = (tmp[0] + tmp[pitch<<1] + 1) >> 1;
- }
- } else
+ for (ptrdiff_t i = pitch & 7; i--; tmp++) {
+ tmp[pitch] = (tmp[0] + tmp[pitch << 1] + 1) >> 1;
+ }
+ } else
#endif
- {
- for (ptrdiff_t i = pitch; i--; tmp++) {
- tmp[pitch] = (tmp[0] + tmp[pitch<<1] + 1) >> 1;
- }
- }
- }
-
- if (!(h&1) && h >= 2) {
- dst += (h-2)*pitch;
- memcpy(dst + pitch, dst, pitch);
- }
+ {
+ for (ptrdiff_t i = pitch; i--; tmp++) {
+ tmp[pitch] = (tmp[0] + tmp[pitch << 1] + 1) >> 1;
+ }
+ }
+ }
+
+ if (!(h & 1) && h >= 2) {
+ dst += (h - 2) * pitch;
+ memcpy(dst + pitch, dst, pitch);
+ }
#ifndef _WIN64
- __asm emms;
+ __asm emms;
#endif
}
void AvgLines555(BYTE* dst, DWORD h, DWORD pitch)
{
- if (h <= 1) {
- return;
- }
+ if (h <= 1) {
+ return;
+ }
- unsigned __int64 __0x03e003e003e003e0 = 0x03e003e003e003e0;
- unsigned __int64 __0x001f001f001f001f = 0x001f001f001f001f;
+ unsigned __int64 __0x03e003e003e003e0 = 0x03e003e003e003e0;
+ unsigned __int64 __0x001f001f001f001f = 0x001f001f001f001f;
- BYTE* s = dst;
- BYTE* d = dst + (h-2)*pitch;
+ BYTE* s = dst;
+ BYTE* d = dst + (h - 2) * pitch;
- for (; s < d; s += pitch*2) {
- BYTE* tmp = s;
+ for (; s < d; s += pitch * 2) {
+ BYTE* tmp = s;
#ifndef _WIN64
- __asm {
- mov esi, tmp
- mov ebx, pitch
+ __asm {
+ mov esi, tmp
+ mov ebx, pitch
- mov ecx, ebx
- shr ecx, 3
+ mov ecx, ebx
+ shr ecx, 3
- movq mm6, __0x03e003e003e003e0
- movq mm7, __0x001f001f001f001f
+ movq mm6, __0x03e003e003e003e0
+ movq mm7, __0x001f001f001f001f
- AvgLines555_loop:
- movq mm0, [esi]
- movq mm1, mm0
- movq mm2, mm0
+ AvgLines555_loop:
+ movq mm0, [esi]
+ movq mm1, mm0
+ movq mm2, mm0
- psrlw mm0, 10 // red1 bits: mm0 = 001f001f001f001f
- pand mm1, mm6 // green1 bits: mm1 = 03e003e003e003e0
- pand mm2, mm7 // blue1 bits: mm2 = 001f001f001f001f
+ psrlw mm0, 10 // red1 bits: mm0 = 001f001f001f001f
+ pand mm1, mm6 // green1 bits: mm1 = 03e003e003e003e0
+ pand mm2, mm7 // blue1 bits: mm2 = 001f001f001f001f
- movq mm3, [esi+ebx*2]
- movq mm4, mm3
- movq mm5, mm3
+ movq mm3, [esi+ebx*2]
+ movq mm4, mm3
+ movq mm5, mm3
- psrlw mm3, 10 // red2 bits: mm3 = 001f001f001f001f
- pand mm4, mm6 // green2 bits: mm4 = 03e003e003e003e0
- pand mm5, mm7 // blue2 bits: mm5 = 001f001f001f001f
+ psrlw mm3, 10 // red2 bits: mm3 = 001f001f001f001f
+ pand mm4, mm6 // green2 bits: mm4 = 03e003e003e003e0
+ pand mm5, mm7 // blue2 bits: mm5 = 001f001f001f001f
- paddw mm0, mm3
- psrlw mm0, 1 // (red1+red2)/2
- psllw mm0, 10 // red bits at 7c007c007c007c00
+ paddw mm0, mm3
+ psrlw mm0, 1 // (red1+red2)/2
+ psllw mm0, 10 // red bits at 7c007c007c007c00
- paddw mm1, mm4
- psrlw mm1, 1 // (green1+green2)/2
- pand mm1, mm6 // green bits at 03e003e003e003e0
+ paddw mm1, mm4
+ psrlw mm1, 1 // (green1+green2)/2
+ pand mm1, mm6 // green bits at 03e003e003e003e0
- paddw mm2, mm5
- psrlw mm2, 1 // (blue1+blue2)/2
- // blue bits at 001f001f001f001f (no need to pand, lower bits were discareded)
+ paddw mm2, mm5
+ psrlw mm2, 1 // (blue1+blue2)/2
+ // blue bits at 001f001f001f001f (no need to pand, lower bits were discareded)
- por mm0, mm1
- por mm0, mm2
+ por mm0, mm1
+ por mm0, mm2
- movq [esi+ebx], mm0
+ movq [esi+ebx], mm0
- lea esi, [esi+8]
+ lea esi, [esi+8]
- dec ecx
- jnz AvgLines555_loop
+ dec ecx
+ jnz AvgLines555_loop
- mov tmp, esi
- }
+ mov tmp, esi
+ }
#endif
- for (ptrdiff_t i = (pitch&7)>>1; i--; tmp++) {
- tmp[pitch] =
- ((((*tmp&0x7c00) + (tmp[pitch<<1]&0x7c00)) >> 1)&0x7c00)|
- ((((*tmp&0x03e0) + (tmp[pitch<<1]&0x03e0)) >> 1)&0x03e0)|
- ((((*tmp&0x001f) + (tmp[pitch<<1]&0x001f)) >> 1)&0x001f);
- }
- }
+ for (ptrdiff_t i = (pitch & 7) >> 1; i--; tmp++) {
+ tmp[pitch] =
+ ((((*tmp & 0x7c00) + (tmp[pitch << 1] & 0x7c00)) >> 1) & 0x7c00) |
+ ((((*tmp & 0x03e0) + (tmp[pitch << 1] & 0x03e0)) >> 1) & 0x03e0) |
+ ((((*tmp & 0x001f) + (tmp[pitch << 1] & 0x001f)) >> 1) & 0x001f);
+ }
+ }
- if (!(h&1) && h >= 2) {
- dst += (h-2)*pitch;
- memcpy(dst + pitch, dst, pitch);
- }
+ if (!(h & 1) && h >= 2) {
+ dst += (h - 2) * pitch;
+ memcpy(dst + pitch, dst, pitch);
+ }
#ifndef _WIN64
- __asm emms;
+ __asm emms;
#endif
}
void AvgLines565(BYTE* dst, DWORD h, DWORD pitch)
{
- if (h <= 1) {
- return;
- }
+ if (h <= 1) {
+ return;
+ }
- unsigned __int64 __0x07e007e007e007e0 = 0x07e007e007e007e0;
- unsigned __int64 __0x001f001f001f001f = 0x001f001f001f001f;
+ unsigned __int64 __0x07e007e007e007e0 = 0x07e007e007e007e0;
+ unsigned __int64 __0x001f001f001f001f = 0x001f001f001f001f;
- BYTE* s = dst;
- BYTE* d = dst + (h-2)*pitch;
+ BYTE* s = dst;
+ BYTE* d = dst + (h - 2) * pitch;
- for (; s < d; s += pitch*2) {
- WORD* tmp = (WORD*)s;
+ for (; s < d; s += pitch * 2) {
+ WORD* tmp = (WORD*)s;
#ifndef _WIN64
- __asm {
- mov esi, tmp
- mov ebx, pitch
+ __asm {
+ mov esi, tmp
+ mov ebx, pitch
- mov ecx, ebx
- shr ecx, 3
+ mov ecx, ebx
+ shr ecx, 3
- movq mm6, __0x07e007e007e007e0
- movq mm7, __0x001f001f001f001f
+ movq mm6, __0x07e007e007e007e0
+ movq mm7, __0x001f001f001f001f
- AvgLines565_loop:
- movq mm0, [esi]
- movq mm1, mm0
- movq mm2, mm0
+ AvgLines565_loop:
+ movq mm0, [esi]
+ movq mm1, mm0
+ movq mm2, mm0
- psrlw mm0, 11 // red1 bits: mm0 = 001f001f001f001f
- pand mm1, mm6 // green1 bits: mm1 = 07e007e007e007e0
- pand mm2, mm7 // blue1 bits: mm2 = 001f001f001f001f
+ psrlw mm0, 11 // red1 bits: mm0 = 001f001f001f001f
+ pand mm1, mm6 // green1 bits: mm1 = 07e007e007e007e0
+ pand mm2, mm7 // blue1 bits: mm2 = 001f001f001f001f
- movq mm3, [esi+ebx*2]
- movq mm4, mm3
- movq mm5, mm3
+ movq mm3, [esi+ebx*2]
+ movq mm4, mm3
+ movq mm5, mm3
- psrlw mm3, 11 // red2 bits: mm3 = 001f001f001f001f
- pand mm4, mm6 // green2 bits: mm4 = 07e007e007e007e0
- pand mm5, mm7 // blue2 bits: mm5 = 001f001f001f001f
+ psrlw mm3, 11 // red2 bits: mm3 = 001f001f001f001f
+ pand mm4, mm6 // green2 bits: mm4 = 07e007e007e007e0
+ pand mm5, mm7 // blue2 bits: mm5 = 001f001f001f001f
- paddw mm0, mm3
- psrlw mm0, 1 // (red1+red2)/2
- psllw mm0, 11 // red bits at f800f800f800f800
+ paddw mm0, mm3
+ psrlw mm0, 1 // (red1+red2)/2
+ psllw mm0, 11 // red bits at f800f800f800f800
- paddw mm1, mm4
- psrlw mm1, 1 // (green1+green2)/2
- pand mm1, mm6 // green bits at 03e003e003e003e0
+ paddw mm1, mm4
+ psrlw mm1, 1 // (green1+green2)/2
+ pand mm1, mm6 // green bits at 03e003e003e003e0
- paddw mm2, mm5
- psrlw mm2, 1 // (blue1+blue2)/2
- // blue bits at 001f001f001f001f (no need to pand, lower bits were discareded)
+ paddw mm2, mm5
+ psrlw mm2, 1 // (blue1+blue2)/2
+ // blue bits at 001f001f001f001f (no need to pand, lower bits were discareded)
- por mm0, mm1
- por mm0, mm2
+ por mm0, mm1
+ por mm0, mm2
- movq [esi+ebx], mm0
+ movq [esi+ebx], mm0
- lea esi, [esi+8]
+ lea esi, [esi+8]
- dec ecx
- jnz AvgLines565_loop
+ dec ecx
+ jnz AvgLines565_loop
- mov tmp, esi
- }
+ mov tmp, esi
+ }
#else
- for (ptrdiff_t wd=(pitch>>3); wd--; tmp++) {
- tmp[0] =
- ((((*tmp&0xf800) + (tmp[pitch<<1]&0xf800)) >> 1)&0xf800)|
- ((((*tmp&0x07e0) + (tmp[pitch<<1]&0x07e0)) >> 1)&0x07e0)|
- ((((*tmp&0x001f) + (tmp[pitch<<1]&0x001f)) >> 1)&0x001f);
- }
+ for (ptrdiff_t wd = (pitch >> 3); wd--; tmp++) {
+ tmp[0] =
+ ((((*tmp & 0xf800) + (tmp[pitch << 1] & 0xf800)) >> 1) & 0xf800) |
+ ((((*tmp & 0x07e0) + (tmp[pitch << 1] & 0x07e0)) >> 1) & 0x07e0) |
+ ((((*tmp & 0x001f) + (tmp[pitch << 1] & 0x001f)) >> 1) & 0x001f);
+ }
#endif
- for (ptrdiff_t i = (pitch&7)>>1; i--; tmp++) {
- tmp[pitch] =
- ((((*tmp&0xf800) + (tmp[pitch<<1]&0xf800)) >> 1)&0xf800)|
- ((((*tmp&0x07e0) + (tmp[pitch<<1]&0x07e0)) >> 1)&0x07e0)|
- ((((*tmp&0x001f) + (tmp[pitch<<1]&0x001f)) >> 1)&0x001f);
- }
- }
+ for (ptrdiff_t i = (pitch & 7) >> 1; i--; tmp++) {
+ tmp[pitch] =
+ ((((*tmp & 0xf800) + (tmp[pitch << 1] & 0xf800)) >> 1) & 0xf800) |
+ ((((*tmp & 0x07e0) + (tmp[pitch << 1] & 0x07e0)) >> 1) & 0x07e0) |
+ ((((*tmp & 0x001f) + (tmp[pitch << 1] & 0x001f)) >> 1) & 0x001f);
+ }
+ }
- if (!(h&1) && h >= 2) {
- dst += (h-2)*pitch;
- memcpy(dst + pitch, dst, pitch);
- }
+ if (!(h & 1) && h >= 2) {
+ dst += (h - 2) * pitch;
+ memcpy(dst + pitch, dst, pitch);
+ }
#ifndef _WIN64
- __asm emms;
+ __asm emms;
#endif
}
diff --git a/src/filters/transform/VSFilter/AvgLines.h b/src/filters/transform/VSFilter/AvgLines.h
index af769fbb3..94763be6e 100644
--- a/src/filters/transform/VSFilter/AvgLines.h
+++ b/src/filters/transform/VSFilter/AvgLines.h
@@ -1,19 +1,19 @@
-// VirtualDub - Video processing and capture application
-// Copyright (C) 1998-2001 Avery Lee
+// VirtualDub - Video processing and capture application
+// Copyright (C) 1998-2001 Avery Lee
//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#pragma once
diff --git a/src/filters/transform/VSFilter/Copy.cpp b/src/filters/transform/VSFilter/Copy.cpp
index a4c146ed4..3ddefafb7 100644
--- a/src/filters/transform/VSFilter/Copy.cpp
+++ b/src/filters/transform/VSFilter/Copy.cpp
@@ -38,215 +38,215 @@ extern void ColorConvInit();
void BltLineRGB32(DWORD* d, BYTE* sub, int w, const GUID& subtype)
{
- if (subtype == MEDIASUBTYPE_YV12 || subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV) {
- BYTE* db = (BYTE*)d;
- BYTE* dbtend = db + w;
-
- for (; db < dbtend; sub+=4, db++) {
- if (sub[3] < 0xff) {
- int y = (c2y_yb[sub[0]] + c2y_yg[sub[1]] + c2y_yr[sub[2]] + 0x108000) >> 16;
- *db = y; // w/o colors
- }
- }
- } else if (subtype == MEDIASUBTYPE_YUY2) {
- WORD* ds = (WORD*)d;
- WORD* dstend = ds + w;
-
- for (; ds < dstend; sub+=4, ds++) {
- if (sub[3] < 0xff) {
- int y = (c2y_yb[sub[0]] + c2y_yg[sub[1]] + c2y_yr[sub[2]] + 0x108000) >> 16;
- *ds = 0x8000|y; // w/o colors
- }
- }
- } else if (subtype == MEDIASUBTYPE_RGB555) {
- WORD* ds = (WORD*)d;
- WORD* dstend = ds + w;
-
- for (; ds < dstend; sub+=4, ds++) {
- if (sub[3] < 0xff) {
- *ds = ((*((DWORD*)sub)>>9)&0x7c00)|((*((DWORD*)sub)>>6)&0x03e0)|((*((DWORD*)sub)>>3)&0x001f);
- }
- }
- } else if (subtype == MEDIASUBTYPE_RGB565) {
- WORD* ds = (WORD*)d;
- WORD* dstend = ds + w;
-
- for (; ds < dstend; sub+=4, ds++) {
- if (sub[3] < 0xff) {
- *ds = ((*((DWORD*)sub)>>8)&0xf800)|((*((DWORD*)sub)>>5)&0x07e0)|((*((DWORD*)sub)>>3)&0x001f);
- }
- }
- } else if (subtype == MEDIASUBTYPE_RGB24) {
- BYTE* dt = (BYTE*)d;
- BYTE* dstend = dt + w*3;
-
- for (; dt < dstend; sub+=4, dt+=3) {
- if (sub[3] < 0xff) {
- dt[0] = sub[0];
- dt[1] = sub[1];
- dt[2] = sub[2];
- }
- }
- } else if (subtype == MEDIASUBTYPE_RGB32 || subtype == MEDIASUBTYPE_ARGB32) {
- DWORD* dstend = d + w;
-
- for (; d < dstend; sub+=4, d++) {
- if (sub[3] < 0xff) {
- *d = *((DWORD*)sub)&0xffffff;
- }
- }
- }
+ if (subtype == MEDIASUBTYPE_YV12 || subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV) {
+ BYTE* db = (BYTE*)d;
+ BYTE* dbtend = db + w;
+
+ for (; db < dbtend; sub += 4, db++) {
+ if (sub[3] < 0xff) {
+ int y = (c2y_yb[sub[0]] + c2y_yg[sub[1]] + c2y_yr[sub[2]] + 0x108000) >> 16;
+ *db = y; // w/o colors
+ }
+ }
+ } else if (subtype == MEDIASUBTYPE_YUY2) {
+ WORD* ds = (WORD*)d;
+ WORD* dstend = ds + w;
+
+ for (; ds < dstend; sub += 4, ds++) {
+ if (sub[3] < 0xff) {
+ int y = (c2y_yb[sub[0]] + c2y_yg[sub[1]] + c2y_yr[sub[2]] + 0x108000) >> 16;
+ *ds = 0x8000 | y; // w/o colors
+ }
+ }
+ } else if (subtype == MEDIASUBTYPE_RGB555) {
+ WORD* ds = (WORD*)d;
+ WORD* dstend = ds + w;
+
+ for (; ds < dstend; sub += 4, ds++) {
+ if (sub[3] < 0xff) {
+ *ds = ((*((DWORD*)sub) >> 9) & 0x7c00) | ((*((DWORD*)sub) >> 6) & 0x03e0) | ((*((DWORD*)sub) >> 3) & 0x001f);
+ }
+ }
+ } else if (subtype == MEDIASUBTYPE_RGB565) {
+ WORD* ds = (WORD*)d;
+ WORD* dstend = ds + w;
+
+ for (; ds < dstend; sub += 4, ds++) {
+ if (sub[3] < 0xff) {
+ *ds = ((*((DWORD*)sub) >> 8) & 0xf800) | ((*((DWORD*)sub) >> 5) & 0x07e0) | ((*((DWORD*)sub) >> 3) & 0x001f);
+ }
+ }
+ } else if (subtype == MEDIASUBTYPE_RGB24) {
+ BYTE* dt = (BYTE*)d;
+ BYTE* dstend = dt + w * 3;
+
+ for (; dt < dstend; sub += 4, dt += 3) {
+ if (sub[3] < 0xff) {
+ dt[0] = sub[0];
+ dt[1] = sub[1];
+ dt[2] = sub[2];
+ }
+ }
+ } else if (subtype == MEDIASUBTYPE_RGB32 || subtype == MEDIASUBTYPE_ARGB32) {
+ DWORD* dstend = d + w;
+
+ for (; d < dstend; sub += 4, d++) {
+ if (sub[3] < 0xff) {
+ *d = *((DWORD*)sub) & 0xffffff;
+ }
+ }
+ }
}
HRESULT CDirectVobSubFilter::Copy(BYTE* pSub, BYTE* pIn, CSize sub, CSize in, int bpp, const GUID& subtype, DWORD black)
{
- int wIn = in.cx, hIn = in.cy, pitchIn = wIn*bpp>>3;
- int wSub = sub.cx, hSub = sub.cy, pitchSub = wSub*bpp>>3;
- bool fScale2x = wIn*2 <= wSub;
+ int wIn = in.cx, hIn = in.cy, pitchIn = wIn * bpp >> 3;
+ int wSub = sub.cx, hSub = sub.cy, pitchSub = wSub * bpp >> 3;
+ bool fScale2x = wIn * 2 <= wSub;
- if (fScale2x) {
- wIn <<= 1, hIn <<= 1;
- }
+ if (fScale2x) {
+ wIn <<= 1, hIn <<= 1;
+ }
- int left = ((wSub - wIn)>>1)&~1;
- int mid = wIn;
- int right = left + ((wSub - wIn)&1);
+ int left = ((wSub - wIn) >> 1)&~1;
+ int mid = wIn;
+ int right = left + ((wSub - wIn) & 1);
- int dpLeft = left*bpp>>3;
- int dpMid = mid*bpp>>3;
- int dpRight = right*bpp>>3;
+ int dpLeft = left * bpp >> 3;
+ int dpMid = mid * bpp >> 3;
+ int dpRight = right * bpp >> 3;
- ASSERT(wSub >= wIn);
+ ASSERT(wSub >= wIn);
- {
- int i = 0, j = 0;
+ {
+ int i = 0, j = 0;
- j += (hSub - hIn) >> 1;
+ j += (hSub - hIn) >> 1;
- for (; i < j; i++, pSub += pitchSub) {
- memsetd(pSub, black, dpLeft+dpMid+dpRight);
- }
+ for (; i < j; i++, pSub += pitchSub) {
+ memsetd(pSub, black, dpLeft + dpMid + dpRight);
+ }
- j += hIn;
+ j += hIn;
- if (hIn > hSub) {
- pIn += pitchIn * ((hIn - hSub) >> (fScale2x?2:1));
- }
+ if (hIn > hSub) {
+ pIn += pitchIn * ((hIn - hSub) >> (fScale2x ? 2 : 1));
+ }
- if (fScale2x) {
- Scale2x(subtype,
- pSub + dpLeft, pitchSub, pIn, pitchIn,
- in.cx, (min(j, hSub) - i) >> 1);
+ if (fScale2x) {
+ Scale2x(subtype,
+ pSub + dpLeft, pitchSub, pIn, pitchIn,
+ in.cx, (min(j, hSub) - i) >> 1);
- for (ptrdiff_t k = min(j, hSub); i < k; i++, pIn += pitchIn, pSub += pitchSub) {
- memsetd(pSub, black, dpLeft);
- memsetd(pSub + dpLeft+dpMid, black, dpRight);
- }
- } else {
- for (ptrdiff_t k = min(j, hSub); i < k; i++, pIn += pitchIn, pSub += pitchSub) {
- memsetd(pSub, black, dpLeft);
- memcpy(pSub + dpLeft, pIn, dpMid);
- memsetd(pSub + dpLeft+dpMid, black, dpRight);
- }
- }
+ for (ptrdiff_t k = min(j, hSub); i < k; i++, pIn += pitchIn, pSub += pitchSub) {
+ memsetd(pSub, black, dpLeft);
+ memsetd(pSub + dpLeft + dpMid, black, dpRight);
+ }
+ } else {
+ for (ptrdiff_t k = min(j, hSub); i < k; i++, pIn += pitchIn, pSub += pitchSub) {
+ memsetd(pSub, black, dpLeft);
+ memcpy(pSub + dpLeft, pIn, dpMid);
+ memsetd(pSub + dpLeft + dpMid, black, dpRight);
+ }
+ }
- j = hSub;
+ j = hSub;
- for (; i < j; i++, pSub += pitchSub) {
- memsetd(pSub, black, dpLeft+dpMid+dpRight);
- }
- }
+ for (; i < j; i++, pSub += pitchSub) {
+ memsetd(pSub, black, dpLeft + dpMid + dpRight);
+ }
+ }
- return NOERROR;
+ return NOERROR;
}
void CDirectVobSubFilter::PrintMessages(BYTE* pOut)
{
- if (!m_hdc || !m_hbm) {
- return;
- }
+ if (!m_hdc || !m_hbm) {
+ return;
+ }
- ColorConvInit();
+ ColorConvInit();
- const GUID& subtype = m_pOutput->CurrentMediaType().subtype;
+ const GUID& subtype = m_pOutput->CurrentMediaType().subtype;
- BITMAPINFOHEADER bihOut;
- ExtractBIH(&m_pOutput->CurrentMediaType(), &bihOut);
+ BITMAPINFOHEADER bihOut;
+ ExtractBIH(&m_pOutput->CurrentMediaType(), &bihOut);
- if (!m_fOSD) {
- return;
- }
+ if (!m_fOSD) {
+ return;
+ }
- CString msg;
+ CString msg;
- msg.Format(_T("in: %dx%d %s\nout: %dx%d %s\n"),
- m_w, m_h,
- Subtype2String(m_pInput->CurrentMediaType().subtype),
- bihOut.biWidth, bihOut.biHeight,
- Subtype2String(m_pOutput->CurrentMediaType().subtype));
+ msg.Format(_T("in: %dx%d %s\nout: %dx%d %s\n"),
+ m_w, m_h,
+ Subtype2String(m_pInput->CurrentMediaType().subtype),
+ bihOut.biWidth, bihOut.biHeight,
+ Subtype2String(m_pOutput->CurrentMediaType().subtype));
- msg.AppendFormat(_T("real fps: %.3f, current fps: %.3f\nmedia time: %d, subtitle time: %I64d [ms]\nframe number: %d (calculated)\nrate: %.4lf\n"),
- m_fps, m_fMediaFPSEnabled ? m_MediaFPS : fabs(m_fps),
- m_tPrev.Millisecs(), CalcCurrentTime()/10000,
- (int)(m_tPrev.m_time * m_fps / 10000000),
- m_pInput->CurrentRate());
+ msg.AppendFormat(_T("real fps: %.3f, current fps: %.3f\nmedia time: %d, subtitle time: %I64d [ms]\nframe number: %d (calculated)\nrate: %.4lf\n"),
+ m_fps, m_fMediaFPSEnabled ? m_MediaFPS : fabs(m_fps),
+ m_tPrev.Millisecs(), CalcCurrentTime() / 10000,
+ (int)(m_tPrev.m_time * m_fps / 10000000),
+ m_pInput->CurrentRate());
- CAutoLock cAutoLock(&m_csQueueLock);
+ CAutoLock cAutoLock(&m_csQueueLock);
- if (m_pSubPicQueue) {
- int nSubPics = -1;
- REFERENCE_TIME rtNow = -1, rtStart = -1, rtStop = -1;
- m_pSubPicQueue->GetStats(nSubPics, rtNow, rtStart, rtStop);
- msg.AppendFormat(_T("queue stats: %I64d - %I64d [ms]\n"), rtStart/10000, rtStop/10000);
+ if (m_pSubPicQueue) {
+ int nSubPics = -1;
+ REFERENCE_TIME rtNow = -1, rtStart = -1, rtStop = -1;
+ m_pSubPicQueue->GetStats(nSubPics, rtNow, rtStart, rtStop);
+ msg.AppendFormat(_T("queue stats: %I64d - %I64d [ms]\n"), rtStart / 10000, rtStop / 10000);
- for (int i = 0; i < nSubPics; i++) {
- m_pSubPicQueue->GetStats(i, rtStart, rtStop);
- msg.AppendFormat(_T("%d: %I64d - %I64d [ms]\n"), i, rtStart/10000, rtStop/10000);
- }
- }
+ for (int i = 0; i < nSubPics; i++) {
+ m_pSubPicQueue->GetStats(i, rtStart, rtStop);
+ msg.AppendFormat(_T("%d: %I64d - %I64d [ms]\n"), i, rtStart / 10000, rtStop / 10000);
+ }
+ }
- HANDLE hOldBitmap = SelectObject(m_hdc, m_hbm);
- HANDLE hOldFont = SelectObject(m_hdc, m_hfont);
+ HANDLE hOldBitmap = SelectObject(m_hdc, m_hbm);
+ HANDLE hOldFont = SelectObject(m_hdc, m_hfont);
- SetTextColor(m_hdc, 0xffffff);
- SetBkMode(m_hdc, TRANSPARENT);
- SetMapMode(m_hdc, MM_TEXT);
+ SetTextColor(m_hdc, 0xffffff);
+ SetBkMode(m_hdc, TRANSPARENT);
+ SetMapMode(m_hdc, MM_TEXT);
- BITMAP bm;
- GetObject(m_hbm, sizeof(BITMAP), &bm);
+ BITMAP bm;
+ GetObject(m_hbm, sizeof(BITMAP), &bm);
- CRect r(0, 0, bm.bmWidth, bm.bmHeight);
- DrawText(m_hdc, msg, msg.GetLength(), &r, DT_CALCRECT|DT_EXTERNALLEADING|DT_NOPREFIX|DT_WORDBREAK);
+ CRect r(0, 0, bm.bmWidth, bm.bmHeight);
+ DrawText(m_hdc, msg, msg.GetLength(), &r, DT_CALCRECT | DT_EXTERNALLEADING | DT_NOPREFIX | DT_WORDBREAK);
- r += CPoint(10, 10);
- r &= CRect(0, 0, bm.bmWidth, bm.bmHeight);
+ r += CPoint(10, 10);
+ r &= CRect(0, 0, bm.bmWidth, bm.bmHeight);
- DrawText(m_hdc, msg, msg.GetLength(), &r, DT_LEFT|DT_TOP|DT_NOPREFIX|DT_WORDBREAK);
+ DrawText(m_hdc, msg, msg.GetLength(), &r, DT_LEFT | DT_TOP | DT_NOPREFIX | DT_WORDBREAK);
- BYTE* pIn = (BYTE*)bm.bmBits;
- int pitchIn = bm.bmWidthBytes;
- int pitchOut = bihOut.biWidth * bihOut.biBitCount >> 3;
+ BYTE* pIn = (BYTE*)bm.bmBits;
+ int pitchIn = bm.bmWidthBytes;
+ int pitchOut = bihOut.biWidth * bihOut.biBitCount >> 3;
- if (subtype == MEDIASUBTYPE_YV12 || subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV) {
- pitchOut = bihOut.biWidth;
- }
+ if (subtype == MEDIASUBTYPE_YV12 || subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV) {
+ pitchOut = bihOut.biWidth;
+ }
- pitchIn = (pitchIn+3)&~3;
- pitchOut = (pitchOut+3)&~3;
+ pitchIn = (pitchIn + 3)&~3;
+ pitchOut = (pitchOut + 3)&~3;
- if (bihOut.biHeight > 0 && bihOut.biCompression <= 3) { // flip if the dst bitmap is flipped rgb (m_hbm is a top-down bitmap, not like the subpictures)
- pOut += pitchOut * (abs(bihOut.biHeight)-1);
- pitchOut = -pitchOut;
- }
+ if (bihOut.biHeight > 0 && bihOut.biCompression <= 3) { // flip if the dst bitmap is flipped rgb (m_hbm is a top-down bitmap, not like the subpictures)
+ pOut += pitchOut * (abs(bihOut.biHeight) - 1);
+ pitchOut = -pitchOut;
+ }
- pIn += pitchIn * r.top;
- pOut += pitchOut * r.top;
+ pIn += pitchIn * r.top;
+ pOut += pitchOut * r.top;
- for (int w = min(r.right, m_w), h = r.Height(); h--; pIn += pitchIn, pOut += pitchOut) {
- BltLineRGB32((DWORD*)pOut, pIn, w, subtype);
- memsetd(pIn, 0xff000000, r.right*4);
- }
+ for (int w = min(r.right, m_w), h = r.Height(); h--; pIn += pitchIn, pOut += pitchOut) {
+ BltLineRGB32((DWORD*)pOut, pIn, w, subtype);
+ memsetd(pIn, 0xff000000, r.right * 4);
+ }
- SelectObject(m_hdc, hOldBitmap);
- SelectObject(m_hdc, hOldFont);
+ SelectObject(m_hdc, hOldBitmap);
+ SelectObject(m_hdc, hOldFont);
}
diff --git a/src/filters/transform/VSFilter/DirectVobSub.cpp b/src/filters/transform/VSFilter/DirectVobSub.cpp
index 7f1a1bc92..15ed3e6d0 100644
--- a/src/filters/transform/VSFilter/DirectVobSub.cpp
+++ b/src/filters/transform/VSFilter/DirectVobSub.cpp
@@ -27,763 +27,763 @@
CDirectVobSub::CDirectVobSub()
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- BYTE* pData;
- UINT nSize;
-
- m_iSelectedLanguage = 0;
- m_fHideSubtitles = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_HIDE), 0);
- m_uSubPictToBuffer = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SUBPICTTOBUFFER), 10);
- m_fAnimWhenBuffering = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ANIMWHENBUFFERING), 1);
- m_fOverridePlacement = !!theApp.GetProfileInt(ResStr(IDS_R_TEXT), ResStr(IDS_RT_OVERRIDEPLACEMENT), 0);
- m_PlacementXperc = theApp.GetProfileInt(ResStr(IDS_R_TEXT), ResStr(IDS_RT_XPERC), 50);
- m_PlacementYperc = theApp.GetProfileInt(ResStr(IDS_R_TEXT), ResStr(IDS_RT_YPERC), 90);
- m_fBufferVobSub = !!theApp.GetProfileInt(ResStr(IDS_R_VOBSUB), ResStr(IDS_RV_BUFFER), 1);
- m_fOnlyShowForcedVobSubs = !!theApp.GetProfileInt(ResStr(IDS_R_VOBSUB), ResStr(IDS_RV_ONLYSHOWFORCEDSUBS), 0);
- m_fPolygonize = !!theApp.GetProfileInt(ResStr(IDS_R_VOBSUB), ResStr(IDS_RV_POLYGONIZE), 0);
- m_defStyle <<= theApp.GetProfileString(ResStr(IDS_R_TEXT), ResStr(IDS_RT_STYLE), _T(""));
- m_fFlipPicture = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_FLIPPICTURE), 0);
- m_fFlipSubtitles = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_FLIPSUBTITLES), 0);
- m_fOSD = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SHOWOSDSTATS), 0);
- m_fSaveFullPath = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SAVEFULLPATH), 0);
- m_nReloaderDisableCount = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_DISABLERELOADER), 0) ? 1 : 0;
- m_SubtitleDelay = theApp.GetProfileInt(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_SUBTITLEDELAY), 0);
- m_SubtitleSpeedMul = theApp.GetProfileInt(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_SUBTITLESPEEDMUL), 1000);
- m_SubtitleSpeedDiv = theApp.GetProfileInt(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_SUBTITLESPEEDDIV), 1000);
- m_fMediaFPSEnabled = !!theApp.GetProfileInt(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_MEDIAFPSENABLED), 0);
- m_ePARCompensationType = static_cast<CSimpleTextSubtitle::EPARCompensationType>(theApp.GetProfileInt(ResStr(IDS_R_TEXT), ResStr(IDS_RT_AUTOPARCOMPENSATION), 0));
- pData = NULL;
- if (theApp.GetProfileBinary(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_MEDIAFPS), &pData, &nSize) && pData) {
- if (nSize != sizeof(m_MediaFPS)) {
- m_MediaFPS = 25.0;
- } else {
- memcpy(&m_MediaFPS, pData, sizeof(m_MediaFPS));
- }
- delete [] pData;
- }
- m_ZoomRect.left = m_ZoomRect.top = 0;
- m_ZoomRect.right = m_ZoomRect.bottom = 1;
-
- m_fForced = false;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ BYTE* pData;
+ UINT nSize;
+
+ m_iSelectedLanguage = 0;
+ m_fHideSubtitles = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_HIDE), 0);
+ m_uSubPictToBuffer = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SUBPICTTOBUFFER), 10);
+ m_fAnimWhenBuffering = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ANIMWHENBUFFERING), 1);
+ m_fOverridePlacement = !!theApp.GetProfileInt(ResStr(IDS_R_TEXT), ResStr(IDS_RT_OVERRIDEPLACEMENT), 0);
+ m_PlacementXperc = theApp.GetProfileInt(ResStr(IDS_R_TEXT), ResStr(IDS_RT_XPERC), 50);
+ m_PlacementYperc = theApp.GetProfileInt(ResStr(IDS_R_TEXT), ResStr(IDS_RT_YPERC), 90);
+ m_fBufferVobSub = !!theApp.GetProfileInt(ResStr(IDS_R_VOBSUB), ResStr(IDS_RV_BUFFER), 1);
+ m_fOnlyShowForcedVobSubs = !!theApp.GetProfileInt(ResStr(IDS_R_VOBSUB), ResStr(IDS_RV_ONLYSHOWFORCEDSUBS), 0);
+ m_fPolygonize = !!theApp.GetProfileInt(ResStr(IDS_R_VOBSUB), ResStr(IDS_RV_POLYGONIZE), 0);
+ m_defStyle <<= theApp.GetProfileString(ResStr(IDS_R_TEXT), ResStr(IDS_RT_STYLE), _T(""));
+ m_fFlipPicture = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_FLIPPICTURE), 0);
+ m_fFlipSubtitles = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_FLIPSUBTITLES), 0);
+ m_fOSD = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SHOWOSDSTATS), 0);
+ m_fSaveFullPath = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SAVEFULLPATH), 0);
+ m_nReloaderDisableCount = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_DISABLERELOADER), 0) ? 1 : 0;
+ m_SubtitleDelay = theApp.GetProfileInt(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_SUBTITLEDELAY), 0);
+ m_SubtitleSpeedMul = theApp.GetProfileInt(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_SUBTITLESPEEDMUL), 1000);
+ m_SubtitleSpeedDiv = theApp.GetProfileInt(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_SUBTITLESPEEDDIV), 1000);
+ m_fMediaFPSEnabled = !!theApp.GetProfileInt(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_MEDIAFPSENABLED), 0);
+ m_ePARCompensationType = static_cast<CSimpleTextSubtitle::EPARCompensationType>(theApp.GetProfileInt(ResStr(IDS_R_TEXT), ResStr(IDS_RT_AUTOPARCOMPENSATION), 0));
+ pData = NULL;
+ if (theApp.GetProfileBinary(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_MEDIAFPS), &pData, &nSize) && pData) {
+ if (nSize != sizeof(m_MediaFPS)) {
+ m_MediaFPS = 25.0;
+ } else {
+ memcpy(&m_MediaFPS, pData, sizeof(m_MediaFPS));
+ }
+ delete [] pData;
+ }
+ m_ZoomRect.left = m_ZoomRect.top = 0;
+ m_ZoomRect.right = m_ZoomRect.bottom = 1;
+
+ m_fForced = false;
}
CDirectVobSub::~CDirectVobSub()
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
}
STDMETHODIMP CDirectVobSub::get_FileName(WCHAR* fn)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if (!fn) {
- return E_POINTER;
- }
+ if (!fn) {
+ return E_POINTER;
+ }
- wcscpy(fn, m_FileName);
+ wcscpy(fn, m_FileName);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::put_FileName(WCHAR* fn)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if (!fn) {
- return E_POINTER;
- }
+ if (!fn) {
+ return E_POINTER;
+ }
- CString tmp = fn;
- if (!m_FileName.Left(m_FileName.ReverseFind('.')+1).CompareNoCase(tmp.Left(tmp.ReverseFind('.')+1))) {
- return S_FALSE;
- }
+ CString tmp = fn;
+ if (!m_FileName.Left(m_FileName.ReverseFind('.') + 1).CompareNoCase(tmp.Left(tmp.ReverseFind('.') + 1))) {
+ return S_FALSE;
+ }
- m_FileName = fn;
+ m_FileName = fn;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::get_LanguageCount(int* nLangs)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- return nLangs ? *nLangs = 0, S_OK : E_POINTER;
+ return nLangs ? *nLangs = 0, S_OK : E_POINTER;
}
STDMETHODIMP CDirectVobSub::get_LanguageName(int iLanguage, WCHAR** ppName)
{
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::get_SelectedLanguage(int* iSelected)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- return iSelected ? *iSelected = m_iSelectedLanguage, S_OK : E_POINTER;
+ return iSelected ? *iSelected = m_iSelectedLanguage, S_OK : E_POINTER;
}
STDMETHODIMP CDirectVobSub::put_SelectedLanguage(int iSelected)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if (m_iSelectedLanguage == iSelected) {
- return S_FALSE;
- }
+ if (m_iSelectedLanguage == iSelected) {
+ return S_FALSE;
+ }
- int nCount;
- if (FAILED(get_LanguageCount(&nCount))
- || iSelected < 0
- || iSelected >= nCount) {
- return E_FAIL;
- }
+ int nCount;
+ if (FAILED(get_LanguageCount(&nCount))
+ || iSelected < 0
+ || iSelected >= nCount) {
+ return E_FAIL;
+ }
- m_iSelectedLanguage = iSelected;
+ m_iSelectedLanguage = iSelected;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::get_HideSubtitles(bool* fHideSubtitles)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- return fHideSubtitles ? *fHideSubtitles = m_fHideSubtitles, S_OK : E_POINTER;
+ return fHideSubtitles ? *fHideSubtitles = m_fHideSubtitles, S_OK : E_POINTER;
}
STDMETHODIMP CDirectVobSub::put_HideSubtitles(bool fHideSubtitles)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if (m_fHideSubtitles == fHideSubtitles) {
- return S_FALSE;
- }
+ if (m_fHideSubtitles == fHideSubtitles) {
+ return S_FALSE;
+ }
- m_fHideSubtitles = fHideSubtitles;
+ m_fHideSubtitles = fHideSubtitles;
- return S_OK;
+ return S_OK;
}
// deprecated
STDMETHODIMP CDirectVobSub::get_PreBuffering(bool* fDoPreBuffering)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- return fDoPreBuffering ? *fDoPreBuffering = (m_uSubPictToBuffer > 0), S_OK : E_POINTER;
+ return fDoPreBuffering ? *fDoPreBuffering = (m_uSubPictToBuffer > 0), S_OK : E_POINTER;
}
// deprecated
STDMETHODIMP CDirectVobSub::put_PreBuffering(bool fDoPreBuffering)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if ((m_uSubPictToBuffer > 0) == fDoPreBuffering) {
- return S_FALSE;
- }
+ if ((m_uSubPictToBuffer > 0) == fDoPreBuffering) {
+ return S_FALSE;
+ }
- m_uSubPictToBuffer = fDoPreBuffering ? 4 : 0; // 4 is the default value for SubPictToBuffer
+ m_uSubPictToBuffer = fDoPreBuffering ? 4 : 0; // 4 is the default value for SubPictToBuffer
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::get_SubPictToBuffer(unsigned int* uSubPictToBuffer)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- return uSubPictToBuffer ? *uSubPictToBuffer = m_uSubPictToBuffer, S_OK : E_POINTER;
+ return uSubPictToBuffer ? *uSubPictToBuffer = m_uSubPictToBuffer, S_OK : E_POINTER;
}
STDMETHODIMP CDirectVobSub::put_SubPictToBuffer(unsigned int uSubPictToBuffer)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if (m_uSubPictToBuffer == uSubPictToBuffer) {
- return S_FALSE;
- }
+ if (m_uSubPictToBuffer == uSubPictToBuffer) {
+ return S_FALSE;
+ }
- m_uSubPictToBuffer = uSubPictToBuffer;
+ m_uSubPictToBuffer = uSubPictToBuffer;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::get_AnimWhenBuffering(bool* fAnimWhenBuffering)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- return fAnimWhenBuffering ? *fAnimWhenBuffering = m_fAnimWhenBuffering, S_OK : E_POINTER;
+ return fAnimWhenBuffering ? *fAnimWhenBuffering = m_fAnimWhenBuffering, S_OK : E_POINTER;
}
STDMETHODIMP CDirectVobSub::put_AnimWhenBuffering(bool fAnimWhenBuffering)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if (m_fAnimWhenBuffering == fAnimWhenBuffering) {
- return S_FALSE;
- }
+ if (m_fAnimWhenBuffering == fAnimWhenBuffering) {
+ return S_FALSE;
+ }
- m_fAnimWhenBuffering = fAnimWhenBuffering;
+ m_fAnimWhenBuffering = fAnimWhenBuffering;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::get_Placement(bool* fOverridePlacement, int* xperc, int* yperc)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if (fOverridePlacement) {
- *fOverridePlacement = m_fOverridePlacement;
- }
- if (xperc) {
- *xperc = m_PlacementXperc;
- }
- if (yperc) {
- *yperc = m_PlacementYperc;
- }
+ if (fOverridePlacement) {
+ *fOverridePlacement = m_fOverridePlacement;
+ }
+ if (xperc) {
+ *xperc = m_PlacementXperc;
+ }
+ if (yperc) {
+ *yperc = m_PlacementYperc;
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::put_Placement(bool fOverridePlacement, int xperc, int yperc)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if (m_fOverridePlacement == fOverridePlacement && m_PlacementXperc == xperc && m_PlacementYperc == yperc) {
- return S_FALSE;
- }
+ if (m_fOverridePlacement == fOverridePlacement && m_PlacementXperc == xperc && m_PlacementYperc == yperc) {
+ return S_FALSE;
+ }
- m_fOverridePlacement = fOverridePlacement;
- m_PlacementXperc = xperc;
- m_PlacementYperc = yperc;
+ m_fOverridePlacement = fOverridePlacement;
+ m_PlacementXperc = xperc;
+ m_PlacementYperc = yperc;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::get_VobSubSettings(bool* fBuffer, bool* fOnlyShowForcedSubs, bool* fPolygonize)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if (fBuffer) {
- *fBuffer = m_fBufferVobSub;
- }
- if (fOnlyShowForcedSubs) {
- *fOnlyShowForcedSubs = m_fOnlyShowForcedVobSubs;
- }
- if (fPolygonize) {
- *fPolygonize = m_fPolygonize;
- }
+ if (fBuffer) {
+ *fBuffer = m_fBufferVobSub;
+ }
+ if (fOnlyShowForcedSubs) {
+ *fOnlyShowForcedSubs = m_fOnlyShowForcedVobSubs;
+ }
+ if (fPolygonize) {
+ *fPolygonize = m_fPolygonize;
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::put_VobSubSettings(bool fBuffer, bool fOnlyShowForcedSubs, bool fPolygonize)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if (m_fBufferVobSub == fBuffer && m_fOnlyShowForcedVobSubs == fOnlyShowForcedSubs && m_fPolygonize == fPolygonize) {
- return S_FALSE;
- }
+ if (m_fBufferVobSub == fBuffer && m_fOnlyShowForcedVobSubs == fOnlyShowForcedSubs && m_fPolygonize == fPolygonize) {
+ return S_FALSE;
+ }
- m_fBufferVobSub = fBuffer;
- m_fOnlyShowForcedVobSubs = fOnlyShowForcedSubs;
- m_fPolygonize = fPolygonize;
+ m_fBufferVobSub = fBuffer;
+ m_fOnlyShowForcedVobSubs = fOnlyShowForcedSubs;
+ m_fPolygonize = fPolygonize;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::get_TextSettings(void* lf, int lflen, COLORREF* color, bool* fShadow, bool* fOutline, bool* fAdvancedRenderer)
{
- CAutoLock cAutoLock(&m_propsLock);
-
- if (lf) {
- if (lflen == sizeof(LOGFONTA)) {
- strncpy_s(((LOGFONTA*)lf)->lfFaceName, LF_FACESIZE, CStringA(m_defStyle.fontName), _TRUNCATE);
- } else if (lflen == sizeof(LOGFONTW)) {
- wcsncpy_s(((LOGFONTW*)lf)->lfFaceName, LF_FACESIZE, CStringW(m_defStyle.fontName), _TRUNCATE);
- } else {
- return E_INVALIDARG;
- }
-
- ((LOGFONT*)lf)->lfCharSet = m_defStyle.charSet;
- ((LOGFONT*)lf)->lfItalic = m_defStyle.fItalic;
- ((LOGFONT*)lf)->lfHeight = (LONG)m_defStyle.fontSize;
- ((LOGFONT*)lf)->lfWeight = m_defStyle.fontWeight;
- ((LOGFONT*)lf)->lfStrikeOut = m_defStyle.fStrikeOut;
- ((LOGFONT*)lf)->lfUnderline = m_defStyle.fUnderline;
- }
-
- if (color) {
- *color = m_defStyle.colors[0];
- }
- if (fShadow) {
- *fShadow = (m_defStyle.shadowDepthX!=0) || (m_defStyle.shadowDepthY!=0);
- }
- if (fOutline) {
- *fOutline = (m_defStyle.outlineWidthX+m_defStyle.outlineWidthY)>0;
- }
- if (fAdvancedRenderer) {
- *fAdvancedRenderer = m_fAdvancedRenderer;
- }
-
- return S_OK;
+ CAutoLock cAutoLock(&m_propsLock);
+
+ if (lf) {
+ if (lflen == sizeof(LOGFONTA)) {
+ strncpy_s(((LOGFONTA*)lf)->lfFaceName, LF_FACESIZE, CStringA(m_defStyle.fontName), _TRUNCATE);
+ } else if (lflen == sizeof(LOGFONTW)) {
+ wcsncpy_s(((LOGFONTW*)lf)->lfFaceName, LF_FACESIZE, CStringW(m_defStyle.fontName), _TRUNCATE);
+ } else {
+ return E_INVALIDARG;
+ }
+
+ ((LOGFONT*)lf)->lfCharSet = m_defStyle.charSet;
+ ((LOGFONT*)lf)->lfItalic = m_defStyle.fItalic;
+ ((LOGFONT*)lf)->lfHeight = (LONG)m_defStyle.fontSize;
+ ((LOGFONT*)lf)->lfWeight = m_defStyle.fontWeight;
+ ((LOGFONT*)lf)->lfStrikeOut = m_defStyle.fStrikeOut;
+ ((LOGFONT*)lf)->lfUnderline = m_defStyle.fUnderline;
+ }
+
+ if (color) {
+ *color = m_defStyle.colors[0];
+ }
+ if (fShadow) {
+ *fShadow = (m_defStyle.shadowDepthX != 0) || (m_defStyle.shadowDepthY != 0);
+ }
+ if (fOutline) {
+ *fOutline = (m_defStyle.outlineWidthX + m_defStyle.outlineWidthY) > 0;
+ }
+ if (fAdvancedRenderer) {
+ *fAdvancedRenderer = m_fAdvancedRenderer;
+ }
+
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::put_TextSettings(void* lf, int lflen, COLORREF color, bool fShadow, bool fOutline, bool fAdvancedRenderer)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if (lf) {
- if (lflen == sizeof(LOGFONTA)) {
- m_defStyle.fontName = ((LOGFONTA*)lf)->lfFaceName;
- } else if (lflen == sizeof(LOGFONTW)) {
- m_defStyle.fontName = ((LOGFONTW*)lf)->lfFaceName;
- } else {
- return E_INVALIDARG;
- }
+ if (lf) {
+ if (lflen == sizeof(LOGFONTA)) {
+ m_defStyle.fontName = ((LOGFONTA*)lf)->lfFaceName;
+ } else if (lflen == sizeof(LOGFONTW)) {
+ m_defStyle.fontName = ((LOGFONTW*)lf)->lfFaceName;
+ } else {
+ return E_INVALIDARG;
+ }
- m_defStyle.charSet = ((LOGFONT*)lf)->lfCharSet;
- m_defStyle.fItalic = !!((LOGFONT*)lf)->lfItalic;
- m_defStyle.fontSize = ((LOGFONT*)lf)->lfHeight;
- m_defStyle.fontWeight = ((LOGFONT*)lf)->lfWeight;
- m_defStyle.fStrikeOut = !!((LOGFONT*)lf)->lfStrikeOut;
- m_defStyle.fUnderline = !!((LOGFONT*)lf)->lfUnderline;
+ m_defStyle.charSet = ((LOGFONT*)lf)->lfCharSet;
+ m_defStyle.fItalic = !!((LOGFONT*)lf)->lfItalic;
+ m_defStyle.fontSize = ((LOGFONT*)lf)->lfHeight;
+ m_defStyle.fontWeight = ((LOGFONT*)lf)->lfWeight;
+ m_defStyle.fStrikeOut = !!((LOGFONT*)lf)->lfStrikeOut;
+ m_defStyle.fUnderline = !!((LOGFONT*)lf)->lfUnderline;
- if (m_defStyle.fontSize < 0) {
- HDC hdc = ::GetDC(0);
- m_defStyle.fontSize = -m_defStyle.fontSize * 72 / GetDeviceCaps(hdc, LOGPIXELSY);
- ::ReleaseDC(0, hdc);
- }
+ if (m_defStyle.fontSize < 0) {
+ HDC hdc = ::GetDC(0);
+ m_defStyle.fontSize = -m_defStyle.fontSize * 72 / GetDeviceCaps(hdc, LOGPIXELSY);
+ ::ReleaseDC(0, hdc);
+ }
- }
+ }
- m_defStyle.colors[0] = color;
- m_defStyle.shadowDepthX = m_defStyle.shadowDepthY = fShadow?2:0;
- m_defStyle.outlineWidthX = m_defStyle.outlineWidthY = fOutline?2:0;
+ m_defStyle.colors[0] = color;
+ m_defStyle.shadowDepthX = m_defStyle.shadowDepthY = fShadow ? 2 : 0;
+ m_defStyle.outlineWidthX = m_defStyle.outlineWidthY = fOutline ? 2 : 0;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::get_Flip(bool* fPicture, bool* fSubtitles)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if (fPicture) {
- *fPicture = m_fFlipPicture;
- }
- if (fSubtitles) {
- *fSubtitles = m_fFlipSubtitles;
- }
+ if (fPicture) {
+ *fPicture = m_fFlipPicture;
+ }
+ if (fSubtitles) {
+ *fSubtitles = m_fFlipSubtitles;
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::put_Flip(bool fPicture, bool fSubtitles)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if (m_fFlipPicture == fPicture && m_fFlipSubtitles == fSubtitles) {
- return S_FALSE;
- }
+ if (m_fFlipPicture == fPicture && m_fFlipSubtitles == fSubtitles) {
+ return S_FALSE;
+ }
- m_fFlipPicture = fPicture;
- m_fFlipSubtitles = fSubtitles;
+ m_fFlipPicture = fPicture;
+ m_fFlipSubtitles = fSubtitles;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::get_OSD(bool* fOSD)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- return fOSD ? *fOSD = m_fOSD, S_OK : E_POINTER;
+ return fOSD ? *fOSD = m_fOSD, S_OK : E_POINTER;
}
STDMETHODIMP CDirectVobSub::put_OSD(bool fOSD)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if (m_fOSD == fOSD) {
- return S_FALSE;
- }
+ if (m_fOSD == fOSD) {
+ return S_FALSE;
+ }
- m_fOSD = fOSD;
+ m_fOSD = fOSD;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::get_SaveFullPath(bool* fSaveFullPath)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- return fSaveFullPath ? *fSaveFullPath = m_fSaveFullPath, S_OK : E_POINTER;
+ return fSaveFullPath ? *fSaveFullPath = m_fSaveFullPath, S_OK : E_POINTER;
}
STDMETHODIMP CDirectVobSub::put_SaveFullPath(bool fSaveFullPath)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if (m_fSaveFullPath == fSaveFullPath) {
- return S_FALSE;
- }
+ if (m_fSaveFullPath == fSaveFullPath) {
+ return S_FALSE;
+ }
- m_fSaveFullPath = fSaveFullPath;
+ m_fSaveFullPath = fSaveFullPath;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::get_SubtitleTiming(int* delay, int* speedmul, int* speeddiv)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if (delay) {
- *delay = m_SubtitleDelay;
- }
- if (speedmul) {
- *speedmul = m_SubtitleSpeedMul;
- }
- if (speeddiv) {
- *speeddiv = m_SubtitleSpeedDiv;
- }
+ if (delay) {
+ *delay = m_SubtitleDelay;
+ }
+ if (speedmul) {
+ *speedmul = m_SubtitleSpeedMul;
+ }
+ if (speeddiv) {
+ *speeddiv = m_SubtitleSpeedDiv;
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::put_SubtitleTiming(int delay, int speedmul, int speeddiv)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if (m_SubtitleDelay == delay && m_SubtitleSpeedMul == speedmul && m_SubtitleSpeedDiv == speeddiv) {
- return S_FALSE;
- }
+ if (m_SubtitleDelay == delay && m_SubtitleSpeedMul == speedmul && m_SubtitleSpeedDiv == speeddiv) {
+ return S_FALSE;
+ }
- m_SubtitleDelay = delay;
- m_SubtitleSpeedMul = speedmul;
- if (speeddiv > 0) {
- m_SubtitleSpeedDiv = speeddiv;
- }
+ m_SubtitleDelay = delay;
+ m_SubtitleSpeedMul = speedmul;
+ if (speeddiv > 0) {
+ m_SubtitleSpeedDiv = speeddiv;
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::get_MediaFPS(bool* fEnabled, double* fps)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if (fEnabled) {
- *fEnabled = m_fMediaFPSEnabled;
- }
- if (fps) {
- *fps = m_MediaFPS;
- }
+ if (fEnabled) {
+ *fEnabled = m_fMediaFPSEnabled;
+ }
+ if (fps) {
+ *fps = m_MediaFPS;
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::put_MediaFPS(bool fEnabled, double fps)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if (m_fMediaFPSEnabled == fEnabled && m_MediaFPS == fps) {
- return S_FALSE;
- }
+ if (m_fMediaFPSEnabled == fEnabled && m_MediaFPS == fps) {
+ return S_FALSE;
+ }
- m_fMediaFPSEnabled = fEnabled;
- if (fps > 0) {
- m_MediaFPS = fps;
- }
+ m_fMediaFPSEnabled = fEnabled;
+ if (fps > 0) {
+ m_MediaFPS = fps;
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::get_ZoomRect(NORMALIZEDRECT* rect)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if (!rect) {
- return E_POINTER;
- }
+ if (!rect) {
+ return E_POINTER;
+ }
- *rect = m_ZoomRect;
+ *rect = m_ZoomRect;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::put_ZoomRect(NORMALIZEDRECT* rect)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if (!rect) {
- return E_POINTER;
- }
+ if (!rect) {
+ return E_POINTER;
+ }
- if (!memcmp(&m_ZoomRect, rect, sizeof(m_ZoomRect))) {
- return S_FALSE;
- }
+ if (!memcmp(&m_ZoomRect, rect, sizeof(m_ZoomRect))) {
+ return S_FALSE;
+ }
- m_ZoomRect = *rect;
+ m_ZoomRect = *rect;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::UpdateRegistry()
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- CAutoLock cAutoLock(&m_propsLock);
-
- theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_HIDE), m_fHideSubtitles);
- theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SUBPICTTOBUFFER), m_uSubPictToBuffer);
- theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ANIMWHENBUFFERING), m_fAnimWhenBuffering);
- theApp.WriteProfileInt(ResStr(IDS_R_TEXT), ResStr(IDS_RT_OVERRIDEPLACEMENT), m_fOverridePlacement);
- theApp.WriteProfileInt(ResStr(IDS_R_TEXT), ResStr(IDS_RT_XPERC), m_PlacementXperc);
- theApp.WriteProfileInt(ResStr(IDS_R_TEXT), ResStr(IDS_RT_YPERC), m_PlacementYperc);
- theApp.WriteProfileInt(ResStr(IDS_R_VOBSUB), ResStr(IDS_RV_BUFFER), m_fBufferVobSub);
- theApp.WriteProfileInt(ResStr(IDS_R_VOBSUB), ResStr(IDS_RV_ONLYSHOWFORCEDSUBS), m_fOnlyShowForcedVobSubs);
- theApp.WriteProfileInt(ResStr(IDS_R_VOBSUB), ResStr(IDS_RV_POLYGONIZE), m_fPolygonize);
- CString style;
- theApp.WriteProfileString(ResStr(IDS_R_TEXT), ResStr(IDS_RT_STYLE), style <<= m_defStyle);
- theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_FLIPPICTURE), m_fFlipPicture);
- theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_FLIPSUBTITLES), m_fFlipSubtitles);
- theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SHOWOSDSTATS), m_fOSD);
- theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SAVEFULLPATH), m_fSaveFullPath);
- theApp.WriteProfileInt(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_SUBTITLEDELAY), m_SubtitleDelay);
- theApp.WriteProfileInt(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_SUBTITLESPEEDMUL), m_SubtitleSpeedMul);
- theApp.WriteProfileInt(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_SUBTITLESPEEDDIV), m_SubtitleSpeedDiv);
- theApp.WriteProfileInt(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_MEDIAFPSENABLED), m_fMediaFPSEnabled);
- theApp.WriteProfileBinary(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_MEDIAFPS), (BYTE*)&m_MediaFPS, sizeof(m_MediaFPS));
- theApp.WriteProfileInt(ResStr(IDS_R_TEXT), ResStr(IDS_RT_AUTOPARCOMPENSATION), m_ePARCompensationType);
-
- return S_OK;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ CAutoLock cAutoLock(&m_propsLock);
+
+ theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_HIDE), m_fHideSubtitles);
+ theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SUBPICTTOBUFFER), m_uSubPictToBuffer);
+ theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ANIMWHENBUFFERING), m_fAnimWhenBuffering);
+ theApp.WriteProfileInt(ResStr(IDS_R_TEXT), ResStr(IDS_RT_OVERRIDEPLACEMENT), m_fOverridePlacement);
+ theApp.WriteProfileInt(ResStr(IDS_R_TEXT), ResStr(IDS_RT_XPERC), m_PlacementXperc);
+ theApp.WriteProfileInt(ResStr(IDS_R_TEXT), ResStr(IDS_RT_YPERC), m_PlacementYperc);
+ theApp.WriteProfileInt(ResStr(IDS_R_VOBSUB), ResStr(IDS_RV_BUFFER), m_fBufferVobSub);
+ theApp.WriteProfileInt(ResStr(IDS_R_VOBSUB), ResStr(IDS_RV_ONLYSHOWFORCEDSUBS), m_fOnlyShowForcedVobSubs);
+ theApp.WriteProfileInt(ResStr(IDS_R_VOBSUB), ResStr(IDS_RV_POLYGONIZE), m_fPolygonize);
+ CString style;
+ theApp.WriteProfileString(ResStr(IDS_R_TEXT), ResStr(IDS_RT_STYLE), style <<= m_defStyle);
+ theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_FLIPPICTURE), m_fFlipPicture);
+ theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_FLIPSUBTITLES), m_fFlipSubtitles);
+ theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SHOWOSDSTATS), m_fOSD);
+ theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SAVEFULLPATH), m_fSaveFullPath);
+ theApp.WriteProfileInt(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_SUBTITLEDELAY), m_SubtitleDelay);
+ theApp.WriteProfileInt(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_SUBTITLESPEEDMUL), m_SubtitleSpeedMul);
+ theApp.WriteProfileInt(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_SUBTITLESPEEDDIV), m_SubtitleSpeedDiv);
+ theApp.WriteProfileInt(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_MEDIAFPSENABLED), m_fMediaFPSEnabled);
+ theApp.WriteProfileBinary(ResStr(IDS_R_TIMING), ResStr(IDS_RTM_MEDIAFPS), (BYTE*)&m_MediaFPS, sizeof(m_MediaFPS));
+ theApp.WriteProfileInt(ResStr(IDS_R_TEXT), ResStr(IDS_RT_AUTOPARCOMPENSATION), m_ePARCompensationType);
+
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::HasConfigDialog(int iSelected)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CDirectVobSub::ShowConfigDialog(int iSelected, HWND hWndParent)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CDirectVobSub::IsSubtitleReloaderLocked(bool* fLocked)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if (!fLocked) {
- return E_POINTER;
- }
+ if (!fLocked) {
+ return E_POINTER;
+ }
- bool fDisabled;
- get_SubtitleReloader(&fDisabled);
+ bool fDisabled;
+ get_SubtitleReloader(&fDisabled);
- *fLocked = fDisabled || m_nReloaderDisableCount > 0;
+ *fLocked = fDisabled || m_nReloaderDisableCount > 0;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::LockSubtitleReloader(bool fLock)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if (fLock) {
- m_nReloaderDisableCount++;
- } else {
- m_nReloaderDisableCount--;
- }
+ if (fLock) {
+ m_nReloaderDisableCount++;
+ } else {
+ m_nReloaderDisableCount--;
+ }
- ASSERT(m_nReloaderDisableCount >= 0);
- if (m_nReloaderDisableCount < 0) {
- m_nReloaderDisableCount = 0;
- }
+ ASSERT(m_nReloaderDisableCount >= 0);
+ if (m_nReloaderDisableCount < 0) {
+ m_nReloaderDisableCount = 0;
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::get_SubtitleReloader(bool* fDisabled)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if (fDisabled) {
- *fDisabled = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_DISABLERELOADER), 0);
- }
+ if (fDisabled) {
+ *fDisabled = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_DISABLERELOADER), 0);
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::put_SubtitleReloader(bool fDisable)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- bool b;
- get_SubtitleReloader(&b);
- if (b == fDisable) {
- return S_FALSE;
- }
+ bool b;
+ get_SubtitleReloader(&b);
+ if (b == fDisable) {
+ return S_FALSE;
+ }
- theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_DISABLERELOADER), fDisable);
+ theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_DISABLERELOADER), fDisable);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::get_ExtendPicture(int* horizontal, int* vertical, int* resx2, int* resx2minw, int* resx2minh)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if (horizontal) {
- *horizontal = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_MOD32FIX), 0) & 1;
- }
- if (vertical) {
- *vertical = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EXTPIC), 0);
- }
- if (resx2) {
- *resx2 = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2), 2) & 3;
- }
- if (resx2minw) {
- *resx2minw = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2MINW), 384);
- }
- if (resx2minh) {
- *resx2minh = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2MINH), 288);
- }
+ if (horizontal) {
+ *horizontal = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_MOD32FIX), 0) & 1;
+ }
+ if (vertical) {
+ *vertical = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EXTPIC), 0);
+ }
+ if (resx2) {
+ *resx2 = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2), 2) & 3;
+ }
+ if (resx2minw) {
+ *resx2minw = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2MINW), 384);
+ }
+ if (resx2minh) {
+ *resx2minh = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2MINH), 288);
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::put_ExtendPicture(int horizontal, int vertical, int resx2, int resx2minw, int resx2minh)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- int i[5];
- get_ExtendPicture(i, i+1, i+2, i+3, i+4);
- if (i[0] == horizontal && i[1] == vertical && i[2] == resx2 && i[3] == resx2minw && i[4] == resx2minh) {
- return S_FALSE;
- }
+ int i[5];
+ get_ExtendPicture(i, i + 1, i + 2, i + 3, i + 4);
+ if (i[0] == horizontal && i[1] == vertical && i[2] == resx2 && i[3] == resx2minw && i[4] == resx2minh) {
+ return S_FALSE;
+ }
- theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_MOD32FIX), horizontal & 1);
- theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EXTPIC), vertical);
- theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2), resx2 & 3);
- theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2MINW), resx2minw);
- theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2MINH), resx2minh);
+ theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_MOD32FIX), horizontal & 1);
+ theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EXTPIC), vertical);
+ theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2), resx2 & 3);
+ theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2MINW), resx2minw);
+ theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_RESX2MINH), resx2minh);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::get_LoadSettings(int* level, bool* fExternalLoad, bool* fWebLoad, bool* fEmbeddedLoad)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if (level) {
- *level = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_LOADLEVEL), 0) & 3;
- }
- if (fExternalLoad) {
- *fExternalLoad = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EXTERNALLOAD), 1);
- }
- if (fWebLoad) {
- *fWebLoad = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_WEBLOAD), 0);
- }
- if (fEmbeddedLoad) {
- *fEmbeddedLoad = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EMBEDDEDLOAD), 1);
- }
+ if (level) {
+ *level = theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_LOADLEVEL), 0) & 3;
+ }
+ if (fExternalLoad) {
+ *fExternalLoad = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EXTERNALLOAD), 1);
+ }
+ if (fWebLoad) {
+ *fWebLoad = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_WEBLOAD), 0);
+ }
+ if (fEmbeddedLoad) {
+ *fEmbeddedLoad = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EMBEDDEDLOAD), 1);
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::put_LoadSettings(int level, bool fExternalLoad, bool fWebLoad, bool fEmbeddedLoad)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- int i;
- bool b[3];
- get_LoadSettings(&i, b, b+1, b+2);
- if (i == level && b[0] == fExternalLoad && b[1] == fWebLoad && b[2] == fEmbeddedLoad) {
- return S_FALSE;
- }
+ int i;
+ bool b[3];
+ get_LoadSettings(&i, b, b + 1, b + 2);
+ if (i == level && b[0] == fExternalLoad && b[1] == fWebLoad && b[2] == fEmbeddedLoad) {
+ return S_FALSE;
+ }
- theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_LOADLEVEL), level & 3);
- theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EXTERNALLOAD), fExternalLoad);
- theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_WEBLOAD), fWebLoad);
- theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EMBEDDEDLOAD), fEmbeddedLoad);
+ theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_LOADLEVEL), level & 3);
+ theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EXTERNALLOAD), fExternalLoad);
+ theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_WEBLOAD), fWebLoad);
+ theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_EMBEDDEDLOAD), fEmbeddedLoad);
- return S_OK;
+ return S_OK;
}
// IDirectVobSub2
STDMETHODIMP CDirectVobSub::AdviseSubClock(ISubClock* pSubClock)
{
- m_pSubClock = pSubClock;
- return S_OK;
+ m_pSubClock = pSubClock;
+ return S_OK;
}
STDMETHODIMP_(bool) CDirectVobSub::get_Forced()
{
- return m_fForced;
+ return m_fForced;
}
STDMETHODIMP CDirectVobSub::put_Forced(bool fForced)
{
- m_fForced = fForced;
- return S_OK;
+ m_fForced = fForced;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::get_TextSettings(STSStyle* pDefStyle)
{
- CheckPointer(pDefStyle, E_POINTER);
+ CheckPointer(pDefStyle, E_POINTER);
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- *pDefStyle = m_defStyle;
+ *pDefStyle = m_defStyle;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::put_TextSettings(STSStyle* pDefStyle)
{
- CheckPointer(pDefStyle, E_POINTER);
+ CheckPointer(pDefStyle, E_POINTER);
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- if (!memcmp(&m_defStyle, pDefStyle, sizeof(m_defStyle))) {
- return S_FALSE;
- }
+ if (!memcmp(&m_defStyle, pDefStyle, sizeof(m_defStyle))) {
+ return S_FALSE;
+ }
- m_defStyle = *pDefStyle;
+ m_defStyle = *pDefStyle;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::get_AspectRatioSettings(CSimpleTextSubtitle::EPARCompensationType* ePARCompensationType)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- *ePARCompensationType = m_ePARCompensationType;
+ *ePARCompensationType = m_ePARCompensationType;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CDirectVobSub::put_AspectRatioSettings(CSimpleTextSubtitle::EPARCompensationType* ePARCompensationType)
{
- CAutoLock cAutoLock(&m_propsLock);
+ CAutoLock cAutoLock(&m_propsLock);
- m_ePARCompensationType = *ePARCompensationType;
+ m_ePARCompensationType = *ePARCompensationType;
- return S_OK;
+ return S_OK;
}
// IFilterVersion
STDMETHODIMP_(DWORD) CDirectVobSub::GetFilterVersion()
{
- return 0x0234;
+ return 0x0234;
}
diff --git a/src/filters/transform/VSFilter/DirectVobSub.h b/src/filters/transform/VSFilter/DirectVobSub.h
index e7cb42e25..3c307b1e8 100644
--- a/src/filters/transform/VSFilter/DirectVobSub.h
+++ b/src/filters/transform/VSFilter/DirectVobSub.h
@@ -29,110 +29,110 @@
class CDirectVobSub : public IDirectVobSub2, public IFilterVersion
{
protected:
- CDirectVobSub();
- virtual ~CDirectVobSub();
+ CDirectVobSub();
+ virtual ~CDirectVobSub();
protected:
- CCritSec m_propsLock;
-
- CString m_FileName;
- int m_iSelectedLanguage;
- bool m_fHideSubtitles;
- unsigned int m_uSubPictToBuffer;
- bool m_fAnimWhenBuffering;
- bool m_fOverridePlacement;
- int m_PlacementXperc, m_PlacementYperc;
- bool m_fBufferVobSub, m_fOnlyShowForcedVobSubs, m_fPolygonize;
- CSimpleTextSubtitle::EPARCompensationType m_ePARCompensationType;
-
- STSStyle m_defStyle;
-
- bool m_fAdvancedRenderer;
- bool m_fFlipPicture, m_fFlipSubtitles;
- bool m_fOSD;
- int m_nReloaderDisableCount;
- int m_SubtitleDelay, m_SubtitleSpeedMul, m_SubtitleSpeedDiv;
- bool m_fMediaFPSEnabled;
- double m_MediaFPS;
- bool m_fSaveFullPath;
- NORMALIZEDRECT m_ZoomRect;
-
- CComPtr<ISubClock> m_pSubClock;
- bool m_fForced;
+ CCritSec m_propsLock;
+
+ CString m_FileName;
+ int m_iSelectedLanguage;
+ bool m_fHideSubtitles;
+ unsigned int m_uSubPictToBuffer;
+ bool m_fAnimWhenBuffering;
+ bool m_fOverridePlacement;
+ int m_PlacementXperc, m_PlacementYperc;
+ bool m_fBufferVobSub, m_fOnlyShowForcedVobSubs, m_fPolygonize;
+ CSimpleTextSubtitle::EPARCompensationType m_ePARCompensationType;
+
+ STSStyle m_defStyle;
+
+ bool m_fAdvancedRenderer;
+ bool m_fFlipPicture, m_fFlipSubtitles;
+ bool m_fOSD;
+ int m_nReloaderDisableCount;
+ int m_SubtitleDelay, m_SubtitleSpeedMul, m_SubtitleSpeedDiv;
+ bool m_fMediaFPSEnabled;
+ double m_MediaFPS;
+ bool m_fSaveFullPath;
+ NORMALIZEDRECT m_ZoomRect;
+
+ CComPtr<ISubClock> m_pSubClock;
+ bool m_fForced;
public:
- // IDirectVobSub
-
- STDMETHODIMP get_FileName(WCHAR* fn);
- STDMETHODIMP put_FileName(WCHAR* fn);
- STDMETHODIMP get_LanguageCount(int* nLangs);
- STDMETHODIMP get_LanguageName(int iLanguage, WCHAR** ppName);
- STDMETHODIMP get_SelectedLanguage(int* iSelected);
- STDMETHODIMP put_SelectedLanguage(int iSelected);
- STDMETHODIMP get_HideSubtitles(bool* fHideSubtitles);
- STDMETHODIMP put_HideSubtitles(bool fHideSubtitles);
- STDMETHODIMP get_PreBuffering(bool* fDoPreBuffering); // deprecated
- STDMETHODIMP put_PreBuffering(bool fDoPreBuffering); // deprecated
- STDMETHODIMP get_SubPictToBuffer(unsigned int* uSubPictToBuffer);
- STDMETHODIMP put_SubPictToBuffer(unsigned int uSubPictToBuffer);
- STDMETHODIMP get_AnimWhenBuffering(bool* fAnimWhenBuffering);
- STDMETHODIMP put_AnimWhenBuffering(bool fAnimWhenBuffering);
- STDMETHODIMP get_Placement(bool* fOverridePlacement, int* xperc, int* yperc);
- STDMETHODIMP put_Placement(bool fOverridePlacement, int xperc, int yperc);
- STDMETHODIMP get_VobSubSettings(bool* fBuffer, bool* fOnlyShowForcedSubs, bool* fPolygonize);
- STDMETHODIMP put_VobSubSettings(bool fBuffer, bool fOnlyShowForcedSubs, bool fPolygonize);
- STDMETHODIMP get_TextSettings(void* lf, int lflen, COLORREF* color, bool* fShadow, bool* fOutline, bool* fAdvancedRenderer);
- STDMETHODIMP put_TextSettings(void* lf, int lflen, COLORREF color, bool fShadow, bool fOutline, bool fAdvancedRenderer);
- STDMETHODIMP get_Flip(bool* fPicture, bool* fSubtitles);
- STDMETHODIMP put_Flip(bool fPicture, bool fSubtitles);
- STDMETHODIMP get_OSD(bool* fShowOSD);
- STDMETHODIMP put_OSD(bool fShowOSD);
- STDMETHODIMP get_SaveFullPath(bool* fSaveFullPath);
- STDMETHODIMP put_SaveFullPath(bool fSaveFullPath);
- STDMETHODIMP get_SubtitleTiming(int* delay, int* speedmul, int* speeddiv);
- STDMETHODIMP put_SubtitleTiming(int delay, int speedmul, int speeddiv);
- STDMETHODIMP get_MediaFPS(bool* fEnabled, double* fps);
- STDMETHODIMP put_MediaFPS(bool fEnabled, double fps);
- STDMETHODIMP get_ZoomRect(NORMALIZEDRECT* rect);
- STDMETHODIMP put_ZoomRect(NORMALIZEDRECT* rect);
- STDMETHODIMP get_ColorFormat(int* iPosition) {
- return E_NOTIMPL;
- }
- STDMETHODIMP put_ColorFormat(int iPosition) {
- return E_NOTIMPL;
- }
-
- STDMETHODIMP UpdateRegistry();
-
- STDMETHODIMP HasConfigDialog(int iSelected);
- STDMETHODIMP ShowConfigDialog(int iSelected, HWND hWndParent);
-
- // settings for the rest are stored in the registry
-
- STDMETHODIMP IsSubtitleReloaderLocked(bool* fLocked);
- STDMETHODIMP LockSubtitleReloader(bool fLock);
- STDMETHODIMP get_SubtitleReloader(bool* fDisabled);
- STDMETHODIMP put_SubtitleReloader(bool fDisable);
-
- // the followings need a partial or full reloading of the filter
-
- STDMETHODIMP get_ExtendPicture(int* horizontal, int* vertical, int* resx2, int* resx2minw, int* resx2minh);
- STDMETHODIMP put_ExtendPicture(int horizontal, int vertical, int resx2, int resx2minw, int resx2minh);
- STDMETHODIMP get_LoadSettings(int* level, bool* fExternalLoad, bool* fWebLoad, bool* fEmbeddedLoad);
- STDMETHODIMP put_LoadSettings(int level, bool fExternalLoad, bool fWebLoad, bool fEmbeddedLoad);
-
- // IDirectVobSub2
-
- STDMETHODIMP AdviseSubClock(ISubClock* pSubClock);
- STDMETHODIMP_(bool) get_Forced();
- STDMETHODIMP put_Forced(bool fForced);
- STDMETHODIMP get_TextSettings(STSStyle* pDefStyle);
- STDMETHODIMP put_TextSettings(STSStyle* pDefStyle);
- STDMETHODIMP get_AspectRatioSettings(CSimpleTextSubtitle::EPARCompensationType* ePARCompensationType);
- STDMETHODIMP put_AspectRatioSettings(CSimpleTextSubtitle::EPARCompensationType* ePARCompensationType);
-
- // IFilterVersion
-
- STDMETHODIMP_(DWORD) GetFilterVersion();
+ // IDirectVobSub
+
+ STDMETHODIMP get_FileName(WCHAR* fn);
+ STDMETHODIMP put_FileName(WCHAR* fn);
+ STDMETHODIMP get_LanguageCount(int* nLangs);
+ STDMETHODIMP get_LanguageName(int iLanguage, WCHAR** ppName);
+ STDMETHODIMP get_SelectedLanguage(int* iSelected);
+ STDMETHODIMP put_SelectedLanguage(int iSelected);
+ STDMETHODIMP get_HideSubtitles(bool* fHideSubtitles);
+ STDMETHODIMP put_HideSubtitles(bool fHideSubtitles);
+ STDMETHODIMP get_PreBuffering(bool* fDoPreBuffering); // deprecated
+ STDMETHODIMP put_PreBuffering(bool fDoPreBuffering); // deprecated
+ STDMETHODIMP get_SubPictToBuffer(unsigned int* uSubPictToBuffer);
+ STDMETHODIMP put_SubPictToBuffer(unsigned int uSubPictToBuffer);
+ STDMETHODIMP get_AnimWhenBuffering(bool* fAnimWhenBuffering);
+ STDMETHODIMP put_AnimWhenBuffering(bool fAnimWhenBuffering);
+ STDMETHODIMP get_Placement(bool* fOverridePlacement, int* xperc, int* yperc);
+ STDMETHODIMP put_Placement(bool fOverridePlacement, int xperc, int yperc);
+ STDMETHODIMP get_VobSubSettings(bool* fBuffer, bool* fOnlyShowForcedSubs, bool* fPolygonize);
+ STDMETHODIMP put_VobSubSettings(bool fBuffer, bool fOnlyShowForcedSubs, bool fPolygonize);
+ STDMETHODIMP get_TextSettings(void* lf, int lflen, COLORREF* color, bool* fShadow, bool* fOutline, bool* fAdvancedRenderer);
+ STDMETHODIMP put_TextSettings(void* lf, int lflen, COLORREF color, bool fShadow, bool fOutline, bool fAdvancedRenderer);
+ STDMETHODIMP get_Flip(bool* fPicture, bool* fSubtitles);
+ STDMETHODIMP put_Flip(bool fPicture, bool fSubtitles);
+ STDMETHODIMP get_OSD(bool* fShowOSD);
+ STDMETHODIMP put_OSD(bool fShowOSD);
+ STDMETHODIMP get_SaveFullPath(bool* fSaveFullPath);
+ STDMETHODIMP put_SaveFullPath(bool fSaveFullPath);
+ STDMETHODIMP get_SubtitleTiming(int* delay, int* speedmul, int* speeddiv);
+ STDMETHODIMP put_SubtitleTiming(int delay, int speedmul, int speeddiv);
+ STDMETHODIMP get_MediaFPS(bool* fEnabled, double* fps);
+ STDMETHODIMP put_MediaFPS(bool fEnabled, double fps);
+ STDMETHODIMP get_ZoomRect(NORMALIZEDRECT* rect);
+ STDMETHODIMP put_ZoomRect(NORMALIZEDRECT* rect);
+ STDMETHODIMP get_ColorFormat(int* iPosition) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP put_ColorFormat(int iPosition) {
+ return E_NOTIMPL;
+ }
+
+ STDMETHODIMP UpdateRegistry();
+
+ STDMETHODIMP HasConfigDialog(int iSelected);
+ STDMETHODIMP ShowConfigDialog(int iSelected, HWND hWndParent);
+
+ // settings for the rest are stored in the registry
+
+ STDMETHODIMP IsSubtitleReloaderLocked(bool* fLocked);
+ STDMETHODIMP LockSubtitleReloader(bool fLock);
+ STDMETHODIMP get_SubtitleReloader(bool* fDisabled);
+ STDMETHODIMP put_SubtitleReloader(bool fDisable);
+
+ // the followings need a partial or full reloading of the filter
+
+ STDMETHODIMP get_ExtendPicture(int* horizontal, int* vertical, int* resx2, int* resx2minw, int* resx2minh);
+ STDMETHODIMP put_ExtendPicture(int horizontal, int vertical, int resx2, int resx2minw, int resx2minh);
+ STDMETHODIMP get_LoadSettings(int* level, bool* fExternalLoad, bool* fWebLoad, bool* fEmbeddedLoad);
+ STDMETHODIMP put_LoadSettings(int level, bool fExternalLoad, bool fWebLoad, bool fEmbeddedLoad);
+
+ // IDirectVobSub2
+
+ STDMETHODIMP AdviseSubClock(ISubClock* pSubClock);
+ STDMETHODIMP_(bool) get_Forced();
+ STDMETHODIMP put_Forced(bool fForced);
+ STDMETHODIMP get_TextSettings(STSStyle* pDefStyle);
+ STDMETHODIMP put_TextSettings(STSStyle* pDefStyle);
+ STDMETHODIMP get_AspectRatioSettings(CSimpleTextSubtitle::EPARCompensationType* ePARCompensationType);
+ STDMETHODIMP put_AspectRatioSettings(CSimpleTextSubtitle::EPARCompensationType* ePARCompensationType);
+
+ // IFilterVersion
+
+ STDMETHODIMP_(DWORD) GetFilterVersion();
};
diff --git a/src/filters/transform/VSFilter/DirectVobSubFilter.cpp b/src/filters/transform/VSFilter/DirectVobSubFilter.cpp
index e70ade97b..74c4b9d6d 100644
--- a/src/filters/transform/VSFilter/DirectVobSubFilter.cpp
+++ b/src/filters/transform/VSFilter/DirectVobSubFilter.cpp
@@ -47,1744 +47,1744 @@ bool g_RegOK = true;//false; // doesn't work with the dvd graph builder
//
CDirectVobSubFilter::CDirectVobSubFilter(LPUNKNOWN punk, HRESULT* phr, const GUID& clsid)
- : CBaseVideoFilter(NAME("CDirectVobSubFilter"), punk, phr, clsid)
- , m_nSubtitleId((DWORD_PTR)-1)
- , m_fMSMpeg4Fix(false)
- , m_fps(25)
+ : CBaseVideoFilter(NAME("CDirectVobSubFilter"), punk, phr, clsid)
+ , m_nSubtitleId((DWORD_PTR) - 1)
+ , m_fMSMpeg4Fix(false)
+ , m_fps(25)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- m_hdc = 0;
- m_hbm = 0;
- m_hfont = 0;
-
- {
- LOGFONT lf;
- memset(&lf, 0, sizeof(lf));
- lf.lfCharSet = DEFAULT_CHARSET;
- lf.lfOutPrecision = OUT_CHARACTER_PRECIS;
- lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
- lf.lfQuality = ANTIALIASED_QUALITY;
- HDC hdc = GetDC(NULL);
- lf.lfHeight = -MulDiv(10, GetDeviceCaps(hdc, LOGPIXELSY), 72);
- ReleaseDC(NULL, hdc);
- lf.lfWeight = FW_BOLD;
- _tcscpy_s(lf.lfFaceName, _T("Arial"));
- m_hfont = CreateFontIndirect(&lf);
- }
-
- theApp.WriteProfileString(ResStr(IDS_R_DEFTEXTPATHES), _T("Hint"), _T("The first three are fixed, but you can add more up to ten entries."));
- theApp.WriteProfileString(ResStr(IDS_R_DEFTEXTPATHES), _T("Path0"), _T("."));
- theApp.WriteProfileString(ResStr(IDS_R_DEFTEXTPATHES), _T("Path1"), _T("c:\\subtitles"));
- theApp.WriteProfileString(ResStr(IDS_R_DEFTEXTPATHES), _T("Path2"), _T(".\\subtitles"));
-
- m_fLoading = true;
-
- m_hSystrayThread = 0;
- m_tbid.hSystrayWnd = NULL;
- m_tbid.graph = NULL;
- m_tbid.fRunOnce = false;
- m_tbid.fShowIcon = (theApp.m_AppName.Find(_T("zplayer"), 0) < 0 || !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ENABLEZPICON), 0));
-
- HRESULT hr = S_OK;
- m_pTextInput.Add(DNew CTextInputPin(this, m_pLock, &m_csSubLock, &hr));
- ASSERT(SUCCEEDED(hr));
-
- CAMThread::Create();
- m_frd.EndThreadEvent.Create(0, FALSE, FALSE, 0);
- m_frd.RefreshEvent.Create(0, FALSE, FALSE, 0);
-
- memset(&m_CurrentVIH2, 0, sizeof(VIDEOINFOHEADER2));
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ m_hdc = 0;
+ m_hbm = 0;
+ m_hfont = 0;
+
+ {
+ LOGFONT lf;
+ memset(&lf, 0, sizeof(lf));
+ lf.lfCharSet = DEFAULT_CHARSET;
+ lf.lfOutPrecision = OUT_CHARACTER_PRECIS;
+ lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
+ lf.lfQuality = ANTIALIASED_QUALITY;
+ HDC hdc = GetDC(NULL);
+ lf.lfHeight = -MulDiv(10, GetDeviceCaps(hdc, LOGPIXELSY), 72);
+ ReleaseDC(NULL, hdc);
+ lf.lfWeight = FW_BOLD;
+ _tcscpy_s(lf.lfFaceName, _T("Arial"));
+ m_hfont = CreateFontIndirect(&lf);
+ }
+
+ theApp.WriteProfileString(ResStr(IDS_R_DEFTEXTPATHES), _T("Hint"), _T("The first three are fixed, but you can add more up to ten entries."));
+ theApp.WriteProfileString(ResStr(IDS_R_DEFTEXTPATHES), _T("Path0"), _T("."));
+ theApp.WriteProfileString(ResStr(IDS_R_DEFTEXTPATHES), _T("Path1"), _T("c:\\subtitles"));
+ theApp.WriteProfileString(ResStr(IDS_R_DEFTEXTPATHES), _T("Path2"), _T(".\\subtitles"));
+
+ m_fLoading = true;
+
+ m_hSystrayThread = 0;
+ m_tbid.hSystrayWnd = NULL;
+ m_tbid.graph = NULL;
+ m_tbid.fRunOnce = false;
+ m_tbid.fShowIcon = (theApp.m_AppName.Find(_T("zplayer"), 0) < 0 || !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ENABLEZPICON), 0));
+
+ HRESULT hr = S_OK;
+ m_pTextInput.Add(DNew CTextInputPin(this, m_pLock, &m_csSubLock, &hr));
+ ASSERT(SUCCEEDED(hr));
+
+ CAMThread::Create();
+ m_frd.EndThreadEvent.Create(0, FALSE, FALSE, 0);
+ m_frd.RefreshEvent.Create(0, FALSE, FALSE, 0);
+
+ memset(&m_CurrentVIH2, 0, sizeof(VIDEOINFOHEADER2));
}
CDirectVobSubFilter::~CDirectVobSubFilter()
{
- CAutoLock cAutoLock(&m_csQueueLock);
- if (m_pSubPicQueue) {
- m_pSubPicQueue->Invalidate();
- }
- m_pSubPicQueue = NULL;
-
- if (m_hfont) {
- DeleteObject(m_hfont);
- m_hfont = 0;
- }
- if (m_hbm) {
- DeleteObject(m_hbm);
- m_hbm = 0;
- }
- if (m_hdc) {
- DeleteObject(m_hdc);
- m_hdc = 0;
- }
-
- for (size_t i = 0; i < m_pTextInput.GetCount(); i++) {
- delete m_pTextInput[i];
- }
-
- m_frd.EndThreadEvent.Set();
- CAMThread::Close();
+ CAutoLock cAutoLock(&m_csQueueLock);
+ if (m_pSubPicQueue) {
+ m_pSubPicQueue->Invalidate();
+ }
+ m_pSubPicQueue = NULL;
+
+ if (m_hfont) {
+ DeleteObject(m_hfont);
+ m_hfont = 0;
+ }
+ if (m_hbm) {
+ DeleteObject(m_hbm);
+ m_hbm = 0;
+ }
+ if (m_hdc) {
+ DeleteObject(m_hdc);
+ m_hdc = 0;
+ }
+
+ for (size_t i = 0; i < m_pTextInput.GetCount(); i++) {
+ delete m_pTextInput[i];
+ }
+
+ m_frd.EndThreadEvent.Set();
+ CAMThread::Close();
}
STDMETHODIMP CDirectVobSubFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
-
- return
- QI(IDirectVobSub)
- QI(IDirectVobSub2)
- QI(IFilterVersion)
- QI(ISpecifyPropertyPages)
- QI(IAMStreamSelect)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ CheckPointer(ppv, E_POINTER);
+
+ return
+ QI(IDirectVobSub)
+ QI(IDirectVobSub2)
+ QI(IFilterVersion)
+ QI(ISpecifyPropertyPages)
+ QI(IAMStreamSelect)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// CBaseVideoFilter
void CDirectVobSubFilter::GetOutputSize(int& w, int& h, int& arx, int& ary, int& RealWidth, int& RealHeight, int& vsfilter)
{
- CSize s(w, h), os = s;
- AdjustFrameSize(s);
- w = s.cx;
- h = s.cy;
- vsfilter = 1; // enable workaround, see BaseVideoFilter.cpp
-
- if (w != os.cx) {
- while (arx < 100) {
- arx *= 10, ary *= 10;
- }
- arx = arx * w / os.cx;
- }
-
- if (h != os.cy) {
- while (ary < 100) {
- arx *= 10, ary *= 10;
- }
- ary = ary * h / os.cy;
- }
+ CSize s(w, h), os = s;
+ AdjustFrameSize(s);
+ w = s.cx;
+ h = s.cy;
+ vsfilter = 1; // enable workaround, see BaseVideoFilter.cpp
+
+ if (w != os.cx) {
+ while (arx < 100) {
+ arx *= 10, ary *= 10;
+ }
+ arx = arx * w / os.cx;
+ }
+
+ if (h != os.cy) {
+ while (ary < 100) {
+ arx *= 10, ary *= 10;
+ }
+ ary = ary * h / os.cy;
+ }
}
HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn)
{
- HRESULT hr;
+ HRESULT hr;
- REFERENCE_TIME rtStart, rtStop;
- if (SUCCEEDED(pIn->GetTime(&rtStart, &rtStop))) {
- double dRate = m_pInput->CurrentRate();
+ REFERENCE_TIME rtStart, rtStop;
+ if (SUCCEEDED(pIn->GetTime(&rtStart, &rtStop))) {
+ double dRate = m_pInput->CurrentRate();
- m_tPrev = m_pInput->CurrentStartTime() + (REFERENCE_TIME)(dRate*rtStart);
-
- REFERENCE_TIME rtAvgTimePerFrame = rtStop - rtStart;
- if (CComQIPtr<ISubClock2> pSC2 = m_pSubClock) {
- REFERENCE_TIME rt;
- if (S_OK == pSC2->GetAvgTimePerFrame(&rt)) {
- rtAvgTimePerFrame = rt;
- }
- }
+ m_tPrev = m_pInput->CurrentStartTime() + (REFERENCE_TIME)(dRate * rtStart);
+
+ REFERENCE_TIME rtAvgTimePerFrame = rtStop - rtStart;
+ if (CComQIPtr<ISubClock2> pSC2 = m_pSubClock) {
+ REFERENCE_TIME rt;
+ if (S_OK == pSC2->GetAvgTimePerFrame(&rt)) {
+ rtAvgTimePerFrame = rt;
+ }
+ }
- m_fps = 10000000.0/rtAvgTimePerFrame / dRate;
- }
-
- //
+ m_fps = 10000000.0 / rtAvgTimePerFrame / dRate;
+ }
+
+ //
- {
- CAutoLock cAutoLock(&m_csQueueLock);
+ {
+ CAutoLock cAutoLock(&m_csQueueLock);
- if (m_pSubPicQueue) {
- m_pSubPicQueue->SetTime(CalcCurrentTime());
- m_pSubPicQueue->SetFPS(m_fps);
- }
- }
+ if (m_pSubPicQueue) {
+ m_pSubPicQueue->SetTime(CalcCurrentTime());
+ m_pSubPicQueue->SetFPS(m_fps);
+ }
+ }
- //
+ //
- BYTE* pDataIn = NULL;
- if (FAILED(pIn->GetPointer(&pDataIn)) || !pDataIn) {
- return S_FALSE;
- }
+ BYTE* pDataIn = NULL;
+ if (FAILED(pIn->GetPointer(&pDataIn)) || !pDataIn) {
+ return S_FALSE;
+ }
- const CMediaType& mt = m_pInput->CurrentMediaType();
+ const CMediaType& mt = m_pInput->CurrentMediaType();
- BITMAPINFOHEADER bihIn;
- ExtractBIH(&mt, &bihIn);
+ BITMAPINFOHEADER bihIn;
+ ExtractBIH(&mt, &bihIn);
- bool fYV12 = (mt.subtype == MEDIASUBTYPE_YV12 || mt.subtype == MEDIASUBTYPE_I420 || mt.subtype == MEDIASUBTYPE_IYUV);
- int bpp = fYV12 ? 8 : bihIn.biBitCount;
- DWORD black = fYV12 ? 0x10101010 : (bihIn.biCompression == '2YUY') ? 0x80108010 : 0;
+ bool fYV12 = (mt.subtype == MEDIASUBTYPE_YV12 || mt.subtype == MEDIASUBTYPE_I420 || mt.subtype == MEDIASUBTYPE_IYUV);
+ int bpp = fYV12 ? 8 : bihIn.biBitCount;
+ DWORD black = fYV12 ? 0x10101010 : (bihIn.biCompression == '2YUY') ? 0x80108010 : 0;
- CSize sub(m_w, m_h);
- CSize in(bihIn.biWidth, bihIn.biHeight);
+ CSize sub(m_w, m_h);
+ CSize in(bihIn.biWidth, bihIn.biHeight);
- if (FAILED(Copy((BYTE*)m_pTempPicBuff, pDataIn, sub, in, bpp, mt.subtype, black))) {
- return E_FAIL;
- }
+ if (FAILED(Copy((BYTE*)m_pTempPicBuff, pDataIn, sub, in, bpp, mt.subtype, black))) {
+ return E_FAIL;
+ }
- if (fYV12) {
- BYTE* pSubV = (BYTE*)m_pTempPicBuff + (sub.cx*bpp>>3)*sub.cy;
- BYTE* pInV = pDataIn + (in.cx*bpp>>3)*in.cy;
- sub.cx >>= 1;
- sub.cy >>= 1;
- in.cx >>= 1;
- in.cy >>= 1;
- BYTE* pSubU = pSubV + (sub.cx*bpp>>3)*sub.cy;
- BYTE* pInU = pInV + (in.cx*bpp>>3)*in.cy;
- if (FAILED(Copy(pSubV, pInV, sub, in, bpp, mt.subtype, 0x80808080))) {
- return E_FAIL;
- }
- if (FAILED(Copy(pSubU, pInU, sub, in, bpp, mt.subtype, 0x80808080))) {
- return E_FAIL;
- }
- }
+ if (fYV12) {
+ BYTE* pSubV = (BYTE*)m_pTempPicBuff + (sub.cx * bpp >> 3) * sub.cy;
+ BYTE* pInV = pDataIn + (in.cx * bpp >> 3) * in.cy;
+ sub.cx >>= 1;
+ sub.cy >>= 1;
+ in.cx >>= 1;
+ in.cy >>= 1;
+ BYTE* pSubU = pSubV + (sub.cx * bpp >> 3) * sub.cy;
+ BYTE* pInU = pInV + (in.cx * bpp >> 3) * in.cy;
+ if (FAILED(Copy(pSubV, pInV, sub, in, bpp, mt.subtype, 0x80808080))) {
+ return E_FAIL;
+ }
+ if (FAILED(Copy(pSubU, pInU, sub, in, bpp, mt.subtype, 0x80808080))) {
+ return E_FAIL;
+ }
+ }
- //
+ //
- SubPicDesc spd = m_spd;
+ SubPicDesc spd = m_spd;
- CComPtr<IMediaSample> pOut;
- BYTE* pDataOut = NULL;
- if (FAILED(hr = GetDeliveryBuffer(spd.w, spd.h, &pOut))
- || FAILED(hr = pOut->GetPointer(&pDataOut))) {
- return hr;
- }
+ CComPtr<IMediaSample> pOut;
+ BYTE* pDataOut = NULL;
+ if (FAILED(hr = GetDeliveryBuffer(spd.w, spd.h, &pOut))
+ || FAILED(hr = pOut->GetPointer(&pDataOut))) {
+ return hr;
+ }
- pOut->SetTime(&rtStart, &rtStop);
- pOut->SetMediaTime(NULL, NULL);
+ pOut->SetTime(&rtStart, &rtStop);
+ pOut->SetMediaTime(NULL, NULL);
- pOut->SetDiscontinuity(pIn->IsDiscontinuity() == S_OK);
- pOut->SetSyncPoint(pIn->IsSyncPoint() == S_OK);
- pOut->SetPreroll(pIn->IsPreroll() == S_OK);
+ pOut->SetDiscontinuity(pIn->IsDiscontinuity() == S_OK);
+ pOut->SetSyncPoint(pIn->IsSyncPoint() == S_OK);
+ pOut->SetPreroll(pIn->IsPreroll() == S_OK);
- //
+ //
- BITMAPINFOHEADER bihOut;
- ExtractBIH(&m_pOutput->CurrentMediaType(), &bihOut);
+ BITMAPINFOHEADER bihOut;
+ ExtractBIH(&m_pOutput->CurrentMediaType(), &bihOut);
- bool fInputFlipped = bihIn.biHeight >= 0 && bihIn.biCompression <= 3;
- bool fOutputFlipped = bihOut.biHeight >= 0 && bihOut.biCompression <= 3;
+ bool fInputFlipped = bihIn.biHeight >= 0 && bihIn.biCompression <= 3;
+ bool fOutputFlipped = bihOut.biHeight >= 0 && bihOut.biCompression <= 3;
- bool fFlip = fInputFlipped != fOutputFlipped;
- if (m_fFlipPicture) {
- fFlip = !fFlip;
- }
- if (m_fMSMpeg4Fix) {
- fFlip = !fFlip;
- }
+ bool fFlip = fInputFlipped != fOutputFlipped;
+ if (m_fFlipPicture) {
+ fFlip = !fFlip;
+ }
+ if (m_fMSMpeg4Fix) {
+ fFlip = !fFlip;
+ }
- bool fFlipSub = fOutputFlipped;
- if (m_fFlipSubtitles) {
- fFlipSub = !fFlipSub;
- }
-
- //
-
- {
- CAutoLock cAutoLock(&m_csQueueLock);
+ bool fFlipSub = fOutputFlipped;
+ if (m_fFlipSubtitles) {
+ fFlipSub = !fFlipSub;
+ }
+
+ //
+
+ {
+ CAutoLock cAutoLock(&m_csQueueLock);
- if (m_pSubPicQueue) {
- CComPtr<ISubPic> pSubPic;
- if ((m_pSubPicQueue->LookupSubPic(CalcCurrentTime(), pSubPic)) && pSubPic) {
- CRect r;
- pSubPic->GetDirtyRect(r);
+ if (m_pSubPicQueue) {
+ CComPtr<ISubPic> pSubPic;
+ if ((m_pSubPicQueue->LookupSubPic(CalcCurrentTime(), pSubPic)) && pSubPic) {
+ CRect r;
+ pSubPic->GetDirtyRect(r);
- if (fFlip ^ fFlipSub) {
- spd.h = -spd.h;
- }
+ if (fFlip ^ fFlipSub) {
+ spd.h = -spd.h;
+ }
- pSubPic->AlphaBlt(r, r, &spd);
- }
- }
- }
+ pSubPic->AlphaBlt(r, r, &spd);
+ }
+ }
+ }
- CopyBuffer(pDataOut, (BYTE*)spd.bits, spd.w, abs(spd.h)*(fFlip?-1:1), spd.pitch, mt.subtype);
-
- PrintMessages(pDataOut);
-
- return m_pOutput->Deliver(pOut);
+ CopyBuffer(pDataOut, (BYTE*)spd.bits, spd.w, abs(spd.h) * (fFlip ? -1 : 1), spd.pitch, mt.subtype);
+
+ PrintMessages(pDataOut);
+
+ return m_pOutput->Deliver(pOut);
}
// CBaseFilter
CBasePin* CDirectVobSubFilter::GetPin(int n)
{
- if (n < __super::GetPinCount()) {
- return __super::GetPin(n);
- }
+ if (n < __super::GetPinCount()) {
+ return __super::GetPin(n);
+ }
- n -= __super::GetPinCount();
+ n -= __super::GetPinCount();
- if (n >= 0 && (size_t)n < m_pTextInput.GetCount()) {
- return m_pTextInput[n];
- }
+ if (n >= 0 && (size_t)n < m_pTextInput.GetCount()) {
+ return m_pTextInput[n];
+ }
- n -= m_pTextInput.GetCount();
+ n -= m_pTextInput.GetCount();
- return NULL;
+ return NULL;
}
int CDirectVobSubFilter::GetPinCount()
{
- return __super::GetPinCount() + m_pTextInput.GetCount();
+ return __super::GetPinCount() + m_pTextInput.GetCount();
}
HRESULT CDirectVobSubFilter::JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pName)
{
- if (pGraph) {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- if (!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SEENDIVXWARNING), 0)) {
- unsigned __int64 ver = GetFileVersion(_T("divx_c32.ax"));
- if (((ver >> 48)&0xffff) == 4 && ((ver >> 32)&0xffff) == 2) {
- DWORD dwVersion = GetVersion();
- DWORD dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
- //DWORD dwWindowsMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
-
- if (dwVersion < 0x80000000 && dwWindowsMajorVersion >= 5) {
- AfxMessageBox(IDS_DIVX_WARNING, MB_ICONWARNING | MB_OK, 0);
- theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SEENDIVXWARNING), 1);
- }
- }
- }
-
- /*removeme*/
- if (!g_RegOK) {
- DllRegisterServer();
- g_RegOK = true;
- }
- } else {
- if (m_hSystrayThread) {
- SendMessage(m_tbid.hSystrayWnd, WM_CLOSE, 0, 0);
-
- if (WaitForSingleObject(m_hSystrayThread, 10000) != WAIT_OBJECT_0) {
- DbgLog((LOG_TRACE, 0, _T("CALL THE AMBULANCE!!!")));
- TerminateThread(m_hSystrayThread, (DWORD)-1);
- }
-
- m_hSystrayThread = 0;
- }
- }
-
- return __super::JoinFilterGraph(pGraph, pName);
+ if (pGraph) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ if (!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SEENDIVXWARNING), 0)) {
+ unsigned __int64 ver = GetFileVersion(_T("divx_c32.ax"));
+ if (((ver >> 48) & 0xffff) == 4 && ((ver >> 32) & 0xffff) == 2) {
+ DWORD dwVersion = GetVersion();
+ DWORD dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
+ //DWORD dwWindowsMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
+
+ if (dwVersion < 0x80000000 && dwWindowsMajorVersion >= 5) {
+ AfxMessageBox(IDS_DIVX_WARNING, MB_ICONWARNING | MB_OK, 0);
+ theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SEENDIVXWARNING), 1);
+ }
+ }
+ }
+
+ /*removeme*/
+ if (!g_RegOK) {
+ DllRegisterServer();
+ g_RegOK = true;
+ }
+ } else {
+ if (m_hSystrayThread) {
+ SendMessage(m_tbid.hSystrayWnd, WM_CLOSE, 0, 0);
+
+ if (WaitForSingleObject(m_hSystrayThread, 10000) != WAIT_OBJECT_0) {
+ DbgLog((LOG_TRACE, 0, _T("CALL THE AMBULANCE!!!")));
+ TerminateThread(m_hSystrayThread, (DWORD) - 1);
+ }
+
+ m_hSystrayThread = 0;
+ }
+ }
+
+ return __super::JoinFilterGraph(pGraph, pName);
}
STDMETHODIMP CDirectVobSubFilter::QueryFilterInfo(FILTER_INFO* pInfo)
{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
+ CheckPointer(pInfo, E_POINTER);
+ ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
- if (!get_Forced()) {
- return __super::QueryFilterInfo(pInfo);
- }
+ if (!get_Forced()) {
+ return __super::QueryFilterInfo(pInfo);
+ }
- wcscpy_s(pInfo->achName, L"DirectVobSub (forced auto-loading version)");
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
+ wcscpy_s(pInfo->achName, L"DirectVobSub (forced auto-loading version)");
+ pInfo->pGraph = m_pGraph;
+ if (m_pGraph) {
+ m_pGraph->AddRef();
+ }
- return S_OK;
+ return S_OK;
}
// CTransformFilter
HRESULT CDirectVobSubFilter::SetMediaType(PIN_DIRECTION dir, const CMediaType* pmt)
{
- HRESULT hr = __super::SetMediaType(dir, pmt);
- if (FAILED(hr)) {
- return hr;
- }
+ HRESULT hr = __super::SetMediaType(dir, pmt);
+ if (FAILED(hr)) {
+ return hr;
+ }
- if (dir == PINDIR_INPUT) {
- CAutoLock cAutoLock(&m_csReceive);
+ if (dir == PINDIR_INPUT) {
+ CAutoLock cAutoLock(&m_csReceive);
- REFERENCE_TIME atpf =
- pmt->formattype == FORMAT_VideoInfo ? ((VIDEOINFOHEADER*)pmt->Format())->AvgTimePerFrame :
- pmt->formattype == FORMAT_VideoInfo2 ? ((VIDEOINFOHEADER2*)pmt->Format())->AvgTimePerFrame :
- 0;
+ REFERENCE_TIME atpf =
+ pmt->formattype == FORMAT_VideoInfo ? ((VIDEOINFOHEADER*)pmt->Format())->AvgTimePerFrame :
+ pmt->formattype == FORMAT_VideoInfo2 ? ((VIDEOINFOHEADER2*)pmt->Format())->AvgTimePerFrame :
+ 0;
- m_fps = atpf ? 10000000.0 / atpf : 25;
+ m_fps = atpf ? 10000000.0 / atpf : 25;
- if (pmt->formattype == FORMAT_VideoInfo2) {
- m_CurrentVIH2 = *(VIDEOINFOHEADER2*)pmt->Format();
- }
+ if (pmt->formattype == FORMAT_VideoInfo2) {
+ m_CurrentVIH2 = *(VIDEOINFOHEADER2*)pmt->Format();
+ }
- InitSubPicQueue();
- } else if (dir == PINDIR_OUTPUT) {
+ InitSubPicQueue();
+ } else if (dir == PINDIR_OUTPUT) {
- }
+ }
- return hr;
+ return hr;
}
HRESULT CDirectVobSubFilter::CheckConnect(PIN_DIRECTION dir, IPin* pPin)
{
- if (dir == PINDIR_INPUT) {
- } else if (dir == PINDIR_OUTPUT) {
- }
+ if (dir == PINDIR_INPUT) {
+ } else if (dir == PINDIR_OUTPUT) {
+ }
- return __super::CheckConnect(dir, pPin);
+ return __super::CheckConnect(dir, pPin);
}
HRESULT CDirectVobSubFilter::CompleteConnect(PIN_DIRECTION dir, IPin* pReceivePin)
{
- if (dir == PINDIR_INPUT) {
- CComPtr<IBaseFilter> pFilter;
-
- // needed when we have a decoder with a version number of 3.x
- if (SUCCEEDED(m_pGraph->FindFilterByName(L"DivX MPEG-4 DVD Video Decompressor ", &pFilter))
- && (GetFileVersion(_T("divx_c32.ax")) >> 48) <= 4
- || SUCCEEDED(m_pGraph->FindFilterByName(L"Microcrap MPEG-4 Video Decompressor", &pFilter))
- || SUCCEEDED(m_pGraph->FindFilterByName(L"Microsoft MPEG-4 Video Decompressor", &pFilter))
- && (GetFileVersion(_T("mpg4ds32.ax")) >> 48) <= 3) {
- m_fMSMpeg4Fix = true;
- }
- } else if (dir == PINDIR_OUTPUT) {
- if (!m_hSystrayThread) {
- m_tbid.graph = m_pGraph;
- m_tbid.dvs = static_cast<IDirectVobSub*>(this);
-
- DWORD tid;
- m_hSystrayThread = CreateThread(0, 0, SystrayThreadProc, &m_tbid, 0, &tid);
- }
-
- // HACK: triggers CBaseVideoFilter::SetMediaType to adjust m_w/m_h/.. and InitSubPicQueue() to realloc buffers
- m_pInput->SetMediaType(&m_pInput->CurrentMediaType());
- }
-
- return __super::CompleteConnect(dir, pReceivePin);
+ if (dir == PINDIR_INPUT) {
+ CComPtr<IBaseFilter> pFilter;
+
+ // needed when we have a decoder with a version number of 3.x
+ if (SUCCEEDED(m_pGraph->FindFilterByName(L"DivX MPEG-4 DVD Video Decompressor ", &pFilter))
+ && (GetFileVersion(_T("divx_c32.ax")) >> 48) <= 4
+ || SUCCEEDED(m_pGraph->FindFilterByName(L"Microcrap MPEG-4 Video Decompressor", &pFilter))
+ || SUCCEEDED(m_pGraph->FindFilterByName(L"Microsoft MPEG-4 Video Decompressor", &pFilter))
+ && (GetFileVersion(_T("mpg4ds32.ax")) >> 48) <= 3) {
+ m_fMSMpeg4Fix = true;
+ }
+ } else if (dir == PINDIR_OUTPUT) {
+ if (!m_hSystrayThread) {
+ m_tbid.graph = m_pGraph;
+ m_tbid.dvs = static_cast<IDirectVobSub*>(this);
+
+ DWORD tid;
+ m_hSystrayThread = CreateThread(0, 0, SystrayThreadProc, &m_tbid, 0, &tid);
+ }
+
+ // HACK: triggers CBaseVideoFilter::SetMediaType to adjust m_w/m_h/.. and InitSubPicQueue() to realloc buffers
+ m_pInput->SetMediaType(&m_pInput->CurrentMediaType());
+ }
+
+ return __super::CompleteConnect(dir, pReceivePin);
}
HRESULT CDirectVobSubFilter::BreakConnect(PIN_DIRECTION dir)
{
- if (dir == PINDIR_INPUT) {
- if (m_pOutput->IsConnected()) {
- m_pOutput->GetConnected()->Disconnect();
- m_pOutput->Disconnect();
- }
- } else if (dir == PINDIR_OUTPUT) {
- // not really needed, but may free up a little memory
- CAutoLock cAutoLock(&m_csQueueLock);
- m_pSubPicQueue = NULL;
- }
-
- return __super::BreakConnect(dir);
+ if (dir == PINDIR_INPUT) {
+ if (m_pOutput->IsConnected()) {
+ m_pOutput->GetConnected()->Disconnect();
+ m_pOutput->Disconnect();
+ }
+ } else if (dir == PINDIR_OUTPUT) {
+ // not really needed, but may free up a little memory
+ CAutoLock cAutoLock(&m_csQueueLock);
+ m_pSubPicQueue = NULL;
+ }
+
+ return __super::BreakConnect(dir);
}
HRESULT CDirectVobSubFilter::StartStreaming()
{
- // WARNING : calls to m_pGraph member functions from here will generate deadlock with Haali Renderer
- // within MPC-HC (reason is CAutoLock's variables in IFilterGraph functions overriden by CFGManager class)
+ // WARNING : calls to m_pGraph member functions from here will generate deadlock with Haali Renderer
+ // within MPC-HC (reason is CAutoLock's variables in IFilterGraph functions overriden by CFGManager class)
- m_fLoading = false;
+ m_fLoading = false;
- InitSubPicQueue();
+ InitSubPicQueue();
- m_tbid.fRunOnce = true;
+ m_tbid.fRunOnce = true;
- put_MediaFPS(m_fMediaFPSEnabled, m_MediaFPS);
+ put_MediaFPS(m_fMediaFPSEnabled, m_MediaFPS);
- return __super::StartStreaming();
+ return __super::StartStreaming();
}
HRESULT CDirectVobSubFilter::StopStreaming()
{
- InvalidateSubtitle();
+ InvalidateSubtitle();
- return __super::StopStreaming();
+ return __super::StopStreaming();
}
HRESULT CDirectVobSubFilter::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- m_tPrev = tStart;
- return __super::NewSegment(tStart, tStop, dRate);
+ m_tPrev = tStart;
+ return __super::NewSegment(tStart, tStop, dRate);
}
//
REFERENCE_TIME CDirectVobSubFilter::CalcCurrentTime()
{
- REFERENCE_TIME rt = m_pSubClock ? m_pSubClock->GetTime() : m_tPrev;
- return (rt - 10000i64*m_SubtitleDelay) * m_SubtitleSpeedMul / m_SubtitleSpeedDiv; // no, it won't overflow if we use normal parameters (__int64 is enough for about 2000 hours if we multiply it by the max: 65536 as m_SubtitleSpeedMul)
+ REFERENCE_TIME rt = m_pSubClock ? m_pSubClock->GetTime() : m_tPrev;
+ return (rt - 10000i64 * m_SubtitleDelay) * m_SubtitleSpeedMul / m_SubtitleSpeedDiv; // no, it won't overflow if we use normal parameters (__int64 is enough for about 2000 hours if we multiply it by the max: 65536 as m_SubtitleSpeedMul)
}
void CDirectVobSubFilter::InitSubPicQueue()
{
- CAutoLock cAutoLock(&m_csQueueLock);
-
- m_pSubPicQueue = NULL;
-
- m_pTempPicBuff.Free();
- m_pTempPicBuff.Allocate(4*m_w*m_h);
-
- const GUID& subtype = m_pInput->CurrentMediaType().subtype;
-
- BITMAPINFOHEADER bihIn;
- ExtractBIH(&m_pInput->CurrentMediaType(), &bihIn);
-
- m_spd.type = -1;
- if (subtype == MEDIASUBTYPE_YV12) {
- m_spd.type = MSP_YV12;
- } else if (subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV) {
- m_spd.type = MSP_IYUV;
- } else if (subtype == MEDIASUBTYPE_YUY2) {
- m_spd.type = MSP_YUY2;
- } else if (subtype == MEDIASUBTYPE_RGB32) {
- m_spd.type = MSP_RGB32;
- } else if (subtype == MEDIASUBTYPE_RGB24) {
- m_spd.type = MSP_RGB24;
- } else if (subtype == MEDIASUBTYPE_RGB565) {
- m_spd.type = MSP_RGB16;
- } else if (subtype == MEDIASUBTYPE_RGB555) {
- m_spd.type = MSP_RGB15;
- }
- m_spd.w = m_w;
- m_spd.h = m_h;
- m_spd.bpp = (m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV) ? 8 : bihIn.biBitCount;
- m_spd.pitch = m_spd.w*m_spd.bpp>>3;
- m_spd.bits = (void*)m_pTempPicBuff;
-
- CComPtr<ISubPicAllocator> pSubPicAllocator = new CMemSubPicAllocator(m_spd.type, CSize(m_w, m_h));
-
- CSize video(bihIn.biWidth, bihIn.biHeight), window = video;
- if (AdjustFrameSize(window)) {
- video += video;
- }
- ASSERT(window == CSize(m_w, m_h));
-
- pSubPicAllocator->SetCurSize(window);
- pSubPicAllocator->SetCurVidRect(CRect(CPoint((window.cx - video.cx)/2, (window.cy - video.cy)/2), video));
-
- HRESULT hr = S_OK;
-
- m_pSubPicQueue = m_uSubPictToBuffer > 0
- ? (ISubPicQueue*)DNew CSubPicQueue(m_uSubPictToBuffer, !m_fAnimWhenBuffering, pSubPicAllocator, &hr)
- : (ISubPicQueue*)DNew CSubPicQueueNoThread(pSubPicAllocator, &hr);
-
- if (FAILED(hr)) {
- m_pSubPicQueue = NULL;
- }
-
- UpdateSubtitle(false);
-
- if (m_hbm) {
- DeleteObject(m_hbm);
- m_hbm = NULL;
- }
- if (m_hdc) {
- DeleteDC(m_hdc);
- m_hdc = NULL;
- }
-
- struct {
- BITMAPINFOHEADER bih;
- DWORD mask[3];
- } b = {{sizeof(BITMAPINFOHEADER), m_w, -(int)m_h, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0}, 0xFF0000, 0x00FF00, 0x0000FF};
- m_hdc = CreateCompatibleDC(NULL);
- m_hbm = CreateDIBSection(m_hdc, (BITMAPINFO*)&b, DIB_RGB_COLORS, NULL, NULL, 0);
-
- BITMAP bm;
- GetObject(m_hbm, sizeof(bm), &bm);
- memsetd(bm.bmBits, 0xFF000000, bm.bmHeight*bm.bmWidthBytes);
+ CAutoLock cAutoLock(&m_csQueueLock);
+
+ m_pSubPicQueue = NULL;
+
+ m_pTempPicBuff.Free();
+ m_pTempPicBuff.Allocate(4 * m_w * m_h);
+
+ const GUID& subtype = m_pInput->CurrentMediaType().subtype;
+
+ BITMAPINFOHEADER bihIn;
+ ExtractBIH(&m_pInput->CurrentMediaType(), &bihIn);
+
+ m_spd.type = -1;
+ if (subtype == MEDIASUBTYPE_YV12) {
+ m_spd.type = MSP_YV12;
+ } else if (subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV) {
+ m_spd.type = MSP_IYUV;
+ } else if (subtype == MEDIASUBTYPE_YUY2) {
+ m_spd.type = MSP_YUY2;
+ } else if (subtype == MEDIASUBTYPE_RGB32) {
+ m_spd.type = MSP_RGB32;
+ } else if (subtype == MEDIASUBTYPE_RGB24) {
+ m_spd.type = MSP_RGB24;
+ } else if (subtype == MEDIASUBTYPE_RGB565) {
+ m_spd.type = MSP_RGB16;
+ } else if (subtype == MEDIASUBTYPE_RGB555) {
+ m_spd.type = MSP_RGB15;
+ }
+ m_spd.w = m_w;
+ m_spd.h = m_h;
+ m_spd.bpp = (m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV) ? 8 : bihIn.biBitCount;
+ m_spd.pitch = m_spd.w * m_spd.bpp >> 3;
+ m_spd.bits = (void*)m_pTempPicBuff;
+
+ CComPtr<ISubPicAllocator> pSubPicAllocator = new CMemSubPicAllocator(m_spd.type, CSize(m_w, m_h));
+
+ CSize video(bihIn.biWidth, bihIn.biHeight), window = video;
+ if (AdjustFrameSize(window)) {
+ video += video;
+ }
+ ASSERT(window == CSize(m_w, m_h));
+
+ pSubPicAllocator->SetCurSize(window);
+ pSubPicAllocator->SetCurVidRect(CRect(CPoint((window.cx - video.cx) / 2, (window.cy - video.cy) / 2), video));
+
+ HRESULT hr = S_OK;
+
+ m_pSubPicQueue = m_uSubPictToBuffer > 0
+ ? (ISubPicQueue*)DNew CSubPicQueue(m_uSubPictToBuffer, !m_fAnimWhenBuffering, pSubPicAllocator, &hr)
+ : (ISubPicQueue*)DNew CSubPicQueueNoThread(pSubPicAllocator, &hr);
+
+ if (FAILED(hr)) {
+ m_pSubPicQueue = NULL;
+ }
+
+ UpdateSubtitle(false);
+
+ if (m_hbm) {
+ DeleteObject(m_hbm);
+ m_hbm = NULL;
+ }
+ if (m_hdc) {
+ DeleteDC(m_hdc);
+ m_hdc = NULL;
+ }
+
+ struct {
+ BITMAPINFOHEADER bih;
+ DWORD mask[3];
+ } b = {{sizeof(BITMAPINFOHEADER), m_w, -(int)m_h, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0}, 0xFF0000, 0x00FF00, 0x0000FF};
+ m_hdc = CreateCompatibleDC(NULL);
+ m_hbm = CreateDIBSection(m_hdc, (BITMAPINFO*)&b, DIB_RGB_COLORS, NULL, NULL, 0);
+
+ BITMAP bm;
+ GetObject(m_hbm, sizeof(bm), &bm);
+ memsetd(bm.bmBits, 0xFF000000, bm.bmHeight * bm.bmWidthBytes);
}
bool CDirectVobSubFilter::AdjustFrameSize(CSize& s)
{
- int horizontal, vertical, resx2, resx2minw, resx2minh;
- get_ExtendPicture(&horizontal, &vertical, &resx2, &resx2minw, &resx2minh);
-
- bool fRet = (resx2 == 1) || (resx2 == 2 && s.cx*s.cy <= resx2minw*resx2minh);
-
- if (fRet) {
- s.cx <<= 1;
- s.cy <<= 1;
- }
-
- int h;
- switch (vertical&0x7f) {
- case 1:
- h = s.cx * 9 / 16;
- if (s.cy < h || !!(vertical&0x80)) {
- s.cy = (h + 3) & ~3;
- }
- break;
- case 2:
- h = s.cx * 3 / 4;
- if (s.cy < h || !!(vertical&0x80)) {
- s.cy = (h + 3) & ~3;
- }
- break;
- case 3:
- h = 480;
- if (s.cy < h || !!(vertical&0x80)) {
- s.cy = (h + 3) & ~3;
- }
- break;
- case 4:
- h = 576;
- if (s.cy < h || !!(vertical&0x80)) {
- s.cy = (h + 3) & ~3;
- }
- break;
- }
-
- if (horizontal == 1) {
- s.cx = (s.cx + 31) & ~31;
- s.cy = (s.cy + 1) & ~1;
- }
-
- return fRet;
+ int horizontal, vertical, resx2, resx2minw, resx2minh;
+ get_ExtendPicture(&horizontal, &vertical, &resx2, &resx2minw, &resx2minh);
+
+ bool fRet = (resx2 == 1) || (resx2 == 2 && s.cx * s.cy <= resx2minw * resx2minh);
+
+ if (fRet) {
+ s.cx <<= 1;
+ s.cy <<= 1;
+ }
+
+ int h;
+ switch (vertical & 0x7f) {
+ case 1:
+ h = s.cx * 9 / 16;
+ if (s.cy < h || !!(vertical & 0x80)) {
+ s.cy = (h + 3) & ~3;
+ }
+ break;
+ case 2:
+ h = s.cx * 3 / 4;
+ if (s.cy < h || !!(vertical & 0x80)) {
+ s.cy = (h + 3) & ~3;
+ }
+ break;
+ case 3:
+ h = 480;
+ if (s.cy < h || !!(vertical & 0x80)) {
+ s.cy = (h + 3) & ~3;
+ }
+ break;
+ case 4:
+ h = 576;
+ if (s.cy < h || !!(vertical & 0x80)) {
+ s.cy = (h + 3) & ~3;
+ }
+ break;
+ }
+
+ if (horizontal == 1) {
+ s.cx = (s.cx + 31) & ~31;
+ s.cy = (s.cy + 1) & ~1;
+ }
+
+ return fRet;
}
STDMETHODIMP CDirectVobSubFilter::Count(DWORD* pcStreams)
{
- if (!pcStreams) {
- return E_POINTER;
- }
+ if (!pcStreams) {
+ return E_POINTER;
+ }
- *pcStreams = 0;
+ *pcStreams = 0;
- int nLangs = 0;
- if (SUCCEEDED(get_LanguageCount(&nLangs))) {
- (*pcStreams) += nLangs;
- }
+ int nLangs = 0;
+ if (SUCCEEDED(get_LanguageCount(&nLangs))) {
+ (*pcStreams) += nLangs;
+ }
- (*pcStreams) += 2; // enable ... disable
+ (*pcStreams) += 2; // enable ... disable
- (*pcStreams) += 2; // normal flipped
+ (*pcStreams) += 2; // normal flipped
- return S_OK;
+ return S_OK;
}
#define MAXPREFLANGS 5
int CDirectVobSubFilter::FindPreferedLanguage(bool fHideToo)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
- int nLangs;
- get_LanguageCount(&nLangs);
+ int nLangs;
+ get_LanguageCount(&nLangs);
- if (nLangs <= 0) {
- return 0;
- }
+ if (nLangs <= 0) {
+ return 0;
+ }
- for (ptrdiff_t i = 0; i < MAXPREFLANGS; i++) {
- CString tmp;
- tmp.Format(IDS_RL_LANG, i);
+ for (ptrdiff_t i = 0; i < MAXPREFLANGS; i++) {
+ CString tmp;
+ tmp.Format(IDS_RL_LANG, i);
- CString lang = theApp.GetProfileString(ResStr(IDS_R_PREFLANGS), tmp);
+ CString lang = theApp.GetProfileString(ResStr(IDS_R_PREFLANGS), tmp);
- if (!lang.IsEmpty()) {
- for (int ret = 0; ret < nLangs; ret++) {
- CString l;
- WCHAR* pName = NULL;
- get_LanguageName(ret, &pName);
- l = pName;
- CoTaskMemFree(pName);
+ if (!lang.IsEmpty()) {
+ for (int ret = 0; ret < nLangs; ret++) {
+ CString l;
+ WCHAR* pName = NULL;
+ get_LanguageName(ret, &pName);
+ l = pName;
+ CoTaskMemFree(pName);
- if (!l.CompareNoCase(lang)) {
- return ret;
- }
- }
- }
- }
+ if (!l.CompareNoCase(lang)) {
+ return ret;
+ }
+ }
+ }
+ }
- return 0;
+ return 0;
}
void CDirectVobSubFilter::UpdatePreferedLanguages(CString l)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- CString langs[MAXPREFLANGS+1];
-
- int i = 0, j = 0, k = -1;
- for (; i < MAXPREFLANGS; i++) {
- CString tmp;
- tmp.Format(IDS_RL_LANG, i);
-
- langs[j] = theApp.GetProfileString(ResStr(IDS_R_PREFLANGS), tmp);
-
- if (!langs[j].IsEmpty()) {
- if (!langs[j].CompareNoCase(l)) {
- k = j;
- }
- j++;
- }
- }
-
- if (k == -1) {
- langs[k = j] = l;
- j++;
- }
-
- // move the selected to the top of the list
-
- while (k > 0) {
- CString tmp = langs[k];
- langs[k] = langs[k-1];
- langs[k-1] = tmp;
- k--;
- }
-
- // move "Hide subtitles" to the last position if it wasn't our selection
-
- CString hidesubs;
- hidesubs.LoadString(IDS_M_HIDESUBTITLES);
-
- for (k = 1; k < j; k++) {
- if (!langs[k].CompareNoCase(hidesubs)) {
- break;
- }
- }
-
- while (k < j-1) {
- CString tmp = langs[k];
- langs[k] = langs[k+1];
- langs[k+1] = tmp;
- k++;
- }
-
- for (i = 0; i < j; i++) {
- CString tmp;
- tmp.Format(IDS_RL_LANG, i);
-
- theApp.WriteProfileString(ResStr(IDS_R_PREFLANGS), tmp, langs[i]);
- }
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ CString langs[MAXPREFLANGS + 1];
+
+ int i = 0, j = 0, k = -1;
+ for (; i < MAXPREFLANGS; i++) {
+ CString tmp;
+ tmp.Format(IDS_RL_LANG, i);
+
+ langs[j] = theApp.GetProfileString(ResStr(IDS_R_PREFLANGS), tmp);
+
+ if (!langs[j].IsEmpty()) {
+ if (!langs[j].CompareNoCase(l)) {
+ k = j;
+ }
+ j++;
+ }
+ }
+
+ if (k == -1) {
+ langs[k = j] = l;
+ j++;
+ }
+
+ // move the selected to the top of the list
+
+ while (k > 0) {
+ CString tmp = langs[k];
+ langs[k] = langs[k - 1];
+ langs[k - 1] = tmp;
+ k--;
+ }
+
+ // move "Hide subtitles" to the last position if it wasn't our selection
+
+ CString hidesubs;
+ hidesubs.LoadString(IDS_M_HIDESUBTITLES);
+
+ for (k = 1; k < j; k++) {
+ if (!langs[k].CompareNoCase(hidesubs)) {
+ break;
+ }
+ }
+
+ while (k < j - 1) {
+ CString tmp = langs[k];
+ langs[k] = langs[k + 1];
+ langs[k + 1] = tmp;
+ k++;
+ }
+
+ for (i = 0; i < j; i++) {
+ CString tmp;
+ tmp.Format(IDS_RL_LANG, i);
+
+ theApp.WriteProfileString(ResStr(IDS_R_PREFLANGS), tmp, langs[i]);
+ }
}
STDMETHODIMP CDirectVobSubFilter::Enable(long lIndex, DWORD dwFlags)
{
- if (!(dwFlags & AMSTREAMSELECTENABLE_ENABLE)) {
- return E_NOTIMPL;
- }
-
- int nLangs = 0;
- get_LanguageCount(&nLangs);
-
- if (!(lIndex >= 0 && lIndex < nLangs+2+2)) {
- return E_INVALIDARG;
- }
-
- int i = lIndex-1;
-
- if (i == -1 && !m_fLoading) { // we need this because when loading something stupid media player pushes the first stream it founds, which is "enable" in our case
- put_HideSubtitles(false);
- } else if (i >= 0 && i < nLangs) {
- put_HideSubtitles(false);
- put_SelectedLanguage(i);
-
- WCHAR* pName = NULL;
- if (SUCCEEDED(get_LanguageName(i, &pName))) {
- UpdatePreferedLanguages(CString(pName));
- if (pName) {
- CoTaskMemFree(pName);
- }
- }
- } else if (i == nLangs && !m_fLoading) {
- put_HideSubtitles(true);
- } else if ((i == nLangs+1 || i == nLangs+2) && !m_fLoading) {
- put_Flip(i == nLangs+2, m_fFlipSubtitles);
- }
-
- return S_OK;
+ if (!(dwFlags & AMSTREAMSELECTENABLE_ENABLE)) {
+ return E_NOTIMPL;
+ }
+
+ int nLangs = 0;
+ get_LanguageCount(&nLangs);
+
+ if (!(lIndex >= 0 && lIndex < nLangs + 2 + 2)) {
+ return E_INVALIDARG;
+ }
+
+ int i = lIndex - 1;
+
+ if (i == -1 && !m_fLoading) { // we need this because when loading something stupid media player pushes the first stream it founds, which is "enable" in our case
+ put_HideSubtitles(false);
+ } else if (i >= 0 && i < nLangs) {
+ put_HideSubtitles(false);
+ put_SelectedLanguage(i);
+
+ WCHAR* pName = NULL;
+ if (SUCCEEDED(get_LanguageName(i, &pName))) {
+ UpdatePreferedLanguages(CString(pName));
+ if (pName) {
+ CoTaskMemFree(pName);
+ }
+ }
+ } else if (i == nLangs && !m_fLoading) {
+ put_HideSubtitles(true);
+ } else if ((i == nLangs + 1 || i == nLangs + 2) && !m_fLoading) {
+ put_Flip(i == nLangs + 2, m_fFlipSubtitles);
+ }
+
+ return S_OK;
}
STDMETHODIMP CDirectVobSubFilter::Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* pdwFlags, LCID* plcid, DWORD* pdwGroup, WCHAR** ppszName, IUnknown** ppObject, IUnknown** ppUnk)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- int nLangs = 0;
- get_LanguageCount(&nLangs);
-
- if (!(lIndex >= 0 && lIndex < nLangs+2+2)) {
- return E_INVALIDARG;
- }
-
- int i = lIndex-1;
-
- if (ppmt) {
- *ppmt = CreateMediaType(&m_pInput->CurrentMediaType());
- }
-
- if (pdwFlags) {
- *pdwFlags = 0;
-
- if (i == -1 && !m_fHideSubtitles
- || i >= 0 && i < nLangs && i == m_iSelectedLanguage
- || i == nLangs && m_fHideSubtitles
- || i == nLangs+1 && !m_fFlipPicture
- || i == nLangs+2 && m_fFlipPicture) {
- *pdwFlags |= AMSTREAMSELECTINFO_ENABLED;
- }
- }
-
- if (plcid) {
- *plcid = 0;
- }
-
- if (pdwGroup) {
- *pdwGroup = 0x648E51;
- }
-
- if (ppszName) {
- *ppszName = NULL;
-
- CStringW str;
- if (i == -1) {
- str.LoadString(IDS_M_SHOWSUBTITLES);
- } else if (i >= 0 && i < nLangs) {
- get_LanguageName(i, ppszName);
- } else if (i == nLangs) {
- str.LoadString(IDS_M_HIDESUBTITLES);
- } else if (i == nLangs+1) {
- str.LoadString(IDS_M_ORIGINALPICTURE);
- if (pdwGroup) {
- (*pdwGroup)++;
- }
- } else if (i == nLangs+2) {
- str.LoadString(IDS_M_FLIPPEDPICTURE);
- if (pdwGroup) {
- (*pdwGroup)++;
- }
- }
-
- if (!str.IsEmpty()) {
- *ppszName = (WCHAR*)CoTaskMemAlloc((str.GetLength()+1)*sizeof(WCHAR));
- if (*ppszName == NULL) {
- return S_FALSE;
- }
- wcscpy_s(*ppszName, str.GetLength() + 1, str);
- }
- }
-
- if (ppObject) {
- *ppObject = NULL;
- }
-
- if (ppUnk) {
- *ppUnk = NULL;
- }
-
- return S_OK;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ int nLangs = 0;
+ get_LanguageCount(&nLangs);
+
+ if (!(lIndex >= 0 && lIndex < nLangs + 2 + 2)) {
+ return E_INVALIDARG;
+ }
+
+ int i = lIndex - 1;
+
+ if (ppmt) {
+ *ppmt = CreateMediaType(&m_pInput->CurrentMediaType());
+ }
+
+ if (pdwFlags) {
+ *pdwFlags = 0;
+
+ if (i == -1 && !m_fHideSubtitles
+ || i >= 0 && i < nLangs && i == m_iSelectedLanguage
+ || i == nLangs && m_fHideSubtitles
+ || i == nLangs + 1 && !m_fFlipPicture
+ || i == nLangs + 2 && m_fFlipPicture) {
+ *pdwFlags |= AMSTREAMSELECTINFO_ENABLED;
+ }
+ }
+
+ if (plcid) {
+ *plcid = 0;
+ }
+
+ if (pdwGroup) {
+ *pdwGroup = 0x648E51;
+ }
+
+ if (ppszName) {
+ *ppszName = NULL;
+
+ CStringW str;
+ if (i == -1) {
+ str.LoadString(IDS_M_SHOWSUBTITLES);
+ } else if (i >= 0 && i < nLangs) {
+ get_LanguageName(i, ppszName);
+ } else if (i == nLangs) {
+ str.LoadString(IDS_M_HIDESUBTITLES);
+ } else if (i == nLangs + 1) {
+ str.LoadString(IDS_M_ORIGINALPICTURE);
+ if (pdwGroup) {
+ (*pdwGroup)++;
+ }
+ } else if (i == nLangs + 2) {
+ str.LoadString(IDS_M_FLIPPEDPICTURE);
+ if (pdwGroup) {
+ (*pdwGroup)++;
+ }
+ }
+
+ if (!str.IsEmpty()) {
+ *ppszName = (WCHAR*)CoTaskMemAlloc((str.GetLength() + 1) * sizeof(WCHAR));
+ if (*ppszName == NULL) {
+ return S_FALSE;
+ }
+ wcscpy_s(*ppszName, str.GetLength() + 1, str);
+ }
+ }
+
+ if (ppObject) {
+ *ppObject = NULL;
+ }
+
+ if (ppUnk) {
+ *ppUnk = NULL;
+ }
+
+ return S_OK;
}
STDMETHODIMP CDirectVobSubFilter::GetClassID(CLSID* pClsid)
{
- if (pClsid == NULL) {
- return E_POINTER;
- }
- *pClsid = m_clsid;
- return NOERROR;
+ if (pClsid == NULL) {
+ return E_POINTER;
+ }
+ *pClsid = m_clsid;
+ return NOERROR;
}
STDMETHODIMP CDirectVobSubFilter::GetPages(CAUUID* pPages)
{
- CheckPointer(pPages, E_POINTER);
+ CheckPointer(pPages, E_POINTER);
- pPages->cElems = 7;
- pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID)*pPages->cElems);
+ pPages->cElems = 7;
+ pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID) * pPages->cElems);
- if (pPages->pElems == NULL) {
- return E_OUTOFMEMORY;
- }
+ if (pPages->pElems == NULL) {
+ return E_OUTOFMEMORY;
+ }
- int i = 0;
- pPages->pElems[i++] = __uuidof(CDVSMainPPage);
- pPages->pElems[i++] = __uuidof(CDVSGeneralPPage);
- pPages->pElems[i++] = __uuidof(CDVSMiscPPage);
- pPages->pElems[i++] = __uuidof(CDVSTimingPPage);
- pPages->pElems[i++] = __uuidof(CDVSColorPPage);
- pPages->pElems[i++] = __uuidof(CDVSPathsPPage);
- pPages->pElems[i++] = __uuidof(CDVSAboutPPage);
+ int i = 0;
+ pPages->pElems[i++] = __uuidof(CDVSMainPPage);
+ pPages->pElems[i++] = __uuidof(CDVSGeneralPPage);
+ pPages->pElems[i++] = __uuidof(CDVSMiscPPage);
+ pPages->pElems[i++] = __uuidof(CDVSTimingPPage);
+ pPages->pElems[i++] = __uuidof(CDVSColorPPage);
+ pPages->pElems[i++] = __uuidof(CDVSPathsPPage);
+ pPages->pElems[i++] = __uuidof(CDVSAboutPPage);
- return NOERROR;
+ return NOERROR;
}
// IDirectVobSub
STDMETHODIMP CDirectVobSubFilter::put_FileName(WCHAR* fn)
{
- HRESULT hr = CDirectVobSub::put_FileName(fn);
+ HRESULT hr = CDirectVobSub::put_FileName(fn);
- if (hr == S_OK && !Open()) {
- m_FileName.Empty();
- hr = E_FAIL;
- }
+ if (hr == S_OK && !Open()) {
+ m_FileName.Empty();
+ hr = E_FAIL;
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CDirectVobSubFilter::get_LanguageCount(int* nLangs)
{
- HRESULT hr = CDirectVobSub::get_LanguageCount(nLangs);
+ HRESULT hr = CDirectVobSub::get_LanguageCount(nLangs);
- if (hr == NOERROR && nLangs) {
- CAutoLock cAutolock(&m_csQueueLock);
+ if (hr == NOERROR && nLangs) {
+ CAutoLock cAutolock(&m_csQueueLock);
- *nLangs = 0;
- POSITION pos = m_pSubStreams.GetHeadPosition();
- while (pos) {
- (*nLangs) += m_pSubStreams.GetNext(pos)->GetStreamCount();
- }
- }
+ *nLangs = 0;
+ POSITION pos = m_pSubStreams.GetHeadPosition();
+ while (pos) {
+ (*nLangs) += m_pSubStreams.GetNext(pos)->GetStreamCount();
+ }
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CDirectVobSubFilter::get_LanguageName(int iLanguage, WCHAR** ppName)
{
- HRESULT hr = CDirectVobSub::get_LanguageName(iLanguage, ppName);
+ HRESULT hr = CDirectVobSub::get_LanguageName(iLanguage, ppName);
- if (!ppName) {
- return E_POINTER;
- }
+ if (!ppName) {
+ return E_POINTER;
+ }
- if (hr == NOERROR) {
- CAutoLock cAutolock(&m_csQueueLock);
+ if (hr == NOERROR) {
+ CAutoLock cAutolock(&m_csQueueLock);
- hr = E_INVALIDARG;
+ hr = E_INVALIDARG;
- int i = iLanguage;
+ int i = iLanguage;
- POSITION pos = m_pSubStreams.GetHeadPosition();
- while (i >= 0 && pos) {
- CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
+ POSITION pos = m_pSubStreams.GetHeadPosition();
+ while (i >= 0 && pos) {
+ CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
- if (i < pSubStream->GetStreamCount()) {
- pSubStream->GetStreamInfo(i, ppName, NULL);
- hr = NOERROR;
- break;
- }
+ if (i < pSubStream->GetStreamCount()) {
+ pSubStream->GetStreamInfo(i, ppName, NULL);
+ hr = NOERROR;
+ break;
+ }
- i -= pSubStream->GetStreamCount();
- }
- }
+ i -= pSubStream->GetStreamCount();
+ }
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CDirectVobSubFilter::put_SelectedLanguage(int iSelected)
{
- HRESULT hr = CDirectVobSub::put_SelectedLanguage(iSelected);
+ HRESULT hr = CDirectVobSub::put_SelectedLanguage(iSelected);
- if (hr == NOERROR) {
- UpdateSubtitle(false);
- }
+ if (hr == NOERROR) {
+ UpdateSubtitle(false);
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CDirectVobSubFilter::put_HideSubtitles(bool fHideSubtitles)
{
- HRESULT hr = CDirectVobSub::put_HideSubtitles(fHideSubtitles);
+ HRESULT hr = CDirectVobSub::put_HideSubtitles(fHideSubtitles);
- if (hr == NOERROR) {
- UpdateSubtitle(false);
- }
+ if (hr == NOERROR) {
+ UpdateSubtitle(false);
+ }
- return hr;
+ return hr;
}
// deprecated
STDMETHODIMP CDirectVobSubFilter::put_PreBuffering(bool fDoPreBuffering)
{
- HRESULT hr = CDirectVobSub::put_PreBuffering(fDoPreBuffering);
+ HRESULT hr = CDirectVobSub::put_PreBuffering(fDoPreBuffering);
- if (hr == NOERROR && m_pInput && m_pInput->IsConnected()) {
- InitSubPicQueue();
- }
+ if (hr == NOERROR && m_pInput && m_pInput->IsConnected()) {
+ InitSubPicQueue();
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CDirectVobSubFilter::put_SubPictToBuffer(unsigned int uSubPictToBuffer)
{
- HRESULT hr = CDirectVobSub::put_SubPictToBuffer(uSubPictToBuffer);
+ HRESULT hr = CDirectVobSub::put_SubPictToBuffer(uSubPictToBuffer);
- if (hr == NOERROR && m_pInput && m_pInput->IsConnected()) {
- InitSubPicQueue();
- }
+ if (hr == NOERROR && m_pInput && m_pInput->IsConnected()) {
+ InitSubPicQueue();
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CDirectVobSubFilter::put_AnimWhenBuffering(bool fAnimWhenBuffering)
{
- HRESULT hr = CDirectVobSub::put_AnimWhenBuffering(fAnimWhenBuffering);
+ HRESULT hr = CDirectVobSub::put_AnimWhenBuffering(fAnimWhenBuffering);
- if (hr == NOERROR && m_pInput && m_pInput->IsConnected()) {
- InitSubPicQueue();
- }
+ if (hr == NOERROR && m_pInput && m_pInput->IsConnected()) {
+ InitSubPicQueue();
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CDirectVobSubFilter::put_Placement(bool fOverridePlacement, int xperc, int yperc)
{
- HRESULT hr = CDirectVobSub::put_Placement(fOverridePlacement, xperc, yperc);
+ HRESULT hr = CDirectVobSub::put_Placement(fOverridePlacement, xperc, yperc);
- if (hr == NOERROR) {
- UpdateSubtitle(true);
- }
+ if (hr == NOERROR) {
+ UpdateSubtitle(true);
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CDirectVobSubFilter::put_VobSubSettings(bool fBuffer, bool fOnlyShowForcedSubs, bool fReserved)
{
- HRESULT hr = CDirectVobSub::put_VobSubSettings(fBuffer, fOnlyShowForcedSubs, fReserved);
+ HRESULT hr = CDirectVobSub::put_VobSubSettings(fBuffer, fOnlyShowForcedSubs, fReserved);
- if (hr == NOERROR) {
- // UpdateSubtitle(false);
- InvalidateSubtitle();
- }
+ if (hr == NOERROR) {
+ // UpdateSubtitle(false);
+ InvalidateSubtitle();
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CDirectVobSubFilter::put_TextSettings(void* lf, int lflen, COLORREF color, bool fShadow, bool fOutline, bool fAdvancedRenderer)
{
- HRESULT hr = CDirectVobSub::put_TextSettings(lf, lflen, color, fShadow, fOutline, fAdvancedRenderer);
+ HRESULT hr = CDirectVobSub::put_TextSettings(lf, lflen, color, fShadow, fOutline, fAdvancedRenderer);
- if (hr == NOERROR) {
- // UpdateSubtitle(true);
- InvalidateSubtitle();
- }
+ if (hr == NOERROR) {
+ // UpdateSubtitle(true);
+ InvalidateSubtitle();
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CDirectVobSubFilter::put_SubtitleTiming(int delay, int speedmul, int speeddiv)
{
- HRESULT hr = CDirectVobSub::put_SubtitleTiming(delay, speedmul, speeddiv);
+ HRESULT hr = CDirectVobSub::put_SubtitleTiming(delay, speedmul, speeddiv);
- if (hr == NOERROR) {
- InvalidateSubtitle();
- }
+ if (hr == NOERROR) {
+ InvalidateSubtitle();
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CDirectVobSubFilter::get_MediaFPS(bool* fEnabled, double* fps)
{
- HRESULT hr = CDirectVobSub::get_MediaFPS(fEnabled, fps);
-
- CComQIPtr<IMediaSeeking> pMS = m_pGraph;
- double rate;
- if (pMS && SUCCEEDED(pMS->GetRate(&rate))) {
- m_MediaFPS = rate * m_fps;
- if (fps) {
- *fps = m_MediaFPS;
- }
- }
-
- return hr;
+ HRESULT hr = CDirectVobSub::get_MediaFPS(fEnabled, fps);
+
+ CComQIPtr<IMediaSeeking> pMS = m_pGraph;
+ double rate;
+ if (pMS && SUCCEEDED(pMS->GetRate(&rate))) {
+ m_MediaFPS = rate * m_fps;
+ if (fps) {
+ *fps = m_MediaFPS;
+ }
+ }
+
+ return hr;
}
STDMETHODIMP CDirectVobSubFilter::put_MediaFPS(bool fEnabled, double fps)
{
- HRESULT hr = CDirectVobSub::put_MediaFPS(fEnabled, fps);
+ HRESULT hr = CDirectVobSub::put_MediaFPS(fEnabled, fps);
- CComQIPtr<IMediaSeeking> pMS = m_pGraph;
- if (pMS) {
- if (hr == NOERROR) {
- hr = pMS->SetRate(m_fMediaFPSEnabled ? m_MediaFPS / m_fps : 1.0);
- }
+ CComQIPtr<IMediaSeeking> pMS = m_pGraph;
+ if (pMS) {
+ if (hr == NOERROR) {
+ hr = pMS->SetRate(m_fMediaFPSEnabled ? m_MediaFPS / m_fps : 1.0);
+ }
- double dRate;
- if (SUCCEEDED(pMS->GetRate(&dRate))) {
- m_MediaFPS = dRate * m_fps;
- }
- }
+ double dRate;
+ if (SUCCEEDED(pMS->GetRate(&dRate))) {
+ m_MediaFPS = dRate * m_fps;
+ }
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CDirectVobSubFilter::get_ZoomRect(NORMALIZEDRECT* rect)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CDirectVobSubFilter::put_ZoomRect(NORMALIZEDRECT* rect)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IDirectVobSub2
STDMETHODIMP CDirectVobSubFilter::put_TextSettings(STSStyle* pDefStyle)
{
- HRESULT hr = CDirectVobSub::put_TextSettings(pDefStyle);
+ HRESULT hr = CDirectVobSub::put_TextSettings(pDefStyle);
- if (hr == NOERROR) {
- UpdateSubtitle(true);
- }
+ if (hr == NOERROR) {
+ UpdateSubtitle(true);
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CDirectVobSubFilter::put_AspectRatioSettings(CSimpleTextSubtitle::EPARCompensationType* ePARCompensationType)
{
- HRESULT hr = CDirectVobSub::put_AspectRatioSettings(ePARCompensationType);
+ HRESULT hr = CDirectVobSub::put_AspectRatioSettings(ePARCompensationType);
- if (hr == NOERROR) {
- UpdateSubtitle(true);
- }
+ if (hr == NOERROR) {
+ UpdateSubtitle(true);
+ }
- return hr;
+ return hr;
}
// IDirectVobSubFilterColor
STDMETHODIMP CDirectVobSubFilter::HasConfigDialog(int iSelected)
{
- int nLangs;
- if (FAILED(get_LanguageCount(&nLangs))) {
- return E_FAIL;
- }
- return E_FAIL;
- // TODO: temporally disabled since we don't have a new textsub/vobsub editor dlg for dvs yet
- // return (nLangs >= 0 && iSelected < nLangs ? S_OK : E_FAIL);
+ int nLangs;
+ if (FAILED(get_LanguageCount(&nLangs))) {
+ return E_FAIL;
+ }
+ return E_FAIL;
+ // TODO: temporally disabled since we don't have a new textsub/vobsub editor dlg for dvs yet
+ // return (nLangs >= 0 && iSelected < nLangs ? S_OK : E_FAIL);
}
STDMETHODIMP CDirectVobSubFilter::ShowConfigDialog(int iSelected, HWND hWndParent)
{
- // TODO: temporally disabled since we don't have a new textsub/vobsub editor dlg for dvs yet
- return E_FAIL;
+ // TODO: temporally disabled since we don't have a new textsub/vobsub editor dlg for dvs yet
+ return E_FAIL;
}
///////////////////////////////////////////////////////////////////////////
CDirectVobSubFilter2::CDirectVobSubFilter2(LPUNKNOWN punk, HRESULT* phr, const GUID& clsid) :
- CDirectVobSubFilter(punk, phr, clsid)
+ CDirectVobSubFilter(punk, phr, clsid)
{
}
HRESULT CDirectVobSubFilter2::CheckConnect(PIN_DIRECTION dir, IPin* pPin)
{
- CPinInfo pi;
- if (FAILED(pPin->QueryPinInfo(&pi))) {
- return E_FAIL;
- }
-
- if (CComQIPtr<IDirectVobSub>(pi.pFilter)) {
- return E_FAIL;
- }
-
- if (dir == PINDIR_INPUT) {
- CFilterInfo fi;
- if (SUCCEEDED(pi.pFilter->QueryFilterInfo(&fi))
- && !_wcsnicmp(fi.achName, L"Overlay Mixer", 13)) {
- return E_FAIL;
- }
- } else {
- }
-
- return __super::CheckConnect(dir, pPin);
+ CPinInfo pi;
+ if (FAILED(pPin->QueryPinInfo(&pi))) {
+ return E_FAIL;
+ }
+
+ if (CComQIPtr<IDirectVobSub>(pi.pFilter)) {
+ return E_FAIL;
+ }
+
+ if (dir == PINDIR_INPUT) {
+ CFilterInfo fi;
+ if (SUCCEEDED(pi.pFilter->QueryFilterInfo(&fi))
+ && !_wcsnicmp(fi.achName, L"Overlay Mixer", 13)) {
+ return E_FAIL;
+ }
+ } else {
+ }
+
+ return __super::CheckConnect(dir, pPin);
}
HRESULT CDirectVobSubFilter2::JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pName)
{
- if (pGraph) {
- BeginEnumFilters(pGraph, pEF, pBF) {
- if (pBF != (IBaseFilter*)this && CComQIPtr<IDirectVobSub>(pBF)) {
- return E_FAIL;
- }
- }
- EndEnumFilters
-
- // don't look... we will do some serious graph hacking again...
- //
- // we will add dvs2 to the filter graph cache
- // - if the main app has already added some kind of renderer or overlay mixer (anything which accepts video on its input)
- // and
- // - if we have a reason to auto-load (we don't want to make any trouble when there is no need :)
- //
- // This whole workaround is needed because the video stream will always be connected
- // to the pre-added filters first, no matter how high merit we have.
-
- if (!get_Forced()) {
- BeginEnumFilters(pGraph, pEF, pBF) {
- if (CComQIPtr<IDirectVobSub>(pBF)) {
- continue;
- }
-
- CComPtr<IPin> pInPin = GetFirstPin(pBF, PINDIR_INPUT);
- CComPtr<IPin> pOutPin = GetFirstPin(pBF, PINDIR_OUTPUT);
-
- if (!pInPin) {
- continue;
- }
-
- CComPtr<IPin> pPin;
- if (pInPin && SUCCEEDED(pInPin->ConnectedTo(&pPin))
- || pOutPin && SUCCEEDED(pOutPin->ConnectedTo(&pPin))) {
- continue;
- }
-
- if (pOutPin && GetFilterName(pBF) == _T("Overlay Mixer")) {
- continue;
- }
-
- bool fVideoInputPin = false;
-
- do {
- BITMAPINFOHEADER bih = {sizeof(BITMAPINFOHEADER), 384, 288, 1, 16, '2YUY', 384*288*2, 0, 0, 0, 0};
-
- CMediaType cmt;
- cmt.majortype = MEDIATYPE_Video;
- cmt.subtype = MEDIASUBTYPE_YUY2;
- cmt.formattype = FORMAT_VideoInfo;
- cmt.pUnk = NULL;
- cmt.bFixedSizeSamples = TRUE;
- cmt.bTemporalCompression = TRUE;
- cmt.lSampleSize = 384*288*2;
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)cmt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
- memset(vih, 0, sizeof(VIDEOINFOHEADER));
- memcpy(&vih->bmiHeader, &bih, sizeof(bih));
- vih->AvgTimePerFrame = 400000;
-
- if (SUCCEEDED(pInPin->QueryAccept(&cmt))) {
- fVideoInputPin = true;
- break;
- }
-
- VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)cmt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER2));
- memset(vih2, 0, sizeof(VIDEOINFOHEADER2));
- memcpy(&vih2->bmiHeader, &bih, sizeof(bih));
- vih2->AvgTimePerFrame = 400000;
- vih2->dwPictAspectRatioX = 384;
- vih2->dwPictAspectRatioY = 288;
-
- if (SUCCEEDED(pInPin->QueryAccept(&cmt))) {
- fVideoInputPin = true;
- break;
- }
- } while (false);
-
- if (fVideoInputPin) {
- CComPtr<IBaseFilter> pDVS;
- if (ShouldWeAutoload(pGraph) && SUCCEEDED(pDVS.CoCreateInstance(__uuidof(CDirectVobSubFilter2)))) {
- CComQIPtr<IDirectVobSub2>(pDVS)->put_Forced(true);
- CComQIPtr<IGraphConfig>(pGraph)->AddFilterToCache(pDVS);
- }
-
- break;
- }
- }
- EndEnumFilters
- }
- } else {
- }
-
- return __super::JoinFilterGraph(pGraph, pName);
+ if (pGraph) {
+ BeginEnumFilters(pGraph, pEF, pBF) {
+ if (pBF != (IBaseFilter*)this && CComQIPtr<IDirectVobSub>(pBF)) {
+ return E_FAIL;
+ }
+ }
+ EndEnumFilters
+
+ // don't look... we will do some serious graph hacking again...
+ //
+ // we will add dvs2 to the filter graph cache
+ // - if the main app has already added some kind of renderer or overlay mixer (anything which accepts video on its input)
+ // and
+ // - if we have a reason to auto-load (we don't want to make any trouble when there is no need :)
+ //
+ // This whole workaround is needed because the video stream will always be connected
+ // to the pre-added filters first, no matter how high merit we have.
+
+ if (!get_Forced()) {
+ BeginEnumFilters(pGraph, pEF, pBF) {
+ if (CComQIPtr<IDirectVobSub>(pBF)) {
+ continue;
+ }
+
+ CComPtr<IPin> pInPin = GetFirstPin(pBF, PINDIR_INPUT);
+ CComPtr<IPin> pOutPin = GetFirstPin(pBF, PINDIR_OUTPUT);
+
+ if (!pInPin) {
+ continue;
+ }
+
+ CComPtr<IPin> pPin;
+ if (pInPin && SUCCEEDED(pInPin->ConnectedTo(&pPin))
+ || pOutPin && SUCCEEDED(pOutPin->ConnectedTo(&pPin))) {
+ continue;
+ }
+
+ if (pOutPin && GetFilterName(pBF) == _T("Overlay Mixer")) {
+ continue;
+ }
+
+ bool fVideoInputPin = false;
+
+ do {
+ BITMAPINFOHEADER bih = {sizeof(BITMAPINFOHEADER), 384, 288, 1, 16, '2YUY', 384 * 288 * 2, 0, 0, 0, 0};
+
+ CMediaType cmt;
+ cmt.majortype = MEDIATYPE_Video;
+ cmt.subtype = MEDIASUBTYPE_YUY2;
+ cmt.formattype = FORMAT_VideoInfo;
+ cmt.pUnk = NULL;
+ cmt.bFixedSizeSamples = TRUE;
+ cmt.bTemporalCompression = TRUE;
+ cmt.lSampleSize = 384 * 288 * 2;
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)cmt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
+ memset(vih, 0, sizeof(VIDEOINFOHEADER));
+ memcpy(&vih->bmiHeader, &bih, sizeof(bih));
+ vih->AvgTimePerFrame = 400000;
+
+ if (SUCCEEDED(pInPin->QueryAccept(&cmt))) {
+ fVideoInputPin = true;
+ break;
+ }
+
+ VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)cmt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER2));
+ memset(vih2, 0, sizeof(VIDEOINFOHEADER2));
+ memcpy(&vih2->bmiHeader, &bih, sizeof(bih));
+ vih2->AvgTimePerFrame = 400000;
+ vih2->dwPictAspectRatioX = 384;
+ vih2->dwPictAspectRatioY = 288;
+
+ if (SUCCEEDED(pInPin->QueryAccept(&cmt))) {
+ fVideoInputPin = true;
+ break;
+ }
+ } while (false);
+
+ if (fVideoInputPin) {
+ CComPtr<IBaseFilter> pDVS;
+ if (ShouldWeAutoload(pGraph) && SUCCEEDED(pDVS.CoCreateInstance(__uuidof(CDirectVobSubFilter2)))) {
+ CComQIPtr<IDirectVobSub2>(pDVS)->put_Forced(true);
+ CComQIPtr<IGraphConfig>(pGraph)->AddFilterToCache(pDVS);
+ }
+
+ break;
+ }
+ }
+ EndEnumFilters
+ }
+ } else {
+ }
+
+ return __super::JoinFilterGraph(pGraph, pName);
}
HRESULT CDirectVobSubFilter2::CheckInputType(const CMediaType* mtIn)
{
- HRESULT hr = __super::CheckInputType(mtIn);
+ HRESULT hr = __super::CheckInputType(mtIn);
- if (FAILED(hr) || m_pInput->IsConnected()) {
- return hr;
- }
+ if (FAILED(hr) || m_pInput->IsConnected()) {
+ return hr;
+ }
- if (!ShouldWeAutoload(m_pGraph)) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
+ if (!ShouldWeAutoload(m_pGraph)) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
- GetRidOfInternalScriptRenderer();
+ GetRidOfInternalScriptRenderer();
- return NOERROR;
+ return NOERROR;
}
bool CDirectVobSubFilter2::ShouldWeAutoload(IFilterGraph* pGraph)
{
- TCHAR blacklistedapps[][32] = {
- _T("WM8EUTIL."), // wmp8 encoder's dummy renderer releases the outputted media sample after calling Receive on its input pin (yes, even when dvobsub isn't registered at all)
- _T("explorer."), // as some users reported thumbnail preview loads dvobsub, I've never experienced this yet...
- _T("producer."), // this is real's producer
- _T("GoogleDesktopIndex."), // Google Desktop
- _T("GoogleDesktopDisplay."), // Google Desktop
- _T("GoogleDesktopCrawl."), // Google Desktop
- };
-
- for (ptrdiff_t i = 0; i < _countof(blacklistedapps); i++) {
- if (theApp.m_AppName.Find(blacklistedapps[i]) >= 0) {
- return false;
- }
- }
-
- int level;
- bool m_fExternalLoad, m_fWebLoad, m_fEmbeddedLoad;
- get_LoadSettings(&level, &m_fExternalLoad, &m_fWebLoad, &m_fEmbeddedLoad);
-
- if (level < 0 || level >= 2) {
- return false;
- }
-
- bool fRet = false;
-
- if (level == 1) {
- fRet = m_fExternalLoad = m_fWebLoad = m_fEmbeddedLoad = true;
- }
-
- // find text stream on known splitters
-
- if (!fRet && m_fEmbeddedLoad) {
- CComPtr<IBaseFilter> pBF;
- if ((pBF = FindFilter(CLSID_OggSplitter, pGraph)) || (pBF = FindFilter(CLSID_AviSplitter, pGraph))
- || (pBF = FindFilter(L"{34293064-02F2-41D5-9D75-CC5967ACA1AB}", pGraph)) // matroska demux
- || (pBF = FindFilter(L"{0A68C3B5-9164-4a54-AFAF-995B2FF0E0D4}", pGraph)) // matroska source
- || (pBF = FindFilter(L"{149D2E01-C32E-4939-80F6-C07B81015A7A}", pGraph)) // matroska splitter
- || (pBF = FindFilter(L"{55DA30FC-F16B-49fc-BAA5-AE59FC65F82D}", pGraph)) // Haali's matroska splitter
- || (pBF = FindFilter(L"{564FD788-86C9-4444-971E-CC4A243DA150}", pGraph)) // Haali's matroska splitter (AR)
- || (pBF = FindFilter(L"{171252A0-8820-4AFE-9DF8-5C92B2D66B04}", pGraph)) // LAV Splitter
- || (pBF = FindFilter(L"{B98D13E7-55DB-4385-A33D-09FD1BA26338}", pGraph)) // LAV Splitter Source
- || (pBF = FindFilter(L"{E436EBB5-524F-11CE-9F53-0020AF0BA770}", pGraph)) // Solveig matroska splitter
- || (pBF = FindFilter(L"{52B63861-DC93-11CE-A099-00AA00479A58}", pGraph)) // 3ivx splitter
- || (pBF = FindFilter(L"{6D3688CE-3E9D-42F4-92CA-8A11119D25CD}", pGraph)) // our ogg source
- || (pBF = FindFilter(L"{9FF48807-E133-40AA-826F-9B2959E5232D}", pGraph)) // our ogg splitter
- || (pBF = FindFilter(L"{803E8280-F3CE-4201-982C-8CD8FB512004}", pGraph)) // dsm source
- || (pBF = FindFilter(L"{0912B4DD-A30A-4568-B590-7179EBB420EC}", pGraph)) // dsm splitter
- || (pBF = FindFilter(L"{3CCC052E-BDEE-408a-BEA7-90914EF2964B}", pGraph)) // mp4 source
- || (pBF = FindFilter(L"{61F47056-E400-43d3-AF1E-AB7DFFD4C4AD}", pGraph))) { // mp4 splitter
- BeginEnumPins(pBF, pEP, pPin) {
- BeginEnumMediaTypes(pPin, pEM, pmt) {
- if (pmt->majortype == MEDIATYPE_Text || pmt->majortype == MEDIATYPE_Subtitle) {
- fRet = true;
- break;
- }
- }
- EndEnumMediaTypes(pmt)
- if (fRet) {
- break;
- }
- }
- EndEnumFilters
- }
- }
-
- // find file name
-
- CStringW fn;
-
- BeginEnumFilters(pGraph, pEF, pBF) {
- if (CComQIPtr<IFileSourceFilter> pFSF = pBF) {
- LPOLESTR fnw = NULL;
- if (!pFSF || FAILED(pFSF->GetCurFile(&fnw, NULL)) || !fnw) {
- continue;
- }
- fn = CString(fnw);
- CoTaskMemFree(fnw);
- break;
- }
- }
- EndEnumFilters
-
- if ((m_fExternalLoad || m_fWebLoad) && (m_fWebLoad || !(wcsstr(fn, L"http://") || wcsstr(fn, L"mms://")))) {
- bool fTemp = m_fHideSubtitles;
- fRet = !fn.IsEmpty() && SUCCEEDED(put_FileName((LPWSTR)(LPCWSTR)fn))
- || SUCCEEDED(put_FileName(L"c:\\tmp.srt"))
- || fRet;
- if (fTemp) {
- m_fHideSubtitles = true;
- }
- }
-
- return fRet;
+ TCHAR blacklistedapps[][32] = {
+ _T("WM8EUTIL."), // wmp8 encoder's dummy renderer releases the outputted media sample after calling Receive on its input pin (yes, even when dvobsub isn't registered at all)
+ _T("explorer."), // as some users reported thumbnail preview loads dvobsub, I've never experienced this yet...
+ _T("producer."), // this is real's producer
+ _T("GoogleDesktopIndex."), // Google Desktop
+ _T("GoogleDesktopDisplay."), // Google Desktop
+ _T("GoogleDesktopCrawl."), // Google Desktop
+ };
+
+ for (ptrdiff_t i = 0; i < _countof(blacklistedapps); i++) {
+ if (theApp.m_AppName.Find(blacklistedapps[i]) >= 0) {
+ return false;
+ }
+ }
+
+ int level;
+ bool m_fExternalLoad, m_fWebLoad, m_fEmbeddedLoad;
+ get_LoadSettings(&level, &m_fExternalLoad, &m_fWebLoad, &m_fEmbeddedLoad);
+
+ if (level < 0 || level >= 2) {
+ return false;
+ }
+
+ bool fRet = false;
+
+ if (level == 1) {
+ fRet = m_fExternalLoad = m_fWebLoad = m_fEmbeddedLoad = true;
+ }
+
+ // find text stream on known splitters
+
+ if (!fRet && m_fEmbeddedLoad) {
+ CComPtr<IBaseFilter> pBF;
+ if ((pBF = FindFilter(CLSID_OggSplitter, pGraph)) || (pBF = FindFilter(CLSID_AviSplitter, pGraph))
+ || (pBF = FindFilter(L"{34293064-02F2-41D5-9D75-CC5967ACA1AB}", pGraph)) // matroska demux
+ || (pBF = FindFilter(L"{0A68C3B5-9164-4a54-AFAF-995B2FF0E0D4}", pGraph)) // matroska source
+ || (pBF = FindFilter(L"{149D2E01-C32E-4939-80F6-C07B81015A7A}", pGraph)) // matroska splitter
+ || (pBF = FindFilter(L"{55DA30FC-F16B-49fc-BAA5-AE59FC65F82D}", pGraph)) // Haali's matroska splitter
+ || (pBF = FindFilter(L"{564FD788-86C9-4444-971E-CC4A243DA150}", pGraph)) // Haali's matroska splitter (AR)
+ || (pBF = FindFilter(L"{171252A0-8820-4AFE-9DF8-5C92B2D66B04}", pGraph)) // LAV Splitter
+ || (pBF = FindFilter(L"{B98D13E7-55DB-4385-A33D-09FD1BA26338}", pGraph)) // LAV Splitter Source
+ || (pBF = FindFilter(L"{E436EBB5-524F-11CE-9F53-0020AF0BA770}", pGraph)) // Solveig matroska splitter
+ || (pBF = FindFilter(L"{52B63861-DC93-11CE-A099-00AA00479A58}", pGraph)) // 3ivx splitter
+ || (pBF = FindFilter(L"{6D3688CE-3E9D-42F4-92CA-8A11119D25CD}", pGraph)) // our ogg source
+ || (pBF = FindFilter(L"{9FF48807-E133-40AA-826F-9B2959E5232D}", pGraph)) // our ogg splitter
+ || (pBF = FindFilter(L"{803E8280-F3CE-4201-982C-8CD8FB512004}", pGraph)) // dsm source
+ || (pBF = FindFilter(L"{0912B4DD-A30A-4568-B590-7179EBB420EC}", pGraph)) // dsm splitter
+ || (pBF = FindFilter(L"{3CCC052E-BDEE-408a-BEA7-90914EF2964B}", pGraph)) // mp4 source
+ || (pBF = FindFilter(L"{61F47056-E400-43d3-AF1E-AB7DFFD4C4AD}", pGraph))) { // mp4 splitter
+ BeginEnumPins(pBF, pEP, pPin) {
+ BeginEnumMediaTypes(pPin, pEM, pmt) {
+ if (pmt->majortype == MEDIATYPE_Text || pmt->majortype == MEDIATYPE_Subtitle) {
+ fRet = true;
+ break;
+ }
+ }
+ EndEnumMediaTypes(pmt)
+ if (fRet) {
+ break;
+ }
+ }
+ EndEnumFilters
+ }
+ }
+
+ // find file name
+
+ CStringW fn;
+
+ BeginEnumFilters(pGraph, pEF, pBF) {
+ if (CComQIPtr<IFileSourceFilter> pFSF = pBF) {
+ LPOLESTR fnw = NULL;
+ if (!pFSF || FAILED(pFSF->GetCurFile(&fnw, NULL)) || !fnw) {
+ continue;
+ }
+ fn = CString(fnw);
+ CoTaskMemFree(fnw);
+ break;
+ }
+ }
+ EndEnumFilters
+
+ if ((m_fExternalLoad || m_fWebLoad) && (m_fWebLoad || !(wcsstr(fn, L"http://") || wcsstr(fn, L"mms://")))) {
+ bool fTemp = m_fHideSubtitles;
+ fRet = !fn.IsEmpty() && SUCCEEDED(put_FileName((LPWSTR)(LPCWSTR)fn))
+ || SUCCEEDED(put_FileName(L"c:\\tmp.srt"))
+ || fRet;
+ if (fTemp) {
+ m_fHideSubtitles = true;
+ }
+ }
+
+ return fRet;
}
void CDirectVobSubFilter2::GetRidOfInternalScriptRenderer()
{
- while (CComPtr<IBaseFilter> pBF = FindFilter(L"{48025243-2D39-11CE-875D-00608CB78066}", m_pGraph)) {
- BeginEnumPins(pBF, pEP, pPin) {
- PIN_DIRECTION dir;
- CComPtr<IPin> pPinTo;
-
- if (SUCCEEDED(pPin->QueryDirection(&dir)) && dir == PINDIR_INPUT
- && SUCCEEDED(pPin->ConnectedTo(&pPinTo))) {
- m_pGraph->Disconnect(pPinTo);
- m_pGraph->Disconnect(pPin);
- m_pGraph->ConnectDirect(pPinTo, GetPin(2 + m_pTextInput.GetCount()-1), NULL);
- }
- }
- EndEnumPins
-
- if (FAILED(m_pGraph->RemoveFilter(pBF))) {
- break;
- }
- }
+ while (CComPtr<IBaseFilter> pBF = FindFilter(L"{48025243-2D39-11CE-875D-00608CB78066}", m_pGraph)) {
+ BeginEnumPins(pBF, pEP, pPin) {
+ PIN_DIRECTION dir;
+ CComPtr<IPin> pPinTo;
+
+ if (SUCCEEDED(pPin->QueryDirection(&dir)) && dir == PINDIR_INPUT
+ && SUCCEEDED(pPin->ConnectedTo(&pPinTo))) {
+ m_pGraph->Disconnect(pPinTo);
+ m_pGraph->Disconnect(pPin);
+ m_pGraph->ConnectDirect(pPinTo, GetPin(2 + m_pTextInput.GetCount() - 1), NULL);
+ }
+ }
+ EndEnumPins
+
+ if (FAILED(m_pGraph->RemoveFilter(pBF))) {
+ break;
+ }
+ }
}
///////////////////////////////////////////////////////////////////////////////
bool CDirectVobSubFilter::Open()
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- CAutoLock cAutolock(&m_csQueueLock);
-
- m_pSubStreams.RemoveAll();
-
- m_frd.files.RemoveAll();
-
- CAtlArray<CString> paths;
-
- for (ptrdiff_t i = 0; i < 10; i++) {
- CString tmp;
- tmp.Format(IDS_RP_PATH, i);
- CString path = theApp.GetProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp);
- if (!path.IsEmpty()) {
- paths.Add(path);
- }
- }
-
- CAtlArray<SubFile> ret;
- GetSubFileNames(m_FileName, paths, ret);
-
- for (size_t i = 0; i < ret.GetCount(); i++) {
- if (m_frd.files.Find(ret[i].fn)) {
- continue;
- }
-
- CComPtr<ISubStream> pSubStream;
-
- if (!pSubStream) {
- CAutoPtr<CVobSubFile> pVSF(DNew CVobSubFile(&m_csSubLock));
- if (pVSF && pVSF->Open(ret[i].fn) && pVSF->GetStreamCount() > 0) {
- pSubStream = pVSF.Detach();
- m_frd.files.AddTail(ret[i].fn.Left(ret[i].fn.GetLength()-4) + _T(".sub"));
- }
- }
-
- if (!pSubStream) {
- CAutoPtr<CRenderedTextSubtitle> pRTS(DNew CRenderedTextSubtitle(&m_csSubLock));
- if (pRTS && pRTS->Open(ret[i].fn, DEFAULT_CHARSET) && pRTS->GetStreamCount() > 0) {
- pSubStream = pRTS.Detach();
- m_frd.files.AddTail(ret[i].fn + _T(".style"));
- }
- }
-
- if (pSubStream) {
- m_pSubStreams.AddTail(pSubStream);
- m_frd.files.AddTail(ret[i].fn);
- }
- }
-
- for (size_t i = 0; i < m_pTextInput.GetCount(); i++) {
- if (m_pTextInput[i]->IsConnected()) {
- m_pSubStreams.AddTail(m_pTextInput[i]->GetSubStream());
- }
- }
-
- if (S_FALSE == put_SelectedLanguage(FindPreferedLanguage())) {
- UpdateSubtitle(false); // make sure pSubPicProvider of our queue gets updated even if the stream number hasn't changed
- }
-
- m_frd.RefreshEvent.Set();
-
- return (m_pSubStreams.GetCount() > 0);
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ CAutoLock cAutolock(&m_csQueueLock);
+
+ m_pSubStreams.RemoveAll();
+
+ m_frd.files.RemoveAll();
+
+ CAtlArray<CString> paths;
+
+ for (ptrdiff_t i = 0; i < 10; i++) {
+ CString tmp;
+ tmp.Format(IDS_RP_PATH, i);
+ CString path = theApp.GetProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp);
+ if (!path.IsEmpty()) {
+ paths.Add(path);
+ }
+ }
+
+ CAtlArray<SubFile> ret;
+ GetSubFileNames(m_FileName, paths, ret);
+
+ for (size_t i = 0; i < ret.GetCount(); i++) {
+ if (m_frd.files.Find(ret[i].fn)) {
+ continue;
+ }
+
+ CComPtr<ISubStream> pSubStream;
+
+ if (!pSubStream) {
+ CAutoPtr<CVobSubFile> pVSF(DNew CVobSubFile(&m_csSubLock));
+ if (pVSF && pVSF->Open(ret[i].fn) && pVSF->GetStreamCount() > 0) {
+ pSubStream = pVSF.Detach();
+ m_frd.files.AddTail(ret[i].fn.Left(ret[i].fn.GetLength() - 4) + _T(".sub"));
+ }
+ }
+
+ if (!pSubStream) {
+ CAutoPtr<CRenderedTextSubtitle> pRTS(DNew CRenderedTextSubtitle(&m_csSubLock));
+ if (pRTS && pRTS->Open(ret[i].fn, DEFAULT_CHARSET) && pRTS->GetStreamCount() > 0) {
+ pSubStream = pRTS.Detach();
+ m_frd.files.AddTail(ret[i].fn + _T(".style"));
+ }
+ }
+
+ if (pSubStream) {
+ m_pSubStreams.AddTail(pSubStream);
+ m_frd.files.AddTail(ret[i].fn);
+ }
+ }
+
+ for (size_t i = 0; i < m_pTextInput.GetCount(); i++) {
+ if (m_pTextInput[i]->IsConnected()) {
+ m_pSubStreams.AddTail(m_pTextInput[i]->GetSubStream());
+ }
+ }
+
+ if (S_FALSE == put_SelectedLanguage(FindPreferedLanguage())) {
+ UpdateSubtitle(false); // make sure pSubPicProvider of our queue gets updated even if the stream number hasn't changed
+ }
+
+ m_frd.RefreshEvent.Set();
+
+ return (m_pSubStreams.GetCount() > 0);
}
void CDirectVobSubFilter::UpdateSubtitle(bool fApplyDefStyle)
{
- CAutoLock cAutolock(&m_csQueueLock);
+ CAutoLock cAutolock(&m_csQueueLock);
- if (!m_pSubPicQueue) {
- return;
- }
+ if (!m_pSubPicQueue) {
+ return;
+ }
- InvalidateSubtitle();
+ InvalidateSubtitle();
- CComPtr<ISubStream> pSubStream;
+ CComPtr<ISubStream> pSubStream;
- if (!m_fHideSubtitles) {
- int i = m_iSelectedLanguage;
+ if (!m_fHideSubtitles) {
+ int i = m_iSelectedLanguage;
- for (POSITION pos = m_pSubStreams.GetHeadPosition(); i >= 0 && pos; pSubStream = NULL) {
- pSubStream = m_pSubStreams.GetNext(pos);
+ for (POSITION pos = m_pSubStreams.GetHeadPosition(); i >= 0 && pos; pSubStream = NULL) {
+ pSubStream = m_pSubStreams.GetNext(pos);
- if (i < pSubStream->GetStreamCount()) {
- CAutoLock cAutoLock(&m_csSubLock);
- pSubStream->SetStream(i);
- break;
- }
+ if (i < pSubStream->GetStreamCount()) {
+ CAutoLock cAutoLock(&m_csSubLock);
+ pSubStream->SetStream(i);
+ break;
+ }
- i -= pSubStream->GetStreamCount();
- }
- }
+ i -= pSubStream->GetStreamCount();
+ }
+ }
- SetSubtitle(pSubStream, fApplyDefStyle);
+ SetSubtitle(pSubStream, fApplyDefStyle);
}
void CDirectVobSubFilter::SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyle)
{
- CAutoLock cAutolock(&m_csQueueLock);
-
- if (pSubStream) {
- CAutoLock cAutolock(&m_csSubLock);
-
- CLSID clsid;
- pSubStream->GetClassID(&clsid);
-
- if (clsid == __uuidof(CVobSubFile)) {
- CVobSubSettings* pVSS = (CVobSubFile*)(ISubStream*)pSubStream;
-
- if (fApplyDefStyle) {
- pVSS->SetAlignment(m_fOverridePlacement, m_PlacementXperc, m_PlacementYperc, 1, 1);
- pVSS->m_fOnlyShowForcedSubs = m_fOnlyShowForcedVobSubs;
- }
- } else if (clsid == __uuidof(CVobSubStream)) {
- CVobSubSettings* pVSS = (CVobSubStream*)(ISubStream*)pSubStream;
-
- if (fApplyDefStyle) {
- pVSS->SetAlignment(m_fOverridePlacement, m_PlacementXperc, m_PlacementYperc, 1, 1);
- pVSS->m_fOnlyShowForcedSubs = m_fOnlyShowForcedVobSubs;
- }
- } else if (clsid == __uuidof(CRenderedTextSubtitle)) {
- CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)pSubStream;
-
- if (fApplyDefStyle || pRTS->m_fUsingAutoGeneratedDefaultStyle) {
- STSStyle s = m_defStyle;
-
- if (m_fOverridePlacement) {
- s.scrAlignment = 2;
- int w = pRTS->m_dstScreenSize.cx;
- int h = pRTS->m_dstScreenSize.cy;
- int mw = w - s.marginRect.left - s.marginRect.right;
- s.marginRect.bottom = h - MulDiv(h, m_PlacementYperc, 100);
- s.marginRect.left = MulDiv(w, m_PlacementXperc, 100) - mw/2;
- s.marginRect.right = w - (s.marginRect.left + mw);
- }
-
- pRTS->SetDefaultStyle(s);
- }
-
- pRTS->m_ePARCompensationType = m_ePARCompensationType;
- if (m_CurrentVIH2.dwPictAspectRatioX != 0 && m_CurrentVIH2.dwPictAspectRatioY != 0&& m_CurrentVIH2.bmiHeader.biWidth != 0 && m_CurrentVIH2.bmiHeader.biHeight != 0) {
- pRTS->m_dPARCompensation = ((double)abs(m_CurrentVIH2.bmiHeader.biWidth) / (double)abs(m_CurrentVIH2.bmiHeader.biHeight)) /
- ((double)abs((long)m_CurrentVIH2.dwPictAspectRatioX) / (double)abs((long)m_CurrentVIH2.dwPictAspectRatioY));
-
- } else {
- pRTS->m_dPARCompensation = 1.00;
- }
-
- pRTS->Deinit();
- }
- }
-
- if (!fApplyDefStyle) {
- int i = 0;
-
- POSITION pos = m_pSubStreams.GetHeadPosition();
- while (pos) {
- CComPtr<ISubStream> pSubStream2 = m_pSubStreams.GetNext(pos);
-
- if (pSubStream == pSubStream2) {
- m_iSelectedLanguage = i + pSubStream2->GetStream();
- break;
- }
-
- i += pSubStream2->GetStreamCount();
- }
- }
-
- m_nSubtitleId = (DWORD_PTR)pSubStream;
-
- if (m_pSubPicQueue) {
- m_pSubPicQueue->SetSubPicProvider(CComQIPtr<ISubPicProvider>(pSubStream));
- }
+ CAutoLock cAutolock(&m_csQueueLock);
+
+ if (pSubStream) {
+ CAutoLock cAutolock(&m_csSubLock);
+
+ CLSID clsid;
+ pSubStream->GetClassID(&clsid);
+
+ if (clsid == __uuidof(CVobSubFile)) {
+ CVobSubSettings* pVSS = (CVobSubFile*)(ISubStream*)pSubStream;
+
+ if (fApplyDefStyle) {
+ pVSS->SetAlignment(m_fOverridePlacement, m_PlacementXperc, m_PlacementYperc, 1, 1);
+ pVSS->m_fOnlyShowForcedSubs = m_fOnlyShowForcedVobSubs;
+ }
+ } else if (clsid == __uuidof(CVobSubStream)) {
+ CVobSubSettings* pVSS = (CVobSubStream*)(ISubStream*)pSubStream;
+
+ if (fApplyDefStyle) {
+ pVSS->SetAlignment(m_fOverridePlacement, m_PlacementXperc, m_PlacementYperc, 1, 1);
+ pVSS->m_fOnlyShowForcedSubs = m_fOnlyShowForcedVobSubs;
+ }
+ } else if (clsid == __uuidof(CRenderedTextSubtitle)) {
+ CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)pSubStream;
+
+ if (fApplyDefStyle || pRTS->m_fUsingAutoGeneratedDefaultStyle) {
+ STSStyle s = m_defStyle;
+
+ if (m_fOverridePlacement) {
+ s.scrAlignment = 2;
+ int w = pRTS->m_dstScreenSize.cx;
+ int h = pRTS->m_dstScreenSize.cy;
+ int mw = w - s.marginRect.left - s.marginRect.right;
+ s.marginRect.bottom = h - MulDiv(h, m_PlacementYperc, 100);
+ s.marginRect.left = MulDiv(w, m_PlacementXperc, 100) - mw / 2;
+ s.marginRect.right = w - (s.marginRect.left + mw);
+ }
+
+ pRTS->SetDefaultStyle(s);
+ }
+
+ pRTS->m_ePARCompensationType = m_ePARCompensationType;
+ if (m_CurrentVIH2.dwPictAspectRatioX != 0 && m_CurrentVIH2.dwPictAspectRatioY != 0 && m_CurrentVIH2.bmiHeader.biWidth != 0 && m_CurrentVIH2.bmiHeader.biHeight != 0) {
+ pRTS->m_dPARCompensation = ((double)abs(m_CurrentVIH2.bmiHeader.biWidth) / (double)abs(m_CurrentVIH2.bmiHeader.biHeight)) /
+ ((double)abs((long)m_CurrentVIH2.dwPictAspectRatioX) / (double)abs((long)m_CurrentVIH2.dwPictAspectRatioY));
+
+ } else {
+ pRTS->m_dPARCompensation = 1.00;
+ }
+
+ pRTS->Deinit();
+ }
+ }
+
+ if (!fApplyDefStyle) {
+ int i = 0;
+
+ POSITION pos = m_pSubStreams.GetHeadPosition();
+ while (pos) {
+ CComPtr<ISubStream> pSubStream2 = m_pSubStreams.GetNext(pos);
+
+ if (pSubStream == pSubStream2) {
+ m_iSelectedLanguage = i + pSubStream2->GetStream();
+ break;
+ }
+
+ i += pSubStream2->GetStreamCount();
+ }
+ }
+
+ m_nSubtitleId = (DWORD_PTR)pSubStream;
+
+ if (m_pSubPicQueue) {
+ m_pSubPicQueue->SetSubPicProvider(CComQIPtr<ISubPicProvider>(pSubStream));
+ }
}
void CDirectVobSubFilter::InvalidateSubtitle(REFERENCE_TIME rtInvalidate, DWORD_PTR nSubtitleId)
{
- CAutoLock cAutolock(&m_csQueueLock);
+ CAutoLock cAutolock(&m_csQueueLock);
- if (m_pSubPicQueue) {
- if (nSubtitleId == -1 || nSubtitleId == m_nSubtitleId) {
- m_pSubPicQueue->Invalidate(rtInvalidate);
- }
- }
+ if (m_pSubPicQueue) {
+ if (nSubtitleId == -1 || nSubtitleId == m_nSubtitleId) {
+ m_pSubPicQueue->Invalidate(rtInvalidate);
+ }
+ }
}
//////////////////////////////////////////////////////////////////////////////////////////
void CDirectVobSubFilter::AddSubStream(ISubStream* pSubStream)
{
- CAutoLock cAutoLock(&m_csQueueLock);
-
- POSITION pos = m_pSubStreams.Find(pSubStream);
- if (!pos) {
- m_pSubStreams.AddTail(pSubStream);
- }
-
- size_t len = m_pTextInput.GetCount();
- for (size_t i = 0; i < m_pTextInput.GetCount(); i++)
- if (m_pTextInput[i]->IsConnected()) {
- len--;
- }
-
- if (len == 0) {
- HRESULT hr = S_OK;
- m_pTextInput.Add(DNew CTextInputPin(this, m_pLock, &m_csSubLock, &hr));
- }
+ CAutoLock cAutoLock(&m_csQueueLock);
+
+ POSITION pos = m_pSubStreams.Find(pSubStream);
+ if (!pos) {
+ m_pSubStreams.AddTail(pSubStream);
+ }
+
+ size_t len = m_pTextInput.GetCount();
+ for (size_t i = 0; i < m_pTextInput.GetCount(); i++)
+ if (m_pTextInput[i]->IsConnected()) {
+ len--;
+ }
+
+ if (len == 0) {
+ HRESULT hr = S_OK;
+ m_pTextInput.Add(DNew CTextInputPin(this, m_pLock, &m_csSubLock, &hr));
+ }
}
void CDirectVobSubFilter::RemoveSubStream(ISubStream* pSubStream)
{
- CAutoLock cAutoLock(&m_csQueueLock);
+ CAutoLock cAutoLock(&m_csQueueLock);
- POSITION pos = m_pSubStreams.Find(pSubStream);
- if (pos) {
- m_pSubStreams.RemoveAt(pos);
- }
+ POSITION pos = m_pSubStreams.Find(pSubStream);
+ if (pos) {
+ m_pSubStreams.RemoveAt(pos);
+ }
}
void CDirectVobSubFilter::Post_EC_OLE_EVENT(CString str, DWORD_PTR nSubtitleId)
{
- if (nSubtitleId != -1 && nSubtitleId != m_nSubtitleId) {
- return;
- }
+ if (nSubtitleId != -1 && nSubtitleId != m_nSubtitleId) {
+ return;
+ }
- CComQIPtr<IMediaEventSink> pMES = m_pGraph;
- if (!pMES) {
- return;
- }
+ CComQIPtr<IMediaEventSink> pMES = m_pGraph;
+ if (!pMES) {
+ return;
+ }
- CComBSTR bstr1("Text"), bstr2(" ");
+ CComBSTR bstr1("Text"), bstr2(" ");
- str.Trim();
- if (!str.IsEmpty()) {
- bstr2 = CStringA(str);
- }
+ str.Trim();
+ if (!str.IsEmpty()) {
+ bstr2 = CStringA(str);
+ }
- pMES->Notify(EC_OLE_EVENT, (LONG_PTR)bstr1.Detach(), (LONG_PTR)bstr2.Detach());
+ pMES->Notify(EC_OLE_EVENT, (LONG_PTR)bstr1.Detach(), (LONG_PTR)bstr2.Detach());
}
////////////////////////////////////////////////////////////////
void CDirectVobSubFilter::SetupFRD(CStringArray& paths, CAtlArray<HANDLE>& handles)
{
- CAutoLock cAutolock(&m_csSubLock);
+ CAutoLock cAutolock(&m_csSubLock);
- for (size_t i = 2; i < handles.GetCount(); i++) {
- FindCloseChangeNotification(handles[i]);
- }
+ for (size_t i = 2; i < handles.GetCount(); i++) {
+ FindCloseChangeNotification(handles[i]);
+ }
- paths.RemoveAll();
- handles.RemoveAll();
+ paths.RemoveAll();
+ handles.RemoveAll();
- handles.Add(m_frd.EndThreadEvent);
- handles.Add(m_frd.RefreshEvent);
+ handles.Add(m_frd.EndThreadEvent);
+ handles.Add(m_frd.RefreshEvent);
- m_frd.mtime.SetCount(m_frd.files.GetCount());
+ m_frd.mtime.SetCount(m_frd.files.GetCount());
- POSITION pos = m_frd.files.GetHeadPosition();
- for (ptrdiff_t i = 0; pos; i++) {
- CString fn = m_frd.files.GetNext(pos);
+ POSITION pos = m_frd.files.GetHeadPosition();
+ for (ptrdiff_t i = 0; pos; i++) {
+ CString fn = m_frd.files.GetNext(pos);
- CFileStatus status;
- if (CFileGetStatus(fn, status)) {
- m_frd.mtime[i] = status.m_mtime;
- }
+ CFileStatus status;
+ if (CFileGetStatus(fn, status)) {
+ m_frd.mtime[i] = status.m_mtime;
+ }
- fn.Replace('\\', '/');
- fn = fn.Left(fn.ReverseFind('/')+1);
+ fn.Replace('\\', '/');
+ fn = fn.Left(fn.ReverseFind('/') + 1);
- bool fFound = false;
+ bool fFound = false;
- for (ptrdiff_t j = 0; !fFound && j < paths.GetCount(); j++) {
- if (paths[j] == fn) {
- fFound = true;
- }
- }
+ for (ptrdiff_t j = 0; !fFound && j < paths.GetCount(); j++) {
+ if (paths[j] == fn) {
+ fFound = true;
+ }
+ }
- if (!fFound) {
- paths.Add(fn);
+ if (!fFound) {
+ paths.Add(fn);
- HANDLE h = FindFirstChangeNotification(fn, FALSE, FILE_NOTIFY_CHANGE_LAST_WRITE);
- if (h != INVALID_HANDLE_VALUE) {
- handles.Add(h);
- }
- }
- }
+ HANDLE h = FindFirstChangeNotification(fn, FALSE, FILE_NOTIFY_CHANGE_LAST_WRITE);
+ if (h != INVALID_HANDLE_VALUE) {
+ handles.Add(h);
+ }
+ }
+ }
}
DWORD CDirectVobSubFilter::ThreadProc()
{
- SetThreadPriority(m_hThread, THREAD_PRIORITY_LOWEST/*THREAD_PRIORITY_BELOW_NORMAL*/);
-
- CStringArray paths;
- CAtlArray<HANDLE> handles;
-
- SetupFRD(paths, handles);
-
- for (;;) {
- DWORD idx = WaitForMultipleObjects(handles.GetCount(), handles.GetData(), FALSE, INFINITE);
-
- if (idx == (WAIT_OBJECT_0 + 0)) { // m_frd.hEndThreadEvent
- break;
- }
- if (idx == (WAIT_OBJECT_0 + 1)) { // m_frd.hRefreshEvent
- SetupFRD(paths, handles);
- } else if (idx >= (WAIT_OBJECT_0 + 2) && idx < (WAIT_OBJECT_0 + handles.GetCount())) {
- bool fLocked = true;
- IsSubtitleReloaderLocked(&fLocked);
- if (fLocked) {
- continue;
- }
-
- if (FindNextChangeNotification(handles[idx - WAIT_OBJECT_0]) == FALSE) {
- break;
- }
-
- int j = 0;
-
- POSITION pos = m_frd.files.GetHeadPosition();
- for (ptrdiff_t i = 0; pos && j == 0; i++) {
- CString fn = m_frd.files.GetNext(pos);
-
- CFileStatus status;
- if (CFileGetStatus(fn, status) && m_frd.mtime[i] != status.m_mtime) {
- for (j = 0; j < 10; j++) {
- FILE* f = NULL;
- if (!_tfopen_s(&f, fn, _T("rb+"))) {
- fclose(f);
- j = 0;
- break;
- } else {
- Sleep(100);
- j++;
- }
- }
- }
- }
-
- if (j > 0) {
- SetupFRD(paths, handles);
- } else {
- Sleep(500);
-
- POSITION pos = m_frd.files.GetHeadPosition();
- for (ptrdiff_t i = 0; pos; i++) {
- CFileStatus status;
- if (CFileGetStatus(m_frd.files.GetNext(pos), status)
- && m_frd.mtime[i] != status.m_mtime) {
- Open();
- SetupFRD(paths, handles);
- break;
- }
- }
- }
- } else {
- break;
- }
- }
-
- for (size_t i = 2; i < handles.GetCount(); i++) {
- FindCloseChangeNotification(handles[i]);
- }
-
- return 0;
+ SetThreadPriority(m_hThread, THREAD_PRIORITY_LOWEST/*THREAD_PRIORITY_BELOW_NORMAL*/);
+
+ CStringArray paths;
+ CAtlArray<HANDLE> handles;
+
+ SetupFRD(paths, handles);
+
+ for (;;) {
+ DWORD idx = WaitForMultipleObjects(handles.GetCount(), handles.GetData(), FALSE, INFINITE);
+
+ if (idx == (WAIT_OBJECT_0 + 0)) { // m_frd.hEndThreadEvent
+ break;
+ }
+ if (idx == (WAIT_OBJECT_0 + 1)) { // m_frd.hRefreshEvent
+ SetupFRD(paths, handles);
+ } else if (idx >= (WAIT_OBJECT_0 + 2) && idx < (WAIT_OBJECT_0 + handles.GetCount())) {
+ bool fLocked = true;
+ IsSubtitleReloaderLocked(&fLocked);
+ if (fLocked) {
+ continue;
+ }
+
+ if (FindNextChangeNotification(handles[idx - WAIT_OBJECT_0]) == FALSE) {
+ break;
+ }
+
+ int j = 0;
+
+ POSITION pos = m_frd.files.GetHeadPosition();
+ for (ptrdiff_t i = 0; pos && j == 0; i++) {
+ CString fn = m_frd.files.GetNext(pos);
+
+ CFileStatus status;
+ if (CFileGetStatus(fn, status) && m_frd.mtime[i] != status.m_mtime) {
+ for (j = 0; j < 10; j++) {
+ FILE* f = NULL;
+ if (!_tfopen_s(&f, fn, _T("rb+"))) {
+ fclose(f);
+ j = 0;
+ break;
+ } else {
+ Sleep(100);
+ j++;
+ }
+ }
+ }
+ }
+
+ if (j > 0) {
+ SetupFRD(paths, handles);
+ } else {
+ Sleep(500);
+
+ POSITION pos = m_frd.files.GetHeadPosition();
+ for (ptrdiff_t i = 0; pos; i++) {
+ CFileStatus status;
+ if (CFileGetStatus(m_frd.files.GetNext(pos), status)
+ && m_frd.mtime[i] != status.m_mtime) {
+ Open();
+ SetupFRD(paths, handles);
+ break;
+ }
+ }
+ }
+ } else {
+ break;
+ }
+ }
+
+ for (size_t i = 2; i < handles.GetCount(); i++) {
+ FindCloseChangeNotification(handles[i]);
+ }
+
+ return 0;
}
diff --git a/src/filters/transform/VSFilter/DirectVobSubFilter.h b/src/filters/transform/VSFilter/DirectVobSubFilter.h
index bdff3d9ef..1772ecb99 100644
--- a/src/filters/transform/VSFilter/DirectVobSubFilter.h
+++ b/src/filters/transform/VSFilter/DirectVobSubFilter.h
@@ -30,168 +30,168 @@
#include "../../../Subtitles/RTS.h"
typedef struct {
- HWND hSystrayWnd;
- IFilterGraph* graph;
- IDirectVobSub* dvs;
- bool fRunOnce, fShowIcon;
+ HWND hSystrayWnd;
+ IFilterGraph* graph;
+ IDirectVobSub* dvs;
+ bool fRunOnce, fShowIcon;
} SystrayIconData;
/* This is for graphedit */
class __declspec(uuid("93A22E7A-5091-45ef-BA61-6DA26156A5D0"))
- CDirectVobSubFilter
- : public CBaseVideoFilter
- , public CDirectVobSub
- , public ISpecifyPropertyPages
- , public IAMStreamSelect
- , public CAMThread
+ CDirectVobSubFilter
+ : public CBaseVideoFilter
+ , public CDirectVobSub
+ , public ISpecifyPropertyPages
+ , public IAMStreamSelect
+ , public CAMThread
{
- friend class CTextInputPin;
+ friend class CTextInputPin;
- CCritSec m_csQueueLock;
- CComPtr<ISubPicQueue> m_pSubPicQueue;
- void InitSubPicQueue();
- SubPicDesc m_spd;
+ CCritSec m_csQueueLock;
+ CComPtr<ISubPicQueue> m_pSubPicQueue;
+ void InitSubPicQueue();
+ SubPicDesc m_spd;
- bool AdjustFrameSize(CSize& s);
+ bool AdjustFrameSize(CSize& s);
protected:
- void GetOutputSize(int& w, int& h, int& arx, int& ary, int& RealWidth, int& RealHeight, int& vsfilter);
- HRESULT Transform(IMediaSample* pIn);
+ void GetOutputSize(int& w, int& h, int& arx, int& ary, int& RealWidth, int& RealHeight, int& vsfilter);
+ HRESULT Transform(IMediaSample* pIn);
public:
- CDirectVobSubFilter(LPUNKNOWN punk, HRESULT* phr, const GUID& clsid = __uuidof(CDirectVobSubFilter));
- virtual ~CDirectVobSubFilter();
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // CBaseFilter
-
- CBasePin* GetPin(int n);
- int GetPinCount();
-
- STDMETHODIMP JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pName);
- STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
-
- // CTransformFilter
- HRESULT SetMediaType(PIN_DIRECTION dir, const CMediaType* pMediaType),
- CheckConnect(PIN_DIRECTION dir, IPin* pPin),
- CompleteConnect(PIN_DIRECTION dir, IPin* pReceivePin),
- BreakConnect(PIN_DIRECTION dir),
- StartStreaming(),
- StopStreaming(),
- NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
-
- CAtlArray<CTextInputPin*> m_pTextInput;
-
- // IDirectVobSub
- STDMETHODIMP put_FileName(WCHAR* fn);
- STDMETHODIMP get_LanguageCount(int* nLangs);
- STDMETHODIMP get_LanguageName(int iLanguage, WCHAR** ppName);
- STDMETHODIMP put_SelectedLanguage(int iSelected);
- STDMETHODIMP put_HideSubtitles(bool fHideSubtitles);
- STDMETHODIMP put_PreBuffering(bool fDoPreBuffering); // deprecated
- STDMETHODIMP put_SubPictToBuffer(unsigned int uSubPictToBuffer);
- STDMETHODIMP put_AnimWhenBuffering(bool fAnimWhenBuffering);
- STDMETHODIMP put_Placement(bool fOverridePlacement, int xperc, int yperc);
- STDMETHODIMP put_VobSubSettings(bool fBuffer, bool fOnlyShowForcedSubs, bool fPolygonize);
- STDMETHODIMP put_TextSettings(void* lf, int lflen, COLORREF color, bool fShadow, bool fOutline, bool fAdvancedRenderer);
- STDMETHODIMP put_SubtitleTiming(int delay, int speedmul, int speeddiv);
- STDMETHODIMP get_MediaFPS(bool* fEnabled, double* fps);
- STDMETHODIMP put_MediaFPS(bool fEnabled, double fps);
- STDMETHODIMP get_ZoomRect(NORMALIZEDRECT* rect);
- STDMETHODIMP put_ZoomRect(NORMALIZEDRECT* rect);
- STDMETHODIMP HasConfigDialog(int iSelected);
- STDMETHODIMP ShowConfigDialog(int iSelected, HWND hWndParent);
-
- // IDirectVobSub2
- STDMETHODIMP put_TextSettings(STSStyle* pDefStyle);
- STDMETHODIMP put_AspectRatioSettings(CSimpleTextSubtitle::EPARCompensationType* ePARCompensationType);
-
- // ISpecifyPropertyPages
- STDMETHODIMP GetPages(CAUUID* pPages);
-
- // IAMStreamSelect
- STDMETHODIMP Count(DWORD* pcStreams);
- STDMETHODIMP Enable(long lIndex, DWORD dwFlags);
- STDMETHODIMP Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* pdwFlags, LCID* plcid, DWORD* pdwGroup, WCHAR** ppszName, IUnknown** ppObject, IUnknown** ppUnk);
-
- // CPersistStream
- STDMETHODIMP GetClassID(CLSID* pClsid);
+ CDirectVobSubFilter(LPUNKNOWN punk, HRESULT* phr, const GUID& clsid = __uuidof(CDirectVobSubFilter));
+ virtual ~CDirectVobSubFilter();
+
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ // CBaseFilter
+
+ CBasePin* GetPin(int n);
+ int GetPinCount();
+
+ STDMETHODIMP JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pName);
+ STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
+
+ // CTransformFilter
+ HRESULT SetMediaType(PIN_DIRECTION dir, const CMediaType* pMediaType),
+ CheckConnect(PIN_DIRECTION dir, IPin* pPin),
+ CompleteConnect(PIN_DIRECTION dir, IPin* pReceivePin),
+ BreakConnect(PIN_DIRECTION dir),
+ StartStreaming(),
+ StopStreaming(),
+ NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+
+ CAtlArray<CTextInputPin*> m_pTextInput;
+
+ // IDirectVobSub
+ STDMETHODIMP put_FileName(WCHAR* fn);
+ STDMETHODIMP get_LanguageCount(int* nLangs);
+ STDMETHODIMP get_LanguageName(int iLanguage, WCHAR** ppName);
+ STDMETHODIMP put_SelectedLanguage(int iSelected);
+ STDMETHODIMP put_HideSubtitles(bool fHideSubtitles);
+ STDMETHODIMP put_PreBuffering(bool fDoPreBuffering); // deprecated
+ STDMETHODIMP put_SubPictToBuffer(unsigned int uSubPictToBuffer);
+ STDMETHODIMP put_AnimWhenBuffering(bool fAnimWhenBuffering);
+ STDMETHODIMP put_Placement(bool fOverridePlacement, int xperc, int yperc);
+ STDMETHODIMP put_VobSubSettings(bool fBuffer, bool fOnlyShowForcedSubs, bool fPolygonize);
+ STDMETHODIMP put_TextSettings(void* lf, int lflen, COLORREF color, bool fShadow, bool fOutline, bool fAdvancedRenderer);
+ STDMETHODIMP put_SubtitleTiming(int delay, int speedmul, int speeddiv);
+ STDMETHODIMP get_MediaFPS(bool* fEnabled, double* fps);
+ STDMETHODIMP put_MediaFPS(bool fEnabled, double fps);
+ STDMETHODIMP get_ZoomRect(NORMALIZEDRECT* rect);
+ STDMETHODIMP put_ZoomRect(NORMALIZEDRECT* rect);
+ STDMETHODIMP HasConfigDialog(int iSelected);
+ STDMETHODIMP ShowConfigDialog(int iSelected, HWND hWndParent);
+
+ // IDirectVobSub2
+ STDMETHODIMP put_TextSettings(STSStyle* pDefStyle);
+ STDMETHODIMP put_AspectRatioSettings(CSimpleTextSubtitle::EPARCompensationType* ePARCompensationType);
+
+ // ISpecifyPropertyPages
+ STDMETHODIMP GetPages(CAUUID* pPages);
+
+ // IAMStreamSelect
+ STDMETHODIMP Count(DWORD* pcStreams);
+ STDMETHODIMP Enable(long lIndex, DWORD dwFlags);
+ STDMETHODIMP Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* pdwFlags, LCID* plcid, DWORD* pdwGroup, WCHAR** ppszName, IUnknown** ppObject, IUnknown** ppUnk);
+
+ // CPersistStream
+ STDMETHODIMP GetClassID(CLSID* pClsid);
protected:
- HRESULT ChangeMediaType(int iPosition);
+ HRESULT ChangeMediaType(int iPosition);
- HDC m_hdc;
- HBITMAP m_hbm;
- HFONT m_hfont;
- void PrintMessages(BYTE* pOut);
+ HDC m_hdc;
+ HBITMAP m_hbm;
+ HFONT m_hfont;
+ void PrintMessages(BYTE* pOut);
- /* ResX2 */
- CAutoVectorPtr<BYTE> m_pTempPicBuff;
- HRESULT Copy(BYTE* pSub, BYTE* pIn, CSize sub, CSize in, int bpp, const GUID& subtype, DWORD black);
+ /* ResX2 */
+ CAutoVectorPtr<BYTE> m_pTempPicBuff;
+ HRESULT Copy(BYTE* pSub, BYTE* pIn, CSize sub, CSize in, int bpp, const GUID& subtype, DWORD black);
- // segment start time, absolute time
- CRefTime m_tPrev;
- REFERENCE_TIME CalcCurrentTime();
+ // segment start time, absolute time
+ CRefTime m_tPrev;
+ REFERENCE_TIME CalcCurrentTime();
- double m_fps;
+ double m_fps;
- // 3.x- versions of microsoft's mpeg4 codec output flipped image
- bool m_fMSMpeg4Fix;
+ // 3.x- versions of microsoft's mpeg4 codec output flipped image
+ bool m_fMSMpeg4Fix;
- // don't set the "hide subtitles" stream until we are finished with loading
- bool m_fLoading;
+ // don't set the "hide subtitles" stream until we are finished with loading
+ bool m_fLoading;
- bool Open();
+ bool Open();
- int FindPreferedLanguage(bool fHideToo = true);
- void UpdatePreferedLanguages(CString lang);
+ int FindPreferedLanguage(bool fHideToo = true);
+ void UpdatePreferedLanguages(CString lang);
- CCritSec m_csSubLock;
- CInterfaceList<ISubStream> m_pSubStreams;
- DWORD_PTR m_nSubtitleId;
- void UpdateSubtitle(bool fApplyDefStyle = true);
- void SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyle = true);
- void InvalidateSubtitle(REFERENCE_TIME rtInvalidate = -1, DWORD_PTR nSubtitleId = -1);
+ CCritSec m_csSubLock;
+ CInterfaceList<ISubStream> m_pSubStreams;
+ DWORD_PTR m_nSubtitleId;
+ void UpdateSubtitle(bool fApplyDefStyle = true);
+ void SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyle = true);
+ void InvalidateSubtitle(REFERENCE_TIME rtInvalidate = -1, DWORD_PTR nSubtitleId = -1);
- // the text input pin is using these
- void AddSubStream(ISubStream* pSubStream);
- void RemoveSubStream(ISubStream* pSubStream);
- void Post_EC_OLE_EVENT(CString str, DWORD_PTR nSubtitleId = -1);
+ // the text input pin is using these
+ void AddSubStream(ISubStream* pSubStream);
+ void RemoveSubStream(ISubStream* pSubStream);
+ void Post_EC_OLE_EVENT(CString str, DWORD_PTR nSubtitleId = -1);
private:
- class CFileReloaderData
- {
- public:
- ATL::CEvent EndThreadEvent, RefreshEvent;
- CAtlList<CString> files;
- CAtlArray<CTime> mtime;
- } m_frd;
+ class CFileReloaderData
+ {
+ public:
+ ATL::CEvent EndThreadEvent, RefreshEvent;
+ CAtlList<CString> files;
+ CAtlArray<CTime> mtime;
+ } m_frd;
- void SetupFRD(CStringArray& paths, CAtlArray<HANDLE>& handles);
- DWORD ThreadProc();
+ void SetupFRD(CStringArray& paths, CAtlArray<HANDLE>& handles);
+ DWORD ThreadProc();
private:
- HANDLE m_hSystrayThread;
- SystrayIconData m_tbid;
+ HANDLE m_hSystrayThread;
+ SystrayIconData m_tbid;
- VIDEOINFOHEADER2 m_CurrentVIH2;
+ VIDEOINFOHEADER2 m_CurrentVIH2;
};
/* The "auto-loading" version */
class __declspec(uuid("9852A670-F845-491b-9BE6-EBD841B8A613"))
- CDirectVobSubFilter2 : public CDirectVobSubFilter
+ CDirectVobSubFilter2 : public CDirectVobSubFilter
{
- bool ShouldWeAutoload(IFilterGraph* pGraph);
- void GetRidOfInternalScriptRenderer();
+ bool ShouldWeAutoload(IFilterGraph* pGraph);
+ void GetRidOfInternalScriptRenderer();
public:
- CDirectVobSubFilter2(LPUNKNOWN punk, HRESULT* phr, const GUID& clsid = __uuidof(CDirectVobSubFilter2));
+ CDirectVobSubFilter2(LPUNKNOWN punk, HRESULT* phr, const GUID& clsid = __uuidof(CDirectVobSubFilter2));
- HRESULT CheckConnect(PIN_DIRECTION dir, IPin* pPin);
- STDMETHODIMP JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pName);
- HRESULT CheckInputType(const CMediaType* mtIn);
+ HRESULT CheckConnect(PIN_DIRECTION dir, IPin* pPin);
+ STDMETHODIMP JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pName);
+ HRESULT CheckInputType(const CMediaType* mtIn);
};
diff --git a/src/filters/transform/VSFilter/DirectVobSubPropPage.cpp b/src/filters/transform/VSFilter/DirectVobSubPropPage.cpp
index 0175e26fd..405fd3e86 100644
--- a/src/filters/transform/VSFilter/DirectVobSubPropPage.cpp
+++ b/src/filters/transform/VSFilter/DirectVobSubPropPage.cpp
@@ -37,817 +37,817 @@
BOOL WINAPI MyGetDialogSize(int iResourceID, DLGPROC pDlgProc, LPARAM lParam, SIZE* pResult)
{
- HWND hwnd = CreateDialogParam(AfxGetResourceHandle(),
- MAKEINTRESOURCE(iResourceID),
- GetDesktopWindow(),
- pDlgProc,
- lParam);
+ HWND hwnd = CreateDialogParam(AfxGetResourceHandle(),
+ MAKEINTRESOURCE(iResourceID),
+ GetDesktopWindow(),
+ pDlgProc,
+ lParam);
- if (hwnd == NULL) {
- return FALSE;
- }
+ if (hwnd == NULL) {
+ return FALSE;
+ }
- RECT rc;
- GetWindowRect(hwnd, &rc);
- pResult->cx = rc.right - rc.left;
- pResult->cy = rc.bottom - rc.top;
+ RECT rc;
+ GetWindowRect(hwnd, &rc);
+ pResult->cx = rc.right - rc.left;
+ pResult->cy = rc.bottom - rc.top;
- DestroyWindow(hwnd);
+ DestroyWindow(hwnd);
- return TRUE;
+ return TRUE;
}
STDMETHODIMP CDVSBasePPage::GetPageInfo(LPPROPPAGEINFO pPageInfo)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CString str;
- if (!str.LoadString(m_TitleId)) {
- return E_FAIL;
- }
+ CString str;
+ if (!str.LoadString(m_TitleId)) {
+ return E_FAIL;
+ }
- WCHAR wszTitle[STR_MAX_LENGTH];
- wcscpy_s(wszTitle, str);
+ WCHAR wszTitle[STR_MAX_LENGTH];
+ wcscpy_s(wszTitle, str);
- CheckPointer(pPageInfo, E_POINTER);
+ CheckPointer(pPageInfo, E_POINTER);
- // Allocate dynamic memory for the property page title
+ // Allocate dynamic memory for the property page title
- LPOLESTR pszTitle;
- HRESULT hr = AMGetWideString(wszTitle, &pszTitle);
- if (FAILED(hr)) {
- NOTE("No caption memory");
- return hr;
- }
+ LPOLESTR pszTitle;
+ HRESULT hr = AMGetWideString(wszTitle, &pszTitle);
+ if (FAILED(hr)) {
+ NOTE("No caption memory");
+ return hr;
+ }
- pPageInfo->cb = sizeof(PROPPAGEINFO);
- pPageInfo->pszTitle = pszTitle;
- pPageInfo->pszDocString = NULL;
- pPageInfo->pszHelpFile = NULL;
- pPageInfo->dwHelpContext = 0;
- // Set defaults in case GetDialogSize fails
- pPageInfo->size.cx = 340;
- pPageInfo->size.cy = 150;
+ pPageInfo->cb = sizeof(PROPPAGEINFO);
+ pPageInfo->pszTitle = pszTitle;
+ pPageInfo->pszDocString = NULL;
+ pPageInfo->pszHelpFile = NULL;
+ pPageInfo->dwHelpContext = 0;
+ // Set defaults in case GetDialogSize fails
+ pPageInfo->size.cx = 340;
+ pPageInfo->size.cy = 150;
- MyGetDialogSize(m_DialogId, DialogProc, 0L, &pPageInfo->size);
+ MyGetDialogSize(m_DialogId, DialogProc, 0L, &pPageInfo->size);
- return NOERROR;
+ return NOERROR;
}
STDMETHODIMP CDVSBasePPage::Activate(HWND hwndParent, LPCRECT pRect, BOOL fModal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- CheckPointer(pRect,E_POINTER);
- /*
- // Return failure if SetObject has not been called.
- if (m_bObjectSet == FALSE) {
- return E_UNEXPECTED;
- }
- */
- if (m_hwnd) {
- return E_UNEXPECTED;
- }
-
- m_hwnd = CreateDialogParam(AfxGetResourceHandle(), MAKEINTRESOURCE(m_DialogId), hwndParent, DialogProc, (LPARAM)this);
- if (m_hwnd == NULL) {
- return E_OUTOFMEMORY;
- }
-
- OnActivate();
- Move(pRect);
- return Show(SW_SHOWNORMAL);
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ CheckPointer(pRect, E_POINTER);
+ /*
+ // Return failure if SetObject has not been called.
+ if (m_bObjectSet == FALSE) {
+ return E_UNEXPECTED;
+ }
+ */
+ if (m_hwnd) {
+ return E_UNEXPECTED;
+ }
+
+ m_hwnd = CreateDialogParam(AfxGetResourceHandle(), MAKEINTRESOURCE(m_DialogId), hwndParent, DialogProc, (LPARAM)this);
+ if (m_hwnd == NULL) {
+ return E_OUTOFMEMORY;
+ }
+
+ OnActivate();
+ Move(pRect);
+ return Show(SW_SHOWNORMAL);
}
/* CDVSBasePPage */
CDVSBasePPage::CDVSBasePPage(TCHAR* pName, LPUNKNOWN lpunk, int DialogId, int TitleId) :
- CBasePropertyPage(pName, lpunk, DialogId, TitleId),
- m_bIsInitialized(FALSE),
- m_fAttached(false),
- m_fDisableInstantUpdate(false)
+ CBasePropertyPage(pName, lpunk, DialogId, TitleId),
+ m_bIsInitialized(FALSE),
+ m_fAttached(false),
+ m_fDisableInstantUpdate(false)
{
}
INT_PTR CDVSBasePPage::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch (uMsg) {
- case WM_COMMAND: {
- if (m_bIsInitialized) {
- m_bDirty = TRUE;
- if (m_pPageSite) {
- m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);
- }
-
- switch (HIWORD(wParam)) {
- case BN_CLICKED:
- case CBN_SELCHANGE:
- case EN_CHANGE: {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- if (!m_fDisableInstantUpdate
- && !(HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_INSTANTUPDATE)
- && LOWORD(wParam) != IDC_EDIT1 && LOWORD(wParam) != IDC_ANIMWHENBUFFERING
- && !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INSTANTUPDATE), 1)) {
- OnApplyChanges();
- }
- }
- }
- }
- }
- break;
-
- case WM_NCDESTROY:
- DetachControls();
- break;
- }
-
- return OnMessage(uMsg, wParam, lParam)
- ? 0
- : CBasePropertyPage::OnReceiveMessage(hwnd,uMsg,wParam,lParam);
+ switch (uMsg) {
+ case WM_COMMAND: {
+ if (m_bIsInitialized) {
+ m_bDirty = TRUE;
+ if (m_pPageSite) {
+ m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);
+ }
+
+ switch (HIWORD(wParam)) {
+ case BN_CLICKED:
+ case CBN_SELCHANGE:
+ case EN_CHANGE: {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ if (!m_fDisableInstantUpdate
+ && !(HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_INSTANTUPDATE)
+ && LOWORD(wParam) != IDC_EDIT1 && LOWORD(wParam) != IDC_ANIMWHENBUFFERING
+ && !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INSTANTUPDATE), 1)) {
+ OnApplyChanges();
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ case WM_NCDESTROY:
+ DetachControls();
+ break;
+ }
+
+ return OnMessage(uMsg, wParam, lParam)
+ ? 0
+ : CBasePropertyPage::OnReceiveMessage(hwnd, uMsg, wParam, lParam);
}
HRESULT CDVSBasePPage::OnConnect(IUnknown* pUnknown)
{
- if (!(m_pDirectVobSub = pUnknown)) {
- return E_NOINTERFACE;
- }
+ if (!(m_pDirectVobSub = pUnknown)) {
+ return E_NOINTERFACE;
+ }
- m_pDirectVobSub->LockSubtitleReloader(true); // *
+ m_pDirectVobSub->LockSubtitleReloader(true); // *
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
- UpdateObjectData(false);
+ UpdateObjectData(false);
- m_bIsInitialized = FALSE;
+ m_bIsInitialized = FALSE;
- return NOERROR;
+ return NOERROR;
}
HRESULT CDVSBasePPage::OnDisconnect()
{
- if (m_pDirectVobSub == NULL) {
- return E_UNEXPECTED;
- }
+ if (m_pDirectVobSub == NULL) {
+ return E_UNEXPECTED;
+ }
- m_pDirectVobSub->LockSubtitleReloader(false); // *
+ m_pDirectVobSub->LockSubtitleReloader(false); // *
- // for some reason OnDisconnect() will be called twice, that's why we
- // need to release m_pDirectVobSub manually on the first call to avoid
- // a second "m_pDirectVobSub->LockSubtitleReloader(false);"
+ // for some reason OnDisconnect() will be called twice, that's why we
+ // need to release m_pDirectVobSub manually on the first call to avoid
+ // a second "m_pDirectVobSub->LockSubtitleReloader(false);"
- m_pDirectVobSub.Release();
+ m_pDirectVobSub.Release();
- return NOERROR;
+ return NOERROR;
}
HRESULT CDVSBasePPage::OnActivate()
{
- ASSERT(m_pDirectVobSub);
+ ASSERT(m_pDirectVobSub);
- AttachControls();
+ AttachControls();
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
- UpdateControlData(false);
+ UpdateControlData(false);
- m_bIsInitialized = TRUE;
+ m_bIsInitialized = TRUE;
- return NOERROR;
+ return NOERROR;
}
HRESULT CDVSBasePPage::OnDeactivate()
{
- ASSERT(m_pDirectVobSub);
+ ASSERT(m_pDirectVobSub);
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
- UpdateControlData(true);
+ UpdateControlData(true);
- m_bIsInitialized = FALSE;
+ m_bIsInitialized = FALSE;
- return NOERROR;
+ return NOERROR;
}
HRESULT CDVSBasePPage::OnApplyChanges()
{
- ASSERT(m_pDirectVobSub);
+ ASSERT(m_pDirectVobSub);
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
- if (m_bIsInitialized) {
- OnDeactivate();
- UpdateObjectData(true);
- m_pDirectVobSub->UpdateRegistry(); // *
- OnActivate();
- }
+ if (m_bIsInitialized) {
+ OnDeactivate();
+ UpdateObjectData(true);
+ m_pDirectVobSub->UpdateRegistry(); // *
+ OnActivate();
+ }
- return NOERROR;
+ return NOERROR;
}
void CDVSBasePPage::AttachControls()
{
- DetachControls();
-
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- POSITION pos = m_controls.GetStartPosition();
- while (pos) {
- UINT id;
- CWnd* pControl;
- m_controls.GetNextAssoc(pos, id, pControl);
- if (pControl) {
- BOOL fRet = pControl->Attach(GetDlgItem(m_Dlg, id));
- ASSERT(fRet);
- }
- }
-
- m_fAttached = true;
+ DetachControls();
+
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ POSITION pos = m_controls.GetStartPosition();
+ while (pos) {
+ UINT id;
+ CWnd* pControl;
+ m_controls.GetNextAssoc(pos, id, pControl);
+ if (pControl) {
+ BOOL fRet = pControl->Attach(GetDlgItem(m_Dlg, id));
+ ASSERT(fRet);
+ }
+ }
+
+ m_fAttached = true;
}
void CDVSBasePPage::DetachControls()
{
- if (!m_fAttached) {
- return;
- }
-
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- POSITION pos = m_controls.GetStartPosition();
- while (pos) {
- UINT id;
- CWnd* pControl;
- m_controls.GetNextAssoc(pos, id, pControl);
- if (pControl) {
- pControl->Detach();
- }
- }
-
- m_fAttached = false;
+ if (!m_fAttached) {
+ return;
+ }
+
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ POSITION pos = m_controls.GetStartPosition();
+ while (pos) {
+ UINT id;
+ CWnd* pControl;
+ m_controls.GetNextAssoc(pos, id, pControl);
+ if (pControl) {
+ pControl->Detach();
+ }
+ }
+
+ m_fAttached = false;
}
void CDVSBasePPage::BindControl(UINT id, CWnd& control)
{
- m_controls[id] = &control;
+ m_controls[id] = &control;
}
/* CDVSMainPPage */
CDVSMainPPage::CDVSMainPPage(LPUNKNOWN pUnk, HRESULT* phr) :
- CDVSBasePPage(NAME("DirectVobSub Property Page (main)"), pUnk, IDD_DVSMAINPAGE, IDD_DVSMAINPAGE),
- m_nLangs(0),
- m_ppLangs(NULL)
+ CDVSBasePPage(NAME("DirectVobSub Property Page (main)"), pUnk, IDD_DVSMAINPAGE, IDD_DVSMAINPAGE),
+ m_nLangs(0),
+ m_ppLangs(NULL)
{
- BindControl(IDC_FILENAME, m_fnedit);
- BindControl(IDC_LANGCOMBO, m_langs);
- BindControl(IDC_OVERRIDEPLACEMENT, m_oplacement);
- BindControl(IDC_SPIN1, m_subposx);
- BindControl(IDC_SPIN2, m_subposy);
- BindControl(IDC_FONT, m_font);
- BindControl(IDC_ONLYSHOWFORCEDSUBS, m_forcedsubs);
- BindControl(IDC_PARCOMBO, m_PARCombo);
+ BindControl(IDC_FILENAME, m_fnedit);
+ BindControl(IDC_LANGCOMBO, m_langs);
+ BindControl(IDC_OVERRIDEPLACEMENT, m_oplacement);
+ BindControl(IDC_SPIN1, m_subposx);
+ BindControl(IDC_SPIN2, m_subposy);
+ BindControl(IDC_FONT, m_font);
+ BindControl(IDC_ONLYSHOWFORCEDSUBS, m_forcedsubs);
+ BindControl(IDC_PARCOMBO, m_PARCombo);
}
CDVSMainPPage::~CDVSMainPPage()
{
- FreeLangs();
+ FreeLangs();
}
void CDVSMainPPage::FreeLangs()
{
- if (m_nLangs > 0 && m_ppLangs) {
- for (ptrdiff_t i = 0; i < m_nLangs; i++) {
- CoTaskMemFree(m_ppLangs[i]);
- }
- CoTaskMemFree(m_ppLangs);
- m_nLangs = 0;
- m_ppLangs = NULL;
- }
+ if (m_nLangs > 0 && m_ppLangs) {
+ for (ptrdiff_t i = 0; i < m_nLangs; i++) {
+ CoTaskMemFree(m_ppLangs[i]);
+ }
+ CoTaskMemFree(m_ppLangs);
+ m_nLangs = 0;
+ m_ppLangs = NULL;
+ }
}
void CDVSMainPPage::AllocLangs(int nLangs)
{
- m_ppLangs = (WCHAR**)CoTaskMemRealloc(m_ppLangs, sizeof(WCHAR*)*nLangs);
- m_nLangs = nLangs;
+ m_ppLangs = (WCHAR**)CoTaskMemRealloc(m_ppLangs, sizeof(WCHAR*)*nLangs);
+ m_nLangs = nLangs;
}
bool CDVSMainPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch (uMsg) {
- case WM_COMMAND: {
- switch (HIWORD(wParam)) {
- case BN_CLICKED: {
- if (LOWORD(wParam) == IDC_OPEN) {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- CFileDialog fd(TRUE, NULL, NULL,
- OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST,
- _T(".idx .smi .sub .srt .psb .ssa .ass .usf|*.idx;*.smi;*.sub;*.srt;*.psb;*.ssa;*.ass;*.usf|")
- _T("All files (*.*)|*.*||"),
- CDialog::FromHandle(m_Dlg), 0);
-
- if (fd.DoModal() == IDOK) {
- m_fnedit.SetWindowText(fd.GetPathName());
- }
-
- return true;
- } else if (LOWORD(wParam) == IDC_FONT) {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- CStyleEditorDialog dlg(_T("Default"), &m_defStyle, CWnd::FromHandle(m_hwnd));
-
- if (dlg.DoModal() == IDOK) {
- m_defStyle = dlg.m_stss;
- CString str = m_defStyle.fontName;
- if (str.GetLength() > 18) {
- str = str.Left(16).TrimRight() + _T("...");
- }
- m_font.SetWindowText(str);
- }
-
- return true;
- }
- }
- break;
- }
- }
- break;
- }
-
- return false;
+ switch (uMsg) {
+ case WM_COMMAND: {
+ switch (HIWORD(wParam)) {
+ case BN_CLICKED: {
+ if (LOWORD(wParam) == IDC_OPEN) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ CFileDialog fd(TRUE, NULL, NULL,
+ OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST,
+ _T(".idx .smi .sub .srt .psb .ssa .ass .usf|*.idx;*.smi;*.sub;*.srt;*.psb;*.ssa;*.ass;*.usf|")
+ _T("All files (*.*)|*.*||"),
+ CDialog::FromHandle(m_Dlg), 0);
+
+ if (fd.DoModal() == IDOK) {
+ m_fnedit.SetWindowText(fd.GetPathName());
+ }
+
+ return true;
+ } else if (LOWORD(wParam) == IDC_FONT) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ CStyleEditorDialog dlg(_T("Default"), &m_defStyle, CWnd::FromHandle(m_hwnd));
+
+ if (dlg.DoModal() == IDOK) {
+ m_defStyle = dlg.m_stss;
+ CString str = m_defStyle.fontName;
+ if (str.GetLength() > 18) {
+ str = str.Left(16).TrimRight() + _T("...");
+ }
+ m_font.SetWindowText(str);
+ }
+
+ return true;
+ }
+ }
+ break;
+ }
+ }
+ break;
+ }
+
+ return false;
}
void CDVSMainPPage::UpdateObjectData(bool fSave)
{
- if (fSave) {
- if (m_pDirectVobSub->put_FileName(m_fn) == S_OK) {
- int nLangs;
- m_pDirectVobSub->get_LanguageCount(&nLangs);
- AllocLangs(nLangs);
- for (ptrdiff_t i = 0; i < m_nLangs; i++) {
- m_pDirectVobSub->get_LanguageName(i, &m_ppLangs[i]);
- }
- m_pDirectVobSub->get_SelectedLanguage(&m_iSelectedLanguage);
- }
-
- m_pDirectVobSub->put_SelectedLanguage(m_iSelectedLanguage);
- m_pDirectVobSub->put_Placement(m_fOverridePlacement, m_PlacementXperc, m_PlacementYperc);
- m_pDirectVobSub->put_VobSubSettings(true, m_fOnlyShowForcedVobSubs, false);
- m_pDirectVobSub->put_TextSettings(&m_defStyle);
- m_pDirectVobSub->put_AspectRatioSettings(&m_ePARCompensationType);
- } else {
- m_pDirectVobSub->get_FileName(m_fn);
- int nLangs;
- m_pDirectVobSub->get_LanguageCount(&nLangs);
- AllocLangs(nLangs);
- for (ptrdiff_t i = 0; i < m_nLangs; i++) {
- m_pDirectVobSub->get_LanguageName(i, &m_ppLangs[i]);
- }
- m_pDirectVobSub->get_SelectedLanguage(&m_iSelectedLanguage);
- m_pDirectVobSub->get_Placement(&m_fOverridePlacement, &m_PlacementXperc, &m_PlacementYperc);
- m_pDirectVobSub->get_VobSubSettings(NULL, &m_fOnlyShowForcedVobSubs, NULL);
- m_pDirectVobSub->get_TextSettings(&m_defStyle);
- m_pDirectVobSub->get_AspectRatioSettings(&m_ePARCompensationType);
- }
+ if (fSave) {
+ if (m_pDirectVobSub->put_FileName(m_fn) == S_OK) {
+ int nLangs;
+ m_pDirectVobSub->get_LanguageCount(&nLangs);
+ AllocLangs(nLangs);
+ for (ptrdiff_t i = 0; i < m_nLangs; i++) {
+ m_pDirectVobSub->get_LanguageName(i, &m_ppLangs[i]);
+ }
+ m_pDirectVobSub->get_SelectedLanguage(&m_iSelectedLanguage);
+ }
+
+ m_pDirectVobSub->put_SelectedLanguage(m_iSelectedLanguage);
+ m_pDirectVobSub->put_Placement(m_fOverridePlacement, m_PlacementXperc, m_PlacementYperc);
+ m_pDirectVobSub->put_VobSubSettings(true, m_fOnlyShowForcedVobSubs, false);
+ m_pDirectVobSub->put_TextSettings(&m_defStyle);
+ m_pDirectVobSub->put_AspectRatioSettings(&m_ePARCompensationType);
+ } else {
+ m_pDirectVobSub->get_FileName(m_fn);
+ int nLangs;
+ m_pDirectVobSub->get_LanguageCount(&nLangs);
+ AllocLangs(nLangs);
+ for (ptrdiff_t i = 0; i < m_nLangs; i++) {
+ m_pDirectVobSub->get_LanguageName(i, &m_ppLangs[i]);
+ }
+ m_pDirectVobSub->get_SelectedLanguage(&m_iSelectedLanguage);
+ m_pDirectVobSub->get_Placement(&m_fOverridePlacement, &m_PlacementXperc, &m_PlacementYperc);
+ m_pDirectVobSub->get_VobSubSettings(NULL, &m_fOnlyShowForcedVobSubs, NULL);
+ m_pDirectVobSub->get_TextSettings(&m_defStyle);
+ m_pDirectVobSub->get_AspectRatioSettings(&m_ePARCompensationType);
+ }
}
void CDVSMainPPage::UpdateControlData(bool fSave)
{
- if (fSave) {
- CString fn;
- m_fnedit.GetWindowText(fn);
- wcscpy_s(m_fn, fn);
-
- m_iSelectedLanguage = m_langs.GetCurSel();
- m_fOverridePlacement = !!m_oplacement.GetCheck();
- m_PlacementXperc = m_subposx.GetPos();
- m_PlacementYperc = m_subposy.GetPos();
- m_fOnlyShowForcedVobSubs = !!m_forcedsubs.GetCheck();
- if (m_PARCombo.GetCurSel() != CB_ERR) {
- m_ePARCompensationType = static_cast<CSimpleTextSubtitle::EPARCompensationType>(m_PARCombo.GetItemData(m_PARCombo.GetCurSel()));
- } else {
- m_ePARCompensationType = CSimpleTextSubtitle::EPCTDisabled;
- }
- } else {
- m_fnedit.SetWindowText(CString(m_fn));
- m_oplacement.SetCheck(m_fOverridePlacement);
- m_subposx.SetRange(-20, 120);
- m_subposx.SetPos(m_PlacementXperc);
- m_subposx.EnableWindow(m_fOverridePlacement);
- m_subposy.SetRange(-20, 120);
- m_subposy.SetPos(m_PlacementYperc);
- m_subposy.EnableWindow(m_fOverridePlacement);
- m_font.SetWindowText(m_defStyle.fontName);
- m_forcedsubs.SetCheck(m_fOnlyShowForcedVobSubs);
- m_langs.ResetContent();
- m_langs.EnableWindow(m_nLangs > 0);
- for (ptrdiff_t i = 0; i < m_nLangs; i++) {
- m_langs.AddString(CString(m_ppLangs[i]));
- }
- m_langs.SetCurSel(m_iSelectedLanguage);
-
- m_PARCombo.ResetContent();
- m_PARCombo.InsertString(0, ResStr(IDS_RT_PAR_DISABLED));
- m_PARCombo.SetItemData(0, CSimpleTextSubtitle::EPCTDisabled);
- if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTDisabled) {
- m_PARCombo.SetCurSel(0);
- }
-
- m_PARCombo.InsertString(1, ResStr(IDS_RT_PAR_DOWNSCALE));
- m_PARCombo.SetItemData(1, CSimpleTextSubtitle::EPCTDownscale);
- if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTDownscale) {
- m_PARCombo.SetCurSel(1);
- }
-
- m_PARCombo.InsertString(2, ResStr(IDS_RT_PAR_UPSCALE));
- m_PARCombo.SetItemData(2, CSimpleTextSubtitle::EPCTUpscale);
- if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTUpscale) {
- m_PARCombo.SetCurSel(2);
- }
-
- m_PARCombo.InsertString(3, ResStr(IDS_RT_PAR_ACCURATE_SIZE));
- m_PARCombo.SetItemData(3, CSimpleTextSubtitle::EPCTAccurateSize);
- if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTAccurateSize) {
- m_PARCombo.SetCurSel(3);
- }
- }
+ if (fSave) {
+ CString fn;
+ m_fnedit.GetWindowText(fn);
+ wcscpy_s(m_fn, fn);
+
+ m_iSelectedLanguage = m_langs.GetCurSel();
+ m_fOverridePlacement = !!m_oplacement.GetCheck();
+ m_PlacementXperc = m_subposx.GetPos();
+ m_PlacementYperc = m_subposy.GetPos();
+ m_fOnlyShowForcedVobSubs = !!m_forcedsubs.GetCheck();
+ if (m_PARCombo.GetCurSel() != CB_ERR) {
+ m_ePARCompensationType = static_cast<CSimpleTextSubtitle::EPARCompensationType>(m_PARCombo.GetItemData(m_PARCombo.GetCurSel()));
+ } else {
+ m_ePARCompensationType = CSimpleTextSubtitle::EPCTDisabled;
+ }
+ } else {
+ m_fnedit.SetWindowText(CString(m_fn));
+ m_oplacement.SetCheck(m_fOverridePlacement);
+ m_subposx.SetRange(-20, 120);
+ m_subposx.SetPos(m_PlacementXperc);
+ m_subposx.EnableWindow(m_fOverridePlacement);
+ m_subposy.SetRange(-20, 120);
+ m_subposy.SetPos(m_PlacementYperc);
+ m_subposy.EnableWindow(m_fOverridePlacement);
+ m_font.SetWindowText(m_defStyle.fontName);
+ m_forcedsubs.SetCheck(m_fOnlyShowForcedVobSubs);
+ m_langs.ResetContent();
+ m_langs.EnableWindow(m_nLangs > 0);
+ for (ptrdiff_t i = 0; i < m_nLangs; i++) {
+ m_langs.AddString(CString(m_ppLangs[i]));
+ }
+ m_langs.SetCurSel(m_iSelectedLanguage);
+
+ m_PARCombo.ResetContent();
+ m_PARCombo.InsertString(0, ResStr(IDS_RT_PAR_DISABLED));
+ m_PARCombo.SetItemData(0, CSimpleTextSubtitle::EPCTDisabled);
+ if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTDisabled) {
+ m_PARCombo.SetCurSel(0);
+ }
+
+ m_PARCombo.InsertString(1, ResStr(IDS_RT_PAR_DOWNSCALE));
+ m_PARCombo.SetItemData(1, CSimpleTextSubtitle::EPCTDownscale);
+ if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTDownscale) {
+ m_PARCombo.SetCurSel(1);
+ }
+
+ m_PARCombo.InsertString(2, ResStr(IDS_RT_PAR_UPSCALE));
+ m_PARCombo.SetItemData(2, CSimpleTextSubtitle::EPCTUpscale);
+ if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTUpscale) {
+ m_PARCombo.SetCurSel(2);
+ }
+
+ m_PARCombo.InsertString(3, ResStr(IDS_RT_PAR_ACCURATE_SIZE));
+ m_PARCombo.SetItemData(3, CSimpleTextSubtitle::EPCTAccurateSize);
+ if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTAccurateSize) {
+ m_PARCombo.SetCurSel(3);
+ }
+ }
}
/* CDVSGeneralPPage */
CDVSGeneralPPage::CDVSGeneralPPage(LPUNKNOWN pUnk, HRESULT* phr) :
- CDVSBasePPage(NAME("DirectVobSub Property Page (global settings)"), pUnk, IDD_DVSGENERALPAGE, IDD_DVSGENERALPAGE)
+ CDVSBasePPage(NAME("DirectVobSub Property Page (global settings)"), pUnk, IDD_DVSGENERALPAGE, IDD_DVSGENERALPAGE)
{
- BindControl(IDC_VEREXTCOMBO, m_verext);
- BindControl(IDC_MOD32FIX, m_mod32fix);
- BindControl(IDC_RESX2COMBO, m_resx2);
- BindControl(IDC_SPIN3, m_resx2w);
- BindControl(IDC_SPIN4, m_resx2h);
- BindControl(IDC_LOADCOMBO, m_load);
- BindControl(IDC_EXTLOAD, m_extload);
- BindControl(IDC_WEBLOAD, m_webload);
- BindControl(IDC_EMBLOAD, m_embload);
+ BindControl(IDC_VEREXTCOMBO, m_verext);
+ BindControl(IDC_MOD32FIX, m_mod32fix);
+ BindControl(IDC_RESX2COMBO, m_resx2);
+ BindControl(IDC_SPIN3, m_resx2w);
+ BindControl(IDC_SPIN4, m_resx2h);
+ BindControl(IDC_LOADCOMBO, m_load);
+ BindControl(IDC_EXTLOAD, m_extload);
+ BindControl(IDC_WEBLOAD, m_webload);
+ BindControl(IDC_EMBLOAD, m_embload);
}
bool CDVSGeneralPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch (uMsg) {
- case WM_COMMAND: {
- switch (HIWORD(wParam)) {
- case CBN_SELCHANGE: {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- if (LOWORD(wParam) == IDC_RESX2COMBO) {
- m_resx2w.EnableWindow(m_resx2.GetCurSel() == 2);
- m_resx2h.EnableWindow(m_resx2.GetCurSel() == 2);
- return true;
- } else if (LOWORD(wParam) == IDC_LOADCOMBO) {
- m_extload.EnableWindow(m_load.GetCurSel() == 1);
- m_webload.EnableWindow(m_load.GetCurSel() == 1);
- m_embload.EnableWindow(m_load.GetCurSel() == 1);
- return true;
- }
- }
- break;
- }
- }
- break;
- }
-
- return false;
+ switch (uMsg) {
+ case WM_COMMAND: {
+ switch (HIWORD(wParam)) {
+ case CBN_SELCHANGE: {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ if (LOWORD(wParam) == IDC_RESX2COMBO) {
+ m_resx2w.EnableWindow(m_resx2.GetCurSel() == 2);
+ m_resx2h.EnableWindow(m_resx2.GetCurSel() == 2);
+ return true;
+ } else if (LOWORD(wParam) == IDC_LOADCOMBO) {
+ m_extload.EnableWindow(m_load.GetCurSel() == 1);
+ m_webload.EnableWindow(m_load.GetCurSel() == 1);
+ m_embload.EnableWindow(m_load.GetCurSel() == 1);
+ return true;
+ }
+ }
+ break;
+ }
+ }
+ break;
+ }
+
+ return false;
}
void CDVSGeneralPPage::UpdateObjectData(bool fSave)
{
- if (fSave) {
- m_pDirectVobSub->put_ExtendPicture(m_HorExt, m_VerExt, m_ResX2, m_ResX2minw, m_ResX2minh);
- m_pDirectVobSub->put_LoadSettings(m_LoadLevel, m_fExternalLoad, m_fWebLoad, m_fEmbeddedLoad);
- } else {
- m_pDirectVobSub->get_ExtendPicture(&m_HorExt, &m_VerExt, &m_ResX2, &m_ResX2minw, &m_ResX2minh);
- m_pDirectVobSub->get_LoadSettings(&m_LoadLevel, &m_fExternalLoad, &m_fWebLoad, &m_fEmbeddedLoad);
- }
+ if (fSave) {
+ m_pDirectVobSub->put_ExtendPicture(m_HorExt, m_VerExt, m_ResX2, m_ResX2minw, m_ResX2minh);
+ m_pDirectVobSub->put_LoadSettings(m_LoadLevel, m_fExternalLoad, m_fWebLoad, m_fEmbeddedLoad);
+ } else {
+ m_pDirectVobSub->get_ExtendPicture(&m_HorExt, &m_VerExt, &m_ResX2, &m_ResX2minw, &m_ResX2minh);
+ m_pDirectVobSub->get_LoadSettings(&m_LoadLevel, &m_fExternalLoad, &m_fWebLoad, &m_fEmbeddedLoad);
+ }
}
void CDVSGeneralPPage::UpdateControlData(bool fSave)
{
- if (fSave) {
- if (m_verext.GetCurSel() >= 0) {
- m_VerExt = m_verext.GetItemData(m_verext.GetCurSel());
- }
- m_HorExt = !!m_mod32fix.GetCheck();
- if (m_resx2.GetCurSel() >= 0) {
- m_ResX2 = m_resx2.GetItemData(m_resx2.GetCurSel());
- }
- m_ResX2minw = m_resx2w.GetPos();
- m_ResX2minh = m_resx2h.GetPos();
- if (m_load.GetCurSel() >= 0) {
- m_LoadLevel = m_load.GetItemData(m_load.GetCurSel());
- }
- m_fExternalLoad = !!m_extload.GetCheck();
- m_fWebLoad = !!m_webload.GetCheck();
- m_fEmbeddedLoad = !!m_embload.GetCheck();
- } else {
- m_verext.ResetContent();
- m_verext.AddString(ResStr(IDS_ORGHEIGHT));
- m_verext.SetItemData(0, 0);
- m_verext.AddString(ResStr(IDS_EXTTO169));
- m_verext.SetItemData(1, 1);
- m_verext.AddString(ResStr(IDS_EXTTO43));
- m_verext.SetItemData(2, 2);
- m_verext.AddString(ResStr(IDS_EXTTO480));
- m_verext.SetItemData(3, 3);
- m_verext.AddString(ResStr(IDS_EXTTO576));
- m_verext.SetItemData(4, 4);
- m_verext.AddString(ResStr(IDS_CROPTO169));
- m_verext.SetItemData(5, 0x81);
- m_verext.AddString(ResStr(IDS_CROPTO43));
- m_verext.SetItemData(6, 0x82);
- m_verext.SetCurSel((m_VerExt&0x7f) + ((m_VerExt&0x80)?4:0));
- m_mod32fix.SetCheck(m_HorExt&1);
- m_resx2.ResetContent();
- m_resx2.AddString(ResStr(IDS_ORGRES));
- m_resx2.SetItemData(0, 0);
- m_resx2.AddString(ResStr(IDS_DBLRES));
- m_resx2.SetItemData(1, 1);
- m_resx2.AddString(ResStr(IDS_DBLRESIF));
- m_resx2.SetItemData(2, 2);
- m_resx2.SetCurSel(m_ResX2);
- m_resx2w.SetRange(0, 2048);
- m_resx2w.SetPos(m_ResX2minw);
- m_resx2w.EnableWindow(m_ResX2 == 2);
- m_resx2h.SetRange(0, 2048);
- m_resx2h.SetPos(m_ResX2minh);
- m_resx2h.EnableWindow(m_ResX2 == 2);
- m_load.ResetContent();
- m_load.AddString(ResStr(IDS_DONOTLOAD));
- m_load.SetItemData(0, 2);
- m_load.AddString(ResStr(IDS_LOADWHENNEEDED));
- m_load.SetItemData(1, 0);
- m_load.AddString(ResStr(IDS_ALWAYSLOAD));
- m_load.SetItemData(2, 1);
- m_load.SetCurSel(!m_LoadLevel?1:m_LoadLevel==1?2:0);
- m_extload.SetCheck(m_fExternalLoad);
- m_webload.SetCheck(m_fWebLoad);
- m_embload.SetCheck(m_fEmbeddedLoad);
- m_extload.EnableWindow(m_load.GetCurSel() == 1);
- m_webload.EnableWindow(m_load.GetCurSel() == 1);
- m_embload.EnableWindow(m_load.GetCurSel() == 1);
- }
+ if (fSave) {
+ if (m_verext.GetCurSel() >= 0) {
+ m_VerExt = m_verext.GetItemData(m_verext.GetCurSel());
+ }
+ m_HorExt = !!m_mod32fix.GetCheck();
+ if (m_resx2.GetCurSel() >= 0) {
+ m_ResX2 = m_resx2.GetItemData(m_resx2.GetCurSel());
+ }
+ m_ResX2minw = m_resx2w.GetPos();
+ m_ResX2minh = m_resx2h.GetPos();
+ if (m_load.GetCurSel() >= 0) {
+ m_LoadLevel = m_load.GetItemData(m_load.GetCurSel());
+ }
+ m_fExternalLoad = !!m_extload.GetCheck();
+ m_fWebLoad = !!m_webload.GetCheck();
+ m_fEmbeddedLoad = !!m_embload.GetCheck();
+ } else {
+ m_verext.ResetContent();
+ m_verext.AddString(ResStr(IDS_ORGHEIGHT));
+ m_verext.SetItemData(0, 0);
+ m_verext.AddString(ResStr(IDS_EXTTO169));
+ m_verext.SetItemData(1, 1);
+ m_verext.AddString(ResStr(IDS_EXTTO43));
+ m_verext.SetItemData(2, 2);
+ m_verext.AddString(ResStr(IDS_EXTTO480));
+ m_verext.SetItemData(3, 3);
+ m_verext.AddString(ResStr(IDS_EXTTO576));
+ m_verext.SetItemData(4, 4);
+ m_verext.AddString(ResStr(IDS_CROPTO169));
+ m_verext.SetItemData(5, 0x81);
+ m_verext.AddString(ResStr(IDS_CROPTO43));
+ m_verext.SetItemData(6, 0x82);
+ m_verext.SetCurSel((m_VerExt & 0x7f) + ((m_VerExt & 0x80) ? 4 : 0));
+ m_mod32fix.SetCheck(m_HorExt & 1);
+ m_resx2.ResetContent();
+ m_resx2.AddString(ResStr(IDS_ORGRES));
+ m_resx2.SetItemData(0, 0);
+ m_resx2.AddString(ResStr(IDS_DBLRES));
+ m_resx2.SetItemData(1, 1);
+ m_resx2.AddString(ResStr(IDS_DBLRESIF));
+ m_resx2.SetItemData(2, 2);
+ m_resx2.SetCurSel(m_ResX2);
+ m_resx2w.SetRange(0, 2048);
+ m_resx2w.SetPos(m_ResX2minw);
+ m_resx2w.EnableWindow(m_ResX2 == 2);
+ m_resx2h.SetRange(0, 2048);
+ m_resx2h.SetPos(m_ResX2minh);
+ m_resx2h.EnableWindow(m_ResX2 == 2);
+ m_load.ResetContent();
+ m_load.AddString(ResStr(IDS_DONOTLOAD));
+ m_load.SetItemData(0, 2);
+ m_load.AddString(ResStr(IDS_LOADWHENNEEDED));
+ m_load.SetItemData(1, 0);
+ m_load.AddString(ResStr(IDS_ALWAYSLOAD));
+ m_load.SetItemData(2, 1);
+ m_load.SetCurSel(!m_LoadLevel ? 1 : m_LoadLevel == 1 ? 2 : 0);
+ m_extload.SetCheck(m_fExternalLoad);
+ m_webload.SetCheck(m_fWebLoad);
+ m_embload.SetCheck(m_fEmbeddedLoad);
+ m_extload.EnableWindow(m_load.GetCurSel() == 1);
+ m_webload.EnableWindow(m_load.GetCurSel() == 1);
+ m_embload.EnableWindow(m_load.GetCurSel() == 1);
+ }
}
/* CDVSMiscPPage */
CDVSMiscPPage::CDVSMiscPPage(LPUNKNOWN pUnk, HRESULT* phr) :
- CDVSBasePPage(NAME("DirectVobSub Property Page (misc settings)"), pUnk, IDD_DVSMISCPAGE, IDD_DVSMISCPAGE)
+ CDVSBasePPage(NAME("DirectVobSub Property Page (misc settings)"), pUnk, IDD_DVSMISCPAGE, IDD_DVSMISCPAGE)
{
- BindControl(IDC_FLIP, m_flippic);
- BindControl(IDC_FLIPSUB, m_flipsub);
- BindControl(IDC_HIDE, m_hidesub);
- BindControl(IDC_SHOWOSDSTATS, m_showosd);
- BindControl(IDC_PREBUFFERING, m_subpicttobuff);
- BindControl(IDC_ANIMWHENBUFFERING, m_animwhenbuff);
- BindControl(IDC_AUTORELOAD, m_autoreload);
- BindControl(IDC_SAVEFULLPATH, m_savefullpath);
- BindControl(IDC_INSTANTUPDATE, m_instupd);
+ BindControl(IDC_FLIP, m_flippic);
+ BindControl(IDC_FLIPSUB, m_flipsub);
+ BindControl(IDC_HIDE, m_hidesub);
+ BindControl(IDC_SHOWOSDSTATS, m_showosd);
+ BindControl(IDC_PREBUFFERING, m_subpicttobuff);
+ BindControl(IDC_ANIMWHENBUFFERING, m_animwhenbuff);
+ BindControl(IDC_AUTORELOAD, m_autoreload);
+ BindControl(IDC_SAVEFULLPATH, m_savefullpath);
+ BindControl(IDC_INSTANTUPDATE, m_instupd);
}
bool CDVSMiscPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch (uMsg) {
- case WM_COMMAND: {
- switch (HIWORD(wParam)) {
- case BN_CLICKED: {
- if (LOWORD(wParam) == IDC_INSTANTUPDATE) {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INSTANTUPDATE), !!m_instupd.GetCheck());
- return true;
- }
- }
- break;
- }
- }
- break;
- }
-
- return false;
+ switch (uMsg) {
+ case WM_COMMAND: {
+ switch (HIWORD(wParam)) {
+ case BN_CLICKED: {
+ if (LOWORD(wParam) == IDC_INSTANTUPDATE) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INSTANTUPDATE), !!m_instupd.GetCheck());
+ return true;
+ }
+ }
+ break;
+ }
+ }
+ break;
+ }
+
+ return false;
}
void CDVSMiscPPage::UpdateObjectData(bool fSave)
{
- if (fSave) {
- m_pDirectVobSub->put_Flip(m_fFlipPicture, m_fFlipSubtitles);
- m_pDirectVobSub->put_HideSubtitles(m_fHideSubtitles);
- m_pDirectVobSub->put_OSD(m_fOSD);
- m_pDirectVobSub->put_SubPictToBuffer(m_uSubPictToBuffer);
- m_pDirectVobSub->put_AnimWhenBuffering(m_fAnimWhenBuffering);
- m_pDirectVobSub->put_SubtitleReloader(m_fReloaderDisabled);
- m_pDirectVobSub->put_SaveFullPath(m_fSaveFullPath);
- } else {
- m_pDirectVobSub->get_Flip(&m_fFlipPicture, &m_fFlipSubtitles);
- m_pDirectVobSub->get_HideSubtitles(&m_fHideSubtitles);
- m_pDirectVobSub->get_OSD(&m_fOSD);
- m_pDirectVobSub->get_SubPictToBuffer(&m_uSubPictToBuffer);
- m_pDirectVobSub->get_AnimWhenBuffering(&m_fAnimWhenBuffering);
- m_pDirectVobSub->get_SubtitleReloader(&m_fReloaderDisabled);
- m_pDirectVobSub->get_SaveFullPath(&m_fSaveFullPath);
- }
+ if (fSave) {
+ m_pDirectVobSub->put_Flip(m_fFlipPicture, m_fFlipSubtitles);
+ m_pDirectVobSub->put_HideSubtitles(m_fHideSubtitles);
+ m_pDirectVobSub->put_OSD(m_fOSD);
+ m_pDirectVobSub->put_SubPictToBuffer(m_uSubPictToBuffer);
+ m_pDirectVobSub->put_AnimWhenBuffering(m_fAnimWhenBuffering);
+ m_pDirectVobSub->put_SubtitleReloader(m_fReloaderDisabled);
+ m_pDirectVobSub->put_SaveFullPath(m_fSaveFullPath);
+ } else {
+ m_pDirectVobSub->get_Flip(&m_fFlipPicture, &m_fFlipSubtitles);
+ m_pDirectVobSub->get_HideSubtitles(&m_fHideSubtitles);
+ m_pDirectVobSub->get_OSD(&m_fOSD);
+ m_pDirectVobSub->get_SubPictToBuffer(&m_uSubPictToBuffer);
+ m_pDirectVobSub->get_AnimWhenBuffering(&m_fAnimWhenBuffering);
+ m_pDirectVobSub->get_SubtitleReloader(&m_fReloaderDisabled);
+ m_pDirectVobSub->get_SaveFullPath(&m_fSaveFullPath);
+ }
}
void CDVSMiscPPage::UpdateControlData(bool fSave)
{
- if (fSave) {
- m_fFlipPicture = !!m_flippic.GetCheck();
- m_fFlipSubtitles = !!m_flipsub.GetCheck();
- m_fHideSubtitles = !!m_hidesub.GetCheck();
- m_fSaveFullPath = !!m_savefullpath.GetCheck();
- m_uSubPictToBuffer = m_subpicttobuff.GetPos();
- m_fAnimWhenBuffering = !!m_animwhenbuff.GetCheck();
- m_fOSD = !!m_showosd.GetCheck();
- m_fReloaderDisabled = !m_autoreload.GetCheck();
- } else {
- m_flippic.SetCheck(m_fFlipPicture);
- m_flipsub.SetCheck(m_fFlipSubtitles);
- m_hidesub.SetCheck(m_fHideSubtitles);
- m_savefullpath.SetCheck(m_fSaveFullPath);
- m_subpicttobuff.SetPos(m_uSubPictToBuffer);
- m_subpicttobuff.SetRange(0, 60);
- m_animwhenbuff.SetCheck(m_fAnimWhenBuffering);
- m_showosd.SetCheck(m_fOSD);
- m_autoreload.SetCheck(!m_fReloaderDisabled);
- m_instupd.SetCheck(!!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INSTANTUPDATE), 1));
- }
+ if (fSave) {
+ m_fFlipPicture = !!m_flippic.GetCheck();
+ m_fFlipSubtitles = !!m_flipsub.GetCheck();
+ m_fHideSubtitles = !!m_hidesub.GetCheck();
+ m_fSaveFullPath = !!m_savefullpath.GetCheck();
+ m_uSubPictToBuffer = m_subpicttobuff.GetPos();
+ m_fAnimWhenBuffering = !!m_animwhenbuff.GetCheck();
+ m_fOSD = !!m_showosd.GetCheck();
+ m_fReloaderDisabled = !m_autoreload.GetCheck();
+ } else {
+ m_flippic.SetCheck(m_fFlipPicture);
+ m_flipsub.SetCheck(m_fFlipSubtitles);
+ m_hidesub.SetCheck(m_fHideSubtitles);
+ m_savefullpath.SetCheck(m_fSaveFullPath);
+ m_subpicttobuff.SetPos(m_uSubPictToBuffer);
+ m_subpicttobuff.SetRange(0, 60);
+ m_animwhenbuff.SetCheck(m_fAnimWhenBuffering);
+ m_showosd.SetCheck(m_fOSD);
+ m_autoreload.SetCheck(!m_fReloaderDisabled);
+ m_instupd.SetCheck(!!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INSTANTUPDATE), 1));
+ }
}
/* CDVSTimingPPage */
CDVSTimingPPage::CDVSTimingPPage(LPUNKNOWN pUnk, HRESULT* phr) :
- CDVSBasePPage(NAME("DirectVobSub Timing Property Page"), pUnk, IDD_DVSTIMINGPAGE, IDD_DVSTIMINGPAGE)
+ CDVSBasePPage(NAME("DirectVobSub Timing Property Page"), pUnk, IDD_DVSTIMINGPAGE, IDD_DVSTIMINGPAGE)
{
- BindControl(IDC_MODFPS, m_modfps);
- BindControl(IDC_FPS, m_fps);
- BindControl(IDC_SPIN5, m_subdelay);
- BindControl(IDC_SPIN6, m_subspeedmul);
- BindControl(IDC_SPIN9, m_subspeeddiv);
+ BindControl(IDC_MODFPS, m_modfps);
+ BindControl(IDC_FPS, m_fps);
+ BindControl(IDC_SPIN5, m_subdelay);
+ BindControl(IDC_SPIN6, m_subspeedmul);
+ BindControl(IDC_SPIN9, m_subspeeddiv);
}
bool CDVSTimingPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch (uMsg) {
- case WM_COMMAND: {
- switch (HIWORD(wParam)) {
- case BN_CLICKED: {
- if (LOWORD(wParam) == IDC_MODFPS) {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- m_fps.EnableWindow(!!m_modfps.GetCheck());
- return true;
- }
- }
- break;
- }
- }
- break;
- }
-
- return false;
+ switch (uMsg) {
+ case WM_COMMAND: {
+ switch (HIWORD(wParam)) {
+ case BN_CLICKED: {
+ if (LOWORD(wParam) == IDC_MODFPS) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ m_fps.EnableWindow(!!m_modfps.GetCheck());
+ return true;
+ }
+ }
+ break;
+ }
+ }
+ break;
+ }
+
+ return false;
}
void CDVSTimingPPage::UpdateObjectData(bool fSave)
{
- if (fSave) {
- m_pDirectVobSub->put_SubtitleTiming(m_SubtitleDelay, m_SubtitleSpeedMul, m_SubtitleSpeedDiv);
- m_pDirectVobSub->put_MediaFPS(m_fMediaFPSEnabled, m_MediaFPS);
- } else {
- m_pDirectVobSub->get_SubtitleTiming(&m_SubtitleDelay, &m_SubtitleSpeedMul, &m_SubtitleSpeedDiv);
- m_pDirectVobSub->get_MediaFPS(&m_fMediaFPSEnabled, &m_MediaFPS);
- }
+ if (fSave) {
+ m_pDirectVobSub->put_SubtitleTiming(m_SubtitleDelay, m_SubtitleSpeedMul, m_SubtitleSpeedDiv);
+ m_pDirectVobSub->put_MediaFPS(m_fMediaFPSEnabled, m_MediaFPS);
+ } else {
+ m_pDirectVobSub->get_SubtitleTiming(&m_SubtitleDelay, &m_SubtitleSpeedMul, &m_SubtitleSpeedDiv);
+ m_pDirectVobSub->get_MediaFPS(&m_fMediaFPSEnabled, &m_MediaFPS);
+ }
}
void CDVSTimingPPage::UpdateControlData(bool fSave)
{
- if (fSave) {
- m_fMediaFPSEnabled = !!m_modfps.GetCheck();
- CString fpsstr;
- m_fps.GetWindowText(fpsstr);
- float fps;
- if (_stscanf_s(fpsstr, _T("%f"), &fps) == 1) {
- m_MediaFPS = fps;
- }
- m_SubtitleDelay = m_subdelay.GetPos32();
- m_SubtitleSpeedMul = m_subspeedmul.GetPos32();
- m_SubtitleSpeedDiv = m_subspeeddiv.GetPos32();
- } else {
- m_modfps.SetCheck(m_fMediaFPSEnabled);
- CString fpsstr;
- fpsstr.Format(_T("%.4f"), m_MediaFPS);
- m_fps.SetWindowText(fpsstr);
- m_fps.EnableWindow(m_fMediaFPSEnabled);
- m_subdelay.SetRange32(-180*60*1000, 180*60*1000);
- m_subspeedmul.SetRange32(0, 1000000);
- m_subspeeddiv.SetRange32(1, 1000000);
- m_subdelay.SetPos32(m_SubtitleDelay);
- m_subspeedmul.SetPos32(m_SubtitleSpeedMul);
- m_subspeeddiv.SetPos32(m_SubtitleSpeedDiv);
- }
+ if (fSave) {
+ m_fMediaFPSEnabled = !!m_modfps.GetCheck();
+ CString fpsstr;
+ m_fps.GetWindowText(fpsstr);
+ float fps;
+ if (_stscanf_s(fpsstr, _T("%f"), &fps) == 1) {
+ m_MediaFPS = fps;
+ }
+ m_SubtitleDelay = m_subdelay.GetPos32();
+ m_SubtitleSpeedMul = m_subspeedmul.GetPos32();
+ m_SubtitleSpeedDiv = m_subspeeddiv.GetPos32();
+ } else {
+ m_modfps.SetCheck(m_fMediaFPSEnabled);
+ CString fpsstr;
+ fpsstr.Format(_T("%.4f"), m_MediaFPS);
+ m_fps.SetWindowText(fpsstr);
+ m_fps.EnableWindow(m_fMediaFPSEnabled);
+ m_subdelay.SetRange32(-180 * 60 * 1000, 180 * 60 * 1000);
+ m_subspeedmul.SetRange32(0, 1000000);
+ m_subspeeddiv.SetRange32(1, 1000000);
+ m_subdelay.SetPos32(m_SubtitleDelay);
+ m_subspeedmul.SetPos32(m_SubtitleSpeedMul);
+ m_subspeeddiv.SetPos32(m_SubtitleSpeedDiv);
+ }
}
/* CDVSAboutPPage */
CDVSAboutPPage::CDVSAboutPPage(LPUNKNOWN lpunk, HRESULT* phr) :
- CDVSBasePPage(NAME("About Property Page"), lpunk, IDD_DVSABOUTPAGE, IDD_DVSABOUTPAGE)
+ CDVSBasePPage(NAME("About Property Page"), lpunk, IDD_DVSABOUTPAGE, IDD_DVSABOUTPAGE)
{
}
bool CDVSAboutPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch (uMsg) {
- case WM_INITDIALOG: {
- SetDlgItemTextA(m_Dlg, IDC_VERSION, "DirectVobSub 2.41."MAKE_STR(MPC_VERSION_REV)" "MPC_VERSION_ARCH"\nCopyright 2001-2012 MPC-HC Team");
- }
- break;
- case WM_COMMAND: {
- switch (HIWORD(wParam)) {
- case BN_CLICKED: {
- if (LOWORD(wParam) == IDC_HOMEPAGEBTN) {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- ShellExecute(m_Dlg, _T("open"), ResStr(IDS_URL_HOMEPAGE), NULL, NULL, SW_SHOWNORMAL);
- return true;
- } else if (LOWORD(wParam) == IDC_BUGREPORTBTN) {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- ShellExecute(m_Dlg, _T("open"), ResStr(IDS_URL_EMAIL), NULL, NULL, SW_SHOWNORMAL);
- return true;
- }
- }
- break;
- }
- }
- break;
- }
-
- return false;
+ switch (uMsg) {
+ case WM_INITDIALOG: {
+ SetDlgItemTextA(m_Dlg, IDC_VERSION, "DirectVobSub 2.41."MAKE_STR(MPC_VERSION_REV)" "MPC_VERSION_ARCH"\nCopyright 2001-2012 MPC-HC Team");
+ }
+ break;
+ case WM_COMMAND: {
+ switch (HIWORD(wParam)) {
+ case BN_CLICKED: {
+ if (LOWORD(wParam) == IDC_HOMEPAGEBTN) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ ShellExecute(m_Dlg, _T("open"), ResStr(IDS_URL_HOMEPAGE), NULL, NULL, SW_SHOWNORMAL);
+ return true;
+ } else if (LOWORD(wParam) == IDC_BUGREPORTBTN) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ ShellExecute(m_Dlg, _T("open"), ResStr(IDS_URL_EMAIL), NULL, NULL, SW_SHOWNORMAL);
+ return true;
+ }
+ }
+ break;
+ }
+ }
+ break;
+ }
+
+ return false;
}
/* CDVSZoomPPage */
CDVSZoomPPage::CDVSZoomPPage(LPUNKNOWN pUnk, HRESULT* phr) :
- CDVSBasePPage(NAME("DirectVobSub Zoom Property Page"), pUnk, IDD_DVSZOOMPAGE, IDD_DVSZOOMPAGE)
+ CDVSBasePPage(NAME("DirectVobSub Zoom Property Page"), pUnk, IDD_DVSZOOMPAGE, IDD_DVSZOOMPAGE)
{
- BindControl(IDC_SPIN1, m_posx);
- BindControl(IDC_SPIN2, m_posy);
- BindControl(IDC_SPIN7, m_scalex);
- BindControl(IDC_SPIN8, m_scaley);
+ BindControl(IDC_SPIN1, m_posx);
+ BindControl(IDC_SPIN2, m_posy);
+ BindControl(IDC_SPIN7, m_scalex);
+ BindControl(IDC_SPIN8, m_scaley);
}
bool CDVSZoomPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch (uMsg) {
- case WM_COMMAND: {
- switch (HIWORD(wParam)) {
- case EN_CHANGE: {
- if (LOWORD(wParam) == IDC_EDIT1 || LOWORD(wParam) == IDC_EDIT2
- || LOWORD(wParam) == IDC_EDIT7 || LOWORD(wParam) == IDC_EDIT8) {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- UpdateControlData(true);
- UpdateObjectData(true);
- return true;
- }
- }
-
- break;
- }
- }
- break;
- }
-
- return false;
+ switch (uMsg) {
+ case WM_COMMAND: {
+ switch (HIWORD(wParam)) {
+ case EN_CHANGE: {
+ if (LOWORD(wParam) == IDC_EDIT1 || LOWORD(wParam) == IDC_EDIT2
+ || LOWORD(wParam) == IDC_EDIT7 || LOWORD(wParam) == IDC_EDIT8) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ UpdateControlData(true);
+ UpdateObjectData(true);
+ return true;
+ }
+ }
+
+ break;
+ }
+ }
+ break;
+ }
+
+ return false;
}
void CDVSZoomPPage::UpdateControlData(bool fSave)
{
- if (fSave) {
- m_rect.left = 1.0f * (short)m_posx.GetPos() / 100;
- m_rect.top = 1.0f * (short)m_posy.GetPos() / 100;
- m_rect.right = m_rect.left + 1.0f * (short)m_scalex.GetPos() / 100;
- m_rect.bottom = m_rect.top + 1.0f * (short)m_scaley.GetPos() / 100;
- } else {
- m_posx.SetRange(-100, 100);
- m_posx.SetPos((int)(m_rect.left*100));
- m_posy.SetRange(-100, 100);
- m_posy.SetPos((int)(m_rect.top*100));
- m_scalex.SetRange(-300, 300);
- m_scalex.SetPos((int)((m_rect.right-m_rect.left)*100));
- m_scaley.SetRange(-300, 300);
- m_scaley.SetPos((int)((m_rect.bottom-m_rect.top)*100));
- }
+ if (fSave) {
+ m_rect.left = 1.0f * (short)m_posx.GetPos() / 100;
+ m_rect.top = 1.0f * (short)m_posy.GetPos() / 100;
+ m_rect.right = m_rect.left + 1.0f * (short)m_scalex.GetPos() / 100;
+ m_rect.bottom = m_rect.top + 1.0f * (short)m_scaley.GetPos() / 100;
+ } else {
+ m_posx.SetRange(-100, 100);
+ m_posx.SetPos((int)(m_rect.left * 100));
+ m_posy.SetRange(-100, 100);
+ m_posy.SetPos((int)(m_rect.top * 100));
+ m_scalex.SetRange(-300, 300);
+ m_scalex.SetPos((int)((m_rect.right - m_rect.left) * 100));
+ m_scaley.SetRange(-300, 300);
+ m_scaley.SetPos((int)((m_rect.bottom - m_rect.top) * 100));
+ }
}
void CDVSZoomPPage::UpdateObjectData(bool fSave)
{
- if (fSave) {
- m_pDirectVobSub->put_ZoomRect(&m_rect);
- } else {
- m_pDirectVobSub->get_ZoomRect(&m_rect);
- }
+ if (fSave) {
+ m_pDirectVobSub->put_ZoomRect(&m_rect);
+ } else {
+ m_pDirectVobSub->get_ZoomRect(&m_rect);
+ }
}
// TODO: Make CDVSColorPPage and CDVSPathsPPage use an interface on DirectVobSub instead of the registry to communicate
@@ -855,294 +855,294 @@ void CDVSZoomPPage::UpdateObjectData(bool fSave)
/* CDVSColorPPage */
CDVSColorPPage::CDVSColorPPage(LPUNKNOWN pUnk, HRESULT* phr) :
- CDVSBasePPage(NAME("DirectVobSub Color Property Page"), pUnk, IDD_DVSCOLORPAGE, IDD_DVSCOLORPAGE)
+ CDVSBasePPage(NAME("DirectVobSub Color Property Page"), pUnk, IDD_DVSCOLORPAGE, IDD_DVSCOLORPAGE)
{
- BindControl(IDC_PREFLIST, m_preflist);
- BindControl(IDC_DYNCHGLIST, m_dynchglist);
- BindControl(IDC_FORCERGBCHK, m_forcergb);
+ BindControl(IDC_PREFLIST, m_preflist);
+ BindControl(IDC_DYNCHGLIST, m_dynchglist);
+ BindControl(IDC_FORCERGBCHK, m_forcergb);
- m_fDisableInstantUpdate = true;
+ m_fDisableInstantUpdate = true;
}
bool CDVSColorPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch (uMsg) {
- case WM_COMMAND: {
- switch (HIWORD(wParam)) {
- case LBN_DBLCLK:
- if ((HWND)lParam == m_dynchglist.m_hWnd) {
- int old = -1;
- m_pDirectVobSub->get_ColorFormat(&old);
- if (FAILED(m_pDirectVobSub->put_ColorFormat(m_dynchglist.GetCurSel()))) {
- m_dynchglist.SetCurSel(old);
- }
-
- return true;
- }
- break;
-
- case BN_CLICKED: {
- switch (LOWORD(wParam)) {
- case IDC_COLORCHANGE: {
- int old = -1;
- m_pDirectVobSub->get_ColorFormat(&old);
- if (FAILED(m_pDirectVobSub->put_ColorFormat(m_dynchglist.GetCurSel()))) {
- m_dynchglist.SetCurSel(old);
- }
-
- return true;
- }
- case IDC_COLORUP: {
- int sel = m_preflist.GetCurSel();
- if (sel > 0) {
- CString str;
- m_preflist.GetText(sel, str);
- int iPos = (int)m_preflist.GetItemData(sel);
- m_preflist.DeleteString(sel);
- sel--;
- m_preflist.InsertString(sel, str);
- m_preflist.SetItemData(sel, iPos);
- m_preflist.SetCurSel(sel);
- }
-
- return true;
- }
- case IDC_COLORDOWN: {
- int sel = m_preflist.GetCurSel();
- if (sel >= 0 && sel < m_preflist.GetCount()-1) {
- CString str;
- m_preflist.GetText(sel, str);
- int iPos = (int)m_preflist.GetItemData(sel);
- m_preflist.DeleteString(sel);
- sel++;
- m_preflist.InsertString(sel, str);
- m_preflist.SetItemData(sel, iPos);
- m_preflist.SetCurSel(sel);
- }
-
- return true;
- }
- }
- }
- break;
- }
- }
- break;
- }
-
- return false;
+ switch (uMsg) {
+ case WM_COMMAND: {
+ switch (HIWORD(wParam)) {
+ case LBN_DBLCLK:
+ if ((HWND)lParam == m_dynchglist.m_hWnd) {
+ int old = -1;
+ m_pDirectVobSub->get_ColorFormat(&old);
+ if (FAILED(m_pDirectVobSub->put_ColorFormat(m_dynchglist.GetCurSel()))) {
+ m_dynchglist.SetCurSel(old);
+ }
+
+ return true;
+ }
+ break;
+
+ case BN_CLICKED: {
+ switch (LOWORD(wParam)) {
+ case IDC_COLORCHANGE: {
+ int old = -1;
+ m_pDirectVobSub->get_ColorFormat(&old);
+ if (FAILED(m_pDirectVobSub->put_ColorFormat(m_dynchglist.GetCurSel()))) {
+ m_dynchglist.SetCurSel(old);
+ }
+
+ return true;
+ }
+ case IDC_COLORUP: {
+ int sel = m_preflist.GetCurSel();
+ if (sel > 0) {
+ CString str;
+ m_preflist.GetText(sel, str);
+ int iPos = (int)m_preflist.GetItemData(sel);
+ m_preflist.DeleteString(sel);
+ sel--;
+ m_preflist.InsertString(sel, str);
+ m_preflist.SetItemData(sel, iPos);
+ m_preflist.SetCurSel(sel);
+ }
+
+ return true;
+ }
+ case IDC_COLORDOWN: {
+ int sel = m_preflist.GetCurSel();
+ if (sel >= 0 && sel < m_preflist.GetCount() - 1) {
+ CString str;
+ m_preflist.GetText(sel, str);
+ int iPos = (int)m_preflist.GetItemData(sel);
+ m_preflist.DeleteString(sel);
+ sel++;
+ m_preflist.InsertString(sel, str);
+ m_preflist.SetItemData(sel, iPos);
+ m_preflist.SetCurSel(sel);
+ }
+
+ return true;
+ }
+ }
+ }
+ break;
+ }
+ }
+ break;
+ }
+
+ return false;
}
void CDVSColorPPage::UpdateObjectData(bool fSave)
{
- if (fSave) {
- } else {
- }
+ if (fSave) {
+ } else {
+ }
}
void CDVSColorPPage::UpdateControlData(bool fSave)
{
- if (fSave) {
- if ((UINT)m_preflist.GetCount() == VIHSIZE) {
- BYTE* pData = DNew BYTE[VIHSIZE];
-
- for (ptrdiff_t i = 0; i < m_preflist.GetCount(); i++) {
- pData[i] = (BYTE)m_preflist.GetItemData(i);
- }
-
- theApp.WriteProfileBinary(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_COLORFORMATS), pData, VIHSIZE);
-
- delete [] pData;
- } else {
- ASSERT(0);
- }
-
- theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_FORCERGB), !!m_forcergb.GetCheck());
- } else {
- m_preflist.ResetContent();
- m_dynchglist.ResetContent();
-
- BYTE* pData = NULL;
- UINT nSize;
-
- if (!theApp.GetProfileBinary(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_COLORFORMATS), &pData, &nSize)
- || !pData || nSize != VIHSIZE) {
- if (pData) {
- delete [] pData, pData = NULL;
- }
-
- nSize = VIHSIZE;
- pData = DNew BYTE[VIHSIZE];
- for (size_t i = 0; i < VIHSIZE; i++) {
- pData[i] = i;
- }
- }
-
- if (pData) {
- for (ptrdiff_t i = 0; i < (int)nSize; i++) {
- m_dynchglist.AddString(VIH2String(pData[i]));
- m_dynchglist.SetItemData(i, pData[i]);
- m_preflist.AddString(VIH2String(pData[i]));
- m_preflist.SetItemData(i, pData[i]);
- }
-
- int iPosition = -1;
- m_pDirectVobSub->get_ColorFormat(&iPosition);
- m_dynchglist.SetCurSel(iPosition);
-
- delete [] pData;
- }
-
- m_forcergb.SetCheck(theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_FORCERGB), 0)?BST_CHECKED:BST_UNCHECKED);
- }
+ if (fSave) {
+ if ((UINT)m_preflist.GetCount() == VIHSIZE) {
+ BYTE* pData = DNew BYTE[VIHSIZE];
+
+ for (ptrdiff_t i = 0; i < m_preflist.GetCount(); i++) {
+ pData[i] = (BYTE)m_preflist.GetItemData(i);
+ }
+
+ theApp.WriteProfileBinary(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_COLORFORMATS), pData, VIHSIZE);
+
+ delete [] pData;
+ } else {
+ ASSERT(0);
+ }
+
+ theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_FORCERGB), !!m_forcergb.GetCheck());
+ } else {
+ m_preflist.ResetContent();
+ m_dynchglist.ResetContent();
+
+ BYTE* pData = NULL;
+ UINT nSize;
+
+ if (!theApp.GetProfileBinary(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_COLORFORMATS), &pData, &nSize)
+ || !pData || nSize != VIHSIZE) {
+ if (pData) {
+ delete [] pData, pData = NULL;
+ }
+
+ nSize = VIHSIZE;
+ pData = DNew BYTE[VIHSIZE];
+ for (size_t i = 0; i < VIHSIZE; i++) {
+ pData[i] = i;
+ }
+ }
+
+ if (pData) {
+ for (ptrdiff_t i = 0; i < (int)nSize; i++) {
+ m_dynchglist.AddString(VIH2String(pData[i]));
+ m_dynchglist.SetItemData(i, pData[i]);
+ m_preflist.AddString(VIH2String(pData[i]));
+ m_preflist.SetItemData(i, pData[i]);
+ }
+
+ int iPosition = -1;
+ m_pDirectVobSub->get_ColorFormat(&iPosition);
+ m_dynchglist.SetCurSel(iPosition);
+
+ delete [] pData;
+ }
+
+ m_forcergb.SetCheck(theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_FORCERGB), 0) ? BST_CHECKED : BST_UNCHECKED);
+ }
}
/* CDVSPathsPPage */
CDVSPathsPPage::CDVSPathsPPage(LPUNKNOWN pUnk, HRESULT* phr) :
- CDVSBasePPage(NAME("DirectVobSub Paths Property Page"), pUnk, IDD_DVSPATHSPAGE, IDD_DVSPATHSPAGE)
+ CDVSBasePPage(NAME("DirectVobSub Paths Property Page"), pUnk, IDD_DVSPATHSPAGE, IDD_DVSPATHSPAGE)
{
- BindControl(IDC_PATHLIST, m_pathlist);
- BindControl(IDC_PATHEDIT, m_path);
- BindControl(IDC_BROWSE, m_browse);
- BindControl(IDC_REMOVE, m_remove);
- BindControl(IDC_ADD, m_add);
+ BindControl(IDC_PATHLIST, m_pathlist);
+ BindControl(IDC_PATHEDIT, m_path);
+ BindControl(IDC_BROWSE, m_browse);
+ BindControl(IDC_REMOVE, m_remove);
+ BindControl(IDC_ADD, m_add);
- m_fDisableInstantUpdate = true;
+ m_fDisableInstantUpdate = true;
}
bool CDVSPathsPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch (uMsg) {
- case WM_COMMAND: {
- switch (HIWORD(wParam)) {
- case LBN_SELCHANGE:
- if ((HWND)lParam == m_pathlist.m_hWnd) {
- int i = m_pathlist.GetCurSel();
- m_remove.EnableWindow(i >= 3 ? TRUE : FALSE);
- if (i >= 0) {
- CString path;
- m_pathlist.GetText(i, path);
- m_path.SetWindowText(path);
- }
- return true;
- }
- break;
-
- case LBN_SELCANCEL:
- if ((HWND)lParam == m_pathlist.m_hWnd) {
- m_remove.EnableWindow(FALSE);
- return true;
- }
- break;
-
- case BN_CLICKED: {
- switch (LOWORD(wParam)) {
- case IDC_BROWSE: {
- TCHAR pathbuff[_MAX_PATH];
-
- BROWSEINFO bi;
- bi.hwndOwner = m_Dlg;
- bi.pidlRoot = NULL;
- bi.pszDisplayName = pathbuff;
- bi.lpszTitle = _T("");
- bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_EDITBOX | BIF_VALIDATE | BIF_USENEWUI;
- bi.lpfn = NULL;
- bi.lParam = 0;
- bi.iImage = 0;
-
- LPITEMIDLIST iil = SHBrowseForFolder(&bi);
- if (iil) {
- SHGetPathFromIDList(iil, pathbuff);
- m_path.SetWindowText(pathbuff);
- }
-
- return true;
- }
- break;
-
- case IDC_REMOVE: {
- int i = m_pathlist.GetCurSel();
- if (i >= 0) {
- m_pathlist.DeleteString(i);
- i = min(i, m_pathlist.GetCount()-1);
- if (i >= 0 && m_pathlist.GetCount() > 0) {
- m_pathlist.SetCurSel(i);
- m_remove.EnableWindow(i >= 3 ? TRUE : FALSE);
- }
- }
-
- return true;
- }
- break;
-
- case IDC_ADD: {
- CString path;
- m_path.GetWindowText(path);
- if (!path.IsEmpty() && m_pathlist.FindString(-1, path) < 0) {
- m_pathlist.AddString(path);
- }
-
- return true;
- }
- break;
- }
- }
- break;
- }
- }
- break;
- }
-
- return false;
+ switch (uMsg) {
+ case WM_COMMAND: {
+ switch (HIWORD(wParam)) {
+ case LBN_SELCHANGE:
+ if ((HWND)lParam == m_pathlist.m_hWnd) {
+ int i = m_pathlist.GetCurSel();
+ m_remove.EnableWindow(i >= 3 ? TRUE : FALSE);
+ if (i >= 0) {
+ CString path;
+ m_pathlist.GetText(i, path);
+ m_path.SetWindowText(path);
+ }
+ return true;
+ }
+ break;
+
+ case LBN_SELCANCEL:
+ if ((HWND)lParam == m_pathlist.m_hWnd) {
+ m_remove.EnableWindow(FALSE);
+ return true;
+ }
+ break;
+
+ case BN_CLICKED: {
+ switch (LOWORD(wParam)) {
+ case IDC_BROWSE: {
+ TCHAR pathbuff[_MAX_PATH];
+
+ BROWSEINFO bi;
+ bi.hwndOwner = m_Dlg;
+ bi.pidlRoot = NULL;
+ bi.pszDisplayName = pathbuff;
+ bi.lpszTitle = _T("");
+ bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_EDITBOX | BIF_VALIDATE | BIF_USENEWUI;
+ bi.lpfn = NULL;
+ bi.lParam = 0;
+ bi.iImage = 0;
+
+ LPITEMIDLIST iil = SHBrowseForFolder(&bi);
+ if (iil) {
+ SHGetPathFromIDList(iil, pathbuff);
+ m_path.SetWindowText(pathbuff);
+ }
+
+ return true;
+ }
+ break;
+
+ case IDC_REMOVE: {
+ int i = m_pathlist.GetCurSel();
+ if (i >= 0) {
+ m_pathlist.DeleteString(i);
+ i = min(i, m_pathlist.GetCount() - 1);
+ if (i >= 0 && m_pathlist.GetCount() > 0) {
+ m_pathlist.SetCurSel(i);
+ m_remove.EnableWindow(i >= 3 ? TRUE : FALSE);
+ }
+ }
+
+ return true;
+ }
+ break;
+
+ case IDC_ADD: {
+ CString path;
+ m_path.GetWindowText(path);
+ if (!path.IsEmpty() && m_pathlist.FindString(-1, path) < 0) {
+ m_pathlist.AddString(path);
+ }
+
+ return true;
+ }
+ break;
+ }
+ }
+ break;
+ }
+ }
+ break;
+ }
+
+ return false;
}
void CDVSPathsPPage::UpdateObjectData(bool fSave)
{
- if (fSave) {
- CString chk(_T("123456789")), path, tmp;
- int i = 0;
- do {
- tmp.Format(IDS_RP_PATH, i++);
- path = theApp.GetProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, chk);
- if (path != chk) {
- theApp.WriteProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, _T(""));
- }
- } while (path != chk);
-
- for (i = 0; i < m_paths.GetSize(); i++) {
- tmp.Format(IDS_RP_PATH, i);
- theApp.WriteProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, m_paths[i]);
- }
- } else {
- CString chk(_T("123456789")), path, tmp;
- int i = 0;
- do {
- if (!path.IsEmpty()) {
- m_paths.Add(path);
- }
- tmp.Format(IDS_RP_PATH, i++);
- path = theApp.GetProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, chk);
- } while (path != chk);
- }
+ if (fSave) {
+ CString chk(_T("123456789")), path, tmp;
+ int i = 0;
+ do {
+ tmp.Format(IDS_RP_PATH, i++);
+ path = theApp.GetProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, chk);
+ if (path != chk) {
+ theApp.WriteProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, _T(""));
+ }
+ } while (path != chk);
+
+ for (i = 0; i < m_paths.GetSize(); i++) {
+ tmp.Format(IDS_RP_PATH, i);
+ theApp.WriteProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, m_paths[i]);
+ }
+ } else {
+ CString chk(_T("123456789")), path, tmp;
+ int i = 0;
+ do {
+ if (!path.IsEmpty()) {
+ m_paths.Add(path);
+ }
+ tmp.Format(IDS_RP_PATH, i++);
+ path = theApp.GetProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, chk);
+ } while (path != chk);
+ }
}
void CDVSPathsPPage::UpdateControlData(bool fSave)
{
- if (fSave) {
- m_paths.RemoveAll();
- for (int i = 0; i < m_pathlist.GetCount(); i++) {
- CString path;
- m_pathlist.GetText(i, path);
- m_paths.Add(path);
- }
- } else {
- m_pathlist.ResetContent();
- for (ptrdiff_t i = 0; i < m_paths.GetSize(); i++) {
- m_pathlist.AddString(m_paths[i]);
- }
-
- m_remove.EnableWindow(FALSE);
- m_add.EnableWindow(TRUE);
- }
+ if (fSave) {
+ m_paths.RemoveAll();
+ for (int i = 0; i < m_pathlist.GetCount(); i++) {
+ CString path;
+ m_pathlist.GetText(i, path);
+ m_paths.Add(path);
+ }
+ } else {
+ m_pathlist.ResetContent();
+ for (ptrdiff_t i = 0; i < m_paths.GetSize(); i++) {
+ m_pathlist.AddString(m_paths[i]);
+ }
+
+ m_remove.EnableWindow(FALSE);
+ m_add.EnableWindow(TRUE);
+ }
}
diff --git a/src/filters/transform/VSFilter/DirectVobSubPropPage.h b/src/filters/transform/VSFilter/DirectVobSubPropPage.h
index cb67f71cd..64a735954 100644
--- a/src/filters/transform/VSFilter/DirectVobSubPropPage.h
+++ b/src/filters/transform/VSFilter/DirectVobSubPropPage.h
@@ -29,188 +29,188 @@
class CDVSBasePPage : public CBasePropertyPage
{
public:
- // we have to override these to use external, resource-only dlls
- STDMETHODIMP GetPageInfo(LPPROPPAGEINFO pPageInfo);
- STDMETHODIMP Activate(HWND hwndParent, LPCRECT pRect, BOOL fModal);
+ // we have to override these to use external, resource-only dlls
+ STDMETHODIMP GetPageInfo(LPPROPPAGEINFO pPageInfo);
+ STDMETHODIMP Activate(HWND hwndParent, LPCRECT pRect, BOOL fModal);
protected:
- CComQIPtr<IDirectVobSub2> m_pDirectVobSub;
+ CComQIPtr<IDirectVobSub2> m_pDirectVobSub;
- virtual bool OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) {
- return false;
- }
- virtual void UpdateObjectData(bool fSave) {}
- virtual void UpdateControlData(bool fSave) {}
+ virtual bool OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) {
+ return false;
+ }
+ virtual void UpdateObjectData(bool fSave) {}
+ virtual void UpdateControlData(bool fSave) {}
protected:
- CDVSBasePPage(TCHAR* pName, LPUNKNOWN lpunk, int DialogId, int TitleId);
+ CDVSBasePPage(TCHAR* pName, LPUNKNOWN lpunk, int DialogId, int TitleId);
- bool m_fDisableInstantUpdate;
+ bool m_fDisableInstantUpdate;
private:
- BOOL m_bIsInitialized;
+ BOOL m_bIsInitialized;
- HRESULT OnConnect(IUnknown* pUnknown), OnDisconnect(), OnActivate(), OnDeactivate(), OnApplyChanges();
- INT_PTR OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+ HRESULT OnConnect(IUnknown* pUnknown), OnDisconnect(), OnActivate(), OnDeactivate(), OnApplyChanges();
+ INT_PTR OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
private:
- bool m_fAttached;
- void AttachControls(), DetachControls();
+ bool m_fAttached;
+ void AttachControls(), DetachControls();
- CMap<UINT, UINT&, CWnd*, CWnd*> m_controls;
+ CMap<UINT, UINT&, CWnd*, CWnd*> m_controls;
protected:
- void BindControl(UINT id, CWnd& control);
+ void BindControl(UINT id, CWnd& control);
};
class __declspec(uuid("60765CF5-01C2-4ee7-A44B-C791CF25FEA0"))
- CDVSMainPPage : public CDVSBasePPage
+ CDVSMainPPage : public CDVSBasePPage
{
- void FreeLangs(), AllocLangs(int nLangs);
-
- WCHAR m_fn[_MAX_PATH];
- int m_iSelectedLanguage, m_nLangs;
- WCHAR** m_ppLangs;
- bool m_fOverridePlacement;
- int m_PlacementXperc, m_PlacementYperc;
- STSStyle m_defStyle;
- bool m_fOnlyShowForcedVobSubs;
- CSimpleTextSubtitle::EPARCompensationType m_ePARCompensationType;
-
- CEdit m_fnedit;
- CComboBox m_langs;
- CButton m_oplacement;
- CSpinButtonCtrl m_subposx, m_subposy;
- CButton m_font, m_forcedsubs;
- CButton m_AutoPARCompensation;
- CComboBox m_PARCombo;
+ void FreeLangs(), AllocLangs(int nLangs);
+
+ WCHAR m_fn[_MAX_PATH];
+ int m_iSelectedLanguage, m_nLangs;
+ WCHAR** m_ppLangs;
+ bool m_fOverridePlacement;
+ int m_PlacementXperc, m_PlacementYperc;
+ STSStyle m_defStyle;
+ bool m_fOnlyShowForcedVobSubs;
+ CSimpleTextSubtitle::EPARCompensationType m_ePARCompensationType;
+
+ CEdit m_fnedit;
+ CComboBox m_langs;
+ CButton m_oplacement;
+ CSpinButtonCtrl m_subposx, m_subposy;
+ CButton m_font, m_forcedsubs;
+ CButton m_AutoPARCompensation;
+ CComboBox m_PARCombo;
protected:
- virtual bool OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
- virtual void UpdateControlData(bool fSave);
- virtual void UpdateObjectData(bool fSave);
+ virtual bool OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
+ virtual void UpdateControlData(bool fSave);
+ virtual void UpdateObjectData(bool fSave);
public:
- CDVSMainPPage(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CDVSMainPPage();
+ CDVSMainPPage(LPUNKNOWN lpunk, HRESULT* phr);
+ virtual ~CDVSMainPPage();
};
class __declspec(uuid("0180E49C-13BF-46db-9AFD-9F52292E1C22"))
- CDVSGeneralPPage : public CDVSBasePPage
+ CDVSGeneralPPage : public CDVSBasePPage
{
- int m_HorExt, m_VerExt, m_ResX2, m_ResX2minw, m_ResX2minh;
- int m_LoadLevel;
- bool m_fExternalLoad, m_fWebLoad, m_fEmbeddedLoad;
+ int m_HorExt, m_VerExt, m_ResX2, m_ResX2minw, m_ResX2minh;
+ int m_LoadLevel;
+ bool m_fExternalLoad, m_fWebLoad, m_fEmbeddedLoad;
- CComboBox m_verext;
- CButton m_mod32fix;
- CComboBox m_resx2;
- CSpinButtonCtrl m_resx2w, m_resx2h;
- CComboBox m_load;
- CButton m_extload, m_webload, m_embload;
+ CComboBox m_verext;
+ CButton m_mod32fix;
+ CComboBox m_resx2;
+ CSpinButtonCtrl m_resx2w, m_resx2h;
+ CComboBox m_load;
+ CButton m_extload, m_webload, m_embload;
protected:
- virtual bool OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
- virtual void UpdateControlData(bool fSave);
- virtual void UpdateObjectData(bool fSave);
+ virtual bool OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
+ virtual void UpdateControlData(bool fSave);
+ virtual void UpdateObjectData(bool fSave);
public:
- CDVSGeneralPPage(LPUNKNOWN lpunk, HRESULT* phr);
+ CDVSGeneralPPage(LPUNKNOWN lpunk, HRESULT* phr);
};
class __declspec(uuid("A8B25C0E-0894-4531-B668-AB1599FAF7F6"))
- CDVSMiscPPage : public CDVSBasePPage
+ CDVSMiscPPage : public CDVSBasePPage
{
- bool m_fFlipPicture, m_fFlipSubtitles, m_fHideSubtitles, m_fOSD, m_fAnimWhenBuffering, m_fReloaderDisabled, m_fSaveFullPath;
- unsigned int m_uSubPictToBuffer;
+ bool m_fFlipPicture, m_fFlipSubtitles, m_fHideSubtitles, m_fOSD, m_fAnimWhenBuffering, m_fReloaderDisabled, m_fSaveFullPath;
+ unsigned int m_uSubPictToBuffer;
- CButton m_flippic, m_flipsub, m_hidesub, m_showosd, m_animwhenbuff, m_autoreload, m_savefullpath, m_instupd;
- CSpinButtonCtrl m_subpicttobuff;
+ CButton m_flippic, m_flipsub, m_hidesub, m_showosd, m_animwhenbuff, m_autoreload, m_savefullpath, m_instupd;
+ CSpinButtonCtrl m_subpicttobuff;
protected:
- virtual bool OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
- virtual void UpdateControlData(bool fSave);
- virtual void UpdateObjectData(bool fSave);
+ virtual bool OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
+ virtual void UpdateControlData(bool fSave);
+ virtual void UpdateObjectData(bool fSave);
public:
- CDVSMiscPPage(LPUNKNOWN lpunk, HRESULT* phr);
+ CDVSMiscPPage(LPUNKNOWN lpunk, HRESULT* phr);
};
class __declspec(uuid("ACE4747B-35BD-4e97-9DD7-1D4245B0695C"))
- CDVSTimingPPage : public CDVSBasePPage
+ CDVSTimingPPage : public CDVSBasePPage
{
- int m_SubtitleSpeedMul, m_SubtitleSpeedDiv, m_SubtitleDelay;
- bool m_fMediaFPSEnabled;
- double m_MediaFPS;
+ int m_SubtitleSpeedMul, m_SubtitleSpeedDiv, m_SubtitleDelay;
+ bool m_fMediaFPSEnabled;
+ double m_MediaFPS;
- CButton m_modfps;
- CEdit m_fps;
- CSpinButtonCtrl m_subdelay, m_subspeedmul, m_subspeeddiv;
+ CButton m_modfps;
+ CEdit m_fps;
+ CSpinButtonCtrl m_subdelay, m_subspeedmul, m_subspeeddiv;
protected:
- virtual bool OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
- virtual void UpdateControlData(bool fSave);
- virtual void UpdateObjectData(bool fSave);
+ virtual bool OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
+ virtual void UpdateControlData(bool fSave);
+ virtual void UpdateObjectData(bool fSave);
public:
- CDVSTimingPPage(LPUNKNOWN lpunk, HRESULT* phr);
+ CDVSTimingPPage(LPUNKNOWN lpunk, HRESULT* phr);
};
class __declspec(uuid("F544E0F5-CA3C-47ea-A64D-35FCF1602396"))
- CDVSAboutPPage : public CDVSBasePPage
+ CDVSAboutPPage : public CDVSBasePPage
{
protected:
- virtual bool OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
+ virtual bool OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
public:
- CDVSAboutPPage(LPUNKNOWN lpunk, HRESULT* phr);
+ CDVSAboutPPage(LPUNKNOWN lpunk, HRESULT* phr);
};
class __declspec(uuid("525F116F-04AD-40a2-AE2F-A0C4E1AFEF98"))
- CDVSZoomPPage : public CDVSBasePPage
+ CDVSZoomPPage : public CDVSBasePPage
{
- NORMALIZEDRECT m_rect;
+ NORMALIZEDRECT m_rect;
- CSpinButtonCtrl m_posx, m_posy, m_scalex, m_scaley;
+ CSpinButtonCtrl m_posx, m_posy, m_scalex, m_scaley;
protected:
- virtual bool OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
- virtual void UpdateControlData(bool fSave);
- virtual void UpdateObjectData(bool fSave);
+ virtual bool OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
+ virtual void UpdateControlData(bool fSave);
+ virtual void UpdateObjectData(bool fSave);
public:
- CDVSZoomPPage(LPUNKNOWN lpunk, HRESULT* phr);
+ CDVSZoomPPage(LPUNKNOWN lpunk, HRESULT* phr);
};
class __declspec(uuid("C2D6D98F-09CA-4524-AF64-1049B5665C9C"))
- CDVSColorPPage : public CDVSBasePPage
+ CDVSColorPPage : public CDVSBasePPage
{
- CListBox m_preflist, m_dynchglist;
- CButton m_forcergb;
+ CListBox m_preflist, m_dynchglist;
+ CButton m_forcergb;
protected:
- virtual bool OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
- virtual void UpdateControlData(bool fSave);
- virtual void UpdateObjectData(bool fSave);
+ virtual bool OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
+ virtual void UpdateControlData(bool fSave);
+ virtual void UpdateObjectData(bool fSave);
public:
- CDVSColorPPage(LPUNKNOWN lpunk, HRESULT* phr);
+ CDVSColorPPage(LPUNKNOWN lpunk, HRESULT* phr);
};
class __declspec(uuid("CE77C59C-CFD2-429f-868C-8B04D23F94CA"))
- CDVSPathsPPage : public CDVSBasePPage
+ CDVSPathsPPage : public CDVSBasePPage
{
- CStringArray m_paths;
+ CStringArray m_paths;
- CListBox m_pathlist;
- CEdit m_path;
- CButton m_browse, m_remove, m_add;
+ CListBox m_pathlist;
+ CEdit m_path;
+ CButton m_browse, m_remove, m_add;
protected:
- virtual bool OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
- virtual void UpdateControlData(bool fSave);
- virtual void UpdateObjectData(bool fSave);
+ virtual bool OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
+ virtual void UpdateControlData(bool fSave);
+ virtual void UpdateObjectData(bool fSave);
public:
- CDVSPathsPPage(LPUNKNOWN lpunk, HRESULT* phr);
+ CDVSPathsPPage(LPUNKNOWN lpunk, HRESULT* phr);
};
diff --git a/src/filters/transform/VSFilter/IDirectVobSub.h b/src/filters/transform/VSFilter/IDirectVobSub.h
index e8dbc46e3..4a5589398 100644
--- a/src/filters/transform/VSFilter/IDirectVobSub.h
+++ b/src/filters/transform/VSFilter/IDirectVobSub.h
@@ -29,290 +29,290 @@
extern "C" {
#endif
- interface __declspec(uuid("EBE1FB08-3957-47ca-AF13-5827E5442E56"))
+ interface __declspec(uuid("EBE1FB08-3957-47ca-AF13-5827E5442E56"))
IDirectVobSub :
- public IUnknown
- {
- STDMETHOD(get_FileName) (THIS_
- WCHAR* fn // fn should point to a buffer allocated to at least the length of _MAX_PATH (=260)
- ) PURE;
-
- STDMETHOD(put_FileName) (THIS_
- WCHAR* fn
- ) PURE;
-
- STDMETHOD(get_LanguageCount) (THIS_
- int* nLangs
- ) PURE;
-
- STDMETHOD(get_LanguageName) (THIS_
- int iLanguage,
- WCHAR** ppName // the returned *ppName is allocated with CoTaskMemAlloc
- ) PURE;
-
- STDMETHOD(get_SelectedLanguage) (THIS_
- int* iSelected
- ) PURE;
-
- STDMETHOD(put_SelectedLanguage) (THIS_
- int iSelected
- ) PURE;
-
- STDMETHOD(get_HideSubtitles) (THIS_
- bool* fHideSubtitles
- ) PURE;
-
- STDMETHOD(put_HideSubtitles) (THIS_
- bool fHideSubtitles
- ) PURE;
-
- // deprecated
- STDMETHOD(get_PreBuffering) (THIS_
- bool* fDoPreBuffering
- ) PURE;
-
- // deprecated
- STDMETHOD(put_PreBuffering) (THIS_
- bool fDoPreBuffering
- ) PURE;
-
- STDMETHOD(get_Placement) (THIS_
- bool* fOverridePlacement,
- int* xperc,
- int* yperc
- ) PURE;
-
- STDMETHOD(put_Placement) (THIS_
- bool fOverridePlacement,
- int xperc,
- int yperc
- ) PURE;
-
- STDMETHOD(get_VobSubSettings) (THIS_
- bool* fBuffer,
- bool* fOnlyShowForcedSubs,
- bool* fPolygonize
- ) PURE;
-
- STDMETHOD(put_VobSubSettings) (THIS_
- bool fBuffer,
- bool fOnlyShowForcedSubs,
- bool fPolygonize
- ) PURE;
-
- STDMETHOD(get_TextSettings) (THIS_
- void* lf,
- int lflen, // depending on lflen, lf must point to LOGFONTA or LOGFONTW
- COLORREF* color,
- bool* fShadow,
- bool* fOutline,
- bool* fAdvancedRenderer
- ) PURE;
-
- STDMETHOD(put_TextSettings) (THIS_
- void* lf,
- int lflen,
- COLORREF color,
- bool fShadow,
- bool fOutline,
- bool fAdvancedRenderer
- ) PURE;
-
- STDMETHOD(get_Flip) (THIS_
- bool* fPicture,
- bool* fSubtitles
- ) PURE;
-
- STDMETHOD(put_Flip) (THIS_
- bool fPicture,
- bool fSubtitles
- ) PURE;
-
- STDMETHOD(get_OSD) (THIS_
- bool* fOSD
- ) PURE;
-
- STDMETHOD(put_OSD) (THIS_
- bool fOSD
- ) PURE;
-
- STDMETHOD(get_SaveFullPath) (THIS_
- bool* fSaveFullPath
- ) PURE;
-
- STDMETHOD(put_SaveFullPath) (THIS_
- bool fSaveFullPath
- ) PURE;
-
- STDMETHOD(get_SubtitleTiming) (THIS_
- int* delay,
- int* speedmul,
- int* speeddiv
- ) PURE;
-
- STDMETHOD(put_SubtitleTiming) (THIS_
- int delay,
- int speedmul,
- int speeddiv
- ) PURE;
-
- STDMETHOD(get_MediaFPS) (THIS_
- bool* fEnabled,
- double* fps
- ) PURE;
-
- STDMETHOD(put_MediaFPS) (THIS_
- bool fEnabled,
- double fps
- ) PURE;
-
- // no longer supported
-
- STDMETHOD(get_ColorFormat) (THIS_
- int* iPosition
- ) PURE;
-
- STDMETHOD(put_ColorFormat) (THIS_
- int iPosition
- ) PURE;
-
- //
-
- STDMETHOD(get_ZoomRect) (THIS_
- NORMALIZEDRECT* rect
- ) PURE;
-
- STDMETHOD(put_ZoomRect) (THIS_
- NORMALIZEDRECT* rect
- ) PURE;
-
- //
-
- STDMETHOD(UpdateRegistry) (THIS_
- ) PURE;
-
- //
-
- STDMETHOD(HasConfigDialog) (THIS_
- int iSelected
- ) PURE;
-
- STDMETHOD(ShowConfigDialog) (THIS_ // if available, this will popup a child dialog allowing the user to edit the style options
- int iSelected,
- HWND hWndParent
- ) PURE;
-
- //
-
- STDMETHOD(IsSubtitleReloaderLocked) (THIS_
- bool* fLocked
- ) PURE;
-
- STDMETHOD(LockSubtitleReloader) (THIS_
- bool fLock
- ) PURE;
-
- STDMETHOD(get_SubtitleReloader) (THIS_
- bool* fDisabled
- ) PURE;
-
- STDMETHOD(put_SubtitleReloader) (THIS_
- bool fDisable
- ) PURE;
-
- //
-
- STDMETHOD(get_ExtendPicture) (THIS_
- int* horizontal, // 0 - disabled, 1 - mod32 extension (width = (width+31)&~31)
- int* vertical, // 0 - disabled, 1 - 16:9, 2 - 4:3, 0x80 - crop (use crop together with 16:9 or 4:3, eg 0x81 will crop to 16:9 if the picture was taller)
- int* resx2, // 0 - disabled, 1 - enabled, 2 - depends on the original resolution
- int* resx2minw, // resolution doubler will be used if width*height <= resx2minw*resx2minh (resx2minw*resx2minh equals to 384*288 by default)
- int* resx2minh
- ) PURE;
-
- STDMETHOD(put_ExtendPicture) (THIS_
- int horizontal,
- int vertical,
- int resx2,
- int resx2minw,
- int resx2minh
- ) PURE;
-
- STDMETHOD(get_LoadSettings) (THIS_
- int* level, // 0 - when needed, 1 - always, 2 - disabled
- bool* fExternalLoad,
- bool* fWebLoad,
- bool* fEmbeddedLoad
- ) PURE;
-
- STDMETHOD(put_LoadSettings) (THIS_
- int level,
- bool fExternalLoad,
- bool fWebLoad,
- bool fEmbeddedLoad
- ) PURE;
-
- STDMETHOD(get_SubPictToBuffer) (THIS_
- unsigned int* uSubPictToBuffer
- ) PURE;
+ public IUnknown
+ {
+ STDMETHOD(get_FileName)(THIS_
+ WCHAR* fn // fn should point to a buffer allocated to at least the length of _MAX_PATH (=260)
+ ) PURE;
+
+ STDMETHOD(put_FileName)(THIS_
+ WCHAR* fn
+ ) PURE;
+
+ STDMETHOD(get_LanguageCount)(THIS_
+ int* nLangs
+ ) PURE;
+
+ STDMETHOD(get_LanguageName)(THIS_
+ int iLanguage,
+ WCHAR** ppName // the returned *ppName is allocated with CoTaskMemAlloc
+ ) PURE;
+
+ STDMETHOD(get_SelectedLanguage)(THIS_
+ int* iSelected
+ ) PURE;
+
+ STDMETHOD(put_SelectedLanguage)(THIS_
+ int iSelected
+ ) PURE;
+
+ STDMETHOD(get_HideSubtitles)(THIS_
+ bool* fHideSubtitles
+ ) PURE;
+
+ STDMETHOD(put_HideSubtitles)(THIS_
+ bool fHideSubtitles
+ ) PURE;
+
+ // deprecated
+ STDMETHOD(get_PreBuffering)(THIS_
+ bool* fDoPreBuffering
+ ) PURE;
+
+ // deprecated
+ STDMETHOD(put_PreBuffering)(THIS_
+ bool fDoPreBuffering
+ ) PURE;
+
+ STDMETHOD(get_Placement)(THIS_
+ bool* fOverridePlacement,
+ int* xperc,
+ int* yperc
+ ) PURE;
+
+ STDMETHOD(put_Placement)(THIS_
+ bool fOverridePlacement,
+ int xperc,
+ int yperc
+ ) PURE;
+
+ STDMETHOD(get_VobSubSettings)(THIS_
+ bool* fBuffer,
+ bool* fOnlyShowForcedSubs,
+ bool* fPolygonize
+ ) PURE;
+
+ STDMETHOD(put_VobSubSettings)(THIS_
+ bool fBuffer,
+ bool fOnlyShowForcedSubs,
+ bool fPolygonize
+ ) PURE;
+
+ STDMETHOD(get_TextSettings)(THIS_
+ void* lf,
+ int lflen, // depending on lflen, lf must point to LOGFONTA or LOGFONTW
+ COLORREF* color,
+ bool* fShadow,
+ bool* fOutline,
+ bool* fAdvancedRenderer
+ ) PURE;
+
+ STDMETHOD(put_TextSettings)(THIS_
+ void* lf,
+ int lflen,
+ COLORREF color,
+ bool fShadow,
+ bool fOutline,
+ bool fAdvancedRenderer
+ ) PURE;
+
+ STDMETHOD(get_Flip)(THIS_
+ bool* fPicture,
+ bool* fSubtitles
+ ) PURE;
+
+ STDMETHOD(put_Flip)(THIS_
+ bool fPicture,
+ bool fSubtitles
+ ) PURE;
+
+ STDMETHOD(get_OSD)(THIS_
+ bool* fOSD
+ ) PURE;
+
+ STDMETHOD(put_OSD)(THIS_
+ bool fOSD
+ ) PURE;
+
+ STDMETHOD(get_SaveFullPath)(THIS_
+ bool* fSaveFullPath
+ ) PURE;
+
+ STDMETHOD(put_SaveFullPath)(THIS_
+ bool fSaveFullPath
+ ) PURE;
+
+ STDMETHOD(get_SubtitleTiming)(THIS_
+ int* delay,
+ int* speedmul,
+ int* speeddiv
+ ) PURE;
+
+ STDMETHOD(put_SubtitleTiming)(THIS_
+ int delay,
+ int speedmul,
+ int speeddiv
+ ) PURE;
+
+ STDMETHOD(get_MediaFPS)(THIS_
+ bool* fEnabled,
+ double* fps
+ ) PURE;
+
+ STDMETHOD(put_MediaFPS)(THIS_
+ bool fEnabled,
+ double fps
+ ) PURE;
+
+ // no longer supported
+
+ STDMETHOD(get_ColorFormat)(THIS_
+ int* iPosition
+ ) PURE;
+
+ STDMETHOD(put_ColorFormat)(THIS_
+ int iPosition
+ ) PURE;
+
+ //
+
+ STDMETHOD(get_ZoomRect)(THIS_
+ NORMALIZEDRECT* rect
+ ) PURE;
+
+ STDMETHOD(put_ZoomRect)(THIS_
+ NORMALIZEDRECT* rect
+ ) PURE;
+
+ //
+
+ STDMETHOD(UpdateRegistry)(THIS_
+ ) PURE;
+
+ //
+
+ STDMETHOD(HasConfigDialog)(THIS_
+ int iSelected
+ ) PURE;
+
+ STDMETHOD(ShowConfigDialog)(THIS_ // if available, this will popup a child dialog allowing the user to edit the style options
+ int iSelected,
+ HWND hWndParent
+ ) PURE;
+
+ //
+
+ STDMETHOD(IsSubtitleReloaderLocked)(THIS_
+ bool* fLocked
+ ) PURE;
+
+ STDMETHOD(LockSubtitleReloader)(THIS_
+ bool fLock
+ ) PURE;
+
+ STDMETHOD(get_SubtitleReloader)(THIS_
+ bool* fDisabled
+ ) PURE;
+
+ STDMETHOD(put_SubtitleReloader)(THIS_
+ bool fDisable
+ ) PURE;
+
+ //
+
+ STDMETHOD(get_ExtendPicture)(THIS_
+ int* horizontal, // 0 - disabled, 1 - mod32 extension (width = (width+31)&~31)
+ int* vertical, // 0 - disabled, 1 - 16:9, 2 - 4:3, 0x80 - crop (use crop together with 16:9 or 4:3, eg 0x81 will crop to 16:9 if the picture was taller)
+ int* resx2, // 0 - disabled, 1 - enabled, 2 - depends on the original resolution
+ int* resx2minw, // resolution doubler will be used if width*height <= resx2minw*resx2minh (resx2minw*resx2minh equals to 384*288 by default)
+ int* resx2minh
+ ) PURE;
+
+ STDMETHOD(put_ExtendPicture)(THIS_
+ int horizontal,
+ int vertical,
+ int resx2,
+ int resx2minw,
+ int resx2minh
+ ) PURE;
+
+ STDMETHOD(get_LoadSettings)(THIS_
+ int* level, // 0 - when needed, 1 - always, 2 - disabled
+ bool* fExternalLoad,
+ bool* fWebLoad,
+ bool* fEmbeddedLoad
+ ) PURE;
+
+ STDMETHOD(put_LoadSettings)(THIS_
+ int level,
+ bool fExternalLoad,
+ bool fWebLoad,
+ bool fEmbeddedLoad
+ ) PURE;
+
+ STDMETHOD(get_SubPictToBuffer)(THIS_
+ unsigned int* uSubPictToBuffer
+ ) PURE;
- STDMETHOD(put_SubPictToBuffer) (THIS_
- unsigned int uSubPictToBuffer
- ) PURE;
+ STDMETHOD(put_SubPictToBuffer)(THIS_
+ unsigned int uSubPictToBuffer
+ ) PURE;
- STDMETHOD(get_AnimWhenBuffering) (THIS_
- bool* fAnimWhenBuffering
- ) PURE;
+ STDMETHOD(get_AnimWhenBuffering)(THIS_
+ bool* fAnimWhenBuffering
+ ) PURE;
- STDMETHOD(put_AnimWhenBuffering) (THIS_
- bool fAnimWhenBuffering
- ) PURE;
- };
-
- interface __declspec(uuid("FE6EC6A0-21CA-4970-9EF0-B296F7F38AF0"))
+ STDMETHOD(put_AnimWhenBuffering)(THIS_
+ bool fAnimWhenBuffering
+ ) PURE;
+ };
+
+ interface __declspec(uuid("FE6EC6A0-21CA-4970-9EF0-B296F7F38AF0"))
ISubClock :
- public IUnknown {
- STDMETHOD(SetTime)(REFERENCE_TIME rt) PURE;
- STDMETHOD_(REFERENCE_TIME, GetTime)() PURE;
- };
+ public IUnknown {
+ STDMETHOD(SetTime)(REFERENCE_TIME rt) PURE;
+ STDMETHOD_(REFERENCE_TIME, GetTime)() PURE;
+ };
- interface __declspec(uuid("0665B760-FBC1-46C3-A35F-E471527C96A4"))
+ interface __declspec(uuid("0665B760-FBC1-46C3-A35F-E471527C96A4"))
ISubClock2 :
- public ISubClock {
- STDMETHOD(SetAvgTimePerFrame)(REFERENCE_TIME rt) PURE;
- STDMETHOD(GetAvgTimePerFrame)(REFERENCE_TIME* prt) PURE; // return S_OK only if *prt was set and is valid
- };
+ public ISubClock {
+ STDMETHOD(SetAvgTimePerFrame)(REFERENCE_TIME rt) PURE;
+ STDMETHOD(GetAvgTimePerFrame)(REFERENCE_TIME * prt) PURE; // return S_OK only if *prt was set and is valid
+ };
- interface __declspec(uuid("AB52FC9C-2415-4dca-BC1C-8DCC2EAE8150"))
+ interface __declspec(uuid("AB52FC9C-2415-4dca-BC1C-8DCC2EAE8150"))
IDirectVobSub2 :
- public IDirectVobSub {
- STDMETHOD(AdviseSubClock) (THIS_
- ISubClock* pSubClock
- ) PURE;
-
- STDMETHOD_(bool, get_Forced) (THIS_
- ) PURE;
-
- STDMETHOD(put_Forced) (THIS_
- bool fForced
- ) PURE;
-
- STDMETHOD(get_TextSettings) (THIS_
- STSStyle* pDefStyle
- ) PURE;
-
- STDMETHOD(put_TextSettings) (THIS_
- STSStyle* pDefStyle
- ) PURE;
-
- STDMETHOD(get_AspectRatioSettings) (THIS_
- CSimpleTextSubtitle::EPARCompensationType* ePARCompensationType
- ) PURE;
-
- STDMETHOD(put_AspectRatioSettings) (THIS_
- CSimpleTextSubtitle::EPARCompensationType* ePARCompensationType
- ) PURE;
- };
+ public IDirectVobSub {
+ STDMETHOD(AdviseSubClock)(THIS_
+ ISubClock* pSubClock
+ ) PURE;
+
+ STDMETHOD_(bool, get_Forced)(THIS_
+ ) PURE;
+
+ STDMETHOD(put_Forced)(THIS_
+ bool fForced
+ ) PURE;
+
+ STDMETHOD(get_TextSettings)(THIS_
+ STSStyle* pDefStyle
+ ) PURE;
+
+ STDMETHOD(put_TextSettings)(THIS_
+ STSStyle* pDefStyle
+ ) PURE;
+
+ STDMETHOD(get_AspectRatioSettings)(THIS_
+ CSimpleTextSubtitle::EPARCompensationType* ePARCompensationType
+ ) PURE;
+
+ STDMETHOD(put_AspectRatioSettings)(THIS_
+ CSimpleTextSubtitle::EPARCompensationType* ePARCompensationType
+ ) PURE;
+ };
#ifdef __cplusplus
diff --git a/src/filters/transform/VSFilter/Scale2x.cpp b/src/filters/transform/VSFilter/Scale2x.cpp
index 9df7d0a8b..5607d5876 100644
--- a/src/filters/transform/VSFilter/Scale2x.cpp
+++ b/src/filters/transform/VSFilter/Scale2x.cpp
@@ -31,444 +31,444 @@
#pragma warning(disable : 4799) // no emms... blahblahblah
-void Scale2x_YV( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
+void Scale2x_YV(int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch)
{
- BYTE* s1;
- BYTE* s2;
- BYTE* d1;
+ BYTE* s1;
+ BYTE* s2;
+ BYTE* d1;
- for (s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) { // TODO: replace this mess with mmx code
- BYTE* stmp = s1 + spitch;
- BYTE* dtmp = d1 + dpitch;
+ for (s1 = s, s2 = s + h * spitch, d1 = d; s1 < s2; d1 += dpitch) { // TODO: replace this mess with mmx code
+ BYTE* stmp = s1 + spitch;
+ BYTE* dtmp = d1 + dpitch;
- for (BYTE* s3 = s1 + (w-1); s1 < s3; s1 += 1, d1 += 2) {
- d1[0] = s1[0];
- d1[1] = (s1[0]+s1[1])>>1;
- }
+ for (BYTE* s3 = s1 + (w - 1); s1 < s3; s1 += 1, d1 += 2) {
+ d1[0] = s1[0];
+ d1[1] = (s1[0] + s1[1]) >> 1;
+ }
- d1[0] = d1[1] = s1[0];
+ d1[0] = d1[1] = s1[0];
- s1 += 1;
- d1 += 2;
+ s1 += 1;
+ d1 += 2;
- s1 = stmp;
- d1 = dtmp;
- }
+ s1 = stmp;
+ d1 = dtmp;
+ }
- AvgLines8(d, h*2, dpitch);
+ AvgLines8(d, h * 2, dpitch);
}
#ifdef _WIN64
-void Scale2x_YUY2_SSE2( BYTE* s1, BYTE* d1, int w )
+void Scale2x_YUY2_SSE2(BYTE* s1, BYTE* d1, int w)
{
- unsigned __int64 __0xffffffff00000000 = 0xffffffff00000000;
- unsigned __int64 __0x00000000ffffffff = 0x00000000ffffffff;
- unsigned __int64 __0x00ff00ff00ff00ff = 0x00ff00ff00ff00ff;
-
- __m128i mm4 = _mm_cvtsi64_si128(__0x00ff00ff00ff00ff);
- __m128i mm5 = _mm_cvtsi64_si128(__0x00000000ffffffff);
- __m128i mm6 = _mm_cvtsi64_si128(__0xffffffff00000000);
- for (BYTE* s3 = s1 + ((w>>1)-1)*4; s1 < s3; s1 += 4, d1 += 8) {
- __m128i mm0 = _mm_cvtsi64_si128(*(size_t*)s1); //movq mm0, [esi]
- __m128i mm2 = _mm_move_epi64(mm0); //movq mm2, mm0
- mm0 = _mm_and_si128(mm0, mm4); //pand mm0, mm4 // mm0 = 00y400y300y200y1
- mm2 = _mm_srli_epi16(mm2, 8); //psrlw mm2, 8 // mm2 = 00u200v200u100v1
- __m128i mm1 = _mm_move_epi64(mm0); //movq mm1, mm0
- mm0 = _mm_and_si128(mm0, mm5); //pand mm0, mm5 // mm0 = 0000000000y200y1
- mm1 = _mm_slli_epi64(mm1, 16); //psllq mm1, 16
- mm1 = _mm_and_si128(mm1, mm6); //pand mm1, mm6 // mm1 = 00y300y200000000
- mm1 = _mm_or_si128(mm1, mm0); //por mm1, mm0 // mm1 = 00y300y200y200y1
- mm0 = _mm_unpacklo_epi8(mm0, mm0); //punpcklwd mm0, mm0 // mm0 = 00y200y200y100y1
- mm0 = _mm_adds_epi16(mm0,mm1); //paddw mm0, mm1
- mm0 = _mm_srli_epi16(mm0, 1); //psrlw mm0, 1 // mm0 = (mm0 + mm1) / 2
- mm1 = _mm_move_epi64(mm2); //movq mm1, mm2
- mm1 = _mm_unpacklo_epi32(mm1, mm1); //punpckldq mm1, mm1 // mm1 = 00u100v100u100v1
- mm1 = _mm_adds_epi16(mm1,mm2); //paddw mm1, mm2
- mm1 = _mm_srli_epi16(mm1, 1); //psrlw mm1, 1 // mm1 = (mm1 + mm2) / 2
- mm1 = _mm_slli_epi64(mm1, 8); //psllw mm1, 8
- mm1 = _mm_or_si128(mm0, mm1); //por mm0, mm1 // mm0 = (v1+v2)/2|(y2+y3)/2|(u1+u2)/2|y2|v1|(y1+y2)/2|u1|y1
- *(size_t*)d1 = (size_t)_mm_cvtsi128_si64(mm0); //movq [edi], mm0
- }
-
- *d1++ = s1[0];
- *d1++ = s1[1];
- *d1++ =(s1[0]+s1[2])>>1;
- *d1++ = s1[3];
-
- *d1++ = s1[2];
- *d1++ = s1[1];
- *d1++ = s1[2];
- *d1++ = s1[3];
-
- s1 += 4;
+ unsigned __int64 __0xffffffff00000000 = 0xffffffff00000000;
+ unsigned __int64 __0x00000000ffffffff = 0x00000000ffffffff;
+ unsigned __int64 __0x00ff00ff00ff00ff = 0x00ff00ff00ff00ff;
+
+ __m128i mm4 = _mm_cvtsi64_si128(__0x00ff00ff00ff00ff);
+ __m128i mm5 = _mm_cvtsi64_si128(__0x00000000ffffffff);
+ __m128i mm6 = _mm_cvtsi64_si128(__0xffffffff00000000);
+ for (BYTE* s3 = s1 + ((w >> 1) - 1) * 4; s1 < s3; s1 += 4, d1 += 8) {
+ __m128i mm0 = _mm_cvtsi64_si128(*(size_t*)s1); //movq mm0, [esi]
+ __m128i mm2 = _mm_move_epi64(mm0); //movq mm2, mm0
+ mm0 = _mm_and_si128(mm0, mm4); //pand mm0, mm4 // mm0 = 00y400y300y200y1
+ mm2 = _mm_srli_epi16(mm2, 8); //psrlw mm2, 8 // mm2 = 00u200v200u100v1
+ __m128i mm1 = _mm_move_epi64(mm0); //movq mm1, mm0
+ mm0 = _mm_and_si128(mm0, mm5); //pand mm0, mm5 // mm0 = 0000000000y200y1
+ mm1 = _mm_slli_epi64(mm1, 16); //psllq mm1, 16
+ mm1 = _mm_and_si128(mm1, mm6); //pand mm1, mm6 // mm1 = 00y300y200000000
+ mm1 = _mm_or_si128(mm1, mm0); //por mm1, mm0 // mm1 = 00y300y200y200y1
+ mm0 = _mm_unpacklo_epi8(mm0, mm0); //punpcklwd mm0, mm0 // mm0 = 00y200y200y100y1
+ mm0 = _mm_adds_epi16(mm0, mm1); //paddw mm0, mm1
+ mm0 = _mm_srli_epi16(mm0, 1); //psrlw mm0, 1 // mm0 = (mm0 + mm1) / 2
+ mm1 = _mm_move_epi64(mm2); //movq mm1, mm2
+ mm1 = _mm_unpacklo_epi32(mm1, mm1); //punpckldq mm1, mm1 // mm1 = 00u100v100u100v1
+ mm1 = _mm_adds_epi16(mm1, mm2); //paddw mm1, mm2
+ mm1 = _mm_srli_epi16(mm1, 1); //psrlw mm1, 1 // mm1 = (mm1 + mm2) / 2
+ mm1 = _mm_slli_epi64(mm1, 8); //psllw mm1, 8
+ mm1 = _mm_or_si128(mm0, mm1); //por mm0, mm1 // mm0 = (v1+v2)/2|(y2+y3)/2|(u1+u2)/2|y2|v1|(y1+y2)/2|u1|y1
+ *(size_t*)d1 = (size_t)_mm_cvtsi128_si64(mm0); //movq [edi], mm0
+ }
+
+ *d1++ = s1[0];
+ *d1++ = s1[1];
+ *d1++ = (s1[0] + s1[2]) >> 1;
+ *d1++ = s1[3];
+
+ *d1++ = s1[2];
+ *d1++ = s1[1];
+ *d1++ = s1[2];
+ *d1++ = s1[3];
+
+ s1 += 4;
}
#else
-void Scale2x_YUY2_MMX( BYTE* s1, BYTE* d1, int w )
+void Scale2x_YUY2_MMX(BYTE* s1, BYTE* d1, int w)
{
- unsigned __int64 __0xffffffff00000000 = 0xffffffff00000000;
- unsigned __int64 __0x00000000ffffffff = 0x00000000ffffffff;
- unsigned __int64 __0x00ff00ff00ff00ff = 0x00ff00ff00ff00ff;
+ unsigned __int64 __0xffffffff00000000 = 0xffffffff00000000;
+ unsigned __int64 __0x00000000ffffffff = 0x00000000ffffffff;
+ unsigned __int64 __0x00ff00ff00ff00ff = 0x00ff00ff00ff00ff;
- __asm {
- mov esi, s1
- mov edi, d1
+ __asm {
+ mov esi, s1
+ mov edi, d1
- mov ecx, w
- shr ecx, 1
- dec ecx
+ mov ecx, w
+ shr ecx, 1
+ dec ecx
- movq mm4, __0x00ff00ff00ff00ff
- movq mm5, __0x00000000ffffffff
- movq mm6, __0xffffffff00000000
- row_loop1:
- movq mm0, [esi]
- movq mm2, mm0
+ movq mm4, __0x00ff00ff00ff00ff
+ movq mm5, __0x00000000ffffffff
+ movq mm6, __0xffffffff00000000
+ row_loop1:
+ movq mm0, [esi]
+ movq mm2, mm0
- pand mm0, mm4 // mm0 = 00y400y300y200y1
- psrlw mm2, 8 // mm2 = 00u200v200u100v1
+ pand mm0, mm4 // mm0 = 00y400y300y200y1
+ psrlw mm2, 8 // mm2 = 00u200v200u100v1
- movq mm1, mm0
+ movq mm1, mm0
- pand mm0, mm5 // mm0 = 0000000000y200y1
+ pand mm0, mm5 // mm0 = 0000000000y200y1
- psllq mm1, 16
- pand mm1, mm6 // mm1 = 00y300y200000000
+ psllq mm1, 16
+ pand mm1, mm6 // mm1 = 00y300y200000000
- por mm1, mm0 // mm1 = 00y300y200y200y1
+ por mm1, mm0 // mm1 = 00y300y200y200y1
- punpcklwd mm0, mm0 // mm0 = 00y200y200y100y1
+ punpcklwd mm0, mm0 // mm0 = 00y200y200y100y1
- paddw mm0, mm1
- psrlw mm0, 1 // mm0 = (mm0 + mm1) / 2
+ paddw mm0, mm1
+ psrlw mm0, 1 // mm0 = (mm0 + mm1) / 2
- movq mm1, mm2
- punpckldq mm1, mm1 // mm1 = 00u100v100u100v1
+ movq mm1, mm2
+ punpckldq mm1, mm1 // mm1 = 00u100v100u100v1
- paddw mm1, mm2
- psrlw mm1, 1 // mm1 = (mm1 + mm2) / 2
+ paddw mm1, mm2
+ psrlw mm1, 1 // mm1 = (mm1 + mm2) / 2
- psllw mm1, 8
- por mm0, mm1 // mm0 = (v1+v2)/2|(y2+y3)/2|(u1+u2)/2|y2|v1|(y1+y2)/2|u1|y1
+ psllw mm1, 8
+ por mm0, mm1 // mm0 = (v1+v2)/2|(y2+y3)/2|(u1+u2)/2|y2|v1|(y1+y2)/2|u1|y1
- movq [edi], mm0
+ movq [edi], mm0
- lea esi, [esi+4]
- lea edi, [edi+8]
+ lea esi, [esi+4]
+ lea edi, [edi+8]
- dec ecx
- jnz row_loop1
+ dec ecx
+ jnz row_loop1
- mov s1, esi
- mov d1, edi
- };
+ mov s1, esi
+ mov d1, edi
+ };
- *d1++ = s1[0];
- *d1++ = s1[1];
- *d1++ =(s1[0]+s1[2])>>1;
- *d1++ = s1[3];
+ *d1++ = s1[0];
+ *d1++ = s1[1];
+ *d1++ = (s1[0] + s1[2]) >> 1;
+ *d1++ = s1[3];
- *d1++ = s1[2];
- *d1++ = s1[1];
- *d1++ = s1[2];
- *d1++ = s1[3];
+ *d1++ = s1[2];
+ *d1++ = s1[1];
+ *d1++ = s1[2];
+ *d1++ = s1[3];
- s1 += 4;
+ s1 += 4;
}
#endif
-void Scale2x_YUY2_c( BYTE* s1, BYTE* d1, int w )
+void Scale2x_YUY2_c(BYTE* s1, BYTE* d1, int w)
{
- for (BYTE* s3 = s1 + ((w>>1)-1)*4; s1 < s3; s1 += 4, d1 += 8) {
- d1[0] = s1[0];
- d1[1] = s1[1];
- d1[2] = (s1[0]+s1[2])>>1;
- d1[3] = s1[3];
-
- d1[4] = s1[2];
- d1[5] = (s1[1]+s1[5])>>1;
- d1[6] = (s1[2]+s1[4])>>1;
- d1[7] = (s1[3]+s1[7])>>1;
- }
-
- *d1++ = s1[0];
- *d1++ = s1[1];
- *d1++ =(s1[0]+s1[2])>>1;
- *d1++ = s1[3];
-
- *d1++ = s1[2];
- *d1++ = s1[1];
- *d1++ = s1[2];
- *d1++ = s1[3];
-
- s1 += 4;
+ for (BYTE* s3 = s1 + ((w >> 1) - 1) * 4; s1 < s3; s1 += 4, d1 += 8) {
+ d1[0] = s1[0];
+ d1[1] = s1[1];
+ d1[2] = (s1[0] + s1[2]) >> 1;
+ d1[3] = s1[3];
+
+ d1[4] = s1[2];
+ d1[5] = (s1[1] + s1[5]) >> 1;
+ d1[6] = (s1[2] + s1[4]) >> 1;
+ d1[7] = (s1[3] + s1[7]) >> 1;
+ }
+
+ *d1++ = s1[0];
+ *d1++ = s1[1];
+ *d1++ = (s1[0] + s1[2]) >> 1;
+ *d1++ = s1[3];
+
+ *d1++ = s1[2];
+ *d1++ = s1[1];
+ *d1++ = s1[2];
+ *d1++ = s1[3];
+
+ s1 += 4;
}
-void Scale2x_YUY2( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
+void Scale2x_YUY2(int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch)
{
- void (*scale_func)(BYTE* s1, BYTE* d1, int w);
+ void (*scale_func)(BYTE * s1, BYTE * d1, int w);
#ifdef _WIN64
- scale_func = Scale2x_YUY2_SSE2;
+ scale_func = Scale2x_YUY2_SSE2;
#else
- scale_func = Scale2x_YUY2_MMX;
+ scale_func = Scale2x_YUY2_MMX;
#endif
- //scale_func = Scale2x_YUY2_c;
+ //scale_func = Scale2x_YUY2_c;
- //unsigned __int64 __0xffffffff00000000 = 0xffffffff00000000;
- //unsigned __int64 __0x00000000ffffffff = 0x00000000ffffffff;
- //unsigned __int64 __0x00ff00ff00ff00ff = 0x00ff00ff00ff00ff;
+ //unsigned __int64 __0xffffffff00000000 = 0xffffffff00000000;
+ //unsigned __int64 __0x00000000ffffffff = 0x00000000ffffffff;
+ //unsigned __int64 __0x00ff00ff00ff00ff = 0x00ff00ff00ff00ff;
- BYTE* s1;
- BYTE* s2;
- BYTE* d1;
+ BYTE* s1;
+ BYTE* s2;
+ BYTE* d1;
- for (s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) {
- // row0, 4 pixels: y1|u1|y2|v1|y3|u2|y4|v2
- // ->
- // row0, 8 pixels: y1|u1|(y1+y2)/2|v1|y2|(u1+u2)/2|(y2+y3)/2|(v1+v2)/2
+ for (s1 = s, s2 = s + h * spitch, d1 = d; s1 < s2; d1 += dpitch) {
+ // row0, 4 pixels: y1|u1|y2|v1|y3|u2|y4|v2
+ // ->
+ // row0, 8 pixels: y1|u1|(y1+y2)/2|v1|y2|(u1+u2)/2|(y2+y3)/2|(v1+v2)/2
- scale_func(s1, d1, w);
+ scale_func(s1, d1, w);
- s1 += spitch;
- d1 += dpitch;
- }
+ s1 += spitch;
+ d1 += dpitch;
+ }
#ifndef _WIN64
- __asm emms;
+ __asm emms;
#endif
- AvgLines8(d, h*2, dpitch);
+ AvgLines8(d, h * 2, dpitch);
}
-void Scale2x_RGB555( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
+void Scale2x_RGB555(int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch)
{
- BYTE* s1;
- BYTE* s2;
- BYTE* d1;
+ BYTE* s1;
+ BYTE* s2;
+ BYTE* d1;
- for (s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) { // TODO: replace this mess with mmx code
- BYTE* stmp = s1 + spitch;
- BYTE* dtmp = d1 + dpitch;
+ for (s1 = s, s2 = s + h * spitch, d1 = d; s1 < s2; d1 += dpitch) { // TODO: replace this mess with mmx code
+ BYTE* stmp = s1 + spitch;
+ BYTE* dtmp = d1 + dpitch;
- for (BYTE* s3 = s1 + (w-1)*2; s1 < s3; s1 += 2, d1 += 4) {
- *((WORD*)d1) = *((WORD*)s1);
- *((WORD*)d1+1) =
- ((((*((WORD*)s1)&0x7c00) + (*((WORD*)s1+1)&0x7c00)) >> 1)&0x7c00)|
- ((((*((WORD*)s1)&0x03e0) + (*((WORD*)s1+1)&0x03e0)) >> 1)&0x03e0)|
- ((((*((WORD*)s1)&0x001f) + (*((WORD*)s1+1)&0x001f)) >> 1)&0x001f);
- }
+ for (BYTE* s3 = s1 + (w - 1) * 2; s1 < s3; s1 += 2, d1 += 4) {
+ *((WORD*)d1) = *((WORD*)s1);
+ *((WORD*)d1 + 1) =
+ ((((*((WORD*)s1) & 0x7c00) + (*((WORD*)s1 + 1) & 0x7c00)) >> 1) & 0x7c00) |
+ ((((*((WORD*)s1) & 0x03e0) + (*((WORD*)s1 + 1) & 0x03e0)) >> 1) & 0x03e0) |
+ ((((*((WORD*)s1) & 0x001f) + (*((WORD*)s1 + 1) & 0x001f)) >> 1) & 0x001f);
+ }
- *((WORD*)d1) = *((WORD*)s1);
- *((WORD*)d1+1) = *((WORD*)s1);
+ *((WORD*)d1) = *((WORD*)s1);
+ *((WORD*)d1 + 1) = *((WORD*)s1);
- s1 += 2;
- d1 += 4;
+ s1 += 2;
+ d1 += 4;
- s1 = stmp;
- d1 = dtmp;
- }
+ s1 = stmp;
+ d1 = dtmp;
+ }
- AvgLines555(d, h*2, dpitch);
+ AvgLines555(d, h * 2, dpitch);
}
-void Scale2x_RGB565( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
+void Scale2x_RGB565(int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch)
{
- BYTE* s1;
- BYTE* s2;
- BYTE* d1;
+ BYTE* s1;
+ BYTE* s2;
+ BYTE* d1;
- for (s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) { // TODO: replace this mess with mmx code
- BYTE* stmp = s1 + spitch;
- BYTE* dtmp = d1 + dpitch;
+ for (s1 = s, s2 = s + h * spitch, d1 = d; s1 < s2; d1 += dpitch) { // TODO: replace this mess with mmx code
+ BYTE* stmp = s1 + spitch;
+ BYTE* dtmp = d1 + dpitch;
- for (BYTE* s3 = s1 + (w-1)*2; s1 < s3; s1 += 2, d1 += 4) {
- *((WORD*)d1) = *((WORD*)s1);
- *((WORD*)d1+1) =
- ((((*((WORD*)s1)&0xf800) + (*((WORD*)s1+1)&0xf800)) >> 1)&0xf800)|
- ((((*((WORD*)s1)&0x07e0) + (*((WORD*)s1+1)&0x07e0)) >> 1)&0x07e0)|
- ((((*((WORD*)s1)&0x001f) + (*((WORD*)s1+1)&0x001f)) >> 1)&0x001f);
- }
+ for (BYTE* s3 = s1 + (w - 1) * 2; s1 < s3; s1 += 2, d1 += 4) {
+ *((WORD*)d1) = *((WORD*)s1);
+ *((WORD*)d1 + 1) =
+ ((((*((WORD*)s1) & 0xf800) + (*((WORD*)s1 + 1) & 0xf800)) >> 1) & 0xf800) |
+ ((((*((WORD*)s1) & 0x07e0) + (*((WORD*)s1 + 1) & 0x07e0)) >> 1) & 0x07e0) |
+ ((((*((WORD*)s1) & 0x001f) + (*((WORD*)s1 + 1) & 0x001f)) >> 1) & 0x001f);
+ }
- *((WORD*)d1) = *((WORD*)s1);
- *((WORD*)d1+1) = *((WORD*)s1);
+ *((WORD*)d1) = *((WORD*)s1);
+ *((WORD*)d1 + 1) = *((WORD*)s1);
- s1 += 2;
- d1 += 4;
+ s1 += 2;
+ d1 += 4;
- s1 = stmp;
- d1 = dtmp;
- }
+ s1 = stmp;
+ d1 = dtmp;
+ }
- AvgLines565(d, h*2, dpitch);
+ AvgLines565(d, h * 2, dpitch);
}
-void Scale2x_RGB24( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
+void Scale2x_RGB24(int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch)
{
- BYTE* s1;
- BYTE* s2;
- BYTE* d1;
-
- for (s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) { // TODO: replace this mess with mmx code
- BYTE* stmp = s1 + spitch;
- BYTE* dtmp = d1 + dpitch;
-
- for (BYTE* s3 = s1 + (w-1)*3; s1 < s3; s1 += 3, d1 += 6) {
- d1[0] = s1[0];
- d1[1] = s1[1];
- d1[2] = s1[2];
- d1[3] = (s1[0]+s1[3])>>1;
- d1[4] = (s1[1]+s1[4])>>1;
- d1[5] = (s1[2]+s1[5])>>1;
- }
-
- d1[0] = d1[3] = s1[0];
- d1[1] = d1[4] = s1[1];
- d1[2] = d1[5] = s1[2];
-
- s1 += 3;
- d1 += 6;
-
- s1 = stmp;
- d1 = dtmp;
- }
-
- AvgLines8(d, h*2, dpitch);
+ BYTE* s1;
+ BYTE* s2;
+ BYTE* d1;
+
+ for (s1 = s, s2 = s + h * spitch, d1 = d; s1 < s2; d1 += dpitch) { // TODO: replace this mess with mmx code
+ BYTE* stmp = s1 + spitch;
+ BYTE* dtmp = d1 + dpitch;
+
+ for (BYTE* s3 = s1 + (w - 1) * 3; s1 < s3; s1 += 3, d1 += 6) {
+ d1[0] = s1[0];
+ d1[1] = s1[1];
+ d1[2] = s1[2];
+ d1[3] = (s1[0] + s1[3]) >> 1;
+ d1[4] = (s1[1] + s1[4]) >> 1;
+ d1[5] = (s1[2] + s1[5]) >> 1;
+ }
+
+ d1[0] = d1[3] = s1[0];
+ d1[1] = d1[4] = s1[1];
+ d1[2] = d1[5] = s1[2];
+
+ s1 += 3;
+ d1 += 6;
+
+ s1 = stmp;
+ d1 = dtmp;
+ }
+
+ AvgLines8(d, h * 2, dpitch);
}
#ifdef _WIN64
-void Scale2x_XRGB32_SSE2( BYTE* s1, BYTE* d1, int w )
+void Scale2x_XRGB32_SSE2(BYTE* s1, BYTE* d1, int w)
{
- __m128i mm_zero = _mm_setzero_si128();//pxor mm0, mm0
- for (BYTE* s3 = s1 + (w-1)*4; s1 < s3; s1 += 4, d1 += 8) {
+ __m128i mm_zero = _mm_setzero_si128();//pxor mm0, mm0
+ for (BYTE* s3 = s1 + (w - 1) * 4; s1 < s3; s1 += 4, d1 += 8) {
- __m128i mm1 = _mm_cvtsi64_si128(*(size_t*)s1); //movq mm1, [esi]
- __m128i mm2 = _mm_move_epi64(mm1); //movq mm2, mm1
+ __m128i mm1 = _mm_cvtsi64_si128(*(size_t*)s1); //movq mm1, [esi]
+ __m128i mm2 = _mm_move_epi64(mm1); //movq mm2, mm1
- mm1 = _mm_unpacklo_epi8(mm1,mm_zero);//punpcklbw mm1, mm0 // mm1 = 00xx00r100g100b1
- mm2 = _mm_unpacklo_epi8(mm2,mm_zero);//punpckhbw mm2, mm0 // mm2 = 00xx00r200g200b2
+ mm1 = _mm_unpacklo_epi8(mm1, mm_zero); //punpcklbw mm1, mm0 // mm1 = 00xx00r100g100b1
+ mm2 = _mm_unpacklo_epi8(mm2, mm_zero); //punpckhbw mm2, mm0 // mm2 = 00xx00r200g200b2
- mm2 = _mm_adds_epi16(mm2,mm1); //paddw mm2, mm1
- mm2 = _mm_srli_epi16(mm2, 1); //psrlw mm2, 1 // mm2 = (mm1 + mm2) / 2
+ mm2 = _mm_adds_epi16(mm2, mm1); //paddw mm2, mm1
+ mm2 = _mm_srli_epi16(mm2, 1); //psrlw mm2, 1 // mm2 = (mm1 + mm2) / 2
- mm1 = _mm_packus_epi16(mm1,mm2); //packuswb mm1, mm2
+ mm1 = _mm_packus_epi16(mm1, mm2); //packuswb mm1, mm2
- *(size_t*)d1=(size_t)_mm_cvtsi128_si64(mm1);//movq [edi], mm1
- }
+ *(size_t*)d1 = (size_t)_mm_cvtsi128_si64(mm1); //movq [edi], mm1
+ }
- *((DWORD*)d1) = *((DWORD*)s1);
- *((DWORD*)d1+1) = *((DWORD*)s1);
+ *((DWORD*)d1) = *((DWORD*)s1);
+ *((DWORD*)d1 + 1) = *((DWORD*)s1);
- s1 += 4;
- d1 += 8;
+ s1 += 4;
+ d1 += 8;
}
#else
-void Scale2x_XRGB32_MMX( BYTE* s1, BYTE* d1, int w )
+void Scale2x_XRGB32_MMX(BYTE* s1, BYTE* d1, int w)
{
- __asm {
- mov esi, s1
- mov edi, d1
+ __asm {
+ mov esi, s1
+ mov edi, d1
- mov ecx, w
- dec ecx
+ mov ecx, w
+ dec ecx
- pxor mm0, mm0
- row_loop3:
- movq mm1, [esi]
- movq mm2, mm1
+ pxor mm0, mm0
+ row_loop3:
+ movq mm1, [esi]
+ movq mm2, mm1
- punpcklbw mm1, mm0 // mm1 = 00xx00r100g100b1
- punpckhbw mm2, mm0 // mm2 = 00xx00r200g200b2
+ punpcklbw mm1, mm0 // mm1 = 00xx00r100g100b1
+ punpckhbw mm2, mm0 // mm2 = 00xx00r200g200b2
- paddw mm2, mm1
- psrlw mm2, 1 // mm2 = (mm1 + mm2) / 2
+ paddw mm2, mm1
+ psrlw mm2, 1 // mm2 = (mm1 + mm2) / 2
- packuswb mm1, mm2
+ packuswb mm1, mm2
- movq [edi], mm1
+ movq [edi], mm1
- lea esi, [esi+4]
- lea edi, [edi+8]
+ lea esi, [esi+4]
+ lea edi, [edi+8]
- dec ecx
- jnz row_loop3
+ dec ecx
+ jnz row_loop3
- mov s1, esi
- mov d1, edi
- };
+ mov s1, esi
+ mov d1, edi
+ };
- *((DWORD*)d1) = *((DWORD*)s1);
- *((DWORD*)d1+1) = *((DWORD*)s1);
+ *((DWORD*)d1) = *((DWORD*)s1);
+ *((DWORD*)d1 + 1) = *((DWORD*)s1);
- s1 += 4;
- d1 += 8;
+ s1 += 4;
+ d1 += 8;
}
#endif
-void Scale2x_XRGB32_c( BYTE* s1, BYTE* d1, int w )
+void Scale2x_XRGB32_c(BYTE* s1, BYTE* d1, int w)
{
- for (BYTE* s3 = s1 + (w-1)*4; s1 < s3; s1 += 3, d1 += 6) {
- d1[0] = s1[0];
- d1[1] = s1[1];
- d1[2] = s1[2];
- d1[3] = s1[3];
-
- d1[4] = (s1[0]+s1[4])>>1;
- d1[5] = (s1[1]+s1[5])>>1;
- d1[6] = (s1[2]+s1[6])>>1;
- d1[7] = (s1[4]+s1[7])>>1;
- }
-
- *((DWORD*)d1) = *((DWORD*)s1);
- *((DWORD*)d1+1) = *((DWORD*)s1);
-
- s1 += 4;
- d1 += 8;
+ for (BYTE* s3 = s1 + (w - 1) * 4; s1 < s3; s1 += 3, d1 += 6) {
+ d1[0] = s1[0];
+ d1[1] = s1[1];
+ d1[2] = s1[2];
+ d1[3] = s1[3];
+
+ d1[4] = (s1[0] + s1[4]) >> 1;
+ d1[5] = (s1[1] + s1[5]) >> 1;
+ d1[6] = (s1[2] + s1[6]) >> 1;
+ d1[7] = (s1[4] + s1[7]) >> 1;
+ }
+
+ *((DWORD*)d1) = *((DWORD*)s1);
+ *((DWORD*)d1 + 1) = *((DWORD*)s1);
+
+ s1 += 4;
+ d1 += 8;
}
-void Scale2x_XRGB32( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
+void Scale2x_XRGB32(int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch)
{
- void (*scale_func)(BYTE* s1, BYTE* d1, int w);
+ void (*scale_func)(BYTE * s1, BYTE * d1, int w);
#ifdef _WIN64
- scale_func = Scale2x_XRGB32_SSE2;
+ scale_func = Scale2x_XRGB32_SSE2;
#else
- scale_func = Scale2x_XRGB32_MMX;
+ scale_func = Scale2x_XRGB32_MMX;
#endif
- //scale_func = Scale2x_XRGB32_c;
+ //scale_func = Scale2x_XRGB32_c;
- BYTE* s1;
- BYTE* s2;
- BYTE* d1;
+ BYTE* s1;
+ BYTE* s2;
+ BYTE* d1;
- for (s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) {
- scale_func(s1, d1, w);
+ for (s1 = s, s2 = s + h * spitch, d1 = d; s1 < s2; d1 += dpitch) {
+ scale_func(s1, d1, w);
- s1 += spitch;
- d1 += dpitch;
- }
+ s1 += spitch;
+ d1 += dpitch;
+ }
#ifndef _WIN64
- __asm emms;
+ __asm emms;
#endif
- AvgLines8(d, h*2, dpitch);
+ AvgLines8(d, h * 2, dpitch);
}
/* ResX2 */
void Scale2x(const GUID& subtype, BYTE* d, int dpitch, BYTE* s, int spitch, int w, int h)
{
- if (subtype == MEDIASUBTYPE_YV12 || subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV) {
- Scale2x_YV(w, h, d, dpitch, s, spitch);
- } else if (subtype == MEDIASUBTYPE_YUY2) {
- Scale2x_YUY2(w, h, d, dpitch, s, spitch);
- } else if (subtype == MEDIASUBTYPE_RGB555) {
- Scale2x_RGB555(w, h, d, dpitch, s, spitch);
- } else if (subtype == MEDIASUBTYPE_RGB565) {
- Scale2x_RGB565(w, h, d, dpitch, s, spitch);
- } else if (subtype == MEDIASUBTYPE_RGB24) {
- Scale2x_RGB24(w, h, d, dpitch, s, spitch);
- } else if (subtype == MEDIASUBTYPE_RGB32 || subtype == MEDIASUBTYPE_ARGB32) {
- Scale2x_XRGB32(w, h, d, dpitch, s, spitch);
- }
+ if (subtype == MEDIASUBTYPE_YV12 || subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV) {
+ Scale2x_YV(w, h, d, dpitch, s, spitch);
+ } else if (subtype == MEDIASUBTYPE_YUY2) {
+ Scale2x_YUY2(w, h, d, dpitch, s, spitch);
+ } else if (subtype == MEDIASUBTYPE_RGB555) {
+ Scale2x_RGB555(w, h, d, dpitch, s, spitch);
+ } else if (subtype == MEDIASUBTYPE_RGB565) {
+ Scale2x_RGB565(w, h, d, dpitch, s, spitch);
+ } else if (subtype == MEDIASUBTYPE_RGB24) {
+ Scale2x_RGB24(w, h, d, dpitch, s, spitch);
+ } else if (subtype == MEDIASUBTYPE_RGB32 || subtype == MEDIASUBTYPE_ARGB32) {
+ Scale2x_XRGB32(w, h, d, dpitch, s, spitch);
+ }
}
diff --git a/src/filters/transform/VSFilter/StyleEditorDialog.cpp b/src/filters/transform/VSFilter/StyleEditorDialog.cpp
index 8f7d8617b..f401d5ace 100644
--- a/src/filters/transform/VSFilter/StyleEditorDialog.cpp
+++ b/src/filters/transform/VSFilter/StyleEditorDialog.cpp
@@ -39,21 +39,21 @@ END_MESSAGE_MAP()
IMPLEMENT_DYNAMIC(CStyleEditorDialog, CDialog)
CStyleEditorDialog::CStyleEditorDialog(CString title, STSStyle* pstss, CWnd* pParent /*=NULL*/)
- : CDialog(CStyleEditorDialog::IDD, pParent)
- , m_title(title)
- , m_stss(*pstss)
- , m_pParent(pParent)
- , m_iCharset(0)
- , m_spacing(0)
- , m_angle(0)
- , m_scalex(0)
- , m_scaley(0)
- , m_borderstyle(0)
- , m_borderwidth(0)
- , m_shadowdepth(0)
- , m_screenalignment(0)
- , m_margin(0,0,0,0)
- , m_linkalphasliders(FALSE)
+ : CDialog(CStyleEditorDialog::IDD, pParent)
+ , m_title(title)
+ , m_stss(*pstss)
+ , m_pParent(pParent)
+ , m_iCharset(0)
+ , m_spacing(0)
+ , m_angle(0)
+ , m_scalex(0)
+ , m_scaley(0)
+ , m_borderstyle(0)
+ , m_borderwidth(0)
+ , m_shadowdepth(0)
+ , m_screenalignment(0)
+ , m_margin(0, 0, 0, 0)
+ , m_linkalphasliders(FALSE)
{
}
@@ -63,138 +63,138 @@ CStyleEditorDialog::~CStyleEditorDialog()
void CStyleEditorDialog::DoDataExchange(CDataExchange* pDX)
{
- CDialog::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_BUTTON1, m_font);
- DDX_CBIndex(pDX, IDC_COMBO1, m_iCharset);
- DDX_Control(pDX, IDC_COMBO1, m_charset);
- DDX_Text(pDX, IDC_EDIT3, m_spacing);
- DDX_Control(pDX, IDC_SPIN3, m_spacingspin);
- DDX_Text(pDX, IDC_EDIT11, m_angle);
- DDX_Control(pDX, IDC_SPIN10, m_anglespin);
- DDX_Text(pDX, IDC_EDIT5, m_scalex);
- DDX_Control(pDX, IDC_SPIN4, m_scalexspin);
- DDX_Text(pDX, IDC_EDIT6, m_scaley);
- DDX_Control(pDX, IDC_SPIN5, m_scaleyspin);
- DDX_Radio(pDX, IDC_RADIO1, m_borderstyle);
- DDX_Text(pDX, IDC_EDIT1, m_borderwidth);
- DDX_Control(pDX, IDC_SPIN1, m_borderwidthspin);
- DDX_Text(pDX, IDC_EDIT2, m_shadowdepth);
- DDX_Control(pDX, IDC_SPIN2, m_shadowdepthspin);
- DDX_Radio(pDX, IDC_RADIO3, m_screenalignment);
- DDX_Text(pDX, IDC_EDIT7, m_margin.left);
- DDX_Control(pDX, IDC_SPIN6, m_marginleftspin);
- DDX_Text(pDX, IDC_EDIT8, m_margin.right);
- DDX_Control(pDX, IDC_SPIN7, m_marginrightspin);
- DDX_Text(pDX, IDC_EDIT9, m_margin.top);
- DDX_Control(pDX, IDC_SPIN8, m_margintopspin);
- DDX_Text(pDX, IDC_EDIT10, m_margin.bottom);
- DDX_Control(pDX, IDC_SPIN9, m_marginbottomspin);
- DDX_Control(pDX, IDC_COLORPRI, m_color[0]);
- DDX_Control(pDX, IDC_COLORSEC, m_color[1]);
- DDX_Control(pDX, IDC_COLOROUTL, m_color[2]);
- DDX_Control(pDX, IDC_COLORSHAD, m_color[3]);
- DDX_Slider(pDX, IDC_SLIDER2, m_alpha[0]);
- DDX_Slider(pDX, IDC_SLIDER3, m_alpha[1]);
- DDX_Slider(pDX, IDC_SLIDER5, m_alpha[2]);
- DDX_Slider(pDX, IDC_SLIDER6, m_alpha[3]);
- DDX_Control(pDX, IDC_SLIDER2, m_alphasliders[0]);
- DDX_Control(pDX, IDC_SLIDER3, m_alphasliders[1]);
- DDX_Control(pDX, IDC_SLIDER5, m_alphasliders[2]);
- DDX_Control(pDX, IDC_SLIDER6, m_alphasliders[3]);
- DDX_Check(pDX, IDC_CHECK1, m_linkalphasliders);
+ CDialog::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_BUTTON1, m_font);
+ DDX_CBIndex(pDX, IDC_COMBO1, m_iCharset);
+ DDX_Control(pDX, IDC_COMBO1, m_charset);
+ DDX_Text(pDX, IDC_EDIT3, m_spacing);
+ DDX_Control(pDX, IDC_SPIN3, m_spacingspin);
+ DDX_Text(pDX, IDC_EDIT11, m_angle);
+ DDX_Control(pDX, IDC_SPIN10, m_anglespin);
+ DDX_Text(pDX, IDC_EDIT5, m_scalex);
+ DDX_Control(pDX, IDC_SPIN4, m_scalexspin);
+ DDX_Text(pDX, IDC_EDIT6, m_scaley);
+ DDX_Control(pDX, IDC_SPIN5, m_scaleyspin);
+ DDX_Radio(pDX, IDC_RADIO1, m_borderstyle);
+ DDX_Text(pDX, IDC_EDIT1, m_borderwidth);
+ DDX_Control(pDX, IDC_SPIN1, m_borderwidthspin);
+ DDX_Text(pDX, IDC_EDIT2, m_shadowdepth);
+ DDX_Control(pDX, IDC_SPIN2, m_shadowdepthspin);
+ DDX_Radio(pDX, IDC_RADIO3, m_screenalignment);
+ DDX_Text(pDX, IDC_EDIT7, m_margin.left);
+ DDX_Control(pDX, IDC_SPIN6, m_marginleftspin);
+ DDX_Text(pDX, IDC_EDIT8, m_margin.right);
+ DDX_Control(pDX, IDC_SPIN7, m_marginrightspin);
+ DDX_Text(pDX, IDC_EDIT9, m_margin.top);
+ DDX_Control(pDX, IDC_SPIN8, m_margintopspin);
+ DDX_Text(pDX, IDC_EDIT10, m_margin.bottom);
+ DDX_Control(pDX, IDC_SPIN9, m_marginbottomspin);
+ DDX_Control(pDX, IDC_COLORPRI, m_color[0]);
+ DDX_Control(pDX, IDC_COLORSEC, m_color[1]);
+ DDX_Control(pDX, IDC_COLOROUTL, m_color[2]);
+ DDX_Control(pDX, IDC_COLORSHAD, m_color[3]);
+ DDX_Slider(pDX, IDC_SLIDER2, m_alpha[0]);
+ DDX_Slider(pDX, IDC_SLIDER3, m_alpha[1]);
+ DDX_Slider(pDX, IDC_SLIDER5, m_alpha[2]);
+ DDX_Slider(pDX, IDC_SLIDER6, m_alpha[3]);
+ DDX_Control(pDX, IDC_SLIDER2, m_alphasliders[0]);
+ DDX_Control(pDX, IDC_SLIDER3, m_alphasliders[1]);
+ DDX_Control(pDX, IDC_SLIDER5, m_alphasliders[2]);
+ DDX_Control(pDX, IDC_SLIDER6, m_alphasliders[3]);
+ DDX_Check(pDX, IDC_CHECK1, m_linkalphasliders);
}
void CStyleEditorDialog::UpdateControlData(bool fSave)
{
- if (fSave) {
- UpdateData();
-
- if (m_iCharset >= 0) {
- m_stss.charSet = m_charset.GetItemData(m_iCharset);
- }
- m_stss.fontSpacing = m_spacing;
- m_stss.fontAngleZ = m_angle;
- m_stss.fontScaleX = m_scalex;
- m_stss.fontScaleY = m_scaley;
-
- m_stss.borderStyle = m_borderstyle;
- m_stss.outlineWidthX = m_stss.outlineWidthY = m_borderwidth;
- m_stss.shadowDepthX = m_stss.shadowDepthY = m_shadowdepth;
-
- m_stss.scrAlignment = m_screenalignment+1;
- m_stss.marginRect = m_margin;
-
- for (ptrdiff_t i = 0; i < 4; i++) {
- m_stss.alpha[i] = 255-m_alpha[i];
- }
- } else {
- m_font.SetWindowText(m_stss.fontName);
- m_iCharset = -1;
- for (ptrdiff_t i = 0; i < CharSetLen; i++) {
- CString str;
- str.Format(_T("%s (%d)"), CharSetNames[i], CharSetList[i]);
- m_charset.AddString(str);
- m_charset.SetItemData(i, CharSetList[i]);
- if (m_stss.charSet == CharSetList[i]) {
- m_iCharset = i;
- }
- }
- // TODO: allow floats in these edit boxes
- m_spacing = (int)m_stss.fontSpacing;
- m_spacingspin.SetRange32(-10000, 10000);
- while (m_stss.fontAngleZ < 0) {
- m_stss.fontAngleZ += 360;
- }
- m_angle = (int)fmod(m_stss.fontAngleZ, 360);
- m_anglespin.SetRange32(0, 359);
- m_scalex = (int)m_stss.fontScaleX;
- m_scalexspin.SetRange32(-10000, 10000);
- m_scaley = (int)m_stss.fontScaleY;
- m_scaleyspin.SetRange32(-10000, 10000);
-
- m_borderstyle = m_stss.borderStyle;
- m_borderwidth = (int)min(m_stss.outlineWidthX, m_stss.outlineWidthY);
- m_borderwidthspin.SetRange32(0, 10000);
- m_shadowdepth = (int)min(m_stss.shadowDepthX, m_stss.shadowDepthY);
- m_shadowdepthspin.SetRange32(0, 10000);
-
- m_screenalignment = m_stss.scrAlignment-1;
- m_margin = m_stss.marginRect;
- m_marginleftspin.SetRange32(-10000, 10000);
- m_marginrightspin.SetRange32(-10000, 10000);
- m_margintopspin.SetRange32(-10000, 10000);
- m_marginbottomspin.SetRange32(-10000, 10000);
-
- for (ptrdiff_t i = 0; i < 4; i++) {
- m_color[i].SetColorPtr(&m_stss.colors[i]);
- m_alpha[i] = 255-m_stss.alpha[i];
- m_alphasliders[i].SetRange(0, 255);
- }
-
- m_linkalphasliders = FALSE;
-
- UpdateData(FALSE);
- }
+ if (fSave) {
+ UpdateData();
+
+ if (m_iCharset >= 0) {
+ m_stss.charSet = m_charset.GetItemData(m_iCharset);
+ }
+ m_stss.fontSpacing = m_spacing;
+ m_stss.fontAngleZ = m_angle;
+ m_stss.fontScaleX = m_scalex;
+ m_stss.fontScaleY = m_scaley;
+
+ m_stss.borderStyle = m_borderstyle;
+ m_stss.outlineWidthX = m_stss.outlineWidthY = m_borderwidth;
+ m_stss.shadowDepthX = m_stss.shadowDepthY = m_shadowdepth;
+
+ m_stss.scrAlignment = m_screenalignment + 1;
+ m_stss.marginRect = m_margin;
+
+ for (ptrdiff_t i = 0; i < 4; i++) {
+ m_stss.alpha[i] = 255 - m_alpha[i];
+ }
+ } else {
+ m_font.SetWindowText(m_stss.fontName);
+ m_iCharset = -1;
+ for (ptrdiff_t i = 0; i < CharSetLen; i++) {
+ CString str;
+ str.Format(_T("%s (%d)"), CharSetNames[i], CharSetList[i]);
+ m_charset.AddString(str);
+ m_charset.SetItemData(i, CharSetList[i]);
+ if (m_stss.charSet == CharSetList[i]) {
+ m_iCharset = i;
+ }
+ }
+ // TODO: allow floats in these edit boxes
+ m_spacing = (int)m_stss.fontSpacing;
+ m_spacingspin.SetRange32(-10000, 10000);
+ while (m_stss.fontAngleZ < 0) {
+ m_stss.fontAngleZ += 360;
+ }
+ m_angle = (int)fmod(m_stss.fontAngleZ, 360);
+ m_anglespin.SetRange32(0, 359);
+ m_scalex = (int)m_stss.fontScaleX;
+ m_scalexspin.SetRange32(-10000, 10000);
+ m_scaley = (int)m_stss.fontScaleY;
+ m_scaleyspin.SetRange32(-10000, 10000);
+
+ m_borderstyle = m_stss.borderStyle;
+ m_borderwidth = (int)min(m_stss.outlineWidthX, m_stss.outlineWidthY);
+ m_borderwidthspin.SetRange32(0, 10000);
+ m_shadowdepth = (int)min(m_stss.shadowDepthX, m_stss.shadowDepthY);
+ m_shadowdepthspin.SetRange32(0, 10000);
+
+ m_screenalignment = m_stss.scrAlignment - 1;
+ m_margin = m_stss.marginRect;
+ m_marginleftspin.SetRange32(-10000, 10000);
+ m_marginrightspin.SetRange32(-10000, 10000);
+ m_margintopspin.SetRange32(-10000, 10000);
+ m_marginbottomspin.SetRange32(-10000, 10000);
+
+ for (ptrdiff_t i = 0; i < 4; i++) {
+ m_color[i].SetColorPtr(&m_stss.colors[i]);
+ m_alpha[i] = 255 - m_stss.alpha[i];
+ m_alphasliders[i].SetRange(0, 255);
+ }
+
+ m_linkalphasliders = FALSE;
+
+ UpdateData(FALSE);
+ }
}
void CStyleEditorDialog::AskColor(int i)
{
- CColorDialog dlg(m_stss.colors[i]);
- dlg.m_cc.Flags |= CC_FULLOPEN;
- if (dlg.DoModal() == IDOK) {
- m_stss.colors[i] = dlg.m_cc.rgbResult;
- m_color[i].Invalidate();
- }
+ CColorDialog dlg(m_stss.colors[i]);
+ dlg.m_cc.Flags |= CC_FULLOPEN;
+ if (dlg.DoModal() == IDOK) {
+ m_stss.colors[i] = dlg.m_cc.rgbResult;
+ m_color[i].Invalidate();
+ }
}
BEGIN_MESSAGE_MAP(CStyleEditorDialog, CDialog)
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
- ON_STN_CLICKED(IDC_COLORPRI, OnStnClickedColorpri)
- ON_STN_CLICKED(IDC_COLORSEC, OnStnClickedColorsec)
- ON_STN_CLICKED(IDC_COLOROUTL, OnStnClickedColoroutl)
- ON_STN_CLICKED(IDC_COLORSHAD, OnStnClickedColorshad)
- ON_BN_CLICKED(IDC_CHECK1, OnBnClickedCheck1)
- ON_WM_HSCROLL()
+ ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
+ ON_STN_CLICKED(IDC_COLORPRI, OnStnClickedColorpri)
+ ON_STN_CLICKED(IDC_COLORSEC, OnStnClickedColorsec)
+ ON_STN_CLICKED(IDC_COLOROUTL, OnStnClickedColoroutl)
+ ON_STN_CLICKED(IDC_COLORSHAD, OnStnClickedColorshad)
+ ON_BN_CLICKED(IDC_CHECK1, OnBnClickedCheck1)
+ ON_WM_HSCROLL()
END_MESSAGE_MAP()
@@ -202,89 +202,89 @@ END_MESSAGE_MAP()
BOOL CStyleEditorDialog::OnInitDialog()
{
- CDialog::OnInitDialog();
+ CDialog::OnInitDialog();
- SetWindowText(_T("Style Editor - \"") + m_title + _T("\""));
+ SetWindowText(_T("Style Editor - \"") + m_title + _T("\""));
- UpdateControlData(false);
+ UpdateControlData(false);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CStyleEditorDialog::OnOK()
{
- UpdateControlData(true);
+ UpdateControlData(true);
- CDialog::OnOK();
+ CDialog::OnOK();
}
void CStyleEditorDialog::OnBnClickedButton1()
{
- LOGFONT lf;
- lf <<= m_stss;
-
- CFontDialog dlg(&lf, CF_SCREENFONTS|CF_INITTOLOGFONTSTRUCT|CF_FORCEFONTEXIST|CF_SCALABLEONLY|CF_EFFECTS);
- if (dlg.DoModal() == IDOK) {
- CString str(lf.lfFaceName);
- if (str.GetLength() > 16) {
- str = str.Left(14) + _T("...");
- }
- m_font.SetWindowText(str);
-
- for (int i = 0, j = m_charset.GetCount(); i < j; i++) {
- if (m_charset.GetItemData(i) == lf.lfCharSet) {
- m_charset.SetCurSel(i);
- break;
- }
- }
-
- m_stss = lf;
- }
+ LOGFONT lf;
+ lf <<= m_stss;
+
+ CFontDialog dlg(&lf, CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT | CF_FORCEFONTEXIST | CF_SCALABLEONLY | CF_EFFECTS);
+ if (dlg.DoModal() == IDOK) {
+ CString str(lf.lfFaceName);
+ if (str.GetLength() > 16) {
+ str = str.Left(14) + _T("...");
+ }
+ m_font.SetWindowText(str);
+
+ for (int i = 0, j = m_charset.GetCount(); i < j; i++) {
+ if (m_charset.GetItemData(i) == lf.lfCharSet) {
+ m_charset.SetCurSel(i);
+ break;
+ }
+ }
+
+ m_stss = lf;
+ }
}
void CStyleEditorDialog::OnStnClickedColorpri()
{
- AskColor(0);
+ AskColor(0);
}
void CStyleEditorDialog::OnStnClickedColorsec()
{
- AskColor(1);
+ AskColor(1);
}
void CStyleEditorDialog::OnStnClickedColoroutl()
{
- AskColor(2);
+ AskColor(2);
}
void CStyleEditorDialog::OnStnClickedColorshad()
{
- AskColor(3);
+ AskColor(3);
}
void CStyleEditorDialog::OnBnClickedCheck1()
{
- UpdateData();
-
- int avg = 0;
- for (ptrdiff_t i = 0; i < 4; i++) {
- avg += m_alphasliders[i].GetPos();
- }
- avg /= 4;
- for (ptrdiff_t i = 0; i < 4; i++) {
- m_alphasliders[i].SetPos(avg);
- }
+ UpdateData();
+
+ int avg = 0;
+ for (ptrdiff_t i = 0; i < 4; i++) {
+ avg += m_alphasliders[i].GetPos();
+ }
+ avg /= 4;
+ for (ptrdiff_t i = 0; i < 4; i++) {
+ m_alphasliders[i].SetPos(avg);
+ }
}
void CStyleEditorDialog::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
- if (m_linkalphasliders && pScrollBar) {
- int pos = ((CSliderCtrl*)pScrollBar)->GetPos();
- for (ptrdiff_t i = 0; i < 4; i++) {
- m_alphasliders[i].SetPos(pos);
- }
- }
-
- CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
+ if (m_linkalphasliders && pScrollBar) {
+ int pos = ((CSliderCtrl*)pScrollBar)->GetPos();
+ for (ptrdiff_t i = 0; i < 4; i++) {
+ m_alphasliders[i].SetPos(pos);
+ }
+ }
+
+ CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
diff --git a/src/filters/transform/VSFilter/StyleEditorDialog.h b/src/filters/transform/VSFilter/StyleEditorDialog.h
index 7c7823594..a4867476a 100644
--- a/src/filters/transform/VSFilter/StyleEditorDialog.h
+++ b/src/filters/transform/VSFilter/StyleEditorDialog.h
@@ -31,89 +31,89 @@
class CColorStatic : public CStatic
{
- DECLARE_DYNAMIC(CColorStatic)
+ DECLARE_DYNAMIC(CColorStatic)
- COLORREF* m_pColor;
+ COLORREF* m_pColor;
public:
- CColorStatic(CWnd* pParent = NULL) : m_pColor(NULL) {}
- virtual ~CColorStatic() {}
+ CColorStatic(CWnd* pParent = NULL) : m_pColor(NULL) {}
+ virtual ~CColorStatic() {}
- void SetColorPtr(COLORREF* pColor) {
- m_pColor = pColor;
- }
+ void SetColorPtr(COLORREF* pColor) {
+ m_pColor = pColor;
+ }
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
protected:
- virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) {
- CRect r;
- GetClientRect(r);
- CDC::FromHandle(lpDrawItemStruct->hDC)->FillSolidRect(r, m_pColor ? *m_pColor : ::GetSysColor(COLOR_BTNFACE));
- }
+ virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) {
+ CRect r;
+ GetClientRect(r);
+ CDC::FromHandle(lpDrawItemStruct->hDC)->FillSolidRect(r, m_pColor ? *m_pColor : ::GetSysColor(COLOR_BTNFACE));
+ }
};
// CStyleEditorDialog dialog
class CStyleEditorDialog : public CDialog
{
- DECLARE_DYNAMIC(CStyleEditorDialog)
+ DECLARE_DYNAMIC(CStyleEditorDialog)
- CString m_title;
- CWnd* m_pParent;
+ CString m_title;
+ CWnd* m_pParent;
- void UpdateControlData(bool fSave);
- void AskColor(int i);
+ void UpdateControlData(bool fSave);
+ void AskColor(int i);
public:
- CStyleEditorDialog(CString title, STSStyle* pstss, CWnd* pParent = NULL); // standard constructor
- virtual ~CStyleEditorDialog();
+ CStyleEditorDialog(CString title, STSStyle* pstss, CWnd* pParent = NULL); // standard constructor
+ virtual ~CStyleEditorDialog();
- // Dialog Data
- enum { IDD = IDD_STYLEDIALOG };
+ // Dialog Data
+ enum { IDD = IDD_STYLEDIALOG };
- STSStyle m_stss;
+ STSStyle m_stss;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual void OnOK();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual void OnOK();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- CButton m_font;
- int m_iCharset;
- CComboBox m_charset;
- int m_spacing;
- CSpinButtonCtrl m_spacingspin;
- int m_angle;
- CSpinButtonCtrl m_anglespin;
- int m_scalex;
- CSpinButtonCtrl m_scalexspin;
- int m_scaley;
- CSpinButtonCtrl m_scaleyspin;
- int m_borderstyle;
- int m_borderwidth;
- CSpinButtonCtrl m_borderwidthspin;
- int m_shadowdepth;
- CSpinButtonCtrl m_shadowdepthspin;
- int m_screenalignment;
- CRect m_margin;
- CSpinButtonCtrl m_marginleftspin;
- CSpinButtonCtrl m_marginrightspin;
- CSpinButtonCtrl m_margintopspin;
- CSpinButtonCtrl m_marginbottomspin;
- CColorStatic m_color[4];
- int m_alpha[4];
- CSliderCtrl m_alphasliders[4];
- BOOL m_linkalphasliders;
-
- afx_msg void OnBnClickedButton1();
- afx_msg void OnStnClickedColorpri();
- afx_msg void OnStnClickedColorsec();
- afx_msg void OnStnClickedColoroutl();
- afx_msg void OnStnClickedColorshad();
- afx_msg void OnBnClickedCheck1();
- afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
+ CButton m_font;
+ int m_iCharset;
+ CComboBox m_charset;
+ int m_spacing;
+ CSpinButtonCtrl m_spacingspin;
+ int m_angle;
+ CSpinButtonCtrl m_anglespin;
+ int m_scalex;
+ CSpinButtonCtrl m_scalexspin;
+ int m_scaley;
+ CSpinButtonCtrl m_scaleyspin;
+ int m_borderstyle;
+ int m_borderwidth;
+ CSpinButtonCtrl m_borderwidthspin;
+ int m_shadowdepth;
+ CSpinButtonCtrl m_shadowdepthspin;
+ int m_screenalignment;
+ CRect m_margin;
+ CSpinButtonCtrl m_marginleftspin;
+ CSpinButtonCtrl m_marginrightspin;
+ CSpinButtonCtrl m_margintopspin;
+ CSpinButtonCtrl m_marginbottomspin;
+ CColorStatic m_color[4];
+ int m_alpha[4];
+ CSliderCtrl m_alphasliders[4];
+ BOOL m_linkalphasliders;
+
+ afx_msg void OnBnClickedButton1();
+ afx_msg void OnStnClickedColorpri();
+ afx_msg void OnStnClickedColorsec();
+ afx_msg void OnStnClickedColoroutl();
+ afx_msg void OnStnClickedColorshad();
+ afx_msg void OnBnClickedCheck1();
+ afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
};
diff --git a/src/filters/transform/VSFilter/Systray.cpp b/src/filters/transform/VSFilter/Systray.cpp
index 6b7d48bd3..a4aeb6e5b 100644
--- a/src/filters/transform/VSFilter/Systray.cpp
+++ b/src/filters/transform/VSFilter/Systray.cpp
@@ -42,303 +42,303 @@ static UINT WM_NOTIFYICON = RegisterWindowMessage(_T("MYWM_NOTIFYICON"));
LRESULT CALLBACK HookProc(UINT code, WPARAM wParam, LPARAM lParam)
{
- MSG* msg = (MSG*)lParam;
-
- if (msg->message == WM_KEYDOWN) {
- switch (msg->wParam) {
- case VK_F13:
- PostMessage(HWND_BROADCAST, WM_DVSPREVSUB, 0, 0);
- break;
- case VK_F14:
- PostMessage(HWND_BROADCAST, WM_DVSNEXTSUB, 0, 0);
- break;
- case VK_F15:
- PostMessage(HWND_BROADCAST, WM_DVSHIDESUB, 0, 0);
- break;
- case VK_F16:
- PostMessage(HWND_BROADCAST, WM_DVSSHOWSUB, 0, 0);
- break;
- case VK_F17:
- PostMessage(HWND_BROADCAST, WM_DVSSHOWHIDESUB, 0, 0);
- break;
- default:
- break;
- }
- }
-
- // Always call next hook in chain
- return CallNextHookEx(g_hHook, code, wParam, lParam);
+ MSG* msg = (MSG*)lParam;
+
+ if (msg->message == WM_KEYDOWN) {
+ switch (msg->wParam) {
+ case VK_F13:
+ PostMessage(HWND_BROADCAST, WM_DVSPREVSUB, 0, 0);
+ break;
+ case VK_F14:
+ PostMessage(HWND_BROADCAST, WM_DVSNEXTSUB, 0, 0);
+ break;
+ case VK_F15:
+ PostMessage(HWND_BROADCAST, WM_DVSHIDESUB, 0, 0);
+ break;
+ case VK_F16:
+ PostMessage(HWND_BROADCAST, WM_DVSSHOWSUB, 0, 0);
+ break;
+ case VK_F17:
+ PostMessage(HWND_BROADCAST, WM_DVSSHOWHIDESUB, 0, 0);
+ break;
+ default:
+ break;
+ }
+ }
+
+ // Always call next hook in chain
+ return CallNextHookEx(g_hHook, code, wParam, lParam);
}
BEGIN_MESSAGE_MAP(CSystrayWindow, CWnd)
- ON_WM_CREATE()
- ON_WM_CLOSE()
- ON_WM_DESTROY()
- ON_WM_TIMER()
- ON_REGISTERED_MESSAGE(WM_DVSPREVSUB, OnDVSPrevSub)
- ON_REGISTERED_MESSAGE(WM_DVSNEXTSUB, OnDVSNextSub)
- ON_REGISTERED_MESSAGE(WM_DVSHIDESUB, OnDVSHideSub)
- ON_REGISTERED_MESSAGE(WM_DVSSHOWSUB, OnDVSShowSub)
- ON_REGISTERED_MESSAGE(WM_DVSSHOWHIDESUB, OnDVSShowHideSub)
- ON_REGISTERED_MESSAGE(s_uTaskbarRestart, OnTaskBarRestart)
- ON_REGISTERED_MESSAGE(WM_NOTIFYICON, OnNotifyIcon)
+ ON_WM_CREATE()
+ ON_WM_CLOSE()
+ ON_WM_DESTROY()
+ ON_WM_TIMER()
+ ON_REGISTERED_MESSAGE(WM_DVSPREVSUB, OnDVSPrevSub)
+ ON_REGISTERED_MESSAGE(WM_DVSNEXTSUB, OnDVSNextSub)
+ ON_REGISTERED_MESSAGE(WM_DVSHIDESUB, OnDVSHideSub)
+ ON_REGISTERED_MESSAGE(WM_DVSSHOWSUB, OnDVSShowSub)
+ ON_REGISTERED_MESSAGE(WM_DVSSHOWHIDESUB, OnDVSShowHideSub)
+ ON_REGISTERED_MESSAGE(s_uTaskbarRestart, OnTaskBarRestart)
+ ON_REGISTERED_MESSAGE(WM_NOTIFYICON, OnNotifyIcon)
END_MESSAGE_MAP()
int CSystrayWindow::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
- if (CWnd::OnCreate(lpCreateStruct) == -1) {
- return -1;
- }
+ if (CWnd::OnCreate(lpCreateStruct) == -1) {
+ return -1;
+ }
- if (g_hHook == INVALID_HANDLE_VALUE) {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- // g_hHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)HookProc, AfxGetInstanceHandle(), 0);
- }
+ if (g_hHook == INVALID_HANDLE_VALUE) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ // g_hHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)HookProc, AfxGetInstanceHandle(), 0);
+ }
- PostMessage(s_uTaskbarRestart);
+ PostMessage(s_uTaskbarRestart);
- return 0;
+ return 0;
}
void CSystrayWindow::OnClose()
{
- DestroyWindow();
+ DestroyWindow();
}
void CSystrayWindow::OnDestroy()
{
- NOTIFYICONDATA tnid;
- ZeroMemory(&tnid, sizeof(NOTIFYICONDATA));
- tnid.cbSize = sizeof(NOTIFYICONDATA);
- tnid.hWnd = m_hWnd;
- tnid.uID = IDI_ICON1;
- Shell_NotifyIcon(NIM_DELETE, &tnid);
-
- if (g_hHook != INVALID_HANDLE_VALUE) {
- UnhookWindowsHookEx(g_hHook);
- g_hHook = (HHOOK)INVALID_HANDLE_VALUE;
- }
-
- PostQuitMessage(0);
+ NOTIFYICONDATA tnid;
+ ZeroMemory(&tnid, sizeof(NOTIFYICONDATA));
+ tnid.cbSize = sizeof(NOTIFYICONDATA);
+ tnid.hWnd = m_hWnd;
+ tnid.uID = IDI_ICON1;
+ Shell_NotifyIcon(NIM_DELETE, &tnid);
+
+ if (g_hHook != INVALID_HANDLE_VALUE) {
+ UnhookWindowsHookEx(g_hHook);
+ g_hHook = (HHOOK)INVALID_HANDLE_VALUE;
+ }
+
+ PostQuitMessage(0);
}
LRESULT CSystrayWindow::OnDVSPrevSub(WPARAM, LPARAM)
{
- StepSub(-1);
- return 0;
+ StepSub(-1);
+ return 0;
}
LRESULT CSystrayWindow::OnDVSNextSub(WPARAM, LPARAM)
{
- StepSub(+1);
- return 0;
+ StepSub(+1);
+ return 0;
}
LRESULT CSystrayWindow::OnDVSHideSub(WPARAM, LPARAM)
{
- ShowSub(false);
- return 0;
+ ShowSub(false);
+ return 0;
}
LRESULT CSystrayWindow::OnDVSShowSub(WPARAM, LPARAM)
{
- ShowSub(true);
- return 0;
+ ShowSub(true);
+ return 0;
}
LRESULT CSystrayWindow::OnDVSShowHideSub(WPARAM, LPARAM)
{
- ToggleSub();
- return 0;
+ ToggleSub();
+ return 0;
}
LRESULT CSystrayWindow::OnTaskBarRestart(WPARAM, LPARAM)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- if (m_tbid->fShowIcon) {
- NOTIFYICONDATA tnid;
- ZeroMemory(&tnid, sizeof(NOTIFYICONDATA));
- tnid.cbSize = sizeof(NOTIFYICONDATA);
- tnid.hWnd = m_hWnd;
- tnid.uID = IDI_ICON1;
- tnid.hIcon = (HICON)LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON1));
- //tnid.hIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 0, 0, LR_LOADTRANSPARENT);
- tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
- tnid.uCallbackMessage = WM_NOTIFYICON;
- _tcscpy_s(tnid.szTip, _T("DirectVobSub"));
-
- BOOL res = Shell_NotifyIcon(NIM_ADD, &tnid);
-
- if (tnid.hIcon) {
- DestroyIcon(tnid.hIcon);
- }
-
- return res ? 0 : -1;
- }
-
- return 0;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ if (m_tbid->fShowIcon) {
+ NOTIFYICONDATA tnid;
+ ZeroMemory(&tnid, sizeof(NOTIFYICONDATA));
+ tnid.cbSize = sizeof(NOTIFYICONDATA);
+ tnid.hWnd = m_hWnd;
+ tnid.uID = IDI_ICON1;
+ tnid.hIcon = (HICON)LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON1));
+ //tnid.hIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 0, 0, LR_LOADTRANSPARENT);
+ tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
+ tnid.uCallbackMessage = WM_NOTIFYICON;
+ _tcscpy_s(tnid.szTip, _T("DirectVobSub"));
+
+ BOOL res = Shell_NotifyIcon(NIM_ADD, &tnid);
+
+ if (tnid.hIcon) {
+ DestroyIcon(tnid.hIcon);
+ }
+
+ return res ? 0 : -1;
+ }
+
+ return 0;
}
LRESULT CSystrayWindow::OnNotifyIcon(WPARAM wParam, LPARAM lParam)
{
- if ((UINT)wParam != IDI_ICON1) {
- return -1;
- }
-
- HWND hWnd = m_hWnd;
-
- switch ((UINT)lParam) {
- case WM_LBUTTONDBLCLK: {
- // IMPORTANT: we must not hold the graph at the same time as showing the property page
- // or else when closing the app the graph doesn't get released and dvobsub's JoinFilterGraph
- // is never called to close us down.
-
- CComPtr<IBaseFilter> pBF2;
-
- BeginEnumFilters(m_tbid->graph, pEF, pBF) {
- if (!CComQIPtr<IDirectVobSub>(pBF)) {
- continue;
- }
-
- if (CComQIPtr<IVideoWindow> pVW = m_tbid->graph) {
- HWND hwnd;
- if (SUCCEEDED(pVW->get_Owner((OAHWND*)&hwnd))
- || SUCCEEDED(pVW->get_MessageDrain((OAHWND*)&hwnd))) {
- hWnd = hwnd;
- }
- }
-
- pBF2 = pBF;
-
- break;
- }
- EndEnumFilters
-
- if (pBF2) {
- ShowPPage(pBF2, hWnd);
- }
- }
- break;
-
- case WM_RBUTTONDOWN: {
- POINT p;
- GetCursorPos(&p);
-
- CInterfaceArray<IAMStreamSelect> pStreams;
- CStringArray names;
-
- BeginEnumFilters(m_tbid->graph, pEF, pBF) {
- CString name = GetFilterName(pBF);
- if (name.IsEmpty()) {
- continue;
- }
-
- if (CComQIPtr<IAMStreamSelect> pSS = pBF) {
- pStreams.Add(pSS);
- names.Add(name);
- }
- }
- EndEnumFilters
-
- CMenu popup;
- popup.CreatePopupMenu();
-
- for (size_t j = 0; j < pStreams.GetCount(); j++) {
- bool fMMSwitcher = !names[j].Compare(_T("Morgan Stream Switcher"));
-
- DWORD cStreams = 0;
- pStreams[j]->Count(&cStreams);
-
- DWORD flags, group, prevgroup = (DWORD)-1;
-
- for (UINT i = 0; i < cStreams; i++) {
- WCHAR* pName = NULL;
-
- if (S_OK == pStreams[j]->Info(i, 0, &flags, 0, &group, &pName, 0, 0)) {
- if (prevgroup != group && i > 1) {
- if (fMMSwitcher) {
- cStreams = i;
- break;
- }
- popup.AppendMenu(MF_SEPARATOR);
- }
- prevgroup = group;
-
- if (pName) {
- popup.AppendMenu(MF_ENABLED|MF_STRING|(flags?MF_CHECKED:MF_UNCHECKED), (1<<15)|(j<<8)|(i), CString(pName));
- CoTaskMemFree(pName);
- }
- }
- }
-
- if (cStreams > 0) {
- popup.AppendMenu(MF_SEPARATOR);
- }
- }
-
- int i = 0;
-
- TCHAR* str;
- str = CallPPage(m_tbid->graph, i, (HWND)INVALID_HANDLE_VALUE);
- while (str) {
- if (_tcsncmp(str, _T("DivX MPEG"), 9) || m_tbid->fRunOnce) { // divx3's ppage will crash if the graph hasn't been run at least once yet
- popup.AppendMenu(MF_ENABLED|MF_STRING|MF_UNCHECKED, (1<<14)|(i), str);
- }
-
- delete [] str;
-
- i++;
- str = CallPPage(m_tbid->graph, i, (HWND)INVALID_HANDLE_VALUE);
- }
-
- SetForegroundWindow();
- UINT id = popup.TrackPopupMenu(TPM_LEFTBUTTON|TPM_RETURNCMD, p.x, p.y, CWnd::FromHandle(hWnd), 0);
- PostMessage(WM_NULL);
-
- if (id & (1<<15)) {
- pStreams[(id>>8)&0x3f]->Enable(id&0xff, AMSTREAMSELECTENABLE_ENABLE);
- } else if (id & (1<<14)) {
- if (CComQIPtr<IVideoWindow> pVW = m_tbid->graph) {
- HWND hwnd;
- if (SUCCEEDED(pVW->get_Owner((OAHWND*)&hwnd))
- || SUCCEEDED(pVW->get_MessageDrain((OAHWND*)&hwnd))) {
- hWnd = hwnd;
- }
- }
-
- CallPPage(m_tbid->graph, id&0xff, hWnd);
- }
- }
- break;
-
- default:
- break;
- }
-
- return 0;
+ if ((UINT)wParam != IDI_ICON1) {
+ return -1;
+ }
+
+ HWND hWnd = m_hWnd;
+
+ switch ((UINT)lParam) {
+ case WM_LBUTTONDBLCLK: {
+ // IMPORTANT: we must not hold the graph at the same time as showing the property page
+ // or else when closing the app the graph doesn't get released and dvobsub's JoinFilterGraph
+ // is never called to close us down.
+
+ CComPtr<IBaseFilter> pBF2;
+
+ BeginEnumFilters(m_tbid->graph, pEF, pBF) {
+ if (!CComQIPtr<IDirectVobSub>(pBF)) {
+ continue;
+ }
+
+ if (CComQIPtr<IVideoWindow> pVW = m_tbid->graph) {
+ HWND hwnd;
+ if (SUCCEEDED(pVW->get_Owner((OAHWND*)&hwnd))
+ || SUCCEEDED(pVW->get_MessageDrain((OAHWND*)&hwnd))) {
+ hWnd = hwnd;
+ }
+ }
+
+ pBF2 = pBF;
+
+ break;
+ }
+ EndEnumFilters
+
+ if (pBF2) {
+ ShowPPage(pBF2, hWnd);
+ }
+ }
+ break;
+
+ case WM_RBUTTONDOWN: {
+ POINT p;
+ GetCursorPos(&p);
+
+ CInterfaceArray<IAMStreamSelect> pStreams;
+ CStringArray names;
+
+ BeginEnumFilters(m_tbid->graph, pEF, pBF) {
+ CString name = GetFilterName(pBF);
+ if (name.IsEmpty()) {
+ continue;
+ }
+
+ if (CComQIPtr<IAMStreamSelect> pSS = pBF) {
+ pStreams.Add(pSS);
+ names.Add(name);
+ }
+ }
+ EndEnumFilters
+
+ CMenu popup;
+ popup.CreatePopupMenu();
+
+ for (size_t j = 0; j < pStreams.GetCount(); j++) {
+ bool fMMSwitcher = !names[j].Compare(_T("Morgan Stream Switcher"));
+
+ DWORD cStreams = 0;
+ pStreams[j]->Count(&cStreams);
+
+ DWORD flags, group, prevgroup = (DWORD) - 1;
+
+ for (UINT i = 0; i < cStreams; i++) {
+ WCHAR* pName = NULL;
+
+ if (S_OK == pStreams[j]->Info(i, 0, &flags, 0, &group, &pName, 0, 0)) {
+ if (prevgroup != group && i > 1) {
+ if (fMMSwitcher) {
+ cStreams = i;
+ break;
+ }
+ popup.AppendMenu(MF_SEPARATOR);
+ }
+ prevgroup = group;
+
+ if (pName) {
+ popup.AppendMenu(MF_ENABLED | MF_STRING | (flags ? MF_CHECKED : MF_UNCHECKED), (1 << 15) | (j << 8) | (i), CString(pName));
+ CoTaskMemFree(pName);
+ }
+ }
+ }
+
+ if (cStreams > 0) {
+ popup.AppendMenu(MF_SEPARATOR);
+ }
+ }
+
+ int i = 0;
+
+ TCHAR* str;
+ str = CallPPage(m_tbid->graph, i, (HWND)INVALID_HANDLE_VALUE);
+ while (str) {
+ if (_tcsncmp(str, _T("DivX MPEG"), 9) || m_tbid->fRunOnce) { // divx3's ppage will crash if the graph hasn't been run at least once yet
+ popup.AppendMenu(MF_ENABLED | MF_STRING | MF_UNCHECKED, (1 << 14) | (i), str);
+ }
+
+ delete [] str;
+
+ i++;
+ str = CallPPage(m_tbid->graph, i, (HWND)INVALID_HANDLE_VALUE);
+ }
+
+ SetForegroundWindow();
+ UINT id = popup.TrackPopupMenu(TPM_LEFTBUTTON | TPM_RETURNCMD, p.x, p.y, CWnd::FromHandle(hWnd), 0);
+ PostMessage(WM_NULL);
+
+ if (id & (1 << 15)) {
+ pStreams[(id >> 8) & 0x3f]->Enable(id & 0xff, AMSTREAMSELECTENABLE_ENABLE);
+ } else if (id & (1 << 14)) {
+ if (CComQIPtr<IVideoWindow> pVW = m_tbid->graph) {
+ HWND hwnd;
+ if (SUCCEEDED(pVW->get_Owner((OAHWND*)&hwnd))
+ || SUCCEEDED(pVW->get_MessageDrain((OAHWND*)&hwnd))) {
+ hWnd = hwnd;
+ }
+ }
+
+ CallPPage(m_tbid->graph, id & 0xff, hWnd);
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return 0;
}
//
DWORD CALLBACK SystrayThreadProc(void* pParam)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CSystrayWindow wnd((SystrayIconData*)pParam);
- if (!wnd.CreateEx(0, AfxRegisterWndClass(0), _T("DVSWND"), WS_OVERLAPPED, CRect(0, 0, 0, 0), NULL, 0, NULL)) {
- return (DWORD)-1;
- }
+ CSystrayWindow wnd((SystrayIconData*)pParam);
+ if (!wnd.CreateEx(0, AfxRegisterWndClass(0), _T("DVSWND"), WS_OVERLAPPED, CRect(0, 0, 0, 0), NULL, 0, NULL)) {
+ return (DWORD) - 1;
+ }
- ((SystrayIconData*)pParam)->hSystrayWnd = wnd.m_hWnd;
+ ((SystrayIconData*)pParam)->hSystrayWnd = wnd.m_hWnd;
- MSG msg;
- while (GetMessage(&msg, NULL/*wnd.m_hWnd*/, 0, 0)) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
+ MSG msg;
+ while (GetMessage(&msg, NULL/*wnd.m_hWnd*/, 0, 0)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
- return 0;
+ return 0;
}
// TODO: replace this function
@@ -346,51 +346,51 @@ DWORD CALLBACK SystrayThreadProc(void* pParam)
// hWnd == INVALID_HANDLE_VALUE - get name, hWnd != INVALID_HANDLE_VALUE - show ppage
static TCHAR* CallPPage(IFilterGraph* pGraph, int idx, HWND hWnd)
{
- int i = 0;
- //bool fFound = false;
-
- WCHAR* wstr = NULL;
- CComPtr<IBaseFilter> pFilter;
- CAUUID caGUID;
- caGUID.pElems = NULL;
-
- BeginEnumFilters(pGraph, pEF, pBF) {
- CComQIPtr<ISpecifyPropertyPages> pSPS = pBF;
-
- if (!pSPS) {
- continue;
- }
-
- if (i == idx) {
- pFilter = pBF;
- pSPS->GetPages(&caGUID);
- wstr = _wcsdup(CStringW(GetFilterName(pBF))); // double char-wchar conversion happens in the non-unicode build, but anyway... :)
- break;
- }
-
- i++;
- }
- EndEnumFilters
-
- TCHAR* ret = NULL;
-
- if (pFilter) {
- if (hWnd != INVALID_HANDLE_VALUE) {
- ShowPPage(pFilter, hWnd);
- } else {
- ret = DNew TCHAR[wcslen(wstr)+1];
- if (ret) {
- _tcscpy_s(ret, wcslen(wstr) + 1, CString(wstr));
- }
- }
- }
-
- if (caGUID.pElems) {
- CoTaskMemFree(caGUID.pElems);
- }
- if (wstr) {
- free(wstr);
- }
-
- return ret;
+ int i = 0;
+ //bool fFound = false;
+
+ WCHAR* wstr = NULL;
+ CComPtr<IBaseFilter> pFilter;
+ CAUUID caGUID;
+ caGUID.pElems = NULL;
+
+ BeginEnumFilters(pGraph, pEF, pBF) {
+ CComQIPtr<ISpecifyPropertyPages> pSPS = pBF;
+
+ if (!pSPS) {
+ continue;
+ }
+
+ if (i == idx) {
+ pFilter = pBF;
+ pSPS->GetPages(&caGUID);
+ wstr = _wcsdup(CStringW(GetFilterName(pBF))); // double char-wchar conversion happens in the non-unicode build, but anyway... :)
+ break;
+ }
+
+ i++;
+ }
+ EndEnumFilters
+
+ TCHAR* ret = NULL;
+
+ if (pFilter) {
+ if (hWnd != INVALID_HANDLE_VALUE) {
+ ShowPPage(pFilter, hWnd);
+ } else {
+ ret = DNew TCHAR[wcslen(wstr) + 1];
+ if (ret) {
+ _tcscpy_s(ret, wcslen(wstr) + 1, CString(wstr));
+ }
+ }
+ }
+
+ if (caGUID.pElems) {
+ CoTaskMemFree(caGUID.pElems);
+ }
+ if (wstr) {
+ free(wstr);
+ }
+
+ return ret;
}
diff --git a/src/filters/transform/VSFilter/Systray.h b/src/filters/transform/VSFilter/Systray.h
index 00b4dc985..f7d823c5a 100644
--- a/src/filters/transform/VSFilter/Systray.h
+++ b/src/filters/transform/VSFilter/Systray.h
@@ -25,50 +25,50 @@
class CSystrayWindow : public CWnd
{
- SystrayIconData* m_tbid;
+ SystrayIconData* m_tbid;
- void StepSub(int dir) {
- int iSelected, nLangs;
- if (FAILED(m_tbid->dvs->get_LanguageCount(&nLangs))) {
- return;
- }
- if (FAILED(m_tbid->dvs->get_SelectedLanguage(&iSelected))) {
- return;
- }
- if (nLangs > 0) {
- m_tbid->dvs->put_SelectedLanguage((iSelected+dir+nLangs)%nLangs);
- }
- }
+ void StepSub(int dir) {
+ int iSelected, nLangs;
+ if (FAILED(m_tbid->dvs->get_LanguageCount(&nLangs))) {
+ return;
+ }
+ if (FAILED(m_tbid->dvs->get_SelectedLanguage(&iSelected))) {
+ return;
+ }
+ if (nLangs > 0) {
+ m_tbid->dvs->put_SelectedLanguage((iSelected + dir + nLangs) % nLangs);
+ }
+ }
- void ShowSub(bool fShow) {
- m_tbid->dvs->put_HideSubtitles(!fShow);
- }
+ void ShowSub(bool fShow) {
+ m_tbid->dvs->put_HideSubtitles(!fShow);
+ }
- void ToggleSub() {
- bool fShow;
- if (FAILED(m_tbid->dvs->get_HideSubtitles(&fShow))) {
- return;
- }
- m_tbid->dvs->put_HideSubtitles(!fShow);
- }
+ void ToggleSub() {
+ bool fShow;
+ if (FAILED(m_tbid->dvs->get_HideSubtitles(&fShow))) {
+ return;
+ }
+ m_tbid->dvs->put_HideSubtitles(!fShow);
+ }
public:
- CSystrayWindow(SystrayIconData* tbid) : m_tbid(tbid) {}
+ CSystrayWindow(SystrayIconData* tbid) : m_tbid(tbid) {}
protected:
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
- afx_msg void OnClose();
- afx_msg void OnDestroy();
- afx_msg LRESULT OnDVSPrevSub(WPARAM, LPARAM);
- afx_msg LRESULT OnDVSNextSub(WPARAM, LPARAM);
- afx_msg LRESULT OnDVSHideSub(WPARAM, LPARAM);
- afx_msg LRESULT OnDVSShowSub(WPARAM, LPARAM);
- afx_msg LRESULT OnDVSShowHideSub(WPARAM, LPARAM);
- afx_msg LRESULT OnTaskBarRestart(WPARAM, LPARAM);
- afx_msg LRESULT OnNotifyIcon(WPARAM, LPARAM);
+ afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
+ afx_msg void OnClose();
+ afx_msg void OnDestroy();
+ afx_msg LRESULT OnDVSPrevSub(WPARAM, LPARAM);
+ afx_msg LRESULT OnDVSNextSub(WPARAM, LPARAM);
+ afx_msg LRESULT OnDVSHideSub(WPARAM, LPARAM);
+ afx_msg LRESULT OnDVSShowSub(WPARAM, LPARAM);
+ afx_msg LRESULT OnDVSShowHideSub(WPARAM, LPARAM);
+ afx_msg LRESULT OnTaskBarRestart(WPARAM, LPARAM);
+ afx_msg LRESULT OnNotifyIcon(WPARAM, LPARAM);
};
extern DWORD CALLBACK SystrayThreadProc(void* pParam);
diff --git a/src/filters/transform/VSFilter/TextInputPin.cpp b/src/filters/transform/VSFilter/TextInputPin.cpp
index 5fecb70e0..0fdba3289 100644
--- a/src/filters/transform/VSFilter/TextInputPin.cpp
+++ b/src/filters/transform/VSFilter/TextInputPin.cpp
@@ -27,22 +27,22 @@
#include "../../../DSUtil/DSUtil.h"
CTextInputPin::CTextInputPin(CDirectVobSubFilter* pFilter, CCritSec* pLock, CCritSec* pSubLock, HRESULT* phr)
- : CSubtitleInputPin(pFilter, pLock, pSubLock, phr)
- , m_pDVS(pFilter)
+ : CSubtitleInputPin(pFilter, pLock, pSubLock, phr)
+ , m_pDVS(pFilter)
{
}
void CTextInputPin::AddSubStream(ISubStream* pSubStream)
{
- m_pDVS->AddSubStream(pSubStream);
+ m_pDVS->AddSubStream(pSubStream);
}
void CTextInputPin::RemoveSubStream(ISubStream* pSubStream)
{
- m_pDVS->RemoveSubStream(pSubStream);
+ m_pDVS->RemoveSubStream(pSubStream);
}
void CTextInputPin::InvalidateSubtitle(REFERENCE_TIME rtStart, ISubStream* pSubStream)
{
- m_pDVS->InvalidateSubtitle(rtStart, (DWORD_PTR)(ISubStream*)pSubStream);
+ m_pDVS->InvalidateSubtitle(rtStart, (DWORD_PTR)(ISubStream*)pSubStream);
}
diff --git a/src/filters/transform/VSFilter/TextInputPin.h b/src/filters/transform/VSFilter/TextInputPin.h
index 3038b9f51..9a5078fd1 100644
--- a/src/filters/transform/VSFilter/TextInputPin.h
+++ b/src/filters/transform/VSFilter/TextInputPin.h
@@ -29,13 +29,13 @@ class CDirectVobSubFilter;
class CTextInputPin : public CSubtitleInputPin
{
- CDirectVobSubFilter* m_pDVS;
+ CDirectVobSubFilter* m_pDVS;
protected:
- void AddSubStream(ISubStream* pSubStream);
- void RemoveSubStream(ISubStream* pSubStream);
- void InvalidateSubtitle(REFERENCE_TIME rtStart, ISubStream* pSubStream);
+ void AddSubStream(ISubStream* pSubStream);
+ void RemoveSubStream(ISubStream* pSubStream);
+ void InvalidateSubtitle(REFERENCE_TIME rtStart, ISubStream* pSubStream);
public:
- CTextInputPin(CDirectVobSubFilter* pFilter, CCritSec* pLock, CCritSec* pSubLock, HRESULT* phr);
+ CTextInputPin(CDirectVobSubFilter* pFilter, CCritSec* pLock, CCritSec* pSubLock, HRESULT* phr);
};
diff --git a/src/filters/transform/VSFilter/VSFilter.cpp b/src/filters/transform/VSFilter/VSFilter.cpp
index c6b82a502..96a4c18d6 100644
--- a/src/filters/transform/VSFilter/VSFilter.cpp
+++ b/src/filters/transform/VSFilter/VSFilter.cpp
@@ -44,39 +44,39 @@ extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);
BOOL CVSFilterApp::InitInstance()
{
- if (!CWinApp::InitInstance()) {
- return FALSE;
- }
+ if (!CWinApp::InitInstance()) {
+ return FALSE;
+ }
- SetRegistryKey(_T("Gabest"));
+ SetRegistryKey(_T("Gabest"));
- DllEntryPoint(AfxGetInstanceHandle(), DLL_PROCESS_ATTACH, 0); // "DllMain" of the dshow baseclasses
+ DllEntryPoint(AfxGetInstanceHandle(), DLL_PROCESS_ATTACH, 0); // "DllMain" of the dshow baseclasses
- STARTUPINFO si;
- GetStartupInfo(&si);
- m_AppName = CString(si.lpTitle);
- m_AppName.Replace('\\', '/');
- m_AppName = m_AppName.Mid(m_AppName.ReverseFind('/')+1);
- m_AppName.MakeLower();
+ STARTUPINFO si;
+ GetStartupInfo(&si);
+ m_AppName = CString(si.lpTitle);
+ m_AppName.Replace('\\', '/');
+ m_AppName = m_AppName.Mid(m_AppName.ReverseFind('/') + 1);
+ m_AppName.MakeLower();
- return TRUE;
+ return TRUE;
}
int CVSFilterApp::ExitInstance()
{
- DllEntryPoint(AfxGetInstanceHandle(), DLL_PROCESS_DETACH, 0); // "DllMain" of the dshow baseclasses
+ DllEntryPoint(AfxGetInstanceHandle(), DLL_PROCESS_DETACH, 0); // "DllMain" of the dshow baseclasses
- return CWinApp::ExitInstance();
+ return CWinApp::ExitInstance();
}
HINSTANCE CVSFilterApp::LoadAppLangResourceDLL()
{
- CString fn;
- fn.ReleaseBufferSetLength(::GetModuleFileName(m_hInstance, fn.GetBuffer(_MAX_PATH), _MAX_PATH));
- fn = fn.Mid(fn.ReverseFind('\\')+1);
- fn = fn.Left(fn.ReverseFind('.')+1);
- fn = fn + _T("lang");
- return ::LoadLibrary(fn);
+ CString fn;
+ fn.ReleaseBufferSetLength(::GetModuleFileName(m_hInstance, fn.GetBuffer(_MAX_PATH), _MAX_PATH));
+ fn = fn.Mid(fn.ReverseFind('\\') + 1);
+ fn = fn.Left(fn.ReverseFind('.') + 1);
+ fn = fn + _T("lang");
+ return ::LoadLibrary(fn);
}
CVSFilterApp theApp;
@@ -84,49 +84,49 @@ CVSFilterApp theApp;
//////////////////////////////////////////////////////////////////////////
const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_NULL, &MEDIASUBTYPE_NULL},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_YUY2},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_YV12},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_I420},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_IYUV},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_RGB32},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_RGB565},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_RGB555},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_RGB24},
+ {&MEDIATYPE_NULL, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_YUY2},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_YV12},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_I420},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_IYUV},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_RGB32},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_RGB565},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_RGB555},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_RGB24},
};
const AMOVIESETUP_MEDIATYPE sudPinTypesIn2[] = {
- {&MEDIATYPE_Text, &MEDIASUBTYPE_NULL},
- {&MEDIATYPE_Subtitle, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_Text, &MEDIASUBTYPE_NULL},
+ {&MEDIATYPE_Subtitle, &MEDIASUBTYPE_NULL},
};
const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
- {&MEDIATYPE_Video, &MEDIASUBTYPE_None},
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_None},
};
const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut},
- {L"Input2", TRUE, FALSE, FALSE, TRUE, &CLSID_NULL, NULL, _countof(sudPinTypesIn2), sudPinTypesIn2}
+ {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesIn), sudPinTypesIn},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, _countof(sudPinTypesOut), sudPinTypesOut},
+ {L"Input2", TRUE, FALSE, FALSE, TRUE, &CLSID_NULL, NULL, _countof(sudPinTypesIn2), sudPinTypesIn2}
};
/*const*/
AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CDirectVobSubFilter), L"DirectVobSub", MERIT_DO_NOT_USE, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CDirectVobSubFilter2), L"DirectVobSub (auto-loading version)", MERIT_PREFERRED+2, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CDirectVobSubFilter), L"DirectVobSub", MERIT_DO_NOT_USE, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CDirectVobSubFilter2), L"DirectVobSub (auto-loading version)", MERIT_PREFERRED + 2, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
};
CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDirectVobSubFilter>, NULL, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CDirectVobSubFilter2>, NULL, &sudFilter[1]},
- {L"DVSMainPPage", &__uuidof(CDVSMainPPage), CreateInstance<CDVSMainPPage>},
- {L"DVSGeneralPPage", &__uuidof(CDVSGeneralPPage), CreateInstance<CDVSGeneralPPage>},
- {L"DVSMiscPPage", &__uuidof(CDVSMiscPPage), CreateInstance<CDVSMiscPPage>},
- {L"DVSTimingPPage", &__uuidof(CDVSTimingPPage), CreateInstance<CDVSTimingPPage>},
- {L"DVSZoomPPage", &__uuidof(CDVSZoomPPage), CreateInstance<CDVSZoomPPage>},
- {L"DVSColorPPage", &__uuidof(CDVSColorPPage), CreateInstance<CDVSColorPPage>},
- {L"DVSPathsPPage", &__uuidof(CDVSPathsPPage), CreateInstance<CDVSPathsPPage>},
- {L"DVSAboutPPage", &__uuidof(CDVSAboutPPage), CreateInstance<CDVSAboutPPage>},
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDirectVobSubFilter>, NULL, &sudFilter[0]},
+ {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CDirectVobSubFilter2>, NULL, &sudFilter[1]},
+ {L"DVSMainPPage", &__uuidof(CDVSMainPPage), CreateInstance<CDVSMainPPage>},
+ {L"DVSGeneralPPage", &__uuidof(CDVSGeneralPPage), CreateInstance<CDVSGeneralPPage>},
+ {L"DVSMiscPPage", &__uuidof(CDVSMiscPPage), CreateInstance<CDVSMiscPPage>},
+ {L"DVSTimingPPage", &__uuidof(CDVSTimingPPage), CreateInstance<CDVSTimingPPage>},
+ {L"DVSZoomPPage", &__uuidof(CDVSZoomPPage), CreateInstance<CDVSZoomPPage>},
+ {L"DVSColorPPage", &__uuidof(CDVSColorPPage), CreateInstance<CDVSColorPPage>},
+ {L"DVSPathsPPage", &__uuidof(CDVSPathsPPage), CreateInstance<CDVSPathsPPage>},
+ {L"DVSAboutPPage", &__uuidof(CDVSAboutPPage), CreateInstance<CDVSAboutPPage>},
};
int g_cTemplates = _countof(g_Templates);
@@ -135,42 +135,42 @@ int g_cTemplates = _countof(g_Templates);
STDAPI DllRegisterServer()
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
- if (theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SEENDIVXWARNING), 0) != 1) {
- theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SEENDIVXWARNING), 0);
- }
+ if (theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SEENDIVXWARNING), 0) != 1) {
+ theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SEENDIVXWARNING), 0);
+ }
- if (theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_VMRZOOMENABLED), -1) == -1) {
- theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_VMRZOOMENABLED), 0);
- }
+ if (theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_VMRZOOMENABLED), -1) == -1) {
+ theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_VMRZOOMENABLED), 0);
+ }
- if (theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ENABLEZPICON), -1) == -1) {
- theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ENABLEZPICON), 0);
- }
+ if (theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ENABLEZPICON), -1) == -1) {
+ theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ENABLEZPICON), 0);
+ }
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- // DVS_WriteProfileInt2(IDS_R_GENERAL, IDS_RG_SEENDIVXWARNING, 0);
+ // DVS_WriteProfileInt2(IDS_R_GENERAL, IDS_RG_SEENDIVXWARNING, 0);
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
void CALLBACK DirectVobSub(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow)
{
- if (FAILED(::CoInitialize(0))) {
- return;
- }
+ if (FAILED(::CoInitialize(0))) {
+ return;
+ }
- CComPtr<IBaseFilter> pFilter;
- CComQIPtr<ISpecifyPropertyPages> pSpecify;
+ CComPtr<IBaseFilter> pFilter;
+ CComQIPtr<ISpecifyPropertyPages> pSpecify;
- if (SUCCEEDED(pFilter.CoCreateInstance(__uuidof(CDirectVobSubFilter))) && (pSpecify = pFilter)) {
- ShowPPage(pFilter, hwnd);
- }
+ if (SUCCEEDED(pFilter.CoCreateInstance(__uuidof(CDirectVobSubFilter))) && (pSpecify = pFilter)) {
+ ShowPPage(pFilter, hwnd);
+ }
- ::CoUninitialize();
+ ::CoUninitialize();
}
diff --git a/src/filters/transform/VSFilter/VSFilter.h b/src/filters/transform/VSFilter/VSFilter.h
index c4e71a50a..ec235390c 100644
--- a/src/filters/transform/VSFilter/VSFilter.h
+++ b/src/filters/transform/VSFilter/VSFilter.h
@@ -28,18 +28,18 @@
class CVSFilterApp : public CWinApp
{
public:
- CVSFilterApp();
+ CVSFilterApp();
- CString m_AppName;
+ CString m_AppName;
protected:
- HINSTANCE LoadAppLangResourceDLL();
+ HINSTANCE LoadAppLangResourceDLL();
public:
- BOOL InitInstance();
- BOOL ExitInstance();
+ BOOL InitInstance();
+ BOOL ExitInstance();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
};
extern CVSFilterApp theApp;
diff --git a/src/filters/transform/VSFilter/csri.h b/src/filters/transform/VSFilter/csri.h
index 7d67bae96..2ed9fc869 100644
--- a/src/filters/transform/VSFilter/csri.h
+++ b/src/filters/transform/VSFilter/csri.h
@@ -36,46 +36,46 @@
#define _CSRI_H 20070119
/** \endcond */
-#include <stddef.h> /* ptrdiff_t */
+#include <stddef.h> /* ptrdiff_t */
#ifdef __cplusplus
extern "C" {
#endif
#ifndef CSRIAPI
- /** CSRI API attributes.
- * defaults to \c extern.
- */
+ /** CSRI API attributes.
+ * defaults to \c extern.
+ */
#define CSRIAPI extern
#endif
- /** \defgroup base CSRI base API. */
- /*@{*/
+ /** \defgroup base CSRI base API. */
+ /*@{*/
- /** pixel format specification for frames */
- enum csri_pixfmt {
- CSRI_F_RGBA = 0,
- CSRI_F_ARGB,
- CSRI_F_BGRA,
- CSRI_F_ABGR,
+ /** pixel format specification for frames */
+ enum csri_pixfmt {
+ CSRI_F_RGBA = 0,
+ CSRI_F_ARGB,
+ CSRI_F_BGRA,
+ CSRI_F_ABGR,
- CSRI_F_RGB_ = 0x100,
- CSRI_F__RGB,
- CSRI_F_BGR_, /**< Windows "RGB32" */
- CSRI_F__BGR,
+ CSRI_F_RGB_ = 0x100,
+ CSRI_F__RGB,
+ CSRI_F_BGR_, /**< Windows "RGB32" */
+ CSRI_F__BGR,
- CSRI_F_RGB = 0x200,
- CSRI_F_BGR, /**< Windows "RGB24" */
+ CSRI_F_RGB = 0x200,
+ CSRI_F_BGR, /**< Windows "RGB24" */
- CSRI_F_AYUV = 0x1000,
- CSRI_F_YUVA,
- CSRI_F_YVUA,
+ CSRI_F_AYUV = 0x1000,
+ CSRI_F_YUVA,
+ CSRI_F_YVUA,
- CSRI_F_YUY2 = 0x1100,
+ CSRI_F_YUY2 = 0x1100,
- CSRI_F_YV12A = 0x2011, /**< planar YUV 2x2 + alpha plane */
- CSRI_F_YV12 = 0x2111 /**< planar YUV 2x2 */
- };
+ CSRI_F_YV12A = 0x2011, /**< planar YUV 2x2 + alpha plane */
+ CSRI_F_YV12 = 0x2111 /**< planar YUV 2x2 */
+ };
#define csri_is_rgb(x) ((x) < 0x1000)
#define csri_is_yuv(x) ((x) >= 0x1000)
@@ -85,261 +85,261 @@ extern "C" {
#define csri_is_yuv_packed(x) ((x) >= 0x1000 && (x) < 0x2000)
#define csri_has_alpha(x) (((x) & 0xfff) < 0x100)
- /** frame/image format specification pre-fed to the renderer */
- struct csri_fmt {
- /** format to be used */
- enum csri_pixfmt pixfmt;
- /** image width, full frame.
- *
- * This should specify the full size of the frame.
- * Specifying the video sub-size (in case of added black
- * borders) is left to an extension.
- */
- unsigned width;
- /** image height */
- unsigned height;
- };
-
- /** single frame to be fed to the renderer. */
- struct csri_frame {
- /** frame format.
- * It is an application bug if this differs from the one
- * passed in struct #csri_fmt to csri_query_fmt()
- */
- enum csri_pixfmt pixfmt;
- /** the frame's data.
- * Packed formats only use planes[0]; planar formats
- * have the data ordered as Y, U, V[, A].
- *
- * Also note that the topmost line always comes first.
- * The Windows biHeight strange-ity is \a NOT duplicated.
- */
- unsigned char *planes[4];
- /** strides for the individual planes.
- * Stride means full byte offset, i.e. do \a not add
- * frame width
- */
- ptrdiff_t strides[4];
- };
+ /** frame/image format specification pre-fed to the renderer */
+ struct csri_fmt {
+ /** format to be used */
+ enum csri_pixfmt pixfmt;
+ /** image width, full frame.
+ *
+ * This should specify the full size of the frame.
+ * Specifying the video sub-size (in case of added black
+ * borders) is left to an extension.
+ */
+ unsigned width;
+ /** image height */
+ unsigned height;
+ };
+
+ /** single frame to be fed to the renderer. */
+ struct csri_frame {
+ /** frame format.
+ * It is an application bug if this differs from the one
+ * passed in struct #csri_fmt to csri_query_fmt()
+ */
+ enum csri_pixfmt pixfmt;
+ /** the frame's data.
+ * Packed formats only use planes[0]; planar formats
+ * have the data ordered as Y, U, V[, A].
+ *
+ * Also note that the topmost line always comes first.
+ * The Windows biHeight strange-ity is \a NOT duplicated.
+ */
+ unsigned char* planes[4];
+ /** strides for the individual planes.
+ * Stride means full byte offset, i.e. do \a not add
+ * frame width
+ */
+ ptrdiff_t strides[4];
+ };
#ifndef CSRI_OWN_HANDLES
- /** opaque renderer data */
- typedef void csri_rend;
- /** opaque instance data */
- typedef void csri_inst;
+ /** opaque renderer data */
+ typedef void csri_rend;
+ /** opaque instance data */
+ typedef void csri_inst;
#endif
#ifdef DOXYGEN
- /** disable the emission of the csri_rend and csri_inst typedefs.
- * define this if you are in a renderer and are typedef'ing
- * csri_rend and csri_inst to your own structs.
- */
+ /** disable the emission of the csri_rend and csri_inst typedefs.
+ * define this if you are in a renderer and are typedef'ing
+ * csri_rend and csri_inst to your own structs.
+ */
#define CSRI_OWN_HANDLES
#endif
- /** renderer description.
- * \ingroup loader
- */
- struct csri_info {
- /** an identifier for the renderer.
- * - MUST match the regular expression
- * \code ^[a-zA-Z]([a-zA-Z0-9_]*[a-zA-Z0-9])? \endcode
- * i.e. consists only of letters, numbers and underscores;
- * must start with a letter and doesnt have an underscore
- * as the last character.
- */
- const char *name;
- /** an identifier to the exact version of the renderer.
- * most likely a version number or revision identifier.
- *
- * The helper library does a strcmp over this field in order
- * to order multiple instances of the same renderer. Use
- * higher-byte-value strings for newer renderers.
- */
- const char *specific;
-
- /** a nice name to be presented to the user */
- const char *longname;
- /** the renderer's author */
- const char *author;
- /** a copyright string. Copyright (c) 2042 by Mr. Nice Guy */
- const char *copyright;
- };
-
- /** data of extension-dependent type.
- * The field to be used MUST be specified in the extension where it is used.
- */
- union csri_vardata {
- long lval;
- double dval;
- const char *utf8val;
- void *otherval;
- };
-
- /** extension identifier.
- * This follows reverse DNS syntax, i.e.:
- * \code root.branch.leaf \endcode
- * you can either reverse a registered domain name, e.g.
- * \code com.microsoft.csri.usegdiplus \endcode
- * or ask the CSRI maintainers to assign a namespace to you.
- *
- * currently registered namespaces are:
- *
- * \code
- * csri.* - official extensions
- * asa.* - custom extensions of the asa renderer
- * \endcode
- */
- typedef const char *csri_ext_id;
-
- /** script loading parameters.
- * each flag MUST have an associated extension, which can be queried
- * with csri_query_ext(). If the open flag constitutes an extension on its
- * sole own, csri_query_ext() can return a meaningless non-NULL value for
- * it.
- *
- * The data field used must be specified.
- *
- * An extension can have multiple flags. In that case, the flags should have
- * the extension name as common prefix, separated with a dot.
- *
- * A renderer MUST ignore unknown open flags. It MUST NOT return an error
- * just because it does not support a particular flag.
- */
- struct csri_openflag {
- /** flag name */
- csri_ext_id name;
- /** flag data argument */
- union csri_vardata data;
- /** link to next flag */
- struct csri_openflag *next;
- };
-
- /** load a script from a file.
- * \param renderer the handle to the renderer
- * \param filename the path to the file to be loaded. \n
- * The filename should be encoded as UTF-8. Windows renderers are
- * expected to convert it to UTF-16 and use the Unicode Windows API
- * functions.
- * \param flags a linked list of open flags. \n
- * The caller manages memory allocation, i.e. static allocation is OK.
- * \return the renderer instance handle, or NULL on error.
- */
- CSRIAPI csri_inst *csri_open_file(csri_rend *renderer,
- const char *filename, struct csri_openflag *flags);
-
- /** load a script from memory.
- * \param renderer the handle to the renderer
- * \param data pointer to the first data byte. \n
- * The caller manages memory allocation and should free the data after
- * calling csri_open_mem(). If the renderer needs to keep the data, it
- * must copy it. \n
- * The renderer is not allowed to write to the data.
- * \param length length, in bytes, of the data
- * \param flags see csri_open_file()
- * \return the render instance handle, or NULL on error.
- */
-
- CSRIAPI csri_inst *csri_open_mem(csri_rend *renderer,
- const void *data, size_t length, struct csri_openflag *flags);
-
- /** close a renderer instance.
- * \param inst the instance handle.
- */
- CSRIAPI void csri_close(csri_inst *inst);
-
-
- /** query / set the image format and size.
- * \param inst the renderer instance handle
- * \param fmt the format and image size to be used
- * \return 0 if the format was successfully set,
- * any other value in case of error.
- */
- CSRIAPI int csri_request_fmt(csri_inst *inst, const struct csri_fmt *fmt);
-
- /** render a single frame
- * \param inst the renderer instance handle
- * \param frame frame data to render to
- * \param time associated timestamp of the frame
- */
- CSRIAPI void csri_render(csri_inst *inst, struct csri_frame *frame,
- double time);
-
-
- /** query for an extension.
- * \param rend the renderer handle
- * \param extname the extension's identifier
- * \return NULL if the extension is not supported,
- * a pointer to extension-specific data otherwise
- *
- * The data pointed to by the return value does not neccessarily need to
- * have any meaning; An extension that does not need to return data
- * can return a pointer to whatever it wants, as long as that pointer is
- * not NULL.
- *
- * In the usual case, the pointer is supposed to point to a struct with
- * function pointers and other information as needed.
- */
- CSRIAPI void *csri_query_ext(csri_rend *rend, csri_ext_id extname);
-
- /*@}*/
-
- /** \defgroup loader CSRI loader API.
- *
- * These functions locate renderers based on given parameters.
- *
- * <b>Renderers must implement these functions as well.</b>
- *
- * They are used by the library to grab renderer information
- * from a shared object; and also this way a single renderer
- * can be linked directly into an appliaction.
- */
- /*@{*/
-
- /** get renderer information
- * \param rend the renderer handle
- * \return information about the renderer, or NULL in case the renderer
- * encountered an internal error.
- */
- CSRIAPI struct csri_info *csri_renderer_info(csri_rend *rend);
-
- /** try to load a given renderer
- * \param name the name of the renderer, as in csri_info.name
- * \param specific the specific version of the renderer,
- * as in csri_info.specific;\n
- * alternatively NULL if any version of the renderer is ok.
- * \return a handle to the renderer if it was successfully loaded,
- * NULL otherwise.
- */
- CSRIAPI csri_rend *csri_renderer_byname(const char *name,
- const char *specific);
-
- /** try to find an implementation of the given extensions.
- * \param next number of extensions pointed to by ext
- * \param ext array of extensions to search for
- * \return a handle to a renderer supporting ALL of the
- * extensions, NULL if none was found.
- */
- CSRIAPI csri_rend *csri_renderer_byext(unsigned n_ext, csri_ext_id *ext);
-
- /** get the default (highest priority) renderer
- * \return a handle to the default renderer, or NULL if
- * no renderer is installed.
- *
- * Together with csri_renderer_next(), this can be used
- * to enumerate all installed renderers.
- */
- CSRIAPI csri_rend *csri_renderer_default();
-
- /** get the next lower priority renderer
- * \param prev the current renderer
- * \return the renderer with the next lower priority than
- * the one named in prev, or NULL if prev is the last
- * renderer installed.
- */
- CSRIAPI csri_rend *csri_renderer_next(csri_rend *prev);
-
- /*@}*/
+ /** renderer description.
+ * \ingroup loader
+ */
+ struct csri_info {
+ /** an identifier for the renderer.
+ * - MUST match the regular expression
+ * \code ^[a-zA-Z]([a-zA-Z0-9_]*[a-zA-Z0-9])? \endcode
+ * i.e. consists only of letters, numbers and underscores;
+ * must start with a letter and doesnt have an underscore
+ * as the last character.
+ */
+ const char* name;
+ /** an identifier to the exact version of the renderer.
+ * most likely a version number or revision identifier.
+ *
+ * The helper library does a strcmp over this field in order
+ * to order multiple instances of the same renderer. Use
+ * higher-byte-value strings for newer renderers.
+ */
+ const char* specific;
+
+ /** a nice name to be presented to the user */
+ const char* longname;
+ /** the renderer's author */
+ const char* author;
+ /** a copyright string. Copyright (c) 2042 by Mr. Nice Guy */
+ const char* copyright;
+ };
+
+ /** data of extension-dependent type.
+ * The field to be used MUST be specified in the extension where it is used.
+ */
+ union csri_vardata {
+ long lval;
+ double dval;
+ const char* utf8val;
+ void* otherval;
+ };
+
+ /** extension identifier.
+ * This follows reverse DNS syntax, i.e.:
+ * \code root.branch.leaf \endcode
+ * you can either reverse a registered domain name, e.g.
+ * \code com.microsoft.csri.usegdiplus \endcode
+ * or ask the CSRI maintainers to assign a namespace to you.
+ *
+ * currently registered namespaces are:
+ *
+ * \code
+ * csri.* - official extensions
+ * asa.* - custom extensions of the asa renderer
+ * \endcode
+ */
+ typedef const char* csri_ext_id;
+
+ /** script loading parameters.
+ * each flag MUST have an associated extension, which can be queried
+ * with csri_query_ext(). If the open flag constitutes an extension on its
+ * sole own, csri_query_ext() can return a meaningless non-NULL value for
+ * it.
+ *
+ * The data field used must be specified.
+ *
+ * An extension can have multiple flags. In that case, the flags should have
+ * the extension name as common prefix, separated with a dot.
+ *
+ * A renderer MUST ignore unknown open flags. It MUST NOT return an error
+ * just because it does not support a particular flag.
+ */
+ struct csri_openflag {
+ /** flag name */
+ csri_ext_id name;
+ /** flag data argument */
+ union csri_vardata data;
+ /** link to next flag */
+ struct csri_openflag* next;
+ };
+
+ /** load a script from a file.
+ * \param renderer the handle to the renderer
+ * \param filename the path to the file to be loaded. \n
+ * The filename should be encoded as UTF-8. Windows renderers are
+ * expected to convert it to UTF-16 and use the Unicode Windows API
+ * functions.
+ * \param flags a linked list of open flags. \n
+ * The caller manages memory allocation, i.e. static allocation is OK.
+ * \return the renderer instance handle, or NULL on error.
+ */
+ CSRIAPI csri_inst* csri_open_file(csri_rend* renderer,
+ const char* filename, struct csri_openflag* flags);
+
+ /** load a script from memory.
+ * \param renderer the handle to the renderer
+ * \param data pointer to the first data byte. \n
+ * The caller manages memory allocation and should free the data after
+ * calling csri_open_mem(). If the renderer needs to keep the data, it
+ * must copy it. \n
+ * The renderer is not allowed to write to the data.
+ * \param length length, in bytes, of the data
+ * \param flags see csri_open_file()
+ * \return the render instance handle, or NULL on error.
+ */
+
+ CSRIAPI csri_inst* csri_open_mem(csri_rend* renderer,
+ const void* data, size_t length, struct csri_openflag* flags);
+
+ /** close a renderer instance.
+ * \param inst the instance handle.
+ */
+ CSRIAPI void csri_close(csri_inst* inst);
+
+
+ /** query / set the image format and size.
+ * \param inst the renderer instance handle
+ * \param fmt the format and image size to be used
+ * \return 0 if the format was successfully set,
+ * any other value in case of error.
+ */
+ CSRIAPI int csri_request_fmt(csri_inst* inst, const struct csri_fmt* fmt);
+
+ /** render a single frame
+ * \param inst the renderer instance handle
+ * \param frame frame data to render to
+ * \param time associated timestamp of the frame
+ */
+ CSRIAPI void csri_render(csri_inst* inst, struct csri_frame* frame,
+ double time);
+
+
+ /** query for an extension.
+ * \param rend the renderer handle
+ * \param extname the extension's identifier
+ * \return NULL if the extension is not supported,
+ * a pointer to extension-specific data otherwise
+ *
+ * The data pointed to by the return value does not neccessarily need to
+ * have any meaning; An extension that does not need to return data
+ * can return a pointer to whatever it wants, as long as that pointer is
+ * not NULL.
+ *
+ * In the usual case, the pointer is supposed to point to a struct with
+ * function pointers and other information as needed.
+ */
+ CSRIAPI void* csri_query_ext(csri_rend* rend, csri_ext_id extname);
+
+ /*@}*/
+
+ /** \defgroup loader CSRI loader API.
+ *
+ * These functions locate renderers based on given parameters.
+ *
+ * <b>Renderers must implement these functions as well.</b>
+ *
+ * They are used by the library to grab renderer information
+ * from a shared object; and also this way a single renderer
+ * can be linked directly into an appliaction.
+ */
+ /*@{*/
+
+ /** get renderer information
+ * \param rend the renderer handle
+ * \return information about the renderer, or NULL in case the renderer
+ * encountered an internal error.
+ */
+ CSRIAPI struct csri_info* csri_renderer_info(csri_rend* rend);
+
+ /** try to load a given renderer
+ * \param name the name of the renderer, as in csri_info.name
+ * \param specific the specific version of the renderer,
+ * as in csri_info.specific;\n
+ * alternatively NULL if any version of the renderer is ok.
+ * \return a handle to the renderer if it was successfully loaded,
+ * NULL otherwise.
+ */
+ CSRIAPI csri_rend* csri_renderer_byname(const char* name,
+ const char* specific);
+
+ /** try to find an implementation of the given extensions.
+ * \param next number of extensions pointed to by ext
+ * \param ext array of extensions to search for
+ * \return a handle to a renderer supporting ALL of the
+ * extensions, NULL if none was found.
+ */
+ CSRIAPI csri_rend* csri_renderer_byext(unsigned n_ext, csri_ext_id* ext);
+
+ /** get the default (highest priority) renderer
+ * \return a handle to the default renderer, or NULL if
+ * no renderer is installed.
+ *
+ * Together with csri_renderer_next(), this can be used
+ * to enumerate all installed renderers.
+ */
+ CSRIAPI csri_rend* csri_renderer_default();
+
+ /** get the next lower priority renderer
+ * \param prev the current renderer
+ * \return the renderer with the next lower priority than
+ * the one named in prev, or NULL if prev is the last
+ * renderer installed.
+ */
+ CSRIAPI csri_rend* csri_renderer_next(csri_rend* prev);
+
+ /*@}*/
#ifdef __cplusplus
}
diff --git a/src/filters/transform/VSFilter/csriapi.cpp b/src/filters/transform/VSFilter/csriapi.cpp
index 42865c1d1..9b710813e 100644
--- a/src/filters/transform/VSFilter/csriapi.cpp
+++ b/src/filters/transform/VSFilter/csriapi.cpp
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2007 Niels Martin Hansen
- * http://aegisub.net/
+ * Copyright (C) 2007 Niels Martin Hansen
+ * http://aegisub.net/
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,15 +29,15 @@
#define CSRIAPI extern "C" __declspec(dllexport)
#define CSRI_OWN_HANDLES
-typedef const char *csri_rend;
+typedef const char* csri_rend;
extern "C" struct csri_vsfilter_inst {
- CRenderedTextSubtitle *rts;
- CCritSec *cs;
- CSize script_res;
- CSize screen_res;
- CRect video_rect;
- enum csri_pixfmt pixfmt;
- size_t readorder;
+ CRenderedTextSubtitle* rts;
+ CCritSec* cs;
+ CSize script_res;
+ CSize screen_res;
+ CRect video_rect;
+ enum csri_pixfmt pixfmt;
+ size_t readorder;
};
typedef struct csri_vsfilter_inst csri_inst;
@@ -45,189 +45,189 @@ typedef struct csri_vsfilter_inst csri_inst;
static csri_rend csri_vsfilter = "vsfilter";
-CSRIAPI csri_inst *csri_open_file(csri_rend *renderer, const char *filename, struct csri_openflag *flags)
+CSRIAPI csri_inst* csri_open_file(csri_rend* renderer, const char* filename, struct csri_openflag* flags)
{
- int namesize;
- wchar_t *namebuf;
-
- namesize = MultiByteToWideChar(CP_UTF8, 0, filename, -1, NULL, 0);
- if (!namesize) {
- return 0;
- }
- namesize++;
- namebuf = new wchar_t[namesize];
- MultiByteToWideChar(CP_UTF8, 0, filename, -1, namebuf, namesize);
-
- csri_inst *inst = new csri_inst();
- inst->cs = new CCritSec();
- inst->rts = new CRenderedTextSubtitle(inst->cs);
- if (inst->rts->Open(CString(namebuf), DEFAULT_CHARSET)) {
- delete[] namebuf;
- inst->readorder = 0;
- return inst;
- } else {
- delete[] namebuf;
- delete inst->rts;
- delete inst->cs;
- delete inst;
- return 0;
- }
+ int namesize;
+ wchar_t* namebuf;
+
+ namesize = MultiByteToWideChar(CP_UTF8, 0, filename, -1, NULL, 0);
+ if (!namesize) {
+ return 0;
+ }
+ namesize++;
+ namebuf = new wchar_t[namesize];
+ MultiByteToWideChar(CP_UTF8, 0, filename, -1, namebuf, namesize);
+
+ csri_inst* inst = new csri_inst();
+ inst->cs = new CCritSec();
+ inst->rts = new CRenderedTextSubtitle(inst->cs);
+ if (inst->rts->Open(CString(namebuf), DEFAULT_CHARSET)) {
+ delete[] namebuf;
+ inst->readorder = 0;
+ return inst;
+ } else {
+ delete[] namebuf;
+ delete inst->rts;
+ delete inst->cs;
+ delete inst;
+ return 0;
+ }
}
-CSRIAPI csri_inst *csri_open_mem(csri_rend *renderer, const void *data, size_t length, struct csri_openflag *flags)
+CSRIAPI csri_inst* csri_open_mem(csri_rend* renderer, const void* data, size_t length, struct csri_openflag* flags)
{
- // This is actually less effecient than opening a file, since this first writes the memory data to a temp file,
- // then opens that file and parses from that.
- csri_inst *inst = new csri_inst();
- inst->cs = new CCritSec();
- inst->rts = new CRenderedTextSubtitle(inst->cs);
- if (inst->rts->Open((BYTE*)data, (int)length, DEFAULT_CHARSET, _T("CSRI memory subtitles"))) {
- inst->readorder = 0;
- return inst;
- } else {
- delete inst->rts;
- delete inst->cs;
- delete inst;
- return 0;
- }
+ // This is actually less effecient than opening a file, since this first writes the memory data to a temp file,
+ // then opens that file and parses from that.
+ csri_inst* inst = new csri_inst();
+ inst->cs = new CCritSec();
+ inst->rts = new CRenderedTextSubtitle(inst->cs);
+ if (inst->rts->Open((BYTE*)data, (int)length, DEFAULT_CHARSET, _T("CSRI memory subtitles"))) {
+ inst->readorder = 0;
+ return inst;
+ } else {
+ delete inst->rts;
+ delete inst->cs;
+ delete inst;
+ return 0;
+ }
}
-CSRIAPI void csri_close(csri_inst *inst)
+CSRIAPI void csri_close(csri_inst* inst)
{
- if (!inst) {
- return;
- }
+ if (!inst) {
+ return;
+ }
- delete inst->rts;
- delete inst->cs;
- delete inst;
+ delete inst->rts;
+ delete inst->cs;
+ delete inst;
}
-CSRIAPI int csri_request_fmt(csri_inst *inst, const struct csri_fmt *fmt)
+CSRIAPI int csri_request_fmt(csri_inst* inst, const struct csri_fmt* fmt)
{
- if (!inst) {
- return -1;
- }
-
- if (!fmt->width || !fmt->height) {
- return -1;
- }
-
- // Check if pixel format is supported
- switch (fmt->pixfmt) {
- case CSRI_F_BGR_:
- case CSRI_F_BGR:
- case CSRI_F_YUY2:
- case CSRI_F_YV12:
- inst->pixfmt = fmt->pixfmt;
- break;
-
- default:
- return -1;
- }
- inst->screen_res = CSize(fmt->width, fmt->height);
- inst->video_rect = CRect(0, 0, fmt->width, fmt->height);
- return 0;
+ if (!inst) {
+ return -1;
+ }
+
+ if (!fmt->width || !fmt->height) {
+ return -1;
+ }
+
+ // Check if pixel format is supported
+ switch (fmt->pixfmt) {
+ case CSRI_F_BGR_:
+ case CSRI_F_BGR:
+ case CSRI_F_YUY2:
+ case CSRI_F_YV12:
+ inst->pixfmt = fmt->pixfmt;
+ break;
+
+ default:
+ return -1;
+ }
+ inst->screen_res = CSize(fmt->width, fmt->height);
+ inst->video_rect = CRect(0, 0, fmt->width, fmt->height);
+ return 0;
}
-CSRIAPI void csri_render(csri_inst *inst, struct csri_frame *frame, double time)
+CSRIAPI void csri_render(csri_inst* inst, struct csri_frame* frame, double time)
{
- const double arbitrary_framerate = 25.0;
- SubPicDesc spd;
- spd.w = inst->screen_res.cx;
- spd.h = inst->screen_res.cy;
- switch (inst->pixfmt) {
- case CSRI_F_BGR_:
- spd.type = MSP_RGB32;
- spd.bpp = 32;
- spd.bits = frame->planes[0];
- spd.pitch = frame->strides[0];
- break;
-
- case CSRI_F_BGR:
- spd.type = MSP_RGB24;
- spd.bpp = 24;
- spd.bits = frame->planes[0];
- spd.pitch = frame->strides[0];
- break;
-
- case CSRI_F_YUY2:
- spd.type = MSP_YUY2;
- spd.bpp = 16;
- spd.bits = frame->planes[0];
- spd.pitch = frame->strides[0];
- break;
-
- case CSRI_F_YV12:
- spd.type = MSP_YV12;
- spd.bpp = 12;
- spd.bits = frame->planes[0];
- spd.bitsU = frame->planes[1];
- spd.bitsV = frame->planes[2];
- spd.pitch = frame->strides[0];
- spd.pitchUV = frame->strides[1];
- break;
-
- default:
- // eh?
- return;
- }
- spd.vidrect = inst->video_rect;
-
- inst->rts->Render(spd, (REFERENCE_TIME)(time*10000000), arbitrary_framerate, inst->video_rect);
+ const double arbitrary_framerate = 25.0;
+ SubPicDesc spd;
+ spd.w = inst->screen_res.cx;
+ spd.h = inst->screen_res.cy;
+ switch (inst->pixfmt) {
+ case CSRI_F_BGR_:
+ spd.type = MSP_RGB32;
+ spd.bpp = 32;
+ spd.bits = frame->planes[0];
+ spd.pitch = frame->strides[0];
+ break;
+
+ case CSRI_F_BGR:
+ spd.type = MSP_RGB24;
+ spd.bpp = 24;
+ spd.bits = frame->planes[0];
+ spd.pitch = frame->strides[0];
+ break;
+
+ case CSRI_F_YUY2:
+ spd.type = MSP_YUY2;
+ spd.bpp = 16;
+ spd.bits = frame->planes[0];
+ spd.pitch = frame->strides[0];
+ break;
+
+ case CSRI_F_YV12:
+ spd.type = MSP_YV12;
+ spd.bpp = 12;
+ spd.bits = frame->planes[0];
+ spd.bitsU = frame->planes[1];
+ spd.bitsV = frame->planes[2];
+ spd.pitch = frame->strides[0];
+ spd.pitchUV = frame->strides[1];
+ break;
+
+ default:
+ // eh?
+ return;
+ }
+ spd.vidrect = inst->video_rect;
+
+ inst->rts->Render(spd, (REFERENCE_TIME)(time * 10000000), arbitrary_framerate, inst->video_rect);
}
// No extensions supported
-CSRIAPI void *csri_query_ext(csri_rend *rend, csri_ext_id extname)
+CSRIAPI void* csri_query_ext(csri_rend* rend, csri_ext_id extname)
{
- return 0;
+ return 0;
}
// Get info for renderer
static struct csri_info csri_vsfilter_info = {
#ifdef _DEBUG
- "vsfilter_textsub_debug", // name
- "2.41", // version (assumed version number, svn revision, patchlevel)
+ "vsfilter_textsub_debug", // name
+ "2.41", // version (assumed version number, svn revision, patchlevel)
#else
- "vsfilter_textsub", // name
- "2.41", // version (assumed version number, svn revision, patchlevel)
+ "vsfilter_textsub", // name
+ "2.41", // version (assumed version number, svn revision, patchlevel)
#endif
- // 2.38-0611 is base svn 611
- // 2.38-0611-1 is with clipfix and fax/fay patch
- // 2.38-0611-2 adds CSRI
- // 2.38-0611-3 fixes a bug in CSRI and adds fontcrash-fix and float-pos
- // 2.38-0611-4 fixes be1-dots and ugly-fade bugs and adds xbord/ybord/xshad/yshad/blur tags and extends be
- // 2.39 merges with guliverkli2 fork
- // 2.41 removes SSF support
- "VSFilter/TextSub (MPC-HC)", // longname
- "Gabest", // author
- "Copyright (c) 2003-2012 by Gabest et al." // copyright
+ // 2.38-0611 is base svn 611
+ // 2.38-0611-1 is with clipfix and fax/fay patch
+ // 2.38-0611-2 adds CSRI
+ // 2.38-0611-3 fixes a bug in CSRI and adds fontcrash-fix and float-pos
+ // 2.38-0611-4 fixes be1-dots and ugly-fade bugs and adds xbord/ybord/xshad/yshad/blur tags and extends be
+ // 2.39 merges with guliverkli2 fork
+ // 2.41 removes SSF support
+ "VSFilter/TextSub (MPC-HC)", // longname
+ "Gabest", // author
+ "Copyright (c) 2003-2012 by Gabest et al." // copyright
};
-CSRIAPI struct csri_info *csri_renderer_info(csri_rend *rend) {
- return &csri_vsfilter_info;
+CSRIAPI struct csri_info* csri_renderer_info(csri_rend* rend) {
+ return &csri_vsfilter_info;
}
// Only one supported, obviously
-CSRIAPI csri_rend *csri_renderer_byname(const char *name, const char *specific)
+CSRIAPI csri_rend* csri_renderer_byname(const char* name, const char* specific)
{
- if (strcmp(name, csri_vsfilter_info.name)) {
- return 0;
- }
- if (specific && strcmp(specific, csri_vsfilter_info.specific)) {
- return 0;
- }
- return &csri_vsfilter;
+ if (strcmp(name, csri_vsfilter_info.name)) {
+ return 0;
+ }
+ if (specific && strcmp(specific, csri_vsfilter_info.specific)) {
+ return 0;
+ }
+ return &csri_vsfilter;
}
// Still just one
-CSRIAPI csri_rend *csri_renderer_default()
+CSRIAPI csri_rend* csri_renderer_default()
{
- return &csri_vsfilter;
+ return &csri_vsfilter;
}
// And no further
-CSRIAPI csri_rend *csri_renderer_next(csri_rend *prev)
+CSRIAPI csri_rend* csri_renderer_next(csri_rend* prev)
{
- return 0;
+ return 0;
}
diff --git a/src/filters/transform/VSFilter/plugins.cpp b/src/filters/transform/VSFilter/plugins.cpp
index 926dad714..fc80c0074 100644
--- a/src/filters/transform/VSFilter/plugins.cpp
+++ b/src/filters/transform/VSFilter/plugins.cpp
@@ -38,1043 +38,1048 @@
namespace Plugin
{
- class CFilter : public CAMThread, public CCritSec
- {
- private:
- CString m_fn;
-
- protected:
- float m_fps;
- CCritSec m_csSubLock;
- CComPtr<ISubPicQueue> m_pSubPicQueue;
- CComPtr<ISubPicProvider> m_pSubPicProvider;
- DWORD_PTR m_SubPicProviderId;
-
- public:
- CFilter() : m_fps(-1), m_SubPicProviderId(0) {
- CAMThread::Create();
- }
- virtual ~CFilter() {
- CAMThread::CallWorker(0);
- }
-
- CString GetFileName() {
- CAutoLock cAutoLock(this);
- return m_fn;
- }
- void SetFileName(CString fn) {
- CAutoLock cAutoLock(this);
- m_fn = fn;
- }
-
- bool Render(SubPicDesc& dst, REFERENCE_TIME rt, float fps) {
- if (!m_pSubPicProvider) {
- return false;
- }
-
- CSize size(dst.w, dst.h);
-
- if (!m_pSubPicQueue) {
- CComPtr<ISubPicAllocator> pAllocator = DNew CMemSubPicAllocator(dst.type, size);
-
- HRESULT hr;
- if (!(m_pSubPicQueue = DNew CSubPicQueueNoThread(pAllocator, &hr)) || FAILED(hr)) {
- m_pSubPicQueue = NULL;
- return false;
- }
- }
-
- if (m_SubPicProviderId != (DWORD_PTR)(ISubPicProvider*)m_pSubPicProvider) {
- m_pSubPicQueue->SetSubPicProvider(m_pSubPicProvider);
- m_SubPicProviderId = (DWORD_PTR)(ISubPicProvider*)m_pSubPicProvider;
- }
-
- CComPtr<ISubPic> pSubPic;
- if (!m_pSubPicQueue->LookupSubPic(rt, pSubPic)) {
- return false;
- }
-
- CRect r;
- pSubPic->GetDirtyRect(r);
-
- if (dst.type == MSP_RGB32 || dst.type == MSP_RGB24 || dst.type == MSP_RGB16 || dst.type == MSP_RGB15) {
- dst.h = -dst.h;
- }
-
- pSubPic->AlphaBlt(r, r, &dst);
-
- return true;
- }
-
- DWORD ThreadProc() {
- SetThreadPriority(m_hThread, THREAD_PRIORITY_LOWEST);
-
- CAtlArray<HANDLE> handles;
- handles.Add(GetRequestHandle());
-
- CString fn = GetFileName();
- CFileStatus fs;
- fs.m_mtime = 0;
- CFileGetStatus(fn, fs);
-
- for (;;) {
- DWORD i = WaitForMultipleObjects(handles.GetCount(), handles.GetData(), FALSE, 1000);
-
- if (WAIT_OBJECT_0 == i) {
- Reply(S_OK);
- break;
- } else if (WAIT_OBJECT_0 + 1 >= i && i <= WAIT_OBJECT_0 + handles.GetCount()) {
- if (FindNextChangeNotification(handles[i - WAIT_OBJECT_0])) {
- CFileStatus fs2;
- fs2.m_mtime = 0;
- CFileGetStatus(fn, fs2);
-
- if (fs.m_mtime < fs2.m_mtime) {
- fs.m_mtime = fs2.m_mtime;
-
- if (CComQIPtr<ISubStream> pSubStream = m_pSubPicProvider) {
- CAutoLock cAutoLock(&m_csSubLock);
- pSubStream->Reload();
- }
- }
- }
- } else if (WAIT_TIMEOUT == i) {
- CString fn2 = GetFileName();
-
- if (fn != fn2) {
- CPath p(fn2);
- p.RemoveFileSpec();
- HANDLE h = FindFirstChangeNotification(p, FALSE, FILE_NOTIFY_CHANGE_LAST_WRITE);
- if (h != INVALID_HANDLE_VALUE) {
- fn = fn2;
- handles.SetCount(1);
- handles.Add(h);
- }
- }
- } else { // if (WAIT_ABANDONED_0 == i || WAIT_FAILED == i)
- break;
- }
- }
-
- m_hThread = 0;
-
- for (size_t i = 1; i < handles.GetCount(); i++) {
- FindCloseChangeNotification(handles[i]);
- }
-
- return 0;
- }
- };
-
- class CVobSubFilter : virtual public CFilter
- {
- public:
- CVobSubFilter(CString fn = _T("")) {
- if (!fn.IsEmpty()) {
- Open(fn);
- }
- }
-
- bool Open(CString fn) {
- SetFileName(_T(""));
- m_pSubPicProvider = NULL;
-
- if (CVobSubFile* vsf = DNew CVobSubFile(&m_csSubLock)) {
- m_pSubPicProvider = (ISubPicProvider*)vsf;
- if (vsf->Open(CString(fn))) {
- SetFileName(fn);
- } else {
- m_pSubPicProvider = NULL;
- }
- }
-
- return !!m_pSubPicProvider;
- }
- };
-
- class CTextSubFilter : virtual public CFilter
- {
- int m_CharSet;
-
- public:
- CTextSubFilter(CString fn = _T(""), int CharSet = DEFAULT_CHARSET, float fps = -1)
- : m_CharSet(CharSet) {
- m_fps = fps;
- if (!fn.IsEmpty()) {
- Open(fn, CharSet);
- }
- }
-
- int GetCharSet() {
- return m_CharSet;
- }
-
- bool Open(CString fn, int CharSet = DEFAULT_CHARSET) {
- SetFileName(_T(""));
- m_pSubPicProvider = NULL;
-
- if (!m_pSubPicProvider) {
- if (CRenderedTextSubtitle* rts = DNew CRenderedTextSubtitle(&m_csSubLock)) {
- m_pSubPicProvider = (ISubPicProvider*)rts;
- if (rts->Open(CString(fn), CharSet)) {
- SetFileName(fn);
- } else {
- m_pSubPicProvider = NULL;
- }
- }
- }
-
- return !!m_pSubPicProvider;
- }
- };
+ class CFilter : public CAMThread, public CCritSec
+ {
+ private:
+ CString m_fn;
+
+ protected:
+ float m_fps;
+ CCritSec m_csSubLock;
+ CComPtr<ISubPicQueue> m_pSubPicQueue;
+ CComPtr<ISubPicProvider> m_pSubPicProvider;
+ DWORD_PTR m_SubPicProviderId;
+
+ public:
+ CFilter() : m_fps(-1), m_SubPicProviderId(0) {
+ CAMThread::Create();
+ }
+ virtual ~CFilter() {
+ CAMThread::CallWorker(0);
+ }
+
+ CString GetFileName() {
+ CAutoLock cAutoLock(this);
+ return m_fn;
+ }
+ void SetFileName(CString fn) {
+ CAutoLock cAutoLock(this);
+ m_fn = fn;
+ }
+
+ bool Render(SubPicDesc& dst, REFERENCE_TIME rt, float fps) {
+ if (!m_pSubPicProvider) {
+ return false;
+ }
+
+ CSize size(dst.w, dst.h);
+
+ if (!m_pSubPicQueue) {
+ CComPtr<ISubPicAllocator> pAllocator = DNew CMemSubPicAllocator(dst.type, size);
+
+ HRESULT hr;
+ if (!(m_pSubPicQueue = DNew CSubPicQueueNoThread(pAllocator, &hr)) || FAILED(hr)) {
+ m_pSubPicQueue = NULL;
+ return false;
+ }
+ }
+
+ if (m_SubPicProviderId != (DWORD_PTR)(ISubPicProvider*)m_pSubPicProvider) {
+ m_pSubPicQueue->SetSubPicProvider(m_pSubPicProvider);
+ m_SubPicProviderId = (DWORD_PTR)(ISubPicProvider*)m_pSubPicProvider;
+ }
+
+ CComPtr<ISubPic> pSubPic;
+ if (!m_pSubPicQueue->LookupSubPic(rt, pSubPic)) {
+ return false;
+ }
+
+ CRect r;
+ pSubPic->GetDirtyRect(r);
+
+ if (dst.type == MSP_RGB32 || dst.type == MSP_RGB24 || dst.type == MSP_RGB16 || dst.type == MSP_RGB15) {
+ dst.h = -dst.h;
+ }
+
+ pSubPic->AlphaBlt(r, r, &dst);
+
+ return true;
+ }
+
+ DWORD ThreadProc() {
+ SetThreadPriority(m_hThread, THREAD_PRIORITY_LOWEST);
+
+ CAtlArray<HANDLE> handles;
+ handles.Add(GetRequestHandle());
+
+ CString fn = GetFileName();
+ CFileStatus fs;
+ fs.m_mtime = 0;
+ CFileGetStatus(fn, fs);
+
+ for (;;) {
+ DWORD i = WaitForMultipleObjects(handles.GetCount(), handles.GetData(), FALSE, 1000);
+
+ if (WAIT_OBJECT_0 == i) {
+ Reply(S_OK);
+ break;
+ } else if (WAIT_OBJECT_0 + 1 >= i && i <= WAIT_OBJECT_0 + handles.GetCount()) {
+ if (FindNextChangeNotification(handles[i - WAIT_OBJECT_0])) {
+ CFileStatus fs2;
+ fs2.m_mtime = 0;
+ CFileGetStatus(fn, fs2);
+
+ if (fs.m_mtime < fs2.m_mtime) {
+ fs.m_mtime = fs2.m_mtime;
+
+ if (CComQIPtr<ISubStream> pSubStream = m_pSubPicProvider) {
+ CAutoLock cAutoLock(&m_csSubLock);
+ pSubStream->Reload();
+ }
+ }
+ }
+ } else if (WAIT_TIMEOUT == i) {
+ CString fn2 = GetFileName();
+
+ if (fn != fn2) {
+ CPath p(fn2);
+ p.RemoveFileSpec();
+ HANDLE h = FindFirstChangeNotification(p, FALSE, FILE_NOTIFY_CHANGE_LAST_WRITE);
+ if (h != INVALID_HANDLE_VALUE) {
+ fn = fn2;
+ handles.SetCount(1);
+ handles.Add(h);
+ }
+ }
+ } else { // if (WAIT_ABANDONED_0 == i || WAIT_FAILED == i)
+ break;
+ }
+ }
+
+ m_hThread = 0;
+
+ for (size_t i = 1; i < handles.GetCount(); i++) {
+ FindCloseChangeNotification(handles[i]);
+ }
+
+ return 0;
+ }
+ };
+
+ class CVobSubFilter : virtual public CFilter
+ {
+ public:
+ CVobSubFilter(CString fn = _T("")) {
+ if (!fn.IsEmpty()) {
+ Open(fn);
+ }
+ }
+
+ bool Open(CString fn) {
+ SetFileName(_T(""));
+ m_pSubPicProvider = NULL;
+
+ if (CVobSubFile* vsf = DNew CVobSubFile(&m_csSubLock)) {
+ m_pSubPicProvider = (ISubPicProvider*)vsf;
+ if (vsf->Open(CString(fn))) {
+ SetFileName(fn);
+ } else {
+ m_pSubPicProvider = NULL;
+ }
+ }
+
+ return !!m_pSubPicProvider;
+ }
+ };
+
+ class CTextSubFilter : virtual public CFilter
+ {
+ int m_CharSet;
+
+ public:
+ CTextSubFilter(CString fn = _T(""), int CharSet = DEFAULT_CHARSET, float fps = -1)
+ : m_CharSet(CharSet) {
+ m_fps = fps;
+ if (!fn.IsEmpty()) {
+ Open(fn, CharSet);
+ }
+ }
+
+ int GetCharSet() {
+ return m_CharSet;
+ }
+
+ bool Open(CString fn, int CharSet = DEFAULT_CHARSET) {
+ SetFileName(_T(""));
+ m_pSubPicProvider = NULL;
+
+ if (!m_pSubPicProvider) {
+ if (CRenderedTextSubtitle* rts = DNew CRenderedTextSubtitle(&m_csSubLock)) {
+ m_pSubPicProvider = (ISubPicProvider*)rts;
+ if (rts->Open(CString(fn), CharSet)) {
+ SetFileName(fn);
+ } else {
+ m_pSubPicProvider = NULL;
+ }
+ }
+ }
+
+ return !!m_pSubPicProvider;
+ }
+ };
#ifndef _WIN64
- //
- // old VirtualDub interface
- //
+ //
+ // old VirtualDub interface
+ //
- namespace VirtualDub
- {
+ namespace VirtualDub
+ {
#include <vd2/extras/FilterSDK/VirtualDub.h>
- class CVirtualDubFilter : virtual public CFilter
- {
- public:
- CVirtualDubFilter() {}
- virtual ~CVirtualDubFilter() {}
-
- virtual int RunProc(const FilterActivation* fa, const FilterFunctions* ff) {
- SubPicDesc dst;
- dst.type = MSP_RGB32;
- dst.w = fa->src.w;
- dst.h = fa->src.h;
- dst.bpp = 32;
- dst.pitch = fa->src.pitch;
- dst.bits = (LPVOID)fa->src.data;
-
- Render(dst, 10000i64*fa->pfsi->lSourceFrameMS, (float)1000 / fa->pfsi->lMicrosecsPerFrame);
-
- return 0;
- }
-
- virtual long ParamProc(FilterActivation* fa, const FilterFunctions* ff) {
- fa->dst.offset = fa->src.offset;
- fa->dst.modulo = fa->src.modulo;
- fa->dst.pitch = fa->src.pitch;
-
- return 0;
- }
-
- virtual int ConfigProc(FilterActivation* fa, const FilterFunctions* ff, HWND hwnd) = 0;
- virtual void StringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str) = 0;
- virtual bool FssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen) = 0;
- };
-
- class CVobSubVirtualDubFilter : public CVobSubFilter, public CVirtualDubFilter
- {
- public:
- CVobSubVirtualDubFilter(CString fn = _T(""))
- : CVobSubFilter(fn) {}
-
- int ConfigProc(FilterActivation* fa, const FilterFunctions* ff, HWND hwnd) {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY,
- _T("VobSub files (*.idx;*.sub)|*.idx;*.sub||"), CWnd::FromHandle(hwnd), 0);
-
- if (fd.DoModal() != IDOK) {
- return 1;
- }
-
- return Open(fd.GetPathName()) ? 0 : 1;
- }
-
- void StringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str) {
- sprintf(str, " (%s)", !GetFileName().IsEmpty() ? CStringA(GetFileName()) : " (empty)");
- }
-
- bool FssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen) {
- CStringA fn(GetFileName());
- fn.Replace("\\", "\\\\");
- _snprintf_s(buf, buflen, buflen, "Config(\"%s\")", fn);
- return true;
- }
- };
-
- class CTextSubVirtualDubFilter : public CTextSubFilter, public CVirtualDubFilter
- {
- public:
- CTextSubVirtualDubFilter(CString fn = _T(""), int CharSet = DEFAULT_CHARSET)
- : CTextSubFilter(fn, CharSet) {}
-
- int ConfigProc(FilterActivation* fa, const FilterFunctions* ff, HWND hwnd) {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- const TCHAR formats[] = _T("TextSub files (*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt)|*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt||");
- CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_ENABLETEMPLATE|OFN_ENABLEHOOK,
- formats, CWnd::FromHandle(hwnd), sizeof(OPENFILENAME));
- UINT_PTR CALLBACK OpenHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
-
- fd.m_pOFN->hInstance = AfxGetResourceHandle();
- fd.m_pOFN->lpTemplateName = MAKEINTRESOURCE(IDD_TEXTSUBOPENTEMPLATE);
- fd.m_pOFN->lpfnHook = (LPOFNHOOKPROC)OpenHookProc;
- fd.m_pOFN->lCustData = (LPARAM)DEFAULT_CHARSET;
-
- if (fd.DoModal() != IDOK) {
- return 1;
- }
-
- return Open(fd.GetPathName(), fd.m_pOFN->lCustData) ? 0 : 1;
- }
-
- void StringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str) {
- if (!GetFileName().IsEmpty()) {
- sprintf(str, " (%s, %d)", CStringA(GetFileName()), GetCharSet());
- } else {
- sprintf(str, " (empty)");
- }
- }
-
- bool FssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen) {
- CStringA fn(GetFileName());
- fn.Replace("\\", "\\\\");
- _snprintf_s(buf, buflen, buflen, "Config(\"%s\", %d)", fn, GetCharSet());
- return true;
- }
- };
-
- int vobsubInitProc(FilterActivation* fa, const FilterFunctions* ff)
- {
- *(CVirtualDubFilter**)fa->filter_data = DNew CVobSubVirtualDubFilter();
- return !(*(CVirtualDubFilter**)fa->filter_data);
- }
-
- int textsubInitProc(FilterActivation* fa, const FilterFunctions* ff)
- {
- *(CVirtualDubFilter**)fa->filter_data = DNew CTextSubVirtualDubFilter();
- return !(*(CVirtualDubFilter**)fa->filter_data);
- }
-
- void baseDeinitProc(FilterActivation* fa, const FilterFunctions* ff)
- {
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if (f) {
- delete f, f = NULL;
- }
- }
-
- int baseRunProc(const FilterActivation* fa, const FilterFunctions* ff)
- {
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->RunProc(fa, ff) : 1;
- }
-
- long baseParamProc(FilterActivation* fa, const FilterFunctions* ff)
- {
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->ParamProc(fa, ff) : 1;
- }
-
- int baseConfigProc(FilterActivation* fa, const FilterFunctions* ff, HWND hwnd)
- {
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->ConfigProc(fa, ff, hwnd) : 1;
- }
-
- void baseStringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str)
- {
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if (f) {
- f->StringProc(fa, ff, str);
- }
- }
-
- bool baseFssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen)
- {
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->FssProc(fa, ff, buf, buflen) : false;
- }
-
- void vobsubScriptConfig(IScriptInterpreter* isi, void* lpVoid, CScriptValue* argv, int argc)
- {
- FilterActivation* fa = (FilterActivation*)lpVoid;
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if (f) {
- delete f;
- }
- f = DNew CVobSubVirtualDubFilter(CString(*argv[0].asString()));
- *(CVirtualDubFilter**)fa->filter_data = f;
- }
-
- void textsubScriptConfig(IScriptInterpreter* isi, void* lpVoid, CScriptValue* argv, int argc)
- {
- FilterActivation* fa = (FilterActivation*)lpVoid;
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if (f) {
- delete f;
- }
- f = DNew CTextSubVirtualDubFilter(CString(*argv[0].asString()), argv[1].asInt());
- *(CVirtualDubFilter**)fa->filter_data = f;
- }
-
- ScriptFunctionDef vobsub_func_defs[]= {
- { (ScriptFunctionPtr)vobsubScriptConfig, "Config", "0s" },
- { NULL },
- };
-
- CScriptObject vobsub_obj= {
- NULL, vobsub_func_defs
- };
-
- struct FilterDefinition filterDef_vobsub = {
- NULL, NULL, NULL, // next, prev, module
- "VobSub", // name
- "Adds subtitles from a vob sequence.", // desc
- "Gabest", // maker
- NULL, // private_data
- sizeof(CVirtualDubFilter**), // inst_data_size
- vobsubInitProc, // initProc
- baseDeinitProc, // deinitProc
- baseRunProc, // runProc
- baseParamProc, // paramProc
- baseConfigProc, // configProc
- baseStringProc, // stringProc
- NULL, // startProc
- NULL, // endProc
- &vobsub_obj, // script_obj
- baseFssProc, // fssProc
- };
-
- ScriptFunctionDef textsub_func_defs[]= {
- { (ScriptFunctionPtr)textsubScriptConfig, "Config", "0si" },
- { NULL },
- };
-
- CScriptObject textsub_obj= {
- NULL, textsub_func_defs
- };
-
- struct FilterDefinition filterDef_textsub = {
- NULL, NULL, NULL, // next, prev, module
- "TextSub", // name
- "Adds subtitles from srt, sub, psb, smi, ssa, ass file formats.", // desc
- "Gabest", // maker
- NULL, // private_data
- sizeof(CVirtualDubFilter**), // inst_data_size
- textsubInitProc, // initProc
- baseDeinitProc, // deinitProc
- baseRunProc, // runProc
- baseParamProc, // paramProc
- baseConfigProc, // configProc
- baseStringProc, // stringProc
- NULL, // startProc
- NULL, // endProc
- &textsub_obj, // script_obj
- baseFssProc, // fssProc
- };
-
- static FilterDefinition* fd_vobsub;
- static FilterDefinition* fd_textsub;
-
- extern "C" __declspec(dllexport) int __cdecl VirtualdubFilterModuleInit2(FilterModule *fm, const FilterFunctions *ff, int& vdfd_ver, int& vdfd_compat)
- {
- fd_vobsub = ff->addFilter(fm, &filterDef_vobsub, sizeof(FilterDefinition));
- if (!fd_vobsub) {
- return 1;
- }
- fd_textsub = ff->addFilter(fm, &filterDef_textsub, sizeof(FilterDefinition));
- if (!fd_textsub) {
- return 1;
- }
-
- vdfd_ver = VIRTUALDUB_FILTERDEF_VERSION;
- vdfd_compat = VIRTUALDUB_FILTERDEF_COMPATIBLE;
-
- return 0;
- }
-
- extern "C" __declspec(dllexport) void __cdecl VirtualdubFilterModuleDeinit(FilterModule *fm, const FilterFunctions *ff)
- {
- ff->removeFilter(fd_textsub);
- ff->removeFilter(fd_vobsub);
- }
- }/**/
+ class CVirtualDubFilter : virtual public CFilter
+ {
+ public:
+ CVirtualDubFilter() {}
+ virtual ~CVirtualDubFilter() {}
+
+ virtual int RunProc(const FilterActivation* fa, const FilterFunctions* ff) {
+ SubPicDesc dst;
+ dst.type = MSP_RGB32;
+ dst.w = fa->src.w;
+ dst.h = fa->src.h;
+ dst.bpp = 32;
+ dst.pitch = fa->src.pitch;
+ dst.bits = (LPVOID)fa->src.data;
+
+ Render(dst, 10000i64 * fa->pfsi->lSourceFrameMS, (float)1000 / fa->pfsi->lMicrosecsPerFrame);
+
+ return 0;
+ }
+
+ virtual long ParamProc(FilterActivation* fa, const FilterFunctions* ff) {
+ fa->dst.offset = fa->src.offset;
+ fa->dst.modulo = fa->src.modulo;
+ fa->dst.pitch = fa->src.pitch;
+
+ return 0;
+ }
+
+ virtual int ConfigProc(FilterActivation* fa, const FilterFunctions* ff, HWND hwnd) = 0;
+ virtual void StringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str) = 0;
+ virtual bool FssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen) = 0;
+ };
+
+ class CVobSubVirtualDubFilter : public CVobSubFilter, public CVirtualDubFilter
+ {
+ public:
+ CVobSubVirtualDubFilter(CString fn = _T(""))
+ : CVobSubFilter(fn) {}
+
+ int ConfigProc(FilterActivation* fa, const FilterFunctions* ff, HWND hwnd) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY,
+ _T("VobSub files (*.idx;*.sub)|*.idx;*.sub||"), CWnd::FromHandle(hwnd), 0);
+
+ if (fd.DoModal() != IDOK) {
+ return 1;
+ }
+
+ return Open(fd.GetPathName()) ? 0 : 1;
+ }
+
+ void StringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str) {
+ sprintf(str, " (%s)", !GetFileName().IsEmpty() ? CStringA(GetFileName()) : " (empty)");
+ }
+
+ bool FssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen) {
+ CStringA fn(GetFileName());
+ fn.Replace("\\", "\\\\");
+ _snprintf_s(buf, buflen, buflen, "Config(\"%s\")", fn);
+ return true;
+ }
+ };
+
+ class CTextSubVirtualDubFilter : public CTextSubFilter, public CVirtualDubFilter
+ {
+ public:
+ CTextSubVirtualDubFilter(CString fn = _T(""), int CharSet = DEFAULT_CHARSET)
+ : CTextSubFilter(fn, CharSet) {}
+
+ int ConfigProc(FilterActivation* fa, const FilterFunctions* ff, HWND hwnd) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ const TCHAR formats[] = _T("TextSub files (*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt)|*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt||");
+ CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_ENABLETEMPLATE | OFN_ENABLEHOOK,
+ formats, CWnd::FromHandle(hwnd), sizeof(OPENFILENAME));
+ UINT_PTR CALLBACK OpenHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
+
+ fd.m_pOFN->hInstance = AfxGetResourceHandle();
+ fd.m_pOFN->lpTemplateName = MAKEINTRESOURCE(IDD_TEXTSUBOPENTEMPLATE);
+ fd.m_pOFN->lpfnHook = (LPOFNHOOKPROC)OpenHookProc;
+ fd.m_pOFN->lCustData = (LPARAM)DEFAULT_CHARSET;
+
+ if (fd.DoModal() != IDOK) {
+ return 1;
+ }
+
+ return Open(fd.GetPathName(), fd.m_pOFN->lCustData) ? 0 : 1;
+ }
+
+ void StringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str) {
+ if (!GetFileName().IsEmpty()) {
+ sprintf(str, " (%s, %d)", CStringA(GetFileName()), GetCharSet());
+ } else {
+ sprintf(str, " (empty)");
+ }
+ }
+
+ bool FssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen) {
+ CStringA fn(GetFileName());
+ fn.Replace("\\", "\\\\");
+ _snprintf_s(buf, buflen, buflen, "Config(\"%s\", %d)", fn, GetCharSet());
+ return true;
+ }
+ };
+
+ int vobsubInitProc(FilterActivation* fa, const FilterFunctions* ff)
+ {
+ *(CVirtualDubFilter**)fa->filter_data = DNew CVobSubVirtualDubFilter();
+ return !(*(CVirtualDubFilter**)fa->filter_data);
+ }
+
+ int textsubInitProc(FilterActivation* fa, const FilterFunctions* ff)
+ {
+ *(CVirtualDubFilter**)fa->filter_data = DNew CTextSubVirtualDubFilter();
+ return !(*(CVirtualDubFilter**)fa->filter_data);
+ }
+
+ void baseDeinitProc(FilterActivation* fa, const FilterFunctions* ff)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if (f) {
+ delete f, f = NULL;
+ }
+ }
+
+ int baseRunProc(const FilterActivation* fa, const FilterFunctions* ff)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->RunProc(fa, ff) : 1;
+ }
+
+ long baseParamProc(FilterActivation* fa, const FilterFunctions* ff)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->ParamProc(fa, ff) : 1;
+ }
+
+ int baseConfigProc(FilterActivation* fa, const FilterFunctions* ff, HWND hwnd)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->ConfigProc(fa, ff, hwnd) : 1;
+ }
+
+ void baseStringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if (f) {
+ f->StringProc(fa, ff, str);
+ }
+ }
+
+ bool baseFssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->FssProc(fa, ff, buf, buflen) : false;
+ }
+
+ void vobsubScriptConfig(IScriptInterpreter* isi, void* lpVoid, CScriptValue* argv, int argc)
+ {
+ FilterActivation* fa = (FilterActivation*)lpVoid;
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if (f) {
+ delete f;
+ }
+ f = DNew CVobSubVirtualDubFilter(CString(*argv[0].asString()));
+ *(CVirtualDubFilter**)fa->filter_data = f;
+ }
+
+ void textsubScriptConfig(IScriptInterpreter* isi, void* lpVoid, CScriptValue* argv, int argc)
+ {
+ FilterActivation* fa = (FilterActivation*)lpVoid;
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if (f) {
+ delete f;
+ }
+ f = DNew CTextSubVirtualDubFilter(CString(*argv[0].asString()), argv[1].asInt());
+ *(CVirtualDubFilter**)fa->filter_data = f;
+ }
+
+ ScriptFunctionDef vobsub_func_defs[] = {
+ { (ScriptFunctionPtr)vobsubScriptConfig, "Config", "0s" },
+ { NULL },
+ };
+
+ CScriptObject vobsub_obj = {
+ NULL, vobsub_func_defs
+ };
+
+ struct FilterDefinition filterDef_vobsub = {
+ NULL, NULL, NULL, // next, prev, module
+ "VobSub", // name
+ "Adds subtitles from a vob sequence.", // desc
+ "Gabest", // maker
+ NULL, // private_data
+ sizeof(CVirtualDubFilter**), // inst_data_size
+ vobsubInitProc, // initProc
+ baseDeinitProc, // deinitProc
+ baseRunProc, // runProc
+ baseParamProc, // paramProc
+ baseConfigProc, // configProc
+ baseStringProc, // stringProc
+ NULL, // startProc
+ NULL, // endProc
+ &vobsub_obj, // script_obj
+ baseFssProc, // fssProc
+ };
+
+ ScriptFunctionDef textsub_func_defs[] = {
+ { (ScriptFunctionPtr)textsubScriptConfig, "Config", "0si" },
+ { NULL },
+ };
+
+ CScriptObject textsub_obj = {
+ NULL, textsub_func_defs
+ };
+
+ struct FilterDefinition filterDef_textsub = {
+ NULL, NULL, NULL, // next, prev, module
+ "TextSub", // name
+ "Adds subtitles from srt, sub, psb, smi, ssa, ass file formats.", // desc
+ "Gabest", // maker
+ NULL, // private_data
+ sizeof(CVirtualDubFilter**), // inst_data_size
+ textsubInitProc, // initProc
+ baseDeinitProc, // deinitProc
+ baseRunProc, // runProc
+ baseParamProc, // paramProc
+ baseConfigProc, // configProc
+ baseStringProc, // stringProc
+ NULL, // startProc
+ NULL, // endProc
+ &textsub_obj, // script_obj
+ baseFssProc, // fssProc
+ };
+
+ static FilterDefinition* fd_vobsub;
+ static FilterDefinition* fd_textsub;
+
+ extern "C" __declspec(dllexport) int __cdecl VirtualdubFilterModuleInit2(FilterModule* fm, const FilterFunctions* ff, int& vdfd_ver, int& vdfd_compat)
+ {
+ fd_vobsub = ff->addFilter(fm, &filterDef_vobsub, sizeof(FilterDefinition));
+ if (!fd_vobsub) {
+ return 1;
+ }
+ fd_textsub = ff->addFilter(fm, &filterDef_textsub, sizeof(FilterDefinition));
+ if (!fd_textsub) {
+ return 1;
+ }
+
+ vdfd_ver = VIRTUALDUB_FILTERDEF_VERSION;
+ vdfd_compat = VIRTUALDUB_FILTERDEF_COMPATIBLE;
+
+ return 0;
+ }
+
+ extern "C" __declspec(dllexport) void __cdecl VirtualdubFilterModuleDeinit(FilterModule* fm, const FilterFunctions* ff)
+ {
+ ff->removeFilter(fd_textsub);
+ ff->removeFilter(fd_vobsub);
+ }
+ }/**/
#else
- //
- // VirtualDub new plugin interface sdk 1.1
- //
- namespace VirtualDubNew
- {
+ //
+ // VirtualDub new plugin interface sdk 1.1
+ //
+ namespace VirtualDubNew
+ {
#include <vd2/plugin/vdplugin.h>
#include <vd2/plugin/vdvideofilt.h>
- class CVirtualDubFilter : virtual public CFilter
- {
- public:
- CVirtualDubFilter() {}
- virtual ~CVirtualDubFilter() {}
-
- virtual int RunProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff) {
- SubPicDesc dst;
- dst.type = MSP_RGB32;
- dst.w = fa->src.w;
- dst.h = fa->src.h;
- dst.bpp = 32;
- dst.pitch = fa->src.pitch;
- dst.bits = (LPVOID)fa->src.data;
-
- Render(dst, 10000i64*fa->pfsi->lSourceFrameMS, (float)1000 / fa->pfsi->lMicrosecsPerFrame);
-
- return 0;
- }
-
- virtual long ParamProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff) {
- fa->dst.offset = fa->src.offset;
- fa->dst.modulo = fa->src.modulo;
- fa->dst.pitch = fa->src.pitch;
-
- return 0;
- }
-
- virtual int ConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd) = 0;
- virtual void StringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str) = 0;
- virtual bool FssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen) = 0;
- };
-
- class CVobSubVirtualDubFilter : public CVobSubFilter, public CVirtualDubFilter
- {
- public:
- CVobSubVirtualDubFilter(CString fn = _T(""))
- : CVobSubFilter(fn) {}
-
- int ConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd) {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY,
- _T("VobSub files (*.idx;*.sub)|*.idx;*.sub||"), CWnd::FromHandle((HWND)hwnd), 0);
-
- if (fd.DoModal() != IDOK) {
- return 1;
- }
-
- return Open(fd.GetPathName()) ? 0 : 1;
- }
-
- void StringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str) {
- sprintf(str, " (%s)", !GetFileName().IsEmpty() ? CStringA(GetFileName()) : " (empty)");
- }
-
- bool FssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen) {
- CStringA fn(GetFileName());
- fn.Replace("\\", "\\\\");
- _snprintf_s(buf, buflen, buflen, "Config(\"%s\")", fn);
- return true;
- }
- };
-
- class CTextSubVirtualDubFilter : public CTextSubFilter, public CVirtualDubFilter
- {
- public:
- CTextSubVirtualDubFilter(CString fn = _T(""), int CharSet = DEFAULT_CHARSET)
- : CTextSubFilter(fn, CharSet) {}
-
- int ConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd) {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- /* off encoding changing */
+ class CVirtualDubFilter : virtual public CFilter
+ {
+ public:
+ CVirtualDubFilter() {}
+ virtual ~CVirtualDubFilter() {}
+
+ virtual int RunProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff) {
+ SubPicDesc dst;
+ dst.type = MSP_RGB32;
+ dst.w = fa->src.w;
+ dst.h = fa->src.h;
+ dst.bpp = 32;
+ dst.pitch = fa->src.pitch;
+ dst.bits = (LPVOID)fa->src.data;
+
+ Render(dst, 10000i64 * fa->pfsi->lSourceFrameMS, (float)1000 / fa->pfsi->lMicrosecsPerFrame);
+
+ return 0;
+ }
+
+ virtual long ParamProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff) {
+ fa->dst.offset = fa->src.offset;
+ fa->dst.modulo = fa->src.modulo;
+ fa->dst.pitch = fa->src.pitch;
+
+ return 0;
+ }
+
+ virtual int ConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd) = 0;
+ virtual void StringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str) = 0;
+ virtual bool FssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen) = 0;
+ };
+
+ class CVobSubVirtualDubFilter : public CVobSubFilter, public CVirtualDubFilter
+ {
+ public:
+ CVobSubVirtualDubFilter(CString fn = _T(""))
+ : CVobSubFilter(fn) {}
+
+ int ConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY,
+ _T("VobSub files (*.idx;*.sub)|*.idx;*.sub||"), CWnd::FromHandle((HWND)hwnd), 0);
+
+ if (fd.DoModal() != IDOK) {
+ return 1;
+ }
+
+ return Open(fd.GetPathName()) ? 0 : 1;
+ }
+
+ void StringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str) {
+ sprintf(str, " (%s)", !GetFileName().IsEmpty() ? CStringA(GetFileName()) : " (empty)");
+ }
+
+ bool FssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen) {
+ CStringA fn(GetFileName());
+ fn.Replace("\\", "\\\\");
+ _snprintf_s(buf, buflen, buflen, "Config(\"%s\")", fn);
+ return true;
+ }
+ };
+
+ class CTextSubVirtualDubFilter : public CTextSubFilter, public CVirtualDubFilter
+ {
+ public:
+ CTextSubVirtualDubFilter(CString fn = _T(""), int CharSet = DEFAULT_CHARSET)
+ : CTextSubFilter(fn, CharSet) {}
+
+ int ConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ /* off encoding changing */
#ifndef _DEBUG
- const TCHAR formats[] = _T("TextSub files (*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt)|*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt||");
- CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_ENABLETEMPLATE|OFN_ENABLEHOOK,
- formats, CWnd::FromHandle((HWND)hwnd), sizeof(OPENFILENAME));
- UINT_PTR CALLBACK OpenHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
-
- fd.m_pOFN->hInstance = AfxGetResourceHandle();
- fd.m_pOFN->lpTemplateName = MAKEINTRESOURCE(IDD_TEXTSUBOPENTEMPLATE);
- fd.m_pOFN->lpfnHook = (LPOFNHOOKPROC)OpenHookProc;
- fd.m_pOFN->lCustData = (LPARAM)DEFAULT_CHARSET;
+ const TCHAR formats[] = _T("TextSub files (*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt)|*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt||");
+ CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_ENABLETEMPLATE | OFN_ENABLEHOOK,
+ formats, CWnd::FromHandle((HWND)hwnd), sizeof(OPENFILENAME));
+ UINT_PTR CALLBACK OpenHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
+
+ fd.m_pOFN->hInstance = AfxGetResourceHandle();
+ fd.m_pOFN->lpTemplateName = MAKEINTRESOURCE(IDD_TEXTSUBOPENTEMPLATE);
+ fd.m_pOFN->lpfnHook = (LPOFNHOOKPROC)OpenHookProc;
+ fd.m_pOFN->lCustData = (LPARAM)DEFAULT_CHARSET;
#else
- const TCHAR formats[] = _T("TextSub files (*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt)|*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt||");
- CFileDialog fd(TRUE, NULL, GetFileName(), OFN_ENABLESIZING|OFN_HIDEREADONLY,
- formats, CWnd::FromHandle((HWND)hwnd), sizeof(OPENFILENAME));
+ const TCHAR formats[] = _T("TextSub files (*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt)|*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt||");
+ CFileDialog fd(TRUE, NULL, GetFileName(), OFN_ENABLESIZING | OFN_HIDEREADONLY,
+ formats, CWnd::FromHandle((HWND)hwnd), sizeof(OPENFILENAME));
#endif
- if (fd.DoModal() != IDOK) {
- return 1;
- }
-
- return Open(fd.GetPathName(), fd.m_pOFN->lCustData) ? 0 : 1;
- }
-
- void StringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str) {
- if (!GetFileName().IsEmpty()) {
- sprintf(str, " (%s, %d)", CStringA(GetFileName()), GetCharSet());
- } else {
- sprintf(str, " (empty)");
- }
- }
-
- bool FssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen) {
- CStringA fn(GetFileName());
- fn.Replace("\\", "\\\\");
- _snprintf_s(buf, buflen, buflen, "Config(\"%s\", %d)", fn, GetCharSet());
- return true;
- }
- };
-
- int vobsubInitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
- {
- return ((*(CVirtualDubFilter**)fa->filter_data = DNew CVobSubVirtualDubFilter()) == NULL);
- }
-
- int textsubInitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
- {
- return ((*(CVirtualDubFilter**)fa->filter_data = DNew CTextSubVirtualDubFilter()) == NULL);
- }
-
- void baseDeinitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
- {
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if (f) {
- delete f, f = NULL;
- }
- }
-
- int baseRunProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff)
- {
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->RunProc(fa, ff) : 1;
- }
-
- long baseParamProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
- {
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->ParamProc(fa, ff) : 1;
- }
-
- int baseConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd)
- {
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->ConfigProc(fa, ff, hwnd) : 1;
- }
-
- void baseStringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str)
- {
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if (f) {
- f->StringProc(fa, ff, str);
- }
- }
-
- bool baseFssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen)
- {
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->FssProc(fa, ff, buf, buflen) : false;
- }
-
- void vobsubScriptConfig(IVDXScriptInterpreter* isi, void* lpVoid, VDXScriptValue* argv, int argc)
- {
- VDXFilterActivation* fa = (VDXFilterActivation*)lpVoid;
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if (f) {
- delete f;
- }
- f = DNew CVobSubVirtualDubFilter(CString(*argv[0].asString()));
- *(CVirtualDubFilter**)fa->filter_data = f;
- }
-
- void textsubScriptConfig(IVDXScriptInterpreter* isi, void* lpVoid, VDXScriptValue* argv, int argc)
- {
- VDXFilterActivation* fa = (VDXFilterActivation*)lpVoid;
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if (f) {
- delete f;
- }
- f = DNew CTextSubVirtualDubFilter(CString(*argv[0].asString()), argv[1].asInt());
- *(CVirtualDubFilter**)fa->filter_data = f;
- }
-
- VDXScriptFunctionDef vobsub_func_defs[]= {
- { (VDXScriptFunctionPtr)vobsubScriptConfig, "Config", "0s" },
- { NULL },
- };
-
- VDXScriptObject vobsub_obj= {
- NULL, vobsub_func_defs
- };
-
- struct VDXFilterDefinition filterDef_vobsub = {
- NULL, NULL, NULL, // next, prev, module
- "VobSub", // name
- "Adds subtitles from a vob sequence.", // desc
- "Gabest", // maker
- NULL, // private_data
- sizeof(CVirtualDubFilter**), // inst_data_size
- vobsubInitProc, // initProc
- baseDeinitProc, // deinitProc
- baseRunProc, // runProc
- baseParamProc, // paramProc
- baseConfigProc, // configProc
- baseStringProc, // stringProc
- NULL, // startProc
- NULL, // endProc
- &vobsub_obj, // script_obj
- baseFssProc, // fssProc
- };
-
- VDXScriptFunctionDef textsub_func_defs[]= {
- { (VDXScriptFunctionPtr)textsubScriptConfig, "Config", "0si" },
- { NULL },
- };
-
- VDXScriptObject textsub_obj= {
- NULL, textsub_func_defs
- };
-
- struct VDXFilterDefinition filterDef_textsub = {
- NULL, NULL, NULL, // next, prev, module
- "TextSub", // name
- "Adds subtitles from srt, sub, psb, smi, ssa, ass file formats.", // desc
- "Gabest", // maker
- NULL, // private_data
- sizeof(CVirtualDubFilter**), // inst_data_size
- textsubInitProc, // initProc
- baseDeinitProc, // deinitProc
- baseRunProc, // runProc
- baseParamProc, // paramProc
- baseConfigProc, // configProc
- baseStringProc, // stringProc
- NULL, // startProc
- NULL, // endProc
- &textsub_obj, // script_obj
- baseFssProc, // fssProc
- };
-
- static VDXFilterDefinition* fd_vobsub;
- static VDXFilterDefinition* fd_textsub;
-
- extern "C" __declspec(dllexport) int __cdecl VirtualdubFilterModuleInit2(VDXFilterModule *fm, const VDXFilterFunctions *ff, int& vdfd_ver, int& vdfd_compat)
- {
- if (((fd_vobsub = ff->addFilter(fm, &filterDef_vobsub, sizeof(VDXFilterDefinition))) == NULL)
- || ((fd_textsub = ff->addFilter(fm, &filterDef_textsub, sizeof(VDXFilterDefinition))) == NULL)) {
- return 1;
- }
-
- vdfd_ver = VIRTUALDUB_FILTERDEF_VERSION;
- vdfd_compat = VIRTUALDUB_FILTERDEF_COMPATIBLE;
-
- return 0;
- }
-
- extern "C" __declspec(dllexport) void __cdecl VirtualdubFilterModuleDeinit(VDXFilterModule *fm, const VDXFilterFunctions *ff)
- {
- ff->removeFilter(fd_textsub);
- ff->removeFilter(fd_vobsub);
- }
- }
+ if (fd.DoModal() != IDOK) {
+ return 1;
+ }
+
+ return Open(fd.GetPathName(), fd.m_pOFN->lCustData) ? 0 : 1;
+ }
+
+ void StringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str) {
+ if (!GetFileName().IsEmpty()) {
+ sprintf(str, " (%s, %d)", CStringA(GetFileName()), GetCharSet());
+ } else {
+ sprintf(str, " (empty)");
+ }
+ }
+
+ bool FssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen) {
+ CStringA fn(GetFileName());
+ fn.Replace("\\", "\\\\");
+ _snprintf_s(buf, buflen, buflen, "Config(\"%s\", %d)", fn, GetCharSet());
+ return true;
+ }
+ };
+
+ int vobsubInitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
+ {
+ return ((*(CVirtualDubFilter**)fa->filter_data = DNew CVobSubVirtualDubFilter()) == NULL);
+ }
+
+ int textsubInitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
+ {
+ return ((*(CVirtualDubFilter**)fa->filter_data = DNew CTextSubVirtualDubFilter()) == NULL);
+ }
+
+ void baseDeinitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if (f) {
+ delete f, f = NULL;
+ }
+ }
+
+ int baseRunProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->RunProc(fa, ff) : 1;
+ }
+
+ long baseParamProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->ParamProc(fa, ff) : 1;
+ }
+
+ int baseConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->ConfigProc(fa, ff, hwnd) : 1;
+ }
+
+ void baseStringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if (f) {
+ f->StringProc(fa, ff, str);
+ }
+ }
+
+ bool baseFssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->FssProc(fa, ff, buf, buflen) : false;
+ }
+
+ void vobsubScriptConfig(IVDXScriptInterpreter* isi, void* lpVoid, VDXScriptValue* argv, int argc)
+ {
+ VDXFilterActivation* fa = (VDXFilterActivation*)lpVoid;
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if (f) {
+ delete f;
+ }
+ f = DNew CVobSubVirtualDubFilter(CString(*argv[0].asString()));
+ *(CVirtualDubFilter**)fa->filter_data = f;
+ }
+
+ void textsubScriptConfig(IVDXScriptInterpreter* isi, void* lpVoid, VDXScriptValue* argv, int argc)
+ {
+ VDXFilterActivation* fa = (VDXFilterActivation*)lpVoid;
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if (f) {
+ delete f;
+ }
+ f = DNew CTextSubVirtualDubFilter(CString(*argv[0].asString()), argv[1].asInt());
+ *(CVirtualDubFilter**)fa->filter_data = f;
+ }
+
+ VDXScriptFunctionDef vobsub_func_defs[] = {
+ { (VDXScriptFunctionPtr)vobsubScriptConfig, "Config", "0s" },
+ { NULL },
+ };
+
+ VDXScriptObject vobsub_obj = {
+ NULL, vobsub_func_defs
+ };
+
+ struct VDXFilterDefinition filterDef_vobsub = {
+ NULL, NULL, NULL, // next, prev, module
+ "VobSub", // name
+ "Adds subtitles from a vob sequence.", // desc
+ "Gabest", // maker
+ NULL, // private_data
+ sizeof(CVirtualDubFilter**), // inst_data_size
+ vobsubInitProc, // initProc
+ baseDeinitProc, // deinitProc
+ baseRunProc, // runProc
+ baseParamProc, // paramProc
+ baseConfigProc, // configProc
+ baseStringProc, // stringProc
+ NULL, // startProc
+ NULL, // endProc
+ &vobsub_obj, // script_obj
+ baseFssProc, // fssProc
+ };
+
+ VDXScriptFunctionDef textsub_func_defs[] = {
+ { (VDXScriptFunctionPtr)textsubScriptConfig, "Config", "0si" },
+ { NULL },
+ };
+
+ VDXScriptObject textsub_obj = {
+ NULL, textsub_func_defs
+ };
+
+ struct VDXFilterDefinition filterDef_textsub = {
+ NULL, NULL, NULL, // next, prev, module
+ "TextSub", // name
+ "Adds subtitles from srt, sub, psb, smi, ssa, ass file formats.", // desc
+ "Gabest", // maker
+ NULL, // private_data
+ sizeof(CVirtualDubFilter**), // inst_data_size
+ textsubInitProc, // initProc
+ baseDeinitProc, // deinitProc
+ baseRunProc, // runProc
+ baseParamProc, // paramProc
+ baseConfigProc, // configProc
+ baseStringProc, // stringProc
+ NULL, // startProc
+ NULL, // endProc
+ &textsub_obj, // script_obj
+ baseFssProc, // fssProc
+ };
+
+ static VDXFilterDefinition* fd_vobsub;
+ static VDXFilterDefinition* fd_textsub;
+
+ extern "C" __declspec(dllexport) int __cdecl VirtualdubFilterModuleInit2(VDXFilterModule* fm, const VDXFilterFunctions* ff, int& vdfd_ver, int& vdfd_compat)
+ {
+ if (((fd_vobsub = ff->addFilter(fm, &filterDef_vobsub, sizeof(VDXFilterDefinition))) == NULL)
+ || ((fd_textsub = ff->addFilter(fm, &filterDef_textsub, sizeof(VDXFilterDefinition))) == NULL)) {
+ return 1;
+ }
+
+ vdfd_ver = VIRTUALDUB_FILTERDEF_VERSION;
+ vdfd_compat = VIRTUALDUB_FILTERDEF_COMPATIBLE;
+
+ return 0;
+ }
+
+ extern "C" __declspec(dllexport) void __cdecl VirtualdubFilterModuleDeinit(VDXFilterModule* fm, const VDXFilterFunctions* ff)
+ {
+ ff->removeFilter(fd_textsub);
+ ff->removeFilter(fd_vobsub);
+ }
+ }
#endif
- //
- // Avisynth interface
- //
+ //
+ // Avisynth interface
+ //
- namespace AviSynth1
- {
+ namespace AviSynth1
+ {
#include <avisynth/avisynth1.h>
- class CAvisynthFilter : public GenericVideoFilter, virtual public CFilter
- {
- public:
- CAvisynthFilter(PClip c, IScriptEnvironment* env) : GenericVideoFilter(c) {}
-
- PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) {
- PVideoFrame frame = child->GetFrame(n, env);
-
- env->MakeWritable(&frame);
-
- SubPicDesc dst;
- dst.w = vi.width;
- dst.h = vi.height;
- dst.pitch = frame->GetPitch();
- dst.bits = (void**)frame->GetWritePtr();
- dst.bpp = vi.BitsPerPixel();
- dst.type =
- vi.IsRGB32() ? ( env->GetVar("RGBA").AsBool() ? MSP_RGBA :MSP_RGB32) :
- vi.IsRGB24() ? MSP_RGB24 :
- vi.IsYUY2() ? MSP_YUY2 :
- -1;
-
- float fps = m_fps > 0 ? m_fps : (float)vi.fps_numerator / vi.fps_denominator;
-
- Render(dst, (REFERENCE_TIME)(10000000i64 * n / fps), fps);
-
- return frame;
- }
- };
-
- class CVobSubAvisynthFilter : public CVobSubFilter, public CAvisynthFilter
- {
- public:
- CVobSubAvisynthFilter(PClip c, const char* fn, IScriptEnvironment* env)
- : CVobSubFilter(CString(fn))
- , CAvisynthFilter(c, env) {
- if (!m_pSubPicProvider) {
- env->ThrowError("VobSub: Can't open \"%s\"", fn);
- }
- }
- };
-
- AVSValue __cdecl VobSubCreateS(AVSValue args, void* user_data, IScriptEnvironment* env)
- {
- return (DNew CVobSubAvisynthFilter(args[0].AsClip(), args[1].AsString(), env));
- }
-
- class CTextSubAvisynthFilter : public CTextSubFilter, public CAvisynthFilter
- {
- public:
- CTextSubAvisynthFilter(PClip c, IScriptEnvironment* env, const char* fn, int CharSet = DEFAULT_CHARSET, float fps = -1)
- : CTextSubFilter(CString(fn), CharSet, fps)
- , CAvisynthFilter(c, env) {
- if (!m_pSubPicProvider)
- env->ThrowError("TextSub: Can't open \"%s\"", fn);
- }
- };
-
- AVSValue __cdecl TextSubCreateS(AVSValue args, void* user_data, IScriptEnvironment* env)
- {
- return (DNew CTextSubAvisynthFilter(args[0].AsClip(), env, args[1].AsString()));
- }
-
- AVSValue __cdecl TextSubCreateSI(AVSValue args, void* user_data, IScriptEnvironment* env)
- {
- return (DNew CTextSubAvisynthFilter(args[0].AsClip(), env, args[1].AsString(), args[2].AsInt()));
- }
-
- AVSValue __cdecl TextSubCreateSIF(AVSValue args, void* user_data, IScriptEnvironment* env)
- {
- return (DNew CTextSubAvisynthFilter(args[0].AsClip(), env, args[1].AsString(), args[2].AsInt(), (float)args[3].AsFloat()));
- }
-
- AVSValue __cdecl MaskSubCreateSIIFI(AVSValue args, void* user_data, IScriptEnvironment* env)
- {
- AVSValue rgb32("RGB32");
- AVSValue tab[5] = {
- args[1],
- args[2],
- args[3],
- args[4],
- rgb32
- };
- AVSValue value(tab,5);
- const char * nom[5]= {
- "width",
- "height",
- "fps",
- "length",
- "pixel_type"
- };
- AVSValue clip(env->Invoke("Blackness",value,nom));
- env->SetVar(env->SaveString("RGBA"),true);
- return (DNew CTextSubAvisynthFilter(clip.AsClip(), env, args[0].AsString()));
- }
-
- extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit(IScriptEnvironment* env)
- {
- env->AddFunction("VobSub", "cs", VobSubCreateS, 0);
- env->AddFunction("TextSub", "cs", TextSubCreateS, 0);
- env->AddFunction("TextSub", "csi", TextSubCreateSI, 0);
- env->AddFunction("TextSub", "csif", TextSubCreateSIF, 0);
- env->AddFunction("MaskSub", "siifi", MaskSubCreateSIIFI, 0);
- env->SetVar(env->SaveString("RGBA"),false);
- return NULL;
- }
- }
-
- namespace AviSynth25
- {
+ class CAvisynthFilter : public GenericVideoFilter, virtual public CFilter
+ {
+ public:
+ CAvisynthFilter(PClip c, IScriptEnvironment* env) : GenericVideoFilter(c) {}
+
+ PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) {
+ PVideoFrame frame = child->GetFrame(n, env);
+
+ env->MakeWritable(&frame);
+
+ SubPicDesc dst;
+ dst.w = vi.width;
+ dst.h = vi.height;
+ dst.pitch = frame->GetPitch();
+ dst.bits = (void**)frame->GetWritePtr();
+ dst.bpp = vi.BitsPerPixel();
+ dst.type =
+ vi.IsRGB32() ? (env->GetVar("RGBA").AsBool() ? MSP_RGBA : MSP_RGB32) :
+ vi.IsRGB24() ? MSP_RGB24 :
+ vi.IsYUY2() ? MSP_YUY2 :
+ -1;
+
+ float fps = m_fps > 0 ? m_fps : (float)vi.fps_numerator / vi.fps_denominator;
+
+ Render(dst, (REFERENCE_TIME)(10000000i64 * n / fps), fps);
+
+ return frame;
+ }
+ };
+
+ class CVobSubAvisynthFilter : public CVobSubFilter, public CAvisynthFilter
+ {
+ public:
+ CVobSubAvisynthFilter(PClip c, const char* fn, IScriptEnvironment* env)
+ : CVobSubFilter(CString(fn))
+ , CAvisynthFilter(c, env) {
+ if (!m_pSubPicProvider) {
+ env->ThrowError("VobSub: Can't open \"%s\"", fn);
+ }
+ }
+ };
+
+ AVSValue __cdecl VobSubCreateS(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ return (DNew CVobSubAvisynthFilter(args[0].AsClip(), args[1].AsString(), env));
+ }
+
+ class CTextSubAvisynthFilter : public CTextSubFilter, public CAvisynthFilter
+ {
+ public:
+ CTextSubAvisynthFilter(PClip c, IScriptEnvironment* env, const char* fn, int CharSet = DEFAULT_CHARSET, float fps = -1)
+ : CTextSubFilter(CString(fn), CharSet, fps)
+ , CAvisynthFilter(c, env) {
+ if (!m_pSubPicProvider) {
+ env->ThrowError("TextSub: Can't open \"%s\"", fn);
+ }
+ }
+ };
+
+ AVSValue __cdecl TextSubCreateS(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ return (DNew CTextSubAvisynthFilter(args[0].AsClip(), env, args[1].AsString()));
+ }
+
+ AVSValue __cdecl TextSubCreateSI(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ return (DNew CTextSubAvisynthFilter(args[0].AsClip(), env, args[1].AsString(), args[2].AsInt()));
+ }
+
+ AVSValue __cdecl TextSubCreateSIF(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ return (DNew CTextSubAvisynthFilter(args[0].AsClip(), env, args[1].AsString(), args[2].AsInt(), (float)args[3].AsFloat()));
+ }
+
+ AVSValue __cdecl MaskSubCreateSIIFI(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ AVSValue rgb32("RGB32");
+ AVSValue tab[5] = {
+ args[1],
+ args[2],
+ args[3],
+ args[4],
+ rgb32
+ };
+ AVSValue value(tab, 5);
+ const char* nom[5] = {
+ "width",
+ "height",
+ "fps",
+ "length",
+ "pixel_type"
+ };
+ AVSValue clip(env->Invoke("Blackness", value, nom));
+ env->SetVar(env->SaveString("RGBA"), true);
+ return (DNew CTextSubAvisynthFilter(clip.AsClip(), env, args[0].AsString()));
+ }
+
+ extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit(IScriptEnvironment* env)
+ {
+ env->AddFunction("VobSub", "cs", VobSubCreateS, 0);
+ env->AddFunction("TextSub", "cs", TextSubCreateS, 0);
+ env->AddFunction("TextSub", "csi", TextSubCreateSI, 0);
+ env->AddFunction("TextSub", "csif", TextSubCreateSIF, 0);
+ env->AddFunction("MaskSub", "siifi", MaskSubCreateSIIFI, 0);
+ env->SetVar(env->SaveString("RGBA"), false);
+ return NULL;
+ }
+ }
+
+ namespace AviSynth25
+ {
#include <avisynth/avisynth25.h>
- static bool s_fSwapUV = false;
-
- class CAvisynthFilter : public GenericVideoFilter, virtual public CFilter
- {
- public:
- VFRTranslator *vfr;
-
- CAvisynthFilter(PClip c, IScriptEnvironment* env, VFRTranslator *_vfr=0) : GenericVideoFilter(c), vfr(_vfr) {}
-
- PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) {
- PVideoFrame frame = child->GetFrame(n, env);
-
- env->MakeWritable(&frame);
-
- SubPicDesc dst;
- dst.w = vi.width;
- dst.h = vi.height;
- dst.pitch = frame->GetPitch();
- dst.pitchUV = frame->GetPitch(PLANAR_U);
- dst.bits = (void**)frame->GetWritePtr();
- dst.bitsU = frame->GetWritePtr(PLANAR_U);
- dst.bitsV = frame->GetWritePtr(PLANAR_V);
- dst.bpp = dst.pitch/dst.w*8; //vi.BitsPerPixel();
- dst.type =
- vi.IsRGB32() ?( env->GetVar("RGBA").AsBool() ? MSP_RGBA : MSP_RGB32) :
- vi.IsRGB24() ? MSP_RGB24 :
- vi.IsYUY2() ? MSP_YUY2 :
- /*vi.IsYV12()*/ vi.pixel_type == VideoInfo::CS_YV12 ? (s_fSwapUV?MSP_IYUV:MSP_YV12) :
- /*vi.IsIYUV()*/ vi.pixel_type == VideoInfo::CS_IYUV ? (s_fSwapUV?MSP_YV12:MSP_IYUV) :
- -1;
-
- float fps = m_fps > 0 ? m_fps : (float)vi.fps_numerator / vi.fps_denominator;
-
- REFERENCE_TIME timestamp;
-
- if (!vfr) {
- timestamp = (REFERENCE_TIME)(10000000i64 * n / fps);
- } else {
- timestamp = (REFERENCE_TIME)(10000000 * vfr->TimeStampFromFrameNumber(n));
- }
-
- Render(dst, timestamp, fps);
-
- return frame;
- }
- };
-
- class CVobSubAvisynthFilter : public CVobSubFilter, public CAvisynthFilter
- {
- public:
- CVobSubAvisynthFilter(PClip c, const char* fn, IScriptEnvironment* env)
- : CVobSubFilter(CString(fn))
- , CAvisynthFilter(c, env) {
- if (!m_pSubPicProvider) {
- env->ThrowError("VobSub: Can't open \"%s\"", fn);
- }
- }
- };
-
- AVSValue __cdecl VobSubCreateS(AVSValue args, void* user_data, IScriptEnvironment* env)
- {
- return (DNew CVobSubAvisynthFilter(args[0].AsClip(), args[1].AsString(), env));
- }
-
- class CTextSubAvisynthFilter : public CTextSubFilter, public CAvisynthFilter
- {
- public:
- CTextSubAvisynthFilter(PClip c, IScriptEnvironment* env, const char* fn, int CharSet = DEFAULT_CHARSET, float fps = -1, VFRTranslator *vfr = 0) //vfr patch
- : CTextSubFilter(CString(fn), CharSet, fps)
- , CAvisynthFilter(c, env, vfr) {
- if (!m_pSubPicProvider)
- env->ThrowError("TextSub: Can't open \"%s\"", fn);
- }
- };
-
- AVSValue __cdecl TextSubCreateGeneral(AVSValue args, void* user_data, IScriptEnvironment* env)
- {
- if (!args[1].Defined())
- env->ThrowError("TextSub: You must specify a subtitle file to use");
- VFRTranslator *vfr = 0;
- if (args[4].Defined()) {
- vfr = GetVFRTranslator(args[4].AsString());
- }
-
- return (DNew CTextSubAvisynthFilter(
- args[0].AsClip(),
- env,
- args[1].AsString(),
- args[2].AsInt(DEFAULT_CHARSET),
- (float)args[3].AsFloat(-1),
- vfr));
- }
-
- AVSValue __cdecl TextSubSwapUV(AVSValue args, void* user_data, IScriptEnvironment* env)
- {
- s_fSwapUV = args[0].AsBool(false);
- return AVSValue();
- }
-
- AVSValue __cdecl MaskSubCreate(AVSValue args, void* user_data, IScriptEnvironment* env)/*SIIFI*/
- {
- if (!args[0].Defined())
- env->ThrowError("MaskSub: You must specify a subtitle file to use");
- if (!args[3].Defined() && !args[6].Defined())
- env->ThrowError("MaskSub: You must specify either FPS or a VFR timecodes file");
- VFRTranslator *vfr = 0;
- if (args[6].Defined()) {
- vfr = GetVFRTranslator(args[6].AsString());
- }
-
- AVSValue rgb32("RGB32");
- AVSValue fps(args[3].AsFloat(25));
- AVSValue tab[6] = {
- args[1],
- args[2],
- args[3],
- args[4],
- rgb32
- };
- AVSValue value(tab,5);
- const char * nom[5]= {
- "width",
- "height",
- "fps",
- "length",
- "pixel_type"
- };
- AVSValue clip(env->Invoke("Blackness",value,nom));
- env->SetVar(env->SaveString("RGBA"),true);
- //return (DNew CTextSubAvisynthFilter(clip.AsClip(), env, args[0].AsString()));
- return (DNew CTextSubAvisynthFilter(
- clip.AsClip(),
- env,
- args[0].AsString(),
- args[5].AsInt(DEFAULT_CHARSET),
- (float)args[3].AsFloat(-1),
- vfr));
- }
-
- extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScriptEnvironment* env)
- {
- env->AddFunction("VobSub", "cs", VobSubCreateS, 0);
- env->AddFunction("TextSub", "c[file]s[charset]i[fps]f[vfr]s", TextSubCreateGeneral, 0);
- env->AddFunction("TextSubSwapUV", "b", TextSubSwapUV, 0);
- env->AddFunction("MaskSub", "[file]s[width]i[height]i[fps]f[length]i[charset]i[vfr]s", MaskSubCreate, 0);
- env->SetVar(env->SaveString("RGBA"),false);
- return NULL;
- }
- }
+ static bool s_fSwapUV = false;
+
+ class CAvisynthFilter : public GenericVideoFilter, virtual public CFilter
+ {
+ public:
+ VFRTranslator* vfr;
+
+ CAvisynthFilter(PClip c, IScriptEnvironment* env, VFRTranslator* _vfr = 0) : GenericVideoFilter(c), vfr(_vfr) {}
+
+ PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) {
+ PVideoFrame frame = child->GetFrame(n, env);
+
+ env->MakeWritable(&frame);
+
+ SubPicDesc dst;
+ dst.w = vi.width;
+ dst.h = vi.height;
+ dst.pitch = frame->GetPitch();
+ dst.pitchUV = frame->GetPitch(PLANAR_U);
+ dst.bits = (void**)frame->GetWritePtr();
+ dst.bitsU = frame->GetWritePtr(PLANAR_U);
+ dst.bitsV = frame->GetWritePtr(PLANAR_V);
+ dst.bpp = dst.pitch / dst.w * 8; //vi.BitsPerPixel();
+ dst.type =
+ vi.IsRGB32() ? (env->GetVar("RGBA").AsBool() ? MSP_RGBA : MSP_RGB32) :
+ vi.IsRGB24() ? MSP_RGB24 :
+ vi.IsYUY2() ? MSP_YUY2 :
+ /*vi.IsYV12()*/ vi.pixel_type == VideoInfo::CS_YV12 ? (s_fSwapUV ? MSP_IYUV : MSP_YV12) :
+ /*vi.IsIYUV()*/ vi.pixel_type == VideoInfo::CS_IYUV ? (s_fSwapUV ? MSP_YV12 : MSP_IYUV) :
+ -1;
+
+ float fps = m_fps > 0 ? m_fps : (float)vi.fps_numerator / vi.fps_denominator;
+
+ REFERENCE_TIME timestamp;
+
+ if (!vfr) {
+ timestamp = (REFERENCE_TIME)(10000000i64 * n / fps);
+ } else {
+ timestamp = (REFERENCE_TIME)(10000000 * vfr->TimeStampFromFrameNumber(n));
+ }
+
+ Render(dst, timestamp, fps);
+
+ return frame;
+ }
+ };
+
+ class CVobSubAvisynthFilter : public CVobSubFilter, public CAvisynthFilter
+ {
+ public:
+ CVobSubAvisynthFilter(PClip c, const char* fn, IScriptEnvironment* env)
+ : CVobSubFilter(CString(fn))
+ , CAvisynthFilter(c, env) {
+ if (!m_pSubPicProvider) {
+ env->ThrowError("VobSub: Can't open \"%s\"", fn);
+ }
+ }
+ };
+
+ AVSValue __cdecl VobSubCreateS(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ return (DNew CVobSubAvisynthFilter(args[0].AsClip(), args[1].AsString(), env));
+ }
+
+ class CTextSubAvisynthFilter : public CTextSubFilter, public CAvisynthFilter
+ {
+ public:
+ CTextSubAvisynthFilter(PClip c, IScriptEnvironment* env, const char* fn, int CharSet = DEFAULT_CHARSET, float fps = -1, VFRTranslator* vfr = 0) //vfr patch
+ : CTextSubFilter(CString(fn), CharSet, fps)
+ , CAvisynthFilter(c, env, vfr) {
+ if (!m_pSubPicProvider) {
+ env->ThrowError("TextSub: Can't open \"%s\"", fn);
+ }
+ }
+ };
+
+ AVSValue __cdecl TextSubCreateGeneral(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ if (!args[1].Defined()) {
+ env->ThrowError("TextSub: You must specify a subtitle file to use");
+ }
+ VFRTranslator* vfr = 0;
+ if (args[4].Defined()) {
+ vfr = GetVFRTranslator(args[4].AsString());
+ }
+
+ return (DNew CTextSubAvisynthFilter(
+ args[0].AsClip(),
+ env,
+ args[1].AsString(),
+ args[2].AsInt(DEFAULT_CHARSET),
+ (float)args[3].AsFloat(-1),
+ vfr));
+ }
+
+ AVSValue __cdecl TextSubSwapUV(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ s_fSwapUV = args[0].AsBool(false);
+ return AVSValue();
+ }
+
+ AVSValue __cdecl MaskSubCreate(AVSValue args, void* user_data, IScriptEnvironment* env)/*SIIFI*/
+ {
+ if (!args[0].Defined()) {
+ env->ThrowError("MaskSub: You must specify a subtitle file to use");
+ }
+ if (!args[3].Defined() && !args[6].Defined()) {
+ env->ThrowError("MaskSub: You must specify either FPS or a VFR timecodes file");
+ }
+ VFRTranslator* vfr = 0;
+ if (args[6].Defined()) {
+ vfr = GetVFRTranslator(args[6].AsString());
+ }
+
+ AVSValue rgb32("RGB32");
+ AVSValue fps(args[3].AsFloat(25));
+ AVSValue tab[6] = {
+ args[1],
+ args[2],
+ args[3],
+ args[4],
+ rgb32
+ };
+ AVSValue value(tab, 5);
+ const char* nom[5] = {
+ "width",
+ "height",
+ "fps",
+ "length",
+ "pixel_type"
+ };
+ AVSValue clip(env->Invoke("Blackness", value, nom));
+ env->SetVar(env->SaveString("RGBA"), true);
+ //return (DNew CTextSubAvisynthFilter(clip.AsClip(), env, args[0].AsString()));
+ return (DNew CTextSubAvisynthFilter(
+ clip.AsClip(),
+ env,
+ args[0].AsString(),
+ args[5].AsInt(DEFAULT_CHARSET),
+ (float)args[3].AsFloat(-1),
+ vfr));
+ }
+
+ extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScriptEnvironment* env)
+ {
+ env->AddFunction("VobSub", "cs", VobSubCreateS, 0);
+ env->AddFunction("TextSub", "c[file]s[charset]i[fps]f[vfr]s", TextSubCreateGeneral, 0);
+ env->AddFunction("TextSubSwapUV", "b", TextSubSwapUV, 0);
+ env->AddFunction("MaskSub", "[file]s[width]i[height]i[fps]f[length]i[charset]i[vfr]s", MaskSubCreate, 0);
+ env->SetVar(env->SaveString("RGBA"), false);
+ return NULL;
+ }
+ }
}
UINT_PTR CALLBACK OpenHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
- switch (uiMsg) {
- case WM_NOTIFY: {
- OPENFILENAME* ofn = ((OFNOTIFY *)lParam)->lpOFN;
+ switch (uiMsg) {
+ case WM_NOTIFY: {
+ OPENFILENAME* ofn = ((OFNOTIFY*)lParam)->lpOFN;
- if (((NMHDR *)lParam)->code == CDN_FILEOK) {
- ofn->lCustData = (LPARAM)CharSetList[SendMessage(GetDlgItem(hDlg, IDC_COMBO1), CB_GETCURSEL, 0, 0)];
- }
+ if (((NMHDR*)lParam)->code == CDN_FILEOK) {
+ ofn->lCustData = (LPARAM)CharSetList[SendMessage(GetDlgItem(hDlg, IDC_COMBO1), CB_GETCURSEL, 0, 0)];
+ }
- break;
- }
+ break;
+ }
- case WM_INITDIALOG: {
- SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam);
+ case WM_INITDIALOG: {
+ SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam);
- for (ptrdiff_t i = 0; i < CharSetLen; i++) {
- CString s;
- s.Format(_T("%s (%d)"), CharSetNames[i], CharSetList[i]);
- SendMessage(GetDlgItem(hDlg, IDC_COMBO1), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)s);
- if (CharSetList[i] == (int)((OPENFILENAME*)lParam)->lCustData) {
- SendMessage(GetDlgItem(hDlg, IDC_COMBO1), CB_SETCURSEL, i, 0);
- }
- }
+ for (ptrdiff_t i = 0; i < CharSetLen; i++) {
+ CString s;
+ s.Format(_T("%s (%d)"), CharSetNames[i], CharSetList[i]);
+ SendMessage(GetDlgItem(hDlg, IDC_COMBO1), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)s);
+ if (CharSetList[i] == (int)((OPENFILENAME*)lParam)->lCustData) {
+ SendMessage(GetDlgItem(hDlg, IDC_COMBO1), CB_SETCURSEL, i, 0);
+ }
+ }
- break;
- }
+ break;
+ }
- default:
- break;
- }
+ default:
+ break;
+ }
- return FALSE;
+ return FALSE;
}
diff --git a/src/filters/transform/VSFilter/vfr.cpp b/src/filters/transform/VSFilter/vfr.cpp
index 10d68237e..000bd8dee 100644
--- a/src/filters/transform/VSFilter/vfr.cpp
+++ b/src/filters/transform/VSFilter/vfr.cpp
@@ -35,154 +35,154 @@
class TimecodesV1 : public VFRTranslator
{
private:
- // Used when sections run out
- double default_spf;
- double first_non_section_timestamp;
- int first_non_section_frame;
-
- // Also generate sections for unspecified ones
- // (use the default framerate then)
- struct FrameRateSection {
- double start_time;
- double spf;
- int start_frame;
- int end_frame;
- };
- std::vector<FrameRateSection> sections;
+ // Used when sections run out
+ double default_spf;
+ double first_non_section_timestamp;
+ int first_non_section_frame;
+
+ // Also generate sections for unspecified ones
+ // (use the default framerate then)
+ struct FrameRateSection {
+ double start_time;
+ double spf;
+ int start_frame;
+ int end_frame;
+ };
+ std::vector<FrameRateSection> sections;
public:
- virtual double TimeStampFromFrameNumber(int n) {
- // Find correct section
- for (size_t i = 0; i < sections.size(); i++) {
- FrameRateSection &sect = sections[i];
- if (n >= sect.start_frame && n <= sect.end_frame) {
- return sect.start_time + (n - sect.start_frame) * sect.spf;
- }
- }
- // Not in a section
- if (n < 0) {
- return 0.0;
- }
- return first_non_section_timestamp + (n - first_non_section_frame) * default_spf;
- }
-
- TimecodesV1(FILE *vfrfile) {
- char buf[100];
-
- default_spf = -1;
- double cur_time = 0.0;
-
- FrameRateSection temp_section;
- temp_section.start_time = 0.0;
- temp_section.spf = -1;
- temp_section.start_frame = 0;
- temp_section.end_frame = 0;
-
- while (fgets(buf, 100, vfrfile)) {
- // Comment?
- if (buf[0] == '#') {
- continue;
- }
-
- if (_strnicmp(buf, "Assume ", 7) == 0 && default_spf < 0) {
- char *num = buf+7;
- default_spf = atof(num);
- if (default_spf > 0) {
- default_spf = 1 / default_spf;
- } else {
- default_spf = -1;
- }
- temp_section.spf = default_spf;
- continue;
- }
-
- int start_frame, end_frame;
- float fps;
- if (sscanf_s(buf, "%d,%d,%f", &start_frame, &end_frame, &fps) == 3) {
- // Finish the current temp section
- temp_section.end_frame = start_frame - 1;
- if (temp_section.end_frame >= temp_section.start_frame) {
- cur_time += (temp_section.end_frame - temp_section.start_frame + 1) * temp_section.spf;
- sections.push_back(temp_section);
- }
- // Insert the section corresponding to this line
- temp_section.spf = 1/fps;
- temp_section.start_frame = start_frame;
- temp_section.end_frame = end_frame;
- temp_section.start_time = cur_time;
- cur_time += (end_frame - start_frame + 1) / fps;
- sections.push_back(temp_section);
- // Begin new temp section
- temp_section.spf = default_spf;
- temp_section.start_frame = end_frame + 1;
- temp_section.end_frame = end_frame; // yes, negative duration
- temp_section.start_time = cur_time;
- }
- }
-
- first_non_section_timestamp = cur_time;
- first_non_section_frame = temp_section.start_frame;
- }
+ virtual double TimeStampFromFrameNumber(int n) {
+ // Find correct section
+ for (size_t i = 0; i < sections.size(); i++) {
+ FrameRateSection& sect = sections[i];
+ if (n >= sect.start_frame && n <= sect.end_frame) {
+ return sect.start_time + (n - sect.start_frame) * sect.spf;
+ }
+ }
+ // Not in a section
+ if (n < 0) {
+ return 0.0;
+ }
+ return first_non_section_timestamp + (n - first_non_section_frame) * default_spf;
+ }
+
+ TimecodesV1(FILE* vfrfile) {
+ char buf[100];
+
+ default_spf = -1;
+ double cur_time = 0.0;
+
+ FrameRateSection temp_section;
+ temp_section.start_time = 0.0;
+ temp_section.spf = -1;
+ temp_section.start_frame = 0;
+ temp_section.end_frame = 0;
+
+ while (fgets(buf, 100, vfrfile)) {
+ // Comment?
+ if (buf[0] == '#') {
+ continue;
+ }
+
+ if (_strnicmp(buf, "Assume ", 7) == 0 && default_spf < 0) {
+ char* num = buf + 7;
+ default_spf = atof(num);
+ if (default_spf > 0) {
+ default_spf = 1 / default_spf;
+ } else {
+ default_spf = -1;
+ }
+ temp_section.spf = default_spf;
+ continue;
+ }
+
+ int start_frame, end_frame;
+ float fps;
+ if (sscanf_s(buf, "%d,%d,%f", &start_frame, &end_frame, &fps) == 3) {
+ // Finish the current temp section
+ temp_section.end_frame = start_frame - 1;
+ if (temp_section.end_frame >= temp_section.start_frame) {
+ cur_time += (temp_section.end_frame - temp_section.start_frame + 1) * temp_section.spf;
+ sections.push_back(temp_section);
+ }
+ // Insert the section corresponding to this line
+ temp_section.spf = 1 / fps;
+ temp_section.start_frame = start_frame;
+ temp_section.end_frame = end_frame;
+ temp_section.start_time = cur_time;
+ cur_time += (end_frame - start_frame + 1) / fps;
+ sections.push_back(temp_section);
+ // Begin new temp section
+ temp_section.spf = default_spf;
+ temp_section.start_frame = end_frame + 1;
+ temp_section.end_frame = end_frame; // yes, negative duration
+ temp_section.start_time = cur_time;
+ }
+ }
+
+ first_non_section_timestamp = cur_time;
+ first_non_section_frame = temp_section.start_frame;
+ }
};
class TimecodesV2 : public VFRTranslator
{
private:
- // Main data
- std::vector<double> timestamps;
- // For when data are exhausted (well, they shouldn't, then the vfr file is bad)
- int last_known_frame;
- double last_known_timestamp;
- double assumed_spf;
+ // Main data
+ std::vector<double> timestamps;
+ // For when data are exhausted (well, they shouldn't, then the vfr file is bad)
+ int last_known_frame;
+ double last_known_timestamp;
+ double assumed_spf;
public:
- virtual double TimeStampFromFrameNumber(int n) {
- if (n < (int)timestamps.size() && n >= 0) {
- return timestamps[n];
- }
- if (n < 0) {
- return 0.0;
- }
- return last_known_timestamp + (n - last_known_frame) * assumed_spf;
- }
-
- TimecodesV2(FILE *vfrfile) {
- char buf[50];
-
- timestamps.reserve(8192); // should be enough for most cases
-
- while (fgets(buf, 50, vfrfile)) {
- // Comment?
- if (buf[0] == '#') {
- continue;
- }
- // Otherwise assume it's a good timestamp
- timestamps.push_back(atof(buf)/1000);
- }
-
- last_known_frame = (int)timestamps.size()-1;
- last_known_timestamp = timestamps[last_known_frame];
- assumed_spf = last_known_timestamp - timestamps[last_known_frame - 1];
- }
+ virtual double TimeStampFromFrameNumber(int n) {
+ if (n < (int)timestamps.size() && n >= 0) {
+ return timestamps[n];
+ }
+ if (n < 0) {
+ return 0.0;
+ }
+ return last_known_timestamp + (n - last_known_frame) * assumed_spf;
+ }
+
+ TimecodesV2(FILE* vfrfile) {
+ char buf[50];
+
+ timestamps.reserve(8192); // should be enough for most cases
+
+ while (fgets(buf, 50, vfrfile)) {
+ // Comment?
+ if (buf[0] == '#') {
+ continue;
+ }
+ // Otherwise assume it's a good timestamp
+ timestamps.push_back(atof(buf) / 1000);
+ }
+
+ last_known_frame = (int)timestamps.size() - 1;
+ last_known_timestamp = timestamps[last_known_frame];
+ assumed_spf = last_known_timestamp - timestamps[last_known_frame - 1];
+ }
};
-VFRTranslator *GetVFRTranslator(const char *vfrfile)
+VFRTranslator* GetVFRTranslator(const char* vfrfile)
{
- char buf[32];
- buf[19] = 0; // In "# timecode format v1" the version number is character index 19
- FILE *f;
- fopen_s(&f, vfrfile, "r"); // errno_t err = <-- TODO: Check if fopen_s fails
- VFRTranslator *res = 0;
- if (fgets(buf, 32, f) && buf[0] == '#') {
- // So do some really shoddy parsing here, assume the file is good
- if (buf[19] == '1') {
- res = DNew TimecodesV1(f);
- } else if (buf[19] == '2') {
- res = DNew TimecodesV2(f);
- }
- }
- fclose(f);
- return res;
+ char buf[32];
+ buf[19] = 0; // In "# timecode format v1" the version number is character index 19
+ FILE* f;
+ fopen_s(&f, vfrfile, "r"); // errno_t err = <-- TODO: Check if fopen_s fails
+ VFRTranslator* res = 0;
+ if (fgets(buf, 32, f) && buf[0] == '#') {
+ // So do some really shoddy parsing here, assume the file is good
+ if (buf[19] == '1') {
+ res = DNew TimecodesV1(f);
+ } else if (buf[19] == '2') {
+ res = DNew TimecodesV2(f);
+ }
+ }
+ fclose(f);
+ return res;
}
diff --git a/src/filters/transform/VSFilter/vfr.h b/src/filters/transform/VSFilter/vfr.h
index 84c0a4ef7..4de46e30d 100644
--- a/src/filters/transform/VSFilter/vfr.h
+++ b/src/filters/transform/VSFilter/vfr.h
@@ -29,9 +29,9 @@
class VFRTranslator
{
public:
- virtual double TimeStampFromFrameNumber(int n) = 0;
+ virtual double TimeStampFromFrameNumber(int n) = 0;
};
-VFRTranslator *GetVFRTranslator(const char *vfrfile);
+VFRTranslator* GetVFRTranslator(const char* vfrfile);
#endif
diff --git a/src/mpc-hc/AboutDlg.cpp b/src/mpc-hc/AboutDlg.cpp
index fcc6ed7c2..94d007c14 100644
--- a/src/mpc-hc/AboutDlg.cpp
+++ b/src/mpc-hc/AboutDlg.cpp
@@ -29,45 +29,45 @@
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
-extern "C" char *GetFFmpegCompiler();
+extern "C" char* GetFFmpegCompiler();
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD), m_appname(_T(""))
- , m_strBuildNumber(_T(""))
- , m_MPCCompiler(_T(""))
- , m_FFmpegCompiler(_T(""))
+ , m_strBuildNumber(_T(""))
+ , m_MPCCompiler(_T(""))
+ , m_FFmpegCompiler(_T(""))
{
- //{{AFX_DATA_INIT(CAboutDlg)
- //}}AFX_DATA_INIT
+ //{{AFX_DATA_INIT(CAboutDlg)
+ //}}AFX_DATA_INIT
}
BOOL CAboutDlg::OnInitDialog()
{
- UpdateData();
+ UpdateData();
#ifdef _WIN64
- m_appname += _T(" (64-bit)");
+ m_appname += _T(" (64-bit)");
#endif
- m_strBuildNumber = AfxGetMyApp()->m_strVersion;
+ m_strBuildNumber = AfxGetMyApp()->m_strVersion;
#if defined(__INTEL_COMPILER)
#if (__INTEL_COMPILER >= 1210)
- m_MPCCompiler = _T("ICL ");
- m_MPCCompiler += MAKE_STR(__INTEL_COMPILER);
+ m_MPCCompiler = _T("ICL ");
+ m_MPCCompiler += MAKE_STR(__INTEL_COMPILER);
#else
- #error Compiler is not supported!
+#error Compiler is not supported!
#endif
#elif defined(_MSC_VER)
#if (_MSC_VER == 1700)
- m_MPCCompiler = _T("MSVC 2012");
+ m_MPCCompiler = _T("MSVC 2012");
#elif (_MSC_VER == 1600)
- #if (_MSC_FULL_VER >= 160040219)
- m_MPCCompiler = _T("MSVC 2010 SP1");
- #else
- m_MPCCompiler = _T("MSVC 2010");
- #endif
+#if (_MSC_FULL_VER >= 160040219)
+ m_MPCCompiler = _T("MSVC 2010 SP1");
+#else
+ m_MPCCompiler = _T("MSVC 2010");
+#endif
#elif (_MSC_VER < 1600)
- #error Compiler is not supported!
+#error Compiler is not supported!
#endif
#else
#error Please add support for your compiler
@@ -75,66 +75,66 @@ BOOL CAboutDlg::OnInitDialog()
#if !defined(_M_X64) && defined(_M_IX86_FP)
#if (_M_IX86_FP == 1) // /arch:SSE was used
- m_MPCCompiler += _T(" (SSE)");
+ m_MPCCompiler += _T(" (SSE)");
#elif (_M_IX86_FP == 2) // /arch:SSE2 was used
- m_MPCCompiler += _T(" (SSE2)");
+ m_MPCCompiler += _T(" (SSE2)");
#endif
#endif // _M_IX86_FP
#ifdef _DEBUG
- m_MPCCompiler += _T(" Debug");
+ m_MPCCompiler += _T(" Debug");
#endif
#if HAS_FFMPEG
- m_FFmpegCompiler.Format(CA2W(GetFFmpegCompiler()));
+ m_FFmpegCompiler.Format(CA2W(GetFFmpegCompiler()));
#endif
- // Build the path to Authors.txt
- GetModuleFileName(AfxGetInstanceHandle(), m_AuthorsPath.GetBuffer(_MAX_PATH), _MAX_PATH);
- m_AuthorsPath.ReleaseBuffer();
- m_AuthorsPath = m_AuthorsPath.Left(m_AuthorsPath.ReverseFind('\\') + 1) + _T("Authors.txt");
- // Check if the file exists
- CFileStatus fs;
- if (CFile::GetStatus(m_AuthorsPath, fs)) {
- // If it does, we make the filename clickable
- m_Credits.Replace(_T("Authors.txt"), _T("<a>Authors.txt</a>"));
- }
+ // Build the path to Authors.txt
+ GetModuleFileName(AfxGetInstanceHandle(), m_AuthorsPath.GetBuffer(_MAX_PATH), _MAX_PATH);
+ m_AuthorsPath.ReleaseBuffer();
+ m_AuthorsPath = m_AuthorsPath.Left(m_AuthorsPath.ReverseFind('\\') + 1) + _T("Authors.txt");
+ // Check if the file exists
+ CFileStatus fs;
+ if (CFile::GetStatus(m_AuthorsPath, fs)) {
+ // If it does, we make the filename clickable
+ m_Credits.Replace(_T("Authors.txt"), _T("<a>Authors.txt</a>"));
+ }
- UpdateData(FALSE);
+ UpdateData(FALSE);
- GetDlgItem(IDOK)->SetFocus();
+ GetDlgItem(IDOK)->SetFocus();
- return FALSE;
+ return FALSE;
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAboutDlg)
- //}}AFX_DATA_MAP
- DDX_Text(pDX, IDC_STATIC1, m_appname);
- DDX_Text(pDX, IDC_BUILD_NUMBER, m_strBuildNumber);
- DDX_Text(pDX, IDC_MPC_COMPILER, m_MPCCompiler);
- DDX_Text(pDX, IDC_FFMPEG_COMPILER, m_FFmpegCompiler);
- DDX_Text(pDX, IDC_AUTHORS_LINK, m_Credits);
+ CDialog::DoDataExchange(pDX);
+ //{{AFX_DATA_MAP(CAboutDlg)
+ //}}AFX_DATA_MAP
+ DDX_Text(pDX, IDC_STATIC1, m_appname);
+ DDX_Text(pDX, IDC_BUILD_NUMBER, m_strBuildNumber);
+ DDX_Text(pDX, IDC_MPC_COMPILER, m_MPCCompiler);
+ DDX_Text(pDX, IDC_FFMPEG_COMPILER, m_FFmpegCompiler);
+ DDX_Text(pDX, IDC_AUTHORS_LINK, m_Credits);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- //{{AFX_MSG_MAP(CAboutDlg)
- // No message handlers
- //}}AFX_MSG_MAP
- ON_NOTIFY(NM_CLICK, IDC_HOMEPAGE_LINK, OnHomepage)
- ON_NOTIFY(NM_CLICK, IDC_AUTHORS_LINK, OnAuthors)
+ //{{AFX_MSG_MAP(CAboutDlg)
+ // No message handlers
+ //}}AFX_MSG_MAP
+ ON_NOTIFY(NM_CLICK, IDC_HOMEPAGE_LINK, OnHomepage)
+ ON_NOTIFY(NM_CLICK, IDC_AUTHORS_LINK, OnAuthors)
END_MESSAGE_MAP()
-void CAboutDlg::OnHomepage(NMHDR *pNMHDR, LRESULT *pResult)
+void CAboutDlg::OnHomepage(NMHDR* pNMHDR, LRESULT* pResult)
{
- ShellExecute(m_hWnd, _T("open"), _T("http://mpc-hc.sourceforge.net/"), NULL, NULL, SW_SHOWDEFAULT);
- *pResult = 0;
+ ShellExecute(m_hWnd, _T("open"), _T("http://mpc-hc.sourceforge.net/"), NULL, NULL, SW_SHOWDEFAULT);
+ *pResult = 0;
}
-void CAboutDlg::OnAuthors(NMHDR *pNMHDR, LRESULT *pResult)
+void CAboutDlg::OnAuthors(NMHDR* pNMHDR, LRESULT* pResult)
{
- ShellExecute(m_hWnd, _T("open"), m_AuthorsPath, NULL, NULL, SW_SHOWDEFAULT);
- *pResult = 0;
+ ShellExecute(m_hWnd, _T("open"), m_AuthorsPath, NULL, NULL, SW_SHOWDEFAULT);
+ *pResult = 0;
}
diff --git a/src/mpc-hc/AboutDlg.h b/src/mpc-hc/AboutDlg.h
index 3948563b6..5bcab48c2 100644
--- a/src/mpc-hc/AboutDlg.h
+++ b/src/mpc-hc/AboutDlg.h
@@ -27,36 +27,36 @@
class CAboutDlg : public CDialog
{
- CString m_appname;
- CString m_strBuildNumber;
- CString m_MPCCompiler;
- CString m_FFmpegCompiler;
- CString m_Credits;
- CString m_AuthorsPath;
+ CString m_appname;
+ CString m_strBuildNumber;
+ CString m_MPCCompiler;
+ CString m_FFmpegCompiler;
+ CString m_Credits;
+ CString m_AuthorsPath;
public:
- CAboutDlg();
+ CAboutDlg();
- virtual BOOL OnInitDialog();
+ virtual BOOL OnInitDialog();
- afx_msg void OnHomepage(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnAuthors(NMHDR *pNMHDR, LRESULT *pResult);
+ afx_msg void OnHomepage(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnAuthors(NMHDR* pNMHDR, LRESULT* pResult);
- // Dialog Data
- //{{AFX_DATA(CAboutDlg)
- enum { IDD = IDD_ABOUTBOX };
- //}}AFX_DATA
+ // Dialog Data
+ //{{AFX_DATA(CAboutDlg)
+ enum { IDD = IDD_ABOUTBOX };
+ //}}AFX_DATA
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CAboutDlg)
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CAboutDlg)
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- //}}AFX_VIRTUAL
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ //}}AFX_VIRTUAL
- // Implementation
+ // Implementation
protected:
- //{{AFX_MSG(CAboutDlg)
- // No message handlers
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
+ //{{AFX_MSG(CAboutDlg)
+ // No message handlers
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
};
diff --git a/src/mpc-hc/AppSettings.cpp b/src/mpc-hc/AppSettings.cpp
index 008dd217b..11df75d83 100644
--- a/src/mpc-hc/AppSettings.cpp
+++ b/src/mpc-hc/AppSettings.cpp
@@ -31,177 +31,177 @@
CAppSettings::CAppSettings()
- : fInitialized(false)
- , MRU(0, _T("Recent File List"), _T("File%d"), 20)
- , MRUDub(0, _T("Recent Dub List"), _T("Dub%d"), 20)
- , hAccel(NULL)
- , nCmdlnWebServerPort(-1)
- , fShowDebugInfo(false)
+ : fInitialized(false)
+ , MRU(0, _T("Recent File List"), _T("File%d"), 20)
+ , MRUDub(0, _T("Recent Dub List"), _T("Dub%d"), 20)
+ , hAccel(NULL)
+ , nCmdlnWebServerPort(-1)
+ , fShowDebugInfo(false)
{
- // Internal source filter
+ // Internal source filter
#if INTERNAL_SOURCEFILTER_CDDA
- SrcFiltersKeys[SRC_CDDA] = _T("SRC_CDDA");
+ SrcFiltersKeys[SRC_CDDA] = _T("SRC_CDDA");
#endif
#if INTERNAL_SOURCEFILTER_CDXA
- SrcFiltersKeys[SRC_CDXA] = _T("SRC_CDXA");
+ SrcFiltersKeys[SRC_CDXA] = _T("SRC_CDXA");
#endif
#if INTERNAL_SOURCEFILTER_VTS
- SrcFiltersKeys[SRC_VTS] = _T("SRC_VTS");
+ SrcFiltersKeys[SRC_VTS] = _T("SRC_VTS");
#endif
#if INTERNAL_SOURCEFILTER_FLIC
- SrcFiltersKeys[SRC_FLIC] = _T("SRC_FLIC");
+ SrcFiltersKeys[SRC_FLIC] = _T("SRC_FLIC");
#endif
#if INTERNAL_SOURCEFILTER_DVSOURCE
- SrcFiltersKeys[SRC_D2V] = _T("SRC_D2V");
+ SrcFiltersKeys[SRC_D2V] = _T("SRC_D2V");
#endif
#if INTERNAL_SOURCEFILTER_DTSAC3
- SrcFiltersKeys[SRC_DTSAC3] = _T("SRC_DTSAC3");
+ SrcFiltersKeys[SRC_DTSAC3] = _T("SRC_DTSAC3");
#endif
#if INTERNAL_SOURCEFILTER_MATROSKA
- SrcFiltersKeys[SRC_MATROSKA] = _T("SRC_MATROSKA");
+ SrcFiltersKeys[SRC_MATROSKA] = _T("SRC_MATROSKA");
#endif
#if INTERNAL_SOURCEFILTER_SHOUTCAST
- SrcFiltersKeys[SRC_SHOUTCAST] = _T("SRC_SHOUTCAST");
+ SrcFiltersKeys[SRC_SHOUTCAST] = _T("SRC_SHOUTCAST");
#endif
#if INTERNAL_SOURCEFILTER_REALMEDIA
- SrcFiltersKeys[SRC_REALMEDIA] = _T("SRC_REALMEDIA");
+ SrcFiltersKeys[SRC_REALMEDIA] = _T("SRC_REALMEDIA");
#endif
#if INTERNAL_SOURCEFILTER_AVI
- SrcFiltersKeys[SRC_AVI] = _T("SRC_AVI");
+ SrcFiltersKeys[SRC_AVI] = _T("SRC_AVI");
#endif
#if INTERNAL_SOURCEFILTER_OGG
- SrcFiltersKeys[SRC_OGG] = _T("SRC_OGG");
+ SrcFiltersKeys[SRC_OGG] = _T("SRC_OGG");
#endif
#if INTERNAL_SOURCEFILTER_MPEG
- SrcFiltersKeys[SRC_MPEG] = _T("SRC_MPEG");
+ SrcFiltersKeys[SRC_MPEG] = _T("SRC_MPEG");
#endif
#if INTERNAL_SOURCEFILTER_MPEGAUDIO
- SrcFiltersKeys[SRC_MPA] = _T("SRC_MPA");
+ SrcFiltersKeys[SRC_MPA] = _T("SRC_MPA");
#endif
#if INTERNAL_SOURCEFILTER_DSM
- SrcFiltersKeys[SRC_DSM] = _T("SRC_DSM");
+ SrcFiltersKeys[SRC_DSM] = _T("SRC_DSM");
#endif
- SrcFiltersKeys[SRC_SUBS] = _T("SRC_SUBS");
+ SrcFiltersKeys[SRC_SUBS] = _T("SRC_SUBS");
#if INTERNAL_SOURCEFILTER_MP4
- SrcFiltersKeys[SRC_MP4] = _T("SRC_MP4");
+ SrcFiltersKeys[SRC_MP4] = _T("SRC_MP4");
#endif
#if INTERNAL_SOURCEFILTER_FLV
- SrcFiltersKeys[SRC_FLV] = _T("SRC_FLV");
+ SrcFiltersKeys[SRC_FLV] = _T("SRC_FLV");
#endif
#if INTERNAL_SOURCEFILTER_FLAC
- SrcFiltersKeys[SRC_FLAC] = _T("SRC_FLAC");
+ SrcFiltersKeys[SRC_FLAC] = _T("SRC_FLAC");
#endif
- // Internal decoders
+ // Internal decoders
#if INTERNAL_DECODER_MPEG1
- TraFiltersKeys[TRA_MPEG1] = _T("TRA_MPEG1");
+ TraFiltersKeys[TRA_MPEG1] = _T("TRA_MPEG1");
#endif
#if INTERNAL_DECODER_MPEG2
- TraFiltersKeys[TRA_MPEG2] = _T("TRA_MPEG2");
+ TraFiltersKeys[TRA_MPEG2] = _T("TRA_MPEG2");
#endif
#if INTERNAL_DECODER_REALVIDEO
- TraFiltersKeys[TRA_RV] = _T("TRA_RV");
+ TraFiltersKeys[TRA_RV] = _T("TRA_RV");
#endif
#if INTERNAL_DECODER_REALAUDIO
- TraFiltersKeys[TRA_RA] = _T("TRA_RA");
+ TraFiltersKeys[TRA_RA] = _T("TRA_RA");
#endif
#if INTERNAL_DECODER_MPEGAUDIO
- TraFiltersKeys[TRA_MPA] = _T("TRA_MPA");
+ TraFiltersKeys[TRA_MPA] = _T("TRA_MPA");
#endif
#if INTERNAL_DECODER_DTS
- TraFiltersKeys[TRA_DTS] = _T("TRA_DTS");
- TraFiltersKeys[TRA_LPCM] = _T("TRA_LPCM");
+ TraFiltersKeys[TRA_DTS] = _T("TRA_DTS");
+ TraFiltersKeys[TRA_LPCM] = _T("TRA_LPCM");
#endif
#if INTERNAL_DECODER_AC3
- TraFiltersKeys[TRA_AC3] = _T("TRA_AC3");
+ TraFiltersKeys[TRA_AC3] = _T("TRA_AC3");
#endif
#if INTERNAL_DECODER_AAC
- TraFiltersKeys[TRA_AAC] = _T("TRA_AAC");
+ TraFiltersKeys[TRA_AAC] = _T("TRA_AAC");
#endif
#if INTERNAL_DECODER_ALAC
- TraFiltersKeys[TRA_ALAC] = _T("TRA_ALAC");
+ TraFiltersKeys[TRA_ALAC] = _T("TRA_ALAC");
#endif
#if INTERNAL_DECODER_ALS
- TraFiltersKeys[TRA_ALS] = _T("TRA_ALS");
+ TraFiltersKeys[TRA_ALS] = _T("TRA_ALS");
#endif
#if INTERNAL_DECODER_PS2AUDIO
- TraFiltersKeys[TRA_PS2AUD] = _T("TRA_PS2AUD");
+ TraFiltersKeys[TRA_PS2AUD] = _T("TRA_PS2AUD");
#endif
#if INTERNAL_DECODER_VORBIS
- TraFiltersKeys[TRA_VORBIS] = _T("TRA_VORBIS");
+ TraFiltersKeys[TRA_VORBIS] = _T("TRA_VORBIS");
#endif
#if INTERNAL_DECODER_FLAC
- TraFiltersKeys[TRA_FLAC] = _T("TRA_FLAC");
+ TraFiltersKeys[TRA_FLAC] = _T("TRA_FLAC");
#endif
#if INTERNAL_DECODER_NELLYMOSER
- TraFiltersKeys[TRA_NELLY] = _T("TRA_NELLY");
+ TraFiltersKeys[TRA_NELLY] = _T("TRA_NELLY");
#endif
#if INTERNAL_DECODER_AMR
- TraFiltersKeys[TRA_AMR] = _T("TRA_AMR");
+ TraFiltersKeys[TRA_AMR] = _T("TRA_AMR");
#endif
#if INTERNAL_DECODER_PCM
- TraFiltersKeys[TRA_PCM] = _T("TRA_PCM");
+ TraFiltersKeys[TRA_PCM] = _T("TRA_PCM");
#endif
- // Internal DXVA decoders
+ // Internal DXVA decoders
#if INTERNAL_DECODER_H264_DXVA
- DXVAFiltersKeys[TRA_DXVA_H264] = _T("TRA_DXVA_H264");
+ DXVAFiltersKeys[TRA_DXVA_H264] = _T("TRA_DXVA_H264");
#endif
#if INTERNAL_DECODER_VC1_DXVA
- DXVAFiltersKeys[TRA_DXVA_VC1] = _T("TRA_DXVA_VC1");
+ DXVAFiltersKeys[TRA_DXVA_VC1] = _T("TRA_DXVA_VC1");
#endif
#if INTERNAL_DECODER_WMV3_DXVA
- DXVAFiltersKeys[TRA_DXVA_WMV3] = _T("TRA_DXVA_WMV3");
+ DXVAFiltersKeys[TRA_DXVA_WMV3] = _T("TRA_DXVA_WMV3");
#endif
#if INTERNAL_DECODER_MPEG2_DXVA
- DXVAFiltersKeys[TRA_DXVA_MPEG2] = _T("TRA_DXVA_MPEG2");
+ DXVAFiltersKeys[TRA_DXVA_MPEG2] = _T("TRA_DXVA_MPEG2");
#endif
- // Internal FFMpeg decoders
+ // Internal FFMpeg decoders
#if INTERNAL_DECODER_H264
- FFMFiltersKeys[FFM_H264] = _T("FFM_H264");
+ FFMFiltersKeys[FFM_H264] = _T("FFM_H264");
#endif
#if INTERNAL_DECODER_VC1
- FFMFiltersKeys[FFM_VC1] = _T("FFM_VC1");
+ FFMFiltersKeys[FFM_VC1] = _T("FFM_VC1");
#endif
#if INTERNAL_DECODER_FLV
- FFMFiltersKeys[FFM_FLV4] = _T("FFM_FLV4");
+ FFMFiltersKeys[FFM_FLV4] = _T("FFM_FLV4");
#endif
#if INTERNAL_DECODER_VP356
- FFMFiltersKeys[FFM_VP356] = _T("FFM_VP356");
+ FFMFiltersKeys[FFM_VP356] = _T("FFM_VP356");
#endif
#if INTERNAL_DECODER_VP8
- FFMFiltersKeys[FFM_VP8] = _T("FFM_VP8");
+ FFMFiltersKeys[FFM_VP8] = _T("FFM_VP8");
#endif
#if INTERNAL_DECODER_XVID
- FFMFiltersKeys[FFM_XVID] = _T("FFM_XVID");
+ FFMFiltersKeys[FFM_XVID] = _T("FFM_XVID");
#endif
#if INTERNAL_DECODER_DIVX
- FFMFiltersKeys[FFM_DIVX] = _T("FFM_DIVX");
+ FFMFiltersKeys[FFM_DIVX] = _T("FFM_DIVX");
#endif
#if INTERNAL_DECODER_MSMPEG4
- FFMFiltersKeys[FFM_MSMPEG4] = _T("FFM_MSMPEG4");
+ FFMFiltersKeys[FFM_MSMPEG4] = _T("FFM_MSMPEG4");
#endif
#if INTERNAL_DECODER_WMV
- FFMFiltersKeys[FFM_WMV] = _T("FFM_WMV");
+ FFMFiltersKeys[FFM_WMV] = _T("FFM_WMV");
#endif
#if INTERNAL_DECODER_SVQ
- FFMFiltersKeys[FFM_SVQ3] = _T("FFM_SVQ3");
+ FFMFiltersKeys[FFM_SVQ3] = _T("FFM_SVQ3");
#endif
#if INTERNAL_DECODER_H263
- FFMFiltersKeys[FFM_H263] = _T("FFM_H263");
+ FFMFiltersKeys[FFM_H263] = _T("FFM_H263");
#endif
#if INTERNAL_DECODER_THEORA
- FFMFiltersKeys[FFM_THEORA] = _T("FFM_THEORA");
+ FFMFiltersKeys[FFM_THEORA] = _T("FFM_THEORA");
#endif
#if INTERNAL_DECODER_AMVV
- FFMFiltersKeys[FFM_AMVV] = _T("FFM_AMVV");
+ FFMFiltersKeys[FFM_AMVV] = _T("FFM_AMVV");
#endif
#if INTERNAL_DECODER_MJPEG
- FFMFiltersKeys[FFM_MJPEG] = _T("FFM_MJPEG");
+ FFMFiltersKeys[FFM_MJPEG] = _T("FFM_MJPEG");
#endif
#if INTERNAL_DECODER_INDEO
- FFMFiltersKeys[FFM_INDEO] = _T("FFM_INDEO");
+ FFMFiltersKeys[FFM_INDEO] = _T("FFM_INDEO");
#endif
}
@@ -209,1760 +209,1757 @@ CAppSettings::CAppSettings()
void CAppSettings::CreateCommands()
{
#define ADDCMD(cmd) wmcmds.AddTail(wmcmd##cmd)
- ADDCMD((ID_FILE_OPENQUICK, 'Q', FVIRTKEY|FCONTROL|FNOINVERT, IDS_MPLAYERC_0));
- ADDCMD((ID_FILE_OPENMEDIA, 'O', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_OPEN_FILE));
- ADDCMD((ID_FILE_OPENDVD, 'D', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_OPEN_DVD));
- ADDCMD((ID_FILE_OPENDEVICE, 'V', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_OPEN_DEVICE));
- ADDCMD((ID_FILE_REOPEN, 'E', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_REOPEN));
-
- ADDCMD((ID_FILE_SAVE_COPY, 0, FVIRTKEY|FNOINVERT, IDS_AG_SAVE_AS));
- ADDCMD((ID_FILE_SAVE_IMAGE, 'I', FVIRTKEY|FALT|FNOINVERT, IDS_AG_SAVE_IMAGE));
- ADDCMD((ID_FILE_SAVE_IMAGE_AUTO, VK_F5, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_6));
- ADDCMD((ID_FILE_SAVE_THUMBNAILS, 0, FVIRTKEY|FNOINVERT, IDS_FILE_SAVE_THUMBNAILS));
-
- ADDCMD((ID_FILE_LOAD_SUBTITLE, 'L', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_LOAD_SUBTITLE));
- ADDCMD((ID_FILE_SAVE_SUBTITLE, 'S', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_SAVE_SUBTITLE));
- ADDCMD((ID_FILE_CLOSEPLAYLIST, 'C', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_CLOSE));
- ADDCMD((ID_FILE_PROPERTIES, VK_F10, FVIRTKEY|FSHIFT|FNOINVERT, IDS_AG_PROPERTIES));
- ADDCMD((ID_FILE_EXIT, 'X', FVIRTKEY|FALT|FNOINVERT, IDS_AG_EXIT));
- ADDCMD((ID_PLAY_PLAYPAUSE, VK_SPACE, FVIRTKEY|FNOINVERT, IDS_AG_PLAYPAUSE, APPCOMMAND_MEDIA_PLAY_PAUSE, wmcmd::LDOWN, wmcmd::LDOWN));
- ADDCMD((ID_PLAY_PLAY, 0, FVIRTKEY|FNOINVERT, IDS_AG_PLAY, APPCOMMAND_MEDIA_PLAY));
- ADDCMD((ID_PLAY_PAUSE, 0, FVIRTKEY|FNOINVERT, IDS_AG_PAUSE, APPCOMMAND_MEDIA_PAUSE));
- ADDCMD((ID_PLAY_STOP, VK_OEM_PERIOD, FVIRTKEY|FNOINVERT, IDS_AG_STOP, APPCOMMAND_MEDIA_STOP));
- ADDCMD((ID_PLAY_FRAMESTEP, VK_RIGHT, FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_FRAMESTEP));
- ADDCMD((ID_PLAY_FRAMESTEPCANCEL, VK_LEFT, FVIRTKEY|FCONTROL|FNOINVERT, IDS_MPLAYERC_16));
- ADDCMD((ID_PLAY_GOTO, 'G', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_GO_TO));
- ADDCMD((ID_PLAY_INCRATE, VK_UP, FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_INCREASE_RATE));
- ADDCMD((ID_PLAY_DECRATE, VK_DOWN, FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_DECREASE_RATE));
- ADDCMD((ID_PLAY_RESETRATE, 'R', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_RESET_RATE));
- ADDCMD((ID_PLAY_INCAUDDELAY, VK_ADD, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_21));
- ADDCMD((ID_PLAY_DECAUDDELAY, VK_SUBTRACT, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_22));
- ADDCMD((ID_PLAY_SEEKFORWARDSMALL, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_23));
- ADDCMD((ID_PLAY_SEEKBACKWARDSMALL, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_24));
- ADDCMD((ID_PLAY_SEEKFORWARDMED, VK_RIGHT, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_25));
- ADDCMD((ID_PLAY_SEEKBACKWARDMED, VK_LEFT, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_26));
- ADDCMD((ID_PLAY_SEEKFORWARDLARGE, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_27));
- ADDCMD((ID_PLAY_SEEKBACKWARDLARGE, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_28));
- ADDCMD((ID_PLAY_SEEKKEYFORWARD, VK_RIGHT, FVIRTKEY|FSHIFT|FNOINVERT, IDS_MPLAYERC_29));
- ADDCMD((ID_PLAY_SEEKKEYBACKWARD, VK_LEFT, FVIRTKEY|FSHIFT|FNOINVERT, IDS_MPLAYERC_30));
- ADDCMD((ID_NAVIGATE_SKIPFORWARD, VK_NEXT, FVIRTKEY|FNOINVERT, IDS_AG_NEXT, APPCOMMAND_MEDIA_NEXTTRACK, wmcmd::X2DOWN, wmcmd::X2DOWN));
- ADDCMD((ID_NAVIGATE_SKIPBACK, VK_PRIOR, FVIRTKEY|FNOINVERT, IDS_AG_PREVIOUS, APPCOMMAND_MEDIA_PREVIOUSTRACK, wmcmd::X1DOWN, wmcmd::X1DOWN));
- ADDCMD((ID_NAVIGATE_SKIPFORWARDFILE, VK_NEXT, FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_NEXT_FILE));
- ADDCMD((ID_NAVIGATE_SKIPBACKFILE, VK_PRIOR, FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_PREVIOUS_FILE));
- ADDCMD((ID_NAVIGATE_TUNERSCAN, 'T', FVIRTKEY|FSHIFT|FNOINVERT, IDS_NAVIGATE_TUNERSCAN));
- ADDCMD((ID_FAVORITES_QUICKADDFAVORITE, 'Q', FVIRTKEY|FSHIFT|FNOINVERT, IDS_FAVORITES_QUICKADDFAVORITE));
- ADDCMD((ID_VIEW_CAPTIONMENU, '0', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_TOGGLE_CAPTION));
- ADDCMD((ID_VIEW_SEEKER, '1', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_TOGGLE_SEEKER));
- ADDCMD((ID_VIEW_CONTROLS, '2', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_TOGGLE_CONTROLS));
- ADDCMD((ID_VIEW_INFORMATION, '3', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_TOGGLE_INFO));
- ADDCMD((ID_VIEW_STATISTICS, '4', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_TOGGLE_STATS));
- ADDCMD((ID_VIEW_STATUS, '5', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_TOGGLE_STATUS));
- ADDCMD((ID_VIEW_SUBRESYNC, '6', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_TOGGLE_SUBRESYNC));
- ADDCMD((ID_VIEW_PLAYLIST, '7', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_TOGGLE_PLAYLIST));
- ADDCMD((ID_VIEW_CAPTURE, '8', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_TOGGLE_CAPTURE));
- ADDCMD((ID_VIEW_SHADEREDITOR, '9', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_TOGGLE_SHADER));
- ADDCMD((ID_VIEW_PRESETS_MINIMAL, '1', FVIRTKEY|FNOINVERT, IDS_AG_VIEW_MINIMAL));
- ADDCMD((ID_VIEW_PRESETS_COMPACT, '2', FVIRTKEY|FNOINVERT, IDS_AG_VIEW_COMPACT));
- ADDCMD((ID_VIEW_PRESETS_NORMAL, '3', FVIRTKEY|FNOINVERT, IDS_AG_VIEW_NORMAL));
- ADDCMD((ID_VIEW_FULLSCREEN, VK_RETURN, FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_FULLSCREEN, 0, wmcmd::LDBLCLK, wmcmd::LDBLCLK));
- ADDCMD((ID_VIEW_FULLSCREEN_SECONDARY, VK_RETURN, FVIRTKEY|FALT|FNOINVERT, IDS_MPLAYERC_39));
- ADDCMD((ID_VIEW_ZOOM_50, '1', FVIRTKEY|FALT|FNOINVERT, IDS_AG_ZOOM_50));
- ADDCMD((ID_VIEW_ZOOM_100, '2', FVIRTKEY|FALT|FNOINVERT, IDS_AG_ZOOM_100));
- ADDCMD((ID_VIEW_ZOOM_200, '3', FVIRTKEY|FALT|FNOINVERT, IDS_AG_ZOOM_200));
- ADDCMD((ID_VIEW_ZOOM_AUTOFIT, '4', FVIRTKEY|FALT|FNOINVERT, IDS_AG_ZOOM_AUTO_FIT));
- ADDCMD((ID_VIEW_ZOOM_AUTOFIT_LARGER, '5', FVIRTKEY|FALT|FNOINVERT, IDS_AG_ZOOM_AUTO_FIT_LARGER));
- ADDCMD((ID_ASPECTRATIO_NEXT, 0, FVIRTKEY|FNOINVERT, IDS_AG_NEXT_AR_PRESET));
- ADDCMD((ID_VIEW_VF_HALF, 0, FVIRTKEY|FNOINVERT, IDS_AG_VIDFRM_HALF));
- ADDCMD((ID_VIEW_VF_NORMAL, 0, FVIRTKEY|FNOINVERT, IDS_AG_VIDFRM_NORMAL));
- ADDCMD((ID_VIEW_VF_DOUBLE, 0, FVIRTKEY|FNOINVERT, IDS_AG_VIDFRM_DOUBLE));
- ADDCMD((ID_VIEW_VF_STRETCH, 0, FVIRTKEY|FNOINVERT, IDS_AG_VIDFRM_STRETCH));
- ADDCMD((ID_VIEW_VF_FROMINSIDE, 0, FVIRTKEY|FNOINVERT, IDS_AG_VIDFRM_INSIDE));
- ADDCMD((ID_VIEW_VF_ZOOM1, 0, FVIRTKEY|FNOINVERT, IDS_AG_VIDFRM_ZOOM1));
- ADDCMD((ID_VIEW_VF_ZOOM2, 0, FVIRTKEY|FNOINVERT, IDS_AG_VIDFRM_ZOOM2));
- ADDCMD((ID_VIEW_VF_FROMOUTSIDE, 0, FVIRTKEY|FNOINVERT, IDS_AG_VIDFRM_OUTSIDE));
- ADDCMD((ID_VIEW_VF_SWITCHZOOM, 'P', FVIRTKEY|FNOINVERT, IDS_AG_VIDFRM_SWITCHZOOM));
- ADDCMD((ID_ONTOP_ALWAYS, 'A', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_ALWAYS_ON_TOP));
- ADDCMD((ID_VIEW_RESET, VK_NUMPAD5, FVIRTKEY|FNOINVERT, IDS_AG_PNS_RESET));
- ADDCMD((ID_VIEW_INCSIZE, VK_NUMPAD9, FVIRTKEY|FNOINVERT, IDS_AG_PNS_INC_SIZE));
- ADDCMD((ID_VIEW_INCWIDTH, VK_NUMPAD6, FVIRTKEY|FNOINVERT, IDS_AG_PNS_INC_WIDTH));
- ADDCMD((ID_VIEW_INCHEIGHT, VK_NUMPAD8, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_47));
- ADDCMD((ID_VIEW_DECSIZE, VK_NUMPAD1, FVIRTKEY|FNOINVERT, IDS_AG_PNS_DEC_SIZE));
- ADDCMD((ID_VIEW_DECWIDTH, VK_NUMPAD4, FVIRTKEY|FNOINVERT, IDS_AG_PNS_DEC_WIDTH));
- ADDCMD((ID_VIEW_DECHEIGHT, VK_NUMPAD2, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_50));
- ADDCMD((ID_PANSCAN_CENTER, VK_NUMPAD5, FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_PNS_CENTER));
- ADDCMD((ID_PANSCAN_MOVELEFT, VK_NUMPAD4, FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_PNS_LEFT));
- ADDCMD((ID_PANSCAN_MOVERIGHT, VK_NUMPAD6, FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_PNS_RIGHT));
- ADDCMD((ID_PANSCAN_MOVEUP, VK_NUMPAD8, FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_PNS_UP));
- ADDCMD((ID_PANSCAN_MOVEDOWN, VK_NUMPAD2, FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_PNS_DOWN));
- ADDCMD((ID_PANSCAN_MOVEUPLEFT, VK_NUMPAD7, FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_PNS_UPLEFT));
- ADDCMD((ID_PANSCAN_MOVEUPRIGHT, VK_NUMPAD9, FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_PNS_UPRIGHT));
- ADDCMD((ID_PANSCAN_MOVEDOWNLEFT, VK_NUMPAD1, FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_PNS_DOWNLEFT));
- ADDCMD((ID_PANSCAN_MOVEDOWNRIGHT, VK_NUMPAD3, FVIRTKEY|FCONTROL|FNOINVERT, IDS_MPLAYERC_59));
- ADDCMD((ID_PANSCAN_ROTATEXP, VK_NUMPAD8, FVIRTKEY|FALT|FNOINVERT, IDS_AG_PNS_ROTATEX_P));
- ADDCMD((ID_PANSCAN_ROTATEXM, VK_NUMPAD2, FVIRTKEY|FALT|FNOINVERT, IDS_AG_PNS_ROTATEX_M));
- ADDCMD((ID_PANSCAN_ROTATEYP, VK_NUMPAD4, FVIRTKEY|FALT|FNOINVERT, IDS_AG_PNS_ROTATEY_P));
- ADDCMD((ID_PANSCAN_ROTATEYM, VK_NUMPAD6, FVIRTKEY|FALT|FNOINVERT, IDS_AG_PNS_ROTATEY_M));
- ADDCMD((ID_PANSCAN_ROTATEZP, VK_NUMPAD1, FVIRTKEY|FALT|FNOINVERT, IDS_AG_PNS_ROTATEZ_P));
- ADDCMD((ID_PANSCAN_ROTATEZM, VK_NUMPAD3, FVIRTKEY|FALT|FNOINVERT, IDS_AG_PNS_ROTATEZ_M));
- ADDCMD((ID_VOLUME_UP, VK_UP, FVIRTKEY|FNOINVERT, IDS_AG_VOLUME_UP, 0, wmcmd::WUP, wmcmd::WUP));
- ADDCMD((ID_VOLUME_DOWN, VK_DOWN, FVIRTKEY|FNOINVERT, IDS_AG_VOLUME_DOWN, 0, wmcmd::WDOWN, wmcmd::WDOWN));
- ADDCMD((ID_VOLUME_MUTE, 'M', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_VOLUME_MUTE, 0));
- ADDCMD((ID_VOLUME_BOOST_INC, 0, FVIRTKEY|FNOINVERT, IDS_VOLUME_BOOST_INC));
- ADDCMD((ID_VOLUME_BOOST_DEC, 0, FVIRTKEY|FNOINVERT, IDS_VOLUME_BOOST_DEC));
- ADDCMD((ID_VOLUME_BOOST_MIN, 0, FVIRTKEY|FNOINVERT, IDS_VOLUME_BOOST_MIN));
- ADDCMD((ID_VOLUME_BOOST_MAX, 0, FVIRTKEY|FNOINVERT, IDS_VOLUME_BOOST_MAX));
- ADDCMD((ID_CUSTOM_CHANNEL_MAPPING, 0, FVIRTKEY|FNOINVERT, IDS_CUSTOM_CHANNEL_MAPPING));
- ADDCMD((ID_NORMALIZE, 0, FVIRTKEY|FNOINVERT, IDS_NORMALIZE));
- ADDCMD((ID_REGAIN_VOLUME, 0, FVIRTKEY|FNOINVERT, IDS_REGAIN_VOLUME));
- ADDCMD((ID_COLOR_BRIGHTNESS_INC, 0, FVIRTKEY|FNOINVERT, IDS_BRIGHTNESS_INC));
- ADDCMD((ID_COLOR_BRIGHTNESS_DEC, 0, FVIRTKEY|FNOINVERT, IDS_BRIGHTNESS_DEC));
- ADDCMD((ID_COLOR_CONTRAST_INC, 0, FVIRTKEY|FNOINVERT, IDS_CONTRAST_INC));
- ADDCMD((ID_COLOR_CONTRAST_DEC, 0, FVIRTKEY|FNOINVERT, IDS_CONTRAST_DEC));
- //ADDCMD((ID_COLOR_HUE_INC, 0, FVIRTKEY|FNOINVERT, IDS_HUE_INC)); // nobody need this feature
- //ADDCMD((ID_COLOR_HUE_DEC, 0, FVIRTKEY|FNOINVERT, IDS_HUE_DEC)); // nobody need this feature
- ADDCMD((ID_COLOR_SATURATION_INC, 0, FVIRTKEY|FNOINVERT, IDS_SATURATION_INC));
- ADDCMD((ID_COLOR_SATURATION_DEC, 0, FVIRTKEY|FNOINVERT, IDS_SATURATION_DEC));
- ADDCMD((ID_COLOR_RESET, 0, FVIRTKEY|FNOINVERT, IDS_RESET_COLOR));
- ADDCMD((ID_NAVIGATE_TITLEMENU, 'T', FVIRTKEY|FALT|FNOINVERT, IDS_MPLAYERC_63));
- ADDCMD((ID_NAVIGATE_ROOTMENU, 'R', FVIRTKEY|FALT|FNOINVERT, IDS_AG_DVD_ROOT_MENU));
- ADDCMD((ID_NAVIGATE_SUBPICTUREMENU, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_65));
- ADDCMD((ID_NAVIGATE_AUDIOMENU, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_66));
- ADDCMD((ID_NAVIGATE_ANGLEMENU, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_67));
- ADDCMD((ID_NAVIGATE_CHAPTERMENU, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_68));
- ADDCMD((ID_NAVIGATE_MENU_LEFT, VK_LEFT, FVIRTKEY|FALT|FNOINVERT, IDS_AG_DVD_MENU_LEFT));
- ADDCMD((ID_NAVIGATE_MENU_RIGHT, VK_RIGHT, FVIRTKEY|FALT|FNOINVERT, IDS_MPLAYERC_70));
- ADDCMD((ID_NAVIGATE_MENU_UP, VK_UP, FVIRTKEY|FALT|FNOINVERT, IDS_AG_DVD_MENU_UP));
- ADDCMD((ID_NAVIGATE_MENU_DOWN, VK_DOWN, FVIRTKEY|FALT|FNOINVERT, IDS_AG_DVD_MENU_DOWN));
- ADDCMD((ID_NAVIGATE_MENU_ACTIVATE, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_73));
- ADDCMD((ID_NAVIGATE_MENU_BACK, 0, FVIRTKEY|FNOINVERT, IDS_AG_DVD_MENU_BACK));
- ADDCMD((ID_NAVIGATE_MENU_LEAVE, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_75));
- ADDCMD((ID_BOSS, 'B', FVIRTKEY|FNOINVERT, IDS_AG_BOSS_KEY));
- ADDCMD((ID_MENU_PLAYER_SHORT, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_77, 0, wmcmd::RUP, wmcmd::RUP));
- ADDCMD((ID_MENU_PLAYER_LONG, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_78));
- ADDCMD((ID_MENU_FILTERS, 0, FVIRTKEY|FNOINVERT, IDS_AG_FILTERS_MENU));
- ADDCMD((ID_VIEW_OPTIONS, 'O', FVIRTKEY|FNOINVERT, IDS_AG_OPTIONS));
- ADDCMD((ID_STREAM_AUDIO_NEXT, 'A', FVIRTKEY|FNOINVERT, IDS_AG_NEXT_AUDIO));
- ADDCMD((ID_STREAM_AUDIO_PREV, 'A', FVIRTKEY|FSHIFT|FNOINVERT, IDS_AG_PREV_AUDIO));
- ADDCMD((ID_STREAM_SUB_NEXT, 'S', FVIRTKEY|FNOINVERT, IDS_AG_NEXT_SUBTITLE));
- ADDCMD((ID_STREAM_SUB_PREV, 'S', FVIRTKEY|FSHIFT|FNOINVERT, IDS_AG_PREV_SUBTITLE));
- ADDCMD((ID_STREAM_SUB_ONOFF, 'W', FVIRTKEY|FNOINVERT, IDS_MPLAYERC_85));
- ADDCMD((ID_SUBTITLES_SUBITEM_START+2, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_86));
- ADDCMD((ID_OGM_AUDIO_NEXT, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_87));
- ADDCMD((ID_OGM_AUDIO_PREV, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_88));
- ADDCMD((ID_OGM_SUB_NEXT, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_89));
- ADDCMD((ID_OGM_SUB_PREV, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_90));
- ADDCMD((ID_DVD_ANGLE_NEXT, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_91));
- ADDCMD((ID_DVD_ANGLE_PREV, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_92));
- ADDCMD((ID_DVD_AUDIO_NEXT, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_93));
- ADDCMD((ID_DVD_AUDIO_PREV, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_94));
- ADDCMD((ID_DVD_SUB_NEXT, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_95));
- ADDCMD((ID_DVD_SUB_PREV, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_96));
- ADDCMD((ID_DVD_SUB_ONOFF, 0, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_97));
- ADDCMD((ID_VIEW_TEARING_TEST, 'T', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_TEARING_TEST));
- ADDCMD((ID_VIEW_REMAINING_TIME, 'I', FVIRTKEY|FCONTROL|FNOINVERT, IDS_MPLAYERC_98));
- ADDCMD((ID_SHADERS_TOGGLE, 'P', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AT_TOGGLE_SHADER));
- ADDCMD((ID_SHADERS_TOGGLE_SCREENSPACE, 'P', FVIRTKEY|FCONTROL|FALT|FNOINVERT, IDS_AT_TOGGLE_SHADERSCREENSPACE));
- ADDCMD((ID_D3DFULLSCREEN_TOGGLE, 'F', FVIRTKEY|FCONTROL|FNOINVERT, IDS_MPLAYERC_99));
- ADDCMD((ID_GOTO_PREV_SUB, 'Y', FVIRTKEY|FNOINVERT, IDS_MPLAYERC_100, APPCOMMAND_BROWSER_BACKWARD));
- ADDCMD((ID_GOTO_NEXT_SUB, 'U', FVIRTKEY|FNOINVERT, IDS_MPLAYERC_101, APPCOMMAND_BROWSER_FORWARD));
- ADDCMD((ID_SHIFT_SUB_DOWN, VK_NEXT, FVIRTKEY|FALT|FNOINVERT, IDS_MPLAYERC_102));
- ADDCMD((ID_SHIFT_SUB_UP, VK_PRIOR, FVIRTKEY|FALT|FNOINVERT, IDS_MPLAYERC_103));
- ADDCMD((ID_VIEW_DISPLAYSTATS, 'J', FVIRTKEY|FCONTROL|FNOINVERT, IDS_AG_DISPLAY_STATS));
- ADDCMD((ID_VIEW_RESETSTATS, 'R', FVIRTKEY|FCONTROL|FALT|FNOINVERT, IDS_AG_RESET_STATS));
- ADDCMD((ID_VIEW_VSYNC, 'V', FVIRTKEY|FNOINVERT, IDS_AG_VSYNC));
- ADDCMD((ID_VIEW_ENABLEFRAMETIMECORRECTION, 'C', FVIRTKEY|FNOINVERT, IDS_AG_ENABLEFRAMETIMECORRECTION));
- ADDCMD((ID_VIEW_VSYNCACCURATE, 'V', FVIRTKEY|FCONTROL|FALT|FNOINVERT, IDS_AG_VSYNCACCURATE));
- ADDCMD((ID_VIEW_VSYNCOFFSET_DECREASE, VK_UP, FVIRTKEY|FCONTROL|FALT|FNOINVERT, IDS_AG_VSYNCOFFSET_DECREASE));
- ADDCMD((ID_VIEW_VSYNCOFFSET_INCREASE, VK_DOWN, FVIRTKEY|FCONTROL|FALT|FNOINVERT, IDS_AG_VSYNCOFFSET_INCREASE));
- ADDCMD((ID_SUB_DELAY_DOWN, VK_F1, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_104));
- ADDCMD((ID_SUB_DELAY_UP, VK_F2, FVIRTKEY|FNOINVERT, IDS_MPLAYERC_105));
-
- ADDCMD((ID_AFTERPLAYBACK_CLOSE, 0, FVIRTKEY|FNOINVERT, IDS_AFTERPLAYBACK_CLOSE));
- ADDCMD((ID_AFTERPLAYBACK_STANDBY, 0, FVIRTKEY|FNOINVERT, IDS_AFTERPLAYBACK_STANDBY));
- ADDCMD((ID_AFTERPLAYBACK_HIBERNATE, 0, FVIRTKEY|FNOINVERT, IDS_AFTERPLAYBACK_HIBERNATE));
- ADDCMD((ID_AFTERPLAYBACK_SHUTDOWN, 0, FVIRTKEY|FNOINVERT, IDS_AFTERPLAYBACK_SHUTDOWN));
- ADDCMD((ID_AFTERPLAYBACK_LOGOFF, 0, FVIRTKEY|FNOINVERT, IDS_AFTERPLAYBACK_LOGOFF));
- ADDCMD((ID_AFTERPLAYBACK_LOCK, 0, FVIRTKEY|FNOINVERT, IDS_AFTERPLAYBACK_LOCK));
- ADDCMD((ID_AFTERPLAYBACK_EXIT, 0, FVIRTKEY|FNOINVERT, IDS_AFTERPLAYBACK_EXIT));
- ADDCMD((ID_AFTERPLAYBACK_DONOTHING, 0, FVIRTKEY|FNOINVERT, IDS_AFTERPLAYBACK_DONOTHING));
- ADDCMD((ID_AFTERPLAYBACK_NEXT, 0, FVIRTKEY|FNOINVERT, IDS_AFTERPLAYBACK_NEXT));
-
- ADDCMD((ID_VIEW_EDITLISTEDITOR, 0, FVIRTKEY|FNOINVERT, IDS_AG_TOGGLE_EDITLISTEDITOR));
- ADDCMD((ID_EDL_IN, 0, FVIRTKEY|FNOINVERT, IDS_AG_EDL_IN));
- ADDCMD((ID_EDL_OUT, 0, FVIRTKEY|FNOINVERT, IDS_AG_EDL_OUT));
- ADDCMD((ID_EDL_NEWCLIP, 0, FVIRTKEY|FNOINVERT, IDS_AG_EDL_NEW_CLIP));
- ADDCMD((ID_EDL_SAVE, 0, FVIRTKEY|FNOINVERT, IDS_AG_EDL_SAVE));
-
- ResetPositions();
+ ADDCMD((ID_FILE_OPENQUICK, 'Q', FVIRTKEY | FCONTROL | FNOINVERT, IDS_MPLAYERC_0));
+ ADDCMD((ID_FILE_OPENMEDIA, 'O', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_OPEN_FILE));
+ ADDCMD((ID_FILE_OPENDVD, 'D', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_OPEN_DVD));
+ ADDCMD((ID_FILE_OPENDEVICE, 'V', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_OPEN_DEVICE));
+ ADDCMD((ID_FILE_REOPEN, 'E', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_REOPEN));
+
+ ADDCMD((ID_FILE_SAVE_COPY, 0, FVIRTKEY | FNOINVERT, IDS_AG_SAVE_AS));
+ ADDCMD((ID_FILE_SAVE_IMAGE, 'I', FVIRTKEY | FALT | FNOINVERT, IDS_AG_SAVE_IMAGE));
+ ADDCMD((ID_FILE_SAVE_IMAGE_AUTO, VK_F5, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_6));
+ ADDCMD((ID_FILE_SAVE_THUMBNAILS, 0, FVIRTKEY | FNOINVERT, IDS_FILE_SAVE_THUMBNAILS));
+
+ ADDCMD((ID_FILE_LOAD_SUBTITLE, 'L', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_LOAD_SUBTITLE));
+ ADDCMD((ID_FILE_SAVE_SUBTITLE, 'S', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_SAVE_SUBTITLE));
+ ADDCMD((ID_FILE_CLOSEPLAYLIST, 'C', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_CLOSE));
+ ADDCMD((ID_FILE_PROPERTIES, VK_F10, FVIRTKEY | FSHIFT | FNOINVERT, IDS_AG_PROPERTIES));
+ ADDCMD((ID_FILE_EXIT, 'X', FVIRTKEY | FALT | FNOINVERT, IDS_AG_EXIT));
+ ADDCMD((ID_PLAY_PLAYPAUSE, VK_SPACE, FVIRTKEY | FNOINVERT, IDS_AG_PLAYPAUSE, APPCOMMAND_MEDIA_PLAY_PAUSE, wmcmd::LDOWN, wmcmd::LDOWN));
+ ADDCMD((ID_PLAY_PLAY, 0, FVIRTKEY | FNOINVERT, IDS_AG_PLAY, APPCOMMAND_MEDIA_PLAY));
+ ADDCMD((ID_PLAY_PAUSE, 0, FVIRTKEY | FNOINVERT, IDS_AG_PAUSE, APPCOMMAND_MEDIA_PAUSE));
+ ADDCMD((ID_PLAY_STOP, VK_OEM_PERIOD, FVIRTKEY | FNOINVERT, IDS_AG_STOP, APPCOMMAND_MEDIA_STOP));
+ ADDCMD((ID_PLAY_FRAMESTEP, VK_RIGHT, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_FRAMESTEP));
+ ADDCMD((ID_PLAY_FRAMESTEPCANCEL, VK_LEFT, FVIRTKEY | FCONTROL | FNOINVERT, IDS_MPLAYERC_16));
+ ADDCMD((ID_PLAY_GOTO, 'G', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_GO_TO));
+ ADDCMD((ID_PLAY_INCRATE, VK_UP, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_INCREASE_RATE));
+ ADDCMD((ID_PLAY_DECRATE, VK_DOWN, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_DECREASE_RATE));
+ ADDCMD((ID_PLAY_RESETRATE, 'R', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_RESET_RATE));
+ ADDCMD((ID_PLAY_INCAUDDELAY, VK_ADD, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_21));
+ ADDCMD((ID_PLAY_DECAUDDELAY, VK_SUBTRACT, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_22));
+ ADDCMD((ID_PLAY_SEEKFORWARDSMALL, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_23));
+ ADDCMD((ID_PLAY_SEEKBACKWARDSMALL, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_24));
+ ADDCMD((ID_PLAY_SEEKFORWARDMED, VK_RIGHT, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_25));
+ ADDCMD((ID_PLAY_SEEKBACKWARDMED, VK_LEFT, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_26));
+ ADDCMD((ID_PLAY_SEEKFORWARDLARGE, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_27));
+ ADDCMD((ID_PLAY_SEEKBACKWARDLARGE, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_28));
+ ADDCMD((ID_PLAY_SEEKKEYFORWARD, VK_RIGHT, FVIRTKEY | FSHIFT | FNOINVERT, IDS_MPLAYERC_29));
+ ADDCMD((ID_PLAY_SEEKKEYBACKWARD, VK_LEFT, FVIRTKEY | FSHIFT | FNOINVERT, IDS_MPLAYERC_30));
+ ADDCMD((ID_NAVIGATE_SKIPFORWARD, VK_NEXT, FVIRTKEY | FNOINVERT, IDS_AG_NEXT, APPCOMMAND_MEDIA_NEXTTRACK, wmcmd::X2DOWN, wmcmd::X2DOWN));
+ ADDCMD((ID_NAVIGATE_SKIPBACK, VK_PRIOR, FVIRTKEY | FNOINVERT, IDS_AG_PREVIOUS, APPCOMMAND_MEDIA_PREVIOUSTRACK, wmcmd::X1DOWN, wmcmd::X1DOWN));
+ ADDCMD((ID_NAVIGATE_SKIPFORWARDFILE, VK_NEXT, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_NEXT_FILE));
+ ADDCMD((ID_NAVIGATE_SKIPBACKFILE, VK_PRIOR, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PREVIOUS_FILE));
+ ADDCMD((ID_NAVIGATE_TUNERSCAN, 'T', FVIRTKEY | FSHIFT | FNOINVERT, IDS_NAVIGATE_TUNERSCAN));
+ ADDCMD((ID_FAVORITES_QUICKADDFAVORITE, 'Q', FVIRTKEY | FSHIFT | FNOINVERT, IDS_FAVORITES_QUICKADDFAVORITE));
+ ADDCMD((ID_VIEW_CAPTIONMENU, '0', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_CAPTION));
+ ADDCMD((ID_VIEW_SEEKER, '1', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_SEEKER));
+ ADDCMD((ID_VIEW_CONTROLS, '2', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_CONTROLS));
+ ADDCMD((ID_VIEW_INFORMATION, '3', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_INFO));
+ ADDCMD((ID_VIEW_STATISTICS, '4', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_STATS));
+ ADDCMD((ID_VIEW_STATUS, '5', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_STATUS));
+ ADDCMD((ID_VIEW_SUBRESYNC, '6', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_SUBRESYNC));
+ ADDCMD((ID_VIEW_PLAYLIST, '7', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_PLAYLIST));
+ ADDCMD((ID_VIEW_CAPTURE, '8', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_CAPTURE));
+ ADDCMD((ID_VIEW_SHADEREDITOR, '9', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TOGGLE_SHADER));
+ ADDCMD((ID_VIEW_PRESETS_MINIMAL, '1', FVIRTKEY | FNOINVERT, IDS_AG_VIEW_MINIMAL));
+ ADDCMD((ID_VIEW_PRESETS_COMPACT, '2', FVIRTKEY | FNOINVERT, IDS_AG_VIEW_COMPACT));
+ ADDCMD((ID_VIEW_PRESETS_NORMAL, '3', FVIRTKEY | FNOINVERT, IDS_AG_VIEW_NORMAL));
+ ADDCMD((ID_VIEW_FULLSCREEN, VK_RETURN, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_FULLSCREEN, 0, wmcmd::LDBLCLK, wmcmd::LDBLCLK));
+ ADDCMD((ID_VIEW_FULLSCREEN_SECONDARY, VK_RETURN, FVIRTKEY | FALT | FNOINVERT, IDS_MPLAYERC_39));
+ ADDCMD((ID_VIEW_ZOOM_50, '1', FVIRTKEY | FALT | FNOINVERT, IDS_AG_ZOOM_50));
+ ADDCMD((ID_VIEW_ZOOM_100, '2', FVIRTKEY | FALT | FNOINVERT, IDS_AG_ZOOM_100));
+ ADDCMD((ID_VIEW_ZOOM_200, '3', FVIRTKEY | FALT | FNOINVERT, IDS_AG_ZOOM_200));
+ ADDCMD((ID_VIEW_ZOOM_AUTOFIT, '4', FVIRTKEY | FALT | FNOINVERT, IDS_AG_ZOOM_AUTO_FIT));
+ ADDCMD((ID_VIEW_ZOOM_AUTOFIT_LARGER, '5', FVIRTKEY | FALT | FNOINVERT, IDS_AG_ZOOM_AUTO_FIT_LARGER));
+ ADDCMD((ID_ASPECTRATIO_NEXT, 0, FVIRTKEY | FNOINVERT, IDS_AG_NEXT_AR_PRESET));
+ ADDCMD((ID_VIEW_VF_HALF, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_HALF));
+ ADDCMD((ID_VIEW_VF_NORMAL, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_NORMAL));
+ ADDCMD((ID_VIEW_VF_DOUBLE, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_DOUBLE));
+ ADDCMD((ID_VIEW_VF_STRETCH, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_STRETCH));
+ ADDCMD((ID_VIEW_VF_FROMINSIDE, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_INSIDE));
+ ADDCMD((ID_VIEW_VF_ZOOM1, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_ZOOM1));
+ ADDCMD((ID_VIEW_VF_ZOOM2, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_ZOOM2));
+ ADDCMD((ID_VIEW_VF_FROMOUTSIDE, 0, FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_OUTSIDE));
+ ADDCMD((ID_VIEW_VF_SWITCHZOOM, 'P', FVIRTKEY | FNOINVERT, IDS_AG_VIDFRM_SWITCHZOOM));
+ ADDCMD((ID_ONTOP_ALWAYS, 'A', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_ALWAYS_ON_TOP));
+ ADDCMD((ID_VIEW_RESET, VK_NUMPAD5, FVIRTKEY | FNOINVERT, IDS_AG_PNS_RESET));
+ ADDCMD((ID_VIEW_INCSIZE, VK_NUMPAD9, FVIRTKEY | FNOINVERT, IDS_AG_PNS_INC_SIZE));
+ ADDCMD((ID_VIEW_INCWIDTH, VK_NUMPAD6, FVIRTKEY | FNOINVERT, IDS_AG_PNS_INC_WIDTH));
+ ADDCMD((ID_VIEW_INCHEIGHT, VK_NUMPAD8, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_47));
+ ADDCMD((ID_VIEW_DECSIZE, VK_NUMPAD1, FVIRTKEY | FNOINVERT, IDS_AG_PNS_DEC_SIZE));
+ ADDCMD((ID_VIEW_DECWIDTH, VK_NUMPAD4, FVIRTKEY | FNOINVERT, IDS_AG_PNS_DEC_WIDTH));
+ ADDCMD((ID_VIEW_DECHEIGHT, VK_NUMPAD2, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_50));
+ ADDCMD((ID_PANSCAN_CENTER, VK_NUMPAD5, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_CENTER));
+ ADDCMD((ID_PANSCAN_MOVELEFT, VK_NUMPAD4, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_LEFT));
+ ADDCMD((ID_PANSCAN_MOVERIGHT, VK_NUMPAD6, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_RIGHT));
+ ADDCMD((ID_PANSCAN_MOVEUP, VK_NUMPAD8, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_UP));
+ ADDCMD((ID_PANSCAN_MOVEDOWN, VK_NUMPAD2, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_DOWN));
+ ADDCMD((ID_PANSCAN_MOVEUPLEFT, VK_NUMPAD7, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_UPLEFT));
+ ADDCMD((ID_PANSCAN_MOVEUPRIGHT, VK_NUMPAD9, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_UPRIGHT));
+ ADDCMD((ID_PANSCAN_MOVEDOWNLEFT, VK_NUMPAD1, FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_PNS_DOWNLEFT));
+ ADDCMD((ID_PANSCAN_MOVEDOWNRIGHT, VK_NUMPAD3, FVIRTKEY | FCONTROL | FNOINVERT, IDS_MPLAYERC_59));
+ ADDCMD((ID_PANSCAN_ROTATEXP, VK_NUMPAD8, FVIRTKEY | FALT | FNOINVERT, IDS_AG_PNS_ROTATEX_P));
+ ADDCMD((ID_PANSCAN_ROTATEXM, VK_NUMPAD2, FVIRTKEY | FALT | FNOINVERT, IDS_AG_PNS_ROTATEX_M));
+ ADDCMD((ID_PANSCAN_ROTATEYP, VK_NUMPAD4, FVIRTKEY | FALT | FNOINVERT, IDS_AG_PNS_ROTATEY_P));
+ ADDCMD((ID_PANSCAN_ROTATEYM, VK_NUMPAD6, FVIRTKEY | FALT | FNOINVERT, IDS_AG_PNS_ROTATEY_M));
+ ADDCMD((ID_PANSCAN_ROTATEZP, VK_NUMPAD1, FVIRTKEY | FALT | FNOINVERT, IDS_AG_PNS_ROTATEZ_P));
+ ADDCMD((ID_PANSCAN_ROTATEZM, VK_NUMPAD3, FVIRTKEY | FALT | FNOINVERT, IDS_AG_PNS_ROTATEZ_M));
+ ADDCMD((ID_VOLUME_UP, VK_UP, FVIRTKEY | FNOINVERT, IDS_AG_VOLUME_UP, 0, wmcmd::WUP, wmcmd::WUP));
+ ADDCMD((ID_VOLUME_DOWN, VK_DOWN, FVIRTKEY | FNOINVERT, IDS_AG_VOLUME_DOWN, 0, wmcmd::WDOWN, wmcmd::WDOWN));
+ ADDCMD((ID_VOLUME_MUTE, 'M', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_VOLUME_MUTE, 0));
+ ADDCMD((ID_VOLUME_BOOST_INC, 0, FVIRTKEY | FNOINVERT, IDS_VOLUME_BOOST_INC));
+ ADDCMD((ID_VOLUME_BOOST_DEC, 0, FVIRTKEY | FNOINVERT, IDS_VOLUME_BOOST_DEC));
+ ADDCMD((ID_VOLUME_BOOST_MIN, 0, FVIRTKEY | FNOINVERT, IDS_VOLUME_BOOST_MIN));
+ ADDCMD((ID_VOLUME_BOOST_MAX, 0, FVIRTKEY | FNOINVERT, IDS_VOLUME_BOOST_MAX));
+ ADDCMD((ID_CUSTOM_CHANNEL_MAPPING, 0, FVIRTKEY | FNOINVERT, IDS_CUSTOM_CHANNEL_MAPPING));
+ ADDCMD((ID_NORMALIZE, 0, FVIRTKEY | FNOINVERT, IDS_NORMALIZE));
+ ADDCMD((ID_REGAIN_VOLUME, 0, FVIRTKEY | FNOINVERT, IDS_REGAIN_VOLUME));
+ ADDCMD((ID_COLOR_BRIGHTNESS_INC, 0, FVIRTKEY | FNOINVERT, IDS_BRIGHTNESS_INC));
+ ADDCMD((ID_COLOR_BRIGHTNESS_DEC, 0, FVIRTKEY | FNOINVERT, IDS_BRIGHTNESS_DEC));
+ ADDCMD((ID_COLOR_CONTRAST_INC, 0, FVIRTKEY | FNOINVERT, IDS_CONTRAST_INC));
+ ADDCMD((ID_COLOR_CONTRAST_DEC, 0, FVIRTKEY | FNOINVERT, IDS_CONTRAST_DEC));
+ ADDCMD((ID_COLOR_SATURATION_INC, 0, FVIRTKEY | FNOINVERT, IDS_SATURATION_INC));
+ ADDCMD((ID_COLOR_SATURATION_DEC, 0, FVIRTKEY | FNOINVERT, IDS_SATURATION_DEC));
+ ADDCMD((ID_COLOR_RESET, 0, FVIRTKEY | FNOINVERT, IDS_RESET_COLOR));
+ ADDCMD((ID_NAVIGATE_TITLEMENU, 'T', FVIRTKEY | FALT | FNOINVERT, IDS_MPLAYERC_63));
+ ADDCMD((ID_NAVIGATE_ROOTMENU, 'R', FVIRTKEY | FALT | FNOINVERT, IDS_AG_DVD_ROOT_MENU));
+ ADDCMD((ID_NAVIGATE_SUBPICTUREMENU, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_65));
+ ADDCMD((ID_NAVIGATE_AUDIOMENU, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_66));
+ ADDCMD((ID_NAVIGATE_ANGLEMENU, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_67));
+ ADDCMD((ID_NAVIGATE_CHAPTERMENU, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_68));
+ ADDCMD((ID_NAVIGATE_MENU_LEFT, VK_LEFT, FVIRTKEY | FALT | FNOINVERT, IDS_AG_DVD_MENU_LEFT));
+ ADDCMD((ID_NAVIGATE_MENU_RIGHT, VK_RIGHT, FVIRTKEY | FALT | FNOINVERT, IDS_MPLAYERC_70));
+ ADDCMD((ID_NAVIGATE_MENU_UP, VK_UP, FVIRTKEY | FALT | FNOINVERT, IDS_AG_DVD_MENU_UP));
+ ADDCMD((ID_NAVIGATE_MENU_DOWN, VK_DOWN, FVIRTKEY | FALT | FNOINVERT, IDS_AG_DVD_MENU_DOWN));
+ ADDCMD((ID_NAVIGATE_MENU_ACTIVATE, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_73));
+ ADDCMD((ID_NAVIGATE_MENU_BACK, 0, FVIRTKEY | FNOINVERT, IDS_AG_DVD_MENU_BACK));
+ ADDCMD((ID_NAVIGATE_MENU_LEAVE, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_75));
+ ADDCMD((ID_BOSS, 'B', FVIRTKEY | FNOINVERT, IDS_AG_BOSS_KEY));
+ ADDCMD((ID_MENU_PLAYER_SHORT, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_77, 0, wmcmd::RUP, wmcmd::RUP));
+ ADDCMD((ID_MENU_PLAYER_LONG, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_78));
+ ADDCMD((ID_MENU_FILTERS, 0, FVIRTKEY | FNOINVERT, IDS_AG_FILTERS_MENU));
+ ADDCMD((ID_VIEW_OPTIONS, 'O', FVIRTKEY | FNOINVERT, IDS_AG_OPTIONS));
+ ADDCMD((ID_STREAM_AUDIO_NEXT, 'A', FVIRTKEY | FNOINVERT, IDS_AG_NEXT_AUDIO));
+ ADDCMD((ID_STREAM_AUDIO_PREV, 'A', FVIRTKEY | FSHIFT | FNOINVERT, IDS_AG_PREV_AUDIO));
+ ADDCMD((ID_STREAM_SUB_NEXT, 'S', FVIRTKEY | FNOINVERT, IDS_AG_NEXT_SUBTITLE));
+ ADDCMD((ID_STREAM_SUB_PREV, 'S', FVIRTKEY | FSHIFT | FNOINVERT, IDS_AG_PREV_SUBTITLE));
+ ADDCMD((ID_STREAM_SUB_ONOFF, 'W', FVIRTKEY | FNOINVERT, IDS_MPLAYERC_85));
+ ADDCMD((ID_SUBTITLES_SUBITEM_START + 2, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_86));
+ ADDCMD((ID_OGM_AUDIO_NEXT, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_87));
+ ADDCMD((ID_OGM_AUDIO_PREV, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_88));
+ ADDCMD((ID_OGM_SUB_NEXT, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_89));
+ ADDCMD((ID_OGM_SUB_PREV, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_90));
+ ADDCMD((ID_DVD_ANGLE_NEXT, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_91));
+ ADDCMD((ID_DVD_ANGLE_PREV, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_92));
+ ADDCMD((ID_DVD_AUDIO_NEXT, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_93));
+ ADDCMD((ID_DVD_AUDIO_PREV, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_94));
+ ADDCMD((ID_DVD_SUB_NEXT, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_95));
+ ADDCMD((ID_DVD_SUB_PREV, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_96));
+ ADDCMD((ID_DVD_SUB_ONOFF, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_97));
+ ADDCMD((ID_VIEW_TEARING_TEST, 'T', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_TEARING_TEST));
+ ADDCMD((ID_VIEW_REMAINING_TIME, 'I', FVIRTKEY | FCONTROL | FNOINVERT, IDS_MPLAYERC_98));
+ ADDCMD((ID_SHADERS_TOGGLE, 'P', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AT_TOGGLE_SHADER));
+ ADDCMD((ID_SHADERS_TOGGLE_SCREENSPACE, 'P', FVIRTKEY | FCONTROL | FALT | FNOINVERT, IDS_AT_TOGGLE_SHADERSCREENSPACE));
+ ADDCMD((ID_D3DFULLSCREEN_TOGGLE, 'F', FVIRTKEY | FCONTROL | FNOINVERT, IDS_MPLAYERC_99));
+ ADDCMD((ID_GOTO_PREV_SUB, 'Y', FVIRTKEY | FNOINVERT, IDS_MPLAYERC_100, APPCOMMAND_BROWSER_BACKWARD));
+ ADDCMD((ID_GOTO_NEXT_SUB, 'U', FVIRTKEY | FNOINVERT, IDS_MPLAYERC_101, APPCOMMAND_BROWSER_FORWARD));
+ ADDCMD((ID_SHIFT_SUB_DOWN, VK_NEXT, FVIRTKEY | FALT | FNOINVERT, IDS_MPLAYERC_102));
+ ADDCMD((ID_SHIFT_SUB_UP, VK_PRIOR, FVIRTKEY | FALT | FNOINVERT, IDS_MPLAYERC_103));
+ ADDCMD((ID_VIEW_DISPLAYSTATS, 'J', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_DISPLAY_STATS));
+ ADDCMD((ID_VIEW_RESETSTATS, 'R', FVIRTKEY | FCONTROL | FALT | FNOINVERT, IDS_AG_RESET_STATS));
+ ADDCMD((ID_VIEW_VSYNC, 'V', FVIRTKEY | FNOINVERT, IDS_AG_VSYNC));
+ ADDCMD((ID_VIEW_ENABLEFRAMETIMECORRECTION, 'C', FVIRTKEY | FNOINVERT, IDS_AG_ENABLEFRAMETIMECORRECTION));
+ ADDCMD((ID_VIEW_VSYNCACCURATE, 'V', FVIRTKEY | FCONTROL | FALT | FNOINVERT, IDS_AG_VSYNCACCURATE));
+ ADDCMD((ID_VIEW_VSYNCOFFSET_DECREASE, VK_UP, FVIRTKEY | FCONTROL | FALT | FNOINVERT, IDS_AG_VSYNCOFFSET_DECREASE));
+ ADDCMD((ID_VIEW_VSYNCOFFSET_INCREASE, VK_DOWN, FVIRTKEY | FCONTROL | FALT | FNOINVERT, IDS_AG_VSYNCOFFSET_INCREASE));
+ ADDCMD((ID_SUB_DELAY_DOWN, VK_F1, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_104));
+ ADDCMD((ID_SUB_DELAY_UP, VK_F2, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_105));
+
+ ADDCMD((ID_AFTERPLAYBACK_CLOSE, 0, FVIRTKEY | FNOINVERT, IDS_AFTERPLAYBACK_CLOSE));
+ ADDCMD((ID_AFTERPLAYBACK_STANDBY, 0, FVIRTKEY | FNOINVERT, IDS_AFTERPLAYBACK_STANDBY));
+ ADDCMD((ID_AFTERPLAYBACK_HIBERNATE, 0, FVIRTKEY | FNOINVERT, IDS_AFTERPLAYBACK_HIBERNATE));
+ ADDCMD((ID_AFTERPLAYBACK_SHUTDOWN, 0, FVIRTKEY | FNOINVERT, IDS_AFTERPLAYBACK_SHUTDOWN));
+ ADDCMD((ID_AFTERPLAYBACK_LOGOFF, 0, FVIRTKEY | FNOINVERT, IDS_AFTERPLAYBACK_LOGOFF));
+ ADDCMD((ID_AFTERPLAYBACK_LOCK, 0, FVIRTKEY | FNOINVERT, IDS_AFTERPLAYBACK_LOCK));
+ ADDCMD((ID_AFTERPLAYBACK_EXIT, 0, FVIRTKEY | FNOINVERT, IDS_AFTERPLAYBACK_EXIT));
+ ADDCMD((ID_AFTERPLAYBACK_DONOTHING, 0, FVIRTKEY | FNOINVERT, IDS_AFTERPLAYBACK_DONOTHING));
+ ADDCMD((ID_AFTERPLAYBACK_NEXT, 0, FVIRTKEY | FNOINVERT, IDS_AFTERPLAYBACK_NEXT));
+
+ ADDCMD((ID_VIEW_EDITLISTEDITOR, 0, FVIRTKEY | FNOINVERT, IDS_AG_TOGGLE_EDITLISTEDITOR));
+ ADDCMD((ID_EDL_IN, 0, FVIRTKEY | FNOINVERT, IDS_AG_EDL_IN));
+ ADDCMD((ID_EDL_OUT, 0, FVIRTKEY | FNOINVERT, IDS_AG_EDL_OUT));
+ ADDCMD((ID_EDL_NEWCLIP, 0, FVIRTKEY | FNOINVERT, IDS_AG_EDL_NEW_CLIP));
+ ADDCMD((ID_EDL_SAVE, 0, FVIRTKEY | FNOINVERT, IDS_AG_EDL_SAVE));
+
+ ResetPositions();
#undef ADDCMD
}
CAppSettings::~CAppSettings()
{
- if (hAccel) {
- DestroyAcceleratorTable(hAccel);
- }
+ if (hAccel) {
+ DestroyAcceleratorTable(hAccel);
+ }
}
bool CAppSettings::IsD3DFullscreen() const
{
- if (nCLSwitches&CLSW_D3DFULLSCREEN) {
- return true;
- } else if (iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS ||
- iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
- iDSVideoRendererType == VIDRNDT_DS_MADVR ||
- iDSVideoRendererType == VIDRNDT_DS_SYNC) {
- return fD3DFullscreen;
- } else {
- return false;
- }
+ if (nCLSwitches & CLSW_D3DFULLSCREEN) {
+ return true;
+ } else if (iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS ||
+ iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
+ iDSVideoRendererType == VIDRNDT_DS_MADVR ||
+ iDSVideoRendererType == VIDRNDT_DS_SYNC) {
+ return fD3DFullscreen;
+ } else {
+ return false;
+ }
}
CString CAppSettings::SelectedAudioRenderer() const
{
- CString strResult;
- if (AfxGetMyApp()->m_AudioRendererDisplayName_CL != _T("")) {
- strResult = AfxGetMyApp()->m_AudioRendererDisplayName_CL;
- } else {
- strResult = AfxGetAppSettings().strAudioRendererDisplayName;
- }
-
- return strResult;
+ CString strResult;
+ if (AfxGetMyApp()->m_AudioRendererDisplayName_CL != _T("")) {
+ strResult = AfxGetMyApp()->m_AudioRendererDisplayName_CL;
+ } else {
+ strResult = AfxGetAppSettings().strAudioRendererDisplayName;
+ }
+
+ return strResult;
}
void CAppSettings::ResetPositions()
{
- nCurrentDvdPosition = -1;
- nCurrentFilePosition = -1;
+ nCurrentDvdPosition = -1;
+ nCurrentFilePosition = -1;
}
DVD_POSITION* CAppSettings::CurrentDVDPosition()
{
- if (nCurrentDvdPosition != -1) {
- return &DvdPosition[nCurrentDvdPosition];
- } else {
- return NULL;
- }
+ if (nCurrentDvdPosition != -1) {
+ return &DvdPosition[nCurrentDvdPosition];
+ } else {
+ return NULL;
+ }
}
bool CAppSettings::NewDvd(ULONGLONG llDVDGuid)
{
- // Look for the DVD position
- for (int i=0; i<MAX_DVD_POSITION; i++) {
- if (DvdPosition[i].llDVDGuid == llDVDGuid) {
- nCurrentDvdPosition = i;
- return false;
- }
- }
-
- // If DVD is unknown, we put it first
- for (int i=MAX_DVD_POSITION-1; i>0; i--) {
- memcpy (&DvdPosition[i], &DvdPosition[i-1], sizeof(DVD_POSITION));
- }
- DvdPosition[0].llDVDGuid = llDVDGuid;
- nCurrentDvdPosition = 0;
- return true;
+ // Look for the DVD position
+ for (int i = 0; i < MAX_DVD_POSITION; i++) {
+ if (DvdPosition[i].llDVDGuid == llDVDGuid) {
+ nCurrentDvdPosition = i;
+ return false;
+ }
+ }
+
+ // If DVD is unknown, we put it first
+ for (int i = MAX_DVD_POSITION - 1; i > 0; i--) {
+ memcpy(&DvdPosition[i], &DvdPosition[i - 1], sizeof(DVD_POSITION));
+ }
+ DvdPosition[0].llDVDGuid = llDVDGuid;
+ nCurrentDvdPosition = 0;
+ return true;
}
FILE_POSITION* CAppSettings::CurrentFilePosition()
{
- if (nCurrentFilePosition != -1) {
- return &FilePosition[nCurrentFilePosition];
- } else {
- return NULL;
- }
+ if (nCurrentFilePosition != -1) {
+ return &FilePosition[nCurrentFilePosition];
+ } else {
+ return NULL;
+ }
}
bool CAppSettings::NewFile(LPCTSTR strFileName)
{
- // Look for the file position
- for (int i=0; i<MAX_FILE_POSITION; i++) {
- if (FilePosition[i].strFile == strFileName) {
- nCurrentFilePosition = i;
- return false;
- }
- }
-
- // If it is unknown, we put it first
- for (int i=MAX_FILE_POSITION-1; i>0; i--) {
- FilePosition[i].strFile = FilePosition[i-1].strFile;
- FilePosition[i].llPosition = FilePosition[i-1].llPosition;
- }
- FilePosition[0].strFile = strFileName;
- FilePosition[0].llPosition = 0;
- nCurrentFilePosition = 0;
- return true;
+ // Look for the file position
+ for (int i = 0; i < MAX_FILE_POSITION; i++) {
+ if (FilePosition[i].strFile == strFileName) {
+ nCurrentFilePosition = i;
+ return false;
+ }
+ }
+
+ // If it is unknown, we put it first
+ for (int i = MAX_FILE_POSITION - 1; i > 0; i--) {
+ FilePosition[i].strFile = FilePosition[i - 1].strFile;
+ FilePosition[i].llPosition = FilePosition[i - 1].llPosition;
+ }
+ FilePosition[0].strFile = strFileName;
+ FilePosition[0].llPosition = 0;
+ nCurrentFilePosition = 0;
+ return true;
}
-void CAppSettings::DeserializeHex (LPCTSTR strVal, BYTE* pBuffer, int nBufSize) const
+void CAppSettings::DeserializeHex(LPCTSTR strVal, BYTE* pBuffer, int nBufSize) const
{
- long lRes;
+ long lRes;
- for (int i=0; i<nBufSize; i++) {
- _stscanf_s(strVal+(i*2), _T("%02x"), &lRes);
- pBuffer[i] = (BYTE)lRes;
- }
+ for (int i = 0; i < nBufSize; i++) {
+ _stscanf_s(strVal + (i * 2), _T("%02x"), &lRes);
+ pBuffer[i] = (BYTE)lRes;
+ }
}
-CString CAppSettings::SerializeHex (BYTE* pBuffer, int nBufSize) const
+CString CAppSettings::SerializeHex(BYTE* pBuffer, int nBufSize) const
{
- CString strTemp;
- CString strResult;
+ CString strTemp;
+ CString strResult;
- for (int i=0; i<nBufSize; i++) {
- strTemp.Format (_T("%02x"), pBuffer[i]);
- strResult += strTemp;
- }
+ for (int i = 0; i < nBufSize; i++) {
+ strTemp.Format(_T("%02x"), pBuffer[i]);
+ strResult += strTemp;
+ }
- return strResult;
+ return strResult;
}
void CAppSettings::UpdateData(bool fSave)
{
- CWinApp* pApp = AfxGetApp();
- ASSERT(pApp);
-
- UINT len;
- BYTE* ptr = NULL;
-
- if (fSave) {
- if (!fInitialized) {
- return;
- }
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_HIDECAPTIONMENU, iCaptionMenuMode);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_HIDENAVIGATION, fHideNavigation);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_CONTROLSTATE, nCS);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_DEFAULTVIDEOFRAME, iDefaultVideoSize);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_KEEPASPECTRATIO, fKeepAspectRatio);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_COMPMONDESKARDIFF, fCompMonDeskARDiff);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_VOLUME, nVolume);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_BALANCE, nBalance);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MUTE, fMute);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LOOPNUM, nLoops);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LOOP, fLoopForever);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REWIND, fRewind);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ZOOM, iZoomLevel);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MULTIINST, fAllowMultipleInst);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_TITLEBARTEXTSTYLE, iTitleBarTextStyle);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_TITLEBARTEXTTITLE, fTitleBarTextTitle);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ONTOP, iOnTop);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_TRAYICON, fTrayIcon);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOZOOM, fRememberZoomLevel);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_FULLSCREENCTRLS, fShowBarsWhenFullScreen);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_FULLSCREENCTRLSTIMEOUT, nShowBarsWhenFullScreenTimeOut);
- pApp->WriteProfileBinary(IDS_R_SETTINGS, IDS_RS_FULLSCREENRES, (BYTE*)&AutoChangeFullscrRes, sizeof(AutoChangeFullscrRes));
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_EXITFULLSCREENATTHEEND, fExitFullScreenAtTheEnd);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_RESTORERESAFTEREXIT, fRestoreResAfterExit);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REMEMBERWINDOWPOS, fRememberWindowPos);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REMEMBERWINDOWSIZE, fRememberWindowSize);
- if (fSavePnSZoom) {
- CString str;
- str.Format(_T("%.3f,%.3f"), dZoomX, dZoomY);
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_PANSCANZOOM, str);
- } else {
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_PANSCANZOOM, NULL);
- }
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SNAPTODESKTOPEDGES, fSnapToDesktopEdges);
- pApp->WriteProfileBinary(IDS_R_SETTINGS, IDS_RS_LASTWINDOWRECT, (BYTE*)&rcLastWindowPos, sizeof(rcLastWindowPos));
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LASTWINDOWTYPE, nLastWindowType);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ASPECTRATIO_X, sizeAspectRatio.cx);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ASPECTRATIO_Y, sizeAspectRatio.cy);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_KEEPHISTORY, fKeepHistory);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_DSVIDEORENDERERTYPE, iDSVideoRendererType);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_RMVIDEORENDERERTYPE, iRMVideoRendererType);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_QTVIDEORENDERERTYPE, iQTVideoRendererType);
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SHUFFLEPLAYLISTITEMS, bShufflePlaylistItems);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REMEMBERPLAYLISTITEMS, bRememberPlaylistItems);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_HIDEPLAYLISTFULLSCREEN, bHidePlaylistFullScreen);
- pApp->WriteProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_REMEMBERPOS, bFavRememberPos);
- pApp->WriteProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_RELATIVEDRIVE, bFavRelativeDrive);
-
- UpdateRenderersData(true);
-
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_AUDIORENDERERTYPE, CString(strAudioRendererDisplayName));
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOLOADAUDIO, fAutoloadAudio);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOLOADSUBTITLES, fAutoloadSubtitles);
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_SUBTITLESLANGORDER, CString(strSubtitlesLanguageOrder));
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_AUDIOSLANGORDER, CString(strAudiosLanguageOrder));
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_BLOCKVSFILTER, fBlockVSFilter);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEWORKERTHREADFOROPENING, fEnableWorkerThreadForOpening);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REPORTFAILEDPINS, fReportFailedPins);
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_DVDPATH, strDVDPath);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_USEDVDPATH, fUseDVDPath);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MENULANG, idMenuLang);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIOLANG, idAudioLang);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SUBTITLESLANG, idSubtitlesLang);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOSPEAKERCONF, fAutoSpeakerConf);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_CLOSEDCAPTIONS, fClosedCaptions);
- CString style;
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_SPLOGFONT, style <<= subdefstyle);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SPOVERRIDEPLACEMENT, fOverridePlacement);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SPHORPOS, nHorPos);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SPVERPOS, nVerPos);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SUBDELAYINTERVAL, nSubDelayInterval);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLESUBTITLES, fEnableSubtitles);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_PRIORITIZEEXTERNALSUBTITLES, fPrioritizeExternalSubtitles);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_DISABLEINTERNALSUBTITLES, fDisableInternalSubtitles);
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_SUBTITLEPATHS, strSubtitlePaths);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_USEDEFAULTSUBTITLESSTYLE, fUseDefaultSubtitlesStyle);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEAUDIOSWITCHER, fEnableAudioSwitcher);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEAUDIOTIMESHIFT, fAudioTimeShift);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIOTIMESHIFT, iAudioTimeShift);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_DOWNSAMPLETO441, fDownSampleTo441);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_CUSTOMCHANNELMAPPING, fCustomChannelMapping);
- pApp->WriteProfileBinary(IDS_R_SETTINGS, IDS_RS_SPEAKERTOCHANNELMAPPING, (BYTE*)pSpeakerToChannelMap, sizeof(pSpeakerToChannelMap));
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIONORMALIZE, fAudioNormalize);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIONORMALIZERECOVER, fAudioNormalizeRecover);
-
- CString strTemp;
- strTemp.Format( _T("%.1f"), dAudioBoost_dB);
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_AUDIOBOOST, strTemp);
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SPEAKERCHANNELS, nSpeakerChannels);
-
- // Multi-monitor code
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_FULLSCREENMONITOR, CString(strFullScreenMonitor));
- // Prevent Minimize when in Fullscreen mode on non default monitor
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_PREVENT_MINIMIZE, fPreventMinimize);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_WIN7TASKBAR, fUseWin7TaskBar);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_EXIT_AFTER_PB, fExitAfterPlayback);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_NEXT_AFTER_PB, fNextInDirAfterPlayback);
- // TODO: Change IDS_RS_MPC_NO_SEARCH_IN_FOLDER into IDS_RS_SEARCH_IN_FOLDER
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_NO_SEARCH_IN_FOLDER, !fUseSearchInFolder);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_USE_TIME_TOOLTIP, fUseTimeTooltip);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_TIME_TOOLTIP_POSITION, nTimeTooltipPosition);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_OSD_SIZE, nOSDSize);
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_MPC_OSD_FONT, strOSDFont);
-
- // Associated types with icon or not...
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ASSOCIATED_WITH_ICON, fAssociatedWithIcons);
- // Last Open Dir
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_LAST_OPEN_DIR, strLastOpenDir);
-
- // CASIMIR666 : new settings
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_D3DFULLSCREEN, fD3DFullscreen);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MONITOR_AUTOREFRESHRATE, fMonitorAutoRefreshRate);
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_COLOR_BRIGHTNESS, iBrightness);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_COLOR_CONTRAST, iContrast);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_COLOR_HUE, iHue);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_COLOR_SATURATION, iSaturation);
-
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_SHADERLIST, strShaderList);
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_SHADERLISTSCREENSPACE, strShaderListScreenSpace);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_TOGGLESHADER, (int)fToggleShader);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_TOGGLESHADERSSCREENSPACE, (int)fToggleShaderScreenSpace);
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SHOWOSD, (int)fShowOSD);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEEDLEDITOR, (int)fEnableEDLEditor);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LANGUAGE, language);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_FASTSEEK_KEYFRAME, (int)fFastSeek);
-
- // Save analog capture settings
- pApp->WriteProfileInt (IDS_R_SETTINGS, IDS_RS_DEFAULT_CAPTURE, iDefaultCaptureDevice);
- pApp->WriteProfileString(IDS_RS_CAPTURE, IDS_RS_VIDEO_DISP_NAME, strAnalogVideo);
- pApp->WriteProfileString(IDS_RS_CAPTURE, IDS_RS_AUDIO_DISP_NAME, strAnalogAudio);
- pApp->WriteProfileInt (IDS_RS_CAPTURE, IDS_RS_COUNTRY, iAnalogCountry);
-
- // Save digital capture settings (BDA)
- pApp->WriteProfileString(IDS_RS_DVB, IDS_RS_BDA_NETWORKPROVIDER, strBDANetworkProvider);
- pApp->WriteProfileString(IDS_RS_DVB, IDS_RS_BDA_TUNER, strBDATuner);
- pApp->WriteProfileString(IDS_RS_DVB, IDS_RS_BDA_RECEIVER, strBDAReceiver);
- //pApp->WriteProfileString(IDS_RS_DVB, IDS_RS_BDA_STANDARD, strBDAStandard);
- pApp->WriteProfileInt(IDS_RS_DVB, IDS_RS_BDA_SCAN_FREQ_START, iBDAScanFreqStart);
- pApp->WriteProfileInt(IDS_RS_DVB, IDS_RS_BDA_SCAN_FREQ_END, iBDAScanFreqEnd);
- pApp->WriteProfileInt(IDS_RS_DVB, IDS_RS_BDA_BANDWIDTH, iBDABandwidth);
- pApp->WriteProfileInt(IDS_RS_DVB, IDS_RS_BDA_USE_OFFSET, fBDAUseOffset);
- pApp->WriteProfileInt(IDS_RS_DVB, IDS_RS_BDA_OFFSET, iBDAOffset);
- pApp->WriteProfileInt(IDS_RS_DVB, IDS_RS_BDA_IGNORE_ENCRYPTED_CHANNELS, fBDAIgnoreEncryptedChannels);
- pApp->WriteProfileInt(IDS_RS_DVB, IDS_RS_DVB_LAST_CHANNEL, nDVBLastChannel);
-
- int iChannel = 0;
- POSITION pos = m_DVBChannels.GetHeadPosition();
- while (pos) {
- CString strTemp;
- CString strChannel;
- CDVBChannel& Channel = m_DVBChannels.GetNext(pos);
- strTemp.Format(_T("%d"), iChannel);
- pApp->WriteProfileString(IDS_RS_DVB, strTemp, Channel.ToString());
- iChannel++;
- }
-
- // playback positions for last played DVDs
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_DVDPOS, (int)fRememberDVDPos);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_FILEPOS, (int)fRememberFilePos);
- if (fKeepHistory) {
- for (int i=0; i<MAX_DVD_POSITION; i++) {
- CString strDVDPos;
- CString strValue;
-
- strDVDPos.Format (_T("DVD Position %d"), i);
- strValue = SerializeHex((BYTE*)&DvdPosition[i], sizeof(DVD_POSITION));
- pApp->WriteProfileString(IDS_R_SETTINGS, strDVDPos, strValue);
- }
-
- // playback positions for last played files
- for (int i=0; i<MAX_FILE_POSITION; i++) {
- CString strFilePos;
- CString strValue;
-
- strFilePos.Format (_T("File Name %d"), i);
- pApp->WriteProfileString(IDS_R_SETTINGS, strFilePos, FilePosition[i].strFile);
- strFilePos.Format (_T("File Position %d"), i);
- strValue.Format (_T("%I64d"), FilePosition[i].llPosition);
- pApp->WriteProfileString(IDS_R_SETTINGS, strFilePos, strValue);
- }
- }
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LASTFULLSCREEN, (int)fLastFullScreen);
- // CASIMIR666 : end of new settings
-
- {
- for (unsigned int i = 0; ; i++) {
- CString key;
- key.Format(_T("%s\\%04u"), IDS_R_FILTERS, i);
- int j = pApp->GetProfileInt(key, _T("Enabled"), -1);
- pApp->WriteProfileString(key, NULL, NULL);
- if (j < 0) {
- break;
- }
- }
- pApp->WriteProfileString(IDS_R_FILTERS, NULL, NULL);
-
- unsigned int k = 0;
- POSITION pos = m_filters.GetHeadPosition();
- while (pos) {
- FilterOverride* f = m_filters.GetNext(pos);
-
- if (f->fTemporary) {
- continue;
- }
-
- CString key;
- key.Format(_T("%s\\%04u"), IDS_R_FILTERS, k);
-
- pApp->WriteProfileInt(key, _T("SourceType"), (int)f->type);
- pApp->WriteProfileInt(key, _T("Enabled"), (int)!f->fDisabled);
- if (f->type == FilterOverride::REGISTERED) {
- pApp->WriteProfileString(key, _T("DisplayName"), CString(f->dispname));
- pApp->WriteProfileString(key, _T("Name"), f->name);
- } else if (f->type == FilterOverride::EXTERNAL) {
- pApp->WriteProfileString(key, _T("Path"), f->path);
- pApp->WriteProfileString(key, _T("Name"), f->name);
- pApp->WriteProfileString(key, _T("CLSID"), CStringFromGUID(f->clsid));
- }
- POSITION pos2 = f->backup.GetHeadPosition();
- for (unsigned int i = 0; pos2; i++) {
- CString val;
- val.Format(_T("org%04u"), i);
- pApp->WriteProfileString(key, val, CStringFromGUID(f->backup.GetNext(pos2)));
- }
- pos2 = f->guids.GetHeadPosition();
- for (unsigned int i = 0; pos2; i++) {
- CString val;
- val.Format(_T("mod%04u"), i);
- pApp->WriteProfileString(key, val, CStringFromGUID(f->guids.GetNext(pos2)));
- }
- pApp->WriteProfileInt(key, _T("LoadType"), f->iLoadType);
- pApp->WriteProfileInt(key, _T("Merit"), f->dwMerit);
-
- k++;
- }
- }
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_INTREALMEDIA, fIntRealMedia);
- //pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REALMEDIARENDERLESS, fRealMediaRenderless);
- //pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_QUICKTIMERENDERER, iQuickTimeRenderer);
- //pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REALMEDIAFPS, *((DWORD*)&dRealMediaQuickTimeFPS));
-
- pApp->WriteProfileString(IDS_R_SETTINGS _T("\\") IDS_RS_PNSPRESETS, NULL, NULL);
- for (INT_PTR i = 0, j = m_pnspresets.GetCount(); i < j; i++) {
- CString str;
- str.Format(_T("Preset%Id"), i);
- pApp->WriteProfileString(IDS_R_SETTINGS _T("\\") IDS_RS_PNSPRESETS, str, m_pnspresets[i]);
- }
-
- pApp->WriteProfileString(IDS_R_COMMANDS, NULL, NULL);
- pos = wmcmds.GetHeadPosition();
- for (int i = 0; pos; ) {
- wmcmd& wc = wmcmds.GetNext(pos);
- if (wc.IsModified()) {
- CString str;
- str.Format(_T("CommandMod%d"), i);
- CString str2;
- str2.Format(_T("%d %x %x %s %d %u %u %u"),
- wc.cmd, wc.fVirt, wc.key,
- _T("\"") + CString(wc.rmcmd) + _T("\""), wc.rmrepcnt,
- wc.mouse, wc.appcmd, wc.mouseFS);
- pApp->WriteProfileString(IDS_R_COMMANDS, str, str2);
- i++;
- }
- }
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_WINLIRC, fWinLirc);
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_WINLIRCADDR, strWinLircAddr);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_UICE, fUIce);
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_UICEADDR, strUIceAddr);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_GLOBALMEDIA, fGlobalMedia);
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_JUMPDISTS, nJumpDistS);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_JUMPDISTM, nJumpDistM);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_JUMPDISTL, nJumpDistL);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LIMITWINDOWPROPORTIONS, fLimitWindowProportions);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_NOTIFYMSN, fNotifyMSN);
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LASTUSEDPAGE, nLastUsedPage);
-
- m_Formats.UpdateData(true);
-
- // Internal filters
- for (int f=0; f<SRC_LAST; f++) {
- pApp->WriteProfileInt(IDS_R_INTERNAL_FILTERS, SrcFiltersKeys[f], SrcFilters[f]);
- }
- for (int f=0; f<TRA_LAST; f++) {
- pApp->WriteProfileInt(IDS_R_INTERNAL_FILTERS, TraFiltersKeys[f], TraFilters[f]);
- }
- for (int f=0; f<TRA_DXVA_LAST; f++) {
- pApp->WriteProfileInt(IDS_R_INTERNAL_FILTERS, DXVAFiltersKeys[f], DXVAFilters[f]);
- }
- for (int f=0; f<FFM_LAST; f++) {
- pApp->WriteProfileInt(IDS_R_INTERNAL_FILTERS, FFMFiltersKeys[f], FFmpegFilters[f]);
- }
-
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_LOGOFILE, strLogoFileName);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LOGOID, nLogoId);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LOGOEXT, fLogoExternal);
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_HIDECDROMSSUBMENU, fHideCDROMsSubMenu);
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_PRIORITY, dwPriority);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LAUNCHFULLSCREEN, fLaunchfullscreen);
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEWEBSERVER, fEnableWebServer);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERPORT, nWebServerPort);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERPRINTDEBUGINFO, fWebServerPrintDebugInfo);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERUSECOMPRESSION, fWebServerUseCompression);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERLOCALHOSTONLY, fWebServerLocalhostOnly);
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_WEBROOT, strWebRoot);
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_WEBDEFINDEX, strWebDefIndex);
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_WEBSERVERCGI, strWebServerCGI);
-
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_SNAPSHOTPATH, strSnapShotPath);
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_SNAPSHOTEXT, strSnapShotExt);
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_THUMBROWS, iThumbRows);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_THUMBCOLS, iThumbCols);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_THUMBWIDTH, iThumbWidth);
-
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_ISDB, strISDb);
-
- pApp->WriteProfileString(IDS_R_SHADERS, NULL, NULL);
- pApp->WriteProfileInt(IDS_R_SHADERS, IDS_R_SHADERS_INITIALIZED, 1);
- pApp->WriteProfileString(IDS_R_SHADERS, IDS_R_SHADERS_COMBINE, strShadercombine);
- pApp->WriteProfileString(IDS_R_SHADERS, IDS_R_SHADERS_COMBINESCREENSPACE, strShadercombineScreenSpace);
-
-
- pos = m_shaders.GetHeadPosition();
- for (int i = 0; pos; i++) {
- const Shader& s = m_shaders.GetNext(pos);
-
- if (!s.label.IsEmpty()) {
- CString index;
- index.Format(_T("%d"), i);
- CString srcdata = s.srcdata;
- srcdata.Replace(_T("\r"), _T(""));
- srcdata.Replace(_T("\n"), _T("\\n"));
- srcdata.Replace(_T("\t"), _T("\\t"));
- AfxGetApp()->WriteProfileString(IDS_R_SHADERS, index, s.label + _T("|") + s.target + _T("|") + srcdata);
- }
- }
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_REMAINING_TIME, fRemainingTime);
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_UPDATER_AUTO_CHECK, nUpdaterAutoCheck);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_UPDATER_DELAY, nUpdaterDelay);
-
- if (pApp->m_pszRegistryKey) {
- // WINBUG: on win2k this would crash WritePrivateProfileString
- pApp->WriteProfileInt(_T(""), _T(""), pApp->GetProfileInt(_T(""), _T(""), 0)?0:1);
- }
- } else {
- if (fInitialized) {
- return;
- }
-
- iDXVer = 0;
- CRegKey dxver;
- if (ERROR_SUCCESS == dxver.Open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\DirectX"), KEY_READ)) {
- CString str;
- ULONG len = 64;
- if (ERROR_SUCCESS == dxver.QueryStringValue(_T("Version"), str.GetBuffer(len), &len)) {
- str.ReleaseBuffer(len);
- int ver[4];
- _stscanf_s(str, _T("%d.%d.%d.%d"), ver+0, ver+1, ver+2, ver+3);
- iDXVer = ver[1];
- }
- }
-
- // Set interface language first!
- language = (LANGID)pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LANGUAGE, -1);
- if (language == (LANGID)-1) {
- CMPlayerCApp::SetDefaultLanguage();
- } else if (language != 0) {
- if (language <= 23) { // Here for compatibility with old settings
- CMPlayerCApp::SetLanguage(CMPlayerCApp::GetLanguageResourceByResourceID(language + ID_LANGUAGE_ENGLISH));
- } else {
- CMPlayerCApp::SetLanguage(CMPlayerCApp::GetLanguageResourceByLocaleID(language));
- }
- }
-
- CreateCommands();
-
- iCaptionMenuMode = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_HIDECAPTIONMENU, MODE_SHOWCAPTIONMENU);
- fHideNavigation = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_HIDENAVIGATION, 0);
- nCS = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_CONTROLSTATE, CS_SEEKBAR|CS_TOOLBAR|CS_STATUSBAR);
- iDefaultVideoSize = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DEFAULTVIDEOFRAME, DVS_FROMINSIDE);
- fKeepAspectRatio = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_KEEPASPECTRATIO, TRUE);
- fCompMonDeskARDiff = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_COMPMONDESKARDIFF, FALSE);
- nVolume = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_VOLUME, 100);
- nBalance = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_BALANCE, 0);
- fMute = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MUTE, 0);
- nLoops = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LOOPNUM, 1);
- fLoopForever = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LOOP, 0);
- fRewind = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_REWIND, FALSE);
- iZoomLevel = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ZOOM, 1);
- iDSVideoRendererType = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DSVIDEORENDERERTYPE, (SysVersion::IsVistaOrLater() ? (HasEVR() ? VIDRNDT_DS_EVR_CUSTOM : VIDRNDT_DS_DEFAULT) : VIDRNDT_DS_VMR7WINDOWED));
- iRMVideoRendererType = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_RMVIDEORENDERERTYPE, VIDRNDT_RM_DEFAULT);
- iQTVideoRendererType = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_QTVIDEORENDERERTYPE, VIDRNDT_QT_DEFAULT);
-
- UpdateRenderersData(false);
-
- strAudioRendererDisplayName = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_AUDIORENDERERTYPE, _T(""));
- fAutoloadAudio = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOLOADAUDIO, TRUE);
- fAutoloadSubtitles = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOLOADSUBTITLES, !IsVSFilterInstalled() || (SysVersion::IsVistaOrLater() && HasEVR()));
- strSubtitlesLanguageOrder = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_SUBTITLESLANGORDER, _T(""));
- strAudiosLanguageOrder = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_AUDIOSLANGORDER, _T(""));
- fBlockVSFilter = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_BLOCKVSFILTER, TRUE);
- fEnableWorkerThreadForOpening = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEWORKERTHREADFOROPENING, TRUE);
- fReportFailedPins = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_REPORTFAILEDPINS, TRUE);
- fAllowMultipleInst = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MULTIINST, 0);
- iTitleBarTextStyle = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_TITLEBARTEXTSTYLE, 1);
- fTitleBarTextTitle = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_TITLEBARTEXTTITLE, FALSE);
- iOnTop = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ONTOP, 0);
- fTrayIcon = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_TRAYICON, 0);
- fRememberZoomLevel = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOZOOM, 1);
- fShowBarsWhenFullScreen = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_FULLSCREENCTRLS, 1);
- nShowBarsWhenFullScreenTimeOut = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_FULLSCREENCTRLSTIMEOUT, 0);
-
- //Multi-monitor code
- strFullScreenMonitor = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_FULLSCREENMONITOR, _T(""));
- // Prevent Minimize when in Fullscreen mode on non default monitor
- fPreventMinimize = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_PREVENT_MINIMIZE, 0);
- fUseWin7TaskBar = SysVersion::Is7OrLater() ? !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_WIN7TASKBAR, TRUE) : FALSE;
- fExitAfterPlayback = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_EXIT_AFTER_PB, 0);
- fNextInDirAfterPlayback = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_NEXT_AFTER_PB, 0);
- // TODO: Change IDS_RS_MPC_NO_SEARCH_IN_FOLDER into IDS_RS_SEARCH_IN_FOLDER
- fUseSearchInFolder = !pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_NO_SEARCH_IN_FOLDER, 0);
- fUseTimeTooltip = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_USE_TIME_TOOLTIP, TRUE);
- nTimeTooltipPosition = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_TIME_TOOLTIP_POSITION, TIME_TOOLTIP_ABOVE_SEEKBAR);
- nOSDSize = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_OSD_SIZE, SysVersion::IsVistaOrLater() ? 18 : 20);
- if (SysVersion::IsVistaOrLater()) {
- LOGFONT lf;
- GetMessageFont(&lf);
- strOSDFont = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_MPC_OSD_FONT, lf.lfFaceName);
- }
- else {
- strOSDFont= pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_MPC_OSD_FONT, _T("Arial"));
- }
-
- // Associated types with icon or not...
- fAssociatedWithIcons = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ASSOCIATED_WITH_ICON, 1);
- // Last Open Dir
- strLastOpenDir = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_LAST_OPEN_DIR, _T("C:\\"));
-
- if ( pApp->GetProfileBinary(IDS_R_SETTINGS, IDS_RS_FULLSCREENRES, &ptr, &len) ) {
- if ( len == sizeof(AChFR) ) {
- memcpy( &AutoChangeFullscrRes, ptr, sizeof(AChFR) );
- } else {
- AutoChangeFullscrRes.bEnabled = false;
- }
- delete [] ptr;
- } else {
- AutoChangeFullscrRes.bEnabled = false;
- }
-
- fExitFullScreenAtTheEnd = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_EXITFULLSCREENATTHEEND, 1);
- fRestoreResAfterExit = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_RESTORERESAFTEREXIT, 1);
- fRememberWindowPos = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_REMEMBERWINDOWPOS, 0);
- fRememberWindowSize = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_REMEMBERWINDOWSIZE, 0);
- CString str = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_PANSCANZOOM, _T(""));
- if ( _stscanf_s(str, _T("%f,%f"), &dZoomX, &dZoomY) == 2 &&
- dZoomX >=0.196 && dZoomX <=3.06 && // 0.196 = 0.2 / 1.02
- dZoomY >=0.196 && dZoomY <=3.06) { // 3.06 = 3 * 1.02
- fSavePnSZoom = true;
- } else {
- fSavePnSZoom = false;
- dZoomX = 1.0;
- dZoomY = 1.0;
- }
- fSnapToDesktopEdges = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SNAPTODESKTOPEDGES, 0);
- sizeAspectRatio.cx = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ASPECTRATIO_X, 0);
- sizeAspectRatio.cy = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ASPECTRATIO_Y, 0);
- fKeepHistory = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_KEEPHISTORY, 1);
- if ( pApp->GetProfileBinary(IDS_R_SETTINGS, IDS_RS_LASTWINDOWRECT, &ptr, &len) ) {
- if ( len == sizeof(CRect) ) {
- memcpy( &rcLastWindowPos, ptr, sizeof(CRect) );
- } else {
- fRememberWindowPos = false;
- }
- delete [] ptr;
- } else {
- fRememberWindowPos = false;
- }
- nLastWindowType = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LASTWINDOWTYPE, SIZE_RESTORED);
-
- bShufflePlaylistItems = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SHUFFLEPLAYLISTITEMS, FALSE);
- bRememberPlaylistItems = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_REMEMBERPLAYLISTITEMS, TRUE);
- bHidePlaylistFullScreen = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_HIDEPLAYLISTFULLSCREEN, FALSE);
- bFavRememberPos = !!pApp->GetProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_REMEMBERPOS, TRUE);
- bFavRelativeDrive = !!pApp->GetProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_RELATIVEDRIVE, FALSE);
-
- strDVDPath = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_DVDPATH, _T(""));
- fUseDVDPath = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_USEDVDPATH, 0);
- idMenuLang = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MENULANG, 0);
- idAudioLang = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIOLANG, 0);
- idSubtitlesLang = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SUBTITLESLANG, 0);
- fAutoSpeakerConf = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOSPEAKERCONF, 1);
- fClosedCaptions = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_CLOSEDCAPTIONS, 0);
- // TODO: rename subdefstyle -> defStyle, IDS_RS_SPLOGFONT -> IDS_RS_SPSTYLE
- {
- CString temp = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_SPLOGFONT, _T(""));
- subdefstyle <<= temp;
- if (temp == _T("")) {
- subdefstyle.relativeTo = 1; //default "Position subtitles relative to the video frame" option is checked
- }
- }
- fOverridePlacement = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SPOVERRIDEPLACEMENT, 0);
- nHorPos = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SPHORPOS, 50);
- nVerPos = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SPVERPOS, 90);
- nSubDelayInterval = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SUBDELAYINTERVAL, 500);
-
- fEnableSubtitles = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLESUBTITLES, TRUE);
- fPrioritizeExternalSubtitles = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_PRIORITIZEEXTERNALSUBTITLES, TRUE);
- fDisableInternalSubtitles = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DISABLEINTERNALSUBTITLES, FALSE);
- strSubtitlePaths = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_SUBTITLEPATHS, DEFAULT_SUBTITLE_PATHS);
- fUseDefaultSubtitlesStyle = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_USEDEFAULTSUBTITLESSTYLE, FALSE);
- fEnableAudioSwitcher = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEAUDIOSWITCHER, TRUE);
- fAudioTimeShift = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEAUDIOTIMESHIFT, 0);
- iAudioTimeShift = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIOTIMESHIFT, 0);
- fDownSampleTo441 = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DOWNSAMPLETO441, 0);
- fCustomChannelMapping = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_CUSTOMCHANNELMAPPING, 0);
-
- BOOL bResult = pApp->GetProfileBinary( IDS_R_SETTINGS, IDS_RS_SPEAKERTOCHANNELMAPPING, &ptr, &len );
- if ( bResult && len == sizeof(pSpeakerToChannelMap) ) {
- memcpy( pSpeakerToChannelMap, ptr, sizeof(pSpeakerToChannelMap) );
- } else {
- memset(pSpeakerToChannelMap, 0, sizeof(pSpeakerToChannelMap));
- for (int j = 0; j < 18; j++)
- for (int i = 0; i <= j; i++) {
- pSpeakerToChannelMap[j][i] = 1<<i;
- }
-
- pSpeakerToChannelMap[0][0] = 1<<0;
- pSpeakerToChannelMap[0][1] = 1<<0;
-
- pSpeakerToChannelMap[3][0] = 1<<0;
- pSpeakerToChannelMap[3][1] = 1<<1;
- pSpeakerToChannelMap[3][2] = 0;
- pSpeakerToChannelMap[3][3] = 0;
- pSpeakerToChannelMap[3][4] = 1<<2;
- pSpeakerToChannelMap[3][5] = 1<<3;
-
- pSpeakerToChannelMap[4][0] = 1<<0;
- pSpeakerToChannelMap[4][1] = 1<<1;
- pSpeakerToChannelMap[4][2] = 1<<2;
- pSpeakerToChannelMap[4][3] = 0;
- pSpeakerToChannelMap[4][4] = 1<<3;
- pSpeakerToChannelMap[4][5] = 1<<4;
- }
- if ( bResult ) {
- delete [] ptr;
- }
-
- fAudioNormalize = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIONORMALIZE, FALSE);
- fAudioNormalizeRecover = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIONORMALIZERECOVER, TRUE);
- dAudioBoost_dB = (float)_tstof(pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_AUDIOBOOST, _T("0")));
- if (dAudioBoost_dB<0 || dAudioBoost_dB>10) {
- dAudioBoost_dB = 0;
- }
-
- nSpeakerChannels = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SPEAKERCHANNELS, 2);
-
- {
- for (unsigned int i = 0; ; i++) {
- CString key;
- key.Format(_T("%s\\%04u"), IDS_R_FILTERS, i);
-
- CAutoPtr<FilterOverride> f(DNew FilterOverride);
-
- f->fDisabled = !pApp->GetProfileInt(key, _T("Enabled"), 0);
-
- UINT j = pApp->GetProfileInt(key, _T("SourceType"), -1);
- if (j == 0) {
- f->type = FilterOverride::REGISTERED;
- f->dispname = CStringW(pApp->GetProfileString(key, _T("DisplayName"), _T("")));
- f->name = pApp->GetProfileString(key, _T("Name"), _T(""));
- } else if (j == 1) {
- f->type = FilterOverride::EXTERNAL;
- f->path = pApp->GetProfileString(key, _T("Path"), _T(""));
- f->name = pApp->GetProfileString(key, _T("Name"), _T(""));
- f->clsid = GUIDFromCString(pApp->GetProfileString(key, _T("CLSID"), _T("")));
- } else {
- pApp->WriteProfileString(key, NULL, 0);
- break;
- }
-
- f->backup.RemoveAll();
- for (unsigned int i = 0; ; i++) {
- CString val;
- val.Format(_T("org%04u"), i);
- CString guid = pApp->GetProfileString(key, val, _T(""));
- if (guid.IsEmpty()) {
- break;
- }
- f->backup.AddTail(GUIDFromCString(guid));
- }
-
- f->guids.RemoveAll();
- for (unsigned int i = 0; ; i++) {
- CString val;
- val.Format(_T("mod%04u"), i);
- CString guid = pApp->GetProfileString(key, val, _T(""));
- if (guid.IsEmpty()) {
- break;
- }
- f->guids.AddTail(GUIDFromCString(guid));
- }
-
- f->iLoadType = (int)pApp->GetProfileInt(key, _T("LoadType"), -1);
- if (f->iLoadType < 0) {
- break;
- }
-
- f->dwMerit = pApp->GetProfileInt(key, _T("Merit"), MERIT_DO_NOT_USE+1);
-
- m_filters.AddTail(f);
- }
- }
-
- fIntRealMedia = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_INTREALMEDIA, 0);
- //fRealMediaRenderless = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_REALMEDIARENDERLESS, 0);
- //iQuickTimeRenderer = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_QUICKTIMERENDERER, 2);
- //dRealMediaQuickTimeFPS = 25.0;
- //*((DWORD*)&dRealMediaQuickTimeFPS) = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_REALMEDIAFPS, *((DWORD*)&dRealMediaQuickTimeFPS));
-
- m_pnspresets.RemoveAll();
- for (int i = 0; i < (ID_PANNSCAN_PRESETS_END - ID_PANNSCAN_PRESETS_START); i++) {
- CString str;
- str.Format(_T("Preset%d"), i);
- str = pApp->GetProfileString(IDS_R_SETTINGS _T("\\") IDS_RS_PNSPRESETS, str, _T(""));
- if (str.IsEmpty()) {
- break;
- }
- m_pnspresets.Add(str);
- }
-
- if (m_pnspresets.IsEmpty()) {
- double _4p3 = 4.0/3.0;
- double _16p9 = 16.0/9.0;
- double _185p1 = 1.85/1.0;
- double _235p1 = 2.35/1.0;
- UNREFERENCED_PARAMETER(_185p1);
-
- CString str;
- str.Format(IDS_SCALE_16_9, 0.5, 0.5, _4p3/_4p3, _16p9/_4p3);
- m_pnspresets.Add(str);
- str.Format(IDS_SCALE_WIDESCREEN, 0.5, 0.5, _16p9/_4p3, _16p9/_4p3);
- m_pnspresets.Add(str);
- str.Format(IDS_SCALE_ULTRAWIDE, 0.5, 0.5, _235p1/_4p3, _235p1/_4p3);
- m_pnspresets.Add(str);
- }
-
- for (int i = 0; i < wmcmds.GetCount(); i++) {
- CString str;
- str.Format(_T("CommandMod%d"), i);
- str = pApp->GetProfileString(IDS_R_COMMANDS, str, _T(""));
- if (str.IsEmpty()) {
- break;
- }
- int cmd, fVirt, key, repcnt;
- UINT mouse, mouseFS, appcmd;
- TCHAR buff[128];
- int n;
- if (5 > (n = _stscanf_s(str, _T("%d %x %x %s %d %u %u %u"), &cmd, &fVirt, &key, buff, _countof(buff), &repcnt, &mouse, &appcmd, &mouseFS))) {
- break;
- }
- if (POSITION pos = wmcmds.Find(cmd)) {
- wmcmd& wc = wmcmds.GetAt(pos);
- wc.cmd = cmd;
- wc.fVirt = fVirt;
- wc.key = key;
- if (n >= 6) {
- wc.mouse = mouse;
- }
- if (n >= 7) {
- wc.appcmd = appcmd;
- }
- // If there is no distinct bindings for windowed and
- // fullscreen modes we use the same for both.
- wc.mouseFS = (n >= 8) ? mouseFS : wc.mouse;
- wc.rmcmd = CStringA(buff).Trim('\"');
- wc.rmrepcnt = repcnt;
- }
- }
-
- CAtlArray<ACCEL> pAccel;
- pAccel.SetCount(wmcmds.GetCount());
- POSITION pos = wmcmds.GetHeadPosition();
- for (int i = 0; pos; i++) {
- pAccel[i] = wmcmds.GetNext(pos);
- }
- hAccel = CreateAcceleratorTable(pAccel.GetData(), (int)pAccel.GetCount());
-
- strWinLircAddr = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_WINLIRCADDR, _T("127.0.0.1:8765"));
- fWinLirc = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_WINLIRC, 0);
- strUIceAddr = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_UICEADDR, _T("127.0.0.1:1234"));
- fUIce = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_UICE, 0);
- fGlobalMedia = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_GLOBALMEDIA, 1);
-
- nJumpDistS = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_JUMPDISTS, DEFAULT_JUMPDISTANCE_1);
- nJumpDistM = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_JUMPDISTM, DEFAULT_JUMPDISTANCE_2);
- nJumpDistL = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_JUMPDISTL, DEFAULT_JUMPDISTANCE_3);
- fLimitWindowProportions = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LIMITWINDOWPROPORTIONS, FALSE);
- fNotifyMSN = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_NOTIFYMSN, FALSE);
-
- m_Formats.UpdateData(false);
-
- // Internal filters
- for (int f=0; f<SRC_LAST; f++) {
- SrcFilters[f] = !!pApp->GetProfileInt(IDS_R_INTERNAL_FILTERS, SrcFiltersKeys[f], 1);
- }
- for (int f=0; f<TRA_LAST; f++) {
- TraFilters[f] = !!pApp->GetProfileInt(IDS_R_INTERNAL_FILTERS, TraFiltersKeys[f], 1);
- }
- for (int f=0; f<TRA_DXVA_LAST; f++) {
- DXVAFilters[f] = !!pApp->GetProfileInt(IDS_R_INTERNAL_FILTERS, DXVAFiltersKeys[f], 1);
- }
- for (int f=0; f<FFM_LAST; f++) {
- FFmpegFilters[f] = !!pApp->GetProfileInt(IDS_R_INTERNAL_FILTERS, FFMFiltersKeys[f], 1);
- }
- if (!TRA_DXVA_LAST) DXVAFilters[0] = FALSE;
- if (!FFM_LAST) FFmpegFilters[0] = FALSE;
-
- strLogoFileName = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_LOGOFILE, _T(""));
- nLogoId = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LOGOID, DEF_LOGO);
- fLogoExternal = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LOGOEXT, 0);
-
- fHideCDROMsSubMenu = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_HIDECDROMSSUBMENU, 0);
-
- dwPriority = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_PRIORITY, NORMAL_PRIORITY_CLASS);
- ::SetPriorityClass(::GetCurrentProcess(), dwPriority);
- fLaunchfullscreen = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LAUNCHFULLSCREEN, FALSE);
-
- fEnableWebServer = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEWEBSERVER, FALSE);
- nWebServerPort = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERPORT, 13579);
- fWebServerPrintDebugInfo = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERPRINTDEBUGINFO, FALSE);
- fWebServerUseCompression = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERUSECOMPRESSION, TRUE);
- fWebServerLocalhostOnly = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERLOCALHOSTONLY, FALSE);
- strWebRoot = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_WEBROOT, _T("*./webroot"));
- strWebDefIndex = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_WEBDEFINDEX, _T("index.html;index.php"));
- strWebServerCGI = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_WEBSERVERCGI, _T(""));
-
- CString MyPictures;
-
- CRegKey key;
- // grrrrr
- // if (!SHGetSpecialFolderPath(NULL, MyPictures.GetBufferSetLength(_MAX_PATH), CSIDL_MYPICTURES, TRUE)) MyPictures.Empty();
- // else MyPictures.ReleaseBuffer();
- if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"), KEY_READ)) {
- ULONG len = _MAX_PATH;
- if (ERROR_SUCCESS == key.QueryStringValue(_T("My Pictures"), MyPictures.GetBuffer(_MAX_PATH), &len)) {
- MyPictures.ReleaseBufferSetLength(len);
- } else {
- MyPictures.Empty();
- }
- }
- strSnapShotPath = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_SNAPSHOTPATH, MyPictures);
- strSnapShotExt = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_SNAPSHOTEXT, _T(".jpg"));
-
- iThumbRows = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_THUMBROWS, 4);
- iThumbCols = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_THUMBCOLS, 4);
- iThumbWidth = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_THUMBWIDTH, 1024);
-
- strISDb = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_ISDB, _T("www.opensubtitles.org/isdb"));
-
- nLastUsedPage = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LASTUSEDPAGE, 0);
- //
-
- m_shaders.RemoveAll();
-
- CAtlStringMap<UINT> shaders;
-
- shaders[_T("16-235 -> 0-255 [SD][HD]")] = IDF_SHADER_LEVELS;
- shaders[_T("16-235 -> 0-255 [SD]")] = IDF_SHADER_LEVELS2;
- shaders[_T("0-255 -> 16-235")] = IDF_SHADER_LEVELS3;
- shaders[_T("BT.601 -> BT.709")] = IDF_SHADER_BT601_BT709;
- shaders[_T("contour")] = IDF_SHADER_CONTOUR;
- shaders[_T("deinterlace (blend)")] = IDF_SHADER_DEINTERLACE;
- shaders[_T("edge sharpen")] = IDF_SHADER_EDGE_SHARPEN;
- shaders[_T("emboss")] = IDF_SHADER_EMBOSS;
- shaders[_T("grayscale")] = IDF_SHADER_GRAYSCALE;
- shaders[_T("invert")] = IDF_SHADER_INVERT;
- shaders[_T("letterbox")] = IDF_SHADER_LETTERBOX;
- shaders[_T("nightvision")] = IDF_SHADER_NIGHTVISION;
- shaders[_T("procamp")] = IDF_SHADER_PROCAMP;
- shaders[_T("sharpen")] = IDF_SHADER_SHARPEN;
- shaders[_T("sharpen complex")] = IDF_SHADER_SHARPEN_COMPLEX;
- shaders[_T("sharpen complex 2")] = IDF_SHADER_SHARPEN_COMPLEX2;
- shaders[_T("sphere")] = IDF_SHADER_SPHERE;
- shaders[_T("spotlight")] = IDF_SHADER_SPOTLIGHT;
- shaders[_T("wave")] = IDF_SHADER_WAVE;
- shaders[_T("denoise")] = IDF_SHADER_DENOISE;
- shaders[_T("YV12 Chroma Upsampling")] = IDF_SHADER_YV12CHROMAUP;
-
- for (int iShader=0; ; iShader++) {
- CString str;
- str.Format(_T("%d"), iShader);
- str = pApp->GetProfileString(IDS_R_SHADERS, str);
-
- CAtlList<CString> sl;
- CString label = Explode(str, sl, '|');
- if (label.IsEmpty()) {
- break;
- }
- if (sl.GetCount() < 3) {
- continue;
- }
-
- Shader s;
- s.label = sl.RemoveHead();
- s.target = sl.RemoveHead();
- s.srcdata = sl.RemoveHead();
- s.srcdata.Replace(_T("\\n"), _T("\n"));
- s.srcdata.Replace(_T("\\t"), _T("\t"));
- m_shaders.AddTail(s);
-
- shaders.RemoveKey(s.label);
- }
-
- pos = shaders.GetStartPosition();
- while (pos) {
- CAtlStringMap<UINT>::CPair* pPair = shaders.GetNext(pos);
-
- CStringA srcdata;
- if (LoadResource(pPair->m_value, srcdata, _T("FILE"))) {
- Shader s;
- s.label = pPair->m_key;
-
- // Select minimum version for each shader!
- switch (pPair->m_value) {
- case IDF_SHADER_DENOISE :
- s.target = _T("ps_3_0");
- break;
- case IDF_SHADER_SHARPEN_COMPLEX2 :
- s.target = _T("ps_2_a");
- break;
- default :
- s.target = _T("ps_2_0");
- break;
- }
- s.srcdata = CString(srcdata);
- m_shaders.AddTail(s);
- }
- }
-
- // CASIMIR666 : new settings
- fD3DFullscreen = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_D3DFULLSCREEN, FALSE);
- fMonitorAutoRefreshRate = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MONITOR_AUTOREFRESHRATE, FALSE);
-
- iBrightness = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_COLOR_BRIGHTNESS, 0);
- iContrast = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_COLOR_CONTRAST, 0);
- iHue = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_COLOR_HUE, 0);
- iSaturation = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_COLOR_SATURATION, 0);
-
- strShaderList = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_SHADERLIST, _T(""));
- strShaderListScreenSpace = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_SHADERLISTSCREENSPACE, _T(""));
- fToggleShader = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_TOGGLESHADER, 0);
- fToggleShaderScreenSpace = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_TOGGLESHADERSSCREENSPACE, 0);
-
- fShowOSD = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SHOWOSD, 1);
- fEnableEDLEditor= !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEEDLEDITOR, FALSE);
- fFastSeek = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_FASTSEEK_KEYFRAME, FALSE);
-
- // Save analog capture settings
- iDefaultCaptureDevice = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DEFAULT_CAPTURE, 0);
- strAnalogVideo = pApp->GetProfileString(IDS_RS_CAPTURE, IDS_RS_VIDEO_DISP_NAME, _T("dummy"));
- strAnalogAudio = pApp->GetProfileString(IDS_RS_CAPTURE, IDS_RS_AUDIO_DISP_NAME, _T("dummy"));
- iAnalogCountry = pApp->GetProfileInt(IDS_RS_CAPTURE, IDS_RS_COUNTRY, 1);
-
- strBDANetworkProvider = pApp->GetProfileString(IDS_RS_DVB, IDS_RS_BDA_NETWORKPROVIDER, _T(""));
- strBDATuner = pApp->GetProfileString(IDS_RS_DVB, IDS_RS_BDA_TUNER, _T(""));
- strBDAReceiver = pApp->GetProfileString(IDS_RS_DVB, IDS_RS_BDA_RECEIVER, _T(""));
- //sBDAStandard = pApp->GetProfileString(IDS_RS_DVB, IDS_RS_BDA_STANDARD, _T(""));
- iBDAScanFreqStart = pApp->GetProfileInt(IDS_RS_DVB, IDS_RS_BDA_SCAN_FREQ_START, 474000);
- iBDAScanFreqEnd = pApp->GetProfileInt(IDS_RS_DVB, IDS_RS_BDA_SCAN_FREQ_END, 858000);
- iBDABandwidth = pApp->GetProfileInt(IDS_RS_DVB, IDS_RS_BDA_BANDWIDTH, 8);
- fBDAUseOffset = !!pApp->GetProfileInt(IDS_RS_DVB, IDS_RS_BDA_USE_OFFSET, 0);
- iBDAOffset = pApp->GetProfileInt(IDS_RS_DVB, IDS_RS_BDA_OFFSET, 166);
- fBDAIgnoreEncryptedChannels = !!pApp->GetProfileInt(IDS_RS_DVB, IDS_RS_BDA_IGNORE_ENCRYPTED_CHANNELS, 0);
- nDVBLastChannel = pApp->GetProfileInt(IDS_RS_DVB, IDS_RS_DVB_LAST_CHANNEL, 1);
-
- for (int iChannel = 0; ; iChannel++) {
- CString strTemp;
- CString strChannel;
- CDVBChannel Channel;
- strTemp.Format(_T("%d"), iChannel);
- strChannel = pApp->GetProfileString(IDS_RS_DVB, strTemp, _T(""));
- if (strChannel.IsEmpty()) {
- break;
- }
- Channel.FromString(strChannel);
- m_DVBChannels.AddTail (Channel);
- }
-
- // playback positions for last played DVDs
- fRememberDVDPos = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DVDPOS, 0);
- nCurrentDvdPosition = -1;
- memset (DvdPosition, 0, sizeof(DvdPosition));
- for (int i=0; i<MAX_DVD_POSITION; i++) {
- CString strDVDPos;
- CString strValue;
-
- strDVDPos.Format (_T("DVD Position %d"), i);
- strValue = pApp->GetProfileString(IDS_R_SETTINGS, strDVDPos, _T(""));
- if (strValue.GetLength()/2 == sizeof(DVD_POSITION)) {
- DeserializeHex(strValue, (BYTE*)&DvdPosition[i], sizeof(DVD_POSITION));
- }
- }
-
- // playback positions for last played files
- fRememberFilePos = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_FILEPOS, 0);
- nCurrentFilePosition = -1;
- for (int i=0; i<MAX_FILE_POSITION; i++) {
- CString strFilePos;
- CString strValue;
-
- strFilePos.Format (_T("File Name %d"), i);
- FilePosition[i].strFile = pApp->GetProfileString(IDS_R_SETTINGS, strFilePos, _T(""));
-
- strFilePos.Format (_T("File Position %d"), i);
- strValue = pApp->GetProfileString(IDS_R_SETTINGS, strFilePos, _T(""));
- FilePosition[i].llPosition = _tstoi64 (strValue);
- }
-
- fLastFullScreen = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LASTFULLSCREEN, 0);
-
- // TODO: sort shaders by label
-
- strShadercombine = pApp->GetProfileString(IDS_R_SHADERS, IDS_R_SHADERS_COMBINE, _T(""));
- strShadercombineScreenSpace = pApp->GetProfileString(IDS_R_SHADERS, IDS_R_SHADERS_COMBINESCREENSPACE, _T(""));
-
- fRemainingTime = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_REMAINING_TIME, FALSE);
-
- nUpdaterAutoCheck = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_UPDATER_AUTO_CHECK, AUTOUPDATE_UNKNOWN);
- nUpdaterDelay = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_UPDATER_DELAY, 7);
- if (nUpdaterDelay < 1) {
- nUpdaterDelay = 1;
- }
-
- if (fLaunchfullscreen) {
- nCLSwitches |= CLSW_FULLSCREEN;
- }
-
- fInitialized = true;
- }
+ CWinApp* pApp = AfxGetApp();
+ ASSERT(pApp);
+
+ UINT len;
+ BYTE* ptr = NULL;
+
+ if (fSave) {
+ if (!fInitialized) {
+ return;
+ }
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_HIDECAPTIONMENU, iCaptionMenuMode);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_HIDENAVIGATION, fHideNavigation);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_CONTROLSTATE, nCS);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_DEFAULTVIDEOFRAME, iDefaultVideoSize);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_KEEPASPECTRATIO, fKeepAspectRatio);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_COMPMONDESKARDIFF, fCompMonDeskARDiff);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_VOLUME, nVolume);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_BALANCE, nBalance);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MUTE, fMute);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LOOPNUM, nLoops);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LOOP, fLoopForever);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REWIND, fRewind);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ZOOM, iZoomLevel);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MULTIINST, fAllowMultipleInst);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_TITLEBARTEXTSTYLE, iTitleBarTextStyle);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_TITLEBARTEXTTITLE, fTitleBarTextTitle);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ONTOP, iOnTop);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_TRAYICON, fTrayIcon);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOZOOM, fRememberZoomLevel);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_FULLSCREENCTRLS, fShowBarsWhenFullScreen);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_FULLSCREENCTRLSTIMEOUT, nShowBarsWhenFullScreenTimeOut);
+ pApp->WriteProfileBinary(IDS_R_SETTINGS, IDS_RS_FULLSCREENRES, (BYTE*)&AutoChangeFullscrRes, sizeof(AutoChangeFullscrRes));
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_EXITFULLSCREENATTHEEND, fExitFullScreenAtTheEnd);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_RESTORERESAFTEREXIT, fRestoreResAfterExit);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REMEMBERWINDOWPOS, fRememberWindowPos);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REMEMBERWINDOWSIZE, fRememberWindowSize);
+ if (fSavePnSZoom) {
+ CString str;
+ str.Format(_T("%.3f,%.3f"), dZoomX, dZoomY);
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_PANSCANZOOM, str);
+ } else {
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_PANSCANZOOM, NULL);
+ }
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SNAPTODESKTOPEDGES, fSnapToDesktopEdges);
+ pApp->WriteProfileBinary(IDS_R_SETTINGS, IDS_RS_LASTWINDOWRECT, (BYTE*)&rcLastWindowPos, sizeof(rcLastWindowPos));
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LASTWINDOWTYPE, nLastWindowType);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ASPECTRATIO_X, sizeAspectRatio.cx);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ASPECTRATIO_Y, sizeAspectRatio.cy);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_KEEPHISTORY, fKeepHistory);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_DSVIDEORENDERERTYPE, iDSVideoRendererType);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_RMVIDEORENDERERTYPE, iRMVideoRendererType);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_QTVIDEORENDERERTYPE, iQTVideoRendererType);
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SHUFFLEPLAYLISTITEMS, bShufflePlaylistItems);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REMEMBERPLAYLISTITEMS, bRememberPlaylistItems);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_HIDEPLAYLISTFULLSCREEN, bHidePlaylistFullScreen);
+ pApp->WriteProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_REMEMBERPOS, bFavRememberPos);
+ pApp->WriteProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_RELATIVEDRIVE, bFavRelativeDrive);
+
+ UpdateRenderersData(true);
+
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_AUDIORENDERERTYPE, CString(strAudioRendererDisplayName));
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOLOADAUDIO, fAutoloadAudio);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOLOADSUBTITLES, fAutoloadSubtitles);
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_SUBTITLESLANGORDER, CString(strSubtitlesLanguageOrder));
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_AUDIOSLANGORDER, CString(strAudiosLanguageOrder));
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_BLOCKVSFILTER, fBlockVSFilter);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEWORKERTHREADFOROPENING, fEnableWorkerThreadForOpening);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REPORTFAILEDPINS, fReportFailedPins);
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_DVDPATH, strDVDPath);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_USEDVDPATH, fUseDVDPath);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MENULANG, idMenuLang);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIOLANG, idAudioLang);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SUBTITLESLANG, idSubtitlesLang);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOSPEAKERCONF, fAutoSpeakerConf);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_CLOSEDCAPTIONS, fClosedCaptions);
+ CString style;
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_SPLOGFONT, style <<= subdefstyle);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SPOVERRIDEPLACEMENT, fOverridePlacement);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SPHORPOS, nHorPos);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SPVERPOS, nVerPos);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SUBDELAYINTERVAL, nSubDelayInterval);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLESUBTITLES, fEnableSubtitles);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_PRIORITIZEEXTERNALSUBTITLES, fPrioritizeExternalSubtitles);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_DISABLEINTERNALSUBTITLES, fDisableInternalSubtitles);
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_SUBTITLEPATHS, strSubtitlePaths);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_USEDEFAULTSUBTITLESSTYLE, fUseDefaultSubtitlesStyle);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEAUDIOSWITCHER, fEnableAudioSwitcher);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEAUDIOTIMESHIFT, fAudioTimeShift);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIOTIMESHIFT, iAudioTimeShift);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_DOWNSAMPLETO441, fDownSampleTo441);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_CUSTOMCHANNELMAPPING, fCustomChannelMapping);
+ pApp->WriteProfileBinary(IDS_R_SETTINGS, IDS_RS_SPEAKERTOCHANNELMAPPING, (BYTE*)pSpeakerToChannelMap, sizeof(pSpeakerToChannelMap));
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIONORMALIZE, fAudioNormalize);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIONORMALIZERECOVER, fAudioNormalizeRecover);
+
+ CString strTemp;
+ strTemp.Format(_T("%.1f"), dAudioBoost_dB);
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_AUDIOBOOST, strTemp);
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SPEAKERCHANNELS, nSpeakerChannels);
+
+ // Multi-monitor code
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_FULLSCREENMONITOR, CString(strFullScreenMonitor));
+ // Prevent Minimize when in Fullscreen mode on non default monitor
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_PREVENT_MINIMIZE, fPreventMinimize);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_WIN7TASKBAR, fUseWin7TaskBar);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_EXIT_AFTER_PB, fExitAfterPlayback);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_NEXT_AFTER_PB, fNextInDirAfterPlayback);
+ // TODO: Change IDS_RS_MPC_NO_SEARCH_IN_FOLDER into IDS_RS_SEARCH_IN_FOLDER
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_NO_SEARCH_IN_FOLDER, !fUseSearchInFolder);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_USE_TIME_TOOLTIP, fUseTimeTooltip);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_TIME_TOOLTIP_POSITION, nTimeTooltipPosition);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_OSD_SIZE, nOSDSize);
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_MPC_OSD_FONT, strOSDFont);
+
+ // Associated types with icon or not...
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ASSOCIATED_WITH_ICON, fAssociatedWithIcons);
+ // Last Open Dir
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_LAST_OPEN_DIR, strLastOpenDir);
+
+ // CASIMIR666 : new settings
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_D3DFULLSCREEN, fD3DFullscreen);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_MONITOR_AUTOREFRESHRATE, fMonitorAutoRefreshRate);
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_COLOR_BRIGHTNESS, iBrightness);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_COLOR_CONTRAST, iContrast);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_COLOR_HUE, iHue);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_COLOR_SATURATION, iSaturation);
+
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_SHADERLIST, strShaderList);
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_SHADERLISTSCREENSPACE, strShaderListScreenSpace);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_TOGGLESHADER, (int)fToggleShader);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_TOGGLESHADERSSCREENSPACE, (int)fToggleShaderScreenSpace);
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SHOWOSD, (int)fShowOSD);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEEDLEDITOR, (int)fEnableEDLEditor);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LANGUAGE, language);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_FASTSEEK_KEYFRAME, (int)fFastSeek);
+
+ // Save analog capture settings
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_DEFAULT_CAPTURE, iDefaultCaptureDevice);
+ pApp->WriteProfileString(IDS_RS_CAPTURE, IDS_RS_VIDEO_DISP_NAME, strAnalogVideo);
+ pApp->WriteProfileString(IDS_RS_CAPTURE, IDS_RS_AUDIO_DISP_NAME, strAnalogAudio);
+ pApp->WriteProfileInt(IDS_RS_CAPTURE, IDS_RS_COUNTRY, iAnalogCountry);
+
+ // Save digital capture settings (BDA)
+ pApp->WriteProfileString(IDS_RS_DVB, IDS_RS_BDA_NETWORKPROVIDER, strBDANetworkProvider);
+ pApp->WriteProfileString(IDS_RS_DVB, IDS_RS_BDA_TUNER, strBDATuner);
+ pApp->WriteProfileString(IDS_RS_DVB, IDS_RS_BDA_RECEIVER, strBDAReceiver);
+ //pApp->WriteProfileString(IDS_RS_DVB, IDS_RS_BDA_STANDARD, strBDAStandard);
+ pApp->WriteProfileInt(IDS_RS_DVB, IDS_RS_BDA_SCAN_FREQ_START, iBDAScanFreqStart);
+ pApp->WriteProfileInt(IDS_RS_DVB, IDS_RS_BDA_SCAN_FREQ_END, iBDAScanFreqEnd);
+ pApp->WriteProfileInt(IDS_RS_DVB, IDS_RS_BDA_BANDWIDTH, iBDABandwidth);
+ pApp->WriteProfileInt(IDS_RS_DVB, IDS_RS_BDA_USE_OFFSET, fBDAUseOffset);
+ pApp->WriteProfileInt(IDS_RS_DVB, IDS_RS_BDA_OFFSET, iBDAOffset);
+ pApp->WriteProfileInt(IDS_RS_DVB, IDS_RS_BDA_IGNORE_ENCRYPTED_CHANNELS, fBDAIgnoreEncryptedChannels);
+ pApp->WriteProfileInt(IDS_RS_DVB, IDS_RS_DVB_LAST_CHANNEL, nDVBLastChannel);
+
+ int iChannel = 0;
+ POSITION pos = m_DVBChannels.GetHeadPosition();
+ while (pos) {
+ CString strTemp;
+ CString strChannel;
+ CDVBChannel& Channel = m_DVBChannels.GetNext(pos);
+ strTemp.Format(_T("%d"), iChannel);
+ pApp->WriteProfileString(IDS_RS_DVB, strTemp, Channel.ToString());
+ iChannel++;
+ }
+
+ // playback positions for last played DVDs
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_DVDPOS, (int)fRememberDVDPos);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_FILEPOS, (int)fRememberFilePos);
+ if (fKeepHistory) {
+ for (int i = 0; i < MAX_DVD_POSITION; i++) {
+ CString strDVDPos;
+ CString strValue;
+
+ strDVDPos.Format(_T("DVD Position %d"), i);
+ strValue = SerializeHex((BYTE*)&DvdPosition[i], sizeof(DVD_POSITION));
+ pApp->WriteProfileString(IDS_R_SETTINGS, strDVDPos, strValue);
+ }
+
+ // playback positions for last played files
+ for (int i = 0; i < MAX_FILE_POSITION; i++) {
+ CString strFilePos;
+ CString strValue;
+
+ strFilePos.Format(_T("File Name %d"), i);
+ pApp->WriteProfileString(IDS_R_SETTINGS, strFilePos, FilePosition[i].strFile);
+ strFilePos.Format(_T("File Position %d"), i);
+ strValue.Format(_T("%I64d"), FilePosition[i].llPosition);
+ pApp->WriteProfileString(IDS_R_SETTINGS, strFilePos, strValue);
+ }
+ }
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LASTFULLSCREEN, (int)fLastFullScreen);
+ // CASIMIR666 : end of new settings
+
+ {
+ for (unsigned int i = 0; ; i++) {
+ CString key;
+ key.Format(_T("%s\\%04u"), IDS_R_FILTERS, i);
+ int j = pApp->GetProfileInt(key, _T("Enabled"), -1);
+ pApp->WriteProfileString(key, NULL, NULL);
+ if (j < 0) {
+ break;
+ }
+ }
+ pApp->WriteProfileString(IDS_R_FILTERS, NULL, NULL);
+
+ unsigned int k = 0;
+ POSITION pos = m_filters.GetHeadPosition();
+ while (pos) {
+ FilterOverride* f = m_filters.GetNext(pos);
+
+ if (f->fTemporary) {
+ continue;
+ }
+
+ CString key;
+ key.Format(_T("%s\\%04u"), IDS_R_FILTERS, k);
+
+ pApp->WriteProfileInt(key, _T("SourceType"), (int)f->type);
+ pApp->WriteProfileInt(key, _T("Enabled"), (int)!f->fDisabled);
+ if (f->type == FilterOverride::REGISTERED) {
+ pApp->WriteProfileString(key, _T("DisplayName"), CString(f->dispname));
+ pApp->WriteProfileString(key, _T("Name"), f->name);
+ } else if (f->type == FilterOverride::EXTERNAL) {
+ pApp->WriteProfileString(key, _T("Path"), f->path);
+ pApp->WriteProfileString(key, _T("Name"), f->name);
+ pApp->WriteProfileString(key, _T("CLSID"), CStringFromGUID(f->clsid));
+ }
+ POSITION pos2 = f->backup.GetHeadPosition();
+ for (unsigned int i = 0; pos2; i++) {
+ CString val;
+ val.Format(_T("org%04u"), i);
+ pApp->WriteProfileString(key, val, CStringFromGUID(f->backup.GetNext(pos2)));
+ }
+ pos2 = f->guids.GetHeadPosition();
+ for (unsigned int i = 0; pos2; i++) {
+ CString val;
+ val.Format(_T("mod%04u"), i);
+ pApp->WriteProfileString(key, val, CStringFromGUID(f->guids.GetNext(pos2)));
+ }
+ pApp->WriteProfileInt(key, _T("LoadType"), f->iLoadType);
+ pApp->WriteProfileInt(key, _T("Merit"), f->dwMerit);
+
+ k++;
+ }
+ }
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_INTREALMEDIA, fIntRealMedia);
+ //pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REALMEDIARENDERLESS, fRealMediaRenderless);
+ //pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_QUICKTIMERENDERER, iQuickTimeRenderer);
+ //pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REALMEDIAFPS, *((DWORD*)&dRealMediaQuickTimeFPS));
+
+ pApp->WriteProfileString(IDS_R_SETTINGS _T("\\") IDS_RS_PNSPRESETS, NULL, NULL);
+ for (INT_PTR i = 0, j = m_pnspresets.GetCount(); i < j; i++) {
+ CString str;
+ str.Format(_T("Preset%Id"), i);
+ pApp->WriteProfileString(IDS_R_SETTINGS _T("\\") IDS_RS_PNSPRESETS, str, m_pnspresets[i]);
+ }
+
+ pApp->WriteProfileString(IDS_R_COMMANDS, NULL, NULL);
+ pos = wmcmds.GetHeadPosition();
+ for (int i = 0; pos;) {
+ wmcmd& wc = wmcmds.GetNext(pos);
+ if (wc.IsModified()) {
+ CString str;
+ str.Format(_T("CommandMod%d"), i);
+ CString str2;
+ str2.Format(_T("%d %x %x %s %d %u %u %u"),
+ wc.cmd, wc.fVirt, wc.key,
+ _T("\"") + CString(wc.rmcmd) + _T("\""), wc.rmrepcnt,
+ wc.mouse, wc.appcmd, wc.mouseFS);
+ pApp->WriteProfileString(IDS_R_COMMANDS, str, str2);
+ i++;
+ }
+ }
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_WINLIRC, fWinLirc);
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_WINLIRCADDR, strWinLircAddr);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_UICE, fUIce);
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_UICEADDR, strUIceAddr);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_GLOBALMEDIA, fGlobalMedia);
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_JUMPDISTS, nJumpDistS);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_JUMPDISTM, nJumpDistM);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_JUMPDISTL, nJumpDistL);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LIMITWINDOWPROPORTIONS, fLimitWindowProportions);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_NOTIFYMSN, fNotifyMSN);
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LASTUSEDPAGE, nLastUsedPage);
+
+ m_Formats.UpdateData(true);
+
+ // Internal filters
+ for (int f = 0; f < SRC_LAST; f++) {
+ pApp->WriteProfileInt(IDS_R_INTERNAL_FILTERS, SrcFiltersKeys[f], SrcFilters[f]);
+ }
+ for (int f = 0; f < TRA_LAST; f++) {
+ pApp->WriteProfileInt(IDS_R_INTERNAL_FILTERS, TraFiltersKeys[f], TraFilters[f]);
+ }
+ for (int f = 0; f < TRA_DXVA_LAST; f++) {
+ pApp->WriteProfileInt(IDS_R_INTERNAL_FILTERS, DXVAFiltersKeys[f], DXVAFilters[f]);
+ }
+ for (int f = 0; f < FFM_LAST; f++) {
+ pApp->WriteProfileInt(IDS_R_INTERNAL_FILTERS, FFMFiltersKeys[f], FFmpegFilters[f]);
+ }
+
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_LOGOFILE, strLogoFileName);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LOGOID, nLogoId);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LOGOEXT, fLogoExternal);
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_HIDECDROMSSUBMENU, fHideCDROMsSubMenu);
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_PRIORITY, dwPriority);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_LAUNCHFULLSCREEN, fLaunchfullscreen);
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEWEBSERVER, fEnableWebServer);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERPORT, nWebServerPort);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERPRINTDEBUGINFO, fWebServerPrintDebugInfo);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERUSECOMPRESSION, fWebServerUseCompression);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERLOCALHOSTONLY, fWebServerLocalhostOnly);
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_WEBROOT, strWebRoot);
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_WEBDEFINDEX, strWebDefIndex);
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_WEBSERVERCGI, strWebServerCGI);
+
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_SNAPSHOTPATH, strSnapShotPath);
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_SNAPSHOTEXT, strSnapShotExt);
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_THUMBROWS, iThumbRows);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_THUMBCOLS, iThumbCols);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_THUMBWIDTH, iThumbWidth);
+
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_RS_ISDB, strISDb);
+
+ pApp->WriteProfileString(IDS_R_SHADERS, NULL, NULL);
+ pApp->WriteProfileInt(IDS_R_SHADERS, IDS_R_SHADERS_INITIALIZED, 1);
+ pApp->WriteProfileString(IDS_R_SHADERS, IDS_R_SHADERS_COMBINE, strShadercombine);
+ pApp->WriteProfileString(IDS_R_SHADERS, IDS_R_SHADERS_COMBINESCREENSPACE, strShadercombineScreenSpace);
+
+
+ pos = m_shaders.GetHeadPosition();
+ for (int i = 0; pos; i++) {
+ const Shader& s = m_shaders.GetNext(pos);
+
+ if (!s.label.IsEmpty()) {
+ CString index;
+ index.Format(_T("%d"), i);
+ CString srcdata = s.srcdata;
+ srcdata.Replace(_T("\r"), _T(""));
+ srcdata.Replace(_T("\n"), _T("\\n"));
+ srcdata.Replace(_T("\t"), _T("\\t"));
+ AfxGetApp()->WriteProfileString(IDS_R_SHADERS, index, s.label + _T("|") + s.target + _T("|") + srcdata);
+ }
+ }
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_REMAINING_TIME, fRemainingTime);
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_UPDATER_AUTO_CHECK, nUpdaterAutoCheck);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_UPDATER_DELAY, nUpdaterDelay);
+
+ if (pApp->m_pszRegistryKey) {
+ // WINBUG: on win2k this would crash WritePrivateProfileString
+ pApp->WriteProfileInt(_T(""), _T(""), pApp->GetProfileInt(_T(""), _T(""), 0) ? 0 : 1);
+ }
+ } else {
+ if (fInitialized) {
+ return;
+ }
+
+ iDXVer = 0;
+ CRegKey dxver;
+ if (ERROR_SUCCESS == dxver.Open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\DirectX"), KEY_READ)) {
+ CString str;
+ ULONG len = 64;
+ if (ERROR_SUCCESS == dxver.QueryStringValue(_T("Version"), str.GetBuffer(len), &len)) {
+ str.ReleaseBuffer(len);
+ int ver[4];
+ _stscanf_s(str, _T("%d.%d.%d.%d"), ver + 0, ver + 1, ver + 2, ver + 3);
+ iDXVer = ver[1];
+ }
+ }
+
+ // Set interface language first!
+ language = (LANGID)pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LANGUAGE, -1);
+ if (language == (LANGID) - 1) {
+ CMPlayerCApp::SetDefaultLanguage();
+ } else if (language != 0) {
+ if (language <= 23) { // Here for compatibility with old settings
+ CMPlayerCApp::SetLanguage(CMPlayerCApp::GetLanguageResourceByResourceID(language + ID_LANGUAGE_ENGLISH));
+ } else {
+ CMPlayerCApp::SetLanguage(CMPlayerCApp::GetLanguageResourceByLocaleID(language));
+ }
+ }
+
+ CreateCommands();
+
+ iCaptionMenuMode = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_HIDECAPTIONMENU, MODE_SHOWCAPTIONMENU);
+ fHideNavigation = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_HIDENAVIGATION, 0);
+ nCS = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_CONTROLSTATE, CS_SEEKBAR | CS_TOOLBAR | CS_STATUSBAR);
+ iDefaultVideoSize = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DEFAULTVIDEOFRAME, DVS_FROMINSIDE);
+ fKeepAspectRatio = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_KEEPASPECTRATIO, TRUE);
+ fCompMonDeskARDiff = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_COMPMONDESKARDIFF, FALSE);
+ nVolume = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_VOLUME, 100);
+ nBalance = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_BALANCE, 0);
+ fMute = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MUTE, 0);
+ nLoops = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LOOPNUM, 1);
+ fLoopForever = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LOOP, 0);
+ fRewind = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_REWIND, FALSE);
+ iZoomLevel = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ZOOM, 1);
+ iDSVideoRendererType = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DSVIDEORENDERERTYPE, (SysVersion::IsVistaOrLater() ? (HasEVR() ? VIDRNDT_DS_EVR_CUSTOM : VIDRNDT_DS_DEFAULT) : VIDRNDT_DS_VMR7WINDOWED));
+ iRMVideoRendererType = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_RMVIDEORENDERERTYPE, VIDRNDT_RM_DEFAULT);
+ iQTVideoRendererType = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_QTVIDEORENDERERTYPE, VIDRNDT_QT_DEFAULT);
+
+ UpdateRenderersData(false);
+
+ strAudioRendererDisplayName = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_AUDIORENDERERTYPE, _T(""));
+ fAutoloadAudio = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOLOADAUDIO, TRUE);
+ fAutoloadSubtitles = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOLOADSUBTITLES, !IsVSFilterInstalled() || (SysVersion::IsVistaOrLater() && HasEVR()));
+ strSubtitlesLanguageOrder = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_SUBTITLESLANGORDER, _T(""));
+ strAudiosLanguageOrder = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_AUDIOSLANGORDER, _T(""));
+ fBlockVSFilter = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_BLOCKVSFILTER, TRUE);
+ fEnableWorkerThreadForOpening = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEWORKERTHREADFOROPENING, TRUE);
+ fReportFailedPins = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_REPORTFAILEDPINS, TRUE);
+ fAllowMultipleInst = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MULTIINST, 0);
+ iTitleBarTextStyle = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_TITLEBARTEXTSTYLE, 1);
+ fTitleBarTextTitle = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_TITLEBARTEXTTITLE, FALSE);
+ iOnTop = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ONTOP, 0);
+ fTrayIcon = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_TRAYICON, 0);
+ fRememberZoomLevel = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOZOOM, 1);
+ fShowBarsWhenFullScreen = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_FULLSCREENCTRLS, 1);
+ nShowBarsWhenFullScreenTimeOut = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_FULLSCREENCTRLSTIMEOUT, 0);
+
+ //Multi-monitor code
+ strFullScreenMonitor = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_FULLSCREENMONITOR, _T(""));
+ // Prevent Minimize when in Fullscreen mode on non default monitor
+ fPreventMinimize = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_PREVENT_MINIMIZE, 0);
+ fUseWin7TaskBar = SysVersion::Is7OrLater() ? !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_WIN7TASKBAR, TRUE) : FALSE;
+ fExitAfterPlayback = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_EXIT_AFTER_PB, 0);
+ fNextInDirAfterPlayback = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_NEXT_AFTER_PB, 0);
+ // TODO: Change IDS_RS_MPC_NO_SEARCH_IN_FOLDER into IDS_RS_SEARCH_IN_FOLDER
+ fUseSearchInFolder = !pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_NO_SEARCH_IN_FOLDER, 0);
+ fUseTimeTooltip = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_USE_TIME_TOOLTIP, TRUE);
+ nTimeTooltipPosition = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_TIME_TOOLTIP_POSITION, TIME_TOOLTIP_ABOVE_SEEKBAR);
+ nOSDSize = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MPC_OSD_SIZE, SysVersion::IsVistaOrLater() ? 18 : 20);
+ if (SysVersion::IsVistaOrLater()) {
+ LOGFONT lf;
+ GetMessageFont(&lf);
+ strOSDFont = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_MPC_OSD_FONT, lf.lfFaceName);
+ } else {
+ strOSDFont = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_MPC_OSD_FONT, _T("Arial"));
+ }
+
+ // Associated types with icon or not...
+ fAssociatedWithIcons = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ASSOCIATED_WITH_ICON, 1);
+ // Last Open Dir
+ strLastOpenDir = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_LAST_OPEN_DIR, _T("C:\\"));
+
+ if (pApp->GetProfileBinary(IDS_R_SETTINGS, IDS_RS_FULLSCREENRES, &ptr, &len)) {
+ if (len == sizeof(AChFR)) {
+ memcpy(&AutoChangeFullscrRes, ptr, sizeof(AChFR));
+ } else {
+ AutoChangeFullscrRes.bEnabled = false;
+ }
+ delete [] ptr;
+ } else {
+ AutoChangeFullscrRes.bEnabled = false;
+ }
+
+ fExitFullScreenAtTheEnd = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_EXITFULLSCREENATTHEEND, 1);
+ fRestoreResAfterExit = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_RESTORERESAFTEREXIT, 1);
+ fRememberWindowPos = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_REMEMBERWINDOWPOS, 0);
+ fRememberWindowSize = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_REMEMBERWINDOWSIZE, 0);
+ CString str = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_PANSCANZOOM, _T(""));
+ if (_stscanf_s(str, _T("%f,%f"), &dZoomX, &dZoomY) == 2 &&
+ dZoomX >= 0.196 && dZoomX <= 3.06 && // 0.196 = 0.2 / 1.02
+ dZoomY >= 0.196 && dZoomY <= 3.06) { // 3.06 = 3 * 1.02
+ fSavePnSZoom = true;
+ } else {
+ fSavePnSZoom = false;
+ dZoomX = 1.0;
+ dZoomY = 1.0;
+ }
+ fSnapToDesktopEdges = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SNAPTODESKTOPEDGES, 0);
+ sizeAspectRatio.cx = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ASPECTRATIO_X, 0);
+ sizeAspectRatio.cy = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ASPECTRATIO_Y, 0);
+ fKeepHistory = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_KEEPHISTORY, 1);
+ if (pApp->GetProfileBinary(IDS_R_SETTINGS, IDS_RS_LASTWINDOWRECT, &ptr, &len)) {
+ if (len == sizeof(CRect)) {
+ memcpy(&rcLastWindowPos, ptr, sizeof(CRect));
+ } else {
+ fRememberWindowPos = false;
+ }
+ delete [] ptr;
+ } else {
+ fRememberWindowPos = false;
+ }
+ nLastWindowType = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LASTWINDOWTYPE, SIZE_RESTORED);
+
+ bShufflePlaylistItems = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SHUFFLEPLAYLISTITEMS, FALSE);
+ bRememberPlaylistItems = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_REMEMBERPLAYLISTITEMS, TRUE);
+ bHidePlaylistFullScreen = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_HIDEPLAYLISTFULLSCREEN, FALSE);
+ bFavRememberPos = !!pApp->GetProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_REMEMBERPOS, TRUE);
+ bFavRelativeDrive = !!pApp->GetProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_RELATIVEDRIVE, FALSE);
+
+ strDVDPath = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_DVDPATH, _T(""));
+ fUseDVDPath = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_USEDVDPATH, 0);
+ idMenuLang = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MENULANG, 0);
+ idAudioLang = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIOLANG, 0);
+ idSubtitlesLang = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SUBTITLESLANG, 0);
+ fAutoSpeakerConf = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUTOSPEAKERCONF, 1);
+ fClosedCaptions = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_CLOSEDCAPTIONS, 0);
+ // TODO: rename subdefstyle -> defStyle, IDS_RS_SPLOGFONT -> IDS_RS_SPSTYLE
+ {
+ CString temp = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_SPLOGFONT, _T(""));
+ subdefstyle <<= temp;
+ if (temp == _T("")) {
+ subdefstyle.relativeTo = 1; //default "Position subtitles relative to the video frame" option is checked
+ }
+ }
+ fOverridePlacement = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SPOVERRIDEPLACEMENT, 0);
+ nHorPos = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SPHORPOS, 50);
+ nVerPos = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SPVERPOS, 90);
+ nSubDelayInterval = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SUBDELAYINTERVAL, 500);
+
+ fEnableSubtitles = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLESUBTITLES, TRUE);
+ fPrioritizeExternalSubtitles = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_PRIORITIZEEXTERNALSUBTITLES, TRUE);
+ fDisableInternalSubtitles = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DISABLEINTERNALSUBTITLES, FALSE);
+ strSubtitlePaths = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_SUBTITLEPATHS, DEFAULT_SUBTITLE_PATHS);
+ fUseDefaultSubtitlesStyle = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_USEDEFAULTSUBTITLESSTYLE, FALSE);
+ fEnableAudioSwitcher = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEAUDIOSWITCHER, TRUE);
+ fAudioTimeShift = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEAUDIOTIMESHIFT, 0);
+ iAudioTimeShift = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIOTIMESHIFT, 0);
+ fDownSampleTo441 = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DOWNSAMPLETO441, 0);
+ fCustomChannelMapping = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_CUSTOMCHANNELMAPPING, 0);
+
+ BOOL bResult = pApp->GetProfileBinary(IDS_R_SETTINGS, IDS_RS_SPEAKERTOCHANNELMAPPING, &ptr, &len);
+ if (bResult && len == sizeof(pSpeakerToChannelMap)) {
+ memcpy(pSpeakerToChannelMap, ptr, sizeof(pSpeakerToChannelMap));
+ } else {
+ memset(pSpeakerToChannelMap, 0, sizeof(pSpeakerToChannelMap));
+ for (int j = 0; j < 18; j++)
+ for (int i = 0; i <= j; i++) {
+ pSpeakerToChannelMap[j][i] = 1 << i;
+ }
+
+ pSpeakerToChannelMap[0][0] = 1 << 0;
+ pSpeakerToChannelMap[0][1] = 1 << 0;
+
+ pSpeakerToChannelMap[3][0] = 1 << 0;
+ pSpeakerToChannelMap[3][1] = 1 << 1;
+ pSpeakerToChannelMap[3][2] = 0;
+ pSpeakerToChannelMap[3][3] = 0;
+ pSpeakerToChannelMap[3][4] = 1 << 2;
+ pSpeakerToChannelMap[3][5] = 1 << 3;
+
+ pSpeakerToChannelMap[4][0] = 1 << 0;
+ pSpeakerToChannelMap[4][1] = 1 << 1;
+ pSpeakerToChannelMap[4][2] = 1 << 2;
+ pSpeakerToChannelMap[4][3] = 0;
+ pSpeakerToChannelMap[4][4] = 1 << 3;
+ pSpeakerToChannelMap[4][5] = 1 << 4;
+ }
+ if (bResult) {
+ delete [] ptr;
+ }
+
+ fAudioNormalize = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIONORMALIZE, FALSE);
+ fAudioNormalizeRecover = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_AUDIONORMALIZERECOVER, TRUE);
+ dAudioBoost_dB = (float)_tstof(pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_AUDIOBOOST, _T("0")));
+ if (dAudioBoost_dB < 0 || dAudioBoost_dB > 10) {
+ dAudioBoost_dB = 0;
+ }
+
+ nSpeakerChannels = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SPEAKERCHANNELS, 2);
+
+ {
+ for (unsigned int i = 0; ; i++) {
+ CString key;
+ key.Format(_T("%s\\%04u"), IDS_R_FILTERS, i);
+
+ CAutoPtr<FilterOverride> f(DNew FilterOverride);
+
+ f->fDisabled = !pApp->GetProfileInt(key, _T("Enabled"), 0);
+
+ UINT j = pApp->GetProfileInt(key, _T("SourceType"), -1);
+ if (j == 0) {
+ f->type = FilterOverride::REGISTERED;
+ f->dispname = CStringW(pApp->GetProfileString(key, _T("DisplayName"), _T("")));
+ f->name = pApp->GetProfileString(key, _T("Name"), _T(""));
+ } else if (j == 1) {
+ f->type = FilterOverride::EXTERNAL;
+ f->path = pApp->GetProfileString(key, _T("Path"), _T(""));
+ f->name = pApp->GetProfileString(key, _T("Name"), _T(""));
+ f->clsid = GUIDFromCString(pApp->GetProfileString(key, _T("CLSID"), _T("")));
+ } else {
+ pApp->WriteProfileString(key, NULL, 0);
+ break;
+ }
+
+ f->backup.RemoveAll();
+ for (unsigned int i = 0; ; i++) {
+ CString val;
+ val.Format(_T("org%04u"), i);
+ CString guid = pApp->GetProfileString(key, val, _T(""));
+ if (guid.IsEmpty()) {
+ break;
+ }
+ f->backup.AddTail(GUIDFromCString(guid));
+ }
+
+ f->guids.RemoveAll();
+ for (unsigned int i = 0; ; i++) {
+ CString val;
+ val.Format(_T("mod%04u"), i);
+ CString guid = pApp->GetProfileString(key, val, _T(""));
+ if (guid.IsEmpty()) {
+ break;
+ }
+ f->guids.AddTail(GUIDFromCString(guid));
+ }
+
+ f->iLoadType = (int)pApp->GetProfileInt(key, _T("LoadType"), -1);
+ if (f->iLoadType < 0) {
+ break;
+ }
+
+ f->dwMerit = pApp->GetProfileInt(key, _T("Merit"), MERIT_DO_NOT_USE + 1);
+
+ m_filters.AddTail(f);
+ }
+ }
+
+ fIntRealMedia = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_INTREALMEDIA, 0);
+ //fRealMediaRenderless = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_REALMEDIARENDERLESS, 0);
+ //iQuickTimeRenderer = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_QUICKTIMERENDERER, 2);
+ //dRealMediaQuickTimeFPS = 25.0;
+ //*((DWORD*)&dRealMediaQuickTimeFPS) = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_REALMEDIAFPS, *((DWORD*)&dRealMediaQuickTimeFPS));
+
+ m_pnspresets.RemoveAll();
+ for (int i = 0; i < (ID_PANNSCAN_PRESETS_END - ID_PANNSCAN_PRESETS_START); i++) {
+ CString str;
+ str.Format(_T("Preset%d"), i);
+ str = pApp->GetProfileString(IDS_R_SETTINGS _T("\\") IDS_RS_PNSPRESETS, str, _T(""));
+ if (str.IsEmpty()) {
+ break;
+ }
+ m_pnspresets.Add(str);
+ }
+
+ if (m_pnspresets.IsEmpty()) {
+ double _4p3 = 4.0 / 3.0;
+ double _16p9 = 16.0 / 9.0;
+ double _185p1 = 1.85 / 1.0;
+ double _235p1 = 2.35 / 1.0;
+ UNREFERENCED_PARAMETER(_185p1);
+
+ CString str;
+ str.Format(IDS_SCALE_16_9, 0.5, 0.5, _4p3 / _4p3, _16p9 / _4p3);
+ m_pnspresets.Add(str);
+ str.Format(IDS_SCALE_WIDESCREEN, 0.5, 0.5, _16p9 / _4p3, _16p9 / _4p3);
+ m_pnspresets.Add(str);
+ str.Format(IDS_SCALE_ULTRAWIDE, 0.5, 0.5, _235p1 / _4p3, _235p1 / _4p3);
+ m_pnspresets.Add(str);
+ }
+
+ for (int i = 0; i < wmcmds.GetCount(); i++) {
+ CString str;
+ str.Format(_T("CommandMod%d"), i);
+ str = pApp->GetProfileString(IDS_R_COMMANDS, str, _T(""));
+ if (str.IsEmpty()) {
+ break;
+ }
+ int cmd, fVirt, key, repcnt;
+ UINT mouse, mouseFS, appcmd;
+ TCHAR buff[128];
+ int n;
+ if (5 > (n = _stscanf_s(str, _T("%d %x %x %s %d %u %u %u"), &cmd, &fVirt, &key, buff, _countof(buff), &repcnt, &mouse, &appcmd, &mouseFS))) {
+ break;
+ }
+ if (POSITION pos = wmcmds.Find(cmd)) {
+ wmcmd& wc = wmcmds.GetAt(pos);
+ wc.cmd = cmd;
+ wc.fVirt = fVirt;
+ wc.key = key;
+ if (n >= 6) {
+ wc.mouse = mouse;
+ }
+ if (n >= 7) {
+ wc.appcmd = appcmd;
+ }
+ // If there is no distinct bindings for windowed and
+ // fullscreen modes we use the same for both.
+ wc.mouseFS = (n >= 8) ? mouseFS : wc.mouse;
+ wc.rmcmd = CStringA(buff).Trim('\"');
+ wc.rmrepcnt = repcnt;
+ }
+ }
+
+ CAtlArray<ACCEL> pAccel;
+ pAccel.SetCount(wmcmds.GetCount());
+ POSITION pos = wmcmds.GetHeadPosition();
+ for (int i = 0; pos; i++) {
+ pAccel[i] = wmcmds.GetNext(pos);
+ }
+ hAccel = CreateAcceleratorTable(pAccel.GetData(), (int)pAccel.GetCount());
+
+ strWinLircAddr = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_WINLIRCADDR, _T("127.0.0.1:8765"));
+ fWinLirc = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_WINLIRC, 0);
+ strUIceAddr = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_UICEADDR, _T("127.0.0.1:1234"));
+ fUIce = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_UICE, 0);
+ fGlobalMedia = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_GLOBALMEDIA, 1);
+
+ nJumpDistS = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_JUMPDISTS, DEFAULT_JUMPDISTANCE_1);
+ nJumpDistM = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_JUMPDISTM, DEFAULT_JUMPDISTANCE_2);
+ nJumpDistL = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_JUMPDISTL, DEFAULT_JUMPDISTANCE_3);
+ fLimitWindowProportions = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LIMITWINDOWPROPORTIONS, FALSE);
+ fNotifyMSN = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_NOTIFYMSN, FALSE);
+
+ m_Formats.UpdateData(false);
+
+ // Internal filters
+ for (int f = 0; f < SRC_LAST; f++) {
+ SrcFilters[f] = !!pApp->GetProfileInt(IDS_R_INTERNAL_FILTERS, SrcFiltersKeys[f], 1);
+ }
+ for (int f = 0; f < TRA_LAST; f++) {
+ TraFilters[f] = !!pApp->GetProfileInt(IDS_R_INTERNAL_FILTERS, TraFiltersKeys[f], 1);
+ }
+ for (int f = 0; f < TRA_DXVA_LAST; f++) {
+ DXVAFilters[f] = !!pApp->GetProfileInt(IDS_R_INTERNAL_FILTERS, DXVAFiltersKeys[f], 1);
+ }
+ for (int f = 0; f < FFM_LAST; f++) {
+ FFmpegFilters[f] = !!pApp->GetProfileInt(IDS_R_INTERNAL_FILTERS, FFMFiltersKeys[f], 1);
+ }
+ if (!TRA_DXVA_LAST) { DXVAFilters[0] = FALSE; }
+ if (!FFM_LAST) { FFmpegFilters[0] = FALSE; }
+
+ strLogoFileName = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_LOGOFILE, _T(""));
+ nLogoId = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LOGOID, DEF_LOGO);
+ fLogoExternal = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LOGOEXT, 0);
+
+ fHideCDROMsSubMenu = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_HIDECDROMSSUBMENU, 0);
+
+ dwPriority = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_PRIORITY, NORMAL_PRIORITY_CLASS);
+ ::SetPriorityClass(::GetCurrentProcess(), dwPriority);
+ fLaunchfullscreen = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LAUNCHFULLSCREEN, FALSE);
+
+ fEnableWebServer = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEWEBSERVER, FALSE);
+ nWebServerPort = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERPORT, 13579);
+ fWebServerPrintDebugInfo = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERPRINTDEBUGINFO, FALSE);
+ fWebServerUseCompression = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERUSECOMPRESSION, TRUE);
+ fWebServerLocalhostOnly = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_WEBSERVERLOCALHOSTONLY, FALSE);
+ strWebRoot = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_WEBROOT, _T("*./webroot"));
+ strWebDefIndex = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_WEBDEFINDEX, _T("index.html;index.php"));
+ strWebServerCGI = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_WEBSERVERCGI, _T(""));
+
+ CString MyPictures;
+
+ CRegKey key;
+ // grrrrr
+ // if (!SHGetSpecialFolderPath(NULL, MyPictures.GetBufferSetLength(_MAX_PATH), CSIDL_MYPICTURES, TRUE)) MyPictures.Empty();
+ // else MyPictures.ReleaseBuffer();
+ if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"), KEY_READ)) {
+ ULONG len = _MAX_PATH;
+ if (ERROR_SUCCESS == key.QueryStringValue(_T("My Pictures"), MyPictures.GetBuffer(_MAX_PATH), &len)) {
+ MyPictures.ReleaseBufferSetLength(len);
+ } else {
+ MyPictures.Empty();
+ }
+ }
+ strSnapShotPath = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_SNAPSHOTPATH, MyPictures);
+ strSnapShotExt = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_SNAPSHOTEXT, _T(".jpg"));
+
+ iThumbRows = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_THUMBROWS, 4);
+ iThumbCols = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_THUMBCOLS, 4);
+ iThumbWidth = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_THUMBWIDTH, 1024);
+
+ strISDb = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_ISDB, _T("www.opensubtitles.org/isdb"));
+
+ nLastUsedPage = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LASTUSEDPAGE, 0);
+ //
+
+ m_shaders.RemoveAll();
+
+ CAtlStringMap<UINT> shaders;
+
+ shaders[_T("16-235 -> 0-255 [SD][HD]")] = IDF_SHADER_LEVELS;
+ shaders[_T("16-235 -> 0-255 [SD]")] = IDF_SHADER_LEVELS2;
+ shaders[_T("0-255 -> 16-235")] = IDF_SHADER_LEVELS3;
+ shaders[_T("BT.601 -> BT.709")] = IDF_SHADER_BT601_BT709;
+ shaders[_T("contour")] = IDF_SHADER_CONTOUR;
+ shaders[_T("deinterlace (blend)")] = IDF_SHADER_DEINTERLACE;
+ shaders[_T("edge sharpen")] = IDF_SHADER_EDGE_SHARPEN;
+ shaders[_T("emboss")] = IDF_SHADER_EMBOSS;
+ shaders[_T("grayscale")] = IDF_SHADER_GRAYSCALE;
+ shaders[_T("invert")] = IDF_SHADER_INVERT;
+ shaders[_T("letterbox")] = IDF_SHADER_LETTERBOX;
+ shaders[_T("nightvision")] = IDF_SHADER_NIGHTVISION;
+ shaders[_T("procamp")] = IDF_SHADER_PROCAMP;
+ shaders[_T("sharpen")] = IDF_SHADER_SHARPEN;
+ shaders[_T("sharpen complex")] = IDF_SHADER_SHARPEN_COMPLEX;
+ shaders[_T("sharpen complex 2")] = IDF_SHADER_SHARPEN_COMPLEX2;
+ shaders[_T("sphere")] = IDF_SHADER_SPHERE;
+ shaders[_T("spotlight")] = IDF_SHADER_SPOTLIGHT;
+ shaders[_T("wave")] = IDF_SHADER_WAVE;
+ shaders[_T("denoise")] = IDF_SHADER_DENOISE;
+ shaders[_T("YV12 Chroma Upsampling")] = IDF_SHADER_YV12CHROMAUP;
+
+ for (int iShader = 0; ; iShader++) {
+ CString str;
+ str.Format(_T("%d"), iShader);
+ str = pApp->GetProfileString(IDS_R_SHADERS, str);
+
+ CAtlList<CString> sl;
+ CString label = Explode(str, sl, '|');
+ if (label.IsEmpty()) {
+ break;
+ }
+ if (sl.GetCount() < 3) {
+ continue;
+ }
+
+ Shader s;
+ s.label = sl.RemoveHead();
+ s.target = sl.RemoveHead();
+ s.srcdata = sl.RemoveHead();
+ s.srcdata.Replace(_T("\\n"), _T("\n"));
+ s.srcdata.Replace(_T("\\t"), _T("\t"));
+ m_shaders.AddTail(s);
+
+ shaders.RemoveKey(s.label);
+ }
+
+ pos = shaders.GetStartPosition();
+ while (pos) {
+ CAtlStringMap<UINT>::CPair* pPair = shaders.GetNext(pos);
+
+ CStringA srcdata;
+ if (LoadResource(pPair->m_value, srcdata, _T("FILE"))) {
+ Shader s;
+ s.label = pPair->m_key;
+
+ // Select minimum version for each shader!
+ switch (pPair->m_value) {
+ case IDF_SHADER_DENOISE :
+ s.target = _T("ps_3_0");
+ break;
+ case IDF_SHADER_SHARPEN_COMPLEX2 :
+ s.target = _T("ps_2_a");
+ break;
+ default :
+ s.target = _T("ps_2_0");
+ break;
+ }
+ s.srcdata = CString(srcdata);
+ m_shaders.AddTail(s);
+ }
+ }
+
+ // CASIMIR666 : new settings
+ fD3DFullscreen = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_D3DFULLSCREEN, FALSE);
+ fMonitorAutoRefreshRate = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MONITOR_AUTOREFRESHRATE, FALSE);
+
+ iBrightness = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_COLOR_BRIGHTNESS, 0);
+ iContrast = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_COLOR_CONTRAST, 0);
+ iHue = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_COLOR_HUE, 0);
+ iSaturation = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_COLOR_SATURATION, 0);
+
+ strShaderList = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_SHADERLIST, _T(""));
+ strShaderListScreenSpace = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_SHADERLISTSCREENSPACE, _T(""));
+ fToggleShader = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_TOGGLESHADER, 0);
+ fToggleShaderScreenSpace = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_TOGGLESHADERSSCREENSPACE, 0);
+
+ fShowOSD = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SHOWOSD, 1);
+ fEnableEDLEditor = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ENABLEEDLEDITOR, FALSE);
+ fFastSeek = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_FASTSEEK_KEYFRAME, FALSE);
+
+ // Save analog capture settings
+ iDefaultCaptureDevice = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DEFAULT_CAPTURE, 0);
+ strAnalogVideo = pApp->GetProfileString(IDS_RS_CAPTURE, IDS_RS_VIDEO_DISP_NAME, _T("dummy"));
+ strAnalogAudio = pApp->GetProfileString(IDS_RS_CAPTURE, IDS_RS_AUDIO_DISP_NAME, _T("dummy"));
+ iAnalogCountry = pApp->GetProfileInt(IDS_RS_CAPTURE, IDS_RS_COUNTRY, 1);
+
+ strBDANetworkProvider = pApp->GetProfileString(IDS_RS_DVB, IDS_RS_BDA_NETWORKPROVIDER, _T(""));
+ strBDATuner = pApp->GetProfileString(IDS_RS_DVB, IDS_RS_BDA_TUNER, _T(""));
+ strBDAReceiver = pApp->GetProfileString(IDS_RS_DVB, IDS_RS_BDA_RECEIVER, _T(""));
+ //sBDAStandard = pApp->GetProfileString(IDS_RS_DVB, IDS_RS_BDA_STANDARD, _T(""));
+ iBDAScanFreqStart = pApp->GetProfileInt(IDS_RS_DVB, IDS_RS_BDA_SCAN_FREQ_START, 474000);
+ iBDAScanFreqEnd = pApp->GetProfileInt(IDS_RS_DVB, IDS_RS_BDA_SCAN_FREQ_END, 858000);
+ iBDABandwidth = pApp->GetProfileInt(IDS_RS_DVB, IDS_RS_BDA_BANDWIDTH, 8);
+ fBDAUseOffset = !!pApp->GetProfileInt(IDS_RS_DVB, IDS_RS_BDA_USE_OFFSET, 0);
+ iBDAOffset = pApp->GetProfileInt(IDS_RS_DVB, IDS_RS_BDA_OFFSET, 166);
+ fBDAIgnoreEncryptedChannels = !!pApp->GetProfileInt(IDS_RS_DVB, IDS_RS_BDA_IGNORE_ENCRYPTED_CHANNELS, 0);
+ nDVBLastChannel = pApp->GetProfileInt(IDS_RS_DVB, IDS_RS_DVB_LAST_CHANNEL, 1);
+
+ for (int iChannel = 0; ; iChannel++) {
+ CString strTemp;
+ CString strChannel;
+ CDVBChannel Channel;
+ strTemp.Format(_T("%d"), iChannel);
+ strChannel = pApp->GetProfileString(IDS_RS_DVB, strTemp, _T(""));
+ if (strChannel.IsEmpty()) {
+ break;
+ }
+ Channel.FromString(strChannel);
+ m_DVBChannels.AddTail(Channel);
+ }
+
+ // playback positions for last played DVDs
+ fRememberDVDPos = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DVDPOS, 0);
+ nCurrentDvdPosition = -1;
+ memset(DvdPosition, 0, sizeof(DvdPosition));
+ for (int i = 0; i < MAX_DVD_POSITION; i++) {
+ CString strDVDPos;
+ CString strValue;
+
+ strDVDPos.Format(_T("DVD Position %d"), i);
+ strValue = pApp->GetProfileString(IDS_R_SETTINGS, strDVDPos, _T(""));
+ if (strValue.GetLength() / 2 == sizeof(DVD_POSITION)) {
+ DeserializeHex(strValue, (BYTE*)&DvdPosition[i], sizeof(DVD_POSITION));
+ }
+ }
+
+ // playback positions for last played files
+ fRememberFilePos = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_FILEPOS, 0);
+ nCurrentFilePosition = -1;
+ for (int i = 0; i < MAX_FILE_POSITION; i++) {
+ CString strFilePos;
+ CString strValue;
+
+ strFilePos.Format(_T("File Name %d"), i);
+ FilePosition[i].strFile = pApp->GetProfileString(IDS_R_SETTINGS, strFilePos, _T(""));
+
+ strFilePos.Format(_T("File Position %d"), i);
+ strValue = pApp->GetProfileString(IDS_R_SETTINGS, strFilePos, _T(""));
+ FilePosition[i].llPosition = _tstoi64(strValue);
+ }
+
+ fLastFullScreen = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LASTFULLSCREEN, 0);
+
+ // TODO: sort shaders by label
+
+ strShadercombine = pApp->GetProfileString(IDS_R_SHADERS, IDS_R_SHADERS_COMBINE, _T(""));
+ strShadercombineScreenSpace = pApp->GetProfileString(IDS_R_SHADERS, IDS_R_SHADERS_COMBINESCREENSPACE, _T(""));
+
+ fRemainingTime = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_REMAINING_TIME, FALSE);
+
+ nUpdaterAutoCheck = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_UPDATER_AUTO_CHECK, AUTOUPDATE_UNKNOWN);
+ nUpdaterDelay = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_UPDATER_DELAY, 7);
+ if (nUpdaterDelay < 1) {
+ nUpdaterDelay = 1;
+ }
+
+ if (fLaunchfullscreen) {
+ nCLSwitches |= CLSW_FULLSCREEN;
+ }
+
+ fInitialized = true;
+ }
}
bool CAppSettings::GetAllowMultiInst() const
{
- return !!AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MULTIINST, 0);
+ return !!AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, IDS_RS_MULTIINST, 0);
}
void CAppSettings::UpdateRenderersData(bool fSave)
{
- CWinApp* pApp = AfxGetApp();
- CRenderersSettings& r = m_RenderersSettings;
-
- if (fSave) {
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_APSURACEFUSAGE, r.iAPSurfaceUsage);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_DX9_RESIZER, r.iDX9Resizer);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_VMR9MIXERMODE, r.fVMR9MixerMode);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_VMR9MIXERYUV, r.fVMR9MixerYUV);
-
- CRenderersSettings::CRendererSettingsEVR& rendererSettings = r.m_RenderSettings;
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRAlternateVSync"), rendererSettings.fVMR9AlterativeVSync);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRVSyncOffset"), rendererSettings.iVMR9VSyncOffset);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRVSyncAccurate2"), rendererSettings.iVMR9VSyncAccurate);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRFullscreenGUISupport"), rendererSettings.iVMR9FullscreenGUISupport);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRVSync"), rendererSettings.iVMR9VSync);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRDisableDesktopComposition"), rendererSettings.iVMRDisableDesktopComposition);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRFullFloatingPointProcessing"), rendererSettings.iVMR9FullFloatingPointProcessing);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRHalfFloatingPointProcessing"), rendererSettings.iVMR9HalfFloatingPointProcessing);
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRColorManagementEnable"), rendererSettings.iVMR9ColorManagementEnable);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRColorManagementInput"), rendererSettings.iVMR9ColorManagementInput);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRColorManagementAmbientLight"), rendererSettings.iVMR9ColorManagementAmbientLight);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRColorManagementIntent"), rendererSettings.iVMR9ColorManagementIntent);
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("EVROutputRange"), rendererSettings.iEVROutputRange);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("EVRHighColorRes"), rendererSettings.iEVRHighColorResolution);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("EVRForceInputHighColorRes"), rendererSettings.iEVRForceInputHighColorResolution);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("EVREnableFrameTimeCorrection"), rendererSettings.iEVREnableFrameTimeCorrection);
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRFlushGPUBeforeVSync"), rendererSettings.iVMRFlushGPUBeforeVSync);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRFlushGPUAfterPresent"), rendererSettings.iVMRFlushGPUAfterPresent);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRFlushGPUWait"), rendererSettings.iVMRFlushGPUWait);
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("SynchronizeClock"), rendererSettings.bSynchronizeVideo);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("SynchronizeDisplay"), rendererSettings.bSynchronizeDisplay);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("SynchronizeNearest"), rendererSettings.bSynchronizeNearest);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("LineDelta"), rendererSettings.iLineDelta);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("ColumnDelta"), rendererSettings.iColumnDelta);
-
- pApp->WriteProfileBinary(IDS_R_SETTINGS, _T("CycleDelta"), (LPBYTE)&(rendererSettings.fCycleDelta), sizeof(rendererSettings.fCycleDelta));
- pApp->WriteProfileBinary(IDS_R_SETTINGS, _T("TargetSyncOffset"), (LPBYTE)&(rendererSettings.fTargetSyncOffset), sizeof(rendererSettings.fTargetSyncOffset));
- pApp->WriteProfileBinary(IDS_R_SETTINGS, _T("ControlLimit"), (LPBYTE)&(rendererSettings.fControlLimit), sizeof(rendererSettings.fControlLimit));
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("ResetDevice"), r.fResetDevice);
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SPCSIZE, r.nSPCSize);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SPCMAXRES, r.nSPCMaxRes);
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_POW2TEX, r.fSPCPow2Tex);
- pApp->WriteProfileInt(IDS_R_SETTINGS, _T("SPCAllowAnimationWhenBuffering"), r.fSPCAllowAnimationWhenBuffering);
-
- pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_EVR_BUFFERS, r.iEvrBuffers);
-
- pApp->WriteProfileString(IDS_R_SETTINGS, IDS_D3D9RENDERDEVICE, r.D3D9RenderDevice);
- } else {
- r.iAPSurfaceUsage = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_APSURACEFUSAGE, (SysVersion::IsVistaOrLater() ? VIDRNDT_AP_TEXTURE3D : VIDRNDT_AP_TEXTURE2D));
- r.iDX9Resizer = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DX9_RESIZER, 1);
- r.fVMR9MixerMode = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_VMR9MIXERMODE, TRUE);
- r.fVMR9MixerYUV = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_VMR9MIXERYUV, FALSE);
-
- CRenderersSettings::CRendererSettingsEVR& renderSettings = r.m_RenderSettings;
- CRenderersSettings::CRendererSettingsEVR DefaultSettings;
- renderSettings.fVMR9AlterativeVSync = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRAlternateVSync"), DefaultSettings.fVMR9AlterativeVSync);
- renderSettings.iVMR9VSyncOffset = pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRVSyncOffset"), DefaultSettings.iVMR9VSyncOffset);
- renderSettings.iVMR9VSyncAccurate = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRVSyncAccurate2"), DefaultSettings.iVMR9VSyncAccurate);
- renderSettings.iVMR9FullscreenGUISupport = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRFullscreenGUISupport"), DefaultSettings.iVMR9FullscreenGUISupport);
- renderSettings.iEVRHighColorResolution = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("EVRHighColorRes"), DefaultSettings.iEVRHighColorResolution);
- renderSettings.iEVRForceInputHighColorResolution = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("EVRForceInputHighColorRes"), DefaultSettings.iEVRForceInputHighColorResolution);
- renderSettings.iEVREnableFrameTimeCorrection = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("EVREnableFrameTimeCorrection"), DefaultSettings.iEVREnableFrameTimeCorrection);
- renderSettings.iVMR9VSync = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRVSync"), DefaultSettings.iVMR9VSync);
- renderSettings.iVMRDisableDesktopComposition = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRDisableDesktopComposition"), DefaultSettings.iVMRDisableDesktopComposition);
- renderSettings.iVMR9FullFloatingPointProcessing = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRFullFloatingPointProcessing"), DefaultSettings.iVMR9FullFloatingPointProcessing);
- renderSettings.iVMR9HalfFloatingPointProcessing = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRHalfFloatingPointProcessing"), DefaultSettings.iVMR9HalfFloatingPointProcessing);
-
- renderSettings.iVMR9ColorManagementEnable = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRColorManagementEnable"), DefaultSettings.iVMR9ColorManagementEnable);
- renderSettings.iVMR9ColorManagementInput = pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRColorManagementInput"), DefaultSettings.iVMR9ColorManagementInput);
- renderSettings.iVMR9ColorManagementAmbientLight = pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRColorManagementAmbientLight"), DefaultSettings.iVMR9ColorManagementAmbientLight);
- renderSettings.iVMR9ColorManagementIntent = pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRColorManagementIntent"), DefaultSettings.iVMR9ColorManagementIntent);
-
- renderSettings.iEVROutputRange = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("EVROutputRange"), DefaultSettings.iEVROutputRange);
-
- renderSettings.iVMRFlushGPUBeforeVSync = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRFlushGPUBeforeVSync"), DefaultSettings.iVMRFlushGPUBeforeVSync);
- renderSettings.iVMRFlushGPUAfterPresent = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRFlushGPUAfterPresent"), DefaultSettings.iVMRFlushGPUAfterPresent);
- renderSettings.iVMRFlushGPUWait = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRFlushGPUWait"), DefaultSettings.iVMRFlushGPUWait);
-
- renderSettings.bSynchronizeVideo = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("SynchronizeClock"), DefaultSettings.bSynchronizeVideo);
- renderSettings.bSynchronizeDisplay = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("SynchronizeDisplay"), DefaultSettings.bSynchronizeDisplay);
- renderSettings.bSynchronizeNearest = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("SynchronizeNearest"), DefaultSettings.bSynchronizeNearest);
- renderSettings.iLineDelta = pApp->GetProfileInt(IDS_R_SETTINGS, _T("LineDelta"), DefaultSettings.iLineDelta);
- renderSettings.iColumnDelta = pApp->GetProfileInt(IDS_R_SETTINGS, _T("ColumnDelta"), DefaultSettings.iColumnDelta);
-
- double *dPtr;
- UINT dSize;
- if (pApp->GetProfileBinary(IDS_R_SETTINGS, _T("CycleDelta"), (LPBYTE*)&dPtr, &dSize)) {
- renderSettings.fCycleDelta = *dPtr;
- delete [] dPtr;
- }
-
- if (pApp->GetProfileBinary(IDS_R_SETTINGS, _T("TargetSyncOffset"), (LPBYTE*)&dPtr, &dSize)) {
- renderSettings.fTargetSyncOffset = *dPtr;
- delete [] dPtr;
- }
- if (pApp->GetProfileBinary(IDS_R_SETTINGS, _T("ControlLimit"), (LPBYTE*)&dPtr, &dSize)) {
- renderSettings.fControlLimit = *dPtr;
- delete [] dPtr;
- }
-
- r.fResetDevice = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("ResetDevice"), TRUE);
-
- r.nSPCSize = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SPCSIZE, 4);
- r.nSPCMaxRes = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SPCMAXRES, 2);
- r.fSPCPow2Tex = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_POW2TEX, TRUE);
- r.fSPCAllowAnimationWhenBuffering = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("SPCAllowAnimationWhenBuffering"), TRUE);
-
- r.iEvrBuffers = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_EVR_BUFFERS, 5);
- r.D3D9RenderDevice = pApp->GetProfileString(IDS_R_SETTINGS, IDS_D3D9RENDERDEVICE, _T(""));
- }
+ CWinApp* pApp = AfxGetApp();
+ CRenderersSettings& r = m_RenderersSettings;
+
+ if (fSave) {
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_APSURACEFUSAGE, r.iAPSurfaceUsage);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_DX9_RESIZER, r.iDX9Resizer);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_VMR9MIXERMODE, r.fVMR9MixerMode);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_VMR9MIXERYUV, r.fVMR9MixerYUV);
+
+ CRenderersSettings::CRendererSettingsEVR& rendererSettings = r.m_RenderSettings;
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRAlternateVSync"), rendererSettings.fVMR9AlterativeVSync);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRVSyncOffset"), rendererSettings.iVMR9VSyncOffset);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRVSyncAccurate2"), rendererSettings.iVMR9VSyncAccurate);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRFullscreenGUISupport"), rendererSettings.iVMR9FullscreenGUISupport);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRVSync"), rendererSettings.iVMR9VSync);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRDisableDesktopComposition"), rendererSettings.iVMRDisableDesktopComposition);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRFullFloatingPointProcessing"), rendererSettings.iVMR9FullFloatingPointProcessing);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRHalfFloatingPointProcessing"), rendererSettings.iVMR9HalfFloatingPointProcessing);
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRColorManagementEnable"), rendererSettings.iVMR9ColorManagementEnable);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRColorManagementInput"), rendererSettings.iVMR9ColorManagementInput);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRColorManagementAmbientLight"), rendererSettings.iVMR9ColorManagementAmbientLight);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRColorManagementIntent"), rendererSettings.iVMR9ColorManagementIntent);
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("EVROutputRange"), rendererSettings.iEVROutputRange);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("EVRHighColorRes"), rendererSettings.iEVRHighColorResolution);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("EVRForceInputHighColorRes"), rendererSettings.iEVRForceInputHighColorResolution);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("EVREnableFrameTimeCorrection"), rendererSettings.iEVREnableFrameTimeCorrection);
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRFlushGPUBeforeVSync"), rendererSettings.iVMRFlushGPUBeforeVSync);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRFlushGPUAfterPresent"), rendererSettings.iVMRFlushGPUAfterPresent);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("VMRFlushGPUWait"), rendererSettings.iVMRFlushGPUWait);
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("SynchronizeClock"), rendererSettings.bSynchronizeVideo);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("SynchronizeDisplay"), rendererSettings.bSynchronizeDisplay);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("SynchronizeNearest"), rendererSettings.bSynchronizeNearest);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("LineDelta"), rendererSettings.iLineDelta);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("ColumnDelta"), rendererSettings.iColumnDelta);
+
+ pApp->WriteProfileBinary(IDS_R_SETTINGS, _T("CycleDelta"), (LPBYTE) & (rendererSettings.fCycleDelta), sizeof(rendererSettings.fCycleDelta));
+ pApp->WriteProfileBinary(IDS_R_SETTINGS, _T("TargetSyncOffset"), (LPBYTE) & (rendererSettings.fTargetSyncOffset), sizeof(rendererSettings.fTargetSyncOffset));
+ pApp->WriteProfileBinary(IDS_R_SETTINGS, _T("ControlLimit"), (LPBYTE) & (rendererSettings.fControlLimit), sizeof(rendererSettings.fControlLimit));
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("ResetDevice"), r.fResetDevice);
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SPCSIZE, r.nSPCSize);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_SPCMAXRES, r.nSPCMaxRes);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_POW2TEX, r.fSPCPow2Tex);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("SPCAllowAnimationWhenBuffering"), r.fSPCAllowAnimationWhenBuffering);
+
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_EVR_BUFFERS, r.iEvrBuffers);
+
+ pApp->WriteProfileString(IDS_R_SETTINGS, IDS_D3D9RENDERDEVICE, r.D3D9RenderDevice);
+ } else {
+ r.iAPSurfaceUsage = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_APSURACEFUSAGE, (SysVersion::IsVistaOrLater() ? VIDRNDT_AP_TEXTURE3D : VIDRNDT_AP_TEXTURE2D));
+ r.iDX9Resizer = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_DX9_RESIZER, 1);
+ r.fVMR9MixerMode = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_VMR9MIXERMODE, TRUE);
+ r.fVMR9MixerYUV = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_VMR9MIXERYUV, FALSE);
+
+ CRenderersSettings::CRendererSettingsEVR& renderSettings = r.m_RenderSettings;
+ CRenderersSettings::CRendererSettingsEVR DefaultSettings;
+ renderSettings.fVMR9AlterativeVSync = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRAlternateVSync"), DefaultSettings.fVMR9AlterativeVSync);
+ renderSettings.iVMR9VSyncOffset = pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRVSyncOffset"), DefaultSettings.iVMR9VSyncOffset);
+ renderSettings.iVMR9VSyncAccurate = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRVSyncAccurate2"), DefaultSettings.iVMR9VSyncAccurate);
+ renderSettings.iVMR9FullscreenGUISupport = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRFullscreenGUISupport"), DefaultSettings.iVMR9FullscreenGUISupport);
+ renderSettings.iEVRHighColorResolution = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("EVRHighColorRes"), DefaultSettings.iEVRHighColorResolution);
+ renderSettings.iEVRForceInputHighColorResolution = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("EVRForceInputHighColorRes"), DefaultSettings.iEVRForceInputHighColorResolution);
+ renderSettings.iEVREnableFrameTimeCorrection = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("EVREnableFrameTimeCorrection"), DefaultSettings.iEVREnableFrameTimeCorrection);
+ renderSettings.iVMR9VSync = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRVSync"), DefaultSettings.iVMR9VSync);
+ renderSettings.iVMRDisableDesktopComposition = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRDisableDesktopComposition"), DefaultSettings.iVMRDisableDesktopComposition);
+ renderSettings.iVMR9FullFloatingPointProcessing = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRFullFloatingPointProcessing"), DefaultSettings.iVMR9FullFloatingPointProcessing);
+ renderSettings.iVMR9HalfFloatingPointProcessing = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRHalfFloatingPointProcessing"), DefaultSettings.iVMR9HalfFloatingPointProcessing);
+
+ renderSettings.iVMR9ColorManagementEnable = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRColorManagementEnable"), DefaultSettings.iVMR9ColorManagementEnable);
+ renderSettings.iVMR9ColorManagementInput = pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRColorManagementInput"), DefaultSettings.iVMR9ColorManagementInput);
+ renderSettings.iVMR9ColorManagementAmbientLight = pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRColorManagementAmbientLight"), DefaultSettings.iVMR9ColorManagementAmbientLight);
+ renderSettings.iVMR9ColorManagementIntent = pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRColorManagementIntent"), DefaultSettings.iVMR9ColorManagementIntent);
+
+ renderSettings.iEVROutputRange = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("EVROutputRange"), DefaultSettings.iEVROutputRange);
+
+ renderSettings.iVMRFlushGPUBeforeVSync = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRFlushGPUBeforeVSync"), DefaultSettings.iVMRFlushGPUBeforeVSync);
+ renderSettings.iVMRFlushGPUAfterPresent = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRFlushGPUAfterPresent"), DefaultSettings.iVMRFlushGPUAfterPresent);
+ renderSettings.iVMRFlushGPUWait = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("VMRFlushGPUWait"), DefaultSettings.iVMRFlushGPUWait);
+
+ renderSettings.bSynchronizeVideo = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("SynchronizeClock"), DefaultSettings.bSynchronizeVideo);
+ renderSettings.bSynchronizeDisplay = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("SynchronizeDisplay"), DefaultSettings.bSynchronizeDisplay);
+ renderSettings.bSynchronizeNearest = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("SynchronizeNearest"), DefaultSettings.bSynchronizeNearest);
+ renderSettings.iLineDelta = pApp->GetProfileInt(IDS_R_SETTINGS, _T("LineDelta"), DefaultSettings.iLineDelta);
+ renderSettings.iColumnDelta = pApp->GetProfileInt(IDS_R_SETTINGS, _T("ColumnDelta"), DefaultSettings.iColumnDelta);
+
+ double* dPtr;
+ UINT dSize;
+ if (pApp->GetProfileBinary(IDS_R_SETTINGS, _T("CycleDelta"), (LPBYTE*)&dPtr, &dSize)) {
+ renderSettings.fCycleDelta = *dPtr;
+ delete [] dPtr;
+ }
+
+ if (pApp->GetProfileBinary(IDS_R_SETTINGS, _T("TargetSyncOffset"), (LPBYTE*)&dPtr, &dSize)) {
+ renderSettings.fTargetSyncOffset = *dPtr;
+ delete [] dPtr;
+ }
+ if (pApp->GetProfileBinary(IDS_R_SETTINGS, _T("ControlLimit"), (LPBYTE*)&dPtr, &dSize)) {
+ renderSettings.fControlLimit = *dPtr;
+ delete [] dPtr;
+ }
+
+ r.fResetDevice = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("ResetDevice"), TRUE);
+
+ r.nSPCSize = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SPCSIZE, 4);
+ r.nSPCMaxRes = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SPCMAXRES, 2);
+ r.fSPCPow2Tex = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_POW2TEX, TRUE);
+ r.fSPCAllowAnimationWhenBuffering = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("SPCAllowAnimationWhenBuffering"), TRUE);
+
+ r.iEvrBuffers = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_EVR_BUFFERS, 5);
+ r.D3D9RenderDevice = pApp->GetProfileString(IDS_R_SETTINGS, IDS_D3D9RENDERDEVICE, _T(""));
+ }
}
void CAppSettings::SaveCurrentFilePosition()
{
- CWinApp* pApp = AfxGetApp();
- CString strFilePos;
- CString strValue;
- int i = nCurrentFilePosition;
-
- strFilePos.Format (_T("File Name %d"), i);
- pApp->WriteProfileString(IDS_R_SETTINGS, strFilePos, FilePosition[i].strFile);
- strFilePos.Format (_T("File Position %d"), i);
- strValue.Format (_T("%I64d"), FilePosition[i].llPosition);
- pApp->WriteProfileString(IDS_R_SETTINGS, strFilePos, strValue);
+ CWinApp* pApp = AfxGetApp();
+ CString strFilePos;
+ CString strValue;
+ int i = nCurrentFilePosition;
+
+ strFilePos.Format(_T("File Name %d"), i);
+ pApp->WriteProfileString(IDS_R_SETTINGS, strFilePos, FilePosition[i].strFile);
+ strFilePos.Format(_T("File Position %d"), i);
+ strValue.Format(_T("%I64d"), FilePosition[i].llPosition);
+ pApp->WriteProfileString(IDS_R_SETTINGS, strFilePos, strValue);
}
void CAppSettings::ClearFilePositions()
{
- CWinApp* pApp = AfxGetApp();
- CString strFilePos;
- for (int i=0; i<MAX_FILE_POSITION; i++) {
- FilePosition[i].strFile = _T("");
- FilePosition[i].llPosition = 0;
-
- strFilePos.Format (_T("File Name %d"), i);
- pApp->WriteProfileString(IDS_R_SETTINGS, strFilePos, _T(""));
- strFilePos.Format (_T("File Position %d"), i);
- pApp->WriteProfileString(IDS_R_SETTINGS, strFilePos, _T(""));
- }
+ CWinApp* pApp = AfxGetApp();
+ CString strFilePos;
+ for (int i = 0; i < MAX_FILE_POSITION; i++) {
+ FilePosition[i].strFile = _T("");
+ FilePosition[i].llPosition = 0;
+
+ strFilePos.Format(_T("File Name %d"), i);
+ pApp->WriteProfileString(IDS_R_SETTINGS, strFilePos, _T(""));
+ strFilePos.Format(_T("File Position %d"), i);
+ pApp->WriteProfileString(IDS_R_SETTINGS, strFilePos, _T(""));
+ }
}
void CAppSettings::SaveCurrentDVDPosition()
{
- CWinApp* pApp = AfxGetApp();
- CString strDVDPos;
- CString strValue;
- int i = nCurrentDvdPosition;
-
- strDVDPos.Format (_T("DVD Position %d"), i);
- strValue = SerializeHex((BYTE*)&DvdPosition[i], sizeof(DVD_POSITION));
- pApp->WriteProfileString(IDS_R_SETTINGS, strDVDPos, strValue);
+ CWinApp* pApp = AfxGetApp();
+ CString strDVDPos;
+ CString strValue;
+ int i = nCurrentDvdPosition;
+
+ strDVDPos.Format(_T("DVD Position %d"), i);
+ strValue = SerializeHex((BYTE*)&DvdPosition[i], sizeof(DVD_POSITION));
+ pApp->WriteProfileString(IDS_R_SETTINGS, strDVDPos, strValue);
}
void CAppSettings::ClearDVDPositions()
{
- CWinApp* pApp = AfxGetApp();
- CString strDVDPos;
- for (int i=0; i<MAX_DVD_POSITION; i++) {
- DvdPosition[i].llDVDGuid = 0;
- DvdPosition[i].lTitle = 0;
-
- strDVDPos.Format (_T("DVD Position %d"), i);
- pApp->WriteProfileString(IDS_R_SETTINGS, strDVDPos, _T(""));
- }
+ CWinApp* pApp = AfxGetApp();
+ CString strDVDPos;
+ for (int i = 0; i < MAX_DVD_POSITION; i++) {
+ DvdPosition[i].llDVDGuid = 0;
+ DvdPosition[i].lTitle = 0;
+
+ strDVDPos.Format(_T("DVD Position %d"), i);
+ pApp->WriteProfileString(IDS_R_SETTINGS, strDVDPos, _T(""));
+ }
}
__int64 CAppSettings::ConvertTimeToMSec(CString& time) const
{
- __int64 Sec = 0;
- __int64 mSec = 0;
- __int64 mult = 1;
-
- int pos = time.GetLength() - 1;
- if (pos < 3) {
- return 0;
- }
-
- while (pos >= 0) {
- TCHAR ch = time[pos];
- if (ch == '.') {
- mSec = Sec * 1000 / mult;
- Sec = 0;
- mult = 1;
- } else if (ch == ':') {
- mult = mult * 6 / 10;
- } else if (ch >= '0' && ch <= '9') {
- Sec += (ch - '0') * mult;
- mult *= 10;
- } else {
- mSec = Sec = 0;
- break;
- }
- pos--;
- }
- return Sec*1000 + mSec;
+ __int64 Sec = 0;
+ __int64 mSec = 0;
+ __int64 mult = 1;
+
+ int pos = time.GetLength() - 1;
+ if (pos < 3) {
+ return 0;
+ }
+
+ while (pos >= 0) {
+ TCHAR ch = time[pos];
+ if (ch == '.') {
+ mSec = Sec * 1000 / mult;
+ Sec = 0;
+ mult = 1;
+ } else if (ch == ':') {
+ mult = mult * 6 / 10;
+ } else if (ch >= '0' && ch <= '9') {
+ Sec += (ch - '0') * mult;
+ mult *= 10;
+ } else {
+ mSec = Sec = 0;
+ break;
+ }
+ pos--;
+ }
+ return Sec * 1000 + mSec;
}
void CAppSettings::ExtractDVDStartPos(CString& strParam)
{
- int i = 0, j = 0;
- for (CString token = strParam.Tokenize(_T("#"), i);
- j < 3 && !token.IsEmpty();
- token = strParam.Tokenize(_T("#"), i), j++) {
- switch (j) {
- case 0 :
- lDVDTitle = token.IsEmpty() ? 0 : (ULONG)_wtol(token);
- break;
- case 1 :
- if (token.Find(':') >0) {
- _stscanf_s(token, _T("%02d:%02d:%02d.%03d"), &DVDPosition.bHours, &DVDPosition.bMinutes, &DVDPosition.bSeconds, &DVDPosition.bFrames);
- /* Hack by Ron. If bFrames >= 30, PlayTime commands fail due to invalid arg */
- DVDPosition.bFrames = 0;
- } else {
- lDVDChapter = token.IsEmpty() ? 0 : (ULONG)_wtol(token);
- }
- break;
- }
- }
+ int i = 0, j = 0;
+ for (CString token = strParam.Tokenize(_T("#"), i);
+ j < 3 && !token.IsEmpty();
+ token = strParam.Tokenize(_T("#"), i), j++) {
+ switch (j) {
+ case 0 :
+ lDVDTitle = token.IsEmpty() ? 0 : (ULONG)_wtol(token);
+ break;
+ case 1 :
+ if (token.Find(':') > 0) {
+ _stscanf_s(token, _T("%02d:%02d:%02d.%03d"), &DVDPosition.bHours, &DVDPosition.bMinutes, &DVDPosition.bSeconds, &DVDPosition.bFrames);
+ /* Hack by Ron. If bFrames >= 30, PlayTime commands fail due to invalid arg */
+ DVDPosition.bFrames = 0;
+ } else {
+ lDVDChapter = token.IsEmpty() ? 0 : (ULONG)_wtol(token);
+ }
+ break;
+ }
+ }
}
CString CAppSettings::ParseFileName(CString const& param)
{
- CString fullPathName;
+ CString fullPathName;
- // Try to transform relative pathname into full pathname
- if (param.Find(_T(":")) < 0) {
- fullPathName.ReleaseBuffer(GetFullPathName(param, _MAX_PATH, fullPathName.GetBuffer(_MAX_PATH), NULL));
+ // Try to transform relative pathname into full pathname
+ if (param.Find(_T(":")) < 0) {
+ fullPathName.ReleaseBuffer(GetFullPathName(param, _MAX_PATH, fullPathName.GetBuffer(_MAX_PATH), NULL));
- CFileStatus fs;
- if (!fullPathName.IsEmpty() && CFileGetStatus(fullPathName, fs)) {
- return fullPathName;
- }
- }
+ CFileStatus fs;
+ if (!fullPathName.IsEmpty() && CFileGetStatus(fullPathName, fs)) {
+ return fullPathName;
+ }
+ }
- return param;
+ return param;
}
void CAppSettings::ParseCommandLine(CAtlList<CString>& cmdln)
{
- nCLSwitches = 0;
- slFiles.RemoveAll();
- slDubs.RemoveAll();
- slSubs.RemoveAll();
- slFilters.RemoveAll();
- rtStart = 0;
- rtShift = 0;
- lDVDTitle = 0;
- lDVDChapter = 0;
- memset (&DVDPosition, 0, sizeof(DVDPosition));
- iAdminOption=0;
- sizeFixedWindow.SetSize(0, 0);
- iMonitor = 0;
- hMasterWnd = 0;
- strPnSPreset.Empty();
-
- POSITION pos = cmdln.GetHeadPosition();
- while (pos) {
- const CString& param = cmdln.GetNext(pos);
- if (param.IsEmpty()) {
- continue;
- }
-
- if ((param[0] == '-' || param[0] == '/') && param.GetLength() > 1) {
- CString sw = param.Mid(1).MakeLower();
- if (sw == _T("open")) {
- nCLSwitches |= CLSW_OPEN;
- } else if (sw == _T("play")) {
- nCLSwitches |= CLSW_PLAY;
- } else if (sw == _T("fullscreen")) {
- nCLSwitches |= CLSW_FULLSCREEN;
- } else if (sw == _T("minimized")) {
- nCLSwitches |= CLSW_MINIMIZED;
- } else if (sw == _T("new")) {
- nCLSwitches |= CLSW_NEW;
- } else if (sw == _T("help") || sw == _T("h") || sw == _T("?")) {
- nCLSwitches |= CLSW_HELP;
- } else if (sw == _T("dub") && pos) {
- slDubs.AddTail(ParseFileName(cmdln.GetNext(pos)));
- } else if (sw == _T("dubdelay") && pos) {
- CString strFile = ParseFileName(cmdln.GetNext(pos));
- int nPos = strFile.Find (_T("DELAY"));
- if (nPos != -1) {
- rtShift = 10000 * _tstol(strFile.Mid(nPos + 6));
- }
- slDubs.AddTail(strFile);
- } else if (sw == _T("sub") && pos) {
- slSubs.AddTail(ParseFileName(cmdln.GetNext(pos)));
- } else if (sw == _T("filter") && pos) {
- slFilters.AddTail(cmdln.GetNext(pos));
- } else if (sw == _T("dvd")) {
- nCLSwitches |= CLSW_DVD;
- } else if (sw == _T("dvdpos")) {
- ExtractDVDStartPos(cmdln.GetNext(pos));
- } else if (sw == _T("cd")) {
- nCLSwitches |= CLSW_CD;
- } else if (sw == _T("add")) {
- nCLSwitches |= CLSW_ADD;
- } else if (sw == _T("regvid")) {
- nCLSwitches |= CLSW_REGEXTVID;
- } else if (sw == _T("regaud")) {
- nCLSwitches |= CLSW_REGEXTAUD;
- } else if (sw == _T("regpl")) {
- nCLSwitches |= CLSW_REGEXTPL;
- } else if (sw == _T("regall")) {
- nCLSwitches |= (CLSW_REGEXTVID | CLSW_REGEXTAUD | CLSW_REGEXTPL);
- } else if (sw == _T("unregall")) {
- nCLSwitches |= CLSW_UNREGEXT;
- } else if (sw == _T("unregvid")) {
- nCLSwitches |= CLSW_UNREGEXT; /* keep for compatibility with old versions */
- } else if (sw == _T("unregaud")) {
- nCLSwitches |= CLSW_UNREGEXT; /* keep for compatibility with old versions */
- } else if (sw == _T("start") && pos) {
- rtStart = 10000i64*_tcstol(cmdln.GetNext(pos), NULL, 10);
- nCLSwitches |= CLSW_STARTVALID;
- } else if (sw == _T("startpos") && pos) {
- rtStart = 10000i64 * ConvertTimeToMSec(cmdln.GetNext(pos));
- nCLSwitches |= CLSW_STARTVALID;
- } else if (sw == _T("nofocus")) {
- nCLSwitches |= CLSW_NOFOCUS;
- } else if (sw == _T("close")) {
- nCLSwitches |= CLSW_CLOSE;
- } else if (sw == _T("standby")) {
- nCLSwitches |= CLSW_STANDBY;
- } else if (sw == _T("hibernate")) {
- nCLSwitches |= CLSW_HIBERNATE;
- } else if (sw == _T("shutdown")) {
- nCLSwitches |= CLSW_SHUTDOWN;
- } else if (sw == _T("logoff")) {
- nCLSwitches |= CLSW_LOGOFF;
- } else if (sw == _T("lock")) {
- nCLSwitches |= CLSW_LOCK;
- } else if (sw == _T("d3dfs")) {
- nCLSwitches |= CLSW_D3DFULLSCREEN;
- } else if (sw == _T("adminoption")) {
- nCLSwitches |= CLSW_ADMINOPTION;
- iAdminOption = _ttoi (cmdln.GetNext(pos));
- } else if (sw == _T("slave")) {
- nCLSwitches |= CLSW_SLAVE;
- hMasterWnd = (HWND)_ttol (cmdln.GetNext(pos));
- } else if (sw == _T("fixedsize") && pos) {
- CAtlList<CString> sl;
- Explode(cmdln.GetNext(pos), sl, ',', 2);
- if (sl.GetCount() == 2) {
- sizeFixedWindow.SetSize(_ttol(sl.GetHead()), _ttol(sl.GetTail()));
- if (sizeFixedWindow.cx > 0 && sizeFixedWindow.cy > 0) {
- nCLSwitches |= CLSW_FIXEDSIZE;
- }
- }
- } else if (sw == _T("monitor") && pos) {
- iMonitor = _tcstol(cmdln.GetNext(pos), NULL, 10);
- nCLSwitches |= CLSW_MONITOR;
- } else if (sw == _T("pns")) {
- strPnSPreset = cmdln.GetNext(pos);
- } else if (sw == _T("webport") && pos) {
- int tmpport = _tcstol(cmdln.GetNext(pos), NULL, 10);
- if ( tmpport >= 0 && tmpport <= 65535 ) {
- nCmdlnWebServerPort = tmpport;
- }
- } else if (sw == _T("debug")) {
- fShowDebugInfo = true;
- } else if (sw == _T("nominidump")) {
- CMiniDump::Disable();
- } else if (sw == _T("audiorenderer") && pos) {
- SetAudioRenderer(_ttoi(cmdln.GetNext(pos)));
- } else if (sw == _T("reset")) {
- nCLSwitches |= CLSW_RESET;
- } else {
- nCLSwitches |= CLSW_HELP|CLSW_UNRECOGNIZEDSWITCH;
- }
- } else {
- slFiles.AddTail(ParseFileName(param));
- }
- }
+ nCLSwitches = 0;
+ slFiles.RemoveAll();
+ slDubs.RemoveAll();
+ slSubs.RemoveAll();
+ slFilters.RemoveAll();
+ rtStart = 0;
+ rtShift = 0;
+ lDVDTitle = 0;
+ lDVDChapter = 0;
+ memset(&DVDPosition, 0, sizeof(DVDPosition));
+ iAdminOption = 0;
+ sizeFixedWindow.SetSize(0, 0);
+ iMonitor = 0;
+ hMasterWnd = 0;
+ strPnSPreset.Empty();
+
+ POSITION pos = cmdln.GetHeadPosition();
+ while (pos) {
+ const CString& param = cmdln.GetNext(pos);
+ if (param.IsEmpty()) {
+ continue;
+ }
+
+ if ((param[0] == '-' || param[0] == '/') && param.GetLength() > 1) {
+ CString sw = param.Mid(1).MakeLower();
+ if (sw == _T("open")) {
+ nCLSwitches |= CLSW_OPEN;
+ } else if (sw == _T("play")) {
+ nCLSwitches |= CLSW_PLAY;
+ } else if (sw == _T("fullscreen")) {
+ nCLSwitches |= CLSW_FULLSCREEN;
+ } else if (sw == _T("minimized")) {
+ nCLSwitches |= CLSW_MINIMIZED;
+ } else if (sw == _T("new")) {
+ nCLSwitches |= CLSW_NEW;
+ } else if (sw == _T("help") || sw == _T("h") || sw == _T("?")) {
+ nCLSwitches |= CLSW_HELP;
+ } else if (sw == _T("dub") && pos) {
+ slDubs.AddTail(ParseFileName(cmdln.GetNext(pos)));
+ } else if (sw == _T("dubdelay") && pos) {
+ CString strFile = ParseFileName(cmdln.GetNext(pos));
+ int nPos = strFile.Find(_T("DELAY"));
+ if (nPos != -1) {
+ rtShift = 10000 * _tstol(strFile.Mid(nPos + 6));
+ }
+ slDubs.AddTail(strFile);
+ } else if (sw == _T("sub") && pos) {
+ slSubs.AddTail(ParseFileName(cmdln.GetNext(pos)));
+ } else if (sw == _T("filter") && pos) {
+ slFilters.AddTail(cmdln.GetNext(pos));
+ } else if (sw == _T("dvd")) {
+ nCLSwitches |= CLSW_DVD;
+ } else if (sw == _T("dvdpos")) {
+ ExtractDVDStartPos(cmdln.GetNext(pos));
+ } else if (sw == _T("cd")) {
+ nCLSwitches |= CLSW_CD;
+ } else if (sw == _T("add")) {
+ nCLSwitches |= CLSW_ADD;
+ } else if (sw == _T("regvid")) {
+ nCLSwitches |= CLSW_REGEXTVID;
+ } else if (sw == _T("regaud")) {
+ nCLSwitches |= CLSW_REGEXTAUD;
+ } else if (sw == _T("regpl")) {
+ nCLSwitches |= CLSW_REGEXTPL;
+ } else if (sw == _T("regall")) {
+ nCLSwitches |= (CLSW_REGEXTVID | CLSW_REGEXTAUD | CLSW_REGEXTPL);
+ } else if (sw == _T("unregall")) {
+ nCLSwitches |= CLSW_UNREGEXT;
+ } else if (sw == _T("unregvid")) {
+ nCLSwitches |= CLSW_UNREGEXT; /* keep for compatibility with old versions */
+ } else if (sw == _T("unregaud")) {
+ nCLSwitches |= CLSW_UNREGEXT; /* keep for compatibility with old versions */
+ } else if (sw == _T("start") && pos) {
+ rtStart = 10000i64 * _tcstol(cmdln.GetNext(pos), NULL, 10);
+ nCLSwitches |= CLSW_STARTVALID;
+ } else if (sw == _T("startpos") && pos) {
+ rtStart = 10000i64 * ConvertTimeToMSec(cmdln.GetNext(pos));
+ nCLSwitches |= CLSW_STARTVALID;
+ } else if (sw == _T("nofocus")) {
+ nCLSwitches |= CLSW_NOFOCUS;
+ } else if (sw == _T("close")) {
+ nCLSwitches |= CLSW_CLOSE;
+ } else if (sw == _T("standby")) {
+ nCLSwitches |= CLSW_STANDBY;
+ } else if (sw == _T("hibernate")) {
+ nCLSwitches |= CLSW_HIBERNATE;
+ } else if (sw == _T("shutdown")) {
+ nCLSwitches |= CLSW_SHUTDOWN;
+ } else if (sw == _T("logoff")) {
+ nCLSwitches |= CLSW_LOGOFF;
+ } else if (sw == _T("lock")) {
+ nCLSwitches |= CLSW_LOCK;
+ } else if (sw == _T("d3dfs")) {
+ nCLSwitches |= CLSW_D3DFULLSCREEN;
+ } else if (sw == _T("adminoption")) {
+ nCLSwitches |= CLSW_ADMINOPTION;
+ iAdminOption = _ttoi(cmdln.GetNext(pos));
+ } else if (sw == _T("slave")) {
+ nCLSwitches |= CLSW_SLAVE;
+ hMasterWnd = (HWND)_ttol(cmdln.GetNext(pos));
+ } else if (sw == _T("fixedsize") && pos) {
+ CAtlList<CString> sl;
+ Explode(cmdln.GetNext(pos), sl, ',', 2);
+ if (sl.GetCount() == 2) {
+ sizeFixedWindow.SetSize(_ttol(sl.GetHead()), _ttol(sl.GetTail()));
+ if (sizeFixedWindow.cx > 0 && sizeFixedWindow.cy > 0) {
+ nCLSwitches |= CLSW_FIXEDSIZE;
+ }
+ }
+ } else if (sw == _T("monitor") && pos) {
+ iMonitor = _tcstol(cmdln.GetNext(pos), NULL, 10);
+ nCLSwitches |= CLSW_MONITOR;
+ } else if (sw == _T("pns")) {
+ strPnSPreset = cmdln.GetNext(pos);
+ } else if (sw == _T("webport") && pos) {
+ int tmpport = _tcstol(cmdln.GetNext(pos), NULL, 10);
+ if (tmpport >= 0 && tmpport <= 65535) {
+ nCmdlnWebServerPort = tmpport;
+ }
+ } else if (sw == _T("debug")) {
+ fShowDebugInfo = true;
+ } else if (sw == _T("nominidump")) {
+ CMiniDump::Disable();
+ } else if (sw == _T("audiorenderer") && pos) {
+ SetAudioRenderer(_ttoi(cmdln.GetNext(pos)));
+ } else if (sw == _T("reset")) {
+ nCLSwitches |= CLSW_RESET;
+ } else {
+ nCLSwitches |= CLSW_HELP | CLSW_UNRECOGNIZEDSWITCH;
+ }
+ } else {
+ slFiles.AddTail(ParseFileName(param));
+ }
+ }
}
void CAppSettings::GetFav(favtype ft, CAtlList<CString>& sl)
{
- sl.RemoveAll();
-
- CString root;
-
- switch (ft) {
- case FAV_FILE:
- root = IDS_R_FAVFILES;
- break;
- case FAV_DVD:
- root = IDS_R_FAVDVDS;
- break;
- case FAV_DEVICE:
- root = IDS_R_FAVDEVICES;
- break;
- default:
- return;
- }
-
- for (int i = 0; ; i++) {
- CString s;
- s.Format(_T("Name%d"), i);
- s = AfxGetApp()->GetProfileString(root, s, NULL);
- if (s.IsEmpty()) {
- break;
- }
- sl.AddTail(s);
- }
+ sl.RemoveAll();
+
+ CString root;
+
+ switch (ft) {
+ case FAV_FILE:
+ root = IDS_R_FAVFILES;
+ break;
+ case FAV_DVD:
+ root = IDS_R_FAVDVDS;
+ break;
+ case FAV_DEVICE:
+ root = IDS_R_FAVDEVICES;
+ break;
+ default:
+ return;
+ }
+
+ for (int i = 0; ; i++) {
+ CString s;
+ s.Format(_T("Name%d"), i);
+ s = AfxGetApp()->GetProfileString(root, s, NULL);
+ if (s.IsEmpty()) {
+ break;
+ }
+ sl.AddTail(s);
+ }
}
void CAppSettings::SetFav(favtype ft, CAtlList<CString>& sl)
{
- CString root;
-
- switch (ft) {
- case FAV_FILE:
- root = IDS_R_FAVFILES;
- break;
- case FAV_DVD:
- root = IDS_R_FAVDVDS;
- break;
- case FAV_DEVICE:
- root = IDS_R_FAVDEVICES;
- break;
- default:
- return;
- }
-
- AfxGetApp()->WriteProfileString(root, NULL, NULL);
-
- int i = 0;
- POSITION pos = sl.GetHeadPosition();
- while (pos) {
- CString s;
- s.Format(_T("Name%d"), i++);
- AfxGetApp()->WriteProfileString(root, s, sl.GetNext(pos));
- }
+ CString root;
+
+ switch (ft) {
+ case FAV_FILE:
+ root = IDS_R_FAVFILES;
+ break;
+ case FAV_DVD:
+ root = IDS_R_FAVDVDS;
+ break;
+ case FAV_DEVICE:
+ root = IDS_R_FAVDEVICES;
+ break;
+ default:
+ return;
+ }
+
+ AfxGetApp()->WriteProfileString(root, NULL, NULL);
+
+ int i = 0;
+ POSITION pos = sl.GetHeadPosition();
+ while (pos) {
+ CString s;
+ s.Format(_T("Name%d"), i++);
+ AfxGetApp()->WriteProfileString(root, s, sl.GetNext(pos));
+ }
}
void CAppSettings::AddFav(favtype ft, CString s)
{
- CAtlList<CString> sl;
- GetFav(ft, sl);
- if (sl.Find(s)) {
- return;
- }
- sl.AddTail(s);
- SetFav(ft, sl);
+ CAtlList<CString> sl;
+ GetFav(ft, sl);
+ if (sl.Find(s)) {
+ return;
+ }
+ sl.AddTail(s);
+ SetFav(ft, sl);
}
CDVBChannel* CAppSettings::FindChannelByPref(int nPrefNumber)
{
- POSITION pos = m_DVBChannels.GetHeadPosition();
- while (pos) {
- CDVBChannel& Channel = m_DVBChannels.GetNext (pos);
- if (Channel.GetPrefNumber() == nPrefNumber) {
- return &Channel;
- }
- }
-
- return NULL;
+ POSITION pos = m_DVBChannels.GetHeadPosition();
+ while (pos) {
+ CDVBChannel& Channel = m_DVBChannels.GetNext(pos);
+ if (Channel.GetPrefNumber() == nPrefNumber) {
+ return &Channel;
+ }
+ }
+
+ return NULL;
}
// Settings::CRecentFileAndURLList
CAppSettings::CRecentFileAndURLList::CRecentFileAndURLList(UINT nStart, LPCTSTR lpszSection,
- LPCTSTR lpszEntryFormat, int nSize,
- int nMaxDispLen)
- : CRecentFileList(nStart, lpszSection, lpszEntryFormat, nSize, nMaxDispLen)
+ LPCTSTR lpszEntryFormat, int nSize,
+ int nMaxDispLen)
+ : CRecentFileList(nStart, lpszSection, lpszEntryFormat, nSize, nMaxDispLen)
{
}
@@ -1971,48 +1968,48 @@ extern BOOL AFXAPI AfxComparePath(LPCTSTR lpszPath1, LPCTSTR lpszPath2);
void CAppSettings::CRecentFileAndURLList::Add(LPCTSTR lpszPathName)
{
- ASSERT(m_arrNames != NULL);
- ASSERT(lpszPathName != NULL);
- ASSERT(AfxIsValidString(lpszPathName));
-
- if (CString(lpszPathName).MakeLower().Find(_T("@device:")) >= 0) {
- return;
- }
-
- bool fURL = (CString(lpszPathName).Find(_T("://")) >= 0);
-
- // fully qualify the path name
- TCHAR szTemp[1024];
- if (fURL) {
- _tcscpy_s(szTemp, lpszPathName);
- } else {
- AfxFullPath(szTemp, lpszPathName);
- }
-
- // update the MRU list, if an existing MRU string matches file name
- int iMRU;
- for (iMRU = 0; iMRU < m_nSize-1; iMRU++) {
- if ((fURL && !_tcscmp(m_arrNames[iMRU], szTemp))
- || AfxComparePath(m_arrNames[iMRU], szTemp)) {
- break; // iMRU will point to matching entry
- }
- }
- // move MRU strings before this one down
- for (; iMRU > 0; iMRU--) {
- ASSERT(iMRU > 0);
- ASSERT(iMRU < m_nSize);
- m_arrNames[iMRU] = m_arrNames[iMRU-1];
- }
- // place this one at the beginning
- m_arrNames[0] = szTemp;
+ ASSERT(m_arrNames != NULL);
+ ASSERT(lpszPathName != NULL);
+ ASSERT(AfxIsValidString(lpszPathName));
+
+ if (CString(lpszPathName).MakeLower().Find(_T("@device:")) >= 0) {
+ return;
+ }
+
+ bool fURL = (CString(lpszPathName).Find(_T("://")) >= 0);
+
+ // fully qualify the path name
+ TCHAR szTemp[1024];
+ if (fURL) {
+ _tcscpy_s(szTemp, lpszPathName);
+ } else {
+ AfxFullPath(szTemp, lpszPathName);
+ }
+
+ // update the MRU list, if an existing MRU string matches file name
+ int iMRU;
+ for (iMRU = 0; iMRU < m_nSize - 1; iMRU++) {
+ if ((fURL && !_tcscmp(m_arrNames[iMRU], szTemp))
+ || AfxComparePath(m_arrNames[iMRU], szTemp)) {
+ break; // iMRU will point to matching entry
+ }
+ }
+ // move MRU strings before this one down
+ for (; iMRU > 0; iMRU--) {
+ ASSERT(iMRU > 0);
+ ASSERT(iMRU < m_nSize);
+ m_arrNames[iMRU] = m_arrNames[iMRU - 1];
+ }
+ // place this one at the beginning
+ m_arrNames[0] = szTemp;
}
bool CAppSettings::IsVSFilterInstalled()
{
- return IsCLSIDRegistered(_T("{9852A670-F845-491B-9BE6-EBD841B8A613}"));
+ return IsCLSIDRegistered(_T("{9852A670-F845-491B-9BE6-EBD841B8A613}"));
}
bool CAppSettings::HasEVR()
{
- return IsCLSIDRegistered(_T("{FA10746C-9B63-4B6C-BC49-FC300EA5F256}"));
+ return IsCLSIDRegistered(_T("{FA10746C-9B63-4B6C-BC49-FC300EA5F256}"));
}
diff --git a/src/mpc-hc/AppSettings.h b/src/mpc-hc/AppSettings.h
index b88d0db4a..908627972 100644
--- a/src/mpc-hc/AppSettings.h
+++ b/src/mpc-hc/AppSettings.h
@@ -34,97 +34,97 @@
// flags for AppSettings::nCS
enum {
- CS_NONE=0,
- CS_SEEKBAR=1,
- CS_TOOLBAR=CS_SEEKBAR<<1,
- CS_INFOBAR=CS_TOOLBAR<<1,
- CS_STATSBAR=CS_INFOBAR<<1,
- CS_STATUSBAR=CS_STATSBAR<<1,
- CS_LAST=CS_STATUSBAR
+ CS_NONE = 0,
+ CS_SEEKBAR = 1,
+ CS_TOOLBAR = CS_SEEKBAR << 1,
+ CS_INFOBAR = CS_TOOLBAR << 1,
+ CS_STATSBAR = CS_INFOBAR << 1,
+ CS_STATUSBAR = CS_STATSBAR << 1,
+ CS_LAST = CS_STATUSBAR
};
enum {
- CLSW_NONE=0,
- CLSW_OPEN=1,
- CLSW_PLAY=CLSW_OPEN<<1,
- CLSW_CLOSE=CLSW_PLAY<<1,
- CLSW_STANDBY=CLSW_CLOSE<<1,
- CLSW_HIBERNATE=CLSW_STANDBY<<1,
- CLSW_SHUTDOWN=CLSW_HIBERNATE<<1,
- CLSW_LOGOFF=CLSW_SHUTDOWN<<1,
- CLSW_LOCK=CLSW_LOGOFF<<1,
- CLSW_AFTERPLAYBACK_MASK=CLSW_CLOSE|CLSW_STANDBY|CLSW_SHUTDOWN|CLSW_HIBERNATE|CLSW_LOGOFF|CLSW_LOCK,
- CLSW_FULLSCREEN=CLSW_LOCK<<1,
- CLSW_NEW=CLSW_FULLSCREEN<<1,
- CLSW_HELP=CLSW_NEW<<1,
- CLSW_DVD=CLSW_HELP<<1,
- CLSW_CD=CLSW_DVD<<1,
- CLSW_ADD=CLSW_CD<<1,
- CLSW_MINIMIZED=CLSW_ADD<<1,
- CLSW_REGEXTVID=CLSW_MINIMIZED<<1, // 16
- CLSW_REGEXTAUD=CLSW_REGEXTVID<<1,
- CLSW_REGEXTPL=CLSW_REGEXTAUD<<1,
- CLSW_UNREGEXT=CLSW_REGEXTPL<<1,
- CLSW_STARTVALID=CLSW_UNREGEXT<<2,
- CLSW_NOFOCUS=CLSW_STARTVALID<<1,
- CLSW_FIXEDSIZE=CLSW_NOFOCUS<<1,
- CLSW_MONITOR=CLSW_FIXEDSIZE<<1,
- CLSW_D3DFULLSCREEN=CLSW_MONITOR<<1,
- CLSW_ADMINOPTION=CLSW_D3DFULLSCREEN<<1,
- CLSW_SLAVE=CLSW_ADMINOPTION<<1,
- CLSW_AUDIORENDERER=CLSW_SLAVE<<1,
- CLSW_RESET=CLSW_AUDIORENDERER<<1,
- CLSW_UNRECOGNIZEDSWITCH=CLSW_RESET<<1 // 30
+ CLSW_NONE = 0,
+ CLSW_OPEN = 1,
+ CLSW_PLAY = CLSW_OPEN << 1,
+ CLSW_CLOSE = CLSW_PLAY << 1,
+ CLSW_STANDBY = CLSW_CLOSE << 1,
+ CLSW_HIBERNATE = CLSW_STANDBY << 1,
+ CLSW_SHUTDOWN = CLSW_HIBERNATE << 1,
+ CLSW_LOGOFF = CLSW_SHUTDOWN << 1,
+ CLSW_LOCK = CLSW_LOGOFF << 1,
+ CLSW_AFTERPLAYBACK_MASK = CLSW_CLOSE | CLSW_STANDBY | CLSW_SHUTDOWN | CLSW_HIBERNATE | CLSW_LOGOFF | CLSW_LOCK,
+ CLSW_FULLSCREEN = CLSW_LOCK << 1,
+ CLSW_NEW = CLSW_FULLSCREEN << 1,
+ CLSW_HELP = CLSW_NEW << 1,
+ CLSW_DVD = CLSW_HELP << 1,
+ CLSW_CD = CLSW_DVD << 1,
+ CLSW_ADD = CLSW_CD << 1,
+ CLSW_MINIMIZED = CLSW_ADD << 1,
+ CLSW_REGEXTVID = CLSW_MINIMIZED << 1, // 16
+ CLSW_REGEXTAUD = CLSW_REGEXTVID << 1,
+ CLSW_REGEXTPL = CLSW_REGEXTAUD << 1,
+ CLSW_UNREGEXT = CLSW_REGEXTPL << 1,
+ CLSW_STARTVALID = CLSW_UNREGEXT << 2,
+ CLSW_NOFOCUS = CLSW_STARTVALID << 1,
+ CLSW_FIXEDSIZE = CLSW_NOFOCUS << 1,
+ CLSW_MONITOR = CLSW_FIXEDSIZE << 1,
+ CLSW_D3DFULLSCREEN = CLSW_MONITOR << 1,
+ CLSW_ADMINOPTION = CLSW_D3DFULLSCREEN << 1,
+ CLSW_SLAVE = CLSW_ADMINOPTION << 1,
+ CLSW_AUDIORENDERER = CLSW_SLAVE << 1,
+ CLSW_RESET = CLSW_AUDIORENDERER << 1,
+ CLSW_UNRECOGNIZEDSWITCH = CLSW_RESET << 1 // 30
};
enum {
- MODE_SHOWCAPTIONMENU,
- MODE_HIDEMENU,
- MODE_FRAMEONLY,
- MODE_BORDERLESS,
- MODE_COUNT
+ MODE_SHOWCAPTIONMENU,
+ MODE_HIDEMENU,
+ MODE_FRAMEONLY,
+ MODE_BORDERLESS,
+ MODE_COUNT
}; // flags for Caption & Menu Mode
enum {
- VIDRNDT_DS_DEFAULT,
- VIDRNDT_DS_OLDRENDERER,
- VIDRNDT_DS_OVERLAYMIXER,
- VIDRNDT_DS_VMR7WINDOWED,
- VIDRNDT_DS_VMR9WINDOWED,
- VIDRNDT_DS_VMR7RENDERLESS,
- VIDRNDT_DS_VMR9RENDERLESS,
- VIDRNDT_DS_DXR,
- VIDRNDT_DS_NULL_COMP,
- VIDRNDT_DS_NULL_UNCOMP,
- VIDRNDT_DS_EVR,
- VIDRNDT_DS_EVR_CUSTOM,
- VIDRNDT_DS_MADVR,
- VIDRNDT_DS_SYNC
+ VIDRNDT_DS_DEFAULT,
+ VIDRNDT_DS_OLDRENDERER,
+ VIDRNDT_DS_OVERLAYMIXER,
+ VIDRNDT_DS_VMR7WINDOWED,
+ VIDRNDT_DS_VMR9WINDOWED,
+ VIDRNDT_DS_VMR7RENDERLESS,
+ VIDRNDT_DS_VMR9RENDERLESS,
+ VIDRNDT_DS_DXR,
+ VIDRNDT_DS_NULL_COMP,
+ VIDRNDT_DS_NULL_UNCOMP,
+ VIDRNDT_DS_EVR,
+ VIDRNDT_DS_EVR_CUSTOM,
+ VIDRNDT_DS_MADVR,
+ VIDRNDT_DS_SYNC
};
// Enumeration for MCE remote control (careful : add 0x010000 for all keys!)
enum MCE_RAW_INPUT {
- MCE_DETAILS = 0x010209,
- MCE_GUIDE = 0x01008D,
- MCE_TVJUMP = 0x010025,
- MCE_STANDBY = 0x010082,
- MCE_OEM1 = 0x010080,
- MCE_OEM2 = 0x010081,
- MCE_MYTV = 0x010046,
- MCE_MYVIDEOS = 0x01004A,
- MCE_MYPICTURES = 0x010049,
- MCE_MYMUSIC = 0x010047,
- MCE_RECORDEDTV = 0x010048,
- MCE_DVDANGLE = 0x01004B,
- MCE_DVDAUDIO = 0x01004C,
- MCE_DVDMENU = 0x010024,
- MCE_DVDSUBTITLE = 0x01004D,
- MCE_RED = 0x01005B,
- MCE_GREEN = 0x01005C,
- MCE_YELLOW = 0x01005D,
- MCE_BLUE = 0x01005E,
- MCE_MEDIA_NEXTTRACK = 0x0100B5,
- MCE_MEDIA_PREVIOUSTRACK = 0x0100B6,
+ MCE_DETAILS = 0x010209,
+ MCE_GUIDE = 0x01008D,
+ MCE_TVJUMP = 0x010025,
+ MCE_STANDBY = 0x010082,
+ MCE_OEM1 = 0x010080,
+ MCE_OEM2 = 0x010081,
+ MCE_MYTV = 0x010046,
+ MCE_MYVIDEOS = 0x01004A,
+ MCE_MYPICTURES = 0x010049,
+ MCE_MYMUSIC = 0x010047,
+ MCE_RECORDEDTV = 0x010048,
+ MCE_DVDANGLE = 0x01004B,
+ MCE_DVDAUDIO = 0x01004C,
+ MCE_DVDMENU = 0x010024,
+ MCE_DVDSUBTITLE = 0x01004D,
+ MCE_RED = 0x01005B,
+ MCE_GREEN = 0x01005C,
+ MCE_YELLOW = 0x01005D,
+ MCE_BLUE = 0x01005E,
+ MCE_MEDIA_NEXTTRACK = 0x0100B5,
+ MCE_MEDIA_PREVIOUSTRACK = 0x0100B6,
};
#define AUDRNDT_NULL_COMP _T("Null Audio Renderer (Any)")
@@ -138,463 +138,463 @@ enum MCE_RAW_INPUT {
typedef enum {
- DVS_HALF,
- DVS_NORMAL,
- DVS_DOUBLE,
- DVS_STRETCH,
- DVS_FROMINSIDE,
- DVS_FROMOUTSIDE,
- DVS_ZOOM1,
- DVS_ZOOM2
+ DVS_HALF,
+ DVS_NORMAL,
+ DVS_DOUBLE,
+ DVS_STRETCH,
+ DVS_FROMINSIDE,
+ DVS_FROMOUTSIDE,
+ DVS_ZOOM1,
+ DVS_ZOOM2
} dvstype;
typedef enum {
- FAV_FILE,
- FAV_DVD,
- FAV_DEVICE
+ FAV_FILE,
+ FAV_DVD,
+ FAV_DEVICE
} favtype;
#define MAX_DVD_POSITION 20
typedef struct {
- ULONGLONG llDVDGuid;
- ULONG lTitle;
- DVD_HMSF_TIMECODE Timecode;
+ ULONGLONG llDVDGuid;
+ ULONG lTitle;
+ DVD_HMSF_TIMECODE Timecode;
} DVD_POSITION;
#define MAX_FILE_POSITION 20
typedef struct {
- CString strFile;
- LONGLONG llPosition;
+ CString strFile;
+ LONGLONG llPosition;
} FILE_POSITION;
enum {
- TIME_TOOLTIP_ABOVE_SEEKBAR,
- TIME_TOOLTIP_BELOW_SEEKBAR
+ TIME_TOOLTIP_ABOVE_SEEKBAR,
+ TIME_TOOLTIP_BELOW_SEEKBAR
};
#pragma pack(push, 1)
typedef struct {
- bool fValid;
- CSize size;
- int bpp, freq;
- DWORD dmDisplayFlags;
+ bool fValid;
+ CSize size;
+ int bpp, freq;
+ DWORD dmDisplayFlags;
} dispmode;
typedef struct {
- double vfr_from;
- double vfr_to;
- bool fChecked;
- dispmode dmFSRes;
- bool fIsData;
+ double vfr_from;
+ double vfr_to;
+ bool fChecked;
+ dispmode dmFSRes;
+ bool fIsData;
} fpsmode;
#define MaxFpsCount 30
typedef struct {
- bool bEnabled;
- fpsmode dmFullscreenRes[MaxFpsCount];
- bool bApplyDefault;
-} AChFR; //AutoChangeFullscrRes
+ bool bEnabled;
+ fpsmode dmFullscreenRes[MaxFpsCount];
+ bool bApplyDefault;
+} AChFR; //AutoChangeFullscrRes
#pragma pack(pop)
class wmcmd : public ACCEL
{
- ACCEL backup;
- UINT appcmdorg;
- UINT mouseorg;
- UINT mouseFSorg;
+ ACCEL backup;
+ UINT appcmdorg;
+ UINT mouseorg;
+ UINT mouseFSorg;
public:
- DWORD dwname;
- UINT appcmd;
- enum {NONE,LDOWN,LUP,LDBLCLK,MDOWN,MUP,MDBLCLK,RDOWN,RUP,RDBLCLK,X1DOWN,X1UP,X1DBLCLK,X2DOWN,X2UP,X2DBLCLK,WUP,WDOWN,LAST};
- UINT mouse;
- UINT mouseFS;
- CStringA rmcmd;
- int rmrepcnt;
-
- wmcmd(WORD cmd = 0) {
- this->cmd = cmd;
- }
-
- wmcmd(WORD cmd, WORD key, BYTE fVirt, DWORD dwname, UINT appcmd = 0, UINT mouse = NONE, UINT mouseFS = NONE, LPCSTR rmcmd = "", int rmrepcnt = 5) {
- this->cmd = cmd;
- this->key = key;
- this->fVirt = fVirt;
- this->appcmd = appcmdorg = appcmd;
- this->dwname = dwname;
- this->mouse = mouseorg = mouse;
- this->mouseFS = mouseFSorg = mouseFS;
- this->rmcmd = rmcmd;
- this->rmrepcnt = rmrepcnt;
- backup = *this;
- }
-
- bool operator == (const wmcmd& wc) const {
- return (cmd > 0 && cmd == wc.cmd);
- }
-
- CString GetName() const {
- return ResStr (dwname);
- }
-
- void Restore() {
- *(ACCEL*)this = backup;
- appcmd = appcmdorg;
- mouse = mouseorg;
- mouseFS = mouseFSorg;
- rmcmd.Empty();
- rmrepcnt = 5;
- }
-
- bool IsModified() const {
- return (memcmp((const ACCEL*)this, &backup, sizeof(ACCEL)) || appcmd != appcmdorg || mouse != mouseorg || mouseFS != mouseFSorg || !rmcmd.IsEmpty() || rmrepcnt != 5);
- }
+ DWORD dwname;
+ UINT appcmd;
+ enum {NONE, LDOWN, LUP, LDBLCLK, MDOWN, MUP, MDBLCLK, RDOWN, RUP, RDBLCLK, X1DOWN, X1UP, X1DBLCLK, X2DOWN, X2UP, X2DBLCLK, WUP, WDOWN, LAST};
+ UINT mouse;
+ UINT mouseFS;
+ CStringA rmcmd;
+ int rmrepcnt;
+
+ wmcmd(WORD cmd = 0) {
+ this->cmd = cmd;
+ }
+
+ wmcmd(WORD cmd, WORD key, BYTE fVirt, DWORD dwname, UINT appcmd = 0, UINT mouse = NONE, UINT mouseFS = NONE, LPCSTR rmcmd = "", int rmrepcnt = 5) {
+ this->cmd = cmd;
+ this->key = key;
+ this->fVirt = fVirt;
+ this->appcmd = appcmdorg = appcmd;
+ this->dwname = dwname;
+ this->mouse = mouseorg = mouse;
+ this->mouseFS = mouseFSorg = mouseFS;
+ this->rmcmd = rmcmd;
+ this->rmrepcnt = rmrepcnt;
+ backup = *this;
+ }
+
+ bool operator == (const wmcmd& wc) const {
+ return (cmd > 0 && cmd == wc.cmd);
+ }
+
+ CString GetName() const {
+ return ResStr(dwname);
+ }
+
+ void Restore() {
+ *(ACCEL*)this = backup;
+ appcmd = appcmdorg;
+ mouse = mouseorg;
+ mouseFS = mouseFSorg;
+ rmcmd.Empty();
+ rmrepcnt = 5;
+ }
+
+ bool IsModified() const {
+ return (memcmp((const ACCEL*)this, &backup, sizeof(ACCEL)) || appcmd != appcmdorg || mouse != mouseorg || mouseFS != mouseFSorg || !rmcmd.IsEmpty() || rmrepcnt != 5);
+ }
};
class CRemoteCtrlClient : public CAsyncSocket
{
protected:
- CCritSec m_csLock;
- CWnd* m_pWnd;
- enum {DISCONNECTED, CONNECTED, CONNECTING} m_nStatus;
- CString m_addr;
+ CCritSec m_csLock;
+ CWnd* m_pWnd;
+ enum {DISCONNECTED, CONNECTED, CONNECTING} m_nStatus;
+ CString m_addr;
- virtual void OnConnect(int nErrorCode);
- virtual void OnClose(int nErrorCode);
- virtual void OnReceive(int nErrorCode);
+ virtual void OnConnect(int nErrorCode);
+ virtual void OnClose(int nErrorCode);
+ virtual void OnReceive(int nErrorCode);
- virtual void OnCommand(CStringA str) = 0;
+ virtual void OnCommand(CStringA str) = 0;
- void ExecuteCommand(CStringA cmd, int repcnt);
+ void ExecuteCommand(CStringA cmd, int repcnt);
public:
- CRemoteCtrlClient();
- void SetHWND(HWND hWnd);
- void Connect(CString addr);
- void DisConnect();
- int GetStatus() const { return m_nStatus; }
+ CRemoteCtrlClient();
+ void SetHWND(HWND hWnd);
+ void Connect(CString addr);
+ void DisConnect();
+ int GetStatus() const { return m_nStatus; }
};
class CWinLircClient : public CRemoteCtrlClient
{
protected:
- virtual void OnCommand(CStringA str);
+ virtual void OnCommand(CStringA str);
public:
- CWinLircClient();
+ CWinLircClient();
};
class CUIceClient : public CRemoteCtrlClient
{
protected:
- virtual void OnCommand(CStringA str);
+ virtual void OnCommand(CStringA str);
public:
- CUIceClient();
+ CUIceClient();
};
class CAppSettings
{
- bool fInitialized;
+ bool fInitialized;
- class CRecentFileAndURLList : public CRecentFileList
- {
- public:
- CRecentFileAndURLList(UINT nStart, LPCTSTR lpszSection,
- LPCTSTR lpszEntryFormat, int nSize,
- int nMaxDispLen = AFX_ABBREV_FILENAME_LEN);
+ class CRecentFileAndURLList : public CRecentFileList
+ {
+ public:
+ CRecentFileAndURLList(UINT nStart, LPCTSTR lpszSection,
+ LPCTSTR lpszEntryFormat, int nSize,
+ int nMaxDispLen = AFX_ABBREV_FILENAME_LEN);
- virtual void Add(LPCTSTR lpszPathName); // we have to override CRecentFileList::Add because the original version can't handle URLs
- };
+ virtual void Add(LPCTSTR lpszPathName); // we have to override CRecentFileList::Add because the original version can't handle URLs
+ };
public:
- // cmdline params
- UINT nCLSwitches;
- CAtlList<CString> slFiles, slDubs, slSubs, slFilters;
-
- // Initial position (used by command line flags)
- REFERENCE_TIME rtShift;
- REFERENCE_TIME rtStart;
- ULONG lDVDTitle;
- ULONG lDVDChapter;
- DVD_HMSF_TIMECODE DVDPosition;
-
- CSize sizeFixedWindow;
- bool HasFixedWindowSize() const { return sizeFixedWindow.cx > 0 || sizeFixedWindow.cy > 0; }
- //int iFixedWidth, iFixedHeight;
- int iMonitor;
-
- CString strPnSPreset;
-
- CString ParseFileName(CString const& param);
- void ParseCommandLine(CAtlList<CString>& cmdln);
-
- // Added a Debug display to the screen (/debug option)
- bool fShowDebugInfo;
-
- int iDXVer;
- int iAdminOption;
-
- UINT nCS; // Control state for toolbars
- int iCaptionMenuMode; // normal -> hidemenu -> frameonly -> borderless
- bool fHideNavigation;
- int iDefaultVideoSize;
- bool fKeepAspectRatio;
- bool fCompMonDeskARDiff;
-
- CRecentFileAndURLList MRU;
- CRecentFileAndURLList MRUDub;
-
- CAutoPtrList<FilterOverride> m_filters;
-
- CRenderersSettings m_RenderersSettings;
-
- int iDSVideoRendererType;
- int iRMVideoRendererType;
- int iQTVideoRendererType;
-
- int nVolume;
- int nBalance;
- bool fMute;
- int nLoops;
- bool fLoopForever;
- bool fRewind;
- int iZoomLevel;
- //int iVideoRendererType;
- CStringW strAudioRendererDisplayName;
- bool fAutoloadAudio;
- bool fAutoloadSubtitles;
- bool fBlockVSFilter;
- bool fEnableWorkerThreadForOpening;
- bool fReportFailedPins;
-
- CStringW strFullScreenMonitor;
- bool fAssociatedWithIcons;
- CStringW strLastOpenDir;
-
- bool fAllowMultipleInst;
- int iTitleBarTextStyle;
- bool fTitleBarTextTitle;
- int iOnTop;
- bool fTrayIcon;
- bool fRememberZoomLevel;
- bool fShowBarsWhenFullScreen;
- int nShowBarsWhenFullScreenTimeOut;
- AChFR AutoChangeFullscrRes;
- bool fExitFullScreenAtTheEnd;
- bool fRestoreResAfterExit;
- bool fRememberWindowPos;
- bool fRememberWindowSize;
- bool fSavePnSZoom;
- float dZoomX;
- float dZoomY;
- bool fSnapToDesktopEdges;
- CRect rcLastWindowPos;
- UINT nLastWindowType;
- CSize sizeAspectRatio;
- bool fKeepHistory;
- UINT nLastUsedPage;
-
- bool bShufflePlaylistItems;
- bool bRememberPlaylistItems;
- bool bHidePlaylistFullScreen;
- bool bFavRememberPos;
- bool bFavRelativeDrive;
-
- CString strDVDPath;
- bool fUseDVDPath;
- LCID idMenuLang, idAudioLang, idSubtitlesLang;
- bool fAutoSpeakerConf;
- bool fClosedCaptions;
-
- STSStyle subdefstyle;
- bool fOverridePlacement;
- int nHorPos, nVerPos;
- int nSubDelayInterval;
- bool fEnableSubtitles;
- bool fUseDefaultSubtitlesStyle;
- bool fPrioritizeExternalSubtitles;
- bool fDisableInternalSubtitles;
- CString strSubtitlePaths;
-
- int nJumpDistS;
- int nJumpDistM;
- int nJumpDistL;
- bool fLimitWindowProportions;
- bool fNotifyMSN;
-
- bool fEnableAudioSwitcher;
- bool fDownSampleTo441;
- bool fAudioTimeShift;
- int iAudioTimeShift;
- bool fCustomChannelMapping;
- DWORD pSpeakerToChannelMap[18][18];
- bool fAudioNormalize;
- bool fAudioNormalizeRecover;
- float dAudioBoost_dB;
-
- bool fIntRealMedia;
- //bool fRealMediaRenderless;
- int iQuickTimeRenderer;
- //float dRealMediaQuickTimeFPS;
-
- CStringArray m_pnspresets;
-
- CList<wmcmd> wmcmds;
- HACCEL hAccel;
-
- bool fWinLirc;
- CString strWinLircAddr;
- CWinLircClient WinLircClient;
- bool fUIce;
- CString strUIceAddr;
- CUIceClient UIceClient;
- bool fGlobalMedia;
-
- CMediaFormats m_Formats;
-
- bool SrcFilters[SRC_LAST + !SRC_LAST];
- bool TraFilters[TRA_LAST + !TRA_LAST];
- bool DXVAFilters[TRA_DXVA_LAST + !TRA_DXVA_LAST];
- bool FFmpegFilters[FFM_LAST + !FFM_LAST];
-
- CString strLogoFileName;
- UINT nLogoId;
- bool fLogoExternal;
-
- bool fHideCDROMsSubMenu;
-
- DWORD dwPriority;
- bool fLaunchfullscreen;
-
- BOOL fEnableWebServer;
- int nWebServerPort;
- int nCmdlnWebServerPort;
- bool fWebServerPrintDebugInfo;
- bool fWebServerUseCompression;
- bool fWebServerLocalhostOnly;
- CString strWebRoot, strWebDefIndex;
- CString strWebServerCGI;
-
- CString strSnapShotPath, strSnapShotExt;
- int iThumbRows, iThumbCols, iThumbWidth;
-
- CString strISDb;
-
- struct Shader {
- CString label;
- CString target;
- CString srcdata;
- };
- CAtlList<Shader> m_shaders;
- CString strShadercombine;
- CString strShadercombineScreenSpace;
-
- // Casimir666 : new settings
- bool fD3DFullscreen;
- bool fMonitorAutoRefreshRate;
- bool fLastFullScreen;
- bool fEnableEDLEditor;
- int iBrightness;
- int iContrast;
- int iHue;
- int iSaturation;
- CString strShaderList;
- CString strShaderListScreenSpace;
- bool fToggleShader;
- bool fToggleShaderScreenSpace;
-
- bool fRememberDVDPos;
- bool fRememberFilePos;
- bool fShowOSD;
- LANGID language;
- bool fFastSeek;
-
- // BDA configuration
- int iDefaultCaptureDevice; // Default capture device (analog=0, 1=digital)
- CString strAnalogVideo;
- CString strAnalogAudio;
- int iAnalogCountry;
- CString strBDANetworkProvider;
- CString strBDATuner;
- CString strBDAReceiver;
- //CString strBDAStandard;
- int iBDAScanFreqStart;
- int iBDAScanFreqEnd;
- int iBDABandwidth;
- bool fBDAUseOffset;
- int iBDAOffset;
- bool fBDAIgnoreEncryptedChannels;
- UINT nDVBLastChannel;
- CAtlList<CDVBChannel> m_DVBChannels;
-
- HWND hMasterWnd;
-
- bool IsD3DFullscreen() const;
- CString SelectedAudioRenderer() const;
- void ResetPositions();
- DVD_POSITION* CurrentDVDPosition();
- bool NewDvd(ULONGLONG llDVDGuid);
- FILE_POSITION* CurrentFilePosition();
- bool NewFile(LPCTSTR strFileName);
-
- void SaveCurrentDVDPosition();
- void ClearDVDPositions();
- void SaveCurrentFilePosition();
- void ClearFilePositions();
-
- void DeserializeHex (LPCTSTR strVal, BYTE* pBuffer, int nBufSize) const;
- CString SerializeHex (BYTE* pBuffer, int nBufSize) const;
+ // cmdline params
+ UINT nCLSwitches;
+ CAtlList<CString> slFiles, slDubs, slSubs, slFilters;
+
+ // Initial position (used by command line flags)
+ REFERENCE_TIME rtShift;
+ REFERENCE_TIME rtStart;
+ ULONG lDVDTitle;
+ ULONG lDVDChapter;
+ DVD_HMSF_TIMECODE DVDPosition;
+
+ CSize sizeFixedWindow;
+ bool HasFixedWindowSize() const { return sizeFixedWindow.cx > 0 || sizeFixedWindow.cy > 0; }
+ //int iFixedWidth, iFixedHeight;
+ int iMonitor;
+
+ CString strPnSPreset;
+
+ CString ParseFileName(CString const& param);
+ void ParseCommandLine(CAtlList<CString>& cmdln);
+
+ // Added a Debug display to the screen (/debug option)
+ bool fShowDebugInfo;
+
+ int iDXVer;
+ int iAdminOption;
+
+ UINT nCS; // Control state for toolbars
+ int iCaptionMenuMode; // normal -> hidemenu -> frameonly -> borderless
+ bool fHideNavigation;
+ int iDefaultVideoSize;
+ bool fKeepAspectRatio;
+ bool fCompMonDeskARDiff;
+
+ CRecentFileAndURLList MRU;
+ CRecentFileAndURLList MRUDub;
+
+ CAutoPtrList<FilterOverride> m_filters;
+
+ CRenderersSettings m_RenderersSettings;
+
+ int iDSVideoRendererType;
+ int iRMVideoRendererType;
+ int iQTVideoRendererType;
+
+ int nVolume;
+ int nBalance;
+ bool fMute;
+ int nLoops;
+ bool fLoopForever;
+ bool fRewind;
+ int iZoomLevel;
+ //int iVideoRendererType;
+ CStringW strAudioRendererDisplayName;
+ bool fAutoloadAudio;
+ bool fAutoloadSubtitles;
+ bool fBlockVSFilter;
+ bool fEnableWorkerThreadForOpening;
+ bool fReportFailedPins;
+
+ CStringW strFullScreenMonitor;
+ bool fAssociatedWithIcons;
+ CStringW strLastOpenDir;
+
+ bool fAllowMultipleInst;
+ int iTitleBarTextStyle;
+ bool fTitleBarTextTitle;
+ int iOnTop;
+ bool fTrayIcon;
+ bool fRememberZoomLevel;
+ bool fShowBarsWhenFullScreen;
+ int nShowBarsWhenFullScreenTimeOut;
+ AChFR AutoChangeFullscrRes;
+ bool fExitFullScreenAtTheEnd;
+ bool fRestoreResAfterExit;
+ bool fRememberWindowPos;
+ bool fRememberWindowSize;
+ bool fSavePnSZoom;
+ float dZoomX;
+ float dZoomY;
+ bool fSnapToDesktopEdges;
+ CRect rcLastWindowPos;
+ UINT nLastWindowType;
+ CSize sizeAspectRatio;
+ bool fKeepHistory;
+ UINT nLastUsedPage;
+
+ bool bShufflePlaylistItems;
+ bool bRememberPlaylistItems;
+ bool bHidePlaylistFullScreen;
+ bool bFavRememberPos;
+ bool bFavRelativeDrive;
+
+ CString strDVDPath;
+ bool fUseDVDPath;
+ LCID idMenuLang, idAudioLang, idSubtitlesLang;
+ bool fAutoSpeakerConf;
+ bool fClosedCaptions;
+
+ STSStyle subdefstyle;
+ bool fOverridePlacement;
+ int nHorPos, nVerPos;
+ int nSubDelayInterval;
+ bool fEnableSubtitles;
+ bool fUseDefaultSubtitlesStyle;
+ bool fPrioritizeExternalSubtitles;
+ bool fDisableInternalSubtitles;
+ CString strSubtitlePaths;
+
+ int nJumpDistS;
+ int nJumpDistM;
+ int nJumpDistL;
+ bool fLimitWindowProportions;
+ bool fNotifyMSN;
+
+ bool fEnableAudioSwitcher;
+ bool fDownSampleTo441;
+ bool fAudioTimeShift;
+ int iAudioTimeShift;
+ bool fCustomChannelMapping;
+ DWORD pSpeakerToChannelMap[18][18];
+ bool fAudioNormalize;
+ bool fAudioNormalizeRecover;
+ float dAudioBoost_dB;
+
+ bool fIntRealMedia;
+ //bool fRealMediaRenderless;
+ int iQuickTimeRenderer;
+ //float dRealMediaQuickTimeFPS;
+
+ CStringArray m_pnspresets;
+
+ CList<wmcmd> wmcmds;
+ HACCEL hAccel;
+
+ bool fWinLirc;
+ CString strWinLircAddr;
+ CWinLircClient WinLircClient;
+ bool fUIce;
+ CString strUIceAddr;
+ CUIceClient UIceClient;
+ bool fGlobalMedia;
+
+ CMediaFormats m_Formats;
+
+ bool SrcFilters[SRC_LAST + !SRC_LAST];
+ bool TraFilters[TRA_LAST + !TRA_LAST];
+ bool DXVAFilters[TRA_DXVA_LAST + !TRA_DXVA_LAST];
+ bool FFmpegFilters[FFM_LAST + !FFM_LAST];
+
+ CString strLogoFileName;
+ UINT nLogoId;
+ bool fLogoExternal;
+
+ bool fHideCDROMsSubMenu;
+
+ DWORD dwPriority;
+ bool fLaunchfullscreen;
+
+ BOOL fEnableWebServer;
+ int nWebServerPort;
+ int nCmdlnWebServerPort;
+ bool fWebServerPrintDebugInfo;
+ bool fWebServerUseCompression;
+ bool fWebServerLocalhostOnly;
+ CString strWebRoot, strWebDefIndex;
+ CString strWebServerCGI;
+
+ CString strSnapShotPath, strSnapShotExt;
+ int iThumbRows, iThumbCols, iThumbWidth;
+
+ CString strISDb;
+
+ struct Shader {
+ CString label;
+ CString target;
+ CString srcdata;
+ };
+ CAtlList<Shader> m_shaders;
+ CString strShadercombine;
+ CString strShadercombineScreenSpace;
+
+ // Casimir666 : new settings
+ bool fD3DFullscreen;
+ bool fMonitorAutoRefreshRate;
+ bool fLastFullScreen;
+ bool fEnableEDLEditor;
+ int iBrightness;
+ int iContrast;
+ int iHue;
+ int iSaturation;
+ CString strShaderList;
+ CString strShaderListScreenSpace;
+ bool fToggleShader;
+ bool fToggleShaderScreenSpace;
+
+ bool fRememberDVDPos;
+ bool fRememberFilePos;
+ bool fShowOSD;
+ LANGID language;
+ bool fFastSeek;
+
+ // BDA configuration
+ int iDefaultCaptureDevice; // Default capture device (analog=0, 1=digital)
+ CString strAnalogVideo;
+ CString strAnalogAudio;
+ int iAnalogCountry;
+ CString strBDANetworkProvider;
+ CString strBDATuner;
+ CString strBDAReceiver;
+ //CString strBDAStandard;
+ int iBDAScanFreqStart;
+ int iBDAScanFreqEnd;
+ int iBDABandwidth;
+ bool fBDAUseOffset;
+ int iBDAOffset;
+ bool fBDAIgnoreEncryptedChannels;
+ UINT nDVBLastChannel;
+ CAtlList<CDVBChannel> m_DVBChannels;
+
+ HWND hMasterWnd;
+
+ bool IsD3DFullscreen() const;
+ CString SelectedAudioRenderer() const;
+ void ResetPositions();
+ DVD_POSITION* CurrentDVDPosition();
+ bool NewDvd(ULONGLONG llDVDGuid);
+ FILE_POSITION* CurrentFilePosition();
+ bool NewFile(LPCTSTR strFileName);
+
+ void SaveCurrentDVDPosition();
+ void ClearDVDPositions();
+ void SaveCurrentFilePosition();
+ void ClearFilePositions();
+
+ void DeserializeHex(LPCTSTR strVal, BYTE* pBuffer, int nBufSize) const;
+ CString SerializeHex(BYTE* pBuffer, int nBufSize) const;
private :
- DVD_POSITION DvdPosition[MAX_DVD_POSITION];
- int nCurrentDvdPosition;
- FILE_POSITION FilePosition[MAX_FILE_POSITION];
- int nCurrentFilePosition;
+ DVD_POSITION DvdPosition[MAX_DVD_POSITION];
+ int nCurrentDvdPosition;
+ FILE_POSITION FilePosition[MAX_FILE_POSITION];
+ int nCurrentFilePosition;
- CString SrcFiltersKeys[SRC_LAST + !SRC_LAST];
- CString TraFiltersKeys[TRA_LAST + !TRA_LAST];
- CString DXVAFiltersKeys[TRA_DXVA_LAST + !TRA_DXVA_LAST];
- CString FFMFiltersKeys[FFM_LAST + !FFM_LAST];
+ CString SrcFiltersKeys[SRC_LAST + !SRC_LAST];
+ CString TraFiltersKeys[TRA_LAST + !TRA_LAST];
+ CString DXVAFiltersKeys[TRA_DXVA_LAST + !TRA_DXVA_LAST];
+ CString FFMFiltersKeys[FFM_LAST + !FFM_LAST];
- __int64 ConvertTimeToMSec(CString& time) const;
- void ExtractDVDStartPos(CString& strParam);
+ __int64 ConvertTimeToMSec(CString& time) const;
+ void ExtractDVDStartPos(CString& strParam);
- void CreateCommands();
+ void CreateCommands();
public:
- CAppSettings();
- virtual ~CAppSettings();
- void UpdateData(bool fSave);
-
- void GetFav(favtype ft, CAtlList<CString>& sl);
- void SetFav(favtype ft, CAtlList<CString>& sl);
- void AddFav(favtype ft, CString s);
- CDVBChannel* FindChannelByPref(int nPrefNumber);
-
- bool fPreventMinimize;
- bool fUseWin7TaskBar;
- bool fExitAfterPlayback;
- bool fNextInDirAfterPlayback;
- bool fUseSearchInFolder;
- bool fUseTimeTooltip;
- int nTimeTooltipPosition;
- int nOSDSize;
- CString strOSDFont;
- CStringW strSubtitlesLanguageOrder;
- CStringW strAudiosLanguageOrder;
-
- int nSpeakerChannels;
-
- bool fRemainingTime;
-
- int nUpdaterAutoCheck;
- int nUpdaterDelay;
-
- bool GetAllowMultiInst() const;
- static bool IsVSFilterInstalled();
- static bool HasEVR();
+ CAppSettings();
+ virtual ~CAppSettings();
+ void UpdateData(bool fSave);
+
+ void GetFav(favtype ft, CAtlList<CString>& sl);
+ void SetFav(favtype ft, CAtlList<CString>& sl);
+ void AddFav(favtype ft, CString s);
+ CDVBChannel* FindChannelByPref(int nPrefNumber);
+
+ bool fPreventMinimize;
+ bool fUseWin7TaskBar;
+ bool fExitAfterPlayback;
+ bool fNextInDirAfterPlayback;
+ bool fUseSearchInFolder;
+ bool fUseTimeTooltip;
+ int nTimeTooltipPosition;
+ int nOSDSize;
+ CString strOSDFont;
+ CStringW strSubtitlesLanguageOrder;
+ CStringW strAudiosLanguageOrder;
+
+ int nSpeakerChannels;
+
+ bool fRemainingTime;
+
+ int nUpdaterAutoCheck;
+ int nUpdaterDelay;
+
+ bool GetAllowMultiInst() const;
+ static bool IsVSFilterInstalled();
+ static bool HasEVR();
private:
- void UpdateRenderersData(bool fSave);
- friend void CRenderersSettings::UpdateData(bool bSave);
+ void UpdateRenderersData(bool fSave);
+ friend void CRenderersSettings::UpdateData(bool bSave);
};
diff --git a/src/mpc-hc/AuthDlg.cpp b/src/mpc-hc/AuthDlg.cpp
index 12e2e4311..17c91bb9a 100644
--- a/src/mpc-hc/AuthDlg.cpp
+++ b/src/mpc-hc/AuthDlg.cpp
@@ -31,10 +31,10 @@
IMPLEMENT_DYNAMIC(CAuthDlg, CDialog)
CAuthDlg::CAuthDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CAuthDlg::IDD, pParent)
- , m_username(_T(""))
- , m_password(_T(""))
- , m_remember(FALSE)
+ : CDialog(CAuthDlg::IDD, pParent)
+ , m_username(_T(""))
+ , m_password(_T(""))
+ , m_remember(FALSE)
{
}
@@ -44,26 +44,26 @@ CAuthDlg::~CAuthDlg()
void CAuthDlg::DoDataExchange(CDataExchange* pDX)
{
- CDialog::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_COMBO1, m_usernamectrl);
- DDX_Text(pDX, IDC_COMBO1, m_username);
- DDX_Text(pDX, IDC_EDIT3, m_password);
- DDX_Check(pDX, IDC_CHECK1, m_remember);
+ CDialog::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_COMBO1, m_usernamectrl);
+ DDX_Text(pDX, IDC_COMBO1, m_username);
+ DDX_Text(pDX, IDC_EDIT3, m_password);
+ DDX_Check(pDX, IDC_CHECK1, m_remember);
}
CString CAuthDlg::DEncrypt(CString str)
{
- for (int i = 0; i < str.GetLength(); i++) {
- str.SetAt(i, str[i]^5);
- }
- return str;
+ for (int i = 0; i < str.GetLength(); i++) {
+ str.SetAt(i, str[i] ^ 5);
+ }
+ return str;
}
BEGIN_MESSAGE_MAP(CAuthDlg, CDialog)
- ON_BN_CLICKED(IDOK, OnBnClickedOk)
- ON_CBN_SELCHANGE(IDC_COMBO1, OnCbnSelchangeCombo1)
- ON_EN_SETFOCUS(IDC_EDIT3, OnEnSetfocusEdit3)
+ ON_BN_CLICKED(IDOK, OnBnClickedOk)
+ ON_CBN_SELCHANGE(IDC_COMBO1, OnCbnSelchangeCombo1)
+ ON_EN_SETFOCUS(IDC_EDIT3, OnEnSetfocusEdit3)
END_MESSAGE_MAP()
@@ -71,88 +71,88 @@ END_MESSAGE_MAP()
BOOL CAuthDlg::OnInitDialog()
{
- CDialog::OnInitDialog();
-
- CWinApp* pApp = AfxGetApp();
-
- if (pApp->m_pszRegistryKey) {
- CRegKey hSecKey(pApp->GetSectionKey(IDS_R_LOGINS));
- if (hSecKey) {
- int i = 0;
- TCHAR username[256], password[256];
- for (;;) {
- DWORD unlen = _countof(username);
- DWORD pwlen = sizeof(password);
- DWORD type = REG_SZ;
- if (ERROR_SUCCESS == RegEnumValue(
- hSecKey, i++, username, &unlen, 0, &type, (BYTE*)password, &pwlen)) {
- m_logins[username] = DEncrypt(password);
- m_usernamectrl.AddString(username);
- } else {
- break;
- }
- }
- }
- } else {
- CAutoVectorPtr<TCHAR> buff;
- buff.Allocate(32767/sizeof(TCHAR));
-
- DWORD len = GetPrivateProfileSection(
- IDS_R_LOGINS, buff, 32767/sizeof(TCHAR), pApp->m_pszProfileName);
-
- TCHAR* p = buff;
- while (*p && len > 0) {
- CString str = p;
- p += str.GetLength()+1;
- len -= str.GetLength()+1;
- CAtlList<CString> sl;
- Explode(str, sl, '=', 2);
- if (sl.GetCount() == 2) {
- m_logins[sl.GetHead()] = DEncrypt(sl.GetTail());
- m_usernamectrl.AddString(sl.GetHead());
- }
- }
- }
-
- m_usernamectrl.SetFocus();
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ CDialog::OnInitDialog();
+
+ CWinApp* pApp = AfxGetApp();
+
+ if (pApp->m_pszRegistryKey) {
+ CRegKey hSecKey(pApp->GetSectionKey(IDS_R_LOGINS));
+ if (hSecKey) {
+ int i = 0;
+ TCHAR username[256], password[256];
+ for (;;) {
+ DWORD unlen = _countof(username);
+ DWORD pwlen = sizeof(password);
+ DWORD type = REG_SZ;
+ if (ERROR_SUCCESS == RegEnumValue(
+ hSecKey, i++, username, &unlen, 0, &type, (BYTE*)password, &pwlen)) {
+ m_logins[username] = DEncrypt(password);
+ m_usernamectrl.AddString(username);
+ } else {
+ break;
+ }
+ }
+ }
+ } else {
+ CAutoVectorPtr<TCHAR> buff;
+ buff.Allocate(32767 / sizeof(TCHAR));
+
+ DWORD len = GetPrivateProfileSection(
+ IDS_R_LOGINS, buff, 32767 / sizeof(TCHAR), pApp->m_pszProfileName);
+
+ TCHAR* p = buff;
+ while (*p && len > 0) {
+ CString str = p;
+ p += str.GetLength() + 1;
+ len -= str.GetLength() + 1;
+ CAtlList<CString> sl;
+ Explode(str, sl, '=', 2);
+ if (sl.GetCount() == 2) {
+ m_logins[sl.GetHead()] = DEncrypt(sl.GetTail());
+ m_usernamectrl.AddString(sl.GetHead());
+ }
+ }
+ }
+
+ m_usernamectrl.SetFocus();
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CAuthDlg::OnBnClickedOk()
{
- UpdateData();
+ UpdateData();
- if (!m_username.IsEmpty()) {
- CWinApp* pApp = AfxGetApp();
- pApp->WriteProfileString(IDS_R_LOGINS, m_username, m_remember ? DEncrypt(m_password) : _T(""));
- }
+ if (!m_username.IsEmpty()) {
+ CWinApp* pApp = AfxGetApp();
+ pApp->WriteProfileString(IDS_R_LOGINS, m_username, m_remember ? DEncrypt(m_password) : _T(""));
+ }
- OnOK();
+ OnOK();
}
void CAuthDlg::OnCbnSelchangeCombo1()
{
- CString username;
- m_usernamectrl.GetLBText(m_usernamectrl.GetCurSel(), username);
-
- CString password;
- if (m_logins.Lookup(username, password)) {
- m_password = password;
- m_remember = TRUE;
- UpdateData(FALSE);
- }
+ CString username;
+ m_usernamectrl.GetLBText(m_usernamectrl.GetCurSel(), username);
+
+ CString password;
+ if (m_logins.Lookup(username, password)) {
+ m_password = password;
+ m_remember = TRUE;
+ UpdateData(FALSE);
+ }
}
void CAuthDlg::OnEnSetfocusEdit3()
{
- UpdateData();
-
- CString password;
- if (m_logins.Lookup(m_username, password)) {
- m_password = password;
- m_remember = TRUE;
- UpdateData(FALSE);
- }
+ UpdateData();
+
+ CString password;
+ if (m_logins.Lookup(m_username, password)) {
+ m_password = password;
+ m_remember = TRUE;
+ UpdateData(FALSE);
+ }
}
diff --git a/src/mpc-hc/AuthDlg.h b/src/mpc-hc/AuthDlg.h
index ba979bfde..6a9240b06 100644
--- a/src/mpc-hc/AuthDlg.h
+++ b/src/mpc-hc/AuthDlg.h
@@ -31,31 +31,31 @@
class CAuthDlg : public CDialog
{
- DECLARE_DYNAMIC(CAuthDlg)
+ DECLARE_DYNAMIC(CAuthDlg)
private:
- CString DEncrypt(CString pw);
- CMapStringToString m_logins;
+ CString DEncrypt(CString pw);
+ CMapStringToString m_logins;
public:
- CAuthDlg(CWnd* pParent = NULL); // standard constructor
- virtual ~CAuthDlg();
+ CAuthDlg(CWnd* pParent = NULL); // standard constructor
+ virtual ~CAuthDlg();
- // Dialog Data
- enum { IDD = IDD_AUTH_DLG };
- CComboBox m_usernamectrl;
- CString m_username;
- CString m_password;
- BOOL m_remember;
+ // Dialog Data
+ enum { IDD = IDD_AUTH_DLG };
+ CComboBox m_usernamectrl;
+ CString m_username;
+ CString m_password;
+ BOOL m_remember;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnBnClickedOk();
- afx_msg void OnCbnSelchangeCombo1();
- afx_msg void OnEnSetfocusEdit3();
+ afx_msg void OnBnClickedOk();
+ afx_msg void OnCbnSelchangeCombo1();
+ afx_msg void OnEnSetfocusEdit3();
};
diff --git a/src/mpc-hc/BaseGraph.cpp b/src/mpc-hc/BaseGraph.cpp
index 93e56901f..cd139c88c 100644
--- a/src/mpc-hc/BaseGraph.cpp
+++ b/src/mpc-hc/BaseGraph.cpp
@@ -32,39 +32,39 @@
BOOL CPlayerWindow::PreCreateWindow(CREATESTRUCT& cs)
{
- if (!CWnd::PreCreateWindow(cs)) {
- return FALSE;
- }
+ if (!CWnd::PreCreateWindow(cs)) {
+ return FALSE;
+ }
- cs.style &= ~WS_BORDER;
- cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS,
- ::LoadCursor(NULL, IDC_HAND), NULL, NULL);
+ cs.style &= ~WS_BORDER;
+ cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS,
+ ::LoadCursor(NULL, IDC_HAND), NULL, NULL);
- return TRUE;
+ return TRUE;
}
BEGIN_MESSAGE_MAP(CPlayerWindow, CWnd)
- ON_WM_ERASEBKGND()
+ ON_WM_ERASEBKGND()
END_MESSAGE_MAP()
BOOL CPlayerWindow::OnEraseBkgnd(CDC* pDC)
{
- for (CWnd* pChild = GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow()) {
- if (!pChild->IsWindowVisible()) {
- continue;
- }
+ for (CWnd* pChild = GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow()) {
+ if (!pChild->IsWindowVisible()) {
+ continue;
+ }
- CRect r;
- pChild->GetClientRect(&r);
- pChild->MapWindowPoints(this, &r);
- pDC->ExcludeClipRect(&r);
- }
+ CRect r;
+ pChild->GetClientRect(&r);
+ pChild->MapWindowPoints(this, &r);
+ pDC->ExcludeClipRect(&r);
+ }
- CRect r;
- GetClientRect(&r);
- pDC->FillSolidRect(&r, 0);
+ CRect r;
+ GetClientRect(&r);
+ pDC->FillSolidRect(&r, 0);
- return TRUE;
+ return TRUE;
}
//
@@ -72,8 +72,8 @@ BOOL CPlayerWindow::OnEraseBkgnd(CDC* pDC)
//
CBaseGraph::CBaseGraph()
- : CUnknown(NAME("CBaseGraph"), NULL)
- , m_hNotifyWnd(NULL)
+ : CUnknown(NAME("CBaseGraph"), NULL)
+ , m_hNotifyWnd(NULL)
{
}
@@ -83,819 +83,819 @@ CBaseGraph::~CBaseGraph()
STDMETHODIMP CBaseGraph::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- QI(IFilterGraph)
- QI(IGraphBuilder)
- QI(IFilterGraph2)
- QI(IGraphBuilder2)
- QI(IMediaControl)
- QI(IMediaSeeking)
- QI(IMediaEventEx)
- QI(IVideoWindow)
- QI(IBasicVideo)
- QI(IBasicAudio)
- QI(IAMOpenProgress)
- QI(IGraphEngine)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IFilterGraph)
+ QI(IGraphBuilder)
+ QI(IFilterGraph2)
+ QI(IGraphBuilder2)
+ QI(IMediaControl)
+ QI(IMediaSeeking)
+ QI(IMediaEventEx)
+ QI(IVideoWindow)
+ QI(IBasicVideo)
+ QI(IBasicAudio)
+ QI(IAMOpenProgress)
+ QI(IGraphEngine)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
void CBaseGraph::ClearMessageQueue()
{
- while (!m_msgqueue.IsEmpty()) {
- GMSG msg = m_msgqueue.RemoveHead();
- FreeEventParams(msg.m_lEventCode, msg.m_lParam1, msg.m_lParam2);
- }
+ while (!m_msgqueue.IsEmpty()) {
+ GMSG msg = m_msgqueue.RemoveHead();
+ FreeEventParams(msg.m_lEventCode, msg.m_lParam1, msg.m_lParam2);
+ }
}
void CBaseGraph::NotifyEvent(long lEventCode, LONG_PTR lParam1, LONG_PTR lParam2)
{
- if (!m_hNotifyWnd) {
- return;
- }
+ if (!m_hNotifyWnd) {
+ return;
+ }
- GMSG msg;
- msg.m_lEventCode = lEventCode;
- msg.m_lParam1 = lParam1;
- msg.m_lParam2 = lParam2;
- m_msgqueue.AddTail(msg);
+ GMSG msg;
+ msg.m_lEventCode = lEventCode;
+ msg.m_lParam1 = lParam1;
+ msg.m_lParam2 = lParam2;
+ m_msgqueue.AddTail(msg);
- PostMessage((HWND)m_hNotifyWnd, m_lNotifyMsg, 0, m_lNotifyInstData);
+ PostMessage((HWND)m_hNotifyWnd, m_lNotifyMsg, 0, m_lNotifyInstData);
}
// IDispatch
STDMETHODIMP CBaseGraph::GetTypeInfoCount(UINT* pctinfo)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IFilterGraph
STDMETHODIMP CBaseGraph::AddFilter(IBaseFilter* pFilter, LPCWSTR pName)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::RemoveFilter(IBaseFilter* pFilter)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::EnumFilters(IEnumFilters** ppEnum)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::FindFilterByName(LPCWSTR pName, IBaseFilter** ppFilter)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::ConnectDirect(IPin* ppinOut, IPin* ppinIn, const AM_MEDIA_TYPE* pmt)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::Reconnect(IPin* ppin)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::Disconnect(IPin* ppin)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::SetDefaultSyncSource()
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IGraphBuilder
STDMETHODIMP CBaseGraph::Connect(IPin* ppinOut, IPin* ppinIn)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::Render(IPin* ppinOut)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::AddSourceFilter(LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter)
{
- *ppFilter = NULL;
- return RenderFile(lpcwstrFileName, NULL);
+ *ppFilter = NULL;
+ return RenderFile(lpcwstrFileName, NULL);
}//E_NOTIMPL;}
STDMETHODIMP CBaseGraph::SetLogFile(DWORD_PTR hFile)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::Abort()
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::ShouldOperationContinue()
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IFilterGraph2
STDMETHODIMP CBaseGraph::AddSourceFilterForMoniker(IMoniker* pMoniker, IBindCtx* pCtx, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::ReconnectEx(IPin* ppin, const AM_MEDIA_TYPE* pmt)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::RenderEx(IPin* pPinOut, DWORD dwFlags, DWORD* pvContext)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IGraphBuilder2
STDMETHODIMP CBaseGraph::IsPinDirection(IPin* pPin, PIN_DIRECTION dir)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::IsPinConnected(IPin* pPin)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::ConnectFilter(IBaseFilter* pBF, IPin* pPinIn)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::ConnectFilter(IPin* pPinOut, IBaseFilter* pBF)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::ConnectFilterDirect(IPin* pPinOut, IBaseFilter* pBF, const AM_MEDIA_TYPE* pmt)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::NukeDownstream(IUnknown* pUnk)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::FindInterface(REFIID iid, void** ppv, BOOL bRemove)
{
- return QueryInterface(iid, ppv);
+ return QueryInterface(iid, ppv);
}
STDMETHODIMP CBaseGraph::AddToROT()
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::RemoveFromROT()
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IMediaControl
STDMETHODIMP CBaseGraph::Run()
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::Pause()
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::Stop()
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::GetState(LONG msTimeout, OAFilterState* pfs)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::RenderFile(BSTR strFilename)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::AddSourceFilter(BSTR strFilename, IDispatch** ppUnk)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_FilterCollection(IDispatch** ppUnk)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_RegFilterCollection(IDispatch** ppUnk)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::StopWhenReady()
{
- return Stop();
+ return Stop();
}
// IMediaEvent
STDMETHODIMP CBaseGraph::GetEventHandle(OAEVENT* hEvent)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::GetEvent(long* lEventCode, LONG_PTR* lParam1, LONG_PTR* lParam2, long msTimeout)
{
- if (m_msgqueue.IsEmpty()) {
- return E_FAIL;
- }
+ if (m_msgqueue.IsEmpty()) {
+ return E_FAIL;
+ }
- GMSG msg = m_msgqueue.RemoveHead();
- if (lEventCode) {
- *lEventCode = msg.m_lEventCode;
- }
- if (lParam1) {
- *lParam1 = msg.m_lParam1;
- }
- if (lParam2) {
- *lParam2 = msg.m_lParam2;
- }
+ GMSG msg = m_msgqueue.RemoveHead();
+ if (lEventCode) {
+ *lEventCode = msg.m_lEventCode;
+ }
+ if (lParam1) {
+ *lParam1 = msg.m_lParam1;
+ }
+ if (lParam2) {
+ *lParam2 = msg.m_lParam2;
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CBaseGraph::WaitForCompletion(long msTimeout, long* pEvCode)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::CancelDefaultHandling(long lEvCode)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::RestoreDefaultHandling(long lEvCode)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::FreeEventParams(long lEvCode, LONG_PTR lParam1, LONG_PTR lParam2)
{
- if (EC_BG_ERROR == lEvCode) {
- if (lParam1) {
- CoTaskMemFree((void*)lParam1);
- }
- }
+ if (EC_BG_ERROR == lEvCode) {
+ if (lParam1) {
+ CoTaskMemFree((void*)lParam1);
+ }
+ }
- return S_OK;
+ return S_OK;
}
// IMediaEventEx
STDMETHODIMP CBaseGraph::SetNotifyWindow(OAHWND hwnd, long lMsg, LONG_PTR lInstanceData)
{
- m_hNotifyWnd = hwnd;
- m_lNotifyMsg = lMsg;
- m_lNotifyInstData = lInstanceData;
+ m_hNotifyWnd = hwnd;
+ m_lNotifyMsg = lMsg;
+ m_lNotifyInstData = lInstanceData;
- if (!IsWindow((HWND)m_hNotifyWnd)) {
- m_hNotifyWnd = NULL;
- return E_FAIL;
- }
+ if (!IsWindow((HWND)m_hNotifyWnd)) {
+ m_hNotifyWnd = NULL;
+ return E_FAIL;
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CBaseGraph::SetNotifyFlags(long lNoNotifyFlags)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::GetNotifyFlags(long* lplNoNotifyFlags)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IMediaSeeking
STDMETHODIMP CBaseGraph::GetCapabilities(DWORD* pCapabilities)
{
- return pCapabilities ? *pCapabilities = AM_SEEKING_CanSeekAbsolute|AM_SEEKING_CanGetCurrentPos|AM_SEEKING_CanGetDuration, S_OK : E_POINTER;
+ return pCapabilities ? *pCapabilities = AM_SEEKING_CanSeekAbsolute | AM_SEEKING_CanGetCurrentPos | AM_SEEKING_CanGetDuration, S_OK : E_POINTER;
}
STDMETHODIMP CBaseGraph::CheckCapabilities(DWORD* pCapabilities)
{
- CheckPointer(pCapabilities, E_POINTER);
+ CheckPointer(pCapabilities, E_POINTER);
- if (*pCapabilities == 0) {
- return S_OK;
- }
+ if (*pCapabilities == 0) {
+ return S_OK;
+ }
- DWORD caps;
- GetCapabilities(&caps);
+ DWORD caps;
+ GetCapabilities(&caps);
- DWORD caps2 = caps & *pCapabilities;
+ DWORD caps2 = caps & *pCapabilities;
- return caps2 == 0 ? E_FAIL : caps2 == *pCapabilities ? S_OK : S_FALSE;
+ return caps2 == 0 ? E_FAIL : caps2 == *pCapabilities ? S_OK : S_FALSE;
}
STDMETHODIMP CBaseGraph::IsFormatSupported(const GUID* pFormat)
{
- return !pFormat ? E_POINTER : *pFormat == TIME_FORMAT_MEDIA_TIME ? S_OK : S_FALSE;
+ return !pFormat ? E_POINTER : *pFormat == TIME_FORMAT_MEDIA_TIME ? S_OK : S_FALSE;
}
STDMETHODIMP CBaseGraph::QueryPreferredFormat(GUID* pFormat)
{
- return GetTimeFormat(pFormat);
+ return GetTimeFormat(pFormat);
}
STDMETHODIMP CBaseGraph::GetTimeFormat(GUID* pFormat)
{
- return pFormat ? *pFormat = TIME_FORMAT_MEDIA_TIME, S_OK : E_POINTER;
+ return pFormat ? *pFormat = TIME_FORMAT_MEDIA_TIME, S_OK : E_POINTER;
}
STDMETHODIMP CBaseGraph::IsUsingTimeFormat(const GUID* pFormat)
{
- return IsFormatSupported(pFormat);
+ return IsFormatSupported(pFormat);
}
STDMETHODIMP CBaseGraph::SetTimeFormat(const GUID* pFormat)
{
- return S_OK == IsFormatSupported(pFormat) ? S_OK : E_INVALIDARG;
+ return S_OK == IsFormatSupported(pFormat) ? S_OK : E_INVALIDARG;
}
STDMETHODIMP CBaseGraph::GetDuration(LONGLONG* pDuration)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::GetStopPosition(LONGLONG* pStop)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::GetCurrentPosition(LONGLONG* pCurrent)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::GetPositions(LONGLONG* pCurrent, LONGLONG* pStop)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::SetRate(double dRate)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::GetRate(double* pdRate)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::GetPreroll(LONGLONG* pllPreroll)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IVideoWindow
STDMETHODIMP CBaseGraph::put_Caption(BSTR strCaption)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_Caption(BSTR* strCaption)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::put_WindowStyle(long WindowStyle)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_WindowStyle(long* WindowStyle)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::put_WindowStyleEx(long WindowStyleEx)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_WindowStyleEx(long* WindowStyleEx)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::put_AutoShow(long AutoShow)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_AutoShow(long* AutoShow)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::put_WindowState(long WindowState)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_WindowState(long* WindowState)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::put_BackgroundPalette(long BackgroundPalette)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_BackgroundPalette(long* pBackgroundPalette)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::put_Visible(long Visible)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_Visible(long* pVisible)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::put_Left(long Left)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_Left(long* pLeft)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::put_Width(long Width)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_Width(long* pWidth)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::put_Top(long Top)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_Top(long* pTop)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::put_Height(long Height)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_Height(long* pHeight)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::put_Owner(OAHWND Owner)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_Owner(OAHWND* Owner)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::put_MessageDrain(OAHWND Drain)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_MessageDrain(OAHWND* Drain)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_BorderColor(long* Color)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::put_BorderColor(long Color)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_FullScreenMode(long* FullScreenMode)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::put_FullScreenMode(long FullScreenMode)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::SetWindowForeground(long Focus)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::NotifyOwnerMessage(OAHWND hwnd, long uMsg, LONG_PTR wParam, LONG_PTR lParam)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::SetWindowPosition(long Left, long Top, long Width, long Height)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::GetWindowPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::GetMinIdealImageSize(long* pWidth, long* pHeight)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::GetMaxIdealImageSize(long* pWidth, long* pHeight)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::GetRestorePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::HideCursor(long HideCursor)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::IsCursorHidden(long* CursorHidden)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IBasicVideo
STDMETHODIMP CBaseGraph::get_AvgTimePerFrame(REFTIME* pAvgTimePerFrame)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_BitRate(long* pBitRate)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_BitErrorRate(long* pBitErrorRate)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_VideoWidth(long* pVideoWidth)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_VideoHeight(long* pVideoHeight)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::put_SourceLeft(long SourceLeft)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_SourceLeft(long* pSourceLeft)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::put_SourceWidth(long SourceWidth)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_SourceWidth(long* pSourceWidth)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::put_SourceTop(long SourceTop)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_SourceTop(long* pSourceTop)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::put_SourceHeight(long SourceHeight)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_SourceHeight(long* pSourceHeight)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::put_DestinationLeft(long DestinationLeft)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_DestinationLeft(long* pDestinationLeft)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::put_DestinationWidth(long DestinationWidth)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_DestinationWidth(long* pDestinationWidth)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::put_DestinationTop(long DestinationTop)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_DestinationTop(long* pDestinationTop)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::put_DestinationHeight(long DestinationHeight)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_DestinationHeight(long* pDestinationHeight)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::SetSourcePosition(long Left, long Top, long Width, long Height)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::GetSourcePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::SetDefaultSourcePosition()
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::SetDestinationPosition(long Left, long Top, long Width, long Height)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::GetDestinationPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::SetDefaultDestinationPosition()
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::GetVideoSize(long* pWidth, long* pHeight)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::GetVideoPaletteEntries(long StartIndex, long Entries, long* pRetrieved, long* pPalette)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::GetCurrentImage(long* pBufferSize, long* pDIBImage)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::IsUsingDefaultSource()
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::IsUsingDefaultDestination()
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IBasicAudio
STDMETHODIMP CBaseGraph::put_Volume(long lVolume)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_Volume(long* plVolume)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::put_Balance(long lBalance)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::get_Balance(long* plBalance)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IAMOpenProgress
STDMETHODIMP CBaseGraph::QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CBaseGraph::AbortOperation()
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IGraphEngine
STDMETHODIMP_(engine_t) CBaseGraph::GetEngine()
{
- return DirectShow;
+ return DirectShow;
}
diff --git a/src/mpc-hc/BaseGraph.h b/src/mpc-hc/BaseGraph.h
index be0454201..25c7f58d6 100644
--- a/src/mpc-hc/BaseGraph.h
+++ b/src/mpc-hc/BaseGraph.h
@@ -29,12 +29,12 @@
class CPlayerWindow : public CWnd
{
public:
- CPlayerWindow() {}
+ CPlayerWindow() {}
protected:
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
- DECLARE_MESSAGE_MAP()
+ virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
+ afx_msg BOOL OnEraseBkgnd(CDC* pDC);
+ DECLARE_MESSAGE_MAP()
};
typedef enum {DirectShow = 0, RealMedia, QuickTime, ShockWave} engine_t;
@@ -42,218 +42,218 @@ typedef enum {DirectShow = 0, RealMedia, QuickTime, ShockWave} engine_t;
interface __declspec(uuid("B110CDE5-6331-4118-8AAF-A870D6F7E2E4"))
IGraphEngine :
public IUnknown {
- STDMETHOD_(engine_t, GetEngine) () = 0;
+ STDMETHOD_(engine_t, GetEngine)() = 0;
};
enum {
- EC_BG_AUDIO_CHANGED = EC_USER+1,
- EC_BG_ERROR
+ EC_BG_AUDIO_CHANGED = EC_USER + 1,
+ EC_BG_ERROR
};
class CBaseGraph
- : public CUnknown
- , public IGraphBuilder2
- , public IMediaControl
- , public IMediaEventEx
- , public IMediaSeeking
- , public IVideoWindow
- , public IBasicVideo
- , public IBasicAudio
- , public IAMOpenProgress
- , public IGraphEngine
+ : public CUnknown
+ , public IGraphBuilder2
+ , public IMediaControl
+ , public IMediaEventEx
+ , public IMediaSeeking
+ , public IVideoWindow
+ , public IBasicVideo
+ , public IBasicAudio
+ , public IAMOpenProgress
+ , public IGraphEngine
{
- OAHWND m_hNotifyWnd;
- long m_lNotifyMsg;
- LONG_PTR m_lNotifyInstData;
+ OAHWND m_hNotifyWnd;
+ long m_lNotifyMsg;
+ LONG_PTR m_lNotifyInstData;
- typedef struct {
- long m_lEventCode;
- LONG_PTR m_lParam1, m_lParam2;
- } GMSG;
- CList<GMSG> m_msgqueue;
+ typedef struct {
+ long m_lEventCode;
+ LONG_PTR m_lParam1, m_lParam2;
+ } GMSG;
+ CList<GMSG> m_msgqueue;
protected:
- void ClearMessageQueue();
+ void ClearMessageQueue();
public:
- CBaseGraph();
- virtual ~CBaseGraph();
+ CBaseGraph();
+ virtual ~CBaseGraph();
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- void NotifyEvent(long lEventCode, LONG_PTR lParam1 = 0, LONG_PTR lParam2 = 0);
+ void NotifyEvent(long lEventCode, LONG_PTR lParam1 = 0, LONG_PTR lParam2 = 0);
protected:
- // IDispatch
- STDMETHODIMP GetTypeInfoCount(UINT* pctinfo);
- STDMETHODIMP GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo);
- STDMETHODIMP GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId);
- STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr);
+ // IDispatch
+ STDMETHODIMP GetTypeInfoCount(UINT* pctinfo);
+ STDMETHODIMP GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo);
+ STDMETHODIMP GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId);
+ STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr);
- // IFilterGraph
- STDMETHODIMP AddFilter(IBaseFilter* pFilter, LPCWSTR pName);
- STDMETHODIMP RemoveFilter(IBaseFilter* pFilter);
- STDMETHODIMP EnumFilters(IEnumFilters** ppEnum);
- STDMETHODIMP FindFilterByName(LPCWSTR pName, IBaseFilter** ppFilter);
- STDMETHODIMP ConnectDirect(IPin* ppinOut, IPin* ppinIn, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP Reconnect(IPin* ppin);
- STDMETHODIMP Disconnect(IPin* ppin);
- STDMETHODIMP SetDefaultSyncSource();
+ // IFilterGraph
+ STDMETHODIMP AddFilter(IBaseFilter* pFilter, LPCWSTR pName);
+ STDMETHODIMP RemoveFilter(IBaseFilter* pFilter);
+ STDMETHODIMP EnumFilters(IEnumFilters** ppEnum);
+ STDMETHODIMP FindFilterByName(LPCWSTR pName, IBaseFilter** ppFilter);
+ STDMETHODIMP ConnectDirect(IPin* ppinOut, IPin* ppinIn, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP Reconnect(IPin* ppin);
+ STDMETHODIMP Disconnect(IPin* ppin);
+ STDMETHODIMP SetDefaultSyncSource();
- // IGraphBuilder
- STDMETHODIMP Connect(IPin* ppinOut, IPin* ppinIn);
- STDMETHODIMP Render(IPin* ppinOut);
- STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
- STDMETHODIMP AddSourceFilter(LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter);
- STDMETHODIMP SetLogFile(DWORD_PTR hFile);
- STDMETHODIMP Abort();
- STDMETHODIMP ShouldOperationContinue();
+ // IGraphBuilder
+ STDMETHODIMP Connect(IPin* ppinOut, IPin* ppinIn);
+ STDMETHODIMP Render(IPin* ppinOut);
+ STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
+ STDMETHODIMP AddSourceFilter(LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter);
+ STDMETHODIMP SetLogFile(DWORD_PTR hFile);
+ STDMETHODIMP Abort();
+ STDMETHODIMP ShouldOperationContinue();
- // IFilterGraph2
- STDMETHODIMP AddSourceFilterForMoniker(IMoniker* pMoniker, IBindCtx* pCtx, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter);
- STDMETHODIMP ReconnectEx(IPin* ppin, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP RenderEx(IPin* pPinOut, DWORD dwFlags, DWORD* pvContext);
+ // IFilterGraph2
+ STDMETHODIMP AddSourceFilterForMoniker(IMoniker* pMoniker, IBindCtx* pCtx, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter);
+ STDMETHODIMP ReconnectEx(IPin* ppin, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP RenderEx(IPin* pPinOut, DWORD dwFlags, DWORD* pvContext);
- // IGraphBuilder2
- STDMETHODIMP IsPinDirection(IPin* pPin, PIN_DIRECTION dir);
- STDMETHODIMP IsPinConnected(IPin* pPin);
- STDMETHODIMP ConnectFilter(IBaseFilter* pBF, IPin* pPinIn);
- STDMETHODIMP ConnectFilter(IPin* pPinOut, IBaseFilter* pBF);
- STDMETHODIMP ConnectFilterDirect(IPin* pPinOut, IBaseFilter* pBF, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP NukeDownstream(IUnknown* pUnk);
- STDMETHODIMP FindInterface(REFIID iid, void** ppv, BOOL bRemove);
- STDMETHODIMP AddToROT();
- STDMETHODIMP RemoveFromROT();
+ // IGraphBuilder2
+ STDMETHODIMP IsPinDirection(IPin* pPin, PIN_DIRECTION dir);
+ STDMETHODIMP IsPinConnected(IPin* pPin);
+ STDMETHODIMP ConnectFilter(IBaseFilter* pBF, IPin* pPinIn);
+ STDMETHODIMP ConnectFilter(IPin* pPinOut, IBaseFilter* pBF);
+ STDMETHODIMP ConnectFilterDirect(IPin* pPinOut, IBaseFilter* pBF, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP NukeDownstream(IUnknown* pUnk);
+ STDMETHODIMP FindInterface(REFIID iid, void** ppv, BOOL bRemove);
+ STDMETHODIMP AddToROT();
+ STDMETHODIMP RemoveFromROT();
- // IMediaControl
- STDMETHODIMP Run();
- STDMETHODIMP Pause();
- STDMETHODIMP Stop();
- STDMETHODIMP GetState(LONG msTimeout, OAFilterState* pfs);
- STDMETHODIMP RenderFile(BSTR strFilename);
- STDMETHODIMP AddSourceFilter(BSTR strFilename, IDispatch** ppUnk);
- STDMETHODIMP get_FilterCollection(IDispatch** ppUnk);
- STDMETHODIMP get_RegFilterCollection(IDispatch** ppUnk);
- STDMETHODIMP StopWhenReady();
+ // IMediaControl
+ STDMETHODIMP Run();
+ STDMETHODIMP Pause();
+ STDMETHODIMP Stop();
+ STDMETHODIMP GetState(LONG msTimeout, OAFilterState* pfs);
+ STDMETHODIMP RenderFile(BSTR strFilename);
+ STDMETHODIMP AddSourceFilter(BSTR strFilename, IDispatch** ppUnk);
+ STDMETHODIMP get_FilterCollection(IDispatch** ppUnk);
+ STDMETHODIMP get_RegFilterCollection(IDispatch** ppUnk);
+ STDMETHODIMP StopWhenReady();
- // IMediaEvent
- STDMETHODIMP GetEventHandle(OAEVENT* hEvent);
- STDMETHODIMP GetEvent(long* lEventCode, LONG_PTR* lParam1, LONG_PTR* lParam2, long msTimeout);
- STDMETHODIMP WaitForCompletion(long msTimeout, long* pEvCode);
- STDMETHODIMP CancelDefaultHandling(long lEvCode);
- STDMETHODIMP RestoreDefaultHandling(long lEvCode);
- STDMETHODIMP FreeEventParams(long lEvCode, LONG_PTR lParam1, LONG_PTR lParam2);
+ // IMediaEvent
+ STDMETHODIMP GetEventHandle(OAEVENT* hEvent);
+ STDMETHODIMP GetEvent(long* lEventCode, LONG_PTR* lParam1, LONG_PTR* lParam2, long msTimeout);
+ STDMETHODIMP WaitForCompletion(long msTimeout, long* pEvCode);
+ STDMETHODIMP CancelDefaultHandling(long lEvCode);
+ STDMETHODIMP RestoreDefaultHandling(long lEvCode);
+ STDMETHODIMP FreeEventParams(long lEvCode, LONG_PTR lParam1, LONG_PTR lParam2);
- // IMediaEventEx
- STDMETHODIMP SetNotifyWindow(OAHWND hwnd, long lMsg, LONG_PTR lInstanceData);
- STDMETHODIMP SetNotifyFlags(long lNoNotifyFlags);
- STDMETHODIMP GetNotifyFlags(long* lplNoNotifyFlags);
+ // IMediaEventEx
+ STDMETHODIMP SetNotifyWindow(OAHWND hwnd, long lMsg, LONG_PTR lInstanceData);
+ STDMETHODIMP SetNotifyFlags(long lNoNotifyFlags);
+ STDMETHODIMP GetNotifyFlags(long* lplNoNotifyFlags);
- // IMediaSeeking
- STDMETHODIMP GetCapabilities(DWORD* pCapabilities);
- STDMETHODIMP CheckCapabilities(DWORD* pCapabilities);
- STDMETHODIMP IsFormatSupported(const GUID* pFormat);
- STDMETHODIMP QueryPreferredFormat(GUID* pFormat);
- STDMETHODIMP GetTimeFormat(GUID* pFormat);
- STDMETHODIMP IsUsingTimeFormat(const GUID* pFormat);
- STDMETHODIMP SetTimeFormat(const GUID* pFormat);
- STDMETHODIMP GetDuration(LONGLONG* pDuration);
- STDMETHODIMP GetStopPosition(LONGLONG* pStop);
- STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
- STDMETHODIMP ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat);
- STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
- STDMETHODIMP GetPositions(LONGLONG* pCurrent, LONGLONG* pStop);
- STDMETHODIMP GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest);
- STDMETHODIMP SetRate(double dRate);
- STDMETHODIMP GetRate(double* pdRate);
- STDMETHODIMP GetPreroll(LONGLONG* pllPreroll);
+ // IMediaSeeking
+ STDMETHODIMP GetCapabilities(DWORD* pCapabilities);
+ STDMETHODIMP CheckCapabilities(DWORD* pCapabilities);
+ STDMETHODIMP IsFormatSupported(const GUID* pFormat);
+ STDMETHODIMP QueryPreferredFormat(GUID* pFormat);
+ STDMETHODIMP GetTimeFormat(GUID* pFormat);
+ STDMETHODIMP IsUsingTimeFormat(const GUID* pFormat);
+ STDMETHODIMP SetTimeFormat(const GUID* pFormat);
+ STDMETHODIMP GetDuration(LONGLONG* pDuration);
+ STDMETHODIMP GetStopPosition(LONGLONG* pStop);
+ STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
+ STDMETHODIMP ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat);
+ STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
+ STDMETHODIMP GetPositions(LONGLONG* pCurrent, LONGLONG* pStop);
+ STDMETHODIMP GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest);
+ STDMETHODIMP SetRate(double dRate);
+ STDMETHODIMP GetRate(double* pdRate);
+ STDMETHODIMP GetPreroll(LONGLONG* pllPreroll);
- // IVideoWindow
- STDMETHODIMP put_Caption(BSTR strCaption);
- STDMETHODIMP get_Caption(BSTR* strCaption);
- STDMETHODIMP put_WindowStyle(long WindowStyle);
- STDMETHODIMP get_WindowStyle(long* WindowStyle);
- STDMETHODIMP put_WindowStyleEx(long WindowStyleEx);
- STDMETHODIMP get_WindowStyleEx(long* WindowStyleEx);
- STDMETHODIMP put_AutoShow(long AutoShow);
- STDMETHODIMP get_AutoShow(long* AutoShow);
- STDMETHODIMP put_WindowState(long WindowState);
- STDMETHODIMP get_WindowState(long* WindowState);
- STDMETHODIMP put_BackgroundPalette(long BackgroundPalette);
- STDMETHODIMP get_BackgroundPalette(long* pBackgroundPalette);
- STDMETHODIMP put_Visible(long Visible);
- STDMETHODIMP get_Visible(long* pVisible);
- STDMETHODIMP put_Left(long Left);
- STDMETHODIMP get_Left(long* pLeft);
- STDMETHODIMP put_Width(long Width);
- STDMETHODIMP get_Width(long* pWidth);
- STDMETHODIMP put_Top(long Top);
- STDMETHODIMP get_Top(long* pTop);
- STDMETHODIMP put_Height(long Height);
- STDMETHODIMP get_Height(long* pHeight);
- STDMETHODIMP put_Owner(OAHWND Owner);
- STDMETHODIMP get_Owner(OAHWND* Owner);
- STDMETHODIMP put_MessageDrain(OAHWND Drain);
- STDMETHODIMP get_MessageDrain(OAHWND* Drain);
- STDMETHODIMP get_BorderColor(long* Color);
- STDMETHODIMP put_BorderColor(long Color);
- STDMETHODIMP get_FullScreenMode(long* FullScreenMode);
- STDMETHODIMP put_FullScreenMode(long FullScreenMode);
- STDMETHODIMP SetWindowForeground(long Focus);
- STDMETHODIMP NotifyOwnerMessage(OAHWND hwnd, long uMsg, LONG_PTR wParam, LONG_PTR lParam);
- STDMETHODIMP SetWindowPosition(long Left, long Top, long Width, long Height);
- STDMETHODIMP GetWindowPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight);
- STDMETHODIMP GetMinIdealImageSize(long* pWidth, long* pHeight);
- STDMETHODIMP GetMaxIdealImageSize(long* pWidth, long* pHeight);
- STDMETHODIMP GetRestorePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight);
- STDMETHODIMP HideCursor(long HideCursor);
- STDMETHODIMP IsCursorHidden(long* CursorHidden);
+ // IVideoWindow
+ STDMETHODIMP put_Caption(BSTR strCaption);
+ STDMETHODIMP get_Caption(BSTR* strCaption);
+ STDMETHODIMP put_WindowStyle(long WindowStyle);
+ STDMETHODIMP get_WindowStyle(long* WindowStyle);
+ STDMETHODIMP put_WindowStyleEx(long WindowStyleEx);
+ STDMETHODIMP get_WindowStyleEx(long* WindowStyleEx);
+ STDMETHODIMP put_AutoShow(long AutoShow);
+ STDMETHODIMP get_AutoShow(long* AutoShow);
+ STDMETHODIMP put_WindowState(long WindowState);
+ STDMETHODIMP get_WindowState(long* WindowState);
+ STDMETHODIMP put_BackgroundPalette(long BackgroundPalette);
+ STDMETHODIMP get_BackgroundPalette(long* pBackgroundPalette);
+ STDMETHODIMP put_Visible(long Visible);
+ STDMETHODIMP get_Visible(long* pVisible);
+ STDMETHODIMP put_Left(long Left);
+ STDMETHODIMP get_Left(long* pLeft);
+ STDMETHODIMP put_Width(long Width);
+ STDMETHODIMP get_Width(long* pWidth);
+ STDMETHODIMP put_Top(long Top);
+ STDMETHODIMP get_Top(long* pTop);
+ STDMETHODIMP put_Height(long Height);
+ STDMETHODIMP get_Height(long* pHeight);
+ STDMETHODIMP put_Owner(OAHWND Owner);
+ STDMETHODIMP get_Owner(OAHWND* Owner);
+ STDMETHODIMP put_MessageDrain(OAHWND Drain);
+ STDMETHODIMP get_MessageDrain(OAHWND* Drain);
+ STDMETHODIMP get_BorderColor(long* Color);
+ STDMETHODIMP put_BorderColor(long Color);
+ STDMETHODIMP get_FullScreenMode(long* FullScreenMode);
+ STDMETHODIMP put_FullScreenMode(long FullScreenMode);
+ STDMETHODIMP SetWindowForeground(long Focus);
+ STDMETHODIMP NotifyOwnerMessage(OAHWND hwnd, long uMsg, LONG_PTR wParam, LONG_PTR lParam);
+ STDMETHODIMP SetWindowPosition(long Left, long Top, long Width, long Height);
+ STDMETHODIMP GetWindowPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight);
+ STDMETHODIMP GetMinIdealImageSize(long* pWidth, long* pHeight);
+ STDMETHODIMP GetMaxIdealImageSize(long* pWidth, long* pHeight);
+ STDMETHODIMP GetRestorePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight);
+ STDMETHODIMP HideCursor(long HideCursor);
+ STDMETHODIMP IsCursorHidden(long* CursorHidden);
- // IBasicVideo
- STDMETHODIMP get_AvgTimePerFrame(REFTIME* pAvgTimePerFrame);
- STDMETHODIMP get_BitRate(long* pBitRate);
- STDMETHODIMP get_BitErrorRate(long* pBitErrorRate);
- STDMETHODIMP get_VideoWidth(long* pVideoWidth);
- STDMETHODIMP get_VideoHeight(long* pVideoHeight);
- STDMETHODIMP put_SourceLeft(long SourceLeft);
- STDMETHODIMP get_SourceLeft(long* pSourceLeft);
- STDMETHODIMP put_SourceWidth(long SourceWidth);
- STDMETHODIMP get_SourceWidth(long* pSourceWidth);
- STDMETHODIMP put_SourceTop(long SourceTop);
- STDMETHODIMP get_SourceTop(long* pSourceTop);
- STDMETHODIMP put_SourceHeight(long SourceHeight);
- STDMETHODIMP get_SourceHeight(long* pSourceHeight);
- STDMETHODIMP put_DestinationLeft(long DestinationLeft);
- STDMETHODIMP get_DestinationLeft(long* pDestinationLeft);
- STDMETHODIMP put_DestinationWidth(long DestinationWidth);
- STDMETHODIMP get_DestinationWidth(long* pDestinationWidth);
- STDMETHODIMP put_DestinationTop(long DestinationTop);
- STDMETHODIMP get_DestinationTop(long* pDestinationTop);
- STDMETHODIMP put_DestinationHeight(long DestinationHeight);
- STDMETHODIMP get_DestinationHeight(long* pDestinationHeight);
- STDMETHODIMP SetSourcePosition(long Left, long Top, long Width, long Height);
- STDMETHODIMP GetSourcePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight);
- STDMETHODIMP SetDefaultSourcePosition();
- STDMETHODIMP SetDestinationPosition(long Left, long Top, long Width, long Height);
- STDMETHODIMP GetDestinationPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight);
- STDMETHODIMP SetDefaultDestinationPosition();
- STDMETHODIMP GetVideoSize(long* pWidth, long* pHeight);
- STDMETHODIMP GetVideoPaletteEntries(long StartIndex, long Entries, long* pRetrieved, long* pPalette);
- STDMETHODIMP GetCurrentImage(long* pBufferSize, long* pDIBImage);
- STDMETHODIMP IsUsingDefaultSource();
- STDMETHODIMP IsUsingDefaultDestination();
+ // IBasicVideo
+ STDMETHODIMP get_AvgTimePerFrame(REFTIME* pAvgTimePerFrame);
+ STDMETHODIMP get_BitRate(long* pBitRate);
+ STDMETHODIMP get_BitErrorRate(long* pBitErrorRate);
+ STDMETHODIMP get_VideoWidth(long* pVideoWidth);
+ STDMETHODIMP get_VideoHeight(long* pVideoHeight);
+ STDMETHODIMP put_SourceLeft(long SourceLeft);
+ STDMETHODIMP get_SourceLeft(long* pSourceLeft);
+ STDMETHODIMP put_SourceWidth(long SourceWidth);
+ STDMETHODIMP get_SourceWidth(long* pSourceWidth);
+ STDMETHODIMP put_SourceTop(long SourceTop);
+ STDMETHODIMP get_SourceTop(long* pSourceTop);
+ STDMETHODIMP put_SourceHeight(long SourceHeight);
+ STDMETHODIMP get_SourceHeight(long* pSourceHeight);
+ STDMETHODIMP put_DestinationLeft(long DestinationLeft);
+ STDMETHODIMP get_DestinationLeft(long* pDestinationLeft);
+ STDMETHODIMP put_DestinationWidth(long DestinationWidth);
+ STDMETHODIMP get_DestinationWidth(long* pDestinationWidth);
+ STDMETHODIMP put_DestinationTop(long DestinationTop);
+ STDMETHODIMP get_DestinationTop(long* pDestinationTop);
+ STDMETHODIMP put_DestinationHeight(long DestinationHeight);
+ STDMETHODIMP get_DestinationHeight(long* pDestinationHeight);
+ STDMETHODIMP SetSourcePosition(long Left, long Top, long Width, long Height);
+ STDMETHODIMP GetSourcePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight);
+ STDMETHODIMP SetDefaultSourcePosition();
+ STDMETHODIMP SetDestinationPosition(long Left, long Top, long Width, long Height);
+ STDMETHODIMP GetDestinationPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight);
+ STDMETHODIMP SetDefaultDestinationPosition();
+ STDMETHODIMP GetVideoSize(long* pWidth, long* pHeight);
+ STDMETHODIMP GetVideoPaletteEntries(long StartIndex, long Entries, long* pRetrieved, long* pPalette);
+ STDMETHODIMP GetCurrentImage(long* pBufferSize, long* pDIBImage);
+ STDMETHODIMP IsUsingDefaultSource();
+ STDMETHODIMP IsUsingDefaultDestination();
- // IBasicAudio
- STDMETHODIMP put_Volume(long lVolume);
- STDMETHODIMP get_Volume(long* plVolume);
- STDMETHODIMP put_Balance(long lBalance);
- STDMETHODIMP get_Balance(long* plBalance);
+ // IBasicAudio
+ STDMETHODIMP put_Volume(long lVolume);
+ STDMETHODIMP get_Volume(long* plVolume);
+ STDMETHODIMP put_Balance(long lBalance);
+ STDMETHODIMP get_Balance(long* plBalance);
- // IAMOpenProgress
- STDMETHODIMP QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent);
- STDMETHODIMP AbortOperation();
+ // IAMOpenProgress
+ STDMETHODIMP QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent);
+ STDMETHODIMP AbortOperation();
- // IGraphEngine
- STDMETHODIMP_(engine_t) GetEngine();
+ // IGraphEngine
+ STDMETHODIMP_(engine_t) GetEngine();
};
diff --git a/src/mpc-hc/CShockwaveFlash.h b/src/mpc-hc/CShockwaveFlash.h
index 139287b25..7e76d497d 100644
--- a/src/mpc-hc/CShockwaveFlash.h
+++ b/src/mpc-hc/CShockwaveFlash.h
@@ -30,357 +30,357 @@
class CShockwaveFlash : public CWnd
{
protected:
- DECLARE_DYNCREATE(CShockwaveFlash)
+ DECLARE_DYNCREATE(CShockwaveFlash)
public:
- CLSID const& GetClsid() {
- static CLSID const clsid
- = { 0xD27CDB6E, 0xAE6D, 0x11CF, { 0x96, 0xB8, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } };
- return clsid;
- }
- virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle,
- const RECT& rect, CWnd* pParentWnd, UINT nID,
- CCreateContext* pContext = NULL) {
- return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID);
- }
+ CLSID const& GetClsid() {
+ static CLSID const clsid
+ = { 0xD27CDB6E, 0xAE6D, 0x11CF, { 0x96, 0xB8, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } };
+ return clsid;
+ }
+ virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle,
+ const RECT& rect, CWnd* pParentWnd, UINT nID,
+ CCreateContext* pContext = NULL) {
+ return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID);
+ }
- BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd,
- UINT nID, CFile* pPersist = NULL, BOOL bStorage = FALSE,
- BSTR bstrLicKey = NULL) {
- return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID,
- pPersist, bStorage, bstrLicKey);
- }
+ BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd,
+ UINT nID, CFile* pPersist = NULL, BOOL bStorage = FALSE,
+ BSTR bstrLicKey = NULL) {
+ return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID,
+ pPersist, bStorage, bstrLicKey);
+ }
- // Attributes
+ // Attributes
public:
- // Operations
+ // Operations
public:
- long get_ReadyState() {
- long result;
- InvokeHelper(DISPID_READYSTATE, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
- return result;
- }
- long get_TotalFrames() {
- long result;
- InvokeHelper(0x7c, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
- return result;
- }
- BOOL get_Playing() {
- BOOL result;
- InvokeHelper(0x7d, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
- return result;
- }
- void put_Playing(BOOL newValue) {
- static BYTE parms[] = VTS_BOOL ;
- InvokeHelper(0x7d, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- long get_Quality() {
- long result;
- InvokeHelper(0x69, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
- return result;
- }
- void put_Quality(long newValue) {
- static BYTE parms[] = VTS_I4 ;
- InvokeHelper(0x69, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- long get_ScaleMode() {
- long result;
- InvokeHelper(0x78, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
- return result;
- }
- void put_ScaleMode(long newValue) {
- static BYTE parms[] = VTS_I4 ;
- InvokeHelper(0x78, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- long get_AlignMode() {
- long result;
- InvokeHelper(0x79, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
- return result;
- }
- void put_AlignMode(long newValue) {
- static BYTE parms[] = VTS_I4 ;
- InvokeHelper(0x79, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- long get_BackgroundColor() {
- long result;
- InvokeHelper(0x7b, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
- return result;
- }
- void put_BackgroundColor(long newValue) {
- static BYTE parms[] = VTS_I4 ;
- InvokeHelper(0x7b, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- BOOL get_Loop() {
- BOOL result;
- InvokeHelper(0x6a, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
- return result;
- }
- void put_Loop(BOOL newValue) {
- static BYTE parms[] = VTS_BOOL ;
- InvokeHelper(0x6a, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- CString get_Movie() {
- CString result;
- InvokeHelper(0x66, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
- return result;
- }
- void put_Movie(LPCTSTR newValue) {
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0x66, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- long get_FrameNum() {
- long result;
- InvokeHelper(0x6b, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
- return result;
- }
- void put_FrameNum(long newValue) {
- static BYTE parms[] = VTS_I4 ;
- InvokeHelper(0x6b, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- void SetZoomRect(long left, long top, long right, long bottom) {
- static BYTE parms[] = VTS_I4 VTS_I4 VTS_I4 VTS_I4 ;
- InvokeHelper(0x6d, DISPATCH_METHOD, VT_EMPTY, NULL, parms, left, top, right, bottom);
- }
- void Zoom(long factor) {
- static BYTE parms[] = VTS_I4 ;
- InvokeHelper(0x76, DISPATCH_METHOD, VT_EMPTY, NULL, parms, factor);
- }
- void Pan(long x, long y, long mode) {
- static BYTE parms[] = VTS_I4 VTS_I4 VTS_I4 ;
- InvokeHelper(0x77, DISPATCH_METHOD, VT_EMPTY, NULL, parms, x, y, mode);
- }
- void Play() {
- InvokeHelper(0x70, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
- }
- void Stop() {
- InvokeHelper(0x71, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
- }
- void Back() {
- InvokeHelper(0x72, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
- }
- void Forward() {
- InvokeHelper(0x73, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
- }
- void Rewind() {
- InvokeHelper(0x74, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
- }
- void StopPlay() {
- InvokeHelper(0x7e, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
- }
- void GotoFrame(long FrameNum) {
- static BYTE parms[] = VTS_I4 ;
- InvokeHelper(0x7f, DISPATCH_METHOD, VT_EMPTY, NULL, parms, FrameNum);
- }
- long CurrentFrame() {
- long result;
- InvokeHelper(0x80, DISPATCH_METHOD, VT_I4, (void*)&result, NULL);
- return result;
- }
- BOOL IsPlaying() {
- BOOL result;
- InvokeHelper(0x81, DISPATCH_METHOD, VT_BOOL, (void*)&result, NULL);
- return result;
- }
- long PercentLoaded() {
- long result;
- InvokeHelper(0x82, DISPATCH_METHOD, VT_I4, (void*)&result, NULL);
- return result;
- }
- BOOL FrameLoaded(long FrameNum) {
- BOOL result;
- static BYTE parms[] = VTS_I4 ;
- InvokeHelper(0x83, DISPATCH_METHOD, VT_BOOL, (void*)&result, parms, FrameNum);
- return result;
- }
- long FlashVersion() {
- long result;
- InvokeHelper(0x84, DISPATCH_METHOD, VT_I4, (void*)&result, NULL);
- return result;
- }
- CString get_WMode() {
- CString result;
- InvokeHelper(0x85, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
- return result;
- }
- void put_WMode(LPCTSTR newValue) {
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0x85, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- CString get_SAlign() {
- CString result;
- InvokeHelper(0x86, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
- return result;
- }
- void put_SAlign(LPCTSTR newValue) {
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0x86, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- BOOL get_Menu() {
- BOOL result;
- InvokeHelper(0x87, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
- return result;
- }
- void put_Menu(BOOL newValue) {
- static BYTE parms[] = VTS_BOOL ;
- InvokeHelper(0x87, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- CString get_Base() {
- CString result;
- InvokeHelper(0x88, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
- return result;
- }
- void put_Base(LPCTSTR newValue) {
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0x88, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- CString get_Scale() {
- CString result;
- InvokeHelper(0x89, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
- return result;
- }
- void put_Scale(LPCTSTR newValue) {
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0x89, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- BOOL get_DeviceFont() {
- BOOL result;
- InvokeHelper(0x8a, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
- return result;
- }
- void put_DeviceFont(BOOL newValue) {
- static BYTE parms[] = VTS_BOOL ;
- InvokeHelper(0x8a, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- BOOL get_EmbedMovie() {
- BOOL result;
- InvokeHelper(0x8b, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
- return result;
- }
- void put_EmbedMovie(BOOL newValue) {
- static BYTE parms[] = VTS_BOOL ;
- InvokeHelper(0x8b, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- CString get_BGColor() {
- CString result;
- InvokeHelper(0x8c, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
- return result;
- }
- void put_BGColor(LPCTSTR newValue) {
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0x8c, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- CString get_Quality2() {
- CString result;
- InvokeHelper(0x8d, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
- return result;
- }
- void put_Quality2(LPCTSTR newValue) {
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0x8d, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- void LoadMovie(long layer, LPCTSTR url) {
- static BYTE parms[] = VTS_I4 VTS_BSTR ;
- InvokeHelper(0x8e, DISPATCH_METHOD, VT_EMPTY, NULL, parms, layer, url);
- }
- void TGotoFrame(LPCTSTR target, long FrameNum) {
- static BYTE parms[] = VTS_BSTR VTS_I4 ;
- InvokeHelper(0x8f, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target, FrameNum);
- }
- void TGotoLabel(LPCTSTR target, LPCTSTR label) {
- static BYTE parms[] = VTS_BSTR VTS_BSTR ;
- InvokeHelper(0x90, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target, label);
- }
- long TCurrentFrame(LPCTSTR target) {
- long result;
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0x91, DISPATCH_METHOD, VT_I4, (void*)&result, parms, target);
- return result;
- }
- CString TCurrentLabel(LPCTSTR target) {
- CString result;
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0x92, DISPATCH_METHOD, VT_BSTR, (void*)&result, parms, target);
- return result;
- }
- void TPlay(LPCTSTR target) {
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0x93, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target);
- }
- void TStopPlay(LPCTSTR target) {
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0x94, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target);
- }
- void SetVariable(LPCTSTR name, LPCTSTR value) {
- static BYTE parms[] = VTS_BSTR VTS_BSTR ;
- InvokeHelper(0x97, DISPATCH_METHOD, VT_EMPTY, NULL, parms, name, value);
- }
- CString GetVariable(LPCTSTR name) {
- CString result;
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0x98, DISPATCH_METHOD, VT_BSTR, (void*)&result, parms, name);
- return result;
- }
- void TSetProperty(LPCTSTR target, long property, LPCTSTR value) {
- static BYTE parms[] = VTS_BSTR VTS_I4 VTS_BSTR ;
- InvokeHelper(0x99, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target, property, value);
- }
- CString TGetProperty(LPCTSTR target, long property) {
- CString result;
- static BYTE parms[] = VTS_BSTR VTS_I4 ;
- InvokeHelper(0x9a, DISPATCH_METHOD, VT_BSTR, (void*)&result, parms, target, property);
- return result;
- }
- void TCallFrame(LPCTSTR target, long FrameNum) {
- static BYTE parms[] = VTS_BSTR VTS_I4 ;
- InvokeHelper(0x9b, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target, FrameNum);
- }
- void TCallLabel(LPCTSTR target, LPCTSTR label) {
- static BYTE parms[] = VTS_BSTR VTS_BSTR ;
- InvokeHelper(0x9c, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target, label);
- }
- void TSetPropertyNum(LPCTSTR target, long property, double value) {
- static BYTE parms[] = VTS_BSTR VTS_I4 VTS_R8 ;
- InvokeHelper(0x9d, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target, property, value);
- }
- double TGetPropertyNum(LPCTSTR target, long property) {
- double result;
- static BYTE parms[] = VTS_BSTR VTS_I4 ;
- InvokeHelper(0x9e, DISPATCH_METHOD, VT_R8, (void*)&result, parms, target, property);
- return result;
- }
- double TGetPropertyAsNumber(LPCTSTR target, long property) {
- double result;
- static BYTE parms[] = VTS_BSTR VTS_I4 ;
- InvokeHelper(0xac, DISPATCH_METHOD, VT_R8, (void*)&result, parms, target, property);
- return result;
- }
- CString get_SWRemote() {
- CString result;
- InvokeHelper(0x9f, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
- return result;
- }
- void put_SWRemote(LPCTSTR newValue) {
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0x9f, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- CString get_FlashVars() {
- CString result;
- InvokeHelper(0xaa, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
- return result;
- }
- void put_FlashVars(LPCTSTR newValue) {
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0xaa, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
- CString get_AllowScriptAccess() {
- CString result;
- InvokeHelper(0xab, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
- return result;
- }
- void put_AllowScriptAccess(LPCTSTR newValue) {
- static BYTE parms[] = VTS_BSTR ;
- InvokeHelper(0xab, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
- }
+ long get_ReadyState() {
+ long result;
+ InvokeHelper(DISPID_READYSTATE, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
+ return result;
+ }
+ long get_TotalFrames() {
+ long result;
+ InvokeHelper(0x7c, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
+ return result;
+ }
+ BOOL get_Playing() {
+ BOOL result;
+ InvokeHelper(0x7d, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
+ return result;
+ }
+ void put_Playing(BOOL newValue) {
+ static BYTE parms[] = VTS_BOOL ;
+ InvokeHelper(0x7d, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ long get_Quality() {
+ long result;
+ InvokeHelper(0x69, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
+ return result;
+ }
+ void put_Quality(long newValue) {
+ static BYTE parms[] = VTS_I4 ;
+ InvokeHelper(0x69, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ long get_ScaleMode() {
+ long result;
+ InvokeHelper(0x78, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
+ return result;
+ }
+ void put_ScaleMode(long newValue) {
+ static BYTE parms[] = VTS_I4 ;
+ InvokeHelper(0x78, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ long get_AlignMode() {
+ long result;
+ InvokeHelper(0x79, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
+ return result;
+ }
+ void put_AlignMode(long newValue) {
+ static BYTE parms[] = VTS_I4 ;
+ InvokeHelper(0x79, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ long get_BackgroundColor() {
+ long result;
+ InvokeHelper(0x7b, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
+ return result;
+ }
+ void put_BackgroundColor(long newValue) {
+ static BYTE parms[] = VTS_I4 ;
+ InvokeHelper(0x7b, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ BOOL get_Loop() {
+ BOOL result;
+ InvokeHelper(0x6a, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
+ return result;
+ }
+ void put_Loop(BOOL newValue) {
+ static BYTE parms[] = VTS_BOOL ;
+ InvokeHelper(0x6a, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ CString get_Movie() {
+ CString result;
+ InvokeHelper(0x66, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
+ return result;
+ }
+ void put_Movie(LPCTSTR newValue) {
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0x66, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ long get_FrameNum() {
+ long result;
+ InvokeHelper(0x6b, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
+ return result;
+ }
+ void put_FrameNum(long newValue) {
+ static BYTE parms[] = VTS_I4 ;
+ InvokeHelper(0x6b, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ void SetZoomRect(long left, long top, long right, long bottom) {
+ static BYTE parms[] = VTS_I4 VTS_I4 VTS_I4 VTS_I4 ;
+ InvokeHelper(0x6d, DISPATCH_METHOD, VT_EMPTY, NULL, parms, left, top, right, bottom);
+ }
+ void Zoom(long factor) {
+ static BYTE parms[] = VTS_I4 ;
+ InvokeHelper(0x76, DISPATCH_METHOD, VT_EMPTY, NULL, parms, factor);
+ }
+ void Pan(long x, long y, long mode) {
+ static BYTE parms[] = VTS_I4 VTS_I4 VTS_I4 ;
+ InvokeHelper(0x77, DISPATCH_METHOD, VT_EMPTY, NULL, parms, x, y, mode);
+ }
+ void Play() {
+ InvokeHelper(0x70, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
+ }
+ void Stop() {
+ InvokeHelper(0x71, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
+ }
+ void Back() {
+ InvokeHelper(0x72, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
+ }
+ void Forward() {
+ InvokeHelper(0x73, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
+ }
+ void Rewind() {
+ InvokeHelper(0x74, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
+ }
+ void StopPlay() {
+ InvokeHelper(0x7e, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
+ }
+ void GotoFrame(long FrameNum) {
+ static BYTE parms[] = VTS_I4 ;
+ InvokeHelper(0x7f, DISPATCH_METHOD, VT_EMPTY, NULL, parms, FrameNum);
+ }
+ long CurrentFrame() {
+ long result;
+ InvokeHelper(0x80, DISPATCH_METHOD, VT_I4, (void*)&result, NULL);
+ return result;
+ }
+ BOOL IsPlaying() {
+ BOOL result;
+ InvokeHelper(0x81, DISPATCH_METHOD, VT_BOOL, (void*)&result, NULL);
+ return result;
+ }
+ long PercentLoaded() {
+ long result;
+ InvokeHelper(0x82, DISPATCH_METHOD, VT_I4, (void*)&result, NULL);
+ return result;
+ }
+ BOOL FrameLoaded(long FrameNum) {
+ BOOL result;
+ static BYTE parms[] = VTS_I4 ;
+ InvokeHelper(0x83, DISPATCH_METHOD, VT_BOOL, (void*)&result, parms, FrameNum);
+ return result;
+ }
+ long FlashVersion() {
+ long result;
+ InvokeHelper(0x84, DISPATCH_METHOD, VT_I4, (void*)&result, NULL);
+ return result;
+ }
+ CString get_WMode() {
+ CString result;
+ InvokeHelper(0x85, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
+ return result;
+ }
+ void put_WMode(LPCTSTR newValue) {
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0x85, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ CString get_SAlign() {
+ CString result;
+ InvokeHelper(0x86, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
+ return result;
+ }
+ void put_SAlign(LPCTSTR newValue) {
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0x86, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ BOOL get_Menu() {
+ BOOL result;
+ InvokeHelper(0x87, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
+ return result;
+ }
+ void put_Menu(BOOL newValue) {
+ static BYTE parms[] = VTS_BOOL ;
+ InvokeHelper(0x87, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ CString get_Base() {
+ CString result;
+ InvokeHelper(0x88, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
+ return result;
+ }
+ void put_Base(LPCTSTR newValue) {
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0x88, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ CString get_Scale() {
+ CString result;
+ InvokeHelper(0x89, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
+ return result;
+ }
+ void put_Scale(LPCTSTR newValue) {
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0x89, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ BOOL get_DeviceFont() {
+ BOOL result;
+ InvokeHelper(0x8a, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
+ return result;
+ }
+ void put_DeviceFont(BOOL newValue) {
+ static BYTE parms[] = VTS_BOOL ;
+ InvokeHelper(0x8a, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ BOOL get_EmbedMovie() {
+ BOOL result;
+ InvokeHelper(0x8b, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
+ return result;
+ }
+ void put_EmbedMovie(BOOL newValue) {
+ static BYTE parms[] = VTS_BOOL ;
+ InvokeHelper(0x8b, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ CString get_BGColor() {
+ CString result;
+ InvokeHelper(0x8c, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
+ return result;
+ }
+ void put_BGColor(LPCTSTR newValue) {
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0x8c, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ CString get_Quality2() {
+ CString result;
+ InvokeHelper(0x8d, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
+ return result;
+ }
+ void put_Quality2(LPCTSTR newValue) {
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0x8d, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ void LoadMovie(long layer, LPCTSTR url) {
+ static BYTE parms[] = VTS_I4 VTS_BSTR ;
+ InvokeHelper(0x8e, DISPATCH_METHOD, VT_EMPTY, NULL, parms, layer, url);
+ }
+ void TGotoFrame(LPCTSTR target, long FrameNum) {
+ static BYTE parms[] = VTS_BSTR VTS_I4 ;
+ InvokeHelper(0x8f, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target, FrameNum);
+ }
+ void TGotoLabel(LPCTSTR target, LPCTSTR label) {
+ static BYTE parms[] = VTS_BSTR VTS_BSTR ;
+ InvokeHelper(0x90, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target, label);
+ }
+ long TCurrentFrame(LPCTSTR target) {
+ long result;
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0x91, DISPATCH_METHOD, VT_I4, (void*)&result, parms, target);
+ return result;
+ }
+ CString TCurrentLabel(LPCTSTR target) {
+ CString result;
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0x92, DISPATCH_METHOD, VT_BSTR, (void*)&result, parms, target);
+ return result;
+ }
+ void TPlay(LPCTSTR target) {
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0x93, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target);
+ }
+ void TStopPlay(LPCTSTR target) {
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0x94, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target);
+ }
+ void SetVariable(LPCTSTR name, LPCTSTR value) {
+ static BYTE parms[] = VTS_BSTR VTS_BSTR ;
+ InvokeHelper(0x97, DISPATCH_METHOD, VT_EMPTY, NULL, parms, name, value);
+ }
+ CString GetVariable(LPCTSTR name) {
+ CString result;
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0x98, DISPATCH_METHOD, VT_BSTR, (void*)&result, parms, name);
+ return result;
+ }
+ void TSetProperty(LPCTSTR target, long property, LPCTSTR value) {
+ static BYTE parms[] = VTS_BSTR VTS_I4 VTS_BSTR ;
+ InvokeHelper(0x99, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target, property, value);
+ }
+ CString TGetProperty(LPCTSTR target, long property) {
+ CString result;
+ static BYTE parms[] = VTS_BSTR VTS_I4 ;
+ InvokeHelper(0x9a, DISPATCH_METHOD, VT_BSTR, (void*)&result, parms, target, property);
+ return result;
+ }
+ void TCallFrame(LPCTSTR target, long FrameNum) {
+ static BYTE parms[] = VTS_BSTR VTS_I4 ;
+ InvokeHelper(0x9b, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target, FrameNum);
+ }
+ void TCallLabel(LPCTSTR target, LPCTSTR label) {
+ static BYTE parms[] = VTS_BSTR VTS_BSTR ;
+ InvokeHelper(0x9c, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target, label);
+ }
+ void TSetPropertyNum(LPCTSTR target, long property, double value) {
+ static BYTE parms[] = VTS_BSTR VTS_I4 VTS_R8 ;
+ InvokeHelper(0x9d, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target, property, value);
+ }
+ double TGetPropertyNum(LPCTSTR target, long property) {
+ double result;
+ static BYTE parms[] = VTS_BSTR VTS_I4 ;
+ InvokeHelper(0x9e, DISPATCH_METHOD, VT_R8, (void*)&result, parms, target, property);
+ return result;
+ }
+ double TGetPropertyAsNumber(LPCTSTR target, long property) {
+ double result;
+ static BYTE parms[] = VTS_BSTR VTS_I4 ;
+ InvokeHelper(0xac, DISPATCH_METHOD, VT_R8, (void*)&result, parms, target, property);
+ return result;
+ }
+ CString get_SWRemote() {
+ CString result;
+ InvokeHelper(0x9f, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
+ return result;
+ }
+ void put_SWRemote(LPCTSTR newValue) {
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0x9f, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ CString get_FlashVars() {
+ CString result;
+ InvokeHelper(0xaa, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
+ return result;
+ }
+ void put_FlashVars(LPCTSTR newValue) {
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0xaa, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
+ CString get_AllowScriptAccess() {
+ CString result;
+ InvokeHelper(0xab, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
+ return result;
+ }
+ void put_AllowScriptAccess(LPCTSTR newValue) {
+ static BYTE parms[] = VTS_BSTR ;
+ InvokeHelper(0xab, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
+ }
};
diff --git a/src/mpc-hc/ChildView.cpp b/src/mpc-hc/ChildView.cpp
index d10ce2ae0..2611fff74 100644
--- a/src/mpc-hc/ChildView.cpp
+++ b/src/mpc-hc/ChildView.cpp
@@ -29,12 +29,12 @@
/////////////////////////////////////////////////////////////////////////////
// CChildView
-CChildView::CChildView() : m_vrect(0,0,0,0)
+CChildView::CChildView() : m_vrect(0, 0, 0, 0)
{
- m_lastlmdowntime = 0;
- m_lastlmdownpoint.SetPoint(0, 0);
+ m_lastlmdowntime = 0;
+ m_lastlmdownpoint.SetPoint(0, 0);
- LoadLogo();
+ LoadLogo();
}
CChildView::~CChildView()
@@ -43,127 +43,127 @@ CChildView::~CChildView()
BOOL CChildView::PreCreateWindow(CREATESTRUCT& cs)
{
- if (!CWnd::PreCreateWindow(cs)) {
- return FALSE;
- }
+ if (!CWnd::PreCreateWindow(cs)) {
+ return FALSE;
+ }
- cs.style &= ~WS_BORDER;
- cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS,
- ::LoadCursor(NULL, IDC_ARROW), HBRUSH(COLOR_WINDOW+1), NULL);
+ cs.style &= ~WS_BORDER;
+ cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS,
+ ::LoadCursor(NULL, IDC_ARROW), HBRUSH(COLOR_WINDOW + 1), NULL);
- return TRUE;
+ return TRUE;
}
BOOL CChildView::PreTranslateMessage(MSG* pMsg)
{
- if (pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MYMOUSELAST) {
- CWnd* pParent = GetParent();
- CPoint p(pMsg->lParam);
- ::MapWindowPoints(pMsg->hwnd, pParent->m_hWnd, &p, 1);
-
- bool fDblClick = false;
-
- bool fInteractiveVideo = ((CMainFrame*)AfxGetMainWnd())->IsInteractiveVideo();
- /*
- if (fInteractiveVideo)
- {
- if (pMsg->message == WM_LBUTTONDOWN)
- {
- if ((pMsg->time - m_lastlmdowntime) <= GetDoubleClickTime()
- && abs(pMsg->pt.x - m_lastlmdownpoint.x) <= GetSystemMetrics(SM_CXDOUBLECLK)
- && abs(pMsg->pt.y - m_lastlmdownpoint.y) <= GetSystemMetrics(SM_CYDOUBLECLK))
- {
- fDblClick = true;
- m_lastlmdowntime = 0;
- m_lastlmdownpoint.SetPoint(0, 0);
- }
- else
- {
- m_lastlmdowntime = pMsg->time;
- m_lastlmdownpoint = pMsg->pt;
- }
- }
- else if (pMsg->message == WM_LBUTTONDBLCLK)
- {
- m_lastlmdowntime = pMsg->time;
- m_lastlmdownpoint = pMsg->pt;
- }
- }
- */
- if ((pMsg->message == WM_LBUTTONDOWN || pMsg->message == WM_LBUTTONUP || pMsg->message == WM_MOUSEMOVE)
- && fInteractiveVideo) {
- if (pMsg->message == WM_MOUSEMOVE) {
- pParent->PostMessage(pMsg->message, pMsg->wParam, MAKELPARAM(p.x, p.y));
- }
-
- if (fDblClick) {
- pParent->PostMessage(WM_LBUTTONDOWN, pMsg->wParam, MAKELPARAM(p.x, p.y));
- pParent->PostMessage(WM_LBUTTONDBLCLK, pMsg->wParam, MAKELPARAM(p.x, p.y));
- }
- } else {
- pParent->PostMessage(pMsg->message, pMsg->wParam, MAKELPARAM(p.x, p.y));
- return TRUE;
- }
- }
-
- return CWnd::PreTranslateMessage(pMsg);
+ if (pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MYMOUSELAST) {
+ CWnd* pParent = GetParent();
+ CPoint p(pMsg->lParam);
+ ::MapWindowPoints(pMsg->hwnd, pParent->m_hWnd, &p, 1);
+
+ bool fDblClick = false;
+
+ bool fInteractiveVideo = ((CMainFrame*)AfxGetMainWnd())->IsInteractiveVideo();
+ /*
+ if (fInteractiveVideo)
+ {
+ if (pMsg->message == WM_LBUTTONDOWN)
+ {
+ if ((pMsg->time - m_lastlmdowntime) <= GetDoubleClickTime()
+ && abs(pMsg->pt.x - m_lastlmdownpoint.x) <= GetSystemMetrics(SM_CXDOUBLECLK)
+ && abs(pMsg->pt.y - m_lastlmdownpoint.y) <= GetSystemMetrics(SM_CYDOUBLECLK))
+ {
+ fDblClick = true;
+ m_lastlmdowntime = 0;
+ m_lastlmdownpoint.SetPoint(0, 0);
+ }
+ else
+ {
+ m_lastlmdowntime = pMsg->time;
+ m_lastlmdownpoint = pMsg->pt;
+ }
+ }
+ else if (pMsg->message == WM_LBUTTONDBLCLK)
+ {
+ m_lastlmdowntime = pMsg->time;
+ m_lastlmdownpoint = pMsg->pt;
+ }
+ }
+ */
+ if ((pMsg->message == WM_LBUTTONDOWN || pMsg->message == WM_LBUTTONUP || pMsg->message == WM_MOUSEMOVE)
+ && fInteractiveVideo) {
+ if (pMsg->message == WM_MOUSEMOVE) {
+ pParent->PostMessage(pMsg->message, pMsg->wParam, MAKELPARAM(p.x, p.y));
+ }
+
+ if (fDblClick) {
+ pParent->PostMessage(WM_LBUTTONDOWN, pMsg->wParam, MAKELPARAM(p.x, p.y));
+ pParent->PostMessage(WM_LBUTTONDBLCLK, pMsg->wParam, MAKELPARAM(p.x, p.y));
+ }
+ } else {
+ pParent->PostMessage(pMsg->message, pMsg->wParam, MAKELPARAM(p.x, p.y));
+ return TRUE;
+ }
+ }
+
+ return CWnd::PreTranslateMessage(pMsg);
}
void CChildView::SetVideoRect(CRect r)
{
- m_vrect = r;
+ m_vrect = r;
- Invalidate();
+ Invalidate();
}
void CChildView::LoadLogo()
{
- AppSettings& s = AfxGetAppSettings();
- bool bHaveLogo = false;
+ AppSettings& s = AfxGetAppSettings();
+ bool bHaveLogo = false;
- CAutoLock cAutoLock(&m_csLogo);
+ CAutoLock cAutoLock(&m_csLogo);
- m_logo.Detach();
+ m_logo.Detach();
- if (s.fLogoExternal) {
- bHaveLogo = !!m_logo.LoadFromFile(s.strLogoFileName);
- }
+ if (s.fLogoExternal) {
+ bHaveLogo = !!m_logo.LoadFromFile(s.strLogoFileName);
+ }
- if (!bHaveLogo) {
- s.fLogoExternal = false; // use the built-in logo instead
- s.strLogoFileName = ""; // clear logo file name
+ if (!bHaveLogo) {
+ s.fLogoExternal = false; // use the built-in logo instead
+ s.strLogoFileName = ""; // clear logo file name
- if (!m_logo.Load(s.nLogoId)) { // try the latest selected build-in logo
- m_logo.Load(s.nLogoId = DEF_LOGO); // if fail then use the default logo, should and must never fail
- }
- }
+ if (!m_logo.Load(s.nLogoId)) { // try the latest selected build-in logo
+ m_logo.Load(s.nLogoId = DEF_LOGO); // if fail then use the default logo, should and must never fail
+ }
+ }
- if (m_hWnd) {
- Invalidate();
- }
+ if (m_hWnd) {
+ Invalidate();
+ }
}
CSize CChildView::GetLogoSize() const
{
- return m_logo.GetBitmapDimension();
+ return m_logo.GetBitmapDimension();
}
IMPLEMENT_DYNAMIC(CChildView, CWnd)
BEGIN_MESSAGE_MAP(CChildView, CWnd)
- //{{AFX_MSG_MAP(CChildView)
- ON_WM_PAINT()
- ON_WM_ERASEBKGND()
- ON_WM_SIZE()
- ON_COMMAND_EX(ID_PLAY_PLAYPAUSE, OnPlayPlayPauseStop)
- ON_COMMAND_EX(ID_PLAY_PLAY, OnPlayPlayPauseStop)
- ON_COMMAND_EX(ID_PLAY_PAUSE, OnPlayPlayPauseStop)
- ON_COMMAND_EX(ID_PLAY_STOP, OnPlayPlayPauseStop)
- ON_WM_SETCURSOR()
- //}}AFX_MSG_MAP
- // ON_WM_NCHITTEST()
- ON_WM_NCHITTEST()
- ON_WM_NCLBUTTONDOWN()
+ //{{AFX_MSG_MAP(CChildView)
+ ON_WM_PAINT()
+ ON_WM_ERASEBKGND()
+ ON_WM_SIZE()
+ ON_COMMAND_EX(ID_PLAY_PLAYPAUSE, OnPlayPlayPauseStop)
+ ON_COMMAND_EX(ID_PLAY_PLAY, OnPlayPlayPauseStop)
+ ON_COMMAND_EX(ID_PLAY_PAUSE, OnPlayPlayPauseStop)
+ ON_COMMAND_EX(ID_PLAY_STOP, OnPlayPlayPauseStop)
+ ON_WM_SETCURSOR()
+ //}}AFX_MSG_MAP
+ // ON_WM_NCHITTEST()
+ ON_WM_NCHITTEST()
+ ON_WM_NCLBUTTONDOWN()
END_MESSAGE_MAP()
@@ -172,170 +172,170 @@ END_MESSAGE_MAP()
void CChildView::OnPaint()
{
- CPaintDC dc(this); // device context for painting
+ CPaintDC dc(this); // device context for painting
- ((CMainFrame*)GetParentFrame())->RepaintVideo();
+ ((CMainFrame*)GetParentFrame())->RepaintVideo();
- // Do not call CWnd::OnPaint() for painting messages
+ // Do not call CWnd::OnPaint() for painting messages
}
BOOL CChildView::OnEraseBkgnd(CDC* pDC)
{
- CRect r;
-
- CAutoLock cAutoLock(&m_csLogo);
-
- CImage img;
- img.Attach(m_logo);
-
- if (((CMainFrame*)GetParentFrame())->IsSomethingLoaded()) {
- pDC->ExcludeClipRect(m_vrect);
- } else if (!img.IsNull()) {
- GetClientRect(r);
- int w = min(img.GetWidth(), r.Width());
- int h = min(img.GetHeight(), r.Height());
- int x = (r.Width() - w) / 2;
- int y = (r.Height() - h) / 2;
- r = CRect(CPoint(x, y), CSize(w, h));
-
- int oldmode = pDC->SetStretchBltMode(STRETCH_HALFTONE);
- img.StretchBlt(*pDC, r, CRect(0, 0, img.GetWidth(), img.GetHeight()));
- pDC->SetStretchBltMode(oldmode);
- pDC->ExcludeClipRect(r);
- }
- img.Detach();
-
- GetClientRect(r);
- pDC->FillSolidRect(r, 0);
-
- return TRUE;
+ CRect r;
+
+ CAutoLock cAutoLock(&m_csLogo);
+
+ CImage img;
+ img.Attach(m_logo);
+
+ if (((CMainFrame*)GetParentFrame())->IsSomethingLoaded()) {
+ pDC->ExcludeClipRect(m_vrect);
+ } else if (!img.IsNull()) {
+ GetClientRect(r);
+ int w = min(img.GetWidth(), r.Width());
+ int h = min(img.GetHeight(), r.Height());
+ int x = (r.Width() - w) / 2;
+ int y = (r.Height() - h) / 2;
+ r = CRect(CPoint(x, y), CSize(w, h));
+
+ int oldmode = pDC->SetStretchBltMode(STRETCH_HALFTONE);
+ img.StretchBlt(*pDC, r, CRect(0, 0, img.GetWidth(), img.GetHeight()));
+ pDC->SetStretchBltMode(oldmode);
+ pDC->ExcludeClipRect(r);
+ }
+ img.Detach();
+
+ GetClientRect(r);
+ pDC->FillSolidRect(r, 0);
+
+ return TRUE;
}
void CChildView::OnSize(UINT nType, int cx, int cy)
{
- CWnd::OnSize(nType, cx, cy);
+ CWnd::OnSize(nType, cx, cy);
- ((CMainFrame*)GetParentFrame())->MoveVideoWindow();
+ ((CMainFrame*)GetParentFrame())->MoveVideoWindow();
}
BOOL CChildView::OnPlayPlayPauseStop(UINT nID)
{
- if (nID == ID_PLAY_STOP) {
- SetVideoRect();
- }
- CString osd = ResStr(nID);
- int i = osd.Find(_T("\n"));
- if (i > 0) {
- osd.Delete(i, osd.GetLength()-i);
- }
-
- CRect r1;
- ((CMainFrame*)AfxGetMainWnd())->GetClientRect(&r1);
- if ((!r1.Width()) || (!r1.Height())) {
- return FALSE;
- }
-
- if (!(((CMainFrame*)AfxGetMainWnd())->m_OpenFile)) {
- ((CMainFrame*)AfxGetMainWnd())->m_OSD.DisplayMessage(OSD_TOPLEFT, osd, 1500);
- }
- return FALSE;
+ if (nID == ID_PLAY_STOP) {
+ SetVideoRect();
+ }
+ CString osd = ResStr(nID);
+ int i = osd.Find(_T("\n"));
+ if (i > 0) {
+ osd.Delete(i, osd.GetLength() - i);
+ }
+
+ CRect r1;
+ ((CMainFrame*)AfxGetMainWnd())->GetClientRect(&r1);
+ if ((!r1.Width()) || (!r1.Height())) {
+ return FALSE;
+ }
+
+ if (!(((CMainFrame*)AfxGetMainWnd())->m_OpenFile)) {
+ ((CMainFrame*)AfxGetMainWnd())->m_OSD.DisplayMessage(OSD_TOPLEFT, osd, 1500);
+ }
+ return FALSE;
}
BOOL CChildView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
- if (((CMainFrame*)GetParentFrame())->m_fHideCursor) {
- SetCursor(NULL);
- return TRUE;
- }
- if (((CMainFrame*)GetParentFrame())->IsSomethingLoaded() && (nHitTest == HTCLIENT)) {
- if (((CMainFrame*)GetParentFrame())->GetPlaybackMode() == PM_DVD) {
- return FALSE;
- }
- ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
- return TRUE;
- }
- return CWnd::OnSetCursor(pWnd, nHitTest, message);
+ if (((CMainFrame*)GetParentFrame())->m_fHideCursor) {
+ SetCursor(NULL);
+ return TRUE;
+ }
+ if (((CMainFrame*)GetParentFrame())->IsSomethingLoaded() && (nHitTest == HTCLIENT)) {
+ if (((CMainFrame*)GetParentFrame())->GetPlaybackMode() == PM_DVD) {
+ return FALSE;
+ }
+ ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
+ return TRUE;
+ }
+ return CWnd::OnSetCursor(pWnd, nHitTest, message);
}
LRESULT CChildView::OnNcHitTest(CPoint point)
{
- LRESULT nHitTest = CWnd::OnNcHitTest(point);
-
- CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
- bool fLeftMouseBtnUnassigned = !AssignedToCmd(wmcmd::LDOWN);
- if (!pFrame->m_fFullScreen && (pFrame->IsCaptionHidden() || fLeftMouseBtnUnassigned)) {
- CRect rcClient, rcFrame;
- GetWindowRect(&rcFrame);
- rcClient = rcFrame;
-
- CSize sizeBorder(GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
-
- rcClient.InflateRect(-(5 * sizeBorder.cx), -(5 * sizeBorder.cy));
- rcFrame.InflateRect(sizeBorder.cx, sizeBorder.cy);
-
- if (rcFrame.PtInRect(point)) {
- if (point.x > rcClient.right) {
- if (point.y < rcClient.top) {
- nHitTest = HTTOPRIGHT;
- } else if (point.y > rcClient.bottom) {
- nHitTest = HTBOTTOMRIGHT;
- } else {
- nHitTest = HTRIGHT;
- }
- } else if (point.x < rcClient.left) {
- if (point.y < rcClient.top) {
- nHitTest = HTTOPLEFT;
- } else if (point.y > rcClient.bottom) {
- nHitTest = HTBOTTOMLEFT;
- } else {
- nHitTest = HTLEFT;
- }
- } else if (point.y < rcClient.top) {
- nHitTest = HTTOP;
- } else if (point.y > rcClient.bottom) {
- nHitTest = HTBOTTOM;
- }
- }
- }
- return nHitTest;
+ LRESULT nHitTest = CWnd::OnNcHitTest(point);
+
+ CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
+ bool fLeftMouseBtnUnassigned = !AssignedToCmd(wmcmd::LDOWN);
+ if (!pFrame->m_fFullScreen && (pFrame->IsCaptionHidden() || fLeftMouseBtnUnassigned)) {
+ CRect rcClient, rcFrame;
+ GetWindowRect(&rcFrame);
+ rcClient = rcFrame;
+
+ CSize sizeBorder(GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
+
+ rcClient.InflateRect(-(5 * sizeBorder.cx), -(5 * sizeBorder.cy));
+ rcFrame.InflateRect(sizeBorder.cx, sizeBorder.cy);
+
+ if (rcFrame.PtInRect(point)) {
+ if (point.x > rcClient.right) {
+ if (point.y < rcClient.top) {
+ nHitTest = HTTOPRIGHT;
+ } else if (point.y > rcClient.bottom) {
+ nHitTest = HTBOTTOMRIGHT;
+ } else {
+ nHitTest = HTRIGHT;
+ }
+ } else if (point.x < rcClient.left) {
+ if (point.y < rcClient.top) {
+ nHitTest = HTTOPLEFT;
+ } else if (point.y > rcClient.bottom) {
+ nHitTest = HTBOTTOMLEFT;
+ } else {
+ nHitTest = HTLEFT;
+ }
+ } else if (point.y < rcClient.top) {
+ nHitTest = HTTOP;
+ } else if (point.y > rcClient.bottom) {
+ nHitTest = HTBOTTOM;
+ }
+ }
+ }
+ return nHitTest;
}
void CChildView::OnNcLButtonDown(UINT nHitTest, CPoint point)
{
- CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
- bool fLeftMouseBtnUnassigned = !AssignedToCmd(wmcmd::LDOWN);
- if (!pFrame->m_fFullScreen && (pFrame->IsCaptionHidden() || fLeftMouseBtnUnassigned)) {
- BYTE bFlag = 0;
- switch (nHitTest) {
- case HTTOP:
- bFlag = WMSZ_TOP;
- break;
- case HTTOPLEFT:
- bFlag = WMSZ_TOPLEFT;
- break;
- case HTTOPRIGHT:
- bFlag = WMSZ_TOPRIGHT;
- break;
- case HTLEFT:
- bFlag = WMSZ_LEFT;
- break;
- case HTRIGHT:
- bFlag = WMSZ_RIGHT;
- break;
- case HTBOTTOM:
- bFlag = WMSZ_BOTTOM;
- break;
- case HTBOTTOMLEFT:
- bFlag = WMSZ_BOTTOMLEFT;
- break;
- case HTBOTTOMRIGHT:
- bFlag = WMSZ_BOTTOMRIGHT;
- break;
- }
- if (bFlag) {
- pFrame->PostMessage(WM_SYSCOMMAND, (SC_SIZE | bFlag), (LPARAM)POINTTOPOINTS(point));
- } else {
- CWnd::OnNcLButtonDown(nHitTest, point);
- }
- }
+ CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
+ bool fLeftMouseBtnUnassigned = !AssignedToCmd(wmcmd::LDOWN);
+ if (!pFrame->m_fFullScreen && (pFrame->IsCaptionHidden() || fLeftMouseBtnUnassigned)) {
+ BYTE bFlag = 0;
+ switch (nHitTest) {
+ case HTTOP:
+ bFlag = WMSZ_TOP;
+ break;
+ case HTTOPLEFT:
+ bFlag = WMSZ_TOPLEFT;
+ break;
+ case HTTOPRIGHT:
+ bFlag = WMSZ_TOPRIGHT;
+ break;
+ case HTLEFT:
+ bFlag = WMSZ_LEFT;
+ break;
+ case HTRIGHT:
+ bFlag = WMSZ_RIGHT;
+ break;
+ case HTBOTTOM:
+ bFlag = WMSZ_BOTTOM;
+ break;
+ case HTBOTTOMLEFT:
+ bFlag = WMSZ_BOTTOMLEFT;
+ break;
+ case HTBOTTOMRIGHT:
+ bFlag = WMSZ_BOTTOMRIGHT;
+ break;
+ }
+ if (bFlag) {
+ pFrame->PostMessage(WM_SYSCOMMAND, (SC_SIZE | bFlag), (LPARAM)POINTTOPOINTS(point));
+ } else {
+ CWnd::OnNcLButtonDown(nHitTest, point);
+ }
+ }
}
diff --git a/src/mpc-hc/ChildView.h b/src/mpc-hc/ChildView.h
index 9913a3ae5..f8cad2fd5 100644
--- a/src/mpc-hc/ChildView.h
+++ b/src/mpc-hc/ChildView.h
@@ -27,42 +27,42 @@
class CChildView : public CWnd
{
- CRect m_vrect;
+ CRect m_vrect;
- DWORD m_lastlmdowntime;
- CPoint m_lastlmdownpoint;
+ DWORD m_lastlmdowntime;
+ CPoint m_lastlmdownpoint;
- CCritSec m_csLogo;
- CMPCPngImage m_logo;
+ CCritSec m_csLogo;
+ CMPCPngImage m_logo;
public:
- CChildView();
- virtual ~CChildView();
+ CChildView();
+ virtual ~CChildView();
- DECLARE_DYNAMIC(CChildView)
+ DECLARE_DYNAMIC(CChildView)
public:
- void SetVideoRect(CRect r = CRect(0,0,0,0));
- CRect GetVideoRect() const {
- return m_vrect;
- }
+ void SetVideoRect(CRect r = CRect(0, 0, 0, 0));
+ CRect GetVideoRect() const {
+ return m_vrect;
+ }
- void LoadLogo();
- CSize GetLogoSize() const;
+ void LoadLogo();
+ CSize GetLogoSize() const;
protected:
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
- afx_msg void OnPaint();
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg BOOL OnPlayPlayPauseStop(UINT nID);
- afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
+ afx_msg void OnPaint();
+ afx_msg BOOL OnEraseBkgnd(CDC* pDC);
+ afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg BOOL OnPlayPlayPauseStop(UINT nID);
+ afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnSetFocus(CWnd* pOldWnd);
- afx_msg LRESULT OnNcHitTest(CPoint point);
- afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
+ afx_msg void OnSetFocus(CWnd* pOldWnd);
+ afx_msg LRESULT OnNcHitTest(CPoint point);
+ afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
};
diff --git a/src/mpc-hc/ComPropertyPage.cpp b/src/mpc-hc/ComPropertyPage.cpp
index 77f11e89e..64d53c184 100644
--- a/src/mpc-hc/ComPropertyPage.cpp
+++ b/src/mpc-hc/ComPropertyPage.cpp
@@ -31,12 +31,12 @@
IMPLEMENT_DYNAMIC(CComPropertyPage, CPropertyPage)
CComPropertyPage::CComPropertyPage(IPropertyPage* pPage)
- : CPropertyPage(CComPropertyPage::IDD), m_pPage(pPage)
+ : CPropertyPage(CComPropertyPage::IDD), m_pPage(pPage)
{
- PROPPAGEINFO ppi;
- m_pPage->GetPageInfo(&ppi);
- m_pPSP->pszTitle = (m_strCaption = ppi.pszTitle);
- m_psp.dwFlags |= PSP_USETITLE;
+ PROPPAGEINFO ppi;
+ m_pPage->GetPageInfo(&ppi);
+ m_pPSP->pszTitle = (m_strCaption = ppi.pszTitle);
+ m_psp.dwFlags |= PSP_USETITLE;
}
CComPropertyPage::~CComPropertyPage()
@@ -45,52 +45,52 @@ CComPropertyPage::~CComPropertyPage()
void CComPropertyPage::DoDataExchange(CDataExchange* pDX)
{
- CPropertyPage::DoDataExchange(pDX);
+ CPropertyPage::DoDataExchange(pDX);
}
BOOL CComPropertyPage::OnInitDialog()
{
- CPropertyPage::OnInitDialog();
+ CPropertyPage::OnInitDialog();
- CRect r;
- PROPPAGEINFO ppi;
- m_pPage->GetPageInfo(&ppi);
- r = CRect(CPoint(0,0), ppi.size);
- m_pPage->Activate(m_hWnd, r, FALSE);
- m_pPage->Show(SW_SHOW);
+ CRect r;
+ PROPPAGEINFO ppi;
+ m_pPage->GetPageInfo(&ppi);
+ r = CRect(CPoint(0, 0), ppi.size);
+ m_pPage->Activate(m_hWnd, r, FALSE);
+ m_pPage->Show(SW_SHOW);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CComPropertyPage::OnDestroy()
{
- CPropertyPage::OnDestroy();
- m_pPage->Deactivate();
+ CPropertyPage::OnDestroy();
+ m_pPage->Deactivate();
}
BOOL CComPropertyPage::OnSetActive()
{
- SetModified(S_OK == m_pPage->IsPageDirty());
+ SetModified(S_OK == m_pPage->IsPageDirty());
- CWnd* pParent = GetParent();
- if (pParent->IsKindOf(RUNTIME_CLASS(CComPropertySheet))) {
- CComPropertySheet* pSheet = static_cast<CComPropertySheet*>(pParent);
- pSheet->OnActivated(this);
- }
+ CWnd* pParent = GetParent();
+ if (pParent->IsKindOf(RUNTIME_CLASS(CComPropertySheet))) {
+ CComPropertySheet* pSheet = static_cast<CComPropertySheet*>(pParent);
+ pSheet->OnActivated(this);
+ }
- return CPropertyPage::OnSetActive();
+ return CPropertyPage::OnSetActive();
}
BOOL CComPropertyPage::OnKillActive()
{
- SetModified(FALSE);
- return CPropertyPage::OnKillActive();
+ SetModified(FALSE);
+ return CPropertyPage::OnKillActive();
}
BEGIN_MESSAGE_MAP(CComPropertyPage, CPropertyPage)
- ON_WM_DESTROY()
+ ON_WM_DESTROY()
END_MESSAGE_MAP()
@@ -98,9 +98,9 @@ END_MESSAGE_MAP()
void CComPropertyPage::OnOK()
{
- if (S_OK == m_pPage->IsPageDirty()) {
- m_pPage->Apply();
- }
- SetModified(FALSE);
- CPropertyPage::OnOK();
+ if (S_OK == m_pPage->IsPageDirty()) {
+ m_pPage->Apply();
+ }
+ SetModified(FALSE);
+ CPropertyPage::OnOK();
}
diff --git a/src/mpc-hc/ComPropertyPage.h b/src/mpc-hc/ComPropertyPage.h
index 9bc092d1d..e624da2f3 100644
--- a/src/mpc-hc/ComPropertyPage.h
+++ b/src/mpc-hc/ComPropertyPage.h
@@ -29,26 +29,26 @@
class CComPropertyPage : public CPropertyPage
{
- DECLARE_DYNAMIC(CComPropertyPage)
+ DECLARE_DYNAMIC(CComPropertyPage)
- CComPtr<IPropertyPage> m_pPage;
+ CComPtr<IPropertyPage> m_pPage;
public:
- CComPropertyPage(IPropertyPage* pPage);
- virtual ~CComPropertyPage();
+ CComPropertyPage(IPropertyPage* pPage);
+ virtual ~CComPropertyPage();
- // Dialog Data
- enum { IDD = IDD_COMPROPERTYPAGE };
+ // Dialog Data
+ enum { IDD = IDD_COMPROPERTYPAGE };
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnSetActive();
- virtual BOOL OnKillActive();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnSetActive();
+ virtual BOOL OnKillActive();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- virtual BOOL OnInitDialog();
- afx_msg void OnDestroy();
- virtual void OnOK();
+ virtual BOOL OnInitDialog();
+ afx_msg void OnDestroy();
+ virtual void OnOK();
};
diff --git a/src/mpc-hc/ComPropertySheet.cpp b/src/mpc-hc/ComPropertySheet.cpp
index 0a841d14a..aadf68a1e 100644
--- a/src/mpc-hc/ComPropertySheet.cpp
+++ b/src/mpc-hc/ComPropertySheet.cpp
@@ -32,58 +32,58 @@
class CComPropertyPageSite : public CUnknown, public IPropertyPageSite
{
- IComPropertyPageDirty* m_pPPD;
+ IComPropertyPageDirty* m_pPPD;
public:
- CComPropertyPageSite(IComPropertyPageDirty* pPPD) : CUnknown(NAME("CComPropertyPageSite"), NULL), m_pPPD(pPPD) {}
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
- return
- QI(IPropertyPageSite)
- __super::NonDelegatingQueryInterface(riid, ppv);
- }
-
- // IPropertyPageSite
- STDMETHODIMP OnStatusChange(DWORD flags) {
- if (m_pPPD) {
- if (flags&PROPPAGESTATUS_DIRTY) {
- m_pPPD->OnSetDirty(true);
- }
- if (flags&PROPPAGESTATUS_CLEAN) {
- m_pPPD->OnSetDirty(false);
- }
- }
- return S_OK;
- }
- STDMETHODIMP GetLocaleID(LCID* pLocaleID) {
- CheckPointer(pLocaleID, E_POINTER);
- *pLocaleID = ::GetUserDefaultLCID();
- return S_OK;
- }
- STDMETHODIMP GetPageContainer(IUnknown** ppUnk) {
- return E_NOTIMPL;
- }
- STDMETHODIMP TranslateAccelerator(LPMSG pMsg) {
- return E_NOTIMPL;
- }
+ CComPropertyPageSite(IComPropertyPageDirty* pPPD) : CUnknown(NAME("CComPropertyPageSite"), NULL), m_pPPD(pPPD) {}
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
+ return
+ QI(IPropertyPageSite)
+ __super::NonDelegatingQueryInterface(riid, ppv);
+ }
+
+ // IPropertyPageSite
+ STDMETHODIMP OnStatusChange(DWORD flags) {
+ if (m_pPPD) {
+ if (flags & PROPPAGESTATUS_DIRTY) {
+ m_pPPD->OnSetDirty(true);
+ }
+ if (flags & PROPPAGESTATUS_CLEAN) {
+ m_pPPD->OnSetDirty(false);
+ }
+ }
+ return S_OK;
+ }
+ STDMETHODIMP GetLocaleID(LCID* pLocaleID) {
+ CheckPointer(pLocaleID, E_POINTER);
+ *pLocaleID = ::GetUserDefaultLCID();
+ return S_OK;
+ }
+ STDMETHODIMP GetPageContainer(IUnknown** ppUnk) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP TranslateAccelerator(LPMSG pMsg) {
+ return E_NOTIMPL;
+ }
};
// CComPropertySheet
IMPLEMENT_DYNAMIC(CComPropertySheet, CPropertySheet)
CComPropertySheet::CComPropertySheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
- : CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
+ : CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
{
- m_pSite = DNew CComPropertyPageSite(this);
- m_size.SetSize(0, 0);
+ m_pSite = DNew CComPropertyPageSite(this);
+ m_size.SetSize(0, 0);
}
CComPropertySheet::CComPropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
- : CPropertySheet(pszCaption, pParentWnd, iSelectPage)
+ : CPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
- m_pSite = DNew CComPropertyPageSite(this);
- m_size.SetSize(0, 0);
+ m_pSite = DNew CComPropertyPageSite(this);
+ m_size.SetSize(0, 0);
}
CComPropertySheet::~CComPropertySheet()
@@ -92,148 +92,148 @@ CComPropertySheet::~CComPropertySheet()
int CComPropertySheet::AddPages(ISpecifyPropertyPages* pSPP)
{
- if (!pSPP) {
- return 0;
- }
+ if (!pSPP) {
+ return 0;
+ }
- CAUUID caGUID;
- caGUID.pElems = NULL;
- if (FAILED(pSPP->GetPages(&caGUID)) || caGUID.pElems == NULL) {
- return 0;
- }
+ CAUUID caGUID;
+ caGUID.pElems = NULL;
+ if (FAILED(pSPP->GetPages(&caGUID)) || caGUID.pElems == NULL) {
+ return 0;
+ }
- IUnknown* lpUnk = NULL;
- if (FAILED(pSPP->QueryInterface(&lpUnk))) {
- return 0;
- }
+ IUnknown* lpUnk = NULL;
+ if (FAILED(pSPP->QueryInterface(&lpUnk))) {
+ return 0;
+ }
- m_spp.AddTail(pSPP);
+ m_spp.AddTail(pSPP);
- CComQIPtr<ISpecifyPropertyPages2> pSPP2 = pSPP;
- CComQIPtr<IPersist> pPersist = pSPP;
+ CComQIPtr<ISpecifyPropertyPages2> pSPP2 = pSPP;
+ CComQIPtr<IPersist> pPersist = pSPP;
- ULONG nPages = 0;
- for (ULONG i = 0; i < caGUID.cElems; i++) {
- CComPtr<IPropertyPage> pPage;
+ ULONG nPages = 0;
+ for (ULONG i = 0; i < caGUID.cElems; i++) {
+ CComPtr<IPropertyPage> pPage;
- HRESULT hr = E_FAIL;
+ HRESULT hr = E_FAIL;
- if (FAILED(hr) && !pPage && pSPP2) {
- hr = pSPP2->CreatePage(caGUID.pElems[i], &pPage);
- }
+ if (FAILED(hr) && !pPage && pSPP2) {
+ hr = pSPP2->CreatePage(caGUID.pElems[i], &pPage);
+ }
- if (FAILED(hr) && !pPage) {
- hr = pPage.CoCreateInstance(caGUID.pElems[i]);
- }
+ if (FAILED(hr) && !pPage) {
+ hr = pPage.CoCreateInstance(caGUID.pElems[i]);
+ }
- if (FAILED(hr) && !pPage && pPersist) {
- hr = LoadExternalPropertyPage(pPersist, caGUID.pElems[i], &pPage);
- }
+ if (FAILED(hr) && !pPage && pPersist) {
+ hr = LoadExternalPropertyPage(pPersist, caGUID.pElems[i], &pPage);
+ }
- if (SUCCEEDED(hr)) {
- if (AddPage(pPage, lpUnk)) {
- nPages++;
- }
- }
- }
+ if (SUCCEEDED(hr)) {
+ if (AddPage(pPage, lpUnk)) {
+ nPages++;
+ }
+ }
+ }
- if (caGUID.pElems) {
- CoTaskMemFree(caGUID.pElems);
- }
- lpUnk->Release();
+ if (caGUID.pElems) {
+ CoTaskMemFree(caGUID.pElems);
+ }
+ lpUnk->Release();
- return nPages;
+ return nPages;
}
bool CComPropertySheet::AddPage(IPropertyPage* pPage, IUnknown* pUnk)
{
- if (!pPage || !pUnk) {
- return false;
- }
-
- HRESULT hr;
- hr = pPage->SetPageSite(m_pSite);
- hr = pPage->SetObjects(1, &pUnk);
- PROPPAGEINFO ppi;
- hr = pPage->GetPageInfo(&ppi);
- m_size.cx = max(m_size.cx, ppi.size.cx);
- m_size.cy = max(m_size.cy, ppi.size.cy);
- CAutoPtr<CComPropertyPage> p(DNew CComPropertyPage(pPage));
- __super::AddPage(p);
- m_pages.AddTail(p);
-
- return true;
+ if (!pPage || !pUnk) {
+ return false;
+ }
+
+ HRESULT hr;
+ hr = pPage->SetPageSite(m_pSite);
+ hr = pPage->SetObjects(1, &pUnk);
+ PROPPAGEINFO ppi;
+ hr = pPage->GetPageInfo(&ppi);
+ m_size.cx = max(m_size.cx, ppi.size.cx);
+ m_size.cy = max(m_size.cy, ppi.size.cy);
+ CAutoPtr<CComPropertyPage> p(DNew CComPropertyPage(pPage));
+ __super::AddPage(p);
+ m_pages.AddTail(p);
+
+ return true;
}
void CComPropertySheet::OnActivated(CPropertyPage* pPage)
{
- if (!pPage) {
- return;
- }
-
- CRect bounds(30000,30000,-30000,-30000);
-
- CRect wr, cr;
- GetWindowRect(wr);
- GetClientRect(cr);
- CSize ws = wr.Size(), cs = cr.Size();
-
- CRect twr, tcr;
- CTabCtrl* pTC = (CTabCtrl*)GetDlgItem(AFX_IDC_TAB_CONTROL);
- pTC->GetWindowRect(twr);
- pTC->GetClientRect(tcr);
- CSize tws = twr.Size(), tcs = tcr.Size();
-
- if (CWnd* pChild = pPage->GetWindow(GW_CHILD)) {
- pChild->ModifyStyle(WS_CAPTION|WS_THICKFRAME, 0);
- pChild->ModifyStyleEx(WS_EX_DLGMODALFRAME, WS_EX_CONTROLPARENT);
-
- for (CWnd* pGrandChild = pChild->GetWindow(GW_CHILD); pGrandChild; pGrandChild = pGrandChild->GetNextWindow()) {
- if (!(pGrandChild->GetStyle()&WS_VISIBLE)) {
- continue;
- }
-
- CRect r;
- pGrandChild->GetWindowRect(&r);
- pChild->ScreenToClient(r);
- bounds |= r;
- }
- }
-
- bounds |= CRect(0,0,0,0);
- bounds.SetRect(0, 0, bounds.right + max(bounds.left, 4), bounds.bottom + max(bounds.top, 4));
-
- CRect r = CRect(CPoint(0,0), bounds.Size());
- pTC->AdjustRect(TRUE, r);
- r.SetRect(twr.TopLeft(), twr.TopLeft() + r.Size());
- ScreenToClient(r);
- pTC->MoveWindow(r);
- pTC->ModifyStyle(TCS_MULTILINE, TCS_SINGLELINE);
-
- CSize diff = r.Size() - tws;
-
- if (!bounds.IsRectEmpty()) {
- if (CWnd* pChild = pPage->GetWindow(GW_CHILD)) {
- pChild->MoveWindow(bounds);
- }
- CRect r = twr;
- pTC->AdjustRect(FALSE, r);
- ScreenToClient(r);
- pPage->MoveWindow(CRect(r.TopLeft(), bounds.Size()));
- }
-
- int _afxPropSheetButtons[] = { IDOK, IDCANCEL, ID_APPLY_NOW, IDHELP };
- for (int i = 0; i < _countof(_afxPropSheetButtons); i++) {
- if (CWnd* pWnd = GetDlgItem(_afxPropSheetButtons[i])) {
- pWnd->GetWindowRect(r);
- ScreenToClient(r);
- pWnd->MoveWindow(CRect(r.TopLeft() + diff, r.Size()));
- }
- }
-
- MoveWindow(CRect(wr.TopLeft(), ws + diff));
-
- Invalidate();
+ if (!pPage) {
+ return;
+ }
+
+ CRect bounds(30000, 30000, -30000, -30000);
+
+ CRect wr, cr;
+ GetWindowRect(wr);
+ GetClientRect(cr);
+ CSize ws = wr.Size(), cs = cr.Size();
+
+ CRect twr, tcr;
+ CTabCtrl* pTC = (CTabCtrl*)GetDlgItem(AFX_IDC_TAB_CONTROL);
+ pTC->GetWindowRect(twr);
+ pTC->GetClientRect(tcr);
+ CSize tws = twr.Size(), tcs = tcr.Size();
+
+ if (CWnd* pChild = pPage->GetWindow(GW_CHILD)) {
+ pChild->ModifyStyle(WS_CAPTION | WS_THICKFRAME, 0);
+ pChild->ModifyStyleEx(WS_EX_DLGMODALFRAME, WS_EX_CONTROLPARENT);
+
+ for (CWnd* pGrandChild = pChild->GetWindow(GW_CHILD); pGrandChild; pGrandChild = pGrandChild->GetNextWindow()) {
+ if (!(pGrandChild->GetStyle()&WS_VISIBLE)) {
+ continue;
+ }
+
+ CRect r;
+ pGrandChild->GetWindowRect(&r);
+ pChild->ScreenToClient(r);
+ bounds |= r;
+ }
+ }
+
+ bounds |= CRect(0, 0, 0, 0);
+ bounds.SetRect(0, 0, bounds.right + max(bounds.left, 4), bounds.bottom + max(bounds.top, 4));
+
+ CRect r = CRect(CPoint(0, 0), bounds.Size());
+ pTC->AdjustRect(TRUE, r);
+ r.SetRect(twr.TopLeft(), twr.TopLeft() + r.Size());
+ ScreenToClient(r);
+ pTC->MoveWindow(r);
+ pTC->ModifyStyle(TCS_MULTILINE, TCS_SINGLELINE);
+
+ CSize diff = r.Size() - tws;
+
+ if (!bounds.IsRectEmpty()) {
+ if (CWnd* pChild = pPage->GetWindow(GW_CHILD)) {
+ pChild->MoveWindow(bounds);
+ }
+ CRect r = twr;
+ pTC->AdjustRect(FALSE, r);
+ ScreenToClient(r);
+ pPage->MoveWindow(CRect(r.TopLeft(), bounds.Size()));
+ }
+
+ int _afxPropSheetButtons[] = { IDOK, IDCANCEL, ID_APPLY_NOW, IDHELP };
+ for (int i = 0; i < _countof(_afxPropSheetButtons); i++) {
+ if (CWnd* pWnd = GetDlgItem(_afxPropSheetButtons[i])) {
+ pWnd->GetWindowRect(r);
+ ScreenToClient(r);
+ pWnd->MoveWindow(CRect(r.TopLeft() + diff, r.Size()));
+ }
+ }
+
+ MoveWindow(CRect(wr.TopLeft(), ws + diff));
+
+ Invalidate();
}
@@ -245,11 +245,11 @@ END_MESSAGE_MAP()
BOOL CComPropertySheet::OnInitDialog()
{
- BOOL bResult = (BOOL)Default();//CPropertySheet::OnInitDialog();
+ BOOL bResult = (BOOL)Default();//CPropertySheet::OnInitDialog();
- if (!(GetStyle() & WS_CHILD)) {
- CenterWindow();
- }
+ if (!(GetStyle() & WS_CHILD)) {
+ CenterWindow();
+ }
- return bResult;
+ return bResult;
}
diff --git a/src/mpc-hc/ComPropertySheet.h b/src/mpc-hc/ComPropertySheet.h
index 722304732..0280e35e4 100644
--- a/src/mpc-hc/ComPropertySheet.h
+++ b/src/mpc-hc/ComPropertySheet.h
@@ -27,39 +27,39 @@
interface IComPropertyPageDirty {
- virtual void OnSetDirty(bool fDirty) = 0;
+ virtual void OnSetDirty(bool fDirty) = 0;
};
// CComPropertySheet
class CComPropertySheet : public CPropertySheet, public IComPropertyPageDirty
{
- DECLARE_DYNAMIC(CComPropertySheet)
+ DECLARE_DYNAMIC(CComPropertySheet)
- CComPtr<IPropertyPageSite> m_pSite;
- CInterfaceList<ISpecifyPropertyPages> m_spp;
- CAutoPtrList<CComPropertyPage> m_pages;
- CSize m_size;
+ CComPtr<IPropertyPageSite> m_pSite;
+ CInterfaceList<ISpecifyPropertyPages> m_spp;
+ CAutoPtrList<CComPropertyPage> m_pages;
+ CSize m_size;
public:
- CComPropertySheet(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
- CComPropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
- virtual ~CComPropertySheet();
+ CComPropertySheet(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
+ CComPropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
+ virtual ~CComPropertySheet();
- int AddPages(ISpecifyPropertyPages* pSPP);
- bool AddPage(IPropertyPage* pPage, IUnknown* pUnk);
+ int AddPages(ISpecifyPropertyPages* pSPP);
+ bool AddPage(IPropertyPage* pPage, IUnknown* pUnk);
- void OnActivated(CPropertyPage* pPage);
+ void OnActivated(CPropertyPage* pPage);
- // IComPropertyPageDirty
- void OnSetDirty(bool fDirty) {
- if (CPropertyPage* p = GetActivePage()) {
- p->SetModified(fDirty);
- }
- }
+ // IComPropertyPageDirty
+ void OnSetDirty(bool fDirty) {
+ if (CPropertyPage* p = GetActivePage()) {
+ p->SetModified(fDirty);
+ }
+ }
- virtual BOOL OnInitDialog();
+ virtual BOOL OnInitDialog();
protected:
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
};
diff --git a/src/mpc-hc/DVBChannel.cpp b/src/mpc-hc/DVBChannel.cpp
index 10afe3c4c..df2effb7f 100644
--- a/src/mpc-hc/DVBChannel.cpp
+++ b/src/mpc-hc/DVBChannel.cpp
@@ -27,21 +27,21 @@
CDVBChannel::CDVBChannel(void)
{
- m_ulFrequency = 0;
- m_nPrefNumber = 0;
- m_nOriginNumber = 0;
- m_bEncrypted = false;
- m_bNowNextFlag = false;
- m_ulONID = 0;
- m_ulTSID = 0;
- m_ulSID = 0;
- m_ulPMT = 0;
- m_ulPCR = 0;
- m_ulVideoPID = 0;
- m_nVideoType = DVB_MPV;
- m_nAudioCount = 0;
- m_nDefaultAudio = 0;
- m_nSubtitleCount = 0;
+ m_ulFrequency = 0;
+ m_nPrefNumber = 0;
+ m_nOriginNumber = 0;
+ m_bEncrypted = false;
+ m_bNowNextFlag = false;
+ m_ulONID = 0;
+ m_ulTSID = 0;
+ m_ulSID = 0;
+ m_ulPMT = 0;
+ m_ulPCR = 0;
+ m_ulVideoPID = 0;
+ m_nVideoType = DVB_MPV;
+ m_nAudioCount = 0;
+ m_nDefaultAudio = 0;
+ m_nSubtitleCount = 0;
}
CDVBChannel::~CDVBChannel(void)
@@ -50,113 +50,113 @@ CDVBChannel::~CDVBChannel(void)
void CDVBChannel::FromString(CString strValue)
{
- int i = 0;
- int nVersion;
+ int i = 0;
+ int nVersion;
- nVersion = _tstol(strValue.Tokenize(_T("|"), i));
- m_strName = strValue.Tokenize(_T("|"), i);
- m_ulFrequency = _tstol(strValue.Tokenize(_T("|"), i));
- m_nPrefNumber = _tstol(strValue.Tokenize(_T("|"), i));
- m_nOriginNumber = _tstol(strValue.Tokenize(_T("|"), i));
- if (nVersion > FORMAT_VERSION_0) {
- m_bEncrypted = !!_tstol(strValue.Tokenize(_T("|"), i));
- }
- if (nVersion > FORMAT_VERSION_1) {
- m_bNowNextFlag = !!_tstol(strValue.Tokenize(_T("|"), i));
- }
- m_ulONID = _tstol(strValue.Tokenize(_T("|"), i));
- m_ulTSID = _tstol(strValue.Tokenize(_T("|"), i));
- m_ulSID = _tstol(strValue.Tokenize(_T("|"), i));
- m_ulPMT = _tstol(strValue.Tokenize(_T("|"), i));
- m_ulPCR = _tstol(strValue.Tokenize(_T("|"), i));
- m_ulVideoPID = _tstol(strValue.Tokenize(_T("|"), i));
- m_nVideoType = (DVB_STREAM_TYPE)_tstol(strValue.Tokenize(_T("|"), i));
- m_nAudioCount = _tstol(strValue.Tokenize(_T("|"), i));
- if (nVersion > FORMAT_VERSION_1) {
- m_nDefaultAudio = _tstol(strValue.Tokenize(_T("|"), i));
- }
- m_nSubtitleCount = _tstol(strValue.Tokenize(_T("|"), i));
+ nVersion = _tstol(strValue.Tokenize(_T("|"), i));
+ m_strName = strValue.Tokenize(_T("|"), i);
+ m_ulFrequency = _tstol(strValue.Tokenize(_T("|"), i));
+ m_nPrefNumber = _tstol(strValue.Tokenize(_T("|"), i));
+ m_nOriginNumber = _tstol(strValue.Tokenize(_T("|"), i));
+ if (nVersion > FORMAT_VERSION_0) {
+ m_bEncrypted = !!_tstol(strValue.Tokenize(_T("|"), i));
+ }
+ if (nVersion > FORMAT_VERSION_1) {
+ m_bNowNextFlag = !!_tstol(strValue.Tokenize(_T("|"), i));
+ }
+ m_ulONID = _tstol(strValue.Tokenize(_T("|"), i));
+ m_ulTSID = _tstol(strValue.Tokenize(_T("|"), i));
+ m_ulSID = _tstol(strValue.Tokenize(_T("|"), i));
+ m_ulPMT = _tstol(strValue.Tokenize(_T("|"), i));
+ m_ulPCR = _tstol(strValue.Tokenize(_T("|"), i));
+ m_ulVideoPID = _tstol(strValue.Tokenize(_T("|"), i));
+ m_nVideoType = (DVB_STREAM_TYPE)_tstol(strValue.Tokenize(_T("|"), i));
+ m_nAudioCount = _tstol(strValue.Tokenize(_T("|"), i));
+ if (nVersion > FORMAT_VERSION_1) {
+ m_nDefaultAudio = _tstol(strValue.Tokenize(_T("|"), i));
+ }
+ m_nSubtitleCount = _tstol(strValue.Tokenize(_T("|"), i));
- for (int j=0; j<m_nAudioCount; j++) {
- m_Audios[j].PID = _tstol(strValue.Tokenize(_T("|"), i));
- m_Audios[j].Type = (DVB_STREAM_TYPE)_tstol(strValue.Tokenize(_T("|"), i));
- m_Audios[j].PesType = (PES_STREAM_TYPE)_tstol(strValue.Tokenize(_T("|"), i));
- m_Audios[j].Language = strValue.Tokenize(_T("|"), i);
- }
+ for (int j = 0; j < m_nAudioCount; j++) {
+ m_Audios[j].PID = _tstol(strValue.Tokenize(_T("|"), i));
+ m_Audios[j].Type = (DVB_STREAM_TYPE)_tstol(strValue.Tokenize(_T("|"), i));
+ m_Audios[j].PesType = (PES_STREAM_TYPE)_tstol(strValue.Tokenize(_T("|"), i));
+ m_Audios[j].Language = strValue.Tokenize(_T("|"), i);
+ }
- for (int j=0; j<m_nSubtitleCount; j++) {
- m_Subtitles[j].PID = _tstol(strValue.Tokenize(_T("|"), i));
- m_Subtitles[j].Type = (DVB_STREAM_TYPE)_tstol(strValue.Tokenize(_T("|"), i));
- m_Subtitles[j].PesType = (PES_STREAM_TYPE)_tstol(strValue.Tokenize(_T("|"), i));
- m_Subtitles[j].Language = strValue.Tokenize(_T("|"), i);
- }
+ for (int j = 0; j < m_nSubtitleCount; j++) {
+ m_Subtitles[j].PID = _tstol(strValue.Tokenize(_T("|"), i));
+ m_Subtitles[j].Type = (DVB_STREAM_TYPE)_tstol(strValue.Tokenize(_T("|"), i));
+ m_Subtitles[j].PesType = (PES_STREAM_TYPE)_tstol(strValue.Tokenize(_T("|"), i));
+ m_Subtitles[j].Language = strValue.Tokenize(_T("|"), i);
+ }
}
CString CDVBChannel::ToString()
{
- CString strValue;
- strValue.AppendFormat (_T("%d|%s|%ld|%d|%d|%d|%d|%ld|%ld|%ld|%ld|%ld|%ld|%d|%ld|%d|%ld"),
- FORMAT_VERSION_CURRENT,
- m_strName,
- m_ulFrequency,
- m_nPrefNumber,
- m_nOriginNumber,
- m_bEncrypted,
- m_bNowNextFlag,
- m_ulONID,
- m_ulTSID,
- m_ulSID,
- m_ulPMT,
- m_ulPCR,
- m_ulVideoPID,
- m_nVideoType,
- m_nAudioCount,
- m_nDefaultAudio,
- m_nSubtitleCount);
+ CString strValue;
+ strValue.AppendFormat(_T("%d|%s|%ld|%d|%d|%d|%d|%ld|%ld|%ld|%ld|%ld|%ld|%d|%ld|%d|%ld"),
+ FORMAT_VERSION_CURRENT,
+ m_strName,
+ m_ulFrequency,
+ m_nPrefNumber,
+ m_nOriginNumber,
+ m_bEncrypted,
+ m_bNowNextFlag,
+ m_ulONID,
+ m_ulTSID,
+ m_ulSID,
+ m_ulPMT,
+ m_ulPCR,
+ m_ulVideoPID,
+ m_nVideoType,
+ m_nAudioCount,
+ m_nDefaultAudio,
+ m_nSubtitleCount);
- for (int i=0; i<m_nAudioCount; i++) {
- strValue.AppendFormat (_T("|%ld|%d|%d|%s"), m_Audios[i].PID, m_Audios[i].Type, m_Audios[i].PesType, m_Audios[i].Language);
- }
+ for (int i = 0; i < m_nAudioCount; i++) {
+ strValue.AppendFormat(_T("|%ld|%d|%d|%s"), m_Audios[i].PID, m_Audios[i].Type, m_Audios[i].PesType, m_Audios[i].Language);
+ }
- for (int i=0; i<m_nSubtitleCount; i++) {
- strValue.AppendFormat (_T("|%ld|%d|%d|%s"), m_Subtitles[i].PID, m_Subtitles[i].Type, m_Subtitles[i].PesType, m_Subtitles[i].Language);
- }
+ for (int i = 0; i < m_nSubtitleCount; i++) {
+ strValue.AppendFormat(_T("|%ld|%d|%d|%s"), m_Subtitles[i].PID, m_Subtitles[i].Type, m_Subtitles[i].PesType, m_Subtitles[i].Language);
+ }
- return strValue;
+ return strValue;
}
void CDVBChannel::SetName(BYTE* Value)
{
- m_strName = CA2W((LPCSTR)Value);
+ m_strName = CA2W((LPCSTR)Value);
}
-void CDVBChannel::AddStreamInfo (ULONG ulPID, DVB_STREAM_TYPE nType, PES_STREAM_TYPE nPesType, LPCTSTR strLanguage)
+void CDVBChannel::AddStreamInfo(ULONG ulPID, DVB_STREAM_TYPE nType, PES_STREAM_TYPE nPesType, LPCTSTR strLanguage)
{
- switch (nType) {
- case DVB_MPV :
- case DVB_H264 :
- m_ulVideoPID = ulPID;
- m_nVideoType = nType;
- break;
- case DVB_MPA :
- case DVB_AC3 :
- case DVB_EAC3 :
- if (m_nAudioCount < DVB_MAX_AUDIO) {
- m_Audios[m_nAudioCount].PID = ulPID;
- m_Audios[m_nAudioCount].Type = nType;
- m_Audios[m_nAudioCount].PesType = nPesType;
- m_Audios[m_nAudioCount].Language = strLanguage;
- m_nAudioCount++;
- }
- break;
- case DVB_SUBTITLE :
- if (m_nSubtitleCount < DVB_MAX_SUBTITLE) {
- m_Subtitles[m_nSubtitleCount].PID = ulPID;
- m_Subtitles[m_nSubtitleCount].Type = nType;
- m_Subtitles[m_nSubtitleCount].PesType = nPesType;
- m_Subtitles[m_nSubtitleCount].Language = strLanguage;
- m_nSubtitleCount++;
- }
- break;
- }
+ switch (nType) {
+ case DVB_MPV :
+ case DVB_H264 :
+ m_ulVideoPID = ulPID;
+ m_nVideoType = nType;
+ break;
+ case DVB_MPA :
+ case DVB_AC3 :
+ case DVB_EAC3 :
+ if (m_nAudioCount < DVB_MAX_AUDIO) {
+ m_Audios[m_nAudioCount].PID = ulPID;
+ m_Audios[m_nAudioCount].Type = nType;
+ m_Audios[m_nAudioCount].PesType = nPesType;
+ m_Audios[m_nAudioCount].Language = strLanguage;
+ m_nAudioCount++;
+ }
+ break;
+ case DVB_SUBTITLE :
+ if (m_nSubtitleCount < DVB_MAX_SUBTITLE) {
+ m_Subtitles[m_nSubtitleCount].PID = ulPID;
+ m_Subtitles[m_nSubtitleCount].Type = nType;
+ m_Subtitles[m_nSubtitleCount].PesType = nPesType;
+ m_Subtitles[m_nSubtitleCount].Language = strLanguage;
+ m_nSubtitleCount++;
+ }
+ break;
+ }
}
diff --git a/src/mpc-hc/DVBChannel.h b/src/mpc-hc/DVBChannel.h
index 2864ab13e..717a8c582 100644
--- a/src/mpc-hc/DVBChannel.h
+++ b/src/mpc-hc/DVBChannel.h
@@ -22,176 +22,176 @@
#pragma once
-#define FORMAT_VERSION_0 0
-#define FORMAT_VERSION_1 1
-#define FORMAT_VERSION_CURRENT 2
+#define FORMAT_VERSION_0 0
+#define FORMAT_VERSION_1 1
+#define FORMAT_VERSION_CURRENT 2
-#define DVB_MAX_AUDIO 10
-#define DVB_MAX_SUBTITLE 10
+#define DVB_MAX_AUDIO 10
+#define DVB_MAX_SUBTITLE 10
typedef enum {
- DVB_MPV = 0x00,
- DVB_H264 = 0x01,
- DVB_MPA = 0x02,
- DVB_AC3 = 0x03,
- DVB_EAC3 = 0x04,
- DVB_PSI = 0x80,
- DVB_TIF = 0x81,
- DVB_EPG = 0x82,
- DVB_PMT = 0x83,
- DVB_SUB = 0x83,
- DVB_SUBTITLE= 0xFE,
- DVB_UNKNOWN = 0xFF
+ DVB_MPV = 0x00,
+ DVB_H264 = 0x01,
+ DVB_MPA = 0x02,
+ DVB_AC3 = 0x03,
+ DVB_EAC3 = 0x04,
+ DVB_PSI = 0x80,
+ DVB_TIF = 0x81,
+ DVB_EPG = 0x82,
+ DVB_PMT = 0x83,
+ DVB_SUB = 0x83,
+ DVB_SUBTITLE = 0xFE,
+ DVB_UNKNOWN = 0xFF
} DVB_STREAM_TYPE;
typedef struct {
- ULONG PID;
- DVB_STREAM_TYPE Type;
- PES_STREAM_TYPE PesType;
- CString Language;
+ ULONG PID;
+ DVB_STREAM_TYPE Type;
+ PES_STREAM_TYPE PesType;
+ CString Language;
- LCID GetLCID() {
- return ISO6392ToLcid(CStringA(Language));
- };
+ LCID GetLCID() {
+ return ISO6392ToLcid(CStringA(Language));
+ };
} DVBStreamInfo;
class CDVBChannel
{
public:
- CDVBChannel(void);
- ~CDVBChannel(void);
+ CDVBChannel(void);
+ ~CDVBChannel(void);
- void FromString(CString strValue);
- CString ToString();
+ void FromString(CString strValue);
+ CString ToString();
- LPCTSTR GetName() const {
- return m_strName;
- };
- ULONG GetFrequency() const {
- return m_ulFrequency;
- };
- int GetPrefNumber() const {
- return m_nPrefNumber;
- };
- int GetOriginNumber() const {
- return m_nOriginNumber;
- };
- ULONG GetONID() const {
- return m_ulONID;
- };
- ULONG GetTSID() const {
- return m_ulTSID;
- };
- ULONG GetSID() const {
- return m_ulSID;
- };
- ULONG GetPMT() const {
- return m_ulPMT;
- };
- ULONG GetPCR() const {
- return m_ulPCR;
- };
- ULONG GetVideoPID() const {
- return m_ulVideoPID;
- };
- DVB_STREAM_TYPE GetVideoType() const {
- return m_nVideoType;
- }
- ULONG GetDefaultAudioPID() const {
- return m_Audios[GetDefaultAudio()].PID;
- };
- DVB_STREAM_TYPE GetDefaultAudioType() const {
- return m_Audios[0].Type;
- }
- ULONG GetDefaultSubtitlePID() const {
- return m_Subtitles[0].PID; /* TODO : fa*/
- };
- int GetAudioCount() const {
- return m_nAudioCount;
- };
- int GetDefaultAudio() const {
- return m_nDefaultAudio;
- };
- int GetSubtitleCount() const {
- return m_nSubtitleCount;
- };
- DVBStreamInfo* GetAudio(int nIndex) {
- return &m_Audios[nIndex];
- };
- DVBStreamInfo* GetSubtitle(int nIndex) {
- return &m_Subtitles[nIndex];
- };
- bool HasName() {
- return !m_strName.IsEmpty();
- };
- bool IsEncrypted() {
- return m_bEncrypted;
- };
- bool GetNowNextFlag() {
- return m_bNowNextFlag;
- };
+ LPCTSTR GetName() const {
+ return m_strName;
+ };
+ ULONG GetFrequency() const {
+ return m_ulFrequency;
+ };
+ int GetPrefNumber() const {
+ return m_nPrefNumber;
+ };
+ int GetOriginNumber() const {
+ return m_nOriginNumber;
+ };
+ ULONG GetONID() const {
+ return m_ulONID;
+ };
+ ULONG GetTSID() const {
+ return m_ulTSID;
+ };
+ ULONG GetSID() const {
+ return m_ulSID;
+ };
+ ULONG GetPMT() const {
+ return m_ulPMT;
+ };
+ ULONG GetPCR() const {
+ return m_ulPCR;
+ };
+ ULONG GetVideoPID() const {
+ return m_ulVideoPID;
+ };
+ DVB_STREAM_TYPE GetVideoType() const {
+ return m_nVideoType;
+ }
+ ULONG GetDefaultAudioPID() const {
+ return m_Audios[GetDefaultAudio()].PID;
+ };
+ DVB_STREAM_TYPE GetDefaultAudioType() const {
+ return m_Audios[0].Type;
+ }
+ ULONG GetDefaultSubtitlePID() const {
+ return m_Subtitles[0].PID; /* TODO : fa*/
+ };
+ int GetAudioCount() const {
+ return m_nAudioCount;
+ };
+ int GetDefaultAudio() const {
+ return m_nDefaultAudio;
+ };
+ int GetSubtitleCount() const {
+ return m_nSubtitleCount;
+ };
+ DVBStreamInfo* GetAudio(int nIndex) {
+ return &m_Audios[nIndex];
+ };
+ DVBStreamInfo* GetSubtitle(int nIndex) {
+ return &m_Subtitles[nIndex];
+ };
+ bool HasName() {
+ return !m_strName.IsEmpty();
+ };
+ bool IsEncrypted() {
+ return m_bEncrypted;
+ };
+ bool GetNowNextFlag() {
+ return m_bNowNextFlag;
+ };
- void SetName(BYTE* Value);
- void SetName(LPCTSTR Value) {
- m_strName = Value;
- };
- void SetFrequency(ULONG Value) {
- m_ulFrequency = Value;
- };
- void SetPrefNumber(int Value) {
- m_nPrefNumber = Value;
- };
- void SetOriginNumber(int Value) {
- m_nOriginNumber = m_nPrefNumber = Value;
- };
- void SetEncrypted(bool Value) {
- m_bEncrypted = Value;
- };
- void SetNowNextFlag(bool Value) {
- m_bNowNextFlag = Value;
- };
- void SetONID(ULONG Value) {
- m_ulONID = Value;
- };
- void SetTSID(ULONG Value) {
- m_ulTSID = Value;
- };
- void SetSID(ULONG Value) {
- m_ulSID = Value;
- };
- void SetPMT(ULONG Value) {
- m_ulPMT = Value;
- };
- void SetPCR(ULONG Value) {
- m_ulPCR = Value;
- };
- void SetVideoPID(ULONG Value) {
- m_ulVideoPID = Value;
- };
- void SetDefaultAudio(int Value) {
- m_nDefaultAudio = Value;
- }
+ void SetName(BYTE* Value);
+ void SetName(LPCTSTR Value) {
+ m_strName = Value;
+ };
+ void SetFrequency(ULONG Value) {
+ m_ulFrequency = Value;
+ };
+ void SetPrefNumber(int Value) {
+ m_nPrefNumber = Value;
+ };
+ void SetOriginNumber(int Value) {
+ m_nOriginNumber = m_nPrefNumber = Value;
+ };
+ void SetEncrypted(bool Value) {
+ m_bEncrypted = Value;
+ };
+ void SetNowNextFlag(bool Value) {
+ m_bNowNextFlag = Value;
+ };
+ void SetONID(ULONG Value) {
+ m_ulONID = Value;
+ };
+ void SetTSID(ULONG Value) {
+ m_ulTSID = Value;
+ };
+ void SetSID(ULONG Value) {
+ m_ulSID = Value;
+ };
+ void SetPMT(ULONG Value) {
+ m_ulPMT = Value;
+ };
+ void SetPCR(ULONG Value) {
+ m_ulPCR = Value;
+ };
+ void SetVideoPID(ULONG Value) {
+ m_ulVideoPID = Value;
+ };
+ void SetDefaultAudio(int Value) {
+ m_nDefaultAudio = Value;
+ }
- void AddStreamInfo (ULONG ulPID, DVB_STREAM_TYPE nType, PES_STREAM_TYPE nPesType, LPCTSTR strLanguage);
+ void AddStreamInfo(ULONG ulPID, DVB_STREAM_TYPE nType, PES_STREAM_TYPE nPesType, LPCTSTR strLanguage);
private :
- CString m_strName;
- ULONG m_ulFrequency;
- int m_nPrefNumber;
- int m_nOriginNumber;
- bool m_bEncrypted;
- bool m_bNowNextFlag;
- ULONG m_ulONID;
- ULONG m_ulTSID;
- ULONG m_ulSID;
- ULONG m_ulPMT;
- ULONG m_ulPCR;
- ULONG m_ulVideoPID;
- DVB_STREAM_TYPE m_nVideoType;
- int m_nAudioCount;
- int m_nDefaultAudio;
- int m_nSubtitleCount;
- DVBStreamInfo m_Audios[DVB_MAX_AUDIO];
- DVBStreamInfo m_Subtitles[DVB_MAX_SUBTITLE];
+ CString m_strName;
+ ULONG m_ulFrequency;
+ int m_nPrefNumber;
+ int m_nOriginNumber;
+ bool m_bEncrypted;
+ bool m_bNowNextFlag;
+ ULONG m_ulONID;
+ ULONG m_ulTSID;
+ ULONG m_ulSID;
+ ULONG m_ulPMT;
+ ULONG m_ulPCR;
+ ULONG m_ulVideoPID;
+ DVB_STREAM_TYPE m_nVideoType;
+ int m_nAudioCount;
+ int m_nDefaultAudio;
+ int m_nSubtitleCount;
+ DVBStreamInfo m_Audios[DVB_MAX_AUDIO];
+ DVBStreamInfo m_Subtitles[DVB_MAX_SUBTITLE];
};
diff --git a/src/mpc-hc/DeinterlacerFilter.cpp b/src/mpc-hc/DeinterlacerFilter.cpp
index 17384b609..397be2839 100644
--- a/src/mpc-hc/DeinterlacerFilter.cpp
+++ b/src/mpc-hc/DeinterlacerFilter.cpp
@@ -28,136 +28,136 @@
CDeinterlacerFilter::CDeinterlacerFilter(LPUNKNOWN punk, HRESULT* phr)
- : CTransformFilter(NAME("CDeinterlacerFilter"), punk, __uuidof(CDeinterlacerFilter))
+ : CTransformFilter(NAME("CDeinterlacerFilter"), punk, __uuidof(CDeinterlacerFilter))
{
- if (phr) {
- *phr = S_OK;
- }
+ if (phr) {
+ *phr = S_OK;
+ }
}
HRESULT CDeinterlacerFilter::CheckConnect(PIN_DIRECTION dir, IPin* pPin)
{
- return GetCLSID(pPin) == __uuidof(*this) ? E_FAIL : S_OK;
+ return GetCLSID(pPin) == __uuidof(*this) ? E_FAIL : S_OK;
}
HRESULT CDeinterlacerFilter::CheckInputType(const CMediaType* mtIn)
{
- BITMAPINFOHEADER bih;
- if (!ExtractBIH(mtIn, &bih) /*|| bih.biHeight <= 0*/ || bih.biHeight <= 288) {
- return E_FAIL;
- }
-
- return mtIn->subtype == MEDIASUBTYPE_YUY2 || mtIn->subtype == MEDIASUBTYPE_UYVY
- || mtIn->subtype == MEDIASUBTYPE_I420 || mtIn->subtype == MEDIASUBTYPE_YV12 || mtIn->subtype == MEDIASUBTYPE_IYUV
- ? S_OK
- : E_FAIL;
+ BITMAPINFOHEADER bih;
+ if (!ExtractBIH(mtIn, &bih) /*|| bih.biHeight <= 0*/ || bih.biHeight <= 288) {
+ return E_FAIL;
+ }
+
+ return mtIn->subtype == MEDIASUBTYPE_YUY2 || mtIn->subtype == MEDIASUBTYPE_UYVY
+ || mtIn->subtype == MEDIASUBTYPE_I420 || mtIn->subtype == MEDIASUBTYPE_YV12 || mtIn->subtype == MEDIASUBTYPE_IYUV
+ ? S_OK
+ : E_FAIL;
}
HRESULT CDeinterlacerFilter::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
{
- return mtIn->subtype == mtOut->subtype ? S_OK : E_FAIL;
+ return mtIn->subtype == mtOut->subtype ? S_OK : E_FAIL;
}
HRESULT CDeinterlacerFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
{
- HRESULT hr;
-
- AM_MEDIA_TYPE* pmt = NULL;
- if (SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt) {
- CMediaType mt = *pmt;
- m_pOutput->SetMediaType(&mt);
- DeleteMediaType(pmt);
- }
-
- BYTE* pDataIn = NULL;
- if (FAILED(pIn->GetPointer(&pDataIn)) || !pDataIn) {
- return S_FALSE;
- }
-
- BYTE* pDataOut = NULL;
- if (FAILED(hr = pOut->GetPointer(&pDataOut)) || !pDataOut) {
- return hr;
- }
-
- const CMediaType& mtIn = m_pInput->CurrentMediaType();
- const CMediaType& mtOut = m_pOutput->CurrentMediaType();
-
- BITMAPINFOHEADER bihIn, bihOut;
- ExtractBIH(&mtIn, &bihIn);
- ExtractBIH(&mtOut, &bihOut);
-
- bool fInputFlipped = bihIn.biHeight >= 0 && bihIn.biCompression <= 3;
- bool fOutputFlipped = bihOut.biHeight >= 0 && bihOut.biCompression <= 3;
- bool fFlip = fInputFlipped != fOutputFlipped;
-
- int bppIn = !(bihIn.biBitCount&7) ? bihIn.biBitCount : 8;
- int bppOut = !(bihOut.biBitCount&7) ? bihOut.biBitCount : 8;
- int pitchIn = bihIn.biWidth*bppIn>>3;
- int pitchOut = bihOut.biWidth*bppOut>>3;
- BYTE* pDataOut2 = pDataOut;
- if (fFlip) {
- pDataOut2 += pitchOut*(bihIn.biHeight-1);
- pitchOut = -pitchOut;
- }
-
- if (mtIn.subtype == MEDIASUBTYPE_YUY2 || mtIn.subtype == MEDIASUBTYPE_UYVY) {
- DeinterlaceBlend(pDataOut, pDataIn, pitchIn, bihIn.biHeight, pitchOut, pitchIn);
- } else if (mtIn.subtype == MEDIASUBTYPE_I420 || mtIn.subtype == MEDIASUBTYPE_YV12 || mtIn.subtype == MEDIASUBTYPE_IYUV) {
- DeinterlaceBlend(pDataOut, pDataIn, pitchIn, bihIn.biHeight, pitchOut, pitchIn);
-
- int sizeIn = bihIn.biHeight*pitchIn, sizeOut = abs(bihOut.biHeight)*pitchOut;
- pitchIn /= 2;
- pitchOut /= 2;
- bihIn.biHeight /= 2;
- pDataIn += sizeIn;
- pDataOut += sizeOut;
- DeinterlaceBlend(pDataOut, pDataIn, pitchIn, bihIn.biHeight, pitchOut, pitchIn);
-
- pDataIn += sizeIn/4;
- pDataOut += sizeOut/4;
- DeinterlaceBlend(pDataOut, pDataIn, pitchIn, bihIn.biHeight, pitchOut, pitchIn);
- }
-
- return S_OK;
+ HRESULT hr;
+
+ AM_MEDIA_TYPE* pmt = NULL;
+ if (SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt) {
+ CMediaType mt = *pmt;
+ m_pOutput->SetMediaType(&mt);
+ DeleteMediaType(pmt);
+ }
+
+ BYTE* pDataIn = NULL;
+ if (FAILED(pIn->GetPointer(&pDataIn)) || !pDataIn) {
+ return S_FALSE;
+ }
+
+ BYTE* pDataOut = NULL;
+ if (FAILED(hr = pOut->GetPointer(&pDataOut)) || !pDataOut) {
+ return hr;
+ }
+
+ const CMediaType& mtIn = m_pInput->CurrentMediaType();
+ const CMediaType& mtOut = m_pOutput->CurrentMediaType();
+
+ BITMAPINFOHEADER bihIn, bihOut;
+ ExtractBIH(&mtIn, &bihIn);
+ ExtractBIH(&mtOut, &bihOut);
+
+ bool fInputFlipped = bihIn.biHeight >= 0 && bihIn.biCompression <= 3;
+ bool fOutputFlipped = bihOut.biHeight >= 0 && bihOut.biCompression <= 3;
+ bool fFlip = fInputFlipped != fOutputFlipped;
+
+ int bppIn = !(bihIn.biBitCount & 7) ? bihIn.biBitCount : 8;
+ int bppOut = !(bihOut.biBitCount & 7) ? bihOut.biBitCount : 8;
+ int pitchIn = bihIn.biWidth * bppIn >> 3;
+ int pitchOut = bihOut.biWidth * bppOut >> 3;
+ BYTE* pDataOut2 = pDataOut;
+ if (fFlip) {
+ pDataOut2 += pitchOut * (bihIn.biHeight - 1);
+ pitchOut = -pitchOut;
+ }
+
+ if (mtIn.subtype == MEDIASUBTYPE_YUY2 || mtIn.subtype == MEDIASUBTYPE_UYVY) {
+ DeinterlaceBlend(pDataOut, pDataIn, pitchIn, bihIn.biHeight, pitchOut, pitchIn);
+ } else if (mtIn.subtype == MEDIASUBTYPE_I420 || mtIn.subtype == MEDIASUBTYPE_YV12 || mtIn.subtype == MEDIASUBTYPE_IYUV) {
+ DeinterlaceBlend(pDataOut, pDataIn, pitchIn, bihIn.biHeight, pitchOut, pitchIn);
+
+ int sizeIn = bihIn.biHeight * pitchIn, sizeOut = abs(bihOut.biHeight) * pitchOut;
+ pitchIn /= 2;
+ pitchOut /= 2;
+ bihIn.biHeight /= 2;
+ pDataIn += sizeIn;
+ pDataOut += sizeOut;
+ DeinterlaceBlend(pDataOut, pDataIn, pitchIn, bihIn.biHeight, pitchOut, pitchIn);
+
+ pDataIn += sizeIn / 4;
+ pDataOut += sizeOut / 4;
+ DeinterlaceBlend(pDataOut, pDataIn, pitchIn, bihIn.biHeight, pitchOut, pitchIn);
+ }
+
+ return S_OK;
}
HRESULT CDeinterlacerFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if (m_pInput->IsConnected() == FALSE) {
- return E_UNEXPECTED;
- }
-
- BITMAPINFOHEADER bih;
- ExtractBIH(&m_pOutput->CurrentMediaType(), &bih);
-
- pProperties->cBuffers = 1;
- pProperties->cbBuffer = bih.biSizeImage;
- pProperties->cbAlign = 1;
- pProperties->cbPrefix = 0;
-
- HRESULT hr;
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
- return hr;
- }
-
- return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
- ? E_FAIL
- : NOERROR;
+ if (m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
+
+ BITMAPINFOHEADER bih;
+ ExtractBIH(&m_pOutput->CurrentMediaType(), &bih);
+
+ pProperties->cBuffers = 1;
+ pProperties->cbBuffer = bih.biSizeImage;
+ pProperties->cbAlign = 1;
+ pProperties->cbPrefix = 0;
+
+ HRESULT hr;
+ ALLOCATOR_PROPERTIES Actual;
+ if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
+
+ return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
+ ? E_FAIL
+ : NOERROR;
}
HRESULT CDeinterlacerFilter::GetMediaType(int iPosition, CMediaType* pmt)
{
- if (m_pInput->IsConnected() == FALSE) {
- return E_UNEXPECTED;
- }
- if (iPosition < 0) {
- return E_INVALIDARG;
- }
- if (iPosition > 0) {
- return VFW_S_NO_MORE_ITEMS;
- }
- *pmt = m_pInput->CurrentMediaType();
- CorrectMediaType(pmt);
- return S_OK;
+ if (m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
+ if (iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if (iPosition > 0) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
+ *pmt = m_pInput->CurrentMediaType();
+ CorrectMediaType(pmt);
+ return S_OK;
}
diff --git a/src/mpc-hc/DeinterlacerFilter.h b/src/mpc-hc/DeinterlacerFilter.h
index 1cbf01b85..711212dfe 100644
--- a/src/mpc-hc/DeinterlacerFilter.h
+++ b/src/mpc-hc/DeinterlacerFilter.h
@@ -25,16 +25,16 @@
class __declspec(uuid("96F3E0BE-1BA4-4E79-973D-191FE425C86B"))
- CDeinterlacerFilter : public CTransformFilter
+ CDeinterlacerFilter : public CTransformFilter
{
protected:
- HRESULT CheckConnect(PIN_DIRECTION dir, IPin* pPin);
- HRESULT CheckInputType(const CMediaType* mtIn);
- HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
- HRESULT Transform(IMediaSample* pIn, IMediaSample* pOut);
- HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
+ HRESULT CheckConnect(PIN_DIRECTION dir, IPin* pPin);
+ HRESULT CheckInputType(const CMediaType* mtIn);
+ HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
+ HRESULT Transform(IMediaSample* pIn, IMediaSample* pOut);
+ HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT GetMediaType(int iPosition, CMediaType* pmt);
public:
- CDeinterlacerFilter(LPUNKNOWN punk, HRESULT* phr);
+ CDeinterlacerFilter(LPUNKNOWN punk, HRESULT* phr);
};
diff --git a/src/mpc-hc/EditListEditor.cpp b/src/mpc-hc/EditListEditor.cpp
index 685d7d151..48cf43604 100644
--- a/src/mpc-hc/EditListEditor.cpp
+++ b/src/mpc-hc/EditListEditor.cpp
@@ -28,634 +28,634 @@
CClip::CClip()
{
- m_rtIn = _I64_MIN;
- m_rtOut = _I64_MIN;
+ m_rtIn = _I64_MIN;
+ m_rtOut = _I64_MIN;
}
void CClip::SetIn(LPCTSTR strVal)
{
- m_rtIn = StringToReftime (strVal);
+ m_rtIn = StringToReftime(strVal);
}
void CClip::SetOut(LPCTSTR strVal)
{
- m_rtOut = StringToReftime (strVal);
+ m_rtOut = StringToReftime(strVal);
}
-void CClip::SetIn (REFERENCE_TIME rtVal)
+void CClip::SetIn(REFERENCE_TIME rtVal)
{
- m_rtIn = rtVal;
- if (m_rtIn > m_rtOut) {
- m_rtOut = _I64_MIN;
- }
+ m_rtIn = rtVal;
+ if (m_rtIn > m_rtOut) {
+ m_rtOut = _I64_MIN;
+ }
};
-void CClip::SetOut (REFERENCE_TIME rtVal)
+void CClip::SetOut(REFERENCE_TIME rtVal)
{
- m_rtOut = rtVal;
- if (m_rtIn > m_rtOut) {
- m_rtIn = _I64_MIN;
- }
+ m_rtOut = rtVal;
+ if (m_rtIn > m_rtOut) {
+ m_rtIn = _I64_MIN;
+ }
};
CString CClip::GetIn()
{
- if (m_rtIn == _I64_MIN) {
- return _T("");
- } else {
- return ReftimeToString(m_rtIn);
- }
+ if (m_rtIn == _I64_MIN) {
+ return _T("");
+ } else {
+ return ReftimeToString(m_rtIn);
+ }
}
CString CClip::GetOut()
{
- if (m_rtOut == _I64_MIN) {
- return _T("");
- } else {
- return ReftimeToString(m_rtOut);
- }
+ if (m_rtOut == _I64_MIN) {
+ return _T("");
+ } else {
+ return ReftimeToString(m_rtOut);
+ }
}
IMPLEMENT_DYNAMIC(CEditListEditor, CPlayerBar)
CEditListEditor::CEditListEditor(void)
{
- m_CurPos = NULL;
- m_bDragging = FALSE;
- m_nDragIndex = -1;
- m_nDropIndex = -1;
- m_bFileOpen = false;
+ m_CurPos = NULL;
+ m_bDragging = FALSE;
+ m_nDragIndex = -1;
+ m_nDropIndex = -1;
+ m_bFileOpen = false;
}
CEditListEditor::~CEditListEditor(void)
{
- SaveEditListToFile();
+ SaveEditListToFile();
}
BEGIN_MESSAGE_MAP(CEditListEditor, CPlayerBar)
- ON_WM_SIZE()
- ON_NOTIFY(LVN_ITEMCHANGED, IDC_EDITLIST, OnLvnItemchanged)
- ON_NOTIFY(LVN_KEYDOWN, IDC_EDITLIST, OnLvnKeyDown)
- ON_WM_DRAWITEM()
- ON_NOTIFY(LVN_BEGINDRAG, IDC_EDITLIST, OnBeginDrag)
- ON_WM_MOUSEMOVE()
- ON_WM_LBUTTONUP()
- ON_WM_TIMER()
- ON_NOTIFY(LVN_BEGINLABELEDIT, IDC_EDITLIST, OnBeginlabeleditList)
- ON_NOTIFY(LVN_DOLABELEDIT, IDC_EDITLIST, OnDolabeleditList)
- ON_NOTIFY(LVN_ENDLABELEDIT, IDC_EDITLIST, OnEndlabeleditList)
+ ON_WM_SIZE()
+ ON_NOTIFY(LVN_ITEMCHANGED, IDC_EDITLIST, OnLvnItemchanged)
+ ON_NOTIFY(LVN_KEYDOWN, IDC_EDITLIST, OnLvnKeyDown)
+ ON_WM_DRAWITEM()
+ ON_NOTIFY(LVN_BEGINDRAG, IDC_EDITLIST, OnBeginDrag)
+ ON_WM_MOUSEMOVE()
+ ON_WM_LBUTTONUP()
+ ON_WM_TIMER()
+ ON_NOTIFY(LVN_BEGINLABELEDIT, IDC_EDITLIST, OnBeginlabeleditList)
+ ON_NOTIFY(LVN_DOLABELEDIT, IDC_EDITLIST, OnDolabeleditList)
+ ON_NOTIFY(LVN_ENDLABELEDIT, IDC_EDITLIST, OnEndlabeleditList)
END_MESSAGE_MAP()
BOOL CEditListEditor::Create(CWnd* pParentWnd, UINT defDockBarID)
{
- if (!__super::Create(ResStr(IDS_EDIT_LIST_EDITOR), pParentWnd, ID_VIEW_EDITLISTEDITOR, defDockBarID, _T("Edit List Editor"))) {
- return FALSE;
- }
+ if (!__super::Create(ResStr(IDS_EDIT_LIST_EDITOR), pParentWnd, ID_VIEW_EDITLISTEDITOR, defDockBarID, _T("Edit List Editor"))) {
+ return FALSE;
+ }
- m_stUsers.Create (_T("User :"), WS_VISIBLE|WS_CHILD, CRect (5,5,100,21), this, 0);
- m_cbUsers.Create (WS_CHILD|WS_VISIBLE|CBS_DROPDOWNLIST, CRect (90,0, 260, 21), this, 0);
- FillCombo(_T("Users.txt"), m_cbUsers, false);
+ m_stUsers.Create(_T("User :"), WS_VISIBLE | WS_CHILD, CRect(5, 5, 100, 21), this, 0);
+ m_cbUsers.Create(WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST, CRect(90, 0, 260, 21), this, 0);
+ FillCombo(_T("Users.txt"), m_cbUsers, false);
- m_stHotFolders.Create (_T("Hot folder :"), WS_VISIBLE|WS_CHILD, CRect (5,35,100,51), this, 0);
- m_cbHotFolders.Create (WS_CHILD|WS_VISIBLE|CBS_DROPDOWNLIST, CRect (90,30, 260, 21), this, 0);
- FillCombo(_T("HotFolders.txt"), m_cbHotFolders, true);
+ m_stHotFolders.Create(_T("Hot folder :"), WS_VISIBLE | WS_CHILD, CRect(5, 35, 100, 51), this, 0);
+ m_cbHotFolders.Create(WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST, CRect(90, 30, 260, 21), this, 0);
+ FillCombo(_T("HotFolders.txt"), m_cbHotFolders, true);
- m_list.CreateEx(
- WS_EX_DLGMODALFRAME|WS_EX_CLIENTEDGE,
- WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_TABSTOP
- |LVS_OWNERDRAWFIXED
- |LVS_REPORT|LVS_SINGLESEL|LVS_AUTOARRANGE|LVS_NOSORTHEADER,
- CRect(0,0,100,100), this, IDC_EDITLIST);
+ m_list.CreateEx(
+ WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE,
+ WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP
+ | LVS_OWNERDRAWFIXED
+ | LVS_REPORT | LVS_SINGLESEL | LVS_AUTOARRANGE | LVS_NOSORTHEADER,
+ CRect(0, 0, 100, 100), this, IDC_EDITLIST);
- m_list.SetExtendedStyle(m_list.GetExtendedStyle()|LVS_EX_FULLROWSELECT|LVS_EX_DOUBLEBUFFER);
+ m_list.SetExtendedStyle(m_list.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);
- m_list.InsertColumn(COL_IN, _T("Nb."), LVCFMT_LEFT, 35);
- m_list.InsertColumn(COL_IN, _T("In"), LVCFMT_LEFT, 100);
- m_list.InsertColumn(COL_OUT, _T("Out"), LVCFMT_LEFT, 100);
- m_list.InsertColumn(COL_NAME, _T("Name"), LVCFMT_LEFT, 150);
+ m_list.InsertColumn(COL_IN, _T("Nb."), LVCFMT_LEFT, 35);
+ m_list.InsertColumn(COL_IN, _T("In"), LVCFMT_LEFT, 100);
+ m_list.InsertColumn(COL_OUT, _T("Out"), LVCFMT_LEFT, 100);
+ m_list.InsertColumn(COL_NAME, _T("Name"), LVCFMT_LEFT, 150);
- m_fakeImageList.Create(1, 16, ILC_COLOR4, 10, 10);
- m_list.SetImageList(&m_fakeImageList, LVSIL_SMALL);
+ m_fakeImageList.Create(1, 16, ILC_COLOR4, 10, 10);
+ m_list.SetImageList(&m_fakeImageList, LVSIL_SMALL);
- return TRUE;
+ return TRUE;
}
void CEditListEditor::OnSize(UINT nType, int cx, int cy)
{
- CSizingControlBarG::OnSize(nType, cx, cy);
+ CSizingControlBarG::OnSize(nType, cx, cy);
- ResizeListColumn();
+ ResizeListColumn();
}
void CEditListEditor::ResizeListColumn()
{
- if (::IsWindow(m_list.m_hWnd)) {
- CRect r;
- GetClientRect(r);
- r.DeflateRect(2, 2);
+ if (::IsWindow(m_list.m_hWnd)) {
+ CRect r;
+ GetClientRect(r);
+ r.DeflateRect(2, 2);
- r.top += 60;
- m_list.SetRedraw(FALSE);
- m_list.MoveWindow(r);
- m_list.GetClientRect(r);
- m_list.SetRedraw(TRUE);
- }
+ r.top += 60;
+ m_list.SetRedraw(FALSE);
+ m_list.MoveWindow(r);
+ m_list.GetClientRect(r);
+ m_list.SetRedraw(TRUE);
+ }
}
void CEditListEditor::SaveEditListToFile()
{
- if ((m_bFileOpen || m_EditList.GetCount() >0) && !m_strFileName.IsEmpty()) {
- CStdioFile EditListFile;
- if (EditListFile.Open (m_strFileName, CFile::modeCreate|CFile::modeWrite)) {
- CString strLine;
- int nIndex;
- CString strUser;
- CString strHotFolders;
+ if ((m_bFileOpen || m_EditList.GetCount() > 0) && !m_strFileName.IsEmpty()) {
+ CStdioFile EditListFile;
+ if (EditListFile.Open(m_strFileName, CFile::modeCreate | CFile::modeWrite)) {
+ CString strLine;
+ int nIndex;
+ CString strUser;
+ CString strHotFolders;
- nIndex = m_cbUsers.GetCurSel();
- if (nIndex >= 0) {
- m_cbUsers.GetLBText(nIndex, strUser);
- }
+ nIndex = m_cbUsers.GetCurSel();
+ if (nIndex >= 0) {
+ m_cbUsers.GetLBText(nIndex, strUser);
+ }
- nIndex = m_cbHotFolders.GetCurSel();
- if (nIndex >= 0) {
- m_cbHotFolders.GetLBText(nIndex, strHotFolders);
- }
+ nIndex = m_cbHotFolders.GetCurSel();
+ if (nIndex >= 0) {
+ m_cbHotFolders.GetLBText(nIndex, strHotFolders);
+ }
- POSITION pos = m_EditList.GetHeadPosition();
- for (int i = 0; pos; i++, m_EditList.GetNext(pos)) {
- CClip& CurClip = m_EditList.GetAt(pos);
+ POSITION pos = m_EditList.GetHeadPosition();
+ for (int i = 0; pos; i++, m_EditList.GetNext(pos)) {
+ CClip& CurClip = m_EditList.GetAt(pos);
- if (CurClip.HaveIn() && CurClip.HaveOut()) {
- strLine.Format(_T("%s\t%s\t%s\t%s\t%s\n"), CurClip.GetIn(), CurClip.GetOut(), CurClip.GetName(), strUser, strHotFolders);
- EditListFile.WriteString (strLine);
- }
- }
+ if (CurClip.HaveIn() && CurClip.HaveOut()) {
+ strLine.Format(_T("%s\t%s\t%s\t%s\t%s\n"), CurClip.GetIn(), CurClip.GetOut(), CurClip.GetName(), strUser, strHotFolders);
+ EditListFile.WriteString(strLine);
+ }
+ }
- EditListFile.Close();
- }
- }
+ EditListFile.Close();
+ }
+ }
}
void CEditListEditor::CloseFile()
{
- SaveEditListToFile();
- m_EditList.RemoveAll();
- m_list.DeleteAllItems();
- m_CurPos = NULL;
- m_strFileName = "";
- m_bFileOpen = false;
- m_cbHotFolders.SetCurSel(0);
+ SaveEditListToFile();
+ m_EditList.RemoveAll();
+ m_list.DeleteAllItems();
+ m_CurPos = NULL;
+ m_strFileName = "";
+ m_bFileOpen = false;
+ m_cbHotFolders.SetCurSel(0);
}
void CEditListEditor::OpenFile(LPCTSTR lpFileName)
{
- CString strLine;
- CStdioFile EditListFile;
- CString strUser;
- CString strHotFolders;
-
- CloseFile();
- m_strFileName.Format(_T("%s.edl"), lpFileName);
-
- if (EditListFile.Open (m_strFileName, CFile::modeRead)) {
- m_bFileOpen = true;
- while (EditListFile.ReadString(strLine)) {
- //int nPos = 0;
- CString strIn; // = strLine.Tokenize(_T(" \t"), nPos);
- CString strOut; // = strLine.Tokenize(_T(" \t"), nPos);
- CString strName; // = strLine.Tokenize(_T(" \t"), nPos);
-
- AfxExtractSubString (strIn, strLine, 0, _T('\t'));
- AfxExtractSubString (strOut, strLine, 1, _T('\t'));
- AfxExtractSubString (strName, strLine, 2, _T('\t'));
- if (strUser.IsEmpty()) {
- AfxExtractSubString (strUser, strLine, 3, _T('\t'));
- SelectCombo(strUser, m_cbUsers);
- }
- if (strHotFolders.IsEmpty()) {
- AfxExtractSubString (strHotFolders, strLine, 4, _T('\t'));
- SelectCombo(strHotFolders, m_cbHotFolders);
- }
-
- if (!strIn.IsEmpty() && !strOut.IsEmpty()) {
- CClip NewClip;
- NewClip.SetIn (strIn);
- NewClip.SetOut (strOut);
- NewClip.SetName(strName);
-
- InsertClip (NULL, NewClip);
- }
- }
-
- EditListFile.Close();
- } else {
- m_bFileOpen = false;
- }
-
- if (m_NameList.GetCount() == 0) {
- CStdioFile NameFile;
- CString str;
- if (NameFile.Open (_T("EditListNames.txt"), CFile::modeRead)) {
- while (NameFile.ReadString(str)) {
- m_NameList.Add(str);
- }
- NameFile.Close();
- }
- }
-}
-
-void CEditListEditor::SetIn (REFERENCE_TIME rtIn)
-{
- if (m_CurPos != NULL) {
- CClip& CurClip = m_EditList.GetAt (m_CurPos);
-
- CurClip.SetIn (rtIn);
- m_list.Invalidate();
- }
+ CString strLine;
+ CStdioFile EditListFile;
+ CString strUser;
+ CString strHotFolders;
+
+ CloseFile();
+ m_strFileName.Format(_T("%s.edl"), lpFileName);
+
+ if (EditListFile.Open(m_strFileName, CFile::modeRead)) {
+ m_bFileOpen = true;
+ while (EditListFile.ReadString(strLine)) {
+ //int nPos = 0;
+ CString strIn; // = strLine.Tokenize(_T(" \t"), nPos);
+ CString strOut; // = strLine.Tokenize(_T(" \t"), nPos);
+ CString strName; // = strLine.Tokenize(_T(" \t"), nPos);
+
+ AfxExtractSubString(strIn, strLine, 0, _T('\t'));
+ AfxExtractSubString(strOut, strLine, 1, _T('\t'));
+ AfxExtractSubString(strName, strLine, 2, _T('\t'));
+ if (strUser.IsEmpty()) {
+ AfxExtractSubString(strUser, strLine, 3, _T('\t'));
+ SelectCombo(strUser, m_cbUsers);
+ }
+ if (strHotFolders.IsEmpty()) {
+ AfxExtractSubString(strHotFolders, strLine, 4, _T('\t'));
+ SelectCombo(strHotFolders, m_cbHotFolders);
+ }
+
+ if (!strIn.IsEmpty() && !strOut.IsEmpty()) {
+ CClip NewClip;
+ NewClip.SetIn(strIn);
+ NewClip.SetOut(strOut);
+ NewClip.SetName(strName);
+
+ InsertClip(NULL, NewClip);
+ }
+ }
+
+ EditListFile.Close();
+ } else {
+ m_bFileOpen = false;
+ }
+
+ if (m_NameList.GetCount() == 0) {
+ CStdioFile NameFile;
+ CString str;
+ if (NameFile.Open(_T("EditListNames.txt"), CFile::modeRead)) {
+ while (NameFile.ReadString(str)) {
+ m_NameList.Add(str);
+ }
+ NameFile.Close();
+ }
+ }
+}
+
+void CEditListEditor::SetIn(REFERENCE_TIME rtIn)
+{
+ if (m_CurPos != NULL) {
+ CClip& CurClip = m_EditList.GetAt(m_CurPos);
+
+ CurClip.SetIn(rtIn);
+ m_list.Invalidate();
+ }
}
void CEditListEditor::SetOut(REFERENCE_TIME rtOut)
{
- if (m_CurPos != NULL) {
- CClip& CurClip = m_EditList.GetAt (m_CurPos);
+ if (m_CurPos != NULL) {
+ CClip& CurClip = m_EditList.GetAt(m_CurPos);
- CurClip.SetOut (rtOut);
- m_list.Invalidate();
- }
+ CurClip.SetOut(rtOut);
+ m_list.Invalidate();
+ }
}
void CEditListEditor::NewClip(REFERENCE_TIME rtVal)
{
- CClip NewClip;
+ CClip NewClip;
- if (m_CurPos != NULL) {
- CClip& CurClip = m_EditList.GetAt (m_CurPos);
+ if (m_CurPos != NULL) {
+ CClip& CurClip = m_EditList.GetAt(m_CurPos);
- if (CurClip.HaveIn()) {
- if (!CurClip.HaveOut()) {
- CurClip.SetOut (rtVal);
- }
- }
- }
- m_CurPos = InsertClip (m_CurPos, NewClip);
- m_list.Invalidate();
+ if (CurClip.HaveIn()) {
+ if (!CurClip.HaveOut()) {
+ CurClip.SetOut(rtVal);
+ }
+ }
+ }
+ m_CurPos = InsertClip(m_CurPos, NewClip);
+ m_list.Invalidate();
}
void CEditListEditor::Save()
{
- SaveEditListToFile();
+ SaveEditListToFile();
}
-int CEditListEditor::FindIndex(POSITION pos)
+int CEditListEditor::FindIndex(POSITION pos)
{
- int iItem = 0;
- POSITION CurPos = m_EditList.GetHeadPosition();
- while (CurPos && CurPos != pos) {
- m_EditList.GetNext (CurPos);
- iItem++;
- }
- return iItem;
+ int iItem = 0;
+ POSITION CurPos = m_EditList.GetHeadPosition();
+ while (CurPos && CurPos != pos) {
+ m_EditList.GetNext(CurPos);
+ iItem++;
+ }
+ return iItem;
}
POSITION CEditListEditor::InsertClip(POSITION pos, CClip& NewClip)
{
- LVITEM lv;
- POSITION NewClipPos;
+ LVITEM lv;
+ POSITION NewClipPos;
- if (pos == NULL) {
- NewClipPos = m_EditList.AddTail (NewClip);
- } else {
- NewClipPos = m_EditList.InsertAfter (pos, NewClip);
- }
+ if (pos == NULL) {
+ NewClipPos = m_EditList.AddTail(NewClip);
+ } else {
+ NewClipPos = m_EditList.InsertAfter(pos, NewClip);
+ }
- lv.mask = LVIF_STATE | LVIF_TEXT;
- lv.iItem = FindIndex (pos);
- lv.iSubItem = 0;
- lv.pszText = _T("");
- lv.state = m_list.GetItemCount()==0 ? LVIS_SELECTED : 0;
- m_list.InsertItem(&lv);
+ lv.mask = LVIF_STATE | LVIF_TEXT;
+ lv.iItem = FindIndex(pos);
+ lv.iSubItem = 0;
+ lv.pszText = _T("");
+ lv.state = m_list.GetItemCount() == 0 ? LVIS_SELECTED : 0;
+ m_list.InsertItem(&lv);
- return NewClipPos;
+ return NewClipPos;
}
void CEditListEditor::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
- if (nIDCtl != IDC_EDITLIST) {
- return;
- }
-
- int nItem = lpDrawItemStruct->itemID;
- CRect rcItem = lpDrawItemStruct->rcItem;
- POSITION pos = m_EditList.FindIndex(nItem);
-
- if (pos != NULL) {
- bool fSelected = (pos == m_CurPos);
- UNREFERENCED_PARAMETER(fSelected);
- CClip& CurClip = m_EditList.GetAt(pos);
- CString strTemp;
-
- CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
-
- if (!!m_list.GetItemState(nItem, LVIS_SELECTED)) {
- FillRect(pDC->m_hDC, rcItem, CBrush(0xf1dacc));
- FrameRect(pDC->m_hDC, rcItem, CBrush(0xc56a31));
- } else {
- FillRect(pDC->m_hDC, rcItem, CBrush(GetSysColor(COLOR_WINDOW)));
- }
-
- COLORREF textcolor = RGB(0,0,0);
- if (!CurClip.HaveIn() || !CurClip.HaveOut()) {
- textcolor = RGB(255,0,0);
- }
-
- for (int i=0; i<COL_MAX; i++) {
- m_list.GetSubItemRect(nItem, i, LVIR_LABEL, rcItem);
- pDC->SetTextColor(textcolor);
- switch (i) {
- case COL_INDEX :
- strTemp.Format (_T("%d"), nItem+1);
- pDC->DrawText (strTemp, rcItem, DT_CENTER | DT_VCENTER);
- break;
- case COL_IN :
- pDC->DrawText (CurClip.GetIn(), rcItem, DT_CENTER | DT_VCENTER);
- break;
- case COL_OUT :
- pDC->DrawText (CurClip.GetOut(), rcItem, DT_CENTER | DT_VCENTER);
- break;
- case COL_NAME :
- pDC->DrawText (CurClip.GetName(), rcItem, DT_LEFT | DT_VCENTER);
- break;
- }
- }
- }
-}
-
-void CEditListEditor::OnLvnItemchanged(NMHDR *pNMHDR, LRESULT *pResult)
-{
- LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
-
- if (pNMLV->iItem >= 0) {
- m_CurPos = m_EditList.FindIndex (pNMLV->iItem);
- }
+ if (nIDCtl != IDC_EDITLIST) {
+ return;
+ }
+
+ int nItem = lpDrawItemStruct->itemID;
+ CRect rcItem = lpDrawItemStruct->rcItem;
+ POSITION pos = m_EditList.FindIndex(nItem);
+
+ if (pos != NULL) {
+ bool fSelected = (pos == m_CurPos);
+ UNREFERENCED_PARAMETER(fSelected);
+ CClip& CurClip = m_EditList.GetAt(pos);
+ CString strTemp;
+
+ CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
+
+ if (!!m_list.GetItemState(nItem, LVIS_SELECTED)) {
+ FillRect(pDC->m_hDC, rcItem, CBrush(0xf1dacc));
+ FrameRect(pDC->m_hDC, rcItem, CBrush(0xc56a31));
+ } else {
+ FillRect(pDC->m_hDC, rcItem, CBrush(GetSysColor(COLOR_WINDOW)));
+ }
+
+ COLORREF textcolor = RGB(0, 0, 0);
+ if (!CurClip.HaveIn() || !CurClip.HaveOut()) {
+ textcolor = RGB(255, 0, 0);
+ }
+
+ for (int i = 0; i < COL_MAX; i++) {
+ m_list.GetSubItemRect(nItem, i, LVIR_LABEL, rcItem);
+ pDC->SetTextColor(textcolor);
+ switch (i) {
+ case COL_INDEX :
+ strTemp.Format(_T("%d"), nItem + 1);
+ pDC->DrawText(strTemp, rcItem, DT_CENTER | DT_VCENTER);
+ break;
+ case COL_IN :
+ pDC->DrawText(CurClip.GetIn(), rcItem, DT_CENTER | DT_VCENTER);
+ break;
+ case COL_OUT :
+ pDC->DrawText(CurClip.GetOut(), rcItem, DT_CENTER | DT_VCENTER);
+ break;
+ case COL_NAME :
+ pDC->DrawText(CurClip.GetName(), rcItem, DT_LEFT | DT_VCENTER);
+ break;
+ }
+ }
+ }
+}
+
+void CEditListEditor::OnLvnItemchanged(NMHDR* pNMHDR, LRESULT* pResult)
+{
+ LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
+
+ if (pNMLV->iItem >= 0) {
+ m_CurPos = m_EditList.FindIndex(pNMLV->iItem);
+ }
}
void CEditListEditor::OnLvnKeyDown(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMLVKEYDOWN pLVKeyDown = reinterpret_cast<LPNMLVKEYDOWN>(pNMHDR);
-
- *pResult = FALSE;
-
- if (pLVKeyDown->wVKey == VK_DELETE) {
- POSITION pos = m_list.GetFirstSelectedItemPosition();
- POSITION ClipPos;
- int nItem = -1;
- while (pos) {
- nItem = m_list.GetNextSelectedItem(pos);
- ClipPos = m_EditList.FindIndex (nItem);
- if (ClipPos) {
- m_EditList.RemoveAt (ClipPos);
- }
- m_list.DeleteItem (nItem);
- }
- if (nItem != -1) {
- m_list.SetItemState (min (nItem, m_list.GetItemCount()-1), LVIS_SELECTED, LVIS_SELECTED);
- }
- m_list.Invalidate();
- }
+ LPNMLVKEYDOWN pLVKeyDown = reinterpret_cast<LPNMLVKEYDOWN>(pNMHDR);
+
+ *pResult = FALSE;
+
+ if (pLVKeyDown->wVKey == VK_DELETE) {
+ POSITION pos = m_list.GetFirstSelectedItemPosition();
+ POSITION ClipPos;
+ int nItem = -1;
+ while (pos) {
+ nItem = m_list.GetNextSelectedItem(pos);
+ ClipPos = m_EditList.FindIndex(nItem);
+ if (ClipPos) {
+ m_EditList.RemoveAt(ClipPos);
+ }
+ m_list.DeleteItem(nItem);
+ }
+ if (nItem != -1) {
+ m_list.SetItemState(min(nItem, m_list.GetItemCount() - 1), LVIS_SELECTED, LVIS_SELECTED);
+ }
+ m_list.Invalidate();
+ }
}
void CEditListEditor::OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult)
{
- ModifyStyle(WS_EX_ACCEPTFILES, 0);
+ ModifyStyle(WS_EX_ACCEPTFILES, 0);
- m_nDragIndex = ((LPNMLISTVIEW)pNMHDR)->iItem;
+ m_nDragIndex = ((LPNMLISTVIEW)pNMHDR)->iItem;
- CPoint p(0, 0);
- m_pDragImage = m_list.CreateDragImageEx(&p);
+ CPoint p(0, 0);
+ m_pDragImage = m_list.CreateDragImageEx(&p);
- CPoint p2 = ((LPNMLISTVIEW)pNMHDR)->ptAction;
+ CPoint p2 = ((LPNMLISTVIEW)pNMHDR)->ptAction;
- m_pDragImage->BeginDrag(0, p2 - p);
- m_pDragImage->DragEnter(GetDesktopWindow(), ((LPNMLISTVIEW)pNMHDR)->ptAction);
+ m_pDragImage->BeginDrag(0, p2 - p);
+ m_pDragImage->DragEnter(GetDesktopWindow(), ((LPNMLISTVIEW)pNMHDR)->ptAction);
- m_bDragging = TRUE;
- m_nDropIndex = -1;
+ m_bDragging = TRUE;
+ m_nDropIndex = -1;
- SetCapture();
+ SetCapture();
}
void CEditListEditor::OnMouseMove(UINT nFlags, CPoint point)
{
- if (m_bDragging) {
- m_ptDropPoint = point;
- ClientToScreen(&m_ptDropPoint);
+ if (m_bDragging) {
+ m_ptDropPoint = point;
+ ClientToScreen(&m_ptDropPoint);
- m_pDragImage->DragMove(m_ptDropPoint);
- m_pDragImage->DragShowNolock(FALSE);
+ m_pDragImage->DragMove(m_ptDropPoint);
+ m_pDragImage->DragShowNolock(FALSE);
- WindowFromPoint(m_ptDropPoint)->ScreenToClient(&m_ptDropPoint);
+ WindowFromPoint(m_ptDropPoint)->ScreenToClient(&m_ptDropPoint);
- m_pDragImage->DragShowNolock(TRUE);
+ m_pDragImage->DragShowNolock(TRUE);
- {
- int iOverItem = m_list.HitTest(m_ptDropPoint);
- int iTopItem = m_list.GetTopIndex();
- int iBottomItem = m_list.GetBottomIndex();
+ {
+ int iOverItem = m_list.HitTest(m_ptDropPoint);
+ int iTopItem = m_list.GetTopIndex();
+ int iBottomItem = m_list.GetBottomIndex();
- if (iOverItem == iTopItem && iTopItem != 0) { // top of list
- SetTimer(1, 100, NULL);
- } else {
- KillTimer(1);
- }
+ if (iOverItem == iTopItem && iTopItem != 0) { // top of list
+ SetTimer(1, 100, NULL);
+ } else {
+ KillTimer(1);
+ }
- if (iOverItem >= iBottomItem && iBottomItem != (m_list.GetItemCount() - 1)) { // bottom of list
- SetTimer(2, 100, NULL);
- } else {
- KillTimer(2);
- }
- }
- }
+ if (iOverItem >= iBottomItem && iBottomItem != (m_list.GetItemCount() - 1)) { // bottom of list
+ SetTimer(2, 100, NULL);
+ } else {
+ KillTimer(2);
+ }
+ }
+ }
- __super::OnMouseMove(nFlags, point);
+ __super::OnMouseMove(nFlags, point);
}
void CEditListEditor::OnTimer(UINT_PTR nIDEvent)
{
- int iTopItem = m_list.GetTopIndex();
- int iBottomItem = iTopItem + m_list.GetCountPerPage() - 1;
+ int iTopItem = m_list.GetTopIndex();
+ int iBottomItem = iTopItem + m_list.GetCountPerPage() - 1;
- if (m_bDragging) {
- m_pDragImage->DragShowNolock(FALSE);
+ if (m_bDragging) {
+ m_pDragImage->DragShowNolock(FALSE);
- if (nIDEvent == 1) {
- m_list.EnsureVisible(iTopItem - 1, false);
- m_list.UpdateWindow();
- if (m_list.GetTopIndex() == 0) {
- KillTimer(1);
- }
- } else if (nIDEvent == 2) {
- m_list.EnsureVisible(iBottomItem + 1, false);
- m_list.UpdateWindow();
- if (m_list.GetBottomIndex() == (m_list.GetItemCount() - 1)) {
- KillTimer(2);
- }
- }
+ if (nIDEvent == 1) {
+ m_list.EnsureVisible(iTopItem - 1, false);
+ m_list.UpdateWindow();
+ if (m_list.GetTopIndex() == 0) {
+ KillTimer(1);
+ }
+ } else if (nIDEvent == 2) {
+ m_list.EnsureVisible(iBottomItem + 1, false);
+ m_list.UpdateWindow();
+ if (m_list.GetBottomIndex() == (m_list.GetItemCount() - 1)) {
+ KillTimer(2);
+ }
+ }
- m_pDragImage->DragShowNolock(TRUE);
- }
+ m_pDragImage->DragShowNolock(TRUE);
+ }
- __super::OnTimer(nIDEvent);
+ __super::OnTimer(nIDEvent);
}
void CEditListEditor::OnLButtonUp(UINT nFlags, CPoint point)
{
- if (m_bDragging) {
- ::ReleaseCapture();
+ if (m_bDragging) {
+ ::ReleaseCapture();
- m_bDragging = FALSE;
- m_pDragImage->DragLeave(GetDesktopWindow());
- m_pDragImage->EndDrag();
+ m_bDragging = FALSE;
+ m_pDragImage->DragLeave(GetDesktopWindow());
+ m_pDragImage->EndDrag();
- delete m_pDragImage;
- m_pDragImage = NULL;
+ delete m_pDragImage;
+ m_pDragImage = NULL;
- KillTimer(1);
- KillTimer(2);
+ KillTimer(1);
+ KillTimer(2);
- CPoint pt(point);
- ClientToScreen(&pt);
+ CPoint pt(point);
+ ClientToScreen(&pt);
- if (WindowFromPoint(pt) == &m_list) {
- DropItemOnList();
- }
- }
+ if (WindowFromPoint(pt) == &m_list) {
+ DropItemOnList();
+ }
+ }
- ModifyStyle(0, WS_EX_ACCEPTFILES);
+ ModifyStyle(0, WS_EX_ACCEPTFILES);
- __super::OnLButtonUp(nFlags, point);
+ __super::OnLButtonUp(nFlags, point);
}
void CEditListEditor::DropItemOnList()
{
- m_ptDropPoint.y -= 10; //
- m_nDropIndex = m_list.HitTest(CPoint(10, m_ptDropPoint.y));
+ m_ptDropPoint.y -= 10; //
+ m_nDropIndex = m_list.HitTest(CPoint(10, m_ptDropPoint.y));
- POSITION DragPos = m_EditList.FindIndex (m_nDragIndex);
- POSITION DropPos = m_EditList.FindIndex (m_nDropIndex);
- if ((DragPos!=NULL) && (DropPos!=NULL)) {
- CClip& DragClip = m_EditList.GetAt(DragPos);
- m_EditList.InsertAfter (DropPos, DragClip);
- m_EditList.RemoveAt (DragPos);
- m_list.Invalidate();
- }
+ POSITION DragPos = m_EditList.FindIndex(m_nDragIndex);
+ POSITION DropPos = m_EditList.FindIndex(m_nDropIndex);
+ if ((DragPos != NULL) && (DropPos != NULL)) {
+ CClip& DragClip = m_EditList.GetAt(DragPos);
+ m_EditList.InsertAfter(DropPos, DragClip);
+ m_EditList.RemoveAt(DragPos);
+ m_list.Invalidate();
+ }
}
void CEditListEditor::OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- LV_ITEM* pItem = &pDispInfo->item;
+ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
+ LV_ITEM* pItem = &pDispInfo->item;
- *pResult = FALSE;
+ *pResult = FALSE;
- if (pItem->iItem < 0) {
- return;
- }
+ if (pItem->iItem < 0) {
+ return;
+ }
- if (pItem->iSubItem == COL_NAME) {
- *pResult = TRUE;
- }
+ if (pItem->iSubItem == COL_NAME) {
+ *pResult = TRUE;
+ }
}
void CEditListEditor::OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- LV_ITEM* pItem = &pDispInfo->item;
+ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
+ LV_ITEM* pItem = &pDispInfo->item;
- *pResult = FALSE;
+ *pResult = FALSE;
- if (pItem->iItem < 0) {
- return;
- }
+ if (pItem->iItem < 0) {
+ return;
+ }
- if (m_CurPos != NULL && pItem->iSubItem == COL_NAME) {
- CClip& CurClip = m_EditList.GetAt (m_CurPos);
- int nSel = FindNameIndex (CurClip.GetName());
+ if (m_CurPos != NULL && pItem->iSubItem == COL_NAME) {
+ CClip& CurClip = m_EditList.GetAt(m_CurPos);
+ int nSel = FindNameIndex(CurClip.GetName());
- CAtlList<CString> sl;
- for (int i=0; i<m_NameList.GetCount(); i++) {
- sl.AddTail(m_NameList.GetAt(i));
- }
- m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel, true);
+ CAtlList<CString> sl;
+ for (int i = 0; i < m_NameList.GetCount(); i++) {
+ sl.AddTail(m_NameList.GetAt(i));
+ }
+ m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel, true);
- *pResult = TRUE;
- }
+ *pResult = TRUE;
+ }
}
void CEditListEditor::OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- LV_ITEM* pItem = &pDispInfo->item;
+ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
+ LV_ITEM* pItem = &pDispInfo->item;
- *pResult = FALSE;
+ *pResult = FALSE;
- if (!m_list.m_fInPlaceDirty) {
- return;
- }
+ if (!m_list.m_fInPlaceDirty) {
+ return;
+ }
- if (pItem->iItem < 0) {
- return;
- }
+ if (pItem->iItem < 0) {
+ return;
+ }
- CString& CurName = m_NameList.GetAt(pItem->lParam);
+ CString& CurName = m_NameList.GetAt(pItem->lParam);
- if (m_CurPos != NULL && pItem->iSubItem == COL_NAME) {
- CClip& CurClip = m_EditList.GetAt (m_CurPos);
- CurClip.SetName(CurName);
+ if (m_CurPos != NULL && pItem->iSubItem == COL_NAME) {
+ CClip& CurClip = m_EditList.GetAt(m_CurPos);
+ CurClip.SetName(CurName);
- *pResult = TRUE;
- }
+ *pResult = TRUE;
+ }
}
int CEditListEditor::FindNameIndex(LPCTSTR strName)
{
- int nResult = -1;
+ int nResult = -1;
- for (int i = 0; i<m_NameList.GetCount(); i++) {
- CString& CurName = m_NameList.GetAt(i);
+ for (int i = 0; i < m_NameList.GetCount(); i++) {
+ CString& CurName = m_NameList.GetAt(i);
- if (CurName == strName) {
- nResult = i;
- break;
- }
- }
+ if (CurName == strName) {
+ nResult = i;
+ break;
+ }
+ }
- return nResult;
+ return nResult;
}
void CEditListEditor::FillCombo(LPCTSTR strFileName, CComboBox& Combo, bool bAllowNull)
{
- CStdioFile NameFile;
- CString str;
- if (NameFile.Open (strFileName, CFile::modeRead)) {
- if (bAllowNull) {
- Combo.AddString(_T(""));
- }
+ CStdioFile NameFile;
+ CString str;
+ if (NameFile.Open(strFileName, CFile::modeRead)) {
+ if (bAllowNull) {
+ Combo.AddString(_T(""));
+ }
- while (NameFile.ReadString(str)) {
- Combo.AddString(str);
- }
- NameFile.Close();
- }
+ while (NameFile.ReadString(str)) {
+ Combo.AddString(str);
+ }
+ NameFile.Close();
+ }
}
void CEditListEditor::SelectCombo(LPCTSTR strValue, CComboBox& Combo)
{
- for (int i=0; i<Combo.GetCount(); i++) {
- CString strTemp;
- Combo.GetLBText(i, strTemp);
- if (strTemp == strValue) {
- Combo.SetCurSel(i);
- break;
- }
- }
+ for (int i = 0; i < Combo.GetCount(); i++) {
+ CString strTemp;
+ Combo.GetLBText(i, strTemp);
+ if (strTemp == strValue) {
+ Combo.SetCurSel(i);
+ break;
+ }
+ }
}
diff --git a/src/mpc-hc/EditListEditor.h b/src/mpc-hc/EditListEditor.h
index aa91e7841..0761708da 100644
--- a/src/mpc-hc/EditListEditor.h
+++ b/src/mpc-hc/EditListEditor.h
@@ -29,93 +29,93 @@
class CClip
{
private :
- REFERENCE_TIME m_rtIn;
- REFERENCE_TIME m_rtOut;
- CString m_strName;
+ REFERENCE_TIME m_rtIn;
+ REFERENCE_TIME m_rtOut;
+ CString m_strName;
public :
- CClip();
-
- bool HaveIn() {
- return m_rtIn != _I64_MIN;
- };
- bool HaveOut() {
- return m_rtOut != _I64_MIN;
- };
-
- void SetOut (LPCTSTR strVal);
- void SetIn (LPCTSTR strVal);
- void SetIn (REFERENCE_TIME rtVal);
- void SetOut (REFERENCE_TIME rtVal);
- void SetName(LPCTSTR strName) {
- m_strName = strName;
- };
-
- CString GetIn();
- CString GetOut();
- CString GetName() const {
- return m_strName;
- };
+ CClip();
+
+ bool HaveIn() {
+ return m_rtIn != _I64_MIN;
+ };
+ bool HaveOut() {
+ return m_rtOut != _I64_MIN;
+ };
+
+ void SetOut(LPCTSTR strVal);
+ void SetIn(LPCTSTR strVal);
+ void SetIn(REFERENCE_TIME rtVal);
+ void SetOut(REFERENCE_TIME rtVal);
+ void SetName(LPCTSTR strName) {
+ m_strName = strName;
+ };
+
+ CString GetIn();
+ CString GetOut();
+ CString GetName() const {
+ return m_strName;
+ };
};
-class CEditListEditor : public CPlayerBar
+class CEditListEditor : public CPlayerBar
{
- DECLARE_DYNAMIC(CEditListEditor)
-
- enum {COL_INDEX, COL_IN, COL_OUT, COL_NAME, COL_MAX};
-
- CPlayerListCtrl m_list;
- CStatic m_stUsers;
- CComboBox m_cbUsers;
- CStatic m_stHotFolders;
- CComboBox m_cbHotFolders;
- CImageList m_fakeImageList;
- POSITION m_CurPos;
- BOOL m_bDragging;
- int m_nDragIndex;
- int m_nDropIndex;
- CPoint m_ptDropPoint;
- CImageList* m_pDragImage;
-
- CString m_strFileName;
- bool m_bFileOpen;
- CList<CClip> m_EditList;
- CArray<CString> m_NameList;
-
- void SaveEditListToFile();
- void ResizeListColumn();
- POSITION InsertClip(POSITION pos, CClip& NewClip);
- void DropItemOnList();
- int FindIndex(POSITION pos);
- int FindNameIndex(LPCTSTR strName);
- void FillCombo(LPCTSTR strFileName, CComboBox& Combo, bool bAllowNull);
- void SelectCombo(LPCTSTR strValue, CComboBox& Combo);
+ DECLARE_DYNAMIC(CEditListEditor)
+
+ enum {COL_INDEX, COL_IN, COL_OUT, COL_NAME, COL_MAX};
+
+ CPlayerListCtrl m_list;
+ CStatic m_stUsers;
+ CComboBox m_cbUsers;
+ CStatic m_stHotFolders;
+ CComboBox m_cbHotFolders;
+ CImageList m_fakeImageList;
+ POSITION m_CurPos;
+ BOOL m_bDragging;
+ int m_nDragIndex;
+ int m_nDropIndex;
+ CPoint m_ptDropPoint;
+ CImageList* m_pDragImage;
+
+ CString m_strFileName;
+ bool m_bFileOpen;
+ CList<CClip> m_EditList;
+ CArray<CString> m_NameList;
+
+ void SaveEditListToFile();
+ void ResizeListColumn();
+ POSITION InsertClip(POSITION pos, CClip& NewClip);
+ void DropItemOnList();
+ int FindIndex(POSITION pos);
+ int FindNameIndex(LPCTSTR strName);
+ void FillCombo(LPCTSTR strFileName, CComboBox& Combo, bool bAllowNull);
+ void SelectCombo(LPCTSTR strValue, CComboBox& Combo);
protected :
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- CEditListEditor(void);
- ~CEditListEditor(void);
-
- BOOL Create(CWnd* pParentWnd, UINT defDockBarID);
-
- void CloseFile();
- void OpenFile(LPCTSTR lpFileName);
- void SetIn(REFERENCE_TIME rtIn);
- void SetOut(REFERENCE_TIME rtOut);
- void NewClip(REFERENCE_TIME rtVal);
- void Save();
-
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg void OnLvnKeyDown(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
- afx_msg void OnLvnItemchanged(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnMouseMove(UINT nFlags, CPoint point);
- afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
- afx_msg void OnTimer(UINT_PTR nIDEvent);
- afx_msg void OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ CEditListEditor(void);
+ ~CEditListEditor(void);
+
+ BOOL Create(CWnd* pParentWnd, UINT defDockBarID);
+
+ void CloseFile();
+ void OpenFile(LPCTSTR lpFileName);
+ void SetIn(REFERENCE_TIME rtIn);
+ void SetOut(REFERENCE_TIME rtOut);
+ void NewClip(REFERENCE_TIME rtVal);
+ void Save();
+
+ afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg void OnLvnKeyDown(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
+ afx_msg void OnLvnItemchanged(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnMouseMove(UINT nFlags, CPoint point);
+ afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
+ afx_msg void OnTimer(UINT_PTR nIDEvent);
+ afx_msg void OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
};
diff --git a/src/mpc-hc/EditWithButton.cpp b/src/mpc-hc/EditWithButton.cpp
index 18ed86fc4..191773b53 100644
--- a/src/mpc-hc/EditWithButton.cpp
+++ b/src/mpc-hc/EditWithButton.cpp
@@ -1,311 +1,307 @@
#include "stdafx.h"
#include "EditWithButton.h"
-#define WM_EDITWITHBUTTON_RECALCNCSIZE (WM_USER + 200) // arbitrary number. hopefully no conflicts
+#define WM_EDITWITHBUTTON_RECALCNCSIZE (WM_USER + 200) // arbitrary number. hopefully no conflicts
// CEditWithButton_Base ---------------------------------------------------------------------------
CEditWithButton_Base::CEditWithButton_Base()
- : m_TopBorder(0), m_BottomBorder(0), m_LeftBorder(0), m_RightBorder(0), m_ButtonWidth(1)
- , m_IsButtonPressed(false), m_IsMouseActive(false), m_IsButtonHot(false)
+ : m_TopBorder(0), m_BottomBorder(0), m_LeftBorder(0), m_RightBorder(0), m_ButtonWidth(1)
+ , m_IsButtonPressed(false), m_IsMouseActive(false), m_IsButtonHot(false)
{
}
BEGIN_MESSAGE_MAP(CEditWithButton_Base, CEdit)
- ON_WM_NCCALCSIZE()
- ON_WM_NCPAINT()
- ON_WM_NCLBUTTONDOWN()
- ON_WM_MOUSEMOVE()
- ON_WM_NCMOUSEMOVE()
- ON_WM_NCMOUSELEAVE()
- ON_WM_LBUTTONUP()
- ON_WM_NCHITTEST()
- ON_MESSAGE(WM_EDITWITHBUTTON_RECALCNCSIZE, OnRecalcNcSize)
- ON_WM_NCDESTROY()
- ON_WM_ENABLE()
- ON_MESSAGE(EM_SETREADONLY, OnSetReadOnly)
+ ON_WM_NCCALCSIZE()
+ ON_WM_NCPAINT()
+ ON_WM_NCLBUTTONDOWN()
+ ON_WM_MOUSEMOVE()
+ ON_WM_NCMOUSEMOVE()
+ ON_WM_NCMOUSELEAVE()
+ ON_WM_LBUTTONUP()
+ ON_WM_NCHITTEST()
+ ON_MESSAGE(WM_EDITWITHBUTTON_RECALCNCSIZE, OnRecalcNcSize)
+ ON_WM_NCDESTROY()
+ ON_WM_ENABLE()
+ ON_MESSAGE(EM_SETREADONLY, OnSetReadOnly)
END_MESSAGE_MAP()
CRect CEditWithButton_Base::GetButtonRect(const CRect& rectWindow) const
{
- CRect rectButton(rectWindow);
- rectButton.top += m_TopBorder;
- rectButton.bottom -= m_BottomBorder;
- rectButton.right -= m_RightBorder;
- rectButton.left = rectButton.right - m_ButtonWidth;
-
- // take into account any scrollbars in the edit control
- if (rectButton.right > rectButton.left)
- rectButton.OffsetRect(m_RightBorder - m_LeftBorder, 0);
-
- return rectButton;
+ CRect rectButton(rectWindow);
+ rectButton.top += m_TopBorder;
+ rectButton.bottom -= m_BottomBorder;
+ rectButton.right -= m_RightBorder;
+ rectButton.left = rectButton.right - m_ButtonWidth;
+
+ // take into account any scrollbars in the edit control
+ if (rectButton.right > rectButton.left) {
+ rectButton.OffsetRect(m_RightBorder - m_LeftBorder, 0);
+ }
+
+ return rectButton;
}
int CEditWithButton_Base::GetButtonThemeState() const
{
- if (GetStyle() & (ES_READONLY | WS_DISABLED))
- return PBS_DISABLED;
- else if (m_IsButtonPressed)
- return PBS_PRESSED;
- else if (m_IsButtonHot)
- return PBS_HOT;
- else
- return PBS_NORMAL;
+ if (GetStyle() & (ES_READONLY | WS_DISABLED)) {
+ return PBS_DISABLED;
+ } else if (m_IsButtonPressed) {
+ return PBS_PRESSED;
+ } else if (m_IsButtonHot) {
+ return PBS_HOT;
+ } else {
+ return PBS_NORMAL;
+ }
}
void CEditWithButton_Base::DrawButton(CRect rectButton)
{
- CWindowDC dc(this);
-
- HTHEME hButtonTheme = OpenThemeData(m_hWnd, _T("Button"));
- if (hButtonTheme)
- {
- int ButtonState = GetButtonThemeState();
-
- // If necessary, first fill with the edit control's background color.
- if (IsThemeBackgroundPartiallyTransparent(hButtonTheme, BP_PUSHBUTTON, ButtonState))
- {
- HTHEME hEditTheme = OpenThemeDataEx(m_hWnd, _T("Edit"), OTD_NONCLIENT);
-
- COLORREF BgColor = RGB(0, 0, 0);
- BgColor = GetThemeSysColor(hEditTheme, (GetStyle() & (ES_READONLY | WS_DISABLED)) ? COLOR_3DFACE : COLOR_WINDOW);
- dc.FillSolidRect(rectButton, BgColor);
-
- CloseThemeData(hEditTheme);
- }
-
- DrawThemeBackground(hButtonTheme, dc, BP_PUSHBUTTON, ButtonState, rectButton, NULL);
-
- DrawButtonContent(dc, rectButton, hButtonTheme);
-
- CloseThemeData(hButtonTheme);
- }
- else
- {
- UINT uState = DFCS_BUTTONPUSH;
- if (GetStyle() & (ES_READONLY | WS_DISABLED))
- uState |= DFCS_INACTIVE;
- else if (m_IsButtonPressed)
- uState |= DFCS_PUSHED;
- dc.DrawFrameControl(rectButton, DFC_BUTTON, uState);
-
- // If the button is in a pressed state, then contents should move slightly as part of the "push" effect.
- if (m_IsButtonPressed)
- rectButton.OffsetRect(1, 1);
-
- DrawButtonContent(dc, rectButton, NULL);
- }
+ CWindowDC dc(this);
+
+ HTHEME hButtonTheme = OpenThemeData(m_hWnd, _T("Button"));
+ if (hButtonTheme) {
+ int ButtonState = GetButtonThemeState();
+
+ // If necessary, first fill with the edit control's background color.
+ if (IsThemeBackgroundPartiallyTransparent(hButtonTheme, BP_PUSHBUTTON, ButtonState)) {
+ HTHEME hEditTheme = OpenThemeDataEx(m_hWnd, _T("Edit"), OTD_NONCLIENT);
+
+ COLORREF BgColor = RGB(0, 0, 0);
+ BgColor = GetThemeSysColor(hEditTheme, (GetStyle() & (ES_READONLY | WS_DISABLED)) ? COLOR_3DFACE : COLOR_WINDOW);
+ dc.FillSolidRect(rectButton, BgColor);
+
+ CloseThemeData(hEditTheme);
+ }
+
+ DrawThemeBackground(hButtonTheme, dc, BP_PUSHBUTTON, ButtonState, rectButton, NULL);
+
+ DrawButtonContent(dc, rectButton, hButtonTheme);
+
+ CloseThemeData(hButtonTheme);
+ } else {
+ UINT uState = DFCS_BUTTONPUSH;
+ if (GetStyle() & (ES_READONLY | WS_DISABLED)) {
+ uState |= DFCS_INACTIVE;
+ } else if (m_IsButtonPressed) {
+ uState |= DFCS_PUSHED;
+ }
+ dc.DrawFrameControl(rectButton, DFC_BUTTON, uState);
+
+ // If the button is in a pressed state, then contents should move slightly as part of the "push" effect.
+ if (m_IsButtonPressed) {
+ rectButton.OffsetRect(1, 1);
+ }
+
+ DrawButtonContent(dc, rectButton, NULL);
+ }
}
void CEditWithButton_Base::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp)
{
- CRect rectOld = lpncsp->rgrc[0];
+ CRect rectOld = lpncsp->rgrc[0];
- // Let the default processing setup space of the usual screen elements (borders, etc)
- CEdit::OnNcCalcSize(bCalcValidRects, lpncsp);
+ // Let the default processing setup space of the usual screen elements (borders, etc)
+ CEdit::OnNcCalcSize(bCalcValidRects, lpncsp);
- // Store the current size of the borders, so we know where to put the button
- m_TopBorder = lpncsp->rgrc[0].top - rectOld.top;
- m_BottomBorder = rectOld.bottom - lpncsp->rgrc[0].bottom;
- m_LeftBorder = lpncsp->rgrc[0].left - rectOld.left;
- m_RightBorder = rectOld.right - lpncsp->rgrc[0].right;
+ // Store the current size of the borders, so we know where to put the button
+ m_TopBorder = lpncsp->rgrc[0].top - rectOld.top;
+ m_BottomBorder = rectOld.bottom - lpncsp->rgrc[0].bottom;
+ m_LeftBorder = lpncsp->rgrc[0].left - rectOld.left;
+ m_RightBorder = rectOld.right - lpncsp->rgrc[0].right;
- m_ButtonWidth = CalculateButtonWidth();
+ m_ButtonWidth = CalculateButtonWidth();
- // Deflate the right side, making room for our button
- lpncsp->rgrc[0].right -= m_ButtonWidth;
+ // Deflate the right side, making room for our button
+ lpncsp->rgrc[0].right -= m_ButtonWidth;
}
void CEditWithButton_Base::OnNcPaint()
{
- // Allow default processing
- CEdit::OnNcPaint();
+ // Allow default processing
+ CEdit::OnNcPaint();
- CRect rectWindow;
- GetWindowRect(rectWindow);
- // Adjust coords to start at 0,0
- rectWindow.OffsetRect(-rectWindow.TopLeft());
+ CRect rectWindow;
+ GetWindowRect(rectWindow);
+ // Adjust coords to start at 0,0
+ rectWindow.OffsetRect(-rectWindow.TopLeft());
- CRect rectButton = GetButtonRect(rectWindow);
+ CRect rectButton = GetButtonRect(rectWindow);
- DrawButton(rectButton);
+ DrawButton(rectButton);
}
void CEditWithButton_Base::OnNcLButtonDown(UINT nHitTest, CPoint point)
{
- if (!(GetStyle() & (ES_READONLY | WS_DISABLED)))
- {
- CRect rectWindow;
- GetWindowRect(rectWindow);
- CRect rectButton = GetButtonRect(rectWindow);
+ if (!(GetStyle() & (ES_READONLY | WS_DISABLED))) {
+ CRect rectWindow;
+ GetWindowRect(rectWindow);
+ CRect rectButton = GetButtonRect(rectWindow);
- if (rectButton.PtInRect(point))
- {
- SetCapture();
+ if (rectButton.PtInRect(point)) {
+ SetCapture();
- m_IsButtonPressed = true;
- m_IsMouseActive = true;
+ m_IsButtonPressed = true;
+ m_IsMouseActive = true;
- // Redraw the button to reflect the change
- SetWindowPos(NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
- }
- }
+ // Redraw the button to reflect the change
+ SetWindowPos(NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
+ }
+ }
- CEdit::OnNcLButtonDown(nHitTest, point);
+ CEdit::OnNcLButtonDown(nHitTest, point);
}
void CEditWithButton_Base::OnMouseMove(UINT nFlags, CPoint point)
{
- if (m_IsMouseActive)
- {
- ClientToScreen(&point);
+ if (m_IsMouseActive) {
+ ClientToScreen(&point);
- CRect rectWindow;
- GetWindowRect(rectWindow);
- CRect rectButton = GetButtonRect(rectWindow);
+ CRect rectWindow;
+ GetWindowRect(rectWindow);
+ CRect rectButton = GetButtonRect(rectWindow);
- bool OldState = m_IsButtonPressed;
+ bool OldState = m_IsButtonPressed;
- m_IsButtonPressed = rectButton.PtInRect(point) != FALSE;
+ m_IsButtonPressed = rectButton.PtInRect(point) != FALSE;
- // If the button state has changed, redraw it to reflect the change
- if (OldState != m_IsButtonPressed)
- SetWindowPos(NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
- }
+ // If the button state has changed, redraw it to reflect the change
+ if (OldState != m_IsButtonPressed) {
+ SetWindowPos(NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
+ }
+ }
- CEdit::OnMouseMove(nFlags, point);
+ CEdit::OnMouseMove(nFlags, point);
}
void CEditWithButton_Base::OnNcMouseMove(UINT nHitTest, CPoint point)
{
- CRect rectWindow;
- GetWindowRect(rectWindow);
- CRect rectButton = GetButtonRect(rectWindow);
-
- bool OldState = m_IsButtonHot;
- m_IsButtonHot = rectButton.PtInRect(point) != FALSE;
- // If the button state has changed, redraw it to reflect the change
- if (OldState != m_IsButtonHot)
- {
- SetWindowPos(NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
-
- // If the state has changed to hot, register to get the WM_NCMOUSELEAVE notification.
- if (m_IsButtonHot)
- {
- TRACKMOUSEEVENT tme;
- tme.cbSize = sizeof(tme);
- tme.dwFlags = TME_LEAVE | TME_NONCLIENT;
- tme.hwndTrack = m_hWnd;
- tme.dwHoverTime = HOVER_DEFAULT;
- _TrackMouseEvent(&tme);
- }
- }
-
- CEdit::OnNcMouseMove(nHitTest, point);
+ CRect rectWindow;
+ GetWindowRect(rectWindow);
+ CRect rectButton = GetButtonRect(rectWindow);
+
+ bool OldState = m_IsButtonHot;
+ m_IsButtonHot = rectButton.PtInRect(point) != FALSE;
+ // If the button state has changed, redraw it to reflect the change
+ if (OldState != m_IsButtonHot) {
+ SetWindowPos(NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
+
+ // If the state has changed to hot, register to get the WM_NCMOUSELEAVE notification.
+ if (m_IsButtonHot) {
+ TRACKMOUSEEVENT tme;
+ tme.cbSize = sizeof(tme);
+ tme.dwFlags = TME_LEAVE | TME_NONCLIENT;
+ tme.hwndTrack = m_hWnd;
+ tme.dwHoverTime = HOVER_DEFAULT;
+ _TrackMouseEvent(&tme);
+ }
+ }
+
+ CEdit::OnNcMouseMove(nHitTest, point);
}
void CEditWithButton_Base::OnNcMouseLeave()
{
- CPoint point;
- GetCursorPos(&point);
-
- CRect rectWindow;
- GetWindowRect(rectWindow);
- CRect rectButton = GetButtonRect(rectWindow);
-
- // We may get this message either when the mouse actually leaves the client area
- // or when the user clicks the mouse on the button. So we must check whether or
- // not the cursor has actually left the button area. If so, then update the hot
- // state and prompt a redraw of the button.
- if (!rectButton.PtInRect(point))
- {
- m_IsButtonHot = false;
- SetWindowPos(NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
- }
-
- CEdit::OnNcMouseLeave();
+ CPoint point;
+ GetCursorPos(&point);
+
+ CRect rectWindow;
+ GetWindowRect(rectWindow);
+ CRect rectButton = GetButtonRect(rectWindow);
+
+ // We may get this message either when the mouse actually leaves the client area
+ // or when the user clicks the mouse on the button. So we must check whether or
+ // not the cursor has actually left the button area. If so, then update the hot
+ // state and prompt a redraw of the button.
+ if (!rectButton.PtInRect(point)) {
+ m_IsButtonHot = false;
+ SetWindowPos(NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
+ }
+
+ CEdit::OnNcMouseLeave();
}
void CEditWithButton_Base::OnLButtonUp(UINT nFlags, CPoint point)
{
- if (m_IsMouseActive)
- {
- ReleaseCapture();
+ if (m_IsMouseActive) {
+ ReleaseCapture();
- ClientToScreen(&point);
+ ClientToScreen(&point);
- CRect rectWindow;
- GetWindowRect(rectWindow);
- CRect rectButton = GetButtonRect(rectWindow);
+ CRect rectWindow;
+ GetWindowRect(rectWindow);
+ CRect rectButton = GetButtonRect(rectWindow);
- // Reset the button to a "normal" state.
- m_IsButtonHot = false;
- m_IsButtonPressed = false;
- m_IsMouseActive = false;
+ // Reset the button to a "normal" state.
+ m_IsButtonHot = false;
+ m_IsButtonPressed = false;
+ m_IsMouseActive = false;
- // Redraw the button to reflect the changes.
- SetWindowPos(NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
+ // Redraw the button to reflect the changes.
+ SetWindowPos(NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
- // Run the on-click logic if appropriate.
- if (rectButton.PtInRect(point))
- OnLeftClick();
- }
+ // Run the on-click logic if appropriate.
+ if (rectButton.PtInRect(point)) {
+ OnLeftClick();
+ }
+ }
- CEdit::OnLButtonUp(nFlags, point);
+ CEdit::OnLButtonUp(nFlags, point);
}
LRESULT CEditWithButton_Base::OnNcHitTest(CPoint point)
{
- CRect rectWindow;
- GetWindowRect(rectWindow);
- CRect rectButton = GetButtonRect(rectWindow);
+ CRect rectWindow;
+ GetWindowRect(rectWindow);
+ CRect rectButton = GetButtonRect(rectWindow);
- if (rectButton.PtInRect(point))
- return HTBORDER;
+ if (rectButton.PtInRect(point)) {
+ return HTBORDER;
+ }
- return CEdit::OnNcHitTest(point);
+ return CEdit::OnNcHitTest(point);
}
void CEditWithButton_Base::PreSubclassWindow()
{
- CEdit::PreSubclassWindow();
+ CEdit::PreSubclassWindow();
- // Because our WindowProc is not yet in place, we need to post a message
- PostMessage(WM_EDITWITHBUTTON_RECALCNCSIZE);
+ // Because our WindowProc is not yet in place, we need to post a message
+ PostMessage(WM_EDITWITHBUTTON_RECALCNCSIZE);
}
LRESULT CEditWithButton_Base::OnRecalcNcSize(WPARAM wParam, LPARAM lParam)
{
- // Prompt a WM_NCCALCSIZE to be issued
- SetWindowPos(NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
+ // Prompt a WM_NCCALCSIZE to be issued
+ SetWindowPos(NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
- return 0;
+ return 0;
}
void CEditWithButton_Base::OnEnable(BOOL bEnable)
{
- // Let all the default handling happen.
- CEdit::OnEnable(bEnable);
+ // Let all the default handling happen.
+ CEdit::OnEnable(bEnable);
- // Prompt the button area to redraw.
- SetWindowPos(NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
+ // Prompt the button area to redraw.
+ SetWindowPos(NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
}
LRESULT CEditWithButton_Base::OnSetReadOnly(WPARAM wParam, LPARAM lParam)
{
- // Let all the default handling happen.
- LRESULT r = DefWindowProc(EM_SETREADONLY, wParam, lParam);
+ // Let all the default handling happen.
+ LRESULT r = DefWindowProc(EM_SETREADONLY, wParam, lParam);
- // Prompt the button area to redraw.
- SetWindowPos(NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
+ // Prompt the button area to redraw.
+ SetWindowPos(NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
- return r;
+ return r;
}
void CEditWithButton_Base::OnLeftClick()
{
- PostMessage(EDIT_BUTTON_LEFTCLICKED);
+ PostMessage(EDIT_BUTTON_LEFTCLICKED);
}
@@ -313,51 +309,50 @@ void CEditWithButton_Base::OnLeftClick()
// CEditWithButton --------------------------------------------------------------------------------
CEditWithButton::CEditWithButton(LPCTSTR pszButtonText)
- : m_ButtonText(pszButtonText)
+ : m_ButtonText(pszButtonText)
{
}
CString CEditWithButton::GetButtonText() const
{
- return m_ButtonText;
+ return m_ButtonText;
}
void CEditWithButton::SetButtonText(LPCTSTR buttonText)
{
- m_ButtonText = buttonText;
+ m_ButtonText = buttonText;
- // If this is a live window, then prompt the button area to redraw.
- if (IsWindow(m_hWnd))
- SetWindowPos(NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
+ // If this is a live window, then prompt the button area to redraw.
+ if (IsWindow(m_hWnd)) {
+ SetWindowPos(NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
+ }
}
void CEditWithButton::DrawButtonContent(CDC& dc, CRect rectButton, HTHEME hButtonTheme)
{
- CFont* pOldFont = dc.SelectObject(GetFont());
-
- if (hButtonTheme)
- {
- DrawThemeText(hButtonTheme, dc.m_hDC, BP_PUSHBUTTON, GetButtonThemeState(),
- m_ButtonText, m_ButtonText.GetLength(),
- DT_CENTER | DT_VCENTER | DT_SINGLELINE, 0, rectButton);
- }
- else
- {
- if (GetStyle() & (ES_READONLY | WS_DISABLED))
- dc.SetTextColor(GetSysColor(COLOR_GRAYTEXT));
-
- dc.SetBkMode(TRANSPARENT);
- dc.DrawText(m_ButtonText, m_ButtonText.GetLength(),
- rectButton, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
- }
-
- dc.SelectObject(pOldFont);
+ CFont* pOldFont = dc.SelectObject(GetFont());
+
+ if (hButtonTheme) {
+ DrawThemeText(hButtonTheme, dc.m_hDC, BP_PUSHBUTTON, GetButtonThemeState(),
+ m_ButtonText, m_ButtonText.GetLength(),
+ DT_CENTER | DT_VCENTER | DT_SINGLELINE, 0, rectButton);
+ } else {
+ if (GetStyle() & (ES_READONLY | WS_DISABLED)) {
+ dc.SetTextColor(GetSysColor(COLOR_GRAYTEXT));
+ }
+
+ dc.SetBkMode(TRANSPARENT);
+ dc.DrawText(m_ButtonText, m_ButtonText.GetLength(),
+ rectButton, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
+ }
+
+ dc.SelectObject(pOldFont);
}
int CEditWithButton::CalculateButtonWidth()
{
- CWindowDC dc(this);
- return dc.GetTextExtent(' ' + m_ButtonText + ' ').cx;
- // Note: For readability, we need some space between the text and the side borders of the button.
- // A simple way to accomplish this is to pad the string with spaces when calculating the width.
+ CWindowDC dc(this);
+ return dc.GetTextExtent(' ' + m_ButtonText + ' ').cx;
+ // Note: For readability, we need some space between the text and the side borders of the button.
+ // A simple way to accomplish this is to pad the string with spaces when calculating the width.
}
diff --git a/src/mpc-hc/EditWithButton.h b/src/mpc-hc/EditWithButton.h
index 046db6fac..9ef99cbf6 100644
--- a/src/mpc-hc/EditWithButton.h
+++ b/src/mpc-hc/EditWithButton.h
@@ -1,19 +1,19 @@
/*
- Edit With Button
+ Edit With Button
- This class acts mostly like a normal Edit Box except that it provides a button to the right
- side of the control. Clicking the button invokes the virutal OnLeftClick method. If that
- has not been overridden in a derived classes then it sends the EDIT_BUTTON_LEFTCLICKED
- message to the parent window.
+ This class acts mostly like a normal Edit Box except that it provides a button to the right
+ side of the control. Clicking the button invokes the virutal OnLeftClick method. If that
+ has not been overridden in a derived classes then it sends the EDIT_BUTTON_LEFTCLICKED
+ message to the parent window.
- CEditWithButton_Base contains most of the code to make this work but cannot be instantiated
- itself. A derived class must override DrawButtonContent and CalculateButtonWidth to determine
- what is actually drawn for the button.
+ CEditWithButton_Base contains most of the code to make this work but cannot be instantiated
+ itself. A derived class must override DrawButtonContent and CalculateButtonWidth to determine
+ what is actually drawn for the button.
- CEditWithButton is a derived class that handles the simplest form of a button where a plain
- text string is displayed on the button.
+ CEditWithButton is a derived class that handles the simplest form of a button where a plain
+ text string is displayed on the button.
- Other classes could be derived to draw other kinds of buttons.
+ Other classes could be derived to draw other kinds of buttons.
*/
#pragma once
@@ -23,7 +23,7 @@
// May be sent to the parent window when the edit control's button is clicked.
// wParam will be set to the ID of the control that sent the message.
-#define EDIT_BUTTON_LEFTCLICKED (WM_APP + 842) // arbitrary number, change if necessary
+#define EDIT_BUTTON_LEFTCLICKED (WM_APP + 842) // arbitrary number, change if necessary
// CEditWithButton_Base ---------------------------------------------------------------------------
@@ -31,63 +31,63 @@
class CEditWithButton_Base : public CEdit
{
public:
- CEditWithButton_Base();
+ CEditWithButton_Base();
- // Called when a left click is detected. The default implementation will send a
- // EDIT_BUTTON_LEFTCLICKED message to the parent window. Derived classes
- // could override this to handle the event themselves, and so are not required
- // to call this base implementation.
- virtual void OnLeftClick();
+ // Called when a left click is detected. The default implementation will send a
+ // EDIT_BUTTON_LEFTCLICKED message to the parent window. Derived classes
+ // could override this to handle the event themselves, and so are not required
+ // to call this base implementation.
+ virtual void OnLeftClick();
protected:
- afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp);
- afx_msg void OnNcPaint();
- afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
- afx_msg void OnMouseMove(UINT nFlags, CPoint point);
- afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point);
- afx_msg void OnNcMouseLeave();
- afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
- afx_msg LRESULT OnNcHitTest(CPoint point);
- virtual void PreSubclassWindow();
- afx_msg LRESULT OnRecalcNcSize(WPARAM wParam, LPARAM lParam);
- afx_msg void OnEnable(BOOL bEnable);
- afx_msg LRESULT OnSetReadOnly(WPARAM wParam, LPARAM lParam);
- DECLARE_MESSAGE_MAP()
-
- // Given the rectangle of the control window, this returns the rect that the button will occupy.
- CRect GetButtonRect(const CRect& rectWindow) const;
-
- // Translates the current button state in a value that could be used by DrawThemeBackground.
- int GetButtonThemeState() const;
-
- // Called when the button needs to be drawn.
- // The default implementation draws the button frame, adjusts the rect if
- // the button is pressed, and then calls DrawButtonContent to render the
- // contents of the button.
- virtual void DrawButton(CRect rectButton);
-
- // Called when the button contents (anything inside the button's border) needs to
- // be drawn. The rect will have already been adjusted if the button is pressed.
- // The content must be drawn using the given device context within the given rect.
- virtual void DrawButtonContent(CDC& dc, CRect rectButton, HTHEME hButtonTheme) = 0;
-
- // Called when the button's width needs to be (re)calculated.
- // This must return the width in pixels.
- virtual int CalculateButtonWidth() = 0;
+ afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp);
+ afx_msg void OnNcPaint();
+ afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
+ afx_msg void OnMouseMove(UINT nFlags, CPoint point);
+ afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point);
+ afx_msg void OnNcMouseLeave();
+ afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
+ afx_msg LRESULT OnNcHitTest(CPoint point);
+ virtual void PreSubclassWindow();
+ afx_msg LRESULT OnRecalcNcSize(WPARAM wParam, LPARAM lParam);
+ afx_msg void OnEnable(BOOL bEnable);
+ afx_msg LRESULT OnSetReadOnly(WPARAM wParam, LPARAM lParam);
+ DECLARE_MESSAGE_MAP()
+
+ // Given the rectangle of the control window, this returns the rect that the button will occupy.
+ CRect GetButtonRect(const CRect& rectWindow) const;
+
+ // Translates the current button state in a value that could be used by DrawThemeBackground.
+ int GetButtonThemeState() const;
+
+ // Called when the button needs to be drawn.
+ // The default implementation draws the button frame, adjusts the rect if
+ // the button is pressed, and then calls DrawButtonContent to render the
+ // contents of the button.
+ virtual void DrawButton(CRect rectButton);
+
+ // Called when the button contents (anything inside the button's border) needs to
+ // be drawn. The rect will have already been adjusted if the button is pressed.
+ // The content must be drawn using the given device context within the given rect.
+ virtual void DrawButtonContent(CDC& dc, CRect rectButton, HTHEME hButtonTheme) = 0;
+
+ // Called when the button's width needs to be (re)calculated.
+ // This must return the width in pixels.
+ virtual int CalculateButtonWidth() = 0;
private:
- int m_TopBorder;
- int m_BottomBorder;
- int m_LeftBorder;
- int m_RightBorder;
+ int m_TopBorder;
+ int m_BottomBorder;
+ int m_LeftBorder;
+ int m_RightBorder;
- int m_ButtonWidth; // stores the button's width in pixels (so that we don't have to re-calculate it)
+ int m_ButtonWidth; // stores the button's width in pixels (so that we don't have to re-calculate it)
- bool m_IsButtonPressed;
- bool m_IsMouseActive;
+ bool m_IsButtonPressed;
+ bool m_IsMouseActive;
- bool m_IsButtonHot;
+ bool m_IsButtonHot;
};
@@ -96,18 +96,18 @@ private:
class CEditWithButton : public CEditWithButton_Base
{
public:
- // The given text will be displayed in the button.
- explicit CEditWithButton(LPCTSTR pszButtonText = _T("..."));
+ // The given text will be displayed in the button.
+ explicit CEditWithButton(LPCTSTR pszButtonText = _T("..."));
- // Gets/Sets the button text.
- CString GetButtonText() const;
- void SetButtonText(LPCTSTR buttonText);
+ // Gets/Sets the button text.
+ CString GetButtonText() const;
+ void SetButtonText(LPCTSTR buttonText);
private:
- virtual void DrawButtonContent(CDC& dc, CRect rectButton, HTHEME hButtonTheme);
+ virtual void DrawButtonContent(CDC& dc, CRect rectButton, HTHEME hButtonTheme);
- virtual int CalculateButtonWidth();
+ virtual int CalculateButtonWidth();
- CString m_ButtonText;
+ CString m_ButtonText;
};
diff --git a/src/mpc-hc/FGFilter.cpp b/src/mpc-hc/FGFilter.cpp
index 60285171a..9eb4056b5 100644
--- a/src/mpc-hc/FGFilter.cpp
+++ b/src/mpc-hc/FGFilter.cpp
@@ -37,56 +37,56 @@
//
CFGFilter::CFGFilter(const CLSID& clsid, CStringW name, UINT64 merit)
- : m_clsid(clsid)
- , m_name(name)
+ : m_clsid(clsid)
+ , m_name(name)
{
- m_merit.val = merit;
+ m_merit.val = merit;
}
const CAtlList<GUID>& CFGFilter::GetTypes() const
{
- return m_types;
+ return m_types;
}
void CFGFilter::SetTypes(const CAtlList<GUID>& types)
{
- m_types.RemoveAll();
- m_types.AddTailList(&types);
+ m_types.RemoveAll();
+ m_types.AddTailList(&types);
}
void CFGFilter::AddType(const GUID& majortype, const GUID& subtype)
{
- m_types.AddTail(majortype);
- m_types.AddTail(subtype);
+ m_types.AddTail(majortype);
+ m_types.AddTail(subtype);
}
bool CFGFilter::CheckTypes(const CAtlArray<GUID>& types, bool fExactMatch)
{
- POSITION pos = m_types.GetHeadPosition();
- while (pos) {
- const GUID& majortype = m_types.GetNext(pos);
- if (!pos) {
- ASSERT(0);
- break;
- }
- const GUID& subtype = m_types.GetNext(pos);
-
- for (int i = 0, len = types.GetCount() & ~1; i < len; i += 2) {
- if (fExactMatch) {
- if (majortype == types[i] && majortype != GUID_NULL
- && subtype == types[i+1] && subtype != GUID_NULL) {
- return true;
- }
- } else {
- if ((majortype == GUID_NULL || types[i] == GUID_NULL || majortype == types[i])
- && (subtype == GUID_NULL || types[i+1] == GUID_NULL || subtype == types[i+1])) {
- return true;
- }
- }
- }
- }
-
- return false;
+ POSITION pos = m_types.GetHeadPosition();
+ while (pos) {
+ const GUID& majortype = m_types.GetNext(pos);
+ if (!pos) {
+ ASSERT(0);
+ break;
+ }
+ const GUID& subtype = m_types.GetNext(pos);
+
+ for (int i = 0, len = types.GetCount() & ~1; i < len; i += 2) {
+ if (fExactMatch) {
+ if (majortype == types[i] && majortype != GUID_NULL
+ && subtype == types[i + 1] && subtype != GUID_NULL) {
+ return true;
+ }
+ } else {
+ if ((majortype == GUID_NULL || types[i] == GUID_NULL || majortype == types[i])
+ && (subtype == GUID_NULL || types[i + 1] == GUID_NULL || subtype == types[i + 1])) {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
}
//
@@ -94,309 +94,309 @@ bool CFGFilter::CheckTypes(const CAtlArray<GUID>& types, bool fExactMatch)
//
CFGFilterRegistry::CFGFilterRegistry(IMoniker* pMoniker, UINT64 merit)
- : CFGFilter(GUID_NULL, L"", merit)
- , m_pMoniker(pMoniker)
+ : CFGFilter(GUID_NULL, L"", merit)
+ , m_pMoniker(pMoniker)
{
- if (!m_pMoniker) {
- return;
- }
-
- LPOLESTR str = NULL;
- if (FAILED(m_pMoniker->GetDisplayName(0, 0, &str))) {
- return;
- }
- m_DisplayName = m_name = str;
- CoTaskMemFree(str), str = NULL;
-
- QueryProperties();
-
- if (merit != MERIT64_DO_USE) {
- m_merit.val = merit;
- }
+ if (!m_pMoniker) {
+ return;
+ }
+
+ LPOLESTR str = NULL;
+ if (FAILED(m_pMoniker->GetDisplayName(0, 0, &str))) {
+ return;
+ }
+ m_DisplayName = m_name = str;
+ CoTaskMemFree(str), str = NULL;
+
+ QueryProperties();
+
+ if (merit != MERIT64_DO_USE) {
+ m_merit.val = merit;
+ }
}
CFGFilterRegistry::CFGFilterRegistry(CStringW DisplayName, UINT64 merit)
- : CFGFilter(GUID_NULL, L"", merit)
- , m_DisplayName(DisplayName)
+ : CFGFilter(GUID_NULL, L"", merit)
+ , m_DisplayName(DisplayName)
{
- if (m_DisplayName.IsEmpty()) {
- return;
- }
+ if (m_DisplayName.IsEmpty()) {
+ return;
+ }
- CComPtr<IBindCtx> pBC;
- CreateBindCtx(0, &pBC);
+ CComPtr<IBindCtx> pBC;
+ CreateBindCtx(0, &pBC);
- ULONG chEaten;
- if (S_OK != MkParseDisplayName(pBC, CComBSTR(m_DisplayName), &chEaten, &m_pMoniker)) {
- return;
- }
+ ULONG chEaten;
+ if (S_OK != MkParseDisplayName(pBC, CComBSTR(m_DisplayName), &chEaten, &m_pMoniker)) {
+ return;
+ }
- QueryProperties();
+ QueryProperties();
- if (merit != MERIT64_DO_USE) {
- m_merit.val = merit;
- }
+ if (merit != MERIT64_DO_USE) {
+ m_merit.val = merit;
+ }
}
void CFGFilterRegistry::QueryProperties()
{
- ASSERT(m_pMoniker);
- CComPtr<IPropertyBag> pPB;
- if (SUCCEEDED(m_pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB))) {
- CComVariant var;
- if (SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
- m_name = var.bstrVal;
- var.Clear();
- }
-
- if (SUCCEEDED(pPB->Read(CComBSTR(_T("CLSID")), &var, NULL))) {
- CLSIDFromString(var.bstrVal, &m_clsid);
- var.Clear();
- }
-
- if (SUCCEEDED(pPB->Read(CComBSTR(_T("FilterData")), &var, NULL))) {
- BSTR* pstr;
- if (SUCCEEDED(SafeArrayAccessData(var.parray, (void**)&pstr))) {
- ExtractFilterData((BYTE*)pstr, var.parray->cbElements*(var.parray->rgsabound[0].cElements));
- SafeArrayUnaccessData(var.parray);
- }
-
- var.Clear();
- }
- }
+ ASSERT(m_pMoniker);
+ CComPtr<IPropertyBag> pPB;
+ if (SUCCEEDED(m_pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB))) {
+ CComVariant var;
+ if (SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
+ m_name = var.bstrVal;
+ var.Clear();
+ }
+
+ if (SUCCEEDED(pPB->Read(CComBSTR(_T("CLSID")), &var, NULL))) {
+ CLSIDFromString(var.bstrVal, &m_clsid);
+ var.Clear();
+ }
+
+ if (SUCCEEDED(pPB->Read(CComBSTR(_T("FilterData")), &var, NULL))) {
+ BSTR* pstr;
+ if (SUCCEEDED(SafeArrayAccessData(var.parray, (void**)&pstr))) {
+ ExtractFilterData((BYTE*)pstr, var.parray->cbElements * (var.parray->rgsabound[0].cElements));
+ SafeArrayUnaccessData(var.parray);
+ }
+
+ var.Clear();
+ }
+ }
}
CFGFilterRegistry::CFGFilterRegistry(const CLSID& clsid, UINT64 merit)
- : CFGFilter(clsid, L"", merit)
+ : CFGFilter(clsid, L"", merit)
{
- if (m_clsid == GUID_NULL) {
- return;
- }
-
- CString guid = CStringFromGUID(m_clsid);
-
- CRegKey key;
-
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("CLSID\\") + guid, KEY_READ)) {
- ULONG nChars = 0;
- if (ERROR_SUCCESS == key.QueryStringValue(NULL, NULL, &nChars)) {
- CString name;
- if (ERROR_SUCCESS == key.QueryStringValue(NULL, name.GetBuffer(nChars), &nChars)) {
- name.ReleaseBuffer(nChars);
- m_name = name;
- }
- }
-
- key.Close();
- }
-
- CRegKey catkey;
-
- if (ERROR_SUCCESS == catkey.Open(HKEY_CLASSES_ROOT, _T("CLSID\\{083863F1-70DE-11d0-BD40-00A0C911CE86}\\Instance"), KEY_READ)) {
- if (ERROR_SUCCESS != key.Open(catkey, guid, KEY_READ)) {
- // illiminable pack uses the name of the filter and not the clsid, have to enum all keys to find it...
-
- FILETIME ft;
- TCHAR buff[256];
- DWORD len = _countof(buff);
- for (DWORD i = 0; ERROR_SUCCESS == catkey.EnumKey(i, buff, &len, &ft); i++, len = _countof(buff)) {
- if (ERROR_SUCCESS == key.Open(catkey, buff, KEY_READ)) {
- TCHAR clsid[256];
- len = _countof(clsid);
- if (ERROR_SUCCESS == key.QueryStringValue(_T("CLSID"), clsid, &len) && GUIDFromCString(clsid) == m_clsid) {
- break;
- }
-
- key.Close();
- }
- }
- }
-
- if (key) {
- ULONG nChars = 0;
- if (ERROR_SUCCESS == key.QueryStringValue(_T("FriendlyName"), NULL, &nChars)) {
- CString name;
- if (ERROR_SUCCESS == key.QueryStringValue(_T("FriendlyName"), name.GetBuffer(nChars), &nChars)) {
- name.ReleaseBuffer(nChars);
- m_name = name;
- }
- }
-
- ULONG nBytes = 0;
- if (ERROR_SUCCESS == key.QueryBinaryValue(_T("FilterData"), NULL, &nBytes)) {
- CAutoVectorPtr<BYTE> buff;
- if (buff.Allocate(nBytes) && ERROR_SUCCESS == key.QueryBinaryValue(_T("FilterData"), buff, &nBytes)) {
- ExtractFilterData(buff, nBytes);
- }
- }
-
- key.Close();
- }
- }
-
- if (merit != MERIT64_DO_USE) {
- m_merit.val = merit;
- }
+ if (m_clsid == GUID_NULL) {
+ return;
+ }
+
+ CString guid = CStringFromGUID(m_clsid);
+
+ CRegKey key;
+
+ if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("CLSID\\") + guid, KEY_READ)) {
+ ULONG nChars = 0;
+ if (ERROR_SUCCESS == key.QueryStringValue(NULL, NULL, &nChars)) {
+ CString name;
+ if (ERROR_SUCCESS == key.QueryStringValue(NULL, name.GetBuffer(nChars), &nChars)) {
+ name.ReleaseBuffer(nChars);
+ m_name = name;
+ }
+ }
+
+ key.Close();
+ }
+
+ CRegKey catkey;
+
+ if (ERROR_SUCCESS == catkey.Open(HKEY_CLASSES_ROOT, _T("CLSID\\{083863F1-70DE-11d0-BD40-00A0C911CE86}\\Instance"), KEY_READ)) {
+ if (ERROR_SUCCESS != key.Open(catkey, guid, KEY_READ)) {
+ // illiminable pack uses the name of the filter and not the clsid, have to enum all keys to find it...
+
+ FILETIME ft;
+ TCHAR buff[256];
+ DWORD len = _countof(buff);
+ for (DWORD i = 0; ERROR_SUCCESS == catkey.EnumKey(i, buff, &len, &ft); i++, len = _countof(buff)) {
+ if (ERROR_SUCCESS == key.Open(catkey, buff, KEY_READ)) {
+ TCHAR clsid[256];
+ len = _countof(clsid);
+ if (ERROR_SUCCESS == key.QueryStringValue(_T("CLSID"), clsid, &len) && GUIDFromCString(clsid) == m_clsid) {
+ break;
+ }
+
+ key.Close();
+ }
+ }
+ }
+
+ if (key) {
+ ULONG nChars = 0;
+ if (ERROR_SUCCESS == key.QueryStringValue(_T("FriendlyName"), NULL, &nChars)) {
+ CString name;
+ if (ERROR_SUCCESS == key.QueryStringValue(_T("FriendlyName"), name.GetBuffer(nChars), &nChars)) {
+ name.ReleaseBuffer(nChars);
+ m_name = name;
+ }
+ }
+
+ ULONG nBytes = 0;
+ if (ERROR_SUCCESS == key.QueryBinaryValue(_T("FilterData"), NULL, &nBytes)) {
+ CAutoVectorPtr<BYTE> buff;
+ if (buff.Allocate(nBytes) && ERROR_SUCCESS == key.QueryBinaryValue(_T("FilterData"), buff, &nBytes)) {
+ ExtractFilterData(buff, nBytes);
+ }
+ }
+
+ key.Close();
+ }
+ }
+
+ if (merit != MERIT64_DO_USE) {
+ m_merit.val = merit;
+ }
}
HRESULT CFGFilterRegistry::Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
{
- CheckPointer(ppBF, E_POINTER);
+ CheckPointer(ppBF, E_POINTER);
- HRESULT hr = E_FAIL;
+ HRESULT hr = E_FAIL;
- if (m_pMoniker) {
- if (SUCCEEDED(hr = m_pMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)ppBF))) {
- m_clsid = ::GetCLSID(*ppBF);
- }
- } else if (m_clsid != GUID_NULL) {
- CComQIPtr<IBaseFilter> pBF;
+ if (m_pMoniker) {
+ if (SUCCEEDED(hr = m_pMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)ppBF))) {
+ m_clsid = ::GetCLSID(*ppBF);
+ }
+ } else if (m_clsid != GUID_NULL) {
+ CComQIPtr<IBaseFilter> pBF;
- if (FAILED(pBF.CoCreateInstance(m_clsid))) {
- return E_FAIL;
- }
+ if (FAILED(pBF.CoCreateInstance(m_clsid))) {
+ return E_FAIL;
+ }
- *ppBF = pBF.Detach();
+ *ppBF = pBF.Detach();
- hr = S_OK;
- }
+ hr = S_OK;
+ }
- return hr;
+ return hr;
};
interface __declspec(uuid("97f7c4d4-547b-4a5f-8332-536430ad2e4d"))
IAMFilterData :
public IUnknown {
- STDMETHOD (ParseFilterData) (BYTE* rgbFilterData, ULONG cb, BYTE** prgbRegFilter2) PURE;
- STDMETHOD (CreateFilterData) (REGFILTER2* prf2, BYTE** prgbFilterData, ULONG* pcb) PURE;
+ STDMETHOD(ParseFilterData)(BYTE * rgbFilterData, ULONG cb, BYTE** prgbRegFilter2) PURE;
+ STDMETHOD(CreateFilterData)(REGFILTER2 * prf2, BYTE** prgbFilterData, ULONG * pcb) PURE;
};
void CFGFilterRegistry::ExtractFilterData(BYTE* p, UINT len)
{
- CComPtr<IAMFilterData> pFD;
- BYTE* ptr = NULL;
-
- if (SUCCEEDED(pFD.CoCreateInstance(CLSID_FilterMapper2))
- && SUCCEEDED(pFD->ParseFilterData(p, len, (BYTE**)&ptr))) {
- REGFILTER2* prf = (REGFILTER2*)*(WPARAM*)ptr; // this is f*cked up
-
- m_merit.mid = prf->dwMerit;
-
- if (prf->dwVersion == 1) {
- for (UINT i = 0; i < prf->cPins; i++) {
- if (prf->rgPins[i].bOutput) {
- continue;
- }
-
- for (UINT j = 0; j < prf->rgPins[i].nMediaTypes; j++) {
- if (!prf->rgPins[i].lpMediaType[j].clsMajorType || !prf->rgPins[i].lpMediaType[j].clsMinorType) {
- break;
- }
-
- const REGPINTYPES& rpt = prf->rgPins[i].lpMediaType[j];
- AddType(*rpt.clsMajorType, *rpt.clsMinorType);
- }
- }
- } else if (prf->dwVersion == 2) {
- for (UINT i = 0; i < prf->cPins2; i++) {
- if (prf->rgPins2[i].dwFlags&REG_PINFLAG_B_OUTPUT) {
- continue;
- }
-
- for (UINT j = 0; j < prf->rgPins2[i].nMediaTypes; j++) {
- if (!prf->rgPins2[i].lpMediaType[j].clsMajorType || !prf->rgPins2[i].lpMediaType[j].clsMinorType) {
- break;
- }
-
- const REGPINTYPES& rpt = prf->rgPins2[i].lpMediaType[j];
- AddType(*rpt.clsMajorType, *rpt.clsMinorType);
- }
- }
- }
-
- CoTaskMemFree(prf);
- } else {
- BYTE* base = p;
+ CComPtr<IAMFilterData> pFD;
+ BYTE* ptr = NULL;
+
+ if (SUCCEEDED(pFD.CoCreateInstance(CLSID_FilterMapper2))
+ && SUCCEEDED(pFD->ParseFilterData(p, len, (BYTE**)&ptr))) {
+ REGFILTER2* prf = (REGFILTER2*) * (WPARAM*)ptr; // this is f*cked up
+
+ m_merit.mid = prf->dwMerit;
+
+ if (prf->dwVersion == 1) {
+ for (UINT i = 0; i < prf->cPins; i++) {
+ if (prf->rgPins[i].bOutput) {
+ continue;
+ }
+
+ for (UINT j = 0; j < prf->rgPins[i].nMediaTypes; j++) {
+ if (!prf->rgPins[i].lpMediaType[j].clsMajorType || !prf->rgPins[i].lpMediaType[j].clsMinorType) {
+ break;
+ }
+
+ const REGPINTYPES& rpt = prf->rgPins[i].lpMediaType[j];
+ AddType(*rpt.clsMajorType, *rpt.clsMinorType);
+ }
+ }
+ } else if (prf->dwVersion == 2) {
+ for (UINT i = 0; i < prf->cPins2; i++) {
+ if (prf->rgPins2[i].dwFlags & REG_PINFLAG_B_OUTPUT) {
+ continue;
+ }
+
+ for (UINT j = 0; j < prf->rgPins2[i].nMediaTypes; j++) {
+ if (!prf->rgPins2[i].lpMediaType[j].clsMajorType || !prf->rgPins2[i].lpMediaType[j].clsMinorType) {
+ break;
+ }
+
+ const REGPINTYPES& rpt = prf->rgPins2[i].lpMediaType[j];
+ AddType(*rpt.clsMajorType, *rpt.clsMinorType);
+ }
+ }
+ }
+
+ CoTaskMemFree(prf);
+ } else {
+ BYTE* base = p;
#define ChkLen(size) if (p - base + size > (int)len) return;
- ChkLen(4)
- if (*(DWORD*)p != 0x00000002) {
- return; // only version 2 supported, no samples found for 1
- }
- p += 4;
-
- ChkLen(4)
- m_merit.mid = *(DWORD*)p;
- p += 4;
-
- m_types.RemoveAll();
-
- ChkLen(8)
- DWORD nPins = *(DWORD*)p;
- p += 8;
- while (nPins-- > 0) {
- ChkLen(1)
- BYTE n = *p-0x30;
- p++;
- UNREFERENCED_PARAMETER(n);
-
- ChkLen(2)
- WORD pi = *(WORD*)p;
- p += 2;
- ASSERT(pi == 'ip');
- UNREFERENCED_PARAMETER(pi);
-
- ChkLen(1)
- BYTE x33 = *p;
- p++;
- ASSERT(x33 == 0x33);
- UNREFERENCED_PARAMETER(x33);
-
- ChkLen(8)
- bool fOutput = !!(*p&REG_PINFLAG_B_OUTPUT);
- p += 8;
-
- ChkLen(12)
- DWORD nTypes = *(DWORD*)p;
- p += 12;
- while (nTypes-- > 0) {
- ChkLen(1)
- BYTE n = *p-0x30;
- p++;
- UNREFERENCED_PARAMETER(n);
-
- ChkLen(2)
- WORD ty = *(WORD*)p;
- p += 2;
- ASSERT(ty == 'yt');
- UNREFERENCED_PARAMETER(ty);
-
- ChkLen(5)
- BYTE x33 = *p;
- p++;
- ASSERT(x33 == 0x33);
- UNREFERENCED_PARAMETER(x33);
- p += 4;
-
- ChkLen(8)
- if (*(DWORD*)p < (DWORD)(p-base+8) || *(DWORD*)p >= len
- || *(DWORD*)(p+4) < (DWORD)(p-base+8) || *(DWORD*)(p+4) >= len) {
- p += 8;
- continue;
- }
-
- GUID majortype, subtype;
- memcpy(&majortype, &base[*(DWORD*)p], sizeof(GUID));
- p += 4;
- if (!fOutput) {
- AddType(majortype, subtype);
- }
- }
- }
+ ChkLen(4)
+ if (*(DWORD*)p != 0x00000002) {
+ return; // only version 2 supported, no samples found for 1
+ }
+ p += 4;
+
+ ChkLen(4)
+ m_merit.mid = *(DWORD*)p;
+ p += 4;
+
+ m_types.RemoveAll();
+
+ ChkLen(8)
+ DWORD nPins = *(DWORD*)p;
+ p += 8;
+ while (nPins-- > 0) {
+ ChkLen(1)
+ BYTE n = *p - 0x30;
+ p++;
+ UNREFERENCED_PARAMETER(n);
+
+ ChkLen(2)
+ WORD pi = *(WORD*)p;
+ p += 2;
+ ASSERT(pi == 'ip');
+ UNREFERENCED_PARAMETER(pi);
+
+ ChkLen(1)
+ BYTE x33 = *p;
+ p++;
+ ASSERT(x33 == 0x33);
+ UNREFERENCED_PARAMETER(x33);
+
+ ChkLen(8)
+ bool fOutput = !!(*p & REG_PINFLAG_B_OUTPUT);
+ p += 8;
+
+ ChkLen(12)
+ DWORD nTypes = *(DWORD*)p;
+ p += 12;
+ while (nTypes-- > 0) {
+ ChkLen(1)
+ BYTE n = *p - 0x30;
+ p++;
+ UNREFERENCED_PARAMETER(n);
+
+ ChkLen(2)
+ WORD ty = *(WORD*)p;
+ p += 2;
+ ASSERT(ty == 'yt');
+ UNREFERENCED_PARAMETER(ty);
+
+ ChkLen(5)
+ BYTE x33 = *p;
+ p++;
+ ASSERT(x33 == 0x33);
+ UNREFERENCED_PARAMETER(x33);
+ p += 4;
+
+ ChkLen(8)
+ if (*(DWORD*)p < (DWORD)(p - base + 8) || *(DWORD*)p >= len
+ || *(DWORD*)(p + 4) < (DWORD)(p - base + 8) || *(DWORD*)(p + 4) >= len) {
+ p += 8;
+ continue;
+ }
+
+ GUID majortype, subtype;
+ memcpy(&majortype, &base[*(DWORD*)p], sizeof(GUID));
+ p += 4;
+ if (!fOutput) {
+ AddType(majortype, subtype);
+ }
+ }
+ }
#undef ChkLen
- }
+ }
}
//
@@ -404,17 +404,17 @@ void CFGFilterRegistry::ExtractFilterData(BYTE* p, UINT len)
//
CFGFilterFile::CFGFilterFile(const CLSID& clsid, CString path, CStringW name, UINT64 merit)
- : CFGFilter(clsid, name, merit)
- , m_path(path)
- , m_hInst(NULL)
+ : CFGFilter(clsid, name, merit)
+ , m_path(path)
+ , m_hInst(NULL)
{
}
HRESULT CFGFilterFile::Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
{
- CheckPointer(ppBF, E_POINTER);
+ CheckPointer(ppBF, E_POINTER);
- return LoadExternalFilter(m_path, m_clsid, ppBF);
+ return LoadExternalFilter(m_path, m_clsid, ppBF);
}
//
@@ -422,63 +422,63 @@ HRESULT CFGFilterFile::Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_
//
CFGFilterVideoRenderer::CFGFilterVideoRenderer(HWND hWnd, const CLSID& clsid, CStringW name, UINT64 merit)
- : CFGFilter(clsid, name, merit)
- , m_hWnd(hWnd)
+ : CFGFilter(clsid, name, merit)
+ , m_hWnd(hWnd)
{
- AddType(MEDIATYPE_Video, MEDIASUBTYPE_NULL);
+ AddType(MEDIATYPE_Video, MEDIASUBTYPE_NULL);
}
HRESULT CFGFilterVideoRenderer::Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
{
- TRACE("--> CFGFilterVideoRenderer::Create on thread: %d\n", GetCurrentThreadId());
- CheckPointer(ppBF, E_POINTER);
-
- HRESULT hr = S_OK;
-
- CComPtr<ISubPicAllocatorPresenter> pCAP;
-
- if (m_clsid == CLSID_VMR7AllocatorPresenter
- || m_clsid == CLSID_VMR9AllocatorPresenter
- || m_clsid == CLSID_DXRAllocatorPresenter
- || m_clsid == CLSID_madVRAllocatorPresenter
- || m_clsid == CLSID_EVRAllocatorPresenter
- || m_clsid == CLSID_SyncAllocatorPresenter) {
- bool bFullscreen = (AfxGetApp()->m_pMainWnd != NULL) && (((CMainFrame*)AfxGetApp()->m_pMainWnd)->IsD3DFullScreenMode());
- if (SUCCEEDED(CreateAP7(m_clsid, m_hWnd, &pCAP))
- || SUCCEEDED(CreateAP9(m_clsid, m_hWnd, bFullscreen, &pCAP))
- || SUCCEEDED(CreateEVR(m_clsid, m_hWnd, bFullscreen, &pCAP))
- || SUCCEEDED(CreateSyncRenderer(m_clsid, m_hWnd, bFullscreen, &pCAP))) {
- CComPtr<IUnknown> pRenderer;
- if (SUCCEEDED(hr = pCAP->CreateRenderer(&pRenderer))) {
- *ppBF = CComQIPtr<IBaseFilter>(pRenderer).Detach();
- pUnks.AddTail(pCAP);
- }
- }
- } else {
- CComPtr<IBaseFilter> pBF;
- if (SUCCEEDED(pBF.CoCreateInstance(m_clsid))) {
- if (m_clsid == CLSID_EnhancedVideoRenderer) {
- CComQIPtr<IEVRFilterConfig> pConfig = pBF;
- pConfig->SetNumberOfStreams(3);
- }
-
- BeginEnumPins(pBF, pEP, pPin) {
- if (CComQIPtr<IMixerPinConfig, &IID_IMixerPinConfig> pMPC = pPin) {
- pUnks.AddTail(pMPC);
- break;
- }
- }
- EndEnumPins;
-
- *ppBF = pBF.Detach();
- }
- }
-
- if (!*ppBF) {
- hr = E_FAIL;
- }
-
- return hr;
+ TRACE("--> CFGFilterVideoRenderer::Create on thread: %d\n", GetCurrentThreadId());
+ CheckPointer(ppBF, E_POINTER);
+
+ HRESULT hr = S_OK;
+
+ CComPtr<ISubPicAllocatorPresenter> pCAP;
+
+ if (m_clsid == CLSID_VMR7AllocatorPresenter
+ || m_clsid == CLSID_VMR9AllocatorPresenter
+ || m_clsid == CLSID_DXRAllocatorPresenter
+ || m_clsid == CLSID_madVRAllocatorPresenter
+ || m_clsid == CLSID_EVRAllocatorPresenter
+ || m_clsid == CLSID_SyncAllocatorPresenter) {
+ bool bFullscreen = (AfxGetApp()->m_pMainWnd != NULL) && (((CMainFrame*)AfxGetApp()->m_pMainWnd)->IsD3DFullScreenMode());
+ if (SUCCEEDED(CreateAP7(m_clsid, m_hWnd, &pCAP))
+ || SUCCEEDED(CreateAP9(m_clsid, m_hWnd, bFullscreen, &pCAP))
+ || SUCCEEDED(CreateEVR(m_clsid, m_hWnd, bFullscreen, &pCAP))
+ || SUCCEEDED(CreateSyncRenderer(m_clsid, m_hWnd, bFullscreen, &pCAP))) {
+ CComPtr<IUnknown> pRenderer;
+ if (SUCCEEDED(hr = pCAP->CreateRenderer(&pRenderer))) {
+ *ppBF = CComQIPtr<IBaseFilter>(pRenderer).Detach();
+ pUnks.AddTail(pCAP);
+ }
+ }
+ } else {
+ CComPtr<IBaseFilter> pBF;
+ if (SUCCEEDED(pBF.CoCreateInstance(m_clsid))) {
+ if (m_clsid == CLSID_EnhancedVideoRenderer) {
+ CComQIPtr<IEVRFilterConfig> pConfig = pBF;
+ pConfig->SetNumberOfStreams(3);
+ }
+
+ BeginEnumPins(pBF, pEP, pPin) {
+ if (CComQIPtr<IMixerPinConfig, &IID_IMixerPinConfig> pMPC = pPin) {
+ pUnks.AddTail(pMPC);
+ break;
+ }
+ }
+ EndEnumPins;
+
+ *ppBF = pBF.Detach();
+ }
+ }
+
+ if (!*ppBF) {
+ hr = E_FAIL;
+ }
+
+ return hr;
}
//
@@ -491,150 +491,150 @@ CFGFilterList::CFGFilterList()
CFGFilterList::~CFGFilterList()
{
- RemoveAll();
+ RemoveAll();
}
void CFGFilterList::RemoveAll()
{
- while (!m_filters.IsEmpty()) {
- const filter_t& f = m_filters.RemoveHead();
- if (f.autodelete) {
- delete f.pFGF;
- }
- }
-
- m_sortedfilters.RemoveAll();
+ while (!m_filters.IsEmpty()) {
+ const filter_t& f = m_filters.RemoveHead();
+ if (f.autodelete) {
+ delete f.pFGF;
+ }
+ }
+
+ m_sortedfilters.RemoveAll();
}
void CFGFilterList::Insert(CFGFilter* pFGF, int group, bool exactmatch, bool autodelete)
{
- if (CFGFilterRegistry* f1r = dynamic_cast<CFGFilterRegistry*>(pFGF)) {
- POSITION pos = m_filters.GetHeadPosition();
- while (pos) {
- filter_t& f2 = m_filters.GetNext(pos);
-
- if (group != f2.group) {
- continue;
- }
-
- if (CFGFilterRegistry* f2r = dynamic_cast<CFGFilterRegistry*>(f2.pFGF)) {
- if (f1r->GetMoniker() && f2r->GetMoniker() && S_OK == f1r->GetMoniker()->IsEqual(f2r->GetMoniker())
- || f1r->GetCLSID() != GUID_NULL && f1r->GetCLSID() == f2r->GetCLSID()) {
- TRACE(_T("FGM: Inserting %d %d %016I64x '%s' NOT!\n"),
- group, exactmatch, pFGF->GetMerit(),
- pFGF->GetName().IsEmpty() ? CStringFromGUID(pFGF->GetCLSID()) : CString(pFGF->GetName()));
-
- if (autodelete) {
- delete pFGF;
- }
- return;
- }
- }
- }
- }
-
- POSITION pos = m_filters.GetHeadPosition();
- while (pos) {
- if (m_filters.GetNext(pos).pFGF == pFGF) {
- TRACE(_T("FGM: Inserting %d %d %016I64x '%s' DUP!\n"),
- group, exactmatch, pFGF->GetMerit(),
- pFGF->GetName().IsEmpty() ? CStringFromGUID(pFGF->GetCLSID()) : CString(pFGF->GetName()));
-
- if (autodelete) {
- delete pFGF;
- }
- return;
- }
- }
-
- TRACE(_T("FGM: Inserting %d %d %016I64x '%s'\n"),
- group, exactmatch, pFGF->GetMerit(),
- pFGF->GetName().IsEmpty() ? CStringFromGUID(pFGF->GetCLSID()) : CString(pFGF->GetName()));
-
- filter_t f = {m_filters.GetCount(), pFGF, group, exactmatch, autodelete};
- m_filters.AddTail(f);
-
- m_sortedfilters.RemoveAll();
+ if (CFGFilterRegistry* f1r = dynamic_cast<CFGFilterRegistry*>(pFGF)) {
+ POSITION pos = m_filters.GetHeadPosition();
+ while (pos) {
+ filter_t& f2 = m_filters.GetNext(pos);
+
+ if (group != f2.group) {
+ continue;
+ }
+
+ if (CFGFilterRegistry* f2r = dynamic_cast<CFGFilterRegistry*>(f2.pFGF)) {
+ if (f1r->GetMoniker() && f2r->GetMoniker() && S_OK == f1r->GetMoniker()->IsEqual(f2r->GetMoniker())
+ || f1r->GetCLSID() != GUID_NULL && f1r->GetCLSID() == f2r->GetCLSID()) {
+ TRACE(_T("FGM: Inserting %d %d %016I64x '%s' NOT!\n"),
+ group, exactmatch, pFGF->GetMerit(),
+ pFGF->GetName().IsEmpty() ? CStringFromGUID(pFGF->GetCLSID()) : CString(pFGF->GetName()));
+
+ if (autodelete) {
+ delete pFGF;
+ }
+ return;
+ }
+ }
+ }
+ }
+
+ POSITION pos = m_filters.GetHeadPosition();
+ while (pos) {
+ if (m_filters.GetNext(pos).pFGF == pFGF) {
+ TRACE(_T("FGM: Inserting %d %d %016I64x '%s' DUP!\n"),
+ group, exactmatch, pFGF->GetMerit(),
+ pFGF->GetName().IsEmpty() ? CStringFromGUID(pFGF->GetCLSID()) : CString(pFGF->GetName()));
+
+ if (autodelete) {
+ delete pFGF;
+ }
+ return;
+ }
+ }
+
+ TRACE(_T("FGM: Inserting %d %d %016I64x '%s'\n"),
+ group, exactmatch, pFGF->GetMerit(),
+ pFGF->GetName().IsEmpty() ? CStringFromGUID(pFGF->GetCLSID()) : CString(pFGF->GetName()));
+
+ filter_t f = {m_filters.GetCount(), pFGF, group, exactmatch, autodelete};
+ m_filters.AddTail(f);
+
+ m_sortedfilters.RemoveAll();
}
POSITION CFGFilterList::GetHeadPosition()
{
- if (m_sortedfilters.IsEmpty()) {
- CAtlArray<filter_t> sort;
- sort.SetCount(m_filters.GetCount());
- POSITION pos = m_filters.GetHeadPosition();
- for (int i = 0; pos; i++) {
- sort[i] = m_filters.GetNext(pos);
- }
- qsort(&sort[0], sort.GetCount(), sizeof(sort[0]), filter_cmp);
- for (size_t i = 0; i < sort.GetCount(); i++)
- if (sort[i].pFGF->GetMerit() >= MERIT64_DO_USE) {
- m_sortedfilters.AddTail(sort[i].pFGF);
- }
- }
+ if (m_sortedfilters.IsEmpty()) {
+ CAtlArray<filter_t> sort;
+ sort.SetCount(m_filters.GetCount());
+ POSITION pos = m_filters.GetHeadPosition();
+ for (int i = 0; pos; i++) {
+ sort[i] = m_filters.GetNext(pos);
+ }
+ qsort(&sort[0], sort.GetCount(), sizeof(sort[0]), filter_cmp);
+ for (size_t i = 0; i < sort.GetCount(); i++)
+ if (sort[i].pFGF->GetMerit() >= MERIT64_DO_USE) {
+ m_sortedfilters.AddTail(sort[i].pFGF);
+ }
+ }
#ifdef _DEBUG
- TRACE(_T("FGM: Sorting filters\n"));
+ TRACE(_T("FGM: Sorting filters\n"));
- POSITION pos = m_sortedfilters.GetHeadPosition();
- while (pos) {
- CFGFilter* pFGF = m_sortedfilters.GetNext(pos);
- TRACE(_T("FGM: - %016I64x '%s'\n"), pFGF->GetMerit(), pFGF->GetName().IsEmpty() ? CStringFromGUID(pFGF->GetCLSID()) : CString(pFGF->GetName()));
- }
+ POSITION pos = m_sortedfilters.GetHeadPosition();
+ while (pos) {
+ CFGFilter* pFGF = m_sortedfilters.GetNext(pos);
+ TRACE(_T("FGM: - %016I64x '%s'\n"), pFGF->GetMerit(), pFGF->GetName().IsEmpty() ? CStringFromGUID(pFGF->GetCLSID()) : CString(pFGF->GetName()));
+ }
#endif
- return m_sortedfilters.GetHeadPosition();
+ return m_sortedfilters.GetHeadPosition();
}
CFGFilter* CFGFilterList::GetNext(POSITION& pos)
{
- return m_sortedfilters.GetNext(pos);
+ return m_sortedfilters.GetNext(pos);
}
int CFGFilterList::filter_cmp(const void* a, const void* b)
{
- filter_t* fa = (filter_t*)a;
- filter_t* fb = (filter_t*)b;
-
- if (fa->group < fb->group) {
- return -1;
- }
- if (fa->group > fb->group) {
- return +1;
- }
-
- if (fa->pFGF->GetCLSID() == fb->pFGF->GetCLSID()) {
- CFGFilterFile* fgfa = dynamic_cast<CFGFilterFile*>(fa->pFGF);
- CFGFilterFile* fgfb = dynamic_cast<CFGFilterFile*>(fb->pFGF);
-
- if (fgfa && !fgfb) {
- return -1;
- }
- if (!fgfa && fgfb) {
- return +1;
- }
- }
-
- if (fa->pFGF->GetMerit() > fb->pFGF->GetMerit()) {
- return -1;
- }
- if (fa->pFGF->GetMerit() < fb->pFGF->GetMerit()) {
- return +1;
- }
-
- if (fa->exactmatch && !fb->exactmatch) {
- return -1;
- }
- if (!fa->exactmatch && fb->exactmatch) {
- return +1;
- }
-
- if (fa->index < fb->index) {
- return -1;
- }
- if (fa->index > fb->index) {
- return +1;
- }
-
- return 0;
+ filter_t* fa = (filter_t*)a;
+ filter_t* fb = (filter_t*)b;
+
+ if (fa->group < fb->group) {
+ return -1;
+ }
+ if (fa->group > fb->group) {
+ return +1;
+ }
+
+ if (fa->pFGF->GetCLSID() == fb->pFGF->GetCLSID()) {
+ CFGFilterFile* fgfa = dynamic_cast<CFGFilterFile*>(fa->pFGF);
+ CFGFilterFile* fgfb = dynamic_cast<CFGFilterFile*>(fb->pFGF);
+
+ if (fgfa && !fgfb) {
+ return -1;
+ }
+ if (!fgfa && fgfb) {
+ return +1;
+ }
+ }
+
+ if (fa->pFGF->GetMerit() > fb->pFGF->GetMerit()) {
+ return -1;
+ }
+ if (fa->pFGF->GetMerit() < fb->pFGF->GetMerit()) {
+ return +1;
+ }
+
+ if (fa->exactmatch && !fb->exactmatch) {
+ return -1;
+ }
+ if (!fa->exactmatch && fb->exactmatch) {
+ return +1;
+ }
+
+ if (fa->index < fb->index) {
+ return -1;
+ }
+ if (fa->index > fb->index) {
+ return +1;
+ }
+
+ return 0;
}
diff --git a/src/mpc-hc/FGFilter.h b/src/mpc-hc/FGFilter.h
index 4743c82d7..7abf7c5ce 100644
--- a/src/mpc-hc/FGFilter.h
+++ b/src/mpc-hc/FGFilter.h
@@ -35,135 +35,135 @@
class CFGFilter
{
protected:
- CLSID m_clsid;
- CStringW m_name;
- struct {
- union {
- UINT64 val;
- struct {
- UINT64 low:16, mid:32, high:16;
- };
- };
- } m_merit;
- CAtlList<GUID> m_types;
+ CLSID m_clsid;
+ CStringW m_name;
+ struct {
+ union {
+ UINT64 val;
+ struct {
+ UINT64 low: 16, mid: 32, high: 16;
+ };
+ };
+ } m_merit;
+ CAtlList<GUID> m_types;
public:
- CFGFilter(const CLSID& clsid, CStringW name = L"", UINT64 merit = MERIT64_DO_USE);
- virtual ~CFGFilter() {}
-
- CLSID GetCLSID() const {
- return m_clsid;
- }
- CStringW GetName() const {
- return m_name;
- }
- UINT64 GetMerit() const {
- return m_merit.val;
- }
- DWORD GetMeritForDirectShow() const {
- return m_merit.mid;
- }
- const CAtlList<GUID>& GetTypes() const;
- void SetTypes(const CAtlList<GUID>& types);
- void AddType(const GUID& majortype, const GUID& subtype);
- bool CheckTypes(const CAtlArray<GUID>& types, bool fExactMatch);
-
- CAtlList<CString> m_protocols, m_extensions, m_chkbytes; // TODO: subtype?
-
- virtual HRESULT Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks) = 0;
+ CFGFilter(const CLSID& clsid, CStringW name = L"", UINT64 merit = MERIT64_DO_USE);
+ virtual ~CFGFilter() {}
+
+ CLSID GetCLSID() const {
+ return m_clsid;
+ }
+ CStringW GetName() const {
+ return m_name;
+ }
+ UINT64 GetMerit() const {
+ return m_merit.val;
+ }
+ DWORD GetMeritForDirectShow() const {
+ return m_merit.mid;
+ }
+ const CAtlList<GUID>& GetTypes() const;
+ void SetTypes(const CAtlList<GUID>& types);
+ void AddType(const GUID& majortype, const GUID& subtype);
+ bool CheckTypes(const CAtlArray<GUID>& types, bool fExactMatch);
+
+ CAtlList<CString> m_protocols, m_extensions, m_chkbytes; // TODO: subtype?
+
+ virtual HRESULT Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks) = 0;
};
class CFGFilterRegistry : public CFGFilter
{
protected:
- CStringW m_DisplayName;
- CComPtr<IMoniker> m_pMoniker;
+ CStringW m_DisplayName;
+ CComPtr<IMoniker> m_pMoniker;
- void ExtractFilterData(BYTE* p, UINT len);
+ void ExtractFilterData(BYTE* p, UINT len);
public:
- CFGFilterRegistry(IMoniker* pMoniker, UINT64 merit = MERIT64_DO_USE);
- CFGFilterRegistry(CStringW DisplayName, UINT64 merit = MERIT64_DO_USE);
- CFGFilterRegistry(const CLSID& clsid, UINT64 merit = MERIT64_DO_USE);
-
- CStringW GetDisplayName() {
- return m_DisplayName;
- }
- IMoniker* GetMoniker() {
- return m_pMoniker;
- }
-
- HRESULT Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
+ CFGFilterRegistry(IMoniker* pMoniker, UINT64 merit = MERIT64_DO_USE);
+ CFGFilterRegistry(CStringW DisplayName, UINT64 merit = MERIT64_DO_USE);
+ CFGFilterRegistry(const CLSID& clsid, UINT64 merit = MERIT64_DO_USE);
+
+ CStringW GetDisplayName() {
+ return m_DisplayName;
+ }
+ IMoniker* GetMoniker() {
+ return m_pMoniker;
+ }
+
+ HRESULT Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
private:
- void QueryProperties();
+ void QueryProperties();
};
template<class T>
class CFGFilterInternal : public CFGFilter
{
public:
- CFGFilterInternal(CStringW name = L"", UINT64 merit = MERIT64_DO_USE) : CFGFilter(__uuidof(T), name, merit) {}
+ CFGFilterInternal(CStringW name = L"", UINT64 merit = MERIT64_DO_USE) : CFGFilter(__uuidof(T), name, merit) {}
- HRESULT Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks) {
- CheckPointer(ppBF, E_POINTER);
+ HRESULT Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks) {
+ CheckPointer(ppBF, E_POINTER);
- HRESULT hr = S_OK;
- CComPtr<IBaseFilter> pBF = DNew T(NULL, &hr);
- if (FAILED(hr)) {
- return hr;
- }
+ HRESULT hr = S_OK;
+ CComPtr<IBaseFilter> pBF = DNew T(NULL, &hr);
+ if (FAILED(hr)) {
+ return hr;
+ }
- *ppBF = pBF.Detach();
+ *ppBF = pBF.Detach();
- return hr;
- }
+ return hr;
+ }
};
class CFGFilterFile : public CFGFilter
{
protected:
- CString m_path;
- HINSTANCE m_hInst;
+ CString m_path;
+ HINSTANCE m_hInst;
public:
- CFGFilterFile(const CLSID& clsid, CString path, CStringW name = L"", UINT64 merit = MERIT64_DO_USE);
+ CFGFilterFile(const CLSID& clsid, CString path, CStringW name = L"", UINT64 merit = MERIT64_DO_USE);
- HRESULT Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
+ HRESULT Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
};
class CFGFilterVideoRenderer : public CFGFilter
{
protected:
- HWND m_hWnd;
+ HWND m_hWnd;
public:
- CFGFilterVideoRenderer(HWND hWnd, const CLSID& clsid, CStringW name = L"", UINT64 merit = MERIT64_DO_USE);
+ CFGFilterVideoRenderer(HWND hWnd, const CLSID& clsid, CStringW name = L"", UINT64 merit = MERIT64_DO_USE);
- HRESULT Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
+ HRESULT Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
};
class CFGFilterList
{
- struct filter_t {
- int index;
- CFGFilter* pFGF;
- int group;
- bool exactmatch, autodelete;
- };
- static int filter_cmp(const void* a, const void* b);
- CAtlList<filter_t> m_filters;
- CAtlList<CFGFilter*> m_sortedfilters;
+ struct filter_t {
+ int index;
+ CFGFilter* pFGF;
+ int group;
+ bool exactmatch, autodelete;
+ };
+ static int filter_cmp(const void* a, const void* b);
+ CAtlList<filter_t> m_filters;
+ CAtlList<CFGFilter*> m_sortedfilters;
public:
- CFGFilterList();
- virtual ~CFGFilterList();
+ CFGFilterList();
+ virtual ~CFGFilterList();
- bool IsEmpty() {
- return m_filters.IsEmpty();
- }
- void RemoveAll();
- void Insert(CFGFilter* pFGF, int group, bool exactmatch = false, bool autodelete = true);
+ bool IsEmpty() {
+ return m_filters.IsEmpty();
+ }
+ void RemoveAll();
+ void Insert(CFGFilter* pFGF, int group, bool exactmatch = false, bool autodelete = true);
- POSITION GetHeadPosition();
- CFGFilter* GetNext(POSITION& pos);
+ POSITION GetHeadPosition();
+ CFGFilter* GetNext(POSITION& pos);
};
diff --git a/src/mpc-hc/FGManager.cpp b/src/mpc-hc/FGManager.cpp
index 54789819e..a6202303e 100644
--- a/src/mpc-hc/FGManager.cpp
+++ b/src/mpc-hc/FGManager.cpp
@@ -44,2570 +44,2570 @@
// {212690FB-83E5-4526-8FD7-74478B7939CD} from wmcodecdsp.h
-DEFINE_GUID (CLSID_CMPEG2VidDecoderDS, 0x212690FB, 0x83E5, 0x4526, 0x8F, 0xD7, 0x74, 0x47, 0x8B, 0x79, 0x39, 0xCD);
+DEFINE_GUID(CLSID_CMPEG2VidDecoderDS, 0x212690FB, 0x83E5, 0x4526, 0x8F, 0xD7, 0x74, 0x47, 0x8B, 0x79, 0x39, 0xCD);
// {39F498AF-1A09-4275-B193-673B0BA3D478}
-DEFINE_GUID (CLSID_CMpeg2DecFilter, 0x39F498AF, 0x1A09, 0x4275, 0xB1, 0x93, 0x67, 0x3B, 0x0B, 0xA3, 0xD4, 0x78);
+DEFINE_GUID(CLSID_CMpeg2DecFilter, 0x39F498AF, 0x1A09, 0x4275, 0xB1, 0x93, 0x67, 0x3B, 0x0B, 0xA3, 0xD4, 0x78);
// {71E4616A-DB5E-452B-8CA5-71D9CC7805E9}
-DEFINE_GUID (CLSID_NvidiaVideoDecoder, 0x71E4616A, 0xDB5E, 0x452B, 0x8C, 0xA5, 0x71, 0xD9, 0xCC, 0x78, 0x05, 0xE9);
+DEFINE_GUID(CLSID_NvidiaVideoDecoder, 0x71E4616A, 0xDB5E, 0x452B, 0x8C, 0xA5, 0x71, 0xD9, 0xCC, 0x78, 0x05, 0xE9);
// {D7D50E8D-DD72-43C2-8587-A0C197D837D2}
-DEFINE_GUID (CLSID_SonicCinemasterVideoDecoder, 0xD7D50E8D, 0xDD72, 0x43C2, 0x85, 0x87, 0xA0, 0xC1, 0x97, 0xD8, 0x37, 0xD2);
+DEFINE_GUID(CLSID_SonicCinemasterVideoDecoder, 0xD7D50E8D, 0xDD72, 0x43C2, 0x85, 0x87, 0xA0, 0xC1, 0x97, 0xD8, 0x37, 0xD2);
//
// CFGManager
//
CFGManager::CFGManager(LPCTSTR pName, LPUNKNOWN pUnk)
- : CUnknown(pName, pUnk)
- , m_dwRegister(0)
+ : CUnknown(pName, pUnk)
+ , m_dwRegister(0)
{
- m_pUnkInner.CoCreateInstance(CLSID_FilterGraph, GetOwner());
- m_pFM.CoCreateInstance(CLSID_FilterMapper2);
+ m_pUnkInner.CoCreateInstance(CLSID_FilterGraph, GetOwner());
+ m_pFM.CoCreateInstance(CLSID_FilterMapper2);
}
CFGManager::~CFGManager()
{
- CAutoLock cAutoLock(this);
- while (!m_source.IsEmpty()) {
- delete m_source.RemoveHead();
- }
- while (!m_transform.IsEmpty()) {
- delete m_transform.RemoveHead();
- }
- while (!m_override.IsEmpty()) {
- delete m_override.RemoveHead();
- }
- m_pUnks.RemoveAll();
- m_pUnkInner.Release();
+ CAutoLock cAutoLock(this);
+ while (!m_source.IsEmpty()) {
+ delete m_source.RemoveHead();
+ }
+ while (!m_transform.IsEmpty()) {
+ delete m_transform.RemoveHead();
+ }
+ while (!m_override.IsEmpty()) {
+ delete m_override.RemoveHead();
+ }
+ m_pUnks.RemoveAll();
+ m_pUnkInner.Release();
}
STDMETHODIMP CFGManager::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
-
- return
- QI(IFilterGraph)
- QI(IGraphBuilder)
- QI(IFilterGraph2)
- QI(IGraphBuilder2)
- QI(IGraphBuilderDeadEnd)
- m_pUnkInner && (riid != IID_IUnknown && SUCCEEDED(m_pUnkInner->QueryInterface(riid, ppv))) ? S_OK :
- __super::NonDelegatingQueryInterface(riid, ppv);
+ CheckPointer(ppv, E_POINTER);
+
+ return
+ QI(IFilterGraph)
+ QI(IGraphBuilder)
+ QI(IFilterGraph2)
+ QI(IGraphBuilder2)
+ QI(IGraphBuilderDeadEnd)
+ m_pUnkInner && (riid != IID_IUnknown && SUCCEEDED(m_pUnkInner->QueryInterface(riid, ppv))) ? S_OK :
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
//
void CFGManager::CStreamPath::Append(IBaseFilter* pBF, IPin* pPin)
{
- path_t p;
- p.clsid = GetCLSID(pBF);
- p.filter = GetFilterName(pBF);
- p.pin = GetPinName(pPin);
- AddTail(p);
+ path_t p;
+ p.clsid = GetCLSID(pBF);
+ p.filter = GetFilterName(pBF);
+ p.pin = GetPinName(pPin);
+ AddTail(p);
}
bool CFGManager::CStreamPath::Compare(const CStreamPath& path)
{
- POSITION pos1 = GetHeadPosition();
- POSITION pos2 = path.GetHeadPosition();
+ POSITION pos1 = GetHeadPosition();
+ POSITION pos2 = path.GetHeadPosition();
- while (pos1 && pos2) {
- const path_t& p1 = GetNext(pos1);
- const path_t& p2 = path.GetNext(pos2);
+ while (pos1 && pos2) {
+ const path_t& p1 = GetNext(pos1);
+ const path_t& p2 = path.GetNext(pos2);
- if (p1.filter != p2.filter) {
- return true;
- } else if (p1.pin != p2.pin) {
- return false;
- }
- }
+ if (p1.filter != p2.filter) {
+ return true;
+ } else if (p1.pin != p2.pin) {
+ return false;
+ }
+ }
- return true;
+ return true;
}
//
bool CFGManager::CheckBytes(HANDLE hFile, CString chkbytes)
{
- CAtlList<CString> sl;
- Explode(chkbytes, sl, ',');
-
- if (sl.GetCount() < 4) {
- return false;
- }
-
- ASSERT(!(sl.GetCount()&3));
-
- LARGE_INTEGER size = {0, 0};
- GetFileSizeEx(hFile, &size);
-
- while (sl.GetCount() >= 4) {
- CString offsetstr = sl.RemoveHead();
- CString cbstr = sl.RemoveHead();
- CString maskstr = sl.RemoveHead();
- CString valstr = sl.RemoveHead();
-
- long cb = _ttol(cbstr);
-
- if (offsetstr.IsEmpty() || cbstr.IsEmpty()
- || valstr.IsEmpty() || (valstr.GetLength() & 1)
- || cb*2 != valstr.GetLength()) {
- return false;
- }
-
- LARGE_INTEGER offset;
- offset.QuadPart = _ttoi64(offsetstr);
- if (offset.QuadPart < 0) {
- offset.QuadPart = size.QuadPart - offset.QuadPart;
- }
- SetFilePointerEx(hFile, offset, &offset, FILE_BEGIN);
-
- // LAME
- while (maskstr.GetLength() < valstr.GetLength()) {
- maskstr += 'F';
- }
-
- CAtlArray<BYTE> mask, val;
- CStringToBin(maskstr, mask);
- CStringToBin(valstr, val);
-
- for (size_t i = 0; i < val.GetCount(); i++) {
- BYTE b;
- DWORD r;
- if (!ReadFile(hFile, &b, 1, &r, NULL) || (b & mask[i]) != val[i]) {
- return false;
- }
- }
- }
-
- return sl.IsEmpty();
+ CAtlList<CString> sl;
+ Explode(chkbytes, sl, ',');
+
+ if (sl.GetCount() < 4) {
+ return false;
+ }
+
+ ASSERT(!(sl.GetCount() & 3));
+
+ LARGE_INTEGER size = {0, 0};
+ GetFileSizeEx(hFile, &size);
+
+ while (sl.GetCount() >= 4) {
+ CString offsetstr = sl.RemoveHead();
+ CString cbstr = sl.RemoveHead();
+ CString maskstr = sl.RemoveHead();
+ CString valstr = sl.RemoveHead();
+
+ long cb = _ttol(cbstr);
+
+ if (offsetstr.IsEmpty() || cbstr.IsEmpty()
+ || valstr.IsEmpty() || (valstr.GetLength() & 1)
+ || cb * 2 != valstr.GetLength()) {
+ return false;
+ }
+
+ LARGE_INTEGER offset;
+ offset.QuadPart = _ttoi64(offsetstr);
+ if (offset.QuadPart < 0) {
+ offset.QuadPart = size.QuadPart - offset.QuadPart;
+ }
+ SetFilePointerEx(hFile, offset, &offset, FILE_BEGIN);
+
+ // LAME
+ while (maskstr.GetLength() < valstr.GetLength()) {
+ maskstr += 'F';
+ }
+
+ CAtlArray<BYTE> mask, val;
+ CStringToBin(maskstr, mask);
+ CStringToBin(valstr, val);
+
+ for (size_t i = 0; i < val.GetCount(); i++) {
+ BYTE b;
+ DWORD r;
+ if (!ReadFile(hFile, &b, 1, &r, NULL) || (b & mask[i]) != val[i]) {
+ return false;
+ }
+ }
+ }
+
+ return sl.IsEmpty();
}
-CFGFilter *LookupFilterRegistry(const GUID &guid, CAtlList<CFGFilter*> &list, UINT64 fallback_merit = MERIT64_DO_USE)
+CFGFilter* LookupFilterRegistry(const GUID& guid, CAtlList<CFGFilter*>& list, UINT64 fallback_merit = MERIT64_DO_USE)
{
- POSITION pos = list.GetHeadPosition();
- CFGFilter *pFilter = NULL;
- while (pos) {
- CFGFilter* pFGF = list.GetNext(pos);
- if (pFGF->GetCLSID() == guid) {
- pFilter = pFGF;
- break;
- }
- }
- if (pFilter) {
- return DNew CFGFilterRegistry(guid, pFilter->GetMerit());
- } else {
- return DNew CFGFilterRegistry(guid, fallback_merit);
- }
+ POSITION pos = list.GetHeadPosition();
+ CFGFilter* pFilter = NULL;
+ while (pos) {
+ CFGFilter* pFGF = list.GetNext(pos);
+ if (pFGF->GetCLSID() == guid) {
+ pFilter = pFGF;
+ break;
+ }
+ }
+ if (pFilter) {
+ return DNew CFGFilterRegistry(guid, pFilter->GetMerit());
+ } else {
+ return DNew CFGFilterRegistry(guid, fallback_merit);
+ }
}
HRESULT CFGManager::EnumSourceFilters(LPCWSTR lpcwstrFileName, CFGFilterList& fl)
{
- // TODO: use overrides
-
- CheckPointer(lpcwstrFileName, E_POINTER);
-
- fl.RemoveAll();
-
- CStringW fn = CStringW(lpcwstrFileName).TrimLeft();
- CStringW protocol = fn.Left(fn.Find(':')+1).TrimRight(':').MakeLower();
- CStringW ext = CPathW(fn).GetExtension().MakeLower();
-
- HANDLE hFile = INVALID_HANDLE_VALUE;
-
- if (protocol.GetLength() <= 1 || protocol == L"file") {
- hFile = CreateFile(CString(fn), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE)NULL);
-
- if (hFile == INVALID_HANDLE_VALUE) {
- return VFW_E_NOT_FOUND;
- }
- }
-
- // exceptions first
-
- if (ext == _T(".dvr-ms") || ext == _T(".wtv")) { // doh, this is stupid
- fl.Insert(LookupFilterRegistry(CLSID_StreamBufferSource, m_override, MERIT64_PREFERRED), 0);
- }
-
- TCHAR buff[256], buff2[256];
- ULONG len, len2;
-
- if (hFile == INVALID_HANDLE_VALUE) {
- // internal / protocol
-
- POSITION pos = m_source.GetHeadPosition();
- while (pos) {
- CFGFilter* pFGF = m_source.GetNext(pos);
- if (pFGF->m_protocols.Find(CString(protocol))) {
- fl.Insert(pFGF, 0, false, false);
- }
- }
- } else {
- // internal / check bytes
-
- POSITION pos = m_source.GetHeadPosition();
- while (pos) {
- CFGFilter* pFGF = m_source.GetNext(pos);
-
- POSITION pos2 = pFGF->m_chkbytes.GetHeadPosition();
- while (pos2) {
- if (CheckBytes(hFile, pFGF->m_chkbytes.GetNext(pos2))) {
- fl.Insert(pFGF, 1, false, false);
- break;
- }
- }
- }
- }
-
- if (!ext.IsEmpty()) {
- // internal / file extension
-
- POSITION pos = m_source.GetHeadPosition();
- while (pos) {
- CFGFilter* pFGF = m_source.GetNext(pos);
- if (pFGF->m_extensions.Find(CString(ext))) {
- fl.Insert(pFGF, 2, false, false);
- }
- }
- }
-
- {
- // internal / the rest
-
- POSITION pos = m_source.GetHeadPosition();
- while (pos) {
- CFGFilter* pFGF = m_source.GetNext(pos);
- if (pFGF->m_protocols.IsEmpty() && pFGF->m_chkbytes.IsEmpty() && pFGF->m_extensions.IsEmpty()) {
- fl.Insert(pFGF, 3, false, false);
- }
- }
- }
-
- if (hFile == INVALID_HANDLE_VALUE) {
- // protocol
-
- CRegKey key;
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, CString(protocol), KEY_READ)) {
- CRegKey exts;
- if (ERROR_SUCCESS == exts.Open(key, _T("Extensions"), KEY_READ)) {
- len = _countof(buff);
- if (ERROR_SUCCESS == exts.QueryStringValue(CString(ext), buff, &len)) {
- fl.Insert(LookupFilterRegistry(GUIDFromCString(buff), m_override), 4);
- }
- }
-
- len = _countof(buff);
- if (ERROR_SUCCESS == key.QueryStringValue(_T("Source Filter"), buff, &len)) {
- fl.Insert(LookupFilterRegistry(GUIDFromCString(buff), m_override), 5);
- }
- }
-
- fl.Insert(DNew CFGFilterRegistry(CLSID_URLReader), 6);
- } else {
- // check bytes
-
- CRegKey key;
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Media Type"), KEY_READ)) {
- FILETIME ft;
- len = _countof(buff);
- for (DWORD i = 0; ERROR_SUCCESS == key.EnumKey(i, buff, &len, &ft); i++, len = _countof(buff)) {
- GUID majortype;
- if (FAILED(GUIDFromCString(buff, majortype))) {
- continue;
- }
-
- CRegKey majorkey;
- if (ERROR_SUCCESS == majorkey.Open(key, buff, KEY_READ)) {
- len = _countof(buff);
- for (DWORD j = 0; ERROR_SUCCESS == majorkey.EnumKey(j, buff, &len, &ft); j++, len = _countof(buff)) {
- GUID subtype;
- if (FAILED(GUIDFromCString(buff, subtype))) {
- continue;
- }
-
- CRegKey subkey;
- if (ERROR_SUCCESS == subkey.Open(majorkey, buff, KEY_READ)) {
- len = _countof(buff);
- if (ERROR_SUCCESS != subkey.QueryStringValue(_T("Source Filter"), buff, &len)) {
- continue;
- }
-
- GUID clsid = GUIDFromCString(buff);
-
- len = _countof(buff);
- len2 = sizeof(buff2);
- for (DWORD k = 0, type;
- clsid != GUID_NULL && ERROR_SUCCESS == RegEnumValue(subkey, k, buff2, &len2, 0, &type, (BYTE*)buff, &len);
- k++, len = _countof(buff), len2 = sizeof(buff2)) {
- if (CheckBytes(hFile, CString(buff))) {
- CFGFilter* pFGF = LookupFilterRegistry(clsid, m_override);
- pFGF->AddType(majortype, subtype);
- fl.Insert(pFGF, 9);
- break;
- }
- }
- }
- }
- }
- }
- }
- }
-
- if (!ext.IsEmpty()) {
- // file extension
-
- CRegKey key;
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Media Type\\Extensions\\") + CString(ext), KEY_READ)) {
- ULONG len = _countof(buff);
- memset(buff, 0, sizeof(buff));
- LONG ret = key.QueryStringValue(_T("Source Filter"), buff, &len); // QueryStringValue can return ERROR_INVALID_DATA on bogus strings (radlight mpc v1003, fixed in v1004)
- if (ERROR_SUCCESS == ret || ERROR_INVALID_DATA == ret && GUIDFromCString(buff) != GUID_NULL) {
- GUID clsid = GUIDFromCString(buff);
- GUID majortype = GUID_NULL;
- GUID subtype = GUID_NULL;
-
- len = _countof(buff);
- if (ERROR_SUCCESS == key.QueryStringValue(_T("Media Type"), buff, &len)) {
- majortype = GUIDFromCString(buff);
- }
-
- len = _countof(buff);
- if (ERROR_SUCCESS == key.QueryStringValue(_T("Subtype"), buff, &len)) {
- subtype = GUIDFromCString(buff);
- }
-
- CFGFilter* pFGF = LookupFilterRegistry(clsid, m_override);
- pFGF->AddType(majortype, subtype);
- fl.Insert(pFGF, 7);
- }
- }
- }
-
- if (hFile != INVALID_HANDLE_VALUE) {
- CloseHandle(hFile);
- }
-
- CFGFilter* pFGF = LookupFilterRegistry(CLSID_AsyncReader, m_override);
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_NULL);
- fl.Insert(pFGF, 9);
-
- return S_OK;
+ // TODO: use overrides
+
+ CheckPointer(lpcwstrFileName, E_POINTER);
+
+ fl.RemoveAll();
+
+ CStringW fn = CStringW(lpcwstrFileName).TrimLeft();
+ CStringW protocol = fn.Left(fn.Find(':') + 1).TrimRight(':').MakeLower();
+ CStringW ext = CPathW(fn).GetExtension().MakeLower();
+
+ HANDLE hFile = INVALID_HANDLE_VALUE;
+
+ if (protocol.GetLength() <= 1 || protocol == L"file") {
+ hFile = CreateFile(CString(fn), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE)NULL);
+
+ if (hFile == INVALID_HANDLE_VALUE) {
+ return VFW_E_NOT_FOUND;
+ }
+ }
+
+ // exceptions first
+
+ if (ext == _T(".dvr-ms") || ext == _T(".wtv")) { // doh, this is stupid
+ fl.Insert(LookupFilterRegistry(CLSID_StreamBufferSource, m_override, MERIT64_PREFERRED), 0);
+ }
+
+ TCHAR buff[256], buff2[256];
+ ULONG len, len2;
+
+ if (hFile == INVALID_HANDLE_VALUE) {
+ // internal / protocol
+
+ POSITION pos = m_source.GetHeadPosition();
+ while (pos) {
+ CFGFilter* pFGF = m_source.GetNext(pos);
+ if (pFGF->m_protocols.Find(CString(protocol))) {
+ fl.Insert(pFGF, 0, false, false);
+ }
+ }
+ } else {
+ // internal / check bytes
+
+ POSITION pos = m_source.GetHeadPosition();
+ while (pos) {
+ CFGFilter* pFGF = m_source.GetNext(pos);
+
+ POSITION pos2 = pFGF->m_chkbytes.GetHeadPosition();
+ while (pos2) {
+ if (CheckBytes(hFile, pFGF->m_chkbytes.GetNext(pos2))) {
+ fl.Insert(pFGF, 1, false, false);
+ break;
+ }
+ }
+ }
+ }
+
+ if (!ext.IsEmpty()) {
+ // internal / file extension
+
+ POSITION pos = m_source.GetHeadPosition();
+ while (pos) {
+ CFGFilter* pFGF = m_source.GetNext(pos);
+ if (pFGF->m_extensions.Find(CString(ext))) {
+ fl.Insert(pFGF, 2, false, false);
+ }
+ }
+ }
+
+ {
+ // internal / the rest
+
+ POSITION pos = m_source.GetHeadPosition();
+ while (pos) {
+ CFGFilter* pFGF = m_source.GetNext(pos);
+ if (pFGF->m_protocols.IsEmpty() && pFGF->m_chkbytes.IsEmpty() && pFGF->m_extensions.IsEmpty()) {
+ fl.Insert(pFGF, 3, false, false);
+ }
+ }
+ }
+
+ if (hFile == INVALID_HANDLE_VALUE) {
+ // protocol
+
+ CRegKey key;
+ if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, CString(protocol), KEY_READ)) {
+ CRegKey exts;
+ if (ERROR_SUCCESS == exts.Open(key, _T("Extensions"), KEY_READ)) {
+ len = _countof(buff);
+ if (ERROR_SUCCESS == exts.QueryStringValue(CString(ext), buff, &len)) {
+ fl.Insert(LookupFilterRegistry(GUIDFromCString(buff), m_override), 4);
+ }
+ }
+
+ len = _countof(buff);
+ if (ERROR_SUCCESS == key.QueryStringValue(_T("Source Filter"), buff, &len)) {
+ fl.Insert(LookupFilterRegistry(GUIDFromCString(buff), m_override), 5);
+ }
+ }
+
+ fl.Insert(DNew CFGFilterRegistry(CLSID_URLReader), 6);
+ } else {
+ // check bytes
+
+ CRegKey key;
+ if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Media Type"), KEY_READ)) {
+ FILETIME ft;
+ len = _countof(buff);
+ for (DWORD i = 0; ERROR_SUCCESS == key.EnumKey(i, buff, &len, &ft); i++, len = _countof(buff)) {
+ GUID majortype;
+ if (FAILED(GUIDFromCString(buff, majortype))) {
+ continue;
+ }
+
+ CRegKey majorkey;
+ if (ERROR_SUCCESS == majorkey.Open(key, buff, KEY_READ)) {
+ len = _countof(buff);
+ for (DWORD j = 0; ERROR_SUCCESS == majorkey.EnumKey(j, buff, &len, &ft); j++, len = _countof(buff)) {
+ GUID subtype;
+ if (FAILED(GUIDFromCString(buff, subtype))) {
+ continue;
+ }
+
+ CRegKey subkey;
+ if (ERROR_SUCCESS == subkey.Open(majorkey, buff, KEY_READ)) {
+ len = _countof(buff);
+ if (ERROR_SUCCESS != subkey.QueryStringValue(_T("Source Filter"), buff, &len)) {
+ continue;
+ }
+
+ GUID clsid = GUIDFromCString(buff);
+
+ len = _countof(buff);
+ len2 = sizeof(buff2);
+ for (DWORD k = 0, type;
+ clsid != GUID_NULL && ERROR_SUCCESS == RegEnumValue(subkey, k, buff2, &len2, 0, &type, (BYTE*)buff, &len);
+ k++, len = _countof(buff), len2 = sizeof(buff2)) {
+ if (CheckBytes(hFile, CString(buff))) {
+ CFGFilter* pFGF = LookupFilterRegistry(clsid, m_override);
+ pFGF->AddType(majortype, subtype);
+ fl.Insert(pFGF, 9);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!ext.IsEmpty()) {
+ // file extension
+
+ CRegKey key;
+ if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Media Type\\Extensions\\") + CString(ext), KEY_READ)) {
+ ULONG len = _countof(buff);
+ memset(buff, 0, sizeof(buff));
+ LONG ret = key.QueryStringValue(_T("Source Filter"), buff, &len); // QueryStringValue can return ERROR_INVALID_DATA on bogus strings (radlight mpc v1003, fixed in v1004)
+ if (ERROR_SUCCESS == ret || ERROR_INVALID_DATA == ret && GUIDFromCString(buff) != GUID_NULL) {
+ GUID clsid = GUIDFromCString(buff);
+ GUID majortype = GUID_NULL;
+ GUID subtype = GUID_NULL;
+
+ len = _countof(buff);
+ if (ERROR_SUCCESS == key.QueryStringValue(_T("Media Type"), buff, &len)) {
+ majortype = GUIDFromCString(buff);
+ }
+
+ len = _countof(buff);
+ if (ERROR_SUCCESS == key.QueryStringValue(_T("Subtype"), buff, &len)) {
+ subtype = GUIDFromCString(buff);
+ }
+
+ CFGFilter* pFGF = LookupFilterRegistry(clsid, m_override);
+ pFGF->AddType(majortype, subtype);
+ fl.Insert(pFGF, 7);
+ }
+ }
+ }
+
+ if (hFile != INVALID_HANDLE_VALUE) {
+ CloseHandle(hFile);
+ }
+
+ CFGFilter* pFGF = LookupFilterRegistry(CLSID_AsyncReader, m_override);
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_NULL);
+ fl.Insert(pFGF, 9);
+
+ return S_OK;
}
HRESULT CFGManager::AddSourceFilter(CFGFilter* pFGF, LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, IBaseFilter** ppBF)
{
- TRACE(_T("FGM: AddSourceFilter trying '%s'\n"), CStringFromGUID(pFGF->GetCLSID()));
-
- CheckPointer(lpcwstrFileName, E_POINTER);
- CheckPointer(ppBF, E_POINTER);
-
- ASSERT(*ppBF == NULL);
-
- HRESULT hr;
-
- CComPtr<IBaseFilter> pBF;
- CInterfaceList<IUnknown, &IID_IUnknown> pUnks;
- if (FAILED(hr = pFGF->Create(&pBF, pUnks))) {
- return hr;
- }
-
- CComQIPtr<IFileSourceFilter> pFSF = pBF;
- if (!pFSF) {
- return E_NOINTERFACE;
- }
-
- if (FAILED(hr = AddFilter(pBF, lpcwstrFilterName))) {
- return hr;
- }
-
- const AM_MEDIA_TYPE* pmt = NULL;
-
- CMediaType mt;
- const CAtlList<GUID>& types = pFGF->GetTypes();
- if (types.GetCount() == 2 && (types.GetHead() != GUID_NULL || types.GetTail() != GUID_NULL)) {
- mt.majortype = types.GetHead();
- mt.subtype = types.GetTail();
- pmt = &mt;
- }
-
- // sometimes looping with AviSynth
- if (FAILED(hr = pFSF->Load(lpcwstrFileName, pmt))) {
- RemoveFilter(pBF);
- return hr;
- }
-
- // doh :P
- BeginEnumMediaTypes(GetFirstPin(pBF, PINDIR_OUTPUT), pEMT, pmt) {
- static const GUID guid1 =
- { 0x640999A0, 0xA946, 0x11D0, { 0xA5, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } };
- static const GUID guid2 =
- { 0x640999A1, 0xA946, 0x11D0, { 0xA5, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } };
- static const GUID guid3 =
- { 0xD51BD5AE, 0x7548, 0x11CF, { 0xA5, 0x20, 0x00, 0x80, 0xC7, 0x7E, 0xF5, 0x8A } };
-
- if (pmt->subtype == guid1 || pmt->subtype == guid2 || pmt->subtype == guid3) {
- RemoveFilter(pBF);
- pFGF = DNew CFGFilterRegistry(CLSID_NetShowSource);
- hr = AddSourceFilter(pFGF, lpcwstrFileName, lpcwstrFilterName, ppBF);
- delete pFGF;
- return hr;
- }
- }
- EndEnumMediaTypes(pmt)
-
- *ppBF = pBF.Detach();
-
- m_pUnks.AddTailList(&pUnks);
-
- return S_OK;
+ TRACE(_T("FGM: AddSourceFilter trying '%s'\n"), CStringFromGUID(pFGF->GetCLSID()));
+
+ CheckPointer(lpcwstrFileName, E_POINTER);
+ CheckPointer(ppBF, E_POINTER);
+
+ ASSERT(*ppBF == NULL);
+
+ HRESULT hr;
+
+ CComPtr<IBaseFilter> pBF;
+ CInterfaceList<IUnknown, &IID_IUnknown> pUnks;
+ if (FAILED(hr = pFGF->Create(&pBF, pUnks))) {
+ return hr;
+ }
+
+ CComQIPtr<IFileSourceFilter> pFSF = pBF;
+ if (!pFSF) {
+ return E_NOINTERFACE;
+ }
+
+ if (FAILED(hr = AddFilter(pBF, lpcwstrFilterName))) {
+ return hr;
+ }
+
+ const AM_MEDIA_TYPE* pmt = NULL;
+
+ CMediaType mt;
+ const CAtlList<GUID>& types = pFGF->GetTypes();
+ if (types.GetCount() == 2 && (types.GetHead() != GUID_NULL || types.GetTail() != GUID_NULL)) {
+ mt.majortype = types.GetHead();
+ mt.subtype = types.GetTail();
+ pmt = &mt;
+ }
+
+ // sometimes looping with AviSynth
+ if (FAILED(hr = pFSF->Load(lpcwstrFileName, pmt))) {
+ RemoveFilter(pBF);
+ return hr;
+ }
+
+ // doh :P
+ BeginEnumMediaTypes(GetFirstPin(pBF, PINDIR_OUTPUT), pEMT, pmt) {
+ static const GUID guid1 =
+ { 0x640999A0, 0xA946, 0x11D0, { 0xA5, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } };
+ static const GUID guid2 =
+ { 0x640999A1, 0xA946, 0x11D0, { 0xA5, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } };
+ static const GUID guid3 =
+ { 0xD51BD5AE, 0x7548, 0x11CF, { 0xA5, 0x20, 0x00, 0x80, 0xC7, 0x7E, 0xF5, 0x8A } };
+
+ if (pmt->subtype == guid1 || pmt->subtype == guid2 || pmt->subtype == guid3) {
+ RemoveFilter(pBF);
+ pFGF = DNew CFGFilterRegistry(CLSID_NetShowSource);
+ hr = AddSourceFilter(pFGF, lpcwstrFileName, lpcwstrFilterName, ppBF);
+ delete pFGF;
+ return hr;
+ }
+ }
+ EndEnumMediaTypes(pmt)
+
+ *ppBF = pBF.Detach();
+
+ m_pUnks.AddTailList(&pUnks);
+
+ return S_OK;
}
// IFilterGraph
STDMETHODIMP CFGManager::AddFilter(IBaseFilter* pFilter, LPCWSTR pName)
{
- if (!m_pUnkInner) {
- return E_UNEXPECTED;
- }
+ if (!m_pUnkInner) {
+ return E_UNEXPECTED;
+ }
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- HRESULT hr;
+ HRESULT hr;
- if (FAILED(hr = CComQIPtr<IFilterGraph2>(m_pUnkInner)->AddFilter(pFilter, pName))) {
- return hr;
- }
+ if (FAILED(hr = CComQIPtr<IFilterGraph2>(m_pUnkInner)->AddFilter(pFilter, pName))) {
+ return hr;
+ }
- // TODO
- hr = pFilter->JoinFilterGraph(NULL, NULL);
- hr = pFilter->JoinFilterGraph(this, pName);
+ // TODO
+ hr = pFilter->JoinFilterGraph(NULL, NULL);
+ hr = pFilter->JoinFilterGraph(this, pName);
- return hr;
+ return hr;
}
STDMETHODIMP CFGManager::RemoveFilter(IBaseFilter* pFilter)
{
- if (!m_pUnkInner) {
- return E_UNEXPECTED;
- }
+ if (!m_pUnkInner) {
+ return E_UNEXPECTED;
+ }
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return CComQIPtr<IFilterGraph2>(m_pUnkInner)->RemoveFilter(pFilter);
+ return CComQIPtr<IFilterGraph2>(m_pUnkInner)->RemoveFilter(pFilter);
}
STDMETHODIMP CFGManager::EnumFilters(IEnumFilters** ppEnum)
{
- if (!m_pUnkInner) {
- return E_UNEXPECTED;
- }
+ if (!m_pUnkInner) {
+ return E_UNEXPECTED;
+ }
- // Not locking here fixes a deadlock involving ReClock
- //CAutoLock cAutoLock(this);
+ // Not locking here fixes a deadlock involving ReClock
+ //CAutoLock cAutoLock(this);
- return CComQIPtr<IFilterGraph2>(m_pUnkInner)->EnumFilters(ppEnum);
+ return CComQIPtr<IFilterGraph2>(m_pUnkInner)->EnumFilters(ppEnum);
}
STDMETHODIMP CFGManager::FindFilterByName(LPCWSTR pName, IBaseFilter** ppFilter)
{
- if (!m_pUnkInner) {
- return E_UNEXPECTED;
- }
+ if (!m_pUnkInner) {
+ return E_UNEXPECTED;
+ }
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return CComQIPtr<IFilterGraph2>(m_pUnkInner)->FindFilterByName(pName, ppFilter);
+ return CComQIPtr<IFilterGraph2>(m_pUnkInner)->FindFilterByName(pName, ppFilter);
}
STDMETHODIMP CFGManager::ConnectDirect(IPin* pPinOut, IPin* pPinIn, const AM_MEDIA_TYPE* pmt)
{
- if (!m_pUnkInner) {
- return E_UNEXPECTED;
- }
-
- CAutoLock cAutoLock(this);
-
- CComPtr<IBaseFilter> pBF = GetFilterFromPin(pPinIn);
- CLSID clsid = GetCLSID(pBF);
-
- // TODO: GetUpStreamFilter goes up on the first input pin only
- for (CComPtr<IBaseFilter> pBFUS = GetFilterFromPin(pPinOut); pBFUS; pBFUS = GetUpStreamFilter(pBFUS)) {
- if (pBFUS == pBF) {
- return VFW_E_CIRCULAR_GRAPH;
- }
- if (clsid!=CLSID_Proxy && GetCLSID(pBFUS) == clsid) {
- return VFW_E_CANNOT_CONNECT;
- }
- }
-
- return CComQIPtr<IFilterGraph2>(m_pUnkInner)->ConnectDirect(pPinOut, pPinIn, pmt);
+ if (!m_pUnkInner) {
+ return E_UNEXPECTED;
+ }
+
+ CAutoLock cAutoLock(this);
+
+ CComPtr<IBaseFilter> pBF = GetFilterFromPin(pPinIn);
+ CLSID clsid = GetCLSID(pBF);
+
+ // TODO: GetUpStreamFilter goes up on the first input pin only
+ for (CComPtr<IBaseFilter> pBFUS = GetFilterFromPin(pPinOut); pBFUS; pBFUS = GetUpStreamFilter(pBFUS)) {
+ if (pBFUS == pBF) {
+ return VFW_E_CIRCULAR_GRAPH;
+ }
+ if (clsid != CLSID_Proxy && GetCLSID(pBFUS) == clsid) {
+ return VFW_E_CANNOT_CONNECT;
+ }
+ }
+
+ return CComQIPtr<IFilterGraph2>(m_pUnkInner)->ConnectDirect(pPinOut, pPinIn, pmt);
}
STDMETHODIMP CFGManager::Reconnect(IPin* ppin)
{
- if (!m_pUnkInner) {
- return E_UNEXPECTED;
- }
+ if (!m_pUnkInner) {
+ return E_UNEXPECTED;
+ }
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return CComQIPtr<IFilterGraph2>(m_pUnkInner)->Reconnect(ppin);
+ return CComQIPtr<IFilterGraph2>(m_pUnkInner)->Reconnect(ppin);
}
STDMETHODIMP CFGManager::Disconnect(IPin* ppin)
{
- if (!m_pUnkInner) {
- return E_UNEXPECTED;
- }
+ if (!m_pUnkInner) {
+ return E_UNEXPECTED;
+ }
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return CComQIPtr<IFilterGraph2>(m_pUnkInner)->Disconnect(ppin);
+ return CComQIPtr<IFilterGraph2>(m_pUnkInner)->Disconnect(ppin);
}
STDMETHODIMP CFGManager::SetDefaultSyncSource()
{
- if (!m_pUnkInner) {
- return E_UNEXPECTED;
- }
+ if (!m_pUnkInner) {
+ return E_UNEXPECTED;
+ }
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return CComQIPtr<IFilterGraph2>(m_pUnkInner)->SetDefaultSyncSource();
+ return CComQIPtr<IFilterGraph2>(m_pUnkInner)->SetDefaultSyncSource();
}
// IGraphBuilder
STDMETHODIMP CFGManager::Connect(IPin* pPinOut, IPin* pPinIn)
{
- return Connect(pPinOut, pPinIn, true);
+ return Connect(pPinOut, pPinIn, true);
}
HRESULT CFGManager::Connect(IPin* pPinOut, IPin* pPinIn, bool bContinueRender)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- CheckPointer(pPinOut, E_POINTER);
+ CheckPointer(pPinOut, E_POINTER);
- HRESULT hr;
+ HRESULT hr;
- if (S_OK != IsPinDirection(pPinOut, PINDIR_OUTPUT)
- || pPinIn && S_OK != IsPinDirection(pPinIn, PINDIR_INPUT)) {
- return VFW_E_INVALID_DIRECTION;
- }
+ if (S_OK != IsPinDirection(pPinOut, PINDIR_OUTPUT)
+ || pPinIn && S_OK != IsPinDirection(pPinIn, PINDIR_INPUT)) {
+ return VFW_E_INVALID_DIRECTION;
+ }
- if (S_OK == IsPinConnected(pPinOut)
- || pPinIn && S_OK == IsPinConnected(pPinIn)) {
- return VFW_E_ALREADY_CONNECTED;
- }
+ if (S_OK == IsPinConnected(pPinOut)
+ || pPinIn && S_OK == IsPinConnected(pPinIn)) {
+ return VFW_E_ALREADY_CONNECTED;
+ }
- bool fDeadEnd = true;
+ bool fDeadEnd = true;
- if (pPinIn) {
- // 1. Try a direct connection between the filters, with no intermediate filters
+ if (pPinIn) {
+ // 1. Try a direct connection between the filters, with no intermediate filters
- if (SUCCEEDED(hr = ConnectDirect(pPinOut, pPinIn, NULL))) {
- return hr;
- }
- } else {
- // 1. Use IStreamBuilder
+ if (SUCCEEDED(hr = ConnectDirect(pPinOut, pPinIn, NULL))) {
+ return hr;
+ }
+ } else {
+ // 1. Use IStreamBuilder
- if (CComQIPtr<IStreamBuilder> pSB = pPinOut) {
- if (SUCCEEDED(hr = pSB->Render(pPinOut, this))) {
- return hr;
- }
-
- pSB->Backout(pPinOut, this);
- }
- }
-
- // 2. Try cached filters
-
- if (CComQIPtr<IGraphConfig> pGC = (IGraphBuilder2*)this) {
- BeginEnumCachedFilters(pGC, pEF, pBF) {
- if (pPinIn && GetFilterFromPin(pPinIn) == pBF) {
- continue;
- }
-
- hr = pGC->RemoveFilterFromCache(pBF);
-
- // does RemoveFilterFromCache call AddFilter like AddFilterToCache calls RemoveFilter ?
-
- if (SUCCEEDED(hr = ConnectFilterDirect(pPinOut, pBF, NULL))) {
- if (!IsStreamEnd(pBF)) {
- fDeadEnd = false;
- }
-
- if (SUCCEEDED(hr = ConnectFilter(pBF, pPinIn))) {
- return hr;
- }
- }
-
- hr = pGC->AddFilterToCache(pBF);
- }
- EndEnumCachedFilters
- }
-
- // 3. Try filters in the graph
-
- {
- CInterfaceList<IBaseFilter> pBFs;
-
- BeginEnumFilters(this, pEF, pBF) {
- if (pPinIn && GetFilterFromPin(pPinIn) == pBF
- || GetFilterFromPin(pPinOut) == pBF) {
- continue;
- }
-
- // HACK: ffdshow - audio capture filter
- if (GetCLSID(pPinOut) == GUIDFromCString(_T("{04FE9017-F873-410E-871E-AB91661A4EF7}"))
- && GetCLSID(pBF) == GUIDFromCString(_T("{E30629D2-27E5-11CE-875D-00608CB78066}"))) {
- continue;
- }
-
- pBFs.AddTail(pBF);
- }
- EndEnumFilters;
-
- POSITION pos = pBFs.GetHeadPosition();
- while (pos) {
- IBaseFilter* pBF = pBFs.GetNext(pos);
-
- if (SUCCEEDED(hr = ConnectFilterDirect(pPinOut, pBF, NULL))) {
- if (!IsStreamEnd(pBF)) {
- fDeadEnd = false;
- }
-
- if (SUCCEEDED(hr = ConnectFilter(pBF, pPinIn))) {
- return hr;
- }
- }
-
- EXECUTE_ASSERT(Disconnect(pPinOut));
- }
- }
-
- // 4. Look up filters in the registry
-
- {
- CFGFilterList fl;
-
- CAtlArray<GUID> types;
- ExtractMediaTypes(pPinOut, types);
-
- POSITION pos = m_transform.GetHeadPosition();
- while (pos) {
- CFGFilter* pFGF = m_transform.GetNext(pos);
- if (pFGF->GetMerit() < MERIT64_DO_USE || pFGF->CheckTypes(types, false)) {
- fl.Insert(pFGF, 0, pFGF->CheckTypes(types, true), false);
- }
- }
-
- pos = m_override.GetHeadPosition();
- while (pos) {
- CFGFilter* pFGF = m_override.GetNext(pos);
- if (pFGF->GetMerit() < MERIT64_DO_USE || pFGF->CheckTypes(types, false)) {
- fl.Insert(pFGF, 0, pFGF->CheckTypes(types, true), false);
- }
- }
-
- CComPtr<IEnumMoniker> pEM;
- if (types.GetCount() > 0
- && SUCCEEDED(m_pFM->EnumMatchingFilters(
- &pEM, 0, FALSE, MERIT_DO_NOT_USE+1,
- TRUE, types.GetCount()/2, types.GetData(), NULL, NULL, FALSE,
- !!pPinIn, 0, NULL, NULL, NULL))) {
- for (CComPtr<IMoniker> pMoniker; S_OK == pEM->Next(1, &pMoniker, NULL); pMoniker = NULL) {
- CFGFilterRegistry* pFGF = DNew CFGFilterRegistry(pMoniker);
- fl.Insert(pFGF, 0, pFGF->CheckTypes(types, true));
- }
- }
-
- // let's check whether the madVR allocator presenter is in our list
- // it should be if madVR is selected as the video renderer
- CFGFilter* pMadVRAllocatorPresenter = NULL;
- pos = fl.GetHeadPosition();
- while (pos) {
- CFGFilter* pFGF = fl.GetNext(pos);
- if (pFGF->GetCLSID() == CLSID_madVRAllocatorPresenter) {
- // found it!
- pMadVRAllocatorPresenter = pFGF;
- break;
- }
- }
-
- pos = fl.GetHeadPosition();
- while (pos) {
- CFGFilter* pFGF = fl.GetNext(pos);
-
- // Checks if madVR is already in the graph to avoid two instances at the same time
- CComPtr<IBaseFilter> pBFmadVR;
- FindFilterByName(_T("madVR Renderer"), &pBFmadVR);
- if ( pBFmadVR && (pFGF->GetName() == _T("madVR Renderer"))) {
- continue;
- }
-
- if ((pMadVRAllocatorPresenter) && (pFGF->GetCLSID() == CLSID_madVR))
- // the pure madVR filter was selected (without the allocator presenter)
- // subtitles, OSD etc don't work correcty without the allocator presenter
- // so we prefer the allocator presenter over the pure filter
- {
- pFGF = pMadVRAllocatorPresenter;
- }
-
- TRACE(_T("FGM: Connecting '%s'\n"), pFGF->GetName());
-
- CComPtr<IBaseFilter> pBF;
- CInterfaceList<IUnknown, &IID_IUnknown> pUnks;
- if (FAILED(pFGF->Create(&pBF, pUnks))) {
- continue;
- }
-
- if (FAILED(hr = AddFilter(pBF, pFGF->GetName()))) {
- pBF.Release();
- continue;
- }
-
- hr = ConnectFilterDirect(pPinOut, pBF, NULL);
- /*
- if (FAILED(hr))
- {
- if (types.GetCount() >= 2 && types[0] == MEDIATYPE_Stream && types[1] != GUID_NULL)
- {
- CMediaType mt;
-
- mt.majortype = types[0];
- mt.subtype = types[1];
- mt.formattype = FORMAT_None;
- if (FAILED(hr)) hr = ConnectFilterDirect(pPinOut, pBF, &mt);
-
- mt.formattype = GUID_NULL;
- if (FAILED(hr)) hr = ConnectFilterDirect(pPinOut, pBF, &mt);
- }
- }
- */
- if (SUCCEEDED(hr)) {
- if (!IsStreamEnd(pBF)) {
- fDeadEnd = false;
- }
-
- if (bContinueRender) {
- hr = ConnectFilter(pBF, pPinIn);
- }
-
- if (SUCCEEDED(hr)) {
- m_pUnks.AddTailList(&pUnks);
-
- // maybe the application should do this...
-
- POSITION pos = pUnks.GetHeadPosition();
- while (pos) {
- if (CComQIPtr<IMixerPinConfig, &IID_IMixerPinConfig> pMPC = pUnks.GetNext(pos)) {
- pMPC->SetAspectRatioMode(AM_ARMODE_STRETCHED);
- }
- }
-
- if (CComQIPtr<IVMRAspectRatioControl> pARC = pBF) {
- pARC->SetAspectRatioMode(VMR_ARMODE_NONE);
- }
-
- if (CComQIPtr<IVMRAspectRatioControl9> pARC = pBF) {
- pARC->SetAspectRatioMode(VMR_ARMODE_NONE);
- }
-
- if (CComQIPtr<IVMRMixerControl9> pMC = pBF) {
- m_pUnks.AddTail (pMC);
- }
-
- if (CComQIPtr<IVMRMixerBitmap9> pMB = pBF) {
- m_pUnks.AddTail (pMB);
- }
-
- if (CComQIPtr<IMFGetService, &__uuidof(IMFGetService)> pMFGS = pBF) {
- CComPtr<IMFVideoDisplayControl> pMFVDC;
- CComPtr<IMFVideoMixerBitmap> pMFMB;
- CComPtr<IMFVideoProcessor> pMFVP;
-
- if (SUCCEEDED (pMFGS->GetService (MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl, (void**)&pMFVDC))) {
- m_pUnks.AddTail (pMFVDC);
- }
-
- if (SUCCEEDED (pMFGS->GetService (MR_VIDEO_MIXER_SERVICE, IID_IMFVideoMixerBitmap, (void**)&pMFMB))) {
- m_pUnks.AddTail (pMFMB);
- }
-
- if (SUCCEEDED (pMFGS->GetService (MR_VIDEO_MIXER_SERVICE, IID_IMFVideoProcessor, (void**)&pMFVP))) {
- m_pUnks.AddTail (pMFVP);
- }
-
- // CComPtr<IMFWorkQueueServices> pMFWQS;
- // pMFGS->GetService (MF_WORKQUEUE_SERVICES, IID_IMFWorkQueueServices, (void**)&pMFWQS);
- // pMFWQS->BeginRegisterPlatformWorkQueueWithMMCSS(
-
- }
-
- return hr;
- }
- }
-
- EXECUTE_ASSERT(SUCCEEDED(RemoveFilter(pBF)));
- TRACE(_T("FGM: Connecting '%s' FAILED!\n"), pFGF->GetName());
- pBF.Release();
- }
- }
-
- if (fDeadEnd) {
- CAutoPtr<CStreamDeadEnd> psde(DNew CStreamDeadEnd());
- psde->AddTailList(&m_streampath);
- int skip = 0;
- BeginEnumMediaTypes(pPinOut, pEM, pmt) {
- if (pmt->majortype == MEDIATYPE_Stream && pmt->subtype == MEDIASUBTYPE_NULL) {
- skip++;
- }
- psde->mts.AddTail(CMediaType(*pmt));
- }
- EndEnumMediaTypes(pmt)
- if (skip < (int)psde->mts.GetCount()) {
- m_deadends.Add(psde);
- }
- }
-
- return pPinIn ? VFW_E_CANNOT_CONNECT : VFW_E_CANNOT_RENDER;
+ if (CComQIPtr<IStreamBuilder> pSB = pPinOut) {
+ if (SUCCEEDED(hr = pSB->Render(pPinOut, this))) {
+ return hr;
+ }
+
+ pSB->Backout(pPinOut, this);
+ }
+ }
+
+ // 2. Try cached filters
+
+ if (CComQIPtr<IGraphConfig> pGC = (IGraphBuilder2*)this) {
+ BeginEnumCachedFilters(pGC, pEF, pBF) {
+ if (pPinIn && GetFilterFromPin(pPinIn) == pBF) {
+ continue;
+ }
+
+ hr = pGC->RemoveFilterFromCache(pBF);
+
+ // does RemoveFilterFromCache call AddFilter like AddFilterToCache calls RemoveFilter ?
+
+ if (SUCCEEDED(hr = ConnectFilterDirect(pPinOut, pBF, NULL))) {
+ if (!IsStreamEnd(pBF)) {
+ fDeadEnd = false;
+ }
+
+ if (SUCCEEDED(hr = ConnectFilter(pBF, pPinIn))) {
+ return hr;
+ }
+ }
+
+ hr = pGC->AddFilterToCache(pBF);
+ }
+ EndEnumCachedFilters
+ }
+
+ // 3. Try filters in the graph
+
+ {
+ CInterfaceList<IBaseFilter> pBFs;
+
+ BeginEnumFilters(this, pEF, pBF) {
+ if (pPinIn && GetFilterFromPin(pPinIn) == pBF
+ || GetFilterFromPin(pPinOut) == pBF) {
+ continue;
+ }
+
+ // HACK: ffdshow - audio capture filter
+ if (GetCLSID(pPinOut) == GUIDFromCString(_T("{04FE9017-F873-410E-871E-AB91661A4EF7}"))
+ && GetCLSID(pBF) == GUIDFromCString(_T("{E30629D2-27E5-11CE-875D-00608CB78066}"))) {
+ continue;
+ }
+
+ pBFs.AddTail(pBF);
+ }
+ EndEnumFilters;
+
+ POSITION pos = pBFs.GetHeadPosition();
+ while (pos) {
+ IBaseFilter* pBF = pBFs.GetNext(pos);
+
+ if (SUCCEEDED(hr = ConnectFilterDirect(pPinOut, pBF, NULL))) {
+ if (!IsStreamEnd(pBF)) {
+ fDeadEnd = false;
+ }
+
+ if (SUCCEEDED(hr = ConnectFilter(pBF, pPinIn))) {
+ return hr;
+ }
+ }
+
+ EXECUTE_ASSERT(Disconnect(pPinOut));
+ }
+ }
+
+ // 4. Look up filters in the registry
+
+ {
+ CFGFilterList fl;
+
+ CAtlArray<GUID> types;
+ ExtractMediaTypes(pPinOut, types);
+
+ POSITION pos = m_transform.GetHeadPosition();
+ while (pos) {
+ CFGFilter* pFGF = m_transform.GetNext(pos);
+ if (pFGF->GetMerit() < MERIT64_DO_USE || pFGF->CheckTypes(types, false)) {
+ fl.Insert(pFGF, 0, pFGF->CheckTypes(types, true), false);
+ }
+ }
+
+ pos = m_override.GetHeadPosition();
+ while (pos) {
+ CFGFilter* pFGF = m_override.GetNext(pos);
+ if (pFGF->GetMerit() < MERIT64_DO_USE || pFGF->CheckTypes(types, false)) {
+ fl.Insert(pFGF, 0, pFGF->CheckTypes(types, true), false);
+ }
+ }
+
+ CComPtr<IEnumMoniker> pEM;
+ if (types.GetCount() > 0
+ && SUCCEEDED(m_pFM->EnumMatchingFilters(
+ &pEM, 0, FALSE, MERIT_DO_NOT_USE + 1,
+ TRUE, types.GetCount() / 2, types.GetData(), NULL, NULL, FALSE,
+ !!pPinIn, 0, NULL, NULL, NULL))) {
+ for (CComPtr<IMoniker> pMoniker; S_OK == pEM->Next(1, &pMoniker, NULL); pMoniker = NULL) {
+ CFGFilterRegistry* pFGF = DNew CFGFilterRegistry(pMoniker);
+ fl.Insert(pFGF, 0, pFGF->CheckTypes(types, true));
+ }
+ }
+
+ // let's check whether the madVR allocator presenter is in our list
+ // it should be if madVR is selected as the video renderer
+ CFGFilter* pMadVRAllocatorPresenter = NULL;
+ pos = fl.GetHeadPosition();
+ while (pos) {
+ CFGFilter* pFGF = fl.GetNext(pos);
+ if (pFGF->GetCLSID() == CLSID_madVRAllocatorPresenter) {
+ // found it!
+ pMadVRAllocatorPresenter = pFGF;
+ break;
+ }
+ }
+
+ pos = fl.GetHeadPosition();
+ while (pos) {
+ CFGFilter* pFGF = fl.GetNext(pos);
+
+ // Checks if madVR is already in the graph to avoid two instances at the same time
+ CComPtr<IBaseFilter> pBFmadVR;
+ FindFilterByName(_T("madVR Renderer"), &pBFmadVR);
+ if (pBFmadVR && (pFGF->GetName() == _T("madVR Renderer"))) {
+ continue;
+ }
+
+ if ((pMadVRAllocatorPresenter) && (pFGF->GetCLSID() == CLSID_madVR))
+ // the pure madVR filter was selected (without the allocator presenter)
+ // subtitles, OSD etc don't work correcty without the allocator presenter
+ // so we prefer the allocator presenter over the pure filter
+ {
+ pFGF = pMadVRAllocatorPresenter;
+ }
+
+ TRACE(_T("FGM: Connecting '%s'\n"), pFGF->GetName());
+
+ CComPtr<IBaseFilter> pBF;
+ CInterfaceList<IUnknown, &IID_IUnknown> pUnks;
+ if (FAILED(pFGF->Create(&pBF, pUnks))) {
+ continue;
+ }
+
+ if (FAILED(hr = AddFilter(pBF, pFGF->GetName()))) {
+ pBF.Release();
+ continue;
+ }
+
+ hr = ConnectFilterDirect(pPinOut, pBF, NULL);
+ /*
+ if (FAILED(hr))
+ {
+ if (types.GetCount() >= 2 && types[0] == MEDIATYPE_Stream && types[1] != GUID_NULL)
+ {
+ CMediaType mt;
+
+ mt.majortype = types[0];
+ mt.subtype = types[1];
+ mt.formattype = FORMAT_None;
+ if (FAILED(hr)) hr = ConnectFilterDirect(pPinOut, pBF, &mt);
+
+ mt.formattype = GUID_NULL;
+ if (FAILED(hr)) hr = ConnectFilterDirect(pPinOut, pBF, &mt);
+ }
+ }
+ */
+ if (SUCCEEDED(hr)) {
+ if (!IsStreamEnd(pBF)) {
+ fDeadEnd = false;
+ }
+
+ if (bContinueRender) {
+ hr = ConnectFilter(pBF, pPinIn);
+ }
+
+ if (SUCCEEDED(hr)) {
+ m_pUnks.AddTailList(&pUnks);
+
+ // maybe the application should do this...
+
+ POSITION pos = pUnks.GetHeadPosition();
+ while (pos) {
+ if (CComQIPtr<IMixerPinConfig, &IID_IMixerPinConfig> pMPC = pUnks.GetNext(pos)) {
+ pMPC->SetAspectRatioMode(AM_ARMODE_STRETCHED);
+ }
+ }
+
+ if (CComQIPtr<IVMRAspectRatioControl> pARC = pBF) {
+ pARC->SetAspectRatioMode(VMR_ARMODE_NONE);
+ }
+
+ if (CComQIPtr<IVMRAspectRatioControl9> pARC = pBF) {
+ pARC->SetAspectRatioMode(VMR_ARMODE_NONE);
+ }
+
+ if (CComQIPtr<IVMRMixerControl9> pMC = pBF) {
+ m_pUnks.AddTail(pMC);
+ }
+
+ if (CComQIPtr<IVMRMixerBitmap9> pMB = pBF) {
+ m_pUnks.AddTail(pMB);
+ }
+
+ if (CComQIPtr<IMFGetService, &__uuidof(IMFGetService)> pMFGS = pBF) {
+ CComPtr<IMFVideoDisplayControl> pMFVDC;
+ CComPtr<IMFVideoMixerBitmap> pMFMB;
+ CComPtr<IMFVideoProcessor> pMFVP;
+
+ if (SUCCEEDED(pMFGS->GetService(MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl, (void**)&pMFVDC))) {
+ m_pUnks.AddTail(pMFVDC);
+ }
+
+ if (SUCCEEDED(pMFGS->GetService(MR_VIDEO_MIXER_SERVICE, IID_IMFVideoMixerBitmap, (void**)&pMFMB))) {
+ m_pUnks.AddTail(pMFMB);
+ }
+
+ if (SUCCEEDED(pMFGS->GetService(MR_VIDEO_MIXER_SERVICE, IID_IMFVideoProcessor, (void**)&pMFVP))) {
+ m_pUnks.AddTail(pMFVP);
+ }
+
+ // CComPtr<IMFWorkQueueServices> pMFWQS;
+ // pMFGS->GetService (MF_WORKQUEUE_SERVICES, IID_IMFWorkQueueServices, (void**)&pMFWQS);
+ // pMFWQS->BeginRegisterPlatformWorkQueueWithMMCSS(
+
+ }
+
+ return hr;
+ }
+ }
+
+ EXECUTE_ASSERT(SUCCEEDED(RemoveFilter(pBF)));
+ TRACE(_T("FGM: Connecting '%s' FAILED!\n"), pFGF->GetName());
+ pBF.Release();
+ }
+ }
+
+ if (fDeadEnd) {
+ CAutoPtr<CStreamDeadEnd> psde(DNew CStreamDeadEnd());
+ psde->AddTailList(&m_streampath);
+ int skip = 0;
+ BeginEnumMediaTypes(pPinOut, pEM, pmt) {
+ if (pmt->majortype == MEDIATYPE_Stream && pmt->subtype == MEDIASUBTYPE_NULL) {
+ skip++;
+ }
+ psde->mts.AddTail(CMediaType(*pmt));
+ }
+ EndEnumMediaTypes(pmt)
+ if (skip < (int)psde->mts.GetCount()) {
+ m_deadends.Add(psde);
+ }
+ }
+
+ return pPinIn ? VFW_E_CANNOT_CONNECT : VFW_E_CANNOT_RENDER;
}
STDMETHODIMP CFGManager::Render(IPin* pPinOut)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return RenderEx(pPinOut, 0, NULL);
+ return RenderEx(pPinOut, 0, NULL);
}
STDMETHODIMP CFGManager::RenderFile(LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrPlayList)
{
- TRACE("--> CFGManager::RenderFile on thread: %d\n", GetCurrentThreadId());
- CAutoLock cAutoLock(this);
+ TRACE("--> CFGManager::RenderFile on thread: %d\n", GetCurrentThreadId());
+ CAutoLock cAutoLock(this);
- m_streampath.RemoveAll();
- m_deadends.RemoveAll();
+ m_streampath.RemoveAll();
+ m_deadends.RemoveAll();
- HRESULT hr;
+ HRESULT hr;
- /*
- CComPtr<IBaseFilter> pBF;
- if (FAILED(hr = AddSourceFilter(lpcwstrFile, lpcwstrFile, &pBF)))
- return hr;
+ /*
+ CComPtr<IBaseFilter> pBF;
+ if (FAILED(hr = AddSourceFilter(lpcwstrFile, lpcwstrFile, &pBF)))
+ return hr;
- return ConnectFilter(pBF, NULL);
- */
+ return ConnectFilter(pBF, NULL);
+ */
- CFGFilterList fl;
- if (FAILED(hr = EnumSourceFilters(lpcwstrFileName, fl))) {
- return hr;
- }
+ CFGFilterList fl;
+ if (FAILED(hr = EnumSourceFilters(lpcwstrFileName, fl))) {
+ return hr;
+ }
- CAutoPtrArray<CStreamDeadEnd> deadends;
+ CAutoPtrArray<CStreamDeadEnd> deadends;
- hr = VFW_E_CANNOT_RENDER;
+ hr = VFW_E_CANNOT_RENDER;
- POSITION pos = fl.GetHeadPosition();
- while (pos) {
- CComPtr<IBaseFilter> pBF;
+ POSITION pos = fl.GetHeadPosition();
+ while (pos) {
+ CComPtr<IBaseFilter> pBF;
- if (SUCCEEDED(hr = AddSourceFilter(fl.GetNext(pos), lpcwstrFileName, lpcwstrFileName, &pBF))) {
- m_streampath.RemoveAll();
- m_deadends.RemoveAll();
+ if (SUCCEEDED(hr = AddSourceFilter(fl.GetNext(pos), lpcwstrFileName, lpcwstrFileName, &pBF))) {
+ m_streampath.RemoveAll();
+ m_deadends.RemoveAll();
- if (SUCCEEDED(hr = ConnectFilter(pBF, NULL))) {
- return hr;
- }
+ if (SUCCEEDED(hr = ConnectFilter(pBF, NULL))) {
+ return hr;
+ }
- NukeDownstream(pBF);
- RemoveFilter(pBF);
+ NukeDownstream(pBF);
+ RemoveFilter(pBF);
- deadends.Append(m_deadends);
- }
- }
+ deadends.Append(m_deadends);
+ }
+ }
- m_deadends.Copy(deadends);
+ m_deadends.Copy(deadends);
- return hr;
+ return hr;
}
STDMETHODIMP CFGManager::AddSourceFilter(LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- HRESULT hr;
+ HRESULT hr;
- CFGFilterList fl;
- if (FAILED(hr = EnumSourceFilters(lpcwstrFileName, fl))) {
- return hr;
- }
+ CFGFilterList fl;
+ if (FAILED(hr = EnumSourceFilters(lpcwstrFileName, fl))) {
+ return hr;
+ }
- POSITION pos = fl.GetHeadPosition();
- while (pos) {
- if (SUCCEEDED(hr = AddSourceFilter(fl.GetNext(pos), lpcwstrFileName, lpcwstrFilterName, ppFilter))) {
- return hr;
- }
- }
+ POSITION pos = fl.GetHeadPosition();
+ while (pos) {
+ if (SUCCEEDED(hr = AddSourceFilter(fl.GetNext(pos), lpcwstrFileName, lpcwstrFilterName, ppFilter))) {
+ return hr;
+ }
+ }
- return VFW_E_CANNOT_LOAD_SOURCE_FILTER;
+ return VFW_E_CANNOT_LOAD_SOURCE_FILTER;
}
STDMETHODIMP CFGManager::SetLogFile(DWORD_PTR hFile)
{
- if (!m_pUnkInner) {
- return E_UNEXPECTED;
- }
+ if (!m_pUnkInner) {
+ return E_UNEXPECTED;
+ }
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return CComQIPtr<IFilterGraph2>(m_pUnkInner)->SetLogFile(hFile);
+ return CComQIPtr<IFilterGraph2>(m_pUnkInner)->SetLogFile(hFile);
}
STDMETHODIMP CFGManager::Abort()
{
- if (!m_pUnkInner) {
- return E_UNEXPECTED;
- }
+ if (!m_pUnkInner) {
+ return E_UNEXPECTED;
+ }
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return CComQIPtr<IFilterGraph2>(m_pUnkInner)->Abort();
+ return CComQIPtr<IFilterGraph2>(m_pUnkInner)->Abort();
}
STDMETHODIMP CFGManager::ShouldOperationContinue()
{
- if (!m_pUnkInner) {
- return E_UNEXPECTED;
- }
+ if (!m_pUnkInner) {
+ return E_UNEXPECTED;
+ }
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return CComQIPtr<IFilterGraph2>(m_pUnkInner)->ShouldOperationContinue();
+ return CComQIPtr<IFilterGraph2>(m_pUnkInner)->ShouldOperationContinue();
}
// IFilterGraph2
STDMETHODIMP CFGManager::AddSourceFilterForMoniker(IMoniker* pMoniker, IBindCtx* pCtx, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter)
{
- if (!m_pUnkInner) {
- return E_UNEXPECTED;
- }
+ if (!m_pUnkInner) {
+ return E_UNEXPECTED;
+ }
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return CComQIPtr<IFilterGraph2>(m_pUnkInner)->AddSourceFilterForMoniker(pMoniker, pCtx, lpcwstrFilterName, ppFilter);
+ return CComQIPtr<IFilterGraph2>(m_pUnkInner)->AddSourceFilterForMoniker(pMoniker, pCtx, lpcwstrFilterName, ppFilter);
}
STDMETHODIMP CFGManager::ReconnectEx(IPin* ppin, const AM_MEDIA_TYPE* pmt)
{
- if (!m_pUnkInner) {
- return E_UNEXPECTED;
- }
+ if (!m_pUnkInner) {
+ return E_UNEXPECTED;
+ }
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return CComQIPtr<IFilterGraph2>(m_pUnkInner)->ReconnectEx(ppin, pmt);
+ return CComQIPtr<IFilterGraph2>(m_pUnkInner)->ReconnectEx(ppin, pmt);
}
STDMETHODIMP CFGManager::RenderEx(IPin* pPinOut, DWORD dwFlags, DWORD* pvContext)
{
- CAutoLock cAutoLock(this);
-
- m_streampath.RemoveAll();
- m_deadends.RemoveAll();
-
- if (!pPinOut || dwFlags > AM_RENDEREX_RENDERTOEXISTINGRENDERERS || pvContext) {
- return E_INVALIDARG;
- }
-
- HRESULT hr;
-
- if (dwFlags & AM_RENDEREX_RENDERTOEXISTINGRENDERERS) {
- CInterfaceList<IBaseFilter> pBFs;
-
- BeginEnumFilters(this, pEF, pBF) {
- if (CComQIPtr<IAMFilterMiscFlags> pAMMF = pBF) {
- if (pAMMF->GetMiscFlags() & AM_FILTER_MISC_FLAGS_IS_RENDERER) {
- pBFs.AddTail(pBF);
- }
- } else {
- BeginEnumPins(pBF, pEP, pPin) {
- CComPtr<IPin> pPinIn;
- DWORD size = 1;
- if (SUCCEEDED(pPin->QueryInternalConnections(&pPinIn, &size)) && size == 0) {
- pBFs.AddTail(pBF);
- break;
- }
- }
- EndEnumPins;
- }
- }
- EndEnumFilters;
-
- while (!pBFs.IsEmpty()) {
- if (SUCCEEDED(hr = ConnectFilter(pPinOut, pBFs.RemoveHead()))) {
- return hr;
- }
- }
-
- return VFW_E_CANNOT_RENDER;
- }
-
- return Connect(pPinOut, (IPin*)NULL);
+ CAutoLock cAutoLock(this);
+
+ m_streampath.RemoveAll();
+ m_deadends.RemoveAll();
+
+ if (!pPinOut || dwFlags > AM_RENDEREX_RENDERTOEXISTINGRENDERERS || pvContext) {
+ return E_INVALIDARG;
+ }
+
+ HRESULT hr;
+
+ if (dwFlags & AM_RENDEREX_RENDERTOEXISTINGRENDERERS) {
+ CInterfaceList<IBaseFilter> pBFs;
+
+ BeginEnumFilters(this, pEF, pBF) {
+ if (CComQIPtr<IAMFilterMiscFlags> pAMMF = pBF) {
+ if (pAMMF->GetMiscFlags() & AM_FILTER_MISC_FLAGS_IS_RENDERER) {
+ pBFs.AddTail(pBF);
+ }
+ } else {
+ BeginEnumPins(pBF, pEP, pPin) {
+ CComPtr<IPin> pPinIn;
+ DWORD size = 1;
+ if (SUCCEEDED(pPin->QueryInternalConnections(&pPinIn, &size)) && size == 0) {
+ pBFs.AddTail(pBF);
+ break;
+ }
+ }
+ EndEnumPins;
+ }
+ }
+ EndEnumFilters;
+
+ while (!pBFs.IsEmpty()) {
+ if (SUCCEEDED(hr = ConnectFilter(pPinOut, pBFs.RemoveHead()))) {
+ return hr;
+ }
+ }
+
+ return VFW_E_CANNOT_RENDER;
+ }
+
+ return Connect(pPinOut, (IPin*)NULL);
}
// IGraphBuilder2
STDMETHODIMP CFGManager::IsPinDirection(IPin* pPin, PIN_DIRECTION dir1)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- CheckPointer(pPin, E_POINTER);
+ CheckPointer(pPin, E_POINTER);
- PIN_DIRECTION dir2;
- if (FAILED(pPin->QueryDirection(&dir2))) {
- return E_FAIL;
- }
+ PIN_DIRECTION dir2;
+ if (FAILED(pPin->QueryDirection(&dir2))) {
+ return E_FAIL;
+ }
- return dir1 == dir2 ? S_OK : S_FALSE;
+ return dir1 == dir2 ? S_OK : S_FALSE;
}
STDMETHODIMP CFGManager::IsPinConnected(IPin* pPin)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- CheckPointer(pPin, E_POINTER);
+ CheckPointer(pPin, E_POINTER);
- CComPtr<IPin> pPinTo;
- return SUCCEEDED(pPin->ConnectedTo(&pPinTo)) && pPinTo ? S_OK : S_FALSE;
+ CComPtr<IPin> pPinTo;
+ return SUCCEEDED(pPin->ConnectedTo(&pPinTo)) && pPinTo ? S_OK : S_FALSE;
}
STDMETHODIMP CFGManager::ConnectFilter(IBaseFilter* pBF, IPin* pPinIn)
{
- CAutoLock cAutoLock(this);
-
- CheckPointer(pBF, E_POINTER);
-
- if (pPinIn && S_OK != IsPinDirection(pPinIn, PINDIR_INPUT)) {
- return VFW_E_INVALID_DIRECTION;
- }
-
- int nTotal = 0, nRendered = 0;
-
- AppSettings& s = AfxGetAppSettings();
-
- BeginEnumPins(pBF, pEP, pPin) {
- if (S_OK == IsPinDirection(pPin, PINDIR_OUTPUT)
- && S_OK != IsPinConnected(pPin)
- && !((s.iDSVideoRendererType != VIDRNDT_DS_EVR_CUSTOM && s.iDSVideoRendererType != VIDRNDT_DS_EVR && s.iDSVideoRendererType != VIDRNDT_DS_SYNC) && GetPinName(pPin)[0] == '~')) {
-
- CLSID clsid;
- pBF->GetClassID(&clsid);
- // Disable DVD subtitle mixing in EVR-CP and EVR-Sync for Microsoft DTV-DVD Video Decoder, it's corrupt DVD playback ...
- if (clsid == CLSID_CMPEG2VidDecoderDS) {
- if (s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_SYNC) {
- CString pin_name = GetPinName(pPin);
- if (GetPinName(pPin)[0] == '~') {
- continue;
- }
- }
- }
- // No multiple pin for Internal MPEG2 Software Decoder, Nvidia PureVideo Decoder, Sonic Cinemaster VideoDecoder
- else if (clsid == CLSID_CMpeg2DecFilter
- || clsid == CLSID_NvidiaVideoDecoder
- || clsid == CLSID_SonicCinemasterVideoDecoder) {
- CString pin_name = GetPinName(pPin);
- if (GetPinName(pPin)[0] == '~') {
- continue;
- }
- //TODO: enable multiple pins for the renderer, if the video decoder supports DXVA
- }
-
- m_streampath.Append(pBF, pPin);
-
- HRESULT hr = Connect(pPin, pPinIn);
-
- if (SUCCEEDED(hr)) {
- for (ptrdiff_t i = m_deadends.GetCount()-1; i >= 0; i--)
- if (m_deadends[i]->Compare(m_streampath)) {
- m_deadends.RemoveAt(i);
- }
-
- nRendered++;
- }
-
- nTotal++;
-
- m_streampath.RemoveTail();
-
- if (SUCCEEDED(hr) && pPinIn) {
- return S_OK;
- }
- }
- }
- EndEnumPins;
-
- return
- nRendered == nTotal ? (nRendered > 0 ? S_OK : S_FALSE) :
- nRendered > 0 ? VFW_S_PARTIAL_RENDER :
- VFW_E_CANNOT_RENDER;
+ CAutoLock cAutoLock(this);
+
+ CheckPointer(pBF, E_POINTER);
+
+ if (pPinIn && S_OK != IsPinDirection(pPinIn, PINDIR_INPUT)) {
+ return VFW_E_INVALID_DIRECTION;
+ }
+
+ int nTotal = 0, nRendered = 0;
+
+ AppSettings& s = AfxGetAppSettings();
+
+ BeginEnumPins(pBF, pEP, pPin) {
+ if (S_OK == IsPinDirection(pPin, PINDIR_OUTPUT)
+ && S_OK != IsPinConnected(pPin)
+ && !((s.iDSVideoRendererType != VIDRNDT_DS_EVR_CUSTOM && s.iDSVideoRendererType != VIDRNDT_DS_EVR && s.iDSVideoRendererType != VIDRNDT_DS_SYNC) && GetPinName(pPin)[0] == '~')) {
+
+ CLSID clsid;
+ pBF->GetClassID(&clsid);
+ // Disable DVD subtitle mixing in EVR-CP and EVR-Sync for Microsoft DTV-DVD Video Decoder, it's corrupt DVD playback ...
+ if (clsid == CLSID_CMPEG2VidDecoderDS) {
+ if (s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_SYNC) {
+ CString pin_name = GetPinName(pPin);
+ if (GetPinName(pPin)[0] == '~') {
+ continue;
+ }
+ }
+ }
+ // No multiple pin for Internal MPEG2 Software Decoder, Nvidia PureVideo Decoder, Sonic Cinemaster VideoDecoder
+ else if (clsid == CLSID_CMpeg2DecFilter
+ || clsid == CLSID_NvidiaVideoDecoder
+ || clsid == CLSID_SonicCinemasterVideoDecoder) {
+ CString pin_name = GetPinName(pPin);
+ if (GetPinName(pPin)[0] == '~') {
+ continue;
+ }
+ //TODO: enable multiple pins for the renderer, if the video decoder supports DXVA
+ }
+
+ m_streampath.Append(pBF, pPin);
+
+ HRESULT hr = Connect(pPin, pPinIn);
+
+ if (SUCCEEDED(hr)) {
+ for (ptrdiff_t i = m_deadends.GetCount() - 1; i >= 0; i--)
+ if (m_deadends[i]->Compare(m_streampath)) {
+ m_deadends.RemoveAt(i);
+ }
+
+ nRendered++;
+ }
+
+ nTotal++;
+
+ m_streampath.RemoveTail();
+
+ if (SUCCEEDED(hr) && pPinIn) {
+ return S_OK;
+ }
+ }
+ }
+ EndEnumPins;
+
+ return
+ nRendered == nTotal ? (nRendered > 0 ? S_OK : S_FALSE) :
+ nRendered > 0 ? VFW_S_PARTIAL_RENDER :
+ VFW_E_CANNOT_RENDER;
}
STDMETHODIMP CFGManager::ConnectFilter(IPin* pPinOut, IBaseFilter* pBF)
{
- CAutoLock cAutoLock(this);
-
- CheckPointer(pPinOut, E_POINTER);
- CheckPointer(pBF, E_POINTER);
-
- if (S_OK != IsPinDirection(pPinOut, PINDIR_OUTPUT)) {
- return VFW_E_INVALID_DIRECTION;
- }
-
- AppSettings& s = AfxGetAppSettings();
-
- BeginEnumPins(pBF, pEP, pPin) {
- if (S_OK == IsPinDirection(pPin, PINDIR_INPUT)
- && S_OK != IsPinConnected(pPin)
- && !((s.iDSVideoRendererType != VIDRNDT_DS_EVR_CUSTOM && s.iDSVideoRendererType != VIDRNDT_DS_EVR && s.iDSVideoRendererType != VIDRNDT_DS_SYNC) && GetPinName(pPin)[0] == '~')) {
- HRESULT hr = Connect(pPinOut, pPin);
- if (SUCCEEDED(hr)) {
- return hr;
- }
- }
- }
- EndEnumPins;
-
- return VFW_E_CANNOT_CONNECT;
+ CAutoLock cAutoLock(this);
+
+ CheckPointer(pPinOut, E_POINTER);
+ CheckPointer(pBF, E_POINTER);
+
+ if (S_OK != IsPinDirection(pPinOut, PINDIR_OUTPUT)) {
+ return VFW_E_INVALID_DIRECTION;
+ }
+
+ AppSettings& s = AfxGetAppSettings();
+
+ BeginEnumPins(pBF, pEP, pPin) {
+ if (S_OK == IsPinDirection(pPin, PINDIR_INPUT)
+ && S_OK != IsPinConnected(pPin)
+ && !((s.iDSVideoRendererType != VIDRNDT_DS_EVR_CUSTOM && s.iDSVideoRendererType != VIDRNDT_DS_EVR && s.iDSVideoRendererType != VIDRNDT_DS_SYNC) && GetPinName(pPin)[0] == '~')) {
+ HRESULT hr = Connect(pPinOut, pPin);
+ if (SUCCEEDED(hr)) {
+ return hr;
+ }
+ }
+ }
+ EndEnumPins;
+
+ return VFW_E_CANNOT_CONNECT;
}
STDMETHODIMP CFGManager::ConnectFilterDirect(IPin* pPinOut, IBaseFilter* pBF, const AM_MEDIA_TYPE* pmt)
{
- CAutoLock cAutoLock(this);
-
- CheckPointer(pPinOut, E_POINTER);
- CheckPointer(pBF, E_POINTER);
-
- if (S_OK != IsPinDirection(pPinOut, PINDIR_OUTPUT)) {
- return VFW_E_INVALID_DIRECTION;
- }
-
- AppSettings& s = AfxGetAppSettings();
-
- BeginEnumPins(pBF, pEP, pPin) {
- if (S_OK == IsPinDirection(pPin, PINDIR_INPUT)
- && S_OK != IsPinConnected(pPin)
- && !((s.iDSVideoRendererType != VIDRNDT_DS_EVR_CUSTOM && s.iDSVideoRendererType != VIDRNDT_DS_EVR && s.iDSVideoRendererType != VIDRNDT_DS_SYNC) && GetPinName(pPin)[0] == '~')) {
- HRESULT hr = ConnectDirect(pPinOut, pPin, pmt);
- if (SUCCEEDED(hr)) {
- return hr;
- }
- }
- }
- EndEnumPins;
-
- return VFW_E_CANNOT_CONNECT;
+ CAutoLock cAutoLock(this);
+
+ CheckPointer(pPinOut, E_POINTER);
+ CheckPointer(pBF, E_POINTER);
+
+ if (S_OK != IsPinDirection(pPinOut, PINDIR_OUTPUT)) {
+ return VFW_E_INVALID_DIRECTION;
+ }
+
+ AppSettings& s = AfxGetAppSettings();
+
+ BeginEnumPins(pBF, pEP, pPin) {
+ if (S_OK == IsPinDirection(pPin, PINDIR_INPUT)
+ && S_OK != IsPinConnected(pPin)
+ && !((s.iDSVideoRendererType != VIDRNDT_DS_EVR_CUSTOM && s.iDSVideoRendererType != VIDRNDT_DS_EVR && s.iDSVideoRendererType != VIDRNDT_DS_SYNC) && GetPinName(pPin)[0] == '~')) {
+ HRESULT hr = ConnectDirect(pPinOut, pPin, pmt);
+ if (SUCCEEDED(hr)) {
+ return hr;
+ }
+ }
+ }
+ EndEnumPins;
+
+ return VFW_E_CANNOT_CONNECT;
}
STDMETHODIMP CFGManager::NukeDownstream(IUnknown* pUnk)
{
- CAutoLock cAutoLock(this);
-
- if (CComQIPtr<IBaseFilter> pBF = pUnk) {
- BeginEnumPins(pBF, pEP, pPin) {
- NukeDownstream(pPin);
- }
- EndEnumPins;
- } else if (CComQIPtr<IPin> pPin = pUnk) {
- CComPtr<IPin> pPinTo;
- if (S_OK == IsPinDirection(pPin, PINDIR_OUTPUT)
- && SUCCEEDED(pPin->ConnectedTo(&pPinTo)) && pPinTo) {
- if (CComPtr<IBaseFilter> pBF = GetFilterFromPin(pPinTo)) {
- NukeDownstream(pBF);
- Disconnect(pPinTo);
- Disconnect(pPin);
- RemoveFilter(pBF);
- }
- }
- } else {
- return E_INVALIDARG;
- }
-
- return S_OK;
+ CAutoLock cAutoLock(this);
+
+ if (CComQIPtr<IBaseFilter> pBF = pUnk) {
+ BeginEnumPins(pBF, pEP, pPin) {
+ NukeDownstream(pPin);
+ }
+ EndEnumPins;
+ } else if (CComQIPtr<IPin> pPin = pUnk) {
+ CComPtr<IPin> pPinTo;
+ if (S_OK == IsPinDirection(pPin, PINDIR_OUTPUT)
+ && SUCCEEDED(pPin->ConnectedTo(&pPinTo)) && pPinTo) {
+ if (CComPtr<IBaseFilter> pBF = GetFilterFromPin(pPinTo)) {
+ NukeDownstream(pBF);
+ Disconnect(pPinTo);
+ Disconnect(pPin);
+ RemoveFilter(pBF);
+ }
+ }
+ } else {
+ return E_INVALIDARG;
+ }
+
+ return S_OK;
}
STDMETHODIMP CFGManager::FindInterface(REFIID iid, void** ppv, BOOL bRemove)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- for (POSITION pos = m_pUnks.GetHeadPosition(); pos; m_pUnks.GetNext(pos)) {
- if (SUCCEEDED(m_pUnks.GetAt(pos)->QueryInterface(iid, ppv))) {
- if (bRemove) {
- m_pUnks.RemoveAt(pos);
- }
- return S_OK;
- }
- }
+ for (POSITION pos = m_pUnks.GetHeadPosition(); pos; m_pUnks.GetNext(pos)) {
+ if (SUCCEEDED(m_pUnks.GetAt(pos)->QueryInterface(iid, ppv))) {
+ if (bRemove) {
+ m_pUnks.RemoveAt(pos);
+ }
+ return S_OK;
+ }
+ }
- return E_NOINTERFACE;
+ return E_NOINTERFACE;
}
STDMETHODIMP CFGManager::AddToROT()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- HRESULT hr;
+ HRESULT hr;
- if (m_dwRegister) {
- return S_FALSE;
- }
+ if (m_dwRegister) {
+ return S_FALSE;
+ }
- CComPtr<IRunningObjectTable> pROT;
- CComPtr<IMoniker> pMoniker;
- WCHAR wsz[256];
- swprintf_s(wsz, _countof(wsz), L"FilterGraph %08p pid %08x (MPC)", this, GetCurrentProcessId());
- if (SUCCEEDED(hr = GetRunningObjectTable(0, &pROT))
- && SUCCEEDED(hr = CreateItemMoniker(L"!", wsz, &pMoniker))) {
- hr = pROT->Register(ROTFLAGS_REGISTRATIONKEEPSALIVE, (IGraphBuilder2*)this, pMoniker, &m_dwRegister);
- }
+ CComPtr<IRunningObjectTable> pROT;
+ CComPtr<IMoniker> pMoniker;
+ WCHAR wsz[256];
+ swprintf_s(wsz, _countof(wsz), L"FilterGraph %08p pid %08x (MPC)", this, GetCurrentProcessId());
+ if (SUCCEEDED(hr = GetRunningObjectTable(0, &pROT))
+ && SUCCEEDED(hr = CreateItemMoniker(L"!", wsz, &pMoniker))) {
+ hr = pROT->Register(ROTFLAGS_REGISTRATIONKEEPSALIVE, (IGraphBuilder2*)this, pMoniker, &m_dwRegister);
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CFGManager::RemoveFromROT()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- HRESULT hr;
+ HRESULT hr;
- if (!m_dwRegister) {
- return S_FALSE;
- }
+ if (!m_dwRegister) {
+ return S_FALSE;
+ }
- CComPtr<IRunningObjectTable> pROT;
- if (SUCCEEDED(hr = GetRunningObjectTable(0, &pROT))
- && SUCCEEDED(hr = pROT->Revoke(m_dwRegister))) {
- m_dwRegister = 0;
- }
+ CComPtr<IRunningObjectTable> pROT;
+ if (SUCCEEDED(hr = GetRunningObjectTable(0, &pROT))
+ && SUCCEEDED(hr = pROT->Revoke(m_dwRegister))) {
+ m_dwRegister = 0;
+ }
- return hr;
+ return hr;
}
// IGraphBuilderDeadEnd
STDMETHODIMP_(size_t) CFGManager::GetCount()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- return m_deadends.GetCount();
+ return m_deadends.GetCount();
}
STDMETHODIMP CFGManager::GetDeadEnd(int iIndex, CAtlList<CStringW>& path, CAtlList<CMediaType>& mts)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- if (iIndex < 0 || iIndex >= (int)m_deadends.GetCount()) {
- return E_FAIL;
- }
+ if (iIndex < 0 || iIndex >= (int)m_deadends.GetCount()) {
+ return E_FAIL;
+ }
- path.RemoveAll();
- mts.RemoveAll();
+ path.RemoveAll();
+ mts.RemoveAll();
- POSITION pos = m_deadends[iIndex]->GetHeadPosition();
- while (pos) {
- const path_t& p = m_deadends[iIndex]->GetNext(pos);
+ POSITION pos = m_deadends[iIndex]->GetHeadPosition();
+ while (pos) {
+ const path_t& p = m_deadends[iIndex]->GetNext(pos);
- CStringW str;
- str.Format(L"%s::%s", p.filter, p.pin);
- path.AddTail(str);
- }
+ CStringW str;
+ str.Format(L"%s::%s", p.filter, p.pin);
+ path.AddTail(str);
+ }
- mts.AddTailList(&m_deadends[iIndex]->mts);
+ mts.AddTailList(&m_deadends[iIndex]->mts);
- return S_OK;
+ return S_OK;
}
//
-// CFGManagerCustom
+// CFGManagerCustom
//
CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
- : CFGManager(pName, pUnk)
+ : CFGManager(pName, pUnk)
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- bool bOverrideBroadcom = false;
- CFGFilter* pFGF;
+ bool bOverrideBroadcom = false;
+ CFGFilter* pFGF;
- bool *src = s.SrcFilters;
- bool *tra = s.TraFilters;
- bool *dxva_filters = s.DXVAFilters;
- bool *ffmpeg_filters = s.FFmpegFilters;
+ bool* src = s.SrcFilters;
+ bool* tra = s.TraFilters;
+ bool* dxva_filters = s.DXVAFilters;
+ bool* ffmpeg_filters = s.FFmpegFilters;
- // Source filters
+ // Source filters
#if INTERNAL_SOURCEFILTER_SHOUTCAST
- if (src[SRC_SHOUTCAST]) {
- pFGF = DNew CFGFilterInternal<CShoutcastSource>();
- pFGF->m_protocols.AddTail(_T("http"));
- m_source.AddTail(pFGF);
- }
+ if (src[SRC_SHOUTCAST]) {
+ pFGF = DNew CFGFilterInternal<CShoutcastSource>();
+ pFGF->m_protocols.AddTail(_T("http"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_UDP
- // if (src[SRC_UDP])
- {
- pFGF = DNew CFGFilterInternal<CUDPReader>();
- pFGF->m_protocols.AddTail(_T("udp"));
- m_source.AddTail(pFGF);
- }
+ // if (src[SRC_UDP])
+ {
+ pFGF = DNew CFGFilterInternal<CUDPReader>();
+ pFGF->m_protocols.AddTail(_T("udp"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_AVI
- if (src[SRC_AVI]) {
- pFGF = DNew CFGFilterInternal<CAviSourceFilter>();
- pFGF->m_chkbytes.AddTail(_T("0,4,,52494646,8,4,,41564920"));
- pFGF->m_chkbytes.AddTail(_T("0,4,,52494646,8,4,,41564958"));
- m_source.AddTail(pFGF);
- }
+ if (src[SRC_AVI]) {
+ pFGF = DNew CFGFilterInternal<CAviSourceFilter>();
+ pFGF->m_chkbytes.AddTail(_T("0,4,,52494646,8,4,,41564920"));
+ pFGF->m_chkbytes.AddTail(_T("0,4,,52494646,8,4,,41564958"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_MP4
- if (src[SRC_MP4]) {
- pFGF = DNew CFGFilterInternal<CMP4SourceFilter>();
- pFGF->m_chkbytes.AddTail(_T("4,4,,66747970")); // ftyp
- pFGF->m_chkbytes.AddTail(_T("4,4,,6d6f6f76")); // moov
- pFGF->m_chkbytes.AddTail(_T("4,4,,6d646174")); // mdat
- pFGF->m_chkbytes.AddTail(_T("4,4,,736b6970")); // skip
- pFGF->m_chkbytes.AddTail(_T("4,12,ffffffff00000000ffffffff,77696465027fe3706d646174")); // wide ? mdat
- pFGF->m_chkbytes.AddTail(_T("3,3,,000001")); // raw mpeg4 video
- pFGF->m_extensions.AddTail(_T(".mov"));
- m_source.AddTail(pFGF);
- }
+ if (src[SRC_MP4]) {
+ pFGF = DNew CFGFilterInternal<CMP4SourceFilter>();
+ pFGF->m_chkbytes.AddTail(_T("4,4,,66747970")); // ftyp
+ pFGF->m_chkbytes.AddTail(_T("4,4,,6d6f6f76")); // moov
+ pFGF->m_chkbytes.AddTail(_T("4,4,,6d646174")); // mdat
+ pFGF->m_chkbytes.AddTail(_T("4,4,,736b6970")); // skip
+ pFGF->m_chkbytes.AddTail(_T("4,12,ffffffff00000000ffffffff,77696465027fe3706d646174")); // wide ? mdat
+ pFGF->m_chkbytes.AddTail(_T("3,3,,000001")); // raw mpeg4 video
+ pFGF->m_extensions.AddTail(_T(".mov"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_FLV
- if (src[SRC_FLV]) {
- pFGF = DNew CFGFilterInternal<CFLVSourceFilter>();
- pFGF->m_chkbytes.AddTail(_T("0,4,,464C5601")); // FLV (v1)
- m_source.AddTail(pFGF);
- }
+ if (src[SRC_FLV]) {
+ pFGF = DNew CFGFilterInternal<CFLVSourceFilter>();
+ pFGF->m_chkbytes.AddTail(_T("0,4,,464C5601")); // FLV (v1)
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_MATROSKA
- if (src[SRC_MATROSKA]) {
- pFGF = DNew CFGFilterInternal<CMatroskaSourceFilter>();
- pFGF->m_chkbytes.AddTail(_T("0,4,,1A45DFA3"));
- m_source.AddTail(pFGF);
- }
+ if (src[SRC_MATROSKA]) {
+ pFGF = DNew CFGFilterInternal<CMatroskaSourceFilter>();
+ pFGF->m_chkbytes.AddTail(_T("0,4,,1A45DFA3"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_REALMEDIA
- if (src[SRC_REALMEDIA]) {
- pFGF = DNew CFGFilterInternal<CRealMediaSourceFilter>();
- pFGF->m_chkbytes.AddTail(_T("0,4,,2E524D46"));
- m_source.AddTail(pFGF);
- }
+ if (src[SRC_REALMEDIA]) {
+ pFGF = DNew CFGFilterInternal<CRealMediaSourceFilter>();
+ pFGF->m_chkbytes.AddTail(_T("0,4,,2E524D46"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_DSM
- if (src[SRC_DSM]) {
- pFGF = DNew CFGFilterInternal<CDSMSourceFilter>();
- pFGF->m_chkbytes.AddTail(_T("0,4,,44534D53"));
- m_source.AddTail(pFGF);
- }
+ if (src[SRC_DSM]) {
+ pFGF = DNew CFGFilterInternal<CDSMSourceFilter>();
+ pFGF->m_chkbytes.AddTail(_T("0,4,,44534D53"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_FLIC
- if (src[SRC_FLIC]) {
- pFGF = DNew CFGFilterInternal<CFLICSource>();
- pFGF->m_chkbytes.AddTail(_T("4,2,,11AF"));
- pFGF->m_chkbytes.AddTail(_T("4,2,,12AF"));
- pFGF->m_extensions.AddTail(_T(".fli"));
- pFGF->m_extensions.AddTail(_T(".flc"));
- m_source.AddTail(pFGF);
- }
+ if (src[SRC_FLIC]) {
+ pFGF = DNew CFGFilterInternal<CFLICSource>();
+ pFGF->m_chkbytes.AddTail(_T("4,2,,11AF"));
+ pFGF->m_chkbytes.AddTail(_T("4,2,,12AF"));
+ pFGF->m_extensions.AddTail(_T(".fli"));
+ pFGF->m_extensions.AddTail(_T(".flc"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_FLAC
- if (src[SRC_FLAC]) {
- pFGF = DNew CFGFilterInternal<CFLACSource>();
- pFGF->m_chkbytes.AddTail(_T("0,4,,664C6143"));
- pFGF->m_extensions.AddTail(_T(".flac"));
- m_source.AddTail(pFGF);
- }
+ if (src[SRC_FLAC]) {
+ pFGF = DNew CFGFilterInternal<CFLACSource>();
+ pFGF->m_chkbytes.AddTail(_T("0,4,,664C6143"));
+ pFGF->m_extensions.AddTail(_T(".flac"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_CDDA
- if (src[SRC_CDDA]) {
- pFGF = DNew CFGFilterInternal<CCDDAReader>();
- pFGF->m_extensions.AddTail(_T(".cda"));
- m_source.AddTail(pFGF);
- }
+ if (src[SRC_CDDA]) {
+ pFGF = DNew CFGFilterInternal<CCDDAReader>();
+ pFGF->m_extensions.AddTail(_T(".cda"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_CDXA
- if (src[SRC_CDXA]) {
- pFGF = DNew CFGFilterInternal<CCDXAReader>();
- pFGF->m_chkbytes.AddTail(_T("0,4,,52494646,8,4,,43445841"));
- m_source.AddTail(pFGF);
- }
+ if (src[SRC_CDXA]) {
+ pFGF = DNew CFGFilterInternal<CCDXAReader>();
+ pFGF->m_chkbytes.AddTail(_T("0,4,,52494646,8,4,,43445841"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_VTS
- if (src[SRC_VTS]) {
- pFGF = DNew CFGFilterInternal<CVTSReader>();
- pFGF->m_chkbytes.AddTail(_T("0,12,,445644564944454F2D565453"));
- m_source.AddTail(pFGF);
- }
+ if (src[SRC_VTS]) {
+ pFGF = DNew CFGFilterInternal<CVTSReader>();
+ pFGF->m_chkbytes.AddTail(_T("0,12,,445644564944454F2D565453"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_DVSOURCE
- // TODOX64 : fix DVSource internal filter
+ // TODOX64 : fix DVSource internal filter
#ifndef _WIN64
- __if_exists(CD2VSource) {
- if (src[SRC_D2V]) {
- pFGF = DNew CFGFilterInternal<CD2VSource>();
- pFGF->m_chkbytes.AddTail(_T("0,18,,4456443241564950726F6A65637446696C65"));
- pFGF->m_extensions.AddTail(_T(".d2v"));
- m_source.AddTail(pFGF);
- }
- }
+ __if_exists(CD2VSource) {
+ if (src[SRC_D2V]) {
+ pFGF = DNew CFGFilterInternal<CD2VSource>();
+ pFGF->m_chkbytes.AddTail(_T("0,18,,4456443241564950726F6A65637446696C65"));
+ pFGF->m_extensions.AddTail(_T(".d2v"));
+ m_source.AddTail(pFGF);
+ }
+ }
#endif
#endif
#if INTERNAL_SOURCEFILTER_OGG
- if (src[SRC_OGG]) {
- pFGF = DNew CFGFilterInternal<COggSourceFilter>();
- pFGF->m_chkbytes.AddTail(_T("0,4,,4F676753"));
- m_source.AddTail(pFGF);
- }
+ if (src[SRC_OGG]) {
+ pFGF = DNew CFGFilterInternal<COggSourceFilter>();
+ pFGF->m_chkbytes.AddTail(_T("0,4,,4F676753"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_MPEG
- if (src[SRC_MPEG]) {
- pFGF = DNew CFGFilterInternal<CMpegSourceFilter>();
- pFGF->m_chkbytes.AddTail(_T("0,16,FFFFFFFFF100010001800001FFFFFFFF,000001BA2100010001800001000001BB"));
- pFGF->m_chkbytes.AddTail(_T("0,5,FFFFFFFFC0,000001BA40"));
- pFGF->m_chkbytes.AddTail(_T("0,1,,47,188,1,,47,376,1,,47"));
- pFGF->m_chkbytes.AddTail(_T("4,1,,47,196,1,,47,388,1,,47"));
- pFGF->m_chkbytes.AddTail(_T("0,4,,54467263,1660,1,,47"));
- pFGF->m_chkbytes.AddTail(_T("0,8,fffffc00ffe00000,4156000055000000"));
- pFGF->m_chkbytes.AddTail(_T("0,8,,4D504C5330323030")); // MPLS0200
- pFGF->m_chkbytes.AddTail(_T("0,8,,4D504C5330313030")); // MPLS0100
- pFGF->m_extensions.AddTail(_T(".ts")); // for some broken .ts
- m_source.AddTail(pFGF);
- }
+ if (src[SRC_MPEG]) {
+ pFGF = DNew CFGFilterInternal<CMpegSourceFilter>();
+ pFGF->m_chkbytes.AddTail(_T("0,16,FFFFFFFFF100010001800001FFFFFFFF,000001BA2100010001800001000001BB"));
+ pFGF->m_chkbytes.AddTail(_T("0,5,FFFFFFFFC0,000001BA40"));
+ pFGF->m_chkbytes.AddTail(_T("0,1,,47,188,1,,47,376,1,,47"));
+ pFGF->m_chkbytes.AddTail(_T("4,1,,47,196,1,,47,388,1,,47"));
+ pFGF->m_chkbytes.AddTail(_T("0,4,,54467263,1660,1,,47"));
+ pFGF->m_chkbytes.AddTail(_T("0,8,fffffc00ffe00000,4156000055000000"));
+ pFGF->m_chkbytes.AddTail(_T("0,8,,4D504C5330323030")); // MPLS0200
+ pFGF->m_chkbytes.AddTail(_T("0,8,,4D504C5330313030")); // MPLS0100
+ pFGF->m_extensions.AddTail(_T(".ts")); // for some broken .ts
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_DTSAC3
- if (src[SRC_DTSAC3]) {
- pFGF = DNew CFGFilterInternal<CDTSAC3Source>();
- pFGF->m_chkbytes.AddTail(_T("0,4,,7FFE8001")); // DTS
- pFGF->m_chkbytes.AddTail(_T("0,4,,fE7f0180")); // DTS LE
- pFGF->m_chkbytes.AddTail(_T("0,2,,0B77")); // AC3, E-AC3
- pFGF->m_chkbytes.AddTail(_T("0,4,,52494646,8,8,,57415645666D7420"));// RIFFxxxxWAVEfmt_ for DTSWAV
- pFGF->m_chkbytes.AddTail(_T("4,4,,F8726FBB")); // MLP
- pFGF->m_extensions.AddTail(_T(".ac3"));
- pFGF->m_extensions.AddTail(_T(".dts"));
- pFGF->m_extensions.AddTail(_T(".eac3"));
- m_source.AddTail(pFGF);
- }
+ if (src[SRC_DTSAC3]) {
+ pFGF = DNew CFGFilterInternal<CDTSAC3Source>();
+ pFGF->m_chkbytes.AddTail(_T("0,4,,7FFE8001")); // DTS
+ pFGF->m_chkbytes.AddTail(_T("0,4,,fE7f0180")); // DTS LE
+ pFGF->m_chkbytes.AddTail(_T("0,2,,0B77")); // AC3, E-AC3
+ pFGF->m_chkbytes.AddTail(_T("0,4,,52494646,8,8,,57415645666D7420"));// RIFFxxxxWAVEfmt_ for DTSWAV
+ pFGF->m_chkbytes.AddTail(_T("4,4,,F8726FBB")); // MLP
+ pFGF->m_extensions.AddTail(_T(".ac3"));
+ pFGF->m_extensions.AddTail(_T(".dts"));
+ pFGF->m_extensions.AddTail(_T(".eac3"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_MPEGAUDIO
- if (src[SRC_MPA]) {
- pFGF = DNew CFGFilterInternal<CMpaSourceFilter>();
- pFGF->m_chkbytes.AddTail(_T("0,2,FFE0,FFE0"));
- pFGF->m_chkbytes.AddTail(_T("0,10,FFFFFF00000080808080,49443300000000000000"));
- m_source.AddTail(pFGF);
- }
+ if (src[SRC_MPA]) {
+ pFGF = DNew CFGFilterInternal<CMpaSourceFilter>();
+ pFGF->m_chkbytes.AddTail(_T("0,2,FFE0,FFE0"));
+ pFGF->m_chkbytes.AddTail(_T("0,10,FFFFFF00000080808080,49443300000000000000"));
+ m_source.AddTail(pFGF);
+ }
#endif
#if INTERNAL_SOURCEFILTER_AVI2AC3
- // hmmm, shouldn't there be an option in the GUI to enable/disable this filter?
- pFGF = DNew CFGFilterInternal<CAVI2AC3Filter>(AVI2AC3FilterName, MERIT64(0x00680000)+1);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_WAVE_DOLBY_AC3);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_WAVE_DTS);
- m_transform.AddTail(pFGF);
+ // hmmm, shouldn't there be an option in the GUI to enable/disable this filter?
+ pFGF = DNew CFGFilterInternal<CAVI2AC3Filter>(AVI2AC3FilterName, MERIT64(0x00680000) + 1);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_WAVE_DOLBY_AC3);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_WAVE_DTS);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_SOURCEFILTER_MATROSKA
- if (src[SRC_MATROSKA]) {
- pFGF = DNew CFGFilterInternal<CMatroskaSplitterFilter>(MatroskaSplitterName, MERIT64_ABOVE_DSHOW);
- } else {
- pFGF = DNew CFGFilterInternal<CMatroskaSplitterFilter>(LowMerit(MatroskaSplitterName), MERIT64_DO_USE);
- }
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Matroska);
- pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
- m_transform.AddTail(pFGF);
+ if (src[SRC_MATROSKA]) {
+ pFGF = DNew CFGFilterInternal<CMatroskaSplitterFilter>(MatroskaSplitterName, MERIT64_ABOVE_DSHOW);
+ } else {
+ pFGF = DNew CFGFilterInternal<CMatroskaSplitterFilter>(LowMerit(MatroskaSplitterName), MERIT64_DO_USE);
+ }
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Matroska);
+ pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_SOURCEFILTER_REALMEDIA
- if (src[SRC_REALMEDIA]) {
- pFGF = DNew CFGFilterInternal<CRealMediaSplitterFilter>(RMSplitterName, MERIT64_ABOVE_DSHOW);
- } else {
- pFGF = DNew CFGFilterInternal<CRealMediaSplitterFilter>(LowMerit(RMSplitterName), MERIT64_DO_USE);
- }
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_RealMedia);
- pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
- m_transform.AddTail(pFGF);
+ if (src[SRC_REALMEDIA]) {
+ pFGF = DNew CFGFilterInternal<CRealMediaSplitterFilter>(RMSplitterName, MERIT64_ABOVE_DSHOW);
+ } else {
+ pFGF = DNew CFGFilterInternal<CRealMediaSplitterFilter>(LowMerit(RMSplitterName), MERIT64_DO_USE);
+ }
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_RealMedia);
+ pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_SOURCEFILTER_AVI
- if (src[SRC_AVI]) {
- pFGF = DNew CFGFilterInternal<CAviSplitterFilter>(AviSplitterName, MERIT64_ABOVE_DSHOW);
- } else {
- pFGF = DNew CFGFilterInternal<CAviSplitterFilter>(LowMerit(AviSplitterName), MERIT64_DO_USE);
- }
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Avi);
- pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
- m_transform.AddTail(pFGF);
+ if (src[SRC_AVI]) {
+ pFGF = DNew CFGFilterInternal<CAviSplitterFilter>(AviSplitterName, MERIT64_ABOVE_DSHOW);
+ } else {
+ pFGF = DNew CFGFilterInternal<CAviSplitterFilter>(LowMerit(AviSplitterName), MERIT64_DO_USE);
+ }
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Avi);
+ pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_SOURCEFILTER_OGG
- if (src[SRC_OGG]) {
- pFGF = DNew CFGFilterInternal<COggSplitterFilter>(OggSplitterName, MERIT64_ABOVE_DSHOW);
- } else {
- pFGF = DNew CFGFilterInternal<COggSplitterFilter>(LowMerit(OggSplitterName), MERIT64_DO_USE);
- }
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Ogg);
- pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
- m_transform.AddTail(pFGF);
+ if (src[SRC_OGG]) {
+ pFGF = DNew CFGFilterInternal<COggSplitterFilter>(OggSplitterName, MERIT64_ABOVE_DSHOW);
+ } else {
+ pFGF = DNew CFGFilterInternal<COggSplitterFilter>(LowMerit(OggSplitterName), MERIT64_DO_USE);
+ }
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Ogg);
+ pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_SOURCEFILTER_MPEG
- if (src[SRC_MPEG]) {
- pFGF = DNew CFGFilterInternal<CMpegSplitterFilter>(MpegSplitterName, MERIT64_ABOVE_DSHOW);
- } else {
- pFGF = DNew CFGFilterInternal<CMpegSplitterFilter>(LowMerit(MpegSplitterName), MERIT64_DO_USE);
- }
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MPEG1System);
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MPEG2_PROGRAM);
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MPEG2_TRANSPORT);
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MPEG2_PVA);
- pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
- m_transform.AddTail(pFGF);
+ if (src[SRC_MPEG]) {
+ pFGF = DNew CFGFilterInternal<CMpegSplitterFilter>(MpegSplitterName, MERIT64_ABOVE_DSHOW);
+ } else {
+ pFGF = DNew CFGFilterInternal<CMpegSplitterFilter>(LowMerit(MpegSplitterName), MERIT64_DO_USE);
+ }
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MPEG1System);
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MPEG2_PROGRAM);
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MPEG2_TRANSPORT);
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MPEG2_PVA);
+ pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_SOURCEFILTER_MPEGAUDIO
- if (src[SRC_MPA]) {
- pFGF = DNew CFGFilterInternal<CMpaSplitterFilter>(MpaSplitterName, MERIT64_ABOVE_DSHOW);
- } else {
- pFGF = DNew CFGFilterInternal<CMpaSplitterFilter>(LowMerit(MpaSplitterName), MERIT64_DO_USE);
- }
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MPEG1Audio);
- pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
- m_transform.AddTail(pFGF);
+ if (src[SRC_MPA]) {
+ pFGF = DNew CFGFilterInternal<CMpaSplitterFilter>(MpaSplitterName, MERIT64_ABOVE_DSHOW);
+ } else {
+ pFGF = DNew CFGFilterInternal<CMpaSplitterFilter>(LowMerit(MpaSplitterName), MERIT64_DO_USE);
+ }
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MPEG1Audio);
+ pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_SOURCEFILTER_DSM
- if (src[SRC_DSM]) {
- pFGF = DNew CFGFilterInternal<CDSMSplitterFilter>(DSMSplitterName, MERIT64_ABOVE_DSHOW);
- } else {
- pFGF = DNew CFGFilterInternal<CDSMSplitterFilter>(LowMerit(DSMSplitterName), MERIT64_DO_USE);
- }
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_DirectShowMedia);
- pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
- m_transform.AddTail(pFGF);
+ if (src[SRC_DSM]) {
+ pFGF = DNew CFGFilterInternal<CDSMSplitterFilter>(DSMSplitterName, MERIT64_ABOVE_DSHOW);
+ } else {
+ pFGF = DNew CFGFilterInternal<CDSMSplitterFilter>(LowMerit(DSMSplitterName), MERIT64_DO_USE);
+ }
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_DirectShowMedia);
+ pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_SOURCEFILTER_MP4
- if (src[SRC_MP4]) {
- pFGF = DNew CFGFilterInternal<CMP4SplitterFilter>(MP4SplitterName, MERIT64_ABOVE_DSHOW);
- } else {
- pFGF = DNew CFGFilterInternal<CMP4SplitterFilter>(LowMerit(MP4SplitterName), MERIT64_DO_USE);
- }
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MP4);
- pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
- m_transform.AddTail(pFGF);
+ if (src[SRC_MP4]) {
+ pFGF = DNew CFGFilterInternal<CMP4SplitterFilter>(MP4SplitterName, MERIT64_ABOVE_DSHOW);
+ } else {
+ pFGF = DNew CFGFilterInternal<CMP4SplitterFilter>(LowMerit(MP4SplitterName), MERIT64_DO_USE);
+ }
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MP4);
+ pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_SOURCEFILTER_FLV
- if (src[SRC_FLV]) {
- pFGF = DNew CFGFilterInternal<CFLVSplitterFilter>(FlvSplitterName, MERIT64_ABOVE_DSHOW);
- } else {
- pFGF = DNew CFGFilterInternal<CFLVSplitterFilter>(LowMerit(FlvSplitterName), MERIT64_DO_USE);
- }
- pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_FLV);
- pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
- m_transform.AddTail(pFGF);
+ if (src[SRC_FLV]) {
+ pFGF = DNew CFGFilterInternal<CFLVSplitterFilter>(FlvSplitterName, MERIT64_ABOVE_DSHOW);
+ } else {
+ pFGF = DNew CFGFilterInternal<CFLVSplitterFilter>(LowMerit(FlvSplitterName), MERIT64_DO_USE);
+ }
+ pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_FLV);
+ pFGF->AddType(MEDIATYPE_Stream, GUID_NULL);
+ m_transform.AddTail(pFGF);
#endif
- // Transform filters
+ // Transform filters
#if INTERNAL_DECODER_MPEG1
- pFGF = DNew CFGFilterInternal<CMpeg2DecFilter>(
- (tra[TRA_MPEG1]) ? Mpeg2DecFilterName : Mpeg2DecFilterName,
- (tra[TRA_MPEG1]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPEG1Packet);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPEG1Payload);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CMpeg2DecFilter>(
+ (tra[TRA_MPEG1]) ? Mpeg2DecFilterName : Mpeg2DecFilterName,
+ (tra[TRA_MPEG1]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPEG1Packet);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPEG1Payload);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_MPEGAUDIO
- pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
- (tra[TRA_MPA]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
- (tra[TRA_MPA]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MP3);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MPEG1AudioPayload);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MPEG1Payload);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MPEG1Packet);
- m_transform.AddTail(pFGF);
-
- pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
- (tra[TRA_MPA]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
- (tra[TRA_MPA]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_MPEG2_AUDIO);
- pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_MPEG2_AUDIO);
- pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_MPEG2_AUDIO);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MPEG2_AUDIO);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
+ (tra[TRA_MPA]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
+ (tra[TRA_MPA]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MP3);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MPEG1AudioPayload);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MPEG1Payload);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MPEG1Packet);
+ m_transform.AddTail(pFGF);
+
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
+ (tra[TRA_MPA]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
+ (tra[TRA_MPA]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_MPEG2_AUDIO);
+ pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_MPEG2_AUDIO);
+ pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_MPEG2_AUDIO);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MPEG2_AUDIO);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_AMR
- pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
- (tra[TRA_AMR]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
- (tra[TRA_AMR]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_SAMR);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_AMR);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_SAWB);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
+ (tra[TRA_AMR]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
+ (tra[TRA_AMR]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_SAMR);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_AMR);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_SAWB);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_LPCM
- pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
- (tra[TRA_LPCM]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
- (tra[TRA_LPCM]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_DVD_LPCM_AUDIO);
- pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_DVD_LPCM_AUDIO);
- pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_DVD_LPCM_AUDIO);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_DVD_LPCM_AUDIO);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_HDMV_LPCM_AUDIO);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
+ (tra[TRA_LPCM]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
+ (tra[TRA_LPCM]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_DVD_LPCM_AUDIO);
+ pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_DVD_LPCM_AUDIO);
+ pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_DVD_LPCM_AUDIO);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_DVD_LPCM_AUDIO);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_HDMV_LPCM_AUDIO);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_AC3
- pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
- (tra[TRA_AC3]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
- (tra[TRA_AC3]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_DOLBY_AC3);
- pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_DOLBY_AC3);
- pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_DOLBY_AC3);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_DOLBY_AC3);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_WAVE_DOLBY_AC3);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_DOLBY_TRUEHD);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_DOLBY_DDPLUS);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MLP);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
+ (tra[TRA_AC3]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
+ (tra[TRA_AC3]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_DOLBY_AC3);
+ pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_DOLBY_AC3);
+ pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_DOLBY_AC3);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_DOLBY_AC3);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_WAVE_DOLBY_AC3);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_DOLBY_TRUEHD);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_DOLBY_DDPLUS);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MLP);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_DTS
- pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
- (tra[TRA_DTS]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
- (tra[TRA_DTS]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_DTS);
- pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_DTS);
- pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_DTS);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_DTS);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_WAVE_DTS);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
+ (tra[TRA_DTS]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
+ (tra[TRA_DTS]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_DTS);
+ pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_DTS);
+ pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_DTS);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_DTS);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_WAVE_DTS);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_AAC
- pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
- (tra[TRA_AAC]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
- (tra[TRA_AAC]) ? MERIT64_ABOVE_DSHOW+1 : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_AAC);
- pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_AAC);
- pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_AAC);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_AAC);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_LATM_AAC);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_AAC_ADTS);
- pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_MP4A);
- pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_MP4A);
- pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_MP4A);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MP4A);
- pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_mp4a);
- pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_mp4a);
- pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_mp4a);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_mp4a);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
+ (tra[TRA_AAC]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
+ (tra[TRA_AAC]) ? MERIT64_ABOVE_DSHOW + 1 : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_AAC);
+ pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_AAC);
+ pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_AAC);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_AAC);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_LATM_AAC);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_AAC_ADTS);
+ pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_MP4A);
+ pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_MP4A);
+ pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_MP4A);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_MP4A);
+ pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_mp4a);
+ pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_mp4a);
+ pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_mp4a);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_mp4a);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_PS2AUDIO
- pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
- (tra[TRA_PS2AUD]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
- (tra[TRA_PS2AUD]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_PS2_PCM);
- pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_PS2_PCM);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_PS2_PCM);
- pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_PS2_ADPCM);
- pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_PS2_ADPCM);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_PS2_ADPCM);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
+ (tra[TRA_PS2AUD]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
+ (tra[TRA_PS2AUD]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_PS2_PCM);
+ pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_PS2_PCM);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_PS2_PCM);
+ pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_PS2_ADPCM);
+ pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_PS2_ADPCM);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_PS2_ADPCM);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_REALVIDEO
- pFGF = DNew CFGFilterInternal<CRealVideoDecoder>(
- (tra[TRA_RV]) ? RMVideoDecoderName : LowMerit(RMVideoDecoderName),
- (tra[TRA_RV]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RV10);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RV20);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RV30);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RV40);
- m_transform.AddTail(pFGF);
-
- pFGF = DNew CFGFilterInternal<CMPCVideoDecFilter>(
- (tra[TRA_RV]) ? MPCVideoDecName : LowMerit(MPCVideoDecName),
- (tra[TRA_RV]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RV10);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RV20);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RV30);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RV40);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CRealVideoDecoder>(
+ (tra[TRA_RV]) ? RMVideoDecoderName : LowMerit(RMVideoDecoderName),
+ (tra[TRA_RV]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RV10);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RV20);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RV30);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RV40);
+ m_transform.AddTail(pFGF);
+
+ pFGF = DNew CFGFilterInternal<CMPCVideoDecFilter>(
+ (tra[TRA_RV]) ? MPCVideoDecName : LowMerit(MPCVideoDecName),
+ (tra[TRA_RV]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RV10);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RV20);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RV30);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RV40);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_REALAUDIO
- pFGF = DNew CFGFilterInternal<CRealAudioDecoder>(
- (tra[TRA_RA]) ? RMAudioDecoderName : LowMerit(RMAudioDecoderName),
- (tra[TRA_RA]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_14_4);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_28_8);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_ATRC);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_COOK);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_DNET);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_SIPR);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_RAAC);
- m_transform.AddTail(pFGF);
-
- pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
- (tra[TRA_RA]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
- (tra[TRA_RA]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_14_4);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_28_8);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_ATRC);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_COOK);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_DNET);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_SIPR);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_RAAC);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_RACP);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CRealAudioDecoder>(
+ (tra[TRA_RA]) ? RMAudioDecoderName : LowMerit(RMAudioDecoderName),
+ (tra[TRA_RA]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_14_4);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_28_8);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_ATRC);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_COOK);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_DNET);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_SIPR);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_RAAC);
+ m_transform.AddTail(pFGF);
+
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
+ (tra[TRA_RA]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
+ (tra[TRA_RA]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_14_4);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_28_8);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_ATRC);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_COOK);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_DNET);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_SIPR);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_RAAC);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_RACP);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_VORBIS
- pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
- (tra[TRA_VORBIS]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
- (tra[TRA_VORBIS]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_Vorbis2);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
+ (tra[TRA_VORBIS]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
+ (tra[TRA_VORBIS]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_Vorbis2);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_FLAC
- pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
- (tra[TRA_FLAC]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
- (tra[TRA_FLAC]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_FLAC_FRAMED);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
+ (tra[TRA_FLAC]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
+ (tra[TRA_FLAC]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_FLAC_FRAMED);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_NELLYMOSER
- pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
- (tra[TRA_NELLY]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
- (tra[TRA_NELLY]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NELLYMOSER);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
+ (tra[TRA_NELLY]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
+ (tra[TRA_NELLY]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NELLYMOSER);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_ALAC
- pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
- (tra[TRA_ALAC]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
- (tra[TRA_ALAC]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_ALAC);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
+ (tra[TRA_ALAC]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
+ (tra[TRA_ALAC]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_ALAC);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_ALS
- pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
- (tra[TRA_ALS]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
- (tra[TRA_ALS]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_ALS);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
+ (tra[TRA_ALS]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
+ (tra[TRA_ALS]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_ALS);
+ m_transform.AddTail(pFGF);
#endif
#if INTERNAL_DECODER_PCM
- pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
- (tra[TRA_PCM]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
- (tra[TRA_PCM]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_PCM_NONE);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_PCM_RAW);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_PCM_TWOS);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_PCM_SOWT);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_PCM_IN24);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_PCM_IN32);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_PCM_FL32);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_PCM_FL64);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_IEEE_FLOAT); // only for 64-bit float PCM
- /* todo: this should not depend on PCM */
+ pFGF = DNew CFGFilterInternal<CMpaDecFilter>(
+ (tra[TRA_PCM]) ? MPCAudioDecName : LowMerit(MPCAudioDecName),
+ (tra[TRA_PCM]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_PCM_NONE);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_PCM_RAW);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_PCM_TWOS);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_PCM_SOWT);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_PCM_IN24);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_PCM_IN32);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_PCM_FL32);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_PCM_FL64);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_IEEE_FLOAT); // only for 64-bit float PCM
+ /* todo: this should not depend on PCM */
#if INTERNAL_DECODER_ADPCM
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_IMA4);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_ADPCM_SWF);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_ADPCM_AMV);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_IMA4);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_ADPCM_SWF);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_ADPCM_AMV);
#endif
- m_transform.AddTail(pFGF);
+ m_transform.AddTail(pFGF);
#endif
- pFGF = DNew CFGFilterInternal<CNullTextRenderer>(L"NullTextRenderer", MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_Text, MEDIASUBTYPE_NULL);
- pFGF->AddType(MEDIATYPE_ScriptCommand, MEDIASUBTYPE_NULL);
- pFGF->AddType(MEDIATYPE_Subtitle, MEDIASUBTYPE_NULL);
- pFGF->AddType(MEDIATYPE_Text, MEDIASUBTYPE_NULL);
- pFGF->AddType(MEDIATYPE_NULL, MEDIASUBTYPE_DVD_SUBPICTURE);
- pFGF->AddType(MEDIATYPE_NULL, MEDIASUBTYPE_CVD_SUBPICTURE);
- pFGF->AddType(MEDIATYPE_NULL, MEDIASUBTYPE_SVCD_SUBPICTURE);
- m_transform.AddTail(pFGF);
+ pFGF = DNew CFGFilterInternal<CNullTextRenderer>(L"NullTextRenderer", MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_Text, MEDIASUBTYPE_NULL);
+ pFGF->AddType(MEDIATYPE_ScriptCommand, MEDIASUBTYPE_NULL);
+ pFGF->AddType(MEDIATYPE_Subtitle, MEDIASUBTYPE_NULL);
+ pFGF->AddType(MEDIATYPE_Text, MEDIASUBTYPE_NULL);
+ pFGF->AddType(MEDIATYPE_NULL, MEDIASUBTYPE_DVD_SUBPICTURE);
+ pFGF->AddType(MEDIATYPE_NULL, MEDIASUBTYPE_CVD_SUBPICTURE);
+ pFGF->AddType(MEDIATYPE_NULL, MEDIASUBTYPE_SVCD_SUBPICTURE);
+ m_transform.AddTail(pFGF);
- // High merit MPC Video Decoder
+ // High merit MPC Video Decoder
#if HAS_FFMPEG_VIDEO_DECODERS || HAS_DXVA_VIDEO_DECODERS
- pFGF = DNew CFGFilterInternal<CMPCVideoDecFilter>(MPCVideoDecName, MERIT64_ABOVE_DSHOW);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_TSCC);
+ pFGF = DNew CFGFilterInternal<CMPCVideoDecFilter>(MPCVideoDecName, MERIT64_ABOVE_DSHOW);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_TSCC);
#if INTERNAL_DECODER_FLV
- if (ffmpeg_filters[FFM_FLV4]) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FLV1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_flv1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FLV4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_flv4);
- }
+ if (ffmpeg_filters[FFM_FLV4]) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FLV1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_flv1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FLV4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_flv4);
+ }
#endif
#if INTERNAL_DECODER_VP356
- if (ffmpeg_filters[FFM_VP356]) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP30);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP31);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP50);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp50);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP60);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp60);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP61);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp61);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP62);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp62);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP6F);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp6f);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP6A);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp6a);
- }
+ if (ffmpeg_filters[FFM_VP356]) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP30);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP31);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP50);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp50);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP60);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp60);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP61);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp61);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP62);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp62);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP6F);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp6f);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP6A);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp6a);
+ }
#endif
#if INTERNAL_DECODER_H264 | INTERNAL_DECODER_H264_DXVA
- if ((ffmpeg_filters[FFM_H264]) || (dxva_filters[TRA_DXVA_H264])) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H264);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_h264);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_X264);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_x264);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VSSH);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vssh);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DAVC);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_davc);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_PAVC);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_pavc);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AVC1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_avc1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H264_bis);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_CCV1);
- }
+ if ((ffmpeg_filters[FFM_H264]) || (dxva_filters[TRA_DXVA_H264])) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H264);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_h264);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_X264);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_x264);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VSSH);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vssh);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DAVC);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_davc);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_PAVC);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_pavc);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AVC1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_avc1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H264_bis);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_CCV1);
+ }
#endif
#if INTERNAL_DECODER_MPEG2_DXVA
- if (dxva_filters[TRA_DXVA_MPEG2]) {
- pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
- pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
- pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_MPEG2_VIDEO);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPEG2_VIDEO);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPG2);
- }
+ if (dxva_filters[TRA_DXVA_MPEG2]) {
+ pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
+ pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
+ pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_MPEG2_VIDEO);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPEG2_VIDEO);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPG2);
+ }
#endif
#if INTERNAL_DECODER_VC1 | INTERNAL_DECODER_VC1_DXVA
- if ((ffmpeg_filters[FFM_VC1]) || (dxva_filters[TRA_DXVA_VC1])) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WVC1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wvc1);
- }
+ if ((ffmpeg_filters[FFM_VC1]) || (dxva_filters[TRA_DXVA_VC1])) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WVC1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wvc1);
+ }
#endif
#if INTERNAL_DECODER_XVID
- if (ffmpeg_filters[FFM_XVID]) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_XVID);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_xvid);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_XVIX);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_xvix);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP4V);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp4v);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_M4S2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_m4s2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP4S);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp4s);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3IV1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3iv1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3IV2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3iv2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3IVX);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3ivx);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_BLZ0);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_blz0);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DM4V);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dm4v);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DXGM);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dxgm);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FMP4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_fmp4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_HDX4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_hdx4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_LMP4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_lmp4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_NDIG);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_ndig);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RMP4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_rmp4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SMP4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_smp4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SEDG);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_sedg);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_UMP4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_ump4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WV1F);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wv1f);
- }
+ if (ffmpeg_filters[FFM_XVID]) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_XVID);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_xvid);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_XVIX);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_xvix);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP4V);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp4v);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_M4S2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_m4s2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP4S);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp4s);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3IV1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3iv1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3IV2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3iv2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3IVX);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3ivx);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_BLZ0);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_blz0);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DM4V);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dm4v);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DXGM);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dxgm);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FMP4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_fmp4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_HDX4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_hdx4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_LMP4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_lmp4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_NDIG);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_ndig);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RMP4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_rmp4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SMP4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_smp4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SEDG);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_sedg);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_UMP4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_ump4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WV1F);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wv1f);
+ }
#endif
#if INTERNAL_DECODER_DIVX
- if (ffmpeg_filters[FFM_DIVX]) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIVX);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_divx);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DX50);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dx50);
- }
+ if (ffmpeg_filters[FFM_DIVX]) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIVX);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_divx);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DX50);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dx50);
+ }
#endif
#if INTERNAL_DECODER_WMV
- if (ffmpeg_filters[FFM_WMV]) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wmv1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wmv2);
- }
+ if (ffmpeg_filters[FFM_WMV]) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wmv1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wmv2);
+ }
#endif
#if INTERNAL_DECODER_WMV || INTERNAL_DECODER_WMV3_DXVA
- if ((ffmpeg_filters[FFM_WMV]) || (dxva_filters[TRA_DXVA_WMV3])) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wmv3);
- }
+ if ((ffmpeg_filters[FFM_WMV]) || (dxva_filters[TRA_DXVA_WMV3])) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wmv3);
+ }
#endif
#if INTERNAL_DECODER_MSMPEG4
- if (ffmpeg_filters[FFM_MSMPEG4]) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DVX3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dvx3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP43);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp43);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_COL1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_col1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV5);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div5);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV6);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div6);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AP41);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_ap41);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPG3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mpg3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP42);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp42);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPG4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mpg4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP41);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp41);
- }
+ if (ffmpeg_filters[FFM_MSMPEG4]) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DVX3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dvx3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP43);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp43);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_COL1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_col1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV5);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div5);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV6);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div6);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AP41);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_ap41);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPG3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mpg3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP42);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp42);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPG4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mpg4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP41);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp41);
+ }
#endif
#if INTERNAL_DECODER_SVQ
- if (ffmpeg_filters[FFM_SVQ3]) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SVQ3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SVQ1);
- }
+ if (ffmpeg_filters[FFM_SVQ3]) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SVQ3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SVQ1);
+ }
#endif
#if INTERNAL_DECODER_H263
- if (ffmpeg_filters[FFM_H263]) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H263);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_h263);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_S263);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_s263);
- }
+ if (ffmpeg_filters[FFM_H263]) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H263);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_h263);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_S263);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_s263);
+ }
#endif
#if INTERNAL_DECODER_THEORA
- if (ffmpeg_filters[FFM_THEORA]) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_THEORA);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_theora);
- }
+ if (ffmpeg_filters[FFM_THEORA]) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_THEORA);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_theora);
+ }
#endif
#if INTERNAL_DECODER_AMVV
- if (ffmpeg_filters[FFM_AMVV]) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AMVV);
- }
+ if (ffmpeg_filters[FFM_AMVV]) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AMVV);
+ }
#endif
#if INTERNAL_DECODER_VP8
- if (ffmpeg_filters[FFM_VP8]) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP80);
- }
+ if (ffmpeg_filters[FFM_VP8]) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP80);
+ }
#endif
#if INTERNAL_DECODER_MJPEG
- if (ffmpeg_filters[FFM_MJPEG]) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MJPG);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_QTJpeg);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MJPA);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MJPB);
- }
+ if (ffmpeg_filters[FFM_MJPEG]) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MJPG);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_QTJpeg);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MJPA);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MJPB);
+ }
#endif
#if INTERNAL_DECODER_INDEO
- if (ffmpeg_filters[FFM_INDEO]) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_IV31);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_IV32);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_IV41);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_IV50);
- }
-#endif
- m_transform.AddTail(pFGF);
+ if (ffmpeg_filters[FFM_INDEO]) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_IV31);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_IV32);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_IV41);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_IV50);
+ }
+#endif
+ m_transform.AddTail(pFGF);
#endif /* #if HAS_FFMPEG_VIDEO_DECODERS || HAS_DXVA_VIDEO_DECODERS */
#if HAS_FFMPEG_VIDEO_DECODERS || HAS_DXVA_VIDEO_DECODERS
- CMPCVideoDecFilter::FFmpegFilters = (HAS_FFMPEG_DECODERS) ? s.FFmpegFilters : NULL;
- CMPCVideoDecFilter::DXVAFilters = (HAS_DXVA_VIDEO_DECODERS) ? s.DXVAFilters : NULL;
+ CMPCVideoDecFilter::FFmpegFilters = (HAS_FFMPEG_DECODERS) ? s.FFmpegFilters : NULL;
+ CMPCVideoDecFilter::DXVAFilters = (HAS_DXVA_VIDEO_DECODERS) ? s.DXVAFilters : NULL;
#endif
#if 0 /* low merit instance doesn't work because the values in array CMPCVideoDecFilter::FFmpegFilters/DXVAFilters are 0 when formats are disabled in normal merit filter */
#if HAS_FFMPEG_VIDEO_DECODERS || HAS_DXVA_VIDEO_DECODERS
- // Low merit MPC Video Decoder
- pFGF = DNew CFGFilterInternal<CMPCVideoDecFilter>(LowMerit(MPCVideoDecName), MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_TSCC);
+ // Low merit MPC Video Decoder
+ pFGF = DNew CFGFilterInternal<CMPCVideoDecFilter>(LowMerit(MPCVideoDecName), MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_TSCC);
#if INTERNAL_DECODER_FLV
- if (!(ffmpeg_filters[FFM_FLV4])) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FLV1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_flv1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FLV4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_flv4);
- }
+ if (!(ffmpeg_filters[FFM_FLV4])) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FLV1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_flv1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FLV4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_flv4);
+ }
#endif
#if INTERNAL_DECODER_VP356
- if (!(ffmpeg_filters[FFM_VP356])) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP30);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP31);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP50);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp50);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP60);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp60);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP61);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp61);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP62);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp62);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP6F);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp6f);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP6A);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp6a);
- }
+ if (!(ffmpeg_filters[FFM_VP356])) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP30);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP31);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP50);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp50);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP60);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp60);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP61);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp61);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP62);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp62);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP6F);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp6f);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP6A);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp6a);
+ }
#endif
#if INTERNAL_DECODER_H264 | INTERNAL_DECODER_H264_DXVA
- if (!(ffmpeg_filters[FFM_H264]) && !(dxva_filters[TRA_DXVA_H264])) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H264);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_h264);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_X264);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_x264);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VSSH);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vssh);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DAVC);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_davc);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_PAVC);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_pavc);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AVC1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_avc1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H264_bis);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_CCV1);
- }
+ if (!(ffmpeg_filters[FFM_H264]) && !(dxva_filters[TRA_DXVA_H264])) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H264);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_h264);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_X264);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_x264);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VSSH);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vssh);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DAVC);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_davc);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_PAVC);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_pavc);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AVC1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_avc1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H264_bis);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_CCV1);
+ }
#endif
#if INTERNAL_DECODER_MPEG2_DXVA
- if (!(dxva_filters[TRA_DXVA_MPEG2])) {
- pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
- pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
- pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_MPEG2_VIDEO);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPEG2_VIDEO);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPG2);
- }
+ if (!(dxva_filters[TRA_DXVA_MPEG2])) {
+ pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
+ pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
+ pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_MPEG2_VIDEO);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPEG2_VIDEO);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPG2);
+ }
#endif
#if INTERNAL_DECODER_VC1 | INTERNAL_DECODER_VC1_DXVA
- if (!(ffmpeg_filters[FFM_VC1]) && !(dxva_filters[TRA_DXVA_VC1])) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WVC1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wvc1);
- }
+ if (!(ffmpeg_filters[FFM_VC1]) && !(dxva_filters[TRA_DXVA_VC1])) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WVC1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wvc1);
+ }
#endif
#if INTERNAL_DECODER_XVID
- if (!(ffmpeg_filters[FFM_XVID])) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_XVID);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_xvid);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_XVIX);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_xvix);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP4V);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp4v);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_M4S2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_m4s2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP4S);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp4s);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3IV1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3iv1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3IV2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3iv2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3IVX);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3ivx);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_BLZ0);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_blz0);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DM4V);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dm4v);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DXGM);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dxgm);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FMP4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_fmp4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_HDX4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_hdx4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_LMP4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_lmp4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_NDIG);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_ndig);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RMP4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_rmp4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SMP4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_smp4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SEDG);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_sedg);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_UMP4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_ump4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WV1F);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wv1f);
- }
+ if (!(ffmpeg_filters[FFM_XVID])) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_XVID);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_xvid);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_XVIX);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_xvix);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP4V);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp4v);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_M4S2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_m4s2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP4S);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp4s);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3IV1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3iv1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3IV2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3iv2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3IVX);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_3ivx);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_BLZ0);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_blz0);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DM4V);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dm4v);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DXGM);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dxgm);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FMP4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_fmp4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_HDX4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_hdx4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_LMP4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_lmp4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_NDIG);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_ndig);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_RMP4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_rmp4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SMP4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_smp4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SEDG);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_sedg);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_UMP4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_ump4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WV1F);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wv1f);
+ }
#endif
#if INTERNAL_DECODER_DIVX
- if (!(ffmpeg_filters[FFM_DIVX])) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIVX);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_divx);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DX50);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dx50);
- }
+ if (!(ffmpeg_filters[FFM_DIVX])) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIVX);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_divx);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DX50);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dx50);
+ }
#endif
#if INTERNAL_DECODER_WMV
- if (!(ffmpeg_filters[FFM_WMV])) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wmv1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wmv2);
- }
+ if (!(ffmpeg_filters[FFM_WMV])) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wmv1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wmv2);
+ }
#endif
#if INTERNAL_DECODER_WMV | INTERNAL_DECODER_WMV3_DXVA
- if ((ffmpeg_filters[FFM_WMV]) || (dxva_filters[TRA_DXVA_WMV3])) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wmv3);
- }
+ if ((ffmpeg_filters[FFM_WMV]) || (dxva_filters[TRA_DXVA_WMV3])) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wmv3);
+ }
#endif
#if INTERNAL_DECODER_MSMPEG4
- if (!(ffmpeg_filters[FFM_MSMPEG4])) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DVX3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dvx3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP43);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp43);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_COL1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_col1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV5);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div5);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV6);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div6);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AP41);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_ap41);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPG3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mpg3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP42);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp42);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPG4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mpg4);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP41);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp41);
- }
+ if (!(ffmpeg_filters[FFM_MSMPEG4])) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DVX3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_dvx3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP43);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp43);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_COL1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_col1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV5);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div5);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV6);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div6);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AP41);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_ap41);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPG3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mpg3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP42);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp42);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPG4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mpg4);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MP41);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_mp41);
+ }
#endif
#if INTERNAL_DECODER_SVQ
- if (!(ffmpeg_filters[FFM_SVQ3])) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SVQ3);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SVQ1);
- }
+ if (!(ffmpeg_filters[FFM_SVQ3])) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SVQ3);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_SVQ1);
+ }
#endif
#if INTERNAL_DECODER_H263
- if (!(ffmpeg_filters[FFM_H263])) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H263);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_h263);
- }
+ if (!(ffmpeg_filters[FFM_H263])) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H263);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_h263);
+ }
#endif
#if INTERNAL_DECODER_THEORA
- if (!(ffmpeg_filters[FFM_THEORA])) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_THEORA);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_theora);
- }
+ if (!(ffmpeg_filters[FFM_THEORA])) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_THEORA);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_theora);
+ }
#endif
#if INTERNAL_DECODER_AMVV
- if (!(ffmpeg_filters[FFM_AMVV])) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AMVV);
- }
+ if (!(ffmpeg_filters[FFM_AMVV])) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AMVV);
+ }
#endif
#if INTERNAL_DECODER_VP8
- if (!(ffmpeg_filters[FFM_VP8])) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP80);
- }
+ if (!(ffmpeg_filters[FFM_VP8])) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP80);
+ }
#endif
#if INTERNAL_DECODER_MJPEG
- if (ffmpeg_filters[FFM_MJPEG]) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MJPG);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_QTJpeg);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MJPA);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MJPB);
- }
+ if (ffmpeg_filters[FFM_MJPEG]) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MJPG);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_QTJpeg);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MJPA);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MJPB);
+ }
#endif
#if INTERNAL_DECODER_INDEO
- if (ffmpeg_filters[FFM_INDEO]) {
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_IV31);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_IV32);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_IV41);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_IV50);
- }
-#endif
- m_transform.AddTail(pFGF);
+ if (ffmpeg_filters[FFM_INDEO]) {
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_IV31);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_IV32);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_IV41);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_IV50);
+ }
+#endif
+ m_transform.AddTail(pFGF);
#endif /* HAS_FFMPEG_VIDEO_DECODERS || HAS_DXVA_VIDEO_DECODERS */
#endif /* 0 */
#if INTERNAL_DECODER_MPEG2
- // Keep software decoder after DXVA decoder !
- pFGF = DNew CFGFilterInternal<CMpeg2DecFilter>(
- (tra[TRA_MPEG2]) ? Mpeg2DecFilterName : LowMerit(Mpeg2DecFilterName),
- (tra[TRA_MPEG2]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
- pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
- pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
- pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_MPEG2_VIDEO);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPEG2_VIDEO);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPG2);
- m_transform.AddTail(pFGF);
-#endif
-
- // Blocked filters
-
- // "Subtitle Mixer" makes an access violation around the
- // 11-12th media type when enumerating them on its output.
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{00A95963-3BE5-48C0-AD9F-3356D67EA09D}")), MERIT64_DO_NOT_USE));
-
- // DiracSplitter.ax is crashing MPC-HC when opening invalid files...
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{09E7F58E-71A1-419D-B0A0-E524AE1454A9}")), MERIT64_DO_NOT_USE));
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{5899CFB9-948F-4869-A999-5544ECB38BA5}")), MERIT64_DO_NOT_USE));
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{F78CF248-180E-4713-B107-B13F7B5C31E1}")), MERIT64_DO_NOT_USE));
-
- // ISCR suxx
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{48025243-2D39-11CE-875D-00608CB78066}")), MERIT64_DO_NOT_USE));
-
- // Samsung's "mpeg-4 demultiplexor" can even open matroska files, amazing...
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{99EC0C72-4D1B-411B-AB1F-D561EE049D94}")), MERIT64_DO_NOT_USE));
-
- // LG Video Renderer (lgvid.ax) just crashes when trying to connect it
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{9F711C60-0668-11D0-94D4-0000C02BA972}")), MERIT64_DO_NOT_USE));
-
- // palm demuxer crashes (even crashes graphedit when dropping an .ac3 onto it)
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{BE2CF8A7-08CE-4A2C-9A25-FD726A999196}")), MERIT64_DO_NOT_USE));
-
- // DCDSPFilter (early versions crash mpc)
- {
- CRegKey key;
-
- TCHAR buff[256];
- ULONG len = sizeof(buff);
- memset(buff, 0, len);
-
- CString clsid = _T("{B38C58A0-1809-11D6-A458-EDAE78F1DF12}");
-
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("CLSID\\") + clsid + _T("\\InprocServer32"), KEY_READ)
- && ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len)
- && GetFileVersion(buff) < 0x0001000000030000ui64) {
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(clsid), MERIT64_DO_NOT_USE));
- }
- }
-
- /*
- // NVIDIA Transport Demux crashed for someone, I could not reproduce it
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{735823C1-ACC4-11D3-85AC-006008376FB8}")), MERIT64_DO_NOT_USE));
- */
-
- // mainconcept color space converter
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{272D77A0-A852-4851-ADA4-9091FEAD4C86}")), MERIT64_DO_NOT_USE));
-
- // Block VSFilter when internal subtitle renderer will get used
- if (s.fAutoloadSubtitles && s.fBlockVSFilter) {
- if (s.iDSVideoRendererType == VIDRNDT_DS_VMR7RENDERLESS || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS || s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_DXR || s.iDSVideoRendererType == VIDRNDT_DS_SYNC || s.iDSVideoRendererType == VIDRNDT_DS_MADVR) {
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{9852A670-F845-491B-9BE6-EBD841B8A613}")), MERIT64_DO_NOT_USE));
- }
- }
-
- // Overrides
-
- WORD merit_low = 1;
-
- POSITION pos = s.m_filters.GetTailPosition();
- while (pos) {
- FilterOverride* fo = s.m_filters.GetPrev(pos);
-
- if (!fo->fDisabled && fo->name == _T("Broadcom Video Decoder")) {
- bOverrideBroadcom = true;
- }
-
- if (fo->fDisabled || fo->type == FilterOverride::EXTERNAL && !CPath(MakeFullPath(fo->path)).FileExists()) {
- continue;
- }
-
- ULONGLONG merit =
- fo->iLoadType == FilterOverride::PREFERRED ? MERIT64_ABOVE_DSHOW :
- fo->iLoadType == FilterOverride::MERIT ? MERIT64(fo->dwMerit) :
- MERIT64_DO_NOT_USE; // fo->iLoadType == FilterOverride::BLOCKED
-
- merit += merit_low++;
-
- CFGFilter* pFGF = NULL;
-
- if (fo->type == FilterOverride::REGISTERED) {
- pFGF = DNew CFGFilterRegistry(fo->dispname, merit);
- } else if (fo->type == FilterOverride::EXTERNAL) {
- pFGF = DNew CFGFilterFile(fo->clsid, fo->path, CStringW(fo->name), merit);
- }
-
- if (pFGF) {
- pFGF->SetTypes(fo->guids);
- m_override.AddTail(pFGF);
- }
- }
-
- /* Use Broadcom decoder (if installed) for VC-1, H.264 and MPEG-2 */
- if (!bOverrideBroadcom) {
- pFGF = DNew CFGFilterRegistry(GUIDFromCString(_T("{2DE1D17E-46B1-42A8-9AEC-E20E80D9B1A9}")), MERIT64_ABOVE_DSHOW);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H264);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_h264);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_X264);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_x264);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VSSH);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vssh);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DAVC);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_davc);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_PAVC);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_pavc);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AVC1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_avc1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H264_bis);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_CCV1);
-
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WVC1);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wvc1);
-
- pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
- pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
- pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_MPEG2_VIDEO);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPEG2_VIDEO);
- m_transform.AddHead(pFGF);
- }
+ // Keep software decoder after DXVA decoder !
+ pFGF = DNew CFGFilterInternal<CMpeg2DecFilter>(
+ (tra[TRA_MPEG2]) ? Mpeg2DecFilterName : LowMerit(Mpeg2DecFilterName),
+ (tra[TRA_MPEG2]) ? MERIT64_ABOVE_DSHOW : MERIT64_DO_USE);
+ pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
+ pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
+ pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_MPEG2_VIDEO);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPEG2_VIDEO);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPG2);
+ m_transform.AddTail(pFGF);
+#endif
+
+ // Blocked filters
+
+ // "Subtitle Mixer" makes an access violation around the
+ // 11-12th media type when enumerating them on its output.
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{00A95963-3BE5-48C0-AD9F-3356D67EA09D}")), MERIT64_DO_NOT_USE));
+
+ // DiracSplitter.ax is crashing MPC-HC when opening invalid files...
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{09E7F58E-71A1-419D-B0A0-E524AE1454A9}")), MERIT64_DO_NOT_USE));
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{5899CFB9-948F-4869-A999-5544ECB38BA5}")), MERIT64_DO_NOT_USE));
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{F78CF248-180E-4713-B107-B13F7B5C31E1}")), MERIT64_DO_NOT_USE));
+
+ // ISCR suxx
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{48025243-2D39-11CE-875D-00608CB78066}")), MERIT64_DO_NOT_USE));
+
+ // Samsung's "mpeg-4 demultiplexor" can even open matroska files, amazing...
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{99EC0C72-4D1B-411B-AB1F-D561EE049D94}")), MERIT64_DO_NOT_USE));
+
+ // LG Video Renderer (lgvid.ax) just crashes when trying to connect it
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{9F711C60-0668-11D0-94D4-0000C02BA972}")), MERIT64_DO_NOT_USE));
+
+ // palm demuxer crashes (even crashes graphedit when dropping an .ac3 onto it)
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{BE2CF8A7-08CE-4A2C-9A25-FD726A999196}")), MERIT64_DO_NOT_USE));
+
+ // DCDSPFilter (early versions crash mpc)
+ {
+ CRegKey key;
+
+ TCHAR buff[256];
+ ULONG len = sizeof(buff);
+ memset(buff, 0, len);
+
+ CString clsid = _T("{B38C58A0-1809-11D6-A458-EDAE78F1DF12}");
+
+ if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("CLSID\\") + clsid + _T("\\InprocServer32"), KEY_READ)
+ && ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len)
+ && GetFileVersion(buff) < 0x0001000000030000ui64) {
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(clsid), MERIT64_DO_NOT_USE));
+ }
+ }
+
+ /*
+ // NVIDIA Transport Demux crashed for someone, I could not reproduce it
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{735823C1-ACC4-11D3-85AC-006008376FB8}")), MERIT64_DO_NOT_USE));
+ */
+
+ // mainconcept color space converter
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{272D77A0-A852-4851-ADA4-9091FEAD4C86}")), MERIT64_DO_NOT_USE));
+
+ // Block VSFilter when internal subtitle renderer will get used
+ if (s.fAutoloadSubtitles && s.fBlockVSFilter) {
+ if (s.iDSVideoRendererType == VIDRNDT_DS_VMR7RENDERLESS || s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS || s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM || s.iDSVideoRendererType == VIDRNDT_DS_DXR || s.iDSVideoRendererType == VIDRNDT_DS_SYNC || s.iDSVideoRendererType == VIDRNDT_DS_MADVR) {
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{9852A670-F845-491B-9BE6-EBD841B8A613}")), MERIT64_DO_NOT_USE));
+ }
+ }
+
+ // Overrides
+
+ WORD merit_low = 1;
+
+ POSITION pos = s.m_filters.GetTailPosition();
+ while (pos) {
+ FilterOverride* fo = s.m_filters.GetPrev(pos);
+
+ if (!fo->fDisabled && fo->name == _T("Broadcom Video Decoder")) {
+ bOverrideBroadcom = true;
+ }
+
+ if (fo->fDisabled || fo->type == FilterOverride::EXTERNAL && !CPath(MakeFullPath(fo->path)).FileExists()) {
+ continue;
+ }
+
+ ULONGLONG merit =
+ fo->iLoadType == FilterOverride::PREFERRED ? MERIT64_ABOVE_DSHOW :
+ fo->iLoadType == FilterOverride::MERIT ? MERIT64(fo->dwMerit) :
+ MERIT64_DO_NOT_USE; // fo->iLoadType == FilterOverride::BLOCKED
+
+ merit += merit_low++;
+
+ CFGFilter* pFGF = NULL;
+
+ if (fo->type == FilterOverride::REGISTERED) {
+ pFGF = DNew CFGFilterRegistry(fo->dispname, merit);
+ } else if (fo->type == FilterOverride::EXTERNAL) {
+ pFGF = DNew CFGFilterFile(fo->clsid, fo->path, CStringW(fo->name), merit);
+ }
+
+ if (pFGF) {
+ pFGF->SetTypes(fo->guids);
+ m_override.AddTail(pFGF);
+ }
+ }
+
+ /* Use Broadcom decoder (if installed) for VC-1, H.264 and MPEG-2 */
+ if (!bOverrideBroadcom) {
+ pFGF = DNew CFGFilterRegistry(GUIDFromCString(_T("{2DE1D17E-46B1-42A8-9AEC-E20E80D9B1A9}")), MERIT64_ABOVE_DSHOW);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H264);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_h264);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_X264);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_x264);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VSSH);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vssh);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DAVC);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_davc);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_PAVC);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_pavc);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AVC1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_avc1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H264_bis);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_CCV1);
+
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WVC1);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wvc1);
+
+ pFGF->AddType(MEDIATYPE_DVD_ENCRYPTED_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
+ pFGF->AddType(MEDIATYPE_MPEG2_PACK, MEDIASUBTYPE_MPEG2_VIDEO);
+ pFGF->AddType(MEDIATYPE_MPEG2_PES, MEDIASUBTYPE_MPEG2_VIDEO);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_MPEG2_VIDEO);
+ m_transform.AddHead(pFGF);
+ }
}
STDMETHODIMP CFGManagerCustom::AddFilter(IBaseFilter* pBF, LPCWSTR pName)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- HRESULT hr;
+ HRESULT hr;
- if (FAILED(hr = __super::AddFilter(pBF, pName))) {
- return hr;
- }
+ if (FAILED(hr = __super::AddFilter(pBF, pName))) {
+ return hr;
+ }
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- if (GetCLSID(pBF) == CLSID_DMOWrapperFilter) {
- if (CComQIPtr<IPropertyBag> pPB = pBF) {
- CComVariant var(true);
- pPB->Write(CComBSTR(L"_HIRESOUTPUT"), &var);
- }
- }
+ if (GetCLSID(pBF) == CLSID_DMOWrapperFilter) {
+ if (CComQIPtr<IPropertyBag> pPB = pBF) {
+ CComVariant var(true);
+ pPB->Write(CComBSTR(L"_HIRESOUTPUT"), &var);
+ }
+ }
- if (CComQIPtr<IAudioSwitcherFilter> pASF = pBF) {
- pASF->EnableDownSamplingTo441(s.fDownSampleTo441);
- pASF->SetSpeakerConfig(s.fCustomChannelMapping, s.pSpeakerToChannelMap);
- pASF->SetAudioTimeShift(s.fAudioTimeShift ? 10000i64*s.iAudioTimeShift : 0);
- pASF->SetNormalizeBoost(s.fAudioNormalize, s.fAudioNormalizeRecover, s.dAudioBoost_dB);
- }
+ if (CComQIPtr<IAudioSwitcherFilter> pASF = pBF) {
+ pASF->EnableDownSamplingTo441(s.fDownSampleTo441);
+ pASF->SetSpeakerConfig(s.fCustomChannelMapping, s.pSpeakerToChannelMap);
+ pASF->SetAudioTimeShift(s.fAudioTimeShift ? 10000i64 * s.iAudioTimeShift : 0);
+ pASF->SetNormalizeBoost(s.fAudioNormalize, s.fAudioNormalizeRecover, s.dAudioBoost_dB);
+ }
- return hr;
+ return hr;
}
//
-// CFGManagerPlayer
+// CFGManagerPlayer
//
CFGManagerPlayer::CFGManagerPlayer(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd)
- : CFGManagerCustom(pName, pUnk)
- , m_hWnd(hWnd)
- , m_vrmerit(MERIT64(MERIT_PREFERRED))
- , m_armerit(MERIT64(MERIT_PREFERRED))
+ : CFGManagerCustom(pName, pUnk)
+ , m_hWnd(hWnd)
+ , m_vrmerit(MERIT64(MERIT_PREFERRED))
+ , m_armerit(MERIT64(MERIT_PREFERRED))
{
- TRACE("--> CFGManagerPlayer::CFGManagerPlayer on thread: %d\n", GetCurrentThreadId());
- CFGFilter* pFGF;
-
- AppSettings& s = AfxGetAppSettings();
-
- if (m_pFM) {
- CComPtr<IEnumMoniker> pEM;
-
- GUID guids[] = {MEDIATYPE_Video, MEDIASUBTYPE_NULL};
-
- if (SUCCEEDED(m_pFM->EnumMatchingFilters(&pEM, 0, FALSE, MERIT_DO_NOT_USE+1,
- TRUE, 1, guids, NULL, NULL, TRUE, FALSE, 0, NULL, NULL, NULL))) {
- for (CComPtr<IMoniker> pMoniker; S_OK == pEM->Next(1, &pMoniker, NULL); pMoniker = NULL) {
- CFGFilterRegistry f(pMoniker);
- m_vrmerit = max(m_vrmerit, f.GetMerit());
- }
- }
-
- m_vrmerit += 0x100;
- }
-
- if (m_pFM) {
- CComPtr<IEnumMoniker> pEM;
-
- GUID guids[] = {MEDIATYPE_Audio, MEDIASUBTYPE_NULL};
-
- if (SUCCEEDED(m_pFM->EnumMatchingFilters(&pEM, 0, FALSE, MERIT_DO_NOT_USE+1,
- TRUE, 1, guids, NULL, NULL, TRUE, FALSE, 0, NULL, NULL, NULL))) {
- for (CComPtr<IMoniker> pMoniker; S_OK == pEM->Next(1, &pMoniker, NULL); pMoniker = NULL) {
- CFGFilterRegistry f(pMoniker);
- m_armerit = max(m_armerit, f.GetMerit());
- }
- }
-
- BeginEnumSysDev(CLSID_AudioRendererCategory, pMoniker) {
- CFGFilterRegistry f(pMoniker);
- m_armerit = max(m_armerit, f.GetMerit());
- }
- EndEnumSysDev
-
- m_armerit += 0x100;
- }
-
- // Switchers
-
- if (s.fEnableAudioSwitcher) {
- pFGF = DNew CFGFilterInternal<CAudioSwitcherFilter>(L"Audio Switcher", m_armerit + 0x100);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NULL);
- m_transform.AddTail(pFGF);
-
- // morgan stream switcher
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{D3CD7858-971A-4838-ACEC-40CA5D529DC8}")), MERIT64_DO_NOT_USE));
- }
-
- // Renderers
-
- switch (s.iDSVideoRendererType) {
- case VIDRNDT_DS_OLDRENDERER:
- m_transform.AddTail(DNew CFGFilterRegistry(CLSID_VideoRenderer, m_vrmerit));
- break;
- case VIDRNDT_DS_OVERLAYMIXER:
- m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_OverlayMixer, L"Overlay Mixer", m_vrmerit));
- break;
- case VIDRNDT_DS_VMR7WINDOWED:
- m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_VideoMixingRenderer, L"Video Mixing Renderer 7", m_vrmerit));
- break;
- case VIDRNDT_DS_VMR9WINDOWED:
- m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_VideoMixingRenderer9, L"Video Mixing Renderer 9", m_vrmerit));
- break;
- case VIDRNDT_DS_VMR7RENDERLESS:
- m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_VMR7AllocatorPresenter, L"Video Mixing Renderer 7 (Renderless)", m_vrmerit));
- break;
- case VIDRNDT_DS_VMR9RENDERLESS:
- m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_VMR9AllocatorPresenter, L"Video Mixing Renderer 9 (Renderless)", m_vrmerit));
- break;
- case VIDRNDT_DS_EVR:
- m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_EnhancedVideoRenderer, L"Enhanced Video Renderer", m_vrmerit));
- break;
- case VIDRNDT_DS_EVR_CUSTOM:
- m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_EVRAllocatorPresenter, L"Enhanced Video Renderer (custom presenter)", m_vrmerit));
- break;
- case VIDRNDT_DS_DXR:
- m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_DXRAllocatorPresenter, L"Haali's Video Renderer", m_vrmerit));
- break;
- case VIDRNDT_DS_MADVR:
- m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_madVRAllocatorPresenter, L"madVR Renderer", m_vrmerit));
- break;
- case VIDRNDT_DS_SYNC:
- m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_SyncAllocatorPresenter, L"EVR Sync", m_vrmerit));
- break;
- case VIDRNDT_DS_NULL_COMP:
- pFGF = DNew CFGFilterInternal<CNullVideoRenderer>(L"Null Video Renderer (Any)", MERIT64_ABOVE_DSHOW+2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_NULL);
- m_transform.AddTail(pFGF);
- break;
- case VIDRNDT_DS_NULL_UNCOMP:
- pFGF = DNew CFGFilterInternal<CNullUVideoRenderer>(L"Null Video Renderer (Uncompressed)", MERIT64_ABOVE_DSHOW+2);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_NULL);
- m_transform.AddTail(pFGF);
- break;
- }
-
- CString SelAudioRenderer = s.SelectedAudioRenderer();
- if (SelAudioRenderer == AUDRNDT_NULL_COMP) {
- pFGF = DNew CFGFilterInternal<CNullAudioRenderer>(AUDRNDT_NULL_COMP, MERIT64_ABOVE_DSHOW+2);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NULL);
- m_transform.AddTail(pFGF);
- } else if (SelAudioRenderer == AUDRNDT_NULL_UNCOMP) {
- pFGF = DNew CFGFilterInternal<CNullUAudioRenderer>(AUDRNDT_NULL_UNCOMP, MERIT64_ABOVE_DSHOW+2);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NULL);
- m_transform.AddTail(pFGF);
- } else if (SelAudioRenderer == AUDRNDT_MPC) {
- pFGF = DNew CFGFilterInternal<CMpcAudioRenderer>(AUDRNDT_MPC, MERIT64_ABOVE_DSHOW+2);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NULL);
- m_transform.AddTail(pFGF);
- } else if (SelAudioRenderer!="") {
- pFGF = DNew CFGFilterRegistry(SelAudioRenderer, m_armerit);
- pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NULL);
- m_transform.AddTail(pFGF);
- }
+ TRACE("--> CFGManagerPlayer::CFGManagerPlayer on thread: %d\n", GetCurrentThreadId());
+ CFGFilter* pFGF;
+
+ AppSettings& s = AfxGetAppSettings();
+
+ if (m_pFM) {
+ CComPtr<IEnumMoniker> pEM;
+
+ GUID guids[] = {MEDIATYPE_Video, MEDIASUBTYPE_NULL};
+
+ if (SUCCEEDED(m_pFM->EnumMatchingFilters(&pEM, 0, FALSE, MERIT_DO_NOT_USE + 1,
+ TRUE, 1, guids, NULL, NULL, TRUE, FALSE, 0, NULL, NULL, NULL))) {
+ for (CComPtr<IMoniker> pMoniker; S_OK == pEM->Next(1, &pMoniker, NULL); pMoniker = NULL) {
+ CFGFilterRegistry f(pMoniker);
+ m_vrmerit = max(m_vrmerit, f.GetMerit());
+ }
+ }
+
+ m_vrmerit += 0x100;
+ }
+
+ if (m_pFM) {
+ CComPtr<IEnumMoniker> pEM;
+
+ GUID guids[] = {MEDIATYPE_Audio, MEDIASUBTYPE_NULL};
+
+ if (SUCCEEDED(m_pFM->EnumMatchingFilters(&pEM, 0, FALSE, MERIT_DO_NOT_USE + 1,
+ TRUE, 1, guids, NULL, NULL, TRUE, FALSE, 0, NULL, NULL, NULL))) {
+ for (CComPtr<IMoniker> pMoniker; S_OK == pEM->Next(1, &pMoniker, NULL); pMoniker = NULL) {
+ CFGFilterRegistry f(pMoniker);
+ m_armerit = max(m_armerit, f.GetMerit());
+ }
+ }
+
+ BeginEnumSysDev(CLSID_AudioRendererCategory, pMoniker) {
+ CFGFilterRegistry f(pMoniker);
+ m_armerit = max(m_armerit, f.GetMerit());
+ }
+ EndEnumSysDev
+
+ m_armerit += 0x100;
+ }
+
+ // Switchers
+
+ if (s.fEnableAudioSwitcher) {
+ pFGF = DNew CFGFilterInternal<CAudioSwitcherFilter>(L"Audio Switcher", m_armerit + 0x100);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NULL);
+ m_transform.AddTail(pFGF);
+
+ // morgan stream switcher
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{D3CD7858-971A-4838-ACEC-40CA5D529DC8}")), MERIT64_DO_NOT_USE));
+ }
+
+ // Renderers
+
+ switch (s.iDSVideoRendererType) {
+ case VIDRNDT_DS_OLDRENDERER:
+ m_transform.AddTail(DNew CFGFilterRegistry(CLSID_VideoRenderer, m_vrmerit));
+ break;
+ case VIDRNDT_DS_OVERLAYMIXER:
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_OverlayMixer, L"Overlay Mixer", m_vrmerit));
+ break;
+ case VIDRNDT_DS_VMR7WINDOWED:
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_VideoMixingRenderer, L"Video Mixing Renderer 7", m_vrmerit));
+ break;
+ case VIDRNDT_DS_VMR9WINDOWED:
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_VideoMixingRenderer9, L"Video Mixing Renderer 9", m_vrmerit));
+ break;
+ case VIDRNDT_DS_VMR7RENDERLESS:
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_VMR7AllocatorPresenter, L"Video Mixing Renderer 7 (Renderless)", m_vrmerit));
+ break;
+ case VIDRNDT_DS_VMR9RENDERLESS:
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_VMR9AllocatorPresenter, L"Video Mixing Renderer 9 (Renderless)", m_vrmerit));
+ break;
+ case VIDRNDT_DS_EVR:
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_EnhancedVideoRenderer, L"Enhanced Video Renderer", m_vrmerit));
+ break;
+ case VIDRNDT_DS_EVR_CUSTOM:
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_EVRAllocatorPresenter, L"Enhanced Video Renderer (custom presenter)", m_vrmerit));
+ break;
+ case VIDRNDT_DS_DXR:
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_DXRAllocatorPresenter, L"Haali's Video Renderer", m_vrmerit));
+ break;
+ case VIDRNDT_DS_MADVR:
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_madVRAllocatorPresenter, L"madVR Renderer", m_vrmerit));
+ break;
+ case VIDRNDT_DS_SYNC:
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_SyncAllocatorPresenter, L"EVR Sync", m_vrmerit));
+ break;
+ case VIDRNDT_DS_NULL_COMP:
+ pFGF = DNew CFGFilterInternal<CNullVideoRenderer>(L"Null Video Renderer (Any)", MERIT64_ABOVE_DSHOW + 2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_NULL);
+ m_transform.AddTail(pFGF);
+ break;
+ case VIDRNDT_DS_NULL_UNCOMP:
+ pFGF = DNew CFGFilterInternal<CNullUVideoRenderer>(L"Null Video Renderer (Uncompressed)", MERIT64_ABOVE_DSHOW + 2);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_NULL);
+ m_transform.AddTail(pFGF);
+ break;
+ }
+
+ CString SelAudioRenderer = s.SelectedAudioRenderer();
+ if (SelAudioRenderer == AUDRNDT_NULL_COMP) {
+ pFGF = DNew CFGFilterInternal<CNullAudioRenderer>(AUDRNDT_NULL_COMP, MERIT64_ABOVE_DSHOW + 2);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NULL);
+ m_transform.AddTail(pFGF);
+ } else if (SelAudioRenderer == AUDRNDT_NULL_UNCOMP) {
+ pFGF = DNew CFGFilterInternal<CNullUAudioRenderer>(AUDRNDT_NULL_UNCOMP, MERIT64_ABOVE_DSHOW + 2);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NULL);
+ m_transform.AddTail(pFGF);
+ } else if (SelAudioRenderer == AUDRNDT_MPC) {
+ pFGF = DNew CFGFilterInternal<CMpcAudioRenderer>(AUDRNDT_MPC, MERIT64_ABOVE_DSHOW + 2);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NULL);
+ m_transform.AddTail(pFGF);
+ } else if (SelAudioRenderer != "") {
+ pFGF = DNew CFGFilterRegistry(SelAudioRenderer, m_armerit);
+ pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NULL);
+ m_transform.AddTail(pFGF);
+ }
}
STDMETHODIMP CFGManagerPlayer::ConnectDirect(IPin* pPinOut, IPin* pPinIn, const AM_MEDIA_TYPE* pmt)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- if (GetCLSID(pPinOut) == CLSID_MPEG2Demultiplexer) {
- CComQIPtr<IMediaSeeking> pMS = pPinOut;
- REFERENCE_TIME rtDur = 0;
- if (!pMS || FAILED(pMS->GetDuration(&rtDur)) || rtDur <= 0) {
- return E_FAIL;
- }
- }
+ if (GetCLSID(pPinOut) == CLSID_MPEG2Demultiplexer) {
+ CComQIPtr<IMediaSeeking> pMS = pPinOut;
+ REFERENCE_TIME rtDur = 0;
+ if (!pMS || FAILED(pMS->GetDuration(&rtDur)) || rtDur <= 0) {
+ return E_FAIL;
+ }
+ }
- return __super::ConnectDirect(pPinOut, pPinIn, pmt);
+ return __super::ConnectDirect(pPinOut, pPinIn, pmt);
}
//
@@ -2615,95 +2615,95 @@ STDMETHODIMP CFGManagerPlayer::ConnectDirect(IPin* pPinOut, IPin* pPinIn, const
//
CFGManagerDVD::CFGManagerDVD(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd)
- : CFGManagerPlayer(pName, pUnk, hWnd)
+ : CFGManagerPlayer(pName, pUnk, hWnd)
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- // have to avoid the old video renderer
- if (s.iDSVideoRendererType == VIDRNDT_DS_OLDRENDERER) {
- m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_OverlayMixer, L"Overlay Mixer", m_vrmerit-1));
- }
+ // have to avoid the old video renderer
+ if (s.iDSVideoRendererType == VIDRNDT_DS_OLDRENDERER) {
+ m_transform.AddTail(DNew CFGFilterVideoRenderer(m_hWnd, CLSID_OverlayMixer, L"Overlay Mixer", m_vrmerit - 1));
+ }
- // elecard's decoder isn't suited for dvd playback (atm)
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{F50B3F13-19C4-11CF-AA9A-02608C9BABA2}")), MERIT64_DO_NOT_USE));
+ // elecard's decoder isn't suited for dvd playback (atm)
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{F50B3F13-19C4-11CF-AA9A-02608C9BABA2}")), MERIT64_DO_NOT_USE));
}
class CResetDVD : public CDVDSession
{
public:
- CResetDVD(LPCTSTR path) {
- if (Open(path)) {
- if (BeginSession()) {
- Authenticate(); /*GetDiscKey();*/
- EndSession();
- }
- Close();
- }
- }
+ CResetDVD(LPCTSTR path) {
+ if (Open(path)) {
+ if (BeginSession()) {
+ Authenticate(); /*GetDiscKey();*/
+ EndSession();
+ }
+ Close();
+ }
+ }
};
STDMETHODIMP CFGManagerDVD::RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- HRESULT hr;
+ HRESULT hr;
- CComPtr<IBaseFilter> pBF;
- if (FAILED(hr = AddSourceFilter(lpcwstrFile, lpcwstrFile, &pBF))) {
- return hr;
- }
+ CComPtr<IBaseFilter> pBF;
+ if (FAILED(hr = AddSourceFilter(lpcwstrFile, lpcwstrFile, &pBF))) {
+ return hr;
+ }
- return ConnectFilter(pBF, NULL);
+ return ConnectFilter(pBF, NULL);
}
STDMETHODIMP CFGManagerDVD::AddSourceFilter(LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
- CheckPointer(lpcwstrFileName, E_POINTER);
- CheckPointer(ppFilter, E_POINTER);
+ CheckPointer(lpcwstrFileName, E_POINTER);
+ CheckPointer(ppFilter, E_POINTER);
- HRESULT hr;
+ HRESULT hr;
- CStringW fn = CStringW(lpcwstrFileName).TrimLeft();
- CStringW protocol = fn.Left(fn.Find(':')+1).TrimRight(':').MakeLower();
- CStringW ext = CPathW(fn).GetExtension().MakeLower();
+ CStringW fn = CStringW(lpcwstrFileName).TrimLeft();
+ CStringW protocol = fn.Left(fn.Find(':') + 1).TrimRight(':').MakeLower();
+ CStringW ext = CPathW(fn).GetExtension().MakeLower();
- GUID clsid = ext == L".ratdvd" ? GUIDFromCString(_T("{482d10b6-376e-4411-8a17-833800A065DB}")) : CLSID_DVDNavigator;
+ GUID clsid = ext == L".ratdvd" ? GUIDFromCString(_T("{482d10b6-376e-4411-8a17-833800A065DB}")) : CLSID_DVDNavigator;
- CComPtr<IBaseFilter> pBF;
- if (FAILED(hr = pBF.CoCreateInstance(clsid))
- || FAILED(hr = AddFilter(pBF, L"DVD Navigator"))) {
- return VFW_E_CANNOT_LOAD_SOURCE_FILTER;
- }
+ CComPtr<IBaseFilter> pBF;
+ if (FAILED(hr = pBF.CoCreateInstance(clsid))
+ || FAILED(hr = AddFilter(pBF, L"DVD Navigator"))) {
+ return VFW_E_CANNOT_LOAD_SOURCE_FILTER;
+ }
- CComQIPtr<IDvdControl2> pDVDC;
- CComQIPtr<IDvdInfo2> pDVDI;
+ CComQIPtr<IDvdControl2> pDVDC;
+ CComQIPtr<IDvdInfo2> pDVDI;
- if (!((pDVDC = pBF) && (pDVDI = pBF))) {
- return E_NOINTERFACE;
- }
+ if (!((pDVDC = pBF) && (pDVDI = pBF))) {
+ return E_NOINTERFACE;
+ }
- WCHAR buff[_MAX_PATH];
- ULONG len;
- if ((!fn.IsEmpty()
- && FAILED(hr = pDVDC->SetDVDDirectory(fn))
- && FAILED(hr = pDVDC->SetDVDDirectory(fn + L"VIDEO_TS"))
- && FAILED(hr = pDVDC->SetDVDDirectory(fn + L"\\VIDEO_TS")))
- || FAILED(hr = pDVDI->GetDVDDirectory(buff, _countof(buff), &len)) || len == 0) {
- return E_INVALIDARG;
- }
+ WCHAR buff[_MAX_PATH];
+ ULONG len;
+ if ((!fn.IsEmpty()
+ && FAILED(hr = pDVDC->SetDVDDirectory(fn))
+ && FAILED(hr = pDVDC->SetDVDDirectory(fn + L"VIDEO_TS"))
+ && FAILED(hr = pDVDC->SetDVDDirectory(fn + L"\\VIDEO_TS")))
+ || FAILED(hr = pDVDI->GetDVDDirectory(buff, _countof(buff), &len)) || len == 0) {
+ return E_INVALIDARG;
+ }
- pDVDC->SetOption(DVD_ResetOnStop, FALSE);
- pDVDC->SetOption(DVD_HMSF_TimeCodeEvents, TRUE);
+ pDVDC->SetOption(DVD_ResetOnStop, FALSE);
+ pDVDC->SetOption(DVD_HMSF_TimeCodeEvents, TRUE);
- if (clsid == CLSID_DVDNavigator) {
- CResetDVD(CString(buff));
- }
+ if (clsid == CLSID_DVDNavigator) {
+ CResetDVD(CString(buff));
+ }
- *ppFilter = pBF.Detach();
+ *ppFilter = pBF.Detach();
- return S_OK;
+ return S_OK;
}
//
@@ -2711,14 +2711,14 @@ STDMETHODIMP CFGManagerDVD::AddSourceFilter(LPCWSTR lpcwstrFileName, LPCWSTR lpc
//
CFGManagerCapture::CFGManagerCapture(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd)
- : CFGManagerPlayer(pName, pUnk, hWnd)
+ : CFGManagerPlayer(pName, pUnk, hWnd)
{
- CFGFilter* pFGF = DNew CFGFilterInternal<CDeinterlacerFilter>(L"Deinterlacer", m_vrmerit + 0x100);
- pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_NULL);
- m_transform.AddTail(pFGF);
+ CFGFilter* pFGF = DNew CFGFilterInternal<CDeinterlacerFilter>(L"Deinterlacer", m_vrmerit + 0x100);
+ pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_NULL);
+ m_transform.AddTail(pFGF);
- // morgan stream switcher
- m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{D3CD7858-971A-4838-ACEC-40CA5D529DC8}")), MERIT64_DO_NOT_USE));
+ // morgan stream switcher
+ m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{D3CD7858-971A-4838-ACEC-40CA5D529DC8}")), MERIT64_DO_NOT_USE));
}
//
@@ -2726,9 +2726,9 @@ CFGManagerCapture::CFGManagerCapture(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd)
//
CFGManagerMuxer::CFGManagerMuxer(LPCTSTR pName, LPUNKNOWN pUnk)
- : CFGManagerCustom(pName, pUnk)
+ : CFGManagerCustom(pName, pUnk)
{
- m_source.AddTail(DNew CFGFilterInternal<CSubtitleSourceASS>());
+ m_source.AddTail(DNew CFGFilterInternal<CSubtitleSourceASS>());
}
//
@@ -2736,21 +2736,21 @@ CFGManagerMuxer::CFGManagerMuxer(LPCTSTR pName, LPUNKNOWN pUnk)
//
CFGAggregator::CFGAggregator(const CLSID& clsid, LPCTSTR pName, LPUNKNOWN pUnk, HRESULT& hr)
- : CUnknown(pName, pUnk)
+ : CUnknown(pName, pUnk)
{
- hr = m_pUnkInner.CoCreateInstance(clsid, GetOwner());
+ hr = m_pUnkInner.CoCreateInstance(clsid, GetOwner());
}
CFGAggregator::~CFGAggregator()
{
- m_pUnkInner.Release();
+ m_pUnkInner.Release();
}
STDMETHODIMP CFGAggregator::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- m_pUnkInner && (riid != IID_IUnknown && SUCCEEDED(m_pUnkInner->QueryInterface(riid, ppv))) ? S_OK :
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ m_pUnkInner && (riid != IID_IUnknown && SUCCEEDED(m_pUnkInner->QueryInterface(riid, ppv))) ? S_OK :
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
diff --git a/src/mpc-hc/FGManager.h b/src/mpc-hc/FGManager.h
index 7d3654cfe..d103288ef 100644
--- a/src/mpc-hc/FGManager.h
+++ b/src/mpc-hc/FGManager.h
@@ -30,147 +30,147 @@
#define LowMerit(x) (CStringW(x) + LowMeritSuffix)
class CFGManager
- : public CUnknown
- , public IGraphBuilder2
- , public IGraphBuilderDeadEnd
- , public CCritSec
+ : public CUnknown
+ , public IGraphBuilder2
+ , public IGraphBuilderDeadEnd
+ , public CCritSec
{
public:
- struct path_t {
- CLSID clsid;
- CString filter, pin;
- };
-
- class CStreamPath : public CAtlList<path_t>
- {
- public:
- void Append(IBaseFilter* pBF, IPin* pPin);
- bool Compare(const CStreamPath& path);
- };
-
- class CStreamDeadEnd : public CStreamPath
- {
- public:
- CAtlList<CMediaType> mts;
- };
+ struct path_t {
+ CLSID clsid;
+ CString filter, pin;
+ };
+
+ class CStreamPath : public CAtlList<path_t>
+ {
+ public:
+ void Append(IBaseFilter* pBF, IPin* pPin);
+ bool Compare(const CStreamPath& path);
+ };
+
+ class CStreamDeadEnd : public CStreamPath
+ {
+ public:
+ CAtlList<CMediaType> mts;
+ };
private:
- CComPtr<IUnknown> m_pUnkInner;
- DWORD m_dwRegister;
+ CComPtr<IUnknown> m_pUnkInner;
+ DWORD m_dwRegister;
- CStreamPath m_streampath;
- CAutoPtrArray<CStreamDeadEnd> m_deadends;
+ CStreamPath m_streampath;
+ CAutoPtrArray<CStreamDeadEnd> m_deadends;
protected:
- CComPtr<IFilterMapper2> m_pFM;
- CInterfaceList<IUnknown, &IID_IUnknown> m_pUnks;
- CAtlList<CFGFilter*> m_source, m_transform, m_override;
+ CComPtr<IFilterMapper2> m_pFM;
+ CInterfaceList<IUnknown, &IID_IUnknown> m_pUnks;
+ CAtlList<CFGFilter*> m_source, m_transform, m_override;
- static bool CheckBytes(HANDLE hFile, CString chkbytes);
+ static bool CheckBytes(HANDLE hFile, CString chkbytes);
- HRESULT EnumSourceFilters(LPCWSTR lpcwstrFileName, CFGFilterList& fl);
- HRESULT AddSourceFilter(CFGFilter* pFGF, LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, IBaseFilter** ppBF);
- HRESULT Connect(IPin* pPinOut, IPin* pPinIn, bool bContinueRender);
+ HRESULT EnumSourceFilters(LPCWSTR lpcwstrFileName, CFGFilterList& fl);
+ HRESULT AddSourceFilter(CFGFilter* pFGF, LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, IBaseFilter** ppBF);
+ HRESULT Connect(IPin* pPinOut, IPin* pPinIn, bool bContinueRender);
- // IFilterGraph
+ // IFilterGraph
- STDMETHODIMP AddFilter(IBaseFilter* pFilter, LPCWSTR pName);
- STDMETHODIMP RemoveFilter(IBaseFilter* pFilter);
- STDMETHODIMP EnumFilters(IEnumFilters** ppEnum);
- STDMETHODIMP FindFilterByName(LPCWSTR pName, IBaseFilter** ppFilter);
- STDMETHODIMP ConnectDirect(IPin* pPinOut, IPin* pPinIn, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP Reconnect(IPin* ppin);
- STDMETHODIMP Disconnect(IPin* ppin);
- STDMETHODIMP SetDefaultSyncSource();
+ STDMETHODIMP AddFilter(IBaseFilter* pFilter, LPCWSTR pName);
+ STDMETHODIMP RemoveFilter(IBaseFilter* pFilter);
+ STDMETHODIMP EnumFilters(IEnumFilters** ppEnum);
+ STDMETHODIMP FindFilterByName(LPCWSTR pName, IBaseFilter** ppFilter);
+ STDMETHODIMP ConnectDirect(IPin* pPinOut, IPin* pPinIn, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP Reconnect(IPin* ppin);
+ STDMETHODIMP Disconnect(IPin* ppin);
+ STDMETHODIMP SetDefaultSyncSource();
- // IGraphBuilder
+ // IGraphBuilder
- STDMETHODIMP Connect(IPin* pPinOut, IPin* pPinIn);
- STDMETHODIMP Render(IPin* pPinOut);
- STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
- STDMETHODIMP AddSourceFilter(LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter);
- STDMETHODIMP SetLogFile(DWORD_PTR hFile);
- STDMETHODIMP Abort();
- STDMETHODIMP ShouldOperationContinue();
+ STDMETHODIMP Connect(IPin* pPinOut, IPin* pPinIn);
+ STDMETHODIMP Render(IPin* pPinOut);
+ STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
+ STDMETHODIMP AddSourceFilter(LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter);
+ STDMETHODIMP SetLogFile(DWORD_PTR hFile);
+ STDMETHODIMP Abort();
+ STDMETHODIMP ShouldOperationContinue();
- // IFilterGraph2
+ // IFilterGraph2
- STDMETHODIMP AddSourceFilterForMoniker(IMoniker* pMoniker, IBindCtx* pCtx, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter);
- STDMETHODIMP ReconnectEx(IPin* ppin, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP RenderEx(IPin* pPinOut, DWORD dwFlags, DWORD* pvContext);
+ STDMETHODIMP AddSourceFilterForMoniker(IMoniker* pMoniker, IBindCtx* pCtx, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter);
+ STDMETHODIMP ReconnectEx(IPin* ppin, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP RenderEx(IPin* pPinOut, DWORD dwFlags, DWORD* pvContext);
- // IGraphBuilder2
+ // IGraphBuilder2
- STDMETHODIMP IsPinDirection(IPin* pPin, PIN_DIRECTION dir);
- STDMETHODIMP IsPinConnected(IPin* pPin);
- STDMETHODIMP ConnectFilter(IBaseFilter* pBF, IPin* pPinIn);
- STDMETHODIMP ConnectFilter(IPin* pPinOut, IBaseFilter* pBF);
- STDMETHODIMP ConnectFilterDirect(IPin* pPinOut, IBaseFilter* pBF, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP NukeDownstream(IUnknown* pUnk);
- STDMETHODIMP FindInterface(REFIID iid, void** ppv, BOOL bRemove);
- STDMETHODIMP AddToROT();
- STDMETHODIMP RemoveFromROT();
+ STDMETHODIMP IsPinDirection(IPin* pPin, PIN_DIRECTION dir);
+ STDMETHODIMP IsPinConnected(IPin* pPin);
+ STDMETHODIMP ConnectFilter(IBaseFilter* pBF, IPin* pPinIn);
+ STDMETHODIMP ConnectFilter(IPin* pPinOut, IBaseFilter* pBF);
+ STDMETHODIMP ConnectFilterDirect(IPin* pPinOut, IBaseFilter* pBF, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP NukeDownstream(IUnknown* pUnk);
+ STDMETHODIMP FindInterface(REFIID iid, void** ppv, BOOL bRemove);
+ STDMETHODIMP AddToROT();
+ STDMETHODIMP RemoveFromROT();
- // IGraphBuilderDeadEnd
+ // IGraphBuilderDeadEnd
- STDMETHODIMP_(size_t) GetCount();
- STDMETHODIMP GetDeadEnd(int iIndex, CAtlList<CStringW>& path, CAtlList<CMediaType>& mts);
+ STDMETHODIMP_(size_t) GetCount();
+ STDMETHODIMP GetDeadEnd(int iIndex, CAtlList<CStringW>& path, CAtlList<CMediaType>& mts);
public:
- CFGManager(LPCTSTR pName, LPUNKNOWN pUnk);
- virtual ~CFGManager();
+ CFGManager(LPCTSTR pName, LPUNKNOWN pUnk);
+ virtual ~CFGManager();
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
};
class CFGManagerCustom : public CFGManager
{
public:
- // IFilterGraph
+ // IFilterGraph
- STDMETHODIMP AddFilter(IBaseFilter* pFilter, LPCWSTR pName);
+ STDMETHODIMP AddFilter(IBaseFilter* pFilter, LPCWSTR pName);
public:
- CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk);
+ CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk);
};
class CFGManagerPlayer : public CFGManagerCustom
{
protected:
- HWND m_hWnd;
- UINT64 m_vrmerit, m_armerit;
+ HWND m_hWnd;
+ UINT64 m_vrmerit, m_armerit;
- // IFilterGraph
+ // IFilterGraph
- STDMETHODIMP ConnectDirect(IPin* pPinOut, IPin* pPinIn, const AM_MEDIA_TYPE* pmt);
+ STDMETHODIMP ConnectDirect(IPin* pPinOut, IPin* pPinIn, const AM_MEDIA_TYPE* pmt);
public:
- CFGManagerPlayer(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd);
+ CFGManagerPlayer(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd);
};
class CFGManagerDVD : public CFGManagerPlayer
{
protected:
- // IGraphBuilder
+ // IGraphBuilder
- STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
- STDMETHODIMP AddSourceFilter(LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter);
+ STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
+ STDMETHODIMP AddSourceFilter(LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter);
public:
- CFGManagerDVD(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd);
+ CFGManagerDVD(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd);
};
class CFGManagerCapture : public CFGManagerPlayer
{
public:
- CFGManagerCapture(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd);
+ CFGManagerCapture(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd);
};
class CFGManagerMuxer : public CFGManagerCustom
{
public:
- CFGManagerMuxer(LPCTSTR pName, LPUNKNOWN pUnk);
+ CFGManagerMuxer(LPCTSTR pName, LPUNKNOWN pUnk);
};
//
@@ -178,12 +178,12 @@ public:
class CFGAggregator : public CUnknown
{
protected:
- CComPtr<IUnknown> m_pUnkInner;
+ CComPtr<IUnknown> m_pUnkInner;
public:
- CFGAggregator(const CLSID& clsid, LPCTSTR pName, LPUNKNOWN pUnk, HRESULT& hr);
- virtual ~CFGAggregator();
+ CFGAggregator(const CLSID& clsid, LPCTSTR pName, LPUNKNOWN pUnk, HRESULT& hr);
+ virtual ~CFGAggregator();
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
};
diff --git a/src/mpc-hc/FGManagerBDA.cpp b/src/mpc-hc/FGManagerBDA.cpp
index f5898ba6d..f85f06ad3 100644
--- a/src/mpc-hc/FGManagerBDA.cpp
+++ b/src/mpc-hc/FGManagerBDA.cpp
@@ -44,199 +44,199 @@
/// Format, Video MPEG2
static const MPEG2VIDEOINFO sMpv_fmt = {
- {
- // hdr
- {0,0,720,576}, // rcSource
- {0,0,0,0}, // rcTarget
- 0, // dwBitRate
- 0, // dwBitErrorRate
- 0, // AvgTimePerFrame
- 0, // dwInterlaceFlags
- 0, // dwCopyProtectFlags
- 0, // dwPictAspectRatioX
- 0, // dwPictAspectRatioY
- {0}, // dwControlFlag & dwReserved1
- 0, // dwReserved2
- {
- // bmiHeader
- sizeof(BITMAPINFOHEADER),// biSize
- 720, // biWidth
- 576 // biHeight
- }
- // implicitly sets the others fields to 0
- }
+ {
+ // hdr
+ {0, 0, 720, 576}, // rcSource
+ {0, 0, 0, 0}, // rcTarget
+ 0, // dwBitRate
+ 0, // dwBitErrorRate
+ 0, // AvgTimePerFrame
+ 0, // dwInterlaceFlags
+ 0, // dwCopyProtectFlags
+ 0, // dwPictAspectRatioX
+ 0, // dwPictAspectRatioY
+ {0}, // dwControlFlag & dwReserved1
+ 0, // dwReserved2
+ {
+ // bmiHeader
+ sizeof(BITMAPINFOHEADER),// biSize
+ 720, // biWidth
+ 576 // biHeight
+ }
+ // implicitly sets the others fields to 0
+ }
};
/// Media type, Video MPEG2
static const AM_MEDIA_TYPE mt_Mpv = {
- MEDIATYPE_Video, // majortype
- MEDIASUBTYPE_MPEG2_VIDEO, // subtype
- FALSE, // bFixedSizeSamples
- TRUE, // bTemporalCompression
- 0, // lSampleSize
- FORMAT_MPEG2Video, // formattype
- NULL, // pUnk
- sizeof(sMpv_fmt), // cbFormat
- (LPBYTE)&sMpv_fmt // pbFormat
+ MEDIATYPE_Video, // majortype
+ MEDIASUBTYPE_MPEG2_VIDEO, // subtype
+ FALSE, // bFixedSizeSamples
+ TRUE, // bTemporalCompression
+ 0, // lSampleSize
+ FORMAT_MPEG2Video, // formattype
+ NULL, // pUnk
+ sizeof(sMpv_fmt), // cbFormat
+ (LPBYTE)& sMpv_fmt // pbFormat
};
#define FCC_h264 MAKEFOURCC('h', '2', '6', '4')
/// Format, Video H264
static const VIDEOINFOHEADER2 vih2_H264 = {
- {0,0,0,0}, // rcSource
- {0,0,0,0}, // rcTarget
- 0, // dwBitRate,
- 0, // dwBitErrorRate
- 0, // AvgTimePerFrame
- 0, // dwInterlaceFlags
- 0, // dwCopyProtectFlags
- 0, // dwPictAspectRatioX
- 0, // dwPictAspectRatioY
- {0}, // dwControlFlag & dwReserved1
- 0, // dwReserved2
- {
- // bmiHeader
- sizeof(BITMAPINFOHEADER), // biSize
- // 720, // biWidth
- // 576, // biHeight
- 1920, // biWidth
- 1080, // biHeight
- 0, // biPlanes
- 0, // biBitCount
- FCC_h264 // biCompression
- }
- // implicitly sets the others fields to 0
+ {0, 0, 0, 0}, // rcSource
+ {0, 0, 0, 0}, // rcTarget
+ 0, // dwBitRate,
+ 0, // dwBitErrorRate
+ 0, // AvgTimePerFrame
+ 0, // dwInterlaceFlags
+ 0, // dwCopyProtectFlags
+ 0, // dwPictAspectRatioX
+ 0, // dwPictAspectRatioY
+ {0}, // dwControlFlag & dwReserved1
+ 0, // dwReserved2
+ {
+ // bmiHeader
+ sizeof(BITMAPINFOHEADER), // biSize
+ // 720, // biWidth
+ // 576, // biHeight
+ 1920, // biWidth
+ 1080, // biHeight
+ 0, // biPlanes
+ 0, // biBitCount
+ FCC_h264 // biCompression
+ }
+ // implicitly sets the others fields to 0
};
/// Media type, Video H264
static const AM_MEDIA_TYPE mt_H264 = {
- MEDIATYPE_Video, // majortype
- MEDIASUBTYPE_H264, // subtype
- FALSE, // bFixedSizeSamples
- TRUE, // bTemporalCompression
- 1, // lSampleSize
- FORMAT_VideoInfo2, // formattype
- NULL, // pUnk
- sizeof(vih2_H264), // cbFormat
- (LPBYTE)&vih2_H264 // pbFormat
+ MEDIATYPE_Video, // majortype
+ MEDIASUBTYPE_H264, // subtype
+ FALSE, // bFixedSizeSamples
+ TRUE, // bTemporalCompression
+ 1, // lSampleSize
+ FORMAT_VideoInfo2, // formattype
+ NULL, // pUnk
+ sizeof(vih2_H264), // cbFormat
+ (LPBYTE)& vih2_H264 // pbFormat
};
/// Format, Audio (common)
static const WAVEFORMATEX wf_Audio = {
- WAVE_FORMAT_PCM, // wFormatTag
- 2, // nChannels
- 48000, // nSamplesPerSec
- 4*48000, // nAvgBytesPerSec
- 4, // nBlockAlign
- 16, // wBitsPerSample
- 0 // cbSize
+ WAVE_FORMAT_PCM, // wFormatTag
+ 2, // nChannels
+ 48000, // nSamplesPerSec
+ 4 * 48000, // nAvgBytesPerSec
+ 4, // nBlockAlign
+ 16, // wBitsPerSample
+ 0 // cbSize
};
/// Media type, Audio MPEG2
static const AM_MEDIA_TYPE mt_Mpa = {
- MEDIATYPE_Audio, // majortype
- MEDIASUBTYPE_MPEG2_AUDIO, // subtype
- TRUE, // bFixedSizeSamples
- FALSE, // bTemporalCompression
- 0, // lSampleSize
- FORMAT_WaveFormatEx, // formattype
- NULL, // pUnk
- sizeof(wf_Audio), // cbFormat
- (LPBYTE)&wf_Audio // pbFormat
+ MEDIATYPE_Audio, // majortype
+ MEDIASUBTYPE_MPEG2_AUDIO, // subtype
+ TRUE, // bFixedSizeSamples
+ FALSE, // bTemporalCompression
+ 0, // lSampleSize
+ FORMAT_WaveFormatEx, // formattype
+ NULL, // pUnk
+ sizeof(wf_Audio), // cbFormat
+ (LPBYTE)& wf_Audio // pbFormat
};
/// Media type, Audio AC3
static const AM_MEDIA_TYPE mt_Ac3 = {
- MEDIATYPE_Audio, // majortype
- MEDIASUBTYPE_DOLBY_AC3, // subtype
- TRUE, // bFixedSizeSamples
- FALSE, // bTemporalCompression
- 0, // lSampleSize
- FORMAT_WaveFormatEx, // formattype
- NULL, // pUnk
- sizeof(wf_Audio), // cbFormat
- (LPBYTE)&wf_Audio, // pbFormat
+ MEDIATYPE_Audio, // majortype
+ MEDIASUBTYPE_DOLBY_AC3, // subtype
+ TRUE, // bFixedSizeSamples
+ FALSE, // bTemporalCompression
+ 0, // lSampleSize
+ FORMAT_WaveFormatEx, // formattype
+ NULL, // pUnk
+ sizeof(wf_Audio), // cbFormat
+ (LPBYTE)& wf_Audio, // pbFormat
};
/// Media type, Audio EAC3
static const AM_MEDIA_TYPE mt_Eac3 = {
- MEDIATYPE_Audio, // majortype
- MEDIASUBTYPE_DOLBY_DDPLUS, // subtype
- TRUE, // bFixedSizeSamples
- FALSE, // bTemporalCompression
- 0, // lSampleSize
- FORMAT_WaveFormatEx, // formattype
- NULL, // pUnk
- sizeof(wf_Audio), // cbFormat
- (LPBYTE)&wf_Audio, // pbFormat
+ MEDIATYPE_Audio, // majortype
+ MEDIASUBTYPE_DOLBY_DDPLUS, // subtype
+ TRUE, // bFixedSizeSamples
+ FALSE, // bTemporalCompression
+ 0, // lSampleSize
+ FORMAT_WaveFormatEx, // formattype
+ NULL, // pUnk
+ sizeof(wf_Audio), // cbFormat
+ (LPBYTE)& wf_Audio, // pbFormat
};
/// Media type, PSI
static const AM_MEDIA_TYPE mt_Psi = {
- MEDIATYPE_MPEG2_SECTIONS, // majortype
- MEDIASUBTYPE_MPEG2DATA, // subtype
- TRUE, // bFixedSizeSamples
- FALSE, // bTemporalCompression
- 0, // lSampleSize
- FORMAT_None, // formattype
- NULL, // pUnk
- 0, // cbFormat
- NULL // pbFormat
+ MEDIATYPE_MPEG2_SECTIONS, // majortype
+ MEDIASUBTYPE_MPEG2DATA, // subtype
+ TRUE, // bFixedSizeSamples
+ FALSE, // bTemporalCompression
+ 0, // lSampleSize
+ FORMAT_None, // formattype
+ NULL, // pUnk
+ 0, // cbFormat
+ NULL // pbFormat
};
/// Media type, TIF
static const AM_MEDIA_TYPE mt_Tif = {
- MEDIATYPE_MPEG2_SECTIONS, // majortype
- MEDIASUBTYPE_DVB_SI, // subtype
- TRUE, // bFixedSizeSamples
- FALSE, // bTemporalCompression
- 0, // lSampleSize
- FORMAT_None, // formattype
- NULL, // pUnk
- 0, // cbFormat
- NULL // pbFormat
+ MEDIATYPE_MPEG2_SECTIONS, // majortype
+ MEDIASUBTYPE_DVB_SI, // subtype
+ TRUE, // bFixedSizeSamples
+ FALSE, // bTemporalCompression
+ 0, // lSampleSize
+ FORMAT_None, // formattype
+ NULL, // pUnk
+ 0, // cbFormat
+ NULL // pbFormat
};
/// Media type, EPG
static const AM_MEDIA_TYPE mt_Epg = {
- MEDIATYPE_MPEG2_SECTIONS, // majortype
- MEDIASUBTYPE_DVB_SI, // subtype
- TRUE, // bFixedSizeSamples
- FALSE, // bTemporalCompression
- 0, // lSampleSize
- FORMAT_None, // formattype
- NULL, // pUnk
- 0, // cbFormat
- NULL, // pbFormat
+ MEDIATYPE_MPEG2_SECTIONS, // majortype
+ MEDIASUBTYPE_DVB_SI, // subtype
+ TRUE, // bFixedSizeSamples
+ FALSE, // bTemporalCompression
+ 0, // lSampleSize
+ FORMAT_None, // formattype
+ NULL, // pUnk
+ 0, // cbFormat
+ NULL, // pbFormat
};
/// Media type, PMT
static const AM_MEDIA_TYPE mt_Pmt = {
- MEDIATYPE_MPEG2_SECTIONS, // majortype
- MEDIASUBTYPE_DVB_SI, // subtype
- TRUE, // bFixedSizeSamples
- FALSE, // bTemporalCompression
- 0, // lSampleSize
- FORMAT_None, // formattype
- NULL, // pUnk
- 0, // cbFormat
- NULL // pbFormat
+ MEDIATYPE_MPEG2_SECTIONS, // majortype
+ MEDIASUBTYPE_DVB_SI, // subtype
+ TRUE, // bFixedSizeSamples
+ FALSE, // bTemporalCompression
+ 0, // lSampleSize
+ FORMAT_None, // formattype
+ NULL, // pUnk
+ 0, // cbFormat
+ NULL // pbFormat
};
static const SUBTITLEINFO SubFormat = { 0, "", L"" };
/// Media type, subtitle
static const AM_MEDIA_TYPE mt_Subtitle = {
- MEDIATYPE_Subtitle, // majortype
- MEDIASUBTYPE_DVB_SUBTITLES, // subtype
- FALSE, // bFixedSizeSamples
- FALSE, // bTemporalCompression
- 0, // lSampleSize
- FORMAT_None, // formattype
- NULL, // pUnk
- sizeof(SubFormat), // cbFormat
- (LPBYTE)&SubFormat // pbFormat
+ MEDIATYPE_Subtitle, // majortype
+ MEDIASUBTYPE_DVB_SUBTITLES, // subtype
+ FALSE, // bFixedSizeSamples
+ FALSE, // bTemporalCompression
+ 0, // lSampleSize
+ FORMAT_None, // formattype
+ NULL, // pUnk
+ sizeof(SubFormat), // cbFormat
+ (LPBYTE)& SubFormat // pbFormat
};
/// CLSID for TIF
@@ -245,632 +245,632 @@ static CLSID CLSID_BDA_MPEG2_TIF =
{0xFC772AB0, 0x0C7F, 0x11D3, {0x8F, 0xF2, 0x00, 0xA0, 0xC9, 0x22, 0x4C, 0xF4}};
CFGManagerBDA::CFGManagerBDA(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd)
- : CFGManagerPlayer (pName, pUnk, hWnd)
+ : CFGManagerPlayer(pName, pUnk, hWnd)
{
- LOG (_T("\nStarting session ------------------------------------------------->"));
- m_DVBStreams[DVB_MPV] = CDVBStream(L"mpv", &mt_Mpv);
- m_DVBStreams[DVB_H264] = CDVBStream(L"h264", &mt_H264);
- m_DVBStreams[DVB_MPA] = CDVBStream(L"mpa", &mt_Mpa);
- m_DVBStreams[DVB_AC3] = CDVBStream(L"ac3", &mt_Ac3);
- m_DVBStreams[DVB_EAC3] = CDVBStream(L"eac3", &mt_Eac3);
- m_DVBStreams[DVB_PSI] = CDVBStream(L"psi", &mt_Psi, true, MEDIA_MPEG2_PSI);
- m_DVBStreams[DVB_TIF] = CDVBStream(L"tif", &mt_Tif, true);
- m_DVBStreams[DVB_EPG] = CDVBStream(L"epg", &mt_Epg);
-
- // Warning : MEDIA_ELEMENTARY_STREAM didn't work for subtitles with Windows XP!
- if (SysVersion::IsVistaOrLater()) {
- m_DVBStreams[DVB_SUB] = CDVBStream(L"sub", &mt_Subtitle/*, false, MEDIA_TRANSPORT_PAYLOAD*/);
- } else {
- m_DVBStreams[DVB_SUB] = CDVBStream(L"sub", &mt_Subtitle, false, MEDIA_TRANSPORT_PAYLOAD);
- }
-
- m_nCurVideoType = DVB_MPV;
- m_nCurAudioType = DVB_MPA;
- m_fHideWindow = false;
-
- // Hack : remove audio switcher !
- POSITION pos = m_transform.GetHeadPosition();
- while (pos) {
- CFGFilter* pFGF = m_transform.GetAt(pos);
- if (pFGF->GetCLSID() == __uuidof(CAudioSwitcherFilter)) {
- m_transform.RemoveAt (pos);
- delete pFGF;
- break;
- }
- m_transform.GetNext(pos);
- }
- LOG (_T("CFGManagerBDA object created."));
+ LOG(_T("\nStarting session ------------------------------------------------->"));
+ m_DVBStreams[DVB_MPV] = CDVBStream(L"mpv", &mt_Mpv);
+ m_DVBStreams[DVB_H264] = CDVBStream(L"h264", &mt_H264);
+ m_DVBStreams[DVB_MPA] = CDVBStream(L"mpa", &mt_Mpa);
+ m_DVBStreams[DVB_AC3] = CDVBStream(L"ac3", &mt_Ac3);
+ m_DVBStreams[DVB_EAC3] = CDVBStream(L"eac3", &mt_Eac3);
+ m_DVBStreams[DVB_PSI] = CDVBStream(L"psi", &mt_Psi, true, MEDIA_MPEG2_PSI);
+ m_DVBStreams[DVB_TIF] = CDVBStream(L"tif", &mt_Tif, true);
+ m_DVBStreams[DVB_EPG] = CDVBStream(L"epg", &mt_Epg);
+
+ // Warning : MEDIA_ELEMENTARY_STREAM didn't work for subtitles with Windows XP!
+ if (SysVersion::IsVistaOrLater()) {
+ m_DVBStreams[DVB_SUB] = CDVBStream(L"sub", &mt_Subtitle/*, false, MEDIA_TRANSPORT_PAYLOAD*/);
+ } else {
+ m_DVBStreams[DVB_SUB] = CDVBStream(L"sub", &mt_Subtitle, false, MEDIA_TRANSPORT_PAYLOAD);
+ }
+
+ m_nCurVideoType = DVB_MPV;
+ m_nCurAudioType = DVB_MPA;
+ m_fHideWindow = false;
+
+ // Hack : remove audio switcher !
+ POSITION pos = m_transform.GetHeadPosition();
+ while (pos) {
+ CFGFilter* pFGF = m_transform.GetAt(pos);
+ if (pFGF->GetCLSID() == __uuidof(CAudioSwitcherFilter)) {
+ m_transform.RemoveAt(pos);
+ delete pFGF;
+ break;
+ }
+ m_transform.GetNext(pos);
+ }
+ LOG(_T("CFGManagerBDA object created."));
}
CFGManagerBDA::~CFGManagerBDA()
{
- m_DVBStreams.RemoveAll();
- LOG (_T("\nCFGManagerBDA object destroyed."));
+ m_DVBStreams.RemoveAll();
+ LOG(_T("\nCFGManagerBDA object destroyed."));
}
HRESULT CFGManagerBDA::CreateKSFilter(IBaseFilter** ppBF, CLSID KSCategory, CStringW& DisplayName)
{
- HRESULT hr = VFW_E_NOT_FOUND;
- BeginEnumSysDev (KSCategory, pMoniker) {
- CComPtr<IPropertyBag> pPB;
- CComVariant var;
- LPOLESTR strName = NULL;
- if (SUCCEEDED (pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB)) &&
- SUCCEEDED (pMoniker->GetDisplayName(NULL, NULL, &strName)) &&
- SUCCEEDED (pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)) ) {
- CStringW Name = CStringW(strName);
- if (Name != DisplayName) {
- continue;
- }
-
- hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter, (void**)ppBF);
- if (SUCCEEDED (hr)) {
- hr = AddFilter (*ppBF, CStringW(var.bstrVal));
- }
- break;
- }
-
- if (strName) {
- CoTaskMemFree(strName);
- }
- }
- EndEnumSysDev
-
- return hr;
+ HRESULT hr = VFW_E_NOT_FOUND;
+ BeginEnumSysDev(KSCategory, pMoniker) {
+ CComPtr<IPropertyBag> pPB;
+ CComVariant var;
+ LPOLESTR strName = NULL;
+ if (SUCCEEDED(pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB)) &&
+ SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName)) &&
+ SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
+ CStringW Name = CStringW(strName);
+ if (Name != DisplayName) {
+ continue;
+ }
+
+ hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter, (void**)ppBF);
+ if (SUCCEEDED(hr)) {
+ hr = AddFilter(*ppBF, CStringW(var.bstrVal));
+ }
+ break;
+ }
+
+ if (strName) {
+ CoTaskMemFree(strName);
+ }
+ }
+ EndEnumSysDev
+
+ return hr;
}
HRESULT CFGManagerBDA::SearchIBDATopology(const CComPtr<IBaseFilter>& pTuner, REFIID iid, CComPtr<IUnknown>& pUnk)
{
- CComQIPtr<IBDA_Topology> pTop(pTuner);
- CheckPointer (pTop, E_NOINTERFACE);
+ CComQIPtr<IBDA_Topology> pTop(pTuner);
+ CheckPointer(pTop, E_NOINTERFACE);
- ULONG NodeTypes;
- ULONG NodeType[32];
+ ULONG NodeTypes;
+ ULONG NodeType[32];
- HRESULT hr = pTop->GetNodeTypes(&NodeTypes, _countof(NodeType), NodeType);
+ HRESULT hr = pTop->GetNodeTypes(&NodeTypes, _countof(NodeType), NodeType);
- if (FAILED(hr)) {
- return hr;
- }
+ if (FAILED(hr)) {
+ return hr;
+ }
- for (ULONG i = 0; i < NodeTypes; i++) {
- ULONG nInterfaces;
- GUID aInterface[32];
+ for (ULONG i = 0; i < NodeTypes; i++) {
+ ULONG nInterfaces;
+ GUID aInterface[32];
- hr = pTop->GetNodeInterfaces(NodeType[i], &nInterfaces, _countof(aInterface), aInterface);
+ hr = pTop->GetNodeInterfaces(NodeType[i], &nInterfaces, _countof(aInterface), aInterface);
- if (FAILED(hr)) {
- continue;
- }
+ if (FAILED(hr)) {
+ continue;
+ }
- for (ULONG j = 0; j < nInterfaces; j++) {
- if (aInterface[j] == iid) {
- return pTop->GetControlNode(0, 1, NodeType[i], &pUnk);
- }
- }
- }
+ for (ULONG j = 0; j < nInterfaces; j++) {
+ if (aInterface[j] == iid) {
+ return pTop->GetControlNode(0, 1, NodeType[i], &pUnk);
+ }
+ }
+ }
- return hr;
+ return hr;
}
HRESULT CFGManagerBDA::ConnectFilters(IBaseFilter* pOutFilter, IBaseFilter* pInFilter)
{
- HRESULT hr = VFW_E_CANNOT_CONNECT;
- BeginEnumPins(pOutFilter, pEP, pOutPin) {
- if (S_OK == IsPinDirection(pOutPin, PINDIR_OUTPUT)
- && S_OK != IsPinConnected(pOutPin)) {
- BeginEnumPins(pInFilter, pEP, pInPin) {
- if (S_OK == IsPinDirection(pInPin, PINDIR_INPUT)
- && S_OK != IsPinConnected(pInPin)) {
- hr = this->ConnectDirect(pOutPin, pInPin, NULL);
-
- /*#ifdef _DEBUG
- PIN_INFO InfoPinIn, InfoPinOut;
- FILTER_INFO InfoFilterIn, InfoFilterOut;
- pInPin->QueryPinInfo (&InfoPinIn);
- pOutPin->QueryPinInfo (&InfoPinOut);
- InfoPinIn.pFilter->QueryFilterInfo(&InfoFilterIn);
- InfoPinOut.pFilter->QueryFilterInfo(&InfoFilterOut);
-
- TRACE ("%S - %S => %S - %S (hr=0x%08x)\n", InfoFilterOut.achName, InfoPinOut.achName, InfoFilterIn.achName, InfoPinIn.achName, hr);
-
- InfoPinIn.pFilter->Release();
- InfoPinOut.pFilter->Release();
- #endif*/
- if (SUCCEEDED (hr)) {
- return hr;
- }
- }
- }
- EndEnumPins;
- }
- }
- EndEnumPins;
-
- return hr;
+ HRESULT hr = VFW_E_CANNOT_CONNECT;
+ BeginEnumPins(pOutFilter, pEP, pOutPin) {
+ if (S_OK == IsPinDirection(pOutPin, PINDIR_OUTPUT)
+ && S_OK != IsPinConnected(pOutPin)) {
+ BeginEnumPins(pInFilter, pEP, pInPin) {
+ if (S_OK == IsPinDirection(pInPin, PINDIR_INPUT)
+ && S_OK != IsPinConnected(pInPin)) {
+ hr = this->ConnectDirect(pOutPin, pInPin, NULL);
+
+ /*#ifdef _DEBUG
+ PIN_INFO InfoPinIn, InfoPinOut;
+ FILTER_INFO InfoFilterIn, InfoFilterOut;
+ pInPin->QueryPinInfo (&InfoPinIn);
+ pOutPin->QueryPinInfo (&InfoPinOut);
+ InfoPinIn.pFilter->QueryFilterInfo(&InfoFilterIn);
+ InfoPinOut.pFilter->QueryFilterInfo(&InfoFilterOut);
+
+ TRACE ("%S - %S => %S - %S (hr=0x%08x)\n", InfoFilterOut.achName, InfoPinOut.achName, InfoFilterIn.achName, InfoPinIn.achName, hr);
+
+ InfoPinIn.pFilter->Release();
+ InfoPinOut.pFilter->Release();
+ #endif*/
+ if (SUCCEEDED(hr)) {
+ return hr;
+ }
+ }
+ }
+ EndEnumPins;
+ }
+ }
+ EndEnumPins;
+
+ return hr;
}
STDMETHODIMP CFGManagerBDA::RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList)
{
- HRESULT hr;
- AppSettings& s = AfxGetAppSettings();
- CComPtr<IBaseFilter> pNetwork;
- CComPtr<IBaseFilter> pTuner;
- CComPtr<IBaseFilter> pReceiver;
-
- LOG (_T("\nCreating BDA filters..."));
- CheckAndLog (CreateKSFilter (&pNetwork, KSCATEGORY_BDA_NETWORK_PROVIDER, s.strBDANetworkProvider), "BDA : Network provider creation");
- if (FAILED(hr = CreateKSFilter (&pTuner, KSCATEGORY_BDA_NETWORK_TUNER, s.strBDATuner))) {
- MessageBox(AfxGetMyApp()->GetMainWnd()->m_hWnd, ResStr(IDS_BDA_ERROR_CREATE_TUNER), ResStr(IDS_BDA_ERROR), MB_ICONERROR | MB_OK);
- TRACE("BDA : Network tuner creation"" :0x%08x\n",hr);
- return hr;
- }
- if (s.strBDATuner.Right(40) != s.strBDAReceiver.Right(40)) { // check if filters are the same
- if (FAILED(hr = CreateKSFilter (&pReceiver, KSCATEGORY_BDA_RECEIVER_COMPONENT, s.strBDAReceiver))) {
- MessageBox(AfxGetMyApp()->GetMainWnd()->m_hWnd, ResStr(IDS_BDA_ERROR_CREATE_RECEIVER), ResStr(IDS_BDA_ERROR), MB_ICONERROR | MB_OK);
- TRACE("BDA : Receiver creation"" :0x%08x\n",hr);
- return hr;
- }
- if (FAILED(hr = ConnectFilters (pNetwork, pTuner))) {
- MessageBox(AfxGetMyApp()->GetMainWnd()->m_hWnd, ResStr(IDS_BDA_ERROR_CONNECT_NW_TUNER), ResStr(IDS_BDA_ERROR), MB_ICONERROR | MB_OK);
- TRACE("BDA : Network <-> Tuner"" :0x%08x\n",hr);
- return hr;
- }
- if (FAILED(hr = ConnectFilters (pTuner, pReceiver))) {
- MessageBox(AfxGetMyApp()->GetMainWnd()->m_hWnd, ResStr(IDS_BDA_ERROR_CONNECT_TUNER_REC), ResStr(IDS_BDA_ERROR), MB_ICONERROR | MB_OK);
- TRACE("BDA : Tuner <-> Receiver"" :0x%08x\n",hr);
- return hr;
- }
- LOG (_T("Network -> Tuner -> Receiver connected."));
-
- CComPtr<IBaseFilter> pMpeg2Demux;
- m_pBDAControl = pTuner;
- if (FAILED(hr = SearchIBDATopology (pTuner, m_pBDAFreq))) {
- AfxMessageBox(_T("BDA Error: IBDA_FrequencyFilter topology."), MB_OK);
- TRACE("BDA : IBDA_FrequencyFilter topology"" :0x%08x\n",hr);
- return hr;
- }
- if (FAILED(hr = SearchIBDATopology (pTuner, m_pBDAStats))) {
- AfxMessageBox(_T("BDA Error: IBDA_SignalStatistics topology."), MB_OK);
- TRACE("BDA : IBDA_SignalStatistics topology"" :0x%08x\n",hr);
- return hr;
- }
-
- // Create Mpeg2 demux
- if (FAILED(hr = CreateMicrosoftDemux (pReceiver, pMpeg2Demux))) {
- MessageBox(AfxGetMyApp()->GetMainWnd()->m_hWnd, ResStr(IDS_BDA_ERROR_DEMULTIPLEXER), ResStr(IDS_BDA_ERROR), MB_ICONERROR | MB_OK);
- TRACE("BDA : Microsoft demux creation"" :0x%08x\n",hr);
- return hr;
- }
- } else { // if same filters, connect pNetwork to pTuner directly
- if (FAILED(hr = ConnectFilters (pNetwork, pTuner))) {
- MessageBox(AfxGetMyApp()->GetMainWnd()->m_hWnd, ResStr(IDS_BDA_ERROR_CONNECT_TUNER), ResStr(IDS_BDA_ERROR), MB_ICONERROR | MB_OK);
- TRACE("BDA : Network <-> Tuner/Receiver"" :0x%08x\n",hr);
- return hr;
- }
-
- CComPtr<IBaseFilter> pMpeg2Demux;
- m_pBDAControl = pTuner;
- if (FAILED(hr = SearchIBDATopology (pTuner, m_pBDAFreq))) {
- AfxMessageBox(_T("BDA Error: IBDA_FrequencyFilter topology."), MB_OK);
- TRACE("BDA : IBDA_FrequencyFilter topology"" :0x%08x\n",hr);
- return hr;
- }
- if (FAILED(hr = SearchIBDATopology (pTuner, m_pBDAStats))) {
- AfxMessageBox(_T("BDA Error: IBDA_SignalStatistics topology."), MB_OK);
- TRACE("BDA : IBDA_SignalStatistics topology"" :0x%08x\n",hr);
- return hr;
- }
- LOG (_T("Network -> Receiver connected."));
-
- // Create Mpeg2 demux
- if (FAILED(hr = CreateMicrosoftDemux (pTuner, pMpeg2Demux))) {
- MessageBox(AfxGetMyApp()->GetMainWnd()->m_hWnd, ResStr(IDS_BDA_ERROR_DEMULTIPLEXER), ResStr(IDS_BDA_ERROR), MB_ICONERROR | MB_OK);
- TRACE("BDA : Microsoft demux creation"" :0x%08x\n",hr);
- return hr;
- }
- }
+ HRESULT hr;
+ AppSettings& s = AfxGetAppSettings();
+ CComPtr<IBaseFilter> pNetwork;
+ CComPtr<IBaseFilter> pTuner;
+ CComPtr<IBaseFilter> pReceiver;
+
+ LOG(_T("\nCreating BDA filters..."));
+ CheckAndLog(CreateKSFilter(&pNetwork, KSCATEGORY_BDA_NETWORK_PROVIDER, s.strBDANetworkProvider), "BDA : Network provider creation");
+ if (FAILED(hr = CreateKSFilter(&pTuner, KSCATEGORY_BDA_NETWORK_TUNER, s.strBDATuner))) {
+ MessageBox(AfxGetMyApp()->GetMainWnd()->m_hWnd, ResStr(IDS_BDA_ERROR_CREATE_TUNER), ResStr(IDS_BDA_ERROR), MB_ICONERROR | MB_OK);
+ TRACE("BDA : Network tuner creation"" :0x%08x\n", hr);
+ return hr;
+ }
+ if (s.strBDATuner.Right(40) != s.strBDAReceiver.Right(40)) { // check if filters are the same
+ if (FAILED(hr = CreateKSFilter(&pReceiver, KSCATEGORY_BDA_RECEIVER_COMPONENT, s.strBDAReceiver))) {
+ MessageBox(AfxGetMyApp()->GetMainWnd()->m_hWnd, ResStr(IDS_BDA_ERROR_CREATE_RECEIVER), ResStr(IDS_BDA_ERROR), MB_ICONERROR | MB_OK);
+ TRACE("BDA : Receiver creation"" :0x%08x\n", hr);
+ return hr;
+ }
+ if (FAILED(hr = ConnectFilters(pNetwork, pTuner))) {
+ MessageBox(AfxGetMyApp()->GetMainWnd()->m_hWnd, ResStr(IDS_BDA_ERROR_CONNECT_NW_TUNER), ResStr(IDS_BDA_ERROR), MB_ICONERROR | MB_OK);
+ TRACE("BDA : Network <-> Tuner"" :0x%08x\n", hr);
+ return hr;
+ }
+ if (FAILED(hr = ConnectFilters(pTuner, pReceiver))) {
+ MessageBox(AfxGetMyApp()->GetMainWnd()->m_hWnd, ResStr(IDS_BDA_ERROR_CONNECT_TUNER_REC), ResStr(IDS_BDA_ERROR), MB_ICONERROR | MB_OK);
+ TRACE("BDA : Tuner <-> Receiver"" :0x%08x\n", hr);
+ return hr;
+ }
+ LOG(_T("Network -> Tuner -> Receiver connected."));
+
+ CComPtr<IBaseFilter> pMpeg2Demux;
+ m_pBDAControl = pTuner;
+ if (FAILED(hr = SearchIBDATopology(pTuner, m_pBDAFreq))) {
+ AfxMessageBox(_T("BDA Error: IBDA_FrequencyFilter topology."), MB_OK);
+ TRACE("BDA : IBDA_FrequencyFilter topology"" :0x%08x\n", hr);
+ return hr;
+ }
+ if (FAILED(hr = SearchIBDATopology(pTuner, m_pBDAStats))) {
+ AfxMessageBox(_T("BDA Error: IBDA_SignalStatistics topology."), MB_OK);
+ TRACE("BDA : IBDA_SignalStatistics topology"" :0x%08x\n", hr);
+ return hr;
+ }
+
+ // Create Mpeg2 demux
+ if (FAILED(hr = CreateMicrosoftDemux(pReceiver, pMpeg2Demux))) {
+ MessageBox(AfxGetMyApp()->GetMainWnd()->m_hWnd, ResStr(IDS_BDA_ERROR_DEMULTIPLEXER), ResStr(IDS_BDA_ERROR), MB_ICONERROR | MB_OK);
+ TRACE("BDA : Microsoft demux creation"" :0x%08x\n", hr);
+ return hr;
+ }
+ } else { // if same filters, connect pNetwork to pTuner directly
+ if (FAILED(hr = ConnectFilters(pNetwork, pTuner))) {
+ MessageBox(AfxGetMyApp()->GetMainWnd()->m_hWnd, ResStr(IDS_BDA_ERROR_CONNECT_TUNER), ResStr(IDS_BDA_ERROR), MB_ICONERROR | MB_OK);
+ TRACE("BDA : Network <-> Tuner/Receiver"" :0x%08x\n", hr);
+ return hr;
+ }
+
+ CComPtr<IBaseFilter> pMpeg2Demux;
+ m_pBDAControl = pTuner;
+ if (FAILED(hr = SearchIBDATopology(pTuner, m_pBDAFreq))) {
+ AfxMessageBox(_T("BDA Error: IBDA_FrequencyFilter topology."), MB_OK);
+ TRACE("BDA : IBDA_FrequencyFilter topology"" :0x%08x\n", hr);
+ return hr;
+ }
+ if (FAILED(hr = SearchIBDATopology(pTuner, m_pBDAStats))) {
+ AfxMessageBox(_T("BDA Error: IBDA_SignalStatistics topology."), MB_OK);
+ TRACE("BDA : IBDA_SignalStatistics topology"" :0x%08x\n", hr);
+ return hr;
+ }
+ LOG(_T("Network -> Receiver connected."));
+
+ // Create Mpeg2 demux
+ if (FAILED(hr = CreateMicrosoftDemux(pTuner, pMpeg2Demux))) {
+ MessageBox(AfxGetMyApp()->GetMainWnd()->m_hWnd, ResStr(IDS_BDA_ERROR_DEMULTIPLEXER), ResStr(IDS_BDA_ERROR), MB_ICONERROR | MB_OK);
+ TRACE("BDA : Microsoft demux creation"" :0x%08x\n", hr);
+ return hr;
+ }
+ }
#ifdef _DEBUG
- LOG (_T("\nFilter list:"));
- BeginEnumFilters(this, pEF, pBF) {
- LOG(GetFilterName(pBF));
- }
- EndEnumFilters;
+ LOG(_T("\nFilter list:"));
+ BeginEnumFilters(this, pEF, pBF) {
+ LOG(GetFilterName(pBF));
+ }
+ EndEnumFilters;
#endif
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CFGManagerBDA::ConnectDirect(IPin* pPinOut, IPin* pPinIn, const AM_MEDIA_TYPE* pmt)
{
- // Bypass CFGManagerPlayer limitation (IMediaSeeking for Mpeg2 demux)
- return CFGManagerCustom::ConnectDirect (pPinOut, pPinIn, pmt);
+ // Bypass CFGManagerPlayer limitation (IMediaSeeking for Mpeg2 demux)
+ return CFGManagerCustom::ConnectDirect(pPinOut, pPinIn, pmt);
}
-STDMETHODIMP CFGManagerBDA::SetChannel (int nChannelPrefNumber)
+STDMETHODIMP CFGManagerBDA::SetChannel(int nChannelPrefNumber)
{
- HRESULT hr = E_INVALIDARG;
- AppSettings& s = AfxGetAppSettings();
- CDVBChannel* pChannel = s.FindChannelByPref(nChannelPrefNumber);
+ HRESULT hr = E_INVALIDARG;
+ AppSettings& s = AfxGetAppSettings();
+ CDVBChannel* pChannel = s.FindChannelByPref(nChannelPrefNumber);
- if (pChannel != NULL) {
- hr = SetChannelInternal (pChannel);
+ if (pChannel != NULL) {
+ hr = SetChannelInternal(pChannel);
- if (SUCCEEDED (hr)) {
- s.nDVBLastChannel = nChannelPrefNumber;
- }
- }
+ if (SUCCEEDED(hr)) {
+ s.nDVBLastChannel = nChannelPrefNumber;
+ }
+ }
- return hr;
+ return hr;
}
-STDMETHODIMP CFGManagerBDA::SetAudio (int nAudioIndex)
+STDMETHODIMP CFGManagerBDA::SetAudio(int nAudioIndex)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CFGManagerBDA::SetFrequency(ULONG freq)
{
- HRESULT hr;
- AppSettings& s = AfxGetAppSettings();
- CheckPointer (m_pBDAControl, E_FAIL);
- CheckPointer (m_pBDAFreq, E_FAIL);
-
- CheckAndLog (m_pBDAControl->StartChanges(), "BDA : Setfrequency StartChanges");
- CheckAndLog (m_pBDAFreq->put_Bandwidth(s.iBDABandwidth), "BDA : Setfrequency put_Bandwidth");
- CheckAndLog (m_pBDAFreq->put_Frequency(freq), "BDA : Setfrequency put_Frequency");
- CheckAndLog (m_pBDAControl->CheckChanges(), "BDA : Setfrequency CheckChanges");
- CheckAndLog (m_pBDAControl->CommitChanges(), "BDA : Setfrequency CommitChanges");
-
- return hr;
+ HRESULT hr;
+ AppSettings& s = AfxGetAppSettings();
+ CheckPointer(m_pBDAControl, E_FAIL);
+ CheckPointer(m_pBDAFreq, E_FAIL);
+
+ CheckAndLog(m_pBDAControl->StartChanges(), "BDA : Setfrequency StartChanges");
+ CheckAndLog(m_pBDAFreq->put_Bandwidth(s.iBDABandwidth), "BDA : Setfrequency put_Bandwidth");
+ CheckAndLog(m_pBDAFreq->put_Frequency(freq), "BDA : Setfrequency put_Frequency");
+ CheckAndLog(m_pBDAControl->CheckChanges(), "BDA : Setfrequency CheckChanges");
+ CheckAndLog(m_pBDAControl->CommitChanges(), "BDA : Setfrequency CommitChanges");
+
+ return hr;
}
STDMETHODIMP CFGManagerBDA::Scan(ULONG ulFrequency, HWND hWnd)
{
- CMpeg2DataParser Parser (m_DVBStreams[DVB_PSI].GetFilter());
+ CMpeg2DataParser Parser(m_DVBStreams[DVB_PSI].GetFilter());
- Parser.ParseSDT(ulFrequency);
- Parser.ParsePAT();
- Parser.ParseNIT();
+ Parser.ParseSDT(ulFrequency);
+ Parser.ParsePAT();
+ Parser.ParseNIT();
- POSITION pos = Parser.Channels.GetStartPosition();
- while (pos) {
- CDVBChannel& Channel = Parser.Channels.GetNextValue(pos);
- if (Channel.HasName()) {
- ::SendMessage (hWnd, WM_TUNER_NEW_CHANNEL, 0, (LPARAM)(LPCTSTR)Channel.ToString());
- }
- }
+ POSITION pos = Parser.Channels.GetStartPosition();
+ while (pos) {
+ CDVBChannel& Channel = Parser.Channels.GetNextValue(pos);
+ if (Channel.HasName()) {
+ ::SendMessage(hWnd, WM_TUNER_NEW_CHANNEL, 0, (LPARAM)(LPCTSTR)Channel.ToString());
+ }
+ }
- return S_OK;
+ return S_OK;
}
-STDMETHODIMP CFGManagerBDA::GetStats (BOOLEAN& bPresent, BOOLEAN& bLocked, LONG& lStrength, LONG& lQuality)
+STDMETHODIMP CFGManagerBDA::GetStats(BOOLEAN& bPresent, BOOLEAN& bLocked, LONG& lStrength, LONG& lQuality)
{
- HRESULT hr;
- CheckPointer (m_pBDAStats, E_UNEXPECTED);
+ HRESULT hr;
+ CheckPointer(m_pBDAStats, E_UNEXPECTED);
- CheckNoLog (m_pBDAStats->get_SignalPresent (&bPresent));
- CheckNoLog (m_pBDAStats->get_SignalLocked (&bLocked));
- CheckNoLog (m_pBDAStats->get_SignalStrength (&lStrength));
- CheckNoLog (m_pBDAStats->get_SignalQuality (&lQuality));
+ CheckNoLog(m_pBDAStats->get_SignalPresent(&bPresent));
+ CheckNoLog(m_pBDAStats->get_SignalLocked(&bLocked));
+ CheckNoLog(m_pBDAStats->get_SignalStrength(&lStrength));
+ CheckNoLog(m_pBDAStats->get_SignalQuality(&lQuality));
- return S_OK;
+ return S_OK;
}
// IAMStreamSelect
STDMETHODIMP CFGManagerBDA::Count(DWORD* pcStreams)
{
- CheckPointer(pcStreams, E_POINTER);
- AppSettings& s = AfxGetAppSettings();
- CDVBChannel* pChannel = s.FindChannelByPref(s.nDVBLastChannel);
+ CheckPointer(pcStreams, E_POINTER);
+ AppSettings& s = AfxGetAppSettings();
+ CDVBChannel* pChannel = s.FindChannelByPref(s.nDVBLastChannel);
- *pcStreams = 0;
+ *pcStreams = 0;
- if (pChannel != 0) {
- *pcStreams = pChannel->GetAudioCount() + pChannel->GetSubtitleCount();
- }
+ if (pChannel != 0) {
+ *pcStreams = pChannel->GetAudioCount() + pChannel->GetSubtitleCount();
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CFGManagerBDA::Enable(long lIndex, DWORD dwFlags)
{
- HRESULT hr = E_INVALIDARG;
- AppSettings& s = AfxGetAppSettings();
- CDVBChannel* pChannel = s.FindChannelByPref(s.nDVBLastChannel);
- DVBStreamInfo* pStreamInfo = NULL;
- CDVBStream* pStream = NULL;
- FILTER_STATE nState;
-
- if (pChannel) {
- if (lIndex>=0 && lIndex < pChannel->GetAudioCount()) {
- pStreamInfo = pChannel->GetAudio(lIndex);
- pStream = &m_DVBStreams[pStreamInfo->Type];
- if (pStream && pStreamInfo) {
- nState = GetState();
- if (m_nCurAudioType != pStreamInfo->Type) {
- SwitchStream (m_nCurAudioType, pStreamInfo->Type);
- }
- pStream->Map (pStreamInfo->PID);
- ChangeState ((FILTER_STATE)nState);
-
- hr = S_OK;
- }
- } else if (lIndex > 0 && lIndex < pChannel->GetAudioCount()+pChannel->GetSubtitleCount()) {
- pStreamInfo = pChannel->GetSubtitle(lIndex-pChannel->GetAudioCount());
-
- if (pStreamInfo) {
- m_DVBStreams[DVB_SUB].Map(pStreamInfo->PID);
- hr = S_OK;
- }
- }
- }
-
- return hr;
+ HRESULT hr = E_INVALIDARG;
+ AppSettings& s = AfxGetAppSettings();
+ CDVBChannel* pChannel = s.FindChannelByPref(s.nDVBLastChannel);
+ DVBStreamInfo* pStreamInfo = NULL;
+ CDVBStream* pStream = NULL;
+ FILTER_STATE nState;
+
+ if (pChannel) {
+ if (lIndex >= 0 && lIndex < pChannel->GetAudioCount()) {
+ pStreamInfo = pChannel->GetAudio(lIndex);
+ pStream = &m_DVBStreams[pStreamInfo->Type];
+ if (pStream && pStreamInfo) {
+ nState = GetState();
+ if (m_nCurAudioType != pStreamInfo->Type) {
+ SwitchStream(m_nCurAudioType, pStreamInfo->Type);
+ }
+ pStream->Map(pStreamInfo->PID);
+ ChangeState((FILTER_STATE)nState);
+
+ hr = S_OK;
+ }
+ } else if (lIndex > 0 && lIndex < pChannel->GetAudioCount() + pChannel->GetSubtitleCount()) {
+ pStreamInfo = pChannel->GetSubtitle(lIndex - pChannel->GetAudioCount());
+
+ if (pStreamInfo) {
+ m_DVBStreams[DVB_SUB].Map(pStreamInfo->PID);
+ hr = S_OK;
+ }
+ }
+ }
+
+ return hr;
}
STDMETHODIMP CFGManagerBDA::Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* pdwFlags, LCID* plcid, DWORD* pdwGroup, WCHAR** ppszName, IUnknown** ppObject, IUnknown** ppUnk)
{
- HRESULT hr = E_INVALIDARG;
- AppSettings& s = AfxGetAppSettings();
- CDVBChannel* pChannel = s.FindChannelByPref(s.nDVBLastChannel);
- DVBStreamInfo* pStreamInfo = NULL;
- CDVBStream* pStream = NULL;
- CDVBStream* pCurrentStream = NULL;
-
- if (pChannel) {
- if (lIndex>=0 && lIndex < pChannel->GetAudioCount()) {
- pCurrentStream = &m_DVBStreams[m_nCurAudioType];
- pStreamInfo = pChannel->GetAudio(lIndex);
- if (pStreamInfo) {
- pStream = &m_DVBStreams[pStreamInfo->Type];
- }
- if (pdwGroup) {
- *pdwGroup = 1; // Audio group
- }
- } else if (lIndex > 0 && lIndex < pChannel->GetAudioCount()+pChannel->GetSubtitleCount()) {
- pCurrentStream = &m_DVBStreams[DVB_SUB];
- pStreamInfo = pChannel->GetSubtitle(lIndex-pChannel->GetAudioCount());
- if (pStreamInfo) {
- pStream = &m_DVBStreams[pStreamInfo->Type];
- }
- if (pdwGroup) {
- *pdwGroup = 2; // Subtitle group
- }
- }
-
- if (pStreamInfo && pStream && pCurrentStream) {
- if (ppmt) {
- *ppmt = CreateMediaType(pStream->GetMediaType());
- }
- if (pdwFlags) {
- *pdwFlags = (pCurrentStream->GetMappedPID() == pStreamInfo->PID) ? AMSTREAMSELECTINFO_ENABLED|AMSTREAMSELECTINFO_EXCLUSIVE : 0;
- }
- if (plcid) {
- *plcid = pStreamInfo->GetLCID();
- }
- if (ppObject) {
- *ppObject = NULL;
- }
- if (ppUnk) {
- *ppUnk = NULL;
- }
- if (ppszName) {
- CStringW str;
-
- str = StreamTypeToName(pStreamInfo->PesType);
-
- *ppszName = (WCHAR*)CoTaskMemAlloc((str.GetLength()+1)*sizeof(WCHAR));
- if (*ppszName == NULL) {
- return E_OUTOFMEMORY;
- }
- wcscpy_s(*ppszName, str.GetLength()+1, str);
- }
-
- hr = S_OK;
- }
- }
-
- return hr;
+ HRESULT hr = E_INVALIDARG;
+ AppSettings& s = AfxGetAppSettings();
+ CDVBChannel* pChannel = s.FindChannelByPref(s.nDVBLastChannel);
+ DVBStreamInfo* pStreamInfo = NULL;
+ CDVBStream* pStream = NULL;
+ CDVBStream* pCurrentStream = NULL;
+
+ if (pChannel) {
+ if (lIndex >= 0 && lIndex < pChannel->GetAudioCount()) {
+ pCurrentStream = &m_DVBStreams[m_nCurAudioType];
+ pStreamInfo = pChannel->GetAudio(lIndex);
+ if (pStreamInfo) {
+ pStream = &m_DVBStreams[pStreamInfo->Type];
+ }
+ if (pdwGroup) {
+ *pdwGroup = 1; // Audio group
+ }
+ } else if (lIndex > 0 && lIndex < pChannel->GetAudioCount() + pChannel->GetSubtitleCount()) {
+ pCurrentStream = &m_DVBStreams[DVB_SUB];
+ pStreamInfo = pChannel->GetSubtitle(lIndex - pChannel->GetAudioCount());
+ if (pStreamInfo) {
+ pStream = &m_DVBStreams[pStreamInfo->Type];
+ }
+ if (pdwGroup) {
+ *pdwGroup = 2; // Subtitle group
+ }
+ }
+
+ if (pStreamInfo && pStream && pCurrentStream) {
+ if (ppmt) {
+ *ppmt = CreateMediaType(pStream->GetMediaType());
+ }
+ if (pdwFlags) {
+ *pdwFlags = (pCurrentStream->GetMappedPID() == pStreamInfo->PID) ? AMSTREAMSELECTINFO_ENABLED | AMSTREAMSELECTINFO_EXCLUSIVE : 0;
+ }
+ if (plcid) {
+ *plcid = pStreamInfo->GetLCID();
+ }
+ if (ppObject) {
+ *ppObject = NULL;
+ }
+ if (ppUnk) {
+ *ppUnk = NULL;
+ }
+ if (ppszName) {
+ CStringW str;
+
+ str = StreamTypeToName(pStreamInfo->PesType);
+
+ *ppszName = (WCHAR*)CoTaskMemAlloc((str.GetLength() + 1) * sizeof(WCHAR));
+ if (*ppszName == NULL) {
+ return E_OUTOFMEMORY;
+ }
+ wcscpy_s(*ppszName, str.GetLength() + 1, str);
+ }
+
+ hr = S_OK;
+ }
+ }
+
+ return hr;
}
STDMETHODIMP CFGManagerBDA::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- QI(IBDATuner)
- QI(IAMStreamSelect)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IBDATuner)
+ QI(IAMStreamSelect)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CFGManagerBDA::CreateMicrosoftDemux(IBaseFilter* pReceiver, CComPtr<IBaseFilter>& pMpeg2Demux)
{
- CComPtr<IMpeg2Demultiplexer> pDemux;
- HRESULT hr;
-
- CheckNoLog (pMpeg2Demux.CoCreateInstance (CLSID_MPEG2Demultiplexer, NULL, CLSCTX_INPROC_SERVER));
- CheckNoLog (AddFilter (pMpeg2Demux, _T("MPEG-2 Demultiplexer")));
- CheckNoLog (ConnectFilters (pReceiver, pMpeg2Demux));
- CheckNoLog (pMpeg2Demux->QueryInterface(IID_IMpeg2Demultiplexer, (void**)&pDemux));
-
- // Cleanup unnecessary pins
- //for (int i=0; i<6; i++)
- //{
- // CStringW strPin;
- // strPin.Format(L"%d", i);
- // pDemux->DeleteOutputPin((LPWSTR)(LPCWSTR)strPin);
- //}
-
- LOG (_T("Receiver -> Demux connected."));
-
- POSITION pos = m_DVBStreams.GetStartPosition();
- while (pos) {
- CComPtr<IPin> pPin;
- DVB_STREAM_TYPE nType = m_DVBStreams.GetNextKey(pos);
- CDVBStream& Stream = m_DVBStreams[nType];
-
- if (nType != DVB_EPG) { // Hack: DVB_EPG not required
- if (!Stream.GetFindExisting() ||
- (pPin = FindPin (pMpeg2Demux, PINDIR_OUTPUT, Stream.GetMediaType())) == NULL) {
- CheckNoLog (pDemux->CreateOutputPin ((AM_MEDIA_TYPE*)Stream.GetMediaType(), Stream.GetName(), &pPin));
- }
-
- if (nType == m_nCurVideoType || nType == m_nCurAudioType) {
- CheckNoLog (Connect (pPin, NULL, true));
- Stream.SetPin (pPin);
- LOG (_T("Graph completed for stream type %d."),nType);
- } else {
- CheckNoLog (Connect (pPin, NULL, false));
- Stream.SetPin (pPin);
- LOG (_T("Filter connected to Demux for media type %d."),nType);
- }
- if (nType == DVB_H264) {
- m_pPin_h264 = pPin; // Demux h264 output pin
- }
- }
- }
-
- return S_OK;
+ CComPtr<IMpeg2Demultiplexer> pDemux;
+ HRESULT hr;
+
+ CheckNoLog(pMpeg2Demux.CoCreateInstance(CLSID_MPEG2Demultiplexer, NULL, CLSCTX_INPROC_SERVER));
+ CheckNoLog(AddFilter(pMpeg2Demux, _T("MPEG-2 Demultiplexer")));
+ CheckNoLog(ConnectFilters(pReceiver, pMpeg2Demux));
+ CheckNoLog(pMpeg2Demux->QueryInterface(IID_IMpeg2Demultiplexer, (void**)&pDemux));
+
+ // Cleanup unnecessary pins
+ //for (int i=0; i<6; i++)
+ //{
+ // CStringW strPin;
+ // strPin.Format(L"%d", i);
+ // pDemux->DeleteOutputPin((LPWSTR)(LPCWSTR)strPin);
+ //}
+
+ LOG(_T("Receiver -> Demux connected."));
+
+ POSITION pos = m_DVBStreams.GetStartPosition();
+ while (pos) {
+ CComPtr<IPin> pPin;
+ DVB_STREAM_TYPE nType = m_DVBStreams.GetNextKey(pos);
+ CDVBStream& Stream = m_DVBStreams[nType];
+
+ if (nType != DVB_EPG) { // Hack: DVB_EPG not required
+ if (!Stream.GetFindExisting() ||
+ (pPin = FindPin(pMpeg2Demux, PINDIR_OUTPUT, Stream.GetMediaType())) == NULL) {
+ CheckNoLog(pDemux->CreateOutputPin((AM_MEDIA_TYPE*)Stream.GetMediaType(), Stream.GetName(), &pPin));
+ }
+
+ if (nType == m_nCurVideoType || nType == m_nCurAudioType) {
+ CheckNoLog(Connect(pPin, NULL, true));
+ Stream.SetPin(pPin);
+ LOG(_T("Graph completed for stream type %d."), nType);
+ } else {
+ CheckNoLog(Connect(pPin, NULL, false));
+ Stream.SetPin(pPin);
+ LOG(_T("Filter connected to Demux for media type %d."), nType);
+ }
+ if (nType == DVB_H264) {
+ m_pPin_h264 = pPin; // Demux h264 output pin
+ }
+ }
+ }
+
+ return S_OK;
}
-HRESULT CFGManagerBDA::SetChannelInternal (CDVBChannel* pChannel)
+HRESULT CFGManagerBDA::SetChannelInternal(CDVBChannel* pChannel)
{
- HRESULT hr = S_OK;
- bool fRadioToTV = false;
-
- int nState = GetState();
-
- if (pChannel->GetVideoPID() != 0) {
- SwitchStream (m_nCurVideoType, pChannel->GetVideoType());
- if (m_fHideWindow) {
- fRadioToTV = true;
- }
- } else {
- m_fHideWindow = true;
- ((CMainFrame*)AfxGetMainWnd())->HideVideoWindow(m_fHideWindow);
- }
-
- SwitchStream (m_nCurAudioType, pChannel->GetDefaultAudioType());
-
- // Re-connection needed for H264 to allow different formats of H264 channels
- // Makes possible switching between H264 channels of different resolutions
- // and/or between interlaced and progressive.
-
- if (m_nCurVideoType == DVB_H264) {
- CComPtr<IPin> pInPin;
- m_pPin_h264->ConnectedTo(&pInPin);
- m_pPin_h264->Disconnect();
- pInPin->Disconnect();
- ConnectDirect(m_pPin_h264, pInPin, NULL);
- }
-
- CheckNoLog (SetFrequency (pChannel->GetFrequency()));
- if (pChannel->GetVideoPID() != 0) {
- CheckNoLog (m_DVBStreams[m_nCurVideoType].Map (pChannel->GetVideoPID()));
- }
-
- CheckNoLog (m_DVBStreams[m_nCurAudioType].Map (pChannel->GetDefaultAudioPID()));
-
- if (GetState() == State_Stopped) {
- hr = ChangeState ((FILTER_STATE)nState);
- }
-
- if (fRadioToTV) {
- m_fHideWindow = false;
- Sleep(1800);
- ((CMainFrame*)AfxGetMainWnd())->HideVideoWindow(m_fHideWindow);
- }
-
- // TODO : remove sub later!
- // CheckNoLog (m_DVBStreams[DVB_SUB].Map (pChannel->GetDefaultSubtitlePID()));
-
- return hr;
+ HRESULT hr = S_OK;
+ bool fRadioToTV = false;
+
+ int nState = GetState();
+
+ if (pChannel->GetVideoPID() != 0) {
+ SwitchStream(m_nCurVideoType, pChannel->GetVideoType());
+ if (m_fHideWindow) {
+ fRadioToTV = true;
+ }
+ } else {
+ m_fHideWindow = true;
+ ((CMainFrame*)AfxGetMainWnd())->HideVideoWindow(m_fHideWindow);
+ }
+
+ SwitchStream(m_nCurAudioType, pChannel->GetDefaultAudioType());
+
+ // Re-connection needed for H264 to allow different formats of H264 channels
+ // Makes possible switching between H264 channels of different resolutions
+ // and/or between interlaced and progressive.
+
+ if (m_nCurVideoType == DVB_H264) {
+ CComPtr<IPin> pInPin;
+ m_pPin_h264->ConnectedTo(&pInPin);
+ m_pPin_h264->Disconnect();
+ pInPin->Disconnect();
+ ConnectDirect(m_pPin_h264, pInPin, NULL);
+ }
+
+ CheckNoLog(SetFrequency(pChannel->GetFrequency()));
+ if (pChannel->GetVideoPID() != 0) {
+ CheckNoLog(m_DVBStreams[m_nCurVideoType].Map(pChannel->GetVideoPID()));
+ }
+
+ CheckNoLog(m_DVBStreams[m_nCurAudioType].Map(pChannel->GetDefaultAudioPID()));
+
+ if (GetState() == State_Stopped) {
+ hr = ChangeState((FILTER_STATE)nState);
+ }
+
+ if (fRadioToTV) {
+ m_fHideWindow = false;
+ Sleep(1800);
+ ((CMainFrame*)AfxGetMainWnd())->HideVideoWindow(m_fHideWindow);
+ }
+
+ // TODO : remove sub later!
+ // CheckNoLog (m_DVBStreams[DVB_SUB].Map (pChannel->GetDefaultSubtitlePID()));
+
+ return hr;
}
-HRESULT CFGManagerBDA::SwitchStream (DVB_STREAM_TYPE& nOldType, DVB_STREAM_TYPE nNewType)
+HRESULT CFGManagerBDA::SwitchStream(DVB_STREAM_TYPE& nOldType, DVB_STREAM_TYPE nNewType)
{
- if ((nNewType != nOldType) || (nNewType == DVB_H264)) {
- CComPtr<IBaseFilter> pFGOld = m_DVBStreams[nOldType].GetFilter();
- CComPtr<IBaseFilter> pFGNew = m_DVBStreams[nNewType].GetFilter();
- CComPtr<IPin> pOldOut = GetFirstPin (pFGOld, PINDIR_OUTPUT);
- CComPtr<IPin> pInPin;
- CComPtr<IPin> pNewOut = GetFirstPin (pFGNew, PINDIR_OUTPUT);
-
- if (GetState() != State_Stopped) {
- ChangeState (State_Stopped);
- }
- pOldOut->ConnectedTo(&pInPin);
- Disconnect (pOldOut);
- Disconnect (pInPin);
- ConnectDirect(pNewOut, pInPin, NULL);
- nOldType = nNewType;
- }
- return S_OK;
+ if ((nNewType != nOldType) || (nNewType == DVB_H264)) {
+ CComPtr<IBaseFilter> pFGOld = m_DVBStreams[nOldType].GetFilter();
+ CComPtr<IBaseFilter> pFGNew = m_DVBStreams[nNewType].GetFilter();
+ CComPtr<IPin> pOldOut = GetFirstPin(pFGOld, PINDIR_OUTPUT);
+ CComPtr<IPin> pInPin;
+ CComPtr<IPin> pNewOut = GetFirstPin(pFGNew, PINDIR_OUTPUT);
+
+ if (GetState() != State_Stopped) {
+ ChangeState(State_Stopped);
+ }
+ pOldOut->ConnectedTo(&pInPin);
+ Disconnect(pOldOut);
+ Disconnect(pInPin);
+ ConnectDirect(pNewOut, pInPin, NULL);
+ nOldType = nNewType;
+ }
+ return S_OK;
}
-HRESULT CFGManagerBDA::UpdatePSI(PresentFollowing &NowNext)
+HRESULT CFGManagerBDA::UpdatePSI(PresentFollowing& NowNext)
{
- HRESULT hr = S_FALSE;
- AppSettings& s = AfxGetAppSettings();
- CDVBChannel* pChannel = s.FindChannelByPref(s.nDVBLastChannel);
- CMpeg2DataParser Parser (m_DVBStreams[DVB_PSI].GetFilter());
+ HRESULT hr = S_FALSE;
+ AppSettings& s = AfxGetAppSettings();
+ CDVBChannel* pChannel = s.FindChannelByPref(s.nDVBLastChannel);
+ CMpeg2DataParser Parser(m_DVBStreams[DVB_PSI].GetFilter());
- if (pChannel->GetNowNextFlag()) {
- hr = Parser.ParseEIT(pChannel->GetSID(), NowNext);
- }
+ if (pChannel->GetNowNextFlag()) {
+ hr = Parser.ParseEIT(pChannel->GetSID(), NowNext);
+ }
- return hr;
+ return hr;
}
HRESULT CFGManagerBDA::ChangeState(FILTER_STATE nRequested)
{
- HRESULT hr = S_OK;
- OAFilterState nState = nRequested+1;
-
- CComPtr<IMediaControl> pMC;
- QueryInterface(__uuidof(IMediaControl), (void**) &pMC);
- pMC->GetState (500, &nState);
- if (nState != nRequested) {
- switch (nRequested) {
- case State_Stopped : {
- if (SUCCEEDED(hr = pMC->Stop())) {
- ((CMainFrame*)AfxGetMainWnd())->KillTimersStop();
- }
- LOG (_T("IMediaControl stop: %d."),hr);
- return hr;
- }
- case State_Paused : {
- LOG (_T("IMediaControl pause."));
- return pMC->Pause();
- }
- case State_Running : {
- int iCount = 0;
- hr = S_FALSE;
- while ((hr == S_FALSE) && (iCount++ < 10)) {
- hr = pMC->Run();
- if (hr == S_FALSE) {
- Sleep(50);
- }
- }
- if (SUCCEEDED(hr)) {
- ((CMainFrame*)AfxGetMainWnd())->SetTimersPlay();
- }
- LOG (_T("IMediaControl play: %d."),hr);
- return hr;
- }
- }
- }
- return hr;
+ HRESULT hr = S_OK;
+ OAFilterState nState = nRequested + 1;
+
+ CComPtr<IMediaControl> pMC;
+ QueryInterface(__uuidof(IMediaControl), (void**) &pMC);
+ pMC->GetState(500, &nState);
+ if (nState != nRequested) {
+ switch (nRequested) {
+ case State_Stopped : {
+ if (SUCCEEDED(hr = pMC->Stop())) {
+ ((CMainFrame*)AfxGetMainWnd())->KillTimersStop();
+ }
+ LOG(_T("IMediaControl stop: %d."), hr);
+ return hr;
+ }
+ case State_Paused : {
+ LOG(_T("IMediaControl pause."));
+ return pMC->Pause();
+ }
+ case State_Running : {
+ int iCount = 0;
+ hr = S_FALSE;
+ while ((hr == S_FALSE) && (iCount++ < 10)) {
+ hr = pMC->Run();
+ if (hr == S_FALSE) {
+ Sleep(50);
+ }
+ }
+ if (SUCCEEDED(hr)) {
+ ((CMainFrame*)AfxGetMainWnd())->SetTimersPlay();
+ }
+ LOG(_T("IMediaControl play: %d."), hr);
+ return hr;
+ }
+ }
+ }
+ return hr;
}
FILTER_STATE CFGManagerBDA::GetState()
{
- CComPtr<IMediaControl> pMC;
- OAFilterState nState;
- QueryInterface(__uuidof(IMediaControl), (void**) &pMC);
- pMC->GetState (500, &nState);
+ CComPtr<IMediaControl> pMC;
+ OAFilterState nState;
+ QueryInterface(__uuidof(IMediaControl), (void**) &pMC);
+ pMC->GetState(500, &nState);
- return (FILTER_STATE) nState;
+ return (FILTER_STATE) nState;
}
diff --git a/src/mpc-hc/FGManagerBDA.h b/src/mpc-hc/FGManagerBDA.h
index 58c226c88..b0c3afc64 100644
--- a/src/mpc-hc/FGManagerBDA.h
+++ b/src/mpc-hc/FGManagerBDA.h
@@ -31,156 +31,156 @@
class CDVBStream
{
public :
- CDVBStream() :
- m_ulMappedPID(0) {
- }
-
- CDVBStream(LPWSTR strName, const AM_MEDIA_TYPE * pmt, bool bFindExisting = false, MEDIA_SAMPLE_CONTENT nMsc=MEDIA_ELEMENTARY_STREAM) :
- m_Name(strName),
- m_bFindExisting(bFindExisting),
- m_pmt(pmt),
- m_nMsc(nMsc),
- m_ulMappedPID(0)
- {}
-
- LPWSTR GetName() { /*const*/
- return m_Name;
- };
- const AM_MEDIA_TYPE* GetMediaType() { /*const*/
- return m_pmt;
- };
- bool GetFindExisting() const {
- return m_bFindExisting;
- };
- IBaseFilter* GetFilter() {
- return m_pFilter;
- };
-
- void SetPin(IPin* pPin) {
- CComPtr<IPin> pPinOut;
- PIN_INFO PinInfo;
-
- m_pMap = pPin;
- if (m_pMap &&
- SUCCEEDED (pPin->ConnectedTo (&pPinOut)) &&
- SUCCEEDED (pPinOut->QueryPinInfo (&PinInfo))) {
- m_pFilter.Attach (PinInfo.pFilter);
- }
- }
-
- HRESULT Map (ULONG ulPID) {
- CheckPointer (m_pMap, E_UNEXPECTED);
- ClearMaps();
- m_ulMappedPID = ulPID;
- return m_pMap->MapPID (1, &ulPID, m_nMsc);
- }
-
- HRESULT Unmap (ULONG ulPID) {
- CheckPointer (m_pMap, E_UNEXPECTED);
- m_ulMappedPID = 0;
- return m_pMap->UnmapPID (1, &ulPID);
- }
-
- ULONG GetMappedPID() const {
- return m_ulMappedPID;
- }
+ CDVBStream() :
+ m_ulMappedPID(0) {
+ }
+
+ CDVBStream(LPWSTR strName, const AM_MEDIA_TYPE* pmt, bool bFindExisting = false, MEDIA_SAMPLE_CONTENT nMsc = MEDIA_ELEMENTARY_STREAM) :
+ m_Name(strName),
+ m_bFindExisting(bFindExisting),
+ m_pmt(pmt),
+ m_nMsc(nMsc),
+ m_ulMappedPID(0)
+ {}
+
+ LPWSTR GetName() { /*const*/
+ return m_Name;
+ };
+ const AM_MEDIA_TYPE* GetMediaType() { /*const*/
+ return m_pmt;
+ };
+ bool GetFindExisting() const {
+ return m_bFindExisting;
+ };
+ IBaseFilter* GetFilter() {
+ return m_pFilter;
+ };
+
+ void SetPin(IPin* pPin) {
+ CComPtr<IPin> pPinOut;
+ PIN_INFO PinInfo;
+
+ m_pMap = pPin;
+ if (m_pMap &&
+ SUCCEEDED(pPin->ConnectedTo(&pPinOut)) &&
+ SUCCEEDED(pPinOut->QueryPinInfo(&PinInfo))) {
+ m_pFilter.Attach(PinInfo.pFilter);
+ }
+ }
+
+ HRESULT Map(ULONG ulPID) {
+ CheckPointer(m_pMap, E_UNEXPECTED);
+ ClearMaps();
+ m_ulMappedPID = ulPID;
+ return m_pMap->MapPID(1, &ulPID, m_nMsc);
+ }
+
+ HRESULT Unmap(ULONG ulPID) {
+ CheckPointer(m_pMap, E_UNEXPECTED);
+ m_ulMappedPID = 0;
+ return m_pMap->UnmapPID(1, &ulPID);
+ }
+
+ ULONG GetMappedPID() const {
+ return m_ulMappedPID;
+ }
private :
- CComQIPtr<IMPEG2PIDMap> m_pMap;
- CComPtr<IBaseFilter> m_pFilter;
- const AM_MEDIA_TYPE* m_pmt;
- bool m_bFindExisting;
- LPWSTR m_Name;
- MEDIA_SAMPLE_CONTENT m_nMsc;
- ULONG m_ulMappedPID;
-
- void ClearMaps() {
- HRESULT hr;
- CComPtr<IEnumPIDMap> pEnumMap;
-
- if (SUCCEEDED(hr = m_pMap->EnumPIDMap(&pEnumMap))) {
- PID_MAP maps[8];
- ULONG nbPids = 0;
-
- if (pEnumMap->Next(_countof(maps), maps, &nbPids)==S_OK) {
- for (ULONG i=0; i<nbPids; i++) {
- ULONG pid = maps[i].ulPID;
-
- m_pMap->UnmapPID(1, &pid);
- }
- }
- }
- }
+ CComQIPtr<IMPEG2PIDMap> m_pMap;
+ CComPtr<IBaseFilter> m_pFilter;
+ const AM_MEDIA_TYPE* m_pmt;
+ bool m_bFindExisting;
+ LPWSTR m_Name;
+ MEDIA_SAMPLE_CONTENT m_nMsc;
+ ULONG m_ulMappedPID;
+
+ void ClearMaps() {
+ HRESULT hr;
+ CComPtr<IEnumPIDMap> pEnumMap;
+
+ if (SUCCEEDED(hr = m_pMap->EnumPIDMap(&pEnumMap))) {
+ PID_MAP maps[8];
+ ULONG nbPids = 0;
+
+ if (pEnumMap->Next(_countof(maps), maps, &nbPids) == S_OK) {
+ for (ULONG i = 0; i < nbPids; i++) {
+ ULONG pid = maps[i].ulPID;
+
+ m_pMap->UnmapPID(1, &pid);
+ }
+ }
+ }
+ }
};
class CFGManagerBDA : public CFGManagerPlayer, IBDATuner, IAMStreamSelect
{
public:
- CFGManagerBDA(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd);
- ~CFGManagerBDA();
+ CFGManagerBDA(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd);
+ ~CFGManagerBDA();
- // IGraphBuilder
- STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
+ // IGraphBuilder
+ STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
- // IFilterGraph
- STDMETHODIMP ConnectDirect(IPin* pPinOut, IPin* pPinIn, const AM_MEDIA_TYPE* pmt);
+ // IFilterGraph
+ STDMETHODIMP ConnectDirect(IPin* pPinOut, IPin* pPinIn, const AM_MEDIA_TYPE* pmt);
- // IBDATuner
- STDMETHODIMP SetChannel (int nChannelPrefNumber);
- STDMETHODIMP SetAudio (int nAudioIndex);
- STDMETHODIMP SetFrequency(ULONG freq);
- STDMETHODIMP Scan(ULONG ulFrequency, HWND hWnd);
- STDMETHODIMP GetStats (BOOLEAN& bPresent, BOOLEAN& bLocked, LONG& lStrength, LONG& lQuality);
+ // IBDATuner
+ STDMETHODIMP SetChannel(int nChannelPrefNumber);
+ STDMETHODIMP SetAudio(int nAudioIndex);
+ STDMETHODIMP SetFrequency(ULONG freq);
+ STDMETHODIMP Scan(ULONG ulFrequency, HWND hWnd);
+ STDMETHODIMP GetStats(BOOLEAN& bPresent, BOOLEAN& bLocked, LONG& lStrength, LONG& lQuality);
- // IAMStreamSelect
- STDMETHODIMP Count(DWORD* pcStreams);
- STDMETHODIMP Enable(long lIndex, DWORD dwFlags);
- STDMETHODIMP Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* pdwFlags, LCID* plcid, DWORD* pdwGroup, WCHAR** ppszName, IUnknown** ppObject, IUnknown** ppUnk);
+ // IAMStreamSelect
+ STDMETHODIMP Count(DWORD* pcStreams);
+ STDMETHODIMP Enable(long lIndex, DWORD dwFlags);
+ STDMETHODIMP Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* pdwFlags, LCID* plcid, DWORD* pdwGroup, WCHAR** ppszName, IUnknown** ppObject, IUnknown** ppUnk);
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- STDMETHODIMP UpdatePSI( PresentFollowing &NowNext);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP UpdatePSI(PresentFollowing& NowNext);
private :
- CComQIPtr<IBDA_DeviceControl> m_pBDAControl;
- CComPtr<IBDA_FrequencyFilter> m_pBDAFreq;
- CComPtr<IBDA_SignalStatistics> m_pBDAStats;
- CAtlMap<DVB_STREAM_TYPE, CDVBStream> m_DVBStreams;
-
- DVB_STREAM_TYPE m_nCurVideoType;
- DVB_STREAM_TYPE m_nCurAudioType;
- CString m_BDANetworkProvider;
- bool m_fHideWindow;
- CComPtr<IPin> m_pPin_h264;
-
- HRESULT CreateKSFilter(IBaseFilter** ppBF, CLSID KSCategory, CStringW& DisplayName);
- HRESULT ConnectFilters(IBaseFilter* pOutFiter, IBaseFilter* pInFilter);
- HRESULT CreateMicrosoftDemux(IBaseFilter* pReceiver, CComPtr<IBaseFilter>& pMpeg2Demux);
- HRESULT SetChannelInternal (CDVBChannel* pChannel);
- HRESULT SwitchStream (DVB_STREAM_TYPE& nOldType, DVB_STREAM_TYPE nNewType);
- HRESULT ChangeState(FILTER_STATE nRequested);
- FILTER_STATE GetState();
-
- template <class ITF>
- HRESULT SearchIBDATopology(const CComPtr<IBaseFilter> & pTuner, CComPtr<ITF> & pItf) {
- CComPtr<IUnknown> pUnk;
- HRESULT hr = SearchIBDATopology(pTuner, __uuidof(ITF), pUnk);
-
- if (SUCCEEDED(hr)) {
- hr = pUnk.QueryInterface(&pItf);
- }
- return !pItf ? E_NOINTERFACE : hr;
- }
-
- HRESULT SearchIBDATopology(const CComPtr<IBaseFilter>& pTuner, REFIID iid, CComPtr<IUnknown>& pUnk);
-
- void Sleep(unsigned int mseconds) {
- clock_t goal = mseconds + clock();
- while (goal > clock()) {
- ;
- }
- }
+ CComQIPtr<IBDA_DeviceControl> m_pBDAControl;
+ CComPtr<IBDA_FrequencyFilter> m_pBDAFreq;
+ CComPtr<IBDA_SignalStatistics> m_pBDAStats;
+ CAtlMap<DVB_STREAM_TYPE, CDVBStream> m_DVBStreams;
+
+ DVB_STREAM_TYPE m_nCurVideoType;
+ DVB_STREAM_TYPE m_nCurAudioType;
+ CString m_BDANetworkProvider;
+ bool m_fHideWindow;
+ CComPtr<IPin> m_pPin_h264;
+
+ HRESULT CreateKSFilter(IBaseFilter** ppBF, CLSID KSCategory, CStringW& DisplayName);
+ HRESULT ConnectFilters(IBaseFilter* pOutFiter, IBaseFilter* pInFilter);
+ HRESULT CreateMicrosoftDemux(IBaseFilter* pReceiver, CComPtr<IBaseFilter>& pMpeg2Demux);
+ HRESULT SetChannelInternal(CDVBChannel* pChannel);
+ HRESULT SwitchStream(DVB_STREAM_TYPE& nOldType, DVB_STREAM_TYPE nNewType);
+ HRESULT ChangeState(FILTER_STATE nRequested);
+ FILTER_STATE GetState();
+
+ template <class ITF>
+ HRESULT SearchIBDATopology(const CComPtr<IBaseFilter>& pTuner, CComPtr<ITF>& pItf) {
+ CComPtr<IUnknown> pUnk;
+ HRESULT hr = SearchIBDATopology(pTuner, __uuidof(ITF), pUnk);
+
+ if (SUCCEEDED(hr)) {
+ hr = pUnk.QueryInterface(&pItf);
+ }
+ return !pItf ? E_NOINTERFACE : hr;
+ }
+
+ HRESULT SearchIBDATopology(const CComPtr<IBaseFilter>& pTuner, REFIID iid, CComPtr<IUnknown>& pUnk);
+
+ void Sleep(unsigned int mseconds) {
+ clock_t goal = mseconds + clock();
+ while (goal > clock()) {
+ ;
+ }
+ }
};
#define LOG_FILE _T("bda.log")
@@ -188,19 +188,19 @@ private :
#ifdef _DEBUG
static void LOG(LPCTSTR fmt, ...)
{
- va_list args;
- va_start(args, fmt);
- //int nCount = _vsctprintf(fmt, args) + 1;
- TCHAR buff[3000];
- FILE* f;
- _vstprintf_s(buff, _countof(buff), fmt, args);
- if (_tfopen_s(&f, LOG_FILE, _T("at")) == 0) {
- fseek(f, 0, 2);
- _ftprintf_s(f, _T("%s\n"), buff);
- fclose(f);
- }
-
- va_end(args);
+ va_list args;
+ va_start(args, fmt);
+ //int nCount = _vsctprintf(fmt, args) + 1;
+ TCHAR buff[3000];
+ FILE* f;
+ _vstprintf_s(buff, _countof(buff), fmt, args);
+ if (_tfopen_s(&f, LOG_FILE, _T("at")) == 0) {
+ fseek(f, 0, 2);
+ _ftprintf_s(f, _T("%s\n"), buff);
+ fclose(f);
+ }
+
+ va_end(args);
}
#else
inline void LOG(LPCTSTR fmt, ...) {}
diff --git a/src/mpc-hc/FakeFilterMapper2.cpp b/src/mpc-hc/FakeFilterMapper2.cpp
index beb792374..caffca07f 100644
--- a/src/mpc-hc/FakeFilterMapper2.cpp
+++ b/src/mpc-hc/FakeFilterMapper2.cpp
@@ -30,491 +30,491 @@
#include <detours/detours.h>
-HRESULT (__stdcall * Real_CoCreateInstance)(CONST IID& a0,
- LPUNKNOWN a1,
- DWORD a2,
- CONST IID& a3,
- LPVOID* a4)
- = CoCreateInstance;
-
-LONG (WINAPI * Real_RegCreateKeyExA)(HKEY a0,
- LPCSTR a1,
- DWORD a2,
- LPSTR a3,
- DWORD a4,
- REGSAM a5,
- LPSECURITY_ATTRIBUTES a6,
- PHKEY a7,
- LPDWORD a8)
- = RegCreateKeyExA;
-
-LONG (WINAPI * Real_RegCreateKeyExW)(HKEY a0,
- LPCWSTR a1,
- DWORD a2,
- LPWSTR a3,
- DWORD a4,
- REGSAM a5,
- LPSECURITY_ATTRIBUTES a6,
- PHKEY a7,
- LPDWORD a8)
- = RegCreateKeyExW;
-
-LONG (WINAPI * Real_RegDeleteKeyA)(HKEY a0,
- LPCSTR a1)
- = RegDeleteKeyA;
-
-LONG (WINAPI * Real_RegDeleteKeyW)(HKEY a0,
- LPCWSTR a1)
- = RegDeleteKeyW;
-
-LONG (WINAPI * Real_RegDeleteValueA)(HKEY a0,
- LPCSTR a1)
- = RegDeleteValueA;
-
-
-LONG (WINAPI * Real_RegDeleteValueW)(HKEY a0,
- LPCWSTR a1)
- = RegDeleteValueW;
-
-LONG (WINAPI * Real_RegEnumKeyExA)(HKEY a0,
- DWORD a1,
- LPSTR a2,
- LPDWORD a3,
- LPDWORD a4,
- LPSTR a5,
- LPDWORD a6,
- struct _FILETIME* a7)
- = RegEnumKeyExA;
-
-LONG (WINAPI * Real_RegEnumKeyExW)(HKEY a0,
- DWORD a1,
- LPWSTR a2,
- LPDWORD a3,
- LPDWORD a4,
- LPWSTR a5,
- LPDWORD a6,
- struct _FILETIME* a7)
- = RegEnumKeyExW;
-
-LONG (WINAPI * Real_RegEnumValueA)(HKEY a0,
- DWORD a1,
- LPSTR a2,
- LPDWORD a3,
- LPDWORD a4,
- LPDWORD a5,
- LPBYTE a6,
- LPDWORD a7)
- = RegEnumValueA;
-
-LONG (WINAPI * Real_RegEnumValueW)(HKEY a0,
- DWORD a1,
- LPWSTR a2,
- LPDWORD a3,
- LPDWORD a4,
- LPDWORD a5,
- LPBYTE a6,
- LPDWORD a7)
- = RegEnumValueW;
-
-LONG (WINAPI * Real_RegOpenKeyExA)(HKEY a0,
- LPCSTR a1,
- DWORD a2,
- REGSAM a3,
- PHKEY a4)
- = RegOpenKeyExA;
-
-LONG (WINAPI * Real_RegOpenKeyExW)(HKEY a0,
- LPCWSTR a1,
- DWORD a2,
- REGSAM a3,
- PHKEY a4)
- = RegOpenKeyExW;
-
-LONG (WINAPI * Real_RegQueryInfoKeyA)(HKEY a0,
- LPSTR a1,
- LPDWORD a2,
- LPDWORD a3,
- LPDWORD a4,
- LPDWORD a5,
- LPDWORD a6,
- LPDWORD a7,
- LPDWORD a8,
- LPDWORD a9,
- LPDWORD a10,
- struct _FILETIME* a11)
- = RegQueryInfoKeyA;
-
-LONG (WINAPI * Real_RegQueryInfoKeyW)(HKEY a0,
- LPWSTR a1,
- LPDWORD a2,
- LPDWORD a3,
- LPDWORD a4,
- LPDWORD a5,
- LPDWORD a6,
- LPDWORD a7,
- LPDWORD a8,
- LPDWORD a9,
- LPDWORD a10,
- struct _FILETIME* a11)
- = RegQueryInfoKeyW;
-
-LONG (WINAPI * Real_RegQueryValueExA)(HKEY a0,
- LPCSTR a1,
- LPDWORD a2,
- LPDWORD a3,
- LPBYTE a4,
- LPDWORD a5)
- = RegQueryValueExA;
-
-LONG (WINAPI * Real_RegQueryValueExW)(HKEY a0,
- LPCWSTR a1,
- LPDWORD a2,
- LPDWORD a3,
- LPBYTE a4,
- LPDWORD a5)
- = RegQueryValueExW;
-
-LONG (WINAPI * Real_RegSetValueExA)(HKEY a0,
- LPCSTR a1,
- DWORD a2,
- DWORD a3,
- const BYTE* a4,
- DWORD a5)
- = RegSetValueExA;
-
-LONG (WINAPI * Real_RegSetValueExW)(HKEY a0,
- LPCWSTR a1,
- DWORD a2,
- DWORD a3,
- const BYTE* a4,
- DWORD a5)
- = RegSetValueExW;
-
-
-LONG (WINAPI * Real_RegCloseKey)(HKEY a0)
- = RegCloseKey;
-
-LONG (WINAPI * Real_RegFlushKey)(HKEY a0)
- = RegFlushKey;
-
-LONG (WINAPI * Real_RegCreateKeyA)(HKEY a0, LPCSTR a1, PHKEY a2)
- = RegCreateKeyA;
-
-LONG (WINAPI * Real_RegCreateKeyW)(HKEY a0, LPCWSTR a1, PHKEY a2)
- = RegCreateKeyW;
-
-LONG (WINAPI * Real_RegOpenKeyA)(HKEY a0, LPCSTR a1, PHKEY a2)
- = RegOpenKeyA;
-
-LONG (WINAPI * Real_RegOpenKeyW)(HKEY a0, LPCWSTR a1, PHKEY a2)
- = RegOpenKeyW;
-
-LONG (WINAPI * Real_RegQueryValueA)(HKEY a0, LPCSTR a1, LPSTR a2, PLONG a3)
- = RegQueryValueA;
-
-LONG (WINAPI * Real_RegQueryValueW)(HKEY a0, LPCWSTR a1, LPWSTR a2, PLONG a3)
- = RegQueryValueW;
-
-LONG (WINAPI * Real_RegSetValueW)(HKEY a0, LPCWSTR a1, DWORD a2, LPCWSTR a3, DWORD a4)
- = RegSetValueW;
-
-LONG (WINAPI * Real_RegSetValueA)(HKEY a0, LPCSTR a1, DWORD a2, LPCSTR a3, DWORD a4)
- = RegSetValueA;
+HRESULT(__stdcall* Real_CoCreateInstance)(CONST IID& a0,
+ LPUNKNOWN a1,
+ DWORD a2,
+ CONST IID& a3,
+ LPVOID* a4)
+ = CoCreateInstance;
+
+LONG(WINAPI* Real_RegCreateKeyExA)(HKEY a0,
+ LPCSTR a1,
+ DWORD a2,
+ LPSTR a3,
+ DWORD a4,
+ REGSAM a5,
+ LPSECURITY_ATTRIBUTES a6,
+ PHKEY a7,
+ LPDWORD a8)
+ = RegCreateKeyExA;
+
+LONG(WINAPI* Real_RegCreateKeyExW)(HKEY a0,
+ LPCWSTR a1,
+ DWORD a2,
+ LPWSTR a3,
+ DWORD a4,
+ REGSAM a5,
+ LPSECURITY_ATTRIBUTES a6,
+ PHKEY a7,
+ LPDWORD a8)
+ = RegCreateKeyExW;
+
+LONG(WINAPI* Real_RegDeleteKeyA)(HKEY a0,
+ LPCSTR a1)
+ = RegDeleteKeyA;
+
+LONG(WINAPI* Real_RegDeleteKeyW)(HKEY a0,
+ LPCWSTR a1)
+ = RegDeleteKeyW;
+
+LONG(WINAPI* Real_RegDeleteValueA)(HKEY a0,
+ LPCSTR a1)
+ = RegDeleteValueA;
+
+
+LONG(WINAPI* Real_RegDeleteValueW)(HKEY a0,
+ LPCWSTR a1)
+ = RegDeleteValueW;
+
+LONG(WINAPI* Real_RegEnumKeyExA)(HKEY a0,
+ DWORD a1,
+ LPSTR a2,
+ LPDWORD a3,
+ LPDWORD a4,
+ LPSTR a5,
+ LPDWORD a6,
+ struct _FILETIME* a7)
+ = RegEnumKeyExA;
+
+LONG(WINAPI* Real_RegEnumKeyExW)(HKEY a0,
+ DWORD a1,
+ LPWSTR a2,
+ LPDWORD a3,
+ LPDWORD a4,
+ LPWSTR a5,
+ LPDWORD a6,
+ struct _FILETIME* a7)
+ = RegEnumKeyExW;
+
+LONG(WINAPI* Real_RegEnumValueA)(HKEY a0,
+ DWORD a1,
+ LPSTR a2,
+ LPDWORD a3,
+ LPDWORD a4,
+ LPDWORD a5,
+ LPBYTE a6,
+ LPDWORD a7)
+ = RegEnumValueA;
+
+LONG(WINAPI* Real_RegEnumValueW)(HKEY a0,
+ DWORD a1,
+ LPWSTR a2,
+ LPDWORD a3,
+ LPDWORD a4,
+ LPDWORD a5,
+ LPBYTE a6,
+ LPDWORD a7)
+ = RegEnumValueW;
+
+LONG(WINAPI* Real_RegOpenKeyExA)(HKEY a0,
+ LPCSTR a1,
+ DWORD a2,
+ REGSAM a3,
+ PHKEY a4)
+ = RegOpenKeyExA;
+
+LONG(WINAPI* Real_RegOpenKeyExW)(HKEY a0,
+ LPCWSTR a1,
+ DWORD a2,
+ REGSAM a3,
+ PHKEY a4)
+ = RegOpenKeyExW;
+
+LONG(WINAPI* Real_RegQueryInfoKeyA)(HKEY a0,
+ LPSTR a1,
+ LPDWORD a2,
+ LPDWORD a3,
+ LPDWORD a4,
+ LPDWORD a5,
+ LPDWORD a6,
+ LPDWORD a7,
+ LPDWORD a8,
+ LPDWORD a9,
+ LPDWORD a10,
+ struct _FILETIME* a11)
+ = RegQueryInfoKeyA;
+
+LONG(WINAPI* Real_RegQueryInfoKeyW)(HKEY a0,
+ LPWSTR a1,
+ LPDWORD a2,
+ LPDWORD a3,
+ LPDWORD a4,
+ LPDWORD a5,
+ LPDWORD a6,
+ LPDWORD a7,
+ LPDWORD a8,
+ LPDWORD a9,
+ LPDWORD a10,
+ struct _FILETIME* a11)
+ = RegQueryInfoKeyW;
+
+LONG(WINAPI* Real_RegQueryValueExA)(HKEY a0,
+ LPCSTR a1,
+ LPDWORD a2,
+ LPDWORD a3,
+ LPBYTE a4,
+ LPDWORD a5)
+ = RegQueryValueExA;
+
+LONG(WINAPI* Real_RegQueryValueExW)(HKEY a0,
+ LPCWSTR a1,
+ LPDWORD a2,
+ LPDWORD a3,
+ LPBYTE a4,
+ LPDWORD a5)
+ = RegQueryValueExW;
+
+LONG(WINAPI* Real_RegSetValueExA)(HKEY a0,
+ LPCSTR a1,
+ DWORD a2,
+ DWORD a3,
+ const BYTE* a4,
+ DWORD a5)
+ = RegSetValueExA;
+
+LONG(WINAPI* Real_RegSetValueExW)(HKEY a0,
+ LPCWSTR a1,
+ DWORD a2,
+ DWORD a3,
+ const BYTE* a4,
+ DWORD a5)
+ = RegSetValueExW;
+
+
+LONG(WINAPI* Real_RegCloseKey)(HKEY a0)
+ = RegCloseKey;
+
+LONG(WINAPI* Real_RegFlushKey)(HKEY a0)
+ = RegFlushKey;
+
+LONG(WINAPI* Real_RegCreateKeyA)(HKEY a0, LPCSTR a1, PHKEY a2)
+ = RegCreateKeyA;
+
+LONG(WINAPI* Real_RegCreateKeyW)(HKEY a0, LPCWSTR a1, PHKEY a2)
+ = RegCreateKeyW;
+
+LONG(WINAPI* Real_RegOpenKeyA)(HKEY a0, LPCSTR a1, PHKEY a2)
+ = RegOpenKeyA;
+
+LONG(WINAPI* Real_RegOpenKeyW)(HKEY a0, LPCWSTR a1, PHKEY a2)
+ = RegOpenKeyW;
+
+LONG(WINAPI* Real_RegQueryValueA)(HKEY a0, LPCSTR a1, LPSTR a2, PLONG a3)
+ = RegQueryValueA;
+
+LONG(WINAPI* Real_RegQueryValueW)(HKEY a0, LPCWSTR a1, LPWSTR a2, PLONG a3)
+ = RegQueryValueW;
+
+LONG(WINAPI* Real_RegSetValueW)(HKEY a0, LPCWSTR a1, DWORD a2, LPCWSTR a3, DWORD a4)
+ = RegSetValueW;
+
+LONG(WINAPI* Real_RegSetValueA)(HKEY a0, LPCSTR a1, DWORD a2, LPCSTR a3, DWORD a4)
+ = RegSetValueA;
HRESULT WINAPI Mine_CoCreateInstance(IN REFCLSID rclsid, IN LPUNKNOWN pUnkOuter,
- IN DWORD dwClsContext, IN REFIID riid, OUT LPVOID FAR* ppv)
-{
- if (CFilterMapper2::m_pFilterMapper2) {
- CheckPointer(ppv, E_POINTER);
-
- if (rclsid == CLSID_FilterMapper) {
- ASSERT(0);
- return REGDB_E_CLASSNOTREG; // sorry...
- }
-
- if (rclsid == CLSID_FilterMapper2) {
- if (pUnkOuter) {
- return CLASS_E_NOAGGREGATION;
- }
-
- if (riid == __uuidof(IUnknown)) {
- CFilterMapper2::m_pFilterMapper2->AddRef();
- *ppv = (IUnknown*)CFilterMapper2::m_pFilterMapper2;
- return S_OK;
- } else if (riid == __uuidof(IFilterMapper2)) {
- CFilterMapper2::m_pFilterMapper2->AddRef();
- *ppv = (IFilterMapper2*)CFilterMapper2::m_pFilterMapper2;
- return S_OK;
- } else {
- return E_NOINTERFACE;
- }
- }
- }
- /* else
- {
- if (rclsid == CLSID_FilterMapper2)
- {
- CFilterMapper2* pFM2 = DNew CFilterMapper2(true, false, pUnkOuter);
- CComPtr<IUnknown> pUnk = (IUnknown*)pFM2;
- return pUnk->QueryInterface(riid, ppv);
- }
- }
- */
- if (!pUnkOuter)
- if (rclsid == CLSID_VideoMixingRenderer || rclsid == CLSID_VideoMixingRenderer9
- || rclsid == CLSID_VideoRenderer || rclsid == CLSID_VideoRendererDefault
- || rclsid == CLSID_OverlayMixer) { // || rclsid == CLSID_OverlayMixer2 - where is this declared?)
- CMacrovisionKicker* pMK = DNew CMacrovisionKicker(NAME("CMacrovisionKicker"), NULL);
- CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)pMK;
- CComPtr<IUnknown> pInner;
- HRESULT hr;
- if (SUCCEEDED(hr = Real_CoCreateInstance(rclsid, pUnk, dwClsContext, __uuidof(IUnknown), (void**)&pInner))) {
- pMK->SetInner(pInner);
- return pUnk->QueryInterface(riid, ppv);
- }
- }
-
- return Real_CoCreateInstance(rclsid, pUnkOuter, dwClsContext, riid, ppv);
+ IN DWORD dwClsContext, IN REFIID riid, OUT LPVOID FAR* ppv)
+{
+ if (CFilterMapper2::m_pFilterMapper2) {
+ CheckPointer(ppv, E_POINTER);
+
+ if (rclsid == CLSID_FilterMapper) {
+ ASSERT(0);
+ return REGDB_E_CLASSNOTREG; // sorry...
+ }
+
+ if (rclsid == CLSID_FilterMapper2) {
+ if (pUnkOuter) {
+ return CLASS_E_NOAGGREGATION;
+ }
+
+ if (riid == __uuidof(IUnknown)) {
+ CFilterMapper2::m_pFilterMapper2->AddRef();
+ *ppv = (IUnknown*)CFilterMapper2::m_pFilterMapper2;
+ return S_OK;
+ } else if (riid == __uuidof(IFilterMapper2)) {
+ CFilterMapper2::m_pFilterMapper2->AddRef();
+ *ppv = (IFilterMapper2*)CFilterMapper2::m_pFilterMapper2;
+ return S_OK;
+ } else {
+ return E_NOINTERFACE;
+ }
+ }
+ }
+ /* else
+ {
+ if (rclsid == CLSID_FilterMapper2)
+ {
+ CFilterMapper2* pFM2 = DNew CFilterMapper2(true, false, pUnkOuter);
+ CComPtr<IUnknown> pUnk = (IUnknown*)pFM2;
+ return pUnk->QueryInterface(riid, ppv);
+ }
+ }
+ */
+ if (!pUnkOuter)
+ if (rclsid == CLSID_VideoMixingRenderer || rclsid == CLSID_VideoMixingRenderer9
+ || rclsid == CLSID_VideoRenderer || rclsid == CLSID_VideoRendererDefault
+ || rclsid == CLSID_OverlayMixer) { // || rclsid == CLSID_OverlayMixer2 - where is this declared?)
+ CMacrovisionKicker* pMK = DNew CMacrovisionKicker(NAME("CMacrovisionKicker"), NULL);
+ CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)pMK;
+ CComPtr<IUnknown> pInner;
+ HRESULT hr;
+ if (SUCCEEDED(hr = Real_CoCreateInstance(rclsid, pUnk, dwClsContext, __uuidof(IUnknown), (void**)&pInner))) {
+ pMK->SetInner(pInner);
+ return pUnk->QueryInterface(riid, ppv);
+ }
+ }
+
+ return Real_CoCreateInstance(rclsid, pUnkOuter, dwClsContext, riid, ppv);
}
#define FAKEHKEY (HKEY)0x12345678
LONG WINAPI Mine_RegCloseKey(HKEY a0)
{
- if (CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
- return ERROR_SUCCESS;
- }
- return Real_RegCloseKey(a0);
+ if (CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
+ return ERROR_SUCCESS;
+ }
+ return Real_RegCloseKey(a0);
}
LONG WINAPI Mine_RegFlushKey(HKEY a0)
{
- if (CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
- return ERROR_SUCCESS;
- }
- return Real_RegFlushKey(a0);
+ if (CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
+ return ERROR_SUCCESS;
+ }
+ return Real_RegFlushKey(a0);
}
LONG WINAPI Mine_RegCreateKeyA(HKEY a0, LPCSTR a1, PHKEY a2)
{
- if (CFilterMapper2::m_pFilterMapper2) {
- *a2 = FAKEHKEY;
- return ERROR_SUCCESS;
- }
- return Real_RegCreateKeyA(a0, a1, a2);
+ if (CFilterMapper2::m_pFilterMapper2) {
+ *a2 = FAKEHKEY;
+ return ERROR_SUCCESS;
+ }
+ return Real_RegCreateKeyA(a0, a1, a2);
}
LONG WINAPI Mine_RegCreateKeyW(HKEY a0, LPCWSTR a1, PHKEY a2)
{
- if (CFilterMapper2::m_pFilterMapper2) {
- *a2 = FAKEHKEY;
- return ERROR_SUCCESS;
- }
- return Real_RegCreateKeyW(a0, a1, a2);
+ if (CFilterMapper2::m_pFilterMapper2) {
+ *a2 = FAKEHKEY;
+ return ERROR_SUCCESS;
+ }
+ return Real_RegCreateKeyW(a0, a1, a2);
}
LONG WINAPI Mine_RegCreateKeyExA(HKEY a0, LPCSTR a1, DWORD a2, LPSTR a3, DWORD a4, REGSAM a5, LPSECURITY_ATTRIBUTES a6, PHKEY a7, LPDWORD a8)
{
- if (CFilterMapper2::m_pFilterMapper2) {
- *a7 = FAKEHKEY;
- return ERROR_SUCCESS;
- }
- return Real_RegCreateKeyExA(a0, a1, a2, a3, a4, a5, a6, a7, a8);
+ if (CFilterMapper2::m_pFilterMapper2) {
+ *a7 = FAKEHKEY;
+ return ERROR_SUCCESS;
+ }
+ return Real_RegCreateKeyExA(a0, a1, a2, a3, a4, a5, a6, a7, a8);
}
LONG WINAPI Mine_RegCreateKeyExW(HKEY a0, LPCWSTR a1, DWORD a2, LPWSTR a3, DWORD a4, REGSAM a5, LPSECURITY_ATTRIBUTES a6, PHKEY a7, LPDWORD a8)
{
- if (CFilterMapper2::m_pFilterMapper2) {
- *a7 = FAKEHKEY;
- return ERROR_SUCCESS;
- }
- return Real_RegCreateKeyExW(a0, a1, a2, a3, a4, a5, a6, a7, a8);
+ if (CFilterMapper2::m_pFilterMapper2) {
+ *a7 = FAKEHKEY;
+ return ERROR_SUCCESS;
+ }
+ return Real_RegCreateKeyExW(a0, a1, a2, a3, a4, a5, a6, a7, a8);
}
LONG WINAPI Mine_RegDeleteKeyA(HKEY a0, LPCSTR a1)
{
- if (CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (INT_PTR)a0 < 0)) {
- return ERROR_SUCCESS;
- }
- return Real_RegDeleteKeyA(a0, a1);
+ if (CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (INT_PTR)a0 < 0)) {
+ return ERROR_SUCCESS;
+ }
+ return Real_RegDeleteKeyA(a0, a1);
}
LONG WINAPI Mine_RegDeleteKeyW(HKEY a0, LPCWSTR a1)
{
- if (CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (INT_PTR)a0 < 0)) {
- return ERROR_SUCCESS;
- }
- return Real_RegDeleteKeyW(a0, a1);
+ if (CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (INT_PTR)a0 < 0)) {
+ return ERROR_SUCCESS;
+ }
+ return Real_RegDeleteKeyW(a0, a1);
}
LONG WINAPI Mine_RegDeleteValueA(HKEY a0, LPCSTR a1)
{
- if (CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (INT_PTR)a0 < 0)) {
- return ERROR_SUCCESS;
- }
- return Real_RegDeleteValueA(a0, a1);
+ if (CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (INT_PTR)a0 < 0)) {
+ return ERROR_SUCCESS;
+ }
+ return Real_RegDeleteValueA(a0, a1);
}
LONG WINAPI Mine_RegDeleteValueW(HKEY a0, LPCWSTR a1)
{
- if (CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (INT_PTR)a0 < 0)) {
- return ERROR_SUCCESS;
- }
- return Real_RegDeleteValueW(a0, a1);
+ if (CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (INT_PTR)a0 < 0)) {
+ return ERROR_SUCCESS;
+ }
+ return Real_RegDeleteValueW(a0, a1);
}
LONG WINAPI Mine_RegEnumKeyExA(HKEY a0, DWORD a1, LPSTR a2, LPDWORD a3, LPDWORD a4, LPSTR a5, LPDWORD a6, struct _FILETIME* a7)
{
- if (CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
- return ERROR_NO_MORE_ITEMS;
- }
- return Real_RegEnumKeyExA(a0, a1, a2, a3, a4, a5, a6, a7);
+ if (CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
+ return ERROR_NO_MORE_ITEMS;
+ }
+ return Real_RegEnumKeyExA(a0, a1, a2, a3, a4, a5, a6, a7);
}
LONG WINAPI Mine_RegEnumKeyExW(HKEY a0, DWORD a1, LPWSTR a2, LPDWORD a3, LPDWORD a4, LPWSTR a5, LPDWORD a6, struct _FILETIME* a7)
{
- if (CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
- return ERROR_NO_MORE_ITEMS;
- }
- return Real_RegEnumKeyExW(a0, a1, a2, a3, a4, a5, a6, a7);
+ if (CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
+ return ERROR_NO_MORE_ITEMS;
+ }
+ return Real_RegEnumKeyExW(a0, a1, a2, a3, a4, a5, a6, a7);
}
LONG WINAPI Mine_RegEnumValueA(HKEY a0, DWORD a1, LPSTR a2, LPDWORD a3, LPDWORD a4, LPDWORD a5, LPBYTE a6, LPDWORD a7)
{
- if (CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
- return ERROR_NO_MORE_ITEMS;
- }
- return Real_RegEnumValueA(a0, a1, a2, a3, a4, a5, a6, a7);
+ if (CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
+ return ERROR_NO_MORE_ITEMS;
+ }
+ return Real_RegEnumValueA(a0, a1, a2, a3, a4, a5, a6, a7);
}
LONG WINAPI Mine_RegEnumValueW(HKEY a0, DWORD a1, LPWSTR a2, LPDWORD a3, LPDWORD a4, LPDWORD a5, LPBYTE a6, LPDWORD a7)
{
- if (CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
- return ERROR_NO_MORE_ITEMS;
- }
- return Real_RegEnumValueW(a0, a1, a2, a3, a4, a5, a6, a7);
+ if (CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
+ return ERROR_NO_MORE_ITEMS;
+ }
+ return Real_RegEnumValueW(a0, a1, a2, a3, a4, a5, a6, a7);
}
LONG WINAPI Mine_RegOpenKeyA(HKEY a0, LPCSTR a1, PHKEY a2)
{
- if (CFilterMapper2::m_pFilterMapper2) {
- *a2 = FAKEHKEY;
- return ERROR_SUCCESS;
- }
- return Real_RegOpenKeyA(a0, a1, a2);
+ if (CFilterMapper2::m_pFilterMapper2) {
+ *a2 = FAKEHKEY;
+ return ERROR_SUCCESS;
+ }
+ return Real_RegOpenKeyA(a0, a1, a2);
}
LONG WINAPI Mine_RegOpenKeyW(HKEY a0, LPCWSTR a1, PHKEY a2)
{
- if (CFilterMapper2::m_pFilterMapper2) {
- *a2 = FAKEHKEY;
- return ERROR_SUCCESS;
- }
- return Real_RegOpenKeyW(a0, a1, a2);
+ if (CFilterMapper2::m_pFilterMapper2) {
+ *a2 = FAKEHKEY;
+ return ERROR_SUCCESS;
+ }
+ return Real_RegOpenKeyW(a0, a1, a2);
}
LONG WINAPI Mine_RegOpenKeyExA(HKEY a0, LPCSTR a1, DWORD a2, REGSAM a3, PHKEY a4)
{
- if (CFilterMapper2::m_pFilterMapper2 && (a3&(KEY_SET_VALUE|KEY_CREATE_SUB_KEY))) {
- *a4 = FAKEHKEY;
- return ERROR_SUCCESS;
- }
- return Real_RegOpenKeyExA(a0, a1, a2, a3, a4);
+ if (CFilterMapper2::m_pFilterMapper2 && (a3 & (KEY_SET_VALUE | KEY_CREATE_SUB_KEY))) {
+ *a4 = FAKEHKEY;
+ return ERROR_SUCCESS;
+ }
+ return Real_RegOpenKeyExA(a0, a1, a2, a3, a4);
}
LONG WINAPI Mine_RegOpenKeyExW(HKEY a0, LPCWSTR a1, DWORD a2, REGSAM a3, PHKEY a4)
{
- if (CFilterMapper2::m_pFilterMapper2 && (a3&(KEY_SET_VALUE|KEY_CREATE_SUB_KEY))) {
- *a4 = FAKEHKEY;
- return ERROR_SUCCESS;
- }
- return Real_RegOpenKeyExW(a0, a1, a2, a3, a4);
+ if (CFilterMapper2::m_pFilterMapper2 && (a3 & (KEY_SET_VALUE | KEY_CREATE_SUB_KEY))) {
+ *a4 = FAKEHKEY;
+ return ERROR_SUCCESS;
+ }
+ return Real_RegOpenKeyExW(a0, a1, a2, a3, a4);
}
LONG WINAPI Mine_RegQueryInfoKeyA(HKEY a0, LPSTR a1, LPDWORD a2, LPDWORD a3, LPDWORD a4, LPDWORD a5, LPDWORD a6, LPDWORD a7, LPDWORD a8, LPDWORD a9, LPDWORD a10, struct _FILETIME* a11)
{
- if (CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
- return ERROR_INVALID_HANDLE;
- }
- return Real_RegQueryInfoKeyA(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11);
+ if (CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
+ return ERROR_INVALID_HANDLE;
+ }
+ return Real_RegQueryInfoKeyA(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11);
}
LONG WINAPI Mine_RegQueryInfoKeyW(HKEY a0, LPWSTR a1, LPDWORD a2, LPDWORD a3, LPDWORD a4, LPDWORD a5, LPDWORD a6, LPDWORD a7, LPDWORD a8, LPDWORD a9, LPDWORD a10, struct _FILETIME* a11)
{
- if (CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
- return ERROR_INVALID_HANDLE;
- }
- return Real_RegQueryInfoKeyW(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11);
+ if (CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
+ return ERROR_INVALID_HANDLE;
+ }
+ return Real_RegQueryInfoKeyW(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11);
}
LONG WINAPI Mine_RegQueryValueA(HKEY a0, LPCSTR a1, LPSTR a2, PLONG a3)
{
- if (CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
- *a3 = 0;
- return ERROR_SUCCESS;
- }
- return Real_RegQueryValueA(a0, a1, a2, a3);
+ if (CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
+ *a3 = 0;
+ return ERROR_SUCCESS;
+ }
+ return Real_RegQueryValueA(a0, a1, a2, a3);
}
LONG WINAPI Mine_RegQueryValueW(HKEY a0, LPCWSTR a1, LPWSTR a2, PLONG a3)
{
- if (CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
- *a3 = 0;
- return ERROR_SUCCESS;
- }
- return Real_RegQueryValueW(a0, a1, a2, a3);
+ if (CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
+ *a3 = 0;
+ return ERROR_SUCCESS;
+ }
+ return Real_RegQueryValueW(a0, a1, a2, a3);
}
LONG WINAPI Mine_RegQueryValueExA(HKEY a0, LPCSTR a1, LPDWORD a2, LPDWORD a3, LPBYTE a4, LPDWORD a5)
{
- if (CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
- *a5 = 0;
- return ERROR_SUCCESS;
- }
- return Real_RegQueryValueExA(a0, a1, a2, a3, a4, a5);
+ if (CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
+ *a5 = 0;
+ return ERROR_SUCCESS;
+ }
+ return Real_RegQueryValueExA(a0, a1, a2, a3, a4, a5);
}
LONG WINAPI Mine_RegQueryValueExW(HKEY a0, LPCWSTR a1, LPDWORD a2, LPDWORD a3, LPBYTE a4, LPDWORD a5)
{
- if (CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
- *a5 = 0;
- return ERROR_SUCCESS;
- }
- return Real_RegQueryValueExW(a0, a1, a2, a3, a4, a5);
+ if (CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
+ *a5 = 0;
+ return ERROR_SUCCESS;
+ }
+ return Real_RegQueryValueExW(a0, a1, a2, a3, a4, a5);
}
LONG WINAPI Mine_RegSetValueA(HKEY a0, LPCSTR a1, DWORD a2, LPCSTR a3, DWORD a4)
{
- if (CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (INT_PTR)a0 < 0)) {
- return ERROR_SUCCESS;
- }
- return Real_RegSetValueA(a0, a1, a2, a3, a4);
+ if (CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (INT_PTR)a0 < 0)) {
+ return ERROR_SUCCESS;
+ }
+ return Real_RegSetValueA(a0, a1, a2, a3, a4);
}
LONG WINAPI Mine_RegSetValueW(HKEY a0, LPCWSTR a1, DWORD a2, LPCWSTR a3, DWORD a4)
{
- if (CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (INT_PTR)a0 < 0)) {
- return ERROR_SUCCESS;
- }
- return Real_RegSetValueW(a0, a1, a2, a3, a4);
+ if (CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (INT_PTR)a0 < 0)) {
+ return ERROR_SUCCESS;
+ }
+ return Real_RegSetValueW(a0, a1, a2, a3, a4);
}
LONG WINAPI Mine_RegSetValueExA(HKEY a0, LPCSTR a1, DWORD a2, DWORD a3, BYTE* a4, DWORD a5)
{
- if (CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (INT_PTR)a0 < 0)) {
- return ERROR_SUCCESS;
- }
- return Real_RegSetValueExA(a0, a1, a2, a3, a4, a5);
+ if (CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (INT_PTR)a0 < 0)) {
+ return ERROR_SUCCESS;
+ }
+ return Real_RegSetValueExA(a0, a1, a2, a3, a4, a5);
}
LONG WINAPI Mine_RegSetValueExW(HKEY a0, LPCWSTR a1, DWORD a2, DWORD a3, BYTE* a4, DWORD a5)
{
- if (CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (INT_PTR)a0 < 0)) {
- return ERROR_SUCCESS;
- }
- return Real_RegSetValueExW(a0, a1, a2, a3, a4, a5);
+ if (CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (INT_PTR)a0 < 0)) {
+ return ERROR_SUCCESS;
+ }
+ return Real_RegSetValueExW(a0, a1, a2, a3, a4, a5);
}
//
@@ -527,190 +527,190 @@ bool CFilterMapper2::fInitialized = false;
void CFilterMapper2::Init()
{
- if (!fInitialized) {
- DetourAttach(&(PVOID&)Real_CoCreateInstance, (PVOID)Mine_CoCreateInstance);
- DetourAttach(&(PVOID&)Real_RegCloseKey, (PVOID)Mine_RegCloseKey);
- DetourAttach(&(PVOID&)Real_RegFlushKey, (PVOID)Mine_RegFlushKey);
- DetourAttach(&(PVOID&)Real_RegCreateKeyA, (PVOID)Mine_RegCreateKeyA);
- DetourAttach(&(PVOID&)Real_RegCreateKeyW, (PVOID)Mine_RegCreateKeyW);
- DetourAttach(&(PVOID&)Real_RegCreateKeyExA, (PVOID)Mine_RegCreateKeyExA);
- DetourAttach(&(PVOID&)Real_RegCreateKeyExW, (PVOID)Mine_RegCreateKeyExW);
- DetourAttach(&(PVOID&)Real_RegDeleteKeyA, (PVOID)Mine_RegDeleteKeyA);
- DetourAttach(&(PVOID&)Real_RegDeleteKeyW, (PVOID)Mine_RegDeleteKeyW);
- DetourAttach(&(PVOID&)Real_RegDeleteValueA, (PVOID)Mine_RegDeleteValueA);
- DetourAttach(&(PVOID&)Real_RegDeleteValueW, (PVOID)Mine_RegDeleteValueW);
- DetourAttach(&(PVOID&)Real_RegEnumKeyExA, (PVOID)Mine_RegEnumKeyExA);
- DetourAttach(&(PVOID&)Real_RegEnumKeyExW, (PVOID)Mine_RegEnumKeyExW);
- DetourAttach(&(PVOID&)Real_RegEnumValueA, (PVOID)Mine_RegEnumValueA);
- DetourAttach(&(PVOID&)Real_RegEnumValueW, (PVOID)Mine_RegEnumValueW);
- DetourAttach(&(PVOID&)Real_RegOpenKeyA, (PVOID)Mine_RegOpenKeyA);
- DetourAttach(&(PVOID&)Real_RegOpenKeyW, (PVOID)Mine_RegOpenKeyW);
- DetourAttach(&(PVOID&)Real_RegOpenKeyExA, (PVOID)Mine_RegOpenKeyExA);
- DetourAttach(&(PVOID&)Real_RegOpenKeyExW, (PVOID)Mine_RegOpenKeyExW);
- DetourAttach(&(PVOID&)Real_RegQueryInfoKeyA, (PVOID)Mine_RegQueryInfoKeyA);
- DetourAttach(&(PVOID&)Real_RegQueryInfoKeyW, (PVOID)Mine_RegQueryInfoKeyW);
- DetourAttach(&(PVOID&)Real_RegQueryValueA, (PVOID)Mine_RegQueryValueA);
- DetourAttach(&(PVOID&)Real_RegQueryValueW, (PVOID)Mine_RegQueryValueW);
- DetourAttach(&(PVOID&)Real_RegQueryValueExA, (PVOID)Mine_RegQueryValueExA);
- DetourAttach(&(PVOID&)Real_RegQueryValueExW, (PVOID)Mine_RegQueryValueExW);
- DetourAttach(&(PVOID&)Real_RegSetValueA, (PVOID)Mine_RegSetValueA);
- DetourAttach(&(PVOID&)Real_RegSetValueW, (PVOID)Mine_RegSetValueW);
- DetourAttach(&(PVOID&)Real_RegSetValueExA, (PVOID)Mine_RegSetValueExA);
- DetourAttach(&(PVOID&)Real_RegSetValueExW, (PVOID)Mine_RegSetValueExW);
-
- fInitialized = true;
- }
+ if (!fInitialized) {
+ DetourAttach(&(PVOID&)Real_CoCreateInstance, (PVOID)Mine_CoCreateInstance);
+ DetourAttach(&(PVOID&)Real_RegCloseKey, (PVOID)Mine_RegCloseKey);
+ DetourAttach(&(PVOID&)Real_RegFlushKey, (PVOID)Mine_RegFlushKey);
+ DetourAttach(&(PVOID&)Real_RegCreateKeyA, (PVOID)Mine_RegCreateKeyA);
+ DetourAttach(&(PVOID&)Real_RegCreateKeyW, (PVOID)Mine_RegCreateKeyW);
+ DetourAttach(&(PVOID&)Real_RegCreateKeyExA, (PVOID)Mine_RegCreateKeyExA);
+ DetourAttach(&(PVOID&)Real_RegCreateKeyExW, (PVOID)Mine_RegCreateKeyExW);
+ DetourAttach(&(PVOID&)Real_RegDeleteKeyA, (PVOID)Mine_RegDeleteKeyA);
+ DetourAttach(&(PVOID&)Real_RegDeleteKeyW, (PVOID)Mine_RegDeleteKeyW);
+ DetourAttach(&(PVOID&)Real_RegDeleteValueA, (PVOID)Mine_RegDeleteValueA);
+ DetourAttach(&(PVOID&)Real_RegDeleteValueW, (PVOID)Mine_RegDeleteValueW);
+ DetourAttach(&(PVOID&)Real_RegEnumKeyExA, (PVOID)Mine_RegEnumKeyExA);
+ DetourAttach(&(PVOID&)Real_RegEnumKeyExW, (PVOID)Mine_RegEnumKeyExW);
+ DetourAttach(&(PVOID&)Real_RegEnumValueA, (PVOID)Mine_RegEnumValueA);
+ DetourAttach(&(PVOID&)Real_RegEnumValueW, (PVOID)Mine_RegEnumValueW);
+ DetourAttach(&(PVOID&)Real_RegOpenKeyA, (PVOID)Mine_RegOpenKeyA);
+ DetourAttach(&(PVOID&)Real_RegOpenKeyW, (PVOID)Mine_RegOpenKeyW);
+ DetourAttach(&(PVOID&)Real_RegOpenKeyExA, (PVOID)Mine_RegOpenKeyExA);
+ DetourAttach(&(PVOID&)Real_RegOpenKeyExW, (PVOID)Mine_RegOpenKeyExW);
+ DetourAttach(&(PVOID&)Real_RegQueryInfoKeyA, (PVOID)Mine_RegQueryInfoKeyA);
+ DetourAttach(&(PVOID&)Real_RegQueryInfoKeyW, (PVOID)Mine_RegQueryInfoKeyW);
+ DetourAttach(&(PVOID&)Real_RegQueryValueA, (PVOID)Mine_RegQueryValueA);
+ DetourAttach(&(PVOID&)Real_RegQueryValueW, (PVOID)Mine_RegQueryValueW);
+ DetourAttach(&(PVOID&)Real_RegQueryValueExA, (PVOID)Mine_RegQueryValueExA);
+ DetourAttach(&(PVOID&)Real_RegQueryValueExW, (PVOID)Mine_RegQueryValueExW);
+ DetourAttach(&(PVOID&)Real_RegSetValueA, (PVOID)Mine_RegSetValueA);
+ DetourAttach(&(PVOID&)Real_RegSetValueW, (PVOID)Mine_RegSetValueW);
+ DetourAttach(&(PVOID&)Real_RegSetValueExA, (PVOID)Mine_RegSetValueExA);
+ DetourAttach(&(PVOID&)Real_RegSetValueExW, (PVOID)Mine_RegSetValueExW);
+
+ fInitialized = true;
+ }
}
CFilterMapper2::CFilterMapper2(bool fRefCounted, bool fAllowUnreg, LPUNKNOWN pUnkOuter)
- : CUnknown(NAME("CFilterMapper2"), pUnkOuter)
- , m_fRefCounted(fRefCounted), m_fAllowUnreg(fAllowUnreg)
+ : CUnknown(NAME("CFilterMapper2"), pUnkOuter)
+ , m_fRefCounted(fRefCounted), m_fAllowUnreg(fAllowUnreg)
{
- m_cRef = fRefCounted ? 0 : 1;
+ m_cRef = fRefCounted ? 0 : 1;
- Init();
+ Init();
- HRESULT hr = Real_CoCreateInstance(
- CLSID_FilterMapper2, (IUnknown*)(INonDelegatingUnknown*)this, CLSCTX_ALL,
- __uuidof(IUnknown), (void**)&m_pFM2);
- if (FAILED(hr) || !m_pFM2) {
- ASSERT(0);
- return;
- }
+ HRESULT hr = Real_CoCreateInstance(
+ CLSID_FilterMapper2, (IUnknown*)(INonDelegatingUnknown*)this, CLSCTX_ALL,
+ __uuidof(IUnknown), (void**)&m_pFM2);
+ if (FAILED(hr) || !m_pFM2) {
+ ASSERT(0);
+ return;
+ }
}
CFilterMapper2::~CFilterMapper2()
{
- POSITION pos = m_filters.GetHeadPosition();
- while (pos) {
- delete m_filters.GetNext(pos);
- }
+ POSITION pos = m_filters.GetHeadPosition();
+ while (pos) {
+ delete m_filters.GetNext(pos);
+ }
}
STDMETHODIMP CFilterMapper2::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- if (riid == __uuidof(IFilterMapper2)) {
- return GetInterface((IFilterMapper2*)this, ppv);
- }
+ if (riid == __uuidof(IFilterMapper2)) {
+ return GetInterface((IFilterMapper2*)this, ppv);
+ }
- HRESULT hr = m_pFM2 ? m_pFM2->QueryInterface(riid, ppv) : E_NOINTERFACE;
+ HRESULT hr = m_pFM2 ? m_pFM2->QueryInterface(riid, ppv) : E_NOINTERFACE;
- return
- SUCCEEDED(hr) ? hr :
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ SUCCEEDED(hr) ? hr :
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
void CFilterMapper2::Register(CString path)
{
- // Load filter
- if (HMODULE h = LoadLibraryEx(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH)) {
- typedef HRESULT (__stdcall * PDllRegisterServer)();
- if (PDllRegisterServer p = (PDllRegisterServer)GetProcAddress(h, "DllRegisterServer")) {
- ASSERT(CFilterMapper2::m_pFilterMapper2 == NULL);
+ // Load filter
+ if (HMODULE h = LoadLibraryEx(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH)) {
+ typedef HRESULT(__stdcall * PDllRegisterServer)();
+ if (PDllRegisterServer p = (PDllRegisterServer)GetProcAddress(h, "DllRegisterServer")) {
+ ASSERT(CFilterMapper2::m_pFilterMapper2 == NULL);
- CFilterMapper2::m_pFilterMapper2 = this;
- m_path = path;
- p();
- m_path.Empty();
- CFilterMapper2::m_pFilterMapper2 = NULL;
- }
+ CFilterMapper2::m_pFilterMapper2 = this;
+ m_path = path;
+ p();
+ m_path.Empty();
+ CFilterMapper2::m_pFilterMapper2 = NULL;
+ }
- FreeLibrary(h);
- }
+ FreeLibrary(h);
+ }
}
// IFilterMapper2
STDMETHODIMP CFilterMapper2::CreateCategory(REFCLSID clsidCategory, DWORD dwCategoryMerit, LPCWSTR Description)
{
- if (!m_path.IsEmpty()) {
- return S_OK;
- } else if (CComQIPtr<IFilterMapper2> pFM2 = m_pFM2) {
- return pFM2->CreateCategory(clsidCategory, dwCategoryMerit, Description);
- }
+ if (!m_path.IsEmpty()) {
+ return S_OK;
+ } else if (CComQIPtr<IFilterMapper2> pFM2 = m_pFM2) {
+ return pFM2->CreateCategory(clsidCategory, dwCategoryMerit, Description);
+ }
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CFilterMapper2::UnregisterFilter(const CLSID* pclsidCategory, const OLECHAR* szInstance, REFCLSID Filter)
{
- if (!m_path.IsEmpty()) {
- return S_OK;
- } else if (CComQIPtr<IFilterMapper2> pFM2 = m_pFM2) {
- return m_fAllowUnreg
- ? pFM2->UnregisterFilter(pclsidCategory, szInstance, Filter)
- : S_OK;
- }
+ if (!m_path.IsEmpty()) {
+ return S_OK;
+ } else if (CComQIPtr<IFilterMapper2> pFM2 = m_pFM2) {
+ return m_fAllowUnreg
+ ? pFM2->UnregisterFilter(pclsidCategory, szInstance, Filter)
+ : S_OK;
+ }
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CFilterMapper2::RegisterFilter(REFCLSID clsidFilter, LPCWSTR Name, IMoniker** ppMoniker, const CLSID* pclsidCategory, const OLECHAR* szInstance, const REGFILTER2* prf2)
{
- if (!m_path.IsEmpty()) {
- if (FilterOverride* f = DNew FilterOverride) {
- f->fDisabled = false;
- f->type = FilterOverride::EXTERNAL;
- f->path = m_path;
- f->name = CStringW(Name);
- f->clsid = clsidFilter;
- f->iLoadType = FilterOverride::MERIT;
- f->dwMerit = prf2->dwMerit;
-
- if (prf2->dwVersion == 1) {
- for (ULONG i = 0; i < prf2->cPins; i++) {
- const REGFILTERPINS& rgPin = prf2->rgPins[i];
- if (rgPin.bOutput) {
- continue;
- }
-
- for (UINT i = 0; i < rgPin.nMediaTypes; i++) {
- if (!rgPin.lpMediaType[i].clsMajorType || !rgPin.lpMediaType[i].clsMinorType) {
- break;
- }
- f->guids.AddTail(*rgPin.lpMediaType[i].clsMajorType);
- f->guids.AddTail(*rgPin.lpMediaType[i].clsMinorType);
- }
- }
- } else if (prf2->dwVersion == 2) {
- for (ULONG i = 0; i < prf2->cPins2; i++) {
- const REGFILTERPINS2& rgPin = prf2->rgPins2[i];
- if (rgPin.dwFlags&REG_PINFLAG_B_OUTPUT) {
- continue;
- }
-
- for (UINT i = 0; i < rgPin.nMediaTypes; i++) {
- if (!rgPin.lpMediaType[i].clsMajorType || !rgPin.lpMediaType[i].clsMinorType) {
- break;
- }
- f->guids.AddTail(*rgPin.lpMediaType[i].clsMajorType);
- f->guids.AddTail(*rgPin.lpMediaType[i].clsMinorType);
- }
- }
- }
-
- f->backup.AddTailList(&f->guids);
-
- m_filters.AddTail(f);
- }
-
- return S_OK;
- } else if (CComQIPtr<IFilterMapper2> pFM2 = m_pFM2) {
- return pFM2->RegisterFilter(clsidFilter, Name, ppMoniker, pclsidCategory, szInstance, prf2);
- }
-
- return E_NOTIMPL;
+ if (!m_path.IsEmpty()) {
+ if (FilterOverride* f = DNew FilterOverride) {
+ f->fDisabled = false;
+ f->type = FilterOverride::EXTERNAL;
+ f->path = m_path;
+ f->name = CStringW(Name);
+ f->clsid = clsidFilter;
+ f->iLoadType = FilterOverride::MERIT;
+ f->dwMerit = prf2->dwMerit;
+
+ if (prf2->dwVersion == 1) {
+ for (ULONG i = 0; i < prf2->cPins; i++) {
+ const REGFILTERPINS& rgPin = prf2->rgPins[i];
+ if (rgPin.bOutput) {
+ continue;
+ }
+
+ for (UINT i = 0; i < rgPin.nMediaTypes; i++) {
+ if (!rgPin.lpMediaType[i].clsMajorType || !rgPin.lpMediaType[i].clsMinorType) {
+ break;
+ }
+ f->guids.AddTail(*rgPin.lpMediaType[i].clsMajorType);
+ f->guids.AddTail(*rgPin.lpMediaType[i].clsMinorType);
+ }
+ }
+ } else if (prf2->dwVersion == 2) {
+ for (ULONG i = 0; i < prf2->cPins2; i++) {
+ const REGFILTERPINS2& rgPin = prf2->rgPins2[i];
+ if (rgPin.dwFlags & REG_PINFLAG_B_OUTPUT) {
+ continue;
+ }
+
+ for (UINT i = 0; i < rgPin.nMediaTypes; i++) {
+ if (!rgPin.lpMediaType[i].clsMajorType || !rgPin.lpMediaType[i].clsMinorType) {
+ break;
+ }
+ f->guids.AddTail(*rgPin.lpMediaType[i].clsMajorType);
+ f->guids.AddTail(*rgPin.lpMediaType[i].clsMinorType);
+ }
+ }
+ }
+
+ f->backup.AddTailList(&f->guids);
+
+ m_filters.AddTail(f);
+ }
+
+ return S_OK;
+ } else if (CComQIPtr<IFilterMapper2> pFM2 = m_pFM2) {
+ return pFM2->RegisterFilter(clsidFilter, Name, ppMoniker, pclsidCategory, szInstance, prf2);
+ }
+
+ return E_NOTIMPL;
}
STDMETHODIMP CFilterMapper2::EnumMatchingFilters(IEnumMoniker** ppEnum, DWORD dwFlags, BOOL bExactMatch, DWORD dwMerit,
- BOOL bInputNeeded, DWORD cInputTypes, const GUID* pInputTypes, const REGPINMEDIUM* pMedIn, const CLSID* pPinCategoryIn, BOOL bRender,
- BOOL bOutputNeeded, DWORD cOutputTypes, const GUID* pOutputTypes, const REGPINMEDIUM* pMedOut, const CLSID* pPinCategoryOut)
+ BOOL bInputNeeded, DWORD cInputTypes, const GUID* pInputTypes, const REGPINMEDIUM* pMedIn, const CLSID* pPinCategoryIn, BOOL bRender,
+ BOOL bOutputNeeded, DWORD cOutputTypes, const GUID* pOutputTypes, const REGPINMEDIUM* pMedOut, const CLSID* pPinCategoryOut)
{
- if (CComQIPtr<IFilterMapper2> pFM2 = m_pFM2) {
- pFM2->EnumMatchingFilters(ppEnum, dwFlags, bExactMatch, dwMerit,
- bInputNeeded, cInputTypes, pInputTypes, pMedIn, pPinCategoryIn, bRender,
- bOutputNeeded, cOutputTypes, pOutputTypes, pMedOut, pPinCategoryOut);
- }
+ if (CComQIPtr<IFilterMapper2> pFM2 = m_pFM2) {
+ pFM2->EnumMatchingFilters(ppEnum, dwFlags, bExactMatch, dwMerit,
+ bInputNeeded, cInputTypes, pInputTypes, pMedIn, pPinCategoryIn, bRender,
+ bOutputNeeded, cOutputTypes, pOutputTypes, pMedOut, pPinCategoryOut);
+ }
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
diff --git a/src/mpc-hc/FakeFilterMapper2.h b/src/mpc-hc/FakeFilterMapper2.h
index c47265307..14c9fa3ee 100644
--- a/src/mpc-hc/FakeFilterMapper2.h
+++ b/src/mpc-hc/FakeFilterMapper2.h
@@ -29,102 +29,102 @@
class FilterOverride
{
public:
- bool fDisabled, fTemporary;
- enum {REGISTERED, EXTERNAL} type;
- // REGISTERED
- CStringW dispname;
- // EXTERNAL
- CString path, name;
- CLSID clsid;
- // props
- CAtlList<GUID> guids, backup;
- enum {PREFERRED, BLOCK, MERIT};
- int iLoadType;
- DWORD dwMerit;
-
- FilterOverride() {
- fTemporary = false;
- }
- FilterOverride(FilterOverride* f) {
- fDisabled = f->fDisabled;
- fTemporary = f->fTemporary;
- type = f->type;
- dispname = f->dispname;
- path = f->path;
- name = f->name;
- clsid = f->clsid;
- guids.AddTailList(&f->guids);
- backup.AddTailList(&f->backup);
- iLoadType = f->iLoadType;
- dwMerit = f->dwMerit;
- }
+ bool fDisabled, fTemporary;
+ enum {REGISTERED, EXTERNAL} type;
+ // REGISTERED
+ CStringW dispname;
+ // EXTERNAL
+ CString path, name;
+ CLSID clsid;
+ // props
+ CAtlList<GUID> guids, backup;
+ enum {PREFERRED, BLOCK, MERIT};
+ int iLoadType;
+ DWORD dwMerit;
+
+ FilterOverride() {
+ fTemporary = false;
+ }
+ FilterOverride(FilterOverride* f) {
+ fDisabled = f->fDisabled;
+ fTemporary = f->fTemporary;
+ type = f->type;
+ dispname = f->dispname;
+ path = f->path;
+ name = f->name;
+ clsid = f->clsid;
+ guids.AddTailList(&f->guids);
+ backup.AddTailList(&f->backup);
+ iLoadType = f->iLoadType;
+ dwMerit = f->dwMerit;
+ }
};
/*
class CFilterMapper2 : protected CUnknown, protected IFilterMapper2
{
- static bool fInitialized;
+ static bool fInitialized;
- CComPtr<IFilterMapper2> m_pFM2;
- CString m_path;
+ CComPtr<IFilterMapper2> m_pFM2;
+ CString m_path;
protected:
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // IFilterMapper2
+ // IFilterMapper2
- STDMETHODIMP CreateCategory(REFCLSID clsidCategory, DWORD dwCategoryMerit, LPCWSTR Description);
- STDMETHODIMP UnregisterFilter(const CLSID* pclsidCategory, const OLECHAR* szInstance, REFCLSID Filter);
- STDMETHODIMP RegisterFilter(REFCLSID clsidFilter, LPCWSTR Name, IMoniker** ppMoniker, const CLSID* pclsidCategory, const OLECHAR* szInstance, const REGFILTER2* prf2);
- STDMETHODIMP EnumMatchingFilters(IEnumMoniker** ppEnum, DWORD dwFlags, BOOL bExactMatch, DWORD dwMerit,
- BOOL bInputNeeded, DWORD cInputTypes, const GUID* pInputTypes, const REGPINMEDIUM* pMedIn, const CLSID* pPinCategoryIn, BOOL bRender,
- BOOL bOutputNeeded, DWORD cOutputTypes, const GUID* pOutputTypes, const REGPINMEDIUM* pMedOut, const CLSID* pPinCategoryOut);
+ STDMETHODIMP CreateCategory(REFCLSID clsidCategory, DWORD dwCategoryMerit, LPCWSTR Description);
+ STDMETHODIMP UnregisterFilter(const CLSID* pclsidCategory, const OLECHAR* szInstance, REFCLSID Filter);
+ STDMETHODIMP RegisterFilter(REFCLSID clsidFilter, LPCWSTR Name, IMoniker** ppMoniker, const CLSID* pclsidCategory, const OLECHAR* szInstance, const REGFILTER2* prf2);
+ STDMETHODIMP EnumMatchingFilters(IEnumMoniker** ppEnum, DWORD dwFlags, BOOL bExactMatch, DWORD dwMerit,
+ BOOL bInputNeeded, DWORD cInputTypes, const GUID* pInputTypes, const REGPINMEDIUM* pMedIn, const CLSID* pPinCategoryIn, BOOL bRender,
+ BOOL bOutputNeeded, DWORD cOutputTypes, const GUID* pOutputTypes, const REGPINMEDIUM* pMedOut, const CLSID* pPinCategoryOut);
public:
- CFilterMapper2();
- virtual ~CFilterMapper2();
+ CFilterMapper2();
+ virtual ~CFilterMapper2();
- static void Init();
+ static void Init();
- static IFilterMapper2* m_pFilterMapper2;
- CList<Filter*> m_filters;
- void Register(CString path);
+ static IFilterMapper2* m_pFilterMapper2;
+ CList<Filter*> m_filters;
+ void Register(CString path);
};
*/
class CFilterMapper2 : protected CUnknown, public IFilterMapper2
{
- static bool fInitialized;
+ static bool fInitialized;
- CComPtr<IUnknown> m_pFM2;
- CString m_path;
+ CComPtr<IUnknown> m_pFM2;
+ CString m_path;
- bool m_fRefCounted, m_fAllowUnreg;
+ bool m_fRefCounted, m_fAllowUnreg;
protected:
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // IFilterMapper2
+ // IFilterMapper2
- STDMETHODIMP CreateCategory(REFCLSID clsidCategory, DWORD dwCategoryMerit, LPCWSTR Description);
- STDMETHODIMP UnregisterFilter(const CLSID* pclsidCategory, const OLECHAR* szInstance, REFCLSID Filter);
- STDMETHODIMP RegisterFilter(REFCLSID clsidFilter, LPCWSTR Name, IMoniker** ppMoniker, const CLSID* pclsidCategory, const OLECHAR* szInstance, const REGFILTER2* prf2);
- STDMETHODIMP EnumMatchingFilters(IEnumMoniker** ppEnum, DWORD dwFlags, BOOL bExactMatch, DWORD dwMerit,
- BOOL bInputNeeded, DWORD cInputTypes, const GUID* pInputTypes, const REGPINMEDIUM* pMedIn, const CLSID* pPinCategoryIn, BOOL bRender,
- BOOL bOutputNeeded, DWORD cOutputTypes, const GUID* pOutputTypes, const REGPINMEDIUM* pMedOut, const CLSID* pPinCategoryOut);
+ STDMETHODIMP CreateCategory(REFCLSID clsidCategory, DWORD dwCategoryMerit, LPCWSTR Description);
+ STDMETHODIMP UnregisterFilter(const CLSID* pclsidCategory, const OLECHAR* szInstance, REFCLSID Filter);
+ STDMETHODIMP RegisterFilter(REFCLSID clsidFilter, LPCWSTR Name, IMoniker** ppMoniker, const CLSID* pclsidCategory, const OLECHAR* szInstance, const REGFILTER2* prf2);
+ STDMETHODIMP EnumMatchingFilters(IEnumMoniker** ppEnum, DWORD dwFlags, BOOL bExactMatch, DWORD dwMerit,
+ BOOL bInputNeeded, DWORD cInputTypes, const GUID* pInputTypes, const REGPINMEDIUM* pMedIn, const CLSID* pPinCategoryIn, BOOL bRender,
+ BOOL bOutputNeeded, DWORD cOutputTypes, const GUID* pOutputTypes, const REGPINMEDIUM* pMedOut, const CLSID* pPinCategoryOut);
public:
- CFilterMapper2(bool fRefCounted, bool fAllowUnreg = false, LPUNKNOWN pUnkOuter = NULL);
- virtual ~CFilterMapper2();
+ CFilterMapper2(bool fRefCounted, bool fAllowUnreg = false, LPUNKNOWN pUnkOuter = NULL);
+ virtual ~CFilterMapper2();
- void SetInner(IUnknown* pUnk) {
- m_pFM2 = pUnk;
- }
+ void SetInner(IUnknown* pUnk) {
+ m_pFM2 = pUnk;
+ }
- static void Init();
+ static void Init();
- static IFilterMapper2* m_pFilterMapper2;
- CList<FilterOverride*> m_filters;
- void Register(CString path);
+ static IFilterMapper2* m_pFilterMapper2;
+ CList<FilterOverride*> m_filters;
+ void Register(CString path);
};
diff --git a/src/mpc-hc/FavoriteAddDlg.cpp b/src/mpc-hc/FavoriteAddDlg.cpp
index 95dd18bc0..4013037f8 100644
--- a/src/mpc-hc/FavoriteAddDlg.cpp
+++ b/src/mpc-hc/FavoriteAddDlg.cpp
@@ -31,11 +31,11 @@
IMPLEMENT_DYNAMIC(CFavoriteAddDlg, CCmdUIDialog)
CFavoriteAddDlg::CFavoriteAddDlg(CString shortname, CString fullname, CWnd* pParent /*=NULL*/)
- : CCmdUIDialog(CFavoriteAddDlg::IDD, pParent)
- , m_shortname(shortname)
- , m_fullname(fullname)
- , m_bRememberPos(TRUE)
- , m_bRelativeDrive(FALSE)
+ : CCmdUIDialog(CFavoriteAddDlg::IDD, pParent)
+ , m_shortname(shortname)
+ , m_fullname(fullname)
+ , m_bRememberPos(TRUE)
+ , m_bRelativeDrive(FALSE)
{
}
@@ -45,60 +45,60 @@ CFavoriteAddDlg::~CFavoriteAddDlg()
void CFavoriteAddDlg::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_COMBO1, m_namectrl);
- DDX_CBString(pDX, IDC_COMBO1, m_name);
- DDX_Check(pDX, IDC_CHECK1, m_bRememberPos);
- DDX_Check(pDX, IDC_CHECK2, m_bRelativeDrive);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_COMBO1, m_namectrl);
+ DDX_CBString(pDX, IDC_COMBO1, m_name);
+ DDX_Check(pDX, IDC_CHECK1, m_bRememberPos);
+ DDX_Check(pDX, IDC_CHECK2, m_bRelativeDrive);
}
BOOL CFavoriteAddDlg::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- if ( !m_shortname.IsEmpty() ) {
- m_namectrl.AddString( m_shortname );
- }
+ if (!m_shortname.IsEmpty()) {
+ m_namectrl.AddString(m_shortname);
+ }
- if ( !m_fullname.IsEmpty() ) {
- m_namectrl.AddString( m_fullname );
- }
+ if (!m_fullname.IsEmpty()) {
+ m_namectrl.AddString(m_fullname);
+ }
- ::CorrectComboListWidth(m_namectrl);
+ ::CorrectComboListWidth(m_namectrl);
- m_bRememberPos = AfxGetAppSettings().bFavRememberPos;
- m_bRelativeDrive = AfxGetAppSettings().bFavRelativeDrive;
+ m_bRememberPos = AfxGetAppSettings().bFavRememberPos;
+ m_bRelativeDrive = AfxGetAppSettings().bFavRelativeDrive;
- UpdateData(FALSE); // Update UI
+ UpdateData(FALSE); // Update UI
- m_namectrl.SetCurSel( 0 );
+ m_namectrl.SetCurSel(0);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BEGIN_MESSAGE_MAP(CFavoriteAddDlg, CCmdUIDialog)
- ON_UPDATE_COMMAND_UI(IDOK, OnUpdateOk)
+ ON_UPDATE_COMMAND_UI(IDOK, OnUpdateOk)
END_MESSAGE_MAP()
// CFavoriteAddDlg message handlers
-void CFavoriteAddDlg::OnUpdateOk(CCmdUI *pCmdUI)
+void CFavoriteAddDlg::OnUpdateOk(CCmdUI* pCmdUI)
{
- UpdateData(); // Retrieve UI values
+ UpdateData(); // Retrieve UI values
- pCmdUI->Enable( !m_name.IsEmpty() );
+ pCmdUI->Enable(!m_name.IsEmpty());
}
void CFavoriteAddDlg::OnOK()
{
- UpdateData(); // Retrieve UI values
+ UpdateData(); // Retrieve UI values
- // Remember settings
- AfxGetAppSettings().bFavRememberPos = !!m_bRememberPos;
- AfxGetAppSettings().bFavRelativeDrive = !!m_bRelativeDrive;
+ // Remember settings
+ AfxGetAppSettings().bFavRememberPos = !!m_bRememberPos;
+ AfxGetAppSettings().bFavRelativeDrive = !!m_bRelativeDrive;
- CCmdUIDialog::OnOK();
+ CCmdUIDialog::OnOK();
}
diff --git a/src/mpc-hc/FavoriteAddDlg.h b/src/mpc-hc/FavoriteAddDlg.h
index 0a9221c0f..6a1fc4297 100644
--- a/src/mpc-hc/FavoriteAddDlg.h
+++ b/src/mpc-hc/FavoriteAddDlg.h
@@ -30,31 +30,31 @@
class CFavoriteAddDlg : public CCmdUIDialog
{
- DECLARE_DYNAMIC(CFavoriteAddDlg)
+ DECLARE_DYNAMIC(CFavoriteAddDlg)
private:
- CString m_shortname, m_fullname;
+ CString m_shortname, m_fullname;
public:
- CFavoriteAddDlg(CString shortname, CString fullname, CWnd* pParent = NULL); // standard constructor
- virtual ~CFavoriteAddDlg();
+ CFavoriteAddDlg(CString shortname, CString fullname, CWnd* pParent = NULL); // standard constructor
+ virtual ~CFavoriteAddDlg();
- // Dialog Data
- enum { IDD = IDD_FAVADD };
+ // Dialog Data
+ enum { IDD = IDD_FAVADD };
- CComboBox m_namectrl;
- CString m_name;
- BOOL m_bRememberPos;
- BOOL m_bRelativeDrive;
+ CComboBox m_namectrl;
+ CString m_name;
+ BOOL m_bRememberPos;
+ BOOL m_bRelativeDrive;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnUpdateOk(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateOk(CCmdUI* pCmdUI);
protected:
- virtual void OnOK();
+ virtual void OnOK();
};
diff --git a/src/mpc-hc/FavoriteOrganizeDlg.cpp b/src/mpc-hc/FavoriteOrganizeDlg.cpp
index 53d2878ae..ae906ce94 100644
--- a/src/mpc-hc/FavoriteOrganizeDlg.cpp
+++ b/src/mpc-hc/FavoriteOrganizeDlg.cpp
@@ -31,7 +31,7 @@
//IMPLEMENT_DYNAMIC(CFavoriteOrganizeDlg, CResizableDialog)
CFavoriteOrganizeDlg::CFavoriteOrganizeDlg(CWnd* pParent /*=NULL*/)
- : CResizableDialog(CFavoriteOrganizeDlg::IDD, pParent)
+ : CResizableDialog(CFavoriteOrganizeDlg::IDD, pParent)
{
}
@@ -41,84 +41,84 @@ CFavoriteOrganizeDlg::~CFavoriteOrganizeDlg()
void CFavoriteOrganizeDlg::SetupList(bool fSave)
{
- int i = m_tab.GetCurSel();
-
- if (fSave) {
- CAtlList<CString> sl;
-
- for (int j = 0; j < m_list.GetItemCount(); j++) {
- CString desc = m_list.GetItemText(j, 0);
- desc.Remove(';');
- CString str = m_sl[i].GetAt((POSITION)m_list.GetItemData(j));
- sl.AddTail(desc + str.Mid(str.Find(';')));
- }
-
- m_sl[i].RemoveAll();
- m_sl[i].AddTailList(&sl);
- } else {
- m_list.DeleteAllItems();
-
- POSITION pos = m_sl[i].GetHeadPosition(), tmp;
- while (pos) {
- tmp = pos;
-
- CAtlList<CString> sl;
- Explode(m_sl[i].GetNext(pos), sl, ';', 3);
-
- int n = m_list.InsertItem(m_list.GetItemCount(), sl.RemoveHead());
- m_list.SetItemData(n, (DWORD_PTR)tmp);
-
- if (!sl.IsEmpty()) {
- REFERENCE_TIME rt = 0;
- if (1 == _stscanf_s(sl.GetHead(), _T("%I64d"), &rt) && rt > 0) {
- DVD_HMSF_TIMECODE hmsf = RT2HMSF(rt);
-
- CString str;
- str.Format(_T("[%02d:%02d:%02d]"), hmsf.bHours, hmsf.bMinutes, hmsf.bSeconds);
- m_list.SetItemText(n, 1, str);
- }
- }
- }
-
- UpdateColumnsSizes();
- }
+ int i = m_tab.GetCurSel();
+
+ if (fSave) {
+ CAtlList<CString> sl;
+
+ for (int j = 0; j < m_list.GetItemCount(); j++) {
+ CString desc = m_list.GetItemText(j, 0);
+ desc.Remove(';');
+ CString str = m_sl[i].GetAt((POSITION)m_list.GetItemData(j));
+ sl.AddTail(desc + str.Mid(str.Find(';')));
+ }
+
+ m_sl[i].RemoveAll();
+ m_sl[i].AddTailList(&sl);
+ } else {
+ m_list.DeleteAllItems();
+
+ POSITION pos = m_sl[i].GetHeadPosition(), tmp;
+ while (pos) {
+ tmp = pos;
+
+ CAtlList<CString> sl;
+ Explode(m_sl[i].GetNext(pos), sl, ';', 3);
+
+ int n = m_list.InsertItem(m_list.GetItemCount(), sl.RemoveHead());
+ m_list.SetItemData(n, (DWORD_PTR)tmp);
+
+ if (!sl.IsEmpty()) {
+ REFERENCE_TIME rt = 0;
+ if (1 == _stscanf_s(sl.GetHead(), _T("%I64d"), &rt) && rt > 0) {
+ DVD_HMSF_TIMECODE hmsf = RT2HMSF(rt);
+
+ CString str;
+ str.Format(_T("[%02d:%02d:%02d]"), hmsf.bHours, hmsf.bMinutes, hmsf.bSeconds);
+ m_list.SetItemText(n, 1, str);
+ }
+ }
+ }
+
+ UpdateColumnsSizes();
+ }
}
void CFavoriteOrganizeDlg::UpdateColumnsSizes()
{
- CRect r;
- m_list.GetClientRect(r);
- m_list.SetColumnWidth(0, LVSCW_AUTOSIZE);
- m_list.SetColumnWidth(1, LVSCW_AUTOSIZE);
- m_list.SetColumnWidth(1, max(m_list.GetColumnWidth(1), r.Width() - m_list.GetColumnWidth(0)));
+ CRect r;
+ m_list.GetClientRect(r);
+ m_list.SetColumnWidth(0, LVSCW_AUTOSIZE);
+ m_list.SetColumnWidth(1, LVSCW_AUTOSIZE);
+ m_list.SetColumnWidth(1, max(m_list.GetColumnWidth(1), r.Width() - m_list.GetColumnWidth(0)));
}
void CFavoriteOrganizeDlg::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_TAB1, m_tab);
- DDX_Control(pDX, IDC_LIST2, m_list);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_TAB1, m_tab);
+ DDX_Control(pDX, IDC_LIST2, m_list);
}
BEGIN_MESSAGE_MAP(CFavoriteOrganizeDlg, CResizableDialog)
- ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, OnTcnSelchangeTab1)
- ON_WM_DRAWITEM()
- ON_BN_CLICKED(IDC_BUTTON1, OnRenameBnClicked)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateRenameBn)
- ON_BN_CLICKED(IDC_BUTTON2, OnDeleteBnClicked)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON2, OnUpdateDeleteBn)
- ON_BN_CLICKED(IDC_BUTTON3, OnUpBnClicked)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON3, OnUpdateUpBn)
- ON_BN_CLICKED(IDC_BUTTON4, OnDownBnClicked)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON4, OnUpdateDownBn)
- ON_NOTIFY(TCN_SELCHANGING, IDC_TAB1, OnTcnSelchangingTab1)
- ON_BN_CLICKED(IDOK, OnBnClickedOk)
- ON_WM_ACTIVATE()
- ON_NOTIFY(LVN_ENDLABELEDIT, IDC_LIST2, OnLvnEndlabeleditList2)
- ON_NOTIFY(NM_DBLCLK, IDC_LIST2, OnPlayFavorite)
- ON_NOTIFY(LVN_KEYDOWN, IDC_LIST2, OnKeyPressed)
- ON_WM_SIZE()
+ ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, OnTcnSelchangeTab1)
+ ON_WM_DRAWITEM()
+ ON_BN_CLICKED(IDC_BUTTON1, OnRenameBnClicked)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateRenameBn)
+ ON_BN_CLICKED(IDC_BUTTON2, OnDeleteBnClicked)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON2, OnUpdateDeleteBn)
+ ON_BN_CLICKED(IDC_BUTTON3, OnUpBnClicked)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON3, OnUpdateUpBn)
+ ON_BN_CLICKED(IDC_BUTTON4, OnDownBnClicked)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON4, OnUpdateDownBn)
+ ON_NOTIFY(TCN_SELCHANGING, IDC_TAB1, OnTcnSelchangingTab1)
+ ON_BN_CLICKED(IDOK, OnBnClickedOk)
+ ON_WM_ACTIVATE()
+ ON_NOTIFY(LVN_ENDLABELEDIT, IDC_LIST2, OnLvnEndlabeleditList2)
+ ON_NOTIFY(NM_DBLCLK, IDC_LIST2, OnPlayFavorite)
+ ON_NOTIFY(LVN_KEYDOWN, IDC_LIST2, OnKeyPressed)
+ ON_WM_SIZE()
END_MESSAGE_MAP()
@@ -126,291 +126,291 @@ END_MESSAGE_MAP()
BOOL CFavoriteOrganizeDlg::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- m_tab.InsertItem(0, ResStr(IDS_FAVFILES));
- m_tab.InsertItem(1, ResStr(IDS_FAVDVDS));
- // m_tab.InsertItem(2, ResStr(IDS_FAVDEVICES));
- m_tab.SetCurSel(0);
+ m_tab.InsertItem(0, ResStr(IDS_FAVFILES));
+ m_tab.InsertItem(1, ResStr(IDS_FAVDVDS));
+ // m_tab.InsertItem(2, ResStr(IDS_FAVDEVICES));
+ m_tab.SetCurSel(0);
- m_list.InsertColumn(0, _T(""));
- m_list.InsertColumn(1, _T(""));
- m_list.SetExtendedStyle(m_list.GetExtendedStyle()|LVS_EX_FULLROWSELECT);
+ m_list.InsertColumn(0, _T(""));
+ m_list.InsertColumn(1, _T(""));
+ m_list.SetExtendedStyle(m_list.GetExtendedStyle() | LVS_EX_FULLROWSELECT);
- AfxGetAppSettings().GetFav(FAV_FILE, m_sl[0]);
- AfxGetAppSettings().GetFav(FAV_DVD, m_sl[1]);
- AfxGetAppSettings().GetFav(FAV_DEVICE, m_sl[2]);
+ AfxGetAppSettings().GetFav(FAV_FILE, m_sl[0]);
+ AfxGetAppSettings().GetFav(FAV_DVD, m_sl[1]);
+ AfxGetAppSettings().GetFav(FAV_DEVICE, m_sl[2]);
- SetupList(false);
+ SetupList(false);
- AddAnchor(IDC_TAB1, TOP_LEFT, BOTTOM_RIGHT);
- AddAnchor(IDC_LIST2, TOP_LEFT, BOTTOM_RIGHT);
- AddAnchor(IDC_BUTTON1, TOP_RIGHT);
- AddAnchor(IDC_BUTTON2, TOP_RIGHT);
- AddAnchor(IDC_BUTTON3, TOP_RIGHT);
- AddAnchor(IDC_BUTTON4, TOP_RIGHT);
- AddAnchor(IDOK, BOTTOM_RIGHT);
+ AddAnchor(IDC_TAB1, TOP_LEFT, BOTTOM_RIGHT);
+ AddAnchor(IDC_LIST2, TOP_LEFT, BOTTOM_RIGHT);
+ AddAnchor(IDC_BUTTON1, TOP_RIGHT);
+ AddAnchor(IDC_BUTTON2, TOP_RIGHT);
+ AddAnchor(IDC_BUTTON3, TOP_RIGHT);
+ AddAnchor(IDC_BUTTON4, TOP_RIGHT);
+ AddAnchor(IDOK, BOTTOM_RIGHT);
- EnableSaveRestore(IDS_R_DLG_ORGANIZE_FAV);
+ EnableSaveRestore(IDS_R_DLG_ORGANIZE_FAV);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CFavoriteOrganizeDlg::PreTranslateMessage(MSG* pMsg)
{
- // Inhibit default handling for the Enter key when the list has the focus and an item is selected.
- if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN
- && pMsg->hwnd == m_list.GetSafeHwnd() && m_list.GetSelectedCount() > 0) {
- return FALSE;
- }
+ // Inhibit default handling for the Enter key when the list has the focus and an item is selected.
+ if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN
+ && pMsg->hwnd == m_list.GetSafeHwnd() && m_list.GetSelectedCount() > 0) {
+ return FALSE;
+ }
- return __super::PreTranslateMessage(pMsg);
+ return __super::PreTranslateMessage(pMsg);
}
void CFavoriteOrganizeDlg::OnTcnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult)
{
- SetupList(false);
+ SetupList(false);
- m_list.SetWindowPos(&wndTop, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
+ m_list.SetWindowPos(&wndTop, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
- *pResult = 0;
+ *pResult = 0;
}
void CFavoriteOrganizeDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
- if (nIDCtl != IDC_LIST2) {
- return;
- }
-
- int nItem = lpDrawItemStruct->itemID;
- CRect rcItem = lpDrawItemStruct->rcItem;
-
- CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
-
- CBrush b;
- if (!!m_list.GetItemState(nItem, LVIS_SELECTED)) {
- b.CreateSolidBrush(0xf1dacc);
- pDC->FillRect(rcItem, &b);
- b.CreateSolidBrush(0xc56a31);
- pDC->FrameRect(rcItem, &b);
- } else {
- b.CreateSysColorBrush(COLOR_WINDOW);
- pDC->FillRect(rcItem, &b);
- }
-
- CString str;
- pDC->SetTextColor(0);
-
- str = m_list.GetItemText(nItem, 0);
- pDC->TextOut(rcItem.left + 3, (rcItem.top+rcItem.bottom - pDC->GetTextExtent(str).cy) / 2, str);
- str = m_list.GetItemText(nItem, 1);
- if (!str.IsEmpty()) {
- pDC->TextOut(rcItem.right - pDC->GetTextExtent(str).cx - 3, (rcItem.top+rcItem.bottom - pDC->GetTextExtent(str).cy) / 2, str);
- }
+ if (nIDCtl != IDC_LIST2) {
+ return;
+ }
+
+ int nItem = lpDrawItemStruct->itemID;
+ CRect rcItem = lpDrawItemStruct->rcItem;
+
+ CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
+
+ CBrush b;
+ if (!!m_list.GetItemState(nItem, LVIS_SELECTED)) {
+ b.CreateSolidBrush(0xf1dacc);
+ pDC->FillRect(rcItem, &b);
+ b.CreateSolidBrush(0xc56a31);
+ pDC->FrameRect(rcItem, &b);
+ } else {
+ b.CreateSysColorBrush(COLOR_WINDOW);
+ pDC->FillRect(rcItem, &b);
+ }
+
+ CString str;
+ pDC->SetTextColor(0);
+
+ str = m_list.GetItemText(nItem, 0);
+ pDC->TextOut(rcItem.left + 3, (rcItem.top + rcItem.bottom - pDC->GetTextExtent(str).cy) / 2, str);
+ str = m_list.GetItemText(nItem, 1);
+ if (!str.IsEmpty()) {
+ pDC->TextOut(rcItem.right - pDC->GetTextExtent(str).cx - 3, (rcItem.top + rcItem.bottom - pDC->GetTextExtent(str).cy) / 2, str);
+ }
}
void CFavoriteOrganizeDlg::OnRenameBnClicked()
{
- if (POSITION pos = m_list.GetFirstSelectedItemPosition()) {
- m_list.SetFocus();
- m_list.EditLabel(m_list.GetNextSelectedItem(pos));
- }
+ if (POSITION pos = m_list.GetFirstSelectedItemPosition()) {
+ m_list.SetFocus();
+ m_list.EditLabel(m_list.GetNextSelectedItem(pos));
+ }
}
void CFavoriteOrganizeDlg::OnUpdateRenameBn(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_list.GetSelectedCount() == 1);
+ pCmdUI->Enable(m_list.GetSelectedCount() == 1);
}
void CFavoriteOrganizeDlg::OnLvnEndlabeleditList2(NMHDR* pNMHDR, LRESULT* pResult)
{
- NMLVDISPINFO* pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
- if (pDispInfo->item.iItem >= 0 && pDispInfo->item.pszText) {
- m_list.SetItemText(pDispInfo->item.iItem, 0, pDispInfo->item.pszText);
- }
- UpdateColumnsSizes();
+ NMLVDISPINFO* pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
+ if (pDispInfo->item.iItem >= 0 && pDispInfo->item.pszText) {
+ m_list.SetItemText(pDispInfo->item.iItem, 0, pDispInfo->item.pszText);
+ }
+ UpdateColumnsSizes();
- *pResult = 0;
+ *pResult = 0;
}
void CFavoriteOrganizeDlg::PlayFavorite(int nItem)
{
- switch (m_tab.GetCurSel()) {
- case 0: // Files
- ((CMainFrame*)GetParentFrame())->PlayFavoriteFile(m_sl[0].GetAt((POSITION)m_list.GetItemData(nItem)));
- break;
- case 1: // DVDs
- ((CMainFrame*)GetParentFrame())->PlayFavoriteDVD(m_sl[1].GetAt((POSITION)m_list.GetItemData(nItem)));
- break;
- case 2: // Devices
- break;
- }
+ switch (m_tab.GetCurSel()) {
+ case 0: // Files
+ ((CMainFrame*)GetParentFrame())->PlayFavoriteFile(m_sl[0].GetAt((POSITION)m_list.GetItemData(nItem)));
+ break;
+ case 1: // DVDs
+ ((CMainFrame*)GetParentFrame())->PlayFavoriteDVD(m_sl[1].GetAt((POSITION)m_list.GetItemData(nItem)));
+ break;
+ case 2: // Devices
+ break;
+ }
}
-void CFavoriteOrganizeDlg::OnPlayFavorite(NMHDR *pNMHDR, LRESULT *pResult)
+void CFavoriteOrganizeDlg::OnPlayFavorite(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMITEMACTIVATE pItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
+ LPNMITEMACTIVATE pItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
- if (pItemActivate->iItem >= 0) {
- PlayFavorite(pItemActivate->iItem);
- }
+ if (pItemActivate->iItem >= 0) {
+ PlayFavorite(pItemActivate->iItem);
+ }
}
void CFavoriteOrganizeDlg::OnKeyPressed(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_KEYDOWN* pLVKeyDow = (LV_KEYDOWN*)pNMHDR;
-
- switch (pLVKeyDow->wVKey) {
- case VK_DELETE:
- case VK_BACK:
- OnDeleteBnClicked();
- *pResult = 1;
- break;
- case VK_RETURN:
- if (POSITION pos = m_list.GetFirstSelectedItemPosition()) {
- int nItem = m_list.GetNextSelectedItem(pos);
- if (nItem >= 0 && nItem < m_list.GetItemCount()) {
- PlayFavorite(nItem);
- }
- }
- *pResult = 1;
- break;
- case 'A':
- if (GetKeyState(VK_CONTROL) < 0) { // If the high-order bit is 1, the key is down; otherwise, it is up.
- m_list.SetItemState(-1, LVIS_SELECTED, LVIS_SELECTED);
- }
- *pResult = 1;
- break;
- case 'I':
- if (GetKeyState(VK_CONTROL) < 0) { // If the high-order bit is 1, the key is down; otherwise, it is up.
- for (int nItem = 0; nItem < m_list.GetItemCount(); nItem++) {
- m_list.SetItemState(nItem, ~m_list.GetItemState(nItem, LVIS_SELECTED), LVIS_SELECTED);
- }
- }
- *pResult = 1;
- break;
- default:
- *pResult = 0;
- }
+ LV_KEYDOWN* pLVKeyDow = (LV_KEYDOWN*)pNMHDR;
+
+ switch (pLVKeyDow->wVKey) {
+ case VK_DELETE:
+ case VK_BACK:
+ OnDeleteBnClicked();
+ *pResult = 1;
+ break;
+ case VK_RETURN:
+ if (POSITION pos = m_list.GetFirstSelectedItemPosition()) {
+ int nItem = m_list.GetNextSelectedItem(pos);
+ if (nItem >= 0 && nItem < m_list.GetItemCount()) {
+ PlayFavorite(nItem);
+ }
+ }
+ *pResult = 1;
+ break;
+ case 'A':
+ if (GetKeyState(VK_CONTROL) < 0) { // If the high-order bit is 1, the key is down; otherwise, it is up.
+ m_list.SetItemState(-1, LVIS_SELECTED, LVIS_SELECTED);
+ }
+ *pResult = 1;
+ break;
+ case 'I':
+ if (GetKeyState(VK_CONTROL) < 0) { // If the high-order bit is 1, the key is down; otherwise, it is up.
+ for (int nItem = 0; nItem < m_list.GetItemCount(); nItem++) {
+ m_list.SetItemState(nItem, ~m_list.GetItemState(nItem, LVIS_SELECTED), LVIS_SELECTED);
+ }
+ }
+ *pResult = 1;
+ break;
+ default:
+ *pResult = 0;
+ }
}
void CFavoriteOrganizeDlg::OnDeleteBnClicked()
{
- POSITION pos;
- int nItem = -1;
+ POSITION pos;
+ int nItem = -1;
- while ((pos = m_list.GetFirstSelectedItemPosition()) != NULL) {
- nItem = m_list.GetNextSelectedItem(pos);
- if (nItem < 0 || nItem >= m_list.GetItemCount()) {
- return;
- }
+ while ((pos = m_list.GetFirstSelectedItemPosition()) != NULL) {
+ nItem = m_list.GetNextSelectedItem(pos);
+ if (nItem < 0 || nItem >= m_list.GetItemCount()) {
+ return;
+ }
- m_list.DeleteItem(nItem);
- }
+ m_list.DeleteItem(nItem);
+ }
- nItem = min(nItem, m_list.GetItemCount() - 1);
- m_list.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED);
+ nItem = min(nItem, m_list.GetItemCount() - 1);
+ m_list.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED);
}
void CFavoriteOrganizeDlg::OnUpdateDeleteBn(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_list.GetSelectedCount() > 0);
+ pCmdUI->Enable(m_list.GetSelectedCount() > 0);
}
void CFavoriteOrganizeDlg::MoveItem(int nItem, int offset)
{
- DWORD_PTR data = m_list.GetItemData(nItem);
- CString strName = m_list.GetItemText(nItem, 0);
- CString strPos = m_list.GetItemText(nItem, 1);
+ DWORD_PTR data = m_list.GetItemData(nItem);
+ CString strName = m_list.GetItemText(nItem, 0);
+ CString strPos = m_list.GetItemText(nItem, 1);
- m_list.DeleteItem(nItem);
+ m_list.DeleteItem(nItem);
- nItem += offset;
+ nItem += offset;
- m_list.InsertItem(nItem, strName);
- m_list.SetItemData(nItem, data);
- m_list.SetItemText(nItem, 1, strPos);
- m_list.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED);
+ m_list.InsertItem(nItem, strName);
+ m_list.SetItemData(nItem, data);
+ m_list.SetItemText(nItem, 1, strPos);
+ m_list.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED);
}
void CFavoriteOrganizeDlg::OnUpBnClicked()
{
- POSITION pos = m_list.GetFirstSelectedItemPosition();
- int nItem;
+ POSITION pos = m_list.GetFirstSelectedItemPosition();
+ int nItem;
- while (pos) {
- nItem = m_list.GetNextSelectedItem(pos);
- if (nItem <= 0 || nItem >= m_list.GetItemCount()) {
- return;
- }
+ while (pos) {
+ nItem = m_list.GetNextSelectedItem(pos);
+ if (nItem <= 0 || nItem >= m_list.GetItemCount()) {
+ return;
+ }
- MoveItem(nItem, -1);
- }
+ MoveItem(nItem, -1);
+ }
}
void CFavoriteOrganizeDlg::OnUpdateUpBn(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_list.GetSelectedCount() > 0 && !m_list.GetItemState(0, LVIS_SELECTED));
+ pCmdUI->Enable(m_list.GetSelectedCount() > 0 && !m_list.GetItemState(0, LVIS_SELECTED));
}
void CFavoriteOrganizeDlg::OnDownBnClicked()
{
- CArray<int> selectedItems;
- POSITION pos = m_list.GetFirstSelectedItemPosition();
- int nItem;
-
- while (pos) {
- nItem = m_list.GetNextSelectedItem(pos);
- if (nItem < 0 || nItem >= m_list.GetItemCount() - 1) {
- return;
- }
-
- selectedItems.Add(nItem);
- }
-
- for (INT_PTR i = selectedItems.GetSize() - 1; i >= 0; i--) {
- MoveItem(selectedItems[i], +1);
- }
+ CArray<int> selectedItems;
+ POSITION pos = m_list.GetFirstSelectedItemPosition();
+ int nItem;
+
+ while (pos) {
+ nItem = m_list.GetNextSelectedItem(pos);
+ if (nItem < 0 || nItem >= m_list.GetItemCount() - 1) {
+ return;
+ }
+
+ selectedItems.Add(nItem);
+ }
+
+ for (INT_PTR i = selectedItems.GetSize() - 1; i >= 0; i--) {
+ MoveItem(selectedItems[i], +1);
+ }
}
void CFavoriteOrganizeDlg::OnUpdateDownBn(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_list.GetSelectedCount() > 0 && !m_list.GetItemState(m_list.GetItemCount() - 1, LVIS_SELECTED));
+ pCmdUI->Enable(m_list.GetSelectedCount() > 0 && !m_list.GetItemState(m_list.GetItemCount() - 1, LVIS_SELECTED));
}
-void CFavoriteOrganizeDlg::OnTcnSelchangingTab1(NMHDR *pNMHDR, LRESULT *pResult)
+void CFavoriteOrganizeDlg::OnTcnSelchangingTab1(NMHDR* pNMHDR, LRESULT* pResult)
{
- SetupList(true);
+ SetupList(true);
- *pResult = 0;
+ *pResult = 0;
}
void CFavoriteOrganizeDlg::OnBnClickedOk()
{
- SetupList(true);
+ SetupList(true);
- AfxGetAppSettings().SetFav(FAV_FILE, m_sl[0]);
- AfxGetAppSettings().SetFav(FAV_DVD, m_sl[1]);
- AfxGetAppSettings().SetFav(FAV_DEVICE, m_sl[2]);
+ AfxGetAppSettings().SetFav(FAV_FILE, m_sl[0]);
+ AfxGetAppSettings().SetFav(FAV_DVD, m_sl[1]);
+ AfxGetAppSettings().SetFav(FAV_DEVICE, m_sl[2]);
- OnOK();
+ OnOK();
}
void CFavoriteOrganizeDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
- __super::OnActivate(nState, pWndOther, bMinimized);
+ __super::OnActivate(nState, pWndOther, bMinimized);
- if (nState == WA_ACTIVE) {
- m_list.SetWindowPos(&wndTop, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
- }
+ if (nState == WA_ACTIVE) {
+ m_list.SetWindowPos(&wndTop, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
+ }
}
void CFavoriteOrganizeDlg::OnSize(UINT nType, int cx, int cy)
{
- __super::OnSize(nType, cx, cy);
+ __super::OnSize(nType, cx, cy);
- if (IsWindow(m_list)) {
- m_list.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER);
- }
+ if (IsWindow(m_list)) {
+ m_list.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER);
+ }
}
diff --git a/src/mpc-hc/FavoriteOrganizeDlg.h b/src/mpc-hc/FavoriteOrganizeDlg.h
index 38fcd2c09..a32a0bb5b 100644
--- a/src/mpc-hc/FavoriteOrganizeDlg.h
+++ b/src/mpc-hc/FavoriteOrganizeDlg.h
@@ -32,49 +32,49 @@
class CFavoriteOrganizeDlg : public CResizableDialog
{
- // DECLARE_DYNAMIC(CFavoriteOrganizeDlg)
+ // DECLARE_DYNAMIC(CFavoriteOrganizeDlg)
private:
- CAtlList<CString> m_sl[3];
+ CAtlList<CString> m_sl[3];
public:
- CFavoriteOrganizeDlg(CWnd* pParent = NULL); // standard constructor
- virtual ~CFavoriteOrganizeDlg();
+ CFavoriteOrganizeDlg(CWnd* pParent = NULL); // standard constructor
+ virtual ~CFavoriteOrganizeDlg();
- virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
- // Dialog Data
- enum { IDD = IDD_FAVORGANIZE };
+ // Dialog Data
+ enum { IDD = IDD_FAVORGANIZE };
- CTabCtrl m_tab;
- CListCtrl m_list;
+ CTabCtrl m_tab;
+ CListCtrl m_list;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
- void SetupList(bool fSave);
- void UpdateColumnsSizes();
- void MoveItem(int nItem, int offset);
- void PlayFavorite(int nItem);
+ void SetupList(bool fSave);
+ void UpdateColumnsSizes();
+ void MoveItem(int nItem, int offset);
+ void PlayFavorite(int nItem);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnTcnSelchangeTab1(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
- afx_msg void OnRenameBnClicked();
- afx_msg void OnUpdateRenameBn(CCmdUI* pCmdUI);
- afx_msg void OnDeleteBnClicked();
- afx_msg void OnUpdateDeleteBn(CCmdUI* pCmdUI);
- afx_msg void OnUpBnClicked();
- afx_msg void OnUpdateUpBn(CCmdUI* pCmdUI);
- afx_msg void OnDownBnClicked();
- afx_msg void OnUpdateDownBn(CCmdUI* pCmdUI);
- afx_msg void OnTcnSelchangingTab1(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnBnClickedOk();
- afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
- afx_msg void OnLvnEndlabeleditList2(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnPlayFavorite(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnKeyPressed(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg void OnTcnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
+ afx_msg void OnRenameBnClicked();
+ afx_msg void OnUpdateRenameBn(CCmdUI* pCmdUI);
+ afx_msg void OnDeleteBnClicked();
+ afx_msg void OnUpdateDeleteBn(CCmdUI* pCmdUI);
+ afx_msg void OnUpBnClicked();
+ afx_msg void OnUpdateUpBn(CCmdUI* pCmdUI);
+ afx_msg void OnDownBnClicked();
+ afx_msg void OnUpdateDownBn(CCmdUI* pCmdUI);
+ afx_msg void OnTcnSelchangingTab1(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnBnClickedOk();
+ afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
+ afx_msg void OnLvnEndlabeleditList2(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnPlayFavorite(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnKeyPressed(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnSize(UINT nType, int cx, int cy);
};
diff --git a/src/mpc-hc/FileDropTarget.cpp b/src/mpc-hc/FileDropTarget.cpp
index 0abd91872..7b4889d14 100644
--- a/src/mpc-hc/FileDropTarget.cpp
+++ b/src/mpc-hc/FileDropTarget.cpp
@@ -30,9 +30,9 @@
//IMPLEMENT_DYNAMIC(CFileDropTarget, COleDropTarget)
CFileDropTarget::CFileDropTarget(CDropTarget* pDropTarget)
- : m_pDropTarget(pDropTarget)
+ : m_pDropTarget(pDropTarget)
{
- ASSERT(m_pDropTarget);
+ ASSERT(m_pDropTarget);
}
CFileDropTarget::~CFileDropTarget()
@@ -41,34 +41,34 @@ CFileDropTarget::~CFileDropTarget()
DROPEFFECT CFileDropTarget::OnDragEnter(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
{
- return m_pDropTarget ? m_pDropTarget->OnDragEnter(pDataObject, dwKeyState, point) : DROPEFFECT_NONE;
+ return m_pDropTarget ? m_pDropTarget->OnDragEnter(pDataObject, dwKeyState, point) : DROPEFFECT_NONE;
}
DROPEFFECT CFileDropTarget::OnDragOver(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
{
- return m_pDropTarget ? m_pDropTarget->OnDragOver(pDataObject, dwKeyState, point) : DROPEFFECT_NONE;
+ return m_pDropTarget ? m_pDropTarget->OnDragOver(pDataObject, dwKeyState, point) : DROPEFFECT_NONE;
}
BOOL CFileDropTarget::OnDrop(CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point)
{
- return m_pDropTarget ? m_pDropTarget->OnDrop(pDataObject, dropEffect, point) : DROPEFFECT_NONE;
+ return m_pDropTarget ? m_pDropTarget->OnDrop(pDataObject, dropEffect, point) : DROPEFFECT_NONE;
}
DROPEFFECT CFileDropTarget::OnDropEx(CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint point)
{
- return m_pDropTarget ? m_pDropTarget->OnDropEx(pDataObject, dropDefault, dropList, point) : DROPEFFECT_NONE;
+ return m_pDropTarget ? m_pDropTarget->OnDropEx(pDataObject, dropDefault, dropList, point) : DROPEFFECT_NONE;
}
void CFileDropTarget::OnDragLeave(CWnd* pWnd)
{
- if (m_pDropTarget) {
- m_pDropTarget->OnDragLeave();
- }
+ if (m_pDropTarget) {
+ m_pDropTarget->OnDragLeave();
+ }
}
DROPEFFECT CFileDropTarget::OnDragScroll(CWnd* pWnd, DWORD dwKeyState, CPoint point)
{
- return m_pDropTarget ? m_pDropTarget->OnDragScroll(dwKeyState, point) : DROPEFFECT_NONE;
+ return m_pDropTarget ? m_pDropTarget->OnDragScroll(dwKeyState, point) : DROPEFFECT_NONE;
}
BEGIN_MESSAGE_MAP(CFileDropTarget, COleDropTarget)
diff --git a/src/mpc-hc/FileDropTarget.h b/src/mpc-hc/FileDropTarget.h
index d45658b76..055c0f5d8 100644
--- a/src/mpc-hc/FileDropTarget.h
+++ b/src/mpc-hc/FileDropTarget.h
@@ -29,46 +29,46 @@
class CDropTarget
{
public:
- CDropTarget() {}
+ CDropTarget() {}
- virtual DROPEFFECT OnDragEnter(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point) {
- return DROPEFFECT_NONE;
- }
- virtual DROPEFFECT OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point) {
- return DROPEFFECT_NONE;
- }
- virtual BOOL OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point) {
- return FALSE;
- }
- virtual DROPEFFECT OnDropEx(COleDataObject* pDataObject, DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint point) {
- return (DROPEFFECT)-1;
- }
- virtual void OnDragLeave() {}
- virtual DROPEFFECT OnDragScroll(DWORD dwKeyState, CPoint point) {
- return DROPEFFECT_NONE;
- }
+ virtual DROPEFFECT OnDragEnter(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point) {
+ return DROPEFFECT_NONE;
+ }
+ virtual DROPEFFECT OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point) {
+ return DROPEFFECT_NONE;
+ }
+ virtual BOOL OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point) {
+ return FALSE;
+ }
+ virtual DROPEFFECT OnDropEx(COleDataObject* pDataObject, DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint point) {
+ return (DROPEFFECT) - 1;
+ }
+ virtual void OnDragLeave() {}
+ virtual DROPEFFECT OnDragScroll(DWORD dwKeyState, CPoint point) {
+ return DROPEFFECT_NONE;
+ }
};
// CFileDropTarget command target
class CFileDropTarget : public COleDropTarget
{
- // DECLARE_DYNAMIC(CFileDropTarget)
+ // DECLARE_DYNAMIC(CFileDropTarget)
private:
- CDropTarget* m_pDropTarget;
+ CDropTarget* m_pDropTarget;
public:
- CFileDropTarget(CDropTarget* pDropTarget);
- virtual ~CFileDropTarget();
+ CFileDropTarget(CDropTarget* pDropTarget);
+ virtual ~CFileDropTarget();
protected:
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
- DROPEFFECT OnDragEnter(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
- DROPEFFECT OnDragOver(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
- BOOL OnDrop(CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point);
- DROPEFFECT OnDropEx(CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint point);
- void OnDragLeave(CWnd* pWnd);
- DROPEFFECT OnDragScroll(CWnd* pWnd, DWORD dwKeyState, CPoint point);
+ DROPEFFECT OnDragEnter(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
+ DROPEFFECT OnDragOver(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
+ BOOL OnDrop(CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point);
+ DROPEFFECT OnDropEx(CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint point);
+ void OnDragLeave(CWnd* pWnd);
+ DROPEFFECT OnDragScroll(CWnd* pWnd, DWORD dwKeyState, CPoint point);
};
diff --git a/src/mpc-hc/FilterEnum.h b/src/mpc-hc/FilterEnum.h
index e10fc85eb..2dc85fcb0 100644
--- a/src/mpc-hc/FilterEnum.h
+++ b/src/mpc-hc/FilterEnum.h
@@ -26,200 +26,200 @@
enum {
- SOURCE_FILTER,
- DECODER,
- DXVA_DECODER,
- FFMPEG_DECODER,
- FILTER_TYPE_NB
+ SOURCE_FILTER,
+ DECODER,
+ DXVA_DECODER,
+ FFMPEG_DECODER,
+ FILTER_TYPE_NB
};
enum SOURCE_FILTER {
#if INTERNAL_SOURCEFILTER_CDDA
- SRC_CDDA,
+ SRC_CDDA,
#endif
#if INTERNAL_SOURCEFILTER_CDXA
- SRC_CDXA,
+ SRC_CDXA,
#endif
#if INTERNAL_SOURCEFILTER_VTS
- SRC_VTS,
+ SRC_VTS,
#endif
#if INTERNAL_SOURCEFILTER_FLIC
- SRC_FLIC,
+ SRC_FLIC,
#endif
#if INTERNAL_SOURCEFILTER_DVSOURCE
- SRC_D2V,
+ SRC_D2V,
#endif
#if INTERNAL_SOURCEFILTER_DTSAC3
- SRC_DTSAC3,
+ SRC_DTSAC3,
#endif
#if INTERNAL_SOURCEFILTER_MATROSKA
- SRC_MATROSKA,
+ SRC_MATROSKA,
#endif
#if INTERNAL_SOURCEFILTER_SHOUTCAST
- SRC_SHOUTCAST,
+ SRC_SHOUTCAST,
#endif
#if INTERNAL_SOURCEFILTER_REALMEDIA
- SRC_REALMEDIA,
+ SRC_REALMEDIA,
#endif
#if INTERNAL_SOURCEFILTER_AVI
- SRC_AVI,
+ SRC_AVI,
#endif
#if INTERNAL_SOURCEFILTER_OGG
- SRC_OGG,
+ SRC_OGG,
#endif
#if INTERNAL_SOURCEFILTER_MPEG
- SRC_MPEG,
+ SRC_MPEG,
#endif
#if INTERNAL_SOURCEFILTER_MPEGAUDIO
- SRC_MPA,
+ SRC_MPA,
#endif
#if INTERNAL_SOURCEFILTER_DSM
- SRC_DSM,
+ SRC_DSM,
#endif
- SRC_SUBS,
+ SRC_SUBS,
#if INTERNAL_SOURCEFILTER_MP4
- SRC_MP4,
+ SRC_MP4,
#endif
#if INTERNAL_SOURCEFILTER_FLV
- SRC_FLV,
+ SRC_FLV,
#endif
#if INTERNAL_SOURCEFILTER_FLAC
- SRC_FLAC,
+ SRC_FLAC,
#endif
- SRC_LAST
+ SRC_LAST
};
enum DECODER {
#if INTERNAL_DECODER_MPEG1
- TRA_MPEG1,
+ TRA_MPEG1,
#endif
#if INTERNAL_DECODER_MPEG2
- TRA_MPEG2,
+ TRA_MPEG2,
#endif
#if INTERNAL_DECODER_REALVIDEO
- TRA_RV,
+ TRA_RV,
#endif
#if INTERNAL_DECODER_REALAUDIO
- TRA_RA,
+ TRA_RA,
#endif
#if INTERNAL_DECODER_MPEGAUDIO
- TRA_MPA,
+ TRA_MPA,
#endif
#if INTERNAL_DECODER_DTS
- TRA_DTS,
+ TRA_DTS,
#endif
#if INTERNAL_DECODER_LPCM
- TRA_LPCM,
+ TRA_LPCM,
#endif
#if INTERNAL_DECODER_AC3
- TRA_AC3,
+ TRA_AC3,
#endif
#if INTERNAL_DECODER_AAC
- TRA_AAC,
+ TRA_AAC,
#endif
#if INTERNAL_DECODER_ALAC
- TRA_ALAC,
+ TRA_ALAC,
#endif
#if INTERNAL_DECODER_ALS
- TRA_ALS,
+ TRA_ALS,
#endif
#if INTERNAL_DECODER_PS2AUDIO
- TRA_PS2AUD,
+ TRA_PS2AUD,
#endif
#if INTERNAL_DECODER_VORBIS
- TRA_VORBIS,
+ TRA_VORBIS,
#endif
#if INTERNAL_DECODER_FLAC
- TRA_FLAC,
+ TRA_FLAC,
#endif
#if INTERNAL_DECODER_NELLYMOSER
- TRA_NELLY,
+ TRA_NELLY,
#endif
#if INTERNAL_DECODER_AMR
- TRA_AMR,
+ TRA_AMR,
#endif
#if INTERNAL_DECODER_PCM
- TRA_PCM,
+ TRA_PCM,
#endif
- TRA_LAST
+ TRA_LAST
};
enum DXVA_DECODER {
#if INTERNAL_DECODER_H264_DXVA
- TRA_DXVA_H264,
+ TRA_DXVA_H264,
#endif
#if INTERNAL_DECODER_VC1_DXVA
- TRA_DXVA_VC1,
+ TRA_DXVA_VC1,
#endif
#if INTERNAL_DECODER_MPEG2_DXVA
- TRA_DXVA_MPEG2,
+ TRA_DXVA_MPEG2,
#endif
#if INTERNAL_DECODER_WMV3_DXVA
- TRA_DXVA_WMV3,
+ TRA_DXVA_WMV3,
#endif
- TRA_DXVA_LAST,
- // dummy values (needed in FGManager.cpp)
+ TRA_DXVA_LAST,
+ // dummy values (needed in FGManager.cpp)
#if !INTERNAL_DECODER_H264_DXVA & INTERNAL_DECODER_H264
- TRA_DXVA_H264 = TRA_DXVA_LAST,
+ TRA_DXVA_H264 = TRA_DXVA_LAST,
#endif
#if !INTERNAL_DECODER_VC1_DXVA & INTERNAL_DECODER_VC1
- TRA_DXVA_VC1 = TRA_DXVA_LAST,
+ TRA_DXVA_VC1 = TRA_DXVA_LAST,
#endif
};
enum FFMPEG_DECODER {
#if INTERNAL_DECODER_H264
- FFM_H264,
+ FFM_H264,
#endif
#if INTERNAL_DECODER_VC1
- FFM_VC1,
+ FFM_VC1,
#endif
#if INTERNAL_DECODER_FLV
- FFM_FLV4,
+ FFM_FLV4,
#endif
#if INTERNAL_DECODER_VP356
- FFM_VP356,
+ FFM_VP356,
#endif
#if INTERNAL_DECODER_VP8
- FFM_VP8,
+ FFM_VP8,
#endif
#if INTERNAL_DECODER_XVID
- FFM_XVID,
+ FFM_XVID,
#endif
#if INTERNAL_DECODER_DIVX
- FFM_DIVX,
+ FFM_DIVX,
#endif
#if INTERNAL_DECODER_MSMPEG4
- FFM_MSMPEG4,
+ FFM_MSMPEG4,
#endif
#if INTERNAL_DECODER_WMV
- FFM_WMV,
+ FFM_WMV,
#endif
#if INTERNAL_DECODER_SVQ
- FFM_SVQ3,
+ FFM_SVQ3,
#endif
#if INTERNAL_DECODER_H263
- FFM_H263,
+ FFM_H263,
#endif
#if INTERNAL_DECODER_THEORA
- FFM_THEORA,
+ FFM_THEORA,
#endif
#if INTERNAL_DECODER_AMVV
- FFM_AMVV,
+ FFM_AMVV,
#endif
#if INTERNAL_DECODER_MJPEG
- FFM_MJPEG,
+ FFM_MJPEG,
#endif
#if INTERNAL_DECODER_INDEO
- FFM_INDEO,
+ FFM_INDEO,
#endif
- FFM_LAST,
- // dummy values (needed in FGManager.cpp)
+ FFM_LAST,
+ // dummy values (needed in FGManager.cpp)
#if !INTERNAL_DECODER_H264 & INTERNAL_DECODER_H264_DXVA
- FFM_H264 = FFM_LAST,
+ FFM_H264 = FFM_LAST,
#endif
#if !INTERNAL_DECODER_VC1 & INTERNAL_DECODER_VC1_DXVA
- FFM_VC1 = FFM_LAST,
+ FFM_VC1 = FFM_LAST,
#endif
};
diff --git a/src/mpc-hc/FloatEdit.cpp b/src/mpc-hc/FloatEdit.cpp
index 9613e7993..dec39d4d9 100644
--- a/src/mpc-hc/FloatEdit.cpp
+++ b/src/mpc-hc/FloatEdit.cpp
@@ -31,52 +31,52 @@ IMPLEMENT_DYNAMIC(CFloatEdit, CEdit)
bool CFloatEdit::GetFloat(float& f)
{
- CString s;
- GetWindowText(s);
- return (_stscanf_s(s, _T("%f"), &f) == 1);
+ CString s;
+ GetWindowText(s);
+ return (_stscanf_s(s, _T("%f"), &f) == 1);
}
double CFloatEdit::operator = (double d)
{
- CString s;
- s.Format(_T("%.4f"), d);
- SetWindowText(s);
- return d;
+ CString s;
+ s.Format(_T("%.4f"), d);
+ SetWindowText(s);
+ return d;
}
CFloatEdit::operator double()
{
- CString s;
- GetWindowText(s);
- float f = 0;
- return (_stscanf_s(s, _T("%f"), &f) == 1 ? f : 0);
+ CString s;
+ GetWindowText(s);
+ float f = 0;
+ return (_stscanf_s(s, _T("%f"), &f) == 1 ? f : 0);
}
BEGIN_MESSAGE_MAP(CFloatEdit, CEdit)
- ON_WM_CHAR()
+ ON_WM_CHAR()
END_MESSAGE_MAP()
void CFloatEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
- if (!(nChar >= '0' && nChar <= '9' || nChar == '.' || nChar == '\b')) {
- return;
- }
+ if (!(nChar >= '0' && nChar <= '9' || nChar == '.' || nChar == '\b')) {
+ return;
+ }
- CString str;
- GetWindowText(str);
+ CString str;
+ GetWindowText(str);
- if (nChar == '.' && (str.Find('.') >= 0 || str.IsEmpty())) {
- return;
- }
+ if (nChar == '.' && (str.Find('.') >= 0 || str.IsEmpty())) {
+ return;
+ }
- int nStartChar, nEndChar;
- GetSel(nStartChar, nEndChar);
+ int nStartChar, nEndChar;
+ GetSel(nStartChar, nEndChar);
- if (nChar == '\b' && nStartChar <= 0) {
- return;
- }
+ if (nChar == '\b' && nStartChar <= 0) {
+ return;
+ }
- CEdit::OnChar(nChar, nRepCnt, nFlags);
+ CEdit::OnChar(nChar, nRepCnt, nFlags);
}
// CIntEdit
@@ -84,34 +84,34 @@ void CFloatEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
IMPLEMENT_DYNAMIC(CIntEdit, CEdit)
BEGIN_MESSAGE_MAP(CIntEdit, CEdit)
- ON_WM_CHAR()
+ ON_WM_CHAR()
END_MESSAGE_MAP()
void CIntEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
- if (!(nChar >= '0' && nChar <= '9' || nChar == '-' || nChar == '\b')) {
- return;
- }
+ if (!(nChar >= '0' && nChar <= '9' || nChar == '-' || nChar == '\b')) {
+ return;
+ }
- CString str;
- GetWindowText(str);
+ CString str;
+ GetWindowText(str);
- if (nChar == '-' && !str.IsEmpty() && str[0] == '-') {
- return;
- }
+ if (nChar == '-' && !str.IsEmpty() && str[0] == '-') {
+ return;
+ }
- int nStartChar, nEndChar;
- GetSel(nStartChar, nEndChar);
+ int nStartChar, nEndChar;
+ GetSel(nStartChar, nEndChar);
- if (nChar == '\b' && nStartChar <= 0) {
- return;
- }
+ if (nChar == '\b' && nStartChar <= 0) {
+ return;
+ }
- if (nChar == '-' && (nStartChar != 0 || nEndChar != 0)) {
- return;
- }
+ if (nChar == '-' && (nStartChar != 0 || nEndChar != 0)) {
+ return;
+ }
- CEdit::OnChar(nChar, nRepCnt, nFlags);
+ CEdit::OnChar(nChar, nRepCnt, nFlags);
}
// CHexEdit
@@ -120,51 +120,51 @@ IMPLEMENT_DYNAMIC(CHexEdit, CEdit)
bool CHexEdit::GetDWORD(DWORD& dw)
{
- CString s;
- GetWindowText(s);
- return (_stscanf_s(s, _T("%x"), &dw) == 1);
+ CString s;
+ GetWindowText(s);
+ return (_stscanf_s(s, _T("%x"), &dw) == 1);
}
DWORD CHexEdit::operator = (DWORD dw)
{
- CString s;
- s.Format(_T("%08x"), dw);
- SetWindowText(s);
- return dw;
+ CString s;
+ s.Format(_T("%08x"), dw);
+ SetWindowText(s);
+ return dw;
}
CHexEdit::operator DWORD()
{
- CString s;
- GetWindowText(s);
- DWORD dw;
- return (_stscanf_s(s, _T("%x"), &dw) == 1 ? dw : 0);
+ CString s;
+ GetWindowText(s);
+ DWORD dw;
+ return (_stscanf_s(s, _T("%x"), &dw) == 1 ? dw : 0);
}
BEGIN_MESSAGE_MAP(CHexEdit, CEdit)
- ON_WM_CHAR()
+ ON_WM_CHAR()
END_MESSAGE_MAP()
void CHexEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
- if (!(nChar >= 'A' && nChar <= 'F' || nChar >= 'a' && nChar <= 'f'
- || nChar >= '0' && nChar <= '9' || nChar == '\b')) {
- return;
- }
+ if (!(nChar >= 'A' && nChar <= 'F' || nChar >= 'a' && nChar <= 'f'
+ || nChar >= '0' && nChar <= '9' || nChar == '\b')) {
+ return;
+ }
- CString str;
- GetWindowText(str);
+ CString str;
+ GetWindowText(str);
- int nStartChar, nEndChar;
- GetSel(nStartChar, nEndChar);
+ int nStartChar, nEndChar;
+ GetSel(nStartChar, nEndChar);
- if (nChar == '\b' && nStartChar <= 0) {
- return;
- }
+ if (nChar == '\b' && nStartChar <= 0) {
+ return;
+ }
- if (nChar != '\b' && nEndChar - nStartChar == 0 && str.GetLength() >= 8) {
- return;
- }
+ if (nChar != '\b' && nEndChar - nStartChar == 0 && str.GetLength() >= 8) {
+ return;
+ }
- CEdit::OnChar(nChar, nRepCnt, nFlags);
+ CEdit::OnChar(nChar, nRepCnt, nFlags);
}
diff --git a/src/mpc-hc/FloatEdit.h b/src/mpc-hc/FloatEdit.h
index 78b229817..4fcf190bc 100644
--- a/src/mpc-hc/FloatEdit.h
+++ b/src/mpc-hc/FloatEdit.h
@@ -29,15 +29,15 @@
class CFloatEdit : public CEdit
{
public:
- bool GetFloat(float& f);
- double operator = (double d);
- operator double();
+ bool GetFloat(float& f);
+ double operator = (double d);
+ operator double();
- DECLARE_DYNAMIC(CFloatEdit)
- DECLARE_MESSAGE_MAP()
+ DECLARE_DYNAMIC(CFloatEdit)
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
+ afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
};
// CIntEdit
@@ -45,11 +45,11 @@ public:
class CIntEdit : public CEdit
{
public:
- DECLARE_DYNAMIC(CIntEdit)
- DECLARE_MESSAGE_MAP()
+ DECLARE_DYNAMIC(CIntEdit)
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
+ afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
};
// CHexEdit
@@ -57,13 +57,13 @@ public:
class CHexEdit : public CEdit
{
public:
- bool GetDWORD(DWORD& dw);
- DWORD operator = (DWORD dw);
- operator DWORD();
+ bool GetDWORD(DWORD& dw);
+ DWORD operator = (DWORD dw);
+ operator DWORD();
- DECLARE_DYNAMIC(CHexEdit)
- DECLARE_MESSAGE_MAP()
+ DECLARE_DYNAMIC(CHexEdit)
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
+ afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
};
diff --git a/src/mpc-hc/FullscreenWnd.cpp b/src/mpc-hc/FullscreenWnd.cpp
index 906fbe49d..b81236ff2 100644
--- a/src/mpc-hc/FullscreenWnd.cpp
+++ b/src/mpc-hc/FullscreenWnd.cpp
@@ -32,9 +32,9 @@
IMPLEMENT_DYNAMIC(CFullscreenWnd, CWnd)
CFullscreenWnd::CFullscreenWnd(CMainFrame* pMainFrame)
{
- m_pMainFrame = pMainFrame;
- m_hCursor = ::LoadCursor(NULL, IDC_ARROW);
- m_bCursorVisible = false;
+ m_pMainFrame = pMainFrame;
+ m_hCursor = ::LoadCursor(NULL, IDC_ARROW);
+ m_bCursorVisible = false;
}
CFullscreenWnd::~CFullscreenWnd()
@@ -43,91 +43,91 @@ CFullscreenWnd::~CFullscreenWnd()
BEGIN_MESSAGE_MAP(CFullscreenWnd, CWnd)
- ON_WM_ERASEBKGND()
- ON_WM_SETCURSOR()
+ ON_WM_ERASEBKGND()
+ ON_WM_SETCURSOR()
END_MESSAGE_MAP()
LRESULT CFullscreenWnd::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
- switch (message) {
- case WM_COMMAND :
- m_pMainFrame->PostMessage(message, wParam, lParam);
- break;
- }
- return CWnd::WindowProc(message, wParam, lParam);
+ switch (message) {
+ case WM_COMMAND :
+ m_pMainFrame->PostMessage(message, wParam, lParam);
+ break;
+ }
+ return CWnd::WindowProc(message, wParam, lParam);
}
BOOL CFullscreenWnd::PreTranslateMessage(MSG* pMsg)
{
- switch (pMsg->message) {
- case WM_MOUSEMOVE :
- case WM_SYSKEYDOWN :
- case WM_SYSKEYUP :
- case WM_SYSCHAR :
- case WM_SYSCOMMAND :
-
- case WM_KEYDOWN :
- case WM_KEYUP :
- case WM_CHAR :
-
- case WM_LBUTTONDOWN :
- case WM_LBUTTONUP :
- case WM_LBUTTONDBLCLK :
- case WM_MBUTTONDOWN :
- case WM_MBUTTONUP :
- case WM_MBUTTONDBLCLK :
- case WM_RBUTTONDOWN :
- case WM_RBUTTONUP :
- case WM_RBUTTONDBLCLK :
-
- case WM_MOUSEWHEEL :
-
- m_pMainFrame->SendMessage(pMsg->message, pMsg->wParam, pMsg->lParam);
- break;
- }
-
- return CWnd::PreTranslateMessage(pMsg);
+ switch (pMsg->message) {
+ case WM_MOUSEMOVE :
+ case WM_SYSKEYDOWN :
+ case WM_SYSKEYUP :
+ case WM_SYSCHAR :
+ case WM_SYSCOMMAND :
+
+ case WM_KEYDOWN :
+ case WM_KEYUP :
+ case WM_CHAR :
+
+ case WM_LBUTTONDOWN :
+ case WM_LBUTTONUP :
+ case WM_LBUTTONDBLCLK :
+ case WM_MBUTTONDOWN :
+ case WM_MBUTTONUP :
+ case WM_MBUTTONDBLCLK :
+ case WM_RBUTTONDOWN :
+ case WM_RBUTTONUP :
+ case WM_RBUTTONDBLCLK :
+
+ case WM_MOUSEWHEEL :
+
+ m_pMainFrame->SendMessage(pMsg->message, pMsg->wParam, pMsg->lParam);
+ break;
+ }
+
+ return CWnd::PreTranslateMessage(pMsg);
}
BOOL CFullscreenWnd::PreCreateWindow(CREATESTRUCT& cs)
{
- if (!CWnd::PreCreateWindow(cs)) {
- return FALSE;
- }
+ if (!CWnd::PreCreateWindow(cs)) {
+ return FALSE;
+ }
- cs.style &= ~WS_BORDER;
- cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS, m_hCursor, HBRUSH(COLOR_WINDOW+1), NULL);
+ cs.style &= ~WS_BORDER;
+ cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS, m_hCursor, HBRUSH(COLOR_WINDOW + 1), NULL);
- return TRUE;
+ return TRUE;
}
// CFullscreenWnd message handlers
BOOL CFullscreenWnd::OnEraseBkgnd(CDC* pDC)
{
- return false;
+ return false;
}
BOOL CFullscreenWnd::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
- if (m_bCursorVisible) {
- ::SetCursor(m_hCursor);
- } else {
- ::SetCursor(NULL);
- }
- return FALSE;
+ if (m_bCursorVisible) {
+ ::SetCursor(m_hCursor);
+ } else {
+ ::SetCursor(NULL);
+ }
+ return FALSE;
}
void CFullscreenWnd::ShowCursor(bool bVisible)
{
- if (m_bCursorVisible != bVisible) {
- m_bCursorVisible = bVisible;
- PostMessage (WM_SETCURSOR,0,0);
- }
+ if (m_bCursorVisible != bVisible) {
+ m_bCursorVisible = bVisible;
+ PostMessage(WM_SETCURSOR, 0, 0);
+ }
}
bool CFullscreenWnd::IsWindow()
{
- return (m_hWnd != NULL);
+ return (m_hWnd != NULL);
}
diff --git a/src/mpc-hc/FullscreenWnd.h b/src/mpc-hc/FullscreenWnd.h
index abeb402da..8bee90adf 100644
--- a/src/mpc-hc/FullscreenWnd.h
+++ b/src/mpc-hc/FullscreenWnd.h
@@ -28,27 +28,27 @@ class CMainFrame;
class CFullscreenWnd : public CWnd
{
- DECLARE_DYNAMIC(CFullscreenWnd)
+ DECLARE_DYNAMIC(CFullscreenWnd)
public:
- CFullscreenWnd(CMainFrame* pMainFrame);
- virtual ~CFullscreenWnd();
+ CFullscreenWnd(CMainFrame* pMainFrame);
+ virtual ~CFullscreenWnd();
- void ShowCursor(bool bVisible);
- bool IsWindow();
+ void ShowCursor(bool bVisible);
+ bool IsWindow();
protected:
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
+ virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
- CMainFrame* m_pMainFrame;
- HCURSOR m_hCursor;
- bool m_bCursorVisible;
+ CMainFrame* m_pMainFrame;
+ HCURSOR m_hCursor;
+ bool m_bCursorVisible;
public:
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
- afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
+ afx_msg BOOL OnEraseBkgnd(CDC* pDC);
+ afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
};
diff --git a/src/mpc-hc/GoToDlg.cpp b/src/mpc-hc/GoToDlg.cpp
index c0d1bd7a3..73884301e 100644
--- a/src/mpc-hc/GoToDlg.cpp
+++ b/src/mpc-hc/GoToDlg.cpp
@@ -33,20 +33,20 @@
IMPLEMENT_DYNAMIC(CGoToDlg, CDialog)
CGoToDlg::CGoToDlg(REFERENCE_TIME time, REFERENCE_TIME maxTime, double fps, CWnd* pParent /*=NULL*/)
- : CDialog(CGoToDlg::IDD, pParent)
- , m_timestr(_T(""))
- , m_framestr(_T(""))
- , m_time(time)
- , m_maxTime(maxTime)
- , m_fps(fps)
+ : CDialog(CGoToDlg::IDD, pParent)
+ , m_timestr(_T(""))
+ , m_framestr(_T(""))
+ , m_time(time)
+ , m_maxTime(maxTime)
+ , m_fps(fps)
{
- if (m_fps == 0) {
- CString str = AfxGetApp()->GetProfileString(IDS_R_SETTINGS, _T("fps"), _T("0"));
- float fps;
- if (_stscanf_s(str, _T("%f"), &fps) == 1) {
- m_fps = fps;
- }
- }
+ if (m_fps == 0) {
+ CString str = AfxGetApp()->GetProfileString(IDS_R_SETTINGS, _T("fps"), _T("0"));
+ float fps;
+ if (_stscanf_s(str, _T("%f"), &fps) == 1) {
+ m_fps = fps;
+ }
+ }
}
CGoToDlg::~CGoToDlg()
@@ -55,67 +55,67 @@ CGoToDlg::~CGoToDlg()
void CGoToDlg::DoDataExchange(CDataExchange* pDX)
{
- CDialog::DoDataExchange(pDX);
- DDX_Text(pDX, IDC_EDIT1, m_timestr);
- DDX_Text(pDX, IDC_EDIT2, m_framestr);
- DDX_Control(pDX, IDC_EDIT1, m_timeedit);
- DDX_Control(pDX, IDC_EDIT2, m_frameedit);
+ CDialog::DoDataExchange(pDX);
+ DDX_Text(pDX, IDC_EDIT1, m_timestr);
+ DDX_Text(pDX, IDC_EDIT2, m_framestr);
+ DDX_Control(pDX, IDC_EDIT1, m_timeedit);
+ DDX_Control(pDX, IDC_EDIT2, m_frameedit);
}
BOOL CGoToDlg::OnInitDialog()
{
- CDialog::OnInitDialog();
-
- bool showHours = (m_maxTime >= 3600*1000*10000i64);
-
- if (showHours) {
- m_timeedit.EnableMask(_T("DD DD DD DDD"), _T("__:__:__.___"), L'0', _T("0123456789"));
- } else {
- m_timeedit.EnableMask(_T("DD DD DDD"), _T("__:__.___"), L'0', _T("0123456789"));
- }
- m_timeedit.EnableGetMaskedCharsOnly(false);
- m_timeedit.EnableSelectByGroup(false);
-
- int time = (int) (m_time / 10000);
- if (time >= 0) {
- if (showHours) {
- m_timestr.Format(_T("%02d:%02d:%02d.%03d"),
- (time/(1000*60*60))%60, (time/(1000*60))%60, (time/1000)%60, time%1000);
- } else {
- m_timestr.Format(_T("%02d:%02d.%03d"),
- (time/(1000*60))%60, (time/1000)%60, time%1000);
- }
-
- if (m_fps > 0) {
- m_framestr.Format(_T("%d, %.3f"), (int)(m_fps*m_time/10000000), m_fps);
- }
-
- UpdateData(FALSE);
-
- switch (AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("gotoluf"), 0)) {
- default:
- case 0:
- m_timeedit.SetFocus();
- m_timeedit.SetSel(0, 0);
- break;
- case 1:
- m_frameedit.SetFocus();
- m_frameedit.SetSel(0, m_framestr.Find(','));
- break;
- }
-
- }
-
- return FALSE;
-
- // return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ CDialog::OnInitDialog();
+
+ bool showHours = (m_maxTime >= 3600 * 1000 * 10000i64);
+
+ if (showHours) {
+ m_timeedit.EnableMask(_T("DD DD DD DDD"), _T("__:__:__.___"), L'0', _T("0123456789"));
+ } else {
+ m_timeedit.EnableMask(_T("DD DD DDD"), _T("__:__.___"), L'0', _T("0123456789"));
+ }
+ m_timeedit.EnableGetMaskedCharsOnly(false);
+ m_timeedit.EnableSelectByGroup(false);
+
+ int time = (int)(m_time / 10000);
+ if (time >= 0) {
+ if (showHours) {
+ m_timestr.Format(_T("%02d:%02d:%02d.%03d"),
+ (time / (1000 * 60 * 60)) % 60, (time / (1000 * 60)) % 60, (time / 1000) % 60, time % 1000);
+ } else {
+ m_timestr.Format(_T("%02d:%02d.%03d"),
+ (time / (1000 * 60)) % 60, (time / 1000) % 60, time % 1000);
+ }
+
+ if (m_fps > 0) {
+ m_framestr.Format(_T("%d, %.3f"), (int)(m_fps * m_time / 10000000), m_fps);
+ }
+
+ UpdateData(FALSE);
+
+ switch (AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("gotoluf"), 0)) {
+ default:
+ case 0:
+ m_timeedit.SetFocus();
+ m_timeedit.SetSel(0, 0);
+ break;
+ case 1:
+ m_frameedit.SetFocus();
+ m_frameedit.SetSel(0, m_framestr.Find(','));
+ break;
+ }
+
+ }
+
+ return FALSE;
+
+ // return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BEGIN_MESSAGE_MAP(CGoToDlg, CDialog)
- ON_BN_CLICKED(IDC_OK1, OnBnClickedOk1)
- ON_BN_CLICKED(IDC_OK2, OnBnClickedOk2)
+ ON_BN_CLICKED(IDC_OK1, OnBnClickedOk1)
+ ON_BN_CLICKED(IDC_OK2, OnBnClickedOk2)
END_MESSAGE_MAP()
@@ -123,72 +123,72 @@ END_MESSAGE_MAP()
void CGoToDlg::OnBnClickedOk1()
{
- UpdateData();
-
- unsigned int hh = 0;
- unsigned int mm = 0;
- float ss = 0.0;
- wchar_t c1 = L':'; // delimiter character
- wchar_t c2 = L':'; // delimiter character
- wchar_t c3[2]; // unnecessary character
-
- if ((swscanf_s(m_timestr, L"%f%1s", &ss, &c3, _countof(c3)) == 1 || // sss[.ms]
- swscanf_s(m_timestr, L"%u%c%f%1s", &mm, &c2, sizeof(wchar_t), &ss, &c3, _countof(c3)) == 3 && ss < 60 || // mmm:ss[.ms]
- swscanf_s(m_timestr, L"%u%c%u%c%f%1s", &hh, &c1, sizeof(wchar_t), &mm, &c2, sizeof(wchar_t), &ss, &c3, _countof(c3)) == 5 && mm < 60 && ss < 60) && // hhh:mm:ss[.ms]
- c1 == L':' && c2 == L':' && ss >=0) {
-
- int time = (int)(1000*((hh*60+mm)*60+ss)+0.5);
- m_time = time * 10000i64;
-
- OnOK();
- } else {
- AfxMessageBox(IDS_GOTO_ERROR_PARSING_TIME, MB_ICONEXCLAMATION | MB_OK, 0);
- }
+ UpdateData();
+
+ unsigned int hh = 0;
+ unsigned int mm = 0;
+ float ss = 0.0;
+ wchar_t c1 = L':'; // delimiter character
+ wchar_t c2 = L':'; // delimiter character
+ wchar_t c3[2]; // unnecessary character
+
+ if ((swscanf_s(m_timestr, L"%f%1s", &ss, &c3, _countof(c3)) == 1 || // sss[.ms]
+ swscanf_s(m_timestr, L"%u%c%f%1s", &mm, &c2, sizeof(wchar_t), &ss, &c3, _countof(c3)) == 3 && ss < 60 || // mmm:ss[.ms]
+ swscanf_s(m_timestr, L"%u%c%u%c%f%1s", &hh, &c1, sizeof(wchar_t), &mm, &c2, sizeof(wchar_t), &ss, &c3, _countof(c3)) == 5 && mm < 60 && ss < 60) && // hhh:mm:ss[.ms]
+ c1 == L':' && c2 == L':' && ss >= 0) {
+
+ int time = (int)(1000 * ((hh * 60 + mm) * 60 + ss) + 0.5);
+ m_time = time * 10000i64;
+
+ OnOK();
+ } else {
+ AfxMessageBox(IDS_GOTO_ERROR_PARSING_TIME, MB_ICONEXCLAMATION | MB_OK, 0);
+ }
}
void CGoToDlg::OnBnClickedOk2()
{
- UpdateData();
-
- unsigned int frame;
- float fps;
- wchar_t c1[2]; // delimiter character
- wchar_t c2[2]; // unnecessary character
-
- int result = swscanf_s(m_framestr, L"%u%1s%f%1s", &frame, &c1, _countof(c1), &fps, &c2, _countof(c2));
- if (result == 1) {
- m_time = (REFERENCE_TIME)ceil(10000000.0*frame/m_fps);
- OnOK();
- } else if (result == 3 && c1[0] == L',') {
- m_time = (REFERENCE_TIME)ceil(10000000.0*frame/fps);
- OnOK();
- } else if (result == 0 || c1[0] != L',') {
- AfxMessageBox(IDS_GOTO_ERROR_PARSING_TEXT, MB_ICONEXCLAMATION | MB_OK, 0);
- } else {
- AfxMessageBox(IDS_GOTO_ERROR_PARSING_FPS, MB_ICONEXCLAMATION | MB_OK, 0);
- }
+ UpdateData();
+
+ unsigned int frame;
+ float fps;
+ wchar_t c1[2]; // delimiter character
+ wchar_t c2[2]; // unnecessary character
+
+ int result = swscanf_s(m_framestr, L"%u%1s%f%1s", &frame, &c1, _countof(c1), &fps, &c2, _countof(c2));
+ if (result == 1) {
+ m_time = (REFERENCE_TIME)ceil(10000000.0 * frame / m_fps);
+ OnOK();
+ } else if (result == 3 && c1[0] == L',') {
+ m_time = (REFERENCE_TIME)ceil(10000000.0 * frame / fps);
+ OnOK();
+ } else if (result == 0 || c1[0] != L',') {
+ AfxMessageBox(IDS_GOTO_ERROR_PARSING_TEXT, MB_ICONEXCLAMATION | MB_OK, 0);
+ } else {
+ AfxMessageBox(IDS_GOTO_ERROR_PARSING_FPS, MB_ICONEXCLAMATION | MB_OK, 0);
+ }
}
void CGoToDlg::OnOK()
{
- if (m_time > m_maxTime) {
- AfxMessageBox(IDS_GOTO_ERROR_INVALID_TIME, MB_ICONEXCLAMATION | MB_OK, 0);
- } else {
- __super::OnOK();
- }
+ if (m_time > m_maxTime) {
+ AfxMessageBox(IDS_GOTO_ERROR_INVALID_TIME, MB_ICONEXCLAMATION | MB_OK, 0);
+ } else {
+ __super::OnOK();
+ }
}
BOOL CGoToDlg::PreTranslateMessage(MSG* pMsg)
{
- if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN) {
- if (*GetFocus() == m_timeedit) {
- OnBnClickedOk1();
- } else if (*GetFocus() == m_frameedit) {
- OnBnClickedOk2();
- }
+ if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN) {
+ if (*GetFocus() == m_timeedit) {
+ OnBnClickedOk1();
+ } else if (*GetFocus() == m_frameedit) {
+ OnBnClickedOk2();
+ }
- return TRUE;
- }
+ return TRUE;
+ }
- return __super::PreTranslateMessage(pMsg);
+ return __super::PreTranslateMessage(pMsg);
}
diff --git a/src/mpc-hc/GoToDlg.h b/src/mpc-hc/GoToDlg.h
index bab938cfe..4db515060 100644
--- a/src/mpc-hc/GoToDlg.h
+++ b/src/mpc-hc/GoToDlg.h
@@ -32,33 +32,33 @@
class CGoToDlg : public CDialog
{
- DECLARE_DYNAMIC(CGoToDlg)
+ DECLARE_DYNAMIC(CGoToDlg)
public:
- CGoToDlg(REFERENCE_TIME time = -1, REFERENCE_TIME maxTime = -1, double fps = 0, CWnd* pParent = NULL); // standard constructor
- virtual ~CGoToDlg();
+ CGoToDlg(REFERENCE_TIME time = -1, REFERENCE_TIME maxTime = -1, double fps = 0, CWnd* pParent = NULL); // standard constructor
+ virtual ~CGoToDlg();
- CString m_timestr;
- CString m_framestr;
- CMFCMaskedEdit m_timeedit;
- CEdit m_frameedit;
+ CString m_timestr;
+ CString m_framestr;
+ CMFCMaskedEdit m_timeedit;
+ CEdit m_frameedit;
- REFERENCE_TIME m_time;
- REFERENCE_TIME m_maxTime;
- double m_fps;
+ REFERENCE_TIME m_time;
+ REFERENCE_TIME m_maxTime;
+ double m_fps;
- // Dialog Data
- enum { IDD = IDD_GOTO_DLG };
+ // Dialog Data
+ enum { IDD = IDD_GOTO_DLG };
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnBnClickedOk1();
- afx_msg void OnBnClickedOk2();
- virtual void OnOK();
+ afx_msg void OnBnClickedOk1();
+ afx_msg void OnBnClickedOk2();
+ virtual void OnOK();
};
diff --git a/src/mpc-hc/IGraphBuilder2.h b/src/mpc-hc/IGraphBuilder2.h
index 57ecbbe60..46e1facf8 100644
--- a/src/mpc-hc/IGraphBuilder2.h
+++ b/src/mpc-hc/IGraphBuilder2.h
@@ -25,36 +25,36 @@
typedef struct {
- CString cPresent;
- CString SummaryDesc;
- CString StartTime;
- CString Duration;
- CMapStringToString ExtendedDescriptorsItems;
- CStringList ExtendedDescriptorsTexts;
- CString cFollowing;
+ CString cPresent;
+ CString SummaryDesc;
+ CString StartTime;
+ CString Duration;
+ CMapStringToString ExtendedDescriptorsItems;
+ CStringList ExtendedDescriptorsTexts;
+ CString cFollowing;
} PresentFollowing;
interface __declspec(uuid("165BE9D6-0929-4363-9BA3-580D735AA0F6"))
IGraphBuilder2 :
public IFilterGraph2 {
- STDMETHOD(IsPinDirection) (IPin* pPin, PIN_DIRECTION dir) = 0;
- STDMETHOD(IsPinConnected) (IPin* pPin) = 0;
- STDMETHOD(ConnectFilter) (IBaseFilter* pBF, IPin* pPinIn) = 0;
- STDMETHOD(ConnectFilter) (IPin* pPinOut, IBaseFilter* pBF) = 0;
- STDMETHOD(ConnectFilterDirect) (IPin* pPinOut, IBaseFilter* pBF, const AM_MEDIA_TYPE* pmt) = 0;
- STDMETHOD(NukeDownstream) (IUnknown* pUnk) = 0;
- STDMETHOD(FindInterface) (REFIID iid, void** ppv, BOOL bRemove) = 0;
- STDMETHOD(AddToROT) () = 0;
- STDMETHOD(RemoveFromROT) () = 0;
+ STDMETHOD(IsPinDirection)(IPin * pPin, PIN_DIRECTION dir) = 0;
+ STDMETHOD(IsPinConnected)(IPin * pPin) = 0;
+ STDMETHOD(ConnectFilter)(IBaseFilter * pBF, IPin * pPinIn) = 0;
+ STDMETHOD(ConnectFilter)(IPin * pPinOut, IBaseFilter * pBF) = 0;
+ STDMETHOD(ConnectFilterDirect)(IPin * pPinOut, IBaseFilter * pBF, const AM_MEDIA_TYPE * pmt) = 0;
+ STDMETHOD(NukeDownstream)(IUnknown * pUnk) = 0;
+ STDMETHOD(FindInterface)(REFIID iid, void** ppv, BOOL bRemove) = 0;
+ STDMETHOD(AddToROT)() = 0;
+ STDMETHOD(RemoveFromROT)() = 0;
};
// private use only
interface __declspec(uuid("43CDA93D-6A4E-4A07-BD3E-49D161073EE7"))
IGraphBuilderDeadEnd :
public IUnknown {
- STDMETHOD_(size_t, GetCount)() = 0;
- STDMETHOD(GetDeadEnd) (int iIndex, CAtlList<CStringW>& path, CAtlList<CMediaType>& mts) = 0;
+ STDMETHOD_(size_t, GetCount)() = 0;
+ STDMETHOD(GetDeadEnd)(int iIndex, CAtlList<CStringW>& path, CAtlList<CMediaType>& mts) = 0;
};
@@ -62,10 +62,10 @@ public IUnknown {
interface __declspec(uuid("43CDA93D-6A4E-4A07-BD3E-49D161073EE7"))
IBDATuner :
public IUnknown {
- STDMETHOD(SetChannel) (int nChannelPrefNumber) = 0;
- STDMETHOD(SetAudio) (int nAudioIndex) = 0;
- STDMETHOD(SetFrequency) (ULONG ulFrequency) = 0;
- STDMETHOD(Scan) (ULONG ulFrequency, HWND hWnd) = 0;
- STDMETHOD(GetStats) (BOOLEAN& bPresent, BOOLEAN& bLocked, LONG& lStrength, LONG& lQuality) = 0;
- STDMETHOD(UpdatePSI) (PresentFollowing &NowNext) = 0;
+ STDMETHOD(SetChannel)(int nChannelPrefNumber) = 0;
+ STDMETHOD(SetAudio)(int nAudioIndex) = 0;
+ STDMETHOD(SetFrequency)(ULONG ulFrequency) = 0;
+ STDMETHOD(Scan)(ULONG ulFrequency, HWND hWnd) = 0;
+ STDMETHOD(GetStats)(BOOLEAN & bPresent, BOOLEAN & bLocked, LONG & lStrength, LONG & lQuality) = 0;
+ STDMETHOD(UpdatePSI)(PresentFollowing & NowNext) = 0;
};
diff --git a/src/mpc-hc/ISDb.cpp b/src/mpc-hc/ISDb.cpp
index afd48a7c0..42c7c2cd4 100644
--- a/src/mpc-hc/ISDb.cpp
+++ b/src/mpc-hc/ISDb.cpp
@@ -29,90 +29,90 @@
bool mpc_filehash(LPCTSTR fn, filehash& fh)
{
- CFile f;
- CFileException fe;
- if (!f.Open(fn, CFile::modeRead|CFile::osSequentialScan|CFile::shareDenyNone, &fe)) {
- return false;
- }
-
- CPath p(fn);
- p.StripPath();
- fh.name = (LPCTSTR)p;
-
- fh.size = f.GetLength();
-
- fh.mpc_filehash = fh.size;
- for (UINT64 tmp = 0, i = 0; i < 65536/sizeof(tmp) && f.Read(&tmp, sizeof(tmp)); fh.mpc_filehash += tmp, i++) {
- ;
- }
- f.Seek(max(0, (INT64)fh.size - 65536), CFile::begin);
- for (UINT64 tmp = 0, i = 0; i < 65536/sizeof(tmp) && f.Read(&tmp, sizeof(tmp)); fh.mpc_filehash += tmp, i++) {
- ;
- }
-
- return true;
+ CFile f;
+ CFileException fe;
+ if (!f.Open(fn, CFile::modeRead | CFile::osSequentialScan | CFile::shareDenyNone, &fe)) {
+ return false;
+ }
+
+ CPath p(fn);
+ p.StripPath();
+ fh.name = (LPCTSTR)p;
+
+ fh.size = f.GetLength();
+
+ fh.mpc_filehash = fh.size;
+ for (UINT64 tmp = 0, i = 0; i < 65536 / sizeof(tmp) && f.Read(&tmp, sizeof(tmp)); fh.mpc_filehash += tmp, i++) {
+ ;
+ }
+ f.Seek(max(0, (INT64)fh.size - 65536), CFile::begin);
+ for (UINT64 tmp = 0, i = 0; i < 65536 / sizeof(tmp) && f.Read(&tmp, sizeof(tmp)); fh.mpc_filehash += tmp, i++) {
+ ;
+ }
+
+ return true;
}
void mpc_filehash(CPlaylist& pl, CList<filehash>& fhs)
{
- fhs.RemoveAll();
-
- POSITION pos = pl.GetHeadPosition();
- while (pos) {
- CString fn = pl.GetNext(pos).m_fns.GetHead();
- if (AfxGetAppSettings().m_Formats.FindExt(CPath(fn).GetExtension().MakeLower(), true)) {
- continue;
- }
-
- filehash fh;
- if (!mpc_filehash(fn, fh)) {
- continue;
- }
-
- fhs.AddTail(fh);
- }
+ fhs.RemoveAll();
+
+ POSITION pos = pl.GetHeadPosition();
+ while (pos) {
+ CString fn = pl.GetNext(pos).m_fns.GetHead();
+ if (AfxGetAppSettings().m_Formats.FindExt(CPath(fn).GetExtension().MakeLower(), true)) {
+ continue;
+ }
+
+ filehash fh;
+ if (!mpc_filehash(fn, fh)) {
+ continue;
+ }
+
+ fhs.AddTail(fh);
+ }
}
CStringA makeargs(CPlaylist& pl)
{
- CList<filehash> fhs;
- mpc_filehash(pl, fhs);
+ CList<filehash> fhs;
+ mpc_filehash(pl, fhs);
- CAtlList<CStringA> args;
+ CAtlList<CStringA> args;
- POSITION pos = fhs.GetHeadPosition();
- for (int i = 0; pos; i++) {
- filehash& fh = fhs.GetNext(pos);
+ POSITION pos = fhs.GetHeadPosition();
+ for (int i = 0; pos; i++) {
+ filehash& fh = fhs.GetNext(pos);
- CStringA str;
- str.Format("name[%d]=%s&size[%d]=%016I64x&hash[%d]=%016I64x",
- i, UrlEncode(CStringA(fh.name)),
- i, fh.size,
- i, fh.mpc_filehash);
+ CStringA str;
+ str.Format("name[%d]=%s&size[%d]=%016I64x&hash[%d]=%016I64x",
+ i, UrlEncode(CStringA(fh.name)),
+ i, fh.size,
+ i, fh.mpc_filehash);
- args.AddTail(str);
- }
+ args.AddTail(str);
+ }
- return Implode(args, '&');
+ return Implode(args, '&');
}
bool OpenUrl(CInternetSession& is, CString url, CStringA& str)
{
- str.Empty();
+ str.Empty();
- try {
- CAutoPtr<CStdioFile> f(is.OpenURL(url, 1, INTERNET_FLAG_TRANSFER_BINARY|INTERNET_FLAG_EXISTING_CONNECT));
+ try {
+ CAutoPtr<CStdioFile> f(is.OpenURL(url, 1, INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_EXISTING_CONNECT));
- char buff[1024];
- for (int len; (len = f->Read(buff, sizeof(buff))) > 0; str += CStringA(buff, len)) {
- ;
- }
+ char buff[1024];
+ for (int len; (len = f->Read(buff, sizeof(buff))) > 0; str += CStringA(buff, len)) {
+ ;
+ }
- f->Close(); // must close it because the destructor doesn't seem to do it and we will get an exception when "is" is destroying
- } catch (CInternetException* ie) {
- ie->Delete();
- return false;
- }
+ f->Close(); // must close it because the destructor doesn't seem to do it and we will get an exception when "is" is destroying
+ } catch (CInternetException* ie) {
+ ie->Delete();
+ return false;
+ }
- return true;
+ return true;
}
diff --git a/src/mpc-hc/ISDb.h b/src/mpc-hc/ISDb.h
index 5032fd5db..a1ad2d3a6 100644
--- a/src/mpc-hc/ISDb.h
+++ b/src/mpc-hc/ISDb.h
@@ -32,38 +32,38 @@
struct isdb_subtitle {
- int id, discs, disc_no;
- CStringA name, format, language, iso639_2, nick, email;
- struct isdb_subtitle() {
- reset();
- }
- void reset() {
- id = discs = disc_no = 0;
- format = language = nick = email = "";
- }
+ int id, discs, disc_no;
+ CStringA name, format, language, iso639_2, nick, email;
+ struct isdb_subtitle() {
+ reset();
+ }
+ void reset() {
+ id = discs = disc_no = 0;
+ format = language = nick = email = "";
+ }
};
struct isdb_movie {
- CAtlList<CStringA> titles;
- CAtlList<isdb_subtitle> subs;
- void reset() {
- titles.RemoveAll();
- subs.RemoveAll();
- }
- isdb_movie& operator = (const struct isdb_movie& m) {
- if (this != &m) {
- titles.RemoveAll();
- titles.AddTailList(&m.titles);
- subs.RemoveAll();
- subs.AddTailList(&m.subs);
- }
- return *this;
- }
+ CAtlList<CStringA> titles;
+ CAtlList<isdb_subtitle> subs;
+ void reset() {
+ titles.RemoveAll();
+ subs.RemoveAll();
+ }
+ isdb_movie& operator = (const struct isdb_movie& m) {
+ if (this != &m) {
+ titles.RemoveAll();
+ titles.AddTailList(&m.titles);
+ subs.RemoveAll();
+ subs.AddTailList(&m.subs);
+ }
+ return *this;
+ }
};
struct filehash {
- CString name;
- UINT64 size, mpc_filehash;
+ CString name;
+ UINT64 size, mpc_filehash;
};
extern bool mpc_filehash(LPCTSTR fn, filehash& fh);
diff --git a/src/mpc-hc/Ifo.cpp b/src/mpc-hc/Ifo.cpp
index 62ee7614a..a1c96d5f0 100644
--- a/src/mpc-hc/Ifo.cpp
+++ b/src/mpc-hc/Ifo.cpp
@@ -66,16 +66,16 @@
#define le2me_64(x) (x)
#endif
-#define DVD_VIDEO_LB_LEN 2048
-#define IFO_HDR_LEN 8
-#define LU_SUB_LEN 8
+#define DVD_VIDEO_LB_LEN 2048
+#define IFO_HDR_LEN 8
+#define LU_SUB_LEN 8
-extern HANDLE (__stdcall * Real_CreateFileW)(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
+extern HANDLE(__stdcall* Real_CreateFileW)(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
-unsigned __int32 get4bytes (const BYTE* buf)
+unsigned __int32 get4bytes(const BYTE* buf)
{
- return be2me_32 (*((unsigned __int32 *)buf));
+ return be2me_32(*((unsigned __int32*)buf));
}
@@ -89,175 +89,175 @@ unsigned __int32 get4bytes (const BYTE* buf)
CIfo::CIfo()
{
- m_pBuffer = NULL;
- m_pPGCI = NULL;
- m_pPGCIT = NULL;
- m_dwSize = 0;
+ m_pBuffer = NULL;
+ m_pPGCI = NULL;
+ m_pPGCIT = NULL;
+ m_dwSize = 0;
}
-int CIfo::GetMiscPGCI (CIfo::ifo_hdr_t *hdr, int title, uint8_t **ptr)
+int CIfo::GetMiscPGCI(CIfo::ifo_hdr_t* hdr, int title, uint8_t** ptr)
{
- pgci_sub_t *pgci_sub;
+ pgci_sub_t* pgci_sub;
- *ptr = (uint8_t *) hdr;
- *ptr += IFO_HDR_LEN;
- pgci_sub = (pgci_sub_t *) *ptr + title;
+ *ptr = (uint8_t*) hdr;
+ *ptr += IFO_HDR_LEN;
+ pgci_sub = (pgci_sub_t*) *ptr + title;
- *ptr = (uint8_t *) hdr + be2me_32 (pgci_sub->start);
+ *ptr = (uint8_t*) hdr + be2me_32(pgci_sub->start);
- return 0;
+ return 0;
}
-void CIfo::RemovePgciUOPs (uint8_t *ptr)
+void CIfo::RemovePgciUOPs(uint8_t* ptr)
{
- ifo_hdr_t* hdr = (ifo_hdr_t *) ptr;
- uint16_t num;
- int i;
+ ifo_hdr_t* hdr = (ifo_hdr_t*) ptr;
+ uint16_t num;
+ int i;
- ptr += IFO_HDR_LEN;
- num = be2me_16(hdr->num);
+ ptr += IFO_HDR_LEN;
+ num = be2me_16(hdr->num);
- for (i=1; i<=num; i++) {
- lu_sub_t *lu_sub = (lu_sub_t *) ptr;
- UNREFERENCED_PARAMETER(lu_sub);
+ for (i = 1; i <= num; i++) {
+ lu_sub_t* lu_sub = (lu_sub_t*) ptr;
+ UNREFERENCED_PARAMETER(lu_sub);
- ptr += LU_SUB_LEN;
- }
+ ptr += LU_SUB_LEN;
+ }
- for (i=0; i<be2me_16(hdr->num); i++) {
- uint8_t *ptr;
+ for (i = 0; i < be2me_16(hdr->num); i++) {
+ uint8_t* ptr;
- if (GetMiscPGCI (hdr, i, &ptr) >= 0) {
- pgc_t* pgc = (pgc_t*) ptr;
- pgc->prohibited_ops = 0;
- }
- }
+ if (GetMiscPGCI(hdr, i, &ptr) >= 0) {
+ pgc_t* pgc = (pgc_t*) ptr;
+ pgc->prohibited_ops = 0;
+ }
+ }
}
CIfo::pgc_t* CIfo::GetFirstPGC()
{
- if (m_pBuffer) {
- return (pgc_t*) (m_pBuffer + 0x0400);
- } else {
- return NULL;
- }
+ if (m_pBuffer) {
+ return (pgc_t*)(m_pBuffer + 0x0400);
+ } else {
+ return NULL;
+ }
}
CIfo::pgc_t* CIfo::GetPGCI(const int title, const ifo_hdr_t* hdr)
{
- CIfo::pgci_sub_t *pgci_sub;
- uint8_t *ptr;
+ CIfo::pgci_sub_t* pgci_sub;
+ uint8_t* ptr;
- ptr = (uint8_t *) hdr;
- ptr += IFO_HDR_LEN;
+ ptr = (uint8_t*) hdr;
+ ptr += IFO_HDR_LEN;
- pgci_sub = (pgci_sub_t *) ptr + title;
+ pgci_sub = (pgci_sub_t*) ptr + title;
- ptr = (uint8_t *) hdr + be2me_32 (pgci_sub->start);
+ ptr = (uint8_t*) hdr + be2me_32(pgci_sub->start);
- /* jdw */
- if ( ptr >= ( (uint8_t *) hdr + be2me_32 ( hdr->len ))) {
- return NULL ;
- }
- /* /jdw */
+ /* jdw */
+ if (ptr >= ((uint8_t*) hdr + be2me_32(hdr->len))) {
+ return NULL ;
+ }
+ /* /jdw */
- return (pgc_t *) ptr;
+ return (pgc_t*) ptr;
}
bool CIfo::IsVTS()
{
- if (m_dwSize<12 || (strncmp ((char*)m_pBuffer, "DVDVIDEO-VTS", 12)!=0)) {
- return false;
- }
+ if (m_dwSize < 12 || (strncmp((char*)m_pBuffer, "DVDVIDEO-VTS", 12) != 0)) {
+ return false;
+ }
- return true;
+ return true;
}
bool CIfo::IsVMG()
{
- if (m_dwSize<12 || (strncmp ((char*)m_pBuffer, "DVDVIDEO-VMG", 12)!=0)) {
- return false;
- }
+ if (m_dwSize < 12 || (strncmp((char*)m_pBuffer, "DVDVIDEO-VMG", 12) != 0)) {
+ return false;
+ }
- return true;
+ return true;
}
-bool CIfo::OpenFile (LPCTSTR strFile)
+bool CIfo::OpenFile(LPCTSTR strFile)
{
- bool bRet = false;
- HANDLE hFile;
- LARGE_INTEGER size;
-
- hFile = Real_CreateFileW((LPTSTR) strFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- ASSERT (hFile != INVALID_HANDLE_VALUE);
-
- if (hFile != INVALID_HANDLE_VALUE && GetFileSizeEx(hFile, &size) &&
- size.QuadPart <= 0x800000) { // max size of the ifo file = 8 MB (taken with reserve. need a more correct info)
- m_pBuffer = DNew BYTE [size.QuadPart];
- ReadFile (hFile, m_pBuffer, size.QuadPart, &m_dwSize, NULL);
- CloseHandle (hFile);
-
- if (IsVTS() && (OFF_VTSM_PGCI_UT(m_pBuffer)!=0)) {
- m_pPGCI = (ifo_hdr_t*)(m_pBuffer + OFF_VTSM_PGCI_UT(m_pBuffer) * DVD_VIDEO_LB_LEN);
- m_pPGCIT = (ifo_hdr_t*)(m_pBuffer + OFF_VTS_PGCIT(m_pBuffer) * DVD_VIDEO_LB_LEN);
- } else if (IsVMG() && (OFF_VMGM_PGCI_UT(m_pBuffer)!=0)) {
- m_pPGCI = (ifo_hdr_t*)(m_pBuffer + OFF_VMGM_PGCI_UT(m_pBuffer) * DVD_VIDEO_LB_LEN);
- }
-
- bRet = (m_pPGCI != NULL);
- }
-
- return bRet;
+ bool bRet = false;
+ HANDLE hFile;
+ LARGE_INTEGER size;
+
+ hFile = Real_CreateFileW((LPTSTR) strFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ ASSERT(hFile != INVALID_HANDLE_VALUE);
+
+ if (hFile != INVALID_HANDLE_VALUE && GetFileSizeEx(hFile, &size) &&
+ size.QuadPart <= 0x800000) { // max size of the ifo file = 8 MB (taken with reserve. need a more correct info)
+ m_pBuffer = DNew BYTE [size.QuadPart];
+ ReadFile(hFile, m_pBuffer, size.QuadPart, &m_dwSize, NULL);
+ CloseHandle(hFile);
+
+ if (IsVTS() && (OFF_VTSM_PGCI_UT(m_pBuffer) != 0)) {
+ m_pPGCI = (ifo_hdr_t*)(m_pBuffer + OFF_VTSM_PGCI_UT(m_pBuffer) * DVD_VIDEO_LB_LEN);
+ m_pPGCIT = (ifo_hdr_t*)(m_pBuffer + OFF_VTS_PGCIT(m_pBuffer) * DVD_VIDEO_LB_LEN);
+ } else if (IsVMG() && (OFF_VMGM_PGCI_UT(m_pBuffer) != 0)) {
+ m_pPGCI = (ifo_hdr_t*)(m_pBuffer + OFF_VMGM_PGCI_UT(m_pBuffer) * DVD_VIDEO_LB_LEN);
+ }
+
+ bRet = (m_pPGCI != NULL);
+ }
+
+ return bRet;
}
bool CIfo::RemoveUOPs()
{
- pgc_t* pgc;
-
- if (m_pPGCI) {
- pgc = GetFirstPGC();
- pgc->prohibited_ops = 0;
-
- for (int i=0; i<be2me_16(m_pPGCI->num); i++) {
- pgc = GetPGCI(i, m_pPGCI);
- if (pgc) {
- RemovePgciUOPs ((uint8_t*)pgc);
- }
- }
- }
- if (m_pPGCIT) {
- for (int i=0; i<be2me_16(m_pPGCIT->num); i++) {
- pgc = GetPGCI(i, m_pPGCIT);
- if (pgc) {
- pgc->prohibited_ops = 0;
- }
- }
- }
- return true;
+ pgc_t* pgc;
+
+ if (m_pPGCI) {
+ pgc = GetFirstPGC();
+ pgc->prohibited_ops = 0;
+
+ for (int i = 0; i < be2me_16(m_pPGCI->num); i++) {
+ pgc = GetPGCI(i, m_pPGCI);
+ if (pgc) {
+ RemovePgciUOPs((uint8_t*)pgc);
+ }
+ }
+ }
+ if (m_pPGCIT) {
+ for (int i = 0; i < be2me_16(m_pPGCIT->num); i++) {
+ pgc = GetPGCI(i, m_pPGCIT);
+ if (pgc) {
+ pgc->prohibited_ops = 0;
+ }
+ }
+ }
+ return true;
}
-bool CIfo::SaveFile (LPCTSTR strFile)
+bool CIfo::SaveFile(LPCTSTR strFile)
{
- bool bRet = false;
- HANDLE m_hFile;
-
- if (m_pBuffer) {
- m_hFile = Real_CreateFileW((LPTSTR) strFile, GENERIC_WRITE|GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
- ASSERT (m_hFile != INVALID_HANDLE_VALUE);
-
- if (m_hFile != INVALID_HANDLE_VALUE) {
- DWORD dwSize;
- WriteFile (m_hFile, m_pBuffer, m_dwSize, &dwSize, NULL);
- CloseHandle(m_hFile);
- bRet = true;
- }
- }
-
- return bRet;
+ bool bRet = false;
+ HANDLE m_hFile;
+
+ if (m_pBuffer) {
+ m_hFile = Real_CreateFileW((LPTSTR) strFile, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ ASSERT(m_hFile != INVALID_HANDLE_VALUE);
+
+ if (m_hFile != INVALID_HANDLE_VALUE) {
+ DWORD dwSize;
+ WriteFile(m_hFile, m_pBuffer, m_dwSize, &dwSize, NULL);
+ CloseHandle(m_hFile);
+ bRet = true;
+ }
+ }
+
+ return bRet;
}
CIfo::~CIfo(void)
{
- delete[] m_pBuffer;
+ delete[] m_pBuffer;
}
diff --git a/src/mpc-hc/Ifo.h b/src/mpc-hc/Ifo.h
index a4a536bae..1d099e83b 100644
--- a/src/mpc-hc/Ifo.h
+++ b/src/mpc-hc/Ifo.h
@@ -34,159 +34,159 @@ typedef unsigned __int32 uint32_t;
class CIfo
{
public:
- CIfo();
+ CIfo();
- bool OpenFile (LPCTSTR strFile);
- bool SaveFile (LPCTSTR strFile);
- bool RemoveUOPs();
+ bool OpenFile(LPCTSTR strFile);
+ bool SaveFile(LPCTSTR strFile);
+ bool RemoveUOPs();
- ~CIfo(void);
+ ~CIfo(void);
private :
- typedef struct {
- uint16_t id : 16; // Language
- uint16_t : 16; // don't know
- uint32_t start : 32; // Start of unit
- } pgci_sub_t;
+ typedef struct {
+ uint16_t id : 16; // Language
+ uint16_t : 16; // don't know
+ uint32_t start : 32; // Start of unit
+ } pgci_sub_t;
- typedef struct {
- uint8_t hour;
- uint8_t minute;
- uint8_t second;
- uint8_t frame_u; // The two high bits are the frame rate.
- } dvd_time_t;
+ typedef struct {
+ uint8_t hour;
+ uint8_t minute;
+ uint8_t second;
+ uint8_t frame_u; // The two high bits are the frame rate.
+ } dvd_time_t;
- typedef uint8_t command_data_t[8];
+ typedef uint8_t command_data_t[8];
#define COMMAND_DATA_SIZE 8
- typedef struct { // PGC Command Table
- uint16_t nr_of_pre;
- uint16_t nr_of_post;
- uint16_t nr_of_cell;
- uint16_t tbl_len;
- command_data_t *pre_commands;
- command_data_t *post_commands;
- command_data_t *cell_commands;
- } pgc_command_tbl_t;
+ typedef struct { // PGC Command Table
+ uint16_t nr_of_pre;
+ uint16_t nr_of_post;
+ uint16_t nr_of_cell;
+ uint16_t tbl_len;
+ command_data_t* pre_commands;
+ command_data_t* post_commands;
+ command_data_t* cell_commands;
+ } pgc_command_tbl_t;
#define PGC_COMMAND_TBL_SIZE 8
- typedef uint8_t pgc_program_map_t;
+ typedef uint8_t pgc_program_map_t;
- typedef struct { // Cell Playback Information
- uint8_t chain_info : 8; // 0x5e 0xde(2 angles, no overlay), 0x5f 0x9f 0x9f 0xdf(4 angles overlay), 0x2 0xa 0x8(1 angle)
- uint8_t foo; // parental control ??
- uint8_t still_time;
- uint8_t cell_cmd;
+ typedef struct { // Cell Playback Information
+ uint8_t chain_info : 8; // 0x5e 0xde(2 angles, no overlay), 0x5f 0x9f 0x9f 0xdf(4 angles overlay), 0x2 0xa 0x8(1 angle)
+ uint8_t foo; // parental control ??
+ uint8_t still_time;
+ uint8_t cell_cmd;
- dvd_time_t playback_time;
- uint32_t vobu_start; // 1st vobu start
- uint32_t ilvu_end;
- uint32_t vobu_last_start;
- uint32_t vobu_last_end;
- } ifo_pgci_caddr_t;
+ dvd_time_t playback_time;
+ uint32_t vobu_start; // 1st vobu start
+ uint32_t ilvu_end;
+ uint32_t vobu_last_start;
+ uint32_t vobu_last_end;
+ } ifo_pgci_caddr_t;
- typedef struct { // Cell Position Information
- uint16_t vob_id : 16; // Video Object Identifier
- uint8_t foo : 8; // Unknown
- uint8_t cell_id : 8; // Cell Identifier
- } ifo_pgc_cpos_t;
+ typedef struct { // Cell Position Information
+ uint16_t vob_id : 16; // Video Object Identifier
+ uint8_t foo : 8; // Unknown
+ uint8_t cell_id : 8; // Cell Identifier
+ } ifo_pgc_cpos_t;
#ifndef CLUT_T
#define CLUT_T
- typedef struct { // CLUT == Color LookUp Table
- uint8_t foo : 8; // UNKNOWN: 0x00?
- uint8_t y : 8;
- uint8_t cr : 8;
- uint8_t cb : 8;
- } clut_t;
+ typedef struct { // CLUT == Color LookUp Table
+ uint8_t foo : 8; // UNKNOWN: 0x00?
+ uint8_t y : 8;
+ uint8_t cr : 8;
+ uint8_t cb : 8;
+ } clut_t;
#endif
- typedef struct { // Audio Status
+ typedef struct { // Audio Status
#if BYTE_ORDER == BIG_ENDIAN
- uint8_t available : 1;
- uint8_t link : 7;
+ uint8_t available : 1;
+ uint8_t link : 7;
#else
- uint8_t link : 7;
- uint8_t available : 1;
+ uint8_t link : 7;
+ uint8_t available : 1;
#endif
- uint8_t foo : 8; // UNKNOWN
- } audio_status_t;
+ uint8_t foo : 8; // UNKNOWN
+ } audio_status_t;
- typedef struct { // Subpicture status
+ typedef struct { // Subpicture status
#if BYTE_ORDER == BIG_ENDIAN
- uint8_t available : 1;
- uint8_t format4_3 : 7;
+ uint8_t available : 1;
+ uint8_t format4_3 : 7;
#else
- uint8_t format4_3 : 7;
- uint8_t available : 1;
+ uint8_t format4_3 : 7;
+ uint8_t available : 1;
#endif
- uint8_t wide : 8;
- uint8_t letter : 8;
- uint8_t pan : 8;
- } subp_status_t;
-
-
- typedef struct { // Program Chain Information
- uint16_t zero_1;
- uint8_t nr_of_programs;
- uint8_t nr_of_cells;
- dvd_time_t playback_time;
- uint32_t prohibited_ops; // New type?
- audio_status_t audio_status[8];
- subp_status_t subp_status[32];
- uint16_t next_pgc_nr;
- uint16_t prev_pgc_nr;
- uint16_t goup_pgc_nr;
- uint8_t still_time;
- uint8_t pg_playback_mode;
- clut_t clut[16];
- uint16_t pgc_command_tbl_offset;
- uint16_t pgc_program_map_offset;
- uint16_t cell_playback_tbl_offset;
- uint16_t cell_position_tbl_offset;
- pgc_command_tbl_t *pgc_command_tbl;
- pgc_program_map_t *pgc_program_map;
- ifo_pgci_caddr_t *cell_playback_tbl;
- ifo_pgc_cpos_t *cell_position_tbl;
- } pgc_t;
+ uint8_t wide : 8;
+ uint8_t letter : 8;
+ uint8_t pan : 8;
+ } subp_status_t;
+
+
+ typedef struct { // Program Chain Information
+ uint16_t zero_1;
+ uint8_t nr_of_programs;
+ uint8_t nr_of_cells;
+ dvd_time_t playback_time;
+ uint32_t prohibited_ops; // New type?
+ audio_status_t audio_status[8];
+ subp_status_t subp_status[32];
+ uint16_t next_pgc_nr;
+ uint16_t prev_pgc_nr;
+ uint16_t goup_pgc_nr;
+ uint8_t still_time;
+ uint8_t pg_playback_mode;
+ clut_t clut[16];
+ uint16_t pgc_command_tbl_offset;
+ uint16_t pgc_program_map_offset;
+ uint16_t cell_playback_tbl_offset;
+ uint16_t cell_position_tbl_offset;
+ pgc_command_tbl_t* pgc_command_tbl;
+ pgc_program_map_t* pgc_program_map;
+ ifo_pgci_caddr_t* cell_playback_tbl;
+ ifo_pgc_cpos_t* cell_position_tbl;
+ } pgc_t;
#define PGC_SIZE 236
- typedef struct {
- uint16_t num : 16; // number of entries
- uint16_t : 16; // UNKNOWN
- uint32_t len : 32; // length of table
- } ifo_hdr_t;
+ typedef struct {
+ uint16_t num : 16; // number of entries
+ uint16_t : 16; // UNKNOWN
+ uint32_t len : 32; // length of table
+ } ifo_hdr_t;
- typedef struct {
+ typedef struct {
#if BYTE_ORDER == BIG_ENDIAN
- uint16_t foo1 : 4; // don't know
- uint8_t menu_id : 4; // 0=off, 3=root, 4=spu,
- // 5=audio, 6=angle, 7=ptt
+ uint16_t foo1 : 4; // don't know
+ uint8_t menu_id : 4; // 0=off, 3=root, 4=spu,
+ // 5=audio, 6=angle, 7=ptt
#else
- uint8_t menu_id : 4; // 0=off, 3=root, 4=spu,
- // 5=audio, 6=angle, 7=ptt
- uint16_t foo1 : 4; // don't know
+ uint8_t menu_id : 4; // 0=off, 3=root, 4=spu,
+ // 5=audio, 6=angle, 7=ptt
+ uint16_t foo1 : 4; // don't know
#endif
- uint16_t foo2 : 8; // don't know
- uint16_t bar : 16; // don't know
- uint32_t start : 32; // Start of unit
- } lu_sub_t;
+ uint16_t foo2 : 8; // don't know
+ uint16_t bar : 16; // don't know
+ uint32_t start : 32; // Start of unit
+ } lu_sub_t;
- BYTE* m_pBuffer;
- DWORD m_dwSize;
+ BYTE* m_pBuffer;
+ DWORD m_dwSize;
- ifo_hdr_t* m_pPGCI;
- ifo_hdr_t* m_pPGCIT;
+ ifo_hdr_t* m_pPGCI;
+ ifo_hdr_t* m_pPGCIT;
- bool IsVTS();
- bool IsVMG();
+ bool IsVTS();
+ bool IsVMG();
- pgc_t* GetFirstPGC();
- pgc_t* GetPGCI(const int title, const ifo_hdr_t* hdr);
- int GetMiscPGCI (ifo_hdr_t *hdr, int title, uint8_t **ptr);
- void RemovePgciUOPs (uint8_t *ptr);
+ pgc_t* GetFirstPGC();
+ pgc_t* GetPGCI(const int title, const ifo_hdr_t* hdr);
+ int GetMiscPGCI(ifo_hdr_t* hdr, int title, uint8_t** ptr);
+ void RemovePgciUOPs(uint8_t* ptr);
};
diff --git a/src/mpc-hc/KeyProvider.cpp b/src/mpc-hc/KeyProvider.cpp
index 0998ba095..7ac8537de 100644
--- a/src/mpc-hc/KeyProvider.cpp
+++ b/src/mpc-hc/KeyProvider.cpp
@@ -27,29 +27,29 @@
CKeyProvider::CKeyProvider()
- : CUnknown(NAME("CKeyProvider"), NULL)
+ : CUnknown(NAME("CKeyProvider"), NULL)
{
}
STDMETHODIMP CKeyProvider::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- return
- QI(IServiceProvider)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IServiceProvider)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
-STDMETHODIMP CKeyProvider::QueryService(REFIID siid, REFIID riid, void **ppv)
+STDMETHODIMP CKeyProvider::QueryService(REFIID siid, REFIID riid, void** ppv)
{
- /*
- if (siid == __uuidof(IWMReader) && riid == IID_IUnknown)
- {
- CComPtr<IUnknown> punkCert;
- HRESULT hr = WMCreateCertificate(&punkCert);
- if (SUCCEEDED(hr))
- *ppv = (void*)punkCert.Detach();
- return hr;
- }
- */
+ /*
+ if (siid == __uuidof(IWMReader) && riid == IID_IUnknown)
+ {
+ CComPtr<IUnknown> punkCert;
+ HRESULT hr = WMCreateCertificate(&punkCert);
+ if (SUCCEEDED(hr))
+ *ppv = (void*)punkCert.Detach();
+ return hr;
+ }
+ */
- return E_NOINTERFACE;
+ return E_NOINTERFACE;
}
diff --git a/src/mpc-hc/KeyProvider.h b/src/mpc-hc/KeyProvider.h
index ef26c5b6e..f21774a47 100644
--- a/src/mpc-hc/KeyProvider.h
+++ b/src/mpc-hc/KeyProvider.h
@@ -29,15 +29,15 @@
// Declare and implement a key provider class derived from IServiceProvider.
class CKeyProvider
- : public CUnknown
- , public IServiceProvider
+ : public CUnknown
+ , public IServiceProvider
{
public:
- CKeyProvider();
+ CKeyProvider();
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- // IServiceProvider
- STDMETHODIMP QueryService(REFIID siid, REFIID riid, void **ppv);
+ // IServiceProvider
+ STDMETHODIMP QueryService(REFIID siid, REFIID riid, void** ppv);
};
diff --git a/src/mpc-hc/LcdSupport.cpp b/src/mpc-hc/LcdSupport.cpp
index cbf070303..28bf6a932 100644
--- a/src/mpc-hc/LcdSupport.cpp
+++ b/src/mpc-hc/LcdSupport.cpp
@@ -33,41 +33,41 @@
#define LCD_UPD_TIMER 40
-void LCD_UpdateThread(void * Control)
+void LCD_UpdateThread(void* Control)
{
- CMPC_Lcd * ctrl = static_cast<CMPC_Lcd *> (Control);
- wchar_t str[40];
- __time64_t ltime;
- __time64_t otime = 0;
- struct tm thetime;
- _tsetlocale(LC_ALL, _T("")); // set current system locale
-
- while (ctrl->Thread_Loop) {
- EnterCriticalSection(&ctrl->cs);
- if (_time64(&ltime) != otime) { // Retrieve the time
- otime = ltime;
- _localtime64_s(&thetime, &ltime);
-
- // Format the current time structure into a string
- // using %#x is the long date representation,
- // appropriate to the current locale
- if (wcsftime(str, _countof(str), _T("%#x"), (const struct tm *)&thetime) &&
- (ltime > ctrl->nThread_tTimeout || ltime < otime)) { // message displayed, no update until timeout
- ctrl->m_Manager.m_Text[0].SetText(str);
- }
-
- if (wcsftime(str, _countof(str), _T("%X"), (const struct tm *)&thetime)) {
- ctrl->m_Manager.m_Text[1].SetText(str);
- }
- }
-
- ctrl->m_Output.Update(GetTickCount()); // This invokes OnUpdate for the active screen
- ctrl->m_Output.Draw(); // This invokes OnDraw for the active screen
- LeaveCriticalSection(&ctrl->cs);
- Sleep(LCD_UPD_TIMER);
- }
-
- _endthread();
+ CMPC_Lcd* ctrl = static_cast<CMPC_Lcd*>(Control);
+ wchar_t str[40];
+ __time64_t ltime;
+ __time64_t otime = 0;
+ struct tm thetime;
+ _tsetlocale(LC_ALL, _T("")); // set current system locale
+
+ while (ctrl->Thread_Loop) {
+ EnterCriticalSection(&ctrl->cs);
+ if (_time64(&ltime) != otime) { // Retrieve the time
+ otime = ltime;
+ _localtime64_s(&thetime, &ltime);
+
+ // Format the current time structure into a string
+ // using %#x is the long date representation,
+ // appropriate to the current locale
+ if (wcsftime(str, _countof(str), _T("%#x"), (const struct tm*)&thetime) &&
+ (ltime > ctrl->nThread_tTimeout || ltime < otime)) { // message displayed, no update until timeout
+ ctrl->m_Manager.m_Text[0].SetText(str);
+ }
+
+ if (wcsftime(str, _countof(str), _T("%X"), (const struct tm*)&thetime)) {
+ ctrl->m_Manager.m_Text[1].SetText(str);
+ }
+ }
+
+ ctrl->m_Output.Update(GetTickCount()); // This invokes OnUpdate for the active screen
+ ctrl->m_Output.Draw(); // This invokes OnDraw for the active screen
+ LeaveCriticalSection(&ctrl->cs);
+ Sleep(LCD_UPD_TIMER);
+ }
+
+ _endthread();
}
/******************************************************************************************************
@@ -75,110 +75,110 @@ void LCD_UpdateThread(void * Control)
HRESULT CLCDMyManager::Initialize()
{
- LOGFONT lf;
- HFONT hFont;
- unsigned int x, y;
-
- // max dims: 160 x 43
- x = 10;
- y = 0;
-
- // Initialize the text control (media)
- m_Text1.Initialize();
- m_Text1.SetOrigin(x, y);
- m_Text1.SetSize(160-x, 13);
- m_Text1.SetAlignment(DT_CENTER);
- m_Text1.SetWordWrap(false);
- m_Text1.SetText(_T(""));
- m_Text1.SetStartDelay(5000);
- m_Text1.SetEndDelay(2000);
- m_Text1.EnableRepeat(true);
- m_Text1.SetScrollDirection(CLCDScrollingText::SCROLL_HORZ);
- m_Text1.SetSpeed(24);
-
- // Initialize the progressbar control (media progress)
- y += 15;
- m_ProgBar[1].Initialize();
- m_ProgBar[1].SetOrigin(x+10, y);
- m_ProgBar[1].SetSize(160-x-10, 7);
- m_ProgBar[1].SetPos(0);
- m_ProgBar[1].SetProgressStyle(CLCDProgressBar::STYLE_FILLED_H);
-
- // gfx
- m_PlayState.Initialize();
- m_PlayState.SetOrigin(x, y);
- m_PlayState.SetSize(7, 7);
-
- // Initialize the text control (time / mpc messages)
- y += 7;
- m_Text[0].Initialize();
- m_Text[0].SetOrigin(x, y);
- m_Text[0].SetSize(160-x, /*13*/25);
- m_Text[0].SetAlignment(DT_CENTER);
- m_Text[0].SetWordWrap(false);
- m_Text[0].SetText(_T(""));
- m_Text[0].SetFontPointSize(7);
- hFont = m_Text[0].GetFont();
- GetObject(hFont, sizeof(LOGFONT), &lf);
- wcscpy_s(lf.lfFaceName, LF_FACESIZE, _T("Microsoft Sans Serif"));
- m_Text[0].SetFont(lf);
-
- y += 11;
- m_Text[1].Initialize();
- m_Text[1].SetOrigin(x, y);
- m_Text[1].SetSize(160-x, /*13*/25);
- m_Text[1].SetAlignment(DT_CENTER);
- m_Text[1].SetWordWrap(false);
- m_Text[1].SetText(_T(""));
- m_Text[1].SetFontPointSize(7);
- hFont = m_Text[1].GetFont();
- GetObject(hFont, sizeof(LOGFONT), &lf);
- wcscpy_s(lf.lfFaceName, LF_FACESIZE, _T("Microsoft Sans Serif"));
- m_Text[1].SetFont(lf);
-
- // Initialize the progressbar control (volume)
- m_ProgBar[0].Initialize();
- m_ProgBar[0].SetOrigin(0, 0);
- m_ProgBar[0].SetSize(7, 43);
- m_ProgBar[0].SetPos(0);
- m_ProgBar[0].SetProgressStyle(CLCDProgressBar::STYLE_FILLED_V);
-
- AddObject(&m_Text1);
- AddObject(&m_Text[0]);
- AddObject(&m_Text[1]);
- AddObject(&m_ProgBar[0]);
- AddObject(&m_ProgBar[1]);
- AddObject(&m_PlayState);
-
- return CLCDManager::Initialize();
+ LOGFONT lf;
+ HFONT hFont;
+ unsigned int x, y;
+
+ // max dims: 160 x 43
+ x = 10;
+ y = 0;
+
+ // Initialize the text control (media)
+ m_Text1.Initialize();
+ m_Text1.SetOrigin(x, y);
+ m_Text1.SetSize(160 - x, 13);
+ m_Text1.SetAlignment(DT_CENTER);
+ m_Text1.SetWordWrap(false);
+ m_Text1.SetText(_T(""));
+ m_Text1.SetStartDelay(5000);
+ m_Text1.SetEndDelay(2000);
+ m_Text1.EnableRepeat(true);
+ m_Text1.SetScrollDirection(CLCDScrollingText::SCROLL_HORZ);
+ m_Text1.SetSpeed(24);
+
+ // Initialize the progressbar control (media progress)
+ y += 15;
+ m_ProgBar[1].Initialize();
+ m_ProgBar[1].SetOrigin(x + 10, y);
+ m_ProgBar[1].SetSize(160 - x - 10, 7);
+ m_ProgBar[1].SetPos(0);
+ m_ProgBar[1].SetProgressStyle(CLCDProgressBar::STYLE_FILLED_H);
+
+ // gfx
+ m_PlayState.Initialize();
+ m_PlayState.SetOrigin(x, y);
+ m_PlayState.SetSize(7, 7);
+
+ // Initialize the text control (time / mpc messages)
+ y += 7;
+ m_Text[0].Initialize();
+ m_Text[0].SetOrigin(x, y);
+ m_Text[0].SetSize(160 - x, /*13*/25);
+ m_Text[0].SetAlignment(DT_CENTER);
+ m_Text[0].SetWordWrap(false);
+ m_Text[0].SetText(_T(""));
+ m_Text[0].SetFontPointSize(7);
+ hFont = m_Text[0].GetFont();
+ GetObject(hFont, sizeof(LOGFONT), &lf);
+ wcscpy_s(lf.lfFaceName, LF_FACESIZE, _T("Microsoft Sans Serif"));
+ m_Text[0].SetFont(lf);
+
+ y += 11;
+ m_Text[1].Initialize();
+ m_Text[1].SetOrigin(x, y);
+ m_Text[1].SetSize(160 - x, /*13*/25);
+ m_Text[1].SetAlignment(DT_CENTER);
+ m_Text[1].SetWordWrap(false);
+ m_Text[1].SetText(_T(""));
+ m_Text[1].SetFontPointSize(7);
+ hFont = m_Text[1].GetFont();
+ GetObject(hFont, sizeof(LOGFONT), &lf);
+ wcscpy_s(lf.lfFaceName, LF_FACESIZE, _T("Microsoft Sans Serif"));
+ m_Text[1].SetFont(lf);
+
+ // Initialize the progressbar control (volume)
+ m_ProgBar[0].Initialize();
+ m_ProgBar[0].SetOrigin(0, 0);
+ m_ProgBar[0].SetSize(7, 43);
+ m_ProgBar[0].SetPos(0);
+ m_ProgBar[0].SetProgressStyle(CLCDProgressBar::STYLE_FILLED_V);
+
+ AddObject(&m_Text1);
+ AddObject(&m_Text[0]);
+ AddObject(&m_Text[1]);
+ AddObject(&m_ProgBar[0]);
+ AddObject(&m_ProgBar[1]);
+ AddObject(&m_PlayState);
+
+ return CLCDManager::Initialize();
}
void CLCDMyManager::OnLCDButtonUp(int nButton)
{
- switch (nButton) {
- case LGLCDBUTTON_BUTTON0: {
- /*LOGFONT lf;
- HFONT hFont = m_Text1.GetFont();
-
- GetObject(hFont, sizeof(LOGFONT), &lf);
-
- CFontDialog cfd(&lf);
- if (cfd.DoModal() == IDOK)
- {
- cfd.GetCurrentFont(&lf);
- m_Text1.SetFont(lf);
- }*/
- break;
- }
- case LGLCDBUTTON_BUTTON1:
- break;
- case LGLCDBUTTON_BUTTON2:
- break;
- case LGLCDBUTTON_BUTTON3:
- break;
- default:
- break;
- }
+ switch (nButton) {
+ case LGLCDBUTTON_BUTTON0: {
+ /*LOGFONT lf;
+ HFONT hFont = m_Text1.GetFont();
+
+ GetObject(hFont, sizeof(LOGFONT), &lf);
+
+ CFontDialog cfd(&lf);
+ if (cfd.DoModal() == IDOK)
+ {
+ cfd.GetCurrentFont(&lf);
+ m_Text1.SetFont(lf);
+ }*/
+ break;
+ }
+ case LGLCDBUTTON_BUTTON1:
+ break;
+ case LGLCDBUTTON_BUTTON2:
+ break;
+ case LGLCDBUTTON_BUTTON3:
+ break;
+ default:
+ break;
+ }
}
/******************************************************************************************************
@@ -187,185 +187,185 @@ void CLCDMyManager::OnLCDButtonUp(int nButton)
/* attach to an available lcd */
CMPC_Lcd::CMPC_Lcd(void)
{
- BYTE bPause[] = {0x93, 0xFF,
- 0x93, 0xFF,
- 0x93, 0xFF,
- 0x93, 0xFF,
- 0x93, 0xFF,
- 0x93, 0xFF,
- 0x93, 0xFF
- };
-
- BYTE bStop[] = {0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00,
- 0x00, 0x00
- };
-
- BYTE bPlay[] = {0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
- 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
- 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
- 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
- 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F
- };
-
- hBmp[PS_PLAY] = CreateBitmap(56, 7, 1, 1, bPlay);
- hBmp[PS_PAUSE] = CreateBitmap(14, 7, 1, 1, bPause);
- hBmp[PS_STOP] = CreateBitmap( 8, 7, 1, 1, bStop);
-
- InitializeCriticalSection(&cs);
- hLCD_UpdateThread = NULL;
-
- // lcd init
- ZeroMemory(&m_ConnCtx, sizeof(m_ConnCtx));
-
- m_ConnCtx.appFriendlyName = _T(LCD_APP_NAME);
- m_ConnCtx.isPersistent = FALSE;
- m_ConnCtx.isAutostartable = FALSE;
- m_ConnCtx.onConfigure.configCallback = NULL; // we don't have a configuration screen
- m_ConnCtx.onConfigure.configContext = NULL;
- m_ConnCtx.connection = LGLCD_INVALID_CONNECTION; // the "connection" member will be returned upon return
-
- if (m_Output.Initialize(&m_ConnCtx) != ERROR_SUCCESS || // Initialize the output object
- m_Manager.Initialize() != ERROR_SUCCESS) {
- //_tperror(_T("Initialize"));
- return;
- }
-
- m_Manager.SetExpiration(INFINITE); // Set the expiration on the sample screen
-
- // Add and lock the screen onto our output manager
- m_Output.AddScreen(&m_Manager);
- m_Output.LockScreen(&m_Manager);
-
- m_Output.Update(GetTickCount()); // This invokes OnUpdate for the active screen
- m_Output.Draw(); // This invokes OnDraw for the active screen
-
- if (m_Output.IsOpened()) {
- Thread_Loop = true;
- SetPlayState(PS_STOP);
- hLCD_UpdateThread = (HANDLE) _beginthread(LCD_UpdateThread, 512 /* stack */, (void*) this /* arg */);
- }
+ BYTE bPause[] = {0x93, 0xFF,
+ 0x93, 0xFF,
+ 0x93, 0xFF,
+ 0x93, 0xFF,
+ 0x93, 0xFF,
+ 0x93, 0xFF,
+ 0x93, 0xFF
+ };
+
+ BYTE bStop[] = {0x00, 0x00,
+ 0x00, 0x00,
+ 0x00, 0x00,
+ 0x00, 0x00,
+ 0x00, 0x00,
+ 0x00, 0x00,
+ 0x00, 0x00
+ };
+
+ BYTE bPlay[] = {0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
+ 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+ 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
+ 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F
+ };
+
+ hBmp[PS_PLAY] = CreateBitmap(56, 7, 1, 1, bPlay);
+ hBmp[PS_PAUSE] = CreateBitmap(14, 7, 1, 1, bPause);
+ hBmp[PS_STOP] = CreateBitmap(8, 7, 1, 1, bStop);
+
+ InitializeCriticalSection(&cs);
+ hLCD_UpdateThread = NULL;
+
+ // lcd init
+ ZeroMemory(&m_ConnCtx, sizeof(m_ConnCtx));
+
+ m_ConnCtx.appFriendlyName = _T(LCD_APP_NAME);
+ m_ConnCtx.isPersistent = FALSE;
+ m_ConnCtx.isAutostartable = FALSE;
+ m_ConnCtx.onConfigure.configCallback = NULL; // we don't have a configuration screen
+ m_ConnCtx.onConfigure.configContext = NULL;
+ m_ConnCtx.connection = LGLCD_INVALID_CONNECTION; // the "connection" member will be returned upon return
+
+ if (m_Output.Initialize(&m_ConnCtx) != ERROR_SUCCESS || // Initialize the output object
+ m_Manager.Initialize() != ERROR_SUCCESS) {
+ //_tperror(_T("Initialize"));
+ return;
+ }
+
+ m_Manager.SetExpiration(INFINITE); // Set the expiration on the sample screen
+
+ // Add and lock the screen onto our output manager
+ m_Output.AddScreen(&m_Manager);
+ m_Output.LockScreen(&m_Manager);
+
+ m_Output.Update(GetTickCount()); // This invokes OnUpdate for the active screen
+ m_Output.Draw(); // This invokes OnDraw for the active screen
+
+ if (m_Output.IsOpened()) {
+ Thread_Loop = true;
+ SetPlayState(PS_STOP);
+ hLCD_UpdateThread = (HANDLE) _beginthread(LCD_UpdateThread, 512 /* stack */, (void*) this /* arg */);
+ }
}
/* detach from lcd */
CMPC_Lcd::~CMPC_Lcd(void)
{
- if ( m_Output.IsOpened() ) {
- Thread_Loop = false;
- WaitForSingleObject( hLCD_UpdateThread, LCD_UPD_TIMER * 2 /* timeout */ );
- hLCD_UpdateThread = NULL;
- }
+ if (m_Output.IsOpened()) {
+ Thread_Loop = false;
+ WaitForSingleObject(hLCD_UpdateThread, LCD_UPD_TIMER * 2 /* timeout */);
+ hLCD_UpdateThread = NULL;
+ }
- DeleteCriticalSection( &cs );
+ DeleteCriticalSection(&cs);
- DeleteObject(hBmp[PS_PLAY]);
- DeleteObject(hBmp[PS_PAUSE]);
- DeleteObject(hBmp[PS_STOP]);
+ DeleteObject(hBmp[PS_PLAY]);
+ DeleteObject(hBmp[PS_PAUSE]);
+ DeleteObject(hBmp[PS_STOP]);
- m_Output.Shutdown();
+ m_Output.Shutdown();
}
/* update title name */
-void CMPC_Lcd::SetMediaTitle(const TCHAR * text)
+void CMPC_Lcd::SetMediaTitle(const TCHAR* text)
{
- EnterCriticalSection(&cs);
- m_Manager.m_Text1.SetText(text);
- m_Manager.m_ProgBar[1].SetPos(0);
- LeaveCriticalSection(&cs);
+ EnterCriticalSection(&cs);
+ m_Manager.m_Text1.SetText(text);
+ m_Manager.m_ProgBar[1].SetPos(0);
+ LeaveCriticalSection(&cs);
}
/* set volume min/max */
void CMPC_Lcd::SetVolumeRange(__int64 nStart, __int64 nStop)
{
- EnterCriticalSection(&cs);
- m_Manager.m_ProgBar[0].SetRange(nStart, nStop);
- LeaveCriticalSection(&cs);
+ EnterCriticalSection(&cs);
+ m_Manager.m_ProgBar[0].SetRange(nStart, nStop);
+ LeaveCriticalSection(&cs);
}
/* update volume */
void CMPC_Lcd::SetVolume(__int64 nVol)
{
- EnterCriticalSection(&cs);
- m_Manager.m_ProgBar[0].SetPos(nVol);
- LeaveCriticalSection(&cs);
+ EnterCriticalSection(&cs);
+ m_Manager.m_ProgBar[0].SetPos(nVol);
+ LeaveCriticalSection(&cs);
}
/* set media min/max */
void CMPC_Lcd::SetMediaRange(__int64 nStart, __int64 nStop)
{
- EnterCriticalSection(&cs);
- m_Manager.m_ProgBar[1].SetRange(nStart, nStop);
- LeaveCriticalSection(&cs);
+ EnterCriticalSection(&cs);
+ m_Manager.m_ProgBar[1].SetRange(nStart, nStop);
+ LeaveCriticalSection(&cs);
}
/* update media position */
void CMPC_Lcd::SetMediaPos(__int64 nPos)
{
- EnterCriticalSection(&cs);
- m_Manager.m_ProgBar[1].SetPos(nPos);
- LeaveCriticalSection(&cs);
+ EnterCriticalSection(&cs);
+ m_Manager.m_ProgBar[1].SetPos(nPos);
+ LeaveCriticalSection(&cs);
}
/* update status message (displayed for nTimeOut milliseconds) */
-void CMPC_Lcd::SetStatusMessage(const TCHAR * text, int nTimeOut)
+void CMPC_Lcd::SetStatusMessage(const TCHAR* text, int nTimeOut)
{
- if (!m_Output.IsOpened()) {
- return;
- }
-
- __time64_t ltime;
- _time64(&ltime);
- if ((nTimeOut /= 1000) < 1) {
- nTimeOut = 1;
- }
-
- EnterCriticalSection(&cs);
- nThread_tTimeout = ltime + nTimeOut;
- m_Manager.m_Text[0].SetText(text);
- LeaveCriticalSection(&cs);
+ if (!m_Output.IsOpened()) {
+ return;
+ }
+
+ __time64_t ltime;
+ _time64(&ltime);
+ if ((nTimeOut /= 1000) < 1) {
+ nTimeOut = 1;
+ }
+
+ EnterCriticalSection(&cs);
+ nThread_tTimeout = ltime + nTimeOut;
+ m_Manager.m_Text[0].SetText(text);
+ LeaveCriticalSection(&cs);
}
/* update play state bitmap */
void CMPC_Lcd::SetPlayState(CMPC_Lcd::PlayState ps)
{
- if (!m_Output.IsOpened()) {
- return;
- }
-
- EnterCriticalSection(&cs);
- switch (ps) {
- case PS_PLAY:
- m_Output.SetAsForeground(true);
- m_Manager.m_PlayState.SetBitmap(hBmp[PS_PLAY]);
- m_Manager.m_PlayState.ResetUpdate();
- m_Manager.m_PlayState.SetSubpicWidth(7);
- m_Manager.m_PlayState.SetAnimationRate(300);
- break;
-
- case PS_PAUSE:
- m_Manager.m_PlayState.SetBitmap(hBmp[PS_PAUSE]);
- m_Manager.m_PlayState.ResetUpdate();
- m_Manager.m_PlayState.SetSubpicWidth(7);
- m_Manager.m_PlayState.SetAnimationRate(800);
- break;
-
- case PS_STOP:
- m_Output.SetAsForeground(false);
- m_Manager.m_ProgBar[1].SetPos(0);
- m_Manager.m_PlayState.SetBitmap(hBmp[PS_STOP]);
- m_Manager.m_PlayState.ResetUpdate();
- m_Manager.m_PlayState.SetSubpicWidth(7);
- m_Manager.m_PlayState.SetAnimationRate(5000); // dummy, only one picture
- break;
-
- default:
- break;
- }
- LeaveCriticalSection(&cs);
+ if (!m_Output.IsOpened()) {
+ return;
+ }
+
+ EnterCriticalSection(&cs);
+ switch (ps) {
+ case PS_PLAY:
+ m_Output.SetAsForeground(true);
+ m_Manager.m_PlayState.SetBitmap(hBmp[PS_PLAY]);
+ m_Manager.m_PlayState.ResetUpdate();
+ m_Manager.m_PlayState.SetSubpicWidth(7);
+ m_Manager.m_PlayState.SetAnimationRate(300);
+ break;
+
+ case PS_PAUSE:
+ m_Manager.m_PlayState.SetBitmap(hBmp[PS_PAUSE]);
+ m_Manager.m_PlayState.ResetUpdate();
+ m_Manager.m_PlayState.SetSubpicWidth(7);
+ m_Manager.m_PlayState.SetAnimationRate(800);
+ break;
+
+ case PS_STOP:
+ m_Output.SetAsForeground(false);
+ m_Manager.m_ProgBar[1].SetPos(0);
+ m_Manager.m_PlayState.SetBitmap(hBmp[PS_STOP]);
+ m_Manager.m_PlayState.ResetUpdate();
+ m_Manager.m_PlayState.SetSubpicWidth(7);
+ m_Manager.m_PlayState.SetAnimationRate(5000); // dummy, only one picture
+ break;
+
+ default:
+ break;
+ }
+ LeaveCriticalSection(&cs);
}
diff --git a/src/mpc-hc/LcdSupport.h b/src/mpc-hc/LcdSupport.h
index a8b5a226b..933a07d59 100644
--- a/src/mpc-hc/LcdSupport.h
+++ b/src/mpc-hc/LcdSupport.h
@@ -35,45 +35,45 @@
class CLCDMyManager : public CLCDManager
{
public:
- virtual HRESULT Initialize(void);
- virtual void OnLCDButtonUp(int nButton);
+ virtual HRESULT Initialize(void);
+ virtual void OnLCDButtonUp(int nButton);
- CLCDScrollingText m_Text1;
- CLCDText m_Text[2];
- CLCDProgressBar m_ProgBar[2];
- CLCDAnimatedBitmap m_PlayState;
+ CLCDScrollingText m_Text1;
+ CLCDText m_Text[2];
+ CLCDProgressBar m_ProgBar[2];
+ CLCDAnimatedBitmap m_PlayState;
};
class CMPC_Lcd
{
public:
- enum PlayState {
- PS_PLAY = 0,
- PS_PAUSE = 1,
- PS_STOP = 2,
- PS_UNUSED = 3
- };
+ enum PlayState {
+ PS_PLAY = 0,
+ PS_PAUSE = 1,
+ PS_STOP = 2,
+ PS_UNUSED = 3
+ };
private:
- lgLcdConnectContext m_ConnCtx;
- HANDLE hLCD_UpdateThread;
- HBITMAP hBmp[PS_UNUSED];
+ lgLcdConnectContext m_ConnCtx;
+ HANDLE hLCD_UpdateThread;
+ HBITMAP hBmp[PS_UNUSED];
public:
- CLCDOutput m_Output;
- CLCDMyManager m_Manager;
- bool Thread_Loop;
- __time64_t nThread_tTimeout;
- CRITICAL_SECTION cs;
+ CLCDOutput m_Output;
+ CLCDMyManager m_Manager;
+ bool Thread_Loop;
+ __time64_t nThread_tTimeout;
+ CRITICAL_SECTION cs;
- CMPC_Lcd();
- ~CMPC_Lcd();
+ CMPC_Lcd();
+ ~CMPC_Lcd();
- void SetMediaTitle(const TCHAR * text);
- void SetMediaRange(__int64 nStart, __int64 nStop);
- void SetMediaPos(__int64 nPos);
- void SetVolumeRange(__int64 nStart, __int64 nStop);
- void SetVolume(__int64 nVol);
- void SetStatusMessage(const TCHAR * text, int nTimeOut);
- void SetPlayState(PlayState ps);
+ void SetMediaTitle(const TCHAR* text);
+ void SetMediaRange(__int64 nStart, __int64 nStop);
+ void SetMediaPos(__int64 nPos);
+ void SetVolumeRange(__int64 nStart, __int64 nStop);
+ void SetVolume(__int64 nVol);
+ void SetStatusMessage(const TCHAR* text, int nTimeOut);
+ void SetPlayState(PlayState ps);
};
diff --git a/src/mpc-hc/MPCPngImage.cpp b/src/mpc-hc/MPCPngImage.cpp
index f53832762..1bd2e9dd9 100644
--- a/src/mpc-hc/MPCPngImage.cpp
+++ b/src/mpc-hc/MPCPngImage.cpp
@@ -25,100 +25,90 @@ CMPCPngImage::~CMPCPngImage()
BOOL CMPCPngImage::Load(UINT uiResID, HINSTANCE hinstRes)
{
- return Load(MAKEINTRESOURCE(uiResID), hinstRes);
+ return Load(MAKEINTRESOURCE(uiResID), hinstRes);
}
BOOL CMPCPngImage::Load(LPCTSTR lpszResourceName, HINSTANCE hinstRes)
{
- if (hinstRes == NULL)
- {
- hinstRes = AfxFindResourceHandle(lpszResourceName, _T("PNG"));
- }
-
- HRSRC hRsrc = ::FindResource(hinstRes, lpszResourceName, _T("PNG"));
- if (hRsrc == NULL)
- {
- // Fallback to the instance handle
- hinstRes = AfxGetInstanceHandle();
- hRsrc = ::FindResource(hinstRes, lpszResourceName, _T("PNG"));
- if (hRsrc == NULL)
- {
- return FALSE;
- }
- }
-
- HGLOBAL hGlobal = LoadResource(hinstRes, hRsrc);
- if (hGlobal == NULL)
- {
- return FALSE;
- }
-
- LPVOID lpBuffer = ::LockResource(hGlobal);
- if (lpBuffer == NULL)
- {
- FreeResource(hGlobal);
- return FALSE;
- }
-
- BOOL bRes = LoadFromBuffer((LPBYTE) lpBuffer, (UINT) ::SizeofResource(hinstRes, hRsrc));
-
- UnlockResource(hGlobal);
- FreeResource(hGlobal);
-
- return bRes;
+ if (hinstRes == NULL) {
+ hinstRes = AfxFindResourceHandle(lpszResourceName, _T("PNG"));
+ }
+
+ HRSRC hRsrc = ::FindResource(hinstRes, lpszResourceName, _T("PNG"));
+ if (hRsrc == NULL) {
+ // Fallback to the instance handle
+ hinstRes = AfxGetInstanceHandle();
+ hRsrc = ::FindResource(hinstRes, lpszResourceName, _T("PNG"));
+ if (hRsrc == NULL) {
+ return FALSE;
+ }
+ }
+
+ HGLOBAL hGlobal = LoadResource(hinstRes, hRsrc);
+ if (hGlobal == NULL) {
+ return FALSE;
+ }
+
+ LPVOID lpBuffer = ::LockResource(hGlobal);
+ if (lpBuffer == NULL) {
+ FreeResource(hGlobal);
+ return FALSE;
+ }
+
+ BOOL bRes = LoadFromBuffer((LPBYTE) lpBuffer, (UINT) ::SizeofResource(hinstRes, hRsrc));
+
+ UnlockResource(hGlobal);
+ FreeResource(hGlobal);
+
+ return bRes;
}
//*******************************************************************************
BOOL CMPCPngImage::LoadFromFile(LPCTSTR lpszPath)
{
- BOOL bRes = FALSE;
+ BOOL bRes = FALSE;
- if (m_pImage == NULL)
- {
- m_pImage = new CImage;
- ENSURE(m_pImage != NULL);
- }
+ if (m_pImage == NULL) {
+ m_pImage = new CImage;
+ ENSURE(m_pImage != NULL);
+ }
- if (m_pImage->Load(lpszPath) == S_OK)
- {
- bRes = Attach(m_pImage->Detach());
- }
+ if (m_pImage->Load(lpszPath) == S_OK) {
+ bRes = Attach(m_pImage->Detach());
+ }
- return bRes;
+ return bRes;
}
//*******************************************************************************
BOOL CMPCPngImage::LoadFromBuffer(LPBYTE lpBuffer, UINT uiSize)
{
- ASSERT(lpBuffer != NULL);
+ ASSERT(lpBuffer != NULL);
- HGLOBAL hRes = ::GlobalAlloc(GMEM_MOVEABLE, uiSize);
- if (hRes == NULL)
- {
- return FALSE;
- }
+ HGLOBAL hRes = ::GlobalAlloc(GMEM_MOVEABLE, uiSize);
+ if (hRes == NULL) {
+ return FALSE;
+ }
- IStream* pStream = NULL;
- LPVOID lpResBuffer = ::GlobalLock(hRes);
- ASSERT (lpResBuffer != NULL);
+ IStream* pStream = NULL;
+ LPVOID lpResBuffer = ::GlobalLock(hRes);
+ ASSERT(lpResBuffer != NULL);
- memcpy(lpResBuffer, lpBuffer, uiSize);
+ memcpy(lpResBuffer, lpBuffer, uiSize);
- HRESULT hResult = ::CreateStreamOnHGlobal(hRes, FALSE, &pStream);
+ HRESULT hResult = ::CreateStreamOnHGlobal(hRes, FALSE, &pStream);
- if (hResult != S_OK)
- {
- return FALSE;
- }
+ if (hResult != S_OK) {
+ return FALSE;
+ }
- if (m_pImage == NULL)
- {
- m_pImage = new CImage;
- ENSURE(m_pImage != NULL);
- }
+ if (m_pImage == NULL) {
+ m_pImage = new CImage;
+ ENSURE(m_pImage != NULL);
+ }
- m_pImage->Load(pStream);
- pStream->Release();
+ m_pImage->Load(pStream);
+ pStream->Release();
- BOOL bRes = Attach(m_pImage->Detach());
+ BOOL bRes = Attach(m_pImage->Detach());
- return bRes;
+ return bRes;
}
diff --git a/src/mpc-hc/MPCPngImage.h b/src/mpc-hc/MPCPngImage.h
index be037074a..aedd96d2f 100644
--- a/src/mpc-hc/MPCPngImage.h
+++ b/src/mpc-hc/MPCPngImage.h
@@ -4,29 +4,27 @@
class CMPCPngImage : public CBitmap
{
- // Construction/Destruction
+ // Construction/Destruction
public:
- CMPCPngImage();
- virtual ~CMPCPngImage();
+ CMPCPngImage();
+ virtual ~CMPCPngImage();
- // Attributes:
+ // Attributes:
protected:
- static ATL::CImage* m_pImage;
+ static ATL::CImage* m_pImage;
- // Operations:
+ // Operations:
public:
- BOOL Load (UINT uiResID, HINSTANCE hinstRes = NULL);
- BOOL Load (LPCTSTR lpszResourceName, HINSTANCE hinstRes = NULL);
+ BOOL Load(UINT uiResID, HINSTANCE hinstRes = NULL);
+ BOOL Load(LPCTSTR lpszResourceName, HINSTANCE hinstRes = NULL);
- BOOL LoadFromFile (LPCTSTR lpszPath);
- BOOL LoadFromBuffer (LPBYTE lpBuffer, UINT uiSize);
+ BOOL LoadFromFile(LPCTSTR lpszPath);
+ BOOL LoadFromBuffer(LPBYTE lpBuffer, UINT uiSize);
- static void __stdcall CleanUp ()
- {
- if (m_pImage != NULL)
- {
- delete m_pImage;
- m_pImage = NULL;
- }
- }
+ static void __stdcall CleanUp() {
+ if (m_pImage != NULL) {
+ delete m_pImage;
+ m_pImage = NULL;
+ }
+ }
};
diff --git a/src/mpc-hc/MainFrm.cpp b/src/mpc-hc/MainFrm.cpp
index ffd9d16e0..84b3d25ca 100644
--- a/src/mpc-hc/MainFrm.cpp
+++ b/src/mpc-hc/MainFrm.cpp
@@ -116,29 +116,29 @@ bool b_firstPlay = false;
class CSubClock : public CUnknown, public ISubClock
{
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
- return
- QI(ISubClock)
- CUnknown::NonDelegatingQueryInterface(riid, ppv);
- }
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
+ return
+ QI(ISubClock)
+ CUnknown::NonDelegatingQueryInterface(riid, ppv);
+ }
- REFERENCE_TIME m_rt;
+ REFERENCE_TIME m_rt;
public:
- CSubClock() : CUnknown(NAME("CSubClock"), NULL) {
- m_rt = 0;
- }
-
- DECLARE_IUNKNOWN;
-
- // ISubClock
- STDMETHODIMP SetTime(REFERENCE_TIME rt) {
- m_rt = rt;
- return S_OK;
- }
- STDMETHODIMP_(REFERENCE_TIME) GetTime() {
- return m_rt;
- }
+ CSubClock() : CUnknown(NAME("CSubClock"), NULL) {
+ m_rt = 0;
+ }
+
+ DECLARE_IUNKNOWN;
+
+ // ISubClock
+ STDMETHODIMP SetTime(REFERENCE_TIME rt) {
+ m_rt = rt;
+ return S_OK;
+ }
+ STDMETHODIMP_(REFERENCE_TIME) GetTime() {
+ return m_rt;
+ }
};
//
@@ -172,444 +172,444 @@ public:
IMPLEMENT_DYNAMIC(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
- ON_WM_CREATE()
- ON_WM_DESTROY()
- ON_WM_CLOSE()
-
- ON_REGISTERED_MESSAGE(s_uTaskbarRestart, OnTaskBarRestart)
- ON_REGISTERED_MESSAGE(WM_NOTIFYICON, OnNotifyIcon)
-
- ON_REGISTERED_MESSAGE(s_uTBBC, OnTaskBarThumbnailsCreate)
-
- ON_WM_SETFOCUS()
- ON_WM_GETMINMAXINFO()
- ON_WM_MOVE()
- ON_WM_MOVING()
- ON_WM_SIZE()
- ON_WM_SIZING()
- ON_MESSAGE_VOID(WM_DISPLAYCHANGE, OnDisplayChange)
-
- ON_WM_SYSCOMMAND()
- ON_WM_ACTIVATEAPP()
- ON_MESSAGE(WM_APPCOMMAND, OnAppCommand)
- ON_WM_INPUT()
- ON_MESSAGE(WM_HOTKEY, OnHotKey)
-
- ON_WM_TIMER()
-
- ON_MESSAGE(WM_GRAPHNOTIFY, OnGraphNotify)
- ON_MESSAGE(WM_RESET_DEVICE, OnResetDevice)
- ON_MESSAGE(WM_REARRANGERENDERLESS, OnRepaintRenderLess)
- ON_MESSAGE(WM_RESUMEFROMSTATE, OnResumeFromState)
-
- ON_WM_LBUTTONDOWN()
- ON_WM_LBUTTONUP()
- ON_WM_LBUTTONDBLCLK()
- ON_WM_MBUTTONDOWN()
- ON_WM_MBUTTONUP()
- ON_WM_MBUTTONDBLCLK()
- ON_WM_RBUTTONDOWN()
- ON_WM_RBUTTONUP()
- ON_WM_RBUTTONDBLCLK()
- ON_MESSAGE(WM_XBUTTONDOWN, OnXButtonDown)
- ON_MESSAGE(WM_XBUTTONUP, OnXButtonUp)
- ON_MESSAGE(WM_XBUTTONDBLCLK, OnXButtonDblClk)
- ON_WM_MOUSEWHEEL()
- ON_WM_MOUSEMOVE()
-
- ON_WM_NCHITTEST()
-
- ON_WM_HSCROLL()
-
- ON_WM_INITMENU()
- ON_WM_INITMENUPOPUP()
- ON_WM_UNINITMENUPOPUP()
-
- ON_COMMAND(ID_MENU_PLAYER_SHORT, OnMenuPlayerShort)
- ON_COMMAND(ID_MENU_PLAYER_LONG, OnMenuPlayerLong)
- ON_COMMAND(ID_MENU_FILTERS, OnMenuFilters)
-
- ON_UPDATE_COMMAND_UI(IDC_PLAYERSTATUS, OnUpdatePlayerStatus)
-
- ON_COMMAND(ID_FILE_POST_OPENMEDIA, OnFilePostOpenmedia)
- ON_UPDATE_COMMAND_UI(ID_FILE_POST_OPENMEDIA, OnUpdateFilePostOpenmedia)
- ON_COMMAND(ID_FILE_POST_CLOSEMEDIA, OnFilePostClosemedia)
- ON_UPDATE_COMMAND_UI(ID_FILE_POST_CLOSEMEDIA, OnUpdateFilePostClosemedia)
-
- ON_COMMAND(ID_BOSS, OnBossKey)
-
- ON_COMMAND_RANGE(ID_STREAM_AUDIO_NEXT, ID_STREAM_AUDIO_PREV, OnStreamAudio)
- ON_COMMAND_RANGE(ID_STREAM_SUB_NEXT, ID_STREAM_SUB_PREV, OnStreamSub)
- ON_COMMAND(ID_STREAM_SUB_ONOFF, OnStreamSubOnOff)
- ON_COMMAND_RANGE(ID_OGM_AUDIO_NEXT, ID_OGM_AUDIO_PREV, OnOgmAudio)
- ON_COMMAND_RANGE(ID_OGM_SUB_NEXT, ID_OGM_SUB_PREV, OnOgmSub)
- ON_COMMAND_RANGE(ID_DVD_ANGLE_NEXT, ID_DVD_ANGLE_PREV, OnDvdAngle)
- ON_COMMAND_RANGE(ID_DVD_AUDIO_NEXT, ID_DVD_AUDIO_PREV, OnDvdAudio)
- ON_COMMAND_RANGE(ID_DVD_SUB_NEXT, ID_DVD_SUB_PREV, OnDvdSub)
- ON_COMMAND(ID_DVD_SUB_ONOFF, OnDvdSubOnOff)
-
-
- ON_COMMAND(ID_FILE_OPENQUICK, OnFileOpenQuick)
- ON_UPDATE_COMMAND_UI(ID_FILE_OPENMEDIA, OnUpdateFileOpen)
- ON_COMMAND(ID_FILE_OPENMEDIA, OnFileOpenmedia)
- ON_UPDATE_COMMAND_UI(ID_FILE_OPENMEDIA, OnUpdateFileOpen)
- ON_WM_COPYDATA()
- ON_COMMAND(ID_FILE_OPENDVD, OnFileOpendvd)
- ON_UPDATE_COMMAND_UI(ID_FILE_OPENDVD, OnUpdateFileOpen)
- ON_COMMAND(ID_FILE_OPENDEVICE, OnFileOpendevice)
- ON_UPDATE_COMMAND_UI(ID_FILE_OPENDEVICE, OnUpdateFileOpen)
- ON_COMMAND_RANGE(ID_FILE_OPEN_CD_START, ID_FILE_OPEN_CD_END, OnFileOpenCD)
- ON_UPDATE_COMMAND_UI_RANGE(ID_FILE_OPEN_CD_START, ID_FILE_OPEN_CD_END, OnUpdateFileOpen)
- ON_COMMAND(ID_FILE_REOPEN, OnFileReopen)
- ON_WM_DROPFILES()
- ON_COMMAND(ID_FILE_SAVE_COPY, OnFileSaveAs)
- ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_COPY, OnUpdateFileSaveAs)
- ON_COMMAND(ID_FILE_SAVE_IMAGE, OnFileSaveImage)
- ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_IMAGE, OnUpdateFileSaveImage)
- ON_COMMAND(ID_FILE_SAVE_IMAGE_AUTO, OnFileSaveImageAuto)
- ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_IMAGE_AUTO, OnUpdateFileSaveImage)
- ON_COMMAND(ID_FILE_SAVE_THUMBNAILS, OnFileSaveThumbnails)
- ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_THUMBNAILS, OnUpdateFileSaveThumbnails)
- ON_COMMAND(ID_FILE_LOAD_SUBTITLE, OnFileLoadsubtitle)
- ON_UPDATE_COMMAND_UI(ID_FILE_LOAD_SUBTITLE, OnUpdateFileLoadsubtitle)
- ON_COMMAND(ID_FILE_SAVE_SUBTITLE, OnFileSavesubtitle)
- ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_SUBTITLE, OnUpdateFileSavesubtitle)
- ON_COMMAND(ID_FILE_ISDB_SEARCH, OnFileISDBSearch)
- ON_UPDATE_COMMAND_UI(ID_FILE_ISDB_SEARCH, OnUpdateFileISDBSearch)
- ON_COMMAND(ID_FILE_ISDB_UPLOAD, OnFileISDBUpload)
- ON_UPDATE_COMMAND_UI(ID_FILE_ISDB_UPLOAD, OnUpdateFileISDBUpload)
- ON_COMMAND(ID_FILE_ISDB_DOWNLOAD, OnFileISDBDownload)
- ON_UPDATE_COMMAND_UI(ID_FILE_ISDB_DOWNLOAD, OnUpdateFileISDBDownload)
- ON_COMMAND(ID_FILE_PROPERTIES, OnFileProperties)
- ON_UPDATE_COMMAND_UI(ID_FILE_PROPERTIES, OnUpdateFileProperties)
- ON_COMMAND(ID_FILE_CLOSEPLAYLIST, OnFileClosePlaylist)
- ON_UPDATE_COMMAND_UI(ID_FILE_CLOSEPLAYLIST, OnUpdateFileClose)
- ON_COMMAND(ID_FILE_CLOSEMEDIA, OnFileCloseMedia)
- ON_UPDATE_COMMAND_UI(ID_FILE_CLOSEMEDIA, OnUpdateFileClose)
-
- ON_COMMAND(ID_VIEW_CAPTIONMENU, OnViewCaptionmenu)
- ON_UPDATE_COMMAND_UI(ID_VIEW_CAPTIONMENU, OnUpdateViewCaptionmenu)
- ON_COMMAND_RANGE(ID_VIEW_SEEKER, ID_VIEW_STATUS, OnViewControlBar)
- ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_SEEKER, ID_VIEW_STATUS, OnUpdateViewControlBar)
- ON_COMMAND(ID_VIEW_SUBRESYNC, OnViewSubresync)
- ON_UPDATE_COMMAND_UI(ID_VIEW_SUBRESYNC, OnUpdateViewSubresync)
- ON_COMMAND(ID_VIEW_PLAYLIST, OnViewPlaylist)
- ON_UPDATE_COMMAND_UI(ID_VIEW_PLAYLIST, OnUpdateViewPlaylist)
- ON_COMMAND(ID_VIEW_EDITLISTEDITOR, OnViewEditListEditor)
- ON_COMMAND(ID_EDL_IN, OnEDLIn)
- ON_UPDATE_COMMAND_UI(ID_EDL_IN, OnUpdateEDLIn)
- ON_COMMAND(ID_EDL_OUT, OnEDLOut)
- ON_UPDATE_COMMAND_UI(ID_EDL_OUT, OnUpdateEDLOut)
- ON_COMMAND(ID_EDL_NEWCLIP, OnEDLNewClip)
- ON_UPDATE_COMMAND_UI(ID_EDL_NEWCLIP, OnUpdateEDLNewClip)
- ON_COMMAND(ID_EDL_SAVE, OnEDLSave)
- ON_UPDATE_COMMAND_UI(ID_EDL_SAVE, OnUpdateEDLSave)
- ON_COMMAND(ID_VIEW_CAPTURE, OnViewCapture)
- ON_UPDATE_COMMAND_UI(ID_VIEW_CAPTURE, OnUpdateViewCapture)
- ON_COMMAND(ID_VIEW_SHADEREDITOR, OnViewShaderEditor)
- ON_UPDATE_COMMAND_UI(ID_VIEW_SHADEREDITOR, OnUpdateViewShaderEditor)
- ON_COMMAND(ID_VIEW_PRESETS_MINIMAL, OnViewMinimal)
- ON_UPDATE_COMMAND_UI(ID_VIEW_PRESETS_MINIMAL, OnUpdateViewMinimal)
- ON_COMMAND(ID_VIEW_PRESETS_COMPACT, OnViewCompact)
- ON_UPDATE_COMMAND_UI(ID_VIEW_PRESETS_COMPACT, OnUpdateViewCompact)
- ON_COMMAND(ID_VIEW_PRESETS_NORMAL, OnViewNormal)
- ON_UPDATE_COMMAND_UI(ID_VIEW_PRESETS_NORMAL, OnUpdateViewNormal)
- ON_COMMAND(ID_VIEW_FULLSCREEN, OnViewFullscreen)
- ON_COMMAND(ID_VIEW_FULLSCREEN_SECONDARY, OnViewFullscreenSecondary)
- ON_UPDATE_COMMAND_UI(ID_VIEW_FULLSCREEN, OnUpdateViewFullscreen)
- ON_COMMAND_RANGE(ID_VIEW_ZOOM_50, ID_VIEW_ZOOM_200, OnViewZoom)
- ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_ZOOM_50, ID_VIEW_ZOOM_200, OnUpdateViewZoom)
- ON_COMMAND(ID_VIEW_ZOOM_AUTOFIT, OnViewZoomAutoFit)
- ON_UPDATE_COMMAND_UI(ID_VIEW_ZOOM_AUTOFIT, OnUpdateViewZoom)
- ON_COMMAND(ID_VIEW_ZOOM_AUTOFIT_LARGER, OnViewZoomAutoFitLarger)
- ON_UPDATE_COMMAND_UI(ID_VIEW_ZOOM_AUTOFIT_LARGER, OnUpdateViewZoom)
- ON_COMMAND_RANGE(ID_VIEW_VF_HALF, ID_VIEW_VF_ZOOM2, OnViewDefaultVideoFrame)
- ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_VF_HALF, ID_VIEW_VF_ZOOM2, OnUpdateViewDefaultVideoFrame)
- ON_COMMAND(ID_VIEW_VF_SWITCHZOOM, OnViewSwitchVideoFrame)
- ON_COMMAND(ID_VIEW_VF_KEEPASPECTRATIO, OnViewKeepaspectratio)
- ON_UPDATE_COMMAND_UI(ID_VIEW_VF_KEEPASPECTRATIO, OnUpdateViewKeepaspectratio)
- ON_COMMAND(ID_VIEW_VF_COMPMONDESKARDIFF, OnViewCompMonDeskARDiff)
- ON_UPDATE_COMMAND_UI(ID_VIEW_VF_COMPMONDESKARDIFF, OnUpdateViewCompMonDeskARDiff)
- ON_COMMAND_RANGE(ID_VIEW_RESET, ID_PANSCAN_CENTER, OnViewPanNScan)
- ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_RESET, ID_PANSCAN_CENTER, OnUpdateViewPanNScan)
- ON_COMMAND_RANGE(ID_PANNSCAN_PRESETS_START, ID_PANNSCAN_PRESETS_END, OnViewPanNScanPresets)
- ON_UPDATE_COMMAND_UI_RANGE(ID_PANNSCAN_PRESETS_START, ID_PANNSCAN_PRESETS_END, OnUpdateViewPanNScanPresets)
- ON_COMMAND_RANGE(ID_PANSCAN_ROTATEXP, ID_PANSCAN_ROTATEZM, OnViewRotate)
- ON_UPDATE_COMMAND_UI_RANGE(ID_PANSCAN_ROTATEXP, ID_PANSCAN_ROTATEZM, OnUpdateViewRotate)
- ON_COMMAND_RANGE(ID_ASPECTRATIO_START, ID_ASPECTRATIO_END, OnViewAspectRatio)
- ON_UPDATE_COMMAND_UI_RANGE(ID_ASPECTRATIO_START, ID_ASPECTRATIO_END, OnUpdateViewAspectRatio)
- ON_COMMAND(ID_ASPECTRATIO_NEXT, OnViewAspectRatioNext)
- ON_COMMAND_RANGE(ID_ONTOP_NEVER, ID_ONTOP_WHILEPLAYINGVIDEO, OnViewOntop)
- ON_UPDATE_COMMAND_UI_RANGE(ID_ONTOP_NEVER, ID_ONTOP_WHILEPLAYINGVIDEO, OnUpdateViewOntop)
- ON_COMMAND(ID_VIEW_OPTIONS, OnViewOptions)
-
- // Casimir666
- ON_UPDATE_COMMAND_UI(ID_VIEW_TEARING_TEST, OnUpdateViewTearingTest)
- ON_COMMAND(ID_VIEW_TEARING_TEST, OnViewTearingTest)
- ON_UPDATE_COMMAND_UI(ID_VIEW_DISPLAYSTATS, OnUpdateViewDisplayStats)
- ON_COMMAND(ID_VIEW_RESETSTATS, OnViewResetStats)
- ON_COMMAND(ID_VIEW_DISPLAYSTATS, OnViewDisplayStatsSC)
- ON_UPDATE_COMMAND_UI(ID_VIEW_FULLSCREENGUISUPPORT, OnUpdateViewFullscreenGUISupport)
- ON_UPDATE_COMMAND_UI(ID_VIEW_HIGHCOLORRESOLUTION, OnUpdateViewHighColorResolution)
- ON_UPDATE_COMMAND_UI(ID_VIEW_FORCEINPUTHIGHCOLORRESOLUTION, OnUpdateViewForceInputHighColorResolution)
- ON_UPDATE_COMMAND_UI(ID_VIEW_FULLFLOATINGPOINTPROCESSING, OnUpdateViewFullFloatingPointProcessing)
- ON_UPDATE_COMMAND_UI(ID_VIEW_HALFFLOATINGPOINTPROCESSING, OnUpdateViewHalfFloatingPointProcessing)
- ON_UPDATE_COMMAND_UI(ID_VIEW_ENABLEFRAMETIMECORRECTION, OnUpdateViewEnableFrameTimeCorrection)
- ON_UPDATE_COMMAND_UI(ID_VIEW_VSYNC, OnUpdateViewVSync)
- ON_UPDATE_COMMAND_UI(ID_VIEW_VSYNCOFFSET, OnUpdateViewVSyncOffset)
- ON_UPDATE_COMMAND_UI(ID_VIEW_VSYNCACCURATE, OnUpdateViewVSyncAccurate)
-
- ON_UPDATE_COMMAND_UI(ID_VIEW_SYNCHRONIZEVIDEO, OnUpdateViewSynchronizeVideo)
- ON_UPDATE_COMMAND_UI(ID_VIEW_SYNCHRONIZEDISPLAY, OnUpdateViewSynchronizeDisplay)
- ON_UPDATE_COMMAND_UI(ID_VIEW_SYNCHRONIZENEAREST, OnUpdateViewSynchronizeNearest)
-
- ON_UPDATE_COMMAND_UI(ID_VIEW_CM_ENABLE, OnUpdateViewColorManagementEnable)
- ON_UPDATE_COMMAND_UI(ID_VIEW_CM_INPUT_AUTO, OnUpdateViewColorManagementInput)
- ON_UPDATE_COMMAND_UI(ID_VIEW_CM_INPUT_HDTV, OnUpdateViewColorManagementInput)
- ON_UPDATE_COMMAND_UI(ID_VIEW_CM_INPUT_SDTV_NTSC, OnUpdateViewColorManagementInput)
- ON_UPDATE_COMMAND_UI(ID_VIEW_CM_INPUT_SDTV_PAL, OnUpdateViewColorManagementInput)
- ON_UPDATE_COMMAND_UI(ID_VIEW_CM_AMBIENTLIGHT_BRIGHT, OnUpdateViewColorManagementAmbientLight)
- ON_UPDATE_COMMAND_UI(ID_VIEW_CM_AMBIENTLIGHT_DIM, OnUpdateViewColorManagementAmbientLight)
- ON_UPDATE_COMMAND_UI(ID_VIEW_CM_AMBIENTLIGHT_DARK, OnUpdateViewColorManagementAmbientLight)
- ON_UPDATE_COMMAND_UI(ID_VIEW_CM_INTENT_PERCEPTUAL, OnUpdateViewColorManagementIntent)
- ON_UPDATE_COMMAND_UI(ID_VIEW_CM_INTENT_RELATIVECOLORIMETRIC, OnUpdateViewColorManagementIntent)
- ON_UPDATE_COMMAND_UI(ID_VIEW_CM_INTENT_SATURATION, OnUpdateViewColorManagementIntent)
- ON_UPDATE_COMMAND_UI(ID_VIEW_CM_INTENT_ABSOLUTECOLORIMETRIC, OnUpdateViewColorManagementIntent)
-
- ON_UPDATE_COMMAND_UI(ID_VIEW_EVROUTPUTRANGE_0_255, OnUpdateViewEVROutputRange)
- ON_UPDATE_COMMAND_UI(ID_VIEW_EVROUTPUTRANGE_16_235, OnUpdateViewEVROutputRange)
-
- ON_UPDATE_COMMAND_UI(ID_VIEW_FLUSHGPU_BEFOREVSYNC, OnUpdateViewFlushGPU)
- ON_UPDATE_COMMAND_UI(ID_VIEW_FLUSHGPU_AFTERPRESENT, OnUpdateViewFlushGPU)
- ON_UPDATE_COMMAND_UI(ID_VIEW_FLUSHGPU_WAIT, OnUpdateViewFlushGPU)
-
- ON_UPDATE_COMMAND_UI(ID_VIEW_D3DFULLSCREEN, OnUpdateViewD3DFullscreen)
- ON_UPDATE_COMMAND_UI(ID_VIEW_DISABLEDESKTOPCOMPOSITION, OnUpdateViewDisableDesktopComposition)
- ON_UPDATE_COMMAND_UI(ID_VIEW_ALTERNATIVEVSYNC, OnUpdateViewAlternativeVSync)
-
-
- ON_UPDATE_COMMAND_UI(ID_VIEW_VSYNCOFFSET_INCREASE, OnUpdateViewVSyncOffsetIncrease)
- ON_UPDATE_COMMAND_UI(ID_VIEW_VSYNCOFFSET_DECREASE, OnUpdateViewVSyncOffsetDecrease)
- ON_COMMAND(ID_VIEW_FULLSCREENGUISUPPORT, OnViewFullscreenGUISupport)
- ON_COMMAND(ID_VIEW_HIGHCOLORRESOLUTION, OnViewHighColorResolution)
- ON_COMMAND(ID_VIEW_FORCEINPUTHIGHCOLORRESOLUTION, OnViewForceInputHighColorResolution)
- ON_COMMAND(ID_VIEW_FULLFLOATINGPOINTPROCESSING, OnViewFullFloatingPointProcessing)
- ON_COMMAND(ID_VIEW_HALFFLOATINGPOINTPROCESSING, OnViewHalfFloatingPointProcessing)
- ON_COMMAND(ID_VIEW_ENABLEFRAMETIMECORRECTION, OnViewEnableFrameTimeCorrection)
- ON_COMMAND(ID_VIEW_VSYNC, OnViewVSync)
- ON_COMMAND(ID_VIEW_VSYNCACCURATE, OnViewVSyncAccurate)
-
- ON_COMMAND(ID_VIEW_SYNCHRONIZEVIDEO, OnViewSynchronizeVideo)
- ON_COMMAND(ID_VIEW_SYNCHRONIZEDISPLAY, OnViewSynchronizeDisplay)
- ON_COMMAND(ID_VIEW_SYNCHRONIZENEAREST, OnViewSynchronizeNearest)
-
- ON_COMMAND(ID_VIEW_CM_ENABLE, OnViewColorManagementEnable)
- ON_COMMAND(ID_VIEW_CM_INPUT_AUTO, OnViewColorManagementInputAuto)
- ON_COMMAND(ID_VIEW_CM_INPUT_HDTV, OnViewColorManagementInputHDTV)
- ON_COMMAND(ID_VIEW_CM_INPUT_SDTV_NTSC, OnViewColorManagementInputSDTV_NTSC)
- ON_COMMAND(ID_VIEW_CM_INPUT_SDTV_PAL, OnViewColorManagementInputSDTV_PAL)
- ON_COMMAND(ID_VIEW_CM_AMBIENTLIGHT_BRIGHT, OnViewColorManagementAmbientLightBright)
- ON_COMMAND(ID_VIEW_CM_AMBIENTLIGHT_DIM, OnViewColorManagementAmbientLightDim)
- ON_COMMAND(ID_VIEW_CM_AMBIENTLIGHT_DARK, OnViewColorManagementAmbientLightDark)
- ON_COMMAND(ID_VIEW_CM_INTENT_PERCEPTUAL, OnViewColorManagementIntentPerceptual)
- ON_COMMAND(ID_VIEW_CM_INTENT_RELATIVECOLORIMETRIC, OnViewColorManagementIntentRelativeColorimetric)
- ON_COMMAND(ID_VIEW_CM_INTENT_SATURATION, OnViewColorManagementIntentSaturation)
- ON_COMMAND(ID_VIEW_CM_INTENT_ABSOLUTECOLORIMETRIC, OnViewColorManagementIntentAbsoluteColorimetric)
-
- ON_COMMAND(ID_VIEW_EVROUTPUTRANGE_0_255, OnViewEVROutputRange_0_255)
- ON_COMMAND(ID_VIEW_EVROUTPUTRANGE_16_235, OnViewEVROutputRange_16_235)
-
- ON_COMMAND(ID_VIEW_FLUSHGPU_BEFOREVSYNC, OnViewFlushGPUBeforeVSync)
- ON_COMMAND(ID_VIEW_FLUSHGPU_AFTERPRESENT, OnViewFlushGPUAfterVSync)
- ON_COMMAND(ID_VIEW_FLUSHGPU_WAIT, OnViewFlushGPUWait)
-
- ON_COMMAND(ID_VIEW_D3DFULLSCREEN, OnViewD3DFullScreen)
- ON_COMMAND(ID_VIEW_DISABLEDESKTOPCOMPOSITION, OnViewDisableDesktopComposition)
- ON_COMMAND(ID_VIEW_ALTERNATIVEVSYNC, OnViewAlternativeVSync)
- ON_COMMAND(ID_VIEW_RESET_DEFAULT, OnViewResetDefault)
- ON_COMMAND(ID_VIEW_RESET_OPTIMAL, OnViewResetOptimal)
-
- ON_COMMAND(ID_VIEW_VSYNCOFFSET_INCREASE, OnViewVSyncOffsetIncrease)
- ON_COMMAND(ID_VIEW_VSYNCOFFSET_DECREASE, OnViewVSyncOffsetDecrease)
- ON_UPDATE_COMMAND_UI(ID_SHADERS_TOGGLE, OnUpdateShaderToggle)
- ON_COMMAND(ID_SHADERS_TOGGLE, OnShaderToggle)
- ON_UPDATE_COMMAND_UI(ID_SHADERS_TOGGLE_SCREENSPACE, OnUpdateShaderToggleScreenSpace)
- ON_COMMAND(ID_SHADERS_TOGGLE_SCREENSPACE, OnShaderToggleScreenSpace)
- ON_UPDATE_COMMAND_UI(ID_VIEW_REMAINING_TIME, OnUpdateViewRemainingTime)
- ON_COMMAND(ID_VIEW_REMAINING_TIME, OnViewRemainingTime)
- ON_COMMAND(ID_D3DFULLSCREEN_TOGGLE, OnD3DFullscreenToggle)
- ON_COMMAND_RANGE(ID_GOTO_PREV_SUB, ID_GOTO_NEXT_SUB, OnGotoSubtitle)
- ON_COMMAND_RANGE(ID_SHIFT_SUB_DOWN, ID_SHIFT_SUB_UP, OnShiftSubtitle)
- ON_COMMAND_RANGE(ID_SUB_DELAY_DOWN, ID_SUB_DELAY_UP, OnSubtitleDelay)
- ON_COMMAND_RANGE(ID_LANGUAGE_ENGLISH, ID_LANGUAGE_LAST, OnLanguage)
-
- ON_COMMAND(ID_PLAY_PLAY, OnPlayPlay)
- ON_COMMAND(ID_PLAY_PAUSE, OnPlayPause)
- ON_COMMAND(ID_PLAY_PLAYPAUSE, OnPlayPlaypause)
- ON_COMMAND(ID_PLAY_STOP, OnPlayStop)
- ON_UPDATE_COMMAND_UI(ID_PLAY_PLAY, OnUpdatePlayPauseStop)
- ON_UPDATE_COMMAND_UI(ID_PLAY_PAUSE, OnUpdatePlayPauseStop)
- ON_UPDATE_COMMAND_UI(ID_PLAY_PLAYPAUSE, OnUpdatePlayPauseStop)
- ON_UPDATE_COMMAND_UI(ID_PLAY_STOP, OnUpdatePlayPauseStop)
- ON_COMMAND_RANGE(ID_PLAY_FRAMESTEP, ID_PLAY_FRAMESTEPCANCEL, OnPlayFramestep)
- ON_UPDATE_COMMAND_UI_RANGE(ID_PLAY_FRAMESTEP, ID_PLAY_FRAMESTEPCANCEL, OnUpdatePlayFramestep)
- ON_COMMAND_RANGE(ID_PLAY_SEEKBACKWARDSMALL, ID_PLAY_SEEKFORWARDLARGE, OnPlaySeek)
- ON_COMMAND_RANGE(ID_PLAY_SEEKKEYBACKWARD, ID_PLAY_SEEKKEYFORWARD, OnPlaySeekKey)
- ON_UPDATE_COMMAND_UI_RANGE(ID_PLAY_SEEKBACKWARDSMALL, ID_PLAY_SEEKFORWARDLARGE, OnUpdatePlaySeek)
- ON_UPDATE_COMMAND_UI_RANGE(ID_PLAY_SEEKKEYBACKWARD, ID_PLAY_SEEKKEYFORWARD, OnUpdatePlaySeek)
- ON_COMMAND(ID_PLAY_GOTO, OnPlayGoto)
- ON_UPDATE_COMMAND_UI(ID_PLAY_GOTO, OnUpdateGoto)
- ON_COMMAND_RANGE(ID_PLAY_DECRATE, ID_PLAY_INCRATE, OnPlayChangeRate)
- ON_UPDATE_COMMAND_UI_RANGE(ID_PLAY_DECRATE, ID_PLAY_INCRATE, OnUpdatePlayChangeRate)
- ON_COMMAND(ID_PLAY_RESETRATE, OnPlayResetRate)
- ON_UPDATE_COMMAND_UI(ID_PLAY_RESETRATE, OnUpdatePlayResetRate)
- ON_COMMAND_RANGE(ID_PLAY_INCAUDDELAY, ID_PLAY_DECAUDDELAY, OnPlayChangeAudDelay)
- ON_UPDATE_COMMAND_UI_RANGE(ID_PLAY_INCAUDDELAY, ID_PLAY_DECAUDDELAY, OnUpdatePlayChangeAudDelay)
- ON_COMMAND_RANGE(ID_FILTERS_SUBITEM_START, ID_FILTERS_SUBITEM_END, OnPlayFilters)
- ON_UPDATE_COMMAND_UI_RANGE(ID_FILTERS_SUBITEM_START, ID_FILTERS_SUBITEM_END, OnUpdatePlayFilters)
- ON_COMMAND_RANGE(ID_SHADERS_START, ID_SHADERS_END, OnPlayShaders)
- ON_COMMAND_RANGE(ID_AUDIO_SUBITEM_START, ID_AUDIO_SUBITEM_END, OnPlayAudio)
- ON_UPDATE_COMMAND_UI_RANGE(ID_AUDIO_SUBITEM_START, ID_AUDIO_SUBITEM_END, OnUpdatePlayAudio)
- ON_COMMAND_RANGE(ID_SUBTITLES_SUBITEM_START, ID_SUBTITLES_SUBITEM_END, OnPlaySubtitles)
- ON_UPDATE_COMMAND_UI_RANGE(ID_SUBTITLES_SUBITEM_START, ID_SUBTITLES_SUBITEM_END, OnUpdatePlaySubtitles)
- ON_COMMAND_RANGE(ID_FILTERSTREAMS_SUBITEM_START, ID_FILTERSTREAMS_SUBITEM_END, OnPlayLanguage)
- ON_UPDATE_COMMAND_UI_RANGE(ID_FILTERSTREAMS_SUBITEM_START, ID_FILTERSTREAMS_SUBITEM_END, OnUpdatePlayLanguage)
- ON_COMMAND_RANGE(ID_VOLUME_UP, ID_VOLUME_MUTE, OnPlayVolume)
- ON_COMMAND_RANGE(ID_VOLUME_BOOST_INC, ID_VOLUME_BOOST_MAX, OnPlayVolumeBoost)
- ON_UPDATE_COMMAND_UI_RANGE(ID_VOLUME_BOOST_INC, ID_VOLUME_BOOST_MAX, OnUpdatePlayVolumeBoost)
- ON_COMMAND(ID_CUSTOM_CHANNEL_MAPPING, OnCustomChannelMapping)
- ON_UPDATE_COMMAND_UI(ID_CUSTOM_CHANNEL_MAPPING, OnUpdateCustomChannelMapping)
- ON_COMMAND_RANGE(ID_NORMALIZE, ID_REGAIN_VOLUME, OnNormalizeRegainVolume)
- ON_UPDATE_COMMAND_UI_RANGE(ID_NORMALIZE, ID_REGAIN_VOLUME, OnUpdateNormalizeRegainVolume)
- ON_COMMAND_RANGE(ID_COLOR_BRIGHTNESS_INC, ID_COLOR_RESET, OnPlayColor)
- ON_COMMAND_RANGE(ID_AFTERPLAYBACK_CLOSE, ID_AFTERPLAYBACK_DONOTHING, OnAfterplayback)
- ON_UPDATE_COMMAND_UI_RANGE(ID_AFTERPLAYBACK_CLOSE, ID_AFTERPLAYBACK_DONOTHING, OnUpdateAfterplayback)
- ON_COMMAND_RANGE(ID_AFTERPLAYBACK_EXIT, ID_AFTERPLAYBACK_NEXT, OnAfterplayback)
- ON_UPDATE_COMMAND_UI_RANGE(ID_AFTERPLAYBACK_EXIT, ID_AFTERPLAYBACK_NEXT, OnUpdateAfterplayback)
-
- ON_COMMAND_RANGE(ID_NAVIGATE_SKIPBACK, ID_NAVIGATE_SKIPFORWARD, OnNavigateSkip)
- ON_UPDATE_COMMAND_UI_RANGE(ID_NAVIGATE_SKIPBACK, ID_NAVIGATE_SKIPFORWARD, OnUpdateNavigateSkip)
- ON_COMMAND_RANGE(ID_NAVIGATE_SKIPBACKFILE, ID_NAVIGATE_SKIPFORWARDFILE, OnNavigateSkipFile)
- ON_UPDATE_COMMAND_UI_RANGE(ID_NAVIGATE_SKIPBACKFILE, ID_NAVIGATE_SKIPFORWARDFILE, OnUpdateNavigateSkipFile)
- ON_COMMAND_RANGE(ID_NAVIGATE_TITLEMENU, ID_NAVIGATE_CHAPTERMENU, OnNavigateMenu)
- ON_UPDATE_COMMAND_UI_RANGE(ID_NAVIGATE_TITLEMENU, ID_NAVIGATE_CHAPTERMENU, OnUpdateNavigateMenu)
- ON_COMMAND_RANGE(ID_NAVIGATE_AUDIO_SUBITEM_START, ID_NAVIGATE_AUDIO_SUBITEM_END, OnNavigateAudio)
- ON_COMMAND_RANGE(ID_NAVIGATE_SUBP_SUBITEM_START, ID_NAVIGATE_SUBP_SUBITEM_END, OnNavigateSubpic)
- ON_COMMAND_RANGE(ID_NAVIGATE_ANGLE_SUBITEM_START, ID_NAVIGATE_ANGLE_SUBITEM_END, OnNavigateAngle)
- ON_COMMAND_RANGE(ID_NAVIGATE_CHAP_SUBITEM_START, ID_NAVIGATE_CHAP_SUBITEM_END, OnNavigateChapters)
- ON_COMMAND_RANGE(ID_NAVIGATE_MENU_LEFT, ID_NAVIGATE_MENU_LEAVE, OnNavigateMenuItem)
- ON_UPDATE_COMMAND_UI_RANGE(ID_NAVIGATE_MENU_LEFT, ID_NAVIGATE_MENU_LEAVE, OnUpdateNavigateMenuItem)
- ON_COMMAND(ID_NAVIGATE_TUNERSCAN, OnTunerScan)
- ON_UPDATE_COMMAND_UI(ID_NAVIGATE_TUNERSCAN, OnUpdateTunerScan)
-
- ON_COMMAND(ID_FAVORITES_ADD, OnFavoritesAdd)
- ON_UPDATE_COMMAND_UI(ID_FAVORITES_ADD, OnUpdateFavoritesAdd)
- ON_COMMAND(ID_FAVORITES_QUICKADDFAVORITE, OnFavoritesQuickAddFavorite)
- ON_COMMAND(ID_FAVORITES_ORGANIZE, OnFavoritesOrganize)
- ON_UPDATE_COMMAND_UI(ID_FAVORITES_ORGANIZE, OnUpdateFavoritesOrganize)
- ON_COMMAND_RANGE(ID_FAVORITES_FILE_START, ID_FAVORITES_FILE_END, OnFavoritesFile)
- ON_UPDATE_COMMAND_UI_RANGE(ID_FAVORITES_FILE_START, ID_FAVORITES_FILE_END, OnUpdateFavoritesFile)
- ON_COMMAND_RANGE(ID_FAVORITES_DVD_START, ID_FAVORITES_DVD_END, OnFavoritesDVD)
- ON_UPDATE_COMMAND_UI_RANGE(ID_FAVORITES_DVD_START, ID_FAVORITES_DVD_END, OnUpdateFavoritesDVD)
- ON_COMMAND_RANGE(ID_FAVORITES_DEVICE_START, ID_FAVORITES_DEVICE_END, OnFavoritesDevice)
- ON_UPDATE_COMMAND_UI_RANGE(ID_FAVORITES_DEVICE_START, ID_FAVORITES_DEVICE_END, OnUpdateFavoritesDevice)
-
- ON_COMMAND(ID_RECENT_FILES_CLEAR, OnRecentFileClear)
- ON_UPDATE_COMMAND_UI(ID_RECENT_FILES_CLEAR, OnUpdateRecentFileClear)
- ON_COMMAND_RANGE(ID_RECENT_FILE_START, ID_RECENT_FILE_END, OnRecentFile)
- ON_UPDATE_COMMAND_UI_RANGE(ID_RECENT_FILE_START, ID_RECENT_FILE_END, OnUpdateRecentFile)
-
- ON_COMMAND(ID_HELP_HOMEPAGE, OnHelpHomepage)
- ON_COMMAND(ID_HELP_CHECKFORUPDATE, OnHelpCheckForUpdate)
- //ON_COMMAND(ID_HELP_DOCUMENTATION, OnHelpDocumentation)
- ON_COMMAND(ID_HELP_TOOLBARIMAGES, OnHelpToolbarImages)
- ON_COMMAND(ID_HELP_DONATE, OnHelpDonate)
-
- // Open Dir incl. SubDir
- ON_COMMAND(ID_FILE_OPENDIRECTORY, OnFileOpendirectory)
- ON_UPDATE_COMMAND_UI(ID_FILE_OPENDIRECTORY, OnUpdateFileOpen)
- ON_WM_POWERBROADCAST()
-
- // Navigation panel
- ON_COMMAND(ID_VIEW_NAVIGATION, OnViewNavigation)
- ON_UPDATE_COMMAND_UI(ID_VIEW_NAVIGATION, OnUpdateViewNavigation)
-
- ON_WM_WTSSESSION_CHANGE()
+ ON_WM_CREATE()
+ ON_WM_DESTROY()
+ ON_WM_CLOSE()
+
+ ON_REGISTERED_MESSAGE(s_uTaskbarRestart, OnTaskBarRestart)
+ ON_REGISTERED_MESSAGE(WM_NOTIFYICON, OnNotifyIcon)
+
+ ON_REGISTERED_MESSAGE(s_uTBBC, OnTaskBarThumbnailsCreate)
+
+ ON_WM_SETFOCUS()
+ ON_WM_GETMINMAXINFO()
+ ON_WM_MOVE()
+ ON_WM_MOVING()
+ ON_WM_SIZE()
+ ON_WM_SIZING()
+ ON_MESSAGE_VOID(WM_DISPLAYCHANGE, OnDisplayChange)
+
+ ON_WM_SYSCOMMAND()
+ ON_WM_ACTIVATEAPP()
+ ON_MESSAGE(WM_APPCOMMAND, OnAppCommand)
+ ON_WM_INPUT()
+ ON_MESSAGE(WM_HOTKEY, OnHotKey)
+
+ ON_WM_TIMER()
+
+ ON_MESSAGE(WM_GRAPHNOTIFY, OnGraphNotify)
+ ON_MESSAGE(WM_RESET_DEVICE, OnResetDevice)
+ ON_MESSAGE(WM_REARRANGERENDERLESS, OnRepaintRenderLess)
+ ON_MESSAGE(WM_RESUMEFROMSTATE, OnResumeFromState)
+
+ ON_WM_LBUTTONDOWN()
+ ON_WM_LBUTTONUP()
+ ON_WM_LBUTTONDBLCLK()
+ ON_WM_MBUTTONDOWN()
+ ON_WM_MBUTTONUP()
+ ON_WM_MBUTTONDBLCLK()
+ ON_WM_RBUTTONDOWN()
+ ON_WM_RBUTTONUP()
+ ON_WM_RBUTTONDBLCLK()
+ ON_MESSAGE(WM_XBUTTONDOWN, OnXButtonDown)
+ ON_MESSAGE(WM_XBUTTONUP, OnXButtonUp)
+ ON_MESSAGE(WM_XBUTTONDBLCLK, OnXButtonDblClk)
+ ON_WM_MOUSEWHEEL()
+ ON_WM_MOUSEMOVE()
+
+ ON_WM_NCHITTEST()
+
+ ON_WM_HSCROLL()
+
+ ON_WM_INITMENU()
+ ON_WM_INITMENUPOPUP()
+ ON_WM_UNINITMENUPOPUP()
+
+ ON_COMMAND(ID_MENU_PLAYER_SHORT, OnMenuPlayerShort)
+ ON_COMMAND(ID_MENU_PLAYER_LONG, OnMenuPlayerLong)
+ ON_COMMAND(ID_MENU_FILTERS, OnMenuFilters)
+
+ ON_UPDATE_COMMAND_UI(IDC_PLAYERSTATUS, OnUpdatePlayerStatus)
+
+ ON_COMMAND(ID_FILE_POST_OPENMEDIA, OnFilePostOpenmedia)
+ ON_UPDATE_COMMAND_UI(ID_FILE_POST_OPENMEDIA, OnUpdateFilePostOpenmedia)
+ ON_COMMAND(ID_FILE_POST_CLOSEMEDIA, OnFilePostClosemedia)
+ ON_UPDATE_COMMAND_UI(ID_FILE_POST_CLOSEMEDIA, OnUpdateFilePostClosemedia)
+
+ ON_COMMAND(ID_BOSS, OnBossKey)
+
+ ON_COMMAND_RANGE(ID_STREAM_AUDIO_NEXT, ID_STREAM_AUDIO_PREV, OnStreamAudio)
+ ON_COMMAND_RANGE(ID_STREAM_SUB_NEXT, ID_STREAM_SUB_PREV, OnStreamSub)
+ ON_COMMAND(ID_STREAM_SUB_ONOFF, OnStreamSubOnOff)
+ ON_COMMAND_RANGE(ID_OGM_AUDIO_NEXT, ID_OGM_AUDIO_PREV, OnOgmAudio)
+ ON_COMMAND_RANGE(ID_OGM_SUB_NEXT, ID_OGM_SUB_PREV, OnOgmSub)
+ ON_COMMAND_RANGE(ID_DVD_ANGLE_NEXT, ID_DVD_ANGLE_PREV, OnDvdAngle)
+ ON_COMMAND_RANGE(ID_DVD_AUDIO_NEXT, ID_DVD_AUDIO_PREV, OnDvdAudio)
+ ON_COMMAND_RANGE(ID_DVD_SUB_NEXT, ID_DVD_SUB_PREV, OnDvdSub)
+ ON_COMMAND(ID_DVD_SUB_ONOFF, OnDvdSubOnOff)
+
+
+ ON_COMMAND(ID_FILE_OPENQUICK, OnFileOpenQuick)
+ ON_UPDATE_COMMAND_UI(ID_FILE_OPENMEDIA, OnUpdateFileOpen)
+ ON_COMMAND(ID_FILE_OPENMEDIA, OnFileOpenmedia)
+ ON_UPDATE_COMMAND_UI(ID_FILE_OPENMEDIA, OnUpdateFileOpen)
+ ON_WM_COPYDATA()
+ ON_COMMAND(ID_FILE_OPENDVD, OnFileOpendvd)
+ ON_UPDATE_COMMAND_UI(ID_FILE_OPENDVD, OnUpdateFileOpen)
+ ON_COMMAND(ID_FILE_OPENDEVICE, OnFileOpendevice)
+ ON_UPDATE_COMMAND_UI(ID_FILE_OPENDEVICE, OnUpdateFileOpen)
+ ON_COMMAND_RANGE(ID_FILE_OPEN_CD_START, ID_FILE_OPEN_CD_END, OnFileOpenCD)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_FILE_OPEN_CD_START, ID_FILE_OPEN_CD_END, OnUpdateFileOpen)
+ ON_COMMAND(ID_FILE_REOPEN, OnFileReopen)
+ ON_WM_DROPFILES()
+ ON_COMMAND(ID_FILE_SAVE_COPY, OnFileSaveAs)
+ ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_COPY, OnUpdateFileSaveAs)
+ ON_COMMAND(ID_FILE_SAVE_IMAGE, OnFileSaveImage)
+ ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_IMAGE, OnUpdateFileSaveImage)
+ ON_COMMAND(ID_FILE_SAVE_IMAGE_AUTO, OnFileSaveImageAuto)
+ ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_IMAGE_AUTO, OnUpdateFileSaveImage)
+ ON_COMMAND(ID_FILE_SAVE_THUMBNAILS, OnFileSaveThumbnails)
+ ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_THUMBNAILS, OnUpdateFileSaveThumbnails)
+ ON_COMMAND(ID_FILE_LOAD_SUBTITLE, OnFileLoadsubtitle)
+ ON_UPDATE_COMMAND_UI(ID_FILE_LOAD_SUBTITLE, OnUpdateFileLoadsubtitle)
+ ON_COMMAND(ID_FILE_SAVE_SUBTITLE, OnFileSavesubtitle)
+ ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_SUBTITLE, OnUpdateFileSavesubtitle)
+ ON_COMMAND(ID_FILE_ISDB_SEARCH, OnFileISDBSearch)
+ ON_UPDATE_COMMAND_UI(ID_FILE_ISDB_SEARCH, OnUpdateFileISDBSearch)
+ ON_COMMAND(ID_FILE_ISDB_UPLOAD, OnFileISDBUpload)
+ ON_UPDATE_COMMAND_UI(ID_FILE_ISDB_UPLOAD, OnUpdateFileISDBUpload)
+ ON_COMMAND(ID_FILE_ISDB_DOWNLOAD, OnFileISDBDownload)
+ ON_UPDATE_COMMAND_UI(ID_FILE_ISDB_DOWNLOAD, OnUpdateFileISDBDownload)
+ ON_COMMAND(ID_FILE_PROPERTIES, OnFileProperties)
+ ON_UPDATE_COMMAND_UI(ID_FILE_PROPERTIES, OnUpdateFileProperties)
+ ON_COMMAND(ID_FILE_CLOSEPLAYLIST, OnFileClosePlaylist)
+ ON_UPDATE_COMMAND_UI(ID_FILE_CLOSEPLAYLIST, OnUpdateFileClose)
+ ON_COMMAND(ID_FILE_CLOSEMEDIA, OnFileCloseMedia)
+ ON_UPDATE_COMMAND_UI(ID_FILE_CLOSEMEDIA, OnUpdateFileClose)
+
+ ON_COMMAND(ID_VIEW_CAPTIONMENU, OnViewCaptionmenu)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_CAPTIONMENU, OnUpdateViewCaptionmenu)
+ ON_COMMAND_RANGE(ID_VIEW_SEEKER, ID_VIEW_STATUS, OnViewControlBar)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_SEEKER, ID_VIEW_STATUS, OnUpdateViewControlBar)
+ ON_COMMAND(ID_VIEW_SUBRESYNC, OnViewSubresync)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_SUBRESYNC, OnUpdateViewSubresync)
+ ON_COMMAND(ID_VIEW_PLAYLIST, OnViewPlaylist)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_PLAYLIST, OnUpdateViewPlaylist)
+ ON_COMMAND(ID_VIEW_EDITLISTEDITOR, OnViewEditListEditor)
+ ON_COMMAND(ID_EDL_IN, OnEDLIn)
+ ON_UPDATE_COMMAND_UI(ID_EDL_IN, OnUpdateEDLIn)
+ ON_COMMAND(ID_EDL_OUT, OnEDLOut)
+ ON_UPDATE_COMMAND_UI(ID_EDL_OUT, OnUpdateEDLOut)
+ ON_COMMAND(ID_EDL_NEWCLIP, OnEDLNewClip)
+ ON_UPDATE_COMMAND_UI(ID_EDL_NEWCLIP, OnUpdateEDLNewClip)
+ ON_COMMAND(ID_EDL_SAVE, OnEDLSave)
+ ON_UPDATE_COMMAND_UI(ID_EDL_SAVE, OnUpdateEDLSave)
+ ON_COMMAND(ID_VIEW_CAPTURE, OnViewCapture)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_CAPTURE, OnUpdateViewCapture)
+ ON_COMMAND(ID_VIEW_SHADEREDITOR, OnViewShaderEditor)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_SHADEREDITOR, OnUpdateViewShaderEditor)
+ ON_COMMAND(ID_VIEW_PRESETS_MINIMAL, OnViewMinimal)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_PRESETS_MINIMAL, OnUpdateViewMinimal)
+ ON_COMMAND(ID_VIEW_PRESETS_COMPACT, OnViewCompact)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_PRESETS_COMPACT, OnUpdateViewCompact)
+ ON_COMMAND(ID_VIEW_PRESETS_NORMAL, OnViewNormal)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_PRESETS_NORMAL, OnUpdateViewNormal)
+ ON_COMMAND(ID_VIEW_FULLSCREEN, OnViewFullscreen)
+ ON_COMMAND(ID_VIEW_FULLSCREEN_SECONDARY, OnViewFullscreenSecondary)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_FULLSCREEN, OnUpdateViewFullscreen)
+ ON_COMMAND_RANGE(ID_VIEW_ZOOM_50, ID_VIEW_ZOOM_200, OnViewZoom)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_ZOOM_50, ID_VIEW_ZOOM_200, OnUpdateViewZoom)
+ ON_COMMAND(ID_VIEW_ZOOM_AUTOFIT, OnViewZoomAutoFit)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_ZOOM_AUTOFIT, OnUpdateViewZoom)
+ ON_COMMAND(ID_VIEW_ZOOM_AUTOFIT_LARGER, OnViewZoomAutoFitLarger)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_ZOOM_AUTOFIT_LARGER, OnUpdateViewZoom)
+ ON_COMMAND_RANGE(ID_VIEW_VF_HALF, ID_VIEW_VF_ZOOM2, OnViewDefaultVideoFrame)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_VF_HALF, ID_VIEW_VF_ZOOM2, OnUpdateViewDefaultVideoFrame)
+ ON_COMMAND(ID_VIEW_VF_SWITCHZOOM, OnViewSwitchVideoFrame)
+ ON_COMMAND(ID_VIEW_VF_KEEPASPECTRATIO, OnViewKeepaspectratio)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_VF_KEEPASPECTRATIO, OnUpdateViewKeepaspectratio)
+ ON_COMMAND(ID_VIEW_VF_COMPMONDESKARDIFF, OnViewCompMonDeskARDiff)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_VF_COMPMONDESKARDIFF, OnUpdateViewCompMonDeskARDiff)
+ ON_COMMAND_RANGE(ID_VIEW_RESET, ID_PANSCAN_CENTER, OnViewPanNScan)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_RESET, ID_PANSCAN_CENTER, OnUpdateViewPanNScan)
+ ON_COMMAND_RANGE(ID_PANNSCAN_PRESETS_START, ID_PANNSCAN_PRESETS_END, OnViewPanNScanPresets)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_PANNSCAN_PRESETS_START, ID_PANNSCAN_PRESETS_END, OnUpdateViewPanNScanPresets)
+ ON_COMMAND_RANGE(ID_PANSCAN_ROTATEXP, ID_PANSCAN_ROTATEZM, OnViewRotate)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_PANSCAN_ROTATEXP, ID_PANSCAN_ROTATEZM, OnUpdateViewRotate)
+ ON_COMMAND_RANGE(ID_ASPECTRATIO_START, ID_ASPECTRATIO_END, OnViewAspectRatio)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_ASPECTRATIO_START, ID_ASPECTRATIO_END, OnUpdateViewAspectRatio)
+ ON_COMMAND(ID_ASPECTRATIO_NEXT, OnViewAspectRatioNext)
+ ON_COMMAND_RANGE(ID_ONTOP_NEVER, ID_ONTOP_WHILEPLAYINGVIDEO, OnViewOntop)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_ONTOP_NEVER, ID_ONTOP_WHILEPLAYINGVIDEO, OnUpdateViewOntop)
+ ON_COMMAND(ID_VIEW_OPTIONS, OnViewOptions)
+
+ // Casimir666
+ ON_UPDATE_COMMAND_UI(ID_VIEW_TEARING_TEST, OnUpdateViewTearingTest)
+ ON_COMMAND(ID_VIEW_TEARING_TEST, OnViewTearingTest)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_DISPLAYSTATS, OnUpdateViewDisplayStats)
+ ON_COMMAND(ID_VIEW_RESETSTATS, OnViewResetStats)
+ ON_COMMAND(ID_VIEW_DISPLAYSTATS, OnViewDisplayStatsSC)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_FULLSCREENGUISUPPORT, OnUpdateViewFullscreenGUISupport)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_HIGHCOLORRESOLUTION, OnUpdateViewHighColorResolution)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_FORCEINPUTHIGHCOLORRESOLUTION, OnUpdateViewForceInputHighColorResolution)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_FULLFLOATINGPOINTPROCESSING, OnUpdateViewFullFloatingPointProcessing)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_HALFFLOATINGPOINTPROCESSING, OnUpdateViewHalfFloatingPointProcessing)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_ENABLEFRAMETIMECORRECTION, OnUpdateViewEnableFrameTimeCorrection)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_VSYNC, OnUpdateViewVSync)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_VSYNCOFFSET, OnUpdateViewVSyncOffset)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_VSYNCACCURATE, OnUpdateViewVSyncAccurate)
+
+ ON_UPDATE_COMMAND_UI(ID_VIEW_SYNCHRONIZEVIDEO, OnUpdateViewSynchronizeVideo)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_SYNCHRONIZEDISPLAY, OnUpdateViewSynchronizeDisplay)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_SYNCHRONIZENEAREST, OnUpdateViewSynchronizeNearest)
+
+ ON_UPDATE_COMMAND_UI(ID_VIEW_CM_ENABLE, OnUpdateViewColorManagementEnable)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_CM_INPUT_AUTO, OnUpdateViewColorManagementInput)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_CM_INPUT_HDTV, OnUpdateViewColorManagementInput)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_CM_INPUT_SDTV_NTSC, OnUpdateViewColorManagementInput)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_CM_INPUT_SDTV_PAL, OnUpdateViewColorManagementInput)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_CM_AMBIENTLIGHT_BRIGHT, OnUpdateViewColorManagementAmbientLight)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_CM_AMBIENTLIGHT_DIM, OnUpdateViewColorManagementAmbientLight)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_CM_AMBIENTLIGHT_DARK, OnUpdateViewColorManagementAmbientLight)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_CM_INTENT_PERCEPTUAL, OnUpdateViewColorManagementIntent)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_CM_INTENT_RELATIVECOLORIMETRIC, OnUpdateViewColorManagementIntent)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_CM_INTENT_SATURATION, OnUpdateViewColorManagementIntent)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_CM_INTENT_ABSOLUTECOLORIMETRIC, OnUpdateViewColorManagementIntent)
+
+ ON_UPDATE_COMMAND_UI(ID_VIEW_EVROUTPUTRANGE_0_255, OnUpdateViewEVROutputRange)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_EVROUTPUTRANGE_16_235, OnUpdateViewEVROutputRange)
+
+ ON_UPDATE_COMMAND_UI(ID_VIEW_FLUSHGPU_BEFOREVSYNC, OnUpdateViewFlushGPU)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_FLUSHGPU_AFTERPRESENT, OnUpdateViewFlushGPU)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_FLUSHGPU_WAIT, OnUpdateViewFlushGPU)
+
+ ON_UPDATE_COMMAND_UI(ID_VIEW_D3DFULLSCREEN, OnUpdateViewD3DFullscreen)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_DISABLEDESKTOPCOMPOSITION, OnUpdateViewDisableDesktopComposition)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_ALTERNATIVEVSYNC, OnUpdateViewAlternativeVSync)
+
+
+ ON_UPDATE_COMMAND_UI(ID_VIEW_VSYNCOFFSET_INCREASE, OnUpdateViewVSyncOffsetIncrease)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_VSYNCOFFSET_DECREASE, OnUpdateViewVSyncOffsetDecrease)
+ ON_COMMAND(ID_VIEW_FULLSCREENGUISUPPORT, OnViewFullscreenGUISupport)
+ ON_COMMAND(ID_VIEW_HIGHCOLORRESOLUTION, OnViewHighColorResolution)
+ ON_COMMAND(ID_VIEW_FORCEINPUTHIGHCOLORRESOLUTION, OnViewForceInputHighColorResolution)
+ ON_COMMAND(ID_VIEW_FULLFLOATINGPOINTPROCESSING, OnViewFullFloatingPointProcessing)
+ ON_COMMAND(ID_VIEW_HALFFLOATINGPOINTPROCESSING, OnViewHalfFloatingPointProcessing)
+ ON_COMMAND(ID_VIEW_ENABLEFRAMETIMECORRECTION, OnViewEnableFrameTimeCorrection)
+ ON_COMMAND(ID_VIEW_VSYNC, OnViewVSync)
+ ON_COMMAND(ID_VIEW_VSYNCACCURATE, OnViewVSyncAccurate)
+
+ ON_COMMAND(ID_VIEW_SYNCHRONIZEVIDEO, OnViewSynchronizeVideo)
+ ON_COMMAND(ID_VIEW_SYNCHRONIZEDISPLAY, OnViewSynchronizeDisplay)
+ ON_COMMAND(ID_VIEW_SYNCHRONIZENEAREST, OnViewSynchronizeNearest)
+
+ ON_COMMAND(ID_VIEW_CM_ENABLE, OnViewColorManagementEnable)
+ ON_COMMAND(ID_VIEW_CM_INPUT_AUTO, OnViewColorManagementInputAuto)
+ ON_COMMAND(ID_VIEW_CM_INPUT_HDTV, OnViewColorManagementInputHDTV)
+ ON_COMMAND(ID_VIEW_CM_INPUT_SDTV_NTSC, OnViewColorManagementInputSDTV_NTSC)
+ ON_COMMAND(ID_VIEW_CM_INPUT_SDTV_PAL, OnViewColorManagementInputSDTV_PAL)
+ ON_COMMAND(ID_VIEW_CM_AMBIENTLIGHT_BRIGHT, OnViewColorManagementAmbientLightBright)
+ ON_COMMAND(ID_VIEW_CM_AMBIENTLIGHT_DIM, OnViewColorManagementAmbientLightDim)
+ ON_COMMAND(ID_VIEW_CM_AMBIENTLIGHT_DARK, OnViewColorManagementAmbientLightDark)
+ ON_COMMAND(ID_VIEW_CM_INTENT_PERCEPTUAL, OnViewColorManagementIntentPerceptual)
+ ON_COMMAND(ID_VIEW_CM_INTENT_RELATIVECOLORIMETRIC, OnViewColorManagementIntentRelativeColorimetric)
+ ON_COMMAND(ID_VIEW_CM_INTENT_SATURATION, OnViewColorManagementIntentSaturation)
+ ON_COMMAND(ID_VIEW_CM_INTENT_ABSOLUTECOLORIMETRIC, OnViewColorManagementIntentAbsoluteColorimetric)
+
+ ON_COMMAND(ID_VIEW_EVROUTPUTRANGE_0_255, OnViewEVROutputRange_0_255)
+ ON_COMMAND(ID_VIEW_EVROUTPUTRANGE_16_235, OnViewEVROutputRange_16_235)
+
+ ON_COMMAND(ID_VIEW_FLUSHGPU_BEFOREVSYNC, OnViewFlushGPUBeforeVSync)
+ ON_COMMAND(ID_VIEW_FLUSHGPU_AFTERPRESENT, OnViewFlushGPUAfterVSync)
+ ON_COMMAND(ID_VIEW_FLUSHGPU_WAIT, OnViewFlushGPUWait)
+
+ ON_COMMAND(ID_VIEW_D3DFULLSCREEN, OnViewD3DFullScreen)
+ ON_COMMAND(ID_VIEW_DISABLEDESKTOPCOMPOSITION, OnViewDisableDesktopComposition)
+ ON_COMMAND(ID_VIEW_ALTERNATIVEVSYNC, OnViewAlternativeVSync)
+ ON_COMMAND(ID_VIEW_RESET_DEFAULT, OnViewResetDefault)
+ ON_COMMAND(ID_VIEW_RESET_OPTIMAL, OnViewResetOptimal)
+
+ ON_COMMAND(ID_VIEW_VSYNCOFFSET_INCREASE, OnViewVSyncOffsetIncrease)
+ ON_COMMAND(ID_VIEW_VSYNCOFFSET_DECREASE, OnViewVSyncOffsetDecrease)
+ ON_UPDATE_COMMAND_UI(ID_SHADERS_TOGGLE, OnUpdateShaderToggle)
+ ON_COMMAND(ID_SHADERS_TOGGLE, OnShaderToggle)
+ ON_UPDATE_COMMAND_UI(ID_SHADERS_TOGGLE_SCREENSPACE, OnUpdateShaderToggleScreenSpace)
+ ON_COMMAND(ID_SHADERS_TOGGLE_SCREENSPACE, OnShaderToggleScreenSpace)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_REMAINING_TIME, OnUpdateViewRemainingTime)
+ ON_COMMAND(ID_VIEW_REMAINING_TIME, OnViewRemainingTime)
+ ON_COMMAND(ID_D3DFULLSCREEN_TOGGLE, OnD3DFullscreenToggle)
+ ON_COMMAND_RANGE(ID_GOTO_PREV_SUB, ID_GOTO_NEXT_SUB, OnGotoSubtitle)
+ ON_COMMAND_RANGE(ID_SHIFT_SUB_DOWN, ID_SHIFT_SUB_UP, OnShiftSubtitle)
+ ON_COMMAND_RANGE(ID_SUB_DELAY_DOWN, ID_SUB_DELAY_UP, OnSubtitleDelay)
+ ON_COMMAND_RANGE(ID_LANGUAGE_ENGLISH, ID_LANGUAGE_LAST, OnLanguage)
+
+ ON_COMMAND(ID_PLAY_PLAY, OnPlayPlay)
+ ON_COMMAND(ID_PLAY_PAUSE, OnPlayPause)
+ ON_COMMAND(ID_PLAY_PLAYPAUSE, OnPlayPlaypause)
+ ON_COMMAND(ID_PLAY_STOP, OnPlayStop)
+ ON_UPDATE_COMMAND_UI(ID_PLAY_PLAY, OnUpdatePlayPauseStop)
+ ON_UPDATE_COMMAND_UI(ID_PLAY_PAUSE, OnUpdatePlayPauseStop)
+ ON_UPDATE_COMMAND_UI(ID_PLAY_PLAYPAUSE, OnUpdatePlayPauseStop)
+ ON_UPDATE_COMMAND_UI(ID_PLAY_STOP, OnUpdatePlayPauseStop)
+ ON_COMMAND_RANGE(ID_PLAY_FRAMESTEP, ID_PLAY_FRAMESTEPCANCEL, OnPlayFramestep)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_PLAY_FRAMESTEP, ID_PLAY_FRAMESTEPCANCEL, OnUpdatePlayFramestep)
+ ON_COMMAND_RANGE(ID_PLAY_SEEKBACKWARDSMALL, ID_PLAY_SEEKFORWARDLARGE, OnPlaySeek)
+ ON_COMMAND_RANGE(ID_PLAY_SEEKKEYBACKWARD, ID_PLAY_SEEKKEYFORWARD, OnPlaySeekKey)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_PLAY_SEEKBACKWARDSMALL, ID_PLAY_SEEKFORWARDLARGE, OnUpdatePlaySeek)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_PLAY_SEEKKEYBACKWARD, ID_PLAY_SEEKKEYFORWARD, OnUpdatePlaySeek)
+ ON_COMMAND(ID_PLAY_GOTO, OnPlayGoto)
+ ON_UPDATE_COMMAND_UI(ID_PLAY_GOTO, OnUpdateGoto)
+ ON_COMMAND_RANGE(ID_PLAY_DECRATE, ID_PLAY_INCRATE, OnPlayChangeRate)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_PLAY_DECRATE, ID_PLAY_INCRATE, OnUpdatePlayChangeRate)
+ ON_COMMAND(ID_PLAY_RESETRATE, OnPlayResetRate)
+ ON_UPDATE_COMMAND_UI(ID_PLAY_RESETRATE, OnUpdatePlayResetRate)
+ ON_COMMAND_RANGE(ID_PLAY_INCAUDDELAY, ID_PLAY_DECAUDDELAY, OnPlayChangeAudDelay)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_PLAY_INCAUDDELAY, ID_PLAY_DECAUDDELAY, OnUpdatePlayChangeAudDelay)
+ ON_COMMAND_RANGE(ID_FILTERS_SUBITEM_START, ID_FILTERS_SUBITEM_END, OnPlayFilters)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_FILTERS_SUBITEM_START, ID_FILTERS_SUBITEM_END, OnUpdatePlayFilters)
+ ON_COMMAND_RANGE(ID_SHADERS_START, ID_SHADERS_END, OnPlayShaders)
+ ON_COMMAND_RANGE(ID_AUDIO_SUBITEM_START, ID_AUDIO_SUBITEM_END, OnPlayAudio)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_AUDIO_SUBITEM_START, ID_AUDIO_SUBITEM_END, OnUpdatePlayAudio)
+ ON_COMMAND_RANGE(ID_SUBTITLES_SUBITEM_START, ID_SUBTITLES_SUBITEM_END, OnPlaySubtitles)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_SUBTITLES_SUBITEM_START, ID_SUBTITLES_SUBITEM_END, OnUpdatePlaySubtitles)
+ ON_COMMAND_RANGE(ID_FILTERSTREAMS_SUBITEM_START, ID_FILTERSTREAMS_SUBITEM_END, OnPlayLanguage)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_FILTERSTREAMS_SUBITEM_START, ID_FILTERSTREAMS_SUBITEM_END, OnUpdatePlayLanguage)
+ ON_COMMAND_RANGE(ID_VOLUME_UP, ID_VOLUME_MUTE, OnPlayVolume)
+ ON_COMMAND_RANGE(ID_VOLUME_BOOST_INC, ID_VOLUME_BOOST_MAX, OnPlayVolumeBoost)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_VOLUME_BOOST_INC, ID_VOLUME_BOOST_MAX, OnUpdatePlayVolumeBoost)
+ ON_COMMAND(ID_CUSTOM_CHANNEL_MAPPING, OnCustomChannelMapping)
+ ON_UPDATE_COMMAND_UI(ID_CUSTOM_CHANNEL_MAPPING, OnUpdateCustomChannelMapping)
+ ON_COMMAND_RANGE(ID_NORMALIZE, ID_REGAIN_VOLUME, OnNormalizeRegainVolume)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_NORMALIZE, ID_REGAIN_VOLUME, OnUpdateNormalizeRegainVolume)
+ ON_COMMAND_RANGE(ID_COLOR_BRIGHTNESS_INC, ID_COLOR_RESET, OnPlayColor)
+ ON_COMMAND_RANGE(ID_AFTERPLAYBACK_CLOSE, ID_AFTERPLAYBACK_DONOTHING, OnAfterplayback)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_AFTERPLAYBACK_CLOSE, ID_AFTERPLAYBACK_DONOTHING, OnUpdateAfterplayback)
+ ON_COMMAND_RANGE(ID_AFTERPLAYBACK_EXIT, ID_AFTERPLAYBACK_NEXT, OnAfterplayback)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_AFTERPLAYBACK_EXIT, ID_AFTERPLAYBACK_NEXT, OnUpdateAfterplayback)
+
+ ON_COMMAND_RANGE(ID_NAVIGATE_SKIPBACK, ID_NAVIGATE_SKIPFORWARD, OnNavigateSkip)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_NAVIGATE_SKIPBACK, ID_NAVIGATE_SKIPFORWARD, OnUpdateNavigateSkip)
+ ON_COMMAND_RANGE(ID_NAVIGATE_SKIPBACKFILE, ID_NAVIGATE_SKIPFORWARDFILE, OnNavigateSkipFile)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_NAVIGATE_SKIPBACKFILE, ID_NAVIGATE_SKIPFORWARDFILE, OnUpdateNavigateSkipFile)
+ ON_COMMAND_RANGE(ID_NAVIGATE_TITLEMENU, ID_NAVIGATE_CHAPTERMENU, OnNavigateMenu)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_NAVIGATE_TITLEMENU, ID_NAVIGATE_CHAPTERMENU, OnUpdateNavigateMenu)
+ ON_COMMAND_RANGE(ID_NAVIGATE_AUDIO_SUBITEM_START, ID_NAVIGATE_AUDIO_SUBITEM_END, OnNavigateAudio)
+ ON_COMMAND_RANGE(ID_NAVIGATE_SUBP_SUBITEM_START, ID_NAVIGATE_SUBP_SUBITEM_END, OnNavigateSubpic)
+ ON_COMMAND_RANGE(ID_NAVIGATE_ANGLE_SUBITEM_START, ID_NAVIGATE_ANGLE_SUBITEM_END, OnNavigateAngle)
+ ON_COMMAND_RANGE(ID_NAVIGATE_CHAP_SUBITEM_START, ID_NAVIGATE_CHAP_SUBITEM_END, OnNavigateChapters)
+ ON_COMMAND_RANGE(ID_NAVIGATE_MENU_LEFT, ID_NAVIGATE_MENU_LEAVE, OnNavigateMenuItem)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_NAVIGATE_MENU_LEFT, ID_NAVIGATE_MENU_LEAVE, OnUpdateNavigateMenuItem)
+ ON_COMMAND(ID_NAVIGATE_TUNERSCAN, OnTunerScan)
+ ON_UPDATE_COMMAND_UI(ID_NAVIGATE_TUNERSCAN, OnUpdateTunerScan)
+
+ ON_COMMAND(ID_FAVORITES_ADD, OnFavoritesAdd)
+ ON_UPDATE_COMMAND_UI(ID_FAVORITES_ADD, OnUpdateFavoritesAdd)
+ ON_COMMAND(ID_FAVORITES_QUICKADDFAVORITE, OnFavoritesQuickAddFavorite)
+ ON_COMMAND(ID_FAVORITES_ORGANIZE, OnFavoritesOrganize)
+ ON_UPDATE_COMMAND_UI(ID_FAVORITES_ORGANIZE, OnUpdateFavoritesOrganize)
+ ON_COMMAND_RANGE(ID_FAVORITES_FILE_START, ID_FAVORITES_FILE_END, OnFavoritesFile)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_FAVORITES_FILE_START, ID_FAVORITES_FILE_END, OnUpdateFavoritesFile)
+ ON_COMMAND_RANGE(ID_FAVORITES_DVD_START, ID_FAVORITES_DVD_END, OnFavoritesDVD)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_FAVORITES_DVD_START, ID_FAVORITES_DVD_END, OnUpdateFavoritesDVD)
+ ON_COMMAND_RANGE(ID_FAVORITES_DEVICE_START, ID_FAVORITES_DEVICE_END, OnFavoritesDevice)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_FAVORITES_DEVICE_START, ID_FAVORITES_DEVICE_END, OnUpdateFavoritesDevice)
+
+ ON_COMMAND(ID_RECENT_FILES_CLEAR, OnRecentFileClear)
+ ON_UPDATE_COMMAND_UI(ID_RECENT_FILES_CLEAR, OnUpdateRecentFileClear)
+ ON_COMMAND_RANGE(ID_RECENT_FILE_START, ID_RECENT_FILE_END, OnRecentFile)
+ ON_UPDATE_COMMAND_UI_RANGE(ID_RECENT_FILE_START, ID_RECENT_FILE_END, OnUpdateRecentFile)
+
+ ON_COMMAND(ID_HELP_HOMEPAGE, OnHelpHomepage)
+ ON_COMMAND(ID_HELP_CHECKFORUPDATE, OnHelpCheckForUpdate)
+ //ON_COMMAND(ID_HELP_DOCUMENTATION, OnHelpDocumentation)
+ ON_COMMAND(ID_HELP_TOOLBARIMAGES, OnHelpToolbarImages)
+ ON_COMMAND(ID_HELP_DONATE, OnHelpDonate)
+
+ // Open Dir incl. SubDir
+ ON_COMMAND(ID_FILE_OPENDIRECTORY, OnFileOpendirectory)
+ ON_UPDATE_COMMAND_UI(ID_FILE_OPENDIRECTORY, OnUpdateFileOpen)
+ ON_WM_POWERBROADCAST()
+
+ // Navigation panel
+ ON_COMMAND(ID_VIEW_NAVIGATION, OnViewNavigation)
+ ON_UPDATE_COMMAND_UI(ID_VIEW_NAVIGATION, OnUpdateViewNavigation)
+
+ ON_WM_WTSSESSION_CHANGE()
END_MESSAGE_MAP()
#ifdef _DEBUG
-const TCHAR *GetEventString(LONG evCode)
+const TCHAR* GetEventString(LONG evCode)
{
#define UNPACK_VALUE(VALUE) case VALUE: return _T( #VALUE );
- switch (evCode) {
- UNPACK_VALUE(EC_COMPLETE);
- UNPACK_VALUE(EC_USERABORT);
- UNPACK_VALUE(EC_ERRORABORT);
- UNPACK_VALUE(EC_TIME);
- UNPACK_VALUE(EC_REPAINT);
- UNPACK_VALUE(EC_STREAM_ERROR_STOPPED);
- UNPACK_VALUE(EC_STREAM_ERROR_STILLPLAYING);
- UNPACK_VALUE(EC_ERROR_STILLPLAYING);
- UNPACK_VALUE(EC_PALETTE_CHANGED);
- UNPACK_VALUE(EC_VIDEO_SIZE_CHANGED);
- UNPACK_VALUE(EC_QUALITY_CHANGE);
- UNPACK_VALUE(EC_SHUTTING_DOWN);
- UNPACK_VALUE(EC_CLOCK_CHANGED);
- UNPACK_VALUE(EC_PAUSED);
- UNPACK_VALUE(EC_OPENING_FILE);
- UNPACK_VALUE(EC_BUFFERING_DATA);
- UNPACK_VALUE(EC_FULLSCREEN_LOST);
- UNPACK_VALUE(EC_ACTIVATE);
- UNPACK_VALUE(EC_NEED_RESTART);
- UNPACK_VALUE(EC_WINDOW_DESTROYED);
- UNPACK_VALUE(EC_DISPLAY_CHANGED);
- UNPACK_VALUE(EC_STARVATION);
- UNPACK_VALUE(EC_OLE_EVENT);
- UNPACK_VALUE(EC_NOTIFY_WINDOW);
- UNPACK_VALUE(EC_STREAM_CONTROL_STOPPED);
- UNPACK_VALUE(EC_STREAM_CONTROL_STARTED);
- UNPACK_VALUE(EC_END_OF_SEGMENT);
- UNPACK_VALUE(EC_SEGMENT_STARTED);
- UNPACK_VALUE(EC_LENGTH_CHANGED);
- UNPACK_VALUE(EC_DEVICE_LOST);
- UNPACK_VALUE(EC_SAMPLE_NEEDED);
- UNPACK_VALUE(EC_PROCESSING_LATENCY);
- UNPACK_VALUE(EC_SAMPLE_LATENCY);
- UNPACK_VALUE(EC_SCRUB_TIME);
- UNPACK_VALUE(EC_STEP_COMPLETE);
- UNPACK_VALUE(EC_TIMECODE_AVAILABLE);
- UNPACK_VALUE(EC_EXTDEVICE_MODE_CHANGE);
- UNPACK_VALUE(EC_STATE_CHANGE);
- UNPACK_VALUE(EC_GRAPH_CHANGED);
- UNPACK_VALUE(EC_CLOCK_UNSET);
- UNPACK_VALUE(EC_VMR_RENDERDEVICE_SET);
- UNPACK_VALUE(EC_VMR_SURFACE_FLIPPED);
- UNPACK_VALUE(EC_VMR_RECONNECTION_FAILED);
- UNPACK_VALUE(EC_PREPROCESS_COMPLETE);
- UNPACK_VALUE(EC_CODECAPI_EVENT);
- UNPACK_VALUE(EC_WMT_INDEX_EVENT);
- UNPACK_VALUE(EC_WMT_EVENT);
- UNPACK_VALUE(EC_BUILT);
- UNPACK_VALUE(EC_UNBUILT);
- UNPACK_VALUE(EC_SKIP_FRAMES);
- UNPACK_VALUE(EC_PLEASE_REOPEN);
- UNPACK_VALUE(EC_STATUS);
- UNPACK_VALUE(EC_MARKER_HIT);
- UNPACK_VALUE(EC_LOADSTATUS);
- UNPACK_VALUE(EC_FILE_CLOSED);
- UNPACK_VALUE(EC_ERRORABORTEX);
- //UNPACK_VALUE(EC_NEW_PIN);
- //UNPACK_VALUE(EC_RENDER_FINISHED);
- UNPACK_VALUE(EC_EOS_SOON);
- UNPACK_VALUE(EC_CONTENTPROPERTY_CHANGED);
- UNPACK_VALUE(EC_BANDWIDTHCHANGE);
- UNPACK_VALUE(EC_VIDEOFRAMEREADY);
-
- UNPACK_VALUE(EC_BG_AUDIO_CHANGED);
- UNPACK_VALUE(EC_BG_ERROR);
- };
+ switch (evCode) {
+ UNPACK_VALUE(EC_COMPLETE);
+ UNPACK_VALUE(EC_USERABORT);
+ UNPACK_VALUE(EC_ERRORABORT);
+ UNPACK_VALUE(EC_TIME);
+ UNPACK_VALUE(EC_REPAINT);
+ UNPACK_VALUE(EC_STREAM_ERROR_STOPPED);
+ UNPACK_VALUE(EC_STREAM_ERROR_STILLPLAYING);
+ UNPACK_VALUE(EC_ERROR_STILLPLAYING);
+ UNPACK_VALUE(EC_PALETTE_CHANGED);
+ UNPACK_VALUE(EC_VIDEO_SIZE_CHANGED);
+ UNPACK_VALUE(EC_QUALITY_CHANGE);
+ UNPACK_VALUE(EC_SHUTTING_DOWN);
+ UNPACK_VALUE(EC_CLOCK_CHANGED);
+ UNPACK_VALUE(EC_PAUSED);
+ UNPACK_VALUE(EC_OPENING_FILE);
+ UNPACK_VALUE(EC_BUFFERING_DATA);
+ UNPACK_VALUE(EC_FULLSCREEN_LOST);
+ UNPACK_VALUE(EC_ACTIVATE);
+ UNPACK_VALUE(EC_NEED_RESTART);
+ UNPACK_VALUE(EC_WINDOW_DESTROYED);
+ UNPACK_VALUE(EC_DISPLAY_CHANGED);
+ UNPACK_VALUE(EC_STARVATION);
+ UNPACK_VALUE(EC_OLE_EVENT);
+ UNPACK_VALUE(EC_NOTIFY_WINDOW);
+ UNPACK_VALUE(EC_STREAM_CONTROL_STOPPED);
+ UNPACK_VALUE(EC_STREAM_CONTROL_STARTED);
+ UNPACK_VALUE(EC_END_OF_SEGMENT);
+ UNPACK_VALUE(EC_SEGMENT_STARTED);
+ UNPACK_VALUE(EC_LENGTH_CHANGED);
+ UNPACK_VALUE(EC_DEVICE_LOST);
+ UNPACK_VALUE(EC_SAMPLE_NEEDED);
+ UNPACK_VALUE(EC_PROCESSING_LATENCY);
+ UNPACK_VALUE(EC_SAMPLE_LATENCY);
+ UNPACK_VALUE(EC_SCRUB_TIME);
+ UNPACK_VALUE(EC_STEP_COMPLETE);
+ UNPACK_VALUE(EC_TIMECODE_AVAILABLE);
+ UNPACK_VALUE(EC_EXTDEVICE_MODE_CHANGE);
+ UNPACK_VALUE(EC_STATE_CHANGE);
+ UNPACK_VALUE(EC_GRAPH_CHANGED);
+ UNPACK_VALUE(EC_CLOCK_UNSET);
+ UNPACK_VALUE(EC_VMR_RENDERDEVICE_SET);
+ UNPACK_VALUE(EC_VMR_SURFACE_FLIPPED);
+ UNPACK_VALUE(EC_VMR_RECONNECTION_FAILED);
+ UNPACK_VALUE(EC_PREPROCESS_COMPLETE);
+ UNPACK_VALUE(EC_CODECAPI_EVENT);
+ UNPACK_VALUE(EC_WMT_INDEX_EVENT);
+ UNPACK_VALUE(EC_WMT_EVENT);
+ UNPACK_VALUE(EC_BUILT);
+ UNPACK_VALUE(EC_UNBUILT);
+ UNPACK_VALUE(EC_SKIP_FRAMES);
+ UNPACK_VALUE(EC_PLEASE_REOPEN);
+ UNPACK_VALUE(EC_STATUS);
+ UNPACK_VALUE(EC_MARKER_HIT);
+ UNPACK_VALUE(EC_LOADSTATUS);
+ UNPACK_VALUE(EC_FILE_CLOSED);
+ UNPACK_VALUE(EC_ERRORABORTEX);
+ //UNPACK_VALUE(EC_NEW_PIN);
+ //UNPACK_VALUE(EC_RENDER_FINISHED);
+ UNPACK_VALUE(EC_EOS_SOON);
+ UNPACK_VALUE(EC_CONTENTPROPERTY_CHANGED);
+ UNPACK_VALUE(EC_BANDWIDTHCHANGE);
+ UNPACK_VALUE(EC_VIDEOFRAMEREADY);
+
+ UNPACK_VALUE(EC_BG_AUDIO_CHANGED);
+ UNPACK_VALUE(EC_BG_ERROR);
+ };
#undef UNPACK_VALUE
- return _T("UNKNOWN");
+ return _T("UNKNOWN");
}
#endif
@@ -617,352 +617,352 @@ const TCHAR *GetEventString(LONG evCode)
// CMainFrame construction/destruction
CMainFrame::CMainFrame() :
- m_iMediaLoadState(MLS_CLOSED),
- m_iPlaybackMode(PM_NONE),
- m_iSpeedLevel(0),
- m_dSpeedRate(1.0),
- m_rtDurationOverride(-1),
- m_fFullScreen(false),
- m_fFirstFSAfterLaunchOnFS(false),
- m_fHideCursor(false),
- m_lastMouseMove(-1, -1),
- m_pLastBar(NULL),
- m_nCS(0),
- m_nLoops(0),
- m_iSubtitleSel(-1),
- m_ZoomX(1), m_ZoomY(1), m_PosX(0.5), m_PosY(0.5),
- m_AngleX(0), m_AngleY(0), m_AngleZ(0),
- m_fCustomGraph(false),
- m_fRealMediaGraph(false), m_fShockwaveGraph(false), m_fQuicktimeGraph(false),
- m_fFrameSteppingActive(false),
- m_fEndOfStream(false),
- m_fCapturing(false),
- m_fLiveWM(false),
- m_fOpeningAborted(false),
- m_fBuffering(false),
- m_fileDropTarget(this),
- m_fTrayIcon(false),
- m_pFullscreenWnd(NULL),
- m_pVideoWnd(NULL),
- m_bRemainingTime(false),
- m_nCurSubtitle(-1),
- m_lSubtitleShift(0),
- m_bToggleShader(false),
- m_nStepForwardCount(0),
- m_rtStepForwardStart(0),
- m_bToggleShaderScreenSpace(false),
- m_bInOptions(false),
- m_lCurrentChapter(0),
- m_lChapterStartTime(0xFFFFFFFF),
- m_pTaskbarList(NULL),
- m_pGraphThread(NULL),
- m_bOpenedThruThread(false),
- m_nMenuHideTick(0),
- m_bWasSnapped(false),
- m_nSeekDirection(SEEK_DIRECTION_NONE),
- m_bIsBDPlay(false),
- m_LastOpenBDPath(_T("")),
- m_fClosingState(false)
-{
- //m_Lcd.SetVolumeRange(0, 100);
- m_LastSaveTime.QuadPart = 0;
+ m_iMediaLoadState(MLS_CLOSED),
+ m_iPlaybackMode(PM_NONE),
+ m_iSpeedLevel(0),
+ m_dSpeedRate(1.0),
+ m_rtDurationOverride(-1),
+ m_fFullScreen(false),
+ m_fFirstFSAfterLaunchOnFS(false),
+ m_fHideCursor(false),
+ m_lastMouseMove(-1, -1),
+ m_pLastBar(NULL),
+ m_nCS(0),
+ m_nLoops(0),
+ m_iSubtitleSel(-1),
+ m_ZoomX(1), m_ZoomY(1), m_PosX(0.5), m_PosY(0.5),
+ m_AngleX(0), m_AngleY(0), m_AngleZ(0),
+ m_fCustomGraph(false),
+ m_fRealMediaGraph(false), m_fShockwaveGraph(false), m_fQuicktimeGraph(false),
+ m_fFrameSteppingActive(false),
+ m_fEndOfStream(false),
+ m_fCapturing(false),
+ m_fLiveWM(false),
+ m_fOpeningAborted(false),
+ m_fBuffering(false),
+ m_fileDropTarget(this),
+ m_fTrayIcon(false),
+ m_pFullscreenWnd(NULL),
+ m_pVideoWnd(NULL),
+ m_bRemainingTime(false),
+ m_nCurSubtitle(-1),
+ m_lSubtitleShift(0),
+ m_bToggleShader(false),
+ m_nStepForwardCount(0),
+ m_rtStepForwardStart(0),
+ m_bToggleShaderScreenSpace(false),
+ m_bInOptions(false),
+ m_lCurrentChapter(0),
+ m_lChapterStartTime(0xFFFFFFFF),
+ m_pTaskbarList(NULL),
+ m_pGraphThread(NULL),
+ m_bOpenedThruThread(false),
+ m_nMenuHideTick(0),
+ m_bWasSnapped(false),
+ m_nSeekDirection(SEEK_DIRECTION_NONE),
+ m_bIsBDPlay(false),
+ m_LastOpenBDPath(_T("")),
+ m_fClosingState(false)
+{
+ //m_Lcd.SetVolumeRange(0, 100);
+ m_LastSaveTime.QuadPart = 0;
}
CMainFrame::~CMainFrame()
{
- //m_owner.DestroyWindow();
- //delete m_pFullscreenWnd; // double delete see CMainFrame::OnDestroy
+ //m_owner.DestroyWindow();
+ //delete m_pFullscreenWnd; // double delete see CMainFrame::OnDestroy
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
- if (__super::OnCreate(lpCreateStruct) == -1) {
- return -1;
- }
-
- m_popup.LoadMenu(IDR_POPUP);
- m_popupmain.LoadMenu(IDR_POPUPMAIN);
-
- // create a view to occupy the client area of the frame
- if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
- CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL)) {
- TRACE0("Failed to create view window\n");
- return -1;
- }
- // Should never be RTLed
- m_wndView.ModifyStyleEx(WS_EX_LAYOUTRTL, WS_EX_NOINHERITLAYOUT);
-
- // static bars
-
- BOOL bResult = m_wndStatusBar.Create(this);
- if (bResult) {
- bResult = m_wndStatsBar.Create(this);
- }
- if (bResult) {
- bResult = m_wndInfoBar.Create(this);
- }
- if (bResult) {
- bResult = m_wndToolBar.Create(this);
- }
- if (bResult) {
- bResult = m_wndSeekBar.Create(this);
- }
- if (!bResult) {
- TRACE0("Failed to create all control bars\n");
- return -1; // fail to create
- }
-
- m_pFullscreenWnd = DNew CFullscreenWnd(this);
-
- m_bars.AddTail(&m_wndSeekBar);
- m_bars.AddTail(&m_wndToolBar);
- m_bars.AddTail(&m_wndInfoBar);
- m_bars.AddTail(&m_wndStatsBar);
- m_bars.AddTail(&m_wndStatusBar);
-
- m_wndSeekBar.Enable(false);
-
- // dockable bars
-
- EnableDocking(CBRS_ALIGN_ANY);
-
- m_dockingbars.RemoveAll();
-
- m_wndSubresyncBar.Create(this, AFX_IDW_DOCKBAR_TOP, &m_csSubLock);
- m_wndSubresyncBar.SetBarStyle(m_wndSubresyncBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
- m_wndSubresyncBar.EnableDocking(CBRS_ALIGN_ANY);
- m_wndSubresyncBar.SetHeight(200);
- m_dockingbars.AddTail(&m_wndSubresyncBar);
-
- m_wndPlaylistBar.Create(this, AFX_IDW_DOCKBAR_BOTTOM);
- m_wndPlaylistBar.SetBarStyle(m_wndPlaylistBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
- m_wndPlaylistBar.EnableDocking(CBRS_ALIGN_ANY);
- m_wndPlaylistBar.SetHeight(100);
- m_dockingbars.AddTail(&m_wndPlaylistBar);
- m_wndPlaylistBar.LoadPlaylist(GetRecentFile());
-
- m_wndEditListEditor.Create(this, AFX_IDW_DOCKBAR_RIGHT);
- m_wndEditListEditor.SetBarStyle(m_wndEditListEditor.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
- m_wndEditListEditor.EnableDocking(CBRS_ALIGN_ANY);
- m_dockingbars.AddTail(&m_wndEditListEditor);
- m_wndEditListEditor.SetHeight(100);
-
- m_wndCaptureBar.Create(this, AFX_IDW_DOCKBAR_LEFT);
- m_wndCaptureBar.SetBarStyle(m_wndCaptureBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
- m_wndCaptureBar.EnableDocking(CBRS_ALIGN_LEFT|CBRS_ALIGN_RIGHT);
- m_dockingbars.AddTail(&m_wndCaptureBar);
-
- m_wndNavigationBar.Create(this, AFX_IDW_DOCKBAR_LEFT);
- m_wndNavigationBar.SetBarStyle(m_wndNavigationBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
- m_wndNavigationBar.EnableDocking(CBRS_ALIGN_LEFT|CBRS_ALIGN_RIGHT);
- m_dockingbars.AddTail(&m_wndNavigationBar);
-
- m_wndShaderEditorBar.Create(this, AFX_IDW_DOCKBAR_TOP);
- m_wndShaderEditorBar.SetBarStyle(m_wndShaderEditorBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
- m_wndShaderEditorBar.EnableDocking(CBRS_ALIGN_ANY);
- m_dockingbars.AddTail(&m_wndShaderEditorBar);
-
- // Hide all dockable bars by default
- POSITION pos = m_dockingbars.GetHeadPosition();
- while (pos) {
- m_dockingbars.GetNext(pos)->ShowWindow(SW_HIDE);
- }
-
- m_fileDropTarget.Register(this);
-
- GetDesktopWindow()->GetWindowRect(&m_rcDesktop);
-
- AppSettings& s = AfxGetAppSettings();
-
- // Load the controls
- m_nCS = s.nCS;
- ShowControls(m_nCS);
-
- SetAlwaysOnTop(s.iOnTop);
-
- ShowTrayIcon(s.fTrayIcon);
-
- SetFocus();
-
- m_pGraphThread = (CGraphThread*)AfxBeginThread(RUNTIME_CLASS(CGraphThread));
-
- if (m_pGraphThread) {
- m_pGraphThread->SetMainFrame(this);
- }
+ if (__super::OnCreate(lpCreateStruct) == -1) {
+ return -1;
+ }
+
+ m_popup.LoadMenu(IDR_POPUP);
+ m_popupmain.LoadMenu(IDR_POPUPMAIN);
+
+ // create a view to occupy the client area of the frame
+ if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
+ CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL)) {
+ TRACE0("Failed to create view window\n");
+ return -1;
+ }
+ // Should never be RTLed
+ m_wndView.ModifyStyleEx(WS_EX_LAYOUTRTL, WS_EX_NOINHERITLAYOUT);
+
+ // static bars
+
+ BOOL bResult = m_wndStatusBar.Create(this);
+ if (bResult) {
+ bResult = m_wndStatsBar.Create(this);
+ }
+ if (bResult) {
+ bResult = m_wndInfoBar.Create(this);
+ }
+ if (bResult) {
+ bResult = m_wndToolBar.Create(this);
+ }
+ if (bResult) {
+ bResult = m_wndSeekBar.Create(this);
+ }
+ if (!bResult) {
+ TRACE0("Failed to create all control bars\n");
+ return -1; // fail to create
+ }
+
+ m_pFullscreenWnd = DNew CFullscreenWnd(this);
+
+ m_bars.AddTail(&m_wndSeekBar);
+ m_bars.AddTail(&m_wndToolBar);
+ m_bars.AddTail(&m_wndInfoBar);
+ m_bars.AddTail(&m_wndStatsBar);
+ m_bars.AddTail(&m_wndStatusBar);
+
+ m_wndSeekBar.Enable(false);
- if (s.nCmdlnWebServerPort != 0) {
- if (s.nCmdlnWebServerPort > 0) {
- StartWebServer(s.nCmdlnWebServerPort);
- } else if (s.fEnableWebServer) {
- StartWebServer(s.nWebServerPort);
- }
- }
+ // dockable bars
- // Casimir666 : reload Shaders
- {
- CString strList = s.strShaderList;
- CString strRes;
- int curPos= 0;
+ EnableDocking(CBRS_ALIGN_ANY);
- strRes = strList.Tokenize (_T("|"), curPos);
- while (strRes != _T("")) {
- m_shaderlabels.AddTail (strRes);
- strRes = strList.Tokenize(_T("|"),curPos);
- }
- }
- {
- CString strList = s.strShaderListScreenSpace;
- CString strRes;
- int curPos= 0;
+ m_dockingbars.RemoveAll();
- strRes = strList.Tokenize (_T("|"), curPos);
- while (strRes != _T("")) {
- m_shaderlabelsScreenSpace.AddTail (strRes);
- strRes = strList.Tokenize(_T("|"),curPos);
- }
- }
+ m_wndSubresyncBar.Create(this, AFX_IDW_DOCKBAR_TOP, &m_csSubLock);
+ m_wndSubresyncBar.SetBarStyle(m_wndSubresyncBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
+ m_wndSubresyncBar.EnableDocking(CBRS_ALIGN_ANY);
+ m_wndSubresyncBar.SetHeight(200);
+ m_dockingbars.AddTail(&m_wndSubresyncBar);
- m_bToggleShader = s.fToggleShader;
- m_bToggleShaderScreenSpace = s.fToggleShaderScreenSpace;
+ m_wndPlaylistBar.Create(this, AFX_IDW_DOCKBAR_BOTTOM);
+ m_wndPlaylistBar.SetBarStyle(m_wndPlaylistBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
+ m_wndPlaylistBar.EnableDocking(CBRS_ALIGN_ANY);
+ m_wndPlaylistBar.SetHeight(100);
+ m_dockingbars.AddTail(&m_wndPlaylistBar);
+ m_wndPlaylistBar.LoadPlaylist(GetRecentFile());
- m_strTitle.LoadString(IDR_MAINFRAME);
+ m_wndEditListEditor.Create(this, AFX_IDW_DOCKBAR_RIGHT);
+ m_wndEditListEditor.SetBarStyle(m_wndEditListEditor.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
+ m_wndEditListEditor.EnableDocking(CBRS_ALIGN_ANY);
+ m_dockingbars.AddTail(&m_wndEditListEditor);
+ m_wndEditListEditor.SetHeight(100);
- SetWindowText(m_strTitle);
- //m_Lcd.SetMediaTitle(LPCTSTR(m_strTitle));
+ m_wndCaptureBar.Create(this, AFX_IDW_DOCKBAR_LEFT);
+ m_wndCaptureBar.SetBarStyle(m_wndCaptureBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
+ m_wndCaptureBar.EnableDocking(CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT);
+ m_dockingbars.AddTail(&m_wndCaptureBar);
+
+ m_wndNavigationBar.Create(this, AFX_IDW_DOCKBAR_LEFT);
+ m_wndNavigationBar.SetBarStyle(m_wndNavigationBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
+ m_wndNavigationBar.EnableDocking(CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT);
+ m_dockingbars.AddTail(&m_wndNavigationBar);
+
+ m_wndShaderEditorBar.Create(this, AFX_IDW_DOCKBAR_TOP);
+ m_wndShaderEditorBar.SetBarStyle(m_wndShaderEditorBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
+ m_wndShaderEditorBar.EnableDocking(CBRS_ALIGN_ANY);
+ m_dockingbars.AddTail(&m_wndShaderEditorBar);
+
+ // Hide all dockable bars by default
+ POSITION pos = m_dockingbars.GetHeadPosition();
+ while (pos) {
+ m_dockingbars.GetNext(pos)->ShowWindow(SW_HIDE);
+ }
+
+ m_fileDropTarget.Register(this);
+
+ GetDesktopWindow()->GetWindowRect(&m_rcDesktop);
+
+ AppSettings& s = AfxGetAppSettings();
+
+ // Load the controls
+ m_nCS = s.nCS;
+ ShowControls(m_nCS);
+
+ SetAlwaysOnTop(s.iOnTop);
+
+ ShowTrayIcon(s.fTrayIcon);
+
+ SetFocus();
+
+ m_pGraphThread = (CGraphThread*)AfxBeginThread(RUNTIME_CLASS(CGraphThread));
+
+ if (m_pGraphThread) {
+ m_pGraphThread->SetMainFrame(this);
+ }
+
+ if (s.nCmdlnWebServerPort != 0) {
+ if (s.nCmdlnWebServerPort > 0) {
+ StartWebServer(s.nCmdlnWebServerPort);
+ } else if (s.fEnableWebServer) {
+ StartWebServer(s.nWebServerPort);
+ }
+ }
+
+ // Casimir666 : reload Shaders
+ {
+ CString strList = s.strShaderList;
+ CString strRes;
+ int curPos = 0;
+
+ strRes = strList.Tokenize(_T("|"), curPos);
+ while (strRes != _T("")) {
+ m_shaderlabels.AddTail(strRes);
+ strRes = strList.Tokenize(_T("|"), curPos);
+ }
+ }
+ {
+ CString strList = s.strShaderListScreenSpace;
+ CString strRes;
+ int curPos = 0;
+
+ strRes = strList.Tokenize(_T("|"), curPos);
+ while (strRes != _T("")) {
+ m_shaderlabelsScreenSpace.AddTail(strRes);
+ strRes = strList.Tokenize(_T("|"), curPos);
+ }
+ }
- m_OpenFile = false;
+ m_bToggleShader = s.fToggleShader;
+ m_bToggleShaderScreenSpace = s.fToggleShaderScreenSpace;
- SendAPICommand (CMD_CONNECT, L"%d", GetSafeHwnd());
+ m_strTitle.LoadString(IDR_MAINFRAME);
- WTSRegisterSessionNotification();
+ SetWindowText(m_strTitle);
+ //m_Lcd.SetMediaTitle(LPCTSTR(m_strTitle));
- return 0;
+ m_OpenFile = false;
+
+ SendAPICommand(CMD_CONNECT, L"%d", GetSafeHwnd());
+
+ WTSRegisterSessionNotification();
+
+ return 0;
}
void CMainFrame::OnDestroy()
{
- WTSUnRegisterSessionNotification();
+ WTSUnRegisterSessionNotification();
- ShowTrayIcon( false );
+ ShowTrayIcon(false);
- m_fileDropTarget.Revoke();
+ m_fileDropTarget.Revoke();
- if ( m_pGraphThread ) {
- CAMEvent e;
- m_pGraphThread->PostThreadMessage( CGraphThread::TM_EXIT, 0, (LPARAM)&e );
- if ( !e.Wait(5000) ) {
- TRACE(_T("ERROR: Must call TerminateThread() on CMainFrame::m_pGraphThread->m_hThread\n"));
- TerminateThread( m_pGraphThread->m_hThread, (DWORD)-1 );
- }
- }
+ if (m_pGraphThread) {
+ CAMEvent e;
+ m_pGraphThread->PostThreadMessage(CGraphThread::TM_EXIT, 0, (LPARAM)&e);
+ if (!e.Wait(5000)) {
+ TRACE(_T("ERROR: Must call TerminateThread() on CMainFrame::m_pGraphThread->m_hThread\n"));
+ TerminateThread(m_pGraphThread->m_hThread, (DWORD) - 1);
+ }
+ }
- if ( m_pFullscreenWnd ) {
- if ( m_pFullscreenWnd->IsWindow() ) {
- m_pFullscreenWnd->DestroyWindow();
- }
- delete m_pFullscreenWnd;
- }
+ if (m_pFullscreenWnd) {
+ if (m_pFullscreenWnd->IsWindow()) {
+ m_pFullscreenWnd->DestroyWindow();
+ }
+ delete m_pFullscreenWnd;
+ }
- __super::OnDestroy();
+ __super::OnDestroy();
}
void CMainFrame::OnClose()
{
- m_fClosingState = true;
+ m_fClosingState = true;
- AppSettings& s = AfxGetAppSettings();
- // Casimir666 : save shaders list
- {
- POSITION pos;
- CString strList = "";
+ AppSettings& s = AfxGetAppSettings();
+ // Casimir666 : save shaders list
+ {
+ POSITION pos;
+ CString strList = "";
- pos = m_shaderlabels.GetHeadPosition();
- while (pos) {
- strList += m_shaderlabels.GetAt (pos) + "|";
- m_dockingbars.GetNext(pos);
- }
- s.strShaderList = strList;
- }
- {
- POSITION pos;
- CString strList = "";
-
- pos = m_shaderlabelsScreenSpace.GetHeadPosition();
- while (pos) {
- strList += m_shaderlabelsScreenSpace.GetAt (pos) + "|";
- m_dockingbars.GetNext(pos);
- }
- s.strShaderListScreenSpace = strList;
- }
+ pos = m_shaderlabels.GetHeadPosition();
+ while (pos) {
+ strList += m_shaderlabels.GetAt(pos) + "|";
+ m_dockingbars.GetNext(pos);
+ }
+ s.strShaderList = strList;
+ }
+ {
+ POSITION pos;
+ CString strList = "";
+
+ pos = m_shaderlabelsScreenSpace.GetHeadPosition();
+ while (pos) {
+ strList += m_shaderlabelsScreenSpace.GetAt(pos) + "|";
+ m_dockingbars.GetNext(pos);
+ }
+ s.strShaderListScreenSpace = strList;
+ }
- s.fToggleShader = m_bToggleShader;
- s.fToggleShaderScreenSpace = m_bToggleShaderScreenSpace;
+ s.fToggleShader = m_bToggleShader;
+ s.fToggleShaderScreenSpace = m_bToggleShaderScreenSpace;
- s.dZoomX = m_ZoomX;
- s.dZoomY = m_ZoomY;
+ s.dZoomX = m_ZoomX;
+ s.dZoomY = m_ZoomY;
- m_wndPlaylistBar.SavePlaylist();
+ m_wndPlaylistBar.SavePlaylist();
- SaveControlBars();
+ SaveControlBars();
- ShowWindow(SW_HIDE);
+ ShowWindow(SW_HIDE);
- CloseMedia();
+ CloseMedia();
- s.WinLircClient.DisConnect();
- s.UIceClient.DisConnect();
+ s.WinLircClient.DisConnect();
+ s.UIceClient.DisConnect();
- __super::OnClose();
+ __super::OnClose();
}
DROPEFFECT CMainFrame::OnDragEnter(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
{
- return DROPEFFECT_NONE;
+ return DROPEFFECT_NONE;
}
DROPEFFECT CMainFrame::OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
{
- UINT CF_URL = RegisterClipboardFormat(_T("UniformResourceLocator"));
- return pDataObject->IsDataAvailable(CF_URL) ? DROPEFFECT_COPY : DROPEFFECT_NONE;
+ UINT CF_URL = RegisterClipboardFormat(_T("UniformResourceLocator"));
+ return pDataObject->IsDataAvailable(CF_URL) ? DROPEFFECT_COPY : DROPEFFECT_NONE;
}
BOOL CMainFrame::OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point)
{
- UINT CF_URL = RegisterClipboardFormat(_T("UniformResourceLocator"));
+ UINT CF_URL = RegisterClipboardFormat(_T("UniformResourceLocator"));
- BOOL bResult = FALSE;
+ BOOL bResult = FALSE;
- if (pDataObject->IsDataAvailable(CF_URL)) {
- FORMATETC fmt = {CF_URL, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
- if (HGLOBAL hGlobal = pDataObject->GetGlobalData(CF_URL, &fmt)) {
- LPCSTR pText = (LPCSTR)GlobalLock(hGlobal);
- if (AfxIsValidString(pText)) {
- CStringA url(pText);
+ if (pDataObject->IsDataAvailable(CF_URL)) {
+ FORMATETC fmt = {CF_URL, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
+ if (HGLOBAL hGlobal = pDataObject->GetGlobalData(CF_URL, &fmt)) {
+ LPCSTR pText = (LPCSTR)GlobalLock(hGlobal);
+ if (AfxIsValidString(pText)) {
+ CStringA url(pText);
- SetForegroundWindow();
+ SetForegroundWindow();
- CAtlList<CString> sl;
- sl.AddTail(CString(url));
+ CAtlList<CString> sl;
+ sl.AddTail(CString(url));
- if (m_wndPlaylistBar.IsWindowVisible()) {
- m_wndPlaylistBar.Append(sl, true);
- } else {
- m_wndPlaylistBar.Open(sl, true);
- OpenCurPlaylistItem();
- }
+ if (m_wndPlaylistBar.IsWindowVisible()) {
+ m_wndPlaylistBar.Append(sl, true);
+ } else {
+ m_wndPlaylistBar.Open(sl, true);
+ OpenCurPlaylistItem();
+ }
- GlobalUnlock(hGlobal);
- bResult = TRUE;
- }
- }
- }
+ GlobalUnlock(hGlobal);
+ bResult = TRUE;
+ }
+ }
+ }
- return bResult;
+ return bResult;
}
DROPEFFECT CMainFrame::OnDropEx(COleDataObject* pDataObject, DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint point)
{
- return (DROPEFFECT)-1;
+ return (DROPEFFECT) - 1;
}
void CMainFrame::OnDragLeave()
@@ -971,204 +971,204 @@ void CMainFrame::OnDragLeave()
DROPEFFECT CMainFrame::OnDragScroll(DWORD dwKeyState, CPoint point)
{
- return DROPEFFECT_NONE;
+ return DROPEFFECT_NONE;
}
LPCTSTR CMainFrame::GetRecentFile() const
{
- CRecentFileList& MRU = AfxGetAppSettings().MRU;
- MRU.ReadList();
- for (int i = 0; i < MRU.GetSize(); i++) {
- if (!MRU[i].IsEmpty()) {
- return MRU[i].GetString();
- }
- }
- return NULL;
+ CRecentFileList& MRU = AfxGetAppSettings().MRU;
+ MRU.ReadList();
+ for (int i = 0; i < MRU.GetSize(); i++) {
+ if (!MRU[i].IsEmpty()) {
+ return MRU[i].GetString();
+ }
+ }
+ return NULL;
}
void CMainFrame::RestoreControlBars()
{
- POSITION pos = m_dockingbars.GetHeadPosition();
- while (pos) {
- CPlayerBar* pBar = dynamic_cast<CPlayerBar*>(m_dockingbars.GetNext(pos));
+ POSITION pos = m_dockingbars.GetHeadPosition();
+ while (pos) {
+ CPlayerBar* pBar = dynamic_cast<CPlayerBar*>(m_dockingbars.GetNext(pos));
- if (pBar) {
- pBar->LoadState(this);
- }
- }
+ if (pBar) {
+ pBar->LoadState(this);
+ }
+ }
}
void CMainFrame::SaveControlBars()
{
- POSITION pos = m_dockingbars.GetHeadPosition();
- while (pos) {
- CPlayerBar* pBar = dynamic_cast<CPlayerBar*>(m_dockingbars.GetNext(pos));
+ POSITION pos = m_dockingbars.GetHeadPosition();
+ while (pos) {
+ CPlayerBar* pBar = dynamic_cast<CPlayerBar*>(m_dockingbars.GetNext(pos));
- if (pBar) {
- pBar->SaveState();
- }
- }
+ if (pBar) {
+ pBar->SaveState();
+ }
+ }
}
LRESULT CMainFrame::OnTaskBarRestart(WPARAM, LPARAM)
{
- m_fTrayIcon = false;
- ShowTrayIcon(AfxGetAppSettings().fTrayIcon);
+ m_fTrayIcon = false;
+ ShowTrayIcon(AfxGetAppSettings().fTrayIcon);
- return 0;
+ return 0;
}
LRESULT CMainFrame::OnNotifyIcon(WPARAM wParam, LPARAM lParam)
{
- if ((UINT)wParam != IDR_MAINFRAME) {
- return -1;
- }
-
- switch ((UINT)lParam) {
- case WM_LBUTTONDOWN:
- ShowWindow(SW_SHOW);
- CreateThumbnailToolbar();
- MoveVideoWindow();
- SetForegroundWindow();
- break;
-
- case WM_LBUTTONDBLCLK:
- PostMessage(WM_COMMAND, ID_FILE_OPENMEDIA);
- break;
-
- case WM_RBUTTONDOWN: {
- POINT p;
- GetCursorPos(&p);
- SetForegroundWindow();
- m_popupmain.GetSubMenu(0)->TrackPopupMenu(TPM_RIGHTBUTTON|TPM_NOANIMATION, p.x, p.y, GetModalParent());
- PostMessage(WM_NULL);
- break;
- }
-
- case WM_MOUSEMOVE: {
- CString str;
- GetWindowText(str);
- SetTrayTip(str);
- break;
- }
-
- default:
- break;
- }
-
- return 0;
+ if ((UINT)wParam != IDR_MAINFRAME) {
+ return -1;
+ }
+
+ switch ((UINT)lParam) {
+ case WM_LBUTTONDOWN:
+ ShowWindow(SW_SHOW);
+ CreateThumbnailToolbar();
+ MoveVideoWindow();
+ SetForegroundWindow();
+ break;
+
+ case WM_LBUTTONDBLCLK:
+ PostMessage(WM_COMMAND, ID_FILE_OPENMEDIA);
+ break;
+
+ case WM_RBUTTONDOWN: {
+ POINT p;
+ GetCursorPos(&p);
+ SetForegroundWindow();
+ m_popupmain.GetSubMenu(0)->TrackPopupMenu(TPM_RIGHTBUTTON | TPM_NOANIMATION, p.x, p.y, GetModalParent());
+ PostMessage(WM_NULL);
+ break;
+ }
+
+ case WM_MOUSEMOVE: {
+ CString str;
+ GetWindowText(str);
+ SetTrayTip(str);
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ return 0;
}
LRESULT CMainFrame::OnTaskBarThumbnailsCreate(WPARAM, LPARAM)
{
- return CreateThumbnailToolbar();
+ return CreateThumbnailToolbar();
}
void CMainFrame::ShowTrayIcon(bool fShow)
{
- BOOL bWasVisible = ShowWindow(SW_HIDE);
- NOTIFYICONDATA tnid;
-
- ZeroMemory(&tnid, sizeof(NOTIFYICONDATA));
- tnid.cbSize = sizeof(NOTIFYICONDATA);
- tnid.hWnd = m_hWnd;
- tnid.uID = IDR_MAINFRAME;
-
- if (fShow) {
- if (!m_fTrayIcon) {
- tnid.hIcon = (HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
- tnid.uFlags = NIF_MESSAGE|NIF_ICON|NIF_TIP;
- tnid.uCallbackMessage = WM_NOTIFYICON;
- StringCchCopy(tnid.szTip, _countof(tnid.szTip), _T("Media Player Classic"));
- Shell_NotifyIcon(NIM_ADD, &tnid);
-
- m_fTrayIcon = true;
- }
- } else {
- if (m_fTrayIcon) {
- Shell_NotifyIcon(NIM_DELETE, &tnid);
-
- m_fTrayIcon = false;
- }
- }
+ BOOL bWasVisible = ShowWindow(SW_HIDE);
+ NOTIFYICONDATA tnid;
+
+ ZeroMemory(&tnid, sizeof(NOTIFYICONDATA));
+ tnid.cbSize = sizeof(NOTIFYICONDATA);
+ tnid.hWnd = m_hWnd;
+ tnid.uID = IDR_MAINFRAME;
+
+ if (fShow) {
+ if (!m_fTrayIcon) {
+ tnid.hIcon = (HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
+ tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
+ tnid.uCallbackMessage = WM_NOTIFYICON;
+ StringCchCopy(tnid.szTip, _countof(tnid.szTip), _T("Media Player Classic"));
+ Shell_NotifyIcon(NIM_ADD, &tnid);
+
+ m_fTrayIcon = true;
+ }
+ } else {
+ if (m_fTrayIcon) {
+ Shell_NotifyIcon(NIM_DELETE, &tnid);
+
+ m_fTrayIcon = false;
+ }
+ }
- if (bWasVisible) {
- ShowWindow(SW_SHOW);
- }
+ if (bWasVisible) {
+ ShowWindow(SW_SHOW);
+ }
}
void CMainFrame::SetTrayTip(CString str)
{
- NOTIFYICONDATA tnid;
- tnid.cbSize = sizeof(NOTIFYICONDATA);
- tnid.hWnd = m_hWnd;
- tnid.uID = IDR_MAINFRAME;
- tnid.uFlags = NIF_TIP;
- StringCchCopy(tnid.szTip, _countof(tnid.szTip), str);
- Shell_NotifyIcon(NIM_MODIFY, &tnid);
+ NOTIFYICONDATA tnid;
+ tnid.cbSize = sizeof(NOTIFYICONDATA);
+ tnid.hWnd = m_hWnd;
+ tnid.uID = IDR_MAINFRAME;
+ tnid.uFlags = NIF_TIP;
+ StringCchCopy(tnid.szTip, _countof(tnid.szTip), str);
+ Shell_NotifyIcon(NIM_MODIFY, &tnid);
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
- if (!__super::PreCreateWindow(cs)) {
- return FALSE;
- }
+ if (!__super::PreCreateWindow(cs)) {
+ return FALSE;
+ }
- cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
+ cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
- cs.lpszClass = MPC_WND_CLASS_NAME; //AfxRegisterWndClass(0);
+ cs.lpszClass = MPC_WND_CLASS_NAME; //AfxRegisterWndClass(0);
- return TRUE;
+ return TRUE;
}
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
- if (pMsg->message == WM_KEYDOWN) {
- /* if (m_fShockwaveGraph
- && (pMsg->wParam == VK_LEFT || pMsg->wParam == VK_RIGHT
- || pMsg->wParam == VK_UP || pMsg->wParam == VK_DOWN))
- return FALSE;
- */
- if (pMsg->wParam == VK_ESCAPE) {
- bool fEscapeNotAssigned = !AssignedToCmd(VK_ESCAPE, m_fFullScreen, false);
-
- if (fEscapeNotAssigned) {
- if (m_fFullScreen) {
- OnViewFullscreen();
- if (m_iMediaLoadState == MLS_LOADED) {
- PostMessage(WM_COMMAND, ID_PLAY_PAUSE);
- }
- return TRUE;
- } else if (IsCaptionHidden()) {
- PostMessage(WM_COMMAND, ID_VIEW_CAPTIONMENU);
- return TRUE;
- }
- }
- } else if (pMsg->wParam == VK_LEFT && pAMTuner) {
- PostMessage(WM_COMMAND, ID_NAVIGATE_SKIPBACK);
- return TRUE;
- } else if (pMsg->wParam == VK_RIGHT && pAMTuner) {
- PostMessage(WM_COMMAND, ID_NAVIGATE_SKIPFORWARD);
- return TRUE;
- }
- }
-
- return __super::PreTranslateMessage(pMsg);
+ if (pMsg->message == WM_KEYDOWN) {
+ /* if (m_fShockwaveGraph
+ && (pMsg->wParam == VK_LEFT || pMsg->wParam == VK_RIGHT
+ || pMsg->wParam == VK_UP || pMsg->wParam == VK_DOWN))
+ return FALSE;
+ */
+ if (pMsg->wParam == VK_ESCAPE) {
+ bool fEscapeNotAssigned = !AssignedToCmd(VK_ESCAPE, m_fFullScreen, false);
+
+ if (fEscapeNotAssigned) {
+ if (m_fFullScreen) {
+ OnViewFullscreen();
+ if (m_iMediaLoadState == MLS_LOADED) {
+ PostMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ }
+ return TRUE;
+ } else if (IsCaptionHidden()) {
+ PostMessage(WM_COMMAND, ID_VIEW_CAPTIONMENU);
+ return TRUE;
+ }
+ }
+ } else if (pMsg->wParam == VK_LEFT && pAMTuner) {
+ PostMessage(WM_COMMAND, ID_NAVIGATE_SKIPBACK);
+ return TRUE;
+ } else if (pMsg->wParam == VK_RIGHT && pAMTuner) {
+ PostMessage(WM_COMMAND, ID_NAVIGATE_SKIPFORWARD);
+ return TRUE;
+ }
+ }
+
+ return __super::PreTranslateMessage(pMsg);
}
void CMainFrame::RecalcLayout(BOOL bNotify)
{
- __super::RecalcLayout(bNotify);
+ __super::RecalcLayout(bNotify);
- m_wndSeekBar.HideToolTip();
+ m_wndSeekBar.HideToolTip();
- CRect r;
- GetWindowRect(&r);
- MINMAXINFO mmi;
- memset(&mmi, 0, sizeof(mmi));
- SendMessage(WM_GETMINMAXINFO, 0, (LPARAM)&mmi);
- r |= CRect(r.TopLeft(), CSize(r.Width(), mmi.ptMinTrackSize.y));
- MoveWindow(&r);
+ CRect r;
+ GetWindowRect(&r);
+ MINMAXINFO mmi;
+ memset(&mmi, 0, sizeof(mmi));
+ SendMessage(WM_GETMINMAXINFO, 0, (LPARAM)&mmi);
+ r |= CRect(r.TopLeft(), CSize(r.Width(), mmi.ptMinTrackSize.y));
+ MoveWindow(&r);
}
/////////////////////////////////////////////////////////////////////////////
@@ -1177,12 +1177,12 @@ void CMainFrame::RecalcLayout(BOOL bNotify)
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
- __super::AssertValid();
+ __super::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
- __super::Dump(dc);
+ __super::Dump(dc);
}
#endif //_DEBUG
@@ -1191,475 +1191,475 @@ void CMainFrame::Dump(CDumpContext& dc) const
// CMainFrame message handlers
void CMainFrame::OnSetFocus(CWnd* pOldWnd)
{
- SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
+ SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
- // forward focus to the view window
- if (IsWindow(m_wndView.m_hWnd)) {
- m_wndView.SetFocus();
- }
+ // forward focus to the view window
+ if (IsWindow(m_wndView.m_hWnd)) {
+ m_wndView.SetFocus();
+ }
}
BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
- // let the view have first crack at the command
- if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) {
- return TRUE;
- }
+ // let the view have first crack at the command
+ if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) {
+ return TRUE;
+ }
- POSITION pos = m_bars.GetHeadPosition();
- while (pos) {
- if (m_bars.GetNext(pos)->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) {
- return TRUE;
- }
- }
+ POSITION pos = m_bars.GetHeadPosition();
+ while (pos) {
+ if (m_bars.GetNext(pos)->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) {
+ return TRUE;
+ }
+ }
- pos = m_dockingbars.GetHeadPosition();
- while (pos) {
- if (m_dockingbars.GetNext(pos)->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) {
- return TRUE;
- }
- }
+ pos = m_dockingbars.GetHeadPosition();
+ while (pos) {
+ if (m_dockingbars.GetNext(pos)->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) {
+ return TRUE;
+ }
+ }
- // otherwise, do default handling
- return __super::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
+ // otherwise, do default handling
+ return __super::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
void CMainFrame::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
{
- AppSettings &s = AfxGetAppSettings();
- DWORD style = GetStyle();
-
- lpMMI->ptMinTrackSize.x = 16;
- if ( !IsMenuHidden() ) {
- MENUBARINFO mbi;
- memset(&mbi, 0, sizeof(mbi));
- mbi.cbSize = sizeof(mbi);
- ::GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi);
-
- // Calculate menu's horizontal length in pixels
- lpMMI->ptMinTrackSize.x = GetSystemMetrics(SM_CYMENU)/2; //free space after menu
- CRect r;
- for (int i = 0; ::GetMenuItemRect(m_hWnd, mbi.hMenu, i, &r); i++) {
- lpMMI->ptMinTrackSize.x += r.Width();
- }
- }
- if ( IsWindow(m_wndToolBar.m_hWnd) && m_wndToolBar.IsVisible() ) {
- lpMMI->ptMinTrackSize.x = max( m_wndToolBar.GetMinWidth(), lpMMI->ptMinTrackSize.x );
- }
-
- lpMMI->ptMinTrackSize.y = 0;
- if ( style & WS_CAPTION ) {
- lpMMI->ptMinTrackSize.y += GetSystemMetrics( SM_CYCAPTION );
- if (s.iCaptionMenuMode == MODE_SHOWCAPTIONMENU) {
- lpMMI->ptMinTrackSize.y += GetSystemMetrics( SM_CYMENU ); //(mbi.rcBar.bottom - mbi.rcBar.top);
- }
- //else MODE_HIDEMENU
- }
-
- if (style & WS_THICKFRAME) {
- lpMMI->ptMinTrackSize.x += GetSystemMetrics(SM_CXSIZEFRAME) * 2;
- lpMMI->ptMinTrackSize.y += GetSystemMetrics(SM_CYSIZEFRAME) * 2;
- if ( (style & WS_CAPTION) == 0 ) {
- lpMMI->ptMinTrackSize.x -= 2;
- lpMMI->ptMinTrackSize.y -= 2;
- }
- }
-
- POSITION pos = m_bars.GetHeadPosition();
- while ( pos ) {
- CControlBar *pCB = m_bars.GetNext( pos );
- if ( !IsWindow(pCB->m_hWnd) || !pCB->IsVisible() ) {
- continue;
- }
- lpMMI->ptMinTrackSize.y += pCB->CalcFixedLayout(TRUE, TRUE).cy;
- }
-
- pos = m_dockingbars.GetHeadPosition();
- while ( pos ) {
- CSizingControlBar *pCB = m_dockingbars.GetNext( pos );
- if ( IsWindow(pCB->m_hWnd) && pCB->IsWindowVisible() && !pCB->IsFloating() ) {
- lpMMI->ptMinTrackSize.y += pCB->CalcFixedLayout(TRUE, TRUE).cy - 2; // 2 is a magic value from CSizingControlBar class, i guess this should be GetSystemMetrics( SM_CXBORDER ) or similar
- }
- }
- if (lpMMI->ptMinTrackSize.y<16) {
- lpMMI->ptMinTrackSize.y = 16;
- }
-
- __super::OnGetMinMaxInfo( lpMMI );
+ AppSettings& s = AfxGetAppSettings();
+ DWORD style = GetStyle();
+
+ lpMMI->ptMinTrackSize.x = 16;
+ if (!IsMenuHidden()) {
+ MENUBARINFO mbi;
+ memset(&mbi, 0, sizeof(mbi));
+ mbi.cbSize = sizeof(mbi);
+ ::GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi);
+
+ // Calculate menu's horizontal length in pixels
+ lpMMI->ptMinTrackSize.x = GetSystemMetrics(SM_CYMENU) / 2; //free space after menu
+ CRect r;
+ for (int i = 0; ::GetMenuItemRect(m_hWnd, mbi.hMenu, i, &r); i++) {
+ lpMMI->ptMinTrackSize.x += r.Width();
+ }
+ }
+ if (IsWindow(m_wndToolBar.m_hWnd) && m_wndToolBar.IsVisible()) {
+ lpMMI->ptMinTrackSize.x = max(m_wndToolBar.GetMinWidth(), lpMMI->ptMinTrackSize.x);
+ }
+
+ lpMMI->ptMinTrackSize.y = 0;
+ if (style & WS_CAPTION) {
+ lpMMI->ptMinTrackSize.y += GetSystemMetrics(SM_CYCAPTION);
+ if (s.iCaptionMenuMode == MODE_SHOWCAPTIONMENU) {
+ lpMMI->ptMinTrackSize.y += GetSystemMetrics(SM_CYMENU); //(mbi.rcBar.bottom - mbi.rcBar.top);
+ }
+ //else MODE_HIDEMENU
+ }
+
+ if (style & WS_THICKFRAME) {
+ lpMMI->ptMinTrackSize.x += GetSystemMetrics(SM_CXSIZEFRAME) * 2;
+ lpMMI->ptMinTrackSize.y += GetSystemMetrics(SM_CYSIZEFRAME) * 2;
+ if ((style & WS_CAPTION) == 0) {
+ lpMMI->ptMinTrackSize.x -= 2;
+ lpMMI->ptMinTrackSize.y -= 2;
+ }
+ }
+
+ POSITION pos = m_bars.GetHeadPosition();
+ while (pos) {
+ CControlBar* pCB = m_bars.GetNext(pos);
+ if (!IsWindow(pCB->m_hWnd) || !pCB->IsVisible()) {
+ continue;
+ }
+ lpMMI->ptMinTrackSize.y += pCB->CalcFixedLayout(TRUE, TRUE).cy;
+ }
+
+ pos = m_dockingbars.GetHeadPosition();
+ while (pos) {
+ CSizingControlBar* pCB = m_dockingbars.GetNext(pos);
+ if (IsWindow(pCB->m_hWnd) && pCB->IsWindowVisible() && !pCB->IsFloating()) {
+ lpMMI->ptMinTrackSize.y += pCB->CalcFixedLayout(TRUE, TRUE).cy - 2; // 2 is a magic value from CSizingControlBar class, i guess this should be GetSystemMetrics( SM_CXBORDER ) or similar
+ }
+ }
+ if (lpMMI->ptMinTrackSize.y < 16) {
+ lpMMI->ptMinTrackSize.y = 16;
+ }
+
+ __super::OnGetMinMaxInfo(lpMMI);
}
void CMainFrame::OnMove(int x, int y)
{
- __super::OnMove(x, y);
+ __super::OnMove(x, y);
- //MoveVideoWindow(); // This isn't needed, based on my limited tests. If it is needed then please add a description the scenario(s) where it is needed.
- m_wndView.Invalidate();
+ //MoveVideoWindow(); // This isn't needed, based on my limited tests. If it is needed then please add a description the scenario(s) where it is needed.
+ m_wndView.Invalidate();
- WINDOWPLACEMENT wp;
- GetWindowPlacement(&wp);
- if (!m_fFirstFSAfterLaunchOnFS && !m_fFullScreen && wp.flags != WPF_RESTORETOMAXIMIZED && wp.showCmd != SW_SHOWMINIMIZED) {
- GetWindowRect(AfxGetAppSettings().rcLastWindowPos);
- }
+ WINDOWPLACEMENT wp;
+ GetWindowPlacement(&wp);
+ if (!m_fFirstFSAfterLaunchOnFS && !m_fFullScreen && wp.flags != WPF_RESTORETOMAXIMIZED && wp.showCmd != SW_SHOWMINIMIZED) {
+ GetWindowRect(AfxGetAppSettings().rcLastWindowPos);
+ }
}
void CMainFrame::OnMoving(UINT fwSide, LPRECT pRect)
{
- __super::OnMoving(fwSide, pRect);
- m_bWasSnapped = false;
+ __super::OnMoving(fwSide, pRect);
+ m_bWasSnapped = false;
- if (AfxGetAppSettings().fSnapToDesktopEdges) {
- const CPoint threshold(5, 5);
+ if (AfxGetAppSettings().fSnapToDesktopEdges) {
+ const CPoint threshold(5, 5);
- CRect r0 = m_rcDesktop;
- CRect r1 = r0 + threshold;
- CRect r2 = r0 - threshold;
+ CRect r0 = m_rcDesktop;
+ CRect r1 = r0 + threshold;
+ CRect r2 = r0 - threshold;
- RECT& wr = *pRect;
- CSize ws = CRect(wr).Size();
+ RECT& wr = *pRect;
+ CSize ws = CRect(wr).Size();
- if (wr.left < r1.left && wr.left > r2.left) {
- wr.right = (wr.left = r0.left) + ws.cx;
- m_bWasSnapped = true;
- }
+ if (wr.left < r1.left && wr.left > r2.left) {
+ wr.right = (wr.left = r0.left) + ws.cx;
+ m_bWasSnapped = true;
+ }
- if (wr.top < r1.top && wr.top > r2.top) {
- wr.bottom = (wr.top = r0.top) + ws.cy;
- m_bWasSnapped = true;
- }
+ if (wr.top < r1.top && wr.top > r2.top) {
+ wr.bottom = (wr.top = r0.top) + ws.cy;
+ m_bWasSnapped = true;
+ }
- if (wr.right < r1.right && wr.right > r2.right) {
- wr.left = (wr.right = r0.right) - ws.cx;
- m_bWasSnapped = true;
- }
+ if (wr.right < r1.right && wr.right > r2.right) {
+ wr.left = (wr.right = r0.right) - ws.cx;
+ m_bWasSnapped = true;
+ }
- if (wr.bottom < r1.bottom && wr.bottom > r2.bottom) {
- wr.top = (wr.bottom = r0.bottom) - ws.cy;
- m_bWasSnapped = true;
- }
- }
+ if (wr.bottom < r1.bottom && wr.bottom > r2.bottom) {
+ wr.top = (wr.bottom = r0.bottom) - ws.cy;
+ m_bWasSnapped = true;
+ }
+ }
}
void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
- __super::OnSize(nType, cx, cy);
+ __super::OnSize(nType, cx, cy);
- m_OSD.OnSize (nType, cx, cy);
+ m_OSD.OnSize(nType, cx, cy);
- if (nType == SIZE_RESTORED && m_fTrayIcon) {
- ShowWindow(SW_SHOW);
- }
+ if (nType == SIZE_RESTORED && m_fTrayIcon) {
+ ShowWindow(SW_SHOW);
+ }
- if (!m_fFirstFSAfterLaunchOnFS && IsWindowVisible() && !m_fFullScreen) {
- AppSettings& s = AfxGetAppSettings();
- if (nType != SIZE_MAXIMIZED && nType != SIZE_MINIMIZED) {
- GetWindowRect(s.rcLastWindowPos);
- }
- s.nLastWindowType = nType;
- }
+ if (!m_fFirstFSAfterLaunchOnFS && IsWindowVisible() && !m_fFullScreen) {
+ AppSettings& s = AfxGetAppSettings();
+ if (nType != SIZE_MAXIMIZED && nType != SIZE_MINIMIZED) {
+ GetWindowRect(s.rcLastWindowPos);
+ }
+ s.nLastWindowType = nType;
+ }
}
void CMainFrame::OnSizing(UINT fwSide, LPRECT pRect)
{
- __super::OnSizing(fwSide, pRect);
-
- AppSettings& s = AfxGetAppSettings();
-
- bool fCtrl = !!(GetAsyncKeyState(VK_CONTROL)&0x80000000);
-
- if (m_iMediaLoadState != MLS_LOADED || m_fFullScreen
- || s.iDefaultVideoSize == DVS_STRETCH
- || (fCtrl == s.fLimitWindowProportions)) { // remember that fCtrl is initialized with !!whatever(), same with fLimitWindowProportions
- return;
- }
-
- CSize wsize(pRect->right - pRect->left, pRect->bottom - pRect->top);
- CSize vsize = GetVideoSize();
- CSize fsize(0, 0);
-
- if (!vsize.cx || !vsize.cy) {
- return;
- }
-
- // TODO
- {
- DWORD style = GetStyle();
-
- // This doesn't give correct menu pixel size
- //MENUBARINFO mbi;
- //memset(&mbi, 0, sizeof(mbi));
- //mbi.cbSize = sizeof(mbi);
- //::GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi);
-
- if (style & WS_THICKFRAME) {
- fsize.cx += GetSystemMetrics( SM_CXSIZEFRAME ) * 2;
- fsize.cy += GetSystemMetrics( SM_CYSIZEFRAME ) * 2;
- if ( (style & WS_CAPTION) == 0 ) {
- fsize.cx -= 2;
- fsize.cy -= 2;
- }
- }
-
- if ( style & WS_CAPTION ) {
- fsize.cy += GetSystemMetrics( SM_CYCAPTION );
- if (s.iCaptionMenuMode == MODE_SHOWCAPTIONMENU) {
- fsize.cy += GetSystemMetrics( SM_CYMENU ); //mbi.rcBar.bottom - mbi.rcBar.top;
- }
- //else MODE_HIDEMENU
- }
-
- POSITION pos = m_bars.GetHeadPosition();
- while ( pos ) {
- CControlBar * pCB = m_bars.GetNext( pos );
- if ( IsWindow(pCB->m_hWnd) && pCB->IsVisible() ) {
- fsize.cy += pCB->CalcFixedLayout(TRUE, TRUE).cy;
- }
- }
-
- pos = m_dockingbars.GetHeadPosition();
- while ( pos ) {
- CSizingControlBar *pCB = m_dockingbars.GetNext( pos );
-
- if ( IsWindow(pCB->m_hWnd) && pCB->IsWindowVisible() && !pCB->IsFloating() ) {
- if ( pCB->IsHorzDocked() ) {
- fsize.cy += pCB->CalcFixedLayout(TRUE, TRUE).cy - 2;
- } else if ( pCB->IsVertDocked() ) {
- fsize.cx += pCB->CalcFixedLayout(TRUE, FALSE).cx;
- }
- }
- }
- }
-
- wsize -= fsize;
-
- bool fWider = wsize.cy < wsize.cx;
-
- wsize.SetSize(
- wsize.cy * vsize.cx / vsize.cy,
- wsize.cx * vsize.cy / vsize.cx);
-
- wsize += fsize;
-
- if (fwSide == WMSZ_TOP || fwSide == WMSZ_BOTTOM || !fWider && (fwSide == WMSZ_TOPRIGHT || fwSide == WMSZ_BOTTOMRIGHT)) {
- pRect->right = pRect->left + wsize.cx;
- } else if (fwSide == WMSZ_LEFT || fwSide == WMSZ_RIGHT || fWider && (fwSide == WMSZ_BOTTOMLEFT || fwSide == WMSZ_BOTTOMRIGHT)) {
- pRect->bottom = pRect->top + wsize.cy;
- } else if (!fWider && (fwSide == WMSZ_TOPLEFT || fwSide == WMSZ_BOTTOMLEFT)) {
- pRect->left = pRect->right - wsize.cx;
- } else if (fWider && (fwSide == WMSZ_TOPLEFT || fwSide == WMSZ_TOPRIGHT)) {
- pRect->top = pRect->bottom - wsize.cy;
- }
+ __super::OnSizing(fwSide, pRect);
+
+ AppSettings& s = AfxGetAppSettings();
+
+ bool fCtrl = !!(GetAsyncKeyState(VK_CONTROL) & 0x80000000);
+
+ if (m_iMediaLoadState != MLS_LOADED || m_fFullScreen
+ || s.iDefaultVideoSize == DVS_STRETCH
+ || (fCtrl == s.fLimitWindowProportions)) { // remember that fCtrl is initialized with !!whatever(), same with fLimitWindowProportions
+ return;
+ }
+
+ CSize wsize(pRect->right - pRect->left, pRect->bottom - pRect->top);
+ CSize vsize = GetVideoSize();
+ CSize fsize(0, 0);
+
+ if (!vsize.cx || !vsize.cy) {
+ return;
+ }
+
+ // TODO
+ {
+ DWORD style = GetStyle();
+
+ // This doesn't give correct menu pixel size
+ //MENUBARINFO mbi;
+ //memset(&mbi, 0, sizeof(mbi));
+ //mbi.cbSize = sizeof(mbi);
+ //::GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi);
+
+ if (style & WS_THICKFRAME) {
+ fsize.cx += GetSystemMetrics(SM_CXSIZEFRAME) * 2;
+ fsize.cy += GetSystemMetrics(SM_CYSIZEFRAME) * 2;
+ if ((style & WS_CAPTION) == 0) {
+ fsize.cx -= 2;
+ fsize.cy -= 2;
+ }
+ }
+
+ if (style & WS_CAPTION) {
+ fsize.cy += GetSystemMetrics(SM_CYCAPTION);
+ if (s.iCaptionMenuMode == MODE_SHOWCAPTIONMENU) {
+ fsize.cy += GetSystemMetrics(SM_CYMENU); //mbi.rcBar.bottom - mbi.rcBar.top;
+ }
+ //else MODE_HIDEMENU
+ }
+
+ POSITION pos = m_bars.GetHeadPosition();
+ while (pos) {
+ CControlBar* pCB = m_bars.GetNext(pos);
+ if (IsWindow(pCB->m_hWnd) && pCB->IsVisible()) {
+ fsize.cy += pCB->CalcFixedLayout(TRUE, TRUE).cy;
+ }
+ }
+
+ pos = m_dockingbars.GetHeadPosition();
+ while (pos) {
+ CSizingControlBar* pCB = m_dockingbars.GetNext(pos);
+
+ if (IsWindow(pCB->m_hWnd) && pCB->IsWindowVisible() && !pCB->IsFloating()) {
+ if (pCB->IsHorzDocked()) {
+ fsize.cy += pCB->CalcFixedLayout(TRUE, TRUE).cy - 2;
+ } else if (pCB->IsVertDocked()) {
+ fsize.cx += pCB->CalcFixedLayout(TRUE, FALSE).cx;
+ }
+ }
+ }
+ }
+
+ wsize -= fsize;
+
+ bool fWider = wsize.cy < wsize.cx;
+
+ wsize.SetSize(
+ wsize.cy * vsize.cx / vsize.cy,
+ wsize.cx * vsize.cy / vsize.cx);
+
+ wsize += fsize;
+
+ if (fwSide == WMSZ_TOP || fwSide == WMSZ_BOTTOM || !fWider && (fwSide == WMSZ_TOPRIGHT || fwSide == WMSZ_BOTTOMRIGHT)) {
+ pRect->right = pRect->left + wsize.cx;
+ } else if (fwSide == WMSZ_LEFT || fwSide == WMSZ_RIGHT || fWider && (fwSide == WMSZ_BOTTOMLEFT || fwSide == WMSZ_BOTTOMRIGHT)) {
+ pRect->bottom = pRect->top + wsize.cy;
+ } else if (!fWider && (fwSide == WMSZ_TOPLEFT || fwSide == WMSZ_BOTTOMLEFT)) {
+ pRect->left = pRect->right - wsize.cx;
+ } else if (fWider && (fwSide == WMSZ_TOPLEFT || fwSide == WMSZ_TOPRIGHT)) {
+ pRect->top = pRect->bottom - wsize.cy;
+ }
}
void CMainFrame::OnDisplayChange() // untested, not sure if it's working...
{
- TRACE(_T("*** CMainFrame::OnDisplayChange()\n"));
-
- GetDesktopWindow()->GetWindowRect(&m_rcDesktop);
- if (m_pFullscreenWnd && m_pFullscreenWnd->IsWindow()) {
- MONITORINFO MonitorInfo;
- HMONITOR hMonitor;
- ZeroMemory (&MonitorInfo, sizeof(MonitorInfo));
- MonitorInfo.cbSize = sizeof(MonitorInfo);
- hMonitor = MonitorFromWindow (m_pFullscreenWnd->m_hWnd, 0);
- if (GetMonitorInfo (hMonitor, &MonitorInfo)) {
- CRect MonitorRect = CRect (MonitorInfo.rcMonitor);
- m_fullWndSize.cx = MonitorRect.Width();
- m_fullWndSize.cy = MonitorRect.Height();
- m_pFullscreenWnd->SetWindowPos (NULL,
- MonitorRect.left,
- MonitorRect.top,
- MonitorRect.Width(),
- MonitorRect.Height(), SWP_NOZORDER);
- MoveVideoWindow();
- }
- }
-
- AppSettings& s = AfxGetAppSettings();
- if (s.iDSVideoRendererType != VIDRNDT_DS_MADVR && s.iDSVideoRendererType != VIDRNDT_DS_DXR) {
- IDirect3D9* pD3D9 = NULL;
- DWORD m_nPCIVendor = 0;
-
- pD3D9 = Direct3DCreate9(D3D_SDK_VERSION);
- if (pD3D9) {
- D3DADAPTER_IDENTIFIER9 adapterIdentifier;
- if (pD3D9->GetAdapterIdentifier(GetAdapter(pD3D9, m_hWnd), 0, &adapterIdentifier) == S_OK) {
- m_nPCIVendor = adapterIdentifier.VendorId;
- }
- pD3D9->Release();
- }
-
- if (m_nPCIVendor == 0x8086) { // Disable ResetDevice for Intel, until can fix ...
- return;
- }
- }
-
- if (m_iMediaLoadState == MLS_LOADED) {
- if (m_pGraphThread) {
- m_pGraphThread->PostThreadMessage(CGraphThread::TM_DISPLAY_CHANGE, 0, 0);
- } else {
- DisplayChange();
- }
- }
+ TRACE(_T("*** CMainFrame::OnDisplayChange()\n"));
+
+ GetDesktopWindow()->GetWindowRect(&m_rcDesktop);
+ if (m_pFullscreenWnd && m_pFullscreenWnd->IsWindow()) {
+ MONITORINFO MonitorInfo;
+ HMONITOR hMonitor;
+ ZeroMemory(&MonitorInfo, sizeof(MonitorInfo));
+ MonitorInfo.cbSize = sizeof(MonitorInfo);
+ hMonitor = MonitorFromWindow(m_pFullscreenWnd->m_hWnd, 0);
+ if (GetMonitorInfo(hMonitor, &MonitorInfo)) {
+ CRect MonitorRect = CRect(MonitorInfo.rcMonitor);
+ m_fullWndSize.cx = MonitorRect.Width();
+ m_fullWndSize.cy = MonitorRect.Height();
+ m_pFullscreenWnd->SetWindowPos(NULL,
+ MonitorRect.left,
+ MonitorRect.top,
+ MonitorRect.Width(),
+ MonitorRect.Height(), SWP_NOZORDER);
+ MoveVideoWindow();
+ }
+ }
+
+ AppSettings& s = AfxGetAppSettings();
+ if (s.iDSVideoRendererType != VIDRNDT_DS_MADVR && s.iDSVideoRendererType != VIDRNDT_DS_DXR) {
+ IDirect3D9* pD3D9 = NULL;
+ DWORD m_nPCIVendor = 0;
+
+ pD3D9 = Direct3DCreate9(D3D_SDK_VERSION);
+ if (pD3D9) {
+ D3DADAPTER_IDENTIFIER9 adapterIdentifier;
+ if (pD3D9->GetAdapterIdentifier(GetAdapter(pD3D9, m_hWnd), 0, &adapterIdentifier) == S_OK) {
+ m_nPCIVendor = adapterIdentifier.VendorId;
+ }
+ pD3D9->Release();
+ }
+
+ if (m_nPCIVendor == 0x8086) { // Disable ResetDevice for Intel, until can fix ...
+ return;
+ }
+ }
+
+ if (m_iMediaLoadState == MLS_LOADED) {
+ if (m_pGraphThread) {
+ m_pGraphThread->PostThreadMessage(CGraphThread::TM_DISPLAY_CHANGE, 0, 0);
+ } else {
+ DisplayChange();
+ }
+ }
}
void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
- // Only stop screensaver if video playing; allow for audio only
- if ((GetMediaState() == State_Running && !m_fAudioOnly) && (((nID & 0xFFF0) == SC_SCREENSAVE) || ((nID & 0xFFF0) == SC_MONITORPOWER))) {
- TRACE(_T("SC_SCREENSAVE, nID = %d, lParam = %d\n"), nID, lParam);
- return;
- } else if ((nID & 0xFFF0) == SC_MINIMIZE && m_fTrayIcon) {
- ShowWindow(SW_HIDE);
- return;
- }
+ // Only stop screensaver if video playing; allow for audio only
+ if ((GetMediaState() == State_Running && !m_fAudioOnly) && (((nID & 0xFFF0) == SC_SCREENSAVE) || ((nID & 0xFFF0) == SC_MONITORPOWER))) {
+ TRACE(_T("SC_SCREENSAVE, nID = %d, lParam = %d\n"), nID, lParam);
+ return;
+ } else if ((nID & 0xFFF0) == SC_MINIMIZE && m_fTrayIcon) {
+ ShowWindow(SW_HIDE);
+ return;
+ }
- __super::OnSysCommand(nID, lParam);
+ __super::OnSysCommand(nID, lParam);
}
void CMainFrame::OnActivateApp(BOOL bActive, DWORD dwThreadID)
{
- __super::OnActivateApp(bActive, dwThreadID);
+ __super::OnActivateApp(bActive, dwThreadID);
- if (AfxGetAppSettings().iOnTop) {
- return;
- }
+ if (AfxGetAppSettings().iOnTop) {
+ return;
+ }
- MONITORINFO mi;
- mi.cbSize = sizeof(MONITORINFO);
- GetMonitorInfo(MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST), &mi);
+ MONITORINFO mi;
+ mi.cbSize = sizeof(MONITORINFO);
+ GetMonitorInfo(MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST), &mi);
- if (!bActive && (mi.dwFlags&MONITORINFOF_PRIMARY) && m_fFullScreen && m_iMediaLoadState == MLS_LOADED) {
- bool fExitFullscreen = true;
+ if (!bActive && (mi.dwFlags & MONITORINFOF_PRIMARY) && m_fFullScreen && m_iMediaLoadState == MLS_LOADED) {
+ bool fExitFullscreen = true;
- if (CWnd* pWnd = GetForegroundWindow()) {
- HMONITOR hMonitor1 = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- HMONITOR hMonitor2 = MonitorFromWindow(pWnd->m_hWnd, MONITOR_DEFAULTTONEAREST);
- CMonitors monitors;
- if (hMonitor1 && hMonitor2 && ((hMonitor1 != hMonitor2) || (monitors.GetCount()>1))) {
- fExitFullscreen = false;
- }
+ if (CWnd* pWnd = GetForegroundWindow()) {
+ HMONITOR hMonitor1 = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+ HMONITOR hMonitor2 = MonitorFromWindow(pWnd->m_hWnd, MONITOR_DEFAULTTONEAREST);
+ CMonitors monitors;
+ if (hMonitor1 && hMonitor2 && ((hMonitor1 != hMonitor2) || (monitors.GetCount() > 1))) {
+ fExitFullscreen = false;
+ }
- CString title;
- pWnd->GetWindowText(title);
+ CString title;
+ pWnd->GetWindowText(title);
- CString module;
+ CString module;
- DWORD pid;
- GetWindowThreadProcessId(pWnd->m_hWnd, &pid);
+ DWORD pid;
+ GetWindowThreadProcessId(pWnd->m_hWnd, &pid);
- if (HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid)) {
- HMODULE hMod;
- DWORD cbNeeded;
+ if (HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid)) {
+ HMODULE hMod;
+ DWORD cbNeeded;
- if (EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cbNeeded)) {
- module.ReleaseBufferSetLength(GetModuleFileNameEx(hProcess, hMod, module.GetBuffer(_MAX_PATH), _MAX_PATH));
- }
+ if (EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cbNeeded)) {
+ module.ReleaseBufferSetLength(GetModuleFileNameEx(hProcess, hMod, module.GetBuffer(_MAX_PATH), _MAX_PATH));
+ }
- CloseHandle(hProcess);
- }
+ CloseHandle(hProcess);
+ }
- CPath p(module);
- p.StripPath();
- module = (LPCTSTR)p;
- module.MakeLower();
+ CPath p(module);
+ p.StripPath();
+ module = (LPCTSTR)p;
+ module.MakeLower();
- CString str;
- str.Format(IDS_MAINFRM_2, module, title);
- SendStatusMessage(str, 5000);
- }
+ CString str;
+ str.Format(IDS_MAINFRM_2, module, title);
+ SendStatusMessage(str, 5000);
+ }
- if (fExitFullscreen) {
- OnViewFullscreen();
- }
- }
+ if (fExitFullscreen) {
+ OnViewFullscreen();
+ }
+ }
}
LRESULT CMainFrame::OnAppCommand(WPARAM wParam, LPARAM lParam)
{
- UINT cmd = GET_APPCOMMAND_LPARAM(lParam);
- UINT uDevice = GET_DEVICE_LPARAM(lParam);
+ UINT cmd = GET_APPCOMMAND_LPARAM(lParam);
+ UINT uDevice = GET_DEVICE_LPARAM(lParam);
- if (uDevice != FAPPCOMMAND_OEM ||
- cmd == APPCOMMAND_MEDIA_PLAY || cmd == APPCOMMAND_MEDIA_PAUSE || cmd == APPCOMMAND_MEDIA_CHANNEL_UP ||
- cmd == APPCOMMAND_MEDIA_CHANNEL_DOWN || cmd == APPCOMMAND_MEDIA_RECORD ||
- cmd == APPCOMMAND_MEDIA_FAST_FORWARD || cmd == APPCOMMAND_MEDIA_REWIND ) {
- AppSettings& s = AfxGetAppSettings();
+ if (uDevice != FAPPCOMMAND_OEM ||
+ cmd == APPCOMMAND_MEDIA_PLAY || cmd == APPCOMMAND_MEDIA_PAUSE || cmd == APPCOMMAND_MEDIA_CHANNEL_UP ||
+ cmd == APPCOMMAND_MEDIA_CHANNEL_DOWN || cmd == APPCOMMAND_MEDIA_RECORD ||
+ cmd == APPCOMMAND_MEDIA_FAST_FORWARD || cmd == APPCOMMAND_MEDIA_REWIND) {
+ AppSettings& s = AfxGetAppSettings();
- BOOL fRet = FALSE;
+ BOOL fRet = FALSE;
- POSITION pos = s.wmcmds.GetHeadPosition();
- while (pos) {
- wmcmd& wc = s.wmcmds.GetNext(pos);
- if (wc.appcmd == cmd && TRUE == SendMessage(WM_COMMAND, wc.cmd)) {
- fRet = TRUE;
- }
- }
+ POSITION pos = s.wmcmds.GetHeadPosition();
+ while (pos) {
+ wmcmd& wc = s.wmcmds.GetNext(pos);
+ if (wc.appcmd == cmd && TRUE == SendMessage(WM_COMMAND, wc.cmd)) {
+ fRet = TRUE;
+ }
+ }
- if (fRet) {
- return TRUE;
- }
- }
+ if (fRet) {
+ return TRUE;
+ }
+ }
- return Default();
+ return Default();
}
void CMainFrame::OnRawInput(UINT nInputcode, HRAWINPUT hRawInput)
{
- AppSettings& s = AfxGetAppSettings();
- UINT nMceCmd = 0;
-
- nMceCmd = AfxGetMyApp()->GetRemoteControlCode (nInputcode, hRawInput);
- switch (nMceCmd) {
- case MCE_DETAILS :
- case MCE_GUIDE :
- case MCE_TVJUMP :
- case MCE_STANDBY :
- case MCE_OEM1 :
- case MCE_OEM2 :
- case MCE_MYTV :
- case MCE_MYVIDEOS :
- case MCE_MYPICTURES :
- case MCE_MYMUSIC :
- case MCE_RECORDEDTV :
- case MCE_DVDANGLE :
- case MCE_DVDAUDIO :
- case MCE_DVDMENU :
- case MCE_DVDSUBTITLE :
- case MCE_RED :
- case MCE_GREEN :
- case MCE_YELLOW :
- case MCE_BLUE :
- case MCE_MEDIA_NEXTTRACK :
- case MCE_MEDIA_PREVIOUSTRACK :
- POSITION pos = s.wmcmds.GetHeadPosition();
- while (pos) {
- wmcmd& wc = s.wmcmds.GetNext(pos);
- if (wc.appcmd == nMceCmd) {
- SendMessage(WM_COMMAND, wc.cmd);
- break;
- }
- }
- break;
- }
+ AppSettings& s = AfxGetAppSettings();
+ UINT nMceCmd = 0;
+
+ nMceCmd = AfxGetMyApp()->GetRemoteControlCode(nInputcode, hRawInput);
+ switch (nMceCmd) {
+ case MCE_DETAILS :
+ case MCE_GUIDE :
+ case MCE_TVJUMP :
+ case MCE_STANDBY :
+ case MCE_OEM1 :
+ case MCE_OEM2 :
+ case MCE_MYTV :
+ case MCE_MYVIDEOS :
+ case MCE_MYPICTURES :
+ case MCE_MYMUSIC :
+ case MCE_RECORDEDTV :
+ case MCE_DVDANGLE :
+ case MCE_DVDAUDIO :
+ case MCE_DVDMENU :
+ case MCE_DVDSUBTITLE :
+ case MCE_RED :
+ case MCE_GREEN :
+ case MCE_YELLOW :
+ case MCE_BLUE :
+ case MCE_MEDIA_NEXTTRACK :
+ case MCE_MEDIA_PREVIOUSTRACK :
+ POSITION pos = s.wmcmds.GetHeadPosition();
+ while (pos) {
+ wmcmd& wc = s.wmcmds.GetNext(pos);
+ if (wc.appcmd == nMceCmd) {
+ SendMessage(WM_COMMAND, wc.cmd);
+ break;
+ }
+ }
+ break;
+ }
}
LRESULT CMainFrame::OnHotKey(WPARAM wParam, LPARAM lParam)
{
- AppSettings& s = AfxGetAppSettings();
- BOOL fRet = FALSE;
+ AppSettings& s = AfxGetAppSettings();
+ BOOL fRet = FALSE;
- if (GetActiveWindow() == this || s.fGlobalMedia == TRUE) {
- POSITION pos = s.wmcmds.GetHeadPosition();
+ if (GetActiveWindow() == this || s.fGlobalMedia == TRUE) {
+ POSITION pos = s.wmcmds.GetHeadPosition();
- while (pos) {
- wmcmd& wc = s.wmcmds.GetNext(pos);
- if (wc.appcmd == wParam && TRUE == SendMessage(WM_COMMAND, wc.cmd)) {
- fRet = TRUE;
- }
- }
- }
+ while (pos) {
+ wmcmd& wc = s.wmcmds.GetNext(pos);
+ if (wc.appcmd == wParam && TRUE == SendMessage(WM_COMMAND, wc.cmd)) {
+ fRet = TRUE;
+ }
+ }
+ }
- return fRet;
+ return fRet;
}
bool g_bNoDuration = false;
@@ -1667,565 +1667,565 @@ bool g_bExternalSubtitleTime = false;
void CMainFrame::OnTimer(UINT_PTR nIDEvent)
{
- switch (nIDEvent) {
- case TIMER_STREAMPOSPOLLER:
- if (m_iMediaLoadState == MLS_LOADED) {
- REFERENCE_TIME rtNow = 0, rtDur = 0;
-
- if (GetPlaybackMode() == PM_FILE) {
- pMS->GetCurrentPosition(&rtNow);
- pMS->GetDuration(&rtDur);
-
- // Casimir666 : autosave subtitle sync after play
- if ((m_nCurSubtitle >= 0) && (m_rtCurSubPos != rtNow)) {
- if (m_lSubtitleShift != 0) {
- if (m_wndSubresyncBar.SaveToDisk()) {
- m_OSD.DisplayMessage (OSD_TOPLEFT, ResStr(IDS_AG_SUBTITLES_SAVED), 500);
- } else {
- m_OSD.DisplayMessage (OSD_TOPLEFT, ResStr(IDS_MAINFRM_4));
- }
- }
- m_nCurSubtitle = -1;
- m_lSubtitleShift = 0;
- }
-
- if (!m_fEndOfStream) {
- AppSettings& s = AfxGetAppSettings();
- FILE_POSITION* FilePosition = s.CurrentFilePosition();
- if (FilePosition) {
- FilePosition->llPosition = rtNow;
-
- LARGE_INTEGER time;
- QueryPerformanceCounter(&time);
- LARGE_INTEGER freq;
- QueryPerformanceFrequency(&freq);
- if ((time.QuadPart - m_LastSaveTime.QuadPart) >= 30 * freq.QuadPart) { // save every half of minute
- m_LastSaveTime = time;
- if (s.fKeepHistory && s.fRememberFilePos) {
- s.SaveCurrentFilePosition();
- }
- }
- }
- }
-
- if (m_rtDurationOverride >= 0) {
- rtDur = m_rtDurationOverride;
- }
-
- g_bNoDuration = rtDur <= 0;
- m_wndSeekBar.Enable(rtDur > 0);
- m_wndSeekBar.SetRange(0, rtDur);
- m_wndSeekBar.SetPos(rtNow);
- m_OSD.SetRange (0, rtDur);
- m_OSD.SetPos (rtNow);
- //m_Lcd.SetMediaRange(0, rtDur);
- //m_Lcd.SetMediaPos(rtNow);
- } else if (GetPlaybackMode() == PM_CAPTURE) {
- pMS->GetCurrentPosition(&rtNow);
- if (m_fCapturing && m_wndCaptureBar.m_capdlg.m_pMux) {
- CComQIPtr<IMediaSeeking> pMuxMS = m_wndCaptureBar.m_capdlg.m_pMux;
- if (!pMuxMS || FAILED(pMuxMS->GetCurrentPosition(&rtNow))) {
- rtNow = 0;
- }
- }
-
- if (m_rtDurationOverride >= 0) {
- rtDur = m_rtDurationOverride;
- }
-
- g_bNoDuration = rtDur <= 0;
- m_wndSeekBar.Enable(false);
- m_wndSeekBar.SetRange(0, rtDur);
- m_wndSeekBar.SetPos(rtNow);
- m_OSD.SetRange (0, rtDur);
- m_OSD.SetPos (rtNow);
- //m_Lcd.SetMediaRange(0, rtDur);
- //m_Lcd.SetMediaPos(rtNow);
- }
-
- if (m_pCAP && GetPlaybackMode() != PM_FILE) {
- g_bExternalSubtitleTime = true;
- if (pDVDI) {
- DVD_PLAYBACK_LOCATION2 Location;
- if (pDVDI->GetCurrentLocation(&Location) == S_OK) {
- double fps = Location.TimeCodeFlags == DVD_TC_FLAG_25fps ? 25.0
- : Location.TimeCodeFlags == DVD_TC_FLAG_30fps ? 30.0
- : Location.TimeCodeFlags == DVD_TC_FLAG_DropFrame ? 29.97
- : 25.0;
-
- LONGLONG rtTimeCode = HMSF2RT(Location.TimeCode, fps);
- m_pCAP->SetTime(rtTimeCode);
- } else {
- m_pCAP->SetTime(/*rtNow*/m_wndSeekBar.GetPos());
- }
- } else {
- // Set rtNow to support DVB subtitle
- m_pCAP->SetTime(rtNow);
- }
- } else {
- g_bExternalSubtitleTime = false;
- }
- }
- break;
- case TIMER_STREAMPOSPOLLER2:
- if (m_iMediaLoadState == MLS_LOADED) {
- __int64 start, stop, pos;
- m_wndSeekBar.GetRange(start, stop);
- pos = m_wndSeekBar.GetPosReal();
-
- GUID tf;
- pMS->GetTimeFormat(&tf);
-
- if (GetPlaybackMode() == PM_CAPTURE && !m_fCapturing) {
- CString str = ResStr(IDS_CAPTURE_LIVE);
-
- long lChannel = 0, lVivSub = 0, lAudSub = 0;
- if (pAMTuner
- && m_wndCaptureBar.m_capdlg.IsTunerActive()
- && SUCCEEDED(pAMTuner->get_Channel(&lChannel, &lVivSub, &lAudSub))) {
- CString ch;
- ch.Format(_T(" (ch%d)"), lChannel);
- str += ch;
- }
-
- m_wndStatusBar.SetStatusTimer(str);
- } else {
- m_wndStatusBar.SetStatusTimer(pos, stop, !!m_wndSubresyncBar.IsWindowVisible(), &tf);
- if (m_bRemainingTime) {
- m_OSD.DisplayMessage(OSD_TOPLEFT, m_wndStatusBar.GetStatusTimer());
- }
- }
-
- m_wndSubresyncBar.SetTime(pos);
-
- if (m_pCAP && GetMediaState() == State_Paused) {
- m_pCAP->Paint(false);
- }
- }
- break;
- case TIMER_FULLSCREENCONTROLBARHIDER: {
- CPoint p;
- GetCursorPos(&p);
-
- CRect r;
- GetWindowRect(r);
- bool fCursorOutside = !r.PtInRect(p);
-
- CWnd* pWnd = WindowFromPoint(p);
- if (pWnd && (m_wndView == *pWnd || m_wndView.IsChild(pWnd) || fCursorOutside)) {
- if (AfxGetAppSettings().nShowBarsWhenFullScreenTimeOut >= 0) {
- ShowControls(CS_NONE);
- }
- }
- }
- break;
- case TIMER_FULLSCREENMOUSEHIDER: {
- CPoint p;
- GetCursorPos(&p);
-
- CRect r;
- GetWindowRect(r);
- bool fCursorOutside = !r.PtInRect(p);
- CWnd* pWnd = WindowFromPoint(p);
- if (m_pFullscreenWnd->IsWindow()) {
- TRACE ("==> HIDE!\n");
- if (!m_bInOptions && pWnd == m_pFullscreenWnd) {
- m_pFullscreenWnd->ShowCursor(false);
- }
- KillTimer(TIMER_FULLSCREENMOUSEHIDER);
- } else {
- CWnd* pWnd = WindowFromPoint(p);
- if (pWnd && !m_bInOptions && (m_wndView == *pWnd || m_wndView.IsChild(pWnd) || fCursorOutside)) {
- m_fHideCursor = true;
- SetCursor(NULL);
- }
- }
- }
- break;
- case TIMER_STATS: {
- if (pQP) {
- CString rate;
- if (m_iSpeedLevel >= -11 && m_iSpeedLevel <= 3 && m_iSpeedLevel != -4) {
- CString speeds[] = {_T("1/8"),_T("1/4"),_T("1/2"),_T("1"),_T("2"),_T("4"),_T("8")};
- rate = speeds[(m_iSpeedLevel >= -3 ? m_iSpeedLevel : (-m_iSpeedLevel - 8)) + 3];
- if (m_iSpeedLevel < -4) {
- rate = _T("-") + rate;
- }
- if (!rate.IsEmpty()) {
- rate = _T("(") + rate + _T("X)");
- }
- }
-
- CString info;
- int val = 0;
-
- /*
- Reproduce:
- 1. Start a video
- 2. Pause video
- 3. Hibernate computer
- 4. Start computer again
- MPC-HC window should now be hung
-
- Stack dump from a Windows 7 64-bit machine:
- Thread 1:
- ntdll_77d30000!ZwWaitForSingleObject+0x15
- ntdll_77d30000!RtlpWaitOnCriticalSection+0x13e
- ntdll_77d30000!RtlEnterCriticalSection+0x150
- QUARTZ!CBlockLock<CKsOpmLib>::CBlockLock<CKsOpmLib>+0x14 <- Lock
- QUARTZ!CImageSync::get_AvgFrameRate+0x24
- QUARTZ!CVMRFilter::get_AvgFrameRate+0x31
- mpc_hc!CMainFrame::OnTimer+0xb80
- mpc_hc!CWnd::OnWndMsg+0x3e8
- mpc_hc!CWnd::WindowProc+0x24
- mpc_hc!CMainFrame::WindowProc+0x15e
- mpc_hc!AfxCallWndProc+0xac
- mpc_hc!AfxWndProc+0x36
- USER32!InternalCallWinProc+0x23
- USER32!UserCallWinProcCheckWow+0x109
- USER32!DispatchMessageWorker+0x3bc
- USER32!DispatchMessageW+0xf
- mpc_hc!AfxInternalPumpMessage+0x40
- mpc_hc!CWinThread::Run+0x5b
- mpc_hc!AfxWinMain+0x69
- mpc_hc!__tmainCRTStartup+0x11a
-
- Thread 2:
- ntdll_77d30000!ZwWaitForSingleObject+0x15
- ntdll_77d30000!RtlpWaitOnCriticalSection+0x13e
- ntdll_77d30000!RtlEnterCriticalSection+0x150
- QUARTZ!CBlockLock<CKsOpmLib>::CBlockLock<CKsOpmLib>+0x14 <- Lock
- QUARTZ!VMR9::CVMRFilter::NonDelegatingQueryInterface+0x1b
- mpc_hc!DSObjects::COuterVMR9::NonDelegatingQueryInterface+0x5b
- mpc_hc!CMacrovisionKicker::NonDelegatingQueryInterface+0xdc
- QUARTZ!CImageSync::QueryInterface+0x16
- QUARTZ!VMR9::CVMRFilter::CIImageSyncNotifyEvent::QueryInterface+0x19
- mpc_hc!DSObjects::CVMR9AllocatorPresenter::PresentImage+0xa9
- QUARTZ!VMR9::CVMRFilter::CIVMRImagePresenter::PresentImage+0x2c
- QUARTZ!VMR9::CImageSync::DoRenderSample+0xd5
- QUARTZ!VMR9::CImageSync::ReceiveWorker+0xad
- QUARTZ!VMR9::CImageSync::Receive+0x46
- QUARTZ!VMR9::CVideoMixer::CompositeTheStreamsTogether+0x24f
- QUARTZ!VMR9::CVideoMixer::MixerThread+0x184
- QUARTZ!VMR9::CVideoMixer::MixerThreadProc+0xd
- KERNEL32!BaseThreadInitThunk+0xe
- ntdll_77d30000!__RtlUserThreadStart+0x70
- ntdll_77d30000!_RtlUserThreadStart+0x1b
-
- There can be a bug in QUARTZ or more likely mpc-hc is doing something wrong
- */
- pQP->get_AvgFrameRate(&val); // We hang here due to a lock that never gets released.
- info.Format(_T("%d.%02d %s"), val / 100, val % 100, rate);
- m_wndStatsBar.SetLine(ResStr(IDS_AG_FRAMERATE), info);
-
- int avg, dev;
- pQP->get_AvgSyncOffset(&avg);
- pQP->get_DevSyncOffset(&dev);
- info.Format(_T("avg: %d ms, dev: %d ms"), avg, dev);
- m_wndStatsBar.SetLine(_T("Sync Offset"), info);
-
- int drawn, dropped;
- pQP->get_FramesDrawn(&drawn);
- pQP->get_FramesDroppedInRenderer(&dropped);
- info.Format(IDS_MAINFRM_6, drawn, dropped);
- m_wndStatsBar.SetLine(ResStr(IDS_AG_FRAMES), info);
-
- pQP->get_Jitter(&val);
- info.Format(_T("%d ms"), val);
- m_wndStatsBar.SetLine(_T("Jitter"), info);
- }
-
- if (pBI) {
- CAtlList<CString> sl;
-
- for (int i = 0, j = pBI->GetCount(); i < j; i++) {
- int samples, size;
- if (S_OK == pBI->GetStatus(i, samples, size)) {
- CString str;
- str.Format(_T("[%d]: %03d/%d KB"), i, samples, size / 1024);
- sl.AddTail(str);
- }
- }
-
- if (!sl.IsEmpty()) {
- CString str;
- str.Format(_T("%s (p%d)"), Implode(sl, ' '), pBI->GetPriority());
-
- m_wndStatsBar.SetLine(ResStr(IDS_AG_BUFFERS), str);
- }
- }
-
- CInterfaceList<IBitRateInfo> pBRIs;
-
- BeginEnumFilters(pGB, pEF, pBF) {
- BeginEnumPins(pBF, pEP, pPin) {
- if (CComQIPtr<IBitRateInfo> pBRI = pPin) {
- pBRIs.AddTail(pBRI);
- }
- }
- EndEnumPins;
-
- if (!pBRIs.IsEmpty()) {
- CAtlList<CString> sl;
-
- POSITION pos = pBRIs.GetHeadPosition();
- for (int i = 0; pos; i++) {
- IBitRateInfo* pBRI = pBRIs.GetNext(pos);
-
- DWORD cur = pBRI->GetCurrentBitRate() / 1000;
- DWORD avg = pBRI->GetAverageBitRate() / 1000;
-
- if (avg == 0) {
- continue;
- }
-
- CString str;
- if (cur != avg) {
- str.Format(_T("[%d]: %d/%d Kb/s"), i, avg, cur);
- } else {
- str.Format(_T("[%d]: %d Kb/s"), i, avg);
- }
- sl.AddTail(str);
- }
-
- if (!sl.IsEmpty()) {
- m_wndStatsBar.SetLine(_T("Bitrate"), Implode(sl, ' ') + _T(" (avg/cur)"));
- }
-
- break;
- }
- }
- EndEnumFilters;
-
- if (GetPlaybackMode() == PM_FILE) {
- SetupChapters();
- }
-
- if (GetPlaybackMode() == PM_DVD) { // we also use this timer to update the info panel for DVD playback
- ULONG ulAvailable, ulCurrent;
-
- // Location
-
- CString Location('-');
-
- DVD_PLAYBACK_LOCATION2 loc;
- ULONG ulNumOfVolumes, ulVolume;
- DVD_DISC_SIDE Side;
- ULONG ulNumOfTitles;
- ULONG ulNumOfChapters;
-
- if (SUCCEEDED(pDVDI->GetCurrentLocation(&loc))
- && SUCCEEDED(pDVDI->GetNumberOfChapters(loc.TitleNum, &ulNumOfChapters))
- && SUCCEEDED(pDVDI->GetDVDVolumeInfo(&ulNumOfVolumes, &ulVolume, &Side, &ulNumOfTitles))) {
- Location.Format(IDS_MAINFRM_9,
- ulVolume, ulNumOfVolumes,
- loc.TitleNum, ulNumOfTitles,
- loc.ChapterNum, ulNumOfChapters);
- ULONG tsec = (loc.TimeCode.bHours*3600)
- + (loc.TimeCode.bMinutes*60)
- + (loc.TimeCode.bSeconds);
- /* This might not always work, such as on resume */
- if ( loc.ChapterNum != m_lCurrentChapter ) {
- m_lCurrentChapter = loc.ChapterNum;
- m_lChapterStartTime = tsec;
- } else {
- /* If a resume point was used, and the user chapter jumps,
- then it might do some funky time jumping. Try to 'fix' the
- chapter start time if this happens */
- if ( m_lChapterStartTime > tsec ) {
- m_lChapterStartTime = tsec;
- }
- }
- }
-
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_LOCATION), Location);
-
- // Video
-
- CString Video('-');
-
- DVD_VideoAttributes VATR;
-
- if (SUCCEEDED(pDVDI->GetCurrentAngle(&ulAvailable, &ulCurrent))
- && SUCCEEDED(pDVDI->GetCurrentVideoAttributes(&VATR))) {
- Video.Format(IDS_MAINFRM_10,
- ulCurrent, ulAvailable,
- VATR.ulSourceResolutionX, VATR.ulSourceResolutionY, VATR.ulFrameRate,
- VATR.ulAspectX, VATR.ulAspectY);
- }
-
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_VIDEO), Video);
-
- // Audio
-
- CString Audio('-');
-
- DVD_AudioAttributes AATR;
-
- if (SUCCEEDED(pDVDI->GetCurrentAudio(&ulAvailable, &ulCurrent))
- && SUCCEEDED(pDVDI->GetAudioAttributes(ulCurrent, &AATR))) {
- CString lang;
- if (AATR.Language) {
- int len = GetLocaleInfo(AATR.Language, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
- lang.ReleaseBufferSetLength(max(len-1, 0));
- } else {
- lang.Format(IDS_AG_UNKNOWN, ulCurrent+1);
- }
-
- switch (AATR.LanguageExtension) {
- case DVD_AUD_EXT_NotSpecified:
- default:
- break;
- case DVD_AUD_EXT_Captions:
- lang += _T(" (Captions)");
- break;
- case DVD_AUD_EXT_VisuallyImpaired:
- lang += _T(" (Visually Impaired)");
- break;
- case DVD_AUD_EXT_DirectorComments1:
- lang += _T(" (Director Comments 1)");
- break;
- case DVD_AUD_EXT_DirectorComments2:
- lang += _T(" (Director Comments 2)");
- break;
- }
-
- CString format = GetDVDAudioFormatName(AATR);
-
- Audio.Format(IDS_MAINFRM_11,
- lang,
- format,
- AATR.dwFrequency,
- AATR.bQuantization,
- AATR.bNumberOfChannels,
- (AATR.bNumberOfChannels > 1 ? ResStr(IDS_MAINFRM_13) : ResStr(IDS_MAINFRM_12)));
-
- m_wndStatusBar.SetStatusBitmap(
- AATR.bNumberOfChannels == 1 ? IDB_MONO
- : AATR.bNumberOfChannels >= 2 ? IDB_STEREO
- : IDB_NOAUDIO);
- }
-
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_AUDIO), Audio);
-
- // Subtitles
-
- CString Subtitles('-');
-
- BOOL bIsDisabled;
- DVD_SubpictureAttributes SATR;
-
- if (SUCCEEDED(pDVDI->GetCurrentSubpicture(&ulAvailable, &ulCurrent, &bIsDisabled))
- && SUCCEEDED(pDVDI->GetSubpictureAttributes(ulCurrent, &SATR))) {
- CString lang;
- int len = GetLocaleInfo(SATR.Language, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
- lang.ReleaseBufferSetLength(max(len-1, 0));
-
- switch (SATR.LanguageExtension) {
- case DVD_SP_EXT_NotSpecified:
- default:
- break;
- case DVD_SP_EXT_Caption_Normal:
- lang += _T("");
- break;
- case DVD_SP_EXT_Caption_Big:
- lang += _T(" (Big)");
- break;
- case DVD_SP_EXT_Caption_Children:
- lang += _T(" (Children)");
- break;
- case DVD_SP_EXT_CC_Normal:
- lang += _T(" (CC)");
- break;
- case DVD_SP_EXT_CC_Big:
- lang += _T(" (CC Big)");
- break;
- case DVD_SP_EXT_CC_Children:
- lang += _T(" (CC Children)");
- break;
- case DVD_SP_EXT_Forced:
- lang += _T(" (Forced)");
- break;
- case DVD_SP_EXT_DirectorComments_Normal:
- lang += _T(" (Director Comments)");
- break;
- case DVD_SP_EXT_DirectorComments_Big:
- lang += _T(" (Director Comments, Big)");
- break;
- case DVD_SP_EXT_DirectorComments_Children:
- lang += _T(" (Director Comments, Children)");
- break;
- }
-
- if (bIsDisabled) {
- lang = _T("-");
- }
-
- Subtitles.Format(_T("%s"),
- lang);
- }
-
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_SUBTITLES), Subtitles);
- }
-
- if (GetMediaState() == State_Running && !m_fAudioOnly) {
- UINT fSaverActive = 0;
- if (SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, (PVOID)&fSaverActive, 0)) {
- SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 0, 0, SPIF_SENDWININICHANGE); // this might not be needed at all...
- SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, fSaverActive, 0, SPIF_SENDWININICHANGE);
- }
-
- fSaverActive = 0;
- if (SystemParametersInfo(SPI_GETPOWEROFFACTIVE, 0, (PVOID)&fSaverActive, 0)) {
- SystemParametersInfo(SPI_SETPOWEROFFACTIVE, 0, 0, SPIF_SENDWININICHANGE); // this might not be needed at all...
- SystemParametersInfo(SPI_SETPOWEROFFACTIVE, fSaverActive, 0, SPIF_SENDWININICHANGE);
- }
- // prevent screensaver activate, monitor sleep/turn off after playback
- SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
- }
- }
- break;
- case TIMER_STATUSERASER: {
- KillTimer(TIMER_STATUSERASER);
- m_playingmsg.Empty();
- }
- break;
- }
-
- __super::OnTimer(nIDEvent);
+ switch (nIDEvent) {
+ case TIMER_STREAMPOSPOLLER:
+ if (m_iMediaLoadState == MLS_LOADED) {
+ REFERENCE_TIME rtNow = 0, rtDur = 0;
+
+ if (GetPlaybackMode() == PM_FILE) {
+ pMS->GetCurrentPosition(&rtNow);
+ pMS->GetDuration(&rtDur);
+
+ // Casimir666 : autosave subtitle sync after play
+ if ((m_nCurSubtitle >= 0) && (m_rtCurSubPos != rtNow)) {
+ if (m_lSubtitleShift != 0) {
+ if (m_wndSubresyncBar.SaveToDisk()) {
+ m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_AG_SUBTITLES_SAVED), 500);
+ } else {
+ m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_MAINFRM_4));
+ }
+ }
+ m_nCurSubtitle = -1;
+ m_lSubtitleShift = 0;
+ }
+
+ if (!m_fEndOfStream) {
+ AppSettings& s = AfxGetAppSettings();
+ FILE_POSITION* FilePosition = s.CurrentFilePosition();
+ if (FilePosition) {
+ FilePosition->llPosition = rtNow;
+
+ LARGE_INTEGER time;
+ QueryPerformanceCounter(&time);
+ LARGE_INTEGER freq;
+ QueryPerformanceFrequency(&freq);
+ if ((time.QuadPart - m_LastSaveTime.QuadPart) >= 30 * freq.QuadPart) { // save every half of minute
+ m_LastSaveTime = time;
+ if (s.fKeepHistory && s.fRememberFilePos) {
+ s.SaveCurrentFilePosition();
+ }
+ }
+ }
+ }
+
+ if (m_rtDurationOverride >= 0) {
+ rtDur = m_rtDurationOverride;
+ }
+
+ g_bNoDuration = rtDur <= 0;
+ m_wndSeekBar.Enable(rtDur > 0);
+ m_wndSeekBar.SetRange(0, rtDur);
+ m_wndSeekBar.SetPos(rtNow);
+ m_OSD.SetRange(0, rtDur);
+ m_OSD.SetPos(rtNow);
+ //m_Lcd.SetMediaRange(0, rtDur);
+ //m_Lcd.SetMediaPos(rtNow);
+ } else if (GetPlaybackMode() == PM_CAPTURE) {
+ pMS->GetCurrentPosition(&rtNow);
+ if (m_fCapturing && m_wndCaptureBar.m_capdlg.m_pMux) {
+ CComQIPtr<IMediaSeeking> pMuxMS = m_wndCaptureBar.m_capdlg.m_pMux;
+ if (!pMuxMS || FAILED(pMuxMS->GetCurrentPosition(&rtNow))) {
+ rtNow = 0;
+ }
+ }
+
+ if (m_rtDurationOverride >= 0) {
+ rtDur = m_rtDurationOverride;
+ }
+
+ g_bNoDuration = rtDur <= 0;
+ m_wndSeekBar.Enable(false);
+ m_wndSeekBar.SetRange(0, rtDur);
+ m_wndSeekBar.SetPos(rtNow);
+ m_OSD.SetRange(0, rtDur);
+ m_OSD.SetPos(rtNow);
+ //m_Lcd.SetMediaRange(0, rtDur);
+ //m_Lcd.SetMediaPos(rtNow);
+ }
+
+ if (m_pCAP && GetPlaybackMode() != PM_FILE) {
+ g_bExternalSubtitleTime = true;
+ if (pDVDI) {
+ DVD_PLAYBACK_LOCATION2 Location;
+ if (pDVDI->GetCurrentLocation(&Location) == S_OK) {
+ double fps = Location.TimeCodeFlags == DVD_TC_FLAG_25fps ? 25.0
+ : Location.TimeCodeFlags == DVD_TC_FLAG_30fps ? 30.0
+ : Location.TimeCodeFlags == DVD_TC_FLAG_DropFrame ? 29.97
+ : 25.0;
+
+ LONGLONG rtTimeCode = HMSF2RT(Location.TimeCode, fps);
+ m_pCAP->SetTime(rtTimeCode);
+ } else {
+ m_pCAP->SetTime(/*rtNow*/m_wndSeekBar.GetPos());
+ }
+ } else {
+ // Set rtNow to support DVB subtitle
+ m_pCAP->SetTime(rtNow);
+ }
+ } else {
+ g_bExternalSubtitleTime = false;
+ }
+ }
+ break;
+ case TIMER_STREAMPOSPOLLER2:
+ if (m_iMediaLoadState == MLS_LOADED) {
+ __int64 start, stop, pos;
+ m_wndSeekBar.GetRange(start, stop);
+ pos = m_wndSeekBar.GetPosReal();
+
+ GUID tf;
+ pMS->GetTimeFormat(&tf);
+
+ if (GetPlaybackMode() == PM_CAPTURE && !m_fCapturing) {
+ CString str = ResStr(IDS_CAPTURE_LIVE);
+
+ long lChannel = 0, lVivSub = 0, lAudSub = 0;
+ if (pAMTuner
+ && m_wndCaptureBar.m_capdlg.IsTunerActive()
+ && SUCCEEDED(pAMTuner->get_Channel(&lChannel, &lVivSub, &lAudSub))) {
+ CString ch;
+ ch.Format(_T(" (ch%d)"), lChannel);
+ str += ch;
+ }
+
+ m_wndStatusBar.SetStatusTimer(str);
+ } else {
+ m_wndStatusBar.SetStatusTimer(pos, stop, !!m_wndSubresyncBar.IsWindowVisible(), &tf);
+ if (m_bRemainingTime) {
+ m_OSD.DisplayMessage(OSD_TOPLEFT, m_wndStatusBar.GetStatusTimer());
+ }
+ }
+
+ m_wndSubresyncBar.SetTime(pos);
+
+ if (m_pCAP && GetMediaState() == State_Paused) {
+ m_pCAP->Paint(false);
+ }
+ }
+ break;
+ case TIMER_FULLSCREENCONTROLBARHIDER: {
+ CPoint p;
+ GetCursorPos(&p);
+
+ CRect r;
+ GetWindowRect(r);
+ bool fCursorOutside = !r.PtInRect(p);
+
+ CWnd* pWnd = WindowFromPoint(p);
+ if (pWnd && (m_wndView == *pWnd || m_wndView.IsChild(pWnd) || fCursorOutside)) {
+ if (AfxGetAppSettings().nShowBarsWhenFullScreenTimeOut >= 0) {
+ ShowControls(CS_NONE);
+ }
+ }
+ }
+ break;
+ case TIMER_FULLSCREENMOUSEHIDER: {
+ CPoint p;
+ GetCursorPos(&p);
+
+ CRect r;
+ GetWindowRect(r);
+ bool fCursorOutside = !r.PtInRect(p);
+ CWnd* pWnd = WindowFromPoint(p);
+ if (m_pFullscreenWnd->IsWindow()) {
+ TRACE("==> HIDE!\n");
+ if (!m_bInOptions && pWnd == m_pFullscreenWnd) {
+ m_pFullscreenWnd->ShowCursor(false);
+ }
+ KillTimer(TIMER_FULLSCREENMOUSEHIDER);
+ } else {
+ CWnd* pWnd = WindowFromPoint(p);
+ if (pWnd && !m_bInOptions && (m_wndView == *pWnd || m_wndView.IsChild(pWnd) || fCursorOutside)) {
+ m_fHideCursor = true;
+ SetCursor(NULL);
+ }
+ }
+ }
+ break;
+ case TIMER_STATS: {
+ if (pQP) {
+ CString rate;
+ if (m_iSpeedLevel >= -11 && m_iSpeedLevel <= 3 && m_iSpeedLevel != -4) {
+ CString speeds[] = {_T("1/8"), _T("1/4"), _T("1/2"), _T("1"), _T("2"), _T("4"), _T("8")};
+ rate = speeds[(m_iSpeedLevel >= -3 ? m_iSpeedLevel : (-m_iSpeedLevel - 8)) + 3];
+ if (m_iSpeedLevel < -4) {
+ rate = _T("-") + rate;
+ }
+ if (!rate.IsEmpty()) {
+ rate = _T("(") + rate + _T("X)");
+ }
+ }
+
+ CString info;
+ int val = 0;
+
+ /*
+ Reproduce:
+ 1. Start a video
+ 2. Pause video
+ 3. Hibernate computer
+ 4. Start computer again
+ MPC-HC window should now be hung
+
+ Stack dump from a Windows 7 64-bit machine:
+ Thread 1:
+ ntdll_77d30000!ZwWaitForSingleObject+0x15
+ ntdll_77d30000!RtlpWaitOnCriticalSection+0x13e
+ ntdll_77d30000!RtlEnterCriticalSection+0x150
+ QUARTZ!CBlockLock<CKsOpmLib>::CBlockLock<CKsOpmLib>+0x14 <- Lock
+ QUARTZ!CImageSync::get_AvgFrameRate+0x24
+ QUARTZ!CVMRFilter::get_AvgFrameRate+0x31
+ mpc_hc!CMainFrame::OnTimer+0xb80
+ mpc_hc!CWnd::OnWndMsg+0x3e8
+ mpc_hc!CWnd::WindowProc+0x24
+ mpc_hc!CMainFrame::WindowProc+0x15e
+ mpc_hc!AfxCallWndProc+0xac
+ mpc_hc!AfxWndProc+0x36
+ USER32!InternalCallWinProc+0x23
+ USER32!UserCallWinProcCheckWow+0x109
+ USER32!DispatchMessageWorker+0x3bc
+ USER32!DispatchMessageW+0xf
+ mpc_hc!AfxInternalPumpMessage+0x40
+ mpc_hc!CWinThread::Run+0x5b
+ mpc_hc!AfxWinMain+0x69
+ mpc_hc!__tmainCRTStartup+0x11a
+
+ Thread 2:
+ ntdll_77d30000!ZwWaitForSingleObject+0x15
+ ntdll_77d30000!RtlpWaitOnCriticalSection+0x13e
+ ntdll_77d30000!RtlEnterCriticalSection+0x150
+ QUARTZ!CBlockLock<CKsOpmLib>::CBlockLock<CKsOpmLib>+0x14 <- Lock
+ QUARTZ!VMR9::CVMRFilter::NonDelegatingQueryInterface+0x1b
+ mpc_hc!DSObjects::COuterVMR9::NonDelegatingQueryInterface+0x5b
+ mpc_hc!CMacrovisionKicker::NonDelegatingQueryInterface+0xdc
+ QUARTZ!CImageSync::QueryInterface+0x16
+ QUARTZ!VMR9::CVMRFilter::CIImageSyncNotifyEvent::QueryInterface+0x19
+ mpc_hc!DSObjects::CVMR9AllocatorPresenter::PresentImage+0xa9
+ QUARTZ!VMR9::CVMRFilter::CIVMRImagePresenter::PresentImage+0x2c
+ QUARTZ!VMR9::CImageSync::DoRenderSample+0xd5
+ QUARTZ!VMR9::CImageSync::ReceiveWorker+0xad
+ QUARTZ!VMR9::CImageSync::Receive+0x46
+ QUARTZ!VMR9::CVideoMixer::CompositeTheStreamsTogether+0x24f
+ QUARTZ!VMR9::CVideoMixer::MixerThread+0x184
+ QUARTZ!VMR9::CVideoMixer::MixerThreadProc+0xd
+ KERNEL32!BaseThreadInitThunk+0xe
+ ntdll_77d30000!__RtlUserThreadStart+0x70
+ ntdll_77d30000!_RtlUserThreadStart+0x1b
+
+ There can be a bug in QUARTZ or more likely mpc-hc is doing something wrong
+ */
+ pQP->get_AvgFrameRate(&val); // We hang here due to a lock that never gets released.
+ info.Format(_T("%d.%02d %s"), val / 100, val % 100, rate);
+ m_wndStatsBar.SetLine(ResStr(IDS_AG_FRAMERATE), info);
+
+ int avg, dev;
+ pQP->get_AvgSyncOffset(&avg);
+ pQP->get_DevSyncOffset(&dev);
+ info.Format(_T("avg: %d ms, dev: %d ms"), avg, dev);
+ m_wndStatsBar.SetLine(_T("Sync Offset"), info);
+
+ int drawn, dropped;
+ pQP->get_FramesDrawn(&drawn);
+ pQP->get_FramesDroppedInRenderer(&dropped);
+ info.Format(IDS_MAINFRM_6, drawn, dropped);
+ m_wndStatsBar.SetLine(ResStr(IDS_AG_FRAMES), info);
+
+ pQP->get_Jitter(&val);
+ info.Format(_T("%d ms"), val);
+ m_wndStatsBar.SetLine(_T("Jitter"), info);
+ }
+
+ if (pBI) {
+ CAtlList<CString> sl;
+
+ for (int i = 0, j = pBI->GetCount(); i < j; i++) {
+ int samples, size;
+ if (S_OK == pBI->GetStatus(i, samples, size)) {
+ CString str;
+ str.Format(_T("[%d]: %03d/%d KB"), i, samples, size / 1024);
+ sl.AddTail(str);
+ }
+ }
+
+ if (!sl.IsEmpty()) {
+ CString str;
+ str.Format(_T("%s (p%d)"), Implode(sl, ' '), pBI->GetPriority());
+
+ m_wndStatsBar.SetLine(ResStr(IDS_AG_BUFFERS), str);
+ }
+ }
+
+ CInterfaceList<IBitRateInfo> pBRIs;
+
+ BeginEnumFilters(pGB, pEF, pBF) {
+ BeginEnumPins(pBF, pEP, pPin) {
+ if (CComQIPtr<IBitRateInfo> pBRI = pPin) {
+ pBRIs.AddTail(pBRI);
+ }
+ }
+ EndEnumPins;
+
+ if (!pBRIs.IsEmpty()) {
+ CAtlList<CString> sl;
+
+ POSITION pos = pBRIs.GetHeadPosition();
+ for (int i = 0; pos; i++) {
+ IBitRateInfo* pBRI = pBRIs.GetNext(pos);
+
+ DWORD cur = pBRI->GetCurrentBitRate() / 1000;
+ DWORD avg = pBRI->GetAverageBitRate() / 1000;
+
+ if (avg == 0) {
+ continue;
+ }
+
+ CString str;
+ if (cur != avg) {
+ str.Format(_T("[%d]: %d/%d Kb/s"), i, avg, cur);
+ } else {
+ str.Format(_T("[%d]: %d Kb/s"), i, avg);
+ }
+ sl.AddTail(str);
+ }
+
+ if (!sl.IsEmpty()) {
+ m_wndStatsBar.SetLine(_T("Bitrate"), Implode(sl, ' ') + _T(" (avg/cur)"));
+ }
+
+ break;
+ }
+ }
+ EndEnumFilters;
+
+ if (GetPlaybackMode() == PM_FILE) {
+ SetupChapters();
+ }
+
+ if (GetPlaybackMode() == PM_DVD) { // we also use this timer to update the info panel for DVD playback
+ ULONG ulAvailable, ulCurrent;
+
+ // Location
+
+ CString Location('-');
+
+ DVD_PLAYBACK_LOCATION2 loc;
+ ULONG ulNumOfVolumes, ulVolume;
+ DVD_DISC_SIDE Side;
+ ULONG ulNumOfTitles;
+ ULONG ulNumOfChapters;
+
+ if (SUCCEEDED(pDVDI->GetCurrentLocation(&loc))
+ && SUCCEEDED(pDVDI->GetNumberOfChapters(loc.TitleNum, &ulNumOfChapters))
+ && SUCCEEDED(pDVDI->GetDVDVolumeInfo(&ulNumOfVolumes, &ulVolume, &Side, &ulNumOfTitles))) {
+ Location.Format(IDS_MAINFRM_9,
+ ulVolume, ulNumOfVolumes,
+ loc.TitleNum, ulNumOfTitles,
+ loc.ChapterNum, ulNumOfChapters);
+ ULONG tsec = (loc.TimeCode.bHours * 3600)
+ + (loc.TimeCode.bMinutes * 60)
+ + (loc.TimeCode.bSeconds);
+ /* This might not always work, such as on resume */
+ if (loc.ChapterNum != m_lCurrentChapter) {
+ m_lCurrentChapter = loc.ChapterNum;
+ m_lChapterStartTime = tsec;
+ } else {
+ /* If a resume point was used, and the user chapter jumps,
+ then it might do some funky time jumping. Try to 'fix' the
+ chapter start time if this happens */
+ if (m_lChapterStartTime > tsec) {
+ m_lChapterStartTime = tsec;
+ }
+ }
+ }
+
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_LOCATION), Location);
+
+ // Video
+
+ CString Video('-');
+
+ DVD_VideoAttributes VATR;
+
+ if (SUCCEEDED(pDVDI->GetCurrentAngle(&ulAvailable, &ulCurrent))
+ && SUCCEEDED(pDVDI->GetCurrentVideoAttributes(&VATR))) {
+ Video.Format(IDS_MAINFRM_10,
+ ulCurrent, ulAvailable,
+ VATR.ulSourceResolutionX, VATR.ulSourceResolutionY, VATR.ulFrameRate,
+ VATR.ulAspectX, VATR.ulAspectY);
+ }
+
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_VIDEO), Video);
+
+ // Audio
+
+ CString Audio('-');
+
+ DVD_AudioAttributes AATR;
+
+ if (SUCCEEDED(pDVDI->GetCurrentAudio(&ulAvailable, &ulCurrent))
+ && SUCCEEDED(pDVDI->GetAudioAttributes(ulCurrent, &AATR))) {
+ CString lang;
+ if (AATR.Language) {
+ int len = GetLocaleInfo(AATR.Language, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
+ lang.ReleaseBufferSetLength(max(len - 1, 0));
+ } else {
+ lang.Format(IDS_AG_UNKNOWN, ulCurrent + 1);
+ }
+
+ switch (AATR.LanguageExtension) {
+ case DVD_AUD_EXT_NotSpecified:
+ default:
+ break;
+ case DVD_AUD_EXT_Captions:
+ lang += _T(" (Captions)");
+ break;
+ case DVD_AUD_EXT_VisuallyImpaired:
+ lang += _T(" (Visually Impaired)");
+ break;
+ case DVD_AUD_EXT_DirectorComments1:
+ lang += _T(" (Director Comments 1)");
+ break;
+ case DVD_AUD_EXT_DirectorComments2:
+ lang += _T(" (Director Comments 2)");
+ break;
+ }
+
+ CString format = GetDVDAudioFormatName(AATR);
+
+ Audio.Format(IDS_MAINFRM_11,
+ lang,
+ format,
+ AATR.dwFrequency,
+ AATR.bQuantization,
+ AATR.bNumberOfChannels,
+ (AATR.bNumberOfChannels > 1 ? ResStr(IDS_MAINFRM_13) : ResStr(IDS_MAINFRM_12)));
+
+ m_wndStatusBar.SetStatusBitmap(
+ AATR.bNumberOfChannels == 1 ? IDB_MONO
+ : AATR.bNumberOfChannels >= 2 ? IDB_STEREO
+ : IDB_NOAUDIO);
+ }
+
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_AUDIO), Audio);
+
+ // Subtitles
+
+ CString Subtitles('-');
+
+ BOOL bIsDisabled;
+ DVD_SubpictureAttributes SATR;
+
+ if (SUCCEEDED(pDVDI->GetCurrentSubpicture(&ulAvailable, &ulCurrent, &bIsDisabled))
+ && SUCCEEDED(pDVDI->GetSubpictureAttributes(ulCurrent, &SATR))) {
+ CString lang;
+ int len = GetLocaleInfo(SATR.Language, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
+ lang.ReleaseBufferSetLength(max(len - 1, 0));
+
+ switch (SATR.LanguageExtension) {
+ case DVD_SP_EXT_NotSpecified:
+ default:
+ break;
+ case DVD_SP_EXT_Caption_Normal:
+ lang += _T("");
+ break;
+ case DVD_SP_EXT_Caption_Big:
+ lang += _T(" (Big)");
+ break;
+ case DVD_SP_EXT_Caption_Children:
+ lang += _T(" (Children)");
+ break;
+ case DVD_SP_EXT_CC_Normal:
+ lang += _T(" (CC)");
+ break;
+ case DVD_SP_EXT_CC_Big:
+ lang += _T(" (CC Big)");
+ break;
+ case DVD_SP_EXT_CC_Children:
+ lang += _T(" (CC Children)");
+ break;
+ case DVD_SP_EXT_Forced:
+ lang += _T(" (Forced)");
+ break;
+ case DVD_SP_EXT_DirectorComments_Normal:
+ lang += _T(" (Director Comments)");
+ break;
+ case DVD_SP_EXT_DirectorComments_Big:
+ lang += _T(" (Director Comments, Big)");
+ break;
+ case DVD_SP_EXT_DirectorComments_Children:
+ lang += _T(" (Director Comments, Children)");
+ break;
+ }
+
+ if (bIsDisabled) {
+ lang = _T("-");
+ }
+
+ Subtitles.Format(_T("%s"),
+ lang);
+ }
+
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_SUBTITLES), Subtitles);
+ }
+
+ if (GetMediaState() == State_Running && !m_fAudioOnly) {
+ UINT fSaverActive = 0;
+ if (SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, (PVOID)&fSaverActive, 0)) {
+ SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 0, 0, SPIF_SENDWININICHANGE); // this might not be needed at all...
+ SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, fSaverActive, 0, SPIF_SENDWININICHANGE);
+ }
+
+ fSaverActive = 0;
+ if (SystemParametersInfo(SPI_GETPOWEROFFACTIVE, 0, (PVOID)&fSaverActive, 0)) {
+ SystemParametersInfo(SPI_SETPOWEROFFACTIVE, 0, 0, SPIF_SENDWININICHANGE); // this might not be needed at all...
+ SystemParametersInfo(SPI_SETPOWEROFFACTIVE, fSaverActive, 0, SPIF_SENDWININICHANGE);
+ }
+ // prevent screensaver activate, monitor sleep/turn off after playback
+ SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
+ }
+ }
+ break;
+ case TIMER_STATUSERASER: {
+ KillTimer(TIMER_STATUSERASER);
+ m_playingmsg.Empty();
+ }
+ break;
+ }
+
+ __super::OnTimer(nIDEvent);
}
bool CMainFrame::DoAfterPlaybackEvent()
{
- AppSettings& s = AfxGetAppSettings();
-
- bool fExit = (s.nCLSwitches & CLSW_CLOSE) || s.fExitAfterPlayback;
-
- if (s.nCLSwitches & CLSW_STANDBY) {
- SetPrivilege(SE_SHUTDOWN_NAME);
- SetSystemPowerState(TRUE, FALSE);
- fExit = true; // TODO: unless the app closes, it will call standby or hibernate once again forever, how to avoid that?
- } else if (s.nCLSwitches & CLSW_HIBERNATE) {
- SetPrivilege(SE_SHUTDOWN_NAME);
- SetSystemPowerState(FALSE, FALSE);
- fExit = true; // TODO: unless the app closes, it will call standby or hibernate once again forever, how to avoid that?
- } else if (s.nCLSwitches & CLSW_SHUTDOWN) {
- SetPrivilege(SE_SHUTDOWN_NAME);
- ExitWindowsEx(EWX_SHUTDOWN|EWX_POWEROFF|EWX_FORCEIFHUNG, 0);
- fExit = true;
- } else if (s.nCLSwitches & CLSW_LOGOFF) {
- SetPrivilege(SE_SHUTDOWN_NAME);
- ExitWindowsEx(EWX_LOGOFF|EWX_FORCEIFHUNG, 0);
- fExit = true;
- } else if (s.nCLSwitches & CLSW_LOCK) {
- LockWorkStation();
- }
-
- if (fExit) {
- SendMessage(WM_COMMAND, ID_FILE_EXIT);
- }
-
- return fExit;
+ AppSettings& s = AfxGetAppSettings();
+
+ bool fExit = (s.nCLSwitches & CLSW_CLOSE) || s.fExitAfterPlayback;
+
+ if (s.nCLSwitches & CLSW_STANDBY) {
+ SetPrivilege(SE_SHUTDOWN_NAME);
+ SetSystemPowerState(TRUE, FALSE);
+ fExit = true; // TODO: unless the app closes, it will call standby or hibernate once again forever, how to avoid that?
+ } else if (s.nCLSwitches & CLSW_HIBERNATE) {
+ SetPrivilege(SE_SHUTDOWN_NAME);
+ SetSystemPowerState(FALSE, FALSE);
+ fExit = true; // TODO: unless the app closes, it will call standby or hibernate once again forever, how to avoid that?
+ } else if (s.nCLSwitches & CLSW_SHUTDOWN) {
+ SetPrivilege(SE_SHUTDOWN_NAME);
+ ExitWindowsEx(EWX_SHUTDOWN | EWX_POWEROFF | EWX_FORCEIFHUNG, 0);
+ fExit = true;
+ } else if (s.nCLSwitches & CLSW_LOGOFF) {
+ SetPrivilege(SE_SHUTDOWN_NAME);
+ ExitWindowsEx(EWX_LOGOFF | EWX_FORCEIFHUNG, 0);
+ fExit = true;
+ } else if (s.nCLSwitches & CLSW_LOCK) {
+ LockWorkStation();
+ }
+
+ if (fExit) {
+ SendMessage(WM_COMMAND, ID_FILE_EXIT);
+ }
+
+ return fExit;
}
//
@@ -2233,87 +2233,87 @@ bool CMainFrame::DoAfterPlaybackEvent()
//
bool CMainFrame::GraphEventComplete()
{
- AppSettings& s = AfxGetAppSettings();
- FILE_POSITION* FilePosition = s.CurrentFilePosition();
- if (FilePosition) {
- FilePosition->llPosition = 0;
-
- QueryPerformanceCounter(&m_LastSaveTime);
- if (s.fKeepHistory && s.fRememberFilePos) {
- s.SaveCurrentFilePosition();
- }
- }
-
- if (m_wndPlaylistBar.GetCount() <= 1) {
- m_nLoops++;
-
- if (DoAfterPlaybackEvent()) {
- return false;
- }
-
- if (s.fLoopForever || m_nLoops < s.nLoops) {
- if (GetMediaState() == State_Stopped) {
- SendMessage(WM_COMMAND, ID_PLAY_PLAY);
- } else {
- LONGLONG pos = 0;
- pMS->SetPositions(&pos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
-
- if (GetMediaState() == State_Paused) {
- SendMessage(WM_COMMAND, ID_PLAY_PLAY);
- }
- }
- } else {
- bool bNextMediaExist = false;
- if (s.fNextInDirAfterPlayback) {
- bNextMediaExist = SearchInDir(true);
- }
- if (!bNextMediaExist) {
- if (s.fRewind) {
- SendMessage(WM_COMMAND, ID_PLAY_STOP);
- } else {
- m_fEndOfStream = true;
- SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
- }
- m_OSD.ClearMessage();
-
- if (m_fFullScreen && s.fExitFullScreenAtTheEnd) {
- OnViewFullscreen();
- }
-
- if (s.fNextInDirAfterPlayback) {
- m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_NO_MORE_MEDIA));
- // Don't move it. Else OSD message "Pause" will rewrite this message.
- }
- }
- }
- } else if (m_wndPlaylistBar.GetCount() > 1) {
- if (m_wndPlaylistBar.IsAtEnd()) {
- if (DoAfterPlaybackEvent()) {
- return false;
- }
-
- m_nLoops++;
- }
-
- if (s.fLoopForever || m_nLoops < s.nLoops) {
- int nLoops = m_nLoops;
- SendMessage(WM_COMMAND, ID_NAVIGATE_SKIPFORWARD);
- m_nLoops = nLoops;
- } else {
- if (m_fFullScreen && s.fExitFullScreenAtTheEnd) {
- OnViewFullscreen();
- }
-
- if (s.fRewind) {
- s.nCLSwitches |= CLSW_OPEN; // HACK
- PostMessage(WM_COMMAND, ID_NAVIGATE_SKIPFORWARD);
- } else {
- m_fEndOfStream = true;
- PostMessage(WM_COMMAND, ID_PLAY_PAUSE);
- }
- }
- }
- return true;
+ AppSettings& s = AfxGetAppSettings();
+ FILE_POSITION* FilePosition = s.CurrentFilePosition();
+ if (FilePosition) {
+ FilePosition->llPosition = 0;
+
+ QueryPerformanceCounter(&m_LastSaveTime);
+ if (s.fKeepHistory && s.fRememberFilePos) {
+ s.SaveCurrentFilePosition();
+ }
+ }
+
+ if (m_wndPlaylistBar.GetCount() <= 1) {
+ m_nLoops++;
+
+ if (DoAfterPlaybackEvent()) {
+ return false;
+ }
+
+ if (s.fLoopForever || m_nLoops < s.nLoops) {
+ if (GetMediaState() == State_Stopped) {
+ SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ } else {
+ LONGLONG pos = 0;
+ pMS->SetPositions(&pos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
+
+ if (GetMediaState() == State_Paused) {
+ SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ }
+ }
+ } else {
+ bool bNextMediaExist = false;
+ if (s.fNextInDirAfterPlayback) {
+ bNextMediaExist = SearchInDir(true);
+ }
+ if (!bNextMediaExist) {
+ if (s.fRewind) {
+ SendMessage(WM_COMMAND, ID_PLAY_STOP);
+ } else {
+ m_fEndOfStream = true;
+ SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ }
+ m_OSD.ClearMessage();
+
+ if (m_fFullScreen && s.fExitFullScreenAtTheEnd) {
+ OnViewFullscreen();
+ }
+
+ if (s.fNextInDirAfterPlayback) {
+ m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_NO_MORE_MEDIA));
+ // Don't move it. Else OSD message "Pause" will rewrite this message.
+ }
+ }
+ }
+ } else if (m_wndPlaylistBar.GetCount() > 1) {
+ if (m_wndPlaylistBar.IsAtEnd()) {
+ if (DoAfterPlaybackEvent()) {
+ return false;
+ }
+
+ m_nLoops++;
+ }
+
+ if (s.fLoopForever || m_nLoops < s.nLoops) {
+ int nLoops = m_nLoops;
+ SendMessage(WM_COMMAND, ID_NAVIGATE_SKIPFORWARD);
+ m_nLoops = nLoops;
+ } else {
+ if (m_fFullScreen && s.fExitFullScreenAtTheEnd) {
+ OnViewFullscreen();
+ }
+
+ if (s.fRewind) {
+ s.nCLSwitches |= CLSW_OPEN; // HACK
+ PostMessage(WM_COMMAND, ID_NAVIGATE_SKIPFORWARD);
+ } else {
+ m_fEndOfStream = true;
+ PostMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ }
+ }
+ }
+ return true;
}
//
@@ -2322,1725 +2322,1725 @@ bool CMainFrame::GraphEventComplete()
LRESULT CMainFrame::OnGraphNotify(WPARAM wParam, LPARAM lParam)
{
- AppSettings& s = AfxGetAppSettings();
- HRESULT hr = S_OK;
+ AppSettings& s = AfxGetAppSettings();
+ HRESULT hr = S_OK;
- UpdateThumbarButton();
+ UpdateThumbarButton();
- LONG evCode = 0;
- LONG_PTR evParam1, evParam2;
- while (pME && SUCCEEDED(pME->GetEvent(&evCode, &evParam1, &evParam2, 0))) {
+ LONG evCode = 0;
+ LONG_PTR evParam1, evParam2;
+ while (pME && SUCCEEDED(pME->GetEvent(&evCode, &evParam1, &evParam2, 0))) {
#ifdef _DEBUG
- TRACE("--> CMainFrame::OnGraphNotify on thread: %d; event: 0x%08x (%ws)\n", GetCurrentThreadId(), evCode, GetEventString(evCode));
+ TRACE("--> CMainFrame::OnGraphNotify on thread: %d; event: 0x%08x (%ws)\n", GetCurrentThreadId(), evCode, GetEventString(evCode));
#endif
- CString str;
-
- if (m_fCustomGraph) {
- if (EC_BG_ERROR == evCode) {
- str = CString((char*)evParam1);
- }
- }
-
- if (!m_fFrameSteppingActive) {
- m_nStepForwardCount = 0;
- }
-
- hr = pME->FreeEventParams(evCode, evParam1, evParam2);
-
- switch (evCode) {
- case EC_COMPLETE:
- if (!GraphEventComplete()) {
- return hr;
- }
- break;
- case EC_ERRORABORT:
- TRACE(_T("\thr = %08x\n"), (HRESULT)evParam1);
- break;
- case EC_BUFFERING_DATA:
- TRACE(_T("\t%d, %d\n"), (HRESULT)evParam1, evParam2);
-
- m_fBuffering = ((HRESULT)evParam1 != S_OK);
- break;
- case EC_STEP_COMPLETE:
- if (m_fFrameSteppingActive) {
- m_nStepForwardCount++;
- m_fFrameSteppingActive = false;
- pBA->put_Volume(m_VolumeBeforeFrameStepping);
- }
- break;
- case EC_DEVICE_LOST:
- if (GetPlaybackMode() == PM_CAPTURE && evParam2 == 0) {
- CComQIPtr<IBaseFilter> pBF = (IUnknown*)evParam1;
- if (!pVidCap && pVidCap == pBF || !pAudCap && pAudCap == pBF) {
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- }
- }
- break;
- case EC_DVD_TITLE_CHANGE: {
- // Casimir666 : Save current chapter
- DVD_POSITION* DvdPos = s.CurrentDVDPosition();
- if (DvdPos) {
- DvdPos->lTitle = (DWORD)evParam1;
- }
-
- if (GetPlaybackMode() == PM_FILE) {
- SetupChapters();
- } else if (GetPlaybackMode() == PM_DVD) {
- m_iDVDTitle = (DWORD)evParam1;
-
- if (m_iDVDDomain == DVD_DOMAIN_Title) {
- CString Domain;
- Domain.Format(IDS_AG_TITLE, m_iDVDTitle);
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_DOMAIN), Domain);
- }
- }
- }
- break;
- case EC_DVD_DOMAIN_CHANGE: {
- m_iDVDDomain = (DVD_DOMAIN)evParam1;
-
- CString Domain('-');
-
- switch (m_iDVDDomain) {
- case DVD_DOMAIN_FirstPlay:
- ULONGLONG llDVDGuid;
-
- Domain = _T("First Play");
-
- if ( s.fShowDebugInfo ) {
- m_OSD.DebugMessage(_T("%s"), Domain);
- }
-
- if (pDVDI && SUCCEEDED (pDVDI->GetDiscID (NULL, &llDVDGuid))) {
- if ( s.fShowDebugInfo ) {
- m_OSD.DebugMessage(_T("DVD Title: %d"), s.lDVDTitle);
- }
-
- if (s.lDVDTitle != 0) {
- s.NewDvd (llDVDGuid);
- // Set command line position
- hr = pDVDC->PlayTitle(s.lDVDTitle, DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
- if ( s.fShowDebugInfo ) {
- m_OSD.DebugMessage(_T("PlayTitle: 0x%08X"), hr);
- m_OSD.DebugMessage(_T("DVD Chapter: %d"), s.lDVDChapter);
- }
-
- if (s.lDVDChapter > 1) {
- hr = pDVDC->PlayChapterInTitle(s.lDVDTitle, s.lDVDChapter, DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
- if ( s.fShowDebugInfo ) {
- m_OSD.DebugMessage(_T("PlayChapterInTitle: 0x%08X"), hr);
- }
- } else {
- // Trick: skip trailers with some DVDs
- hr = pDVDC->Resume(DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
- if ( s.fShowDebugInfo ) {
- m_OSD.DebugMessage(_T("Resume: 0x%08X"), hr);
- }
-
- // If the resume call succeeded, then we skip PlayChapterInTitle
- // and PlayAtTimeInTitle.
- if ( hr == S_OK ) {
- // This might fail if the Title is not available yet?
- hr = pDVDC->PlayAtTime(&s.DVDPosition,
- DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
- if ( s.fShowDebugInfo ) {
- m_OSD.DebugMessage(_T("PlayAtTime: 0x%08X"), hr);
- }
- } else {
- if ( s.fShowDebugInfo )
- m_OSD.DebugMessage(_T("Timecode requested: %02d:%02d:%02d.%03d"),
- s.DVDPosition.bHours, s.DVDPosition.bMinutes,
- s.DVDPosition.bSeconds, s.DVDPosition.bFrames);
-
- // Always play chapter 1 (for now, until something else dumb happens)
- hr = pDVDC->PlayChapterInTitle(s.lDVDTitle, 1,
- DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
- if ( s.fShowDebugInfo ) {
- m_OSD.DebugMessage(_T("PlayChapterInTitle: 0x%08X"), hr);
- }
-
- // This might fail if the Title is not available yet?
- hr = pDVDC->PlayAtTime(&s.DVDPosition,
- DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
- if ( s.fShowDebugInfo ) {
- m_OSD.DebugMessage(_T("PlayAtTime: 0x%08X"), hr);
- }
-
- if ( hr != S_OK ) {
- hr = pDVDC->PlayAtTimeInTitle(s.lDVDTitle, &s.DVDPosition,
- DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
- if ( s.fShowDebugInfo ) {
- m_OSD.DebugMessage(_T("PlayAtTimeInTitle: 0x%08X"), hr);
- }
- }
- } // Resume
-
- hr = pDVDC->PlayAtTime(&s.DVDPosition,
- DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
- if ( s.fShowDebugInfo ) {
- m_OSD.DebugMessage(_T("PlayAtTime: %d"), hr);
- }
- }
-
- m_iDVDTitle = s.lDVDTitle;
- s.lDVDTitle = 0;
- s.lDVDChapter = 0;
- } else if (s.fKeepHistory && s.fRememberDVDPos && !s.NewDvd(llDVDGuid)) {
- // Set last remembered position (if founded...)
- DVD_POSITION* DvdPos = s.CurrentDVDPosition();
-
- pDVDC->PlayTitle(DvdPos->lTitle, DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
- pDVDC->Resume(DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
+ CString str;
+
+ if (m_fCustomGraph) {
+ if (EC_BG_ERROR == evCode) {
+ str = CString((char*)evParam1);
+ }
+ }
+
+ if (!m_fFrameSteppingActive) {
+ m_nStepForwardCount = 0;
+ }
+
+ hr = pME->FreeEventParams(evCode, evParam1, evParam2);
+
+ switch (evCode) {
+ case EC_COMPLETE:
+ if (!GraphEventComplete()) {
+ return hr;
+ }
+ break;
+ case EC_ERRORABORT:
+ TRACE(_T("\thr = %08x\n"), (HRESULT)evParam1);
+ break;
+ case EC_BUFFERING_DATA:
+ TRACE(_T("\t%d, %d\n"), (HRESULT)evParam1, evParam2);
+
+ m_fBuffering = ((HRESULT)evParam1 != S_OK);
+ break;
+ case EC_STEP_COMPLETE:
+ if (m_fFrameSteppingActive) {
+ m_nStepForwardCount++;
+ m_fFrameSteppingActive = false;
+ pBA->put_Volume(m_VolumeBeforeFrameStepping);
+ }
+ break;
+ case EC_DEVICE_LOST:
+ if (GetPlaybackMode() == PM_CAPTURE && evParam2 == 0) {
+ CComQIPtr<IBaseFilter> pBF = (IUnknown*)evParam1;
+ if (!pVidCap && pVidCap == pBF || !pAudCap && pAudCap == pBF) {
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+ }
+ }
+ break;
+ case EC_DVD_TITLE_CHANGE: {
+ // Casimir666 : Save current chapter
+ DVD_POSITION* DvdPos = s.CurrentDVDPosition();
+ if (DvdPos) {
+ DvdPos->lTitle = (DWORD)evParam1;
+ }
+
+ if (GetPlaybackMode() == PM_FILE) {
+ SetupChapters();
+ } else if (GetPlaybackMode() == PM_DVD) {
+ m_iDVDTitle = (DWORD)evParam1;
+
+ if (m_iDVDDomain == DVD_DOMAIN_Title) {
+ CString Domain;
+ Domain.Format(IDS_AG_TITLE, m_iDVDTitle);
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_DOMAIN), Domain);
+ }
+ }
+ }
+ break;
+ case EC_DVD_DOMAIN_CHANGE: {
+ m_iDVDDomain = (DVD_DOMAIN)evParam1;
+
+ CString Domain('-');
+
+ switch (m_iDVDDomain) {
+ case DVD_DOMAIN_FirstPlay:
+ ULONGLONG llDVDGuid;
+
+ Domain = _T("First Play");
+
+ if (s.fShowDebugInfo) {
+ m_OSD.DebugMessage(_T("%s"), Domain);
+ }
+
+ if (pDVDI && SUCCEEDED(pDVDI->GetDiscID(NULL, &llDVDGuid))) {
+ if (s.fShowDebugInfo) {
+ m_OSD.DebugMessage(_T("DVD Title: %d"), s.lDVDTitle);
+ }
+
+ if (s.lDVDTitle != 0) {
+ s.NewDvd(llDVDGuid);
+ // Set command line position
+ hr = pDVDC->PlayTitle(s.lDVDTitle, DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
+ if (s.fShowDebugInfo) {
+ m_OSD.DebugMessage(_T("PlayTitle: 0x%08X"), hr);
+ m_OSD.DebugMessage(_T("DVD Chapter: %d"), s.lDVDChapter);
+ }
+
+ if (s.lDVDChapter > 1) {
+ hr = pDVDC->PlayChapterInTitle(s.lDVDTitle, s.lDVDChapter, DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
+ if (s.fShowDebugInfo) {
+ m_OSD.DebugMessage(_T("PlayChapterInTitle: 0x%08X"), hr);
+ }
+ } else {
+ // Trick: skip trailers with some DVDs
+ hr = pDVDC->Resume(DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
+ if (s.fShowDebugInfo) {
+ m_OSD.DebugMessage(_T("Resume: 0x%08X"), hr);
+ }
+
+ // If the resume call succeeded, then we skip PlayChapterInTitle
+ // and PlayAtTimeInTitle.
+ if (hr == S_OK) {
+ // This might fail if the Title is not available yet?
+ hr = pDVDC->PlayAtTime(&s.DVDPosition,
+ DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
+ if (s.fShowDebugInfo) {
+ m_OSD.DebugMessage(_T("PlayAtTime: 0x%08X"), hr);
+ }
+ } else {
+ if (s.fShowDebugInfo)
+ m_OSD.DebugMessage(_T("Timecode requested: %02d:%02d:%02d.%03d"),
+ s.DVDPosition.bHours, s.DVDPosition.bMinutes,
+ s.DVDPosition.bSeconds, s.DVDPosition.bFrames);
+
+ // Always play chapter 1 (for now, until something else dumb happens)
+ hr = pDVDC->PlayChapterInTitle(s.lDVDTitle, 1,
+ DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
+ if (s.fShowDebugInfo) {
+ m_OSD.DebugMessage(_T("PlayChapterInTitle: 0x%08X"), hr);
+ }
+
+ // This might fail if the Title is not available yet?
+ hr = pDVDC->PlayAtTime(&s.DVDPosition,
+ DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
+ if (s.fShowDebugInfo) {
+ m_OSD.DebugMessage(_T("PlayAtTime: 0x%08X"), hr);
+ }
+
+ if (hr != S_OK) {
+ hr = pDVDC->PlayAtTimeInTitle(s.lDVDTitle, &s.DVDPosition,
+ DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
+ if (s.fShowDebugInfo) {
+ m_OSD.DebugMessage(_T("PlayAtTimeInTitle: 0x%08X"), hr);
+ }
+ }
+ } // Resume
+
+ hr = pDVDC->PlayAtTime(&s.DVDPosition,
+ DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
+ if (s.fShowDebugInfo) {
+ m_OSD.DebugMessage(_T("PlayAtTime: %d"), hr);
+ }
+ }
+
+ m_iDVDTitle = s.lDVDTitle;
+ s.lDVDTitle = 0;
+ s.lDVDChapter = 0;
+ } else if (s.fKeepHistory && s.fRememberDVDPos && !s.NewDvd(llDVDGuid)) {
+ // Set last remembered position (if founded...)
+ DVD_POSITION* DvdPos = s.CurrentDVDPosition();
+
+ pDVDC->PlayTitle(DvdPos->lTitle, DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
+ pDVDC->Resume(DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
#if 1
- if (SUCCEEDED (hr = pDVDC->PlayAtTimeInTitle(
- DvdPos->lTitle, &DvdPos->Timecode,
- DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL)))
+ if (SUCCEEDED(hr = pDVDC->PlayAtTimeInTitle(
+ DvdPos->lTitle, &DvdPos->Timecode,
+ DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL)))
#else
- if (SUCCEEDED (hr = pDVDC->PlayAtTime (&DvdPos->Timecode,
- DVD_CMD_FLAG_Flush, NULL)))
+ if (SUCCEEDED(hr = pDVDC->PlayAtTime(&DvdPos->Timecode,
+ DVD_CMD_FLAG_Flush, NULL)))
#endif
- {
- m_iDVDTitle = DvdPos->lTitle;
- }
- }
- AppSettings& s = AfxGetAppSettings();
- if (s.fRememberZoomLevel && !m_fFullScreen && !s.IsD3DFullscreen()) { // Hack to the normal initial zoom for DVD + DXVA ...
- ZoomVideoWindow();
- }
- }
- break;
- case DVD_DOMAIN_VideoManagerMenu:
- Domain = _T("Video Manager Menu");
- if ( s.fShowDebugInfo ) {
- m_OSD.DebugMessage(_T("%s"), Domain);
- }
- break;
- case DVD_DOMAIN_VideoTitleSetMenu:
- Domain = _T("Video Title Set Menu");
- if ( s.fShowDebugInfo ) {
- m_OSD.DebugMessage(_T("%s"), Domain);
- }
- break;
- case DVD_DOMAIN_Title:
- Domain.Format(IDS_AG_TITLE, m_iDVDTitle);
- if ( s.fShowDebugInfo ) {
- m_OSD.DebugMessage(_T("%s"), Domain);
- }
- DVD_POSITION* DvdPos;
- DvdPos = s.CurrentDVDPosition();
- if (DvdPos) {
- DvdPos->lTitle = m_iDVDTitle;
- }
- break;
- case DVD_DOMAIN_Stop:
- Domain.LoadString(IDS_AG_STOP);
- if ( s.fShowDebugInfo ) {
- m_OSD.DebugMessage(_T("%s"), Domain);
- }
- break;
- default:
- Domain = _T("-");
- if ( s.fShowDebugInfo ) {
- m_OSD.DebugMessage(_T("%s"), Domain);
- }
- break;
- }
-
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_DOMAIN), Domain);
-
-#if 0 // UOPs debug traces
- if (hr == VFW_E_DVD_OPERATION_INHIBITED) {
- ULONG UOPfields = 0;
- pDVDI->GetCurrentUOPS(&UOPfields);
- CString message;
- message.Format( _T("UOP bitfield: 0x%08X; domain: %s"), UOPfields, Domain);
- m_OSD.DisplayMessage( OSD_TOPLEFT, message );
- } else {
- m_OSD.DisplayMessage( OSD_TOPRIGHT, Domain );
- }
+ {
+ m_iDVDTitle = DvdPos->lTitle;
+ }
+ }
+ AppSettings& s = AfxGetAppSettings();
+ if (s.fRememberZoomLevel && !m_fFullScreen && !s.IsD3DFullscreen()) { // Hack to the normal initial zoom for DVD + DXVA ...
+ ZoomVideoWindow();
+ }
+ }
+ break;
+ case DVD_DOMAIN_VideoManagerMenu:
+ Domain = _T("Video Manager Menu");
+ if (s.fShowDebugInfo) {
+ m_OSD.DebugMessage(_T("%s"), Domain);
+ }
+ break;
+ case DVD_DOMAIN_VideoTitleSetMenu:
+ Domain = _T("Video Title Set Menu");
+ if (s.fShowDebugInfo) {
+ m_OSD.DebugMessage(_T("%s"), Domain);
+ }
+ break;
+ case DVD_DOMAIN_Title:
+ Domain.Format(IDS_AG_TITLE, m_iDVDTitle);
+ if (s.fShowDebugInfo) {
+ m_OSD.DebugMessage(_T("%s"), Domain);
+ }
+ DVD_POSITION* DvdPos;
+ DvdPos = s.CurrentDVDPosition();
+ if (DvdPos) {
+ DvdPos->lTitle = m_iDVDTitle;
+ }
+ break;
+ case DVD_DOMAIN_Stop:
+ Domain.LoadString(IDS_AG_STOP);
+ if (s.fShowDebugInfo) {
+ m_OSD.DebugMessage(_T("%s"), Domain);
+ }
+ break;
+ default:
+ Domain = _T("-");
+ if (s.fShowDebugInfo) {
+ m_OSD.DebugMessage(_T("%s"), Domain);
+ }
+ break;
+ }
+
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_DOMAIN), Domain);
+
+#if 0 // UOPs debug traces
+ if (hr == VFW_E_DVD_OPERATION_INHIBITED) {
+ ULONG UOPfields = 0;
+ pDVDI->GetCurrentUOPS(&UOPfields);
+ CString message;
+ message.Format(_T("UOP bitfield: 0x%08X; domain: %s"), UOPfields, Domain);
+ m_OSD.DisplayMessage(OSD_TOPLEFT, message);
+ } else {
+ m_OSD.DisplayMessage(OSD_TOPRIGHT, Domain);
+ }
#endif
- MoveVideoWindow(); // AR might have changed
- }
- break;
- case EC_DVD_CURRENT_HMSF_TIME: {
- double fps = evParam2 == DVD_TC_FLAG_25fps ? 25.0
- : evParam2 == DVD_TC_FLAG_30fps ? 30.0
- : evParam2 == DVD_TC_FLAG_DropFrame ? 29.97
- : 25.0;
-
- REFERENCE_TIME rtDur = 0;
-
- DVD_HMSF_TIMECODE tcDur;
- ULONG ulFlags;
- if (SUCCEEDED(pDVDI->GetTotalTitleTime(&tcDur, &ulFlags))) {
- rtDur = HMSF2RT(tcDur, fps);
- }
-
- g_bNoDuration = rtDur <= 0;
- m_wndSeekBar.Enable(rtDur > 0);
- m_wndSeekBar.SetRange(0, rtDur);
- m_OSD.SetRange (0, rtDur);
- //m_Lcd.SetMediaRange(0, rtDur);
-
- REFERENCE_TIME rtNow = HMSF2RT(*((DVD_HMSF_TIMECODE*)&evParam1), fps);
-
- // Casimir666 : Save current position in the chapter
- DVD_POSITION* DvdPos = s.CurrentDVDPosition();
- if (DvdPos) {
- memcpy (&DvdPos->Timecode, (void*)&evParam1, sizeof(DVD_HMSF_TIMECODE));
- }
-
- m_wndSeekBar.SetPos(rtNow);
- m_OSD.SetPos(rtNow);
- //m_Lcd.SetMediaPos(rtNow);
-
- if (m_pSubClock) {
- m_pSubClock->SetTime(rtNow);
- }
- }
- break;
- case EC_DVD_ERROR: {
- TRACE(_T("\t%d %d\n"), evParam1, evParam2);
-
- UINT err;
-
- switch (evParam1) {
- case DVD_ERROR_Unexpected:
- default:
- err = IDS_MAINFRM_16;
- break;
- case DVD_ERROR_CopyProtectFail:
- err = IDS_MAINFRM_17;
- break;
- case DVD_ERROR_InvalidDVD1_0Disc:
- err = IDS_MAINFRM_18;
- break;
- case DVD_ERROR_InvalidDiscRegion:
- err = IDS_MAINFRM_19;
- break;
- case DVD_ERROR_LowParentalLevel:
- err = IDS_MAINFRM_20;
- break;
- case DVD_ERROR_MacrovisionFail:
- err = IDS_MAINFRM_21;
- break;
- case DVD_ERROR_IncompatibleSystemAndDecoderRegions:
- err = IDS_MAINFRM_22;
- break;
- case DVD_ERROR_IncompatibleDiscAndDecoderRegions:
- err = IDS_MAINFRM_23;
- break;
- }
-
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
-
- m_closingmsg.LoadString(err);
- }
- break;
- case EC_DVD_WARNING:
- TRACE(_T("\t%d %d\n"), evParam1, evParam2);
- break;
- case EC_VIDEO_SIZE_CHANGED: {
- TRACE(_T("\t%dx%d\n"), CSize((DWORD)evParam1));
-
- WINDOWPLACEMENT wp;
- wp.length = sizeof(wp);
- GetWindowPlacement(&wp);
-
- CSize size((DWORD)evParam1);
- m_fAudioOnly = (size.cx <= 0 || size.cy <= 0);
-
- if (s.fRememberZoomLevel
- && !(m_fFullScreen || wp.showCmd == SW_SHOWMAXIMIZED || wp.showCmd == SW_SHOWMINIMIZED)) {
- ZoomVideoWindow();
- } else {
- MoveVideoWindow();
- }
- }
- break;
- case EC_LENGTH_CHANGED: {
- REFERENCE_TIME rtDur = 0;
- pMS->GetDuration(&rtDur);
- m_wndPlaylistBar.SetCurTime(rtDur);
- }
- break;
- case EC_BG_AUDIO_CHANGED:
- if (m_fCustomGraph) {
- int nAudioChannels = (int)evParam1;
-
- m_wndStatusBar.SetStatusBitmap(nAudioChannels == 1 ? IDB_MONO
- : nAudioChannels >= 2 ? IDB_STEREO
- : IDB_NOAUDIO);
- }
- break;
- case EC_BG_ERROR:
- if (m_fCustomGraph) {
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- m_closingmsg = !str.IsEmpty() ? str : _T("Unspecified graph error");
- m_wndPlaylistBar.SetCurValid(false);
- return hr;
- }
- break;
- case EC_DVD_PLAYBACK_RATE_CHANGE:
- if (m_fCustomGraph && s.AutoChangeFullscrRes.bEnabled &&
- m_fFullScreen && m_iDVDDomain == DVD_DOMAIN_Title) {
- AutoChangeMonitorMode();
- }
- break;
- }
- }
-
- return hr;
-}
-
-LRESULT CMainFrame::OnResetDevice( WPARAM wParam, LPARAM lParam )
-{
- OAFilterState fs = State_Stopped;
- pMC->GetState(0, &fs);
- if (fs == State_Running) {
- pMC->Pause();
- }
-
- m_OSD.HideMessage(true);
-
- BOOL bResult = false;
- if (m_bOpenedThruThread) {
- CAMEvent e;
- m_pGraphThread->PostThreadMessage(CGraphThread::TM_RESET, (WPARAM)&bResult, (LPARAM)&e);
- e.Wait();
- } else {
- ResetDevice();
- }
-
- m_OSD.HideMessage(false);
-
- if (fs == State_Running) {
- pMC->Run();
- }
- return S_OK;
+ MoveVideoWindow(); // AR might have changed
+ }
+ break;
+ case EC_DVD_CURRENT_HMSF_TIME: {
+ double fps = evParam2 == DVD_TC_FLAG_25fps ? 25.0
+ : evParam2 == DVD_TC_FLAG_30fps ? 30.0
+ : evParam2 == DVD_TC_FLAG_DropFrame ? 29.97
+ : 25.0;
+
+ REFERENCE_TIME rtDur = 0;
+
+ DVD_HMSF_TIMECODE tcDur;
+ ULONG ulFlags;
+ if (SUCCEEDED(pDVDI->GetTotalTitleTime(&tcDur, &ulFlags))) {
+ rtDur = HMSF2RT(tcDur, fps);
+ }
+
+ g_bNoDuration = rtDur <= 0;
+ m_wndSeekBar.Enable(rtDur > 0);
+ m_wndSeekBar.SetRange(0, rtDur);
+ m_OSD.SetRange(0, rtDur);
+ //m_Lcd.SetMediaRange(0, rtDur);
+
+ REFERENCE_TIME rtNow = HMSF2RT(*((DVD_HMSF_TIMECODE*)&evParam1), fps);
+
+ // Casimir666 : Save current position in the chapter
+ DVD_POSITION* DvdPos = s.CurrentDVDPosition();
+ if (DvdPos) {
+ memcpy(&DvdPos->Timecode, (void*)&evParam1, sizeof(DVD_HMSF_TIMECODE));
+ }
+
+ m_wndSeekBar.SetPos(rtNow);
+ m_OSD.SetPos(rtNow);
+ //m_Lcd.SetMediaPos(rtNow);
+
+ if (m_pSubClock) {
+ m_pSubClock->SetTime(rtNow);
+ }
+ }
+ break;
+ case EC_DVD_ERROR: {
+ TRACE(_T("\t%d %d\n"), evParam1, evParam2);
+
+ UINT err;
+
+ switch (evParam1) {
+ case DVD_ERROR_Unexpected:
+ default:
+ err = IDS_MAINFRM_16;
+ break;
+ case DVD_ERROR_CopyProtectFail:
+ err = IDS_MAINFRM_17;
+ break;
+ case DVD_ERROR_InvalidDVD1_0Disc:
+ err = IDS_MAINFRM_18;
+ break;
+ case DVD_ERROR_InvalidDiscRegion:
+ err = IDS_MAINFRM_19;
+ break;
+ case DVD_ERROR_LowParentalLevel:
+ err = IDS_MAINFRM_20;
+ break;
+ case DVD_ERROR_MacrovisionFail:
+ err = IDS_MAINFRM_21;
+ break;
+ case DVD_ERROR_IncompatibleSystemAndDecoderRegions:
+ err = IDS_MAINFRM_22;
+ break;
+ case DVD_ERROR_IncompatibleDiscAndDecoderRegions:
+ err = IDS_MAINFRM_23;
+ break;
+ }
+
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+
+ m_closingmsg.LoadString(err);
+ }
+ break;
+ case EC_DVD_WARNING:
+ TRACE(_T("\t%d %d\n"), evParam1, evParam2);
+ break;
+ case EC_VIDEO_SIZE_CHANGED: {
+ TRACE(_T("\t%dx%d\n"), CSize((DWORD)evParam1));
+
+ WINDOWPLACEMENT wp;
+ wp.length = sizeof(wp);
+ GetWindowPlacement(&wp);
+
+ CSize size((DWORD)evParam1);
+ m_fAudioOnly = (size.cx <= 0 || size.cy <= 0);
+
+ if (s.fRememberZoomLevel
+ && !(m_fFullScreen || wp.showCmd == SW_SHOWMAXIMIZED || wp.showCmd == SW_SHOWMINIMIZED)) {
+ ZoomVideoWindow();
+ } else {
+ MoveVideoWindow();
+ }
+ }
+ break;
+ case EC_LENGTH_CHANGED: {
+ REFERENCE_TIME rtDur = 0;
+ pMS->GetDuration(&rtDur);
+ m_wndPlaylistBar.SetCurTime(rtDur);
+ }
+ break;
+ case EC_BG_AUDIO_CHANGED:
+ if (m_fCustomGraph) {
+ int nAudioChannels = (int)evParam1;
+
+ m_wndStatusBar.SetStatusBitmap(nAudioChannels == 1 ? IDB_MONO
+ : nAudioChannels >= 2 ? IDB_STEREO
+ : IDB_NOAUDIO);
+ }
+ break;
+ case EC_BG_ERROR:
+ if (m_fCustomGraph) {
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+ m_closingmsg = !str.IsEmpty() ? str : _T("Unspecified graph error");
+ m_wndPlaylistBar.SetCurValid(false);
+ return hr;
+ }
+ break;
+ case EC_DVD_PLAYBACK_RATE_CHANGE:
+ if (m_fCustomGraph && s.AutoChangeFullscrRes.bEnabled &&
+ m_fFullScreen && m_iDVDDomain == DVD_DOMAIN_Title) {
+ AutoChangeMonitorMode();
+ }
+ break;
+ }
+ }
+
+ return hr;
+}
+
+LRESULT CMainFrame::OnResetDevice(WPARAM wParam, LPARAM lParam)
+{
+ OAFilterState fs = State_Stopped;
+ pMC->GetState(0, &fs);
+ if (fs == State_Running) {
+ pMC->Pause();
+ }
+
+ m_OSD.HideMessage(true);
+
+ BOOL bResult = false;
+ if (m_bOpenedThruThread) {
+ CAMEvent e;
+ m_pGraphThread->PostThreadMessage(CGraphThread::TM_RESET, (WPARAM)&bResult, (LPARAM)&e);
+ e.Wait();
+ } else {
+ ResetDevice();
+ }
+
+ m_OSD.HideMessage(false);
+
+ if (fs == State_Running) {
+ pMC->Run();
+ }
+ return S_OK;
}
LRESULT CMainFrame::OnRepaintRenderLess(WPARAM wParam, LPARAM lParam)
{
- MoveVideoWindow();
- return TRUE;
+ MoveVideoWindow();
+ return TRUE;
}
LRESULT CMainFrame::OnResumeFromState(WPARAM wParam, LPARAM lParam)
{
- int iPlaybackMode = (int)wParam;
-
- if (iPlaybackMode == PM_FILE) {
- SeekTo(10000i64*int(lParam), false);
- } else if (iPlaybackMode == PM_DVD) {
- CComPtr<IDvdState> pDvdState;
- pDvdState.Attach((IDvdState*)lParam);
- if (pDVDC) {
- pDVDC->SetState(pDvdState, DVD_CMD_FLAG_Block, NULL);
- }
- } else if (iPlaybackMode == PM_CAPTURE) {
- // not implemented
- } else {
- ASSERT(0);
- return FALSE;
- }
+ int iPlaybackMode = (int)wParam;
+
+ if (iPlaybackMode == PM_FILE) {
+ SeekTo(10000i64 * int(lParam), false);
+ } else if (iPlaybackMode == PM_DVD) {
+ CComPtr<IDvdState> pDvdState;
+ pDvdState.Attach((IDvdState*)lParam);
+ if (pDVDC) {
+ pDVDC->SetState(pDvdState, DVD_CMD_FLAG_Block, NULL);
+ }
+ } else if (iPlaybackMode == PM_CAPTURE) {
+ // not implemented
+ } else {
+ ASSERT(0);
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
BOOL CMainFrame::OnButton(UINT id, UINT nFlags, CPoint point)
{
- SetFocus();
+ SetFocus();
- CRect r;
- if (m_pFullscreenWnd->IsWindow()) {
- m_pFullscreenWnd->GetClientRect(r);
- } else {
- m_wndView.GetClientRect(r);
- m_wndView.MapWindowPoints(this, &r);
- }
+ CRect r;
+ if (m_pFullscreenWnd->IsWindow()) {
+ m_pFullscreenWnd->GetClientRect(r);
+ } else {
+ m_wndView.GetClientRect(r);
+ m_wndView.MapWindowPoints(this, &r);
+ }
- if (id != wmcmd::WDOWN && id != wmcmd::WUP && !r.PtInRect(point)) {
- return FALSE;
- }
+ if (id != wmcmd::WDOWN && id != wmcmd::WUP && !r.PtInRect(point)) {
+ return FALSE;
+ }
- BOOL ret = FALSE;
+ BOOL ret = FALSE;
- WORD cmd = AssignedToCmd(id, m_fFullScreen);
- if (cmd) {
- SendMessage(WM_COMMAND, cmd);
- ret = TRUE;
- }
+ WORD cmd = AssignedToCmd(id, m_fFullScreen);
+ if (cmd) {
+ SendMessage(WM_COMMAND, cmd);
+ ret = TRUE;
+ }
- return ret;
+ return ret;
}
static bool s_fLDown = false;
void CMainFrame::OnLButtonDown(UINT nFlags, CPoint point)
{
- if (!m_pFullscreenWnd->IsWindow() || !m_OSD.OnLButtonDown (nFlags, point)) {
- SetFocus();
+ if (!m_pFullscreenWnd->IsWindow() || !m_OSD.OnLButtonDown(nFlags, point)) {
+ SetFocus();
- bool fClicked = false;
+ bool fClicked = false;
- if (GetPlaybackMode() == PM_DVD) {
- CPoint p = point - m_wndView.GetVideoRect().TopLeft();
+ if (GetPlaybackMode() == PM_DVD) {
+ CPoint p = point - m_wndView.GetVideoRect().TopLeft();
- if (SUCCEEDED(pDVDC->ActivateAtPosition(p))
- || m_iDVDDomain == DVD_DOMAIN_VideoManagerMenu
- || m_iDVDDomain == DVD_DOMAIN_VideoTitleSetMenu) {
- fClicked = true;
- }
- }
+ if (SUCCEEDED(pDVDC->ActivateAtPosition(p))
+ || m_iDVDDomain == DVD_DOMAIN_VideoManagerMenu
+ || m_iDVDDomain == DVD_DOMAIN_VideoTitleSetMenu) {
+ fClicked = true;
+ }
+ }
- if (!fClicked) {
- bool fLeftMouseBtnUnassigned = !AssignedToCmd(wmcmd::LDOWN, m_fFullScreen);
+ if (!fClicked) {
+ bool fLeftMouseBtnUnassigned = !AssignedToCmd(wmcmd::LDOWN, m_fFullScreen);
- if (!m_fFullScreen && ((IsCaptionHidden() && AfxGetAppSettings().nCS<=CS_SEEKBAR) || fLeftMouseBtnUnassigned || ((GetTickCount()-m_nMenuHideTick)<100))) {
- PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y));
- } else {
- s_fLDown = true;
- if (OnButton(wmcmd::LDOWN, nFlags, point)) {
- return;
- }
- }
- }
+ if (!m_fFullScreen && ((IsCaptionHidden() && AfxGetAppSettings().nCS <= CS_SEEKBAR) || fLeftMouseBtnUnassigned || ((GetTickCount() - m_nMenuHideTick) < 100))) {
+ PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y));
+ } else {
+ s_fLDown = true;
+ if (OnButton(wmcmd::LDOWN, nFlags, point)) {
+ return;
+ }
+ }
+ }
- __super::OnLButtonDown(nFlags, point);
- }
+ __super::OnLButtonDown(nFlags, point);
+ }
}
void CMainFrame::OnLButtonUp(UINT nFlags, CPoint point)
{
- if (!m_pFullscreenWnd->IsWindow() || !m_OSD.OnLButtonUp (nFlags, point)) {
- bool fLeftMouseBtnUnassigned = !AssignedToCmd(wmcmd::LDOWN, m_fFullScreen);
- if (fLeftMouseBtnUnassigned || ((GetTickCount()-m_nMenuHideTick)<100)) {
- PostMessage(WM_NCLBUTTONUP, HTCAPTION, MAKELPARAM(point.x, point.y));
- } else if (OnButton(wmcmd::LUP, nFlags, point)) {
- return;
- }
+ if (!m_pFullscreenWnd->IsWindow() || !m_OSD.OnLButtonUp(nFlags, point)) {
+ bool fLeftMouseBtnUnassigned = !AssignedToCmd(wmcmd::LDOWN, m_fFullScreen);
+ if (fLeftMouseBtnUnassigned || ((GetTickCount() - m_nMenuHideTick) < 100)) {
+ PostMessage(WM_NCLBUTTONUP, HTCAPTION, MAKELPARAM(point.x, point.y));
+ } else if (OnButton(wmcmd::LUP, nFlags, point)) {
+ return;
+ }
- __super::OnLButtonUp(nFlags, point);
- }
+ __super::OnLButtonUp(nFlags, point);
+ }
}
void CMainFrame::OnLButtonDblClk(UINT nFlags, CPoint point)
{
- if (s_fLDown) {
- SendMessage(WM_LBUTTONDOWN, nFlags, MAKELPARAM(point.x, point.y));
- s_fLDown = false;
- }
- if (!OnButton(wmcmd::LDBLCLK, nFlags, point)) {
- __super::OnLButtonDblClk(nFlags, point);
- }
+ if (s_fLDown) {
+ SendMessage(WM_LBUTTONDOWN, nFlags, MAKELPARAM(point.x, point.y));
+ s_fLDown = false;
+ }
+ if (!OnButton(wmcmd::LDBLCLK, nFlags, point)) {
+ __super::OnLButtonDblClk(nFlags, point);
+ }
}
void CMainFrame::OnMButtonDown(UINT nFlags, CPoint point)
{
- SendMessage(WM_CANCELMODE);
- if (!OnButton(wmcmd::MDOWN, nFlags, point)) {
- __super::OnMButtonDown(nFlags, point);
- }
+ SendMessage(WM_CANCELMODE);
+ if (!OnButton(wmcmd::MDOWN, nFlags, point)) {
+ __super::OnMButtonDown(nFlags, point);
+ }
}
void CMainFrame::OnMButtonUp(UINT nFlags, CPoint point)
{
- if (!OnButton(wmcmd::MUP, nFlags, point)) {
- __super::OnMButtonUp(nFlags, point);
- }
+ if (!OnButton(wmcmd::MUP, nFlags, point)) {
+ __super::OnMButtonUp(nFlags, point);
+ }
}
void CMainFrame::OnMButtonDblClk(UINT nFlags, CPoint point)
{
- SendMessage(WM_MBUTTONDOWN, nFlags, MAKELPARAM(point.x, point.y));
- if (!OnButton(wmcmd::MDBLCLK, nFlags, point)) {
- __super::OnMButtonDblClk(nFlags, point);
- }
+ SendMessage(WM_MBUTTONDOWN, nFlags, MAKELPARAM(point.x, point.y));
+ if (!OnButton(wmcmd::MDBLCLK, nFlags, point)) {
+ __super::OnMButtonDblClk(nFlags, point);
+ }
}
void CMainFrame::OnRButtonDown(UINT nFlags, CPoint point)
{
- if (!OnButton(wmcmd::RDOWN, nFlags, point)) {
- __super::OnRButtonDown(nFlags, point);
- }
+ if (!OnButton(wmcmd::RDOWN, nFlags, point)) {
+ __super::OnRButtonDown(nFlags, point);
+ }
}
void CMainFrame::OnRButtonUp(UINT nFlags, CPoint point)
{
- CPoint p;
- GetCursorPos(&p);
- SetFocus();
- if (WindowFromPoint(p) != m_pFullscreenWnd && !OnButton(wmcmd::RUP, nFlags, point)) {
- __super::OnRButtonUp(nFlags, point);
- }
+ CPoint p;
+ GetCursorPos(&p);
+ SetFocus();
+ if (WindowFromPoint(p) != m_pFullscreenWnd && !OnButton(wmcmd::RUP, nFlags, point)) {
+ __super::OnRButtonUp(nFlags, point);
+ }
}
void CMainFrame::OnRButtonDblClk(UINT nFlags, CPoint point)
{
- SendMessage(WM_RBUTTONDOWN, nFlags, MAKELPARAM(point.x, point.y));
- if (!OnButton(wmcmd::RDBLCLK, nFlags, point)) {
- __super::OnRButtonDblClk(nFlags, point);
- }
+ SendMessage(WM_RBUTTONDOWN, nFlags, MAKELPARAM(point.x, point.y));
+ if (!OnButton(wmcmd::RDBLCLK, nFlags, point)) {
+ __super::OnRButtonDblClk(nFlags, point);
+ }
}
LRESULT CMainFrame::OnXButtonDown(WPARAM wParam, LPARAM lParam)
{
- SendMessage(WM_CANCELMODE);
- UINT fwButton = GET_XBUTTON_WPARAM(wParam);
- return OnButton(fwButton == XBUTTON1 ? wmcmd::X1DOWN : fwButton == XBUTTON2 ? wmcmd::X2DOWN : wmcmd::NONE,
- GET_KEYSTATE_WPARAM(wParam), CPoint(lParam));
+ SendMessage(WM_CANCELMODE);
+ UINT fwButton = GET_XBUTTON_WPARAM(wParam);
+ return OnButton(fwButton == XBUTTON1 ? wmcmd::X1DOWN : fwButton == XBUTTON2 ? wmcmd::X2DOWN : wmcmd::NONE,
+ GET_KEYSTATE_WPARAM(wParam), CPoint(lParam));
}
LRESULT CMainFrame::OnXButtonUp(WPARAM wParam, LPARAM lParam)
{
- UINT fwButton = GET_XBUTTON_WPARAM(wParam);
- return OnButton(fwButton == XBUTTON1 ? wmcmd::X1UP : fwButton == XBUTTON2 ? wmcmd::X2UP : wmcmd::NONE,
- GET_KEYSTATE_WPARAM(wParam), CPoint(lParam));
+ UINT fwButton = GET_XBUTTON_WPARAM(wParam);
+ return OnButton(fwButton == XBUTTON1 ? wmcmd::X1UP : fwButton == XBUTTON2 ? wmcmd::X2UP : wmcmd::NONE,
+ GET_KEYSTATE_WPARAM(wParam), CPoint(lParam));
}
LRESULT CMainFrame::OnXButtonDblClk(WPARAM wParam, LPARAM lParam)
{
- SendMessage(WM_XBUTTONDOWN, wParam, lParam);
- UINT fwButton = GET_XBUTTON_WPARAM(wParam);
- return OnButton(fwButton == XBUTTON1 ? wmcmd::X1DBLCLK : fwButton == XBUTTON2 ? wmcmd::X2DBLCLK : wmcmd::NONE,
- GET_KEYSTATE_WPARAM(wParam), CPoint(lParam));
+ SendMessage(WM_XBUTTONDOWN, wParam, lParam);
+ UINT fwButton = GET_XBUTTON_WPARAM(wParam);
+ return OnButton(fwButton == XBUTTON1 ? wmcmd::X1DBLCLK : fwButton == XBUTTON2 ? wmcmd::X2DBLCLK : wmcmd::NONE,
+ GET_KEYSTATE_WPARAM(wParam), CPoint(lParam));
}
BOOL CMainFrame::OnMouseWheel(UINT nFlags, short zDelta, CPoint point)
{
- ScreenToClient(&point);
+ ScreenToClient(&point);
- BOOL fRet =
- zDelta > 0 ? OnButton(wmcmd::WUP, nFlags, point) :
- zDelta < 0 ? OnButton(wmcmd::WDOWN, nFlags, point) :
- FALSE;
+ BOOL fRet =
+ zDelta > 0 ? OnButton(wmcmd::WUP, nFlags, point) :
+ zDelta < 0 ? OnButton(wmcmd::WDOWN, nFlags, point) :
+ FALSE;
- return fRet;
+ return fRet;
}
void CMainFrame::OnMouseMove(UINT nFlags, CPoint point)
{
- // Waffs : ignore mousemoves when entering fullscreen
- if (m_lastMouseMove.x == -1 && m_lastMouseMove.y == -1) {
- m_lastMouseMove.x = point.x;
- m_lastMouseMove.y = point.y;
- }
-
- if (!m_OSD.OnMouseMove (nFlags, point)) {
- if (GetPlaybackMode() == PM_DVD) {
- CPoint vp = point - m_wndView.GetVideoRect().TopLeft();
- ULONG pulButtonIndex;
- if (!m_fHideCursor) {
- SetCursor(LoadCursor(NULL, SUCCEEDED(pDVDI->GetButtonAtPosition(vp, &pulButtonIndex)) ? IDC_HAND : IDC_ARROW));
- }
- pDVDC->SelectAtPosition(vp);
- }
-
- CSize diff = m_lastMouseMove - point;
- AppSettings& s = AfxGetAppSettings();
-
- if (m_pFullscreenWnd->IsWindow() && (abs(diff.cx)+abs(diff.cy)) >= 1) {
- //TRACE ("==> SHOW!\n");
- m_pFullscreenWnd->ShowCursor(true);
-
- // Casimir666 : hide the cursor if we are not in the DVD menu
- if ((GetPlaybackMode() == PM_FILE) || (GetPlaybackMode() == PM_DVD)) {
- KillTimer(TIMER_FULLSCREENMOUSEHIDER);
- SetTimer(TIMER_FULLSCREENMOUSEHIDER, 2000, NULL);
- }
- } else if (m_fFullScreen && (abs(diff.cx)+abs(diff.cy)) >= 1) {
- int nTimeOut = s.nShowBarsWhenFullScreenTimeOut;
-
- if (nTimeOut < 0) {
- m_fHideCursor = false;
- if (s.fShowBarsWhenFullScreen) {
- ShowControls(m_nCS);
- if (GetPlaybackMode() == PM_CAPTURE && !s.fHideNavigation && s.iDefaultCaptureDevice == 1) {
- m_wndNavigationBar.m_navdlg.UpdateElementList();
- m_wndNavigationBar.ShowControls(this, TRUE);
- }
- }
-
- KillTimer(TIMER_FULLSCREENCONTROLBARHIDER);
- SetTimer(TIMER_FULLSCREENMOUSEHIDER, 2000, NULL);
- } else if (nTimeOut == 0) {
- CRect r;
- GetClientRect(r);
- r.top = r.bottom;
-
- POSITION pos = m_bars.GetHeadPosition();
- for (int i = 1; pos; i <<= 1) {
- CControlBar* pNext = m_bars.GetNext(pos);
- CSize size = pNext->CalcFixedLayout(FALSE, TRUE);
- if (m_nCS & i) {
- r.top -= size.cy;
- }
- }
-
-
- // HACK: the controls would cover the menu too early hiding some buttons
- if (GetPlaybackMode() == PM_DVD
- && (m_iDVDDomain == DVD_DOMAIN_VideoManagerMenu
- || m_iDVDDomain == DVD_DOMAIN_VideoTitleSetMenu)) {
- r.top = r.bottom - 10;
- }
-
- m_fHideCursor = false;
-
- if (r.PtInRect(point)) {
- if (s.fShowBarsWhenFullScreen) {
- ShowControls(m_nCS);
- }
- } else {
- if (s.fShowBarsWhenFullScreen) {
- ShowControls(CS_NONE);
- }
- }
-
- // PM_CAPTURE: Left Navigation panel for switching channels
- if (GetPlaybackMode() == PM_CAPTURE && !s.fHideNavigation && s.iDefaultCaptureDevice == 1) {
- CRect rLeft;
- GetClientRect(rLeft);
- rLeft.right = rLeft.left;
- CSize size = m_wndNavigationBar.CalcFixedLayout(FALSE, TRUE);
- rLeft.right += size.cx;
-
- m_fHideCursor = false;
-
- if (rLeft.PtInRect(point)) {
- if (s.fShowBarsWhenFullScreen) {
- m_wndNavigationBar.m_navdlg.UpdateElementList();
- m_wndNavigationBar.ShowControls(this, TRUE);
- }
- } else {
- if (s.fShowBarsWhenFullScreen) {
- m_wndNavigationBar.ShowControls(this, FALSE);
- }
- }
- }
-
- SetTimer(TIMER_FULLSCREENMOUSEHIDER, 2000, NULL);
- } else {
- m_fHideCursor = false;
- if (s.fShowBarsWhenFullScreen) {
- ShowControls(m_nCS);
- }
-
- SetTimer(TIMER_FULLSCREENCONTROLBARHIDER, nTimeOut*1000, NULL);
- SetTimer(TIMER_FULLSCREENMOUSEHIDER, max(nTimeOut*1000, 2000), NULL);
- }
- }
-
- m_lastMouseMove = point;
-
- __super::OnMouseMove(nFlags, point);
- }
+ // Waffs : ignore mousemoves when entering fullscreen
+ if (m_lastMouseMove.x == -1 && m_lastMouseMove.y == -1) {
+ m_lastMouseMove.x = point.x;
+ m_lastMouseMove.y = point.y;
+ }
+
+ if (!m_OSD.OnMouseMove(nFlags, point)) {
+ if (GetPlaybackMode() == PM_DVD) {
+ CPoint vp = point - m_wndView.GetVideoRect().TopLeft();
+ ULONG pulButtonIndex;
+ if (!m_fHideCursor) {
+ SetCursor(LoadCursor(NULL, SUCCEEDED(pDVDI->GetButtonAtPosition(vp, &pulButtonIndex)) ? IDC_HAND : IDC_ARROW));
+ }
+ pDVDC->SelectAtPosition(vp);
+ }
+
+ CSize diff = m_lastMouseMove - point;
+ AppSettings& s = AfxGetAppSettings();
+
+ if (m_pFullscreenWnd->IsWindow() && (abs(diff.cx) + abs(diff.cy)) >= 1) {
+ //TRACE ("==> SHOW!\n");
+ m_pFullscreenWnd->ShowCursor(true);
+
+ // Casimir666 : hide the cursor if we are not in the DVD menu
+ if ((GetPlaybackMode() == PM_FILE) || (GetPlaybackMode() == PM_DVD)) {
+ KillTimer(TIMER_FULLSCREENMOUSEHIDER);
+ SetTimer(TIMER_FULLSCREENMOUSEHIDER, 2000, NULL);
+ }
+ } else if (m_fFullScreen && (abs(diff.cx) + abs(diff.cy)) >= 1) {
+ int nTimeOut = s.nShowBarsWhenFullScreenTimeOut;
+
+ if (nTimeOut < 0) {
+ m_fHideCursor = false;
+ if (s.fShowBarsWhenFullScreen) {
+ ShowControls(m_nCS);
+ if (GetPlaybackMode() == PM_CAPTURE && !s.fHideNavigation && s.iDefaultCaptureDevice == 1) {
+ m_wndNavigationBar.m_navdlg.UpdateElementList();
+ m_wndNavigationBar.ShowControls(this, TRUE);
+ }
+ }
+
+ KillTimer(TIMER_FULLSCREENCONTROLBARHIDER);
+ SetTimer(TIMER_FULLSCREENMOUSEHIDER, 2000, NULL);
+ } else if (nTimeOut == 0) {
+ CRect r;
+ GetClientRect(r);
+ r.top = r.bottom;
+
+ POSITION pos = m_bars.GetHeadPosition();
+ for (int i = 1; pos; i <<= 1) {
+ CControlBar* pNext = m_bars.GetNext(pos);
+ CSize size = pNext->CalcFixedLayout(FALSE, TRUE);
+ if (m_nCS & i) {
+ r.top -= size.cy;
+ }
+ }
+
+
+ // HACK: the controls would cover the menu too early hiding some buttons
+ if (GetPlaybackMode() == PM_DVD
+ && (m_iDVDDomain == DVD_DOMAIN_VideoManagerMenu
+ || m_iDVDDomain == DVD_DOMAIN_VideoTitleSetMenu)) {
+ r.top = r.bottom - 10;
+ }
+
+ m_fHideCursor = false;
+
+ if (r.PtInRect(point)) {
+ if (s.fShowBarsWhenFullScreen) {
+ ShowControls(m_nCS);
+ }
+ } else {
+ if (s.fShowBarsWhenFullScreen) {
+ ShowControls(CS_NONE);
+ }
+ }
+
+ // PM_CAPTURE: Left Navigation panel for switching channels
+ if (GetPlaybackMode() == PM_CAPTURE && !s.fHideNavigation && s.iDefaultCaptureDevice == 1) {
+ CRect rLeft;
+ GetClientRect(rLeft);
+ rLeft.right = rLeft.left;
+ CSize size = m_wndNavigationBar.CalcFixedLayout(FALSE, TRUE);
+ rLeft.right += size.cx;
+
+ m_fHideCursor = false;
+
+ if (rLeft.PtInRect(point)) {
+ if (s.fShowBarsWhenFullScreen) {
+ m_wndNavigationBar.m_navdlg.UpdateElementList();
+ m_wndNavigationBar.ShowControls(this, TRUE);
+ }
+ } else {
+ if (s.fShowBarsWhenFullScreen) {
+ m_wndNavigationBar.ShowControls(this, FALSE);
+ }
+ }
+ }
+
+ SetTimer(TIMER_FULLSCREENMOUSEHIDER, 2000, NULL);
+ } else {
+ m_fHideCursor = false;
+ if (s.fShowBarsWhenFullScreen) {
+ ShowControls(m_nCS);
+ }
+
+ SetTimer(TIMER_FULLSCREENCONTROLBARHIDER, nTimeOut * 1000, NULL);
+ SetTimer(TIMER_FULLSCREENMOUSEHIDER, max(nTimeOut * 1000, 2000), NULL);
+ }
+ }
+
+ m_lastMouseMove = point;
+
+ __super::OnMouseMove(nFlags, point);
+ }
}
LRESULT CMainFrame::OnNcHitTest(CPoint point)
{
- LRESULT nHitTest = __super::OnNcHitTest(point);
- return ((IsCaptionHidden()) && nHitTest == HTCLIENT) ? HTCAPTION : nHitTest;
+ LRESULT nHitTest = __super::OnNcHitTest(point);
+ return ((IsCaptionHidden()) && nHitTest == HTCLIENT) ? HTCAPTION : nHitTest;
}
void CMainFrame::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
- bool Shift_State = !!(::GetKeyState(VK_SHIFT)&0x8000);
- if (AfxGetAppSettings().fFastSeek) {
- Shift_State = !Shift_State;
- }
+ bool Shift_State = !!(::GetKeyState(VK_SHIFT) & 0x8000);
+ if (AfxGetAppSettings().fFastSeek) {
+ Shift_State = !Shift_State;
+ }
- if (pScrollBar->IsKindOf(RUNTIME_CLASS(CVolumeCtrl))) {
- OnPlayVolume(0);
- } else if (pScrollBar->IsKindOf(RUNTIME_CLASS(CPlayerSeekBar)) && m_iMediaLoadState == MLS_LOADED) {
- SeekTo(m_wndSeekBar.GetPos(), Shift_State);
- } else if (m_pVideoWnd == m_pVideoWnd) {
- SeekTo(m_OSD.GetPos(), Shift_State);
- }
+ if (pScrollBar->IsKindOf(RUNTIME_CLASS(CVolumeCtrl))) {
+ OnPlayVolume(0);
+ } else if (pScrollBar->IsKindOf(RUNTIME_CLASS(CPlayerSeekBar)) && m_iMediaLoadState == MLS_LOADED) {
+ SeekTo(m_wndSeekBar.GetPos(), Shift_State);
+ } else if (m_pVideoWnd == m_pVideoWnd) {
+ SeekTo(m_OSD.GetPos(), Shift_State);
+ }
- __super::OnHScroll(nSBCode, nPos, pScrollBar);
+ __super::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CMainFrame::OnInitMenu(CMenu* pMenu)
{
- __super::OnInitMenu(pMenu);
+ __super::OnInitMenu(pMenu);
- const UINT uiMenuCount = pMenu->GetMenuItemCount();
- if (uiMenuCount == -1) {
- return;
- }
+ const UINT uiMenuCount = pMenu->GetMenuItemCount();
+ if (uiMenuCount == -1) {
+ return;
+ }
- MENUITEMINFO mii;
- mii.cbSize = sizeof(mii);
+ MENUITEMINFO mii;
+ mii.cbSize = sizeof(mii);
- for (UINT i = 0; i < uiMenuCount; ++i) {
+ for (UINT i = 0; i < uiMenuCount; ++i) {
#ifdef _DEBUG
- CString str;
- pMenu->GetMenuString(i, str, MF_BYPOSITION);
- str.Remove('&');
+ CString str;
+ pMenu->GetMenuString(i, str, MF_BYPOSITION);
+ str.Remove('&');
#endif
- UINT itemID = pMenu->GetMenuItemID(i);
- if (itemID == 0xFFFFFFFF) {
- mii.fMask = MIIM_ID;
- pMenu->GetMenuItemInfo(i, &mii, TRUE);
- itemID = mii.wID;
- }
-
- CMenu* pSubMenu = NULL;
-
- if (itemID == ID_FAVORITES) {
- SetupFavoritesSubMenu();
- pSubMenu = &m_favorites;
- }/*else if (itemID == ID_RECENT_FILES) {
- SetupRecentFilesSubMenu();
- pSubMenu = &m_recentfiles;
- }*/
-
- if (pSubMenu) {
- mii.fMask = MIIM_STATE|MIIM_SUBMENU|MIIM_ID;
- mii.fType = MF_POPUP;
- mii.wID = itemID; // save ID after set popup type
- mii.hSubMenu = pSubMenu->m_hMenu;
- mii.fState = (pSubMenu->GetMenuItemCount() > 0 ? MF_ENABLED : (MF_DISABLED|MF_GRAYED));
- pMenu->SetMenuItemInfo(i, &mii, TRUE);
- }
- }
+ UINT itemID = pMenu->GetMenuItemID(i);
+ if (itemID == 0xFFFFFFFF) {
+ mii.fMask = MIIM_ID;
+ pMenu->GetMenuItemInfo(i, &mii, TRUE);
+ itemID = mii.wID;
+ }
+
+ CMenu* pSubMenu = NULL;
+
+ if (itemID == ID_FAVORITES) {
+ SetupFavoritesSubMenu();
+ pSubMenu = &m_favorites;
+ }/*else if (itemID == ID_RECENT_FILES) {
+ SetupRecentFilesSubMenu();
+ pSubMenu = &m_recentfiles;
+ }*/
+
+ if (pSubMenu) {
+ mii.fMask = MIIM_STATE | MIIM_SUBMENU | MIIM_ID;
+ mii.fType = MF_POPUP;
+ mii.wID = itemID; // save ID after set popup type
+ mii.hSubMenu = pSubMenu->m_hMenu;
+ mii.fState = (pSubMenu->GetMenuItemCount() > 0 ? MF_ENABLED : (MF_DISABLED | MF_GRAYED));
+ pMenu->SetMenuItemInfo(i, &mii, TRUE);
+ }
+ }
}
void CMainFrame::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
{
- __super::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
+ __super::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
- UINT uiMenuCount = pPopupMenu->GetMenuItemCount();
- if (uiMenuCount == -1) {
- return;
- }
+ UINT uiMenuCount = pPopupMenu->GetMenuItemCount();
+ if (uiMenuCount == -1) {
+ return;
+ }
- MENUITEMINFO mii;
- mii.cbSize = sizeof(mii);
+ MENUITEMINFO mii;
+ mii.cbSize = sizeof(mii);
- for (UINT i = 0; i < uiMenuCount; ++i) {
+ for (UINT i = 0; i < uiMenuCount; ++i) {
#ifdef _DEBUG
- CString str;
- pPopupMenu->GetMenuString(i, str, MF_BYPOSITION);
- str.Remove('&');
+ CString str;
+ pPopupMenu->GetMenuString(i, str, MF_BYPOSITION);
+ str.Remove('&');
#endif
- UINT firstSubItemID = 0;
- CMenu* sm = pPopupMenu->GetSubMenu(i);
- if (sm) {
- firstSubItemID= sm->GetMenuItemID(0);
- }
-
- if (firstSubItemID == ID_NAVIGATE_SKIPBACK) { // is "Navigate" submenu {
- UINT fState = (m_iMediaLoadState == MLS_LOADED
- && (1/*GetPlaybackMode() == PM_DVD *//*|| (GetPlaybackMode() == PM_FILE && m_PlayList.GetCount() > 0)*/))
- ? MF_ENABLED
- : (MF_DISABLED|MF_GRAYED);
- pPopupMenu->EnableMenuItem(i, MF_BYPOSITION|fState);
- continue;
- }
- if (firstSubItemID == ID_VIEW_VF_HALF // is "Video Frame" submenu
- || firstSubItemID == ID_VIEW_INCSIZE // is "Pan&Scan" submenu
- || firstSubItemID == ID_ASPECTRATIO_SOURCE // is "Override Aspect Ratio" submenu
- || firstSubItemID == ID_VIEW_ZOOM_50) { // is "Zoom" submenu
- UINT fState = (m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly)
- ? MF_ENABLED
- : (MF_DISABLED|MF_GRAYED);
- pPopupMenu->EnableMenuItem(i, MF_BYPOSITION|fState);
- continue;
- }
-
- UINT itemID = pPopupMenu->GetMenuItemID(i);
- if (itemID == 0xFFFFFFFF) {
- mii.fMask = MIIM_ID;
- pPopupMenu->GetMenuItemInfo(i, &mii, TRUE);
- itemID = mii.wID;
- }
- CMenu* pSubMenu = NULL;
-
- if (itemID == ID_FILE_OPENDISC32774) {
- SetupOpenCDSubMenu();
- pSubMenu = &m_opencds;
- } else if (itemID == ID_FILTERS) {
- SetupFiltersSubMenu();
- pSubMenu = &m_filters;
- } else if (itemID == ID_MENU_LANGUAGE) {
- SetupLanguageMenu();
- pSubMenu = &m_language;
- } else if (itemID == ID_AUDIOS) {
- SetupAudioSwitcherSubMenu();
- pSubMenu = &m_audios;
- } else if (itemID == ID_SUBTITLES) {
- SetupSubtitlesSubMenu();
- pSubMenu = &m_subtitles;
- } else if (itemID == ID_AUDIOLANGUAGE) {
- SetupNavAudioSubMenu();
- pSubMenu = &m_navaudio;
- } else if (itemID == ID_SUBTITLELANGUAGE) {
- SetupNavSubtitleSubMenu();
- pSubMenu = &m_navsubtitle;
- } else if (itemID == ID_VIDEOANGLE) {
-
- CString menu_str;
- if (GetPlaybackMode() == PM_DVD) {
- menu_str.LoadString(IDS_MENU_VIDEO_ANGLE);
- } else {
- menu_str.LoadString(IDS_MENU_VIDEO_STREAM);
- }
-
- mii.fMask = MIIM_STRING;
- mii.dwTypeData = (LPTSTR)(LPCTSTR)menu_str;
- pPopupMenu->SetMenuItemInfo(i, &mii, TRUE);
-
- SetupNavAngleSubMenu();
- pSubMenu = &m_navangle;
- } else if (itemID == ID_JUMPTO) {
- SetupNavChaptersSubMenu();
- pSubMenu = &m_navchapters;
- } else if (itemID == ID_FAVORITES) {
- SetupFavoritesSubMenu();
- pSubMenu = &m_favorites;
- } else if (itemID == ID_RECENT_FILES) {
- SetupRecentFilesSubMenu();
- pSubMenu = &m_recentfiles;
- } else if (itemID == ID_SHADERS) {
- SetupShadersSubMenu();
- pSubMenu = &m_shaders;
- }
-
- if (pSubMenu) {
- mii.fMask = MIIM_STATE|MIIM_SUBMENU|MIIM_ID;
- mii.fType = MF_POPUP;
- mii.wID = itemID; // save ID after set popup type
- mii.hSubMenu = pSubMenu->m_hMenu;
- mii.fState = (pSubMenu->GetMenuItemCount() > 0 ? MF_ENABLED : (MF_DISABLED|MF_GRAYED));
- pPopupMenu->SetMenuItemInfo(i, &mii, TRUE);
- //continue;
- }
- }
-
- //
-
- uiMenuCount = pPopupMenu->GetMenuItemCount();
- if (uiMenuCount == -1) {
- return;
- }
-
- for (UINT i = 0; i < uiMenuCount; ++i) {
- UINT nID = pPopupMenu->GetMenuItemID(i);
- if (nID == ID_SEPARATOR || nID == -1
- || nID >= ID_FAVORITES_FILE_START && nID <= ID_FAVORITES_FILE_END
- || nID >= ID_RECENT_FILE_START && nID <= ID_RECENT_FILE_END
- || nID >= ID_NAVIGATE_CHAP_SUBITEM_START && nID <= ID_NAVIGATE_CHAP_SUBITEM_END) {
- continue;
- }
-
- CString str;
- pPopupMenu->GetMenuString(i, str, MF_BYPOSITION);
- int k = str.Find('\t');
- if (k > 0) {
- str = str.Left(k);
- }
-
- CString key = CPPageAccelTbl::MakeAccelShortcutLabel(nID);
- if (key.IsEmpty() && k < 0) {
- continue;
- }
- str += _T("\t") + key;
-
- // BUG(?): this disables menu item update ui calls for some reason...
- //pPopupMenu->ModifyMenu(i, MF_BYPOSITION|MF_STRING, nID, str);
-
- // this works fine
- MENUITEMINFO mii;
- mii.cbSize = sizeof(mii);
- mii.fMask = MIIM_STRING;
- mii.dwTypeData = (LPTSTR)(LPCTSTR)str;
- pPopupMenu->SetMenuItemInfo(i, &mii, TRUE);
-
- }
-
- //
-
- uiMenuCount = pPopupMenu->GetMenuItemCount();
- if (uiMenuCount == -1) {
- return;
- }
-
- bool fPnSPresets = false;
-
- for (UINT i = 0; i < uiMenuCount; ++i) {
- UINT nID = pPopupMenu->GetMenuItemID(i);
-
- if (nID >= ID_PANNSCAN_PRESETS_START && nID < ID_PANNSCAN_PRESETS_END) {
- do {
- nID = pPopupMenu->GetMenuItemID(i);
- pPopupMenu->DeleteMenu(i, MF_BYPOSITION);
- uiMenuCount--;
- } while (i < uiMenuCount && nID >= ID_PANNSCAN_PRESETS_START && nID < ID_PANNSCAN_PRESETS_END);
-
- nID = pPopupMenu->GetMenuItemID(i);
- }
-
- if (nID == ID_VIEW_RESET) {
- fPnSPresets = true;
- }
- }
-
- if (fPnSPresets) {
- AppSettings& s = AfxGetAppSettings();
- INT_PTR i = 0, j = s.m_pnspresets.GetCount();
- for (; i < j; i++) {
- int k = 0;
- CString label = s.m_pnspresets[i].Tokenize(_T(","), k);
- pPopupMenu->InsertMenu(ID_VIEW_RESET, MF_BYCOMMAND, ID_PANNSCAN_PRESETS_START+i, label);
- }
- //if (j > 0)
- {
- pPopupMenu->InsertMenu(ID_VIEW_RESET, MF_BYCOMMAND, ID_PANNSCAN_PRESETS_START+i, ResStr(IDS_PANSCAN_EDIT));
- pPopupMenu->InsertMenu(ID_VIEW_RESET, MF_BYCOMMAND|MF_SEPARATOR);
- }
- }
+ UINT firstSubItemID = 0;
+ CMenu* sm = pPopupMenu->GetSubMenu(i);
+ if (sm) {
+ firstSubItemID = sm->GetMenuItemID(0);
+ }
+
+ if (firstSubItemID == ID_NAVIGATE_SKIPBACK) { // is "Navigate" submenu {
+ UINT fState = (m_iMediaLoadState == MLS_LOADED
+ && (1/*GetPlaybackMode() == PM_DVD *//*|| (GetPlaybackMode() == PM_FILE && m_PlayList.GetCount() > 0)*/))
+ ? MF_ENABLED
+ : (MF_DISABLED | MF_GRAYED);
+ pPopupMenu->EnableMenuItem(i, MF_BYPOSITION | fState);
+ continue;
+ }
+ if (firstSubItemID == ID_VIEW_VF_HALF // is "Video Frame" submenu
+ || firstSubItemID == ID_VIEW_INCSIZE // is "Pan&Scan" submenu
+ || firstSubItemID == ID_ASPECTRATIO_SOURCE // is "Override Aspect Ratio" submenu
+ || firstSubItemID == ID_VIEW_ZOOM_50) { // is "Zoom" submenu
+ UINT fState = (m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly)
+ ? MF_ENABLED
+ : (MF_DISABLED | MF_GRAYED);
+ pPopupMenu->EnableMenuItem(i, MF_BYPOSITION | fState);
+ continue;
+ }
+
+ UINT itemID = pPopupMenu->GetMenuItemID(i);
+ if (itemID == 0xFFFFFFFF) {
+ mii.fMask = MIIM_ID;
+ pPopupMenu->GetMenuItemInfo(i, &mii, TRUE);
+ itemID = mii.wID;
+ }
+ CMenu* pSubMenu = NULL;
+
+ if (itemID == ID_FILE_OPENDISC32774) {
+ SetupOpenCDSubMenu();
+ pSubMenu = &m_opencds;
+ } else if (itemID == ID_FILTERS) {
+ SetupFiltersSubMenu();
+ pSubMenu = &m_filters;
+ } else if (itemID == ID_MENU_LANGUAGE) {
+ SetupLanguageMenu();
+ pSubMenu = &m_language;
+ } else if (itemID == ID_AUDIOS) {
+ SetupAudioSwitcherSubMenu();
+ pSubMenu = &m_audios;
+ } else if (itemID == ID_SUBTITLES) {
+ SetupSubtitlesSubMenu();
+ pSubMenu = &m_subtitles;
+ } else if (itemID == ID_AUDIOLANGUAGE) {
+ SetupNavAudioSubMenu();
+ pSubMenu = &m_navaudio;
+ } else if (itemID == ID_SUBTITLELANGUAGE) {
+ SetupNavSubtitleSubMenu();
+ pSubMenu = &m_navsubtitle;
+ } else if (itemID == ID_VIDEOANGLE) {
+
+ CString menu_str;
+ if (GetPlaybackMode() == PM_DVD) {
+ menu_str.LoadString(IDS_MENU_VIDEO_ANGLE);
+ } else {
+ menu_str.LoadString(IDS_MENU_VIDEO_STREAM);
+ }
+
+ mii.fMask = MIIM_STRING;
+ mii.dwTypeData = (LPTSTR)(LPCTSTR)menu_str;
+ pPopupMenu->SetMenuItemInfo(i, &mii, TRUE);
+
+ SetupNavAngleSubMenu();
+ pSubMenu = &m_navangle;
+ } else if (itemID == ID_JUMPTO) {
+ SetupNavChaptersSubMenu();
+ pSubMenu = &m_navchapters;
+ } else if (itemID == ID_FAVORITES) {
+ SetupFavoritesSubMenu();
+ pSubMenu = &m_favorites;
+ } else if (itemID == ID_RECENT_FILES) {
+ SetupRecentFilesSubMenu();
+ pSubMenu = &m_recentfiles;
+ } else if (itemID == ID_SHADERS) {
+ SetupShadersSubMenu();
+ pSubMenu = &m_shaders;
+ }
+
+ if (pSubMenu) {
+ mii.fMask = MIIM_STATE | MIIM_SUBMENU | MIIM_ID;
+ mii.fType = MF_POPUP;
+ mii.wID = itemID; // save ID after set popup type
+ mii.hSubMenu = pSubMenu->m_hMenu;
+ mii.fState = (pSubMenu->GetMenuItemCount() > 0 ? MF_ENABLED : (MF_DISABLED | MF_GRAYED));
+ pPopupMenu->SetMenuItemInfo(i, &mii, TRUE);
+ //continue;
+ }
+ }
+
+ //
+
+ uiMenuCount = pPopupMenu->GetMenuItemCount();
+ if (uiMenuCount == -1) {
+ return;
+ }
+
+ for (UINT i = 0; i < uiMenuCount; ++i) {
+ UINT nID = pPopupMenu->GetMenuItemID(i);
+ if (nID == ID_SEPARATOR || nID == -1
+ || nID >= ID_FAVORITES_FILE_START && nID <= ID_FAVORITES_FILE_END
+ || nID >= ID_RECENT_FILE_START && nID <= ID_RECENT_FILE_END
+ || nID >= ID_NAVIGATE_CHAP_SUBITEM_START && nID <= ID_NAVIGATE_CHAP_SUBITEM_END) {
+ continue;
+ }
+
+ CString str;
+ pPopupMenu->GetMenuString(i, str, MF_BYPOSITION);
+ int k = str.Find('\t');
+ if (k > 0) {
+ str = str.Left(k);
+ }
+
+ CString key = CPPageAccelTbl::MakeAccelShortcutLabel(nID);
+ if (key.IsEmpty() && k < 0) {
+ continue;
+ }
+ str += _T("\t") + key;
+
+ // BUG(?): this disables menu item update ui calls for some reason...
+ //pPopupMenu->ModifyMenu(i, MF_BYPOSITION|MF_STRING, nID, str);
+
+ // this works fine
+ MENUITEMINFO mii;
+ mii.cbSize = sizeof(mii);
+ mii.fMask = MIIM_STRING;
+ mii.dwTypeData = (LPTSTR)(LPCTSTR)str;
+ pPopupMenu->SetMenuItemInfo(i, &mii, TRUE);
+
+ }
+
+ //
+
+ uiMenuCount = pPopupMenu->GetMenuItemCount();
+ if (uiMenuCount == -1) {
+ return;
+ }
+
+ bool fPnSPresets = false;
+
+ for (UINT i = 0; i < uiMenuCount; ++i) {
+ UINT nID = pPopupMenu->GetMenuItemID(i);
+
+ if (nID >= ID_PANNSCAN_PRESETS_START && nID < ID_PANNSCAN_PRESETS_END) {
+ do {
+ nID = pPopupMenu->GetMenuItemID(i);
+ pPopupMenu->DeleteMenu(i, MF_BYPOSITION);
+ uiMenuCount--;
+ } while (i < uiMenuCount && nID >= ID_PANNSCAN_PRESETS_START && nID < ID_PANNSCAN_PRESETS_END);
+
+ nID = pPopupMenu->GetMenuItemID(i);
+ }
+
+ if (nID == ID_VIEW_RESET) {
+ fPnSPresets = true;
+ }
+ }
+
+ if (fPnSPresets) {
+ AppSettings& s = AfxGetAppSettings();
+ INT_PTR i = 0, j = s.m_pnspresets.GetCount();
+ for (; i < j; i++) {
+ int k = 0;
+ CString label = s.m_pnspresets[i].Tokenize(_T(","), k);
+ pPopupMenu->InsertMenu(ID_VIEW_RESET, MF_BYCOMMAND, ID_PANNSCAN_PRESETS_START + i, label);
+ }
+ //if (j > 0)
+ {
+ pPopupMenu->InsertMenu(ID_VIEW_RESET, MF_BYCOMMAND, ID_PANNSCAN_PRESETS_START + i, ResStr(IDS_PANSCAN_EDIT));
+ pPopupMenu->InsertMenu(ID_VIEW_RESET, MF_BYCOMMAND | MF_SEPARATOR);
+ }
+ }
}
void CMainFrame::OnUnInitMenuPopup(CMenu* pPopupMenu, UINT nFlags)
{
- __super::OnUnInitMenuPopup(pPopupMenu, nFlags);
+ __super::OnUnInitMenuPopup(pPopupMenu, nFlags);
- m_nMenuHideTick = GetTickCount();
+ m_nMenuHideTick = GetTickCount();
}
BOOL CMainFrame::OnMenu(CMenu* pMenu)
{
- if (!pMenu) {
- return FALSE;
- }
- AppSettings& s = AfxGetAppSettings();
- // Do not show popup menu in D3D fullscreen for Sync Renderer. It has several adverse effects.
- if (IsD3DFullScreenMode() && s.iDSVideoRendererType == VIDRNDT_DS_SYNC) {
- return FALSE;
- }
- KillTimer(TIMER_FULLSCREENMOUSEHIDER);
- m_fHideCursor = false;
+ if (!pMenu) {
+ return FALSE;
+ }
+ AppSettings& s = AfxGetAppSettings();
+ // Do not show popup menu in D3D fullscreen for Sync Renderer. It has several adverse effects.
+ if (IsD3DFullScreenMode() && s.iDSVideoRendererType == VIDRNDT_DS_SYNC) {
+ return FALSE;
+ }
+ KillTimer(TIMER_FULLSCREENMOUSEHIDER);
+ m_fHideCursor = false;
- CPoint point;
- GetCursorPos(&point);
+ CPoint point;
+ GetCursorPos(&point);
- MSG msg;
- pMenu->TrackPopupMenu(TPM_RIGHTBUTTON|TPM_NOANIMATION, point.x+1, point.y+1, this);
- PeekMessage(&msg, this->m_hWnd, WM_LBUTTONDOWN, WM_LBUTTONDOWN, PM_REMOVE); //remove the click LMB, which closes the popup menu
+ MSG msg;
+ pMenu->TrackPopupMenu(TPM_RIGHTBUTTON | TPM_NOANIMATION, point.x + 1, point.y + 1, this);
+ PeekMessage(&msg, this->m_hWnd, WM_LBUTTONDOWN, WM_LBUTTONDOWN, PM_REMOVE); //remove the click LMB, which closes the popup menu
- if (m_fFullScreen) {
- SetTimer(TIMER_FULLSCREENMOUSEHIDER, 2000, NULL); //need when working with menus and use the keyboard only
- }
+ if (m_fFullScreen) {
+ SetTimer(TIMER_FULLSCREENMOUSEHIDER, 2000, NULL); //need when working with menus and use the keyboard only
+ }
- return TRUE;
+ return TRUE;
}
void CMainFrame::OnMenuPlayerShort()
{
- if (IsMenuHidden() || m_pFullscreenWnd->IsWindow()) {
- OnMenu(m_popupmain.GetSubMenu(0));
- } else {
- OnMenu(m_popup.GetSubMenu(0));
- }
+ if (IsMenuHidden() || m_pFullscreenWnd->IsWindow()) {
+ OnMenu(m_popupmain.GetSubMenu(0));
+ } else {
+ OnMenu(m_popup.GetSubMenu(0));
+ }
}
void CMainFrame::OnMenuPlayerLong()
{
- OnMenu(m_popupmain.GetSubMenu(0));
+ OnMenu(m_popupmain.GetSubMenu(0));
}
void CMainFrame::OnMenuFilters()
{
- SetupFiltersSubMenu();
- OnMenu(&m_filters);
+ SetupFiltersSubMenu();
+ OnMenu(&m_filters);
}
void CMainFrame::OnUpdatePlayerStatus(CCmdUI* pCmdUI)
{
- if (m_iMediaLoadState == MLS_LOADING) {
- pCmdUI->SetText(ResStr(IDS_CONTROLS_OPENING));
- if ((AfxGetAppSettings().fUseWin7TaskBar) && (m_pTaskbarList)) {
- m_pTaskbarList->SetProgressState(m_hWnd, TBPF_INDETERMINATE);
- }
- } else if (m_iMediaLoadState == MLS_LOADED) {
- CString msg;
-
- if (!m_playingmsg.IsEmpty()) {
- msg = m_playingmsg;
- } else if (m_fCapturing) {
- msg.LoadString(IDS_CONTROLS_CAPTURING);
-
- if (pAMDF) {
- long lDropped = 0;
- pAMDF->GetNumDropped(&lDropped);
- long lNotDropped = 0;
- pAMDF->GetNumNotDropped(&lNotDropped);
-
- if ((lDropped + lNotDropped) > 0) {
- msg.AppendFormat(IDS_MAINFRM_37, lDropped + lNotDropped, lDropped);
- }
- }
-
- CComPtr<IPin> pPin;
- if (SUCCEEDED(pCGB->FindPin(m_wndCaptureBar.m_capdlg.m_pDst, PINDIR_INPUT, NULL, NULL, FALSE, 0, &pPin))) {
- LONGLONG size = 0;
- if (CComQIPtr<IStream> pStream = pPin) {
- pStream->Commit(STGC_DEFAULT);
-
- WIN32_FIND_DATA findFileData;
- HANDLE h = FindFirstFile(m_wndCaptureBar.m_capdlg.m_file, &findFileData);
- if (h != INVALID_HANDLE_VALUE) {
- size = ((LONGLONG)findFileData.nFileSizeHigh << 32) | findFileData.nFileSizeLow;
-
- if (size < 1024i64*1024) {
- msg.AppendFormat(IDS_MAINFRM_38, size/1024);
- } else { //if (size < 1024i64*1024*1024)
- msg.AppendFormat(IDS_MAINFRM_39, size/1024/1024);
- }
-
- FindClose(h);
- }
- }
-
- ULARGE_INTEGER FreeBytesAvailable, TotalNumberOfBytes, TotalNumberOfFreeBytes;
- if (GetDiskFreeSpaceEx(
- m_wndCaptureBar.m_capdlg.m_file.Left(m_wndCaptureBar.m_capdlg.m_file.ReverseFind('\\')+1),
- &FreeBytesAvailable, &TotalNumberOfBytes, &TotalNumberOfFreeBytes)) {
- if (FreeBytesAvailable.QuadPart < 1024i64*1024) {
- msg.AppendFormat(IDS_MAINFRM_40, FreeBytesAvailable.QuadPart/1024);
- } else { //if (FreeBytesAvailable.QuadPart < 1024i64*1024*1024)
- msg.AppendFormat(IDS_MAINFRM_41, FreeBytesAvailable.QuadPart/1024/1024);
- }
- }
-
- if (m_wndCaptureBar.m_capdlg.m_pMux) {
- __int64 pos = 0;
- CComQIPtr<IMediaSeeking> pMuxMS = m_wndCaptureBar.m_capdlg.m_pMux;
- if (pMuxMS && SUCCEEDED(pMuxMS->GetCurrentPosition(&pos)) && pos > 0) {
- double bytepersec = 10000000.0 * size / pos;
- if (bytepersec > 0) {
- m_rtDurationOverride = __int64(10000000.0 * (FreeBytesAvailable.QuadPart+size) / bytepersec);
- }
- }
- }
-
- if (m_wndCaptureBar.m_capdlg.m_pVidBuffer
- || m_wndCaptureBar.m_capdlg.m_pAudBuffer) {
- int nFreeVidBuffers = 0, nFreeAudBuffers = 0;
- if (CComQIPtr<IBufferFilter> pVB = m_wndCaptureBar.m_capdlg.m_pVidBuffer) {
- nFreeVidBuffers = pVB->GetFreeBuffers();
- }
- if (CComQIPtr<IBufferFilter> pAB = m_wndCaptureBar.m_capdlg.m_pAudBuffer) {
- nFreeAudBuffers = pAB->GetFreeBuffers();
- }
-
- msg.AppendFormat(IDS_MAINFRM_42, nFreeVidBuffers, nFreeAudBuffers);
- }
- }
- } else if (m_fBuffering) {
- BeginEnumFilters(pGB, pEF, pBF) {
- if (CComQIPtr<IAMNetworkStatus, &IID_IAMNetworkStatus> pAMNS = pBF) {
- long BufferingProgress = 0;
- if (SUCCEEDED(pAMNS->get_BufferingProgress(&BufferingProgress)) && BufferingProgress > 0) {
- msg.Format(IDS_CONTROLS_BUFFERING, BufferingProgress);
-
- __int64 start = 0, stop = 0;
- m_wndSeekBar.GetRange(start, stop);
- m_fLiveWM = (stop == start);
- }
- break;
- }
- }
- EndEnumFilters;
- } else if (pAMOP) {
- __int64 t = 0, c = 0;
- if (SUCCEEDED(pAMOP->QueryProgress(&t, &c)) && t > 0 && c < t) {
- msg.Format(IDS_CONTROLS_BUFFERING, c*100/t);
- }
-
- if (m_fUpdateInfoBar) {
- OpenSetupInfoBar();
- }
- }
-
- OAFilterState fs = GetMediaState();
- CString UI_Text =
- !msg.IsEmpty() ? msg :
- fs == State_Stopped ? ResStr(IDS_CONTROLS_STOPPED) :
- (fs == State_Paused || m_fFrameSteppingActive) ? ResStr(IDS_CONTROLS_PAUSED) :
- fs == State_Running ? ResStr(IDS_CONTROLS_PLAYING) :
- _T("");
- if ((!m_fAudioOnly) && (UI_Text == ResStr(IDS_CONTROLS_PAUSED) || UI_Text == ResStr(IDS_CONTROLS_PLAYING))) {
- CString DXVA_Text = GetDXVADecoderDescription();
- if (!(_T("Not using DXVA")==DXVA_Text) || (_T("Unknown")==DXVA_Text)) {
- UI_Text += _T(" [DXVA]");
- }
- }
- pCmdUI->SetText(UI_Text);
- } else if (m_iMediaLoadState == MLS_CLOSING) {
- pCmdUI->SetText(ResStr(IDS_CONTROLS_CLOSING));
- if ((AfxGetAppSettings().fUseWin7TaskBar) && (m_pTaskbarList)) {
- m_pTaskbarList->SetProgressState(m_hWnd, TBPF_INDETERMINATE);
- }
- } else {
- pCmdUI->SetText(m_closingmsg);
- }
+ if (m_iMediaLoadState == MLS_LOADING) {
+ pCmdUI->SetText(ResStr(IDS_CONTROLS_OPENING));
+ if ((AfxGetAppSettings().fUseWin7TaskBar) && (m_pTaskbarList)) {
+ m_pTaskbarList->SetProgressState(m_hWnd, TBPF_INDETERMINATE);
+ }
+ } else if (m_iMediaLoadState == MLS_LOADED) {
+ CString msg;
+
+ if (!m_playingmsg.IsEmpty()) {
+ msg = m_playingmsg;
+ } else if (m_fCapturing) {
+ msg.LoadString(IDS_CONTROLS_CAPTURING);
+
+ if (pAMDF) {
+ long lDropped = 0;
+ pAMDF->GetNumDropped(&lDropped);
+ long lNotDropped = 0;
+ pAMDF->GetNumNotDropped(&lNotDropped);
+
+ if ((lDropped + lNotDropped) > 0) {
+ msg.AppendFormat(IDS_MAINFRM_37, lDropped + lNotDropped, lDropped);
+ }
+ }
+
+ CComPtr<IPin> pPin;
+ if (SUCCEEDED(pCGB->FindPin(m_wndCaptureBar.m_capdlg.m_pDst, PINDIR_INPUT, NULL, NULL, FALSE, 0, &pPin))) {
+ LONGLONG size = 0;
+ if (CComQIPtr<IStream> pStream = pPin) {
+ pStream->Commit(STGC_DEFAULT);
+
+ WIN32_FIND_DATA findFileData;
+ HANDLE h = FindFirstFile(m_wndCaptureBar.m_capdlg.m_file, &findFileData);
+ if (h != INVALID_HANDLE_VALUE) {
+ size = ((LONGLONG)findFileData.nFileSizeHigh << 32) | findFileData.nFileSizeLow;
+
+ if (size < 1024i64 * 1024) {
+ msg.AppendFormat(IDS_MAINFRM_38, size / 1024);
+ } else { //if (size < 1024i64*1024*1024)
+ msg.AppendFormat(IDS_MAINFRM_39, size / 1024 / 1024);
+ }
+
+ FindClose(h);
+ }
+ }
+
+ ULARGE_INTEGER FreeBytesAvailable, TotalNumberOfBytes, TotalNumberOfFreeBytes;
+ if (GetDiskFreeSpaceEx(
+ m_wndCaptureBar.m_capdlg.m_file.Left(m_wndCaptureBar.m_capdlg.m_file.ReverseFind('\\') + 1),
+ &FreeBytesAvailable, &TotalNumberOfBytes, &TotalNumberOfFreeBytes)) {
+ if (FreeBytesAvailable.QuadPart < 1024i64 * 1024) {
+ msg.AppendFormat(IDS_MAINFRM_40, FreeBytesAvailable.QuadPart / 1024);
+ } else { //if (FreeBytesAvailable.QuadPart < 1024i64*1024*1024)
+ msg.AppendFormat(IDS_MAINFRM_41, FreeBytesAvailable.QuadPart / 1024 / 1024);
+ }
+ }
+
+ if (m_wndCaptureBar.m_capdlg.m_pMux) {
+ __int64 pos = 0;
+ CComQIPtr<IMediaSeeking> pMuxMS = m_wndCaptureBar.m_capdlg.m_pMux;
+ if (pMuxMS && SUCCEEDED(pMuxMS->GetCurrentPosition(&pos)) && pos > 0) {
+ double bytepersec = 10000000.0 * size / pos;
+ if (bytepersec > 0) {
+ m_rtDurationOverride = __int64(10000000.0 * (FreeBytesAvailable.QuadPart + size) / bytepersec);
+ }
+ }
+ }
+
+ if (m_wndCaptureBar.m_capdlg.m_pVidBuffer
+ || m_wndCaptureBar.m_capdlg.m_pAudBuffer) {
+ int nFreeVidBuffers = 0, nFreeAudBuffers = 0;
+ if (CComQIPtr<IBufferFilter> pVB = m_wndCaptureBar.m_capdlg.m_pVidBuffer) {
+ nFreeVidBuffers = pVB->GetFreeBuffers();
+ }
+ if (CComQIPtr<IBufferFilter> pAB = m_wndCaptureBar.m_capdlg.m_pAudBuffer) {
+ nFreeAudBuffers = pAB->GetFreeBuffers();
+ }
+
+ msg.AppendFormat(IDS_MAINFRM_42, nFreeVidBuffers, nFreeAudBuffers);
+ }
+ }
+ } else if (m_fBuffering) {
+ BeginEnumFilters(pGB, pEF, pBF) {
+ if (CComQIPtr<IAMNetworkStatus, &IID_IAMNetworkStatus> pAMNS = pBF) {
+ long BufferingProgress = 0;
+ if (SUCCEEDED(pAMNS->get_BufferingProgress(&BufferingProgress)) && BufferingProgress > 0) {
+ msg.Format(IDS_CONTROLS_BUFFERING, BufferingProgress);
+
+ __int64 start = 0, stop = 0;
+ m_wndSeekBar.GetRange(start, stop);
+ m_fLiveWM = (stop == start);
+ }
+ break;
+ }
+ }
+ EndEnumFilters;
+ } else if (pAMOP) {
+ __int64 t = 0, c = 0;
+ if (SUCCEEDED(pAMOP->QueryProgress(&t, &c)) && t > 0 && c < t) {
+ msg.Format(IDS_CONTROLS_BUFFERING, c * 100 / t);
+ }
+
+ if (m_fUpdateInfoBar) {
+ OpenSetupInfoBar();
+ }
+ }
+
+ OAFilterState fs = GetMediaState();
+ CString UI_Text =
+ !msg.IsEmpty() ? msg :
+ fs == State_Stopped ? ResStr(IDS_CONTROLS_STOPPED) :
+ (fs == State_Paused || m_fFrameSteppingActive) ? ResStr(IDS_CONTROLS_PAUSED) :
+ fs == State_Running ? ResStr(IDS_CONTROLS_PLAYING) :
+ _T("");
+ if ((!m_fAudioOnly) && (UI_Text == ResStr(IDS_CONTROLS_PAUSED) || UI_Text == ResStr(IDS_CONTROLS_PLAYING))) {
+ CString DXVA_Text = GetDXVADecoderDescription();
+ if (!(_T("Not using DXVA") == DXVA_Text) || (_T("Unknown") == DXVA_Text)) {
+ UI_Text += _T(" [DXVA]");
+ }
+ }
+ pCmdUI->SetText(UI_Text);
+ } else if (m_iMediaLoadState == MLS_CLOSING) {
+ pCmdUI->SetText(ResStr(IDS_CONTROLS_CLOSING));
+ if ((AfxGetAppSettings().fUseWin7TaskBar) && (m_pTaskbarList)) {
+ m_pTaskbarList->SetProgressState(m_hWnd, TBPF_INDETERMINATE);
+ }
+ } else {
+ pCmdUI->SetText(m_closingmsg);
+ }
}
void CMainFrame::OnFilePostOpenmedia()
{
- OpenSetupInfoBar();
-
- OpenSetupStatsBar();
-
- OpenSetupStatusBar();
-
- //OpenSetupToolBar();
-
- OpenSetupCaptureBar();
-
- REFERENCE_TIME rtDur = 0;
- pMS->GetDuration(&rtDur);
- m_wndPlaylistBar.SetCurTime(rtDur);
-
- if (GetPlaybackMode() == PM_CAPTURE) {
- ShowControlBar(&m_wndSubresyncBar, FALSE, TRUE);
- ShowControls(m_nCS & ~CS_SEEKBAR, true);
- //ShowControlBar(&m_wndPlaylistBar, FALSE, TRUE);
- //ShowControlBar(&m_wndCaptureBar, TRUE, TRUE);
- }
-
- m_nCurSubtitle = -1;
- m_lSubtitleShift = 0;
- if (m_pCAP) {
- m_pCAP->SetSubtitleDelay(0);
- }
-
- SetLoadState (MLS_LOADED);
- AppSettings& s = AfxGetAppSettings();
-
- // IMPORTANT: must not call any windowing msgs before
- // this point, it will deadlock when OpenMediaPrivate is
- // still running and the renderer window was created on
- // the same worker-thread
-
- {
- WINDOWPLACEMENT wp;
- wp.length = sizeof(wp);
- GetWindowPlacement(&wp);
-
- // Workaround to avoid MadVR freezing when switching channels in PM_CAPTURE mode:
- if (IsWindowVisible() && s.fRememberZoomLevel
- && !(m_fFullScreen || wp.showCmd == SW_SHOWMAXIMIZED || wp.showCmd == SW_SHOWMINIMIZED)
- && GetPlaybackMode() == PM_CAPTURE && s.iDSVideoRendererType == VIDRNDT_DS_MADVR) {
- ShowWindow(SW_MAXIMIZE);
- wp.showCmd = SW_SHOWMAXIMIZED;
- }
-
-
- // restore magnification
- if (IsWindowVisible() && s.fRememberZoomLevel
- && !(m_fFullScreen || wp.showCmd == SW_SHOWMAXIMIZED || wp.showCmd == SW_SHOWMINIMIZED)) {
- ZoomVideoWindow(false);
- }
- }
-
- // Waffs : PnS command line
- if (!s.strPnSPreset.IsEmpty()) {
- for (int i = 0; i < s.m_pnspresets.GetCount(); i++) {
- int j = 0;
- CString str = s.m_pnspresets[i];
- CString label = str.Tokenize(_T(","), j);
- if (s.strPnSPreset == label) {
- OnViewPanNScanPresets(i+ID_PANNSCAN_PRESETS_START);
- }
- }
- s.strPnSPreset.Empty();
- }
- SendNowPlayingToMSN();
- SendNowPlayingToApi();
+ OpenSetupInfoBar();
+
+ OpenSetupStatsBar();
+
+ OpenSetupStatusBar();
+
+ //OpenSetupToolBar();
+
+ OpenSetupCaptureBar();
+
+ REFERENCE_TIME rtDur = 0;
+ pMS->GetDuration(&rtDur);
+ m_wndPlaylistBar.SetCurTime(rtDur);
+
+ if (GetPlaybackMode() == PM_CAPTURE) {
+ ShowControlBar(&m_wndSubresyncBar, FALSE, TRUE);
+ ShowControls(m_nCS & ~CS_SEEKBAR, true);
+ //ShowControlBar(&m_wndPlaylistBar, FALSE, TRUE);
+ //ShowControlBar(&m_wndCaptureBar, TRUE, TRUE);
+ }
+
+ m_nCurSubtitle = -1;
+ m_lSubtitleShift = 0;
+ if (m_pCAP) {
+ m_pCAP->SetSubtitleDelay(0);
+ }
+
+ SetLoadState(MLS_LOADED);
+ AppSettings& s = AfxGetAppSettings();
+
+ // IMPORTANT: must not call any windowing msgs before
+ // this point, it will deadlock when OpenMediaPrivate is
+ // still running and the renderer window was created on
+ // the same worker-thread
+
+ {
+ WINDOWPLACEMENT wp;
+ wp.length = sizeof(wp);
+ GetWindowPlacement(&wp);
+
+ // Workaround to avoid MadVR freezing when switching channels in PM_CAPTURE mode:
+ if (IsWindowVisible() && s.fRememberZoomLevel
+ && !(m_fFullScreen || wp.showCmd == SW_SHOWMAXIMIZED || wp.showCmd == SW_SHOWMINIMIZED)
+ && GetPlaybackMode() == PM_CAPTURE && s.iDSVideoRendererType == VIDRNDT_DS_MADVR) {
+ ShowWindow(SW_MAXIMIZE);
+ wp.showCmd = SW_SHOWMAXIMIZED;
+ }
+
+
+ // restore magnification
+ if (IsWindowVisible() && s.fRememberZoomLevel
+ && !(m_fFullScreen || wp.showCmd == SW_SHOWMAXIMIZED || wp.showCmd == SW_SHOWMINIMIZED)) {
+ ZoomVideoWindow(false);
+ }
+ }
+
+ // Waffs : PnS command line
+ if (!s.strPnSPreset.IsEmpty()) {
+ for (int i = 0; i < s.m_pnspresets.GetCount(); i++) {
+ int j = 0;
+ CString str = s.m_pnspresets[i];
+ CString label = str.Tokenize(_T(","), j);
+ if (s.strPnSPreset == label) {
+ OnViewPanNScanPresets(i + ID_PANNSCAN_PRESETS_START);
+ }
+ }
+ s.strPnSPreset.Empty();
+ }
+ SendNowPlayingToMSN();
+ SendNowPlayingToApi();
}
void CMainFrame::OnUpdateFilePostOpenmedia(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADING);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADING);
}
void CMainFrame::OnFilePostClosemedia()
{
- if (IsD3DFullScreenMode()) {
- KillTimer(TIMER_FULLSCREENMOUSEHIDER);
- KillTimer(TIMER_FULLSCREENCONTROLBARHIDER);
- m_fHideCursor = false;
- }
- m_wndView.SetVideoRect();
- m_wndSeekBar.Enable(false);
- m_wndSeekBar.SetPos(0);
- m_wndInfoBar.RemoveAllLines();
- m_wndStatsBar.RemoveAllLines();
- m_wndStatusBar.Clear();
- m_wndStatusBar.ShowTimer(false);
-
- if (AfxGetAppSettings().fEnableEDLEditor) {
- m_wndEditListEditor.CloseFile();
- }
-
- if (IsWindow(m_wndSubresyncBar.m_hWnd)) {
- ShowControlBar(&m_wndSubresyncBar, FALSE, TRUE);
- SetSubtitle(NULL);
- }
-
- if (IsWindow(m_wndCaptureBar.m_hWnd)) {
- ShowControlBar(&m_wndCaptureBar, FALSE, TRUE);
- m_wndCaptureBar.m_capdlg.SetupVideoControls(_T(""), NULL, NULL, NULL);
- m_wndCaptureBar.m_capdlg.SetupAudioControls(_T(""), NULL, CInterfaceArray<IAMAudioInputMixer>());
- }
-
- if (GetPlaybackMode() == PM_CAPTURE) {
- // Restore the controls
- ShowControls(AfxGetAppSettings().nCS, true);
- }
-
- RecalcLayout();
-
- SetWindowText(m_strTitle);
- //m_Lcd.SetMediaTitle(LPCTSTR(m_strTitle));
-
- SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
-
- // this will prevent any further UI updates on the dynamically added menu items
- SetupFiltersSubMenu();
- SetupAudioSwitcherSubMenu();
- SetupSubtitlesSubMenu();
- SetupNavAudioSubMenu();
- SetupNavSubtitleSubMenu();
- SetupNavAngleSubMenu();
- SetupNavChaptersSubMenu();
- SetupFavoritesSubMenu();
- SetupRecentFilesSubMenu();
-
- SendNowPlayingToMSN();
+ if (IsD3DFullScreenMode()) {
+ KillTimer(TIMER_FULLSCREENMOUSEHIDER);
+ KillTimer(TIMER_FULLSCREENCONTROLBARHIDER);
+ m_fHideCursor = false;
+ }
+ m_wndView.SetVideoRect();
+ m_wndSeekBar.Enable(false);
+ m_wndSeekBar.SetPos(0);
+ m_wndInfoBar.RemoveAllLines();
+ m_wndStatsBar.RemoveAllLines();
+ m_wndStatusBar.Clear();
+ m_wndStatusBar.ShowTimer(false);
+
+ if (AfxGetAppSettings().fEnableEDLEditor) {
+ m_wndEditListEditor.CloseFile();
+ }
+
+ if (IsWindow(m_wndSubresyncBar.m_hWnd)) {
+ ShowControlBar(&m_wndSubresyncBar, FALSE, TRUE);
+ SetSubtitle(NULL);
+ }
+
+ if (IsWindow(m_wndCaptureBar.m_hWnd)) {
+ ShowControlBar(&m_wndCaptureBar, FALSE, TRUE);
+ m_wndCaptureBar.m_capdlg.SetupVideoControls(_T(""), NULL, NULL, NULL);
+ m_wndCaptureBar.m_capdlg.SetupAudioControls(_T(""), NULL, CInterfaceArray<IAMAudioInputMixer>());
+ }
+
+ if (GetPlaybackMode() == PM_CAPTURE) {
+ // Restore the controls
+ ShowControls(AfxGetAppSettings().nCS, true);
+ }
+
+ RecalcLayout();
+
+ SetWindowText(m_strTitle);
+ //m_Lcd.SetMediaTitle(LPCTSTR(m_strTitle));
+
+ SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
+
+ // this will prevent any further UI updates on the dynamically added menu items
+ SetupFiltersSubMenu();
+ SetupAudioSwitcherSubMenu();
+ SetupSubtitlesSubMenu();
+ SetupNavAudioSubMenu();
+ SetupNavSubtitleSubMenu();
+ SetupNavAngleSubMenu();
+ SetupNavChaptersSubMenu();
+ SetupFavoritesSubMenu();
+ SetupRecentFilesSubMenu();
+
+ SendNowPlayingToMSN();
}
void CMainFrame::OnUpdateFilePostClosemedia(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!!m_hWnd && m_iMediaLoadState == MLS_CLOSING);
+ pCmdUI->Enable(!!m_hWnd && m_iMediaLoadState == MLS_CLOSING);
}
void CMainFrame::OnBossKey()
{
- // Disable animation
- ANIMATIONINFO AnimationInfo;
- AnimationInfo.cbSize = sizeof(ANIMATIONINFO);
- ::SystemParametersInfo(SPI_GETANIMATION, sizeof(ANIMATIONINFO), &AnimationInfo, 0);
- int m_WindowAnimationType = AnimationInfo.iMinAnimate;
- AnimationInfo.iMinAnimate = 0;
- ::SystemParametersInfo(SPI_SETANIMATION, sizeof(ANIMATIONINFO), &AnimationInfo, 0);
-
- SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
- if (m_fFullScreen) {
- SendMessage(WM_COMMAND, ID_VIEW_FULLSCREEN);
- }
- SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, -1);
+ // Disable animation
+ ANIMATIONINFO AnimationInfo;
+ AnimationInfo.cbSize = sizeof(ANIMATIONINFO);
+ ::SystemParametersInfo(SPI_GETANIMATION, sizeof(ANIMATIONINFO), &AnimationInfo, 0);
+ int m_WindowAnimationType = AnimationInfo.iMinAnimate;
+ AnimationInfo.iMinAnimate = 0;
+ ::SystemParametersInfo(SPI_SETANIMATION, sizeof(ANIMATIONINFO), &AnimationInfo, 0);
+
+ SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ if (m_fFullScreen) {
+ SendMessage(WM_COMMAND, ID_VIEW_FULLSCREEN);
+ }
+ SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, -1);
- // Enable animation
- AnimationInfo.iMinAnimate = m_WindowAnimationType;
- ::SystemParametersInfo(SPI_SETANIMATION, sizeof(ANIMATIONINFO), &AnimationInfo, 0);
+ // Enable animation
+ AnimationInfo.iMinAnimate = m_WindowAnimationType;
+ ::SystemParametersInfo(SPI_SETANIMATION, sizeof(ANIMATIONINFO), &AnimationInfo, 0);
}
void CMainFrame::OnStreamAudio(UINT nID)
{
- nID -= ID_STREAM_AUDIO_NEXT;
-
- if (m_iMediaLoadState != MLS_LOADED) {
- return;
- }
-
- CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
- if (!pSS) {
- pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB); // morgan's switcher
- }
-
- DWORD cStreams = 0;
- if (pSS && SUCCEEDED(pSS->Count(&cStreams)) && cStreams > 1) {
- nID = m_iAudioStreams.GetAt(m_iAudioStreams.FindIndex(nID)); // remember that the audio streams are reordered according to user preference, so have to figure out which stream from the original order was clicked
- for (int i = 0; i < (int)cStreams; i++) {
- AM_MEDIA_TYPE* pmt = NULL;
- DWORD dwFlags = 0;
- LCID lcid = 0;
- DWORD dwGroup = 0;
- WCHAR* pszName = NULL;
- if (FAILED(pSS->Info(i, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))) {
- return;
- }
-
- if (pmt) {
- DeleteMediaType(pmt);
- }
- if (pszName) {
- CoTaskMemFree(pszName);
- }
-
- if (dwFlags&(AMSTREAMSELECTINFO_ENABLED|AMSTREAMSELECTINFO_EXCLUSIVE)) {
- long stream_index = (i+(nID==0?1:cStreams-1))%cStreams;
- pSS->Enable(stream_index, AMSTREAMSELECTENABLE_ENABLE);
- if (SUCCEEDED(pSS->Info(stream_index, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))) {
- CString strMessage;
- strMessage.Format(IDS_AUDIO_STREAM, pszName);
- m_OSD.DisplayMessage(OSD_TOPLEFT, strMessage);
- if (pmt) {
- DeleteMediaType(pmt);
- }
- if (pszName) {
- CoTaskMemFree(pszName);
- }
- }
- break;
- }
- }
- } else if (GetPlaybackMode() == PM_FILE) {
- SendMessage(WM_COMMAND, ID_OGM_AUDIO_NEXT+nID);
- } else if (GetPlaybackMode() == PM_DVD) {
- SendMessage(WM_COMMAND, ID_DVD_AUDIO_NEXT+nID);
- }
+ nID -= ID_STREAM_AUDIO_NEXT;
+
+ if (m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
+
+ CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
+ if (!pSS) {
+ pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB); // morgan's switcher
+ }
+
+ DWORD cStreams = 0;
+ if (pSS && SUCCEEDED(pSS->Count(&cStreams)) && cStreams > 1) {
+ nID = m_iAudioStreams.GetAt(m_iAudioStreams.FindIndex(nID)); // remember that the audio streams are reordered according to user preference, so have to figure out which stream from the original order was clicked
+ for (int i = 0; i < (int)cStreams; i++) {
+ AM_MEDIA_TYPE* pmt = NULL;
+ DWORD dwFlags = 0;
+ LCID lcid = 0;
+ DWORD dwGroup = 0;
+ WCHAR* pszName = NULL;
+ if (FAILED(pSS->Info(i, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))) {
+ return;
+ }
+
+ if (pmt) {
+ DeleteMediaType(pmt);
+ }
+ if (pszName) {
+ CoTaskMemFree(pszName);
+ }
+
+ if (dwFlags & (AMSTREAMSELECTINFO_ENABLED | AMSTREAMSELECTINFO_EXCLUSIVE)) {
+ long stream_index = (i + (nID == 0 ? 1 : cStreams - 1)) % cStreams;
+ pSS->Enable(stream_index, AMSTREAMSELECTENABLE_ENABLE);
+ if (SUCCEEDED(pSS->Info(stream_index, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))) {
+ CString strMessage;
+ strMessage.Format(IDS_AUDIO_STREAM, pszName);
+ m_OSD.DisplayMessage(OSD_TOPLEFT, strMessage);
+ if (pmt) {
+ DeleteMediaType(pmt);
+ }
+ if (pszName) {
+ CoTaskMemFree(pszName);
+ }
+ }
+ break;
+ }
+ }
+ } else if (GetPlaybackMode() == PM_FILE) {
+ SendMessage(WM_COMMAND, ID_OGM_AUDIO_NEXT + nID);
+ } else if (GetPlaybackMode() == PM_DVD) {
+ SendMessage(WM_COMMAND, ID_DVD_AUDIO_NEXT + nID);
+ }
}
void CMainFrame::OnStreamSub(UINT nID)
{
- nID -= ID_STREAM_SUB_NEXT;
- if (m_iMediaLoadState != MLS_LOADED) {
- return;
- }
-
- int cnt = 0;
- POSITION pos = m_pSubStreams.GetHeadPosition();
- while (pos) {
- cnt += m_pSubStreams.GetNext(pos)->GetStreamCount();
- }
-
- if (cnt > 1) {
- int i = ((m_iSubtitleSel&0x7fffffff)+(nID==0?1:cnt-1))%cnt;
- m_iSubtitleSel = i | (m_iSubtitleSel&0x80000000);
- UpdateSubtitle(true);
- SetFocus();
- } else if (GetPlaybackMode() == PM_FILE) {
- SendMessage(WM_COMMAND, ID_OGM_SUB_NEXT+nID);
- } else if (GetPlaybackMode() == PM_DVD) {
- SendMessage(WM_COMMAND, ID_DVD_SUB_NEXT+nID);
- }
+ nID -= ID_STREAM_SUB_NEXT;
+ if (m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
+
+ int cnt = 0;
+ POSITION pos = m_pSubStreams.GetHeadPosition();
+ while (pos) {
+ cnt += m_pSubStreams.GetNext(pos)->GetStreamCount();
+ }
+
+ if (cnt > 1) {
+ int i = ((m_iSubtitleSel & 0x7fffffff) + (nID == 0 ? 1 : cnt - 1)) % cnt;
+ m_iSubtitleSel = i | (m_iSubtitleSel & 0x80000000);
+ UpdateSubtitle(true);
+ SetFocus();
+ } else if (GetPlaybackMode() == PM_FILE) {
+ SendMessage(WM_COMMAND, ID_OGM_SUB_NEXT + nID);
+ } else if (GetPlaybackMode() == PM_DVD) {
+ SendMessage(WM_COMMAND, ID_DVD_SUB_NEXT + nID);
+ }
}
void CMainFrame::OnStreamSubOnOff()
{
- if (m_iMediaLoadState != MLS_LOADED) {
- return;
- }
-
- int cnt = 0;
- POSITION pos = m_pSubStreams.GetHeadPosition();
- while (pos) {
- cnt += m_pSubStreams.GetNext(pos)->GetStreamCount();
- }
-
- if (cnt > 0) {
- if (m_iSubtitleSel == -1) {
- m_iSubtitleSel = 0;
- } else {
- m_iSubtitleSel ^= 0x80000000;
- }
- UpdateSubtitle(true);
- SetFocus();
- AfxGetAppSettings().fEnableSubtitles = !(m_iSubtitleSel & 0x80000000);
- } else if (GetPlaybackMode() == PM_DVD) {
- SendMessage(WM_COMMAND, ID_DVD_SUB_ONOFF);
- }
+ if (m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
+
+ int cnt = 0;
+ POSITION pos = m_pSubStreams.GetHeadPosition();
+ while (pos) {
+ cnt += m_pSubStreams.GetNext(pos)->GetStreamCount();
+ }
+
+ if (cnt > 0) {
+ if (m_iSubtitleSel == -1) {
+ m_iSubtitleSel = 0;
+ } else {
+ m_iSubtitleSel ^= 0x80000000;
+ }
+ UpdateSubtitle(true);
+ SetFocus();
+ AfxGetAppSettings().fEnableSubtitles = !(m_iSubtitleSel & 0x80000000);
+ } else if (GetPlaybackMode() == PM_DVD) {
+ SendMessage(WM_COMMAND, ID_DVD_SUB_ONOFF);
+ }
}
void CMainFrame::OnOgmAudio(UINT nID)
{
- nID -= ID_OGM_AUDIO_NEXT;
-
- if (m_iMediaLoadState != MLS_LOADED) {
- return;
- }
-
- CComQIPtr<IAMStreamSelect> pSS = FindSourceSelectableFilter();
- if (!pSS) {
- return;
- }
-
- CAtlArray<int> snds;
- INT_PTR iSel = -1;
-
- DWORD cStreams = 0;
- if (SUCCEEDED(pSS->Count(&cStreams)) && cStreams > 1) {
- for (int i = 0; i < (int)cStreams; i++) {
- AM_MEDIA_TYPE* pmt = NULL;
- DWORD dwFlags = 0;
- LCID lcid = 0;
- DWORD dwGroup = 0;
- WCHAR* pszName = NULL;
- if (FAILED(pSS->Info(i, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))) {
- return;
- }
-
- if (dwGroup == 1) {
- if (dwFlags&(AMSTREAMSELECTINFO_ENABLED|AMSTREAMSELECTINFO_EXCLUSIVE)) {
- iSel = snds.GetCount();
- }
- snds.Add(i);
- }
-
- if (pmt) {
- DeleteMediaType(pmt);
- }
- if (pszName) {
- CoTaskMemFree(pszName);
- }
-
- }
-
- size_t cnt = snds.GetCount();
- if (cnt > 1 && iSel >= 0) {
- int nNewStream = snds[(iSel+(nID==0?1:cnt-1))%cnt];
- pSS->Enable(nNewStream, AMSTREAMSELECTENABLE_ENABLE);
-
- AM_MEDIA_TYPE* pmt = NULL;
- DWORD dwFlags = 0;
- LCID lcid = 0;
- DWORD dwGroup = 0;
- WCHAR* pszName = NULL;
-
- if (SUCCEEDED(pSS->Info(nNewStream, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))) {
- CString strMessage;
- CString audio_stream = pszName;
- int k = audio_stream.Find(_T("Audio - "));
- if (k>=0) {
- audio_stream = audio_stream.Right(audio_stream.GetLength() - k - 8);
- }
- strMessage.Format(IDS_AUDIO_STREAM, audio_stream);
- m_OSD.DisplayMessage(OSD_TOPLEFT, strMessage);
-
- if (pmt) {
- DeleteMediaType(pmt);
- }
- if (pszName) {
- CoTaskMemFree(pszName);
- }
- }
- }
- }
+ nID -= ID_OGM_AUDIO_NEXT;
+
+ if (m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
+
+ CComQIPtr<IAMStreamSelect> pSS = FindSourceSelectableFilter();
+ if (!pSS) {
+ return;
+ }
+
+ CAtlArray<int> snds;
+ INT_PTR iSel = -1;
+
+ DWORD cStreams = 0;
+ if (SUCCEEDED(pSS->Count(&cStreams)) && cStreams > 1) {
+ for (int i = 0; i < (int)cStreams; i++) {
+ AM_MEDIA_TYPE* pmt = NULL;
+ DWORD dwFlags = 0;
+ LCID lcid = 0;
+ DWORD dwGroup = 0;
+ WCHAR* pszName = NULL;
+ if (FAILED(pSS->Info(i, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))) {
+ return;
+ }
+
+ if (dwGroup == 1) {
+ if (dwFlags & (AMSTREAMSELECTINFO_ENABLED | AMSTREAMSELECTINFO_EXCLUSIVE)) {
+ iSel = snds.GetCount();
+ }
+ snds.Add(i);
+ }
+
+ if (pmt) {
+ DeleteMediaType(pmt);
+ }
+ if (pszName) {
+ CoTaskMemFree(pszName);
+ }
+
+ }
+
+ size_t cnt = snds.GetCount();
+ if (cnt > 1 && iSel >= 0) {
+ int nNewStream = snds[(iSel + (nID == 0 ? 1 : cnt - 1)) % cnt];
+ pSS->Enable(nNewStream, AMSTREAMSELECTENABLE_ENABLE);
+
+ AM_MEDIA_TYPE* pmt = NULL;
+ DWORD dwFlags = 0;
+ LCID lcid = 0;
+ DWORD dwGroup = 0;
+ WCHAR* pszName = NULL;
+
+ if (SUCCEEDED(pSS->Info(nNewStream, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))) {
+ CString strMessage;
+ CString audio_stream = pszName;
+ int k = audio_stream.Find(_T("Audio - "));
+ if (k >= 0) {
+ audio_stream = audio_stream.Right(audio_stream.GetLength() - k - 8);
+ }
+ strMessage.Format(IDS_AUDIO_STREAM, audio_stream);
+ m_OSD.DisplayMessage(OSD_TOPLEFT, strMessage);
+
+ if (pmt) {
+ DeleteMediaType(pmt);
+ }
+ if (pszName) {
+ CoTaskMemFree(pszName);
+ }
+ }
+ }
+ }
}
void CMainFrame::OnOgmSub(UINT nID)
{
- nID -= ID_OGM_SUB_NEXT;
-
- if (m_iMediaLoadState != MLS_LOADED) {
- return;
- }
-
- CComQIPtr<IAMStreamSelect> pSS = FindSourceSelectableFilter();
- if (!pSS) {
- return;
- }
-
- CArray<int> subs;
- INT_PTR iSel = -1;
-
- DWORD cStreams = 0;
- if (SUCCEEDED(pSS->Count(&cStreams)) && cStreams > 1) {
- for (int i = 0; i < (int)cStreams; i++) {
- AM_MEDIA_TYPE* pmt = NULL;
- DWORD dwFlags = 0;
- LCID lcid = 0;
- DWORD dwGroup = 0;
- WCHAR* pszName = NULL;
- if (FAILED(pSS->Info(i, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))) {
- return;
- }
-
- if (dwGroup == 2) {
- if (dwFlags&(AMSTREAMSELECTINFO_ENABLED|AMSTREAMSELECTINFO_EXCLUSIVE)) {
- iSel = subs.GetCount();
- }
- subs.Add(i);
- }
-
- if (pmt) {
- DeleteMediaType(pmt);
- }
- if (pszName) {
- CoTaskMemFree(pszName);
- }
-
- }
-
- INT_PTR cnt = subs.GetCount();
- if (cnt > 1 && iSel >= 0) {
- int nNewStream = subs[(iSel+(nID==0?1:cnt-1))%cnt];
- pSS->Enable(nNewStream, AMSTREAMSELECTENABLE_ENABLE);
-
- AM_MEDIA_TYPE* pmt = NULL;
- DWORD dwFlags = 0;
- LCID lcid = 0;
- DWORD dwGroup = 0;
- WCHAR* pszName = NULL;
- if (SUCCEEDED(pSS->Info(nNewStream, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))) {
- CString lang;
- CString strMessage;
- if (lcid == 0) {
- lang = pszName;
- } else {
- int len = GetLocaleInfo(lcid, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
- lang.ReleaseBufferSetLength(max(len-1, 0));
- }
-
- strMessage.Format(IDS_SUBTITLE_STREAM, lang);
- m_OSD.DisplayMessage(OSD_TOPLEFT, strMessage);
- if (pmt) {
- DeleteMediaType(pmt);
- }
- if (pszName) {
- CoTaskMemFree(pszName);
- }
- }
- }
- }
+ nID -= ID_OGM_SUB_NEXT;
+
+ if (m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
+
+ CComQIPtr<IAMStreamSelect> pSS = FindSourceSelectableFilter();
+ if (!pSS) {
+ return;
+ }
+
+ CArray<int> subs;
+ INT_PTR iSel = -1;
+
+ DWORD cStreams = 0;
+ if (SUCCEEDED(pSS->Count(&cStreams)) && cStreams > 1) {
+ for (int i = 0; i < (int)cStreams; i++) {
+ AM_MEDIA_TYPE* pmt = NULL;
+ DWORD dwFlags = 0;
+ LCID lcid = 0;
+ DWORD dwGroup = 0;
+ WCHAR* pszName = NULL;
+ if (FAILED(pSS->Info(i, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))) {
+ return;
+ }
+
+ if (dwGroup == 2) {
+ if (dwFlags & (AMSTREAMSELECTINFO_ENABLED | AMSTREAMSELECTINFO_EXCLUSIVE)) {
+ iSel = subs.GetCount();
+ }
+ subs.Add(i);
+ }
+
+ if (pmt) {
+ DeleteMediaType(pmt);
+ }
+ if (pszName) {
+ CoTaskMemFree(pszName);
+ }
+
+ }
+
+ INT_PTR cnt = subs.GetCount();
+ if (cnt > 1 && iSel >= 0) {
+ int nNewStream = subs[(iSel + (nID == 0 ? 1 : cnt - 1)) % cnt];
+ pSS->Enable(nNewStream, AMSTREAMSELECTENABLE_ENABLE);
+
+ AM_MEDIA_TYPE* pmt = NULL;
+ DWORD dwFlags = 0;
+ LCID lcid = 0;
+ DWORD dwGroup = 0;
+ WCHAR* pszName = NULL;
+ if (SUCCEEDED(pSS->Info(nNewStream, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))) {
+ CString lang;
+ CString strMessage;
+ if (lcid == 0) {
+ lang = pszName;
+ } else {
+ int len = GetLocaleInfo(lcid, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
+ lang.ReleaseBufferSetLength(max(len - 1, 0));
+ }
+
+ strMessage.Format(IDS_SUBTITLE_STREAM, lang);
+ m_OSD.DisplayMessage(OSD_TOPLEFT, strMessage);
+ if (pmt) {
+ DeleteMediaType(pmt);
+ }
+ if (pszName) {
+ CoTaskMemFree(pszName);
+ }
+ }
+ }
+ }
}
void CMainFrame::OnDvdAngle(UINT nID)
{
- if (m_iMediaLoadState != MLS_LOADED) {
- return;
- }
-
- if (pDVDI && pDVDC) {
- ULONG ulAnglesAvailable, ulCurrentAngle;
- if (SUCCEEDED(pDVDI->GetCurrentAngle(&ulAnglesAvailable, &ulCurrentAngle)) && ulAnglesAvailable > 1) {
- ulCurrentAngle += (nID == ID_DVD_ANGLE_NEXT) ? 1 : -1;
- if (ulCurrentAngle > ulAnglesAvailable) {
- ulCurrentAngle = 1;
- } else if (ulCurrentAngle < 1) {
- ulCurrentAngle = ulAnglesAvailable;
- }
- pDVDC->SelectAngle(ulCurrentAngle, DVD_CMD_FLAG_Block, NULL);
+ if (m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
- CString osdMessage;
- osdMessage.Format(IDS_AG_ANGLE, ulCurrentAngle);
- m_OSD.DisplayMessage(OSD_TOPLEFT, osdMessage);
- }
- }
+ if (pDVDI && pDVDC) {
+ ULONG ulAnglesAvailable, ulCurrentAngle;
+ if (SUCCEEDED(pDVDI->GetCurrentAngle(&ulAnglesAvailable, &ulCurrentAngle)) && ulAnglesAvailable > 1) {
+ ulCurrentAngle += (nID == ID_DVD_ANGLE_NEXT) ? 1 : -1;
+ if (ulCurrentAngle > ulAnglesAvailable) {
+ ulCurrentAngle = 1;
+ } else if (ulCurrentAngle < 1) {
+ ulCurrentAngle = ulAnglesAvailable;
+ }
+ pDVDC->SelectAngle(ulCurrentAngle, DVD_CMD_FLAG_Block, NULL);
+
+ CString osdMessage;
+ osdMessage.Format(IDS_AG_ANGLE, ulCurrentAngle);
+ m_OSD.DisplayMessage(OSD_TOPLEFT, osdMessage);
+ }
+ }
}
void CMainFrame::OnDvdAudio(UINT nID)
{
- HRESULT hr;
- nID -= ID_DVD_AUDIO_NEXT;
-
- if (m_iMediaLoadState != MLS_LOADED) {
- return;
- }
-
- if (pDVDI && pDVDC) {
- ULONG nStreamsAvailable, nCurrentStream;
- if (SUCCEEDED(pDVDI->GetCurrentAudio(&nStreamsAvailable, &nCurrentStream)) && nStreamsAvailable > 1) {
- DVD_AudioAttributes AATR;
- UINT nNextStream = (nCurrentStream+(nID==0?1:nStreamsAvailable-1))%nStreamsAvailable;
-
- hr = pDVDC->SelectAudioStream(nNextStream, DVD_CMD_FLAG_Block, NULL);
- if (SUCCEEDED(pDVDI->GetAudioAttributes(nNextStream, &AATR))) {
- CString lang;
- CString strMessage;
- if (AATR.Language) {
- int len = GetLocaleInfo(AATR.Language, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
- lang.ReleaseBufferSetLength(max(len-1, 0));
- } else {
- lang.Format(IDS_AG_UNKNOWN, nNextStream+1);
- }
-
- CString format = GetDVDAudioFormatName(AATR);
- CString str("");
-
- if (!format.IsEmpty()) {
- str.Format(IDS_MAINFRM_11,
- lang,
- format,
- AATR.dwFrequency,
- AATR.bQuantization,
- AATR.bNumberOfChannels,
- (AATR.bNumberOfChannels > 1 ? ResStr(IDS_MAINFRM_13) : ResStr(IDS_MAINFRM_12)));
- str += FAILED(hr) ? _T(" [") + ResStr(IDS_AG_ERROR) + _T("] ") : _T("");
- strMessage.Format(IDS_AUDIO_STREAM, str);
- m_OSD.DisplayMessage(OSD_TOPLEFT, strMessage);
- }
- }
- }
- }
+ HRESULT hr;
+ nID -= ID_DVD_AUDIO_NEXT;
+
+ if (m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
+
+ if (pDVDI && pDVDC) {
+ ULONG nStreamsAvailable, nCurrentStream;
+ if (SUCCEEDED(pDVDI->GetCurrentAudio(&nStreamsAvailable, &nCurrentStream)) && nStreamsAvailable > 1) {
+ DVD_AudioAttributes AATR;
+ UINT nNextStream = (nCurrentStream + (nID == 0 ? 1 : nStreamsAvailable - 1)) % nStreamsAvailable;
+
+ hr = pDVDC->SelectAudioStream(nNextStream, DVD_CMD_FLAG_Block, NULL);
+ if (SUCCEEDED(pDVDI->GetAudioAttributes(nNextStream, &AATR))) {
+ CString lang;
+ CString strMessage;
+ if (AATR.Language) {
+ int len = GetLocaleInfo(AATR.Language, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
+ lang.ReleaseBufferSetLength(max(len - 1, 0));
+ } else {
+ lang.Format(IDS_AG_UNKNOWN, nNextStream + 1);
+ }
+
+ CString format = GetDVDAudioFormatName(AATR);
+ CString str("");
+
+ if (!format.IsEmpty()) {
+ str.Format(IDS_MAINFRM_11,
+ lang,
+ format,
+ AATR.dwFrequency,
+ AATR.bQuantization,
+ AATR.bNumberOfChannels,
+ (AATR.bNumberOfChannels > 1 ? ResStr(IDS_MAINFRM_13) : ResStr(IDS_MAINFRM_12)));
+ str += FAILED(hr) ? _T(" [") + ResStr(IDS_AG_ERROR) + _T("] ") : _T("");
+ strMessage.Format(IDS_AUDIO_STREAM, str);
+ m_OSD.DisplayMessage(OSD_TOPLEFT, strMessage);
+ }
+ }
+ }
+ }
}
void CMainFrame::OnDvdSub(UINT nID)
{
- HRESULT hr;
- nID -= ID_DVD_SUB_NEXT;
-
- if (m_iMediaLoadState != MLS_LOADED) {
- return;
- }
-
- if (pDVDI && pDVDC) {
- ULONG ulStreamsAvailable, ulCurrentStream;
- BOOL bIsDisabled;
- if (SUCCEEDED(pDVDI->GetCurrentSubpicture(&ulStreamsAvailable, &ulCurrentStream, &bIsDisabled))
- && ulStreamsAvailable > 1) {
- //UINT nNextStream = (ulCurrentStream+(nID==0?1:ulStreamsAvailable-1))%ulStreamsAvailable;
- int nNextStream;
-
- if (!bIsDisabled) {
- nNextStream = ulCurrentStream+ (nID==0?1:-1);
- } else {
- nNextStream = (nID==0?0:ulStreamsAvailable-1);
- }
-
- if (!bIsDisabled && ((nNextStream < 0) || ((ULONG)nNextStream >= ulStreamsAvailable))) {
- pDVDC->SetSubpictureState(FALSE, DVD_CMD_FLAG_Block, NULL);
- m_OSD.DisplayMessage (OSD_TOPLEFT, ResStr(IDS_SUBTITLE_STREAM_OFF));
- } else {
- hr = pDVDC->SelectSubpictureStream(nNextStream, DVD_CMD_FLAG_Block, NULL);
-
- DVD_SubpictureAttributes SATR;
- pDVDC->SetSubpictureState(TRUE, DVD_CMD_FLAG_Block, NULL);
- if (SUCCEEDED(pDVDI->GetSubpictureAttributes(nNextStream, &SATR))) {
- CString lang;
- CString strMessage;
- int len = GetLocaleInfo(SATR.Language, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
- lang.ReleaseBufferSetLength(max(len-1, 0));
- lang += FAILED(hr) ? _T(" [") + ResStr(IDS_AG_ERROR) + _T("] ") : _T("");
- strMessage.Format(IDS_SUBTITLE_STREAM, lang);
- m_OSD.DisplayMessage(OSD_TOPLEFT, strMessage);
- }
- }
- }
- }
+ HRESULT hr;
+ nID -= ID_DVD_SUB_NEXT;
+
+ if (m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
+
+ if (pDVDI && pDVDC) {
+ ULONG ulStreamsAvailable, ulCurrentStream;
+ BOOL bIsDisabled;
+ if (SUCCEEDED(pDVDI->GetCurrentSubpicture(&ulStreamsAvailable, &ulCurrentStream, &bIsDisabled))
+ && ulStreamsAvailable > 1) {
+ //UINT nNextStream = (ulCurrentStream+(nID==0?1:ulStreamsAvailable-1))%ulStreamsAvailable;
+ int nNextStream;
+
+ if (!bIsDisabled) {
+ nNextStream = ulCurrentStream + (nID == 0 ? 1 : -1);
+ } else {
+ nNextStream = (nID == 0 ? 0 : ulStreamsAvailable - 1);
+ }
+
+ if (!bIsDisabled && ((nNextStream < 0) || ((ULONG)nNextStream >= ulStreamsAvailable))) {
+ pDVDC->SetSubpictureState(FALSE, DVD_CMD_FLAG_Block, NULL);
+ m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_SUBTITLE_STREAM_OFF));
+ } else {
+ hr = pDVDC->SelectSubpictureStream(nNextStream, DVD_CMD_FLAG_Block, NULL);
+
+ DVD_SubpictureAttributes SATR;
+ pDVDC->SetSubpictureState(TRUE, DVD_CMD_FLAG_Block, NULL);
+ if (SUCCEEDED(pDVDI->GetSubpictureAttributes(nNextStream, &SATR))) {
+ CString lang;
+ CString strMessage;
+ int len = GetLocaleInfo(SATR.Language, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
+ lang.ReleaseBufferSetLength(max(len - 1, 0));
+ lang += FAILED(hr) ? _T(" [") + ResStr(IDS_AG_ERROR) + _T("] ") : _T("");
+ strMessage.Format(IDS_SUBTITLE_STREAM, lang);
+ m_OSD.DisplayMessage(OSD_TOPLEFT, strMessage);
+ }
+ }
+ }
+ }
}
void CMainFrame::OnDvdSubOnOff()
{
- if (m_iMediaLoadState != MLS_LOADED) {
- return;
- }
+ if (m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
- if (pDVDI && pDVDC) {
- ULONG ulStreamsAvailable, ulCurrentStream;
- BOOL bIsDisabled;
- if (SUCCEEDED(pDVDI->GetCurrentSubpicture(&ulStreamsAvailable, &ulCurrentStream, &bIsDisabled))) {
- pDVDC->SetSubpictureState(bIsDisabled, DVD_CMD_FLAG_Block, NULL);
- }
- }
+ if (pDVDI && pDVDC) {
+ ULONG ulStreamsAvailable, ulCurrentStream;
+ BOOL bIsDisabled;
+ if (SUCCEEDED(pDVDI->GetCurrentSubpicture(&ulStreamsAvailable, &ulCurrentStream, &bIsDisabled))) {
+ pDVDC->SetSubpictureState(bIsDisabled, DVD_CMD_FLAG_Block, NULL);
+ }
+ }
}
//
@@ -4051,2453 +4051,2453 @@ void CMainFrame::OnDvdSubOnOff()
void CMainFrame::OnFileOpenQuick()
{
- if (m_iMediaLoadState == MLS_LOADING || !IsWindow(m_wndPlaylistBar)) {
- return;
- }
+ if (m_iMediaLoadState == MLS_LOADING || !IsWindow(m_wndPlaylistBar)) {
+ return;
+ }
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- CString filter;
- CAtlArray<CString> mask;
- s.m_Formats.GetFilter(filter, mask);
+ CString filter;
+ CAtlArray<CString> mask;
+ s.m_Formats.GetFilter(filter, mask);
- DWORD dwFlags = OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_ALLOWMULTISELECT|OFN_ENABLEINCLUDENOTIFY|OFN_NOCHANGEDIR;
- if (!s.fKeepHistory) {
- dwFlags |= OFN_DONTADDTORECENT;
- }
+ DWORD dwFlags = OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT | OFN_ENABLEINCLUDENOTIFY | OFN_NOCHANGEDIR;
+ if (!s.fKeepHistory) {
+ dwFlags |= OFN_DONTADDTORECENT;
+ }
- COpenFileDlg fd(mask, true, NULL, NULL, dwFlags, filter, GetModalParent());
- if (fd.DoModal() != IDOK) {
- return;
- }
+ COpenFileDlg fd(mask, true, NULL, NULL, dwFlags, filter, GetModalParent());
+ if (fd.DoModal() != IDOK) {
+ return;
+ }
- CAtlList<CString> fns;
+ CAtlList<CString> fns;
- POSITION pos = fd.GetStartPosition();
- while (pos) {
- fns.AddTail(fd.GetNextPathName(pos));
- }
+ POSITION pos = fd.GetStartPosition();
+ while (pos) {
+ fns.AddTail(fd.GetNextPathName(pos));
+ }
- bool fMultipleFiles = false;
+ bool fMultipleFiles = false;
- if (fns.GetCount() > 1
- || fns.GetCount() == 1
- && (fns.GetHead()[fns.GetHead().GetLength()-1] == '\\'
- || fns.GetHead()[fns.GetHead().GetLength()-1] == '*')) {
- fMultipleFiles = true;
- }
+ if (fns.GetCount() > 1
+ || fns.GetCount() == 1
+ && (fns.GetHead()[fns.GetHead().GetLength() - 1] == '\\'
+ || fns.GetHead()[fns.GetHead().GetLength() - 1] == '*')) {
+ fMultipleFiles = true;
+ }
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- ShowWindow(SW_SHOW);
- SetForegroundWindow();
+ ShowWindow(SW_SHOW);
+ SetForegroundWindow();
- if (fns.GetCount() == 1) {
- if (OpenBD(fns.GetHead())) {
- return;
- }
- }
+ if (fns.GetCount() == 1) {
+ if (OpenBD(fns.GetHead())) {
+ return;
+ }
+ }
- m_wndPlaylistBar.Open(fns, fMultipleFiles);
+ m_wndPlaylistBar.Open(fns, fMultipleFiles);
- if (m_wndPlaylistBar.GetCount() == 1 && m_wndPlaylistBar.IsWindowVisible() && !m_wndPlaylistBar.IsFloating()) {
- ShowControlBar(&m_wndPlaylistBar, FALSE, TRUE);
- }
+ if (m_wndPlaylistBar.GetCount() == 1 && m_wndPlaylistBar.IsWindowVisible() && !m_wndPlaylistBar.IsFloating()) {
+ ShowControlBar(&m_wndPlaylistBar, FALSE, TRUE);
+ }
- OpenCurPlaylistItem();
+ OpenCurPlaylistItem();
}
void CMainFrame::OnFileOpenmedia()
{
- if (m_iMediaLoadState == MLS_LOADING || !IsWindow(m_wndPlaylistBar) || m_pFullscreenWnd->IsWindow()) {
- return;
- }
+ if (m_iMediaLoadState == MLS_LOADING || !IsWindow(m_wndPlaylistBar) || m_pFullscreenWnd->IsWindow()) {
+ return;
+ }
- static COpenDlg dlg;
- if (IsWindow(dlg.GetSafeHwnd()) && dlg.IsWindowVisible()) {
- dlg.SetForegroundWindow();
- return;
- }
- if (dlg.DoModal() != IDOK || dlg.m_fns.GetCount() == 0) {
- return;
- }
+ static COpenDlg dlg;
+ if (IsWindow(dlg.GetSafeHwnd()) && dlg.IsWindowVisible()) {
+ dlg.SetForegroundWindow();
+ return;
+ }
+ if (dlg.DoModal() != IDOK || dlg.m_fns.GetCount() == 0) {
+ return;
+ }
- if (!dlg.m_fAppendPlaylist) {
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- }
+ if (!dlg.m_fAppendPlaylist) {
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+ }
- ShowWindow(SW_SHOW);
- SetForegroundWindow();
+ ShowWindow(SW_SHOW);
+ SetForegroundWindow();
- if (!dlg.m_fMultipleFiles) {
- if (OpenBD(dlg.m_fns.GetHead())) {
- return;
- }
- }
+ if (!dlg.m_fMultipleFiles) {
+ if (OpenBD(dlg.m_fns.GetHead())) {
+ return;
+ }
+ }
- if (dlg.m_fAppendPlaylist) {
- m_wndPlaylistBar.Append(dlg.m_fns, dlg.m_fMultipleFiles);
- return;
- }
+ if (dlg.m_fAppendPlaylist) {
+ m_wndPlaylistBar.Append(dlg.m_fns, dlg.m_fMultipleFiles);
+ return;
+ }
- m_wndPlaylistBar.Open(dlg.m_fns, dlg.m_fMultipleFiles);
+ m_wndPlaylistBar.Open(dlg.m_fns, dlg.m_fMultipleFiles);
- if (m_wndPlaylistBar.GetCount() == 1 && m_wndPlaylistBar.IsWindowVisible() && !m_wndPlaylistBar.IsFloating()) {
- ShowControlBar(&m_wndPlaylistBar, FALSE, TRUE);
- }
+ if (m_wndPlaylistBar.GetCount() == 1 && m_wndPlaylistBar.IsWindowVisible() && !m_wndPlaylistBar.IsFloating()) {
+ ShowControlBar(&m_wndPlaylistBar, FALSE, TRUE);
+ }
- OpenCurPlaylistItem();
+ OpenCurPlaylistItem();
}
void CMainFrame::OnUpdateFileOpen(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState != MLS_LOADING);
+ pCmdUI->Enable(m_iMediaLoadState != MLS_LOADING);
}
BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCDS)
{
- if (m_fClosingState) {
- return FALSE;
- }
-
- AppSettings& s = AfxGetAppSettings();
-
- if (s.hMasterWnd) {
- ProcessAPICommand(pCDS);
- return TRUE;
- }
-
- /*
- if (m_iMediaLoadState == MLS_LOADING || !IsWindow(m_wndPlaylistBar))
- return FALSE;
- */
-
- if (pCDS->dwData != 0x6ABE51 || pCDS->cbData < sizeof(DWORD)) {
- return FALSE;
- }
-
- DWORD len = *((DWORD*)pCDS->lpData);
- TCHAR* pBuff = (TCHAR*)((DWORD*)pCDS->lpData + 1);
- TCHAR* pBuffEnd = (TCHAR*)((BYTE*)pBuff + pCDS->cbData - sizeof(DWORD));
-
- CAtlList<CString> cmdln;
-
- while (len-- > 0 && pBuff < pBuffEnd) {
- CString str(pBuff);
- pBuff += str.GetLength() + 1;
-
- cmdln.AddTail(str);
- }
-
- s.ParseCommandLine(cmdln);
-
- if (s.nCLSwitches&CLSW_SLAVE) {
- SendAPICommand (CMD_CONNECT, L"%d", GetSafeHwnd());
- }
-
- POSITION pos = s.slFilters.GetHeadPosition();
- while (pos) {
- CString fullpath = MakeFullPath(s.slFilters.GetNext(pos));
-
- CPath tmp(fullpath);
- tmp.RemoveFileSpec();
- tmp.AddBackslash();
- CString path = tmp;
-
- WIN32_FIND_DATA fd = {0};
- HANDLE hFind = FindFirstFile(fullpath, &fd);
- if (hFind != INVALID_HANDLE_VALUE) {
- do {
- if (fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) {
- continue;
- }
-
- CFilterMapper2 fm2(false);
- fm2.Register(path + fd.cFileName);
- while (!fm2.m_filters.IsEmpty()) {
- if (FilterOverride* f = fm2.m_filters.RemoveTail()) {
- f->fTemporary = true;
-
- bool fFound = false;
-
- POSITION pos2 = s.m_filters.GetHeadPosition();
- while (pos2) {
- FilterOverride* f2 = s.m_filters.GetNext(pos2);
- if (f2->type == FilterOverride::EXTERNAL && !f2->path.CompareNoCase(f->path)) {
- fFound = true;
- break;
- }
- }
-
- if (!fFound) {
- CAutoPtr<FilterOverride> p(f);
- s.m_filters.AddHead(p);
- }
- }
- }
- } while (FindNextFile(hFind, &fd));
-
- FindClose(hFind);
- }
- }
-
- bool fSetForegroundWindow = false;
-
- if ((s.nCLSwitches&CLSW_DVD) && !s.slFiles.IsEmpty()) {
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- fSetForegroundWindow = true;
-
- CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
- if (p) {
- p->path = s.slFiles.GetHead();
- p->subs.AddTailList(&s.slSubs);
- }
- OpenMedia(p);
- } else if (s.nCLSwitches&CLSW_CD) {
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- fSetForegroundWindow = true;
-
- CAtlList<CString> sl;
-
- if (!s.slFiles.IsEmpty()) {
- GetCDROMType(s.slFiles.GetHead()[0], sl);
- } else {
- CString dir;
- dir.ReleaseBufferSetLength(GetCurrentDirectory(_MAX_PATH, dir.GetBuffer(_MAX_PATH)));
-
- GetCDROMType(dir[0], sl);
-
- for (TCHAR drive = 'C'; sl.IsEmpty() && drive <= 'Z'; drive++) {
- GetCDROMType(drive, sl);
- }
- }
-
- m_wndPlaylistBar.Open(sl, true);
- OpenCurPlaylistItem();
- } else if (!s.slFiles.IsEmpty()) {
- CAtlList<CString> sl;
- sl.AddTailList(&s.slFiles);
-
- ParseDirs(sl);
-
- bool fMulti = sl.GetCount() > 1;
-
- if (!fMulti) {
- sl.AddTailList(&s.slDubs);
- }
-
- if (OpenBD(s.slFiles.GetHead())) {
- if (fSetForegroundWindow && !(s.nCLSwitches&CLSW_NOFOCUS)) {
- SetForegroundWindow();
- }
- s.nCLSwitches &= ~CLSW_NOFOCUS;
- return true;
- } else if (!fMulti && CPath(s.slFiles.GetHead() + _T("\\VIDEO_TS")).IsDirectory()) {
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- fSetForegroundWindow = true;
-
- CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
- if (p) {
- p->path = s.slFiles.GetHead();
- p->subs.AddTailList(&s.slSubs);
- }
- OpenMedia(p);
- } else {
- if (last_run && ((GetTickCount()-last_run)<500)) {
- s.nCLSwitches |= CLSW_ADD;
- }
- last_run = GetTickCount();
-
- if ((s.nCLSwitches&CLSW_ADD) && m_wndPlaylistBar.GetCount() > 0) {
- m_wndPlaylistBar.Append(sl, fMulti, &s.slSubs);
-
- if (s.nCLSwitches&(CLSW_OPEN|CLSW_PLAY)) {
- m_wndPlaylistBar.SetLast();
- OpenCurPlaylistItem();
- }
- } else {
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- fSetForegroundWindow = true;
-
- m_wndPlaylistBar.Open(sl, fMulti, &s.slSubs);
- OpenCurPlaylistItem((s.nCLSwitches&CLSW_STARTVALID) ? s.rtStart : 0);
-
- s.nCLSwitches &= ~CLSW_STARTVALID;
- s.rtStart = 0;
- }
- }
- } else {
- s.nCLSwitches = CLSW_NONE;
- }
-
- if (fSetForegroundWindow && !(s.nCLSwitches&CLSW_NOFOCUS)) {
- SetForegroundWindow();
- }
-
- s.nCLSwitches &= ~CLSW_NOFOCUS;
-
- return TRUE;
-}
-
-int CALLBACK BrowseCallbackProc(HWND hwnd,UINT uMsg,LPARAM lp, LPARAM pData)
-{
- switch (uMsg) {
- case BFFM_INITIALIZED:
- //Initial directory is set here
- SendMessage(hwnd, BFFM_SETSELECTION, TRUE,(LPARAM)(LPCTSTR)AfxGetAppSettings().strDVDPath);
- break;
- default:
- break;
- }
- return 0;
+ if (m_fClosingState) {
+ return FALSE;
+ }
+
+ AppSettings& s = AfxGetAppSettings();
+
+ if (s.hMasterWnd) {
+ ProcessAPICommand(pCDS);
+ return TRUE;
+ }
+
+ /*
+ if (m_iMediaLoadState == MLS_LOADING || !IsWindow(m_wndPlaylistBar))
+ return FALSE;
+ */
+
+ if (pCDS->dwData != 0x6ABE51 || pCDS->cbData < sizeof(DWORD)) {
+ return FALSE;
+ }
+
+ DWORD len = *((DWORD*)pCDS->lpData);
+ TCHAR* pBuff = (TCHAR*)((DWORD*)pCDS->lpData + 1);
+ TCHAR* pBuffEnd = (TCHAR*)((BYTE*)pBuff + pCDS->cbData - sizeof(DWORD));
+
+ CAtlList<CString> cmdln;
+
+ while (len-- > 0 && pBuff < pBuffEnd) {
+ CString str(pBuff);
+ pBuff += str.GetLength() + 1;
+
+ cmdln.AddTail(str);
+ }
+
+ s.ParseCommandLine(cmdln);
+
+ if (s.nCLSwitches & CLSW_SLAVE) {
+ SendAPICommand(CMD_CONNECT, L"%d", GetSafeHwnd());
+ }
+
+ POSITION pos = s.slFilters.GetHeadPosition();
+ while (pos) {
+ CString fullpath = MakeFullPath(s.slFilters.GetNext(pos));
+
+ CPath tmp(fullpath);
+ tmp.RemoveFileSpec();
+ tmp.AddBackslash();
+ CString path = tmp;
+
+ WIN32_FIND_DATA fd = {0};
+ HANDLE hFind = FindFirstFile(fullpath, &fd);
+ if (hFind != INVALID_HANDLE_VALUE) {
+ do {
+ if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+ continue;
+ }
+
+ CFilterMapper2 fm2(false);
+ fm2.Register(path + fd.cFileName);
+ while (!fm2.m_filters.IsEmpty()) {
+ if (FilterOverride* f = fm2.m_filters.RemoveTail()) {
+ f->fTemporary = true;
+
+ bool fFound = false;
+
+ POSITION pos2 = s.m_filters.GetHeadPosition();
+ while (pos2) {
+ FilterOverride* f2 = s.m_filters.GetNext(pos2);
+ if (f2->type == FilterOverride::EXTERNAL && !f2->path.CompareNoCase(f->path)) {
+ fFound = true;
+ break;
+ }
+ }
+
+ if (!fFound) {
+ CAutoPtr<FilterOverride> p(f);
+ s.m_filters.AddHead(p);
+ }
+ }
+ }
+ } while (FindNextFile(hFind, &fd));
+
+ FindClose(hFind);
+ }
+ }
+
+ bool fSetForegroundWindow = false;
+
+ if ((s.nCLSwitches & CLSW_DVD) && !s.slFiles.IsEmpty()) {
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+ fSetForegroundWindow = true;
+
+ CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
+ if (p) {
+ p->path = s.slFiles.GetHead();
+ p->subs.AddTailList(&s.slSubs);
+ }
+ OpenMedia(p);
+ } else if (s.nCLSwitches & CLSW_CD) {
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+ fSetForegroundWindow = true;
+
+ CAtlList<CString> sl;
+
+ if (!s.slFiles.IsEmpty()) {
+ GetCDROMType(s.slFiles.GetHead()[0], sl);
+ } else {
+ CString dir;
+ dir.ReleaseBufferSetLength(GetCurrentDirectory(_MAX_PATH, dir.GetBuffer(_MAX_PATH)));
+
+ GetCDROMType(dir[0], sl);
+
+ for (TCHAR drive = 'C'; sl.IsEmpty() && drive <= 'Z'; drive++) {
+ GetCDROMType(drive, sl);
+ }
+ }
+
+ m_wndPlaylistBar.Open(sl, true);
+ OpenCurPlaylistItem();
+ } else if (!s.slFiles.IsEmpty()) {
+ CAtlList<CString> sl;
+ sl.AddTailList(&s.slFiles);
+
+ ParseDirs(sl);
+
+ bool fMulti = sl.GetCount() > 1;
+
+ if (!fMulti) {
+ sl.AddTailList(&s.slDubs);
+ }
+
+ if (OpenBD(s.slFiles.GetHead())) {
+ if (fSetForegroundWindow && !(s.nCLSwitches & CLSW_NOFOCUS)) {
+ SetForegroundWindow();
+ }
+ s.nCLSwitches &= ~CLSW_NOFOCUS;
+ return true;
+ } else if (!fMulti && CPath(s.slFiles.GetHead() + _T("\\VIDEO_TS")).IsDirectory()) {
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+ fSetForegroundWindow = true;
+
+ CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
+ if (p) {
+ p->path = s.slFiles.GetHead();
+ p->subs.AddTailList(&s.slSubs);
+ }
+ OpenMedia(p);
+ } else {
+ if (last_run && ((GetTickCount() - last_run) < 500)) {
+ s.nCLSwitches |= CLSW_ADD;
+ }
+ last_run = GetTickCount();
+
+ if ((s.nCLSwitches & CLSW_ADD) && m_wndPlaylistBar.GetCount() > 0) {
+ m_wndPlaylistBar.Append(sl, fMulti, &s.slSubs);
+
+ if (s.nCLSwitches & (CLSW_OPEN | CLSW_PLAY)) {
+ m_wndPlaylistBar.SetLast();
+ OpenCurPlaylistItem();
+ }
+ } else {
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+ fSetForegroundWindow = true;
+
+ m_wndPlaylistBar.Open(sl, fMulti, &s.slSubs);
+ OpenCurPlaylistItem((s.nCLSwitches & CLSW_STARTVALID) ? s.rtStart : 0);
+
+ s.nCLSwitches &= ~CLSW_STARTVALID;
+ s.rtStart = 0;
+ }
+ }
+ } else {
+ s.nCLSwitches = CLSW_NONE;
+ }
+
+ if (fSetForegroundWindow && !(s.nCLSwitches & CLSW_NOFOCUS)) {
+ SetForegroundWindow();
+ }
+
+ s.nCLSwitches &= ~CLSW_NOFOCUS;
+
+ return TRUE;
+}
+
+int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData)
+{
+ switch (uMsg) {
+ case BFFM_INITIALIZED:
+ //Initial directory is set here
+ SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)(LPCTSTR)AfxGetAppSettings().strDVDPath);
+ break;
+ default:
+ break;
+ }
+ return 0;
}
void CMainFrame::OnFileOpendvd()
{
- if ((m_iMediaLoadState == MLS_LOADING) || m_pFullscreenWnd->IsWindow()) {
- return;
- }
-
- /*
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- SetForegroundWindow();
-
- ShowWindow(SW_SHOW);
-
- CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
- if (p)
- {
- AppSettings& s = AfxGetAppSettings();
- if (s.fUseDVDPath && !s.strDVDPath.IsEmpty())
- {
- p->path = s.strDVDPath;
- p->path.Replace('/', '\\');
- if (p->path[p->path.GetLength()-1] != '\\') p->path += '\\';
- }
- }
- OpenMedia(p);*/
-
- AppSettings& s = AfxGetAppSettings();
- CString strTitle = ResStr(IDS_MAINFRM_46);
- CString path;
-
- if (SysVersion::IsVistaOrLater()) {
- CFileDialog dlg(TRUE);
- IFileOpenDialog *openDlgPtr = dlg.GetIFileOpenDialog();
-
- if (openDlgPtr != NULL) {
- openDlgPtr->SetTitle(strTitle);
- openDlgPtr->SetOptions(FOS_PICKFOLDERS | FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST);
- if (FAILED(openDlgPtr->Show(m_hWnd))) {
- openDlgPtr->Release();
- return;
- }
- openDlgPtr->Release();
-
- path = dlg.GetFolderPath();
- }
- } else {
- TCHAR _path[_MAX_PATH];
-
- BROWSEINFO bi;
- bi.hwndOwner = m_hWnd;
- bi.pidlRoot = NULL;
- bi.pszDisplayName = _path;
- bi.lpszTitle = strTitle;
- bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_VALIDATE | BIF_USENEWUI | BIF_NONEWFOLDERBUTTON;
- bi.lpfn = BrowseCallbackProc;
- bi.lParam = 0;
- bi.iImage = 0;
-
- static LPITEMIDLIST iil;
- iil = SHBrowseForFolder(&bi);
- if (iil) {
- SHGetPathFromIDList(iil, _path);
- path = _path;
- }
- }
-
- if (!path.IsEmpty()) {
- s.strDVDPath = path;
- if (!OpenBD(path)) {
- CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
- p->path = path;
- p->path.Replace('/', '\\');
- if (p->path[p->path.GetLength()-1] != '\\') {
- p->path += '\\';
- }
-
- OpenMedia(p);
- }
- }
+ if ((m_iMediaLoadState == MLS_LOADING) || m_pFullscreenWnd->IsWindow()) {
+ return;
+ }
+
+ /*
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+ SetForegroundWindow();
+
+ ShowWindow(SW_SHOW);
+
+ CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
+ if (p)
+ {
+ AppSettings& s = AfxGetAppSettings();
+ if (s.fUseDVDPath && !s.strDVDPath.IsEmpty())
+ {
+ p->path = s.strDVDPath;
+ p->path.Replace('/', '\\');
+ if (p->path[p->path.GetLength()-1] != '\\') p->path += '\\';
+ }
+ }
+ OpenMedia(p);*/
+
+ AppSettings& s = AfxGetAppSettings();
+ CString strTitle = ResStr(IDS_MAINFRM_46);
+ CString path;
+
+ if (SysVersion::IsVistaOrLater()) {
+ CFileDialog dlg(TRUE);
+ IFileOpenDialog* openDlgPtr = dlg.GetIFileOpenDialog();
+
+ if (openDlgPtr != NULL) {
+ openDlgPtr->SetTitle(strTitle);
+ openDlgPtr->SetOptions(FOS_PICKFOLDERS | FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST);
+ if (FAILED(openDlgPtr->Show(m_hWnd))) {
+ openDlgPtr->Release();
+ return;
+ }
+ openDlgPtr->Release();
+
+ path = dlg.GetFolderPath();
+ }
+ } else {
+ TCHAR _path[_MAX_PATH];
+
+ BROWSEINFO bi;
+ bi.hwndOwner = m_hWnd;
+ bi.pidlRoot = NULL;
+ bi.pszDisplayName = _path;
+ bi.lpszTitle = strTitle;
+ bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_VALIDATE | BIF_USENEWUI | BIF_NONEWFOLDERBUTTON;
+ bi.lpfn = BrowseCallbackProc;
+ bi.lParam = 0;
+ bi.iImage = 0;
+
+ static LPITEMIDLIST iil;
+ iil = SHBrowseForFolder(&bi);
+ if (iil) {
+ SHGetPathFromIDList(iil, _path);
+ path = _path;
+ }
+ }
+
+ if (!path.IsEmpty()) {
+ s.strDVDPath = path;
+ if (!OpenBD(path)) {
+ CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
+ p->path = path;
+ p->path.Replace('/', '\\');
+ if (p->path[p->path.GetLength() - 1] != '\\') {
+ p->path += '\\';
+ }
+
+ OpenMedia(p);
+ }
+ }
}
void CMainFrame::OnFileOpendevice()
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- if (m_iMediaLoadState == MLS_LOADING) {
- return;
- }
+ if (m_iMediaLoadState == MLS_LOADING) {
+ return;
+ }
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- SetForegroundWindow();
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+ SetForegroundWindow();
- ShowWindow(SW_SHOW);
+ ShowWindow(SW_SHOW);
- m_wndPlaylistBar.Empty();
+ m_wndPlaylistBar.Empty();
- CAutoPtr<OpenDeviceData> p(DNew OpenDeviceData());
- if (p) {
- p->DisplayName[0] = s.strAnalogVideo;
- p->DisplayName[1] = s.strAnalogAudio;
- }
- OpenMedia(p);
- if (GetPlaybackMode() == PM_CAPTURE && !s.fHideNavigation && m_iMediaLoadState == MLS_LOADED && s.iDefaultCaptureDevice == 1) {
- m_wndNavigationBar.m_navdlg.UpdateElementList();
- ShowControlBar(&m_wndNavigationBar, !s.fHideNavigation, TRUE);
- }
+ CAutoPtr<OpenDeviceData> p(DNew OpenDeviceData());
+ if (p) {
+ p->DisplayName[0] = s.strAnalogVideo;
+ p->DisplayName[1] = s.strAnalogAudio;
+ }
+ OpenMedia(p);
+ if (GetPlaybackMode() == PM_CAPTURE && !s.fHideNavigation && m_iMediaLoadState == MLS_LOADED && s.iDefaultCaptureDevice == 1) {
+ m_wndNavigationBar.m_navdlg.UpdateElementList();
+ ShowControlBar(&m_wndNavigationBar, !s.fHideNavigation, TRUE);
+ }
}
void CMainFrame::OnFileOpenCD(UINT nID)
{
- nID -= ID_FILE_OPEN_CD_START;
+ nID -= ID_FILE_OPEN_CD_START;
- nID++;
- for (TCHAR drive = 'C'; drive <= 'Z'; drive++) {
- CAtlList<CString> sl;
+ nID++;
+ for (TCHAR drive = 'C'; drive <= 'Z'; drive++) {
+ CAtlList<CString> sl;
- switch (GetCDROMType(drive, sl)) {
- case CDROM_Audio:
- case CDROM_VideoCD:
- case CDROM_DVDVideo:
- nID--;
- break;
- default:
- break;
- }
+ switch (GetCDROMType(drive, sl)) {
+ case CDROM_Audio:
+ case CDROM_VideoCD:
+ case CDROM_DVDVideo:
+ nID--;
+ break;
+ default:
+ break;
+ }
- if (nID == 0) {
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- SetForegroundWindow();
+ if (nID == 0) {
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+ SetForegroundWindow();
- ShowWindow(SW_SHOW);
+ ShowWindow(SW_SHOW);
- m_wndPlaylistBar.Open(sl, true);
- OpenCurPlaylistItem();
+ m_wndPlaylistBar.Open(sl, true);
+ OpenCurPlaylistItem();
- break;
- }
- }
+ break;
+ }
+ }
}
void CMainFrame::OnFileReopen()
{
- if (!m_LastOpenBDPath.IsEmpty() && OpenBD(m_LastOpenBDPath)) {
- return;
- }
- OpenCurPlaylistItem();
+ if (!m_LastOpenBDPath.IsEmpty() && OpenBD(m_LastOpenBDPath)) {
+ return;
+ }
+ OpenCurPlaylistItem();
}
void CMainFrame::OnDropFiles(HDROP hDropInfo)
{
- SetForegroundWindow();
+ SetForegroundWindow();
- if (m_wndPlaylistBar.IsWindowVisible()) {
- m_wndPlaylistBar.OnDropFiles(hDropInfo);
- return;
- }
+ if (m_wndPlaylistBar.IsWindowVisible()) {
+ m_wndPlaylistBar.OnDropFiles(hDropInfo);
+ return;
+ }
- CAtlList<CString> sl;
+ CAtlList<CString> sl;
- UINT nFiles = ::DragQueryFile(hDropInfo, (UINT)-1, NULL, 0);
+ UINT nFiles = ::DragQueryFile(hDropInfo, (UINT) - 1, NULL, 0);
- if (nFiles == 1) {
- CString path;
- path.ReleaseBuffer(::DragQueryFile(hDropInfo, 0, path.GetBuffer(_MAX_PATH), _MAX_PATH));
- if (OpenBD(path)) {
- return;
- }
- }
+ if (nFiles == 1) {
+ CString path;
+ path.ReleaseBuffer(::DragQueryFile(hDropInfo, 0, path.GetBuffer(_MAX_PATH), _MAX_PATH));
+ if (OpenBD(path)) {
+ return;
+ }
+ }
- for (UINT iFile = 0; iFile < nFiles; iFile++) {
- CString fn;
- fn.ReleaseBuffer(::DragQueryFile(hDropInfo, iFile, fn.GetBuffer(_MAX_PATH), _MAX_PATH));
- sl.AddTail(fn);
- }
+ for (UINT iFile = 0; iFile < nFiles; iFile++) {
+ CString fn;
+ fn.ReleaseBuffer(::DragQueryFile(hDropInfo, iFile, fn.GetBuffer(_MAX_PATH), _MAX_PATH));
+ sl.AddTail(fn);
+ }
- ParseDirs(sl);
+ ParseDirs(sl);
- ::DragFinish(hDropInfo);
+ ::DragFinish(hDropInfo);
- if (sl.IsEmpty()) {
- return;
- }
+ if (sl.IsEmpty()) {
+ return;
+ }
- if (sl.GetCount() == 1 && m_iMediaLoadState == MLS_LOADED && m_pCAP) {
- ISubStream *pSubStream = NULL;
- if (LoadSubtitle(sl.GetHead(), &pSubStream)) {
- SetSubtitle(pSubStream); // the subtitle at the insert position according to LoadSubtitle()
- CPath p(sl.GetHead());
- p.StripPath();
- SendStatusMessage(CString((LPCTSTR)p) + ResStr(IDS_MAINFRM_47), 3000);
- return;
- }
- }
+ if (sl.GetCount() == 1 && m_iMediaLoadState == MLS_LOADED && m_pCAP) {
+ ISubStream* pSubStream = NULL;
+ if (LoadSubtitle(sl.GetHead(), &pSubStream)) {
+ SetSubtitle(pSubStream); // the subtitle at the insert position according to LoadSubtitle()
+ CPath p(sl.GetHead());
+ p.StripPath();
+ SendStatusMessage(CString((LPCTSTR)p) + ResStr(IDS_MAINFRM_47), 3000);
+ return;
+ }
+ }
- m_wndPlaylistBar.Open(sl, true);
- OpenCurPlaylistItem();
+ m_wndPlaylistBar.Open(sl, true);
+ OpenCurPlaylistItem();
}
void CMainFrame::OnFileSaveAs()
{
- CString ext, in = m_wndPlaylistBar.GetCurFileName(), out = in;
-
- if (out.Find(_T("://")) < 0) {
- ext = CString(CPath(out).GetExtension()).MakeLower();
- if (ext == _T(".cda")) {
- out = out.Left(out.GetLength()-4) + _T(".wav");
- } else if (ext == _T(".ifo")) {
- out = out.Left(out.GetLength()-4) + _T(".vob");
- }
- } else {
- out.Empty();
- }
-
- CFileDialog fd(FALSE, 0, out,
- OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST|OFN_NOCHANGEDIR,
- ResStr(IDS_MAINFRM_48), GetModalParent(), 0);
- if (fd.DoModal() != IDOK || !in.CompareNoCase(fd.GetPathName())) {
- return;
- }
-
- CPath p(fd.GetPathName());
- if (!ext.IsEmpty()) {
- p.AddExtension(ext);
- }
-
- OAFilterState fs = State_Stopped;
- pMC->GetState(0, &fs);
- if (fs == State_Running) {
- pMC->Pause();
- }
-
- CSaveDlg dlg(in, p);
- dlg.DoModal();
-
- if (fs == State_Running) {
- pMC->Run();
- }
+ CString ext, in = m_wndPlaylistBar.GetCurFileName(), out = in;
+
+ if (out.Find(_T("://")) < 0) {
+ ext = CString(CPath(out).GetExtension()).MakeLower();
+ if (ext == _T(".cda")) {
+ out = out.Left(out.GetLength() - 4) + _T(".wav");
+ } else if (ext == _T(".ifo")) {
+ out = out.Left(out.GetLength() - 4) + _T(".vob");
+ }
+ } else {
+ out.Empty();
+ }
+
+ CFileDialog fd(FALSE, 0, out,
+ OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR,
+ ResStr(IDS_MAINFRM_48), GetModalParent(), 0);
+ if (fd.DoModal() != IDOK || !in.CompareNoCase(fd.GetPathName())) {
+ return;
+ }
+
+ CPath p(fd.GetPathName());
+ if (!ext.IsEmpty()) {
+ p.AddExtension(ext);
+ }
+
+ OAFilterState fs = State_Stopped;
+ pMC->GetState(0, &fs);
+ if (fs == State_Running) {
+ pMC->Pause();
+ }
+
+ CSaveDlg dlg(in, p);
+ dlg.DoModal();
+
+ if (fs == State_Running) {
+ pMC->Run();
+ }
}
void CMainFrame::OnUpdateFileSaveAs(CCmdUI* pCmdUI)
{
- if (m_iMediaLoadState != MLS_LOADED || GetPlaybackMode() != PM_FILE) {
- pCmdUI->Enable(FALSE);
- return;
- }
+ if (m_iMediaLoadState != MLS_LOADED || GetPlaybackMode() != PM_FILE) {
+ pCmdUI->Enable(FALSE);
+ return;
+ }
- CString fn = m_wndPlaylistBar.GetCurFileName();
- CString ext = fn.Mid(fn.ReverseFind('.')+1).MakeLower();
+ CString fn = m_wndPlaylistBar.GetCurFileName();
+ CString ext = fn.Mid(fn.ReverseFind('.') + 1).MakeLower();
- if (fn.Find(_T("://")) >= 0) {
- pCmdUI->Enable(FALSE);
- return;
- }
+ if (fn.Find(_T("://")) >= 0) {
+ pCmdUI->Enable(FALSE);
+ return;
+ }
- pCmdUI->Enable(TRUE);
+ pCmdUI->Enable(TRUE);
}
bool CMainFrame::GetDIB(BYTE** ppData, long& size, bool fSilent)
{
- if (!ppData) {
- return false;
- }
-
- *ppData = NULL;
- size = 0;
-
- OAFilterState fs = GetMediaState();
-
- if (!(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly && (fs == State_Paused || fs == State_Running))) {
- return false;
- }
-
- if (fs == State_Running && !m_pCAP) {
- pMC->Pause();
- GetMediaState(); // wait for completion of the pause command
- }
-
- HRESULT hr = S_OK;
- CString errmsg;
-
- do {
- if (m_pCAP) {
- hr = m_pCAP->GetDIB(NULL, (DWORD*)&size);
- if (FAILED(hr)) {
- errmsg.Format(IDS_MAINFRM_49, hr);
- break;
- }
-
- *ppData = DNew BYTE[size];
- if (!(*ppData)) {
- return false;
- }
-
- hr = m_pCAP->GetDIB(*ppData, (DWORD*)&size);
- //if (FAILED(hr)) {errmsg.Format(_T("GetDIB failed, hr = %08x"), hr); break;}
- if (FAILED(hr)) {
- OnPlayPause();
- GetMediaState(); // Pause and retry to support ffdshow queuing.
- int retry = 0;
- while (FAILED(hr) && retry < 20) {
- hr = m_pCAP->GetDIB(*ppData, (DWORD*)&size);
- if (SUCCEEDED(hr)) {
- break;
- }
- Sleep(1);
- retry++;
- }
- if (FAILED(hr)) {
- errmsg.Format(IDS_MAINFRM_49, hr);
- break;
- }
- }
- } else if (m_pMFVDC) {
- // Capture with EVR
- BITMAPINFOHEADER bih = {sizeof(BITMAPINFOHEADER)};
- BYTE* pDib;
- DWORD dwSize;
- REFERENCE_TIME rtImage = 0;
- hr = m_pMFVDC->GetCurrentImage (&bih, &pDib, &dwSize, &rtImage);
- if (FAILED(hr) || dwSize == 0) {
- errmsg.Format(IDS_MAINFRM_51, hr);
- break;
- }
-
- size = (long)dwSize+sizeof(BITMAPINFOHEADER);
- *ppData = DNew BYTE[size];
- if (!(*ppData)) {
- return false;
- }
- memcpy_s (*ppData, size, &bih, sizeof(BITMAPINFOHEADER));
- memcpy_s (*ppData+sizeof(BITMAPINFOHEADER), size-sizeof(BITMAPINFOHEADER), pDib, dwSize);
- CoTaskMemFree (pDib);
- } else {
- hr = pBV->GetCurrentImage(&size, NULL);
- if (FAILED(hr) || size == 0) {
- errmsg.Format(IDS_MAINFRM_51, hr);
- break;
- }
-
- *ppData = DNew BYTE[size];
- if (!(*ppData)) {
- return false;
- }
-
- hr = pBV->GetCurrentImage(&size, (long*)*ppData);
- if (FAILED(hr)) {
- errmsg.Format(IDS_MAINFRM_51, hr);
- break;
- }
- }
- } while (0);
-
- if (!fSilent) {
- if (!errmsg.IsEmpty()) {
- AfxMessageBox(errmsg, MB_OK);
- }
- }
-
- if (fs == State_Running && GetMediaState() != State_Running) {
- pMC->Run();
- }
-
- if (FAILED(hr)) {
- if (*ppData) {
- ASSERT(0); // huh?
- delete [] *ppData;
- *ppData = NULL;
- }
- return false;
- }
-
- return true;
+ if (!ppData) {
+ return false;
+ }
+
+ *ppData = NULL;
+ size = 0;
+
+ OAFilterState fs = GetMediaState();
+
+ if (!(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly && (fs == State_Paused || fs == State_Running))) {
+ return false;
+ }
+
+ if (fs == State_Running && !m_pCAP) {
+ pMC->Pause();
+ GetMediaState(); // wait for completion of the pause command
+ }
+
+ HRESULT hr = S_OK;
+ CString errmsg;
+
+ do {
+ if (m_pCAP) {
+ hr = m_pCAP->GetDIB(NULL, (DWORD*)&size);
+ if (FAILED(hr)) {
+ errmsg.Format(IDS_MAINFRM_49, hr);
+ break;
+ }
+
+ *ppData = DNew BYTE[size];
+ if (!(*ppData)) {
+ return false;
+ }
+
+ hr = m_pCAP->GetDIB(*ppData, (DWORD*)&size);
+ //if (FAILED(hr)) {errmsg.Format(_T("GetDIB failed, hr = %08x"), hr); break;}
+ if (FAILED(hr)) {
+ OnPlayPause();
+ GetMediaState(); // Pause and retry to support ffdshow queuing.
+ int retry = 0;
+ while (FAILED(hr) && retry < 20) {
+ hr = m_pCAP->GetDIB(*ppData, (DWORD*)&size);
+ if (SUCCEEDED(hr)) {
+ break;
+ }
+ Sleep(1);
+ retry++;
+ }
+ if (FAILED(hr)) {
+ errmsg.Format(IDS_MAINFRM_49, hr);
+ break;
+ }
+ }
+ } else if (m_pMFVDC) {
+ // Capture with EVR
+ BITMAPINFOHEADER bih = {sizeof(BITMAPINFOHEADER)};
+ BYTE* pDib;
+ DWORD dwSize;
+ REFERENCE_TIME rtImage = 0;
+ hr = m_pMFVDC->GetCurrentImage(&bih, &pDib, &dwSize, &rtImage);
+ if (FAILED(hr) || dwSize == 0) {
+ errmsg.Format(IDS_MAINFRM_51, hr);
+ break;
+ }
+
+ size = (long)dwSize + sizeof(BITMAPINFOHEADER);
+ *ppData = DNew BYTE[size];
+ if (!(*ppData)) {
+ return false;
+ }
+ memcpy_s(*ppData, size, &bih, sizeof(BITMAPINFOHEADER));
+ memcpy_s(*ppData + sizeof(BITMAPINFOHEADER), size - sizeof(BITMAPINFOHEADER), pDib, dwSize);
+ CoTaskMemFree(pDib);
+ } else {
+ hr = pBV->GetCurrentImage(&size, NULL);
+ if (FAILED(hr) || size == 0) {
+ errmsg.Format(IDS_MAINFRM_51, hr);
+ break;
+ }
+
+ *ppData = DNew BYTE[size];
+ if (!(*ppData)) {
+ return false;
+ }
+
+ hr = pBV->GetCurrentImage(&size, (long*)*ppData);
+ if (FAILED(hr)) {
+ errmsg.Format(IDS_MAINFRM_51, hr);
+ break;
+ }
+ }
+ } while (0);
+
+ if (!fSilent) {
+ if (!errmsg.IsEmpty()) {
+ AfxMessageBox(errmsg, MB_OK);
+ }
+ }
+
+ if (fs == State_Running && GetMediaState() != State_Running) {
+ pMC->Run();
+ }
+
+ if (FAILED(hr)) {
+ if (*ppData) {
+ ASSERT(0); // huh?
+ delete [] *ppData;
+ *ppData = NULL;
+ }
+ return false;
+ }
+
+ return true;
}
void CMainFrame::SaveDIB(LPCTSTR fn, BYTE* pData, long size)
{
- PBITMAPINFO bi = reinterpret_cast<PBITMAPINFO>(pData);
- PBITMAPINFOHEADER bih = &bi->bmiHeader;
-
- int bpp = bih->biBitCount;
- if (bpp != 16 && bpp != 24 && bpp != 32) {
- AfxMessageBox(IDS_MAINFRM_53, MB_ICONWARNING | MB_OK, 0);
- return;
- }
- int w = bih->biWidth;
- int h = abs(bih->biHeight);
- BYTE* p = DNew BYTE[w * h * 4];
+ PBITMAPINFO bi = reinterpret_cast<PBITMAPINFO>(pData);
+ PBITMAPINFOHEADER bih = &bi->bmiHeader;
- const BYTE* src = pData + sizeof(*bih);
- if (bpp <= 8) {
- if (bih->biClrUsed) {
- src += bih->biClrUsed * sizeof(bi->bmiColors[0]);
- } else {
- src += (1 << bpp) * DWORD(sizeof(bi->bmiColors[0]));
- }
- }
+ int bpp = bih->biBitCount;
+ if (bpp != 16 && bpp != 24 && bpp != 32) {
+ AfxMessageBox(IDS_MAINFRM_53, MB_ICONWARNING | MB_OK, 0);
+ return;
+ }
+ int w = bih->biWidth;
+ int h = abs(bih->biHeight);
+ BYTE* p = DNew BYTE[w * h * 4];
+
+ const BYTE* src = pData + sizeof(*bih);
+ if (bpp <= 8) {
+ if (bih->biClrUsed) {
+ src += bih->biClrUsed * sizeof(bi->bmiColors[0]);
+ } else {
+ src += (1 << bpp) * DWORD(sizeof(bi->bmiColors[0]));
+ }
+ }
- int srcpitch = w * (bpp >> 3);
- int dstpitch = w * 4;
+ int srcpitch = w * (bpp >> 3);
+ int dstpitch = w * 4;
- BitBltFromRGBToRGB(w, h, p, dstpitch, 32, (BYTE*)src + srcpitch * (h - 1), -srcpitch, bpp);
+ BitBltFromRGBToRGB(w, h, p, dstpitch, 32, (BYTE*)src + srcpitch * (h - 1), -srcpitch, bpp);
- {
- CBitmap bmp;
- bmp.CreateBitmap(w, h, bih->biPlanes, bpp, p);
- delete [] p;
+ {
+ CBitmap bmp;
+ bmp.CreateBitmap(w, h, bih->biPlanes, bpp, p);
+ delete [] p;
- CImage img;
- img.Attach(bmp);
+ CImage img;
+ img.Attach(bmp);
- if (FAILED(img.Save(fn))) {
- AfxMessageBox(IDS_MAINFRM_53, MB_ICONWARNING | MB_OK, 0);
- return;
- }
- }
+ if (FAILED(img.Save(fn))) {
+ AfxMessageBox(IDS_MAINFRM_53, MB_ICONWARNING | MB_OK, 0);
+ return;
+ }
+ }
- CPath path(fn);
- path.m_strPath.Replace(_T("\\\\"), _T("\\"));
+ CPath path(fn);
+ path.m_strPath.Replace(_T("\\\\"), _T("\\"));
- if (CDC* pDC = m_wndStatusBar.m_status.GetDC()) {
- CRect r;
- m_wndStatusBar.m_status.GetClientRect(r);
- path.CompactPath(pDC->m_hDC, r.Width());
- m_wndStatusBar.m_status.ReleaseDC(pDC);
- }
+ if (CDC* pDC = m_wndStatusBar.m_status.GetDC()) {
+ CRect r;
+ m_wndStatusBar.m_status.GetClientRect(r);
+ path.CompactPath(pDC->m_hDC, r.Width());
+ m_wndStatusBar.m_status.ReleaseDC(pDC);
+ }
- SendStatusMessage((LPCTSTR)path, 3000);
+ SendStatusMessage((LPCTSTR)path, 3000);
}
void CMainFrame::SaveImage(LPCTSTR fn)
{
- BYTE* pData = NULL;
- long size = 0;
+ BYTE* pData = NULL;
+ long size = 0;
- if (GetDIB(&pData, size)) {
- SaveDIB(fn, pData, size);
- delete [] pData;
+ if (GetDIB(&pData, size)) {
+ SaveDIB(fn, pData, size);
+ delete [] pData;
- m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_OSD_IMAGE_SAVED), 3000);
- }
+ m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_OSD_IMAGE_SAVED), 3000);
+ }
}
void CMainFrame::SaveThumbnails(LPCTSTR fn)
{
- if (!pMC || !pMS || GetPlaybackMode() != PM_FILE /*&& GetPlaybackMode() != PM_DVD*/) {
- return;
- }
-
- REFERENCE_TIME rtPos = GetPos();
- REFERENCE_TIME rtDur = GetDur();
-
- if (rtDur <= 0) {
- AfxMessageBox(IDS_MAINFRM_54, MB_ICONWARNING | MB_OK, 0);
- return;
- }
-
- pMC->Pause();
- GetMediaState(); // wait for completion of the pause command
-
- //
-
- CSize video, wh(0, 0), arxy(0, 0);
-
- if (m_pMFVDC) {
- m_pMFVDC->GetNativeVideoSize(&wh, &arxy);
- } else if (m_pCAP) {
- wh = m_pCAP->GetVideoSize(false);
- arxy = m_pCAP->GetVideoSize(true);
- } else {
- pBV->GetVideoSize(&wh.cx, &wh.cy);
-
- long arx = 0, ary = 0;
- CComQIPtr<IBasicVideo2> pBV2 = pBV;
- if (pBV2 && SUCCEEDED(pBV2->GetPreferredAspectRatio(&arx, &ary)) && arx > 0 && ary > 0) {
- arxy.SetSize(arx, ary);
- }
- }
-
- if (wh.cx <= 0 || wh.cy <= 0) {
- AfxMessageBox(IDS_MAINFRM_55, MB_ICONWARNING | MB_OK, 0);
- return;
- }
-
- // with the overlay mixer IBasicVideo2 won't tell the new AR when changed dynamically
- DVD_VideoAttributes VATR;
- if (GetPlaybackMode() == PM_DVD && SUCCEEDED(pDVDI->GetCurrentVideoAttributes(&VATR))) {
- arxy.SetSize(VATR.ulAspectX, VATR.ulAspectY);
- }
-
- video = (arxy.cx <= 0 || arxy.cy <= 0) ? wh : CSize(MulDiv(wh.cy, arxy.cx, arxy.cy), wh.cy);
-
- //
-
- AppSettings& s = AfxGetAppSettings();
-
- int cols = max (1, min (10, s.iThumbCols)), rows = max(1, min (20, s.iThumbRows));
-
- int margin = 5;
- int infoheight = 70;
- int width = max (256, min (2560, s.iThumbWidth));
- int height = width * video.cy / video.cx * rows / cols + infoheight;
-
- int dibsize = sizeof(BITMAPINFOHEADER) + width*height*4;
-
- CAutoVectorPtr<BYTE> dib;
- if (!dib.Allocate(dibsize)) {
- AfxMessageBox(IDS_MAINFRM_56, MB_ICONWARNING | MB_OK, 0);
- return;
- }
-
- BITMAPINFOHEADER* bih = (BITMAPINFOHEADER*)(BYTE*)dib;
- memset(bih, 0, sizeof(BITMAPINFOHEADER));
- bih->biSize = sizeof(BITMAPINFOHEADER);
- bih->biWidth = width;
- bih->biHeight = height;
- bih->biPlanes = 1;
- bih->biBitCount = 32;
- bih->biCompression = BI_RGB;
- bih->biSizeImage = width*height*4;
- memsetd(bih + 1, 0xffffff, bih->biSizeImage);
-
- SubPicDesc spd;
- spd.w = width;
- spd.h = height;
- spd.bpp = 32;
- spd.pitch = -width*4;
- spd.vidrect = CRect(0, 0, width, height);
- spd.bits = (BYTE*)(bih + 1) + (width*4)*(height-1);
-
- {
- BYTE* p = (BYTE*)spd.bits;
- for (int y = 0; y < spd.h; y++, p += spd.pitch)
- for (int x = 0; x < spd.w; x++) {
- ((DWORD*)p)[x] = 0x010101 * (0xe0 + 0x08*y/spd.h + 0x18*(spd.w-x)/spd.w);
- }
- }
-
- CCritSec csSubLock;
- RECT bbox;
-
- for (int i = 1, pics = cols*rows; i <= pics; i++) {
- REFERENCE_TIME rt = rtDur * i / (pics+1);
- DVD_HMSF_TIMECODE hmsf = RT2HMS_r(rt);
-
- SeekTo(rt);
-
- m_VolumeBeforeFrameStepping = m_wndToolBar.Volume;
- pBA->put_Volume(-10000);
-
- HRESULT hr = pFS ? pFS->Step(1, NULL) : E_FAIL;
-
- if (FAILED(hr)) {
- pBA->put_Volume(m_VolumeBeforeFrameStepping);
- AfxMessageBox(IDS_FRAME_STEP_ERROR_RENDERER, MB_ICONEXCLAMATION | MB_OK, 0);
- return;
- }
-
- HANDLE hGraphEvent = NULL;
- pME->GetEventHandle((OAEVENT*)&hGraphEvent);
-
- while (hGraphEvent && WaitForSingleObject(hGraphEvent, INFINITE) == WAIT_OBJECT_0) {
- LONG evCode = 0;
- LONG_PTR evParam1, evParam2;
- while (pME && SUCCEEDED(pME->GetEvent(&evCode, &evParam1, &evParam2, 0))) {
- pME->FreeEventParams(evCode, evParam1, evParam2);
- if (EC_STEP_COMPLETE == evCode) {
- hGraphEvent = NULL;
- }
- }
- }
-
- pBA->put_Volume(m_VolumeBeforeFrameStepping);
-
- int col = (i-1)%cols;
- int row = (i-1)/cols;
-
- CSize s((width-margin*2)/cols, (height-margin*2-infoheight)/rows);
- CPoint p(margin+col*s.cx, margin+row*s.cy+infoheight);
- CRect r(p, s);
- r.DeflateRect(margin, margin);
-
- CRenderedTextSubtitle rts(&csSubLock);
- rts.CreateDefaultStyle(0);
- rts.m_dstScreenSize.SetSize(width, height);
- STSStyle* style = DNew STSStyle();
- style->marginRect.SetRectEmpty();
- rts.AddStyle(_T("thumbs"), style);
-
- CStringW str;
- str.Format(L"{\\an7\\1c&Hffffff&\\4a&Hb0&\\bord1\\shad4\\be1}{\\p1}m %d %d l %d %d %d %d %d %d{\\p}",
- r.left, r.top, r.right, r.top, r.right, r.bottom, r.left, r.bottom);
- rts.Add(str, true, 0, 1, _T("thumbs"));
- str.Format(L"{\\an3\\1c&Hffffff&\\3c&H000000&\\alpha&H80&\\fs16\\b1\\bord2\\shad0\\pos(%d,%d)}%02d:%02d:%02d",
- r.right-5, r.bottom-3, hmsf.bHours, hmsf.bMinutes, hmsf.bSeconds);
- rts.Add(str, true, 1, 2, _T("thumbs"));
-
- rts.Render(spd, 0, 25, bbox);
-
- BYTE* pData = NULL;
- long size = 0;
- if (!GetDIB(&pData, size)) {
- return;
- }
-
- BITMAPINFO* bi = (BITMAPINFO*)pData;
-
- if (bi->bmiHeader.biBitCount != 32) {
- delete [] pData;
- CString str;
- str.Format(IDS_MAINFRM_57, bi->bmiHeader.biBitCount);
- AfxMessageBox(str);
- return;
- }
-
- int sw = bi->bmiHeader.biWidth;
- int sh = abs(bi->bmiHeader.biHeight);
- int sp = sw*4;
- const BYTE* src = pData + sizeof(bi->bmiHeader);
- if (bi->bmiHeader.biHeight >= 0) {
- src += sp*(sh-1);
- sp = -sp;
- }
-
- int dp = spd.pitch;
- BYTE* dst = (BYTE*)spd.bits + spd.pitch*r.top + r.left*4;
-
- for (DWORD h = r.bottom - r.top, y = 0, yd = (sh<<8)/h; h > 0; y += yd, h--) {
- DWORD yf = y&0xff;
- DWORD yi = y>>8;
-
- DWORD* s0 = (DWORD*)(src + (int)yi*sp);
- DWORD* s1 = (DWORD*)(src + (int)yi*sp + sp);
- DWORD* d = (DWORD*)dst;
+ if (!pMC || !pMS || GetPlaybackMode() != PM_FILE /*&& GetPlaybackMode() != PM_DVD*/) {
+ return;
+ }
- for (DWORD w = r.right - r.left, x = 0, xd = (sw<<8)/w; w > 0; x += xd, w--) {
- DWORD xf = x&0xff;
- DWORD xi = x>>8;
+ REFERENCE_TIME rtPos = GetPos();
+ REFERENCE_TIME rtDur = GetDur();
- DWORD c0 = s0[xi];
- DWORD c1 = s0[xi+1];
- DWORD c2 = s1[xi];
- DWORD c3 = s1[xi+1];
+ if (rtDur <= 0) {
+ AfxMessageBox(IDS_MAINFRM_54, MB_ICONWARNING | MB_OK, 0);
+ return;
+ }
- c0 = ((c0&0xff00ff) + ((((c1&0xff00ff) - (c0&0xff00ff)) * xf) >> 8)) & 0xff00ff
- | ((c0&0x00ff00) + ((((c1&0x00ff00) - (c0&0x00ff00)) * xf) >> 8)) & 0x00ff00;
+ pMC->Pause();
+ GetMediaState(); // wait for completion of the pause command
- c2 = ((c2&0xff00ff) + ((((c3&0xff00ff) - (c2&0xff00ff)) * xf) >> 8)) & 0xff00ff
- | ((c2&0x00ff00) + ((((c3&0x00ff00) - (c2&0x00ff00)) * xf) >> 8)) & 0x00ff00;
+ //
- c0 = ((c0&0xff00ff) + ((((c2&0xff00ff) - (c0&0xff00ff)) * yf) >> 8)) & 0xff00ff
- | ((c0&0x00ff00) + ((((c2&0x00ff00) - (c0&0x00ff00)) * yf) >> 8)) & 0x00ff00;
-
- *d++ = c0;
- }
-
- dst += dp;
- }
-
- rts.Render(spd, 10000, 25, bbox);
+ CSize video, wh(0, 0), arxy(0, 0);
- delete [] pData;
- }
-
- {
- CRenderedTextSubtitle rts(&csSubLock);
- rts.CreateDefaultStyle(0);
- rts.m_dstScreenSize.SetSize(width, height);
- STSStyle* style = DNew STSStyle();
- style->marginRect.SetRect(margin*2, margin*2, margin*2, height-infoheight-margin);
- rts.AddStyle(_T("thumbs"), style);
+ if (m_pMFVDC) {
+ m_pMFVDC->GetNativeVideoSize(&wh, &arxy);
+ } else if (m_pCAP) {
+ wh = m_pCAP->GetVideoSize(false);
+ arxy = m_pCAP->GetVideoSize(true);
+ } else {
+ pBV->GetVideoSize(&wh.cx, &wh.cy);
- CStringW str;
- str.Format(L"{\\an9\\fs%d\\b1\\bord0\\shad0\\1c&Hffffff&}%s", infoheight-10, width >= 550 ? L"Media Player Classic" : L"MPC");
+ long arx = 0, ary = 0;
+ CComQIPtr<IBasicVideo2> pBV2 = pBV;
+ if (pBV2 && SUCCEEDED(pBV2->GetPreferredAspectRatio(&arx, &ary)) && arx > 0 && ary > 0) {
+ arxy.SetSize(arx, ary);
+ }
+ }
- rts.Add(str, true, 0, 1, _T("thumbs"), _T(""), _T(""), CRect(0,0,0,0), -1);
+ if (wh.cx <= 0 || wh.cy <= 0) {
+ AfxMessageBox(IDS_MAINFRM_55, MB_ICONWARNING | MB_OK, 0);
+ return;
+ }
- DVD_HMSF_TIMECODE hmsf = RT2HMS_r(rtDur);
+ // with the overlay mixer IBasicVideo2 won't tell the new AR when changed dynamically
+ DVD_VideoAttributes VATR;
+ if (GetPlaybackMode() == PM_DVD && SUCCEEDED(pDVDI->GetCurrentVideoAttributes(&VATR))) {
+ arxy.SetSize(VATR.ulAspectX, VATR.ulAspectY);
+ }
- CPath path(m_wndPlaylistBar.GetCurFileName());
- path.StripPath();
- CStringW fn = (LPCTSTR)path;
+ video = (arxy.cx <= 0 || arxy.cy <= 0) ? wh : CSize(MulDiv(wh.cy, arxy.cx, arxy.cy), wh.cy);
- CStringW fs;
- WIN32_FIND_DATA wfd;
- HANDLE hFind = FindFirstFile(m_wndPlaylistBar.GetCurFileName(), &wfd);
- if (hFind != INVALID_HANDLE_VALUE) {
- FindClose(hFind);
+ //
- __int64 size = (__int64(wfd.nFileSizeHigh)<<32)|wfd.nFileSizeLow;
- const int MAX_FILE_SIZE_BUFFER = 65;
- WCHAR szFileSize[MAX_FILE_SIZE_BUFFER];
- StrFormatByteSizeW(size, szFileSize, MAX_FILE_SIZE_BUFFER);
- fs.Format(IDS_MAINFRM_58, szFileSize, size);
- }
+ AppSettings& s = AfxGetAppSettings();
- CStringW ar;
- if (arxy.cx > 0 && arxy.cy > 0 && arxy.cx != wh.cx && arxy.cy != wh.cy) {
- ar.Format(L"(%d:%d)", arxy.cx, arxy.cy);
- }
+ int cols = max(1, min(10, s.iThumbCols)), rows = max(1, min(20, s.iThumbRows));
- str.Format(IDS_MAINFRM_59,
- fn, fs, wh.cx, wh.cy, ar, hmsf.bHours, hmsf.bMinutes, hmsf.bSeconds);
- rts.Add(str, true, 0, 1, _T("thumbs"));
+ int margin = 5;
+ int infoheight = 70;
+ int width = max(256, min(2560, s.iThumbWidth));
+ int height = width * video.cy / video.cx * rows / cols + infoheight;
- rts.Render(spd, 0, 25, bbox);
- }
+ int dibsize = sizeof(BITMAPINFOHEADER) + width * height * 4;
- SaveDIB(fn, (BYTE*)dib, dibsize);
+ CAutoVectorPtr<BYTE> dib;
+ if (!dib.Allocate(dibsize)) {
+ AfxMessageBox(IDS_MAINFRM_56, MB_ICONWARNING | MB_OK, 0);
+ return;
+ }
+
+ BITMAPINFOHEADER* bih = (BITMAPINFOHEADER*)(BYTE*)dib;
+ memset(bih, 0, sizeof(BITMAPINFOHEADER));
+ bih->biSize = sizeof(BITMAPINFOHEADER);
+ bih->biWidth = width;
+ bih->biHeight = height;
+ bih->biPlanes = 1;
+ bih->biBitCount = 32;
+ bih->biCompression = BI_RGB;
+ bih->biSizeImage = width * height * 4;
+ memsetd(bih + 1, 0xffffff, bih->biSizeImage);
+
+ SubPicDesc spd;
+ spd.w = width;
+ spd.h = height;
+ spd.bpp = 32;
+ spd.pitch = -width * 4;
+ spd.vidrect = CRect(0, 0, width, height);
+ spd.bits = (BYTE*)(bih + 1) + (width * 4) * (height - 1);
+
+ {
+ BYTE* p = (BYTE*)spd.bits;
+ for (int y = 0; y < spd.h; y++, p += spd.pitch)
+ for (int x = 0; x < spd.w; x++) {
+ ((DWORD*)p)[x] = 0x010101 * (0xe0 + 0x08 * y / spd.h + 0x18 * (spd.w - x) / spd.w);
+ }
+ }
- SeekTo(rtPos);
+ CCritSec csSubLock;
+ RECT bbox;
+
+ for (int i = 1, pics = cols * rows; i <= pics; i++) {
+ REFERENCE_TIME rt = rtDur * i / (pics + 1);
+ DVD_HMSF_TIMECODE hmsf = RT2HMS_r(rt);
+
+ SeekTo(rt);
+
+ m_VolumeBeforeFrameStepping = m_wndToolBar.Volume;
+ pBA->put_Volume(-10000);
+
+ HRESULT hr = pFS ? pFS->Step(1, NULL) : E_FAIL;
+
+ if (FAILED(hr)) {
+ pBA->put_Volume(m_VolumeBeforeFrameStepping);
+ AfxMessageBox(IDS_FRAME_STEP_ERROR_RENDERER, MB_ICONEXCLAMATION | MB_OK, 0);
+ return;
+ }
+
+ HANDLE hGraphEvent = NULL;
+ pME->GetEventHandle((OAEVENT*)&hGraphEvent);
+
+ while (hGraphEvent && WaitForSingleObject(hGraphEvent, INFINITE) == WAIT_OBJECT_0) {
+ LONG evCode = 0;
+ LONG_PTR evParam1, evParam2;
+ while (pME && SUCCEEDED(pME->GetEvent(&evCode, &evParam1, &evParam2, 0))) {
+ pME->FreeEventParams(evCode, evParam1, evParam2);
+ if (EC_STEP_COMPLETE == evCode) {
+ hGraphEvent = NULL;
+ }
+ }
+ }
+
+ pBA->put_Volume(m_VolumeBeforeFrameStepping);
+
+ int col = (i - 1) % cols;
+ int row = (i - 1) / cols;
+
+ CSize s((width - margin * 2) / cols, (height - margin * 2 - infoheight) / rows);
+ CPoint p(margin + col * s.cx, margin + row * s.cy + infoheight);
+ CRect r(p, s);
+ r.DeflateRect(margin, margin);
+
+ CRenderedTextSubtitle rts(&csSubLock);
+ rts.CreateDefaultStyle(0);
+ rts.m_dstScreenSize.SetSize(width, height);
+ STSStyle* style = DNew STSStyle();
+ style->marginRect.SetRectEmpty();
+ rts.AddStyle(_T("thumbs"), style);
+
+ CStringW str;
+ str.Format(L"{\\an7\\1c&Hffffff&\\4a&Hb0&\\bord1\\shad4\\be1}{\\p1}m %d %d l %d %d %d %d %d %d{\\p}",
+ r.left, r.top, r.right, r.top, r.right, r.bottom, r.left, r.bottom);
+ rts.Add(str, true, 0, 1, _T("thumbs"));
+ str.Format(L"{\\an3\\1c&Hffffff&\\3c&H000000&\\alpha&H80&\\fs16\\b1\\bord2\\shad0\\pos(%d,%d)}%02d:%02d:%02d",
+ r.right - 5, r.bottom - 3, hmsf.bHours, hmsf.bMinutes, hmsf.bSeconds);
+ rts.Add(str, true, 1, 2, _T("thumbs"));
+
+ rts.Render(spd, 0, 25, bbox);
+
+ BYTE* pData = NULL;
+ long size = 0;
+ if (!GetDIB(&pData, size)) {
+ return;
+ }
+
+ BITMAPINFO* bi = (BITMAPINFO*)pData;
+
+ if (bi->bmiHeader.biBitCount != 32) {
+ delete [] pData;
+ CString str;
+ str.Format(IDS_MAINFRM_57, bi->bmiHeader.biBitCount);
+ AfxMessageBox(str);
+ return;
+ }
+
+ int sw = bi->bmiHeader.biWidth;
+ int sh = abs(bi->bmiHeader.biHeight);
+ int sp = sw * 4;
+ const BYTE* src = pData + sizeof(bi->bmiHeader);
+ if (bi->bmiHeader.biHeight >= 0) {
+ src += sp * (sh - 1);
+ sp = -sp;
+ }
+
+ int dp = spd.pitch;
+ BYTE* dst = (BYTE*)spd.bits + spd.pitch * r.top + r.left * 4;
+
+ for (DWORD h = r.bottom - r.top, y = 0, yd = (sh << 8) / h; h > 0; y += yd, h--) {
+ DWORD yf = y & 0xff;
+ DWORD yi = y >> 8;
+
+ DWORD* s0 = (DWORD*)(src + (int)yi * sp);
+ DWORD* s1 = (DWORD*)(src + (int)yi * sp + sp);
+ DWORD* d = (DWORD*)dst;
+
+ for (DWORD w = r.right - r.left, x = 0, xd = (sw << 8) / w; w > 0; x += xd, w--) {
+ DWORD xf = x & 0xff;
+ DWORD xi = x >> 8;
+
+ DWORD c0 = s0[xi];
+ DWORD c1 = s0[xi + 1];
+ DWORD c2 = s1[xi];
+ DWORD c3 = s1[xi + 1];
+
+ c0 = ((c0 & 0xff00ff) + ((((c1 & 0xff00ff) - (c0 & 0xff00ff)) * xf) >> 8)) & 0xff00ff
+ | ((c0 & 0x00ff00) + ((((c1 & 0x00ff00) - (c0 & 0x00ff00)) * xf) >> 8)) & 0x00ff00;
+
+ c2 = ((c2 & 0xff00ff) + ((((c3 & 0xff00ff) - (c2 & 0xff00ff)) * xf) >> 8)) & 0xff00ff
+ | ((c2 & 0x00ff00) + ((((c3 & 0x00ff00) - (c2 & 0x00ff00)) * xf) >> 8)) & 0x00ff00;
+
+ c0 = ((c0 & 0xff00ff) + ((((c2 & 0xff00ff) - (c0 & 0xff00ff)) * yf) >> 8)) & 0xff00ff
+ | ((c0 & 0x00ff00) + ((((c2 & 0x00ff00) - (c0 & 0x00ff00)) * yf) >> 8)) & 0x00ff00;
+
+ *d++ = c0;
+ }
+
+ dst += dp;
+ }
+
+ rts.Render(spd, 10000, 25, bbox);
+
+ delete [] pData;
+ }
- m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_OSD_THUMBS_SAVED), 3000);
+ {
+ CRenderedTextSubtitle rts(&csSubLock);
+ rts.CreateDefaultStyle(0);
+ rts.m_dstScreenSize.SetSize(width, height);
+ STSStyle* style = DNew STSStyle();
+ style->marginRect.SetRect(margin * 2, margin * 2, margin * 2, height - infoheight - margin);
+ rts.AddStyle(_T("thumbs"), style);
+
+ CStringW str;
+ str.Format(L"{\\an9\\fs%d\\b1\\bord0\\shad0\\1c&Hffffff&}%s", infoheight - 10, width >= 550 ? L"Media Player Classic" : L"MPC");
+
+ rts.Add(str, true, 0, 1, _T("thumbs"), _T(""), _T(""), CRect(0, 0, 0, 0), -1);
+
+ DVD_HMSF_TIMECODE hmsf = RT2HMS_r(rtDur);
+
+ CPath path(m_wndPlaylistBar.GetCurFileName());
+ path.StripPath();
+ CStringW fn = (LPCTSTR)path;
+
+ CStringW fs;
+ WIN32_FIND_DATA wfd;
+ HANDLE hFind = FindFirstFile(m_wndPlaylistBar.GetCurFileName(), &wfd);
+ if (hFind != INVALID_HANDLE_VALUE) {
+ FindClose(hFind);
+
+ __int64 size = (__int64(wfd.nFileSizeHigh) << 32) | wfd.nFileSizeLow;
+ const int MAX_FILE_SIZE_BUFFER = 65;
+ WCHAR szFileSize[MAX_FILE_SIZE_BUFFER];
+ StrFormatByteSizeW(size, szFileSize, MAX_FILE_SIZE_BUFFER);
+ fs.Format(IDS_MAINFRM_58, szFileSize, size);
+ }
+
+ CStringW ar;
+ if (arxy.cx > 0 && arxy.cy > 0 && arxy.cx != wh.cx && arxy.cy != wh.cy) {
+ ar.Format(L"(%d:%d)", arxy.cx, arxy.cy);
+ }
+
+ str.Format(IDS_MAINFRM_59,
+ fn, fs, wh.cx, wh.cy, ar, hmsf.bHours, hmsf.bMinutes, hmsf.bSeconds);
+ rts.Add(str, true, 0, 1, _T("thumbs"));
+
+ rts.Render(spd, 0, 25, bbox);
+ }
+
+ SaveDIB(fn, (BYTE*)dib, dibsize);
+
+ SeekTo(rtPos);
+
+ m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_OSD_THUMBS_SAVED), 3000);
}
static CString MakeSnapshotFileName(LPCTSTR prefix)
{
- CTime t = CTime::GetCurrentTime();
- CString fn;
- fn.Format(_T("%s_[%s]%s"), prefix, t.Format(_T("%Y.%m.%d_%H.%M.%S")), AfxGetAppSettings().strSnapShotExt);
- return fn;
+ CTime t = CTime::GetCurrentTime();
+ CString fn;
+ fn.Format(_T("%s_[%s]%s"), prefix, t.Format(_T("%Y.%m.%d_%H.%M.%S")), AfxGetAppSettings().strSnapShotExt);
+ return fn;
}
BOOL CMainFrame::IsRendererCompatibleWithSaveImage()
{
- BOOL result = TRUE;
- AppSettings& s = AfxGetAppSettings();
-
- if (m_fRealMediaGraph && (s.iRMVideoRendererType == VIDRNDT_RM_DEFAULT)) {
- AfxMessageBox(IDS_SCREENSHOT_ERROR_REAL, MB_ICONEXCLAMATION | MB_OK, 0);
- result = FALSE;
- } else if (m_fQuicktimeGraph && (s.iQTVideoRendererType == VIDRNDT_QT_DEFAULT)) {
- AfxMessageBox(IDS_SCREENSHOT_ERROR_QT, MB_ICONEXCLAMATION | MB_OK, 0);
- result = FALSE;
- } else if (m_fShockwaveGraph) {
- AfxMessageBox(IDS_SCREENSHOT_ERROR_SHOCKWAVE, MB_ICONEXCLAMATION | MB_OK, 0);
- result = FALSE;
- } else if (s.iDSVideoRendererType == VIDRNDT_DS_OVERLAYMIXER) {
- AfxMessageBox(IDS_SCREENSHOT_ERROR_OVERLAY, MB_ICONEXCLAMATION | MB_OK, 0);
- result = FALSE;
- } else if (s.iDSVideoRendererType == VIDRNDT_DS_MADVR) {
- AfxMessageBox(IDS_SCREENSHOT_ERROR_MADVR, MB_ICONEXCLAMATION | MB_OK, 0);
- result = FALSE;
- }
-
- return result;
+ BOOL result = TRUE;
+ AppSettings& s = AfxGetAppSettings();
+
+ if (m_fRealMediaGraph && (s.iRMVideoRendererType == VIDRNDT_RM_DEFAULT)) {
+ AfxMessageBox(IDS_SCREENSHOT_ERROR_REAL, MB_ICONEXCLAMATION | MB_OK, 0);
+ result = FALSE;
+ } else if (m_fQuicktimeGraph && (s.iQTVideoRendererType == VIDRNDT_QT_DEFAULT)) {
+ AfxMessageBox(IDS_SCREENSHOT_ERROR_QT, MB_ICONEXCLAMATION | MB_OK, 0);
+ result = FALSE;
+ } else if (m_fShockwaveGraph) {
+ AfxMessageBox(IDS_SCREENSHOT_ERROR_SHOCKWAVE, MB_ICONEXCLAMATION | MB_OK, 0);
+ result = FALSE;
+ } else if (s.iDSVideoRendererType == VIDRNDT_DS_OVERLAYMIXER) {
+ AfxMessageBox(IDS_SCREENSHOT_ERROR_OVERLAY, MB_ICONEXCLAMATION | MB_OK, 0);
+ result = FALSE;
+ } else if (s.iDSVideoRendererType == VIDRNDT_DS_MADVR) {
+ AfxMessageBox(IDS_SCREENSHOT_ERROR_MADVR, MB_ICONEXCLAMATION | MB_OK, 0);
+ result = FALSE;
+ }
+
+ return result;
}
CString CMainFrame::GetVidPos() const
{
- CString posstr = _T("");
- if ((GetPlaybackMode() == PM_FILE) || (GetPlaybackMode() == PM_DVD)) {
- __int64 start, stop, pos;
- m_wndSeekBar.GetRange(start, stop);
- pos = m_wndSeekBar.GetPosReal();
+ CString posstr = _T("");
+ if ((GetPlaybackMode() == PM_FILE) || (GetPlaybackMode() == PM_DVD)) {
+ __int64 start, stop, pos;
+ m_wndSeekBar.GetRange(start, stop);
+ pos = m_wndSeekBar.GetPosReal();
- DVD_HMSF_TIMECODE tcNow = RT2HMSF(pos);
- DVD_HMSF_TIMECODE tcDur = RT2HMSF(stop);
+ DVD_HMSF_TIMECODE tcNow = RT2HMSF(pos);
+ DVD_HMSF_TIMECODE tcDur = RT2HMSF(stop);
- if (tcDur.bHours > 0 || (pos >= stop && tcNow.bHours > 0)) {
- posstr.Format(_T("%02d.%02d.%02d"), tcNow.bHours, tcNow.bMinutes, tcNow.bSeconds);
- } else {
- posstr.Format(_T("%02d.%02d"), tcNow.bMinutes, tcNow.bSeconds);
- }
- }
+ if (tcDur.bHours > 0 || (pos >= stop && tcNow.bHours > 0)) {
+ posstr.Format(_T("%02d.%02d.%02d"), tcNow.bHours, tcNow.bMinutes, tcNow.bSeconds);
+ } else {
+ posstr.Format(_T("%02d.%02d"), tcNow.bMinutes, tcNow.bSeconds);
+ }
+ }
- return posstr;
+ return posstr;
}
void CMainFrame::OnFileSaveImage()
{
- AppSettings& s = AfxGetAppSettings();
-
- /* Check if a compatible renderer is being used */
- if (!IsRendererCompatibleWithSaveImage()) {
- return;
- }
-
- CPath psrc(s.strSnapShotPath);
-
- CStringW prefix = _T("snapshot");
- if (GetPlaybackMode() == PM_FILE) {
- CPath path(m_wndPlaylistBar.GetCurFileName());
- path.StripPath();
- prefix.Format(_T("%s_snapshot_%s"), path, GetVidPos());
- } else if (GetPlaybackMode() == PM_DVD) {
- prefix.Format(_T("snapshot_dvd_%s"), GetVidPos());
- }
- psrc.Combine(s.strSnapShotPath, MakeSnapshotFileName(prefix));
-
- CFileDialog fd(FALSE, 0, (LPCTSTR)psrc,
- OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST|OFN_NOCHANGEDIR,
- _T("BMP - Windows Bitmap (*.bmp)|*.bmp|JPG - JPEG Image (*.jpg)|*.jpg|PNG - Portable Network Graphics (*.png)|*.png||"), GetModalParent(), 0);
-
- if (s.strSnapShotExt == _T(".bmp")) {
- fd.m_pOFN->nFilterIndex = 1;
- } else if (s.strSnapShotExt == _T(".jpg")) {
- fd.m_pOFN->nFilterIndex = 2;
- } else if (s.strSnapShotExt == _T(".png")) {
- fd.m_pOFN->nFilterIndex = 3;
- }
-
- if (fd.DoModal() != IDOK) {
- return;
- }
-
- if (fd.m_pOFN->nFilterIndex == 1) {
- s.strSnapShotExt = _T(".bmp");
- } else if (fd.m_pOFN->nFilterIndex == 2) {
- s.strSnapShotExt = _T(".jpg");
- } else {
- fd.m_pOFN->nFilterIndex = 3;
- s.strSnapShotExt = _T(".png");
- }
-
- CPath pdst(fd.GetPathName());
- if (pdst.GetExtension().MakeLower() != s.strSnapShotExt) {
- pdst.RenameExtension(s.strSnapShotExt);
- }
- CString path = (LPCTSTR)pdst;
- pdst.RemoveFileSpec();
- s.strSnapShotPath = (LPCTSTR)pdst;
-
- SaveImage(path);
+ AppSettings& s = AfxGetAppSettings();
+
+ /* Check if a compatible renderer is being used */
+ if (!IsRendererCompatibleWithSaveImage()) {
+ return;
+ }
+
+ CPath psrc(s.strSnapShotPath);
+
+ CStringW prefix = _T("snapshot");
+ if (GetPlaybackMode() == PM_FILE) {
+ CPath path(m_wndPlaylistBar.GetCurFileName());
+ path.StripPath();
+ prefix.Format(_T("%s_snapshot_%s"), path, GetVidPos());
+ } else if (GetPlaybackMode() == PM_DVD) {
+ prefix.Format(_T("snapshot_dvd_%s"), GetVidPos());
+ }
+ psrc.Combine(s.strSnapShotPath, MakeSnapshotFileName(prefix));
+
+ CFileDialog fd(FALSE, 0, (LPCTSTR)psrc,
+ OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR,
+ _T("BMP - Windows Bitmap (*.bmp)|*.bmp|JPG - JPEG Image (*.jpg)|*.jpg|PNG - Portable Network Graphics (*.png)|*.png||"), GetModalParent(), 0);
+
+ if (s.strSnapShotExt == _T(".bmp")) {
+ fd.m_pOFN->nFilterIndex = 1;
+ } else if (s.strSnapShotExt == _T(".jpg")) {
+ fd.m_pOFN->nFilterIndex = 2;
+ } else if (s.strSnapShotExt == _T(".png")) {
+ fd.m_pOFN->nFilterIndex = 3;
+ }
+
+ if (fd.DoModal() != IDOK) {
+ return;
+ }
+
+ if (fd.m_pOFN->nFilterIndex == 1) {
+ s.strSnapShotExt = _T(".bmp");
+ } else if (fd.m_pOFN->nFilterIndex == 2) {
+ s.strSnapShotExt = _T(".jpg");
+ } else {
+ fd.m_pOFN->nFilterIndex = 3;
+ s.strSnapShotExt = _T(".png");
+ }
+
+ CPath pdst(fd.GetPathName());
+ if (pdst.GetExtension().MakeLower() != s.strSnapShotExt) {
+ pdst.RenameExtension(s.strSnapShotExt);
+ }
+ CString path = (LPCTSTR)pdst;
+ pdst.RemoveFileSpec();
+ s.strSnapShotPath = (LPCTSTR)pdst;
+
+ SaveImage(path);
}
void CMainFrame::OnFileSaveImageAuto()
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- /* Check if a compatible renderer is being used */
- if (!IsRendererCompatibleWithSaveImage()) {
- return;
- }
+ /* Check if a compatible renderer is being used */
+ if (!IsRendererCompatibleWithSaveImage()) {
+ return;
+ }
- CStringW prefix = _T("snapshot");
- if (GetPlaybackMode() == PM_FILE) {
- CPath path(m_wndPlaylistBar.GetCurFileName());
- path.StripPath();
- prefix.Format(_T("%s_snapshot_%s"), path, GetVidPos());
- } else if (GetPlaybackMode() == PM_DVD) {
- prefix.Format(_T("snapshot_dvd_%s"), GetVidPos());
- }
+ CStringW prefix = _T("snapshot");
+ if (GetPlaybackMode() == PM_FILE) {
+ CPath path(m_wndPlaylistBar.GetCurFileName());
+ path.StripPath();
+ prefix.Format(_T("%s_snapshot_%s"), path, GetVidPos());
+ } else if (GetPlaybackMode() == PM_DVD) {
+ prefix.Format(_T("snapshot_dvd_%s"), GetVidPos());
+ }
- CString fn;
- fn.Format(_T("%s\\%s"), s.strSnapShotPath, MakeSnapshotFileName(prefix));
- SaveImage(fn);
+ CString fn;
+ fn.Format(_T("%s\\%s"), s.strSnapShotPath, MakeSnapshotFileName(prefix));
+ SaveImage(fn);
}
void CMainFrame::OnUpdateFileSaveImage(CCmdUI* pCmdUI)
{
- OAFilterState fs = GetMediaState();
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly && (fs == State_Paused || fs == State_Running));
+ OAFilterState fs = GetMediaState();
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly && (fs == State_Paused || fs == State_Running));
}
void CMainFrame::OnFileSaveThumbnails()
{
- AppSettings& s = AfxGetAppSettings();
-
- /* Check if a compatible renderer is being used */
- if (!IsRendererCompatibleWithSaveImage()) {
- return;
- }
-
- CPath psrc(s.strSnapShotPath);
- CStringW prefix = _T("thumbs");
- if (GetPlaybackMode() == PM_FILE) {
- CPath path(m_wndPlaylistBar.GetCurFileName());
- path.StripPath();
- prefix.Format(_T("%s_thumbs"), path);
- }
- psrc.Combine(s.strSnapShotPath, MakeSnapshotFileName(prefix));
-
- CSaveThumbnailsDialog fd(
- s.iThumbRows, s.iThumbCols, s.iThumbWidth,
- 0, (LPCTSTR)psrc,
- _T("BMP - Windows Bitmap (*.bmp)|*.bmp|JPG - JPEG Image (*.jpg)|*.jpg|PNG - Portable Network Graphics (*.png)|*.png||"), GetModalParent());
-
- if (s.strSnapShotExt == _T(".bmp")) {
- fd.m_pOFN->nFilterIndex = 1;
- } else if (s.strSnapShotExt == _T(".jpg")) {
- fd.m_pOFN->nFilterIndex = 2;
- } else if (s.strSnapShotExt == _T(".png")) {
- fd.m_pOFN->nFilterIndex = 3;
- }
-
- if (fd.DoModal() != IDOK) {
- return;
- }
-
- if (fd.m_pOFN->nFilterIndex == 1) {
- s.strSnapShotExt = _T(".bmp");
- } else if (fd.m_pOFN->nFilterIndex == 2) {
- s.strSnapShotExt = _T(".jpg");
- } else {
- fd.m_pOFN->nFilterIndex = 3;
- s.strSnapShotExt = _T(".png");
- }
-
- s.iThumbRows = fd.m_rows;
- s.iThumbCols = fd.m_cols;
- s.iThumbWidth = fd.m_width;
-
- CPath pdst(fd.GetPathName());
- if (pdst.GetExtension().MakeLower() != s.strSnapShotExt) {
- pdst.RenameExtension(s.strSnapShotExt);
- }
- CString path = (LPCTSTR)pdst;
- pdst.RemoveFileSpec();
- s.strSnapShotPath = (LPCTSTR)pdst;
-
- SaveThumbnails(path);
+ AppSettings& s = AfxGetAppSettings();
+
+ /* Check if a compatible renderer is being used */
+ if (!IsRendererCompatibleWithSaveImage()) {
+ return;
+ }
+
+ CPath psrc(s.strSnapShotPath);
+ CStringW prefix = _T("thumbs");
+ if (GetPlaybackMode() == PM_FILE) {
+ CPath path(m_wndPlaylistBar.GetCurFileName());
+ path.StripPath();
+ prefix.Format(_T("%s_thumbs"), path);
+ }
+ psrc.Combine(s.strSnapShotPath, MakeSnapshotFileName(prefix));
+
+ CSaveThumbnailsDialog fd(
+ s.iThumbRows, s.iThumbCols, s.iThumbWidth,
+ 0, (LPCTSTR)psrc,
+ _T("BMP - Windows Bitmap (*.bmp)|*.bmp|JPG - JPEG Image (*.jpg)|*.jpg|PNG - Portable Network Graphics (*.png)|*.png||"), GetModalParent());
+
+ if (s.strSnapShotExt == _T(".bmp")) {
+ fd.m_pOFN->nFilterIndex = 1;
+ } else if (s.strSnapShotExt == _T(".jpg")) {
+ fd.m_pOFN->nFilterIndex = 2;
+ } else if (s.strSnapShotExt == _T(".png")) {
+ fd.m_pOFN->nFilterIndex = 3;
+ }
+
+ if (fd.DoModal() != IDOK) {
+ return;
+ }
+
+ if (fd.m_pOFN->nFilterIndex == 1) {
+ s.strSnapShotExt = _T(".bmp");
+ } else if (fd.m_pOFN->nFilterIndex == 2) {
+ s.strSnapShotExt = _T(".jpg");
+ } else {
+ fd.m_pOFN->nFilterIndex = 3;
+ s.strSnapShotExt = _T(".png");
+ }
+
+ s.iThumbRows = fd.m_rows;
+ s.iThumbCols = fd.m_cols;
+ s.iThumbWidth = fd.m_width;
+
+ CPath pdst(fd.GetPathName());
+ if (pdst.GetExtension().MakeLower() != s.strSnapShotExt) {
+ pdst.RenameExtension(s.strSnapShotExt);
+ }
+ CString path = (LPCTSTR)pdst;
+ pdst.RemoveFileSpec();
+ s.strSnapShotPath = (LPCTSTR)pdst;
+
+ SaveThumbnails(path);
}
void CMainFrame::OnUpdateFileSaveThumbnails(CCmdUI* pCmdUI)
{
- OAFilterState fs = GetMediaState();
- UNREFERENCED_PARAMETER(fs);
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly && (GetPlaybackMode() == PM_FILE /*|| GetPlaybackMode() == PM_DVD*/));
+ OAFilterState fs = GetMediaState();
+ UNREFERENCED_PARAMETER(fs);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly && (GetPlaybackMode() == PM_FILE /*|| GetPlaybackMode() == PM_DVD*/));
}
void CMainFrame::OnFileLoadsubtitle()
{
- if (!m_pCAP) {
- AfxMessageBox(IDS_MAINFRM_60, MB_ICONINFORMATION | MB_OK, 0);
- return;
- }
+ if (!m_pCAP) {
+ AfxMessageBox(IDS_MAINFRM_60, MB_ICONINFORMATION | MB_OK, 0);
+ return;
+ }
- static TCHAR szFilter[] =
- _T(".srt .sub .ssa .ass .smi .psb .txt .idx .usf .xss|")
- _T("*.srt;*.sub;*.ssa;*.ass;*smi;*.psb;*.txt;*.idx;*.usf;*.xss||");
+ static TCHAR szFilter[] =
+ _T(".srt .sub .ssa .ass .smi .psb .txt .idx .usf .xss|")
+ _T("*.srt;*.sub;*.ssa;*.ass;*smi;*.psb;*.txt;*.idx;*.usf;*.xss||");
- CFileDialog fd(TRUE, NULL, NULL,
- OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY|OFN_NOCHANGEDIR,
- szFilter, GetModalParent(), 0);
+ CFileDialog fd(TRUE, NULL, NULL,
+ OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_NOCHANGEDIR,
+ szFilter, GetModalParent(), 0);
- if (fd.DoModal() != IDOK) {
- return;
- }
+ if (fd.DoModal() != IDOK) {
+ return;
+ }
- ISubStream *pSubStream = NULL;
- if (LoadSubtitle(fd.GetPathName(), &pSubStream)) {
- SetSubtitle(pSubStream); // the subtitle at the insert position according to LoadSubtitle()
- }
+ ISubStream* pSubStream = NULL;
+ if (LoadSubtitle(fd.GetPathName(), &pSubStream)) {
+ SetSubtitle(pSubStream); // the subtitle at the insert position according to LoadSubtitle()
+ }
}
-void CMainFrame::OnUpdateFileLoadsubtitle(CCmdUI *pCmdUI)
+void CMainFrame::OnUpdateFileLoadsubtitle(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && /*m_pCAP &&*/ !m_fAudioOnly);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && /*m_pCAP &&*/ !m_fAudioOnly);
}
void CMainFrame::OnFileSavesubtitle()
{
- int i = m_iSubtitleSel;
-
- POSITION pos = m_pSubStreams.GetHeadPosition();
- while (pos && i >= 0) {
- CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
-
- if (i < pSubStream->GetStreamCount()) {
- CLSID clsid;
- if (FAILED(pSubStream->GetClassID(&clsid))) {
- continue;
- }
-
- OpenMediaData *pOMD = m_wndPlaylistBar.GetCurOMD();
- CString suggestedFileName("");
- if (OpenFileData* p = dynamic_cast<OpenFileData*>(pOMD)) {
- // HACK: get the file name from the current playlist item
- suggestedFileName = m_wndPlaylistBar.GetCurFileName();
- suggestedFileName = suggestedFileName.Left(suggestedFileName.ReverseFind('.')); // exclude the extension, it will be auto completed
- }
-
- if (clsid == __uuidof(CVobSubFile)) {
- CVobSubFile* pVSF = (CVobSubFile*)(ISubStream*)pSubStream;
-
- // remember to set lpszDefExt to the first extension in the filter so that the save dialog autocompletes the extension
- // and tracks attempts to overwrite in a graceful manner
- CFileDialog fd(FALSE, _T("idx"), suggestedFileName,
- OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST|OFN_NOCHANGEDIR,
- _T("VobSub (*.idx, *.sub)|*.idx;*.sub||"), GetModalParent(), 0);
-
- if (fd.DoModal() == IDOK) {
- CAutoLock cAutoLock(&m_csSubLock);
- pVSF->Save(fd.GetPathName());
- }
-
- return;
- } else if (clsid == __uuidof(CRenderedTextSubtitle)) {
- CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)pSubStream;
-
- CString filter;
- // WATCH the order in GFN.h for exttype
- filter += _T("SubRip (*.srt)|*.srt|");
- filter += _T("MicroDVD (*.sub)|*.sub|");
- filter += _T("SAMI (*.smi)|*.smi|");
- filter += _T("PowerDivX (*.psb)|*.psb|");
- filter += _T("SubStation Alpha (*.ssa)|*.ssa|");
- filter += _T("Advanced SubStation Alpha (*.ass)|*.ass|");
- filter += _T("|");
-
- // same thing as in the case of CVobSubFile above for lpszDefExt
- CSaveTextFileDialog fd(pRTS->m_encoding, _T("srt"), suggestedFileName, filter, GetModalParent());
-
- if (fd.DoModal() == IDOK) {
- CAutoLock cAutoLock(&m_csSubLock);
- pRTS->SaveAs(fd.GetPathName(), (exttype)(fd.m_ofn.nFilterIndex-1), m_pCAP->GetFPS(), fd.GetEncoding());
- }
-
- return;
- }
- }
-
- i -= pSubStream->GetStreamCount();
- }
+ int i = m_iSubtitleSel;
+
+ POSITION pos = m_pSubStreams.GetHeadPosition();
+ while (pos && i >= 0) {
+ CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
+
+ if (i < pSubStream->GetStreamCount()) {
+ CLSID clsid;
+ if (FAILED(pSubStream->GetClassID(&clsid))) {
+ continue;
+ }
+
+ OpenMediaData* pOMD = m_wndPlaylistBar.GetCurOMD();
+ CString suggestedFileName("");
+ if (OpenFileData* p = dynamic_cast<OpenFileData*>(pOMD)) {
+ // HACK: get the file name from the current playlist item
+ suggestedFileName = m_wndPlaylistBar.GetCurFileName();
+ suggestedFileName = suggestedFileName.Left(suggestedFileName.ReverseFind('.')); // exclude the extension, it will be auto completed
+ }
+
+ if (clsid == __uuidof(CVobSubFile)) {
+ CVobSubFile* pVSF = (CVobSubFile*)(ISubStream*)pSubStream;
+
+ // remember to set lpszDefExt to the first extension in the filter so that the save dialog autocompletes the extension
+ // and tracks attempts to overwrite in a graceful manner
+ CFileDialog fd(FALSE, _T("idx"), suggestedFileName,
+ OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR,
+ _T("VobSub (*.idx, *.sub)|*.idx;*.sub||"), GetModalParent(), 0);
+
+ if (fd.DoModal() == IDOK) {
+ CAutoLock cAutoLock(&m_csSubLock);
+ pVSF->Save(fd.GetPathName());
+ }
+
+ return;
+ } else if (clsid == __uuidof(CRenderedTextSubtitle)) {
+ CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)pSubStream;
+
+ CString filter;
+ // WATCH the order in GFN.h for exttype
+ filter += _T("SubRip (*.srt)|*.srt|");
+ filter += _T("MicroDVD (*.sub)|*.sub|");
+ filter += _T("SAMI (*.smi)|*.smi|");
+ filter += _T("PowerDivX (*.psb)|*.psb|");
+ filter += _T("SubStation Alpha (*.ssa)|*.ssa|");
+ filter += _T("Advanced SubStation Alpha (*.ass)|*.ass|");
+ filter += _T("|");
+
+ // same thing as in the case of CVobSubFile above for lpszDefExt
+ CSaveTextFileDialog fd(pRTS->m_encoding, _T("srt"), suggestedFileName, filter, GetModalParent());
+
+ if (fd.DoModal() == IDOK) {
+ CAutoLock cAutoLock(&m_csSubLock);
+ pRTS->SaveAs(fd.GetPathName(), (exttype)(fd.m_ofn.nFilterIndex - 1), m_pCAP->GetFPS(), fd.GetEncoding());
+ }
+
+ return;
+ }
+ }
+
+ i -= pSubStream->GetStreamCount();
+ }
}
void CMainFrame::OnUpdateFileSavesubtitle(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iSubtitleSel >= 0);
+ pCmdUI->Enable(m_iSubtitleSel >= 0);
}
void CMainFrame::OnFileISDBSearch()
{
- CStringA url = "http://" + AfxGetAppSettings().strISDb + "/index.php?";
- CStringA args = makeargs(m_wndPlaylistBar.m_pl);
- ShellExecute(m_hWnd, _T("open"), CString(url+args), NULL, NULL, SW_SHOWDEFAULT);
+ CStringA url = "http://" + AfxGetAppSettings().strISDb + "/index.php?";
+ CStringA args = makeargs(m_wndPlaylistBar.m_pl);
+ ShellExecute(m_hWnd, _T("open"), CString(url + args), NULL, NULL, SW_SHOWDEFAULT);
}
-void CMainFrame::OnUpdateFileISDBSearch(CCmdUI *pCmdUI)
+void CMainFrame::OnUpdateFileISDBSearch(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(TRUE);
+ pCmdUI->Enable(TRUE);
}
void CMainFrame::OnFileISDBUpload()
{
- CStringA url = "http://" + AfxGetAppSettings().strISDb + "/ul.php?";
- CStringA args = makeargs(m_wndPlaylistBar.m_pl);
- ShellExecute(m_hWnd, _T("open"), CString(url+args), NULL, NULL, SW_SHOWDEFAULT);
+ CStringA url = "http://" + AfxGetAppSettings().strISDb + "/ul.php?";
+ CStringA args = makeargs(m_wndPlaylistBar.m_pl);
+ ShellExecute(m_hWnd, _T("open"), CString(url + args), NULL, NULL, SW_SHOWDEFAULT);
}
-void CMainFrame::OnUpdateFileISDBUpload(CCmdUI *pCmdUI)
+void CMainFrame::OnUpdateFileISDBUpload(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_wndPlaylistBar.GetCount() > 0);
+ pCmdUI->Enable(m_wndPlaylistBar.GetCount() > 0);
}
void CMainFrame::OnFileISDBDownload()
{
- AppSettings& s = AfxGetAppSettings();
- filehash fh;
- if (!::mpc_filehash((CString)m_wndPlaylistBar.GetCurFileName(), fh)) {
- MessageBeep((UINT)-1);
- return;
- }
-
- try {
- CStringA url = "http://" + s.strISDb + "/index.php?";
- CStringA args;
- args.Format("player=mpc&name[0]=%s&size[0]=%016I64x&hash[0]=%016I64x",
- UrlEncode(CStringA(fh.name)), fh.size, fh.mpc_filehash);
- url.Append(args);
+ AppSettings& s = AfxGetAppSettings();
+ filehash fh;
+ if (!::mpc_filehash((CString)m_wndPlaylistBar.GetCurFileName(), fh)) {
+ MessageBeep((UINT) - 1);
+ return;
+ }
- CSubtitleDlDlg dlg(GetModalParent(), url);
- dlg.DoModal();
- } catch (CInternetException* ie) {
- ie->Delete();
- return;
- }
+ try {
+ CStringA url = "http://" + s.strISDb + "/index.php?";
+ CStringA args;
+ args.Format("player=mpc&name[0]=%s&size[0]=%016I64x&hash[0]=%016I64x",
+ UrlEncode(CStringA(fh.name)), fh.size, fh.mpc_filehash);
+ url.Append(args);
+
+ CSubtitleDlDlg dlg(GetModalParent(), url);
+ dlg.DoModal();
+ } catch (CInternetException* ie) {
+ ie->Delete();
+ return;
+ }
}
-void CMainFrame::OnUpdateFileISDBDownload(CCmdUI *pCmdUI)
+void CMainFrame::OnUpdateFileISDBDownload(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && m_pCAP && !m_fAudioOnly);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && m_pCAP && !m_fAudioOnly);
}
void CMainFrame::OnFileProperties()
{
- CPPageFileInfoSheet m_fileinfo(m_wndPlaylistBar.GetCurFileName(), this, GetModalParent());
- m_fileinfo.DoModal();
+ CPPageFileInfoSheet m_fileinfo(m_wndPlaylistBar.GetCurFileName(), this, GetModalParent());
+ m_fileinfo.DoModal();
}
void CMainFrame::OnUpdateFileProperties(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && GetPlaybackMode() == PM_FILE);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && GetPlaybackMode() == PM_FILE);
}
void CMainFrame::OnFileCloseMedia()
{
- CloseMedia();
+ CloseMedia();
}
void CMainFrame::OnUpdateViewTearingTest(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
- pCmdUI->SetCheck(AfxGetMyApp()->m_Renderers.m_fTearingTest);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
+ pCmdUI->SetCheck(AfxGetMyApp()->m_Renderers.m_fTearingTest);
}
void CMainFrame::OnViewTearingTest()
{
- AfxGetMyApp()->m_Renderers.m_fTearingTest = !AfxGetMyApp()->m_Renderers.m_fTearingTest;
+ AfxGetMyApp()->m_Renderers.m_fTearingTest = !AfxGetMyApp()->m_Renderers.m_fTearingTest;
}
void CMainFrame::OnUpdateViewDisplayStats(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- CRenderersSettings& r = s.m_RenderersSettings;
- bool supported = (s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
- s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS ||
- s.iDSVideoRendererType == VIDRNDT_DS_SYNC) &&
- r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D;
+ AppSettings& s = AfxGetAppSettings();
+ CRenderersSettings& r = s.m_RenderersSettings;
+ bool supported = (s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
+ s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS ||
+ s.iDSVideoRendererType == VIDRNDT_DS_SYNC) &&
+ r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D;
- pCmdUI->Enable(supported && m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
- pCmdUI->SetCheck(supported && (AfxGetMyApp()->m_Renderers.m_fDisplayStats));
+ pCmdUI->Enable(supported && m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
+ pCmdUI->SetCheck(supported && (AfxGetMyApp()->m_Renderers.m_fDisplayStats));
}
void CMainFrame::OnViewResetStats()
{
- AfxGetMyApp()->m_Renderers.m_bResetStats = true; // Reset by "consumer"
+ AfxGetMyApp()->m_Renderers.m_bResetStats = true; // Reset by "consumer"
}
void CMainFrame::OnViewDisplayStatsSC()
{
- if (!AfxGetMyApp()->m_Renderers.m_fDisplayStats) {
- AfxGetMyApp()->m_Renderers.m_bResetStats = true; // to Reset statictics on first call ...
- }
+ if (!AfxGetMyApp()->m_Renderers.m_fDisplayStats) {
+ AfxGetMyApp()->m_Renderers.m_bResetStats = true; // to Reset statictics on first call ...
+ }
- ++AfxGetMyApp()->m_Renderers.m_fDisplayStats;
- if (AfxGetMyApp()->m_Renderers.m_fDisplayStats > 3) {
- AfxGetMyApp()->m_Renderers.m_fDisplayStats = 0;
- }
+ ++AfxGetMyApp()->m_Renderers.m_fDisplayStats;
+ if (AfxGetMyApp()->m_Renderers.m_fDisplayStats > 3) {
+ AfxGetMyApp()->m_Renderers.m_fDisplayStats = 0;
+ }
}
void CMainFrame::OnUpdateViewVSync(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- CRenderersSettings& r = s.m_RenderersSettings;
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
- s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
- r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
+ AppSettings& s = AfxGetAppSettings();
+ CRenderersSettings& r = s.m_RenderersSettings;
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
+ s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
+ r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
- pCmdUI->Enable (supported);
- pCmdUI->SetCheck (!supported || (r.m_RenderSettings.iVMR9VSync));
+ pCmdUI->Enable(supported);
+ pCmdUI->SetCheck(!supported || (r.m_RenderSettings.iVMR9VSync));
}
void CMainFrame::OnUpdateViewVSyncOffset(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- CRenderersSettings& r = s.m_RenderersSettings;
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
- s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
- r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) &&
- r.m_RenderSettings.fVMR9AlterativeVSync;
+ AppSettings& s = AfxGetAppSettings();
+ CRenderersSettings& r = s.m_RenderersSettings;
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
+ s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
+ r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) &&
+ r.m_RenderSettings.fVMR9AlterativeVSync;
- pCmdUI->Enable(supported);
- CString Temp;
- Temp.Format(L"%d", r.m_RenderSettings.iVMR9VSyncOffset);
- pCmdUI->SetText(Temp);
+ pCmdUI->Enable(supported);
+ CString Temp;
+ Temp.Format(L"%d", r.m_RenderSettings.iVMR9VSyncOffset);
+ pCmdUI->SetText(Temp);
}
void CMainFrame::OnUpdateViewVSyncAccurate(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- CRenderersSettings& r = s.m_RenderersSettings;
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
- s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
- r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
+ AppSettings& s = AfxGetAppSettings();
+ CRenderersSettings& r = s.m_RenderersSettings;
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
+ s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
+ r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
- pCmdUI->Enable (supported);
- pCmdUI->SetCheck(r.m_RenderSettings.iVMR9VSyncAccurate);
+ pCmdUI->Enable(supported);
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMR9VSyncAccurate);
}
void CMainFrame::OnUpdateViewSynchronizeVideo(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- CRenderersSettings& r = s.m_RenderersSettings;
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_SYNC) && GetPlaybackMode() == PM_NONE);
+ AppSettings& s = AfxGetAppSettings();
+ CRenderersSettings& r = s.m_RenderersSettings;
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_SYNC) && GetPlaybackMode() == PM_NONE);
- pCmdUI->Enable(supported);
- pCmdUI->SetCheck(r.m_RenderSettings.bSynchronizeVideo);
+ pCmdUI->Enable(supported);
+ pCmdUI->SetCheck(r.m_RenderSettings.bSynchronizeVideo);
}
void CMainFrame::OnUpdateViewSynchronizeDisplay(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- CRenderersSettings& r = s.m_RenderersSettings;
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_SYNC) && GetPlaybackMode() == PM_NONE);
+ AppSettings& s = AfxGetAppSettings();
+ CRenderersSettings& r = s.m_RenderersSettings;
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_SYNC) && GetPlaybackMode() == PM_NONE);
- pCmdUI->Enable(supported);
- pCmdUI->SetCheck(r.m_RenderSettings.bSynchronizeDisplay);
+ pCmdUI->Enable(supported);
+ pCmdUI->SetCheck(r.m_RenderSettings.bSynchronizeDisplay);
}
void CMainFrame::OnUpdateViewSynchronizeNearest(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- CRenderersSettings& r = s.m_RenderersSettings;
- bool supported = (s.iDSVideoRendererType == VIDRNDT_DS_SYNC);
+ AppSettings& s = AfxGetAppSettings();
+ CRenderersSettings& r = s.m_RenderersSettings;
+ bool supported = (s.iDSVideoRendererType == VIDRNDT_DS_SYNC);
- pCmdUI->Enable(supported);
- pCmdUI->SetCheck(r.m_RenderSettings.bSynchronizeNearest);
+ pCmdUI->Enable(supported);
+ pCmdUI->SetCheck(r.m_RenderSettings.bSynchronizeNearest);
}
void CMainFrame::OnUpdateViewColorManagementEnable(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- CRenderersSettings& r = s.m_RenderersSettings;
- CRenderersData& rd = AfxGetMyApp()->m_Renderers;
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
- s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
- r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) &&
- rd.m_bFP16Support;
+ AppSettings& s = AfxGetAppSettings();
+ CRenderersSettings& r = s.m_RenderersSettings;
+ CRenderersData& rd = AfxGetMyApp()->m_Renderers;
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
+ s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
+ r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) &&
+ rd.m_bFP16Support;
- pCmdUI->Enable (supported);
- pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementEnable);
+ pCmdUI->Enable(supported);
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementEnable);
}
void CMainFrame::OnUpdateViewColorManagementInput(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- CRenderersSettings& r = s.m_RenderersSettings;
- CRenderersData& rd = AfxGetMyApp()->m_Renderers;
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
- s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
- r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) &&
- rd.m_bFP16Support &&
- r.m_RenderSettings.iVMR9ColorManagementEnable;
-
- pCmdUI->Enable (supported);
-
- switch (pCmdUI->m_nID) {
- case ID_VIEW_CM_INPUT_AUTO:
- pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementInput == VIDEO_SYSTEM_UNKNOWN);
- break;
-
- case ID_VIEW_CM_INPUT_HDTV:
- pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementInput == VIDEO_SYSTEM_HDTV);
- break;
-
- case ID_VIEW_CM_INPUT_SDTV_NTSC:
- pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementInput == VIDEO_SYSTEM_SDTV_NTSC);
- break;
-
- case ID_VIEW_CM_INPUT_SDTV_PAL:
- pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementInput == VIDEO_SYSTEM_SDTV_PAL);
- break;
- }
+ AppSettings& s = AfxGetAppSettings();
+ CRenderersSettings& r = s.m_RenderersSettings;
+ CRenderersData& rd = AfxGetMyApp()->m_Renderers;
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
+ s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
+ r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) &&
+ rd.m_bFP16Support &&
+ r.m_RenderSettings.iVMR9ColorManagementEnable;
+
+ pCmdUI->Enable(supported);
+
+ switch (pCmdUI->m_nID) {
+ case ID_VIEW_CM_INPUT_AUTO:
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementInput == VIDEO_SYSTEM_UNKNOWN);
+ break;
+
+ case ID_VIEW_CM_INPUT_HDTV:
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementInput == VIDEO_SYSTEM_HDTV);
+ break;
+
+ case ID_VIEW_CM_INPUT_SDTV_NTSC:
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementInput == VIDEO_SYSTEM_SDTV_NTSC);
+ break;
+
+ case ID_VIEW_CM_INPUT_SDTV_PAL:
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementInput == VIDEO_SYSTEM_SDTV_PAL);
+ break;
+ }
}
void CMainFrame::OnUpdateViewColorManagementAmbientLight(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- CRenderersSettings& r = s.m_RenderersSettings;
- CRenderersData& rd = AfxGetMyApp()->m_Renderers;
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
- s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
- r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) &&
- rd.m_bFP16Support &&
- r.m_RenderSettings.iVMR9ColorManagementEnable;
-
- pCmdUI->Enable (supported);
-
- switch (pCmdUI->m_nID) {
- case ID_VIEW_CM_AMBIENTLIGHT_BRIGHT:
- pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementAmbientLight == AMBIENT_LIGHT_BRIGHT);
- break;
-
- case ID_VIEW_CM_AMBIENTLIGHT_DIM:
- pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementAmbientLight == AMBIENT_LIGHT_DIM);
- break;
-
- case ID_VIEW_CM_AMBIENTLIGHT_DARK:
- pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementAmbientLight == AMBIENT_LIGHT_DARK);
- break;
- }
+ AppSettings& s = AfxGetAppSettings();
+ CRenderersSettings& r = s.m_RenderersSettings;
+ CRenderersData& rd = AfxGetMyApp()->m_Renderers;
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
+ s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
+ r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) &&
+ rd.m_bFP16Support &&
+ r.m_RenderSettings.iVMR9ColorManagementEnable;
+
+ pCmdUI->Enable(supported);
+
+ switch (pCmdUI->m_nID) {
+ case ID_VIEW_CM_AMBIENTLIGHT_BRIGHT:
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementAmbientLight == AMBIENT_LIGHT_BRIGHT);
+ break;
+
+ case ID_VIEW_CM_AMBIENTLIGHT_DIM:
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementAmbientLight == AMBIENT_LIGHT_DIM);
+ break;
+
+ case ID_VIEW_CM_AMBIENTLIGHT_DARK:
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementAmbientLight == AMBIENT_LIGHT_DARK);
+ break;
+ }
}
void CMainFrame::OnUpdateViewColorManagementIntent(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- CRenderersSettings& r = s.m_RenderersSettings;
- CRenderersData& rd = AfxGetMyApp()->m_Renderers;
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
- s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
- r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) &&
- rd.m_bFP16Support &&
- r.m_RenderSettings.iVMR9ColorManagementEnable;
-
- pCmdUI->Enable (supported);
-
- switch (pCmdUI->m_nID) {
- case ID_VIEW_CM_INTENT_PERCEPTUAL:
- pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementIntent == COLOR_RENDERING_INTENT_PERCEPTUAL);
- break;
-
- case ID_VIEW_CM_INTENT_RELATIVECOLORIMETRIC:
- pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementIntent == COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC);
- break;
-
- case ID_VIEW_CM_INTENT_SATURATION:
- pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementIntent == COLOR_RENDERING_INTENT_SATURATION);
- break;
-
- case ID_VIEW_CM_INTENT_ABSOLUTECOLORIMETRIC:
- pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementIntent == COLOR_RENDERING_INTENT_ABSOLUTE_COLORIMETRIC);
- break;
- }
+ AppSettings& s = AfxGetAppSettings();
+ CRenderersSettings& r = s.m_RenderersSettings;
+ CRenderersData& rd = AfxGetMyApp()->m_Renderers;
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
+ s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
+ r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) &&
+ rd.m_bFP16Support &&
+ r.m_RenderSettings.iVMR9ColorManagementEnable;
+
+ pCmdUI->Enable(supported);
+
+ switch (pCmdUI->m_nID) {
+ case ID_VIEW_CM_INTENT_PERCEPTUAL:
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementIntent == COLOR_RENDERING_INTENT_PERCEPTUAL);
+ break;
+
+ case ID_VIEW_CM_INTENT_RELATIVECOLORIMETRIC:
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementIntent == COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC);
+ break;
+
+ case ID_VIEW_CM_INTENT_SATURATION:
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementIntent == COLOR_RENDERING_INTENT_SATURATION);
+ break;
+
+ case ID_VIEW_CM_INTENT_ABSOLUTECOLORIMETRIC:
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementIntent == COLOR_RENDERING_INTENT_ABSOLUTE_COLORIMETRIC);
+ break;
+ }
}
void CMainFrame::OnUpdateViewEVROutputRange(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- CRenderersSettings& r = s.m_RenderersSettings;
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
- s.iDSVideoRendererType == VIDRNDT_DS_SYNC) &&
- r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
+ AppSettings& s = AfxGetAppSettings();
+ CRenderersSettings& r = s.m_RenderersSettings;
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
+ s.iDSVideoRendererType == VIDRNDT_DS_SYNC) &&
+ r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
- pCmdUI->Enable (supported);
+ pCmdUI->Enable(supported);
- if (pCmdUI->m_nID == ID_VIEW_EVROUTPUTRANGE_0_255) {
- pCmdUI->SetCheck(r.m_RenderSettings.iEVROutputRange == 0);
- } else if (pCmdUI->m_nID == ID_VIEW_EVROUTPUTRANGE_16_235) {
- pCmdUI->SetCheck(r.m_RenderSettings.iEVROutputRange == 1);
- }
+ if (pCmdUI->m_nID == ID_VIEW_EVROUTPUTRANGE_0_255) {
+ pCmdUI->SetCheck(r.m_RenderSettings.iEVROutputRange == 0);
+ } else if (pCmdUI->m_nID == ID_VIEW_EVROUTPUTRANGE_16_235) {
+ pCmdUI->SetCheck(r.m_RenderSettings.iEVROutputRange == 1);
+ }
}
void CMainFrame::OnUpdateViewFlushGPU(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- CRenderersSettings& r = s.m_RenderersSettings;
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
- s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
- r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
+ AppSettings& s = AfxGetAppSettings();
+ CRenderersSettings& r = s.m_RenderersSettings;
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
+ s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
+ r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
- pCmdUI->Enable (supported);
+ pCmdUI->Enable(supported);
- if (pCmdUI->m_nID == ID_VIEW_FLUSHGPU_BEFOREVSYNC) {
- pCmdUI->SetCheck(r.m_RenderSettings.iVMRFlushGPUBeforeVSync != 0);
- } else if (pCmdUI->m_nID == ID_VIEW_FLUSHGPU_AFTERPRESENT) {
- pCmdUI->SetCheck(r.m_RenderSettings.iVMRFlushGPUAfterPresent != 0);
- } else if (pCmdUI->m_nID == ID_VIEW_FLUSHGPU_WAIT) {
- pCmdUI->SetCheck(r.m_RenderSettings.iVMRFlushGPUWait != 0);
- }
+ if (pCmdUI->m_nID == ID_VIEW_FLUSHGPU_BEFOREVSYNC) {
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMRFlushGPUBeforeVSync != 0);
+ } else if (pCmdUI->m_nID == ID_VIEW_FLUSHGPU_AFTERPRESENT) {
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMRFlushGPUAfterPresent != 0);
+ } else if (pCmdUI->m_nID == ID_VIEW_FLUSHGPU_WAIT) {
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMRFlushGPUWait != 0);
+ }
}
void CMainFrame::OnUpdateViewD3DFullscreen(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- CRenderersSettings& r = s.m_RenderersSettings;
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
- s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS ||
- s.iDSVideoRendererType == VIDRNDT_DS_SYNC) &&
- r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
+ AppSettings& s = AfxGetAppSettings();
+ CRenderersSettings& r = s.m_RenderersSettings;
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
+ s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS ||
+ s.iDSVideoRendererType == VIDRNDT_DS_SYNC) &&
+ r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
- pCmdUI->Enable (supported);
- pCmdUI->SetCheck(s.fD3DFullscreen);
+ pCmdUI->Enable(supported);
+ pCmdUI->SetCheck(s.fD3DFullscreen);
}
void CMainFrame::OnUpdateViewDisableDesktopComposition(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- CRenderersSettings& r = s.m_RenderersSettings;
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
- s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS ||
- s.iDSVideoRendererType == VIDRNDT_DS_SYNC) &&
- r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D &&
- SysVersion::IsVistaOrLater());
+ AppSettings& s = AfxGetAppSettings();
+ CRenderersSettings& r = s.m_RenderersSettings;
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
+ s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS ||
+ s.iDSVideoRendererType == VIDRNDT_DS_SYNC) &&
+ r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D &&
+ SysVersion::IsVistaOrLater());
- pCmdUI->Enable(supported);
- pCmdUI->SetCheck(r.m_RenderSettings.iVMRDisableDesktopComposition);
+ pCmdUI->Enable(supported);
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMRDisableDesktopComposition);
}
void CMainFrame::OnUpdateViewAlternativeVSync(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- CRenderersSettings& r = s.m_RenderersSettings;
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
- s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
- r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
+ AppSettings& s = AfxGetAppSettings();
+ CRenderersSettings& r = s.m_RenderersSettings;
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
+ s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
+ r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
- pCmdUI->Enable (supported);
- pCmdUI->SetCheck(r.m_RenderSettings.fVMR9AlterativeVSync);
+ pCmdUI->Enable(supported);
+ pCmdUI->SetCheck(r.m_RenderSettings.fVMR9AlterativeVSync);
}
void CMainFrame::OnUpdateViewFullscreenGUISupport(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- CRenderersSettings& r = s.m_RenderersSettings;
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
- s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
- r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
+ AppSettings& s = AfxGetAppSettings();
+ CRenderersSettings& r = s.m_RenderersSettings;
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
+ s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
+ r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
- pCmdUI->Enable (supported);
- pCmdUI->SetCheck(r.m_RenderSettings.iVMR9FullscreenGUISupport);
+ pCmdUI->Enable(supported);
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMR9FullscreenGUISupport);
}
void CMainFrame::OnUpdateViewHighColorResolution(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- CRenderersSettings& r = s.m_RenderersSettings;
- CRenderersData& rd = AfxGetMyApp()->m_Renderers;
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
- s.iDSVideoRendererType == VIDRNDT_DS_SYNC) &&
- r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) &&
- rd.m_b10bitSupport;
+ AppSettings& s = AfxGetAppSettings();
+ CRenderersSettings& r = s.m_RenderersSettings;
+ CRenderersData& rd = AfxGetMyApp()->m_Renderers;
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
+ s.iDSVideoRendererType == VIDRNDT_DS_SYNC) &&
+ r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) &&
+ rd.m_b10bitSupport;
- pCmdUI->Enable (supported);
- pCmdUI->SetCheck(r.m_RenderSettings.iEVRHighColorResolution);
+ pCmdUI->Enable(supported);
+ pCmdUI->SetCheck(r.m_RenderSettings.iEVRHighColorResolution);
}
void CMainFrame::OnUpdateViewForceInputHighColorResolution(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- CRenderersSettings& r = s.m_RenderersSettings;
- CRenderersData& rd = AfxGetMyApp()->m_Renderers;
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM) &&
- r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) &&
- rd.m_b10bitSupport;
+ AppSettings& s = AfxGetAppSettings();
+ CRenderersSettings& r = s.m_RenderersSettings;
+ CRenderersData& rd = AfxGetMyApp()->m_Renderers;
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM) &&
+ r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) &&
+ rd.m_b10bitSupport;
- pCmdUI->Enable (supported);
- pCmdUI->SetCheck(r.m_RenderSettings.iEVRForceInputHighColorResolution);
+ pCmdUI->Enable(supported);
+ pCmdUI->SetCheck(r.m_RenderSettings.iEVRForceInputHighColorResolution);
}
void CMainFrame::OnUpdateViewFullFloatingPointProcessing(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- CRenderersSettings& r = s.m_RenderersSettings;
- CRenderersData& rd = AfxGetMyApp()->m_Renderers;
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
- s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
- r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) &&
- rd.m_bFP16Support;
+ AppSettings& s = AfxGetAppSettings();
+ CRenderersSettings& r = s.m_RenderersSettings;
+ CRenderersData& rd = AfxGetMyApp()->m_Renderers;
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
+ s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
+ r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) &&
+ rd.m_bFP16Support;
- pCmdUI->Enable (supported);
- pCmdUI->SetCheck(r.m_RenderSettings.iVMR9FullFloatingPointProcessing);
+ pCmdUI->Enable(supported);
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMR9FullFloatingPointProcessing);
}
void CMainFrame::OnUpdateViewHalfFloatingPointProcessing(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- CRenderersSettings& r = s.m_RenderersSettings;
- CRenderersData& rd = AfxGetMyApp()->m_Renderers;
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
- s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
- r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) &&
- rd.m_bFP16Support;
+ AppSettings& s = AfxGetAppSettings();
+ CRenderersSettings& r = s.m_RenderersSettings;
+ CRenderersData& rd = AfxGetMyApp()->m_Renderers;
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
+ s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
+ r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) &&
+ rd.m_bFP16Support;
- pCmdUI->Enable (supported);
- pCmdUI->SetCheck(r.m_RenderSettings.iVMR9HalfFloatingPointProcessing);
+ pCmdUI->Enable(supported);
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMR9HalfFloatingPointProcessing);
}
void CMainFrame::OnUpdateViewEnableFrameTimeCorrection(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- CRenderersSettings& r = s.m_RenderersSettings;
- bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM) &&
- r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
+ AppSettings& s = AfxGetAppSettings();
+ CRenderersSettings& r = s.m_RenderersSettings;
+ bool supported = ((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM) &&
+ r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D);
- pCmdUI->Enable (supported);
- pCmdUI->SetCheck(r.m_RenderSettings.iEVREnableFrameTimeCorrection);
+ pCmdUI->Enable(supported);
+ pCmdUI->SetCheck(r.m_RenderSettings.iEVREnableFrameTimeCorrection);
}
void CMainFrame::OnUpdateViewVSyncOffsetIncrease(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- CRenderersSettings& r = s.m_RenderersSettings;
- bool supported = s.iDSVideoRendererType == VIDRNDT_DS_SYNC ||
- (((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
- s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
- r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) &&
- r.m_RenderSettings.fVMR9AlterativeVSync);
+ AppSettings& s = AfxGetAppSettings();
+ CRenderersSettings& r = s.m_RenderersSettings;
+ bool supported = s.iDSVideoRendererType == VIDRNDT_DS_SYNC ||
+ (((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
+ s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
+ r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) &&
+ r.m_RenderSettings.fVMR9AlterativeVSync);
- pCmdUI->Enable (supported);
+ pCmdUI->Enable(supported);
}
void CMainFrame::OnUpdateViewVSyncOffsetDecrease(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- CRenderersSettings& r = s.m_RenderersSettings;
- bool supported = s.iDSVideoRendererType == VIDRNDT_DS_SYNC ||
- (((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
- s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
- r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) &&
- r.m_RenderSettings.fVMR9AlterativeVSync);
+ AppSettings& s = AfxGetAppSettings();
+ CRenderersSettings& r = s.m_RenderersSettings;
+ bool supported = s.iDSVideoRendererType == VIDRNDT_DS_SYNC ||
+ (((s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM ||
+ s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) &&
+ r.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) &&
+ r.m_RenderSettings.fVMR9AlterativeVSync);
- pCmdUI->Enable (supported);
+ pCmdUI->Enable(supported);
}
void CMainFrame::OnViewVSync()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.iVMR9VSync = !s.m_RenderSettings.iVMR9VSync;
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT,
- s.m_RenderSettings.iVMR9VSync ? ResStr(IDS_OSD_RS_VSYNC_ON) : ResStr(IDS_OSD_RS_VSYNC_OFF));
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.iVMR9VSync = !s.m_RenderSettings.iVMR9VSync;
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT,
+ s.m_RenderSettings.iVMR9VSync ? ResStr(IDS_OSD_RS_VSYNC_ON) : ResStr(IDS_OSD_RS_VSYNC_OFF));
}
void CMainFrame::OnViewVSyncAccurate()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.iVMR9VSyncAccurate = !s.m_RenderSettings.iVMR9VSyncAccurate;
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT,
- s.m_RenderSettings.iVMR9VSyncAccurate ? ResStr(IDS_OSD_RS_ACCURATE_VSYNC_ON) : ResStr(IDS_OSD_RS_ACCURATE_VSYNC_OFF));
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.iVMR9VSyncAccurate = !s.m_RenderSettings.iVMR9VSyncAccurate;
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT,
+ s.m_RenderSettings.iVMR9VSyncAccurate ? ResStr(IDS_OSD_RS_ACCURATE_VSYNC_ON) : ResStr(IDS_OSD_RS_ACCURATE_VSYNC_OFF));
}
void CMainFrame::OnViewSynchronizeVideo()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.bSynchronizeVideo = !s.m_RenderSettings.bSynchronizeVideo;
- if (s.m_RenderSettings.bSynchronizeVideo) {
- s.m_RenderSettings.bSynchronizeDisplay = false;
- s.m_RenderSettings.bSynchronizeNearest = false;
- s.m_RenderSettings.iVMR9VSync = false;
- s.m_RenderSettings.iVMR9VSyncAccurate = false;
- s.m_RenderSettings.fVMR9AlterativeVSync = false;
- }
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.bSynchronizeVideo = !s.m_RenderSettings.bSynchronizeVideo;
+ if (s.m_RenderSettings.bSynchronizeVideo) {
+ s.m_RenderSettings.bSynchronizeDisplay = false;
+ s.m_RenderSettings.bSynchronizeNearest = false;
+ s.m_RenderSettings.iVMR9VSync = false;
+ s.m_RenderSettings.iVMR9VSyncAccurate = false;
+ s.m_RenderSettings.fVMR9AlterativeVSync = false;
+ }
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT,
- s.m_RenderSettings.bSynchronizeVideo ? ResStr(IDS_OSD_RS_SYNC_TO_DISPLAY_ON) : ResStr(IDS_OSD_RS_SYNC_TO_DISPLAY_ON));
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT,
+ s.m_RenderSettings.bSynchronizeVideo ? ResStr(IDS_OSD_RS_SYNC_TO_DISPLAY_ON) : ResStr(IDS_OSD_RS_SYNC_TO_DISPLAY_ON));
}
void CMainFrame::OnViewSynchronizeDisplay()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.bSynchronizeDisplay = !s.m_RenderSettings.bSynchronizeDisplay;
- if (s.m_RenderSettings.bSynchronizeDisplay) {
- s.m_RenderSettings.bSynchronizeVideo = false;
- s.m_RenderSettings.bSynchronizeNearest = false;
- s.m_RenderSettings.iVMR9VSync = false;
- s.m_RenderSettings.iVMR9VSyncAccurate = false;
- s.m_RenderSettings.fVMR9AlterativeVSync = false;
- }
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.bSynchronizeDisplay = !s.m_RenderSettings.bSynchronizeDisplay;
+ if (s.m_RenderSettings.bSynchronizeDisplay) {
+ s.m_RenderSettings.bSynchronizeVideo = false;
+ s.m_RenderSettings.bSynchronizeNearest = false;
+ s.m_RenderSettings.iVMR9VSync = false;
+ s.m_RenderSettings.iVMR9VSyncAccurate = false;
+ s.m_RenderSettings.fVMR9AlterativeVSync = false;
+ }
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT,
- s.m_RenderSettings.bSynchronizeDisplay ? ResStr(IDS_OSD_RS_SYNC_TO_VIDEO_ON) : ResStr(IDS_OSD_RS_SYNC_TO_VIDEO_ON));
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT,
+ s.m_RenderSettings.bSynchronizeDisplay ? ResStr(IDS_OSD_RS_SYNC_TO_VIDEO_ON) : ResStr(IDS_OSD_RS_SYNC_TO_VIDEO_ON));
}
void CMainFrame::OnViewSynchronizeNearest()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.bSynchronizeNearest = !s.m_RenderSettings.bSynchronizeNearest;
- if (s.m_RenderSettings.bSynchronizeNearest) {
- s.m_RenderSettings.bSynchronizeVideo = false;
- s.m_RenderSettings.bSynchronizeDisplay = false;
- s.m_RenderSettings.iVMR9VSync = false;
- s.m_RenderSettings.iVMR9VSyncAccurate = false;
- s.m_RenderSettings.fVMR9AlterativeVSync = false;
- }
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.bSynchronizeNearest = !s.m_RenderSettings.bSynchronizeNearest;
+ if (s.m_RenderSettings.bSynchronizeNearest) {
+ s.m_RenderSettings.bSynchronizeVideo = false;
+ s.m_RenderSettings.bSynchronizeDisplay = false;
+ s.m_RenderSettings.iVMR9VSync = false;
+ s.m_RenderSettings.iVMR9VSyncAccurate = false;
+ s.m_RenderSettings.fVMR9AlterativeVSync = false;
+ }
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT,
- s.m_RenderSettings.bSynchronizeNearest ? ResStr(IDS_OSD_RS_PRESENT_NEAREST_ON) : ResStr(IDS_OSD_RS_PRESENT_NEAREST_OFF));
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT,
+ s.m_RenderSettings.bSynchronizeNearest ? ResStr(IDS_OSD_RS_PRESENT_NEAREST_ON) : ResStr(IDS_OSD_RS_PRESENT_NEAREST_OFF));
}
void CMainFrame::OnViewColorManagementEnable()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.iVMR9ColorManagementEnable = !s.m_RenderSettings.iVMR9ColorManagementEnable;
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT,
- s.m_RenderSettings.iVMR9ColorManagementEnable ? ResStr(IDS_OSD_RS_COLOR_MANAGEMENT_ON) : ResStr(IDS_OSD_RS_COLOR_MANAGEMENT_OFF));
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.iVMR9ColorManagementEnable = !s.m_RenderSettings.iVMR9ColorManagementEnable;
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT,
+ s.m_RenderSettings.iVMR9ColorManagementEnable ? ResStr(IDS_OSD_RS_COLOR_MANAGEMENT_ON) : ResStr(IDS_OSD_RS_COLOR_MANAGEMENT_OFF));
}
void CMainFrame::OnViewColorManagementInputAuto()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.iVMR9ColorManagementInput = VIDEO_SYSTEM_UNKNOWN;
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_OSD_RS_INPUT_TYPE_AUTO));
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.iVMR9ColorManagementInput = VIDEO_SYSTEM_UNKNOWN;
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_OSD_RS_INPUT_TYPE_AUTO));
}
void CMainFrame::OnViewColorManagementInputHDTV()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.iVMR9ColorManagementInput = VIDEO_SYSTEM_HDTV;
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_OSD_RS_INPUT_TYPE_HDTV));
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.iVMR9ColorManagementInput = VIDEO_SYSTEM_HDTV;
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_OSD_RS_INPUT_TYPE_HDTV));
}
void CMainFrame::OnViewColorManagementInputSDTV_NTSC()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.iVMR9ColorManagementInput = VIDEO_SYSTEM_SDTV_NTSC;
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_OSD_RS_INPUT_TYPE_SD_NTSC));
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.iVMR9ColorManagementInput = VIDEO_SYSTEM_SDTV_NTSC;
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_OSD_RS_INPUT_TYPE_SD_NTSC));
}
void CMainFrame::OnViewColorManagementInputSDTV_PAL()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.iVMR9ColorManagementInput = VIDEO_SYSTEM_SDTV_PAL;
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_OSD_RS_INPUT_TYPE_SD_PAL));
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.iVMR9ColorManagementInput = VIDEO_SYSTEM_SDTV_PAL;
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_OSD_RS_INPUT_TYPE_SD_PAL));
}
void CMainFrame::OnViewColorManagementAmbientLightBright()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.iVMR9ColorManagementAmbientLight = AMBIENT_LIGHT_BRIGHT;
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_OSD_RS_AMBIENT_LIGHT_BRIGHT));
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.iVMR9ColorManagementAmbientLight = AMBIENT_LIGHT_BRIGHT;
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_OSD_RS_AMBIENT_LIGHT_BRIGHT));
}
void CMainFrame::OnViewColorManagementAmbientLightDim()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.iVMR9ColorManagementAmbientLight = AMBIENT_LIGHT_DIM;
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_OSD_RS_AMBIENT_LIGHT_DIM));
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.iVMR9ColorManagementAmbientLight = AMBIENT_LIGHT_DIM;
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_OSD_RS_AMBIENT_LIGHT_DIM));
}
void CMainFrame::OnViewColorManagementAmbientLightDark()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.iVMR9ColorManagementAmbientLight = AMBIENT_LIGHT_DARK;
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_OSD_RS_AMBIENT_LIGHT_DARK));
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.iVMR9ColorManagementAmbientLight = AMBIENT_LIGHT_DARK;
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_OSD_RS_AMBIENT_LIGHT_DARK));
}
void CMainFrame::OnViewColorManagementIntentPerceptual()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.iVMR9ColorManagementIntent = COLOR_RENDERING_INTENT_PERCEPTUAL;
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_OSD_RS_REND_INTENT_PERCEPT));
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.iVMR9ColorManagementIntent = COLOR_RENDERING_INTENT_PERCEPTUAL;
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_OSD_RS_REND_INTENT_PERCEPT));
}
void CMainFrame::OnViewColorManagementIntentRelativeColorimetric()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.iVMR9ColorManagementIntent = COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC;
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_OSD_RS_REND_INTENT_RELATIVE));
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.iVMR9ColorManagementIntent = COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC;
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_OSD_RS_REND_INTENT_RELATIVE));
}
void CMainFrame::OnViewColorManagementIntentSaturation()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.iVMR9ColorManagementIntent = COLOR_RENDERING_INTENT_SATURATION;
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_OSD_RS_REND_INTENT_SATUR));
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.iVMR9ColorManagementIntent = COLOR_RENDERING_INTENT_SATURATION;
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_OSD_RS_REND_INTENT_SATUR));
}
void CMainFrame::OnViewColorManagementIntentAbsoluteColorimetric()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.iVMR9ColorManagementIntent = COLOR_RENDERING_INTENT_ABSOLUTE_COLORIMETRIC;
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_OSD_RS_REND_INTENT_ABSOLUTE));
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.iVMR9ColorManagementIntent = COLOR_RENDERING_INTENT_ABSOLUTE_COLORIMETRIC;
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_OSD_RS_REND_INTENT_ABSOLUTE));
}
void CMainFrame::OnViewEVROutputRange_0_255()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.iEVROutputRange = 0;
- s.UpdateData(true);
- CString strOSD;
- strOSD.Format(IDS_OSD_RS_OUTPUT_RANGE, _T("0 - 255"));
- m_OSD.DisplayMessage (OSD_TOPRIGHT, strOSD);
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.iEVROutputRange = 0;
+ s.UpdateData(true);
+ CString strOSD;
+ strOSD.Format(IDS_OSD_RS_OUTPUT_RANGE, _T("0 - 255"));
+ m_OSD.DisplayMessage(OSD_TOPRIGHT, strOSD);
}
void CMainFrame::OnViewEVROutputRange_16_235()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.iEVROutputRange = 1;
- s.UpdateData(true);
- CString strOSD;
- strOSD.Format(IDS_OSD_RS_OUTPUT_RANGE, _T("16 - 235"));
- m_OSD.DisplayMessage (OSD_TOPRIGHT, strOSD);
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.iEVROutputRange = 1;
+ s.UpdateData(true);
+ CString strOSD;
+ strOSD.Format(IDS_OSD_RS_OUTPUT_RANGE, _T("16 - 235"));
+ m_OSD.DisplayMessage(OSD_TOPRIGHT, strOSD);
}
void CMainFrame::OnViewFlushGPUBeforeVSync()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.iVMRFlushGPUBeforeVSync = !s.m_RenderSettings.iVMRFlushGPUBeforeVSync;
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT,
- s.m_RenderSettings.iVMRFlushGPUBeforeVSync ? ResStr(IDS_OSD_RS_FLUSH_BEF_VSYNC_ON) : ResStr(IDS_OSD_RS_FLUSH_BEF_VSYNC_OFF));
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.iVMRFlushGPUBeforeVSync = !s.m_RenderSettings.iVMRFlushGPUBeforeVSync;
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT,
+ s.m_RenderSettings.iVMRFlushGPUBeforeVSync ? ResStr(IDS_OSD_RS_FLUSH_BEF_VSYNC_ON) : ResStr(IDS_OSD_RS_FLUSH_BEF_VSYNC_OFF));
}
void CMainFrame::OnViewFlushGPUAfterVSync()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.iVMRFlushGPUAfterPresent = !s.m_RenderSettings.iVMRFlushGPUAfterPresent;
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT,
- s.m_RenderSettings.iVMRFlushGPUAfterPresent ? ResStr(IDS_OSD_RS_FLUSH_AFT_PRES_ON) : ResStr(IDS_OSD_RS_FLUSH_AFT_PRES_OFF));
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.iVMRFlushGPUAfterPresent = !s.m_RenderSettings.iVMRFlushGPUAfterPresent;
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT,
+ s.m_RenderSettings.iVMRFlushGPUAfterPresent ? ResStr(IDS_OSD_RS_FLUSH_AFT_PRES_ON) : ResStr(IDS_OSD_RS_FLUSH_AFT_PRES_OFF));
}
void CMainFrame::OnViewFlushGPUWait()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.iVMRFlushGPUWait = !s.m_RenderSettings.iVMRFlushGPUWait;
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT,
- s.m_RenderSettings.iVMRFlushGPUWait ? ResStr(IDS_OSD_RS_WAIT_ON) : ResStr(IDS_OSD_RS_WAIT_OFF));
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.iVMRFlushGPUWait = !s.m_RenderSettings.iVMRFlushGPUWait;
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT,
+ s.m_RenderSettings.iVMRFlushGPUWait ? ResStr(IDS_OSD_RS_WAIT_ON) : ResStr(IDS_OSD_RS_WAIT_OFF));
}
void CMainFrame::OnViewD3DFullScreen()
{
- AppSettings& s = AfxGetAppSettings();
- s.fD3DFullscreen = !s.fD3DFullscreen;
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT,
- s.fD3DFullscreen ? ResStr(IDS_OSD_RS_D3D_FULLSCREEN_ON) : ResStr(IDS_OSD_RS_D3D_FULLSCREEN_OFF));
+ AppSettings& s = AfxGetAppSettings();
+ s.fD3DFullscreen = !s.fD3DFullscreen;
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT,
+ s.fD3DFullscreen ? ResStr(IDS_OSD_RS_D3D_FULLSCREEN_ON) : ResStr(IDS_OSD_RS_D3D_FULLSCREEN_OFF));
}
void CMainFrame::OnViewDisableDesktopComposition()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.iVMRDisableDesktopComposition = !s.m_RenderSettings.iVMRDisableDesktopComposition;
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT,
- s.m_RenderSettings.iVMRDisableDesktopComposition ? ResStr(IDS_OSD_RS_NO_DESKTOP_COMP_ON) : ResStr(IDS_OSD_RS_NO_DESKTOP_COMP_OFF));
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.iVMRDisableDesktopComposition = !s.m_RenderSettings.iVMRDisableDesktopComposition;
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT,
+ s.m_RenderSettings.iVMRDisableDesktopComposition ? ResStr(IDS_OSD_RS_NO_DESKTOP_COMP_ON) : ResStr(IDS_OSD_RS_NO_DESKTOP_COMP_OFF));
}
void CMainFrame::OnViewAlternativeVSync()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.fVMR9AlterativeVSync = !s.m_RenderSettings.fVMR9AlterativeVSync;
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT,
- s.m_RenderSettings.fVMR9AlterativeVSync ? ResStr(IDS_OSD_RS_ALT_VSYNC_ON) : ResStr(IDS_OSD_RS_ALT_VSYNC_OFF));
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.fVMR9AlterativeVSync = !s.m_RenderSettings.fVMR9AlterativeVSync;
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT,
+ s.m_RenderSettings.fVMR9AlterativeVSync ? ResStr(IDS_OSD_RS_ALT_VSYNC_ON) : ResStr(IDS_OSD_RS_ALT_VSYNC_OFF));
}
void CMainFrame::OnViewResetDefault()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.SetDefault();
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_OSD_RS_RESET_DEFAULT));
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.SetDefault();
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_OSD_RS_RESET_DEFAULT));
}
void CMainFrame::OnViewResetOptimal()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.SetOptimal();
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_OSD_RS_RESET_OPTIMAL));
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.SetOptimal();
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_OSD_RS_RESET_OPTIMAL));
}
void CMainFrame::OnViewFullscreenGUISupport()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.iVMR9FullscreenGUISupport = !s.m_RenderSettings.iVMR9FullscreenGUISupport;
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT,
- s.m_RenderSettings.iVMR9FullscreenGUISupport ? ResStr(IDS_OSD_RS_D3D_FS_GUI_SUPP_ON) : ResStr(IDS_OSD_RS_D3D_FS_GUI_SUPP_OFF));
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.iVMR9FullscreenGUISupport = !s.m_RenderSettings.iVMR9FullscreenGUISupport;
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT,
+ s.m_RenderSettings.iVMR9FullscreenGUISupport ? ResStr(IDS_OSD_RS_D3D_FS_GUI_SUPP_ON) : ResStr(IDS_OSD_RS_D3D_FS_GUI_SUPP_OFF));
}
void CMainFrame::OnViewHighColorResolution()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.iEVRHighColorResolution = !s.m_RenderSettings.iEVRHighColorResolution;
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT,
- s.m_RenderSettings.iEVRHighColorResolution ? ResStr(IDS_OSD_RS_10BIT_RBG_OUT_ON) : ResStr(IDS_OSD_RS_10BIT_RBG_OUT_OFF));
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.iEVRHighColorResolution = !s.m_RenderSettings.iEVRHighColorResolution;
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT,
+ s.m_RenderSettings.iEVRHighColorResolution ? ResStr(IDS_OSD_RS_10BIT_RBG_OUT_ON) : ResStr(IDS_OSD_RS_10BIT_RBG_OUT_OFF));
}
void CMainFrame::OnViewForceInputHighColorResolution()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.iEVRForceInputHighColorResolution = !s.m_RenderSettings.iEVRForceInputHighColorResolution;
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT,
- s.m_RenderSettings.iEVRForceInputHighColorResolution ? ResStr(IDS_OSD_RS_10BIT_RBG_IN_ON) : ResStr(IDS_OSD_RS_10BIT_RBG_IN_OFF));
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.iEVRForceInputHighColorResolution = !s.m_RenderSettings.iEVRForceInputHighColorResolution;
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT,
+ s.m_RenderSettings.iEVRForceInputHighColorResolution ? ResStr(IDS_OSD_RS_10BIT_RBG_IN_ON) : ResStr(IDS_OSD_RS_10BIT_RBG_IN_OFF));
}
void CMainFrame::OnViewFullFloatingPointProcessing()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.iVMR9FullFloatingPointProcessing = !s.m_RenderSettings.iVMR9FullFloatingPointProcessing;
- if (s.m_RenderSettings.iVMR9FullFloatingPointProcessing) {
- s.m_RenderSettings.iVMR9HalfFloatingPointProcessing = false;
- }
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT,
- s.m_RenderSettings.iVMR9FullFloatingPointProcessing ? ResStr(IDS_OSD_RS_FULL_FP_PROCESS_ON) : ResStr(IDS_OSD_RS_FULL_FP_PROCESS_OFF));
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.iVMR9FullFloatingPointProcessing = !s.m_RenderSettings.iVMR9FullFloatingPointProcessing;
+ if (s.m_RenderSettings.iVMR9FullFloatingPointProcessing) {
+ s.m_RenderSettings.iVMR9HalfFloatingPointProcessing = false;
+ }
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT,
+ s.m_RenderSettings.iVMR9FullFloatingPointProcessing ? ResStr(IDS_OSD_RS_FULL_FP_PROCESS_ON) : ResStr(IDS_OSD_RS_FULL_FP_PROCESS_OFF));
}
void CMainFrame::OnViewHalfFloatingPointProcessing()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.iVMR9HalfFloatingPointProcessing = !s.m_RenderSettings.iVMR9HalfFloatingPointProcessing;
- if (s.m_RenderSettings.iVMR9HalfFloatingPointProcessing) {
- s.m_RenderSettings.iVMR9FullFloatingPointProcessing = false;
- }
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT,
- s.m_RenderSettings.iVMR9HalfFloatingPointProcessing ? ResStr(IDS_OSD_RS_HALF_FP_PROCESS_ON) : ResStr(IDS_OSD_RS_HALF_FP_PROCESS_OFF));
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.iVMR9HalfFloatingPointProcessing = !s.m_RenderSettings.iVMR9HalfFloatingPointProcessing;
+ if (s.m_RenderSettings.iVMR9HalfFloatingPointProcessing) {
+ s.m_RenderSettings.iVMR9FullFloatingPointProcessing = false;
+ }
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT,
+ s.m_RenderSettings.iVMR9HalfFloatingPointProcessing ? ResStr(IDS_OSD_RS_HALF_FP_PROCESS_ON) : ResStr(IDS_OSD_RS_HALF_FP_PROCESS_OFF));
}
void CMainFrame::OnViewEnableFrameTimeCorrection()
{
- CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
- s.m_RenderSettings.iEVREnableFrameTimeCorrection = !s.m_RenderSettings.iEVREnableFrameTimeCorrection;
- s.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT,
- s.m_RenderSettings.iEVREnableFrameTimeCorrection ? ResStr(IDS_OSD_RS_FT_CORRECTION_ON) : ResStr(IDS_OSD_RS_FT_CORRECTION_OFF));
+ CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
+ s.m_RenderSettings.iEVREnableFrameTimeCorrection = !s.m_RenderSettings.iEVREnableFrameTimeCorrection;
+ s.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT,
+ s.m_RenderSettings.iEVREnableFrameTimeCorrection ? ResStr(IDS_OSD_RS_FT_CORRECTION_ON) : ResStr(IDS_OSD_RS_FT_CORRECTION_OFF));
}
void CMainFrame::OnViewVSyncOffsetIncrease()
{
- AppSettings& s = AfxGetAppSettings();
- CRenderersSettings& r = s.m_RenderersSettings;
- CString strOSD;
- if (s.iDSVideoRendererType == VIDRNDT_DS_SYNC) {
- r.m_RenderSettings.fTargetSyncOffset = r.m_RenderSettings.fTargetSyncOffset - 0.5; // Yeah, it should be a "-"
- strOSD.Format(IDS_OSD_RS_TARGET_VSYNC_OFFSET, r.m_RenderSettings.fTargetSyncOffset);
- } else {
- ++r.m_RenderSettings.iVMR9VSyncOffset;
- strOSD.Format(IDS_OSD_RS_VSYNC_OFFSET, r.m_RenderSettings.iVMR9VSyncOffset);
- }
- r.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT, strOSD);
+ AppSettings& s = AfxGetAppSettings();
+ CRenderersSettings& r = s.m_RenderersSettings;
+ CString strOSD;
+ if (s.iDSVideoRendererType == VIDRNDT_DS_SYNC) {
+ r.m_RenderSettings.fTargetSyncOffset = r.m_RenderSettings.fTargetSyncOffset - 0.5; // Yeah, it should be a "-"
+ strOSD.Format(IDS_OSD_RS_TARGET_VSYNC_OFFSET, r.m_RenderSettings.fTargetSyncOffset);
+ } else {
+ ++r.m_RenderSettings.iVMR9VSyncOffset;
+ strOSD.Format(IDS_OSD_RS_VSYNC_OFFSET, r.m_RenderSettings.iVMR9VSyncOffset);
+ }
+ r.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT, strOSD);
}
void CMainFrame::OnViewVSyncOffsetDecrease()
{
- AppSettings& s = AfxGetAppSettings();
- CRenderersSettings& r = s.m_RenderersSettings;
- CString strOSD;
- if (s.iDSVideoRendererType == VIDRNDT_DS_SYNC) {
- r.m_RenderSettings.fTargetSyncOffset = r.m_RenderSettings.fTargetSyncOffset + 0.5;
- strOSD.Format(IDS_OSD_RS_TARGET_VSYNC_OFFSET, r.m_RenderSettings.fTargetSyncOffset);
- } else {
- --r.m_RenderSettings.iVMR9VSyncOffset;
- strOSD.Format(IDS_OSD_RS_VSYNC_OFFSET, r.m_RenderSettings.iVMR9VSyncOffset);
- }
- r.UpdateData(true);
- m_OSD.DisplayMessage(OSD_TOPRIGHT, strOSD);
+ AppSettings& s = AfxGetAppSettings();
+ CRenderersSettings& r = s.m_RenderersSettings;
+ CString strOSD;
+ if (s.iDSVideoRendererType == VIDRNDT_DS_SYNC) {
+ r.m_RenderSettings.fTargetSyncOffset = r.m_RenderSettings.fTargetSyncOffset + 0.5;
+ strOSD.Format(IDS_OSD_RS_TARGET_VSYNC_OFFSET, r.m_RenderSettings.fTargetSyncOffset);
+ } else {
+ --r.m_RenderSettings.iVMR9VSyncOffset;
+ strOSD.Format(IDS_OSD_RS_VSYNC_OFFSET, r.m_RenderSettings.iVMR9VSyncOffset);
+ }
+ r.UpdateData(true);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT, strOSD);
}
void CMainFrame::OnUpdateViewRemainingTime(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- pCmdUI->Enable (s.fShowOSD && (m_iMediaLoadState != MLS_CLOSED));
- pCmdUI->SetCheck (m_bRemainingTime);
+ AppSettings& s = AfxGetAppSettings();
+ pCmdUI->Enable(s.fShowOSD && (m_iMediaLoadState != MLS_CLOSED));
+ pCmdUI->SetCheck(m_bRemainingTime);
}
void CMainFrame::OnViewRemainingTime()
{
- m_bRemainingTime = !m_bRemainingTime;
+ m_bRemainingTime = !m_bRemainingTime;
- if (!m_bRemainingTime) {
- m_OSD.ClearMessage();
- }
+ if (!m_bRemainingTime) {
+ m_OSD.ClearMessage();
+ }
- OnTimer(TIMER_STREAMPOSPOLLER2);
+ OnTimer(TIMER_STREAMPOSPOLLER2);
}
void CMainFrame::OnUpdateShaderToggle(CCmdUI* pCmdUI)
{
- if (m_shaderlabels.IsEmpty()) {
- pCmdUI->Enable(FALSE);
- m_bToggleShader = false;
- pCmdUI->SetCheck (0);
- } else {
- pCmdUI->Enable(TRUE);
- pCmdUI->SetCheck (m_bToggleShader);
- }
+ if (m_shaderlabels.IsEmpty()) {
+ pCmdUI->Enable(FALSE);
+ m_bToggleShader = false;
+ pCmdUI->SetCheck(0);
+ } else {
+ pCmdUI->Enable(TRUE);
+ pCmdUI->SetCheck(m_bToggleShader);
+ }
}
void CMainFrame::OnUpdateShaderToggleScreenSpace(CCmdUI* pCmdUI)
{
- if (m_shaderlabelsScreenSpace.IsEmpty()) {
- pCmdUI->Enable(FALSE);
- m_bToggleShaderScreenSpace = false;
- pCmdUI->SetCheck(0);
- } else {
- pCmdUI->Enable(TRUE);
- pCmdUI->SetCheck(m_bToggleShaderScreenSpace);
- }
+ if (m_shaderlabelsScreenSpace.IsEmpty()) {
+ pCmdUI->Enable(FALSE);
+ m_bToggleShaderScreenSpace = false;
+ pCmdUI->SetCheck(0);
+ } else {
+ pCmdUI->Enable(TRUE);
+ pCmdUI->SetCheck(m_bToggleShaderScreenSpace);
+ }
}
void CMainFrame::OnShaderToggle()
{
- m_bToggleShader = !m_bToggleShader;
- if (m_bToggleShader) {
- SetShaders();
- m_OSD.DisplayMessage (OSD_TOPRIGHT, ResStr(IDS_MAINFRM_65));
- } else {
- if (m_pCAP) {
- m_pCAP->SetPixelShader(NULL, NULL);
- }
- m_OSD.DisplayMessage (OSD_TOPRIGHT, ResStr(IDS_MAINFRM_66));
- }
+ m_bToggleShader = !m_bToggleShader;
+ if (m_bToggleShader) {
+ SetShaders();
+ m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_MAINFRM_65));
+ } else {
+ if (m_pCAP) {
+ m_pCAP->SetPixelShader(NULL, NULL);
+ }
+ m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_MAINFRM_66));
+ }
}
void CMainFrame::OnShaderToggleScreenSpace()
{
- m_bToggleShaderScreenSpace = !m_bToggleShaderScreenSpace;
- if (m_bToggleShaderScreenSpace) {
- SetShaders();
- m_OSD.DisplayMessage (OSD_TOPRIGHT, ResStr(IDS_MAINFRM_PPONSCR));
- } else {
- if (m_pCAP2) {
- m_pCAP2->SetPixelShader2(NULL, NULL, true);
- }
- m_OSD.DisplayMessage (OSD_TOPRIGHT, ResStr(IDS_MAINFRM_PPOFFSCR));
- }
+ m_bToggleShaderScreenSpace = !m_bToggleShaderScreenSpace;
+ if (m_bToggleShaderScreenSpace) {
+ SetShaders();
+ m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_MAINFRM_PPONSCR));
+ } else {
+ if (m_pCAP2) {
+ m_pCAP2->SetPixelShader2(NULL, NULL, true);
+ }
+ m_OSD.DisplayMessage(OSD_TOPRIGHT, ResStr(IDS_MAINFRM_PPOFFSCR));
+ }
}
void CMainFrame::OnD3DFullscreenToggle()
{
- AppSettings& s = AfxGetAppSettings();
- CString strMsg;
+ AppSettings& s = AfxGetAppSettings();
+ CString strMsg;
- s.fD3DFullscreen = !s.fD3DFullscreen;
- strMsg = s.fD3DFullscreen ? ResStr(IDS_OSD_RS_D3D_FULLSCREEN_ON) : ResStr(IDS_OSD_RS_D3D_FULLSCREEN_OFF);
+ s.fD3DFullscreen = !s.fD3DFullscreen;
+ strMsg = s.fD3DFullscreen ? ResStr(IDS_OSD_RS_D3D_FULLSCREEN_ON) : ResStr(IDS_OSD_RS_D3D_FULLSCREEN_OFF);
- if (m_iMediaLoadState == MLS_CLOSED) {
- m_closingmsg = strMsg;
- } else {
- m_OSD.DisplayMessage (OSD_TOPRIGHT, strMsg);
- }
+ if (m_iMediaLoadState == MLS_CLOSED) {
+ m_closingmsg = strMsg;
+ } else {
+ m_OSD.DisplayMessage(OSD_TOPRIGHT, strMsg);
+ }
}
void CMainFrame::OnFileClosePlaylist()
{
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- RestoreDefaultWindowRect();
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+ RestoreDefaultWindowRect();
}
void CMainFrame::OnUpdateFileClose(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED || m_iMediaLoadState == MLS_LOADING);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED || m_iMediaLoadState == MLS_LOADING);
}
// view
void CMainFrame::OnViewCaptionmenu()
{
- AppSettings& s = AfxGetAppSettings();
- s.iCaptionMenuMode++;
- s.iCaptionMenuMode %= MODE_COUNT; // three states: normal->borderless->frame only->
-
- if ( m_fFullScreen ) {
- return;
- }
-
- DWORD dwRemove = 0, dwAdd = 0;
- DWORD dwFlags = SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER;
- HMENU hMenu = NULL;
-
- CRect wr;
- GetWindowRect( &wr );
-
- switch (s.iCaptionMenuMode) {
- case MODE_SHOWCAPTIONMENU: // borderless -> normal
- dwAdd = WS_CAPTION | WS_THICKFRAME;
- hMenu = m_hMenuDefault;
- wr.right += GetSystemMetrics(SM_CXSIZEFRAME) * 2;
- wr.bottom += GetSystemMetrics(SM_CYSIZEFRAME) * 2;
- wr.bottom += GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYMENU);
- break;
-
- case MODE_HIDEMENU: // normal -> hidemenu
- hMenu = NULL;
- wr.bottom -= GetSystemMetrics(SM_CYMENU);
- break;
-
- case MODE_FRAMEONLY: // hidemenu -> frameonly
- dwRemove = WS_CAPTION;
- wr.right -= 2;
- wr.bottom -= GetSystemMetrics(SM_CYCAPTION) + 2;
- break;
-
- case MODE_BORDERLESS: // frameonly -> borderless
- dwRemove = WS_THICKFRAME;
- wr.right -= GetSystemMetrics(SM_CXSIZEFRAME) * 2 - 2;
- wr.bottom -= GetSystemMetrics(SM_CYSIZEFRAME) * 2 - 2;
- break;
- }
-
- ModifyStyle(dwRemove, dwAdd, SWP_NOZORDER);
- ::SetMenu(m_hWnd, hMenu);
- if (IsZoomed()) { // If the window is maximized, we want it to stay maximized.
- dwFlags |= SWP_NOSIZE;
- }
- // NOTE: wr.left and wr.top are ignored due to SWP_NOMOVE flag
- SetWindowPos(NULL, wr.left, wr.top, wr.Width(), wr.Height(), dwFlags);
-
- MoveVideoWindow();
+ AppSettings& s = AfxGetAppSettings();
+ s.iCaptionMenuMode++;
+ s.iCaptionMenuMode %= MODE_COUNT; // three states: normal->borderless->frame only->
+
+ if (m_fFullScreen) {
+ return;
+ }
+
+ DWORD dwRemove = 0, dwAdd = 0;
+ DWORD dwFlags = SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER;
+ HMENU hMenu = NULL;
+
+ CRect wr;
+ GetWindowRect(&wr);
+
+ switch (s.iCaptionMenuMode) {
+ case MODE_SHOWCAPTIONMENU: // borderless -> normal
+ dwAdd = WS_CAPTION | WS_THICKFRAME;
+ hMenu = m_hMenuDefault;
+ wr.right += GetSystemMetrics(SM_CXSIZEFRAME) * 2;
+ wr.bottom += GetSystemMetrics(SM_CYSIZEFRAME) * 2;
+ wr.bottom += GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYMENU);
+ break;
+
+ case MODE_HIDEMENU: // normal -> hidemenu
+ hMenu = NULL;
+ wr.bottom -= GetSystemMetrics(SM_CYMENU);
+ break;
+
+ case MODE_FRAMEONLY: // hidemenu -> frameonly
+ dwRemove = WS_CAPTION;
+ wr.right -= 2;
+ wr.bottom -= GetSystemMetrics(SM_CYCAPTION) + 2;
+ break;
+
+ case MODE_BORDERLESS: // frameonly -> borderless
+ dwRemove = WS_THICKFRAME;
+ wr.right -= GetSystemMetrics(SM_CXSIZEFRAME) * 2 - 2;
+ wr.bottom -= GetSystemMetrics(SM_CYSIZEFRAME) * 2 - 2;
+ break;
+ }
+
+ ModifyStyle(dwRemove, dwAdd, SWP_NOZORDER);
+ ::SetMenu(m_hWnd, hMenu);
+ if (IsZoomed()) { // If the window is maximized, we want it to stay maximized.
+ dwFlags |= SWP_NOSIZE;
+ }
+ // NOTE: wr.left and wr.top are ignored due to SWP_NOMOVE flag
+ SetWindowPos(NULL, wr.left, wr.top, wr.Width(), wr.Height(), dwFlags);
+
+ MoveVideoWindow();
}
void CMainFrame::OnUpdateViewCaptionmenu(CCmdUI* pCmdUI)
{
- static int NEXT_MODE[] = {IDS_VIEW_HIDEMENU, IDS_VIEW_FRAMEONLY, IDS_VIEW_BORDERLESS, IDS_VIEW_CAPTIONMENU};
- int idx = (AfxGetAppSettings().iCaptionMenuMode %= MODE_COUNT);
- pCmdUI->SetText(ResStr(NEXT_MODE[idx]));
+ static int NEXT_MODE[] = {IDS_VIEW_HIDEMENU, IDS_VIEW_FRAMEONLY, IDS_VIEW_BORDERLESS, IDS_VIEW_CAPTIONMENU};
+ int idx = (AfxGetAppSettings().iCaptionMenuMode %= MODE_COUNT);
+ pCmdUI->SetText(ResStr(NEXT_MODE[idx]));
}
void CMainFrame::OnViewControlBar(UINT nID)
{
- nID -= ID_VIEW_SEEKER;
- UINT bitID = (1u << nID);
+ nID -= ID_VIEW_SEEKER;
+ UINT bitID = (1u << nID);
- // Remember the change
- AfxGetAppSettings().nCS ^= bitID;
+ // Remember the change
+ AfxGetAppSettings().nCS ^= bitID;
- ShowControls(m_nCS ^ bitID, true);
+ ShowControls(m_nCS ^ bitID, true);
}
void CMainFrame::OnUpdateViewControlBar(CCmdUI* pCmdUI)
{
- UINT nID = pCmdUI->m_nID - ID_VIEW_SEEKER;
- pCmdUI->SetCheck(!!(m_nCS & (1<<nID)));
+ UINT nID = pCmdUI->m_nID - ID_VIEW_SEEKER;
+ pCmdUI->SetCheck(!!(m_nCS & (1 << nID)));
- if (pCmdUI->m_nID == ID_VIEW_SEEKER) {
- pCmdUI->Enable(GetPlaybackMode() != PM_CAPTURE);
- }
+ if (pCmdUI->m_nID == ID_VIEW_SEEKER) {
+ pCmdUI->Enable(GetPlaybackMode() != PM_CAPTURE);
+ }
}
void CMainFrame::OnViewSubresync()
{
- ShowControlBar(&m_wndSubresyncBar, !m_wndSubresyncBar.IsWindowVisible(), TRUE);
+ ShowControlBar(&m_wndSubresyncBar, !m_wndSubresyncBar.IsWindowVisible(), TRUE);
}
void CMainFrame::OnUpdateViewSubresync(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(m_wndSubresyncBar.IsWindowVisible());
- pCmdUI->Enable(m_pCAP && m_iSubtitleSel >= 0);
+ pCmdUI->SetCheck(m_wndSubresyncBar.IsWindowVisible());
+ pCmdUI->Enable(m_pCAP && m_iSubtitleSel >= 0);
}
void CMainFrame::OnViewPlaylist()
{
- ShowControlBar(&m_wndPlaylistBar, !m_wndPlaylistBar.IsWindowVisible(), TRUE);
+ ShowControlBar(&m_wndPlaylistBar, !m_wndPlaylistBar.IsWindowVisible(), TRUE);
}
void CMainFrame::OnUpdateViewPlaylist(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(m_wndPlaylistBar.IsWindowVisible());
- pCmdUI->Enable(m_iMediaLoadState == MLS_CLOSED && m_iMediaLoadState != MLS_LOADED
- || m_iMediaLoadState == MLS_LOADED /*&& (GetPlaybackMode() == PM_FILE || GetPlaybackMode() == PM_CAPTURE)*/);
+ pCmdUI->SetCheck(m_wndPlaylistBar.IsWindowVisible());
+ pCmdUI->Enable(m_iMediaLoadState == MLS_CLOSED && m_iMediaLoadState != MLS_LOADED
+ || m_iMediaLoadState == MLS_LOADED /*&& (GetPlaybackMode() == PM_FILE || GetPlaybackMode() == PM_CAPTURE)*/);
}
void CMainFrame::OnViewEditListEditor()
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- if (s.fEnableEDLEditor || (AfxMessageBox(IDS_MB_SHOW_EDL_EDITOR, MB_ICONQUESTION | MB_YESNO, 0) == IDYES)) {
- s.fEnableEDLEditor = true;
- ShowControlBar(&m_wndEditListEditor, !m_wndEditListEditor.IsWindowVisible(), TRUE);
- }
+ if (s.fEnableEDLEditor || (AfxMessageBox(IDS_MB_SHOW_EDL_EDITOR, MB_ICONQUESTION | MB_YESNO, 0) == IDYES)) {
+ s.fEnableEDLEditor = true;
+ ShowControlBar(&m_wndEditListEditor, !m_wndEditListEditor.IsWindowVisible(), TRUE);
+ }
}
void CMainFrame::OnEDLIn()
{
- if (AfxGetAppSettings().fEnableEDLEditor && (m_iMediaLoadState == MLS_LOADED) && (GetPlaybackMode() == PM_FILE)) {
- REFERENCE_TIME rt;
+ if (AfxGetAppSettings().fEnableEDLEditor && (m_iMediaLoadState == MLS_LOADED) && (GetPlaybackMode() == PM_FILE)) {
+ REFERENCE_TIME rt;
- pMS->GetCurrentPosition(&rt);
- m_wndEditListEditor.SetIn(rt);
- }
+ pMS->GetCurrentPosition(&rt);
+ m_wndEditListEditor.SetIn(rt);
+ }
}
void CMainFrame::OnUpdateEDLIn(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_wndEditListEditor.IsWindowVisible());
+ pCmdUI->Enable(m_wndEditListEditor.IsWindowVisible());
}
void CMainFrame::OnEDLOut()
{
- if (AfxGetAppSettings().fEnableEDLEditor && (m_iMediaLoadState == MLS_LOADED) && (GetPlaybackMode() == PM_FILE)) {
- REFERENCE_TIME rt;
+ if (AfxGetAppSettings().fEnableEDLEditor && (m_iMediaLoadState == MLS_LOADED) && (GetPlaybackMode() == PM_FILE)) {
+ REFERENCE_TIME rt;
- pMS->GetCurrentPosition(&rt);
- m_wndEditListEditor.SetOut(rt);
- }
+ pMS->GetCurrentPosition(&rt);
+ m_wndEditListEditor.SetOut(rt);
+ }
}
void CMainFrame::OnUpdateEDLOut(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_wndEditListEditor.IsWindowVisible());
+ pCmdUI->Enable(m_wndEditListEditor.IsWindowVisible());
}
void CMainFrame::OnEDLNewClip()
{
- if (AfxGetAppSettings().fEnableEDLEditor && (m_iMediaLoadState == MLS_LOADED) && (GetPlaybackMode() == PM_FILE)) {
- REFERENCE_TIME rt;
+ if (AfxGetAppSettings().fEnableEDLEditor && (m_iMediaLoadState == MLS_LOADED) && (GetPlaybackMode() == PM_FILE)) {
+ REFERENCE_TIME rt;
- pMS->GetCurrentPosition(&rt);
- m_wndEditListEditor.NewClip(rt);
- }
+ pMS->GetCurrentPosition(&rt);
+ m_wndEditListEditor.NewClip(rt);
+ }
}
void CMainFrame::OnUpdateEDLNewClip(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_wndEditListEditor.IsWindowVisible());
+ pCmdUI->Enable(m_wndEditListEditor.IsWindowVisible());
}
void CMainFrame::OnEDLSave()
{
- if (AfxGetAppSettings().fEnableEDLEditor && (m_iMediaLoadState == MLS_LOADED) && (GetPlaybackMode() == PM_FILE)) {
- m_wndEditListEditor.Save();
- }
+ if (AfxGetAppSettings().fEnableEDLEditor && (m_iMediaLoadState == MLS_LOADED) && (GetPlaybackMode() == PM_FILE)) {
+ m_wndEditListEditor.Save();
+ }
}
void CMainFrame::OnUpdateEDLSave(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_wndEditListEditor.IsWindowVisible());
+ pCmdUI->Enable(m_wndEditListEditor.IsWindowVisible());
}
// Navigation menu
void CMainFrame::OnViewNavigation()
{
- AppSettings& s = AfxGetAppSettings();
- s.fHideNavigation = !s.fHideNavigation;
- m_wndNavigationBar.m_navdlg.UpdateElementList();
- if (GetPlaybackMode() == PM_CAPTURE) {
- ShowControlBar(&m_wndNavigationBar, !s.fHideNavigation, TRUE);
- }
+ AppSettings& s = AfxGetAppSettings();
+ s.fHideNavigation = !s.fHideNavigation;
+ m_wndNavigationBar.m_navdlg.UpdateElementList();
+ if (GetPlaybackMode() == PM_CAPTURE) {
+ ShowControlBar(&m_wndNavigationBar, !s.fHideNavigation, TRUE);
+ }
}
void CMainFrame::OnUpdateViewNavigation(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(!AfxGetAppSettings().fHideNavigation);
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && GetPlaybackMode() == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1);
+ pCmdUI->SetCheck(!AfxGetAppSettings().fHideNavigation);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && GetPlaybackMode() == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1);
}
void CMainFrame::OnViewCapture()
{
- ShowControlBar(&m_wndCaptureBar, !m_wndCaptureBar.IsWindowVisible(), TRUE);
+ ShowControlBar(&m_wndCaptureBar, !m_wndCaptureBar.IsWindowVisible(), TRUE);
}
void CMainFrame::OnUpdateViewCapture(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(m_wndCaptureBar.IsWindowVisible());
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && GetPlaybackMode() == PM_CAPTURE);
+ pCmdUI->SetCheck(m_wndCaptureBar.IsWindowVisible());
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && GetPlaybackMode() == PM_CAPTURE);
}
void CMainFrame::OnViewShaderEditor()
{
- ShowControlBar(&m_wndShaderEditorBar, !m_wndShaderEditorBar.IsWindowVisible(), TRUE);
+ ShowControlBar(&m_wndShaderEditorBar, !m_wndShaderEditorBar.IsWindowVisible(), TRUE);
}
void CMainFrame::OnUpdateViewShaderEditor(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(m_wndShaderEditorBar.IsWindowVisible());
- pCmdUI->Enable(TRUE);
+ pCmdUI->SetCheck(m_wndShaderEditorBar.IsWindowVisible());
+ pCmdUI->Enable(TRUE);
}
void CMainFrame::OnViewMinimal()
{
- SetUIPreset(MODE_BORDERLESS, CS_NONE);
+ SetUIPreset(MODE_BORDERLESS, CS_NONE);
}
void CMainFrame::OnUpdateViewMinimal(CCmdUI* pCmdUI)
@@ -6506,7 +6506,7 @@ void CMainFrame::OnUpdateViewMinimal(CCmdUI* pCmdUI)
void CMainFrame::OnViewCompact()
{
- SetUIPreset(MODE_FRAMEONLY, CS_SEEKBAR);
+ SetUIPreset(MODE_FRAMEONLY, CS_SEEKBAR);
}
void CMainFrame::OnUpdateViewCompact(CCmdUI* pCmdUI)
@@ -6515,7 +6515,7 @@ void CMainFrame::OnUpdateViewCompact(CCmdUI* pCmdUI)
void CMainFrame::OnViewNormal()
{
- SetUIPreset(MODE_SHOWCAPTIONMENU, CS_SEEKBAR|CS_TOOLBAR|CS_STATUSBAR|CS_INFOBAR);
+ SetUIPreset(MODE_SHOWCAPTIONMENU, CS_SEEKBAR | CS_TOOLBAR | CS_STATUSBAR | CS_INFOBAR);
}
void CMainFrame::OnUpdateViewNormal(CCmdUI* pCmdUI)
@@ -6524,3793 +6524,3787 @@ void CMainFrame::OnUpdateViewNormal(CCmdUI* pCmdUI)
void CMainFrame::SetUIPreset(int iCaptionMenuMode, UINT nCS)
{
- while (AfxGetAppSettings().iCaptionMenuMode != iCaptionMenuMode) {
- SendMessage(WM_COMMAND, ID_VIEW_CAPTIONMENU);
- }
+ while (AfxGetAppSettings().iCaptionMenuMode != iCaptionMenuMode) {
+ SendMessage(WM_COMMAND, ID_VIEW_CAPTIONMENU);
+ }
- // Remember the change
- AfxGetAppSettings().nCS = nCS;
- // Hide seek bar on capture mode
- if (GetPlaybackMode() == PM_CAPTURE) {
- nCS &= ~CS_SEEKBAR;
- }
- ShowControls(nCS, true);
+ // Remember the change
+ AfxGetAppSettings().nCS = nCS;
+ // Hide seek bar on capture mode
+ if (GetPlaybackMode() == PM_CAPTURE) {
+ nCS &= ~CS_SEEKBAR;
+ }
+ ShowControls(nCS, true);
}
void CMainFrame::OnViewFullscreen()
{
- ToggleFullscreen(true, true);
+ ToggleFullscreen(true, true);
}
void CMainFrame::OnViewFullscreenSecondary()
{
- ToggleFullscreen(true, false);
+ ToggleFullscreen(true, false);
}
void CMainFrame::OnUpdateViewFullscreen(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly || m_fFullScreen);
- pCmdUI->SetCheck(m_fFullScreen);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly || m_fFullScreen);
+ pCmdUI->SetCheck(m_fFullScreen);
}
void CMainFrame::OnViewZoom(UINT nID)
{
- double scale = (nID == ID_VIEW_ZOOM_50) ? 0.5 : (nID == ID_VIEW_ZOOM_200) ? 2.0 : 1.0;
+ double scale = (nID == ID_VIEW_ZOOM_50) ? 0.5 : (nID == ID_VIEW_ZOOM_200) ? 2.0 : 1.0;
- ZoomVideoWindow(true, scale);
+ ZoomVideoWindow(true, scale);
- CString strODSMessage;
- strODSMessage.Format(IDS_OSD_ZOOM, scale * 100);
- m_OSD.DisplayMessage(OSD_TOPLEFT, strODSMessage, 3000);
+ CString strODSMessage;
+ strODSMessage.Format(IDS_OSD_ZOOM, scale * 100);
+ m_OSD.DisplayMessage(OSD_TOPLEFT, strODSMessage, 3000);
}
void CMainFrame::OnUpdateViewZoom(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
}
void CMainFrame::OnViewZoomAutoFit()
{
- ZoomVideoWindow(true, GetZoomAutoFitScale(false));
- m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_OSD_ZOOM_AUTO), 3000);
+ ZoomVideoWindow(true, GetZoomAutoFitScale(false));
+ m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_OSD_ZOOM_AUTO), 3000);
}
void CMainFrame::OnViewZoomAutoFitLarger()
{
- ZoomVideoWindow(true, GetZoomAutoFitScale(true));
- m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_OSD_ZOOM_AUTO_LARGER), 3000);
+ ZoomVideoWindow(true, GetZoomAutoFitScale(true));
+ m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_OSD_ZOOM_AUTO_LARGER), 3000);
}
void CMainFrame::OnViewDefaultVideoFrame(UINT nID)
{
- AfxGetAppSettings().iDefaultVideoSize = nID - ID_VIEW_VF_HALF;
- m_ZoomX = m_ZoomY = 1;
- m_PosX = m_PosY = 0.5;
- MoveVideoWindow();
+ AfxGetAppSettings().iDefaultVideoSize = nID - ID_VIEW_VF_HALF;
+ m_ZoomX = m_ZoomY = 1;
+ m_PosX = m_PosY = 0.5;
+ MoveVideoWindow();
}
void CMainFrame::OnUpdateViewDefaultVideoFrame(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
- int dvs = pCmdUI->m_nID - ID_VIEW_VF_HALF;
- pCmdUI->SetRadio(AfxGetAppSettings().iDefaultVideoSize == dvs);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
+ int dvs = pCmdUI->m_nID - ID_VIEW_VF_HALF;
+ pCmdUI->SetRadio(AfxGetAppSettings().iDefaultVideoSize == dvs);
}
void CMainFrame::OnViewSwitchVideoFrame()
{
- int vs = AfxGetAppSettings().iDefaultVideoSize;
- if (vs <= DVS_DOUBLE || vs == DVS_FROMOUTSIDE) {
- vs = DVS_STRETCH;
- } else if (vs == DVS_FROMINSIDE) {
- vs = DVS_ZOOM1;
- } else if (vs == DVS_ZOOM2) {
- vs = DVS_FROMOUTSIDE;
- } else {
- vs++;
- }
- switch (vs) { // TODO: Read messages from resource file
- case DVS_STRETCH:
- m_OSD.DisplayMessage (OSD_TOPLEFT, ResStr(IDS_STRETCH_TO_WINDOW));
- break;
- case DVS_FROMINSIDE:
- m_OSD.DisplayMessage (OSD_TOPLEFT, ResStr(IDS_TOUCH_WINDOW_FROM_INSIDE));
- break;
- case DVS_ZOOM1:
- m_OSD.DisplayMessage (OSD_TOPLEFT, ResStr(IDS_ZOOM1));
- break;
- case DVS_ZOOM2:
- m_OSD.DisplayMessage (OSD_TOPLEFT, ResStr(IDS_ZOOM2));
- break;
- case DVS_FROMOUTSIDE:
- m_OSD.DisplayMessage (OSD_TOPLEFT, ResStr(IDS_TOUCH_WINDOW_FROM_OUTSIDE));
- break;
- }
- AfxGetAppSettings().iDefaultVideoSize = vs;
- m_ZoomX = m_ZoomY = 1;
- m_PosX = m_PosY = 0.5;
- MoveVideoWindow();
+ int vs = AfxGetAppSettings().iDefaultVideoSize;
+ if (vs <= DVS_DOUBLE || vs == DVS_FROMOUTSIDE) {
+ vs = DVS_STRETCH;
+ } else if (vs == DVS_FROMINSIDE) {
+ vs = DVS_ZOOM1;
+ } else if (vs == DVS_ZOOM2) {
+ vs = DVS_FROMOUTSIDE;
+ } else {
+ vs++;
+ }
+ switch (vs) { // TODO: Read messages from resource file
+ case DVS_STRETCH:
+ m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_STRETCH_TO_WINDOW));
+ break;
+ case DVS_FROMINSIDE:
+ m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_TOUCH_WINDOW_FROM_INSIDE));
+ break;
+ case DVS_ZOOM1:
+ m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_ZOOM1));
+ break;
+ case DVS_ZOOM2:
+ m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_ZOOM2));
+ break;
+ case DVS_FROMOUTSIDE:
+ m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_TOUCH_WINDOW_FROM_OUTSIDE));
+ break;
+ }
+ AfxGetAppSettings().iDefaultVideoSize = vs;
+ m_ZoomX = m_ZoomY = 1;
+ m_PosX = m_PosY = 0.5;
+ MoveVideoWindow();
}
void CMainFrame::OnViewKeepaspectratio()
{
- AfxGetAppSettings().fKeepAspectRatio = !AfxGetAppSettings().fKeepAspectRatio;
- MoveVideoWindow();
+ AfxGetAppSettings().fKeepAspectRatio = !AfxGetAppSettings().fKeepAspectRatio;
+ MoveVideoWindow();
}
void CMainFrame::OnUpdateViewKeepaspectratio(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
- pCmdUI->SetCheck(AfxGetAppSettings().fKeepAspectRatio);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
+ pCmdUI->SetCheck(AfxGetAppSettings().fKeepAspectRatio);
}
void CMainFrame::OnViewCompMonDeskARDiff()
{
- AfxGetAppSettings().fCompMonDeskARDiff = !AfxGetAppSettings().fCompMonDeskARDiff;
- MoveVideoWindow();
+ AfxGetAppSettings().fCompMonDeskARDiff = !AfxGetAppSettings().fCompMonDeskARDiff;
+ MoveVideoWindow();
}
void CMainFrame::OnUpdateViewCompMonDeskARDiff(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
- pCmdUI->SetCheck(AfxGetAppSettings().fCompMonDeskARDiff);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
+ pCmdUI->SetCheck(AfxGetAppSettings().fCompMonDeskARDiff);
}
void CMainFrame::OnViewPanNScan(UINT nID)
{
- if (m_iMediaLoadState != MLS_LOADED) {
- return;
- }
-
- int x = 0, y = 0;
- int dx = 0, dy = 0;
-
- switch (nID) {
- case ID_VIEW_RESET:
- m_ZoomX = m_ZoomY = 1.0;
- m_PosX = m_PosY = 0.5;
- m_AngleX = m_AngleY = m_AngleZ = 0;
- break;
- case ID_VIEW_INCSIZE:
- x = y = 1;
- break;
- case ID_VIEW_DECSIZE:
- x = y = -1;
- break;
- case ID_VIEW_INCWIDTH:
- x = 1;
- break;
- case ID_VIEW_DECWIDTH:
- x = -1;
- break;
- case ID_VIEW_INCHEIGHT:
- y = 1;
- break;
- case ID_VIEW_DECHEIGHT:
- y = -1;
- break;
- case ID_PANSCAN_CENTER:
- m_PosX = m_PosY = 0.5;
- break;
- case ID_PANSCAN_MOVELEFT:
- dx = -1;
- break;
- case ID_PANSCAN_MOVERIGHT:
- dx = 1;
- break;
- case ID_PANSCAN_MOVEUP:
- dy = -1;
- break;
- case ID_PANSCAN_MOVEDOWN:
- dy = 1;
- break;
- case ID_PANSCAN_MOVEUPLEFT:
- dx = dy = -1;
- break;
- case ID_PANSCAN_MOVEUPRIGHT:
- dx = 1;
- dy = -1;
- break;
- case ID_PANSCAN_MOVEDOWNLEFT:
- dx = -1;
- dy = 1;
- break;
- case ID_PANSCAN_MOVEDOWNRIGHT:
- dx = dy = 1;
- break;
- default:
- break;
- }
-
- if (x > 0 && m_ZoomX < 3) {
- m_ZoomX *= 1.02;
- } else if (x < 0 && m_ZoomX > 0.2) {
- m_ZoomX /= 1.02;
- }
-
- if (y > 0 && m_ZoomY < 3) {
- m_ZoomY *= 1.02;
- } else if (y < 0 && m_ZoomY > 0.2) {
- m_ZoomY /= 1.02;
- }
-
- if (dx < 0 && m_PosX > 0) {
- m_PosX = max(m_PosX - 0.005*m_ZoomX, 0);
- } else if (dx > 0 && m_PosX < 1) {
- m_PosX = min(m_PosX + 0.005*m_ZoomX, 1);
- }
-
- if (dy < 0 && m_PosY > 0) {
- m_PosY = max(m_PosY - 0.005*m_ZoomY, 0);
- } else if (dy > 0 && m_PosY < 1) {
- m_PosY = min(m_PosY + 0.005*m_ZoomY, 1);
- }
-
- MoveVideoWindow(true);
+ if (m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
+
+ int x = 0, y = 0;
+ int dx = 0, dy = 0;
+
+ switch (nID) {
+ case ID_VIEW_RESET:
+ m_ZoomX = m_ZoomY = 1.0;
+ m_PosX = m_PosY = 0.5;
+ m_AngleX = m_AngleY = m_AngleZ = 0;
+ break;
+ case ID_VIEW_INCSIZE:
+ x = y = 1;
+ break;
+ case ID_VIEW_DECSIZE:
+ x = y = -1;
+ break;
+ case ID_VIEW_INCWIDTH:
+ x = 1;
+ break;
+ case ID_VIEW_DECWIDTH:
+ x = -1;
+ break;
+ case ID_VIEW_INCHEIGHT:
+ y = 1;
+ break;
+ case ID_VIEW_DECHEIGHT:
+ y = -1;
+ break;
+ case ID_PANSCAN_CENTER:
+ m_PosX = m_PosY = 0.5;
+ break;
+ case ID_PANSCAN_MOVELEFT:
+ dx = -1;
+ break;
+ case ID_PANSCAN_MOVERIGHT:
+ dx = 1;
+ break;
+ case ID_PANSCAN_MOVEUP:
+ dy = -1;
+ break;
+ case ID_PANSCAN_MOVEDOWN:
+ dy = 1;
+ break;
+ case ID_PANSCAN_MOVEUPLEFT:
+ dx = dy = -1;
+ break;
+ case ID_PANSCAN_MOVEUPRIGHT:
+ dx = 1;
+ dy = -1;
+ break;
+ case ID_PANSCAN_MOVEDOWNLEFT:
+ dx = -1;
+ dy = 1;
+ break;
+ case ID_PANSCAN_MOVEDOWNRIGHT:
+ dx = dy = 1;
+ break;
+ default:
+ break;
+ }
+
+ if (x > 0 && m_ZoomX < 3) {
+ m_ZoomX *= 1.02;
+ } else if (x < 0 && m_ZoomX > 0.2) {
+ m_ZoomX /= 1.02;
+ }
+
+ if (y > 0 && m_ZoomY < 3) {
+ m_ZoomY *= 1.02;
+ } else if (y < 0 && m_ZoomY > 0.2) {
+ m_ZoomY /= 1.02;
+ }
+
+ if (dx < 0 && m_PosX > 0) {
+ m_PosX = max(m_PosX - 0.005 * m_ZoomX, 0);
+ } else if (dx > 0 && m_PosX < 1) {
+ m_PosX = min(m_PosX + 0.005 * m_ZoomX, 1);
+ }
+
+ if (dy < 0 && m_PosY > 0) {
+ m_PosY = max(m_PosY - 0.005 * m_ZoomY, 0);
+ } else if (dy > 0 && m_PosY < 1) {
+ m_PosY = min(m_PosY + 0.005 * m_ZoomY, 1);
+ }
+
+ MoveVideoWindow(true);
}
void CMainFrame::OnUpdateViewPanNScan(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
}
void CMainFrame::OnViewPanNScanPresets(UINT nID)
{
- if (m_iMediaLoadState != MLS_LOADED) {
- return;
- }
-
- AppSettings& s = AfxGetAppSettings();
-
- nID -= ID_PANNSCAN_PRESETS_START;
-
- if ((INT_PTR)nID == s.m_pnspresets.GetCount()) {
- CPnSPresetsDlg dlg;
- dlg.m_pnspresets.Copy(s.m_pnspresets);
- if (dlg.DoModal() == IDOK) {
- s.m_pnspresets.Copy(dlg.m_pnspresets);
- s.UpdateData(true);
- }
- return;
- }
-
- m_PosX = 0.5;
- m_PosY = 0.5;
- m_ZoomX = 1.0;
- m_ZoomY = 1.0;
-
- CString str = s.m_pnspresets[nID];
-
- int i = 0, j = 0;
- for (CString token = str.Tokenize(_T(","), i); !token.IsEmpty(); token = str.Tokenize(_T(","), i), j++) {
- float f = 0;
- if (_stscanf_s(token, _T("%f"), &f) != 1) {
- continue;
- }
-
- switch (j) {
- case 0:
- break;
- case 1:
- m_PosX = f;
- break;
- case 2:
- m_PosY = f;
- break;
- case 3:
- m_ZoomX = f;
- break;
- case 4:
- m_ZoomY = f;
- break;
- default:
- break;
- }
- }
-
- if (j != 5) {
- return;
- }
-
- m_PosX = min(max(m_PosX, 0), 1);
- m_PosY = min(max(m_PosY, 0), 1);
- m_ZoomX = min(max(m_ZoomX, 0.2), 3);
- m_ZoomY = min(max(m_ZoomY, 0.2), 3);
-
- MoveVideoWindow(true);
+ if (m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
+
+ AppSettings& s = AfxGetAppSettings();
+
+ nID -= ID_PANNSCAN_PRESETS_START;
+
+ if ((INT_PTR)nID == s.m_pnspresets.GetCount()) {
+ CPnSPresetsDlg dlg;
+ dlg.m_pnspresets.Copy(s.m_pnspresets);
+ if (dlg.DoModal() == IDOK) {
+ s.m_pnspresets.Copy(dlg.m_pnspresets);
+ s.UpdateData(true);
+ }
+ return;
+ }
+
+ m_PosX = 0.5;
+ m_PosY = 0.5;
+ m_ZoomX = 1.0;
+ m_ZoomY = 1.0;
+
+ CString str = s.m_pnspresets[nID];
+
+ int i = 0, j = 0;
+ for (CString token = str.Tokenize(_T(","), i); !token.IsEmpty(); token = str.Tokenize(_T(","), i), j++) {
+ float f = 0;
+ if (_stscanf_s(token, _T("%f"), &f) != 1) {
+ continue;
+ }
+
+ switch (j) {
+ case 0:
+ break;
+ case 1:
+ m_PosX = f;
+ break;
+ case 2:
+ m_PosY = f;
+ break;
+ case 3:
+ m_ZoomX = f;
+ break;
+ case 4:
+ m_ZoomY = f;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (j != 5) {
+ return;
+ }
+
+ m_PosX = min(max(m_PosX, 0), 1);
+ m_PosY = min(max(m_PosY, 0), 1);
+ m_ZoomX = min(max(m_ZoomX, 0.2), 3);
+ m_ZoomY = min(max(m_ZoomY, 0.2), 3);
+
+ MoveVideoWindow(true);
}
void CMainFrame::OnUpdateViewPanNScanPresets(CCmdUI* pCmdUI)
{
- int nID = pCmdUI->m_nID - ID_PANNSCAN_PRESETS_START;
- AppSettings& s = AfxGetAppSettings();
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly && nID >= 0 && nID <= s.m_pnspresets.GetCount());
+ int nID = pCmdUI->m_nID - ID_PANNSCAN_PRESETS_START;
+ AppSettings& s = AfxGetAppSettings();
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly && nID >= 0 && nID <= s.m_pnspresets.GetCount());
}
void CMainFrame::OnViewRotate(UINT nID)
{
- if (!m_pCAP) {
- return;
- }
-
- switch (nID) {
- case ID_PANSCAN_ROTATEXP:
- m_AngleX += 2;
- break;
- case ID_PANSCAN_ROTATEXM:
- m_AngleX -= 2;
- break;
- case ID_PANSCAN_ROTATEYP:
- m_AngleY += 2;
- break;
- case ID_PANSCAN_ROTATEYM:
- m_AngleY -= 2;
- break;
- case ID_PANSCAN_ROTATEZP:
- m_AngleZ += 2;
- break;
- case ID_PANSCAN_ROTATEZM:
- m_AngleZ -= 2;
- break;
- default:
- return;
- }
-
- m_pCAP->SetVideoAngle(Vector(Vector::DegToRad(m_AngleX), Vector::DegToRad(m_AngleY), Vector::DegToRad(m_AngleZ)));
-
- CString info;
- info.Format(_T("x: %d, y: %d, z: %d"), m_AngleX, m_AngleY, m_AngleZ);
- SendStatusMessage(info, 3000);
+ if (!m_pCAP) {
+ return;
+ }
+
+ switch (nID) {
+ case ID_PANSCAN_ROTATEXP:
+ m_AngleX += 2;
+ break;
+ case ID_PANSCAN_ROTATEXM:
+ m_AngleX -= 2;
+ break;
+ case ID_PANSCAN_ROTATEYP:
+ m_AngleY += 2;
+ break;
+ case ID_PANSCAN_ROTATEYM:
+ m_AngleY -= 2;
+ break;
+ case ID_PANSCAN_ROTATEZP:
+ m_AngleZ += 2;
+ break;
+ case ID_PANSCAN_ROTATEZM:
+ m_AngleZ -= 2;
+ break;
+ default:
+ return;
+ }
+
+ m_pCAP->SetVideoAngle(Vector(Vector::DegToRad(m_AngleX), Vector::DegToRad(m_AngleY), Vector::DegToRad(m_AngleZ)));
+
+ CString info;
+ info.Format(_T("x: %d, y: %d, z: %d"), m_AngleX, m_AngleY, m_AngleZ);
+ SendStatusMessage(info, 3000);
}
void CMainFrame::OnUpdateViewRotate(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly && m_pCAP);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly && m_pCAP);
}
// FIXME
-const static SIZE s_ar[] = {{0,0}, {4,3}, {5,4}, {16,9}, {235,100}, {185,100}};
+const static SIZE s_ar[] = {{0, 0}, {4, 3}, {5, 4}, {16, 9}, {235, 100}, {185, 100}};
void CMainFrame::OnViewAspectRatio(UINT nID)
{
- CSize& ar = AfxGetAppSettings().sizeAspectRatio;
+ CSize& ar = AfxGetAppSettings().sizeAspectRatio;
- ar = s_ar[nID - ID_ASPECTRATIO_START];
+ ar = s_ar[nID - ID_ASPECTRATIO_START];
- CString info;
- if (ar.cx && ar.cy) {
- info.Format(IDS_MAINFRM_68, ar.cx, ar.cy);
- } else {
- info.LoadString(IDS_MAINFRM_69);
- }
- SendStatusMessage(info, 3000);
+ CString info;
+ if (ar.cx && ar.cy) {
+ info.Format(IDS_MAINFRM_68, ar.cx, ar.cy);
+ } else {
+ info.LoadString(IDS_MAINFRM_69);
+ }
+ SendStatusMessage(info, 3000);
- m_OSD.DisplayMessage(OSD_TOPLEFT, info, 3000);
+ m_OSD.DisplayMessage(OSD_TOPLEFT, info, 3000);
- MoveVideoWindow();
+ MoveVideoWindow();
}
void CMainFrame::OnUpdateViewAspectRatio(CCmdUI* pCmdUI)
{
- pCmdUI->SetRadio(AfxGetAppSettings().sizeAspectRatio == s_ar[pCmdUI->m_nID - ID_ASPECTRATIO_START]);
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
+ pCmdUI->SetRadio(AfxGetAppSettings().sizeAspectRatio == s_ar[pCmdUI->m_nID - ID_ASPECTRATIO_START]);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly);
}
void CMainFrame::OnViewAspectRatioNext()
{
- CSize& ar = AfxGetAppSettings().sizeAspectRatio;
+ CSize& ar = AfxGetAppSettings().sizeAspectRatio;
- UINT nID = ID_ASPECTRATIO_START;
+ UINT nID = ID_ASPECTRATIO_START;
- for (int i = 0; i < _countof(s_ar); i++) {
- if (ar == s_ar[i]) {
- nID += (i + 1) % _countof(s_ar);
- break;
- }
- }
+ for (int i = 0; i < _countof(s_ar); i++) {
+ if (ar == s_ar[i]) {
+ nID += (i + 1) % _countof(s_ar);
+ break;
+ }
+ }
- OnViewAspectRatio(nID);
+ OnViewAspectRatio(nID);
}
void CMainFrame::OnViewOntop(UINT nID)
{
- nID -= ID_ONTOP_NEVER;
- if (AfxGetAppSettings().iOnTop == (int)nID) {
- nID = !nID;
- }
- SetAlwaysOnTop(nID);
+ nID -= ID_ONTOP_NEVER;
+ if (AfxGetAppSettings().iOnTop == (int)nID) {
+ nID = !nID;
+ }
+ SetAlwaysOnTop(nID);
}
void CMainFrame::OnUpdateViewOntop(CCmdUI* pCmdUI)
{
- int onTop = pCmdUI->m_nID - ID_ONTOP_NEVER;
- pCmdUI->SetRadio(AfxGetAppSettings().iOnTop == onTop);
+ int onTop = pCmdUI->m_nID - ID_ONTOP_NEVER;
+ pCmdUI->SetRadio(AfxGetAppSettings().iOnTop == onTop);
}
void CMainFrame::OnViewOptions()
{
- ShowOptions();
+ ShowOptions();
}
// play
void CMainFrame::OnPlayPlay()
{
- if (m_iMediaLoadState == MLS_CLOSED) {
- b_firstPlay = false;
- OpenCurPlaylistItem();
- return;
- }
-
- if (m_iMediaLoadState == MLS_LOADED) {
- if (GetMediaState() == State_Stopped) {
- m_iSpeedLevel = 0;
- m_dSpeedRate = 1.0;
- }
-
- if (GetPlaybackMode() == PM_FILE) {
- if (m_fEndOfStream) {
- SendMessage(WM_COMMAND, ID_PLAY_STOP);
- }
- pMS->SetRate(m_dSpeedRate);
- pMC->Run();
- } else if (GetPlaybackMode() == PM_DVD) {
- double dRate = 1.0;
- m_iSpeedLevel = 0;
- m_dSpeedRate = 1.0;
-
- pDVDC->PlayForwards(dRate, DVD_CMD_FLAG_Block, NULL);
- pDVDC->Pause(FALSE);
- pMC->Run();
- } else if (GetPlaybackMode() == PM_CAPTURE) {
- pMC->Stop(); // audio preview won't be in sync if we run it from paused state
- pMC->Run();
- if (AfxGetAppSettings().iDefaultCaptureDevice == 1) {
- CComQIPtr<IBDATuner> pTun = pGB;
- if (pTun) {
- pTun->SetChannel (AfxGetAppSettings().nDVBLastChannel);
- DisplayCurrentChannelOSD();
- }
- }
- }
-
- SetTimersPlay();
- if (m_fFrameSteppingActive) { // FIXME
- m_fFrameSteppingActive = false;
- pBA->put_Volume(m_VolumeBeforeFrameStepping);
- } else {
- pBA->put_Volume(m_wndToolBar.Volume);
- }
-
- SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
- }
-
- MoveVideoWindow();
- //m_Lcd.SetStatusMessage(ResStr(IDS_CONTROLS_PLAYING), 3000);
- SetPlayState (PS_PLAY);
-
- OnTimer(TIMER_STREAMPOSPOLLER);
-
- m_OpenFile = false;
-
- SetupEVRColorControl(); // can be configured when streaming begins
-
- if (b_firstPlay) {
- b_firstPlay = false;
- CString m_strOSD;
-
- if (GetPlaybackMode() == PM_FILE) {
- m_strOSD = m_wndPlaylistBar.GetCurFileName();
- if (!m_LastOpenBDPath.IsEmpty()) {
- m_strOSD.LoadString(ID_PLAY_PLAY);
- int i = m_strOSD.Find(_T("\n"));
- if (i > 0) {
- m_strOSD.Delete(i, m_strOSD.GetLength()-i);
- }
- m_strOSD += _T(" BD");
- } else if (m_strOSD != _T("")) {
- m_strOSD.TrimRight('/');
- m_strOSD.Replace('\\', '/');
- m_strOSD = m_strOSD.Mid(m_strOSD.ReverseFind('/')+1);
- }
- } else if (GetPlaybackMode() == PM_DVD) {
- m_strOSD.LoadString(ID_PLAY_PLAY);
- int i = m_strOSD.Find(_T("\n"));
- if (i > 0) {
- m_strOSD.Delete(i, m_strOSD.GetLength()-i);
- }
- m_strOSD += _T(" DVD");
- }
-
- if (!m_strOSD.IsEmpty()) {
- m_OSD.DisplayMessage(OSD_TOPLEFT, m_strOSD, 3000);
- }
- }
+ if (m_iMediaLoadState == MLS_CLOSED) {
+ b_firstPlay = false;
+ OpenCurPlaylistItem();
+ return;
+ }
+
+ if (m_iMediaLoadState == MLS_LOADED) {
+ if (GetMediaState() == State_Stopped) {
+ m_iSpeedLevel = 0;
+ m_dSpeedRate = 1.0;
+ }
+
+ if (GetPlaybackMode() == PM_FILE) {
+ if (m_fEndOfStream) {
+ SendMessage(WM_COMMAND, ID_PLAY_STOP);
+ }
+ pMS->SetRate(m_dSpeedRate);
+ pMC->Run();
+ } else if (GetPlaybackMode() == PM_DVD) {
+ double dRate = 1.0;
+ m_iSpeedLevel = 0;
+ m_dSpeedRate = 1.0;
+
+ pDVDC->PlayForwards(dRate, DVD_CMD_FLAG_Block, NULL);
+ pDVDC->Pause(FALSE);
+ pMC->Run();
+ } else if (GetPlaybackMode() == PM_CAPTURE) {
+ pMC->Stop(); // audio preview won't be in sync if we run it from paused state
+ pMC->Run();
+ if (AfxGetAppSettings().iDefaultCaptureDevice == 1) {
+ CComQIPtr<IBDATuner> pTun = pGB;
+ if (pTun) {
+ pTun->SetChannel(AfxGetAppSettings().nDVBLastChannel);
+ DisplayCurrentChannelOSD();
+ }
+ }
+ }
+
+ SetTimersPlay();
+ if (m_fFrameSteppingActive) { // FIXME
+ m_fFrameSteppingActive = false;
+ pBA->put_Volume(m_VolumeBeforeFrameStepping);
+ } else {
+ pBA->put_Volume(m_wndToolBar.Volume);
+ }
+
+ SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
+ }
+
+ MoveVideoWindow();
+ //m_Lcd.SetStatusMessage(ResStr(IDS_CONTROLS_PLAYING), 3000);
+ SetPlayState(PS_PLAY);
+
+ OnTimer(TIMER_STREAMPOSPOLLER);
+
+ m_OpenFile = false;
+
+ SetupEVRColorControl(); // can be configured when streaming begins
+
+ if (b_firstPlay) {
+ b_firstPlay = false;
+ CString m_strOSD;
+
+ if (GetPlaybackMode() == PM_FILE) {
+ m_strOSD = m_wndPlaylistBar.GetCurFileName();
+ if (!m_LastOpenBDPath.IsEmpty()) {
+ m_strOSD.LoadString(ID_PLAY_PLAY);
+ int i = m_strOSD.Find(_T("\n"));
+ if (i > 0) {
+ m_strOSD.Delete(i, m_strOSD.GetLength() - i);
+ }
+ m_strOSD += _T(" BD");
+ } else if (m_strOSD != _T("")) {
+ m_strOSD.TrimRight('/');
+ m_strOSD.Replace('\\', '/');
+ m_strOSD = m_strOSD.Mid(m_strOSD.ReverseFind('/') + 1);
+ }
+ } else if (GetPlaybackMode() == PM_DVD) {
+ m_strOSD.LoadString(ID_PLAY_PLAY);
+ int i = m_strOSD.Find(_T("\n"));
+ if (i > 0) {
+ m_strOSD.Delete(i, m_strOSD.GetLength() - i);
+ }
+ m_strOSD += _T(" DVD");
+ }
+
+ if (!m_strOSD.IsEmpty()) {
+ m_OSD.DisplayMessage(OSD_TOPLEFT, m_strOSD, 3000);
+ }
+ }
}
void CMainFrame::OnPlayPauseI()
{
- if (m_iMediaLoadState == MLS_LOADED) {
+ if (m_iMediaLoadState == MLS_LOADED) {
- if (GetPlaybackMode() == PM_FILE) {
- pMC->Pause();
- } else if (GetPlaybackMode() == PM_DVD) {
- pMC->Pause();
- } else if (GetPlaybackMode() == PM_CAPTURE) {
- pMC->Pause();
- }
+ if (GetPlaybackMode() == PM_FILE) {
+ pMC->Pause();
+ } else if (GetPlaybackMode() == PM_DVD) {
+ pMC->Pause();
+ } else if (GetPlaybackMode() == PM_CAPTURE) {
+ pMC->Pause();
+ }
- KillTimer(TIMER_STATS);
- SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
- }
+ KillTimer(TIMER_STATS);
+ SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
+ }
- MoveVideoWindow();
- //m_Lcd.SetStatusMessage(ResStr(IDS_CONTROLS_PAUSED), 3000);
- SetPlayState (PS_PAUSE);
+ MoveVideoWindow();
+ //m_Lcd.SetStatusMessage(ResStr(IDS_CONTROLS_PAUSED), 3000);
+ SetPlayState(PS_PAUSE);
}
void CMainFrame::OnPlayPause()
{
- // Support ffdshow queuing.
- // To avoid black out on pause, we have to lock g_ffdshowReceive to synchronize with ReceiveMine.
- if (queue_ffdshow_support) {
- CAutoLock lck(&g_ffdshowReceive);
- return OnPlayPauseI();
- }
- OnPlayPauseI();
+ // Support ffdshow queuing.
+ // To avoid black out on pause, we have to lock g_ffdshowReceive to synchronize with ReceiveMine.
+ if (queue_ffdshow_support) {
+ CAutoLock lck(&g_ffdshowReceive);
+ return OnPlayPauseI();
+ }
+ OnPlayPauseI();
}
void CMainFrame::OnPlayPlaypause()
{
- OAFilterState fs = GetMediaState();
- if (fs == State_Running) {
- SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
- } else if (fs == State_Stopped || fs == State_Paused) {
- SendMessage(WM_COMMAND, ID_PLAY_PLAY);
- }
+ OAFilterState fs = GetMediaState();
+ if (fs == State_Running) {
+ SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ } else if (fs == State_Stopped || fs == State_Paused) {
+ SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ }
}
void CMainFrame::OnPlayStop()
{
- if (m_iMediaLoadState == MLS_LOADED) {
- if (GetPlaybackMode() == PM_FILE) {
- LONGLONG pos = 0;
- pMS->SetPositions(&pos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
- pMC->Stop();
-
- // BUG: after pause or stop the netshow url source filter won't continue
- // on the next play command, unless we cheat it by setting the file name again.
- //
- // Note: WMPx may be using some undocumented interface to restart streaming.
-
- BeginEnumFilters(pGB, pEF, pBF) {
- CComQIPtr<IAMNetworkStatus, &IID_IAMNetworkStatus> pAMNS = pBF;
- CComQIPtr<IFileSourceFilter> pFSF = pBF;
- if (pAMNS && pFSF) {
- WCHAR* pFN = NULL;
- AM_MEDIA_TYPE mt;
- if (SUCCEEDED(pFSF->GetCurFile(&pFN, &mt)) && pFN && *pFN) {
- pFSF->Load(pFN, NULL);
- CoTaskMemFree(pFN);
- }
- break;
- }
- }
- EndEnumFilters;
- } else if (GetPlaybackMode() == PM_DVD) {
- pDVDC->SetOption(DVD_ResetOnStop, TRUE);
- pMC->Stop();
- pDVDC->SetOption(DVD_ResetOnStop, FALSE);
- } else if (GetPlaybackMode() == PM_CAPTURE) {
- pMC->Stop();
- }
-
- m_iSpeedLevel = 0;
- m_dSpeedRate = 1.0;
-
- if (m_fFrameSteppingActive) { // FIXME
- m_fFrameSteppingActive = false;
- pBA->put_Volume(m_VolumeBeforeFrameStepping);
- }
-
- m_fEndOfStream = false;
- }
-
- m_nLoops = 0;
-
- if (m_hWnd) {
- KillTimersStop();
- MoveVideoWindow();
-
- if (m_iMediaLoadState == MLS_LOADED) {
- __int64 start, stop;
- m_wndSeekBar.GetRange(start, stop);
- GUID tf;
- pMS->GetTimeFormat(&tf);
- if (GetPlaybackMode() != PM_CAPTURE) {
- m_wndStatusBar.SetStatusTimer(m_wndSeekBar.GetPosReal(), stop, !!m_wndSubresyncBar.IsWindowVisible(), &tf);
- }
-
- SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
- }
- }
-
- //m_Lcd.SetStatusMessage(ResStr(IDS_CONTROLS_STOPPED), 3000);
- SetPlayState (PS_STOP);
-}
+ if (m_iMediaLoadState == MLS_LOADED) {
+ if (GetPlaybackMode() == PM_FILE) {
+ LONGLONG pos = 0;
+ pMS->SetPositions(&pos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
+ pMC->Stop();
+
+ // BUG: after pause or stop the netshow url source filter won't continue
+ // on the next play command, unless we cheat it by setting the file name again.
+ //
+ // Note: WMPx may be using some undocumented interface to restart streaming.
+
+ BeginEnumFilters(pGB, pEF, pBF) {
+ CComQIPtr<IAMNetworkStatus, &IID_IAMNetworkStatus> pAMNS = pBF;
+ CComQIPtr<IFileSourceFilter> pFSF = pBF;
+ if (pAMNS && pFSF) {
+ WCHAR* pFN = NULL;
+ AM_MEDIA_TYPE mt;
+ if (SUCCEEDED(pFSF->GetCurFile(&pFN, &mt)) && pFN && *pFN) {
+ pFSF->Load(pFN, NULL);
+ CoTaskMemFree(pFN);
+ }
+ break;
+ }
+ }
+ EndEnumFilters;
+ } else if (GetPlaybackMode() == PM_DVD) {
+ pDVDC->SetOption(DVD_ResetOnStop, TRUE);
+ pMC->Stop();
+ pDVDC->SetOption(DVD_ResetOnStop, FALSE);
+ } else if (GetPlaybackMode() == PM_CAPTURE) {
+ pMC->Stop();
+ }
+
+ m_iSpeedLevel = 0;
+ m_dSpeedRate = 1.0;
+
+ if (m_fFrameSteppingActive) { // FIXME
+ m_fFrameSteppingActive = false;
+ pBA->put_Volume(m_VolumeBeforeFrameStepping);
+ }
+
+ m_fEndOfStream = false;
+ }
-void CMainFrame::OnUpdatePlayPauseStop(CCmdUI* pCmdUI)
-{
- OAFilterState fs = m_fFrameSteppingActive ? State_Paused : GetMediaState();
+ m_nLoops = 0;
- pCmdUI->SetCheck(fs == State_Running && pCmdUI->m_nID == ID_PLAY_PLAY
- || fs == State_Paused && pCmdUI->m_nID == ID_PLAY_PAUSE
- || fs == State_Stopped && pCmdUI->m_nID == ID_PLAY_STOP
- || (fs == State_Paused || fs == State_Running) && pCmdUI->m_nID == ID_PLAY_PLAYPAUSE);
+ if (m_hWnd) {
+ KillTimersStop();
+ MoveVideoWindow();
- bool fEnable = false;
+ if (m_iMediaLoadState == MLS_LOADED) {
+ __int64 start, stop;
+ m_wndSeekBar.GetRange(start, stop);
+ GUID tf;
+ pMS->GetTimeFormat(&tf);
+ if (GetPlaybackMode() != PM_CAPTURE) {
+ m_wndStatusBar.SetStatusTimer(m_wndSeekBar.GetPosReal(), stop, !!m_wndSubresyncBar.IsWindowVisible(), &tf);
+ }
- if (fs >= 0) {
- if (GetPlaybackMode() == PM_FILE || GetPlaybackMode() == PM_CAPTURE) {
- fEnable = true;
+ SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
+ }
+ }
- if (fs == State_Stopped && pCmdUI->m_nID == ID_PLAY_PAUSE && m_fRealMediaGraph) {
- fEnable = false; // can't go into paused state from stopped with rm
- } else if (m_fCapturing) {
- fEnable = false;
- } else if (m_fLiveWM && pCmdUI->m_nID == ID_PLAY_PAUSE) {
- fEnable = false;
- }
- } else if (GetPlaybackMode() == PM_DVD) {
- fEnable = m_iDVDDomain != DVD_DOMAIN_VideoManagerMenu
- && m_iDVDDomain != DVD_DOMAIN_VideoTitleSetMenu;
+ //m_Lcd.SetStatusMessage(ResStr(IDS_CONTROLS_STOPPED), 3000);
+ SetPlayState(PS_STOP);
+}
- if (fs == State_Stopped && pCmdUI->m_nID == ID_PLAY_PAUSE) {
- fEnable = false;
- }
- }
- } else if (pCmdUI->m_nID == ID_PLAY_PLAY && m_wndPlaylistBar.GetCount() > 0) {
- fEnable = true;
- }
+void CMainFrame::OnUpdatePlayPauseStop(CCmdUI* pCmdUI)
+{
+ OAFilterState fs = m_fFrameSteppingActive ? State_Paused : GetMediaState();
+
+ pCmdUI->SetCheck(fs == State_Running && pCmdUI->m_nID == ID_PLAY_PLAY
+ || fs == State_Paused && pCmdUI->m_nID == ID_PLAY_PAUSE
+ || fs == State_Stopped && pCmdUI->m_nID == ID_PLAY_STOP
+ || (fs == State_Paused || fs == State_Running) && pCmdUI->m_nID == ID_PLAY_PLAYPAUSE);
+
+ bool fEnable = false;
+
+ if (fs >= 0) {
+ if (GetPlaybackMode() == PM_FILE || GetPlaybackMode() == PM_CAPTURE) {
+ fEnable = true;
+
+ if (fs == State_Stopped && pCmdUI->m_nID == ID_PLAY_PAUSE && m_fRealMediaGraph) {
+ fEnable = false; // can't go into paused state from stopped with rm
+ } else if (m_fCapturing) {
+ fEnable = false;
+ } else if (m_fLiveWM && pCmdUI->m_nID == ID_PLAY_PAUSE) {
+ fEnable = false;
+ }
+ } else if (GetPlaybackMode() == PM_DVD) {
+ fEnable = m_iDVDDomain != DVD_DOMAIN_VideoManagerMenu
+ && m_iDVDDomain != DVD_DOMAIN_VideoTitleSetMenu;
+
+ if (fs == State_Stopped && pCmdUI->m_nID == ID_PLAY_PAUSE) {
+ fEnable = false;
+ }
+ }
+ } else if (pCmdUI->m_nID == ID_PLAY_PLAY && m_wndPlaylistBar.GetCount() > 0) {
+ fEnable = true;
+ }
- pCmdUI->Enable(fEnable);
+ pCmdUI->Enable(fEnable);
}
void CMainFrame::OnPlayFramestep(UINT nID)
{
- REFERENCE_TIME rt;
-
- if (pFS && m_fQuicktimeGraph) {
- if (GetMediaState() != State_Paused) {
- SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
- }
-
- pFS->Step(nID == ID_PLAY_FRAMESTEP ? 1 : -1, NULL);
- } else if (pFS && nID == ID_PLAY_FRAMESTEP) {
- m_OSD.EnableShowMessage(false);
-
- if (GetMediaState() != State_Paused && !queue_ffdshow_support) {
- SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
- }
-
- // To support framestep back, store the initial position when
- // stepping forward
- if (m_nStepForwardCount == 0) {
- pMS->GetCurrentPosition(&m_rtStepForwardStart);
- }
-
- m_fFrameSteppingActive = true;
-
- m_VolumeBeforeFrameStepping = m_wndToolBar.Volume;
- pBA->put_Volume(-10000);
-
- pFS->Step(1, NULL);
-
- m_OSD.EnableShowMessage();
-
- } else if (S_OK == pMS->IsFormatSupported(&TIME_FORMAT_FRAME)) {
- if (GetMediaState() != State_Paused) {
- SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
- }
-
- pMS->SetTimeFormat(&TIME_FORMAT_FRAME);
- pMS->GetCurrentPosition(&rt);
- if (nID == ID_PLAY_FRAMESTEP) {
- rt++;
- } else if (nID == ID_PLAY_FRAMESTEPCANCEL) {
- rt--;
- }
- pMS->SetPositions(&rt, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
- pMS->SetTimeFormat(&TIME_FORMAT_MEDIA_TIME);
- } else { //if (s.iDSVideoRendererType != VIDRNDT_DS_VMR9WINDOWED && s.iDSVideoRendererType != VIDRNDT_DS_VMR9RENDERLESS)
- if (GetMediaState() != State_Paused) {
- SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
- }
-
- REFERENCE_TIME rtAvgTime = 0;
- BeginEnumFilters(pGB, pEF, pBF) {
- BeginEnumPins(pBF, pEP, pPin) {
- AM_MEDIA_TYPE mt;
- pPin->ConnectionMediaType(&mt);
-
- if (mt.majortype == MEDIATYPE_Video && mt.formattype == FORMAT_VideoInfo) {
- rtAvgTime = ((VIDEOINFOHEADER*)mt.pbFormat)->AvgTimePerFrame;
- } else if (mt.majortype == MEDIATYPE_Video && mt.formattype == FORMAT_VideoInfo2) {
- rtAvgTime = ((VIDEOINFOHEADER2*)mt.pbFormat)->AvgTimePerFrame;
- }
- }
- EndEnumPins;
- }
- EndEnumFilters;
-
- // Exit of framestep forward : calculate the initial position
- if (m_nStepForwardCount != 0) {
- pFS->CancelStep();
- rt = m_rtStepForwardStart + m_nStepForwardCount*rtAvgTime;
- m_nStepForwardCount = 0;
- } else {
- pMS->GetCurrentPosition(&rt);
- }
- if (nID == ID_PLAY_FRAMESTEP) {
- rt += rtAvgTime;
- } else if (nID == ID_PLAY_FRAMESTEPCANCEL) {
- rt -= rtAvgTime;
- }
- pMS->SetPositions(&rt, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
- }
+ REFERENCE_TIME rt;
+
+ if (pFS && m_fQuicktimeGraph) {
+ if (GetMediaState() != State_Paused) {
+ SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ }
+
+ pFS->Step(nID == ID_PLAY_FRAMESTEP ? 1 : -1, NULL);
+ } else if (pFS && nID == ID_PLAY_FRAMESTEP) {
+ m_OSD.EnableShowMessage(false);
+
+ if (GetMediaState() != State_Paused && !queue_ffdshow_support) {
+ SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ }
+
+ // To support framestep back, store the initial position when
+ // stepping forward
+ if (m_nStepForwardCount == 0) {
+ pMS->GetCurrentPosition(&m_rtStepForwardStart);
+ }
+
+ m_fFrameSteppingActive = true;
+
+ m_VolumeBeforeFrameStepping = m_wndToolBar.Volume;
+ pBA->put_Volume(-10000);
+
+ pFS->Step(1, NULL);
+
+ m_OSD.EnableShowMessage();
+
+ } else if (S_OK == pMS->IsFormatSupported(&TIME_FORMAT_FRAME)) {
+ if (GetMediaState() != State_Paused) {
+ SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ }
+
+ pMS->SetTimeFormat(&TIME_FORMAT_FRAME);
+ pMS->GetCurrentPosition(&rt);
+ if (nID == ID_PLAY_FRAMESTEP) {
+ rt++;
+ } else if (nID == ID_PLAY_FRAMESTEPCANCEL) {
+ rt--;
+ }
+ pMS->SetPositions(&rt, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
+ pMS->SetTimeFormat(&TIME_FORMAT_MEDIA_TIME);
+ } else { //if (s.iDSVideoRendererType != VIDRNDT_DS_VMR9WINDOWED && s.iDSVideoRendererType != VIDRNDT_DS_VMR9RENDERLESS)
+ if (GetMediaState() != State_Paused) {
+ SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ }
+
+ REFERENCE_TIME rtAvgTime = 0;
+ BeginEnumFilters(pGB, pEF, pBF) {
+ BeginEnumPins(pBF, pEP, pPin) {
+ AM_MEDIA_TYPE mt;
+ pPin->ConnectionMediaType(&mt);
+
+ if (mt.majortype == MEDIATYPE_Video && mt.formattype == FORMAT_VideoInfo) {
+ rtAvgTime = ((VIDEOINFOHEADER*)mt.pbFormat)->AvgTimePerFrame;
+ } else if (mt.majortype == MEDIATYPE_Video && mt.formattype == FORMAT_VideoInfo2) {
+ rtAvgTime = ((VIDEOINFOHEADER2*)mt.pbFormat)->AvgTimePerFrame;
+ }
+ }
+ EndEnumPins;
+ }
+ EndEnumFilters;
+
+ // Exit of framestep forward : calculate the initial position
+ if (m_nStepForwardCount != 0) {
+ pFS->CancelStep();
+ rt = m_rtStepForwardStart + m_nStepForwardCount * rtAvgTime;
+ m_nStepForwardCount = 0;
+ } else {
+ pMS->GetCurrentPosition(&rt);
+ }
+ if (nID == ID_PLAY_FRAMESTEP) {
+ rt += rtAvgTime;
+ } else if (nID == ID_PLAY_FRAMESTEPCANCEL) {
+ rt -= rtAvgTime;
+ }
+ pMS->SetPositions(&rt, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
+ }
}
void CMainFrame::OnUpdatePlayFramestep(CCmdUI* pCmdUI)
{
- bool fEnable = false;
-
- if (m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly &&
- (GetPlaybackMode() != PM_DVD || m_iDVDDomain == DVD_DOMAIN_Title) &&
- GetPlaybackMode() != PM_CAPTURE &&
- !m_fLiveWM) {
- if (S_OK == pMS->IsFormatSupported(&TIME_FORMAT_FRAME)) {
- fEnable = true;
- } else if (pCmdUI->m_nID == ID_PLAY_FRAMESTEP) {
- fEnable = true;
- } else if (pCmdUI->m_nID == ID_PLAY_FRAMESTEPCANCEL && pFS && pFS->CanStep(0, NULL) == S_OK) {
- fEnable = true;
- } else if (m_fQuicktimeGraph && pFS) {
- fEnable = true;
- }
- }
+ bool fEnable = false;
+
+ if (m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly &&
+ (GetPlaybackMode() != PM_DVD || m_iDVDDomain == DVD_DOMAIN_Title) &&
+ GetPlaybackMode() != PM_CAPTURE &&
+ !m_fLiveWM) {
+ if (S_OK == pMS->IsFormatSupported(&TIME_FORMAT_FRAME)) {
+ fEnable = true;
+ } else if (pCmdUI->m_nID == ID_PLAY_FRAMESTEP) {
+ fEnable = true;
+ } else if (pCmdUI->m_nID == ID_PLAY_FRAMESTEPCANCEL && pFS && pFS->CanStep(0, NULL) == S_OK) {
+ fEnable = true;
+ } else if (m_fQuicktimeGraph && pFS) {
+ fEnable = true;
+ }
+ }
- pCmdUI->Enable(fEnable);
+ pCmdUI->Enable(fEnable);
}
void CMainFrame::OnPlaySeek(UINT nID)
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- REFERENCE_TIME dt =
- nID == ID_PLAY_SEEKBACKWARDSMALL ? -10000i64*s.nJumpDistS :
- nID == ID_PLAY_SEEKFORWARDSMALL ? +10000i64*s.nJumpDistS :
- nID == ID_PLAY_SEEKBACKWARDMED ? -10000i64*s.nJumpDistM :
- nID == ID_PLAY_SEEKFORWARDMED ? +10000i64*s.nJumpDistM :
- nID == ID_PLAY_SEEKBACKWARDLARGE ? -10000i64*s.nJumpDistL :
- nID == ID_PLAY_SEEKFORWARDLARGE ? +10000i64*s.nJumpDistL :
- 0;
+ REFERENCE_TIME dt =
+ nID == ID_PLAY_SEEKBACKWARDSMALL ? -10000i64 * s.nJumpDistS :
+ nID == ID_PLAY_SEEKFORWARDSMALL ? +10000i64 * s.nJumpDistS :
+ nID == ID_PLAY_SEEKBACKWARDMED ? -10000i64 * s.nJumpDistM :
+ nID == ID_PLAY_SEEKFORWARDMED ? +10000i64 * s.nJumpDistM :
+ nID == ID_PLAY_SEEKBACKWARDLARGE ? -10000i64 * s.nJumpDistL :
+ nID == ID_PLAY_SEEKFORWARDLARGE ? +10000i64 * s.nJumpDistL :
+ 0;
- m_nSeekDirection = (nID == ID_PLAY_SEEKBACKWARDSMALL || nID == ID_PLAY_SEEKBACKWARDMED || nID == ID_PLAY_SEEKBACKWARDLARGE) ? SEEK_DIRECTION_BACKWARD :
- (nID == ID_PLAY_SEEKFORWARDSMALL || nID == ID_PLAY_SEEKFORWARDMED || nID == ID_PLAY_SEEKFORWARDLARGE) ? SEEK_DIRECTION_FORWARD : SEEK_DIRECTION_NONE;
+ m_nSeekDirection = (nID == ID_PLAY_SEEKBACKWARDSMALL || nID == ID_PLAY_SEEKBACKWARDMED || nID == ID_PLAY_SEEKBACKWARDLARGE) ? SEEK_DIRECTION_BACKWARD :
+ (nID == ID_PLAY_SEEKFORWARDSMALL || nID == ID_PLAY_SEEKFORWARDMED || nID == ID_PLAY_SEEKFORWARDLARGE) ? SEEK_DIRECTION_FORWARD : SEEK_DIRECTION_NONE;
- if (!dt) {
- return;
- }
+ if (!dt) {
+ return;
+ }
- // HACK: the custom graph should support frame based seeking instead
- if (m_fShockwaveGraph) {
- dt /= 10000i64*100;
- }
+ // HACK: the custom graph should support frame based seeking instead
+ if (m_fShockwaveGraph) {
+ dt /= 10000i64 * 100;
+ }
- SeekTo(m_wndSeekBar.GetPos() + dt, s.fFastSeek);
+ SeekTo(m_wndSeekBar.GetPos() + dt, s.fFastSeek);
}
void CMainFrame::SetTimersPlay()
{
- SetTimer(TIMER_STREAMPOSPOLLER, 40, NULL);
- SetTimer(TIMER_STREAMPOSPOLLER2, 500, NULL);
- SetTimer(TIMER_STATS, 1000, NULL);
+ SetTimer(TIMER_STREAMPOSPOLLER, 40, NULL);
+ SetTimer(TIMER_STREAMPOSPOLLER2, 500, NULL);
+ SetTimer(TIMER_STATS, 1000, NULL);
}
void CMainFrame::KillTimersStop()
{
- KillTimer(TIMER_STREAMPOSPOLLER2);
- KillTimer(TIMER_STREAMPOSPOLLER);
- KillTimer(TIMER_STATS);
+ KillTimer(TIMER_STREAMPOSPOLLER2);
+ KillTimer(TIMER_STREAMPOSPOLLER);
+ KillTimer(TIMER_STATS);
}
static int rangebsearch(REFERENCE_TIME val, CAtlArray<REFERENCE_TIME>& rta)
{
- int i = 0, j = rta.GetCount() - 1, ret = -1;
-
- if (j >= 0 && val >= rta[j]) {
- return j;
- }
-
- while (i < j) {
- int mid = (i + j) >> 1;
- REFERENCE_TIME midt = rta[mid];
- if (val == midt) {
- ret = mid;
- break;
- } else if (val < midt) {
- ret = -1;
- if (j == mid) {
- mid--;
- }
- j = mid;
- } else if (val > midt) {
- ret = mid;
- if (i == mid) {
- mid++;
- }
- i = mid;
- }
- }
-
- return ret;
+ int i = 0, j = rta.GetCount() - 1, ret = -1;
+
+ if (j >= 0 && val >= rta[j]) {
+ return j;
+ }
+
+ while (i < j) {
+ int mid = (i + j) >> 1;
+ REFERENCE_TIME midt = rta[mid];
+ if (val == midt) {
+ ret = mid;
+ break;
+ } else if (val < midt) {
+ ret = -1;
+ if (j == mid) {
+ mid--;
+ }
+ j = mid;
+ } else if (val > midt) {
+ ret = mid;
+ if (i == mid) {
+ mid++;
+ }
+ i = mid;
+ }
+ }
+
+ return ret;
}
void CMainFrame::OnPlaySeekKey(UINT nID)
{
- if (m_kfs.GetCount() > 0) {
- HRESULT hr;
+ if (m_kfs.GetCount() > 0) {
+ HRESULT hr;
- if (GetMediaState() == State_Stopped) {
- SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
- }
+ if (GetMediaState() == State_Stopped) {
+ SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ }
- REFERENCE_TIME rtCurrent, rtDur;
- hr = pMS->GetCurrentPosition(&rtCurrent);
- hr = pMS->GetDuration(&rtDur);
+ REFERENCE_TIME rtCurrent, rtDur;
+ hr = pMS->GetCurrentPosition(&rtCurrent);
+ hr = pMS->GetDuration(&rtDur);
- int dec = 1;
- int i = rangebsearch(rtCurrent, m_kfs);
- if (i > 0) {
- dec = (UINT)max(min(rtCurrent - m_kfs[i-1], 10000000), 0);
- }
+ int dec = 1;
+ int i = rangebsearch(rtCurrent, m_kfs);
+ if (i > 0) {
+ dec = (UINT)max(min(rtCurrent - m_kfs[i - 1], 10000000), 0);
+ }
- rtCurrent =
- nID == ID_PLAY_SEEKKEYBACKWARD ? max(rtCurrent - dec, 0) :
- nID == ID_PLAY_SEEKKEYFORWARD ? rtCurrent : 0;
+ rtCurrent =
+ nID == ID_PLAY_SEEKKEYBACKWARD ? max(rtCurrent - dec, 0) :
+ nID == ID_PLAY_SEEKKEYFORWARD ? rtCurrent : 0;
- i = rangebsearch(rtCurrent, m_kfs);
+ i = rangebsearch(rtCurrent, m_kfs);
- if (nID == ID_PLAY_SEEKKEYBACKWARD) {
- rtCurrent = m_kfs[max(i, 0)];
- } else if (nID == ID_PLAY_SEEKKEYFORWARD && i < (int)m_kfs.GetCount()-1) {
- rtCurrent = m_kfs[i+1];
- } else {
- return;
- }
+ if (nID == ID_PLAY_SEEKKEYBACKWARD) {
+ rtCurrent = m_kfs[max(i, 0)];
+ } else if (nID == ID_PLAY_SEEKKEYFORWARD && i < (int)m_kfs.GetCount() - 1) {
+ rtCurrent = m_kfs[i + 1];
+ } else {
+ return;
+ }
- // HACK: if d3d or something changes fpu control word the values of
- // m_kfs may be different now (if it was asked again), adding a little
- // to the seek position eliminates this error usually.
+ // HACK: if d3d or something changes fpu control word the values of
+ // m_kfs may be different now (if it was asked again), adding a little
+ // to the seek position eliminates this error usually.
- rtCurrent += 10;
+ rtCurrent += 10;
- hr = pMS->SetPositions(
- &rtCurrent, AM_SEEKING_AbsolutePositioning|AM_SEEKING_SeekToKeyFrame,
- NULL, AM_SEEKING_NoPositioning);
+ hr = pMS->SetPositions(
+ &rtCurrent, AM_SEEKING_AbsolutePositioning | AM_SEEKING_SeekToKeyFrame,
+ NULL, AM_SEEKING_NoPositioning);
- m_OSD.DisplayMessage(OSD_TOPLEFT, m_wndStatusBar.GetStatusTimer(), 1500);
- }
+ m_OSD.DisplayMessage(OSD_TOPLEFT, m_wndStatusBar.GetStatusTimer(), 1500);
+ }
}
void CMainFrame::OnUpdatePlaySeek(CCmdUI* pCmdUI)
{
- bool fEnable = false;
+ bool fEnable = false;
- OAFilterState fs = GetMediaState();
+ OAFilterState fs = GetMediaState();
- if (m_iMediaLoadState == MLS_LOADED && (fs == State_Paused || fs == State_Running)) {
- fEnable = true;
- if (GetPlaybackMode() == PM_DVD && (m_iDVDDomain != DVD_DOMAIN_Title || fs != State_Running)) {
- fEnable = false;
- } else if (GetPlaybackMode() == PM_CAPTURE) {
- fEnable = false;
- }
- }
+ if (m_iMediaLoadState == MLS_LOADED && (fs == State_Paused || fs == State_Running)) {
+ fEnable = true;
+ if (GetPlaybackMode() == PM_DVD && (m_iDVDDomain != DVD_DOMAIN_Title || fs != State_Running)) {
+ fEnable = false;
+ } else if (GetPlaybackMode() == PM_CAPTURE) {
+ fEnable = false;
+ }
+ }
- pCmdUI->Enable(fEnable);
+ pCmdUI->Enable(fEnable);
}
void CMainFrame::OnPlayGoto()
{
- if ((m_iMediaLoadState != MLS_LOADED) || m_pFullscreenWnd->IsWindow()) {
- return;
- }
-
- REFTIME atpf = 0;
- if (FAILED(pBV->get_AvgTimePerFrame(&atpf)) || atpf < 0) {
- atpf = 0;
-
- BeginEnumFilters(pGB, pEF, pBF) {
- if (atpf > 0) {
- break;
- }
-
- BeginEnumPins(pBF, pEP, pPin) {
- if (atpf > 0) {
- break;
- }
-
- AM_MEDIA_TYPE mt;
- pPin->ConnectionMediaType(&mt);
+ if ((m_iMediaLoadState != MLS_LOADED) || m_pFullscreenWnd->IsWindow()) {
+ return;
+ }
- if (mt.majortype == MEDIATYPE_Video && mt.formattype == FORMAT_VideoInfo) {
- atpf = (REFTIME)((VIDEOINFOHEADER*)mt.pbFormat)->AvgTimePerFrame / 10000000i64;
- } else if (mt.majortype == MEDIATYPE_Video && mt.formattype == FORMAT_VideoInfo2) {
- atpf = (REFTIME)((VIDEOINFOHEADER2*)mt.pbFormat)->AvgTimePerFrame / 10000000i64;
- }
- }
- EndEnumPins;
- }
- EndEnumFilters;
- }
+ REFTIME atpf = 0;
+ if (FAILED(pBV->get_AvgTimePerFrame(&atpf)) || atpf < 0) {
+ atpf = 0;
+
+ BeginEnumFilters(pGB, pEF, pBF) {
+ if (atpf > 0) {
+ break;
+ }
+
+ BeginEnumPins(pBF, pEP, pPin) {
+ if (atpf > 0) {
+ break;
+ }
+
+ AM_MEDIA_TYPE mt;
+ pPin->ConnectionMediaType(&mt);
+
+ if (mt.majortype == MEDIATYPE_Video && mt.formattype == FORMAT_VideoInfo) {
+ atpf = (REFTIME)((VIDEOINFOHEADER*)mt.pbFormat)->AvgTimePerFrame / 10000000i64;
+ } else if (mt.majortype == MEDIATYPE_Video && mt.formattype == FORMAT_VideoInfo2) {
+ atpf = (REFTIME)((VIDEOINFOHEADER2*)mt.pbFormat)->AvgTimePerFrame / 10000000i64;
+ }
+ }
+ EndEnumPins;
+ }
+ EndEnumFilters;
+ }
- REFERENCE_TIME start, dur = -1;
- m_wndSeekBar.GetRange(start, dur);
- CGoToDlg dlg(m_wndSeekBar.GetPos(), dur, atpf > 0 ? (1.0/atpf) : 0);
- if (IDOK != dlg.DoModal() || dlg.m_time < 0) {
- return;
- }
+ REFERENCE_TIME start, dur = -1;
+ m_wndSeekBar.GetRange(start, dur);
+ CGoToDlg dlg(m_wndSeekBar.GetPos(), dur, atpf > 0 ? (1.0 / atpf) : 0);
+ if (IDOK != dlg.DoModal() || dlg.m_time < 0) {
+ return;
+ }
- SeekTo(dlg.m_time);
+ SeekTo(dlg.m_time);
}
void CMainFrame::OnUpdateGoto(CCmdUI* pCmdUI)
{
- bool fEnable = false;
+ bool fEnable = false;
- if (m_iMediaLoadState == MLS_LOADED) {
- fEnable = true;
- if (GetPlaybackMode() == PM_DVD && m_iDVDDomain != DVD_DOMAIN_Title) {
- fEnable = false;
- } else if (GetPlaybackMode() == PM_CAPTURE) {
- fEnable = false;
- }
- }
+ if (m_iMediaLoadState == MLS_LOADED) {
+ fEnable = true;
+ if (GetPlaybackMode() == PM_DVD && m_iDVDDomain != DVD_DOMAIN_Title) {
+ fEnable = false;
+ } else if (GetPlaybackMode() == PM_CAPTURE) {
+ fEnable = false;
+ }
+ }
- pCmdUI->Enable(fEnable);
+ pCmdUI->Enable(fEnable);
}
void CMainFrame::OnPlayChangeRate(UINT nID)
{
- if (m_iMediaLoadState != MLS_LOADED) {
- return;
- }
-
- if (GetPlaybackMode() == PM_CAPTURE) {
- if (GetMediaState() != State_Running) {
- SendMessage(WM_COMMAND, ID_PLAY_PLAY);
- }
-
- long lChannelMin = 0, lChannelMax = 0;
- pAMTuner->ChannelMinMax(&lChannelMin, &lChannelMax);
- long lChannel = 0, lVivSub = 0, lAudSub = 0;
- pAMTuner->get_Channel(&lChannel, &lVivSub, &lAudSub);
-
- long lFreqOrg = 0, lFreqNew = -1;
- pAMTuner->get_VideoFrequency(&lFreqOrg);
-
- //long lSignalStrength;
- do {
- if (nID == ID_PLAY_DECRATE) {
- lChannel--;
- } else if (nID == ID_PLAY_INCRATE) {
- lChannel++;
- }
-
- //if (lChannel < lChannelMin) lChannel = lChannelMax;
- //if (lChannel > lChannelMax) lChannel = lChannelMin;
-
- if (lChannel < lChannelMin || lChannel > lChannelMax) {
- break;
- }
-
- if (FAILED(pAMTuner->put_Channel(lChannel, AMTUNER_SUBCHAN_DEFAULT, AMTUNER_SUBCHAN_DEFAULT))) {
- break;
- }
-
- long flFoundSignal;
- pAMTuner->AutoTune(lChannel, &flFoundSignal);
-
- pAMTuner->get_VideoFrequency(&lFreqNew);
- } while (FALSE);
- /* SUCCEEDED(pAMTuner->SignalPresent(&lSignalStrength))
- && (lSignalStrength != AMTUNER_SIGNALPRESENT || lFreqNew == lFreqOrg));*/
-
- } else {
- int iNewSpeedLevel;
-
- // Cap the max FFWD and RWD rates to 128x.
- if (nID == ID_PLAY_INCRATE) {
- iNewSpeedLevel = (m_iSpeedLevel < 7 ? m_iSpeedLevel+1 : 7);
- } else if (nID == ID_PLAY_DECRATE) {
- iNewSpeedLevel = (m_iSpeedLevel > -7 ? m_iSpeedLevel-1 : -7);
- } else {
- return;
- }
-
- HRESULT hr = E_FAIL;
-
- if ((iNewSpeedLevel == -4) && (GetPlaybackMode() == PM_FILE)) {
- if (GetMediaState() != State_Paused) {
- SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
- }
-
- if (GetMediaState() == State_Paused) {
- hr = S_OK;
- }
- } else {
- double dRate = 1.0;
-
- if (GetMediaState() != State_Running) {
- SendMessage(WM_COMMAND, ID_PLAY_PLAY);
- }
-
- if (GetPlaybackMode() == PM_FILE) {
- dRate = pow(2.0, iNewSpeedLevel >= -3 ? iNewSpeedLevel : (-iNewSpeedLevel - 8));
- if (fabs(dRate - 1.0) < 0.01) {
- dRate = 1.0;
- }
- hr = pMS->SetRate(dRate);
- } else if (GetPlaybackMode() == PM_DVD) {
- dRate = pow(2.0, abs(iNewSpeedLevel));
- if (iNewSpeedLevel >= 0) {
- hr = pDVDC->PlayForwards(dRate, DVD_CMD_FLAG_Block, NULL);
- } else {
- hr = pDVDC->PlayBackwards(dRate, DVD_CMD_FLAG_Block, NULL);
- }
- }
-
- if (SUCCEEDED(hr)) {
- m_iSpeedLevel = iNewSpeedLevel;
- m_dSpeedRate = dRate;
-
- CString strODSMessage;
- strODSMessage.Format(IDS_OSD_SPEED, (iNewSpeedLevel < 0 && GetPlaybackMode() == PM_DVD) ? -dRate : dRate);
- m_OSD.DisplayMessage(OSD_TOPRIGHT, strODSMessage);
- }
- }
-
- }
+ if (m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
+
+ if (GetPlaybackMode() == PM_CAPTURE) {
+ if (GetMediaState() != State_Running) {
+ SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ }
+
+ long lChannelMin = 0, lChannelMax = 0;
+ pAMTuner->ChannelMinMax(&lChannelMin, &lChannelMax);
+ long lChannel = 0, lVivSub = 0, lAudSub = 0;
+ pAMTuner->get_Channel(&lChannel, &lVivSub, &lAudSub);
+
+ long lFreqOrg = 0, lFreqNew = -1;
+ pAMTuner->get_VideoFrequency(&lFreqOrg);
+
+ //long lSignalStrength;
+ do {
+ if (nID == ID_PLAY_DECRATE) {
+ lChannel--;
+ } else if (nID == ID_PLAY_INCRATE) {
+ lChannel++;
+ }
+
+ //if (lChannel < lChannelMin) lChannel = lChannelMax;
+ //if (lChannel > lChannelMax) lChannel = lChannelMin;
+
+ if (lChannel < lChannelMin || lChannel > lChannelMax) {
+ break;
+ }
+
+ if (FAILED(pAMTuner->put_Channel(lChannel, AMTUNER_SUBCHAN_DEFAULT, AMTUNER_SUBCHAN_DEFAULT))) {
+ break;
+ }
+
+ long flFoundSignal;
+ pAMTuner->AutoTune(lChannel, &flFoundSignal);
+
+ pAMTuner->get_VideoFrequency(&lFreqNew);
+ } while (FALSE);
+ /* SUCCEEDED(pAMTuner->SignalPresent(&lSignalStrength))
+ && (lSignalStrength != AMTUNER_SIGNALPRESENT || lFreqNew == lFreqOrg));*/
+
+ } else {
+ int iNewSpeedLevel;
+
+ // Cap the max FFWD and RWD rates to 128x.
+ if (nID == ID_PLAY_INCRATE) {
+ iNewSpeedLevel = (m_iSpeedLevel < 7 ? m_iSpeedLevel + 1 : 7);
+ } else if (nID == ID_PLAY_DECRATE) {
+ iNewSpeedLevel = (m_iSpeedLevel > -7 ? m_iSpeedLevel - 1 : -7);
+ } else {
+ return;
+ }
+
+ HRESULT hr = E_FAIL;
+
+ if ((iNewSpeedLevel == -4) && (GetPlaybackMode() == PM_FILE)) {
+ if (GetMediaState() != State_Paused) {
+ SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ }
+
+ if (GetMediaState() == State_Paused) {
+ hr = S_OK;
+ }
+ } else {
+ double dRate = 1.0;
+
+ if (GetMediaState() != State_Running) {
+ SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ }
+
+ if (GetPlaybackMode() == PM_FILE) {
+ dRate = pow(2.0, iNewSpeedLevel >= -3 ? iNewSpeedLevel : (-iNewSpeedLevel - 8));
+ if (fabs(dRate - 1.0) < 0.01) {
+ dRate = 1.0;
+ }
+ hr = pMS->SetRate(dRate);
+ } else if (GetPlaybackMode() == PM_DVD) {
+ dRate = pow(2.0, abs(iNewSpeedLevel));
+ if (iNewSpeedLevel >= 0) {
+ hr = pDVDC->PlayForwards(dRate, DVD_CMD_FLAG_Block, NULL);
+ } else {
+ hr = pDVDC->PlayBackwards(dRate, DVD_CMD_FLAG_Block, NULL);
+ }
+ }
+
+ if (SUCCEEDED(hr)) {
+ m_iSpeedLevel = iNewSpeedLevel;
+ m_dSpeedRate = dRate;
+
+ CString strODSMessage;
+ strODSMessage.Format(IDS_OSD_SPEED, (iNewSpeedLevel < 0 && GetPlaybackMode() == PM_DVD) ? -dRate : dRate);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT, strODSMessage);
+ }
+ }
+
+ }
}
void CMainFrame::OnUpdatePlayChangeRate(CCmdUI* pCmdUI)
{
- bool fEnable = false;
-
- if (m_iMediaLoadState == MLS_LOADED) {
- bool fInc = pCmdUI->m_nID == ID_PLAY_INCRATE;
-
- fEnable = true;
- if (fInc && m_iSpeedLevel >= 7) {
- fEnable = false;
- } else if (!fInc && GetPlaybackMode() == PM_FILE && m_iSpeedLevel <= -4) {
- fEnable = false;
- } else if (!fInc && GetPlaybackMode() == PM_DVD && m_iSpeedLevel <= -11) {
- fEnable = false;
- } else if (GetPlaybackMode() == PM_DVD && m_iDVDDomain != DVD_DOMAIN_Title) {
- fEnable = false;
- } else if (m_fRealMediaGraph || m_fShockwaveGraph) {
- fEnable = false;
- } else if (GetPlaybackMode() == PM_CAPTURE && (!m_wndCaptureBar.m_capdlg.IsTunerActive() || m_fCapturing)) {
- fEnable = false;
- } else if (m_fLiveWM) {
- fEnable = false;
- }
- }
+ bool fEnable = false;
+
+ if (m_iMediaLoadState == MLS_LOADED) {
+ bool fInc = pCmdUI->m_nID == ID_PLAY_INCRATE;
+
+ fEnable = true;
+ if (fInc && m_iSpeedLevel >= 7) {
+ fEnable = false;
+ } else if (!fInc && GetPlaybackMode() == PM_FILE && m_iSpeedLevel <= -4) {
+ fEnable = false;
+ } else if (!fInc && GetPlaybackMode() == PM_DVD && m_iSpeedLevel <= -11) {
+ fEnable = false;
+ } else if (GetPlaybackMode() == PM_DVD && m_iDVDDomain != DVD_DOMAIN_Title) {
+ fEnable = false;
+ } else if (m_fRealMediaGraph || m_fShockwaveGraph) {
+ fEnable = false;
+ } else if (GetPlaybackMode() == PM_CAPTURE && (!m_wndCaptureBar.m_capdlg.IsTunerActive() || m_fCapturing)) {
+ fEnable = false;
+ } else if (m_fLiveWM) {
+ fEnable = false;
+ }
+ }
- pCmdUI->Enable(fEnable);
+ pCmdUI->Enable(fEnable);
}
void CMainFrame::OnPlayResetRate()
{
- if (m_iMediaLoadState != MLS_LOADED) {
- return;
- }
+ if (m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
- HRESULT hr = E_FAIL;
+ HRESULT hr = E_FAIL;
- if (GetMediaState() != State_Running) {
- SendMessage(WM_COMMAND, ID_PLAY_PLAY);
- }
+ if (GetMediaState() != State_Running) {
+ SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ }
- if (GetPlaybackMode() == PM_FILE) {
- hr = pMS->SetRate(1.0);
- } else if (GetPlaybackMode() == PM_DVD) {
- hr = pDVDC->PlayForwards(1.0, DVD_CMD_FLAG_Block, NULL);
- }
+ if (GetPlaybackMode() == PM_FILE) {
+ hr = pMS->SetRate(1.0);
+ } else if (GetPlaybackMode() == PM_DVD) {
+ hr = pDVDC->PlayForwards(1.0, DVD_CMD_FLAG_Block, NULL);
+ }
- if (SUCCEEDED(hr)) {
- m_iSpeedLevel = 0;
- m_dSpeedRate = 1.0;
+ if (SUCCEEDED(hr)) {
+ m_iSpeedLevel = 0;
+ m_dSpeedRate = 1.0;
- CString strODSMessage;
- strODSMessage.Format(IDS_OSD_SPEED, m_dSpeedRate);
- m_OSD.DisplayMessage(OSD_TOPRIGHT, strODSMessage);
- }
+ CString strODSMessage;
+ strODSMessage.Format(IDS_OSD_SPEED, m_dSpeedRate);
+ m_OSD.DisplayMessage(OSD_TOPRIGHT, strODSMessage);
+ }
}
void CMainFrame::OnUpdatePlayResetRate(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED);
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED);
}
void CMainFrame::SetAudioDelay(REFERENCE_TIME rtShift)
{
- if (CComQIPtr<IAudioSwitcherFilter> pASF = FindFilter(__uuidof(CAudioSwitcherFilter), pGB)) {
- pASF->SetAudioTimeShift(rtShift);
+ if (CComQIPtr<IAudioSwitcherFilter> pASF = FindFilter(__uuidof(CAudioSwitcherFilter), pGB)) {
+ pASF->SetAudioTimeShift(rtShift);
- CString str;
- str.Format(IDS_MAINFRM_70, rtShift/10000);
- SendStatusMessage(str, 3000);
- m_OSD.DisplayMessage(OSD_TOPLEFT, str);
- }
+ CString str;
+ str.Format(IDS_MAINFRM_70, rtShift / 10000);
+ SendStatusMessage(str, 3000);
+ m_OSD.DisplayMessage(OSD_TOPLEFT, str);
+ }
}
void CMainFrame::SetSubtitleDelay(int delay_ms)
{
- if (m_pCAP) {
- m_pCAP->SetSubtitleDelay(delay_ms);
+ if (m_pCAP) {
+ m_pCAP->SetSubtitleDelay(delay_ms);
- CString strSubDelay;
- strSubDelay.Format(IDS_MAINFRM_139, delay_ms);
- SendStatusMessage(strSubDelay, 3000);
- m_OSD.DisplayMessage(OSD_TOPLEFT, strSubDelay);
- }
+ CString strSubDelay;
+ strSubDelay.Format(IDS_MAINFRM_139, delay_ms);
+ SendStatusMessage(strSubDelay, 3000);
+ m_OSD.DisplayMessage(OSD_TOPLEFT, strSubDelay);
+ }
}
void CMainFrame::OnPlayChangeAudDelay(UINT nID)
{
- if (CComQIPtr<IAudioSwitcherFilter> pASF = FindFilter(__uuidof(CAudioSwitcherFilter), pGB)) {
- REFERENCE_TIME rtShift = pASF->GetAudioTimeShift();
- rtShift +=
- nID == ID_PLAY_INCAUDDELAY ? 100000 :
- nID == ID_PLAY_DECAUDDELAY ? -100000 :
- 0;
+ if (CComQIPtr<IAudioSwitcherFilter> pASF = FindFilter(__uuidof(CAudioSwitcherFilter), pGB)) {
+ REFERENCE_TIME rtShift = pASF->GetAudioTimeShift();
+ rtShift +=
+ nID == ID_PLAY_INCAUDDELAY ? 100000 :
+ nID == ID_PLAY_DECAUDDELAY ? -100000 :
+ 0;
- SetAudioDelay (rtShift);
- }
+ SetAudioDelay(rtShift);
+ }
}
void CMainFrame::OnUpdatePlayChangeAudDelay(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!!pGB /*&& !!FindFilter(__uuidof(CAudioSwitcherFilter), pGB)*/);
+ pCmdUI->Enable(!!pGB /*&& !!FindFilter(__uuidof(CAudioSwitcherFilter), pGB)*/);
}
void CMainFrame::OnPlayFilters(UINT nID)
{
- //ShowPPage(m_spparray[nID - ID_FILTERS_SUBITEM_START], m_hWnd);
+ //ShowPPage(m_spparray[nID - ID_FILTERS_SUBITEM_START], m_hWnd);
- CComPtr<IUnknown> pUnk = m_pparray[nID - ID_FILTERS_SUBITEM_START];
+ CComPtr<IUnknown> pUnk = m_pparray[nID - ID_FILTERS_SUBITEM_START];
- CComPropertySheet ps(ResStr(IDS_PROPSHEET_PROPERTIES), GetModalParent());
+ CComPropertySheet ps(ResStr(IDS_PROPSHEET_PROPERTIES), GetModalParent());
- if (CComQIPtr<ISpecifyPropertyPages> pSPP = pUnk) {
- ps.AddPages(pSPP);
- }
+ if (CComQIPtr<ISpecifyPropertyPages> pSPP = pUnk) {
+ ps.AddPages(pSPP);
+ }
- if (CComQIPtr<IBaseFilter> pBF = pUnk) {
- HRESULT hr;
- CComPtr<IPropertyPage> pPP = DNew CInternalPropertyPageTempl<CPinInfoWnd>(NULL, &hr);
- ps.AddPage(pPP, pBF);
- }
+ if (CComQIPtr<IBaseFilter> pBF = pUnk) {
+ HRESULT hr;
+ CComPtr<IPropertyPage> pPP = DNew CInternalPropertyPageTempl<CPinInfoWnd>(NULL, &hr);
+ ps.AddPage(pPP, pBF);
+ }
- if (ps.GetPageCount() > 0) {
- ps.DoModal();
- OpenSetupStatusBar();
- }
+ if (ps.GetPageCount() > 0) {
+ ps.DoModal();
+ OpenSetupStatusBar();
+ }
}
void CMainFrame::OnUpdatePlayFilters(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!m_fCapturing);
+ pCmdUI->Enable(!m_fCapturing);
}
enum {
- ID_SHADERS_SELECT = ID_SHADERS_START,
- ID_SHADERS_SELECT_SCREENSPACE
+ ID_SHADERS_SELECT = ID_SHADERS_START,
+ ID_SHADERS_SELECT_SCREENSPACE
};
void CMainFrame::OnPlayShaders(UINT nID)
{
- if (nID == ID_SHADERS_SELECT) {
- if (IDOK != CShaderCombineDlg(m_shaderlabels, m_shaderlabelsScreenSpace, GetModalParent()).DoModal()) {
- return;
- }
- }
+ if (nID == ID_SHADERS_SELECT) {
+ if (IDOK != CShaderCombineDlg(m_shaderlabels, m_shaderlabelsScreenSpace, GetModalParent()).DoModal()) {
+ return;
+ }
+ }
- SetShaders();
+ SetShaders();
}
void CMainFrame::OnPlayAudio(UINT nID)
{
- int i = (int)nID - (1 + ID_AUDIO_SUBITEM_START);
+ int i = (int)nID - (1 + ID_AUDIO_SUBITEM_START);
- CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
- if (!pSS) {
- pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB);
- }
+ CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
+ if (!pSS) {
+ pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB);
+ }
- if (i == -1) {
- ShowOptions(CPPageAudioSwitcher::IDD);
- } else if (i >= 0 && pSS) {
- i = m_iAudioStreams.GetAt(m_iAudioStreams.FindIndex(i)); // don't forget that the audio streams are reordered, so have to figure which one from the initial order is used here
- pSS->Enable(i, AMSTREAMSELECTENABLE_ENABLE);
- }
+ if (i == -1) {
+ ShowOptions(CPPageAudioSwitcher::IDD);
+ } else if (i >= 0 && pSS) {
+ i = m_iAudioStreams.GetAt(m_iAudioStreams.FindIndex(i)); // don't forget that the audio streams are reordered, so have to figure which one from the initial order is used here
+ pSS->Enable(i, AMSTREAMSELECTENABLE_ENABLE);
+ }
}
void CMainFrame::OnUpdatePlayAudio(CCmdUI* pCmdUI)
{
- UINT nID = pCmdUI->m_nID;
- int i = (int)nID - (1 + ID_AUDIO_SUBITEM_START);
-
- CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
- if (!pSS) {
- pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB);
- }
-
- /*if (i == -1)
- {
- // TODO****
- }
- else*/
- if (i >= 0 && pSS) {
- i = m_iAudioStreams.GetAt(m_iAudioStreams.FindIndex(i)); // audio streams are reordered, so figure out which one from the initial order is used here
- DWORD flags = 0;
-
- if (SUCCEEDED(pSS->Info(i, NULL, &flags, NULL, NULL, NULL, NULL, NULL))) {
- if (flags&AMSTREAMSELECTINFO_EXCLUSIVE) {
- pCmdUI->SetRadio(TRUE);
- } else if (flags&AMSTREAMSELECTINFO_ENABLED) {
- pCmdUI->SetCheck(TRUE);
- } else {
- pCmdUI->SetCheck(FALSE);
- }
- } else {
- pCmdUI->Enable(FALSE);
- }
- }
+ UINT nID = pCmdUI->m_nID;
+ int i = (int)nID - (1 + ID_AUDIO_SUBITEM_START);
+
+ CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
+ if (!pSS) {
+ pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB);
+ }
+
+ /*if (i == -1)
+ {
+ // TODO****
+ }
+ else*/
+ if (i >= 0 && pSS) {
+ i = m_iAudioStreams.GetAt(m_iAudioStreams.FindIndex(i)); // audio streams are reordered, so figure out which one from the initial order is used here
+ DWORD flags = 0;
+
+ if (SUCCEEDED(pSS->Info(i, NULL, &flags, NULL, NULL, NULL, NULL, NULL))) {
+ if (flags & AMSTREAMSELECTINFO_EXCLUSIVE) {
+ pCmdUI->SetRadio(TRUE);
+ } else if (flags & AMSTREAMSELECTINFO_ENABLED) {
+ pCmdUI->SetCheck(TRUE);
+ } else {
+ pCmdUI->SetCheck(FALSE);
+ }
+ } else {
+ pCmdUI->Enable(FALSE);
+ }
+ }
}
void CMainFrame::OnPlaySubtitles(UINT nID)
{
- int i = (int)nID - (5 + ID_SUBTITLES_SUBITEM_START); // currently the subtitles submenu contains 5 items, apart from the actual subtitles list
-
- if (i == -5) {
- // options
- ShowOptions(CPPageSubtitles::IDD);
- } else if (i == -4) {
- // styles
- int i = m_iSubtitleSel;
-
- POSITION pos = m_pSubStreams.GetHeadPosition();
- while (pos && i >= 0) {
- CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
-
- if (i < pSubStream->GetStreamCount()) {
- CLSID clsid;
- if (FAILED(pSubStream->GetClassID(&clsid))) {
- continue;
- }
-
- if (clsid == __uuidof(CRenderedTextSubtitle)) {
- CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)pSubStream;
-
- CAutoPtrArray<CPPageSubStyle> pages;
- CAtlArray<STSStyle*> styles;
-
- POSITION pos = pRTS->m_styles.GetStartPosition();
- for (int i = 0; pos; i++) {
- CString key;
- STSStyle* val;
- pRTS->m_styles.GetNextAssoc(pos, key, val);
-
- CAutoPtr<CPPageSubStyle> page(DNew CPPageSubStyle());
- page->InitStyle(key, *val);
- pages.Add(page);
- styles.Add(val);
- }
-
- CString m_style = ResStr(IDS_SUBTITLES_STYLES);
- int i = m_style.Find(_T("&"));
- if (i!=-1 ) {
- m_style.Delete(i, 1);
- }
- CPropertySheet dlg(m_style, GetModalParent());
- for (int i = 0; i < (int)pages.GetCount(); i++) {
- dlg.AddPage(pages[i]);
- }
-
- if (dlg.DoModal() == IDOK) {
- for (int j = 0; j < (int)pages.GetCount(); j++) {
- pages[j]->GetStyle(*styles[j]);
- }
- UpdateSubtitle(false, false);
- }
-
- return;
- }
- }
-
- i -= pSubStream->GetStreamCount();
- }
- } else if (i == -3) {
- // reload
- ReloadSubtitle();
- } else if (i == -2) {
- // enable
- if (m_iSubtitleSel == -1) {
- m_iSubtitleSel = 0;
- } else {
- m_iSubtitleSel ^= (1<<31);
- }
- UpdateSubtitle();
- } else if (i == -1) {
- // override default style
- // TODO: default subtitles style toggle here
- AfxGetAppSettings().fUseDefaultSubtitlesStyle = !AfxGetAppSettings().fUseDefaultSubtitlesStyle;
- UpdateSubtitle();
- } else if (i >= 0) {
- // this is an actual item from the subtitles list
- m_iSubtitleSel = i;
- UpdateSubtitle();
- }
-
- AfxGetAppSettings().fEnableSubtitles = !(m_iSubtitleSel & 0x80000000);
+ int i = (int)nID - (5 + ID_SUBTITLES_SUBITEM_START); // currently the subtitles submenu contains 5 items, apart from the actual subtitles list
+
+ if (i == -5) {
+ // options
+ ShowOptions(CPPageSubtitles::IDD);
+ } else if (i == -4) {
+ // styles
+ int i = m_iSubtitleSel;
+
+ POSITION pos = m_pSubStreams.GetHeadPosition();
+ while (pos && i >= 0) {
+ CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
+
+ if (i < pSubStream->GetStreamCount()) {
+ CLSID clsid;
+ if (FAILED(pSubStream->GetClassID(&clsid))) {
+ continue;
+ }
+
+ if (clsid == __uuidof(CRenderedTextSubtitle)) {
+ CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)pSubStream;
+
+ CAutoPtrArray<CPPageSubStyle> pages;
+ CAtlArray<STSStyle*> styles;
+
+ POSITION pos = pRTS->m_styles.GetStartPosition();
+ for (int i = 0; pos; i++) {
+ CString key;
+ STSStyle* val;
+ pRTS->m_styles.GetNextAssoc(pos, key, val);
+
+ CAutoPtr<CPPageSubStyle> page(DNew CPPageSubStyle());
+ page->InitStyle(key, *val);
+ pages.Add(page);
+ styles.Add(val);
+ }
+
+ CString m_style = ResStr(IDS_SUBTITLES_STYLES);
+ int i = m_style.Find(_T("&"));
+ if (i != -1) {
+ m_style.Delete(i, 1);
+ }
+ CPropertySheet dlg(m_style, GetModalParent());
+ for (int i = 0; i < (int)pages.GetCount(); i++) {
+ dlg.AddPage(pages[i]);
+ }
+
+ if (dlg.DoModal() == IDOK) {
+ for (int j = 0; j < (int)pages.GetCount(); j++) {
+ pages[j]->GetStyle(*styles[j]);
+ }
+ UpdateSubtitle(false, false);
+ }
+
+ return;
+ }
+ }
+
+ i -= pSubStream->GetStreamCount();
+ }
+ } else if (i == -3) {
+ // reload
+ ReloadSubtitle();
+ } else if (i == -2) {
+ // enable
+ if (m_iSubtitleSel == -1) {
+ m_iSubtitleSel = 0;
+ } else {
+ m_iSubtitleSel ^= (1 << 31);
+ }
+ UpdateSubtitle();
+ } else if (i == -1) {
+ // override default style
+ // TODO: default subtitles style toggle here
+ AfxGetAppSettings().fUseDefaultSubtitlesStyle = !AfxGetAppSettings().fUseDefaultSubtitlesStyle;
+ UpdateSubtitle();
+ } else if (i >= 0) {
+ // this is an actual item from the subtitles list
+ m_iSubtitleSel = i;
+ UpdateSubtitle();
+ }
+
+ AfxGetAppSettings().fEnableSubtitles = !(m_iSubtitleSel & 0x80000000);
}
void CMainFrame::OnUpdatePlaySubtitles(CCmdUI* pCmdUI)
{
- UINT nID = pCmdUI->m_nID;
- int i = (int)nID - (5 + ID_SUBTITLES_SUBITEM_START); // again, 5 pre-set subtitles options before the actual list
-
- pCmdUI->Enable(m_pCAP && !m_fAudioOnly);
-
- if (i == -4) {
- // styles
- pCmdUI->Enable(FALSE);
-
- int i = m_iSubtitleSel;
-
- POSITION pos = m_pSubStreams.GetHeadPosition();
- while (pos && i >= 0) {
- CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
-
- if (i < pSubStream->GetStreamCount()) {
- CLSID clsid;
- if (FAILED(pSubStream->GetClassID(&clsid))) {
- continue;
- }
-
- if (clsid == __uuidof(CRenderedTextSubtitle)) {
- pCmdUI->Enable(TRUE);
- break;
- }
- }
-
- i -= pSubStream->GetStreamCount();
- }
- } else if (i == -2) {
- // enabled
- pCmdUI->SetCheck(AfxGetAppSettings().fEnableSubtitles);
- } else if (i == -1) {
- // override
- // TODO: foxX - default subtitles style toggle here; still wip
- pCmdUI->SetCheck(AfxGetAppSettings().fUseDefaultSubtitlesStyle);
- pCmdUI->Enable(AfxGetAppSettings().fEnableSubtitles);
- } else if (i >= 0) {
- pCmdUI->SetRadio(i == abs(m_iSubtitleSel));
- }
+ UINT nID = pCmdUI->m_nID;
+ int i = (int)nID - (5 + ID_SUBTITLES_SUBITEM_START); // again, 5 pre-set subtitles options before the actual list
+
+ pCmdUI->Enable(m_pCAP && !m_fAudioOnly);
+
+ if (i == -4) {
+ // styles
+ pCmdUI->Enable(FALSE);
+
+ int i = m_iSubtitleSel;
+
+ POSITION pos = m_pSubStreams.GetHeadPosition();
+ while (pos && i >= 0) {
+ CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
+
+ if (i < pSubStream->GetStreamCount()) {
+ CLSID clsid;
+ if (FAILED(pSubStream->GetClassID(&clsid))) {
+ continue;
+ }
+
+ if (clsid == __uuidof(CRenderedTextSubtitle)) {
+ pCmdUI->Enable(TRUE);
+ break;
+ }
+ }
+
+ i -= pSubStream->GetStreamCount();
+ }
+ } else if (i == -2) {
+ // enabled
+ pCmdUI->SetCheck(AfxGetAppSettings().fEnableSubtitles);
+ } else if (i == -1) {
+ // override
+ // TODO: foxX - default subtitles style toggle here; still wip
+ pCmdUI->SetCheck(AfxGetAppSettings().fUseDefaultSubtitlesStyle);
+ pCmdUI->Enable(AfxGetAppSettings().fEnableSubtitles);
+ } else if (i >= 0) {
+ pCmdUI->SetRadio(i == abs(m_iSubtitleSel));
+ }
}
void CMainFrame::OnPlayLanguage(UINT nID)
{
- nID -= ID_FILTERSTREAMS_SUBITEM_START;
- CComPtr<IAMStreamSelect> pAMSS = m_ssarray[nID];
- UINT i = nID;
- while (i > 0 && pAMSS == m_ssarray[i-1]) {
- i--;
- }
- if (FAILED(pAMSS->Enable(nID-i, AMSTREAMSELECTENABLE_ENABLE))) {
- MessageBeep((UINT)-1);
- }
+ nID -= ID_FILTERSTREAMS_SUBITEM_START;
+ CComPtr<IAMStreamSelect> pAMSS = m_ssarray[nID];
+ UINT i = nID;
+ while (i > 0 && pAMSS == m_ssarray[i - 1]) {
+ i--;
+ }
+ if (FAILED(pAMSS->Enable(nID - i, AMSTREAMSELECTENABLE_ENABLE))) {
+ MessageBeep((UINT) - 1);
+ }
- OpenSetupStatusBar();
+ OpenSetupStatusBar();
}
void CMainFrame::OnUpdatePlayLanguage(CCmdUI* pCmdUI)
{
- UINT nID = pCmdUI->m_nID;
- nID -= ID_FILTERSTREAMS_SUBITEM_START;
- CComPtr<IAMStreamSelect> pAMSS = m_ssarray[nID];
- UINT i = nID;
- while (i > 0 && pAMSS == m_ssarray[i-1]) {
- i--;
- }
- DWORD flags = 0;
- pAMSS->Info(nID-i, NULL, &flags, NULL, NULL, NULL, NULL, NULL);
- if (flags&AMSTREAMSELECTINFO_EXCLUSIVE) {
- pCmdUI->SetRadio(TRUE);
- } else if (flags&AMSTREAMSELECTINFO_ENABLED) {
- pCmdUI->SetCheck(TRUE);
- } else {
- pCmdUI->SetCheck(FALSE);
- }
+ UINT nID = pCmdUI->m_nID;
+ nID -= ID_FILTERSTREAMS_SUBITEM_START;
+ CComPtr<IAMStreamSelect> pAMSS = m_ssarray[nID];
+ UINT i = nID;
+ while (i > 0 && pAMSS == m_ssarray[i - 1]) {
+ i--;
+ }
+ DWORD flags = 0;
+ pAMSS->Info(nID - i, NULL, &flags, NULL, NULL, NULL, NULL, NULL);
+ if (flags & AMSTREAMSELECTINFO_EXCLUSIVE) {
+ pCmdUI->SetRadio(TRUE);
+ } else if (flags & AMSTREAMSELECTINFO_ENABLED) {
+ pCmdUI->SetCheck(TRUE);
+ } else {
+ pCmdUI->SetCheck(FALSE);
+ }
}
void CMainFrame::OnPlayVolume(UINT nID)
{
- if (m_iMediaLoadState == MLS_LOADED) {
- CString strVolume;
- pBA->put_Volume(m_wndToolBar.Volume);
-
- //strVolume.Format (L"Vol : %d dB", m_wndToolBar.Volume / 100);
- if (m_wndToolBar.Volume == -10000) {
- strVolume.Format(IDS_VOLUME_OSD, 0);
- } else {
- strVolume.Format(IDS_VOLUME_OSD, m_wndToolBar.m_volctrl.GetPos());
- }
- m_OSD.DisplayMessage(OSD_TOPLEFT, strVolume);
- //SendStatusMessage(strVolume, 3000); // Now the volume is displayed in three places at once.
- }
+ if (m_iMediaLoadState == MLS_LOADED) {
+ CString strVolume;
+ pBA->put_Volume(m_wndToolBar.Volume);
+
+ //strVolume.Format (L"Vol : %d dB", m_wndToolBar.Volume / 100);
+ if (m_wndToolBar.Volume == -10000) {
+ strVolume.Format(IDS_VOLUME_OSD, 0);
+ } else {
+ strVolume.Format(IDS_VOLUME_OSD, m_wndToolBar.m_volctrl.GetPos());
+ }
+ m_OSD.DisplayMessage(OSD_TOPLEFT, strVolume);
+ //SendStatusMessage(strVolume, 3000); // Now the volume is displayed in three places at once.
+ }
- //m_Lcd.SetVolume((m_wndToolBar.Volume > -10000 ? m_wndToolBar.m_volctrl.GetPos() : 1));
+ //m_Lcd.SetVolume((m_wndToolBar.Volume > -10000 ? m_wndToolBar.m_volctrl.GetPos() : 1));
}
void CMainFrame::OnPlayVolumeBoost(UINT nID)
{
- AppSettings& s = AfxGetAppSettings();
-
- int i = (int)(s.dAudioBoost_dB*10+0.1);
-
- switch (nID) {
- case ID_VOLUME_BOOST_INC:
- i = min(i+10, 100);
- break;
- case ID_VOLUME_BOOST_DEC:
- i = max(i-10, 0);
- break;
- case ID_VOLUME_BOOST_MIN:
- i = 0;
- break;
- case ID_VOLUME_BOOST_MAX:
- i = 100;
- break;
- }
- s.dAudioBoost_dB = i/10.f;
- SetVolumeBoost(s.dAudioBoost_dB);
+ AppSettings& s = AfxGetAppSettings();
+
+ int i = (int)(s.dAudioBoost_dB * 10 + 0.1);
+
+ switch (nID) {
+ case ID_VOLUME_BOOST_INC:
+ i = min(i + 10, 100);
+ break;
+ case ID_VOLUME_BOOST_DEC:
+ i = max(i - 10, 0);
+ break;
+ case ID_VOLUME_BOOST_MIN:
+ i = 0;
+ break;
+ case ID_VOLUME_BOOST_MAX:
+ i = 100;
+ break;
+ }
+ s.dAudioBoost_dB = i / 10.f;
+ SetVolumeBoost(s.dAudioBoost_dB);
}
void CMainFrame::SetVolumeBoost(float fAudioBoost_dB)
{
- CString strBoost;
- strBoost.Format(IDS_BOOST_OSD, fAudioBoost_dB);
+ CString strBoost;
+ strBoost.Format(IDS_BOOST_OSD, fAudioBoost_dB);
- if (CComQIPtr<IAudioSwitcherFilter> pASF = FindFilter(__uuidof(CAudioSwitcherFilter), pGB)) {
- bool fNormalize, fNormalizeRecover;
- float boost;
- pASF->GetNormalizeBoost(fNormalize, fNormalizeRecover, boost);
- pASF->SetNormalizeBoost(fNormalize, fNormalizeRecover, fAudioBoost_dB);
- m_OSD.DisplayMessage(OSD_TOPLEFT, strBoost);
- }
+ if (CComQIPtr<IAudioSwitcherFilter> pASF = FindFilter(__uuidof(CAudioSwitcherFilter), pGB)) {
+ bool fNormalize, fNormalizeRecover;
+ float boost;
+ pASF->GetNormalizeBoost(fNormalize, fNormalizeRecover, boost);
+ pASF->SetNormalizeBoost(fNormalize, fNormalizeRecover, fAudioBoost_dB);
+ m_OSD.DisplayMessage(OSD_TOPLEFT, strBoost);
+ }
}
void CMainFrame::OnUpdatePlayVolumeBoost(CCmdUI* pCmdUI)
{
- pCmdUI->Enable();
+ pCmdUI->Enable();
}
void CMainFrame::OnCustomChannelMapping()
{
- if (CComQIPtr<IAudioSwitcherFilter> pASF = FindFilter(__uuidof(CAudioSwitcherFilter), pGB)) {
- AppSettings& s = AfxGetAppSettings();
- s.fCustomChannelMapping = !s.fCustomChannelMapping;
- pASF->SetSpeakerConfig(s.fCustomChannelMapping, s.pSpeakerToChannelMap);
- m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(s.fCustomChannelMapping ? IDS_OSD_CUSTOM_CH_MAPPING_ON : IDS_OSD_CUSTOM_CH_MAPPING_OFF));
- }
+ if (CComQIPtr<IAudioSwitcherFilter> pASF = FindFilter(__uuidof(CAudioSwitcherFilter), pGB)) {
+ AppSettings& s = AfxGetAppSettings();
+ s.fCustomChannelMapping = !s.fCustomChannelMapping;
+ pASF->SetSpeakerConfig(s.fCustomChannelMapping, s.pSpeakerToChannelMap);
+ m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(s.fCustomChannelMapping ? IDS_OSD_CUSTOM_CH_MAPPING_ON : IDS_OSD_CUSTOM_CH_MAPPING_OFF));
+ }
}
void CMainFrame::OnUpdateCustomChannelMapping(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- pCmdUI->Enable(s.fEnableAudioSwitcher);
+ AppSettings& s = AfxGetAppSettings();
+ pCmdUI->Enable(s.fEnableAudioSwitcher);
}
void CMainFrame::OnNormalizeRegainVolume(UINT nID)
{
- if (CComQIPtr<IAudioSwitcherFilter> pASF = FindFilter(__uuidof(CAudioSwitcherFilter), pGB)) {
- AppSettings& s = AfxGetAppSettings();
- WORD osdMessage;
-
- switch (nID) {
- case ID_NORMALIZE:
- s.fAudioNormalize = !s.fAudioNormalize;
- osdMessage = s.fAudioNormalize ? IDS_OSD_NORMALIZE_ON : IDS_OSD_NORMALIZE_OFF;
- break;
- case ID_REGAIN_VOLUME:
- s.fAudioNormalizeRecover = !s.fAudioNormalizeRecover;
- osdMessage = s.fAudioNormalizeRecover ? IDS_OSD_REGAIN_VOLUME_ON : IDS_OSD_REGAIN_VOLUME_OFF;
- break;
- }
-
- pASF->SetNormalizeBoost(s.fAudioNormalize, s.fAudioNormalizeRecover, s.dAudioBoost_dB);
- m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(osdMessage));
- }
+ if (CComQIPtr<IAudioSwitcherFilter> pASF = FindFilter(__uuidof(CAudioSwitcherFilter), pGB)) {
+ AppSettings& s = AfxGetAppSettings();
+ WORD osdMessage;
+
+ switch (nID) {
+ case ID_NORMALIZE:
+ s.fAudioNormalize = !s.fAudioNormalize;
+ osdMessage = s.fAudioNormalize ? IDS_OSD_NORMALIZE_ON : IDS_OSD_NORMALIZE_OFF;
+ break;
+ case ID_REGAIN_VOLUME:
+ s.fAudioNormalizeRecover = !s.fAudioNormalizeRecover;
+ osdMessage = s.fAudioNormalizeRecover ? IDS_OSD_REGAIN_VOLUME_ON : IDS_OSD_REGAIN_VOLUME_OFF;
+ break;
+ }
+
+ pASF->SetNormalizeBoost(s.fAudioNormalize, s.fAudioNormalizeRecover, s.dAudioBoost_dB);
+ m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(osdMessage));
+ }
}
void CMainFrame::OnUpdateNormalizeRegainVolume(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- pCmdUI->Enable(s.fEnableAudioSwitcher);
+ AppSettings& s = AfxGetAppSettings();
+ pCmdUI->Enable(s.fEnableAudioSwitcher);
}
void CMainFrame::OnPlayColor(UINT nID)
{
- if (m_pMC || m_pMFVP) {
- AppSettings& s = AfxGetAppSettings();
- //ColorRanges* crs = AfxGetMyApp()->ColorControls;
- int& brightness = s.iBrightness;
- int& contrast = s.iContrast;
- int& hue = s.iHue;
- int& saturation = s.iSaturation;
- CString tmp, str;
- switch (nID) {
-
- case ID_COLOR_BRIGHTNESS_INC:
- brightness += 2;
- case ID_COLOR_BRIGHTNESS_DEC:
- brightness -=1;
- SetColorControl(ProcAmp_Brightness, brightness, contrast, hue, saturation);
- brightness ? tmp.Format(_T("%+d"), brightness) : tmp = _T("0");
- str.Format(IDS_OSD_BRIGHTNESS, tmp);
- break;
-
- case ID_COLOR_CONTRAST_INC:
- contrast += 2;
- case ID_COLOR_CONTRAST_DEC:
- contrast -= 1;
- SetColorControl(ProcAmp_Contrast, brightness, contrast, hue, saturation);
- contrast ? tmp.Format(_T("%+d"), contrast) : tmp = _T("0");
- str.Format(IDS_OSD_CONTRAST, tmp);
- break;
-
- case ID_COLOR_HUE_INC:
- hue += 2;
- case ID_COLOR_HUE_DEC:
- hue -= 1;
- SetColorControl(ProcAmp_Hue, brightness, contrast, hue, saturation);
- hue ? tmp.Format(_T("%+d"), hue) : tmp = _T("0");
- str.Format(IDS_OSD_HUE, tmp);
- break;
-
- case ID_COLOR_SATURATION_INC:
- saturation += 2;
- case ID_COLOR_SATURATION_DEC:
- saturation -= 1;
- SetColorControl(ProcAmp_Saturation, brightness, contrast, hue, saturation);
- saturation ? tmp.Format(_T("%+d"), saturation) : tmp = _T("0");
- str.Format(IDS_OSD_SATURATION, tmp);
- break;
-
- case ID_COLOR_RESET:
- brightness = AfxGetMyApp()->GetColorControl(ProcAmp_Brightness)->DefaultValue;
- contrast = AfxGetMyApp()->GetColorControl(ProcAmp_Contrast)->DefaultValue;
- hue = AfxGetMyApp()->GetColorControl(ProcAmp_Hue)->DefaultValue;
- saturation = AfxGetMyApp()->GetColorControl(ProcAmp_Saturation)->DefaultValue;
- SetColorControl(ProcAmp_All, brightness, contrast, hue, saturation);
- str.LoadString(IDS_OSD_RESET_COLOR);
- break;
- }
- m_OSD.DisplayMessage(OSD_TOPLEFT, str);
- } else {
- m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_OSD_NO_COLORCONTROL));
- }
+ if (m_pMC || m_pMFVP) {
+ AppSettings& s = AfxGetAppSettings();
+ //ColorRanges* crs = AfxGetMyApp()->ColorControls;
+ int& brightness = s.iBrightness;
+ int& contrast = s.iContrast;
+ int& hue = s.iHue;
+ int& saturation = s.iSaturation;
+ CString tmp, str;
+ switch (nID) {
+
+ case ID_COLOR_BRIGHTNESS_INC:
+ brightness += 2;
+ case ID_COLOR_BRIGHTNESS_DEC:
+ brightness -= 1;
+ SetColorControl(ProcAmp_Brightness, brightness, contrast, hue, saturation);
+ brightness ? tmp.Format(_T("%+d"), brightness) : tmp = _T("0");
+ str.Format(IDS_OSD_BRIGHTNESS, tmp);
+ break;
+
+ case ID_COLOR_CONTRAST_INC:
+ contrast += 2;
+ case ID_COLOR_CONTRAST_DEC:
+ contrast -= 1;
+ SetColorControl(ProcAmp_Contrast, brightness, contrast, hue, saturation);
+ contrast ? tmp.Format(_T("%+d"), contrast) : tmp = _T("0");
+ str.Format(IDS_OSD_CONTRAST, tmp);
+ break;
+
+ case ID_COLOR_HUE_INC:
+ hue += 2;
+ case ID_COLOR_HUE_DEC:
+ hue -= 1;
+ SetColorControl(ProcAmp_Hue, brightness, contrast, hue, saturation);
+ hue ? tmp.Format(_T("%+d"), hue) : tmp = _T("0");
+ str.Format(IDS_OSD_HUE, tmp);
+ break;
+
+ case ID_COLOR_SATURATION_INC:
+ saturation += 2;
+ case ID_COLOR_SATURATION_DEC:
+ saturation -= 1;
+ SetColorControl(ProcAmp_Saturation, brightness, contrast, hue, saturation);
+ saturation ? tmp.Format(_T("%+d"), saturation) : tmp = _T("0");
+ str.Format(IDS_OSD_SATURATION, tmp);
+ break;
+
+ case ID_COLOR_RESET:
+ brightness = AfxGetMyApp()->GetColorControl(ProcAmp_Brightness)->DefaultValue;
+ contrast = AfxGetMyApp()->GetColorControl(ProcAmp_Contrast)->DefaultValue;
+ hue = AfxGetMyApp()->GetColorControl(ProcAmp_Hue)->DefaultValue;
+ saturation = AfxGetMyApp()->GetColorControl(ProcAmp_Saturation)->DefaultValue;
+ SetColorControl(ProcAmp_All, brightness, contrast, hue, saturation);
+ str.LoadString(IDS_OSD_RESET_COLOR);
+ break;
+ }
+ m_OSD.DisplayMessage(OSD_TOPLEFT, str);
+ } else {
+ m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_OSD_NO_COLORCONTROL));
+ }
}
void CMainFrame::OnAfterplayback(UINT nID)
{
- AppSettings& s = AfxGetAppSettings();
- s.nCLSwitches &= ~CLSW_AFTERPLAYBACK_MASK;
- WORD osdMsg;
-
- switch (nID) {
- case ID_AFTERPLAYBACK_NEXT:
- s.fNextInDirAfterPlayback = true;
- s.fExitAfterPlayback = false;
- osdMsg = IDS_AFTERPLAYBACK_NEXT;
- break;
- case ID_AFTERPLAYBACK_EXIT:
- s.fExitAfterPlayback = true;
- s.fNextInDirAfterPlayback = false;
- osdMsg = IDS_AFTERPLAYBACK_EXIT;
- break;
- case ID_AFTERPLAYBACK_DONOTHING:
- s.fExitAfterPlayback = false;
- s.fNextInDirAfterPlayback = false;
- osdMsg = IDS_AFTERPLAYBACK_DONOTHING;
- break;
- case ID_AFTERPLAYBACK_CLOSE:
- s.nCLSwitches |= CLSW_CLOSE;
- osdMsg = IDS_AFTERPLAYBACK_CLOSE;
- break;
- case ID_AFTERPLAYBACK_STANDBY:
- s.nCLSwitches |= CLSW_STANDBY;
- osdMsg = IDS_AFTERPLAYBACK_STANDBY;
- break;
- case ID_AFTERPLAYBACK_HIBERNATE:
- s.nCLSwitches |= CLSW_HIBERNATE;
- osdMsg = IDS_AFTERPLAYBACK_HIBERNATE;
- break;
- case ID_AFTERPLAYBACK_SHUTDOWN:
- s.nCLSwitches |= CLSW_SHUTDOWN;
- osdMsg = IDS_AFTERPLAYBACK_SHUTDOWN;
- break;
- case ID_AFTERPLAYBACK_LOGOFF:
- s.nCLSwitches |= CLSW_LOGOFF;
- osdMsg = IDS_AFTERPLAYBACK_LOGOFF;
- break;
- case ID_AFTERPLAYBACK_LOCK:
- s.nCLSwitches |= CLSW_LOCK;
- osdMsg = IDS_AFTERPLAYBACK_LOCK;
- break;
- }
-
- m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(osdMsg));
+ AppSettings& s = AfxGetAppSettings();
+ s.nCLSwitches &= ~CLSW_AFTERPLAYBACK_MASK;
+ WORD osdMsg;
+
+ switch (nID) {
+ case ID_AFTERPLAYBACK_NEXT:
+ s.fNextInDirAfterPlayback = true;
+ s.fExitAfterPlayback = false;
+ osdMsg = IDS_AFTERPLAYBACK_NEXT;
+ break;
+ case ID_AFTERPLAYBACK_EXIT:
+ s.fExitAfterPlayback = true;
+ s.fNextInDirAfterPlayback = false;
+ osdMsg = IDS_AFTERPLAYBACK_EXIT;
+ break;
+ case ID_AFTERPLAYBACK_DONOTHING:
+ s.fExitAfterPlayback = false;
+ s.fNextInDirAfterPlayback = false;
+ osdMsg = IDS_AFTERPLAYBACK_DONOTHING;
+ break;
+ case ID_AFTERPLAYBACK_CLOSE:
+ s.nCLSwitches |= CLSW_CLOSE;
+ osdMsg = IDS_AFTERPLAYBACK_CLOSE;
+ break;
+ case ID_AFTERPLAYBACK_STANDBY:
+ s.nCLSwitches |= CLSW_STANDBY;
+ osdMsg = IDS_AFTERPLAYBACK_STANDBY;
+ break;
+ case ID_AFTERPLAYBACK_HIBERNATE:
+ s.nCLSwitches |= CLSW_HIBERNATE;
+ osdMsg = IDS_AFTERPLAYBACK_HIBERNATE;
+ break;
+ case ID_AFTERPLAYBACK_SHUTDOWN:
+ s.nCLSwitches |= CLSW_SHUTDOWN;
+ osdMsg = IDS_AFTERPLAYBACK_SHUTDOWN;
+ break;
+ case ID_AFTERPLAYBACK_LOGOFF:
+ s.nCLSwitches |= CLSW_LOGOFF;
+ osdMsg = IDS_AFTERPLAYBACK_LOGOFF;
+ break;
+ case ID_AFTERPLAYBACK_LOCK:
+ s.nCLSwitches |= CLSW_LOCK;
+ osdMsg = IDS_AFTERPLAYBACK_LOCK;
+ break;
+ }
+
+ m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(osdMsg));
}
void CMainFrame::OnUpdateAfterplayback(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
- bool fChecked = false;
-
- switch (pCmdUI->m_nID) {
- case ID_AFTERPLAYBACK_EXIT:
- fChecked = !!s.fExitAfterPlayback;
- break;
- case ID_AFTERPLAYBACK_NEXT:
- fChecked = !!s.fNextInDirAfterPlayback;
- break;
- case ID_AFTERPLAYBACK_CLOSE:
- fChecked = !!(s.nCLSwitches & CLSW_CLOSE);
- break;
- case ID_AFTERPLAYBACK_STANDBY:
- fChecked = !!(s.nCLSwitches & CLSW_STANDBY);
- break;
- case ID_AFTERPLAYBACK_HIBERNATE:
- fChecked = !!(s.nCLSwitches & CLSW_HIBERNATE);
- break;
- case ID_AFTERPLAYBACK_SHUTDOWN:
- fChecked = !!(s.nCLSwitches & CLSW_SHUTDOWN);
- break;
- case ID_AFTERPLAYBACK_LOGOFF:
- fChecked = !!(s.nCLSwitches & CLSW_LOGOFF);
- break;
- case ID_AFTERPLAYBACK_LOCK:
- fChecked = !!(s.nCLSwitches & CLSW_LOCK);
- break;
- case ID_AFTERPLAYBACK_DONOTHING:
- fChecked = (!s.fExitAfterPlayback) && (!s.fNextInDirAfterPlayback);
- break;
- }
-
- pCmdUI->SetRadio(fChecked);
+ AppSettings& s = AfxGetAppSettings();
+ bool fChecked = false;
+
+ switch (pCmdUI->m_nID) {
+ case ID_AFTERPLAYBACK_EXIT:
+ fChecked = !!s.fExitAfterPlayback;
+ break;
+ case ID_AFTERPLAYBACK_NEXT:
+ fChecked = !!s.fNextInDirAfterPlayback;
+ break;
+ case ID_AFTERPLAYBACK_CLOSE:
+ fChecked = !!(s.nCLSwitches & CLSW_CLOSE);
+ break;
+ case ID_AFTERPLAYBACK_STANDBY:
+ fChecked = !!(s.nCLSwitches & CLSW_STANDBY);
+ break;
+ case ID_AFTERPLAYBACK_HIBERNATE:
+ fChecked = !!(s.nCLSwitches & CLSW_HIBERNATE);
+ break;
+ case ID_AFTERPLAYBACK_SHUTDOWN:
+ fChecked = !!(s.nCLSwitches & CLSW_SHUTDOWN);
+ break;
+ case ID_AFTERPLAYBACK_LOGOFF:
+ fChecked = !!(s.nCLSwitches & CLSW_LOGOFF);
+ break;
+ case ID_AFTERPLAYBACK_LOCK:
+ fChecked = !!(s.nCLSwitches & CLSW_LOCK);
+ break;
+ case ID_AFTERPLAYBACK_DONOTHING:
+ fChecked = (!s.fExitAfterPlayback) && (!s.fNextInDirAfterPlayback);
+ break;
+ }
+
+ pCmdUI->SetRadio(fChecked);
}
// navigate
void CMainFrame::OnNavigateSkip(UINT nID)
{
- if (GetPlaybackMode() == PM_FILE) {
- SetupChapters();
-
- flast_nID = nID;
-
- if (DWORD nChapters = m_pCB->ChapGetCount()) {
- REFERENCE_TIME rtCur;
- pMS->GetCurrentPosition(&rtCur);
-
- REFERENCE_TIME rt = rtCur;
- CComBSTR name;
- long i = 0;
-
- if (nID == ID_NAVIGATE_SKIPBACK) {
- rt -= 30000000;
- i = m_pCB->ChapLookup(&rt, &name);
- } else if (nID == ID_NAVIGATE_SKIPFORWARD) {
- i = m_pCB->ChapLookup(&rt, &name) + 1;
- name.Empty();
- if (i < (int)nChapters) {
- m_pCB->ChapGet(i, &rt, &name);
- }
- }
-
- if (i >= 0 && (DWORD)i < nChapters) {
- SeekTo(rt);
- SendStatusMessage(ResStr(IDS_AG_CHAPTER2) + CString(name), 3000);
-
- REFERENCE_TIME rtDur;
- pMS->GetDuration(&rtDur);
- CString m_strOSD;
- m_strOSD.Format(_T("%s/%s %s%d/%d - \"%s\""), ReftimeToString2(rt), ReftimeToString2(rtDur), ResStr(IDS_AG_CHAPTER2), i+1, nChapters, name);
- m_OSD.DisplayMessage(OSD_TOPLEFT, m_strOSD, 3000);
- return;
- }
- }
-
- if (nID == ID_NAVIGATE_SKIPBACK) {
- SendMessage(WM_COMMAND, ID_NAVIGATE_SKIPBACKFILE);
- } else if (nID == ID_NAVIGATE_SKIPFORWARD) {
- SendMessage(WM_COMMAND, ID_NAVIGATE_SKIPFORWARDFILE);
- }
- } else if (GetPlaybackMode() == PM_DVD) {
- m_iSpeedLevel = 0;
- m_dSpeedRate = 1.0;
-
- if (GetMediaState() != State_Running) {
- SendMessage(WM_COMMAND, ID_PLAY_PLAY);
- }
-
- ULONG ulNumOfVolumes, ulVolume;
- DVD_DISC_SIDE Side;
- ULONG ulNumOfTitles = 0;
- pDVDI->GetDVDVolumeInfo(&ulNumOfVolumes, &ulVolume, &Side, &ulNumOfTitles);
-
- DVD_PLAYBACK_LOCATION2 Location;
- pDVDI->GetCurrentLocation(&Location);
-
- ULONG ulNumOfChapters = 0;
- pDVDI->GetNumberOfChapters(Location.TitleNum, &ulNumOfChapters);
-
- if (nID == ID_NAVIGATE_SKIPBACK) {
- if (Location.ChapterNum == 1 && Location.TitleNum > 1) {
- pDVDI->GetNumberOfChapters(Location.TitleNum-1, &ulNumOfChapters);
- pDVDC->PlayChapterInTitle(Location.TitleNum-1, ulNumOfChapters, DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
- } else {
- ULONG tsec = (Location.TimeCode.bHours * 3600)
- + (Location.TimeCode.bMinutes * 60)
- + (Location.TimeCode.bSeconds);
- ULONG diff = 0;
- if ( m_lChapterStartTime != 0xFFFFFFFF && tsec > m_lChapterStartTime ) {
- diff = tsec - m_lChapterStartTime;
- }
- // Restart the chapter if more than 7 seconds have passed
- if ( diff <= 7 ) {
- pDVDC->PlayPrevChapter(DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
- } else {
- pDVDC->ReplayChapter(DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
- }
- }
- } else if (nID == ID_NAVIGATE_SKIPFORWARD) {
- if (Location.ChapterNum == ulNumOfChapters && Location.TitleNum < ulNumOfTitles) {
- pDVDC->PlayChapterInTitle(Location.TitleNum+1, 1, DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
- } else {
- pDVDC->PlayNextChapter(DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
- }
- }
-
- if ((pDVDI->GetCurrentLocation(&Location) == S_OK)) {
- pDVDI->GetNumberOfChapters(Location.TitleNum, &ulNumOfChapters);
- CString m_strTitle;
- m_strTitle.Format(IDS_AG_TITLE2, Location.TitleNum, ulNumOfTitles);
- __int64 start, stop;
- m_wndSeekBar.GetRange(start, stop);
-
- CString m_strOSD;
- if (stop > 0) {
- DVD_HMSF_TIMECODE stopHMSF = RT2HMS_r(stop);
- m_strOSD.Format(_T("%s/%s %s, %s%02d/%02d"), DVDtimeToString(Location.TimeCode, stopHMSF.bHours > 0), DVDtimeToString(stopHMSF),
- m_strTitle, ResStr(IDS_AG_CHAPTER2), Location.ChapterNum, ulNumOfChapters);
- } else {
- m_strOSD.Format(_T("%s, %s%02d/%02d"), m_strTitle, ResStr(IDS_AG_CHAPTER2), Location.ChapterNum, ulNumOfChapters);
- }
-
- m_OSD.DisplayMessage(OSD_TOPLEFT, m_strOSD, 3000);
- }
-
- /*
- if (nID == ID_NAVIGATE_SKIPBACK)
- pDVDC->PlayPrevChapter(DVD_CMD_FLAG_Block, NULL);
- else if (nID == ID_NAVIGATE_SKIPFORWARD)
- pDVDC->PlayNextChapter(DVD_CMD_FLAG_Block, NULL);
- */
- } else if (GetPlaybackMode() == PM_CAPTURE) {
- if (AfxGetAppSettings().iDefaultCaptureDevice == 1) {
- CComQIPtr<IBDATuner> pTun = pGB;
- if (pTun) {
- int nCurrentChannel;
- AppSettings& s = AfxGetAppSettings();
-
- nCurrentChannel = s.nDVBLastChannel;
-
- if (nID == ID_NAVIGATE_SKIPBACK) {
- pTun->SetChannel (nCurrentChannel - 1);
- DisplayCurrentChannelOSD();
- if (m_wndNavigationBar.IsVisible()) {
- m_wndNavigationBar.m_navdlg.UpdatePos(nCurrentChannel - 1);
- }
- } else if (nID == ID_NAVIGATE_SKIPFORWARD) {
- pTun->SetChannel (nCurrentChannel + 1);
- DisplayCurrentChannelOSD();
- if (m_wndNavigationBar.IsVisible()) {
- m_wndNavigationBar.m_navdlg.UpdatePos(nCurrentChannel + 1);
- }
- }
-
- }
- }
-
- }
+ if (GetPlaybackMode() == PM_FILE) {
+ SetupChapters();
+
+ flast_nID = nID;
+
+ if (DWORD nChapters = m_pCB->ChapGetCount()) {
+ REFERENCE_TIME rtCur;
+ pMS->GetCurrentPosition(&rtCur);
+
+ REFERENCE_TIME rt = rtCur;
+ CComBSTR name;
+ long i = 0;
+
+ if (nID == ID_NAVIGATE_SKIPBACK) {
+ rt -= 30000000;
+ i = m_pCB->ChapLookup(&rt, &name);
+ } else if (nID == ID_NAVIGATE_SKIPFORWARD) {
+ i = m_pCB->ChapLookup(&rt, &name) + 1;
+ name.Empty();
+ if (i < (int)nChapters) {
+ m_pCB->ChapGet(i, &rt, &name);
+ }
+ }
+
+ if (i >= 0 && (DWORD)i < nChapters) {
+ SeekTo(rt);
+ SendStatusMessage(ResStr(IDS_AG_CHAPTER2) + CString(name), 3000);
+
+ REFERENCE_TIME rtDur;
+ pMS->GetDuration(&rtDur);
+ CString m_strOSD;
+ m_strOSD.Format(_T("%s/%s %s%d/%d - \"%s\""), ReftimeToString2(rt), ReftimeToString2(rtDur), ResStr(IDS_AG_CHAPTER2), i + 1, nChapters, name);
+ m_OSD.DisplayMessage(OSD_TOPLEFT, m_strOSD, 3000);
+ return;
+ }
+ }
+
+ if (nID == ID_NAVIGATE_SKIPBACK) {
+ SendMessage(WM_COMMAND, ID_NAVIGATE_SKIPBACKFILE);
+ } else if (nID == ID_NAVIGATE_SKIPFORWARD) {
+ SendMessage(WM_COMMAND, ID_NAVIGATE_SKIPFORWARDFILE);
+ }
+ } else if (GetPlaybackMode() == PM_DVD) {
+ m_iSpeedLevel = 0;
+ m_dSpeedRate = 1.0;
+
+ if (GetMediaState() != State_Running) {
+ SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ }
+
+ ULONG ulNumOfVolumes, ulVolume;
+ DVD_DISC_SIDE Side;
+ ULONG ulNumOfTitles = 0;
+ pDVDI->GetDVDVolumeInfo(&ulNumOfVolumes, &ulVolume, &Side, &ulNumOfTitles);
+
+ DVD_PLAYBACK_LOCATION2 Location;
+ pDVDI->GetCurrentLocation(&Location);
+
+ ULONG ulNumOfChapters = 0;
+ pDVDI->GetNumberOfChapters(Location.TitleNum, &ulNumOfChapters);
+
+ if (nID == ID_NAVIGATE_SKIPBACK) {
+ if (Location.ChapterNum == 1 && Location.TitleNum > 1) {
+ pDVDI->GetNumberOfChapters(Location.TitleNum - 1, &ulNumOfChapters);
+ pDVDC->PlayChapterInTitle(Location.TitleNum - 1, ulNumOfChapters, DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
+ } else {
+ ULONG tsec = (Location.TimeCode.bHours * 3600)
+ + (Location.TimeCode.bMinutes * 60)
+ + (Location.TimeCode.bSeconds);
+ ULONG diff = 0;
+ if (m_lChapterStartTime != 0xFFFFFFFF && tsec > m_lChapterStartTime) {
+ diff = tsec - m_lChapterStartTime;
+ }
+ // Restart the chapter if more than 7 seconds have passed
+ if (diff <= 7) {
+ pDVDC->PlayPrevChapter(DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
+ } else {
+ pDVDC->ReplayChapter(DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
+ }
+ }
+ } else if (nID == ID_NAVIGATE_SKIPFORWARD) {
+ if (Location.ChapterNum == ulNumOfChapters && Location.TitleNum < ulNumOfTitles) {
+ pDVDC->PlayChapterInTitle(Location.TitleNum + 1, 1, DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
+ } else {
+ pDVDC->PlayNextChapter(DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
+ }
+ }
+
+ if ((pDVDI->GetCurrentLocation(&Location) == S_OK)) {
+ pDVDI->GetNumberOfChapters(Location.TitleNum, &ulNumOfChapters);
+ CString m_strTitle;
+ m_strTitle.Format(IDS_AG_TITLE2, Location.TitleNum, ulNumOfTitles);
+ __int64 start, stop;
+ m_wndSeekBar.GetRange(start, stop);
+
+ CString m_strOSD;
+ if (stop > 0) {
+ DVD_HMSF_TIMECODE stopHMSF = RT2HMS_r(stop);
+ m_strOSD.Format(_T("%s/%s %s, %s%02d/%02d"), DVDtimeToString(Location.TimeCode, stopHMSF.bHours > 0), DVDtimeToString(stopHMSF),
+ m_strTitle, ResStr(IDS_AG_CHAPTER2), Location.ChapterNum, ulNumOfChapters);
+ } else {
+ m_strOSD.Format(_T("%s, %s%02d/%02d"), m_strTitle, ResStr(IDS_AG_CHAPTER2), Location.ChapterNum, ulNumOfChapters);
+ }
+
+ m_OSD.DisplayMessage(OSD_TOPLEFT, m_strOSD, 3000);
+ }
+
+ /*
+ if (nID == ID_NAVIGATE_SKIPBACK)
+ pDVDC->PlayPrevChapter(DVD_CMD_FLAG_Block, NULL);
+ else if (nID == ID_NAVIGATE_SKIPFORWARD)
+ pDVDC->PlayNextChapter(DVD_CMD_FLAG_Block, NULL);
+ */
+ } else if (GetPlaybackMode() == PM_CAPTURE) {
+ if (AfxGetAppSettings().iDefaultCaptureDevice == 1) {
+ CComQIPtr<IBDATuner> pTun = pGB;
+ if (pTun) {
+ int nCurrentChannel;
+ AppSettings& s = AfxGetAppSettings();
+
+ nCurrentChannel = s.nDVBLastChannel;
+
+ if (nID == ID_NAVIGATE_SKIPBACK) {
+ pTun->SetChannel(nCurrentChannel - 1);
+ DisplayCurrentChannelOSD();
+ if (m_wndNavigationBar.IsVisible()) {
+ m_wndNavigationBar.m_navdlg.UpdatePos(nCurrentChannel - 1);
+ }
+ } else if (nID == ID_NAVIGATE_SKIPFORWARD) {
+ pTun->SetChannel(nCurrentChannel + 1);
+ DisplayCurrentChannelOSD();
+ if (m_wndNavigationBar.IsVisible()) {
+ m_wndNavigationBar.m_navdlg.UpdatePos(nCurrentChannel + 1);
+ }
+ }
+
+ }
+ }
+
+ }
}
void CMainFrame::OnUpdateNavigateSkip(CCmdUI* pCmdUI)
{
- // moved to the timer callback function, that runs less frequent
- //if (GetPlaybackMode() == PM_FILE) SetupChapters();
+ // moved to the timer callback function, that runs less frequent
+ //if (GetPlaybackMode() == PM_FILE) SetupChapters();
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED
- && ((GetPlaybackMode() == PM_DVD
- && m_iDVDDomain != DVD_DOMAIN_VideoManagerMenu
- && m_iDVDDomain != DVD_DOMAIN_VideoTitleSetMenu)
- || (GetPlaybackMode() == PM_FILE && AfxGetAppSettings().fUseSearchInFolder)
- || (GetPlaybackMode() == PM_FILE && !AfxGetAppSettings().fUseSearchInFolder && (m_wndPlaylistBar.GetCount() > 1 || m_pCB->ChapGetCount() > 1))
- || (GetPlaybackMode() == PM_CAPTURE && !m_fCapturing)));
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED
+ && ((GetPlaybackMode() == PM_DVD
+ && m_iDVDDomain != DVD_DOMAIN_VideoManagerMenu
+ && m_iDVDDomain != DVD_DOMAIN_VideoTitleSetMenu)
+ || (GetPlaybackMode() == PM_FILE && AfxGetAppSettings().fUseSearchInFolder)
+ || (GetPlaybackMode() == PM_FILE && !AfxGetAppSettings().fUseSearchInFolder && (m_wndPlaylistBar.GetCount() > 1 || m_pCB->ChapGetCount() > 1))
+ || (GetPlaybackMode() == PM_CAPTURE && !m_fCapturing)));
}
void CMainFrame::OnNavigateSkipFile(UINT nID)
{
- if (GetPlaybackMode() == PM_FILE || GetPlaybackMode() == PM_CAPTURE) {
- if (m_wndPlaylistBar.GetCount() == 1) {
- if (GetPlaybackMode() == PM_CAPTURE || !AfxGetAppSettings().fUseSearchInFolder) {
- SendMessage(WM_COMMAND, ID_PLAY_STOP); // do not remove this, unless you want a circular call with OnPlayPlay()
- SendMessage(WM_COMMAND, ID_PLAY_PLAY);
- } else {
- if (nID == ID_NAVIGATE_SKIPBACKFILE) {
- if (!SearchInDir(false)) {
- m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_FIRST_IN_FOLDER));
- }
- } else if (nID == ID_NAVIGATE_SKIPFORWARDFILE) {
- if (!SearchInDir(true)) {
- m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_LAST_IN_FOLDER));
- }
- }
- }
- } else {
- if (nID == ID_NAVIGATE_SKIPBACKFILE) {
- m_wndPlaylistBar.SetPrev();
- } else if (nID == ID_NAVIGATE_SKIPFORWARDFILE) {
- m_wndPlaylistBar.SetNext();
- }
-
- OpenCurPlaylistItem();
- }
- }
+ if (GetPlaybackMode() == PM_FILE || GetPlaybackMode() == PM_CAPTURE) {
+ if (m_wndPlaylistBar.GetCount() == 1) {
+ if (GetPlaybackMode() == PM_CAPTURE || !AfxGetAppSettings().fUseSearchInFolder) {
+ SendMessage(WM_COMMAND, ID_PLAY_STOP); // do not remove this, unless you want a circular call with OnPlayPlay()
+ SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ } else {
+ if (nID == ID_NAVIGATE_SKIPBACKFILE) {
+ if (!SearchInDir(false)) {
+ m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_FIRST_IN_FOLDER));
+ }
+ } else if (nID == ID_NAVIGATE_SKIPFORWARDFILE) {
+ if (!SearchInDir(true)) {
+ m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_LAST_IN_FOLDER));
+ }
+ }
+ }
+ } else {
+ if (nID == ID_NAVIGATE_SKIPBACKFILE) {
+ m_wndPlaylistBar.SetPrev();
+ } else if (nID == ID_NAVIGATE_SKIPFORWARDFILE) {
+ m_wndPlaylistBar.SetNext();
+ }
+
+ OpenCurPlaylistItem();
+ }
+ }
}
void CMainFrame::OnUpdateNavigateSkipFile(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED
- && ((GetPlaybackMode() == PM_FILE && (m_wndPlaylistBar.GetCount() > 1 || AfxGetAppSettings().fUseSearchInFolder))
- || (GetPlaybackMode() == PM_CAPTURE && !m_fCapturing && m_wndPlaylistBar.GetCount() > 1)));
+ pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED
+ && ((GetPlaybackMode() == PM_FILE && (m_wndPlaylistBar.GetCount() > 1 || AfxGetAppSettings().fUseSearchInFolder))
+ || (GetPlaybackMode() == PM_CAPTURE && !m_fCapturing && m_wndPlaylistBar.GetCount() > 1)));
}
void CMainFrame::OnNavigateMenu(UINT nID)
{
- nID -= ID_NAVIGATE_TITLEMENU;
+ nID -= ID_NAVIGATE_TITLEMENU;
- if (m_iMediaLoadState != MLS_LOADED || GetPlaybackMode() != PM_DVD) {
- return;
- }
+ if (m_iMediaLoadState != MLS_LOADED || GetPlaybackMode() != PM_DVD) {
+ return;
+ }
- m_iSpeedLevel = 0;
- m_dSpeedRate = 1.0;
+ m_iSpeedLevel = 0;
+ m_dSpeedRate = 1.0;
- if (GetMediaState() != State_Running) {
- SendMessage(WM_COMMAND, ID_PLAY_PLAY);
- }
+ if (GetMediaState() != State_Running) {
+ SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ }
- pDVDC->ShowMenu((DVD_MENU_ID)(nID+2), DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
+ pDVDC->ShowMenu((DVD_MENU_ID)(nID + 2), DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
}
void CMainFrame::OnUpdateNavigateMenu(CCmdUI* pCmdUI)
{
- UINT nID = pCmdUI->m_nID - ID_NAVIGATE_TITLEMENU;
- ULONG ulUOPs;
+ UINT nID = pCmdUI->m_nID - ID_NAVIGATE_TITLEMENU;
+ ULONG ulUOPs;
- if (m_iMediaLoadState != MLS_LOADED || GetPlaybackMode() != PM_DVD
- || FAILED(pDVDI->GetCurrentUOPS(&ulUOPs))) {
- pCmdUI->Enable(FALSE);
- return;
- }
+ if (m_iMediaLoadState != MLS_LOADED || GetPlaybackMode() != PM_DVD
+ || FAILED(pDVDI->GetCurrentUOPS(&ulUOPs))) {
+ pCmdUI->Enable(FALSE);
+ return;
+ }
- pCmdUI->Enable(!(ulUOPs & (UOP_FLAG_ShowMenu_Title << nID)));
+ pCmdUI->Enable(!(ulUOPs & (UOP_FLAG_ShowMenu_Title << nID)));
}
void CMainFrame::OnNavigateAudio(UINT nID)
{
- nID -= ID_NAVIGATE_AUDIO_SUBITEM_START;
+ nID -= ID_NAVIGATE_AUDIO_SUBITEM_START;
- if (GetPlaybackMode() == PM_FILE || (GetPlaybackMode() == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1)) {
- OnNavStreamSelectSubMenu(nID, 1);
- } else if (GetPlaybackMode() == PM_DVD) {
- pDVDC->SelectAudioStream(nID, DVD_CMD_FLAG_Block, NULL);
- }
+ if (GetPlaybackMode() == PM_FILE || (GetPlaybackMode() == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1)) {
+ OnNavStreamSelectSubMenu(nID, 1);
+ } else if (GetPlaybackMode() == PM_DVD) {
+ pDVDC->SelectAudioStream(nID, DVD_CMD_FLAG_Block, NULL);
+ }
}
void CMainFrame::OnNavigateSubpic(UINT nID)
{
- if (GetPlaybackMode() == PM_FILE || (GetPlaybackMode() == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1)) {
- OnNavStreamSelectSubMenu(nID - ID_NAVIGATE_SUBP_SUBITEM_START, 2);
- } else if (GetPlaybackMode() == PM_DVD) {
- int i = (int)nID - (1 + ID_NAVIGATE_SUBP_SUBITEM_START);
-
- if (i == -1) {
- ULONG ulStreamsAvailable, ulCurrentStream;
- BOOL bIsDisabled;
- if (SUCCEEDED(pDVDI->GetCurrentSubpicture(&ulStreamsAvailable, &ulCurrentStream, &bIsDisabled))) {
- pDVDC->SetSubpictureState(bIsDisabled, DVD_CMD_FLAG_Block, NULL);
- }
- } else {
- pDVDC->SelectSubpictureStream(i, DVD_CMD_FLAG_Block, NULL);
- pDVDC->SetSubpictureState(TRUE, DVD_CMD_FLAG_Block, NULL);
- }
- }
+ if (GetPlaybackMode() == PM_FILE || (GetPlaybackMode() == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1)) {
+ OnNavStreamSelectSubMenu(nID - ID_NAVIGATE_SUBP_SUBITEM_START, 2);
+ } else if (GetPlaybackMode() == PM_DVD) {
+ int i = (int)nID - (1 + ID_NAVIGATE_SUBP_SUBITEM_START);
+
+ if (i == -1) {
+ ULONG ulStreamsAvailable, ulCurrentStream;
+ BOOL bIsDisabled;
+ if (SUCCEEDED(pDVDI->GetCurrentSubpicture(&ulStreamsAvailable, &ulCurrentStream, &bIsDisabled))) {
+ pDVDC->SetSubpictureState(bIsDisabled, DVD_CMD_FLAG_Block, NULL);
+ }
+ } else {
+ pDVDC->SelectSubpictureStream(i, DVD_CMD_FLAG_Block, NULL);
+ pDVDC->SetSubpictureState(TRUE, DVD_CMD_FLAG_Block, NULL);
+ }
+ }
}
void CMainFrame::OnNavigateAngle(UINT nID)
{
- nID -= ID_NAVIGATE_ANGLE_SUBITEM_START;
+ nID -= ID_NAVIGATE_ANGLE_SUBITEM_START;
- if (GetPlaybackMode() == PM_FILE) {
- OnNavStreamSelectSubMenu(nID, 0);
- } else if (GetPlaybackMode() == PM_DVD) {
- pDVDC->SelectAngle(nID+1, DVD_CMD_FLAG_Block, NULL);
+ if (GetPlaybackMode() == PM_FILE) {
+ OnNavStreamSelectSubMenu(nID, 0);
+ } else if (GetPlaybackMode() == PM_DVD) {
+ pDVDC->SelectAngle(nID + 1, DVD_CMD_FLAG_Block, NULL);
- CString osdMessage;
- osdMessage.Format(IDS_AG_ANGLE, nID+1);
- m_OSD.DisplayMessage(OSD_TOPLEFT, osdMessage);
- }
+ CString osdMessage;
+ osdMessage.Format(IDS_AG_ANGLE, nID + 1);
+ m_OSD.DisplayMessage(OSD_TOPLEFT, osdMessage);
+ }
}
void CMainFrame::OnNavigateChapters(UINT nID)
{
- if (nID < ID_NAVIGATE_CHAP_SUBITEM_START) {
- return;
- }
-
- if (GetPlaybackMode() == PM_FILE) {
- int id = nID - ID_NAVIGATE_CHAP_SUBITEM_START;
-
- if (id < (int)m_MPLSPlaylist.GetCount() && m_MPLSPlaylist.GetCount() > 1) {
- POSITION pos = m_MPLSPlaylist.GetHeadPosition();
- int idx = 0;
- while (pos) {
- CHdmvClipInfo::PlaylistItem Item = m_MPLSPlaylist.GetNext(pos);
- if (idx == id) {
- m_bIsBDPlay = true;
- m_wndPlaylistBar.Empty();
- CAtlList<CString> sl;
- sl.AddTail(CString(Item.m_strFileName));
- m_wndPlaylistBar.Append(sl, false);
- OpenCurPlaylistItem();
- return;
- }
- idx++;
- }
- }
-
- if (m_MPLSPlaylist.GetCount() > 1) {
- id -= m_MPLSPlaylist.GetCount();
- }
-
- if (id >= 0 && id < (int)m_pCB->ChapGetCount() && m_pCB->ChapGetCount() > 1) {
- REFERENCE_TIME rt;
- CComBSTR name;
- if (SUCCEEDED(m_pCB->ChapGet(id, &rt, &name))) {
- SeekTo(rt);
- SendStatusMessage(ResStr(IDS_AG_CHAPTER2) + CString(name), 3000);
-
- REFERENCE_TIME rtDur;
- pMS->GetDuration(&rtDur);
- CString m_strOSD;
- m_strOSD.Format(_T("%s/%s %s%d/%d - \"%s\""), ReftimeToString2(rt), ReftimeToString2(rtDur), ResStr(IDS_AG_CHAPTER2), id+1, m_pCB->ChapGetCount(), name);
- m_OSD.DisplayMessage(OSD_TOPLEFT, m_strOSD, 3000);
- }
- return;
- }
-
- if (m_pCB->ChapGetCount() > 1) {
- id -= m_pCB->ChapGetCount();
- }
-
- if (id >= 0 && id < m_wndPlaylistBar.GetCount() && m_wndPlaylistBar.GetSelIdx() != id) {
- m_wndPlaylistBar.SetSelIdx(id);
- OpenCurPlaylistItem();
- }
- } else if (GetPlaybackMode() == PM_DVD) {
- ULONG ulNumOfVolumes, ulVolume;
- DVD_DISC_SIDE Side;
- ULONG ulNumOfTitles = 0;
- pDVDI->GetDVDVolumeInfo(&ulNumOfVolumes, &ulVolume, &Side, &ulNumOfTitles);
-
- DVD_PLAYBACK_LOCATION2 Location;
- pDVDI->GetCurrentLocation(&Location);
-
- ULONG ulNumOfChapters = 0;
- pDVDI->GetNumberOfChapters(Location.TitleNum, &ulNumOfChapters);
-
- nID -= (ID_NAVIGATE_CHAP_SUBITEM_START - 1);
-
- if (nID <= ulNumOfTitles) {
- pDVDC->PlayTitle(nID, DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL); // sometimes this does not do anything ...
- pDVDC->PlayChapterInTitle(nID, 1, DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL); // ... but this does!
- } else {
- nID -= ulNumOfTitles;
-
- if (nID <= ulNumOfChapters) {
- pDVDC->PlayChapter(nID, DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
- }
- }
-
- if ((pDVDI->GetCurrentLocation(&Location) == S_OK)) {
- pDVDI->GetNumberOfChapters(Location.TitleNum, &ulNumOfChapters);
- CString m_strTitle;
- m_strTitle.Format(IDS_AG_TITLE2, Location.TitleNum, ulNumOfTitles);
- __int64 start, stop;
- m_wndSeekBar.GetRange(start, stop);
-
- CString m_strOSD;
- if (stop > 0) {
- DVD_HMSF_TIMECODE stopHMSF = RT2HMS_r(stop);
- m_strOSD.Format(_T("%s/%s %s, %s%02d/%02d"), DVDtimeToString(Location.TimeCode, stopHMSF.bHours > 0), DVDtimeToString(stopHMSF),
- m_strTitle, ResStr(IDS_AG_CHAPTER2), Location.ChapterNum, ulNumOfChapters);
- } else {
- m_strOSD.Format(_T("%s, %s%02d/%02d"), m_strTitle, ResStr(IDS_AG_CHAPTER2), Location.ChapterNum, ulNumOfChapters);
- }
-
- m_OSD.DisplayMessage(OSD_TOPLEFT, m_strOSD, 3000);
- }
- } else if (GetPlaybackMode() == PM_CAPTURE) {
- AppSettings& s = AfxGetAppSettings();
-
- nID -= ID_NAVIGATE_CHAP_SUBITEM_START;
-
- if (s.iDefaultCaptureDevice == 1) {
- CComQIPtr<IBDATuner> pTun = pGB;
- if (pTun) {
- if (s.nDVBLastChannel != nID) {
- pTun->SetChannel (nID);
- DisplayCurrentChannelOSD();
- if (m_wndNavigationBar.IsVisible()) {
- m_wndNavigationBar.m_navdlg.UpdatePos(nID);
- }
- }
- }
- }
- }
+ if (nID < ID_NAVIGATE_CHAP_SUBITEM_START) {
+ return;
+ }
+
+ if (GetPlaybackMode() == PM_FILE) {
+ int id = nID - ID_NAVIGATE_CHAP_SUBITEM_START;
+
+ if (id < (int)m_MPLSPlaylist.GetCount() && m_MPLSPlaylist.GetCount() > 1) {
+ POSITION pos = m_MPLSPlaylist.GetHeadPosition();
+ int idx = 0;
+ while (pos) {
+ CHdmvClipInfo::PlaylistItem Item = m_MPLSPlaylist.GetNext(pos);
+ if (idx == id) {
+ m_bIsBDPlay = true;
+ m_wndPlaylistBar.Empty();
+ CAtlList<CString> sl;
+ sl.AddTail(CString(Item.m_strFileName));
+ m_wndPlaylistBar.Append(sl, false);
+ OpenCurPlaylistItem();
+ return;
+ }
+ idx++;
+ }
+ }
+
+ if (m_MPLSPlaylist.GetCount() > 1) {
+ id -= m_MPLSPlaylist.GetCount();
+ }
+
+ if (id >= 0 && id < (int)m_pCB->ChapGetCount() && m_pCB->ChapGetCount() > 1) {
+ REFERENCE_TIME rt;
+ CComBSTR name;
+ if (SUCCEEDED(m_pCB->ChapGet(id, &rt, &name))) {
+ SeekTo(rt);
+ SendStatusMessage(ResStr(IDS_AG_CHAPTER2) + CString(name), 3000);
+
+ REFERENCE_TIME rtDur;
+ pMS->GetDuration(&rtDur);
+ CString m_strOSD;
+ m_strOSD.Format(_T("%s/%s %s%d/%d - \"%s\""), ReftimeToString2(rt), ReftimeToString2(rtDur), ResStr(IDS_AG_CHAPTER2), id + 1, m_pCB->ChapGetCount(), name);
+ m_OSD.DisplayMessage(OSD_TOPLEFT, m_strOSD, 3000);
+ }
+ return;
+ }
+
+ if (m_pCB->ChapGetCount() > 1) {
+ id -= m_pCB->ChapGetCount();
+ }
+
+ if (id >= 0 && id < m_wndPlaylistBar.GetCount() && m_wndPlaylistBar.GetSelIdx() != id) {
+ m_wndPlaylistBar.SetSelIdx(id);
+ OpenCurPlaylistItem();
+ }
+ } else if (GetPlaybackMode() == PM_DVD) {
+ ULONG ulNumOfVolumes, ulVolume;
+ DVD_DISC_SIDE Side;
+ ULONG ulNumOfTitles = 0;
+ pDVDI->GetDVDVolumeInfo(&ulNumOfVolumes, &ulVolume, &Side, &ulNumOfTitles);
+
+ DVD_PLAYBACK_LOCATION2 Location;
+ pDVDI->GetCurrentLocation(&Location);
+
+ ULONG ulNumOfChapters = 0;
+ pDVDI->GetNumberOfChapters(Location.TitleNum, &ulNumOfChapters);
+
+ nID -= (ID_NAVIGATE_CHAP_SUBITEM_START - 1);
+
+ if (nID <= ulNumOfTitles) {
+ pDVDC->PlayTitle(nID, DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL); // sometimes this does not do anything ...
+ pDVDC->PlayChapterInTitle(nID, 1, DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL); // ... but this does!
+ } else {
+ nID -= ulNumOfTitles;
+
+ if (nID <= ulNumOfChapters) {
+ pDVDC->PlayChapter(nID, DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
+ }
+ }
+
+ if ((pDVDI->GetCurrentLocation(&Location) == S_OK)) {
+ pDVDI->GetNumberOfChapters(Location.TitleNum, &ulNumOfChapters);
+ CString m_strTitle;
+ m_strTitle.Format(IDS_AG_TITLE2, Location.TitleNum, ulNumOfTitles);
+ __int64 start, stop;
+ m_wndSeekBar.GetRange(start, stop);
+
+ CString m_strOSD;
+ if (stop > 0) {
+ DVD_HMSF_TIMECODE stopHMSF = RT2HMS_r(stop);
+ m_strOSD.Format(_T("%s/%s %s, %s%02d/%02d"), DVDtimeToString(Location.TimeCode, stopHMSF.bHours > 0), DVDtimeToString(stopHMSF),
+ m_strTitle, ResStr(IDS_AG_CHAPTER2), Location.ChapterNum, ulNumOfChapters);
+ } else {
+ m_strOSD.Format(_T("%s, %s%02d/%02d"), m_strTitle, ResStr(IDS_AG_CHAPTER2), Location.ChapterNum, ulNumOfChapters);
+ }
+
+ m_OSD.DisplayMessage(OSD_TOPLEFT, m_strOSD, 3000);
+ }
+ } else if (GetPlaybackMode() == PM_CAPTURE) {
+ AppSettings& s = AfxGetAppSettings();
+
+ nID -= ID_NAVIGATE_CHAP_SUBITEM_START;
+
+ if (s.iDefaultCaptureDevice == 1) {
+ CComQIPtr<IBDATuner> pTun = pGB;
+ if (pTun) {
+ if (s.nDVBLastChannel != nID) {
+ pTun->SetChannel(nID);
+ DisplayCurrentChannelOSD();
+ if (m_wndNavigationBar.IsVisible()) {
+ m_wndNavigationBar.m_navdlg.UpdatePos(nID);
+ }
+ }
+ }
+ }
+ }
}
void CMainFrame::OnNavigateMenuItem(UINT nID)
{
- nID -= ID_NAVIGATE_MENU_LEFT;
-
- if (GetPlaybackMode() == PM_DVD) {
- switch (nID) {
- case 0:
- pDVDC->SelectRelativeButton(DVD_Relative_Left);
- break;
- case 1:
- pDVDC->SelectRelativeButton(DVD_Relative_Right);
- break;
- case 2:
- pDVDC->SelectRelativeButton(DVD_Relative_Upper);
- break;
- case 3:
- pDVDC->SelectRelativeButton(DVD_Relative_Lower);
- break;
- case 4:
- if (m_iDVDDomain != DVD_DOMAIN_Title) { // Casimir666 : for the remote control
- pDVDC->ActivateButton();
- } else {
- OnPlayPlay();
- }
- break;
- case 5:
- pDVDC->ReturnFromSubmenu(DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
- break;
- case 6:
- pDVDC->Resume(DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
- break;
- default:
- break;
- }
- } else if (GetPlaybackMode() == PM_FILE) {
- OnPlayPlay();
- }
+ nID -= ID_NAVIGATE_MENU_LEFT;
+
+ if (GetPlaybackMode() == PM_DVD) {
+ switch (nID) {
+ case 0:
+ pDVDC->SelectRelativeButton(DVD_Relative_Left);
+ break;
+ case 1:
+ pDVDC->SelectRelativeButton(DVD_Relative_Right);
+ break;
+ case 2:
+ pDVDC->SelectRelativeButton(DVD_Relative_Upper);
+ break;
+ case 3:
+ pDVDC->SelectRelativeButton(DVD_Relative_Lower);
+ break;
+ case 4:
+ if (m_iDVDDomain != DVD_DOMAIN_Title) { // Casimir666 : for the remote control
+ pDVDC->ActivateButton();
+ } else {
+ OnPlayPlay();
+ }
+ break;
+ case 5:
+ pDVDC->ReturnFromSubmenu(DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
+ break;
+ case 6:
+ pDVDC->Resume(DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
+ break;
+ default:
+ break;
+ }
+ } else if (GetPlaybackMode() == PM_FILE) {
+ OnPlayPlay();
+ }
}
void CMainFrame::OnUpdateNavigateMenuItem(CCmdUI* pCmdUI)
{
- pCmdUI->Enable((m_iMediaLoadState == MLS_LOADED) && ((GetPlaybackMode() == PM_DVD) || (GetPlaybackMode() == PM_FILE)));
+ pCmdUI->Enable((m_iMediaLoadState == MLS_LOADED) && ((GetPlaybackMode() == PM_DVD) || (GetPlaybackMode() == PM_FILE)));
}
void CMainFrame::OnTunerScan()
{
- CTunerScanDlg Dlg;
- Dlg.DoModal();
+ CTunerScanDlg Dlg;
+ Dlg.DoModal();
}
void CMainFrame::OnUpdateTunerScan(CCmdUI* pCmdUI)
{
- pCmdUI->Enable((m_iMediaLoadState == MLS_LOADED) &&
- (AfxGetAppSettings().iDefaultCaptureDevice == 1) &&
- ((GetPlaybackMode() == PM_CAPTURE)));
+ pCmdUI->Enable((m_iMediaLoadState == MLS_LOADED) &&
+ (AfxGetAppSettings().iDefaultCaptureDevice == 1) &&
+ ((GetPlaybackMode() == PM_CAPTURE)));
}
// favorites
class CDVDStateStream : public CUnknown, public IStream
{
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
- return
- QI(IStream)
- CUnknown::NonDelegatingQueryInterface(riid, ppv);
- }
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
+ return
+ QI(IStream)
+ CUnknown::NonDelegatingQueryInterface(riid, ppv);
+ }
- __int64 m_pos;
+ __int64 m_pos;
public:
- CDVDStateStream() : CUnknown(NAME("CDVDStateStream"), NULL) {
- m_pos = 0;
- }
-
- DECLARE_IUNKNOWN;
-
- CAtlArray<BYTE> m_data;
-
- // ISequentialStream
- STDMETHODIMP Read(void* pv, ULONG cb, ULONG* pcbRead) {
- __int64 cbRead = min((__int64)(m_data.GetCount() - m_pos), (__int64)cb);
- cbRead = max(cbRead, 0);
- memcpy(pv, &m_data[(INT_PTR)m_pos], (int)cbRead);
- if (pcbRead) {
- *pcbRead = (ULONG)cbRead;
- }
- m_pos += cbRead;
- return S_OK;
- }
- STDMETHODIMP Write(const void* pv, ULONG cb, ULONG* pcbWritten) {
- BYTE* p = (BYTE*)pv;
- ULONG cbWritten = (ULONG)-1;
- while (++cbWritten < cb) {
- m_data.Add(*p++);
- }
- if (pcbWritten) {
- *pcbWritten = cbWritten;
- }
- return S_OK;
- }
-
- // IStream
- STDMETHODIMP Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition) {
- return E_NOTIMPL;
- }
- STDMETHODIMP SetSize(ULARGE_INTEGER libNewSize) {
- return E_NOTIMPL;
- }
- STDMETHODIMP CopyTo(IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten) {
- return E_NOTIMPL;
- }
- STDMETHODIMP Commit(DWORD grfCommitFlags) {
- return E_NOTIMPL;
- }
- STDMETHODIMP Revert() {
- return E_NOTIMPL;
- }
- STDMETHODIMP LockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) {
- return E_NOTIMPL;
- }
- STDMETHODIMP UnlockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) {
- return E_NOTIMPL;
- }
- STDMETHODIMP Stat(STATSTG* pstatstg, DWORD grfStatFlag) {
- return E_NOTIMPL;
- }
- STDMETHODIMP Clone(IStream** ppstm) {
- return E_NOTIMPL;
- }
+ CDVDStateStream() : CUnknown(NAME("CDVDStateStream"), NULL) {
+ m_pos = 0;
+ }
+
+ DECLARE_IUNKNOWN;
+
+ CAtlArray<BYTE> m_data;
+
+ // ISequentialStream
+ STDMETHODIMP Read(void* pv, ULONG cb, ULONG* pcbRead) {
+ __int64 cbRead = min((__int64)(m_data.GetCount() - m_pos), (__int64)cb);
+ cbRead = max(cbRead, 0);
+ memcpy(pv, &m_data[(INT_PTR)m_pos], (int)cbRead);
+ if (pcbRead) {
+ *pcbRead = (ULONG)cbRead;
+ }
+ m_pos += cbRead;
+ return S_OK;
+ }
+ STDMETHODIMP Write(const void* pv, ULONG cb, ULONG* pcbWritten) {
+ BYTE* p = (BYTE*)pv;
+ ULONG cbWritten = (ULONG) - 1;
+ while (++cbWritten < cb) {
+ m_data.Add(*p++);
+ }
+ if (pcbWritten) {
+ *pcbWritten = cbWritten;
+ }
+ return S_OK;
+ }
+
+ // IStream
+ STDMETHODIMP Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP SetSize(ULARGE_INTEGER libNewSize) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP CopyTo(IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP Commit(DWORD grfCommitFlags) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP Revert() {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP LockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP UnlockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP Stat(STATSTG* pstatstg, DWORD grfStatFlag) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP Clone(IStream** ppstm) {
+ return E_NOTIMPL;
+ }
};
void CMainFrame::OnFavoritesAdd()
{
- AppSettings& s = AfxGetAppSettings();
-
- bool is_BD = false;
-
- if (GetPlaybackMode() == PM_FILE) {
- CString fn = m_wndPlaylistBar.GetCurFileName();
- if (fn.IsEmpty()) {
- BeginEnumFilters(pGB, pEF, pBF) {
- CComQIPtr<IFileSourceFilter> pFSF = pBF;
- if (pFSF) {
- LPOLESTR pFN = NULL;
- AM_MEDIA_TYPE mt;
- if (SUCCEEDED(pFSF->GetCurFile(&pFN, &mt)) && pFN && *pFN) {
- fn = CStringW(pFN);
- CoTaskMemFree(pFN);
- }
- break;
- }
- }
- EndEnumFilters
- if (fn.IsEmpty()) {
- return;
- }
- is_BD = true;
- }
-
- CString desc = fn;
- desc.Replace('\\', '/');
- int i = desc.Find(_T("://")), j = desc.Find(_T("?")), k = desc.ReverseFind('/');
- if (i >= 0) {
- desc = j >= 0 ? desc.Left(j) : desc;
- } else if (k >= 0) {
- desc = desc.Mid(k+1);
- }
-
- CFavoriteAddDlg dlg(desc, fn);
- if (dlg.DoModal() != IDOK) {
- return;
- }
-
- // Name
- CString str = dlg.m_name;
- str.Remove(';');
-
- // RememberPos
- CString pos(_T("0"));
- if (dlg.m_bRememberPos) {
- pos.Format(_T("%I64d"), GetPos());
- }
-
- str += ';';
- str += pos;
-
- // RelativeDrive
- CString relativeDrive;
- relativeDrive.Format( _T("%d"), dlg.m_bRelativeDrive );
-
- str += ';';
- str += relativeDrive;
-
- // Paths
- if (is_BD) {
- str += _T(";") + fn;
- } else {
- CPlaylistItem pli;
- if (m_wndPlaylistBar.GetCur(pli)) {
- POSITION pos = pli.m_fns.GetHeadPosition();
- while (pos) {
- str += _T(";") + pli.m_fns.GetNext(pos);
- }
- }
- }
-
- s.AddFav(FAV_FILE, str);
- } else if (GetPlaybackMode() == PM_DVD) {
- WCHAR path[_MAX_PATH];
- ULONG len = 0;
- pDVDI->GetDVDDirectory(path, _MAX_PATH, &len);
- CString fn = path;
- fn.TrimRight(_T("/\\"));
-
- DVD_PLAYBACK_LOCATION2 Location;
- pDVDI->GetCurrentLocation(&Location);
- CString desc;
- desc.Format(_T("%s - T%02d C%02d - %02d:%02d:%02d"), fn, Location.TitleNum, Location.ChapterNum,
- Location.TimeCode.bHours, Location.TimeCode.bMinutes, Location.TimeCode.bSeconds);
-
- CFavoriteAddDlg dlg(fn, desc);
- if (dlg.DoModal() != IDOK) {
- return;
- }
-
- // Name
- CString str = dlg.m_name;
- str.Remove(';');
-
- // RememberPos
- CString pos(_T("0"));
- if (dlg.m_bRememberPos) {
- CDVDStateStream stream;
- stream.AddRef();
-
- CComPtr<IDvdState> pStateData;
- CComQIPtr<IPersistStream> pPersistStream;
- if (SUCCEEDED(pDVDI->GetState(&pStateData))
- && (pPersistStream = pStateData)
- && SUCCEEDED(OleSaveToStream(pPersistStream, (IStream*)&stream))) {
- pos = BinToCString(stream.m_data.GetData(), stream.m_data.GetCount());
- }
- }
-
- str += ';';
- str += pos;
-
- // Paths
- str += ';';
- str += fn;
-
- s.AddFav(FAV_DVD, str);
- } else if (GetPlaybackMode() == PM_CAPTURE) {
- // TODO
- }
+ AppSettings& s = AfxGetAppSettings();
+
+ bool is_BD = false;
+
+ if (GetPlaybackMode() == PM_FILE) {
+ CString fn = m_wndPlaylistBar.GetCurFileName();
+ if (fn.IsEmpty()) {
+ BeginEnumFilters(pGB, pEF, pBF) {
+ CComQIPtr<IFileSourceFilter> pFSF = pBF;
+ if (pFSF) {
+ LPOLESTR pFN = NULL;
+ AM_MEDIA_TYPE mt;
+ if (SUCCEEDED(pFSF->GetCurFile(&pFN, &mt)) && pFN && *pFN) {
+ fn = CStringW(pFN);
+ CoTaskMemFree(pFN);
+ }
+ break;
+ }
+ }
+ EndEnumFilters
+ if (fn.IsEmpty()) {
+ return;
+ }
+ is_BD = true;
+ }
+
+ CString desc = fn;
+ desc.Replace('\\', '/');
+ int i = desc.Find(_T("://")), j = desc.Find(_T("?")), k = desc.ReverseFind('/');
+ if (i >= 0) {
+ desc = j >= 0 ? desc.Left(j) : desc;
+ } else if (k >= 0) {
+ desc = desc.Mid(k + 1);
+ }
+
+ CFavoriteAddDlg dlg(desc, fn);
+ if (dlg.DoModal() != IDOK) {
+ return;
+ }
+
+ // Name
+ CString str = dlg.m_name;
+ str.Remove(';');
+
+ // RememberPos
+ CString pos(_T("0"));
+ if (dlg.m_bRememberPos) {
+ pos.Format(_T("%I64d"), GetPos());
+ }
+
+ str += ';';
+ str += pos;
+
+ // RelativeDrive
+ CString relativeDrive;
+ relativeDrive.Format(_T("%d"), dlg.m_bRelativeDrive);
+
+ str += ';';
+ str += relativeDrive;
+
+ // Paths
+ if (is_BD) {
+ str += _T(";") + fn;
+ } else {
+ CPlaylistItem pli;
+ if (m_wndPlaylistBar.GetCur(pli)) {
+ POSITION pos = pli.m_fns.GetHeadPosition();
+ while (pos) {
+ str += _T(";") + pli.m_fns.GetNext(pos);
+ }
+ }
+ }
+
+ s.AddFav(FAV_FILE, str);
+ } else if (GetPlaybackMode() == PM_DVD) {
+ WCHAR path[_MAX_PATH];
+ ULONG len = 0;
+ pDVDI->GetDVDDirectory(path, _MAX_PATH, &len);
+ CString fn = path;
+ fn.TrimRight(_T("/\\"));
+
+ DVD_PLAYBACK_LOCATION2 Location;
+ pDVDI->GetCurrentLocation(&Location);
+ CString desc;
+ desc.Format(_T("%s - T%02d C%02d - %02d:%02d:%02d"), fn, Location.TitleNum, Location.ChapterNum,
+ Location.TimeCode.bHours, Location.TimeCode.bMinutes, Location.TimeCode.bSeconds);
+
+ CFavoriteAddDlg dlg(fn, desc);
+ if (dlg.DoModal() != IDOK) {
+ return;
+ }
+
+ // Name
+ CString str = dlg.m_name;
+ str.Remove(';');
+
+ // RememberPos
+ CString pos(_T("0"));
+ if (dlg.m_bRememberPos) {
+ CDVDStateStream stream;
+ stream.AddRef();
+
+ CComPtr<IDvdState> pStateData;
+ CComQIPtr<IPersistStream> pPersistStream;
+ if (SUCCEEDED(pDVDI->GetState(&pStateData))
+ && (pPersistStream = pStateData)
+ && SUCCEEDED(OleSaveToStream(pPersistStream, (IStream*)&stream))) {
+ pos = BinToCString(stream.m_data.GetData(), stream.m_data.GetCount());
+ }
+ }
+
+ str += ';';
+ str += pos;
+
+ // Paths
+ str += ';';
+ str += fn;
+
+ s.AddFav(FAV_DVD, str);
+ } else if (GetPlaybackMode() == PM_CAPTURE) {
+ // TODO
+ }
}
void CMainFrame::OnUpdateFavoritesAdd(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(GetPlaybackMode() == PM_FILE || GetPlaybackMode() == PM_DVD);
+ pCmdUI->Enable(GetPlaybackMode() == PM_FILE || GetPlaybackMode() == PM_DVD);
}
// TODO: OnFavoritesAdd and OnFavoritesQuickAddFavorite use nearly the same code, do something about it
void CMainFrame::OnFavoritesQuickAddFavorite()
{
- AppSettings& s = AfxGetAppSettings();
-
- bool is_BD = false;
-
- WORD osdMsg = 0;
-
- if (GetPlaybackMode() == PM_FILE) {
- CString fn = m_wndPlaylistBar.GetCurFileName();
- if (fn.IsEmpty()) {
- BeginEnumFilters(pGB, pEF, pBF) {
- CComQIPtr<IFileSourceFilter> pFSF = pBF;
- if (pFSF) {
- LPOLESTR pFN = NULL;
- AM_MEDIA_TYPE mt;
- if (SUCCEEDED(pFSF->GetCurFile(&pFN, &mt)) && pFN && *pFN) {
- fn = CStringW(pFN);
- CoTaskMemFree(pFN);
- }
- break;
- }
- }
- EndEnumFilters
- if (fn.IsEmpty()) {
- return;
- }
- is_BD = true;
- }
-
- CString desc = fn;
- desc.Replace('\\', '/');
- int i = desc.Find(_T("://")), j = desc.Find(_T("?")), k = desc.ReverseFind('/');
- if (i >= 0) {
- desc = j >= 0 ? desc.Left(j) : desc;
- } else if (k >= 0) {
- desc = desc.Mid(k+1);
- }
-
- CString fn_with_pos(desc);
- if (s.bFavRememberPos) {
- fn_with_pos.Format(_T("%s_%s"), desc, GetVidPos()); // Add file position (time format) so it will be easier to organize later
- }
-
- // Name
- CString str = fn_with_pos;
- str.Remove(';');
-
- // RememberPos
- CString pos(_T("0"));
- if (s.bFavRememberPos) {
- pos.Format(_T("%I64d"), GetPos());
- }
-
- str += ';';
- str += pos;
-
- // RelativeDrive
- CString relativeDrive;
- relativeDrive.Format( _T("%d"), s.bFavRelativeDrive );
-
- str += ';';
- str += relativeDrive;
-
- // Paths
- if (is_BD) {
- str += _T(";") + fn;
- } else {
- CPlaylistItem pli;
- if (m_wndPlaylistBar.GetCur(pli)) {
- POSITION pos = pli.m_fns.GetHeadPosition();
- while (pos) {
- str += _T(";") + pli.m_fns.GetNext(pos);
- }
- }
- }
-
- s.AddFav(FAV_FILE, str);
-
- osdMsg = IDS_FILE_FAV_ADDED;
- } else if (GetPlaybackMode() == PM_DVD) {
- WCHAR path[_MAX_PATH];
- ULONG len = 0;
- pDVDI->GetDVDDirectory(path, _MAX_PATH, &len);
- CString fn = path;
- fn.TrimRight(_T("/\\"));
-
- DVD_PLAYBACK_LOCATION2 Location;
- pDVDI->GetCurrentLocation(&Location);
- CString desc;
- desc.Format(_T("%s - T%02d C%02d - %02d:%02d:%02d"), fn, Location.TitleNum, Location.ChapterNum,
- Location.TimeCode.bHours, Location.TimeCode.bMinutes, Location.TimeCode.bSeconds);
-
- // Name
- CString str = s.bFavRememberPos ? desc : fn;
- str.Remove(';');
-
- // RememberPos
- CString pos(_T("0"));
- if (s.bFavRememberPos) {
- CDVDStateStream stream;
- stream.AddRef();
-
- CComPtr<IDvdState> pStateData;
- CComQIPtr<IPersistStream> pPersistStream;
- if (SUCCEEDED(pDVDI->GetState(&pStateData))
- && (pPersistStream = pStateData)
- && SUCCEEDED(OleSaveToStream(pPersistStream, (IStream*)&stream))) {
- pos = BinToCString(stream.m_data.GetData(), stream.m_data.GetCount());
- }
- }
-
- str += ';';
- str += pos;
-
- // Paths
- str += ';';
- str += fn;
-
- s.AddFav(FAV_DVD, str);
-
- osdMsg = IDS_DVD_FAV_ADDED;
- } else if (GetPlaybackMode() == PM_CAPTURE) {
- // TODO
- }
-
- if (osdMsg) {
- CString osdMsgStr = ResStr(osdMsg);
- SendStatusMessage(osdMsgStr, 3000);
- m_OSD.DisplayMessage(OSD_TOPLEFT, osdMsgStr, 3000);
- }
+ AppSettings& s = AfxGetAppSettings();
+
+ bool is_BD = false;
+
+ WORD osdMsg = 0;
+
+ if (GetPlaybackMode() == PM_FILE) {
+ CString fn = m_wndPlaylistBar.GetCurFileName();
+ if (fn.IsEmpty()) {
+ BeginEnumFilters(pGB, pEF, pBF) {
+ CComQIPtr<IFileSourceFilter> pFSF = pBF;
+ if (pFSF) {
+ LPOLESTR pFN = NULL;
+ AM_MEDIA_TYPE mt;
+ if (SUCCEEDED(pFSF->GetCurFile(&pFN, &mt)) && pFN && *pFN) {
+ fn = CStringW(pFN);
+ CoTaskMemFree(pFN);
+ }
+ break;
+ }
+ }
+ EndEnumFilters
+ if (fn.IsEmpty()) {
+ return;
+ }
+ is_BD = true;
+ }
+
+ CString desc = fn;
+ desc.Replace('\\', '/');
+ int i = desc.Find(_T("://")), j = desc.Find(_T("?")), k = desc.ReverseFind('/');
+ if (i >= 0) {
+ desc = j >= 0 ? desc.Left(j) : desc;
+ } else if (k >= 0) {
+ desc = desc.Mid(k + 1);
+ }
+
+ CString fn_with_pos(desc);
+ if (s.bFavRememberPos) {
+ fn_with_pos.Format(_T("%s_%s"), desc, GetVidPos()); // Add file position (time format) so it will be easier to organize later
+ }
+
+ // Name
+ CString str = fn_with_pos;
+ str.Remove(';');
+
+ // RememberPos
+ CString pos(_T("0"));
+ if (s.bFavRememberPos) {
+ pos.Format(_T("%I64d"), GetPos());
+ }
+
+ str += ';';
+ str += pos;
+
+ // RelativeDrive
+ CString relativeDrive;
+ relativeDrive.Format(_T("%d"), s.bFavRelativeDrive);
+
+ str += ';';
+ str += relativeDrive;
+
+ // Paths
+ if (is_BD) {
+ str += _T(";") + fn;
+ } else {
+ CPlaylistItem pli;
+ if (m_wndPlaylistBar.GetCur(pli)) {
+ POSITION pos = pli.m_fns.GetHeadPosition();
+ while (pos) {
+ str += _T(";") + pli.m_fns.GetNext(pos);
+ }
+ }
+ }
+
+ s.AddFav(FAV_FILE, str);
+
+ osdMsg = IDS_FILE_FAV_ADDED;
+ } else if (GetPlaybackMode() == PM_DVD) {
+ WCHAR path[_MAX_PATH];
+ ULONG len = 0;
+ pDVDI->GetDVDDirectory(path, _MAX_PATH, &len);
+ CString fn = path;
+ fn.TrimRight(_T("/\\"));
+
+ DVD_PLAYBACK_LOCATION2 Location;
+ pDVDI->GetCurrentLocation(&Location);
+ CString desc;
+ desc.Format(_T("%s - T%02d C%02d - %02d:%02d:%02d"), fn, Location.TitleNum, Location.ChapterNum,
+ Location.TimeCode.bHours, Location.TimeCode.bMinutes, Location.TimeCode.bSeconds);
+
+ // Name
+ CString str = s.bFavRememberPos ? desc : fn;
+ str.Remove(';');
+
+ // RememberPos
+ CString pos(_T("0"));
+ if (s.bFavRememberPos) {
+ CDVDStateStream stream;
+ stream.AddRef();
+
+ CComPtr<IDvdState> pStateData;
+ CComQIPtr<IPersistStream> pPersistStream;
+ if (SUCCEEDED(pDVDI->GetState(&pStateData))
+ && (pPersistStream = pStateData)
+ && SUCCEEDED(OleSaveToStream(pPersistStream, (IStream*)&stream))) {
+ pos = BinToCString(stream.m_data.GetData(), stream.m_data.GetCount());
+ }
+ }
+
+ str += ';';
+ str += pos;
+
+ // Paths
+ str += ';';
+ str += fn;
+
+ s.AddFav(FAV_DVD, str);
+
+ osdMsg = IDS_DVD_FAV_ADDED;
+ } else if (GetPlaybackMode() == PM_CAPTURE) {
+ // TODO
+ }
+
+ if (osdMsg) {
+ CString osdMsgStr = ResStr(osdMsg);
+ SendStatusMessage(osdMsgStr, 3000);
+ m_OSD.DisplayMessage(OSD_TOPLEFT, osdMsgStr, 3000);
+ }
}
void CMainFrame::OnFavoritesOrganize()
{
- CFavoriteOrganizeDlg dlg;
- dlg.DoModal();
+ CFavoriteOrganizeDlg dlg;
+ dlg.DoModal();
}
void CMainFrame::OnUpdateFavoritesOrganize(CCmdUI* pCmdUI)
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- CAtlList<CString> sl;
- s.GetFav(FAV_FILE, sl);
- bool enable = !sl.IsEmpty();
- if (!enable) {
- s.GetFav(FAV_DVD, sl);
- enable = !sl.IsEmpty();
- }
+ CAtlList<CString> sl;
+ s.GetFav(FAV_FILE, sl);
+ bool enable = !sl.IsEmpty();
+ if (!enable) {
+ s.GetFav(FAV_DVD, sl);
+ enable = !sl.IsEmpty();
+ }
- pCmdUI->Enable(enable);
+ pCmdUI->Enable(enable);
}
void CMainFrame::OnRecentFileClear()
{
- if (IDYES != AfxMessageBox(IDS_RECENT_FILES_QUESTION, MB_ICONQUESTION | MB_YESNO, 0)) {
- return;
- }
+ if (IDYES != AfxMessageBox(IDS_RECENT_FILES_QUESTION, MB_ICONQUESTION | MB_YESNO, 0)) {
+ return;
+ }
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- for (int i = s.MRU.GetSize() - 1; i >= 0; i--) {
- s.MRU.Remove(i);
- }
- for (int i = s.MRUDub.GetSize() - 1; i >= 0; i--) {
- s.MRUDub.Remove(i);
- }
- s.MRU.WriteList();
- s.MRUDub.WriteList();
+ for (int i = s.MRU.GetSize() - 1; i >= 0; i--) {
+ s.MRU.Remove(i);
+ }
+ for (int i = s.MRUDub.GetSize() - 1; i >= 0; i--) {
+ s.MRUDub.Remove(i);
+ }
+ s.MRU.WriteList();
+ s.MRUDub.WriteList();
- s.ClearFilePositions();
- s.ClearDVDPositions();
+ s.ClearFilePositions();
+ s.ClearDVDPositions();
}
void CMainFrame::OnUpdateRecentFileClear(CCmdUI* pCmdUI)
{
- // TODO: Add your command update UI handler code here
+ // TODO: Add your command update UI handler code here
}
void CMainFrame::OnFavoritesFile(UINT nID)
{
- nID -= ID_FAVORITES_FILE_START;
+ nID -= ID_FAVORITES_FILE_START;
- CAtlList<CString> sl;
- AfxGetAppSettings().GetFav(FAV_FILE, sl);
+ CAtlList<CString> sl;
+ AfxGetAppSettings().GetFav(FAV_FILE, sl);
- if (POSITION pos = sl.FindIndex(nID)) {
- PlayFavoriteFile(sl.GetAt(pos));
- }
+ if (POSITION pos = sl.FindIndex(nID)) {
+ PlayFavoriteFile(sl.GetAt(pos));
+ }
}
void CMainFrame::PlayFavoriteFile(CString fav)
{
- CAtlList<CString> fns;
- REFERENCE_TIME rtStart = 0;
- BOOL bRelativeDrive = FALSE;
-
- int i = 0, j = 0;
- for (CString s2 = fav.Tokenize(_T(";"), i);
- !s2.IsEmpty();
- s2 = fav.Tokenize(_T(";"), i), j++) {
- if (j == 0) {
- ; // desc / name
- } else if (j == 1) {
- _stscanf_s(s2, _T("%I64d"), &rtStart); // pos
- } else if (j == 2) {
- _stscanf_s(s2, _T("%d"), &bRelativeDrive); // relative drive
- } else {
- fns.AddTail(s2); // paths
- }
- }
-
- // NOTE: This is just for the favorites but we could add a global settings that does this always when on. Could be useful when using removable devices.
- // All you have to do then is plug in your 500 gb drive, full with movies and/or music, start MPC-HC (from the 500 gb drive) with a preloaded playlist and press play.
- if ( bRelativeDrive ) {
- // Get the drive MPC-HC is on and apply it to the path list
- CString exePath;
- DWORD dwLength = GetModuleFileName( AfxGetInstanceHandle(), exePath.GetBuffer(_MAX_PATH), _MAX_PATH );
- exePath.ReleaseBuffer( dwLength );
-
- CPath exeDrive( exePath );
-
- if ( exeDrive.StripToRoot() ) {
- POSITION pos = fns.GetHeadPosition();
-
- while ( pos != NULL ) {
- CString &stringPath = fns.GetNext( pos );
- CPath path( stringPath );
-
- int rootLength = path.SkipRoot();
-
- if ( path.StripToRoot() ) {
- if ( _tcsicmp(exeDrive, path) != 0 ) { // Do we need to replace the drive letter ?
- // Replace drive letter
- CString newPath( exeDrive );
-
- newPath += stringPath.Mid( rootLength );//newPath += stringPath.Mid( 3 );
-
- stringPath = newPath;
- }
- }
- }
- }
- }
-
- m_wndPlaylistBar.Open(fns, false);
- OpenCurPlaylistItem(max(rtStart, 0));
+ CAtlList<CString> fns;
+ REFERENCE_TIME rtStart = 0;
+ BOOL bRelativeDrive = FALSE;
+
+ int i = 0, j = 0;
+ for (CString s2 = fav.Tokenize(_T(";"), i);
+ !s2.IsEmpty();
+ s2 = fav.Tokenize(_T(";"), i), j++) {
+ if (j == 0) {
+ ; // desc / name
+ } else if (j == 1) {
+ _stscanf_s(s2, _T("%I64d"), &rtStart); // pos
+ } else if (j == 2) {
+ _stscanf_s(s2, _T("%d"), &bRelativeDrive); // relative drive
+ } else {
+ fns.AddTail(s2); // paths
+ }
+ }
+
+ // NOTE: This is just for the favorites but we could add a global settings that does this always when on. Could be useful when using removable devices.
+ // All you have to do then is plug in your 500 gb drive, full with movies and/or music, start MPC-HC (from the 500 gb drive) with a preloaded playlist and press play.
+ if (bRelativeDrive) {
+ // Get the drive MPC-HC is on and apply it to the path list
+ CString exePath;
+ DWORD dwLength = GetModuleFileName(AfxGetInstanceHandle(), exePath.GetBuffer(_MAX_PATH), _MAX_PATH);
+ exePath.ReleaseBuffer(dwLength);
+
+ CPath exeDrive(exePath);
+
+ if (exeDrive.StripToRoot()) {
+ POSITION pos = fns.GetHeadPosition();
+
+ while (pos != NULL) {
+ CString& stringPath = fns.GetNext(pos);
+ CPath path(stringPath);
+
+ int rootLength = path.SkipRoot();
+
+ if (path.StripToRoot()) {
+ if (_tcsicmp(exeDrive, path) != 0) { // Do we need to replace the drive letter ?
+ // Replace drive letter
+ CString newPath(exeDrive);
+
+ newPath += stringPath.Mid(rootLength); //newPath += stringPath.Mid( 3 );
+
+ stringPath = newPath;
+ }
+ }
+ }
+ }
+ }
+
+ m_wndPlaylistBar.Open(fns, false);
+ OpenCurPlaylistItem(max(rtStart, 0));
}
void CMainFrame::OnUpdateFavoritesFile(CCmdUI* pCmdUI)
{
- UINT nID = pCmdUI->m_nID - ID_FAVORITES_FILE_START;
- UNREFERENCED_PARAMETER(nID);
+ UINT nID = pCmdUI->m_nID - ID_FAVORITES_FILE_START;
+ UNREFERENCED_PARAMETER(nID);
}
void CMainFrame::OnRecentFile(UINT nID)
{
- nID -= ID_RECENT_FILE_START;
- CString str;
- m_recentfiles.GetMenuString(nID+2, str, MF_BYPOSITION);
- if (!m_wndPlaylistBar.SelectFileInPlaylist(str)) {
- CAtlList<CString> fns;
- fns.AddTail(str);
- m_wndPlaylistBar.Open(fns, false);
- }
- OpenCurPlaylistItem(0);
+ nID -= ID_RECENT_FILE_START;
+ CString str;
+ m_recentfiles.GetMenuString(nID + 2, str, MF_BYPOSITION);
+ if (!m_wndPlaylistBar.SelectFileInPlaylist(str)) {
+ CAtlList<CString> fns;
+ fns.AddTail(str);
+ m_wndPlaylistBar.Open(fns, false);
+ }
+ OpenCurPlaylistItem(0);
}
void CMainFrame::OnUpdateRecentFile(CCmdUI* pCmdUI)
{
- UINT nID = pCmdUI->m_nID - ID_RECENT_FILE_START;
- UNREFERENCED_PARAMETER(nID);
+ UINT nID = pCmdUI->m_nID - ID_RECENT_FILE_START;
+ UNREFERENCED_PARAMETER(nID);
}
void CMainFrame::OnFavoritesDVD(UINT nID)
{
- nID -= ID_FAVORITES_DVD_START;
+ nID -= ID_FAVORITES_DVD_START;
- CAtlList<CString> sl;
- AfxGetAppSettings().GetFav(FAV_DVD, sl);
+ CAtlList<CString> sl;
+ AfxGetAppSettings().GetFav(FAV_DVD, sl);
- if (POSITION pos = sl.FindIndex(nID)) {
- PlayFavoriteDVD(sl.GetAt(pos));
- }
+ if (POSITION pos = sl.FindIndex(nID)) {
+ PlayFavoriteDVD(sl.GetAt(pos));
+ }
}
void CMainFrame::PlayFavoriteDVD(CString fav)
{
- CString fn;
-
- CDVDStateStream stream;
- stream.AddRef();
-
- int i = 0, j = 0;
- for (CString s2 = fav.Tokenize(_T(";"), i);
- !s2.IsEmpty();
- s2 = fav.Tokenize(_T(";"), i), j++) {
- if (j == 0) {
- ; // desc
- } else if (j == 1 && s2 != _T("0")) { // state
- CStringToBin(s2, stream.m_data);
- } else if (j == 2) {
- fn = s2; // path
- }
- }
+ CString fn;
+
+ CDVDStateStream stream;
+ stream.AddRef();
+
+ int i = 0, j = 0;
+ for (CString s2 = fav.Tokenize(_T(";"), i);
+ !s2.IsEmpty();
+ s2 = fav.Tokenize(_T(";"), i), j++) {
+ if (j == 0) {
+ ; // desc
+ } else if (j == 1 && s2 != _T("0")) { // state
+ CStringToBin(s2, stream.m_data);
+ } else if (j == 2) {
+ fn = s2; // path
+ }
+ }
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- CComPtr<IDvdState> pDvdState;
- HRESULT hr = OleLoadFromStream((IStream*)&stream, IID_IDvdState, (void**)&pDvdState);
- UNREFERENCED_PARAMETER(hr);
+ CComPtr<IDvdState> pDvdState;
+ HRESULT hr = OleLoadFromStream((IStream*)&stream, IID_IDvdState, (void**)&pDvdState);
+ UNREFERENCED_PARAMETER(hr);
- CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
- if (p) {
- p->path = fn;
- p->pDvdState = pDvdState;
- }
- OpenMedia(p);
+ CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
+ if (p) {
+ p->path = fn;
+ p->pDvdState = pDvdState;
+ }
+ OpenMedia(p);
}
void CMainFrame::OnUpdateFavoritesDVD(CCmdUI* pCmdUI)
{
- UINT nID = pCmdUI->m_nID - ID_FAVORITES_DVD_START;
- UNREFERENCED_PARAMETER(nID);
+ UINT nID = pCmdUI->m_nID - ID_FAVORITES_DVD_START;
+ UNREFERENCED_PARAMETER(nID);
}
void CMainFrame::OnFavoritesDevice(UINT nID)
{
- nID -= ID_FAVORITES_DEVICE_START;
+ nID -= ID_FAVORITES_DEVICE_START;
}
void CMainFrame::OnUpdateFavoritesDevice(CCmdUI* pCmdUI)
{
- UINT nID = pCmdUI->m_nID - ID_FAVORITES_DEVICE_START;
- UNREFERENCED_PARAMETER(nID);
+ UINT nID = pCmdUI->m_nID - ID_FAVORITES_DEVICE_START;
+ UNREFERENCED_PARAMETER(nID);
}
// help
void CMainFrame::OnHelpHomepage()
{
- ShellExecute(m_hWnd, _T("open"), _T("http://mpc-hc.sourceforge.net/"), NULL, NULL, SW_SHOWDEFAULT);
+ ShellExecute(m_hWnd, _T("open"), _T("http://mpc-hc.sourceforge.net/"), NULL, NULL, SW_SHOWDEFAULT);
}
void CMainFrame::OnHelpCheckForUpdate()
{
- UpdateChecker::CheckForUpdate();
+ UpdateChecker::CheckForUpdate();
}
/*
void CMainFrame::OnHelpDocumentation()
{
- ShellExecute(m_hWnd, _T("open"), _T("http://sourceforge.net/project/showfiles.php?group_id=82303&package_id=144472"), NULL, NULL, SW_SHOWDEFAULT);
+ ShellExecute(m_hWnd, _T("open"), _T("http://sourceforge.net/project/showfiles.php?group_id=82303&package_id=144472"), NULL, NULL, SW_SHOWDEFAULT);
}
*/
void CMainFrame::OnHelpToolbarImages()
{
- ShellExecute(m_hWnd, _T("open"), _T("http://sourceforge.net/apps/trac/mpc-hc/wiki/Toolbar_images"), NULL, NULL, SW_SHOWDEFAULT);
+ ShellExecute(m_hWnd, _T("open"), _T("http://sourceforge.net/apps/trac/mpc-hc/wiki/Toolbar_images"), NULL, NULL, SW_SHOWDEFAULT);
}
void CMainFrame::OnHelpDonate()
{
- ShellExecute(m_hWnd, _T("open"), _T("http://sourceforge.net/donate/index.php?group_id=170561"), NULL, NULL, SW_SHOWDEFAULT);
+ ShellExecute(m_hWnd, _T("open"), _T("http://sourceforge.net/donate/index.php?group_id=170561"), NULL, NULL, SW_SHOWDEFAULT);
}
//////////////////////////////////
static BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
{
- CAtlArray<HMONITOR>* ml = (CAtlArray<HMONITOR>*)dwData;
- ml->Add(hMonitor);
- return TRUE;
+ CAtlArray<HMONITOR>* ml = (CAtlArray<HMONITOR>*)dwData;
+ ml->Add(hMonitor);
+ return TRUE;
}
void CMainFrame::SetDefaultWindowRect(int iMonitor)
{
- AppSettings& s = AfxGetAppSettings();
- int w, h, x, y;
-
- if (s.HasFixedWindowSize()) {
- w = s.sizeFixedWindow.cx;
- h = s.sizeFixedWindow.cy;
- } else if (s.fRememberWindowSize) {
- w = s.rcLastWindowPos.Width();
- h = s.rcLastWindowPos.Height();
- } else {
- CRect r1, r2;
- GetClientRect(&r1);
- m_wndView.GetClientRect(&r2);
-
- CSize logosize = m_wndView.GetLogoSize();
- int _DEFCLIENTW = max(logosize.cx, DEFCLIENTW);
- int _DEFCLIENTH = max(logosize.cy, DEFCLIENTH);
-
- if (GetSystemMetrics(SM_REMOTESESSION)) {
- _DEFCLIENTH = 0;
- }
-
- DWORD style = GetStyle();
-
- w = _DEFCLIENTW + r1.Width() - r2.Width();
- h = _DEFCLIENTH + r1.Height() - r2.Height();
-
- if (style & WS_THICKFRAME) {
- w += GetSystemMetrics(SM_CXSIZEFRAME) * 2;
- h += GetSystemMetrics(SM_CYSIZEFRAME) * 2;
- if ( (style & WS_CAPTION) == 0 ) {
- w -= 2;
- h -= 2;
- }
- }
-
- if (style & WS_CAPTION) {
- h += GetSystemMetrics(SM_CYCAPTION);
- if (s.iCaptionMenuMode == MODE_SHOWCAPTIONMENU) {
- h += GetSystemMetrics(SM_CYMENU);
- }
- //else MODE_HIDEMENU
- }
- }
-
- bool inmonitor = false;
- if (s.fRememberWindowPos) {
- CMonitor monitor;
- CMonitors monitors;
- POINT ptA;
- ptA.x = s.rcLastWindowPos.TopLeft().x;
- ptA.y = s.rcLastWindowPos.TopLeft().y;
- inmonitor = (ptA.x<0 || ptA.y<0);
- if (!inmonitor) {
- for ( int i = 0; i < monitors.GetCount(); i++ ) {
- monitor = monitors.GetMonitor( i );
- if (monitor.IsOnMonitor(ptA)) {
- inmonitor = true;
- break;
- }
- }
- }
- }
-
- if (s.fRememberWindowPos && inmonitor) {
- x = s.rcLastWindowPos.TopLeft().x;
- y = s.rcLastWindowPos.TopLeft().y;
- } else {
- HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
-
- if (iMonitor > 0) {
- iMonitor--;
- CAtlArray<HMONITOR> ml;
- EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (LPARAM)&ml);
- if ((size_t)iMonitor < ml.GetCount()) {
- hMonitor = ml[iMonitor];
- }
- }
-
- MONITORINFO mi;
- mi.cbSize = sizeof(MONITORINFO);
- GetMonitorInfo(hMonitor, &mi);
-
- x = (mi.rcWork.left+mi.rcWork.right-w)/2; // Center main window
- y = (mi.rcWork.top+mi.rcWork.bottom-h)/2; // no need to call CenterWindow()
- }
-
- UINT lastWindowType = s.nLastWindowType;
- MoveWindow(x, y, w, h);
-
- if (s.iCaptionMenuMode!=MODE_SHOWCAPTIONMENU) {
- if (s.iCaptionMenuMode==MODE_FRAMEONLY) {
- ModifyStyle(WS_CAPTION, 0, SWP_NOZORDER);
- } else if (s.iCaptionMenuMode==MODE_BORDERLESS) {
- ModifyStyle(WS_CAPTION | WS_THICKFRAME, 0, SWP_NOZORDER);
- }
- ::SetMenu(m_hWnd, NULL);
- SetWindowPos(NULL, 0, 0, 0, 0, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER);
- }
-
- if (!s.fRememberWindowPos) {
- CenterWindow();
- }
-
- if (s.fRememberWindowSize && s.fRememberWindowPos) {
- if (lastWindowType == SIZE_MAXIMIZED) {
- ShowWindow(SW_MAXIMIZE);
- } else if (lastWindowType == SIZE_MINIMIZED) {
- ShowWindow(SW_MINIMIZE);
- }
- }
-
- if (s.fSavePnSZoom) {
- m_ZoomX = s.dZoomX;
- m_ZoomY = s.dZoomY;
- }
+ AppSettings& s = AfxGetAppSettings();
+ int w, h, x, y;
+
+ if (s.HasFixedWindowSize()) {
+ w = s.sizeFixedWindow.cx;
+ h = s.sizeFixedWindow.cy;
+ } else if (s.fRememberWindowSize) {
+ w = s.rcLastWindowPos.Width();
+ h = s.rcLastWindowPos.Height();
+ } else {
+ CRect r1, r2;
+ GetClientRect(&r1);
+ m_wndView.GetClientRect(&r2);
+
+ CSize logosize = m_wndView.GetLogoSize();
+ int _DEFCLIENTW = max(logosize.cx, DEFCLIENTW);
+ int _DEFCLIENTH = max(logosize.cy, DEFCLIENTH);
+
+ if (GetSystemMetrics(SM_REMOTESESSION)) {
+ _DEFCLIENTH = 0;
+ }
+
+ DWORD style = GetStyle();
+
+ w = _DEFCLIENTW + r1.Width() - r2.Width();
+ h = _DEFCLIENTH + r1.Height() - r2.Height();
+
+ if (style & WS_THICKFRAME) {
+ w += GetSystemMetrics(SM_CXSIZEFRAME) * 2;
+ h += GetSystemMetrics(SM_CYSIZEFRAME) * 2;
+ if ((style & WS_CAPTION) == 0) {
+ w -= 2;
+ h -= 2;
+ }
+ }
+
+ if (style & WS_CAPTION) {
+ h += GetSystemMetrics(SM_CYCAPTION);
+ if (s.iCaptionMenuMode == MODE_SHOWCAPTIONMENU) {
+ h += GetSystemMetrics(SM_CYMENU);
+ }
+ //else MODE_HIDEMENU
+ }
+ }
+
+ bool inmonitor = false;
+ if (s.fRememberWindowPos) {
+ CMonitor monitor;
+ CMonitors monitors;
+ POINT ptA;
+ ptA.x = s.rcLastWindowPos.TopLeft().x;
+ ptA.y = s.rcLastWindowPos.TopLeft().y;
+ inmonitor = (ptA.x < 0 || ptA.y < 0);
+ if (!inmonitor) {
+ for (int i = 0; i < monitors.GetCount(); i++) {
+ monitor = monitors.GetMonitor(i);
+ if (monitor.IsOnMonitor(ptA)) {
+ inmonitor = true;
+ break;
+ }
+ }
+ }
+ }
+
+ if (s.fRememberWindowPos && inmonitor) {
+ x = s.rcLastWindowPos.TopLeft().x;
+ y = s.rcLastWindowPos.TopLeft().y;
+ } else {
+ HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+
+ if (iMonitor > 0) {
+ iMonitor--;
+ CAtlArray<HMONITOR> ml;
+ EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (LPARAM)&ml);
+ if ((size_t)iMonitor < ml.GetCount()) {
+ hMonitor = ml[iMonitor];
+ }
+ }
+
+ MONITORINFO mi;
+ mi.cbSize = sizeof(MONITORINFO);
+ GetMonitorInfo(hMonitor, &mi);
+
+ x = (mi.rcWork.left + mi.rcWork.right - w) / 2; // Center main window
+ y = (mi.rcWork.top + mi.rcWork.bottom - h) / 2; // no need to call CenterWindow()
+ }
+
+ UINT lastWindowType = s.nLastWindowType;
+ MoveWindow(x, y, w, h);
+
+ if (s.iCaptionMenuMode != MODE_SHOWCAPTIONMENU) {
+ if (s.iCaptionMenuMode == MODE_FRAMEONLY) {
+ ModifyStyle(WS_CAPTION, 0, SWP_NOZORDER);
+ } else if (s.iCaptionMenuMode == MODE_BORDERLESS) {
+ ModifyStyle(WS_CAPTION | WS_THICKFRAME, 0, SWP_NOZORDER);
+ }
+ ::SetMenu(m_hWnd, NULL);
+ SetWindowPos(NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER);
+ }
+
+ if (!s.fRememberWindowPos) {
+ CenterWindow();
+ }
+
+ if (s.fRememberWindowSize && s.fRememberWindowPos) {
+ if (lastWindowType == SIZE_MAXIMIZED) {
+ ShowWindow(SW_MAXIMIZE);
+ } else if (lastWindowType == SIZE_MINIMIZED) {
+ ShowWindow(SW_MINIMIZE);
+ }
+ }
+
+ if (s.fSavePnSZoom) {
+ m_ZoomX = s.dZoomX;
+ m_ZoomY = s.dZoomY;
+ }
}
void CMainFrame::SetDefaultFullscreenState()
{
- AppSettings& s = AfxGetAppSettings();
-
- // Waffs : fullscreen command line
- if (!(s.nCLSwitches&CLSW_ADD) && (s.nCLSwitches&CLSW_FULLSCREEN) && !s.slFiles.IsEmpty()) {
- ToggleFullscreen(true, true);
- SetCursor(NULL);
- AfxGetAppSettings().nCLSwitches &= ~CLSW_FULLSCREEN;
- m_fFirstFSAfterLaunchOnFS = true;
- } else if (s.fRememberWindowSize && s.fRememberWindowPos && !m_fFullScreen && s.fLastFullScreen) {
- // Casimir666 : if fullscreen was on, put it on back
- ToggleFullscreen(true, true);
- }
+ AppSettings& s = AfxGetAppSettings();
+
+ // Waffs : fullscreen command line
+ if (!(s.nCLSwitches & CLSW_ADD) && (s.nCLSwitches & CLSW_FULLSCREEN) && !s.slFiles.IsEmpty()) {
+ ToggleFullscreen(true, true);
+ SetCursor(NULL);
+ AfxGetAppSettings().nCLSwitches &= ~CLSW_FULLSCREEN;
+ m_fFirstFSAfterLaunchOnFS = true;
+ } else if (s.fRememberWindowSize && s.fRememberWindowPos && !m_fFullScreen && s.fLastFullScreen) {
+ // Casimir666 : if fullscreen was on, put it on back
+ ToggleFullscreen(true, true);
+ }
}
void CMainFrame::RestoreDefaultWindowRect()
{
- AppSettings& s = AfxGetAppSettings();
-
- WINDOWPLACEMENT wp;
- GetWindowPlacement(&wp);
- if (!m_fFullScreen && wp.showCmd != SW_SHOWMAXIMIZED && wp.showCmd != SW_SHOWMINIMIZED
- //&& (GetExStyle()&WS_EX_APPWINDOW)
- && !s.fRememberWindowSize) {
- int x, y, w, h;
-
- if (s.HasFixedWindowSize()) {
- w = s.sizeFixedWindow.cx;
- h = s.sizeFixedWindow.cy;
- } else {
- CRect r1, r2;
- GetClientRect(&r1);
- m_wndView.GetClientRect(&r2);
-
- CSize logosize = m_wndView.GetLogoSize();
- int _DEFCLIENTW = max(logosize.cx, DEFCLIENTW);
- int _DEFCLIENTH = max(logosize.cy, DEFCLIENTH);
-
- DWORD style = GetStyle();
- w = _DEFCLIENTW + r1.Width() - r2.Width();
- h = _DEFCLIENTH + r1.Height() - r2.Height();
-
- if (style & WS_THICKFRAME) {
- w += GetSystemMetrics(SM_CXSIZEFRAME) * 2;
- h += GetSystemMetrics(SM_CYSIZEFRAME) * 2;
- if ( (style & WS_CAPTION) == 0 ) {
- w -= 2;
- h -= 2;
- }
- }
-
- if (style & WS_CAPTION) {
- h += GetSystemMetrics(SM_CYCAPTION);
- if (s.iCaptionMenuMode == MODE_SHOWCAPTIONMENU) {
- h += GetSystemMetrics(SM_CYMENU);
- }
- //else MODE_HIDEMENU
- }
- }
-
- if (s.fRememberWindowPos) {
- x = s.rcLastWindowPos.TopLeft().x;
- y = s.rcLastWindowPos.TopLeft().y;
- } else {
- CRect r;
- GetWindowRect(r);
-
- x = r.CenterPoint().x - w/2; // Center window here
- y = r.CenterPoint().y - h/2; // no need to call CenterWindow()
- }
-
- MoveWindow(x, y, w, h);
-
- if (!s.fRememberWindowPos) {
- CenterWindow();
- }
- }
+ AppSettings& s = AfxGetAppSettings();
+
+ WINDOWPLACEMENT wp;
+ GetWindowPlacement(&wp);
+ if (!m_fFullScreen && wp.showCmd != SW_SHOWMAXIMIZED && wp.showCmd != SW_SHOWMINIMIZED
+ //&& (GetExStyle()&WS_EX_APPWINDOW)
+ && !s.fRememberWindowSize) {
+ int x, y, w, h;
+
+ if (s.HasFixedWindowSize()) {
+ w = s.sizeFixedWindow.cx;
+ h = s.sizeFixedWindow.cy;
+ } else {
+ CRect r1, r2;
+ GetClientRect(&r1);
+ m_wndView.GetClientRect(&r2);
+
+ CSize logosize = m_wndView.GetLogoSize();
+ int _DEFCLIENTW = max(logosize.cx, DEFCLIENTW);
+ int _DEFCLIENTH = max(logosize.cy, DEFCLIENTH);
+
+ DWORD style = GetStyle();
+ w = _DEFCLIENTW + r1.Width() - r2.Width();
+ h = _DEFCLIENTH + r1.Height() - r2.Height();
+
+ if (style & WS_THICKFRAME) {
+ w += GetSystemMetrics(SM_CXSIZEFRAME) * 2;
+ h += GetSystemMetrics(SM_CYSIZEFRAME) * 2;
+ if ((style & WS_CAPTION) == 0) {
+ w -= 2;
+ h -= 2;
+ }
+ }
+
+ if (style & WS_CAPTION) {
+ h += GetSystemMetrics(SM_CYCAPTION);
+ if (s.iCaptionMenuMode == MODE_SHOWCAPTIONMENU) {
+ h += GetSystemMetrics(SM_CYMENU);
+ }
+ //else MODE_HIDEMENU
+ }
+ }
+
+ if (s.fRememberWindowPos) {
+ x = s.rcLastWindowPos.TopLeft().x;
+ y = s.rcLastWindowPos.TopLeft().y;
+ } else {
+ CRect r;
+ GetWindowRect(r);
+
+ x = r.CenterPoint().x - w / 2; // Center window here
+ y = r.CenterPoint().y - h / 2; // no need to call CenterWindow()
+ }
+
+ MoveWindow(x, y, w, h);
+
+ if (!s.fRememberWindowPos) {
+ CenterWindow();
+ }
+ }
}
OAFilterState CMainFrame::GetMediaState() const
{
- OAFilterState ret = -1;
- if (m_iMediaLoadState == MLS_LOADED) {
- pMC->GetState(0, &ret);
- }
- return ret;
+ OAFilterState ret = -1;
+ if (m_iMediaLoadState == MLS_LOADED) {
+ pMC->GetState(0, &ret);
+ }
+ return ret;
}
void CMainFrame::SetPlaybackMode(int iNewStatus)
{
- m_iPlaybackMode = iNewStatus;
- if (m_wndNavigationBar.IsWindowVisible() && GetPlaybackMode() != PM_CAPTURE) {
- ShowControlBar(&m_wndNavigationBar, !m_wndNavigationBar.IsWindowVisible(), TRUE);
- }
+ m_iPlaybackMode = iNewStatus;
+ if (m_wndNavigationBar.IsWindowVisible() && GetPlaybackMode() != PM_CAPTURE) {
+ ShowControlBar(&m_wndNavigationBar, !m_wndNavigationBar.IsWindowVisible(), TRUE);
+ }
}
CSize CMainFrame::GetVideoSize() const
{
- bool fKeepAspectRatio = AfxGetAppSettings().fKeepAspectRatio;
- bool fCompMonDeskARDiff = AfxGetAppSettings().fCompMonDeskARDiff;
-
- CSize ret(0,0);
- if (m_iMediaLoadState != MLS_LOADED || m_fAudioOnly) {
- return ret;
- }
-
- CSize wh(0, 0), arxy(0, 0);
-
- if (m_pMFVDC) {
- m_pMFVDC->GetNativeVideoSize(&wh, &arxy); // TODO : check AR !!
- } else if (m_pCAP) {
- wh = m_pCAP->GetVideoSize(false);
- arxy = m_pCAP->GetVideoSize(fKeepAspectRatio);
- } else {
- pBV->GetVideoSize(&wh.cx, &wh.cy);
-
- long arx = 0, ary = 0;
- CComQIPtr<IBasicVideo2> pBV2 = pBV;
- // FIXME: It can hang here, for few seconds (CPU goes to 100%), after the window have been moving over to another screen,
- // due to GetPreferredAspectRatio, if it happens before CAudioSwitcherFilter::DeliverEndFlush, it seems.
- if (pBV2 && SUCCEEDED(pBV2->GetPreferredAspectRatio(&arx, &ary)) && arx > 0 && ary > 0) {
- arxy.SetSize(arx, ary);
- }
- }
-
- if (wh.cx <= 0 || wh.cy <= 0) {
- return ret;
- }
-
- // with the overlay mixer IBasicVideo2 won't tell the new AR when changed dynamically
- DVD_VideoAttributes VATR;
- if (GetPlaybackMode() == PM_DVD && SUCCEEDED(pDVDI->GetCurrentVideoAttributes(&VATR))) {
- arxy.SetSize(VATR.ulAspectX, VATR.ulAspectY);
- }
-
- CSize& ar = AfxGetAppSettings().sizeAspectRatio;
- if (ar.cx && ar.cy) {
- arxy = ar;
- }
-
- ret = (!fKeepAspectRatio || arxy.cx <= 0 || arxy.cy <= 0)
- ? wh
- : CSize(MulDiv(wh.cy, arxy.cx, arxy.cy), wh.cy);
-
- if (fCompMonDeskARDiff)
- if (HDC hDC = ::GetDC(0)) {
- int _HORZSIZE = GetDeviceCaps(hDC, HORZSIZE);
- int _VERTSIZE = GetDeviceCaps(hDC, VERTSIZE);
- int _HORZRES = GetDeviceCaps(hDC, HORZRES);
- int _VERTRES = GetDeviceCaps(hDC, VERTRES);
-
- if (_HORZSIZE > 0 && _VERTSIZE > 0 && _HORZRES > 0 && _VERTRES > 0) {
- double a = 1.0*_HORZSIZE/_VERTSIZE;
- double b = 1.0*_HORZRES/_VERTRES;
-
- if (b < a) {
- ret.cy = (DWORD)(1.0*ret.cy * a / b);
- } else if (a < b) {
- ret.cx = (DWORD)(1.0*ret.cx * b / a);
- }
- }
-
- ::ReleaseDC(0, hDC);
- }
-
- return ret;
+ bool fKeepAspectRatio = AfxGetAppSettings().fKeepAspectRatio;
+ bool fCompMonDeskARDiff = AfxGetAppSettings().fCompMonDeskARDiff;
+
+ CSize ret(0, 0);
+ if (m_iMediaLoadState != MLS_LOADED || m_fAudioOnly) {
+ return ret;
+ }
+
+ CSize wh(0, 0), arxy(0, 0);
+
+ if (m_pMFVDC) {
+ m_pMFVDC->GetNativeVideoSize(&wh, &arxy); // TODO : check AR !!
+ } else if (m_pCAP) {
+ wh = m_pCAP->GetVideoSize(false);
+ arxy = m_pCAP->GetVideoSize(fKeepAspectRatio);
+ } else {
+ pBV->GetVideoSize(&wh.cx, &wh.cy);
+
+ long arx = 0, ary = 0;
+ CComQIPtr<IBasicVideo2> pBV2 = pBV;
+ // FIXME: It can hang here, for few seconds (CPU goes to 100%), after the window have been moving over to another screen,
+ // due to GetPreferredAspectRatio, if it happens before CAudioSwitcherFilter::DeliverEndFlush, it seems.
+ if (pBV2 && SUCCEEDED(pBV2->GetPreferredAspectRatio(&arx, &ary)) && arx > 0 && ary > 0) {
+ arxy.SetSize(arx, ary);
+ }
+ }
+
+ if (wh.cx <= 0 || wh.cy <= 0) {
+ return ret;
+ }
+
+ // with the overlay mixer IBasicVideo2 won't tell the new AR when changed dynamically
+ DVD_VideoAttributes VATR;
+ if (GetPlaybackMode() == PM_DVD && SUCCEEDED(pDVDI->GetCurrentVideoAttributes(&VATR))) {
+ arxy.SetSize(VATR.ulAspectX, VATR.ulAspectY);
+ }
+
+ CSize& ar = AfxGetAppSettings().sizeAspectRatio;
+ if (ar.cx && ar.cy) {
+ arxy = ar;
+ }
+
+ ret = (!fKeepAspectRatio || arxy.cx <= 0 || arxy.cy <= 0)
+ ? wh
+ : CSize(MulDiv(wh.cy, arxy.cx, arxy.cy), wh.cy);
+
+ if (fCompMonDeskARDiff)
+ if (HDC hDC = ::GetDC(0)) {
+ int _HORZSIZE = GetDeviceCaps(hDC, HORZSIZE);
+ int _VERTSIZE = GetDeviceCaps(hDC, VERTSIZE);
+ int _HORZRES = GetDeviceCaps(hDC, HORZRES);
+ int _VERTRES = GetDeviceCaps(hDC, VERTRES);
+
+ if (_HORZSIZE > 0 && _VERTSIZE > 0 && _HORZRES > 0 && _VERTRES > 0) {
+ double a = 1.0 * _HORZSIZE / _VERTSIZE;
+ double b = 1.0 * _HORZRES / _VERTRES;
+
+ if (b < a) {
+ ret.cy = (DWORD)(1.0 * ret.cy * a / b);
+ } else if (a < b) {
+ ret.cx = (DWORD)(1.0 * ret.cx * b / a);
+ }
+ }
+
+ ::ReleaseDC(0, hDC);
+ }
+
+ return ret;
}
void CMainFrame::ToggleFullscreen(bool fToNearest, bool fSwitchScreenResWhenHasTo)
{
- if (m_pFullscreenWnd->IsWindow()) {
- return;
- }
-
- AppSettings& s = AfxGetAppSettings();
- CRect r;
- DWORD dwRemove = 0, dwAdd = 0;
- DWORD dwRemoveEx = 0, dwAddEx = 0;
- HMENU hMenu;
- MONITORINFO mi;
- mi.cbSize = sizeof(MONITORINFO);
-
- HMONITOR hm = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- HMONITOR hm_cur = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
-
- CMonitors monitors;
-
- if (!m_fFullScreen) {
- if (s.bHidePlaylistFullScreen && m_wndPlaylistBar.IsVisible()) {
- m_wndPlaylistBar.SetHiddenDueToFullscreen(true);
- ShowControlBar(&m_wndPlaylistBar, FALSE, TRUE);
- }
-
- if (!m_fFirstFSAfterLaunchOnFS) {
- GetWindowRect(&m_lastWindowRect);
- }
- if (s.AutoChangeFullscrRes.bEnabled && fSwitchScreenResWhenHasTo && (GetPlaybackMode() != PM_NONE)) {
- AutoChangeMonitorMode();
- }
- m_LastWindow_HM = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
-
- CString str;
- CMonitor monitor;
- if (s.strFullScreenMonitor == _T("Current")) {
- hm = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- } else {
- for ( int i = 0; i < monitors.GetCount(); i++ ) {
- monitor = monitors.GetMonitor( i );
- monitor.GetName(str);
- if ((monitor.IsMonitor()) && (s.strFullScreenMonitor == str)) {
- hm = monitor;
- break;
- }
- }
- if (!hm) {
- hm = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- }
- }
-
- dwRemove = WS_CAPTION|WS_THICKFRAME;
- GetMonitorInfo(hm, &mi);
- if (fToNearest) {
- r = mi.rcMonitor;
- } else {
- GetDesktopWindow()->GetWindowRect(&r);
- }
- hMenu = NULL;
- } else {
- if (s.AutoChangeFullscrRes.bEnabled && s.AutoChangeFullscrRes.bApplyDefault && s.AutoChangeFullscrRes.dmFullscreenRes[0].fChecked == 1) {
- SetDispMode(s.AutoChangeFullscrRes.dmFullscreenRes[0].dmFSRes, s.strFullScreenMonitor);
- }
-
- dwAdd = (s.iCaptionMenuMode==MODE_BORDERLESS ? 0 : s.iCaptionMenuMode==MODE_FRAMEONLY? WS_THICKFRAME: WS_CAPTION | WS_THICKFRAME);
- if (!m_fFirstFSAfterLaunchOnFS) {
- r = m_lastWindowRect;
- }
- hMenu = (s.iCaptionMenuMode==MODE_SHOWCAPTIONMENU) ? m_hMenuDefault: NULL;
-
- if (s.bHidePlaylistFullScreen && m_wndPlaylistBar.IsHiddenDueToFullscreen()) {
- m_wndPlaylistBar.SetHiddenDueToFullscreen(false);
- ShowControlBar(&m_wndPlaylistBar, TRUE, TRUE);
- }
- }
-
- m_lastMouseMove.x = m_lastMouseMove.y = -1;
-
- bool fAudioOnly = m_fAudioOnly;
- m_fAudioOnly = true;
-
- m_fFullScreen = !m_fFullScreen;
- s.fLastFullScreen = m_fFullScreen;
-
- ModifyStyle(dwRemove, dwAdd, SWP_NOZORDER);
- ModifyStyleEx(dwRemoveEx, dwAddEx, SWP_NOZORDER);
- ::SetMenu(m_hWnd, hMenu);
-
- static bool m_Change_Monitor = false;
- // try disable shader when move from one monitor to other ...
- if (m_fFullScreen) {
- m_Change_Monitor = (hm != hm_cur);
- if ((m_Change_Monitor) && (!m_bToggleShader)) {
- if (m_pCAP) {
- m_pCAP->SetPixelShader(NULL, NULL);
- }
- }
- if (m_Change_Monitor && m_bToggleShaderScreenSpace) {
- if (m_pCAP2) {
- m_pCAP2->SetPixelShader2(NULL, NULL, true);
- }
- }
-
- } else {
- if (m_Change_Monitor && m_bToggleShader) {
- if (m_pCAP) {
- m_pCAP->SetPixelShader(NULL, NULL);
- }
- }
- }
-
- if (m_fFullScreen) {
- m_fHideCursor = true;
- if (s.fShowBarsWhenFullScreen) {
- int nTimeOut = s.nShowBarsWhenFullScreenTimeOut;
- if (nTimeOut == 0) {
- ShowControls(CS_NONE);
- ShowControlBar(&m_wndNavigationBar, false, TRUE);
- } else if (nTimeOut > 0) {
- SetTimer(TIMER_FULLSCREENCONTROLBARHIDER, nTimeOut*1000, NULL);
- SetTimer(TIMER_FULLSCREENMOUSEHIDER, max(nTimeOut*1000, 2000), NULL);
- }
- } else {
- ShowControls(CS_NONE);
- ShowControlBar(&m_wndNavigationBar, false, TRUE);
- }
-
- if (s.fPreventMinimize) {
- if (hm != hm_cur) {
- ModifyStyle(WS_MINIMIZEBOX, 0, SWP_NOZORDER);
- }
- }
- } else {
- ModifyStyle(0, WS_MINIMIZEBOX, SWP_NOZORDER);
- KillTimer(TIMER_FULLSCREENCONTROLBARHIDER);
- KillTimer(TIMER_FULLSCREENMOUSEHIDER);
- m_fHideCursor = false;
- ShowControls(m_nCS);
- if (GetPlaybackMode() == PM_CAPTURE && s.iDefaultCaptureDevice == 1) {
- ShowControlBar(&m_wndNavigationBar, !s.fHideNavigation, TRUE);
- }
- }
-
- m_fAudioOnly = fAudioOnly;
-
- // Temporarily hide the OSD message if there is one, it will
- // be restored after. This avoid positioning problems.
- m_OSD.HideMessage(true);
-
- if (m_fFirstFSAfterLaunchOnFS) { //Play started in Fullscreen
- if (s.fRememberWindowSize || s.fRememberWindowPos) {
- r = s.rcLastWindowPos;
- if (!s.fRememberWindowPos) {
- hm = MonitorFromPoint( CPoint( 0,0 ), MONITOR_DEFAULTTOPRIMARY );
- GetMonitorInfo(hm, &mi);
- CRect m_r = mi.rcMonitor;
- int left = m_r.left + (m_r.Width() - r.Width())/2;
- int top = m_r.top + (m_r.Height() - r.Height())/2;
- r = CRect(left, top, left + r.Width(), top + r.Height());
- }
- if (!s.fRememberWindowSize) {
- CSize vsize = GetVideoSize();
- r = CRect(r.left, r.top, r.left + vsize.cx, r.top + vsize.cy);
- ShowWindow(SW_HIDE);
- }
- SetWindowPos(NULL, r.left, r.top, r.Width(), r.Height(), SWP_NOZORDER|SWP_NOSENDCHANGING);
- if (!s.fRememberWindowSize) {
- ZoomVideoWindow();
- ShowWindow(SW_SHOW);
- }
- } else {
- if (m_LastWindow_HM != hm_cur) {
- GetMonitorInfo(m_LastWindow_HM, &mi);
- r = mi.rcMonitor;
- ShowWindow(SW_HIDE);
- SetWindowPos(NULL, r.left, r.top, r.Width(), r.Height(), SWP_NOZORDER|SWP_NOSENDCHANGING);
- }
- ZoomVideoWindow();
- if (m_LastWindow_HM != hm_cur) {
- ShowWindow(SW_SHOW);
- }
- }
- m_fFirstFSAfterLaunchOnFS = false;
- } else {
- SetWindowPos(NULL, r.left, r.top, r.Width(), r.Height(), SWP_NOZORDER|SWP_NOSENDCHANGING);
- }
-
- SetAlwaysOnTop(s.iOnTop);
-
- MoveVideoWindow();
-
- m_OSD.HideMessage(false);
-
- if ((m_Change_Monitor) && (!m_bToggleShader || !m_bToggleShaderScreenSpace)) { // Enabled shader ...
- SetShaders();
- }
+ if (m_pFullscreenWnd->IsWindow()) {
+ return;
+ }
+
+ AppSettings& s = AfxGetAppSettings();
+ CRect r;
+ DWORD dwRemove = 0, dwAdd = 0;
+ DWORD dwRemoveEx = 0, dwAddEx = 0;
+ HMENU hMenu;
+ MONITORINFO mi;
+ mi.cbSize = sizeof(MONITORINFO);
+
+ HMONITOR hm = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+ HMONITOR hm_cur = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+
+ CMonitors monitors;
+
+ if (!m_fFullScreen) {
+ if (s.bHidePlaylistFullScreen && m_wndPlaylistBar.IsVisible()) {
+ m_wndPlaylistBar.SetHiddenDueToFullscreen(true);
+ ShowControlBar(&m_wndPlaylistBar, FALSE, TRUE);
+ }
+
+ if (!m_fFirstFSAfterLaunchOnFS) {
+ GetWindowRect(&m_lastWindowRect);
+ }
+ if (s.AutoChangeFullscrRes.bEnabled && fSwitchScreenResWhenHasTo && (GetPlaybackMode() != PM_NONE)) {
+ AutoChangeMonitorMode();
+ }
+ m_LastWindow_HM = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+
+ CString str;
+ CMonitor monitor;
+ if (s.strFullScreenMonitor == _T("Current")) {
+ hm = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+ } else {
+ for (int i = 0; i < monitors.GetCount(); i++) {
+ monitor = monitors.GetMonitor(i);
+ monitor.GetName(str);
+ if ((monitor.IsMonitor()) && (s.strFullScreenMonitor == str)) {
+ hm = monitor;
+ break;
+ }
+ }
+ if (!hm) {
+ hm = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+ }
+ }
+
+ dwRemove = WS_CAPTION | WS_THICKFRAME;
+ GetMonitorInfo(hm, &mi);
+ if (fToNearest) {
+ r = mi.rcMonitor;
+ } else {
+ GetDesktopWindow()->GetWindowRect(&r);
+ }
+ hMenu = NULL;
+ } else {
+ if (s.AutoChangeFullscrRes.bEnabled && s.AutoChangeFullscrRes.bApplyDefault && s.AutoChangeFullscrRes.dmFullscreenRes[0].fChecked == 1) {
+ SetDispMode(s.AutoChangeFullscrRes.dmFullscreenRes[0].dmFSRes, s.strFullScreenMonitor);
+ }
+
+ dwAdd = (s.iCaptionMenuMode == MODE_BORDERLESS ? 0 : s.iCaptionMenuMode == MODE_FRAMEONLY ? WS_THICKFRAME : WS_CAPTION | WS_THICKFRAME);
+ if (!m_fFirstFSAfterLaunchOnFS) {
+ r = m_lastWindowRect;
+ }
+ hMenu = (s.iCaptionMenuMode == MODE_SHOWCAPTIONMENU) ? m_hMenuDefault : NULL;
+
+ if (s.bHidePlaylistFullScreen && m_wndPlaylistBar.IsHiddenDueToFullscreen()) {
+ m_wndPlaylistBar.SetHiddenDueToFullscreen(false);
+ ShowControlBar(&m_wndPlaylistBar, TRUE, TRUE);
+ }
+ }
+
+ m_lastMouseMove.x = m_lastMouseMove.y = -1;
+
+ bool fAudioOnly = m_fAudioOnly;
+ m_fAudioOnly = true;
+
+ m_fFullScreen = !m_fFullScreen;
+ s.fLastFullScreen = m_fFullScreen;
+
+ ModifyStyle(dwRemove, dwAdd, SWP_NOZORDER);
+ ModifyStyleEx(dwRemoveEx, dwAddEx, SWP_NOZORDER);
+ ::SetMenu(m_hWnd, hMenu);
+
+ static bool m_Change_Monitor = false;
+ // try disable shader when move from one monitor to other ...
+ if (m_fFullScreen) {
+ m_Change_Monitor = (hm != hm_cur);
+ if ((m_Change_Monitor) && (!m_bToggleShader)) {
+ if (m_pCAP) {
+ m_pCAP->SetPixelShader(NULL, NULL);
+ }
+ }
+ if (m_Change_Monitor && m_bToggleShaderScreenSpace) {
+ if (m_pCAP2) {
+ m_pCAP2->SetPixelShader2(NULL, NULL, true);
+ }
+ }
+
+ } else {
+ if (m_Change_Monitor && m_bToggleShader) {
+ if (m_pCAP) {
+ m_pCAP->SetPixelShader(NULL, NULL);
+ }
+ }
+ }
+
+ if (m_fFullScreen) {
+ m_fHideCursor = true;
+ if (s.fShowBarsWhenFullScreen) {
+ int nTimeOut = s.nShowBarsWhenFullScreenTimeOut;
+ if (nTimeOut == 0) {
+ ShowControls(CS_NONE);
+ ShowControlBar(&m_wndNavigationBar, false, TRUE);
+ } else if (nTimeOut > 0) {
+ SetTimer(TIMER_FULLSCREENCONTROLBARHIDER, nTimeOut * 1000, NULL);
+ SetTimer(TIMER_FULLSCREENMOUSEHIDER, max(nTimeOut * 1000, 2000), NULL);
+ }
+ } else {
+ ShowControls(CS_NONE);
+ ShowControlBar(&m_wndNavigationBar, false, TRUE);
+ }
+
+ if (s.fPreventMinimize) {
+ if (hm != hm_cur) {
+ ModifyStyle(WS_MINIMIZEBOX, 0, SWP_NOZORDER);
+ }
+ }
+ } else {
+ ModifyStyle(0, WS_MINIMIZEBOX, SWP_NOZORDER);
+ KillTimer(TIMER_FULLSCREENCONTROLBARHIDER);
+ KillTimer(TIMER_FULLSCREENMOUSEHIDER);
+ m_fHideCursor = false;
+ ShowControls(m_nCS);
+ if (GetPlaybackMode() == PM_CAPTURE && s.iDefaultCaptureDevice == 1) {
+ ShowControlBar(&m_wndNavigationBar, !s.fHideNavigation, TRUE);
+ }
+ }
+
+ m_fAudioOnly = fAudioOnly;
+
+ // Temporarily hide the OSD message if there is one, it will
+ // be restored after. This avoid positioning problems.
+ m_OSD.HideMessage(true);
+
+ if (m_fFirstFSAfterLaunchOnFS) { //Play started in Fullscreen
+ if (s.fRememberWindowSize || s.fRememberWindowPos) {
+ r = s.rcLastWindowPos;
+ if (!s.fRememberWindowPos) {
+ hm = MonitorFromPoint(CPoint(0, 0), MONITOR_DEFAULTTOPRIMARY);
+ GetMonitorInfo(hm, &mi);
+ CRect m_r = mi.rcMonitor;
+ int left = m_r.left + (m_r.Width() - r.Width()) / 2;
+ int top = m_r.top + (m_r.Height() - r.Height()) / 2;
+ r = CRect(left, top, left + r.Width(), top + r.Height());
+ }
+ if (!s.fRememberWindowSize) {
+ CSize vsize = GetVideoSize();
+ r = CRect(r.left, r.top, r.left + vsize.cx, r.top + vsize.cy);
+ ShowWindow(SW_HIDE);
+ }
+ SetWindowPos(NULL, r.left, r.top, r.Width(), r.Height(), SWP_NOZORDER | SWP_NOSENDCHANGING);
+ if (!s.fRememberWindowSize) {
+ ZoomVideoWindow();
+ ShowWindow(SW_SHOW);
+ }
+ } else {
+ if (m_LastWindow_HM != hm_cur) {
+ GetMonitorInfo(m_LastWindow_HM, &mi);
+ r = mi.rcMonitor;
+ ShowWindow(SW_HIDE);
+ SetWindowPos(NULL, r.left, r.top, r.Width(), r.Height(), SWP_NOZORDER | SWP_NOSENDCHANGING);
+ }
+ ZoomVideoWindow();
+ if (m_LastWindow_HM != hm_cur) {
+ ShowWindow(SW_SHOW);
+ }
+ }
+ m_fFirstFSAfterLaunchOnFS = false;
+ } else {
+ SetWindowPos(NULL, r.left, r.top, r.Width(), r.Height(), SWP_NOZORDER | SWP_NOSENDCHANGING);
+ }
+
+ SetAlwaysOnTop(s.iOnTop);
+
+ MoveVideoWindow();
+
+ m_OSD.HideMessage(false);
+
+ if ((m_Change_Monitor) && (!m_bToggleShader || !m_bToggleShaderScreenSpace)) { // Enabled shader ...
+ SetShaders();
+ }
}
void CMainFrame::AutoChangeMonitorMode()
{
- AppSettings& s = AfxGetAppSettings();
- CStringW mf_hmonitor = s.strFullScreenMonitor;
- double MediaFPS = 0.0;
-
- if (s.IsD3DFullscreen() && miFPS > 0.9) {
- MediaFPS = miFPS;
- }
- else if (GetPlaybackMode() == PM_FILE) {
- LONGLONG m_rtTimePerFrame = 1;
- // if ExtractAvgTimePerFrame isn't executed then MediaFPS=10000000.0,
- // (int)(MediaFPS + 0.5)=10000000 and SetDispMode is executed to Default.
- BeginEnumFilters(pGB, pEF, pBF) {
- BeginEnumPins(pBF, pEP, pPin) {
- CMediaTypeEx mt;
- PIN_DIRECTION dir;
- if (FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_OUTPUT
- || FAILED(pPin->ConnectionMediaType(&mt))) {
- continue;
- }
- ExtractAvgTimePerFrame (&mt, m_rtTimePerFrame);
- if (m_rtTimePerFrame == 0) {
- m_rtTimePerFrame=1;
- }
- }
- EndEnumPins;
- }
- EndEnumFilters;
- MediaFPS = 10000000.0 / m_rtTimePerFrame;
- }
- else if (GetPlaybackMode() == PM_DVD) {
- DVD_PLAYBACK_LOCATION2 Location;
- if (pDVDI->GetCurrentLocation(&Location) == S_OK) {
- MediaFPS = Location.TimeCodeFlags == DVD_TC_FLAG_25fps ? 25.0
- : Location.TimeCodeFlags == DVD_TC_FLAG_30fps ? 30.0
- : Location.TimeCodeFlags == DVD_TC_FLAG_DropFrame ? 29.97
- : 25.0;
- }
- }
-
- for (int rs = 1; rs < 100 ; rs++) {
- if (s.AutoChangeFullscrRes.dmFullscreenRes[rs].fIsData == true
- && s.AutoChangeFullscrRes.dmFullscreenRes[rs].fChecked == 1
- && MediaFPS >= s.AutoChangeFullscrRes.dmFullscreenRes[rs].vfr_from
- && MediaFPS <= s.AutoChangeFullscrRes.dmFullscreenRes[rs].vfr_to) {
-
- SetDispMode(s.AutoChangeFullscrRes.dmFullscreenRes[rs].dmFSRes, mf_hmonitor);
- return;
- }
- }
- if (s.AutoChangeFullscrRes.dmFullscreenRes[0].fChecked == 1) {
- SetDispMode(s.AutoChangeFullscrRes.dmFullscreenRes[0].dmFSRes, mf_hmonitor);
- }
+ AppSettings& s = AfxGetAppSettings();
+ CStringW mf_hmonitor = s.strFullScreenMonitor;
+ double MediaFPS = 0.0;
+
+ if (s.IsD3DFullscreen() && miFPS > 0.9) {
+ MediaFPS = miFPS;
+ } else if (GetPlaybackMode() == PM_FILE) {
+ LONGLONG m_rtTimePerFrame = 1;
+ // if ExtractAvgTimePerFrame isn't executed then MediaFPS=10000000.0,
+ // (int)(MediaFPS + 0.5)=10000000 and SetDispMode is executed to Default.
+ BeginEnumFilters(pGB, pEF, pBF) {
+ BeginEnumPins(pBF, pEP, pPin) {
+ CMediaTypeEx mt;
+ PIN_DIRECTION dir;
+ if (FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_OUTPUT
+ || FAILED(pPin->ConnectionMediaType(&mt))) {
+ continue;
+ }
+ ExtractAvgTimePerFrame(&mt, m_rtTimePerFrame);
+ if (m_rtTimePerFrame == 0) {
+ m_rtTimePerFrame = 1;
+ }
+ }
+ EndEnumPins;
+ }
+ EndEnumFilters;
+ MediaFPS = 10000000.0 / m_rtTimePerFrame;
+ } else if (GetPlaybackMode() == PM_DVD) {
+ DVD_PLAYBACK_LOCATION2 Location;
+ if (pDVDI->GetCurrentLocation(&Location) == S_OK) {
+ MediaFPS = Location.TimeCodeFlags == DVD_TC_FLAG_25fps ? 25.0
+ : Location.TimeCodeFlags == DVD_TC_FLAG_30fps ? 30.0
+ : Location.TimeCodeFlags == DVD_TC_FLAG_DropFrame ? 29.97
+ : 25.0;
+ }
+ }
+
+ for (int rs = 1; rs < 100 ; rs++) {
+ if (s.AutoChangeFullscrRes.dmFullscreenRes[rs].fIsData == true
+ && s.AutoChangeFullscrRes.dmFullscreenRes[rs].fChecked == 1
+ && MediaFPS >= s.AutoChangeFullscrRes.dmFullscreenRes[rs].vfr_from
+ && MediaFPS <= s.AutoChangeFullscrRes.dmFullscreenRes[rs].vfr_to) {
+
+ SetDispMode(s.AutoChangeFullscrRes.dmFullscreenRes[rs].dmFSRes, mf_hmonitor);
+ return;
+ }
+ }
+ if (s.AutoChangeFullscrRes.dmFullscreenRes[0].fChecked == 1) {
+ SetDispMode(s.AutoChangeFullscrRes.dmFullscreenRes[0].dmFSRes, mf_hmonitor);
+ }
}
void CMainFrame::MoveVideoWindow(bool fShowStats)
{
- if ((m_iMediaLoadState == MLS_LOADED) && !m_fAudioOnly && IsWindowVisible()) {
- RECT wr;
- // fullscreen
- if (m_pFullscreenWnd->IsWindow()) {
- m_pFullscreenWnd->GetClientRect(&wr);
- }
- // windowed Mode
- else if (!m_fFullScreen) {
- m_wndView.GetClientRect(&wr);
- }
- // fullscreen on non-primary monitor
- else {
- GetWindowRect(&wr);
- RECT r;
- m_wndView.GetWindowRect(&r);
- wr.left -= r.left;
- wr.right -= r.left;
- wr.top -= r.top;
- wr.bottom -= r.top;
- }
-
- double dWRWidth = (double)(wr.right - wr.left);
- double dWRHeight = (double)(wr.bottom - wr.top);
-
- RECT vr = {0, 0, 0, 0};
-
- OAFilterState fs = GetMediaState();
- if ((fs == State_Paused) || (fs == State_Running) || (fs == State_Stopped) && (m_fShockwaveGraph || m_fQuicktimeGraph)) {
- SIZE arxy = GetVideoSize();
- double dARx = (double)(arxy.cx);
- double dARy = (double)(arxy.cy);
-
- dvstype iDefaultVideoSize = static_cast<dvstype>(AfxGetAppSettings().iDefaultVideoSize);
- double dVRWidth, dVRHeight;
- if (iDefaultVideoSize == DVS_HALF) {
- dVRWidth = dARx * 0.5;
- dVRHeight = dARy * 0.5;
- }
- else if (iDefaultVideoSize == DVS_NORMAL) {
- dVRWidth = dARx;
- dVRHeight = dARy;
- }
- else if (iDefaultVideoSize == DVS_DOUBLE) {
- dVRWidth = dARx * 2.0;
- dVRHeight = dARy * 2.0;
- } else {
- dVRWidth = dWRWidth;
- dVRHeight = dWRHeight;
- }
-
- if (!m_fShockwaveGraph) { // && !m_fQuicktimeGraph)
- double dCRWidth = dVRHeight * dARx / dARy;
-
- if (iDefaultVideoSize == DVS_FROMINSIDE) {
- if (dVRWidth < dCRWidth) {
- dVRHeight = dVRWidth * dARy / dARx;
- } else {
- dVRWidth = dCRWidth;
- }
- }
- else if (iDefaultVideoSize == DVS_FROMOUTSIDE) {
- if (dVRWidth > dCRWidth) {
- dVRHeight = dVRWidth * dARy / dARx;
- } else {
- dVRWidth = dCRWidth;
- }
- }
- else if ((iDefaultVideoSize == DVS_ZOOM1) || (iDefaultVideoSize == DVS_ZOOM2)) {
- double minw = dCRWidth;
- double maxw = dCRWidth;
-
- if (dVRWidth < dCRWidth) {
- minw = dVRWidth;
- }
- else {
- maxw = dVRWidth;
- }
-
- double scale = (iDefaultVideoSize == DVS_ZOOM1) ?
- 1.0 / 3.0 :
- 2.0 / 3.0;
- dVRWidth = minw + (maxw - minw) * scale;
- dVRHeight = dVRWidth * dARy / dARx;
- }
- }
-
- // either flooring or ceiling is required here, else the left-to-right and top-to-bottom sizes will get distorted through rounding twice each
- double dPPLeft = floor(m_PosX * (dWRWidth * 3.0 - m_ZoomX * dVRWidth) - dWRWidth);
- double dPPTop = floor(m_PosY * (dWRHeight * 3.0 - m_ZoomY * dVRHeight) - dWRHeight);
- // left and top parts are allowed to be negative
- vr.left = (LONG)(dPPLeft);
- vr.top = (LONG)(dPPTop);
- // right and bottom parts are always at picture center or beyond, so never negative
- vr.right = (LONG)(m_ZoomX * dVRWidth + dPPLeft);
- vr.bottom = (LONG)(m_ZoomY * dVRHeight + dPPTop);
-
- if (fShowStats) {
- CString info;
- info.Format(_T("Pos %.2f %.2f, Zoom %.2f %.2f, AR %.2f"), m_PosX, m_PosY, m_ZoomX, m_ZoomY, dVRWidth / dVRHeight);
- SendStatusMessage(info, 3000);
- }
- }
-
- if (m_pCAP) {
- m_pCAP->SetPosition(wr, vr);
- Vector v(Vector::DegToRad(m_AngleX), Vector::DegToRad(m_AngleY), Vector::DegToRad(m_AngleZ));
- m_pCAP->SetVideoAngle(v);
- } else {
- HRESULT hr;
- hr = pBV->SetDefaultSourcePosition();
- hr = pBV->SetDestinationPosition(vr.left, vr.top, vr.right - vr.left, vr.bottom - vr.top);
- hr = pVW->SetWindowPosition(wr.left, wr.top, wr.right - wr.left, wr.bottom - wr.top);
-
- if (m_pMFVDC) {
- m_pMFVDC->SetVideoPosition(NULL, &wr);
- }
- }
-
- m_wndView.SetVideoRect(&wr);
- } else {
- m_wndView.SetVideoRect();
- }
-
- UpdateThumbarButton();
+ if ((m_iMediaLoadState == MLS_LOADED) && !m_fAudioOnly && IsWindowVisible()) {
+ RECT wr;
+ // fullscreen
+ if (m_pFullscreenWnd->IsWindow()) {
+ m_pFullscreenWnd->GetClientRect(&wr);
+ }
+ // windowed Mode
+ else if (!m_fFullScreen) {
+ m_wndView.GetClientRect(&wr);
+ }
+ // fullscreen on non-primary monitor
+ else {
+ GetWindowRect(&wr);
+ RECT r;
+ m_wndView.GetWindowRect(&r);
+ wr.left -= r.left;
+ wr.right -= r.left;
+ wr.top -= r.top;
+ wr.bottom -= r.top;
+ }
+
+ double dWRWidth = (double)(wr.right - wr.left);
+ double dWRHeight = (double)(wr.bottom - wr.top);
+
+ RECT vr = {0, 0, 0, 0};
+
+ OAFilterState fs = GetMediaState();
+ if ((fs == State_Paused) || (fs == State_Running) || (fs == State_Stopped) && (m_fShockwaveGraph || m_fQuicktimeGraph)) {
+ SIZE arxy = GetVideoSize();
+ double dARx = (double)(arxy.cx);
+ double dARy = (double)(arxy.cy);
+
+ dvstype iDefaultVideoSize = static_cast<dvstype>(AfxGetAppSettings().iDefaultVideoSize);
+ double dVRWidth, dVRHeight;
+ if (iDefaultVideoSize == DVS_HALF) {
+ dVRWidth = dARx * 0.5;
+ dVRHeight = dARy * 0.5;
+ } else if (iDefaultVideoSize == DVS_NORMAL) {
+ dVRWidth = dARx;
+ dVRHeight = dARy;
+ } else if (iDefaultVideoSize == DVS_DOUBLE) {
+ dVRWidth = dARx * 2.0;
+ dVRHeight = dARy * 2.0;
+ } else {
+ dVRWidth = dWRWidth;
+ dVRHeight = dWRHeight;
+ }
+
+ if (!m_fShockwaveGraph) { // && !m_fQuicktimeGraph)
+ double dCRWidth = dVRHeight * dARx / dARy;
+
+ if (iDefaultVideoSize == DVS_FROMINSIDE) {
+ if (dVRWidth < dCRWidth) {
+ dVRHeight = dVRWidth * dARy / dARx;
+ } else {
+ dVRWidth = dCRWidth;
+ }
+ } else if (iDefaultVideoSize == DVS_FROMOUTSIDE) {
+ if (dVRWidth > dCRWidth) {
+ dVRHeight = dVRWidth * dARy / dARx;
+ } else {
+ dVRWidth = dCRWidth;
+ }
+ } else if ((iDefaultVideoSize == DVS_ZOOM1) || (iDefaultVideoSize == DVS_ZOOM2)) {
+ double minw = dCRWidth;
+ double maxw = dCRWidth;
+
+ if (dVRWidth < dCRWidth) {
+ minw = dVRWidth;
+ } else {
+ maxw = dVRWidth;
+ }
+
+ double scale = (iDefaultVideoSize == DVS_ZOOM1) ?
+ 1.0 / 3.0 :
+ 2.0 / 3.0;
+ dVRWidth = minw + (maxw - minw) * scale;
+ dVRHeight = dVRWidth * dARy / dARx;
+ }
+ }
+
+ // either flooring or ceiling is required here, else the left-to-right and top-to-bottom sizes will get distorted through rounding twice each
+ double dPPLeft = floor(m_PosX * (dWRWidth * 3.0 - m_ZoomX * dVRWidth) - dWRWidth);
+ double dPPTop = floor(m_PosY * (dWRHeight * 3.0 - m_ZoomY * dVRHeight) - dWRHeight);
+ // left and top parts are allowed to be negative
+ vr.left = (LONG)(dPPLeft);
+ vr.top = (LONG)(dPPTop);
+ // right and bottom parts are always at picture center or beyond, so never negative
+ vr.right = (LONG)(m_ZoomX * dVRWidth + dPPLeft);
+ vr.bottom = (LONG)(m_ZoomY * dVRHeight + dPPTop);
+
+ if (fShowStats) {
+ CString info;
+ info.Format(_T("Pos %.2f %.2f, Zoom %.2f %.2f, AR %.2f"), m_PosX, m_PosY, m_ZoomX, m_ZoomY, dVRWidth / dVRHeight);
+ SendStatusMessage(info, 3000);
+ }
+ }
+
+ if (m_pCAP) {
+ m_pCAP->SetPosition(wr, vr);
+ Vector v(Vector::DegToRad(m_AngleX), Vector::DegToRad(m_AngleY), Vector::DegToRad(m_AngleZ));
+ m_pCAP->SetVideoAngle(v);
+ } else {
+ HRESULT hr;
+ hr = pBV->SetDefaultSourcePosition();
+ hr = pBV->SetDestinationPosition(vr.left, vr.top, vr.right - vr.left, vr.bottom - vr.top);
+ hr = pVW->SetWindowPosition(wr.left, wr.top, wr.right - wr.left, wr.bottom - wr.top);
+
+ if (m_pMFVDC) {
+ m_pMFVDC->SetVideoPosition(NULL, &wr);
+ }
+ }
+
+ m_wndView.SetVideoRect(&wr);
+ } else {
+ m_wndView.SetVideoRect();
+ }
+
+ UpdateThumbarButton();
}
void CMainFrame::HideVideoWindow(bool fHide)
{
- CRect wr;
- if (m_pFullscreenWnd->IsWindow()) {
- m_pFullscreenWnd->GetClientRect(&wr);
- } else if (!m_fFullScreen) {
- m_wndView.GetClientRect(&wr);
- } else {
- GetWindowRect(&wr);
-
- // this code is needed to work in fullscreen on secondary monitor
- CRect r;
- m_wndView.GetWindowRect(&r);
- wr -= r.TopLeft();
- }
+ CRect wr;
+ if (m_pFullscreenWnd->IsWindow()) {
+ m_pFullscreenWnd->GetClientRect(&wr);
+ } else if (!m_fFullScreen) {
+ m_wndView.GetClientRect(&wr);
+ } else {
+ GetWindowRect(&wr);
+
+ // this code is needed to work in fullscreen on secondary monitor
+ CRect r;
+ m_wndView.GetWindowRect(&r);
+ wr -= r.TopLeft();
+ }
- CRect vr = CRect(0,0,0,0);
- if (m_pCAP) {
- if (fHide) {
- m_pCAP->SetPosition(wr, vr); // hide
- } else {
- m_pCAP->SetPosition(wr, wr); // show
- }
- }
+ CRect vr = CRect(0, 0, 0, 0);
+ if (m_pCAP) {
+ if (fHide) {
+ m_pCAP->SetPosition(wr, vr); // hide
+ } else {
+ m_pCAP->SetPosition(wr, wr); // show
+ }
+ }
}
void CMainFrame::ZoomVideoWindow(bool snap, double scale)
{
- if (m_iMediaLoadState != MLS_LOADED) {
- return;
- }
-
- AppSettings& s = AfxGetAppSettings();
-
- if (scale <= 0) {
- scale =
- s.iZoomLevel == 0 ? 0.5 :
- s.iZoomLevel == 1 ? 1.0 :
- s.iZoomLevel == 2 ? 2.0 :
- s.iZoomLevel == 3 ? GetZoomAutoFitScale(false) :
- s.iZoomLevel == 4 ? GetZoomAutoFitScale(true) : 1.0;
- }
-
- if (m_fFullScreen) {
- OnViewFullscreen();
- }
-
- MINMAXINFO mmi;
- OnGetMinMaxInfo(&mmi);
-
- CRect r;
- GetWindowRect(r);
- int w = 0, h = 0;
-
- if (!m_fAudioOnly) {
- CSize arxy = GetVideoSize();
-
- long lWidth = int(arxy.cx * scale + 0.5);
- long lHeight = int(arxy.cy * scale + 0.5);
-
- DWORD style = GetStyle();
-
- CRect r1, r2;
- GetClientRect(&r1);
- m_wndView.GetClientRect(&r2);
-
- w = r1.Width() - r2.Width() + lWidth;
- h = r1.Height() - r2.Height() + lHeight;
-
- if (style & WS_THICKFRAME) {
- w += GetSystemMetrics(SM_CXSIZEFRAME) * 2;
- h += GetSystemMetrics(SM_CYSIZEFRAME) * 2;
- if ( (style & WS_CAPTION) == 0 ) {
- w -= 2;
- h -= 2;
- }
- }
-
- if ( style & WS_CAPTION ) {
- h += GetSystemMetrics( SM_CYCAPTION );
- if (s.iCaptionMenuMode == MODE_SHOWCAPTIONMENU) {
- h += GetSystemMetrics( SM_CYMENU );
- }
- //else MODE_HIDEMENU
- }
-
- if (GetPlaybackMode() == PM_CAPTURE && !s.fHideNavigation && !m_fFullScreen && !m_wndNavigationBar.IsVisible()) {
- CSize r = m_wndNavigationBar.CalcFixedLayout(FALSE, TRUE);
- w += r.cx;
- }
-
- w = max(w, mmi.ptMinTrackSize.x);
- h = max(h, mmi.ptMinTrackSize.y);
- } else {
- w = r.Width(); // mmi.ptMinTrackSize.x;
- h = mmi.ptMinTrackSize.y;
- }
-
- // Prevention of going beyond the scopes of screen
- MONITORINFO mi;
- mi.cbSize = sizeof(MONITORINFO);
- GetMonitorInfo(MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST), &mi);
- w = min(w, (mi.rcWork.right - mi.rcWork.left));
- h = min(h, (mi.rcWork.bottom - mi.rcWork.top));
-
- if (!s.fRememberWindowPos) {
- bool isSnapped = false;
-
- if (snap && s.fSnapToDesktopEdges && m_bWasSnapped) { // check if snapped to edges
- isSnapped = (r.left == mi.rcWork.left) || (r.top == mi.rcWork.top)
- || (r.right == mi.rcWork.right) || (r.bottom == mi.rcWork.bottom);
- }
-
- if (isSnapped) { // prefer left, top snap to right, bottom snap
- if (r.left == mi.rcWork.left) {}
- else if (r.right == mi.rcWork.right) {
- r.left = r.right - w;
- }
-
- if (r.top == mi.rcWork.top) {}
- else if (r.bottom == mi.rcWork.bottom) {
- r.top = r.bottom - h;
- }
- } else { // center window
- CPoint cp = r.CenterPoint();
- r.left = cp.x - w/2;
- r.top = cp.y - h/2;
- m_bWasSnapped = false;
- }
- }
-
- r.right = r.left + w;
- r.bottom = r.top + h;
-
- if (r.right > mi.rcWork.right) {
- r.OffsetRect(mi.rcWork.right-r.right, 0);
- }
- if (r.left < mi.rcWork.left) {
- r.OffsetRect(mi.rcWork.left-r.left, 0);
- }
- if (r.bottom > mi.rcWork.bottom) {
- r.OffsetRect(0, mi.rcWork.bottom-r.bottom);
- }
- if (r.top < mi.rcWork.top) {
- r.OffsetRect(0, mi.rcWork.top-r.top);
- }
-
- if ((m_fFullScreen || !s.HasFixedWindowSize()) && !m_pFullscreenWnd->IsWindow()) {
- MoveWindow(r);
- }
-
- //ShowWindow(SW_SHOWNORMAL);
-
- MoveVideoWindow();
+ if (m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
+
+ AppSettings& s = AfxGetAppSettings();
+
+ if (scale <= 0) {
+ scale =
+ s.iZoomLevel == 0 ? 0.5 :
+ s.iZoomLevel == 1 ? 1.0 :
+ s.iZoomLevel == 2 ? 2.0 :
+ s.iZoomLevel == 3 ? GetZoomAutoFitScale(false) :
+ s.iZoomLevel == 4 ? GetZoomAutoFitScale(true) : 1.0;
+ }
+
+ if (m_fFullScreen) {
+ OnViewFullscreen();
+ }
+
+ MINMAXINFO mmi;
+ OnGetMinMaxInfo(&mmi);
+
+ CRect r;
+ GetWindowRect(r);
+ int w = 0, h = 0;
+
+ if (!m_fAudioOnly) {
+ CSize arxy = GetVideoSize();
+
+ long lWidth = int(arxy.cx * scale + 0.5);
+ long lHeight = int(arxy.cy * scale + 0.5);
+
+ DWORD style = GetStyle();
+
+ CRect r1, r2;
+ GetClientRect(&r1);
+ m_wndView.GetClientRect(&r2);
+
+ w = r1.Width() - r2.Width() + lWidth;
+ h = r1.Height() - r2.Height() + lHeight;
+
+ if (style & WS_THICKFRAME) {
+ w += GetSystemMetrics(SM_CXSIZEFRAME) * 2;
+ h += GetSystemMetrics(SM_CYSIZEFRAME) * 2;
+ if ((style & WS_CAPTION) == 0) {
+ w -= 2;
+ h -= 2;
+ }
+ }
+
+ if (style & WS_CAPTION) {
+ h += GetSystemMetrics(SM_CYCAPTION);
+ if (s.iCaptionMenuMode == MODE_SHOWCAPTIONMENU) {
+ h += GetSystemMetrics(SM_CYMENU);
+ }
+ //else MODE_HIDEMENU
+ }
+
+ if (GetPlaybackMode() == PM_CAPTURE && !s.fHideNavigation && !m_fFullScreen && !m_wndNavigationBar.IsVisible()) {
+ CSize r = m_wndNavigationBar.CalcFixedLayout(FALSE, TRUE);
+ w += r.cx;
+ }
+
+ w = max(w, mmi.ptMinTrackSize.x);
+ h = max(h, mmi.ptMinTrackSize.y);
+ } else {
+ w = r.Width(); // mmi.ptMinTrackSize.x;
+ h = mmi.ptMinTrackSize.y;
+ }
+
+ // Prevention of going beyond the scopes of screen
+ MONITORINFO mi;
+ mi.cbSize = sizeof(MONITORINFO);
+ GetMonitorInfo(MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST), &mi);
+ w = min(w, (mi.rcWork.right - mi.rcWork.left));
+ h = min(h, (mi.rcWork.bottom - mi.rcWork.top));
+
+ if (!s.fRememberWindowPos) {
+ bool isSnapped = false;
+
+ if (snap && s.fSnapToDesktopEdges && m_bWasSnapped) { // check if snapped to edges
+ isSnapped = (r.left == mi.rcWork.left) || (r.top == mi.rcWork.top)
+ || (r.right == mi.rcWork.right) || (r.bottom == mi.rcWork.bottom);
+ }
+
+ if (isSnapped) { // prefer left, top snap to right, bottom snap
+ if (r.left == mi.rcWork.left) {}
+ else if (r.right == mi.rcWork.right) {
+ r.left = r.right - w;
+ }
+
+ if (r.top == mi.rcWork.top) {}
+ else if (r.bottom == mi.rcWork.bottom) {
+ r.top = r.bottom - h;
+ }
+ } else { // center window
+ CPoint cp = r.CenterPoint();
+ r.left = cp.x - w / 2;
+ r.top = cp.y - h / 2;
+ m_bWasSnapped = false;
+ }
+ }
+
+ r.right = r.left + w;
+ r.bottom = r.top + h;
+
+ if (r.right > mi.rcWork.right) {
+ r.OffsetRect(mi.rcWork.right - r.right, 0);
+ }
+ if (r.left < mi.rcWork.left) {
+ r.OffsetRect(mi.rcWork.left - r.left, 0);
+ }
+ if (r.bottom > mi.rcWork.bottom) {
+ r.OffsetRect(0, mi.rcWork.bottom - r.bottom);
+ }
+ if (r.top < mi.rcWork.top) {
+ r.OffsetRect(0, mi.rcWork.top - r.top);
+ }
+
+ if ((m_fFullScreen || !s.HasFixedWindowSize()) && !m_pFullscreenWnd->IsWindow()) {
+ MoveWindow(r);
+ }
+
+ //ShowWindow(SW_SHOWNORMAL);
+
+ MoveVideoWindow();
}
double CMainFrame::GetZoomAutoFitScale(bool bLargerOnly) const
{
- if (m_iMediaLoadState != MLS_LOADED || m_fAudioOnly) {
- return 1.0;
- }
-
- CSize arxy = GetVideoSize();
- // get the work area
- MONITORINFO mi;
- mi.cbSize = sizeof(MONITORINFO);
- HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- GetMonitorInfo(hMonitor, &mi);
- RECT& wa = mi.rcWork;
-
- // vertical borders
- arxy.cx += 2 * ::GetSystemMetrics(SM_CXSIZEFRAME);
- // horizontal border + caption
- arxy.cy += ::GetSystemMetrics(SM_CYSIZEFRAME) + ::GetSystemMetrics(SM_CYCAPTION);
- RECT r;
- if (m_wndSeekBar.IsVisible()) {
- m_wndSeekBar.GetWindowRect(&r);
- arxy.cy += r.bottom - r.top;
- }
- if (m_wndToolBar.IsVisible()) {
- m_wndToolBar.GetWindowRect(&r);
- arxy.cy += r.bottom - r.top;
- }
- if (m_wndInfoBar.IsVisible()) {
- m_wndInfoBar.GetWindowRect(&r);
- arxy.cy += r.bottom - r.top;
- }
- if (m_wndStatsBar.IsVisible()) {
- m_wndStatsBar.GetWindowRect(&r);
- arxy.cy += r.bottom - r.top;
- }
- if (m_wndStatusBar.IsVisible()) {
- m_wndStatusBar.GetWindowRect(&r);
- arxy.cy += r.bottom - r.top;
- }
-
- LONG width = wa.right - wa.left;
- LONG height = wa.bottom - wa.top;
- if (bLargerOnly && (arxy.cx < width && arxy.cy < height))
- return 1.0;
-
- double sx = 2.0/3.0 * (double)width / (double)arxy.cx;
- double sy = 2.0/3.0 * (double)height / (double)arxy.cy;
-
- return sx < sy ? sx : sy;
+ if (m_iMediaLoadState != MLS_LOADED || m_fAudioOnly) {
+ return 1.0;
+ }
+
+ CSize arxy = GetVideoSize();
+ // get the work area
+ MONITORINFO mi;
+ mi.cbSize = sizeof(MONITORINFO);
+ HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+ GetMonitorInfo(hMonitor, &mi);
+ RECT& wa = mi.rcWork;
+
+ // vertical borders
+ arxy.cx += 2 * ::GetSystemMetrics(SM_CXSIZEFRAME);
+ // horizontal border + caption
+ arxy.cy += ::GetSystemMetrics(SM_CYSIZEFRAME) + ::GetSystemMetrics(SM_CYCAPTION);
+ RECT r;
+ if (m_wndSeekBar.IsVisible()) {
+ m_wndSeekBar.GetWindowRect(&r);
+ arxy.cy += r.bottom - r.top;
+ }
+ if (m_wndToolBar.IsVisible()) {
+ m_wndToolBar.GetWindowRect(&r);
+ arxy.cy += r.bottom - r.top;
+ }
+ if (m_wndInfoBar.IsVisible()) {
+ m_wndInfoBar.GetWindowRect(&r);
+ arxy.cy += r.bottom - r.top;
+ }
+ if (m_wndStatsBar.IsVisible()) {
+ m_wndStatsBar.GetWindowRect(&r);
+ arxy.cy += r.bottom - r.top;
+ }
+ if (m_wndStatusBar.IsVisible()) {
+ m_wndStatusBar.GetWindowRect(&r);
+ arxy.cy += r.bottom - r.top;
+ }
+
+ LONG width = wa.right - wa.left;
+ LONG height = wa.bottom - wa.top;
+ if (bLargerOnly && (arxy.cx < width && arxy.cy < height)) {
+ return 1.0;
+ }
+
+ double sx = 2.0 / 3.0 * (double)width / (double)arxy.cx;
+ double sy = 2.0 / 3.0 * (double)height / (double)arxy.cy;
+
+ return sx < sy ? sx : sy;
}
void CMainFrame::RepaintVideo()
{
- if (m_pCAP) {
- m_pCAP->Paint(false);
- }
+ if (m_pCAP) {
+ m_pCAP->Paint(false);
+ }
}
void CMainFrame::SetShaders()
{
- if (!m_pCAP) {
- return;
- }
-
- AppSettings& s = AfxGetAppSettings();
-
- CAtlStringMap<const AppSettings::Shader*> s2s;
-
- POSITION pos = s.m_shaders.GetHeadPosition();
- while (pos) {
- const AppSettings::Shader* pShader = &s.m_shaders.GetNext(pos);
- s2s[pShader->label] = pShader;
- }
-
- m_pCAP->SetPixelShader(NULL, NULL);
- if (m_pCAP2) {
- m_pCAP2->SetPixelShader2(NULL, NULL, true);
- }
-
- for (int i = 0; i < 2; ++i) {
- if (i == 0 && !m_bToggleShader) {
- continue;
- }
- if (i == 1 && !m_bToggleShaderScreenSpace) {
- continue;
- }
- CAtlList<CString> labels;
-
- CAtlList<CString> *pLabels;
- if (i == 0) {
- pLabels = &m_shaderlabels;
- } else {
- if (!m_pCAP2) {
- break;
- }
- pLabels = &m_shaderlabelsScreenSpace;
- }
-
- pos = pLabels->GetHeadPosition();
- while (pos) {
- const AppSettings::Shader* pShader = NULL;
- if (s2s.Lookup(pLabels->GetNext(pos), pShader)) {
- CStringA target = pShader->target;
- CStringA srcdata = pShader->srcdata;
-
- HRESULT hr;
- if (i == 0) {
- hr = m_pCAP->SetPixelShader(srcdata, target);
- } else {
- hr = m_pCAP2->SetPixelShader2(srcdata, target, true);
- }
-
- if (FAILED(hr)) {
- m_pCAP->SetPixelShader(NULL, NULL);
- if (m_pCAP2) {
- m_pCAP2->SetPixelShader2(NULL, NULL, true);
- }
- SendStatusMessage(ResStr(IDS_MAINFRM_73) + pShader->label, 3000);
- return;
- }
-
- labels.AddTail(pShader->label);
- }
- }
-
- if (m_iMediaLoadState == MLS_LOADED) {
- CString str = Implode(labels, '|');
- str.Replace(_T("|"), _T(", "));
- SendStatusMessage(ResStr(IDS_AG_SHADER) + str, 3000);
- }
- }
+ if (!m_pCAP) {
+ return;
+ }
+
+ AppSettings& s = AfxGetAppSettings();
+
+ CAtlStringMap<const AppSettings::Shader*> s2s;
+
+ POSITION pos = s.m_shaders.GetHeadPosition();
+ while (pos) {
+ const AppSettings::Shader* pShader = &s.m_shaders.GetNext(pos);
+ s2s[pShader->label] = pShader;
+ }
+
+ m_pCAP->SetPixelShader(NULL, NULL);
+ if (m_pCAP2) {
+ m_pCAP2->SetPixelShader2(NULL, NULL, true);
+ }
+
+ for (int i = 0; i < 2; ++i) {
+ if (i == 0 && !m_bToggleShader) {
+ continue;
+ }
+ if (i == 1 && !m_bToggleShaderScreenSpace) {
+ continue;
+ }
+ CAtlList<CString> labels;
+
+ CAtlList<CString>* pLabels;
+ if (i == 0) {
+ pLabels = &m_shaderlabels;
+ } else {
+ if (!m_pCAP2) {
+ break;
+ }
+ pLabels = &m_shaderlabelsScreenSpace;
+ }
+
+ pos = pLabels->GetHeadPosition();
+ while (pos) {
+ const AppSettings::Shader* pShader = NULL;
+ if (s2s.Lookup(pLabels->GetNext(pos), pShader)) {
+ CStringA target = pShader->target;
+ CStringA srcdata = pShader->srcdata;
+
+ HRESULT hr;
+ if (i == 0) {
+ hr = m_pCAP->SetPixelShader(srcdata, target);
+ } else {
+ hr = m_pCAP2->SetPixelShader2(srcdata, target, true);
+ }
+
+ if (FAILED(hr)) {
+ m_pCAP->SetPixelShader(NULL, NULL);
+ if (m_pCAP2) {
+ m_pCAP2->SetPixelShader2(NULL, NULL, true);
+ }
+ SendStatusMessage(ResStr(IDS_MAINFRM_73) + pShader->label, 3000);
+ return;
+ }
+
+ labels.AddTail(pShader->label);
+ }
+ }
+
+ if (m_iMediaLoadState == MLS_LOADED) {
+ CString str = Implode(labels, '|');
+ str.Replace(_T("|"), _T(", "));
+ SendStatusMessage(ResStr(IDS_AG_SHADER) + str, 3000);
+ }
+ }
}
void CMainFrame::UpdateShaders(CString label)
{
- if (!m_pCAP) {
- return;
- }
+ if (!m_pCAP) {
+ return;
+ }
- if (m_shaderlabels.GetCount() <= 1) {
- m_shaderlabels.RemoveAll();
- }
+ if (m_shaderlabels.GetCount() <= 1) {
+ m_shaderlabels.RemoveAll();
+ }
- if (m_shaderlabels.IsEmpty() && !label.IsEmpty()) {
- m_shaderlabels.AddTail(label);
- }
+ if (m_shaderlabels.IsEmpty() && !label.IsEmpty()) {
+ m_shaderlabels.AddTail(label);
+ }
- bool fUpdate = m_shaderlabels.IsEmpty();
+ bool fUpdate = m_shaderlabels.IsEmpty();
- POSITION pos = m_shaderlabels.GetHeadPosition();
- while (pos) {
- if (label == m_shaderlabels.GetNext(pos)) {
- fUpdate = true;
- break;
- }
- }
+ POSITION pos = m_shaderlabels.GetHeadPosition();
+ while (pos) {
+ if (label == m_shaderlabels.GetNext(pos)) {
+ fUpdate = true;
+ break;
+ }
+ }
- if (fUpdate) {
- SetShaders();
- }
+ if (fUpdate) {
+ SetShaders();
+ }
}
void CMainFrame::SetBalance(int balance)
{
- int sign = balance>0?-1:1; // -1: invert sign for more right channel
- int balance_dB;
- if (balance > -100 && balance < 100) {
- balance_dB = sign*(int)(100*20*log10(1-abs(balance)/100.0f));
- } else {
- balance_dB = sign*(-10000); // -10000: only left, 10000: only right
- }
+ int sign = balance > 0 ? -1 : 1; // -1: invert sign for more right channel
+ int balance_dB;
+ if (balance > -100 && balance < 100) {
+ balance_dB = sign * (int)(100 * 20 * log10(1 - abs(balance) / 100.0f));
+ } else {
+ balance_dB = sign * (-10000); // -10000: only left, 10000: only right
+ }
- if (m_iMediaLoadState == MLS_LOADED) {
- CString strBalance, strBalanceOSD;
+ if (m_iMediaLoadState == MLS_LOADED) {
+ CString strBalance, strBalanceOSD;
- pBA->put_Balance(balance_dB);
+ pBA->put_Balance(balance_dB);
- if (balance == 0) {
- strBalance = L"L = R";
- } else if (balance < 0) {
- strBalance.Format(L"L +%d%%", -balance);
- } else { //if (m_nBalance > 0)
- strBalance.Format(L"R +%d%%", balance);
- }
+ if (balance == 0) {
+ strBalance = L"L = R";
+ } else if (balance < 0) {
+ strBalance.Format(L"L +%d%%", -balance);
+ } else { //if (m_nBalance > 0)
+ strBalance.Format(L"R +%d%%", balance);
+ }
- strBalanceOSD.Format(IDS_BALANCE_OSD, strBalance);
- m_OSD.DisplayMessage(OSD_TOPLEFT, strBalanceOSD);
- }
+ strBalanceOSD.Format(IDS_BALANCE_OSD, strBalance);
+ m_OSD.DisplayMessage(OSD_TOPLEFT, strBalanceOSD);
+ }
}
void CMainFrame::SetupIViAudReg()
{
- if (!AfxGetAppSettings().fAutoSpeakerConf) {
- return;
- }
-
- DWORD spc = 0, defchnum = 0;
-
- if (AfxGetAppSettings().fAutoSpeakerConf) {
- CComPtr<IDirectSound> pDS;
- if (SUCCEEDED(DirectSoundCreate(NULL, &pDS, NULL))
- && SUCCEEDED(pDS->SetCooperativeLevel(m_hWnd, DSSCL_NORMAL))) {
- if (SUCCEEDED(pDS->GetSpeakerConfig(&spc))) {
- switch (spc) {
- case DSSPEAKER_DIRECTOUT:
- defchnum = 6;
- break;
- case DSSPEAKER_HEADPHONE:
- defchnum = 2;
- break;
- case DSSPEAKER_MONO:
- defchnum = 1;
- break;
- case DSSPEAKER_QUAD:
- defchnum = 4;
- break;
- default:
- case DSSPEAKER_STEREO:
- defchnum = 2;
- break;
- case DSSPEAKER_SURROUND:
- defchnum = 2;
- break;
- case DSSPEAKER_5POINT1:
- defchnum = 5;
- break;
- case DSSPEAKER_7POINT1:
- defchnum = 5;
- break;
- }
- }
- }
- } else {
- defchnum = 2;
- }
-
- CRegKey iviaud;
- if (ERROR_SUCCESS == iviaud.Create(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\InterVideo\\Common\\AudioDec"))) {
- DWORD chnum = 0;
- if (FAILED(iviaud.QueryDWORDValue(_T("AUDIO"), chnum))) {
- chnum = 0;
- }
- if (chnum <= defchnum) { // check if the user has already set it..., but we won't skip if it's lower than sensible :P
- iviaud.SetDWORDValue(_T("AUDIO"), defchnum);
- }
- }
+ if (!AfxGetAppSettings().fAutoSpeakerConf) {
+ return;
+ }
+
+ DWORD spc = 0, defchnum = 0;
+
+ if (AfxGetAppSettings().fAutoSpeakerConf) {
+ CComPtr<IDirectSound> pDS;
+ if (SUCCEEDED(DirectSoundCreate(NULL, &pDS, NULL))
+ && SUCCEEDED(pDS->SetCooperativeLevel(m_hWnd, DSSCL_NORMAL))) {
+ if (SUCCEEDED(pDS->GetSpeakerConfig(&spc))) {
+ switch (spc) {
+ case DSSPEAKER_DIRECTOUT:
+ defchnum = 6;
+ break;
+ case DSSPEAKER_HEADPHONE:
+ defchnum = 2;
+ break;
+ case DSSPEAKER_MONO:
+ defchnum = 1;
+ break;
+ case DSSPEAKER_QUAD:
+ defchnum = 4;
+ break;
+ default:
+ case DSSPEAKER_STEREO:
+ defchnum = 2;
+ break;
+ case DSSPEAKER_SURROUND:
+ defchnum = 2;
+ break;
+ case DSSPEAKER_5POINT1:
+ defchnum = 5;
+ break;
+ case DSSPEAKER_7POINT1:
+ defchnum = 5;
+ break;
+ }
+ }
+ }
+ } else {
+ defchnum = 2;
+ }
+
+ CRegKey iviaud;
+ if (ERROR_SUCCESS == iviaud.Create(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\InterVideo\\Common\\AudioDec"))) {
+ DWORD chnum = 0;
+ if (FAILED(iviaud.QueryDWORDValue(_T("AUDIO"), chnum))) {
+ chnum = 0;
+ }
+ if (chnum <= defchnum) { // check if the user has already set it..., but we won't skip if it's lower than sensible :P
+ iviaud.SetDWORDValue(_T("AUDIO"), defchnum);
+ }
+ }
}
//
@@ -10319,1903 +10313,1904 @@ void CMainFrame::SetupIViAudReg()
bool CMainFrame::IsRealEngineCompatible(CString strFilename) const
{
- // Real Media engine didn't support Unicode filename (nor filenames with # characters)
- for (int i=0; i<strFilename.GetLength(); i++) {
- WCHAR Char = strFilename[i];
- if (Char<32 || Char>126 || Char==35) {
- return false;
- }
- }
- return true;
+ // Real Media engine didn't support Unicode filename (nor filenames with # characters)
+ for (int i = 0; i < strFilename.GetLength(); i++) {
+ WCHAR Char = strFilename[i];
+ if (Char < 32 || Char > 126 || Char == 35) {
+ return false;
+ }
+ }
+ return true;
}
void CMainFrame::OpenCreateGraphObject(OpenMediaData* pOMD)
{
- ASSERT(pGB == NULL);
-
- m_fCustomGraph = false;
- m_fRealMediaGraph = m_fShockwaveGraph = m_fQuicktimeGraph = false;
-
- AppSettings& s = AfxGetAppSettings();
-
- // CASIMIR666 todo
- if (s.IsD3DFullscreen() &&
- ((s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) ||
- (s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM) ||
- (s.iDSVideoRendererType == VIDRNDT_DS_MADVR) ||
- (s.iDSVideoRendererType == VIDRNDT_DS_SYNC))) {
- CreateFullScreenWindow();
- m_pVideoWnd = m_pFullscreenWnd;
- } else {
- m_pVideoWnd = &m_wndView;
- }
-
- if (OpenFileData* p = dynamic_cast<OpenFileData*>(pOMD)) {
- engine_t engine = s.m_Formats.GetEngine(p->fns.GetHead());
-
- CStringA ct = GetContentType(p->fns.GetHead());
-
- if (ct == "video/x-ms-asf") {
- // TODO: put something here to make the windows media source filter load later
- } else if (ct == "audio/x-pn-realaudio"
- || ct == "audio/x-pn-realaudio-plugin"
- || ct == "audio/x-realaudio-secure"
- || ct == "video/vnd.rn-realvideo-secure"
- || ct == "application/vnd.rn-realmedia"
- || ct.Find("vnd.rn-") >= 0
- || ct.Find("realaudio") >= 0
- || ct.Find("realvideo") >= 0) {
- engine = RealMedia;
- } else if (ct == "application/x-shockwave-flash") {
- engine = ShockWave;
- } else if (ct == "video/quicktime"
- || ct == "application/x-quicktimeplayer") {
- engine = QuickTime;
- }
-
- HRESULT hr = E_FAIL;
- CComPtr<IUnknown> pUnk;
-
- if (engine == RealMedia) {
- // TODO : see why Real SDK crash here ...
- //if (!IsRealEngineCompatible(p->fns.GetHead()))
- // throw ResStr(IDS_REALVIDEO_INCOMPATIBLE);
-
- pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew DSObjects::CRealMediaGraph(m_pVideoWnd->m_hWnd, hr);
- if (!pUnk) {
- throw (UINT)IDS_AG_OUT_OF_MEMORY;
- }
-
- if (SUCCEEDED(hr)) {
- pGB = CComQIPtr<IGraphBuilder>(pUnk);
- if (pGB) {
- m_fRealMediaGraph = true;
- }
- }
- } else if (engine == ShockWave) {
- pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew DSObjects::CShockwaveGraph(m_pVideoWnd->m_hWnd, hr);
- if (!pUnk) {
- throw (UINT)IDS_AG_OUT_OF_MEMORY;
- }
-
- if (SUCCEEDED(hr)) {
- pGB = CComQIPtr<IGraphBuilder>(pUnk);
- }
- if (FAILED(hr) || !pGB) {
- throw (UINT)IDS_MAINFRM_77;
- }
- m_fShockwaveGraph = true;
- } else if (engine == QuickTime) {
-#ifdef _WIN64 // TODOX64
- //MessageBox (ResStr(IDS_MAINFRM_78), _T(""), MB_OK);
-#else
- pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew DSObjects::CQuicktimeGraph(m_pVideoWnd->m_hWnd, hr);
- if (!pUnk) {
- throw (UINT)IDS_AG_OUT_OF_MEMORY;
- }
-
- if (SUCCEEDED(hr)) {
- pGB = CComQIPtr<IGraphBuilder>(pUnk);
- if (pGB) {
- m_fQuicktimeGraph = true;
- }
- }
-#endif
- }
+ ASSERT(pGB == NULL);
- m_fCustomGraph = m_fRealMediaGraph || m_fShockwaveGraph || m_fQuicktimeGraph;
+ m_fCustomGraph = false;
+ m_fRealMediaGraph = m_fShockwaveGraph = m_fQuicktimeGraph = false;
- if (!m_fCustomGraph) {
- pGB = DNew CFGManagerPlayer(_T("CFGManagerPlayer"), NULL, m_pVideoWnd->m_hWnd);
- }
- } else if (OpenDVDData* p = dynamic_cast<OpenDVDData*>(pOMD)) {
- pGB = DNew CFGManagerDVD(_T("CFGManagerDVD"), NULL, m_pVideoWnd->m_hWnd);
- } else if (OpenDeviceData* p = dynamic_cast<OpenDeviceData*>(pOMD)) {
- if (s.iDefaultCaptureDevice == 1) {
- pGB = DNew CFGManagerBDA(_T("CFGManagerBDA"), NULL, m_pVideoWnd->m_hWnd);
- } else {
- pGB = DNew CFGManagerCapture(_T("CFGManagerCapture"), NULL, m_pVideoWnd->m_hWnd);
- }
- }
+ AppSettings& s = AfxGetAppSettings();
+
+ // CASIMIR666 todo
+ if (s.IsD3DFullscreen() &&
+ ((s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) ||
+ (s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM) ||
+ (s.iDSVideoRendererType == VIDRNDT_DS_MADVR) ||
+ (s.iDSVideoRendererType == VIDRNDT_DS_SYNC))) {
+ CreateFullScreenWindow();
+ m_pVideoWnd = m_pFullscreenWnd;
+ } else {
+ m_pVideoWnd = &m_wndView;
+ }
+
+ if (OpenFileData* p = dynamic_cast<OpenFileData*>(pOMD)) {
+ engine_t engine = s.m_Formats.GetEngine(p->fns.GetHead());
+
+ CStringA ct = GetContentType(p->fns.GetHead());
+
+ if (ct == "video/x-ms-asf") {
+ // TODO: put something here to make the windows media source filter load later
+ } else if (ct == "audio/x-pn-realaudio"
+ || ct == "audio/x-pn-realaudio-plugin"
+ || ct == "audio/x-realaudio-secure"
+ || ct == "video/vnd.rn-realvideo-secure"
+ || ct == "application/vnd.rn-realmedia"
+ || ct.Find("vnd.rn-") >= 0
+ || ct.Find("realaudio") >= 0
+ || ct.Find("realvideo") >= 0) {
+ engine = RealMedia;
+ } else if (ct == "application/x-shockwave-flash") {
+ engine = ShockWave;
+ } else if (ct == "video/quicktime"
+ || ct == "application/x-quicktimeplayer") {
+ engine = QuickTime;
+ }
+
+ HRESULT hr = E_FAIL;
+ CComPtr<IUnknown> pUnk;
+
+ if (engine == RealMedia) {
+ // TODO : see why Real SDK crash here ...
+ //if (!IsRealEngineCompatible(p->fns.GetHead()))
+ // throw ResStr(IDS_REALVIDEO_INCOMPATIBLE);
+
+ pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew DSObjects::CRealMediaGraph(m_pVideoWnd->m_hWnd, hr);
+ if (!pUnk) {
+ throw(UINT)IDS_AG_OUT_OF_MEMORY;
+ }
+
+ if (SUCCEEDED(hr)) {
+ pGB = CComQIPtr<IGraphBuilder>(pUnk);
+ if (pGB) {
+ m_fRealMediaGraph = true;
+ }
+ }
+ } else if (engine == ShockWave) {
+ pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew DSObjects::CShockwaveGraph(m_pVideoWnd->m_hWnd, hr);
+ if (!pUnk) {
+ throw(UINT)IDS_AG_OUT_OF_MEMORY;
+ }
+
+ if (SUCCEEDED(hr)) {
+ pGB = CComQIPtr<IGraphBuilder>(pUnk);
+ }
+ if (FAILED(hr) || !pGB) {
+ throw(UINT)IDS_MAINFRM_77;
+ }
+ m_fShockwaveGraph = true;
+ } else if (engine == QuickTime) {
+#ifdef _WIN64 // TODOX64
+ //MessageBox (ResStr(IDS_MAINFRM_78), _T(""), MB_OK);
+#else
+ pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew DSObjects::CQuicktimeGraph(m_pVideoWnd->m_hWnd, hr);
+ if (!pUnk) {
+ throw(UINT)IDS_AG_OUT_OF_MEMORY;
+ }
+
+ if (SUCCEEDED(hr)) {
+ pGB = CComQIPtr<IGraphBuilder>(pUnk);
+ if (pGB) {
+ m_fQuicktimeGraph = true;
+ }
+ }
+#endif
+ }
+
+ m_fCustomGraph = m_fRealMediaGraph || m_fShockwaveGraph || m_fQuicktimeGraph;
+
+ if (!m_fCustomGraph) {
+ pGB = DNew CFGManagerPlayer(_T("CFGManagerPlayer"), NULL, m_pVideoWnd->m_hWnd);
+ }
+ } else if (OpenDVDData* p = dynamic_cast<OpenDVDData*>(pOMD)) {
+ pGB = DNew CFGManagerDVD(_T("CFGManagerDVD"), NULL, m_pVideoWnd->m_hWnd);
+ } else if (OpenDeviceData* p = dynamic_cast<OpenDeviceData*>(pOMD)) {
+ if (s.iDefaultCaptureDevice == 1) {
+ pGB = DNew CFGManagerBDA(_T("CFGManagerBDA"), NULL, m_pVideoWnd->m_hWnd);
+ } else {
+ pGB = DNew CFGManagerCapture(_T("CFGManagerCapture"), NULL, m_pVideoWnd->m_hWnd);
+ }
+ }
- if (!pGB) {
- throw (UINT)IDS_MAINFRM_80;
- }
+ if (!pGB) {
+ throw(UINT)IDS_MAINFRM_80;
+ }
- pGB->AddToROT();
+ pGB->AddToROT();
- pMC = pGB;
- pME = pGB;
- pMS = pGB; // general
- pVW = pGB;
- pBV = pGB; // video
- pBA = pGB; // audio
- pFS = pGB;
+ pMC = pGB;
+ pME = pGB;
+ pMS = pGB; // general
+ pVW = pGB;
+ pBV = pGB; // video
+ pBA = pGB; // audio
+ pFS = pGB;
- if (!(pMC && pME && pMS)
- || !(pVW && pBV)
- || !(pBA)) {
- throw (UINT)IDS_GRAPH_INTERFACES_ERROR;
- }
+ if (!(pMC && pME && pMS)
+ || !(pVW && pBV)
+ || !(pBA)) {
+ throw(UINT)IDS_GRAPH_INTERFACES_ERROR;
+ }
- if (FAILED(pME->SetNotifyWindow((OAHWND)m_hWnd, WM_GRAPHNOTIFY, 0))) {
- throw (UINT)IDS_GRAPH_TARGET_WND_ERROR;
- }
+ if (FAILED(pME->SetNotifyWindow((OAHWND)m_hWnd, WM_GRAPHNOTIFY, 0))) {
+ throw(UINT)IDS_GRAPH_TARGET_WND_ERROR;
+ }
- m_pProv = (IUnknown*)DNew CKeyProvider();
+ m_pProv = (IUnknown*)DNew CKeyProvider();
- if (CComQIPtr<IObjectWithSite> pObjectWithSite = pGB) {
- pObjectWithSite->SetSite(m_pProv);
- }
+ if (CComQIPtr<IObjectWithSite> pObjectWithSite = pGB) {
+ pObjectWithSite->SetSite(m_pProv);
+ }
- m_pCB = DNew CDSMChapterBag(NULL, NULL);
+ m_pCB = DNew CDSMChapterBag(NULL, NULL);
}
-CWnd *CMainFrame::GetModalParent()
+CWnd* CMainFrame::GetModalParent()
{
- AppSettings& s = AfxGetAppSettings();
- CWnd *pParentWnd = this;
- if (m_pFullscreenWnd->IsWindow() && s.m_RenderersSettings.m_RenderSettings.iVMR9FullscreenGUISupport) {
- pParentWnd = m_pFullscreenWnd;
- }
- return pParentWnd;
+ AppSettings& s = AfxGetAppSettings();
+ CWnd* pParentWnd = this;
+ if (m_pFullscreenWnd->IsWindow() && s.m_RenderersSettings.m_RenderSettings.iVMR9FullscreenGUISupport) {
+ pParentWnd = m_pFullscreenWnd;
+ }
+ return pParentWnd;
}
void CMainFrame::OpenFile(OpenFileData* pOFD)
{
- if (pOFD->fns.IsEmpty()) {
- throw (UINT)IDS_MAINFRM_81;
- }
-
- AppSettings& s = AfxGetAppSettings();
-
- bool fFirst = true;
-
- POSITION pos = pOFD->fns.GetHeadPosition();
- while (pos) {
- CString fn = pOFD->fns.GetNext(pos);
-
- fn.Trim();
- if (fn.IsEmpty() && !fFirst) {
- break;
- }
-
- HRESULT hr = pGB->RenderFile(CStringW(fn), NULL);
-
- if (s.fKeepHistory && s.fRememberFilePos && !s.NewFile(fn)) {
- REFERENCE_TIME rtPos = s.CurrentFilePosition()->llPosition;
- if (pMS) {
- pMS->SetPositions (&rtPos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
- }
- }
- QueryPerformanceCounter(&m_LastSaveTime);
-
- if (FAILED(hr)) {
- if (fFirst) {
- if (s.fReportFailedPins) {
- CComQIPtr<IGraphBuilderDeadEnd> pGBDE = pGB;
- if (pGBDE && pGBDE->GetCount()) {
- CMediaTypesDlg(pGBDE, GetModalParent()).DoModal();
- }
- }
-
- UINT err;
-
- switch (hr) {
- case E_ABORT:
- err = IDS_MAINFRM_82;
- break;
- case E_FAIL:
- case E_POINTER:
- default:
- err = IDS_MAINFRM_83;
- break;
- case E_INVALIDARG:
- err = IDS_MAINFRM_84;
- break;
- case E_OUTOFMEMORY:
- err = IDS_AG_OUT_OF_MEMORY;
- break;
- case VFW_E_CANNOT_CONNECT:
- err = IDS_MAINFRM_86;
- break;
- case VFW_E_CANNOT_LOAD_SOURCE_FILTER:
- err = IDS_MAINFRM_87;
- break;
- case VFW_E_CANNOT_RENDER:
- err = IDS_MAINFRM_88;
- break;
- case VFW_E_INVALID_FILE_FORMAT:
- err = IDS_MAINFRM_89;
- break;
- case VFW_E_NOT_FOUND:
- err = IDS_MAINFRM_90;
- break;
- case VFW_E_UNKNOWN_FILE_TYPE:
- err = IDS_MAINFRM_91;
- break;
- case VFW_E_UNSUPPORTED_STREAM:
- err = IDS_MAINFRM_92;
- break;
- }
-
- throw err;
- }
- }
-
- if (s.fKeepHistory) {
- CRecentFileList* pMRU = fFirst ? &s.MRU : &s.MRUDub;
- pMRU->ReadList();
- pMRU->Add(fn);
- pMRU->WriteList();
- SHAddToRecentDocs(SHARD_PATH, fn);
- }
-
- if (fFirst) {
- pOFD->title = fn;
- }
-
- fFirst = false;
-
- if (m_fCustomGraph) {
- break;
- }
- }
-
- if (s.fReportFailedPins) {
- CComQIPtr<IGraphBuilderDeadEnd> pGBDE = pGB;
- if (pGBDE && pGBDE->GetCount()) {
- CMediaTypesDlg(pGBDE, GetModalParent()).DoModal();
- }
- }
-
- if (!(pAMOP = pGB)) {
- BeginEnumFilters(pGB, pEF, pBF)
- if (pAMOP = pBF) {
- break;
- }
- EndEnumFilters;
- }
-
- if (FindFilter(__uuidof(CShoutcastSource), pGB)) {
- m_fUpdateInfoBar = true;
- }
-
- SetupChapters();
-
- CComQIPtr<IKeyFrameInfo> pKFI;
- BeginEnumFilters(pGB, pEF, pBF)
- if (pKFI = pBF) {
- break;
- }
- EndEnumFilters;
- UINT nKFs = 0;
- if (pKFI && S_OK == pKFI->GetKeyFrameCount(nKFs) && nKFs > 0) {
- UINT k = nKFs;
- if (!m_kfs.SetCount(k) || S_OK != pKFI->GetKeyFrames(&TIME_FORMAT_MEDIA_TIME, m_kfs.GetData(), k) || k != nKFs) {
- m_kfs.RemoveAll();
- }
- }
-
- SetPlaybackMode(PM_FILE);
+ if (pOFD->fns.IsEmpty()) {
+ throw(UINT)IDS_MAINFRM_81;
+ }
+
+ AppSettings& s = AfxGetAppSettings();
+
+ bool fFirst = true;
+
+ POSITION pos = pOFD->fns.GetHeadPosition();
+ while (pos) {
+ CString fn = pOFD->fns.GetNext(pos);
+
+ fn.Trim();
+ if (fn.IsEmpty() && !fFirst) {
+ break;
+ }
+
+ HRESULT hr = pGB->RenderFile(CStringW(fn), NULL);
+
+ if (s.fKeepHistory && s.fRememberFilePos && !s.NewFile(fn)) {
+ REFERENCE_TIME rtPos = s.CurrentFilePosition()->llPosition;
+ if (pMS) {
+ pMS->SetPositions(&rtPos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
+ }
+ }
+ QueryPerformanceCounter(&m_LastSaveTime);
+
+ if (FAILED(hr)) {
+ if (fFirst) {
+ if (s.fReportFailedPins) {
+ CComQIPtr<IGraphBuilderDeadEnd> pGBDE = pGB;
+ if (pGBDE && pGBDE->GetCount()) {
+ CMediaTypesDlg(pGBDE, GetModalParent()).DoModal();
+ }
+ }
+
+ UINT err;
+
+ switch (hr) {
+ case E_ABORT:
+ err = IDS_MAINFRM_82;
+ break;
+ case E_FAIL:
+ case E_POINTER:
+ default:
+ err = IDS_MAINFRM_83;
+ break;
+ case E_INVALIDARG:
+ err = IDS_MAINFRM_84;
+ break;
+ case E_OUTOFMEMORY:
+ err = IDS_AG_OUT_OF_MEMORY;
+ break;
+ case VFW_E_CANNOT_CONNECT:
+ err = IDS_MAINFRM_86;
+ break;
+ case VFW_E_CANNOT_LOAD_SOURCE_FILTER:
+ err = IDS_MAINFRM_87;
+ break;
+ case VFW_E_CANNOT_RENDER:
+ err = IDS_MAINFRM_88;
+ break;
+ case VFW_E_INVALID_FILE_FORMAT:
+ err = IDS_MAINFRM_89;
+ break;
+ case VFW_E_NOT_FOUND:
+ err = IDS_MAINFRM_90;
+ break;
+ case VFW_E_UNKNOWN_FILE_TYPE:
+ err = IDS_MAINFRM_91;
+ break;
+ case VFW_E_UNSUPPORTED_STREAM:
+ err = IDS_MAINFRM_92;
+ break;
+ }
+
+ throw err;
+ }
+ }
+
+ if (s.fKeepHistory) {
+ CRecentFileList* pMRU = fFirst ? &s.MRU : &s.MRUDub;
+ pMRU->ReadList();
+ pMRU->Add(fn);
+ pMRU->WriteList();
+ SHAddToRecentDocs(SHARD_PATH, fn);
+ }
+
+ if (fFirst) {
+ pOFD->title = fn;
+ }
+
+ fFirst = false;
+
+ if (m_fCustomGraph) {
+ break;
+ }
+ }
+
+ if (s.fReportFailedPins) {
+ CComQIPtr<IGraphBuilderDeadEnd> pGBDE = pGB;
+ if (pGBDE && pGBDE->GetCount()) {
+ CMediaTypesDlg(pGBDE, GetModalParent()).DoModal();
+ }
+ }
+
+ if (!(pAMOP = pGB)) {
+ BeginEnumFilters(pGB, pEF, pBF)
+ if (pAMOP = pBF) {
+ break;
+ }
+ EndEnumFilters;
+ }
+
+ if (FindFilter(__uuidof(CShoutcastSource), pGB)) {
+ m_fUpdateInfoBar = true;
+ }
+
+ SetupChapters();
+
+ CComQIPtr<IKeyFrameInfo> pKFI;
+ BeginEnumFilters(pGB, pEF, pBF)
+ if (pKFI = pBF) {
+ break;
+ }
+ EndEnumFilters;
+ UINT nKFs = 0;
+ if (pKFI && S_OK == pKFI->GetKeyFrameCount(nKFs) && nKFs > 0) {
+ UINT k = nKFs;
+ if (!m_kfs.SetCount(k) || S_OK != pKFI->GetKeyFrames(&TIME_FORMAT_MEDIA_TIME, m_kfs.GetData(), k) || k != nKFs) {
+ m_kfs.RemoveAll();
+ }
+ }
+
+ SetPlaybackMode(PM_FILE);
}
void CMainFrame::SetupChapters()
{
- ASSERT(m_pCB);
-
- m_pCB->ChapRemoveAll();
-
- CInterfaceList<IBaseFilter> pBFs;
- BeginEnumFilters(pGB, pEF, pBF)
- pBFs.AddTail(pBF);
- EndEnumFilters;
-
- POSITION pos;
-
- pos = pBFs.GetHeadPosition();
- while (pos && !m_pCB->ChapGetCount()) {
- IBaseFilter* pBF = pBFs.GetNext(pos);
-
- CComQIPtr<IDSMChapterBag> pCB = pBF;
- if (!pCB) {
- continue;
- }
-
- for (DWORD i = 0, cnt = pCB->ChapGetCount(); i < cnt; i++) {
- REFERENCE_TIME rt;
- CComBSTR name;
- if (SUCCEEDED(pCB->ChapGet(i, &rt, &name))) {
- m_pCB->ChapAppend(rt, name);
- }
- }
- }
-
- pos = pBFs.GetHeadPosition();
- while (pos && !m_pCB->ChapGetCount()) {
- IBaseFilter* pBF = pBFs.GetNext(pos);
-
- CComQIPtr<IChapterInfo> pCI = pBF;
- if (!pCI) {
- continue;
- }
-
- CHAR iso6391[3];
- ::GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, iso6391, 3);
- CStringA iso6392 = ISO6391To6392(iso6391);
- if (iso6392.GetLength() < 3) {
- iso6392 = "eng";
- }
-
- UINT cnt = pCI->GetChapterCount(CHAPTER_ROOT_ID);
- for (UINT i = 1; i <= cnt; i++) {
- UINT cid = pCI->GetChapterId(CHAPTER_ROOT_ID, i);
-
- ChapterElement ce;
- if (pCI->GetChapterInfo(cid, &ce)) {
- char pl[3] = {iso6392[0], iso6392[1], iso6392[2]};
- char cc[] = " ";
- CComBSTR name;
- name.Attach(pCI->GetChapterStringInfo(cid, pl, cc));
- m_pCB->ChapAppend(ce.rtStart, name);
- }
- }
- }
-
- pos = pBFs.GetHeadPosition();
- while (pos && !m_pCB->ChapGetCount()) {
- IBaseFilter* pBF = pBFs.GetNext(pos);
-
- CComQIPtr<IAMExtendedSeeking, &IID_IAMExtendedSeeking> pES = pBF;
- if (!pES) {
- continue;
- }
-
- long MarkerCount = 0;
- if (SUCCEEDED(pES->get_MarkerCount(&MarkerCount))) {
- for (long i = 1; i <= MarkerCount; i++) {
- double MarkerTime = 0;
- if (SUCCEEDED(pES->GetMarkerTime(i, &MarkerTime))) {
- CStringW name;
- name.Format(L"Chapter %d", i);
-
- CComBSTR bstr;
- if (S_OK == pES->GetMarkerName(i, &bstr)) {
- name = bstr;
- }
-
- m_pCB->ChapAppend(REFERENCE_TIME(MarkerTime*10000000), name);
- }
- }
- }
- }
-
- pos = pBFs.GetHeadPosition();
- while (pos && !m_pCB->ChapGetCount()) {
- IBaseFilter* pBF = pBFs.GetNext(pos);
-
- if (GetCLSID(pBF) != CLSID_OggSplitter) {
- continue;
- }
-
- BeginEnumPins(pBF, pEP, pPin) {
- if (m_pCB->ChapGetCount()) {
- break;
- }
-
- if (CComQIPtr<IPropertyBag> pPB = pPin) {
- for (int i = 1; ; i++) {
- CStringW str;
- CComVariant var;
-
- var.Clear();
- str.Format(L"CHAPTER%02d", i);
- if (S_OK != pPB->Read(str, &var, NULL)) {
- break;
- }
-
- int h, m, s, ms;
- WCHAR wc;
- if (7 != swscanf_s(CStringW(var), L"%d%c%d%c%d%c%d", &h, &wc, sizeof(WCHAR), &m, &wc, sizeof(WCHAR), &s, &wc, sizeof(WCHAR), &ms)) {
- break;
- }
-
- CStringW name;
- name.Format(L"Chapter %d", i);
- var.Clear();
- str += L"NAME";
- if (S_OK == pPB->Read(str, &var, NULL)) {
- name = var;
- }
-
- m_pCB->ChapAppend(10000i64*(((h*60 + m)*60 + s)*1000 + ms), name);
- }
- }
- }
- EndEnumPins;
- }
-
- m_pCB->ChapSort();
+ ASSERT(m_pCB);
+
+ m_pCB->ChapRemoveAll();
+
+ CInterfaceList<IBaseFilter> pBFs;
+ BeginEnumFilters(pGB, pEF, pBF)
+ pBFs.AddTail(pBF);
+ EndEnumFilters;
+
+ POSITION pos;
+
+ pos = pBFs.GetHeadPosition();
+ while (pos && !m_pCB->ChapGetCount()) {
+ IBaseFilter* pBF = pBFs.GetNext(pos);
+
+ CComQIPtr<IDSMChapterBag> pCB = pBF;
+ if (!pCB) {
+ continue;
+ }
+
+ for (DWORD i = 0, cnt = pCB->ChapGetCount(); i < cnt; i++) {
+ REFERENCE_TIME rt;
+ CComBSTR name;
+ if (SUCCEEDED(pCB->ChapGet(i, &rt, &name))) {
+ m_pCB->ChapAppend(rt, name);
+ }
+ }
+ }
+
+ pos = pBFs.GetHeadPosition();
+ while (pos && !m_pCB->ChapGetCount()) {
+ IBaseFilter* pBF = pBFs.GetNext(pos);
+
+ CComQIPtr<IChapterInfo> pCI = pBF;
+ if (!pCI) {
+ continue;
+ }
+
+ CHAR iso6391[3];
+ ::GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, iso6391, 3);
+ CStringA iso6392 = ISO6391To6392(iso6391);
+ if (iso6392.GetLength() < 3) {
+ iso6392 = "eng";
+ }
+
+ UINT cnt = pCI->GetChapterCount(CHAPTER_ROOT_ID);
+ for (UINT i = 1; i <= cnt; i++) {
+ UINT cid = pCI->GetChapterId(CHAPTER_ROOT_ID, i);
+
+ ChapterElement ce;
+ if (pCI->GetChapterInfo(cid, &ce)) {
+ char pl[3] = {iso6392[0], iso6392[1], iso6392[2]};
+ char cc[] = " ";
+ CComBSTR name;
+ name.Attach(pCI->GetChapterStringInfo(cid, pl, cc));
+ m_pCB->ChapAppend(ce.rtStart, name);
+ }
+ }
+ }
+
+ pos = pBFs.GetHeadPosition();
+ while (pos && !m_pCB->ChapGetCount()) {
+ IBaseFilter* pBF = pBFs.GetNext(pos);
+
+ CComQIPtr<IAMExtendedSeeking, &IID_IAMExtendedSeeking> pES = pBF;
+ if (!pES) {
+ continue;
+ }
+
+ long MarkerCount = 0;
+ if (SUCCEEDED(pES->get_MarkerCount(&MarkerCount))) {
+ for (long i = 1; i <= MarkerCount; i++) {
+ double MarkerTime = 0;
+ if (SUCCEEDED(pES->GetMarkerTime(i, &MarkerTime))) {
+ CStringW name;
+ name.Format(L"Chapter %d", i);
+
+ CComBSTR bstr;
+ if (S_OK == pES->GetMarkerName(i, &bstr)) {
+ name = bstr;
+ }
+
+ m_pCB->ChapAppend(REFERENCE_TIME(MarkerTime * 10000000), name);
+ }
+ }
+ }
+ }
+
+ pos = pBFs.GetHeadPosition();
+ while (pos && !m_pCB->ChapGetCount()) {
+ IBaseFilter* pBF = pBFs.GetNext(pos);
+
+ if (GetCLSID(pBF) != CLSID_OggSplitter) {
+ continue;
+ }
+
+ BeginEnumPins(pBF, pEP, pPin) {
+ if (m_pCB->ChapGetCount()) {
+ break;
+ }
+
+ if (CComQIPtr<IPropertyBag> pPB = pPin) {
+ for (int i = 1; ; i++) {
+ CStringW str;
+ CComVariant var;
+
+ var.Clear();
+ str.Format(L"CHAPTER%02d", i);
+ if (S_OK != pPB->Read(str, &var, NULL)) {
+ break;
+ }
+
+ int h, m, s, ms;
+ WCHAR wc;
+ if (7 != swscanf_s(CStringW(var), L"%d%c%d%c%d%c%d", &h, &wc, sizeof(WCHAR), &m, &wc, sizeof(WCHAR), &s, &wc, sizeof(WCHAR), &ms)) {
+ break;
+ }
+
+ CStringW name;
+ name.Format(L"Chapter %d", i);
+ var.Clear();
+ str += L"NAME";
+ if (S_OK == pPB->Read(str, &var, NULL)) {
+ name = var;
+ }
+
+ m_pCB->ChapAppend(10000i64 * (((h * 60 + m) * 60 + s) * 1000 + ms), name);
+ }
+ }
+ }
+ EndEnumPins;
+ }
+
+ m_pCB->ChapSort();
}
void CMainFrame::OpenDVD(OpenDVDData* pODD)
{
- HRESULT hr = pGB->RenderFile(CStringW(pODD->path), NULL);
-
- AppSettings& s = AfxGetAppSettings();
-
- if (s.fReportFailedPins) {
- CComQIPtr<IGraphBuilderDeadEnd> pGBDE = pGB;
- if (pGBDE && pGBDE->GetCount()) {
- CMediaTypesDlg(pGBDE, GetModalParent()).DoModal();
- }
- }
-
- BeginEnumFilters(pGB, pEF, pBF) {
- if ((pDVDC = pBF) && (pDVDI = pBF)) {
- break;
- }
- }
- EndEnumFilters;
-
- if (hr == E_INVALIDARG) {
- throw (UINT)IDS_MAINFRM_93;
- } else if (hr == VFW_E_CANNOT_RENDER) {
- throw (UINT)IDS_DVD_NAV_ALL_PINS_ERROR;
- } else if (hr == VFW_S_PARTIAL_RENDER) {
- throw (UINT)IDS_DVD_NAV_SOME_PINS_ERROR;
- } else if (hr == E_NOINTERFACE || !pDVDC || !pDVDI) {
- throw (UINT)IDS_DVD_INTERFACES_ERROR;
- } else if (hr == VFW_E_CANNOT_LOAD_SOURCE_FILTER) {
- throw (UINT)IDS_MAINFRM_94;
- } else if (FAILED(hr)) {
- throw (UINT)IDS_AG_FAILED;
- }
-
- WCHAR buff[_MAX_PATH];
- ULONG len = 0;
- if (SUCCEEDED(hr = pDVDI->GetDVDDirectory(buff, _countof(buff), &len))) {
- pODD->title = CString(CStringW(buff));
- }
-
- // TODO: resetdvd
- pDVDC->SetOption(DVD_ResetOnStop, FALSE);
- pDVDC->SetOption(DVD_HMSF_TimeCodeEvents, TRUE);
-
- if (s.idMenuLang) {
- pDVDC->SelectDefaultMenuLanguage(s.idMenuLang);
- }
- if (s.idAudioLang) {
- pDVDC->SelectDefaultAudioLanguage(s.idAudioLang, DVD_AUD_EXT_NotSpecified);
- }
- if (s.idSubtitlesLang) {
- pDVDC->SelectDefaultSubpictureLanguage(s.idSubtitlesLang, DVD_SP_EXT_NotSpecified);
- }
-
- m_iDVDDomain = DVD_DOMAIN_Stop;
-
- SetPlaybackMode(PM_DVD);
+ HRESULT hr = pGB->RenderFile(CStringW(pODD->path), NULL);
+
+ AppSettings& s = AfxGetAppSettings();
+
+ if (s.fReportFailedPins) {
+ CComQIPtr<IGraphBuilderDeadEnd> pGBDE = pGB;
+ if (pGBDE && pGBDE->GetCount()) {
+ CMediaTypesDlg(pGBDE, GetModalParent()).DoModal();
+ }
+ }
+
+ BeginEnumFilters(pGB, pEF, pBF) {
+ if ((pDVDC = pBF) && (pDVDI = pBF)) {
+ break;
+ }
+ }
+ EndEnumFilters;
+
+ if (hr == E_INVALIDARG) {
+ throw(UINT)IDS_MAINFRM_93;
+ } else if (hr == VFW_E_CANNOT_RENDER) {
+ throw(UINT)IDS_DVD_NAV_ALL_PINS_ERROR;
+ } else if (hr == VFW_S_PARTIAL_RENDER) {
+ throw(UINT)IDS_DVD_NAV_SOME_PINS_ERROR;
+ } else if (hr == E_NOINTERFACE || !pDVDC || !pDVDI) {
+ throw(UINT)IDS_DVD_INTERFACES_ERROR;
+ } else if (hr == VFW_E_CANNOT_LOAD_SOURCE_FILTER) {
+ throw(UINT)IDS_MAINFRM_94;
+ } else if (FAILED(hr)) {
+ throw(UINT)IDS_AG_FAILED;
+ }
+
+ WCHAR buff[_MAX_PATH];
+ ULONG len = 0;
+ if (SUCCEEDED(hr = pDVDI->GetDVDDirectory(buff, _countof(buff), &len))) {
+ pODD->title = CString(CStringW(buff));
+ }
+
+ // TODO: resetdvd
+ pDVDC->SetOption(DVD_ResetOnStop, FALSE);
+ pDVDC->SetOption(DVD_HMSF_TimeCodeEvents, TRUE);
+
+ if (s.idMenuLang) {
+ pDVDC->SelectDefaultMenuLanguage(s.idMenuLang);
+ }
+ if (s.idAudioLang) {
+ pDVDC->SelectDefaultAudioLanguage(s.idAudioLang, DVD_AUD_EXT_NotSpecified);
+ }
+ if (s.idSubtitlesLang) {
+ pDVDC->SelectDefaultSubpictureLanguage(s.idSubtitlesLang, DVD_SP_EXT_NotSpecified);
+ }
+
+ m_iDVDDomain = DVD_DOMAIN_Stop;
+
+ SetPlaybackMode(PM_DVD);
}
HRESULT CMainFrame::OpenBDAGraph()
{
- HRESULT hr = pGB->RenderFile (L"",L"");
- if (!FAILED(hr)) {
- AddTextPassThruFilter();
- SetPlaybackMode(PM_CAPTURE);
- }
- return hr;
+ HRESULT hr = pGB->RenderFile(L"", L"");
+ if (!FAILED(hr)) {
+ AddTextPassThruFilter();
+ SetPlaybackMode(PM_CAPTURE);
+ }
+ return hr;
}
void CMainFrame::OpenCapture(OpenDeviceData* pODD)
{
- CStringW vidfrname, audfrname;
- CComPtr<IBaseFilter> pVidCapTmp, pAudCapTmp;
-
- m_VidDispName = pODD->DisplayName[0];
-
- if (!m_VidDispName.IsEmpty()) {
- if (!CreateFilter(m_VidDispName, &pVidCapTmp, vidfrname)) {
- throw (UINT)IDS_MAINFRM_96;
- }
- }
-
- m_AudDispName = pODD->DisplayName[1];
-
- if (!m_AudDispName.IsEmpty()) {
- if (!CreateFilter(m_AudDispName, &pAudCapTmp, audfrname)) {
- throw (UINT)IDS_MAINFRM_96;
- }
- }
-
- if (!pVidCapTmp && !pAudCapTmp) {
- throw (UINT)IDS_MAINFRM_98;
- }
-
- pCGB = NULL;
- pVidCap = NULL;
- pAudCap = NULL;
-
- if (FAILED(pCGB.CoCreateInstance(CLSID_CaptureGraphBuilder2))) {
- throw (UINT)IDS_MAINFRM_99;
- }
-
- HRESULT hr;
-
- pCGB->SetFiltergraph(pGB);
-
- if (pVidCapTmp) {
- if (FAILED(hr = pGB->AddFilter(pVidCapTmp, vidfrname))) {
- throw (UINT)IDS_CAPTURE_ERROR_VID_FILTER;
- }
-
- pVidCap = pVidCapTmp;
-
- if (!pAudCapTmp) {
- if (FAILED(pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Interleaved, pVidCap, IID_IAMStreamConfig, (void **)&pAMVSCCap))
- && FAILED(pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pVidCap, IID_IAMStreamConfig, (void **)&pAMVSCCap))) {
- TRACE(_T("Warning: No IAMStreamConfig interface for vidcap capture"));
- }
-
- if (FAILED(pCGB->FindInterface(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Interleaved, pVidCap, IID_IAMStreamConfig, (void **)&pAMVSCPrev))
- && FAILED(pCGB->FindInterface(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video, pVidCap, IID_IAMStreamConfig, (void **)&pAMVSCPrev))) {
- TRACE(_T("Warning: No IAMStreamConfig interface for vidcap capture"));
- }
-
- if (FAILED(pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Audio, pVidCap, IID_IAMStreamConfig, (void **)&pAMASC))
- && FAILED(pCGB->FindInterface(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Audio, pVidCap, IID_IAMStreamConfig, (void **)&pAMASC))) {
- TRACE(_T("Warning: No IAMStreamConfig interface for vidcap"));
- } else {
- pAudCap = pVidCap;
- }
- } else {
- if (FAILED(pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pVidCap, IID_IAMStreamConfig, (void **)&pAMVSCCap))) {
- TRACE(_T("Warning: No IAMStreamConfig interface for vidcap capture"));
- }
-
- if (FAILED(pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pVidCap, IID_IAMStreamConfig, (void **)&pAMVSCPrev))) {
- TRACE(_T("Warning: No IAMStreamConfig interface for vidcap capture"));
- }
- }
-
- if (FAILED(pCGB->FindInterface(&LOOK_UPSTREAM_ONLY, NULL, pVidCap, IID_IAMCrossbar, (void**)&pAMXBar))) {
- TRACE(_T("Warning: No IAMCrossbar interface was found\n"));
- }
-
- if (FAILED(pCGB->FindInterface(&LOOK_UPSTREAM_ONLY, NULL, pVidCap, IID_IAMTVTuner, (void**)&pAMTuner))) {
- TRACE(_T("Warning: No IAMTVTuner interface was found\n"));
- }
- /*
- if (pAMVSCCap)
- {
- //DumpStreamConfig(_T("c:\\mpclog.txt"), pAMVSCCap);
- CComQIPtr<IAMVfwCaptureDialogs> pVfwCD = pVidCap;
- if (!pAMXBar && pVfwCD)
- {
- m_wndCaptureBar.m_capdlg.SetupVideoControls(viddispname, pAMVSCCap, pVfwCD);
- }
- else
- {
- m_wndCaptureBar.m_capdlg.SetupVideoControls(viddispname, pAMVSCCap, pAMXBar, pAMTuner);
- }
- }
- */
- // TODO: init pAMXBar
-
- if (pAMTuner) { // load saved channel
- pAMTuner->put_CountryCode(AfxGetApp()->GetProfileInt(_T("Capture"), _T("Country"), 1));
-
- int vchannel = pODD->vchannel;
- if (vchannel < 0) {
- vchannel = AfxGetApp()->GetProfileInt(_T("Capture\\") + CString(m_VidDispName), _T("Channel"), -1);
- }
- if (vchannel >= 0) {
- OAFilterState fs = State_Stopped;
- pMC->GetState(0, &fs);
- if (fs == State_Running) {
- pMC->Pause();
- }
- pAMTuner->put_Channel(vchannel, AMTUNER_SUBCHAN_DEFAULT, AMTUNER_SUBCHAN_DEFAULT);
- if (fs == State_Running) {
- pMC->Run();
- }
- }
- }
- }
-
- if (pAudCapTmp) {
- if (FAILED(hr = pGB->AddFilter(pAudCapTmp, CStringW(audfrname)))) {
- throw (UINT)IDS_CAPTURE_ERROR_AUD_FILTER;
- }
-
- pAudCap = pAudCapTmp;
-
- if (FAILED(pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Audio, pAudCap, IID_IAMStreamConfig, (void **)&pAMASC))
- && FAILED(pCGB->FindInterface(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Audio, pAudCap, IID_IAMStreamConfig, (void **)&pAMASC))) {
- TRACE(_T("Warning: No IAMStreamConfig interface for vidcap"));
- }
- /*
- CInterfaceArray<IAMAudioInputMixer> pAMAIM;
-
- BeginEnumPins(pAudCap, pEP, pPin)
- {
- PIN_DIRECTION dir;
- if (FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_INPUT)
- continue;
-
- if (CComQIPtr<IAMAudioInputMixer> pAIM = pPin)
- pAMAIM.Add(pAIM);
- }
- EndEnumPins;
-
- if (pAMASC)
- {
- m_wndCaptureBar.m_capdlg.SetupAudioControls(auddispname, pAMASC, pAMAIM);
- }
- */
- }
-
- if (!(pVidCap || pAudCap)) {
- throw (UINT)IDS_MAINFRM_108;
- }
-
- pODD->title.LoadString(IDS_CAPTURE_LIVE);
-
- SetPlaybackMode(PM_CAPTURE);
+ CStringW vidfrname, audfrname;
+ CComPtr<IBaseFilter> pVidCapTmp, pAudCapTmp;
+
+ m_VidDispName = pODD->DisplayName[0];
+
+ if (!m_VidDispName.IsEmpty()) {
+ if (!CreateFilter(m_VidDispName, &pVidCapTmp, vidfrname)) {
+ throw(UINT)IDS_MAINFRM_96;
+ }
+ }
+
+ m_AudDispName = pODD->DisplayName[1];
+
+ if (!m_AudDispName.IsEmpty()) {
+ if (!CreateFilter(m_AudDispName, &pAudCapTmp, audfrname)) {
+ throw(UINT)IDS_MAINFRM_96;
+ }
+ }
+
+ if (!pVidCapTmp && !pAudCapTmp) {
+ throw(UINT)IDS_MAINFRM_98;
+ }
+
+ pCGB = NULL;
+ pVidCap = NULL;
+ pAudCap = NULL;
+
+ if (FAILED(pCGB.CoCreateInstance(CLSID_CaptureGraphBuilder2))) {
+ throw(UINT)IDS_MAINFRM_99;
+ }
+
+ HRESULT hr;
+
+ pCGB->SetFiltergraph(pGB);
+
+ if (pVidCapTmp) {
+ if (FAILED(hr = pGB->AddFilter(pVidCapTmp, vidfrname))) {
+ throw(UINT)IDS_CAPTURE_ERROR_VID_FILTER;
+ }
+
+ pVidCap = pVidCapTmp;
+
+ if (!pAudCapTmp) {
+ if (FAILED(pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Interleaved, pVidCap, IID_IAMStreamConfig, (void**)&pAMVSCCap))
+ && FAILED(pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pVidCap, IID_IAMStreamConfig, (void**)&pAMVSCCap))) {
+ TRACE(_T("Warning: No IAMStreamConfig interface for vidcap capture"));
+ }
+
+ if (FAILED(pCGB->FindInterface(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Interleaved, pVidCap, IID_IAMStreamConfig, (void**)&pAMVSCPrev))
+ && FAILED(pCGB->FindInterface(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video, pVidCap, IID_IAMStreamConfig, (void**)&pAMVSCPrev))) {
+ TRACE(_T("Warning: No IAMStreamConfig interface for vidcap capture"));
+ }
+
+ if (FAILED(pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Audio, pVidCap, IID_IAMStreamConfig, (void**)&pAMASC))
+ && FAILED(pCGB->FindInterface(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Audio, pVidCap, IID_IAMStreamConfig, (void**)&pAMASC))) {
+ TRACE(_T("Warning: No IAMStreamConfig interface for vidcap"));
+ } else {
+ pAudCap = pVidCap;
+ }
+ } else {
+ if (FAILED(pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pVidCap, IID_IAMStreamConfig, (void**)&pAMVSCCap))) {
+ TRACE(_T("Warning: No IAMStreamConfig interface for vidcap capture"));
+ }
+
+ if (FAILED(pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pVidCap, IID_IAMStreamConfig, (void**)&pAMVSCPrev))) {
+ TRACE(_T("Warning: No IAMStreamConfig interface for vidcap capture"));
+ }
+ }
+
+ if (FAILED(pCGB->FindInterface(&LOOK_UPSTREAM_ONLY, NULL, pVidCap, IID_IAMCrossbar, (void**)&pAMXBar))) {
+ TRACE(_T("Warning: No IAMCrossbar interface was found\n"));
+ }
+
+ if (FAILED(pCGB->FindInterface(&LOOK_UPSTREAM_ONLY, NULL, pVidCap, IID_IAMTVTuner, (void**)&pAMTuner))) {
+ TRACE(_T("Warning: No IAMTVTuner interface was found\n"));
+ }
+ /*
+ if (pAMVSCCap)
+ {
+ //DumpStreamConfig(_T("c:\\mpclog.txt"), pAMVSCCap);
+ CComQIPtr<IAMVfwCaptureDialogs> pVfwCD = pVidCap;
+ if (!pAMXBar && pVfwCD)
+ {
+ m_wndCaptureBar.m_capdlg.SetupVideoControls(viddispname, pAMVSCCap, pVfwCD);
+ }
+ else
+ {
+ m_wndCaptureBar.m_capdlg.SetupVideoControls(viddispname, pAMVSCCap, pAMXBar, pAMTuner);
+ }
+ }
+ */
+ // TODO: init pAMXBar
+
+ if (pAMTuner) { // load saved channel
+ pAMTuner->put_CountryCode(AfxGetApp()->GetProfileInt(_T("Capture"), _T("Country"), 1));
+
+ int vchannel = pODD->vchannel;
+ if (vchannel < 0) {
+ vchannel = AfxGetApp()->GetProfileInt(_T("Capture\\") + CString(m_VidDispName), _T("Channel"), -1);
+ }
+ if (vchannel >= 0) {
+ OAFilterState fs = State_Stopped;
+ pMC->GetState(0, &fs);
+ if (fs == State_Running) {
+ pMC->Pause();
+ }
+ pAMTuner->put_Channel(vchannel, AMTUNER_SUBCHAN_DEFAULT, AMTUNER_SUBCHAN_DEFAULT);
+ if (fs == State_Running) {
+ pMC->Run();
+ }
+ }
+ }
+ }
+
+ if (pAudCapTmp) {
+ if (FAILED(hr = pGB->AddFilter(pAudCapTmp, CStringW(audfrname)))) {
+ throw(UINT)IDS_CAPTURE_ERROR_AUD_FILTER;
+ }
+
+ pAudCap = pAudCapTmp;
+
+ if (FAILED(pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Audio, pAudCap, IID_IAMStreamConfig, (void**)&pAMASC))
+ && FAILED(pCGB->FindInterface(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Audio, pAudCap, IID_IAMStreamConfig, (void**)&pAMASC))) {
+ TRACE(_T("Warning: No IAMStreamConfig interface for vidcap"));
+ }
+ /*
+ CInterfaceArray<IAMAudioInputMixer> pAMAIM;
+
+ BeginEnumPins(pAudCap, pEP, pPin)
+ {
+ PIN_DIRECTION dir;
+ if (FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_INPUT)
+ continue;
+
+ if (CComQIPtr<IAMAudioInputMixer> pAIM = pPin)
+ pAMAIM.Add(pAIM);
+ }
+ EndEnumPins;
+
+ if (pAMASC)
+ {
+ m_wndCaptureBar.m_capdlg.SetupAudioControls(auddispname, pAMASC, pAMAIM);
+ }
+ */
+ }
+
+ if (!(pVidCap || pAudCap)) {
+ throw(UINT)IDS_MAINFRM_108;
+ }
+
+ pODD->title.LoadString(IDS_CAPTURE_LIVE);
+
+ SetPlaybackMode(PM_CAPTURE);
}
void CMainFrame::OpenCustomizeGraph()
{
- if (GetPlaybackMode() == PM_CAPTURE) {
- return;
- }
-
- CleanGraph();
-
- if (GetPlaybackMode() == PM_FILE) {
- if (m_pCAP && AfxGetAppSettings().fAutoloadSubtitles) {
- AddTextPassThruFilter();
- }
- }
-
- AppSettings& s = AfxGetAppSettings();
- CRenderersSettings& r = s.m_RenderersSettings;
- if (r.m_RenderSettings.bSynchronizeVideo && s.iDSVideoRendererType == VIDRNDT_DS_SYNC) {
- HRESULT hr;
- m_pRefClock = DNew CSyncClockFilter(NULL, &hr);
- CStringW name;
- name = L"SyncClock Filter";
- pGB->AddFilter(m_pRefClock, name);
-
- CComPtr<IReferenceClock> refClock;
- m_pRefClock->QueryInterface(IID_IReferenceClock, reinterpret_cast<void**>(&refClock));
- CComPtr<IMediaFilter> mediaFilter;
- pGB->QueryInterface(IID_IMediaFilter, reinterpret_cast<void**>(&mediaFilter));
- mediaFilter->SetSyncSource(refClock);
- mediaFilter = NULL;
- refClock = NULL;
-
- m_pRefClock->QueryInterface(IID_ISyncClock, reinterpret_cast<void**>(&m_pSyncClock));
-
- CComQIPtr<ISyncClockAdviser> pAdviser = m_pCAP;
- if (pAdviser) {
- pAdviser->AdviseSyncClock(m_pSyncClock);
- }
- }
-
- if (GetPlaybackMode() == PM_DVD) {
- BeginEnumFilters(pGB, pEF, pBF) {
- if (CComQIPtr<IDirectVobSub2> pDVS2 = pBF) {
- //pDVS2->AdviseSubClock(m_pSubClock = DNew CSubClock);
- //break;
-
- // TODO: test multiple dvobsub instances with one clock
- if (!m_pSubClock) {
- m_pSubClock = DNew CSubClock;
- }
- pDVS2->AdviseSubClock(m_pSubClock);
- }
- }
- EndEnumFilters;
- }
-
- BeginEnumFilters(pGB, pEF, pBF) {
- if (GetCLSID(pBF) == CLSID_OggSplitter) {
- if (CComQIPtr<IAMStreamSelect> pSS = pBF) {
- LCID idAudio = s.idAudioLang;
- if (!idAudio) {
- idAudio = GetUserDefaultLCID();
- }
- LCID idSub = s.idSubtitlesLang;
- if (!idSub) {
- idSub = GetUserDefaultLCID();
- }
-
- DWORD cnt = 0;
- pSS->Count(&cnt);
- for (DWORD i = 0; i < cnt; i++) {
- AM_MEDIA_TYPE* pmt = NULL;
- DWORD dwFlags = 0;
- LCID lcid = 0;
- DWORD dwGroup = 0;
- WCHAR* pszName = NULL;
- if (SUCCEEDED(pSS->Info((long)i, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))) {
- CStringW name(pszName), sound(ResStr(IDS_AG_SOUND)), subtitle(L"Subtitle");
-
- if (idAudio != (LCID)-1 && (idAudio&0x3ff) == (lcid&0x3ff) // sublang seems to be zeroed out in ogm...
- && name.GetLength() > sound.GetLength()
- && !name.Left(sound.GetLength()).CompareNoCase(sound)) {
- if (SUCCEEDED(pSS->Enable(i, AMSTREAMSELECTENABLE_ENABLE))) {
- idAudio = (LCID)-1;
- }
- }
-
- if (idSub != (LCID)-1 && (idSub&0x3ff) == (lcid&0x3ff) // sublang seems to be zeroed out in ogm...
- && name.GetLength() > subtitle.GetLength()
- && !name.Left(subtitle.GetLength()).CompareNoCase(subtitle)
- && name.Mid(subtitle.GetLength()).Trim().CompareNoCase(L"off")) {
- if (SUCCEEDED(pSS->Enable(i, AMSTREAMSELECTENABLE_ENABLE))) {
- idSub = (LCID)-1;
- }
- }
-
- if (pmt) {
- DeleteMediaType(pmt);
- }
- if (pszName) {
- CoTaskMemFree(pszName);
- }
- }
- }
- }
- }
- }
- EndEnumFilters;
-
- CleanGraph();
+ if (GetPlaybackMode() == PM_CAPTURE) {
+ return;
+ }
+
+ CleanGraph();
+
+ if (GetPlaybackMode() == PM_FILE) {
+ if (m_pCAP && AfxGetAppSettings().fAutoloadSubtitles) {
+ AddTextPassThruFilter();
+ }
+ }
+
+ AppSettings& s = AfxGetAppSettings();
+ CRenderersSettings& r = s.m_RenderersSettings;
+ if (r.m_RenderSettings.bSynchronizeVideo && s.iDSVideoRendererType == VIDRNDT_DS_SYNC) {
+ HRESULT hr;
+ m_pRefClock = DNew CSyncClockFilter(NULL, &hr);
+ CStringW name;
+ name = L"SyncClock Filter";
+ pGB->AddFilter(m_pRefClock, name);
+
+ CComPtr<IReferenceClock> refClock;
+ m_pRefClock->QueryInterface(IID_IReferenceClock, reinterpret_cast<void**>(&refClock));
+ CComPtr<IMediaFilter> mediaFilter;
+ pGB->QueryInterface(IID_IMediaFilter, reinterpret_cast<void**>(&mediaFilter));
+ mediaFilter->SetSyncSource(refClock);
+ mediaFilter = NULL;
+ refClock = NULL;
+
+ m_pRefClock->QueryInterface(IID_ISyncClock, reinterpret_cast<void**>(&m_pSyncClock));
+
+ CComQIPtr<ISyncClockAdviser> pAdviser = m_pCAP;
+ if (pAdviser) {
+ pAdviser->AdviseSyncClock(m_pSyncClock);
+ }
+ }
+
+ if (GetPlaybackMode() == PM_DVD) {
+ BeginEnumFilters(pGB, pEF, pBF) {
+ if (CComQIPtr<IDirectVobSub2> pDVS2 = pBF) {
+ //pDVS2->AdviseSubClock(m_pSubClock = DNew CSubClock);
+ //break;
+
+ // TODO: test multiple dvobsub instances with one clock
+ if (!m_pSubClock) {
+ m_pSubClock = DNew CSubClock;
+ }
+ pDVS2->AdviseSubClock(m_pSubClock);
+ }
+ }
+ EndEnumFilters;
+ }
+
+ BeginEnumFilters(pGB, pEF, pBF) {
+ if (GetCLSID(pBF) == CLSID_OggSplitter) {
+ if (CComQIPtr<IAMStreamSelect> pSS = pBF) {
+ LCID idAudio = s.idAudioLang;
+ if (!idAudio) {
+ idAudio = GetUserDefaultLCID();
+ }
+ LCID idSub = s.idSubtitlesLang;
+ if (!idSub) {
+ idSub = GetUserDefaultLCID();
+ }
+
+ DWORD cnt = 0;
+ pSS->Count(&cnt);
+ for (DWORD i = 0; i < cnt; i++) {
+ AM_MEDIA_TYPE* pmt = NULL;
+ DWORD dwFlags = 0;
+ LCID lcid = 0;
+ DWORD dwGroup = 0;
+ WCHAR* pszName = NULL;
+ if (SUCCEEDED(pSS->Info((long)i, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))) {
+ CStringW name(pszName), sound(ResStr(IDS_AG_SOUND)), subtitle(L"Subtitle");
+
+ if (idAudio != (LCID) - 1 && (idAudio & 0x3ff) == (lcid & 0x3ff) // sublang seems to be zeroed out in ogm...
+ && name.GetLength() > sound.GetLength()
+ && !name.Left(sound.GetLength()).CompareNoCase(sound)) {
+ if (SUCCEEDED(pSS->Enable(i, AMSTREAMSELECTENABLE_ENABLE))) {
+ idAudio = (LCID) - 1;
+ }
+ }
+
+ if (idSub != (LCID) - 1 && (idSub & 0x3ff) == (lcid & 0x3ff) // sublang seems to be zeroed out in ogm...
+ && name.GetLength() > subtitle.GetLength()
+ && !name.Left(subtitle.GetLength()).CompareNoCase(subtitle)
+ && name.Mid(subtitle.GetLength()).Trim().CompareNoCase(L"off")) {
+ if (SUCCEEDED(pSS->Enable(i, AMSTREAMSELECTENABLE_ENABLE))) {
+ idSub = (LCID) - 1;
+ }
+ }
+
+ if (pmt) {
+ DeleteMediaType(pmt);
+ }
+ if (pszName) {
+ CoTaskMemFree(pszName);
+ }
+ }
+ }
+ }
+ }
+ }
+ EndEnumFilters;
+
+ CleanGraph();
}
void CMainFrame::OpenSetupVideo()
{
- m_fAudioOnly = true;
-
- if (m_pMFVDC) { // EVR
- m_fAudioOnly = false;
- } else if (m_pCAP) {
- CSize vs = m_pCAP->GetVideoSize();
- m_fAudioOnly = (vs.cx <= 0 || vs.cy <= 0);
- } else {
- {
- long w = 0, h = 0;
-
- if (CComQIPtr<IBasicVideo> pBV = pGB) {
- pBV->GetVideoSize(&w, &h);
- }
-
- if (w > 0 && h > 0) {
- m_fAudioOnly = false;
- }
- }
-
- if (m_fAudioOnly) {
- BeginEnumFilters(pGB, pEF, pBF) {
- long w = 0, h = 0;
-
- if (CComQIPtr<IVideoWindow> pVW = pBF) {
- long lVisible;
- if (FAILED(pVW->get_Visible(&lVisible))) {
- continue;
- }
-
- pVW->get_Width(&w);
- pVW->get_Height(&h);
- }
-
- if (w > 0 && h > 0) {
- m_fAudioOnly = false;
- break;
- }
- }
- EndEnumFilters;
- }
- }
-
- if (m_fShockwaveGraph) {
- m_fAudioOnly = false;
- }
-
- if (m_pCAP) {
- SetShaders();
- }
- // else
- {
- // TESTME
-
- pVW->put_Owner((OAHWND)m_pVideoWnd->m_hWnd);
- pVW->put_WindowStyle(WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN);
- pVW->put_MessageDrain((OAHWND)m_hWnd);
-
- for (CWnd* pWnd = m_wndView.GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
- pWnd->EnableWindow(FALSE); // little trick to let WM_SETCURSOR thru
- }
- }
-
- if (m_fAudioOnly && m_pFullscreenWnd->IsWindow()) {
- m_pFullscreenWnd->DestroyWindow();
- }
+ m_fAudioOnly = true;
+
+ if (m_pMFVDC) { // EVR
+ m_fAudioOnly = false;
+ } else if (m_pCAP) {
+ CSize vs = m_pCAP->GetVideoSize();
+ m_fAudioOnly = (vs.cx <= 0 || vs.cy <= 0);
+ } else {
+ {
+ long w = 0, h = 0;
+
+ if (CComQIPtr<IBasicVideo> pBV = pGB) {
+ pBV->GetVideoSize(&w, &h);
+ }
+
+ if (w > 0 && h > 0) {
+ m_fAudioOnly = false;
+ }
+ }
+
+ if (m_fAudioOnly) {
+ BeginEnumFilters(pGB, pEF, pBF) {
+ long w = 0, h = 0;
+
+ if (CComQIPtr<IVideoWindow> pVW = pBF) {
+ long lVisible;
+ if (FAILED(pVW->get_Visible(&lVisible))) {
+ continue;
+ }
+
+ pVW->get_Width(&w);
+ pVW->get_Height(&h);
+ }
+
+ if (w > 0 && h > 0) {
+ m_fAudioOnly = false;
+ break;
+ }
+ }
+ EndEnumFilters;
+ }
+ }
+
+ if (m_fShockwaveGraph) {
+ m_fAudioOnly = false;
+ }
+
+ if (m_pCAP) {
+ SetShaders();
+ }
+ // else
+ {
+ // TESTME
+
+ pVW->put_Owner((OAHWND)m_pVideoWnd->m_hWnd);
+ pVW->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
+ pVW->put_MessageDrain((OAHWND)m_hWnd);
+
+ for (CWnd* pWnd = m_wndView.GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
+ pWnd->EnableWindow(FALSE); // little trick to let WM_SETCURSOR thru
+ }
+ }
+
+ if (m_fAudioOnly && m_pFullscreenWnd->IsWindow()) {
+ m_pFullscreenWnd->DestroyWindow();
+ }
}
void CMainFrame::OpenSetupAudio()
{
- pBA->put_Volume(m_wndToolBar.Volume);
+ pBA->put_Volume(m_wndToolBar.Volume);
- // FIXME
- int balance = AfxGetAppSettings().nBalance;
+ // FIXME
+ int balance = AfxGetAppSettings().nBalance;
- int sign = balance>0?-1:1; // -1: invert sign for more right channel
- if (balance > -100 && balance < 100) {
- balance = sign*(int)(100*20*log10(1-abs(balance)/100.0f));
- } else {
- balance = sign*(-10000); // -10000: only left, 10000: only right
- }
+ int sign = balance > 0 ? -1 : 1; // -1: invert sign for more right channel
+ if (balance > -100 && balance < 100) {
+ balance = sign * (int)(100 * 20 * log10(1 - abs(balance) / 100.0f));
+ } else {
+ balance = sign * (-10000); // -10000: only left, 10000: only right
+ }
- pBA->put_Balance(balance);
+ pBA->put_Balance(balance);
}
/*
void CMainFrame::OpenSetupToolBar()
{
-// m_wndToolBar.Volume = AfxGetAppSettings().nVolume;
-// SetBalance(AfxGetAppSettings().nBalance);
+// m_wndToolBar.Volume = AfxGetAppSettings().nVolume;
+// SetBalance(AfxGetAppSettings().nBalance);
}
*/
void CMainFrame::OpenSetupCaptureBar()
{
- if (GetPlaybackMode() == PM_CAPTURE) {
- if (pVidCap && pAMVSCCap) {
- CComQIPtr<IAMVfwCaptureDialogs> pVfwCD = pVidCap;
-
- if (!pAMXBar && pVfwCD) {
- m_wndCaptureBar.m_capdlg.SetupVideoControls(m_VidDispName, pAMVSCCap, pVfwCD);
- } else {
- m_wndCaptureBar.m_capdlg.SetupVideoControls(m_VidDispName, pAMVSCCap, pAMXBar, pAMTuner);
- }
- }
-
- if (pAudCap && pAMASC) {
- CInterfaceArray<IAMAudioInputMixer> pAMAIM;
-
- BeginEnumPins(pAudCap, pEP, pPin) {
- if (CComQIPtr<IAMAudioInputMixer> pAIM = pPin) {
- pAMAIM.Add(pAIM);
- }
- }
- EndEnumPins;
-
- m_wndCaptureBar.m_capdlg.SetupAudioControls(m_AudDispName, pAMASC, pAMAIM);
- }
- }
+ if (GetPlaybackMode() == PM_CAPTURE) {
+ if (pVidCap && pAMVSCCap) {
+ CComQIPtr<IAMVfwCaptureDialogs> pVfwCD = pVidCap;
+
+ if (!pAMXBar && pVfwCD) {
+ m_wndCaptureBar.m_capdlg.SetupVideoControls(m_VidDispName, pAMVSCCap, pVfwCD);
+ } else {
+ m_wndCaptureBar.m_capdlg.SetupVideoControls(m_VidDispName, pAMVSCCap, pAMXBar, pAMTuner);
+ }
+ }
+
+ if (pAudCap && pAMASC) {
+ CInterfaceArray<IAMAudioInputMixer> pAMAIM;
+
+ BeginEnumPins(pAudCap, pEP, pPin) {
+ if (CComQIPtr<IAMAudioInputMixer> pAIM = pPin) {
+ pAMAIM.Add(pAIM);
+ }
+ }
+ EndEnumPins;
+
+ m_wndCaptureBar.m_capdlg.SetupAudioControls(m_AudDispName, pAMASC, pAMAIM);
+ }
+ }
- BuildGraphVideoAudio(
- m_wndCaptureBar.m_capdlg.m_fVidPreview, false,
- m_wndCaptureBar.m_capdlg.m_fAudPreview, false);
+ BuildGraphVideoAudio(
+ m_wndCaptureBar.m_capdlg.m_fVidPreview, false,
+ m_wndCaptureBar.m_capdlg.m_fAudPreview, false);
}
void CMainFrame::OpenSetupInfoBar()
{
- if (GetPlaybackMode() == PM_FILE) {
- bool fEmpty = true;
- BeginEnumFilters(pGB, pEF, pBF) {
- if (CComQIPtr<IAMMediaContent, &IID_IAMMediaContent> pAMMC = pBF) {
- CComBSTR bstr;
- if (SUCCEEDED(pAMMC->get_Title(&bstr))) {
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_TITLE), bstr.m_str);
- if (bstr.Length()) {
- fEmpty = false;
- }
- }
- bstr.Empty();
- if (SUCCEEDED(pAMMC->get_AuthorName(&bstr))) {
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_AUTHOR), bstr.m_str);
- if (bstr.Length()) {
- fEmpty = false;
- }
- }
- bstr.Empty();
- if (SUCCEEDED(pAMMC->get_Copyright(&bstr))) {
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_COPYRIGHT), bstr.m_str);
- if (bstr.Length()) {
- fEmpty = false;
- }
- }
- bstr.Empty();
- if (SUCCEEDED(pAMMC->get_Rating(&bstr))) {
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_RATING), bstr.m_str);
- if (bstr.Length()) {
- fEmpty = false;
- }
- }
- bstr.Empty();
- if (SUCCEEDED(pAMMC->get_Description(&bstr))) {
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_DESCRIPTION), bstr.m_str);
- if (bstr.Length()) {
- fEmpty = false;
- }
- }
- bstr.Empty();
- if (!fEmpty) {
- RecalcLayout();
- break;
- }
- }
- }
- EndEnumFilters;
- } else if (GetPlaybackMode() == PM_DVD) {
- CString info('-');
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_DOMAIN), info);
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_LOCATION), info);
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_VIDEO), info);
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_AUDIO), info);
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_SUBTITLES), info);
- RecalcLayout();
- }
+ if (GetPlaybackMode() == PM_FILE) {
+ bool fEmpty = true;
+ BeginEnumFilters(pGB, pEF, pBF) {
+ if (CComQIPtr<IAMMediaContent, &IID_IAMMediaContent> pAMMC = pBF) {
+ CComBSTR bstr;
+ if (SUCCEEDED(pAMMC->get_Title(&bstr))) {
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_TITLE), bstr.m_str);
+ if (bstr.Length()) {
+ fEmpty = false;
+ }
+ }
+ bstr.Empty();
+ if (SUCCEEDED(pAMMC->get_AuthorName(&bstr))) {
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_AUTHOR), bstr.m_str);
+ if (bstr.Length()) {
+ fEmpty = false;
+ }
+ }
+ bstr.Empty();
+ if (SUCCEEDED(pAMMC->get_Copyright(&bstr))) {
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_COPYRIGHT), bstr.m_str);
+ if (bstr.Length()) {
+ fEmpty = false;
+ }
+ }
+ bstr.Empty();
+ if (SUCCEEDED(pAMMC->get_Rating(&bstr))) {
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_RATING), bstr.m_str);
+ if (bstr.Length()) {
+ fEmpty = false;
+ }
+ }
+ bstr.Empty();
+ if (SUCCEEDED(pAMMC->get_Description(&bstr))) {
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_DESCRIPTION), bstr.m_str);
+ if (bstr.Length()) {
+ fEmpty = false;
+ }
+ }
+ bstr.Empty();
+ if (!fEmpty) {
+ RecalcLayout();
+ break;
+ }
+ }
+ }
+ EndEnumFilters;
+ } else if (GetPlaybackMode() == PM_DVD) {
+ CString info('-');
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_DOMAIN), info);
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_LOCATION), info);
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_VIDEO), info);
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_AUDIO), info);
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_SUBTITLES), info);
+ RecalcLayout();
+ }
}
void CMainFrame::OpenSetupStatsBar()
{
- CString info('-');
-
- BeginEnumFilters(pGB, pEF, pBF) {
- if (!pQP && (pQP = pBF)) {
- m_wndStatsBar.SetLine(ResStr(IDS_AG_FRAMERATE), info);
- m_wndStatsBar.SetLine(_T("Sync Offset"), info);
- m_wndStatsBar.SetLine(ResStr(IDS_AG_FRAMES), info);
- m_wndStatsBar.SetLine(_T("Jitter"), info);
- m_wndStatsBar.SetLine(ResStr(IDS_AG_BUFFERS), info);
- m_wndStatsBar.SetLine(_T("Bitrate"), info);
- RecalcLayout();
- }
-
- if (!pBI && (pBI = pBF)) {
- m_wndStatsBar.SetLine(ResStr(IDS_AG_BUFFERS), info);
- m_wndStatsBar.SetLine(_T("Bitrate"), info); // FIXME: shouldn't be here
- RecalcLayout();
- }
- }
- EndEnumFilters;
+ CString info('-');
+
+ BeginEnumFilters(pGB, pEF, pBF) {
+ if (!pQP && (pQP = pBF)) {
+ m_wndStatsBar.SetLine(ResStr(IDS_AG_FRAMERATE), info);
+ m_wndStatsBar.SetLine(_T("Sync Offset"), info);
+ m_wndStatsBar.SetLine(ResStr(IDS_AG_FRAMES), info);
+ m_wndStatsBar.SetLine(_T("Jitter"), info);
+ m_wndStatsBar.SetLine(ResStr(IDS_AG_BUFFERS), info);
+ m_wndStatsBar.SetLine(_T("Bitrate"), info);
+ RecalcLayout();
+ }
+
+ if (!pBI && (pBI = pBF)) {
+ m_wndStatsBar.SetLine(ResStr(IDS_AG_BUFFERS), info);
+ m_wndStatsBar.SetLine(_T("Bitrate"), info); // FIXME: shouldn't be here
+ RecalcLayout();
+ }
+ }
+ EndEnumFilters;
}
void CMainFrame::OpenSetupStatusBar()
{
- m_wndStatusBar.ShowTimer(true);
-
- //
-
- if (!m_fCustomGraph) {
- UINT id = IDB_NOAUDIO;
-
- BeginEnumFilters(pGB, pEF, pBF) {
- CComQIPtr<IBasicAudio> pBA = pBF;
- if (!pBA) {
- continue;
- }
-
- BeginEnumPins(pBF, pEP, pPin) {
- if (S_OK == pGB->IsPinDirection(pPin, PINDIR_INPUT)
- && S_OK == pGB->IsPinConnected(pPin)) {
- AM_MEDIA_TYPE mt;
- memset(&mt, 0, sizeof(mt));
- pPin->ConnectionMediaType(&mt);
-
- if (mt.majortype == MEDIATYPE_Audio && mt.formattype == FORMAT_WaveFormatEx) {
- switch (((WAVEFORMATEX*)mt.pbFormat)->nChannels) {
- case 1:
- id = IDB_MONO;
- break;
- case 2:
- default:
- id = IDB_STEREO;
- break;
- }
- break;
- } else if (mt.majortype == MEDIATYPE_Midi) {
- id = NULL;
- break;
- }
- }
- }
- EndEnumPins;
-
- if (id != IDB_NOAUDIO) {
- break;
- }
- }
- EndEnumFilters;
-
- m_wndStatusBar.SetStatusBitmap(id);
- }
-
- //
-
- HICON hIcon = NULL;
-
- if (GetPlaybackMode() == PM_FILE) {
- CString fn = m_wndPlaylistBar.GetCurFileName();
- CString ext = fn.Mid(fn.ReverseFind('.')+1);
- hIcon = LoadIcon(ext, true);
- } else if (GetPlaybackMode() == PM_DVD) {
- hIcon = LoadIcon(_T(".ifo"), true);
- } else if (GetPlaybackMode() == PM_DVD) {
- //hIcon = ; // TODO
- }
-
- m_wndStatusBar.SetStatusTypeIcon(hIcon);
+ m_wndStatusBar.ShowTimer(true);
+
+ //
+
+ if (!m_fCustomGraph) {
+ UINT id = IDB_NOAUDIO;
+
+ BeginEnumFilters(pGB, pEF, pBF) {
+ CComQIPtr<IBasicAudio> pBA = pBF;
+ if (!pBA) {
+ continue;
+ }
+
+ BeginEnumPins(pBF, pEP, pPin) {
+ if (S_OK == pGB->IsPinDirection(pPin, PINDIR_INPUT)
+ && S_OK == pGB->IsPinConnected(pPin)) {
+ AM_MEDIA_TYPE mt;
+ memset(&mt, 0, sizeof(mt));
+ pPin->ConnectionMediaType(&mt);
+
+ if (mt.majortype == MEDIATYPE_Audio && mt.formattype == FORMAT_WaveFormatEx) {
+ switch (((WAVEFORMATEX*)mt.pbFormat)->nChannels) {
+ case 1:
+ id = IDB_MONO;
+ break;
+ case 2:
+ default:
+ id = IDB_STEREO;
+ break;
+ }
+ break;
+ } else if (mt.majortype == MEDIATYPE_Midi) {
+ id = NULL;
+ break;
+ }
+ }
+ }
+ EndEnumPins;
+
+ if (id != IDB_NOAUDIO) {
+ break;
+ }
+ }
+ EndEnumFilters;
+
+ m_wndStatusBar.SetStatusBitmap(id);
+ }
+
+ //
+
+ HICON hIcon = NULL;
+
+ if (GetPlaybackMode() == PM_FILE) {
+ CString fn = m_wndPlaylistBar.GetCurFileName();
+ CString ext = fn.Mid(fn.ReverseFind('.') + 1);
+ hIcon = LoadIcon(ext, true);
+ } else if (GetPlaybackMode() == PM_DVD) {
+ hIcon = LoadIcon(_T(".ifo"), true);
+ } else if (GetPlaybackMode() == PM_DVD) {
+ //hIcon = ; // TODO
+ }
+
+ m_wndStatusBar.SetStatusTypeIcon(hIcon);
}
void CMainFrame::OpenSetupWindowTitle(CString fn)
{
- CString title = ResStr(IDR_MAINFRAME);
-
- AppSettings& s = AfxGetAppSettings();
-
- int i = s.iTitleBarTextStyle;
-
- if (!fn.IsEmpty() && (i == 0 || i == 1)) {
- if (i == 1) {
- if (GetPlaybackMode() == PM_FILE) {
- fn.Replace('\\', '/');
- CString fn2 = fn.Mid(fn.ReverseFind('/')+1);
- if (!fn2.IsEmpty()) {
- fn = fn2;
- }
-
- if (s.fTitleBarTextTitle) {
- BeginEnumFilters(pGB, pEF, pBF) {
- if (CComQIPtr<IAMMediaContent, &IID_IAMMediaContent> pAMMC = pBF) {
- CComBSTR bstr;
- if (SUCCEEDED(pAMMC->get_Title(&bstr)) && bstr.Length()) {
- fn = CString(bstr.m_str);
- break;
- }
- }
- }
- EndEnumFilters;
- }
- } else if (GetPlaybackMode() == PM_DVD) {
- fn = _T("DVD");
- } else if (GetPlaybackMode() == PM_CAPTURE) {
- fn.LoadString(IDS_CAPTURE_LIVE);
- }
- }
- title = fn;
- }
-
- SetWindowText(title);
- //m_Lcd.SetMediaTitle(LPCTSTR(fn));
+ CString title = ResStr(IDR_MAINFRAME);
+
+ AppSettings& s = AfxGetAppSettings();
+
+ int i = s.iTitleBarTextStyle;
+
+ if (!fn.IsEmpty() && (i == 0 || i == 1)) {
+ if (i == 1) {
+ if (GetPlaybackMode() == PM_FILE) {
+ fn.Replace('\\', '/');
+ CString fn2 = fn.Mid(fn.ReverseFind('/') + 1);
+ if (!fn2.IsEmpty()) {
+ fn = fn2;
+ }
+
+ if (s.fTitleBarTextTitle) {
+ BeginEnumFilters(pGB, pEF, pBF) {
+ if (CComQIPtr<IAMMediaContent, &IID_IAMMediaContent> pAMMC = pBF) {
+ CComBSTR bstr;
+ if (SUCCEEDED(pAMMC->get_Title(&bstr)) && bstr.Length()) {
+ fn = CString(bstr.m_str);
+ break;
+ }
+ }
+ }
+ EndEnumFilters;
+ }
+ } else if (GetPlaybackMode() == PM_DVD) {
+ fn = _T("DVD");
+ } else if (GetPlaybackMode() == PM_CAPTURE) {
+ fn.LoadString(IDS_CAPTURE_LIVE);
+ }
+ }
+ title = fn;
+ }
+
+ SetWindowText(title);
+ //m_Lcd.SetMediaTitle(LPCTSTR(fn));
}
// foxX: simply global now, figures out if, based on the options selected by the user
// the language of audio stream a from pSS is more "important" than that of audio b
-bool DoesAudioPrecede(const CComPtr<IAMStreamSelect> &pSS, int a, int b)
-{
- WCHAR* pName = NULL;
- if (FAILED(pSS->Info(a, NULL, NULL, NULL, NULL, &pName, NULL, NULL))) {
- return false;
- }
- CString nameA(pName);
- nameA = nameA.Trim();
- CoTaskMemFree(pName);
-
- if (FAILED(pSS->Info(b, NULL, NULL, NULL, NULL, &pName, NULL, NULL))) {
- return false;
- }
- CString nameB(pName);
- nameB = nameB.Trim();
- CoTaskMemFree(pName);
-
- int ia = -1;
- int ib = -1;
- CStringW alo = _T("[Forced],") + AfxGetAppSettings().strAudiosLanguageOrder + _T(",[Default]");
- int tPos = 0;
- CStringW lang = alo.Tokenize(_T(",; "), tPos);
- while (tPos != -1 && ia == -1 && ib == -1) {
- int ll = lang.GetLength();
- if ((nameA.Left(ll).CompareNoCase(lang) == 0) || (nameA.Right(ll).CompareNoCase(lang) == 0)) {
- ia = tPos;
- }
- if ((nameB.Left(ll).CompareNoCase(lang) == 0) || (nameB.Right(ll).CompareNoCase(lang) == 0)) {
- ib = tPos;
- }
- lang = alo.Tokenize(_T(",; "), tPos);
- }
- if (ia != -1 && ib == -1) {
- return true;
- }
- return false;
+bool DoesAudioPrecede(const CComPtr<IAMStreamSelect>& pSS, int a, int b)
+{
+ WCHAR* pName = NULL;
+ if (FAILED(pSS->Info(a, NULL, NULL, NULL, NULL, &pName, NULL, NULL))) {
+ return false;
+ }
+ CString nameA(pName);
+ nameA = nameA.Trim();
+ CoTaskMemFree(pName);
+
+ if (FAILED(pSS->Info(b, NULL, NULL, NULL, NULL, &pName, NULL, NULL))) {
+ return false;
+ }
+ CString nameB(pName);
+ nameB = nameB.Trim();
+ CoTaskMemFree(pName);
+
+ int ia = -1;
+ int ib = -1;
+ CStringW alo = _T("[Forced],") + AfxGetAppSettings().strAudiosLanguageOrder + _T(",[Default]");
+ int tPos = 0;
+ CStringW lang = alo.Tokenize(_T(",; "), tPos);
+ while (tPos != -1 && ia == -1 && ib == -1) {
+ int ll = lang.GetLength();
+ if ((nameA.Left(ll).CompareNoCase(lang) == 0) || (nameA.Right(ll).CompareNoCase(lang) == 0)) {
+ ia = tPos;
+ }
+ if ((nameB.Left(ll).CompareNoCase(lang) == 0) || (nameB.Right(ll).CompareNoCase(lang) == 0)) {
+ ib = tPos;
+ }
+ lang = alo.Tokenize(_T(",; "), tPos);
+ }
+ if (ia != -1 && ib == -1) {
+ return true;
+ }
+ return false;
}
// foxX: does the naive insertion, in a separate list of audio streams indexes, of stream number i
// from the original ordering of audio streams, based on language order preference
-void CMainFrame::InsertAudioStream(const CComQIPtr<IAMStreamSelect> &pSS, int i)
-{
- POSITION pos = m_iAudioStreams.GetHeadPosition();
- bool processed = false;
- while (!processed && pos) {
- POSITION prevPos = pos;
- int j = m_iAudioStreams.GetNext(pos);
- if (DoesAudioPrecede(pSS, i, j)) {
- if (prevPos == m_iAudioStreams.GetHeadPosition()) {
- m_iAudioStreams.AddHead(i);
- } else {
- m_iAudioStreams.InsertBefore(prevPos, i);
- }
- processed = true;
- }
- }
- if (!processed) {
- m_iAudioStreams.AddTail(i);
- }
+void CMainFrame::InsertAudioStream(const CComQIPtr<IAMStreamSelect>& pSS, int i)
+{
+ POSITION pos = m_iAudioStreams.GetHeadPosition();
+ bool processed = false;
+ while (!processed && pos) {
+ POSITION prevPos = pos;
+ int j = m_iAudioStreams.GetNext(pos);
+ if (DoesAudioPrecede(pSS, i, j)) {
+ if (prevPos == m_iAudioStreams.GetHeadPosition()) {
+ m_iAudioStreams.AddHead(i);
+ } else {
+ m_iAudioStreams.InsertBefore(prevPos, i);
+ }
+ processed = true;
+ }
+ }
+ if (!processed) {
+ m_iAudioStreams.AddTail(i);
+ }
}
// foxX: creates a mapping of audio streams, where they're ordered based on their language and the user language order options
void CMainFrame::SetupAudioStreams()
{
- if (m_iMediaLoadState != MLS_LOADED) {
- return;
- }
+ if (m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
- m_iAudioStreams.RemoveAll();
+ m_iAudioStreams.RemoveAll();
- CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
- if (!pSS) {
- pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB); // morgan's switcher
- }
+ CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
+ if (!pSS) {
+ pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB); // morgan's switcher
+ }
- DWORD cStreams = 0;
- if (pSS && SUCCEEDED(pSS->Count(&cStreams)) && cStreams > 0) {
- for (int i = 0; i < (int)cStreams; i++) {
- InsertAudioStream(pSS, i);
- }
- }
+ DWORD cStreams = 0;
+ if (pSS && SUCCEEDED(pSS->Count(&cStreams)) && cStreams > 0) {
+ for (int i = 0; i < (int)cStreams; i++) {
+ InsertAudioStream(pSS, i);
+ }
+ }
}
bool CMainFrame::OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD)
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- if (m_iMediaLoadState != MLS_CLOSED) {
- ASSERT(0);
- return false;
- }
+ if (m_iMediaLoadState != MLS_CLOSED) {
+ ASSERT(0);
+ return false;
+ }
- OpenFileData *pFileData = dynamic_cast<OpenFileData *>(pOMD.m_p);
- OpenDVDData* pDVDData = dynamic_cast<OpenDVDData*>(pOMD.m_p);
- OpenDeviceData* pDeviceData = dynamic_cast<OpenDeviceData*>(pOMD.m_p);
- if (!pFileData && !pDVDData && !pDeviceData) {
- ASSERT(0);
- return false;
- }
+ OpenFileData* pFileData = dynamic_cast<OpenFileData*>(pOMD.m_p);
+ OpenDVDData* pDVDData = dynamic_cast<OpenDVDData*>(pOMD.m_p);
+ OpenDeviceData* pDeviceData = dynamic_cast<OpenDeviceData*>(pOMD.m_p);
+ if (!pFileData && !pDVDData && !pDeviceData) {
+ ASSERT(0);
+ return false;
+ }
- // Clear DXVA state ...
- ClearDXVAState();
+ // Clear DXVA state ...
+ ClearDXVAState();
#ifdef _DEBUG
- // Debug trace code - Begin
- // Check for bad / buggy auto loading file code
- if ( pFileData ) {
- POSITION pos = pFileData->fns.GetHeadPosition();
- UINT index = 0;
- while ( pos != NULL ) {
- CString path = pFileData->fns.GetNext( pos );
- TRACE(_T("--> CMainFrame::OpenMediaPrivate - pFileData->fns[%d]:\n"), index);
- TRACE(_T("\t%ws\n"), path.GetString()); // %ws - wide character string always
- index++;
- }
- }
- // Debug trace code - End
+ // Debug trace code - Begin
+ // Check for bad / buggy auto loading file code
+ if (pFileData) {
+ POSITION pos = pFileData->fns.GetHeadPosition();
+ UINT index = 0;
+ while (pos != NULL) {
+ CString path = pFileData->fns.GetNext(pos);
+ TRACE(_T("--> CMainFrame::OpenMediaPrivate - pFileData->fns[%d]:\n"), index);
+ TRACE(_T("\t%ws\n"), path.GetString()); // %ws - wide character string always
+ index++;
+ }
+ }
+ // Debug trace code - End
#endif
- CString mi_fn = _T("");
-
- if (pFileData) {
- if (pFileData->fns.IsEmpty()) {
- return false;
- }
-
- CString fn = pFileData->fns.GetHead();
-
- int i = fn.Find(_T(":\\"));
- if (i > 0) {
- CString drive = fn.Left(i+2);
- UINT type = GetDriveType(drive);
- CAtlList<CString> sl;
- if (type == DRIVE_REMOVABLE || type == DRIVE_CDROM && GetCDROMType(drive[0], sl) != CDROM_Audio) {
- int ret = IDRETRY;
- while (ret == IDRETRY) {
- WIN32_FIND_DATA findFileData;
- HANDLE h = FindFirstFile(fn, &findFileData);
- if (h != INVALID_HANDLE_VALUE) {
- FindClose(h);
- ret = IDOK;
- } else {
- CString msg;
- msg.Format(IDS_MAINFRM_114, fn);
- ret = AfxMessageBox(msg, MB_RETRYCANCEL);
- }
- }
-
- if (ret != IDOK) {
- return false;
- }
- }
- mi_fn = fn;
- }
- }
-
- if (s.AutoChangeFullscrRes.bEnabled && s.IsD3DFullscreen()) {
- // DVD
- if (pDVDData) {
- mi_fn = pDVDData->path;
- CPath path(mi_fn);
- CString ext = path.GetExtension();
- if (ext == _T("")) {
- if (mi_fn.Right(10) == _T("\\VIDEO_TS\\")) {
- mi_fn = mi_fn + _T("VTS_01_1.VOB");
- } else {
- mi_fn = mi_fn + _T("\\VIDEO_TS\\VTS_01_1.VOB");
- }
- } else if (ext == _T(".IFO")) {
- path.RemoveFileSpec();
- mi_fn = path + _T("\\VTS_01_1.VOB");
- }
- } else {
- CPath path(mi_fn);
- CString ext = path.GetExtension();
- // BD
- if (ext == _T(".mpls")) {
- CHdmvClipInfo ClipInfo;
- CAtlList<CHdmvClipInfo::PlaylistItem> CurPlaylist;
- CHdmvClipInfo::PlaylistItem Item;
- REFERENCE_TIME rtDuration;
- if (SUCCEEDED (ClipInfo.ReadPlaylist(mi_fn, rtDuration, CurPlaylist))) {
- Item = CurPlaylist.GetHead();
- mi_fn = Item.m_strFileName;
- }
- }
- }
-
- // Get FPS
- miFPS = 0.0;
+ CString mi_fn = _T("");
+
+ if (pFileData) {
+ if (pFileData->fns.IsEmpty()) {
+ return false;
+ }
+
+ CString fn = pFileData->fns.GetHead();
+
+ int i = fn.Find(_T(":\\"));
+ if (i > 0) {
+ CString drive = fn.Left(i + 2);
+ UINT type = GetDriveType(drive);
+ CAtlList<CString> sl;
+ if (type == DRIVE_REMOVABLE || type == DRIVE_CDROM && GetCDROMType(drive[0], sl) != CDROM_Audio) {
+ int ret = IDRETRY;
+ while (ret == IDRETRY) {
+ WIN32_FIND_DATA findFileData;
+ HANDLE h = FindFirstFile(fn, &findFileData);
+ if (h != INVALID_HANDLE_VALUE) {
+ FindClose(h);
+ ret = IDOK;
+ } else {
+ CString msg;
+ msg.Format(IDS_MAINFRM_114, fn);
+ ret = AfxMessageBox(msg, MB_RETRYCANCEL);
+ }
+ }
+
+ if (ret != IDOK) {
+ return false;
+ }
+ }
+ mi_fn = fn;
+ }
+ }
+
+ if (s.AutoChangeFullscrRes.bEnabled && s.IsD3DFullscreen()) {
+ // DVD
+ if (pDVDData) {
+ mi_fn = pDVDData->path;
+ CPath path(mi_fn);
+ CString ext = path.GetExtension();
+ if (ext == _T("")) {
+ if (mi_fn.Right(10) == _T("\\VIDEO_TS\\")) {
+ mi_fn = mi_fn + _T("VTS_01_1.VOB");
+ } else {
+ mi_fn = mi_fn + _T("\\VIDEO_TS\\VTS_01_1.VOB");
+ }
+ } else if (ext == _T(".IFO")) {
+ path.RemoveFileSpec();
+ mi_fn = path + _T("\\VTS_01_1.VOB");
+ }
+ } else {
+ CPath path(mi_fn);
+ CString ext = path.GetExtension();
+ // BD
+ if (ext == _T(".mpls")) {
+ CHdmvClipInfo ClipInfo;
+ CAtlList<CHdmvClipInfo::PlaylistItem> CurPlaylist;
+ CHdmvClipInfo::PlaylistItem Item;
+ REFERENCE_TIME rtDuration;
+ if (SUCCEEDED(ClipInfo.ReadPlaylist(mi_fn, rtDuration, CurPlaylist))) {
+ Item = CurPlaylist.GetHead();
+ mi_fn = Item.m_strFileName;
+ }
+ }
+ }
+
+ // Get FPS
+ miFPS = 0.0;
#ifdef USE_MEDIAINFO_STATIC
- MediaInfoLib::MediaInfo MI;
+ MediaInfoLib::MediaInfo MI;
#else
- MediaInfo MI;
+ MediaInfo MI;
#endif
- if (MI.Open(mi_fn.GetString())) {
- CString strFPS = MI.Get(Stream_Video, 0, _T("FrameRate"), Info_Text, Info_Name).c_str();
-
- // 3:2 pulldown ???
- CString strST = MI.Get(Stream_Video, 0, _T("ScanType"), Info_Text, Info_Name).c_str();
- CString strSO = MI.Get(Stream_Video, 0, _T("ScanOrder"), Info_Text, Info_Name).c_str();
-
- if (strFPS == _T("29.970") && (strSO == _T("2:3 Pulldown") || strST == _T("Progressive") && (strSO == _T("TFF") || strSO == _T("BFF") || strSO == _T("2:3 Pulldown"))) ) {
-
- strFPS = _T("23.976");
- }
- miFPS = wcstod(strFPS, NULL);
-
- AutoChangeMonitorMode();
- }
- }
-
- SetLoadState (MLS_LOADING);
-
- // FIXME: Don't show "Closed" initially
- PostMessage(WM_KICKIDLE);
-
- CString err;
-
- m_fUpdateInfoBar = false;
- BeginWaitCursor();
-
- try {
- CComPtr<IVMRMixerBitmap9> pVMB;
- CComPtr<IMFVideoMixerBitmap> pMFVMB;
- CComPtr<IMadVRTextOsd> pMVTO;
- if (m_fOpeningAborted) {
- throw (UINT)IDS_AG_ABORTED;
- }
-
- OpenCreateGraphObject(pOMD);
-
- if (m_fOpeningAborted) {
- throw (UINT)IDS_AG_ABORTED;
- }
-
- SetupIViAudReg();
-
- if (m_fOpeningAborted) {
- throw (UINT)IDS_AG_ABORTED;
- }
-
- if (pFileData) {
- OpenFile(pFileData);
- } else if (pDVDData) {
- OpenDVD(pDVDData);
- } else if (pDeviceData) {
- if (s.iDefaultCaptureDevice == 1) {
- HRESULT hr = OpenBDAGraph();
- if (FAILED(hr)) {
- throw (UINT)IDS_CAPTURE_ERROR_DEVICE;
- }
- } else {
- OpenCapture(pDeviceData);
- }
- } else {
- throw (UINT)IDS_INVALID_PARAMS_ERROR;
- }
-
- m_pCAP2 = NULL;
- m_pCAP = NULL;
-
- pGB->FindInterface(__uuidof(ISubPicAllocatorPresenter), (void**)&m_pCAP, TRUE);
- pGB->FindInterface(__uuidof(ISubPicAllocatorPresenter2), (void**)&m_pCAP2, TRUE);
- pGB->FindInterface(__uuidof(IVMRMixerControl9), (void**)&m_pMC, TRUE);
- pGB->FindInterface(__uuidof(IVMRMixerBitmap9), (void**)&pVMB, TRUE);
- pGB->FindInterface(__uuidof(IMFVideoMixerBitmap), (void**)&pMFVMB, TRUE);
- pMVTO = m_pCAP;
-
- if (s.fShowOSD || s.fShowDebugInfo) { // Force OSD on when the debug switch is used
- if (pMVTO) {
- m_OSD.Start(m_pVideoWnd, pMVTO);
- } else if (pVMB) {
- m_OSD.Start(m_pVideoWnd, pVMB);
- } else if (pMFVMB) {
- m_OSD.Start(m_pVideoWnd, pMFVMB);
- }
- }
-
- if (m_pMC) {
- m_pMC->GetProcAmpControlRange (0, AfxGetMyApp()->GetVMR9ColorControl(ProcAmp_Brightness));
- m_pMC->GetProcAmpControlRange (0, AfxGetMyApp()->GetVMR9ColorControl(ProcAmp_Contrast));
- m_pMC->GetProcAmpControlRange (0, AfxGetMyApp()->GetVMR9ColorControl(ProcAmp_Hue));
- m_pMC->GetProcAmpControlRange (0, AfxGetMyApp()->GetVMR9ColorControl(ProcAmp_Saturation));
- AfxGetMyApp()->UpdateColorControlRange(false);
- SetColorControl(ProcAmp_All, s.iBrightness, s.iContrast, s.iHue, s.iSaturation);
- }
-
- // === EVR !
- pGB->FindInterface(__uuidof(IMFVideoDisplayControl), (void**)&m_pMFVDC, TRUE);
- pGB->FindInterface(__uuidof(IMFVideoProcessor), (void**)&m_pMFVP, TRUE);
- if (m_pMFVDC) {
- RECT Rect;
- ::GetClientRect (m_pVideoWnd->m_hWnd, &Rect);
- m_pMFVDC->SetVideoWindow (m_pVideoWnd->m_hWnd);
- m_pMFVDC->SetVideoPosition(NULL, &Rect);
- }
- /*if (m_pMFVP) {
- //does not work at this location
- //need to choose the correct mode (IMFVideoProcessor::SetVideoProcessorMode)
- m_pMFVP->GetProcAmpRange(DXVA2_ProcAmp_Brightness, AfxGetMyApp()->GetEVRColorControl (Brightness));
- m_pMFVP->GetProcAmpRange(DXVA2_ProcAmp_Contrast, AfxGetMyApp()->GetEVRColorControl (Contrast));
- m_pMFVP->GetProcAmpRange(DXVA2_ProcAmp_Hue, AfxGetMyApp()->GetEVRColorControl (Hue));
- m_pMFVP->GetProcAmpRange(DXVA2_ProcAmp_Saturation, AfxGetMyApp()->GetEVRColorControl (Saturation));
- AfxGetMyApp()->UpdateColorControlRange(true);
- SetColorControl(ProcAmp_All, s.iBrightness, s.iContrast, s.iHue, s.iSaturation);
- }*/
-
- BeginEnumFilters(pGB, pEF, pBF) {
- if (m_pLN21 = pBF) {
- m_pLN21->SetServiceState(s.fClosedCaptions ? AM_L21_CCSTATE_On : AM_L21_CCSTATE_Off);
- break;
- }
- }
- EndEnumFilters;
-
- if (m_fOpeningAborted) {
- throw (UINT)IDS_AG_ABORTED;
- }
-
- OpenCustomizeGraph();
-
- if (m_fOpeningAborted) {
- throw (UINT)IDS_AG_ABORTED;
- }
-
- OpenSetupVideo();
-
- if (m_fOpeningAborted) {
- throw (UINT)IDS_AG_ABORTED;
- }
-
- OpenSetupAudio();
-
- if (m_fOpeningAborted) {
- throw (UINT)IDS_AG_ABORTED;
- }
-
- if (m_pCAP && (!m_fAudioOnly || m_fRealMediaGraph)) {
-
- if (s.fDisableInternalSubtitles) {
- m_pSubStreams.RemoveAll(); // Needs to be replaced with code that checks for forced subtitles.
- }
-
- if (s.fPrioritizeExternalSubtitles) {
- ATL::CInterfaceList<ISubStream, &__uuidof(ISubStream)> subs;
-
- while (!m_pSubStreams.IsEmpty()) {
- subs.AddTail(m_pSubStreams.RemoveHead());
- }
-
- POSITION pos = pOMD->subs.GetHeadPosition();
- while (pos) {
- LoadSubtitle(pOMD->subs.GetNext(pos));
- }
-
- extern ISubStream *InsertSubStream(CInterfaceList<ISubStream> *subStreams, const CComPtr<ISubStream> &theSubStream);
-
- CInterfaceList<ISubStream> pSubStreams;
- while (!subs.IsEmpty()) {
- InsertSubStream(&pSubStreams, subs.RemoveHead());
- }
-
- while (!pSubStreams.IsEmpty()) {
- m_pSubStreams.AddTail(pSubStreams.RemoveHead());
- }
- } else {
- POSITION pos = pOMD->subs.GetHeadPosition();
- while (pos) {
- LoadSubtitle(pOMD->subs.GetNext(pos));
- }
- }
-
- if (AfxGetAppSettings().fEnableSubtitles && m_pSubStreams.GetCount() > 0) {
- CComPtr<ISubStream> pSub = m_pSubStreams.GetHead();
- SetSubtitle(pSub);
- }
- }
-
- if (m_fOpeningAborted) {
- throw (UINT)IDS_AG_ABORTED;
- }
-
- OpenSetupWindowTitle(pOMD->title);
-
- if (s.fEnableEDLEditor) {
- m_wndEditListEditor.OpenFile(pOMD->title);
- }
-
- if (pFileData) {
- m_OpenFile = true;
- }
-
- if (::GetCurrentThreadId() == AfxGetApp()->m_nThreadID) {
- OnFilePostOpenmedia();
- } else {
- PostMessage(WM_COMMAND, ID_FILE_POST_OPENMEDIA);
- }
-
- while (m_iMediaLoadState != MLS_LOADED
- && m_iMediaLoadState != MLS_CLOSING // FIXME
- ) {
- Sleep(50);
- }
-
- SetupAudioStreams(); // reorder audio streams so that they're according to user's options
-
- // PostMessage instead of SendMessage because the user might call CloseMedia and then we would deadlock
-
- PostMessage(WM_COMMAND, ID_PLAY_PAUSE);
-
- b_firstPlay = true;
-
- if (!(AfxGetAppSettings().nCLSwitches&CLSW_OPEN) && (AfxGetAppSettings().nLoops > 0)) {
- PostMessage(WM_COMMAND, ID_PLAY_PLAY);
- } else {
- // If we don't start playing immediately, we need to initialize
- // the seekbar and the time counter.
- OnTimer(TIMER_STREAMPOSPOLLER);
- OnTimer(TIMER_STREAMPOSPOLLER2);
- }
-
- // Casimir666 : audio selection should be done before running the graph to prevent an
- // unnecessary seek when a file is opened (PostMessage ID_AUDIO_SUBITEM_START removed)
- if (m_iAudioStreams.GetCount() > 0) {
- OnPlayAudio (ID_AUDIO_SUBITEM_START + 1);
- }
-
- AfxGetAppSettings().nCLSwitches &= ~CLSW_OPEN;
-
- if (pFileData) {
- if (pFileData->rtStart > 0) {
- PostMessage(WM_RESUMEFROMSTATE, (WPARAM)PM_FILE, (LPARAM)(pFileData->rtStart/10000)); // REFERENCE_TIME doesn't fit in LPARAM under a 32bit env.
- }
- } else if (pDVDData) {
- if (pDVDData->pDvdState) {
- PostMessage(WM_RESUMEFROMSTATE, (WPARAM)PM_DVD, (LPARAM)(CComPtr<IDvdState>(pDVDData->pDvdState).Detach())); // must be released by the called message handler
- }
- } else if (pDeviceData) {
- m_wndCaptureBar.m_capdlg.SetVideoInput(pDeviceData->vinput);
- m_wndCaptureBar.m_capdlg.SetVideoChannel(pDeviceData->vchannel);
- m_wndCaptureBar.m_capdlg.SetAudioInput(pDeviceData->ainput);
- }
- } catch (LPCTSTR msg) {
- err = msg;
- } catch (CString msg) {
- err = msg;
- } catch (UINT msg) {
- err.LoadString(msg);
- }
-
- EndWaitCursor();
-
- if (!err.IsEmpty()) {
- CloseMediaPrivate();
- m_closingmsg = err;
-
- if (err != ResStr(IDS_AG_ABORTED)) {
- if (pFileData) {
- m_wndPlaylistBar.SetCurValid(false);
-
- if (m_wndPlaylistBar.IsAtEnd()) {
- m_nLoops++;
- }
-
- if (s.fLoopForever || m_nLoops < s.nLoops) {
- bool hasValidFile = false;
-
- if (flast_nID == ID_NAVIGATE_SKIPBACK) {
- hasValidFile = m_wndPlaylistBar.SetPrev();
- } else {
- hasValidFile = m_wndPlaylistBar.SetNext();
- }
-
- if (hasValidFile) {
- OpenCurPlaylistItem();
- }
- } else if (m_wndPlaylistBar.GetCount() > 1) {
- DoAfterPlaybackEvent();
- }
- } else {
- OnNavigateSkip(ID_NAVIGATE_SKIPFORWARD);
- }
- }
- } else {
- m_wndPlaylistBar.SetCurValid(true);
-
- // Apply command line audio shift
- if (s.rtShift != 0) {
- SetAudioDelay (s.rtShift);
- s.rtShift = 0;
- }
- }
-
- flast_nID = 0;
-
- if (AfxGetAppSettings().AutoChangeFullscrRes.bEnabled && m_fFullScreen) {
- AutoChangeMonitorMode();
- }
- if (m_fFullScreen && AfxGetAppSettings().fRememberZoomLevel) {
- m_fFirstFSAfterLaunchOnFS = true;
- }
-
- m_LastOpenFile = pOMD->title;
-
- PostMessage(WM_KICKIDLE); // calls main thread to update things
-
- if (!m_bIsBDPlay) {
- m_MPLSPlaylist.RemoveAll();
- m_LastOpenBDPath = _T("");
- }
- m_bIsBDPlay = false;
-
- return err.IsEmpty();
-}
+ if (MI.Open(mi_fn.GetString())) {
+ CString strFPS = MI.Get(Stream_Video, 0, _T("FrameRate"), Info_Text, Info_Name).c_str();
-void CMainFrame::CloseMediaPrivate()
-{
- SetLoadState (MLS_CLOSING);
+ // 3:2 pulldown ???
+ CString strST = MI.Get(Stream_Video, 0, _T("ScanType"), Info_Text, Info_Name).c_str();
+ CString strSO = MI.Get(Stream_Video, 0, _T("ScanOrder"), Info_Text, Info_Name).c_str();
- OnPlayStop(); // SendMessage(WM_COMMAND, ID_PLAY_STOP);
+ if (strFPS == _T("29.970") && (strSO == _T("2:3 Pulldown") || strST == _T("Progressive") && (strSO == _T("TFF") || strSO == _T("BFF") || strSO == _T("2:3 Pulldown")))) {
- SetPlaybackMode(PM_NONE);
+ strFPS = _T("23.976");
+ }
+ miFPS = wcstod(strFPS, NULL);
- m_fLiveWM = false;
+ AutoChangeMonitorMode();
+ }
+ }
- m_fEndOfStream = false;
+ SetLoadState(MLS_LOADING);
+
+ // FIXME: Don't show "Closed" initially
+ PostMessage(WM_KICKIDLE);
+
+ CString err;
+
+ m_fUpdateInfoBar = false;
+ BeginWaitCursor();
+
+ try {
+ CComPtr<IVMRMixerBitmap9> pVMB;
+ CComPtr<IMFVideoMixerBitmap> pMFVMB;
+ CComPtr<IMadVRTextOsd> pMVTO;
+ if (m_fOpeningAborted) {
+ throw(UINT)IDS_AG_ABORTED;
+ }
+
+ OpenCreateGraphObject(pOMD);
+
+ if (m_fOpeningAborted) {
+ throw(UINT)IDS_AG_ABORTED;
+ }
+
+ SetupIViAudReg();
+
+ if (m_fOpeningAborted) {
+ throw(UINT)IDS_AG_ABORTED;
+ }
+
+ if (pFileData) {
+ OpenFile(pFileData);
+ } else if (pDVDData) {
+ OpenDVD(pDVDData);
+ } else if (pDeviceData) {
+ if (s.iDefaultCaptureDevice == 1) {
+ HRESULT hr = OpenBDAGraph();
+ if (FAILED(hr)) {
+ throw(UINT)IDS_CAPTURE_ERROR_DEVICE;
+ }
+ } else {
+ OpenCapture(pDeviceData);
+ }
+ } else {
+ throw(UINT)IDS_INVALID_PARAMS_ERROR;
+ }
+
+ m_pCAP2 = NULL;
+ m_pCAP = NULL;
+
+ pGB->FindInterface(__uuidof(ISubPicAllocatorPresenter), (void**)&m_pCAP, TRUE);
+ pGB->FindInterface(__uuidof(ISubPicAllocatorPresenter2), (void**)&m_pCAP2, TRUE);
+ pGB->FindInterface(__uuidof(IVMRMixerControl9), (void**)&m_pMC, TRUE);
+ pGB->FindInterface(__uuidof(IVMRMixerBitmap9), (void**)&pVMB, TRUE);
+ pGB->FindInterface(__uuidof(IMFVideoMixerBitmap), (void**)&pMFVMB, TRUE);
+ pMVTO = m_pCAP;
+
+ if (s.fShowOSD || s.fShowDebugInfo) { // Force OSD on when the debug switch is used
+ if (pMVTO) {
+ m_OSD.Start(m_pVideoWnd, pMVTO);
+ } else if (pVMB) {
+ m_OSD.Start(m_pVideoWnd, pVMB);
+ } else if (pMFVMB) {
+ m_OSD.Start(m_pVideoWnd, pMFVMB);
+ }
+ }
+
+ if (m_pMC) {
+ m_pMC->GetProcAmpControlRange(0, AfxGetMyApp()->GetVMR9ColorControl(ProcAmp_Brightness));
+ m_pMC->GetProcAmpControlRange(0, AfxGetMyApp()->GetVMR9ColorControl(ProcAmp_Contrast));
+ m_pMC->GetProcAmpControlRange(0, AfxGetMyApp()->GetVMR9ColorControl(ProcAmp_Hue));
+ m_pMC->GetProcAmpControlRange(0, AfxGetMyApp()->GetVMR9ColorControl(ProcAmp_Saturation));
+ AfxGetMyApp()->UpdateColorControlRange(false);
+ SetColorControl(ProcAmp_All, s.iBrightness, s.iContrast, s.iHue, s.iSaturation);
+ }
+
+ // === EVR !
+ pGB->FindInterface(__uuidof(IMFVideoDisplayControl), (void**)&m_pMFVDC, TRUE);
+ pGB->FindInterface(__uuidof(IMFVideoProcessor), (void**)&m_pMFVP, TRUE);
+ if (m_pMFVDC) {
+ RECT Rect;
+ ::GetClientRect(m_pVideoWnd->m_hWnd, &Rect);
+ m_pMFVDC->SetVideoWindow(m_pVideoWnd->m_hWnd);
+ m_pMFVDC->SetVideoPosition(NULL, &Rect);
+ }
+ /*if (m_pMFVP) {
+ //does not work at this location
+ //need to choose the correct mode (IMFVideoProcessor::SetVideoProcessorMode)
+ m_pMFVP->GetProcAmpRange(DXVA2_ProcAmp_Brightness, AfxGetMyApp()->GetEVRColorControl (Brightness));
+ m_pMFVP->GetProcAmpRange(DXVA2_ProcAmp_Contrast, AfxGetMyApp()->GetEVRColorControl (Contrast));
+ m_pMFVP->GetProcAmpRange(DXVA2_ProcAmp_Hue, AfxGetMyApp()->GetEVRColorControl (Hue));
+ m_pMFVP->GetProcAmpRange(DXVA2_ProcAmp_Saturation, AfxGetMyApp()->GetEVRColorControl (Saturation));
+ AfxGetMyApp()->UpdateColorControlRange(true);
+ SetColorControl(ProcAmp_All, s.iBrightness, s.iContrast, s.iHue, s.iSaturation);
+ }*/
+
+ BeginEnumFilters(pGB, pEF, pBF) {
+ if (m_pLN21 = pBF) {
+ m_pLN21->SetServiceState(s.fClosedCaptions ? AM_L21_CCSTATE_On : AM_L21_CCSTATE_Off);
+ break;
+ }
+ }
+ EndEnumFilters;
+
+ if (m_fOpeningAborted) {
+ throw(UINT)IDS_AG_ABORTED;
+ }
+
+ OpenCustomizeGraph();
+
+ if (m_fOpeningAborted) {
+ throw(UINT)IDS_AG_ABORTED;
+ }
+
+ OpenSetupVideo();
+
+ if (m_fOpeningAborted) {
+ throw(UINT)IDS_AG_ABORTED;
+ }
+
+ OpenSetupAudio();
+
+ if (m_fOpeningAborted) {
+ throw(UINT)IDS_AG_ABORTED;
+ }
+
+ if (m_pCAP && (!m_fAudioOnly || m_fRealMediaGraph)) {
+
+ if (s.fDisableInternalSubtitles) {
+ m_pSubStreams.RemoveAll(); // Needs to be replaced with code that checks for forced subtitles.
+ }
+
+ if (s.fPrioritizeExternalSubtitles) {
+ ATL::CInterfaceList<ISubStream, &__uuidof(ISubStream)> subs;
+
+ while (!m_pSubStreams.IsEmpty()) {
+ subs.AddTail(m_pSubStreams.RemoveHead());
+ }
+
+ POSITION pos = pOMD->subs.GetHeadPosition();
+ while (pos) {
+ LoadSubtitle(pOMD->subs.GetNext(pos));
+ }
+
+ extern ISubStream* InsertSubStream(CInterfaceList<ISubStream>* subStreams, const CComPtr<ISubStream>& theSubStream);
+
+ CInterfaceList<ISubStream> pSubStreams;
+ while (!subs.IsEmpty()) {
+ InsertSubStream(&pSubStreams, subs.RemoveHead());
+ }
+
+ while (!pSubStreams.IsEmpty()) {
+ m_pSubStreams.AddTail(pSubStreams.RemoveHead());
+ }
+ } else {
+ POSITION pos = pOMD->subs.GetHeadPosition();
+ while (pos) {
+ LoadSubtitle(pOMD->subs.GetNext(pos));
+ }
+ }
+
+ if (AfxGetAppSettings().fEnableSubtitles && m_pSubStreams.GetCount() > 0) {
+ CComPtr<ISubStream> pSub = m_pSubStreams.GetHead();
+ SetSubtitle(pSub);
+ }
+ }
+
+ if (m_fOpeningAborted) {
+ throw(UINT)IDS_AG_ABORTED;
+ }
+
+ OpenSetupWindowTitle(pOMD->title);
+
+ if (s.fEnableEDLEditor) {
+ m_wndEditListEditor.OpenFile(pOMD->title);
+ }
+
+ if (pFileData) {
+ m_OpenFile = true;
+ }
+
+ if (::GetCurrentThreadId() == AfxGetApp()->m_nThreadID) {
+ OnFilePostOpenmedia();
+ } else {
+ PostMessage(WM_COMMAND, ID_FILE_POST_OPENMEDIA);
+ }
+
+ while (m_iMediaLoadState != MLS_LOADED
+ && m_iMediaLoadState != MLS_CLOSING // FIXME
+ ) {
+ Sleep(50);
+ }
+
+ SetupAudioStreams(); // reorder audio streams so that they're according to user's options
+
+ // PostMessage instead of SendMessage because the user might call CloseMedia and then we would deadlock
+
+ PostMessage(WM_COMMAND, ID_PLAY_PAUSE);
+
+ b_firstPlay = true;
+
+ if (!(AfxGetAppSettings().nCLSwitches & CLSW_OPEN) && (AfxGetAppSettings().nLoops > 0)) {
+ PostMessage(WM_COMMAND, ID_PLAY_PLAY);
+ } else {
+ // If we don't start playing immediately, we need to initialize
+ // the seekbar and the time counter.
+ OnTimer(TIMER_STREAMPOSPOLLER);
+ OnTimer(TIMER_STREAMPOSPOLLER2);
+ }
+
+ // Casimir666 : audio selection should be done before running the graph to prevent an
+ // unnecessary seek when a file is opened (PostMessage ID_AUDIO_SUBITEM_START removed)
+ if (m_iAudioStreams.GetCount() > 0) {
+ OnPlayAudio(ID_AUDIO_SUBITEM_START + 1);
+ }
+
+ AfxGetAppSettings().nCLSwitches &= ~CLSW_OPEN;
+
+ if (pFileData) {
+ if (pFileData->rtStart > 0) {
+ PostMessage(WM_RESUMEFROMSTATE, (WPARAM)PM_FILE, (LPARAM)(pFileData->rtStart / 10000)); // REFERENCE_TIME doesn't fit in LPARAM under a 32bit env.
+ }
+ } else if (pDVDData) {
+ if (pDVDData->pDvdState) {
+ PostMessage(WM_RESUMEFROMSTATE, (WPARAM)PM_DVD, (LPARAM)(CComPtr<IDvdState>(pDVDData->pDvdState).Detach())); // must be released by the called message handler
+ }
+ } else if (pDeviceData) {
+ m_wndCaptureBar.m_capdlg.SetVideoInput(pDeviceData->vinput);
+ m_wndCaptureBar.m_capdlg.SetVideoChannel(pDeviceData->vchannel);
+ m_wndCaptureBar.m_capdlg.SetAudioInput(pDeviceData->ainput);
+ }
+ } catch (LPCTSTR msg) {
+ err = msg;
+ } catch (CString msg) {
+ err = msg;
+ } catch (UINT msg) {
+ err.LoadString(msg);
+ }
+
+ EndWaitCursor();
+
+ if (!err.IsEmpty()) {
+ CloseMediaPrivate();
+ m_closingmsg = err;
+
+ if (err != ResStr(IDS_AG_ABORTED)) {
+ if (pFileData) {
+ m_wndPlaylistBar.SetCurValid(false);
+
+ if (m_wndPlaylistBar.IsAtEnd()) {
+ m_nLoops++;
+ }
+
+ if (s.fLoopForever || m_nLoops < s.nLoops) {
+ bool hasValidFile = false;
+
+ if (flast_nID == ID_NAVIGATE_SKIPBACK) {
+ hasValidFile = m_wndPlaylistBar.SetPrev();
+ } else {
+ hasValidFile = m_wndPlaylistBar.SetNext();
+ }
+
+ if (hasValidFile) {
+ OpenCurPlaylistItem();
+ }
+ } else if (m_wndPlaylistBar.GetCount() > 1) {
+ DoAfterPlaybackEvent();
+ }
+ } else {
+ OnNavigateSkip(ID_NAVIGATE_SKIPFORWARD);
+ }
+ }
+ } else {
+ m_wndPlaylistBar.SetCurValid(true);
+
+ // Apply command line audio shift
+ if (s.rtShift != 0) {
+ SetAudioDelay(s.rtShift);
+ s.rtShift = 0;
+ }
+ }
- m_rtDurationOverride = -1;
+ flast_nID = 0;
- m_kfs.RemoveAll();
+ if (AfxGetAppSettings().AutoChangeFullscrRes.bEnabled && m_fFullScreen) {
+ AutoChangeMonitorMode();
+ }
+ if (m_fFullScreen && AfxGetAppSettings().fRememberZoomLevel) {
+ m_fFirstFSAfterLaunchOnFS = true;
+ }
- m_pCB = NULL;
+ m_LastOpenFile = pOMD->title;
- //if (pVW) pVW->put_Visible(OAFALSE);
- //if (pVW) pVW->put_MessageDrain((OAHWND)NULL), pVW->put_Owner((OAHWND)NULL);
+ PostMessage(WM_KICKIDLE); // calls main thread to update things
- m_pCAP = NULL; // IMPORTANT: IVMRSurfaceAllocatorNotify/IVMRSurfaceAllocatorNotify9 has to be released before the VMR/VMR9, otherwise it will crash in Release()
- m_pCAP2 = NULL;
- m_pMC = NULL;
- m_pMFVP = NULL;
- m_pMFVDC = NULL;
- m_pLN21 = NULL;
- m_pSyncClock = NULL;
- m_OSD.Stop();
+ if (!m_bIsBDPlay) {
+ m_MPLSPlaylist.RemoveAll();
+ m_LastOpenBDPath = _T("");
+ }
+ m_bIsBDPlay = false;
- pAMXBar.Release();
- pAMTuner.Release();
- pAMDF.Release();
- pAMVCCap.Release();
- pAMVCPrev.Release();
- pAMVSCCap.Release();
- pAMVSCPrev.Release();
- pAMASC.Release();
- pVidCap.Release();
- pAudCap.Release();
- pCGB.Release();
- pDVDC.Release();
- pDVDI.Release();
- pQP.Release();
- pBI.Release();
- pAMOP.Release();
- pFS.Release();
- pMC.Release();
- pME.Release();
- pMS.Release();
- pVW.Release();
- pBV.Release();
- pBA.Release();
+ return err.IsEmpty();
+}
- if (pGB) {
- pGB->RemoveFromROT();
- pGB.Release();
- }
+void CMainFrame::CloseMediaPrivate()
+{
+ SetLoadState(MLS_CLOSING);
+
+ OnPlayStop(); // SendMessage(WM_COMMAND, ID_PLAY_STOP);
+
+ SetPlaybackMode(PM_NONE);
+
+ m_fLiveWM = false;
+
+ m_fEndOfStream = false;
+
+ m_rtDurationOverride = -1;
+
+ m_kfs.RemoveAll();
+
+ m_pCB = NULL;
+
+ //if (pVW) pVW->put_Visible(OAFALSE);
+ //if (pVW) pVW->put_MessageDrain((OAHWND)NULL), pVW->put_Owner((OAHWND)NULL);
+
+ m_pCAP = NULL; // IMPORTANT: IVMRSurfaceAllocatorNotify/IVMRSurfaceAllocatorNotify9 has to be released before the VMR/VMR9, otherwise it will crash in Release()
+ m_pCAP2 = NULL;
+ m_pMC = NULL;
+ m_pMFVP = NULL;
+ m_pMFVDC = NULL;
+ m_pLN21 = NULL;
+ m_pSyncClock = NULL;
+ m_OSD.Stop();
+
+ pAMXBar.Release();
+ pAMTuner.Release();
+ pAMDF.Release();
+ pAMVCCap.Release();
+ pAMVCPrev.Release();
+ pAMVSCCap.Release();
+ pAMVSCPrev.Release();
+ pAMASC.Release();
+ pVidCap.Release();
+ pAudCap.Release();
+ pCGB.Release();
+ pDVDC.Release();
+ pDVDI.Release();
+ pQP.Release();
+ pBI.Release();
+ pAMOP.Release();
+ pFS.Release();
+ pMC.Release();
+ pME.Release();
+ pMS.Release();
+ pVW.Release();
+ pBV.Release();
+ pBA.Release();
+
+ if (pGB) {
+ pGB->RemoveFromROT();
+ pGB.Release();
+ }
- if (m_pFullscreenWnd->IsWindow()) {
- m_pFullscreenWnd->DestroyWindow(); // TODO : still freezing sometimes...
- }
+ if (m_pFullscreenWnd->IsWindow()) {
+ m_pFullscreenWnd->DestroyWindow(); // TODO : still freezing sometimes...
+ }
- m_fRealMediaGraph = m_fShockwaveGraph = m_fQuicktimeGraph = false;
+ m_fRealMediaGraph = m_fShockwaveGraph = m_fQuicktimeGraph = false;
- m_pSubClock = NULL;
+ m_pSubClock = NULL;
- m_pProv.Release();
+ m_pProv.Release();
- {
- CAutoLock cAutoLock(&m_csSubLock);
- m_pSubStreams.RemoveAll();
- }
+ {
+ CAutoLock cAutoLock(&m_csSubLock);
+ m_pSubStreams.RemoveAll();
+ }
- m_VidDispName.Empty();
- m_AudDispName.Empty();
+ m_VidDispName.Empty();
+ m_AudDispName.Empty();
- m_closingmsg.LoadString(IDS_CONTROLS_CLOSED);
+ m_closingmsg.LoadString(IDS_CONTROLS_CLOSED);
- AfxGetAppSettings().nCLSwitches &= CLSW_OPEN|CLSW_PLAY|CLSW_AFTERPLAYBACK_MASK|CLSW_NOFOCUS;
- AfxGetAppSettings().ResetPositions();
+ AfxGetAppSettings().nCLSwitches &= CLSW_OPEN | CLSW_PLAY | CLSW_AFTERPLAYBACK_MASK | CLSW_NOFOCUS;
+ AfxGetAppSettings().ResetPositions();
- SetLoadState (MLS_CLOSED);
+ SetLoadState(MLS_CLOSED);
}
-void CMainFrame::ParseDirs(CAtlList<CString>& sl) {
- POSITION pos = sl.GetHeadPosition();
+void CMainFrame::ParseDirs(CAtlList<CString>& sl)
+{
+ POSITION pos = sl.GetHeadPosition();
- while (pos) {
- CString fn = sl.GetNext(pos);
- WIN32_FIND_DATA fd = {0};
- HANDLE hFind = FindFirstFile(fn, &fd);
+ while (pos) {
+ CString fn = sl.GetNext(pos);
+ WIN32_FIND_DATA fd = {0};
+ HANDLE hFind = FindFirstFile(fn, &fd);
- if (hFind != INVALID_HANDLE_VALUE) {
- if (fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) {
- if (fn[fn.GetLength()-1] != '\\') {
- fn += '\\';
- }
+ if (hFind != INVALID_HANDLE_VALUE) {
+ if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+ if (fn[fn.GetLength() - 1] != '\\') {
+ fn += '\\';
+ }
- COpenDirHelper::RecurseAddDir(fn, &sl);
- }
+ COpenDirHelper::RecurseAddDir(fn, &sl);
+ }
- FindClose(hFind);
- }
- }
+ FindClose(hFind);
+ }
+ }
}
static bool SearchInDirCompare(const CString& str1, const CString& str2)
{
- return (StrCmpLogicalW(str1, str2) < 0);
+ return (StrCmpLogicalW(str1, str2) < 0);
}
bool CMainFrame::SearchInDir(bool bDirForward)
{
- CStringArray files;
+ CStringArray files;
- CMediaFormats& mf = AfxGetAppSettings().m_Formats;
+ CMediaFormats& mf = AfxGetAppSettings().m_Formats;
- CString mask = m_LastOpenFile.Left(m_LastOpenFile.ReverseFind(_T('\\')) + 1) + _T("*.*");
- CFileFind finder;
- BOOL bHasNext = finder.FindFile(mask);
+ CString mask = m_LastOpenFile.Left(m_LastOpenFile.ReverseFind(_T('\\')) + 1) + _T("*.*");
+ CFileFind finder;
+ BOOL bHasNext = finder.FindFile(mask);
- while (bHasNext) {
- bHasNext = finder.FindNextFile();
+ while (bHasNext) {
+ bHasNext = finder.FindNextFile();
- if (!finder.IsDirectory()) {
- CString path = finder.GetFilePath();
- CString ext = path.Mid(path.ReverseFind('.'));
- if (mf.FindExt(ext)) {
- files.Add(path);
- }
- }
- }
-
- finder.Close();
+ if (!finder.IsDirectory()) {
+ CString path = finder.GetFilePath();
+ CString ext = path.Mid(path.ReverseFind('.'));
+ if (mf.FindExt(ext)) {
+ files.Add(path);
+ }
+ }
+ }
- if (files.GetCount() <= 1) {
- return false;
- }
+ finder.Close();
- std::sort(files.GetData(), files.GetData() + files.GetCount(), SearchInDirCompare);
+ if (files.GetCount() <= 1) {
+ return false;
+ }
- INT_PTR current = -1;
- for (INT_PTR i = 0, l = files.GetCount(); i < l && current < 0; i++) {
- if (m_LastOpenFile.CompareNoCase(files[i]) == 0) {
- current = i;
- }
- }
+ std::sort(files.GetData(), files.GetData() + files.GetCount(), SearchInDirCompare);
- if (current < 0) {
- return false;
- }
+ INT_PTR current = -1;
+ for (INT_PTR i = 0, l = files.GetCount(); i < l && current < 0; i++) {
+ if (m_LastOpenFile.CompareNoCase(files[i]) == 0) {
+ current = i;
+ }
+ }
- CAtlList<CString> sl;
+ if (current < 0) {
+ return false;
+ }
- if (bDirForward) {
- current++;
- if (current >= files.GetCount()) {
- return false;
- }
- } else {
- current--;
- if (current < 0) {
- return false;
- }
- }
+ CAtlList<CString> sl;
+
+ if (bDirForward) {
+ current++;
+ if (current >= files.GetCount()) {
+ return false;
+ }
+ } else {
+ current--;
+ if (current < 0) {
+ return false;
+ }
+ }
- sl.AddHead(files[current]);
- m_wndPlaylistBar.Open(sl, false);
- OpenCurPlaylistItem();
+ sl.AddHead(files[current]);
+ m_wndPlaylistBar.Open(sl, false);
+ OpenCurPlaylistItem();
- return true;
+ return true;
}
void CMainFrame::DoTunerScan(TunerScanData* pTSD)
{
- if (GetPlaybackMode() == PM_CAPTURE) {
- CComQIPtr<IBDATuner> pTun = pGB;
- if (pTun) {
- BOOLEAN bPresent;
- BOOLEAN bLocked;
- LONG lStrength;
- LONG lQuality;
- int nProgress;
- int nOffset = pTSD->Offset ? 3 : 1;
- LONG lOffsets[3] = {0, pTSD->Offset, -pTSD->Offset};
- bool bSucceeded;
- m_bStopTunerScan = false;
-
- for (ULONG ulFrequency = pTSD->FrequencyStart; ulFrequency <= pTSD->FrequencyStop; ulFrequency += pTSD->Bandwidth) {
- bSucceeded = false;
- for (int nOffsetPos = 0; nOffsetPos < nOffset && !bSucceeded; nOffsetPos++) {
- pTun->SetFrequency (ulFrequency + lOffsets[nOffsetPos]);
- Sleep (200);
- if (SUCCEEDED (pTun->GetStats (bPresent, bLocked, lStrength, lQuality)) && bPresent) {
- ::SendMessage (pTSD->Hwnd, WM_TUNER_STATS, lStrength, lQuality);
- pTun->Scan (ulFrequency + lOffsets[nOffsetPos], pTSD->Hwnd);
- bSucceeded = true;
- }
- }
-
- nProgress = MulDiv(ulFrequency-pTSD->FrequencyStart, 100, pTSD->FrequencyStop-pTSD->FrequencyStart);
- ::SendMessage (pTSD->Hwnd, WM_TUNER_SCAN_PROGRESS, nProgress,0);
- ::SendMessage (pTSD->Hwnd, WM_TUNER_STATS, lStrength, lQuality);
-
- if (m_bStopTunerScan) {
- break;
- }
- }
-
- ::SendMessage (pTSD->Hwnd, WM_TUNER_SCAN_END, 0, 0);
- }
- }
+ if (GetPlaybackMode() == PM_CAPTURE) {
+ CComQIPtr<IBDATuner> pTun = pGB;
+ if (pTun) {
+ BOOLEAN bPresent;
+ BOOLEAN bLocked;
+ LONG lStrength;
+ LONG lQuality;
+ int nProgress;
+ int nOffset = pTSD->Offset ? 3 : 1;
+ LONG lOffsets[3] = {0, pTSD->Offset, -pTSD->Offset};
+ bool bSucceeded;
+ m_bStopTunerScan = false;
+
+ for (ULONG ulFrequency = pTSD->FrequencyStart; ulFrequency <= pTSD->FrequencyStop; ulFrequency += pTSD->Bandwidth) {
+ bSucceeded = false;
+ for (int nOffsetPos = 0; nOffsetPos < nOffset && !bSucceeded; nOffsetPos++) {
+ pTun->SetFrequency(ulFrequency + lOffsets[nOffsetPos]);
+ Sleep(200);
+ if (SUCCEEDED(pTun->GetStats(bPresent, bLocked, lStrength, lQuality)) && bPresent) {
+ ::SendMessage(pTSD->Hwnd, WM_TUNER_STATS, lStrength, lQuality);
+ pTun->Scan(ulFrequency + lOffsets[nOffsetPos], pTSD->Hwnd);
+ bSucceeded = true;
+ }
+ }
+
+ nProgress = MulDiv(ulFrequency - pTSD->FrequencyStart, 100, pTSD->FrequencyStop - pTSD->FrequencyStart);
+ ::SendMessage(pTSD->Hwnd, WM_TUNER_SCAN_PROGRESS, nProgress, 0);
+ ::SendMessage(pTSD->Hwnd, WM_TUNER_STATS, lStrength, lQuality);
+
+ if (m_bStopTunerScan) {
+ break;
+ }
+ }
+
+ ::SendMessage(pTSD->Hwnd, WM_TUNER_SCAN_END, 0, 0);
+ }
+ }
}
// msn
void CMainFrame::SendNowPlayingToMSN()
{
- if (!AfxGetAppSettings().fNotifyMSN) {
- return;
- }
-
- CString title, author;
-
- if (m_iMediaLoadState == MLS_LOADED) {
- m_wndInfoBar.GetLine(ResStr(IDS_INFOBAR_TITLE), title);
- m_wndInfoBar.GetLine(ResStr(IDS_INFOBAR_AUTHOR), author);
-
- if (title.IsEmpty()) {
- CPlaylistItem pli;
- m_wndPlaylistBar.GetCur(pli);
-
- if (!pli.m_fns.IsEmpty()) {
- CString label = !pli.m_label.IsEmpty() ? pli.m_label : pli.m_fns.GetHead();
-
- if (GetPlaybackMode() == PM_FILE) {
- CString fn = label;
- if (fn.Find(_T("://")) >= 0) {
- int i = fn.Find('?');
- if (i >= 0) {
- fn = fn.Left(i);
- }
- }
- CPath path(fn);
- path.StripPath();
- path.MakePretty();
- path.RemoveExtension();
- title = (LPCTSTR)path;
- author.Empty();
- } else if (GetPlaybackMode() == PM_CAPTURE) {
- title = label != pli.m_fns.GetHead() ? label : ResStr(IDS_CAPTURE_LIVE);
- author.Empty();
- } else if (GetPlaybackMode() == PM_DVD) {
- title = _T("DVD");
- author.Empty();
- }
- }
- }
- }
-
- CStringW buff;
- buff += L"\\0Music\\0";
- buff += title.IsEmpty() ? L"0" : L"1";
- buff += L"\\0";
- buff += author.IsEmpty() ? L"{0}" : L"{0} - {1}";
- buff += L"\\0";
- if (!author.IsEmpty()) {
- buff += CStringW(author) + L"\\0";
- }
- buff += CStringW(title) + L"\\0";
- buff += L"\\0\\0";
-
- COPYDATASTRUCT data;
- data.dwData = 0x0547;
- data.lpData = (PVOID)(LPCWSTR)buff;
- data.cbData = buff.GetLength() * 2 + 2;
-
- HWND hWnd = ::FindWindowEx(NULL, NULL, _T("MsnMsgrUIManager"), NULL);
- while (hWnd) {
- ::SendMessage(hWnd, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&data);
- hWnd = ::FindWindowEx(NULL, hWnd, _T("MsnMsgrUIManager"), NULL);
- }
+ if (!AfxGetAppSettings().fNotifyMSN) {
+ return;
+ }
+
+ CString title, author;
+
+ if (m_iMediaLoadState == MLS_LOADED) {
+ m_wndInfoBar.GetLine(ResStr(IDS_INFOBAR_TITLE), title);
+ m_wndInfoBar.GetLine(ResStr(IDS_INFOBAR_AUTHOR), author);
+
+ if (title.IsEmpty()) {
+ CPlaylistItem pli;
+ m_wndPlaylistBar.GetCur(pli);
+
+ if (!pli.m_fns.IsEmpty()) {
+ CString label = !pli.m_label.IsEmpty() ? pli.m_label : pli.m_fns.GetHead();
+
+ if (GetPlaybackMode() == PM_FILE) {
+ CString fn = label;
+ if (fn.Find(_T("://")) >= 0) {
+ int i = fn.Find('?');
+ if (i >= 0) {
+ fn = fn.Left(i);
+ }
+ }
+ CPath path(fn);
+ path.StripPath();
+ path.MakePretty();
+ path.RemoveExtension();
+ title = (LPCTSTR)path;
+ author.Empty();
+ } else if (GetPlaybackMode() == PM_CAPTURE) {
+ title = label != pli.m_fns.GetHead() ? label : ResStr(IDS_CAPTURE_LIVE);
+ author.Empty();
+ } else if (GetPlaybackMode() == PM_DVD) {
+ title = _T("DVD");
+ author.Empty();
+ }
+ }
+ }
+ }
+
+ CStringW buff;
+ buff += L"\\0Music\\0";
+ buff += title.IsEmpty() ? L"0" : L"1";
+ buff += L"\\0";
+ buff += author.IsEmpty() ? L"{0}" : L"{0} - {1}";
+ buff += L"\\0";
+ if (!author.IsEmpty()) {
+ buff += CStringW(author) + L"\\0";
+ }
+ buff += CStringW(title) + L"\\0";
+ buff += L"\\0\\0";
+
+ COPYDATASTRUCT data;
+ data.dwData = 0x0547;
+ data.lpData = (PVOID)(LPCWSTR)buff;
+ data.cbData = buff.GetLength() * 2 + 2;
+
+ HWND hWnd = ::FindWindowEx(NULL, NULL, _T("MsnMsgrUIManager"), NULL);
+ while (hWnd) {
+ ::SendMessage(hWnd, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&data);
+ hWnd = ::FindWindowEx(NULL, hWnd, _T("MsnMsgrUIManager"), NULL);
+ }
}
@@ -12223,2294 +12218,2294 @@ void CMainFrame::SendNowPlayingToMSN()
void CMainFrame::SetupOpenCDSubMenu()
{
- CMenu* pSub = &m_opencds;
-
- if (!IsMenu(pSub->m_hMenu)) {
- pSub->CreatePopupMenu();
- } else while (pSub->RemoveMenu(0, MF_BYPOSITION)) {
- ;
- }
-
- if (m_iMediaLoadState == MLS_LOADING) {
- return;
- }
-
- if (AfxGetAppSettings().fHideCDROMsSubMenu) {
- return;
- }
-
- UINT id = ID_FILE_OPEN_CD_START;
-
- for (TCHAR drive = 'C'; drive <= 'Z'; drive++) {
- CString label = GetDriveLabel(drive), str;
-
- CAtlList<CString> files;
- switch (GetCDROMType(drive, files)) {
- case CDROM_Audio:
- if (label.IsEmpty()) {
- label = _T("Audio CD");
- }
- str.Format(_T("%s (%c:)"), label, drive);
- break;
- case CDROM_VideoCD:
- if (label.IsEmpty()) {
- label = _T("(S)VCD");
- }
- str.Format(_T("%s (%c:)"), label, drive);
- break;
- case CDROM_DVDVideo:
- if (label.IsEmpty()) {
- label = _T("DVD Video");
- }
- str.Format(_T("%s (%c:)"), label, drive);
- break;
- default:
- break;
- }
-
- if (!str.IsEmpty()) {
- pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, id++, str);
- }
- }
+ CMenu* pSub = &m_opencds;
+
+ if (!IsMenu(pSub->m_hMenu)) {
+ pSub->CreatePopupMenu();
+ } else while (pSub->RemoveMenu(0, MF_BYPOSITION)) {
+ ;
+ }
+
+ if (m_iMediaLoadState == MLS_LOADING) {
+ return;
+ }
+
+ if (AfxGetAppSettings().fHideCDROMsSubMenu) {
+ return;
+ }
+
+ UINT id = ID_FILE_OPEN_CD_START;
+
+ for (TCHAR drive = 'C'; drive <= 'Z'; drive++) {
+ CString label = GetDriveLabel(drive), str;
+
+ CAtlList<CString> files;
+ switch (GetCDROMType(drive, files)) {
+ case CDROM_Audio:
+ if (label.IsEmpty()) {
+ label = _T("Audio CD");
+ }
+ str.Format(_T("%s (%c:)"), label, drive);
+ break;
+ case CDROM_VideoCD:
+ if (label.IsEmpty()) {
+ label = _T("(S)VCD");
+ }
+ str.Format(_T("%s (%c:)"), label, drive);
+ break;
+ case CDROM_DVDVideo:
+ if (label.IsEmpty()) {
+ label = _T("DVD Video");
+ }
+ str.Format(_T("%s (%c:)"), label, drive);
+ break;
+ default:
+ break;
+ }
+
+ if (!str.IsEmpty()) {
+ pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, id++, str);
+ }
+ }
}
void CMainFrame::SetupFiltersSubMenu()
{
- CMenu* pSub = &m_filters;
-
- if (!IsMenu(pSub->m_hMenu)) {
- pSub->CreatePopupMenu();
- } else while (pSub->RemoveMenu(0, MF_BYPOSITION)) {
- ;
- }
-
- m_filterpopups.RemoveAll();
-
- m_pparray.RemoveAll();
- m_ssarray.RemoveAll();
-
- if (m_iMediaLoadState == MLS_LOADED) {
- UINT idf = 0;
- UINT ids = ID_FILTERS_SUBITEM_START;
- UINT idl = ID_FILTERSTREAMS_SUBITEM_START;
-
- BeginEnumFilters(pGB, pEF, pBF) {
- CString name(GetFilterName(pBF));
- if (name.GetLength() >= 43) {
- name = name.Left(40) + _T("...");
- }
-
- CLSID clsid = GetCLSID(pBF);
- if (clsid == CLSID_AVIDec) {
- CComPtr<IPin> pPin = GetFirstPin(pBF);
- AM_MEDIA_TYPE mt;
- if (pPin && SUCCEEDED(pPin->ConnectionMediaType(&mt))) {
- DWORD c = ((VIDEOINFOHEADER*)mt.pbFormat)->bmiHeader.biCompression;
- switch (c) {
- case BI_RGB:
- name += _T(" (RGB)");
- break;
- case BI_RLE4:
- name += _T(" (RLE4)");
- break;
- case BI_RLE8:
- name += _T(" (RLE8)");
- break;
- case BI_BITFIELDS:
- name += _T(" (BITF)");
- break;
- default:
- name.Format(_T("%s (%c%c%c%c)"),
- CString(name), (TCHAR)((c>>0)&0xff), (TCHAR)((c>>8)&0xff), (TCHAR)((c>>16)&0xff), (TCHAR)((c>>24)&0xff));
- break;
- }
- }
- } else if (clsid == CLSID_ACMWrapper) {
- CComPtr<IPin> pPin = GetFirstPin(pBF);
- AM_MEDIA_TYPE mt;
- if (pPin && SUCCEEDED(pPin->ConnectionMediaType(&mt))) {
- WORD c = ((WAVEFORMATEX*)mt.pbFormat)->wFormatTag;
- name.Format(_T("%s (0x%04x)"), CString(name), (int)c);
- }
- } else if (clsid == __uuidof(CTextPassThruFilter) || clsid == __uuidof(CNullTextRenderer)
- || clsid == GUIDFromCString(_T("{48025243-2D39-11CE-875D-00608CB78066}"))) { // ISCR
- // hide these
- continue;
- }
-
- CAutoPtr<CMenu> pSubSub(DNew CMenu);
- pSubSub->CreatePopupMenu();
-
- int nPPages = 0;
-
- CComQIPtr<ISpecifyPropertyPages> pSPP = pBF;
-
- /* if (pSPP)
- {
- CAUUID caGUID;
- caGUID.pElems = NULL;
- if (SUCCEEDED(pSPP->GetPages(&caGUID)) && caGUID.cElems > 0)
- {
- */
- m_pparray.Add(pBF);
- pSubSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ids, ResStr(IDS_MAINFRM_116));
- /*
- if (caGUID.pElems) CoTaskMemFree(caGUID.pElems);
- */
- nPPages++;
- /* }
- }
- */
- BeginEnumPins(pBF, pEP, pPin) {
- CString name = GetPinName(pPin);
- name.Replace(_T("&"), _T("&&"));
-
- if (pSPP = pPin) {
- CAUUID caGUID;
- caGUID.pElems = NULL;
- if (SUCCEEDED(pSPP->GetPages(&caGUID)) && caGUID.cElems > 0) {
- m_pparray.Add(pPin);
- pSubSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ids+nPPages, name + ResStr(IDS_MAINFRM_117));
-
- if (caGUID.pElems) {
- CoTaskMemFree(caGUID.pElems);
- }
-
- nPPages++;
- }
- }
- }
- EndEnumPins;
-
- CComQIPtr<IAMStreamSelect> pSS = pBF;
- if (pSS) {
- DWORD nStreams = 0;
- DWORD flags = (DWORD)-1;
- DWORD group = (DWORD)-1;
- DWORD prevgroup = (DWORD)-1;
- LCID lcid;
- WCHAR* wname = NULL;
- CComPtr<IUnknown> pObj, pUnk;
-
- pSS->Count(&nStreams);
-
- if (nStreams > 0 && nPPages > 0) {
- pSubSub->AppendMenu(MF_SEPARATOR|MF_ENABLED);
- }
-
- UINT idlstart = idl;
-
- for (DWORD i = 0; i < nStreams; i++, pObj = NULL, pUnk = NULL) {
- m_ssarray.Add(pSS);
-
- flags = group = 0;
- wname = NULL;
- pSS->Info(i, NULL, &flags, &lcid, &group, &wname, &pObj, &pUnk);
-
- if (group != prevgroup && idl > idlstart) {
- pSubSub->AppendMenu(MF_SEPARATOR|MF_ENABLED);
- }
- prevgroup = group;
-
- if (flags & AMSTREAMSELECTINFO_EXCLUSIVE) {
- } else if (flags & AMSTREAMSELECTINFO_ENABLED) {
- }
-
- if (!wname) {
- CStringW stream(ResStr(IDS_AG_UNKNOWN_STREAM));
- size_t count = stream.GetLength()+3+1;
- wname = (WCHAR*)CoTaskMemAlloc(count*sizeof(WCHAR));
- swprintf_s(wname, count, L"%s %d", stream, min(i+1,999));
- }
-
- CString name(wname);
- name.Replace(_T("&"), _T("&&"));
-
- pSubSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, idl++, name);
-
- CoTaskMemFree(wname);
- }
-
- if (nStreams == 0) {
- pSS.Release();
- }
- }
-
- if (nPPages == 1 && !pSS) {
- pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ids, name);
- } else {
- pSub->AppendMenu(MF_BYPOSITION|MF_STRING|MF_DISABLED|MF_GRAYED, idf, name);
-
- if (nPPages > 0 || pSS) {
- MENUITEMINFO mii;
- mii.cbSize = sizeof(mii);
- mii.fMask = MIIM_STATE|MIIM_SUBMENU;
- mii.fType = MF_POPUP;
- mii.hSubMenu = pSubSub->m_hMenu;
- mii.fState = (pSPP || pSS) ? MF_ENABLED : (MF_DISABLED|MF_GRAYED);
- pSub->SetMenuItemInfo(idf, &mii, TRUE);
-
- m_filterpopups.Add(pSubSub);
- }
- }
-
- ids += nPPages;
- idf++;
- }
- EndEnumFilters;
- }
+ CMenu* pSub = &m_filters;
+
+ if (!IsMenu(pSub->m_hMenu)) {
+ pSub->CreatePopupMenu();
+ } else while (pSub->RemoveMenu(0, MF_BYPOSITION)) {
+ ;
+ }
+
+ m_filterpopups.RemoveAll();
+
+ m_pparray.RemoveAll();
+ m_ssarray.RemoveAll();
+
+ if (m_iMediaLoadState == MLS_LOADED) {
+ UINT idf = 0;
+ UINT ids = ID_FILTERS_SUBITEM_START;
+ UINT idl = ID_FILTERSTREAMS_SUBITEM_START;
+
+ BeginEnumFilters(pGB, pEF, pBF) {
+ CString name(GetFilterName(pBF));
+ if (name.GetLength() >= 43) {
+ name = name.Left(40) + _T("...");
+ }
+
+ CLSID clsid = GetCLSID(pBF);
+ if (clsid == CLSID_AVIDec) {
+ CComPtr<IPin> pPin = GetFirstPin(pBF);
+ AM_MEDIA_TYPE mt;
+ if (pPin && SUCCEEDED(pPin->ConnectionMediaType(&mt))) {
+ DWORD c = ((VIDEOINFOHEADER*)mt.pbFormat)->bmiHeader.biCompression;
+ switch (c) {
+ case BI_RGB:
+ name += _T(" (RGB)");
+ break;
+ case BI_RLE4:
+ name += _T(" (RLE4)");
+ break;
+ case BI_RLE8:
+ name += _T(" (RLE8)");
+ break;
+ case BI_BITFIELDS:
+ name += _T(" (BITF)");
+ break;
+ default:
+ name.Format(_T("%s (%c%c%c%c)"),
+ CString(name), (TCHAR)((c >> 0) & 0xff), (TCHAR)((c >> 8) & 0xff), (TCHAR)((c >> 16) & 0xff), (TCHAR)((c >> 24) & 0xff));
+ break;
+ }
+ }
+ } else if (clsid == CLSID_ACMWrapper) {
+ CComPtr<IPin> pPin = GetFirstPin(pBF);
+ AM_MEDIA_TYPE mt;
+ if (pPin && SUCCEEDED(pPin->ConnectionMediaType(&mt))) {
+ WORD c = ((WAVEFORMATEX*)mt.pbFormat)->wFormatTag;
+ name.Format(_T("%s (0x%04x)"), CString(name), (int)c);
+ }
+ } else if (clsid == __uuidof(CTextPassThruFilter) || clsid == __uuidof(CNullTextRenderer)
+ || clsid == GUIDFromCString(_T("{48025243-2D39-11CE-875D-00608CB78066}"))) { // ISCR
+ // hide these
+ continue;
+ }
+
+ CAutoPtr<CMenu> pSubSub(DNew CMenu);
+ pSubSub->CreatePopupMenu();
+
+ int nPPages = 0;
+
+ CComQIPtr<ISpecifyPropertyPages> pSPP = pBF;
+
+ /* if (pSPP)
+ {
+ CAUUID caGUID;
+ caGUID.pElems = NULL;
+ if (SUCCEEDED(pSPP->GetPages(&caGUID)) && caGUID.cElems > 0)
+ {
+ */
+ m_pparray.Add(pBF);
+ pSubSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ids, ResStr(IDS_MAINFRM_116));
+ /*
+ if (caGUID.pElems) CoTaskMemFree(caGUID.pElems);
+ */
+ nPPages++;
+ /* }
+ }
+ */
+ BeginEnumPins(pBF, pEP, pPin) {
+ CString name = GetPinName(pPin);
+ name.Replace(_T("&"), _T("&&"));
+
+ if (pSPP = pPin) {
+ CAUUID caGUID;
+ caGUID.pElems = NULL;
+ if (SUCCEEDED(pSPP->GetPages(&caGUID)) && caGUID.cElems > 0) {
+ m_pparray.Add(pPin);
+ pSubSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ids + nPPages, name + ResStr(IDS_MAINFRM_117));
+
+ if (caGUID.pElems) {
+ CoTaskMemFree(caGUID.pElems);
+ }
+
+ nPPages++;
+ }
+ }
+ }
+ EndEnumPins;
+
+ CComQIPtr<IAMStreamSelect> pSS = pBF;
+ if (pSS) {
+ DWORD nStreams = 0;
+ DWORD flags = (DWORD) - 1;
+ DWORD group = (DWORD) - 1;
+ DWORD prevgroup = (DWORD) - 1;
+ LCID lcid;
+ WCHAR* wname = NULL;
+ CComPtr<IUnknown> pObj, pUnk;
+
+ pSS->Count(&nStreams);
+
+ if (nStreams > 0 && nPPages > 0) {
+ pSubSub->AppendMenu(MF_SEPARATOR | MF_ENABLED);
+ }
+
+ UINT idlstart = idl;
+
+ for (DWORD i = 0; i < nStreams; i++, pObj = NULL, pUnk = NULL) {
+ m_ssarray.Add(pSS);
+
+ flags = group = 0;
+ wname = NULL;
+ pSS->Info(i, NULL, &flags, &lcid, &group, &wname, &pObj, &pUnk);
+
+ if (group != prevgroup && idl > idlstart) {
+ pSubSub->AppendMenu(MF_SEPARATOR | MF_ENABLED);
+ }
+ prevgroup = group;
+
+ if (flags & AMSTREAMSELECTINFO_EXCLUSIVE) {
+ } else if (flags & AMSTREAMSELECTINFO_ENABLED) {
+ }
+
+ if (!wname) {
+ CStringW stream(ResStr(IDS_AG_UNKNOWN_STREAM));
+ size_t count = stream.GetLength() + 3 + 1;
+ wname = (WCHAR*)CoTaskMemAlloc(count * sizeof(WCHAR));
+ swprintf_s(wname, count, L"%s %d", stream, min(i + 1, 999));
+ }
+
+ CString name(wname);
+ name.Replace(_T("&"), _T("&&"));
+
+ pSubSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, idl++, name);
+
+ CoTaskMemFree(wname);
+ }
+
+ if (nStreams == 0) {
+ pSS.Release();
+ }
+ }
+
+ if (nPPages == 1 && !pSS) {
+ pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ids, name);
+ } else {
+ pSub->AppendMenu(MF_BYPOSITION | MF_STRING | MF_DISABLED | MF_GRAYED, idf, name);
+
+ if (nPPages > 0 || pSS) {
+ MENUITEMINFO mii;
+ mii.cbSize = sizeof(mii);
+ mii.fMask = MIIM_STATE | MIIM_SUBMENU;
+ mii.fType = MF_POPUP;
+ mii.hSubMenu = pSubSub->m_hMenu;
+ mii.fState = (pSPP || pSS) ? MF_ENABLED : (MF_DISABLED | MF_GRAYED);
+ pSub->SetMenuItemInfo(idf, &mii, TRUE);
+
+ m_filterpopups.Add(pSubSub);
+ }
+ }
+
+ ids += nPPages;
+ idf++;
+ }
+ EndEnumFilters;
+ }
}
void CMainFrame::SetupLanguageMenu()
{
- const AppSettings& s = AfxGetAppSettings();
+ const AppSettings& s = AfxGetAppSettings();
- if (!IsMenu(m_language.m_hMenu)) {
- m_language.CreatePopupMenu();
- } else {
- // Empty the menu
- while (m_language.RemoveMenu(0, MF_BYPOSITION));
- }
+ if (!IsMenu(m_language.m_hMenu)) {
+ m_language.CreatePopupMenu();
+ } else {
+ // Empty the menu
+ while (m_language.RemoveMenu(0, MF_BYPOSITION));
+ }
- UINT uiCount = 0;
- CFileStatus fs;
- CString appPath;
- GetModuleFileName(AfxGetInstanceHandle(), appPath.GetBuffer(_MAX_PATH), _MAX_PATH);
- appPath.ReleaseBuffer();
- appPath = appPath.Left(appPath.ReverseFind(_T('\\')) + 1);
+ UINT uiCount = 0;
+ CFileStatus fs;
+ CString appPath;
+ GetModuleFileName(AfxGetInstanceHandle(), appPath.GetBuffer(_MAX_PATH), _MAX_PATH);
+ appPath.ReleaseBuffer();
+ appPath = appPath.Left(appPath.ReverseFind(_T('\\')) + 1);
- for (size_t i = 0; i < CMPlayerCApp::languageResourcesCount; i++) {
- const LanguageResource& lr = CMPlayerCApp::languageResources[i];
+ for (size_t i = 0; i < CMPlayerCApp::languageResourcesCount; i++) {
+ const LanguageResource& lr = CMPlayerCApp::languageResources[i];
- if (lr.dllPath == NULL || CFile::GetStatus(appPath + lr.dllPath, fs)) {
- m_language.AppendMenu(MF_STRING | MF_ENABLED, lr.resourceID, lr.name);
+ if (lr.dllPath == NULL || CFile::GetStatus(appPath + lr.dllPath, fs)) {
+ m_language.AppendMenu(MF_STRING | MF_ENABLED, lr.resourceID, lr.name);
- if (lr.localeID == s.language) {
- m_language.CheckMenuItem(uiCount, MF_BYPOSITION | MF_CHECKED);
- }
+ if (lr.localeID == s.language) {
+ m_language.CheckMenuItem(uiCount, MF_BYPOSITION | MF_CHECKED);
+ }
- uiCount++;
- }
- }
+ uiCount++;
+ }
+ }
- if (uiCount <= 1) {
- m_language.RemoveMenu(0, MF_BYPOSITION);
- }
+ if (uiCount <= 1) {
+ m_language.RemoveMenu(0, MF_BYPOSITION);
+ }
}
void CMainFrame::SetupAudioSwitcherSubMenu()
{
- CMenu* pSub = &m_audios;
-
- if (!IsMenu(pSub->m_hMenu)) {
- pSub->CreatePopupMenu();
- } else while (pSub->RemoveMenu(0, MF_BYPOSITION)) {
- ;
- }
+ CMenu* pSub = &m_audios;
+
+ if (!IsMenu(pSub->m_hMenu)) {
+ pSub->CreatePopupMenu();
+ } else while (pSub->RemoveMenu(0, MF_BYPOSITION)) {
+ ;
+ }
+
+ if (m_iMediaLoadState == MLS_LOADED) {
+ UINT id = ID_AUDIO_SUBITEM_START;
+
+ CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
+ if (!pSS) {
+ pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB);
+ }
+
+ if (pSS) {
+ DWORD cStreams = 0;
+ if (SUCCEEDED(pSS->Count(&cStreams)) && cStreams > 0) {
+ pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, id++, ResStr(IDS_SUBTITLES_OPTIONS));
+ pSub->AppendMenu(MF_SEPARATOR | MF_ENABLED);
+
+ for (int i = 0; i < (int)cStreams; i++) {
+ WCHAR* pName = NULL;
+ POSITION idx = m_iAudioStreams.FindIndex(i);
+ int iStream = m_iAudioStreams.GetAt(idx);
+ if (FAILED(pSS->Info(iStream, NULL, NULL, NULL, NULL, &pName, NULL, NULL))) { // audio streams are reordered, so find the index from the initial order
+ break;
+ }
+
+ CString name(pName);
+ name.Replace(_T("&"), _T("&&"));
+
+ pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, id++, name);
+
+ CoTaskMemFree(pName);
+ }
+ }
+ }
+ }
+}
- if (m_iMediaLoadState == MLS_LOADED) {
- UINT id = ID_AUDIO_SUBITEM_START;
+void CMainFrame::SetupSubtitlesSubMenu()
+{
+ CMenu* pSub = &m_subtitles;
- CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
- if (!pSS) {
- pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB);
- }
+ if (!IsMenu(pSub->m_hMenu)) {
+ pSub->CreatePopupMenu();
+ } else while (pSub->RemoveMenu(0, MF_BYPOSITION)) {
+ ;
+ }
- if (pSS) {
- DWORD cStreams = 0;
- if (SUCCEEDED(pSS->Count(&cStreams)) && cStreams > 0) {
- pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, id++, ResStr(IDS_SUBTITLES_OPTIONS));
- pSub->AppendMenu(MF_SEPARATOR|MF_ENABLED);
+ if (m_iMediaLoadState != MLS_LOADED || m_fAudioOnly || !m_pCAP) {
+ return;
+ }
- for (int i = 0; i < (int)cStreams; i++) {
- WCHAR* pName = NULL;
- POSITION idx = m_iAudioStreams.FindIndex(i);
- int iStream = m_iAudioStreams.GetAt(idx);
- if (FAILED(pSS->Info(iStream, NULL, NULL, NULL, NULL, &pName, NULL, NULL))) { // audio streams are reordered, so find the index from the initial order
- break;
- }
+ UINT id = ID_SUBTITLES_SUBITEM_START;
- CString name(pName);
- name.Replace(_T("&"), _T("&&"));
+ POSITION pos = m_pSubStreams.GetHeadPosition();
- pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, id++, name);
+ if (pos) {
+ pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, id++, ResStr(IDS_SUBTITLES_OPTIONS));
+ pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, id++, ResStr(IDS_SUBTITLES_STYLES));
+ pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, id++, ResStr(IDS_SUBTITLES_RELOAD));
+ pSub->AppendMenu(MF_SEPARATOR);
- CoTaskMemFree(pName);
- }
- }
- }
- }
-}
+ pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, id++, ResStr(IDS_SUBTITLES_ENABLE));
+ pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, id++, ResStr(IDS_SUBTITLES_DEFAULT_STYLE));
+ pSub->AppendMenu(MF_SEPARATOR);
+ }
-void CMainFrame::SetupSubtitlesSubMenu()
-{
- CMenu* pSub = &m_subtitles;
-
- if (!IsMenu(pSub->m_hMenu)) {
- pSub->CreatePopupMenu();
- } else while (pSub->RemoveMenu(0, MF_BYPOSITION)) {
- ;
- }
-
- if (m_iMediaLoadState != MLS_LOADED || m_fAudioOnly || !m_pCAP) {
- return;
- }
-
- UINT id = ID_SUBTITLES_SUBITEM_START;
-
- POSITION pos = m_pSubStreams.GetHeadPosition();
-
- if (pos) {
- pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, id++, ResStr(IDS_SUBTITLES_OPTIONS));
- pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, id++, ResStr(IDS_SUBTITLES_STYLES));
- pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, id++, ResStr(IDS_SUBTITLES_RELOAD));
- pSub->AppendMenu(MF_SEPARATOR);
-
- pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, id++, ResStr(IDS_SUBTITLES_ENABLE));
- pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, id++, ResStr(IDS_SUBTITLES_DEFAULT_STYLE));
- pSub->AppendMenu(MF_SEPARATOR);
- }
-
- while (pos) {
- CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
- if (!pSubStream) {
- continue;
- }
-
- for (int i = 0, j = pSubStream->GetStreamCount(); i < j; i++) {
- WCHAR* pName = NULL;
- if (SUCCEEDED(pSubStream->GetStreamInfo(i, &pName, NULL))) {
- CString name(pName);
- name.Replace(_T("&"), _T("&&"));
-
- pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, id++, name);
- CoTaskMemFree(pName);
- } else {
- pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, id++, ResStr(IDS_AG_UNKNOWN));
- }
- }
-
- // TODO: find a better way to group these entries
- if (pos && m_pSubStreams.GetAt(pos)) {
- CLSID cur, next;
- pSubStream->GetClassID(&cur);
- m_pSubStreams.GetAt(pos)->GetClassID(&next);
-
- if (cur != next) {
- pSub->AppendMenu(MF_SEPARATOR);
- }
- }
- }
+ while (pos) {
+ CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
+ if (!pSubStream) {
+ continue;
+ }
+
+ for (int i = 0, j = pSubStream->GetStreamCount(); i < j; i++) {
+ WCHAR* pName = NULL;
+ if (SUCCEEDED(pSubStream->GetStreamInfo(i, &pName, NULL))) {
+ CString name(pName);
+ name.Replace(_T("&"), _T("&&"));
+
+ pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, id++, name);
+ CoTaskMemFree(pName);
+ } else {
+ pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, id++, ResStr(IDS_AG_UNKNOWN));
+ }
+ }
+
+ // TODO: find a better way to group these entries
+ if (pos && m_pSubStreams.GetAt(pos)) {
+ CLSID cur, next;
+ pSubStream->GetClassID(&cur);
+ m_pSubStreams.GetAt(pos)->GetClassID(&next);
+
+ if (cur != next) {
+ pSub->AppendMenu(MF_SEPARATOR);
+ }
+ }
+ }
}
void CMainFrame::SetupNavAudioSubMenu()
{
- CMenu* pSub = &m_navaudio;
-
- if (!IsMenu(pSub->m_hMenu)) {
- pSub->CreatePopupMenu();
- } else while (pSub->RemoveMenu(0, MF_BYPOSITION)) {
- ;
- }
-
- if (m_iMediaLoadState != MLS_LOADED) {
- return;
- }
-
- UINT id = ID_NAVIGATE_AUDIO_SUBITEM_START;
-
- if (GetPlaybackMode() == PM_FILE || (GetPlaybackMode() == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1)) {
- SetupNavStreamSelectSubMenu(pSub, id, 1);
- } else if (GetPlaybackMode() == PM_DVD) {
- ULONG ulStreamsAvailable, ulCurrentStream;
- if (FAILED(pDVDI->GetCurrentAudio(&ulStreamsAvailable, &ulCurrentStream))) {
- return;
- }
-
- LCID DefLanguage;
- DVD_AUDIO_LANG_EXT ext;
- if (FAILED(pDVDI->GetDefaultAudioLanguage(&DefLanguage, &ext))) {
- return;
- }
-
- for (ULONG i = 0; i < ulStreamsAvailable; i++) {
- LCID Language;
- if (FAILED(pDVDI->GetAudioLanguage(i, &Language))) {
- continue;
- }
-
- UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
- if (Language == DefLanguage) {
- flags |= MF_DEFAULT;
- }
- if (i == ulCurrentStream) {
- flags |= MF_CHECKED;
- }
-
- CString str;
- if (Language) {
- int len = GetLocaleInfo(Language, LOCALE_SENGLANGUAGE, str.GetBuffer(256), 256);
- str.ReleaseBufferSetLength(max(len-1, 0));
- } else {
- str.Format(IDS_AG_UNKNOWN, i+1);
- }
-
- DVD_AudioAttributes ATR;
- if (SUCCEEDED(pDVDI->GetAudioAttributes(i, &ATR))) {
- switch (ATR.LanguageExtension) {
- case DVD_AUD_EXT_NotSpecified:
- default:
- break;
- case DVD_AUD_EXT_Captions:
- str += _T(" (Captions)");
- break;
- case DVD_AUD_EXT_VisuallyImpaired:
- str += _T(" (Visually Impaired)");
- break;
- case DVD_AUD_EXT_DirectorComments1:
- str += ResStr(IDS_MAINFRM_121);
- break;
- case DVD_AUD_EXT_DirectorComments2:
- str += ResStr(IDS_MAINFRM_122);
- break;
- }
-
- CString format = GetDVDAudioFormatName(ATR);
-
- if (!format.IsEmpty()) {
- str.Format(IDS_MAINFRM_11,
- CString(str),
- format,
- ATR.dwFrequency,
- ATR.bQuantization,
- ATR.bNumberOfChannels,
- (ATR.bNumberOfChannels > 1 ? ResStr(IDS_MAINFRM_13) : ResStr(IDS_MAINFRM_12)));
- }
- }
-
- str.Replace(_T("&"), _T("&&"));
-
- pSub->AppendMenu(flags, id++, str);
- }
- }
+ CMenu* pSub = &m_navaudio;
+
+ if (!IsMenu(pSub->m_hMenu)) {
+ pSub->CreatePopupMenu();
+ } else while (pSub->RemoveMenu(0, MF_BYPOSITION)) {
+ ;
+ }
+
+ if (m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
+
+ UINT id = ID_NAVIGATE_AUDIO_SUBITEM_START;
+
+ if (GetPlaybackMode() == PM_FILE || (GetPlaybackMode() == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1)) {
+ SetupNavStreamSelectSubMenu(pSub, id, 1);
+ } else if (GetPlaybackMode() == PM_DVD) {
+ ULONG ulStreamsAvailable, ulCurrentStream;
+ if (FAILED(pDVDI->GetCurrentAudio(&ulStreamsAvailable, &ulCurrentStream))) {
+ return;
+ }
+
+ LCID DefLanguage;
+ DVD_AUDIO_LANG_EXT ext;
+ if (FAILED(pDVDI->GetDefaultAudioLanguage(&DefLanguage, &ext))) {
+ return;
+ }
+
+ for (ULONG i = 0; i < ulStreamsAvailable; i++) {
+ LCID Language;
+ if (FAILED(pDVDI->GetAudioLanguage(i, &Language))) {
+ continue;
+ }
+
+ UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
+ if (Language == DefLanguage) {
+ flags |= MF_DEFAULT;
+ }
+ if (i == ulCurrentStream) {
+ flags |= MF_CHECKED;
+ }
+
+ CString str;
+ if (Language) {
+ int len = GetLocaleInfo(Language, LOCALE_SENGLANGUAGE, str.GetBuffer(256), 256);
+ str.ReleaseBufferSetLength(max(len - 1, 0));
+ } else {
+ str.Format(IDS_AG_UNKNOWN, i + 1);
+ }
+
+ DVD_AudioAttributes ATR;
+ if (SUCCEEDED(pDVDI->GetAudioAttributes(i, &ATR))) {
+ switch (ATR.LanguageExtension) {
+ case DVD_AUD_EXT_NotSpecified:
+ default:
+ break;
+ case DVD_AUD_EXT_Captions:
+ str += _T(" (Captions)");
+ break;
+ case DVD_AUD_EXT_VisuallyImpaired:
+ str += _T(" (Visually Impaired)");
+ break;
+ case DVD_AUD_EXT_DirectorComments1:
+ str += ResStr(IDS_MAINFRM_121);
+ break;
+ case DVD_AUD_EXT_DirectorComments2:
+ str += ResStr(IDS_MAINFRM_122);
+ break;
+ }
+
+ CString format = GetDVDAudioFormatName(ATR);
+
+ if (!format.IsEmpty()) {
+ str.Format(IDS_MAINFRM_11,
+ CString(str),
+ format,
+ ATR.dwFrequency,
+ ATR.bQuantization,
+ ATR.bNumberOfChannels,
+ (ATR.bNumberOfChannels > 1 ? ResStr(IDS_MAINFRM_13) : ResStr(IDS_MAINFRM_12)));
+ }
+ }
+
+ str.Replace(_T("&"), _T("&&"));
+
+ pSub->AppendMenu(flags, id++, str);
+ }
+ }
}
void CMainFrame::SetupNavSubtitleSubMenu()
{
- CMenu* pSub = &m_navsubtitle;
-
- if (!IsMenu(pSub->m_hMenu)) {
- pSub->CreatePopupMenu();
- } else while (pSub->RemoveMenu(0, MF_BYPOSITION)) {
- ;
- }
-
- if (m_iMediaLoadState != MLS_LOADED) {
- return;
- }
-
- UINT id = ID_NAVIGATE_SUBP_SUBITEM_START;
-
- if (GetPlaybackMode() == PM_FILE || (GetPlaybackMode() == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1)) {
- SetupNavStreamSelectSubMenu(pSub, id, 2);
- } else if (GetPlaybackMode() == PM_DVD) {
- ULONG ulStreamsAvailable, ulCurrentStream;
- BOOL bIsDisabled;
- if (FAILED(pDVDI->GetCurrentSubpicture(&ulStreamsAvailable, &ulCurrentStream, &bIsDisabled))
- || ulStreamsAvailable == 0) {
- return;
- }
-
- LCID DefLanguage;
- DVD_SUBPICTURE_LANG_EXT ext;
- if (FAILED(pDVDI->GetDefaultSubpictureLanguage(&DefLanguage, &ext))) {
- return;
- }
-
- pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|(bIsDisabled?0:MF_CHECKED), id++, ResStr(IDS_AG_ENABLED));
- pSub->AppendMenu(MF_BYCOMMAND|MF_SEPARATOR|MF_ENABLED);
-
- for (ULONG i = 0; i < ulStreamsAvailable; i++) {
- LCID Language;
- if (FAILED(pDVDI->GetSubpictureLanguage(i, &Language))) {
- continue;
- }
-
- UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
- if (Language == DefLanguage) {
- flags |= MF_DEFAULT;
- }
- if (i == ulCurrentStream) {
- flags |= MF_CHECKED;
- }
-
- CString str;
- if (Language) {
- int len = GetLocaleInfo(Language, LOCALE_SENGLANGUAGE, str.GetBuffer(256), 256);
- str.ReleaseBufferSetLength(max(len-1, 0));
- } else {
- str.Format(IDS_AG_UNKNOWN, i+1);
- }
-
- DVD_SubpictureAttributes ATR;
- if (SUCCEEDED(pDVDI->GetSubpictureAttributes(i, &ATR))) {
- switch (ATR.LanguageExtension) {
- case DVD_SP_EXT_NotSpecified:
- default:
- break;
- case DVD_SP_EXT_Caption_Normal:
- str += _T("");
- break;
- case DVD_SP_EXT_Caption_Big:
- str += _T(" (Big)");
- break;
- case DVD_SP_EXT_Caption_Children:
- str += _T(" (Children)");
- break;
- case DVD_SP_EXT_CC_Normal:
- str += _T(" (CC)");
- break;
- case DVD_SP_EXT_CC_Big:
- str += _T(" (CC Big)");
- break;
- case DVD_SP_EXT_CC_Children:
- str += _T(" (CC Children)");
- break;
- case DVD_SP_EXT_Forced:
- str += _T(" (Forced)");
- break;
- case DVD_SP_EXT_DirectorComments_Normal:
- str += _T(" (Director Comments)");
- break;
- case DVD_SP_EXT_DirectorComments_Big:
- str += _T(" (Director Comments, Big)");
- break;
- case DVD_SP_EXT_DirectorComments_Children:
- str += _T(" (Director Comments, Children)");
- break;
- }
- }
-
- str.Replace(_T("&"), _T("&&"));
-
- pSub->AppendMenu(flags, id++, str);
- }
- }
+ CMenu* pSub = &m_navsubtitle;
+
+ if (!IsMenu(pSub->m_hMenu)) {
+ pSub->CreatePopupMenu();
+ } else while (pSub->RemoveMenu(0, MF_BYPOSITION)) {
+ ;
+ }
+
+ if (m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
+
+ UINT id = ID_NAVIGATE_SUBP_SUBITEM_START;
+
+ if (GetPlaybackMode() == PM_FILE || (GetPlaybackMode() == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1)) {
+ SetupNavStreamSelectSubMenu(pSub, id, 2);
+ } else if (GetPlaybackMode() == PM_DVD) {
+ ULONG ulStreamsAvailable, ulCurrentStream;
+ BOOL bIsDisabled;
+ if (FAILED(pDVDI->GetCurrentSubpicture(&ulStreamsAvailable, &ulCurrentStream, &bIsDisabled))
+ || ulStreamsAvailable == 0) {
+ return;
+ }
+
+ LCID DefLanguage;
+ DVD_SUBPICTURE_LANG_EXT ext;
+ if (FAILED(pDVDI->GetDefaultSubpictureLanguage(&DefLanguage, &ext))) {
+ return;
+ }
+
+ pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | (bIsDisabled ? 0 : MF_CHECKED), id++, ResStr(IDS_AG_ENABLED));
+ pSub->AppendMenu(MF_BYCOMMAND | MF_SEPARATOR | MF_ENABLED);
+
+ for (ULONG i = 0; i < ulStreamsAvailable; i++) {
+ LCID Language;
+ if (FAILED(pDVDI->GetSubpictureLanguage(i, &Language))) {
+ continue;
+ }
+
+ UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
+ if (Language == DefLanguage) {
+ flags |= MF_DEFAULT;
+ }
+ if (i == ulCurrentStream) {
+ flags |= MF_CHECKED;
+ }
+
+ CString str;
+ if (Language) {
+ int len = GetLocaleInfo(Language, LOCALE_SENGLANGUAGE, str.GetBuffer(256), 256);
+ str.ReleaseBufferSetLength(max(len - 1, 0));
+ } else {
+ str.Format(IDS_AG_UNKNOWN, i + 1);
+ }
+
+ DVD_SubpictureAttributes ATR;
+ if (SUCCEEDED(pDVDI->GetSubpictureAttributes(i, &ATR))) {
+ switch (ATR.LanguageExtension) {
+ case DVD_SP_EXT_NotSpecified:
+ default:
+ break;
+ case DVD_SP_EXT_Caption_Normal:
+ str += _T("");
+ break;
+ case DVD_SP_EXT_Caption_Big:
+ str += _T(" (Big)");
+ break;
+ case DVD_SP_EXT_Caption_Children:
+ str += _T(" (Children)");
+ break;
+ case DVD_SP_EXT_CC_Normal:
+ str += _T(" (CC)");
+ break;
+ case DVD_SP_EXT_CC_Big:
+ str += _T(" (CC Big)");
+ break;
+ case DVD_SP_EXT_CC_Children:
+ str += _T(" (CC Children)");
+ break;
+ case DVD_SP_EXT_Forced:
+ str += _T(" (Forced)");
+ break;
+ case DVD_SP_EXT_DirectorComments_Normal:
+ str += _T(" (Director Comments)");
+ break;
+ case DVD_SP_EXT_DirectorComments_Big:
+ str += _T(" (Director Comments, Big)");
+ break;
+ case DVD_SP_EXT_DirectorComments_Children:
+ str += _T(" (Director Comments, Children)");
+ break;
+ }
+ }
+
+ str.Replace(_T("&"), _T("&&"));
+
+ pSub->AppendMenu(flags, id++, str);
+ }
+ }
}
void CMainFrame::SetupNavAngleSubMenu()
{
- CMenu* pSub = &m_navangle;
+ CMenu* pSub = &m_navangle;
- if (!IsMenu(pSub->m_hMenu)) {
- pSub->CreatePopupMenu();
- } else while (pSub->RemoveMenu(0, MF_BYPOSITION)) {
- ;
- }
+ if (!IsMenu(pSub->m_hMenu)) {
+ pSub->CreatePopupMenu();
+ } else while (pSub->RemoveMenu(0, MF_BYPOSITION)) {
+ ;
+ }
- if (m_iMediaLoadState != MLS_LOADED) {
- return;
- }
+ if (m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
- UINT id = ID_NAVIGATE_ANGLE_SUBITEM_START;
+ UINT id = ID_NAVIGATE_ANGLE_SUBITEM_START;
- if (GetPlaybackMode() == PM_FILE) {
- SetupNavStreamSelectSubMenu(pSub, id, 0);
- } else if (GetPlaybackMode() == PM_DVD) {
- ULONG ulStreamsAvailable, ulCurrentStream;
- if (FAILED(pDVDI->GetCurrentAngle(&ulStreamsAvailable, &ulCurrentStream))) {
- return;
- }
+ if (GetPlaybackMode() == PM_FILE) {
+ SetupNavStreamSelectSubMenu(pSub, id, 0);
+ } else if (GetPlaybackMode() == PM_DVD) {
+ ULONG ulStreamsAvailable, ulCurrentStream;
+ if (FAILED(pDVDI->GetCurrentAngle(&ulStreamsAvailable, &ulCurrentStream))) {
+ return;
+ }
- if (ulStreamsAvailable < 2) {
- return; // one choice is not a choice...
- }
+ if (ulStreamsAvailable < 2) {
+ return; // one choice is not a choice...
+ }
- for (ULONG i = 1; i <= ulStreamsAvailable; i++) {
- UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
- if (i == ulCurrentStream) {
- flags |= MF_CHECKED;
- }
+ for (ULONG i = 1; i <= ulStreamsAvailable; i++) {
+ UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
+ if (i == ulCurrentStream) {
+ flags |= MF_CHECKED;
+ }
- CString str;
- str.Format(IDS_AG_ANGLE, i);
+ CString str;
+ str.Format(IDS_AG_ANGLE, i);
- pSub->AppendMenu(flags, id++, str);
- }
- }
+ pSub->AppendMenu(flags, id++, str);
+ }
+ }
}
static CString StripPath(CString path)
{
- CString p = path;
- p.Replace('\\', '/');
- p = p.Mid(p.ReverseFind('/')+1);
- return (p.IsEmpty() ? path : p);
+ CString p = path;
+ p.Replace('\\', '/');
+ p = p.Mid(p.ReverseFind('/') + 1);
+ return (p.IsEmpty() ? path : p);
}
void CMainFrame::SetupNavChaptersSubMenu()
{
- CMenu* pSub = &m_navchapters;
-
- if (!IsMenu(pSub->m_hMenu)) {
- pSub->CreatePopupMenu();
- } else while (pSub->RemoveMenu(0, MF_BYPOSITION)) {
- ;
- }
-
- if (m_iMediaLoadState != MLS_LOADED) {
- return;
- }
-
- UINT id = ID_NAVIGATE_CHAP_SUBITEM_START;
-
- if (GetPlaybackMode() == PM_FILE) {
- if (m_MPLSPlaylist.GetCount() > 1) {
- DWORD idx = 1;
- POSITION pos = m_MPLSPlaylist.GetHeadPosition();
- while (pos) {
- UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
- if (id != ID_NAVIGATE_CHAP_SUBITEM_START && pos == m_MPLSPlaylist.GetHeadPosition()) {
- //pSub->AppendMenu(MF_SEPARATOR);
- flags |= MF_MENUBARBREAK;
- }
- if (idx == MENUBARBREAK) {
- flags |= MF_MENUBARBREAK;
- idx = 0;
- }
- idx++;
-
- CHdmvClipInfo::PlaylistItem Item = m_MPLSPlaylist.GetNext(pos);
- CString time = _T("[") + ReftimeToString2(Item.Duration()) + _T("]");
- CString name = StripPath(Item.m_strFileName);
-
- if (name == m_wndPlaylistBar.m_pl.GetHead().GetLabel()) {
- flags |= MF_CHECKED;
- }
-
- name.Replace(_T("&"), _T("&&"));
- pSub->AppendMenu(flags, id++, name + '\t' + time);
- }
- }
-
- SetupChapters();
- REFERENCE_TIME rt = GetPos();
- DWORD j = m_pCB->ChapLookup(&rt, NULL);
-
- if (m_pCB->ChapGetCount() > 1) {
- for (DWORD i = 0, idx = 0; i < m_pCB->ChapGetCount(); i++, id++, idx++) {
- rt = 0;
- CComBSTR bstr;
- if (FAILED(m_pCB->ChapGet(i, &rt, &bstr))) {
- continue;
- }
-
- CString time = _T("[") + ReftimeToString2(rt) + _T("]");
-
- CString name = CString(bstr);
- name.Replace(_T("&"), _T("&&"));
- name.Replace(_T("\t"), _T(" "));
-
- UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
- if (i == j) {
- flags |= MF_CHECKED;
- }
-
- if (idx == MENUBARBREAK) {
- flags |= MF_MENUBARBREAK;
- idx = 0;
- }
-
- if (id != ID_NAVIGATE_CHAP_SUBITEM_START && i == 0) {
- //pSub->AppendMenu(MF_SEPARATOR);
- if (m_MPLSPlaylist.GetCount() > 1) {
- flags |= MF_MENUBARBREAK;
- }
- }
- pSub->AppendMenu(flags, id, name + '\t' + time);
- }
- }
-
- if (m_wndPlaylistBar.GetCount() > 1) {
- POSITION pos = m_wndPlaylistBar.m_pl.GetHeadPosition();
- while (pos) {
- UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
- if (pos == m_wndPlaylistBar.m_pl.GetPos()) {
- flags |= MF_CHECKED;
- }
- if (id != ID_NAVIGATE_CHAP_SUBITEM_START && pos == m_wndPlaylistBar.m_pl.GetHeadPosition()) {
- pSub->AppendMenu(MF_SEPARATOR);
- }
- CPlaylistItem& pli = m_wndPlaylistBar.m_pl.GetNext(pos);
- CString name = pli.GetLabel();
- name.Replace(_T("&"), _T("&&"));
- pSub->AppendMenu(flags, id++, name);
- }
- }
-
- } else if (GetPlaybackMode() == PM_DVD) {
- ULONG ulNumOfVolumes, ulVolume;
- DVD_DISC_SIDE Side;
- ULONG ulNumOfTitles = 0;
- pDVDI->GetDVDVolumeInfo(&ulNumOfVolumes, &ulVolume, &Side, &ulNumOfTitles);
-
- DVD_PLAYBACK_LOCATION2 Location;
- pDVDI->GetCurrentLocation(&Location);
-
- ULONG ulNumOfChapters = 0;
- pDVDI->GetNumberOfChapters(Location.TitleNum, &ulNumOfChapters);
-
- ULONG ulUOPs = 0;
- pDVDI->GetCurrentUOPS(&ulUOPs);
-
- for (ULONG i = 1; i <= ulNumOfTitles; i++) {
- UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
- if (i == Location.TitleNum) {
- flags |= MF_CHECKED;
- }
- if (ulUOPs&UOP_FLAG_Play_Title) {
- flags |= MF_DISABLED|MF_GRAYED;
- }
-
- CString str;
- str.Format(IDS_AG_TITLE, i);
-
- pSub->AppendMenu(flags, id++, str);
- }
-
- for (ULONG i = 1; i <= ulNumOfChapters; i++) {
- UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
- if (i == Location.ChapterNum) {
- flags |= MF_CHECKED;
- }
- if (ulUOPs&UOP_FLAG_Play_Chapter) {
- flags |= MF_DISABLED|MF_GRAYED;
- }
- if (i == 1) {
- flags |= MF_MENUBARBREAK;
- }
-
- CString str;
- str.Format(IDS_AG_CHAPTER, i);
-
- pSub->AppendMenu(flags, id++, str);
- }
- } else if (GetPlaybackMode() == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1) {
- AppSettings& s = AfxGetAppSettings();
-
- POSITION pos = s.m_DVBChannels.GetHeadPosition();
- while (pos) {
- CDVBChannel& Channel = s.m_DVBChannels.GetNext(pos);
- UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
-
- if ((UINT)Channel.GetPrefNumber() == s.nDVBLastChannel) {
- flags |= MF_CHECKED;
- }
- pSub->AppendMenu(flags, ID_NAVIGATE_CHAP_SUBITEM_START + Channel.GetPrefNumber(), Channel.GetName());
- }
- }
+ CMenu* pSub = &m_navchapters;
+
+ if (!IsMenu(pSub->m_hMenu)) {
+ pSub->CreatePopupMenu();
+ } else while (pSub->RemoveMenu(0, MF_BYPOSITION)) {
+ ;
+ }
+
+ if (m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
+
+ UINT id = ID_NAVIGATE_CHAP_SUBITEM_START;
+
+ if (GetPlaybackMode() == PM_FILE) {
+ if (m_MPLSPlaylist.GetCount() > 1) {
+ DWORD idx = 1;
+ POSITION pos = m_MPLSPlaylist.GetHeadPosition();
+ while (pos) {
+ UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
+ if (id != ID_NAVIGATE_CHAP_SUBITEM_START && pos == m_MPLSPlaylist.GetHeadPosition()) {
+ //pSub->AppendMenu(MF_SEPARATOR);
+ flags |= MF_MENUBARBREAK;
+ }
+ if (idx == MENUBARBREAK) {
+ flags |= MF_MENUBARBREAK;
+ idx = 0;
+ }
+ idx++;
+
+ CHdmvClipInfo::PlaylistItem Item = m_MPLSPlaylist.GetNext(pos);
+ CString time = _T("[") + ReftimeToString2(Item.Duration()) + _T("]");
+ CString name = StripPath(Item.m_strFileName);
+
+ if (name == m_wndPlaylistBar.m_pl.GetHead().GetLabel()) {
+ flags |= MF_CHECKED;
+ }
+
+ name.Replace(_T("&"), _T("&&"));
+ pSub->AppendMenu(flags, id++, name + '\t' + time);
+ }
+ }
+
+ SetupChapters();
+ REFERENCE_TIME rt = GetPos();
+ DWORD j = m_pCB->ChapLookup(&rt, NULL);
+
+ if (m_pCB->ChapGetCount() > 1) {
+ for (DWORD i = 0, idx = 0; i < m_pCB->ChapGetCount(); i++, id++, idx++) {
+ rt = 0;
+ CComBSTR bstr;
+ if (FAILED(m_pCB->ChapGet(i, &rt, &bstr))) {
+ continue;
+ }
+
+ CString time = _T("[") + ReftimeToString2(rt) + _T("]");
+
+ CString name = CString(bstr);
+ name.Replace(_T("&"), _T("&&"));
+ name.Replace(_T("\t"), _T(" "));
+
+ UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
+ if (i == j) {
+ flags |= MF_CHECKED;
+ }
+
+ if (idx == MENUBARBREAK) {
+ flags |= MF_MENUBARBREAK;
+ idx = 0;
+ }
+
+ if (id != ID_NAVIGATE_CHAP_SUBITEM_START && i == 0) {
+ //pSub->AppendMenu(MF_SEPARATOR);
+ if (m_MPLSPlaylist.GetCount() > 1) {
+ flags |= MF_MENUBARBREAK;
+ }
+ }
+ pSub->AppendMenu(flags, id, name + '\t' + time);
+ }
+ }
+
+ if (m_wndPlaylistBar.GetCount() > 1) {
+ POSITION pos = m_wndPlaylistBar.m_pl.GetHeadPosition();
+ while (pos) {
+ UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
+ if (pos == m_wndPlaylistBar.m_pl.GetPos()) {
+ flags |= MF_CHECKED;
+ }
+ if (id != ID_NAVIGATE_CHAP_SUBITEM_START && pos == m_wndPlaylistBar.m_pl.GetHeadPosition()) {
+ pSub->AppendMenu(MF_SEPARATOR);
+ }
+ CPlaylistItem& pli = m_wndPlaylistBar.m_pl.GetNext(pos);
+ CString name = pli.GetLabel();
+ name.Replace(_T("&"), _T("&&"));
+ pSub->AppendMenu(flags, id++, name);
+ }
+ }
+
+ } else if (GetPlaybackMode() == PM_DVD) {
+ ULONG ulNumOfVolumes, ulVolume;
+ DVD_DISC_SIDE Side;
+ ULONG ulNumOfTitles = 0;
+ pDVDI->GetDVDVolumeInfo(&ulNumOfVolumes, &ulVolume, &Side, &ulNumOfTitles);
+
+ DVD_PLAYBACK_LOCATION2 Location;
+ pDVDI->GetCurrentLocation(&Location);
+
+ ULONG ulNumOfChapters = 0;
+ pDVDI->GetNumberOfChapters(Location.TitleNum, &ulNumOfChapters);
+
+ ULONG ulUOPs = 0;
+ pDVDI->GetCurrentUOPS(&ulUOPs);
+
+ for (ULONG i = 1; i <= ulNumOfTitles; i++) {
+ UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
+ if (i == Location.TitleNum) {
+ flags |= MF_CHECKED;
+ }
+ if (ulUOPs & UOP_FLAG_Play_Title) {
+ flags |= MF_DISABLED | MF_GRAYED;
+ }
+
+ CString str;
+ str.Format(IDS_AG_TITLE, i);
+
+ pSub->AppendMenu(flags, id++, str);
+ }
+
+ for (ULONG i = 1; i <= ulNumOfChapters; i++) {
+ UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
+ if (i == Location.ChapterNum) {
+ flags |= MF_CHECKED;
+ }
+ if (ulUOPs & UOP_FLAG_Play_Chapter) {
+ flags |= MF_DISABLED | MF_GRAYED;
+ }
+ if (i == 1) {
+ flags |= MF_MENUBARBREAK;
+ }
+
+ CString str;
+ str.Format(IDS_AG_CHAPTER, i);
+
+ pSub->AppendMenu(flags, id++, str);
+ }
+ } else if (GetPlaybackMode() == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1) {
+ AppSettings& s = AfxGetAppSettings();
+
+ POSITION pos = s.m_DVBChannels.GetHeadPosition();
+ while (pos) {
+ CDVBChannel& Channel = s.m_DVBChannels.GetNext(pos);
+ UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
+
+ if ((UINT)Channel.GetPrefNumber() == s.nDVBLastChannel) {
+ flags |= MF_CHECKED;
+ }
+ pSub->AppendMenu(flags, ID_NAVIGATE_CHAP_SUBITEM_START + Channel.GetPrefNumber(), Channel.GetName());
+ }
+ }
}
IBaseFilter* CMainFrame::FindSourceSelectableFilter()
{
- IBaseFilter* pSF = NULL;
-
- // splitters for video files (mpeg files with only audio track is very rare)
- pSF = FindFilter(__uuidof(CMpegSplitterFilter), pGB);
- if (!pSF) {
- pSF = FindFilter(__uuidof(CMpegSourceFilter), pGB);
- }
- // universal splitters
- if (!pSF) {
- pSF = FindFilter(CLSID_OggSplitter, pGB);
- }
- if (!pSF) {
- pSF = FindFilter(L"{171252A0-8820-4AFE-9DF8-5C92B2D66B04}", pGB); // LAV Splitter
- }
- if (!pSF) {
- pSF = FindFilter(L"{B98D13E7-55DB-4385-A33D-09FD1BA26338}", pGB); // LAV Splitter Source
- }
- if (!pSF) {
- pSF = FindFilter(L"{55DA30FC-F16B-49fc-BAA5-AE59FC65F82D}", pGB); // Haali Media Source
- }
- if (!pSF) {
- pSF = FindFilter(L"{564FD788-86C9-4444-971E-CC4A243DA150}", pGB); // Haali Media Splitter with previous file source (like rarfilesource)
- }
- if (!pSF) {
- pSF = FindFilter(L"{529A00DB-0C43-4f5b-8EF2-05004CBE0C6F}", pGB); // AV Splitter
- }
- if (!pSF) {
- pSF = FindFilter(L"{D8980E15-E1F6-4916-A10F-D7EB4E9E10B8}", pGB); // AV Source
- }
-
- return pSF;
+ IBaseFilter* pSF = NULL;
+
+ // splitters for video files (mpeg files with only audio track is very rare)
+ pSF = FindFilter(__uuidof(CMpegSplitterFilter), pGB);
+ if (!pSF) {
+ pSF = FindFilter(__uuidof(CMpegSourceFilter), pGB);
+ }
+ // universal splitters
+ if (!pSF) {
+ pSF = FindFilter(CLSID_OggSplitter, pGB);
+ }
+ if (!pSF) {
+ pSF = FindFilter(L"{171252A0-8820-4AFE-9DF8-5C92B2D66B04}", pGB); // LAV Splitter
+ }
+ if (!pSF) {
+ pSF = FindFilter(L"{B98D13E7-55DB-4385-A33D-09FD1BA26338}", pGB); // LAV Splitter Source
+ }
+ if (!pSF) {
+ pSF = FindFilter(L"{55DA30FC-F16B-49fc-BAA5-AE59FC65F82D}", pGB); // Haali Media Source
+ }
+ if (!pSF) {
+ pSF = FindFilter(L"{564FD788-86C9-4444-971E-CC4A243DA150}", pGB); // Haali Media Splitter with previous file source (like rarfilesource)
+ }
+ if (!pSF) {
+ pSF = FindFilter(L"{529A00DB-0C43-4f5b-8EF2-05004CBE0C6F}", pGB); // AV Splitter
+ }
+ if (!pSF) {
+ pSF = FindFilter(L"{D8980E15-E1F6-4916-A10F-D7EB4E9E10B8}", pGB); // AV Source
+ }
+
+ return pSF;
}
void CMainFrame::SetupNavStreamSelectSubMenu(CMenu* pSub, UINT id, DWORD dwSelGroup)
{
- UINT baseid = id;
-
- CComQIPtr<IAMStreamSelect> pSS = FindSourceSelectableFilter();
- if (!pSS) {
- pSS = pGB;
- }
- if (!pSS) {
- return;
- }
-
- DWORD cStreams;
- if (FAILED(pSS->Count(&cStreams))) {
- return;
- }
-
- DWORD dwPrevGroup = (DWORD)-1;
-
- for (int i = 0, j = cStreams; i < j; i++) {
- DWORD dwFlags, dwGroup;
- LCID lcid;
- WCHAR* pszName = NULL;
-
- if (FAILED(pSS->Info(i, NULL, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))
- || !pszName) {
- continue;
- }
+ UINT baseid = id;
- CString name(pszName);
- CString lcname = CString(name).MakeLower();
-
- if (pszName) {
- CoTaskMemFree(pszName);
- }
-
- if (dwGroup != dwSelGroup) {
- continue;
- }
-
- if (dwPrevGroup != -1 && dwPrevGroup != dwGroup) {
- pSub->AppendMenu(MF_SEPARATOR);
- }
- dwPrevGroup = dwGroup;
-
- CString str;
-
- if (lcname.Find(_T(" off")) >= 0) {
- str.LoadString(IDS_AG_DISABLED);
- } else {
- if (lcid == 0) {
- str.Format(IDS_AG_UNKNOWN, id - baseid);
- } else {
- int len = GetLocaleInfo(lcid, LOCALE_SENGLANGUAGE, str.GetBuffer(64), 64);
- str.ReleaseBufferSetLength(max(len-1, 0));
- }
-
- CString lcstr = CString(str).MakeLower();
-
- if (str.IsEmpty() || lcname.Find(lcstr) >= 0) {
- str = name;
- } else if (!name.IsEmpty()) {
- str = CString(name) + _T(" (") + str + _T(")");
- }
- }
+ CComQIPtr<IAMStreamSelect> pSS = FindSourceSelectableFilter();
+ if (!pSS) {
+ pSS = pGB;
+ }
+ if (!pSS) {
+ return;
+ }
- UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
- if (dwFlags) {
- flags |= MF_CHECKED;
- }
+ DWORD cStreams;
+ if (FAILED(pSS->Count(&cStreams))) {
+ return;
+ }
- str.Replace(_T("&"), _T("&&"));
- pSub->AppendMenu(flags, id++, str);
- }
+ DWORD dwPrevGroup = (DWORD) - 1;
+
+ for (int i = 0, j = cStreams; i < j; i++) {
+ DWORD dwFlags, dwGroup;
+ LCID lcid;
+ WCHAR* pszName = NULL;
+
+ if (FAILED(pSS->Info(i, NULL, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))
+ || !pszName) {
+ continue;
+ }
+
+ CString name(pszName);
+ CString lcname = CString(name).MakeLower();
+
+ if (pszName) {
+ CoTaskMemFree(pszName);
+ }
+
+ if (dwGroup != dwSelGroup) {
+ continue;
+ }
+
+ if (dwPrevGroup != -1 && dwPrevGroup != dwGroup) {
+ pSub->AppendMenu(MF_SEPARATOR);
+ }
+ dwPrevGroup = dwGroup;
+
+ CString str;
+
+ if (lcname.Find(_T(" off")) >= 0) {
+ str.LoadString(IDS_AG_DISABLED);
+ } else {
+ if (lcid == 0) {
+ str.Format(IDS_AG_UNKNOWN, id - baseid);
+ } else {
+ int len = GetLocaleInfo(lcid, LOCALE_SENGLANGUAGE, str.GetBuffer(64), 64);
+ str.ReleaseBufferSetLength(max(len - 1, 0));
+ }
+
+ CString lcstr = CString(str).MakeLower();
+
+ if (str.IsEmpty() || lcname.Find(lcstr) >= 0) {
+ str = name;
+ } else if (!name.IsEmpty()) {
+ str = CString(name) + _T(" (") + str + _T(")");
+ }
+ }
+
+ UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
+ if (dwFlags) {
+ flags |= MF_CHECKED;
+ }
+
+ str.Replace(_T("&"), _T("&&"));
+ pSub->AppendMenu(flags, id++, str);
+ }
}
void CMainFrame::OnNavStreamSelectSubMenu(UINT id, DWORD dwSelGroup)
{
- CComQIPtr<IAMStreamSelect> pSS = FindSourceSelectableFilter();
- if (!pSS) {
- pSS = pGB;
- }
- if (!pSS) {
- return;
- }
+ CComQIPtr<IAMStreamSelect> pSS = FindSourceSelectableFilter();
+ if (!pSS) {
+ pSS = pGB;
+ }
+ if (!pSS) {
+ return;
+ }
- DWORD cStreams;
- if (FAILED(pSS->Count(&cStreams))) {
- return;
- }
+ DWORD cStreams;
+ if (FAILED(pSS->Count(&cStreams))) {
+ return;
+ }
- for (int i = 0, j = cStreams; i < j; i++) {
- DWORD dwFlags, dwGroup;
- LCID lcid;
- WCHAR* pszName = NULL;
+ for (int i = 0, j = cStreams; i < j; i++) {
+ DWORD dwFlags, dwGroup;
+ LCID lcid;
+ WCHAR* pszName = NULL;
- if (FAILED(pSS->Info(i, NULL, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))
- || !pszName) {
- continue;
- }
+ if (FAILED(pSS->Info(i, NULL, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))
+ || !pszName) {
+ continue;
+ }
- if (pszName) {
- CoTaskMemFree(pszName);
- }
+ if (pszName) {
+ CoTaskMemFree(pszName);
+ }
- if (dwGroup != dwSelGroup) {
- continue;
- }
+ if (dwGroup != dwSelGroup) {
+ continue;
+ }
- if (id == 0) {
- pSS->Enable(i, AMSTREAMSELECTENABLE_ENABLE);
- break;
- }
+ if (id == 0) {
+ pSS->Enable(i, AMSTREAMSELECTENABLE_ENABLE);
+ break;
+ }
- id--;
- }
+ id--;
+ }
}
void CMainFrame::SetupRecentFilesSubMenu()
{
- CMenu* pSub = &m_recentfiles;
-
- if (!IsMenu(pSub->m_hMenu)) {
- pSub->CreatePopupMenu();
- } else while (pSub->RemoveMenu(0, MF_BYPOSITION)) {
- ;
- }
-
- UINT id = ID_RECENT_FILE_START;
- CRecentFileList& MRU = AfxGetAppSettings().MRU;
- MRU.ReadList();
-
- int mru_count=0;
- for (int i = 0; i < MRU.GetSize(); i++) {
- if (!MRU[i].IsEmpty()) {
- mru_count++;
- break;
- }
- }
- if (mru_count) {
- pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_RECENT_FILES_CLEAR, ResStr(IDS_RECENT_FILES_CLEAR));
- pSub->AppendMenu(MF_SEPARATOR|MF_ENABLED);
- }
-
- for (int i = 0; i < MRU.GetSize(); i++) {
- UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
- if (!MRU[i].IsEmpty()) {
- pSub->AppendMenu(flags, id, MRU[i]);
- }
- id++;
- }
+ CMenu* pSub = &m_recentfiles;
+
+ if (!IsMenu(pSub->m_hMenu)) {
+ pSub->CreatePopupMenu();
+ } else while (pSub->RemoveMenu(0, MF_BYPOSITION)) {
+ ;
+ }
+
+ UINT id = ID_RECENT_FILE_START;
+ CRecentFileList& MRU = AfxGetAppSettings().MRU;
+ MRU.ReadList();
+
+ int mru_count = 0;
+ for (int i = 0; i < MRU.GetSize(); i++) {
+ if (!MRU[i].IsEmpty()) {
+ mru_count++;
+ break;
+ }
+ }
+ if (mru_count) {
+ pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_RECENT_FILES_CLEAR, ResStr(IDS_RECENT_FILES_CLEAR));
+ pSub->AppendMenu(MF_SEPARATOR | MF_ENABLED);
+ }
+
+ for (int i = 0; i < MRU.GetSize(); i++) {
+ UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
+ if (!MRU[i].IsEmpty()) {
+ pSub->AppendMenu(flags, id, MRU[i]);
+ }
+ id++;
+ }
}
void CMainFrame::SetupFavoritesSubMenu()
{
- CMenu* pSub = &m_favorites;
+ CMenu* pSub = &m_favorites;
- if (!IsMenu(pSub->m_hMenu)) {
- pSub->CreatePopupMenu();
- } else while (pSub->RemoveMenu(0, MF_BYPOSITION)) {
- ;
- }
+ if (!IsMenu(pSub->m_hMenu)) {
+ pSub->CreatePopupMenu();
+ } else while (pSub->RemoveMenu(0, MF_BYPOSITION)) {
+ ;
+ }
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_FAVORITES_ADD, ResStr(IDS_FAVORITES_ADD));
- pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_FAVORITES_ORGANIZE, ResStr(IDS_FAVORITES_ORGANIZE));
+ pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_FAVORITES_ADD, ResStr(IDS_FAVORITES_ADD));
+ pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_FAVORITES_ORGANIZE, ResStr(IDS_FAVORITES_ORGANIZE));
- UINT nLastGroupStart = pSub->GetMenuItemCount();
+ UINT nLastGroupStart = pSub->GetMenuItemCount();
- UINT id = ID_FAVORITES_FILE_START;
+ UINT id = ID_FAVORITES_FILE_START;
- CAtlList<CString> sl;
- AfxGetAppSettings().GetFav(FAV_FILE, sl);
+ CAtlList<CString> sl;
+ AfxGetAppSettings().GetFav(FAV_FILE, sl);
- POSITION pos = sl.GetHeadPosition();
- while (pos) {
- UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
+ POSITION pos = sl.GetHeadPosition();
+ while (pos) {
+ UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
- CString f_str = sl.GetNext(pos);
- f_str.Replace(_T("&"), _T("&&"));
- f_str.Replace(_T("\t"), _T(" "));
+ CString f_str = sl.GetNext(pos);
+ f_str.Replace(_T("&"), _T("&&"));
+ f_str.Replace(_T("\t"), _T(" "));
- CAtlList<CString> sl;
- Explode(f_str, sl, ';', 3);
+ CAtlList<CString> sl;
+ Explode(f_str, sl, ';', 3);
- f_str = sl.RemoveHead();
+ f_str = sl.RemoveHead();
- CString str;
+ CString str;
- if (!sl.IsEmpty()) {
- bool bPositionDataPresent = false;
+ if (!sl.IsEmpty()) {
+ bool bPositionDataPresent = false;
- // pos
- REFERENCE_TIME rt = 0;
- if (1 == _stscanf_s(sl.GetHead(), _T("%I64d"), &rt) && rt > 0) {
- DVD_HMSF_TIMECODE hmsf = RT2HMSF(rt);
- str.Format(_T("[%02d:%02d:%02d]"), hmsf.bHours, hmsf.bMinutes, hmsf.bSeconds);
- bPositionDataPresent = true;
- }
+ // pos
+ REFERENCE_TIME rt = 0;
+ if (1 == _stscanf_s(sl.GetHead(), _T("%I64d"), &rt) && rt > 0) {
+ DVD_HMSF_TIMECODE hmsf = RT2HMSF(rt);
+ str.Format(_T("[%02d:%02d:%02d]"), hmsf.bHours, hmsf.bMinutes, hmsf.bSeconds);
+ bPositionDataPresent = true;
+ }
- // relative drive
- if ( sl.GetCount() > 1 ) { // Here to prevent crash if old favorites settings are present
- sl.RemoveHead();
+ // relative drive
+ if (sl.GetCount() > 1) { // Here to prevent crash if old favorites settings are present
+ sl.RemoveHead();
- BOOL bRelativeDrive = FALSE;
- if ( _stscanf_s(sl.GetHead(), _T("%d"), &bRelativeDrive) == 1 ) {
- if (bRelativeDrive) {
- str.Format(_T("[RD]%s"), CString(str));
- }
- }
- }
- if (!str.IsEmpty()) {
- f_str.Format(_T("%s\t%.14s"), CString(f_str), CString(str));
- }
- }
+ BOOL bRelativeDrive = FALSE;
+ if (_stscanf_s(sl.GetHead(), _T("%d"), &bRelativeDrive) == 1) {
+ if (bRelativeDrive) {
+ str.Format(_T("[RD]%s"), CString(str));
+ }
+ }
+ }
+ if (!str.IsEmpty()) {
+ f_str.Format(_T("%s\t%.14s"), CString(f_str), CString(str));
+ }
+ }
- if (!f_str.IsEmpty()) {
- pSub->AppendMenu(flags, id, f_str);
- }
+ if (!f_str.IsEmpty()) {
+ pSub->AppendMenu(flags, id, f_str);
+ }
- id++;
- }
+ id++;
+ }
- if (id > ID_FAVORITES_FILE_START) {
- pSub->InsertMenu(nLastGroupStart, MF_SEPARATOR|MF_ENABLED|MF_BYPOSITION);
- }
+ if (id > ID_FAVORITES_FILE_START) {
+ pSub->InsertMenu(nLastGroupStart, MF_SEPARATOR | MF_ENABLED | MF_BYPOSITION);
+ }
- nLastGroupStart = pSub->GetMenuItemCount();
+ nLastGroupStart = pSub->GetMenuItemCount();
- id = ID_FAVORITES_DVD_START;
+ id = ID_FAVORITES_DVD_START;
- s.GetFav(FAV_DVD, sl);
+ s.GetFav(FAV_DVD, sl);
- pos = sl.GetHeadPosition();
- while (pos) {
- UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
+ pos = sl.GetHeadPosition();
+ while (pos) {
+ UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
- CString str = sl.GetNext(pos);
- str.Replace(_T("&"), _T("&&"));
+ CString str = sl.GetNext(pos);
+ str.Replace(_T("&"), _T("&&"));
- CAtlList<CString> sl;
- Explode(str, sl, ';', 2);
+ CAtlList<CString> sl;
+ Explode(str, sl, ';', 2);
- str = sl.RemoveHead();
+ str = sl.RemoveHead();
- if (!sl.IsEmpty()) {
- // TODO
- }
+ if (!sl.IsEmpty()) {
+ // TODO
+ }
- if (!str.IsEmpty()) {
- pSub->AppendMenu(flags, id, str);
- }
+ if (!str.IsEmpty()) {
+ pSub->AppendMenu(flags, id, str);
+ }
- id++;
- }
+ id++;
+ }
- if (id > ID_FAVORITES_DVD_START) {
- pSub->InsertMenu(nLastGroupStart, MF_SEPARATOR|MF_ENABLED|MF_BYPOSITION);
- }
+ if (id > ID_FAVORITES_DVD_START) {
+ pSub->InsertMenu(nLastGroupStart, MF_SEPARATOR | MF_ENABLED | MF_BYPOSITION);
+ }
- nLastGroupStart = pSub->GetMenuItemCount();
+ nLastGroupStart = pSub->GetMenuItemCount();
- id = ID_FAVORITES_DEVICE_START;
+ id = ID_FAVORITES_DEVICE_START;
- s.GetFav(FAV_DEVICE, sl);
+ s.GetFav(FAV_DEVICE, sl);
- pos = sl.GetHeadPosition();
- while (pos) {
- UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
+ pos = sl.GetHeadPosition();
+ while (pos) {
+ UINT flags = MF_BYCOMMAND | MF_STRING | MF_ENABLED;
- CString str = sl.GetNext(pos);
- str.Replace(_T("&"), _T("&&"));
+ CString str = sl.GetNext(pos);
+ str.Replace(_T("&"), _T("&&"));
- CAtlList<CString> sl;
- Explode(str, sl, ';', 2);
+ CAtlList<CString> sl;
+ Explode(str, sl, ';', 2);
- str = sl.RemoveHead();
+ str = sl.RemoveHead();
- if (!str.IsEmpty()) {
- pSub->AppendMenu(flags, id, str);
- }
+ if (!str.IsEmpty()) {
+ pSub->AppendMenu(flags, id, str);
+ }
- id++;
- }
+ id++;
+ }
}
void CMainFrame::SetupShadersSubMenu()
{
- CMenu* pSub = &m_shaders;
+ CMenu* pSub = &m_shaders;
- if (!IsMenu(pSub->m_hMenu)) {
- pSub->CreatePopupMenu();
- } else while (pSub->RemoveMenu(0, MF_BYPOSITION)) {
- ;
- }
+ if (!IsMenu(pSub->m_hMenu)) {
+ pSub->CreatePopupMenu();
+ } else while (pSub->RemoveMenu(0, MF_BYPOSITION)) {
+ ;
+ }
- pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_SHADERS_TOGGLE, ResStr(IDS_SHADERS_TOGGLE));
- pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_SHADERS_TOGGLE_SCREENSPACE, ResStr(IDS_SHADERS_TOGGLE_SCREENSPACE));
- pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_SHADERS_SELECT, ResStr(IDS_SHADERS_SELECT));
- pSub->AppendMenu(MF_SEPARATOR);
- pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_VIEW_SHADEREDITOR, ResStr(IDS_SHADERS_EDIT));
+ pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_SHADERS_TOGGLE, ResStr(IDS_SHADERS_TOGGLE));
+ pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_SHADERS_TOGGLE_SCREENSPACE, ResStr(IDS_SHADERS_TOGGLE_SCREENSPACE));
+ pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_SHADERS_SELECT, ResStr(IDS_SHADERS_SELECT));
+ pSub->AppendMenu(MF_SEPARATOR);
+ pSub->AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_VIEW_SHADEREDITOR, ResStr(IDS_SHADERS_EDIT));
}
/////////////
void CMainFrame::ShowControls(int nCS, bool fSave /*= false*/)
{
- int nCSprev = m_nCS;
- int hbefore = 0, hafter = 0;
-
- m_pLastBar = NULL;
-
- POSITION pos = m_bars.GetHeadPosition();
- for (int i = 1; pos; i <<= 1) {
- CControlBar* pNext = m_bars.GetNext(pos);
- ShowControlBar(pNext, !!(nCS & i), TRUE);
- if (nCS & i) {
- m_pLastBar = pNext;
- }
-
- CSize s = pNext->CalcFixedLayout(FALSE, TRUE);
- if (nCSprev & i) {
- hbefore += s.cy;
- }
- if (nCS & i) {
- hafter += s.cy;
- }
- }
+ int nCSprev = m_nCS;
+ int hbefore = 0, hafter = 0;
+
+ m_pLastBar = NULL;
+
+ POSITION pos = m_bars.GetHeadPosition();
+ for (int i = 1; pos; i <<= 1) {
+ CControlBar* pNext = m_bars.GetNext(pos);
+ ShowControlBar(pNext, !!(nCS & i), TRUE);
+ if (nCS & i) {
+ m_pLastBar = pNext;
+ }
+
+ CSize s = pNext->CalcFixedLayout(FALSE, TRUE);
+ if (nCSprev & i) {
+ hbefore += s.cy;
+ }
+ if (nCS & i) {
+ hafter += s.cy;
+ }
+ }
- WINDOWPLACEMENT wp;
- wp.length = sizeof(wp);
- GetWindowPlacement(&wp);
+ WINDOWPLACEMENT wp;
+ wp.length = sizeof(wp);
+ GetWindowPlacement(&wp);
- if (wp.showCmd != SW_SHOWMAXIMIZED && !m_fFullScreen) {
- CRect r;
- GetWindowRect(r);
- MoveWindow(r.left, r.top, r.Width(), r.Height() + hafter - hbefore);
- }
+ if (wp.showCmd != SW_SHOWMAXIMIZED && !m_fFullScreen) {
+ CRect r;
+ GetWindowRect(r);
+ MoveWindow(r.left, r.top, r.Width(), r.Height() + hafter - hbefore);
+ }
- if (fSave) {
- m_nCS = nCS;
- }
+ if (fSave) {
+ m_nCS = nCS;
+ }
- RecalcLayout();
+ RecalcLayout();
}
void CMainFrame::SetAlwaysOnTop(int i)
{
- AfxGetAppSettings().iOnTop = i;
-
- if (!m_fFullScreen) {
- const CWnd* pInsertAfter = NULL;
-
- if (i == 0) {
- pInsertAfter = &wndNoTopMost;
- } else if (i == 1) {
- pInsertAfter = &wndTopMost;
- } else if (i == 2) {
- pInsertAfter = GetMediaState() == State_Running ? &wndTopMost : &wndNoTopMost;
- } else { // if (i == 3)
- pInsertAfter = (GetMediaState() == State_Running && !m_fAudioOnly) ? &wndTopMost : &wndNoTopMost;
- }
-
- SetWindowPos(pInsertAfter, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
- } else if (!(GetWindowLongPtr(m_hWnd, GWL_EXSTYLE)&WS_EX_TOPMOST)) {
- if (!AfxGetAppSettings().IsD3DFullscreen()) {
- SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
- }
- }
+ AfxGetAppSettings().iOnTop = i;
+
+ if (!m_fFullScreen) {
+ const CWnd* pInsertAfter = NULL;
+
+ if (i == 0) {
+ pInsertAfter = &wndNoTopMost;
+ } else if (i == 1) {
+ pInsertAfter = &wndTopMost;
+ } else if (i == 2) {
+ pInsertAfter = GetMediaState() == State_Running ? &wndTopMost : &wndNoTopMost;
+ } else { // if (i == 3)
+ pInsertAfter = (GetMediaState() == State_Running && !m_fAudioOnly) ? &wndTopMost : &wndNoTopMost;
+ }
+
+ SetWindowPos(pInsertAfter, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+ } else if (!(GetWindowLongPtr(m_hWnd, GWL_EXSTYLE)&WS_EX_TOPMOST)) {
+ if (!AfxGetAppSettings().IsD3DFullscreen()) {
+ SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+ }
+ }
}
// foxX: as with audio streams, this one will tell if a subtitle comes before the other,
// in accordance with user options regarding subtitle language order
-bool DoesSubPrecede(const CComPtr<ISubStream> &a, const CComPtr<ISubStream> &b)
-{
- WCHAR *pName;
- if (!SUCCEEDED(a->GetStreamInfo(0, &pName, NULL))) {
- return false;
- }
- CStringW nameA(pName);
- nameA = nameA.Trim();
- CoTaskMemFree(pName);
-
- if (!SUCCEEDED(b->GetStreamInfo(0, &pName, NULL))) {
- return false;
- }
- CStringW nameB(pName);
- nameB = nameB.Trim();
- CoTaskMemFree(pName);
-
- int ia = -1;
- int ib = -1;
- CStringW slo = _T("[Forced],") + AfxGetAppSettings().strSubtitlesLanguageOrder + _T(",[Default]");
- int tPos = 0;
- CStringW lang = slo.Tokenize(_T(",; "), tPos);
- while (tPos != -1 && ia == -1 && ib == -1) {
- int ll = lang.GetLength();
- if ((nameA.Left(ll).CompareNoCase(lang) == 0) || (nameA.Right(ll).CompareNoCase(lang) == 0)) {
- ia = tPos;
- }
- if ((nameB.Left(ll).CompareNoCase(lang) == 0) || (nameB.Right(ll).CompareNoCase(lang) == 0)) {
- ib = tPos;
- }
- lang = slo.Tokenize(_T(",; "), tPos);
- }
- if (ia != -1 && ib == -1) {
- return true;
- }
- return false;
+bool DoesSubPrecede(const CComPtr<ISubStream>& a, const CComPtr<ISubStream>& b)
+{
+ WCHAR* pName;
+ if (!SUCCEEDED(a->GetStreamInfo(0, &pName, NULL))) {
+ return false;
+ }
+ CStringW nameA(pName);
+ nameA = nameA.Trim();
+ CoTaskMemFree(pName);
+
+ if (!SUCCEEDED(b->GetStreamInfo(0, &pName, NULL))) {
+ return false;
+ }
+ CStringW nameB(pName);
+ nameB = nameB.Trim();
+ CoTaskMemFree(pName);
+
+ int ia = -1;
+ int ib = -1;
+ CStringW slo = _T("[Forced],") + AfxGetAppSettings().strSubtitlesLanguageOrder + _T(",[Default]");
+ int tPos = 0;
+ CStringW lang = slo.Tokenize(_T(",; "), tPos);
+ while (tPos != -1 && ia == -1 && ib == -1) {
+ int ll = lang.GetLength();
+ if ((nameA.Left(ll).CompareNoCase(lang) == 0) || (nameA.Right(ll).CompareNoCase(lang) == 0)) {
+ ia = tPos;
+ }
+ if ((nameB.Left(ll).CompareNoCase(lang) == 0) || (nameB.Right(ll).CompareNoCase(lang) == 0)) {
+ ib = tPos;
+ }
+ lang = slo.Tokenize(_T(",; "), tPos);
+ }
+ if (ia != -1 && ib == -1) {
+ return true;
+ }
+ return false;
}
// foxX: inserts the subtitle stream exactly where it should be, base on user preference
-ISubStream *InsertSubStream(CInterfaceList<ISubStream> *subStreams, const CComPtr<ISubStream> &theSubStream)
-{
- POSITION pos = subStreams->GetHeadPosition();
- POSITION newPos = NULL;
- bool processed = false;
- while (!processed && pos) {
- POSITION prevPos = pos;
- CComPtr<ISubStream> pSubStream = subStreams->GetNext(pos);
- if (DoesSubPrecede(theSubStream, pSubStream)) {
- if (prevPos == subStreams->GetHeadPosition()) {
- newPos = subStreams->AddHead(theSubStream);
- } else {
- newPos = subStreams->InsertBefore(prevPos, theSubStream);
- }
- processed = true;
- }
- }
- if (!processed) {
- newPos = subStreams->AddTail(theSubStream);
- }
- if (newPos == NULL) {
- newPos = subStreams->GetTailPosition();
- }
- if (newPos == NULL) {
- return NULL;
- }
- return subStreams->GetAt(newPos);
+ISubStream* InsertSubStream(CInterfaceList<ISubStream>* subStreams, const CComPtr<ISubStream>& theSubStream)
+{
+ POSITION pos = subStreams->GetHeadPosition();
+ POSITION newPos = NULL;
+ bool processed = false;
+ while (!processed && pos) {
+ POSITION prevPos = pos;
+ CComPtr<ISubStream> pSubStream = subStreams->GetNext(pos);
+ if (DoesSubPrecede(theSubStream, pSubStream)) {
+ if (prevPos == subStreams->GetHeadPosition()) {
+ newPos = subStreams->AddHead(theSubStream);
+ } else {
+ newPos = subStreams->InsertBefore(prevPos, theSubStream);
+ }
+ processed = true;
+ }
+ }
+ if (!processed) {
+ newPos = subStreams->AddTail(theSubStream);
+ }
+ if (newPos == NULL) {
+ newPos = subStreams->GetTailPosition();
+ }
+ if (newPos == NULL) {
+ return NULL;
+ }
+ return subStreams->GetAt(newPos);
}
void CMainFrame::AddTextPassThruFilter()
{
- BeginEnumFilters(pGB, pEF, pBF) {
- if (!IsSplitter(pBF)) {
- continue;
- }
-
- BeginEnumPins(pBF, pEP, pPin) {
- CComPtr<IPin> pPinTo;
- AM_MEDIA_TYPE mt;
- if (FAILED(pPin->ConnectedTo(&pPinTo)) || !pPinTo
- || FAILED(pPin->ConnectionMediaType(&mt))
- || mt.majortype != MEDIATYPE_Text && mt.majortype != MEDIATYPE_Subtitle) {
- continue;
- }
-
- CComQIPtr<IBaseFilter> pTPTF = DNew CTextPassThruFilter(this);
- CStringW name;
- name.Format(L"TextPassThru%08x", pTPTF);
- if (FAILED(pGB->AddFilter(pTPTF, name))) {
- continue;
- }
-
- HRESULT hr;
-
- hr = pPinTo->Disconnect();
- hr = pPin->Disconnect();
-
- if (FAILED(hr = pGB->ConnectDirect(pPin, GetFirstPin(pTPTF, PINDIR_INPUT), NULL))
- || FAILED(hr = pGB->ConnectDirect(GetFirstPin(pTPTF, PINDIR_OUTPUT), pPinTo, NULL))) {
- hr = pGB->ConnectDirect(pPin, pPinTo, NULL);
- } else {
- InsertSubStream(&m_pSubStreams, CComQIPtr<ISubStream>(pTPTF));
- }
- }
- EndEnumPins;
- }
- EndEnumFilters;
-}
-
-bool CMainFrame::LoadSubtitle(CString fn, ISubStream **actualStream)
-{
- CComPtr<ISubStream> pSubStream;
-
- // TMP: maybe this will catch something for those who get a runtime error dialog when opening subtitles from cds
- try {
- if (!pSubStream) {
- CAutoPtr<CVobSubFile> pVSF(DNew CVobSubFile(&m_csSubLock));
- if (CString(CPath(fn).GetExtension()).MakeLower() == _T(".idx") && pVSF && pVSF->Open(fn) && pVSF->GetStreamCount() > 0) {
- pSubStream = pVSF.Detach();
- }
- }
-
- if (!pSubStream) {
- CAutoPtr<CRenderedTextSubtitle> pRTS(DNew CRenderedTextSubtitle(&m_csSubLock, &AfxGetAppSettings().subdefstyle, AfxGetAppSettings().fUseDefaultSubtitlesStyle));
-
- // The filename of the video file
- CString videoName = m_wndPlaylistBar.GetCurFileName();
- videoName = videoName.Left(videoName.ReverseFind('.')).Mid(videoName.ReverseFind('\\') + 1);
-
- // The filename of the subtitle file
- CString subName = fn.Left(fn.ReverseFind('.')).Mid(fn.ReverseFind('\\') + 1);
-
- CString name;
- if (subName.Find(videoName) != -1 && videoName.CompareNoCase(subName) != 0 && subName.Replace(videoName, _T("")) == 1) {
- name = subName.TrimLeft('.');
- } else {
- name.LoadString(IDS_UNDETERMINED);
- }
-
- if (pRTS && pRTS->Open(fn, DEFAULT_CHARSET, name) && pRTS->GetStreamCount() > 0) {
- pSubStream = pRTS.Detach();
- }
- }
- } catch (CException* e) {
- e->Delete();
- }
-
- if (pSubStream) {
- //m_pSubStreams.AddTail(pSubStream);
- ISubStream *r = InsertSubStream(&m_pSubStreams, pSubStream);
- if (actualStream != NULL) {
- *actualStream = r;
- }
- }
-
- return !!pSubStream;
+ BeginEnumFilters(pGB, pEF, pBF) {
+ if (!IsSplitter(pBF)) {
+ continue;
+ }
+
+ BeginEnumPins(pBF, pEP, pPin) {
+ CComPtr<IPin> pPinTo;
+ AM_MEDIA_TYPE mt;
+ if (FAILED(pPin->ConnectedTo(&pPinTo)) || !pPinTo
+ || FAILED(pPin->ConnectionMediaType(&mt))
+ || mt.majortype != MEDIATYPE_Text && mt.majortype != MEDIATYPE_Subtitle) {
+ continue;
+ }
+
+ CComQIPtr<IBaseFilter> pTPTF = DNew CTextPassThruFilter(this);
+ CStringW name;
+ name.Format(L"TextPassThru%08x", pTPTF);
+ if (FAILED(pGB->AddFilter(pTPTF, name))) {
+ continue;
+ }
+
+ HRESULT hr;
+
+ hr = pPinTo->Disconnect();
+ hr = pPin->Disconnect();
+
+ if (FAILED(hr = pGB->ConnectDirect(pPin, GetFirstPin(pTPTF, PINDIR_INPUT), NULL))
+ || FAILED(hr = pGB->ConnectDirect(GetFirstPin(pTPTF, PINDIR_OUTPUT), pPinTo, NULL))) {
+ hr = pGB->ConnectDirect(pPin, pPinTo, NULL);
+ } else {
+ InsertSubStream(&m_pSubStreams, CComQIPtr<ISubStream>(pTPTF));
+ }
+ }
+ EndEnumPins;
+ }
+ EndEnumFilters;
}
-void CMainFrame::UpdateSubtitle(bool fDisplayMessage, bool fApplyDefStyle)
+bool CMainFrame::LoadSubtitle(CString fn, ISubStream** actualStream)
{
- if (!m_pCAP) {
- return;
- }
+ CComPtr<ISubStream> pSubStream;
+
+ // TMP: maybe this will catch something for those who get a runtime error dialog when opening subtitles from cds
+ try {
+ if (!pSubStream) {
+ CAutoPtr<CVobSubFile> pVSF(DNew CVobSubFile(&m_csSubLock));
+ if (CString(CPath(fn).GetExtension()).MakeLower() == _T(".idx") && pVSF && pVSF->Open(fn) && pVSF->GetStreamCount() > 0) {
+ pSubStream = pVSF.Detach();
+ }
+ }
+
+ if (!pSubStream) {
+ CAutoPtr<CRenderedTextSubtitle> pRTS(DNew CRenderedTextSubtitle(&m_csSubLock, &AfxGetAppSettings().subdefstyle, AfxGetAppSettings().fUseDefaultSubtitlesStyle));
- int i = m_iSubtitleSel;
+ // The filename of the video file
+ CString videoName = m_wndPlaylistBar.GetCurFileName();
+ videoName = videoName.Left(videoName.ReverseFind('.')).Mid(videoName.ReverseFind('\\') + 1);
- POSITION pos = m_pSubStreams.GetHeadPosition();
- while (pos && i >= 0) {
- CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
+ // The filename of the subtitle file
+ CString subName = fn.Left(fn.ReverseFind('.')).Mid(fn.ReverseFind('\\') + 1);
- if (i < pSubStream->GetStreamCount()) {
- CAutoLock cAutoLock(&m_csSubLock);
- pSubStream->SetStream(i);
- SetSubtitle(pSubStream, fApplyDefStyle);
+ CString name;
+ if (subName.Find(videoName) != -1 && videoName.CompareNoCase(subName) != 0 && subName.Replace(videoName, _T("")) == 1) {
+ name = subName.TrimLeft('.');
+ } else {
+ name.LoadString(IDS_UNDETERMINED);
+ }
+
+ if (pRTS && pRTS->Open(fn, DEFAULT_CHARSET, name) && pRTS->GetStreamCount() > 0) {
+ pSubStream = pRTS.Detach();
+ }
+ }
+ } catch (CException* e) {
+ e->Delete();
+ }
+
+ if (pSubStream) {
+ //m_pSubStreams.AddTail(pSubStream);
+ ISubStream* r = InsertSubStream(&m_pSubStreams, pSubStream);
+ if (actualStream != NULL) {
+ *actualStream = r;
+ }
+ }
+
+ return !!pSubStream;
+}
- if (fDisplayMessage) {
- WCHAR* pName = NULL;
- if (SUCCEEDED(pSubStream->GetStreamInfo(0, &pName, NULL))) {
- CString strMessage;
- strMessage.Format(IDS_SUBTITLE_STREAM, pName);
- m_OSD.DisplayMessage (OSD_TOPLEFT, strMessage);
- }
- }
- return;
- }
+void CMainFrame::UpdateSubtitle(bool fDisplayMessage, bool fApplyDefStyle)
+{
+ if (!m_pCAP) {
+ return;
+ }
- i -= pSubStream->GetStreamCount();
- }
+ int i = m_iSubtitleSel;
+
+ POSITION pos = m_pSubStreams.GetHeadPosition();
+ while (pos && i >= 0) {
+ CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
+
+ if (i < pSubStream->GetStreamCount()) {
+ CAutoLock cAutoLock(&m_csSubLock);
+ pSubStream->SetStream(i);
+ SetSubtitle(pSubStream, fApplyDefStyle);
+
+ if (fDisplayMessage) {
+ WCHAR* pName = NULL;
+ if (SUCCEEDED(pSubStream->GetStreamInfo(0, &pName, NULL))) {
+ CString strMessage;
+ strMessage.Format(IDS_SUBTITLE_STREAM, pName);
+ m_OSD.DisplayMessage(OSD_TOPLEFT, strMessage);
+ }
+ }
+ return;
+ }
+
+ i -= pSubStream->GetStreamCount();
+ }
- if (fDisplayMessage && m_iSubtitleSel < 0) {
- m_OSD.DisplayMessage (OSD_TOPLEFT, ResStr(IDS_SUBTITLE_STREAM_OFF));
- }
+ if (fDisplayMessage && m_iSubtitleSel < 0) {
+ m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_SUBTITLE_STREAM_OFF));
+ }
- m_pCAP->SetSubPicProvider(NULL);
+ m_pCAP->SetSubPicProvider(NULL);
}
void CMainFrame::SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyle)
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- if (pSubStream) {
- CLSID clsid;
- pSubStream->GetClassID(&clsid);
+ if (pSubStream) {
+ CLSID clsid;
+ pSubStream->GetClassID(&clsid);
- if (clsid == __uuidof(CVobSubFile)) {
- CVobSubFile* pVSF = (CVobSubFile*)(ISubStream*)pSubStream;
+ if (clsid == __uuidof(CVobSubFile)) {
+ CVobSubFile* pVSF = (CVobSubFile*)(ISubStream*)pSubStream;
- if (fApplyDefStyle) {
- pVSF->SetAlignment(s.fOverridePlacement, s.nHorPos, s.nVerPos, 1, 1);
- }
- } else if (clsid == __uuidof(CVobSubStream)) {
- CVobSubStream* pVSS = (CVobSubStream*)(ISubStream*)pSubStream;
+ if (fApplyDefStyle) {
+ pVSF->SetAlignment(s.fOverridePlacement, s.nHorPos, s.nVerPos, 1, 1);
+ }
+ } else if (clsid == __uuidof(CVobSubStream)) {
+ CVobSubStream* pVSS = (CVobSubStream*)(ISubStream*)pSubStream;
- if (fApplyDefStyle) {
- pVSS->SetAlignment(s.fOverridePlacement, s.nHorPos, s.nVerPos, 1, 1);
- }
- } else if (clsid == __uuidof(CRenderedTextSubtitle)) {
- CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)pSubStream;
+ if (fApplyDefStyle) {
+ pVSS->SetAlignment(s.fOverridePlacement, s.nHorPos, s.nVerPos, 1, 1);
+ }
+ } else if (clsid == __uuidof(CRenderedTextSubtitle)) {
+ CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)pSubStream;
- STSStyle style;
+ STSStyle style;
- if (fApplyDefStyle || pRTS->m_fUsingAutoGeneratedDefaultStyle) {
- style = s.subdefstyle;
+ if (fApplyDefStyle || pRTS->m_fUsingAutoGeneratedDefaultStyle) {
+ style = s.subdefstyle;
- if (s.fOverridePlacement) {
- style.scrAlignment = 2;
- int w = pRTS->m_dstScreenSize.cx;
- int h = pRTS->m_dstScreenSize.cy;
- int mw = w - style.marginRect.left - style.marginRect.right;
- style.marginRect.bottom = h - MulDiv(h, s.nVerPos, 100);
- style.marginRect.left = MulDiv(w, s.nHorPos, 100) - mw/2;
- style.marginRect.right = w - (style.marginRect.left + mw);
- }
+ if (s.fOverridePlacement) {
+ style.scrAlignment = 2;
+ int w = pRTS->m_dstScreenSize.cx;
+ int h = pRTS->m_dstScreenSize.cy;
+ int mw = w - style.marginRect.left - style.marginRect.right;
+ style.marginRect.bottom = h - MulDiv(h, s.nVerPos, 100);
+ style.marginRect.left = MulDiv(w, s.nHorPos, 100) - mw / 2;
+ style.marginRect.right = w - (style.marginRect.left + mw);
+ }
- bool res = pRTS->SetDefaultStyle(style);
- UNREFERENCED_PARAMETER(res);
- }
+ bool res = pRTS->SetDefaultStyle(style);
+ UNREFERENCED_PARAMETER(res);
+ }
- if (pRTS->GetDefaultStyle(style) && style.relativeTo == 2) {
- style.relativeTo = s.subdefstyle.relativeTo;
- pRTS->SetDefaultStyle(style);
- }
+ if (pRTS->GetDefaultStyle(style) && style.relativeTo == 2) {
+ style.relativeTo = s.subdefstyle.relativeTo;
+ pRTS->SetDefaultStyle(style);
+ }
- pRTS->SetOverride(s.fUseDefaultSubtitlesStyle, &s.subdefstyle);
+ pRTS->SetOverride(s.fUseDefaultSubtitlesStyle, &s.subdefstyle);
- pRTS->Deinit();
- }
- }
+ pRTS->Deinit();
+ }
+ }
- if (!fApplyDefStyle) {
- m_iSubtitleSel = -1;
+ if (!fApplyDefStyle) {
+ m_iSubtitleSel = -1;
- if (pSubStream) {
+ if (pSubStream) {
- int i = 0;
+ int i = 0;
- POSITION pos = m_pSubStreams.GetHeadPosition();
- while (pos) {
- CComPtr<ISubStream> pSubStream2 = m_pSubStreams.GetNext(pos);
+ POSITION pos = m_pSubStreams.GetHeadPosition();
+ while (pos) {
+ CComPtr<ISubStream> pSubStream2 = m_pSubStreams.GetNext(pos);
- if (pSubStream == pSubStream2) {
- m_iSubtitleSel = i + pSubStream2->GetStream();
- break;
- }
+ if (pSubStream == pSubStream2) {
+ m_iSubtitleSel = i + pSubStream2->GetStream();
+ break;
+ }
- i += pSubStream2->GetStreamCount();
- }
+ i += pSubStream2->GetStreamCount();
+ }
- }
- }
+ }
+ }
- m_nSubtitleId = (DWORD_PTR)pSubStream;
+ m_nSubtitleId = (DWORD_PTR)pSubStream;
- if (m_pCAP) {
- m_pCAP->SetSubPicProvider(CComQIPtr<ISubPicProvider>(pSubStream));
- m_wndSubresyncBar.SetSubtitle(pSubStream, m_pCAP->GetFPS());
- }
+ if (m_pCAP) {
+ m_pCAP->SetSubPicProvider(CComQIPtr<ISubPicProvider>(pSubStream));
+ m_wndSubresyncBar.SetSubtitle(pSubStream, m_pCAP->GetFPS());
+ }
}
void CMainFrame::ReplaceSubtitle(ISubStream* pSubStreamOld, ISubStream* pSubStreamNew)
{
- POSITION pos = m_pSubStreams.GetHeadPosition();
- while (pos) {
- POSITION cur = pos;
- if (pSubStreamOld == m_pSubStreams.GetNext(pos)) {
- m_pSubStreams.SetAt(cur, pSubStreamNew);
- UpdateSubtitle();
- break;
- }
- }
+ POSITION pos = m_pSubStreams.GetHeadPosition();
+ while (pos) {
+ POSITION cur = pos;
+ if (pSubStreamOld == m_pSubStreams.GetNext(pos)) {
+ m_pSubStreams.SetAt(cur, pSubStreamNew);
+ UpdateSubtitle();
+ break;
+ }
+ }
}
void CMainFrame::InvalidateSubtitle(DWORD_PTR nSubtitleId, REFERENCE_TIME rtInvalidate)
{
- if (m_pCAP) {
- if (nSubtitleId == -1 || nSubtitleId == m_nSubtitleId) {
- m_pCAP->Invalidate(rtInvalidate);
- }
- }
+ if (m_pCAP) {
+ if (nSubtitleId == -1 || nSubtitleId == m_nSubtitleId) {
+ m_pCAP->Invalidate(rtInvalidate);
+ }
+ }
}
void CMainFrame::ReloadSubtitle()
{
- POSITION pos = m_pSubStreams.GetHeadPosition();
- while (pos) {
- m_pSubStreams.GetNext(pos)->Reload();
- }
- UpdateSubtitle();
+ POSITION pos = m_pSubStreams.GetHeadPosition();
+ while (pos) {
+ m_pSubStreams.GetNext(pos)->Reload();
+ }
+ UpdateSubtitle();
}
void CMainFrame::SetSubtitleTrackIdx(int index)
{
- if (m_iMediaLoadState == MLS_LOADED) {
- if (index < 0) {
- m_iSubtitleSel ^= 0x80000000;
- } else {
- POSITION pos = m_pSubStreams.FindIndex(index);
- if (pos) {
- m_iSubtitleSel = index;
- }
- }
- UpdateSubtitle();
- AfxGetAppSettings().fEnableSubtitles = !(m_iSubtitleSel & 0x80000000);
- }
+ if (m_iMediaLoadState == MLS_LOADED) {
+ if (index < 0) {
+ m_iSubtitleSel ^= 0x80000000;
+ } else {
+ POSITION pos = m_pSubStreams.FindIndex(index);
+ if (pos) {
+ m_iSubtitleSel = index;
+ }
+ }
+ UpdateSubtitle();
+ AfxGetAppSettings().fEnableSubtitles = !(m_iSubtitleSel & 0x80000000);
+ }
}
void CMainFrame::SetAudioTrackIdx(int index)
{
- if (m_iMediaLoadState == MLS_LOADED) {
- CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
- if (!pSS) {
- pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB); // morgan's switcher
- }
-
- DWORD cStreams = 0;
- DWORD dwFlags = AMSTREAMSELECTENABLE_ENABLE;
- if (pSS && SUCCEEDED(pSS->Count(&cStreams)))
- if ((index >= 0) && (index < ((int)cStreams))) {
- pSS->Enable(index, dwFlags);
- }
- }
+ if (m_iMediaLoadState == MLS_LOADED) {
+ CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
+ if (!pSS) {
+ pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB); // morgan's switcher
+ }
+
+ DWORD cStreams = 0;
+ DWORD dwFlags = AMSTREAMSELECTENABLE_ENABLE;
+ if (pSS && SUCCEEDED(pSS->Count(&cStreams)))
+ if ((index >= 0) && (index < ((int)cStreams))) {
+ pSS->Enable(index, dwFlags);
+ }
+ }
}
REFERENCE_TIME CMainFrame::GetPos() const
{
- return (m_iMediaLoadState == MLS_LOADED ? m_wndSeekBar.GetPos() : 0);
+ return (m_iMediaLoadState == MLS_LOADED ? m_wndSeekBar.GetPos() : 0);
}
REFERENCE_TIME CMainFrame::GetDur() const
{
- __int64 start, stop;
- m_wndSeekBar.GetRange(start, stop);
- return (m_iMediaLoadState == MLS_LOADED ? stop : 0);
+ __int64 start, stop;
+ m_wndSeekBar.GetRange(start, stop);
+ return (m_iMediaLoadState == MLS_LOADED ? stop : 0);
}
void CMainFrame::SeekTo(REFERENCE_TIME rtPos, bool fSeekToKeyFrame)
{
- OAFilterState fs = GetMediaState();
-
- if (rtPos < 0) {
- rtPos = 0;
- }
-
- m_nStepForwardCount = 0;
- if (GetPlaybackMode() != PM_CAPTURE) {
- __int64 start, stop;
- m_wndSeekBar.GetRange(start, stop);
- GUID tf;
- pMS->GetTimeFormat(&tf);
- if (rtPos > stop) {
- rtPos = stop;
- }
- m_wndStatusBar.SetStatusTimer(rtPos, stop, !!m_wndSubresyncBar.IsWindowVisible(), &tf);
- m_OSD.DisplayMessage(OSD_TOPLEFT, m_wndStatusBar.GetStatusTimer(), 1500);
- }
-
- if (GetPlaybackMode() == PM_FILE) {
- if (fs == State_Stopped) {
- SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
- }
-
- HRESULT hr;
-
- if (fSeekToKeyFrame) {
- if (!m_kfs.IsEmpty()) {
- int i = rangebsearch(rtPos, m_kfs);
- if (i >= 1 && i < (int)m_kfs.GetCount() - 1) {
- rtPos = m_kfs[i + ((m_nSeekDirection == SEEK_DIRECTION_FORWARD) ? 1 : (m_nSeekDirection == SEEK_DIRECTION_BACKWARD) ? (-1) : SEEK_DIRECTION_NONE)];
- }
- }
- }
- m_nSeekDirection = SEEK_DIRECTION_NONE;
-
- hr = pMS->SetPositions(&rtPos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
- } else if (GetPlaybackMode() == PM_DVD && m_iDVDDomain == DVD_DOMAIN_Title) {
- if (fs != State_Running) {
- SendMessage(WM_COMMAND, ID_PLAY_PLAY);
- }
-
- DVD_HMSF_TIMECODE tc = RT2HMSF(rtPos);
- pDVDC->PlayAtTime(&tc, DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
- } else if (GetPlaybackMode() == PM_CAPTURE) {
- TRACE(_T("Warning (CMainFrame::SeekTo): Trying to seek in capture mode"));
- }
- m_fEndOfStream = false;
-
- OnTimer(TIMER_STREAMPOSPOLLER);
- OnTimer(TIMER_STREAMPOSPOLLER2);
-
- SendCurrentPositionToApi(true);
-}
+ OAFilterState fs = GetMediaState();
-void CMainFrame::CleanGraph()
-{
- if (!pGB) {
- return;
- }
+ if (rtPos < 0) {
+ rtPos = 0;
+ }
+
+ m_nStepForwardCount = 0;
+ if (GetPlaybackMode() != PM_CAPTURE) {
+ __int64 start, stop;
+ m_wndSeekBar.GetRange(start, stop);
+ GUID tf;
+ pMS->GetTimeFormat(&tf);
+ if (rtPos > stop) {
+ rtPos = stop;
+ }
+ m_wndStatusBar.SetStatusTimer(rtPos, stop, !!m_wndSubresyncBar.IsWindowVisible(), &tf);
+ m_OSD.DisplayMessage(OSD_TOPLEFT, m_wndStatusBar.GetStatusTimer(), 1500);
+ }
- BeginEnumFilters(pGB, pEF, pBF) {
- CComQIPtr<IAMFilterMiscFlags> pAMMF(pBF);
- if (pAMMF && (pAMMF->GetMiscFlags()&AM_FILTER_MISC_FLAGS_IS_SOURCE)) {
- continue;
- }
+ if (GetPlaybackMode() == PM_FILE) {
+ if (fs == State_Stopped) {
+ SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ }
+
+ HRESULT hr;
+
+ if (fSeekToKeyFrame) {
+ if (!m_kfs.IsEmpty()) {
+ int i = rangebsearch(rtPos, m_kfs);
+ if (i >= 1 && i < (int)m_kfs.GetCount() - 1) {
+ rtPos = m_kfs[i + ((m_nSeekDirection == SEEK_DIRECTION_FORWARD) ? 1 : (m_nSeekDirection == SEEK_DIRECTION_BACKWARD) ? (-1) : SEEK_DIRECTION_NONE)];
+ }
+ }
+ }
+ m_nSeekDirection = SEEK_DIRECTION_NONE;
+
+ hr = pMS->SetPositions(&rtPos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
+ } else if (GetPlaybackMode() == PM_DVD && m_iDVDDomain == DVD_DOMAIN_Title) {
+ if (fs != State_Running) {
+ SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ }
+
+ DVD_HMSF_TIMECODE tc = RT2HMSF(rtPos);
+ pDVDC->PlayAtTime(&tc, DVD_CMD_FLAG_Block | DVD_CMD_FLAG_Flush, NULL);
+ } else if (GetPlaybackMode() == PM_CAPTURE) {
+ TRACE(_T("Warning (CMainFrame::SeekTo): Trying to seek in capture mode"));
+ }
+ m_fEndOfStream = false;
- // some capture filters forget to set AM_FILTER_MISC_FLAGS_IS_SOURCE
- // or to implement the IAMFilterMiscFlags interface
- if (pBF == pVidCap || pBF == pAudCap) {
- continue;
- }
+ OnTimer(TIMER_STREAMPOSPOLLER);
+ OnTimer(TIMER_STREAMPOSPOLLER2);
- if (CComQIPtr<IFileSourceFilter>(pBF)) {
- continue;
- }
+ SendCurrentPositionToApi(true);
+}
- int nIn, nOut, nInC, nOutC;
- if (CountPins(pBF, nIn, nOut, nInC, nOutC) > 0 && (nInC+nOutC) == 0) {
- TRACE(CStringW(L"Removing: ") + GetFilterName(pBF) + '\n');
+void CMainFrame::CleanGraph()
+{
+ if (!pGB) {
+ return;
+ }
- pGB->RemoveFilter(pBF);
- pEF->Reset();
- }
- }
- EndEnumFilters;
+ BeginEnumFilters(pGB, pEF, pBF) {
+ CComQIPtr<IAMFilterMiscFlags> pAMMF(pBF);
+ if (pAMMF && (pAMMF->GetMiscFlags()&AM_FILTER_MISC_FLAGS_IS_SOURCE)) {
+ continue;
+ }
+
+ // some capture filters forget to set AM_FILTER_MISC_FLAGS_IS_SOURCE
+ // or to implement the IAMFilterMiscFlags interface
+ if (pBF == pVidCap || pBF == pAudCap) {
+ continue;
+ }
+
+ if (CComQIPtr<IFileSourceFilter>(pBF)) {
+ continue;
+ }
+
+ int nIn, nOut, nInC, nOutC;
+ if (CountPins(pBF, nIn, nOut, nInC, nOutC) > 0 && (nInC + nOutC) == 0) {
+ TRACE(CStringW(L"Removing: ") + GetFilterName(pBF) + '\n');
+
+ pGB->RemoveFilter(pBF);
+ pEF->Reset();
+ }
+ }
+ EndEnumFilters;
}
#define AUDIOBUFFERLEN 500
static void SetLatency(IBaseFilter* pBF, int cbBuffer)
{
- BeginEnumPins(pBF, pEP, pPin) {
- if (CComQIPtr<IAMBufferNegotiation> pAMBN = pPin) {
- ALLOCATOR_PROPERTIES ap;
- ap.cbAlign = -1; // -1 means no preference.
- ap.cbBuffer = cbBuffer;
- ap.cbPrefix = -1;
- ap.cBuffers = -1;
- pAMBN->SuggestAllocatorProperties(&ap);
- }
- }
- EndEnumPins;
+ BeginEnumPins(pBF, pEP, pPin) {
+ if (CComQIPtr<IAMBufferNegotiation> pAMBN = pPin) {
+ ALLOCATOR_PROPERTIES ap;
+ ap.cbAlign = -1; // -1 means no preference.
+ ap.cbBuffer = cbBuffer;
+ ap.cbPrefix = -1;
+ ap.cBuffers = -1;
+ pAMBN->SuggestAllocatorProperties(&ap);
+ }
+ }
+ EndEnumPins;
}
HRESULT CMainFrame::BuildCapture(IPin* pPin, IBaseFilter* pBF[3], const GUID& majortype, AM_MEDIA_TYPE* pmt)
{
- IBaseFilter* pBuff = pBF[0];
- IBaseFilter* pEnc = pBF[1];
- IBaseFilter* pMux = pBF[2];
-
- if (!pPin || !pMux) {
- return E_FAIL;
- }
-
- CString err;
-
- HRESULT hr = S_OK;
-
- CFilterInfo fi;
- if (FAILED(pMux->QueryFilterInfo(&fi)) || !fi.pGraph) {
- pGB->AddFilter(pMux, L"Multiplexer");
- }
-
- CStringW prefix;
- CString type;
- if (majortype == MEDIATYPE_Video) {
- prefix = L"Video ";
- type.LoadString(IDS_CAPTURE_ERROR_VIDEO);
- } else if (majortype == MEDIATYPE_Audio) {
- prefix = L"Audio ";
- type.LoadString(IDS_CAPTURE_ERROR_AUDIO);
- }
-
- if (pBuff) {
- hr = pGB->AddFilter(pBuff, prefix + L"Buffer");
- if (FAILED(hr)) {
- err.Format(IDS_CAPTURE_ERROR_ADD_BUFFER, type);
- MessageBox(err, ResStr(IDS_CAPTURE_ERROR), MB_ICONERROR | MB_OK);
- return hr;
- }
-
- hr = pGB->ConnectFilter(pPin, pBuff);
- if (FAILED(hr)) {
- err.Format(IDS_CAPTURE_ERROR_CONNECT_BUFF, type);
- MessageBox(err, ResStr(IDS_CAPTURE_ERROR), MB_ICONERROR | MB_OK);
- return hr;
- }
-
- pPin = GetFirstPin(pBuff, PINDIR_OUTPUT);
- }
-
- if (pEnc) {
- hr = pGB->AddFilter(pEnc, prefix + L"Encoder");
- if (FAILED(hr)) {
- err.Format(IDS_CAPTURE_ERROR_ADD_ENCODER, type);
- MessageBox(err, ResStr(IDS_CAPTURE_ERROR), MB_ICONERROR | MB_OK);
- return hr;
- }
-
- hr = pGB->ConnectFilter(pPin, pEnc);
- if (FAILED(hr)) {
- err.Format(IDS_CAPTURE_ERROR_CONNECT_ENC, type);
- MessageBox(err, ResStr(IDS_CAPTURE_ERROR), MB_ICONERROR | MB_OK);
- return hr;
- }
-
- pPin = GetFirstPin(pEnc, PINDIR_OUTPUT);
-
- if (CComQIPtr<IAMStreamConfig> pAMSC = pPin) {
- if (pmt->majortype == majortype) {
- hr = pAMSC->SetFormat(pmt);
- if (FAILED(hr)) {
- err.Format(IDS_CAPTURE_ERROR_COMPRESSION, type);
- MessageBox(err, ResStr(IDS_CAPTURE_ERROR), MB_ICONERROR | MB_OK);
- return hr;
- }
- }
- }
-
- }
-
- //if (pMux)
- {
- hr = pGB->ConnectFilter(pPin, pMux);
- if (FAILED(hr)) {
- err.Format(IDS_CAPTURE_ERROR_MULTIPLEXER, type);
- MessageBox(err, ResStr(IDS_CAPTURE_ERROR), MB_ICONERROR | MB_OK);
- return hr;
- }
- }
-
- CleanGraph();
-
- return S_OK;
+ IBaseFilter* pBuff = pBF[0];
+ IBaseFilter* pEnc = pBF[1];
+ IBaseFilter* pMux = pBF[2];
+
+ if (!pPin || !pMux) {
+ return E_FAIL;
+ }
+
+ CString err;
+
+ HRESULT hr = S_OK;
+
+ CFilterInfo fi;
+ if (FAILED(pMux->QueryFilterInfo(&fi)) || !fi.pGraph) {
+ pGB->AddFilter(pMux, L"Multiplexer");
+ }
+
+ CStringW prefix;
+ CString type;
+ if (majortype == MEDIATYPE_Video) {
+ prefix = L"Video ";
+ type.LoadString(IDS_CAPTURE_ERROR_VIDEO);
+ } else if (majortype == MEDIATYPE_Audio) {
+ prefix = L"Audio ";
+ type.LoadString(IDS_CAPTURE_ERROR_AUDIO);
+ }
+
+ if (pBuff) {
+ hr = pGB->AddFilter(pBuff, prefix + L"Buffer");
+ if (FAILED(hr)) {
+ err.Format(IDS_CAPTURE_ERROR_ADD_BUFFER, type);
+ MessageBox(err, ResStr(IDS_CAPTURE_ERROR), MB_ICONERROR | MB_OK);
+ return hr;
+ }
+
+ hr = pGB->ConnectFilter(pPin, pBuff);
+ if (FAILED(hr)) {
+ err.Format(IDS_CAPTURE_ERROR_CONNECT_BUFF, type);
+ MessageBox(err, ResStr(IDS_CAPTURE_ERROR), MB_ICONERROR | MB_OK);
+ return hr;
+ }
+
+ pPin = GetFirstPin(pBuff, PINDIR_OUTPUT);
+ }
+
+ if (pEnc) {
+ hr = pGB->AddFilter(pEnc, prefix + L"Encoder");
+ if (FAILED(hr)) {
+ err.Format(IDS_CAPTURE_ERROR_ADD_ENCODER, type);
+ MessageBox(err, ResStr(IDS_CAPTURE_ERROR), MB_ICONERROR | MB_OK);
+ return hr;
+ }
+
+ hr = pGB->ConnectFilter(pPin, pEnc);
+ if (FAILED(hr)) {
+ err.Format(IDS_CAPTURE_ERROR_CONNECT_ENC, type);
+ MessageBox(err, ResStr(IDS_CAPTURE_ERROR), MB_ICONERROR | MB_OK);
+ return hr;
+ }
+
+ pPin = GetFirstPin(pEnc, PINDIR_OUTPUT);
+
+ if (CComQIPtr<IAMStreamConfig> pAMSC = pPin) {
+ if (pmt->majortype == majortype) {
+ hr = pAMSC->SetFormat(pmt);
+ if (FAILED(hr)) {
+ err.Format(IDS_CAPTURE_ERROR_COMPRESSION, type);
+ MessageBox(err, ResStr(IDS_CAPTURE_ERROR), MB_ICONERROR | MB_OK);
+ return hr;
+ }
+ }
+ }
+
+ }
+
+ //if (pMux)
+ {
+ hr = pGB->ConnectFilter(pPin, pMux);
+ if (FAILED(hr)) {
+ err.Format(IDS_CAPTURE_ERROR_MULTIPLEXER, type);
+ MessageBox(err, ResStr(IDS_CAPTURE_ERROR), MB_ICONERROR | MB_OK);
+ return hr;
+ }
+ }
+
+ CleanGraph();
+
+ return S_OK;
}
bool CMainFrame::BuildToCapturePreviewPin(
- IBaseFilter* pVidCap, IPin** ppVidCapPin, IPin** ppVidPrevPin,
- IBaseFilter* pAudCap, IPin** ppAudCapPin, IPin** ppAudPrevPin)
+ IBaseFilter* pVidCap, IPin** ppVidCapPin, IPin** ppVidPrevPin,
+ IBaseFilter* pAudCap, IPin** ppAudCapPin, IPin** ppAudPrevPin)
{
- HRESULT hr;
+ HRESULT hr;
- *ppVidCapPin = *ppVidPrevPin = NULL;
- *ppAudCapPin = *ppAudPrevPin = NULL;
+ *ppVidCapPin = *ppVidPrevPin = NULL;
+ *ppAudCapPin = *ppAudPrevPin = NULL;
- CComPtr<IPin> pDVAudPin;
+ CComPtr<IPin> pDVAudPin;
- if (pVidCap) {
- CComPtr<IPin> pPin;
- if (!pAudCap // only look for interleaved stream when we don't use any other audio capture source
- && SUCCEEDED(pCGB->FindPin(pVidCap, PINDIR_OUTPUT, &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Interleaved, TRUE, 0, &pPin))) {
- CComPtr<IBaseFilter> pDVSplitter;
- hr = pDVSplitter.CoCreateInstance(CLSID_DVSplitter);
- hr = pGB->AddFilter(pDVSplitter, L"DV Splitter");
+ if (pVidCap) {
+ CComPtr<IPin> pPin;
+ if (!pAudCap // only look for interleaved stream when we don't use any other audio capture source
+ && SUCCEEDED(pCGB->FindPin(pVidCap, PINDIR_OUTPUT, &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Interleaved, TRUE, 0, &pPin))) {
+ CComPtr<IBaseFilter> pDVSplitter;
+ hr = pDVSplitter.CoCreateInstance(CLSID_DVSplitter);
+ hr = pGB->AddFilter(pDVSplitter, L"DV Splitter");
- hr = pCGB->RenderStream(NULL, &MEDIATYPE_Interleaved, pPin, NULL, pDVSplitter);
+ hr = pCGB->RenderStream(NULL, &MEDIATYPE_Interleaved, pPin, NULL, pDVSplitter);
- pPin = NULL;
- hr = pCGB->FindPin(pDVSplitter, PINDIR_OUTPUT, NULL, &MEDIATYPE_Video, TRUE, 0, &pPin);
- hr = pCGB->FindPin(pDVSplitter, PINDIR_OUTPUT, NULL, &MEDIATYPE_Audio, TRUE, 0, &pDVAudPin);
+ pPin = NULL;
+ hr = pCGB->FindPin(pDVSplitter, PINDIR_OUTPUT, NULL, &MEDIATYPE_Video, TRUE, 0, &pPin);
+ hr = pCGB->FindPin(pDVSplitter, PINDIR_OUTPUT, NULL, &MEDIATYPE_Audio, TRUE, 0, &pDVAudPin);
- CComPtr<IBaseFilter> pDVDec;
- hr = pDVDec.CoCreateInstance(CLSID_DVVideoCodec);
- hr = pGB->AddFilter(pDVDec, L"DV Video Decoder");
+ CComPtr<IBaseFilter> pDVDec;
+ hr = pDVDec.CoCreateInstance(CLSID_DVVideoCodec);
+ hr = pGB->AddFilter(pDVDec, L"DV Video Decoder");
- hr = pGB->ConnectFilter(pPin, pDVDec);
+ hr = pGB->ConnectFilter(pPin, pDVDec);
- pPin = NULL;
- hr = pCGB->FindPin(pDVDec, PINDIR_OUTPUT, NULL, &MEDIATYPE_Video, TRUE, 0, &pPin);
- } else if (FAILED(pCGB->FindPin(pVidCap, PINDIR_OUTPUT, &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, TRUE, 0, &pPin))) {
- MessageBox(ResStr(IDS_CAPTURE_ERROR_VID_CAPT_PIN), ResStr(IDS_CAPTURE_ERROR), MB_ICONERROR | MB_OK);
- return false;
- }
+ pPin = NULL;
+ hr = pCGB->FindPin(pDVDec, PINDIR_OUTPUT, NULL, &MEDIATYPE_Video, TRUE, 0, &pPin);
+ } else if (FAILED(pCGB->FindPin(pVidCap, PINDIR_OUTPUT, &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, TRUE, 0, &pPin))) {
+ MessageBox(ResStr(IDS_CAPTURE_ERROR_VID_CAPT_PIN), ResStr(IDS_CAPTURE_ERROR), MB_ICONERROR | MB_OK);
+ return false;
+ }
- CComPtr<IBaseFilter> pSmartTee;
- hr = pSmartTee.CoCreateInstance(CLSID_SmartTee);
- hr = pGB->AddFilter(pSmartTee, L"Smart Tee (video)");
+ CComPtr<IBaseFilter> pSmartTee;
+ hr = pSmartTee.CoCreateInstance(CLSID_SmartTee);
+ hr = pGB->AddFilter(pSmartTee, L"Smart Tee (video)");
- hr = pGB->ConnectFilter(pPin, pSmartTee);
+ hr = pGB->ConnectFilter(pPin, pSmartTee);
- hr = pSmartTee->FindPin(L"Preview", ppVidPrevPin);
- hr = pSmartTee->FindPin(L"Capture", ppVidCapPin);
- }
+ hr = pSmartTee->FindPin(L"Preview", ppVidPrevPin);
+ hr = pSmartTee->FindPin(L"Capture", ppVidCapPin);
+ }
- if (pAudCap || pDVAudPin) {
- CComPtr<IPin> pPin;
- if (pDVAudPin) {
- pPin = pDVAudPin;
- } else if (FAILED(pCGB->FindPin(pAudCap, PINDIR_OUTPUT, &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Audio, TRUE, 0, &pPin))) {
- MessageBox(ResStr(IDS_CAPTURE_ERROR_AUD_CAPT_PIN), ResStr(IDS_CAPTURE_ERROR), MB_ICONERROR | MB_OK);
- return false;
- }
+ if (pAudCap || pDVAudPin) {
+ CComPtr<IPin> pPin;
+ if (pDVAudPin) {
+ pPin = pDVAudPin;
+ } else if (FAILED(pCGB->FindPin(pAudCap, PINDIR_OUTPUT, &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Audio, TRUE, 0, &pPin))) {
+ MessageBox(ResStr(IDS_CAPTURE_ERROR_AUD_CAPT_PIN), ResStr(IDS_CAPTURE_ERROR), MB_ICONERROR | MB_OK);
+ return false;
+ }
- CComPtr<IBaseFilter> pSmartTee;
- hr = pSmartTee.CoCreateInstance(CLSID_SmartTee);
- hr = pGB->AddFilter(pSmartTee, L"Smart Tee (audio)");
+ CComPtr<IBaseFilter> pSmartTee;
+ hr = pSmartTee.CoCreateInstance(CLSID_SmartTee);
+ hr = pGB->AddFilter(pSmartTee, L"Smart Tee (audio)");
- hr = pGB->ConnectFilter(pPin, pSmartTee);
+ hr = pGB->ConnectFilter(pPin, pSmartTee);
- hr = pSmartTee->FindPin(L"Preview", ppAudPrevPin);
- hr = pSmartTee->FindPin(L"Capture", ppAudCapPin);
- }
+ hr = pSmartTee->FindPin(L"Preview", ppAudPrevPin);
+ hr = pSmartTee->FindPin(L"Capture", ppAudCapPin);
+ }
- return true;
+ return true;
}
bool CMainFrame::BuildGraphVideoAudio(int fVPreview, bool fVCapture, int fAPreview, bool fACapture)
{
- if (!pCGB) {
- return false;
- }
-
- SaveMediaState;
-
- HRESULT hr;
-
- pGB->NukeDownstream(pVidCap);
- pGB->NukeDownstream(pAudCap);
-
- CleanGraph();
-
- if (pAMVSCCap) {
- hr = pAMVSCCap->SetFormat(&m_wndCaptureBar.m_capdlg.m_mtv);
- }
- if (pAMVSCPrev) {
- hr = pAMVSCPrev->SetFormat(&m_wndCaptureBar.m_capdlg.m_mtv);
- }
- if (pAMASC) {
- hr = pAMASC->SetFormat(&m_wndCaptureBar.m_capdlg.m_mta);
- }
-
- CComPtr<IBaseFilter> pVidBuffer = m_wndCaptureBar.m_capdlg.m_pVidBuffer;
- CComPtr<IBaseFilter> pAudBuffer = m_wndCaptureBar.m_capdlg.m_pAudBuffer;
- CComPtr<IBaseFilter> pVidEnc = m_wndCaptureBar.m_capdlg.m_pVidEnc;
- CComPtr<IBaseFilter> pAudEnc = m_wndCaptureBar.m_capdlg.m_pAudEnc;
- CComPtr<IBaseFilter> pMux = m_wndCaptureBar.m_capdlg.m_pMux;
- CComPtr<IBaseFilter> pDst = m_wndCaptureBar.m_capdlg.m_pDst;
- CComPtr<IBaseFilter> pAudMux = m_wndCaptureBar.m_capdlg.m_pAudMux;
- CComPtr<IBaseFilter> pAudDst = m_wndCaptureBar.m_capdlg.m_pAudDst;
-
- bool fFileOutput = (pMux && pDst) || (pAudMux && pAudDst);
- bool fCapture = (fVCapture || fACapture);
-
- if (pAudCap) {
- AM_MEDIA_TYPE* pmt = &m_wndCaptureBar.m_capdlg.m_mta;
- int ms = (fACapture && fFileOutput && m_wndCaptureBar.m_capdlg.m_fAudOutput) ? AUDIOBUFFERLEN : 60;
- if (pMux != pAudMux && fACapture) {
- SetLatency(pAudCap, -1);
- } else if (pmt->pbFormat) {
- SetLatency(pAudCap, ((WAVEFORMATEX*)pmt->pbFormat)->nAvgBytesPerSec * ms / 1000);
- }
- }
-
- CComPtr<IPin> pVidCapPin, pVidPrevPin, pAudCapPin, pAudPrevPin;
- BuildToCapturePreviewPin(pVidCap, &pVidCapPin, &pVidPrevPin, pAudCap, &pAudCapPin, &pAudPrevPin);
-
- //if (pVidCap)
- {
- bool fVidPrev = pVidPrevPin && fVPreview;
- bool fVidCap = pVidCapPin && fVCapture && fFileOutput && m_wndCaptureBar.m_capdlg.m_fVidOutput;
-
- if (fVPreview == 2 && !fVidCap && pVidCapPin) {
- pVidPrevPin = pVidCapPin;
- pVidCapPin = NULL;
- }
-
- if (fVidPrev) {
- m_pCAP = NULL;
- m_pCAP2 = NULL;
- pGB->Render(pVidPrevPin);
- pGB->FindInterface(__uuidof(ISubPicAllocatorPresenter), (void**)&m_pCAP, TRUE);
- pGB->FindInterface(__uuidof(ISubPicAllocatorPresenter2), (void**)&m_pCAP2, TRUE);
- }
-
- if (fVidCap) {
- IBaseFilter* pBF[3] = {pVidBuffer, pVidEnc, pMux};
- HRESULT hr = BuildCapture(pVidCapPin, pBF, MEDIATYPE_Video, &m_wndCaptureBar.m_capdlg.m_mtcv);
- UNREFERENCED_PARAMETER(hr);
- }
-
- pAMDF = NULL;
- pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pVidCap, IID_IAMDroppedFrames, (void**)&pAMDF);
- }
-
- //if (pAudCap)
- {
- bool fAudPrev = pAudPrevPin && fAPreview;
- bool fAudCap = pAudCapPin && fACapture && fFileOutput && m_wndCaptureBar.m_capdlg.m_fAudOutput;
-
- if (fAPreview == 2 && !fAudCap && pAudCapPin) {
- pAudPrevPin = pAudCapPin;
- pAudCapPin = NULL;
- }
-
- if (fAudPrev) {
- pGB->Render(pAudPrevPin);
- }
-
- if (fAudCap) {
- IBaseFilter* pBF[3] = {pAudBuffer, pAudEnc, pAudMux ? pAudMux : pMux};
- HRESULT hr = BuildCapture(pAudCapPin, pBF, MEDIATYPE_Audio, &m_wndCaptureBar.m_capdlg.m_mtca);
- UNREFERENCED_PARAMETER(hr);
- }
- }
-
- if ((pVidCap || pAudCap) && fCapture && fFileOutput) {
- if (pMux != pDst) {
- hr = pGB->AddFilter(pDst, L"File Writer V/A");
- hr = pGB->ConnectFilter(GetFirstPin(pMux, PINDIR_OUTPUT), pDst);
- }
-
- if (CComQIPtr<IConfigAviMux> pCAM = pMux) {
- int nIn, nOut, nInC, nOutC;
- CountPins(pMux, nIn, nOut, nInC, nOutC);
- pCAM->SetMasterStream(nInC-1);
- //pCAM->SetMasterStream(-1);
- pCAM->SetOutputCompatibilityIndex(FALSE);
- }
-
- if (CComQIPtr<IConfigInterleaving> pCI = pMux) {
- //if (FAILED(pCI->put_Mode(INTERLEAVE_CAPTURE)))
- if (FAILED(pCI->put_Mode(INTERLEAVE_NONE_BUFFERED))) {
- pCI->put_Mode(INTERLEAVE_NONE);
- }
-
- REFERENCE_TIME rtInterleave = 10000i64*AUDIOBUFFERLEN, rtPreroll = 0; //10000i64*500
- pCI->put_Interleaving(&rtInterleave, &rtPreroll);
- }
-
- if (pMux != pAudMux && pAudMux != pAudDst) {
- hr = pGB->AddFilter(pAudDst, L"File Writer A");
- hr = pGB->ConnectFilter(GetFirstPin(pAudMux, PINDIR_OUTPUT), pAudDst);
- }
- }
-
- REFERENCE_TIME stop = MAX_TIME;
- hr = pCGB->ControlStream(&PIN_CATEGORY_CAPTURE, NULL, NULL, NULL, &stop, 0, 0); // stop in the infinite
-
- CleanGraph();
-
- OpenSetupVideo();
- OpenSetupAudio();
- OpenSetupStatsBar();
- OpenSetupStatusBar();
-
- RestoreMediaState;
-
- return true;
+ if (!pCGB) {
+ return false;
+ }
+
+ SaveMediaState;
+
+ HRESULT hr;
+
+ pGB->NukeDownstream(pVidCap);
+ pGB->NukeDownstream(pAudCap);
+
+ CleanGraph();
+
+ if (pAMVSCCap) {
+ hr = pAMVSCCap->SetFormat(&m_wndCaptureBar.m_capdlg.m_mtv);
+ }
+ if (pAMVSCPrev) {
+ hr = pAMVSCPrev->SetFormat(&m_wndCaptureBar.m_capdlg.m_mtv);
+ }
+ if (pAMASC) {
+ hr = pAMASC->SetFormat(&m_wndCaptureBar.m_capdlg.m_mta);
+ }
+
+ CComPtr<IBaseFilter> pVidBuffer = m_wndCaptureBar.m_capdlg.m_pVidBuffer;
+ CComPtr<IBaseFilter> pAudBuffer = m_wndCaptureBar.m_capdlg.m_pAudBuffer;
+ CComPtr<IBaseFilter> pVidEnc = m_wndCaptureBar.m_capdlg.m_pVidEnc;
+ CComPtr<IBaseFilter> pAudEnc = m_wndCaptureBar.m_capdlg.m_pAudEnc;
+ CComPtr<IBaseFilter> pMux = m_wndCaptureBar.m_capdlg.m_pMux;
+ CComPtr<IBaseFilter> pDst = m_wndCaptureBar.m_capdlg.m_pDst;
+ CComPtr<IBaseFilter> pAudMux = m_wndCaptureBar.m_capdlg.m_pAudMux;
+ CComPtr<IBaseFilter> pAudDst = m_wndCaptureBar.m_capdlg.m_pAudDst;
+
+ bool fFileOutput = (pMux && pDst) || (pAudMux && pAudDst);
+ bool fCapture = (fVCapture || fACapture);
+
+ if (pAudCap) {
+ AM_MEDIA_TYPE* pmt = &m_wndCaptureBar.m_capdlg.m_mta;
+ int ms = (fACapture && fFileOutput && m_wndCaptureBar.m_capdlg.m_fAudOutput) ? AUDIOBUFFERLEN : 60;
+ if (pMux != pAudMux && fACapture) {
+ SetLatency(pAudCap, -1);
+ } else if (pmt->pbFormat) {
+ SetLatency(pAudCap, ((WAVEFORMATEX*)pmt->pbFormat)->nAvgBytesPerSec * ms / 1000);
+ }
+ }
+
+ CComPtr<IPin> pVidCapPin, pVidPrevPin, pAudCapPin, pAudPrevPin;
+ BuildToCapturePreviewPin(pVidCap, &pVidCapPin, &pVidPrevPin, pAudCap, &pAudCapPin, &pAudPrevPin);
+
+ //if (pVidCap)
+ {
+ bool fVidPrev = pVidPrevPin && fVPreview;
+ bool fVidCap = pVidCapPin && fVCapture && fFileOutput && m_wndCaptureBar.m_capdlg.m_fVidOutput;
+
+ if (fVPreview == 2 && !fVidCap && pVidCapPin) {
+ pVidPrevPin = pVidCapPin;
+ pVidCapPin = NULL;
+ }
+
+ if (fVidPrev) {
+ m_pCAP = NULL;
+ m_pCAP2 = NULL;
+ pGB->Render(pVidPrevPin);
+ pGB->FindInterface(__uuidof(ISubPicAllocatorPresenter), (void**)&m_pCAP, TRUE);
+ pGB->FindInterface(__uuidof(ISubPicAllocatorPresenter2), (void**)&m_pCAP2, TRUE);
+ }
+
+ if (fVidCap) {
+ IBaseFilter* pBF[3] = {pVidBuffer, pVidEnc, pMux};
+ HRESULT hr = BuildCapture(pVidCapPin, pBF, MEDIATYPE_Video, &m_wndCaptureBar.m_capdlg.m_mtcv);
+ UNREFERENCED_PARAMETER(hr);
+ }
+
+ pAMDF = NULL;
+ pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pVidCap, IID_IAMDroppedFrames, (void**)&pAMDF);
+ }
+
+ //if (pAudCap)
+ {
+ bool fAudPrev = pAudPrevPin && fAPreview;
+ bool fAudCap = pAudCapPin && fACapture && fFileOutput && m_wndCaptureBar.m_capdlg.m_fAudOutput;
+
+ if (fAPreview == 2 && !fAudCap && pAudCapPin) {
+ pAudPrevPin = pAudCapPin;
+ pAudCapPin = NULL;
+ }
+
+ if (fAudPrev) {
+ pGB->Render(pAudPrevPin);
+ }
+
+ if (fAudCap) {
+ IBaseFilter* pBF[3] = {pAudBuffer, pAudEnc, pAudMux ? pAudMux : pMux};
+ HRESULT hr = BuildCapture(pAudCapPin, pBF, MEDIATYPE_Audio, &m_wndCaptureBar.m_capdlg.m_mtca);
+ UNREFERENCED_PARAMETER(hr);
+ }
+ }
+
+ if ((pVidCap || pAudCap) && fCapture && fFileOutput) {
+ if (pMux != pDst) {
+ hr = pGB->AddFilter(pDst, L"File Writer V/A");
+ hr = pGB->ConnectFilter(GetFirstPin(pMux, PINDIR_OUTPUT), pDst);
+ }
+
+ if (CComQIPtr<IConfigAviMux> pCAM = pMux) {
+ int nIn, nOut, nInC, nOutC;
+ CountPins(pMux, nIn, nOut, nInC, nOutC);
+ pCAM->SetMasterStream(nInC - 1);
+ //pCAM->SetMasterStream(-1);
+ pCAM->SetOutputCompatibilityIndex(FALSE);
+ }
+
+ if (CComQIPtr<IConfigInterleaving> pCI = pMux) {
+ //if (FAILED(pCI->put_Mode(INTERLEAVE_CAPTURE)))
+ if (FAILED(pCI->put_Mode(INTERLEAVE_NONE_BUFFERED))) {
+ pCI->put_Mode(INTERLEAVE_NONE);
+ }
+
+ REFERENCE_TIME rtInterleave = 10000i64 * AUDIOBUFFERLEN, rtPreroll = 0; //10000i64*500
+ pCI->put_Interleaving(&rtInterleave, &rtPreroll);
+ }
+
+ if (pMux != pAudMux && pAudMux != pAudDst) {
+ hr = pGB->AddFilter(pAudDst, L"File Writer A");
+ hr = pGB->ConnectFilter(GetFirstPin(pAudMux, PINDIR_OUTPUT), pAudDst);
+ }
+ }
+
+ REFERENCE_TIME stop = MAX_TIME;
+ hr = pCGB->ControlStream(&PIN_CATEGORY_CAPTURE, NULL, NULL, NULL, &stop, 0, 0); // stop in the infinite
+
+ CleanGraph();
+
+ OpenSetupVideo();
+ OpenSetupAudio();
+ OpenSetupStatsBar();
+ OpenSetupStatusBar();
+
+ RestoreMediaState;
+
+ return true;
}
bool CMainFrame::StartCapture()
{
- if (!pCGB || m_fCapturing) {
- return false;
- }
+ if (!pCGB || m_fCapturing) {
+ return false;
+ }
- if (!m_wndCaptureBar.m_capdlg.m_pMux && !m_wndCaptureBar.m_capdlg.m_pDst) {
- return false;
- }
+ if (!m_wndCaptureBar.m_capdlg.m_pMux && !m_wndCaptureBar.m_capdlg.m_pDst) {
+ return false;
+ }
- HRESULT hr;
+ HRESULT hr;
- ::SetPriorityClass(::GetCurrentProcess(), HIGH_PRIORITY_CLASS);
+ ::SetPriorityClass(::GetCurrentProcess(), HIGH_PRIORITY_CLASS);
- // rare to see two capture filters to support IAMPushSource at the same time...
- //hr = CComQIPtr<IAMGraphStreams>(pGB)->SyncUsingStreamOffset(TRUE); // TODO:
+ // rare to see two capture filters to support IAMPushSource at the same time...
+ //hr = CComQIPtr<IAMGraphStreams>(pGB)->SyncUsingStreamOffset(TRUE); // TODO:
- BuildGraphVideoAudio(
- m_wndCaptureBar.m_capdlg.m_fVidPreview, true,
- m_wndCaptureBar.m_capdlg.m_fAudPreview, true);
+ BuildGraphVideoAudio(
+ m_wndCaptureBar.m_capdlg.m_fVidPreview, true,
+ m_wndCaptureBar.m_capdlg.m_fAudPreview, true);
- hr = pME->CancelDefaultHandling(EC_REPAINT);
+ hr = pME->CancelDefaultHandling(EC_REPAINT);
- SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ SendMessage(WM_COMMAND, ID_PLAY_PLAY);
- m_fCapturing = true;
+ m_fCapturing = true;
- return true;
+ return true;
}
bool CMainFrame::StopCapture()
{
- if (!pCGB || !m_fCapturing) {
- return false;
- }
+ if (!pCGB || !m_fCapturing) {
+ return false;
+ }
- if (!m_wndCaptureBar.m_capdlg.m_pMux && !m_wndCaptureBar.m_capdlg.m_pDst) {
- return false;
- }
+ if (!m_wndCaptureBar.m_capdlg.m_pMux && !m_wndCaptureBar.m_capdlg.m_pDst) {
+ return false;
+ }
- HRESULT hr;
+ HRESULT hr;
- m_wndStatusBar.SetStatusMessage(ResStr(IDS_CONTROLS_COMPLETING));
+ m_wndStatusBar.SetStatusMessage(ResStr(IDS_CONTROLS_COMPLETING));
- m_fCapturing = false;
+ m_fCapturing = false;
- BuildGraphVideoAudio(
- m_wndCaptureBar.m_capdlg.m_fVidPreview, false,
- m_wndCaptureBar.m_capdlg.m_fAudPreview, false);
+ BuildGraphVideoAudio(
+ m_wndCaptureBar.m_capdlg.m_fVidPreview, false,
+ m_wndCaptureBar.m_capdlg.m_fAudPreview, false);
- hr = pME->RestoreDefaultHandling(EC_REPAINT);
+ hr = pME->RestoreDefaultHandling(EC_REPAINT);
- ::SetPriorityClass(::GetCurrentProcess(), AfxGetAppSettings().dwPriority);
+ ::SetPriorityClass(::GetCurrentProcess(), AfxGetAppSettings().dwPriority);
- m_rtDurationOverride = -1;
+ m_rtDurationOverride = -1;
- return true;
+ return true;
}
//
void CMainFrame::ShowOptions(int idPage)
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- CPPageSheet options(ResStr(IDS_OPTIONS_CAPTION), pGB, GetModalParent(), idPage);
+ CPPageSheet options(ResStr(IDS_OPTIONS_CAPTION), pGB, GetModalParent(), idPage);
- m_bInOptions = true;
- if (options.DoModal() == IDOK) {
- m_bInOptions = false;
- if (!m_fFullScreen) {
- SetAlwaysOnTop(s.iOnTop);
- }
+ m_bInOptions = true;
+ if (options.DoModal() == IDOK) {
+ m_bInOptions = false;
+ if (!m_fFullScreen) {
+ SetAlwaysOnTop(s.iOnTop);
+ }
- m_wndView.LoadLogo();
+ m_wndView.LoadLogo();
- s.UpdateData(true);
+ s.UpdateData(true);
- }
- Invalidate();
- m_bInOptions = false;
+ }
+ Invalidate();
+ m_bInOptions = false;
}
void CMainFrame::StartWebServer(int nPort)
{
- if (!m_pWebServer) {
- m_pWebServer.Attach(DNew CWebServer(this, nPort));
- }
+ if (!m_pWebServer) {
+ m_pWebServer.Attach(DNew CWebServer(this, nPort));
+ }
}
void CMainFrame::StopWebServer()
{
- if (m_pWebServer) {
- m_pWebServer.Free();
- }
+ if (m_pWebServer) {
+ m_pWebServer.Free();
+ }
}
CString CMainFrame::GetStatusMessage() const
{
- CString str;
- m_wndStatusBar.m_status.GetWindowText(str);
- return str;
+ CString str;
+ m_wndStatusBar.m_status.GetWindowText(str);
+ return str;
}
void CMainFrame::SendStatusMessage(CString msg, int nTimeOut)
{
- KillTimer(TIMER_STATUSERASER);
+ KillTimer(TIMER_STATUSERASER);
- m_playingmsg.Empty();
- if (nTimeOut <= 0) {
- return;
- }
+ m_playingmsg.Empty();
+ if (nTimeOut <= 0) {
+ return;
+ }
- m_playingmsg = msg;
- SetTimer(TIMER_STATUSERASER, nTimeOut, NULL);
- //m_Lcd.SetStatusMessage(msg, nTimeOut);
+ m_playingmsg = msg;
+ SetTimer(TIMER_STATUSERASER, nTimeOut, NULL);
+ //m_Lcd.SetStatusMessage(msg, nTimeOut);
}
void CMainFrame::OpenCurPlaylistItem(REFERENCE_TIME rtStart)
{
- if (m_wndPlaylistBar.GetCount() == 0) {
- return;
- }
+ if (m_wndPlaylistBar.GetCount() == 0) {
+ return;
+ }
- CPlaylistItem pli;
- if (!m_wndPlaylistBar.GetCur(pli)) {
- m_wndPlaylistBar.SetFirstSelected();
- }
- if (!m_wndPlaylistBar.GetCur(pli)) {
- return;
- }
+ CPlaylistItem pli;
+ if (!m_wndPlaylistBar.GetCur(pli)) {
+ m_wndPlaylistBar.SetFirstSelected();
+ }
+ if (!m_wndPlaylistBar.GetCur(pli)) {
+ return;
+ }
- CAutoPtr<OpenMediaData> p(m_wndPlaylistBar.GetCurOMD(rtStart));
- if (p) {
- OpenMedia(p);
- }
+ CAutoPtr<OpenMediaData> p(m_wndPlaylistBar.GetCurOMD(rtStart));
+ if (p) {
+ OpenMedia(p);
+ }
}
void CMainFrame::AddCurDevToPlaylist()
{
- if (GetPlaybackMode() == PM_CAPTURE) {
- m_wndPlaylistBar.Append(
- m_VidDispName,
- m_AudDispName,
- m_wndCaptureBar.m_capdlg.GetVideoInput(),
- m_wndCaptureBar.m_capdlg.GetVideoChannel(),
- m_wndCaptureBar.m_capdlg.GetAudioInput()
- );
- }
+ if (GetPlaybackMode() == PM_CAPTURE) {
+ m_wndPlaylistBar.Append(
+ m_VidDispName,
+ m_AudDispName,
+ m_wndCaptureBar.m_capdlg.GetVideoInput(),
+ m_wndCaptureBar.m_capdlg.GetVideoChannel(),
+ m_wndCaptureBar.m_capdlg.GetAudioInput()
+ );
+ }
}
void CMainFrame::OpenMedia(CAutoPtr<OpenMediaData> pOMD)
{
- // shortcut
- if (OpenDeviceData* p = dynamic_cast<OpenDeviceData*>(pOMD.m_p)) {
- if (m_iMediaLoadState == MLS_LOADED && pAMTuner
- && m_VidDispName == p->DisplayName[0] && m_AudDispName == p->DisplayName[1]) {
- m_wndCaptureBar.m_capdlg.SetVideoInput(p->vinput);
- m_wndCaptureBar.m_capdlg.SetVideoChannel(p->vchannel);
- m_wndCaptureBar.m_capdlg.SetAudioInput(p->ainput);
- SendNowPlayingToMSN();
- return;
- }
- }
-
- if (m_iMediaLoadState != MLS_CLOSED) {
- CloseMedia();
- }
-
- //m_iMediaLoadState = MLS_LOADING; // HACK: hides the logo
-
- AppSettings& s = AfxGetAppSettings();
-
- bool fUseThread = m_pGraphThread && AfxGetAppSettings().fEnableWorkerThreadForOpening
- // don't use a worker thread in D3DFullscreen mode except madVR
- && (!AfxGetAppSettings().IsD3DFullscreen() || AfxGetAppSettings().iDSVideoRendererType==VIDRNDT_DS_MADVR);
-
- if (OpenFileData* p = dynamic_cast<OpenFileData*>(pOMD.m_p)) {
- if (p->fns.GetCount() > 0) {
- engine_t e = s.m_Formats.GetEngine(p->fns.GetHead());
- if (e != DirectShow /*&& e != RealMedia && e != QuickTime*/) {
- fUseThread = false;
- }
- }
- } else if (OpenDeviceData* p = dynamic_cast<OpenDeviceData*>(pOMD.m_p)) {
- fUseThread = false;
- }
-
- if (fUseThread) {
- m_pGraphThread->PostThreadMessage(CGraphThread::TM_OPEN, 0, (LPARAM)pOMD.Detach());
- m_bOpenedThruThread = true;
- } else {
- OpenMediaPrivate(pOMD);
- m_bOpenedThruThread = false;
- }
+ // shortcut
+ if (OpenDeviceData* p = dynamic_cast<OpenDeviceData*>(pOMD.m_p)) {
+ if (m_iMediaLoadState == MLS_LOADED && pAMTuner
+ && m_VidDispName == p->DisplayName[0] && m_AudDispName == p->DisplayName[1]) {
+ m_wndCaptureBar.m_capdlg.SetVideoInput(p->vinput);
+ m_wndCaptureBar.m_capdlg.SetVideoChannel(p->vchannel);
+ m_wndCaptureBar.m_capdlg.SetAudioInput(p->ainput);
+ SendNowPlayingToMSN();
+ return;
+ }
+ }
+
+ if (m_iMediaLoadState != MLS_CLOSED) {
+ CloseMedia();
+ }
+
+ //m_iMediaLoadState = MLS_LOADING; // HACK: hides the logo
+
+ AppSettings& s = AfxGetAppSettings();
+
+ bool fUseThread = m_pGraphThread && AfxGetAppSettings().fEnableWorkerThreadForOpening
+ // don't use a worker thread in D3DFullscreen mode except madVR
+ && (!AfxGetAppSettings().IsD3DFullscreen() || AfxGetAppSettings().iDSVideoRendererType == VIDRNDT_DS_MADVR);
+
+ if (OpenFileData* p = dynamic_cast<OpenFileData*>(pOMD.m_p)) {
+ if (p->fns.GetCount() > 0) {
+ engine_t e = s.m_Formats.GetEngine(p->fns.GetHead());
+ if (e != DirectShow /*&& e != RealMedia && e != QuickTime*/) {
+ fUseThread = false;
+ }
+ }
+ } else if (OpenDeviceData* p = dynamic_cast<OpenDeviceData*>(pOMD.m_p)) {
+ fUseThread = false;
+ }
+
+ if (fUseThread) {
+ m_pGraphThread->PostThreadMessage(CGraphThread::TM_OPEN, 0, (LPARAM)pOMD.Detach());
+ m_bOpenedThruThread = true;
+ } else {
+ OpenMediaPrivate(pOMD);
+ m_bOpenedThruThread = false;
+ }
}
bool CMainFrame::ResetDevice()
{
- if (m_pCAP) {
- return m_pCAP->ResetDevice();
- }
- return true;
+ if (m_pCAP) {
+ return m_pCAP->ResetDevice();
+ }
+ return true;
}
bool CMainFrame::DisplayChange()
{
- if (m_pCAP) {
- return m_pCAP->DisplayChange();
- }
- return true;
+ if (m_pCAP) {
+ return m_pCAP->DisplayChange();
+ }
+ return true;
}
void CMainFrame::CloseMedia()
{
- if (m_iMediaLoadState == MLS_CLOSING) {
- TRACE(_T("WARNING: CMainFrame::CloseMedia() called twice or more\n"));
- return;
- }
+ if (m_iMediaLoadState == MLS_CLOSING) {
+ TRACE(_T("WARNING: CMainFrame::CloseMedia() called twice or more\n"));
+ return;
+ }
- int nTimeWaited = 0;
+ int nTimeWaited = 0;
- while (m_iMediaLoadState == MLS_LOADING) {
- m_fOpeningAborted = true;
+ while (m_iMediaLoadState == MLS_LOADING) {
+ m_fOpeningAborted = true;
- if (pGB) {
- pGB->Abort(); // TODO: lock on graph objects somehow, this is not thread safe
- }
+ if (pGB) {
+ pGB->Abort(); // TODO: lock on graph objects somehow, this is not thread safe
+ }
- if (nTimeWaited > 5*1000 && m_pGraphThread) {
- MessageBeep(MB_ICONEXCLAMATION);
- TRACE(_T("CRITICAL ERROR: !!! Must kill opener thread !!!"));
- TerminateThread(m_pGraphThread->m_hThread, (DWORD)-1);
- m_pGraphThread = (CGraphThread*)AfxBeginThread(RUNTIME_CLASS(CGraphThread));
- m_bOpenedThruThread = false;
- break;
- }
+ if (nTimeWaited > 5 * 1000 && m_pGraphThread) {
+ MessageBeep(MB_ICONEXCLAMATION);
+ TRACE(_T("CRITICAL ERROR: !!! Must kill opener thread !!!"));
+ TerminateThread(m_pGraphThread->m_hThread, (DWORD) - 1);
+ m_pGraphThread = (CGraphThread*)AfxBeginThread(RUNTIME_CLASS(CGraphThread));
+ m_bOpenedThruThread = false;
+ break;
+ }
- Sleep(50);
+ Sleep(50);
- nTimeWaited += 50;
- }
+ nTimeWaited += 50;
+ }
- m_fOpeningAborted = false;
+ m_fOpeningAborted = false;
- m_closingmsg.Empty();
+ m_closingmsg.Empty();
- SetLoadState (MLS_CLOSING);
+ SetLoadState(MLS_CLOSING);
- OnFilePostClosemedia();
+ OnFilePostClosemedia();
- if (m_pGraphThread && m_bOpenedThruThread) {
- CAMEvent e;
- m_pGraphThread->PostThreadMessage(CGraphThread::TM_CLOSE, 0, (LPARAM)&e);
- e.Wait(); // either opening or closing has to be blocked to prevent reentering them, closing is the better choice
- } else {
- CloseMediaPrivate();
- }
+ if (m_pGraphThread && m_bOpenedThruThread) {
+ CAMEvent e;
+ m_pGraphThread->PostThreadMessage(CGraphThread::TM_CLOSE, 0, (LPARAM)&e);
+ e.Wait(); // either opening or closing has to be blocked to prevent reentering them, closing is the better choice
+ } else {
+ CloseMediaPrivate();
+ }
- UnloadExternalObjects();
+ UnloadExternalObjects();
- if (m_pFullscreenWnd->IsWindow()) {
- m_pFullscreenWnd->ShowWindow (SW_HIDE);
- }
+ if (m_pFullscreenWnd->IsWindow()) {
+ m_pFullscreenWnd->ShowWindow(SW_HIDE);
+ }
}
void CMainFrame::StartTunerScan(CAutoPtr<TunerScanData> pTSD)
{
- if (m_pGraphThread) {
- m_pGraphThread->PostThreadMessage(CGraphThread::TM_TUNER_SCAN, 0, (LPARAM)pTSD.Detach());
- } else {
- DoTunerScan(pTSD);
- }
+ if (m_pGraphThread) {
+ m_pGraphThread->PostThreadMessage(CGraphThread::TM_TUNER_SCAN, 0, (LPARAM)pTSD.Detach());
+ } else {
+ DoTunerScan(pTSD);
+ }
}
void CMainFrame::StopTunerScan()
{
- m_bStopTunerScan = true;
+ m_bStopTunerScan = true;
}
void CMainFrame::DisplayCurrentChannelOSD()
{
- AppSettings& s = AfxGetAppSettings();
- CDVBChannel* pChannel = s.FindChannelByPref(s.nDVBLastChannel);
- CString osd;
- int i = osd.Find(_T("\n"));
- PresentFollowing NowNext;
-
- if (pChannel != NULL) {
- // Get EIT information:
- CComQIPtr<IBDATuner> pTun = pGB;
- if (pTun) {
- pTun->UpdatePSI(NowNext);
- }
- NowNext.cPresent.Insert(0,_T(" "));
- osd = pChannel->GetName()+ NowNext.cPresent;
- if (i > 0) {
- osd.Delete(i, osd.GetLength()-i);
- }
- m_OSD.DisplayMessage(OSD_TOPLEFT, osd ,3500);
- }
+ AppSettings& s = AfxGetAppSettings();
+ CDVBChannel* pChannel = s.FindChannelByPref(s.nDVBLastChannel);
+ CString osd;
+ int i = osd.Find(_T("\n"));
+ PresentFollowing NowNext;
+
+ if (pChannel != NULL) {
+ // Get EIT information:
+ CComQIPtr<IBDATuner> pTun = pGB;
+ if (pTun) {
+ pTun->UpdatePSI(NowNext);
+ }
+ NowNext.cPresent.Insert(0, _T(" "));
+ osd = pChannel->GetName() + NowNext.cPresent;
+ if (i > 0) {
+ osd.Delete(i, osd.GetLength() - i);
+ }
+ m_OSD.DisplayMessage(OSD_TOPLEFT, osd , 3500);
+ }
}
void CMainFrame::DisplayCurrentChannelInfo()
{
- AppSettings& s = AfxGetAppSettings();
- CDVBChannel* pChannel = s.FindChannelByPref(s.nDVBLastChannel);
- CString osd;
- PresentFollowing NowNext;
-
- if (pChannel != NULL) {
- // Get EIT information:
- CComQIPtr<IBDATuner> pTun = pGB;
- if (pTun) {
- pTun->UpdatePSI(NowNext);
- }
-
- osd = NowNext.cPresent + _T(". ") + NowNext.StartTime + _T(" - ") + NowNext.Duration + _T(". ") + NowNext.SummaryDesc +_T(" ");
- int i = osd.Find(_T("\n"));
- if (i > 0) {
- osd.Delete(i, osd.GetLength()-i);
- }
- m_OSD.DisplayMessage(OSD_TOPLEFT, osd ,8000, 12);
- }
+ AppSettings& s = AfxGetAppSettings();
+ CDVBChannel* pChannel = s.FindChannelByPref(s.nDVBLastChannel);
+ CString osd;
+ PresentFollowing NowNext;
+
+ if (pChannel != NULL) {
+ // Get EIT information:
+ CComQIPtr<IBDATuner> pTun = pGB;
+ if (pTun) {
+ pTun->UpdatePSI(NowNext);
+ }
+
+ osd = NowNext.cPresent + _T(". ") + NowNext.StartTime + _T(" - ") + NowNext.Duration + _T(". ") + NowNext.SummaryDesc + _T(" ");
+ int i = osd.Find(_T("\n"));
+ if (i > 0) {
+ osd.Delete(i, osd.GetLength() - i);
+ }
+ m_OSD.DisplayMessage(OSD_TOPLEFT, osd , 8000, 12);
+ }
}
//
@@ -14521,1352 +14516,1347 @@ IMPLEMENT_DYNCREATE(CGraphThread, CWinThread)
BOOL CGraphThread::InitInstance()
{
- SetThreadName((DWORD)-1, "GraphThread");
- AfxSocketInit();
- return SUCCEEDED(CoInitialize(0)) ? TRUE : FALSE;
+ SetThreadName((DWORD) - 1, "GraphThread");
+ AfxSocketInit();
+ return SUCCEEDED(CoInitialize(0)) ? TRUE : FALSE;
}
int CGraphThread::ExitInstance()
{
- CoUninitialize();
- return __super::ExitInstance();
+ CoUninitialize();
+ return __super::ExitInstance();
}
BEGIN_MESSAGE_MAP(CGraphThread, CWinThread)
- ON_THREAD_MESSAGE(TM_EXIT, OnExit)
- ON_THREAD_MESSAGE(TM_OPEN, OnOpen)
- ON_THREAD_MESSAGE(TM_CLOSE, OnClose)
- ON_THREAD_MESSAGE(TM_RESET, OnReset)
- ON_THREAD_MESSAGE(TM_TUNER_SCAN, OnTunerScan)
- ON_THREAD_MESSAGE(TM_DISPLAY_CHANGE, OnDisplayChange)
+ ON_THREAD_MESSAGE(TM_EXIT, OnExit)
+ ON_THREAD_MESSAGE(TM_OPEN, OnOpen)
+ ON_THREAD_MESSAGE(TM_CLOSE, OnClose)
+ ON_THREAD_MESSAGE(TM_RESET, OnReset)
+ ON_THREAD_MESSAGE(TM_TUNER_SCAN, OnTunerScan)
+ ON_THREAD_MESSAGE(TM_DISPLAY_CHANGE, OnDisplayChange)
END_MESSAGE_MAP()
void CGraphThread::OnExit(WPARAM wParam, LPARAM lParam)
{
- PostQuitMessage(0);
- if (CAMEvent* e = (CAMEvent*)lParam) {
- e->Set();
- }
+ PostQuitMessage(0);
+ if (CAMEvent* e = (CAMEvent*)lParam) {
+ e->Set();
+ }
}
void CGraphThread::OnOpen(WPARAM wParam, LPARAM lParam)
{
- TRACE("--> CGraphThread::OnOpen on thread: %d\n", GetCurrentThreadId());
- if (m_pMainFrame) {
- CAutoPtr<OpenMediaData> pOMD((OpenMediaData*)lParam);
- m_pMainFrame->OpenMediaPrivate(pOMD);
- }
+ TRACE("--> CGraphThread::OnOpen on thread: %d\n", GetCurrentThreadId());
+ if (m_pMainFrame) {
+ CAutoPtr<OpenMediaData> pOMD((OpenMediaData*)lParam);
+ m_pMainFrame->OpenMediaPrivate(pOMD);
+ }
}
void CGraphThread::OnClose(WPARAM wParam, LPARAM lParam)
{
- if (m_pMainFrame) {
- m_pMainFrame->CloseMediaPrivate();
- }
- if (CAMEvent* e = (CAMEvent*)lParam) {
- e->Set();
- }
+ if (m_pMainFrame) {
+ m_pMainFrame->CloseMediaPrivate();
+ }
+ if (CAMEvent* e = (CAMEvent*)lParam) {
+ e->Set();
+ }
}
void CGraphThread::OnReset(WPARAM wParam, LPARAM lParam)
{
- if (m_pMainFrame) {
- BOOL* b = (BOOL*)wParam;
- BOOL bResult = m_pMainFrame->ResetDevice();
- if (b) {
- *b = bResult;
- }
- }
- if (CAMEvent* e = (CAMEvent*)lParam) {
- e->Set();
- }
+ if (m_pMainFrame) {
+ BOOL* b = (BOOL*)wParam;
+ BOOL bResult = m_pMainFrame->ResetDevice();
+ if (b) {
+ *b = bResult;
+ }
+ }
+ if (CAMEvent* e = (CAMEvent*)lParam) {
+ e->Set();
+ }
}
void CGraphThread::OnTunerScan(WPARAM wParam, LPARAM lParam)
{
- if (m_pMainFrame) {
- CAutoPtr<TunerScanData> pTSD((TunerScanData*)lParam);
- m_pMainFrame->DoTunerScan(pTSD);
- }
+ if (m_pMainFrame) {
+ CAutoPtr<TunerScanData> pTSD((TunerScanData*)lParam);
+ m_pMainFrame->DoTunerScan(pTSD);
+ }
}
void CGraphThread::OnDisplayChange(WPARAM wParam, LPARAM lParam)
{
- if (m_pMainFrame) {
- m_pMainFrame->DisplayChange();
- }
+ if (m_pMainFrame) {
+ m_pMainFrame->DisplayChange();
+ }
}
// ==== Added by CASIMIR666
void CMainFrame::SetLoadState(MPC_LOADSTATE iState)
{
- m_iMediaLoadState = iState;
- SendAPICommand (CMD_STATE, L"%d", m_iMediaLoadState);
+ m_iMediaLoadState = iState;
+ SendAPICommand(CMD_STATE, L"%d", m_iMediaLoadState);
}
void CMainFrame::SetPlayState(MPC_PLAYSTATE iState)
{
- //m_Lcd.SetPlayState((CMPC_Lcd::PlayState)iState);
- SendAPICommand (CMD_PLAYMODE, L"%d", iState);
+ //m_Lcd.SetPlayState((CMPC_Lcd::PlayState)iState);
+ SendAPICommand(CMD_PLAYMODE, L"%d", iState);
- if (m_fEndOfStream) {
- SendAPICommand (CMD_NOTIFYENDOFSTREAM, L"\0"); // do not pass NULL here!
- }
+ if (m_fEndOfStream) {
+ SendAPICommand(CMD_NOTIFYENDOFSTREAM, L"\0"); // do not pass NULL here!
+ }
- // Prevent sleep when playing audio and/or video, but allow screensaver when only audio
- if (!m_fAudioOnly) {
- SetThreadExecutionState (iState == PS_PLAY ? ES_CONTINUOUS | ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED : ES_CONTINUOUS);
- } else {
- SetThreadExecutionState (iState == PS_PLAY ? ES_CONTINUOUS | ES_SYSTEM_REQUIRED : ES_CONTINUOUS);
- }
+ // Prevent sleep when playing audio and/or video, but allow screensaver when only audio
+ if (!m_fAudioOnly) {
+ SetThreadExecutionState(iState == PS_PLAY ? ES_CONTINUOUS | ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED : ES_CONTINUOUS);
+ } else {
+ SetThreadExecutionState(iState == PS_PLAY ? ES_CONTINUOUS | ES_SYSTEM_REQUIRED : ES_CONTINUOUS);
+ }
}
bool CMainFrame::CreateFullScreenWindow()
{
- HMONITOR hMonitor;
- MONITORINFOEX MonitorInfo;
- CRect MonitorRect;
-
- if (m_pFullscreenWnd->IsWindow()) {
- m_pFullscreenWnd->DestroyWindow();
- }
-
- ZeroMemory (&MonitorInfo, sizeof(MonitorInfo));
- MonitorInfo.cbSize = sizeof(MonitorInfo);
-
- CMonitors monitors;
- CString str;
- CMonitor monitor;
- AppSettings& s = AfxGetAppSettings();
- hMonitor = NULL;
-
- if (!s.iMonitor) {
- if (s.strFullScreenMonitor == _T("Current")) {
- hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- } else {
- for ( int i = 0; i < monitors.GetCount(); i++ ) {
- monitor = monitors.GetMonitor( i );
- monitor.GetName(str);
-
- if ((monitor.IsMonitor()) && (s.strFullScreenMonitor == str)) {
- hMonitor = monitor;
- break;
- }
- }
- if (!hMonitor) {
- hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- }
- }
- } else {
- hMonitor = MonitorFromWindow (m_hWnd, 0);
- }
- if (GetMonitorInfo (hMonitor, &MonitorInfo)) {
- MonitorRect = CRect (MonitorInfo.rcMonitor);
- // Window creation
- DWORD dwStyle = WS_POPUP | WS_VISIBLE ;
- m_fullWndSize.cx = MonitorRect.Width();
- m_fullWndSize.cy = MonitorRect.Height();
-
- m_pFullscreenWnd->CreateEx (WS_EX_TOPMOST | WS_EX_TOOLWINDOW, _T(""), ResStr(IDS_MAINFRM_136), dwStyle, MonitorRect.left, MonitorRect.top, MonitorRect.Width(), MonitorRect.Height(), NULL, NULL, NULL);
- //SetWindowLongPtr(m_pFullscreenWnd->m_hWnd, GWL_EXSTYLE, WS_EX_TOPMOST); // TODO : still freezing sometimes...
- /*
- CRect r;
- GetWindowRect(r);
-
- int x = MonitorRect.left + (MonitorRect.Width()/2)-(r.Width()/2);
- int y = MonitorRect.top + (MonitorRect.Height()/2)-(r.Height()/2);
- int w = r.Width();
- int h = r.Height();
- MoveWindow(x, y, w, h);
- */
- }
-
- return m_pFullscreenWnd->IsWindow();
+ HMONITOR hMonitor;
+ MONITORINFOEX MonitorInfo;
+ CRect MonitorRect;
+
+ if (m_pFullscreenWnd->IsWindow()) {
+ m_pFullscreenWnd->DestroyWindow();
+ }
+
+ ZeroMemory(&MonitorInfo, sizeof(MonitorInfo));
+ MonitorInfo.cbSize = sizeof(MonitorInfo);
+
+ CMonitors monitors;
+ CString str;
+ CMonitor monitor;
+ AppSettings& s = AfxGetAppSettings();
+ hMonitor = NULL;
+
+ if (!s.iMonitor) {
+ if (s.strFullScreenMonitor == _T("Current")) {
+ hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+ } else {
+ for (int i = 0; i < monitors.GetCount(); i++) {
+ monitor = monitors.GetMonitor(i);
+ monitor.GetName(str);
+
+ if ((monitor.IsMonitor()) && (s.strFullScreenMonitor == str)) {
+ hMonitor = monitor;
+ break;
+ }
+ }
+ if (!hMonitor) {
+ hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+ }
+ }
+ } else {
+ hMonitor = MonitorFromWindow(m_hWnd, 0);
+ }
+ if (GetMonitorInfo(hMonitor, &MonitorInfo)) {
+ MonitorRect = CRect(MonitorInfo.rcMonitor);
+ // Window creation
+ DWORD dwStyle = WS_POPUP | WS_VISIBLE ;
+ m_fullWndSize.cx = MonitorRect.Width();
+ m_fullWndSize.cy = MonitorRect.Height();
+
+ m_pFullscreenWnd->CreateEx(WS_EX_TOPMOST | WS_EX_TOOLWINDOW, _T(""), ResStr(IDS_MAINFRM_136), dwStyle, MonitorRect.left, MonitorRect.top, MonitorRect.Width(), MonitorRect.Height(), NULL, NULL, NULL);
+ //SetWindowLongPtr(m_pFullscreenWnd->m_hWnd, GWL_EXSTYLE, WS_EX_TOPMOST); // TODO : still freezing sometimes...
+ /*
+ CRect r;
+ GetWindowRect(r);
+
+ int x = MonitorRect.left + (MonitorRect.Width()/2)-(r.Width()/2);
+ int y = MonitorRect.top + (MonitorRect.Height()/2)-(r.Height()/2);
+ int w = r.Width();
+ int h = r.Height();
+ MoveWindow(x, y, w, h);
+ */
+ }
+
+ return m_pFullscreenWnd->IsWindow();
}
bool CMainFrame::IsD3DFullScreenMode() const
{
- return m_pFullscreenWnd->IsWindow();
+ return m_pFullscreenWnd->IsWindow();
};
void CMainFrame::SetupEVRColorControl()
{
- if (m_pMFVP) {
- if (FAILED(m_pMFVP->GetProcAmpRange(DXVA2_ProcAmp_Brightness, AfxGetMyApp()->GetEVRColorControl(ProcAmp_Brightness)))) return;
- if (FAILED(m_pMFVP->GetProcAmpRange(DXVA2_ProcAmp_Contrast, AfxGetMyApp()->GetEVRColorControl(ProcAmp_Contrast)))) return;
- if (FAILED(m_pMFVP->GetProcAmpRange(DXVA2_ProcAmp_Hue, AfxGetMyApp()->GetEVRColorControl(ProcAmp_Hue)))) return;
- if (FAILED(m_pMFVP->GetProcAmpRange(DXVA2_ProcAmp_Saturation, AfxGetMyApp()->GetEVRColorControl(ProcAmp_Saturation)))) return;
+ if (m_pMFVP) {
+ if (FAILED(m_pMFVP->GetProcAmpRange(DXVA2_ProcAmp_Brightness, AfxGetMyApp()->GetEVRColorControl(ProcAmp_Brightness)))) { return; }
+ if (FAILED(m_pMFVP->GetProcAmpRange(DXVA2_ProcAmp_Contrast, AfxGetMyApp()->GetEVRColorControl(ProcAmp_Contrast)))) { return; }
+ if (FAILED(m_pMFVP->GetProcAmpRange(DXVA2_ProcAmp_Hue, AfxGetMyApp()->GetEVRColorControl(ProcAmp_Hue)))) { return; }
+ if (FAILED(m_pMFVP->GetProcAmpRange(DXVA2_ProcAmp_Saturation, AfxGetMyApp()->GetEVRColorControl(ProcAmp_Saturation)))) { return; }
- AfxGetMyApp()->UpdateColorControlRange(true);
- SetColorControl(ProcAmp_All, AfxGetAppSettings().iBrightness, AfxGetAppSettings().iContrast, AfxGetAppSettings().iHue, AfxGetAppSettings().iSaturation);
- }
+ AfxGetMyApp()->UpdateColorControlRange(true);
+ SetColorControl(ProcAmp_All, AfxGetAppSettings().iBrightness, AfxGetAppSettings().iContrast, AfxGetAppSettings().iHue, AfxGetAppSettings().iSaturation);
+ }
}
void CMainFrame::SetColorControl(DWORD flags, int& brightness, int& contrast, int& hue, int& saturation)
{
- static VMR9ProcAmpControl ClrControl;
- static DXVA2_ProcAmpValues ClrValues;
-
- COLORPROPERTY_RANGE* cr;
- if (flags&ProcAmp_Brightness) {
- cr = AfxGetMyApp()->GetColorControl(ProcAmp_Brightness);
- brightness = min(max(brightness, cr->MinValue), cr->MaxValue);
- }
- if (flags&ProcAmp_Contrast) {
- cr = AfxGetMyApp()->GetColorControl(ProcAmp_Contrast);
- contrast = min(max(contrast, cr->MinValue), cr->MaxValue);
- }
- if (flags&ProcAmp_Hue) {
- cr = AfxGetMyApp()->GetColorControl(ProcAmp_Hue);
- hue =min(max(hue, cr->MinValue), cr->MaxValue);
- }
- if (flags&ProcAmp_Saturation) {
- cr = AfxGetMyApp()->GetColorControl(ProcAmp_Saturation);
- saturation = min(max(saturation, cr->MinValue), cr->MaxValue);
- }
-
-
- if (m_pMC) {
- ClrControl.dwSize = sizeof(ClrControl);
- ClrControl.dwFlags = flags;
- ClrControl.Brightness = (float)brightness;
- ClrControl.Contrast = (float)(contrast+100)/100;
- ClrControl.Hue = (float)hue;
- ClrControl.Saturation = (float)(saturation+100)/100;
-
- m_pMC->SetProcAmpControl (0, &ClrControl);
- } else if (m_pMFVP) {
- ClrValues.Brightness = IntToFixed(brightness);
- ClrValues.Contrast = IntToFixed(contrast+100, 100);
- ClrValues.Hue = IntToFixed(hue);
- ClrValues.Saturation = IntToFixed(saturation+100, 100);
-
- m_pMFVP->SetProcAmpValues(flags, &ClrValues);
- }
+ static VMR9ProcAmpControl ClrControl;
+ static DXVA2_ProcAmpValues ClrValues;
+
+ COLORPROPERTY_RANGE* cr;
+ if (flags & ProcAmp_Brightness) {
+ cr = AfxGetMyApp()->GetColorControl(ProcAmp_Brightness);
+ brightness = min(max(brightness, cr->MinValue), cr->MaxValue);
+ }
+ if (flags & ProcAmp_Contrast) {
+ cr = AfxGetMyApp()->GetColorControl(ProcAmp_Contrast);
+ contrast = min(max(contrast, cr->MinValue), cr->MaxValue);
+ }
+ if (flags & ProcAmp_Hue) {
+ cr = AfxGetMyApp()->GetColorControl(ProcAmp_Hue);
+ hue = min(max(hue, cr->MinValue), cr->MaxValue);
+ }
+ if (flags & ProcAmp_Saturation) {
+ cr = AfxGetMyApp()->GetColorControl(ProcAmp_Saturation);
+ saturation = min(max(saturation, cr->MinValue), cr->MaxValue);
+ }
+
+
+ if (m_pMC) {
+ ClrControl.dwSize = sizeof(ClrControl);
+ ClrControl.dwFlags = flags;
+ ClrControl.Brightness = (float)brightness;
+ ClrControl.Contrast = (float)(contrast + 100) / 100;
+ ClrControl.Hue = (float)hue;
+ ClrControl.Saturation = (float)(saturation + 100) / 100;
+
+ m_pMC->SetProcAmpControl(0, &ClrControl);
+ } else if (m_pMFVP) {
+ ClrValues.Brightness = IntToFixed(brightness);
+ ClrValues.Contrast = IntToFixed(contrast + 100, 100);
+ ClrValues.Hue = IntToFixed(hue);
+ ClrValues.Saturation = IntToFixed(saturation + 100, 100);
+
+ m_pMFVP->SetProcAmpValues(flags, &ClrValues);
+ }
}
void CMainFrame::SetClosedCaptions(bool enable)
{
- if (m_pLN21) {
- m_pLN21->SetServiceState(enable ? AM_L21_CCSTATE_On : AM_L21_CCSTATE_Off);
- }
-}
-
-LPCTSTR CMainFrame::GetDVDAudioFormatName (DVD_AudioAttributes& ATR) const
-{
- switch (ATR.AudioFormat) {
- case DVD_AudioFormat_AC3:
- return _T("AC3");
- case DVD_AudioFormat_MPEG1:
- case DVD_AudioFormat_MPEG1_DRC:
- return _T("MPEG1");
- case DVD_AudioFormat_MPEG2:
- case DVD_AudioFormat_MPEG2_DRC:
- return _T("MPEG2");
- case DVD_AudioFormat_LPCM:
- return _T("LPCM");
- case DVD_AudioFormat_DTS:
- return _T("DTS");
- case DVD_AudioFormat_SDDS:
- return _T("SDDS");
- case DVD_AudioFormat_Other:
- default:
- return ResStr(IDS_MAINFRM_137);
- }
+ if (m_pLN21) {
+ m_pLN21->SetServiceState(enable ? AM_L21_CCSTATE_On : AM_L21_CCSTATE_Off);
+ }
+}
+
+LPCTSTR CMainFrame::GetDVDAudioFormatName(DVD_AudioAttributes& ATR) const
+{
+ switch (ATR.AudioFormat) {
+ case DVD_AudioFormat_AC3:
+ return _T("AC3");
+ case DVD_AudioFormat_MPEG1:
+ case DVD_AudioFormat_MPEG1_DRC:
+ return _T("MPEG1");
+ case DVD_AudioFormat_MPEG2:
+ case DVD_AudioFormat_MPEG2_DRC:
+ return _T("MPEG2");
+ case DVD_AudioFormat_LPCM:
+ return _T("LPCM");
+ case DVD_AudioFormat_DTS:
+ return _T("DTS");
+ case DVD_AudioFormat_SDDS:
+ return _T("SDDS");
+ case DVD_AudioFormat_Other:
+ default:
+ return ResStr(IDS_MAINFRM_137);
+ }
}
afx_msg void CMainFrame::OnGotoSubtitle(UINT nID)
{
- OnPlayPause();
- m_rtCurSubPos = m_wndSeekBar.GetPosReal();
- m_lSubtitleShift = 0;
- m_nCurSubtitle = m_wndSubresyncBar.FindNearestSub (m_rtCurSubPos, (nID == ID_GOTO_NEXT_SUB));
- if ((m_nCurSubtitle != -1) && pMS) {
- pMS->SetPositions (&m_rtCurSubPos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
- }
+ OnPlayPause();
+ m_rtCurSubPos = m_wndSeekBar.GetPosReal();
+ m_lSubtitleShift = 0;
+ m_nCurSubtitle = m_wndSubresyncBar.FindNearestSub(m_rtCurSubPos, (nID == ID_GOTO_NEXT_SUB));
+ if ((m_nCurSubtitle != -1) && pMS) {
+ pMS->SetPositions(&m_rtCurSubPos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
+ }
}
afx_msg void CMainFrame::OnShiftSubtitle(UINT nID)
{
- if (m_nCurSubtitle >= 0) {
- long lShift = (nID == ID_SHIFT_SUB_DOWN) ? -100 : 100;
- CString strSubShift;
+ if (m_nCurSubtitle >= 0) {
+ long lShift = (nID == ID_SHIFT_SUB_DOWN) ? -100 : 100;
+ CString strSubShift;
- if (m_wndSubresyncBar.ShiftSubtitle (m_nCurSubtitle, lShift, m_rtCurSubPos)) {
- m_lSubtitleShift += lShift;
- if (pMS) {
- pMS->SetPositions (&m_rtCurSubPos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
- }
- }
+ if (m_wndSubresyncBar.ShiftSubtitle(m_nCurSubtitle, lShift, m_rtCurSubPos)) {
+ m_lSubtitleShift += lShift;
+ if (pMS) {
+ pMS->SetPositions(&m_rtCurSubPos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
+ }
+ }
- strSubShift.Format(IDS_MAINFRM_138, m_lSubtitleShift);
- m_OSD.DisplayMessage(OSD_TOPLEFT, strSubShift);
- }
+ strSubShift.Format(IDS_MAINFRM_138, m_lSubtitleShift);
+ m_OSD.DisplayMessage(OSD_TOPLEFT, strSubShift);
+ }
}
afx_msg void CMainFrame::OnSubtitleDelay(UINT nID)
{
- if (m_pCAP) {
- if (m_pSubStreams.IsEmpty()) {
- SendStatusMessage(ResStr(IDS_SUBTITLES_ERROR), 3000);
- return;
- }
+ if (m_pCAP) {
+ if (m_pSubStreams.IsEmpty()) {
+ SendStatusMessage(ResStr(IDS_SUBTITLES_ERROR), 3000);
+ return;
+ }
- int newDelay;
- int oldDelay = m_pCAP->GetSubtitleDelay();
+ int newDelay;
+ int oldDelay = m_pCAP->GetSubtitleDelay();
- if (nID == ID_SUB_DELAY_DOWN) {
- newDelay = oldDelay-AfxGetAppSettings().nSubDelayInterval;
- } else {
- newDelay = oldDelay+AfxGetAppSettings().nSubDelayInterval;
- }
+ if (nID == ID_SUB_DELAY_DOWN) {
+ newDelay = oldDelay - AfxGetAppSettings().nSubDelayInterval;
+ } else {
+ newDelay = oldDelay + AfxGetAppSettings().nSubDelayInterval;
+ }
- SetSubtitleDelay(newDelay);
- }
+ SetSubtitleDelay(newDelay);
+ }
}
afx_msg void CMainFrame::OnLanguage(UINT nID)
{
- CMenu DefaultMenu;
- CMenu* OldMenu;
+ CMenu DefaultMenu;
+ CMenu* OldMenu;
- if (nID == ID_LANGUAGE_HEBREW) { // Show a warning when switching to Hebrew (must not be translated)
- MessageBox(_T("The Hebrew translation will be correctly displayed (with a right-to-left layout) after restarting the application.\n"),
- _T("Media Player Classic - Home Cinema"), MB_ICONINFORMATION | MB_OK);
- }
+ if (nID == ID_LANGUAGE_HEBREW) { // Show a warning when switching to Hebrew (must not be translated)
+ MessageBox(_T("The Hebrew translation will be correctly displayed (with a right-to-left layout) after restarting the application.\n"),
+ _T("Media Player Classic - Home Cinema"), MB_ICONINFORMATION | MB_OK);
+ }
- CMPlayerCApp::SetLanguage(CMPlayerCApp::GetLanguageResourceByResourceID(nID));
+ CMPlayerCApp::SetLanguage(CMPlayerCApp::GetLanguageResourceByResourceID(nID));
- m_opencds.DestroyMenu();
- m_filters.DestroyMenu();
- m_subtitles.DestroyMenu();
- m_audios.DestroyMenu();
- m_navaudio.DestroyMenu();
- m_navsubtitle.DestroyMenu();
- m_navangle.DestroyMenu();
- m_navchapters.DestroyMenu();
- m_favorites.DestroyMenu();
- m_shaders.DestroyMenu();
- m_recentfiles.DestroyMenu();
+ m_opencds.DestroyMenu();
+ m_filters.DestroyMenu();
+ m_subtitles.DestroyMenu();
+ m_audios.DestroyMenu();
+ m_navaudio.DestroyMenu();
+ m_navsubtitle.DestroyMenu();
+ m_navangle.DestroyMenu();
+ m_navchapters.DestroyMenu();
+ m_favorites.DestroyMenu();
+ m_shaders.DestroyMenu();
+ m_recentfiles.DestroyMenu();
- m_popup.DestroyMenu();
- m_popup.LoadMenu(IDR_POPUP);
- m_popupmain.DestroyMenu();
- m_popupmain.LoadMenu(IDR_POPUPMAIN);
+ m_popup.DestroyMenu();
+ m_popup.LoadMenu(IDR_POPUP);
+ m_popupmain.DestroyMenu();
+ m_popupmain.LoadMenu(IDR_POPUPMAIN);
- OldMenu = GetMenu();
- DefaultMenu.LoadMenu(IDR_MAINFRAME);
+ OldMenu = GetMenu();
+ DefaultMenu.LoadMenu(IDR_MAINFRAME);
- SetMenu(&DefaultMenu);
- m_hMenuDefault = DefaultMenu;
- DefaultMenu.Detach();
- // TODO : destroy old menu ???
- //OldMenu->DestroyMenu();
+ SetMenu(&DefaultMenu);
+ m_hMenuDefault = DefaultMenu;
+ DefaultMenu.Detach();
+ // TODO : destroy old menu ???
+ //OldMenu->DestroyMenu();
}
void CMainFrame::ProcessAPICommand(COPYDATASTRUCT* pCDS)
{
- CAtlList<CString> fns;
- REFERENCE_TIME rtPos = 0;
-
- switch (pCDS->dwData) {
- case CMD_OPENFILE :
- fns.AddHead ((LPCWSTR)pCDS->lpData);
- m_wndPlaylistBar.Open(fns, false);
- OpenCurPlaylistItem();
- break;
- case CMD_STOP :
- OnPlayStop();
- break;
- case CMD_CLOSEFILE :
- CloseMedia();
- break;
- case CMD_PLAYPAUSE :
- OnPlayPlaypause();
- break;
- case CMD_ADDTOPLAYLIST :
- fns.AddHead ((LPCWSTR)pCDS->lpData);
- m_wndPlaylistBar.Append(fns, true);
- break;
- case CMD_STARTPLAYLIST :
- OpenCurPlaylistItem();
- break;
- case CMD_CLEARPLAYLIST :
- m_wndPlaylistBar.Empty();
- break;
- case CMD_SETPOSITION :
- rtPos = 10000 * REFERENCE_TIME(_wtof((LPCWSTR)pCDS->lpData)*1000); //with accuracy of 1 ms
- // imianz: quick and dirty trick
- // Pause->SeekTo->Play (in place of SeekTo only) seems to prevents in most cases
- // some strange video effects on avi files (ex. locks a while and than running fast).
- if (!m_fAudioOnly && GetMediaState()==State_Running) {
- SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
- SeekTo(rtPos);
- SendMessage(WM_COMMAND, ID_PLAY_PLAY);
- } else {
- SeekTo(rtPos);
- }
- // show current position overridden by play command
- m_OSD.DisplayMessage(OSD_TOPLEFT, m_wndStatusBar.GetStatusTimer(), 2000);
- break;
- case CMD_SETAUDIODELAY :
- rtPos = _wtol ((LPCWSTR)pCDS->lpData) * 10000;
- SetAudioDelay (rtPos);
- break;
- case CMD_SETSUBTITLEDELAY :
- SetSubtitleDelay(_wtoi((LPCWSTR)pCDS->lpData));
- break;
- case CMD_SETINDEXPLAYLIST :
- //m_wndPlaylistBar.SetSelIdx(_wtoi((LPCWSTR)pCDS->lpData));
- break;
- case CMD_SETAUDIOTRACK :
- SetAudioTrackIdx(_wtoi((LPCWSTR)pCDS->lpData));
- break;
- case CMD_SETSUBTITLETRACK :
- SetSubtitleTrackIdx(_wtoi((LPCWSTR)pCDS->lpData));
- break;
- case CMD_GETSUBTITLETRACKS :
- SendSubtitleTracksToApi();
- break;
- case CMD_GETAUDIOTRACKS :
- SendAudioTracksToApi();
- break;
- case CMD_GETCURRENTPOSITION :
- SendCurrentPositionToApi();
- break;
- case CMD_GETNOWPLAYING:
- SendNowPlayingToApi();
- break;
- case CMD_JUMPOFNSECONDS :
- JumpOfNSeconds(_wtoi((LPCWSTR)pCDS->lpData));
- break;
- case CMD_GETPLAYLIST :
- SendPlaylistToApi();
- break;
- case CMD_JUMPFORWARDMED :
- OnPlaySeek(ID_PLAY_SEEKFORWARDMED);
- break;
- case CMD_JUMPBACKWARDMED :
- OnPlaySeek(ID_PLAY_SEEKBACKWARDMED);
- break;
- case CMD_TOGGLEFULLSCREEN :
- OnViewFullscreen();
- break;
- case CMD_INCREASEVOLUME :
- m_wndToolBar.m_volctrl.IncreaseVolume();
- break;
- case CMD_DECREASEVOLUME :
- m_wndToolBar.m_volctrl.DecreaseVolume();
- break;
- case CMD_SHADER_TOGGLE :
- OnShaderToggle();
- break;
- case CMD_CLOSEAPP :
- PostMessage(WM_CLOSE);
- break;
- case CMD_OSDSHOWMESSAGE:
- ShowOSDCustomMessageApi((MPC_OSDDATA *)pCDS->lpData);
- break;
- }
-}
-
-void CMainFrame::SendAPICommand (MPCAPI_COMMAND nCommand, LPCWSTR fmt, ...)
-{
- AppSettings& s = AfxGetAppSettings();
-
- if (s.hMasterWnd) {
- COPYDATASTRUCT CDS;
- TCHAR buff[800];
-
- va_list args;
- va_start(args, fmt);
- _vstprintf_s(buff, _countof(buff), fmt, args);
-
- CDS.cbData = (DWORD)(_tcslen(buff) + 1) * sizeof(TCHAR);
- CDS.dwData = nCommand;
- CDS.lpData = (LPVOID)buff;
-
- ::SendMessage(s.hMasterWnd, WM_COPYDATA, (WPARAM)GetSafeHwnd(), (LPARAM)&CDS);
-
- va_end(args);
- }
+ CAtlList<CString> fns;
+ REFERENCE_TIME rtPos = 0;
+
+ switch (pCDS->dwData) {
+ case CMD_OPENFILE :
+ fns.AddHead((LPCWSTR)pCDS->lpData);
+ m_wndPlaylistBar.Open(fns, false);
+ OpenCurPlaylistItem();
+ break;
+ case CMD_STOP :
+ OnPlayStop();
+ break;
+ case CMD_CLOSEFILE :
+ CloseMedia();
+ break;
+ case CMD_PLAYPAUSE :
+ OnPlayPlaypause();
+ break;
+ case CMD_ADDTOPLAYLIST :
+ fns.AddHead((LPCWSTR)pCDS->lpData);
+ m_wndPlaylistBar.Append(fns, true);
+ break;
+ case CMD_STARTPLAYLIST :
+ OpenCurPlaylistItem();
+ break;
+ case CMD_CLEARPLAYLIST :
+ m_wndPlaylistBar.Empty();
+ break;
+ case CMD_SETPOSITION :
+ rtPos = 10000 * REFERENCE_TIME(_wtof((LPCWSTR)pCDS->lpData) * 1000); //with accuracy of 1 ms
+ // imianz: quick and dirty trick
+ // Pause->SeekTo->Play (in place of SeekTo only) seems to prevents in most cases
+ // some strange video effects on avi files (ex. locks a while and than running fast).
+ if (!m_fAudioOnly && GetMediaState() == State_Running) {
+ SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ SeekTo(rtPos);
+ SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ } else {
+ SeekTo(rtPos);
+ }
+ // show current position overridden by play command
+ m_OSD.DisplayMessage(OSD_TOPLEFT, m_wndStatusBar.GetStatusTimer(), 2000);
+ break;
+ case CMD_SETAUDIODELAY :
+ rtPos = _wtol((LPCWSTR)pCDS->lpData) * 10000;
+ SetAudioDelay(rtPos);
+ break;
+ case CMD_SETSUBTITLEDELAY :
+ SetSubtitleDelay(_wtoi((LPCWSTR)pCDS->lpData));
+ break;
+ case CMD_SETINDEXPLAYLIST :
+ //m_wndPlaylistBar.SetSelIdx(_wtoi((LPCWSTR)pCDS->lpData));
+ break;
+ case CMD_SETAUDIOTRACK :
+ SetAudioTrackIdx(_wtoi((LPCWSTR)pCDS->lpData));
+ break;
+ case CMD_SETSUBTITLETRACK :
+ SetSubtitleTrackIdx(_wtoi((LPCWSTR)pCDS->lpData));
+ break;
+ case CMD_GETSUBTITLETRACKS :
+ SendSubtitleTracksToApi();
+ break;
+ case CMD_GETAUDIOTRACKS :
+ SendAudioTracksToApi();
+ break;
+ case CMD_GETCURRENTPOSITION :
+ SendCurrentPositionToApi();
+ break;
+ case CMD_GETNOWPLAYING:
+ SendNowPlayingToApi();
+ break;
+ case CMD_JUMPOFNSECONDS :
+ JumpOfNSeconds(_wtoi((LPCWSTR)pCDS->lpData));
+ break;
+ case CMD_GETPLAYLIST :
+ SendPlaylistToApi();
+ break;
+ case CMD_JUMPFORWARDMED :
+ OnPlaySeek(ID_PLAY_SEEKFORWARDMED);
+ break;
+ case CMD_JUMPBACKWARDMED :
+ OnPlaySeek(ID_PLAY_SEEKBACKWARDMED);
+ break;
+ case CMD_TOGGLEFULLSCREEN :
+ OnViewFullscreen();
+ break;
+ case CMD_INCREASEVOLUME :
+ m_wndToolBar.m_volctrl.IncreaseVolume();
+ break;
+ case CMD_DECREASEVOLUME :
+ m_wndToolBar.m_volctrl.DecreaseVolume();
+ break;
+ case CMD_SHADER_TOGGLE :
+ OnShaderToggle();
+ break;
+ case CMD_CLOSEAPP :
+ PostMessage(WM_CLOSE);
+ break;
+ case CMD_OSDSHOWMESSAGE:
+ ShowOSDCustomMessageApi((MPC_OSDDATA*)pCDS->lpData);
+ break;
+ }
+}
+
+void CMainFrame::SendAPICommand(MPCAPI_COMMAND nCommand, LPCWSTR fmt, ...)
+{
+ AppSettings& s = AfxGetAppSettings();
+
+ if (s.hMasterWnd) {
+ COPYDATASTRUCT CDS;
+ TCHAR buff[800];
+
+ va_list args;
+ va_start(args, fmt);
+ _vstprintf_s(buff, _countof(buff), fmt, args);
+
+ CDS.cbData = (DWORD)(_tcslen(buff) + 1) * sizeof(TCHAR);
+ CDS.dwData = nCommand;
+ CDS.lpData = (LPVOID)buff;
+
+ ::SendMessage(s.hMasterWnd, WM_COPYDATA, (WPARAM)GetSafeHwnd(), (LPARAM)&CDS);
+
+ va_end(args);
+ }
}
void CMainFrame::SendNowPlayingToApi()
{
- if (!AfxGetAppSettings().hMasterWnd) {
- return;
- }
-
-
- if (m_iMediaLoadState == MLS_LOADED) {
- CPlaylistItem pli;
- CString title, author, description;
- CString label;
- long lDuration = 0;
- REFERENCE_TIME rtDur;
-
- if (GetPlaybackMode() == PM_FILE) {
- m_wndInfoBar.GetLine(ResStr(IDS_INFOBAR_TITLE), title);
- m_wndInfoBar.GetLine(ResStr(IDS_INFOBAR_AUTHOR), author);
- m_wndInfoBar.GetLine(ResStr(IDS_INFOBAR_DESCRIPTION), description);
-
- m_wndPlaylistBar.GetCur(pli);
- if (!pli.m_fns.IsEmpty()) {
- label = !pli.m_label.IsEmpty() ? pli.m_label : pli.m_fns.GetHead();
-
- pMS->GetDuration(&rtDur);
- DVD_HMSF_TIMECODE tcDur = RT2HMSF(rtDur);
- lDuration = tcDur.bHours*60*60 + tcDur.bMinutes*60 + tcDur.bSeconds;
- }
- }
- else if (GetPlaybackMode() == PM_DVD) {
- DVD_DOMAIN DVDDomain;
- ULONG ulNumOfChapters = 0;
- DVD_PLAYBACK_LOCATION2 Location;
-
- // Get current DVD Domain
- if (SUCCEEDED(pDVDI->GetCurrentDomain(&DVDDomain))) {
- switch (DVDDomain) {
- case DVD_DOMAIN_Stop:
- title = _T("DVD - Stopped");
- break;
- case DVD_DOMAIN_FirstPlay:
- title = _T("DVD - FirstPlay");
- break;
- case DVD_DOMAIN_VideoManagerMenu:
- title = _T("DVD - RootMenu");
- break;
- case DVD_DOMAIN_VideoTitleSetMenu:
- title = _T("DVD - TitleMenu");
- break;
- case DVD_DOMAIN_Title:
- title = _T("DVD - Title");
- break;
- }
-
- // get title information
- if (DVDDomain == DVD_DOMAIN_Title) {
- // get current location (title number & chapter)
- if (SUCCEEDED(pDVDI->GetCurrentLocation(&Location))) {
- // get number of chapters in current title
- pDVDI->GetNumberOfChapters(Location.TitleNum, &ulNumOfChapters);
- }
-
- // get total time of title
- DVD_HMSF_TIMECODE tcDur;
- ULONG ulFlags;
- if (SUCCEEDED(pDVDI->GetTotalTitleTime(&tcDur, &ulFlags))) {
- // calculate duration in seconds
- lDuration = tcDur.bHours*60*60 + tcDur.bMinutes*60 + tcDur.bSeconds;
- }
-
- // build string
- // DVD - xxxxx|currenttitle|numberofchapters|currentchapter|titleduration
- author.Format(L"%d", Location.TitleNum);
- description.Format(L"%d", ulNumOfChapters);
- label.Format(L"%d", Location.ChapterNum);
- }
- }
- }
-
- title.Replace(L"|", L"\\|");
- author.Replace(L"|", L"\\|");
- description.Replace(L"|", L"\\|");
- label.Replace(L"|", L"\\|");
-
- CStringW buff;
- buff.Format(L"%s|%s|%s|%s|%d", title, author, description, label, lDuration);
-
- SendAPICommand(CMD_NOWPLAYING, buff);
- SendSubtitleTracksToApi();
- SendAudioTracksToApi();
- }
+ if (!AfxGetAppSettings().hMasterWnd) {
+ return;
+ }
+
+
+ if (m_iMediaLoadState == MLS_LOADED) {
+ CPlaylistItem pli;
+ CString title, author, description;
+ CString label;
+ long lDuration = 0;
+ REFERENCE_TIME rtDur;
+
+ if (GetPlaybackMode() == PM_FILE) {
+ m_wndInfoBar.GetLine(ResStr(IDS_INFOBAR_TITLE), title);
+ m_wndInfoBar.GetLine(ResStr(IDS_INFOBAR_AUTHOR), author);
+ m_wndInfoBar.GetLine(ResStr(IDS_INFOBAR_DESCRIPTION), description);
+
+ m_wndPlaylistBar.GetCur(pli);
+ if (!pli.m_fns.IsEmpty()) {
+ label = !pli.m_label.IsEmpty() ? pli.m_label : pli.m_fns.GetHead();
+
+ pMS->GetDuration(&rtDur);
+ DVD_HMSF_TIMECODE tcDur = RT2HMSF(rtDur);
+ lDuration = tcDur.bHours * 60 * 60 + tcDur.bMinutes * 60 + tcDur.bSeconds;
+ }
+ } else if (GetPlaybackMode() == PM_DVD) {
+ DVD_DOMAIN DVDDomain;
+ ULONG ulNumOfChapters = 0;
+ DVD_PLAYBACK_LOCATION2 Location;
+
+ // Get current DVD Domain
+ if (SUCCEEDED(pDVDI->GetCurrentDomain(&DVDDomain))) {
+ switch (DVDDomain) {
+ case DVD_DOMAIN_Stop:
+ title = _T("DVD - Stopped");
+ break;
+ case DVD_DOMAIN_FirstPlay:
+ title = _T("DVD - FirstPlay");
+ break;
+ case DVD_DOMAIN_VideoManagerMenu:
+ title = _T("DVD - RootMenu");
+ break;
+ case DVD_DOMAIN_VideoTitleSetMenu:
+ title = _T("DVD - TitleMenu");
+ break;
+ case DVD_DOMAIN_Title:
+ title = _T("DVD - Title");
+ break;
+ }
+
+ // get title information
+ if (DVDDomain == DVD_DOMAIN_Title) {
+ // get current location (title number & chapter)
+ if (SUCCEEDED(pDVDI->GetCurrentLocation(&Location))) {
+ // get number of chapters in current title
+ pDVDI->GetNumberOfChapters(Location.TitleNum, &ulNumOfChapters);
+ }
+
+ // get total time of title
+ DVD_HMSF_TIMECODE tcDur;
+ ULONG ulFlags;
+ if (SUCCEEDED(pDVDI->GetTotalTitleTime(&tcDur, &ulFlags))) {
+ // calculate duration in seconds
+ lDuration = tcDur.bHours * 60 * 60 + tcDur.bMinutes * 60 + tcDur.bSeconds;
+ }
+
+ // build string
+ // DVD - xxxxx|currenttitle|numberofchapters|currentchapter|titleduration
+ author.Format(L"%d", Location.TitleNum);
+ description.Format(L"%d", ulNumOfChapters);
+ label.Format(L"%d", Location.ChapterNum);
+ }
+ }
+ }
+
+ title.Replace(L"|", L"\\|");
+ author.Replace(L"|", L"\\|");
+ description.Replace(L"|", L"\\|");
+ label.Replace(L"|", L"\\|");
+
+ CStringW buff;
+ buff.Format(L"%s|%s|%s|%s|%d", title, author, description, label, lDuration);
+
+ SendAPICommand(CMD_NOWPLAYING, buff);
+ SendSubtitleTracksToApi();
+ SendAudioTracksToApi();
+ }
}
void CMainFrame::SendSubtitleTracksToApi()
{
- CStringW strSubs;
- POSITION pos = m_pSubStreams.GetHeadPosition();
-
- if (m_iMediaLoadState == MLS_LOADED) {
- if (pos) {
- while (pos) {
- CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
-
- for (int i = 0, j = pSubStream->GetStreamCount(); i < j; i++) {
- WCHAR* pName = NULL;
- if (SUCCEEDED(pSubStream->GetStreamInfo(i, &pName, NULL))) {
- CString name(pName);
- if (!strSubs.IsEmpty()) {
- strSubs.Append (L"|");
- }
- name.Replace(L"|", L"\\|");
- strSubs.AppendFormat(L"%s", name);
- CoTaskMemFree(pName);
- }
- }
- }
- if (AfxGetAppSettings().fEnableSubtitles) {
- if (m_iSubtitleSel >= 0) {
- strSubs.AppendFormat(L"|%i", m_iSubtitleSel);
- } else {
- strSubs.Append(L"|-1");
- }
- } else {
- strSubs.Append (L"|-1");
- }
- } else {
- strSubs.Append (L"-1");
- }
- } else {
- strSubs.Append (L"-2");
- }
- SendAPICommand (CMD_LISTSUBTITLETRACKS, strSubs);
+ CStringW strSubs;
+ POSITION pos = m_pSubStreams.GetHeadPosition();
+
+ if (m_iMediaLoadState == MLS_LOADED) {
+ if (pos) {
+ while (pos) {
+ CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
+
+ for (int i = 0, j = pSubStream->GetStreamCount(); i < j; i++) {
+ WCHAR* pName = NULL;
+ if (SUCCEEDED(pSubStream->GetStreamInfo(i, &pName, NULL))) {
+ CString name(pName);
+ if (!strSubs.IsEmpty()) {
+ strSubs.Append(L"|");
+ }
+ name.Replace(L"|", L"\\|");
+ strSubs.AppendFormat(L"%s", name);
+ CoTaskMemFree(pName);
+ }
+ }
+ }
+ if (AfxGetAppSettings().fEnableSubtitles) {
+ if (m_iSubtitleSel >= 0) {
+ strSubs.AppendFormat(L"|%i", m_iSubtitleSel);
+ } else {
+ strSubs.Append(L"|-1");
+ }
+ } else {
+ strSubs.Append(L"|-1");
+ }
+ } else {
+ strSubs.Append(L"-1");
+ }
+ } else {
+ strSubs.Append(L"-2");
+ }
+ SendAPICommand(CMD_LISTSUBTITLETRACKS, strSubs);
}
void CMainFrame::SendAudioTracksToApi()
{
- CStringW strAudios;
-
- if (m_iMediaLoadState == MLS_LOADED) {
- CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
- if (!pSS) {
- pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB); // morgan's switcher
- }
-
- DWORD cStreams = 0;
- if (pSS && SUCCEEDED(pSS->Count(&cStreams))) {
- int currentStream = -1;
- for (int i = 0; i < (int)cStreams; i++) {
- AM_MEDIA_TYPE* pmt = NULL;
- DWORD dwFlags = 0;
- LCID lcid = 0;
- DWORD dwGroup = 0;
- WCHAR* pszName = NULL;
- if (FAILED(pSS->Info(i, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))) {
- return;
- }
- if (dwFlags == AMSTREAMSELECTINFO_EXCLUSIVE) {
- currentStream = i;
- }
- CString name(pszName);
- if (!strAudios.IsEmpty()) {
- strAudios.Append (L"|");
- }
- name.Replace(L"|", L"\\|");
- strAudios.AppendFormat(L"%s", name);
- if (pmt) {
- DeleteMediaType(pmt);
- }
- if (pszName) {
- CoTaskMemFree(pszName);
- }
- }
- strAudios.AppendFormat(L"|%i", currentStream);
-
- } else {
- strAudios.Append(L"-1");
- }
- } else {
- strAudios.Append(L"-2");
- }
- SendAPICommand (CMD_LISTAUDIOTRACKS, strAudios);
+ CStringW strAudios;
+
+ if (m_iMediaLoadState == MLS_LOADED) {
+ CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
+ if (!pSS) {
+ pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB); // morgan's switcher
+ }
+
+ DWORD cStreams = 0;
+ if (pSS && SUCCEEDED(pSS->Count(&cStreams))) {
+ int currentStream = -1;
+ for (int i = 0; i < (int)cStreams; i++) {
+ AM_MEDIA_TYPE* pmt = NULL;
+ DWORD dwFlags = 0;
+ LCID lcid = 0;
+ DWORD dwGroup = 0;
+ WCHAR* pszName = NULL;
+ if (FAILED(pSS->Info(i, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))) {
+ return;
+ }
+ if (dwFlags == AMSTREAMSELECTINFO_EXCLUSIVE) {
+ currentStream = i;
+ }
+ CString name(pszName);
+ if (!strAudios.IsEmpty()) {
+ strAudios.Append(L"|");
+ }
+ name.Replace(L"|", L"\\|");
+ strAudios.AppendFormat(L"%s", name);
+ if (pmt) {
+ DeleteMediaType(pmt);
+ }
+ if (pszName) {
+ CoTaskMemFree(pszName);
+ }
+ }
+ strAudios.AppendFormat(L"|%i", currentStream);
+
+ } else {
+ strAudios.Append(L"-1");
+ }
+ } else {
+ strAudios.Append(L"-2");
+ }
+ SendAPICommand(CMD_LISTAUDIOTRACKS, strAudios);
}
void CMainFrame::SendPlaylistToApi()
{
- CStringW strPlaylist;
- int index;
-
- POSITION pos = m_wndPlaylistBar.m_pl.GetHeadPosition(), pos2;
- while (pos) {
- CPlaylistItem& pli = m_wndPlaylistBar.m_pl.GetNext(pos);
-
- if (pli.m_type == CPlaylistItem::file) {
- pos2 = pli.m_fns.GetHeadPosition();
- while (pos2) {
- CString fn = pli.m_fns.GetNext(pos2);
- if (!strPlaylist.IsEmpty()) {
- strPlaylist.Append (L"|");
- }
- fn.Replace(L"|", L"\\|");
- strPlaylist.AppendFormat(L"%s", fn);
- }
- }
- }
- index = m_wndPlaylistBar.GetSelIdx();
- if (strPlaylist.IsEmpty()) {
- strPlaylist.Append(L"-1");
- } else {
- strPlaylist.AppendFormat(L"|%i", index);
- }
- SendAPICommand (CMD_PLAYLIST, strPlaylist);
+ CStringW strPlaylist;
+ int index;
+
+ POSITION pos = m_wndPlaylistBar.m_pl.GetHeadPosition(), pos2;
+ while (pos) {
+ CPlaylistItem& pli = m_wndPlaylistBar.m_pl.GetNext(pos);
+
+ if (pli.m_type == CPlaylistItem::file) {
+ pos2 = pli.m_fns.GetHeadPosition();
+ while (pos2) {
+ CString fn = pli.m_fns.GetNext(pos2);
+ if (!strPlaylist.IsEmpty()) {
+ strPlaylist.Append(L"|");
+ }
+ fn.Replace(L"|", L"\\|");
+ strPlaylist.AppendFormat(L"%s", fn);
+ }
+ }
+ }
+ index = m_wndPlaylistBar.GetSelIdx();
+ if (strPlaylist.IsEmpty()) {
+ strPlaylist.Append(L"-1");
+ } else {
+ strPlaylist.AppendFormat(L"|%i", index);
+ }
+ SendAPICommand(CMD_PLAYLIST, strPlaylist);
}
void CMainFrame::SendCurrentPositionToApi(bool fNotifySeek)
{
- if (!AfxGetAppSettings().hMasterWnd) {
- return;
- }
-
- if (m_iMediaLoadState == MLS_LOADED) {
- CStringW strPos;
-
- if (GetPlaybackMode() == PM_FILE) {
- REFERENCE_TIME rtCur;
- pMS->GetCurrentPosition(&rtCur);
- strPos.Format(L"%.3f", rtCur/10000000.0);
- }
- else if (GetPlaybackMode() == PM_DVD) {
- DVD_PLAYBACK_LOCATION2 Location;
- // get current location while playing disc, will return 0, if at a menu
- if (pDVDI->GetCurrentLocation(&Location) == S_OK) {
- strPos.Format(L"%u", Location.TimeCode.bHours*60*60 + Location.TimeCode.bMinutes*60 + Location.TimeCode.bSeconds);
- }
- }
+ if (!AfxGetAppSettings().hMasterWnd) {
+ return;
+ }
- SendAPICommand (fNotifySeek ? CMD_NOTIFYSEEK : CMD_CURRENTPOSITION, strPos);
- }
+ if (m_iMediaLoadState == MLS_LOADED) {
+ CStringW strPos;
+
+ if (GetPlaybackMode() == PM_FILE) {
+ REFERENCE_TIME rtCur;
+ pMS->GetCurrentPosition(&rtCur);
+ strPos.Format(L"%.3f", rtCur / 10000000.0);
+ } else if (GetPlaybackMode() == PM_DVD) {
+ DVD_PLAYBACK_LOCATION2 Location;
+ // get current location while playing disc, will return 0, if at a menu
+ if (pDVDI->GetCurrentLocation(&Location) == S_OK) {
+ strPos.Format(L"%u", Location.TimeCode.bHours * 60 * 60 + Location.TimeCode.bMinutes * 60 + Location.TimeCode.bSeconds);
+ }
+ }
+
+ SendAPICommand(fNotifySeek ? CMD_NOTIFYSEEK : CMD_CURRENTPOSITION, strPos);
+ }
}
-void CMainFrame::ShowOSDCustomMessageApi(MPC_OSDDATA *osdData)
+void CMainFrame::ShowOSDCustomMessageApi(MPC_OSDDATA* osdData)
{
- m_OSD.DisplayMessage ((OSD_MESSAGEPOS)osdData->nMsgPos, osdData->strMsg, osdData->nDurationMS);
+ m_OSD.DisplayMessage((OSD_MESSAGEPOS)osdData->nMsgPos, osdData->strMsg, osdData->nDurationMS);
}
void CMainFrame::JumpOfNSeconds(int nSeconds)
{
- if (m_iMediaLoadState == MLS_LOADED) {
- long lPosition = 0;
- REFERENCE_TIME rtCur;
-
- if (GetPlaybackMode() == PM_FILE) {
- pMS->GetCurrentPosition(&rtCur);
- DVD_HMSF_TIMECODE tcCur = RT2HMSF(rtCur);
- lPosition = tcCur.bHours*60*60 + tcCur.bMinutes*60 + tcCur.bSeconds + nSeconds;
-
- // revert the update position to REFERENCE_TIME format
- tcCur.bHours = (BYTE)(lPosition / 3600);
- tcCur.bMinutes = (lPosition / 60) % 60;
- tcCur.bSeconds = lPosition % 60;
- rtCur = HMSF2RT(tcCur);
-
- // quick and dirty trick:
- // pause->seekto->play seems to prevents some strange
- // video effect (ex. locks for a while and than running fast)
- if (!m_fAudioOnly) {
- SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
- }
- SeekTo(rtCur);
- if (!m_fAudioOnly) {
- SendMessage(WM_COMMAND, ID_PLAY_PLAY);
- // show current position overridden by play command
- m_OSD.DisplayMessage(OSD_TOPLEFT, m_wndStatusBar.GetStatusTimer(), 2000);
- }
- }
- }
+ if (m_iMediaLoadState == MLS_LOADED) {
+ long lPosition = 0;
+ REFERENCE_TIME rtCur;
+
+ if (GetPlaybackMode() == PM_FILE) {
+ pMS->GetCurrentPosition(&rtCur);
+ DVD_HMSF_TIMECODE tcCur = RT2HMSF(rtCur);
+ lPosition = tcCur.bHours * 60 * 60 + tcCur.bMinutes * 60 + tcCur.bSeconds + nSeconds;
+
+ // revert the update position to REFERENCE_TIME format
+ tcCur.bHours = (BYTE)(lPosition / 3600);
+ tcCur.bMinutes = (lPosition / 60) % 60;
+ tcCur.bSeconds = lPosition % 60;
+ rtCur = HMSF2RT(tcCur);
+
+ // quick and dirty trick:
+ // pause->seekto->play seems to prevents some strange
+ // video effect (ex. locks for a while and than running fast)
+ if (!m_fAudioOnly) {
+ SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ }
+ SeekTo(rtCur);
+ if (!m_fAudioOnly) {
+ SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ // show current position overridden by play command
+ m_OSD.DisplayMessage(OSD_TOPLEFT, m_wndStatusBar.GetStatusTimer(), 2000);
+ }
+ }
+ }
}
// TODO : to be finished !
//void CMainFrame::AutoSelectTracks()
//{
-// LCID DefAudioLanguageLcid [2] = {MAKELCID( MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT), SORT_DEFAULT), MAKELCID( MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), SORT_DEFAULT)};
-// int DefAudioLanguageIndex [2] = {-1, -1};
-// LCID DefSubtitleLanguageLcid [2] = {0, MAKELCID( MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT), SORT_DEFAULT)};
-// int DefSubtitleLanguageIndex[2] = {-1, -1};
-// LCID Language = MAKELCID( MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT), SORT_DEFAULT);
+// LCID DefAudioLanguageLcid [2] = {MAKELCID( MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT), SORT_DEFAULT), MAKELCID( MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), SORT_DEFAULT)};
+// int DefAudioLanguageIndex [2] = {-1, -1};
+// LCID DefSubtitleLanguageLcid [2] = {0, MAKELCID( MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT), SORT_DEFAULT)};
+// int DefSubtitleLanguageIndex[2] = {-1, -1};
+// LCID Language = MAKELCID( MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT), SORT_DEFAULT);
//
-// if ((m_iMediaLoadState == MLS_LOADING) || (m_iMediaLoadState == MLS_LOADED))
-// {
-// if (GetPlaybackMode() == PM_FILE)
-// {
-// CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
-// if (!pSS) pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB); // morgan's switcher
+// if ((m_iMediaLoadState == MLS_LOADING) || (m_iMediaLoadState == MLS_LOADED))
+// {
+// if (GetPlaybackMode() == PM_FILE)
+// {
+// CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
+// if (!pSS) pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB); // morgan's switcher
//
-// DWORD cStreams = 0;
-// if (pSS && SUCCEEDED(pSS->Count(&cStreams)))
-// {
-// for (int i = 0; i < (int)cStreams; i++)
-// {
-// AM_MEDIA_TYPE* pmt = NULL;
-// DWORD dwFlags = 0;
-// LCID lcid = 0;
-// DWORD dwGroup = 0;
-// WCHAR* pszName = NULL;
-// if (FAILED(pSS->Info(i, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL)))
-// return;
-// }
-// }
+// DWORD cStreams = 0;
+// if (pSS && SUCCEEDED(pSS->Count(&cStreams)))
+// {
+// for (int i = 0; i < (int)cStreams; i++)
+// {
+// AM_MEDIA_TYPE* pmt = NULL;
+// DWORD dwFlags = 0;
+// LCID lcid = 0;
+// DWORD dwGroup = 0;
+// WCHAR* pszName = NULL;
+// if (FAILED(pSS->Info(i, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL)))
+// return;
+// }
+// }
//
-// POSITION pos = m_pSubStreams.GetHeadPosition();
-// while (pos)
-// {
-// CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
-// if (!pSubStream) continue;
+// POSITION pos = m_pSubStreams.GetHeadPosition();
+// while (pos)
+// {
+// CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
+// if (!pSubStream) continue;
//
-// for (int i = 0, j = pSubStream->GetStreamCount(); i < j; i++)
-// {
-// WCHAR* pName = NULL;
-// if (SUCCEEDED(pSubStream->GetStreamInfo(i, &pName, &Language)))
-// {
-// if (DefAudioLanguageLcid[0] == Language) DefSubtitleLanguageIndex[0] = i;
-// if (DefSubtitleLanguageLcid[1] == Language) DefSubtitleLanguageIndex[1] = i;
-// CoTaskMemFree(pName);
-// }
-// }
-// }
-// }
-// else if (GetPlaybackMode() == PM_DVD)
-// {
-// ULONG ulStreamsAvailable, ulCurrentStream;
-// BOOL bIsDisabled;
+// for (int i = 0, j = pSubStream->GetStreamCount(); i < j; i++)
+// {
+// WCHAR* pName = NULL;
+// if (SUCCEEDED(pSubStream->GetStreamInfo(i, &pName, &Language)))
+// {
+// if (DefAudioLanguageLcid[0] == Language) DefSubtitleLanguageIndex[0] = i;
+// if (DefSubtitleLanguageLcid[1] == Language) DefSubtitleLanguageIndex[1] = i;
+// CoTaskMemFree(pName);
+// }
+// }
+// }
+// }
+// else if (GetPlaybackMode() == PM_DVD)
+// {
+// ULONG ulStreamsAvailable, ulCurrentStream;
+// BOOL bIsDisabled;
//
-// if (SUCCEEDED(pDVDI->GetCurrentSubpicture(&ulStreamsAvailable, &ulCurrentStream, &bIsDisabled)))
-// {
-// for (ULONG i = 0; i < ulStreamsAvailable; i++)
-// {
-// DVD_SubpictureAttributes ATR;
-// if (SUCCEEDED(pDVDI->GetSubpictureLanguage(i, &Language)))
-// {
-// // Auto select forced subtitle
-// if ((DefAudioLanguageLcid[0] == Language) && (ATR.LanguageExtension == DVD_SP_EXT_Forced))
-// DefSubtitleLanguageIndex[0] = i;
+// if (SUCCEEDED(pDVDI->GetCurrentSubpicture(&ulStreamsAvailable, &ulCurrentStream, &bIsDisabled)))
+// {
+// for (ULONG i = 0; i < ulStreamsAvailable; i++)
+// {
+// DVD_SubpictureAttributes ATR;
+// if (SUCCEEDED(pDVDI->GetSubpictureLanguage(i, &Language)))
+// {
+// // Auto select forced subtitle
+// if ((DefAudioLanguageLcid[0] == Language) && (ATR.LanguageExtension == DVD_SP_EXT_Forced))
+// DefSubtitleLanguageIndex[0] = i;
//
-// if (DefSubtitleLanguageLcid[1] == Language) DefSubtitleLanguageIndex[1] = i;
-// }
-// }
-// }
+// if (DefSubtitleLanguageLcid[1] == Language) DefSubtitleLanguageIndex[1] = i;
+// }
+// }
+// }
//
-// if (SUCCEEDED(pDVDI->GetCurrentAudio(&ulStreamsAvailable, &ulCurrentStream)))
-// {
-// for (ULONG i = 0; i < ulStreamsAvailable; i++)
-// {
-// if (SUCCEEDED(pDVDI->GetAudioLanguage(i, &Language)))
-// {
-// if (DefAudioLanguageLcid[0] == Language) DefAudioLanguageIndex[0] = i;
-// if (DefAudioLanguageLcid[1] == Language) DefAudioLanguageIndex[1] = i;
-// }
-// }
-// }
+// if (SUCCEEDED(pDVDI->GetCurrentAudio(&ulStreamsAvailable, &ulCurrentStream)))
+// {
+// for (ULONG i = 0; i < ulStreamsAvailable; i++)
+// {
+// if (SUCCEEDED(pDVDI->GetAudioLanguage(i, &Language)))
+// {
+// if (DefAudioLanguageLcid[0] == Language) DefAudioLanguageIndex[0] = i;
+// if (DefAudioLanguageLcid[1] == Language) DefAudioLanguageIndex[1] = i;
+// }
+// }
+// }
//
-// // Select best audio/subtitles tracks
-// if (DefAudioLanguageLcid[0] != -1)
-// {
-// pDVDC->SelectAudioStream(DefAudioLanguageIndex[0], DVD_CMD_FLAG_Block, NULL);
-// if (DefSubtitleLanguageIndex[0] != -1)
-// pDVDC->SelectSubpictureStream(DefSubtitleLanguageIndex[0], DVD_CMD_FLAG_Block, NULL);
-// }
-// else if ((DefAudioLanguageLcid[1] != -1) && (DefSubtitleLanguageLcid[1] != -1))
-// {
-// pDVDC->SelectAudioStream (DefAudioLanguageIndex[1], DVD_CMD_FLAG_Block, NULL);
-// pDVDC->SelectSubpictureStream (DefSubtitleLanguageIndex[1], DVD_CMD_FLAG_Block, NULL);
-// }
-// }
+// // Select best audio/subtitles tracks
+// if (DefAudioLanguageLcid[0] != -1)
+// {
+// pDVDC->SelectAudioStream(DefAudioLanguageIndex[0], DVD_CMD_FLAG_Block, NULL);
+// if (DefSubtitleLanguageIndex[0] != -1)
+// pDVDC->SelectSubpictureStream(DefSubtitleLanguageIndex[0], DVD_CMD_FLAG_Block, NULL);
+// }
+// else if ((DefAudioLanguageLcid[1] != -1) && (DefSubtitleLanguageLcid[1] != -1))
+// {
+// pDVDC->SelectAudioStream (DefAudioLanguageIndex[1], DVD_CMD_FLAG_Block, NULL);
+// pDVDC->SelectSubpictureStream (DefSubtitleLanguageIndex[1], DVD_CMD_FLAG_Block, NULL);
+// }
+// }
//
//
-// }
+// }
//}
void CMainFrame::OnFileOpendirectory()
{
- if (m_iMediaLoadState == MLS_LOADING || !IsWindow(m_wndPlaylistBar)) {
- return;
- }
-
- AppSettings& s = AfxGetAppSettings();
- CString strTitle = ResStr(IDS_MAINFRM_DIR_TITLE);
- CString path;
-
- if (SysVersion::IsVistaOrLater()) {
- CFileDialog dlg(TRUE);
- dlg.AddCheckButton(IDS_MAINFRM_DIR_CHECK, ResStr(IDS_MAINFRM_DIR_CHECK), TRUE);
- IFileOpenDialog *openDlgPtr = dlg.GetIFileOpenDialog();
-
- if (openDlgPtr != NULL) {
- openDlgPtr->SetTitle(strTitle);
- openDlgPtr->SetOptions(FOS_PICKFOLDERS | FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST);
- if (FAILED(openDlgPtr->Show(m_hWnd))) {
- openDlgPtr->Release();
- return;
- }
- openDlgPtr->Release();
-
- path = dlg.GetFolderPath();
-
- BOOL recur = TRUE;
- dlg.GetCheckButtonState(IDS_MAINFRM_DIR_CHECK, recur);
- COpenDirHelper::m_incl_subdir = !!recur;
- } else {
- return;
- }
- } else {
- CString filter;
- CAtlArray<CString> mask;
- s.m_Formats.GetFilter(filter, mask);
-
- COpenDirHelper::strLastOpenDir = s.strLastOpenDir;
-
- TCHAR _path[_MAX_PATH];
- COpenDirHelper::m_incl_subdir = TRUE;
-
- BROWSEINFO bi;
- bi.hwndOwner = m_hWnd;
- bi.pidlRoot = NULL;
- bi.pszDisplayName = _path;
- bi.lpszTitle = strTitle;
- bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_VALIDATE | BIF_STATUSTEXT;
- bi.lpfn = COpenDirHelper::BrowseCallbackProcDIR;
- bi.lParam = 0;
- bi.iImage = 0;
-
- static LPITEMIDLIST iil;
- iil = SHBrowseForFolder(&bi);
- if (iil) {
- SHGetPathFromIDList(iil, _path);
- } else {
- return;
- }
- path = _path;
- }
-
- if (path[path.GetLength() - 1] != '\\') {
- path += '\\';
- }
-
- CAtlList<CString> sl;
- sl.AddTail(path);
- if (COpenDirHelper::m_incl_subdir) {
- COpenDirHelper::RecurseAddDir(path, &sl);
- }
-
- if (m_wndPlaylistBar.IsWindowVisible()) {
- m_wndPlaylistBar.Append(sl, true);
- } else {
- m_wndPlaylistBar.Open(sl, true);
- OpenCurPlaylistItem();
- }
+ if (m_iMediaLoadState == MLS_LOADING || !IsWindow(m_wndPlaylistBar)) {
+ return;
+ }
+
+ AppSettings& s = AfxGetAppSettings();
+ CString strTitle = ResStr(IDS_MAINFRM_DIR_TITLE);
+ CString path;
+
+ if (SysVersion::IsVistaOrLater()) {
+ CFileDialog dlg(TRUE);
+ dlg.AddCheckButton(IDS_MAINFRM_DIR_CHECK, ResStr(IDS_MAINFRM_DIR_CHECK), TRUE);
+ IFileOpenDialog* openDlgPtr = dlg.GetIFileOpenDialog();
+
+ if (openDlgPtr != NULL) {
+ openDlgPtr->SetTitle(strTitle);
+ openDlgPtr->SetOptions(FOS_PICKFOLDERS | FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST);
+ if (FAILED(openDlgPtr->Show(m_hWnd))) {
+ openDlgPtr->Release();
+ return;
+ }
+ openDlgPtr->Release();
+
+ path = dlg.GetFolderPath();
+
+ BOOL recur = TRUE;
+ dlg.GetCheckButtonState(IDS_MAINFRM_DIR_CHECK, recur);
+ COpenDirHelper::m_incl_subdir = !!recur;
+ } else {
+ return;
+ }
+ } else {
+ CString filter;
+ CAtlArray<CString> mask;
+ s.m_Formats.GetFilter(filter, mask);
+
+ COpenDirHelper::strLastOpenDir = s.strLastOpenDir;
+
+ TCHAR _path[_MAX_PATH];
+ COpenDirHelper::m_incl_subdir = TRUE;
+
+ BROWSEINFO bi;
+ bi.hwndOwner = m_hWnd;
+ bi.pidlRoot = NULL;
+ bi.pszDisplayName = _path;
+ bi.lpszTitle = strTitle;
+ bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_VALIDATE | BIF_STATUSTEXT;
+ bi.lpfn = COpenDirHelper::BrowseCallbackProcDIR;
+ bi.lParam = 0;
+ bi.iImage = 0;
+
+ static LPITEMIDLIST iil;
+ iil = SHBrowseForFolder(&bi);
+ if (iil) {
+ SHGetPathFromIDList(iil, _path);
+ } else {
+ return;
+ }
+ path = _path;
+ }
+
+ if (path[path.GetLength() - 1] != '\\') {
+ path += '\\';
+ }
+
+ CAtlList<CString> sl;
+ sl.AddTail(path);
+ if (COpenDirHelper::m_incl_subdir) {
+ COpenDirHelper::RecurseAddDir(path, &sl);
+ }
+
+ if (m_wndPlaylistBar.IsWindowVisible()) {
+ m_wndPlaylistBar.Append(sl, true);
+ } else {
+ m_wndPlaylistBar.Open(sl, true);
+ OpenCurPlaylistItem();
+ }
}
HRESULT CMainFrame::CreateThumbnailToolbar()
{
- if (!AfxGetAppSettings().fUseWin7TaskBar || !SysVersion::Is7OrLater()) {
- return E_FAIL;
- }
-
- if (m_pTaskbarList) {
- m_pTaskbarList->Release();
- }
- HRESULT hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&m_pTaskbarList));
- if (SUCCEEDED(hr)) {
- CMPCPngImage image;
- if (!image.Load(MAKEINTRESOURCE(ID_W7_TOOLBAR))) {
- m_pTaskbarList->Release();
- image.CleanUp();
- return E_FAIL;
- }
-
- BITMAP bi;
- image.GetBitmap(&bi);
- int nI = bi.bmWidth / bi.bmHeight;
- HIMAGELIST hImageList = ImageList_Create(bi.bmHeight, bi.bmHeight, ILC_COLOR32, nI, 0);
-
- ImageList_Add(hImageList, (HBITMAP)image, 0);
- hr = m_pTaskbarList->ThumbBarSetImageList(m_hWnd, hImageList);
-
- if (SUCCEEDED(hr)) {
- THUMBBUTTON buttons[5] = {};
-
- // PREVIOUS
- buttons[0].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[0].dwFlags = THBF_DISABLED;
- buttons[0].iId = IDTB_BUTTON3;
- buttons[0].iBitmap = 0;
- StringCchCopy(buttons[0].szTip, _countof(buttons[0].szTip), ResStr(IDS_AG_PREVIOUS));
-
- // STOP
- buttons[1].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[1].dwFlags = THBF_DISABLED;
- buttons[1].iId = IDTB_BUTTON1;
- buttons[1].iBitmap = 1;
- StringCchCopy(buttons[1].szTip, _countof(buttons[1].szTip), ResStr(IDS_AG_STOP));
-
- // PLAY/PAUSE
- buttons[2].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[2].dwFlags = THBF_DISABLED;
- buttons[2].iId = IDTB_BUTTON2;
- buttons[2].iBitmap = 3;
- StringCchCopy(buttons[2].szTip, _countof(buttons[2].szTip), ResStr(IDS_AG_PLAYPAUSE));
-
- // NEXT
- buttons[3].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[3].dwFlags = THBF_DISABLED;
- buttons[3].iId = IDTB_BUTTON4;
- buttons[3].iBitmap = 4;
- StringCchCopy(buttons[3].szTip, _countof(buttons[3].szTip), ResStr(IDS_AG_NEXT));
-
- // FULLSCREEN
- buttons[4].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[4].dwFlags = THBF_DISABLED;
- buttons[4].iId = IDTB_BUTTON5;
- buttons[4].iBitmap = 5;
- StringCchCopy(buttons[4].szTip, _countof(buttons[4].szTip), ResStr(IDS_AG_FULLSCREEN));
-
- hr = m_pTaskbarList->ThumbBarAddButtons(m_hWnd, ARRAYSIZE(buttons), buttons);
- }
- ImageList_Destroy(hImageList);
- image.CleanUp();
- }
-
- return hr;
-}
+ if (!AfxGetAppSettings().fUseWin7TaskBar || !SysVersion::Is7OrLater()) {
+ return E_FAIL;
+ }
-HRESULT CMainFrame::UpdateThumbarButton()
-{
- if ( !m_pTaskbarList ) {
- return E_FAIL;
- }
-
- if ( !AfxGetAppSettings().fUseWin7TaskBar ) {
- m_pTaskbarList->SetOverlayIcon( m_hWnd, NULL, L"" );
- m_pTaskbarList->SetProgressState( m_hWnd, TBPF_NOPROGRESS );
-
- THUMBBUTTON buttons[5] = {};
-
- buttons[0].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[0].dwFlags = THBF_HIDDEN;
- buttons[0].iId = IDTB_BUTTON3;
-
- buttons[1].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[1].dwFlags = THBF_HIDDEN;
- buttons[1].iId = IDTB_BUTTON1;
-
- buttons[2].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[2].dwFlags = THBF_HIDDEN;
- buttons[2].iId = IDTB_BUTTON2;
-
- buttons[3].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[3].dwFlags = THBF_HIDDEN;
- buttons[3].iId = IDTB_BUTTON4;
-
- buttons[4].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[4].dwFlags = THBF_HIDDEN;
- buttons[4].iId = IDTB_BUTTON5;
-
- HRESULT hr = m_pTaskbarList->ThumbBarUpdateButtons( m_hWnd, ARRAYSIZE(buttons), buttons );
- return hr;
- }
-
- THUMBBUTTON buttons[5] = {};
-
- buttons[0].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[0].dwFlags = (!AfxGetAppSettings().fUseSearchInFolder && m_wndPlaylistBar.GetCount() <= 1 && (m_pCB && m_pCB->ChapGetCount() <= 1)) ? THBF_DISABLED : THBF_ENABLED;
- buttons[0].iId = IDTB_BUTTON3;
- buttons[0].iBitmap = 0;
- StringCchCopy( buttons[0].szTip, _countof(buttons[0].szTip), ResStr(IDS_AG_PREVIOUS) );
-
- buttons[1].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[1].iId = IDTB_BUTTON1;
- buttons[1].iBitmap = 1;
- StringCchCopy( buttons[1].szTip, _countof(buttons[1].szTip), ResStr(IDS_AG_STOP) );
-
- buttons[2].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[2].iId = IDTB_BUTTON2;
- buttons[2].iBitmap = 3;
- StringCchCopy( buttons[2].szTip, _countof(buttons[2].szTip), ResStr(IDS_AG_PLAYPAUSE) );
-
- buttons[3].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[3].dwFlags = (!AfxGetAppSettings().fUseSearchInFolder && m_wndPlaylistBar.GetCount() <= 1 && (m_pCB && m_pCB->ChapGetCount() <= 1)) ? THBF_DISABLED : THBF_ENABLED;
- buttons[3].iId = IDTB_BUTTON4;
- buttons[3].iBitmap = 4;
- StringCchCopy( buttons[3].szTip, _countof(buttons[3].szTip), ResStr(IDS_AG_NEXT) );
-
- buttons[4].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
- buttons[4].dwFlags = THBF_ENABLED;
- buttons[4].iId = IDTB_BUTTON5;
- buttons[4].iBitmap = 5;
- StringCchCopy( buttons[4].szTip, _countof(buttons[4].szTip), ResStr(IDS_AG_FULLSCREEN) );
-
- HICON hIcon = NULL;
-
- if ( m_iMediaLoadState == MLS_LOADED ) {
- OAFilterState fs = GetMediaState();
- if ( fs == State_Running ) {
- buttons[1].dwFlags = THBF_ENABLED;
- buttons[2].dwFlags = THBF_ENABLED;
- buttons[2].iBitmap = 2;
-
- hIcon = AfxGetApp()->LoadIcon( IDR_TB_PLAY );
- m_pTaskbarList->SetProgressState( m_hWnd, TBPF_NORMAL );
- } else if ( fs == State_Stopped ) {
- buttons[1].dwFlags = THBF_DISABLED;
- buttons[2].dwFlags = THBF_ENABLED;
- buttons[2].iBitmap = 3;
-
- hIcon = AfxGetApp()->LoadIcon( IDR_TB_STOP );
- m_pTaskbarList->SetProgressState( m_hWnd, TBPF_NOPROGRESS );
- } else if ( fs == State_Paused ) {
- buttons[1].dwFlags = THBF_ENABLED;
- buttons[2].dwFlags = THBF_ENABLED;
- buttons[2].iBitmap = 3;
-
- hIcon = AfxGetApp()->LoadIcon( IDR_TB_PAUSE );
- m_pTaskbarList->SetProgressState( m_hWnd, TBPF_PAUSED );
- }
-
- if ( m_fAudioOnly ) {
- buttons[4].dwFlags = THBF_DISABLED;
- }
-
- if (GetPlaybackMode() == PM_DVD && m_iDVDDomain != DVD_DOMAIN_Title) {
- buttons[0].dwFlags = THBF_DISABLED;
- buttons[1].dwFlags = THBF_DISABLED;
- buttons[2].dwFlags = THBF_DISABLED;
- buttons[3].dwFlags = THBF_DISABLED;
- }
-
- m_pTaskbarList->SetOverlayIcon( m_hWnd, hIcon, L"" );
-
- if ( hIcon != NULL ) {
- DestroyIcon( hIcon );
- }
- } else {
- buttons[0].dwFlags = THBF_DISABLED;
- buttons[1].dwFlags = THBF_DISABLED;
- buttons[2].dwFlags = THBF_DISABLED;
- buttons[3].dwFlags = THBF_DISABLED;
- buttons[4].dwFlags = THBF_DISABLED;
-
- m_pTaskbarList->SetOverlayIcon( m_hWnd, NULL, L"" );
- m_pTaskbarList->SetProgressState( m_hWnd, TBPF_NOPROGRESS );
- }
-
- HRESULT hr = m_pTaskbarList->ThumbBarUpdateButtons( m_hWnd, ARRAYSIZE(buttons), buttons );
-
- UpdateThumbnailClip();
-
- return hr;
+ if (m_pTaskbarList) {
+ m_pTaskbarList->Release();
+ }
+ HRESULT hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&m_pTaskbarList));
+ if (SUCCEEDED(hr)) {
+ CMPCPngImage image;
+ if (!image.Load(MAKEINTRESOURCE(ID_W7_TOOLBAR))) {
+ m_pTaskbarList->Release();
+ image.CleanUp();
+ return E_FAIL;
+ }
+
+ BITMAP bi;
+ image.GetBitmap(&bi);
+ int nI = bi.bmWidth / bi.bmHeight;
+ HIMAGELIST hImageList = ImageList_Create(bi.bmHeight, bi.bmHeight, ILC_COLOR32, nI, 0);
+
+ ImageList_Add(hImageList, (HBITMAP)image, 0);
+ hr = m_pTaskbarList->ThumbBarSetImageList(m_hWnd, hImageList);
+
+ if (SUCCEEDED(hr)) {
+ THUMBBUTTON buttons[5] = {};
+
+ // PREVIOUS
+ buttons[0].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[0].dwFlags = THBF_DISABLED;
+ buttons[0].iId = IDTB_BUTTON3;
+ buttons[0].iBitmap = 0;
+ StringCchCopy(buttons[0].szTip, _countof(buttons[0].szTip), ResStr(IDS_AG_PREVIOUS));
+
+ // STOP
+ buttons[1].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[1].dwFlags = THBF_DISABLED;
+ buttons[1].iId = IDTB_BUTTON1;
+ buttons[1].iBitmap = 1;
+ StringCchCopy(buttons[1].szTip, _countof(buttons[1].szTip), ResStr(IDS_AG_STOP));
+
+ // PLAY/PAUSE
+ buttons[2].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[2].dwFlags = THBF_DISABLED;
+ buttons[2].iId = IDTB_BUTTON2;
+ buttons[2].iBitmap = 3;
+ StringCchCopy(buttons[2].szTip, _countof(buttons[2].szTip), ResStr(IDS_AG_PLAYPAUSE));
+
+ // NEXT
+ buttons[3].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[3].dwFlags = THBF_DISABLED;
+ buttons[3].iId = IDTB_BUTTON4;
+ buttons[3].iBitmap = 4;
+ StringCchCopy(buttons[3].szTip, _countof(buttons[3].szTip), ResStr(IDS_AG_NEXT));
+
+ // FULLSCREEN
+ buttons[4].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[4].dwFlags = THBF_DISABLED;
+ buttons[4].iId = IDTB_BUTTON5;
+ buttons[4].iBitmap = 5;
+ StringCchCopy(buttons[4].szTip, _countof(buttons[4].szTip), ResStr(IDS_AG_FULLSCREEN));
+
+ hr = m_pTaskbarList->ThumbBarAddButtons(m_hWnd, ARRAYSIZE(buttons), buttons);
+ }
+ ImageList_Destroy(hImageList);
+ image.CleanUp();
+ }
+
+ return hr;
}
-HRESULT CMainFrame::UpdateThumbnailClip()
+HRESULT CMainFrame::UpdateThumbarButton()
{
- if ( !m_pTaskbarList ) {
- return E_FAIL;
- }
+ if (!m_pTaskbarList) {
+ return E_FAIL;
+ }
- if ( (!AfxGetAppSettings().fUseWin7TaskBar) || (m_iMediaLoadState != MLS_LOADED) || (m_fAudioOnly) || m_fFullScreen ) {
- return m_pTaskbarList->SetThumbnailClip( m_hWnd, NULL );
- }
+ if (!AfxGetAppSettings().fUseWin7TaskBar) {
+ m_pTaskbarList->SetOverlayIcon(m_hWnd, NULL, L"");
+ m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NOPROGRESS);
- RECT vid_rect, result_rect;
- m_wndView.GetClientRect( &vid_rect );
+ THUMBBUTTON buttons[5] = {};
- // Remove the menu from thumbnail clip preview if it displayed
- result_rect.left = 2;
- result_rect.right = result_rect.left + (vid_rect.right - vid_rect.left) - 4;
- result_rect.top = (AfxGetAppSettings().iCaptionMenuMode == MODE_SHOWCAPTIONMENU) ? 22 : 2;
- result_rect.bottom = result_rect.top + (vid_rect.bottom - vid_rect.top) - 4;
+ buttons[0].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[0].dwFlags = THBF_HIDDEN;
+ buttons[0].iId = IDTB_BUTTON3;
- return m_pTaskbarList->SetThumbnailClip( m_hWnd, &result_rect );
-}
+ buttons[1].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[1].dwFlags = THBF_HIDDEN;
+ buttons[1].iId = IDTB_BUTTON1;
-LRESULT CMainFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
-{
- if ((message == WM_COMMAND) && (THBN_CLICKED == HIWORD(wParam))) {
- int const wmId = LOWORD(wParam);
- switch (wmId) {
- case IDTB_BUTTON1:
- SendMessage(WM_COMMAND, ID_PLAY_STOP);
- break;
+ buttons[2].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[2].dwFlags = THBF_HIDDEN;
+ buttons[2].iId = IDTB_BUTTON2;
- case IDTB_BUTTON2:
- SendMessage(WM_COMMAND, ID_PLAY_PLAYPAUSE);
- break;
+ buttons[3].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[3].dwFlags = THBF_HIDDEN;
+ buttons[3].iId = IDTB_BUTTON4;
- case IDTB_BUTTON3:
- SendMessage(WM_COMMAND, ID_NAVIGATE_SKIPBACK);
- break;
+ buttons[4].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[4].dwFlags = THBF_HIDDEN;
+ buttons[4].iId = IDTB_BUTTON5;
- case IDTB_BUTTON4:
- SendMessage(WM_COMMAND, ID_NAVIGATE_SKIPFORWARD);
- break;
+ HRESULT hr = m_pTaskbarList->ThumbBarUpdateButtons(m_hWnd, ARRAYSIZE(buttons), buttons);
+ return hr;
+ }
- case IDTB_BUTTON5:
- WINDOWPLACEMENT wp;
- GetWindowPlacement(&wp);
- if (wp.showCmd == SW_SHOWMINIMIZED) {
- SendMessage(WM_SYSCOMMAND, SC_RESTORE, -1);
- }
- SetForegroundWindow();
+ THUMBBUTTON buttons[5] = {};
+
+ buttons[0].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[0].dwFlags = (!AfxGetAppSettings().fUseSearchInFolder && m_wndPlaylistBar.GetCount() <= 1 && (m_pCB && m_pCB->ChapGetCount() <= 1)) ? THBF_DISABLED : THBF_ENABLED;
+ buttons[0].iId = IDTB_BUTTON3;
+ buttons[0].iBitmap = 0;
+ StringCchCopy(buttons[0].szTip, _countof(buttons[0].szTip), ResStr(IDS_AG_PREVIOUS));
+
+ buttons[1].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[1].iId = IDTB_BUTTON1;
+ buttons[1].iBitmap = 1;
+ StringCchCopy(buttons[1].szTip, _countof(buttons[1].szTip), ResStr(IDS_AG_STOP));
+
+ buttons[2].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[2].iId = IDTB_BUTTON2;
+ buttons[2].iBitmap = 3;
+ StringCchCopy(buttons[2].szTip, _countof(buttons[2].szTip), ResStr(IDS_AG_PLAYPAUSE));
+
+ buttons[3].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[3].dwFlags = (!AfxGetAppSettings().fUseSearchInFolder && m_wndPlaylistBar.GetCount() <= 1 && (m_pCB && m_pCB->ChapGetCount() <= 1)) ? THBF_DISABLED : THBF_ENABLED;
+ buttons[3].iId = IDTB_BUTTON4;
+ buttons[3].iBitmap = 4;
+ StringCchCopy(buttons[3].szTip, _countof(buttons[3].szTip), ResStr(IDS_AG_NEXT));
+
+ buttons[4].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+ buttons[4].dwFlags = THBF_ENABLED;
+ buttons[4].iId = IDTB_BUTTON5;
+ buttons[4].iBitmap = 5;
+ StringCchCopy(buttons[4].szTip, _countof(buttons[4].szTip), ResStr(IDS_AG_FULLSCREEN));
+
+ HICON hIcon = NULL;
+
+ if (m_iMediaLoadState == MLS_LOADED) {
+ OAFilterState fs = GetMediaState();
+ if (fs == State_Running) {
+ buttons[1].dwFlags = THBF_ENABLED;
+ buttons[2].dwFlags = THBF_ENABLED;
+ buttons[2].iBitmap = 2;
+
+ hIcon = AfxGetApp()->LoadIcon(IDR_TB_PLAY);
+ m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NORMAL);
+ } else if (fs == State_Stopped) {
+ buttons[1].dwFlags = THBF_DISABLED;
+ buttons[2].dwFlags = THBF_ENABLED;
+ buttons[2].iBitmap = 3;
+
+ hIcon = AfxGetApp()->LoadIcon(IDR_TB_STOP);
+ m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NOPROGRESS);
+ } else if (fs == State_Paused) {
+ buttons[1].dwFlags = THBF_ENABLED;
+ buttons[2].dwFlags = THBF_ENABLED;
+ buttons[2].iBitmap = 3;
+
+ hIcon = AfxGetApp()->LoadIcon(IDR_TB_PAUSE);
+ m_pTaskbarList->SetProgressState(m_hWnd, TBPF_PAUSED);
+ }
+
+ if (m_fAudioOnly) {
+ buttons[4].dwFlags = THBF_DISABLED;
+ }
+
+ if (GetPlaybackMode() == PM_DVD && m_iDVDDomain != DVD_DOMAIN_Title) {
+ buttons[0].dwFlags = THBF_DISABLED;
+ buttons[1].dwFlags = THBF_DISABLED;
+ buttons[2].dwFlags = THBF_DISABLED;
+ buttons[3].dwFlags = THBF_DISABLED;
+ }
+
+ m_pTaskbarList->SetOverlayIcon(m_hWnd, hIcon, L"");
+
+ if (hIcon != NULL) {
+ DestroyIcon(hIcon);
+ }
+ } else {
+ buttons[0].dwFlags = THBF_DISABLED;
+ buttons[1].dwFlags = THBF_DISABLED;
+ buttons[2].dwFlags = THBF_DISABLED;
+ buttons[3].dwFlags = THBF_DISABLED;
+ buttons[4].dwFlags = THBF_DISABLED;
+
+ m_pTaskbarList->SetOverlayIcon(m_hWnd, NULL, L"");
+ m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NOPROGRESS);
+ }
- SendMessage(WM_COMMAND, ID_VIEW_FULLSCREEN);
- break;
+ HRESULT hr = m_pTaskbarList->ThumbBarUpdateButtons(m_hWnd, ARRAYSIZE(buttons), buttons);
- default:
- break;
- }
- return 0;
- }
+ UpdateThumbnailClip();
- return __super::WindowProc(message, wParam, lParam);
+ return hr;
}
-UINT CMainFrame::OnPowerBroadcast(UINT nPowerEvent, UINT nEventData)
+HRESULT CMainFrame::UpdateThumbnailClip()
{
- static BOOL bWasPausedBeforeSuspention;
- OAFilterState mediaState;
-
- switch ( nPowerEvent ) {
- case PBT_APMSUSPEND: // System is suspending operation.
- TRACE("OnPowerBroadcast - suspending\n"); // For user tracking
+ if (!m_pTaskbarList) {
+ return E_FAIL;
+ }
- bWasPausedBeforeSuspention = FALSE; // Reset value
+ if ((!AfxGetAppSettings().fUseWin7TaskBar) || (m_iMediaLoadState != MLS_LOADED) || (m_fAudioOnly) || m_fFullScreen) {
+ return m_pTaskbarList->SetThumbnailClip(m_hWnd, NULL);
+ }
- mediaState = GetMediaState();
- if ( mediaState == State_Running ) {
- bWasPausedBeforeSuspention = TRUE;
- SendMessage( WM_COMMAND, ID_PLAY_PAUSE ); // Pause
- }
- break;
- case PBT_APMRESUMEAUTOMATIC: // Operation is resuming automatically from a low-power state. This message is sent every time the system resumes.
- TRACE("OnPowerBroadcast - resuming\n"); // For user tracking
+ RECT vid_rect, result_rect;
+ m_wndView.GetClientRect(&vid_rect);
- // Resume if we paused before suspension.
- if ( bWasPausedBeforeSuspention ) {
- SendMessage( WM_COMMAND, ID_PLAY_PLAY ); // Resume
- }
- break;
- }
+ // Remove the menu from thumbnail clip preview if it displayed
+ result_rect.left = 2;
+ result_rect.right = result_rect.left + (vid_rect.right - vid_rect.left) - 4;
+ result_rect.top = (AfxGetAppSettings().iCaptionMenuMode == MODE_SHOWCAPTIONMENU) ? 22 : 2;
+ result_rect.bottom = result_rect.top + (vid_rect.bottom - vid_rect.top) - 4;
- return __super::OnPowerBroadcast(nPowerEvent, nEventData);
+ return m_pTaskbarList->SetThumbnailClip(m_hWnd, &result_rect);
}
-#define NOTIFY_FOR_THIS_SESSION 0
+LRESULT CMainFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
+{
+ if ((message == WM_COMMAND) && (THBN_CLICKED == HIWORD(wParam))) {
+ int const wmId = LOWORD(wParam);
+ switch (wmId) {
+ case IDTB_BUTTON1:
+ SendMessage(WM_COMMAND, ID_PLAY_STOP);
+ break;
+
+ case IDTB_BUTTON2:
+ SendMessage(WM_COMMAND, ID_PLAY_PLAYPAUSE);
+ break;
+
+ case IDTB_BUTTON3:
+ SendMessage(WM_COMMAND, ID_NAVIGATE_SKIPBACK);
+ break;
+
+ case IDTB_BUTTON4:
+ SendMessage(WM_COMMAND, ID_NAVIGATE_SKIPFORWARD);
+ break;
+
+ case IDTB_BUTTON5:
+ WINDOWPLACEMENT wp;
+ GetWindowPlacement(&wp);
+ if (wp.showCmd == SW_SHOWMINIMIZED) {
+ SendMessage(WM_SYSCOMMAND, SC_RESTORE, -1);
+ }
+ SetForegroundWindow();
+
+ SendMessage(WM_COMMAND, ID_VIEW_FULLSCREEN);
+ break;
+
+ default:
+ break;
+ }
+ return 0;
+ }
-void CMainFrame::OnSessionChange(UINT nSessionState, UINT nId)
+ return __super::WindowProc(message, wParam, lParam);
+}
+
+UINT CMainFrame::OnPowerBroadcast(UINT nPowerEvent, UINT nEventData)
{
- static BOOL bWasPausedBeforeSessionChange;
+ static BOOL bWasPausedBeforeSuspention;
+ OAFilterState mediaState;
+
+ switch (nPowerEvent) {
+ case PBT_APMSUSPEND: // System is suspending operation.
+ TRACE("OnPowerBroadcast - suspending\n"); // For user tracking
+
+ bWasPausedBeforeSuspention = FALSE; // Reset value
+
+ mediaState = GetMediaState();
+ if (mediaState == State_Running) {
+ bWasPausedBeforeSuspention = TRUE;
+ SendMessage(WM_COMMAND, ID_PLAY_PAUSE); // Pause
+ }
+ break;
+ case PBT_APMRESUMEAUTOMATIC: // Operation is resuming automatically from a low-power state. This message is sent every time the system resumes.
+ TRACE("OnPowerBroadcast - resuming\n"); // For user tracking
+
+ // Resume if we paused before suspension.
+ if (bWasPausedBeforeSuspention) {
+ SendMessage(WM_COMMAND, ID_PLAY_PLAY); // Resume
+ }
+ break;
+ }
- switch (nSessionState)
- {
- case WTS_SESSION_LOCK:
- TRACE(_T("OnSessionChange - Lock session\n"));
+ return __super::OnPowerBroadcast(nPowerEvent, nEventData);
+}
- bWasPausedBeforeSessionChange = FALSE;
- if (GetMediaState() == State_Running && !m_fAudioOnly) {
- bWasPausedBeforeSessionChange = TRUE;
- SendMessage( WM_COMMAND, ID_PLAY_PAUSE );
- }
- break;
- case WTS_SESSION_UNLOCK:
- TRACE(_T("OnSessionChange - UnLock session\n"));
+#define NOTIFY_FOR_THIS_SESSION 0
- if (bWasPausedBeforeSessionChange) {
- SendMessage( WM_COMMAND, ID_PLAY_PLAY );
- }
- break;
- }
+void CMainFrame::OnSessionChange(UINT nSessionState, UINT nId)
+{
+ static BOOL bWasPausedBeforeSessionChange;
+
+ switch (nSessionState) {
+ case WTS_SESSION_LOCK:
+ TRACE(_T("OnSessionChange - Lock session\n"));
+
+ bWasPausedBeforeSessionChange = FALSE;
+ if (GetMediaState() == State_Running && !m_fAudioOnly) {
+ bWasPausedBeforeSessionChange = TRUE;
+ SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ }
+ break;
+ case WTS_SESSION_UNLOCK:
+ TRACE(_T("OnSessionChange - UnLock session\n"));
+
+ if (bWasPausedBeforeSessionChange) {
+ SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ }
+ break;
+ }
}
void CMainFrame::WTSRegisterSessionNotification()
{
- typedef BOOL (WINAPI *WTSREGISTERSESSIONNOTIFICATION)(HWND, DWORD);
- HINSTANCE hWtsLib = LoadLibrary( _T("wtsapi32.dll") );
+ typedef BOOL (WINAPI * WTSREGISTERSESSIONNOTIFICATION)(HWND, DWORD);
+ HINSTANCE hWtsLib = LoadLibrary(_T("wtsapi32.dll"));
- if ( hWtsLib )
- {
- WTSREGISTERSESSIONNOTIFICATION fnWtsRegisterSessionNotification;
+ if (hWtsLib) {
+ WTSREGISTERSESSIONNOTIFICATION fnWtsRegisterSessionNotification;
- fnWtsRegisterSessionNotification = (WTSREGISTERSESSIONNOTIFICATION)GetProcAddress(hWtsLib, "WTSRegisterSessionNotification");
+ fnWtsRegisterSessionNotification = (WTSREGISTERSESSIONNOTIFICATION)GetProcAddress(hWtsLib, "WTSRegisterSessionNotification");
- if ( fnWtsRegisterSessionNotification ) {
- fnWtsRegisterSessionNotification(m_hWnd, NOTIFY_FOR_THIS_SESSION);
- }
+ if (fnWtsRegisterSessionNotification) {
+ fnWtsRegisterSessionNotification(m_hWnd, NOTIFY_FOR_THIS_SESSION);
+ }
- FreeLibrary( hWtsLib );
- hWtsLib = NULL;
- }
+ FreeLibrary(hWtsLib);
+ hWtsLib = NULL;
+ }
}
void CMainFrame::WTSUnRegisterSessionNotification()
{
- typedef BOOL (WINAPI *WTSUNREGISTERSESSIONNOTIFICATION)(HWND);
- HINSTANCE hWtsLib = LoadLibrary( _T("wtsapi32.dll") );
+ typedef BOOL (WINAPI * WTSUNREGISTERSESSIONNOTIFICATION)(HWND);
+ HINSTANCE hWtsLib = LoadLibrary(_T("wtsapi32.dll"));
- if ( hWtsLib )
- {
- WTSUNREGISTERSESSIONNOTIFICATION fnWtsUnRegisterSessionNotification;
+ if (hWtsLib) {
+ WTSUNREGISTERSESSIONNOTIFICATION fnWtsUnRegisterSessionNotification;
- fnWtsUnRegisterSessionNotification = (WTSUNREGISTERSESSIONNOTIFICATION)GetProcAddress(hWtsLib, "WTSUnRegisterSessionNotification");
+ fnWtsUnRegisterSessionNotification = (WTSUNREGISTERSESSIONNOTIFICATION)GetProcAddress(hWtsLib, "WTSUnRegisterSessionNotification");
- if ( fnWtsUnRegisterSessionNotification ) {
- fnWtsUnRegisterSessionNotification( m_hWnd );
- }
+ if (fnWtsUnRegisterSessionNotification) {
+ fnWtsUnRegisterSessionNotification(m_hWnd);
+ }
- FreeLibrary( hWtsLib );
- hWtsLib = NULL;
- }
+ FreeLibrary(hWtsLib);
+ hWtsLib = NULL;
+ }
}
void CMainFrame::EnableShaders1(bool enable)
{
- if (enable && !m_shaderlabels.IsEmpty()) {
- m_bToggleShader = true;
- SetShaders();
- } else {
- m_bToggleShader = false;
- if (m_pCAP) {
- m_pCAP->SetPixelShader(NULL, NULL);
- }
- }
+ if (enable && !m_shaderlabels.IsEmpty()) {
+ m_bToggleShader = true;
+ SetShaders();
+ } else {
+ m_bToggleShader = false;
+ if (m_pCAP) {
+ m_pCAP->SetPixelShader(NULL, NULL);
+ }
+ }
}
void CMainFrame::EnableShaders2(bool enable)
{
- if (enable && !m_shaderlabelsScreenSpace.IsEmpty()) {
- m_bToggleShaderScreenSpace = true;
- SetShaders();
- } else {
- m_bToggleShaderScreenSpace = false;
- if (m_pCAP2) {
- m_pCAP2->SetPixelShader2(NULL, NULL, true);
- }
- }
+ if (enable && !m_shaderlabelsScreenSpace.IsEmpty()) {
+ m_bToggleShaderScreenSpace = true;
+ SetShaders();
+ } else {
+ m_bToggleShaderScreenSpace = false;
+ if (m_pCAP2) {
+ m_pCAP2->SetPixelShader2(NULL, NULL, true);
+ }
+ }
}
bool CMainFrame::OpenBD(CString Path)
{
- CHdmvClipInfo ClipInfo;
- CString strPlaylistFile;
- CAtlList<CHdmvClipInfo::PlaylistItem> MainPlaylist;
-
- m_LastOpenBDPath = Path;
-
- CString ext = CPath(Path).GetExtension();
- ext.MakeLower();
-
- if ((CPath(Path).IsDirectory() && Path.Find(_T("\\BDMV"))) || CPath(Path + _T("\\BDMV")).IsDirectory() || (!ext.IsEmpty() && ext == _T(".bdmv"))) {
- if (!ext.IsEmpty() && ext == _T(".bdmv")) {
- Path.Replace(_T("\\BDMV\\"), _T("\\"));
- CPath _Path(Path);
- _Path.RemoveFileSpec();
- Path = CString(_Path);
- } else if (Path.Find(_T("\\BDMV"))) {
- Path.Replace(_T("\\BDMV"), _T("\\"));
- }
- if (SUCCEEDED (ClipInfo.FindMainMovie (Path, strPlaylistFile, MainPlaylist, m_MPLSPlaylist))) {
- m_wndPlaylistBar.Empty();
- CAtlList<CString> sl;
- sl.AddTail(CString(strPlaylistFile));
- m_wndPlaylistBar.Append(sl, false);
- m_bIsBDPlay = true;
- OpenCurPlaylistItem();
- return true;
- }
- }
-
- m_LastOpenBDPath = _T("");
- return false;
+ CHdmvClipInfo ClipInfo;
+ CString strPlaylistFile;
+ CAtlList<CHdmvClipInfo::PlaylistItem> MainPlaylist;
+
+ m_LastOpenBDPath = Path;
+
+ CString ext = CPath(Path).GetExtension();
+ ext.MakeLower();
+
+ if ((CPath(Path).IsDirectory() && Path.Find(_T("\\BDMV"))) || CPath(Path + _T("\\BDMV")).IsDirectory() || (!ext.IsEmpty() && ext == _T(".bdmv"))) {
+ if (!ext.IsEmpty() && ext == _T(".bdmv")) {
+ Path.Replace(_T("\\BDMV\\"), _T("\\"));
+ CPath _Path(Path);
+ _Path.RemoveFileSpec();
+ Path = CString(_Path);
+ } else if (Path.Find(_T("\\BDMV"))) {
+ Path.Replace(_T("\\BDMV"), _T("\\"));
+ }
+ if (SUCCEEDED(ClipInfo.FindMainMovie(Path, strPlaylistFile, MainPlaylist, m_MPLSPlaylist))) {
+ m_wndPlaylistBar.Empty();
+ CAtlList<CString> sl;
+ sl.AddTail(CString(strPlaylistFile));
+ m_wndPlaylistBar.Append(sl, false);
+ m_bIsBDPlay = true;
+ OpenCurPlaylistItem();
+ return true;
+ }
+ }
+
+ m_LastOpenBDPath = _T("");
+ return false;
}
diff --git a/src/mpc-hc/MainFrm.h b/src/mpc-hc/MainFrm.h
index 35f8a8634..5d62f49bd 100644
--- a/src/mpc-hc/MainFrm.h
+++ b/src/mpc-hc/MainFrm.h
@@ -80,899 +80,899 @@ public IAMLine21Decoder {};
class OpenMediaData
{
public:
- // OpenMediaData() {}
- virtual ~OpenMediaData() {} // one virtual funct is needed to enable rtti
- CString title;
- CAtlList<CString> subs;
+ // OpenMediaData() {}
+ virtual ~OpenMediaData() {} // one virtual funct is needed to enable rtti
+ CString title;
+ CAtlList<CString> subs;
};
class OpenFileData : public OpenMediaData
{
public:
- OpenFileData() : rtStart(0) {}
- CAtlList<CString> fns;
- REFERENCE_TIME rtStart;
+ OpenFileData() : rtStart(0) {}
+ CAtlList<CString> fns;
+ REFERENCE_TIME rtStart;
};
class OpenDVDData : public OpenMediaData
{
public:
- // OpenDVDData() {}
- CString path;
- CComPtr<IDvdState> pDvdState;
+ // OpenDVDData() {}
+ CString path;
+ CComPtr<IDvdState> pDvdState;
};
class OpenDeviceData : public OpenMediaData
{
public:
- OpenDeviceData() {vinput = vchannel = ainput = -1;}
- CStringW DisplayName[2];
- int vinput, vchannel, ainput;
+ OpenDeviceData() {vinput = vchannel = ainput = -1;}
+ CStringW DisplayName[2];
+ int vinput, vchannel, ainput;
};
class TunerScanData
{
public :
- ULONG FrequencyStart;
- ULONG FrequencyStop;
- ULONG Bandwidth;
- LONG Offset;
- HWND Hwnd;
+ ULONG FrequencyStart;
+ ULONG FrequencyStop;
+ ULONG Bandwidth;
+ LONG Offset;
+ HWND Hwnd;
};
class CMainFrame;
class CGraphThread : public CWinThread
{
- CMainFrame* m_pMainFrame;
+ CMainFrame* m_pMainFrame;
- DECLARE_DYNCREATE(CGraphThread);
+ DECLARE_DYNCREATE(CGraphThread);
public:
- CGraphThread() : m_pMainFrame(NULL) {}
+ CGraphThread() : m_pMainFrame(NULL) {}
- void SetMainFrame(CMainFrame* pMainFrame) {m_pMainFrame = pMainFrame;}
+ void SetMainFrame(CMainFrame* pMainFrame) {m_pMainFrame = pMainFrame;}
- BOOL InitInstance();
- int ExitInstance();
+ BOOL InitInstance();
+ int ExitInstance();
- enum {TM_EXIT=WM_APP, TM_OPEN, TM_CLOSE, TM_RESET, TM_TUNER_SCAN, TM_DISPLAY_CHANGE};
- DECLARE_MESSAGE_MAP()
- afx_msg void OnExit(WPARAM wParam, LPARAM lParam);
- afx_msg void OnOpen(WPARAM wParam, LPARAM lParam);
- afx_msg void OnClose(WPARAM wParam, LPARAM lParam);
- afx_msg void OnReset(WPARAM wParam, LPARAM lParam);
- afx_msg void OnTunerScan(WPARAM wParam, LPARAM lParam);
- afx_msg void OnDisplayChange(WPARAM wParam, LPARAM lParam);
+ enum {TM_EXIT = WM_APP, TM_OPEN, TM_CLOSE, TM_RESET, TM_TUNER_SCAN, TM_DISPLAY_CHANGE};
+ DECLARE_MESSAGE_MAP()
+ afx_msg void OnExit(WPARAM wParam, LPARAM lParam);
+ afx_msg void OnOpen(WPARAM wParam, LPARAM lParam);
+ afx_msg void OnClose(WPARAM wParam, LPARAM lParam);
+ afx_msg void OnReset(WPARAM wParam, LPARAM lParam);
+ afx_msg void OnTunerScan(WPARAM wParam, LPARAM lParam);
+ afx_msg void OnDisplayChange(WPARAM wParam, LPARAM lParam);
};
/*
class CKeyFrameFinderThread : public CWinThread, public CCritSec
{
- DECLARE_DYNCREATE(CKeyFrameFinderThread);
+ DECLARE_DYNCREATE(CKeyFrameFinderThread);
public:
- CKeyFrameFinderThread() {}
+ CKeyFrameFinderThread() {}
- CUIntArray m_kfs; // protected by (CCritSec*)this
+ CUIntArray m_kfs; // protected by (CCritSec*)this
- BOOL InitInstance();
- int ExitInstance();
+ BOOL InitInstance();
+ int ExitInstance();
- enum {TM_EXIT=WM_APP, TM_INDEX, TM_BREAK};
- DECLARE_MESSAGE_MAP()
- afx_msg void OnExit(WPARAM wParam, LPARAM lParam);
- afx_msg void OnIndex(WPARAM wParam, LPARAM lParam);
- afx_msg void OnBreak(WPARAM wParam, LPARAM lParam);
+ enum {TM_EXIT=WM_APP, TM_INDEX, TM_BREAK};
+ DECLARE_MESSAGE_MAP()
+ afx_msg void OnExit(WPARAM wParam, LPARAM lParam);
+ afx_msg void OnIndex(WPARAM wParam, LPARAM lParam);
+ afx_msg void OnBreak(WPARAM wParam, LPARAM lParam);
};
*/
interface ISubClock;
class CMainFrame : public CFrameWnd, public CDropTarget
{
- enum {
- TIMER_STREAMPOSPOLLER = 1,
- TIMER_STREAMPOSPOLLER2,
- TIMER_FULLSCREENCONTROLBARHIDER,
- TIMER_FULLSCREENMOUSEHIDER,
- TIMER_STATS,
- TIMER_LEFTCLICK,
- TIMER_STATUSERASER
- };
- enum {
- SEEK_DIRECTION_NONE,
- SEEK_DIRECTION_BACKWARD,
- SEEK_DIRECTION_FORWARD
- };
-
- friend class CPPageFileInfoSheet;
- friend class CPPageLogo;
- friend class CSubtitleDlDlg;
-
- // TODO: wrap these graph objects into a class to make it look cleaner
-
- CComPtr<IGraphBuilder2> pGB;
- CComQIPtr<IMediaControl> pMC;
- CComQIPtr<IMediaEventEx> pME;
- CComQIPtr<IVideoWindow> pVW;
- CComQIPtr<IBasicVideo> pBV;
- CComQIPtr<IBasicAudio> pBA;
- CComQIPtr<IMediaSeeking> pMS;
- CComQIPtr<IVideoFrameStep> pFS;
- CComQIPtr<IQualProp, &IID_IQualProp> pQP;
- CComQIPtr<IBufferInfo> pBI;
- CComQIPtr<IAMOpenProgress> pAMOP;
-
- CComQIPtr<IDvdControl2> pDVDC;
- CComQIPtr<IDvdInfo2> pDVDI;
-
- CComPtr<ICaptureGraphBuilder2> pCGB;
- CStringW m_VidDispName, m_AudDispName;
- CComPtr<IBaseFilter> pVidCap, pAudCap;
- CComPtr<IAMVideoCompression> pAMVCCap, pAMVCPrev;
- CComPtr<IAMStreamConfig> pAMVSCCap, pAMVSCPrev, pAMASC;
- CComPtr<IAMCrossbar> pAMXBar;
- CComPtr<IAMTVTuner> pAMTuner;
- CComPtr<IAMDroppedFrames> pAMDF;
-
- CComPtr<ISubPicAllocatorPresenter> m_pCAP;
- CComPtr<ISubPicAllocatorPresenter2> m_pCAP2;
-
- void SetVolumeBoost(float fAudioBoost_dB);
- void SetBalance(int balance);
+ enum {
+ TIMER_STREAMPOSPOLLER = 1,
+ TIMER_STREAMPOSPOLLER2,
+ TIMER_FULLSCREENCONTROLBARHIDER,
+ TIMER_FULLSCREENMOUSEHIDER,
+ TIMER_STATS,
+ TIMER_LEFTCLICK,
+ TIMER_STATUSERASER
+ };
+ enum {
+ SEEK_DIRECTION_NONE,
+ SEEK_DIRECTION_BACKWARD,
+ SEEK_DIRECTION_FORWARD
+ };
+
+ friend class CPPageFileInfoSheet;
+ friend class CPPageLogo;
+ friend class CSubtitleDlDlg;
+
+ // TODO: wrap these graph objects into a class to make it look cleaner
+
+ CComPtr<IGraphBuilder2> pGB;
+ CComQIPtr<IMediaControl> pMC;
+ CComQIPtr<IMediaEventEx> pME;
+ CComQIPtr<IVideoWindow> pVW;
+ CComQIPtr<IBasicVideo> pBV;
+ CComQIPtr<IBasicAudio> pBA;
+ CComQIPtr<IMediaSeeking> pMS;
+ CComQIPtr<IVideoFrameStep> pFS;
+ CComQIPtr<IQualProp, &IID_IQualProp> pQP;
+ CComQIPtr<IBufferInfo> pBI;
+ CComQIPtr<IAMOpenProgress> pAMOP;
+
+ CComQIPtr<IDvdControl2> pDVDC;
+ CComQIPtr<IDvdInfo2> pDVDI;
+
+ CComPtr<ICaptureGraphBuilder2> pCGB;
+ CStringW m_VidDispName, m_AudDispName;
+ CComPtr<IBaseFilter> pVidCap, pAudCap;
+ CComPtr<IAMVideoCompression> pAMVCCap, pAMVCPrev;
+ CComPtr<IAMStreamConfig> pAMVSCCap, pAMVSCPrev, pAMASC;
+ CComPtr<IAMCrossbar> pAMXBar;
+ CComPtr<IAMTVTuner> pAMTuner;
+ CComPtr<IAMDroppedFrames> pAMDF;
+
+ CComPtr<ISubPicAllocatorPresenter> m_pCAP;
+ CComPtr<ISubPicAllocatorPresenter2> m_pCAP2;
+
+ void SetVolumeBoost(float fAudioBoost_dB);
+ void SetBalance(int balance);
- // subtitles
+ // subtitles
- CCritSec m_csSubLock;
- CInterfaceList<ISubStream> m_pSubStreams;
- CAtlList<int> m_iAudioStreams; // foxX uses this to keep a mapping of audio streams, in which they're ordered based by language user preference
- int m_iSubtitleSel; // if (m_iSubtitleSel&(1<<31)): disabled
- DWORD_PTR m_nSubtitleId;
+ CCritSec m_csSubLock;
+ CInterfaceList<ISubStream> m_pSubStreams;
+ CAtlList<int> m_iAudioStreams; // foxX uses this to keep a mapping of audio streams, in which they're ordered based by language user preference
+ int m_iSubtitleSel; // if (m_iSubtitleSel&(1<<31)): disabled
+ DWORD_PTR m_nSubtitleId;
- friend class CTextPassThruFilter;
+ friend class CTextPassThruFilter;
- // windowing
+ // windowing
- CRect m_lastWindowRect;
- CPoint m_lastMouseMove;
+ CRect m_lastWindowRect;
+ CPoint m_lastMouseMove;
- CRect m_rcDesktop;
+ CRect m_rcDesktop;
- void ShowControls(int nCS, bool fSave = false);
- void SetUIPreset(int iCaptionMenuMode, UINT nCS);
+ void ShowControls(int nCS, bool fSave = false);
+ void SetUIPreset(int iCaptionMenuMode, UINT nCS);
- void SetDefaultWindowRect(int iMonitor = 0);
- void SetDefaultFullscreenState();
- void RestoreDefaultWindowRect();
- void ZoomVideoWindow(bool snap = true, double scale = -1);
- double GetZoomAutoFitScale(bool bLargerOnly = false) const;
+ void SetDefaultWindowRect(int iMonitor = 0);
+ void SetDefaultFullscreenState();
+ void RestoreDefaultWindowRect();
+ void ZoomVideoWindow(bool snap = true, double scale = -1);
+ double GetZoomAutoFitScale(bool bLargerOnly = false) const;
- void SetAlwaysOnTop(int i);
+ void SetAlwaysOnTop(int i);
- // dynamic menus
+ // dynamic menus
- void SetupOpenCDSubMenu();
- void SetupFiltersSubMenu();
- void SetupAudioSwitcherSubMenu();
- void SetupSubtitlesSubMenu();
- void SetupNavAudioSubMenu();
- void SetupNavSubtitleSubMenu();
- void SetupNavAngleSubMenu();
- void SetupNavChaptersSubMenu();
- void SetupFavoritesSubMenu();
- void SetupShadersSubMenu();
- void SetupRecentFilesSubMenu();
- void SetupLanguageMenu();
+ void SetupOpenCDSubMenu();
+ void SetupFiltersSubMenu();
+ void SetupAudioSwitcherSubMenu();
+ void SetupSubtitlesSubMenu();
+ void SetupNavAudioSubMenu();
+ void SetupNavSubtitleSubMenu();
+ void SetupNavAngleSubMenu();
+ void SetupNavChaptersSubMenu();
+ void SetupFavoritesSubMenu();
+ void SetupShadersSubMenu();
+ void SetupRecentFilesSubMenu();
+ void SetupLanguageMenu();
- IBaseFilter* FindSourceSelectableFilter();
- void SetupNavStreamSelectSubMenu(CMenu* pSub, UINT id, DWORD dwSelGroup);
- void OnNavStreamSelectSubMenu(UINT id, DWORD dwSelGroup);
+ IBaseFilter* FindSourceSelectableFilter();
+ void SetupNavStreamSelectSubMenu(CMenu* pSub, UINT id, DWORD dwSelGroup);
+ void OnNavStreamSelectSubMenu(UINT id, DWORD dwSelGroup);
- CMenu m_popupmain, m_popup;
- CMenu m_opencds;
- CMenu m_filters, m_subtitles, m_audios;
- CMenu m_language;
- CAutoPtrArray<CMenu> m_filterpopups;
- CMenu m_navangle;
- CMenu m_navchapters;
- CMenu m_favorites;
- CMenu m_shaders;
- CMenu m_recentfiles;
+ CMenu m_popupmain, m_popup;
+ CMenu m_opencds;
+ CMenu m_filters, m_subtitles, m_audios;
+ CMenu m_language;
+ CAutoPtrArray<CMenu> m_filterpopups;
+ CMenu m_navangle;
+ CMenu m_navchapters;
+ CMenu m_favorites;
+ CMenu m_shaders;
+ CMenu m_recentfiles;
- CInterfaceArray<IUnknown, &IID_IUnknown> m_pparray;
- CInterfaceArray<IAMStreamSelect> m_ssarray;
+ CInterfaceArray<IUnknown, &IID_IUnknown> m_pparray;
+ CInterfaceArray<IAMStreamSelect> m_ssarray;
- // chapters (file mode)
- CComPtr<IDSMChapterBag> m_pCB;
- void SetupChapters();
+ // chapters (file mode)
+ CComPtr<IDSMChapterBag> m_pCB;
+ void SetupChapters();
- //
+ //
- void SetupIViAudReg();
+ void SetupIViAudReg();
- void AddTextPassThruFilter();
+ void AddTextPassThruFilter();
- int m_nLoops;
+ int m_nLoops;
- bool m_fCustomGraph;
- bool m_fRealMediaGraph, m_fShockwaveGraph, m_fQuicktimeGraph;
+ bool m_fCustomGraph;
+ bool m_fRealMediaGraph, m_fShockwaveGraph, m_fQuicktimeGraph;
- CComPtr<ISubClock> m_pSubClock;
+ CComPtr<ISubClock> m_pSubClock;
- int m_fFrameSteppingActive;
- int m_nStepForwardCount;
- REFERENCE_TIME m_rtStepForwardStart;
- int m_VolumeBeforeFrameStepping;
+ int m_fFrameSteppingActive;
+ int m_nStepForwardCount;
+ REFERENCE_TIME m_rtStepForwardStart;
+ int m_VolumeBeforeFrameStepping;
- bool m_fEndOfStream;
+ bool m_fEndOfStream;
- LARGE_INTEGER m_LastSaveTime;
+ LARGE_INTEGER m_LastSaveTime;
- bool m_fBuffering;
+ bool m_fBuffering;
- bool m_fLiveWM;
+ bool m_fLiveWM;
- bool m_fUpdateInfoBar;
+ bool m_fUpdateInfoBar;
- void SendStatusMessage(CString msg, int nTimeOut);
- CString m_playingmsg, m_closingmsg;
+ void SendStatusMessage(CString msg, int nTimeOut);
+ CString m_playingmsg, m_closingmsg;
- REFERENCE_TIME m_rtDurationOverride;
+ REFERENCE_TIME m_rtDurationOverride;
- CComPtr<IUnknown> m_pProv;
+ CComPtr<IUnknown> m_pProv;
- void CleanGraph();
+ void CleanGraph();
- CComPtr<IBaseFilter> pAudioDubSrc;
+ CComPtr<IBaseFilter> pAudioDubSrc;
- void ShowOptions(int idPage = 0);
+ void ShowOptions(int idPage = 0);
- bool GetDIB(BYTE** ppData, long& size, bool fSilent = false);
- void SaveDIB(LPCTSTR fn, BYTE* pData, long size);
- BOOL IsRendererCompatibleWithSaveImage();
- void SaveImage(LPCTSTR fn);
- void SaveThumbnails(LPCTSTR fn);
+ bool GetDIB(BYTE** ppData, long& size, bool fSilent = false);
+ void SaveDIB(LPCTSTR fn, BYTE* pData, long size);
+ BOOL IsRendererCompatibleWithSaveImage();
+ void SaveImage(LPCTSTR fn);
+ void SaveThumbnails(LPCTSTR fn);
- //
+ //
- friend class CWebClientSocket;
- friend class CWebServer;
- CAutoPtr<CWebServer> m_pWebServer;
- int m_iPlaybackMode;
- ULONG m_lCurrentChapter;
- ULONG m_lChapterStartTime;
+ friend class CWebClientSocket;
+ friend class CWebServer;
+ CAutoPtr<CWebServer> m_pWebServer;
+ int m_iPlaybackMode;
+ ULONG m_lCurrentChapter;
+ ULONG m_lChapterStartTime;
public:
- void StartWebServer(int nPort);
- void StopWebServer();
+ void StartWebServer(int nPort);
+ void StopWebServer();
- CString GetStatusMessage() const;
- int GetPlaybackMode() const {return m_iPlaybackMode;}
- void SetPlaybackMode(int iNewStatus);
- bool IsMuted() {return m_wndToolBar.GetVolume() == -10000;}
- int GetVolume() {return m_wndToolBar.m_volctrl.GetPos();}
+ CString GetStatusMessage() const;
+ int GetPlaybackMode() const {return m_iPlaybackMode;}
+ void SetPlaybackMode(int iNewStatus);
+ bool IsMuted() {return m_wndToolBar.GetVolume() == -10000;}
+ int GetVolume() {return m_wndToolBar.m_volctrl.GetPos();}
public:
- CMainFrame();
- DECLARE_DYNAMIC(CMainFrame)
+ CMainFrame();
+ DECLARE_DYNAMIC(CMainFrame)
- // Attributes
+ // Attributes
public:
- bool m_fFullScreen;
- bool m_fFirstFSAfterLaunchOnFS;
- bool m_fHideCursor;
- CMenu m_navaudio, m_navsubtitle;
-
- CComPtr<IBaseFilter> m_pRefClock; // Adjustable reference clock. GothSync
- CComPtr<ISyncClock> m_pSyncClock;
-
- bool IsFrameLessWindow() const {
- return (m_fFullScreen || AfxGetAppSettings().iCaptionMenuMode==MODE_BORDERLESS);
- }
- bool IsCaptionHidden() const {//If no caption, there is no menu bar. But if is no menu bar, then the caption can be.
- return (!m_fFullScreen && AfxGetAppSettings().iCaptionMenuMode>MODE_HIDEMENU);//!=MODE_SHOWCAPTIONMENU && !=MODE_HIDEMENU
- }
- bool IsMenuHidden() const {
- return (!m_fFullScreen && AfxGetAppSettings().iCaptionMenuMode!=MODE_SHOWCAPTIONMENU);
- }
- bool IsSomethingLoaded() const {
- return ((m_iMediaLoadState == MLS_LOADING || m_iMediaLoadState == MLS_LOADED) && !IsD3DFullScreenMode());
- }
- bool IsPlaylistEmpty() {
- return (m_wndPlaylistBar.GetCount() == 0);
- }
- bool IsInteractiveVideo() const {
- return (AfxGetAppSettings().fIntRealMedia && m_fRealMediaGraph || m_fShockwaveGraph);
- }
- bool IsD3DFullScreenMode() const;
-
- CControlBar* m_pLastBar;
+ bool m_fFullScreen;
+ bool m_fFirstFSAfterLaunchOnFS;
+ bool m_fHideCursor;
+ CMenu m_navaudio, m_navsubtitle;
+
+ CComPtr<IBaseFilter> m_pRefClock; // Adjustable reference clock. GothSync
+ CComPtr<ISyncClock> m_pSyncClock;
+
+ bool IsFrameLessWindow() const {
+ return (m_fFullScreen || AfxGetAppSettings().iCaptionMenuMode == MODE_BORDERLESS);
+ }
+ bool IsCaptionHidden() const {//If no caption, there is no menu bar. But if is no menu bar, then the caption can be.
+ return (!m_fFullScreen && AfxGetAppSettings().iCaptionMenuMode > MODE_HIDEMENU); //!=MODE_SHOWCAPTIONMENU && !=MODE_HIDEMENU
+ }
+ bool IsMenuHidden() const {
+ return (!m_fFullScreen && AfxGetAppSettings().iCaptionMenuMode != MODE_SHOWCAPTIONMENU);
+ }
+ bool IsSomethingLoaded() const {
+ return ((m_iMediaLoadState == MLS_LOADING || m_iMediaLoadState == MLS_LOADED) && !IsD3DFullScreenMode());
+ }
+ bool IsPlaylistEmpty() {
+ return (m_wndPlaylistBar.GetCount() == 0);
+ }
+ bool IsInteractiveVideo() const {
+ return (AfxGetAppSettings().fIntRealMedia && m_fRealMediaGraph || m_fShockwaveGraph);
+ }
+ bool IsD3DFullScreenMode() const;
+
+ CControlBar* m_pLastBar;
protected:
- int m_iMediaLoadState;
+ int m_iMediaLoadState;
- bool m_fClosingState;
+ bool m_fClosingState;
- bool m_fAudioOnly;
- dispmode m_dmBeforeFullscreen;
- CString m_LastOpenFile, m_LastOpenBDPath;
- HMONITOR m_LastWindow_HM;
+ bool m_fAudioOnly;
+ dispmode m_dmBeforeFullscreen;
+ CString m_LastOpenFile, m_LastOpenBDPath;
+ HMONITOR m_LastWindow_HM;
- DVD_DOMAIN m_iDVDDomain;
- DWORD m_iDVDTitle;
- int m_iSpeedLevel;
- double m_dSpeedRate;
+ DVD_DOMAIN m_iDVDDomain;
+ DWORD m_iDVDTitle;
+ int m_iSpeedLevel;
+ double m_dSpeedRate;
- double m_ZoomX, m_ZoomY, m_PosX, m_PosY;
- int m_AngleX, m_AngleY, m_AngleZ;
+ double m_ZoomX, m_ZoomY, m_PosX, m_PosY;
+ int m_AngleX, m_AngleY, m_AngleZ;
- // Operations
- bool OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD);
- void CloseMediaPrivate();
- void DoTunerScan(TunerScanData* pTSD);
+ // Operations
+ bool OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD);
+ void CloseMediaPrivate();
+ void DoTunerScan(TunerScanData* pTSD);
- void SendNowPlayingToMSN();
+ void SendNowPlayingToMSN();
- CWnd *GetModalParent();
+ CWnd* GetModalParent();
- void OpenCreateGraphObject(OpenMediaData* pOMD);
- void OpenFile(OpenFileData* pOFD);
- void OpenDVD(OpenDVDData* pODD);
- void OpenCapture(OpenDeviceData* pODD);
- HRESULT OpenBDAGraph();
- void OpenCustomizeGraph();
- void OpenSetupVideo();
- void OpenSetupAudio();
- void OpenSetupInfoBar();
- void OpenSetupStatsBar();
- void OpenSetupStatusBar();
- // void OpenSetupToolBar();
- void OpenSetupCaptureBar();
- void OpenSetupWindowTitle(CString fn = _T(""));
- void AutoChangeMonitorMode();
- double miFPS;
+ void OpenCreateGraphObject(OpenMediaData* pOMD);
+ void OpenFile(OpenFileData* pOFD);
+ void OpenDVD(OpenDVDData* pODD);
+ void OpenCapture(OpenDeviceData* pODD);
+ HRESULT OpenBDAGraph();
+ void OpenCustomizeGraph();
+ void OpenSetupVideo();
+ void OpenSetupAudio();
+ void OpenSetupInfoBar();
+ void OpenSetupStatsBar();
+ void OpenSetupStatusBar();
+ // void OpenSetupToolBar();
+ void OpenSetupCaptureBar();
+ void OpenSetupWindowTitle(CString fn = _T(""));
+ void AutoChangeMonitorMode();
+ double miFPS;
- bool GraphEventComplete();
+ bool GraphEventComplete();
- friend class CGraphThread;
- CGraphThread* m_pGraphThread;
- bool m_bOpenedThruThread;
+ friend class CGraphThread;
+ CGraphThread* m_pGraphThread;
+ bool m_bOpenedThruThread;
- CAtlArray<REFERENCE_TIME> m_kfs;
+ CAtlArray<REFERENCE_TIME> m_kfs;
- bool m_fOpeningAborted;
- bool m_bWasSnapped;
+ bool m_fOpeningAborted;
+ bool m_bWasSnapped;
public:
- void OpenCurPlaylistItem(REFERENCE_TIME rtStart = 0);
- void OpenMedia(CAutoPtr<OpenMediaData> pOMD);
- void PlayFavoriteFile(CString fav);
- void PlayFavoriteDVD(CString fav);
- bool ResetDevice();
- bool DisplayChange();
- void CloseMedia();
- void StartTunerScan(CAutoPtr<TunerScanData> pTSD);
- void StopTunerScan();
-
- void AddCurDevToPlaylist();
-
- bool m_fTrayIcon;
- void ShowTrayIcon(bool fShow);
- void SetTrayTip(CString str);
-
- CSize GetVideoSize() const;
- void ToggleFullscreen(bool fToNearest, bool fSwitchScreenResWhenHasTo);
- void MoveVideoWindow(bool fShowStats = false);
- void RepaintVideo();
- void HideVideoWindow(bool fHide);
-
- OAFilterState GetMediaState() const;
- REFERENCE_TIME GetPos() const;
- REFERENCE_TIME GetDur() const;
- void SeekTo(REFERENCE_TIME rt, bool fSeekToKeyFrame = false);
-
- // audio streams order functions
- void InsertAudioStream(const CComQIPtr<IAMStreamSelect> &pSS, int i);
- void SetupAudioStreams();
- // subtitle streams order function
- bool LoadSubtitle(CString fn, ISubStream **actualStream = NULL);
-
- void UpdateSubtitle(bool fDisplayMessage = false, bool fApplyDefStyle = false);
- void SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyle = false);
- void ReplaceSubtitle(ISubStream* pSubStreamOld, ISubStream* pSubStreamNew);
- void InvalidateSubtitle(DWORD_PTR nSubtitleId = -1, REFERENCE_TIME rtInvalidate = -1);
- void ReloadSubtitle();
-
- void SetAudioTrackIdx(int index);
- void SetSubtitleTrackIdx(int index);
-
- // shaders
- CAtlList<CString> m_shaderlabels;
- CAtlList<CString> m_shaderlabelsScreenSpace;
- void SetShaders();
- void UpdateShaders(CString label);
-
- // capturing
- bool m_fCapturing;
- HRESULT BuildCapture(IPin* pPin, IBaseFilter* pBF[3], const GUID& majortype, AM_MEDIA_TYPE* pmt); // pBF: 0 buff, 1 enc, 2 mux, pmt is for 1 enc
- bool BuildToCapturePreviewPin(
- IBaseFilter* pVidCap, IPin** pVidCapPin, IPin** pVidPrevPin,
- IBaseFilter* pAudCap, IPin** pAudCapPin, IPin** pAudPrevPin);
- bool BuildGraphVideoAudio(int fVPreview, bool fVCapture, int fAPreview, bool fACapture);
- bool DoCapture(), StartCapture(), StopCapture();
-
- bool DoAfterPlaybackEvent();
- void ParseDirs(CAtlList<CString>& sl);
- bool SearchInDir(bool bDirForward);
-
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
- virtual void RecalcLayout(BOOL bNotify = TRUE);
-
- // Dvb capture
- void DisplayCurrentChannelOSD();
- void DisplayCurrentChannelInfo();
-
- // Implementation
+ void OpenCurPlaylistItem(REFERENCE_TIME rtStart = 0);
+ void OpenMedia(CAutoPtr<OpenMediaData> pOMD);
+ void PlayFavoriteFile(CString fav);
+ void PlayFavoriteDVD(CString fav);
+ bool ResetDevice();
+ bool DisplayChange();
+ void CloseMedia();
+ void StartTunerScan(CAutoPtr<TunerScanData> pTSD);
+ void StopTunerScan();
+
+ void AddCurDevToPlaylist();
+
+ bool m_fTrayIcon;
+ void ShowTrayIcon(bool fShow);
+ void SetTrayTip(CString str);
+
+ CSize GetVideoSize() const;
+ void ToggleFullscreen(bool fToNearest, bool fSwitchScreenResWhenHasTo);
+ void MoveVideoWindow(bool fShowStats = false);
+ void RepaintVideo();
+ void HideVideoWindow(bool fHide);
+
+ OAFilterState GetMediaState() const;
+ REFERENCE_TIME GetPos() const;
+ REFERENCE_TIME GetDur() const;
+ void SeekTo(REFERENCE_TIME rt, bool fSeekToKeyFrame = false);
+
+ // audio streams order functions
+ void InsertAudioStream(const CComQIPtr<IAMStreamSelect>& pSS, int i);
+ void SetupAudioStreams();
+ // subtitle streams order function
+ bool LoadSubtitle(CString fn, ISubStream** actualStream = NULL);
+
+ void UpdateSubtitle(bool fDisplayMessage = false, bool fApplyDefStyle = false);
+ void SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyle = false);
+ void ReplaceSubtitle(ISubStream* pSubStreamOld, ISubStream* pSubStreamNew);
+ void InvalidateSubtitle(DWORD_PTR nSubtitleId = -1, REFERENCE_TIME rtInvalidate = -1);
+ void ReloadSubtitle();
+
+ void SetAudioTrackIdx(int index);
+ void SetSubtitleTrackIdx(int index);
+
+ // shaders
+ CAtlList<CString> m_shaderlabels;
+ CAtlList<CString> m_shaderlabelsScreenSpace;
+ void SetShaders();
+ void UpdateShaders(CString label);
+
+ // capturing
+ bool m_fCapturing;
+ HRESULT BuildCapture(IPin* pPin, IBaseFilter* pBF[3], const GUID& majortype, AM_MEDIA_TYPE* pmt); // pBF: 0 buff, 1 enc, 2 mux, pmt is for 1 enc
+ bool BuildToCapturePreviewPin(
+ IBaseFilter* pVidCap, IPin** pVidCapPin, IPin** pVidPrevPin,
+ IBaseFilter* pAudCap, IPin** pAudCapPin, IPin** pAudPrevPin);
+ bool BuildGraphVideoAudio(int fVPreview, bool fVCapture, int fAPreview, bool fACapture);
+ bool DoCapture(), StartCapture(), StopCapture();
+
+ bool DoAfterPlaybackEvent();
+ void ParseDirs(CAtlList<CString>& sl);
+ bool SearchInDir(bool bDirForward);
+
+ virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
+ virtual void RecalcLayout(BOOL bNotify = TRUE);
+
+ // Dvb capture
+ void DisplayCurrentChannelOSD();
+ void DisplayCurrentChannelInfo();
+
+ // Implementation
public:
- virtual ~CMainFrame();
+ virtual ~CMainFrame();
#ifdef _DEBUG
- virtual void AssertValid() const;
- virtual void Dump(CDumpContext& dc) const;
+ virtual void AssertValid() const;
+ virtual void Dump(CDumpContext& dc) const;
#endif
protected: // control bar embedded members
- CChildView m_wndView;
+ CChildView m_wndView;
- UINT m_nCS;
- CPlayerSeekBar m_wndSeekBar;
- CPlayerToolBar m_wndToolBar;
- CPlayerInfoBar m_wndInfoBar;
- CPlayerInfoBar m_wndStatsBar;
- CPlayerStatusBar m_wndStatusBar;
- CList<CControlBar*> m_bars;
+ UINT m_nCS;
+ CPlayerSeekBar m_wndSeekBar;
+ CPlayerToolBar m_wndToolBar;
+ CPlayerInfoBar m_wndInfoBar;
+ CPlayerInfoBar m_wndStatsBar;
+ CPlayerStatusBar m_wndStatusBar;
+ CList<CControlBar*> m_bars;
- CPlayerSubresyncBar m_wndSubresyncBar;
- CPlayerPlaylistBar m_wndPlaylistBar;
- CPlayerCaptureBar m_wndCaptureBar;
- CPlayerNavigationBar m_wndNavigationBar;
- CPlayerShaderEditorBar m_wndShaderEditorBar;
- CEditListEditor m_wndEditListEditor;
- CList<CSizingControlBar*> m_dockingbars;
+ CPlayerSubresyncBar m_wndSubresyncBar;
+ CPlayerPlaylistBar m_wndPlaylistBar;
+ CPlayerCaptureBar m_wndCaptureBar;
+ CPlayerNavigationBar m_wndNavigationBar;
+ CPlayerShaderEditorBar m_wndShaderEditorBar;
+ CEditListEditor m_wndEditListEditor;
+ CList<CSizingControlBar*> m_dockingbars;
- CFileDropTarget m_fileDropTarget;
- // TODO
- DROPEFFECT OnDragEnter(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
- DROPEFFECT OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
- BOOL OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point);
- DROPEFFECT OnDropEx(COleDataObject* pDataObject, DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint point);
- void OnDragLeave();
- DROPEFFECT OnDragScroll(DWORD dwKeyState, CPoint point);
+ CFileDropTarget m_fileDropTarget;
+ // TODO
+ DROPEFFECT OnDragEnter(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
+ DROPEFFECT OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
+ BOOL OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point);
+ DROPEFFECT OnDropEx(COleDataObject* pDataObject, DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint point);
+ void OnDragLeave();
+ DROPEFFECT OnDragScroll(DWORD dwKeyState, CPoint point);
- LPCTSTR GetRecentFile() const;
+ LPCTSTR GetRecentFile() const;
- friend class CPPagePlayback; // TODO
- friend class CPPageAudioSwitcher; // TODO
- friend class CMPlayerCApp; // TODO
+ friend class CPPagePlayback; // TODO
+ friend class CPPageAudioSwitcher; // TODO
+ friend class CMPlayerCApp; // TODO
- void RestoreControlBars();
- void SaveControlBars();
+ void RestoreControlBars();
+ void SaveControlBars();
- // Generated message map functions
+ // Generated message map functions
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
- afx_msg void OnDestroy();
-
- afx_msg LRESULT OnTaskBarRestart(WPARAM, LPARAM);
- afx_msg LRESULT OnNotifyIcon(WPARAM, LPARAM);
- afx_msg LRESULT OnTaskBarThumbnailsCreate(WPARAM, LPARAM);
-
- afx_msg void OnSetFocus(CWnd* pOldWnd);
- afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
- afx_msg void OnMove(int x, int y);
- afx_msg void OnMoving(UINT fwSide, LPRECT pRect);
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
- afx_msg void OnDisplayChange();
-
- afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
- afx_msg void OnActivateApp(BOOL bActive, DWORD dwThreadID);
- afx_msg LRESULT OnAppCommand(WPARAM wParam, LPARAM lParam);
- afx_msg void OnRawInput(UINT nInputcode, HRAWINPUT hRawInput);
-
- afx_msg LRESULT OnHotKey(WPARAM wParam, LPARAM lParam);
-
- afx_msg void OnTimer(UINT_PTR nIDEvent);
-
- afx_msg LRESULT OnGraphNotify(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnResetDevice(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnRepaintRenderLess(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnResumeFromState(WPARAM wParam, LPARAM lParam);
-
- BOOL OnButton(UINT id, UINT nFlags, CPoint point);
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
- afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
- afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
- afx_msg void OnMButtonDblClk(UINT nFlags, CPoint point);
- afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
- afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
- afx_msg LRESULT OnXButtonDown(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnXButtonUp(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnXButtonDblClk(WPARAM wParam, LPARAM lParam);
- afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
- afx_msg void OnMouseMove(UINT nFlags, CPoint point);
-
- afx_msg LRESULT OnNcHitTest(CPoint point);
-
- afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
-
- afx_msg void OnInitMenu(CMenu* pMenu);
- afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
- afx_msg void OnUnInitMenuPopup(CMenu* pPopupMenu, UINT nFlags);
-
- BOOL OnMenu(CMenu* pMenu);
- afx_msg void OnMenuPlayerShort();
- afx_msg void OnMenuPlayerLong();
- afx_msg void OnMenuFilters();
-
- afx_msg void OnUpdatePlayerStatus(CCmdUI* pCmdUI);
-
- afx_msg void OnFilePostOpenmedia();
- afx_msg void OnUpdateFilePostOpenmedia(CCmdUI* pCmdUI);
- afx_msg void OnFilePostClosemedia();
- afx_msg void OnUpdateFilePostClosemedia(CCmdUI* pCmdUI);
-
- afx_msg void OnBossKey();
-
- afx_msg void OnStreamAudio(UINT nID);
- afx_msg void OnStreamSub(UINT nID);
- afx_msg void OnStreamSubOnOff();
- afx_msg void OnOgmAudio(UINT nID);
- afx_msg void OnOgmSub(UINT nID);
- afx_msg void OnDvdAngle(UINT nID);
- afx_msg void OnDvdAudio(UINT nID);
- afx_msg void OnDvdSub(UINT nID);
- afx_msg void OnDvdSubOnOff();
-
-
- // menu item handlers
-
- afx_msg void OnFileOpenQuick();
- afx_msg void OnFileOpenmedia();
- afx_msg void OnUpdateFileOpen(CCmdUI* pCmdUI);
- afx_msg BOOL OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct);
- afx_msg void OnFileOpendvd();
- afx_msg void OnFileOpendevice();
- afx_msg void OnFileOpenCD(UINT nID);
- afx_msg void OnFileReopen();
- afx_msg void OnDropFiles(HDROP hDropInfo); // no menu item
- afx_msg void OnFileSaveAs();
- afx_msg void OnUpdateFileSaveAs(CCmdUI* pCmdUI);
- afx_msg void OnFileSaveImage();
- afx_msg void OnFileSaveImageAuto();
- afx_msg void OnUpdateFileSaveImage(CCmdUI* pCmdUI);
- afx_msg void OnFileSaveThumbnails();
- afx_msg void OnUpdateFileSaveThumbnails(CCmdUI* pCmdUI);
- afx_msg void OnFileLoadsubtitle();
- afx_msg void OnUpdateFileLoadsubtitle(CCmdUI* pCmdUI);
- afx_msg void OnFileSavesubtitle();
- afx_msg void OnUpdateFileSavesubtitle(CCmdUI* pCmdUI);
- afx_msg void OnFileISDBSearch();
- afx_msg void OnUpdateFileISDBSearch(CCmdUI* pCmdUI);
- afx_msg void OnFileISDBUpload();
- afx_msg void OnUpdateFileISDBUpload(CCmdUI* pCmdUI);
- afx_msg void OnFileISDBDownload();
- afx_msg void OnUpdateFileISDBDownload(CCmdUI* pCmdUI);
- afx_msg void OnFileProperties();
- afx_msg void OnUpdateFileProperties(CCmdUI* pCmdUI);
- afx_msg void OnFileClosePlaylist();
- afx_msg void OnFileCloseMedia(); // no menu item
- afx_msg void OnUpdateFileClose(CCmdUI* pCmdUI);
-
- afx_msg void OnViewCaptionmenu();
- afx_msg void OnViewNavigation();
- afx_msg void OnUpdateViewCaptionmenu(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewNavigation(CCmdUI* pCmdUI);
- afx_msg void OnViewControlBar(UINT nID);
- afx_msg void OnUpdateViewControlBar(CCmdUI* pCmdUI);
- afx_msg void OnViewSubresync();
- afx_msg void OnUpdateViewSubresync(CCmdUI* pCmdUI);
- afx_msg void OnViewPlaylist();
- afx_msg void OnUpdateViewPlaylist(CCmdUI* pCmdUI);
- afx_msg void OnViewEditListEditor();
- afx_msg void OnEDLIn();
- afx_msg void OnUpdateEDLIn(CCmdUI* pCmdUI);
- afx_msg void OnEDLOut();
- afx_msg void OnUpdateEDLOut(CCmdUI* pCmdUI);
- afx_msg void OnEDLNewClip();
- afx_msg void OnUpdateEDLNewClip(CCmdUI* pCmdUI);
- afx_msg void OnEDLSave();
- afx_msg void OnUpdateEDLSave(CCmdUI* pCmdUI);
- afx_msg void OnViewCapture();
- afx_msg void OnUpdateViewCapture(CCmdUI* pCmdUI);
- afx_msg void OnViewShaderEditor();
- afx_msg void OnUpdateViewShaderEditor(CCmdUI* pCmdUI);
- afx_msg void OnViewMinimal();
- afx_msg void OnUpdateViewMinimal(CCmdUI* pCmdUI);
- afx_msg void OnViewCompact();
- afx_msg void OnUpdateViewCompact(CCmdUI* pCmdUI);
- afx_msg void OnViewNormal();
- afx_msg void OnUpdateViewNormal(CCmdUI* pCmdUI);
- afx_msg void OnViewFullscreen();
- afx_msg void OnViewFullscreenSecondary();
- afx_msg void OnUpdateViewFullscreen(CCmdUI* pCmdUI);
- afx_msg void OnViewZoom(UINT nID);
- afx_msg void OnUpdateViewZoom(CCmdUI* pCmdUI);
- afx_msg void OnViewZoomAutoFit();
- afx_msg void OnViewZoomAutoFitLarger();
- afx_msg void OnViewDefaultVideoFrame(UINT nID);
- afx_msg void OnUpdateViewDefaultVideoFrame(CCmdUI* pCmdUI);
- afx_msg void OnViewSwitchVideoFrame();
- afx_msg void OnUpdateViewSwitchVideoFrame(CCmdUI* pCmdUI);
- afx_msg void OnViewKeepaspectratio();
- afx_msg void OnUpdateViewKeepaspectratio(CCmdUI* pCmdUI);
- afx_msg void OnViewCompMonDeskARDiff();
- afx_msg void OnUpdateViewCompMonDeskARDiff(CCmdUI* pCmdUI);
- afx_msg void OnViewPanNScan(UINT nID);
- afx_msg void OnUpdateViewPanNScan(CCmdUI* pCmdUI);
- afx_msg void OnViewPanNScanPresets(UINT nID);
- afx_msg void OnUpdateViewPanNScanPresets(CCmdUI* pCmdUI);
- afx_msg void OnViewRotate(UINT nID);
- afx_msg void OnUpdateViewRotate(CCmdUI* pCmdUI);
- afx_msg void OnViewAspectRatio(UINT nID);
- afx_msg void OnUpdateViewAspectRatio(CCmdUI* pCmdUI);
- afx_msg void OnViewAspectRatioNext();
- afx_msg void OnViewOntop(UINT nID);
- afx_msg void OnUpdateViewOntop(CCmdUI* pCmdUI);
- afx_msg void OnViewOptions();
- afx_msg void OnUpdateViewTearingTest(CCmdUI* pCmdUI);
- afx_msg void OnViewTearingTest();
- afx_msg void OnUpdateViewDisplayStats(CCmdUI* pCmdUI);
- afx_msg void OnViewResetStats();
- afx_msg void OnViewDisplayStatsSC();
- afx_msg void OnUpdateViewVSync(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewVSyncOffset(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewVSyncAccurate(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewFlushGPU(CCmdUI* pCmdUI);
-
- afx_msg void OnUpdateViewSynchronizeVideo(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewSynchronizeDisplay(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewSynchronizeNearest(CCmdUI* pCmdUI);
-
- afx_msg void OnUpdateViewD3DFullscreen(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewDisableDesktopComposition(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewAlternativeVSync(CCmdUI* pCmdUI);
-
- afx_msg void OnUpdateViewColorManagementEnable(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewColorManagementInput(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewColorManagementAmbientLight(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewColorManagementIntent(CCmdUI* pCmdUI);
-
- afx_msg void OnUpdateViewEVROutputRange(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewFullscreenGUISupport(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewHighColorResolution(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewForceInputHighColorResolution(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewFullFloatingPointProcessing(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewHalfFloatingPointProcessing(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewEnableFrameTimeCorrection(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewVSyncOffsetIncrease(CCmdUI* pCmdUI);
- afx_msg void OnUpdateViewVSyncOffsetDecrease(CCmdUI* pCmdUI);
- afx_msg void OnViewVSync();
- afx_msg void OnViewVSyncAccurate();
-
- afx_msg void OnViewSynchronizeVideo();
- afx_msg void OnViewSynchronizeDisplay();
- afx_msg void OnViewSynchronizeNearest();
-
- afx_msg void OnViewColorManagementEnable();
- afx_msg void OnViewColorManagementInputAuto();
- afx_msg void OnViewColorManagementInputHDTV();
- afx_msg void OnViewColorManagementInputSDTV_NTSC();
- afx_msg void OnViewColorManagementInputSDTV_PAL();
- afx_msg void OnViewColorManagementAmbientLightBright();
- afx_msg void OnViewColorManagementAmbientLightDim();
- afx_msg void OnViewColorManagementAmbientLightDark();
- afx_msg void OnViewColorManagementIntentPerceptual();
- afx_msg void OnViewColorManagementIntentRelativeColorimetric();
- afx_msg void OnViewColorManagementIntentSaturation();
- afx_msg void OnViewColorManagementIntentAbsoluteColorimetric();
-
- afx_msg void OnViewEVROutputRange_0_255();
- afx_msg void OnViewEVROutputRange_16_235();
-
- afx_msg void OnViewFlushGPUBeforeVSync();
- afx_msg void OnViewFlushGPUAfterVSync();
- afx_msg void OnViewFlushGPUWait();
-
- afx_msg void OnViewD3DFullScreen();
- afx_msg void OnViewDisableDesktopComposition();
- afx_msg void OnViewAlternativeVSync();
- afx_msg void OnViewResetDefault();
- afx_msg void OnViewResetOptimal();
-
- afx_msg void OnViewFullscreenGUISupport();
- afx_msg void OnViewHighColorResolution();
- afx_msg void OnViewForceInputHighColorResolution();
- afx_msg void OnViewFullFloatingPointProcessing();
- afx_msg void OnViewHalfFloatingPointProcessing();
- afx_msg void OnViewEnableFrameTimeCorrection();
- afx_msg void OnViewVSyncOffsetIncrease();
- afx_msg void OnViewVSyncOffsetDecrease();
- afx_msg void OnUpdateShaderToggle(CCmdUI* pCmdUI);
- afx_msg void OnUpdateShaderToggleScreenSpace(CCmdUI* pCmdUI);
- afx_msg void OnShaderToggle();
- afx_msg void OnShaderToggleScreenSpace();
- afx_msg void OnUpdateViewRemainingTime(CCmdUI* pCmdUI);
- afx_msg void OnViewRemainingTime();
- afx_msg void OnD3DFullscreenToggle();
- afx_msg void OnGotoSubtitle(UINT nID);
- afx_msg void OnShiftSubtitle(UINT nID);
- afx_msg void OnSubtitleDelay(UINT nID);
-
-
- afx_msg void OnPlayPlay();
- afx_msg void OnPlayPause();
- afx_msg void OnPlayPauseI();
- afx_msg void OnPlayPlaypause();
- afx_msg void OnPlayStop();
- afx_msg void OnUpdatePlayPauseStop(CCmdUI* pCmdUI);
- afx_msg void OnPlayFramestep(UINT nID);
- afx_msg void OnUpdatePlayFramestep(CCmdUI* pCmdUI);
- afx_msg void OnPlaySeek(UINT nID);
- afx_msg void OnPlaySeekKey(UINT nID); // no menu item
- afx_msg void OnUpdatePlaySeek(CCmdUI* pCmdUI);
- afx_msg void OnPlayGoto();
- afx_msg void OnUpdateGoto(CCmdUI* pCmdUI);
- afx_msg void OnPlayChangeRate(UINT nID);
- afx_msg void OnUpdatePlayChangeRate(CCmdUI* pCmdUI);
- afx_msg void OnPlayResetRate();
- afx_msg void OnUpdatePlayResetRate(CCmdUI* pCmdUI);
- afx_msg void OnPlayChangeAudDelay(UINT nID);
- afx_msg void OnUpdatePlayChangeAudDelay(CCmdUI* pCmdUI);
- afx_msg void OnPlayFilters(UINT nID);
- afx_msg void OnUpdatePlayFilters(CCmdUI* pCmdUI);
- afx_msg void OnPlayShaders(UINT nID);
- afx_msg void OnPlayAudio(UINT nID);
- afx_msg void OnUpdatePlayAudio(CCmdUI* pCmdUI);
- afx_msg void OnPlaySubtitles(UINT nID);
- afx_msg void OnUpdatePlaySubtitles(CCmdUI* pCmdUI);
- afx_msg void OnPlayLanguage(UINT nID);
- afx_msg void OnUpdatePlayLanguage(CCmdUI* pCmdUI);
- afx_msg void OnPlayVolume(UINT nID);
- afx_msg void OnPlayVolumeBoost(UINT nID);
- afx_msg void OnUpdatePlayVolumeBoost(CCmdUI* pCmdUI);
- afx_msg void OnCustomChannelMapping();
- afx_msg void OnUpdateCustomChannelMapping(CCmdUI* pCmdUI);
- afx_msg void OnNormalizeRegainVolume(UINT nID);
- afx_msg void OnUpdateNormalizeRegainVolume(CCmdUI* pCmdUI);
- afx_msg void OnPlayColor(UINT nID);
- afx_msg void OnAfterplayback(UINT nID);
- afx_msg void OnUpdateAfterplayback(CCmdUI* pCmdUI);
-
- afx_msg void OnNavigateSkip(UINT nID);
- afx_msg void OnUpdateNavigateSkip(CCmdUI* pCmdUI);
- afx_msg void OnNavigateSkipFile(UINT nID);
- afx_msg void OnUpdateNavigateSkipFile(CCmdUI* pCmdUI);
- afx_msg void OnNavigateMenu(UINT nID);
- afx_msg void OnUpdateNavigateMenu(CCmdUI* pCmdUI);
- afx_msg void OnNavigateAudio(UINT nID);
- afx_msg void OnNavigateSubpic(UINT nID);
- afx_msg void OnNavigateAngle(UINT nID);
- afx_msg void OnNavigateChapters(UINT nID);
- afx_msg void OnNavigateMenuItem(UINT nID);
- afx_msg void OnUpdateNavigateMenuItem(CCmdUI* pCmdUI);
- afx_msg void OnTunerScan();
- afx_msg void OnUpdateTunerScan(CCmdUI* pCmdUI);
-
- afx_msg void OnFavoritesAdd();
- afx_msg void OnUpdateFavoritesAdd(CCmdUI* pCmdUI);
- afx_msg void OnFavoritesQuickAddFavorite();
- afx_msg void OnFavoritesOrganize();
- afx_msg void OnUpdateFavoritesOrganize(CCmdUI* pCmdUI);
- afx_msg void OnFavoritesFile(UINT nID);
- afx_msg void OnUpdateFavoritesFile(CCmdUI* pCmdUI);
- afx_msg void OnFavoritesDVD(UINT nID);
- afx_msg void OnUpdateFavoritesDVD(CCmdUI* pCmdUI);
- afx_msg void OnFavoritesDevice(UINT nID);
- afx_msg void OnUpdateFavoritesDevice(CCmdUI* pCmdUI);
- afx_msg void OnRecentFileClear();
- afx_msg void OnUpdateRecentFileClear(CCmdUI* pCmdUI);
- afx_msg void OnRecentFile(UINT nID);
- afx_msg void OnUpdateRecentFile(CCmdUI* pCmdUI);
-
-
- afx_msg void OnHelpHomepage();
- afx_msg void OnHelpCheckForUpdate();
- //afx_msg void OnHelpDocumentation();
- afx_msg void OnHelpToolbarImages();
- afx_msg void OnHelpDonate();
-
- afx_msg void OnClose();
-
- afx_msg void OnLanguage(UINT nID);
- afx_msg void OnUpdateLanguage(CCmdUI* pCmdUI);
-
- //CMPC_Lcd m_Lcd;
-
- // ==== Added by CASIMIR666
- CWnd* m_pVideoWnd; // Current Video (main display screen or 2nd)
- SIZE m_fullWndSize;
- CFullscreenWnd* m_pFullscreenWnd;
- CComPtr<IVMRMixerControl9> m_pMC;
- CComPtr<IMFVideoDisplayControl> m_pMFVDC;
- CComPtr<IMFVideoProcessor> m_pMFVP;
- CComPtr<IAMLine21Decoder_2> m_pLN21;
- CVMROSD m_OSD;
- bool m_OpenFile;
- bool m_bRemainingTime;
- int m_nCurSubtitle;
- long m_lSubtitleShift;
- __int64 m_rtCurSubPos;
- CString m_strTitle;
- bool m_bToggleShader;
- bool m_bToggleShaderScreenSpace;
- bool m_bInOptions;
- bool m_bStopTunerScan;
-
- void SetLoadState(MPC_LOADSTATE iState);
- void SetPlayState(MPC_PLAYSTATE iState);
- bool CreateFullScreenWindow();
- void SetupEVRColorControl();
- void SetColorControl(DWORD flags, int& brightness, int& contrast, int& hue, int& saturation);
- void SetClosedCaptions(bool enable);
- LPCTSTR GetDVDAudioFormatName (DVD_AudioAttributes& ATR) const;
- void SetAudioDelay(REFERENCE_TIME rtShift);
- void SetSubtitleDelay(int delay_ms);
- //void AutoSelectTracks();
- bool IsRealEngineCompatible(CString strFilename) const;
- void SetTimersPlay();
- void KillTimersStop();
-
-
- // MPC API functions
- void ProcessAPICommand(COPYDATASTRUCT* pCDS);
- void SendAPICommand (MPCAPI_COMMAND nCommand, LPCWSTR fmt, ...);
- void SendNowPlayingToApi();
- void SendSubtitleTracksToApi();
- void SendAudioTracksToApi();
- void SendPlaylistToApi();
- afx_msg void OnFileOpendirectory();
-
- void SendCurrentPositionToApi(bool fNotifySeek = false);
- void ShowOSDCustomMessageApi(MPC_OSDDATA *osdData);
- void JumpOfNSeconds(int seconds);
-
- CString GetVidPos() const;
-
- ITaskbarList3* m_pTaskbarList;
- HRESULT CreateThumbnailToolbar();
- HRESULT UpdateThumbarButton();
- HRESULT UpdateThumbnailClip();
+ afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
+ afx_msg void OnDestroy();
+
+ afx_msg LRESULT OnTaskBarRestart(WPARAM, LPARAM);
+ afx_msg LRESULT OnNotifyIcon(WPARAM, LPARAM);
+ afx_msg LRESULT OnTaskBarThumbnailsCreate(WPARAM, LPARAM);
+
+ afx_msg void OnSetFocus(CWnd* pOldWnd);
+ afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
+ afx_msg void OnMove(int x, int y);
+ afx_msg void OnMoving(UINT fwSide, LPRECT pRect);
+ afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
+ afx_msg void OnDisplayChange();
+
+ afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
+ afx_msg void OnActivateApp(BOOL bActive, DWORD dwThreadID);
+ afx_msg LRESULT OnAppCommand(WPARAM wParam, LPARAM lParam);
+ afx_msg void OnRawInput(UINT nInputcode, HRAWINPUT hRawInput);
+
+ afx_msg LRESULT OnHotKey(WPARAM wParam, LPARAM lParam);
+
+ afx_msg void OnTimer(UINT_PTR nIDEvent);
+
+ afx_msg LRESULT OnGraphNotify(WPARAM wParam, LPARAM lParam);
+ afx_msg LRESULT OnResetDevice(WPARAM wParam, LPARAM lParam);
+ afx_msg LRESULT OnRepaintRenderLess(WPARAM wParam, LPARAM lParam);
+ afx_msg LRESULT OnResumeFromState(WPARAM wParam, LPARAM lParam);
+
+ BOOL OnButton(UINT id, UINT nFlags, CPoint point);
+ afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
+ afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
+ afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
+ afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
+ afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
+ afx_msg void OnMButtonDblClk(UINT nFlags, CPoint point);
+ afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
+ afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
+ afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
+ afx_msg LRESULT OnXButtonDown(WPARAM wParam, LPARAM lParam);
+ afx_msg LRESULT OnXButtonUp(WPARAM wParam, LPARAM lParam);
+ afx_msg LRESULT OnXButtonDblClk(WPARAM wParam, LPARAM lParam);
+ afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
+ afx_msg void OnMouseMove(UINT nFlags, CPoint point);
+
+ afx_msg LRESULT OnNcHitTest(CPoint point);
+
+ afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
+
+ afx_msg void OnInitMenu(CMenu* pMenu);
+ afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
+ afx_msg void OnUnInitMenuPopup(CMenu* pPopupMenu, UINT nFlags);
+
+ BOOL OnMenu(CMenu* pMenu);
+ afx_msg void OnMenuPlayerShort();
+ afx_msg void OnMenuPlayerLong();
+ afx_msg void OnMenuFilters();
+
+ afx_msg void OnUpdatePlayerStatus(CCmdUI* pCmdUI);
+
+ afx_msg void OnFilePostOpenmedia();
+ afx_msg void OnUpdateFilePostOpenmedia(CCmdUI* pCmdUI);
+ afx_msg void OnFilePostClosemedia();
+ afx_msg void OnUpdateFilePostClosemedia(CCmdUI* pCmdUI);
+
+ afx_msg void OnBossKey();
+
+ afx_msg void OnStreamAudio(UINT nID);
+ afx_msg void OnStreamSub(UINT nID);
+ afx_msg void OnStreamSubOnOff();
+ afx_msg void OnOgmAudio(UINT nID);
+ afx_msg void OnOgmSub(UINT nID);
+ afx_msg void OnDvdAngle(UINT nID);
+ afx_msg void OnDvdAudio(UINT nID);
+ afx_msg void OnDvdSub(UINT nID);
+ afx_msg void OnDvdSubOnOff();
+
+
+ // menu item handlers
+
+ afx_msg void OnFileOpenQuick();
+ afx_msg void OnFileOpenmedia();
+ afx_msg void OnUpdateFileOpen(CCmdUI* pCmdUI);
+ afx_msg BOOL OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct);
+ afx_msg void OnFileOpendvd();
+ afx_msg void OnFileOpendevice();
+ afx_msg void OnFileOpenCD(UINT nID);
+ afx_msg void OnFileReopen();
+ afx_msg void OnDropFiles(HDROP hDropInfo); // no menu item
+ afx_msg void OnFileSaveAs();
+ afx_msg void OnUpdateFileSaveAs(CCmdUI* pCmdUI);
+ afx_msg void OnFileSaveImage();
+ afx_msg void OnFileSaveImageAuto();
+ afx_msg void OnUpdateFileSaveImage(CCmdUI* pCmdUI);
+ afx_msg void OnFileSaveThumbnails();
+ afx_msg void OnUpdateFileSaveThumbnails(CCmdUI* pCmdUI);
+ afx_msg void OnFileLoadsubtitle();
+ afx_msg void OnUpdateFileLoadsubtitle(CCmdUI* pCmdUI);
+ afx_msg void OnFileSavesubtitle();
+ afx_msg void OnUpdateFileSavesubtitle(CCmdUI* pCmdUI);
+ afx_msg void OnFileISDBSearch();
+ afx_msg void OnUpdateFileISDBSearch(CCmdUI* pCmdUI);
+ afx_msg void OnFileISDBUpload();
+ afx_msg void OnUpdateFileISDBUpload(CCmdUI* pCmdUI);
+ afx_msg void OnFileISDBDownload();
+ afx_msg void OnUpdateFileISDBDownload(CCmdUI* pCmdUI);
+ afx_msg void OnFileProperties();
+ afx_msg void OnUpdateFileProperties(CCmdUI* pCmdUI);
+ afx_msg void OnFileClosePlaylist();
+ afx_msg void OnFileCloseMedia(); // no menu item
+ afx_msg void OnUpdateFileClose(CCmdUI* pCmdUI);
+
+ afx_msg void OnViewCaptionmenu();
+ afx_msg void OnViewNavigation();
+ afx_msg void OnUpdateViewCaptionmenu(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewNavigation(CCmdUI* pCmdUI);
+ afx_msg void OnViewControlBar(UINT nID);
+ afx_msg void OnUpdateViewControlBar(CCmdUI* pCmdUI);
+ afx_msg void OnViewSubresync();
+ afx_msg void OnUpdateViewSubresync(CCmdUI* pCmdUI);
+ afx_msg void OnViewPlaylist();
+ afx_msg void OnUpdateViewPlaylist(CCmdUI* pCmdUI);
+ afx_msg void OnViewEditListEditor();
+ afx_msg void OnEDLIn();
+ afx_msg void OnUpdateEDLIn(CCmdUI* pCmdUI);
+ afx_msg void OnEDLOut();
+ afx_msg void OnUpdateEDLOut(CCmdUI* pCmdUI);
+ afx_msg void OnEDLNewClip();
+ afx_msg void OnUpdateEDLNewClip(CCmdUI* pCmdUI);
+ afx_msg void OnEDLSave();
+ afx_msg void OnUpdateEDLSave(CCmdUI* pCmdUI);
+ afx_msg void OnViewCapture();
+ afx_msg void OnUpdateViewCapture(CCmdUI* pCmdUI);
+ afx_msg void OnViewShaderEditor();
+ afx_msg void OnUpdateViewShaderEditor(CCmdUI* pCmdUI);
+ afx_msg void OnViewMinimal();
+ afx_msg void OnUpdateViewMinimal(CCmdUI* pCmdUI);
+ afx_msg void OnViewCompact();
+ afx_msg void OnUpdateViewCompact(CCmdUI* pCmdUI);
+ afx_msg void OnViewNormal();
+ afx_msg void OnUpdateViewNormal(CCmdUI* pCmdUI);
+ afx_msg void OnViewFullscreen();
+ afx_msg void OnViewFullscreenSecondary();
+ afx_msg void OnUpdateViewFullscreen(CCmdUI* pCmdUI);
+ afx_msg void OnViewZoom(UINT nID);
+ afx_msg void OnUpdateViewZoom(CCmdUI* pCmdUI);
+ afx_msg void OnViewZoomAutoFit();
+ afx_msg void OnViewZoomAutoFitLarger();
+ afx_msg void OnViewDefaultVideoFrame(UINT nID);
+ afx_msg void OnUpdateViewDefaultVideoFrame(CCmdUI* pCmdUI);
+ afx_msg void OnViewSwitchVideoFrame();
+ afx_msg void OnUpdateViewSwitchVideoFrame(CCmdUI* pCmdUI);
+ afx_msg void OnViewKeepaspectratio();
+ afx_msg void OnUpdateViewKeepaspectratio(CCmdUI* pCmdUI);
+ afx_msg void OnViewCompMonDeskARDiff();
+ afx_msg void OnUpdateViewCompMonDeskARDiff(CCmdUI* pCmdUI);
+ afx_msg void OnViewPanNScan(UINT nID);
+ afx_msg void OnUpdateViewPanNScan(CCmdUI* pCmdUI);
+ afx_msg void OnViewPanNScanPresets(UINT nID);
+ afx_msg void OnUpdateViewPanNScanPresets(CCmdUI* pCmdUI);
+ afx_msg void OnViewRotate(UINT nID);
+ afx_msg void OnUpdateViewRotate(CCmdUI* pCmdUI);
+ afx_msg void OnViewAspectRatio(UINT nID);
+ afx_msg void OnUpdateViewAspectRatio(CCmdUI* pCmdUI);
+ afx_msg void OnViewAspectRatioNext();
+ afx_msg void OnViewOntop(UINT nID);
+ afx_msg void OnUpdateViewOntop(CCmdUI* pCmdUI);
+ afx_msg void OnViewOptions();
+ afx_msg void OnUpdateViewTearingTest(CCmdUI* pCmdUI);
+ afx_msg void OnViewTearingTest();
+ afx_msg void OnUpdateViewDisplayStats(CCmdUI* pCmdUI);
+ afx_msg void OnViewResetStats();
+ afx_msg void OnViewDisplayStatsSC();
+ afx_msg void OnUpdateViewVSync(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewVSyncOffset(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewVSyncAccurate(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewFlushGPU(CCmdUI* pCmdUI);
+
+ afx_msg void OnUpdateViewSynchronizeVideo(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewSynchronizeDisplay(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewSynchronizeNearest(CCmdUI* pCmdUI);
+
+ afx_msg void OnUpdateViewD3DFullscreen(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewDisableDesktopComposition(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewAlternativeVSync(CCmdUI* pCmdUI);
+
+ afx_msg void OnUpdateViewColorManagementEnable(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewColorManagementInput(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewColorManagementAmbientLight(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewColorManagementIntent(CCmdUI* pCmdUI);
+
+ afx_msg void OnUpdateViewEVROutputRange(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewFullscreenGUISupport(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewHighColorResolution(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewForceInputHighColorResolution(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewFullFloatingPointProcessing(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewHalfFloatingPointProcessing(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewEnableFrameTimeCorrection(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewVSyncOffsetIncrease(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateViewVSyncOffsetDecrease(CCmdUI* pCmdUI);
+ afx_msg void OnViewVSync();
+ afx_msg void OnViewVSyncAccurate();
+
+ afx_msg void OnViewSynchronizeVideo();
+ afx_msg void OnViewSynchronizeDisplay();
+ afx_msg void OnViewSynchronizeNearest();
+
+ afx_msg void OnViewColorManagementEnable();
+ afx_msg void OnViewColorManagementInputAuto();
+ afx_msg void OnViewColorManagementInputHDTV();
+ afx_msg void OnViewColorManagementInputSDTV_NTSC();
+ afx_msg void OnViewColorManagementInputSDTV_PAL();
+ afx_msg void OnViewColorManagementAmbientLightBright();
+ afx_msg void OnViewColorManagementAmbientLightDim();
+ afx_msg void OnViewColorManagementAmbientLightDark();
+ afx_msg void OnViewColorManagementIntentPerceptual();
+ afx_msg void OnViewColorManagementIntentRelativeColorimetric();
+ afx_msg void OnViewColorManagementIntentSaturation();
+ afx_msg void OnViewColorManagementIntentAbsoluteColorimetric();
+
+ afx_msg void OnViewEVROutputRange_0_255();
+ afx_msg void OnViewEVROutputRange_16_235();
+
+ afx_msg void OnViewFlushGPUBeforeVSync();
+ afx_msg void OnViewFlushGPUAfterVSync();
+ afx_msg void OnViewFlushGPUWait();
+
+ afx_msg void OnViewD3DFullScreen();
+ afx_msg void OnViewDisableDesktopComposition();
+ afx_msg void OnViewAlternativeVSync();
+ afx_msg void OnViewResetDefault();
+ afx_msg void OnViewResetOptimal();
+
+ afx_msg void OnViewFullscreenGUISupport();
+ afx_msg void OnViewHighColorResolution();
+ afx_msg void OnViewForceInputHighColorResolution();
+ afx_msg void OnViewFullFloatingPointProcessing();
+ afx_msg void OnViewHalfFloatingPointProcessing();
+ afx_msg void OnViewEnableFrameTimeCorrection();
+ afx_msg void OnViewVSyncOffsetIncrease();
+ afx_msg void OnViewVSyncOffsetDecrease();
+ afx_msg void OnUpdateShaderToggle(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateShaderToggleScreenSpace(CCmdUI* pCmdUI);
+ afx_msg void OnShaderToggle();
+ afx_msg void OnShaderToggleScreenSpace();
+ afx_msg void OnUpdateViewRemainingTime(CCmdUI* pCmdUI);
+ afx_msg void OnViewRemainingTime();
+ afx_msg void OnD3DFullscreenToggle();
+ afx_msg void OnGotoSubtitle(UINT nID);
+ afx_msg void OnShiftSubtitle(UINT nID);
+ afx_msg void OnSubtitleDelay(UINT nID);
+
+
+ afx_msg void OnPlayPlay();
+ afx_msg void OnPlayPause();
+ afx_msg void OnPlayPauseI();
+ afx_msg void OnPlayPlaypause();
+ afx_msg void OnPlayStop();
+ afx_msg void OnUpdatePlayPauseStop(CCmdUI* pCmdUI);
+ afx_msg void OnPlayFramestep(UINT nID);
+ afx_msg void OnUpdatePlayFramestep(CCmdUI* pCmdUI);
+ afx_msg void OnPlaySeek(UINT nID);
+ afx_msg void OnPlaySeekKey(UINT nID); // no menu item
+ afx_msg void OnUpdatePlaySeek(CCmdUI* pCmdUI);
+ afx_msg void OnPlayGoto();
+ afx_msg void OnUpdateGoto(CCmdUI* pCmdUI);
+ afx_msg void OnPlayChangeRate(UINT nID);
+ afx_msg void OnUpdatePlayChangeRate(CCmdUI* pCmdUI);
+ afx_msg void OnPlayResetRate();
+ afx_msg void OnUpdatePlayResetRate(CCmdUI* pCmdUI);
+ afx_msg void OnPlayChangeAudDelay(UINT nID);
+ afx_msg void OnUpdatePlayChangeAudDelay(CCmdUI* pCmdUI);
+ afx_msg void OnPlayFilters(UINT nID);
+ afx_msg void OnUpdatePlayFilters(CCmdUI* pCmdUI);
+ afx_msg void OnPlayShaders(UINT nID);
+ afx_msg void OnPlayAudio(UINT nID);
+ afx_msg void OnUpdatePlayAudio(CCmdUI* pCmdUI);
+ afx_msg void OnPlaySubtitles(UINT nID);
+ afx_msg void OnUpdatePlaySubtitles(CCmdUI* pCmdUI);
+ afx_msg void OnPlayLanguage(UINT nID);
+ afx_msg void OnUpdatePlayLanguage(CCmdUI* pCmdUI);
+ afx_msg void OnPlayVolume(UINT nID);
+ afx_msg void OnPlayVolumeBoost(UINT nID);
+ afx_msg void OnUpdatePlayVolumeBoost(CCmdUI* pCmdUI);
+ afx_msg void OnCustomChannelMapping();
+ afx_msg void OnUpdateCustomChannelMapping(CCmdUI* pCmdUI);
+ afx_msg void OnNormalizeRegainVolume(UINT nID);
+ afx_msg void OnUpdateNormalizeRegainVolume(CCmdUI* pCmdUI);
+ afx_msg void OnPlayColor(UINT nID);
+ afx_msg void OnAfterplayback(UINT nID);
+ afx_msg void OnUpdateAfterplayback(CCmdUI* pCmdUI);
+
+ afx_msg void OnNavigateSkip(UINT nID);
+ afx_msg void OnUpdateNavigateSkip(CCmdUI* pCmdUI);
+ afx_msg void OnNavigateSkipFile(UINT nID);
+ afx_msg void OnUpdateNavigateSkipFile(CCmdUI* pCmdUI);
+ afx_msg void OnNavigateMenu(UINT nID);
+ afx_msg void OnUpdateNavigateMenu(CCmdUI* pCmdUI);
+ afx_msg void OnNavigateAudio(UINT nID);
+ afx_msg void OnNavigateSubpic(UINT nID);
+ afx_msg void OnNavigateAngle(UINT nID);
+ afx_msg void OnNavigateChapters(UINT nID);
+ afx_msg void OnNavigateMenuItem(UINT nID);
+ afx_msg void OnUpdateNavigateMenuItem(CCmdUI* pCmdUI);
+ afx_msg void OnTunerScan();
+ afx_msg void OnUpdateTunerScan(CCmdUI* pCmdUI);
+
+ afx_msg void OnFavoritesAdd();
+ afx_msg void OnUpdateFavoritesAdd(CCmdUI* pCmdUI);
+ afx_msg void OnFavoritesQuickAddFavorite();
+ afx_msg void OnFavoritesOrganize();
+ afx_msg void OnUpdateFavoritesOrganize(CCmdUI* pCmdUI);
+ afx_msg void OnFavoritesFile(UINT nID);
+ afx_msg void OnUpdateFavoritesFile(CCmdUI* pCmdUI);
+ afx_msg void OnFavoritesDVD(UINT nID);
+ afx_msg void OnUpdateFavoritesDVD(CCmdUI* pCmdUI);
+ afx_msg void OnFavoritesDevice(UINT nID);
+ afx_msg void OnUpdateFavoritesDevice(CCmdUI* pCmdUI);
+ afx_msg void OnRecentFileClear();
+ afx_msg void OnUpdateRecentFileClear(CCmdUI* pCmdUI);
+ afx_msg void OnRecentFile(UINT nID);
+ afx_msg void OnUpdateRecentFile(CCmdUI* pCmdUI);
+
+
+ afx_msg void OnHelpHomepage();
+ afx_msg void OnHelpCheckForUpdate();
+ //afx_msg void OnHelpDocumentation();
+ afx_msg void OnHelpToolbarImages();
+ afx_msg void OnHelpDonate();
+
+ afx_msg void OnClose();
+
+ afx_msg void OnLanguage(UINT nID);
+ afx_msg void OnUpdateLanguage(CCmdUI* pCmdUI);
+
+ //CMPC_Lcd m_Lcd;
+
+ // ==== Added by CASIMIR666
+ CWnd* m_pVideoWnd; // Current Video (main display screen or 2nd)
+ SIZE m_fullWndSize;
+ CFullscreenWnd* m_pFullscreenWnd;
+ CComPtr<IVMRMixerControl9> m_pMC;
+ CComPtr<IMFVideoDisplayControl> m_pMFVDC;
+ CComPtr<IMFVideoProcessor> m_pMFVP;
+ CComPtr<IAMLine21Decoder_2> m_pLN21;
+ CVMROSD m_OSD;
+ bool m_OpenFile;
+ bool m_bRemainingTime;
+ int m_nCurSubtitle;
+ long m_lSubtitleShift;
+ __int64 m_rtCurSubPos;
+ CString m_strTitle;
+ bool m_bToggleShader;
+ bool m_bToggleShaderScreenSpace;
+ bool m_bInOptions;
+ bool m_bStopTunerScan;
+
+ void SetLoadState(MPC_LOADSTATE iState);
+ void SetPlayState(MPC_PLAYSTATE iState);
+ bool CreateFullScreenWindow();
+ void SetupEVRColorControl();
+ void SetColorControl(DWORD flags, int& brightness, int& contrast, int& hue, int& saturation);
+ void SetClosedCaptions(bool enable);
+ LPCTSTR GetDVDAudioFormatName(DVD_AudioAttributes& ATR) const;
+ void SetAudioDelay(REFERENCE_TIME rtShift);
+ void SetSubtitleDelay(int delay_ms);
+ //void AutoSelectTracks();
+ bool IsRealEngineCompatible(CString strFilename) const;
+ void SetTimersPlay();
+ void KillTimersStop();
+
+
+ // MPC API functions
+ void ProcessAPICommand(COPYDATASTRUCT* pCDS);
+ void SendAPICommand(MPCAPI_COMMAND nCommand, LPCWSTR fmt, ...);
+ void SendNowPlayingToApi();
+ void SendSubtitleTracksToApi();
+ void SendAudioTracksToApi();
+ void SendPlaylistToApi();
+ afx_msg void OnFileOpendirectory();
+
+ void SendCurrentPositionToApi(bool fNotifySeek = false);
+ void ShowOSDCustomMessageApi(MPC_OSDDATA* osdData);
+ void JumpOfNSeconds(int seconds);
+
+ CString GetVidPos() const;
+
+ ITaskbarList3* m_pTaskbarList;
+ HRESULT CreateThumbnailToolbar();
+ HRESULT UpdateThumbarButton();
+ HRESULT UpdateThumbnailClip();
protected:
- // GDI+
- ULONG_PTR m_gdiplusToken;
- virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
- void WTSRegisterSessionNotification();
- void WTSUnRegisterSessionNotification();
-
- DWORD m_nMenuHideTick;
- UINT m_nSeekDirection;
+ // GDI+
+ ULONG_PTR m_gdiplusToken;
+ virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
+ void WTSRegisterSessionNotification();
+ void WTSUnRegisterSessionNotification();
+
+ DWORD m_nMenuHideTick;
+ UINT m_nSeekDirection;
public:
- afx_msg UINT OnPowerBroadcast(UINT nPowerEvent, UINT nEventData);
- afx_msg void OnSessionChange(UINT nSessionState, UINT nId);
+ afx_msg UINT OnPowerBroadcast(UINT nPowerEvent, UINT nEventData);
+ afx_msg void OnSessionChange(UINT nSessionState, UINT nId);
- void EnableShaders1(bool enable);
- void EnableShaders2(bool enable);
+ void EnableShaders1(bool enable);
+ void EnableShaders2(bool enable);
- CAtlList<CHdmvClipInfo::PlaylistItem> m_MPLSPlaylist;
- bool m_bIsBDPlay;
- bool OpenBD(CString Path);
+ CAtlList<CHdmvClipInfo::PlaylistItem> m_MPLSPlaylist;
+ bool m_bIsBDPlay;
+ bool OpenBD(CString Path);
};
diff --git a/src/mpc-hc/MediaFormats.cpp b/src/mpc-hc/MediaFormats.cpp
index 5cb34c837..5ada46641 100644
--- a/src/mpc-hc/MediaFormats.cpp
+++ b/src/mpc-hc/MediaFormats.cpp
@@ -32,39 +32,39 @@
//
CMediaFormatCategory::CMediaFormatCategory()
- : m_fAudioOnly(false)
+ : m_fAudioOnly(false)
{
}
CMediaFormatCategory::CMediaFormatCategory(
- CString label, CString description, CAtlList<CString>& exts, bool fAudioOnly,
- CString specreqnote, engine_t engine)
+ CString label, CString description, CAtlList<CString>& exts, bool fAudioOnly,
+ CString specreqnote, engine_t engine)
{
- m_label = label;
- m_description = description;
- m_exts.AddTailList(&exts);
- m_backupexts.AddTailList(&m_exts);
- m_specreqnote = specreqnote;
- m_fAudioOnly = fAudioOnly;
- m_engine = engine;
+ m_label = label;
+ m_description = description;
+ m_exts.AddTailList(&exts);
+ m_backupexts.AddTailList(&m_exts);
+ m_specreqnote = specreqnote;
+ m_fAudioOnly = fAudioOnly;
+ m_engine = engine;
}
CMediaFormatCategory::CMediaFormatCategory(
- CString label, CString description, CString exts, bool fAudioOnly,
- CString specreqnote, engine_t engine)
+ CString label, CString description, CString exts, bool fAudioOnly,
+ CString specreqnote, engine_t engine)
{
- m_label = label;
- m_description = description;
- ExplodeMin(exts, m_exts, ' ');
- POSITION pos = m_exts.GetHeadPosition();
- while (pos) {
- m_exts.GetNext(pos).TrimLeft('.');
- }
-
- m_backupexts.AddTailList(&m_exts);
- m_specreqnote = specreqnote;
- m_fAudioOnly = fAudioOnly;
- m_engine = engine;
+ m_label = label;
+ m_description = description;
+ ExplodeMin(exts, m_exts, ' ');
+ POSITION pos = m_exts.GetHeadPosition();
+ while (pos) {
+ m_exts.GetNext(pos).TrimLeft('.');
+ }
+
+ m_backupexts.AddTailList(&m_exts);
+ m_specreqnote = specreqnote;
+ m_fAudioOnly = fAudioOnly;
+ m_engine = engine;
}
CMediaFormatCategory::~CMediaFormatCategory()
@@ -73,113 +73,113 @@ CMediaFormatCategory::~CMediaFormatCategory()
void CMediaFormatCategory::UpdateData(bool fSave)
{
- if (fSave) {
- AfxGetApp()->WriteProfileString(_T("FileFormats"), m_label, GetExts(true));
- } else {
- SetExts(AfxGetApp()->GetProfileString(_T("FileFormats"), m_label, GetExts(true)));
- }
+ if (fSave) {
+ AfxGetApp()->WriteProfileString(_T("FileFormats"), m_label, GetExts(true));
+ } else {
+ SetExts(AfxGetApp()->GetProfileString(_T("FileFormats"), m_label, GetExts(true)));
+ }
}
CMediaFormatCategory::CMediaFormatCategory(const CMediaFormatCategory& mfc)
{
- *this = mfc;
+ *this = mfc;
}
CMediaFormatCategory& CMediaFormatCategory::operator = (const CMediaFormatCategory& mfc)
{
- if (this != &mfc) {
- m_label = mfc.m_label;
- m_description = mfc.m_description;
- m_specreqnote = mfc.m_specreqnote;
- m_exts.RemoveAll();
- m_exts.AddTailList(&mfc.m_exts);
- m_backupexts.RemoveAll();
- m_backupexts.AddTailList(&mfc.m_backupexts);
- m_fAudioOnly = mfc.m_fAudioOnly;
- m_engine = mfc.m_engine;
- }
- return *this;
+ if (this != &mfc) {
+ m_label = mfc.m_label;
+ m_description = mfc.m_description;
+ m_specreqnote = mfc.m_specreqnote;
+ m_exts.RemoveAll();
+ m_exts.AddTailList(&mfc.m_exts);
+ m_backupexts.RemoveAll();
+ m_backupexts.AddTailList(&mfc.m_backupexts);
+ m_fAudioOnly = mfc.m_fAudioOnly;
+ m_engine = mfc.m_engine;
+ }
+ return *this;
}
void CMediaFormatCategory::RestoreDefaultExts()
{
- m_exts.RemoveAll();
- m_exts.AddTailList(&m_backupexts);
+ m_exts.RemoveAll();
+ m_exts.AddTailList(&m_backupexts);
}
void CMediaFormatCategory::SetExts(CAtlList<CString>& exts)
{
- m_exts.RemoveAll();
- m_exts.AddTailList(&exts);
+ m_exts.RemoveAll();
+ m_exts.AddTailList(&exts);
}
void CMediaFormatCategory::SetExts(CString exts)
{
- m_exts.RemoveAll();
- ExplodeMin(exts, m_exts, ' ');
- POSITION pos = m_exts.GetHeadPosition();
- while (pos) {
- POSITION cur = pos;
- CString& ext = m_exts.GetNext(pos);
- if (ext[0] == '\\') {
- m_engine = (engine_t)_tcstol(ext.TrimLeft('\\'), NULL, 10);
- m_exts.RemoveAt(cur);
- } else {
- ext.TrimLeft('.');
- }
- }
+ m_exts.RemoveAll();
+ ExplodeMin(exts, m_exts, ' ');
+ POSITION pos = m_exts.GetHeadPosition();
+ while (pos) {
+ POSITION cur = pos;
+ CString& ext = m_exts.GetNext(pos);
+ if (ext[0] == '\\') {
+ m_engine = (engine_t)_tcstol(ext.TrimLeft('\\'), NULL, 10);
+ m_exts.RemoveAt(cur);
+ } else {
+ ext.TrimLeft('.');
+ }
+ }
}
CString CMediaFormatCategory::GetFilter() const
{
- CString filter;
- POSITION pos = m_exts.GetHeadPosition();
- while (pos) {
- filter += _T("*.") + m_exts.GetNext(pos) + _T(";");
- }
- filter.TrimRight(_T(';')); // cheap...
- return filter;
+ CString filter;
+ POSITION pos = m_exts.GetHeadPosition();
+ while (pos) {
+ filter += _T("*.") + m_exts.GetNext(pos) + _T(";");
+ }
+ filter.TrimRight(_T(';')); // cheap...
+ return filter;
}
CString CMediaFormatCategory::GetExts(bool fAppendEngine) const
{
- CString exts = Implode(m_exts, ' ');
- if (fAppendEngine) {
- exts += CString(_T(" \\")) + (TCHAR)(0x30 + (int)m_engine);
- }
- return exts;
+ CString exts = Implode(m_exts, ' ');
+ if (fAppendEngine) {
+ exts += CString(_T(" \\")) + (TCHAR)(0x30 + (int)m_engine);
+ }
+ return exts;
}
CString CMediaFormatCategory::GetExtsWithPeriod(bool fAppendEngine) const
{
- CString exts;
- POSITION pos = m_exts.GetHeadPosition();
- while (pos) {
- exts += _T(".") + m_exts.GetNext(pos) + _T(" ");
- }
- exts.TrimRight(_T(' ')); // cheap...
- if (fAppendEngine) {
- exts += CString(_T(" \\")) + (TCHAR)(0x30 + (int)m_engine);
- }
- return exts;
+ CString exts;
+ POSITION pos = m_exts.GetHeadPosition();
+ while (pos) {
+ exts += _T(".") + m_exts.GetNext(pos) + _T(" ");
+ }
+ exts.TrimRight(_T(' ')); // cheap...
+ if (fAppendEngine) {
+ exts += CString(_T(" \\")) + (TCHAR)(0x30 + (int)m_engine);
+ }
+ return exts;
}
CString CMediaFormatCategory::GetBackupExtsWithPeriod(bool fAppendEngine) const
{
- CString exts;
- POSITION pos = m_backupexts.GetHeadPosition();
- while (pos) {
- exts += _T(".") + m_backupexts.GetNext(pos) + _T(" ");
- }
- exts.TrimRight(_T(' ')); // cheap...
- if (fAppendEngine) {
- exts += CString(_T(" \\")) + (TCHAR)(0x30 + (int)m_engine);
- }
- return exts;
+ CString exts;
+ POSITION pos = m_backupexts.GetHeadPosition();
+ while (pos) {
+ exts += _T(".") + m_backupexts.GetNext(pos) + _T(" ");
+ }
+ exts.TrimRight(_T(' ')); // cheap...
+ if (fAppendEngine) {
+ exts += CString(_T(" \\")) + (TCHAR)(0x30 + (int)m_engine);
+ }
+ return exts;
}
//
-// CMediaFormats
+// CMediaFormats
//
CMediaFormats::CMediaFormats()
@@ -192,223 +192,223 @@ CMediaFormats::~CMediaFormats()
void CMediaFormats::UpdateData(bool fSave)
{
- if (fSave) {
- AfxGetApp()->WriteProfileString(_T("FileFormats"), NULL, NULL);
+ if (fSave) {
+ AfxGetApp()->WriteProfileString(_T("FileFormats"), NULL, NULL);
- AfxGetApp()->WriteProfileInt(_T("FileFormats"), _T("RtspHandler"), m_iRtspHandler);
- AfxGetApp()->WriteProfileInt(_T("FileFormats"), _T("RtspFileExtFirst"), m_fRtspFileExtFirst);
- } else {
- RemoveAll();
+ AfxGetApp()->WriteProfileInt(_T("FileFormats"), _T("RtspHandler"), m_iRtspHandler);
+ AfxGetApp()->WriteProfileInt(_T("FileFormats"), _T("RtspFileExtFirst"), m_fRtspFileExtFirst);
+ } else {
+ RemoveAll();
#define ADDFMT(f) Add(CMediaFormatCategory##f)
- ADDFMT((_T("avi"), ResStr(IDS_MFMT_AVI), _T("avi")));
- ADDFMT((_T("mpeg"), ResStr(IDS_MFMT_MPEG), _T("mpg mpeg mpe m1v m2v mpv2 mp2v pva evo m2p")));
- ADDFMT((_T("mpegts"), ResStr(IDS_MFMT_MPEGTS), _T("ts tp trp m2t m2ts mts rec")));
- ADDFMT((_T("dvdvideo"), ResStr(IDS_MFMT_DVDVIDEO), _T("vob ifo")));
- ADDFMT((_T("mkv"), ResStr(IDS_MFMT_MKV), _T("mkv")));
- ADDFMT((_T("webm"), ResStr(IDS_MFMT_WEBM), _T("webm")));
- ADDFMT((_T("mp4"), ResStr(IDS_MFMT_MP4), _T("mp4 m4v mp4v mpv4 hdmov")));
- ADDFMT((_T("mov"), ResStr(IDS_MFMT_MOV), _T("mov"), false, _T("QuickTime or QT Lite")));
- ADDFMT((_T("3gp"), ResStr(IDS_MFMT_3GP), _T("3gp 3gpp")));
+ ADDFMT((_T("avi"), ResStr(IDS_MFMT_AVI), _T("avi")));
+ ADDFMT((_T("mpeg"), ResStr(IDS_MFMT_MPEG), _T("mpg mpeg mpe m1v m2v mpv2 mp2v pva evo m2p")));
+ ADDFMT((_T("mpegts"), ResStr(IDS_MFMT_MPEGTS), _T("ts tp trp m2t m2ts mts rec")));
+ ADDFMT((_T("dvdvideo"), ResStr(IDS_MFMT_DVDVIDEO), _T("vob ifo")));
+ ADDFMT((_T("mkv"), ResStr(IDS_MFMT_MKV), _T("mkv")));
+ ADDFMT((_T("webm"), ResStr(IDS_MFMT_WEBM), _T("webm")));
+ ADDFMT((_T("mp4"), ResStr(IDS_MFMT_MP4), _T("mp4 m4v mp4v mpv4 hdmov")));
+ ADDFMT((_T("mov"), ResStr(IDS_MFMT_MOV), _T("mov"), false, _T("QuickTime or QT Lite")));
+ ADDFMT((_T("3gp"), ResStr(IDS_MFMT_3GP), _T("3gp 3gpp")));
#ifdef _WIN64
- ADDFMT((_T("3g2"), ResStr(IDS_MFMT_3G2), _T("3g2 3gp2")));
+ ADDFMT((_T("3g2"), ResStr(IDS_MFMT_3G2), _T("3g2 3gp2")));
#else
- ADDFMT((_T("3g2"), ResStr(IDS_MFMT_3G2), _T("3g2 3gp2"), false, _T("QuickTime or QT Lite"), QuickTime));
+ ADDFMT((_T("3g2"), ResStr(IDS_MFMT_3G2), _T("3g2 3gp2"), false, _T("QuickTime or QT Lite"), QuickTime));
#endif
- ADDFMT((_T("flv"), ResStr(IDS_MFMT_FLV), _T("flv f4v")));
- ADDFMT((_T("ogm"), ResStr(IDS_MFMT_OGM), _T("ogm ogv")));
+ ADDFMT((_T("flv"), ResStr(IDS_MFMT_FLV), _T("flv f4v")));
+ ADDFMT((_T("ogm"), ResStr(IDS_MFMT_OGM), _T("ogm ogv")));
#ifdef _WIN64
- ADDFMT((_T("rm"), ResStr(IDS_MFMT_RM), _T("rm ram rpm rmm")));
- ADDFMT((_T("rt"), ResStr(IDS_MFMT_RT), _T("rt rp smi smil")));
+ ADDFMT((_T("rm"), ResStr(IDS_MFMT_RM), _T("rm ram rpm rmm")));
+ ADDFMT((_T("rt"), ResStr(IDS_MFMT_RT), _T("rt rp smi smil")));
#else
- ADDFMT((_T("rm"), ResStr(IDS_MFMT_RM), _T("rm ram rpm rmm"), false, _T("RealPlayer or Real Alternative"), RealMedia));
- ADDFMT((_T("rt"), ResStr(IDS_MFMT_RT), _T("rt rp smi smil"), false, _T("RealPlayer or Real Alternative"), RealMedia));
+ ADDFMT((_T("rm"), ResStr(IDS_MFMT_RM), _T("rm ram rpm rmm"), false, _T("RealPlayer or Real Alternative"), RealMedia));
+ ADDFMT((_T("rt"), ResStr(IDS_MFMT_RT), _T("rt rp smi smil"), false, _T("RealPlayer or Real Alternative"), RealMedia));
#endif
- ADDFMT((_T("wmv"), ResStr(IDS_MFMT_WMV), _T("wmv wmp wm asf")));
- ADDFMT((_T("videocd"), ResStr(IDS_MFMT_VIDEOCD), _T("dat")));
- ADDFMT((_T("bink"), ResStr(IDS_MFMT_BINK), _T("smk bik"), false, _T("smackw32/binkw32.dll in dll path")));
- ADDFMT((_T("flic"), ResStr(IDS_MFMT_FLIC), _T("fli flc flic")));
- ADDFMT((_T("dsm"), ResStr(IDS_MFMT_DSM), _T("dsm dsv dsa dss")));
- ADDFMT((_T("ivf"), ResStr(IDS_MFMT_IVF), _T("ivf")));
- ADDFMT((_T("dvd2avi"), ResStr(IDS_MFMT_D2V), _T("d2v")));
- ADDFMT((_T("swf"), ResStr(IDS_MFMT_SWF), _T("swf"), false, _T("ShockWave ActiveX control"), ShockWave));
- ADDFMT((_T("other"), ResStr(IDS_MFMT_OTHER), _T("divx rmvb amv")));
- ADDFMT((_T("ac3dts"), ResStr(IDS_MFMT_AC3), _T("ac3 dts"), true));
- ADDFMT((_T("aiff"), ResStr(IDS_MFMT_AIFF), _T("aif aifc aiff"), true));
- ADDFMT((_T("alac"), ResStr(IDS_MFMT_ALAC), _T("alac"), true));
- ADDFMT((_T("amr"), ResStr(IDS_MFMT_AMR), _T("amr"), true));
- ADDFMT((_T("ape"), ResStr(IDS_MFMT_APE), _T("ape apl"), true));
- ADDFMT((_T("au"), ResStr(IDS_MFMT_AU), _T("au snd"), true));
- ADDFMT((_T("audiocd"), ResStr(IDS_MFMT_CDA), _T("cda"), true));
- ADDFMT((_T("flac"), ResStr(IDS_MFMT_FLAC), _T("flac"), true));
+ ADDFMT((_T("wmv"), ResStr(IDS_MFMT_WMV), _T("wmv wmp wm asf")));
+ ADDFMT((_T("videocd"), ResStr(IDS_MFMT_VIDEOCD), _T("dat")));
+ ADDFMT((_T("bink"), ResStr(IDS_MFMT_BINK), _T("smk bik"), false, _T("smackw32/binkw32.dll in dll path")));
+ ADDFMT((_T("flic"), ResStr(IDS_MFMT_FLIC), _T("fli flc flic")));
+ ADDFMT((_T("dsm"), ResStr(IDS_MFMT_DSM), _T("dsm dsv dsa dss")));
+ ADDFMT((_T("ivf"), ResStr(IDS_MFMT_IVF), _T("ivf")));
+ ADDFMT((_T("dvd2avi"), ResStr(IDS_MFMT_D2V), _T("d2v")));
+ ADDFMT((_T("swf"), ResStr(IDS_MFMT_SWF), _T("swf"), false, _T("ShockWave ActiveX control"), ShockWave));
+ ADDFMT((_T("other"), ResStr(IDS_MFMT_OTHER), _T("divx rmvb amv")));
+ ADDFMT((_T("ac3dts"), ResStr(IDS_MFMT_AC3), _T("ac3 dts"), true));
+ ADDFMT((_T("aiff"), ResStr(IDS_MFMT_AIFF), _T("aif aifc aiff"), true));
+ ADDFMT((_T("alac"), ResStr(IDS_MFMT_ALAC), _T("alac"), true));
+ ADDFMT((_T("amr"), ResStr(IDS_MFMT_AMR), _T("amr"), true));
+ ADDFMT((_T("ape"), ResStr(IDS_MFMT_APE), _T("ape apl"), true));
+ ADDFMT((_T("au"), ResStr(IDS_MFMT_AU), _T("au snd"), true));
+ ADDFMT((_T("audiocd"), ResStr(IDS_MFMT_CDA), _T("cda"), true));
+ ADDFMT((_T("flac"), ResStr(IDS_MFMT_FLAC), _T("flac"), true));
#ifdef _WIN64
- ADDFMT((_T("m4a"), ResStr(IDS_MFMT_M4A), _T("m4a m4b aac"), true));
+ ADDFMT((_T("m4a"), ResStr(IDS_MFMT_M4A), _T("m4a m4b aac"), true));
#else
- ADDFMT((_T("m4a"), ResStr(IDS_MFMT_M4A), _T("m4a m4b aac"), true, _T(""), QuickTime));
+ ADDFMT((_T("m4a"), ResStr(IDS_MFMT_M4A), _T("m4a m4b aac"), true, _T(""), QuickTime));
#endif
- ADDFMT((_T("midi"), ResStr(IDS_MFMT_MIDI), _T("mid midi rmi"), true));
- ADDFMT((_T("mka"), ResStr(IDS_MFMT_MKA), _T("mka"), true));
- ADDFMT((_T("mp3"), ResStr(IDS_MFMT_MP3), _T("mp3"), true));
- ADDFMT((_T("mpa"), ResStr(IDS_MFMT_MPA), _T("mpa mp2 m1a m2a"), true));
- ADDFMT((_T("mpc"), ResStr(IDS_MFMT_MPC), _T("mpc"), true));
- ADDFMT((_T("ofr"), ResStr(IDS_MFMT_OFR), _T("ofr ofs"), true));
- ADDFMT((_T("ogg"), ResStr(IDS_MFMT_OGG), _T("ogg oga"), true));
+ ADDFMT((_T("midi"), ResStr(IDS_MFMT_MIDI), _T("mid midi rmi"), true));
+ ADDFMT((_T("mka"), ResStr(IDS_MFMT_MKA), _T("mka"), true));
+ ADDFMT((_T("mp3"), ResStr(IDS_MFMT_MP3), _T("mp3"), true));
+ ADDFMT((_T("mpa"), ResStr(IDS_MFMT_MPA), _T("mpa mp2 m1a m2a"), true));
+ ADDFMT((_T("mpc"), ResStr(IDS_MFMT_MPC), _T("mpc"), true));
+ ADDFMT((_T("ofr"), ResStr(IDS_MFMT_OFR), _T("ofr ofs"), true));
+ ADDFMT((_T("ogg"), ResStr(IDS_MFMT_OGG), _T("ogg oga"), true));
#ifdef _WIN64
- ADDFMT((_T("ra"), ResStr(IDS_MFMT_RA), _T("ra"), true));
+ ADDFMT((_T("ra"), ResStr(IDS_MFMT_RA), _T("ra"), true));
#else
- ADDFMT((_T("ra"), ResStr(IDS_MFMT_RA), _T("ra"), true, _T("RealPlayer or Real Alternative"), RealMedia));
+ ADDFMT((_T("ra"), ResStr(IDS_MFMT_RA), _T("ra"), true, _T("RealPlayer or Real Alternative"), RealMedia));
#endif
- ADDFMT((_T("tak"), ResStr(IDS_MFMT_TAK), _T("tak"), true));
- ADDFMT((_T("tta"), ResStr(IDS_MFMT_TTA), _T("tta"), true));
- ADDFMT((_T("wav"), ResStr(IDS_MFMT_WAV), _T("wav"), true));
- ADDFMT((_T("wma"), ResStr(IDS_MFMT_WMA), _T("wma"), true));
- ADDFMT((_T("wavpack"), ResStr(IDS_MFMT_WV), _T("wv"), true));
- ADDFMT((_T("pls"), ResStr(IDS_MFMT_PLS), _T("asx m3u m3u8 pls wvx wax wmx mpcpl")));
- ADDFMT((_T("bdpls"), ResStr(IDS_MFMT_BDPLS), _T("mpls bdmv")));
+ ADDFMT((_T("tak"), ResStr(IDS_MFMT_TAK), _T("tak"), true));
+ ADDFMT((_T("tta"), ResStr(IDS_MFMT_TTA), _T("tta"), true));
+ ADDFMT((_T("wav"), ResStr(IDS_MFMT_WAV), _T("wav"), true));
+ ADDFMT((_T("wma"), ResStr(IDS_MFMT_WMA), _T("wma"), true));
+ ADDFMT((_T("wavpack"), ResStr(IDS_MFMT_WV), _T("wv"), true));
+ ADDFMT((_T("pls"), ResStr(IDS_MFMT_PLS), _T("asx m3u m3u8 pls wvx wax wmx mpcpl")));
+ ADDFMT((_T("bdpls"), ResStr(IDS_MFMT_BDPLS), _T("mpls bdmv")));
#undef ADDFMT
- m_iRtspHandler = (engine_t)AfxGetApp()->GetProfileInt(_T("FileFormats"), _T("RtspHandler"), (int)RealMedia);
- m_fRtspFileExtFirst = !!AfxGetApp()->GetProfileInt(_T("FileFormats"), _T("RtspFileExtFirst"), 1);
- }
+ m_iRtspHandler = (engine_t)AfxGetApp()->GetProfileInt(_T("FileFormats"), _T("RtspHandler"), (int)RealMedia);
+ m_fRtspFileExtFirst = !!AfxGetApp()->GetProfileInt(_T("FileFormats"), _T("RtspFileExtFirst"), 1);
+ }
- for (size_t i = 0; i < GetCount(); i++) {
- GetAt(i).UpdateData(fSave);
- }
+ for (size_t i = 0; i < GetCount(); i++) {
+ GetAt(i).UpdateData(fSave);
+ }
}
engine_t CMediaFormats::GetRtspHandler(bool& fRtspFileExtFirst)
{
- fRtspFileExtFirst = m_fRtspFileExtFirst;
- return m_iRtspHandler;
+ fRtspFileExtFirst = m_fRtspFileExtFirst;
+ return m_iRtspHandler;
}
void CMediaFormats::SetRtspHandler(engine_t e, bool fRtspFileExtFirst)
{
- m_iRtspHandler = e;
- m_fRtspFileExtFirst = fRtspFileExtFirst;
+ m_iRtspHandler = e;
+ m_fRtspFileExtFirst = fRtspFileExtFirst;
}
bool CMediaFormats::IsUsingEngine(CString path, engine_t e)
{
- return (GetEngine(path) == e);
+ return (GetEngine(path) == e);
}
engine_t CMediaFormats::GetEngine(CString path)
{
- path.Trim().MakeLower();
-
- if (!m_fRtspFileExtFirst && path.Find(_T("rtsp://")) == 0) {
- return m_iRtspHandler;
- }
-
- CString ext = CPath(path).GetExtension();
- ext.MakeLower();
- if (!ext.IsEmpty()) {
- if (path.Find(_T("rtsp://")) == 0) {
- if (ext == _T(".ram") || ext == _T(".rm") || ext == _T(".ra")) {
- return RealMedia;
- }
- if (ext == _T(".qt") || ext == _T(".mov")) {
- return QuickTime;
- }
- }
-
- for (size_t i = 0; i < GetCount(); i++) {
- CMediaFormatCategory& mfc = GetAt(i);
- if (mfc.FindExt(ext)) {
- return mfc.GetEngineType();
- }
- }
- }
-
- if (m_fRtspFileExtFirst && path.Find(_T("rtsp://")) == 0) {
- return m_iRtspHandler;
- }
-
- return DirectShow;
+ path.Trim().MakeLower();
+
+ if (!m_fRtspFileExtFirst && path.Find(_T("rtsp://")) == 0) {
+ return m_iRtspHandler;
+ }
+
+ CString ext = CPath(path).GetExtension();
+ ext.MakeLower();
+ if (!ext.IsEmpty()) {
+ if (path.Find(_T("rtsp://")) == 0) {
+ if (ext == _T(".ram") || ext == _T(".rm") || ext == _T(".ra")) {
+ return RealMedia;
+ }
+ if (ext == _T(".qt") || ext == _T(".mov")) {
+ return QuickTime;
+ }
+ }
+
+ for (size_t i = 0; i < GetCount(); i++) {
+ CMediaFormatCategory& mfc = GetAt(i);
+ if (mfc.FindExt(ext)) {
+ return mfc.GetEngineType();
+ }
+ }
+ }
+
+ if (m_fRtspFileExtFirst && path.Find(_T("rtsp://")) == 0) {
+ return m_iRtspHandler;
+ }
+
+ return DirectShow;
}
bool CMediaFormats::FindExt(CString ext, bool fAudioOnly)
{
- return (FindMediaByExt(ext, fAudioOnly) != NULL);
+ return (FindMediaByExt(ext, fAudioOnly) != NULL);
}
CMediaFormatCategory* CMediaFormats::FindMediaByExt(CString ext, bool fAudioOnly)
{
- ext.TrimLeft(_T('.'));
-
- if (!ext.IsEmpty()) {
- for (size_t i = 0; i < GetCount(); i++) {
- CMediaFormatCategory& mfc = GetAt(i);
- if ((!fAudioOnly || mfc.IsAudioOnly()) && mfc.FindExt(ext)) {
- return &mfc;
- }
- }
- }
-
- return NULL;
+ ext.TrimLeft(_T('.'));
+
+ if (!ext.IsEmpty()) {
+ for (size_t i = 0; i < GetCount(); i++) {
+ CMediaFormatCategory& mfc = GetAt(i);
+ if ((!fAudioOnly || mfc.IsAudioOnly()) && mfc.FindExt(ext)) {
+ return &mfc;
+ }
+ }
+ }
+
+ return NULL;
}
void CMediaFormats::GetFilter(CString& filter, CAtlArray<CString>& mask)
{
- CString strTemp;
-
- filter += ResStr(IDS_AG_MEDIAFILES);
- mask.Add(_T(""));
-
- for (size_t i = 0; i < GetCount(); i++) {
- strTemp = GetAt(i).GetFilter() + _T(";");
- mask[0] += strTemp;
- filter += strTemp;
- }
- mask[0].TrimRight(_T(';'));
- filter.TrimRight(_T(';'));
- filter += _T("|");
-
- for (size_t i = 0; i < GetCount(); i++) {
- CMediaFormatCategory& mfc = GetAt(i);
- filter += mfc.GetDescription() + _T("|" + GetAt(i).GetFilter() + _T("|"));
- mask.Add(mfc.GetFilter());
- }
-
- filter += ResStr(IDS_AG_ALLFILES);
- mask.Add(_T("*.*"));
-
- filter += _T("|");
+ CString strTemp;
+
+ filter += ResStr(IDS_AG_MEDIAFILES);
+ mask.Add(_T(""));
+
+ for (size_t i = 0; i < GetCount(); i++) {
+ strTemp = GetAt(i).GetFilter() + _T(";");
+ mask[0] += strTemp;
+ filter += strTemp;
+ }
+ mask[0].TrimRight(_T(';'));
+ filter.TrimRight(_T(';'));
+ filter += _T("|");
+
+ for (size_t i = 0; i < GetCount(); i++) {
+ CMediaFormatCategory& mfc = GetAt(i);
+ filter += mfc.GetDescription() + _T("|" + GetAt(i).GetFilter() + _T("|"));
+ mask.Add(mfc.GetFilter());
+ }
+
+ filter += ResStr(IDS_AG_ALLFILES);
+ mask.Add(_T("*.*"));
+
+ filter += _T("|");
}
void CMediaFormats::GetAudioFilter(CString& filter, CAtlArray<CString>& mask)
{
- CString strTemp;
- filter += ResStr(IDS_AG_AUDIOFILES);
- mask.Add(_T(""));
-
- for (size_t i = 0; i < GetCount(); i++) {
- CMediaFormatCategory& mfc = GetAt(i);
- if (!mfc.IsAudioOnly() || mfc.GetEngineType() != DirectShow) {
- continue;
- }
- strTemp = GetAt(i).GetFilter() + _T(";");
- mask[0] += strTemp;
- filter += strTemp;
- }
-
- mask[0].TrimRight(_T(';'));
- filter.TrimRight(_T(';'));
- filter += _T("|");
-
- for (size_t i = 0; i < GetCount(); i++) {
- CMediaFormatCategory& mfc = GetAt(i);
- if (!mfc.IsAudioOnly() || mfc.GetEngineType() != DirectShow) {
- continue;
- }
- filter += mfc.GetDescription() + _T("|") + GetAt(i).GetFilter() + _T("|");
- mask.Add(mfc.GetFilter());
- }
-
- filter += ResStr(IDS_AG_ALLFILES);
- mask.Add(_T("*.*"));
-
- filter += _T("|");
+ CString strTemp;
+ filter += ResStr(IDS_AG_AUDIOFILES);
+ mask.Add(_T(""));
+
+ for (size_t i = 0; i < GetCount(); i++) {
+ CMediaFormatCategory& mfc = GetAt(i);
+ if (!mfc.IsAudioOnly() || mfc.GetEngineType() != DirectShow) {
+ continue;
+ }
+ strTemp = GetAt(i).GetFilter() + _T(";");
+ mask[0] += strTemp;
+ filter += strTemp;
+ }
+
+ mask[0].TrimRight(_T(';'));
+ filter.TrimRight(_T(';'));
+ filter += _T("|");
+
+ for (size_t i = 0; i < GetCount(); i++) {
+ CMediaFormatCategory& mfc = GetAt(i);
+ if (!mfc.IsAudioOnly() || mfc.GetEngineType() != DirectShow) {
+ continue;
+ }
+ filter += mfc.GetDescription() + _T("|") + GetAt(i).GetFilter() + _T("|");
+ mask.Add(mfc.GetFilter());
+ }
+
+ filter += ResStr(IDS_AG_ALLFILES);
+ mask.Add(_T("*.*"));
+
+ filter += _T("|");
}
diff --git a/src/mpc-hc/MediaFormats.h b/src/mpc-hc/MediaFormats.h
index 12e12d871..eff473154 100644
--- a/src/mpc-hc/MediaFormats.h
+++ b/src/mpc-hc/MediaFormats.h
@@ -30,68 +30,68 @@
class CMediaFormatCategory
{
protected:
- CString m_label, m_description, m_specreqnote;
- CAtlList<CString> m_exts, m_backupexts;
- bool m_fAudioOnly;
- engine_t m_engine;
+ CString m_label, m_description, m_specreqnote;
+ CAtlList<CString> m_exts, m_backupexts;
+ bool m_fAudioOnly;
+ engine_t m_engine;
public:
- CMediaFormatCategory();
- CMediaFormatCategory(
- CString label, CString description, CAtlList<CString>& exts, bool fAudioOnly = false,
- CString specreqnote = _T(""), engine_t e = DirectShow);
- CMediaFormatCategory(
- CString label, CString description, CString exts, bool fAudioOnly = false,
- CString specreqnote = _T(""), engine_t e = DirectShow);
- virtual ~CMediaFormatCategory();
-
- void UpdateData(bool fSave);
-
- CMediaFormatCategory(const CMediaFormatCategory& mfc);
- CMediaFormatCategory& operator = (const CMediaFormatCategory& mfc);
-
- void RestoreDefaultExts();
- void SetExts(CAtlList<CString>& exts);
- void SetExts(CString exts);
-
- bool FindExt(CString ext) {
- return m_exts.Find(ext.TrimLeft(_T('.')).MakeLower()) != NULL;
- }
-
- CString GetLabel() const {return m_label;}
-
- CString GetDescription() const {return m_description;}
- CString GetFilter() const;
- CString GetExts(bool fAppendEngine = false) const;
- CString GetExtsWithPeriod(bool fAppendEngine = false) const;
- CString GetBackupExtsWithPeriod(bool fAppendEngine = false) const;
- CString GetSpecReqNote() const {return m_specreqnote;}
- bool IsAudioOnly() const {return m_fAudioOnly;}
- engine_t GetEngineType() const {return m_engine;}
- void SetEngineType(engine_t e) {m_engine = e;}
+ CMediaFormatCategory();
+ CMediaFormatCategory(
+ CString label, CString description, CAtlList<CString>& exts, bool fAudioOnly = false,
+ CString specreqnote = _T(""), engine_t e = DirectShow);
+ CMediaFormatCategory(
+ CString label, CString description, CString exts, bool fAudioOnly = false,
+ CString specreqnote = _T(""), engine_t e = DirectShow);
+ virtual ~CMediaFormatCategory();
+
+ void UpdateData(bool fSave);
+
+ CMediaFormatCategory(const CMediaFormatCategory& mfc);
+ CMediaFormatCategory& operator = (const CMediaFormatCategory& mfc);
+
+ void RestoreDefaultExts();
+ void SetExts(CAtlList<CString>& exts);
+ void SetExts(CString exts);
+
+ bool FindExt(CString ext) {
+ return m_exts.Find(ext.TrimLeft(_T('.')).MakeLower()) != NULL;
+ }
+
+ CString GetLabel() const {return m_label;}
+
+ CString GetDescription() const {return m_description;}
+ CString GetFilter() const;
+ CString GetExts(bool fAppendEngine = false) const;
+ CString GetExtsWithPeriod(bool fAppendEngine = false) const;
+ CString GetBackupExtsWithPeriod(bool fAppendEngine = false) const;
+ CString GetSpecReqNote() const {return m_specreqnote;}
+ bool IsAudioOnly() const {return m_fAudioOnly;}
+ engine_t GetEngineType() const {return m_engine;}
+ void SetEngineType(engine_t e) {m_engine = e;}
};
class CMediaFormats : public CAtlArray<CMediaFormatCategory>
{
protected:
- engine_t m_iRtspHandler;
- bool m_fRtspFileExtFirst;
+ engine_t m_iRtspHandler;
+ bool m_fRtspFileExtFirst;
public:
- CMediaFormats();
- virtual ~CMediaFormats();
+ CMediaFormats();
+ virtual ~CMediaFormats();
- void UpdateData(bool fSave);
+ void UpdateData(bool fSave);
- engine_t GetRtspHandler(bool& fRtspFileExtFirst);
- void SetRtspHandler(engine_t e, bool fRtspFileExtFirst);
+ engine_t GetRtspHandler(bool& fRtspFileExtFirst);
+ void SetRtspHandler(engine_t e, bool fRtspFileExtFirst);
- bool IsUsingEngine(CString path, engine_t e);
- engine_t GetEngine(CString path);
+ bool IsUsingEngine(CString path, engine_t e);
+ engine_t GetEngine(CString path);
- bool FindExt(CString ext, bool fAudioOnly = false);
- CMediaFormatCategory* FindMediaByExt(CString ext, bool fAudioOnly = false);
+ bool FindExt(CString ext, bool fAudioOnly = false);
+ CMediaFormatCategory* FindMediaByExt(CString ext, bool fAudioOnly = false);
- void GetFilter(CString& filter, CAtlArray<CString>& mask);
- void GetAudioFilter(CString& filter, CAtlArray<CString>& mask);
+ void GetFilter(CString& filter, CAtlArray<CString>& mask);
+ void GetAudioFilter(CString& filter, CAtlArray<CString>& mask);
};
diff --git a/src/mpc-hc/MediaTypesDlg.cpp b/src/mpc-hc/MediaTypesDlg.cpp
index 3774ae5bf..da0987a1a 100644
--- a/src/mpc-hc/MediaTypesDlg.cpp
+++ b/src/mpc-hc/MediaTypesDlg.cpp
@@ -32,11 +32,11 @@
//IMPLEMENT_DYNAMIC(CMediaTypesDlg, CResizableDialog)
CMediaTypesDlg::CMediaTypesDlg(IGraphBuilderDeadEnd* pGBDE, CWnd* pParent /*=NULL*/)
- : CResizableDialog(CMediaTypesDlg::IDD, pParent)
- , m_pGBDE(pGBDE)
+ : CResizableDialog(CMediaTypesDlg::IDD, pParent)
+ , m_pGBDE(pGBDE)
{
- m_subtype = GUID_NULL;
- m_type = UNKNOWN;
+ m_subtype = GUID_NULL;
+ m_type = UNKNOWN;
}
CMediaTypesDlg::~CMediaTypesDlg()
@@ -45,40 +45,40 @@ CMediaTypesDlg::~CMediaTypesDlg()
void CMediaTypesDlg::DoDataExchange(CDataExchange* pDX)
{
- CResizableDialog::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_COMBO1, m_pins);
- DDX_Control(pDX, IDC_EDIT1, m_report);
+ CResizableDialog::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_COMBO1, m_pins);
+ DDX_Control(pDX, IDC_EDIT1, m_report);
}
void CMediaTypesDlg::AddLine(CString str)
{
- str.Replace(_T("\n"), _T("\r\n"));
- int len = m_report.GetWindowTextLength();
- m_report.SetSel(len, len, TRUE);
- m_report.ReplaceSel(str);
+ str.Replace(_T("\n"), _T("\r\n"));
+ int len = m_report.GetWindowTextLength();
+ m_report.SetSel(len, len, TRUE);
+ m_report.ReplaceSel(str);
}
void CMediaTypesDlg::AddMediaType(AM_MEDIA_TYPE* pmt)
{
- m_subtype = pmt->subtype;
- if (pmt->majortype == MEDIATYPE_Video) {
- m_type = VIDEO;
- } else if (pmt->majortype == MEDIATYPE_Audio) {
- m_type = AUDIO;
- } else {
- m_type = UNKNOWN;
- }
-
- CAtlList<CString> sl;
- CMediaTypeEx(*pmt).Dump(sl);
- POSITION pos = sl.GetHeadPosition();
- while (pos) {
- AddLine(sl.GetNext(pos) + '\n');
- }
+ m_subtype = pmt->subtype;
+ if (pmt->majortype == MEDIATYPE_Video) {
+ m_type = VIDEO;
+ } else if (pmt->majortype == MEDIATYPE_Audio) {
+ m_type = AUDIO;
+ } else {
+ m_type = UNKNOWN;
+ }
+
+ CAtlList<CString> sl;
+ CMediaTypeEx(*pmt).Dump(sl);
+ POSITION pos = sl.GetHeadPosition();
+ while (pos) {
+ AddLine(sl.GetNext(pos) + '\n');
+ }
}
BEGIN_MESSAGE_MAP(CMediaTypesDlg, CResizableDialog)
- ON_CBN_SELCHANGE(IDC_COMBO1, OnCbnSelchangeCombo1)
+ ON_CBN_SELCHANGE(IDC_COMBO1, OnCbnSelchangeCombo1)
END_MESSAGE_MAP()
@@ -86,66 +86,66 @@ END_MESSAGE_MAP()
BOOL CMediaTypesDlg::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- CAtlList<CStringW> path;
- CAtlList<CMediaType> mts;
+ CAtlList<CStringW> path;
+ CAtlList<CMediaType> mts;
- for (int i = 0; S_OK == m_pGBDE->GetDeadEnd(i, path, mts); i++) {
- if (!path.GetCount()) {
- continue;
- }
- m_pins.SetItemData(m_pins.AddString(CString(path.GetTail())), (DWORD_PTR)i);
- }
+ for (int i = 0; S_OK == m_pGBDE->GetDeadEnd(i, path, mts); i++) {
+ if (!path.GetCount()) {
+ continue;
+ }
+ m_pins.SetItemData(m_pins.AddString(CString(path.GetTail())), (DWORD_PTR)i);
+ }
- m_pins.SetCurSel(0);
- OnCbnSelchangeCombo1();
+ m_pins.SetCurSel(0);
+ OnCbnSelchangeCombo1();
- AddAnchor(IDC_STATIC1, TOP_LEFT, TOP_RIGHT);
- AddAnchor(IDC_STATIC2, TOP_LEFT, TOP_RIGHT);
- AddAnchor(IDC_COMBO1, TOP_LEFT, TOP_RIGHT);
- AddAnchor(IDC_EDIT1, TOP_LEFT, BOTTOM_RIGHT);
- AddAnchor(IDOK, BOTTOM_RIGHT);
+ AddAnchor(IDC_STATIC1, TOP_LEFT, TOP_RIGHT);
+ AddAnchor(IDC_STATIC2, TOP_LEFT, TOP_RIGHT);
+ AddAnchor(IDC_COMBO1, TOP_LEFT, TOP_RIGHT);
+ AddAnchor(IDC_EDIT1, TOP_LEFT, BOTTOM_RIGHT);
+ AddAnchor(IDOK, BOTTOM_RIGHT);
- SetMinTrackSize(CSize(300, 200));
+ SetMinTrackSize(CSize(300, 200));
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CMediaTypesDlg::OnCbnSelchangeCombo1()
{
- m_report.SetWindowText(_T(""));
-
- int i = m_pins.GetCurSel();
- if (i < 0) {
- return;
- }
-
- CAtlList<CStringW> path;
- CAtlList<CMediaType> mts;
-
- if (FAILED(m_pGBDE->GetDeadEnd(i, path, mts)) || !path.GetCount()) {
- return;
- }
-
- POSITION pos = path.GetHeadPosition();
- while (pos) {
- AddLine(CString(path.GetNext(pos)) + _T("\n"));
- if (!pos) {
- AddLine(_T("\n"));
- }
- }
-
- pos = mts.GetHeadPosition();
- for (int j = 0; pos; j++) {
- CString str;
- str.Format(_T("Media Type %d:\n"), j);
- AddLine(str);
- AddLine(_T("--------------------------\n"));
- AddMediaType(&mts.GetNext(pos));
- AddLine();
- }
-
- m_report.SetSel(0, 0);
+ m_report.SetWindowText(_T(""));
+
+ int i = m_pins.GetCurSel();
+ if (i < 0) {
+ return;
+ }
+
+ CAtlList<CStringW> path;
+ CAtlList<CMediaType> mts;
+
+ if (FAILED(m_pGBDE->GetDeadEnd(i, path, mts)) || !path.GetCount()) {
+ return;
+ }
+
+ POSITION pos = path.GetHeadPosition();
+ while (pos) {
+ AddLine(CString(path.GetNext(pos)) + _T("\n"));
+ if (!pos) {
+ AddLine(_T("\n"));
+ }
+ }
+
+ pos = mts.GetHeadPosition();
+ for (int j = 0; pos; j++) {
+ CString str;
+ str.Format(_T("Media Type %d:\n"), j);
+ AddLine(str);
+ AddLine(_T("--------------------------\n"));
+ AddMediaType(&mts.GetNext(pos));
+ AddLine();
+ }
+
+ m_report.SetSel(0, 0);
}
diff --git a/src/mpc-hc/MediaTypesDlg.h b/src/mpc-hc/MediaTypesDlg.h
index db303971b..d11360977 100644
--- a/src/mpc-hc/MediaTypesDlg.h
+++ b/src/mpc-hc/MediaTypesDlg.h
@@ -33,29 +33,29 @@
class CMediaTypesDlg : public CResizableDialog
{
- // DECLARE_DYNAMIC(CMediaTypesDlg)
+ // DECLARE_DYNAMIC(CMediaTypesDlg)
private:
- CComPtr<IGraphBuilderDeadEnd> m_pGBDE;
- enum {UNKNOWN, VIDEO, AUDIO} m_type;
- GUID m_subtype;
- void AddLine(CString str = _T("\n"));
- void AddMediaType(AM_MEDIA_TYPE* pmt);
+ CComPtr<IGraphBuilderDeadEnd> m_pGBDE;
+ enum {UNKNOWN, VIDEO, AUDIO} m_type;
+ GUID m_subtype;
+ void AddLine(CString str = _T("\n"));
+ void AddMediaType(AM_MEDIA_TYPE* pmt);
public:
- CMediaTypesDlg(IGraphBuilderDeadEnd* pGBDE, CWnd* pParent = NULL); // standard constructor
- virtual ~CMediaTypesDlg();
+ CMediaTypesDlg(IGraphBuilderDeadEnd* pGBDE, CWnd* pParent = NULL); // standard constructor
+ virtual ~CMediaTypesDlg();
- // Dialog Data
- enum { IDD = IDD_MEDIATYPES_DLG };
- CComboBox m_pins;
- CEdit m_report;
+ // Dialog Data
+ enum { IDD = IDD_MEDIATYPES_DLG };
+ CComboBox m_pins;
+ CEdit m_report;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnCbnSelchangeCombo1();
+ afx_msg void OnCbnSelchangeCombo1();
};
diff --git a/src/mpc-hc/MiniDump.cpp b/src/mpc-hc/MiniDump.cpp
index 82cc782f2..0d819f1c8 100644
--- a/src/mpc-hc/MiniDump.cpp
+++ b/src/mpc-hc/MiniDump.cpp
@@ -29,133 +29,133 @@
#include "../DSUtil/WinAPIUtils.h"
-CMiniDump _Singleton;
-bool CMiniDump::m_bMiniDumpEnabled = true;
+CMiniDump _Singleton;
+bool CMiniDump::m_bMiniDumpEnabled = true;
-typedef BOOL (WINAPI *MINIDUMPWRITEDUMP)( HANDLE hProcess, DWORD dwPid, HANDLE hFile, MINIDUMP_TYPE DumpType,
- CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
- CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
- CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam
- );
+typedef BOOL (WINAPI* MINIDUMPWRITEDUMP)(HANDLE hProcess, DWORD dwPid, HANDLE hFile, MINIDUMP_TYPE DumpType,
+ CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
+ CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
+ CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam
+ );
CMiniDump::CMiniDump()
{
#ifndef _DEBUG
- SetUnhandledExceptionFilter( UnhandledExceptionFilter );
+ SetUnhandledExceptionFilter(UnhandledExceptionFilter);
-//#ifndef _WIN64
- // Enable catching in CRT (http://blog.kalmbachnet.de/?postid=75)
- // PreventSetUnhandledExceptionFilter();
-//#endif
+ //#ifndef _WIN64
+ // Enable catching in CRT (http://blog.kalmbachnet.de/?postid=75)
+ // PreventSetUnhandledExceptionFilter();
+ //#endif
#endif
}
-LPTOP_LEVEL_EXCEPTION_FILTER WINAPI MyDummySetUnhandledExceptionFilter( LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter )
+LPTOP_LEVEL_EXCEPTION_FILTER WINAPI MyDummySetUnhandledExceptionFilter(LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter)
{
- return NULL;
+ return NULL;
}
BOOL CMiniDump::PreventSetUnhandledExceptionFilter()
{
- HMODULE hKernel32 = LoadLibrary( _T("kernel32.dll") );
- if ( hKernel32 == NULL ) {
- return FALSE;
- }
-
- void *pOrgEntry = GetProcAddress( hKernel32, "SetUnhandledExceptionFilter" );
- if ( pOrgEntry == NULL ) {
- return FALSE;
- }
-
- unsigned char newJump[ 100 ];
- DWORD_PTR dwOrgEntryAddr = (DWORD_PTR)pOrgEntry;
- dwOrgEntryAddr += 5; // add 5 for 5 op-codes for jmp far
- void *pNewFunc = &MyDummySetUnhandledExceptionFilter;
- DWORD_PTR dwNewEntryAddr = (DWORD_PTR)pNewFunc;
- DWORD_PTR dwRelativeAddr = dwNewEntryAddr - dwOrgEntryAddr;
-
- newJump[ 0 ] = 0xE9; // JMP absolute
- memcpy( &newJump[ 1 ], &dwRelativeAddr, sizeof(pNewFunc) );
- SIZE_T bytesWritten;
- BOOL bRet = WriteProcessMemory( GetCurrentProcess(), pOrgEntry, newJump, sizeof(pNewFunc) + 1, &bytesWritten );
- FreeLibrary( hKernel32 );
- return bRet;
+ HMODULE hKernel32 = LoadLibrary(_T("kernel32.dll"));
+ if (hKernel32 == NULL) {
+ return FALSE;
+ }
+
+ void* pOrgEntry = GetProcAddress(hKernel32, "SetUnhandledExceptionFilter");
+ if (pOrgEntry == NULL) {
+ return FALSE;
+ }
+
+ unsigned char newJump[ 100 ];
+ DWORD_PTR dwOrgEntryAddr = (DWORD_PTR)pOrgEntry;
+ dwOrgEntryAddr += 5; // add 5 for 5 op-codes for jmp far
+ void* pNewFunc = &MyDummySetUnhandledExceptionFilter;
+ DWORD_PTR dwNewEntryAddr = (DWORD_PTR)pNewFunc;
+ DWORD_PTR dwRelativeAddr = dwNewEntryAddr - dwOrgEntryAddr;
+
+ newJump[ 0 ] = 0xE9; // JMP absolute
+ memcpy(&newJump[ 1 ], &dwRelativeAddr, sizeof(pNewFunc));
+ SIZE_T bytesWritten;
+ BOOL bRet = WriteProcessMemory(GetCurrentProcess(), pOrgEntry, newJump, sizeof(pNewFunc) + 1, &bytesWritten);
+ FreeLibrary(hKernel32);
+ return bRet;
}
-LONG WINAPI CMiniDump::UnhandledExceptionFilter( _EXCEPTION_POINTERS *lpTopLevelExceptionFilter )
+LONG WINAPI CMiniDump::UnhandledExceptionFilter(_EXCEPTION_POINTERS* lpTopLevelExceptionFilter)
{
- LONG retval = EXCEPTION_CONTINUE_SEARCH;
- HMODULE hDll = NULL;
- TCHAR szResult[800];
- CString strDumpPath;
-
- if ( !m_bMiniDumpEnabled ) {
- return retval;
- }
-
- hDll = ::LoadLibrary( _T("dbghelp.dll") );
-
- if ( hDll != NULL ) {
- MINIDUMPWRITEDUMP pMiniDumpWriteDump = (MINIDUMPWRITEDUMP)::GetProcAddress( hDll, "MiniDumpWriteDump" );
- if ( pMiniDumpWriteDump != NULL ) {
- if (!AfxGetMyApp()->IsIniValid()) {
- HRESULT hr = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, strDumpPath.GetBuffer(_MAX_PATH));
- if (FAILED(hr)) {
- return retval;
- }
-
- strDumpPath.ReleaseBuffer();
- strDumpPath.Append(_T("\\Media Player Classic\\"));
- strDumpPath.Append(AfxGetApp()->m_pszExeName);
- strDumpPath.Append(_T(".exe"));
- } else {
- GetModuleFileName(NULL, strDumpPath.GetBuffer(_MAX_PATH), _MAX_PATH);
- strDumpPath.ReleaseBuffer();
- }
- strDumpPath.AppendFormat(_T(".%d.%d.%d.%d.dmp"), MPC_VERSION_NUM);
-
- // create the file
- HANDLE hFile = ::CreateFile(strDumpPath, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS,
- FILE_ATTRIBUTE_NORMAL, NULL);
-
- if ( hFile != INVALID_HANDLE_VALUE ) {
- _MINIDUMP_EXCEPTION_INFORMATION ExInfo;
-
- ExInfo.ThreadId = ::GetCurrentThreadId();
- ExInfo.ExceptionPointers = lpTopLevelExceptionFilter;
- ExInfo.ClientPointers = NULL;
-
- // write the dump
- BOOL bOK = pMiniDumpWriteDump( GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &ExInfo, NULL, NULL );
- if ( bOK ) {
- _stprintf_s( szResult, _countof(szResult), ResStr(IDS_MPC_CRASH), strDumpPath );
- retval = EXCEPTION_EXECUTE_HANDLER;
- } else {
- _stprintf_s( szResult, _countof(szResult), ResStr(IDS_MPC_MINIDUMP_FAIL), strDumpPath, GetLastError() );
- }
-
- ::CloseHandle( hFile );
- } else {
- _stprintf_s( szResult, _countof(szResult), ResStr(IDS_MPC_MINIDUMP_FAIL), strDumpPath, GetLastError() );
- }
- }
- FreeLibrary( hDll );
- }
-
- if (szResult) {
- switch (MessageBox(NULL, szResult, _T("MPC-HC Mini Dump"), retval ? MB_YESNO : MB_OK)) {
- case IDYES:
- ShellExecute(NULL, _T("open"), _T("http://sourceforge.net/apps/trac/mpc-hc/wiki/Bugs_-_Reporting"), NULL, NULL, SW_SHOWDEFAULT);
- ExploreToFile(strDumpPath);
- break;
- case IDNO:
- retval = EXCEPTION_CONTINUE_SEARCH; // rethrow the exception to make easier attaching a debugger
- break;
- }
- }
-
- return retval;
+ LONG retval = EXCEPTION_CONTINUE_SEARCH;
+ HMODULE hDll = NULL;
+ TCHAR szResult[800];
+ CString strDumpPath;
+
+ if (!m_bMiniDumpEnabled) {
+ return retval;
+ }
+
+ hDll = ::LoadLibrary(_T("dbghelp.dll"));
+
+ if (hDll != NULL) {
+ MINIDUMPWRITEDUMP pMiniDumpWriteDump = (MINIDUMPWRITEDUMP)::GetProcAddress(hDll, "MiniDumpWriteDump");
+ if (pMiniDumpWriteDump != NULL) {
+ if (!AfxGetMyApp()->IsIniValid()) {
+ HRESULT hr = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, strDumpPath.GetBuffer(_MAX_PATH));
+ if (FAILED(hr)) {
+ return retval;
+ }
+
+ strDumpPath.ReleaseBuffer();
+ strDumpPath.Append(_T("\\Media Player Classic\\"));
+ strDumpPath.Append(AfxGetApp()->m_pszExeName);
+ strDumpPath.Append(_T(".exe"));
+ } else {
+ GetModuleFileName(NULL, strDumpPath.GetBuffer(_MAX_PATH), _MAX_PATH);
+ strDumpPath.ReleaseBuffer();
+ }
+ strDumpPath.AppendFormat(_T(".%d.%d.%d.%d.dmp"), MPC_VERSION_NUM);
+
+ // create the file
+ HANDLE hFile = ::CreateFile(strDumpPath, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL, NULL);
+
+ if (hFile != INVALID_HANDLE_VALUE) {
+ _MINIDUMP_EXCEPTION_INFORMATION ExInfo;
+
+ ExInfo.ThreadId = ::GetCurrentThreadId();
+ ExInfo.ExceptionPointers = lpTopLevelExceptionFilter;
+ ExInfo.ClientPointers = NULL;
+
+ // write the dump
+ BOOL bOK = pMiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &ExInfo, NULL, NULL);
+ if (bOK) {
+ _stprintf_s(szResult, _countof(szResult), ResStr(IDS_MPC_CRASH), strDumpPath);
+ retval = EXCEPTION_EXECUTE_HANDLER;
+ } else {
+ _stprintf_s(szResult, _countof(szResult), ResStr(IDS_MPC_MINIDUMP_FAIL), strDumpPath, GetLastError());
+ }
+
+ ::CloseHandle(hFile);
+ } else {
+ _stprintf_s(szResult, _countof(szResult), ResStr(IDS_MPC_MINIDUMP_FAIL), strDumpPath, GetLastError());
+ }
+ }
+ FreeLibrary(hDll);
+ }
+
+ if (szResult) {
+ switch (MessageBox(NULL, szResult, _T("MPC-HC Mini Dump"), retval ? MB_YESNO : MB_OK)) {
+ case IDYES:
+ ShellExecute(NULL, _T("open"), _T("http://sourceforge.net/apps/trac/mpc-hc/wiki/Bugs_-_Reporting"), NULL, NULL, SW_SHOWDEFAULT);
+ ExploreToFile(strDumpPath);
+ break;
+ case IDNO:
+ retval = EXCEPTION_CONTINUE_SEARCH; // rethrow the exception to make easier attaching a debugger
+ break;
+ }
+ }
+
+ return retval;
}
diff --git a/src/mpc-hc/MiniDump.h b/src/mpc-hc/MiniDump.h
index f1c7e1d56..4a240cec7 100644
--- a/src/mpc-hc/MiniDump.h
+++ b/src/mpc-hc/MiniDump.h
@@ -25,12 +25,12 @@
class CMiniDump
{
public:
- CMiniDump();
- static void Enable() {m_bMiniDumpEnabled = true;};
- static void Disable() {m_bMiniDumpEnabled = false;};
+ CMiniDump();
+ static void Enable() { m_bMiniDumpEnabled = true; };
+ static void Disable() { m_bMiniDumpEnabled = false; };
private :
- static LONG WINAPI UnhandledExceptionFilter(_EXCEPTION_POINTERS *lpTopLevelExceptionFilter);
- static BOOL PreventSetUnhandledExceptionFilter();
- static bool m_bMiniDumpEnabled;
+ static LONG WINAPI UnhandledExceptionFilter(_EXCEPTION_POINTERS* lpTopLevelExceptionFilter);
+ static BOOL PreventSetUnhandledExceptionFilter();
+ static bool m_bMiniDumpEnabled;
};
diff --git a/src/mpc-hc/Monitors.cpp b/src/mpc-hc/Monitors.cpp
index 4aa7f4552..76750a29e 100644
--- a/src/mpc-hc/Monitors.cpp
+++ b/src/mpc-hc/Monitors.cpp
@@ -30,162 +30,162 @@
CMonitors::CMonitors()
{
- // WARNING : GetSystemMetrics(SM_CMONITORS) return only visible display monitors, and EnumDisplayMonitors
- // enumerate visible and pseudo invisible monitors !!!
- // m_MonitorArray.SetSize( GetMonitorCount() );
+ // WARNING : GetSystemMetrics(SM_CMONITORS) return only visible display monitors, and EnumDisplayMonitors
+ // enumerate visible and pseudo invisible monitors !!!
+ // m_MonitorArray.SetSize( GetMonitorCount() );
- ADDMONITOR addMonitor;
- addMonitor.pMonitors = &m_MonitorArray;
- addMonitor.currentIndex = 0;
+ ADDMONITOR addMonitor;
+ addMonitor.pMonitors = &m_MonitorArray;
+ addMonitor.currentIndex = 0;
- ::EnumDisplayMonitors( NULL, NULL, AddMonitorsCallBack, (LPARAM)&addMonitor );
+ ::EnumDisplayMonitors(NULL, NULL, AddMonitorsCallBack, (LPARAM)&addMonitor);
}
CMonitors::~CMonitors()
{
- for ( int i = 0; i < m_MonitorArray.GetSize(); i++ ) {
- delete m_MonitorArray.GetAt( i );
- }
+ for (int i = 0; i < m_MonitorArray.GetSize(); i++) {
+ delete m_MonitorArray.GetAt(i);
+ }
}
// CMonitors member functions
-BOOL CALLBACK CMonitors::AddMonitorsCallBack( HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData )
+BOOL CALLBACK CMonitors::AddMonitorsCallBack(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
{
- LPADDMONITOR pAddMonitor = (LPADDMONITOR)dwData;
+ LPADDMONITOR pAddMonitor = (LPADDMONITOR)dwData;
- CMonitor* pMonitor = DNew CMonitor;
- pMonitor->Attach( hMonitor );
+ CMonitor* pMonitor = DNew CMonitor;
+ pMonitor->Attach(hMonitor);
- pAddMonitor->pMonitors->Add( pMonitor );
- pAddMonitor->currentIndex++;
+ pAddMonitor->pMonitors->Add(pMonitor);
+ pAddMonitor->currentIndex++;
- return TRUE;
+ return TRUE;
}
//
// returns the primary monitor
CMonitor CMonitors::GetPrimaryMonitor()
{
- //the primary monitor always has its origin at 0,0
- HMONITOR hMonitor = ::MonitorFromPoint( CPoint( 0,0 ), MONITOR_DEFAULTTOPRIMARY );
- ASSERT( IsMonitor( hMonitor ) );
+ //the primary monitor always has its origin at 0,0
+ HMONITOR hMonitor = ::MonitorFromPoint(CPoint(0, 0), MONITOR_DEFAULTTOPRIMARY);
+ ASSERT(IsMonitor(hMonitor));
- CMonitor monitor;
- monitor.Attach( hMonitor );
- ASSERT( monitor.IsPrimaryMonitor() );
+ CMonitor monitor;
+ monitor.Attach(hMonitor);
+ ASSERT(monitor.IsPrimaryMonitor());
- return monitor;
+ return monitor;
}
//
// is the given handle a valid monitor handle
-BOOL CMonitors::IsMonitor( const HMONITOR hMonitor )
+BOOL CMonitors::IsMonitor(const HMONITOR hMonitor)
{
- if ( hMonitor == NULL ) {
- return FALSE;
- }
+ if (hMonitor == NULL) {
+ return FALSE;
+ }
- MATCHMONITOR match;
- match.target = hMonitor;
- match.foundMatch = FALSE;
+ MATCHMONITOR match;
+ match.target = hMonitor;
+ match.foundMatch = FALSE;
- ::EnumDisplayMonitors( NULL, NULL, FindMatchingMonitorHandle, (LPARAM)&match );
+ ::EnumDisplayMonitors(NULL, NULL, FindMatchingMonitorHandle, (LPARAM)&match);
- return match.foundMatch;
+ return match.foundMatch;
}
//this is the callback method that gets called via IsMontior
-BOOL CALLBACK CMonitors::FindMatchingMonitorHandle( HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData )
+BOOL CALLBACK CMonitors::FindMatchingMonitorHandle(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
{
- LPMATCHMONITOR pMatch = (LPMATCHMONITOR)dwData;
+ LPMATCHMONITOR pMatch = (LPMATCHMONITOR)dwData;
- if ( hMonitor == pMatch->target ) {
- //found a monitor with the same handle we are looking for
- pMatch->foundMatch = TRUE;
- return FALSE; //stop enumerating
- }
+ if (hMonitor == pMatch->target) {
+ //found a monitor with the same handle we are looking for
+ pMatch->foundMatch = TRUE;
+ return FALSE; //stop enumerating
+ }
- //haven't found a match yet
- pMatch->foundMatch = FALSE;
- return TRUE; //keep enumerating
+ //haven't found a match yet
+ pMatch->foundMatch = FALSE;
+ return TRUE; //keep enumerating
}
BOOL CMonitors::AllMonitorsShareDisplayFormat()
{
- return ::GetSystemMetrics( SM_SAMEDISPLAYFORMAT );
+ return ::GetSystemMetrics(SM_SAMEDISPLAYFORMAT);
}
//
// the number of monitors on the system
int CMonitors::GetMonitorCount()
{
- return ::GetSystemMetrics(SM_CMONITORS);
+ return ::GetSystemMetrics(SM_CMONITORS);
}
-CMonitor CMonitors::GetMonitor( const int index ) const
+CMonitor CMonitors::GetMonitor(const int index) const
{
- ASSERT( index >= 0 && index < m_MonitorArray.GetCount() );
+ ASSERT(index >= 0 && index < m_MonitorArray.GetCount());
- CMonitor* pMonitor = static_cast<CMonitor*>(m_MonitorArray.GetAt( index ));
+ CMonitor* pMonitor = static_cast<CMonitor*>(m_MonitorArray.GetAt(index));
- return *pMonitor;
+ return *pMonitor;
}
//
// returns the rectangle that is the union of all active monitors
-void CMonitors::GetVirtualDesktopRect( LPRECT lprc )
+void CMonitors::GetVirtualDesktopRect(LPRECT lprc)
{
- ::SetRect( lprc,
- ::GetSystemMetrics( SM_XVIRTUALSCREEN ),
- ::GetSystemMetrics( SM_YVIRTUALSCREEN ),
- ::GetSystemMetrics( SM_CXVIRTUALSCREEN ),
- ::GetSystemMetrics( SM_CYVIRTUALSCREEN ) );
+ ::SetRect(lprc,
+ ::GetSystemMetrics(SM_XVIRTUALSCREEN),
+ ::GetSystemMetrics(SM_YVIRTUALSCREEN),
+ ::GetSystemMetrics(SM_CXVIRTUALSCREEN),
+ ::GetSystemMetrics(SM_CYVIRTUALSCREEN));
}
//
// these methods determine wheter the given item is
// visible on any monitor
-BOOL CMonitors::IsOnScreen( const LPRECT lprc )
+BOOL CMonitors::IsOnScreen(const LPRECT lprc)
{
- return ::MonitorFromRect( lprc, MONITOR_DEFAULTTONULL ) != NULL;
+ return ::MonitorFromRect(lprc, MONITOR_DEFAULTTONULL) != NULL;
}
-BOOL CMonitors::IsOnScreen( const POINT pt )
+BOOL CMonitors::IsOnScreen(const POINT pt)
{
- return ::MonitorFromPoint( pt, MONITOR_DEFAULTTONULL ) != NULL;
+ return ::MonitorFromPoint(pt, MONITOR_DEFAULTTONULL) != NULL;
}
-BOOL CMonitors::IsOnScreen( const CWnd* pWnd )
+BOOL CMonitors::IsOnScreen(const CWnd* pWnd)
{
- return ::MonitorFromWindow( pWnd->GetSafeHwnd(), MONITOR_DEFAULTTONULL ) != NULL;
+ return ::MonitorFromWindow(pWnd->GetSafeHwnd(), MONITOR_DEFAULTTONULL) != NULL;
}
-CMonitor CMonitors::GetNearestMonitor( const LPRECT lprc )
+CMonitor CMonitors::GetNearestMonitor(const LPRECT lprc)
{
- CMonitor monitor;
- monitor.Attach( ::MonitorFromRect( lprc, MONITOR_DEFAULTTONEAREST ) );
+ CMonitor monitor;
+ monitor.Attach(::MonitorFromRect(lprc, MONITOR_DEFAULTTONEAREST));
- return monitor;
+ return monitor;
}
-CMonitor CMonitors::GetNearestMonitor( const POINT pt )
+CMonitor CMonitors::GetNearestMonitor(const POINT pt)
{
- CMonitor monitor;
- monitor.Attach( ::MonitorFromPoint( pt, MONITOR_DEFAULTTONEAREST ) );
+ CMonitor monitor;
+ monitor.Attach(::MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST));
- return monitor;
+ return monitor;
}
-CMonitor CMonitors::GetNearestMonitor( const CWnd* pWnd )
+CMonitor CMonitors::GetNearestMonitor(const CWnd* pWnd)
{
- ASSERT( pWnd );
- ASSERT( ::IsWindow( pWnd->m_hWnd ) );
+ ASSERT(pWnd);
+ ASSERT(::IsWindow(pWnd->m_hWnd));
- CMonitor monitor;
- monitor.Attach( ::MonitorFromWindow( pWnd->GetSafeHwnd(), MONITOR_DEFAULTTONEAREST ) );
+ CMonitor monitor;
+ monitor.Attach(::MonitorFromWindow(pWnd->GetSafeHwnd(), MONITOR_DEFAULTTONEAREST));
- return monitor;
+ return monitor;
}
diff --git a/src/mpc-hc/Monitors.h b/src/mpc-hc/Monitors.h
index 8651e73b6..28de48e30 100644
--- a/src/mpc-hc/Monitors.h
+++ b/src/mpc-hc/Monitors.h
@@ -31,60 +31,60 @@
class CMonitors : public CObject
{
public:
- CMonitors();
- virtual ~CMonitors();
+ CMonitors();
+ virtual ~CMonitors();
- CMonitor GetMonitor( const int index ) const;
+ CMonitor GetMonitor(const int index) const;
- int GetCount() const {
- return (int)m_MonitorArray.GetCount();
- }
+ int GetCount() const {
+ return (int)m_MonitorArray.GetCount();
+ }
- //static members
- static CMonitor GetNearestMonitor( const LPRECT lprc );
- static CMonitor GetNearestMonitor( const POINT pt );
- static CMonitor GetNearestMonitor( const CWnd* pWnd );
+ //static members
+ static CMonitor GetNearestMonitor(const LPRECT lprc);
+ static CMonitor GetNearestMonitor(const POINT pt);
+ static CMonitor GetNearestMonitor(const CWnd* pWnd);
- static BOOL IsOnScreen( const POINT pt );
- static BOOL IsOnScreen( const CWnd* pWnd );
- static BOOL IsOnScreen( const LPRECT lprc );
+ static BOOL IsOnScreen(const POINT pt);
+ static BOOL IsOnScreen(const CWnd* pWnd);
+ static BOOL IsOnScreen(const LPRECT lprc);
- static void GetVirtualDesktopRect( LPRECT lprc );
+ static void GetVirtualDesktopRect(LPRECT lprc);
- static BOOL IsMonitor( const HMONITOR hMonitor );
+ static BOOL IsMonitor(const HMONITOR hMonitor);
- static CMonitor GetPrimaryMonitor();
- static BOOL AllMonitorsShareDisplayFormat();
+ static CMonitor GetPrimaryMonitor();
+ static BOOL AllMonitorsShareDisplayFormat();
- static int GetMonitorCount();
+ static int GetMonitorCount();
private:
- CObArray m_MonitorArray;
-
- typedef struct tagMATCHMONITOR {
- HMONITOR target;
- BOOL foundMatch;
- } MATCHMONITOR, *LPMATCHMONITOR;
-
- static BOOL CALLBACK FindMatchingMonitorHandle(
- HMONITOR hMonitor, // handle to display monitor
- HDC hdcMonitor, // handle to monitor DC
- LPRECT lprcMonitor, // monitor intersection rectangle
- LPARAM dwData // data
- );
-
-
- typedef struct tagADDMONITOR {
- CObArray* pMonitors;
- int currentIndex;
- } ADDMONITOR, *LPADDMONITOR;
-
- static BOOL CALLBACK AddMonitorsCallBack(
- HMONITOR hMonitor, // handle to display monitor
- HDC hdcMonitor, // handle to monitor DC
- LPRECT lprcMonitor, // monitor intersection rectangle
- LPARAM dwData // data
- );
+ CObArray m_MonitorArray;
+
+ typedef struct tagMATCHMONITOR {
+ HMONITOR target;
+ BOOL foundMatch;
+ } MATCHMONITOR, *LPMATCHMONITOR;
+
+ static BOOL CALLBACK FindMatchingMonitorHandle(
+ HMONITOR hMonitor, // handle to display monitor
+ HDC hdcMonitor, // handle to monitor DC
+ LPRECT lprcMonitor, // monitor intersection rectangle
+ LPARAM dwData // data
+ );
+
+
+ typedef struct tagADDMONITOR {
+ CObArray* pMonitors;
+ int currentIndex;
+ } ADDMONITOR, *LPADDMONITOR;
+
+ static BOOL CALLBACK AddMonitorsCallBack(
+ HMONITOR hMonitor, // handle to display monitor
+ HDC hdcMonitor, // handle to monitor DC
+ LPRECT lprcMonitor, // monitor intersection rectangle
+ LPARAM dwData // data
+ );
};
diff --git a/src/mpc-hc/MpcApi.h b/src/mpc-hc/MpcApi.h
index 6554299ff..a03d02975 100644
--- a/src/mpc-hc/MpcApi.h
+++ b/src/mpc-hc/MpcApi.h
@@ -29,8 +29,8 @@
// ..\bin\mpc-hc /slave 125421
//
// After startup, mpc-hc send a WM_COPYDATA message to host with COPYDATASTRUCT struct filled with :
-// - dwData : CMD_CONNECT
-// - lpData : Unicode string containing mpc-hc main window Handle
+// - dwData : CMD_CONNECT
+// - lpData : Unicode string containing mpc-hc main window Handle
//
// To pilot mpc-hc, send WM_COPYDATA messages to Hwnd provided on connection. All messages should be
// formatted as Unicode strings. For commands or notifications with multiple parameters, values are
@@ -38,37 +38,37 @@
// If a string contains a |, it will be escaped with a \ so a \| is not a separator
//
// Ex : When a file is opened, mpc-hc send to host the "now playing" notification :
-// - dwData : CMD_NOWPLAYING
-// - lpData : title|author|description|filename|duration
+// - dwData : CMD_NOWPLAYING
+// - lpData : title|author|description|filename|duration
//
// Ex : When a DVD is playing, use CMD_GETNOWPLAYING to get:
-// - dwData : CMD_NOWPLAYING
-// - lpData : dvddomain|titlenumber|numberofchapters|currentchapter|titleduration
-// dvddomains : DVD - Stopped, DVD - FirstPlay, DVD - RootMenu, DVD - TitleMenu, DVD - Title
+// - dwData : CMD_NOWPLAYING
+// - lpData : dvddomain|titlenumber|numberofchapters|currentchapter|titleduration
+// dvddomains : DVD - Stopped, DVD - FirstPlay, DVD - RootMenu, DVD - TitleMenu, DVD - Title
#pragma once
typedef enum MPC_LOADSTATE {
- MLS_CLOSED,
- MLS_LOADING,
- MLS_LOADED,
- MLS_CLOSING
+ MLS_CLOSED,
+ MLS_LOADING,
+ MLS_LOADED,
+ MLS_CLOSING
};
typedef enum MPC_PLAYSTATE {
- PS_PLAY = 0,
- PS_PAUSE = 1,
- PS_STOP = 2,
- PS_UNUSED = 3
+ PS_PLAY = 0,
+ PS_PAUSE = 1,
+ PS_STOP = 2,
+ PS_UNUSED = 3
};
struct MPC_OSDDATA {
- int nMsgPos; // screen position constant (see OSD_MESSAGEPOS constants)
- int nDurationMS; // duration in milliseconds
- TCHAR strMsg[128]; // message to display thought OSD
+ int nMsgPos; // screen position constant (see OSD_MESSAGEPOS constants)
+ int nDurationMS; // duration in milliseconds
+ TCHAR strMsg[128]; // message to display thought OSD
};
//// MPC_OSDDATA.nMsgPos constants (for host side programming):
//typedef enum
@@ -80,170 +80,170 @@ struct MPC_OSDDATA {
typedef enum MPCAPI_COMMAND {
- // ==== Commands from MPC to host
-
- // Send after connection
- // Par 1 : MPC window handle (command should be send to this HWnd)
- CMD_CONNECT = 0x50000000,
-
- // Send when opening or closing file
- // Par 1 : current state (see MPC_LOADSTATE enum)
- CMD_STATE = 0x50000001,
-
- // Send when playing, pausing or closing file
- // Par 1 : current play mode (see MPC_PLAYSTATE enum)
- CMD_PLAYMODE = 0x50000002,
-
- // Send after opening a new file
- // Par 1 : title
- // Par 2 : author
- // Par 3 : description
- // Par 4 : complete filename (path included)
- // Par 5 : duration in seconds
- CMD_NOWPLAYING = 0x50000003,
-
- // List of subtitle tracks
- // Par 1 : Subtitle track name 0
- // Par 2 : Subtitle track name 1
- // ...
- // Par n : Active subtitle track, -1 if subtitles disabled
- //
- // if no subtitle track present, returns -1
- // if no file loaded, returns -2
- CMD_LISTSUBTITLETRACKS = 0x50000004,
-
- // List of audio tracks
- // Par 1 : Audio track name 0
- // Par 2 : Audio track name 1
- // ...
- // Par n : Active audio track
- //
- // if no audio track present, returns -1
- // if no file loaded, returns -2
- CMD_LISTAUDIOTRACKS = 0x50000005,
-
- // Send current playback position in responce
- // of CMD_GETCURRENTPOSITION.
- // Par 1 : current position in seconds
- CMD_CURRENTPOSITION = 0x50000007,
-
- // Send the current playback position after a jump.
- // (Automatically sent after a seek event).
- // Par 1 : new playback position (in seconds).
- CMD_NOTIFYSEEK = 0x50000008,
-
- // Notify the end of current playback
- // (Automatically sent).
- // Par 1 : none.
- CMD_NOTIFYENDOFSTREAM = 0x50000009,
-
- // List of files in the playlist
- // Par 1 : file path 0
- // Par 2 : file path 1
- // ...
- // Par n : active file, -1 if no active file
- CMD_PLAYLIST = 0x50000006,
-
-
- // ==== Commands from host to MPC
-
- // Open new file
- // Par 1 : file path
- CMD_OPENFILE = 0xA0000000,
-
- // Stop playback, but keep file / playlist
- CMD_STOP = 0xA0000001,
-
- // Stop playback and close file / playlist
- CMD_CLOSEFILE = 0xA0000002,
-
- // Pause or restart playback
- CMD_PLAYPAUSE = 0xA0000003,
-
- // Add a new file to playlist (did not start playing)
- // Par 1 : file path
- CMD_ADDTOPLAYLIST = 0xA0001000,
-
- // Remove all files from playlist
- CMD_CLEARPLAYLIST = 0xA0001001,
-
- // Start playing playlist
- CMD_STARTPLAYLIST = 0xA0001002,
-
- CMD_REMOVEFROMPLAYLIST = 0xA0001003, // TODO
-
- // Cue current file to specific position
- // Par 1 : new position in seconds
- CMD_SETPOSITION = 0xA0002000,
-
- // Set the audio delay
- // Par 1 : new audio delay in ms
- CMD_SETAUDIODELAY = 0xA0002001,
-
- // Set the subtitle delay
- // Par 1 : new subtitle delay in ms
- CMD_SETSUBTITLEDELAY = 0xA0002002,
-
- // Set the active file in the playlist
- // Par 1 : index of the active file, -1 for no file selected
- // DOESN'T WORK
- CMD_SETINDEXPLAYLIST = 0xA0002003,
-
- // Set the audio track
- // Par 1 : index of the audio track
- CMD_SETAUDIOTRACK = 0xA0002004,
-
- // Set the subtitle track
- // Par 1 : index of the subtitle track, -1 for disabling subtitles
- CMD_SETSUBTITLETRACK = 0xA0002005,
-
- // Ask for a list of the subtitles tracks of the file
- // return a CMD_LISTSUBTITLETRACKS
- CMD_GETSUBTITLETRACKS = 0xA0003000,
+ // ==== Commands from MPC to host
+
+ // Send after connection
+ // Par 1 : MPC window handle (command should be send to this HWnd)
+ CMD_CONNECT = 0x50000000,
+
+ // Send when opening or closing file
+ // Par 1 : current state (see MPC_LOADSTATE enum)
+ CMD_STATE = 0x50000001,
+
+ // Send when playing, pausing or closing file
+ // Par 1 : current play mode (see MPC_PLAYSTATE enum)
+ CMD_PLAYMODE = 0x50000002,
+
+ // Send after opening a new file
+ // Par 1 : title
+ // Par 2 : author
+ // Par 3 : description
+ // Par 4 : complete filename (path included)
+ // Par 5 : duration in seconds
+ CMD_NOWPLAYING = 0x50000003,
+
+ // List of subtitle tracks
+ // Par 1 : Subtitle track name 0
+ // Par 2 : Subtitle track name 1
+ // ...
+ // Par n : Active subtitle track, -1 if subtitles disabled
+ //
+ // if no subtitle track present, returns -1
+ // if no file loaded, returns -2
+ CMD_LISTSUBTITLETRACKS = 0x50000004,
+
+ // List of audio tracks
+ // Par 1 : Audio track name 0
+ // Par 2 : Audio track name 1
+ // ...
+ // Par n : Active audio track
+ //
+ // if no audio track present, returns -1
+ // if no file loaded, returns -2
+ CMD_LISTAUDIOTRACKS = 0x50000005,
+
+ // Send current playback position in responce
+ // of CMD_GETCURRENTPOSITION.
+ // Par 1 : current position in seconds
+ CMD_CURRENTPOSITION = 0x50000007,
+
+ // Send the current playback position after a jump.
+ // (Automatically sent after a seek event).
+ // Par 1 : new playback position (in seconds).
+ CMD_NOTIFYSEEK = 0x50000008,
+
+ // Notify the end of current playback
+ // (Automatically sent).
+ // Par 1 : none.
+ CMD_NOTIFYENDOFSTREAM = 0x50000009,
+
+ // List of files in the playlist
+ // Par 1 : file path 0
+ // Par 2 : file path 1
+ // ...
+ // Par n : active file, -1 if no active file
+ CMD_PLAYLIST = 0x50000006,
+
+
+ // ==== Commands from host to MPC
+
+ // Open new file
+ // Par 1 : file path
+ CMD_OPENFILE = 0xA0000000,
+
+ // Stop playback, but keep file / playlist
+ CMD_STOP = 0xA0000001,
+
+ // Stop playback and close file / playlist
+ CMD_CLOSEFILE = 0xA0000002,
+
+ // Pause or restart playback
+ CMD_PLAYPAUSE = 0xA0000003,
+
+ // Add a new file to playlist (did not start playing)
+ // Par 1 : file path
+ CMD_ADDTOPLAYLIST = 0xA0001000,
+
+ // Remove all files from playlist
+ CMD_CLEARPLAYLIST = 0xA0001001,
+
+ // Start playing playlist
+ CMD_STARTPLAYLIST = 0xA0001002,
+
+ CMD_REMOVEFROMPLAYLIST = 0xA0001003, // TODO
+
+ // Cue current file to specific position
+ // Par 1 : new position in seconds
+ CMD_SETPOSITION = 0xA0002000,
+
+ // Set the audio delay
+ // Par 1 : new audio delay in ms
+ CMD_SETAUDIODELAY = 0xA0002001,
+
+ // Set the subtitle delay
+ // Par 1 : new subtitle delay in ms
+ CMD_SETSUBTITLEDELAY = 0xA0002002,
+
+ // Set the active file in the playlist
+ // Par 1 : index of the active file, -1 for no file selected
+ // DOESN'T WORK
+ CMD_SETINDEXPLAYLIST = 0xA0002003,
+
+ // Set the audio track
+ // Par 1 : index of the audio track
+ CMD_SETAUDIOTRACK = 0xA0002004,
+
+ // Set the subtitle track
+ // Par 1 : index of the subtitle track, -1 for disabling subtitles
+ CMD_SETSUBTITLETRACK = 0xA0002005,
+
+ // Ask for a list of the subtitles tracks of the file
+ // return a CMD_LISTSUBTITLETRACKS
+ CMD_GETSUBTITLETRACKS = 0xA0003000,
- // Ask for the current playback position,
- // see CMD_CURRENTPOSITION.
- // Par 1 : current position in seconds
- CMD_GETCURRENTPOSITION = 0xA0003004,
+ // Ask for the current playback position,
+ // see CMD_CURRENTPOSITION.
+ // Par 1 : current position in seconds
+ CMD_GETCURRENTPOSITION = 0xA0003004,
- // Jump forward/backward of N seconds,
- // Par 1 : seconds (negative values for backward)
- CMD_JUMPOFNSECONDS = 0xA0003005,
+ // Jump forward/backward of N seconds,
+ // Par 1 : seconds (negative values for backward)
+ CMD_JUMPOFNSECONDS = 0xA0003005,
- // Ask for a list of the audio tracks of the file
- // return a CMD_LISTAUDIOTRACKS
- CMD_GETAUDIOTRACKS = 0xA0003001,
+ // Ask for a list of the audio tracks of the file
+ // return a CMD_LISTAUDIOTRACKS
+ CMD_GETAUDIOTRACKS = 0xA0003001,
- // Ask for the properties of the current loaded file
- // return a CMD_NOWPLAYING
- CMD_GETNOWPLAYING = 0xA0003002,
+ // Ask for the properties of the current loaded file
+ // return a CMD_NOWPLAYING
+ CMD_GETNOWPLAYING = 0xA0003002,
- // Ask for the current playlist
- // return a CMD_PLAYLIST
- CMD_GETPLAYLIST = 0xA0003003,
+ // Ask for the current playlist
+ // return a CMD_PLAYLIST
+ CMD_GETPLAYLIST = 0xA0003003,
- // Toggle FullScreen
- CMD_TOGGLEFULLSCREEN = 0xA0004000,
+ // Toggle FullScreen
+ CMD_TOGGLEFULLSCREEN = 0xA0004000,
- // Jump forward(medium)
- CMD_JUMPFORWARDMED = 0xA0004001,
+ // Jump forward(medium)
+ CMD_JUMPFORWARDMED = 0xA0004001,
- // Jump backward(medium)
- CMD_JUMPBACKWARDMED = 0xA0004002,
+ // Jump backward(medium)
+ CMD_JUMPBACKWARDMED = 0xA0004002,
- // Increase Volume
- CMD_INCREASEVOLUME = 0xA0004003,
+ // Increase Volume
+ CMD_INCREASEVOLUME = 0xA0004003,
- // Decrease volume
- CMD_DECREASEVOLUME = 0xA0004004,
+ // Decrease volume
+ CMD_DECREASEVOLUME = 0xA0004004,
- // Shader toggle
- CMD_SHADER_TOGGLE = 0xA0004005,
+ // Shader toggle
+ CMD_SHADER_TOGGLE = 0xA0004005,
- // Close App
- CMD_CLOSEAPP = 0xA0004006,
+ // Close App
+ CMD_CLOSEAPP = 0xA0004006,
- // show host defined OSD message string
- CMD_OSDSHOWMESSAGE = 0xA0005000,
+ // show host defined OSD message string
+ CMD_OSDSHOWMESSAGE = 0xA0005000,
};
diff --git a/src/mpc-hc/Mpeg2SectionData.cpp b/src/mpc-hc/Mpeg2SectionData.cpp
index b4cf0b0cf..d87f05bc2 100644
--- a/src/mpc-hc/Mpeg2SectionData.cpp
+++ b/src/mpc-hc/Mpeg2SectionData.cpp
@@ -47,533 +47,533 @@
CMpeg2DataParser::CMpeg2DataParser(IBaseFilter* pFilter)
{
- m_pData = pFilter;
+ m_pData = pFilter;
- memset(&m_Filter, 0, sizeof(m_Filter));
- m_Filter.bVersionNumber = 1;
- m_Filter.wFilterSize = MPEG2_FILTER_VERSION_1_SIZE;
- m_Filter.fSpecifySectionNumber = TRUE;
+ memset(&m_Filter, 0, sizeof(m_Filter));
+ m_Filter.bVersionNumber = 1;
+ m_Filter.wFilterSize = MPEG2_FILTER_VERSION_1_SIZE;
+ m_Filter.fSpecifySectionNumber = TRUE;
}
-CString CMpeg2DataParser::ConvertString (BYTE* pBuffer, int nLength)
+CString CMpeg2DataParser::ConvertString(BYTE* pBuffer, int nLength)
{
- static const UINT16 codepages[0x20] = {
- 28591, // 00 - ISO 8859-1 Latin I
- 28595, // 01 - ISO 8859-5 Cyrillic
- 28596, // 02 - ISO 8859-6 Arabic
- 28597, // 03 - ISO 8859-7 Greek
- 28598, // 04 - ISO 8859-8 Hebrew
- 28599, // 05 - ISO 8859-9 Latin 5
- 28591, // 06 - ??? - ISO/IEC 8859-10 - Latin alphabet No. 6
- 28591, // 07 - ??? - ISO/IEC 8859-11 - Latin/Thai (draft only)
- 28591, // 08 - reserved
- 28603, // 09 - ISO 8859-13 - Estonian
- 28591, // 0a - ??? - ISO/IEC 8859-14 - Latin alphabet No. 8 (Celtic)
- 28605, // 0b - ISO 8859-15 Latin 9
- 28591, // 0c - reserved
- 28591, // 0d - reserved
- 28591, // 0e - reserved
- 28591, // 0f - reserved
- 0, // 10 - See codepages10 array
- 28591, // 11 - ??? - ISO/IEC 10646 - Basic Multilingual Plane (BMP)
- 28591, // 12 - ??? - KSX1001-2004 - Korean Character Set
- 20936, // 13 - Chinese Simplified (GB2312-80)
- 950, // 14 - Chinese Traditional (Big5)
- 28591, // 15 - ??? - UTF-8 encoding of ISO/IEC 10646 - Basic Multilingual Plane (BMP)
- 28591, // 16 - reserved
- 28591, // 17 - reserved
- 28591, // 18 - reserved
- 28591, // 19 - reserved
- 28591, // 1a - reserved
- 28591, // 1b - reserved
- 28591, // 1c - reserved
- 28591, // 1d - reserved
- 28591, // 1e - reserved
- 28591 // 1f - TODO!
- };
-
- static const UINT16 codepages10[0x10] = {
- 28591, // 00 - reserved
- 28591, // 01 - ISO 8859-1 Western European
- 28592, // 02 - ISO 8859-2 Central European
- 28593, // 03 - ISO 8859-3 Latin 3
- 28594, // 04 - ISO 8859-4 Baltic
- 28595, // 05 - ISO 8859-5 Cyrillic
- 28596, // 06 - ISO 8859-6 Arabic
- 28597, // 07 - ISO 8859-7 Greek
- 28598, // 08 - ISO 8859-8 Hebrew
- 28599, // 09 - ISO 8859-9 Turkish
- 28591, // 0a - ??? - ISO/IEC 8859-10
- 28591, // 0b - ??? - ISO/IEC 8859-11
- 28591, // 0c - ??? - ISO/IEC 8859-12
- 28603, // 0d - ISO 8859-13 Estonian
- 28591, // 0e - ??? - ISO/IEC 8859-14
- 28605, // 0f - ISO 8859-15 Latin 9
-
- // 0x10 to 0xFF - reserved for future use
- };
-
- UINT cp = CP_ACP;
- int nDestSize;
- CString strResult;
-
- if (nLength > 0) {
- if (pBuffer[0] == 0x10) {
- pBuffer++;
- nLength--;
- if (pBuffer[0] == 0x00) {
- cp = codepages10[pBuffer[1]];
- } else { // if (pBuffer[0] > 0x00)
- // reserved for future use, use default codepage
- cp = codepages[0];
- }
- pBuffer += 2;
- nLength -= 2;
- } else if (pBuffer[0] < 0x20) {
- cp = codepages[pBuffer[0]];
- pBuffer++;
- nLength--;
- } else { // No code page indication, use the default
- cp = codepages[0];
- }
- }
-
- nDestSize = MultiByteToWideChar (cp, MB_PRECOMPOSED, (LPCSTR)pBuffer, nLength, NULL, 0);
- if (nDestSize < 0) {
- return strResult;
- }
-
- MultiByteToWideChar (cp, MB_PRECOMPOSED, (LPCSTR)pBuffer, nLength, strResult.GetBuffer(nLength), nDestSize);
- strResult.ReleaseBuffer();
-
- return strResult;
+ static const UINT16 codepages[0x20] = {
+ 28591, // 00 - ISO 8859-1 Latin I
+ 28595, // 01 - ISO 8859-5 Cyrillic
+ 28596, // 02 - ISO 8859-6 Arabic
+ 28597, // 03 - ISO 8859-7 Greek
+ 28598, // 04 - ISO 8859-8 Hebrew
+ 28599, // 05 - ISO 8859-9 Latin 5
+ 28591, // 06 - ??? - ISO/IEC 8859-10 - Latin alphabet No. 6
+ 28591, // 07 - ??? - ISO/IEC 8859-11 - Latin/Thai (draft only)
+ 28591, // 08 - reserved
+ 28603, // 09 - ISO 8859-13 - Estonian
+ 28591, // 0a - ??? - ISO/IEC 8859-14 - Latin alphabet No. 8 (Celtic)
+ 28605, // 0b - ISO 8859-15 Latin 9
+ 28591, // 0c - reserved
+ 28591, // 0d - reserved
+ 28591, // 0e - reserved
+ 28591, // 0f - reserved
+ 0, // 10 - See codepages10 array
+ 28591, // 11 - ??? - ISO/IEC 10646 - Basic Multilingual Plane (BMP)
+ 28591, // 12 - ??? - KSX1001-2004 - Korean Character Set
+ 20936, // 13 - Chinese Simplified (GB2312-80)
+ 950, // 14 - Chinese Traditional (Big5)
+ 28591, // 15 - ??? - UTF-8 encoding of ISO/IEC 10646 - Basic Multilingual Plane (BMP)
+ 28591, // 16 - reserved
+ 28591, // 17 - reserved
+ 28591, // 18 - reserved
+ 28591, // 19 - reserved
+ 28591, // 1a - reserved
+ 28591, // 1b - reserved
+ 28591, // 1c - reserved
+ 28591, // 1d - reserved
+ 28591, // 1e - reserved
+ 28591 // 1f - TODO!
+ };
+
+ static const UINT16 codepages10[0x10] = {
+ 28591, // 00 - reserved
+ 28591, // 01 - ISO 8859-1 Western European
+ 28592, // 02 - ISO 8859-2 Central European
+ 28593, // 03 - ISO 8859-3 Latin 3
+ 28594, // 04 - ISO 8859-4 Baltic
+ 28595, // 05 - ISO 8859-5 Cyrillic
+ 28596, // 06 - ISO 8859-6 Arabic
+ 28597, // 07 - ISO 8859-7 Greek
+ 28598, // 08 - ISO 8859-8 Hebrew
+ 28599, // 09 - ISO 8859-9 Turkish
+ 28591, // 0a - ??? - ISO/IEC 8859-10
+ 28591, // 0b - ??? - ISO/IEC 8859-11
+ 28591, // 0c - ??? - ISO/IEC 8859-12
+ 28603, // 0d - ISO 8859-13 Estonian
+ 28591, // 0e - ??? - ISO/IEC 8859-14
+ 28605, // 0f - ISO 8859-15 Latin 9
+
+ // 0x10 to 0xFF - reserved for future use
+ };
+
+ UINT cp = CP_ACP;
+ int nDestSize;
+ CString strResult;
+
+ if (nLength > 0) {
+ if (pBuffer[0] == 0x10) {
+ pBuffer++;
+ nLength--;
+ if (pBuffer[0] == 0x00) {
+ cp = codepages10[pBuffer[1]];
+ } else { // if (pBuffer[0] > 0x00)
+ // reserved for future use, use default codepage
+ cp = codepages[0];
+ }
+ pBuffer += 2;
+ nLength -= 2;
+ } else if (pBuffer[0] < 0x20) {
+ cp = codepages[pBuffer[0]];
+ pBuffer++;
+ nLength--;
+ } else { // No code page indication, use the default
+ cp = codepages[0];
+ }
+ }
+
+ nDestSize = MultiByteToWideChar(cp, MB_PRECOMPOSED, (LPCSTR)pBuffer, nLength, NULL, 0);
+ if (nDestSize < 0) {
+ return strResult;
+ }
+
+ MultiByteToWideChar(cp, MB_PRECOMPOSED, (LPCSTR)pBuffer, nLength, strResult.GetBuffer(nLength), nDestSize);
+ strResult.ReleaseBuffer();
+
+ return strResult;
}
-DVB_STREAM_TYPE CMpeg2DataParser::ConvertToDVBType(PES_STREAM_TYPE nType)
+DVB_STREAM_TYPE CMpeg2DataParser::ConvertToDVBType(PES_STREAM_TYPE nType)
{
- switch (nType) {
- case VIDEO_STREAM_MPEG1 :
- case VIDEO_STREAM_MPEG2 :
- return DVB_MPV;
- case AUDIO_STREAM_MPEG1 :
- case AUDIO_STREAM_MPEG2 :
- return DVB_MPA;
- case VIDEO_STREAM_H264 :
- return DVB_H264;
- case AUDIO_STREAM_AC3 :
- return DVB_AC3;
- case AUDIO_STREAM_AC3_PLUS :
- return DVB_EAC3;
- case SUBTITLE_STREAM :
- return DVB_SUBTITLE;
- }
-
- return DVB_UNKNOWN;
+ switch (nType) {
+ case VIDEO_STREAM_MPEG1 :
+ case VIDEO_STREAM_MPEG2 :
+ return DVB_MPV;
+ case AUDIO_STREAM_MPEG1 :
+ case AUDIO_STREAM_MPEG2 :
+ return DVB_MPA;
+ case VIDEO_STREAM_H264 :
+ return DVB_H264;
+ case AUDIO_STREAM_AC3 :
+ return DVB_AC3;
+ case AUDIO_STREAM_AC3_PLUS :
+ return DVB_EAC3;
+ case SUBTITLE_STREAM :
+ return DVB_SUBTITLE;
+ }
+
+ return DVB_UNKNOWN;
}
HRESULT CMpeg2DataParser::ParseSIHeader(CGolombBuffer& gb, DVB_SI SIType, WORD& wSectionLength, WORD& wTSID)
{
- if (gb.BitRead(8) != SIType) {
- return ERROR_INVALID_DATA; // table_id
- }
- gb.BitRead(1); // section_syntax_indicator
- gb.BitRead(1); // reserved_future_use
- gb.BitRead(2); // reserved
- wSectionLength = (WORD)gb.BitRead(12); // section_length
- wTSID = (WORD)gb.BitRead(16); // transport_stream_id
- gb.BitRead(2); // reserved
- gb.BitRead(5); // version_number
- gb.BitRead(1); // current_next_indicator
- gb.BitRead(8); // section_number
- gb.BitRead(8); // last_section_number
-
- return S_OK;
+ if (gb.BitRead(8) != SIType) {
+ return ERROR_INVALID_DATA; // table_id
+ }
+ gb.BitRead(1); // section_syntax_indicator
+ gb.BitRead(1); // reserved_future_use
+ gb.BitRead(2); // reserved
+ wSectionLength = (WORD)gb.BitRead(12); // section_length
+ wTSID = (WORD)gb.BitRead(16); // transport_stream_id
+ gb.BitRead(2); // reserved
+ gb.BitRead(5); // version_number
+ gb.BitRead(1); // current_next_indicator
+ gb.BitRead(8); // section_number
+ gb.BitRead(8); // last_section_number
+
+ return S_OK;
}
HRESULT CMpeg2DataParser::ParseSDT(ULONG ulFreq)
{
- HRESULT hr;
- CComPtr<ISectionList> pSectionList;
- DWORD dwLength;
- PSECTION data;
- WORD wTSID;
- WORD wONID;
- WORD wSectionLength;
-
- CheckNoLog (m_pData->GetSection (PID_SDT, SI_SDT, &m_Filter, 5000, &pSectionList));
- CheckNoLog (pSectionList->GetSectionData (0, &dwLength, &data));
-
- CGolombBuffer gb ((BYTE*)data, dwLength);
-
- // service_description_section()
- CheckNoLog (ParseSIHeader (gb, SI_SDT, wSectionLength, wTSID));
-
- wONID = (WORD)gb.BitRead(16); // original_network_id
- gb.BitRead(8); // reserved_future_use
-
- while (gb.GetSize() - gb.GetPos() > 4) {
- CDVBChannel Channel;
- Channel.SetFrequency (ulFreq);
- Channel.SetTSID (wTSID);
- Channel.SetONID (wONID);
- Channel.SetSID ((ULONG)gb.BitRead(16)); // service_id uimsbf
- gb.BitRead(6); // reserved_future_use bslbf
- gb.BitRead(1); // EIT_schedule_flag bslbf
- Channel.SetNowNextFlag(!!gb.BitRead(1)); // EIT_present_following_flag bslbf
- gb.BitRead(3); // running_status uimsbf
- Channel.SetEncrypted (!!gb.BitRead(1)); // free_CA_mode bslbf
-
- // Descriptors:
- BeginEnumDescriptors(gb, nType, nLength) {
- switch (nType) {
- case DT_SERVICE :
- gb.BitRead(8); // service_type
- nLength = (WORD)gb.BitRead(8); // service_provider_name_length
- gb.ReadBuffer (DescBuffer, nLength); // service_provider_name
-
- nLength = (WORD)gb.BitRead(8); // service_name_length
- gb.ReadBuffer (DescBuffer, nLength); // service_name
- DescBuffer[nLength] = 0;
- Channel.SetName (ConvertString (DescBuffer, nLength));
- TRACE ("%15S %d\n", Channel.GetName(), Channel.GetSID());
- break;
- default :
- SkipDescriptor (gb, nType, nLength); // descriptor()
- break;
- }
- }
- EndEnumDescriptors
-
-
- if (!Channels.Lookup(Channel.GetSID())) {
- Channels [Channel.GetSID()] = Channel;
- }
- }
-
- return S_OK;
+ HRESULT hr;
+ CComPtr<ISectionList> pSectionList;
+ DWORD dwLength;
+ PSECTION data;
+ WORD wTSID;
+ WORD wONID;
+ WORD wSectionLength;
+
+ CheckNoLog(m_pData->GetSection(PID_SDT, SI_SDT, &m_Filter, 5000, &pSectionList));
+ CheckNoLog(pSectionList->GetSectionData(0, &dwLength, &data));
+
+ CGolombBuffer gb((BYTE*)data, dwLength);
+
+ // service_description_section()
+ CheckNoLog(ParseSIHeader(gb, SI_SDT, wSectionLength, wTSID));
+
+ wONID = (WORD)gb.BitRead(16); // original_network_id
+ gb.BitRead(8); // reserved_future_use
+
+ while (gb.GetSize() - gb.GetPos() > 4) {
+ CDVBChannel Channel;
+ Channel.SetFrequency(ulFreq);
+ Channel.SetTSID(wTSID);
+ Channel.SetONID(wONID);
+ Channel.SetSID((ULONG)gb.BitRead(16)); // service_id uimsbf
+ gb.BitRead(6); // reserved_future_use bslbf
+ gb.BitRead(1); // EIT_schedule_flag bslbf
+ Channel.SetNowNextFlag(!!gb.BitRead(1)); // EIT_present_following_flag bslbf
+ gb.BitRead(3); // running_status uimsbf
+ Channel.SetEncrypted(!!gb.BitRead(1)); // free_CA_mode bslbf
+
+ // Descriptors:
+ BeginEnumDescriptors(gb, nType, nLength) {
+ switch (nType) {
+ case DT_SERVICE :
+ gb.BitRead(8); // service_type
+ nLength = (WORD)gb.BitRead(8); // service_provider_name_length
+ gb.ReadBuffer(DescBuffer, nLength); // service_provider_name
+
+ nLength = (WORD)gb.BitRead(8); // service_name_length
+ gb.ReadBuffer(DescBuffer, nLength); // service_name
+ DescBuffer[nLength] = 0;
+ Channel.SetName(ConvertString(DescBuffer, nLength));
+ TRACE("%15S %d\n", Channel.GetName(), Channel.GetSID());
+ break;
+ default :
+ SkipDescriptor(gb, nType, nLength); // descriptor()
+ break;
+ }
+ }
+ EndEnumDescriptors
+
+
+ if (!Channels.Lookup(Channel.GetSID())) {
+ Channels [Channel.GetSID()] = Channel;
+ }
+ }
+
+ return S_OK;
}
HRESULT CMpeg2DataParser::ParsePAT()
{
- HRESULT hr;
- CComPtr<ISectionList> pSectionList;
- DWORD dwLength;
- PSECTION data;
- WORD wTSID;
- WORD wSectionLength;
-
- CheckNoLog (m_pData->GetSection (PID_PAT, SI_PAT, &m_Filter, 5000, &pSectionList));
- CheckNoLog (pSectionList->GetSectionData (0, &dwLength, &data));
-
- CGolombBuffer gb ((BYTE*)data, dwLength);
-
- // program_association_section()
- CheckNoLog (ParseSIHeader (gb, SI_PAT, wSectionLength, wTSID));
- while (gb.GetSize() - gb.GetPos() > 4) {
- WORD program_number = (WORD)gb.BitRead(16); // program_number
- gb.BitRead(3); // reserved
- if (program_number == 0) {
- gb.BitRead(13); // network_PID
- } else {
- WORD program_map_PID = (WORD)gb.BitRead(13); // program_map_PID
- if (Channels.Lookup(program_number)) {
- Channels [program_number].SetPMT (program_map_PID);
- ParsePMT (Channels [program_number]);
- }
- }
- }
-
- return S_OK;
+ HRESULT hr;
+ CComPtr<ISectionList> pSectionList;
+ DWORD dwLength;
+ PSECTION data;
+ WORD wTSID;
+ WORD wSectionLength;
+
+ CheckNoLog(m_pData->GetSection(PID_PAT, SI_PAT, &m_Filter, 5000, &pSectionList));
+ CheckNoLog(pSectionList->GetSectionData(0, &dwLength, &data));
+
+ CGolombBuffer gb((BYTE*)data, dwLength);
+
+ // program_association_section()
+ CheckNoLog(ParseSIHeader(gb, SI_PAT, wSectionLength, wTSID));
+ while (gb.GetSize() - gb.GetPos() > 4) {
+ WORD program_number = (WORD)gb.BitRead(16); // program_number
+ gb.BitRead(3); // reserved
+ if (program_number == 0) {
+ gb.BitRead(13); // network_PID
+ } else {
+ WORD program_map_PID = (WORD)gb.BitRead(13); // program_map_PID
+ if (Channels.Lookup(program_number)) {
+ Channels [program_number].SetPMT(program_map_PID);
+ ParsePMT(Channels [program_number]);
+ }
+ }
+ }
+
+ return S_OK;
}
HRESULT CMpeg2DataParser::ParsePMT(CDVBChannel& Channel)
{
- HRESULT hr;
- CComPtr<ISectionList> pSectionList;
- DWORD dwLength;
- PSECTION data;
- WORD wTSID;
- WORD wSectionLength;
-
- CheckNoLog (m_pData->GetSection (Channel.GetPMT(), SI_PMT, &m_Filter, 5000, &pSectionList));
- CheckNoLog (pSectionList->GetSectionData (0, &dwLength, &data));
-
- CGolombBuffer gb ((BYTE*)data, dwLength);
-
- // TS_program_map_section()
- CheckNoLog (ParseSIHeader (gb, SI_PMT, wSectionLength, wTSID));
-
- gb.BitRead(3); // reserved
- Channel.SetPCR((ULONG)gb.BitRead(13)); // PCR_PID
- gb.BitRead(4); // reserved
- BeginEnumDescriptors(gb, nType, nLength) { // for (i=0;i<N;i++) {
- SkipDescriptor (gb, nType, nLength); // descriptor()
- }
- EndEnumDescriptors
-
-
- while (gb.GetSize() - gb.GetPos() > 4) {
- PES_STREAM_TYPE pes_stream_type;
- DVB_STREAM_TYPE dvb_stream_type;
- WORD wPID;
- CString strLanguage;
-
- pes_stream_type = (PES_STREAM_TYPE)gb.BitRead(8); // stream_type
- gb.BitRead(3); // reserved
- wPID = (WORD)gb.BitRead(13); // elementary_PID
- gb.BitRead(4); // reserved
-
- BeginEnumDescriptors(gb, nType, nLength) { // ES_info_length
- switch (nType) {
- case DT_ISO_639_LANGUAGE :
- gb.ReadBuffer(DescBuffer, nLength);
- strLanguage = ConvertString (DescBuffer, 3);
- break;
- case DT_AC3_AUDIO :
- pes_stream_type = AUDIO_STREAM_AC3;
- SkipDescriptor (gb, nType, nLength);
- break;
- case DT_EXTENDED_AC3_AUDIO :
- pes_stream_type = AUDIO_STREAM_AC3_PLUS;
- SkipDescriptor (gb, nType, nLength);
- break;
- case DT_SUBTITLING : {
- gb.ReadBuffer(DescBuffer, nLength);
- strLanguage = ConvertString (DescBuffer, 3);
- pes_stream_type = SUBTITLE_STREAM;
- }
- break;
- default :
- SkipDescriptor (gb, nType, nLength);
- break;
- }
- }
- EndEnumDescriptors
- if ((dvb_stream_type = ConvertToDVBType(pes_stream_type)) != DVB_UNKNOWN) {
- Channel.AddStreamInfo (wPID, dvb_stream_type, pes_stream_type, strLanguage);
- }
- }
-
- return S_OK;
+ HRESULT hr;
+ CComPtr<ISectionList> pSectionList;
+ DWORD dwLength;
+ PSECTION data;
+ WORD wTSID;
+ WORD wSectionLength;
+
+ CheckNoLog(m_pData->GetSection(Channel.GetPMT(), SI_PMT, &m_Filter, 5000, &pSectionList));
+ CheckNoLog(pSectionList->GetSectionData(0, &dwLength, &data));
+
+ CGolombBuffer gb((BYTE*)data, dwLength);
+
+ // TS_program_map_section()
+ CheckNoLog(ParseSIHeader(gb, SI_PMT, wSectionLength, wTSID));
+
+ gb.BitRead(3); // reserved
+ Channel.SetPCR((ULONG)gb.BitRead(13)); // PCR_PID
+ gb.BitRead(4); // reserved
+ BeginEnumDescriptors(gb, nType, nLength) { // for (i=0;i<N;i++) {
+ SkipDescriptor(gb, nType, nLength); // descriptor()
+ }
+ EndEnumDescriptors
+
+
+ while (gb.GetSize() - gb.GetPos() > 4) {
+ PES_STREAM_TYPE pes_stream_type;
+ DVB_STREAM_TYPE dvb_stream_type;
+ WORD wPID;
+ CString strLanguage;
+
+ pes_stream_type = (PES_STREAM_TYPE)gb.BitRead(8); // stream_type
+ gb.BitRead(3); // reserved
+ wPID = (WORD)gb.BitRead(13); // elementary_PID
+ gb.BitRead(4); // reserved
+
+ BeginEnumDescriptors(gb, nType, nLength) { // ES_info_length
+ switch (nType) {
+ case DT_ISO_639_LANGUAGE :
+ gb.ReadBuffer(DescBuffer, nLength);
+ strLanguage = ConvertString(DescBuffer, 3);
+ break;
+ case DT_AC3_AUDIO :
+ pes_stream_type = AUDIO_STREAM_AC3;
+ SkipDescriptor(gb, nType, nLength);
+ break;
+ case DT_EXTENDED_AC3_AUDIO :
+ pes_stream_type = AUDIO_STREAM_AC3_PLUS;
+ SkipDescriptor(gb, nType, nLength);
+ break;
+ case DT_SUBTITLING : {
+ gb.ReadBuffer(DescBuffer, nLength);
+ strLanguage = ConvertString(DescBuffer, 3);
+ pes_stream_type = SUBTITLE_STREAM;
+ }
+ break;
+ default :
+ SkipDescriptor(gb, nType, nLength);
+ break;
+ }
+ }
+ EndEnumDescriptors
+ if ((dvb_stream_type = ConvertToDVBType(pes_stream_type)) != DVB_UNKNOWN) {
+ Channel.AddStreamInfo(wPID, dvb_stream_type, pes_stream_type, strLanguage);
+ }
+ }
+
+ return S_OK;
}
-HRESULT CMpeg2DataParser::SetTime(CGolombBuffer& gb, PresentFollowing &NowNext)
+HRESULT CMpeg2DataParser::SetTime(CGolombBuffer& gb, PresentFollowing& NowNext)
{
- char descBuffer[10];
- time_t tTime1 ,tTime2;
- tm tmTime1, tmTime2;
- long nDuration;
- long timezone;
- int daylight;
-
- // init tm structures
- time( &tTime1 );
- localtime_s(&tmTime1, &tTime1);
- _tzset();
- _get_timezone(&timezone); // The difference in seconds between UTC and local time.
- if (!_get_daylight(&daylight)) {
- timezone -= daylight * 3600;
- }
-
- // Start time:
- tmTime1.tm_hour = (int)(gb.BitRead(4)*10);
- tmTime1.tm_hour += (int)gb.BitRead(4);
- tmTime1.tm_min = (int)(gb.BitRead(4)*10);
- tmTime1.tm_min += (int)gb.BitRead(4);
- tmTime1.tm_sec = (int)(gb.BitRead(4)*10);
- tmTime1.tm_sec += (int)gb.BitRead(4);
- tTime1 = mktime(&tmTime1) - timezone;
- localtime_s(&tmTime2, &tTime1);
- tTime1 = mktime(&tmTime2);
- strftime(descBuffer, 6, "%H:%M", &tmTime2);
- descBuffer[6] = '\0';
- NowNext.StartTime = descBuffer;
-
- // Duration:
- nDuration = (long)(36000*gb.BitRead(4));
- nDuration += (long)(3600*gb.BitRead(4));
- nDuration += (long)(600*gb.BitRead(4));
- nDuration += (long)(60*gb.BitRead(4));
- nDuration += (long)(10*gb.BitRead(4));
- nDuration += (long)gb.BitRead(4);
-
- tTime2 = tTime1 + nDuration;
- localtime_s(&tmTime2, &tTime2);
- strftime(descBuffer, 6, "%H:%M", &tmTime2);
- descBuffer[6] = '\0';
- NowNext.Duration = descBuffer;
-
- return S_OK;
+ char descBuffer[10];
+ time_t tTime1, tTime2;
+ tm tmTime1, tmTime2;
+ long nDuration;
+ long timezone;
+ int daylight;
+
+ // init tm structures
+ time(&tTime1);
+ localtime_s(&tmTime1, &tTime1);
+ _tzset();
+ _get_timezone(&timezone); // The difference in seconds between UTC and local time.
+ if (!_get_daylight(&daylight)) {
+ timezone -= daylight * 3600;
+ }
+
+ // Start time:
+ tmTime1.tm_hour = (int)(gb.BitRead(4) * 10);
+ tmTime1.tm_hour += (int)gb.BitRead(4);
+ tmTime1.tm_min = (int)(gb.BitRead(4) * 10);
+ tmTime1.tm_min += (int)gb.BitRead(4);
+ tmTime1.tm_sec = (int)(gb.BitRead(4) * 10);
+ tmTime1.tm_sec += (int)gb.BitRead(4);
+ tTime1 = mktime(&tmTime1) - timezone;
+ localtime_s(&tmTime2, &tTime1);
+ tTime1 = mktime(&tmTime2);
+ strftime(descBuffer, 6, "%H:%M", &tmTime2);
+ descBuffer[6] = '\0';
+ NowNext.StartTime = descBuffer;
+
+ // Duration:
+ nDuration = (long)(36000 * gb.BitRead(4));
+ nDuration += (long)(3600 * gb.BitRead(4));
+ nDuration += (long)(600 * gb.BitRead(4));
+ nDuration += (long)(60 * gb.BitRead(4));
+ nDuration += (long)(10 * gb.BitRead(4));
+ nDuration += (long)gb.BitRead(4);
+
+ tTime2 = tTime1 + nDuration;
+ localtime_s(&tmTime2, &tTime2);
+ strftime(descBuffer, 6, "%H:%M", &tmTime2);
+ descBuffer[6] = '\0';
+ NowNext.Duration = descBuffer;
+
+ return S_OK;
}
-HRESULT CMpeg2DataParser::ParseEIT(ULONG ulSID, PresentFollowing &NowNext)
+HRESULT CMpeg2DataParser::ParseEIT(ULONG ulSID, PresentFollowing& NowNext)
{
- HRESULT hr;
- CComPtr<ISectionList> pSectionList;
- DWORD dwLength;
- PSECTION data;
- ULONG ulGetSID;
- EventInformationSection InfoEvent;
- int nLen;
- int descriptorNumber;
- int itemsLength;
- CString itemDesc, itemText;
- CString text;
-
- do {
- CheckNoLog (m_pData->GetSection (PID_EIT, SI_EIT_act, NULL, 5000, &pSectionList));
-
- CheckNoLog (pSectionList->GetSectionData (0, &dwLength, &data));
- CGolombBuffer gb ((BYTE*)data, dwLength);
-
- InfoEvent.TableID = (UINT8)gb.BitRead(8);
- InfoEvent.SectionSyntaxIndicator = (WORD)gb.BitRead(1);
- gb.BitRead(3);
- InfoEvent.SectionLength = (WORD)gb.BitRead(12);
- ulGetSID = (ULONG)gb.BitRead(8);
- ulGetSID += 0x100 * (ULONG)gb.BitRead(8);
- InfoEvent.ServiceId = ulGetSID; // This is really strange, ServiceID should be uimsbf ???
- gb.BitRead(2);
- InfoEvent.VersionNumber = (UINT8)gb.BitRead(5);
- InfoEvent.CurrentNextIndicator = (UINT8)gb.BitRead(1);
-
- InfoEvent.SectionNumber = (UINT8)gb.BitRead(8);
- InfoEvent.LastSectionNumber = (UINT8)gb.BitRead(8);
- InfoEvent.TransportStreamID = (WORD)gb.BitRead(16);
- InfoEvent.OriginalNetworkID = (WORD)gb.BitRead(16);
- InfoEvent.SegmentLastSectionNumber = (UINT8)gb.BitRead(8);
- InfoEvent.LastTableID = (UINT8)gb.BitRead(8);
-
- // Info event
- InfoEvent.EventID = (WORD)gb.BitRead(16);
- InfoEvent.StartDate = (WORD)gb.BitRead(16);
- SetTime(gb, NowNext);
-
- InfoEvent.RunninStatus = (WORD)gb.BitRead(3);
- InfoEvent.FreeCAMode = (WORD)gb.BitRead(1);
-
- NowNext.ExtendedDescriptorsItems.RemoveAll();
- NowNext.ExtendedDescriptorsTexts.RemoveAll();
-
- if ((InfoEvent.ServiceId == ulSID) && (InfoEvent.CurrentNextIndicator == 1) && (InfoEvent.RunninStatus == 4)) {
- // Descriptors:
- BeginEnumDescriptors(gb, nType, nLength) {
- switch (nType) {
- case DT_SHORT_EVENT:
- gb.BitRead(24); // ISO_639_language_code
-
- nLen = (UINT8)gb.BitRead(8); // event_name_length
- gb.ReadBuffer(DescBuffer, nLen);
- NowNext.cPresent = ConvertString(DescBuffer, nLen);
-
- nLen = (UINT8)gb.BitRead(8); // text_length
- gb.ReadBuffer(DescBuffer, nLen);
- NowNext.SummaryDesc = ConvertString(DescBuffer, nLen);
- break;
- case DT_EXTENDED_EVENT:
- descriptorNumber = (UINT8)gb.BitRead(4); // descriptor_number
- gb.BitRead(4); // last_descriptor_number
- gb.BitRead(24); // ISO_639_language_code
-
- itemsLength = (UINT8)gb.BitRead(8); // length_of_items
- while (itemsLength > 0) {
- nLen = (UINT8)gb.BitRead(8); // item_description_length
- gb.ReadBuffer(DescBuffer, nLen);
- itemDesc = ConvertString(DescBuffer, nLen);
- itemsLength -= nLen + 1;
-
- nLen = (UINT8)gb.BitRead(8); // item_length
- gb.ReadBuffer(DescBuffer, nLen);
- itemText = ConvertString(DescBuffer, nLen);
- itemsLength -= nLen + 1;
-
- NowNext.ExtendedDescriptorsItems.SetAt(itemDesc, itemText);
- }
-
- nLen = (UINT8)gb.BitRead(8); // text_length
- gb.ReadBuffer(DescBuffer, nLen);
- text = ConvertString(DescBuffer, nLen);
- if (descriptorNumber == 0) { // new descriptor set
- NowNext.ExtendedDescriptorsTexts.AddTail(text);
- } else {
- NowNext.ExtendedDescriptorsTexts.GetTail().Append(text);
- }
- break;
- default:
- SkipDescriptor (gb, nType, nLength);
- break;
- }
- }
- EndEnumDescriptors
- }
- m_Filter.SectionNumber++;
- pSectionList.Release();
- } while (((InfoEvent.ServiceId != ulSID) || (InfoEvent.CurrentNextIndicator != 1) || (InfoEvent.RunninStatus != 4)) &&
- (m_Filter.SectionNumber <= 22));
-
- if (InfoEvent.ServiceId != ulSID) {
- NowNext.StartTime = _T("");
- NowNext.Duration = _T("");
- NowNext.cPresent = _T(" Info not available.");
- NowNext.SummaryDesc = _T("");
- NowNext.cFollowing = _T("");
- }
-
- return S_OK;
+ HRESULT hr;
+ CComPtr<ISectionList> pSectionList;
+ DWORD dwLength;
+ PSECTION data;
+ ULONG ulGetSID;
+ EventInformationSection InfoEvent;
+ int nLen;
+ int descriptorNumber;
+ int itemsLength;
+ CString itemDesc, itemText;
+ CString text;
+
+ do {
+ CheckNoLog(m_pData->GetSection(PID_EIT, SI_EIT_act, NULL, 5000, &pSectionList));
+
+ CheckNoLog(pSectionList->GetSectionData(0, &dwLength, &data));
+ CGolombBuffer gb((BYTE*)data, dwLength);
+
+ InfoEvent.TableID = (UINT8)gb.BitRead(8);
+ InfoEvent.SectionSyntaxIndicator = (WORD)gb.BitRead(1);
+ gb.BitRead(3);
+ InfoEvent.SectionLength = (WORD)gb.BitRead(12);
+ ulGetSID = (ULONG)gb.BitRead(8);
+ ulGetSID += 0x100 * (ULONG)gb.BitRead(8);
+ InfoEvent.ServiceId = ulGetSID; // This is really strange, ServiceID should be uimsbf ???
+ gb.BitRead(2);
+ InfoEvent.VersionNumber = (UINT8)gb.BitRead(5);
+ InfoEvent.CurrentNextIndicator = (UINT8)gb.BitRead(1);
+
+ InfoEvent.SectionNumber = (UINT8)gb.BitRead(8);
+ InfoEvent.LastSectionNumber = (UINT8)gb.BitRead(8);
+ InfoEvent.TransportStreamID = (WORD)gb.BitRead(16);
+ InfoEvent.OriginalNetworkID = (WORD)gb.BitRead(16);
+ InfoEvent.SegmentLastSectionNumber = (UINT8)gb.BitRead(8);
+ InfoEvent.LastTableID = (UINT8)gb.BitRead(8);
+
+ // Info event
+ InfoEvent.EventID = (WORD)gb.BitRead(16);
+ InfoEvent.StartDate = (WORD)gb.BitRead(16);
+ SetTime(gb, NowNext);
+
+ InfoEvent.RunninStatus = (WORD)gb.BitRead(3);
+ InfoEvent.FreeCAMode = (WORD)gb.BitRead(1);
+
+ NowNext.ExtendedDescriptorsItems.RemoveAll();
+ NowNext.ExtendedDescriptorsTexts.RemoveAll();
+
+ if ((InfoEvent.ServiceId == ulSID) && (InfoEvent.CurrentNextIndicator == 1) && (InfoEvent.RunninStatus == 4)) {
+ // Descriptors:
+ BeginEnumDescriptors(gb, nType, nLength) {
+ switch (nType) {
+ case DT_SHORT_EVENT:
+ gb.BitRead(24); // ISO_639_language_code
+
+ nLen = (UINT8)gb.BitRead(8); // event_name_length
+ gb.ReadBuffer(DescBuffer, nLen);
+ NowNext.cPresent = ConvertString(DescBuffer, nLen);
+
+ nLen = (UINT8)gb.BitRead(8); // text_length
+ gb.ReadBuffer(DescBuffer, nLen);
+ NowNext.SummaryDesc = ConvertString(DescBuffer, nLen);
+ break;
+ case DT_EXTENDED_EVENT:
+ descriptorNumber = (UINT8)gb.BitRead(4); // descriptor_number
+ gb.BitRead(4); // last_descriptor_number
+ gb.BitRead(24); // ISO_639_language_code
+
+ itemsLength = (UINT8)gb.BitRead(8); // length_of_items
+ while (itemsLength > 0) {
+ nLen = (UINT8)gb.BitRead(8); // item_description_length
+ gb.ReadBuffer(DescBuffer, nLen);
+ itemDesc = ConvertString(DescBuffer, nLen);
+ itemsLength -= nLen + 1;
+
+ nLen = (UINT8)gb.BitRead(8); // item_length
+ gb.ReadBuffer(DescBuffer, nLen);
+ itemText = ConvertString(DescBuffer, nLen);
+ itemsLength -= nLen + 1;
+
+ NowNext.ExtendedDescriptorsItems.SetAt(itemDesc, itemText);
+ }
+
+ nLen = (UINT8)gb.BitRead(8); // text_length
+ gb.ReadBuffer(DescBuffer, nLen);
+ text = ConvertString(DescBuffer, nLen);
+ if (descriptorNumber == 0) { // new descriptor set
+ NowNext.ExtendedDescriptorsTexts.AddTail(text);
+ } else {
+ NowNext.ExtendedDescriptorsTexts.GetTail().Append(text);
+ }
+ break;
+ default:
+ SkipDescriptor(gb, nType, nLength);
+ break;
+ }
+ }
+ EndEnumDescriptors
+ }
+ m_Filter.SectionNumber++;
+ pSectionList.Release();
+ } while (((InfoEvent.ServiceId != ulSID) || (InfoEvent.CurrentNextIndicator != 1) || (InfoEvent.RunninStatus != 4)) &&
+ (m_Filter.SectionNumber <= 22));
+
+ if (InfoEvent.ServiceId != ulSID) {
+ NowNext.StartTime = _T("");
+ NowNext.Duration = _T("");
+ NowNext.cPresent = _T(" Info not available.");
+ NowNext.SummaryDesc = _T("");
+ NowNext.cFollowing = _T("");
+ }
+
+ return S_OK;
}
HRESULT CMpeg2DataParser::ParseNIT()
{
- HRESULT hr;
- CComPtr<ISectionList> pSectionList;
- DWORD dwLength;
- PSECTION data;
- WORD wTSID;
- WORD wSectionLength;
- WORD transport_stream_loop_length;
-
- CheckNoLog (m_pData->GetSection (PID_NIT, SI_NIT, &m_Filter, 5000, &pSectionList));
- CheckNoLog (pSectionList->GetSectionData (0, &dwLength, &data));
-
- CGolombBuffer gb ((BYTE*)data, dwLength);
-
- // network_information_section()
- CheckNoLog (ParseSIHeader (gb, SI_NIT, wSectionLength, wTSID));
-
- gb.BitRead(4); // reserved_future_use
- BeginEnumDescriptors(gb, nType, nLength) { // for (i=0;i<N;i++) {
- SkipDescriptor (gb, nType, nLength); // descriptor()
- }
- EndEnumDescriptors
-
- gb.BitRead(4); // reserved_future_use
- transport_stream_loop_length = (WORD)gb.BitRead(12); // network_descriptors_length
- while (gb.GetSize() - gb.GetPos() > 4) {
- WORD transport_stream_id = (WORD)gb.BitRead(16); // transport_stream_id
- UNREFERENCED_PARAMETER(transport_stream_id);
- WORD original_network_id = (WORD)gb.BitRead(16); // original_network_id
- UNREFERENCED_PARAMETER(original_network_id);
- gb.BitRead(4); // reserved_future_use
- BeginEnumDescriptors (gb, nType, nLength) {
- switch (nType) {
- case DT_LOGICAL_CHANNEL :
- for (int i=0; i<nLength/4; i++) {
- WORD service_id = (WORD)gb.BitRead(16);
- gb.BitRead(6);
- WORD logical_channel_number = (WORD)gb.BitRead(10);
- if (Channels.Lookup(service_id)) {
- Channels[service_id].SetOriginNumber (logical_channel_number);
- TRACE ("NIT association : %d -> %S\n", logical_channel_number, Channels[service_id].ToString());
- }
- }
- break;
- default :
- SkipDescriptor (gb, nType, nLength);
- break;
- }
- }
- EndEnumDescriptors
- }
-
- return S_OK;
+ HRESULT hr;
+ CComPtr<ISectionList> pSectionList;
+ DWORD dwLength;
+ PSECTION data;
+ WORD wTSID;
+ WORD wSectionLength;
+ WORD transport_stream_loop_length;
+
+ CheckNoLog(m_pData->GetSection(PID_NIT, SI_NIT, &m_Filter, 5000, &pSectionList));
+ CheckNoLog(pSectionList->GetSectionData(0, &dwLength, &data));
+
+ CGolombBuffer gb((BYTE*)data, dwLength);
+
+ // network_information_section()
+ CheckNoLog(ParseSIHeader(gb, SI_NIT, wSectionLength, wTSID));
+
+ gb.BitRead(4); // reserved_future_use
+ BeginEnumDescriptors(gb, nType, nLength) { // for (i=0;i<N;i++) {
+ SkipDescriptor(gb, nType, nLength); // descriptor()
+ }
+ EndEnumDescriptors
+
+ gb.BitRead(4); // reserved_future_use
+ transport_stream_loop_length = (WORD)gb.BitRead(12); // network_descriptors_length
+ while (gb.GetSize() - gb.GetPos() > 4) {
+ WORD transport_stream_id = (WORD)gb.BitRead(16); // transport_stream_id
+ UNREFERENCED_PARAMETER(transport_stream_id);
+ WORD original_network_id = (WORD)gb.BitRead(16); // original_network_id
+ UNREFERENCED_PARAMETER(original_network_id);
+ gb.BitRead(4); // reserved_future_use
+ BeginEnumDescriptors(gb, nType, nLength) {
+ switch (nType) {
+ case DT_LOGICAL_CHANNEL :
+ for (int i = 0; i < nLength / 4; i++) {
+ WORD service_id = (WORD)gb.BitRead(16);
+ gb.BitRead(6);
+ WORD logical_channel_number = (WORD)gb.BitRead(10);
+ if (Channels.Lookup(service_id)) {
+ Channels[service_id].SetOriginNumber(logical_channel_number);
+ TRACE("NIT association : %d -> %S\n", logical_channel_number, Channels[service_id].ToString());
+ }
+ }
+ break;
+ default :
+ SkipDescriptor(gb, nType, nLength);
+ break;
+ }
+ }
+ EndEnumDescriptors
+ }
+
+ return S_OK;
}
diff --git a/src/mpc-hc/Mpeg2SectionData.h b/src/mpc-hc/Mpeg2SectionData.h
index b08e6eddf..85063d837 100644
--- a/src/mpc-hc/Mpeg2SectionData.h
+++ b/src/mpc-hc/Mpeg2SectionData.h
@@ -28,40 +28,40 @@
#pragma pack(1)
typedef struct {
- UINT8 TableID;
- WORD SectionSyntaxIndicator : 1;
- WORD Reserved1 : 3;
- WORD SectionLength : 12;
- WORD BouquetID;
- UINT8 Reserved2 : 1;
- UINT8 VersionNumber : 5;
- UINT8 CurrentNextIndicator : 1;
- UINT8 SectionNumber;
- UINT8 LastSectionNumber;
+ UINT8 TableID;
+ WORD SectionSyntaxIndicator : 1;
+ WORD Reserved1 : 3;
+ WORD SectionLength : 12;
+ WORD BouquetID;
+ UINT8 Reserved2 : 1;
+ UINT8 VersionNumber : 5;
+ UINT8 CurrentNextIndicator : 1;
+ UINT8 SectionNumber;
+ UINT8 LastSectionNumber;
} SI_HEADER;
typedef struct {
- UINT8 TableID;
- WORD SectionSyntaxIndicator : 1;
- WORD Reserved1 : 3;
- WORD SectionLength : 12;
- ULONG ServiceId;
- UINT8 Reserved2 : 2;
- UINT8 VersionNumber : 5;
- UINT8 CurrentNextIndicator : 1;
- UINT8 SectionNumber;
- UINT8 LastSectionNumber;
- WORD TransportStreamID;
- WORD OriginalNetworkID;
- UINT8 SegmentLastSectionNumber;
- UINT8 LastTableID;
- WORD EventID;
- WORD StartDate;
- UINT8 StartTime[6];
- UINT8 Duration[6];
- WORD RunninStatus : 3;
- WORD FreeCAMode : 1;
- WORD DescriptorsLoopLenght :12;
+ UINT8 TableID;
+ WORD SectionSyntaxIndicator : 1;
+ WORD Reserved1 : 3;
+ WORD SectionLength : 12;
+ ULONG ServiceId;
+ UINT8 Reserved2 : 2;
+ UINT8 VersionNumber : 5;
+ UINT8 CurrentNextIndicator : 1;
+ UINT8 SectionNumber;
+ UINT8 LastSectionNumber;
+ WORD TransportStreamID;
+ WORD OriginalNetworkID;
+ UINT8 SegmentLastSectionNumber;
+ UINT8 LastTableID;
+ WORD EventID;
+ WORD StartDate;
+ UINT8 StartTime[6];
+ UINT8 Duration[6];
+ WORD RunninStatus : 3;
+ WORD FreeCAMode : 1;
+ WORD DescriptorsLoopLenght : 12;
} EventInformationSection;
@@ -69,26 +69,26 @@ class CMpeg2DataParser
{
public :
- CMpeg2DataParser(IBaseFilter* pFilter);
+ CMpeg2DataParser(IBaseFilter* pFilter);
- HRESULT ParseSDT(ULONG ulFreq);
- HRESULT ParsePAT();
- HRESULT ParseNIT();
- HRESULT ParseEIT(ULONG ulSID, PresentFollowing &NowNext);
- HRESULT ParsePMT(CDVBChannel& Channel);
+ HRESULT ParseSDT(ULONG ulFreq);
+ HRESULT ParsePAT();
+ HRESULT ParseNIT();
+ HRESULT ParseEIT(ULONG ulSID, PresentFollowing& NowNext);
+ HRESULT ParsePMT(CDVBChannel& Channel);
- static CString ConvertString (BYTE* pBuffer, int nLength);
+ static CString ConvertString(BYTE* pBuffer, int nLength);
- CAtlMap<int,CDVBChannel> Channels;
+ CAtlMap<int, CDVBChannel> Channels;
private :
- CComQIPtr<IMpeg2Data> m_pData;
- MPEG2_FILTER m_Filter;
+ CComQIPtr<IMpeg2Data> m_pData;
+ MPEG2_FILTER m_Filter;
- DVB_STREAM_TYPE ConvertToDVBType(PES_STREAM_TYPE nType);
- HRESULT ParseSIHeader(CGolombBuffer& gb, DVB_SI SIType, WORD& wSectionLength, WORD& wTSID);
- HRESULT SetTime(CGolombBuffer& gb, PresentFollowing &NowNext);
+ DVB_STREAM_TYPE ConvertToDVBType(PES_STREAM_TYPE nType);
+ HRESULT ParseSIHeader(CGolombBuffer& gb, DVB_SI SIType, WORD& wSectionLength, WORD& wTSID);
+ HRESULT SetTime(CGolombBuffer& gb, PresentFollowing& NowNext);
};
diff --git a/src/mpc-hc/MultiMonitor.cpp b/src/mpc-hc/MultiMonitor.cpp
index 336b94b99..ef0937515 100644
--- a/src/mpc-hc/MultiMonitor.cpp
+++ b/src/mpc-hc/MultiMonitor.cpp
@@ -29,32 +29,32 @@
// CMonitor
// constucts a monitor class not attached to any handle
-CMonitor::CMonitor() : m_hMonitor( NULL )
+CMonitor::CMonitor() : m_hMonitor(NULL)
{
}
// copy constructor
-CMonitor::CMonitor( const CMonitor& monitor )
+CMonitor::CMonitor(const CMonitor& monitor)
{
- m_hMonitor = (HMONITOR)monitor;
+ m_hMonitor = (HMONITOR)monitor;
}
CMonitor::~CMonitor()
{
}
-void CMonitor::Attach( const HMONITOR hMonitor )
+void CMonitor::Attach(const HMONITOR hMonitor)
{
- ASSERT( CMonitors::IsMonitor( hMonitor ) );
+ ASSERT(CMonitors::IsMonitor(hMonitor));
- m_hMonitor = hMonitor;
+ m_hMonitor = hMonitor;
}
HMONITOR CMonitor::Detach()
{
- HMONITOR hMonitor = m_hMonitor;
- m_hMonitor = NULL;
- return hMonitor;
+ HMONITOR hMonitor = m_hMonitor;
+ m_hMonitor = NULL;
+ return hMonitor;
}
// creates an HDC for the monitor
@@ -67,172 +67,172 @@ HMONITOR CMonitor::Detach()
// Only very exacting applications would need a DC for each monitor
HDC CMonitor::CreateDC() const
{
- ASSERT( IsMonitor() );
+ ASSERT(IsMonitor());
- CString name;
- GetName( name );
+ CString name;
+ GetName(name);
- //create a dc for this display
- HDC hdc = ::CreateDC( name, name, NULL, NULL );
- ASSERT( hdc != NULL );
+ //create a dc for this display
+ HDC hdc = ::CreateDC(name, name, NULL, NULL);
+ ASSERT(hdc != NULL);
- //set the viewport based on the monitor rect's relation to the primary monitor
- CRect rect;
- GetMonitorRect( &rect );
+ //set the viewport based on the monitor rect's relation to the primary monitor
+ CRect rect;
+ GetMonitorRect(&rect);
- ::SetViewportOrgEx( hdc, -rect.left, -rect.top, NULL );
- ::SetViewportExtEx( hdc, rect.Width(), rect.Height(), NULL );
+ ::SetViewportOrgEx(hdc, -rect.left, -rect.top, NULL);
+ ::SetViewportExtEx(hdc, rect.Width(), rect.Height(), NULL);
- return hdc;
+ return hdc;
}
int CMonitor::GetBitsPerPixel() const
{
- HDC hdc = CreateDC();
- int ret = ::GetDeviceCaps( hdc, BITSPIXEL ) * ::GetDeviceCaps( hdc, PLANES );
- VERIFY( ::DeleteDC( hdc ) );
+ HDC hdc = CreateDC();
+ int ret = ::GetDeviceCaps(hdc, BITSPIXEL) * ::GetDeviceCaps(hdc, PLANES);
+ VERIFY(::DeleteDC(hdc));
- return ret;
+ return ret;
}
-void CMonitor::GetName( CString& string ) const
+void CMonitor::GetName(CString& string) const
{
- ASSERT( IsMonitor() );
+ ASSERT(IsMonitor());
- MONITORINFOEX mi;
- mi.cbSize = sizeof( mi );
- ::GetMonitorInfo( m_hMonitor, &mi );
+ MONITORINFOEX mi;
+ mi.cbSize = sizeof(mi);
+ ::GetMonitorInfo(m_hMonitor, &mi);
- string = mi.szDevice;
+ string = mi.szDevice;
}
//
// these methods return true if any part of the item intersects the monitor rect
-BOOL CMonitor::IsOnMonitor( const POINT pt ) const
+BOOL CMonitor::IsOnMonitor(const POINT pt) const
{
- CRect rect;
- GetMonitorRect( rect );
+ CRect rect;
+ GetMonitorRect(rect);
- return rect.PtInRect( pt );
+ return rect.PtInRect(pt);
}
-BOOL CMonitor::IsOnMonitor( const CWnd* pWnd ) const
+BOOL CMonitor::IsOnMonitor(const CWnd* pWnd) const
{
- CRect rect;
- GetMonitorRect( rect );
+ CRect rect;
+ GetMonitorRect(rect);
- ASSERT( ::IsWindow( pWnd->GetSafeHwnd() ) );
- CRect wndRect;
- pWnd->GetWindowRect( &wndRect );
+ ASSERT(::IsWindow(pWnd->GetSafeHwnd()));
+ CRect wndRect;
+ pWnd->GetWindowRect(&wndRect);
- return rect.IntersectRect( rect, wndRect );
+ return rect.IntersectRect(rect, wndRect);
}
-BOOL CMonitor::IsOnMonitor( const LPRECT lprc ) const
+BOOL CMonitor::IsOnMonitor(const LPRECT lprc) const
{
- CRect rect;
- GetMonitorRect( rect );
+ CRect rect;
+ GetMonitorRect(rect);
- return rect.IntersectRect( rect, lprc );
+ return rect.IntersectRect(rect, lprc);
}
-void CMonitor::GetMonitorRect( LPRECT lprc ) const
+void CMonitor::GetMonitorRect(LPRECT lprc) const
{
- ASSERT( IsMonitor() );
+ ASSERT(IsMonitor());
- MONITORINFO mi;
- RECT rc;
+ MONITORINFO mi;
+ RECT rc;
- mi.cbSize = sizeof( mi );
- ::GetMonitorInfo( m_hMonitor, &mi );
- rc = mi.rcMonitor;
+ mi.cbSize = sizeof(mi);
+ ::GetMonitorInfo(m_hMonitor, &mi);
+ rc = mi.rcMonitor;
- ::SetRect( lprc, rc.left, rc.top, rc.right, rc.bottom );
+ ::SetRect(lprc, rc.left, rc.top, rc.right, rc.bottom);
}
//
// the work area does not include the start bar
-void CMonitor::GetWorkAreaRect( LPRECT lprc ) const
+void CMonitor::GetWorkAreaRect(LPRECT lprc) const
{
- ASSERT( IsMonitor() );
+ ASSERT(IsMonitor());
- MONITORINFO mi;
- RECT rc;
+ MONITORINFO mi;
+ RECT rc;
- mi.cbSize = sizeof( mi );
- ::GetMonitorInfo( m_hMonitor, &mi );
- rc = mi.rcWork;
+ mi.cbSize = sizeof(mi);
+ ::GetMonitorInfo(m_hMonitor, &mi);
+ rc = mi.rcWork;
- ::SetRect( lprc, rc.left, rc.top, rc.right, rc.bottom );
+ ::SetRect(lprc, rc.left, rc.top, rc.right, rc.bottom);
}
//these two center methods are adapted from David Campbell's
//MSJ article (see comment at the top of the header file)
-void CMonitor::CenterRectToMonitor( LPRECT lprc, const BOOL UseWorkAreaRect ) const
+void CMonitor::CenterRectToMonitor(LPRECT lprc, const BOOL UseWorkAreaRect) const
{
- int w = lprc->right - lprc->left;
- int h = lprc->bottom - lprc->top;
+ int w = lprc->right - lprc->left;
+ int h = lprc->bottom - lprc->top;
- CRect rect;
- if ( UseWorkAreaRect ) {
- GetWorkAreaRect( &rect );
- } else {
- GetMonitorRect( &rect );
- }
+ CRect rect;
+ if (UseWorkAreaRect) {
+ GetWorkAreaRect(&rect);
+ } else {
+ GetMonitorRect(&rect);
+ }
- lprc->left = rect.left + ( rect.Width() - w ) / 2;
- lprc->top = rect.top + ( rect.Height() - h ) / 2;
- lprc->right = lprc->left + w;
- lprc->bottom = lprc->top + h;
+ lprc->left = rect.left + (rect.Width() - w) / 2;
+ lprc->top = rect.top + (rect.Height() - h) / 2;
+ lprc->right = lprc->left + w;
+ lprc->bottom = lprc->top + h;
}
-void CMonitor::CenterWindowToMonitor( CWnd* const pWnd, const BOOL UseWorkAreaRect ) const
+void CMonitor::CenterWindowToMonitor(CWnd* const pWnd, const BOOL UseWorkAreaRect) const
{
- ASSERT( IsMonitor() );
- ASSERT( pWnd );
- ASSERT( ::IsWindow( pWnd->m_hWnd ) );
+ ASSERT(IsMonitor());
+ ASSERT(pWnd);
+ ASSERT(::IsWindow(pWnd->m_hWnd));
- CRect rect;
- pWnd->GetWindowRect( &rect );
- CenterRectToMonitor( &rect, UseWorkAreaRect );
- pWnd->SetWindowPos( NULL, rect.left, rect.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
+ CRect rect;
+ pWnd->GetWindowRect(&rect);
+ CenterRectToMonitor(&rect, UseWorkAreaRect);
+ pWnd->SetWindowPos(NULL, rect.left, rect.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
}
-void CMonitor::ClipRectToMonitor( LPRECT lprc, const BOOL UseWorkAreaRect ) const
+void CMonitor::ClipRectToMonitor(LPRECT lprc, const BOOL UseWorkAreaRect) const
{
- int w = lprc->right - lprc->left;
- int h = lprc->bottom - lprc->top;
+ int w = lprc->right - lprc->left;
+ int h = lprc->bottom - lprc->top;
- CRect rect;
- if ( UseWorkAreaRect ) {
- GetWorkAreaRect( &rect );
- } else {
- GetMonitorRect( &rect );
- }
+ CRect rect;
+ if (UseWorkAreaRect) {
+ GetWorkAreaRect(&rect);
+ } else {
+ GetMonitorRect(&rect);
+ }
- lprc->left = max( rect.left, min( rect.right - w, lprc->left ) );
- lprc->top = max( rect.top, min( rect.bottom - h, lprc->top ) );
- lprc->right = lprc->left + w;
- lprc->bottom = lprc->top + h;
+ lprc->left = max(rect.left, min(rect.right - w, lprc->left));
+ lprc->top = max(rect.top, min(rect.bottom - h, lprc->top));
+ lprc->right = lprc->left + w;
+ lprc->bottom = lprc->top + h;
}
//
// is the instance the primary monitor
BOOL CMonitor::IsPrimaryMonitor() const
{
- ASSERT( IsMonitor() );
+ ASSERT(IsMonitor());
- MONITORINFO mi;
+ MONITORINFO mi;
- mi.cbSize = sizeof( mi );
- ::GetMonitorInfo( m_hMonitor, &mi );
+ mi.cbSize = sizeof(mi);
+ ::GetMonitorInfo(m_hMonitor, &mi);
- return mi.dwFlags == MONITORINFOF_PRIMARY;
+ return mi.dwFlags == MONITORINFOF_PRIMARY;
}
//
// is the instance currently attached to a valid monitor handle
BOOL CMonitor::IsMonitor() const
{
- return CMonitors::IsMonitor( m_hMonitor );
+ return CMonitors::IsMonitor(m_hMonitor);
}
diff --git a/src/mpc-hc/MultiMonitor.h b/src/mpc-hc/MultiMonitor.h
index c519d8d5d..4bedcfcef 100644
--- a/src/mpc-hc/MultiMonitor.h
+++ b/src/mpc-hc/MultiMonitor.h
@@ -36,55 +36,55 @@
class CMonitor : public CObject
{
public:
- //construction destruction
- CMonitor();
- CMonitor( const CMonitor& monitor );
- virtual ~CMonitor();
+ //construction destruction
+ CMonitor();
+ CMonitor(const CMonitor& monitor);
+ virtual ~CMonitor();
- //operations
- void Attach( const HMONITOR hMonitor );
- HMONITOR Detach();
+ //operations
+ void Attach(const HMONITOR hMonitor);
+ HMONITOR Detach();
- void ClipRectToMonitor( LPRECT lprc, const BOOL UseWorkAreaRect = FALSE ) const;
- void CenterRectToMonitor( LPRECT lprc, const BOOL UseWorkAreaRect = FALSE ) const;
- void CenterWindowToMonitor( CWnd* const pWnd, const BOOL UseWorkAreaRect = FALSE ) const;
+ void ClipRectToMonitor(LPRECT lprc, const BOOL UseWorkAreaRect = FALSE) const;
+ void CenterRectToMonitor(LPRECT lprc, const BOOL UseWorkAreaRect = FALSE) const;
+ void CenterWindowToMonitor(CWnd* const pWnd, const BOOL UseWorkAreaRect = FALSE) const;
- HDC CreateDC() const;
+ HDC CreateDC() const;
- //properties
- void GetMonitorRect( LPRECT lprc ) const;
- void GetWorkAreaRect( LPRECT lprc ) const;
+ //properties
+ void GetMonitorRect(LPRECT lprc) const;
+ void GetWorkAreaRect(LPRECT lprc) const;
- void GetName( CString& string ) const;
+ void GetName(CString& string) const;
- int GetBitsPerPixel() const;
+ int GetBitsPerPixel() const;
- BOOL IsOnMonitor( const POINT pt ) const;
- BOOL IsOnMonitor( const CWnd* pWnd ) const;
- BOOL IsOnMonitor( const LPRECT lprc ) const;
+ BOOL IsOnMonitor(const POINT pt) const;
+ BOOL IsOnMonitor(const CWnd* pWnd) const;
+ BOOL IsOnMonitor(const LPRECT lprc) const;
- BOOL IsPrimaryMonitor() const;
- BOOL IsMonitor() const;
+ BOOL IsPrimaryMonitor() const;
+ BOOL IsMonitor() const;
- //operators
- operator HMONITOR() const {
- return this == NULL ? NULL : m_hMonitor;
- }
+ //operators
+ operator HMONITOR() const {
+ return this == NULL ? NULL : m_hMonitor;
+ }
- BOOL operator ==( const CMonitor& monitor ) const {
- return m_hMonitor == (HMONITOR)monitor;
- }
+ BOOL operator ==(const CMonitor& monitor) const {
+ return m_hMonitor == (HMONITOR)monitor;
+ }
- BOOL operator !=( const CMonitor& monitor ) const {
- return !( *this == monitor );
- }
+ BOOL operator !=(const CMonitor& monitor) const {
+ return !(*this == monitor);
+ }
- CMonitor& operator =( const CMonitor& monitor ) {
- m_hMonitor = (HMONITOR)monitor;
- return *this;
- }
+ CMonitor& operator =(const CMonitor& monitor) {
+ m_hMonitor = (HMONITOR)monitor;
+ return *this;
+ }
private:
- HMONITOR m_hMonitor;
+ HMONITOR m_hMonitor;
};
diff --git a/src/mpc-hc/OpenDirHelper.cpp b/src/mpc-hc/OpenDirHelper.cpp
index c65924fc1..cc87a3913 100644
--- a/src/mpc-hc/OpenDirHelper.cpp
+++ b/src/mpc-hc/OpenDirHelper.cpp
@@ -33,106 +33,106 @@ CString COpenDirHelper::strLastOpenDir;
void COpenDirHelper::SetFont(HWND hwnd, LPTSTR FontName, int FontSize)
{
- HFONT hf, hfOld;
- LOGFONT lf = {0};
- HDC hdc = GetDC(hwnd);
-
- GetObject(GetWindowFont(hwnd), sizeof(lf), &lf);
- lf.lfWeight = FW_REGULAR;
- lf.lfHeight = (LONG)FontSize;
- _tcscpy_s(lf.lfFaceName, FontName);
- hf = CreateFontIndirect(&lf);
- SetBkMode(hdc,OPAQUE);
-
- hfOld = (HFONT)SendMessage(hwnd, WM_GETFONT, NULL, NULL); // get old font
- SendMessage(hwnd, WM_SETFONT, (WPARAM)hf, TRUE); // set new font
-
- if (!hfOld && (hfOld != hf)) {
- DeleteObject(hfOld); // if the old font is not system font or the same as newfont, release it.
- }
- ReleaseDC(hwnd, hdc);
+ HFONT hf, hfOld;
+ LOGFONT lf = {0};
+ HDC hdc = GetDC(hwnd);
+
+ GetObject(GetWindowFont(hwnd), sizeof(lf), &lf);
+ lf.lfWeight = FW_REGULAR;
+ lf.lfHeight = (LONG)FontSize;
+ _tcscpy_s(lf.lfFaceName, FontName);
+ hf = CreateFontIndirect(&lf);
+ SetBkMode(hdc, OPAQUE);
+
+ hfOld = (HFONT)SendMessage(hwnd, WM_GETFONT, NULL, NULL); // get old font
+ SendMessage(hwnd, WM_SETFONT, (WPARAM)hf, TRUE); // set new font
+
+ if (!hfOld && (hfOld != hf)) {
+ DeleteObject(hfOld); // if the old font is not system font or the same as newfont, release it.
+ }
+ ReleaseDC(hwnd, hdc);
}
// Subclass procedure
-LRESULT APIENTRY COpenDirHelper::CheckBoxSubclassProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
+LRESULT APIENTRY COpenDirHelper::CheckBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- if (uMsg == WM_LBUTTONUP) {
- if ((SendMessage(hwnd,BM_GETCHECK,0,0) )== 1) {
- m_incl_subdir = FALSE;
- } else {
- m_incl_subdir = TRUE;
- }
- }
- return CallWindowProc(CBProc, hwnd, uMsg, wParam, lParam);
+ if (uMsg == WM_LBUTTONUP) {
+ if ((SendMessage(hwnd, BM_GETCHECK, 0, 0)) == 1) {
+ m_incl_subdir = FALSE;
+ } else {
+ m_incl_subdir = TRUE;
+ }
+ }
+ return CallWindowProc(CBProc, hwnd, uMsg, wParam, lParam);
}
int CALLBACK COpenDirHelper::BrowseCallbackProcDIR(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
{
- HWND checkbox;
+ HWND checkbox;
- // Initialization callback message
- if (uMsg == BFFM_INITIALIZED) {
- SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)(LPCTSTR)strLastOpenDir);
+ // Initialization callback message
+ if (uMsg == BFFM_INITIALIZED) {
+ SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)(LPCTSTR)strLastOpenDir);
- RECT ListViewRect;
- RECT Dialog;
- RECT ClientArea;
- RECT ButtonRect;
+ RECT ListViewRect;
+ RECT Dialog;
+ RECT ClientArea;
+ RECT ButtonRect;
- checkbox = CreateWindowEx(0, _T("BUTTON"), ResStr(IDS_MAINFRM_DIR_CHECK),
- WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | BS_AUTOCHECKBOX | BS_MULTILINE,
- 0, 100, 100, 50, hwnd, 0, AfxGetApp()->m_hInstance, NULL);
+ checkbox = CreateWindowEx(0, _T("BUTTON"), ResStr(IDS_MAINFRM_DIR_CHECK),
+ WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | BS_AUTOCHECKBOX | BS_MULTILINE,
+ 0, 100, 100, 50, hwnd, 0, AfxGetApp()->m_hInstance, NULL);
- HWND ListView = FindWindowEx(hwnd, NULL, _T("SysTreeView32"), NULL);
+ HWND ListView = FindWindowEx(hwnd, NULL, _T("SysTreeView32"), NULL);
- HWND id_ok = GetDlgItem(hwnd, IDOK);
- HWND id_cancel = GetDlgItem(hwnd, IDCANCEL);
+ HWND id_ok = GetDlgItem(hwnd, IDOK);
+ HWND id_cancel = GetDlgItem(hwnd, IDCANCEL);
- GetWindowRect(hwnd, &Dialog);
- MoveWindow(hwnd, Dialog.left, Dialog.top, Dialog.right-Dialog.left+50, Dialog.bottom-Dialog.top+70, TRUE);
- GetWindowRect(hwnd, &Dialog);
+ GetWindowRect(hwnd, &Dialog);
+ MoveWindow(hwnd, Dialog.left, Dialog.top, Dialog.right - Dialog.left + 50, Dialog.bottom - Dialog.top + 70, TRUE);
+ GetWindowRect(hwnd, &Dialog);
- GetClientRect(hwnd, &ClientArea);
+ GetClientRect(hwnd, &ClientArea);
- GetWindowRect(ListView, &ListViewRect);
- MoveWindow(ListView, ListViewRect.left-Dialog.left-3, ListViewRect.top-Dialog.top-75, ListViewRect.right-ListViewRect.left+49, ListViewRect.bottom-ListViewRect.top+115, TRUE);
- GetWindowRect(ListView, &ListViewRect);
+ GetWindowRect(ListView, &ListViewRect);
+ MoveWindow(ListView, ListViewRect.left - Dialog.left - 3, ListViewRect.top - Dialog.top - 75, ListViewRect.right - ListViewRect.left + 49, ListViewRect.bottom - ListViewRect.top + 115, TRUE);
+ GetWindowRect(ListView, &ListViewRect);
- GetWindowRect(id_ok, &ButtonRect);
- MoveWindow(id_ok, ButtonRect.left-Dialog.left+49, ButtonRect.top-Dialog.top+40, ButtonRect.right-ButtonRect.left, ButtonRect.bottom-ButtonRect.top, TRUE);
+ GetWindowRect(id_ok, &ButtonRect);
+ MoveWindow(id_ok, ButtonRect.left - Dialog.left + 49, ButtonRect.top - Dialog.top + 40, ButtonRect.right - ButtonRect.left, ButtonRect.bottom - ButtonRect.top, TRUE);
- GetWindowRect(id_cancel, &ButtonRect);
- MoveWindow(id_cancel, ButtonRect.left-Dialog.left+49, ButtonRect.top-Dialog.top+40, ButtonRect.right-ButtonRect.left, ButtonRect.bottom-ButtonRect.top, TRUE);
+ GetWindowRect(id_cancel, &ButtonRect);
+ MoveWindow(id_cancel, ButtonRect.left - Dialog.left + 49, ButtonRect.top - Dialog.top + 40, ButtonRect.right - ButtonRect.left, ButtonRect.bottom - ButtonRect.top, TRUE);
- SetWindowPos(checkbox, HWND_BOTTOM, ListViewRect.left-Dialog.left-3, ClientArea.bottom - 35, 180, 27, SWP_SHOWWINDOW);
- SetFont(checkbox, _T("Tahoma"), 13);
+ SetWindowPos(checkbox, HWND_BOTTOM, ListViewRect.left - Dialog.left - 3, ClientArea.bottom - 35, 180, 27, SWP_SHOWWINDOW);
+ SetFont(checkbox, _T("Tahoma"), 13);
- CBProc = (WNDPROC) SetWindowLongPtr(checkbox, GWLP_WNDPROC, (LONG_PTR) CheckBoxSubclassProc);
- SendMessage(checkbox, BM_SETCHECK, (WPARAM)m_incl_subdir, 0);
- }
+ CBProc = (WNDPROC) SetWindowLongPtr(checkbox, GWLP_WNDPROC, (LONG_PTR) CheckBoxSubclassProc);
+ SendMessage(checkbox, BM_SETCHECK, (WPARAM)m_incl_subdir, 0);
+ }
- return 0;
+ return 0;
}
void COpenDirHelper::RecurseAddDir(CString path, CAtlList<CString>* sl)
{
- WIN32_FIND_DATA fd = {0};
-
- HANDLE hFind = FindFirstFile(path + _T("*.*"), &fd);
- if (hFind != INVALID_HANDLE_VALUE) {
- do {
- CString f_name = fd.cFileName;
- if ((fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) && (f_name!=_T(".")) && (f_name!=_T(".."))) {
- CString fullpath = path + f_name;
- if (fullpath[fullpath.GetLength()-1] != '\\') {
- fullpath += '\\';
- }
- sl->AddTail(fullpath);
- RecurseAddDir(fullpath, sl);
- } else {
- continue;
- }
- } while (FindNextFile(hFind, &fd));
- FindClose(hFind);
- }
+ WIN32_FIND_DATA fd = {0};
+
+ HANDLE hFind = FindFirstFile(path + _T("*.*"), &fd);
+ if (hFind != INVALID_HANDLE_VALUE) {
+ do {
+ CString f_name = fd.cFileName;
+ if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && (f_name != _T(".")) && (f_name != _T(".."))) {
+ CString fullpath = path + f_name;
+ if (fullpath[fullpath.GetLength() - 1] != '\\') {
+ fullpath += '\\';
+ }
+ sl->AddTail(fullpath);
+ RecurseAddDir(fullpath, sl);
+ } else {
+ continue;
+ }
+ } while (FindNextFile(hFind, &fd));
+ FindClose(hFind);
+ }
}
diff --git a/src/mpc-hc/OpenDirHelper.h b/src/mpc-hc/OpenDirHelper.h
index afeb4c105..861f53f69 100644
--- a/src/mpc-hc/OpenDirHelper.h
+++ b/src/mpc-hc/OpenDirHelper.h
@@ -26,15 +26,15 @@
class COpenDirHelper
{
public:
- static WNDPROC CBProc;
- static bool m_incl_subdir;
- static CString strLastOpenDir;
+ static WNDPROC CBProc;
+ static bool m_incl_subdir;
+ static CString strLastOpenDir;
- static void SetFont(HWND hwnd,LPTSTR FontName,int FontSize);
- // Subclass procedure
- static LRESULT APIENTRY CheckBoxSubclassProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
+ static void SetFont(HWND hwnd, LPTSTR FontName, int FontSize);
+ // Subclass procedure
+ static LRESULT APIENTRY CheckBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
- static int CALLBACK BrowseCallbackProcDIR(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData);
+ static int CALLBACK BrowseCallbackProcDIR(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData);
- static void RecurseAddDir(CString path, CAtlList<CString>* sl);
+ static void RecurseAddDir(CString path, CAtlList<CString>* sl);
};
diff --git a/src/mpc-hc/OpenDlg.cpp b/src/mpc-hc/OpenDlg.cpp
index 98f9ffade..b157c0649 100644
--- a/src/mpc-hc/OpenDlg.cpp
+++ b/src/mpc-hc/OpenDlg.cpp
@@ -32,11 +32,11 @@
//IMPLEMENT_DYNAMIC(COpenDlg, CResizableDialog)
COpenDlg::COpenDlg(CWnd* pParent /*=NULL*/)
- : CResizableDialog(COpenDlg::IDD, pParent)
- , m_path(_T(""))
- , m_path2(_T(""))
- , m_fMultipleFiles(false)
- , m_fAppendPlaylist(FALSE)
+ : CResizableDialog(COpenDlg::IDD, pParent)
+ , m_path(_T(""))
+ , m_path2(_T(""))
+ , m_fMultipleFiles(false)
+ , m_fAppendPlaylist(FALSE)
{
}
@@ -46,24 +46,24 @@ COpenDlg::~COpenDlg()
void COpenDlg::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_COMBO1, m_mrucombo);
- DDX_CBString(pDX, IDC_COMBO1, m_path);
- DDX_Control(pDX, IDC_COMBO2, m_mrucombo2);
- DDX_CBString(pDX, IDC_COMBO2, m_path2);
- DDX_Control(pDX, IDC_STATIC1, m_label2);
- DDX_Check(pDX, IDC_CHECK1, m_fAppendPlaylist);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_COMBO1, m_mrucombo);
+ DDX_CBString(pDX, IDC_COMBO1, m_path);
+ DDX_Control(pDX, IDC_COMBO2, m_mrucombo2);
+ DDX_CBString(pDX, IDC_COMBO2, m_path2);
+ DDX_Control(pDX, IDC_STATIC1, m_label2);
+ DDX_Check(pDX, IDC_CHECK1, m_fAppendPlaylist);
}
BEGIN_MESSAGE_MAP(COpenDlg, CResizableDialog)
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedBrowsebutton)
- ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedBrowsebutton2)
- ON_BN_CLICKED(IDOK, OnBnClickedOk)
- ON_UPDATE_COMMAND_UI(IDC_STATIC1, OnUpdateDub)
- ON_UPDATE_COMMAND_UI(IDC_COMBO2, OnUpdateDub)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON2, OnUpdateDub)
- ON_UPDATE_COMMAND_UI(IDOK, OnUpdateOk)
+ ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedBrowsebutton)
+ ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedBrowsebutton2)
+ ON_BN_CLICKED(IDOK, OnBnClickedOk)
+ ON_UPDATE_COMMAND_UI(IDC_STATIC1, OnUpdateDub)
+ ON_UPDATE_COMMAND_UI(IDC_COMBO2, OnUpdateDub)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON2, OnUpdateDub)
+ ON_UPDATE_COMMAND_UI(IDOK, OnUpdateOk)
END_MESSAGE_MAP()
@@ -71,156 +71,156 @@ END_MESSAGE_MAP()
BOOL COpenDlg::OnInitDialog()
{
- __super::OnInitDialog();
-
- CRecentFileList& MRU = AfxGetAppSettings().MRU;
- MRU.ReadList();
- m_mrucombo.ResetContent();
- for (int i = 0; i < MRU.GetSize(); i++)
- if (!MRU[i].IsEmpty()) {
- m_mrucombo.AddString(MRU[i]);
- }
- CorrectComboListWidth(m_mrucombo);
-
- CRecentFileList& MRUDub = AfxGetAppSettings().MRUDub;
- MRUDub.ReadList();
- m_mrucombo2.ResetContent();
- for (int i = 0; i < MRUDub.GetSize(); i++)
- if (!MRUDub[i].IsEmpty()) {
- m_mrucombo2.AddString(MRUDub[i]);
- }
- CorrectComboListWidth(m_mrucombo2);
-
- if (m_mrucombo.GetCount() > 0) {
- m_mrucombo.SetCurSel(0);
- }
-
- m_fns.RemoveAll();
- m_path = _T("");
- m_path2 = _T("");
- m_fMultipleFiles = false;
- m_fAppendPlaylist = FALSE;
-
- AddAnchor(m_mrucombo, TOP_LEFT, TOP_RIGHT);
- AddAnchor(m_mrucombo2, TOP_LEFT, TOP_RIGHT);
- AddAnchor(IDC_BUTTON1, TOP_RIGHT);
- AddAnchor(IDC_BUTTON2, TOP_RIGHT);
- AddAnchor(IDOK, TOP_RIGHT);
- AddAnchor(IDCANCEL, TOP_RIGHT);
- AddAnchor(IDC_STATIC1, TOP_LEFT, TOP_RIGHT);
-
- CRect r;
- GetWindowRect(r);
- CSize s = r.Size();
- SetMinTrackSize(s);
- s.cx = 1000;
- SetMaxTrackSize(s);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ CRecentFileList& MRU = AfxGetAppSettings().MRU;
+ MRU.ReadList();
+ m_mrucombo.ResetContent();
+ for (int i = 0; i < MRU.GetSize(); i++)
+ if (!MRU[i].IsEmpty()) {
+ m_mrucombo.AddString(MRU[i]);
+ }
+ CorrectComboListWidth(m_mrucombo);
+
+ CRecentFileList& MRUDub = AfxGetAppSettings().MRUDub;
+ MRUDub.ReadList();
+ m_mrucombo2.ResetContent();
+ for (int i = 0; i < MRUDub.GetSize(); i++)
+ if (!MRUDub[i].IsEmpty()) {
+ m_mrucombo2.AddString(MRUDub[i]);
+ }
+ CorrectComboListWidth(m_mrucombo2);
+
+ if (m_mrucombo.GetCount() > 0) {
+ m_mrucombo.SetCurSel(0);
+ }
+
+ m_fns.RemoveAll();
+ m_path = _T("");
+ m_path2 = _T("");
+ m_fMultipleFiles = false;
+ m_fAppendPlaylist = FALSE;
+
+ AddAnchor(m_mrucombo, TOP_LEFT, TOP_RIGHT);
+ AddAnchor(m_mrucombo2, TOP_LEFT, TOP_RIGHT);
+ AddAnchor(IDC_BUTTON1, TOP_RIGHT);
+ AddAnchor(IDC_BUTTON2, TOP_RIGHT);
+ AddAnchor(IDOK, TOP_RIGHT);
+ AddAnchor(IDCANCEL, TOP_RIGHT);
+ AddAnchor(IDC_STATIC1, TOP_LEFT, TOP_RIGHT);
+
+ CRect r;
+ GetWindowRect(r);
+ CSize s = r.Size();
+ SetMinTrackSize(s);
+ s.cx = 1000;
+ SetMaxTrackSize(s);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
static CString GetFileName(CString str)
{
- CPath p = str;
- p.StripPath();
- return (LPCTSTR)p;
+ CPath p = str;
+ p.StripPath();
+ return (LPCTSTR)p;
}
void COpenDlg::OnBnClickedBrowsebutton()
{
- UpdateData();
-
- AppSettings& s = AfxGetAppSettings();
-
- CString filter;
- CAtlArray<CString> mask;
- s.m_Formats.GetFilter(filter, mask);
-
- DWORD dwFlags = OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_ALLOWMULTISELECT|OFN_ENABLEINCLUDENOTIFY|OFN_NOCHANGEDIR;
- if (!s.fKeepHistory) {
- dwFlags |= OFN_DONTADDTORECENT;
- }
-
- COpenFileDlg fd(mask, true, NULL, m_path, dwFlags, filter, this);
- if (fd.DoModal() != IDOK) {
- return;
- }
-
- m_fns.RemoveAll();
-
- POSITION pos = fd.GetStartPosition();
- while (pos) {
- /*
- CString str = fd.GetNextPathName(pos);
- POSITION insertpos = m_fns.GetTailPosition();
- while (insertpos && GetFileName(str).CompareNoCase(GetFileName(m_fns.GetAt(insertpos))) <= 0)
- m_fns.GetPrev(insertpos);
- if (!insertpos) m_fns.AddHead(str);
- else m_fns.InsertAfter(insertpos, str);
- */
- m_fns.AddTail(fd.GetNextPathName(pos));
- }
-
- if (m_fns.GetCount() > 1
- || m_fns.GetCount() == 1
- && (m_fns.GetHead()[m_fns.GetHead().GetLength()-1] == '\\'
- || m_fns.GetHead()[m_fns.GetHead().GetLength()-1] == '*')) {
- m_fMultipleFiles = true;
- EndDialog(IDOK);
- return;
- }
-
- m_mrucombo.SetWindowText(fd.GetPathName());
+ UpdateData();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ CString filter;
+ CAtlArray<CString> mask;
+ s.m_Formats.GetFilter(filter, mask);
+
+ DWORD dwFlags = OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT | OFN_ENABLEINCLUDENOTIFY | OFN_NOCHANGEDIR;
+ if (!s.fKeepHistory) {
+ dwFlags |= OFN_DONTADDTORECENT;
+ }
+
+ COpenFileDlg fd(mask, true, NULL, m_path, dwFlags, filter, this);
+ if (fd.DoModal() != IDOK) {
+ return;
+ }
+
+ m_fns.RemoveAll();
+
+ POSITION pos = fd.GetStartPosition();
+ while (pos) {
+ /*
+ CString str = fd.GetNextPathName(pos);
+ POSITION insertpos = m_fns.GetTailPosition();
+ while (insertpos && GetFileName(str).CompareNoCase(GetFileName(m_fns.GetAt(insertpos))) <= 0)
+ m_fns.GetPrev(insertpos);
+ if (!insertpos) m_fns.AddHead(str);
+ else m_fns.InsertAfter(insertpos, str);
+ */
+ m_fns.AddTail(fd.GetNextPathName(pos));
+ }
+
+ if (m_fns.GetCount() > 1
+ || m_fns.GetCount() == 1
+ && (m_fns.GetHead()[m_fns.GetHead().GetLength() - 1] == '\\'
+ || m_fns.GetHead()[m_fns.GetHead().GetLength() - 1] == '*')) {
+ m_fMultipleFiles = true;
+ EndDialog(IDOK);
+ return;
+ }
+
+ m_mrucombo.SetWindowText(fd.GetPathName());
}
void COpenDlg::OnBnClickedBrowsebutton2()
{
- UpdateData();
+ UpdateData();
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- CString filter;
- CAtlArray<CString> mask;
- s.m_Formats.GetAudioFilter(filter, mask);
+ CString filter;
+ CAtlArray<CString> mask;
+ s.m_Formats.GetAudioFilter(filter, mask);
- DWORD dwFlags = OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_ENABLEINCLUDENOTIFY|OFN_NOCHANGEDIR;
- if (!s.fKeepHistory) {
- dwFlags |= OFN_DONTADDTORECENT;
- }
+ DWORD dwFlags = OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_ENABLEINCLUDENOTIFY | OFN_NOCHANGEDIR;
+ if (!s.fKeepHistory) {
+ dwFlags |= OFN_DONTADDTORECENT;
+ }
- COpenFileDlg fd(mask, false, NULL, m_path2, dwFlags, filter, this);
+ COpenFileDlg fd(mask, false, NULL, m_path2, dwFlags, filter, this);
- if (fd.DoModal() != IDOK) {
- return;
- }
+ if (fd.DoModal() != IDOK) {
+ return;
+ }
- m_mrucombo2.SetWindowText(fd.GetPathName());
+ m_mrucombo2.SetWindowText(fd.GetPathName());
}
void COpenDlg::OnBnClickedOk()
{
- UpdateData();
+ UpdateData();
- m_fns.RemoveAll();
- m_fns.AddTail(m_path);
- if (m_mrucombo2.IsWindowEnabled()) {
- m_fns.AddTail(m_path2);
- }
+ m_fns.RemoveAll();
+ m_fns.AddTail(m_path);
+ if (m_mrucombo2.IsWindowEnabled()) {
+ m_fns.AddTail(m_path2);
+ }
- m_fMultipleFiles = false;
+ m_fMultipleFiles = false;
- OnOK();
+ OnOK();
}
void COpenDlg::OnUpdateDub(CCmdUI* pCmdUI)
{
- UpdateData();
- pCmdUI->Enable(AfxGetAppSettings().m_Formats.GetEngine(m_path) == DirectShow);
+ UpdateData();
+ pCmdUI->Enable(AfxGetAppSettings().m_Formats.GetEngine(m_path) == DirectShow);
}
void COpenDlg::OnUpdateOk(CCmdUI* pCmdUI)
{
- UpdateData();
- pCmdUI->Enable(!m_path.IsEmpty() || !m_path2.IsEmpty());
+ UpdateData();
+ pCmdUI->Enable(!m_path.IsEmpty() || !m_path2.IsEmpty());
}
diff --git a/src/mpc-hc/OpenDlg.h b/src/mpc-hc/OpenDlg.h
index c22d79c1f..03a2777b9 100644
--- a/src/mpc-hc/OpenDlg.h
+++ b/src/mpc-hc/OpenDlg.h
@@ -31,34 +31,34 @@
class COpenDlg : public CResizableDialog
{
- // DECLARE_DYNAMIC(COpenDlg)
+ // DECLARE_DYNAMIC(COpenDlg)
public:
- COpenDlg(CWnd* pParent = NULL); // standard constructor
- virtual ~COpenDlg();
+ COpenDlg(CWnd* pParent = NULL); // standard constructor
+ virtual ~COpenDlg();
- bool m_fMultipleFiles;
- CAtlList<CString> m_fns;
+ bool m_fMultipleFiles;
+ CAtlList<CString> m_fns;
- // Dialog Data
- enum { IDD = IDD_OPEN_DLG };
- CComboBox m_mrucombo;
- CString m_path;
- CComboBox m_mrucombo2;
- CString m_path2;
- CStatic m_label2;
- BOOL m_fAppendPlaylist;
+ // Dialog Data
+ enum { IDD = IDD_OPEN_DLG };
+ CComboBox m_mrucombo;
+ CString m_path;
+ CComboBox m_mrucombo2;
+ CString m_path2;
+ CStatic m_label2;
+ BOOL m_fAppendPlaylist;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnBnClickedBrowsebutton();
- afx_msg void OnBnClickedBrowsebutton2();
- afx_msg void OnBnClickedOk();
- afx_msg void OnUpdateDub(CCmdUI* pCmdUI);
- afx_msg void OnUpdateOk(CCmdUI* pCmdUI);
+ afx_msg void OnBnClickedBrowsebutton();
+ afx_msg void OnBnClickedBrowsebutton2();
+ afx_msg void OnBnClickedOk();
+ afx_msg void OnUpdateDub(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateOk(CCmdUI* pCmdUI);
};
diff --git a/src/mpc-hc/OpenFileDlg.cpp b/src/mpc-hc/OpenFileDlg.cpp
index 2e853605a..6a4481427 100644
--- a/src/mpc-hc/OpenFileDlg.cpp
+++ b/src/mpc-hc/OpenFileDlg.cpp
@@ -36,26 +36,26 @@ WNDPROC COpenFileDlg::m_wndProc = NULL;
IMPLEMENT_DYNAMIC(COpenFileDlg, CFileDialog)
COpenFileDlg::COpenFileDlg(CAtlArray<CString>& mask, bool fAllowDirSelection, LPCTSTR lpszDefExt, LPCTSTR lpszFileName,
- DWORD dwFlags, LPCTSTR lpszFilter, CWnd* pParentWnd)
- : CFileDialog(TRUE, lpszDefExt, lpszFileName, dwFlags|OFN_NOVALIDATE, lpszFilter, pParentWnd, 0)
- , m_mask(mask)
+ DWORD dwFlags, LPCTSTR lpszFilter, CWnd* pParentWnd)
+ : CFileDialog(TRUE, lpszDefExt, lpszFileName, dwFlags | OFN_NOVALIDATE, lpszFilter, pParentWnd, 0)
+ , m_mask(mask)
{
- m_fAllowDirSelection = fAllowDirSelection;
- m_pOFN->lpstrInitialDir = lpszFileName;
+ m_fAllowDirSelection = fAllowDirSelection;
+ m_pOFN->lpstrInitialDir = lpszFileName;
- m_buff = DNew TCHAR[10000];
- m_buff[0] = 0;
- m_pOFN->lpstrFile = m_buff;
- m_pOFN->nMaxFile = 10000;
+ m_buff = DNew TCHAR[10000];
+ m_buff[0] = 0;
+ m_pOFN->lpstrFile = m_buff;
+ m_pOFN->nMaxFile = 10000;
}
COpenFileDlg::~COpenFileDlg()
{
- delete [] m_buff;
+ delete [] m_buff;
}
BEGIN_MESSAGE_MAP(COpenFileDlg, CFileDialog)
- ON_WM_DESTROY()
+ ON_WM_DESTROY()
END_MESSAGE_MAP()
@@ -63,99 +63,99 @@ END_MESSAGE_MAP()
LRESULT CALLBACK COpenFileDlg::WindowProcNew(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- if (message == WM_COMMAND && HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDOK
- && m_fAllowDirSelection) {
- CAutoVectorPtr<TCHAR> path;
- path.Allocate(_MAX_PATH+1); // _MAX_PATH should be bigger for multiple selection, but we are only interested if it's zero length
- // note: allocating _MAX_PATH only will cause a buffer overrun for too long strings, and will result in a silent app disappearing crash, 100% reproducible
- if (::GetDlgItemText(hwnd, cmb13, (TCHAR*)path, _MAX_PATH) == 0) {
- ::SendMessage(hwnd, CDM_SETCONTROLTEXT, edt1, (LPARAM)__DUMMY__);
- }
- }
-
- return CallWindowProc(COpenFileDlg::m_wndProc, hwnd, message, wParam, lParam);
+ if (message == WM_COMMAND && HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDOK
+ && m_fAllowDirSelection) {
+ CAutoVectorPtr<TCHAR> path;
+ path.Allocate(_MAX_PATH + 1); // _MAX_PATH should be bigger for multiple selection, but we are only interested if it's zero length
+ // note: allocating _MAX_PATH only will cause a buffer overrun for too long strings, and will result in a silent app disappearing crash, 100% reproducible
+ if (::GetDlgItemText(hwnd, cmb13, (TCHAR*)path, _MAX_PATH) == 0) {
+ ::SendMessage(hwnd, CDM_SETCONTROLTEXT, edt1, (LPARAM)__DUMMY__);
+ }
+ }
+
+ return CallWindowProc(COpenFileDlg::m_wndProc, hwnd, message, wParam, lParam);
}
BOOL COpenFileDlg::OnInitDialog()
{
- CFileDialog::OnInitDialog();
+ CFileDialog::OnInitDialog();
- m_wndProc = (WNDPROC)SetWindowLongPtr(GetParent()->m_hWnd, GWLP_WNDPROC , (LONG_PTR)WindowProcNew);
+ m_wndProc = (WNDPROC)SetWindowLongPtr(GetParent()->m_hWnd, GWLP_WNDPROC , (LONG_PTR)WindowProcNew);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void COpenFileDlg::OnDestroy()
{
- int i = GetPathName().Find(__DUMMY__);
- if (i >= 0) {
- m_pOFN->lpstrFile[i] = m_pOFN->lpstrFile[i+1] = 0;
- }
+ int i = GetPathName().Find(__DUMMY__);
+ if (i >= 0) {
+ m_pOFN->lpstrFile[i] = m_pOFN->lpstrFile[i + 1] = 0;
+ }
- CFileDialog::OnDestroy();
+ CFileDialog::OnDestroy();
}
BOOL COpenFileDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
- ASSERT(pResult != NULL);
-
- OFNOTIFY* pNotify = (OFNOTIFY*)lParam;
- // allow message map to override
- if (__super::OnNotify(wParam, lParam, pResult)) {
- ASSERT(pNotify->hdr.code != CDN_INCLUDEITEM);
- return TRUE;
- }
-
- switch (pNotify->hdr.code) {
- case CDN_INCLUDEITEM:
- if (OnIncludeItem((OFNOTIFYEX*)lParam, pResult)) {
- return TRUE;
- }
- break;
- }
-
- return FALSE; // not handled
+ ASSERT(pResult != NULL);
+
+ OFNOTIFY* pNotify = (OFNOTIFY*)lParam;
+ // allow message map to override
+ if (__super::OnNotify(wParam, lParam, pResult)) {
+ ASSERT(pNotify->hdr.code != CDN_INCLUDEITEM);
+ return TRUE;
+ }
+
+ switch (pNotify->hdr.code) {
+ case CDN_INCLUDEITEM:
+ if (OnIncludeItem((OFNOTIFYEX*)lParam, pResult)) {
+ return TRUE;
+ }
+ break;
+ }
+
+ return FALSE; // not handled
}
BOOL COpenFileDlg::OnIncludeItem(OFNOTIFYEX* pOFNEx, LRESULT* pResult)
{
- TCHAR buff[_MAX_PATH];
- if (!SHGetPathFromIDList((LPCITEMIDLIST)pOFNEx->pidl, buff)) {
- STRRET s;
- HRESULT hr = ((IShellFolder*)pOFNEx->psf)->GetDisplayNameOf((LPCITEMIDLIST)pOFNEx->pidl, SHGDN_NORMAL|SHGDN_FORPARSING, &s);
- if (S_OK != hr) {
- return FALSE;
- }
- switch (s.uType) {
- case STRRET_CSTR:
- _tcscpy_s(buff, CString(s.cStr));
- break;
- case STRRET_WSTR:
- _tcscpy_s(buff, CString(s.pOleStr));
- CoTaskMemFree(s.pOleStr);
- break;
- default:
- return FALSE;
- }
- }
-
- CString fn(buff);
- /*
- WIN32_FILE_ATTRIBUTE_DATA fad;
- if (GetFileAttributesEx(fn, GetFileExInfoStandard, &fad)
- && (fad.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY))
- return FALSE;
- */
- int i = fn.ReverseFind('.'), j = fn.ReverseFind('\\');
- if (i < 0 || i < j) {
- return FALSE;
- }
-
- CString mask = m_mask[pOFNEx->lpOFN->nFilterIndex-1] + _T(";");
- CString ext = fn.Mid(i).MakeLower() + _T(";");
-
- *pResult = mask.Find(ext) >= 0 || mask.Find(_T("*.*")) >= 0;
-
- return TRUE;
+ TCHAR buff[_MAX_PATH];
+ if (!SHGetPathFromIDList((LPCITEMIDLIST)pOFNEx->pidl, buff)) {
+ STRRET s;
+ HRESULT hr = ((IShellFolder*)pOFNEx->psf)->GetDisplayNameOf((LPCITEMIDLIST)pOFNEx->pidl, SHGDN_NORMAL | SHGDN_FORPARSING, &s);
+ if (S_OK != hr) {
+ return FALSE;
+ }
+ switch (s.uType) {
+ case STRRET_CSTR:
+ _tcscpy_s(buff, CString(s.cStr));
+ break;
+ case STRRET_WSTR:
+ _tcscpy_s(buff, CString(s.pOleStr));
+ CoTaskMemFree(s.pOleStr);
+ break;
+ default:
+ return FALSE;
+ }
+ }
+
+ CString fn(buff);
+ /*
+ WIN32_FILE_ATTRIBUTE_DATA fad;
+ if (GetFileAttributesEx(fn, GetFileExInfoStandard, &fad)
+ && (fad.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY))
+ return FALSE;
+ */
+ int i = fn.ReverseFind('.'), j = fn.ReverseFind('\\');
+ if (i < 0 || i < j) {
+ return FALSE;
+ }
+
+ CString mask = m_mask[pOFNEx->lpOFN->nFilterIndex - 1] + _T(";");
+ CString ext = fn.Mid(i).MakeLower() + _T(";");
+
+ *pResult = mask.Find(ext) >= 0 || mask.Find(_T("*.*")) >= 0;
+
+ return TRUE;
}
diff --git a/src/mpc-hc/OpenFileDlg.h b/src/mpc-hc/OpenFileDlg.h
index a1de7e7db..67a3abf70 100644
--- a/src/mpc-hc/OpenFileDlg.h
+++ b/src/mpc-hc/OpenFileDlg.h
@@ -30,32 +30,32 @@
class COpenFileDlg : public CFileDialog
{
- DECLARE_DYNAMIC(COpenFileDlg)
+ DECLARE_DYNAMIC(COpenFileDlg)
private:
- TCHAR* m_buff;
- CAtlArray<CString>& m_mask;
+ TCHAR* m_buff;
+ CAtlArray<CString>& m_mask;
public:
- COpenFileDlg(CAtlArray<CString>& mask, bool fAllowDirSelection,
- LPCTSTR lpszDefExt = NULL,
- LPCTSTR lpszFileName = NULL,
- DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
- LPCTSTR lpszFilter = NULL,
- CWnd* pParentWnd = NULL);
- virtual ~COpenFileDlg();
+ COpenFileDlg(CAtlArray<CString>& mask, bool fAllowDirSelection,
+ LPCTSTR lpszDefExt = NULL,
+ LPCTSTR lpszFileName = NULL,
+ DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
+ LPCTSTR lpszFilter = NULL,
+ CWnd* pParentWnd = NULL);
+ virtual ~COpenFileDlg();
- static bool m_fAllowDirSelection;
- static WNDPROC m_wndProc;
- static LRESULT CALLBACK WindowProcNew(HWND hwnd,UINT message, WPARAM wParam, LPARAM lParam);
+ static bool m_fAllowDirSelection;
+ static WNDPROC m_wndProc;
+ static LRESULT CALLBACK WindowProcNew(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
- virtual BOOL OnInitDialog();
+ virtual BOOL OnInitDialog();
protected:
- DECLARE_MESSAGE_MAP()
- virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
- virtual BOOL OnIncludeItem(OFNOTIFYEX* pOFNEx, LRESULT* pResult);
+ DECLARE_MESSAGE_MAP()
+ virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
+ virtual BOOL OnIncludeItem(OFNOTIFYEX* pOFNEx, LRESULT* pResult);
public:
- afx_msg void OnDestroy();
+ afx_msg void OnDestroy();
};
diff --git a/src/mpc-hc/PPageAccelTbl.cpp b/src/mpc-hc/PPageAccelTbl.cpp
index 9205e592f..053af1655 100644
--- a/src/mpc-hc/PPageAccelTbl.cpp
+++ b/src/mpc-hc/PPageAccelTbl.cpp
@@ -27,101 +27,101 @@
struct APP_COMMAND {
- UINT appcmd;
- LPCTSTR cmdname;
+ UINT appcmd;
+ LPCTSTR cmdname;
};
-APP_COMMAND g_CommandList[] = {
- {0, _T("")},
- {APPCOMMAND_BROWSER_BACKWARD, _T("BROWSER_BACKWARD")},
- {APPCOMMAND_BROWSER_FORWARD, _T("BROWSER_FORWARD")},
- {APPCOMMAND_BROWSER_REFRESH, _T("BROWSER_REFRESH")},
- {APPCOMMAND_BROWSER_STOP, _T("BROWSER_STOP")},
- {APPCOMMAND_BROWSER_SEARCH, _T("BROWSER_SEARCH")},
- {APPCOMMAND_BROWSER_FAVORITES, _T("BROWSER_FAVORITES")},
- {APPCOMMAND_BROWSER_HOME, _T("BROWSER_HOME")},
- {APPCOMMAND_VOLUME_MUTE, _T("VOLUME_MUTE")},
- {APPCOMMAND_VOLUME_DOWN, _T("VOLUME_DOWN")},
- {APPCOMMAND_VOLUME_UP, _T("VOLUME_UP")},
- {APPCOMMAND_MEDIA_NEXTTRACK, _T("MEDIA_NEXTTRACK")},
- {APPCOMMAND_MEDIA_PREVIOUSTRACK, _T("MEDIA_PREVIOUSTRACK")},
- {APPCOMMAND_MEDIA_STOP, _T("MEDIA_STOP")},
- {APPCOMMAND_MEDIA_PLAY_PAUSE, _T("MEDIA_PLAY_PAUSE")},
- {APPCOMMAND_LAUNCH_MAIL, _T("LAUNCH_MAIL")},
- {APPCOMMAND_LAUNCH_MEDIA_SELECT, _T("LAUNCH_MEDIA_SELECT")},
- {APPCOMMAND_LAUNCH_APP1, _T("LAUNCH_APP1")},
- {APPCOMMAND_LAUNCH_APP2, _T("LAUNCH_APP2")},
- {APPCOMMAND_BASS_DOWN, _T("BASS_DOWN")},
- {APPCOMMAND_BASS_BOOST, _T("BASS_BOOST")},
- {APPCOMMAND_BASS_UP, _T("BASS_UP")},
- {APPCOMMAND_TREBLE_DOWN, _T("TREBLE_DOWN")},
- {APPCOMMAND_TREBLE_UP, _T("TREBLE_UP")},
- {APPCOMMAND_MICROPHONE_VOLUME_MUTE, _T("MICROPHONE_VOLUME_MUTE")},
- {APPCOMMAND_MICROPHONE_VOLUME_DOWN, _T("MICROPHONE_VOLUME_DOWN")},
- {APPCOMMAND_MICROPHONE_VOLUME_UP, _T("MICROPHONE_VOLUME_UP")},
- {APPCOMMAND_HELP, _T("HELP")},
- {APPCOMMAND_FIND, _T("FIND")},
- {APPCOMMAND_NEW, _T("NEW")},
- {APPCOMMAND_OPEN, _T("OPEN")},
- {APPCOMMAND_CLOSE, _T("CLOSE")},
- {APPCOMMAND_SAVE, _T("SAVE")},
- {APPCOMMAND_PRINT, _T("PRINT")},
- {APPCOMMAND_UNDO, _T("UNDO")},
- {APPCOMMAND_REDO, _T("REDO")},
- {APPCOMMAND_COPY, _T("COPY")},
- {APPCOMMAND_CUT, _T("CUT")},
- {APPCOMMAND_PASTE, _T("PASTE")},
- {APPCOMMAND_REPLY_TO_MAIL, _T("REPLY_TO_MAIL")},
- {APPCOMMAND_FORWARD_MAIL, _T("FORWARD_MAIL")},
- {APPCOMMAND_SEND_MAIL, _T("SEND_MAIL")},
- {APPCOMMAND_SPELL_CHECK, _T("SPELL_CHECK")},
- {APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE, _T("DICTATE_OR_COMMAND_CONTROL_TOGGLE")},
- {APPCOMMAND_MIC_ON_OFF_TOGGLE, _T("MIC_ON_OFF_TOGGLE")},
- {APPCOMMAND_CORRECTION_LIST, _T("CORRECTION_LIST")},
- {APPCOMMAND_MEDIA_PLAY, _T("MEDIA_PLAY")},
- {APPCOMMAND_MEDIA_PAUSE, _T("MEDIA_PAUSE")},
- {APPCOMMAND_MEDIA_RECORD, _T("MEDIA_RECORD")},
- {APPCOMMAND_MEDIA_FAST_FORWARD, _T("MEDIA_FAST_FORWARD")},
- {APPCOMMAND_MEDIA_REWIND, _T("MEDIA_REWIND")},
- {APPCOMMAND_MEDIA_CHANNEL_UP, _T("MEDIA_CHANNEL_UP")},
- {APPCOMMAND_MEDIA_CHANNEL_DOWN, _T("MEDIA_CHANNEL_DOWN")},
- {APPCOMMAND_DELETE, _T("DELETE")},
- {APPCOMMAND_DWM_FLIP3D, _T("DWM_FLIP3D")},
- {MCE_DETAILS, _T("MCE_DETAILS")},
- {MCE_GUIDE, _T("MCE_GUIDE")},
- {MCE_TVJUMP, _T("MCE_TVJUMP")},
- {MCE_STANDBY, _T("MCE_STANDBY")},
- {MCE_OEM1, _T("MCE_OEM1")},
- {MCE_OEM2, _T("MCE_OEM2")},
- {MCE_MYTV, _T("MCE_MYTV")},
- {MCE_MYVIDEOS, _T("MCE_MYVIDEOS")},
- {MCE_MYPICTURES, _T("MCE_MYPICTURES")},
- {MCE_MYMUSIC, _T("MCE_MYMUSIC")},
- {MCE_RECORDEDTV, _T("MCE_RECORDEDTV")},
- {MCE_DVDANGLE, _T("MCE_DVDANGLE")},
- {MCE_DVDAUDIO, _T("MCE_DVDAUDIO")},
- {MCE_DVDMENU, _T("MCE_DVDMENU")},
- {MCE_DVDSUBTITLE, _T("MCE_DVDSUBTITLE")},
- {MCE_RED, _T("MCE_RED")},
- {MCE_GREEN, _T("MCE_GREEN")},
- {MCE_YELLOW, _T("MCE_YELLOW")},
- {MCE_BLUE, _T("MCE_BLUE")},
- {MCE_MEDIA_NEXTTRACK, _T("MCE_MEDIA_NEXTTRACK")},
- {MCE_MEDIA_PREVIOUSTRACK, _T("MCE_MEDIA_PREVIOUSTRACK")}
+APP_COMMAND g_CommandList[] = {
+ {0, _T("")},
+ {APPCOMMAND_BROWSER_BACKWARD, _T("BROWSER_BACKWARD")},
+ {APPCOMMAND_BROWSER_FORWARD, _T("BROWSER_FORWARD")},
+ {APPCOMMAND_BROWSER_REFRESH, _T("BROWSER_REFRESH")},
+ {APPCOMMAND_BROWSER_STOP, _T("BROWSER_STOP")},
+ {APPCOMMAND_BROWSER_SEARCH, _T("BROWSER_SEARCH")},
+ {APPCOMMAND_BROWSER_FAVORITES, _T("BROWSER_FAVORITES")},
+ {APPCOMMAND_BROWSER_HOME, _T("BROWSER_HOME")},
+ {APPCOMMAND_VOLUME_MUTE, _T("VOLUME_MUTE")},
+ {APPCOMMAND_VOLUME_DOWN, _T("VOLUME_DOWN")},
+ {APPCOMMAND_VOLUME_UP, _T("VOLUME_UP")},
+ {APPCOMMAND_MEDIA_NEXTTRACK, _T("MEDIA_NEXTTRACK")},
+ {APPCOMMAND_MEDIA_PREVIOUSTRACK, _T("MEDIA_PREVIOUSTRACK")},
+ {APPCOMMAND_MEDIA_STOP, _T("MEDIA_STOP")},
+ {APPCOMMAND_MEDIA_PLAY_PAUSE, _T("MEDIA_PLAY_PAUSE")},
+ {APPCOMMAND_LAUNCH_MAIL, _T("LAUNCH_MAIL")},
+ {APPCOMMAND_LAUNCH_MEDIA_SELECT, _T("LAUNCH_MEDIA_SELECT")},
+ {APPCOMMAND_LAUNCH_APP1, _T("LAUNCH_APP1")},
+ {APPCOMMAND_LAUNCH_APP2, _T("LAUNCH_APP2")},
+ {APPCOMMAND_BASS_DOWN, _T("BASS_DOWN")},
+ {APPCOMMAND_BASS_BOOST, _T("BASS_BOOST")},
+ {APPCOMMAND_BASS_UP, _T("BASS_UP")},
+ {APPCOMMAND_TREBLE_DOWN, _T("TREBLE_DOWN")},
+ {APPCOMMAND_TREBLE_UP, _T("TREBLE_UP")},
+ {APPCOMMAND_MICROPHONE_VOLUME_MUTE, _T("MICROPHONE_VOLUME_MUTE")},
+ {APPCOMMAND_MICROPHONE_VOLUME_DOWN, _T("MICROPHONE_VOLUME_DOWN")},
+ {APPCOMMAND_MICROPHONE_VOLUME_UP, _T("MICROPHONE_VOLUME_UP")},
+ {APPCOMMAND_HELP, _T("HELP")},
+ {APPCOMMAND_FIND, _T("FIND")},
+ {APPCOMMAND_NEW, _T("NEW")},
+ {APPCOMMAND_OPEN, _T("OPEN")},
+ {APPCOMMAND_CLOSE, _T("CLOSE")},
+ {APPCOMMAND_SAVE, _T("SAVE")},
+ {APPCOMMAND_PRINT, _T("PRINT")},
+ {APPCOMMAND_UNDO, _T("UNDO")},
+ {APPCOMMAND_REDO, _T("REDO")},
+ {APPCOMMAND_COPY, _T("COPY")},
+ {APPCOMMAND_CUT, _T("CUT")},
+ {APPCOMMAND_PASTE, _T("PASTE")},
+ {APPCOMMAND_REPLY_TO_MAIL, _T("REPLY_TO_MAIL")},
+ {APPCOMMAND_FORWARD_MAIL, _T("FORWARD_MAIL")},
+ {APPCOMMAND_SEND_MAIL, _T("SEND_MAIL")},
+ {APPCOMMAND_SPELL_CHECK, _T("SPELL_CHECK")},
+ {APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE, _T("DICTATE_OR_COMMAND_CONTROL_TOGGLE")},
+ {APPCOMMAND_MIC_ON_OFF_TOGGLE, _T("MIC_ON_OFF_TOGGLE")},
+ {APPCOMMAND_CORRECTION_LIST, _T("CORRECTION_LIST")},
+ {APPCOMMAND_MEDIA_PLAY, _T("MEDIA_PLAY")},
+ {APPCOMMAND_MEDIA_PAUSE, _T("MEDIA_PAUSE")},
+ {APPCOMMAND_MEDIA_RECORD, _T("MEDIA_RECORD")},
+ {APPCOMMAND_MEDIA_FAST_FORWARD, _T("MEDIA_FAST_FORWARD")},
+ {APPCOMMAND_MEDIA_REWIND, _T("MEDIA_REWIND")},
+ {APPCOMMAND_MEDIA_CHANNEL_UP, _T("MEDIA_CHANNEL_UP")},
+ {APPCOMMAND_MEDIA_CHANNEL_DOWN, _T("MEDIA_CHANNEL_DOWN")},
+ {APPCOMMAND_DELETE, _T("DELETE")},
+ {APPCOMMAND_DWM_FLIP3D, _T("DWM_FLIP3D")},
+ {MCE_DETAILS, _T("MCE_DETAILS")},
+ {MCE_GUIDE, _T("MCE_GUIDE")},
+ {MCE_TVJUMP, _T("MCE_TVJUMP")},
+ {MCE_STANDBY, _T("MCE_STANDBY")},
+ {MCE_OEM1, _T("MCE_OEM1")},
+ {MCE_OEM2, _T("MCE_OEM2")},
+ {MCE_MYTV, _T("MCE_MYTV")},
+ {MCE_MYVIDEOS, _T("MCE_MYVIDEOS")},
+ {MCE_MYPICTURES, _T("MCE_MYPICTURES")},
+ {MCE_MYMUSIC, _T("MCE_MYMUSIC")},
+ {MCE_RECORDEDTV, _T("MCE_RECORDEDTV")},
+ {MCE_DVDANGLE, _T("MCE_DVDANGLE")},
+ {MCE_DVDAUDIO, _T("MCE_DVDAUDIO")},
+ {MCE_DVDMENU, _T("MCE_DVDMENU")},
+ {MCE_DVDSUBTITLE, _T("MCE_DVDSUBTITLE")},
+ {MCE_RED, _T("MCE_RED")},
+ {MCE_GREEN, _T("MCE_GREEN")},
+ {MCE_YELLOW, _T("MCE_YELLOW")},
+ {MCE_BLUE, _T("MCE_BLUE")},
+ {MCE_MEDIA_NEXTTRACK, _T("MCE_MEDIA_NEXTTRACK")},
+ {MCE_MEDIA_PREVIOUSTRACK, _T("MCE_MEDIA_PREVIOUSTRACK")}
};
// CPPageAccelTbl dialog
IMPLEMENT_DYNAMIC(CPPageAccelTbl, CPPageBase)
CPPageAccelTbl::CPPageAccelTbl()
- : CPPageBase(CPPageAccelTbl::IDD, CPPageAccelTbl::IDD)
- , m_list(0)
- , m_counter(0)
- , m_fWinLirc(FALSE)
- , m_WinLircLink(_T("http://winlirc.sourceforge.net/"))
- , m_fUIce(FALSE)
- , m_UIceLink(_T("http://www.mediatexx.com/"))
- , m_fGlobalMedia(FALSE)
+ : CPPageBase(CPPageAccelTbl::IDD, CPPageAccelTbl::IDD)
+ , m_list(0)
+ , m_counter(0)
+ , m_fWinLirc(FALSE)
+ , m_WinLircLink(_T("http://winlirc.sourceforge.net/"))
+ , m_fUIce(FALSE)
+ , m_UIceLink(_T("http://www.mediatexx.com/"))
+ , m_fGlobalMedia(FALSE)
{
}
@@ -131,1311 +131,1311 @@ CPPageAccelTbl::~CPPageAccelTbl()
BOOL CPPageAccelTbl::PreTranslateMessage(MSG* pMsg)
{
- if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN
- && (pMsg->hwnd == m_WinLircEdit.m_hWnd || pMsg->hwnd == m_UIceEdit.m_hWnd)) {
- OnApply();
- return TRUE;
- }
+ if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN
+ && (pMsg->hwnd == m_WinLircEdit.m_hWnd || pMsg->hwnd == m_UIceEdit.m_hWnd)) {
+ OnApply();
+ return TRUE;
+ }
- return __super::PreTranslateMessage(pMsg);
+ return __super::PreTranslateMessage(pMsg);
}
void CPPageAccelTbl::SetupList()
{
- for (int row = 0; row < m_list.GetItemCount(); row++) {
- wmcmd& wc = m_wmcmds.GetAt((POSITION)m_list.GetItemData(row));
+ for (int row = 0; row < m_list.GetItemCount(); row++) {
+ wmcmd& wc = m_wmcmds.GetAt((POSITION)m_list.GetItemData(row));
- CString hotkey;
- HotkeyModToString(wc.key, wc.fVirt, hotkey);
- m_list.SetItemText(row, COL_KEY, hotkey);
+ CString hotkey;
+ HotkeyModToString(wc.key, wc.fVirt, hotkey);
+ m_list.SetItemText(row, COL_KEY, hotkey);
- CString id;
- id.Format(_T("%d"), wc.cmd);
- m_list.SetItemText(row, COL_ID, id);
+ CString id;
+ id.Format(_T("%d"), wc.cmd);
+ m_list.SetItemText(row, COL_ID, id);
- m_list.SetItemText(row, COL_MOUSE, MakeMouseButtonLabel(wc.mouse));
+ m_list.SetItemText(row, COL_MOUSE, MakeMouseButtonLabel(wc.mouse));
- m_list.SetItemText(row, COL_MOUSE_FS, MakeMouseButtonLabel(wc.mouseFS));
+ m_list.SetItemText(row, COL_MOUSE_FS, MakeMouseButtonLabel(wc.mouseFS));
- m_list.SetItemText(row, COL_APPCMD, MakeAppCommandLabel(wc.appcmd));
+ m_list.SetItemText(row, COL_APPCMD, MakeAppCommandLabel(wc.appcmd));
- m_list.SetItemText(row, COL_RMCMD, CString(wc.rmcmd));
+ m_list.SetItemText(row, COL_RMCMD, CString(wc.rmcmd));
- CString repcnt;
- repcnt.Format(_T("%d"), wc.rmrepcnt);
- m_list.SetItemText(row, COL_RMREPCNT, repcnt);
- }
+ CString repcnt;
+ repcnt.Format(_T("%d"), wc.rmrepcnt);
+ m_list.SetItemText(row, COL_RMREPCNT, repcnt);
+ }
- int contentSize;
- for (int nCol = COL_CMD; nCol <= COL_RMREPCNT; nCol++) {
- m_list.SetColumnWidth(nCol, LVSCW_AUTOSIZE);
- contentSize = m_list.GetColumnWidth(nCol);
- m_list.SetColumnWidth(nCol, LVSCW_AUTOSIZE_USEHEADER);
- if (contentSize > m_list.GetColumnWidth(nCol)) {
- m_list.SetColumnWidth(nCol, LVSCW_AUTOSIZE);
- }
- }
+ int contentSize;
+ for (int nCol = COL_CMD; nCol <= COL_RMREPCNT; nCol++) {
+ m_list.SetColumnWidth(nCol, LVSCW_AUTOSIZE);
+ contentSize = m_list.GetColumnWidth(nCol);
+ m_list.SetColumnWidth(nCol, LVSCW_AUTOSIZE_USEHEADER);
+ if (contentSize > m_list.GetColumnWidth(nCol)) {
+ m_list.SetColumnWidth(nCol, LVSCW_AUTOSIZE);
+ }
+ }
}
CString CPPageAccelTbl::MakeAccelModLabel(BYTE fVirt)
{
- CString str;
- if (fVirt&FCONTROL) {
- if (!str.IsEmpty()) {
- str += _T(" + ");
- }
- str += _T("Ctrl");
- }
- if (fVirt&FALT) {
- if (!str.IsEmpty()) {
- str += _T(" + ");
- }
- str += _T("Alt");
- }
- if (fVirt&FSHIFT) {
- if (!str.IsEmpty()) {
- str += _T(" + ");
- }
- str += _T("Shift");
- }
- if (str.IsEmpty()) {
- str.LoadString(IDS_AG_NONE);
- }
- return str;
+ CString str;
+ if (fVirt & FCONTROL) {
+ if (!str.IsEmpty()) {
+ str += _T(" + ");
+ }
+ str += _T("Ctrl");
+ }
+ if (fVirt & FALT) {
+ if (!str.IsEmpty()) {
+ str += _T(" + ");
+ }
+ str += _T("Alt");
+ }
+ if (fVirt & FSHIFT) {
+ if (!str.IsEmpty()) {
+ str += _T(" + ");
+ }
+ str += _T("Shift");
+ }
+ if (str.IsEmpty()) {
+ str.LoadString(IDS_AG_NONE);
+ }
+ return str;
}
CString CPPageAccelTbl::MakeAccelVkeyLabel(WORD key, bool fVirtKey)
{
- // Reference page for Virtual-Key Codes: http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.100%29.aspx
- CString str;
-
- switch (key) {
- case VK_LBUTTON:
- str = _T("VK_LBUTTON");
- break;
- case VK_RBUTTON:
- str = _T("VK_RBUTTON");
- break;
- case VK_CANCEL:
- str = _T("VK_CANCEL");
- break;
- case VK_MBUTTON:
- str = _T("VK_MBUTTON");
- break;
- case VK_XBUTTON1:
- str = _T("VK_XBUTTON1");
- break;
- case VK_XBUTTON2:
- str = _T("VK_XBUTTON2");
- break;
- case VK_BACK:
- str = _T("VK_BACK");
- break;
- case VK_TAB:
- str = _T("VK_TAB");
- break;
- case VK_CLEAR:
- str = _T("VK_CLEAR");
- break;
- case VK_RETURN:
- str = _T("VK_RETURN");
- break;
- case VK_SHIFT:
- str = _T("VK_SHIFT");
- break;
- case VK_CONTROL:
- str = _T("VK_CONTROL");
- break;
- case VK_MENU:
- str = _T("VK_MENU");
- break;
- case VK_PAUSE:
- str = _T("VK_PAUSE");
- break;
- case VK_CAPITAL:
- str = _T("VK_CAPITAL");
- break;
- // case VK_KANA: str = _T("VK_KANA"); break;
- // case VK_HANGEUL: str = _T("VK_HANGEUL"); break;
- case VK_HANGUL:
- str = _T("VK_HANGUL");
- break;
- case VK_JUNJA:
- str = _T("VK_JUNJA");
- break;
- case VK_FINAL:
- str = _T("VK_FINAL");
- break;
- // case VK_HANJA: str = _T("VK_HANJA"); break;
- case VK_KANJI:
- str = _T("VK_KANJI");
- break;
- case VK_ESCAPE:
- str = _T("VK_ESCAPE");
- break;
- case VK_CONVERT:
- str = _T("VK_CONVERT");
- break;
- case VK_NONCONVERT:
- str = _T("VK_NONCONVERT");
- break;
- case VK_ACCEPT:
- str = _T("VK_ACCEPT");
- break;
- case VK_MODECHANGE:
- str = _T("VK_MODECHANGE");
- break;
- case VK_SPACE:
- str = _T("VK_SPACE");
- break;
- case VK_PRIOR:
- str = _T("VK_PRIOR");
- break;
- case VK_NEXT:
- str = _T("VK_NEXT");
- break;
- case VK_END:
- str = _T("VK_END");
- break;
- case VK_HOME:
- str = _T("VK_HOME");
- break;
- case VK_LEFT:
- str = _T("VK_LEFT");
- break;
- case VK_UP:
- str = _T("VK_UP");
- break;
- case VK_RIGHT:
- str = _T("VK_RIGHT");
- break;
- case VK_DOWN:
- str = _T("VK_DOWN");
- break;
- case VK_SELECT:
- str = _T("VK_SELECT");
- break;
- case VK_PRINT:
- str = _T("VK_PRINT");
- break;
- case VK_EXECUTE:
- str = _T("VK_EXECUTE");
- break;
- case VK_SNAPSHOT:
- str = _T("VK_SNAPSHOT");
- break;
- case VK_INSERT:
- str = _T("VK_INSERT");
- break;
- case VK_DELETE:
- str = _T("VK_DELETE");
- break;
- case VK_HELP:
- str = _T("VK_HELP");
- break;
- case VK_LWIN:
- str = _T("VK_LWIN");
- break;
- case VK_RWIN:
- str = _T("VK_RWIN");
- break;
- case VK_APPS:
- str = _T("VK_APPS");
- break;
- case VK_SLEEP:
- str = _T("VK_SLEEP");
- break;
- case VK_NUMPAD0:
- str = _T("VK_NUMPAD0");
- break;
- case VK_NUMPAD1:
- str = _T("VK_NUMPAD1");
- break;
- case VK_NUMPAD2:
- str = _T("VK_NUMPAD2");
- break;
- case VK_NUMPAD3:
- str = _T("VK_NUMPAD3");
- break;
- case VK_NUMPAD4:
- str = _T("VK_NUMPAD4");
- break;
- case VK_NUMPAD5:
- str = _T("VK_NUMPAD5");
- break;
- case VK_NUMPAD6:
- str = _T("VK_NUMPAD6");
- break;
- case VK_NUMPAD7:
- str = _T("VK_NUMPAD7");
- break;
- case VK_NUMPAD8:
- str = _T("VK_NUMPAD8");
- break;
- case VK_NUMPAD9:
- str = _T("VK_NUMPAD9");
- break;
- case VK_MULTIPLY:
- str = _T("VK_MULTIPLY");
- break;
- case VK_ADD:
- str = _T("VK_ADD");
- break;
- case VK_SEPARATOR:
- str = _T("VK_SEPARATOR");
- break;
- case VK_SUBTRACT:
- str = _T("VK_SUBTRACT");
- break;
- case VK_DECIMAL:
- str = _T("VK_DECIMAL");
- break;
- case VK_DIVIDE:
- str = _T("VK_DIVIDE");
- break;
- case VK_F1:
- str = _T("VK_F1");
- break;
- case VK_F2:
- str = _T("VK_F2");
- break;
- case VK_F3:
- str = _T("VK_F3");
- break;
- case VK_F4:
- str = _T("VK_F4");
- break;
- case VK_F5:
- str = _T("VK_F5");
- break;
- case VK_F6:
- str = _T("VK_F6");
- break;
- case VK_F7:
- str = _T("VK_F7");
- break;
- case VK_F8:
- str = _T("VK_F8");
- break;
- case VK_F9:
- str = _T("VK_F9");
- break;
- case VK_F10:
- str = _T("VK_F10");
- break;
- case VK_F11:
- str = _T("VK_F11");
- break;
- case VK_F12:
- str = _T("VK_F12");
- break;
- case VK_F13:
- str = _T("VK_F13");
- break;
- case VK_F14:
- str = _T("VK_F14");
- break;
- case VK_F15:
- str = _T("VK_F15");
- break;
- case VK_F16:
- str = _T("VK_F16");
- break;
- case VK_F17:
- str = _T("VK_F17");
- break;
- case VK_F18:
- str = _T("VK_F18");
- break;
- case VK_F19:
- str = _T("VK_F19");
- break;
- case VK_F20:
- str = _T("VK_F20");
- break;
- case VK_F21:
- str = _T("VK_F21");
- break;
- case VK_F22:
- str = _T("VK_F22");
- break;
- case VK_F23:
- str = _T("VK_F23");
- break;
- case VK_F24:
- str = _T("VK_F24");
- break;
- case VK_NUMLOCK:
- str = _T("VK_NUMLOCK");
- break;
- case VK_SCROLL:
- str = _T("VK_SCROLL");
- break;
- // case VK_OEM_NEC_EQUAL: str = _T("VK_OEM_NEC_EQUAL"); break;
- case VK_OEM_FJ_JISHO:
- str = _T("VK_OEM_FJ_JISHO");
- break;
- case VK_OEM_FJ_MASSHOU:
- str = _T("VK_OEM_FJ_MASSHOU");
- break;
- case VK_OEM_FJ_TOUROKU:
- str = _T("VK_OEM_FJ_TOUROKU");
- break;
- case VK_OEM_FJ_LOYA:
- str = _T("VK_OEM_FJ_LOYA");
- break;
- case VK_OEM_FJ_ROYA:
- str = _T("VK_OEM_FJ_ROYA");
- break;
- case VK_LSHIFT:
- str = _T("VK_LSHIFT");
- break;
- case VK_RSHIFT:
- str = _T("VK_RSHIFT");
- break;
- case VK_LCONTROL:
- str = _T("VK_LCONTROL");
- break;
- case VK_RCONTROL:
- str = _T("VK_RCONTROL");
- break;
- case VK_LMENU:
- str = _T("VK_LMENU");
- break;
- case VK_RMENU:
- str = _T("VK_RMENU");
- break;
- case VK_BROWSER_BACK:
- str = _T("VK_BROWSER_BACK");
- break;
- case VK_BROWSER_FORWARD:
- str = _T("VK_BROWSER_FORWARD");
- break;
- case VK_BROWSER_REFRESH:
- str = _T("VK_BROWSER_REFRESH");
- break;
- case VK_BROWSER_STOP:
- str = _T("VK_BROWSER_STOP");
- break;
- case VK_BROWSER_SEARCH:
- str = _T("VK_BROWSER_SEARCH");
- break;
- case VK_BROWSER_FAVORITES:
- str = _T("VK_BROWSER_FAVORITES");
- break;
- case VK_BROWSER_HOME:
- str = _T("VK_BROWSER_HOME");
- break;
- case VK_VOLUME_MUTE:
- str = _T("VK_VOLUME_MUTE");
- break;
- case VK_VOLUME_DOWN:
- str = _T("VK_VOLUME_DOWN");
- break;
- case VK_VOLUME_UP:
- str = _T("VK_VOLUME_UP");
- break;
- case VK_MEDIA_NEXT_TRACK:
- str = _T("VK_MEDIA_NEXT_TRACK");
- break;
- case VK_MEDIA_PREV_TRACK:
- str = _T("VK_MEDIA_PREV_TRACK");
- break;
- case VK_MEDIA_STOP:
- str = _T("VK_MEDIA_STOP");
- break;
- case VK_MEDIA_PLAY_PAUSE:
- str = _T("VK_MEDIA_PLAY_PAUSE");
- break;
- case VK_LAUNCH_MAIL:
- str = _T("VK_LAUNCH_MAIL");
- break;
- case VK_LAUNCH_MEDIA_SELECT:
- str = _T("VK_LAUNCH_MEDIA_SELECT");
- break;
- case VK_LAUNCH_APP1:
- str = _T("VK_LAUNCH_APP1");
- break;
- case VK_LAUNCH_APP2:
- str = _T("VK_LAUNCH_APP2");
- break;
- case VK_OEM_1:
- str = _T("VK_OEM_1");
- break;
- case VK_OEM_PLUS:
- str = _T("VK_OEM_PLUS");
- break;
- case VK_OEM_COMMA:
- str = _T("VK_OEM_COMMA");
- break;
- case VK_OEM_MINUS:
- str = _T("VK_OEM_MINUS");
- break;
- case VK_OEM_PERIOD:
- str = _T("VK_OEM_PERIOD");
- break;
- case VK_OEM_2:
- str = _T("VK_OEM_2");
- break;
- case VK_OEM_3:
- str = _T("VK_OEM_3");
- break;
- case VK_OEM_4:
- str = _T("VK_OEM_4");
- break;
- case VK_OEM_5:
- str = _T("VK_OEM_5");
- break;
- case VK_OEM_6:
- str = _T("VK_OEM_6");
- break;
- case VK_OEM_7:
- str = _T("VK_OEM_7");
- break;
- case VK_OEM_8:
- str = _T("VK_OEM_8");
- break;
- case VK_OEM_AX:
- str = _T("VK_OEM_AX");
- break;
- case VK_OEM_102:
- str = _T("VK_OEM_102");
- break;
- case VK_ICO_HELP:
- str = _T("VK_ICO_HELP");
- break;
- case VK_ICO_00:
- str = _T("VK_ICO_00");
- break;
- case VK_PROCESSKEY:
- str = _T("VK_PROCESSKEY");
- break;
- case VK_ICO_CLEAR:
- str = _T("VK_ICO_CLEAR");
- break;
- case VK_PACKET:
- str = _T("VK_PACKET");
- break;
- case VK_OEM_RESET:
- str = _T("VK_OEM_RESET");
- break;
- case VK_OEM_JUMP:
- str = _T("VK_OEM_JUMP");
- break;
- case VK_OEM_PA1:
- str = _T("VK_OEM_PA1");
- break;
- case VK_OEM_PA2:
- str = _T("VK_OEM_PA2");
- break;
- case VK_OEM_PA3:
- str = _T("VK_OEM_PA3");
- break;
- case VK_OEM_WSCTRL:
- str = _T("VK_OEM_WSCTRL");
- break;
- case VK_OEM_CUSEL:
- str = _T("VK_OEM_CUSEL");
- break;
- case VK_OEM_ATTN:
- str = _T("VK_OEM_ATTN");
- break;
- case VK_OEM_FINISH:
- str = _T("VK_OEM_FINISH");
- break;
- case VK_OEM_COPY:
- str = _T("VK_OEM_COPY");
- break;
- case VK_OEM_AUTO:
- str = _T("VK_OEM_AUTO");
- break;
- case VK_OEM_ENLW:
- str = _T("VK_OEM_ENLW");
- break;
- case VK_OEM_BACKTAB:
- str = _T("VK_OEM_BACKTAB");
- break;
- case VK_ATTN:
- str = _T("VK_ATTN");
- break;
- case VK_CRSEL:
- str = _T("VK_CRSEL");
- break;
- case VK_EXSEL:
- str = _T("VK_EXSEL");
- break;
- case VK_EREOF:
- str = _T("VK_EREOF");
- break;
- case VK_PLAY:
- str = _T("VK_PLAY");
- break;
- case VK_ZOOM:
- str = _T("VK_ZOOM");
- break;
- case VK_NONAME:
- str = _T("VK_NONAME");
- break;
- case VK_PA1:
- str = _T("VK_PA1");
- break;
- case VK_OEM_CLEAR:
- str = _T("VK_OEM_CLEAR");
- break;
- case 0x07:
- case 0x0E:
- case 0x0F:
- case 0x16:
- case 0x1A:
- case 0x3A:
- case 0x3B:
- case 0x3C:
- case 0x3D:
- case 0x3E:
- case 0x3F:
- case 0x40:
- str.Format(_T("Undefined (0x%02x)"), (TCHAR)key);
- break;
- case 0x0A:
- case 0x0B:
- case 0x5E:
- case 0xB8:
- case 0xB9:
- case 0xC1:
- case 0xC2:
- case 0xC3:
- case 0xC4:
- case 0xC5:
- case 0xC6:
- case 0xC7:
- case 0xC8:
- case 0xC9:
- case 0xCA:
- case 0xCB:
- case 0xCC:
- case 0xCD:
- case 0xCE:
- case 0xCF:
- case 0xD0:
- case 0xD1:
- case 0xD2:
- case 0xD3:
- case 0xD4:
- case 0xD5:
- case 0xD6:
- case 0xD7:
- case 0xE0:
- str.Format(_T("Reserved (0x%02x)"), (TCHAR)key);
- break;
- case 0x88:
- case 0x89:
- case 0x8A:
- case 0x8B:
- case 0x8C:
- case 0x8D:
- case 0x8E:
- case 0x8F:
- case 0x97:
- case 0x98:
- case 0x99:
- case 0x9A:
- case 0x9B:
- case 0x9C:
- case 0x9D:
- case 0x9E:
- case 0x9F:
- case 0xD8:
- case 0xD9:
- case 0xDA:
- case 0xE8:
- str.Format(_T("Unassigned (0x%02x)"), (TCHAR)key);
- break;
- case 0xFF:
- str = _T("Multimedia keys");
- break;
- default:
- // if ('0' <= key && key <= '9' || 'A' <= key && key <= 'Z')
- str.Format(_T("%c"), (TCHAR)key);
- break;
- }
-
- return str;
+ // Reference page for Virtual-Key Codes: http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.100%29.aspx
+ CString str;
+
+ switch (key) {
+ case VK_LBUTTON:
+ str = _T("VK_LBUTTON");
+ break;
+ case VK_RBUTTON:
+ str = _T("VK_RBUTTON");
+ break;
+ case VK_CANCEL:
+ str = _T("VK_CANCEL");
+ break;
+ case VK_MBUTTON:
+ str = _T("VK_MBUTTON");
+ break;
+ case VK_XBUTTON1:
+ str = _T("VK_XBUTTON1");
+ break;
+ case VK_XBUTTON2:
+ str = _T("VK_XBUTTON2");
+ break;
+ case VK_BACK:
+ str = _T("VK_BACK");
+ break;
+ case VK_TAB:
+ str = _T("VK_TAB");
+ break;
+ case VK_CLEAR:
+ str = _T("VK_CLEAR");
+ break;
+ case VK_RETURN:
+ str = _T("VK_RETURN");
+ break;
+ case VK_SHIFT:
+ str = _T("VK_SHIFT");
+ break;
+ case VK_CONTROL:
+ str = _T("VK_CONTROL");
+ break;
+ case VK_MENU:
+ str = _T("VK_MENU");
+ break;
+ case VK_PAUSE:
+ str = _T("VK_PAUSE");
+ break;
+ case VK_CAPITAL:
+ str = _T("VK_CAPITAL");
+ break;
+ // case VK_KANA: str = _T("VK_KANA"); break;
+ // case VK_HANGEUL: str = _T("VK_HANGEUL"); break;
+ case VK_HANGUL:
+ str = _T("VK_HANGUL");
+ break;
+ case VK_JUNJA:
+ str = _T("VK_JUNJA");
+ break;
+ case VK_FINAL:
+ str = _T("VK_FINAL");
+ break;
+ // case VK_HANJA: str = _T("VK_HANJA"); break;
+ case VK_KANJI:
+ str = _T("VK_KANJI");
+ break;
+ case VK_ESCAPE:
+ str = _T("VK_ESCAPE");
+ break;
+ case VK_CONVERT:
+ str = _T("VK_CONVERT");
+ break;
+ case VK_NONCONVERT:
+ str = _T("VK_NONCONVERT");
+ break;
+ case VK_ACCEPT:
+ str = _T("VK_ACCEPT");
+ break;
+ case VK_MODECHANGE:
+ str = _T("VK_MODECHANGE");
+ break;
+ case VK_SPACE:
+ str = _T("VK_SPACE");
+ break;
+ case VK_PRIOR:
+ str = _T("VK_PRIOR");
+ break;
+ case VK_NEXT:
+ str = _T("VK_NEXT");
+ break;
+ case VK_END:
+ str = _T("VK_END");
+ break;
+ case VK_HOME:
+ str = _T("VK_HOME");
+ break;
+ case VK_LEFT:
+ str = _T("VK_LEFT");
+ break;
+ case VK_UP:
+ str = _T("VK_UP");
+ break;
+ case VK_RIGHT:
+ str = _T("VK_RIGHT");
+ break;
+ case VK_DOWN:
+ str = _T("VK_DOWN");
+ break;
+ case VK_SELECT:
+ str = _T("VK_SELECT");
+ break;
+ case VK_PRINT:
+ str = _T("VK_PRINT");
+ break;
+ case VK_EXECUTE:
+ str = _T("VK_EXECUTE");
+ break;
+ case VK_SNAPSHOT:
+ str = _T("VK_SNAPSHOT");
+ break;
+ case VK_INSERT:
+ str = _T("VK_INSERT");
+ break;
+ case VK_DELETE:
+ str = _T("VK_DELETE");
+ break;
+ case VK_HELP:
+ str = _T("VK_HELP");
+ break;
+ case VK_LWIN:
+ str = _T("VK_LWIN");
+ break;
+ case VK_RWIN:
+ str = _T("VK_RWIN");
+ break;
+ case VK_APPS:
+ str = _T("VK_APPS");
+ break;
+ case VK_SLEEP:
+ str = _T("VK_SLEEP");
+ break;
+ case VK_NUMPAD0:
+ str = _T("VK_NUMPAD0");
+ break;
+ case VK_NUMPAD1:
+ str = _T("VK_NUMPAD1");
+ break;
+ case VK_NUMPAD2:
+ str = _T("VK_NUMPAD2");
+ break;
+ case VK_NUMPAD3:
+ str = _T("VK_NUMPAD3");
+ break;
+ case VK_NUMPAD4:
+ str = _T("VK_NUMPAD4");
+ break;
+ case VK_NUMPAD5:
+ str = _T("VK_NUMPAD5");
+ break;
+ case VK_NUMPAD6:
+ str = _T("VK_NUMPAD6");
+ break;
+ case VK_NUMPAD7:
+ str = _T("VK_NUMPAD7");
+ break;
+ case VK_NUMPAD8:
+ str = _T("VK_NUMPAD8");
+ break;
+ case VK_NUMPAD9:
+ str = _T("VK_NUMPAD9");
+ break;
+ case VK_MULTIPLY:
+ str = _T("VK_MULTIPLY");
+ break;
+ case VK_ADD:
+ str = _T("VK_ADD");
+ break;
+ case VK_SEPARATOR:
+ str = _T("VK_SEPARATOR");
+ break;
+ case VK_SUBTRACT:
+ str = _T("VK_SUBTRACT");
+ break;
+ case VK_DECIMAL:
+ str = _T("VK_DECIMAL");
+ break;
+ case VK_DIVIDE:
+ str = _T("VK_DIVIDE");
+ break;
+ case VK_F1:
+ str = _T("VK_F1");
+ break;
+ case VK_F2:
+ str = _T("VK_F2");
+ break;
+ case VK_F3:
+ str = _T("VK_F3");
+ break;
+ case VK_F4:
+ str = _T("VK_F4");
+ break;
+ case VK_F5:
+ str = _T("VK_F5");
+ break;
+ case VK_F6:
+ str = _T("VK_F6");
+ break;
+ case VK_F7:
+ str = _T("VK_F7");
+ break;
+ case VK_F8:
+ str = _T("VK_F8");
+ break;
+ case VK_F9:
+ str = _T("VK_F9");
+ break;
+ case VK_F10:
+ str = _T("VK_F10");
+ break;
+ case VK_F11:
+ str = _T("VK_F11");
+ break;
+ case VK_F12:
+ str = _T("VK_F12");
+ break;
+ case VK_F13:
+ str = _T("VK_F13");
+ break;
+ case VK_F14:
+ str = _T("VK_F14");
+ break;
+ case VK_F15:
+ str = _T("VK_F15");
+ break;
+ case VK_F16:
+ str = _T("VK_F16");
+ break;
+ case VK_F17:
+ str = _T("VK_F17");
+ break;
+ case VK_F18:
+ str = _T("VK_F18");
+ break;
+ case VK_F19:
+ str = _T("VK_F19");
+ break;
+ case VK_F20:
+ str = _T("VK_F20");
+ break;
+ case VK_F21:
+ str = _T("VK_F21");
+ break;
+ case VK_F22:
+ str = _T("VK_F22");
+ break;
+ case VK_F23:
+ str = _T("VK_F23");
+ break;
+ case VK_F24:
+ str = _T("VK_F24");
+ break;
+ case VK_NUMLOCK:
+ str = _T("VK_NUMLOCK");
+ break;
+ case VK_SCROLL:
+ str = _T("VK_SCROLL");
+ break;
+ // case VK_OEM_NEC_EQUAL: str = _T("VK_OEM_NEC_EQUAL"); break;
+ case VK_OEM_FJ_JISHO:
+ str = _T("VK_OEM_FJ_JISHO");
+ break;
+ case VK_OEM_FJ_MASSHOU:
+ str = _T("VK_OEM_FJ_MASSHOU");
+ break;
+ case VK_OEM_FJ_TOUROKU:
+ str = _T("VK_OEM_FJ_TOUROKU");
+ break;
+ case VK_OEM_FJ_LOYA:
+ str = _T("VK_OEM_FJ_LOYA");
+ break;
+ case VK_OEM_FJ_ROYA:
+ str = _T("VK_OEM_FJ_ROYA");
+ break;
+ case VK_LSHIFT:
+ str = _T("VK_LSHIFT");
+ break;
+ case VK_RSHIFT:
+ str = _T("VK_RSHIFT");
+ break;
+ case VK_LCONTROL:
+ str = _T("VK_LCONTROL");
+ break;
+ case VK_RCONTROL:
+ str = _T("VK_RCONTROL");
+ break;
+ case VK_LMENU:
+ str = _T("VK_LMENU");
+ break;
+ case VK_RMENU:
+ str = _T("VK_RMENU");
+ break;
+ case VK_BROWSER_BACK:
+ str = _T("VK_BROWSER_BACK");
+ break;
+ case VK_BROWSER_FORWARD:
+ str = _T("VK_BROWSER_FORWARD");
+ break;
+ case VK_BROWSER_REFRESH:
+ str = _T("VK_BROWSER_REFRESH");
+ break;
+ case VK_BROWSER_STOP:
+ str = _T("VK_BROWSER_STOP");
+ break;
+ case VK_BROWSER_SEARCH:
+ str = _T("VK_BROWSER_SEARCH");
+ break;
+ case VK_BROWSER_FAVORITES:
+ str = _T("VK_BROWSER_FAVORITES");
+ break;
+ case VK_BROWSER_HOME:
+ str = _T("VK_BROWSER_HOME");
+ break;
+ case VK_VOLUME_MUTE:
+ str = _T("VK_VOLUME_MUTE");
+ break;
+ case VK_VOLUME_DOWN:
+ str = _T("VK_VOLUME_DOWN");
+ break;
+ case VK_VOLUME_UP:
+ str = _T("VK_VOLUME_UP");
+ break;
+ case VK_MEDIA_NEXT_TRACK:
+ str = _T("VK_MEDIA_NEXT_TRACK");
+ break;
+ case VK_MEDIA_PREV_TRACK:
+ str = _T("VK_MEDIA_PREV_TRACK");
+ break;
+ case VK_MEDIA_STOP:
+ str = _T("VK_MEDIA_STOP");
+ break;
+ case VK_MEDIA_PLAY_PAUSE:
+ str = _T("VK_MEDIA_PLAY_PAUSE");
+ break;
+ case VK_LAUNCH_MAIL:
+ str = _T("VK_LAUNCH_MAIL");
+ break;
+ case VK_LAUNCH_MEDIA_SELECT:
+ str = _T("VK_LAUNCH_MEDIA_SELECT");
+ break;
+ case VK_LAUNCH_APP1:
+ str = _T("VK_LAUNCH_APP1");
+ break;
+ case VK_LAUNCH_APP2:
+ str = _T("VK_LAUNCH_APP2");
+ break;
+ case VK_OEM_1:
+ str = _T("VK_OEM_1");
+ break;
+ case VK_OEM_PLUS:
+ str = _T("VK_OEM_PLUS");
+ break;
+ case VK_OEM_COMMA:
+ str = _T("VK_OEM_COMMA");
+ break;
+ case VK_OEM_MINUS:
+ str = _T("VK_OEM_MINUS");
+ break;
+ case VK_OEM_PERIOD:
+ str = _T("VK_OEM_PERIOD");
+ break;
+ case VK_OEM_2:
+ str = _T("VK_OEM_2");
+ break;
+ case VK_OEM_3:
+ str = _T("VK_OEM_3");
+ break;
+ case VK_OEM_4:
+ str = _T("VK_OEM_4");
+ break;
+ case VK_OEM_5:
+ str = _T("VK_OEM_5");
+ break;
+ case VK_OEM_6:
+ str = _T("VK_OEM_6");
+ break;
+ case VK_OEM_7:
+ str = _T("VK_OEM_7");
+ break;
+ case VK_OEM_8:
+ str = _T("VK_OEM_8");
+ break;
+ case VK_OEM_AX:
+ str = _T("VK_OEM_AX");
+ break;
+ case VK_OEM_102:
+ str = _T("VK_OEM_102");
+ break;
+ case VK_ICO_HELP:
+ str = _T("VK_ICO_HELP");
+ break;
+ case VK_ICO_00:
+ str = _T("VK_ICO_00");
+ break;
+ case VK_PROCESSKEY:
+ str = _T("VK_PROCESSKEY");
+ break;
+ case VK_ICO_CLEAR:
+ str = _T("VK_ICO_CLEAR");
+ break;
+ case VK_PACKET:
+ str = _T("VK_PACKET");
+ break;
+ case VK_OEM_RESET:
+ str = _T("VK_OEM_RESET");
+ break;
+ case VK_OEM_JUMP:
+ str = _T("VK_OEM_JUMP");
+ break;
+ case VK_OEM_PA1:
+ str = _T("VK_OEM_PA1");
+ break;
+ case VK_OEM_PA2:
+ str = _T("VK_OEM_PA2");
+ break;
+ case VK_OEM_PA3:
+ str = _T("VK_OEM_PA3");
+ break;
+ case VK_OEM_WSCTRL:
+ str = _T("VK_OEM_WSCTRL");
+ break;
+ case VK_OEM_CUSEL:
+ str = _T("VK_OEM_CUSEL");
+ break;
+ case VK_OEM_ATTN:
+ str = _T("VK_OEM_ATTN");
+ break;
+ case VK_OEM_FINISH:
+ str = _T("VK_OEM_FINISH");
+ break;
+ case VK_OEM_COPY:
+ str = _T("VK_OEM_COPY");
+ break;
+ case VK_OEM_AUTO:
+ str = _T("VK_OEM_AUTO");
+ break;
+ case VK_OEM_ENLW:
+ str = _T("VK_OEM_ENLW");
+ break;
+ case VK_OEM_BACKTAB:
+ str = _T("VK_OEM_BACKTAB");
+ break;
+ case VK_ATTN:
+ str = _T("VK_ATTN");
+ break;
+ case VK_CRSEL:
+ str = _T("VK_CRSEL");
+ break;
+ case VK_EXSEL:
+ str = _T("VK_EXSEL");
+ break;
+ case VK_EREOF:
+ str = _T("VK_EREOF");
+ break;
+ case VK_PLAY:
+ str = _T("VK_PLAY");
+ break;
+ case VK_ZOOM:
+ str = _T("VK_ZOOM");
+ break;
+ case VK_NONAME:
+ str = _T("VK_NONAME");
+ break;
+ case VK_PA1:
+ str = _T("VK_PA1");
+ break;
+ case VK_OEM_CLEAR:
+ str = _T("VK_OEM_CLEAR");
+ break;
+ case 0x07:
+ case 0x0E:
+ case 0x0F:
+ case 0x16:
+ case 0x1A:
+ case 0x3A:
+ case 0x3B:
+ case 0x3C:
+ case 0x3D:
+ case 0x3E:
+ case 0x3F:
+ case 0x40:
+ str.Format(_T("Undefined (0x%02x)"), (TCHAR)key);
+ break;
+ case 0x0A:
+ case 0x0B:
+ case 0x5E:
+ case 0xB8:
+ case 0xB9:
+ case 0xC1:
+ case 0xC2:
+ case 0xC3:
+ case 0xC4:
+ case 0xC5:
+ case 0xC6:
+ case 0xC7:
+ case 0xC8:
+ case 0xC9:
+ case 0xCA:
+ case 0xCB:
+ case 0xCC:
+ case 0xCD:
+ case 0xCE:
+ case 0xCF:
+ case 0xD0:
+ case 0xD1:
+ case 0xD2:
+ case 0xD3:
+ case 0xD4:
+ case 0xD5:
+ case 0xD6:
+ case 0xD7:
+ case 0xE0:
+ str.Format(_T("Reserved (0x%02x)"), (TCHAR)key);
+ break;
+ case 0x88:
+ case 0x89:
+ case 0x8A:
+ case 0x8B:
+ case 0x8C:
+ case 0x8D:
+ case 0x8E:
+ case 0x8F:
+ case 0x97:
+ case 0x98:
+ case 0x99:
+ case 0x9A:
+ case 0x9B:
+ case 0x9C:
+ case 0x9D:
+ case 0x9E:
+ case 0x9F:
+ case 0xD8:
+ case 0xD9:
+ case 0xDA:
+ case 0xE8:
+ str.Format(_T("Unassigned (0x%02x)"), (TCHAR)key);
+ break;
+ case 0xFF:
+ str = _T("Multimedia keys");
+ break;
+ default:
+ // if ('0' <= key && key <= '9' || 'A' <= key && key <= 'Z')
+ str.Format(_T("%c"), (TCHAR)key);
+ break;
+ }
+
+ return str;
}
CString CPPageAccelTbl::MakeAccelShortcutLabel(UINT id)
{
- CList<wmcmd>& wmcmds = AfxGetAppSettings().wmcmds;
- POSITION pos = wmcmds.GetHeadPosition();
- while (pos) {
- ACCEL& a = wmcmds.GetNext(pos);
- if (a.cmd == id) {
- return (MakeAccelShortcutLabel(a));
- }
- }
-
- return _T("");
+ CList<wmcmd>& wmcmds = AfxGetAppSettings().wmcmds;
+ POSITION pos = wmcmds.GetHeadPosition();
+ while (pos) {
+ ACCEL& a = wmcmds.GetNext(pos);
+ if (a.cmd == id) {
+ return (MakeAccelShortcutLabel(a));
+ }
+ }
+
+ return _T("");
}
CString CPPageAccelTbl::MakeAccelShortcutLabel(ACCEL& a)
{
- // Reference page for Virtual-Key Codes: http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.100%29.aspx
- CString str;
-
- switch (a.key) {
- case VK_LBUTTON:
- str = _T("LBtn");
- break;
- case VK_RBUTTON:
- str = _T("RBtn");
- break;
- case VK_CANCEL:
- str = _T("Cancel");
- break;
- case VK_MBUTTON:
- str = _T("MBtn");
- break;
- case VK_XBUTTON1:
- str = _T("X1Btn");
- break;
- case VK_XBUTTON2:
- str = _T("X2Btn");
- break;
- case VK_BACK:
- str = _T("Back");
- break;
- case VK_TAB:
- str = _T("Tab");
- break;
- case VK_CLEAR:
- str = _T("Clear");
- break;
- case VK_RETURN:
- str = _T("Enter");
- break;
- case VK_SHIFT:
- str = _T("Shift");
- break;
- case VK_CONTROL:
- str = _T("Ctrl");
- break;
- case VK_MENU:
- str = _T("Alt");
- break;
- case VK_PAUSE:
- str = _T("Pause");
- break;
- case VK_CAPITAL:
- str = _T("Capital");
- break;
- // case VK_KANA: str = _T("Kana"); break;
- // case VK_HANGEUL: str = _T("Hangeul"); break;
- case VK_HANGUL:
- str = _T("Hangul");
- break;
- case VK_JUNJA:
- str = _T("Junja");
- break;
- case VK_FINAL:
- str = _T("Final");
- break;
- // case VK_HANJA: str = _T("Hanja"); break;
- case VK_KANJI:
- str = _T("Kanji");
- break;
- case VK_ESCAPE:
- str = _T("Escape");
- break;
- case VK_CONVERT:
- str = _T("Convert");
- break;
- case VK_NONCONVERT:
- str = _T("Non Convert");
- break;
- case VK_ACCEPT:
- str = _T("Accept");
- break;
- case VK_MODECHANGE:
- str = _T("Mode Change");
- break;
- case VK_SPACE:
- str = _T("Space");
- break;
- case VK_PRIOR:
- str = _T("PgUp");
- break;
- case VK_NEXT:
- str = _T("PgDn");
- break;
- case VK_END:
- str = _T("End");
- break;
- case VK_HOME:
- str = _T("Home");
- break;
- case VK_LEFT:
- str = _T("Left");
- break;
- case VK_UP:
- str = _T("Up");
- break;
- case VK_RIGHT:
- str = _T("Right");
- break;
- case VK_DOWN:
- str = _T("Down");
- break;
- case VK_SELECT:
- str = _T("Select");
- break;
- case VK_PRINT:
- str = _T("Print");
- break;
- case VK_EXECUTE:
- str = _T("Execute");
- break;
- case VK_SNAPSHOT:
- str = _T("Snapshot");
- break;
- case VK_INSERT:
- str = _T("Insert");
- break;
- case VK_DELETE:
- str = _T("Delete");
- break;
- case VK_HELP:
- str = _T("Help");
- break;
- case VK_LWIN:
- str = _T("LWin");
- break;
- case VK_RWIN:
- str = _T("RWin");
- break;
- case VK_APPS:
- str = _T("Apps");
- break;
- case VK_SLEEP:
- str = _T("Sleep");
- break;
- case VK_NUMPAD0:
- str = _T("Numpad 0");
- break;
- case VK_NUMPAD1:
- str = _T("Numpad 1");
- break;
- case VK_NUMPAD2:
- str = _T("Numpad 2");
- break;
- case VK_NUMPAD3:
- str = _T("Numpad 3");
- break;
- case VK_NUMPAD4:
- str = _T("Numpad 4");
- break;
- case VK_NUMPAD5:
- str = _T("Numpad 5");
- break;
- case VK_NUMPAD6:
- str = _T("Numpad 6");
- break;
- case VK_NUMPAD7:
- str = _T("Numpad 7");
- break;
- case VK_NUMPAD8:
- str = _T("Numpad 8");
- break;
- case VK_NUMPAD9:
- str = _T("Numpad 9");
- break;
- case VK_MULTIPLY:
- str = _T("Multiply");
- break;
- case VK_ADD:
- str = _T("Add");
- break;
- case VK_SEPARATOR:
- str = _T("Separator");
- break;
- case VK_SUBTRACT:
- str = _T("Subtract");
- break;
- case VK_DECIMAL:
- str = _T("Decimal");
- break;
- case VK_DIVIDE:
- str = _T("Divide");
- break;
- case VK_F1:
- str = _T("F1");
- break;
- case VK_F2:
- str = _T("F2");
- break;
- case VK_F3:
- str = _T("F3");
- break;
- case VK_F4:
- str = _T("F4");
- break;
- case VK_F5:
- str = _T("F5");
- break;
- case VK_F6:
- str = _T("F6");
- break;
- case VK_F7:
- str = _T("F7");
- break;
- case VK_F8:
- str = _T("F8");
- break;
- case VK_F9:
- str = _T("F9");
- break;
- case VK_F10:
- str = _T("F10");
- break;
- case VK_F11:
- str = _T("F11");
- break;
- case VK_F12:
- str = _T("F12");
- break;
- case VK_F13:
- str = _T("F13");
- break;
- case VK_F14:
- str = _T("F14");
- break;
- case VK_F15:
- str = _T("F15");
- break;
- case VK_F16:
- str = _T("F16");
- break;
- case VK_F17:
- str = _T("F17");
- break;
- case VK_F18:
- str = _T("F18");
- break;
- case VK_F19:
- str = _T("F19");
- break;
- case VK_F20:
- str = _T("F20");
- break;
- case VK_F21:
- str = _T("F21");
- break;
- case VK_F22:
- str = _T("F22");
- break;
- case VK_F23:
- str = _T("F23");
- break;
- case VK_F24:
- str = _T("F24");
- break;
- case VK_NUMLOCK:
- str = _T("Numlock");
- break;
- case VK_SCROLL:
- str = _T("Scroll");
- break;
- // case VK_OEM_NEC_EQUAL: str = _T("OEM NEC Equal"); break;
- case VK_OEM_FJ_JISHO:
- str = _T("OEM FJ Jisho");
- break;
- case VK_OEM_FJ_MASSHOU:
- str = _T("OEM FJ Msshou");
- break;
- case VK_OEM_FJ_TOUROKU:
- str = _T("OEM FJ Touroku");
- break;
- case VK_OEM_FJ_LOYA:
- str = _T("OEM FJ Loya");
- break;
- case VK_OEM_FJ_ROYA:
- str = _T("OEM FJ Roya");
- break;
- case VK_LSHIFT:
- str = _T("LShift");
- break;
- case VK_RSHIFT:
- str = _T("RShift");
- break;
- case VK_LCONTROL:
- str = _T("LCtrl");
- break;
- case VK_RCONTROL:
- str = _T("RCtrl");
- break;
- case VK_LMENU:
- str = _T("LAlt");
- break;
- case VK_RMENU:
- str = _T("RAlt");
- break;
- case VK_BROWSER_BACK:
- str = _T("Browser Back");
- break;
- case VK_BROWSER_FORWARD:
- str = _T("Browser Forward");
- break;
- case VK_BROWSER_REFRESH:
- str = _T("Browser Refresh");
- break;
- case VK_BROWSER_STOP:
- str = _T("Browser Stop");
- break;
- case VK_BROWSER_SEARCH:
- str = _T("Browser Search");
- break;
- case VK_BROWSER_FAVORITES:
- str = _T("Browser Favorites");
- break;
- case VK_BROWSER_HOME:
- str = _T("Browser Home");
- break;
- case VK_VOLUME_MUTE:
- str = _T("Volume Mute");
- break;
- case VK_VOLUME_DOWN:
- str = _T("Volume Down");
- break;
- case VK_VOLUME_UP:
- str = _T("Volume Up");
- break;
- case VK_MEDIA_NEXT_TRACK:
- str = _T("Media Next Track");
- break;
- case VK_MEDIA_PREV_TRACK:
- str = _T("Media Prev Track");
- break;
- case VK_MEDIA_STOP:
- str = _T("Media Stop");
- break;
- case VK_MEDIA_PLAY_PAUSE:
- str = _T("Media Play/Pause");
- break;
- case VK_LAUNCH_MAIL:
- str = _T("Launch Mail");
- break;
- case VK_LAUNCH_MEDIA_SELECT:
- str = _T("Launch Media Select");
- break;
- case VK_LAUNCH_APP1:
- str = _T("Launch App1");
- break;
- case VK_LAUNCH_APP2:
- str = _T("Launch App2");
- break;
- case VK_OEM_1:
- str = _T("OEM 1");
- break;
- case VK_OEM_PLUS:
- str = _T("Plus");
- break;
- case VK_OEM_COMMA:
- str = _T("Comma");
- break;
- case VK_OEM_MINUS:
- str = _T("Minus");
- break;
- case VK_OEM_PERIOD:
- str = _T("Period");
- break;
- case VK_OEM_2:
- str = _T("OEM 2");
- break;
- case VK_OEM_3:
- str = _T("OEM 3");
- break;
- case VK_OEM_4:
- str = _T("OEM 4");
- break;
- case VK_OEM_5:
- str = _T("OEM 5");
- break;
- case VK_OEM_6:
- str = _T("OEM 6");
- break;
- case VK_OEM_7:
- str = _T("OEM 7");
- break;
- case VK_OEM_8:
- str = _T("OEM 8");
- break;
- case VK_OEM_AX:
- str = _T("OEM AX");
- break;
- case VK_OEM_102:
- str = _T("OEM 102");
- break;
- case VK_ICO_HELP:
- str = _T("ICO Help");
- break;
- case VK_ICO_00:
- str = _T("ICO 00");
- break;
- case VK_PROCESSKEY:
- str = _T("Process Key");
- break;
- case VK_ICO_CLEAR:
- str = _T("ICO Clear");
- break;
- case VK_PACKET:
- str = _T("Packet");
- break;
- case VK_OEM_RESET:
- str = _T("OEM Reset");
- break;
- case VK_OEM_JUMP:
- str = _T("OEM Jump");
- break;
- case VK_OEM_PA1:
- str = _T("OEM PA1");
- break;
- case VK_OEM_PA2:
- str = _T("OEM PA2");
- break;
- case VK_OEM_PA3:
- str = _T("OEM PA3");
- break;
- case VK_OEM_WSCTRL:
- str = _T("OEM WSCtrl");
- break;
- case VK_OEM_CUSEL:
- str = _T("OEM CUSEL");
- break;
- case VK_OEM_ATTN:
- str = _T("OEM ATTN");
- break;
- case VK_OEM_FINISH:
- str = _T("OEM Finish");
- break;
- case VK_OEM_COPY:
- str = _T("OEM Copy");
- break;
- case VK_OEM_AUTO:
- str = _T("OEM Auto");
- break;
- case VK_OEM_ENLW:
- str = _T("OEM ENLW");
- break;
- case VK_OEM_BACKTAB:
- str = _T("OEM Backtab");
- break;
- case VK_ATTN:
- str = _T("ATTN");
- break;
- case VK_CRSEL:
- str = _T("CRSEL");
- break;
- case VK_EXSEL:
- str = _T("EXSEL");
- break;
- case VK_EREOF:
- str = _T("EREOF");
- break;
- case VK_PLAY:
- str = _T("Play");
- break;
- case VK_ZOOM:
- str = _T("Zoom");
- break;
- case VK_NONAME:
- str = _T("Noname");
- break;
- case VK_PA1:
- str = _T("PA1");
- break;
- case VK_OEM_CLEAR:
- str = _T("OEM Clear");
- break;
- case 0x07:
- case 0x0E:
- case 0x0F:
- case 0x16:
- case 0x1A:
- case 0x3A:
- case 0x3B:
- case 0x3C:
- case 0x3D:
- case 0x3E:
- case 0x3F:
- case 0x40:
- str.Format(_T("Undefined (0x%02x)"), (TCHAR)a.key);
- break;
- case 0x0A:
- case 0x0B:
- case 0x5E:
- case 0xB8:
- case 0xB9:
- case 0xC1:
- case 0xC2:
- case 0xC3:
- case 0xC4:
- case 0xC5:
- case 0xC6:
- case 0xC7:
- case 0xC8:
- case 0xC9:
- case 0xCA:
- case 0xCB:
- case 0xCC:
- case 0xCD:
- case 0xCE:
- case 0xCF:
- case 0xD0:
- case 0xD1:
- case 0xD2:
- case 0xD3:
- case 0xD4:
- case 0xD5:
- case 0xD6:
- case 0xD7:
- case 0xE0:
- str.Format(_T("Reserved (0x%02x)"), (TCHAR)a.key);
- break;
- case 0x88:
- case 0x89:
- case 0x8A:
- case 0x8B:
- case 0x8C:
- case 0x8D:
- case 0x8E:
- case 0x8F:
- case 0x97:
- case 0x98:
- case 0x99:
- case 0x9A:
- case 0x9B:
- case 0x9C:
- case 0x9D:
- case 0x9E:
- case 0x9F:
- case 0xD8:
- case 0xD9:
- case 0xDA:
- case 0xE8:
- str.Format(_T("Unassigned (0x%02x)"), (TCHAR)a.key);
- break;
- case 0xFF:
- str = _T("Multimedia keys");
- break;
- default:
- // if ('0' <= a.key && a.key <= '9' || 'A' <= a.key && a.key <= 'Z')
- str.Format(_T("%c"), (TCHAR)a.key);
- break;
- }
-
- if (a.fVirt&(FCONTROL|FALT|FSHIFT)) {
- str = MakeAccelModLabel(a.fVirt) + _T(" + ") + str;
- }
-
- str.Replace(_T(" + "), _T("+"));
-
- return str;
+ // Reference page for Virtual-Key Codes: http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.100%29.aspx
+ CString str;
+
+ switch (a.key) {
+ case VK_LBUTTON:
+ str = _T("LBtn");
+ break;
+ case VK_RBUTTON:
+ str = _T("RBtn");
+ break;
+ case VK_CANCEL:
+ str = _T("Cancel");
+ break;
+ case VK_MBUTTON:
+ str = _T("MBtn");
+ break;
+ case VK_XBUTTON1:
+ str = _T("X1Btn");
+ break;
+ case VK_XBUTTON2:
+ str = _T("X2Btn");
+ break;
+ case VK_BACK:
+ str = _T("Back");
+ break;
+ case VK_TAB:
+ str = _T("Tab");
+ break;
+ case VK_CLEAR:
+ str = _T("Clear");
+ break;
+ case VK_RETURN:
+ str = _T("Enter");
+ break;
+ case VK_SHIFT:
+ str = _T("Shift");
+ break;
+ case VK_CONTROL:
+ str = _T("Ctrl");
+ break;
+ case VK_MENU:
+ str = _T("Alt");
+ break;
+ case VK_PAUSE:
+ str = _T("Pause");
+ break;
+ case VK_CAPITAL:
+ str = _T("Capital");
+ break;
+ // case VK_KANA: str = _T("Kana"); break;
+ // case VK_HANGEUL: str = _T("Hangeul"); break;
+ case VK_HANGUL:
+ str = _T("Hangul");
+ break;
+ case VK_JUNJA:
+ str = _T("Junja");
+ break;
+ case VK_FINAL:
+ str = _T("Final");
+ break;
+ // case VK_HANJA: str = _T("Hanja"); break;
+ case VK_KANJI:
+ str = _T("Kanji");
+ break;
+ case VK_ESCAPE:
+ str = _T("Escape");
+ break;
+ case VK_CONVERT:
+ str = _T("Convert");
+ break;
+ case VK_NONCONVERT:
+ str = _T("Non Convert");
+ break;
+ case VK_ACCEPT:
+ str = _T("Accept");
+ break;
+ case VK_MODECHANGE:
+ str = _T("Mode Change");
+ break;
+ case VK_SPACE:
+ str = _T("Space");
+ break;
+ case VK_PRIOR:
+ str = _T("PgUp");
+ break;
+ case VK_NEXT:
+ str = _T("PgDn");
+ break;
+ case VK_END:
+ str = _T("End");
+ break;
+ case VK_HOME:
+ str = _T("Home");
+ break;
+ case VK_LEFT:
+ str = _T("Left");
+ break;
+ case VK_UP:
+ str = _T("Up");
+ break;
+ case VK_RIGHT:
+ str = _T("Right");
+ break;
+ case VK_DOWN:
+ str = _T("Down");
+ break;
+ case VK_SELECT:
+ str = _T("Select");
+ break;
+ case VK_PRINT:
+ str = _T("Print");
+ break;
+ case VK_EXECUTE:
+ str = _T("Execute");
+ break;
+ case VK_SNAPSHOT:
+ str = _T("Snapshot");
+ break;
+ case VK_INSERT:
+ str = _T("Insert");
+ break;
+ case VK_DELETE:
+ str = _T("Delete");
+ break;
+ case VK_HELP:
+ str = _T("Help");
+ break;
+ case VK_LWIN:
+ str = _T("LWin");
+ break;
+ case VK_RWIN:
+ str = _T("RWin");
+ break;
+ case VK_APPS:
+ str = _T("Apps");
+ break;
+ case VK_SLEEP:
+ str = _T("Sleep");
+ break;
+ case VK_NUMPAD0:
+ str = _T("Numpad 0");
+ break;
+ case VK_NUMPAD1:
+ str = _T("Numpad 1");
+ break;
+ case VK_NUMPAD2:
+ str = _T("Numpad 2");
+ break;
+ case VK_NUMPAD3:
+ str = _T("Numpad 3");
+ break;
+ case VK_NUMPAD4:
+ str = _T("Numpad 4");
+ break;
+ case VK_NUMPAD5:
+ str = _T("Numpad 5");
+ break;
+ case VK_NUMPAD6:
+ str = _T("Numpad 6");
+ break;
+ case VK_NUMPAD7:
+ str = _T("Numpad 7");
+ break;
+ case VK_NUMPAD8:
+ str = _T("Numpad 8");
+ break;
+ case VK_NUMPAD9:
+ str = _T("Numpad 9");
+ break;
+ case VK_MULTIPLY:
+ str = _T("Multiply");
+ break;
+ case VK_ADD:
+ str = _T("Add");
+ break;
+ case VK_SEPARATOR:
+ str = _T("Separator");
+ break;
+ case VK_SUBTRACT:
+ str = _T("Subtract");
+ break;
+ case VK_DECIMAL:
+ str = _T("Decimal");
+ break;
+ case VK_DIVIDE:
+ str = _T("Divide");
+ break;
+ case VK_F1:
+ str = _T("F1");
+ break;
+ case VK_F2:
+ str = _T("F2");
+ break;
+ case VK_F3:
+ str = _T("F3");
+ break;
+ case VK_F4:
+ str = _T("F4");
+ break;
+ case VK_F5:
+ str = _T("F5");
+ break;
+ case VK_F6:
+ str = _T("F6");
+ break;
+ case VK_F7:
+ str = _T("F7");
+ break;
+ case VK_F8:
+ str = _T("F8");
+ break;
+ case VK_F9:
+ str = _T("F9");
+ break;
+ case VK_F10:
+ str = _T("F10");
+ break;
+ case VK_F11:
+ str = _T("F11");
+ break;
+ case VK_F12:
+ str = _T("F12");
+ break;
+ case VK_F13:
+ str = _T("F13");
+ break;
+ case VK_F14:
+ str = _T("F14");
+ break;
+ case VK_F15:
+ str = _T("F15");
+ break;
+ case VK_F16:
+ str = _T("F16");
+ break;
+ case VK_F17:
+ str = _T("F17");
+ break;
+ case VK_F18:
+ str = _T("F18");
+ break;
+ case VK_F19:
+ str = _T("F19");
+ break;
+ case VK_F20:
+ str = _T("F20");
+ break;
+ case VK_F21:
+ str = _T("F21");
+ break;
+ case VK_F22:
+ str = _T("F22");
+ break;
+ case VK_F23:
+ str = _T("F23");
+ break;
+ case VK_F24:
+ str = _T("F24");
+ break;
+ case VK_NUMLOCK:
+ str = _T("Numlock");
+ break;
+ case VK_SCROLL:
+ str = _T("Scroll");
+ break;
+ // case VK_OEM_NEC_EQUAL: str = _T("OEM NEC Equal"); break;
+ case VK_OEM_FJ_JISHO:
+ str = _T("OEM FJ Jisho");
+ break;
+ case VK_OEM_FJ_MASSHOU:
+ str = _T("OEM FJ Msshou");
+ break;
+ case VK_OEM_FJ_TOUROKU:
+ str = _T("OEM FJ Touroku");
+ break;
+ case VK_OEM_FJ_LOYA:
+ str = _T("OEM FJ Loya");
+ break;
+ case VK_OEM_FJ_ROYA:
+ str = _T("OEM FJ Roya");
+ break;
+ case VK_LSHIFT:
+ str = _T("LShift");
+ break;
+ case VK_RSHIFT:
+ str = _T("RShift");
+ break;
+ case VK_LCONTROL:
+ str = _T("LCtrl");
+ break;
+ case VK_RCONTROL:
+ str = _T("RCtrl");
+ break;
+ case VK_LMENU:
+ str = _T("LAlt");
+ break;
+ case VK_RMENU:
+ str = _T("RAlt");
+ break;
+ case VK_BROWSER_BACK:
+ str = _T("Browser Back");
+ break;
+ case VK_BROWSER_FORWARD:
+ str = _T("Browser Forward");
+ break;
+ case VK_BROWSER_REFRESH:
+ str = _T("Browser Refresh");
+ break;
+ case VK_BROWSER_STOP:
+ str = _T("Browser Stop");
+ break;
+ case VK_BROWSER_SEARCH:
+ str = _T("Browser Search");
+ break;
+ case VK_BROWSER_FAVORITES:
+ str = _T("Browser Favorites");
+ break;
+ case VK_BROWSER_HOME:
+ str = _T("Browser Home");
+ break;
+ case VK_VOLUME_MUTE:
+ str = _T("Volume Mute");
+ break;
+ case VK_VOLUME_DOWN:
+ str = _T("Volume Down");
+ break;
+ case VK_VOLUME_UP:
+ str = _T("Volume Up");
+ break;
+ case VK_MEDIA_NEXT_TRACK:
+ str = _T("Media Next Track");
+ break;
+ case VK_MEDIA_PREV_TRACK:
+ str = _T("Media Prev Track");
+ break;
+ case VK_MEDIA_STOP:
+ str = _T("Media Stop");
+ break;
+ case VK_MEDIA_PLAY_PAUSE:
+ str = _T("Media Play/Pause");
+ break;
+ case VK_LAUNCH_MAIL:
+ str = _T("Launch Mail");
+ break;
+ case VK_LAUNCH_MEDIA_SELECT:
+ str = _T("Launch Media Select");
+ break;
+ case VK_LAUNCH_APP1:
+ str = _T("Launch App1");
+ break;
+ case VK_LAUNCH_APP2:
+ str = _T("Launch App2");
+ break;
+ case VK_OEM_1:
+ str = _T("OEM 1");
+ break;
+ case VK_OEM_PLUS:
+ str = _T("Plus");
+ break;
+ case VK_OEM_COMMA:
+ str = _T("Comma");
+ break;
+ case VK_OEM_MINUS:
+ str = _T("Minus");
+ break;
+ case VK_OEM_PERIOD:
+ str = _T("Period");
+ break;
+ case VK_OEM_2:
+ str = _T("OEM 2");
+ break;
+ case VK_OEM_3:
+ str = _T("OEM 3");
+ break;
+ case VK_OEM_4:
+ str = _T("OEM 4");
+ break;
+ case VK_OEM_5:
+ str = _T("OEM 5");
+ break;
+ case VK_OEM_6:
+ str = _T("OEM 6");
+ break;
+ case VK_OEM_7:
+ str = _T("OEM 7");
+ break;
+ case VK_OEM_8:
+ str = _T("OEM 8");
+ break;
+ case VK_OEM_AX:
+ str = _T("OEM AX");
+ break;
+ case VK_OEM_102:
+ str = _T("OEM 102");
+ break;
+ case VK_ICO_HELP:
+ str = _T("ICO Help");
+ break;
+ case VK_ICO_00:
+ str = _T("ICO 00");
+ break;
+ case VK_PROCESSKEY:
+ str = _T("Process Key");
+ break;
+ case VK_ICO_CLEAR:
+ str = _T("ICO Clear");
+ break;
+ case VK_PACKET:
+ str = _T("Packet");
+ break;
+ case VK_OEM_RESET:
+ str = _T("OEM Reset");
+ break;
+ case VK_OEM_JUMP:
+ str = _T("OEM Jump");
+ break;
+ case VK_OEM_PA1:
+ str = _T("OEM PA1");
+ break;
+ case VK_OEM_PA2:
+ str = _T("OEM PA2");
+ break;
+ case VK_OEM_PA3:
+ str = _T("OEM PA3");
+ break;
+ case VK_OEM_WSCTRL:
+ str = _T("OEM WSCtrl");
+ break;
+ case VK_OEM_CUSEL:
+ str = _T("OEM CUSEL");
+ break;
+ case VK_OEM_ATTN:
+ str = _T("OEM ATTN");
+ break;
+ case VK_OEM_FINISH:
+ str = _T("OEM Finish");
+ break;
+ case VK_OEM_COPY:
+ str = _T("OEM Copy");
+ break;
+ case VK_OEM_AUTO:
+ str = _T("OEM Auto");
+ break;
+ case VK_OEM_ENLW:
+ str = _T("OEM ENLW");
+ break;
+ case VK_OEM_BACKTAB:
+ str = _T("OEM Backtab");
+ break;
+ case VK_ATTN:
+ str = _T("ATTN");
+ break;
+ case VK_CRSEL:
+ str = _T("CRSEL");
+ break;
+ case VK_EXSEL:
+ str = _T("EXSEL");
+ break;
+ case VK_EREOF:
+ str = _T("EREOF");
+ break;
+ case VK_PLAY:
+ str = _T("Play");
+ break;
+ case VK_ZOOM:
+ str = _T("Zoom");
+ break;
+ case VK_NONAME:
+ str = _T("Noname");
+ break;
+ case VK_PA1:
+ str = _T("PA1");
+ break;
+ case VK_OEM_CLEAR:
+ str = _T("OEM Clear");
+ break;
+ case 0x07:
+ case 0x0E:
+ case 0x0F:
+ case 0x16:
+ case 0x1A:
+ case 0x3A:
+ case 0x3B:
+ case 0x3C:
+ case 0x3D:
+ case 0x3E:
+ case 0x3F:
+ case 0x40:
+ str.Format(_T("Undefined (0x%02x)"), (TCHAR)a.key);
+ break;
+ case 0x0A:
+ case 0x0B:
+ case 0x5E:
+ case 0xB8:
+ case 0xB9:
+ case 0xC1:
+ case 0xC2:
+ case 0xC3:
+ case 0xC4:
+ case 0xC5:
+ case 0xC6:
+ case 0xC7:
+ case 0xC8:
+ case 0xC9:
+ case 0xCA:
+ case 0xCB:
+ case 0xCC:
+ case 0xCD:
+ case 0xCE:
+ case 0xCF:
+ case 0xD0:
+ case 0xD1:
+ case 0xD2:
+ case 0xD3:
+ case 0xD4:
+ case 0xD5:
+ case 0xD6:
+ case 0xD7:
+ case 0xE0:
+ str.Format(_T("Reserved (0x%02x)"), (TCHAR)a.key);
+ break;
+ case 0x88:
+ case 0x89:
+ case 0x8A:
+ case 0x8B:
+ case 0x8C:
+ case 0x8D:
+ case 0x8E:
+ case 0x8F:
+ case 0x97:
+ case 0x98:
+ case 0x99:
+ case 0x9A:
+ case 0x9B:
+ case 0x9C:
+ case 0x9D:
+ case 0x9E:
+ case 0x9F:
+ case 0xD8:
+ case 0xD9:
+ case 0xDA:
+ case 0xE8:
+ str.Format(_T("Unassigned (0x%02x)"), (TCHAR)a.key);
+ break;
+ case 0xFF:
+ str = _T("Multimedia keys");
+ break;
+ default:
+ // if ('0' <= a.key && a.key <= '9' || 'A' <= a.key && a.key <= 'Z')
+ str.Format(_T("%c"), (TCHAR)a.key);
+ break;
+ }
+
+ if (a.fVirt & (FCONTROL | FALT | FSHIFT)) {
+ str = MakeAccelModLabel(a.fVirt) + _T(" + ") + str;
+ }
+
+ str.Replace(_T(" + "), _T("+"));
+
+ return str;
}
CString CPPageAccelTbl::MakeMouseButtonLabel(UINT mouse)
{
- CString ret;
- switch (mouse) {
- case wmcmd::NONE:
- default:
- ret.LoadString(IDS_AG_NONE);
- break;
- case wmcmd::LDOWN:
- ret = _T("Left Down");
- break;
- case wmcmd::LUP:
- ret = _T("Left Up");
- break;
- case wmcmd::LDBLCLK:
- ret = _T("Left DblClk");
- break;
- case wmcmd::MDOWN:
- ret = _T("Middle Down");
- break;
- case wmcmd::MUP:
- ret = _T("Middle Up");
- break;
- case wmcmd::MDBLCLK:
- ret = _T("Middle DblClk");
- break;
- case wmcmd::RDOWN:
- ret = _T("Right Down");
- break;
- case wmcmd::RUP:
- ret = _T("Right Up");
- break;
- case wmcmd::RDBLCLK:
- ret = _T("Right DblClk");
- break;
- case wmcmd::X1DOWN:
- ret = _T("X1 Down");
- break;
- case wmcmd::X1UP:
- ret = _T("X1 Up");
- break;
- case wmcmd::X1DBLCLK:
- ret = _T("X1 DblClk");
- break;
- case wmcmd::X2DOWN:
- ret = _T("X2 Down");
- break;
- case wmcmd::X2UP:
- ret = _T("X2 Up");
- break;
- case wmcmd::X2DBLCLK:
- ret = _T("X2 DblClk");
- break;
- case wmcmd::WUP:
- ret = _T("Wheel Up");
- break;
- case wmcmd::WDOWN:
- ret = _T("Wheel Down");
- break;
- }
- return ret;
+ CString ret;
+ switch (mouse) {
+ case wmcmd::NONE:
+ default:
+ ret.LoadString(IDS_AG_NONE);
+ break;
+ case wmcmd::LDOWN:
+ ret = _T("Left Down");
+ break;
+ case wmcmd::LUP:
+ ret = _T("Left Up");
+ break;
+ case wmcmd::LDBLCLK:
+ ret = _T("Left DblClk");
+ break;
+ case wmcmd::MDOWN:
+ ret = _T("Middle Down");
+ break;
+ case wmcmd::MUP:
+ ret = _T("Middle Up");
+ break;
+ case wmcmd::MDBLCLK:
+ ret = _T("Middle DblClk");
+ break;
+ case wmcmd::RDOWN:
+ ret = _T("Right Down");
+ break;
+ case wmcmd::RUP:
+ ret = _T("Right Up");
+ break;
+ case wmcmd::RDBLCLK:
+ ret = _T("Right DblClk");
+ break;
+ case wmcmd::X1DOWN:
+ ret = _T("X1 Down");
+ break;
+ case wmcmd::X1UP:
+ ret = _T("X1 Up");
+ break;
+ case wmcmd::X1DBLCLK:
+ ret = _T("X1 DblClk");
+ break;
+ case wmcmd::X2DOWN:
+ ret = _T("X2 Down");
+ break;
+ case wmcmd::X2UP:
+ ret = _T("X2 Up");
+ break;
+ case wmcmd::X2DBLCLK:
+ ret = _T("X2 DblClk");
+ break;
+ case wmcmd::WUP:
+ ret = _T("Wheel Up");
+ break;
+ case wmcmd::WDOWN:
+ ret = _T("Wheel Down");
+ break;
+ }
+ return ret;
}
CString CPPageAccelTbl::MakeAppCommandLabel(UINT id)
{
- for (int i=0; i<_countof(g_CommandList); i++) {
- if (g_CommandList[i].appcmd == id) {
- return CString(g_CommandList[i].cmdname);
- }
- }
- return CString("");
+ for (int i = 0; i < _countof(g_CommandList); i++) {
+ if (g_CommandList[i].appcmd == id) {
+ return CString(g_CommandList[i].cmdname);
+ }
+ }
+ return CString("");
}
void CPPageAccelTbl::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Text(pDX, IDC_EDIT1, m_WinLircAddr);
- DDX_Control(pDX, IDC_EDIT1, m_WinLircEdit);
- DDX_Control(pDX, IDC_STATICLINK, m_WinLircLink);
- DDX_Check(pDX, IDC_CHECK1, m_fWinLirc);
- DDX_Text(pDX, IDC_EDIT2, m_UIceAddr);
- DDX_Control(pDX, IDC_EDIT2, m_UIceEdit);
- DDX_Control(pDX, IDC_STATICLINK2, m_UIceLink);
- DDX_Check(pDX, IDC_CHECK9, m_fUIce);
- DDX_Check(pDX, IDC_CHECK2, m_fGlobalMedia);
+ __super::DoDataExchange(pDX);
+ DDX_Text(pDX, IDC_EDIT1, m_WinLircAddr);
+ DDX_Control(pDX, IDC_EDIT1, m_WinLircEdit);
+ DDX_Control(pDX, IDC_STATICLINK, m_WinLircLink);
+ DDX_Check(pDX, IDC_CHECK1, m_fWinLirc);
+ DDX_Text(pDX, IDC_EDIT2, m_UIceAddr);
+ DDX_Control(pDX, IDC_EDIT2, m_UIceEdit);
+ DDX_Control(pDX, IDC_STATICLINK2, m_UIceLink);
+ DDX_Check(pDX, IDC_CHECK9, m_fUIce);
+ DDX_Check(pDX, IDC_CHECK2, m_fGlobalMedia);
}
BEGIN_MESSAGE_MAP(CPPageAccelTbl, CPPageBase)
- ON_NOTIFY(LVN_BEGINLABELEDIT, IDC_LIST1, OnBeginlabeleditList)
- ON_NOTIFY(LVN_DOLABELEDIT, IDC_LIST1, OnDolabeleditList)
- ON_NOTIFY(LVN_ENDLABELEDIT, IDC_LIST1, OnEndlabeleditList)
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
- ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
- ON_WM_TIMER()
- ON_WM_CTLCOLOR()
+ ON_NOTIFY(LVN_BEGINLABELEDIT, IDC_LIST1, OnBeginlabeleditList)
+ ON_NOTIFY(LVN_DOLABELEDIT, IDC_LIST1, OnDolabeleditList)
+ ON_NOTIFY(LVN_ENDLABELEDIT, IDC_LIST1, OnEndlabeleditList)
+ ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
+ ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
+ ON_WM_TIMER()
+ ON_WM_CTLCOLOR()
END_MESSAGE_MAP()
// CPPageAccelTbl message handlers
@@ -1444,397 +1444,397 @@ static WNDPROC OldControlProc;
static LRESULT CALLBACK ControlProc(HWND control, UINT message, WPARAM wParam, LPARAM lParam)
{
- if (message == WM_KEYDOWN) {
- if ((LOWORD(wParam)== 'A' || LOWORD(wParam) == 'a') &&(GetKeyState(VK_CONTROL) < 0)) {
- CPlayerListCtrl *pList = (CPlayerListCtrl*)CWnd::FromHandle(control);
+ if (message == WM_KEYDOWN) {
+ if ((LOWORD(wParam) == 'A' || LOWORD(wParam) == 'a') && (GetKeyState(VK_CONTROL) < 0)) {
+ CPlayerListCtrl* pList = (CPlayerListCtrl*)CWnd::FromHandle(control);
- for (int i = 0, j = pList->GetItemCount(); i < j; i++) {
- pList->SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
- }
+ for (int i = 0, j = pList->GetItemCount(); i < j; i++) {
+ pList->SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
+ }
- return 0;
- }
- }
+ return 0;
+ }
+ }
- return CallWindowProc(OldControlProc, control, message, wParam, lParam); // call control's own windowproc
+ return CallWindowProc(OldControlProc, control, message, wParam, lParam); // call control's own windowproc
}
BOOL CPPageAccelTbl::OnInitDialog()
{
- __super::OnInitDialog();
-
- AppSettings& s = AfxGetAppSettings();
-
- m_wmcmds.RemoveAll();
- m_wmcmds.AddTail(&s.wmcmds);
- m_fWinLirc = s.fWinLirc;
- m_WinLircAddr = s.strWinLircAddr;
- m_fUIce = s.fUIce;
- m_UIceAddr = s.strUIceAddr;
- m_fGlobalMedia = s.fGlobalMedia;
-
- UpdateData(FALSE);
-
- CRect r;
- GetDlgItem(IDC_PLACEHOLDER)->GetWindowRect(r);
- ScreenToClient(r);
-
- m_list.CreateEx(
- WS_EX_CLIENTEDGE,
- WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_TABSTOP|LVS_REPORT|LVS_AUTOARRANGE|LVS_SHOWSELALWAYS,
- r, this, IDC_LIST1);
-
- m_list.SetExtendedStyle(m_list.GetExtendedStyle()|LVS_EX_FULLROWSELECT|LVS_EX_DOUBLEBUFFER|LVS_EX_GRIDLINES);
-
- for (int i = 0, j = m_list.GetHeaderCtrl()->GetItemCount(); i < j; i++) {
- m_list.DeleteColumn(0);
- }
- m_list.InsertColumn(COL_CMD, ResStr(IDS_AG_COMMAND), LVCFMT_LEFT, 80);
- m_list.InsertColumn(COL_KEY, ResStr(IDS_AG_KEY), LVCFMT_LEFT, 80);
- m_list.InsertColumn(COL_ID, _T("ID"), LVCFMT_LEFT, 40);
- m_list.InsertColumn(COL_MOUSE, ResStr(IDS_AG_MOUSE), LVCFMT_LEFT, 80);
- m_list.InsertColumn(COL_MOUSE_FS, ResStr(IDS_AG_MOUSE_FS), LVCFMT_LEFT, 80);
- m_list.InsertColumn(COL_APPCMD, ResStr(IDS_AG_APP_COMMAND), LVCFMT_LEFT, 120);
- m_list.InsertColumn(COL_RMCMD, _T("RemoteCmd"), LVCFMT_LEFT, 80);
- m_list.InsertColumn(COL_RMREPCNT, _T("RepCnt"), LVCFMT_CENTER, 60);
-
- POSITION pos = m_wmcmds.GetHeadPosition();
- for (int i = 0; pos; i++) {
- int row = m_list.InsertItem(m_list.GetItemCount(), m_wmcmds.GetAt(pos).GetName(), COL_CMD);
- m_list.SetItemData(row, (DWORD_PTR)pos);
- m_wmcmds.GetNext(pos);
- }
-
- SetupList();
-
- m_list.SetColumnWidth(COL_CMD, LVSCW_AUTOSIZE);
- m_list.SetColumnWidth(COL_KEY, LVSCW_AUTOSIZE);
- m_list.SetColumnWidth(COL_ID, LVSCW_AUTOSIZE_USEHEADER);
-
- // subclass the keylist control
- OldControlProc = (WNDPROC) SetWindowLongPtr(m_list.m_hWnd, GWLP_WNDPROC, (LONG_PTR) ControlProc);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ m_wmcmds.RemoveAll();
+ m_wmcmds.AddTail(&s.wmcmds);
+ m_fWinLirc = s.fWinLirc;
+ m_WinLircAddr = s.strWinLircAddr;
+ m_fUIce = s.fUIce;
+ m_UIceAddr = s.strUIceAddr;
+ m_fGlobalMedia = s.fGlobalMedia;
+
+ UpdateData(FALSE);
+
+ CRect r;
+ GetDlgItem(IDC_PLACEHOLDER)->GetWindowRect(r);
+ ScreenToClient(r);
+
+ m_list.CreateEx(
+ WS_EX_CLIENTEDGE,
+ WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP | LVS_REPORT | LVS_AUTOARRANGE | LVS_SHOWSELALWAYS,
+ r, this, IDC_LIST1);
+
+ m_list.SetExtendedStyle(m_list.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_GRIDLINES);
+
+ for (int i = 0, j = m_list.GetHeaderCtrl()->GetItemCount(); i < j; i++) {
+ m_list.DeleteColumn(0);
+ }
+ m_list.InsertColumn(COL_CMD, ResStr(IDS_AG_COMMAND), LVCFMT_LEFT, 80);
+ m_list.InsertColumn(COL_KEY, ResStr(IDS_AG_KEY), LVCFMT_LEFT, 80);
+ m_list.InsertColumn(COL_ID, _T("ID"), LVCFMT_LEFT, 40);
+ m_list.InsertColumn(COL_MOUSE, ResStr(IDS_AG_MOUSE), LVCFMT_LEFT, 80);
+ m_list.InsertColumn(COL_MOUSE_FS, ResStr(IDS_AG_MOUSE_FS), LVCFMT_LEFT, 80);
+ m_list.InsertColumn(COL_APPCMD, ResStr(IDS_AG_APP_COMMAND), LVCFMT_LEFT, 120);
+ m_list.InsertColumn(COL_RMCMD, _T("RemoteCmd"), LVCFMT_LEFT, 80);
+ m_list.InsertColumn(COL_RMREPCNT, _T("RepCnt"), LVCFMT_CENTER, 60);
+
+ POSITION pos = m_wmcmds.GetHeadPosition();
+ for (int i = 0; pos; i++) {
+ int row = m_list.InsertItem(m_list.GetItemCount(), m_wmcmds.GetAt(pos).GetName(), COL_CMD);
+ m_list.SetItemData(row, (DWORD_PTR)pos);
+ m_wmcmds.GetNext(pos);
+ }
+
+ SetupList();
+
+ m_list.SetColumnWidth(COL_CMD, LVSCW_AUTOSIZE);
+ m_list.SetColumnWidth(COL_KEY, LVSCW_AUTOSIZE);
+ m_list.SetColumnWidth(COL_ID, LVSCW_AUTOSIZE_USEHEADER);
+
+ // subclass the keylist control
+ OldControlProc = (WNDPROC) SetWindowLongPtr(m_list.m_hWnd, GWLP_WNDPROC, (LONG_PTR) ControlProc);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageAccelTbl::OnApply()
{
- AfxGetMyApp()->UnregisterHotkeys();
- UpdateData();
-
- AppSettings& s = AfxGetAppSettings();
-
- s.wmcmds.RemoveAll();
- s.wmcmds.AddTail(&m_wmcmds);
-
- CAtlArray<ACCEL> pAccel;
- pAccel.SetCount(m_wmcmds.GetCount());
- POSITION pos = m_wmcmds.GetHeadPosition();
- for (int i = 0; pos; i++) {
- pAccel[i] = m_wmcmds.GetNext(pos);
- }
- if (s.hAccel) {
- DestroyAcceleratorTable(s.hAccel);
- }
- s.hAccel = CreateAcceleratorTable(pAccel.GetData(), (int)pAccel.GetCount());
-
- GetParentFrame()->m_hAccelTable = s.hAccel;
-
- s.fWinLirc = !!m_fWinLirc;
- s.strWinLircAddr = m_WinLircAddr;
- if (s.fWinLirc) {
- s.WinLircClient.Connect(m_WinLircAddr);
- }
- s.fUIce = !!m_fUIce;
- s.strUIceAddr = m_UIceAddr;
- if (s.fUIce) {
- s.UIceClient.Connect(m_UIceAddr);
- }
- s.fGlobalMedia = !!m_fGlobalMedia;
-
- AfxGetMyApp()->RegisterHotkeys();
-
- return __super::OnApply();
+ AfxGetMyApp()->UnregisterHotkeys();
+ UpdateData();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ s.wmcmds.RemoveAll();
+ s.wmcmds.AddTail(&m_wmcmds);
+
+ CAtlArray<ACCEL> pAccel;
+ pAccel.SetCount(m_wmcmds.GetCount());
+ POSITION pos = m_wmcmds.GetHeadPosition();
+ for (int i = 0; pos; i++) {
+ pAccel[i] = m_wmcmds.GetNext(pos);
+ }
+ if (s.hAccel) {
+ DestroyAcceleratorTable(s.hAccel);
+ }
+ s.hAccel = CreateAcceleratorTable(pAccel.GetData(), (int)pAccel.GetCount());
+
+ GetParentFrame()->m_hAccelTable = s.hAccel;
+
+ s.fWinLirc = !!m_fWinLirc;
+ s.strWinLircAddr = m_WinLircAddr;
+ if (s.fWinLirc) {
+ s.WinLircClient.Connect(m_WinLircAddr);
+ }
+ s.fUIce = !!m_fUIce;
+ s.strUIceAddr = m_UIceAddr;
+ if (s.fUIce) {
+ s.UIceClient.Connect(m_UIceAddr);
+ }
+ s.fGlobalMedia = !!m_fGlobalMedia;
+
+ AfxGetMyApp()->RegisterHotkeys();
+
+ return __super::OnApply();
}
void CPPageAccelTbl::OnBnClickedButton1()
{
- m_list.SetFocus();
+ m_list.SetFocus();
- for (int i = 0, j = m_list.GetItemCount(); i < j; i++) {
- m_list.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
- }
+ for (int i = 0, j = m_list.GetItemCount(); i < j; i++) {
+ m_list.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
+ }
}
void CPPageAccelTbl::OnBnClickedButton2()
{
- m_list.SetFocus();
+ m_list.SetFocus();
- POSITION pos = m_list.GetFirstSelectedItemPosition();
- if (!pos) {
- return;
- }
+ POSITION pos = m_list.GetFirstSelectedItemPosition();
+ if (!pos) {
+ return;
+ }
- while (pos) {
- int ni = m_list.GetNextSelectedItem(pos);
- POSITION pi = (POSITION)m_list.GetItemData(ni);
- wmcmd& wc = m_wmcmds.GetAt(pi);
- wc.Restore();
- }
+ while (pos) {
+ int ni = m_list.GetNextSelectedItem(pos);
+ POSITION pi = (POSITION)m_list.GetItemData(ni);
+ wmcmd& wc = m_wmcmds.GetAt(pi);
+ wc.Restore();
+ }
- SetupList();
+ SetupList();
- SetModified();
+ SetModified();
}
void CPPageAccelTbl::OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- LV_ITEM* pItem = &pDispInfo->item;
+ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
+ LV_ITEM* pItem = &pDispInfo->item;
- *pResult = FALSE;
+ *pResult = FALSE;
- if (pItem->iItem < 0) {
- return;
- }
+ if (pItem->iItem < 0) {
+ return;
+ }
- if (pItem->iSubItem == COL_KEY || pItem->iSubItem == COL_APPCMD
- || pItem->iSubItem == COL_MOUSE || pItem->iSubItem == COL_MOUSE_FS
- || pItem->iSubItem == COL_RMCMD || pItem->iSubItem == COL_RMREPCNT) {
- *pResult = TRUE;
- }
+ if (pItem->iSubItem == COL_KEY || pItem->iSubItem == COL_APPCMD
+ || pItem->iSubItem == COL_MOUSE || pItem->iSubItem == COL_MOUSE_FS
+ || pItem->iSubItem == COL_RMCMD || pItem->iSubItem == COL_RMREPCNT) {
+ *pResult = TRUE;
+ }
}
-static BYTE s_mods[] = {0,FALT,FCONTROL,FSHIFT,FCONTROL|FALT,FCONTROL|FSHIFT,FALT|FSHIFT,FCONTROL|FALT|FSHIFT};
+static BYTE s_mods[] = {0, FALT, FCONTROL, FSHIFT, FCONTROL | FALT, FCONTROL | FSHIFT, FALT | FSHIFT, FCONTROL | FALT | FSHIFT};
void CPPageAccelTbl::OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- LV_ITEM* pItem = &pDispInfo->item;
-
- if (pItem->iItem < 0) {
- *pResult = FALSE;
- return;
- }
-
- *pResult = TRUE;
-
- wmcmd& wc = m_wmcmds.GetAt((POSITION)m_list.GetItemData(pItem->iItem));
-
- CAtlList<CString> sl;
- int nSel = -1;
-
- switch (pItem->iSubItem) {
- case COL_KEY: {
- m_list.ShowInPlaceWinHotkey(pItem->iItem, pItem->iSubItem);
- CWinHotkeyCtrl* pWinHotkey = (CWinHotkeyCtrl*)m_list.GetDlgItem(IDC_WINHOTKEY1);
- UINT cod = 0, mod = 0;
-
- if (wc.fVirt & FALT) {
- mod |= MOD_ALT;
- }
- if (wc.fVirt & FCONTROL) {
- mod |= MOD_CONTROL;
- }
- if (wc.fVirt & FSHIFT) {
- mod |= MOD_SHIFT;
- }
- cod = wc.key;
- pWinHotkey->SetWinHotkey(cod, mod);
- break;
- }
- case COL_MOUSE:
- for (UINT i = 0; i < wmcmd::LAST; i++) {
- sl.AddTail(MakeMouseButtonLabel(i));
- if (wc.mouse == i) {
- nSel = i;
- }
- }
-
- m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
- break;
- case COL_MOUSE_FS:
- for (UINT i = 0; i < wmcmd::LAST; i++) {
- sl.AddTail(MakeMouseButtonLabel(i));
- if (wc.mouseFS == i) {
- nSel = i;
- }
- }
-
- m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
- break;
- case COL_APPCMD:
- for (int i = 0; i < _countof(g_CommandList); i++) {
- sl.AddTail(g_CommandList[i].cmdname);
- if (wc.appcmd == g_CommandList[i].appcmd) {
- nSel = i;
- }
- }
-
- m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
- break;
- case COL_RMCMD:
- m_list.ShowInPlaceEdit(pItem->iItem, pItem->iSubItem);
- break;
- case COL_RMREPCNT:
- m_list.ShowInPlaceEdit(pItem->iItem, pItem->iSubItem);
- break;
- default:
- *pResult = FALSE;
- break;
- }
+ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
+ LV_ITEM* pItem = &pDispInfo->item;
+
+ if (pItem->iItem < 0) {
+ *pResult = FALSE;
+ return;
+ }
+
+ *pResult = TRUE;
+
+ wmcmd& wc = m_wmcmds.GetAt((POSITION)m_list.GetItemData(pItem->iItem));
+
+ CAtlList<CString> sl;
+ int nSel = -1;
+
+ switch (pItem->iSubItem) {
+ case COL_KEY: {
+ m_list.ShowInPlaceWinHotkey(pItem->iItem, pItem->iSubItem);
+ CWinHotkeyCtrl* pWinHotkey = (CWinHotkeyCtrl*)m_list.GetDlgItem(IDC_WINHOTKEY1);
+ UINT cod = 0, mod = 0;
+
+ if (wc.fVirt & FALT) {
+ mod |= MOD_ALT;
+ }
+ if (wc.fVirt & FCONTROL) {
+ mod |= MOD_CONTROL;
+ }
+ if (wc.fVirt & FSHIFT) {
+ mod |= MOD_SHIFT;
+ }
+ cod = wc.key;
+ pWinHotkey->SetWinHotkey(cod, mod);
+ break;
+ }
+ case COL_MOUSE:
+ for (UINT i = 0; i < wmcmd::LAST; i++) {
+ sl.AddTail(MakeMouseButtonLabel(i));
+ if (wc.mouse == i) {
+ nSel = i;
+ }
+ }
+
+ m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
+ break;
+ case COL_MOUSE_FS:
+ for (UINT i = 0; i < wmcmd::LAST; i++) {
+ sl.AddTail(MakeMouseButtonLabel(i));
+ if (wc.mouseFS == i) {
+ nSel = i;
+ }
+ }
+
+ m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
+ break;
+ case COL_APPCMD:
+ for (int i = 0; i < _countof(g_CommandList); i++) {
+ sl.AddTail(g_CommandList[i].cmdname);
+ if (wc.appcmd == g_CommandList[i].appcmd) {
+ nSel = i;
+ }
+ }
+
+ m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
+ break;
+ case COL_RMCMD:
+ m_list.ShowInPlaceEdit(pItem->iItem, pItem->iSubItem);
+ break;
+ case COL_RMREPCNT:
+ m_list.ShowInPlaceEdit(pItem->iItem, pItem->iSubItem);
+ break;
+ default:
+ *pResult = FALSE;
+ break;
+ }
}
void CPPageAccelTbl::OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- LV_ITEM* pItem = &pDispInfo->item;
-
- *pResult = FALSE;
-
- if (!m_list.m_fInPlaceDirty) {
- return;
- }
-
- if (pItem->iItem < 0) {
- return;
- }
-
- wmcmd& wc = m_wmcmds.GetAt((POSITION)m_list.GetItemData(pItem->iItem));
-
- switch (pItem->iSubItem) {
- case COL_KEY: {
- UINT cod, mod;
- CWinHotkeyCtrl* pWinHotkey = (CWinHotkeyCtrl*)m_list.GetDlgItem(IDC_WINHOTKEY1);
- pWinHotkey->GetWinHotkey(&cod, &mod);
- wc.fVirt = 0;
- if (mod & MOD_ALT) {
- wc.fVirt |= FALT;
- }
- if (mod & MOD_CONTROL) {
- wc.fVirt |= FCONTROL;
- }
- if (mod & MOD_SHIFT) {
- wc.fVirt |= FSHIFT;
- }
- wc.fVirt |= FVIRTKEY;
- wc.key = cod;
-
- CString str;
- HotkeyToString(cod, mod, str);
- m_list.SetItemText(pItem->iItem, pItem->iSubItem, str);
-
- *pResult = TRUE;
- }
- break;
- case COL_APPCMD: {
- ptrdiff_t i = pItem->lParam;
- if (i >= 0 && i < _countof(g_CommandList)) {
- wc.appcmd = g_CommandList[i].appcmd;
- m_list.SetItemText(pItem->iItem, COL_APPCMD, pItem->pszText);
- *pResult = TRUE;
- }
- }
- break;
- case COL_MOUSE:
- wc.mouse = (UINT)pItem->lParam;
- m_list.SetItemText(pItem->iItem, COL_MOUSE, pItem->pszText);
- break;
- case COL_MOUSE_FS:
- wc.mouseFS = (UINT)pItem->lParam;
- m_list.SetItemText(pItem->iItem, COL_MOUSE_FS, pItem->pszText);
- break;
- case COL_RMCMD:
- wc.rmcmd = CStringA(CString(pItem->pszText)).Trim();
- wc.rmcmd.Replace(' ', '_');
- m_list.SetItemText(pItem->iItem, pItem->iSubItem, CString(wc.rmcmd));
- *pResult = TRUE;
- break;
- case COL_RMREPCNT:
- CString str = CString(pItem->pszText).Trim();
- wc.rmrepcnt = _tcstol(str, NULL, 10);
- str.Format(_T("%d"), wc.rmrepcnt);
- m_list.SetItemText(pItem->iItem, pItem->iSubItem, str);
- *pResult = TRUE;
- break;
- }
-
- if (*pResult) {
- SetModified();
- }
+ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
+ LV_ITEM* pItem = &pDispInfo->item;
+
+ *pResult = FALSE;
+
+ if (!m_list.m_fInPlaceDirty) {
+ return;
+ }
+
+ if (pItem->iItem < 0) {
+ return;
+ }
+
+ wmcmd& wc = m_wmcmds.GetAt((POSITION)m_list.GetItemData(pItem->iItem));
+
+ switch (pItem->iSubItem) {
+ case COL_KEY: {
+ UINT cod, mod;
+ CWinHotkeyCtrl* pWinHotkey = (CWinHotkeyCtrl*)m_list.GetDlgItem(IDC_WINHOTKEY1);
+ pWinHotkey->GetWinHotkey(&cod, &mod);
+ wc.fVirt = 0;
+ if (mod & MOD_ALT) {
+ wc.fVirt |= FALT;
+ }
+ if (mod & MOD_CONTROL) {
+ wc.fVirt |= FCONTROL;
+ }
+ if (mod & MOD_SHIFT) {
+ wc.fVirt |= FSHIFT;
+ }
+ wc.fVirt |= FVIRTKEY;
+ wc.key = cod;
+
+ CString str;
+ HotkeyToString(cod, mod, str);
+ m_list.SetItemText(pItem->iItem, pItem->iSubItem, str);
+
+ *pResult = TRUE;
+ }
+ break;
+ case COL_APPCMD: {
+ ptrdiff_t i = pItem->lParam;
+ if (i >= 0 && i < _countof(g_CommandList)) {
+ wc.appcmd = g_CommandList[i].appcmd;
+ m_list.SetItemText(pItem->iItem, COL_APPCMD, pItem->pszText);
+ *pResult = TRUE;
+ }
+ }
+ break;
+ case COL_MOUSE:
+ wc.mouse = (UINT)pItem->lParam;
+ m_list.SetItemText(pItem->iItem, COL_MOUSE, pItem->pszText);
+ break;
+ case COL_MOUSE_FS:
+ wc.mouseFS = (UINT)pItem->lParam;
+ m_list.SetItemText(pItem->iItem, COL_MOUSE_FS, pItem->pszText);
+ break;
+ case COL_RMCMD:
+ wc.rmcmd = CStringA(CString(pItem->pszText)).Trim();
+ wc.rmcmd.Replace(' ', '_');
+ m_list.SetItemText(pItem->iItem, pItem->iSubItem, CString(wc.rmcmd));
+ *pResult = TRUE;
+ break;
+ case COL_RMREPCNT:
+ CString str = CString(pItem->pszText).Trim();
+ wc.rmrepcnt = _tcstol(str, NULL, 10);
+ str.Format(_T("%d"), wc.rmrepcnt);
+ m_list.SetItemText(pItem->iItem, pItem->iSubItem, str);
+ *pResult = TRUE;
+ break;
+ }
+
+ if (*pResult) {
+ SetModified();
+ }
}
void CPPageAccelTbl::OnTimer(UINT_PTR nIDEvent)
{
- UpdateData();
+ UpdateData();
- if (m_fWinLirc) {
- CString addr;
- m_WinLircEdit.GetWindowText(addr);
- AfxGetAppSettings().WinLircClient.Connect(addr);
- }
+ if (m_fWinLirc) {
+ CString addr;
+ m_WinLircEdit.GetWindowText(addr);
+ AfxGetAppSettings().WinLircClient.Connect(addr);
+ }
- m_WinLircEdit.Invalidate();
+ m_WinLircEdit.Invalidate();
- if (m_fUIce) {
- CString addr;
- m_UIceEdit.GetWindowText(addr);
- AfxGetAppSettings().UIceClient.Connect(addr);
- }
+ if (m_fUIce) {
+ CString addr;
+ m_UIceEdit.GetWindowText(addr);
+ AfxGetAppSettings().UIceClient.Connect(addr);
+ }
- m_UIceEdit.Invalidate();
+ m_UIceEdit.Invalidate();
- m_counter++;
+ m_counter++;
- __super::OnTimer(nIDEvent);
+ __super::OnTimer(nIDEvent);
}
HBRUSH CPPageAccelTbl::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
- HBRUSH hbr = __super::OnCtlColor(pDC, pWnd, nCtlColor);
+ HBRUSH hbr = __super::OnCtlColor(pDC, pWnd, nCtlColor);
- int status = -1;
+ int status = -1;
- if (*pWnd == m_WinLircEdit) {
- status = AfxGetAppSettings().WinLircClient.GetStatus();
- } else if (*pWnd == m_UIceEdit) {
- status = AfxGetAppSettings().UIceClient.GetStatus();
- }
+ if (*pWnd == m_WinLircEdit) {
+ status = AfxGetAppSettings().WinLircClient.GetStatus();
+ } else if (*pWnd == m_UIceEdit) {
+ status = AfxGetAppSettings().UIceClient.GetStatus();
+ }
- if (status == 0 || status == 2 && (m_counter&1)) {
- pDC->SetTextColor(0x0000ff);
- } else if (status == 1) {
- pDC->SetTextColor(0x008000);
- }
+ if (status == 0 || status == 2 && (m_counter & 1)) {
+ pDC->SetTextColor(0x0000ff);
+ } else if (status == 1) {
+ pDC->SetTextColor(0x008000);
+ }
- return hbr;
+ return hbr;
}
BOOL CPPageAccelTbl::OnSetActive()
{
- SetTimer(1, 1000, NULL);
+ SetTimer(1, 1000, NULL);
- return CPPageBase::OnSetActive();
+ return CPPageBase::OnSetActive();
}
BOOL CPPageAccelTbl::OnKillActive()
{
- KillTimer(1);
+ KillTimer(1);
- return CPPageBase::OnKillActive();
+ return CPPageBase::OnKillActive();
}
void CPPageAccelTbl::OnCancel()
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- if (!s.fWinLirc) {
- s.WinLircClient.DisConnect();
- }
- if (!s.fUIce) {
- s.UIceClient.DisConnect();
- }
+ if (!s.fWinLirc) {
+ s.WinLircClient.DisConnect();
+ }
+ if (!s.fUIce) {
+ s.UIceClient.DisConnect();
+ }
- __super::OnCancel();
+ __super::OnCancel();
}
diff --git a/src/mpc-hc/PPageAccelTbl.h b/src/mpc-hc/PPageAccelTbl.h
index 0dca2f4fc..b4df6638c 100644
--- a/src/mpc-hc/PPageAccelTbl.h
+++ b/src/mpc-hc/PPageAccelTbl.h
@@ -33,61 +33,61 @@
class CPPageAccelTbl : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageAccelTbl)
+ DECLARE_DYNAMIC(CPPageAccelTbl)
private:
- enum {COL_CMD, COL_KEY, COL_ID, COL_MOUSE, COL_MOUSE_FS, COL_APPCMD, COL_RMCMD, COL_RMREPCNT};
+ enum {COL_CMD, COL_KEY, COL_ID, COL_MOUSE, COL_MOUSE_FS, COL_APPCMD, COL_RMCMD, COL_RMREPCNT};
- CList<wmcmd> m_wmcmds;
+ CList<wmcmd> m_wmcmds;
- void SetupList();
+ void SetupList();
- int m_counter;
+ int m_counter;
public:
- CPPageAccelTbl();
- virtual ~CPPageAccelTbl();
-
- static CString MakeAccelModLabel(BYTE fVirt);
- static CString MakeAccelVkeyLabel(WORD key, bool fVirtKey);
- static CString MakeAccelShortcutLabel(UINT id);
- static CString MakeAccelShortcutLabel(ACCEL& a);
- static CString MakeMouseButtonLabel(UINT mouse);
- static CString MakeAppCommandLabel(UINT id);
-
- enum {APPCOMMAND_LAST=APPCOMMAND_DWM_FLIP3D};
-
- // Dialog Data
- enum { IDD = IDD_PPAGEACCELTBL };
- CPlayerListCtrl m_list;
- BOOL m_fWinLirc;
- CString m_WinLircAddr;
- CEdit m_WinLircEdit;
- CStaticLink m_WinLircLink;
- BOOL m_fUIce;
- CString m_UIceAddr;
- CEdit m_UIceEdit;
- CStaticLink m_UIceLink;
- BOOL m_fGlobalMedia;
+ CPPageAccelTbl();
+ virtual ~CPPageAccelTbl();
+
+ static CString MakeAccelModLabel(BYTE fVirt);
+ static CString MakeAccelVkeyLabel(WORD key, bool fVirtKey);
+ static CString MakeAccelShortcutLabel(UINT id);
+ static CString MakeAccelShortcutLabel(ACCEL& a);
+ static CString MakeMouseButtonLabel(UINT mouse);
+ static CString MakeAppCommandLabel(UINT id);
+
+ enum {APPCOMMAND_LAST = APPCOMMAND_DWM_FLIP3D};
+
+ // Dialog Data
+ enum { IDD = IDD_PPAGEACCELTBL };
+ CPlayerListCtrl m_list;
+ BOOL m_fWinLirc;
+ CString m_WinLircAddr;
+ CEdit m_WinLircEdit;
+ CStaticLink m_WinLircLink;
+ BOOL m_fUIce;
+ CString m_UIceAddr;
+ CEdit m_UIceEdit;
+ CStaticLink m_UIceLink;
+ BOOL m_fGlobalMedia;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- virtual BOOL OnSetActive();
- virtual BOOL OnKillActive();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL OnSetActive();
+ virtual BOOL OnKillActive();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnBnClickedButton1();
- afx_msg void OnBnClickedButton2();
- afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
- afx_msg void OnTimer(UINT_PTR nIDEvent);
-
- virtual void OnCancel();
+ afx_msg void OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnBnClickedButton1();
+ afx_msg void OnBnClickedButton2();
+ afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
+ afx_msg void OnTimer(UINT_PTR nIDEvent);
+
+ virtual void OnCancel();
};
diff --git a/src/mpc-hc/PPageAudioSwitcher.cpp b/src/mpc-hc/PPageAudioSwitcher.cpp
index b2f478032..a56013606 100644
--- a/src/mpc-hc/PPageAudioSwitcher.cpp
+++ b/src/mpc-hc/PPageAudioSwitcher.cpp
@@ -32,19 +32,19 @@
IMPLEMENT_DYNAMIC(CPPageAudioSwitcher, CPPageBase)
CPPageAudioSwitcher::CPPageAudioSwitcher(IFilterGraph* pFG)
- : CPPageBase(CPPageAudioSwitcher::IDD, CPPageAudioSwitcher::IDD)
- , m_fAudioNormalize(FALSE)
- , m_fAudioNormalizeRecover(FALSE)
- , m_fDownSampleTo441(FALSE)
- , m_fCustomChannelMapping(FALSE)
- , m_nChannels(0)
- , m_fEnableAudioSwitcher(FALSE)
- , m_dwChannelMask(0)
- , m_tAudioTimeShift(0)
- , m_fAudioTimeShift(FALSE)
- , m_AudioBoostPos(0)
+ : CPPageBase(CPPageAudioSwitcher::IDD, CPPageAudioSwitcher::IDD)
+ , m_fAudioNormalize(FALSE)
+ , m_fAudioNormalizeRecover(FALSE)
+ , m_fDownSampleTo441(FALSE)
+ , m_fCustomChannelMapping(FALSE)
+ , m_nChannels(0)
+ , m_fEnableAudioSwitcher(FALSE)
+ , m_dwChannelMask(0)
+ , m_tAudioTimeShift(0)
+ , m_fAudioTimeShift(FALSE)
+ , m_AudioBoostPos(0)
{
- m_pASF = FindFilter(__uuidof(CAudioSwitcherFilter), pFG);
+ m_pASF = FindFilter(__uuidof(CAudioSwitcherFilter), pFG);
}
CPPageAudioSwitcher::~CPPageAudioSwitcher()
@@ -53,47 +53,47 @@ CPPageAudioSwitcher::~CPPageAudioSwitcher()
void CPPageAudioSwitcher::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Check(pDX, IDC_CHECK5, m_fAudioNormalize);
- DDX_Check(pDX, IDC_CHECK6, m_fAudioNormalizeRecover);
- DDX_Slider(pDX, IDC_SLIDER1, m_AudioBoostPos);
- DDX_Control(pDX, IDC_SLIDER1, m_AudioBoostCtrl);
- DDX_Check(pDX, IDC_CHECK3, m_fDownSampleTo441);
- DDX_Check(pDX, IDC_CHECK1, m_fCustomChannelMapping);
- DDX_Control(pDX, IDC_EDIT1, m_nChannelsCtrl);
- DDX_Text(pDX, IDC_EDIT1, m_nChannels);
- DDX_Control(pDX, IDC_SPIN1, m_nChannelsSpinCtrl);
- DDX_Control(pDX, IDC_LIST1, m_list);
- DDX_Check(pDX, IDC_CHECK2, m_fEnableAudioSwitcher);
- DDX_Control(pDX, IDC_CHECK3, m_fDownSampleTo441Ctrl);
- DDX_Control(pDX, IDC_CHECK1, m_fCustomChannelMappingCtrl);
- DDX_Control(pDX, IDC_EDIT2, m_tAudioTimeShiftCtrl);
- DDX_Control(pDX, IDC_SPIN2, m_tAudioTimeShiftSpin);
- DDX_Text(pDX, IDC_EDIT2, m_tAudioTimeShift);
- DDX_Check(pDX, IDC_CHECK4, m_fAudioTimeShift);
- DDX_Control(pDX, IDC_CHECK4, m_fAudioTimeShiftCtrl);
+ __super::DoDataExchange(pDX);
+ DDX_Check(pDX, IDC_CHECK5, m_fAudioNormalize);
+ DDX_Check(pDX, IDC_CHECK6, m_fAudioNormalizeRecover);
+ DDX_Slider(pDX, IDC_SLIDER1, m_AudioBoostPos);
+ DDX_Control(pDX, IDC_SLIDER1, m_AudioBoostCtrl);
+ DDX_Check(pDX, IDC_CHECK3, m_fDownSampleTo441);
+ DDX_Check(pDX, IDC_CHECK1, m_fCustomChannelMapping);
+ DDX_Control(pDX, IDC_EDIT1, m_nChannelsCtrl);
+ DDX_Text(pDX, IDC_EDIT1, m_nChannels);
+ DDX_Control(pDX, IDC_SPIN1, m_nChannelsSpinCtrl);
+ DDX_Control(pDX, IDC_LIST1, m_list);
+ DDX_Check(pDX, IDC_CHECK2, m_fEnableAudioSwitcher);
+ DDX_Control(pDX, IDC_CHECK3, m_fDownSampleTo441Ctrl);
+ DDX_Control(pDX, IDC_CHECK1, m_fCustomChannelMappingCtrl);
+ DDX_Control(pDX, IDC_EDIT2, m_tAudioTimeShiftCtrl);
+ DDX_Control(pDX, IDC_SPIN2, m_tAudioTimeShiftSpin);
+ DDX_Text(pDX, IDC_EDIT2, m_tAudioTimeShift);
+ DDX_Check(pDX, IDC_CHECK4, m_fAudioTimeShift);
+ DDX_Control(pDX, IDC_CHECK4, m_fAudioTimeShiftCtrl);
}
BEGIN_MESSAGE_MAP(CPPageAudioSwitcher, CPPageBase)
- ON_NOTIFY(NM_CLICK, IDC_LIST1, OnNMClickList1)
- ON_WM_DRAWITEM()
- ON_EN_CHANGE(IDC_EDIT1, OnEnChangeEdit1)
- ON_UPDATE_COMMAND_UI(IDC_SLIDER1, OnUpdateAudioSwitcher)
- ON_UPDATE_COMMAND_UI(IDC_CHECK5, OnUpdateAudioSwitcher)
- ON_UPDATE_COMMAND_UI(IDC_CHECK6, OnUpdateAudioSwitcher)
- ON_UPDATE_COMMAND_UI(IDC_CHECK3, OnUpdateAudioSwitcher)
- ON_UPDATE_COMMAND_UI(IDC_CHECK4, OnUpdateAudioSwitcher)
- ON_UPDATE_COMMAND_UI(IDC_EDIT2, OnUpdateAudioSwitcher)
- ON_UPDATE_COMMAND_UI(IDC_SPIN2, OnUpdateAudioSwitcher)
- ON_UPDATE_COMMAND_UI(IDC_CHECK1, OnUpdateAudioSwitcher)
- ON_UPDATE_COMMAND_UI(IDC_EDIT1, OnUpdateChannelMapping)
- ON_UPDATE_COMMAND_UI(IDC_SPIN1, OnUpdateChannelMapping)
- ON_UPDATE_COMMAND_UI(IDC_LIST1, OnUpdateChannelMapping)
- ON_UPDATE_COMMAND_UI(IDC_STATIC1, OnUpdateChannelMapping)
- ON_UPDATE_COMMAND_UI(IDC_STATIC2, OnUpdateChannelMapping)
- ON_UPDATE_COMMAND_UI(IDC_STATIC3, OnUpdateChannelMapping)
- ON_WM_HSCROLL()
- ON_NOTIFY_EX(TTN_NEEDTEXT, 0, OnToolTipNotify)
+ ON_NOTIFY(NM_CLICK, IDC_LIST1, OnNMClickList1)
+ ON_WM_DRAWITEM()
+ ON_EN_CHANGE(IDC_EDIT1, OnEnChangeEdit1)
+ ON_UPDATE_COMMAND_UI(IDC_SLIDER1, OnUpdateAudioSwitcher)
+ ON_UPDATE_COMMAND_UI(IDC_CHECK5, OnUpdateAudioSwitcher)
+ ON_UPDATE_COMMAND_UI(IDC_CHECK6, OnUpdateAudioSwitcher)
+ ON_UPDATE_COMMAND_UI(IDC_CHECK3, OnUpdateAudioSwitcher)
+ ON_UPDATE_COMMAND_UI(IDC_CHECK4, OnUpdateAudioSwitcher)
+ ON_UPDATE_COMMAND_UI(IDC_EDIT2, OnUpdateAudioSwitcher)
+ ON_UPDATE_COMMAND_UI(IDC_SPIN2, OnUpdateAudioSwitcher)
+ ON_UPDATE_COMMAND_UI(IDC_CHECK1, OnUpdateAudioSwitcher)
+ ON_UPDATE_COMMAND_UI(IDC_EDIT1, OnUpdateChannelMapping)
+ ON_UPDATE_COMMAND_UI(IDC_SPIN1, OnUpdateChannelMapping)
+ ON_UPDATE_COMMAND_UI(IDC_LIST1, OnUpdateChannelMapping)
+ ON_UPDATE_COMMAND_UI(IDC_STATIC1, OnUpdateChannelMapping)
+ ON_UPDATE_COMMAND_UI(IDC_STATIC2, OnUpdateChannelMapping)
+ ON_UPDATE_COMMAND_UI(IDC_STATIC3, OnUpdateChannelMapping)
+ ON_WM_HSCROLL()
+ ON_NOTIFY_EX(TTN_NEEDTEXT, 0, OnToolTipNotify)
END_MESSAGE_MAP()
@@ -101,271 +101,271 @@ END_MESSAGE_MAP()
BOOL CPPageAudioSwitcher::OnInitDialog()
{
- __super::OnInitDialog();
-
- AppSettings& s = AfxGetAppSettings();
-
- m_fEnableAudioSwitcher = s.fEnableAudioSwitcher;
- m_fAudioNormalize = s.fAudioNormalize;
- m_fAudioNormalizeRecover = s.fAudioNormalizeRecover;
- m_AudioBoostPos = (int)(s.dAudioBoost_dB*10+0.1);
- m_AudioBoostCtrl.SetRange(0, 100);
- m_fDownSampleTo441 = s.fDownSampleTo441;
- m_fAudioTimeShift = s.fAudioTimeShift;
- m_tAudioTimeShift = s.iAudioTimeShift;
- m_tAudioTimeShiftSpin.SetRange32(-1000*60*60*24, 1000*60*60*24);
- m_fCustomChannelMapping = s.fCustomChannelMapping;
- memcpy(m_pSpeakerToChannelMap, s.pSpeakerToChannelMap, sizeof(s.pSpeakerToChannelMap));
-
- if (m_pASF) {
- m_pASF->GetInputSpeakerConfig(&m_dwChannelMask);
- }
-
- m_nChannels = s.nSpeakerChannels;
- m_nChannelsSpinCtrl.SetRange(1, 18);
-
- if (m_pASF) {
- m_nChannels = m_pASF->GetNumberOfInputChannels();
- }
-
- m_list.InsertColumn(0, _T(""), LVCFMT_LEFT, 100);
- m_list.InsertItem(0, _T(""));
- m_list.InsertItem(1, ResStr(IDS_FRONT_LEFT));
- m_list.InsertItem(2, ResStr(IDS_FRONT_RIGHT));
- m_list.InsertItem(3, ResStr(IDS_FRONT_CENTER));
- m_list.InsertItem(4, ResStr(IDS_LOW_FREQUENCY));
- m_list.InsertItem(5, ResStr(IDS_BACK_LEFT));
- m_list.InsertItem(6, ResStr(IDS_BACK_RIGHT));
- m_list.InsertItem(7, ResStr(IDS_FRONT_LEFT_OF_CENTER));
- m_list.InsertItem(8, ResStr(IDS_FRONT_RIGHT_OF_CENTER));
- m_list.InsertItem(9, ResStr(IDS_BACK_CENTER));
- m_list.InsertItem(10, ResStr(IDS_SIDE_LEFT));
- m_list.InsertItem(11, ResStr(IDS_SIDE_RIGHT));
- m_list.InsertItem(12, ResStr(IDS_TOP_CENTER));
- m_list.InsertItem(13, ResStr(IDS_TOP_FRONT_LEFT));
- m_list.InsertItem(14, ResStr(IDS_TOP_FRONT_CENTER));
- m_list.InsertItem(15, ResStr(IDS_TOP_FRONT_RIGHT));
- m_list.InsertItem(16, ResStr(IDS_TOP_BACK_LEFT));
- m_list.InsertItem(17, ResStr(IDS_TOP_BACK_CENTER));
- m_list.InsertItem(18, ResStr(IDS_TOP_BACK_RIGHT));
- m_list.SetColumnWidth(0, LVSCW_AUTOSIZE);
-
- for (int i = 1; i <= 18; i++) {
- m_list.InsertColumn(i, _T(""), LVCFMT_CENTER, 16);
- CString n;
- n.Format(_T("%d"), i);
- m_list.SetItemText(0, i, n);
- // m_list.SetColumnWidth(i, LVSCW_AUTOSIZE);
- // m_list.SetColumnWidth(i, m_list.GetColumnWidth(i)*8/10);
- }
-
- m_tooltip.Create(GetDlgItem(IDC_SLIDER1));
- m_tooltip.Activate(TRUE);
-
- UpdateData(FALSE);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ m_fEnableAudioSwitcher = s.fEnableAudioSwitcher;
+ m_fAudioNormalize = s.fAudioNormalize;
+ m_fAudioNormalizeRecover = s.fAudioNormalizeRecover;
+ m_AudioBoostPos = (int)(s.dAudioBoost_dB * 10 + 0.1);
+ m_AudioBoostCtrl.SetRange(0, 100);
+ m_fDownSampleTo441 = s.fDownSampleTo441;
+ m_fAudioTimeShift = s.fAudioTimeShift;
+ m_tAudioTimeShift = s.iAudioTimeShift;
+ m_tAudioTimeShiftSpin.SetRange32(-1000 * 60 * 60 * 24, 1000 * 60 * 60 * 24);
+ m_fCustomChannelMapping = s.fCustomChannelMapping;
+ memcpy(m_pSpeakerToChannelMap, s.pSpeakerToChannelMap, sizeof(s.pSpeakerToChannelMap));
+
+ if (m_pASF) {
+ m_pASF->GetInputSpeakerConfig(&m_dwChannelMask);
+ }
+
+ m_nChannels = s.nSpeakerChannels;
+ m_nChannelsSpinCtrl.SetRange(1, 18);
+
+ if (m_pASF) {
+ m_nChannels = m_pASF->GetNumberOfInputChannels();
+ }
+
+ m_list.InsertColumn(0, _T(""), LVCFMT_LEFT, 100);
+ m_list.InsertItem(0, _T(""));
+ m_list.InsertItem(1, ResStr(IDS_FRONT_LEFT));
+ m_list.InsertItem(2, ResStr(IDS_FRONT_RIGHT));
+ m_list.InsertItem(3, ResStr(IDS_FRONT_CENTER));
+ m_list.InsertItem(4, ResStr(IDS_LOW_FREQUENCY));
+ m_list.InsertItem(5, ResStr(IDS_BACK_LEFT));
+ m_list.InsertItem(6, ResStr(IDS_BACK_RIGHT));
+ m_list.InsertItem(7, ResStr(IDS_FRONT_LEFT_OF_CENTER));
+ m_list.InsertItem(8, ResStr(IDS_FRONT_RIGHT_OF_CENTER));
+ m_list.InsertItem(9, ResStr(IDS_BACK_CENTER));
+ m_list.InsertItem(10, ResStr(IDS_SIDE_LEFT));
+ m_list.InsertItem(11, ResStr(IDS_SIDE_RIGHT));
+ m_list.InsertItem(12, ResStr(IDS_TOP_CENTER));
+ m_list.InsertItem(13, ResStr(IDS_TOP_FRONT_LEFT));
+ m_list.InsertItem(14, ResStr(IDS_TOP_FRONT_CENTER));
+ m_list.InsertItem(15, ResStr(IDS_TOP_FRONT_RIGHT));
+ m_list.InsertItem(16, ResStr(IDS_TOP_BACK_LEFT));
+ m_list.InsertItem(17, ResStr(IDS_TOP_BACK_CENTER));
+ m_list.InsertItem(18, ResStr(IDS_TOP_BACK_RIGHT));
+ m_list.SetColumnWidth(0, LVSCW_AUTOSIZE);
+
+ for (int i = 1; i <= 18; i++) {
+ m_list.InsertColumn(i, _T(""), LVCFMT_CENTER, 16);
+ CString n;
+ n.Format(_T("%d"), i);
+ m_list.SetItemText(0, i, n);
+ // m_list.SetColumnWidth(i, LVSCW_AUTOSIZE);
+ // m_list.SetColumnWidth(i, m_list.GetColumnWidth(i)*8/10);
+ }
+
+ m_tooltip.Create(GetDlgItem(IDC_SLIDER1));
+ m_tooltip.Activate(TRUE);
+
+ UpdateData(FALSE);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageAudioSwitcher::OnApply()
{
- UpdateData();
-
- AppSettings& s = AfxGetAppSettings();
-
- s.fEnableAudioSwitcher = !!m_fEnableAudioSwitcher;
- s.fAudioNormalize = !!m_fAudioNormalize;
- s.fAudioNormalizeRecover = !!m_fAudioNormalizeRecover;
- s.dAudioBoost_dB = (float)m_AudioBoostPos/10;
- s.fDownSampleTo441 = !!m_fDownSampleTo441;
- s.fAudioTimeShift = !!m_fAudioTimeShift;
- s.iAudioTimeShift = m_tAudioTimeShift;
- s.fCustomChannelMapping = !!m_fCustomChannelMapping;
- memcpy(s.pSpeakerToChannelMap, m_pSpeakerToChannelMap, sizeof(m_pSpeakerToChannelMap));
-
- if (m_pASF) {
- m_pASF->SetSpeakerConfig(s.fCustomChannelMapping, s.pSpeakerToChannelMap);
- m_pASF->EnableDownSamplingTo441(s.fDownSampleTo441);
- m_pASF->SetAudioTimeShift(s.fAudioTimeShift ? 10000i64*s.iAudioTimeShift : 0);
- m_pASF->SetNormalizeBoost(s.fAudioNormalize, s.fAudioNormalizeRecover, s.dAudioBoost_dB);
- }
-
- s.nSpeakerChannels = m_nChannels;
-
- return __super::OnApply();
+ UpdateData();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ s.fEnableAudioSwitcher = !!m_fEnableAudioSwitcher;
+ s.fAudioNormalize = !!m_fAudioNormalize;
+ s.fAudioNormalizeRecover = !!m_fAudioNormalizeRecover;
+ s.dAudioBoost_dB = (float)m_AudioBoostPos / 10;
+ s.fDownSampleTo441 = !!m_fDownSampleTo441;
+ s.fAudioTimeShift = !!m_fAudioTimeShift;
+ s.iAudioTimeShift = m_tAudioTimeShift;
+ s.fCustomChannelMapping = !!m_fCustomChannelMapping;
+ memcpy(s.pSpeakerToChannelMap, m_pSpeakerToChannelMap, sizeof(m_pSpeakerToChannelMap));
+
+ if (m_pASF) {
+ m_pASF->SetSpeakerConfig(s.fCustomChannelMapping, s.pSpeakerToChannelMap);
+ m_pASF->EnableDownSamplingTo441(s.fDownSampleTo441);
+ m_pASF->SetAudioTimeShift(s.fAudioTimeShift ? 10000i64 * s.iAudioTimeShift : 0);
+ m_pASF->SetNormalizeBoost(s.fAudioNormalize, s.fAudioNormalizeRecover, s.dAudioBoost_dB);
+ }
+
+ s.nSpeakerChannels = m_nChannels;
+
+ return __super::OnApply();
}
void CPPageAudioSwitcher::OnNMClickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
+ LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
- if (lpnmlv->iItem > 0 && lpnmlv->iSubItem > 0 && lpnmlv->iSubItem <= m_nChannels) {
- UpdateData();
- m_pSpeakerToChannelMap[m_nChannels-1][lpnmlv->iItem-1] ^= 1<<(lpnmlv->iSubItem-1);
- m_list.RedrawItems(lpnmlv->iItem, lpnmlv->iItem);
- SetModified();
+ if (lpnmlv->iItem > 0 && lpnmlv->iSubItem > 0 && lpnmlv->iSubItem <= m_nChannels) {
+ UpdateData();
+ m_pSpeakerToChannelMap[m_nChannels - 1][lpnmlv->iItem - 1] ^= 1 << (lpnmlv->iSubItem - 1);
+ m_list.RedrawItems(lpnmlv->iItem, lpnmlv->iItem);
+ SetModified();
- if (GetKeyState(VK_SHIFT) & 0x8000) {
- OnApply();
- }
- }
+ if (GetKeyState(VK_SHIFT) & 0x8000) {
+ OnApply();
+ }
+ }
- *pResult = 0;
+ *pResult = 0;
}
void CPPageAudioSwitcher::OnEnChangeEdit1()
{
- if (IsWindow(m_list.m_hWnd)) {
- UpdateData();
- m_list.Invalidate();
- SetModified();
- }
+ if (IsWindow(m_list.m_hWnd)) {
+ UpdateData();
+ m_list.Invalidate();
+ SetModified();
+ }
}
void CPPageAudioSwitcher::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
- if (nIDCtl != IDC_LIST1) {
- return;
- }
-
- // if (lpDrawItemStruct->itemID == 0)
- // UpdateData();
-
- CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
-
- pDC->SetBkMode(TRANSPARENT);
-
- CPen p(PS_INSIDEFRAME, 1, 0xe0e0e0);
- CPen* old = pDC->SelectObject(&p);
-
- pDC->MoveTo(lpDrawItemStruct->rcItem.left, lpDrawItemStruct->rcItem.bottom-1);
- pDC->LineTo(lpDrawItemStruct->rcItem.right, lpDrawItemStruct->rcItem.bottom-1);
-
- CHeaderCtrl* pHeader = m_list.GetHeaderCtrl();
- int nColumnCount = pHeader->GetItemCount();
-
- for (int i = 0; i < nColumnCount; i++) {
- CRect r, rb;
- m_list.GetSubItemRect(lpDrawItemStruct->itemID, i, LVIR_BOUNDS, rb);
- m_list.GetSubItemRect(lpDrawItemStruct->itemID, i, LVIR_LABEL, r);
-
- pDC->MoveTo(r.right-1, r.top);
- pDC->LineTo(r.right-1, r.bottom-1);
-
- CSize s = pDC->GetTextExtent(m_list.GetItemText(lpDrawItemStruct->itemID, i));
-
- if (i == 0) {
- r.left = rb.left;
-
- if (lpDrawItemStruct->itemID == 0) {
- pDC->MoveTo(0, 0);
- pDC->LineTo(r.right, r.bottom-1);
- } else {
- pDC->SetTextColor(m_list.IsWindowEnabled() ? 0 : 0xb0b0b0);
- pDC->TextOut(r.left+1, (r.top+r.bottom-s.cy)/2, m_list.GetItemText(lpDrawItemStruct->itemID, i));
- }
- } else {
- pDC->SetTextColor(i > m_nChannels ? 0xe0e0e0 : (!m_list.IsWindowEnabled() ? 0xb0b0b0 : 0));
-
- if (lpDrawItemStruct->itemID == 0) {
- pDC->TextOut((r.left+r.right-s.cx)/2, (r.top+r.bottom-s.cy)/2, m_list.GetItemText(lpDrawItemStruct->itemID, i));
- } else {
- if (m_dwChannelMask & (1<<(lpDrawItemStruct->itemID-1))) {
- int nBitsSet = 0;
-
- for (int j = 1; j <= (1<<(lpDrawItemStruct->itemID-1)); j <<= 1) {
- if (m_dwChannelMask & j) {
- nBitsSet++;
- }
- }
-
- if (nBitsSet == i) {
- COLORREF tmp = pDC->GetTextColor();
-
- pDC->SetTextColor(0xe0e0e0);
- CFont f;
- f.CreatePointFont(MulDiv(100, 96, pDC->GetDeviceCaps(LOGPIXELSX)), _T("Marlett"));
- CFont* old = pDC->SelectObject(&f);
- UNREFERENCED_PARAMETER(old);
- s = pDC->GetTextExtent(_T("g"));
- pDC->TextOut((r.left+r.right-s.cx)/2, (r.top+r.bottom-s.cy)/2, _T("g"));
-
- pDC->SetTextColor(tmp);
- }
- }
-
- if (m_pSpeakerToChannelMap[m_nChannels-1][lpDrawItemStruct->itemID-1] & (1<<(i-1))) {
- CFont f;
- f.CreatePointFont(MulDiv(100, 96, pDC->GetDeviceCaps(LOGPIXELSX)), _T("Marlett"));
- CFont* old = pDC->SelectObject(&f);
- s = pDC->GetTextExtent(_T("a"));
- pDC->TextOut((r.left+r.right-s.cx)/2, (r.top+r.bottom-s.cy)/2, _T("a"));
- pDC->SelectObject(old);
- }
- }
- }
- }
-
- pDC->SelectObject(old);
+ if (nIDCtl != IDC_LIST1) {
+ return;
+ }
+
+ // if (lpDrawItemStruct->itemID == 0)
+ // UpdateData();
+
+ CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
+
+ pDC->SetBkMode(TRANSPARENT);
+
+ CPen p(PS_INSIDEFRAME, 1, 0xe0e0e0);
+ CPen* old = pDC->SelectObject(&p);
+
+ pDC->MoveTo(lpDrawItemStruct->rcItem.left, lpDrawItemStruct->rcItem.bottom - 1);
+ pDC->LineTo(lpDrawItemStruct->rcItem.right, lpDrawItemStruct->rcItem.bottom - 1);
+
+ CHeaderCtrl* pHeader = m_list.GetHeaderCtrl();
+ int nColumnCount = pHeader->GetItemCount();
+
+ for (int i = 0; i < nColumnCount; i++) {
+ CRect r, rb;
+ m_list.GetSubItemRect(lpDrawItemStruct->itemID, i, LVIR_BOUNDS, rb);
+ m_list.GetSubItemRect(lpDrawItemStruct->itemID, i, LVIR_LABEL, r);
+
+ pDC->MoveTo(r.right - 1, r.top);
+ pDC->LineTo(r.right - 1, r.bottom - 1);
+
+ CSize s = pDC->GetTextExtent(m_list.GetItemText(lpDrawItemStruct->itemID, i));
+
+ if (i == 0) {
+ r.left = rb.left;
+
+ if (lpDrawItemStruct->itemID == 0) {
+ pDC->MoveTo(0, 0);
+ pDC->LineTo(r.right, r.bottom - 1);
+ } else {
+ pDC->SetTextColor(m_list.IsWindowEnabled() ? 0 : 0xb0b0b0);
+ pDC->TextOut(r.left + 1, (r.top + r.bottom - s.cy) / 2, m_list.GetItemText(lpDrawItemStruct->itemID, i));
+ }
+ } else {
+ pDC->SetTextColor(i > m_nChannels ? 0xe0e0e0 : (!m_list.IsWindowEnabled() ? 0xb0b0b0 : 0));
+
+ if (lpDrawItemStruct->itemID == 0) {
+ pDC->TextOut((r.left + r.right - s.cx) / 2, (r.top + r.bottom - s.cy) / 2, m_list.GetItemText(lpDrawItemStruct->itemID, i));
+ } else {
+ if (m_dwChannelMask & (1 << (lpDrawItemStruct->itemID - 1))) {
+ int nBitsSet = 0;
+
+ for (int j = 1; j <= (1 << (lpDrawItemStruct->itemID - 1)); j <<= 1) {
+ if (m_dwChannelMask & j) {
+ nBitsSet++;
+ }
+ }
+
+ if (nBitsSet == i) {
+ COLORREF tmp = pDC->GetTextColor();
+
+ pDC->SetTextColor(0xe0e0e0);
+ CFont f;
+ f.CreatePointFont(MulDiv(100, 96, pDC->GetDeviceCaps(LOGPIXELSX)), _T("Marlett"));
+ CFont* old = pDC->SelectObject(&f);
+ UNREFERENCED_PARAMETER(old);
+ s = pDC->GetTextExtent(_T("g"));
+ pDC->TextOut((r.left + r.right - s.cx) / 2, (r.top + r.bottom - s.cy) / 2, _T("g"));
+
+ pDC->SetTextColor(tmp);
+ }
+ }
+
+ if (m_pSpeakerToChannelMap[m_nChannels - 1][lpDrawItemStruct->itemID - 1] & (1 << (i - 1))) {
+ CFont f;
+ f.CreatePointFont(MulDiv(100, 96, pDC->GetDeviceCaps(LOGPIXELSX)), _T("Marlett"));
+ CFont* old = pDC->SelectObject(&f);
+ s = pDC->GetTextExtent(_T("a"));
+ pDC->TextOut((r.left + r.right - s.cx) / 2, (r.top + r.bottom - s.cy) / 2, _T("a"));
+ pDC->SelectObject(old);
+ }
+ }
+ }
+ }
+
+ pDC->SelectObject(old);
}
void CPPageAudioSwitcher::OnUpdateAudioSwitcher(CCmdUI* pCmdUI)
{
- // UpdateData();
- pCmdUI->Enable(IsDlgButtonChecked(IDC_CHECK2)/*m_fEnableAudioSwitcher*/);
+ // UpdateData();
+ pCmdUI->Enable(IsDlgButtonChecked(IDC_CHECK2)/*m_fEnableAudioSwitcher*/);
}
void CPPageAudioSwitcher::OnUpdateChannelMapping(CCmdUI* pCmdUI)
{
- // UpdateData();
- pCmdUI->Enable(IsDlgButtonChecked(IDC_CHECK2)/*m_fEnableAudioSwitcher*/
- && IsDlgButtonChecked(IDC_CHECK1)/*m_fCustomChannelMapping*/);
+ // UpdateData();
+ pCmdUI->Enable(IsDlgButtonChecked(IDC_CHECK2)/*m_fEnableAudioSwitcher*/
+ && IsDlgButtonChecked(IDC_CHECK1)/*m_fCustomChannelMapping*/);
}
void CPPageAudioSwitcher::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
- if (*pScrollBar == m_AudioBoostCtrl) {
- UpdateData();
- ((CMainFrame*)GetParentFrame())->SetVolumeBoost((float)m_AudioBoostPos/10); // nice shortcut...
- }
+ if (*pScrollBar == m_AudioBoostCtrl) {
+ UpdateData();
+ ((CMainFrame*)GetParentFrame())->SetVolumeBoost((float)m_AudioBoostPos / 10); // nice shortcut...
+ }
- SetModified();
+ SetModified();
- __super::OnHScroll(nSBCode, nPos, pScrollBar);
+ __super::OnHScroll(nSBCode, nPos, pScrollBar);
}
-BOOL CPPageAudioSwitcher::OnToolTipNotify(UINT id, NMHDR * pNMHDR, LRESULT * pResult)
+BOOL CPPageAudioSwitcher::OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
{
- TOOLTIPTEXT* pTTT = (TOOLTIPTEXT*)pNMHDR;
+ TOOLTIPTEXT* pTTT = (TOOLTIPTEXT*)pNMHDR;
- UINT_PTR nID = pNMHDR->idFrom;
- if (pTTT->uFlags & TTF_IDISHWND) {
- nID = ::GetDlgCtrlID((HWND)nID);
- }
+ UINT_PTR nID = pNMHDR->idFrom;
+ if (pTTT->uFlags & TTF_IDISHWND) {
+ nID = ::GetDlgCtrlID((HWND)nID);
+ }
- if (nID != IDC_SLIDER1) {
- return FALSE;
- }
+ if (nID != IDC_SLIDER1) {
+ return FALSE;
+ }
- static CString strTipText; // static string
+ static CString strTipText; // static string
- strTipText.Format(_T("+%.1f dB"), m_AudioBoostCtrl.GetPos()/10.0);
+ strTipText.Format(_T("+%.1f dB"), m_AudioBoostCtrl.GetPos() / 10.0);
- pTTT->lpszText = (LPWSTR)(LPCWSTR)strTipText;
+ pTTT->lpszText = (LPWSTR)(LPCWSTR)strTipText;
- *pResult = 0;
+ *pResult = 0;
- return TRUE; // message was handled
+ return TRUE; // message was handled
}
void CPPageAudioSwitcher::OnCancel()
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- if (m_AudioBoostPos != (int)(s.dAudioBoost_dB*10+0.1)) {
- ((CMainFrame*)GetParentFrame())->SetVolumeBoost(s.dAudioBoost_dB);
- }
+ if (m_AudioBoostPos != (int)(s.dAudioBoost_dB * 10 + 0.1)) {
+ ((CMainFrame*)GetParentFrame())->SetVolumeBoost(s.dAudioBoost_dB);
+ }
- __super::OnCancel();
+ __super::OnCancel();
}
diff --git a/src/mpc-hc/PPageAudioSwitcher.h b/src/mpc-hc/PPageAudioSwitcher.h
index 4c09e2a63..aa48ceead 100644
--- a/src/mpc-hc/PPageAudioSwitcher.h
+++ b/src/mpc-hc/PPageAudioSwitcher.h
@@ -31,57 +31,57 @@
class CPPageAudioSwitcher : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageAudioSwitcher)
+ DECLARE_DYNAMIC(CPPageAudioSwitcher)
private:
- CComQIPtr<IAudioSwitcherFilter> m_pASF;
- DWORD m_pSpeakerToChannelMap[18][18];
- DWORD m_dwChannelMask;
+ CComQIPtr<IAudioSwitcherFilter> m_pASF;
+ DWORD m_pSpeakerToChannelMap[18][18];
+ DWORD m_dwChannelMask;
public:
- CPPageAudioSwitcher(IFilterGraph* pFG);
- virtual ~CPPageAudioSwitcher();
+ CPPageAudioSwitcher(IFilterGraph* pFG);
+ virtual ~CPPageAudioSwitcher();
- // Dialog Data
- enum { IDD = IDD_PPAGEAUDIOSWITCHER };
+ // Dialog Data
+ enum { IDD = IDD_PPAGEAUDIOSWITCHER };
- BOOL m_fEnableAudioSwitcher;
- BOOL m_fAudioNormalize;
- BOOL m_fAudioNormalizeRecover;
- int m_AudioBoostPos;
- CSliderCtrl m_AudioBoostCtrl;
- BOOL m_fDownSampleTo441;
- CButton m_fDownSampleTo441Ctrl;
- BOOL m_fCustomChannelMapping;
- CButton m_fCustomChannelMappingCtrl;
- CEdit m_nChannelsCtrl;
- int m_nChannels;
- CSpinButtonCtrl m_nChannelsSpinCtrl;
- CListCtrl m_list;
- int m_tAudioTimeShift;
- CButton m_fAudioTimeShiftCtrl;
- CIntEdit m_tAudioTimeShiftCtrl;
- CSpinButtonCtrl m_tAudioTimeShiftSpin;
- BOOL m_fAudioTimeShift;
+ BOOL m_fEnableAudioSwitcher;
+ BOOL m_fAudioNormalize;
+ BOOL m_fAudioNormalizeRecover;
+ int m_AudioBoostPos;
+ CSliderCtrl m_AudioBoostCtrl;
+ BOOL m_fDownSampleTo441;
+ CButton m_fDownSampleTo441Ctrl;
+ BOOL m_fCustomChannelMapping;
+ CButton m_fCustomChannelMappingCtrl;
+ CEdit m_nChannelsCtrl;
+ int m_nChannels;
+ CSpinButtonCtrl m_nChannelsSpinCtrl;
+ CListCtrl m_list;
+ int m_tAudioTimeShift;
+ CButton m_fAudioTimeShiftCtrl;
+ CIntEdit m_tAudioTimeShiftCtrl;
+ CSpinButtonCtrl m_tAudioTimeShiftSpin;
+ BOOL m_fAudioTimeShift;
- // tooltip for slidercontrol
- CToolTipCtrl m_tooltip;
+ // tooltip for slidercontrol
+ CToolTipCtrl m_tooltip;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnNMClickList1(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
- afx_msg void OnEnChangeEdit1();
- afx_msg void OnUpdateAudioSwitcher(CCmdUI* pCmdUI);
- afx_msg void OnUpdateChannelMapping(CCmdUI* pCmdUI);
+ afx_msg void OnNMClickList1(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
+ afx_msg void OnEnChangeEdit1();
+ afx_msg void OnUpdateAudioSwitcher(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateChannelMapping(CCmdUI* pCmdUI);
public:
- afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
- afx_msg BOOL OnToolTipNotify(UINT id, NMHDR * pNMHDR, LRESULT * pResult);
- virtual void OnCancel();
+ afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
+ afx_msg BOOL OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
+ virtual void OnCancel();
};
diff --git a/src/mpc-hc/PPageBase.cpp b/src/mpc-hc/PPageBase.cpp
index d5f002276..27d023a73 100644
--- a/src/mpc-hc/PPageBase.cpp
+++ b/src/mpc-hc/PPageBase.cpp
@@ -30,7 +30,7 @@
IMPLEMENT_DYNAMIC(CPPageBase, CCmdUIPropertyPage)
CPPageBase::CPPageBase(UINT nIDTemplate, UINT nIDCaption)
- : CCmdUIPropertyPage(nIDTemplate, nIDCaption)
+ : CCmdUIPropertyPage(nIDTemplate, nIDCaption)
{
}
@@ -40,45 +40,45 @@ CPPageBase::~CPPageBase()
void CPPageBase::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
+ __super::DoDataExchange(pDX);
}
void CPPageBase::CreateToolTip()
{
- m_wndToolTip.Create(this);
- m_wndToolTip.Activate(TRUE);
- m_wndToolTip.SetMaxTipWidth(300);
- m_wndToolTip.SetDelayTime(TTDT_AUTOPOP, 10000);
- for (CWnd* pChild = GetWindow(GW_CHILD); pChild; pChild = pChild->GetWindow(GW_HWNDNEXT)) {
- CString strToolTip;
- if (strToolTip.LoadString(pChild->GetDlgCtrlID())) {
- m_wndToolTip.AddTool(pChild, strToolTip);
- }
- }
+ m_wndToolTip.Create(this);
+ m_wndToolTip.Activate(TRUE);
+ m_wndToolTip.SetMaxTipWidth(300);
+ m_wndToolTip.SetDelayTime(TTDT_AUTOPOP, 10000);
+ for (CWnd* pChild = GetWindow(GW_CHILD); pChild; pChild = pChild->GetWindow(GW_HWNDNEXT)) {
+ CString strToolTip;
+ if (strToolTip.LoadString(pChild->GetDlgCtrlID())) {
+ m_wndToolTip.AddTool(pChild, strToolTip);
+ }
+ }
}
BOOL CPPageBase::PreTranslateMessage(MSG* pMsg)
{
- if (IsWindow(m_wndToolTip))
- if (pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MOUSELAST) {
- MSG msg;
- memcpy(&msg, pMsg, sizeof(MSG));
- for (HWND hWndParent = ::GetParent(msg.hwnd);
- hWndParent && hWndParent != m_hWnd;
- hWndParent = ::GetParent(hWndParent)) {
- msg.hwnd = hWndParent;
- }
+ if (IsWindow(m_wndToolTip))
+ if (pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MOUSELAST) {
+ MSG msg;
+ memcpy(&msg, pMsg, sizeof(MSG));
+ for (HWND hWndParent = ::GetParent(msg.hwnd);
+ hWndParent && hWndParent != m_hWnd;
+ hWndParent = ::GetParent(hWndParent)) {
+ msg.hwnd = hWndParent;
+ }
- if (msg.hwnd) {
- m_wndToolTip.RelayEvent(&msg);
- }
- }
+ if (msg.hwnd) {
+ m_wndToolTip.RelayEvent(&msg);
+ }
+ }
- return __super::PreTranslateMessage(pMsg);
+ return __super::PreTranslateMessage(pMsg);
}
BEGIN_MESSAGE_MAP(CPPageBase, CCmdUIPropertyPage)
- ON_WM_DESTROY()
+ ON_WM_DESTROY()
END_MESSAGE_MAP()
@@ -86,12 +86,12 @@ END_MESSAGE_MAP()
BOOL CPPageBase::OnSetActive()
{
- AfxGetAppSettings().nLastUsedPage = (UINT)m_pPSP->pszTemplate;
- return __super::OnSetActive();
+ AfxGetAppSettings().nLastUsedPage = (UINT)m_pPSP->pszTemplate;
+ return __super::OnSetActive();
}
void CPPageBase::OnDestroy()
{
- __super::OnDestroy();
- m_wndToolTip.DestroyWindow();
+ __super::OnDestroy();
+ m_wndToolTip.DestroyWindow();
}
diff --git a/src/mpc-hc/PPageBase.h b/src/mpc-hc/PPageBase.h
index 50b9aac64..11ba5e90e 100644
--- a/src/mpc-hc/PPageBase.h
+++ b/src/mpc-hc/PPageBase.h
@@ -29,25 +29,25 @@
class CPPageBase : public CCmdUIPropertyPage
{
- DECLARE_DYNAMIC(CPPageBase)
+ DECLARE_DYNAMIC(CPPageBase)
protected:
- CToolTipCtrl m_wndToolTip;
- void CreateToolTip();
+ CToolTipCtrl m_wndToolTip;
+ void CreateToolTip();
public:
- CPPageBase(UINT nIDTemplate, UINT nIDCaption = 0);
- virtual ~CPPageBase();
+ CPPageBase(UINT nIDTemplate, UINT nIDCaption = 0);
+ virtual ~CPPageBase();
- // Dialog Data
+ // Dialog Data
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- virtual BOOL OnSetActive();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL OnSetActive();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnDestroy();
+ afx_msg void OnDestroy();
};
diff --git a/src/mpc-hc/PPageCapture.cpp b/src/mpc-hc/PPageCapture.cpp
index b65ef0b85..80f9076f2 100644
--- a/src/mpc-hc/PPageCapture.cpp
+++ b/src/mpc-hc/PPageCapture.cpp
@@ -36,253 +36,253 @@
static struct cc_t {
- long code;
- AnalogVideoStandard standard;
- const TCHAR* str;
+ long code;
+ AnalogVideoStandard standard;
+ const TCHAR* str;
} s_countrycodes[] = {
- {1, AnalogVideo_NTSC_M, _T("USA")},
- /* {1, AnalogVideo_NTSC_M, _T("Anguilla")},
- {1, AnalogVideo_NTSC_M, _T("Antigua")},
- {1, AnalogVideo_NTSC_M, _T("Bahamas")},
- {1, AnalogVideo_NTSC_M, _T("Barbados")},
- {1, AnalogVideo_NTSC_M, _T("Bermuda")},
- {1, AnalogVideo_NTSC_M, _T("British Virgin Islands")},
- {1, AnalogVideo_NTSC_M, _T("Canada")},
- {1, AnalogVideo_NTSC_M, _T("Cayman Islands")},
- {1, AnalogVideo_NTSC_M, _T("Dominica")},
- {1, AnalogVideo_NTSC_M, _T("Dominican Republic")},
- {1, AnalogVideo_NTSC_M, _T("Grenada")},
- {1, AnalogVideo_NTSC_M, _T("Jamaica")},
- {1, AnalogVideo_NTSC_M, _T("Montserrat")},
- {1, AnalogVideo_NTSC_M, _T("Nevis")},
- {1, AnalogVideo_NTSC_M, _T("St. Kitts")},
- {1, AnalogVideo_NTSC_M, _T("St. Vincent and the Grenadines")},
- {1, AnalogVideo_NTSC_M, _T("Trinidad and Tobago")},
- {1, AnalogVideo_NTSC_M, _T("Turks and Caicos Islands")},
- {1, AnalogVideo_NTSC_M, _T("Barbuda")},
- {1, AnalogVideo_NTSC_M, _T("Puerto Rico")},
- {1, AnalogVideo_NTSC_M, _T("Saint Lucia")},
- {1, AnalogVideo_NTSC_M, _T("United States Virgin Islands")},
- */
- {2, AnalogVideo_NTSC_M, _T("Canada")},
- {7, AnalogVideo_SECAM_D, _T("Russia")},
- /* {7, AnalogVideo_SECAM_D, _T("Kazakhstan")},
- {7, AnalogVideo_SECAM_D, _T("Kyrgyzstan")},
- {7, AnalogVideo_SECAM_D, _T("Tajikistan")},
- {7, AnalogVideo_SECAM_D, _T("Turkmenistan")},
- {7, AnalogVideo_SECAM_D, _T("Uzbekistan")},
- */
- {20, AnalogVideo_SECAM_B, _T("Egypt")},
- {27, AnalogVideo_PAL_I, _T("South Africa")},
- {30, AnalogVideo_SECAM_B, _T("Greece")},
- {31, AnalogVideo_PAL_B, _T("Netherlands")},
- {32, AnalogVideo_PAL_B, _T("Belgium")},
- {33, AnalogVideo_SECAM_L, _T("France")},
- {34, AnalogVideo_PAL_B, _T("Spain")},
- {36, AnalogVideo_PAL_B, _T("Hungary")},
- {39, AnalogVideo_PAL_B, _T("Italy")},
- {39, AnalogVideo_PAL_B, _T("Vatican City")},
- {40, AnalogVideo_PAL_D, _T("Romania")},
- {41, AnalogVideo_PAL_B, _T("Switzerland")},
- {41, AnalogVideo_PAL_B, _T("Liechtenstein")},
- {43, AnalogVideo_PAL_B, _T("Austria")},
- {44, AnalogVideo_PAL_I, _T("United Kingdom")},
- {45, AnalogVideo_PAL_B, _T("Denmark")},
- {46, AnalogVideo_PAL_B, _T("Sweden")},
- {47, AnalogVideo_PAL_B, _T("Norway")},
- {48, AnalogVideo_PAL_B, _T("Poland")},
- {49, AnalogVideo_PAL_B, _T("Germany")},
- {51, AnalogVideo_NTSC_M, _T("Peru")},
- {52, AnalogVideo_NTSC_M, _T("Mexico")},
- {53, AnalogVideo_NTSC_M, _T("Cuba")},
- {53, AnalogVideo_NTSC_M, _T("Guantanamo Bay")},
- {54, AnalogVideo_PAL_N, _T("Argentina")},
- {55, AnalogVideo_PAL_M, _T("Brazil")},
- {56, AnalogVideo_NTSC_M, _T("Chile")},
- {57, AnalogVideo_NTSC_M, _T("Colombia")},
- {58, AnalogVideo_NTSC_M, _T("Bolivarian Republic of Venezuela")},
- {60, AnalogVideo_PAL_B, _T("Malaysia")},
- {61, AnalogVideo_PAL_B, _T("Australia")},
- // {61, AnalogVideo_NTSC_M, _T("Cocos-Keeling Islands")},
- {62, AnalogVideo_PAL_B, _T("Indonesia")},
- {63, AnalogVideo_NTSC_M, _T("Philippines")},
- {64, AnalogVideo_PAL_B, _T("New Zealand")},
- {65, AnalogVideo_PAL_B, _T("Singapore")},
- {66, AnalogVideo_PAL_B, _T("Thailand")},
- {81, AnalogVideo_NTSC_M_J, _T("Japan")},
- {82, AnalogVideo_NTSC_M, _T("Korea (South)")},
- {84, AnalogVideo_NTSC_M, _T("Vietnam")},
- {86, AnalogVideo_PAL_D, _T("China")},
- {90, AnalogVideo_PAL_B, _T("Turkey")},
- {91, AnalogVideo_PAL_B, _T("India")},
- {92, AnalogVideo_PAL_B, _T("Pakistan")},
- {93, AnalogVideo_PAL_B, _T("Afghanistan")},
- {94, AnalogVideo_PAL_B, _T("Sri Lanka")},
- {95, AnalogVideo_NTSC_M, _T("Myanmar")},
- {98, AnalogVideo_SECAM_B, _T("Iran")},
- {212, AnalogVideo_SECAM_B, _T("Morocco")},
- {213, AnalogVideo_PAL_B, _T("Algeria")},
- {216, AnalogVideo_SECAM_B, _T("Tunisia")},
- {218, AnalogVideo_SECAM_B, _T("Libya")},
- {220, AnalogVideo_SECAM_K, _T("Gambia")},
- {221, AnalogVideo_SECAM_K, _T("Senegal Republic")},
- {222, AnalogVideo_SECAM_B, _T("Mauritania")},
- {223, AnalogVideo_SECAM_K, _T("Mali")},
- {224, AnalogVideo_SECAM_K, _T("Guinea")},
- {225, AnalogVideo_SECAM_K, _T("Cote D'Ivoire")},
- {226, AnalogVideo_SECAM_K, _T("Burkina Faso")},
- {227, AnalogVideo_SECAM_K, _T("Niger")},
- {228, AnalogVideo_SECAM_K, _T("Togo")},
- {229, AnalogVideo_SECAM_K, _T("Benin")},
- {230, AnalogVideo_SECAM_B, _T("Mauritius")},
- {231, AnalogVideo_PAL_B, _T("Liberia")},
- {232, AnalogVideo_PAL_B, _T("Sierra Leone")},
- {233, AnalogVideo_PAL_B, _T("Ghana")},
- {234, AnalogVideo_PAL_B, _T("Nigeria")},
- {235, AnalogVideo_PAL_B, _T("Chad")},
- {236, AnalogVideo_PAL_B, _T("Central African Republic")},
- {237, AnalogVideo_PAL_B, _T("Cameroon")},
- {238, AnalogVideo_NTSC_M, _T("Cape Verde Islands")},
- {239, AnalogVideo_PAL_B, _T("Sao Tome and Principe")},
- {240, AnalogVideo_SECAM_B, _T("Equatorial Guinea")},
- {241, AnalogVideo_SECAM_K, _T("Gabon")},
- {242, AnalogVideo_SECAM_D, _T("Congo")},
- {243, AnalogVideo_SECAM_K, _T("Congo(DRC)")},
- {244, AnalogVideo_PAL_I, _T("Angola")},
- {245, AnalogVideo_NTSC_M, _T("Guinea-Bissau")},
- {246, AnalogVideo_NTSC_M, _T("Diego Garcia")},
- {247, AnalogVideo_NTSC_M, _T("Ascension Island")},
- {248, AnalogVideo_PAL_B, _T("Seychelles Islands")},
- {249, AnalogVideo_PAL_B, _T("Sudan")},
- {250, AnalogVideo_PAL_B, _T("Rwanda")},
- {251, AnalogVideo_PAL_B, _T("Ethiopia")},
- {252, AnalogVideo_PAL_B, _T("Somalia")},
- {253, AnalogVideo_SECAM_K, _T("Djibouti")},
- {254, AnalogVideo_PAL_B, _T("Kenya")},
- {255, AnalogVideo_PAL_B, _T("Tanzania")},
- {256, AnalogVideo_PAL_B, _T("Uganda")},
- {257, AnalogVideo_SECAM_K, _T("Burundi")},
- {258, AnalogVideo_PAL_B, _T("Mozambique")},
- {260, AnalogVideo_PAL_B, _T("Zambia")},
- {261, AnalogVideo_SECAM_K, _T("Madagascar")},
- {262, AnalogVideo_SECAM_K, _T("Reunion Island")},
- {263, AnalogVideo_PAL_B, _T("Zimbabwe")},
- {264, AnalogVideo_PAL_I, _T("Namibia")},
- {265, AnalogVideo_NTSC_M, _T("Malawi")},
- {266, AnalogVideo_PAL_I, _T("Lesotho")},
- {267, AnalogVideo_SECAM_K, _T("Botswana")},
- {268, AnalogVideo_PAL_B, _T("Swaziland")},
- {269, AnalogVideo_SECAM_K, _T("Mayotte Island")},
- // {269, AnalogVideo_NTSC_M, _T("Comoros")},
- {290, AnalogVideo_NTSC_M, _T("St. Helena")},
- {291, AnalogVideo_NTSC_M, _T("Eritrea")},
- {297, AnalogVideo_NTSC_M, _T("Aruba")},
- {298, AnalogVideo_PAL_B, _T("Faroe Islands")},
- {299, AnalogVideo_NTSC_M, _T("Greenland")},
- {350, AnalogVideo_PAL_B, _T("Gibraltar")},
- {351, AnalogVideo_PAL_B, _T("Portugal")},
- {352, AnalogVideo_PAL_B, _T("Luxembourg")},
- {353, AnalogVideo_PAL_I, _T("Ireland")},
- {354, AnalogVideo_PAL_B, _T("Iceland")},
- {355, AnalogVideo_PAL_B, _T("Albania")},
- {356, AnalogVideo_PAL_B, _T("Malta")},
- {357, AnalogVideo_PAL_B, _T("Cyprus")},
- {358, AnalogVideo_PAL_B, _T("Finland")},
- {359, AnalogVideo_SECAM_D, _T("Bulgaria")},
- {370, AnalogVideo_PAL_B, _T("Lithuania")},
- {371, AnalogVideo_SECAM_D, _T("Latvia")},
- {372, AnalogVideo_PAL_B, _T("Estonia")},
- {373, AnalogVideo_SECAM_D, _T("Moldova")},
- {374, AnalogVideo_SECAM_D, _T("Armenia")},
- {375, AnalogVideo_SECAM_D, _T("Belarus")},
- {376, AnalogVideo_NTSC_M, _T("Andorra")},
- {377, AnalogVideo_SECAM_G, _T("Monaco")},
- {378, AnalogVideo_PAL_B, _T("San Marino")},
- {380, AnalogVideo_SECAM_D, _T("Ukraine")},
- {381, AnalogVideo_PAL_B, _T("Serbia and Montenegro")},
- {385, AnalogVideo_PAL_B, _T("Croatia")},
- {386, AnalogVideo_PAL_B, _T("Slovenia")},
- {387, AnalogVideo_PAL_B, _T("Bosnia and Herzegovina")},
- {389, AnalogVideo_PAL_B, _T("F.Y.R.O.M. (Former Yugoslav Republic of Macedonia)")},
- {420, AnalogVideo_PAL_D, _T("Czech Republic")},
- {421, AnalogVideo_PAL_B, _T("Slovak Republic")},
- {500, AnalogVideo_PAL_I, _T("Falkland Islands (Islas Malvinas)")},
- {501, AnalogVideo_NTSC_M, _T("Belize")},
- {502, AnalogVideo_NTSC_M, _T("Guatemala")},
- {503, AnalogVideo_NTSC_M, _T("El Salvador")},
- {504, AnalogVideo_NTSC_M, _T("Honduras")},
- {505, AnalogVideo_NTSC_M, _T("Nicaragua")},
- {506, AnalogVideo_NTSC_M, _T("Costa Rica")},
- {507, AnalogVideo_NTSC_M, _T("Panama")},
- {508, AnalogVideo_SECAM_K, _T("St. Pierre and Miquelon")},
- {509, AnalogVideo_NTSC_M, _T("Haiti")},
- {590, AnalogVideo_SECAM_K, _T("Guadeloupe")},
- // {590, AnalogVideo_NTSC_M, _T("French Antilles")},
- {591, AnalogVideo_PAL_N, _T("Bolivia")},
- {592, AnalogVideo_SECAM_K, _T("Guyana")},
- {593, AnalogVideo_NTSC_M, _T("Ecuador")},
- {594, AnalogVideo_SECAM_K, _T("French Guiana")},
- {595, AnalogVideo_PAL_N, _T("Paraguay")},
- {596, AnalogVideo_SECAM_K, _T("Martinique")},
- {597, AnalogVideo_NTSC_M, _T("Suriname")},
- {598, AnalogVideo_PAL_N, _T("Uruguay")},
- {599, AnalogVideo_NTSC_M, _T("Netherlands Antilles")},
- {670, AnalogVideo_NTSC_M, _T("Saipan Island")},
- // {670, AnalogVideo_NTSC_M, _T("Rota Island")},
- // {670, AnalogVideo_NTSC_M, _T("Tinian Island")},
- {671, AnalogVideo_NTSC_M, _T("Guam")},
- {672, AnalogVideo_NTSC_M, _T("Christmas Island")},
- {672, AnalogVideo_NTSC_M, _T("Australian Antarctic Territory")},
- // {672, AnalogVideo_PAL_B, _T("Norfolk Island")},
- {673, AnalogVideo_PAL_B, _T("Brunei")},
- {674, AnalogVideo_NTSC_M, _T("Nauru")},
- {675, AnalogVideo_PAL_B, _T("Papua New Guinea")},
- {676, AnalogVideo_NTSC_M, _T("Tonga")},
- {677, AnalogVideo_NTSC_M, _T("Solomon Islands")},
- {678, AnalogVideo_NTSC_M, _T("Vanuatu")},
- {679, AnalogVideo_NTSC_M, _T("Fiji Islands")},
- {680, AnalogVideo_NTSC_M, _T("Palau")},
- {681, AnalogVideo_SECAM_K, _T("Wallis and Futuna Islands")},
- {682, AnalogVideo_PAL_B, _T("Cook Islands")},
- {683, AnalogVideo_NTSC_M, _T("Niue")},
- {684, AnalogVideo_NTSC_M, _T("Territory of American Samoa")},
- {685, AnalogVideo_PAL_B, _T("Samoa")},
- {686, AnalogVideo_PAL_B, _T("Kiribati Republic")},
- {687, AnalogVideo_SECAM_K, _T("New Caledonia")},
- {688, AnalogVideo_NTSC_M, _T("Tuvalu")},
- {689, AnalogVideo_SECAM_K, _T("French Polynesia")},
- {690, AnalogVideo_NTSC_M, _T("Tokelau")},
- {691, AnalogVideo_NTSC_M, _T("Micronesia")},
- {692, AnalogVideo_NTSC_M, _T("Marshall Islands")},
- {850, AnalogVideo_SECAM_D, _T("Korea (North)")},
- {852, AnalogVideo_PAL_I, _T("Hong Kong SAR")},
- {853, AnalogVideo_PAL_I, _T("Macao SAR")},
- {855, AnalogVideo_PAL_B, _T("Cambodia")},
- {856, AnalogVideo_PAL_B, _T("Laos")},
- {871, AnalogVideo_NTSC_M, _T("INMARSAT (Atlantic-East)")},
- {872, AnalogVideo_NTSC_M, _T("INMARSAT (Pacific)")},
- {873, AnalogVideo_NTSC_M, _T("INMARSAT (Indian)")},
- {874, AnalogVideo_NTSC_M, _T("INMARSAT (Atlantic-West)")},
- {880, AnalogVideo_PAL_B, _T("Bangladesh")},
- {886, AnalogVideo_NTSC_M, _T("Taiwan")},
- {960, AnalogVideo_PAL_B, _T("Maldives")},
- {961, AnalogVideo_SECAM_B, _T("Lebanon")},
- {962, AnalogVideo_PAL_B, _T("Jordan")},
- {963, AnalogVideo_SECAM_B, _T("Syria")},
- {964, AnalogVideo_SECAM_B, _T("Iraq")},
- {965, AnalogVideo_PAL_B, _T("Kuwait")},
- {966, AnalogVideo_SECAM_B, _T("Saudi Arabia")},
- {967, AnalogVideo_PAL_B, _T("Yemen")},
- {968, AnalogVideo_PAL_B, _T("Oman")},
- {971, AnalogVideo_PAL_B, _T("United Arab Emirates")},
- {972, AnalogVideo_PAL_B, _T("Israel")},
- {973, AnalogVideo_PAL_B, _T("Bahrain")},
- {974, AnalogVideo_PAL_B, _T("Qatar")},
- {975, AnalogVideo_NTSC_M, _T("Bhutan")},
- {976, AnalogVideo_SECAM_D, _T("Mongolia")},
- {977, AnalogVideo_PAL_B, _T("Nepal")},
- {994, AnalogVideo_SECAM_D, _T("Azerbaijan")},
- {995, AnalogVideo_SECAM_D,_T("Georgia")},
+ {1, AnalogVideo_NTSC_M, _T("USA")},
+ /* {1, AnalogVideo_NTSC_M, _T("Anguilla")},
+ {1, AnalogVideo_NTSC_M, _T("Antigua")},
+ {1, AnalogVideo_NTSC_M, _T("Bahamas")},
+ {1, AnalogVideo_NTSC_M, _T("Barbados")},
+ {1, AnalogVideo_NTSC_M, _T("Bermuda")},
+ {1, AnalogVideo_NTSC_M, _T("British Virgin Islands")},
+ {1, AnalogVideo_NTSC_M, _T("Canada")},
+ {1, AnalogVideo_NTSC_M, _T("Cayman Islands")},
+ {1, AnalogVideo_NTSC_M, _T("Dominica")},
+ {1, AnalogVideo_NTSC_M, _T("Dominican Republic")},
+ {1, AnalogVideo_NTSC_M, _T("Grenada")},
+ {1, AnalogVideo_NTSC_M, _T("Jamaica")},
+ {1, AnalogVideo_NTSC_M, _T("Montserrat")},
+ {1, AnalogVideo_NTSC_M, _T("Nevis")},
+ {1, AnalogVideo_NTSC_M, _T("St. Kitts")},
+ {1, AnalogVideo_NTSC_M, _T("St. Vincent and the Grenadines")},
+ {1, AnalogVideo_NTSC_M, _T("Trinidad and Tobago")},
+ {1, AnalogVideo_NTSC_M, _T("Turks and Caicos Islands")},
+ {1, AnalogVideo_NTSC_M, _T("Barbuda")},
+ {1, AnalogVideo_NTSC_M, _T("Puerto Rico")},
+ {1, AnalogVideo_NTSC_M, _T("Saint Lucia")},
+ {1, AnalogVideo_NTSC_M, _T("United States Virgin Islands")},
+ */
+ {2, AnalogVideo_NTSC_M, _T("Canada")},
+ {7, AnalogVideo_SECAM_D, _T("Russia")},
+ /* {7, AnalogVideo_SECAM_D, _T("Kazakhstan")},
+ {7, AnalogVideo_SECAM_D, _T("Kyrgyzstan")},
+ {7, AnalogVideo_SECAM_D, _T("Tajikistan")},
+ {7, AnalogVideo_SECAM_D, _T("Turkmenistan")},
+ {7, AnalogVideo_SECAM_D, _T("Uzbekistan")},
+ */
+ {20, AnalogVideo_SECAM_B, _T("Egypt")},
+ {27, AnalogVideo_PAL_I, _T("South Africa")},
+ {30, AnalogVideo_SECAM_B, _T("Greece")},
+ {31, AnalogVideo_PAL_B, _T("Netherlands")},
+ {32, AnalogVideo_PAL_B, _T("Belgium")},
+ {33, AnalogVideo_SECAM_L, _T("France")},
+ {34, AnalogVideo_PAL_B, _T("Spain")},
+ {36, AnalogVideo_PAL_B, _T("Hungary")},
+ {39, AnalogVideo_PAL_B, _T("Italy")},
+ {39, AnalogVideo_PAL_B, _T("Vatican City")},
+ {40, AnalogVideo_PAL_D, _T("Romania")},
+ {41, AnalogVideo_PAL_B, _T("Switzerland")},
+ {41, AnalogVideo_PAL_B, _T("Liechtenstein")},
+ {43, AnalogVideo_PAL_B, _T("Austria")},
+ {44, AnalogVideo_PAL_I, _T("United Kingdom")},
+ {45, AnalogVideo_PAL_B, _T("Denmark")},
+ {46, AnalogVideo_PAL_B, _T("Sweden")},
+ {47, AnalogVideo_PAL_B, _T("Norway")},
+ {48, AnalogVideo_PAL_B, _T("Poland")},
+ {49, AnalogVideo_PAL_B, _T("Germany")},
+ {51, AnalogVideo_NTSC_M, _T("Peru")},
+ {52, AnalogVideo_NTSC_M, _T("Mexico")},
+ {53, AnalogVideo_NTSC_M, _T("Cuba")},
+ {53, AnalogVideo_NTSC_M, _T("Guantanamo Bay")},
+ {54, AnalogVideo_PAL_N, _T("Argentina")},
+ {55, AnalogVideo_PAL_M, _T("Brazil")},
+ {56, AnalogVideo_NTSC_M, _T("Chile")},
+ {57, AnalogVideo_NTSC_M, _T("Colombia")},
+ {58, AnalogVideo_NTSC_M, _T("Bolivarian Republic of Venezuela")},
+ {60, AnalogVideo_PAL_B, _T("Malaysia")},
+ {61, AnalogVideo_PAL_B, _T("Australia")},
+ // {61, AnalogVideo_NTSC_M, _T("Cocos-Keeling Islands")},
+ {62, AnalogVideo_PAL_B, _T("Indonesia")},
+ {63, AnalogVideo_NTSC_M, _T("Philippines")},
+ {64, AnalogVideo_PAL_B, _T("New Zealand")},
+ {65, AnalogVideo_PAL_B, _T("Singapore")},
+ {66, AnalogVideo_PAL_B, _T("Thailand")},
+ {81, AnalogVideo_NTSC_M_J, _T("Japan")},
+ {82, AnalogVideo_NTSC_M, _T("Korea (South)")},
+ {84, AnalogVideo_NTSC_M, _T("Vietnam")},
+ {86, AnalogVideo_PAL_D, _T("China")},
+ {90, AnalogVideo_PAL_B, _T("Turkey")},
+ {91, AnalogVideo_PAL_B, _T("India")},
+ {92, AnalogVideo_PAL_B, _T("Pakistan")},
+ {93, AnalogVideo_PAL_B, _T("Afghanistan")},
+ {94, AnalogVideo_PAL_B, _T("Sri Lanka")},
+ {95, AnalogVideo_NTSC_M, _T("Myanmar")},
+ {98, AnalogVideo_SECAM_B, _T("Iran")},
+ {212, AnalogVideo_SECAM_B, _T("Morocco")},
+ {213, AnalogVideo_PAL_B, _T("Algeria")},
+ {216, AnalogVideo_SECAM_B, _T("Tunisia")},
+ {218, AnalogVideo_SECAM_B, _T("Libya")},
+ {220, AnalogVideo_SECAM_K, _T("Gambia")},
+ {221, AnalogVideo_SECAM_K, _T("Senegal Republic")},
+ {222, AnalogVideo_SECAM_B, _T("Mauritania")},
+ {223, AnalogVideo_SECAM_K, _T("Mali")},
+ {224, AnalogVideo_SECAM_K, _T("Guinea")},
+ {225, AnalogVideo_SECAM_K, _T("Cote D'Ivoire")},
+ {226, AnalogVideo_SECAM_K, _T("Burkina Faso")},
+ {227, AnalogVideo_SECAM_K, _T("Niger")},
+ {228, AnalogVideo_SECAM_K, _T("Togo")},
+ {229, AnalogVideo_SECAM_K, _T("Benin")},
+ {230, AnalogVideo_SECAM_B, _T("Mauritius")},
+ {231, AnalogVideo_PAL_B, _T("Liberia")},
+ {232, AnalogVideo_PAL_B, _T("Sierra Leone")},
+ {233, AnalogVideo_PAL_B, _T("Ghana")},
+ {234, AnalogVideo_PAL_B, _T("Nigeria")},
+ {235, AnalogVideo_PAL_B, _T("Chad")},
+ {236, AnalogVideo_PAL_B, _T("Central African Republic")},
+ {237, AnalogVideo_PAL_B, _T("Cameroon")},
+ {238, AnalogVideo_NTSC_M, _T("Cape Verde Islands")},
+ {239, AnalogVideo_PAL_B, _T("Sao Tome and Principe")},
+ {240, AnalogVideo_SECAM_B, _T("Equatorial Guinea")},
+ {241, AnalogVideo_SECAM_K, _T("Gabon")},
+ {242, AnalogVideo_SECAM_D, _T("Congo")},
+ {243, AnalogVideo_SECAM_K, _T("Congo(DRC)")},
+ {244, AnalogVideo_PAL_I, _T("Angola")},
+ {245, AnalogVideo_NTSC_M, _T("Guinea-Bissau")},
+ {246, AnalogVideo_NTSC_M, _T("Diego Garcia")},
+ {247, AnalogVideo_NTSC_M, _T("Ascension Island")},
+ {248, AnalogVideo_PAL_B, _T("Seychelles Islands")},
+ {249, AnalogVideo_PAL_B, _T("Sudan")},
+ {250, AnalogVideo_PAL_B, _T("Rwanda")},
+ {251, AnalogVideo_PAL_B, _T("Ethiopia")},
+ {252, AnalogVideo_PAL_B, _T("Somalia")},
+ {253, AnalogVideo_SECAM_K, _T("Djibouti")},
+ {254, AnalogVideo_PAL_B, _T("Kenya")},
+ {255, AnalogVideo_PAL_B, _T("Tanzania")},
+ {256, AnalogVideo_PAL_B, _T("Uganda")},
+ {257, AnalogVideo_SECAM_K, _T("Burundi")},
+ {258, AnalogVideo_PAL_B, _T("Mozambique")},
+ {260, AnalogVideo_PAL_B, _T("Zambia")},
+ {261, AnalogVideo_SECAM_K, _T("Madagascar")},
+ {262, AnalogVideo_SECAM_K, _T("Reunion Island")},
+ {263, AnalogVideo_PAL_B, _T("Zimbabwe")},
+ {264, AnalogVideo_PAL_I, _T("Namibia")},
+ {265, AnalogVideo_NTSC_M, _T("Malawi")},
+ {266, AnalogVideo_PAL_I, _T("Lesotho")},
+ {267, AnalogVideo_SECAM_K, _T("Botswana")},
+ {268, AnalogVideo_PAL_B, _T("Swaziland")},
+ {269, AnalogVideo_SECAM_K, _T("Mayotte Island")},
+ // {269, AnalogVideo_NTSC_M, _T("Comoros")},
+ {290, AnalogVideo_NTSC_M, _T("St. Helena")},
+ {291, AnalogVideo_NTSC_M, _T("Eritrea")},
+ {297, AnalogVideo_NTSC_M, _T("Aruba")},
+ {298, AnalogVideo_PAL_B, _T("Faroe Islands")},
+ {299, AnalogVideo_NTSC_M, _T("Greenland")},
+ {350, AnalogVideo_PAL_B, _T("Gibraltar")},
+ {351, AnalogVideo_PAL_B, _T("Portugal")},
+ {352, AnalogVideo_PAL_B, _T("Luxembourg")},
+ {353, AnalogVideo_PAL_I, _T("Ireland")},
+ {354, AnalogVideo_PAL_B, _T("Iceland")},
+ {355, AnalogVideo_PAL_B, _T("Albania")},
+ {356, AnalogVideo_PAL_B, _T("Malta")},
+ {357, AnalogVideo_PAL_B, _T("Cyprus")},
+ {358, AnalogVideo_PAL_B, _T("Finland")},
+ {359, AnalogVideo_SECAM_D, _T("Bulgaria")},
+ {370, AnalogVideo_PAL_B, _T("Lithuania")},
+ {371, AnalogVideo_SECAM_D, _T("Latvia")},
+ {372, AnalogVideo_PAL_B, _T("Estonia")},
+ {373, AnalogVideo_SECAM_D, _T("Moldova")},
+ {374, AnalogVideo_SECAM_D, _T("Armenia")},
+ {375, AnalogVideo_SECAM_D, _T("Belarus")},
+ {376, AnalogVideo_NTSC_M, _T("Andorra")},
+ {377, AnalogVideo_SECAM_G, _T("Monaco")},
+ {378, AnalogVideo_PAL_B, _T("San Marino")},
+ {380, AnalogVideo_SECAM_D, _T("Ukraine")},
+ {381, AnalogVideo_PAL_B, _T("Serbia and Montenegro")},
+ {385, AnalogVideo_PAL_B, _T("Croatia")},
+ {386, AnalogVideo_PAL_B, _T("Slovenia")},
+ {387, AnalogVideo_PAL_B, _T("Bosnia and Herzegovina")},
+ {389, AnalogVideo_PAL_B, _T("F.Y.R.O.M. (Former Yugoslav Republic of Macedonia)")},
+ {420, AnalogVideo_PAL_D, _T("Czech Republic")},
+ {421, AnalogVideo_PAL_B, _T("Slovak Republic")},
+ {500, AnalogVideo_PAL_I, _T("Falkland Islands (Islas Malvinas)")},
+ {501, AnalogVideo_NTSC_M, _T("Belize")},
+ {502, AnalogVideo_NTSC_M, _T("Guatemala")},
+ {503, AnalogVideo_NTSC_M, _T("El Salvador")},
+ {504, AnalogVideo_NTSC_M, _T("Honduras")},
+ {505, AnalogVideo_NTSC_M, _T("Nicaragua")},
+ {506, AnalogVideo_NTSC_M, _T("Costa Rica")},
+ {507, AnalogVideo_NTSC_M, _T("Panama")},
+ {508, AnalogVideo_SECAM_K, _T("St. Pierre and Miquelon")},
+ {509, AnalogVideo_NTSC_M, _T("Haiti")},
+ {590, AnalogVideo_SECAM_K, _T("Guadeloupe")},
+ // {590, AnalogVideo_NTSC_M, _T("French Antilles")},
+ {591, AnalogVideo_PAL_N, _T("Bolivia")},
+ {592, AnalogVideo_SECAM_K, _T("Guyana")},
+ {593, AnalogVideo_NTSC_M, _T("Ecuador")},
+ {594, AnalogVideo_SECAM_K, _T("French Guiana")},
+ {595, AnalogVideo_PAL_N, _T("Paraguay")},
+ {596, AnalogVideo_SECAM_K, _T("Martinique")},
+ {597, AnalogVideo_NTSC_M, _T("Suriname")},
+ {598, AnalogVideo_PAL_N, _T("Uruguay")},
+ {599, AnalogVideo_NTSC_M, _T("Netherlands Antilles")},
+ {670, AnalogVideo_NTSC_M, _T("Saipan Island")},
+ // {670, AnalogVideo_NTSC_M, _T("Rota Island")},
+ // {670, AnalogVideo_NTSC_M, _T("Tinian Island")},
+ {671, AnalogVideo_NTSC_M, _T("Guam")},
+ {672, AnalogVideo_NTSC_M, _T("Christmas Island")},
+ {672, AnalogVideo_NTSC_M, _T("Australian Antarctic Territory")},
+ // {672, AnalogVideo_PAL_B, _T("Norfolk Island")},
+ {673, AnalogVideo_PAL_B, _T("Brunei")},
+ {674, AnalogVideo_NTSC_M, _T("Nauru")},
+ {675, AnalogVideo_PAL_B, _T("Papua New Guinea")},
+ {676, AnalogVideo_NTSC_M, _T("Tonga")},
+ {677, AnalogVideo_NTSC_M, _T("Solomon Islands")},
+ {678, AnalogVideo_NTSC_M, _T("Vanuatu")},
+ {679, AnalogVideo_NTSC_M, _T("Fiji Islands")},
+ {680, AnalogVideo_NTSC_M, _T("Palau")},
+ {681, AnalogVideo_SECAM_K, _T("Wallis and Futuna Islands")},
+ {682, AnalogVideo_PAL_B, _T("Cook Islands")},
+ {683, AnalogVideo_NTSC_M, _T("Niue")},
+ {684, AnalogVideo_NTSC_M, _T("Territory of American Samoa")},
+ {685, AnalogVideo_PAL_B, _T("Samoa")},
+ {686, AnalogVideo_PAL_B, _T("Kiribati Republic")},
+ {687, AnalogVideo_SECAM_K, _T("New Caledonia")},
+ {688, AnalogVideo_NTSC_M, _T("Tuvalu")},
+ {689, AnalogVideo_SECAM_K, _T("French Polynesia")},
+ {690, AnalogVideo_NTSC_M, _T("Tokelau")},
+ {691, AnalogVideo_NTSC_M, _T("Micronesia")},
+ {692, AnalogVideo_NTSC_M, _T("Marshall Islands")},
+ {850, AnalogVideo_SECAM_D, _T("Korea (North)")},
+ {852, AnalogVideo_PAL_I, _T("Hong Kong SAR")},
+ {853, AnalogVideo_PAL_I, _T("Macao SAR")},
+ {855, AnalogVideo_PAL_B, _T("Cambodia")},
+ {856, AnalogVideo_PAL_B, _T("Laos")},
+ {871, AnalogVideo_NTSC_M, _T("INMARSAT (Atlantic-East)")},
+ {872, AnalogVideo_NTSC_M, _T("INMARSAT (Pacific)")},
+ {873, AnalogVideo_NTSC_M, _T("INMARSAT (Indian)")},
+ {874, AnalogVideo_NTSC_M, _T("INMARSAT (Atlantic-West)")},
+ {880, AnalogVideo_PAL_B, _T("Bangladesh")},
+ {886, AnalogVideo_NTSC_M, _T("Taiwan")},
+ {960, AnalogVideo_PAL_B, _T("Maldives")},
+ {961, AnalogVideo_SECAM_B, _T("Lebanon")},
+ {962, AnalogVideo_PAL_B, _T("Jordan")},
+ {963, AnalogVideo_SECAM_B, _T("Syria")},
+ {964, AnalogVideo_SECAM_B, _T("Iraq")},
+ {965, AnalogVideo_PAL_B, _T("Kuwait")},
+ {966, AnalogVideo_SECAM_B, _T("Saudi Arabia")},
+ {967, AnalogVideo_PAL_B, _T("Yemen")},
+ {968, AnalogVideo_PAL_B, _T("Oman")},
+ {971, AnalogVideo_PAL_B, _T("United Arab Emirates")},
+ {972, AnalogVideo_PAL_B, _T("Israel")},
+ {973, AnalogVideo_PAL_B, _T("Bahrain")},
+ {974, AnalogVideo_PAL_B, _T("Qatar")},
+ {975, AnalogVideo_NTSC_M, _T("Bhutan")},
+ {976, AnalogVideo_SECAM_D, _T("Mongolia")},
+ {977, AnalogVideo_PAL_B, _T("Nepal")},
+ {994, AnalogVideo_SECAM_D, _T("Azerbaijan")},
+ {995, AnalogVideo_SECAM_D, _T("Georgia")},
};
@@ -291,8 +291,8 @@ static struct cc_t {
IMPLEMENT_DYNAMIC(CPPageCapture, CPPageBase)
CPPageCapture::CPPageCapture()
- : CPPageBase(CPPageCapture::IDD, CPPageCapture::IDD)
- , m_iDefaultDevice(0)
+ : CPPageBase(CPPageCapture::IDD, CPPageCapture::IDD)
+ , m_iDefaultDevice(0)
{
}
@@ -303,14 +303,14 @@ CPPageCapture::~CPPageCapture()
void CPPageCapture::DoDataExchange(CDataExchange* pDX)
{
- CPPageBase::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_COMBO1, m_cbAnalogVideo);
- DDX_Control(pDX, IDC_COMBO2, m_cbAnalogAudio);
- DDX_Control(pDX, IDC_COMBO9, m_cbAnalogCountry);
- DDX_Control(pDX, IDC_COMBO4, m_cbDigitalNetworkProvider);
- DDX_Control(pDX, IDC_COMBO5, m_cbDigitalTuner);
- DDX_Control(pDX, IDC_COMBO3, m_cbDigitalReceiver);
- DDX_Radio(pDX, IDC_RADIO1, m_iDefaultDevice);
+ CPPageBase::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_COMBO1, m_cbAnalogVideo);
+ DDX_Control(pDX, IDC_COMBO2, m_cbAnalogAudio);
+ DDX_Control(pDX, IDC_COMBO9, m_cbAnalogCountry);
+ DDX_Control(pDX, IDC_COMBO4, m_cbDigitalNetworkProvider);
+ DDX_Control(pDX, IDC_COMBO5, m_cbDigitalTuner);
+ DDX_Control(pDX, IDC_COMBO3, m_cbDigitalReceiver);
+ DDX_Radio(pDX, IDC_RADIO1, m_iDefaultDevice);
}
@@ -322,267 +322,267 @@ END_MESSAGE_MAP()
BOOL CPPageCapture::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- SetHandCursor(m_hWnd, IDC_COMBO1);
+ SetHandCursor(m_hWnd, IDC_COMBO1);
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- FindAnalogDevices();
- FindDigitalDevices();
+ FindAnalogDevices();
+ FindDigitalDevices();
- m_iDefaultDevice = s.iDefaultCaptureDevice;
+ m_iDefaultDevice = s.iDefaultCaptureDevice;
- UpdateData(FALSE);
+ UpdateData(FALSE);
- return TRUE;
+ return TRUE;
}
void CPPageCapture::FindAnalogDevices()
{
- AppSettings& s = AfxGetAppSettings();
- int iSel = 0;
-
- // List video devised
- BeginEnumSysDev(CLSID_VideoInputDeviceCategory, pMoniker) {
- CComPtr<IPropertyBag> pPB;
- pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
-
- CComVariant var;
- pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
- int i = m_cbAnalogVideo.AddString(CString(var.bstrVal));
-
- LPOLESTR strName = NULL;
- if (SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName))) {
- m_vidnames.Add(CString(strName));
- if (s.strAnalogVideo == CString(strName)) {
- iSel = i;
- }
- CoTaskMemFree(strName);
- }
- }
- EndEnumSysDev
-
- {
- int i = m_cbAnalogAudio.AddString(_T("<Video Capture Device>"));
- m_audnames.Add(_T(""));
- if (s.strAnalogAudio.IsEmpty()) {
- iSel = i;
- }
- }
-
- if (m_cbAnalogVideo.GetCount()) {
- m_cbAnalogVideo.SetCurSel(iSel);
- }
-
- // List audio devised
- iSel = 0;
- BeginEnumSysDev(CLSID_AudioInputDeviceCategory, pMoniker) {
- CComPtr<IPropertyBag> pPB;
- pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
-
- CComVariant var;
- pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
- int i = m_cbAnalogAudio.AddString(CString(var.bstrVal));
-
- LPOLESTR strName = NULL;
- if (SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName))) {
- m_audnames.Add(CString(strName));
- if (s.strAnalogAudio == CString(strName)) {
- iSel = i;
- }
- CoTaskMemFree(strName);
- }
- }
- EndEnumSysDev
- if (m_cbAnalogAudio.GetCount()) {
- m_cbAnalogAudio.SetCurSel(iSel);
- }
-
- // Fill country
- iSel = 0;
- for (int j = 0; j < _countof(s_countrycodes); j++) {
- CString standard;
- switch (s_countrycodes[j].standard) {
- case AnalogVideo_NTSC_M:
- standard = _T("NTSC M");
- break;
- case AnalogVideo_NTSC_M_J:
- standard = _T("NTSC M J");
- break;
- case AnalogVideo_NTSC_433:
- standard = _T("NTSC 433");
- break;
- case AnalogVideo_PAL_B:
- standard = _T("PAL B");
- break;
- case AnalogVideo_PAL_D:
- standard = _T("PAL D");
- break;
- case AnalogVideo_PAL_G:
- standard = _T("PAL G");
- break;
- case AnalogVideo_PAL_H:
- standard = _T("PAL H");
- break;
- case AnalogVideo_PAL_I:
- standard = _T("PAL I");
- break;
- case AnalogVideo_PAL_M:
- standard = _T("PAL M");
- break;
- case AnalogVideo_PAL_N:
- standard = _T("PAL N");
- break;
- case AnalogVideo_PAL_60:
- standard = _T("PAL 60");
- break;
- case AnalogVideo_SECAM_B:
- standard = _T("SECAM B");
- break;
- case AnalogVideo_SECAM_D:
- standard = _T("SECAM D");
- break;
- case AnalogVideo_SECAM_G:
- standard = _T("SECAM G");
- break;
- case AnalogVideo_SECAM_H:
- standard = _T("SECAM H");
- break;
- case AnalogVideo_SECAM_K:
- standard = _T("SECAM K");
- break;
- case AnalogVideo_SECAM_K1:
- standard = _T("SECAM K1");
- break;
- case AnalogVideo_SECAM_L:
- standard = _T("SECAM L");
- break;
- case AnalogVideo_SECAM_L1:
- standard = _T("SECAM L1");
- break;
- case AnalogVideo_PAL_N_COMBO:
- standard = _T("PAL N COMBO");
- break;
- }
-
- CString str;
- str.Format(_T("%d - %s - %s"), s_countrycodes[j].code, s_countrycodes[j].str, standard);
-
- int i = m_cbAnalogCountry.AddString(str);
- m_cbAnalogCountry.SetItemDataPtr(i, &s_countrycodes[j]);
- if (s.iAnalogCountry == s_countrycodes[j].code) {
- iSel = i;
- }
- }
-
- if (m_cbAnalogCountry.GetCount()) {
- m_cbAnalogCountry.SetCurSel(iSel);
- }
+ AppSettings& s = AfxGetAppSettings();
+ int iSel = 0;
+
+ // List video devised
+ BeginEnumSysDev(CLSID_VideoInputDeviceCategory, pMoniker) {
+ CComPtr<IPropertyBag> pPB;
+ pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
+
+ CComVariant var;
+ pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
+ int i = m_cbAnalogVideo.AddString(CString(var.bstrVal));
+
+ LPOLESTR strName = NULL;
+ if (SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName))) {
+ m_vidnames.Add(CString(strName));
+ if (s.strAnalogVideo == CString(strName)) {
+ iSel = i;
+ }
+ CoTaskMemFree(strName);
+ }
+ }
+ EndEnumSysDev
+
+ {
+ int i = m_cbAnalogAudio.AddString(_T("<Video Capture Device>"));
+ m_audnames.Add(_T(""));
+ if (s.strAnalogAudio.IsEmpty()) {
+ iSel = i;
+ }
+ }
+
+ if (m_cbAnalogVideo.GetCount()) {
+ m_cbAnalogVideo.SetCurSel(iSel);
+ }
+
+ // List audio devised
+ iSel = 0;
+ BeginEnumSysDev(CLSID_AudioInputDeviceCategory, pMoniker) {
+ CComPtr<IPropertyBag> pPB;
+ pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
+
+ CComVariant var;
+ pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
+ int i = m_cbAnalogAudio.AddString(CString(var.bstrVal));
+
+ LPOLESTR strName = NULL;
+ if (SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName))) {
+ m_audnames.Add(CString(strName));
+ if (s.strAnalogAudio == CString(strName)) {
+ iSel = i;
+ }
+ CoTaskMemFree(strName);
+ }
+ }
+ EndEnumSysDev
+ if (m_cbAnalogAudio.GetCount()) {
+ m_cbAnalogAudio.SetCurSel(iSel);
+ }
+
+ // Fill country
+ iSel = 0;
+ for (int j = 0; j < _countof(s_countrycodes); j++) {
+ CString standard;
+ switch (s_countrycodes[j].standard) {
+ case AnalogVideo_NTSC_M:
+ standard = _T("NTSC M");
+ break;
+ case AnalogVideo_NTSC_M_J:
+ standard = _T("NTSC M J");
+ break;
+ case AnalogVideo_NTSC_433:
+ standard = _T("NTSC 433");
+ break;
+ case AnalogVideo_PAL_B:
+ standard = _T("PAL B");
+ break;
+ case AnalogVideo_PAL_D:
+ standard = _T("PAL D");
+ break;
+ case AnalogVideo_PAL_G:
+ standard = _T("PAL G");
+ break;
+ case AnalogVideo_PAL_H:
+ standard = _T("PAL H");
+ break;
+ case AnalogVideo_PAL_I:
+ standard = _T("PAL I");
+ break;
+ case AnalogVideo_PAL_M:
+ standard = _T("PAL M");
+ break;
+ case AnalogVideo_PAL_N:
+ standard = _T("PAL N");
+ break;
+ case AnalogVideo_PAL_60:
+ standard = _T("PAL 60");
+ break;
+ case AnalogVideo_SECAM_B:
+ standard = _T("SECAM B");
+ break;
+ case AnalogVideo_SECAM_D:
+ standard = _T("SECAM D");
+ break;
+ case AnalogVideo_SECAM_G:
+ standard = _T("SECAM G");
+ break;
+ case AnalogVideo_SECAM_H:
+ standard = _T("SECAM H");
+ break;
+ case AnalogVideo_SECAM_K:
+ standard = _T("SECAM K");
+ break;
+ case AnalogVideo_SECAM_K1:
+ standard = _T("SECAM K1");
+ break;
+ case AnalogVideo_SECAM_L:
+ standard = _T("SECAM L");
+ break;
+ case AnalogVideo_SECAM_L1:
+ standard = _T("SECAM L1");
+ break;
+ case AnalogVideo_PAL_N_COMBO:
+ standard = _T("PAL N COMBO");
+ break;
+ }
+
+ CString str;
+ str.Format(_T("%d - %s - %s"), s_countrycodes[j].code, s_countrycodes[j].str, standard);
+
+ int i = m_cbAnalogCountry.AddString(str);
+ m_cbAnalogCountry.SetItemDataPtr(i, &s_countrycodes[j]);
+ if (s.iAnalogCountry == s_countrycodes[j].code) {
+ iSel = i;
+ }
+ }
+
+ if (m_cbAnalogCountry.GetCount()) {
+ m_cbAnalogCountry.SetCurSel(iSel);
+ }
}
void CPPageCapture::FindDigitalDevices()
{
- AppSettings& s = AfxGetAppSettings();
- int iSel = 0;
-
- BeginEnumSysDev(KSCATEGORY_BDA_NETWORK_PROVIDER, pMoniker) {
- CComPtr<IPropertyBag> pPB;
- pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
-
- CComVariant var;
- pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
- int i = m_cbDigitalNetworkProvider.AddString(CString(var.bstrVal));
-
- LPOLESTR strName = NULL;
- if (SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName))) {
- m_providernames.Add(CString(strName));
- if (s.strBDANetworkProvider == CString(strName)) {
- iSel = i;
- }
- CoTaskMemFree(strName);
- }
- }
- EndEnumSysDev
- if (m_cbDigitalNetworkProvider.GetCount()) {
- m_cbDigitalNetworkProvider.SetCurSel(iSel);
- }
-
-
- iSel = 0;
- BeginEnumSysDev(KSCATEGORY_BDA_NETWORK_TUNER, pMoniker) {
- CComPtr<IPropertyBag> pPB;
- pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
-
- CComVariant var;
- pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
- int i = m_cbDigitalTuner.AddString(CString(var.bstrVal));
-
- LPOLESTR strName = NULL;
- if (SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName))) {
- m_tunernames.Add(CString(strName));
- if (s.strBDATuner == CString(strName)) {
- iSel = i;
- }
- CoTaskMemFree(strName);
- }
- }
- EndEnumSysDev
- if (m_cbDigitalTuner.GetCount()) {
- m_cbDigitalTuner.SetCurSel(iSel);
- }
-
- iSel = 0;
- BeginEnumSysDev(KSCATEGORY_BDA_RECEIVER_COMPONENT, pMoniker) {
- CComPtr<IPropertyBag> pPB;
- pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
-
- CComVariant var;
- pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
- int i = m_cbDigitalReceiver.AddString(CString(var.bstrVal));
-
- LPOLESTR strName = NULL;
- if (SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName))) {
- m_receivernames.Add(CString(strName));
- if (s.strBDAReceiver == CString(strName)) {
- iSel = i;
- }
- CoTaskMemFree(strName);
- }
- }
- EndEnumSysDev
- if (m_cbDigitalReceiver.GetCount()) {
- m_cbDigitalReceiver.SetCurSel(iSel);
- }
+ AppSettings& s = AfxGetAppSettings();
+ int iSel = 0;
+
+ BeginEnumSysDev(KSCATEGORY_BDA_NETWORK_PROVIDER, pMoniker) {
+ CComPtr<IPropertyBag> pPB;
+ pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
+
+ CComVariant var;
+ pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
+ int i = m_cbDigitalNetworkProvider.AddString(CString(var.bstrVal));
+
+ LPOLESTR strName = NULL;
+ if (SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName))) {
+ m_providernames.Add(CString(strName));
+ if (s.strBDANetworkProvider == CString(strName)) {
+ iSel = i;
+ }
+ CoTaskMemFree(strName);
+ }
+ }
+ EndEnumSysDev
+ if (m_cbDigitalNetworkProvider.GetCount()) {
+ m_cbDigitalNetworkProvider.SetCurSel(iSel);
+ }
+
+
+ iSel = 0;
+ BeginEnumSysDev(KSCATEGORY_BDA_NETWORK_TUNER, pMoniker) {
+ CComPtr<IPropertyBag> pPB;
+ pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
+
+ CComVariant var;
+ pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
+ int i = m_cbDigitalTuner.AddString(CString(var.bstrVal));
+
+ LPOLESTR strName = NULL;
+ if (SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName))) {
+ m_tunernames.Add(CString(strName));
+ if (s.strBDATuner == CString(strName)) {
+ iSel = i;
+ }
+ CoTaskMemFree(strName);
+ }
+ }
+ EndEnumSysDev
+ if (m_cbDigitalTuner.GetCount()) {
+ m_cbDigitalTuner.SetCurSel(iSel);
+ }
+
+ iSel = 0;
+ BeginEnumSysDev(KSCATEGORY_BDA_RECEIVER_COMPONENT, pMoniker) {
+ CComPtr<IPropertyBag> pPB;
+ pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
+
+ CComVariant var;
+ pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
+ int i = m_cbDigitalReceiver.AddString(CString(var.bstrVal));
+
+ LPOLESTR strName = NULL;
+ if (SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName))) {
+ m_receivernames.Add(CString(strName));
+ if (s.strBDAReceiver == CString(strName)) {
+ iSel = i;
+ }
+ CoTaskMemFree(strName);
+ }
+ }
+ EndEnumSysDev
+ if (m_cbDigitalReceiver.GetCount()) {
+ m_cbDigitalReceiver.SetCurSel(iSel);
+ }
}
BOOL CPPageCapture::OnApply()
{
- UpdateData();
-
- AppSettings& s = AfxGetAppSettings();
-
- s.iDefaultCaptureDevice = m_iDefaultDevice;
-
- if (m_cbAnalogVideo.GetCurSel()>=0) {
- s.strAnalogVideo = m_vidnames[m_cbAnalogVideo.GetCurSel()];
- }
- if (m_cbAnalogAudio.GetCurSel()>=0) {
- s.strAnalogAudio = m_audnames[m_cbAnalogAudio.GetCurSel()];
- }
- if (m_cbAnalogCountry.GetCurSel()>=0) {
- s.iAnalogCountry = ((cc_t*)m_cbAnalogCountry.GetItemDataPtr(m_cbAnalogCountry.GetCurSel()))->code;
- }
-
- if (m_cbDigitalNetworkProvider.GetCurSel()>=0) {
- s.strBDANetworkProvider = m_providernames[m_cbDigitalNetworkProvider.GetCurSel()];
- }
- if (m_cbDigitalTuner.GetCurSel()>=0) {
- s.strBDATuner = m_tunernames[m_cbDigitalTuner.GetCurSel()];
- }
- if (m_cbDigitalReceiver.GetCurSel()>=0) {
- s.strBDAReceiver = m_receivernames[m_cbDigitalReceiver.GetCurSel()];
- }
-
- return __super::OnApply();
+ UpdateData();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ s.iDefaultCaptureDevice = m_iDefaultDevice;
+
+ if (m_cbAnalogVideo.GetCurSel() >= 0) {
+ s.strAnalogVideo = m_vidnames[m_cbAnalogVideo.GetCurSel()];
+ }
+ if (m_cbAnalogAudio.GetCurSel() >= 0) {
+ s.strAnalogAudio = m_audnames[m_cbAnalogAudio.GetCurSel()];
+ }
+ if (m_cbAnalogCountry.GetCurSel() >= 0) {
+ s.iAnalogCountry = ((cc_t*)m_cbAnalogCountry.GetItemDataPtr(m_cbAnalogCountry.GetCurSel()))->code;
+ }
+
+ if (m_cbDigitalNetworkProvider.GetCurSel() >= 0) {
+ s.strBDANetworkProvider = m_providernames[m_cbDigitalNetworkProvider.GetCurSel()];
+ }
+ if (m_cbDigitalTuner.GetCurSel() >= 0) {
+ s.strBDATuner = m_tunernames[m_cbDigitalTuner.GetCurSel()];
+ }
+ if (m_cbDigitalReceiver.GetCurSel() >= 0) {
+ s.strBDAReceiver = m_receivernames[m_cbDigitalReceiver.GetCurSel()];
+ }
+
+ return __super::OnApply();
}
diff --git a/src/mpc-hc/PPageCapture.h b/src/mpc-hc/PPageCapture.h
index 6dd23e2d6..7d6b797d1 100644
--- a/src/mpc-hc/PPageCapture.h
+++ b/src/mpc-hc/PPageCapture.h
@@ -30,32 +30,32 @@
class CPPageCapture : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageCapture)
+ DECLARE_DYNAMIC(CPPageCapture)
- CAtlArray<CString> m_vidnames, m_audnames, m_providernames, m_tunernames, m_receivernames;
+ CAtlArray<CString> m_vidnames, m_audnames, m_providernames, m_tunernames, m_receivernames;
public:
- CPPageCapture(); // standard constructor
- virtual ~CPPageCapture();
+ CPPageCapture(); // standard constructor
+ virtual ~CPPageCapture();
- // Dialog Data
- enum { IDD = IDD_PPAGECAPTURE };
+ // Dialog Data
+ enum { IDD = IDD_PPAGECAPTURE };
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
- void FindAnalogDevices();
- void FindDigitalDevices();
+ void FindAnalogDevices();
+ void FindDigitalDevices();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- CComboBox m_cbAnalogVideo;
- CComboBox m_cbAnalogAudio;
- CComboBox m_cbAnalogCountry;
- CComboBox m_cbDigitalNetworkProvider;
- CComboBox m_cbDigitalTuner;
- CComboBox m_cbDigitalReceiver;
- int m_iDefaultDevice;
+ CComboBox m_cbAnalogVideo;
+ CComboBox m_cbAnalogAudio;
+ CComboBox m_cbAnalogCountry;
+ CComboBox m_cbDigitalNetworkProvider;
+ CComboBox m_cbDigitalTuner;
+ CComboBox m_cbDigitalReceiver;
+ int m_iDefaultDevice;
};
diff --git a/src/mpc-hc/PPageDVD.cpp b/src/mpc-hc/PPageDVD.cpp
index c00d83955..e2e5e4568 100644
--- a/src/mpc-hc/PPageDVD.cpp
+++ b/src/mpc-hc/PPageDVD.cpp
@@ -29,150 +29,150 @@
struct {
- LCID lcid;
- LPCSTR name;
+ LCID lcid;
+ LPCSTR name;
}
LCIDNameList[] = {
- {0x0000, "Default"},
- {0x0436, "Afrikaans"},
- {0x041c, "Albanian"},
- {0x0401, "Arabic (Saudi Arabia)"},
- {0x0801, "Arabic (Iraq)"},
- {0x0c01, "Arabic (Egypt)"},
- {0x1001, "Arabic (Libya)"},
- {0x1401, "Arabic (Algeria)"},
- {0x1801, "Arabic (Morocco)"},
- {0x1c01, "Arabic (Tunisia)"},
- {0x2001, "Arabic (Oman)"},
- {0x2401, "Arabic (Yemen)"},
- {0x2801, "Arabic (Syria)"},
- {0x2c01, "Arabic (Jordan)"},
- {0x3001, "Arabic (Lebanon)"},
- {0x3401, "Arabic (Kuwait)"},
- {0x3801, "Arabic (U.A.E.)"},
- {0x3c01, "Arabic (Bahrain)"},
- {0x4001, "Arabic (Qatar)"},
- {0x042b, "Armenian"},
- {0x042c, "Azeri (Latin)"},
- {0x082c, "Azeri (Cyrillic)"},
- {0x042d, "Basque"},
- {0x0423, "Belarusian"},
- {0x0402, "Bulgarian"},
- {0x0455, "Burmese"},
- {0x0403, "Catalan"},
- {0x0404, "Chinese (Taiwan)"},
- {0x0804, "Chinese (PRC)"},
- {0x0c04, "Chinese (Hong Kong SAR, PRC)"},
- {0x1004, "Chinese (Singapore)"},
- {0x1404, "Chinese (Macau SAR)"},
- {0x041a, "Croatian"},
- {0x0405, "Czech"},
- {0x0406, "Danish"},
- {0x0465, "Divehi"},
- {0x0413, "Dutch (Netherlands)"},
- {0x0813, "Dutch (Belgium)"},
- {0x0409, "English (United States)"},
- {0x0809, "English (United Kingdom)"},
- {0x0c09, "English (Australian)"},
- {0x1009, "English (Canadian)"},
- {0x1409, "English (New Zealand)"},
- {0x1809, "English (Ireland)"},
- {0x1c09, "English (South Africa)"},
- {0x2009, "English (Jamaica)"},
- {0x2409, "English (Caribbean)"},
- {0x2809, "English (Belize)"},
- {0x2c09, "English (Trinidad)"},
- {0x3009, "English (Zimbabwe)"},
- {0x3409, "English (Philippines)"},
- {0x0425, "Estonian"},
- {0x0438, "Faeroese"},
- {0x0429, "Farsi"},
- {0x040b, "Finnish"},
- {0x040c, "French (Standard)"},
- {0x080c, "French (Belgian)"},
- {0x0c0c, "French (Canadian)"},
- {0x100c, "French (Switzerland)"},
- {0x140c, "French (Luxembourg)"},
- {0x180c, "French (Monaco)"},
- {0x0456, "Galician"},
- {0x0437, "Georgian"},
- {0x0407, "German (Standard)"},
- {0x0807, "German (Switzerland)"},
- {0x0c07, "German (Austria)"},
- {0x1007, "German (Luxembourg)"},
- {0x1407, "German (Liechtenstein)"},
- {0x0408, "Greek"},
- {0x0447, "Gujarati"},
- {0x040d, "Hebrew"},
- {0x0439, "Hindi"},
- {0x040e, "Hungarian"},
- {0x040f, "Icelandic"},
- {0x0421, "Indonesian"},
- {0x0410, "Italian (Standard)"},
- {0x0810, "Italian (Switzerland)"},
- {0x0411, "Japanese"},
- {0x044b, "Kannada"},
- {0x0457, "Konkani"},
- {0x0412, "Korean"},
- {0x0812, "Korean (Johab)"},
- {0x0440, "Kyrgyz"},
- {0x0426, "Latvian"},
- {0x0427, "Lithuanian"},
- {0x0827, "Lithuanian (Classic)"},
- {0x042f, "FYRO Macedonian"},
- {0x043e, "Malay (Malaysian)"},
- {0x083e, "Malay (Brunei Darussalam)"},
- {0x044e, "Marathi"},
- {0x0450, "Mongolian"},
- {0x0414, "Norwegian (Bokmal)"},
- {0x0814, "Norwegian (Nynorsk)"},
- {0x0415, "Polish"},
- {0x0416, "Portuguese (Brazil)"},
- {0x0816, "Portuguese (Portugal)"},
- {0x0446, "Punjabi"},
- {0x0418, "Romanian"},
- {0x0419, "Russian"},
- {0x044f, "Sanskrit"},
- {0x0c1a, "Serbian (Cyrillic)"},
- {0x081a, "Serbian (Latin)"},
- {0x041b, "Slovak"},
- {0x0424, "Slovenian"},
- {0x040a, "Spanish (Spain, Traditional Sort)"},
- {0x080a, "Spanish (Mexican)"},
- {0x0c0a, "Spanish (Spain, International Sort)"},
- {0x100a, "Spanish (Guatemala)"},
- {0x140a, "Spanish (Costa Rica)"},
- {0x180a, "Spanish (Panama)"},
- {0x1c0a, "Spanish (Dominican Republic)"},
- {0x200a, "Spanish (Venezuela)"},
- {0x240a, "Spanish (Colombia)"},
- {0x280a, "Spanish (Peru)"},
- {0x2c0a, "Spanish (Argentina)"},
- {0x300a, "Spanish (Ecuador)"},
- {0x340a, "Spanish (Chile)"},
- {0x380a, "Spanish (Uruguay)"},
- {0x3c0a, "Spanish (Paraguay)"},
- {0x400a, "Spanish (Bolivia)"},
- {0x440a, "Spanish (El Salvador)"},
- {0x480a, "Spanish (Honduras)"},
- {0x4c0a, "Spanish (Nicaragua)"},
- {0x500a, "Spanish (Puerto Rico)"},
- {0x0430, "Sutu"},
- {0x0441, "Swahili (Kenya)"},
- {0x041d, "Swedish"},
- {0x081d, "Swedish (Finland)"},
- {0x045a, "Syriac"},
- {0x0449, "Tamil"},
- {0x0444, "Tatar (Tatarstan)"},
- {0x044a, "Telugu"},
- {0x041e, "Thai"},
- {0x041f, "Turkish"},
- {0x0422, "Ukrainian"},
- {0x0420, "Urdu (Pakistan)"},
- {0x0820, "Urdu (India)"},
- {0x0443, "Uzbek (Latin)"},
- {0x0843, "Uzbek (Cyrillic)"},
- {0x042a, "Vietnamese"}
+ {0x0000, "Default"},
+ {0x0436, "Afrikaans"},
+ {0x041c, "Albanian"},
+ {0x0401, "Arabic (Saudi Arabia)"},
+ {0x0801, "Arabic (Iraq)"},
+ {0x0c01, "Arabic (Egypt)"},
+ {0x1001, "Arabic (Libya)"},
+ {0x1401, "Arabic (Algeria)"},
+ {0x1801, "Arabic (Morocco)"},
+ {0x1c01, "Arabic (Tunisia)"},
+ {0x2001, "Arabic (Oman)"},
+ {0x2401, "Arabic (Yemen)"},
+ {0x2801, "Arabic (Syria)"},
+ {0x2c01, "Arabic (Jordan)"},
+ {0x3001, "Arabic (Lebanon)"},
+ {0x3401, "Arabic (Kuwait)"},
+ {0x3801, "Arabic (U.A.E.)"},
+ {0x3c01, "Arabic (Bahrain)"},
+ {0x4001, "Arabic (Qatar)"},
+ {0x042b, "Armenian"},
+ {0x042c, "Azeri (Latin)"},
+ {0x082c, "Azeri (Cyrillic)"},
+ {0x042d, "Basque"},
+ {0x0423, "Belarusian"},
+ {0x0402, "Bulgarian"},
+ {0x0455, "Burmese"},
+ {0x0403, "Catalan"},
+ {0x0404, "Chinese (Taiwan)"},
+ {0x0804, "Chinese (PRC)"},
+ {0x0c04, "Chinese (Hong Kong SAR, PRC)"},
+ {0x1004, "Chinese (Singapore)"},
+ {0x1404, "Chinese (Macau SAR)"},
+ {0x041a, "Croatian"},
+ {0x0405, "Czech"},
+ {0x0406, "Danish"},
+ {0x0465, "Divehi"},
+ {0x0413, "Dutch (Netherlands)"},
+ {0x0813, "Dutch (Belgium)"},
+ {0x0409, "English (United States)"},
+ {0x0809, "English (United Kingdom)"},
+ {0x0c09, "English (Australian)"},
+ {0x1009, "English (Canadian)"},
+ {0x1409, "English (New Zealand)"},
+ {0x1809, "English (Ireland)"},
+ {0x1c09, "English (South Africa)"},
+ {0x2009, "English (Jamaica)"},
+ {0x2409, "English (Caribbean)"},
+ {0x2809, "English (Belize)"},
+ {0x2c09, "English (Trinidad)"},
+ {0x3009, "English (Zimbabwe)"},
+ {0x3409, "English (Philippines)"},
+ {0x0425, "Estonian"},
+ {0x0438, "Faeroese"},
+ {0x0429, "Farsi"},
+ {0x040b, "Finnish"},
+ {0x040c, "French (Standard)"},
+ {0x080c, "French (Belgian)"},
+ {0x0c0c, "French (Canadian)"},
+ {0x100c, "French (Switzerland)"},
+ {0x140c, "French (Luxembourg)"},
+ {0x180c, "French (Monaco)"},
+ {0x0456, "Galician"},
+ {0x0437, "Georgian"},
+ {0x0407, "German (Standard)"},
+ {0x0807, "German (Switzerland)"},
+ {0x0c07, "German (Austria)"},
+ {0x1007, "German (Luxembourg)"},
+ {0x1407, "German (Liechtenstein)"},
+ {0x0408, "Greek"},
+ {0x0447, "Gujarati"},
+ {0x040d, "Hebrew"},
+ {0x0439, "Hindi"},
+ {0x040e, "Hungarian"},
+ {0x040f, "Icelandic"},
+ {0x0421, "Indonesian"},
+ {0x0410, "Italian (Standard)"},
+ {0x0810, "Italian (Switzerland)"},
+ {0x0411, "Japanese"},
+ {0x044b, "Kannada"},
+ {0x0457, "Konkani"},
+ {0x0412, "Korean"},
+ {0x0812, "Korean (Johab)"},
+ {0x0440, "Kyrgyz"},
+ {0x0426, "Latvian"},
+ {0x0427, "Lithuanian"},
+ {0x0827, "Lithuanian (Classic)"},
+ {0x042f, "FYRO Macedonian"},
+ {0x043e, "Malay (Malaysian)"},
+ {0x083e, "Malay (Brunei Darussalam)"},
+ {0x044e, "Marathi"},
+ {0x0450, "Mongolian"},
+ {0x0414, "Norwegian (Bokmal)"},
+ {0x0814, "Norwegian (Nynorsk)"},
+ {0x0415, "Polish"},
+ {0x0416, "Portuguese (Brazil)"},
+ {0x0816, "Portuguese (Portugal)"},
+ {0x0446, "Punjabi"},
+ {0x0418, "Romanian"},
+ {0x0419, "Russian"},
+ {0x044f, "Sanskrit"},
+ {0x0c1a, "Serbian (Cyrillic)"},
+ {0x081a, "Serbian (Latin)"},
+ {0x041b, "Slovak"},
+ {0x0424, "Slovenian"},
+ {0x040a, "Spanish (Spain, Traditional Sort)"},
+ {0x080a, "Spanish (Mexican)"},
+ {0x0c0a, "Spanish (Spain, International Sort)"},
+ {0x100a, "Spanish (Guatemala)"},
+ {0x140a, "Spanish (Costa Rica)"},
+ {0x180a, "Spanish (Panama)"},
+ {0x1c0a, "Spanish (Dominican Republic)"},
+ {0x200a, "Spanish (Venezuela)"},
+ {0x240a, "Spanish (Colombia)"},
+ {0x280a, "Spanish (Peru)"},
+ {0x2c0a, "Spanish (Argentina)"},
+ {0x300a, "Spanish (Ecuador)"},
+ {0x340a, "Spanish (Chile)"},
+ {0x380a, "Spanish (Uruguay)"},
+ {0x3c0a, "Spanish (Paraguay)"},
+ {0x400a, "Spanish (Bolivia)"},
+ {0x440a, "Spanish (El Salvador)"},
+ {0x480a, "Spanish (Honduras)"},
+ {0x4c0a, "Spanish (Nicaragua)"},
+ {0x500a, "Spanish (Puerto Rico)"},
+ {0x0430, "Sutu"},
+ {0x0441, "Swahili (Kenya)"},
+ {0x041d, "Swedish"},
+ {0x081d, "Swedish (Finland)"},
+ {0x045a, "Syriac"},
+ {0x0449, "Tamil"},
+ {0x0444, "Tatar (Tatarstan)"},
+ {0x044a, "Telugu"},
+ {0x041e, "Thai"},
+ {0x041f, "Turkish"},
+ {0x0422, "Ukrainian"},
+ {0x0420, "Urdu (Pakistan)"},
+ {0x0820, "Urdu (India)"},
+ {0x0443, "Uzbek (Latin)"},
+ {0x0843, "Uzbek (Cyrillic)"},
+ {0x042a, "Vietnamese"}
};
@@ -180,12 +180,12 @@ LCIDNameList[] = {
IMPLEMENT_DYNAMIC(CPPageDVD, CPPageBase)
CPPageDVD::CPPageDVD()
- : CPPageBase(CPPageDVD::IDD, CPPageDVD::IDD)
- , m_iDVDLocation(0)
- , m_iDVDLangType(0)
- , m_dvdpath(_T(""))
- , m_fAutoSpeakerConf(FALSE)
- , m_fClosedCaptions(FALSE)
+ : CPPageBase(CPPageDVD::IDD, CPPageDVD::IDD)
+ , m_iDVDLocation(0)
+ , m_iDVDLangType(0)
+ , m_dvdpath(_T(""))
+ , m_fAutoSpeakerConf(FALSE)
+ , m_fClosedCaptions(FALSE)
{
}
@@ -195,40 +195,40 @@ CPPageDVD::~CPPageDVD()
void CPPageDVD::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Radio(pDX, IDC_RADIO1, m_iDVDLocation);
- DDX_Radio(pDX, IDC_RADIO3, m_iDVDLangType);
- DDX_Control(pDX, IDC_LIST1, m_lcids);
- DDX_Text(pDX, IDC_DVDPATH, m_dvdpath);
- DDX_Control(pDX, IDC_DVDPATH, m_dvdpathctrl);
- DDX_Control(pDX, IDC_BUTTON1, m_dvdpathselctrl);
- DDX_Check(pDX, IDC_CHECK1, m_fAutoSpeakerConf);
- DDX_Check(pDX, IDC_CHECK2, m_fClosedCaptions);
+ __super::DoDataExchange(pDX);
+ DDX_Radio(pDX, IDC_RADIO1, m_iDVDLocation);
+ DDX_Radio(pDX, IDC_RADIO3, m_iDVDLangType);
+ DDX_Control(pDX, IDC_LIST1, m_lcids);
+ DDX_Text(pDX, IDC_DVDPATH, m_dvdpath);
+ DDX_Control(pDX, IDC_DVDPATH, m_dvdpathctrl);
+ DDX_Control(pDX, IDC_BUTTON1, m_dvdpathselctrl);
+ DDX_Check(pDX, IDC_CHECK1, m_fAutoSpeakerConf);
+ DDX_Check(pDX, IDC_CHECK2, m_fClosedCaptions);
}
void CPPageDVD::UpdateLCIDList()
{
- UpdateData();
-
- LCID lcid = m_iDVDLangType == 0 ? m_idMenuLang
- : m_iDVDLangType == 1 ? m_idAudioLang
- : m_idSubtitlesLang;
-
- for (int i = 0; i < m_lcids.GetCount(); i++) {
- if (m_lcids.GetItemData(i) == lcid) {
- m_lcids.SetCurSel(i);
- m_lcids.SetTopIndex(i);
- break;
- }
- }
+ UpdateData();
+
+ LCID lcid = m_iDVDLangType == 0 ? m_idMenuLang
+ : m_iDVDLangType == 1 ? m_idAudioLang
+ : m_idSubtitlesLang;
+
+ for (int i = 0; i < m_lcids.GetCount(); i++) {
+ if (m_lcids.GetItemData(i) == lcid) {
+ m_lcids.SetCurSel(i);
+ m_lcids.SetTopIndex(i);
+ break;
+ }
+ }
}
BEGIN_MESSAGE_MAP(CPPageDVD, CPPageBase)
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
- ON_CONTROL_RANGE(BN_CLICKED, IDC_RADIO3, IDC_RADIO5, OnBnClickedLangradio123)
- ON_LBN_SELCHANGE(IDC_LIST1, OnLbnSelchangeList1)
- ON_UPDATE_COMMAND_UI(IDC_DVDPATH, OnUpdateDVDPath)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateDVDPath)
+ ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
+ ON_CONTROL_RANGE(BN_CLICKED, IDC_RADIO3, IDC_RADIO5, OnBnClickedLangradio123)
+ ON_LBN_SELCHANGE(IDC_LIST1, OnLbnSelchangeList1)
+ ON_UPDATE_COMMAND_UI(IDC_DVDPATH, OnUpdateDVDPath)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateDVDPath)
END_MESSAGE_MAP()
@@ -236,120 +236,120 @@ END_MESSAGE_MAP()
BOOL CPPageDVD::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- m_iDVDLocation = s.fUseDVDPath ? 1 : 0;
- m_dvdpath = s.strDVDPath;
- m_iDVDLangType = 0;
+ m_iDVDLocation = s.fUseDVDPath ? 1 : 0;
+ m_dvdpath = s.strDVDPath;
+ m_iDVDLangType = 0;
- m_idMenuLang = s.idMenuLang;
- m_idAudioLang = s.idAudioLang;
- m_idSubtitlesLang = s.idSubtitlesLang;
- m_fAutoSpeakerConf = s.fAutoSpeakerConf;
- m_fClosedCaptions = s.fClosedCaptions;
+ m_idMenuLang = s.idMenuLang;
+ m_idAudioLang = s.idAudioLang;
+ m_idSubtitlesLang = s.idSubtitlesLang;
+ m_fAutoSpeakerConf = s.fAutoSpeakerConf;
+ m_fClosedCaptions = s.fClosedCaptions;
- UpdateData(FALSE);
+ UpdateData(FALSE);
- for (int i = 0; i < _countof(LCIDNameList); i++) {
- m_lcids.AddString(CString(LCIDNameList[i].name));
- m_lcids.SetItemData(i, LCIDNameList[i].lcid);
- }
+ for (int i = 0; i < _countof(LCIDNameList); i++) {
+ m_lcids.AddString(CString(LCIDNameList[i].name));
+ m_lcids.SetItemData(i, LCIDNameList[i].lcid);
+ }
- UpdateLCIDList();
+ UpdateLCIDList();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageDVD::OnApply()
{
- UpdateData();
+ UpdateData();
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- s.strDVDPath = m_dvdpath;
- s.fUseDVDPath = (m_iDVDLocation == 1);
- s.idMenuLang = m_idMenuLang;
- s.idAudioLang = m_idAudioLang;
- s.idSubtitlesLang = m_idSubtitlesLang;
- s.fAutoSpeakerConf = !!m_fAutoSpeakerConf;
- s.fClosedCaptions = !!m_fClosedCaptions;
+ s.strDVDPath = m_dvdpath;
+ s.fUseDVDPath = (m_iDVDLocation == 1);
+ s.idMenuLang = m_idMenuLang;
+ s.idAudioLang = m_idAudioLang;
+ s.idSubtitlesLang = m_idSubtitlesLang;
+ s.fAutoSpeakerConf = !!m_fAutoSpeakerConf;
+ s.fClosedCaptions = !!m_fClosedCaptions;
- ((CMainFrame*)AfxGetMyApp()->GetMainWnd())->SetClosedCaptions(s.fClosedCaptions);
+ ((CMainFrame*)AfxGetMyApp()->GetMainWnd())->SetClosedCaptions(s.fClosedCaptions);
- return __super::OnApply();
+ return __super::OnApply();
}
void CPPageDVD::OnBnClickedButton1()
{
- CString path;
- CString strTitle = ResStr(IDS_MAINFRM_46);
-
- if (SysVersion::IsVistaOrLater()) {
- CFileDialog dlg(TRUE);
- IFileOpenDialog *openDlgPtr = dlg.GetIFileOpenDialog();
-
- if (openDlgPtr != NULL) {
- openDlgPtr->SetTitle(strTitle);
- openDlgPtr->SetOptions(FOS_PICKFOLDERS | FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST);
- if (FAILED(openDlgPtr->Show(m_hWnd))) {
- openDlgPtr->Release();
- return;
- }
- openDlgPtr->Release();
-
- path = dlg.GetFolderPath();
- }
- } else {
- TCHAR _path[_MAX_PATH];
-
- BROWSEINFO bi;
- bi.hwndOwner = m_hWnd;
- bi.pidlRoot = NULL;
- bi.pszDisplayName = _path;
- bi.lpszTitle = strTitle;
- bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_VALIDATE | BIF_USENEWUI | BIF_NONEWFOLDERBUTTON;
- bi.lpfn = NULL;
- bi.lParam = 0;
- bi.iImage = 0;
-
- LPITEMIDLIST iil = SHBrowseForFolder(&bi);
- if (iil) {
- SHGetPathFromIDList(iil, _path);
- path = _path;
- }
- }
-
- if (!path.IsEmpty()) {
- m_dvdpath = path;
-
- UpdateData(FALSE);
-
- SetModified();
- }
+ CString path;
+ CString strTitle = ResStr(IDS_MAINFRM_46);
+
+ if (SysVersion::IsVistaOrLater()) {
+ CFileDialog dlg(TRUE);
+ IFileOpenDialog* openDlgPtr = dlg.GetIFileOpenDialog();
+
+ if (openDlgPtr != NULL) {
+ openDlgPtr->SetTitle(strTitle);
+ openDlgPtr->SetOptions(FOS_PICKFOLDERS | FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST);
+ if (FAILED(openDlgPtr->Show(m_hWnd))) {
+ openDlgPtr->Release();
+ return;
+ }
+ openDlgPtr->Release();
+
+ path = dlg.GetFolderPath();
+ }
+ } else {
+ TCHAR _path[_MAX_PATH];
+
+ BROWSEINFO bi;
+ bi.hwndOwner = m_hWnd;
+ bi.pidlRoot = NULL;
+ bi.pszDisplayName = _path;
+ bi.lpszTitle = strTitle;
+ bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_VALIDATE | BIF_USENEWUI | BIF_NONEWFOLDERBUTTON;
+ bi.lpfn = NULL;
+ bi.lParam = 0;
+ bi.iImage = 0;
+
+ LPITEMIDLIST iil = SHBrowseForFolder(&bi);
+ if (iil) {
+ SHGetPathFromIDList(iil, _path);
+ path = _path;
+ }
+ }
+
+ if (!path.IsEmpty()) {
+ m_dvdpath = path;
+
+ UpdateData(FALSE);
+
+ SetModified();
+ }
}
void CPPageDVD::OnBnClickedLangradio123(UINT nID)
{
- UpdateLCIDList();
+ UpdateLCIDList();
}
void CPPageDVD::OnLbnSelchangeList1()
{
- LCID& lcid = m_iDVDLangType == 0 ? m_idMenuLang
- : m_iDVDLangType == 1 ? m_idAudioLang
- : m_idSubtitlesLang;
+ LCID& lcid = m_iDVDLangType == 0 ? m_idMenuLang
+ : m_iDVDLangType == 1 ? m_idAudioLang
+ : m_idSubtitlesLang;
- lcid = (LCID)m_lcids.GetItemData(m_lcids.GetCurSel());
+ lcid = (LCID)m_lcids.GetItemData(m_lcids.GetCurSel());
- SetModified();
+ SetModified();
}
void CPPageDVD::OnUpdateDVDPath(CCmdUI* pCmdUI)
{
- UpdateData();
+ UpdateData();
- pCmdUI->Enable(m_iDVDLocation == 1);
+ pCmdUI->Enable(m_iDVDLocation == 1);
}
diff --git a/src/mpc-hc/PPageDVD.h b/src/mpc-hc/PPageDVD.h
index 056fa0822..8ee2038bf 100644
--- a/src/mpc-hc/PPageDVD.h
+++ b/src/mpc-hc/PPageDVD.h
@@ -29,42 +29,42 @@
class CPPageDVD : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageDVD)
+ DECLARE_DYNAMIC(CPPageDVD)
private:
- void UpdateLCIDList();
+ void UpdateLCIDList();
public:
- CPPageDVD();
- virtual ~CPPageDVD();
+ CPPageDVD();
+ virtual ~CPPageDVD();
- CListBox m_lcids;
- CString m_dvdpath;
- CEdit m_dvdpathctrl;
- CButton m_dvdpathselctrl;
- int m_iDVDLocation;
- int m_iDVDLangType;
+ CListBox m_lcids;
+ CString m_dvdpath;
+ CEdit m_dvdpathctrl;
+ CButton m_dvdpathselctrl;
+ int m_iDVDLocation;
+ int m_iDVDLangType;
- LCID m_idMenuLang;
- LCID m_idAudioLang;
- LCID m_idSubtitlesLang;
+ LCID m_idMenuLang;
+ LCID m_idAudioLang;
+ LCID m_idSubtitlesLang;
- BOOL m_fAutoSpeakerConf;
- BOOL m_fClosedCaptions;
+ BOOL m_fAutoSpeakerConf;
+ BOOL m_fClosedCaptions;
- // Dialog Data
- enum { IDD = IDD_PPAGEDVD};
+ // Dialog Data
+ enum { IDD = IDD_PPAGEDVD};
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnBnClickedButton1();
- afx_msg void OnBnClickedLangradio123(UINT nID);
- afx_msg void OnLbnSelchangeList1();
- afx_msg void OnUpdateDVDPath(CCmdUI* pCmdUI);
+ afx_msg void OnBnClickedButton1();
+ afx_msg void OnBnClickedLangradio123(UINT nID);
+ afx_msg void OnLbnSelchangeList1();
+ afx_msg void OnUpdateDVDPath(CCmdUI* pCmdUI);
};
diff --git a/src/mpc-hc/PPageExternalFilters.cpp b/src/mpc-hc/PPageExternalFilters.cpp
index 06fe9eeaa..5086a7c5a 100644
--- a/src/mpc-hc/PPageExternalFilters.cpp
+++ b/src/mpc-hc/PPageExternalFilters.cpp
@@ -38,9 +38,9 @@
IMPLEMENT_DYNAMIC(CPPageExternalFilters, CPPageBase)
CPPageExternalFilters::CPPageExternalFilters()
- : CPPageBase(CPPageExternalFilters::IDD, CPPageExternalFilters::IDD)
- , m_iLoadType(FilterOverride::PREFERRED)
- , m_pLastSelFilter(NULL)
+ : CPPageBase(CPPageExternalFilters::IDD, CPPageExternalFilters::IDD)
+ , m_iLoadType(FilterOverride::PREFERRED)
+ , m_pLastSelFilter(NULL)
{
}
@@ -50,240 +50,240 @@ CPPageExternalFilters::~CPPageExternalFilters()
void CPPageExternalFilters::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_LIST1, m_filters);
- DDX_Radio(pDX, IDC_RADIO1, m_iLoadType);
- DDX_Control(pDX, IDC_EDIT1, m_dwMerit);
- DDX_Control(pDX, IDC_TREE2, m_tree);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_LIST1, m_filters);
+ DDX_Radio(pDX, IDC_RADIO1, m_iLoadType);
+ DDX_Control(pDX, IDC_EDIT1, m_dwMerit);
+ DDX_Control(pDX, IDC_TREE2, m_tree);
}
void CPPageExternalFilters::StepUp(CCheckListBox& list)
{
- int i = list.GetCurSel();
- if (i < 1) {
- return;
- }
+ int i = list.GetCurSel();
+ if (i < 1) {
+ return;
+ }
- CString str;
- list.GetText(i, str);
- DWORD_PTR dwItemData = list.GetItemData(i);
- int nCheck = list.GetCheck(i);
- list.DeleteString(i);
- i--;
- list.InsertString(i, str);
- list.SetItemData(i, dwItemData);
- list.SetCheck(i, nCheck);
- list.SetCurSel(i);
+ CString str;
+ list.GetText(i, str);
+ DWORD_PTR dwItemData = list.GetItemData(i);
+ int nCheck = list.GetCheck(i);
+ list.DeleteString(i);
+ i--;
+ list.InsertString(i, str);
+ list.SetItemData(i, dwItemData);
+ list.SetCheck(i, nCheck);
+ list.SetCurSel(i);
- SetModified();
+ SetModified();
}
void CPPageExternalFilters::StepDown(CCheckListBox& list)
{
- int i = list.GetCurSel();
- if (i < 0 || i >= list.GetCount()-1) {
- return;
- }
+ int i = list.GetCurSel();
+ if (i < 0 || i >= list.GetCount() - 1) {
+ return;
+ }
- CString str;
- list.GetText(i, str);
- DWORD_PTR dwItemData = list.GetItemData(i);
- int nCheck = list.GetCheck(i);
- list.DeleteString(i);
- i++;
- list.InsertString(i, str);
- list.SetItemData(i, dwItemData);
- list.SetCheck(i, nCheck);
- list.SetCurSel(i);
+ CString str;
+ list.GetText(i, str);
+ DWORD_PTR dwItemData = list.GetItemData(i);
+ int nCheck = list.GetCheck(i);
+ list.DeleteString(i);
+ i++;
+ list.InsertString(i, str);
+ list.SetItemData(i, dwItemData);
+ list.SetCheck(i, nCheck);
+ list.SetCurSel(i);
- SetModified();
+ SetModified();
}
FilterOverride* CPPageExternalFilters::GetCurFilter()
{
- int i = m_filters.GetCurSel();
- return i >= 0 ? (FilterOverride*)m_pFilters.GetAt((POSITION)m_filters.GetItemDataPtr(i)) : (FilterOverride*)NULL;
+ int i = m_filters.GetCurSel();
+ return i >= 0 ? (FilterOverride*)m_pFilters.GetAt((POSITION)m_filters.GetItemDataPtr(i)) : (FilterOverride*)NULL;
}
void CPPageExternalFilters::SetupMajorTypes(CAtlArray<GUID>& guids)
{
- guids.RemoveAll();
- guids.Add(MEDIATYPE_NULL);
- guids.Add(MEDIATYPE_Video);
- guids.Add(MEDIATYPE_Audio);
- guids.Add(MEDIATYPE_Text);
- guids.Add(MEDIATYPE_Midi);
- guids.Add(MEDIATYPE_Stream);
- guids.Add(MEDIATYPE_Interleaved);
- guids.Add(MEDIATYPE_File);
- guids.Add(MEDIATYPE_ScriptCommand);
- guids.Add(MEDIATYPE_AUXLine21Data);
- guids.Add(MEDIATYPE_VBI);
- guids.Add(MEDIATYPE_Timecode);
- guids.Add(MEDIATYPE_LMRT);
- guids.Add(MEDIATYPE_URL_STREAM);
- guids.Add(MEDIATYPE_MPEG1SystemStream);
- guids.Add(MEDIATYPE_AnalogVideo);
- guids.Add(MEDIATYPE_AnalogAudio);
- guids.Add(MEDIATYPE_MPEG2_PACK);
- guids.Add(MEDIATYPE_MPEG2_PES);
- guids.Add(MEDIATYPE_MPEG2_SECTIONS);
- guids.Add(MEDIATYPE_DVD_ENCRYPTED_PACK);
- guids.Add(MEDIATYPE_DVD_NAVIGATION);
+ guids.RemoveAll();
+ guids.Add(MEDIATYPE_NULL);
+ guids.Add(MEDIATYPE_Video);
+ guids.Add(MEDIATYPE_Audio);
+ guids.Add(MEDIATYPE_Text);
+ guids.Add(MEDIATYPE_Midi);
+ guids.Add(MEDIATYPE_Stream);
+ guids.Add(MEDIATYPE_Interleaved);
+ guids.Add(MEDIATYPE_File);
+ guids.Add(MEDIATYPE_ScriptCommand);
+ guids.Add(MEDIATYPE_AUXLine21Data);
+ guids.Add(MEDIATYPE_VBI);
+ guids.Add(MEDIATYPE_Timecode);
+ guids.Add(MEDIATYPE_LMRT);
+ guids.Add(MEDIATYPE_URL_STREAM);
+ guids.Add(MEDIATYPE_MPEG1SystemStream);
+ guids.Add(MEDIATYPE_AnalogVideo);
+ guids.Add(MEDIATYPE_AnalogAudio);
+ guids.Add(MEDIATYPE_MPEG2_PACK);
+ guids.Add(MEDIATYPE_MPEG2_PES);
+ guids.Add(MEDIATYPE_MPEG2_SECTIONS);
+ guids.Add(MEDIATYPE_DVD_ENCRYPTED_PACK);
+ guids.Add(MEDIATYPE_DVD_NAVIGATION);
}
void CPPageExternalFilters::SetupSubTypes(CAtlArray<GUID>& guids)
{
- guids.RemoveAll();
- guids.Add(MEDIASUBTYPE_None);
- guids.Add(MEDIASUBTYPE_CLPL);
- guids.Add(MEDIASUBTYPE_YUYV);
- guids.Add(MEDIASUBTYPE_IYUV);
- guids.Add(MEDIASUBTYPE_YVU9);
- guids.Add(MEDIASUBTYPE_Y411);
- guids.Add(MEDIASUBTYPE_Y41P);
- guids.Add(MEDIASUBTYPE_YUY2);
- guids.Add(MEDIASUBTYPE_YVYU);
- guids.Add(MEDIASUBTYPE_UYVY);
- guids.Add(MEDIASUBTYPE_Y211);
- guids.Add(MEDIASUBTYPE_CLJR);
- guids.Add(MEDIASUBTYPE_IF09);
- guids.Add(MEDIASUBTYPE_CPLA);
- guids.Add(MEDIASUBTYPE_MJPG);
- guids.Add(MEDIASUBTYPE_MJPA);
- guids.Add(MEDIASUBTYPE_MJPB);
- guids.Add(MEDIASUBTYPE_TVMJ);
- guids.Add(MEDIASUBTYPE_WAKE);
- guids.Add(MEDIASUBTYPE_CFCC);
- guids.Add(MEDIASUBTYPE_IJPG);
- guids.Add(MEDIASUBTYPE_Plum);
- guids.Add(MEDIASUBTYPE_DVCS);
- guids.Add(MEDIASUBTYPE_DVSD);
- guids.Add(MEDIASUBTYPE_MDVF);
- guids.Add(MEDIASUBTYPE_RGB1);
- guids.Add(MEDIASUBTYPE_RGB4);
- guids.Add(MEDIASUBTYPE_RGB8);
- guids.Add(MEDIASUBTYPE_RGB565);
- guids.Add(MEDIASUBTYPE_RGB555);
- guids.Add(MEDIASUBTYPE_RGB24);
- guids.Add(MEDIASUBTYPE_RGB32);
- guids.Add(MEDIASUBTYPE_ARGB1555);
- guids.Add(MEDIASUBTYPE_ARGB4444);
- guids.Add(MEDIASUBTYPE_ARGB32);
- guids.Add(MEDIASUBTYPE_A2R10G10B10);
- guids.Add(MEDIASUBTYPE_A2B10G10R10);
- guids.Add(MEDIASUBTYPE_AYUV);
- guids.Add(MEDIASUBTYPE_AI44);
- guids.Add(MEDIASUBTYPE_IA44);
- guids.Add(MEDIASUBTYPE_RGB32_D3D_DX7_RT);
- guids.Add(MEDIASUBTYPE_RGB16_D3D_DX7_RT);
- guids.Add(MEDIASUBTYPE_ARGB32_D3D_DX7_RT);
- guids.Add(MEDIASUBTYPE_ARGB4444_D3D_DX7_RT);
- guids.Add(MEDIASUBTYPE_ARGB1555_D3D_DX7_RT);
- guids.Add(MEDIASUBTYPE_RGB32_D3D_DX9_RT);
- guids.Add(MEDIASUBTYPE_RGB16_D3D_DX9_RT);
- guids.Add(MEDIASUBTYPE_ARGB32_D3D_DX9_RT);
- guids.Add(MEDIASUBTYPE_ARGB4444_D3D_DX9_RT);
- guids.Add(MEDIASUBTYPE_ARGB1555_D3D_DX9_RT);
- guids.Add(MEDIASUBTYPE_YV12);
- guids.Add(MEDIASUBTYPE_NV12);
- guids.Add(MEDIASUBTYPE_IMC1);
- guids.Add(MEDIASUBTYPE_IMC2);
- guids.Add(MEDIASUBTYPE_IMC3);
- guids.Add(MEDIASUBTYPE_IMC4);
- guids.Add(MEDIASUBTYPE_S340);
- guids.Add(MEDIASUBTYPE_S342);
- guids.Add(MEDIASUBTYPE_Overlay);
- guids.Add(MEDIASUBTYPE_MPEG1Packet);
- guids.Add(MEDIASUBTYPE_MPEG1Payload);
- guids.Add(MEDIASUBTYPE_MPEG1AudioPayload);
- guids.Add(MEDIASUBTYPE_MPEG1System);
- guids.Add(MEDIASUBTYPE_MPEG1VideoCD);
- guids.Add(MEDIASUBTYPE_MPEG1Video);
- guids.Add(MEDIASUBTYPE_MPEG1Audio);
- guids.Add(MEDIASUBTYPE_Avi);
- guids.Add(MEDIASUBTYPE_Asf);
- guids.Add(MEDIASUBTYPE_QTMovie);
- guids.Add(MEDIASUBTYPE_QTRpza);
- guids.Add(MEDIASUBTYPE_QTSmc);
- guids.Add(MEDIASUBTYPE_QTRle);
- guids.Add(MEDIASUBTYPE_QTJpeg);
- guids.Add(MEDIASUBTYPE_PCMAudio_Obsolete);
- guids.Add(MEDIASUBTYPE_PCM);
- guids.Add(MEDIASUBTYPE_WAVE);
- guids.Add(MEDIASUBTYPE_AU);
- guids.Add(MEDIASUBTYPE_AIFF);
- guids.Add(MEDIASUBTYPE_dvsd);
- guids.Add(MEDIASUBTYPE_dvhd);
- guids.Add(MEDIASUBTYPE_dvsl);
- guids.Add(MEDIASUBTYPE_dv25);
- guids.Add(MEDIASUBTYPE_dv50);
- guids.Add(MEDIASUBTYPE_dvh1);
- guids.Add(MEDIASUBTYPE_Line21_BytePair);
- guids.Add(MEDIASUBTYPE_Line21_GOPPacket);
- guids.Add(MEDIASUBTYPE_Line21_VBIRawData);
- guids.Add(MEDIASUBTYPE_TELETEXT);
- guids.Add(MEDIASUBTYPE_DRM_Audio);
- guids.Add(MEDIASUBTYPE_IEEE_FLOAT);
- guids.Add(MEDIASUBTYPE_DOLBY_AC3_SPDIF);
- guids.Add(MEDIASUBTYPE_RAW_SPORT);
- guids.Add(MEDIASUBTYPE_SPDIF_TAG_241h);
- guids.Add(MEDIASUBTYPE_DssVideo);
- guids.Add(MEDIASUBTYPE_DssAudio);
- guids.Add(MEDIASUBTYPE_VPVideo);
- guids.Add(MEDIASUBTYPE_VPVBI);
- guids.Add(MEDIASUBTYPE_ATSC_SI);
- guids.Add(MEDIASUBTYPE_DVB_SI);
- guids.Add(MEDIASUBTYPE_MPEG2DATA);
- guids.Add(MEDIASUBTYPE_MPEG2_VIDEO);
- guids.Add(MEDIASUBTYPE_MPEG2_PROGRAM);
- guids.Add(MEDIASUBTYPE_MPEG2_TRANSPORT);
- guids.Add(MEDIASUBTYPE_MPEG2_TRANSPORT_STRIDE);
- guids.Add(MEDIASUBTYPE_MPEG2_AUDIO);
- guids.Add(MEDIASUBTYPE_DOLBY_AC3);
- guids.Add(MEDIASUBTYPE_DVD_SUBPICTURE);
- guids.Add(MEDIASUBTYPE_DVD_LPCM_AUDIO);
- guids.Add(MEDIASUBTYPE_DTS);
- guids.Add(MEDIASUBTYPE_SDDS);
- guids.Add(MEDIASUBTYPE_DVD_NAVIGATION_PCI);
- guids.Add(MEDIASUBTYPE_DVD_NAVIGATION_DSI);
- guids.Add(MEDIASUBTYPE_DVD_NAVIGATION_PROVIDER);
- guids.Add(MEDIASUBTYPE_I420);
- guids.Add(MEDIASUBTYPE_WAVE_DOLBY_AC3);
- guids.Add(MEDIASUBTYPE_WAVE_DTS);
+ guids.RemoveAll();
+ guids.Add(MEDIASUBTYPE_None);
+ guids.Add(MEDIASUBTYPE_CLPL);
+ guids.Add(MEDIASUBTYPE_YUYV);
+ guids.Add(MEDIASUBTYPE_IYUV);
+ guids.Add(MEDIASUBTYPE_YVU9);
+ guids.Add(MEDIASUBTYPE_Y411);
+ guids.Add(MEDIASUBTYPE_Y41P);
+ guids.Add(MEDIASUBTYPE_YUY2);
+ guids.Add(MEDIASUBTYPE_YVYU);
+ guids.Add(MEDIASUBTYPE_UYVY);
+ guids.Add(MEDIASUBTYPE_Y211);
+ guids.Add(MEDIASUBTYPE_CLJR);
+ guids.Add(MEDIASUBTYPE_IF09);
+ guids.Add(MEDIASUBTYPE_CPLA);
+ guids.Add(MEDIASUBTYPE_MJPG);
+ guids.Add(MEDIASUBTYPE_MJPA);
+ guids.Add(MEDIASUBTYPE_MJPB);
+ guids.Add(MEDIASUBTYPE_TVMJ);
+ guids.Add(MEDIASUBTYPE_WAKE);
+ guids.Add(MEDIASUBTYPE_CFCC);
+ guids.Add(MEDIASUBTYPE_IJPG);
+ guids.Add(MEDIASUBTYPE_Plum);
+ guids.Add(MEDIASUBTYPE_DVCS);
+ guids.Add(MEDIASUBTYPE_DVSD);
+ guids.Add(MEDIASUBTYPE_MDVF);
+ guids.Add(MEDIASUBTYPE_RGB1);
+ guids.Add(MEDIASUBTYPE_RGB4);
+ guids.Add(MEDIASUBTYPE_RGB8);
+ guids.Add(MEDIASUBTYPE_RGB565);
+ guids.Add(MEDIASUBTYPE_RGB555);
+ guids.Add(MEDIASUBTYPE_RGB24);
+ guids.Add(MEDIASUBTYPE_RGB32);
+ guids.Add(MEDIASUBTYPE_ARGB1555);
+ guids.Add(MEDIASUBTYPE_ARGB4444);
+ guids.Add(MEDIASUBTYPE_ARGB32);
+ guids.Add(MEDIASUBTYPE_A2R10G10B10);
+ guids.Add(MEDIASUBTYPE_A2B10G10R10);
+ guids.Add(MEDIASUBTYPE_AYUV);
+ guids.Add(MEDIASUBTYPE_AI44);
+ guids.Add(MEDIASUBTYPE_IA44);
+ guids.Add(MEDIASUBTYPE_RGB32_D3D_DX7_RT);
+ guids.Add(MEDIASUBTYPE_RGB16_D3D_DX7_RT);
+ guids.Add(MEDIASUBTYPE_ARGB32_D3D_DX7_RT);
+ guids.Add(MEDIASUBTYPE_ARGB4444_D3D_DX7_RT);
+ guids.Add(MEDIASUBTYPE_ARGB1555_D3D_DX7_RT);
+ guids.Add(MEDIASUBTYPE_RGB32_D3D_DX9_RT);
+ guids.Add(MEDIASUBTYPE_RGB16_D3D_DX9_RT);
+ guids.Add(MEDIASUBTYPE_ARGB32_D3D_DX9_RT);
+ guids.Add(MEDIASUBTYPE_ARGB4444_D3D_DX9_RT);
+ guids.Add(MEDIASUBTYPE_ARGB1555_D3D_DX9_RT);
+ guids.Add(MEDIASUBTYPE_YV12);
+ guids.Add(MEDIASUBTYPE_NV12);
+ guids.Add(MEDIASUBTYPE_IMC1);
+ guids.Add(MEDIASUBTYPE_IMC2);
+ guids.Add(MEDIASUBTYPE_IMC3);
+ guids.Add(MEDIASUBTYPE_IMC4);
+ guids.Add(MEDIASUBTYPE_S340);
+ guids.Add(MEDIASUBTYPE_S342);
+ guids.Add(MEDIASUBTYPE_Overlay);
+ guids.Add(MEDIASUBTYPE_MPEG1Packet);
+ guids.Add(MEDIASUBTYPE_MPEG1Payload);
+ guids.Add(MEDIASUBTYPE_MPEG1AudioPayload);
+ guids.Add(MEDIASUBTYPE_MPEG1System);
+ guids.Add(MEDIASUBTYPE_MPEG1VideoCD);
+ guids.Add(MEDIASUBTYPE_MPEG1Video);
+ guids.Add(MEDIASUBTYPE_MPEG1Audio);
+ guids.Add(MEDIASUBTYPE_Avi);
+ guids.Add(MEDIASUBTYPE_Asf);
+ guids.Add(MEDIASUBTYPE_QTMovie);
+ guids.Add(MEDIASUBTYPE_QTRpza);
+ guids.Add(MEDIASUBTYPE_QTSmc);
+ guids.Add(MEDIASUBTYPE_QTRle);
+ guids.Add(MEDIASUBTYPE_QTJpeg);
+ guids.Add(MEDIASUBTYPE_PCMAudio_Obsolete);
+ guids.Add(MEDIASUBTYPE_PCM);
+ guids.Add(MEDIASUBTYPE_WAVE);
+ guids.Add(MEDIASUBTYPE_AU);
+ guids.Add(MEDIASUBTYPE_AIFF);
+ guids.Add(MEDIASUBTYPE_dvsd);
+ guids.Add(MEDIASUBTYPE_dvhd);
+ guids.Add(MEDIASUBTYPE_dvsl);
+ guids.Add(MEDIASUBTYPE_dv25);
+ guids.Add(MEDIASUBTYPE_dv50);
+ guids.Add(MEDIASUBTYPE_dvh1);
+ guids.Add(MEDIASUBTYPE_Line21_BytePair);
+ guids.Add(MEDIASUBTYPE_Line21_GOPPacket);
+ guids.Add(MEDIASUBTYPE_Line21_VBIRawData);
+ guids.Add(MEDIASUBTYPE_TELETEXT);
+ guids.Add(MEDIASUBTYPE_DRM_Audio);
+ guids.Add(MEDIASUBTYPE_IEEE_FLOAT);
+ guids.Add(MEDIASUBTYPE_DOLBY_AC3_SPDIF);
+ guids.Add(MEDIASUBTYPE_RAW_SPORT);
+ guids.Add(MEDIASUBTYPE_SPDIF_TAG_241h);
+ guids.Add(MEDIASUBTYPE_DssVideo);
+ guids.Add(MEDIASUBTYPE_DssAudio);
+ guids.Add(MEDIASUBTYPE_VPVideo);
+ guids.Add(MEDIASUBTYPE_VPVBI);
+ guids.Add(MEDIASUBTYPE_ATSC_SI);
+ guids.Add(MEDIASUBTYPE_DVB_SI);
+ guids.Add(MEDIASUBTYPE_MPEG2DATA);
+ guids.Add(MEDIASUBTYPE_MPEG2_VIDEO);
+ guids.Add(MEDIASUBTYPE_MPEG2_PROGRAM);
+ guids.Add(MEDIASUBTYPE_MPEG2_TRANSPORT);
+ guids.Add(MEDIASUBTYPE_MPEG2_TRANSPORT_STRIDE);
+ guids.Add(MEDIASUBTYPE_MPEG2_AUDIO);
+ guids.Add(MEDIASUBTYPE_DOLBY_AC3);
+ guids.Add(MEDIASUBTYPE_DVD_SUBPICTURE);
+ guids.Add(MEDIASUBTYPE_DVD_LPCM_AUDIO);
+ guids.Add(MEDIASUBTYPE_DTS);
+ guids.Add(MEDIASUBTYPE_SDDS);
+ guids.Add(MEDIASUBTYPE_DVD_NAVIGATION_PCI);
+ guids.Add(MEDIASUBTYPE_DVD_NAVIGATION_DSI);
+ guids.Add(MEDIASUBTYPE_DVD_NAVIGATION_PROVIDER);
+ guids.Add(MEDIASUBTYPE_I420);
+ guids.Add(MEDIASUBTYPE_WAVE_DOLBY_AC3);
+ guids.Add(MEDIASUBTYPE_WAVE_DTS);
}
BEGIN_MESSAGE_MAP(CPPageExternalFilters, CPPageBase)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON2, OnUpdateFilter)
- ON_UPDATE_COMMAND_UI(IDC_RADIO1, OnUpdateFilter)
- ON_UPDATE_COMMAND_UI(IDC_RADIO2, OnUpdateFilter)
- ON_UPDATE_COMMAND_UI(IDC_RADIO3, OnUpdateFilter)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON3, OnUpdateFilterUp)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON4, OnUpdateFilterDown)
- ON_UPDATE_COMMAND_UI(IDC_EDIT1, OnUpdateFilterMerit)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON5, OnUpdateFilter)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON6, OnUpdateSubType)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON7, OnUpdateDeleteType)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON8, OnUpdateFilter)
- ON_BN_CLICKED(IDC_BUTTON1, OnAddRegistered)
- ON_BN_CLICKED(IDC_BUTTON2, OnRemoveFilter)
- ON_BN_CLICKED(IDC_BUTTON3, OnMoveFilterUp)
- ON_BN_CLICKED(IDC_BUTTON4, OnMoveFilterDown)
- ON_LBN_DBLCLK(IDC_LIST1, OnLbnDblclkFilter)
- ON_WM_VKEYTOITEM()
- ON_BN_CLICKED(IDC_BUTTON5, OnAddMajorType)
- ON_BN_CLICKED(IDC_BUTTON6, OnAddSubType)
- ON_BN_CLICKED(IDC_BUTTON7, OnDeleteType)
- ON_BN_CLICKED(IDC_BUTTON8, OnResetTypes)
- ON_LBN_SELCHANGE(IDC_LIST1, OnLbnSelchangeList1)
- ON_CLBN_CHKCHANGE(IDC_LIST1, OnCheckChangeList1)
- ON_BN_CLICKED(IDC_RADIO1, OnBnClickedRadio)
- ON_BN_CLICKED(IDC_RADIO2, OnBnClickedRadio)
- ON_BN_CLICKED(IDC_RADIO3, OnBnClickedRadio)
- ON_EN_CHANGE(IDC_EDIT1, OnEnChangeEdit1)
- ON_NOTIFY(NM_DBLCLK, IDC_TREE2, OnNMDblclkTree2)
- ON_NOTIFY(TVN_KEYDOWN, IDC_TREE2, OnTVNKeyDownTree2)
- ON_WM_DROPFILES()
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON2, OnUpdateFilter)
+ ON_UPDATE_COMMAND_UI(IDC_RADIO1, OnUpdateFilter)
+ ON_UPDATE_COMMAND_UI(IDC_RADIO2, OnUpdateFilter)
+ ON_UPDATE_COMMAND_UI(IDC_RADIO3, OnUpdateFilter)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON3, OnUpdateFilterUp)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON4, OnUpdateFilterDown)
+ ON_UPDATE_COMMAND_UI(IDC_EDIT1, OnUpdateFilterMerit)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON5, OnUpdateFilter)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON6, OnUpdateSubType)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON7, OnUpdateDeleteType)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON8, OnUpdateFilter)
+ ON_BN_CLICKED(IDC_BUTTON1, OnAddRegistered)
+ ON_BN_CLICKED(IDC_BUTTON2, OnRemoveFilter)
+ ON_BN_CLICKED(IDC_BUTTON3, OnMoveFilterUp)
+ ON_BN_CLICKED(IDC_BUTTON4, OnMoveFilterDown)
+ ON_LBN_DBLCLK(IDC_LIST1, OnLbnDblclkFilter)
+ ON_WM_VKEYTOITEM()
+ ON_BN_CLICKED(IDC_BUTTON5, OnAddMajorType)
+ ON_BN_CLICKED(IDC_BUTTON6, OnAddSubType)
+ ON_BN_CLICKED(IDC_BUTTON7, OnDeleteType)
+ ON_BN_CLICKED(IDC_BUTTON8, OnResetTypes)
+ ON_LBN_SELCHANGE(IDC_LIST1, OnLbnSelchangeList1)
+ ON_CLBN_CHKCHANGE(IDC_LIST1, OnCheckChangeList1)
+ ON_BN_CLICKED(IDC_RADIO1, OnBnClickedRadio)
+ ON_BN_CLICKED(IDC_RADIO2, OnBnClickedRadio)
+ ON_BN_CLICKED(IDC_RADIO3, OnBnClickedRadio)
+ ON_EN_CHANGE(IDC_EDIT1, OnEnChangeEdit1)
+ ON_NOTIFY(NM_DBLCLK, IDC_TREE2, OnNMDblclkTree2)
+ ON_NOTIFY(TVN_KEYDOWN, IDC_TREE2, OnTVNKeyDownTree2)
+ ON_WM_DROPFILES()
END_MESSAGE_MAP()
@@ -291,517 +291,517 @@ END_MESSAGE_MAP()
BOOL CPPageExternalFilters::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- DragAcceptFiles(TRUE);
+ DragAcceptFiles(TRUE);
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- m_pFilters.RemoveAll();
+ m_pFilters.RemoveAll();
- POSITION pos = s.m_filters.GetHeadPosition();
- while (pos) {
- CAutoPtr<FilterOverride> f(DNew FilterOverride(s.m_filters.GetNext(pos)));
+ POSITION pos = s.m_filters.GetHeadPosition();
+ while (pos) {
+ CAutoPtr<FilterOverride> f(DNew FilterOverride(s.m_filters.GetNext(pos)));
- CString name(_T("<unknown>"));
+ CString name(_T("<unknown>"));
- if (f->type == FilterOverride::REGISTERED) {
- name = CFGFilterRegistry(f->dispname).GetName();
- if (name.IsEmpty()) {
- name = f->name + _T(" <not registered>");
- }
- } else if (f->type == FilterOverride::EXTERNAL) {
- name = f->name;
- if (f->fTemporary) {
- name += _T(" <temporary>");
- }
- if (!CPath(MakeFullPath(f->path)).FileExists()) {
- name += _T(" <not found!>");
- }
- }
+ if (f->type == FilterOverride::REGISTERED) {
+ name = CFGFilterRegistry(f->dispname).GetName();
+ if (name.IsEmpty()) {
+ name = f->name + _T(" <not registered>");
+ }
+ } else if (f->type == FilterOverride::EXTERNAL) {
+ name = f->name;
+ if (f->fTemporary) {
+ name += _T(" <temporary>");
+ }
+ if (!CPath(MakeFullPath(f->path)).FileExists()) {
+ name += _T(" <not found!>");
+ }
+ }
- int i = m_filters.AddString(name);
- m_filters.SetCheck(i, f->fDisabled ? 0 : 1);
- m_filters.SetItemDataPtr(i, m_pFilters.AddTail(f));
- }
+ int i = m_filters.AddString(name);
+ m_filters.SetCheck(i, f->fDisabled ? 0 : 1);
+ m_filters.SetItemDataPtr(i, m_pFilters.AddTail(f));
+ }
- UpdateData(FALSE);
+ UpdateData(FALSE);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageExternalFilters::OnApply()
{
- UpdateData();
+ UpdateData();
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- s.m_filters.RemoveAll();
+ s.m_filters.RemoveAll();
- for (int i = 0; i < m_filters.GetCount(); i++) {
- if (POSITION pos = (POSITION)m_filters.GetItemData(i)) {
- CAutoPtr<FilterOverride> f(DNew FilterOverride(m_pFilters.GetAt(pos)));
- f->fDisabled = !m_filters.GetCheck(i);
- s.m_filters.AddTail(f);
- }
- }
+ for (int i = 0; i < m_filters.GetCount(); i++) {
+ if (POSITION pos = (POSITION)m_filters.GetItemData(i)) {
+ CAutoPtr<FilterOverride> f(DNew FilterOverride(m_pFilters.GetAt(pos)));
+ f->fDisabled = !m_filters.GetCheck(i);
+ s.m_filters.AddTail(f);
+ }
+ }
- return __super::OnApply();
+ return __super::OnApply();
}
void CPPageExternalFilters::OnUpdateFilter(CCmdUI* pCmdUI)
{
- if (FilterOverride* f = GetCurFilter()) {
- pCmdUI->Enable(!(pCmdUI->m_nID == IDC_RADIO2 && f->type == FilterOverride::EXTERNAL));
- } else {
- pCmdUI->Enable(FALSE);
- }
+ if (FilterOverride* f = GetCurFilter()) {
+ pCmdUI->Enable(!(pCmdUI->m_nID == IDC_RADIO2 && f->type == FilterOverride::EXTERNAL));
+ } else {
+ pCmdUI->Enable(FALSE);
+ }
}
void CPPageExternalFilters::OnUpdateFilterUp(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_filters.GetCurSel() > 0);
+ pCmdUI->Enable(m_filters.GetCurSel() > 0);
}
void CPPageExternalFilters::OnUpdateFilterDown(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_filters.GetCurSel() >= 0 && m_filters.GetCurSel() < m_filters.GetCount()-1);
+ pCmdUI->Enable(m_filters.GetCurSel() >= 0 && m_filters.GetCurSel() < m_filters.GetCount() - 1);
}
void CPPageExternalFilters::OnUpdateFilterMerit(CCmdUI* pCmdUI)
{
- UpdateData();
- pCmdUI->Enable(m_iLoadType == FilterOverride::MERIT);
+ UpdateData();
+ pCmdUI->Enable(m_iLoadType == FilterOverride::MERIT);
}
void CPPageExternalFilters::OnUpdateSubType(CCmdUI* pCmdUI)
{
- HTREEITEM node = m_tree.GetSelectedItem();
- pCmdUI->Enable(node != NULL && m_tree.GetItemData(node) == NULL);
+ HTREEITEM node = m_tree.GetSelectedItem();
+ pCmdUI->Enable(node != NULL && m_tree.GetItemData(node) == NULL);
}
void CPPageExternalFilters::OnUpdateDeleteType(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!!m_tree.GetSelectedItem());
+ pCmdUI->Enable(!!m_tree.GetSelectedItem());
}
void CPPageExternalFilters::OnAddRegistered()
{
- CRegFilterChooserDlg dlg(this);
- if (dlg.DoModal() == IDOK) {
- while (!dlg.m_filters.IsEmpty()) {
- if (FilterOverride* f = dlg.m_filters.RemoveHead()) {
- CAutoPtr<FilterOverride> p(f);
+ CRegFilterChooserDlg dlg(this);
+ if (dlg.DoModal() == IDOK) {
+ while (!dlg.m_filters.IsEmpty()) {
+ if (FilterOverride* f = dlg.m_filters.RemoveHead()) {
+ CAutoPtr<FilterOverride> p(f);
- CString name = f->name;
+ CString name = f->name;
- if (f->type == FilterOverride::EXTERNAL) {
- if (!CPath(MakeFullPath(f->path)).FileExists()) {
- name += _T(" <not found!>");
- }
- }
+ if (f->type == FilterOverride::EXTERNAL) {
+ if (!CPath(MakeFullPath(f->path)).FileExists()) {
+ name += _T(" <not found!>");
+ }
+ }
- int i = m_filters.AddString(name);
- m_filters.SetItemDataPtr(i, m_pFilters.AddTail(p));
- m_filters.SetCheck(i, 1);
+ int i = m_filters.AddString(name);
+ m_filters.SetItemDataPtr(i, m_pFilters.AddTail(p));
+ m_filters.SetCheck(i, 1);
- if (dlg.m_filters.IsEmpty()) {
- m_filters.SetCurSel(i);
- OnLbnSelchangeList1();
- }
+ if (dlg.m_filters.IsEmpty()) {
+ m_filters.SetCurSel(i);
+ OnLbnSelchangeList1();
+ }
- SetModified();
- }
- }
- }
+ SetModified();
+ }
+ }
+ }
}
void CPPageExternalFilters::OnRemoveFilter()
{
- int i = m_filters.GetCurSel();
- m_pFilters.RemoveAt((POSITION)m_filters.GetItemDataPtr(i));
- m_filters.DeleteString(i);
+ int i = m_filters.GetCurSel();
+ m_pFilters.RemoveAt((POSITION)m_filters.GetItemDataPtr(i));
+ m_filters.DeleteString(i);
- if (i >= m_filters.GetCount()) {
- i--;
- }
- m_filters.SetCurSel(i);
- OnLbnSelchangeList1();
+ if (i >= m_filters.GetCount()) {
+ i--;
+ }
+ m_filters.SetCurSel(i);
+ OnLbnSelchangeList1();
- SetModified();
+ SetModified();
}
void CPPageExternalFilters::OnMoveFilterUp()
{
- StepUp(m_filters);
+ StepUp(m_filters);
}
void CPPageExternalFilters::OnMoveFilterDown()
{
- StepDown(m_filters);
+ StepDown(m_filters);
}
void CPPageExternalFilters::OnLbnDblclkFilter()
{
- if (FilterOverride* f = GetCurFilter()) {
- CComPtr<IBaseFilter> pBF;
- CString name;
-
- if (f->type == FilterOverride::REGISTERED) {
- CStringW namew;
- if (CreateFilter(f->dispname, &pBF, namew)) {
- name = namew;
- }
- } else if (f->type == FilterOverride::EXTERNAL) {
- if (SUCCEEDED(LoadExternalFilter(f->path, f->clsid, &pBF))) {
- name = f->name;
- }
- }
-
- if (CComQIPtr<ISpecifyPropertyPages> pSPP = pBF) {
- CComPropertySheet ps(name, this);
- if (ps.AddPages(pSPP) > 0) {
- CComPtr<IFilterGraph> pFG;
- if (SUCCEEDED(pFG.CoCreateInstance(CLSID_FilterGraph))) {
- pFG->AddFilter(pBF, L"");
- }
-
- ps.DoModal();
- }
- }
- }
+ if (FilterOverride* f = GetCurFilter()) {
+ CComPtr<IBaseFilter> pBF;
+ CString name;
+
+ if (f->type == FilterOverride::REGISTERED) {
+ CStringW namew;
+ if (CreateFilter(f->dispname, &pBF, namew)) {
+ name = namew;
+ }
+ } else if (f->type == FilterOverride::EXTERNAL) {
+ if (SUCCEEDED(LoadExternalFilter(f->path, f->clsid, &pBF))) {
+ name = f->name;
+ }
+ }
+
+ if (CComQIPtr<ISpecifyPropertyPages> pSPP = pBF) {
+ CComPropertySheet ps(name, this);
+ if (ps.AddPages(pSPP) > 0) {
+ CComPtr<IFilterGraph> pFG;
+ if (SUCCEEDED(pFG.CoCreateInstance(CLSID_FilterGraph))) {
+ pFG->AddFilter(pBF, L"");
+ }
+
+ ps.DoModal();
+ }
+ }
+ }
}
int CPPageExternalFilters::OnVKeyToItem(UINT nKey, CListBox* pListBox, UINT nIndex)
{
- if (nKey == VK_DELETE) {
- OnRemoveFilter();
- return -2;
- }
+ if (nKey == VK_DELETE) {
+ OnRemoveFilter();
+ return -2;
+ }
- return __super::OnVKeyToItem(nKey, pListBox, nIndex);
+ return __super::OnVKeyToItem(nKey, pListBox, nIndex);
}
void CPPageExternalFilters::OnAddMajorType()
{
- FilterOverride* f = GetCurFilter();
- if (!f) {
- return;
- }
+ FilterOverride* f = GetCurFilter();
+ if (!f) {
+ return;
+ }
- CAtlArray<GUID> guids;
- SetupMajorTypes(guids);
+ CAtlArray<GUID> guids;
+ SetupMajorTypes(guids);
- CSelectMediaType dlg(guids, MEDIATYPE_NULL, this);
- if (dlg.DoModal() == IDOK) {
- POSITION pos = f->guids.GetHeadPosition();
- while (pos) {
- if (f->guids.GetNext(pos) == dlg.m_guid) {
- AfxMessageBox(IDS_EXTERNAL_FILTERS_ERROR_MT, MB_ICONEXCLAMATION | MB_OK, 0);
- return;
- }
- f->guids.GetNext(pos);
- }
+ CSelectMediaType dlg(guids, MEDIATYPE_NULL, this);
+ if (dlg.DoModal() == IDOK) {
+ POSITION pos = f->guids.GetHeadPosition();
+ while (pos) {
+ if (f->guids.GetNext(pos) == dlg.m_guid) {
+ AfxMessageBox(IDS_EXTERNAL_FILTERS_ERROR_MT, MB_ICONEXCLAMATION | MB_OK, 0);
+ return;
+ }
+ f->guids.GetNext(pos);
+ }
- f->guids.AddTail(dlg.m_guid);
- pos = f->guids.GetTailPosition();
- f->guids.AddTail(GUID_NULL);
+ f->guids.AddTail(dlg.m_guid);
+ pos = f->guids.GetTailPosition();
+ f->guids.AddTail(GUID_NULL);
- CString major = GetMediaTypeName(dlg.m_guid);
- CString sub = GetMediaTypeName(GUID_NULL);
+ CString major = GetMediaTypeName(dlg.m_guid);
+ CString sub = GetMediaTypeName(GUID_NULL);
- HTREEITEM node = m_tree.InsertItem(major);
- m_tree.SetItemData(node, NULL);
+ HTREEITEM node = m_tree.InsertItem(major);
+ m_tree.SetItemData(node, NULL);
- node = m_tree.InsertItem(sub, node);
- m_tree.SetItemData(node, (DWORD_PTR)pos);
+ node = m_tree.InsertItem(sub, node);
+ m_tree.SetItemData(node, (DWORD_PTR)pos);
- SetModified();
- }
+ SetModified();
+ }
}
void CPPageExternalFilters::OnAddSubType()
{
- FilterOverride* f = GetCurFilter();
- if (!f) {
- return;
- }
+ FilterOverride* f = GetCurFilter();
+ if (!f) {
+ return;
+ }
- HTREEITEM node = m_tree.GetSelectedItem();
- if (!node) {
- return;
- }
+ HTREEITEM node = m_tree.GetSelectedItem();
+ if (!node) {
+ return;
+ }
- HTREEITEM child = m_tree.GetChildItem(node);
- if (!child) {
- return;
- }
+ HTREEITEM child = m_tree.GetChildItem(node);
+ if (!child) {
+ return;
+ }
- POSITION pos = (POSITION)m_tree.GetItemData(child);
- GUID major = f->guids.GetAt(pos);
+ POSITION pos = (POSITION)m_tree.GetItemData(child);
+ GUID major = f->guids.GetAt(pos);
- CAtlArray<GUID> guids;
- SetupSubTypes(guids);
+ CAtlArray<GUID> guids;
+ SetupSubTypes(guids);
- CSelectMediaType dlg(guids, MEDIASUBTYPE_NULL, this);
- if (dlg.DoModal() == IDOK) {
- for (child = m_tree.GetChildItem(node); child; child = m_tree.GetNextSiblingItem(child)) {
- pos = (POSITION)m_tree.GetItemData(child);
- f->guids.GetNext(pos);
- if (f->guids.GetAt(pos) == dlg.m_guid) {
- AfxMessageBox(IDS_EXTERNAL_FILTERS_ERROR_MT, MB_ICONEXCLAMATION | MB_OK, 0);
- return;
- }
- }
+ CSelectMediaType dlg(guids, MEDIASUBTYPE_NULL, this);
+ if (dlg.DoModal() == IDOK) {
+ for (child = m_tree.GetChildItem(node); child; child = m_tree.GetNextSiblingItem(child)) {
+ pos = (POSITION)m_tree.GetItemData(child);
+ f->guids.GetNext(pos);
+ if (f->guids.GetAt(pos) == dlg.m_guid) {
+ AfxMessageBox(IDS_EXTERNAL_FILTERS_ERROR_MT, MB_ICONEXCLAMATION | MB_OK, 0);
+ return;
+ }
+ }
- f->guids.AddTail(major);
- pos = f->guids.GetTailPosition();
- f->guids.AddTail(dlg.m_guid);
+ f->guids.AddTail(major);
+ pos = f->guids.GetTailPosition();
+ f->guids.AddTail(dlg.m_guid);
- CString sub = GetMediaTypeName(dlg.m_guid);
+ CString sub = GetMediaTypeName(dlg.m_guid);
- node = m_tree.InsertItem(sub, node);
- m_tree.SetItemData(node, (DWORD_PTR)pos);
+ node = m_tree.InsertItem(sub, node);
+ m_tree.SetItemData(node, (DWORD_PTR)pos);
- SetModified();
- }
+ SetModified();
+ }
}
void CPPageExternalFilters::OnDeleteType()
{
- if (FilterOverride* f = GetCurFilter()) {
- HTREEITEM node = m_tree.GetSelectedItem();
- if (!node) {
- return;
- }
+ if (FilterOverride* f = GetCurFilter()) {
+ HTREEITEM node = m_tree.GetSelectedItem();
+ if (!node) {
+ return;
+ }
- POSITION pos = (POSITION)m_tree.GetItemData(node);
+ POSITION pos = (POSITION)m_tree.GetItemData(node);
- if (pos == NULL) {
- for (HTREEITEM child = m_tree.GetChildItem(node); child; child = m_tree.GetNextSiblingItem(child)) {
- pos = (POSITION)m_tree.GetItemData(child);
+ if (pos == NULL) {
+ for (HTREEITEM child = m_tree.GetChildItem(node); child; child = m_tree.GetNextSiblingItem(child)) {
+ pos = (POSITION)m_tree.GetItemData(child);
- POSITION pos1 = pos;
- f->guids.GetNext(pos);
- POSITION pos2 = pos;
- f->guids.GetNext(pos);
+ POSITION pos1 = pos;
+ f->guids.GetNext(pos);
+ POSITION pos2 = pos;
+ f->guids.GetNext(pos);
- f->guids.RemoveAt(pos1);
- f->guids.RemoveAt(pos2);
- }
+ f->guids.RemoveAt(pos1);
+ f->guids.RemoveAt(pos2);
+ }
- m_tree.DeleteItem(node);
- } else {
- HTREEITEM parent = m_tree.GetParentItem(node);
+ m_tree.DeleteItem(node);
+ } else {
+ HTREEITEM parent = m_tree.GetParentItem(node);
- POSITION pos1 = pos;
- f->guids.GetNext(pos);
- POSITION pos2 = pos;
- f->guids.GetNext(pos);
+ POSITION pos1 = pos;
+ f->guids.GetNext(pos);
+ POSITION pos2 = pos;
+ f->guids.GetNext(pos);
- m_tree.DeleteItem(node);
+ m_tree.DeleteItem(node);
- if (!m_tree.ItemHasChildren(parent)) {
- f->guids.SetAt(pos2, GUID_NULL);
- node = m_tree.InsertItem(GetMediaTypeName(GUID_NULL), parent);
- m_tree.SetItemData(node, (DWORD_PTR)pos1);
- } else {
- f->guids.RemoveAt(pos1);
- f->guids.RemoveAt(pos2);
- }
- }
+ if (!m_tree.ItemHasChildren(parent)) {
+ f->guids.SetAt(pos2, GUID_NULL);
+ node = m_tree.InsertItem(GetMediaTypeName(GUID_NULL), parent);
+ m_tree.SetItemData(node, (DWORD_PTR)pos1);
+ } else {
+ f->guids.RemoveAt(pos1);
+ f->guids.RemoveAt(pos2);
+ }
+ }
- SetModified();
- }
+ SetModified();
+ }
}
void CPPageExternalFilters::OnResetTypes()
{
- if (FilterOverride* f = GetCurFilter()) {
- if (f->type == FilterOverride::REGISTERED) {
- CFGFilterRegistry fgf(f->dispname);
- if (!fgf.GetName().IsEmpty()) {
- f->guids.RemoveAll();
- f->backup.RemoveAll();
+ if (FilterOverride* f = GetCurFilter()) {
+ if (f->type == FilterOverride::REGISTERED) {
+ CFGFilterRegistry fgf(f->dispname);
+ if (!fgf.GetName().IsEmpty()) {
+ f->guids.RemoveAll();
+ f->backup.RemoveAll();
- f->guids.AddTailList(&fgf.GetTypes());
- f->backup.AddTailList(&fgf.GetTypes());
- } else {
- f->guids.RemoveAll();
- f->guids.AddTailList(&f->backup);
- }
- } else {
- f->guids.RemoveAll();
- f->guids.AddTailList(&f->backup);
- }
+ f->guids.AddTailList(&fgf.GetTypes());
+ f->backup.AddTailList(&fgf.GetTypes());
+ } else {
+ f->guids.RemoveAll();
+ f->guids.AddTailList(&f->backup);
+ }
+ } else {
+ f->guids.RemoveAll();
+ f->guids.AddTailList(&f->backup);
+ }
- m_pLastSelFilter = NULL;
- OnLbnSelchangeList1();
+ m_pLastSelFilter = NULL;
+ OnLbnSelchangeList1();
- SetModified();
- }
+ SetModified();
+ }
}
void CPPageExternalFilters::OnLbnSelchangeList1()
{
- if (FilterOverride* f = GetCurFilter()) {
- if (m_pLastSelFilter == f) {
- return;
- }
- m_pLastSelFilter = f;
+ if (FilterOverride* f = GetCurFilter()) {
+ if (m_pLastSelFilter == f) {
+ return;
+ }
+ m_pLastSelFilter = f;
- m_iLoadType = f->iLoadType;
- UpdateData(FALSE);
- m_dwMerit = f->dwMerit;
+ m_iLoadType = f->iLoadType;
+ UpdateData(FALSE);
+ m_dwMerit = f->dwMerit;
- HTREEITEM dummy_item = m_tree.InsertItem(_T(""), 0,0, NULL, TVI_FIRST);
- if (dummy_item)
- for (HTREEITEM item = m_tree.GetNextVisibleItem(dummy_item); item; item = m_tree.GetNextVisibleItem(dummy_item)) {
- m_tree.DeleteItem(item);
- }
+ HTREEITEM dummy_item = m_tree.InsertItem(_T(""), 0, 0, NULL, TVI_FIRST);
+ if (dummy_item)
+ for (HTREEITEM item = m_tree.GetNextVisibleItem(dummy_item); item; item = m_tree.GetNextVisibleItem(dummy_item)) {
+ m_tree.DeleteItem(item);
+ }
- CMapStringToPtr map;
+ CMapStringToPtr map;
- POSITION pos = f->guids.GetHeadPosition();
- while (pos) {
- POSITION tmp = pos;
- CString major = GetMediaTypeName(f->guids.GetNext(pos));
- CString sub = GetMediaTypeName(f->guids.GetNext(pos));
+ POSITION pos = f->guids.GetHeadPosition();
+ while (pos) {
+ POSITION tmp = pos;
+ CString major = GetMediaTypeName(f->guids.GetNext(pos));
+ CString sub = GetMediaTypeName(f->guids.GetNext(pos));
- HTREEITEM node = NULL;
+ HTREEITEM node = NULL;
- void* val = NULL;
- if (map.Lookup(major, val)) {
- node = (HTREEITEM)val;
- } else {
- map[major] = node = m_tree.InsertItem(major);
- }
- m_tree.SetItemData(node, NULL);
+ void* val = NULL;
+ if (map.Lookup(major, val)) {
+ node = (HTREEITEM)val;
+ } else {
+ map[major] = node = m_tree.InsertItem(major);
+ }
+ m_tree.SetItemData(node, NULL);
- node = m_tree.InsertItem(sub, node);
- m_tree.SetItemData(node, (DWORD_PTR)tmp);
- }
+ node = m_tree.InsertItem(sub, node);
+ m_tree.SetItemData(node, (DWORD_PTR)tmp);
+ }
- m_tree.DeleteItem(dummy_item);
+ m_tree.DeleteItem(dummy_item);
- for (HTREEITEM item = m_tree.GetFirstVisibleItem(); item; item = m_tree.GetNextVisibleItem(item)) {
- m_tree.Expand(item, TVE_EXPAND);
- }
+ for (HTREEITEM item = m_tree.GetFirstVisibleItem(); item; item = m_tree.GetNextVisibleItem(item)) {
+ m_tree.Expand(item, TVE_EXPAND);
+ }
- m_tree.EnsureVisible(m_tree.GetRootItem());
- } else {
- m_pLastSelFilter = NULL;
+ m_tree.EnsureVisible(m_tree.GetRootItem());
+ } else {
+ m_pLastSelFilter = NULL;
- m_iLoadType = FilterOverride::PREFERRED;
- UpdateData(FALSE);
- m_dwMerit = 0;
+ m_iLoadType = FilterOverride::PREFERRED;
+ UpdateData(FALSE);
+ m_dwMerit = 0;
- m_tree.DeleteAllItems();
- }
+ m_tree.DeleteAllItems();
+ }
}
void CPPageExternalFilters::OnCheckChangeList1()
{
- SetModified();
+ SetModified();
}
void CPPageExternalFilters::OnBnClickedRadio()
{
- UpdateData();
+ UpdateData();
- FilterOverride* f = GetCurFilter();
- if (f && f->iLoadType != m_iLoadType) {
- f->iLoadType = m_iLoadType;
+ FilterOverride* f = GetCurFilter();
+ if (f && f->iLoadType != m_iLoadType) {
+ f->iLoadType = m_iLoadType;
- SetModified();
- }
+ SetModified();
+ }
}
void CPPageExternalFilters::OnEnChangeEdit1()
{
- UpdateData();
- if (FilterOverride* f = GetCurFilter()) {
- DWORD dw;
- if (m_dwMerit.GetDWORD(dw) && f->dwMerit != dw) {
- f->dwMerit = dw;
+ UpdateData();
+ if (FilterOverride* f = GetCurFilter()) {
+ DWORD dw;
+ if (m_dwMerit.GetDWORD(dw) && f->dwMerit != dw) {
+ f->dwMerit = dw;
- SetModified();
- }
- }
+ SetModified();
+ }
+ }
}
-void CPPageExternalFilters::OnNMDblclkTree2(NMHDR *pNMHDR, LRESULT *pResult)
+void CPPageExternalFilters::OnNMDblclkTree2(NMHDR* pNMHDR, LRESULT* pResult)
{
- *pResult = 0;
+ *pResult = 0;
- if (FilterOverride* f = GetCurFilter()) {
- HTREEITEM node = m_tree.GetSelectedItem();
- if (!node) {
- return;
- }
+ if (FilterOverride* f = GetCurFilter()) {
+ HTREEITEM node = m_tree.GetSelectedItem();
+ if (!node) {
+ return;
+ }
- POSITION pos = (POSITION)m_tree.GetItemData(node);
- if (!pos) {
- return;
- }
+ POSITION pos = (POSITION)m_tree.GetItemData(node);
+ if (!pos) {
+ return;
+ }
- f->guids.GetNext(pos);
- if (!pos) {
- return;
- }
+ f->guids.GetNext(pos);
+ if (!pos) {
+ return;
+ }
- CAtlArray<GUID> guids;
- SetupSubTypes(guids);
+ CAtlArray<GUID> guids;
+ SetupSubTypes(guids);
- CSelectMediaType dlg(guids, f->guids.GetAt(pos), this);
- if (dlg.DoModal() == IDOK) {
- f->guids.SetAt(pos, dlg.m_guid);
- m_tree.SetItemText(node, GetMediaTypeName(dlg.m_guid));
+ CSelectMediaType dlg(guids, f->guids.GetAt(pos), this);
+ if (dlg.DoModal() == IDOK) {
+ f->guids.SetAt(pos, dlg.m_guid);
+ m_tree.SetItemText(node, GetMediaTypeName(dlg.m_guid));
- SetModified();
- }
- }
+ SetModified();
+ }
+ }
}
-void CPPageExternalFilters::OnTVNKeyDownTree2(NMHDR *pNMHDR, LRESULT *pResult)
+void CPPageExternalFilters::OnTVNKeyDownTree2(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMTVKEYDOWN pTVKeyDown = reinterpret_cast<LPNMTVKEYDOWN>(pNMHDR);
+ LPNMTVKEYDOWN pTVKeyDown = reinterpret_cast<LPNMTVKEYDOWN>(pNMHDR);
- if (pTVKeyDown->wVKey == VK_DELETE) {
- OnDeleteType();
- }
+ if (pTVKeyDown->wVKey == VK_DELETE) {
+ OnDeleteType();
+ }
- *pResult = 0;
+ *pResult = 0;
}
void CPPageExternalFilters::OnDropFiles(HDROP hDropInfo)
{
- SetActiveWindow();
-
- UINT nFiles = ::DragQueryFile(hDropInfo, (UINT)-1, NULL, 0);
- for (UINT iFile = 0; iFile < nFiles; iFile++) {
- TCHAR szFileName[_MAX_PATH];
- ::DragQueryFile(hDropInfo, iFile, szFileName, _MAX_PATH);
-
- CFilterMapper2 fm2(false);
- fm2.Register(szFileName);
-
- while (!fm2.m_filters.IsEmpty()) {
- if (FilterOverride* f = fm2.m_filters.RemoveHead()) {
- CAutoPtr<FilterOverride> p(f);
- int i = m_filters.AddString(f->name);
- m_filters.SetItemDataPtr(i, m_pFilters.AddTail(p));
- m_filters.SetCheck(i, 1);
-
- if (fm2.m_filters.IsEmpty()) {
- m_filters.SetCurSel(i);
- OnLbnSelchangeList1();
- }
-
- SetModified();
- }
- }
- }
- ::DragFinish(hDropInfo);
+ SetActiveWindow();
+
+ UINT nFiles = ::DragQueryFile(hDropInfo, (UINT) - 1, NULL, 0);
+ for (UINT iFile = 0; iFile < nFiles; iFile++) {
+ TCHAR szFileName[_MAX_PATH];
+ ::DragQueryFile(hDropInfo, iFile, szFileName, _MAX_PATH);
+
+ CFilterMapper2 fm2(false);
+ fm2.Register(szFileName);
+
+ while (!fm2.m_filters.IsEmpty()) {
+ if (FilterOverride* f = fm2.m_filters.RemoveHead()) {
+ CAutoPtr<FilterOverride> p(f);
+ int i = m_filters.AddString(f->name);
+ m_filters.SetItemDataPtr(i, m_pFilters.AddTail(p));
+ m_filters.SetCheck(i, 1);
+
+ if (fm2.m_filters.IsEmpty()) {
+ m_filters.SetCurSel(i);
+ OnLbnSelchangeList1();
+ }
+
+ SetModified();
+ }
+ }
+ }
+ ::DragFinish(hDropInfo);
}
diff --git a/src/mpc-hc/PPageExternalFilters.h b/src/mpc-hc/PPageExternalFilters.h
index e0b7808e6..3af8e2c10 100644
--- a/src/mpc-hc/PPageExternalFilters.h
+++ b/src/mpc-hc/PPageExternalFilters.h
@@ -32,60 +32,60 @@
class CPPageExternalFilters : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageExternalFilters)
+ DECLARE_DYNAMIC(CPPageExternalFilters)
private:
- void StepUp(CCheckListBox& list);
- void StepDown(CCheckListBox& list);
+ void StepUp(CCheckListBox& list);
+ void StepDown(CCheckListBox& list);
- CAutoPtrList<FilterOverride> m_pFilters;
- FilterOverride* m_pLastSelFilter;
- FilterOverride* GetCurFilter();
+ CAutoPtrList<FilterOverride> m_pFilters;
+ FilterOverride* m_pLastSelFilter;
+ FilterOverride* GetCurFilter();
- void SetupMajorTypes(CAtlArray<GUID>& guids);
- void SetupSubTypes(CAtlArray<GUID>& guids);
+ void SetupMajorTypes(CAtlArray<GUID>& guids);
+ void SetupSubTypes(CAtlArray<GUID>& guids);
public:
- CPPageExternalFilters();
- virtual ~CPPageExternalFilters();
+ CPPageExternalFilters();
+ virtual ~CPPageExternalFilters();
- // Dialog Data
- enum { IDD = IDD_PPAGEEXTERNALFILTERS };
+ // Dialog Data
+ enum { IDD = IDD_PPAGEEXTERNALFILTERS };
- CCheckListBox m_filters;
- int m_iLoadType;
- CHexEdit m_dwMerit;
- CTreeCtrl m_tree;
+ CCheckListBox m_filters;
+ int m_iLoadType;
+ CHexEdit m_dwMerit;
+ CTreeCtrl m_tree;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnUpdateFilter(CCmdUI* pCmdUI);
- afx_msg void OnUpdateFilterUp(CCmdUI* pCmdUI);
- afx_msg void OnUpdateFilterDown(CCmdUI* pCmdUI);
- afx_msg void OnUpdateFilterMerit(CCmdUI* pCmdUI);
- afx_msg void OnUpdateSubType(CCmdUI* pCmdUI);
- afx_msg void OnUpdateDeleteType(CCmdUI* pCmdUI);
- afx_msg void OnAddRegistered();
- afx_msg void OnRemoveFilter();
- afx_msg void OnMoveFilterUp();
- afx_msg void OnMoveFilterDown();
- afx_msg void OnLbnDblclkFilter();
- afx_msg int OnVKeyToItem(UINT nKey, CListBox* pListBox, UINT nIndex);
- afx_msg void OnAddMajorType();
- afx_msg void OnAddSubType();
- afx_msg void OnDeleteType();
- afx_msg void OnResetTypes();
- afx_msg void OnLbnSelchangeList1();
- afx_msg void OnCheckChangeList1();
- afx_msg void OnBnClickedRadio();
- afx_msg void OnEnChangeEdit1();
- afx_msg void OnNMDblclkTree2(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnTVNKeyDownTree2(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnDropFiles(HDROP hDropInfo);
+ afx_msg void OnUpdateFilter(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateFilterUp(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateFilterDown(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateFilterMerit(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateSubType(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateDeleteType(CCmdUI* pCmdUI);
+ afx_msg void OnAddRegistered();
+ afx_msg void OnRemoveFilter();
+ afx_msg void OnMoveFilterUp();
+ afx_msg void OnMoveFilterDown();
+ afx_msg void OnLbnDblclkFilter();
+ afx_msg int OnVKeyToItem(UINT nKey, CListBox* pListBox, UINT nIndex);
+ afx_msg void OnAddMajorType();
+ afx_msg void OnAddSubType();
+ afx_msg void OnDeleteType();
+ afx_msg void OnResetTypes();
+ afx_msg void OnLbnSelchangeList1();
+ afx_msg void OnCheckChangeList1();
+ afx_msg void OnBnClickedRadio();
+ afx_msg void OnEnChangeEdit1();
+ afx_msg void OnNMDblclkTree2(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnTVNKeyDownTree2(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnDropFiles(HDROP hDropInfo);
};
diff --git a/src/mpc-hc/PPageFileInfoClip.cpp b/src/mpc-hc/PPageFileInfoClip.cpp
index 384aa887c..b6805ccf7 100644
--- a/src/mpc-hc/PPageFileInfoClip.cpp
+++ b/src/mpc-hc/PPageFileInfoClip.cpp
@@ -34,61 +34,61 @@
IMPLEMENT_DYNAMIC(CPPageFileInfoClip, CPropertyPage)
CPPageFileInfoClip::CPPageFileInfoClip(CString fn, IFilterGraph* pFG)
- : CPropertyPage(CPPageFileInfoClip::IDD, CPPageFileInfoClip::IDD)
- , m_fn(fn)
- , m_pFG(pFG)
- , m_clip(ResStr(IDS_AG_NONE))
- , m_author(ResStr(IDS_AG_NONE))
- , m_copyright(ResStr(IDS_AG_NONE))
- , m_rating(ResStr(IDS_AG_NONE))
- , m_location_str(ResStr(IDS_AG_NONE))
- , m_hIcon(NULL)
+ : CPropertyPage(CPPageFileInfoClip::IDD, CPPageFileInfoClip::IDD)
+ , m_fn(fn)
+ , m_pFG(pFG)
+ , m_clip(ResStr(IDS_AG_NONE))
+ , m_author(ResStr(IDS_AG_NONE))
+ , m_copyright(ResStr(IDS_AG_NONE))
+ , m_rating(ResStr(IDS_AG_NONE))
+ , m_location_str(ResStr(IDS_AG_NONE))
+ , m_hIcon(NULL)
{
}
CPPageFileInfoClip::~CPPageFileInfoClip()
{
- if (m_hIcon) {
- DestroyIcon(m_hIcon);
- }
+ if (m_hIcon) {
+ DestroyIcon(m_hIcon);
+ }
}
BOOL CPPageFileInfoClip::PreTranslateMessage(MSG* pMsg)
{
- if (pMsg->message == WM_LBUTTONDBLCLK && pMsg->hwnd == m_location.m_hWnd && !m_location_str.IsEmpty()) {
- CString path = m_location_str;
- if (path[path.GetLength() - 1] != '\\') {
- path += _T("\\");
- }
- path += m_fn;
+ if (pMsg->message == WM_LBUTTONDBLCLK && pMsg->hwnd == m_location.m_hWnd && !m_location_str.IsEmpty()) {
+ CString path = m_location_str;
+ if (path[path.GetLength() - 1] != '\\') {
+ path += _T("\\");
+ }
+ path += m_fn;
- if (ExploreToFile(path)) {
- return TRUE;
- }
- }
+ if (ExploreToFile(path)) {
+ return TRUE;
+ }
+ }
- m_tooltip.RelayEvent(pMsg);
+ m_tooltip.RelayEvent(pMsg);
- return __super::PreTranslateMessage(pMsg);
+ return __super::PreTranslateMessage(pMsg);
}
void CPPageFileInfoClip::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_DEFAULTICON, m_icon);
- DDX_Text(pDX, IDC_EDIT1, m_fn);
- DDX_Text(pDX, IDC_EDIT4, m_clip);
- DDX_Text(pDX, IDC_EDIT3, m_author);
- DDX_Text(pDX, IDC_EDIT2, m_copyright);
- DDX_Text(pDX, IDC_EDIT5, m_rating);
- DDX_Control(pDX, IDC_EDIT6, m_location);
- DDX_Control(pDX, IDC_EDIT7, m_desc);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_DEFAULTICON, m_icon);
+ DDX_Text(pDX, IDC_EDIT1, m_fn);
+ DDX_Text(pDX, IDC_EDIT4, m_clip);
+ DDX_Text(pDX, IDC_EDIT3, m_author);
+ DDX_Text(pDX, IDC_EDIT2, m_copyright);
+ DDX_Text(pDX, IDC_EDIT5, m_rating);
+ DDX_Control(pDX, IDC_EDIT6, m_location);
+ DDX_Control(pDX, IDC_EDIT7, m_desc);
}
#define SETPAGEFOCUS WM_APP+252 // arbitrary number, can be changed if necessary
BEGIN_MESSAGE_MAP(CPPageFileInfoClip, CPropertyPage)
- ON_MESSAGE(SETPAGEFOCUS, OnSetPageFocus)
+ ON_MESSAGE(SETPAGEFOCUS, OnSetPageFocus)
END_MESSAGE_MAP()
@@ -96,99 +96,99 @@ END_MESSAGE_MAP()
BOOL CPPageFileInfoClip::OnInitDialog()
{
- __super::OnInitDialog();
-
- if (m_fn == _T("")) {
- BeginEnumFilters(m_pFG, pEF, pBF) {
- CComQIPtr<IFileSourceFilter> pFSF = pBF;
- if (pFSF) {
- LPOLESTR pFN = NULL;
- AM_MEDIA_TYPE mt;
- if (SUCCEEDED(pFSF->GetCurFile(&pFN, &mt)) && pFN && *pFN) {
- m_fn = CStringW(pFN);
- CoTaskMemFree(pFN);
- }
- break;
- }
- }
- EndEnumFilters
- }
-
- m_hIcon = LoadIcon(m_fn, false);
- if (m_hIcon) {
- m_icon.SetIcon(m_hIcon);
- }
-
- m_fn.TrimRight('/');
- int i = max(m_fn.ReverseFind('\\'), m_fn.ReverseFind('/'));
- if (i >= 0 && i < m_fn.GetLength()-1) {
- m_location_str = m_fn.Left(i);
- m_fn = m_fn.Mid(i+1);
-
- if (m_location_str.GetLength() == 2 && m_location_str[1] == ':') {
- m_location_str += '\\';
- }
- }
- m_location.SetWindowText(m_location_str);
-
- bool fEmpty = true;
- BeginEnumFilters(m_pFG, pEF, pBF) {
- if (CComQIPtr<IAMMediaContent, &IID_IAMMediaContent> pAMMC = pBF) {
- CComBSTR bstr;
- if (SUCCEEDED(pAMMC->get_Title(&bstr)) && wcslen(bstr.m_str) > 0) {
- m_clip = bstr.m_str;
- fEmpty = false;
- }
- if (SUCCEEDED(pAMMC->get_AuthorName(&bstr)) && wcslen(bstr.m_str) > 0) {
- m_author = bstr.m_str;
- fEmpty = false;
- }
- if (SUCCEEDED(pAMMC->get_Copyright(&bstr)) && wcslen(bstr.m_str) > 0) {
- m_copyright = bstr.m_str;
- fEmpty = false;
- }
- if (SUCCEEDED(pAMMC->get_Rating(&bstr)) && wcslen(bstr.m_str) > 0) {
- m_rating = bstr.m_str;
- fEmpty = false;
- }
- if (SUCCEEDED(pAMMC->get_Description(&bstr)) && wcslen(bstr.m_str) > 0) {
- m_desc.SetWindowText(CString(bstr.m_str));
- fEmpty = false;
- }
- if (!fEmpty) {
- break;
- }
- }
- }
- EndEnumFilters;
-
- m_tooltip.Create(this, TTS_NOPREFIX | TTS_ALWAYSTIP);
-
- m_tooltip.SetDelayTime(TTDT_INITIAL, 0);
- m_tooltip.SetDelayTime(TTDT_AUTOPOP, 2500);
- m_tooltip.SetDelayTime(TTDT_RESHOW, 0);
-
- m_tooltip.AddTool(&m_location, IDS_TOOLTIP_EXPLORE_TO_FILE);
-
- UpdateData(FALSE);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ if (m_fn == _T("")) {
+ BeginEnumFilters(m_pFG, pEF, pBF) {
+ CComQIPtr<IFileSourceFilter> pFSF = pBF;
+ if (pFSF) {
+ LPOLESTR pFN = NULL;
+ AM_MEDIA_TYPE mt;
+ if (SUCCEEDED(pFSF->GetCurFile(&pFN, &mt)) && pFN && *pFN) {
+ m_fn = CStringW(pFN);
+ CoTaskMemFree(pFN);
+ }
+ break;
+ }
+ }
+ EndEnumFilters
+ }
+
+ m_hIcon = LoadIcon(m_fn, false);
+ if (m_hIcon) {
+ m_icon.SetIcon(m_hIcon);
+ }
+
+ m_fn.TrimRight('/');
+ int i = max(m_fn.ReverseFind('\\'), m_fn.ReverseFind('/'));
+ if (i >= 0 && i < m_fn.GetLength() - 1) {
+ m_location_str = m_fn.Left(i);
+ m_fn = m_fn.Mid(i + 1);
+
+ if (m_location_str.GetLength() == 2 && m_location_str[1] == ':') {
+ m_location_str += '\\';
+ }
+ }
+ m_location.SetWindowText(m_location_str);
+
+ bool fEmpty = true;
+ BeginEnumFilters(m_pFG, pEF, pBF) {
+ if (CComQIPtr<IAMMediaContent, &IID_IAMMediaContent> pAMMC = pBF) {
+ CComBSTR bstr;
+ if (SUCCEEDED(pAMMC->get_Title(&bstr)) && wcslen(bstr.m_str) > 0) {
+ m_clip = bstr.m_str;
+ fEmpty = false;
+ }
+ if (SUCCEEDED(pAMMC->get_AuthorName(&bstr)) && wcslen(bstr.m_str) > 0) {
+ m_author = bstr.m_str;
+ fEmpty = false;
+ }
+ if (SUCCEEDED(pAMMC->get_Copyright(&bstr)) && wcslen(bstr.m_str) > 0) {
+ m_copyright = bstr.m_str;
+ fEmpty = false;
+ }
+ if (SUCCEEDED(pAMMC->get_Rating(&bstr)) && wcslen(bstr.m_str) > 0) {
+ m_rating = bstr.m_str;
+ fEmpty = false;
+ }
+ if (SUCCEEDED(pAMMC->get_Description(&bstr)) && wcslen(bstr.m_str) > 0) {
+ m_desc.SetWindowText(CString(bstr.m_str));
+ fEmpty = false;
+ }
+ if (!fEmpty) {
+ break;
+ }
+ }
+ }
+ EndEnumFilters;
+
+ m_tooltip.Create(this, TTS_NOPREFIX | TTS_ALWAYSTIP);
+
+ m_tooltip.SetDelayTime(TTDT_INITIAL, 0);
+ m_tooltip.SetDelayTime(TTDT_AUTOPOP, 2500);
+ m_tooltip.SetDelayTime(TTDT_RESHOW, 0);
+
+ m_tooltip.AddTool(&m_location, IDS_TOOLTIP_EXPLORE_TO_FILE);
+
+ UpdateData(FALSE);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageFileInfoClip::OnSetActive()
{
- BOOL ret = __super::OnSetActive();
+ BOOL ret = __super::OnSetActive();
- PostMessage(SETPAGEFOCUS, 0, 0L);
+ PostMessage(SETPAGEFOCUS, 0, 0L);
- return ret;
+ return ret;
}
LRESULT CPPageFileInfoClip::OnSetPageFocus(WPARAM wParam, LPARAM lParam)
{
- CPropertySheet* psheet = (CPropertySheet*) GetParent();
- psheet->GetTabControl()->SetFocus();
+ CPropertySheet* psheet = (CPropertySheet*) GetParent();
+ psheet->GetTabControl()->SetFocus();
- return 0;
+ return 0;
} \ No newline at end of file
diff --git a/src/mpc-hc/PPageFileInfoClip.h b/src/mpc-hc/PPageFileInfoClip.h
index c5db5c997..1d432da6c 100644
--- a/src/mpc-hc/PPageFileInfoClip.h
+++ b/src/mpc-hc/PPageFileInfoClip.h
@@ -30,40 +30,40 @@
class CPPageFileInfoClip : public CPropertyPage
{
- DECLARE_DYNAMIC(CPPageFileInfoClip)
+ DECLARE_DYNAMIC(CPPageFileInfoClip)
private:
- CComPtr<IFilterGraph> m_pFG;
- HICON m_hIcon;
+ CComPtr<IFilterGraph> m_pFG;
+ HICON m_hIcon;
- CToolTipCtrl m_tooltip;
+ CToolTipCtrl m_tooltip;
public:
- CPPageFileInfoClip(CString fn, IFilterGraph* pFG);
- virtual ~CPPageFileInfoClip();
+ CPPageFileInfoClip(CString fn, IFilterGraph* pFG);
+ virtual ~CPPageFileInfoClip();
- // Dialog Data
- enum { IDD = IDD_FILEPROPCLIP };
+ // Dialog Data
+ enum { IDD = IDD_FILEPROPCLIP };
- CStatic m_icon;
- CString m_fn;
- CString m_clip;
- CString m_author;
- CString m_copyright;
- CString m_rating;
- CString m_location_str;
- CEdit m_location;
- CEdit m_desc;
+ CStatic m_icon;
+ CString m_fn;
+ CString m_clip;
+ CString m_author;
+ CString m_copyright;
+ CString m_rating;
+ CString m_location_str;
+ CEdit m_location;
+ CEdit m_desc;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- virtual BOOL OnSetActive();
- virtual LRESULT OnSetPageFocus(WPARAM wParam, LPARAM lParam);
- BOOL OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL OnSetActive();
+ virtual LRESULT OnSetPageFocus(WPARAM wParam, LPARAM lParam);
+ BOOL OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
};
diff --git a/src/mpc-hc/PPageFileInfoDetails.cpp b/src/mpc-hc/PPageFileInfoDetails.cpp
index 87281a4a1..a3e1f27ac 100644
--- a/src/mpc-hc/PPageFileInfoDetails.cpp
+++ b/src/mpc-hc/PPageFileInfoDetails.cpp
@@ -35,281 +35,281 @@
IMPLEMENT_DYNAMIC(CPPageFileInfoDetails, CPropertyPage)
CPPageFileInfoDetails::CPPageFileInfoDetails(CString fn, IFilterGraph* pFG, ISubPicAllocatorPresenter* pCAP)
- : CPropertyPage(CPPageFileInfoDetails::IDD, CPPageFileInfoDetails::IDD)
- , m_fn(fn)
- , m_pFG(pFG)
- , m_pCAP(pCAP)
- , m_hIcon(NULL)
- , m_type(ResStr(IDS_AG_NOT_KNOWN))
- , m_size(ResStr(IDS_AG_NOT_KNOWN))
- , m_time(ResStr(IDS_AG_NOT_KNOWN))
- , m_res(ResStr(IDS_AG_NOT_KNOWN))
- , m_created(ResStr(IDS_AG_NOT_KNOWN))
+ : CPropertyPage(CPPageFileInfoDetails::IDD, CPPageFileInfoDetails::IDD)
+ , m_fn(fn)
+ , m_pFG(pFG)
+ , m_pCAP(pCAP)
+ , m_hIcon(NULL)
+ , m_type(ResStr(IDS_AG_NOT_KNOWN))
+ , m_size(ResStr(IDS_AG_NOT_KNOWN))
+ , m_time(ResStr(IDS_AG_NOT_KNOWN))
+ , m_res(ResStr(IDS_AG_NOT_KNOWN))
+ , m_created(ResStr(IDS_AG_NOT_KNOWN))
{
}
CPPageFileInfoDetails::~CPPageFileInfoDetails()
{
- if (m_hIcon) {
- DestroyIcon(m_hIcon);
- }
+ if (m_hIcon) {
+ DestroyIcon(m_hIcon);
+ }
}
void CPPageFileInfoDetails::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_DEFAULTICON, m_icon);
- DDX_Text(pDX, IDC_EDIT1, m_fn);
- DDX_Text(pDX, IDC_EDIT4, m_type);
- DDX_Text(pDX, IDC_EDIT3, m_size);
- DDX_Text(pDX, IDC_EDIT2, m_time);
- DDX_Text(pDX, IDC_EDIT5, m_res);
- DDX_Text(pDX, IDC_EDIT6, m_created);
- DDX_Control(pDX, IDC_EDIT7, m_encoding);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_DEFAULTICON, m_icon);
+ DDX_Text(pDX, IDC_EDIT1, m_fn);
+ DDX_Text(pDX, IDC_EDIT4, m_type);
+ DDX_Text(pDX, IDC_EDIT3, m_size);
+ DDX_Text(pDX, IDC_EDIT2, m_time);
+ DDX_Text(pDX, IDC_EDIT5, m_res);
+ DDX_Text(pDX, IDC_EDIT6, m_created);
+ DDX_Control(pDX, IDC_EDIT7, m_encoding);
}
#define SETPAGEFOCUS WM_APP+252 // arbitrary number, can be changed if necessary
BEGIN_MESSAGE_MAP(CPPageFileInfoDetails, CPropertyPage)
- ON_MESSAGE(SETPAGEFOCUS, OnSetPageFocus)
+ ON_MESSAGE(SETPAGEFOCUS, OnSetPageFocus)
END_MESSAGE_MAP()
// CPPageFileInfoDetails message handlers
static bool GetProperty(IFilterGraph* pFG, LPCOLESTR propName, VARIANT* vt)
{
- BeginEnumFilters(pFG, pEF, pBF) {
- if (CComQIPtr<IPropertyBag> pPB = pBF)
- if (SUCCEEDED(pPB->Read(propName, vt, NULL))) {
- return true;
- }
- }
- EndEnumFilters;
-
- return false;
+ BeginEnumFilters(pFG, pEF, pBF) {
+ if (CComQIPtr<IPropertyBag> pPB = pBF)
+ if (SUCCEEDED(pPB->Read(propName, vt, NULL))) {
+ return true;
+ }
+ }
+ EndEnumFilters;
+
+ return false;
}
static CString FormatDateTime(FILETIME tm)
{
- SYSTEMTIME st;
- FileTimeToSystemTime(&tm, &st);
- TCHAR buff[256];
- GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, buff, 256);
- CString ret(buff);
- ret += _T(" ");
- GetTimeFormat(LOCALE_USER_DEFAULT, 0, &st, NULL, buff, 256);
- ret += buff;
- return ret;
+ SYSTEMTIME st;
+ FileTimeToSystemTime(&tm, &st);
+ TCHAR buff[256];
+ GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, buff, 256);
+ CString ret(buff);
+ ret += _T(" ");
+ GetTimeFormat(LOCALE_USER_DEFAULT, 0, &st, NULL, buff, 256);
+ ret += buff;
+ return ret;
}
BOOL CPPageFileInfoDetails::OnInitDialog()
{
- __super::OnInitDialog();
-
- if (m_fn == _T("")) {
- BeginEnumFilters(m_pFG, pEF, pBF) {
- CComQIPtr<IFileSourceFilter> pFSF = pBF;
- if (pFSF) {
- LPOLESTR pFN = NULL;
- AM_MEDIA_TYPE mt;
- if (SUCCEEDED(pFSF->GetCurFile(&pFN, &mt)) && pFN && *pFN) {
- m_fn = CStringW(pFN);
- CoTaskMemFree(pFN);
- }
- break;
- }
- }
- EndEnumFilters
- }
-
- CString ext = m_fn.Left(m_fn.Find(_T("://"))+1).TrimRight(':');
- if (ext.IsEmpty() || !ext.CompareNoCase(_T("file"))) {
- ext = _T(".") + m_fn.Mid(m_fn.ReverseFind('.')+1);
- }
-
- m_hIcon = LoadIcon(m_fn, false);
- if (m_hIcon) {
- m_icon.SetIcon(m_hIcon);
- }
-
- if (!LoadType(ext, m_type)) {
- m_type.LoadString(IDS_AG_NOT_KNOWN);
- }
-
- CComVariant vt;
- if (::GetProperty(m_pFG, L"CurFile.TimeCreated", &vt)) {
- if (V_VT(&vt) == VT_UI8) {
- ULARGE_INTEGER uli;
- uli.QuadPart = V_UI8(&vt);
-
- FILETIME ft;
- ft.dwLowDateTime = uli.LowPart;
- ft.dwHighDateTime = uli.HighPart;
-
- m_created = FormatDateTime(ft);
- }
- }
-
- WIN32_FIND_DATA wfd;
- HANDLE hFind = FindFirstFile(m_fn, &wfd);
- if (hFind != INVALID_HANDLE_VALUE) {
- FindClose(hFind);
-
- __int64 size = (__int64(wfd.nFileSizeHigh)<<32)|wfd.nFileSizeLow;
- const int MAX_FILE_SIZE_BUFFER = 65;
- WCHAR szFileSize[MAX_FILE_SIZE_BUFFER];
- StrFormatByteSizeW(size, szFileSize, MAX_FILE_SIZE_BUFFER);
- m_size.Format(_T("%s (%I64d bytes)"), szFileSize, size);
-
- if (m_created.IsEmpty()) {
- m_created = FormatDateTime(wfd.ftCreationTime);
- }
- }
-
- REFERENCE_TIME rtDur = 0;
- CComQIPtr<IMediaSeeking> pMS = m_pFG;
- if (pMS && SUCCEEDED(pMS->GetDuration(&rtDur)) && rtDur > 0) {
- m_time = ReftimeToString2(rtDur);
- }
-
- CSize wh(0, 0), arxy(0, 0);
-
- if (m_pCAP) {
- wh = m_pCAP->GetVideoSize(false);
- arxy = m_pCAP->GetVideoSize(true);
- } else {
- if (CComQIPtr<IBasicVideo> pBV = m_pFG) {
- if (SUCCEEDED(pBV->GetVideoSize(&wh.cx, &wh.cy))) {
- if (CComQIPtr<IBasicVideo2> pBV2 = m_pFG) {
- pBV2->GetPreferredAspectRatio(&arxy.cx, &arxy.cy);
- }
- } else {
- wh.SetSize(0, 0);
- }
- }
-
- if (wh.cx == 0 && wh.cy == 0) {
- BeginEnumFilters(m_pFG, pEF, pBF) {
- if (CComQIPtr<IBasicVideo> pBV = pBF) {
- pBV->GetVideoSize(&wh.cx, &wh.cy);
- if (CComQIPtr<IBasicVideo2> pBV2 = pBF) {
- pBV2->GetPreferredAspectRatio(&arxy.cx, &arxy.cy);
- }
- break;
- } else if (CComQIPtr<IVMRWindowlessControl> pWC = pBF) {
- pWC->GetNativeVideoSize(&wh.cx, &wh.cy, &arxy.cx, &arxy.cy);
- break;
- } else if (CComQIPtr<IVMRWindowlessControl9> pWC = pBF) {
- pWC->GetNativeVideoSize(&wh.cx, &wh.cy, &arxy.cx, &arxy.cy);
- break;
- }
- }
- EndEnumFilters;
- }
- }
-
- if (wh.cx > 0 && wh.cy > 0) {
- m_res.Format(_T("%dx%d"), wh.cx, wh.cy);
-
- int lnko = LNKO(arxy.cx, arxy.cy);
- if (lnko > 1) {
- arxy.cx /= lnko, arxy.cy /= lnko;
- }
-
- if (arxy.cx > 0 && arxy.cy > 0 && arxy.cx*wh.cy != arxy.cy*wh.cx) {
- CString ar;
- ar.Format(_T(" (AR %d:%d)"), arxy.cx, arxy.cy);
- m_res += ar;
- }
- }
-
- m_fn.TrimRight('/');
- m_fn.Replace('\\', '/');
- m_fn = m_fn.Mid(m_fn.ReverseFind('/')+1);
-
- UpdateData(FALSE);
-
- InitEncoding();
-
- m_pFG = NULL;
- m_pCAP = NULL;
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ if (m_fn == _T("")) {
+ BeginEnumFilters(m_pFG, pEF, pBF) {
+ CComQIPtr<IFileSourceFilter> pFSF = pBF;
+ if (pFSF) {
+ LPOLESTR pFN = NULL;
+ AM_MEDIA_TYPE mt;
+ if (SUCCEEDED(pFSF->GetCurFile(&pFN, &mt)) && pFN && *pFN) {
+ m_fn = CStringW(pFN);
+ CoTaskMemFree(pFN);
+ }
+ break;
+ }
+ }
+ EndEnumFilters
+ }
+
+ CString ext = m_fn.Left(m_fn.Find(_T("://")) + 1).TrimRight(':');
+ if (ext.IsEmpty() || !ext.CompareNoCase(_T("file"))) {
+ ext = _T(".") + m_fn.Mid(m_fn.ReverseFind('.') + 1);
+ }
+
+ m_hIcon = LoadIcon(m_fn, false);
+ if (m_hIcon) {
+ m_icon.SetIcon(m_hIcon);
+ }
+
+ if (!LoadType(ext, m_type)) {
+ m_type.LoadString(IDS_AG_NOT_KNOWN);
+ }
+
+ CComVariant vt;
+ if (::GetProperty(m_pFG, L"CurFile.TimeCreated", &vt)) {
+ if (V_VT(&vt) == VT_UI8) {
+ ULARGE_INTEGER uli;
+ uli.QuadPart = V_UI8(&vt);
+
+ FILETIME ft;
+ ft.dwLowDateTime = uli.LowPart;
+ ft.dwHighDateTime = uli.HighPart;
+
+ m_created = FormatDateTime(ft);
+ }
+ }
+
+ WIN32_FIND_DATA wfd;
+ HANDLE hFind = FindFirstFile(m_fn, &wfd);
+ if (hFind != INVALID_HANDLE_VALUE) {
+ FindClose(hFind);
+
+ __int64 size = (__int64(wfd.nFileSizeHigh) << 32) | wfd.nFileSizeLow;
+ const int MAX_FILE_SIZE_BUFFER = 65;
+ WCHAR szFileSize[MAX_FILE_SIZE_BUFFER];
+ StrFormatByteSizeW(size, szFileSize, MAX_FILE_SIZE_BUFFER);
+ m_size.Format(_T("%s (%I64d bytes)"), szFileSize, size);
+
+ if (m_created.IsEmpty()) {
+ m_created = FormatDateTime(wfd.ftCreationTime);
+ }
+ }
+
+ REFERENCE_TIME rtDur = 0;
+ CComQIPtr<IMediaSeeking> pMS = m_pFG;
+ if (pMS && SUCCEEDED(pMS->GetDuration(&rtDur)) && rtDur > 0) {
+ m_time = ReftimeToString2(rtDur);
+ }
+
+ CSize wh(0, 0), arxy(0, 0);
+
+ if (m_pCAP) {
+ wh = m_pCAP->GetVideoSize(false);
+ arxy = m_pCAP->GetVideoSize(true);
+ } else {
+ if (CComQIPtr<IBasicVideo> pBV = m_pFG) {
+ if (SUCCEEDED(pBV->GetVideoSize(&wh.cx, &wh.cy))) {
+ if (CComQIPtr<IBasicVideo2> pBV2 = m_pFG) {
+ pBV2->GetPreferredAspectRatio(&arxy.cx, &arxy.cy);
+ }
+ } else {
+ wh.SetSize(0, 0);
+ }
+ }
+
+ if (wh.cx == 0 && wh.cy == 0) {
+ BeginEnumFilters(m_pFG, pEF, pBF) {
+ if (CComQIPtr<IBasicVideo> pBV = pBF) {
+ pBV->GetVideoSize(&wh.cx, &wh.cy);
+ if (CComQIPtr<IBasicVideo2> pBV2 = pBF) {
+ pBV2->GetPreferredAspectRatio(&arxy.cx, &arxy.cy);
+ }
+ break;
+ } else if (CComQIPtr<IVMRWindowlessControl> pWC = pBF) {
+ pWC->GetNativeVideoSize(&wh.cx, &wh.cy, &arxy.cx, &arxy.cy);
+ break;
+ } else if (CComQIPtr<IVMRWindowlessControl9> pWC = pBF) {
+ pWC->GetNativeVideoSize(&wh.cx, &wh.cy, &arxy.cx, &arxy.cy);
+ break;
+ }
+ }
+ EndEnumFilters;
+ }
+ }
+
+ if (wh.cx > 0 && wh.cy > 0) {
+ m_res.Format(_T("%dx%d"), wh.cx, wh.cy);
+
+ int lnko = LNKO(arxy.cx, arxy.cy);
+ if (lnko > 1) {
+ arxy.cx /= lnko, arxy.cy /= lnko;
+ }
+
+ if (arxy.cx > 0 && arxy.cy > 0 && arxy.cx * wh.cy != arxy.cy * wh.cx) {
+ CString ar;
+ ar.Format(_T(" (AR %d:%d)"), arxy.cx, arxy.cy);
+ m_res += ar;
+ }
+ }
+
+ m_fn.TrimRight('/');
+ m_fn.Replace('\\', '/');
+ m_fn = m_fn.Mid(m_fn.ReverseFind('/') + 1);
+
+ UpdateData(FALSE);
+
+ InitEncoding();
+
+ m_pFG = NULL;
+ m_pCAP = NULL;
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageFileInfoDetails::OnSetActive()
{
- BOOL ret = __super::OnSetActive();
- PostMessage(SETPAGEFOCUS, 0, 0L);
- return ret;
+ BOOL ret = __super::OnSetActive();
+ PostMessage(SETPAGEFOCUS, 0, 0L);
+ return ret;
}
LRESULT CPPageFileInfoDetails::OnSetPageFocus(WPARAM wParam, LPARAM lParam)
{
- CPropertySheet* psheet = (CPropertySheet*) GetParent();
- psheet->GetTabControl()->SetFocus();
- return 0;
+ CPropertySheet* psheet = (CPropertySheet*) GetParent();
+ psheet->GetTabControl()->SetFocus();
+ return 0;
}
void CPPageFileInfoDetails::InitEncoding()
{
- CAtlList<CString> sl;
-
- BeginEnumFilters(m_pFG, pEF, pBF) {
- CComPtr<IBaseFilter> pUSBF = GetUpStreamFilter(pBF);
-
- if (GetCLSID(pBF) == CLSID_NetShowSource) {
- continue;
- } else if (GetCLSID(pUSBF) != CLSID_NetShowSource) {
- if (IPin* pPin = GetFirstPin(pBF, PINDIR_INPUT)) {
- CMediaType mt;
- if (FAILED(pPin->ConnectionMediaType(&mt)) || mt.majortype != MEDIATYPE_Stream) {
- continue;
- }
- }
-
- if (IPin* pPin = GetFirstPin(pBF, PINDIR_OUTPUT)) {
- CMediaType mt;
- if (SUCCEEDED(pPin->ConnectionMediaType(&mt)) && mt.majortype == MEDIATYPE_Stream) {
- continue;
- }
- }
- }
-
- BeginEnumPins(pBF, pEP, pPin) {
- CMediaTypeEx mt;
- PIN_DIRECTION dir;
- if (FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_OUTPUT
- || FAILED(pPin->ConnectionMediaType(&mt))) {
- continue;
- }
-
- CString str = mt.ToString();
-
- if (!str.IsEmpty()) {
- if (mt.majortype == MEDIATYPE_Video) { // Sort streams, set Video streams at head
- bool found_video = false;
- for (POSITION pos = sl.GetTailPosition(); pos; sl.GetPrev(pos)) {
- CString Item = sl.GetAt(pos);
- if (!Item.Find(_T("Video:"))) {
- sl.InsertAfter(pos, str + CString(L" [" + GetPinName(pPin) + L"]"));
- found_video = true;
- break;
- }
- }
- if (!found_video) {
- sl.AddHead(str + CString(L" [" + GetPinName(pPin) + L"]"));
- }
- } else {
- sl.AddTail(str + CString(L" [" + GetPinName(pPin) + L"]"));
- }
- }
- }
- EndEnumPins;
- }
- EndEnumFilters;
-
- CString text = Implode(sl, '\n');
- text.Replace(_T("\n"), _T("\r\n"));
- m_encoding.SetWindowText(text);
+ CAtlList<CString> sl;
+
+ BeginEnumFilters(m_pFG, pEF, pBF) {
+ CComPtr<IBaseFilter> pUSBF = GetUpStreamFilter(pBF);
+
+ if (GetCLSID(pBF) == CLSID_NetShowSource) {
+ continue;
+ } else if (GetCLSID(pUSBF) != CLSID_NetShowSource) {
+ if (IPin* pPin = GetFirstPin(pBF, PINDIR_INPUT)) {
+ CMediaType mt;
+ if (FAILED(pPin->ConnectionMediaType(&mt)) || mt.majortype != MEDIATYPE_Stream) {
+ continue;
+ }
+ }
+
+ if (IPin* pPin = GetFirstPin(pBF, PINDIR_OUTPUT)) {
+ CMediaType mt;
+ if (SUCCEEDED(pPin->ConnectionMediaType(&mt)) && mt.majortype == MEDIATYPE_Stream) {
+ continue;
+ }
+ }
+ }
+
+ BeginEnumPins(pBF, pEP, pPin) {
+ CMediaTypeEx mt;
+ PIN_DIRECTION dir;
+ if (FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_OUTPUT
+ || FAILED(pPin->ConnectionMediaType(&mt))) {
+ continue;
+ }
+
+ CString str = mt.ToString();
+
+ if (!str.IsEmpty()) {
+ if (mt.majortype == MEDIATYPE_Video) { // Sort streams, set Video streams at head
+ bool found_video = false;
+ for (POSITION pos = sl.GetTailPosition(); pos; sl.GetPrev(pos)) {
+ CString Item = sl.GetAt(pos);
+ if (!Item.Find(_T("Video:"))) {
+ sl.InsertAfter(pos, str + CString(L" [" + GetPinName(pPin) + L"]"));
+ found_video = true;
+ break;
+ }
+ }
+ if (!found_video) {
+ sl.AddHead(str + CString(L" [" + GetPinName(pPin) + L"]"));
+ }
+ } else {
+ sl.AddTail(str + CString(L" [" + GetPinName(pPin) + L"]"));
+ }
+ }
+ }
+ EndEnumPins;
+ }
+ EndEnumFilters;
+
+ CString text = Implode(sl, '\n');
+ text.Replace(_T("\n"), _T("\r\n"));
+ m_encoding.SetWindowText(text);
}
diff --git a/src/mpc-hc/PPageFileInfoDetails.h b/src/mpc-hc/PPageFileInfoDetails.h
index 151355517..2a5cc4e2f 100644
--- a/src/mpc-hc/PPageFileInfoDetails.h
+++ b/src/mpc-hc/PPageFileInfoDetails.h
@@ -31,39 +31,39 @@
class CPPageFileInfoDetails : public CPropertyPage
{
- DECLARE_DYNAMIC(CPPageFileInfoDetails)
+ DECLARE_DYNAMIC(CPPageFileInfoDetails)
private:
- CComPtr<IFilterGraph> m_pFG;
- CComPtr<ISubPicAllocatorPresenter> m_pCAP;
+ CComPtr<IFilterGraph> m_pFG;
+ CComPtr<ISubPicAllocatorPresenter> m_pCAP;
- HICON m_hIcon;
+ HICON m_hIcon;
- void InitEncoding();
+ void InitEncoding();
public:
- CPPageFileInfoDetails(CString fn, IFilterGraph* pFG, ISubPicAllocatorPresenter* pCAP);
- virtual ~CPPageFileInfoDetails();
+ CPPageFileInfoDetails(CString fn, IFilterGraph* pFG, ISubPicAllocatorPresenter* pCAP);
+ virtual ~CPPageFileInfoDetails();
- // Dialog Data
- enum { IDD = IDD_FILEPROPDETAILS };
+ // Dialog Data
+ enum { IDD = IDD_FILEPROPDETAILS };
- CStatic m_icon;
- CString m_fn;
- CString m_type;
- CString m_size;
- CString m_time;
- CString m_res;
- CString m_created;
- CEdit m_encoding;
+ CStatic m_icon;
+ CString m_fn;
+ CString m_type;
+ CString m_size;
+ CString m_time;
+ CString m_res;
+ CString m_created;
+ CEdit m_encoding;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnSetActive();
- virtual LRESULT OnSetPageFocus(WPARAM wParam, LPARAM lParam);
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnSetActive();
+ virtual LRESULT OnSetPageFocus(WPARAM wParam, LPARAM lParam);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
};
diff --git a/src/mpc-hc/PPageFileInfoRes.cpp b/src/mpc-hc/PPageFileInfoRes.cpp
index b8b2b9f6d..69c4cdebe 100644
--- a/src/mpc-hc/PPageFileInfoRes.cpp
+++ b/src/mpc-hc/PPageFileInfoRes.cpp
@@ -30,125 +30,125 @@
IMPLEMENT_DYNAMIC(CPPageFileInfoRes, CPPageBase)
CPPageFileInfoRes::CPPageFileInfoRes(CString fn, IFilterGraph* pFG)
- : CPPageBase(CPPageFileInfoRes::IDD, CPPageFileInfoRes::IDD)
- , m_fn(fn)
- , m_hIcon(NULL)
- , m_pFG(pFG)
+ : CPPageBase(CPPageFileInfoRes::IDD, CPPageFileInfoRes::IDD)
+ , m_fn(fn)
+ , m_hIcon(NULL)
+ , m_pFG(pFG)
{
}
CPPageFileInfoRes::~CPPageFileInfoRes()
{
- if (m_hIcon) {
- DestroyIcon(m_hIcon);
- }
+ if (m_hIcon) {
+ DestroyIcon(m_hIcon);
+ }
}
void CPPageFileInfoRes::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_DEFAULTICON, m_icon);
- DDX_Text(pDX, IDC_EDIT1, m_fn);
- DDX_Control(pDX, IDC_LIST1, m_list);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_DEFAULTICON, m_icon);
+ DDX_Text(pDX, IDC_EDIT1, m_fn);
+ DDX_Control(pDX, IDC_LIST1, m_list);
}
BEGIN_MESSAGE_MAP(CPPageFileInfoRes, CPPageBase)
- ON_BN_CLICKED(IDC_BUTTON1, OnSaveAs)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateSaveAs)
- ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnNMDblclkList1)
+ ON_BN_CLICKED(IDC_BUTTON1, OnSaveAs)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateSaveAs)
+ ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnNMDblclkList1)
END_MESSAGE_MAP()
// CPPageFileInfoRes message handlers
BOOL CPPageFileInfoRes::OnInitDialog()
{
- __super::OnInitDialog();
-
- m_hIcon = LoadIcon(m_fn, false);
- if (m_hIcon) {
- m_icon.SetIcon(m_hIcon);
- }
-
- m_fn.TrimRight('/');
- int i = max(m_fn.ReverseFind('\\'), m_fn.ReverseFind('/'));
- if (i >= 0 && i < m_fn.GetLength()-1) {
- m_fn = m_fn.Mid(i+1);
- }
-
- m_list.SetExtendedStyle(m_list.GetExtendedStyle()|LVS_EX_FULLROWSELECT);
-
- m_list.InsertColumn(0, _T("Name"), LVCFMT_LEFT, 187);
- m_list.InsertColumn(1, _T("Mime Type"), LVCFMT_LEFT, 127);
-
- BeginEnumFilters(m_pFG, pEF, pBF) {
- if (CComQIPtr<IDSMResourceBag> pRB = pBF)
- if (pRB && pRB->ResGetCount() > 0) {
- for (DWORD i = 0; i < pRB->ResGetCount(); i++) {
- CComBSTR name, desc, mime;
- BYTE* pData = NULL;
- DWORD len = 0;
- if (SUCCEEDED(pRB->ResGet(i, &name, &desc, &mime, &pData, &len, NULL))) {
- CDSMResource r;
- r.name = name;
- r.desc = desc;
- r.mime = mime;
- r.data.SetCount(len);
- memcpy(r.data.GetData(), pData, r.data.GetCount());
- CoTaskMemFree(pData);
- POSITION pos = m_res.AddTail(r);
- int iItem = m_list.InsertItem(m_list.GetItemCount(), CString(name));
- m_list.SetItemText(iItem, 1, CString(mime));
- m_list.SetItemData(iItem, (DWORD_PTR)pos);
- }
- }
- }
- }
- EndEnumFilters;
-
- UpdateData(FALSE);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ m_hIcon = LoadIcon(m_fn, false);
+ if (m_hIcon) {
+ m_icon.SetIcon(m_hIcon);
+ }
+
+ m_fn.TrimRight('/');
+ int i = max(m_fn.ReverseFind('\\'), m_fn.ReverseFind('/'));
+ if (i >= 0 && i < m_fn.GetLength() - 1) {
+ m_fn = m_fn.Mid(i + 1);
+ }
+
+ m_list.SetExtendedStyle(m_list.GetExtendedStyle() | LVS_EX_FULLROWSELECT);
+
+ m_list.InsertColumn(0, _T("Name"), LVCFMT_LEFT, 187);
+ m_list.InsertColumn(1, _T("Mime Type"), LVCFMT_LEFT, 127);
+
+ BeginEnumFilters(m_pFG, pEF, pBF) {
+ if (CComQIPtr<IDSMResourceBag> pRB = pBF)
+ if (pRB && pRB->ResGetCount() > 0) {
+ for (DWORD i = 0; i < pRB->ResGetCount(); i++) {
+ CComBSTR name, desc, mime;
+ BYTE* pData = NULL;
+ DWORD len = 0;
+ if (SUCCEEDED(pRB->ResGet(i, &name, &desc, &mime, &pData, &len, NULL))) {
+ CDSMResource r;
+ r.name = name;
+ r.desc = desc;
+ r.mime = mime;
+ r.data.SetCount(len);
+ memcpy(r.data.GetData(), pData, r.data.GetCount());
+ CoTaskMemFree(pData);
+ POSITION pos = m_res.AddTail(r);
+ int iItem = m_list.InsertItem(m_list.GetItemCount(), CString(name));
+ m_list.SetItemText(iItem, 1, CString(mime));
+ m_list.SetItemData(iItem, (DWORD_PTR)pos);
+ }
+ }
+ }
+ }
+ EndEnumFilters;
+
+ UpdateData(FALSE);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CPPageFileInfoRes::OnSaveAs()
{
- int i = m_list.GetSelectionMark();
- if (i < 0) {
- return;
- }
-
- CDSMResource& r = m_res.GetAt((POSITION)m_list.GetItemData(i));
-
- CFileDialog fd(FALSE, NULL, CString(r.name),
- OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_NOCHANGEDIR,
- _T("All files|*.*||"), this, 0);
- if (fd.DoModal() == IDOK) {
- FILE* f = NULL;
- if (!_tfopen_s(&f, fd.GetPathName(), _T("wb"))) {
- fwrite(r.data.GetData(), 1, r.data.GetCount(), f);
- fclose(f);
- }
- }
+ int i = m_list.GetSelectionMark();
+ if (i < 0) {
+ return;
+ }
+
+ CDSMResource& r = m_res.GetAt((POSITION)m_list.GetItemData(i));
+
+ CFileDialog fd(FALSE, NULL, CString(r.name),
+ OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR,
+ _T("All files|*.*||"), this, 0);
+ if (fd.DoModal() == IDOK) {
+ FILE* f = NULL;
+ if (!_tfopen_s(&f, fd.GetPathName(), _T("wb"))) {
+ fwrite(r.data.GetData(), 1, r.data.GetCount(), f);
+ fclose(f);
+ }
+ }
}
void CPPageFileInfoRes::OnUpdateSaveAs(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_list.GetSelectedCount());
+ pCmdUI->Enable(m_list.GetSelectedCount());
}
-void CPPageFileInfoRes::OnNMDblclkList1(NMHDR *pNMHDR, LRESULT *pResult)
+void CPPageFileInfoRes::OnNMDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
{
- int i = m_list.GetSelectionMark();
- if (i < 0) {
- return;
- }
+ int i = m_list.GetSelectionMark();
+ if (i < 0) {
+ return;
+ }
- CDSMResource& r = m_res.GetAt((POSITION)m_list.GetItemData(i));
+ CDSMResource& r = m_res.GetAt((POSITION)m_list.GetItemData(i));
- CString url;
- url.Format(_T("http://localhost:%d/convres.html?id=%Ix"), AfxGetAppSettings().nWebServerPort, reinterpret_cast<uintptr_t>(&r));
- ShellExecute(NULL, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
+ CString url;
+ url.Format(_T("http://localhost:%d/convres.html?id=%Ix"), AfxGetAppSettings().nWebServerPort, reinterpret_cast<uintptr_t>(&r));
+ ShellExecute(NULL, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
- *pResult = 0;
+ *pResult = 0;
}
diff --git a/src/mpc-hc/PPageFileInfoRes.h b/src/mpc-hc/PPageFileInfoRes.h
index fa11cb2a2..6956b3e4b 100644
--- a/src/mpc-hc/PPageFileInfoRes.h
+++ b/src/mpc-hc/PPageFileInfoRes.h
@@ -33,32 +33,32 @@
class CPPageFileInfoRes : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageFileInfoRes)
+ DECLARE_DYNAMIC(CPPageFileInfoRes)
private:
- CComPtr<IFilterGraph> m_pFG;
- HICON m_hIcon;
- CAtlList<CDSMResource> m_res;
+ CComPtr<IFilterGraph> m_pFG;
+ HICON m_hIcon;
+ CAtlList<CDSMResource> m_res;
public:
- CPPageFileInfoRes(CString fn, IFilterGraph* pFG); // standard constructor
- virtual ~CPPageFileInfoRes();
+ CPPageFileInfoRes(CString fn, IFilterGraph* pFG); // standard constructor
+ virtual ~CPPageFileInfoRes();
- // Dialog Data
- enum { IDD = IDD_FILEPROPRES };
+ // Dialog Data
+ enum { IDD = IDD_FILEPROPRES };
- CStatic m_icon;
- CString m_fn;
- CListCtrl m_list;
+ CStatic m_icon;
+ CString m_fn;
+ CListCtrl m_list;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnSaveAs();
- afx_msg void OnUpdateSaveAs(CCmdUI* pCmdUI);
- afx_msg void OnNMDblclkList1(NMHDR *pNMHDR, LRESULT *pResult);
+ afx_msg void OnSaveAs();
+ afx_msg void OnUpdateSaveAs(CCmdUI* pCmdUI);
+ afx_msg void OnNMDblclkList1(NMHDR* pNMHDR, LRESULT* pResult);
};
diff --git a/src/mpc-hc/PPageFileInfoSheet.cpp b/src/mpc-hc/PPageFileInfoSheet.cpp
index 8dbe1351f..a0005b6f9 100644
--- a/src/mpc-hc/PPageFileInfoSheet.cpp
+++ b/src/mpc-hc/PPageFileInfoSheet.cpp
@@ -32,29 +32,29 @@
IMPLEMENT_DYNAMIC(CPPageFileInfoSheet, CPropertySheet)
CPPageFileInfoSheet::CPPageFileInfoSheet(CString fn, CMainFrame* pMainFrame, CWnd* pParentWnd)
- : CPropertySheet(ResStr(IDS_PROPSHEET_PROPERTIES), pParentWnd, 0)
- , m_clip(fn, pMainFrame->pGB)
- , m_details(fn, pMainFrame->pGB, pMainFrame->m_pCAP)
- , m_res(fn, pMainFrame->pGB)
- , m_mi(fn, pMainFrame->pGB)
- , m_fn(fn)
+ : CPropertySheet(ResStr(IDS_PROPSHEET_PROPERTIES), pParentWnd, 0)
+ , m_clip(fn, pMainFrame->pGB)
+ , m_details(fn, pMainFrame->pGB, pMainFrame->m_pCAP)
+ , m_res(fn, pMainFrame->pGB)
+ , m_mi(fn, pMainFrame->pGB)
+ , m_fn(fn)
{
- AddPage(&m_details);
- AddPage(&m_clip);
-
- BeginEnumFilters(pMainFrame->pGB, pEF, pBF) {
- if (CComQIPtr<IDSMResourceBag> pRB = pBF)
- if (pRB && pRB->ResGetCount() > 0) {
- AddPage(&m_res);
- break;
- }
- }
- EndEnumFilters;
+ AddPage(&m_details);
+ AddPage(&m_clip);
+
+ BeginEnumFilters(pMainFrame->pGB, pEF, pBF) {
+ if (CComQIPtr<IDSMResourceBag> pRB = pBF)
+ if (pRB && pRB->ResGetCount() > 0) {
+ AddPage(&m_res);
+ break;
+ }
+ }
+ EndEnumFilters;
#ifndef USE_MEDIAINFO_STATIC
- if (CPPageFileMediaInfo::HasMediaInfo())
+ if (CPPageFileMediaInfo::HasMediaInfo())
#endif
- AddPage(&m_mi);
+ AddPage(&m_mi);
}
CPPageFileInfoSheet::~CPPageFileInfoSheet()
@@ -63,55 +63,55 @@ CPPageFileInfoSheet::~CPPageFileInfoSheet()
BEGIN_MESSAGE_MAP(CPPageFileInfoSheet, CPropertySheet)
- ON_BN_CLICKED(IDC_BUTTON_MI, OnSaveAs)
+ ON_BN_CLICKED(IDC_BUTTON_MI, OnSaveAs)
END_MESSAGE_MAP()
// CPPageFileInfoSheet message handlers
BOOL CPPageFileInfoSheet::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- m_fn.TrimRight('/');
- int i = max(m_fn.ReverseFind('\\'), m_fn.ReverseFind('/'));
- if (i >= 0 && i < m_fn.GetLength()-1) {
- m_fn = m_fn.Mid(i+1);
- }
- m_fn = m_fn + _T(".MediaInfo.txt");
+ m_fn.TrimRight('/');
+ int i = max(m_fn.ReverseFind('\\'), m_fn.ReverseFind('/'));
+ if (i >= 0 && i < m_fn.GetLength() - 1) {
+ m_fn = m_fn.Mid(i + 1);
+ }
+ m_fn = m_fn + _T(".MediaInfo.txt");
- GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE);
- GetDlgItem(ID_APPLY_NOW)->ShowWindow(SW_HIDE);
- GetDlgItem(IDOK)->SetWindowText(ResStr(IDS_AG_CLOSE));
+ GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE);
+ GetDlgItem(ID_APPLY_NOW)->ShowWindow(SW_HIDE);
+ GetDlgItem(IDOK)->SetWindowText(ResStr(IDS_AG_CLOSE));
- CRect r;
- GetDlgItem(ID_APPLY_NOW)->GetWindowRect(&r);
- ScreenToClient(r);
- GetDlgItem(IDOK)->MoveWindow(r);
+ CRect r;
+ GetDlgItem(ID_APPLY_NOW)->GetWindowRect(&r);
+ ScreenToClient(r);
+ GetDlgItem(IDOK)->MoveWindow(r);
- r.MoveToX(5);
- r.right += 10;
- m_Button_MI.Create(ResStr(IDS_AG_SAVE_AS), WS_CHILD|BS_PUSHBUTTON|WS_VISIBLE, r, this, IDC_BUTTON_MI);
- m_Button_MI.SetFont(GetFont());
- m_Button_MI.ShowWindow(SW_HIDE);
+ r.MoveToX(5);
+ r.right += 10;
+ m_Button_MI.Create(ResStr(IDS_AG_SAVE_AS), WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE, r, this, IDC_BUTTON_MI);
+ m_Button_MI.SetFont(GetFont());
+ m_Button_MI.ShowWindow(SW_HIDE);
- GetTabControl()->SetFocus();
+ GetTabControl()->SetFocus();
- return FALSE; // return TRUE unless you set the focus to a control
+ return FALSE; // return TRUE unless you set the focus to a control
}
void CPPageFileInfoSheet::OnSaveAs()
{
- CFileDialog filedlg (FALSE, _T("*.txt"), m_fn,
- OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST|OFN_NOCHANGEDIR,
- _T("Text Files (*.txt)|*.txt|All Files (*.*)|*.*||"), NULL);
-
- if (filedlg.DoModal() == IDOK) { // user has chosen a file, so
- TCHAR bom = (TCHAR)0xFEFF;
- CFile mFile;
- if (mFile.Open(filedlg.GetPathName(), CFile::modeCreate | CFile::modeWrite)) {
- mFile.Write(&bom, sizeof(TCHAR));
- mFile.Write(LPCTSTR(m_mi.MI_Text), m_mi.MI_Text.GetLength()*sizeof(TCHAR));
- mFile.Close();
- }
- }
+ CFileDialog filedlg(FALSE, _T("*.txt"), m_fn,
+ OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR,
+ _T("Text Files (*.txt)|*.txt|All Files (*.*)|*.*||"), NULL);
+
+ if (filedlg.DoModal() == IDOK) { // user has chosen a file, so
+ TCHAR bom = (TCHAR)0xFEFF;
+ CFile mFile;
+ if (mFile.Open(filedlg.GetPathName(), CFile::modeCreate | CFile::modeWrite)) {
+ mFile.Write(&bom, sizeof(TCHAR));
+ mFile.Write(LPCTSTR(m_mi.MI_Text), m_mi.MI_Text.GetLength()*sizeof(TCHAR));
+ mFile.Close();
+ }
+ }
}
diff --git a/src/mpc-hc/PPageFileInfoSheet.h b/src/mpc-hc/PPageFileInfoSheet.h
index 2f8cb54a8..ff4f1ffae 100644
--- a/src/mpc-hc/PPageFileInfoSheet.h
+++ b/src/mpc-hc/PPageFileInfoSheet.h
@@ -35,25 +35,25 @@ class CMainFrame;
class CPPageFileInfoSheet : public CPropertySheet
{
- DECLARE_DYNAMIC(CPPageFileInfoSheet)
+ DECLARE_DYNAMIC(CPPageFileInfoSheet)
private:
- CPPageFileInfoClip m_clip;
- CPPageFileInfoDetails m_details;
- CPPageFileInfoRes m_res;
- CPPageFileMediaInfo m_mi;
+ CPPageFileInfoClip m_clip;
+ CPPageFileInfoDetails m_details;
+ CPPageFileInfoRes m_res;
+ CPPageFileMediaInfo m_mi;
- CButton m_Button_MI;
+ CButton m_Button_MI;
public:
- CPPageFileInfoSheet(CString fn, CMainFrame* pMainFrame, CWnd* pParentWnd);
- virtual ~CPPageFileInfoSheet();
+ CPPageFileInfoSheet(CString fn, CMainFrame* pMainFrame, CWnd* pParentWnd);
+ virtual ~CPPageFileInfoSheet();
- afx_msg void OnSaveAs();
+ afx_msg void OnSaveAs();
- CString m_fn;
+ CString m_fn;
protected:
- virtual BOOL OnInitDialog();
+ virtual BOOL OnInitDialog();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
};
diff --git a/src/mpc-hc/PPageFileMediaInfo.cpp b/src/mpc-hc/PPageFileMediaInfo.cpp
index 9fe247f7f..bfd85c7ce 100644
--- a/src/mpc-hc/PPageFileMediaInfo.cpp
+++ b/src/mpc-hc/PPageFileMediaInfo.cpp
@@ -41,28 +41,28 @@ using namespace MediaInfoDLL;
IMPLEMENT_DYNAMIC(CPPageFileMediaInfo, CPropertyPage)
CPPageFileMediaInfo::CPPageFileMediaInfo(CString fn, IFilterGraph* pFG)
- : CPropertyPage(CPPageFileMediaInfo::IDD, CPPageFileMediaInfo::IDD)
- , m_fn(fn)
- , m_pFG(pFG)
- , m_pCFont(NULL)
+ : CPropertyPage(CPPageFileMediaInfo::IDD, CPPageFileMediaInfo::IDD)
+ , m_fn(fn)
+ , m_pFG(pFG)
+ , m_pCFont(NULL)
{
}
CPPageFileMediaInfo::~CPPageFileMediaInfo()
{
- delete m_pCFont;
- m_pCFont = NULL;
+ delete m_pCFont;
+ m_pCFont = NULL;
}
void CPPageFileMediaInfo::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_MIEDIT, m_mediainfo);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_MIEDIT, m_mediainfo);
}
BEGIN_MESSAGE_MAP(CPPageFileMediaInfo, CPropertyPage)
- ON_WM_SHOWWINDOW()
+ ON_WM_SHOWWINDOW()
END_MESSAGE_MAP()
// CPPageFileMediaInfo message handlers
@@ -70,101 +70,101 @@ static WNDPROC OldControlProc;
static LRESULT CALLBACK ControlProc(HWND control, UINT message, WPARAM wParam, LPARAM lParam)
{
- if (message == WM_KEYDOWN) {
- if ((LOWORD(wParam)== 'A' || LOWORD(wParam) == 'a')
- &&(GetKeyState(VK_CONTROL) < 0)) {
- CEdit *pEdit = (CEdit*)CWnd::FromHandle(control);
- pEdit->SetSel(0, pEdit->GetWindowTextLength(), TRUE);
- return 0;
- }
- }
-
- return CallWindowProc(OldControlProc, control, message, wParam, lParam); // call edit control's own windowproc
+ if (message == WM_KEYDOWN) {
+ if ((LOWORD(wParam) == 'A' || LOWORD(wParam) == 'a')
+ && (GetKeyState(VK_CONTROL) < 0)) {
+ CEdit* pEdit = (CEdit*)CWnd::FromHandle(control);
+ pEdit->SetSel(0, pEdit->GetWindowTextLength(), TRUE);
+ return 0;
+ }
+ }
+
+ return CallWindowProc(OldControlProc, control, message, wParam, lParam); // call edit control's own windowproc
}
BOOL CPPageFileMediaInfo::OnInitDialog()
{
- __super::OnInitDialog();
-
- if (!m_pCFont) {
- m_pCFont = DNew CFont;
- }
- if (!m_pCFont) {
- return TRUE;
- }
-
- if (m_fn == _T("")) {
- BeginEnumFilters(m_pFG, pEF, pBF) {
- CComQIPtr<IFileSourceFilter> pFSF = pBF;
- if (pFSF) {
- LPOLESTR pFN = NULL;
- AM_MEDIA_TYPE mt;
- if (SUCCEEDED(pFSF->GetCurFile(&pFN, &mt)) && pFN && *pFN) {
- m_fn = CStringW(pFN);
- CoTaskMemFree(pFN);
- }
- break;
- }
- }
- EndEnumFilters
- }
+ __super::OnInitDialog();
+
+ if (!m_pCFont) {
+ m_pCFont = DNew CFont;
+ }
+ if (!m_pCFont) {
+ return TRUE;
+ }
+
+ if (m_fn == _T("")) {
+ BeginEnumFilters(m_pFG, pEF, pBF) {
+ CComQIPtr<IFileSourceFilter> pFSF = pBF;
+ if (pFSF) {
+ LPOLESTR pFN = NULL;
+ AM_MEDIA_TYPE mt;
+ if (SUCCEEDED(pFSF->GetCurFile(&pFN, &mt)) && pFN && *pFN) {
+ m_fn = CStringW(pFN);
+ CoTaskMemFree(pFN);
+ }
+ break;
+ }
+ }
+ EndEnumFilters
+ }
#ifdef USE_MEDIAINFO_STATIC
- MediaInfoLib::String f_name = m_fn;
- MediaInfoLib::MediaInfo MI;
+ MediaInfoLib::String f_name = m_fn;
+ MediaInfoLib::MediaInfo MI;
#else
- MediaInfoDLL::String f_name = m_fn;
- MediaInfo MI;
+ MediaInfoDLL::String f_name = m_fn;
+ MediaInfo MI;
#endif
- MI.Open(f_name);
- MI.Option(_T("Complete"));
- MI.Option(_T("Language"), _T(" Config_Text_ColumnSize;30"));
- MI_Text = MI.Inform().c_str();
- MI.Close();
- if (!MI_Text.Find(_T("Unable to load"))) {
- MI_Text = _T("");
- }
-
- LOGFONT lf;
- memset(&lf, 0, sizeof(lf));
- lf.lfPitchAndFamily = DEFAULT_PITCH | FF_MODERN;
- // The empty string will fallback to the first font that matches the other specified attributes.
- LPCTSTR fonts[] = { _T("Lucida Console"), _T("Courier New"), _T("") };
- // Use a negative value to match the character height instead of the cell height.
- int fonts_size[] = { -10, -11, -11 };
- UINT i = 0;
- BOOL success;
- do {
- _tcscpy_s(lf.lfFaceName, fonts[i]);
- lf.lfHeight = fonts_size[i];
- success = IsFontInstalled(fonts[i]) && m_pCFont->CreateFontIndirect(&lf);
- i++;
- } while (!success && i < _countof(fonts));
- m_mediainfo.SetFont(m_pCFont);
- m_mediainfo.SetWindowText(MI_Text);
-
- // subclass the edit control
- OldControlProc = (WNDPROC)SetWindowLongPtr(m_mediainfo.m_hWnd, GWLP_WNDPROC, (LONG_PTR)ControlProc);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ MI.Open(f_name);
+ MI.Option(_T("Complete"));
+ MI.Option(_T("Language"), _T(" Config_Text_ColumnSize;30"));
+ MI_Text = MI.Inform().c_str();
+ MI.Close();
+ if (!MI_Text.Find(_T("Unable to load"))) {
+ MI_Text = _T("");
+ }
+
+ LOGFONT lf;
+ memset(&lf, 0, sizeof(lf));
+ lf.lfPitchAndFamily = DEFAULT_PITCH | FF_MODERN;
+ // The empty string will fallback to the first font that matches the other specified attributes.
+ LPCTSTR fonts[] = { _T("Lucida Console"), _T("Courier New"), _T("") };
+ // Use a negative value to match the character height instead of the cell height.
+ int fonts_size[] = { -10, -11, -11 };
+ UINT i = 0;
+ BOOL success;
+ do {
+ _tcscpy_s(lf.lfFaceName, fonts[i]);
+ lf.lfHeight = fonts_size[i];
+ success = IsFontInstalled(fonts[i]) && m_pCFont->CreateFontIndirect(&lf);
+ i++;
+ } while (!success && i < _countof(fonts));
+ m_mediainfo.SetFont(m_pCFont);
+ m_mediainfo.SetWindowText(MI_Text);
+
+ // subclass the edit control
+ OldControlProc = (WNDPROC)SetWindowLongPtr(m_mediainfo.m_hWnd, GWLP_WNDPROC, (LONG_PTR)ControlProc);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CPPageFileMediaInfo::OnShowWindow(BOOL bShow, UINT nStatus)
{
- __super::OnShowWindow(bShow, nStatus);
- if (bShow) {
- GetParent()->GetDlgItem(IDC_BUTTON_MI)->ShowWindow(SW_SHOW);
- } else {
- GetParent()->GetDlgItem(IDC_BUTTON_MI)->ShowWindow(SW_HIDE);
- }
+ __super::OnShowWindow(bShow, nStatus);
+ if (bShow) {
+ GetParent()->GetDlgItem(IDC_BUTTON_MI)->ShowWindow(SW_SHOW);
+ } else {
+ GetParent()->GetDlgItem(IDC_BUTTON_MI)->ShowWindow(SW_HIDE);
+ }
}
#ifndef USE_MEDIAINFO_STATIC
bool CPPageFileMediaInfo::HasMediaInfo()
{
- MediaInfo MI;
- return MI.IsReady();
+ MediaInfo MI;
+ return MI.IsReady();
}
#endif
diff --git a/src/mpc-hc/PPageFileMediaInfo.h b/src/mpc-hc/PPageFileMediaInfo.h
index ba9a81b04..24e997c7a 100644
--- a/src/mpc-hc/PPageFileMediaInfo.h
+++ b/src/mpc-hc/PPageFileMediaInfo.h
@@ -26,33 +26,33 @@
class CPPageFileMediaInfo : public CPropertyPage
{
- DECLARE_DYNAMIC(CPPageFileMediaInfo)
+ DECLARE_DYNAMIC(CPPageFileMediaInfo)
private:
- CComPtr<IFilterGraph> m_pFG;
+ CComPtr<IFilterGraph> m_pFG;
public:
- CPPageFileMediaInfo(CString fn, IFilterGraph* pFG);
- virtual ~CPPageFileMediaInfo();
+ CPPageFileMediaInfo(CString fn, IFilterGraph* pFG);
+ virtual ~CPPageFileMediaInfo();
- // Dialog Data
- enum { IDD = IDD_FILEMEDIAINFO };
+ // Dialog Data
+ enum { IDD = IDD_FILEMEDIAINFO };
- CEdit m_mediainfo;
- CString m_fn;
- CFont* m_pCFont;
+ CEdit m_mediainfo;
+ CString m_fn;
+ CFont* m_pCFont;
- CString MI_Text;
+ CString MI_Text;
#ifndef USE_MEDIAINFO_STATIC
- static bool HasMediaInfo();
+ static bool HasMediaInfo();
#endif
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
+ afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
};
diff --git a/src/mpc-hc/PPageFormats.cpp b/src/mpc-hc/PPageFormats.cpp
index 389973455..63c9b4570 100644
--- a/src/mpc-hc/PPageFormats.cpp
+++ b/src/mpc-hc/PPageFormats.cpp
@@ -53,22 +53,22 @@ int f_setAssociatedWithIcon = 0;
IMPLEMENT_DYNAMIC(CPPageFormats, CPPageBase)
CPPageFormats::CPPageFormats()
- : CPPageBase(CPPageFormats::IDD, CPPageFormats::IDD)
- , m_list(0)
- , m_exts(_T(""))
- , m_iRtspHandler(0)
- , m_fRtspFileExtFirst(FALSE)
- , m_bInsufficientPrivileges(false)
+ : CPPageBase(CPPageFormats::IDD, CPPageFormats::IDD)
+ , m_list(0)
+ , m_exts(_T(""))
+ , m_iRtspHandler(0)
+ , m_fRtspFileExtFirst(FALSE)
+ , m_bInsufficientPrivileges(false)
{
- if (m_pAAR == NULL) {
- // Default manager (requires at least Vista)
- HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
- NULL,
- CLSCTX_INPROC,
- __uuidof(IApplicationAssociationRegistration),
- (void**)&m_pAAR);
- UNREFERENCED_PARAMETER(hr);
- }
+ if (m_pAAR == NULL) {
+ // Default manager (requires at least Vista)
+ HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
+ NULL,
+ CLSCTX_INPROC,
+ __uuidof(IApplicationAssociationRegistration),
+ (void**)&m_pAAR);
+ UNREFERENCED_PARAMETER(hr);
+ }
}
CPPageFormats::~CPPageFormats()
@@ -77,1061 +77,1061 @@ CPPageFormats::~CPPageFormats()
void CPPageFormats::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_LIST1, m_list);
- DDX_Text(pDX, IDC_EDIT1, m_exts);
- DDX_Control(pDX, IDC_STATIC1, m_autoplay);
- DDX_Control(pDX, IDC_CHECK1, m_apvideo);
- DDX_Control(pDX, IDC_CHECK2, m_apmusic);
- DDX_Control(pDX, IDC_CHECK3, m_apaudiocd);
- DDX_Control(pDX, IDC_CHECK4, m_apdvd);
- DDX_Radio(pDX, IDC_RADIO1, m_iRtspHandler);
- DDX_Check(pDX, IDC_CHECK5, m_fRtspFileExtFirst);
- DDX_Control(pDX, IDC_CHECK6, m_fContextDir);
- DDX_Control(pDX, IDC_CHECK7, m_fContextFiles);
- DDX_Control(pDX, IDC_CHECK8, m_fAssociatedWithIcons);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_LIST1, m_list);
+ DDX_Text(pDX, IDC_EDIT1, m_exts);
+ DDX_Control(pDX, IDC_STATIC1, m_autoplay);
+ DDX_Control(pDX, IDC_CHECK1, m_apvideo);
+ DDX_Control(pDX, IDC_CHECK2, m_apmusic);
+ DDX_Control(pDX, IDC_CHECK3, m_apaudiocd);
+ DDX_Control(pDX, IDC_CHECK4, m_apdvd);
+ DDX_Radio(pDX, IDC_RADIO1, m_iRtspHandler);
+ DDX_Check(pDX, IDC_CHECK5, m_fRtspFileExtFirst);
+ DDX_Control(pDX, IDC_CHECK6, m_fContextDir);
+ DDX_Control(pDX, IDC_CHECK7, m_fContextFiles);
+ DDX_Control(pDX, IDC_CHECK8, m_fAssociatedWithIcons);
}
int CPPageFormats::GetChecked(int iItem)
{
- LVITEM lvi;
- lvi.iItem = iItem;
- lvi.iSubItem = 0;
- lvi.mask = LVIF_IMAGE;
- m_list.GetItem(&lvi);
- return lvi.iImage;
+ LVITEM lvi;
+ lvi.iItem = iItem;
+ lvi.iSubItem = 0;
+ lvi.mask = LVIF_IMAGE;
+ m_list.GetItem(&lvi);
+ return lvi.iImage;
}
void CPPageFormats::SetChecked(int iItem, int iChecked)
{
- LVITEM lvi;
- lvi.iItem = iItem;
- lvi.iSubItem = 0;
- lvi.mask = LVIF_IMAGE;
- lvi.iImage = iChecked;
- m_list.SetItem(&lvi);
+ LVITEM lvi;
+ lvi.iItem = iItem;
+ lvi.iSubItem = 0;
+ lvi.mask = LVIF_IMAGE;
+ lvi.iImage = iChecked;
+ m_list.SetItem(&lvi);
}
CString CPPageFormats::GetEnqueueCommand()
{
- CString path;
+ CString path;
- TCHAR buff[_MAX_PATH];
- if (::GetModuleFileName(AfxGetInstanceHandle(), buff, _MAX_PATH) == 0) {
- return _T("");
- }
+ TCHAR buff[_MAX_PATH];
+ if (::GetModuleFileName(AfxGetInstanceHandle(), buff, _MAX_PATH) == 0) {
+ return _T("");
+ }
- path = buff;
- return _T("\"") + path + _T("\" /add \"%1\"");
+ path = buff;
+ return _T("\"") + path + _T("\" /add \"%1\"");
}
CString CPPageFormats::GetOpenCommand()
{
- CString path;
- TCHAR buff[_MAX_PATH];
+ CString path;
+ TCHAR buff[_MAX_PATH];
- if (::GetModuleFileName(AfxGetInstanceHandle(), buff, _MAX_PATH) == 0) {
- return _T("");
- }
+ if (::GetModuleFileName(AfxGetInstanceHandle(), buff, _MAX_PATH) == 0) {
+ return _T("");
+ }
- path = buff;
- return _T("\"") + path + _T("\" \"%1\"");
+ path = buff;
+ return _T("\"") + path + _T("\" \"%1\"");
}
bool CPPageFormats::IsRegistered(CString ext)
{
- HRESULT hr;
- BOOL bIsDefault = FALSE;
- CString strProgID = PROGID + ext;
-
- if (m_pAAR == NULL) {
- // Default manager (requires at least Vista)
- hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
- NULL,
- CLSCTX_INPROC,
- __uuidof(IApplicationAssociationRegistration),
- (void**)&m_pAAR);
- }
-
- if (m_pAAR) {
- // The Vista way
- hr = m_pAAR->QueryAppIsDefault(ext, AT_FILEEXTENSION, AL_EFFECTIVE, g_strRegisteredAppName, &bIsDefault);
- } else {
- // The 2000/XP way
- CRegKey key;
- TCHAR buff[256];
- ULONG len = _countof(buff);
- memset(buff, 0, sizeof(buff));
-
- if (ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, ext)) {
- return false;
- }
-
- if (ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len) && !CString(buff).Trim().IsEmpty()) {
- return false;
- }
-
- bIsDefault = (buff == strProgID);
- }
- if (!f_setContextFiles) {
- CRegKey key;
- TCHAR buff[_MAX_PATH];
- ULONG len = _countof(buff);
-
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\open"), KEY_READ)) {
- CString strCommand = ResStr(IDS_OPEN_WITH_MPC);
- if (ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len)) {
- f_setContextFiles = (strCommand.CompareNoCase(CString(buff)) == 0);
- }
- }
- }
-
- // Check if association is for this instance of MPC
- if (bIsDefault) {
- CRegKey key;
- TCHAR buff[_MAX_PATH];
- ULONG len = _countof(buff);
-
- bIsDefault = FALSE;
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\open\\command"), KEY_READ)) {
- CString strCommand = GetOpenCommand();
- if (ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len)) {
- bIsDefault = (strCommand.CompareNoCase(CString(buff)) == 0);
- }
- }
-
- }
-
- return !!bIsDefault;
+ HRESULT hr;
+ BOOL bIsDefault = FALSE;
+ CString strProgID = PROGID + ext;
+
+ if (m_pAAR == NULL) {
+ // Default manager (requires at least Vista)
+ hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
+ NULL,
+ CLSCTX_INPROC,
+ __uuidof(IApplicationAssociationRegistration),
+ (void**)&m_pAAR);
+ }
+
+ if (m_pAAR) {
+ // The Vista way
+ hr = m_pAAR->QueryAppIsDefault(ext, AT_FILEEXTENSION, AL_EFFECTIVE, g_strRegisteredAppName, &bIsDefault);
+ } else {
+ // The 2000/XP way
+ CRegKey key;
+ TCHAR buff[256];
+ ULONG len = _countof(buff);
+ memset(buff, 0, sizeof(buff));
+
+ if (ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, ext)) {
+ return false;
+ }
+
+ if (ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len) && !CString(buff).Trim().IsEmpty()) {
+ return false;
+ }
+
+ bIsDefault = (buff == strProgID);
+ }
+ if (!f_setContextFiles) {
+ CRegKey key;
+ TCHAR buff[_MAX_PATH];
+ ULONG len = _countof(buff);
+
+ if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\open"), KEY_READ)) {
+ CString strCommand = ResStr(IDS_OPEN_WITH_MPC);
+ if (ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len)) {
+ f_setContextFiles = (strCommand.CompareNoCase(CString(buff)) == 0);
+ }
+ }
+ }
+
+ // Check if association is for this instance of MPC
+ if (bIsDefault) {
+ CRegKey key;
+ TCHAR buff[_MAX_PATH];
+ ULONG len = _countof(buff);
+
+ bIsDefault = FALSE;
+ if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\open\\command"), KEY_READ)) {
+ CString strCommand = GetOpenCommand();
+ if (ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len)) {
+ bIsDefault = (strCommand.CompareNoCase(CString(buff)) == 0);
+ }
+ }
+
+ }
+
+ return !!bIsDefault;
}
CString GetProgramDir()
{
- CString RtnVal;
- TCHAR FileName[_MAX_PATH];
- ::GetModuleFileName(AfxGetInstanceHandle(), FileName, _MAX_PATH);
- RtnVal = FileName;
- RtnVal = RtnVal.Left(RtnVal.ReverseFind('\\'));
- return RtnVal;
+ CString RtnVal;
+ TCHAR FileName[_MAX_PATH];
+ ::GetModuleFileName(AfxGetInstanceHandle(), FileName, _MAX_PATH);
+ RtnVal = FileName;
+ RtnVal = RtnVal.Left(RtnVal.ReverseFind('\\'));
+ return RtnVal;
}
-int FileExists(const TCHAR *fileName)
+int FileExists(const TCHAR* fileName)
{
- DWORD fileAttr;
- fileAttr = ::GetFileAttributes(fileName);
- if (0xFFFFFFFF == fileAttr) {
- return false;
- }
- return true;
+ DWORD fileAttr;
+ fileAttr = ::GetFileAttributes(fileName);
+ if (0xFFFFFFFF == fileAttr) {
+ return false;
+ }
+ return true;
}
typedef int (*GetIconIndexFunc)(CString);
int GetIconIndex(CString ext)
{
- int iconindex = -1;
- GetIconIndexFunc _getIconIndexFunc;
- HINSTANCE mpciconlib = LoadLibrary(_T("mpciconlib.dll"));
- if (mpciconlib) {
- _getIconIndexFunc = (GetIconIndexFunc) GetProcAddress(mpciconlib, "get_icon_index");
- if (_getIconIndexFunc) {
- iconindex = _getIconIndexFunc(ext);
- }
- FreeLibrary(mpciconlib);
- }
-
- return iconindex;
+ int iconindex = -1;
+ GetIconIndexFunc _getIconIndexFunc;
+ HINSTANCE mpciconlib = LoadLibrary(_T("mpciconlib.dll"));
+ if (mpciconlib) {
+ _getIconIndexFunc = (GetIconIndexFunc) GetProcAddress(mpciconlib, "get_icon_index");
+ if (_getIconIndexFunc) {
+ iconindex = _getIconIndexFunc(ext);
+ }
+ FreeLibrary(mpciconlib);
+ }
+
+ return iconindex;
}
bool CPPageFormats::RegisterApp()
{
- if (m_pAAR == NULL) {
- // Default manager (requires at least Vista)
- HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
- NULL,
- CLSCTX_INPROC,
- __uuidof(IApplicationAssociationRegistration),
- (void**)&m_pAAR);
- UNREFERENCED_PARAMETER(hr);
- }
-
- if (m_pAAR) {
- CString AppIcon = _T("");
- TCHAR buff[_MAX_PATH];
-
- if (::GetModuleFileName(AfxGetInstanceHandle(), buff, _MAX_PATH)) {
- AppIcon = buff;
- AppIcon = "\""+AppIcon+"\"";
- AppIcon += _T(",0");
- }
-
- // Register MPC for the windows "Default application" manager
- CRegKey key;
-
- if (ERROR_SUCCESS == key.Open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\RegisteredApplications"))) {
- key.SetStringValue(_T("Media Player Classic"), g_strRegisteredKey);
-
- if (ERROR_SUCCESS != key.Create(HKEY_LOCAL_MACHINE, g_strRegisteredKey)) {
- return false;
- }
-
- // ==>> TODO icon !!!
- key.SetStringValue(_T("ApplicationDescription"), ResStr(IDS_APP_DESCRIPTION), REG_EXPAND_SZ);
- key.SetStringValue(_T("ApplicationIcon"), AppIcon, REG_EXPAND_SZ);
- key.SetStringValue(_T("ApplicationName"), ResStr(IDR_MAINFRAME), REG_EXPAND_SZ);
- }
- }
- return true;
+ if (m_pAAR == NULL) {
+ // Default manager (requires at least Vista)
+ HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
+ NULL,
+ CLSCTX_INPROC,
+ __uuidof(IApplicationAssociationRegistration),
+ (void**)&m_pAAR);
+ UNREFERENCED_PARAMETER(hr);
+ }
+
+ if (m_pAAR) {
+ CString AppIcon = _T("");
+ TCHAR buff[_MAX_PATH];
+
+ if (::GetModuleFileName(AfxGetInstanceHandle(), buff, _MAX_PATH)) {
+ AppIcon = buff;
+ AppIcon = "\"" + AppIcon + "\"";
+ AppIcon += _T(",0");
+ }
+
+ // Register MPC for the windows "Default application" manager
+ CRegKey key;
+
+ if (ERROR_SUCCESS == key.Open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\RegisteredApplications"))) {
+ key.SetStringValue(_T("Media Player Classic"), g_strRegisteredKey);
+
+ if (ERROR_SUCCESS != key.Create(HKEY_LOCAL_MACHINE, g_strRegisteredKey)) {
+ return false;
+ }
+
+ // ==>> TODO icon !!!
+ key.SetStringValue(_T("ApplicationDescription"), ResStr(IDS_APP_DESCRIPTION), REG_EXPAND_SZ);
+ key.SetStringValue(_T("ApplicationIcon"), AppIcon, REG_EXPAND_SZ);
+ key.SetStringValue(_T("ApplicationName"), ResStr(IDR_MAINFRAME), REG_EXPAND_SZ);
+ }
+ }
+ return true;
}
bool CPPageFormats::RegisterExt(CString ext, CString strLabel, bool fRegister)
{
- CRegKey key;
- bool bSetValue;
- CString strProgID = PROGID + ext;
-
- if (!fRegister) {
- if (fRegister != IsRegistered(ext)) {
- SetFileAssociation (ext, strProgID, fRegister);
- }
- key.Attach(HKEY_CLASSES_ROOT);
- key.RecurseDeleteKey(strProgID);
- return true;
- }
-
- bSetValue = fRegister || (ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\open\\command"), KEY_READ));
-
- // Create ProgID for this file type
- if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID)) {
- return false;
- }
- if (ERROR_SUCCESS != key.SetStringValue(NULL, strLabel)) {
- return false;
- }
-
- // Add to playlist option
- if (f_setContextFiles) {
- if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\enqueue"))) {
- return false;
- }
- if (ERROR_SUCCESS != key.SetStringValue(NULL, ResStr(IDS_ADD_TO_PLAYLIST))) {
- return false;
- }
-
- if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\enqueue\\command"))) {
- return false;
- }
- if (bSetValue && (ERROR_SUCCESS != key.SetStringValue(NULL, GetEnqueueCommand()))) {
- return false;
- }
- } else {
- key.Close();
- key.Attach(HKEY_CLASSES_ROOT);
- key.RecurseDeleteKey(strProgID + _T("\\shell\\enqueue"));
- }
-
- // Play option
- if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\open"))) {
- return false;
- }
- if (f_setContextFiles) {
- if (ERROR_SUCCESS != key.SetStringValue(NULL, ResStr(IDS_OPEN_WITH_MPC))) {
- return false;
- }
- } else {
- if (ERROR_SUCCESS != key.SetStringValue(NULL, _T(""))) {
- return false;
- }
- }
-
- if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\open\\command"))) {
- return false;
- }
- if (bSetValue && (ERROR_SUCCESS != key.SetStringValue(NULL, GetOpenCommand()))) {
- return false;
- }
-
- if (ERROR_SUCCESS != key.Create(HKEY_LOCAL_MACHINE, g_strRegisteredKey + _T("\\FileAssociations"))) {
- return false;
- }
- if (ERROR_SUCCESS != key.SetStringValue(ext, strProgID)) {
- return false;
- }
-
- if (f_setAssociatedWithIcon) {
- CString AppIcon = _T("");
- TCHAR buff[_MAX_PATH];
-
- CString mpciconlib = GetProgramDir() + _T("\\mpciconlib.dll");
-
- if (FileExists(mpciconlib)) {
- int icon_index = GetIconIndex(ext);
- CString m_typeicon = mpciconlib;
-
- /* icon_index value -1 means no icon was found in the iconlib for the file extension */
- if ((icon_index >= 0) && ExtractIcon(AfxGetApp()->m_hInstance,(LPCWSTR)m_typeicon, icon_index)) {
- m_typeicon = "\""+mpciconlib+"\"";
- AppIcon.Format(_T("%s,%d"), m_typeicon, icon_index);
- }
- }
-
- /* no icon was found for the file extension, so use MPC's icon */
- if ((AppIcon.IsEmpty()) && (::GetModuleFileName(AfxGetInstanceHandle(), buff, _MAX_PATH))) {
- AppIcon = buff;
- AppIcon = "\""+AppIcon+"\"";
- AppIcon += _T(",0");
- }
-
- if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\DefaultIcon"))) {
- return false;
- }
- if (bSetValue && (ERROR_SUCCESS != key.SetStringValue(NULL, AppIcon))) {
- return false;
- }
- } else {
- key.Attach(HKEY_CLASSES_ROOT);
- key.RecurseDeleteKey(strProgID + _T("\\DefaultIcon"));
- }
-
- if (fRegister != IsRegistered(ext)) {
- SetFileAssociation (ext, strProgID, fRegister);
- }
-
- return true;
+ CRegKey key;
+ bool bSetValue;
+ CString strProgID = PROGID + ext;
+
+ if (!fRegister) {
+ if (fRegister != IsRegistered(ext)) {
+ SetFileAssociation(ext, strProgID, fRegister);
+ }
+ key.Attach(HKEY_CLASSES_ROOT);
+ key.RecurseDeleteKey(strProgID);
+ return true;
+ }
+
+ bSetValue = fRegister || (ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\open\\command"), KEY_READ));
+
+ // Create ProgID for this file type
+ if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID)) {
+ return false;
+ }
+ if (ERROR_SUCCESS != key.SetStringValue(NULL, strLabel)) {
+ return false;
+ }
+
+ // Add to playlist option
+ if (f_setContextFiles) {
+ if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\enqueue"))) {
+ return false;
+ }
+ if (ERROR_SUCCESS != key.SetStringValue(NULL, ResStr(IDS_ADD_TO_PLAYLIST))) {
+ return false;
+ }
+
+ if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\enqueue\\command"))) {
+ return false;
+ }
+ if (bSetValue && (ERROR_SUCCESS != key.SetStringValue(NULL, GetEnqueueCommand()))) {
+ return false;
+ }
+ } else {
+ key.Close();
+ key.Attach(HKEY_CLASSES_ROOT);
+ key.RecurseDeleteKey(strProgID + _T("\\shell\\enqueue"));
+ }
+
+ // Play option
+ if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\open"))) {
+ return false;
+ }
+ if (f_setContextFiles) {
+ if (ERROR_SUCCESS != key.SetStringValue(NULL, ResStr(IDS_OPEN_WITH_MPC))) {
+ return false;
+ }
+ } else {
+ if (ERROR_SUCCESS != key.SetStringValue(NULL, _T(""))) {
+ return false;
+ }
+ }
+
+ if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\open\\command"))) {
+ return false;
+ }
+ if (bSetValue && (ERROR_SUCCESS != key.SetStringValue(NULL, GetOpenCommand()))) {
+ return false;
+ }
+
+ if (ERROR_SUCCESS != key.Create(HKEY_LOCAL_MACHINE, g_strRegisteredKey + _T("\\FileAssociations"))) {
+ return false;
+ }
+ if (ERROR_SUCCESS != key.SetStringValue(ext, strProgID)) {
+ return false;
+ }
+
+ if (f_setAssociatedWithIcon) {
+ CString AppIcon = _T("");
+ TCHAR buff[_MAX_PATH];
+
+ CString mpciconlib = GetProgramDir() + _T("\\mpciconlib.dll");
+
+ if (FileExists(mpciconlib)) {
+ int icon_index = GetIconIndex(ext);
+ CString m_typeicon = mpciconlib;
+
+ /* icon_index value -1 means no icon was found in the iconlib for the file extension */
+ if ((icon_index >= 0) && ExtractIcon(AfxGetApp()->m_hInstance, (LPCWSTR)m_typeicon, icon_index)) {
+ m_typeicon = "\"" + mpciconlib + "\"";
+ AppIcon.Format(_T("%s,%d"), m_typeicon, icon_index);
+ }
+ }
+
+ /* no icon was found for the file extension, so use MPC's icon */
+ if ((AppIcon.IsEmpty()) && (::GetModuleFileName(AfxGetInstanceHandle(), buff, _MAX_PATH))) {
+ AppIcon = buff;
+ AppIcon = "\"" + AppIcon + "\"";
+ AppIcon += _T(",0");
+ }
+
+ if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\DefaultIcon"))) {
+ return false;
+ }
+ if (bSetValue && (ERROR_SUCCESS != key.SetStringValue(NULL, AppIcon))) {
+ return false;
+ }
+ } else {
+ key.Attach(HKEY_CLASSES_ROOT);
+ key.RecurseDeleteKey(strProgID + _T("\\DefaultIcon"));
+ }
+
+ if (fRegister != IsRegistered(ext)) {
+ SetFileAssociation(ext, strProgID, fRegister);
+ }
+
+ return true;
}
static struct {
- LPCSTR verb, cmd;
- UINT action;
+ LPCSTR verb, cmd;
+ UINT action;
} handlers[] = {
- {"VideoFiles", " %1", IDS_AUTOPLAY_PLAYVIDEO},
- {"MusicFiles", " %1", IDS_AUTOPLAY_PLAYMUSIC},
- {"CDAudio", " %1 /cd", IDS_AUTOPLAY_PLAYAUDIOCD},
- {"DVDMovie", " %1 /dvd", IDS_AUTOPLAY_PLAYDVDMOVIE},
+ {"VideoFiles", " %1", IDS_AUTOPLAY_PLAYVIDEO},
+ {"MusicFiles", " %1", IDS_AUTOPLAY_PLAYMUSIC},
+ {"CDAudio", " %1 /cd", IDS_AUTOPLAY_PLAYAUDIOCD},
+ {"DVDMovie", " %1 /dvd", IDS_AUTOPLAY_PLAYDVDMOVIE},
};
void CPPageFormats::AddAutoPlayToRegistry(autoplay_t ap, bool fRegister)
{
- TCHAR buff[_MAX_PATH];
- if (::GetModuleFileName(AfxGetInstanceHandle(), buff, _MAX_PATH) == 0) {
- return;
- }
- CString exe = buff;
-
- int i = (int)ap;
- if (i < 0 || i >= _countof(handlers)) {
- return;
- }
-
- CRegKey key;
-
- if (fRegister) {
- if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, _T("MediaPlayerClassic.Autorun"))) {
- return;
- }
- key.Close();
-
- if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT,
- CString(CStringA("MediaPlayerClassic.Autorun\\Shell\\Play") + handlers[i].verb + "\\Command"))) {
- return;
- }
- key.SetStringValue(NULL, _T("\"") + exe + _T("\"") + handlers[i].cmd);
- key.Close();
-
- if (ERROR_SUCCESS != key.Create(HKEY_LOCAL_MACHINE,
- CString(CStringA("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\AutoplayHandlers\\Handlers\\MPCPlay") + handlers[i].verb + "OnArrival"))) {
- return;
- }
- key.SetStringValue(_T("Action"), ResStr(handlers[i].action));
- key.SetStringValue(_T("Provider"), _T("Media Player Classic"));
- key.SetStringValue(_T("InvokeProgID"), _T("MediaPlayerClassic.Autorun"));
- key.SetStringValue(_T("InvokeVerb"), CString(CStringA("Play") + handlers[i].verb));
- key.SetStringValue(_T("DefaultIcon"), exe + _T(",0"));
- key.Close();
-
- if (ERROR_SUCCESS != key.Create(HKEY_LOCAL_MACHINE,
- CString(CStringA("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\AutoplayHandlers\\EventHandlers\\Play") + handlers[i].verb + "OnArrival"))) {
- return;
- }
- key.SetStringValue(CString(CStringA("MPCPlay") + handlers[i].verb + "OnArrival"), _T(""));
- key.Close();
- } else {
- if (ERROR_SUCCESS != key.Create(HKEY_LOCAL_MACHINE,
- CString(CStringA("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\AutoplayHandlers\\EventHandlers\\Play") + handlers[i].verb + "OnArrival"))) {
- return;
- }
- key.DeleteValue(CString(CStringA("MPCPlay") + handlers[i].verb + "OnArrival"));
- key.Close();
- }
+ TCHAR buff[_MAX_PATH];
+ if (::GetModuleFileName(AfxGetInstanceHandle(), buff, _MAX_PATH) == 0) {
+ return;
+ }
+ CString exe = buff;
+
+ int i = (int)ap;
+ if (i < 0 || i >= _countof(handlers)) {
+ return;
+ }
+
+ CRegKey key;
+
+ if (fRegister) {
+ if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, _T("MediaPlayerClassic.Autorun"))) {
+ return;
+ }
+ key.Close();
+
+ if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT,
+ CString(CStringA("MediaPlayerClassic.Autorun\\Shell\\Play") + handlers[i].verb + "\\Command"))) {
+ return;
+ }
+ key.SetStringValue(NULL, _T("\"") + exe + _T("\"") + handlers[i].cmd);
+ key.Close();
+
+ if (ERROR_SUCCESS != key.Create(HKEY_LOCAL_MACHINE,
+ CString(CStringA("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\AutoplayHandlers\\Handlers\\MPCPlay") + handlers[i].verb + "OnArrival"))) {
+ return;
+ }
+ key.SetStringValue(_T("Action"), ResStr(handlers[i].action));
+ key.SetStringValue(_T("Provider"), _T("Media Player Classic"));
+ key.SetStringValue(_T("InvokeProgID"), _T("MediaPlayerClassic.Autorun"));
+ key.SetStringValue(_T("InvokeVerb"), CString(CStringA("Play") + handlers[i].verb));
+ key.SetStringValue(_T("DefaultIcon"), exe + _T(",0"));
+ key.Close();
+
+ if (ERROR_SUCCESS != key.Create(HKEY_LOCAL_MACHINE,
+ CString(CStringA("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\AutoplayHandlers\\EventHandlers\\Play") + handlers[i].verb + "OnArrival"))) {
+ return;
+ }
+ key.SetStringValue(CString(CStringA("MPCPlay") + handlers[i].verb + "OnArrival"), _T(""));
+ key.Close();
+ } else {
+ if (ERROR_SUCCESS != key.Create(HKEY_LOCAL_MACHINE,
+ CString(CStringA("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\AutoplayHandlers\\EventHandlers\\Play") + handlers[i].verb + "OnArrival"))) {
+ return;
+ }
+ key.DeleteValue(CString(CStringA("MPCPlay") + handlers[i].verb + "OnArrival"));
+ key.Close();
+ }
}
bool CPPageFormats::IsAutoPlayRegistered(autoplay_t ap)
{
- ULONG len;
- TCHAR buff[_MAX_PATH];
- if (::GetModuleFileName(AfxGetInstanceHandle(), buff, _MAX_PATH) == 0) {
- return false;
- }
- CString exe = buff;
-
- int i = (int)ap;
- if (i < 0 || i >= _countof(handlers)) {
- return false;
- }
-
- CRegKey key;
-
- if (ERROR_SUCCESS != key.Open(HKEY_LOCAL_MACHINE,
- CString(CStringA("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\AutoplayHandlers\\EventHandlers\\Play") + handlers[i].verb + "OnArrival"),
- KEY_READ)) {
- return false;
- }
- len = _countof(buff);
- if (ERROR_SUCCESS != key.QueryStringValue(
- CString(_T("MPCPlay")) + handlers[i].verb + _T("OnArrival"),
- buff, &len)) {
- return false;
- }
- key.Close();
-
- if (ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT,
- CString(CStringA("MediaPlayerClassic.Autorun\\Shell\\Play") + handlers[i].verb + "\\Command"),
- KEY_READ)) {
- return false;
- }
- len = _countof(buff);
- if (ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len)) {
- return false;
- }
- if (_tcsnicmp(_T("\"") + exe, buff, exe.GetLength() + 1)) {
- return false;
- }
- key.Close();
-
- return true;
+ ULONG len;
+ TCHAR buff[_MAX_PATH];
+ if (::GetModuleFileName(AfxGetInstanceHandle(), buff, _MAX_PATH) == 0) {
+ return false;
+ }
+ CString exe = buff;
+
+ int i = (int)ap;
+ if (i < 0 || i >= _countof(handlers)) {
+ return false;
+ }
+
+ CRegKey key;
+
+ if (ERROR_SUCCESS != key.Open(HKEY_LOCAL_MACHINE,
+ CString(CStringA("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\AutoplayHandlers\\EventHandlers\\Play") + handlers[i].verb + "OnArrival"),
+ KEY_READ)) {
+ return false;
+ }
+ len = _countof(buff);
+ if (ERROR_SUCCESS != key.QueryStringValue(
+ CString(_T("MPCPlay")) + handlers[i].verb + _T("OnArrival"),
+ buff, &len)) {
+ return false;
+ }
+ key.Close();
+
+ if (ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT,
+ CString(CStringA("MediaPlayerClassic.Autorun\\Shell\\Play") + handlers[i].verb + "\\Command"),
+ KEY_READ)) {
+ return false;
+ }
+ len = _countof(buff);
+ if (ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len)) {
+ return false;
+ }
+ if (_tcsnicmp(_T("\"") + exe, buff, exe.GetLength() + 1)) {
+ return false;
+ }
+ key.Close();
+
+ return true;
}
void CPPageFormats::SetListItemState(int nItem)
{
- if (nItem < 0) {
- return;
- }
+ if (nItem < 0) {
+ return;
+ }
- CString str = AfxGetAppSettings().m_Formats[(int)m_list.GetItemData(nItem)].GetExtsWithPeriod();
+ CString str = AfxGetAppSettings().m_Formats[(int)m_list.GetItemData(nItem)].GetExtsWithPeriod();
- CAtlList<CString> exts;
- ExplodeMin(str, exts, ' ');
+ CAtlList<CString> exts;
+ ExplodeMin(str, exts, ' ');
- int cnt = 0;
+ int cnt = 0;
- POSITION pos = exts.GetHeadPosition();
- while (pos) if (IsRegistered(exts.GetNext(pos))) {
- cnt++;
- }
+ POSITION pos = exts.GetHeadPosition();
+ while (pos) if (IsRegistered(exts.GetNext(pos))) {
+ cnt++;
+ }
- if (cnt != 0) {
- cnt = (cnt == (int)exts.GetCount() ? 1 : 2);
- }
- SetChecked(nItem, cnt);
+ if (cnt != 0) {
+ cnt = (cnt == (int)exts.GetCount() ? 1 : 2);
+ }
+ SetChecked(nItem, cnt);
}
bool CPPageFormats::IsNeededIconsLib()
{
- bool needIconLib = false;
- int i = 0;
+ bool needIconLib = false;
+ int i = 0;
- while (!needIconLib && i < m_list.GetItemCount()) {
- if (GetChecked(i) == 1) {
- needIconLib = true;
- }
- i++;
- }
+ while (!needIconLib && i < m_list.GetItemCount()) {
+ if (GetChecked(i) == 1) {
+ needIconLib = true;
+ }
+ i++;
+ }
- return needIconLib;
+ return needIconLib;
}
BEGIN_MESSAGE_MAP(CPPageFormats, CPPageBase)
- ON_NOTIFY(NM_CLICK, IDC_LIST1, OnNMClickList1)
- ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST1, OnLvnItemchangedList1)
- ON_NOTIFY(LVN_BEGINLABELEDIT, IDC_LIST1, OnBeginlabeleditList)
- ON_NOTIFY(LVN_DOLABELEDIT, IDC_LIST1, OnDolabeleditList)
- ON_NOTIFY(LVN_ENDLABELEDIT, IDC_LIST1, OnEndlabeleditList)
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
- ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton12)
- ON_BN_CLICKED(IDC_BUTTON_EXT_SET, OnBnClickedButton11)
- ON_BN_CLICKED(IDC_BUTTON4, OnBnClickedButton14)
- ON_BN_CLICKED(IDC_BUTTON3, OnBnClickedButton13)
- ON_BN_CLICKED(IDC_BUTTON5, OnBnVistaModify)
- ON_BN_CLICKED(IDC_CHECK7, OnFilesAssocModified)
- ON_BN_CLICKED(IDC_CHECK8, OnFilesAssocModified)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON2, OnUpdateButtonDefault)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON_EXT_SET, OnUpdateButtonSet)
+ ON_NOTIFY(NM_CLICK, IDC_LIST1, OnNMClickList1)
+ ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST1, OnLvnItemchangedList1)
+ ON_NOTIFY(LVN_BEGINLABELEDIT, IDC_LIST1, OnBeginlabeleditList)
+ ON_NOTIFY(LVN_DOLABELEDIT, IDC_LIST1, OnDolabeleditList)
+ ON_NOTIFY(LVN_ENDLABELEDIT, IDC_LIST1, OnEndlabeleditList)
+ ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
+ ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton12)
+ ON_BN_CLICKED(IDC_BUTTON_EXT_SET, OnBnClickedButton11)
+ ON_BN_CLICKED(IDC_BUTTON4, OnBnClickedButton14)
+ ON_BN_CLICKED(IDC_BUTTON3, OnBnClickedButton13)
+ ON_BN_CLICKED(IDC_BUTTON5, OnBnVistaModify)
+ ON_BN_CLICKED(IDC_CHECK7, OnFilesAssocModified)
+ ON_BN_CLICKED(IDC_CHECK8, OnFilesAssocModified)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON2, OnUpdateButtonDefault)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON_EXT_SET, OnUpdateButtonSet)
END_MESSAGE_MAP()
// CPPageFormats message handlers
BOOL CPPageFormats::OnInitDialog()
{
- __super::OnInitDialog();
-
- m_bFileExtChanged = false;
-
- m_list.SetExtendedStyle(m_list.GetExtendedStyle()|LVS_EX_FULLROWSELECT);
-
- m_list.InsertColumn(COL_CATEGORY, _T("Category"), LVCFMT_LEFT, 300);
- m_list.InsertColumn(COL_ENGINE, _T("Engine"), LVCFMT_RIGHT, 60);
-
- m_onoff.Create(IDB_ONOFF, 12, 3, 0xffffff);
- m_list.SetImageList(&m_onoff, LVSIL_SMALL);
-
- CMediaFormats& mf = AfxGetAppSettings().m_Formats;
- mf.UpdateData(FALSE);
- for (int i = 0; i < (int)mf.GetCount(); i++) {
- CString label;
- label.Format (_T("%s (%s)"), mf[i].GetDescription(), mf[i].GetExts());
-
- int iItem = m_list.InsertItem(i, label);
- m_list.SetItemData(iItem, i);
- engine_t e = mf[i].GetEngineType();
- m_list.SetItemText(iItem, COL_ENGINE,
- e == DirectShow ? _T("DirectShow") :
- e == RealMedia ? _T("RealMedia") :
- e == QuickTime ? _T("QuickTime") :
- e == ShockWave ? _T("ShockWave") : _T("-"));
- }
-
- // m_list.SetColumnWidth(COL_CATEGORY, LVSCW_AUTOSIZE);
- m_list.SetColumnWidth(COL_ENGINE, LVSCW_AUTOSIZE_USEHEADER);
-
- m_list.SetSelectionMark(0);
- m_list.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
- m_exts = mf[(int)m_list.GetItemData(0)].GetExtsWithPeriod();
-
- AppSettings& s = AfxGetAppSettings();
- bool fRtspFileExtFirst;
- engine_t e = s.m_Formats.GetRtspHandler(fRtspFileExtFirst);
- m_iRtspHandler = (e==RealMedia?0:e==QuickTime?1:2);
- m_fRtspFileExtFirst = fRtspFileExtFirst;
-
- UpdateData(FALSE);
-
- f_setContextFiles = 0;
-
- for (int i = 0; i < m_list.GetItemCount(); i++) {
- SetListItemState(i);
- }
- m_fContextFiles.SetCheck(f_setContextFiles);
-
- m_apvideo.SetCheck(IsAutoPlayRegistered(AP_VIDEO));
- m_apmusic.SetCheck(IsAutoPlayRegistered(AP_MUSIC));
- m_apaudiocd.SetCheck(IsAutoPlayRegistered(AP_AUDIOCD));
- m_apdvd.SetCheck(IsAutoPlayRegistered(AP_DVDMOVIE));
-
- CreateToolTip();
-
-
- if (SysVersion::IsVistaOrLater() && !IsUserAnAdmin()) {
- GetDlgItem(IDC_BUTTON1)->ShowWindow (SW_HIDE);
- GetDlgItem(IDC_BUTTON3)->ShowWindow (SW_HIDE);
- GetDlgItem(IDC_BUTTON4)->ShowWindow (SW_HIDE);
- GetDlgItem(IDC_CHECK1)->EnableWindow (FALSE);
- GetDlgItem(IDC_CHECK2)->EnableWindow (FALSE);
- GetDlgItem(IDC_CHECK3)->EnableWindow (FALSE);
- GetDlgItem(IDC_CHECK4)->EnableWindow (FALSE);
- GetDlgItem(IDC_CHECK5)->EnableWindow (FALSE);
-
- GetDlgItem(IDC_RADIO1)->EnableWindow (FALSE);
- GetDlgItem(IDC_RADIO2)->EnableWindow (FALSE);
- GetDlgItem(IDC_RADIO3)->EnableWindow (FALSE);
-
- GetDlgItem(IDC_BUTTON5)->ShowWindow (SW_SHOW);
- GetDlgItem(IDC_BUTTON5)->SendMessage (BCM_SETSHIELD, 0, 1);
-
- m_bInsufficientPrivileges = true;
- } else {
- GetDlgItem(IDC_BUTTON5)->ShowWindow (SW_HIDE);
- }
-
-
- CRegKey key;
- TCHAR buff[_MAX_PATH];
- ULONG len = _countof(buff);
-
- int fContextDir = 0;
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Directory\\shell\\") PROGID _T(".play\\command"), KEY_READ)) {
- CString strCommand = GetOpenCommand();
- if (ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len)) {
- fContextDir = (strCommand.CompareNoCase(CString(buff)) == 0);
- }
- }
- m_fContextDir.SetCheck(fContextDir);
- m_fAssociatedWithIcons.SetCheck(s.fAssociatedWithIcons);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ m_bFileExtChanged = false;
+
+ m_list.SetExtendedStyle(m_list.GetExtendedStyle() | LVS_EX_FULLROWSELECT);
+
+ m_list.InsertColumn(COL_CATEGORY, _T("Category"), LVCFMT_LEFT, 300);
+ m_list.InsertColumn(COL_ENGINE, _T("Engine"), LVCFMT_RIGHT, 60);
+
+ m_onoff.Create(IDB_ONOFF, 12, 3, 0xffffff);
+ m_list.SetImageList(&m_onoff, LVSIL_SMALL);
+
+ CMediaFormats& mf = AfxGetAppSettings().m_Formats;
+ mf.UpdateData(FALSE);
+ for (int i = 0; i < (int)mf.GetCount(); i++) {
+ CString label;
+ label.Format(_T("%s (%s)"), mf[i].GetDescription(), mf[i].GetExts());
+
+ int iItem = m_list.InsertItem(i, label);
+ m_list.SetItemData(iItem, i);
+ engine_t e = mf[i].GetEngineType();
+ m_list.SetItemText(iItem, COL_ENGINE,
+ e == DirectShow ? _T("DirectShow") :
+ e == RealMedia ? _T("RealMedia") :
+ e == QuickTime ? _T("QuickTime") :
+ e == ShockWave ? _T("ShockWave") : _T("-"));
+ }
+
+ // m_list.SetColumnWidth(COL_CATEGORY, LVSCW_AUTOSIZE);
+ m_list.SetColumnWidth(COL_ENGINE, LVSCW_AUTOSIZE_USEHEADER);
+
+ m_list.SetSelectionMark(0);
+ m_list.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
+ m_exts = mf[(int)m_list.GetItemData(0)].GetExtsWithPeriod();
+
+ AppSettings& s = AfxGetAppSettings();
+ bool fRtspFileExtFirst;
+ engine_t e = s.m_Formats.GetRtspHandler(fRtspFileExtFirst);
+ m_iRtspHandler = (e == RealMedia ? 0 : e == QuickTime ? 1 : 2);
+ m_fRtspFileExtFirst = fRtspFileExtFirst;
+
+ UpdateData(FALSE);
+
+ f_setContextFiles = 0;
+
+ for (int i = 0; i < m_list.GetItemCount(); i++) {
+ SetListItemState(i);
+ }
+ m_fContextFiles.SetCheck(f_setContextFiles);
+
+ m_apvideo.SetCheck(IsAutoPlayRegistered(AP_VIDEO));
+ m_apmusic.SetCheck(IsAutoPlayRegistered(AP_MUSIC));
+ m_apaudiocd.SetCheck(IsAutoPlayRegistered(AP_AUDIOCD));
+ m_apdvd.SetCheck(IsAutoPlayRegistered(AP_DVDMOVIE));
+
+ CreateToolTip();
+
+
+ if (SysVersion::IsVistaOrLater() && !IsUserAnAdmin()) {
+ GetDlgItem(IDC_BUTTON1)->ShowWindow(SW_HIDE);
+ GetDlgItem(IDC_BUTTON3)->ShowWindow(SW_HIDE);
+ GetDlgItem(IDC_BUTTON4)->ShowWindow(SW_HIDE);
+ GetDlgItem(IDC_CHECK1)->EnableWindow(FALSE);
+ GetDlgItem(IDC_CHECK2)->EnableWindow(FALSE);
+ GetDlgItem(IDC_CHECK3)->EnableWindow(FALSE);
+ GetDlgItem(IDC_CHECK4)->EnableWindow(FALSE);
+ GetDlgItem(IDC_CHECK5)->EnableWindow(FALSE);
+
+ GetDlgItem(IDC_RADIO1)->EnableWindow(FALSE);
+ GetDlgItem(IDC_RADIO2)->EnableWindow(FALSE);
+ GetDlgItem(IDC_RADIO3)->EnableWindow(FALSE);
+
+ GetDlgItem(IDC_BUTTON5)->ShowWindow(SW_SHOW);
+ GetDlgItem(IDC_BUTTON5)->SendMessage(BCM_SETSHIELD, 0, 1);
+
+ m_bInsufficientPrivileges = true;
+ } else {
+ GetDlgItem(IDC_BUTTON5)->ShowWindow(SW_HIDE);
+ }
+
+
+ CRegKey key;
+ TCHAR buff[_MAX_PATH];
+ ULONG len = _countof(buff);
+
+ int fContextDir = 0;
+ if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Directory\\shell\\") PROGID _T(".play\\command"), KEY_READ)) {
+ CString strCommand = GetOpenCommand();
+ if (ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len)) {
+ fContextDir = (strCommand.CompareNoCase(CString(buff)) == 0);
+ }
+ }
+ m_fContextDir.SetCheck(fContextDir);
+ m_fAssociatedWithIcons.SetCheck(s.fAssociatedWithIcons);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageFormats::SetFileAssociation(CString strExt, CString strProgID, bool fRegister)
{
- CString extoldreg, extOldIcon;
- CRegKey key;
- HRESULT hr = S_OK;
- TCHAR buff[256];
- ULONG len = _countof(buff);
- memset(buff, 0, sizeof(buff));
-
- if (m_pAAR == NULL) {
- // Default manager (requires at least Vista)
- HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
- NULL,
- CLSCTX_INPROC,
- __uuidof(IApplicationAssociationRegistration),
- (void**)&m_pAAR);
- UNREFERENCED_PARAMETER(hr);
- }
-
- if (m_pAAR) {
- // The Vista way
- CString strNewApp;
- if (fRegister) {
- // Create non existing file type
- if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strExt)) {
- return false;
- }
-
- WCHAR* pszCurrentAssociation;
- // Save current application associated
- if (SUCCEEDED (m_pAAR->QueryCurrentDefault (strExt, AT_FILEEXTENSION, AL_EFFECTIVE, &pszCurrentAssociation))) {
- if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID)) {
- return false;
- }
-
- key.SetStringValue(g_strOldAssoc, pszCurrentAssociation);
-
- // Get current icon for file type
- /*
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, CString(pszCurrentAssociation) + _T("\\DefaultIcon")))
- {
- len = sizeof(buff);
- memset(buff, 0, len);
- if (ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && !CString(buff).Trim().IsEmpty())
- {
- if (ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\DefaultIcon")))
- key.SetStringValue (NULL, buff);
- }
- }
- */
- CoTaskMemFree (pszCurrentAssociation);
- }
- strNewApp = g_strRegisteredAppName;
- } else {
- if (ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, strProgID)) {
- return false;
- }
-
- if (ERROR_SUCCESS == key.QueryStringValue(g_strOldAssoc, buff, &len)) {
- strNewApp = buff;
- }
-
- // TODO : retrieve registered app name from previous association (or find Bill function for that...)
- }
-
- hr = m_pAAR->SetAppAsDefault(strNewApp, strExt, AT_FILEEXTENSION);
- } else {
- // The 2000/XP way
- if (fRegister) {
- // Set new association
- if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strExt)) {
- return false;
- }
-
- len = _countof(buff);
- memset(buff, 0, sizeof(buff));
- if (ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && !CString(buff).Trim().IsEmpty()) {
- extoldreg = buff;
- }
- if (ERROR_SUCCESS != key.SetStringValue(NULL, strProgID)) {
- return false;
- }
-
- // Get current icon for file type
- /*
- if (!extoldreg.IsEmpty())
- {
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, extoldreg + _T("\\DefaultIcon")))
- {
- len = sizeof(buff);
- memset(buff, 0, len);
- if (ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && !CString(buff).Trim().IsEmpty())
- extOldIcon = buff;
- }
- }
- */
-
- // Save old association
- if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID)) {
- return false;
- }
- key.SetStringValue(g_strOldAssoc, extoldreg);
-
- /*
- if (!extOldIcon.IsEmpty() && (ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\DefaultIcon"))))
- key.SetStringValue (NULL, extOldIcon);
- */
- } else {
- // Get previous association
- len = _countof(buff);
- memset(buff, 0, sizeof(buff));
- if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID)) {
- return false;
- }
- if (ERROR_SUCCESS == key.QueryStringValue(g_strOldAssoc, buff, &len) && !CString(buff).Trim().IsEmpty()) {
- extoldreg = buff;
- }
-
- // Set previous association
- if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strExt)) {
- return false;
- }
- key.SetStringValue(NULL, extoldreg);
- }
-
- }
-
- return SUCCEEDED (hr);
+ CString extoldreg, extOldIcon;
+ CRegKey key;
+ HRESULT hr = S_OK;
+ TCHAR buff[256];
+ ULONG len = _countof(buff);
+ memset(buff, 0, sizeof(buff));
+
+ if (m_pAAR == NULL) {
+ // Default manager (requires at least Vista)
+ HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
+ NULL,
+ CLSCTX_INPROC,
+ __uuidof(IApplicationAssociationRegistration),
+ (void**)&m_pAAR);
+ UNREFERENCED_PARAMETER(hr);
+ }
+
+ if (m_pAAR) {
+ // The Vista way
+ CString strNewApp;
+ if (fRegister) {
+ // Create non existing file type
+ if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strExt)) {
+ return false;
+ }
+
+ WCHAR* pszCurrentAssociation;
+ // Save current application associated
+ if (SUCCEEDED(m_pAAR->QueryCurrentDefault(strExt, AT_FILEEXTENSION, AL_EFFECTIVE, &pszCurrentAssociation))) {
+ if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID)) {
+ return false;
+ }
+
+ key.SetStringValue(g_strOldAssoc, pszCurrentAssociation);
+
+ // Get current icon for file type
+ /*
+ if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, CString(pszCurrentAssociation) + _T("\\DefaultIcon")))
+ {
+ len = sizeof(buff);
+ memset(buff, 0, len);
+ if (ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && !CString(buff).Trim().IsEmpty())
+ {
+ if (ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\DefaultIcon")))
+ key.SetStringValue (NULL, buff);
+ }
+ }
+ */
+ CoTaskMemFree(pszCurrentAssociation);
+ }
+ strNewApp = g_strRegisteredAppName;
+ } else {
+ if (ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, strProgID)) {
+ return false;
+ }
+
+ if (ERROR_SUCCESS == key.QueryStringValue(g_strOldAssoc, buff, &len)) {
+ strNewApp = buff;
+ }
+
+ // TODO : retrieve registered app name from previous association (or find Bill function for that...)
+ }
+
+ hr = m_pAAR->SetAppAsDefault(strNewApp, strExt, AT_FILEEXTENSION);
+ } else {
+ // The 2000/XP way
+ if (fRegister) {
+ // Set new association
+ if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strExt)) {
+ return false;
+ }
+
+ len = _countof(buff);
+ memset(buff, 0, sizeof(buff));
+ if (ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && !CString(buff).Trim().IsEmpty()) {
+ extoldreg = buff;
+ }
+ if (ERROR_SUCCESS != key.SetStringValue(NULL, strProgID)) {
+ return false;
+ }
+
+ // Get current icon for file type
+ /*
+ if (!extoldreg.IsEmpty())
+ {
+ if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, extoldreg + _T("\\DefaultIcon")))
+ {
+ len = sizeof(buff);
+ memset(buff, 0, len);
+ if (ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && !CString(buff).Trim().IsEmpty())
+ extOldIcon = buff;
+ }
+ }
+ */
+
+ // Save old association
+ if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID)) {
+ return false;
+ }
+ key.SetStringValue(g_strOldAssoc, extoldreg);
+
+ /*
+ if (!extOldIcon.IsEmpty() && (ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\DefaultIcon"))))
+ key.SetStringValue (NULL, extOldIcon);
+ */
+ } else {
+ // Get previous association
+ len = _countof(buff);
+ memset(buff, 0, sizeof(buff));
+ if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID)) {
+ return false;
+ }
+ if (ERROR_SUCCESS == key.QueryStringValue(g_strOldAssoc, buff, &len) && !CString(buff).Trim().IsEmpty()) {
+ extoldreg = buff;
+ }
+
+ // Set previous association
+ if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strExt)) {
+ return false;
+ }
+ key.SetStringValue(NULL, extoldreg);
+ }
+
+ }
+
+ return SUCCEEDED(hr);
}
BOOL CPPageFormats::OnApply()
{
- UpdateData();
-
- {
- int i = m_list.GetSelectionMark();
- if (i >= 0) {
- i = (int)m_list.GetItemData(i);
- }
- if (i >= 0) {
- CMediaFormats& mf = AfxGetAppSettings().m_Formats;
- mf[i].SetExts(m_exts);
- m_exts = mf[i].GetExtsWithPeriod();
- UpdateData(FALSE);
- }
- }
-
- CMediaFormats& mf = AfxGetAppSettings().m_Formats;
-
- RegisterApp();
-
- f_setContextFiles = m_fContextFiles.GetCheck();
- f_setAssociatedWithIcon = m_fAssociatedWithIcons.GetCheck();
-
- if (m_bFileExtChanged) {
- if (f_setAssociatedWithIcon && IsNeededIconsLib() && !FileExists(GetProgramDir() + _T("\\mpciconlib.dll"))) {
- AfxMessageBox(IDS_MISSING_ICONS_LIB, MB_ICONEXCLAMATION | MB_OK, 0);
- }
-
- for (int i = 0; i < m_list.GetItemCount(); i++) {
- int iChecked = GetChecked(i);
- if (iChecked == 2) {
- continue;
- }
-
- CAtlList<CString> exts;
- Explode(mf[(int)m_list.GetItemData(i)].GetExtsWithPeriod(), exts, ' ');
-
- POSITION pos = exts.GetHeadPosition();
- while (pos) {
- RegisterExt(exts.GetNext(pos), mf[(int)m_list.GetItemData(i)].GetDescription(), !!iChecked);
- }
- }
-
- m_bFileExtChanged = false;
- }
- CRegKey key;
- if (m_fContextDir.GetCheck()) {
- if (ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\") PROGID _T(".enqueue"))) {
- key.SetStringValue(NULL, ResStr(IDS_ADD_TO_PLAYLIST));
- }
-
- if (ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\") PROGID _T(".enqueue\\command"))) {
- key.SetStringValue(NULL, GetEnqueueCommand());
- }
-
- if (ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\") PROGID _T(".play"))) {
- key.SetStringValue(NULL, ResStr(IDS_OPEN_WITH_MPC));
- }
-
- if (ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\") PROGID _T(".play\\command"))) {
- key.SetStringValue(NULL, GetOpenCommand());
- }
- } else {
- key.Attach(HKEY_CLASSES_ROOT);
- key.RecurseDeleteKey(_T("Directory\\shell\\") PROGID _T(".enqueue"));
- key.RecurseDeleteKey(_T("Directory\\shell\\") PROGID _T(".play"));
- }
-
- {
- SetListItemState(m_list.GetSelectionMark());
- }
-
- AddAutoPlayToRegistry(AP_VIDEO, !!m_apvideo.GetCheck());
- AddAutoPlayToRegistry(AP_MUSIC, !!m_apmusic.GetCheck());
- AddAutoPlayToRegistry(AP_AUDIOCD, !!m_apaudiocd.GetCheck());
- AddAutoPlayToRegistry(AP_DVDMOVIE, !!m_apdvd.GetCheck());
-
- AppSettings& s = AfxGetAppSettings();
- s.m_Formats.SetRtspHandler(m_iRtspHandler==0?RealMedia:m_iRtspHandler==1?QuickTime:DirectShow, !!m_fRtspFileExtFirst);
- s.fAssociatedWithIcons = !!m_fAssociatedWithIcons.GetCheck();
-
- SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
-
- return __super::OnApply();
+ UpdateData();
+
+ {
+ int i = m_list.GetSelectionMark();
+ if (i >= 0) {
+ i = (int)m_list.GetItemData(i);
+ }
+ if (i >= 0) {
+ CMediaFormats& mf = AfxGetAppSettings().m_Formats;
+ mf[i].SetExts(m_exts);
+ m_exts = mf[i].GetExtsWithPeriod();
+ UpdateData(FALSE);
+ }
+ }
+
+ CMediaFormats& mf = AfxGetAppSettings().m_Formats;
+
+ RegisterApp();
+
+ f_setContextFiles = m_fContextFiles.GetCheck();
+ f_setAssociatedWithIcon = m_fAssociatedWithIcons.GetCheck();
+
+ if (m_bFileExtChanged) {
+ if (f_setAssociatedWithIcon && IsNeededIconsLib() && !FileExists(GetProgramDir() + _T("\\mpciconlib.dll"))) {
+ AfxMessageBox(IDS_MISSING_ICONS_LIB, MB_ICONEXCLAMATION | MB_OK, 0);
+ }
+
+ for (int i = 0; i < m_list.GetItemCount(); i++) {
+ int iChecked = GetChecked(i);
+ if (iChecked == 2) {
+ continue;
+ }
+
+ CAtlList<CString> exts;
+ Explode(mf[(int)m_list.GetItemData(i)].GetExtsWithPeriod(), exts, ' ');
+
+ POSITION pos = exts.GetHeadPosition();
+ while (pos) {
+ RegisterExt(exts.GetNext(pos), mf[(int)m_list.GetItemData(i)].GetDescription(), !!iChecked);
+ }
+ }
+
+ m_bFileExtChanged = false;
+ }
+ CRegKey key;
+ if (m_fContextDir.GetCheck()) {
+ if (ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\") PROGID _T(".enqueue"))) {
+ key.SetStringValue(NULL, ResStr(IDS_ADD_TO_PLAYLIST));
+ }
+
+ if (ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\") PROGID _T(".enqueue\\command"))) {
+ key.SetStringValue(NULL, GetEnqueueCommand());
+ }
+
+ if (ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\") PROGID _T(".play"))) {
+ key.SetStringValue(NULL, ResStr(IDS_OPEN_WITH_MPC));
+ }
+
+ if (ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\") PROGID _T(".play\\command"))) {
+ key.SetStringValue(NULL, GetOpenCommand());
+ }
+ } else {
+ key.Attach(HKEY_CLASSES_ROOT);
+ key.RecurseDeleteKey(_T("Directory\\shell\\") PROGID _T(".enqueue"));
+ key.RecurseDeleteKey(_T("Directory\\shell\\") PROGID _T(".play"));
+ }
+
+ {
+ SetListItemState(m_list.GetSelectionMark());
+ }
+
+ AddAutoPlayToRegistry(AP_VIDEO, !!m_apvideo.GetCheck());
+ AddAutoPlayToRegistry(AP_MUSIC, !!m_apmusic.GetCheck());
+ AddAutoPlayToRegistry(AP_AUDIOCD, !!m_apaudiocd.GetCheck());
+ AddAutoPlayToRegistry(AP_DVDMOVIE, !!m_apdvd.GetCheck());
+
+ AppSettings& s = AfxGetAppSettings();
+ s.m_Formats.SetRtspHandler(m_iRtspHandler == 0 ? RealMedia : m_iRtspHandler == 1 ? QuickTime : DirectShow, !!m_fRtspFileExtFirst);
+ s.fAssociatedWithIcons = !!m_fAssociatedWithIcons.GetCheck();
+
+ SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
+
+ return __super::OnApply();
}
void CPPageFormats::OnNMClickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
-
- if (lpnmlv->iItem >= 0 && lpnmlv->iSubItem == COL_CATEGORY) {
- CRect r;
- m_list.GetItemRect(lpnmlv->iItem, r, LVIR_ICON);
- if (r.PtInRect(lpnmlv->ptAction)) {
- if (m_bInsufficientPrivileges) {
- MessageBox (ResStr (IDS_CANNOT_CHANGE_FORMAT));
- } else {
- SetChecked(lpnmlv->iItem, (GetChecked(lpnmlv->iItem)&1) == 0 ? 1 : 0);
- m_bFileExtChanged = true;
- SetModified();
- }
- }
- }
-
- *pResult = 0;
+ LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
+
+ if (lpnmlv->iItem >= 0 && lpnmlv->iSubItem == COL_CATEGORY) {
+ CRect r;
+ m_list.GetItemRect(lpnmlv->iItem, r, LVIR_ICON);
+ if (r.PtInRect(lpnmlv->ptAction)) {
+ if (m_bInsufficientPrivileges) {
+ MessageBox(ResStr(IDS_CANNOT_CHANGE_FORMAT));
+ } else {
+ SetChecked(lpnmlv->iItem, (GetChecked(lpnmlv->iItem) & 1) == 0 ? 1 : 0);
+ m_bFileExtChanged = true;
+ SetModified();
+ }
+ }
+ }
+
+ *pResult = 0;
}
-void CPPageFormats::OnLvnItemchangedList1(NMHDR *pNMHDR, LRESULT *pResult)
+void CPPageFormats::OnLvnItemchangedList1(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
+ LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
- if (pNMLV->iItem >= 0 && pNMLV->iSubItem == COL_CATEGORY
- && (pNMLV->uChanged&LVIF_STATE) && (pNMLV->uNewState&LVIS_SELECTED)) {
- m_exts = AfxGetAppSettings().m_Formats[(int)m_list.GetItemData(pNMLV->iItem)].GetExtsWithPeriod();
- UpdateData(FALSE);
- }
+ if (pNMLV->iItem >= 0 && pNMLV->iSubItem == COL_CATEGORY
+ && (pNMLV->uChanged & LVIF_STATE) && (pNMLV->uNewState & LVIS_SELECTED)) {
+ m_exts = AfxGetAppSettings().m_Formats[(int)m_list.GetItemData(pNMLV->iItem)].GetExtsWithPeriod();
+ UpdateData(FALSE);
+ }
- *pResult = 0;
+ *pResult = 0;
}
void CPPageFormats::OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- LV_ITEM* pItem = &pDispInfo->item;
+ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
+ LV_ITEM* pItem = &pDispInfo->item;
- *pResult = FALSE;
+ *pResult = FALSE;
- if (pItem->iItem < 0) {
- return;
- }
+ if (pItem->iItem < 0) {
+ return;
+ }
- if (pItem->iSubItem == COL_ENGINE) {
- *pResult = TRUE;
- }
+ if (pItem->iSubItem == COL_ENGINE) {
+ *pResult = TRUE;
+ }
}
void CPPageFormats::OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- LV_ITEM* pItem = &pDispInfo->item;
+ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
+ LV_ITEM* pItem = &pDispInfo->item;
- *pResult = FALSE;
+ *pResult = FALSE;
- if (pItem->iItem < 0) {
- return;
- }
+ if (pItem->iItem < 0) {
+ return;
+ }
- CMediaFormatCategory& mfc = AfxGetAppSettings().m_Formats[m_list.GetItemData(pItem->iItem)];
+ CMediaFormatCategory& mfc = AfxGetAppSettings().m_Formats[m_list.GetItemData(pItem->iItem)];
- CAtlList<CString> sl;
+ CAtlList<CString> sl;
- if (pItem->iSubItem == COL_ENGINE) {
- sl.AddTail(_T("DirectShow"));
- sl.AddTail(_T("RealMedia"));
- sl.AddTail(_T("QuickTime"));
- sl.AddTail(_T("ShockWave"));
+ if (pItem->iSubItem == COL_ENGINE) {
+ sl.AddTail(_T("DirectShow"));
+ sl.AddTail(_T("RealMedia"));
+ sl.AddTail(_T("QuickTime"));
+ sl.AddTail(_T("ShockWave"));
- int nSel = (int)mfc.GetEngineType();
+ int nSel = (int)mfc.GetEngineType();
- m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
+ m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
- *pResult = TRUE;
- }
+ *pResult = TRUE;
+ }
}
void CPPageFormats::OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- LV_ITEM* pItem = &pDispInfo->item;
+ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
+ LV_ITEM* pItem = &pDispInfo->item;
- *pResult = FALSE;
+ *pResult = FALSE;
- if (!m_list.m_fInPlaceDirty) {
- return;
- }
+ if (!m_list.m_fInPlaceDirty) {
+ return;
+ }
- if (pItem->iItem < 0) {
- return;
- }
+ if (pItem->iItem < 0) {
+ return;
+ }
- CMediaFormatCategory& mfc = AfxGetAppSettings().m_Formats[m_list.GetItemData(pItem->iItem)];
+ CMediaFormatCategory& mfc = AfxGetAppSettings().m_Formats[m_list.GetItemData(pItem->iItem)];
- if (pItem->iSubItem == COL_ENGINE && pItem->lParam >= 0) {
- mfc.SetEngineType((engine_t)pItem->lParam);
- m_list.SetItemText(pItem->iItem, pItem->iSubItem, pItem->pszText);
- *pResult = TRUE;
- }
+ if (pItem->iSubItem == COL_ENGINE && pItem->lParam >= 0) {
+ mfc.SetEngineType((engine_t)pItem->lParam);
+ m_list.SetItemText(pItem->iItem, pItem->iSubItem, pItem->pszText);
+ *pResult = TRUE;
+ }
- if (*pResult) {
- SetModified();
- }
+ if (*pResult) {
+ SetModified();
+ }
}
void CPPageFormats::OnBnClickedButton1()
{
- for (int i = 0, j = m_list.GetItemCount(); i < j; i++) {
- SetChecked(i, 1);
- }
- m_bFileExtChanged = true;
+ for (int i = 0, j = m_list.GetItemCount(); i < j; i++) {
+ SetChecked(i, 1);
+ }
+ m_bFileExtChanged = true;
- m_apvideo.SetCheck(1);
- m_apmusic.SetCheck(1);
- m_apaudiocd.SetCheck(1);
- m_apdvd.SetCheck(1);
+ m_apvideo.SetCheck(1);
+ m_apmusic.SetCheck(1);
+ m_apaudiocd.SetCheck(1);
+ m_apdvd.SetCheck(1);
- SetModified();
+ SetModified();
}
void CPPageFormats::OnBnClickedButton14()
{
- CMediaFormats& mf = AfxGetAppSettings().m_Formats;
-
- for (int i = 0, j = m_list.GetItemCount(); i < j; i++) {
- if (!mf[m_list.GetItemData(i)].GetLabel().CompareNoCase(_T("pls"))) {
- SetChecked(i, 0);
- continue;
- }
- SetChecked(i, mf[(int)m_list.GetItemData(i)].IsAudioOnly()?0:1);
- }
- m_bFileExtChanged = true;
-
- m_apvideo.SetCheck(1);
- m_apmusic.SetCheck(0);
- m_apaudiocd.SetCheck(0);
- m_apdvd.SetCheck(1);
-
- SetModified();
+ CMediaFormats& mf = AfxGetAppSettings().m_Formats;
+
+ for (int i = 0, j = m_list.GetItemCount(); i < j; i++) {
+ if (!mf[m_list.GetItemData(i)].GetLabel().CompareNoCase(_T("pls"))) {
+ SetChecked(i, 0);
+ continue;
+ }
+ SetChecked(i, mf[(int)m_list.GetItemData(i)].IsAudioOnly() ? 0 : 1);
+ }
+ m_bFileExtChanged = true;
+
+ m_apvideo.SetCheck(1);
+ m_apmusic.SetCheck(0);
+ m_apaudiocd.SetCheck(0);
+ m_apdvd.SetCheck(1);
+
+ SetModified();
}
void CPPageFormats::OnBnClickedButton13()
{
- CMediaFormats& mf = AfxGetAppSettings().m_Formats;
+ CMediaFormats& mf = AfxGetAppSettings().m_Formats;
- for (int i = 0, j = m_list.GetItemCount(); i < j; i++) {
- SetChecked(i, mf[(int)m_list.GetItemData(i)].IsAudioOnly()?1:0);
- }
- m_bFileExtChanged = true;
+ for (int i = 0, j = m_list.GetItemCount(); i < j; i++) {
+ SetChecked(i, mf[(int)m_list.GetItemData(i)].IsAudioOnly() ? 1 : 0);
+ }
+ m_bFileExtChanged = true;
- m_apvideo.SetCheck(0);
- m_apmusic.SetCheck(1);
- m_apaudiocd.SetCheck(1);
- m_apdvd.SetCheck(0);
+ m_apvideo.SetCheck(0);
+ m_apmusic.SetCheck(1);
+ m_apaudiocd.SetCheck(1);
+ m_apdvd.SetCheck(0);
- SetModified();
+ SetModified();
}
void CPPageFormats::OnBnVistaModify()
{
- CString strCmd;
- TCHAR strApp[_MAX_PATH];
+ CString strCmd;
+ TCHAR strApp[_MAX_PATH];
- strCmd.Format (_T("/adminoption %d"), IDD);
- GetModuleFileNameEx (GetCurrentProcess(), AfxGetMyApp()->m_hInstance, strApp, _MAX_PATH);
+ strCmd.Format(_T("/adminoption %d"), IDD);
+ GetModuleFileNameEx(GetCurrentProcess(), AfxGetMyApp()->m_hInstance, strApp, _MAX_PATH);
- AfxGetMyApp()->RunAsAdministrator (strApp, strCmd, true);
+ AfxGetMyApp()->RunAsAdministrator(strApp, strCmd, true);
- for (int i = 0; i < m_list.GetItemCount(); i++) {
- SetListItemState(i);
- }
+ for (int i = 0; i < m_list.GetItemCount(); i++) {
+ SetListItemState(i);
+ }
}
void CPPageFormats::OnBnClickedButton12()
{
- int i = m_list.GetSelectionMark();
- if (i < 0) {
- return;
- }
- i = (int)m_list.GetItemData(i);
- CMediaFormats& mf = AfxGetAppSettings().m_Formats;
- mf[i].RestoreDefaultExts();
- m_exts = mf[i].GetExtsWithPeriod();
- SetListItemState(m_list.GetSelectionMark());
- UpdateData(FALSE);
-
- SetModified();
+ int i = m_list.GetSelectionMark();
+ if (i < 0) {
+ return;
+ }
+ i = (int)m_list.GetItemData(i);
+ CMediaFormats& mf = AfxGetAppSettings().m_Formats;
+ mf[i].RestoreDefaultExts();
+ m_exts = mf[i].GetExtsWithPeriod();
+ SetListItemState(m_list.GetSelectionMark());
+ UpdateData(FALSE);
+
+ SetModified();
}
void CPPageFormats::OnBnClickedButton11()
{
- UpdateData();
- int i = m_list.GetSelectionMark();
- if (i < 0) {
- return;
- }
- i = (int)m_list.GetItemData(i);
- CMediaFormats& mf = AfxGetAppSettings().m_Formats;
- mf[i].SetExts(m_exts);
- m_exts = mf[i].GetExtsWithPeriod();
- SetListItemState(m_list.GetSelectionMark());
- UpdateData(FALSE);
-
- SetModified();
+ UpdateData();
+ int i = m_list.GetSelectionMark();
+ if (i < 0) {
+ return;
+ }
+ i = (int)m_list.GetItemData(i);
+ CMediaFormats& mf = AfxGetAppSettings().m_Formats;
+ mf[i].SetExts(m_exts);
+ m_exts = mf[i].GetExtsWithPeriod();
+ SetListItemState(m_list.GetSelectionMark());
+ UpdateData(FALSE);
+
+ SetModified();
}
void CPPageFormats::OnFilesAssocModified()
{
- m_bFileExtChanged = true;
- SetModified();
+ m_bFileExtChanged = true;
+ SetModified();
}
void CPPageFormats::OnUpdateButtonDefault(CCmdUI* pCmdUI)
{
- int i = m_list.GetSelectionMark();
- if (i < 0) {
- pCmdUI->Enable(FALSE);
- return;
- }
- i = (int)m_list.GetItemData(i);
-
- CString orgexts, newexts;
- GetDlgItem(IDC_EDIT1)->GetWindowText(newexts);
- newexts.Trim();
- orgexts = AfxGetAppSettings().m_Formats[i].GetBackupExtsWithPeriod();
-
- pCmdUI->Enable(!!newexts.CompareNoCase(orgexts));
+ int i = m_list.GetSelectionMark();
+ if (i < 0) {
+ pCmdUI->Enable(FALSE);
+ return;
+ }
+ i = (int)m_list.GetItemData(i);
+
+ CString orgexts, newexts;
+ GetDlgItem(IDC_EDIT1)->GetWindowText(newexts);
+ newexts.Trim();
+ orgexts = AfxGetAppSettings().m_Formats[i].GetBackupExtsWithPeriod();
+
+ pCmdUI->Enable(!!newexts.CompareNoCase(orgexts));
}
void CPPageFormats::OnUpdateButtonSet(CCmdUI* pCmdUI)
{
- int i = m_list.GetSelectionMark();
- if (i < 0) {
- pCmdUI->Enable(FALSE);
- return;
- }
- i = (int)m_list.GetItemData(i);
-
- CString orgexts, newexts;
- GetDlgItem(IDC_EDIT1)->GetWindowText(newexts);
- newexts.Trim();
- orgexts = AfxGetAppSettings().m_Formats[i].GetExtsWithPeriod();
-
- pCmdUI->Enable(!!newexts.CompareNoCase(orgexts));
+ int i = m_list.GetSelectionMark();
+ if (i < 0) {
+ pCmdUI->Enable(FALSE);
+ return;
+ }
+ i = (int)m_list.GetItemData(i);
+
+ CString orgexts, newexts;
+ GetDlgItem(IDC_EDIT1)->GetWindowText(newexts);
+ newexts.Trim();
+ orgexts = AfxGetAppSettings().m_Formats[i].GetExtsWithPeriod();
+
+ pCmdUI->Enable(!!newexts.CompareNoCase(orgexts));
}
diff --git a/src/mpc-hc/PPageFormats.h b/src/mpc-hc/PPageFormats.h
index 8c06e844b..22a32abb6 100644
--- a/src/mpc-hc/PPageFormats.h
+++ b/src/mpc-hc/PPageFormats.h
@@ -32,73 +32,73 @@
class CPPageFormats : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageFormats)
+ DECLARE_DYNAMIC(CPPageFormats)
private:
- CImageList m_onoff;
- bool m_bInsufficientPrivileges;
- bool m_bFileExtChanged;
+ CImageList m_onoff;
+ bool m_bInsufficientPrivileges;
+ bool m_bFileExtChanged;
- int GetChecked(int iItem);
- void SetChecked(int iItem, int fChecked);
+ int GetChecked(int iItem);
+ void SetChecked(int iItem, int fChecked);
- typedef enum {AP_VIDEO=0,AP_MUSIC,AP_AUDIOCD,AP_DVDMOVIE} autoplay_t;
- void AddAutoPlayToRegistry(autoplay_t ap, bool fRegister);
- bool IsAutoPlayRegistered(autoplay_t ap);
+ typedef enum {AP_VIDEO = 0, AP_MUSIC, AP_AUDIOCD, AP_DVDMOVIE} autoplay_t;
+ void AddAutoPlayToRegistry(autoplay_t ap, bool fRegister);
+ bool IsAutoPlayRegistered(autoplay_t ap);
- void SetListItemState(int nItem);
- static CComPtr<IApplicationAssociationRegistration> m_pAAR;
- static BOOL SetFileAssociation(CString strExt, CString extfile, bool fRegister);
- static CString GetOpenCommand();
- static CString GetEnqueueCommand();
+ void SetListItemState(int nItem);
+ static CComPtr<IApplicationAssociationRegistration> m_pAAR;
+ static BOOL SetFileAssociation(CString strExt, CString extfile, bool fRegister);
+ static CString GetOpenCommand();
+ static CString GetEnqueueCommand();
- bool IsNeededIconsLib();
+ bool IsNeededIconsLib();
public:
- CPPageFormats();
- virtual ~CPPageFormats();
-
- static bool RegisterApp();
- static bool IsRegistered(CString ext);
- static bool RegisterExt(CString ext, CString strLabel, bool fRegister);
-
- enum {COL_CATEGORY, COL_ENGINE};
- CPlayerListCtrl m_list;
- CString m_exts;
- CStatic m_autoplay;
- CButton m_apvideo;
- CButton m_apmusic;
- CButton m_apaudiocd;
- CButton m_apdvd;
- int m_iRtspHandler;
- BOOL m_fRtspFileExtFirst;
-
- // Dialog Data
- enum { IDD = IDD_PPAGEFORMATS };
+ CPPageFormats();
+ virtual ~CPPageFormats();
+
+ static bool RegisterApp();
+ static bool IsRegistered(CString ext);
+ static bool RegisterExt(CString ext, CString strLabel, bool fRegister);
+
+ enum {COL_CATEGORY, COL_ENGINE};
+ CPlayerListCtrl m_list;
+ CString m_exts;
+ CStatic m_autoplay;
+ CButton m_apvideo;
+ CButton m_apmusic;
+ CButton m_apaudiocd;
+ CButton m_apdvd;
+ int m_iRtspHandler;
+ BOOL m_fRtspFileExtFirst;
+
+ // Dialog Data
+ enum { IDD = IDD_PPAGEFORMATS };
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnNMClickList1(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnLvnItemchangedList1(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnBnClickedButton1();
- afx_msg void OnBnClickedButton14();
- afx_msg void OnBnClickedButton13();
- afx_msg void OnBnClickedButton12();
- afx_msg void OnBnClickedButton11();
- afx_msg void OnBnVistaModify();
- afx_msg void OnFilesAssocModified();
- afx_msg void OnUpdateButtonDefault(CCmdUI* pCmdUI);
- afx_msg void OnUpdateButtonSet(CCmdUI* pCmdUI);
- CButton m_fContextDir;
- CButton m_fContextFiles;
- CButton m_fAssociatedWithIcons;
+ afx_msg void OnNMClickList1(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnLvnItemchangedList1(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnBnClickedButton1();
+ afx_msg void OnBnClickedButton14();
+ afx_msg void OnBnClickedButton13();
+ afx_msg void OnBnClickedButton12();
+ afx_msg void OnBnClickedButton11();
+ afx_msg void OnBnVistaModify();
+ afx_msg void OnFilesAssocModified();
+ afx_msg void OnUpdateButtonDefault(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateButtonSet(CCmdUI* pCmdUI);
+ CButton m_fContextDir;
+ CButton m_fContextFiles;
+ CButton m_fAssociatedWithIcons;
};
diff --git a/src/mpc-hc/PPageFullscreen.cpp b/src/mpc-hc/PPageFullscreen.cpp
index eb5002408..206190341 100644
--- a/src/mpc-hc/PPageFullscreen.cpp
+++ b/src/mpc-hc/PPageFullscreen.cpp
@@ -33,18 +33,18 @@
IMPLEMENT_DYNAMIC(CPPageFullscreen, CPPageBase)
CPPageFullscreen::CPPageFullscreen()
- : CPPageBase(CPPageFullscreen::IDD, CPPageFullscreen::IDD)
- , m_launchfullscreen(FALSE)
- , m_fSetFullscreenRes(FALSE)
- , m_fSetDefault(FALSE)
- , m_iShowBarsWhenFullScreen(FALSE)
- , m_nShowBarsWhenFullScreenTimeOut(0)
- , m_fExitFullScreenAtTheEnd(FALSE)
- , m_fRestoreResAfterExit(TRUE)
- , m_list(0)
- , m_iSel(-1)
+ : CPPageBase(CPPageFullscreen::IDD, CPPageFullscreen::IDD)
+ , m_launchfullscreen(FALSE)
+ , m_fSetFullscreenRes(FALSE)
+ , m_fSetDefault(FALSE)
+ , m_iShowBarsWhenFullScreen(FALSE)
+ , m_nShowBarsWhenFullScreenTimeOut(0)
+ , m_fExitFullScreenAtTheEnd(FALSE)
+ , m_fRestoreResAfterExit(TRUE)
+ , m_list(0)
+ , m_iSel(-1)
{
- memset(m_iSeldm, -1, sizeof(m_iSeldm));
+ memset(m_iSeldm, -1, sizeof(m_iSeldm));
}
CPPageFullscreen::~CPPageFullscreen()
@@ -53,691 +53,691 @@ CPPageFullscreen::~CPPageFullscreen()
void CPPageFullscreen::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Check(pDX, IDC_CHECK1, m_launchfullscreen);
- DDX_Check(pDX, IDC_CHECK2, m_fSetFullscreenRes);
- DDX_Check(pDX, IDC_CHECK3, m_fSetDefault);
- DDX_CBIndex(pDX, IDC_COMBO1, m_iMonitorType);
- DDX_Control(pDX, IDC_COMBO1, m_iMonitorTypeCtrl);
- DDX_Control(pDX, IDC_LIST1, m_list);
- DDX_Check(pDX, IDC_CHECK4, m_iShowBarsWhenFullScreen);
- DDX_Text(pDX, IDC_EDIT1, m_nShowBarsWhenFullScreenTimeOut);
- DDX_Check(pDX, IDC_CHECK5, m_fExitFullScreenAtTheEnd);
- DDX_Control(pDX, IDC_SPIN1, m_nTimeOutCtrl);
- DDX_Check(pDX, IDC_RESTORERESCHECK, m_fRestoreResAfterExit);
+ __super::DoDataExchange(pDX);
+ DDX_Check(pDX, IDC_CHECK1, m_launchfullscreen);
+ DDX_Check(pDX, IDC_CHECK2, m_fSetFullscreenRes);
+ DDX_Check(pDX, IDC_CHECK3, m_fSetDefault);
+ DDX_CBIndex(pDX, IDC_COMBO1, m_iMonitorType);
+ DDX_Control(pDX, IDC_COMBO1, m_iMonitorTypeCtrl);
+ DDX_Control(pDX, IDC_LIST1, m_list);
+ DDX_Check(pDX, IDC_CHECK4, m_iShowBarsWhenFullScreen);
+ DDX_Text(pDX, IDC_EDIT1, m_nShowBarsWhenFullScreenTimeOut);
+ DDX_Check(pDX, IDC_CHECK5, m_fExitFullScreenAtTheEnd);
+ DDX_Control(pDX, IDC_SPIN1, m_nTimeOutCtrl);
+ DDX_Check(pDX, IDC_RESTORERESCHECK, m_fRestoreResAfterExit);
}
BEGIN_MESSAGE_MAP(CPPageFullscreen, CPPageBase)
- ON_CBN_SELCHANGE(IDC_COMBO1, OnUpdateFullScrCombo)
- ON_NOTIFY(LVN_DOLABELEDIT, IDC_LIST1, OnDolabeleditList)
- ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST1, OnLvnItemchangedList1)
- ON_NOTIFY(LVN_BEGINLABELEDIT, IDC_LIST1, OnBeginlabeleditList)
- ON_NOTIFY(LVN_ENDLABELEDIT, IDC_LIST1, OnEndlabeleditList)
- ON_NOTIFY(NM_CLICK, IDC_LIST1, OnNMClickList1)
- ON_NOTIFY(NM_CUSTOMDRAW, IDC_LIST1, OnCustomdrawList)
- ON_CLBN_CHKCHANGE(IDC_LIST1, OnCheckChangeList)
- ON_UPDATE_COMMAND_UI(IDC_LIST1, OnUpdateList)
- ON_UPDATE_COMMAND_UI(IDC_CHECK3, OnUpdateApplyDefault)
- ON_UPDATE_COMMAND_UI(IDC_SPIN1, OnUpdateTimeout)
- ON_UPDATE_COMMAND_UI(IDC_EDIT1, OnUpdateTimeout)
- ON_UPDATE_COMMAND_UI(IDC_RESTORERESCHECK, OnUpdateRestoreRes)
- ON_BN_CLICKED(IDC_BUTTON2, OnRemove)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON2, OnUpdateRemove)
- ON_BN_CLICKED(IDC_BUTTON1, OnAdd)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateAdd)
- ON_BN_CLICKED(IDC_BUTTON3, OnMoveUp)
- ON_BN_CLICKED(IDC_BUTTON4, OnMoveDown)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON3, OnUpdateUp)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON4, OnUpdateDown)
+ ON_CBN_SELCHANGE(IDC_COMBO1, OnUpdateFullScrCombo)
+ ON_NOTIFY(LVN_DOLABELEDIT, IDC_LIST1, OnDolabeleditList)
+ ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST1, OnLvnItemchangedList1)
+ ON_NOTIFY(LVN_BEGINLABELEDIT, IDC_LIST1, OnBeginlabeleditList)
+ ON_NOTIFY(LVN_ENDLABELEDIT, IDC_LIST1, OnEndlabeleditList)
+ ON_NOTIFY(NM_CLICK, IDC_LIST1, OnNMClickList1)
+ ON_NOTIFY(NM_CUSTOMDRAW, IDC_LIST1, OnCustomdrawList)
+ ON_CLBN_CHKCHANGE(IDC_LIST1, OnCheckChangeList)
+ ON_UPDATE_COMMAND_UI(IDC_LIST1, OnUpdateList)
+ ON_UPDATE_COMMAND_UI(IDC_CHECK3, OnUpdateApplyDefault)
+ ON_UPDATE_COMMAND_UI(IDC_SPIN1, OnUpdateTimeout)
+ ON_UPDATE_COMMAND_UI(IDC_EDIT1, OnUpdateTimeout)
+ ON_UPDATE_COMMAND_UI(IDC_RESTORERESCHECK, OnUpdateRestoreRes)
+ ON_BN_CLICKED(IDC_BUTTON2, OnRemove)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON2, OnUpdateRemove)
+ ON_BN_CLICKED(IDC_BUTTON1, OnAdd)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateAdd)
+ ON_BN_CLICKED(IDC_BUTTON3, OnMoveUp)
+ ON_BN_CLICKED(IDC_BUTTON4, OnMoveDown)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON3, OnUpdateUp)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON4, OnUpdateDown)
END_MESSAGE_MAP()
// CPPagePlayer message handlers
BOOL CPPageFullscreen::OnInitDialog()
{
- __super::OnInitDialog();
-
- SetHandCursor(m_hWnd, IDC_COMBO1);
-
- AppSettings& s = AfxGetAppSettings();
-
- m_launchfullscreen = s.fLaunchfullscreen;
- m_AutoChangeFullscrRes = s.AutoChangeFullscrRes;
- m_fSetDefault = s.AutoChangeFullscrRes.bApplyDefault;
- m_f_hmonitor = s.strFullScreenMonitor;
- m_iShowBarsWhenFullScreen = s.fShowBarsWhenFullScreen;
- m_nShowBarsWhenFullScreenTimeOut = s.nShowBarsWhenFullScreenTimeOut;
- m_nTimeOutCtrl.SetRange(-1, 10);
- m_fExitFullScreenAtTheEnd = s.fExitFullScreenAtTheEnd;
- m_fRestoreResAfterExit = s.fRestoreResAfterExit;
-
- CString str;
- m_iMonitorType = 0;
- CMonitor monitor;
- CMonitors monitors;
-
- CString strCurMon;
-
- monitor = monitors.GetNearestMonitor(AfxGetApp()->m_pMainWnd);
- monitor.GetName(strCurMon);
-
- m_iMonitorTypeCtrl.AddString(ResStr(IDS_FULLSCREENMONITOR_CURRENT));
- m_MonitorDisplayNames.Add(_T("Current"));
- if (m_f_hmonitor == _T("Current")) {
- m_iMonitorType = m_iMonitorTypeCtrl.GetCount()-1;
- }
-
- for ( int i = 0; i < monitors.GetCount(); i++ ) {
- monitor = monitors.GetMonitor( i );
- monitor.GetName(str);
-
- if (monitor.IsMonitor()) {
- DISPLAY_DEVICE displayDevice;
- ZeroMemory(&displayDevice, sizeof(displayDevice));
- displayDevice.cb = sizeof(displayDevice);
- VERIFY(EnumDisplayDevices(str, 0, &displayDevice, 0));
- if (str == strCurMon) {
- m_iMonitorTypeCtrl.AddString(str+_T(" - [") + ResStr(IDS_FULLSCREENMONITOR_CURRENT) +_T("] - ")+ displayDevice.DeviceString);
- } else {
- m_iMonitorTypeCtrl.AddString(str+_T(" - ")+ displayDevice.DeviceString);
- }
- m_MonitorDisplayNames.Add(str);
-
- if (m_f_hmonitor == str && m_iMonitorType == 0) {
- m_iMonitorType = m_iMonitorTypeCtrl.GetCount()-1;
- }
- }
- }
-
- if (m_iMonitorTypeCtrl.GetCount() > 2) {
- GetDlgItem(IDC_COMBO1)->EnableWindow(TRUE);
- } else {
- m_iMonitorType = 0;
- GetDlgItem(IDC_COMBO1)->EnableWindow(FALSE);
- }
-
- m_list.SetExtendedStyle(m_list.GetExtendedStyle()|LVS_EX_FULLROWSELECT|LVS_EX_DOUBLEBUFFER
- |LVS_EX_GRIDLINES|LVS_EX_BORDERSELECT|LVS_EX_ONECLICKACTIVATE|LVS_EX_CHECKBOXES|LVS_EX_FLATSB);
- m_list.InsertColumn(COL_Z, ResStr(IDS_PPAGE_FS_CLN_ON_OFF), LVCFMT_LEFT, 60);
- m_list.InsertColumn(COL_VFR_F, ResStr(IDS_PPAGE_FS_CLN_FROM_FPS), LVCFMT_RIGHT, 60);
- m_list.InsertColumn(COL_VFR_T, ResStr(IDS_PPAGE_FS_CLN_TO_FPS), LVCFMT_RIGHT, 60);
- m_list.InsertColumn(COL_SRR, ResStr(IDS_PPAGE_FS_CLN_DISPLAY_MODE), LVCFMT_LEFT, 135);
-
- ModesUpdate();
- UpdateData(FALSE);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ SetHandCursor(m_hWnd, IDC_COMBO1);
+
+ AppSettings& s = AfxGetAppSettings();
+
+ m_launchfullscreen = s.fLaunchfullscreen;
+ m_AutoChangeFullscrRes = s.AutoChangeFullscrRes;
+ m_fSetDefault = s.AutoChangeFullscrRes.bApplyDefault;
+ m_f_hmonitor = s.strFullScreenMonitor;
+ m_iShowBarsWhenFullScreen = s.fShowBarsWhenFullScreen;
+ m_nShowBarsWhenFullScreenTimeOut = s.nShowBarsWhenFullScreenTimeOut;
+ m_nTimeOutCtrl.SetRange(-1, 10);
+ m_fExitFullScreenAtTheEnd = s.fExitFullScreenAtTheEnd;
+ m_fRestoreResAfterExit = s.fRestoreResAfterExit;
+
+ CString str;
+ m_iMonitorType = 0;
+ CMonitor monitor;
+ CMonitors monitors;
+
+ CString strCurMon;
+
+ monitor = monitors.GetNearestMonitor(AfxGetApp()->m_pMainWnd);
+ monitor.GetName(strCurMon);
+
+ m_iMonitorTypeCtrl.AddString(ResStr(IDS_FULLSCREENMONITOR_CURRENT));
+ m_MonitorDisplayNames.Add(_T("Current"));
+ if (m_f_hmonitor == _T("Current")) {
+ m_iMonitorType = m_iMonitorTypeCtrl.GetCount() - 1;
+ }
+
+ for (int i = 0; i < monitors.GetCount(); i++) {
+ monitor = monitors.GetMonitor(i);
+ monitor.GetName(str);
+
+ if (monitor.IsMonitor()) {
+ DISPLAY_DEVICE displayDevice;
+ ZeroMemory(&displayDevice, sizeof(displayDevice));
+ displayDevice.cb = sizeof(displayDevice);
+ VERIFY(EnumDisplayDevices(str, 0, &displayDevice, 0));
+ if (str == strCurMon) {
+ m_iMonitorTypeCtrl.AddString(str + _T(" - [") + ResStr(IDS_FULLSCREENMONITOR_CURRENT) + _T("] - ") + displayDevice.DeviceString);
+ } else {
+ m_iMonitorTypeCtrl.AddString(str + _T(" - ") + displayDevice.DeviceString);
+ }
+ m_MonitorDisplayNames.Add(str);
+
+ if (m_f_hmonitor == str && m_iMonitorType == 0) {
+ m_iMonitorType = m_iMonitorTypeCtrl.GetCount() - 1;
+ }
+ }
+ }
+
+ if (m_iMonitorTypeCtrl.GetCount() > 2) {
+ GetDlgItem(IDC_COMBO1)->EnableWindow(TRUE);
+ } else {
+ m_iMonitorType = 0;
+ GetDlgItem(IDC_COMBO1)->EnableWindow(FALSE);
+ }
+
+ m_list.SetExtendedStyle(m_list.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER
+ | LVS_EX_GRIDLINES | LVS_EX_BORDERSELECT | LVS_EX_ONECLICKACTIVATE | LVS_EX_CHECKBOXES | LVS_EX_FLATSB);
+ m_list.InsertColumn(COL_Z, ResStr(IDS_PPAGE_FS_CLN_ON_OFF), LVCFMT_LEFT, 60);
+ m_list.InsertColumn(COL_VFR_F, ResStr(IDS_PPAGE_FS_CLN_FROM_FPS), LVCFMT_RIGHT, 60);
+ m_list.InsertColumn(COL_VFR_T, ResStr(IDS_PPAGE_FS_CLN_TO_FPS), LVCFMT_RIGHT, 60);
+ m_list.InsertColumn(COL_SRR, ResStr(IDS_PPAGE_FS_CLN_DISPLAY_MODE), LVCFMT_LEFT, 135);
+
+ ModesUpdate();
+ UpdateData(FALSE);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CPPageFullscreen::OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult)
{
- NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
- *pResult = CDRF_DODEFAULT;
-
- if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage ) {
- *pResult = CDRF_NOTIFYITEMDRAW;
- } else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage ) {
- *pResult = CDRF_NOTIFYSUBITEMDRAW;
- } else if ( (CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage ) {
- COLORREF crText;
- if (m_list.GetCheck((int)pLVCD->nmcd.dwItemSpec) == 0) {
- crText = RGB(128,128,128);
- } else {
- crText = RGB(0,0,0);
- }
- pLVCD->clrText = crText;
- *pResult = CDRF_DODEFAULT;
- }
+ NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
+ *pResult = CDRF_DODEFAULT;
+
+ if (CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage) {
+ *pResult = CDRF_NOTIFYITEMDRAW;
+ } else if (CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage) {
+ *pResult = CDRF_NOTIFYSUBITEMDRAW;
+ } else if ((CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage) {
+ COLORREF crText;
+ if (m_list.GetCheck((int)pLVCD->nmcd.dwItemSpec) == 0) {
+ crText = RGB(128, 128, 128);
+ } else {
+ crText = RGB(0, 0, 0);
+ }
+ pLVCD->clrText = crText;
+ *pResult = CDRF_DODEFAULT;
+ }
}
BOOL CPPageFullscreen::OnApply()
{
- UpdateData();
-
- AppSettings& s = AfxGetAppSettings();
- m_AutoChangeFullscrRes.bEnabled = !!m_fSetFullscreenRes;
-
- for (int i = 0; i < MaxFpsCount; i++) {
- int n = m_iSeldm[i];
- if (n >= 0 && (size_t)n < m_dms.GetCount() && i < m_list.GetItemCount()) {
- m_AutoChangeFullscrRes.dmFullscreenRes[i].dmFSRes = m_dms[n];
- m_AutoChangeFullscrRes.dmFullscreenRes[i].fChecked = !!m_list.GetCheck(i);
- m_AutoChangeFullscrRes.dmFullscreenRes[i].fIsData = true;
-
- if (i==0) {
- m_AutoChangeFullscrRes.dmFullscreenRes[i].vfr_from = 0;
- m_AutoChangeFullscrRes.dmFullscreenRes[i].vfr_to = 0;
- } else {
- m_AutoChangeFullscrRes.dmFullscreenRes[i].vfr_from = wcstod(m_list.GetItemText(i, COL_VFR_F), NULL);
- m_AutoChangeFullscrRes.dmFullscreenRes[i].vfr_to = wcstod(m_list.GetItemText(i, COL_VFR_T), NULL);
- }
- } else {
- m_AutoChangeFullscrRes.dmFullscreenRes[i].fIsData = false;
- m_AutoChangeFullscrRes.dmFullscreenRes[i].vfr_from = 0;
- m_AutoChangeFullscrRes.dmFullscreenRes[i].vfr_to = 0;
- m_AutoChangeFullscrRes.dmFullscreenRes[i].fChecked = 0;
- m_AutoChangeFullscrRes.dmFullscreenRes[i].dmFSRes.bpp = 0;
- m_AutoChangeFullscrRes.dmFullscreenRes[i].dmFSRes.dmDisplayFlags = 0;
- m_AutoChangeFullscrRes.dmFullscreenRes[i].dmFSRes.freq = 0;
- m_AutoChangeFullscrRes.dmFullscreenRes[i].dmFSRes.fValid = 0;
- m_AutoChangeFullscrRes.dmFullscreenRes[i].dmFSRes.size = 0;
- }
- }
-
- m_AutoChangeFullscrRes.bApplyDefault = !!m_fSetDefault;
- s.AutoChangeFullscrRes = m_AutoChangeFullscrRes;
- s.fLaunchfullscreen = !!m_launchfullscreen;
- s.strFullScreenMonitor = m_f_hmonitor;
- s.fShowBarsWhenFullScreen = !!m_iShowBarsWhenFullScreen;
- s.nShowBarsWhenFullScreenTimeOut = m_nShowBarsWhenFullScreenTimeOut;
- s.fExitFullScreenAtTheEnd = !!m_fExitFullScreenAtTheEnd;
- s.fRestoreResAfterExit = !!m_fRestoreResAfterExit;
-
- return __super::OnApply();
+ UpdateData();
+
+ AppSettings& s = AfxGetAppSettings();
+ m_AutoChangeFullscrRes.bEnabled = !!m_fSetFullscreenRes;
+
+ for (int i = 0; i < MaxFpsCount; i++) {
+ int n = m_iSeldm[i];
+ if (n >= 0 && (size_t)n < m_dms.GetCount() && i < m_list.GetItemCount()) {
+ m_AutoChangeFullscrRes.dmFullscreenRes[i].dmFSRes = m_dms[n];
+ m_AutoChangeFullscrRes.dmFullscreenRes[i].fChecked = !!m_list.GetCheck(i);
+ m_AutoChangeFullscrRes.dmFullscreenRes[i].fIsData = true;
+
+ if (i == 0) {
+ m_AutoChangeFullscrRes.dmFullscreenRes[i].vfr_from = 0;
+ m_AutoChangeFullscrRes.dmFullscreenRes[i].vfr_to = 0;
+ } else {
+ m_AutoChangeFullscrRes.dmFullscreenRes[i].vfr_from = wcstod(m_list.GetItemText(i, COL_VFR_F), NULL);
+ m_AutoChangeFullscrRes.dmFullscreenRes[i].vfr_to = wcstod(m_list.GetItemText(i, COL_VFR_T), NULL);
+ }
+ } else {
+ m_AutoChangeFullscrRes.dmFullscreenRes[i].fIsData = false;
+ m_AutoChangeFullscrRes.dmFullscreenRes[i].vfr_from = 0;
+ m_AutoChangeFullscrRes.dmFullscreenRes[i].vfr_to = 0;
+ m_AutoChangeFullscrRes.dmFullscreenRes[i].fChecked = 0;
+ m_AutoChangeFullscrRes.dmFullscreenRes[i].dmFSRes.bpp = 0;
+ m_AutoChangeFullscrRes.dmFullscreenRes[i].dmFSRes.dmDisplayFlags = 0;
+ m_AutoChangeFullscrRes.dmFullscreenRes[i].dmFSRes.freq = 0;
+ m_AutoChangeFullscrRes.dmFullscreenRes[i].dmFSRes.fValid = 0;
+ m_AutoChangeFullscrRes.dmFullscreenRes[i].dmFSRes.size = 0;
+ }
+ }
+
+ m_AutoChangeFullscrRes.bApplyDefault = !!m_fSetDefault;
+ s.AutoChangeFullscrRes = m_AutoChangeFullscrRes;
+ s.fLaunchfullscreen = !!m_launchfullscreen;
+ s.strFullScreenMonitor = m_f_hmonitor;
+ s.fShowBarsWhenFullScreen = !!m_iShowBarsWhenFullScreen;
+ s.nShowBarsWhenFullScreenTimeOut = m_nShowBarsWhenFullScreenTimeOut;
+ s.fExitFullScreenAtTheEnd = !!m_fExitFullScreenAtTheEnd;
+ s.fRestoreResAfterExit = !!m_fRestoreResAfterExit;
+
+ return __super::OnApply();
}
void CPPageFullscreen::OnNMClickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
- if (lpnmlv->iItem >= 0 && lpnmlv->iSubItem == COL_SRR) {
- }
- *pResult = 0;
+ LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
+ if (lpnmlv->iItem >= 0 && lpnmlv->iSubItem == COL_SRR) {
+ }
+ *pResult = 0;
}
-void CPPageFullscreen::OnLvnItemchangedList1(NMHDR *pNMHDR, LRESULT *pResult)
+void CPPageFullscreen::OnLvnItemchangedList1(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
- if (pNMLV->iItem >= 0 && pNMLV->iSubItem == COL_SRR) {
- }
- *pResult = 0;
+ LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
+ if (pNMLV->iItem >= 0 && pNMLV->iSubItem == COL_SRR) {
+ }
+ *pResult = 0;
}
void CPPageFullscreen::OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- LV_ITEM* pItem = &pDispInfo->item;
- *pResult = FALSE;
- if (pItem->iItem < 0) {
- return;
- }
- *pResult = TRUE;
+ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
+ LV_ITEM* pItem = &pDispInfo->item;
+ *pResult = FALSE;
+ if (pItem->iItem < 0) {
+ return;
+ }
+ *pResult = TRUE;
}
void CPPageFullscreen::OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- LV_ITEM* pItem = &pDispInfo->item;
- *pResult = FALSE;
- if (pItem->iItem < 0) {
- return;
- }
- CAtlList<CString> sl1;
- CMonitors monitors;
- CString strModes;
- switch (pItem->iSubItem) {
- case COL_SRR:
- sl1.RemoveAll();
- for (int i=0; (size_t)i<sl.GetCount(); i++) {
- sl1.AddTail(sl[i]);
- if (m_list.GetItemText(pItem->iItem, COL_SRR) == sl[i]) {
- m_iSel = i;
- }
- }
- m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl1, m_iSel);
- break;
- case COL_VFR_F:
- case COL_VFR_T:
- if (pItem->iItem != 0) {
- m_list.ShowInPlaceFloatEdit(pItem->iItem, pItem->iSubItem);
- //CEdit* pFloatEdit = (CEdit*)m_list.GetDlgItem(IDC_EDIT1);
- }
- break;
- }
- m_list.RedrawWindow();
- *pResult = TRUE;
+ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
+ LV_ITEM* pItem = &pDispInfo->item;
+ *pResult = FALSE;
+ if (pItem->iItem < 0) {
+ return;
+ }
+ CAtlList<CString> sl1;
+ CMonitors monitors;
+ CString strModes;
+ switch (pItem->iSubItem) {
+ case COL_SRR:
+ sl1.RemoveAll();
+ for (int i = 0; (size_t)i < sl.GetCount(); i++) {
+ sl1.AddTail(sl[i]);
+ if (m_list.GetItemText(pItem->iItem, COL_SRR) == sl[i]) {
+ m_iSel = i;
+ }
+ }
+ m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl1, m_iSel);
+ break;
+ case COL_VFR_F:
+ case COL_VFR_T:
+ if (pItem->iItem != 0) {
+ m_list.ShowInPlaceFloatEdit(pItem->iItem, pItem->iSubItem);
+ //CEdit* pFloatEdit = (CEdit*)m_list.GetDlgItem(IDC_EDIT1);
+ }
+ break;
+ }
+ m_list.RedrawWindow();
+ *pResult = TRUE;
}
void CPPageFullscreen::OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- LV_ITEM* pItem = &pDispInfo->item;
- *pResult = FALSE;
- if (!m_list.m_fInPlaceDirty) {
- return;
- }
- if (pItem->iItem < 0) {
- return;
- }
- switch (pItem->iSubItem) {
- case COL_SRR:
- if (pItem->lParam >= 0) {
- m_iSeldm[pItem->iItem] = m_iSel = (int)pItem->lParam;
- m_list.SetItemText(pItem->iItem, pItem->iSubItem, pItem->pszText);
- }
- break;
- case COL_VFR_F:
- case COL_VFR_T:
- if (pItem->pszText) {
- CString str = pItem->pszText;
- int dotpos = str.Find('.');
- if (dotpos >= 0 && str.GetLength() - dotpos > 4) {
- str.Truncate(dotpos + 4);
- }
- double f = min(max(_tstof(str), 1.0), 125.999);
- str.Format(_T("%.3f"), f);
- m_list.SetItemText(pItem->iItem, pItem->iSubItem, str);
- }
- break;
- }
-
- *pResult = TRUE;
-
- if (*pResult) {
- SetModified();
- }
+ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
+ LV_ITEM* pItem = &pDispInfo->item;
+ *pResult = FALSE;
+ if (!m_list.m_fInPlaceDirty) {
+ return;
+ }
+ if (pItem->iItem < 0) {
+ return;
+ }
+ switch (pItem->iSubItem) {
+ case COL_SRR:
+ if (pItem->lParam >= 0) {
+ m_iSeldm[pItem->iItem] = m_iSel = (int)pItem->lParam;
+ m_list.SetItemText(pItem->iItem, pItem->iSubItem, pItem->pszText);
+ }
+ break;
+ case COL_VFR_F:
+ case COL_VFR_T:
+ if (pItem->pszText) {
+ CString str = pItem->pszText;
+ int dotpos = str.Find('.');
+ if (dotpos >= 0 && str.GetLength() - dotpos > 4) {
+ str.Truncate(dotpos + 4);
+ }
+ double f = min(max(_tstof(str), 1.0), 125.999);
+ str.Format(_T("%.3f"), f);
+ m_list.SetItemText(pItem->iItem, pItem->iSubItem, str);
+ }
+ break;
+ }
+
+ *pResult = TRUE;
+
+ if (*pResult) {
+ SetModified();
+ }
}
void CPPageFullscreen::OnCheckChangeList()
{
- SetModified();
+ SetModified();
}
void CPPageFullscreen::OnUpdateList(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2));
+ pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2));
}
void CPPageFullscreen::OnUpdateApplyDefault(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2));
+ pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2));
}
void CPPageFullscreen::OnUpdateRestoreRes(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2));
+ pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2));
}
void CPPageFullscreen::OnUpdateFullScrCombo()
{
- CMonitors monitors;
- m_f_hmonitor = m_MonitorDisplayNames[m_iMonitorTypeCtrl.GetCurSel()];
- if (AfxGetAppSettings().strFullScreenMonitor != m_f_hmonitor) {
- m_AutoChangeFullscrRes.bEnabled = false;
- }
-
- ModesUpdate();
- SetModified();
+ CMonitors monitors;
+ m_f_hmonitor = m_MonitorDisplayNames[m_iMonitorTypeCtrl.GetCurSel()];
+ if (AfxGetAppSettings().strFullScreenMonitor != m_f_hmonitor) {
+ m_AutoChangeFullscrRes.bEnabled = false;
+ }
+
+ ModesUpdate();
+ SetModified();
}
void CPPageFullscreen::OnUpdateTimeout(CCmdUI* pCmdUI)
{
- UpdateData();
- pCmdUI->Enable(m_iShowBarsWhenFullScreen);
+ UpdateData();
+ pCmdUI->Enable(m_iShowBarsWhenFullScreen);
}
void CPPageFullscreen::ModesUpdate()
{
- CMonitors monitors;
-
- m_fSetFullscreenRes = m_AutoChangeFullscrRes.bEnabled;
- CString sl2[MaxFpsCount];
- dispmode dm, dmtoset[MaxFpsCount];
-
- int i0;
-
- CString str, strCurMon, strModes;
- CString strCur;
- GetCurDispModeString(strCur);
-
- int iNoData = 0;
- for (int i=0; i<MaxFpsCount; i++) {
- dmtoset[i] = m_AutoChangeFullscrRes.dmFullscreenRes[i].dmFSRes;
- if (m_AutoChangeFullscrRes.dmFullscreenRes[i].fIsData == true) {
- iNoData++;
- }
- }
-
- if (!m_AutoChangeFullscrRes.bEnabled
- || m_AutoChangeFullscrRes.dmFullscreenRes[0].dmFSRes.freq <0
- || m_AutoChangeFullscrRes.dmFullscreenRes[0].fIsData == false) {
- GetCurDispMode(dmtoset[0],m_f_hmonitor);
- for (int i=1; i<MaxFpsCount; i++) {
- dmtoset[i] = dmtoset[0];
- }
- }
- m_list.DeleteAllItems();
- m_dms.RemoveAll();
- sl.RemoveAll();
- for (int i=1; i<MaxFpsCount; i++) {
- sl2[i] = _T("");
- }
- memset(m_iSeldm, -1, sizeof(m_iSeldm));
- m_iSel=-1;
-
- for (int i = 0, m = 0, ModeExist = true; ; i++) {
- ModeExist = GetDispMode(i, dm, m_f_hmonitor);
- if (!ModeExist) {
- break;
- }
- if (dm.bpp != 32) {
- continue; // skip non 32bpp mode
- }
-
- int j = 0;
- while (j < m) {
- if (dm.bpp == m_dms[j].bpp &&
- dm.dmDisplayFlags == m_dms[j].dmDisplayFlags &&
- dm.freq == m_dms[j].freq &&
- dm.fValid == m_dms[j].fValid &&
- dm.size == m_dms[j].size) {
- break;
- }
- j++;
- }
- if (j < m) {
- continue;
- }
- m_dms.Add(dm);
- m++;
- }
-
- // sort display modes
- for (unsigned int j, i = 1; i < m_dms.GetCount(); i++) {
- dm = m_dms[i];
- j = i - 1;
- while (j != -1 && m_dms[j].size.cx >= dm.size.cx &&
- m_dms[j].size.cy >= dm.size.cy &&
- m_dms[j].freq > dm.freq) {
- m_dms[j+1] = m_dms[j];
- j--;
- }
- m_dms[j+1] = dm;
- }
-
- for (int i=0; (size_t) i<m_dms.GetCount(); i++) {
- strModes.Format(_T("[ %d ] @ %dx%d "), m_dms[i].freq, m_dms[i].size.cx, m_dms[i].size.cy);
- if (m_dms[i].dmDisplayFlags == DM_INTERLACED) {
- strModes += _T("i");
- } else {
- strModes += _T("p");
- }
-
- sl.Add(strModes);
- for (int n=0; n<MaxFpsCount; n++) {
- if (m_iSeldm[n] < 0
- && dmtoset[n].fValid
- && m_dms[i].size == dmtoset[n].size
- && m_dms[i].bpp == dmtoset[n].bpp
- && m_dms[i].freq == dmtoset[n].freq
- && m_dms[i].dmDisplayFlags == dmtoset[n].dmDisplayFlags) {
- m_iSeldm[n]=i;
- sl2[n] = sl[i];
- if (strCur == strModes) {
- i0 = i;
- }
- }
- }
- }
-
- for (int n=0; n<MaxFpsCount; n++) {
- if (m_AutoChangeFullscrRes.dmFullscreenRes[n].fIsData == true) {
- m_list.InsertItem(n, _T(""));
- CString ss = sl2[n];
- m_list.SetItemText(n, COL_SRR, ss);
- m_list.SetCheck(n, m_AutoChangeFullscrRes.dmFullscreenRes[n].fChecked);
- if (n==0) {
- m_list.SetItemText(n, COL_Z, ResStr(IDS_PPAGE_FS_DEFAULT));
- m_list.SetItemText(n, COL_VFR_F, ResStr(IDS_PPAGE_FS_OTHER));
- m_list.SetItemText(n, COL_VFR_T, ResStr(IDS_PPAGE_FS_OTHER));
- } else {
- n>9 ? ss.Format(_T("%d"), n) : ss.Format(_T("0%d"), n);
- m_list.SetItemText(n, COL_Z, ss);
-
- ss.Format(_T("%.3f"), m_AutoChangeFullscrRes.dmFullscreenRes[n].vfr_from) ;
- m_list.SetItemText(n, COL_VFR_F, ss);
-
- ss.Format(_T("%.3f"), m_AutoChangeFullscrRes.dmFullscreenRes[n].vfr_to) ;
- m_list.SetItemText(n, COL_VFR_T, ss);
- }
- }
- }
- if (m_list.GetItemCount() < 1 || iNoData == 0) {
- strModes.Format(_T("[ %d ] @ %dx%d "), dmtoset[0].freq, dmtoset[0].size.cx, dmtoset[0].size.cy);
- (dmtoset[0].dmDisplayFlags == DM_INTERLACED) ? strModes += _T("i") : strModes += _T("p");
-
- int idx = 0;
- m_list.InsertItem(idx, ResStr(IDS_PPAGE_FS_DEFAULT));
- m_list.SetItemText(idx, COL_VFR_F, ResStr(IDS_PPAGE_FS_OTHER));
- m_list.SetItemText(idx, COL_VFR_T, ResStr(IDS_PPAGE_FS_OTHER));
- m_list.SetItemText(idx, COL_SRR, strModes);
- m_iSeldm[idx] = i0;
- m_list.SetCheck(idx, 1);
- idx++;
- m_list.InsertItem(idx, _T("01"));
- m_list.SetItemText(idx, COL_VFR_F, _T("23.500"));
- m_list.SetItemText(idx, COL_VFR_T, _T("23.981"));
- m_list.SetItemText(idx, COL_SRR, strModes);
- m_iSeldm[idx] = i0;
- m_list.SetCheck(idx, 1);
- idx++;
- m_list.InsertItem(idx, _T("02"));
- m_list.SetItemText(idx, COL_VFR_F, _T("23.982"));
- m_list.SetItemText(idx, COL_VFR_T, _T("24.499"));
- m_list.SetItemText(idx, COL_SRR, strModes);
- m_iSeldm[idx] = i0;
- m_list.SetCheck(idx, 1);
- idx++;
- m_list.InsertItem(idx, _T("03"));
- m_list.SetItemText(idx, COL_VFR_F, _T("24.500"));
- m_list.SetItemText(idx, COL_VFR_T, _T("25.499"));
- m_list.SetItemText(idx, COL_SRR, strModes);
- m_iSeldm[idx] = i0;
- m_list.SetCheck(idx, 1);
- idx++;
- m_list.InsertItem(idx, _T("04"));
- m_list.SetItemText(idx, COL_VFR_F, _T("29.500"));
- m_list.SetItemText(idx, COL_VFR_T, _T("29.981"));
- m_list.SetItemText(idx, COL_SRR, strModes);
- m_iSeldm[idx] = i0;
- m_list.SetCheck(idx, 1);
- idx++;
- m_list.InsertItem(idx, _T("05"));
- m_list.SetItemText(idx, COL_VFR_F, _T("29.982"));
- m_list.SetItemText(idx, COL_VFR_T, _T("30.499"));
- m_list.SetItemText(idx, COL_SRR, strModes);
- m_iSeldm[idx] = i0;
- m_list.SetCheck(idx, 1);
- idx++;
- m_list.InsertItem(idx, _T("06"));
- m_list.SetItemText(idx, COL_VFR_F, _T("49.500"));
- m_list.SetItemText(idx, COL_VFR_T, _T("50.499"));
- m_list.SetItemText(idx, COL_SRR, strModes);
- m_iSeldm[idx] = i0;
- m_list.SetCheck(idx, 1);
- idx++;
- m_list.InsertItem(idx, _T("07"));
- m_list.SetItemText(idx, COL_VFR_F, _T("59.500"));
- m_list.SetItemText(idx, COL_VFR_T, _T("59.945"));
- m_list.SetItemText(idx, COL_SRR, strModes);
- m_iSeldm[idx] = i0;
- m_list.SetCheck(idx, 1);
- idx++;
- m_list.InsertItem(idx, _T("08"));
- m_list.SetItemText(idx, COL_VFR_F, _T("59.946"));
- m_list.SetItemText(idx, COL_VFR_T, _T("60.499"));
- m_list.SetItemText(idx, COL_SRR, strModes);
- m_iSeldm[idx] = i0;
- m_list.SetCheck(idx, 1);
- }
- //ReindexListSubItem();
+ CMonitors monitors;
+
+ m_fSetFullscreenRes = m_AutoChangeFullscrRes.bEnabled;
+ CString sl2[MaxFpsCount];
+ dispmode dm, dmtoset[MaxFpsCount];
+
+ int i0;
+
+ CString str, strCurMon, strModes;
+ CString strCur;
+ GetCurDispModeString(strCur);
+
+ int iNoData = 0;
+ for (int i = 0; i < MaxFpsCount; i++) {
+ dmtoset[i] = m_AutoChangeFullscrRes.dmFullscreenRes[i].dmFSRes;
+ if (m_AutoChangeFullscrRes.dmFullscreenRes[i].fIsData == true) {
+ iNoData++;
+ }
+ }
+
+ if (!m_AutoChangeFullscrRes.bEnabled
+ || m_AutoChangeFullscrRes.dmFullscreenRes[0].dmFSRes.freq < 0
+ || m_AutoChangeFullscrRes.dmFullscreenRes[0].fIsData == false) {
+ GetCurDispMode(dmtoset[0], m_f_hmonitor);
+ for (int i = 1; i < MaxFpsCount; i++) {
+ dmtoset[i] = dmtoset[0];
+ }
+ }
+ m_list.DeleteAllItems();
+ m_dms.RemoveAll();
+ sl.RemoveAll();
+ for (int i = 1; i < MaxFpsCount; i++) {
+ sl2[i] = _T("");
+ }
+ memset(m_iSeldm, -1, sizeof(m_iSeldm));
+ m_iSel = -1;
+
+ for (int i = 0, m = 0, ModeExist = true; ; i++) {
+ ModeExist = GetDispMode(i, dm, m_f_hmonitor);
+ if (!ModeExist) {
+ break;
+ }
+ if (dm.bpp != 32) {
+ continue; // skip non 32bpp mode
+ }
+
+ int j = 0;
+ while (j < m) {
+ if (dm.bpp == m_dms[j].bpp &&
+ dm.dmDisplayFlags == m_dms[j].dmDisplayFlags &&
+ dm.freq == m_dms[j].freq &&
+ dm.fValid == m_dms[j].fValid &&
+ dm.size == m_dms[j].size) {
+ break;
+ }
+ j++;
+ }
+ if (j < m) {
+ continue;
+ }
+ m_dms.Add(dm);
+ m++;
+ }
+
+ // sort display modes
+ for (unsigned int j, i = 1; i < m_dms.GetCount(); i++) {
+ dm = m_dms[i];
+ j = i - 1;
+ while (j != -1 && m_dms[j].size.cx >= dm.size.cx &&
+ m_dms[j].size.cy >= dm.size.cy &&
+ m_dms[j].freq > dm.freq) {
+ m_dms[j + 1] = m_dms[j];
+ j--;
+ }
+ m_dms[j + 1] = dm;
+ }
+
+ for (int i = 0; (size_t) i < m_dms.GetCount(); i++) {
+ strModes.Format(_T("[ %d ] @ %dx%d "), m_dms[i].freq, m_dms[i].size.cx, m_dms[i].size.cy);
+ if (m_dms[i].dmDisplayFlags == DM_INTERLACED) {
+ strModes += _T("i");
+ } else {
+ strModes += _T("p");
+ }
+
+ sl.Add(strModes);
+ for (int n = 0; n < MaxFpsCount; n++) {
+ if (m_iSeldm[n] < 0
+ && dmtoset[n].fValid
+ && m_dms[i].size == dmtoset[n].size
+ && m_dms[i].bpp == dmtoset[n].bpp
+ && m_dms[i].freq == dmtoset[n].freq
+ && m_dms[i].dmDisplayFlags == dmtoset[n].dmDisplayFlags) {
+ m_iSeldm[n] = i;
+ sl2[n] = sl[i];
+ if (strCur == strModes) {
+ i0 = i;
+ }
+ }
+ }
+ }
+
+ for (int n = 0; n < MaxFpsCount; n++) {
+ if (m_AutoChangeFullscrRes.dmFullscreenRes[n].fIsData == true) {
+ m_list.InsertItem(n, _T(""));
+ CString ss = sl2[n];
+ m_list.SetItemText(n, COL_SRR, ss);
+ m_list.SetCheck(n, m_AutoChangeFullscrRes.dmFullscreenRes[n].fChecked);
+ if (n == 0) {
+ m_list.SetItemText(n, COL_Z, ResStr(IDS_PPAGE_FS_DEFAULT));
+ m_list.SetItemText(n, COL_VFR_F, ResStr(IDS_PPAGE_FS_OTHER));
+ m_list.SetItemText(n, COL_VFR_T, ResStr(IDS_PPAGE_FS_OTHER));
+ } else {
+ n > 9 ? ss.Format(_T("%d"), n) : ss.Format(_T("0%d"), n);
+ m_list.SetItemText(n, COL_Z, ss);
+
+ ss.Format(_T("%.3f"), m_AutoChangeFullscrRes.dmFullscreenRes[n].vfr_from) ;
+ m_list.SetItemText(n, COL_VFR_F, ss);
+
+ ss.Format(_T("%.3f"), m_AutoChangeFullscrRes.dmFullscreenRes[n].vfr_to) ;
+ m_list.SetItemText(n, COL_VFR_T, ss);
+ }
+ }
+ }
+ if (m_list.GetItemCount() < 1 || iNoData == 0) {
+ strModes.Format(_T("[ %d ] @ %dx%d "), dmtoset[0].freq, dmtoset[0].size.cx, dmtoset[0].size.cy);
+ (dmtoset[0].dmDisplayFlags == DM_INTERLACED) ? strModes += _T("i") : strModes += _T("p");
+
+ int idx = 0;
+ m_list.InsertItem(idx, ResStr(IDS_PPAGE_FS_DEFAULT));
+ m_list.SetItemText(idx, COL_VFR_F, ResStr(IDS_PPAGE_FS_OTHER));
+ m_list.SetItemText(idx, COL_VFR_T, ResStr(IDS_PPAGE_FS_OTHER));
+ m_list.SetItemText(idx, COL_SRR, strModes);
+ m_iSeldm[idx] = i0;
+ m_list.SetCheck(idx, 1);
+ idx++;
+ m_list.InsertItem(idx, _T("01"));
+ m_list.SetItemText(idx, COL_VFR_F, _T("23.500"));
+ m_list.SetItemText(idx, COL_VFR_T, _T("23.981"));
+ m_list.SetItemText(idx, COL_SRR, strModes);
+ m_iSeldm[idx] = i0;
+ m_list.SetCheck(idx, 1);
+ idx++;
+ m_list.InsertItem(idx, _T("02"));
+ m_list.SetItemText(idx, COL_VFR_F, _T("23.982"));
+ m_list.SetItemText(idx, COL_VFR_T, _T("24.499"));
+ m_list.SetItemText(idx, COL_SRR, strModes);
+ m_iSeldm[idx] = i0;
+ m_list.SetCheck(idx, 1);
+ idx++;
+ m_list.InsertItem(idx, _T("03"));
+ m_list.SetItemText(idx, COL_VFR_F, _T("24.500"));
+ m_list.SetItemText(idx, COL_VFR_T, _T("25.499"));
+ m_list.SetItemText(idx, COL_SRR, strModes);
+ m_iSeldm[idx] = i0;
+ m_list.SetCheck(idx, 1);
+ idx++;
+ m_list.InsertItem(idx, _T("04"));
+ m_list.SetItemText(idx, COL_VFR_F, _T("29.500"));
+ m_list.SetItemText(idx, COL_VFR_T, _T("29.981"));
+ m_list.SetItemText(idx, COL_SRR, strModes);
+ m_iSeldm[idx] = i0;
+ m_list.SetCheck(idx, 1);
+ idx++;
+ m_list.InsertItem(idx, _T("05"));
+ m_list.SetItemText(idx, COL_VFR_F, _T("29.982"));
+ m_list.SetItemText(idx, COL_VFR_T, _T("30.499"));
+ m_list.SetItemText(idx, COL_SRR, strModes);
+ m_iSeldm[idx] = i0;
+ m_list.SetCheck(idx, 1);
+ idx++;
+ m_list.InsertItem(idx, _T("06"));
+ m_list.SetItemText(idx, COL_VFR_F, _T("49.500"));
+ m_list.SetItemText(idx, COL_VFR_T, _T("50.499"));
+ m_list.SetItemText(idx, COL_SRR, strModes);
+ m_iSeldm[idx] = i0;
+ m_list.SetCheck(idx, 1);
+ idx++;
+ m_list.InsertItem(idx, _T("07"));
+ m_list.SetItemText(idx, COL_VFR_F, _T("59.500"));
+ m_list.SetItemText(idx, COL_VFR_T, _T("59.945"));
+ m_list.SetItemText(idx, COL_SRR, strModes);
+ m_iSeldm[idx] = i0;
+ m_list.SetCheck(idx, 1);
+ idx++;
+ m_list.InsertItem(idx, _T("08"));
+ m_list.SetItemText(idx, COL_VFR_F, _T("59.946"));
+ m_list.SetItemText(idx, COL_VFR_T, _T("60.499"));
+ m_list.SetItemText(idx, COL_SRR, strModes);
+ m_iSeldm[idx] = i0;
+ m_list.SetCheck(idx, 1);
+ }
+ //ReindexListSubItem();
}
void CPPageFullscreen::OnRemove()
{
- if (POSITION pos = m_list.GetFirstSelectedItemPosition()) {
- int nItem = m_list.GetNextSelectedItem(pos);
- if (nItem <= 0 || nItem >= m_list.GetItemCount()) {
- return;
- }
- m_list.DeleteItem(nItem);
- nItem = min(nItem, m_list.GetItemCount()-1);
- m_list.SetSelectionMark(nItem);
- m_list.SetFocus();
- m_list.SetItemState(nItem,LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
- ReindexList();
- ReindexListSubItem();
-
- SetModified();
- }
+ if (POSITION pos = m_list.GetFirstSelectedItemPosition()) {
+ int nItem = m_list.GetNextSelectedItem(pos);
+ if (nItem <= 0 || nItem >= m_list.GetItemCount()) {
+ return;
+ }
+ m_list.DeleteItem(nItem);
+ nItem = min(nItem, m_list.GetItemCount() - 1);
+ m_list.SetSelectionMark(nItem);
+ m_list.SetFocus();
+ m_list.SetItemState(nItem, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
+ ReindexList();
+ ReindexListSubItem();
+
+ SetModified();
+ }
}
void CPPageFullscreen::OnUpdateRemove(CCmdUI* pCmdUI)
{
- POSITION pos = m_list.GetFirstSelectedItemPosition();
- int i = m_list.GetNextSelectedItem(pos);
- pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2) && (i > 0 || pos != NULL));
+ POSITION pos = m_list.GetFirstSelectedItemPosition();
+ int i = m_list.GetNextSelectedItem(pos);
+ pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2) && (i > 0 || pos != NULL));
}
void CPPageFullscreen::OnAdd()
{
- POSITION pos = m_list.GetFirstSelectedItemPosition();
- int i = m_list.GetNextSelectedItem(pos)+1;
- if (i<=0) {
- i = m_list.GetItemCount();
- }
- if (m_list.GetItemCount() <= MaxFpsCount) {
- CString str, strCur;
- (i<10) ? str.Format(_T("0%d"), i) : str.Format(_T("%d"), i);
- m_list.InsertItem(i, str);
- m_list.SetItemText(i, COL_VFR_F, _T("1.000"));
- m_list.SetItemText(i, COL_VFR_T, _T("1.000"));
- GetCurDispModeString(strCur);
- m_list.SetItemText(i, COL_SRR, strCur);
- m_list.SetCheck(i,0);
- m_list.SetFocus();
- m_list.SetItemState(i,LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
- ReindexList();
- ReindexListSubItem();
-
- SetModified();
- }
+ POSITION pos = m_list.GetFirstSelectedItemPosition();
+ int i = m_list.GetNextSelectedItem(pos) + 1;
+ if (i <= 0) {
+ i = m_list.GetItemCount();
+ }
+ if (m_list.GetItemCount() <= MaxFpsCount) {
+ CString str, strCur;
+ (i < 10) ? str.Format(_T("0%d"), i) : str.Format(_T("%d"), i);
+ m_list.InsertItem(i, str);
+ m_list.SetItemText(i, COL_VFR_F, _T("1.000"));
+ m_list.SetItemText(i, COL_VFR_T, _T("1.000"));
+ GetCurDispModeString(strCur);
+ m_list.SetItemText(i, COL_SRR, strCur);
+ m_list.SetCheck(i, 0);
+ m_list.SetFocus();
+ m_list.SetItemState(i, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
+ ReindexList();
+ ReindexListSubItem();
+
+ SetModified();
+ }
}
void CPPageFullscreen::OnUpdateAdd(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2));
+ pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2));
}
void CPPageFullscreen::OnMoveUp()
{
- if (POSITION pos = m_list.GetFirstSelectedItemPosition()) {
- int nItem = m_list.GetNextSelectedItem(pos);
- if (nItem <= 0) {
- return;
- }
-
- DWORD_PTR data = m_list.GetItemData(nItem);
- int nCheckCur = m_list.GetCheck(nItem);
- CString strN = m_list.GetItemText(nItem, 0);
- CString strF = m_list.GetItemText(nItem, 1);
- CString strT = m_list.GetItemText(nItem, 2);
- CString strDM = m_list.GetItemText(nItem, 3);
- m_list.DeleteItem(nItem);
-
- nItem--;
- m_list.InsertItem(nItem, strN);
- m_list.SetItemData(nItem, data);
- m_list.SetItemText(nItem, 1, strF);
- m_list.SetItemText(nItem, 2, strT);
- m_list.SetItemText(nItem, 3, strDM);
- m_list.SetCheck(nItem, nCheckCur);
- m_list.SetFocus();
- m_list.SetSelectionMark(nItem);
- m_list.SetItemState(nItem, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
- ReindexList();
- ReindexListSubItem();
-
- SetModified();
- }
+ if (POSITION pos = m_list.GetFirstSelectedItemPosition()) {
+ int nItem = m_list.GetNextSelectedItem(pos);
+ if (nItem <= 0) {
+ return;
+ }
+
+ DWORD_PTR data = m_list.GetItemData(nItem);
+ int nCheckCur = m_list.GetCheck(nItem);
+ CString strN = m_list.GetItemText(nItem, 0);
+ CString strF = m_list.GetItemText(nItem, 1);
+ CString strT = m_list.GetItemText(nItem, 2);
+ CString strDM = m_list.GetItemText(nItem, 3);
+ m_list.DeleteItem(nItem);
+
+ nItem--;
+ m_list.InsertItem(nItem, strN);
+ m_list.SetItemData(nItem, data);
+ m_list.SetItemText(nItem, 1, strF);
+ m_list.SetItemText(nItem, 2, strT);
+ m_list.SetItemText(nItem, 3, strDM);
+ m_list.SetCheck(nItem, nCheckCur);
+ m_list.SetFocus();
+ m_list.SetSelectionMark(nItem);
+ m_list.SetItemState(nItem, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
+ ReindexList();
+ ReindexListSubItem();
+
+ SetModified();
+ }
}
void CPPageFullscreen::OnMoveDown()
{
- if (POSITION pos = m_list.GetFirstSelectedItemPosition()) {
- int nItem = m_list.GetNextSelectedItem(pos);
- if (nItem < 0 || nItem >= m_list.GetItemCount()-1) {
- return;
- }
-
- DWORD_PTR data = m_list.GetItemData(nItem);
- int nCheckCur = m_list.GetCheck(nItem);
- CString strN = m_list.GetItemText(nItem, 0);
- CString strF = m_list.GetItemText(nItem, 1);
- CString strT = m_list.GetItemText(nItem, 2);
- CString strDM = m_list.GetItemText(nItem, 3);
- m_list.DeleteItem(nItem);
-
- nItem++;
-
- m_list.InsertItem(nItem, strN);
- m_list.SetItemData(nItem, data);
- m_list.SetItemText(nItem, 1, strF);
- m_list.SetItemText(nItem, 2, strT);
- m_list.SetItemText(nItem, 3, strDM);
- m_list.SetCheck(nItem, nCheckCur);
- m_list.SetFocus();
- m_list.SetSelectionMark(nItem);
- m_list.SetItemState(nItem, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
- ReindexList();
- ReindexListSubItem();
-
- SetModified();
- }
+ if (POSITION pos = m_list.GetFirstSelectedItemPosition()) {
+ int nItem = m_list.GetNextSelectedItem(pos);
+ if (nItem < 0 || nItem >= m_list.GetItemCount() - 1) {
+ return;
+ }
+
+ DWORD_PTR data = m_list.GetItemData(nItem);
+ int nCheckCur = m_list.GetCheck(nItem);
+ CString strN = m_list.GetItemText(nItem, 0);
+ CString strF = m_list.GetItemText(nItem, 1);
+ CString strT = m_list.GetItemText(nItem, 2);
+ CString strDM = m_list.GetItemText(nItem, 3);
+ m_list.DeleteItem(nItem);
+
+ nItem++;
+
+ m_list.InsertItem(nItem, strN);
+ m_list.SetItemData(nItem, data);
+ m_list.SetItemText(nItem, 1, strF);
+ m_list.SetItemText(nItem, 2, strT);
+ m_list.SetItemText(nItem, 3, strDM);
+ m_list.SetCheck(nItem, nCheckCur);
+ m_list.SetFocus();
+ m_list.SetSelectionMark(nItem);
+ m_list.SetItemState(nItem, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
+ ReindexList();
+ ReindexListSubItem();
+
+ SetModified();
+ }
}
void CPPageFullscreen::OnUpdateUp(CCmdUI* pCmdUI)
{
- POSITION pos = m_list.GetFirstSelectedItemPosition();
- int i = m_list.GetNextSelectedItem(pos);
- pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2) && (i > 1 || pos != NULL));
+ POSITION pos = m_list.GetFirstSelectedItemPosition();
+ int i = m_list.GetNextSelectedItem(pos);
+ pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2) && (i > 1 || pos != NULL));
}
void CPPageFullscreen::OnUpdateDown(CCmdUI* pCmdUI)
{
- POSITION pos = m_list.GetFirstSelectedItemPosition();
- int i = m_list.GetNextSelectedItem(pos);
- pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2) && (i > 0 && i < m_list.GetItemCount()-1));
+ POSITION pos = m_list.GetFirstSelectedItemPosition();
+ int i = m_list.GetNextSelectedItem(pos);
+ pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK2) && (i > 0 && i < m_list.GetItemCount() - 1));
}
void CPPageFullscreen::ReindexList()
{
- if (m_list.GetItemCount() > 1 ) {
- CString str;
- for (int i = 1; i < m_list.GetItemCount(); i++) {
- (i<10) ? str.Format(_T("0%d"), i) : str.Format(_T("%d"), i);
- m_list.SetItemText(i,0,str);
- }
- }
+ if (m_list.GetItemCount() > 1) {
+ CString str;
+ for (int i = 1; i < m_list.GetItemCount(); i++) {
+ (i < 10) ? str.Format(_T("0%d"), i) : str.Format(_T("%d"), i);
+ m_list.SetItemText(i, 0, str);
+ }
+ }
}
void CPPageFullscreen::ReindexListSubItem()
{
- for (int i=0; (size_t) i< sl.GetCount(); i++) {
- for (int n=0; n<m_list.GetItemCount(); n++) {
- if (m_list.GetItemText(n, COL_SRR) == sl[i]) {
- m_iSeldm[n]=i;
- }
- }
- }
+ for (int i = 0; (size_t) i < sl.GetCount(); i++) {
+ for (int n = 0; n < m_list.GetItemCount(); n++) {
+ if (m_list.GetItemText(n, COL_SRR) == sl[i]) {
+ m_iSeldm[n] = i;
+ }
+ }
+ }
}
void CPPageFullscreen::GetCurDispModeString(CString& strCur)
{
- dispmode dmod;
- GetCurDispMode(dmod, m_f_hmonitor);
- strCur.Format(_T("[ %d ] @ %dx%d "), dmod.freq, dmod.size.cx, dmod.size.cy);
- (dmod.dmDisplayFlags == DM_INTERLACED) ? strCur += _T("i") : strCur += _T("p");
+ dispmode dmod;
+ GetCurDispMode(dmod, m_f_hmonitor);
+ strCur.Format(_T("[ %d ] @ %dx%d "), dmod.freq, dmod.size.cx, dmod.size.cy);
+ (dmod.dmDisplayFlags == DM_INTERLACED) ? strCur += _T("i") : strCur += _T("p");
}
diff --git a/src/mpc-hc/PPageFullscreen.h b/src/mpc-hc/PPageFullscreen.h
index 9cc1d284f..7c815335a 100644
--- a/src/mpc-hc/PPageFullscreen.h
+++ b/src/mpc-hc/PPageFullscreen.h
@@ -30,72 +30,72 @@
class CPPageFullscreen : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageFullscreen)
+ DECLARE_DYNAMIC(CPPageFullscreen)
- // private:
- CAtlArray<dispmode> m_dms;
- CAtlArray<CString> sl;
- CStringArray m_MonitorDisplayNames;
+ // private:
+ CAtlArray<dispmode> m_dms;
+ CAtlArray<CString> sl;
+ CStringArray m_MonitorDisplayNames;
public:
- CPPageFullscreen();
- virtual ~CPPageFullscreen();
+ CPPageFullscreen();
+ virtual ~CPPageFullscreen();
- BOOL m_launchfullscreen;
- BOOL m_fSetFullscreenRes;
- BOOL m_fSetDefault;
+ BOOL m_launchfullscreen;
+ BOOL m_fSetFullscreenRes;
+ BOOL m_fSetDefault;
- CPlayerListCtrl m_list;
- enum {COL_Z, COL_VFR_F, COL_VFR_T, COL_SRR};
+ CPlayerListCtrl m_list;
+ enum {COL_Z, COL_VFR_F, COL_VFR_T, COL_SRR};
- AChFR m_AutoChangeFullscrRes;
- CStringW m_f_hmonitor;
- int m_iMonitorType;
- CComboBox m_iMonitorTypeCtrl;
+ AChFR m_AutoChangeFullscrRes;
+ CStringW m_f_hmonitor;
+ int m_iMonitorType;
+ CComboBox m_iMonitorTypeCtrl;
- BOOL m_iShowBarsWhenFullScreen;
- int m_nShowBarsWhenFullScreenTimeOut;
- BOOL m_fExitFullScreenAtTheEnd;
- CSpinButtonCtrl m_nTimeOutCtrl;
- BOOL m_fRestoreResAfterExit;
+ BOOL m_iShowBarsWhenFullScreen;
+ int m_nShowBarsWhenFullScreenTimeOut;
+ BOOL m_fExitFullScreenAtTheEnd;
+ CSpinButtonCtrl m_nTimeOutCtrl;
+ BOOL m_fRestoreResAfterExit;
- int m_iSel;
- int m_iSeldm[MaxFpsCount];
+ int m_iSel;
+ int m_iSeldm[MaxFpsCount];
- // Dialog Data
- enum { IDD = IDD_PPAGEFULLSCREEN };
+ // Dialog Data
+ enum { IDD = IDD_PPAGEFULLSCREEN };
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnUpdateList(CCmdUI* pCmdUI);
- afx_msg void OnNMClickList1(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnLvnItemchangedList1(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnCheckChangeList();
- afx_msg void OnUpdateApplyDefault(CCmdUI* pCmdUI);
- afx_msg void OnUpdateFullScrCombo();
- afx_msg void OnUpdateTimeout(CCmdUI* pCmdUI);
- afx_msg void OnUpdateRestoreRes(CCmdUI* pCmdUI);
- afx_msg void OnRemove();
- afx_msg void OnUpdateRemove(CCmdUI* pCmdUI);
- afx_msg void OnAdd();
- afx_msg void OnUpdateAdd(CCmdUI* pCmdUI);
- afx_msg void OnMoveUp();
- afx_msg void OnMoveDown();
- afx_msg void OnUpdateUp(CCmdUI* pCmdUI);
- afx_msg void OnUpdateDown(CCmdUI* pCmdUI);
-
- void ReindexList();
- void ReindexListSubItem();
- void GetCurDispModeString(CString& strMode);
- void ModesUpdate();
+ afx_msg void OnUpdateList(CCmdUI* pCmdUI);
+ afx_msg void OnNMClickList1(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnLvnItemchangedList1(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnCheckChangeList();
+ afx_msg void OnUpdateApplyDefault(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateFullScrCombo();
+ afx_msg void OnUpdateTimeout(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateRestoreRes(CCmdUI* pCmdUI);
+ afx_msg void OnRemove();
+ afx_msg void OnUpdateRemove(CCmdUI* pCmdUI);
+ afx_msg void OnAdd();
+ afx_msg void OnUpdateAdd(CCmdUI* pCmdUI);
+ afx_msg void OnMoveUp();
+ afx_msg void OnMoveDown();
+ afx_msg void OnUpdateUp(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateDown(CCmdUI* pCmdUI);
+
+ void ReindexList();
+ void ReindexListSubItem();
+ void GetCurDispModeString(CString& strMode);
+ void ModesUpdate();
};
diff --git a/src/mpc-hc/PPageInternalFilters.cpp b/src/mpc-hc/PPageInternalFilters.cpp
index 753f0209c..5b5d0a206 100644
--- a/src/mpc-hc/PPageInternalFilters.cpp
+++ b/src/mpc-hc/PPageInternalFilters.cpp
@@ -31,402 +31,402 @@
static filter_t s_filters[] = {
#if INTERNAL_SOURCEFILTER_AVI
- {_T("AVI"), SOURCE_FILTER, SRC_AVI, IDS_SRC_AVI, NULL},
+ {_T("AVI"), SOURCE_FILTER, SRC_AVI, IDS_SRC_AVI, NULL},
#endif
#if INTERNAL_SOURCEFILTER_CDDA
- {_T("CDDA (Audio CD)"), SOURCE_FILTER, SRC_CDDA, IDS_SRC_CDDA, NULL},
+ {_T("CDDA (Audio CD)"), SOURCE_FILTER, SRC_CDDA, IDS_SRC_CDDA, NULL},
#endif
#if INTERNAL_SOURCEFILTER_CDXA
- {_T("CDXA (VCD/SVCD/XCD)"), SOURCE_FILTER, SRC_CDXA, 0, NULL},
+ {_T("CDXA (VCD/SVCD/XCD)"), SOURCE_FILTER, SRC_CDXA, 0, NULL},
#endif
#if INTERNAL_SOURCEFILTER_DSM
- {_T("DirectShow Media"), SOURCE_FILTER, SRC_DSM, 0, NULL},
+ {_T("DirectShow Media"), SOURCE_FILTER, SRC_DSM, 0, NULL},
#endif
#if INTERNAL_SOURCEFILTER_DTSAC3
- {_T("DTS/AC3"), SOURCE_FILTER, SRC_DTSAC3, 0, NULL},
+ {_T("DTS/AC3"), SOURCE_FILTER, SRC_DTSAC3, 0, NULL},
#endif
#if INTERNAL_SOURCEFILTER_VTS
- {_T("DVD Video Title Set"), SOURCE_FILTER, SRC_VTS, IDS_SRC_VTS, NULL},
+ {_T("DVD Video Title Set"), SOURCE_FILTER, SRC_VTS, IDS_SRC_VTS, NULL},
#endif
#if INTERNAL_SOURCEFILTER_DVSOURCE
- {_T("DVD2AVI Project File"), SOURCE_FILTER, SRC_D2V, 0, NULL},
+ {_T("DVD2AVI Project File"), SOURCE_FILTER, SRC_D2V, 0, NULL},
#endif
#if INTERNAL_SOURCEFILTER_FLIC
- {_T("FLI/FLC"), SOURCE_FILTER, SRC_FLIC, 0, NULL},
+ {_T("FLI/FLC"), SOURCE_FILTER, SRC_FLIC, 0, NULL},
#endif
#if INTERNAL_SOURCEFILTER_FLAC
- {_T("FLAC"), SOURCE_FILTER, SRC_FLAC, 0, NULL},
+ {_T("FLAC"), SOURCE_FILTER, SRC_FLAC, 0, NULL},
#endif
#if INTERNAL_SOURCEFILTER_FLV
- {_T("FLV"), SOURCE_FILTER, SRC_FLV, 0, NULL},
+ {_T("FLV"), SOURCE_FILTER, SRC_FLV, 0, NULL},
#endif
#if INTERNAL_SOURCEFILTER_MATROSKA
- {_T("Matroska"), SOURCE_FILTER, SRC_MATROSKA, 0, NULL},
+ {_T("Matroska"), SOURCE_FILTER, SRC_MATROSKA, 0, NULL},
#endif
#if INTERNAL_SOURCEFILTER_MP4
- {_T("MP4/MOV"), SOURCE_FILTER, SRC_MP4, 0, NULL},
+ {_T("MP4/MOV"), SOURCE_FILTER, SRC_MP4, 0, NULL},
#endif
#if INTERNAL_SOURCEFILTER_MPEGAUDIO
- {_T("MPEG Audio"), SOURCE_FILTER, SRC_MPA, IDS_SRC_MPA, NULL},
+ {_T("MPEG Audio"), SOURCE_FILTER, SRC_MPA, IDS_SRC_MPA, NULL},
#endif
#if INTERNAL_SOURCEFILTER_MPEG
- {_T("MPEG PS/TS/PVA"), SOURCE_FILTER, SRC_MPEG, 0, CreateInstance<CMpegSplitterFilter>},
+ {_T("MPEG PS/TS/PVA"), SOURCE_FILTER, SRC_MPEG, 0, CreateInstance<CMpegSplitterFilter>},
#endif
#if INTERNAL_SOURCEFILTER_OGG
- {_T("Ogg"), SOURCE_FILTER, SRC_OGG, 0, NULL},
+ {_T("Ogg"), SOURCE_FILTER, SRC_OGG, 0, NULL},
#endif
#if INTERNAL_SOURCEFILTER_REALMEDIA
- {_T("RealMedia"), SOURCE_FILTER, SRC_REALMEDIA, IDS_SRC_REALMEDIA, NULL},
+ {_T("RealMedia"), SOURCE_FILTER, SRC_REALMEDIA, IDS_SRC_REALMEDIA, NULL},
#endif
#if INTERNAL_SOURCEFILTER_SHOUTCAST
- {_T("SHOUTcast"), SOURCE_FILTER, SRC_SHOUTCAST, 0, NULL},
+ {_T("SHOUTcast"), SOURCE_FILTER, SRC_SHOUTCAST, 0, NULL},
#endif
#if INTERNAL_DECODER_AAC
- {_T("AAC"), DECODER, TRA_AAC, IDS_TRA_FFMPEG, CreateInstance<CMpaDecFilter>},
+ {_T("AAC"), DECODER, TRA_AAC, IDS_TRA_FFMPEG, CreateInstance<CMpaDecFilter>},
#endif
#if INTERNAL_DECODER_AC3
- {_T("AC3/E-AC3/TrueHD/MLP"), DECODER, TRA_AC3, IDS_TRA_AC3, CreateInstance<CMpaDecFilter>},
+ {_T("AC3/E-AC3/TrueHD/MLP"), DECODER, TRA_AC3, IDS_TRA_AC3, CreateInstance<CMpaDecFilter>},
#endif
#if INTERNAL_DECODER_DTS
- {_T("DTS"), DECODER, TRA_DTS, IDS_TRA_DTS, CreateInstance<CMpaDecFilter>},
- {_T("LPCM"), DECODER, TRA_LPCM, IDS_TRA_LPCM, CreateInstance<CMpaDecFilter>},
+ {_T("DTS"), DECODER, TRA_DTS, IDS_TRA_DTS, CreateInstance<CMpaDecFilter>},
+ {_T("LPCM"), DECODER, TRA_LPCM, IDS_TRA_LPCM, CreateInstance<CMpaDecFilter>},
#endif
#if INTERNAL_DECODER_MPEGAUDIO
- {_T("MPEG Audio"), DECODER, TRA_MPA, IDS_TRA_FFMPEG, CreateInstance<CMpaDecFilter>},
+ {_T("MPEG Audio"), DECODER, TRA_MPA, IDS_TRA_FFMPEG, CreateInstance<CMpaDecFilter>},
#endif
#if INTERNAL_DECODER_VORBIS
- {_T("Vorbis"), DECODER, TRA_VORBIS, IDS_TRA_FFMPEG, CreateInstance<CMpaDecFilter>},
+ {_T("Vorbis"), DECODER, TRA_VORBIS, IDS_TRA_FFMPEG, CreateInstance<CMpaDecFilter>},
#endif
#if INTERNAL_DECODER_FLAC
- {_T("FLAC"), DECODER, TRA_FLAC, IDS_TRA_FFMPEG, CreateInstance<CMpaDecFilter>},
+ {_T("FLAC"), DECODER, TRA_FLAC, IDS_TRA_FFMPEG, CreateInstance<CMpaDecFilter>},
#endif
#if INTERNAL_DECODER_NELLYMOSER
- {_T("Nellymoser"), DECODER, TRA_NELLY, IDS_TRA_FFMPEG, CreateInstance<CMpaDecFilter>},
+ {_T("Nellymoser"), DECODER, TRA_NELLY, IDS_TRA_FFMPEG, CreateInstance<CMpaDecFilter>},
#endif
#if INTERNAL_DECODER_ALAC
- {_T("ALAC"), DECODER, TRA_ALAC, IDS_TRA_FFMPEG, CreateInstance<CMpaDecFilter>},
+ {_T("ALAC"), DECODER, TRA_ALAC, IDS_TRA_FFMPEG, CreateInstance<CMpaDecFilter>},
#endif
#if INTERNAL_DECODER_ALS
- {_T("ALS"), DECODER, TRA_ALS, IDS_TRA_FFMPEG, CreateInstance<CMpaDecFilter>},
+ {_T("ALS"), DECODER, TRA_ALS, IDS_TRA_FFMPEG, CreateInstance<CMpaDecFilter>},
#endif
#if INTERNAL_DECODER_AMR
- {_T("AMR"), DECODER, TRA_AMR, IDS_TRA_FFMPEG, CreateInstance<CMpaDecFilter>},
+ {_T("AMR"), DECODER, TRA_AMR, IDS_TRA_FFMPEG, CreateInstance<CMpaDecFilter>},
#endif
#if INTERNAL_DECODER_REALAUDIO
- {_T("RealAudio"), DECODER, TRA_RA, IDS_TRA_RA, NULL},
+ {_T("RealAudio"), DECODER, TRA_RA, IDS_TRA_RA, NULL},
#endif
#if INTERNAL_DECODER_PS2AUDIO
- {_T("PS2 Audio (PCM/ADPCM)"), DECODER, TRA_PS2AUD, IDS_TRA_PS2AUD, CreateInstance<CMpaDecFilter>},
+ {_T("PS2 Audio (PCM/ADPCM)"), DECODER, TRA_PS2AUD, IDS_TRA_PS2AUD, CreateInstance<CMpaDecFilter>},
#endif
#if INTERNAL_DECODER_PCM
- {_T("Other PCM/ADPCM"), DECODER, TRA_PCM, IDS_TRA_FFMPEG, CreateInstance<CMpaDecFilter>},
+ {_T("Other PCM/ADPCM"), DECODER, TRA_PCM, IDS_TRA_FFMPEG, CreateInstance<CMpaDecFilter>},
#endif
#if INTERNAL_DECODER_H264_DXVA
- {_T("H264/AVC (DXVA)"), DXVA_DECODER, TRA_DXVA_H264, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("H264/AVC (DXVA)"), DXVA_DECODER, TRA_DXVA_H264, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_VC1_DXVA
- {_T("VC1 (DXVA)"), DXVA_DECODER, TRA_DXVA_VC1, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("VC1 (DXVA)"), DXVA_DECODER, TRA_DXVA_VC1, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_WMV3_DXVA
- {_T("WMV3 (DXVA)"), DXVA_DECODER, TRA_DXVA_WMV3, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("WMV3 (DXVA)"), DXVA_DECODER, TRA_DXVA_WMV3, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_MPEG2_DXVA
- {_T("MPEG-2 Video (DXVA)"), DXVA_DECODER, TRA_DXVA_MPEG2, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("MPEG-2 Video (DXVA)"), DXVA_DECODER, TRA_DXVA_MPEG2, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_MPEG1
- {_T("MPEG-1 Video"), DECODER, TRA_MPEG1, IDS_TRA_MPEG1, CreateInstance<CMpeg2DecFilter>},
+ {_T("MPEG-1 Video"), DECODER, TRA_MPEG1, IDS_TRA_MPEG1, CreateInstance<CMpeg2DecFilter>},
#endif
#if INTERNAL_DECODER_MPEG2
- {_T("MPEG-2 Video"), DECODER, TRA_MPEG2, IDS_TRA_MPEG2, CreateInstance<CMpeg2DecFilter>},
+ {_T("MPEG-2 Video"), DECODER, TRA_MPEG2, IDS_TRA_MPEG2, CreateInstance<CMpeg2DecFilter>},
#endif
#if INTERNAL_DECODER_REALVIDEO
- {_T("RealVideo"), DECODER, TRA_RV, IDS_TRA_RV, NULL},
+ {_T("RealVideo"), DECODER, TRA_RV, IDS_TRA_RV, NULL},
#endif
#if INTERNAL_DECODER_H264
- {_T("H264/AVC (FFmpeg)"), FFMPEG_DECODER, FFM_H264, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("H264/AVC (FFmpeg)"), FFMPEG_DECODER, FFM_H264, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_VC1
- {_T("VC1 (FFmpeg)"), FFMPEG_DECODER, FFM_VC1, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("VC1 (FFmpeg)"), FFMPEG_DECODER, FFM_VC1, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_XVID
- {_T("Xvid/MPEG-4"), FFMPEG_DECODER, FFM_XVID, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("Xvid/MPEG-4"), FFMPEG_DECODER, FFM_XVID, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_DIVX
- {_T("DivX"), FFMPEG_DECODER, FFM_DIVX, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("DivX"), FFMPEG_DECODER, FFM_DIVX, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_MSMPEG4
- {_T("MS MPEG-4"), FFMPEG_DECODER, FFM_MSMPEG4, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("MS MPEG-4"), FFMPEG_DECODER, FFM_MSMPEG4, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_FLV
- {_T("FLV1/4"), FFMPEG_DECODER, FFM_FLV4, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("FLV1/4"), FFMPEG_DECODER, FFM_FLV4, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_VP356
- {_T("VP3/5/6"), FFMPEG_DECODER, FFM_VP356, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("VP3/5/6"), FFMPEG_DECODER, FFM_VP356, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_VP8
- {_T("VP8"), FFMPEG_DECODER, FFM_VP8, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("VP8"), FFMPEG_DECODER, FFM_VP8, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_WMV
- {_T("WMV1/2/3"), FFMPEG_DECODER, FFM_WMV, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("WMV1/2/3"), FFMPEG_DECODER, FFM_WMV, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_SVQ
- {_T("SVQ1/3"), FFMPEG_DECODER, FFM_SVQ3, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("SVQ1/3"), FFMPEG_DECODER, FFM_SVQ3, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_H263
- {_T("H263"), FFMPEG_DECODER, FFM_H263, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("H263"), FFMPEG_DECODER, FFM_H263, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_AMVV
- {_T("AMV video"), FFMPEG_DECODER, FFM_AMVV, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("AMV video"), FFMPEG_DECODER, FFM_AMVV, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_THEORA
- {_T("Theora"), FFMPEG_DECODER, FFM_THEORA, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("Theora"), FFMPEG_DECODER, FFM_THEORA, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_MJPEG
- {_T("MJPEG"), FFMPEG_DECODER, FFM_MJPEG, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("MJPEG"), FFMPEG_DECODER, FFM_MJPEG, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
#if INTERNAL_DECODER_INDEO
- {_T("Indeo 3/4/5"), FFMPEG_DECODER, FFM_INDEO, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
+ {_T("Indeo 3/4/5"), FFMPEG_DECODER, FFM_INDEO, IDS_TRA_FFMPEG, CreateInstance<CMPCVideoDecFilter>},
#endif
- {NULL, 0, 0, 0, NULL}
+ {NULL, 0, 0, 0, NULL}
};
IMPLEMENT_DYNAMIC(CPPageInternalFiltersListBox, CCheckListBox)
CPPageInternalFiltersListBox::CPPageInternalFiltersListBox(int n)
- : CCheckListBox()
- , m_n(n)
+ : CCheckListBox()
+ , m_n(n)
{
- for (int i = 0; i < FILTER_TYPE_NB; i++) {
- m_nbFiltersPerType[i] = m_nbChecked[i] = 0;
- }
+ for (int i = 0; i < FILTER_TYPE_NB; i++) {
+ m_nbFiltersPerType[i] = m_nbChecked[i] = 0;
+ }
}
void CPPageInternalFiltersListBox::PreSubclassWindow()
{
- __super::PreSubclassWindow();
- EnableToolTips(TRUE);
+ __super::PreSubclassWindow();
+ EnableToolTips(TRUE);
}
INT_PTR CPPageInternalFiltersListBox::OnToolHitTest(CPoint point, TOOLINFO* pTI) const
{
- BOOL b = FALSE;
- int row = ItemFromPoint(point, b);
- if (row < 0) {
- return -1;
- }
-
- CRect r;
- GetItemRect(row, r);
- pTI->rect = r;
- pTI->hwnd = m_hWnd;
- pTI->uId = (UINT)row;
- pTI->lpszText = LPSTR_TEXTCALLBACK;
- pTI->uFlags |= TTF_ALWAYSTIP;
-
- return pTI->uId;
+ BOOL b = FALSE;
+ int row = ItemFromPoint(point, b);
+ if (row < 0) {
+ return -1;
+ }
+
+ CRect r;
+ GetItemRect(row, r);
+ pTI->rect = r;
+ pTI->hwnd = m_hWnd;
+ pTI->uId = (UINT)row;
+ pTI->lpszText = LPSTR_TEXTCALLBACK;
+ pTI->uFlags |= TTF_ALWAYSTIP;
+
+ return pTI->uId;
}
BEGIN_MESSAGE_MAP(CPPageInternalFiltersListBox, CCheckListBox)
- ON_NOTIFY_EX_RANGE(TTN_NEEDTEXT, 0, 0xFFFF, OnToolTipNotify)
- ON_WM_RBUTTONDOWN()
+ ON_NOTIFY_EX_RANGE(TTN_NEEDTEXT, 0, 0xFFFF, OnToolTipNotify)
+ ON_WM_RBUTTONDOWN()
END_MESSAGE_MAP()
BOOL CPPageInternalFiltersListBox::OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
{
- TOOLTIPTEXT* pTTT = (TOOLTIPTEXT*)pNMHDR;
+ TOOLTIPTEXT* pTTT = (TOOLTIPTEXT*)pNMHDR;
- filter_t* f = (filter_t*)GetItemDataPtr(static_cast<int>(pNMHDR->idFrom));
- if (f->nHintID == 0) {
- return FALSE;
- }
+ filter_t* f = (filter_t*)GetItemDataPtr(static_cast<int>(pNMHDR->idFrom));
+ if (f->nHintID == 0) {
+ return FALSE;
+ }
- ::SendMessage(pNMHDR->hwndFrom, TTM_SETMAXTIPWIDTH, 0, (LPARAM)(INT)1000);
+ ::SendMessage(pNMHDR->hwndFrom, TTM_SETMAXTIPWIDTH, 0, (LPARAM)(INT)1000);
- static CString m_strTipText; // static string
+ static CString m_strTipText; // static string
- m_strTipText.LoadString(f->nHintID);
+ m_strTipText.LoadString(f->nHintID);
- pTTT->lpszText = m_strTipText.GetBuffer();
+ pTTT->lpszText = m_strTipText.GetBuffer();
- *pResult = 0;
+ *pResult = 0;
- return TRUE; // message was handled
+ return TRUE; // message was handled
}
void CPPageInternalFiltersListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
- CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
+ CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
- CFont* pOldFont = NULL;
+ CFont* pOldFont = NULL;
- if ((lpDrawItemStruct->itemData != 0) && ((filter_t*)lpDrawItemStruct->itemData)->CreateInstance) {
- if (!(HFONT)m_bold) {
- CFont* pFont = pDC->GetCurrentFont();
+ if ((lpDrawItemStruct->itemData != 0) && ((filter_t*)lpDrawItemStruct->itemData)->CreateInstance) {
+ if (!(HFONT)m_bold) {
+ CFont* pFont = pDC->GetCurrentFont();
- LOGFONT lf;
- pFont->GetLogFont(&lf);
- lf.lfWeight = FW_BOLD;
+ LOGFONT lf;
+ pFont->GetLogFont(&lf);
+ lf.lfWeight = FW_BOLD;
- m_bold.CreateFontIndirect(&lf);
- }
+ m_bold.CreateFontIndirect(&lf);
+ }
- if ((HFONT)m_bold) {
- pOldFont = pDC->SelectObject(&m_bold);
- }
- }
+ if ((HFONT)m_bold) {
+ pOldFont = pDC->SelectObject(&m_bold);
+ }
+ }
- __super::DrawItem(lpDrawItemStruct);
+ __super::DrawItem(lpDrawItemStruct);
- if (pOldFont) {
- pDC->SelectObject(pOldFont);
- }
+ if (pOldFont) {
+ pDC->SelectObject(pOldFont);
+ }
}
int CPPageInternalFiltersListBox::AddFilter(filter_t* filter, bool checked)
{
- int index = AddString(filter->label);
- // SetItemDataPtr must be called before SetCheck
- SetItemDataPtr(index, filter);
- SetCheck(index, checked);
+ int index = AddString(filter->label);
+ // SetItemDataPtr must be called before SetCheck
+ SetItemDataPtr(index, filter);
+ SetCheck(index, checked);
- return index;
+ return index;
}
void CPPageInternalFiltersListBox::UpdateCheckState()
{
- for (int i = 0; i < FILTER_TYPE_NB; i++) {
- m_nbFiltersPerType[i] = m_nbChecked[i] = 0;
- }
+ for (int i = 0; i < FILTER_TYPE_NB; i++) {
+ m_nbFiltersPerType[i] = m_nbChecked[i] = 0;
+ }
- for (int i = 0; i < GetCount(); i++) {
- filter_t* filter = (filter_t*) GetItemDataPtr(i);
+ for (int i = 0; i < GetCount(); i++) {
+ filter_t* filter = (filter_t*) GetItemDataPtr(i);
- m_nbFiltersPerType[filter->type]++;
+ m_nbFiltersPerType[filter->type]++;
- if (GetCheck(i)) {
- m_nbChecked[filter->type]++;
- }
- }
+ if (GetCheck(i)) {
+ m_nbChecked[filter->type]++;
+ }
+ }
}
void CPPageInternalFiltersListBox::OnRButtonDown(UINT nFlags, CPoint point)
{
- CCheckListBox::OnRButtonDown(nFlags, point);
-
- CMenu m;
- m.CreatePopupMenu();
-
- enum {
- ENABLE_ALL = 1,
- DISABLE_ALL,
- ENABLE_FFMPEG,
- DISABLE_FFMPEG,
- ENABLE_DXVA,
- DISABLE_DXVA,
- };
-
- int totalFilters = 0, totalChecked = 0;
- for (int i = 0; i < FILTER_TYPE_NB; i++) {
- totalFilters += m_nbFiltersPerType[i];
- totalChecked += m_nbChecked[i];
- }
-
- UINT state = (totalChecked != totalFilters) ? MF_ENABLED : MF_GRAYED;
- m.AppendMenu(MF_STRING | state, ENABLE_ALL, ResStr(IDS_ENABLE_ALL_FILTERS));
- state = (totalChecked != 0) ? MF_ENABLED : MF_GRAYED;
- m.AppendMenu(MF_STRING | state, DISABLE_ALL, ResStr(IDS_DISABLE_ALL_FILTERS));
-
- if (m_n == 1) {
+ CCheckListBox::OnRButtonDown(nFlags, point);
+
+ CMenu m;
+ m.CreatePopupMenu();
+
+ enum {
+ ENABLE_ALL = 1,
+ DISABLE_ALL,
+ ENABLE_FFMPEG,
+ DISABLE_FFMPEG,
+ ENABLE_DXVA,
+ DISABLE_DXVA,
+ };
+
+ int totalFilters = 0, totalChecked = 0;
+ for (int i = 0; i < FILTER_TYPE_NB; i++) {
+ totalFilters += m_nbFiltersPerType[i];
+ totalChecked += m_nbChecked[i];
+ }
+
+ UINT state = (totalChecked != totalFilters) ? MF_ENABLED : MF_GRAYED;
+ m.AppendMenu(MF_STRING | state, ENABLE_ALL, ResStr(IDS_ENABLE_ALL_FILTERS));
+ state = (totalChecked != 0) ? MF_ENABLED : MF_GRAYED;
+ m.AppendMenu(MF_STRING | state, DISABLE_ALL, ResStr(IDS_DISABLE_ALL_FILTERS));
+
+ if (m_n == 1) {
#if HAS_FFMPEG_DECODERS
- m.AppendMenu(MF_SEPARATOR);
- state = (m_nbChecked[FFMPEG_DECODER] != m_nbFiltersPerType[FFMPEG_DECODER]) ? MF_ENABLED : MF_GRAYED;
- m.AppendMenu(MF_STRING | state, ENABLE_FFMPEG, ResStr(IDS_ENABLE_FFMPEG_FILTERS));
- state = (m_nbChecked[FFMPEG_DECODER] != 0) ? MF_ENABLED : MF_GRAYED;
- m.AppendMenu(MF_STRING | state, DISABLE_FFMPEG, ResStr(IDS_DISABLE_FFMPEG_FILTERS));
+ m.AppendMenu(MF_SEPARATOR);
+ state = (m_nbChecked[FFMPEG_DECODER] != m_nbFiltersPerType[FFMPEG_DECODER]) ? MF_ENABLED : MF_GRAYED;
+ m.AppendMenu(MF_STRING | state, ENABLE_FFMPEG, ResStr(IDS_ENABLE_FFMPEG_FILTERS));
+ state = (m_nbChecked[FFMPEG_DECODER] != 0) ? MF_ENABLED : MF_GRAYED;
+ m.AppendMenu(MF_STRING | state, DISABLE_FFMPEG, ResStr(IDS_DISABLE_FFMPEG_FILTERS));
#endif
#if HAS_DXVA_VIDEO_DECODERS
- m.AppendMenu(MF_SEPARATOR);
- state = (m_nbChecked[DXVA_DECODER] != m_nbFiltersPerType[DXVA_DECODER]) ? MF_ENABLED : MF_GRAYED;
- m.AppendMenu(MF_STRING | state, ENABLE_DXVA, ResStr(IDS_ENABLE_DXVA_FILTERS));
- state = (m_nbChecked[DXVA_DECODER] != 0) ? MF_ENABLED : MF_GRAYED;
- m.AppendMenu(MF_STRING | state, DISABLE_DXVA, ResStr(IDS_DISABLE_DXVA_FILTERS));
-#endif
- }
-
- CPoint p = point;
- ::MapWindowPoints(m_hWnd, HWND_DESKTOP, &p, 1);
-
- UINT id = m.TrackPopupMenu(TPM_LEFTBUTTON|TPM_RETURNCMD, p.x, p.y, this);
-
- if (id == 0) {
- return;
- }
-
- int index = 0;
- for (int i = 0; i < _countof(s_filters); i++) {
- switch (s_filters[i].type) {
- case SOURCE_FILTER:
- if (m_n == 1) {
- continue;
- }
- break;
- case DECODER:
- case DXVA_DECODER:
- case FFMPEG_DECODER:
- if (m_n == 0) {
- continue;
- }
- break;
- default:
- continue;
- }
-
- switch (id) {
- case ENABLE_ALL:
- SetCheck(index, TRUE);
- break;
- case DISABLE_ALL:
- SetCheck(index, FALSE);
- break;
- case ENABLE_FFMPEG:
- if (s_filters[i].type == FFMPEG_DECODER) {
- SetCheck(index, TRUE);
- }
- break;
- case DISABLE_FFMPEG:
- if (s_filters[i].type == FFMPEG_DECODER) {
- SetCheck(index, FALSE);
- }
- break;
- case ENABLE_DXVA:
- if (s_filters[i].type == DXVA_DECODER) {
- SetCheck(index, TRUE);
- }
- break;
- case DISABLE_DXVA:
- if (s_filters[i].type == DXVA_DECODER) {
- SetCheck(index, FALSE);
- }
- break;
- }
- index++;
- }
-
- GetParent()->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), CLBN_CHKCHANGE), (LPARAM)m_hWnd);
+ m.AppendMenu(MF_SEPARATOR);
+ state = (m_nbChecked[DXVA_DECODER] != m_nbFiltersPerType[DXVA_DECODER]) ? MF_ENABLED : MF_GRAYED;
+ m.AppendMenu(MF_STRING | state, ENABLE_DXVA, ResStr(IDS_ENABLE_DXVA_FILTERS));
+ state = (m_nbChecked[DXVA_DECODER] != 0) ? MF_ENABLED : MF_GRAYED;
+ m.AppendMenu(MF_STRING | state, DISABLE_DXVA, ResStr(IDS_DISABLE_DXVA_FILTERS));
+#endif
+ }
+
+ CPoint p = point;
+ ::MapWindowPoints(m_hWnd, HWND_DESKTOP, &p, 1);
+
+ UINT id = m.TrackPopupMenu(TPM_LEFTBUTTON | TPM_RETURNCMD, p.x, p.y, this);
+
+ if (id == 0) {
+ return;
+ }
+
+ int index = 0;
+ for (int i = 0; i < _countof(s_filters); i++) {
+ switch (s_filters[i].type) {
+ case SOURCE_FILTER:
+ if (m_n == 1) {
+ continue;
+ }
+ break;
+ case DECODER:
+ case DXVA_DECODER:
+ case FFMPEG_DECODER:
+ if (m_n == 0) {
+ continue;
+ }
+ break;
+ default:
+ continue;
+ }
+
+ switch (id) {
+ case ENABLE_ALL:
+ SetCheck(index, TRUE);
+ break;
+ case DISABLE_ALL:
+ SetCheck(index, FALSE);
+ break;
+ case ENABLE_FFMPEG:
+ if (s_filters[i].type == FFMPEG_DECODER) {
+ SetCheck(index, TRUE);
+ }
+ break;
+ case DISABLE_FFMPEG:
+ if (s_filters[i].type == FFMPEG_DECODER) {
+ SetCheck(index, FALSE);
+ }
+ break;
+ case ENABLE_DXVA:
+ if (s_filters[i].type == DXVA_DECODER) {
+ SetCheck(index, TRUE);
+ }
+ break;
+ case DISABLE_DXVA:
+ if (s_filters[i].type == DXVA_DECODER) {
+ SetCheck(index, FALSE);
+ }
+ break;
+ }
+ index++;
+ }
+
+ GetParent()->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), CLBN_CHKCHANGE), (LPARAM)m_hWnd);
}
// CPPageInternalFilters dialog
IMPLEMENT_DYNAMIC(CPPageInternalFilters, CPPageBase)
CPPageInternalFilters::CPPageInternalFilters()
- : CPPageBase(CPPageInternalFilters::IDD, CPPageInternalFilters::IDD)
- , m_listSrc(0)
- , m_listTra(1)
+ : CPPageBase(CPPageInternalFilters::IDD, CPPageInternalFilters::IDD)
+ , m_listSrc(0)
+ , m_listTra(1)
{
}
@@ -436,148 +436,148 @@ CPPageInternalFilters::~CPPageInternalFilters()
void CPPageInternalFilters::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_LIST1, m_listSrc);
- DDX_Control(pDX, IDC_LIST2, m_listTra);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_LIST1, m_listSrc);
+ DDX_Control(pDX, IDC_LIST2, m_listTra);
}
BEGIN_MESSAGE_MAP(CPPageInternalFilters, CPPageBase)
- ON_LBN_DBLCLK(IDC_LIST1, OnLbnDblclkList1)
- ON_LBN_DBLCLK(IDC_LIST2, OnLbnDblclkList2)
- ON_LBN_SELCHANGE(IDC_LIST1, OnSelChange)
- ON_LBN_SELCHANGE(IDC_LIST2, OnSelChange)
- ON_CLBN_CHKCHANGE(IDC_LIST1, OnCheckBoxChange)
- ON_CLBN_CHKCHANGE(IDC_LIST2, OnCheckBoxChange)
+ ON_LBN_DBLCLK(IDC_LIST1, OnLbnDblclkList1)
+ ON_LBN_DBLCLK(IDC_LIST2, OnLbnDblclkList2)
+ ON_LBN_SELCHANGE(IDC_LIST1, OnSelChange)
+ ON_LBN_SELCHANGE(IDC_LIST2, OnSelChange)
+ ON_CLBN_CHKCHANGE(IDC_LIST1, OnCheckBoxChange)
+ ON_CLBN_CHKCHANGE(IDC_LIST2, OnCheckBoxChange)
END_MESSAGE_MAP()
// CPPageInternalFilters message handlers
BOOL CPPageInternalFilters::OnInitDialog()
{
- __super::OnInitDialog();
-
- AppSettings& s = AfxGetAppSettings();
-
- for (int i = 0; i < _countof(s_filters)-1; i++) {
- CPPageInternalFiltersListBox* l;
- bool checked;
-
- switch (s_filters[i].type) {
- case SOURCE_FILTER:
- l = &m_listSrc;
- checked = s.SrcFilters[s_filters[i].flag];
- break;
- case DECODER:
- l = &m_listTra;
- checked = s.TraFilters[s_filters[i].flag];
- break;
- case DXVA_DECODER:
- l = &m_listTra;
- checked = s.DXVAFilters[s_filters[i].flag];
- break;
- case FFMPEG_DECODER:
- l = &m_listTra;
- checked = s.FFmpegFilters[s_filters[i].flag];
- break;
- default:
- l = NULL;
- checked = false;
- }
-
- if (l) {
- l->AddFilter(&s_filters[i], checked);
- }
- }
-
- m_listSrc.UpdateCheckState();
- m_listTra.UpdateCheckState();
-
- UpdateData(FALSE);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ for (int i = 0; i < _countof(s_filters) - 1; i++) {
+ CPPageInternalFiltersListBox* l;
+ bool checked;
+
+ switch (s_filters[i].type) {
+ case SOURCE_FILTER:
+ l = &m_listSrc;
+ checked = s.SrcFilters[s_filters[i].flag];
+ break;
+ case DECODER:
+ l = &m_listTra;
+ checked = s.TraFilters[s_filters[i].flag];
+ break;
+ case DXVA_DECODER:
+ l = &m_listTra;
+ checked = s.DXVAFilters[s_filters[i].flag];
+ break;
+ case FFMPEG_DECODER:
+ l = &m_listTra;
+ checked = s.FFmpegFilters[s_filters[i].flag];
+ break;
+ default:
+ l = NULL;
+ checked = false;
+ }
+
+ if (l) {
+ l->AddFilter(&s_filters[i], checked);
+ }
+ }
+
+ m_listSrc.UpdateCheckState();
+ m_listTra.UpdateCheckState();
+
+ UpdateData(FALSE);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageInternalFilters::OnApply()
{
- UpdateData();
-
- AppSettings& s = AfxGetAppSettings();
-
- CPPageInternalFiltersListBox* list = &m_listSrc;
- for (int l=0; l<2; l++) {
- for (int i = 0; i < list->GetCount(); i++) {
- filter_t* f = (filter_t*) list->GetItemDataPtr(i);
-
- switch (f->type) {
- case SOURCE_FILTER:
- s.SrcFilters[f->flag] = !!list->GetCheck(i);
- break;
- case DECODER:
- s.TraFilters[f->flag] = !!list->GetCheck(i);
- break;
- case DXVA_DECODER:
- s.DXVAFilters[f->flag] = !!list->GetCheck(i);
- break;
- case FFMPEG_DECODER:
- s.FFmpegFilters[f->flag] = !!list->GetCheck(i);
- break;
- }
- }
- list = &m_listTra;
- }
-
- return __super::OnApply();
+ UpdateData();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ CPPageInternalFiltersListBox* list = &m_listSrc;
+ for (int l = 0; l < 2; l++) {
+ for (int i = 0; i < list->GetCount(); i++) {
+ filter_t* f = (filter_t*) list->GetItemDataPtr(i);
+
+ switch (f->type) {
+ case SOURCE_FILTER:
+ s.SrcFilters[f->flag] = !!list->GetCheck(i);
+ break;
+ case DECODER:
+ s.TraFilters[f->flag] = !!list->GetCheck(i);
+ break;
+ case DXVA_DECODER:
+ s.DXVAFilters[f->flag] = !!list->GetCheck(i);
+ break;
+ case FFMPEG_DECODER:
+ s.FFmpegFilters[f->flag] = !!list->GetCheck(i);
+ break;
+ }
+ }
+ list = &m_listTra;
+ }
+
+ return __super::OnApply();
}
void CPPageInternalFilters::ShowPPage(CPPageInternalFiltersListBox& l)
{
- int i = l.GetCurSel();
- if (i < 0) {
- return;
- }
-
- filter_t* f = (filter_t*)l.GetItemDataPtr(i);
- if (!f || !f->CreateInstance) {
- return;
- }
-
- HRESULT hr;
- CUnknown* pObj = f->CreateInstance(NULL, &hr);
- if (!pObj) {
- return;
- }
-
- CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)pObj;
-
- if (SUCCEEDED(hr)) {
- if (CComQIPtr<ISpecifyPropertyPages> pSPP = pUnk) {
- CComPropertySheet ps(ResStr(IDS_PROPSHEET_PROPERTIES), this);
- ps.AddPages(pSPP);
- ps.DoModal();
- }
- }
+ int i = l.GetCurSel();
+ if (i < 0) {
+ return;
+ }
+
+ filter_t* f = (filter_t*)l.GetItemDataPtr(i);
+ if (!f || !f->CreateInstance) {
+ return;
+ }
+
+ HRESULT hr;
+ CUnknown* pObj = f->CreateInstance(NULL, &hr);
+ if (!pObj) {
+ return;
+ }
+
+ CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)pObj;
+
+ if (SUCCEEDED(hr)) {
+ if (CComQIPtr<ISpecifyPropertyPages> pSPP = pUnk) {
+ CComPropertySheet ps(ResStr(IDS_PROPSHEET_PROPERTIES), this);
+ ps.AddPages(pSPP);
+ ps.DoModal();
+ }
+ }
}
void CPPageInternalFilters::OnLbnDblclkList1()
{
- ShowPPage(m_listSrc);
+ ShowPPage(m_listSrc);
}
void CPPageInternalFilters::OnLbnDblclkList2()
{
- ShowPPage(m_listTra);
+ ShowPPage(m_listTra);
}
void CPPageInternalFilters::OnSelChange()
{
- // We only catch the message so that the page is not marked as modified.
+ // We only catch the message so that the page is not marked as modified.
}
void CPPageInternalFilters::OnCheckBoxChange()
{
- m_listSrc.UpdateCheckState();
- m_listTra.UpdateCheckState();
+ m_listSrc.UpdateCheckState();
+ m_listTra.UpdateCheckState();
- SetModified();
+ SetModified();
}
diff --git a/src/mpc-hc/PPageInternalFilters.h b/src/mpc-hc/PPageInternalFilters.h
index aeeb77169..81ee6ea94 100644
--- a/src/mpc-hc/PPageInternalFilters.h
+++ b/src/mpc-hc/PPageInternalFilters.h
@@ -28,66 +28,66 @@
struct filter_t {
- LPCTSTR label;
- int type;
- int flag;
- UINT nHintID;
- CUnknown* (WINAPI * CreateInstance)(LPUNKNOWN lpunk, HRESULT* phr);
+ LPCTSTR label;
+ int type;
+ int flag;
+ UINT nHintID;
+ CUnknown* (WINAPI* CreateInstance)(LPUNKNOWN lpunk, HRESULT* phr);
};
class CPPageInternalFiltersListBox : public CCheckListBox
{
- DECLARE_DYNAMIC(CPPageInternalFiltersListBox)
+ DECLARE_DYNAMIC(CPPageInternalFiltersListBox)
public:
- CPPageInternalFiltersListBox(int n);
+ CPPageInternalFiltersListBox(int n);
protected:
- virtual void PreSubclassWindow();
- virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
+ virtual void PreSubclassWindow();
+ virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
- DECLARE_MESSAGE_MAP()
- afx_msg BOOL OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
+ DECLARE_MESSAGE_MAP()
+ afx_msg BOOL OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
- CFont m_bold;
- int m_n;
- unsigned int m_nbFiltersPerType[FILTER_TYPE_NB];
- unsigned int m_nbChecked[FILTER_TYPE_NB];
+ CFont m_bold;
+ int m_n;
+ unsigned int m_nbFiltersPerType[FILTER_TYPE_NB];
+ unsigned int m_nbChecked[FILTER_TYPE_NB];
public:
- virtual void DrawItem(LPDRAWITEMSTRUCT /*lpDrawItemStruct*/);
- virtual int AddFilter(filter_t* filter, bool checked);
- virtual void UpdateCheckState();
- afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
+ virtual void DrawItem(LPDRAWITEMSTRUCT /*lpDrawItemStruct*/);
+ virtual int AddFilter(filter_t* filter, bool checked);
+ virtual void UpdateCheckState();
+ afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
};
// CPPageInternalFilters dialog
class CPPageInternalFilters : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageInternalFilters)
+ DECLARE_DYNAMIC(CPPageInternalFilters)
public:
- CPPageInternalFilters();
- virtual ~CPPageInternalFilters();
+ CPPageInternalFilters();
+ virtual ~CPPageInternalFilters();
- // Dialog Data
- enum { IDD = IDD_PPAGEINTERNALFILTERS };
- CPPageInternalFiltersListBox m_listSrc;
- CPPageInternalFiltersListBox m_listTra;
+ // Dialog Data
+ enum { IDD = IDD_PPAGEINTERNALFILTERS };
+ CPPageInternalFiltersListBox m_listSrc;
+ CPPageInternalFiltersListBox m_listTra;
- void ShowPPage(CPPageInternalFiltersListBox& l);
+ void ShowPPage(CPPageInternalFiltersListBox& l);
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnLbnDblclkList1();
- afx_msg void OnLbnDblclkList2();
- afx_msg void OnSelChange();
- afx_msg void OnCheckBoxChange();
+ afx_msg void OnLbnDblclkList1();
+ afx_msg void OnLbnDblclkList2();
+ afx_msg void OnSelChange();
+ afx_msg void OnCheckBoxChange();
};
diff --git a/src/mpc-hc/PPageLogo.cpp b/src/mpc-hc/PPageLogo.cpp
index da9692471..d49c8f4a1 100644
--- a/src/mpc-hc/PPageLogo.cpp
+++ b/src/mpc-hc/PPageLogo.cpp
@@ -30,15 +30,15 @@
IMPLEMENT_DYNAMIC(CPPageLogo, CPPageBase)
CPPageLogo::CPPageLogo()
- : CPPageBase(CPPageLogo::IDD, CPPageLogo::IDD)
- , m_intext(0)
- , m_logofn(_T(""))
- , m_author(_T(""))
+ : CPPageBase(CPPageLogo::IDD, CPPageLogo::IDD)
+ , m_intext(0)
+ , m_logofn(_T(""))
+ , m_author(_T(""))
{
- m_logoids.AddTail(IDF_LOGO0);
- m_logoids.AddTail(IDF_LOGO1);
- m_logoids.AddTail(IDF_LOGO2);
- m_logoids.AddTail(IDF_LOGO3);
+ m_logoids.AddTail(IDF_LOGO0);
+ m_logoids.AddTail(IDF_LOGO1);
+ m_logoids.AddTail(IDF_LOGO2);
+ m_logoids.AddTail(IDF_LOGO3);
}
CPPageLogo::~CPPageLogo()
@@ -47,19 +47,19 @@ CPPageLogo::~CPPageLogo()
void CPPageLogo::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Radio(pDX, IDC_RADIO1, m_intext);
- DDX_Text(pDX, IDC_LOGOFILENAME, m_logofn);
- DDX_Control(pDX, IDC_LOGOPREVIEW, m_logopreview);
- DDX_Text(pDX, IDC_AUTHOR, m_author);
+ __super::DoDataExchange(pDX);
+ DDX_Radio(pDX, IDC_RADIO1, m_intext);
+ DDX_Text(pDX, IDC_LOGOFILENAME, m_logofn);
+ DDX_Control(pDX, IDC_LOGOPREVIEW, m_logopreview);
+ DDX_Text(pDX, IDC_AUTHOR, m_author);
}
BEGIN_MESSAGE_MAP(CPPageLogo, CPPageBase)
- ON_BN_CLICKED(IDC_RADIO1, OnBnClickedInternalRadio)
- ON_BN_CLICKED(IDC_RADIO2, OnBnClickedExternalRadio)
- ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN1, OnDeltaposSpin1)
- ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
+ ON_BN_CLICKED(IDC_RADIO1, OnBnClickedInternalRadio)
+ ON_BN_CLICKED(IDC_RADIO2, OnBnClickedExternalRadio)
+ ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN1, OnDeltaposSpin1)
+ ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
END_MESSAGE_MAP()
@@ -67,126 +67,126 @@ END_MESSAGE_MAP()
BOOL CPPageLogo::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- const AppSettings& s = AfxGetAppSettings();
+ const AppSettings& s = AfxGetAppSettings();
- m_intext = s.fLogoExternal?1:0;
- m_logofn = s.strLogoFileName;
+ m_intext = s.fLogoExternal ? 1 : 0;
+ m_logofn = s.strLogoFileName;
- UpdateData(FALSE);
+ UpdateData(FALSE);
- m_logoidpos = m_logoids.GetHeadPosition();
- for (POSITION pos = m_logoids.GetHeadPosition(); pos; m_logoids.GetNext(pos)) {
- if (m_logoids.GetAt(pos) == s.nLogoId) {
- m_logoidpos = pos;
- break;
- }
- }
+ m_logoidpos = m_logoids.GetHeadPosition();
+ for (POSITION pos = m_logoids.GetHeadPosition(); pos; m_logoids.GetNext(pos)) {
+ if (m_logoids.GetAt(pos) == s.nLogoId) {
+ m_logoidpos = pos;
+ break;
+ }
+ }
- if (!m_intext) {
- OnBnClickedInternalRadio();
- } else {
- OnBnClickedExternalRadio();
- }
+ if (!m_intext) {
+ OnBnClickedInternalRadio();
+ } else {
+ OnBnClickedExternalRadio();
+ }
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageLogo::OnApply()
{
- UpdateData();
+ UpdateData();
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- s.fLogoExternal = !!m_intext;
- s.strLogoFileName = m_logofn;
- s.nLogoId = m_logoids.GetAt(m_logoidpos);
+ s.fLogoExternal = !!m_intext;
+ s.strLogoFileName = m_logofn;
+ s.nLogoId = m_logoids.GetAt(m_logoidpos);
- ((CMainFrame*)AfxGetMainWnd())->m_wndView.LoadLogo();
+ ((CMainFrame*)AfxGetMainWnd())->m_wndView.LoadLogo();
- return __super::OnApply();
+ return __super::OnApply();
}
void CPPageLogo::OnBnClickedInternalRadio()
{
- ASSERT(m_logoidpos);
+ ASSERT(m_logoidpos);
- GetDataFromRes();
- Invalidate();
+ GetDataFromRes();
+ Invalidate();
- m_intext = 0;
- UpdateData(FALSE);
+ m_intext = 0;
+ UpdateData(FALSE);
- SetModified();
+ SetModified();
}
void CPPageLogo::OnBnClickedExternalRadio()
{
- UpdateData();
+ UpdateData();
- m_author.Empty();
+ m_author.Empty();
- m_logo.Detach();
- m_logo.LoadFromFile(m_logofn);
- m_logopreview.SetBitmap(m_logo);
- Invalidate();
+ m_logo.Detach();
+ m_logo.LoadFromFile(m_logofn);
+ m_logopreview.SetBitmap(m_logo);
+ Invalidate();
- m_intext = 1;
- UpdateData(FALSE);
+ m_intext = 1;
+ UpdateData(FALSE);
- SetModified();
+ SetModified();
}
-void CPPageLogo::OnDeltaposSpin1(NMHDR *pNMHDR, LRESULT *pResult)
+void CPPageLogo::OnDeltaposSpin1(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
-
- if (pNMUpDown->iDelta < 0) {
- m_logoids.GetNext(m_logoidpos);
- if (!m_logoidpos) {
- m_logoidpos = m_logoids.GetHeadPosition();
- }
- } else {
- m_logoids.GetPrev(m_logoidpos);
- if (!m_logoidpos) {
- m_logoidpos = m_logoids.GetTailPosition();
- }
- }
-
- GetDataFromRes();
-
- UpdateData(FALSE);
- SetModified();
- *pResult = 0;
+ LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
+
+ if (pNMUpDown->iDelta < 0) {
+ m_logoids.GetNext(m_logoidpos);
+ if (!m_logoidpos) {
+ m_logoidpos = m_logoids.GetHeadPosition();
+ }
+ } else {
+ m_logoids.GetPrev(m_logoidpos);
+ if (!m_logoidpos) {
+ m_logoidpos = m_logoids.GetTailPosition();
+ }
+ }
+
+ GetDataFromRes();
+
+ UpdateData(FALSE);
+ SetModified();
+ *pResult = 0;
}
void CPPageLogo::OnBnClickedButton2()
{
- CFileDialog dlg(TRUE, NULL, m_logofn,
- OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_NOCHANGEDIR,
- _T("Images (*.bmp;*.gif;*.jpg;*.png)|*.bmp;*.gif;*.jpg;*.png|All files (*.*)|*.*||"),
- this, 0);
-
- if (dlg.DoModal() == IDOK) {
- m_logofn = dlg.GetPathName();
- UpdateData(FALSE);
- OnBnClickedExternalRadio();
- }
+ CFileDialog dlg(TRUE, NULL, m_logofn,
+ OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_NOCHANGEDIR,
+ _T("Images (*.bmp;*.gif;*.jpg;*.png)|*.bmp;*.gif;*.jpg;*.png|All files (*.*)|*.*||"),
+ this, 0);
+
+ if (dlg.DoModal() == IDOK) {
+ m_logofn = dlg.GetPathName();
+ UpdateData(FALSE);
+ OnBnClickedExternalRadio();
+ }
}
void CPPageLogo::GetDataFromRes()
{
- m_author.Empty();
- m_logo.Detach();
-
- UINT id = m_logoids.GetAt(m_logoidpos);
- if (IDF_LOGO0 != id) {
- m_logo.Load(id);
- if (!m_author.LoadString(id)) {
- m_author.LoadString(IDS_LOGO_AUTHOR);
- }
- }
- m_logopreview.SetBitmap(m_logo);
+ m_author.Empty();
+ m_logo.Detach();
+
+ UINT id = m_logoids.GetAt(m_logoidpos);
+ if (IDF_LOGO0 != id) {
+ m_logo.Load(id);
+ if (!m_author.LoadString(id)) {
+ m_author.LoadString(IDS_LOGO_AUTHOR);
+ }
+ }
+ m_logopreview.SetBitmap(m_logo);
}
diff --git a/src/mpc-hc/PPageLogo.h b/src/mpc-hc/PPageLogo.h
index f6a0fb1cb..8d776ddd5 100644
--- a/src/mpc-hc/PPageLogo.h
+++ b/src/mpc-hc/PPageLogo.h
@@ -29,35 +29,35 @@
class CPPageLogo : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageLogo)
+ DECLARE_DYNAMIC(CPPageLogo)
private:
- CList<UINT> m_logoids;
- POSITION m_logoidpos;
- CMPCPngImage m_logo;
- void GetDataFromRes();
+ CList<UINT> m_logoids;
+ POSITION m_logoidpos;
+ CMPCPngImage m_logo;
+ void GetDataFromRes();
public:
- CPPageLogo();
- virtual ~CPPageLogo();
+ CPPageLogo();
+ virtual ~CPPageLogo();
- // Dialog Data
- enum { IDD = IDD_PPAGELOGO };
- int m_intext;
- CString m_logofn;
- CStatic m_logopreview;
+ // Dialog Data
+ enum { IDD = IDD_PPAGELOGO };
+ int m_intext;
+ CString m_logofn;
+ CStatic m_logopreview;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnBnClickedInternalRadio();
- afx_msg void OnBnClickedExternalRadio();
- afx_msg void OnDeltaposSpin1(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnBnClickedButton2();
- CString m_author;
+ afx_msg void OnBnClickedInternalRadio();
+ afx_msg void OnBnClickedExternalRadio();
+ afx_msg void OnDeltaposSpin1(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnBnClickedButton2();
+ CString m_author;
};
diff --git a/src/mpc-hc/PPageMisc.cpp b/src/mpc-hc/PPageMisc.cpp
index 02451bba6..aa0bdcb86 100644
--- a/src/mpc-hc/PPageMisc.cpp
+++ b/src/mpc-hc/PPageMisc.cpp
@@ -33,7 +33,7 @@
IMPLEMENT_DYNAMIC(CPPageMisc, CPPageBase)
CPPageMisc::CPPageMisc()
- : CPPageBase(CPPageMisc::IDD, CPPageMisc::IDD)
+ : CPPageBase(CPPageMisc::IDD, CPPageMisc::IDD)
{
}
@@ -43,37 +43,37 @@ CPPageMisc::~CPPageMisc()
void CPPageMisc::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_SLI_BRIGHTNESS, m_SliBrightness);
- DDX_Control(pDX, IDC_SLI_CONTRAST, m_SliContrast);
- DDX_Control(pDX, IDC_SLI_HUE, m_SliHue);
- DDX_Control(pDX, IDC_SLI_SATURATION, m_SliSaturation);
- DDX_Text(pDX, IDC_STATIC1, m_sBrightness);
- DDX_Text(pDX, IDC_STATIC2, m_sContrast);
- DDX_Text(pDX, IDC_STATIC3, m_sHue);
- DDX_Text(pDX, IDC_STATIC4, m_sSaturation);
- DDX_Check(pDX, IDC_CHECK1, m_nUpdaterAutoCheck);
- DDX_Text(pDX, IDC_EDIT1, m_nUpdaterDelay);
- DDX_Control(pDX, IDC_CHECK1, m_updaterAutoCheckCtrl);
- DDX_Control(pDX, IDC_EDIT1, m_updaterDelayCtrl);
- DDX_Control(pDX, IDC_SPIN1, m_updaterDelaySpin);
-
- // Validate the delay between each check
- if (pDX->m_bSaveAndValidate && (m_nUpdaterDelay < 1 || m_nUpdaterDelay > 365)) {
- m_updaterDelayCtrl.ShowBalloonTip(ResStr(IDS_UPDATE_DELAY_ERROR_TITLE), ResStr(IDS_UPDATE_DELAY_ERROR_MSG), TTI_ERROR);
- pDX->PrepareEditCtrl(IDC_EDIT1);
- pDX->Fail();
- }
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_SLI_BRIGHTNESS, m_SliBrightness);
+ DDX_Control(pDX, IDC_SLI_CONTRAST, m_SliContrast);
+ DDX_Control(pDX, IDC_SLI_HUE, m_SliHue);
+ DDX_Control(pDX, IDC_SLI_SATURATION, m_SliSaturation);
+ DDX_Text(pDX, IDC_STATIC1, m_sBrightness);
+ DDX_Text(pDX, IDC_STATIC2, m_sContrast);
+ DDX_Text(pDX, IDC_STATIC3, m_sHue);
+ DDX_Text(pDX, IDC_STATIC4, m_sSaturation);
+ DDX_Check(pDX, IDC_CHECK1, m_nUpdaterAutoCheck);
+ DDX_Text(pDX, IDC_EDIT1, m_nUpdaterDelay);
+ DDX_Control(pDX, IDC_CHECK1, m_updaterAutoCheckCtrl);
+ DDX_Control(pDX, IDC_EDIT1, m_updaterDelayCtrl);
+ DDX_Control(pDX, IDC_SPIN1, m_updaterDelaySpin);
+
+ // Validate the delay between each check
+ if (pDX->m_bSaveAndValidate && (m_nUpdaterDelay < 1 || m_nUpdaterDelay > 365)) {
+ m_updaterDelayCtrl.ShowBalloonTip(ResStr(IDS_UPDATE_DELAY_ERROR_TITLE), ResStr(IDS_UPDATE_DELAY_ERROR_MSG), TTI_ERROR);
+ pDX->PrepareEditCtrl(IDC_EDIT1);
+ pDX->Fail();
+ }
}
BEGIN_MESSAGE_MAP(CPPageMisc, CPPageBase)
- ON_WM_HSCROLL()
- ON_BN_CLICKED(IDC_RESET, OnBnClickedReset)
- ON_BN_CLICKED(IDC_RESET_SETTINGS, OnResetSettings)
- ON_BN_CLICKED(IDC_EXPORT_SETTINGS, OnExportSettings)
- ON_UPDATE_COMMAND_UI(IDC_EDIT1, OnUpdateDelayEditBox)
- ON_UPDATE_COMMAND_UI(IDC_SPIN1, OnUpdateDelayEditBox)
+ ON_WM_HSCROLL()
+ ON_BN_CLICKED(IDC_RESET, OnBnClickedReset)
+ ON_BN_CLICKED(IDC_RESET_SETTINGS, OnResetSettings)
+ ON_BN_CLICKED(IDC_EXPORT_SETTINGS, OnExportSettings)
+ ON_UPDATE_COMMAND_UI(IDC_EDIT1, OnUpdateDelayEditBox)
+ ON_UPDATE_COMMAND_UI(IDC_SPIN1, OnUpdateDelayEditBox)
END_MESSAGE_MAP()
@@ -81,158 +81,155 @@ END_MESSAGE_MAP()
BOOL CPPageMisc::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- CreateToolTip();
+ CreateToolTip();
- m_iBrightness = s.iBrightness;
- m_iContrast = s.iContrast;
- m_iHue = s.iHue;
- m_iSaturation = s.iSaturation;
+ m_iBrightness = s.iBrightness;
+ m_iContrast = s.iContrast;
+ m_iHue = s.iHue;
+ m_iSaturation = s.iSaturation;
- m_SliBrightness.EnableWindow (TRUE);
- m_SliBrightness.SetRange (-100, 100, true);
- m_SliBrightness.SetTic (0);
- m_SliBrightness.SetPos (m_iBrightness);
+ m_SliBrightness.EnableWindow(TRUE);
+ m_SliBrightness.SetRange(-100, 100, true);
+ m_SliBrightness.SetTic(0);
+ m_SliBrightness.SetPos(m_iBrightness);
- m_SliContrast.EnableWindow (TRUE);
- m_SliContrast.SetRange (-100, 100, true);
- m_SliContrast.SetTic (0);
- m_SliContrast.SetPos (m_iContrast);
+ m_SliContrast.EnableWindow(TRUE);
+ m_SliContrast.SetRange(-100, 100, true);
+ m_SliContrast.SetTic(0);
+ m_SliContrast.SetPos(m_iContrast);
- m_SliHue.EnableWindow (TRUE);
- m_SliHue.SetRange (-180, 180, true);
- m_SliHue.SetTic (0);
- m_SliHue.SetPos (m_iHue);
+ m_SliHue.EnableWindow(TRUE);
+ m_SliHue.SetRange(-180, 180, true);
+ m_SliHue.SetTic(0);
+ m_SliHue.SetPos(m_iHue);
- m_SliSaturation.EnableWindow (TRUE);
- m_SliSaturation.SetRange (-100, 100, true);
- m_SliSaturation.SetTic (0);
- m_SliSaturation.SetPos (m_iSaturation);
+ m_SliSaturation.EnableWindow(TRUE);
+ m_SliSaturation.SetRange(-100, 100, true);
+ m_SliSaturation.SetTic(0);
+ m_SliSaturation.SetPos(m_iSaturation);
- m_iBrightness ? m_sBrightness.Format(_T("%+d"), m_iBrightness) : m_sBrightness = _T("0");
- m_iContrast ? m_sContrast.Format (_T("%+d"), m_iContrast) : m_sContrast = _T("0");
- m_iHue ? m_sHue.Format (_T("%+d"), m_iHue) : m_sHue = _T("0");
- m_iSaturation ? m_sSaturation.Format(_T("%+d"), m_iSaturation) : m_sSaturation = _T("0");
+ m_iBrightness ? m_sBrightness.Format(_T("%+d"), m_iBrightness) : m_sBrightness = _T("0");
+ m_iContrast ? m_sContrast.Format(_T("%+d"), m_iContrast) : m_sContrast = _T("0");
+ m_iHue ? m_sHue.Format(_T("%+d"), m_iHue) : m_sHue = _T("0");
+ m_iSaturation ? m_sSaturation.Format(_T("%+d"), m_iSaturation) : m_sSaturation = _T("0");
- m_nUpdaterAutoCheck = s.nUpdaterAutoCheck;
- m_nUpdaterDelay = s.nUpdaterDelay;
- m_updaterDelaySpin.SetRange32(1, 365);
+ m_nUpdaterAutoCheck = s.nUpdaterAutoCheck;
+ m_nUpdaterDelay = s.nUpdaterDelay;
+ m_updaterDelaySpin.SetRange32(1, 365);
- UpdateData(FALSE);
+ UpdateData(FALSE);
- return TRUE;
+ return TRUE;
}
BOOL CPPageMisc::OnApply()
{
- UpdateData();
+ UpdateData();
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- s.iBrightness = m_iBrightness;
- s.iContrast = m_iContrast;
- s.iHue = m_iHue;
- s.iSaturation = m_iSaturation;
+ s.iBrightness = m_iBrightness;
+ s.iContrast = m_iContrast;
+ s.iHue = m_iHue;
+ s.iSaturation = m_iSaturation;
- s.nUpdaterAutoCheck = m_nUpdaterAutoCheck;
- s.nUpdaterDelay = m_nUpdaterDelay;
+ s.nUpdaterAutoCheck = m_nUpdaterAutoCheck;
+ s.nUpdaterDelay = m_nUpdaterDelay;
- return __super::OnApply();
+ return __super::OnApply();
}
void CPPageMisc::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
- UpdateData();
- if (*pScrollBar == m_SliBrightness) {
- m_iBrightness = m_SliBrightness.GetPos();
- ((CMainFrame*)AfxGetMyApp()->GetMainWnd())->SetColorControl(ProcAmp_Brightness, m_iBrightness, m_iContrast, m_iHue, m_iSaturation);
- m_iBrightness ? m_sBrightness.Format(_T("%+d"), m_iBrightness) : m_sBrightness = _T("0");
- }
- else if (*pScrollBar == m_SliContrast) {
- m_iContrast = m_SliContrast.GetPos();
- ((CMainFrame*)AfxGetMyApp()->GetMainWnd())->SetColorControl(ProcAmp_Contrast, m_iBrightness, m_iContrast, m_iHue, m_iSaturation);
- m_iContrast ? m_sContrast.Format(_T("%+d"), m_iContrast) : m_sContrast = _T("0");
- }
- else if (*pScrollBar == m_SliHue) {
- m_iHue = m_SliHue.GetPos();
- ((CMainFrame*)AfxGetMyApp()->GetMainWnd())->SetColorControl(ProcAmp_Hue, m_iBrightness, m_iContrast, m_iHue, m_iSaturation);
- m_iHue ? m_sHue.Format(_T("%+d"), m_iHue) : m_sHue = _T("0");
- }
- else if (*pScrollBar == m_SliSaturation) {
- m_iSaturation = m_SliSaturation.GetPos();
- ((CMainFrame*)AfxGetMyApp()->GetMainWnd())->SetColorControl(ProcAmp_Saturation, m_iBrightness, m_iContrast, m_iHue, m_iSaturation);
- m_iSaturation ? m_sSaturation.Format(_T("%+d"), m_iSaturation) : m_sSaturation = _T("0");
- }
-
- UpdateData(FALSE);
-
- SetModified();
-
- __super::OnHScroll(nSBCode, nPos, pScrollBar);
+ UpdateData();
+ if (*pScrollBar == m_SliBrightness) {
+ m_iBrightness = m_SliBrightness.GetPos();
+ ((CMainFrame*)AfxGetMyApp()->GetMainWnd())->SetColorControl(ProcAmp_Brightness, m_iBrightness, m_iContrast, m_iHue, m_iSaturation);
+ m_iBrightness ? m_sBrightness.Format(_T("%+d"), m_iBrightness) : m_sBrightness = _T("0");
+ } else if (*pScrollBar == m_SliContrast) {
+ m_iContrast = m_SliContrast.GetPos();
+ ((CMainFrame*)AfxGetMyApp()->GetMainWnd())->SetColorControl(ProcAmp_Contrast, m_iBrightness, m_iContrast, m_iHue, m_iSaturation);
+ m_iContrast ? m_sContrast.Format(_T("%+d"), m_iContrast) : m_sContrast = _T("0");
+ } else if (*pScrollBar == m_SliHue) {
+ m_iHue = m_SliHue.GetPos();
+ ((CMainFrame*)AfxGetMyApp()->GetMainWnd())->SetColorControl(ProcAmp_Hue, m_iBrightness, m_iContrast, m_iHue, m_iSaturation);
+ m_iHue ? m_sHue.Format(_T("%+d"), m_iHue) : m_sHue = _T("0");
+ } else if (*pScrollBar == m_SliSaturation) {
+ m_iSaturation = m_SliSaturation.GetPos();
+ ((CMainFrame*)AfxGetMyApp()->GetMainWnd())->SetColorControl(ProcAmp_Saturation, m_iBrightness, m_iContrast, m_iHue, m_iSaturation);
+ m_iSaturation ? m_sSaturation.Format(_T("%+d"), m_iSaturation) : m_sSaturation = _T("0");
+ }
+
+ UpdateData(FALSE);
+
+ SetModified();
+
+ __super::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CPPageMisc::OnBnClickedReset()
{
- m_iBrightness = AfxGetMyApp()->GetColorControl(ProcAmp_Brightness)->DefaultValue;
- m_iContrast = AfxGetMyApp()->GetColorControl(ProcAmp_Contrast)->DefaultValue;
- m_iHue = AfxGetMyApp()->GetColorControl(ProcAmp_Hue)->DefaultValue;
- m_iSaturation = AfxGetMyApp()->GetColorControl(ProcAmp_Saturation)->DefaultValue;
+ m_iBrightness = AfxGetMyApp()->GetColorControl(ProcAmp_Brightness)->DefaultValue;
+ m_iContrast = AfxGetMyApp()->GetColorControl(ProcAmp_Contrast)->DefaultValue;
+ m_iHue = AfxGetMyApp()->GetColorControl(ProcAmp_Hue)->DefaultValue;
+ m_iSaturation = AfxGetMyApp()->GetColorControl(ProcAmp_Saturation)->DefaultValue;
- m_SliBrightness.SetPos (m_iBrightness);
- m_SliContrast.SetPos (m_iContrast);
- m_SliHue.SetPos (m_iHue);
- m_SliSaturation.SetPos (m_iSaturation);
+ m_SliBrightness.SetPos(m_iBrightness);
+ m_SliContrast.SetPos(m_iContrast);
+ m_SliHue.SetPos(m_iHue);
+ m_SliSaturation.SetPos(m_iSaturation);
- m_iBrightness ? m_sBrightness.Format(_T("%+d"), m_iBrightness) : m_sBrightness = _T("0");
- m_iContrast ? m_sContrast.Format (_T("%+d"), m_iContrast) : m_sContrast = _T("0");
- m_iHue ? m_sHue.Format (_T("%+d"), m_iHue) : m_sHue = _T("0");
- m_iSaturation ? m_sSaturation.Format(_T("%+d"), m_iSaturation) : m_sSaturation = _T("0");
+ m_iBrightness ? m_sBrightness.Format(_T("%+d"), m_iBrightness) : m_sBrightness = _T("0");
+ m_iContrast ? m_sContrast.Format(_T("%+d"), m_iContrast) : m_sContrast = _T("0");
+ m_iHue ? m_sHue.Format(_T("%+d"), m_iHue) : m_sHue = _T("0");
+ m_iSaturation ? m_sSaturation.Format(_T("%+d"), m_iSaturation) : m_sSaturation = _T("0");
- ((CMainFrame*)AfxGetMyApp()->GetMainWnd())->SetColorControl(ProcAmp_All, m_iBrightness, m_iContrast, m_iHue, m_iSaturation);
+ ((CMainFrame*)AfxGetMyApp()->GetMainWnd())->SetColorControl(ProcAmp_All, m_iBrightness, m_iContrast, m_iHue, m_iSaturation);
- UpdateData(FALSE);
+ UpdateData(FALSE);
- SetModified();
+ SetModified();
}
void CPPageMisc::OnUpdateDelayEditBox(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_updaterAutoCheckCtrl.GetCheck() == BST_CHECKED);
+ pCmdUI->Enable(m_updaterAutoCheckCtrl.GetCheck() == BST_CHECKED);
}
void CPPageMisc::OnResetSettings()
{
- if (MessageBox(ResStr(IDS_RESET_SETTINGS_WARNING), ResStr(IDS_RESET_SETTINGS), MB_ICONEXCLAMATION | MB_YESNO | MB_DEFBUTTON2) == IDYES) {
- ((CMainFrame*)AfxGetMyApp()->GetMainWnd())->SendMessage(WM_CLOSE);
+ if (MessageBox(ResStr(IDS_RESET_SETTINGS_WARNING), ResStr(IDS_RESET_SETTINGS), MB_ICONEXCLAMATION | MB_YESNO | MB_DEFBUTTON2) == IDYES) {
+ ((CMainFrame*)AfxGetMyApp()->GetMainWnd())->SendMessage(WM_CLOSE);
- CString strAppPath;
- GetModuleFileName(NULL, strAppPath.GetBuffer(_MAX_PATH), _MAX_PATH);
- ShellExecute(NULL, _T("open"), strAppPath, _T("/reset"), NULL, SW_SHOWNORMAL) ;
- }
+ CString strAppPath;
+ GetModuleFileName(NULL, strAppPath.GetBuffer(_MAX_PATH), _MAX_PATH);
+ ShellExecute(NULL, _T("open"), strAppPath, _T("/reset"), NULL, SW_SHOWNORMAL) ;
+ }
}
void CPPageMisc::OnExportSettings()
{
- if (GetParent()->GetDlgItem(ID_APPLY_NOW)->IsWindowEnabled()) {
- int ret = MessageBox(ResStr(IDS_EXPORT_SETTINGS_WARNING), ResStr(IDS_EXPORT_SETTINGS), MB_ICONEXCLAMATION | MB_YESNOCANCEL);
+ if (GetParent()->GetDlgItem(ID_APPLY_NOW)->IsWindowEnabled()) {
+ int ret = MessageBox(ResStr(IDS_EXPORT_SETTINGS_WARNING), ResStr(IDS_EXPORT_SETTINGS), MB_ICONEXCLAMATION | MB_YESNOCANCEL);
- if (ret == IDCANCEL) {
- return;
- } else if (ret == IDYES) {
- GetParent()->PostMessage(PSM_APPLY);
- }
- }
+ if (ret == IDCANCEL) {
+ return;
+ } else if (ret == IDYES) {
+ GetParent()->PostMessage(PSM_APPLY);
+ }
+ }
- AfxGetMyApp()->ExportSettings();
+ AfxGetMyApp()->ExportSettings();
}
void CPPageMisc::OnCancel()
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- ((CMainFrame*)AfxGetMyApp()->GetMainWnd())->SetColorControl(ProcAmp_All, s.iBrightness, s.iContrast, s.iHue, s.iSaturation);
- __super::OnCancel();
+ ((CMainFrame*)AfxGetMyApp()->GetMainWnd())->SetColorControl(ProcAmp_All, s.iBrightness, s.iContrast, s.iHue, s.iSaturation);
+ __super::OnCancel();
}
diff --git a/src/mpc-hc/PPageMisc.h b/src/mpc-hc/PPageMisc.h
index 1e42e742e..89359e601 100644
--- a/src/mpc-hc/PPageMisc.h
+++ b/src/mpc-hc/PPageMisc.h
@@ -30,51 +30,51 @@
class CPPageMisc : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageMisc)
+ DECLARE_DYNAMIC(CPPageMisc)
private:
- int m_iBrightness;
- int m_iContrast;
- int m_iHue;
- int m_iSaturation;
- CString m_sBrightness;
- CString m_sContrast;
- CString m_sHue;
- CString m_sSaturation;
-
- CButton m_updaterAutoCheckCtrl;
- CEdit m_updaterDelayCtrl;
- CSpinButtonCtrl m_updaterDelaySpin;
-
- int m_nUpdaterAutoCheck;
- int m_nUpdaterDelay;
+ int m_iBrightness;
+ int m_iContrast;
+ int m_iHue;
+ int m_iSaturation;
+ CString m_sBrightness;
+ CString m_sContrast;
+ CString m_sHue;
+ CString m_sSaturation;
+
+ CButton m_updaterAutoCheckCtrl;
+ CEdit m_updaterDelayCtrl;
+ CSpinButtonCtrl m_updaterDelaySpin;
+
+ int m_nUpdaterAutoCheck;
+ int m_nUpdaterDelay;
public:
- CPPageMisc();
- virtual ~CPPageMisc();
+ CPPageMisc();
+ virtual ~CPPageMisc();
- // Dialog Data
- enum { IDD = IDD_PPAGEMISC };
+ // Dialog Data
+ enum { IDD = IDD_PPAGEMISC };
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- CSliderCtrl m_SliContrast;
- CSliderCtrl m_SliBrightness;
- CSliderCtrl m_SliHue;
- CSliderCtrl m_SliSaturation;
- afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
- afx_msg void OnBnClickedReset();
+ CSliderCtrl m_SliContrast;
+ CSliderCtrl m_SliBrightness;
+ CSliderCtrl m_SliHue;
+ CSliderCtrl m_SliSaturation;
+ afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
+ afx_msg void OnBnClickedReset();
- afx_msg void OnUpdateDelayEditBox(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateDelayEditBox(CCmdUI* pCmdUI);
- afx_msg void OnResetSettings();
- afx_msg void OnExportSettings();
+ afx_msg void OnResetSettings();
+ afx_msg void OnExportSettings();
- virtual void OnCancel();
+ virtual void OnCancel();
};
diff --git a/src/mpc-hc/PPageOutput.cpp b/src/mpc-hc/PPageOutput.cpp
index 070b9b606..44068ae16 100644
--- a/src/mpc-hc/PPageOutput.cpp
+++ b/src/mpc-hc/PPageOutput.cpp
@@ -32,21 +32,21 @@
IMPLEMENT_DYNAMIC(CPPageOutput, CPPageBase)
CPPageOutput::CPPageOutput()
- : CPPageBase(CPPageOutput::IDD, CPPageOutput::IDD)
- , m_iDSVideoRendererType(0)
- , m_iRMVideoRendererType(0)
- , m_iQTVideoRendererType(0)
- , m_iAPSurfaceUsage(0)
- , m_iAudioRendererType(0)
- , m_iDX9Resizer(0)
- , m_fVMR9MixerMode(FALSE)
- , m_fVMR9MixerYUV(FALSE)
- , m_fVMR9AlterativeVSync(FALSE)
- , m_fResetDevice(FALSE)
- , m_iEvrBuffers(L"5")
- , m_fD3DFullscreen(FALSE)
- , m_fD3D9RenderDevice(FALSE)
- , m_iD3D9RenderDevice(-1)
+ : CPPageBase(CPPageOutput::IDD, CPPageOutput::IDD)
+ , m_iDSVideoRendererType(0)
+ , m_iRMVideoRendererType(0)
+ , m_iQTVideoRendererType(0)
+ , m_iAPSurfaceUsage(0)
+ , m_iAudioRendererType(0)
+ , m_iDX9Resizer(0)
+ , m_fVMR9MixerMode(FALSE)
+ , m_fVMR9MixerYUV(FALSE)
+ , m_fVMR9AlterativeVSync(FALSE)
+ , m_fResetDevice(FALSE)
+ , m_iEvrBuffers(L"5")
+ , m_fD3DFullscreen(FALSE)
+ , m_fD3D9RenderDevice(FALSE)
+ , m_iD3D9RenderDevice(-1)
{
}
@@ -56,367 +56,367 @@ CPPageOutput::~CPPageOutput()
void CPPageOutput::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Radio(pDX, IDC_DSSYSDEF, m_iDSVideoRendererType);
- DDX_Radio(pDX, IDC_RMSYSDEF, m_iRMVideoRendererType);
- DDX_Radio(pDX, IDC_QTSYSDEF, m_iQTVideoRendererType);
- // DDX_Radio(pDX, IDC_REGULARSURF, m_iAPSurfaceUsage);
- DDX_CBIndex(pDX, IDC_DX_SURFACE, m_iAPSurfaceUsage);
- DDX_CBIndex(pDX, IDC_COMBO1, m_iAudioRendererType);
- DDX_Control(pDX, IDC_COMBO1, m_iAudioRendererTypeCtrl);
- DDX_CBIndex(pDX, IDC_DX9RESIZER_COMBO, m_iDX9Resizer);
- DDX_Check(pDX, IDC_DSVMR9LOADMIXER, m_fVMR9MixerMode);
- DDX_Check(pDX, IDC_DSVMR9YUVMIXER, m_fVMR9MixerYUV);
- DDX_Check(pDX, IDC_DSVMR9ALTERNATIVEVSYNC, m_fVMR9AlterativeVSync);
- DDX_Check(pDX, IDC_RESETDEVICE, m_fResetDevice);
- DDX_Check(pDX, IDC_FULLSCREEN_MONITOR_CHECK, m_fD3DFullscreen);
-
- DDX_CBString(pDX, IDC_EVR_BUFFERS, m_iEvrBuffers);
-
- DDX_Check(pDX, IDC_D3D9DEVICE, m_fD3D9RenderDevice);
- DDX_CBIndex(pDX, IDC_D3D9DEVICE_COMBO, m_iD3D9RenderDevice);
- DDX_Control(pDX, IDC_D3D9DEVICE_COMBO, m_iD3D9RenderDeviceCtrl);
+ __super::DoDataExchange(pDX);
+ DDX_Radio(pDX, IDC_DSSYSDEF, m_iDSVideoRendererType);
+ DDX_Radio(pDX, IDC_RMSYSDEF, m_iRMVideoRendererType);
+ DDX_Radio(pDX, IDC_QTSYSDEF, m_iQTVideoRendererType);
+ // DDX_Radio(pDX, IDC_REGULARSURF, m_iAPSurfaceUsage);
+ DDX_CBIndex(pDX, IDC_DX_SURFACE, m_iAPSurfaceUsage);
+ DDX_CBIndex(pDX, IDC_COMBO1, m_iAudioRendererType);
+ DDX_Control(pDX, IDC_COMBO1, m_iAudioRendererTypeCtrl);
+ DDX_CBIndex(pDX, IDC_DX9RESIZER_COMBO, m_iDX9Resizer);
+ DDX_Check(pDX, IDC_DSVMR9LOADMIXER, m_fVMR9MixerMode);
+ DDX_Check(pDX, IDC_DSVMR9YUVMIXER, m_fVMR9MixerYUV);
+ DDX_Check(pDX, IDC_DSVMR9ALTERNATIVEVSYNC, m_fVMR9AlterativeVSync);
+ DDX_Check(pDX, IDC_RESETDEVICE, m_fResetDevice);
+ DDX_Check(pDX, IDC_FULLSCREEN_MONITOR_CHECK, m_fD3DFullscreen);
+
+ DDX_CBString(pDX, IDC_EVR_BUFFERS, m_iEvrBuffers);
+
+ DDX_Check(pDX, IDC_D3D9DEVICE, m_fD3D9RenderDevice);
+ DDX_CBIndex(pDX, IDC_D3D9DEVICE_COMBO, m_iD3D9RenderDevice);
+ DDX_Control(pDX, IDC_D3D9DEVICE_COMBO, m_iD3D9RenderDeviceCtrl);
}
BEGIN_MESSAGE_MAP(CPPageOutput, CPPageBase)
- ON_UPDATE_COMMAND_UI(IDC_DSVMR9YUVMIXER, OnUpdateMixerYUV)
- ON_CBN_SELCHANGE(IDC_DX_SURFACE, &CPPageOutput::OnSurfaceChange)
- ON_CONTROL_RANGE(BN_CLICKED, IDC_DSSYSDEF, IDC_DSSYNC, &CPPageOutput::OnDSRendererChange)
- ON_BN_CLICKED(IDC_FULLSCREEN_MONITOR_CHECK, OnFullscreenCheck)
- ON_BN_CLICKED(IDC_D3D9DEVICE, OnD3D9DeviceCheck)
+ ON_UPDATE_COMMAND_UI(IDC_DSVMR9YUVMIXER, OnUpdateMixerYUV)
+ ON_CBN_SELCHANGE(IDC_DX_SURFACE, &CPPageOutput::OnSurfaceChange)
+ ON_CONTROL_RANGE(BN_CLICKED, IDC_DSSYSDEF, IDC_DSSYNC, &CPPageOutput::OnDSRendererChange)
+ ON_BN_CLICKED(IDC_FULLSCREEN_MONITOR_CHECK, OnFullscreenCheck)
+ ON_BN_CLICKED(IDC_D3D9DEVICE, OnD3D9DeviceCheck)
END_MESSAGE_MAP()
void CPPageOutput::DisableRadioButton(UINT nID, UINT nDefID)
{
- if (IsDlgButtonChecked(nID)) {
- CheckDlgButton(nID, BST_UNCHECKED);
- CheckDlgButton(nDefID, BST_CHECKED);
- }
+ if (IsDlgButtonChecked(nID)) {
+ CheckDlgButton(nID, BST_UNCHECKED);
+ CheckDlgButton(nDefID, BST_CHECKED);
+ }
- GetDlgItem(nID)->EnableWindow(FALSE);
+ GetDlgItem(nID)->EnableWindow(FALSE);
}
// CPPageOutput message handlers
BOOL CPPageOutput::OnInitDialog()
{
- __super::OnInitDialog();
-
- SetHandCursor(m_hWnd, IDC_COMBO1);
-
- AppSettings& s = AfxGetAppSettings();
-
- CRenderersSettings& renderersSettings = s.m_RenderersSettings;
- m_iDSVideoRendererType = s.iDSVideoRendererType;
- m_iRMVideoRendererType = s.iRMVideoRendererType;
- m_iQTVideoRendererType = s.iQTVideoRendererType;
- m_iAPSurfaceUsage = renderersSettings.iAPSurfaceUsage;
- m_iDX9Resizer = renderersSettings.iDX9Resizer;
- m_fVMR9MixerMode = renderersSettings.fVMR9MixerMode;
- m_fVMR9MixerYUV = renderersSettings.fVMR9MixerYUV;
- m_fVMR9AlterativeVSync = renderersSettings.m_RenderSettings.fVMR9AlterativeVSync;
- m_fD3DFullscreen = s.fD3DFullscreen;
- m_iEvrBuffers.Format(L"%d", renderersSettings.iEvrBuffers);
-
- m_fResetDevice = s.m_RenderersSettings.fResetDevice;
- m_AudioRendererDisplayNames.Add(_T(""));
- m_iAudioRendererTypeCtrl.AddString(_T("1: ")+ResStr(IDS_PPAGE_OUTPUT_SYS_DEF));
- m_iAudioRendererType = 0;
-
- int i=2;
- CString Cbstr;
-
- BeginEnumSysDev(CLSID_AudioRendererCategory, pMoniker) {
- LPOLESTR olestr = NULL;
- if (FAILED(pMoniker->GetDisplayName(0, 0, &olestr))) {
- continue;
- }
-
- CStringW str(olestr);
- CoTaskMemFree(olestr);
-
- m_AudioRendererDisplayNames.Add(CString(str));
-
- CComPtr<IPropertyBag> pPB;
- if (SUCCEEDED(pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB))) {
- CComVariant var;
- pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
-
- CString fstr(var.bstrVal);
-
- var.Clear();
- if (SUCCEEDED(pPB->Read(CComBSTR(_T("FilterData")), &var, NULL))) {
- BSTR* pbstr;
- if (SUCCEEDED(SafeArrayAccessData(var.parray, (void**)&pbstr))) {
- fstr.Format(_T("%s (%08x)"), CString(fstr), *((DWORD*)pbstr + 1));
- SafeArrayUnaccessData(var.parray);
- }
- }
- Cbstr.Format(_T("%d: %s"), i, fstr);
- } else {
- Cbstr.Format(_T("%d: %s"), i, CString(str));
- }
- m_iAudioRendererTypeCtrl.AddString(Cbstr);
-
- if (s.strAudioRendererDisplayName == str && m_iAudioRendererType == 0) {
- m_iAudioRendererType = m_iAudioRendererTypeCtrl.GetCount()-1;
- }
- i++;
- }
- EndEnumSysDev
-
- Cbstr.Format(_T("%d: %s"), i++, AUDRNDT_NULL_COMP);
- m_AudioRendererDisplayNames.Add(AUDRNDT_NULL_COMP);
- m_iAudioRendererTypeCtrl.AddString(Cbstr);
- if (s.strAudioRendererDisplayName == AUDRNDT_NULL_COMP && m_iAudioRendererType == 0) {
- m_iAudioRendererType = m_iAudioRendererTypeCtrl.GetCount()-1;
- }
-
- Cbstr.Format(_T("%d: %s"), i++, AUDRNDT_NULL_UNCOMP);
- m_AudioRendererDisplayNames.Add(AUDRNDT_NULL_UNCOMP);
- m_iAudioRendererTypeCtrl.AddString(Cbstr);
- if (s.strAudioRendererDisplayName == AUDRNDT_NULL_UNCOMP && m_iAudioRendererType == 0) {
- m_iAudioRendererType = m_iAudioRendererTypeCtrl.GetCount()-1;
- }
-
- Cbstr.Format(_T("%d: %s"), i++, AUDRNDT_MPC);
- m_AudioRendererDisplayNames.Add(AUDRNDT_MPC);
- m_iAudioRendererTypeCtrl.AddString(Cbstr);
- if (s.strAudioRendererDisplayName == AUDRNDT_MPC && m_iAudioRendererType == 0) {
- m_iAudioRendererType = m_iAudioRendererTypeCtrl.GetCount()-1;
- }
-
-
- CorrectComboListWidth(m_iAudioRendererTypeCtrl);
-
- //
- IDirect3D9* pD3D = Direct3DCreate9(D3D_SDK_VERSION);
- if (pD3D) {
- TCHAR strGUID[50];
- CString cstrGUID;
- CString d3ddevice_str = _T("");
- CStringArray adapterList;
-
- D3DADAPTER_IDENTIFIER9 adapterIdentifier;
-
- for (UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp) {
- if (pD3D->GetAdapterIdentifier(adp, 0, &adapterIdentifier) == S_OK) {
- d3ddevice_str = adapterIdentifier.Description;
- d3ddevice_str += _T(" - ");
- d3ddevice_str += adapterIdentifier.DeviceName;
- cstrGUID = _T("");
- if (::StringFromGUID2(adapterIdentifier.DeviceIdentifier, strGUID, 50) > 0) {
- cstrGUID = strGUID;
- }
- if ((cstrGUID != _T(""))) {
- boolean m_find = false;
- for (i = 0; (!m_find) && (i < m_D3D9GUIDNames.GetCount()); i++) {
- if (m_D3D9GUIDNames.GetAt(i) == cstrGUID) {
- m_find = true;
- }
- }
- if (!m_find) {
- m_iD3D9RenderDeviceCtrl.AddString(d3ddevice_str);
- m_D3D9GUIDNames.Add(cstrGUID);
- if (renderersSettings.D3D9RenderDevice == cstrGUID) {
- m_iD3D9RenderDevice = m_iD3D9RenderDeviceCtrl.GetCount()-1;
- }
- }
- }
- }
- }
- pD3D->Release();
- }
-
- CorrectComboListWidth(m_iD3D9RenderDeviceCtrl);
-
- UpdateData(FALSE);
-
- if (!IsCLSIDRegistered(CLSID_VideoMixingRenderer)) {
- DisableRadioButton(IDC_DSVMR7WIN, IDC_DSSYSDEF);
- DisableRadioButton(IDC_DSVMR7REN, IDC_DSSYSDEF);
- }
-
- if (!IsCLSIDRegistered(CLSID_VideoMixingRenderer9)) {
- DisableRadioButton(IDC_DSVMR9WIN, IDC_DSSYSDEF);
- DisableRadioButton(IDC_DSVMR9REN, IDC_DSSYSDEF);
- DisableRadioButton(IDC_RMDX9, IDC_RMSYSDEF);
- DisableRadioButton(IDC_QTDX9, IDC_QTSYSDEF);
- }
-
- if (!IsCLSIDRegistered(CLSID_EnhancedVideoRenderer)) {
- DisableRadioButton(IDC_EVR, IDC_DSSYSDEF);
- DisableRadioButton(IDC_EVR_CUSTOM, IDC_DSSYSDEF);
- DisableRadioButton(IDC_DSSYNC, IDC_DSSYSDEF); // EVR Sync
- }
-
- if (!IsCLSIDRegistered(CLSID_DXR)) {
- DisableRadioButton(IDC_DSDXR, IDC_DSSYSDEF);
- }
-
- if (!IsCLSIDRegistered(CLSID_madVR)) {
- DisableRadioButton(IDC_DSMADVR, IDC_DSSYSDEF);
- }
-
- // YUV mixing is not compatible with Vista
- if (SysVersion::IsVistaOrLater()) {
- GetDlgItem(IDC_DSVMR9YUVMIXER)->ShowWindow (SW_HIDE);
- }
-
- OnDSRendererChange (m_iDSVideoRendererType + IDC_DSSYSDEF);
-
- CheckDlgButton(IDC_D3D9DEVICE, BST_CHECKED);
- GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(TRUE);
- GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(TRUE);
-
- if ((m_iDSVideoRendererType == 6 || m_iDSVideoRendererType == 11) && (m_iD3D9RenderDeviceCtrl.GetCount() > 1)) {
- GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(TRUE);
- GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(FALSE);
- CheckDlgButton(IDC_D3D9DEVICE, BST_UNCHECKED);
- if (m_iD3D9RenderDevice != -1) {
- CheckDlgButton(IDC_D3D9DEVICE, BST_CHECKED);
- GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(TRUE);
- }
- } else {
- GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(FALSE);
- GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(FALSE);
- if (m_iD3D9RenderDevice == -1) {
- CheckDlgButton(IDC_D3D9DEVICE, BST_UNCHECKED);
- }
- }
- UpdateData(TRUE);
-
- CreateToolTip();
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ SetHandCursor(m_hWnd, IDC_COMBO1);
+
+ AppSettings& s = AfxGetAppSettings();
+
+ CRenderersSettings& renderersSettings = s.m_RenderersSettings;
+ m_iDSVideoRendererType = s.iDSVideoRendererType;
+ m_iRMVideoRendererType = s.iRMVideoRendererType;
+ m_iQTVideoRendererType = s.iQTVideoRendererType;
+ m_iAPSurfaceUsage = renderersSettings.iAPSurfaceUsage;
+ m_iDX9Resizer = renderersSettings.iDX9Resizer;
+ m_fVMR9MixerMode = renderersSettings.fVMR9MixerMode;
+ m_fVMR9MixerYUV = renderersSettings.fVMR9MixerYUV;
+ m_fVMR9AlterativeVSync = renderersSettings.m_RenderSettings.fVMR9AlterativeVSync;
+ m_fD3DFullscreen = s.fD3DFullscreen;
+ m_iEvrBuffers.Format(L"%d", renderersSettings.iEvrBuffers);
+
+ m_fResetDevice = s.m_RenderersSettings.fResetDevice;
+ m_AudioRendererDisplayNames.Add(_T(""));
+ m_iAudioRendererTypeCtrl.AddString(_T("1: ") + ResStr(IDS_PPAGE_OUTPUT_SYS_DEF));
+ m_iAudioRendererType = 0;
+
+ int i = 2;
+ CString Cbstr;
+
+ BeginEnumSysDev(CLSID_AudioRendererCategory, pMoniker) {
+ LPOLESTR olestr = NULL;
+ if (FAILED(pMoniker->GetDisplayName(0, 0, &olestr))) {
+ continue;
+ }
+
+ CStringW str(olestr);
+ CoTaskMemFree(olestr);
+
+ m_AudioRendererDisplayNames.Add(CString(str));
+
+ CComPtr<IPropertyBag> pPB;
+ if (SUCCEEDED(pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB))) {
+ CComVariant var;
+ pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);
+
+ CString fstr(var.bstrVal);
+
+ var.Clear();
+ if (SUCCEEDED(pPB->Read(CComBSTR(_T("FilterData")), &var, NULL))) {
+ BSTR* pbstr;
+ if (SUCCEEDED(SafeArrayAccessData(var.parray, (void**)&pbstr))) {
+ fstr.Format(_T("%s (%08x)"), CString(fstr), *((DWORD*)pbstr + 1));
+ SafeArrayUnaccessData(var.parray);
+ }
+ }
+ Cbstr.Format(_T("%d: %s"), i, fstr);
+ } else {
+ Cbstr.Format(_T("%d: %s"), i, CString(str));
+ }
+ m_iAudioRendererTypeCtrl.AddString(Cbstr);
+
+ if (s.strAudioRendererDisplayName == str && m_iAudioRendererType == 0) {
+ m_iAudioRendererType = m_iAudioRendererTypeCtrl.GetCount() - 1;
+ }
+ i++;
+ }
+ EndEnumSysDev
+
+ Cbstr.Format(_T("%d: %s"), i++, AUDRNDT_NULL_COMP);
+ m_AudioRendererDisplayNames.Add(AUDRNDT_NULL_COMP);
+ m_iAudioRendererTypeCtrl.AddString(Cbstr);
+ if (s.strAudioRendererDisplayName == AUDRNDT_NULL_COMP && m_iAudioRendererType == 0) {
+ m_iAudioRendererType = m_iAudioRendererTypeCtrl.GetCount() - 1;
+ }
+
+ Cbstr.Format(_T("%d: %s"), i++, AUDRNDT_NULL_UNCOMP);
+ m_AudioRendererDisplayNames.Add(AUDRNDT_NULL_UNCOMP);
+ m_iAudioRendererTypeCtrl.AddString(Cbstr);
+ if (s.strAudioRendererDisplayName == AUDRNDT_NULL_UNCOMP && m_iAudioRendererType == 0) {
+ m_iAudioRendererType = m_iAudioRendererTypeCtrl.GetCount() - 1;
+ }
+
+ Cbstr.Format(_T("%d: %s"), i++, AUDRNDT_MPC);
+ m_AudioRendererDisplayNames.Add(AUDRNDT_MPC);
+ m_iAudioRendererTypeCtrl.AddString(Cbstr);
+ if (s.strAudioRendererDisplayName == AUDRNDT_MPC && m_iAudioRendererType == 0) {
+ m_iAudioRendererType = m_iAudioRendererTypeCtrl.GetCount() - 1;
+ }
+
+
+ CorrectComboListWidth(m_iAudioRendererTypeCtrl);
+
+ //
+ IDirect3D9* pD3D = Direct3DCreate9(D3D_SDK_VERSION);
+ if (pD3D) {
+ TCHAR strGUID[50];
+ CString cstrGUID;
+ CString d3ddevice_str = _T("");
+ CStringArray adapterList;
+
+ D3DADAPTER_IDENTIFIER9 adapterIdentifier;
+
+ for (UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp) {
+ if (pD3D->GetAdapterIdentifier(adp, 0, &adapterIdentifier) == S_OK) {
+ d3ddevice_str = adapterIdentifier.Description;
+ d3ddevice_str += _T(" - ");
+ d3ddevice_str += adapterIdentifier.DeviceName;
+ cstrGUID = _T("");
+ if (::StringFromGUID2(adapterIdentifier.DeviceIdentifier, strGUID, 50) > 0) {
+ cstrGUID = strGUID;
+ }
+ if ((cstrGUID != _T(""))) {
+ boolean m_find = false;
+ for (i = 0; (!m_find) && (i < m_D3D9GUIDNames.GetCount()); i++) {
+ if (m_D3D9GUIDNames.GetAt(i) == cstrGUID) {
+ m_find = true;
+ }
+ }
+ if (!m_find) {
+ m_iD3D9RenderDeviceCtrl.AddString(d3ddevice_str);
+ m_D3D9GUIDNames.Add(cstrGUID);
+ if (renderersSettings.D3D9RenderDevice == cstrGUID) {
+ m_iD3D9RenderDevice = m_iD3D9RenderDeviceCtrl.GetCount() - 1;
+ }
+ }
+ }
+ }
+ }
+ pD3D->Release();
+ }
+
+ CorrectComboListWidth(m_iD3D9RenderDeviceCtrl);
+
+ UpdateData(FALSE);
+
+ if (!IsCLSIDRegistered(CLSID_VideoMixingRenderer)) {
+ DisableRadioButton(IDC_DSVMR7WIN, IDC_DSSYSDEF);
+ DisableRadioButton(IDC_DSVMR7REN, IDC_DSSYSDEF);
+ }
+
+ if (!IsCLSIDRegistered(CLSID_VideoMixingRenderer9)) {
+ DisableRadioButton(IDC_DSVMR9WIN, IDC_DSSYSDEF);
+ DisableRadioButton(IDC_DSVMR9REN, IDC_DSSYSDEF);
+ DisableRadioButton(IDC_RMDX9, IDC_RMSYSDEF);
+ DisableRadioButton(IDC_QTDX9, IDC_QTSYSDEF);
+ }
+
+ if (!IsCLSIDRegistered(CLSID_EnhancedVideoRenderer)) {
+ DisableRadioButton(IDC_EVR, IDC_DSSYSDEF);
+ DisableRadioButton(IDC_EVR_CUSTOM, IDC_DSSYSDEF);
+ DisableRadioButton(IDC_DSSYNC, IDC_DSSYSDEF); // EVR Sync
+ }
+
+ if (!IsCLSIDRegistered(CLSID_DXR)) {
+ DisableRadioButton(IDC_DSDXR, IDC_DSSYSDEF);
+ }
+
+ if (!IsCLSIDRegistered(CLSID_madVR)) {
+ DisableRadioButton(IDC_DSMADVR, IDC_DSSYSDEF);
+ }
+
+ // YUV mixing is not compatible with Vista
+ if (SysVersion::IsVistaOrLater()) {
+ GetDlgItem(IDC_DSVMR9YUVMIXER)->ShowWindow(SW_HIDE);
+ }
+
+ OnDSRendererChange(m_iDSVideoRendererType + IDC_DSSYSDEF);
+
+ CheckDlgButton(IDC_D3D9DEVICE, BST_CHECKED);
+ GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(TRUE);
+ GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(TRUE);
+
+ if ((m_iDSVideoRendererType == 6 || m_iDSVideoRendererType == 11) && (m_iD3D9RenderDeviceCtrl.GetCount() > 1)) {
+ GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(TRUE);
+ GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(FALSE);
+ CheckDlgButton(IDC_D3D9DEVICE, BST_UNCHECKED);
+ if (m_iD3D9RenderDevice != -1) {
+ CheckDlgButton(IDC_D3D9DEVICE, BST_CHECKED);
+ GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(TRUE);
+ }
+ } else {
+ GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(FALSE);
+ GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(FALSE);
+ if (m_iD3D9RenderDevice == -1) {
+ CheckDlgButton(IDC_D3D9DEVICE, BST_UNCHECKED);
+ }
+ }
+ UpdateData(TRUE);
+
+ CreateToolTip();
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageOutput::OnApply()
{
- UpdateData();
-
- AppSettings& s = AfxGetAppSettings();
-
- CRenderersSettings& renderersSettings = s.m_RenderersSettings;
- s.iDSVideoRendererType = m_iDSVideoRendererType;
- s.iRMVideoRendererType = m_iRMVideoRendererType;
- s.iQTVideoRendererType = m_iQTVideoRendererType;
- renderersSettings.iAPSurfaceUsage = m_iAPSurfaceUsage;
- renderersSettings.iDX9Resizer = m_iDX9Resizer;
- renderersSettings.fVMR9MixerMode = !!m_fVMR9MixerMode;
- renderersSettings.fVMR9MixerYUV = !!m_fVMR9MixerYUV;
- renderersSettings.m_RenderSettings.fVMR9AlterativeVSync = m_fVMR9AlterativeVSync != 0;
- s.strAudioRendererDisplayName = m_AudioRendererDisplayNames[m_iAudioRendererType];
- s.fD3DFullscreen = m_fD3DFullscreen ? true : false;
-
- renderersSettings.fResetDevice = !!m_fResetDevice;
-
- if (!m_iEvrBuffers.IsEmpty()) {
- int Temp = 5;
- swscanf_s(m_iEvrBuffers.GetBuffer(), L"%d", &Temp);
- renderersSettings.iEvrBuffers = Temp;
- } else {
- renderersSettings.iEvrBuffers = 5;
- }
-
- renderersSettings.D3D9RenderDevice = m_fD3D9RenderDevice ? m_D3D9GUIDNames[m_iD3D9RenderDevice] : _T("");
-
- return __super::OnApply();
+ UpdateData();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ CRenderersSettings& renderersSettings = s.m_RenderersSettings;
+ s.iDSVideoRendererType = m_iDSVideoRendererType;
+ s.iRMVideoRendererType = m_iRMVideoRendererType;
+ s.iQTVideoRendererType = m_iQTVideoRendererType;
+ renderersSettings.iAPSurfaceUsage = m_iAPSurfaceUsage;
+ renderersSettings.iDX9Resizer = m_iDX9Resizer;
+ renderersSettings.fVMR9MixerMode = !!m_fVMR9MixerMode;
+ renderersSettings.fVMR9MixerYUV = !!m_fVMR9MixerYUV;
+ renderersSettings.m_RenderSettings.fVMR9AlterativeVSync = m_fVMR9AlterativeVSync != 0;
+ s.strAudioRendererDisplayName = m_AudioRendererDisplayNames[m_iAudioRendererType];
+ s.fD3DFullscreen = m_fD3DFullscreen ? true : false;
+
+ renderersSettings.fResetDevice = !!m_fResetDevice;
+
+ if (!m_iEvrBuffers.IsEmpty()) {
+ int Temp = 5;
+ swscanf_s(m_iEvrBuffers.GetBuffer(), L"%d", &Temp);
+ renderersSettings.iEvrBuffers = Temp;
+ } else {
+ renderersSettings.iEvrBuffers = 5;
+ }
+
+ renderersSettings.D3D9RenderDevice = m_fD3D9RenderDevice ? m_D3D9GUIDNames[m_iD3D9RenderDevice] : _T("");
+
+ return __super::OnApply();
}
void CPPageOutput::OnUpdateMixerYUV(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!!IsDlgButtonChecked(IDC_DSVMR9LOADMIXER) && IsDlgButtonChecked(IDC_DSVMR9REN));
+ pCmdUI->Enable(!!IsDlgButtonChecked(IDC_DSVMR9LOADMIXER) && IsDlgButtonChecked(IDC_DSVMR9REN));
}
void CPPageOutput::OnSurfaceChange()
{
- SetModified();
+ SetModified();
}
void CPPageOutput::OnDSRendererChange(UINT nIDbutton)
{
- GetDlgItem(IDC_DX_SURFACE)->EnableWindow(FALSE);
- GetDlgItem(IDC_DX9RESIZER_COMBO)->EnableWindow(FALSE);
- GetDlgItem(IDC_FULLSCREEN_MONITOR_CHECK)->EnableWindow(FALSE);
- GetDlgItem(IDC_DSVMR9LOADMIXER)->EnableWindow(FALSE);
- GetDlgItem(IDC_DSVMR9YUVMIXER)->EnableWindow(FALSE);
- GetDlgItem(IDC_DSVMR9ALTERNATIVEVSYNC)->EnableWindow(FALSE);
- GetDlgItem(IDC_RESETDEVICE)->EnableWindow(FALSE);
- // GetDlgItem(IDC_CHECK1)->EnableWindow(FALSE);
- GetDlgItem(IDC_EVR_BUFFERS)->EnableWindow((nIDbutton - IDC_DSSYSDEF) == 11);
- GetDlgItem(IDC_EVR_BUFFERS_TXT)->EnableWindow((nIDbutton - IDC_DSSYSDEF) == 11);
-
- GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(FALSE);
- GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(FALSE);
-
- switch (nIDbutton - IDC_DSSYSDEF) {
- case 5 : // VMR7 renderless
- GetDlgItem(IDC_DX_SURFACE)->EnableWindow(TRUE);
- break;
- case 6 : // VMR9 renderless
- if (m_iD3D9RenderDeviceCtrl.GetCount()>1) {
- GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(TRUE);
- GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(IsDlgButtonChecked(IDC_D3D9DEVICE));
- }
-
- GetDlgItem(IDC_DSVMR9LOADMIXER)->EnableWindow(TRUE);
- GetDlgItem(IDC_DSVMR9YUVMIXER)->EnableWindow(TRUE);
- GetDlgItem(IDC_DSVMR9ALTERNATIVEVSYNC)->EnableWindow(TRUE);
- GetDlgItem(IDC_RESETDEVICE)->EnableWindow(TRUE);
- case 11 : // EVR custom presenter
- if (m_iD3D9RenderDeviceCtrl.GetCount()>1) {
- GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(TRUE);
- GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(IsDlgButtonChecked(IDC_D3D9DEVICE));
- }
-
- GetDlgItem(IDC_DX9RESIZER_COMBO)->EnableWindow(TRUE);
- GetDlgItem(IDC_FULLSCREEN_MONITOR_CHECK)->EnableWindow(TRUE);
- // GetDlgItem(IDC_CHECK1)->EnableWindow(TRUE); // Lock back buffer
- GetDlgItem(IDC_DSVMR9ALTERNATIVEVSYNC)->EnableWindow(TRUE);
- GetDlgItem(IDC_RESETDEVICE)->EnableWindow(TRUE);
-
- // Force 3D surface with EVR Custom
- if (nIDbutton - IDC_DSSYSDEF == 11) {
- GetDlgItem(IDC_DX_SURFACE)->EnableWindow(FALSE);
- ((CComboBox*)GetDlgItem(IDC_DX_SURFACE))->SetCurSel(2);
- } else {
- GetDlgItem(IDC_DX_SURFACE)->EnableWindow(TRUE);
- }
- break;
- case 12 : // madVR
- GetDlgItem(IDC_FULLSCREEN_MONITOR_CHECK)->EnableWindow(TRUE);
- break;
- case 13 : // Sync Renderer
- GetDlgItem(IDC_EVR_BUFFERS)->EnableWindow(TRUE);
- GetDlgItem(IDC_EVR_BUFFERS_TXT)->EnableWindow(TRUE);
- GetDlgItem(IDC_DX9RESIZER_COMBO)->EnableWindow(TRUE);
- GetDlgItem(IDC_FULLSCREEN_MONITOR_CHECK)->EnableWindow(TRUE);
- GetDlgItem(IDC_RESETDEVICE)->EnableWindow(TRUE);
- GetDlgItem(IDC_DX_SURFACE)->EnableWindow(FALSE);
- ((CComboBox*)GetDlgItem(IDC_DX_SURFACE))->SetCurSel(2);
- break;
- }
-
- SetModified();
+ GetDlgItem(IDC_DX_SURFACE)->EnableWindow(FALSE);
+ GetDlgItem(IDC_DX9RESIZER_COMBO)->EnableWindow(FALSE);
+ GetDlgItem(IDC_FULLSCREEN_MONITOR_CHECK)->EnableWindow(FALSE);
+ GetDlgItem(IDC_DSVMR9LOADMIXER)->EnableWindow(FALSE);
+ GetDlgItem(IDC_DSVMR9YUVMIXER)->EnableWindow(FALSE);
+ GetDlgItem(IDC_DSVMR9ALTERNATIVEVSYNC)->EnableWindow(FALSE);
+ GetDlgItem(IDC_RESETDEVICE)->EnableWindow(FALSE);
+ // GetDlgItem(IDC_CHECK1)->EnableWindow(FALSE);
+ GetDlgItem(IDC_EVR_BUFFERS)->EnableWindow((nIDbutton - IDC_DSSYSDEF) == 11);
+ GetDlgItem(IDC_EVR_BUFFERS_TXT)->EnableWindow((nIDbutton - IDC_DSSYSDEF) == 11);
+
+ GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(FALSE);
+ GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(FALSE);
+
+ switch (nIDbutton - IDC_DSSYSDEF) {
+ case 5 : // VMR7 renderless
+ GetDlgItem(IDC_DX_SURFACE)->EnableWindow(TRUE);
+ break;
+ case 6 : // VMR9 renderless
+ if (m_iD3D9RenderDeviceCtrl.GetCount() > 1) {
+ GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(TRUE);
+ GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(IsDlgButtonChecked(IDC_D3D9DEVICE));
+ }
+
+ GetDlgItem(IDC_DSVMR9LOADMIXER)->EnableWindow(TRUE);
+ GetDlgItem(IDC_DSVMR9YUVMIXER)->EnableWindow(TRUE);
+ GetDlgItem(IDC_DSVMR9ALTERNATIVEVSYNC)->EnableWindow(TRUE);
+ GetDlgItem(IDC_RESETDEVICE)->EnableWindow(TRUE);
+ case 11 : // EVR custom presenter
+ if (m_iD3D9RenderDeviceCtrl.GetCount() > 1) {
+ GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(TRUE);
+ GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(IsDlgButtonChecked(IDC_D3D9DEVICE));
+ }
+
+ GetDlgItem(IDC_DX9RESIZER_COMBO)->EnableWindow(TRUE);
+ GetDlgItem(IDC_FULLSCREEN_MONITOR_CHECK)->EnableWindow(TRUE);
+ // GetDlgItem(IDC_CHECK1)->EnableWindow(TRUE); // Lock back buffer
+ GetDlgItem(IDC_DSVMR9ALTERNATIVEVSYNC)->EnableWindow(TRUE);
+ GetDlgItem(IDC_RESETDEVICE)->EnableWindow(TRUE);
+
+ // Force 3D surface with EVR Custom
+ if (nIDbutton - IDC_DSSYSDEF == 11) {
+ GetDlgItem(IDC_DX_SURFACE)->EnableWindow(FALSE);
+ ((CComboBox*)GetDlgItem(IDC_DX_SURFACE))->SetCurSel(2);
+ } else {
+ GetDlgItem(IDC_DX_SURFACE)->EnableWindow(TRUE);
+ }
+ break;
+ case 12 : // madVR
+ GetDlgItem(IDC_FULLSCREEN_MONITOR_CHECK)->EnableWindow(TRUE);
+ break;
+ case 13 : // Sync Renderer
+ GetDlgItem(IDC_EVR_BUFFERS)->EnableWindow(TRUE);
+ GetDlgItem(IDC_EVR_BUFFERS_TXT)->EnableWindow(TRUE);
+ GetDlgItem(IDC_DX9RESIZER_COMBO)->EnableWindow(TRUE);
+ GetDlgItem(IDC_FULLSCREEN_MONITOR_CHECK)->EnableWindow(TRUE);
+ GetDlgItem(IDC_RESETDEVICE)->EnableWindow(TRUE);
+ GetDlgItem(IDC_DX_SURFACE)->EnableWindow(FALSE);
+ ((CComboBox*)GetDlgItem(IDC_DX_SURFACE))->SetCurSel(2);
+ break;
+ }
+
+ SetModified();
}
void CPPageOutput::OnFullscreenCheck()
{
- UpdateData();
- if (m_fD3DFullscreen &&
- (MessageBox(ResStr(IDS_D3DFS_WARNING), NULL, MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2) == IDNO)) {
- m_fD3DFullscreen = false;
- UpdateData(FALSE);
- } else {
- SetModified();
- }
+ UpdateData();
+ if (m_fD3DFullscreen &&
+ (MessageBox(ResStr(IDS_D3DFS_WARNING), NULL, MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2) == IDNO)) {
+ m_fD3DFullscreen = false;
+ UpdateData(FALSE);
+ } else {
+ SetModified();
+ }
}
void CPPageOutput::OnD3D9DeviceCheck()
{
- UpdateData();
- GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(m_fD3D9RenderDevice);
- SetModified();
+ UpdateData();
+ GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(m_fD3D9RenderDevice);
+ SetModified();
}
diff --git a/src/mpc-hc/PPageOutput.h b/src/mpc-hc/PPageOutput.h
index 9a6b8813b..8ac975ed2 100644
--- a/src/mpc-hc/PPageOutput.h
+++ b/src/mpc-hc/PPageOutput.h
@@ -32,49 +32,49 @@
class CPPageOutput : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageOutput)
+ DECLARE_DYNAMIC(CPPageOutput)
private:
- CStringArray m_AudioRendererDisplayNames;
- CStringArray m_D3D9GUIDNames;
+ CStringArray m_AudioRendererDisplayNames;
+ CStringArray m_D3D9GUIDNames;
- void DisableRadioButton(UINT nID, UINT nDefID);
+ void DisableRadioButton(UINT nID, UINT nDefID);
public:
- CPPageOutput();
- virtual ~CPPageOutput();
+ CPPageOutput();
+ virtual ~CPPageOutput();
- // Dialog Data
- enum { IDD = IDD_PPAGEOUTPUT };
- int m_iDSVideoRendererType;
- int m_iRMVideoRendererType;
- int m_iQTVideoRendererType;
- int m_iAPSurfaceUsage;
- int m_iAudioRendererType;
- CComboBox m_iAudioRendererTypeCtrl;
- int m_iDX9Resizer;
- BOOL m_fVMR9MixerMode;
- BOOL m_fVMR9MixerYUV;
- BOOL m_fD3DFullscreen;
- BOOL m_fVMR9AlterativeVSync;
- BOOL m_fResetDevice;
- CString m_iEvrBuffers;
+ // Dialog Data
+ enum { IDD = IDD_PPAGEOUTPUT };
+ int m_iDSVideoRendererType;
+ int m_iRMVideoRendererType;
+ int m_iQTVideoRendererType;
+ int m_iAPSurfaceUsage;
+ int m_iAudioRendererType;
+ CComboBox m_iAudioRendererTypeCtrl;
+ int m_iDX9Resizer;
+ BOOL m_fVMR9MixerMode;
+ BOOL m_fVMR9MixerYUV;
+ BOOL m_fD3DFullscreen;
+ BOOL m_fVMR9AlterativeVSync;
+ BOOL m_fResetDevice;
+ CString m_iEvrBuffers;
- BOOL m_fD3D9RenderDevice;
- int m_iD3D9RenderDevice;
- CComboBox m_iD3D9RenderDeviceCtrl;
+ BOOL m_fD3D9RenderDevice;
+ int m_iD3D9RenderDevice;
+ CComboBox m_iD3D9RenderDeviceCtrl;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnUpdateMixerYUV(CCmdUI* pCmdUI);
- afx_msg void OnSurfaceChange();
- afx_msg void OnDSRendererChange(UINT nIDbutton);
- afx_msg void OnFullscreenCheck();
- afx_msg void OnD3D9DeviceCheck();
+ afx_msg void OnUpdateMixerYUV(CCmdUI* pCmdUI);
+ afx_msg void OnSurfaceChange();
+ afx_msg void OnDSRendererChange(UINT nIDbutton);
+ afx_msg void OnFullscreenCheck();
+ afx_msg void OnD3D9DeviceCheck();
};
diff --git a/src/mpc-hc/PPagePlayback.cpp b/src/mpc-hc/PPagePlayback.cpp
index c9bef6c86..d65c90e70 100644
--- a/src/mpc-hc/PPagePlayback.cpp
+++ b/src/mpc-hc/PPagePlayback.cpp
@@ -33,20 +33,20 @@
IMPLEMENT_DYNAMIC(CPPagePlayback, CPPageBase)
CPPagePlayback::CPPagePlayback()
- : CPPageBase(CPPagePlayback::IDD, CPPagePlayback::IDD)
- , m_iLoopForever(0)
- , m_nLoops(0)
- , m_fRewind(FALSE)
- , m_iZoomLevel(0)
- , m_iRememberZoomLevel(FALSE)
- , m_nVolume(0)
- , m_nBalance(0)
- , m_fAutoloadAudio(FALSE)
- , m_fAutoloadSubtitles(FALSE)
- , m_fEnableWorkerThreadForOpening(FALSE)
- , m_fReportFailedPins(FALSE)
- , m_subtitlesLanguageOrder(_T(""))
- , m_audiosLanguageOrder(_T(""))
+ : CPPageBase(CPPagePlayback::IDD, CPPagePlayback::IDD)
+ , m_iLoopForever(0)
+ , m_nLoops(0)
+ , m_fRewind(FALSE)
+ , m_iZoomLevel(0)
+ , m_iRememberZoomLevel(FALSE)
+ , m_nVolume(0)
+ , m_nBalance(0)
+ , m_fAutoloadAudio(FALSE)
+ , m_fAutoloadSubtitles(FALSE)
+ , m_fEnableWorkerThreadForOpening(FALSE)
+ , m_fReportFailedPins(FALSE)
+ , m_subtitlesLanguageOrder(_T(""))
+ , m_audiosLanguageOrder(_T(""))
{
}
@@ -56,35 +56,35 @@ CPPagePlayback::~CPPagePlayback()
void CPPagePlayback::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_SLIDER1, m_volumectrl);
- DDX_Control(pDX, IDC_SLIDER2, m_balancectrl);
- DDX_Control(pDX, IDC_COMBO1, m_zoomlevelctrl);
- DDX_Slider(pDX, IDC_SLIDER1, m_nVolume);
- DDX_Slider(pDX, IDC_SLIDER2, m_nBalance);
- DDX_Radio(pDX, IDC_RADIO1, m_iLoopForever);
- DDX_Control(pDX, IDC_EDIT1, m_loopnumctrl);
- DDX_Text(pDX, IDC_EDIT1, m_nLoops);
- DDX_Check(pDX, IDC_CHECK1, m_fRewind);
- DDX_CBIndex(pDX, IDC_COMBO1, m_iZoomLevel);
- DDX_Check(pDX, IDC_CHECK5, m_iRememberZoomLevel);
- DDX_Check(pDX, IDC_CHECK2, m_fAutoloadAudio);
- DDX_Check(pDX, IDC_CHECK3, m_fAutoloadSubtitles);
- DDX_Check(pDX, IDC_CHECK7, m_fEnableWorkerThreadForOpening);
- DDX_Check(pDX, IDC_CHECK6, m_fReportFailedPins);
- DDX_Text(pDX, IDC_EDIT2, m_subtitlesLanguageOrder);
- DDX_Text(pDX, IDC_EDIT3, m_audiosLanguageOrder);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_SLIDER1, m_volumectrl);
+ DDX_Control(pDX, IDC_SLIDER2, m_balancectrl);
+ DDX_Control(pDX, IDC_COMBO1, m_zoomlevelctrl);
+ DDX_Slider(pDX, IDC_SLIDER1, m_nVolume);
+ DDX_Slider(pDX, IDC_SLIDER2, m_nBalance);
+ DDX_Radio(pDX, IDC_RADIO1, m_iLoopForever);
+ DDX_Control(pDX, IDC_EDIT1, m_loopnumctrl);
+ DDX_Text(pDX, IDC_EDIT1, m_nLoops);
+ DDX_Check(pDX, IDC_CHECK1, m_fRewind);
+ DDX_CBIndex(pDX, IDC_COMBO1, m_iZoomLevel);
+ DDX_Check(pDX, IDC_CHECK5, m_iRememberZoomLevel);
+ DDX_Check(pDX, IDC_CHECK2, m_fAutoloadAudio);
+ DDX_Check(pDX, IDC_CHECK3, m_fAutoloadSubtitles);
+ DDX_Check(pDX, IDC_CHECK7, m_fEnableWorkerThreadForOpening);
+ DDX_Check(pDX, IDC_CHECK6, m_fReportFailedPins);
+ DDX_Text(pDX, IDC_EDIT2, m_subtitlesLanguageOrder);
+ DDX_Text(pDX, IDC_EDIT3, m_audiosLanguageOrder);
}
BEGIN_MESSAGE_MAP(CPPagePlayback, CPPageBase)
- ON_WM_HSCROLL()
- ON_CONTROL_RANGE(BN_CLICKED, IDC_RADIO1, IDC_RADIO2, OnBnClickedRadio12)
- ON_UPDATE_COMMAND_UI(IDC_EDIT1, OnUpdateLoopNum)
- ON_UPDATE_COMMAND_UI(IDC_STATIC1, OnUpdateLoopNum)
- ON_UPDATE_COMMAND_UI(IDC_COMBO1, OnUpdateAutoZoomCombo)
-
- ON_STN_DBLCLK(IDC_STATIC_BALANCE, OnBalanceTextDblClk)
- ON_NOTIFY_EX_RANGE(TTN_NEEDTEXT, 0, 0xFFFF, OnToolTipNotify)
+ ON_WM_HSCROLL()
+ ON_CONTROL_RANGE(BN_CLICKED, IDC_RADIO1, IDC_RADIO2, OnBnClickedRadio12)
+ ON_UPDATE_COMMAND_UI(IDC_EDIT1, OnUpdateLoopNum)
+ ON_UPDATE_COMMAND_UI(IDC_STATIC1, OnUpdateLoopNum)
+ ON_UPDATE_COMMAND_UI(IDC_COMBO1, OnUpdateAutoZoomCombo)
+
+ ON_STN_DBLCLK(IDC_STATIC_BALANCE, OnBalanceTextDblClk)
+ ON_NOTIFY_EX_RANGE(TTN_NEEDTEXT, 0, 0xFFFF, OnToolTipNotify)
END_MESSAGE_MAP()
@@ -92,156 +92,156 @@ END_MESSAGE_MAP()
BOOL CPPagePlayback::OnInitDialog()
{
- __super::OnInitDialog();
-
- SetHandCursor(m_hWnd, IDC_COMBO1);
-
- AppSettings& s = AfxGetAppSettings();
-
- m_volumectrl.SetRange(0, 100);
- m_volumectrl.SetTicFreq(10);
- m_balancectrl.SetRange(-100, 100);
- m_balancectrl.SetLineSize(2);
- m_balancectrl.SetPageSize(2);
- m_balancectrl.SetTicFreq(20);
- m_nVolume = m_oldVolume = s.nVolume;
- m_nBalance = s.nBalance;
- m_iLoopForever = s.fLoopForever?1:0;
- m_nLoops = s.nLoops;
- m_fRewind = s.fRewind;
- m_iZoomLevel = s.iZoomLevel;
- m_iRememberZoomLevel = s.fRememberZoomLevel;
- m_fAutoloadAudio = s.fAutoloadAudio;
- m_fAutoloadSubtitles = s.fAutoloadSubtitles;
- m_fEnableWorkerThreadForOpening = s.fEnableWorkerThreadForOpening;
- m_fReportFailedPins = s.fReportFailedPins;
- m_subtitlesLanguageOrder = s.strSubtitlesLanguageOrder;
- m_audiosLanguageOrder = s.strAudiosLanguageOrder;
-
- m_zoomlevelctrl.AddString(ResStr(IDS_ZOOM_50));
- m_zoomlevelctrl.AddString(ResStr(IDS_ZOOM_100));
- m_zoomlevelctrl.AddString(ResStr(IDS_ZOOM_200));
- m_zoomlevelctrl.AddString(ResStr(IDS_ZOOM_AUTOFIT));
- m_zoomlevelctrl.AddString(ResStr(IDS_ZOOM_AUTOFIT_LARGER));
- CorrectComboListWidth(m_zoomlevelctrl);
-
- EnableToolTips(TRUE);
- UpdateData(FALSE);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ SetHandCursor(m_hWnd, IDC_COMBO1);
+
+ AppSettings& s = AfxGetAppSettings();
+
+ m_volumectrl.SetRange(0, 100);
+ m_volumectrl.SetTicFreq(10);
+ m_balancectrl.SetRange(-100, 100);
+ m_balancectrl.SetLineSize(2);
+ m_balancectrl.SetPageSize(2);
+ m_balancectrl.SetTicFreq(20);
+ m_nVolume = m_oldVolume = s.nVolume;
+ m_nBalance = s.nBalance;
+ m_iLoopForever = s.fLoopForever ? 1 : 0;
+ m_nLoops = s.nLoops;
+ m_fRewind = s.fRewind;
+ m_iZoomLevel = s.iZoomLevel;
+ m_iRememberZoomLevel = s.fRememberZoomLevel;
+ m_fAutoloadAudio = s.fAutoloadAudio;
+ m_fAutoloadSubtitles = s.fAutoloadSubtitles;
+ m_fEnableWorkerThreadForOpening = s.fEnableWorkerThreadForOpening;
+ m_fReportFailedPins = s.fReportFailedPins;
+ m_subtitlesLanguageOrder = s.strSubtitlesLanguageOrder;
+ m_audiosLanguageOrder = s.strAudiosLanguageOrder;
+
+ m_zoomlevelctrl.AddString(ResStr(IDS_ZOOM_50));
+ m_zoomlevelctrl.AddString(ResStr(IDS_ZOOM_100));
+ m_zoomlevelctrl.AddString(ResStr(IDS_ZOOM_200));
+ m_zoomlevelctrl.AddString(ResStr(IDS_ZOOM_AUTOFIT));
+ m_zoomlevelctrl.AddString(ResStr(IDS_ZOOM_AUTOFIT_LARGER));
+ CorrectComboListWidth(m_zoomlevelctrl);
+
+ EnableToolTips(TRUE);
+ UpdateData(FALSE);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPagePlayback::OnApply()
{
- UpdateData();
-
- AppSettings& s = AfxGetAppSettings();
-
- s.nVolume = m_oldVolume = m_nVolume;
- s.nBalance = m_nBalance;
- s.fLoopForever = !!m_iLoopForever;
- s.nLoops = m_nLoops;
- s.fRewind = !!m_fRewind;
- s.iZoomLevel = m_iZoomLevel;
- s.fRememberZoomLevel = !!m_iRememberZoomLevel;
- s.fAutoloadAudio = !!m_fAutoloadAudio;
- s.fAutoloadSubtitles = !!m_fAutoloadSubtitles;
- s.fEnableWorkerThreadForOpening = !!m_fEnableWorkerThreadForOpening;
- s.fReportFailedPins = !!m_fReportFailedPins;
- s.strSubtitlesLanguageOrder = m_subtitlesLanguageOrder;
- s.strAudiosLanguageOrder = m_audiosLanguageOrder;
-
- return __super::OnApply();
+ UpdateData();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ s.nVolume = m_oldVolume = m_nVolume;
+ s.nBalance = m_nBalance;
+ s.fLoopForever = !!m_iLoopForever;
+ s.nLoops = m_nLoops;
+ s.fRewind = !!m_fRewind;
+ s.iZoomLevel = m_iZoomLevel;
+ s.fRememberZoomLevel = !!m_iRememberZoomLevel;
+ s.fAutoloadAudio = !!m_fAutoloadAudio;
+ s.fAutoloadSubtitles = !!m_fAutoloadSubtitles;
+ s.fEnableWorkerThreadForOpening = !!m_fEnableWorkerThreadForOpening;
+ s.fReportFailedPins = !!m_fReportFailedPins;
+ s.strSubtitlesLanguageOrder = m_subtitlesLanguageOrder;
+ s.strAudiosLanguageOrder = m_audiosLanguageOrder;
+
+ return __super::OnApply();
}
void CPPagePlayback::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
- if (*pScrollBar == m_volumectrl) {
- UpdateData();
- ((CMainFrame*)GetParentFrame())->m_wndToolBar.Volume = m_nVolume; // nice shortcut...
- } else if (*pScrollBar == m_balancectrl) {
- UpdateData();
- ((CMainFrame*)GetParentFrame())->SetBalance(m_nBalance); // see prev note...
- }
+ if (*pScrollBar == m_volumectrl) {
+ UpdateData();
+ ((CMainFrame*)GetParentFrame())->m_wndToolBar.Volume = m_nVolume; // nice shortcut...
+ } else if (*pScrollBar == m_balancectrl) {
+ UpdateData();
+ ((CMainFrame*)GetParentFrame())->SetBalance(m_nBalance); // see prev note...
+ }
- SetModified();
+ SetModified();
- __super::OnHScroll(nSBCode, nPos, pScrollBar);
+ __super::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CPPagePlayback::OnBnClickedRadio12(UINT nID)
{
- SetModified();
+ SetModified();
}
void CPPagePlayback::OnUpdateLoopNum(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!!IsDlgButtonChecked(IDC_RADIO1));
+ pCmdUI->Enable(!!IsDlgButtonChecked(IDC_RADIO1));
}
void CPPagePlayback::OnUpdateAutoZoomCombo(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK5));
+ pCmdUI->Enable(!!IsDlgButtonChecked(IDC_CHECK5));
}
void CPPagePlayback::OnBalanceTextDblClk()
{
- // double click on text "Balance" resets the balance to zero
- m_balancectrl.SetPos(0);
- ((CMainFrame*)GetParentFrame())->SetBalance(0);
- SetModified();
+ // double click on text "Balance" resets the balance to zero
+ m_balancectrl.SetPos(0);
+ ((CMainFrame*)GetParentFrame())->SetBalance(0);
+ SetModified();
}
-BOOL CPPagePlayback::OnToolTipNotify(UINT id, NMHDR * pNMHDR, LRESULT * pResult)
+BOOL CPPagePlayback::OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
{
- LPTOOLTIPTEXT pTTT = reinterpret_cast<LPTOOLTIPTEXT>(pNMHDR);
-
- UINT_PTR nID = pNMHDR->idFrom;
- if (pTTT->uFlags & TTF_IDISHWND) {
- nID = ::GetDlgCtrlID((HWND)nID);
- }
-
- if (nID == 0) {
- return FALSE;
- }
-
- CString strTipText;
-
- if (nID == IDC_SLIDER1) {
- strTipText.Format(_T("%d%%"), m_nVolume);
- } else if (nID == IDC_SLIDER2) {
- if (m_nBalance > 0) {
- strTipText.Format(_T("R +%d%%"), m_nBalance);
- } else if (m_nBalance < 0) {
- strTipText.Format(_T("L +%d%%"), -m_nBalance);
- } else { //if (m_nBalance == 0)
- strTipText = _T("L = R");
- }
- } else if (nID == IDC_COMBO1) {
- int i = m_zoomlevelctrl.GetCurSel();
- m_zoomlevelctrl.GetLBText(i, strTipText);
- } else {
- return FALSE;
- }
-
- _tcscpy_s(pTTT->szText, strTipText.Left(_countof(pTTT->szText)));
-
- *pResult = 0;
-
- return TRUE; // message was handled
+ LPTOOLTIPTEXT pTTT = reinterpret_cast<LPTOOLTIPTEXT>(pNMHDR);
+
+ UINT_PTR nID = pNMHDR->idFrom;
+ if (pTTT->uFlags & TTF_IDISHWND) {
+ nID = ::GetDlgCtrlID((HWND)nID);
+ }
+
+ if (nID == 0) {
+ return FALSE;
+ }
+
+ CString strTipText;
+
+ if (nID == IDC_SLIDER1) {
+ strTipText.Format(_T("%d%%"), m_nVolume);
+ } else if (nID == IDC_SLIDER2) {
+ if (m_nBalance > 0) {
+ strTipText.Format(_T("R +%d%%"), m_nBalance);
+ } else if (m_nBalance < 0) {
+ strTipText.Format(_T("L +%d%%"), -m_nBalance);
+ } else { //if (m_nBalance == 0)
+ strTipText = _T("L = R");
+ }
+ } else if (nID == IDC_COMBO1) {
+ int i = m_zoomlevelctrl.GetCurSel();
+ m_zoomlevelctrl.GetLBText(i, strTipText);
+ } else {
+ return FALSE;
+ }
+
+ _tcscpy_s(pTTT->szText, strTipText.Left(_countof(pTTT->szText)));
+
+ *pResult = 0;
+
+ return TRUE; // message was handled
}
void CPPagePlayback::OnCancel()
{
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- if (m_nVolume != m_oldVolume) {
- ((CMainFrame*)GetParentFrame())->m_wndToolBar.Volume = m_oldVolume; //not very nice solution
- }
- if (m_nBalance != s.nBalance) {
- ((CMainFrame*)GetParentFrame())->SetBalance(s.nBalance);
- }
+ if (m_nVolume != m_oldVolume) {
+ ((CMainFrame*)GetParentFrame())->m_wndToolBar.Volume = m_oldVolume; //not very nice solution
+ }
+ if (m_nBalance != s.nBalance) {
+ ((CMainFrame*)GetParentFrame())->SetBalance(s.nBalance);
+ }
- __super::OnCancel();
+ __super::OnCancel();
}
diff --git a/src/mpc-hc/PPagePlayback.h b/src/mpc-hc/PPagePlayback.h
index 8f2afe989..5b5d5e6e6 100644
--- a/src/mpc-hc/PPagePlayback.h
+++ b/src/mpc-hc/PPagePlayback.h
@@ -30,51 +30,51 @@
class CPPagePlayback : public CPPageBase
{
- DECLARE_DYNAMIC(CPPagePlayback)
+ DECLARE_DYNAMIC(CPPagePlayback)
- // private:
- int m_oldVolume; //not very nice solution
+ // private:
+ int m_oldVolume; //not very nice solution
public:
- CPPagePlayback();
- virtual ~CPPagePlayback();
+ CPPagePlayback();
+ virtual ~CPPagePlayback();
- CSliderCtrl m_volumectrl;
- CSliderCtrl m_balancectrl;
- int m_nVolume;
- int m_nBalance;
- int m_iLoopForever;
- CEdit m_loopnumctrl;
- int m_nLoops;
- BOOL m_fRewind;
- int m_iZoomLevel;
- BOOL m_iRememberZoomLevel;
- BOOL m_fAutoloadAudio;
- BOOL m_fAutoloadSubtitles;
- BOOL m_fEnableWorkerThreadForOpening;
- BOOL m_fReportFailedPins;
- CString m_subtitlesLanguageOrder;
- CString m_audiosLanguageOrder;
+ CSliderCtrl m_volumectrl;
+ CSliderCtrl m_balancectrl;
+ int m_nVolume;
+ int m_nBalance;
+ int m_iLoopForever;
+ CEdit m_loopnumctrl;
+ int m_nLoops;
+ BOOL m_fRewind;
+ int m_iZoomLevel;
+ BOOL m_iRememberZoomLevel;
+ BOOL m_fAutoloadAudio;
+ BOOL m_fAutoloadSubtitles;
+ BOOL m_fEnableWorkerThreadForOpening;
+ BOOL m_fReportFailedPins;
+ CString m_subtitlesLanguageOrder;
+ CString m_audiosLanguageOrder;
- CComboBox m_zoomlevelctrl;
+ CComboBox m_zoomlevelctrl;
- // Dialog Data
- enum { IDD = IDD_PPAGEPLAYBACK };
+ // Dialog Data
+ enum { IDD = IDD_PPAGEPLAYBACK };
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
- afx_msg void OnBnClickedRadio12(UINT nID);
- afx_msg void OnUpdateLoopNum(CCmdUI* pCmdUI);
- afx_msg void OnUpdateAutoZoomCombo(CCmdUI* pCmdUI);
+ afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
+ afx_msg void OnBnClickedRadio12(UINT nID);
+ afx_msg void OnUpdateLoopNum(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateAutoZoomCombo(CCmdUI* pCmdUI);
- afx_msg void OnBalanceTextDblClk();
- afx_msg BOOL OnToolTipNotify(UINT id, NMHDR * pNMHDR, LRESULT * pResult);
- virtual void OnCancel();
+ afx_msg void OnBalanceTextDblClk();
+ afx_msg BOOL OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
+ virtual void OnCancel();
};
diff --git a/src/mpc-hc/PPagePlayer.cpp b/src/mpc-hc/PPagePlayer.cpp
index 75206b7c1..039eaebeb 100644
--- a/src/mpc-hc/PPagePlayer.cpp
+++ b/src/mpc-hc/PPagePlayer.cpp
@@ -31,24 +31,24 @@
IMPLEMENT_DYNAMIC(CPPagePlayer, CPPageBase)
CPPagePlayer::CPPagePlayer()
- : CPPageBase(CPPagePlayer::IDD, CPPagePlayer::IDD)
- , m_iAllowMultipleInst(0)
- , m_iAlwaysOnTop(FALSE)
- , m_fTrayIcon(FALSE)
- , m_iTitleBarTextStyle(0)
- , m_bTitleBarTextTitle(0)
- , m_fRememberWindowPos(FALSE)
- , m_fRememberWindowSize(FALSE)
- , m_fSavePnSZoom(FALSE)
- , m_fSnapToDesktopEdges(FALSE)
- , m_fUseIni(FALSE)
- , m_fKeepHistory(FALSE)
- , m_fHideCDROMsSubMenu(FALSE)
- , m_priority(FALSE)
- , m_fShowOSD(FALSE)
- , m_fLimitWindowProportions(TRUE)
- , m_fRememberDVDPos(FALSE)
- , m_fRememberFilePos(FALSE)
+ : CPPageBase(CPPagePlayer::IDD, CPPagePlayer::IDD)
+ , m_iAllowMultipleInst(0)
+ , m_iAlwaysOnTop(FALSE)
+ , m_fTrayIcon(FALSE)
+ , m_iTitleBarTextStyle(0)
+ , m_bTitleBarTextTitle(0)
+ , m_fRememberWindowPos(FALSE)
+ , m_fRememberWindowSize(FALSE)
+ , m_fSavePnSZoom(FALSE)
+ , m_fSnapToDesktopEdges(FALSE)
+ , m_fUseIni(FALSE)
+ , m_fKeepHistory(FALSE)
+ , m_fHideCDROMsSubMenu(FALSE)
+ , m_priority(FALSE)
+ , m_fShowOSD(FALSE)
+ , m_fLimitWindowProportions(TRUE)
+ , m_fRememberDVDPos(FALSE)
+ , m_fRememberFilePos(FALSE)
{
}
@@ -58,129 +58,129 @@ CPPagePlayer::~CPPagePlayer()
void CPPagePlayer::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Radio(pDX, IDC_RADIO1, m_iAllowMultipleInst);
- DDX_Radio(pDX, IDC_RADIO3, m_iTitleBarTextStyle);
- DDX_Check(pDX, IDC_CHECK13, m_bTitleBarTextTitle);
- //DDX_Check(pDX, IDC_CHECK2, m_iAlwaysOnTop);
- DDX_Check(pDX, IDC_CHECK3, m_fTrayIcon);
- DDX_Check(pDX, IDC_CHECK6, m_fRememberWindowPos);
- DDX_Check(pDX, IDC_CHECK7, m_fRememberWindowSize);
- DDX_Check(pDX, IDC_CHECK11, m_fSavePnSZoom);
- DDX_Check(pDX, IDC_CHECK12, m_fSnapToDesktopEdges);
- DDX_Check(pDX, IDC_CHECK8, m_fUseIni);
- DDX_Check(pDX, IDC_CHECK1, m_fKeepHistory);
- DDX_Check(pDX, IDC_CHECK10, m_fHideCDROMsSubMenu);
- DDX_Check(pDX, IDC_CHECK9, m_priority);
- DDX_Check(pDX, IDC_SHOW_OSD, m_fShowOSD);
- DDX_Check(pDX, IDC_CHECK4, m_fLimitWindowProportions);
- DDX_Check(pDX, IDC_DVD_POS, m_fRememberDVDPos);
- DDX_Check(pDX, IDC_FILE_POS, m_fRememberFilePos);
+ __super::DoDataExchange(pDX);
+ DDX_Radio(pDX, IDC_RADIO1, m_iAllowMultipleInst);
+ DDX_Radio(pDX, IDC_RADIO3, m_iTitleBarTextStyle);
+ DDX_Check(pDX, IDC_CHECK13, m_bTitleBarTextTitle);
+ //DDX_Check(pDX, IDC_CHECK2, m_iAlwaysOnTop);
+ DDX_Check(pDX, IDC_CHECK3, m_fTrayIcon);
+ DDX_Check(pDX, IDC_CHECK6, m_fRememberWindowPos);
+ DDX_Check(pDX, IDC_CHECK7, m_fRememberWindowSize);
+ DDX_Check(pDX, IDC_CHECK11, m_fSavePnSZoom);
+ DDX_Check(pDX, IDC_CHECK12, m_fSnapToDesktopEdges);
+ DDX_Check(pDX, IDC_CHECK8, m_fUseIni);
+ DDX_Check(pDX, IDC_CHECK1, m_fKeepHistory);
+ DDX_Check(pDX, IDC_CHECK10, m_fHideCDROMsSubMenu);
+ DDX_Check(pDX, IDC_CHECK9, m_priority);
+ DDX_Check(pDX, IDC_SHOW_OSD, m_fShowOSD);
+ DDX_Check(pDX, IDC_CHECK4, m_fLimitWindowProportions);
+ DDX_Check(pDX, IDC_DVD_POS, m_fRememberDVDPos);
+ DDX_Check(pDX, IDC_FILE_POS, m_fRememberFilePos);
}
BEGIN_MESSAGE_MAP(CPPagePlayer, CPPageBase)
- ON_UPDATE_COMMAND_UI(IDC_CHECK13, OnUpdateCheck13)
- ON_UPDATE_COMMAND_UI(IDC_DVD_POS, OnUpdatePos)
- ON_UPDATE_COMMAND_UI(IDC_FILE_POS, OnUpdatePos)
+ ON_UPDATE_COMMAND_UI(IDC_CHECK13, OnUpdateCheck13)
+ ON_UPDATE_COMMAND_UI(IDC_DVD_POS, OnUpdatePos)
+ ON_UPDATE_COMMAND_UI(IDC_FILE_POS, OnUpdatePos)
END_MESSAGE_MAP()
// CPPagePlayer message handlers
BOOL CPPagePlayer::OnInitDialog()
{
- __super::OnInitDialog();
-
- AppSettings& s = AfxGetAppSettings();
-
- m_iAllowMultipleInst = s.fAllowMultipleInst;
- m_iTitleBarTextStyle = s.iTitleBarTextStyle;
- m_bTitleBarTextTitle = s.fTitleBarTextTitle;
- m_iAlwaysOnTop = s.iOnTop;
- m_fTrayIcon = s.fTrayIcon;
- m_fRememberWindowPos = s.fRememberWindowPos;
- m_fRememberWindowSize = s.fRememberWindowSize;
- m_fSavePnSZoom = s.fSavePnSZoom;
- m_fSnapToDesktopEdges = s.fSnapToDesktopEdges;
- m_fUseIni = AfxGetMyApp()->IsIniValid();
- m_fKeepHistory = s.fKeepHistory;
- m_fHideCDROMsSubMenu = s.fHideCDROMsSubMenu;
- m_priority = s.dwPriority != NORMAL_PRIORITY_CLASS;
- m_fShowOSD = s.fShowOSD;
- m_fRememberDVDPos = s.fRememberDVDPos;
- m_fRememberFilePos = s.fRememberFilePos;
- m_fLimitWindowProportions = s.fLimitWindowProportions;
-
- UpdateData(FALSE);
-
- GetDlgItem(IDC_FILE_POS)->EnableWindow(s.fKeepHistory);
- GetDlgItem(IDC_DVD_POS)->EnableWindow(s.fKeepHistory);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ m_iAllowMultipleInst = s.fAllowMultipleInst;
+ m_iTitleBarTextStyle = s.iTitleBarTextStyle;
+ m_bTitleBarTextTitle = s.fTitleBarTextTitle;
+ m_iAlwaysOnTop = s.iOnTop;
+ m_fTrayIcon = s.fTrayIcon;
+ m_fRememberWindowPos = s.fRememberWindowPos;
+ m_fRememberWindowSize = s.fRememberWindowSize;
+ m_fSavePnSZoom = s.fSavePnSZoom;
+ m_fSnapToDesktopEdges = s.fSnapToDesktopEdges;
+ m_fUseIni = AfxGetMyApp()->IsIniValid();
+ m_fKeepHistory = s.fKeepHistory;
+ m_fHideCDROMsSubMenu = s.fHideCDROMsSubMenu;
+ m_priority = s.dwPriority != NORMAL_PRIORITY_CLASS;
+ m_fShowOSD = s.fShowOSD;
+ m_fRememberDVDPos = s.fRememberDVDPos;
+ m_fRememberFilePos = s.fRememberFilePos;
+ m_fLimitWindowProportions = s.fLimitWindowProportions;
+
+ UpdateData(FALSE);
+
+ GetDlgItem(IDC_FILE_POS)->EnableWindow(s.fKeepHistory);
+ GetDlgItem(IDC_DVD_POS)->EnableWindow(s.fKeepHistory);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPagePlayer::OnApply()
{
- UpdateData();
-
- AppSettings& s = AfxGetAppSettings();
-
- s.fAllowMultipleInst = !!m_iAllowMultipleInst;
- s.iTitleBarTextStyle = m_iTitleBarTextStyle;
- s.fTitleBarTextTitle = !!m_bTitleBarTextTitle;
- s.iOnTop = m_iAlwaysOnTop;
- s.fTrayIcon = !!m_fTrayIcon;
- s.fRememberWindowPos = !!m_fRememberWindowPos;
- s.fRememberWindowSize = !!m_fRememberWindowSize;
- s.fSavePnSZoom = !!m_fSavePnSZoom;
- s.fSnapToDesktopEdges = !!m_fSnapToDesktopEdges;
- s.fKeepHistory = !!m_fKeepHistory;
- s.fHideCDROMsSubMenu = !!m_fHideCDROMsSubMenu;
- s.dwPriority = !m_priority ? NORMAL_PRIORITY_CLASS : GetVersion() < 0 ? HIGH_PRIORITY_CLASS : ABOVE_NORMAL_PRIORITY_CLASS;
- s.fShowOSD = !!m_fShowOSD;
- s.fLimitWindowProportions = !!m_fLimitWindowProportions;
- s.fRememberDVDPos = m_fRememberDVDPos ? true : false;
- s.fRememberFilePos = m_fRememberFilePos ? true : false;
-
- if (!m_fKeepHistory) {
- for (int i = 0; i < s.MRU.GetSize(); i++) {
- s.MRU.Remove(i);
- }
- for (int i = 0; i < s.MRUDub.GetSize(); i++) {
- s.MRUDub.Remove(i);
- }
- s.MRU.WriteList();
- s.MRUDub.WriteList();
-
- s.ClearFilePositions();
- s.ClearDVDPositions();
- }
-
- // Check if the settings location needs to be changed
- if (AfxGetMyApp()->IsIniValid() != !!m_fUseIni) {
- AfxGetMyApp()->ChangeSettingsLocation(!!m_fUseIni);
- }
-
- ((CMainFrame*)AfxGetMainWnd())->ShowTrayIcon(s.fTrayIcon);
-
- ::SetPriorityClass(::GetCurrentProcess(), s.dwPriority);
-
- GetDlgItem(IDC_FILE_POS)->EnableWindow(s.fKeepHistory);
- GetDlgItem(IDC_DVD_POS)->EnableWindow(s.fKeepHistory);
-
- return __super::OnApply();
+ UpdateData();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ s.fAllowMultipleInst = !!m_iAllowMultipleInst;
+ s.iTitleBarTextStyle = m_iTitleBarTextStyle;
+ s.fTitleBarTextTitle = !!m_bTitleBarTextTitle;
+ s.iOnTop = m_iAlwaysOnTop;
+ s.fTrayIcon = !!m_fTrayIcon;
+ s.fRememberWindowPos = !!m_fRememberWindowPos;
+ s.fRememberWindowSize = !!m_fRememberWindowSize;
+ s.fSavePnSZoom = !!m_fSavePnSZoom;
+ s.fSnapToDesktopEdges = !!m_fSnapToDesktopEdges;
+ s.fKeepHistory = !!m_fKeepHistory;
+ s.fHideCDROMsSubMenu = !!m_fHideCDROMsSubMenu;
+ s.dwPriority = !m_priority ? NORMAL_PRIORITY_CLASS : GetVersion() < 0 ? HIGH_PRIORITY_CLASS : ABOVE_NORMAL_PRIORITY_CLASS;
+ s.fShowOSD = !!m_fShowOSD;
+ s.fLimitWindowProportions = !!m_fLimitWindowProportions;
+ s.fRememberDVDPos = m_fRememberDVDPos ? true : false;
+ s.fRememberFilePos = m_fRememberFilePos ? true : false;
+
+ if (!m_fKeepHistory) {
+ for (int i = 0; i < s.MRU.GetSize(); i++) {
+ s.MRU.Remove(i);
+ }
+ for (int i = 0; i < s.MRUDub.GetSize(); i++) {
+ s.MRUDub.Remove(i);
+ }
+ s.MRU.WriteList();
+ s.MRUDub.WriteList();
+
+ s.ClearFilePositions();
+ s.ClearDVDPositions();
+ }
+
+ // Check if the settings location needs to be changed
+ if (AfxGetMyApp()->IsIniValid() != !!m_fUseIni) {
+ AfxGetMyApp()->ChangeSettingsLocation(!!m_fUseIni);
+ }
+
+ ((CMainFrame*)AfxGetMainWnd())->ShowTrayIcon(s.fTrayIcon);
+
+ ::SetPriorityClass(::GetCurrentProcess(), s.dwPriority);
+
+ GetDlgItem(IDC_FILE_POS)->EnableWindow(s.fKeepHistory);
+ GetDlgItem(IDC_DVD_POS)->EnableWindow(s.fKeepHistory);
+
+ return __super::OnApply();
}
void CPPagePlayer::OnUpdateCheck13(CCmdUI* pCmdUI)
{
- UpdateData();
+ UpdateData();
- pCmdUI->Enable(m_iTitleBarTextStyle == 1);
+ pCmdUI->Enable(m_iTitleBarTextStyle == 1);
}
void CPPagePlayer::OnUpdatePos(CCmdUI* pCmdUI)
{
- UpdateData();
+ UpdateData();
- pCmdUI->Enable(!!m_fKeepHistory);
+ pCmdUI->Enable(!!m_fKeepHistory);
}
diff --git a/src/mpc-hc/PPagePlayer.h b/src/mpc-hc/PPagePlayer.h
index 3d067b229..69b701edb 100644
--- a/src/mpc-hc/PPagePlayer.h
+++ b/src/mpc-hc/PPagePlayer.h
@@ -30,42 +30,42 @@
class CPPagePlayer : public CPPageBase
{
- DECLARE_DYNAMIC(CPPagePlayer)
+ DECLARE_DYNAMIC(CPPagePlayer)
public:
- CPPagePlayer();
- virtual ~CPPagePlayer();
+ CPPagePlayer();
+ virtual ~CPPagePlayer();
- int m_iAllowMultipleInst;
- int m_iTitleBarTextStyle;
- BOOL m_bTitleBarTextTitle;
- BOOL m_iAlwaysOnTop;
- BOOL m_fRememberWindowPos;
- BOOL m_fRememberWindowSize;
- BOOL m_fSavePnSZoom;
- BOOL m_fSnapToDesktopEdges;
- BOOL m_fUseIni;
- BOOL m_fTrayIcon;
- BOOL m_fKeepHistory;
- BOOL m_fHideCDROMsSubMenu;
- BOOL m_priority;
- BOOL m_fShowOSD;
- BOOL m_fLimitWindowProportions;
- BOOL m_fRememberDVDPos;
- BOOL m_fRememberFilePos;
+ int m_iAllowMultipleInst;
+ int m_iTitleBarTextStyle;
+ BOOL m_bTitleBarTextTitle;
+ BOOL m_iAlwaysOnTop;
+ BOOL m_fRememberWindowPos;
+ BOOL m_fRememberWindowSize;
+ BOOL m_fSavePnSZoom;
+ BOOL m_fSnapToDesktopEdges;
+ BOOL m_fUseIni;
+ BOOL m_fTrayIcon;
+ BOOL m_fKeepHistory;
+ BOOL m_fHideCDROMsSubMenu;
+ BOOL m_priority;
+ BOOL m_fShowOSD;
+ BOOL m_fLimitWindowProportions;
+ BOOL m_fRememberDVDPos;
+ BOOL m_fRememberFilePos;
- // Dialog Data
- enum { IDD = IDD_PPAGEPLAYER };
+ // Dialog Data
+ enum { IDD = IDD_PPAGEPLAYER };
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnUpdateTimeout(CCmdUI* pCmdUI);
- afx_msg void OnUpdateCheck13(CCmdUI* pCmdUI);
- afx_msg void OnUpdatePos(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateTimeout(CCmdUI* pCmdUI);
+ afx_msg void OnUpdateCheck13(CCmdUI* pCmdUI);
+ afx_msg void OnUpdatePos(CCmdUI* pCmdUI);
};
diff --git a/src/mpc-hc/PPageSheet.cpp b/src/mpc-hc/PPageSheet.cpp
index 38c3b6b08..571855353 100644
--- a/src/mpc-hc/PPageSheet.cpp
+++ b/src/mpc-hc/PPageSheet.cpp
@@ -31,46 +31,46 @@
IMPLEMENT_DYNAMIC(CPPageSheet, CTreePropSheet)
CPPageSheet::CPPageSheet(LPCTSTR pszCaption, IFilterGraph* pFG, CWnd* pParentWnd, UINT idPage)
- : CTreePropSheet(pszCaption, pParentWnd, 0)
- , m_audioswitcher(pFG)
- , m_bLockPage(false)
+ : CTreePropSheet(pszCaption, pParentWnd, 0)
+ , m_audioswitcher(pFG)
+ , m_bLockPage(false)
{
- SetTreeWidth(180);
- AddPage(&m_player);
- AddPage(&m_formats);
- AddPage(&m_acceltbl);
- AddPage(&m_logo);
- AddPage(&m_webserver);
- AddPage(&m_playback);
- AddPage(&m_dvd);
- AddPage(&m_output);
- AddPage(&m_fullscreen);
- AddPage(&m_sync);
- AddPage(&m_tuner);
- AddPage(&m_internalfilters);
- AddPage(&m_audioswitcher);
- AddPage(&m_externalfilters);
- AddPage(&m_subtitles);
- AddPage(&m_substyle);
- AddPage(&m_subMisc);
- AddPage(&m_tweaks);
- AddPage(&m_misc);
-
- EnableStackedTabs(FALSE);
-
- SetTreeViewMode(TRUE, TRUE, FALSE);
-
- if (!idPage) {
- idPage = AfxGetAppSettings().nLastUsedPage;
- }
- if (idPage) {
- for (int i = 0; i < GetPageCount(); i++) {
- if (GetPage(i)->m_pPSP->pszTemplate == MAKEINTRESOURCE(idPage)) {
- SetActivePage(i);
- break;
- }
- }
- }
+ SetTreeWidth(180);
+ AddPage(&m_player);
+ AddPage(&m_formats);
+ AddPage(&m_acceltbl);
+ AddPage(&m_logo);
+ AddPage(&m_webserver);
+ AddPage(&m_playback);
+ AddPage(&m_dvd);
+ AddPage(&m_output);
+ AddPage(&m_fullscreen);
+ AddPage(&m_sync);
+ AddPage(&m_tuner);
+ AddPage(&m_internalfilters);
+ AddPage(&m_audioswitcher);
+ AddPage(&m_externalfilters);
+ AddPage(&m_subtitles);
+ AddPage(&m_substyle);
+ AddPage(&m_subMisc);
+ AddPage(&m_tweaks);
+ AddPage(&m_misc);
+
+ EnableStackedTabs(FALSE);
+
+ SetTreeViewMode(TRUE, TRUE, FALSE);
+
+ if (!idPage) {
+ idPage = AfxGetAppSettings().nLastUsedPage;
+ }
+ if (idPage) {
+ for (int i = 0; i < GetPageCount(); i++) {
+ if (GetPage(i)->m_pPSP->pszTemplate == MAKEINTRESOURCE(idPage)) {
+ SetActivePage(i);
+ break;
+ }
+ }
+ }
}
CPPageSheet::~CPPageSheet()
@@ -79,33 +79,33 @@ CPPageSheet::~CPPageSheet()
CTreeCtrl* CPPageSheet::CreatePageTreeObject()
{
- return DNew CTreePropSheetTreeCtrl();
+ return DNew CTreePropSheetTreeCtrl();
}
BEGIN_MESSAGE_MAP(CPPageSheet, CTreePropSheet)
- ON_WM_CONTEXTMENU()
+ ON_WM_CONTEXTMENU()
END_MESSAGE_MAP()
BOOL CPPageSheet::OnInitDialog()
{
- BOOL bResult = __super::OnInitDialog();
+ BOOL bResult = __super::OnInitDialog();
- if (CTreeCtrl* pTree = GetPageTreeControl()) {
- for (HTREEITEM node = pTree->GetRootItem(); node; node = pTree->GetNextSiblingItem(node)) {
- pTree->Expand(node, TVE_EXPAND);
- }
- }
+ if (CTreeCtrl* pTree = GetPageTreeControl()) {
+ for (HTREEITEM node = pTree->GetRootItem(); node; node = pTree->GetNextSiblingItem(node)) {
+ pTree->Expand(node, TVE_EXPAND);
+ }
+ }
- if (m_bLockPage) {
- GetPageTreeControl()->EnableWindow (FALSE);
- }
+ if (m_bLockPage) {
+ GetPageTreeControl()->EnableWindow(FALSE);
+ }
- return bResult;
+ return bResult;
}
void CPPageSheet::OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/)
{
- // display your own context menu handler or do nothing
+ // display your own context menu handler or do nothing
}
// CTreePropSheetTreeCtrl
@@ -127,8 +127,8 @@ END_MESSAGE_MAP()
BOOL CTreePropSheetTreeCtrl::PreCreateWindow(CREATESTRUCT& cs)
{
- cs.dwExStyle |= WS_EX_CLIENTEDGE;
- // cs.style &= ~TVS_LINESATROOT;
+ cs.dwExStyle |= WS_EX_CLIENTEDGE;
+ // cs.style &= ~TVS_LINESATROOT;
- return __super::PreCreateWindow(cs);
+ return __super::PreCreateWindow(cs);
}
diff --git a/src/mpc-hc/PPageSheet.h b/src/mpc-hc/PPageSheet.h
index 77c5cf5f8..a83c48d2d 100644
--- a/src/mpc-hc/PPageSheet.h
+++ b/src/mpc-hc/PPageSheet.h
@@ -49,56 +49,56 @@
class CTreePropSheetTreeCtrl : public CTreeCtrl
{
- DECLARE_DYNAMIC(CTreePropSheetTreeCtrl)
+ DECLARE_DYNAMIC(CTreePropSheetTreeCtrl)
public:
- CTreePropSheetTreeCtrl();
- virtual ~CTreePropSheetTreeCtrl();
+ CTreePropSheetTreeCtrl();
+ virtual ~CTreePropSheetTreeCtrl();
protected:
- DECLARE_MESSAGE_MAP()
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
+ DECLARE_MESSAGE_MAP()
+ virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
};
// CPPageSheet
class CPPageSheet : public TreePropSheet::CTreePropSheet
{
- DECLARE_DYNAMIC(CPPageSheet)
+ DECLARE_DYNAMIC(CPPageSheet)
private:
- bool m_bLockPage;
+ bool m_bLockPage;
- CPPagePlayer m_player;
- CPPageFormats m_formats;
- CPPageAccelTbl m_acceltbl;
- CPPageLogo m_logo;
- CPPageWebServer m_webserver;
- CPPagePlayback m_playback;
- CPPageDVD m_dvd;
- CPPageOutput m_output;
- CPPageFullscreen m_fullscreen;
- CPPageSync m_sync;
- CPPageCapture m_tuner;
- CPPageInternalFilters m_internalfilters;
- CPPageAudioSwitcher m_audioswitcher;
- CPPageExternalFilters m_externalfilters;
- CPPageSubtitles m_subtitles;
- CPPageSubStyle m_substyle;
- CPPageSubMisc m_subMisc;
- CPPageTweaks m_tweaks;
- CPPageMisc m_misc;
+ CPPagePlayer m_player;
+ CPPageFormats m_formats;
+ CPPageAccelTbl m_acceltbl;
+ CPPageLogo m_logo;
+ CPPageWebServer m_webserver;
+ CPPagePlayback m_playback;
+ CPPageDVD m_dvd;
+ CPPageOutput m_output;
+ CPPageFullscreen m_fullscreen;
+ CPPageSync m_sync;
+ CPPageCapture m_tuner;
+ CPPageInternalFilters m_internalfilters;
+ CPPageAudioSwitcher m_audioswitcher;
+ CPPageExternalFilters m_externalfilters;
+ CPPageSubtitles m_subtitles;
+ CPPageSubStyle m_substyle;
+ CPPageSubMisc m_subMisc;
+ CPPageTweaks m_tweaks;
+ CPPageMisc m_misc;
- CTreeCtrl* CreatePageTreeObject();
+ CTreeCtrl* CreatePageTreeObject();
public:
- CPPageSheet(LPCTSTR pszCaption, IFilterGraph* pFG, CWnd* pParentWnd, UINT idPage = 0);
- virtual ~CPPageSheet();
- afx_msg void OnContextMenu(CWnd *pWnd, CPoint point);
+ CPPageSheet(LPCTSTR pszCaption, IFilterGraph* pFG, CWnd* pParentWnd, UINT idPage = 0);
+ virtual ~CPPageSheet();
+ afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
- void LockPage() {m_bLockPage = true;};
+ void LockPage() {m_bLockPage = true;};
protected:
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- virtual BOOL OnInitDialog();
+ virtual BOOL OnInitDialog();
};
diff --git a/src/mpc-hc/PPageSubMisc.cpp b/src/mpc-hc/PPageSubMisc.cpp
index 1c006a930..b839887ef 100644
--- a/src/mpc-hc/PPageSubMisc.cpp
+++ b/src/mpc-hc/PPageSubMisc.cpp
@@ -30,11 +30,11 @@
IMPLEMENT_DYNAMIC(CPPageSubMisc, CPPageBase)
CPPageSubMisc::CPPageSubMisc()
- : CPPageBase(CPPageSubMisc::IDD, CPPageSubMisc::IDD)
- , m_fPrioritizeExternalSubtitles(FALSE)
- , m_fDisableInternalSubtitles(FALSE)
- , m_szAutoloadPaths("")
- , m_ISDb(_T(""))
+ : CPPageBase(CPPageSubMisc::IDD, CPPageSubMisc::IDD)
+ , m_fPrioritizeExternalSubtitles(FALSE)
+ , m_fDisableInternalSubtitles(FALSE)
+ , m_szAutoloadPaths("")
+ , m_ISDb(_T(""))
{
}
@@ -45,98 +45,98 @@ CPPageSubMisc::~CPPageSubMisc()
void CPPageSubMisc::DoDataExchange(CDataExchange* pDX)
{
- CPPageBase::DoDataExchange(pDX);
- DDX_Check(pDX, IDC_CHECK1, m_fPrioritizeExternalSubtitles);
- DDX_Check(pDX, IDC_CHECK2, m_fDisableInternalSubtitles);
- DDX_Text(pDX, IDC_EDIT1, m_szAutoloadPaths);
- DDX_Control(pDX, IDC_COMBO1, m_ISDbCombo);
- DDX_CBString(pDX, IDC_COMBO1, m_ISDb);
+ CPPageBase::DoDataExchange(pDX);
+ DDX_Check(pDX, IDC_CHECK1, m_fPrioritizeExternalSubtitles);
+ DDX_Check(pDX, IDC_CHECK2, m_fDisableInternalSubtitles);
+ DDX_Text(pDX, IDC_EDIT1, m_szAutoloadPaths);
+ DDX_Control(pDX, IDC_COMBO1, m_ISDbCombo);
+ DDX_CBString(pDX, IDC_COMBO1, m_ISDb);
}
BOOL CPPageSubMisc::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- m_fPrioritizeExternalSubtitles = s.fPrioritizeExternalSubtitles;
- m_fDisableInternalSubtitles = s.fDisableInternalSubtitles;
- m_szAutoloadPaths = s.strSubtitlePaths;
+ m_fPrioritizeExternalSubtitles = s.fPrioritizeExternalSubtitles;
+ m_fDisableInternalSubtitles = s.fDisableInternalSubtitles;
+ m_szAutoloadPaths = s.strSubtitlePaths;
- m_ISDb = s.strISDb;
- m_ISDbCombo.AddString(m_ISDb);
- if (m_ISDb.CompareNoCase(_T("www.opensubtitles.org/isdb"))) {
- m_ISDbCombo.AddString(_T("www.opensubtitles.org/isdb"));
- }
+ m_ISDb = s.strISDb;
+ m_ISDbCombo.AddString(m_ISDb);
+ if (m_ISDb.CompareNoCase(_T("www.opensubtitles.org/isdb"))) {
+ m_ISDbCombo.AddString(_T("www.opensubtitles.org/isdb"));
+ }
- UpdateData(FALSE);
+ UpdateData(FALSE);
- return TRUE;
+ return TRUE;
}
BOOL CPPageSubMisc::OnApply()
{
- UpdateData();
+ UpdateData();
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- s.fPrioritizeExternalSubtitles = !!m_fPrioritizeExternalSubtitles;
- s.fDisableInternalSubtitles = !!m_fDisableInternalSubtitles;
- s.strSubtitlePaths = m_szAutoloadPaths;
+ s.fPrioritizeExternalSubtitles = !!m_fPrioritizeExternalSubtitles;
+ s.fDisableInternalSubtitles = !!m_fDisableInternalSubtitles;
+ s.strSubtitlePaths = m_szAutoloadPaths;
- s.strISDb = m_ISDb;
- s.strISDb.TrimRight('/');
+ s.strISDb = m_ISDb;
+ s.strISDb.TrimRight('/');
- return __super::OnApply();
+ return __super::OnApply();
}
BEGIN_MESSAGE_MAP(CPPageSubMisc, CPPageBase)
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
- ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON2, OnUpdateButton2)
- ON_CBN_EDITCHANGE(IDC_COMBO1, OnURLModified)
+ ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
+ ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON2, OnUpdateButton2)
+ ON_CBN_EDITCHANGE(IDC_COMBO1, OnURLModified)
END_MESSAGE_MAP()
void CPPageSubMisc::OnBnClickedButton1()
{
- m_szAutoloadPaths = DEFAULT_SUBTITLE_PATHS;
+ m_szAutoloadPaths = DEFAULT_SUBTITLE_PATHS;
- UpdateData(FALSE);
- SetModified();
+ UpdateData(FALSE);
+ SetModified();
}
void CPPageSubMisc::OnBnClickedButton2()
{
- CString ISDb, ver, str;
- UINT msg;
+ CString ISDb, ver, str;
+ UINT msg;
- m_ISDbCombo.GetWindowText(ISDb);
- ISDb.TrimRight('/');
+ m_ISDbCombo.GetWindowText(ISDb);
+ ISDb.TrimRight('/');
- ver.Format(_T("ISDb v%d"), ISDb_PROTOCOL_VERSION);
+ ver.Format(_T("ISDb v%d"), ISDb_PROTOCOL_VERSION);
- CWebTextFile wtf;
- UINT nIconType = MB_ICONEXCLAMATION;
+ CWebTextFile wtf;
+ UINT nIconType = MB_ICONEXCLAMATION;
- if (wtf.Open(_T("http://") + ISDb + _T("/test.php")) && wtf.ReadString(str) && str == ver) {
- msg = IDS_PPSDB_URLCORRECT;
- nIconType = MB_ICONINFORMATION;
- } else if (str.Find(_T("ISDb v")) == 0) {
- msg = IDS_PPSDB_PROTOCOLERR;
- } else {
- msg = IDS_PPSDB_BADURL;
- }
+ if (wtf.Open(_T("http://") + ISDb + _T("/test.php")) && wtf.ReadString(str) && str == ver) {
+ msg = IDS_PPSDB_URLCORRECT;
+ nIconType = MB_ICONINFORMATION;
+ } else if (str.Find(_T("ISDb v")) == 0) {
+ msg = IDS_PPSDB_PROTOCOLERR;
+ } else {
+ msg = IDS_PPSDB_BADURL;
+ }
- AfxMessageBox(msg, nIconType | MB_OK, 0);
+ AfxMessageBox(msg, nIconType | MB_OK, 0);
}
void CPPageSubMisc::OnUpdateButton2(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_ISDbCombo.GetWindowTextLength() > 0);
+ pCmdUI->Enable(m_ISDbCombo.GetWindowTextLength() > 0);
}
void CPPageSubMisc::OnURLModified()
{
- SetModified();
+ SetModified();
}
diff --git a/src/mpc-hc/PPageSubMisc.h b/src/mpc-hc/PPageSubMisc.h
index 53c3fb852..d6b150d57 100644
--- a/src/mpc-hc/PPageSubMisc.h
+++ b/src/mpc-hc/PPageSubMisc.h
@@ -29,29 +29,29 @@
class CPPageSubMisc : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageSubMisc)
+ DECLARE_DYNAMIC(CPPageSubMisc)
public:
- CPPageSubMisc();
- virtual ~CPPageSubMisc();
+ CPPageSubMisc();
+ virtual ~CPPageSubMisc();
- // Dialog Data
- enum { IDD = IDD_PPAGESUBMISC };
- BOOL m_fPrioritizeExternalSubtitles;
- BOOL m_fDisableInternalSubtitles;
- CString m_szAutoloadPaths;
- CComboBox m_ISDbCombo;
- CString m_ISDb;
+ // Dialog Data
+ enum { IDD = IDD_PPAGESUBMISC };
+ BOOL m_fPrioritizeExternalSubtitles;
+ BOOL m_fDisableInternalSubtitles;
+ CString m_szAutoloadPaths;
+ CComboBox m_ISDbCombo;
+ CString m_ISDb;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnBnClickedButton1();
- afx_msg void OnBnClickedButton2();
- afx_msg void OnUpdateButton2(CCmdUI* pCmdUI);
- afx_msg void OnURLModified();
+ afx_msg void OnBnClickedButton1();
+ afx_msg void OnBnClickedButton2();
+ afx_msg void OnUpdateButton2(CCmdUI* pCmdUI);
+ afx_msg void OnURLModified();
};
diff --git a/src/mpc-hc/PPageSubStyle.cpp b/src/mpc-hc/PPageSubStyle.cpp
index 893fb3d63..8697aa912 100644
--- a/src/mpc-hc/PPageSubStyle.cpp
+++ b/src/mpc-hc/PPageSubStyle.cpp
@@ -39,22 +39,22 @@
IMPLEMENT_DYNAMIC(CPPageSubStyle, CPPageBase)
CPPageSubStyle::CPPageSubStyle()
- : CPPageBase(CPPageSubStyle::IDD, CPPageSubStyle::IDD)
- , m_iCharset(0)
- , m_spacing(0)
- , m_angle(0)
- , m_scalex(0)
- , m_scaley(0)
- , m_borderstyle(0)
- , m_borderwidth(0)
- , m_shadowdepth(0)
- , m_screenalignment(0)
- , m_margin(0,0,0,0)
- , m_linkalphasliders(FALSE)
- , m_relativeTo(FALSE)
+ : CPPageBase(CPPageSubStyle::IDD, CPPageSubStyle::IDD)
+ , m_iCharset(0)
+ , m_spacing(0)
+ , m_angle(0)
+ , m_scalex(0)
+ , m_scaley(0)
+ , m_borderstyle(0)
+ , m_borderwidth(0)
+ , m_shadowdepth(0)
+ , m_screenalignment(0)
+ , m_margin(0, 0, 0, 0)
+ , m_linkalphasliders(FALSE)
+ , m_relativeTo(FALSE)
{
- m_stss = AfxGetAppSettings().subdefstyle;
- m_fUseDefaultStyle = true;
+ m_stss = AfxGetAppSettings().subdefstyle;
+ m_fUseDefaultStyle = true;
}
CPPageSubStyle::~CPPageSubStyle()
@@ -63,76 +63,76 @@ CPPageSubStyle::~CPPageSubStyle()
void CPPageSubStyle::InitStyle(CString title, STSStyle& stss)
{
- m_pPSP->pszTitle = (m_title = title);
- m_psp.dwFlags |= PSP_USETITLE;
+ m_pPSP->pszTitle = (m_title = title);
+ m_psp.dwFlags |= PSP_USETITLE;
- m_stss = stss;
- m_fUseDefaultStyle = false;
+ m_stss = stss;
+ m_fUseDefaultStyle = false;
}
void CPPageSubStyle::AskColor(int i)
{
- CColorDialog dlg(m_stss.colors[i]);
- dlg.m_cc.Flags |= CC_FULLOPEN;
- if (dlg.DoModal() == IDOK) {
- m_stss.colors[i] = dlg.m_cc.rgbResult;
- m_color[i].Invalidate();
- }
+ CColorDialog dlg(m_stss.colors[i]);
+ dlg.m_cc.Flags |= CC_FULLOPEN;
+ if (dlg.DoModal() == IDOK) {
+ m_stss.colors[i] = dlg.m_cc.rgbResult;
+ m_color[i].Invalidate();
+ }
}
void CPPageSubStyle::DoDataExchange(CDataExchange* pDX)
{
- CPPageBase::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_BUTTON1, m_font);
- DDX_CBIndex(pDX, IDC_COMBO1, m_iCharset);
- DDX_Control(pDX, IDC_COMBO1, m_charset);
- DDX_Text(pDX, IDC_EDIT3, m_spacing);
- DDX_Control(pDX, IDC_SPIN3, m_spacingspin);
- DDX_Text(pDX, IDC_EDIT4, m_angle);
- DDX_Control(pDX, IDC_SPIN10, m_anglespin);
- DDX_Text(pDX, IDC_EDIT5, m_scalex);
- DDX_Control(pDX, IDC_SPIN4, m_scalexspin);
- DDX_Text(pDX, IDC_EDIT6, m_scaley);
- DDX_Control(pDX, IDC_SPIN5, m_scaleyspin);
- DDX_Radio(pDX, IDC_RADIO1, m_borderstyle);
- DDX_Text(pDX, IDC_EDIT1, m_borderwidth);
- DDX_Control(pDX, IDC_SPIN1, m_borderwidthspin);
- DDX_Text(pDX, IDC_EDIT2, m_shadowdepth);
- DDX_Control(pDX, IDC_SPIN2, m_shadowdepthspin);
- DDX_Radio(pDX, IDC_RADIO3, m_screenalignment);
- DDX_Text(pDX, IDC_EDIT7, m_margin.left);
- DDX_Control(pDX, IDC_SPIN6, m_marginleftspin);
- DDX_Text(pDX, IDC_EDIT8, m_margin.right);
- DDX_Control(pDX, IDC_SPIN7, m_marginrightspin);
- DDX_Text(pDX, IDC_EDIT9, m_margin.top);
- DDX_Control(pDX, IDC_SPIN8, m_margintopspin);
- DDX_Text(pDX, IDC_EDIT10, m_margin.bottom);
- DDX_Control(pDX, IDC_SPIN9, m_marginbottomspin);
- DDX_Control(pDX, IDC_COLORPRI, m_color[0]);
- DDX_Control(pDX, IDC_COLORSEC, m_color[1]);
- DDX_Control(pDX, IDC_COLOROUTL, m_color[2]);
- DDX_Control(pDX, IDC_COLORSHAD, m_color[3]);
- DDX_Slider(pDX, IDC_SLIDER1, m_alpha[0]);
- DDX_Slider(pDX, IDC_SLIDER2, m_alpha[1]);
- DDX_Slider(pDX, IDC_SLIDER3, m_alpha[2]);
- DDX_Slider(pDX, IDC_SLIDER4, m_alpha[3]);
- DDX_Control(pDX, IDC_SLIDER1, m_alphasliders[0]);
- DDX_Control(pDX, IDC_SLIDER2, m_alphasliders[1]);
- DDX_Control(pDX, IDC_SLIDER3, m_alphasliders[2]);
- DDX_Control(pDX, IDC_SLIDER4, m_alphasliders[3]);
- DDX_Check(pDX, IDC_CHECK1, m_linkalphasliders);
- DDX_Check(pDX, IDC_CHECK_RELATIVETO, m_relativeTo);
+ CPPageBase::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_BUTTON1, m_font);
+ DDX_CBIndex(pDX, IDC_COMBO1, m_iCharset);
+ DDX_Control(pDX, IDC_COMBO1, m_charset);
+ DDX_Text(pDX, IDC_EDIT3, m_spacing);
+ DDX_Control(pDX, IDC_SPIN3, m_spacingspin);
+ DDX_Text(pDX, IDC_EDIT4, m_angle);
+ DDX_Control(pDX, IDC_SPIN10, m_anglespin);
+ DDX_Text(pDX, IDC_EDIT5, m_scalex);
+ DDX_Control(pDX, IDC_SPIN4, m_scalexspin);
+ DDX_Text(pDX, IDC_EDIT6, m_scaley);
+ DDX_Control(pDX, IDC_SPIN5, m_scaleyspin);
+ DDX_Radio(pDX, IDC_RADIO1, m_borderstyle);
+ DDX_Text(pDX, IDC_EDIT1, m_borderwidth);
+ DDX_Control(pDX, IDC_SPIN1, m_borderwidthspin);
+ DDX_Text(pDX, IDC_EDIT2, m_shadowdepth);
+ DDX_Control(pDX, IDC_SPIN2, m_shadowdepthspin);
+ DDX_Radio(pDX, IDC_RADIO3, m_screenalignment);
+ DDX_Text(pDX, IDC_EDIT7, m_margin.left);
+ DDX_Control(pDX, IDC_SPIN6, m_marginleftspin);
+ DDX_Text(pDX, IDC_EDIT8, m_margin.right);
+ DDX_Control(pDX, IDC_SPIN7, m_marginrightspin);
+ DDX_Text(pDX, IDC_EDIT9, m_margin.top);
+ DDX_Control(pDX, IDC_SPIN8, m_margintopspin);
+ DDX_Text(pDX, IDC_EDIT10, m_margin.bottom);
+ DDX_Control(pDX, IDC_SPIN9, m_marginbottomspin);
+ DDX_Control(pDX, IDC_COLORPRI, m_color[0]);
+ DDX_Control(pDX, IDC_COLORSEC, m_color[1]);
+ DDX_Control(pDX, IDC_COLOROUTL, m_color[2]);
+ DDX_Control(pDX, IDC_COLORSHAD, m_color[3]);
+ DDX_Slider(pDX, IDC_SLIDER1, m_alpha[0]);
+ DDX_Slider(pDX, IDC_SLIDER2, m_alpha[1]);
+ DDX_Slider(pDX, IDC_SLIDER3, m_alpha[2]);
+ DDX_Slider(pDX, IDC_SLIDER4, m_alpha[3]);
+ DDX_Control(pDX, IDC_SLIDER1, m_alphasliders[0]);
+ DDX_Control(pDX, IDC_SLIDER2, m_alphasliders[1]);
+ DDX_Control(pDX, IDC_SLIDER3, m_alphasliders[2]);
+ DDX_Control(pDX, IDC_SLIDER4, m_alphasliders[3]);
+ DDX_Check(pDX, IDC_CHECK1, m_linkalphasliders);
+ DDX_Check(pDX, IDC_CHECK_RELATIVETO, m_relativeTo);
}
BEGIN_MESSAGE_MAP(CPPageSubStyle, CPPageBase)
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
- ON_STN_CLICKED(IDC_COLORPRI, OnStnClickedColorpri)
- ON_STN_CLICKED(IDC_COLORSEC, OnStnClickedColorsec)
- ON_STN_CLICKED(IDC_COLOROUTL, OnStnClickedColoroutl)
- ON_STN_CLICKED(IDC_COLORSHAD, OnStnClickedColorshad)
- ON_BN_CLICKED(IDC_CHECK1, OnBnClickedCheck1)
- ON_WM_HSCROLL()
+ ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
+ ON_STN_CLICKED(IDC_COLORPRI, OnStnClickedColorpri)
+ ON_STN_CLICKED(IDC_COLORSEC, OnStnClickedColorsec)
+ ON_STN_CLICKED(IDC_COLOROUTL, OnStnClickedColoroutl)
+ ON_STN_CLICKED(IDC_COLORSHAD, OnStnClickedColorshad)
+ ON_BN_CLICKED(IDC_CHECK1, OnBnClickedCheck1)
+ ON_WM_HSCROLL()
END_MESSAGE_MAP()
@@ -140,174 +140,174 @@ END_MESSAGE_MAP()
BOOL CPPageSubStyle::OnInitDialog()
{
- __super::OnInitDialog();
-
- SetHandCursor(m_hWnd, IDC_COMBO1);
-
- m_font.SetWindowText(m_stss.fontName);
- m_iCharset = -1;
- for (int i = 0; i < CharSetLen; i++) {
- CString str;
- str.Format(_T("%s (%d)"), CharSetNames[i], CharSetList[i]);
- m_charset.AddString(str);
- m_charset.SetItemData(i, CharSetList[i]);
- if (m_stss.charSet == CharSetList[i]) {
- m_iCharset = i;
- }
- }
-
- // TODO: allow floats in these edit boxes
- m_spacing = (int)m_stss.fontSpacing;
- m_spacingspin.SetRange32(-10000, 10000);
- while (m_stss.fontAngleZ < 0) {
- m_stss.fontAngleZ += 360;
- }
- m_angle = (int)fmod(m_stss.fontAngleZ, 360);
- m_anglespin.SetRange32(0, 359);
- m_scalex = (int)m_stss.fontScaleX;
- m_scalexspin.SetRange32(-10000, 10000);
- m_scaley = (int)m_stss.fontScaleY;
- m_scaleyspin.SetRange32(-10000, 10000);
-
- m_borderstyle = m_stss.borderStyle;
- m_borderwidth = (int)min(m_stss.outlineWidthX, m_stss.outlineWidthY);
- m_borderwidthspin.SetRange32(0, 10000);
- m_shadowdepth = (int)min(m_stss.shadowDepthX, m_stss.shadowDepthY);
- m_shadowdepthspin.SetRange32(0, 10000);
-
- m_screenalignment = m_stss.scrAlignment-1;
- m_margin = m_stss.marginRect;
- m_marginleftspin.SetRange32(-10000, 10000);
- m_marginrightspin.SetRange32(-10000, 10000);
- m_margintopspin.SetRange32(-10000, 10000);
- m_marginbottomspin.SetRange32(-10000, 10000);
- m_relativeTo = m_stss.relativeTo;
-
- for (int i = 0; i < 4; i++) {
- m_color[i].SetColorPtr(&m_stss.colors[i]);
- m_alpha[i] = 255-m_stss.alpha[i];
- m_alphasliders[i].SetRange(0, 255);
- }
-
- m_linkalphasliders = FALSE;
-
- UpdateData(FALSE);
-
- CreateToolTip();
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ SetHandCursor(m_hWnd, IDC_COMBO1);
+
+ m_font.SetWindowText(m_stss.fontName);
+ m_iCharset = -1;
+ for (int i = 0; i < CharSetLen; i++) {
+ CString str;
+ str.Format(_T("%s (%d)"), CharSetNames[i], CharSetList[i]);
+ m_charset.AddString(str);
+ m_charset.SetItemData(i, CharSetList[i]);
+ if (m_stss.charSet == CharSetList[i]) {
+ m_iCharset = i;
+ }
+ }
+
+ // TODO: allow floats in these edit boxes
+ m_spacing = (int)m_stss.fontSpacing;
+ m_spacingspin.SetRange32(-10000, 10000);
+ while (m_stss.fontAngleZ < 0) {
+ m_stss.fontAngleZ += 360;
+ }
+ m_angle = (int)fmod(m_stss.fontAngleZ, 360);
+ m_anglespin.SetRange32(0, 359);
+ m_scalex = (int)m_stss.fontScaleX;
+ m_scalexspin.SetRange32(-10000, 10000);
+ m_scaley = (int)m_stss.fontScaleY;
+ m_scaleyspin.SetRange32(-10000, 10000);
+
+ m_borderstyle = m_stss.borderStyle;
+ m_borderwidth = (int)min(m_stss.outlineWidthX, m_stss.outlineWidthY);
+ m_borderwidthspin.SetRange32(0, 10000);
+ m_shadowdepth = (int)min(m_stss.shadowDepthX, m_stss.shadowDepthY);
+ m_shadowdepthspin.SetRange32(0, 10000);
+
+ m_screenalignment = m_stss.scrAlignment - 1;
+ m_margin = m_stss.marginRect;
+ m_marginleftspin.SetRange32(-10000, 10000);
+ m_marginrightspin.SetRange32(-10000, 10000);
+ m_margintopspin.SetRange32(-10000, 10000);
+ m_marginbottomspin.SetRange32(-10000, 10000);
+ m_relativeTo = m_stss.relativeTo;
+
+ for (int i = 0; i < 4; i++) {
+ m_color[i].SetColorPtr(&m_stss.colors[i]);
+ m_alpha[i] = 255 - m_stss.alpha[i];
+ m_alphasliders[i].SetRange(0, 255);
+ }
+
+ m_linkalphasliders = FALSE;
+
+ UpdateData(FALSE);
+
+ CreateToolTip();
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageSubStyle::OnApply()
{
- UpdateData();
-
- if (m_iCharset >= 0) {
- m_stss.charSet = (int)m_charset.GetItemData(m_iCharset);
- }
- m_stss.fontSpacing = m_spacing;
- m_stss.fontAngleZ = m_angle;
- m_stss.fontScaleX = m_scalex;
- m_stss.fontScaleY = m_scaley;
-
- m_stss.borderStyle = m_borderstyle;
- m_stss.outlineWidthX = m_stss.outlineWidthY = m_borderwidth;
- m_stss.shadowDepthX = m_stss.shadowDepthY = m_shadowdepth;
-
- m_stss.scrAlignment = m_screenalignment+1;
- m_stss.marginRect = m_margin;
- m_stss.relativeTo = m_relativeTo;
-
- for (int i = 0; i < 4; i++) {
- m_stss.alpha[i] = 255-m_alpha[i];
- }
-
- if (m_fUseDefaultStyle) {
- STSStyle& stss = AfxGetAppSettings().subdefstyle;
- if (!(stss == m_stss)) {
- stss = m_stss;
- if (CMainFrame* pFrame = dynamic_cast<CMainFrame*>(AfxGetMainWnd())) {
- pFrame->UpdateSubtitle(false, true);
- }
- }
- }
-
- return __super::OnApply();
+ UpdateData();
+
+ if (m_iCharset >= 0) {
+ m_stss.charSet = (int)m_charset.GetItemData(m_iCharset);
+ }
+ m_stss.fontSpacing = m_spacing;
+ m_stss.fontAngleZ = m_angle;
+ m_stss.fontScaleX = m_scalex;
+ m_stss.fontScaleY = m_scaley;
+
+ m_stss.borderStyle = m_borderstyle;
+ m_stss.outlineWidthX = m_stss.outlineWidthY = m_borderwidth;
+ m_stss.shadowDepthX = m_stss.shadowDepthY = m_shadowdepth;
+
+ m_stss.scrAlignment = m_screenalignment + 1;
+ m_stss.marginRect = m_margin;
+ m_stss.relativeTo = m_relativeTo;
+
+ for (int i = 0; i < 4; i++) {
+ m_stss.alpha[i] = 255 - m_alpha[i];
+ }
+
+ if (m_fUseDefaultStyle) {
+ STSStyle& stss = AfxGetAppSettings().subdefstyle;
+ if (!(stss == m_stss)) {
+ stss = m_stss;
+ if (CMainFrame* pFrame = dynamic_cast<CMainFrame*>(AfxGetMainWnd())) {
+ pFrame->UpdateSubtitle(false, true);
+ }
+ }
+ }
+
+ return __super::OnApply();
}
void CPPageSubStyle::OnBnClickedButton1()
{
- LOGFONT lf;
- lf <<= m_stss;
-
- CFontDialog dlg(&lf, CF_SCREENFONTS|CF_INITTOLOGFONTSTRUCT|CF_FORCEFONTEXIST|CF_SCALABLEONLY|CF_EFFECTS);
- if (dlg.DoModal() == IDOK) {
- CString str(lf.lfFaceName);
- if (str.GetLength() > 16) {
- str = str.Left(14) + _T("...");
- }
- m_font.SetWindowText(str);
-
- for (int i = 0, j = m_charset.GetCount(); i < j; i++) {
- if (m_charset.GetItemData(i) == lf.lfCharSet) {
- m_charset.SetCurSel(i);
- break;
- }
- }
-
- m_stss = lf;
-
- SetModified();
- }
+ LOGFONT lf;
+ lf <<= m_stss;
+
+ CFontDialog dlg(&lf, CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT | CF_FORCEFONTEXIST | CF_SCALABLEONLY | CF_EFFECTS);
+ if (dlg.DoModal() == IDOK) {
+ CString str(lf.lfFaceName);
+ if (str.GetLength() > 16) {
+ str = str.Left(14) + _T("...");
+ }
+ m_font.SetWindowText(str);
+
+ for (int i = 0, j = m_charset.GetCount(); i < j; i++) {
+ if (m_charset.GetItemData(i) == lf.lfCharSet) {
+ m_charset.SetCurSel(i);
+ break;
+ }
+ }
+
+ m_stss = lf;
+
+ SetModified();
+ }
}
void CPPageSubStyle::OnStnClickedColorpri()
{
- AskColor(0);
+ AskColor(0);
}
void CPPageSubStyle::OnStnClickedColorsec()
{
- AskColor(1);
+ AskColor(1);
}
void CPPageSubStyle::OnStnClickedColoroutl()
{
- AskColor(2);
+ AskColor(2);
}
void CPPageSubStyle::OnStnClickedColorshad()
{
- AskColor(3);
+ AskColor(3);
}
void CPPageSubStyle::OnBnClickedCheck1()
{
- UpdateData();
-
- int avg = 0;
- for (int i = 0; i < 4; i++) {
- avg += m_alphasliders[i].GetPos();
- }
- avg /= 4;
- for (int i = 0; i < 4; i++) {
- m_alphasliders[i].SetPos(avg);
- }
-
- SetModified();
+ UpdateData();
+
+ int avg = 0;
+ for (int i = 0; i < 4; i++) {
+ avg += m_alphasliders[i].GetPos();
+ }
+ avg /= 4;
+ for (int i = 0; i < 4; i++) {
+ m_alphasliders[i].SetPos(avg);
+ }
+
+ SetModified();
}
void CPPageSubStyle::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
- if (m_linkalphasliders && pScrollBar) {
- int pos = ((CSliderCtrl*)pScrollBar)->GetPos();
- for (int i = 0; i < 4; i++) {
- m_alphasliders[i].SetPos(pos);
- }
- }
+ if (m_linkalphasliders && pScrollBar) {
+ int pos = ((CSliderCtrl*)pScrollBar)->GetPos();
+ for (int i = 0; i < 4; i++) {
+ m_alphasliders[i].SetPos(pos);
+ }
+ }
- SetModified();
+ SetModified();
- __super::OnHScroll(nSBCode, nPos, pScrollBar);
+ __super::OnHScroll(nSBCode, nPos, pScrollBar);
}
diff --git a/src/mpc-hc/PPageSubStyle.h b/src/mpc-hc/PPageSubStyle.h
index bcb2f3aa6..3961e02fc 100644
--- a/src/mpc-hc/PPageSubStyle.h
+++ b/src/mpc-hc/PPageSubStyle.h
@@ -29,92 +29,92 @@
class CColorStatic : public CStatic
{
- // DECLARE_DYNAMIC(CColorStatic)
+ // DECLARE_DYNAMIC(CColorStatic)
- COLORREF* m_pColor;
+ COLORREF* m_pColor;
public:
- CColorStatic(CWnd* pParent = NULL) : m_pColor(NULL) {}
- virtual ~CColorStatic() {}
+ CColorStatic(CWnd* pParent = NULL) : m_pColor(NULL) {}
+ virtual ~CColorStatic() {}
- void SetColorPtr(COLORREF* pColor) {
- m_pColor = pColor;
- }
+ void SetColorPtr(COLORREF* pColor) {
+ m_pColor = pColor;
+ }
- // DECLARE_MESSAGE_MAP()
+ // DECLARE_MESSAGE_MAP()
protected:
- virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) {
- CRect r;
- GetClientRect(r);
- CDC::FromHandle(lpDrawItemStruct->hDC)->FillSolidRect(r, m_pColor ? *m_pColor : ::GetSysColor(COLOR_BTNFACE));
- }
+ virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) {
+ CRect r;
+ GetClientRect(r);
+ CDC::FromHandle(lpDrawItemStruct->hDC)->FillSolidRect(r, m_pColor ? *m_pColor : ::GetSysColor(COLOR_BTNFACE));
+ }
};
// CPPageSubStyle dialog
class CPPageSubStyle : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageSubStyle)
+ DECLARE_DYNAMIC(CPPageSubStyle)
private:
- CString m_title;
- STSStyle m_stss;
- bool m_fUseDefaultStyle;
+ CString m_title;
+ STSStyle m_stss;
+ bool m_fUseDefaultStyle;
- void AskColor(int i);
+ void AskColor(int i);
public:
- CPPageSubStyle();
- virtual ~CPPageSubStyle();
-
- void InitStyle(CString title, STSStyle& stss);
- void GetStyle(STSStyle& stss) {
- stss = m_stss;
- }
-
- // Dialog Data
- enum { IDD = IDD_PPAGESUBSTYLE };
- CButton m_font;
- int m_iCharset;
- CComboBox m_charset;
- int m_spacing;
- CSpinButtonCtrl m_spacingspin;
- int m_angle;
- CSpinButtonCtrl m_anglespin;
- int m_scalex;
- CSpinButtonCtrl m_scalexspin;
- int m_scaley;
- CSpinButtonCtrl m_scaleyspin;
- int m_borderstyle;
- int m_borderwidth;
- CSpinButtonCtrl m_borderwidthspin;
- int m_shadowdepth;
- CSpinButtonCtrl m_shadowdepthspin;
- int m_screenalignment;
- CRect m_margin;
- CSpinButtonCtrl m_marginleftspin;
- CSpinButtonCtrl m_marginrightspin;
- CSpinButtonCtrl m_margintopspin;
- CSpinButtonCtrl m_marginbottomspin;
- CColorStatic m_color[4];
- int m_alpha[4];
- CSliderCtrl m_alphasliders[4];
- BOOL m_linkalphasliders;
- BOOL m_relativeTo;
+ CPPageSubStyle();
+ virtual ~CPPageSubStyle();
+
+ void InitStyle(CString title, STSStyle& stss);
+ void GetStyle(STSStyle& stss) {
+ stss = m_stss;
+ }
+
+ // Dialog Data
+ enum { IDD = IDD_PPAGESUBSTYLE };
+ CButton m_font;
+ int m_iCharset;
+ CComboBox m_charset;
+ int m_spacing;
+ CSpinButtonCtrl m_spacingspin;
+ int m_angle;
+ CSpinButtonCtrl m_anglespin;
+ int m_scalex;
+ CSpinButtonCtrl m_scalexspin;
+ int m_scaley;
+ CSpinButtonCtrl m_scaleyspin;
+ int m_borderstyle;
+ int m_borderwidth;
+ CSpinButtonCtrl m_borderwidthspin;
+ int m_shadowdepth;
+ CSpinButtonCtrl m_shadowdepthspin;
+ int m_screenalignment;
+ CRect m_margin;
+ CSpinButtonCtrl m_marginleftspin;
+ CSpinButtonCtrl m_marginrightspin;
+ CSpinButtonCtrl m_margintopspin;
+ CSpinButtonCtrl m_marginbottomspin;
+ CColorStatic m_color[4];
+ int m_alpha[4];
+ CSliderCtrl m_alphasliders[4];
+ BOOL m_linkalphasliders;
+ BOOL m_relativeTo;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
-
- DECLARE_MESSAGE_MAP()
- afx_msg void OnBnClickedButton1();
- afx_msg void OnStnClickedColorpri();
- afx_msg void OnStnClickedColorsec();
- afx_msg void OnStnClickedColoroutl();
- afx_msg void OnStnClickedColorshad();
- afx_msg void OnBnClickedCheck1();
- afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
+
+ DECLARE_MESSAGE_MAP()
+ afx_msg void OnBnClickedButton1();
+ afx_msg void OnStnClickedColorpri();
+ afx_msg void OnStnClickedColorsec();
+ afx_msg void OnStnClickedColoroutl();
+ afx_msg void OnStnClickedColorshad();
+ afx_msg void OnBnClickedCheck1();
+ afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
public:
};
diff --git a/src/mpc-hc/PPageSubtitles.cpp b/src/mpc-hc/PPageSubtitles.cpp
index 119b004d2..6bb523bb0 100644
--- a/src/mpc-hc/PPageSubtitles.cpp
+++ b/src/mpc-hc/PPageSubtitles.cpp
@@ -31,14 +31,14 @@
IMPLEMENT_DYNAMIC(CPPageSubtitles, CPPageBase)
CPPageSubtitles::CPPageSubtitles()
- : CPPageBase(CPPageSubtitles::IDD, CPPageSubtitles::IDD)
- , m_fOverridePlacement(FALSE)
- , m_nHorPos(0)
- , m_nVerPos(0)
- , m_nSPCSize(0)
- , m_fSPCPow2Tex(FALSE)
- , m_fSPCAllowAnimationWhenBuffering(TRUE)
- , m_nSubDelayInterval(0)
+ : CPPageBase(CPPageSubtitles::IDD, CPPageSubtitles::IDD)
+ , m_fOverridePlacement(FALSE)
+ , m_nHorPos(0)
+ , m_nVerPos(0)
+ , m_nSPCSize(0)
+ , m_fSPCPow2Tex(FALSE)
+ , m_fSPCAllowAnimationWhenBuffering(TRUE)
+ , m_nSubDelayInterval(0)
{
}
@@ -48,33 +48,33 @@ CPPageSubtitles::~CPPageSubtitles()
void CPPageSubtitles::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Check(pDX, IDC_CHECK3, m_fOverridePlacement);
- DDX_Text(pDX, IDC_EDIT2, m_nHorPos);
- DDX_Control(pDX, IDC_SPIN2, m_nHorPosCtrl);
- DDX_Text(pDX, IDC_EDIT3, m_nVerPos);
- DDX_Control(pDX, IDC_SPIN3, m_nVerPosCtrl);
- DDX_Text(pDX, IDC_EDIT1, m_nSPCSize);
- DDX_Control(pDX, IDC_SPIN1, m_nSPCSizeCtrl);
- DDX_Control(pDX, IDC_COMBO1, m_spmaxres);
- DDX_Control(pDX, IDC_EDIT2, m_nHorPosEdit);
- DDX_Control(pDX, IDC_EDIT3, m_nVerPosEdit);
- DDX_Check(pDX, IDC_CHECK_SPCPOW2TEX, m_fSPCPow2Tex);
- DDX_Check(pDX, IDC_CHECK_SPCANIMWITHBUFFER, m_fSPCAllowAnimationWhenBuffering);
- DDX_Text(pDX, IDC_EDIT4, m_nSubDelayInterval);
+ __super::DoDataExchange(pDX);
+ DDX_Check(pDX, IDC_CHECK3, m_fOverridePlacement);
+ DDX_Text(pDX, IDC_EDIT2, m_nHorPos);
+ DDX_Control(pDX, IDC_SPIN2, m_nHorPosCtrl);
+ DDX_Text(pDX, IDC_EDIT3, m_nVerPos);
+ DDX_Control(pDX, IDC_SPIN3, m_nVerPosCtrl);
+ DDX_Text(pDX, IDC_EDIT1, m_nSPCSize);
+ DDX_Control(pDX, IDC_SPIN1, m_nSPCSizeCtrl);
+ DDX_Control(pDX, IDC_COMBO1, m_spmaxres);
+ DDX_Control(pDX, IDC_EDIT2, m_nHorPosEdit);
+ DDX_Control(pDX, IDC_EDIT3, m_nVerPosEdit);
+ DDX_Check(pDX, IDC_CHECK_SPCPOW2TEX, m_fSPCPow2Tex);
+ DDX_Check(pDX, IDC_CHECK_SPCANIMWITHBUFFER, m_fSPCAllowAnimationWhenBuffering);
+ DDX_Text(pDX, IDC_EDIT4, m_nSubDelayInterval);
}
BEGIN_MESSAGE_MAP(CPPageSubtitles, CPPageBase)
- ON_UPDATE_COMMAND_UI(IDC_EDIT2, OnUpdatePosOverride)
- ON_UPDATE_COMMAND_UI(IDC_SPIN2, OnUpdatePosOverride)
- ON_UPDATE_COMMAND_UI(IDC_EDIT3, OnUpdatePosOverride)
- ON_UPDATE_COMMAND_UI(IDC_SPIN3, OnUpdatePosOverride)
- ON_UPDATE_COMMAND_UI(IDC_STATIC1, OnUpdatePosOverride)
- ON_UPDATE_COMMAND_UI(IDC_STATIC2, OnUpdatePosOverride)
- ON_UPDATE_COMMAND_UI(IDC_STATIC3, OnUpdatePosOverride)
- ON_UPDATE_COMMAND_UI(IDC_STATIC4, OnUpdatePosOverride)
- ON_EN_CHANGE(IDC_EDIT4, OnSubDelayInterval)
+ ON_UPDATE_COMMAND_UI(IDC_EDIT2, OnUpdatePosOverride)
+ ON_UPDATE_COMMAND_UI(IDC_SPIN2, OnUpdatePosOverride)
+ ON_UPDATE_COMMAND_UI(IDC_EDIT3, OnUpdatePosOverride)
+ ON_UPDATE_COMMAND_UI(IDC_SPIN3, OnUpdatePosOverride)
+ ON_UPDATE_COMMAND_UI(IDC_STATIC1, OnUpdatePosOverride)
+ ON_UPDATE_COMMAND_UI(IDC_STATIC2, OnUpdatePosOverride)
+ ON_UPDATE_COMMAND_UI(IDC_STATIC3, OnUpdatePosOverride)
+ ON_UPDATE_COMMAND_UI(IDC_STATIC4, OnUpdatePosOverride)
+ ON_EN_CHANGE(IDC_EDIT4, OnSubDelayInterval)
END_MESSAGE_MAP()
@@ -82,125 +82,125 @@ END_MESSAGE_MAP()
int TranslateResIn(int _In)
{
- switch (_In) {
- case 0:
- return 0;
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- return _In + 4;
- case 6:
- case 7:
- case 8:
- case 9:
- return _In - 5;
- }
- return _In;
+ switch (_In) {
+ case 0:
+ return 0;
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ return _In + 4;
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ return _In - 5;
+ }
+ return _In;
}
int TranslateResOut(int _In)
{
- switch (_In) {
- case 0:
- return 0;
- case 1:
- case 2:
- case 3:
- case 4:
- return _In + 5;
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- return _In - 4;
- }
- return _In;
+ switch (_In) {
+ case 0:
+ return 0;
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ return _In + 5;
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ return _In - 4;
+ }
+ return _In;
}
BOOL CPPageSubtitles::OnInitDialog()
{
- __super::OnInitDialog();
-
- SetHandCursor(m_hWnd, IDC_COMBO1);
-
- AppSettings& s = AfxGetAppSettings();
-
- m_fOverridePlacement = s.fOverridePlacement;
- m_nHorPos = s.nHorPos;
- m_nHorPosCtrl.SetRange(-10,110);
- m_nVerPos = s.nVerPos;
- m_nVerPosCtrl.SetRange(110,-10);
- m_nSPCSize = s.m_RenderersSettings.nSPCSize;
- m_nSPCSizeCtrl.SetRange(0, 60);
- m_spmaxres.AddString(_T("Desktop"));
- m_spmaxres.AddString(_T("2560x1600"));
- m_spmaxres.AddString(_T("1920x1080"));
- m_spmaxres.AddString(_T("1320x900"));
- m_spmaxres.AddString(_T("1280x720"));
- m_spmaxres.AddString(_T("1024x768"));
- m_spmaxres.AddString(_T("800x600"));
- m_spmaxres.AddString(_T("640x480"));
- m_spmaxres.AddString(_T("512x384"));
- m_spmaxres.AddString(_T("384x288"));
- m_spmaxres.SetCurSel(TranslateResIn(s.m_RenderersSettings.nSPCMaxRes));
- m_fSPCPow2Tex = s.m_RenderersSettings.fSPCPow2Tex;
- m_fSPCAllowAnimationWhenBuffering = s.m_RenderersSettings.fSPCAllowAnimationWhenBuffering;
- m_nSubDelayInterval = s.nSubDelayInterval;
-
- UpdateData(FALSE);
-
- CreateToolTip();
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ SetHandCursor(m_hWnd, IDC_COMBO1);
+
+ AppSettings& s = AfxGetAppSettings();
+
+ m_fOverridePlacement = s.fOverridePlacement;
+ m_nHorPos = s.nHorPos;
+ m_nHorPosCtrl.SetRange(-10, 110);
+ m_nVerPos = s.nVerPos;
+ m_nVerPosCtrl.SetRange(110, -10);
+ m_nSPCSize = s.m_RenderersSettings.nSPCSize;
+ m_nSPCSizeCtrl.SetRange(0, 60);
+ m_spmaxres.AddString(_T("Desktop"));
+ m_spmaxres.AddString(_T("2560x1600"));
+ m_spmaxres.AddString(_T("1920x1080"));
+ m_spmaxres.AddString(_T("1320x900"));
+ m_spmaxres.AddString(_T("1280x720"));
+ m_spmaxres.AddString(_T("1024x768"));
+ m_spmaxres.AddString(_T("800x600"));
+ m_spmaxres.AddString(_T("640x480"));
+ m_spmaxres.AddString(_T("512x384"));
+ m_spmaxres.AddString(_T("384x288"));
+ m_spmaxres.SetCurSel(TranslateResIn(s.m_RenderersSettings.nSPCMaxRes));
+ m_fSPCPow2Tex = s.m_RenderersSettings.fSPCPow2Tex;
+ m_fSPCAllowAnimationWhenBuffering = s.m_RenderersSettings.fSPCAllowAnimationWhenBuffering;
+ m_nSubDelayInterval = s.nSubDelayInterval;
+
+ UpdateData(FALSE);
+
+ CreateToolTip();
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageSubtitles::OnApply()
{
- UpdateData();
-
- AppSettings& s = AfxGetAppSettings();
-
- if (s.fOverridePlacement != !!m_fOverridePlacement
- || s.nHorPos != m_nHorPos
- || s.nVerPos != m_nVerPos
- || s.m_RenderersSettings.nSPCSize != m_nSPCSize
- || s.nSubDelayInterval != m_nSubDelayInterval
- || s.m_RenderersSettings.nSPCMaxRes != TranslateResOut(m_spmaxres.GetCurSel())
- || s.m_RenderersSettings.fSPCPow2Tex != !!m_fSPCPow2Tex
- || s.m_RenderersSettings.fSPCAllowAnimationWhenBuffering != !!m_fSPCAllowAnimationWhenBuffering) {
- s.fOverridePlacement = !!m_fOverridePlacement;
- s.nHorPos = m_nHorPos;
- s.nVerPos = m_nVerPos;
- s.m_RenderersSettings.nSPCSize = m_nSPCSize;
- s.nSubDelayInterval = m_nSubDelayInterval;
- s.m_RenderersSettings.nSPCMaxRes = TranslateResOut(m_spmaxres.GetCurSel());
- s.m_RenderersSettings.fSPCPow2Tex = !!m_fSPCPow2Tex;
- s.m_RenderersSettings.fSPCAllowAnimationWhenBuffering = !!m_fSPCAllowAnimationWhenBuffering;
-
- if (CMainFrame* pFrame = (CMainFrame*)GetParentFrame()) {
- pFrame->UpdateSubtitle(true);
- }
- }
-
- return __super::OnApply();
+ UpdateData();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ if (s.fOverridePlacement != !!m_fOverridePlacement
+ || s.nHorPos != m_nHorPos
+ || s.nVerPos != m_nVerPos
+ || s.m_RenderersSettings.nSPCSize != m_nSPCSize
+ || s.nSubDelayInterval != m_nSubDelayInterval
+ || s.m_RenderersSettings.nSPCMaxRes != TranslateResOut(m_spmaxres.GetCurSel())
+ || s.m_RenderersSettings.fSPCPow2Tex != !!m_fSPCPow2Tex
+ || s.m_RenderersSettings.fSPCAllowAnimationWhenBuffering != !!m_fSPCAllowAnimationWhenBuffering) {
+ s.fOverridePlacement = !!m_fOverridePlacement;
+ s.nHorPos = m_nHorPos;
+ s.nVerPos = m_nVerPos;
+ s.m_RenderersSettings.nSPCSize = m_nSPCSize;
+ s.nSubDelayInterval = m_nSubDelayInterval;
+ s.m_RenderersSettings.nSPCMaxRes = TranslateResOut(m_spmaxres.GetCurSel());
+ s.m_RenderersSettings.fSPCPow2Tex = !!m_fSPCPow2Tex;
+ s.m_RenderersSettings.fSPCAllowAnimationWhenBuffering = !!m_fSPCAllowAnimationWhenBuffering;
+
+ if (CMainFrame* pFrame = (CMainFrame*)GetParentFrame()) {
+ pFrame->UpdateSubtitle(true);
+ }
+ }
+
+ return __super::OnApply();
}
void CPPageSubtitles::OnUpdatePosOverride(CCmdUI* pCmdUI)
{
- UpdateData();
- pCmdUI->Enable(m_fOverridePlacement);
+ UpdateData();
+ pCmdUI->Enable(m_fOverridePlacement);
}
void CPPageSubtitles::OnSubDelayInterval()
{
- // If incorrect number, revert modifications
- if (!UpdateData()) {
- UpdateData(FALSE);
- }
+ // If incorrect number, revert modifications
+ if (!UpdateData()) {
+ UpdateData(FALSE);
+ }
- SetModified();
+ SetModified();
}
diff --git a/src/mpc-hc/PPageSubtitles.h b/src/mpc-hc/PPageSubtitles.h
index 5735eae60..50b2d1192 100644
--- a/src/mpc-hc/PPageSubtitles.h
+++ b/src/mpc-hc/PPageSubtitles.h
@@ -30,38 +30,38 @@
class CPPageSubtitles : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageSubtitles)
+ DECLARE_DYNAMIC(CPPageSubtitles)
public:
- CPPageSubtitles();
- virtual ~CPPageSubtitles();
+ CPPageSubtitles();
+ virtual ~CPPageSubtitles();
- BOOL m_fOverridePlacement;
- int m_nHorPos;
- CEdit m_nHorPosEdit;
- CSpinButtonCtrl m_nHorPosCtrl;
- int m_nVerPos;
- CEdit m_nVerPosEdit;
- CSpinButtonCtrl m_nVerPosCtrl;
- int m_nSPCSize;
- CSpinButtonCtrl m_nSPCSizeCtrl;
- CComboBox m_spmaxres;
- BOOL m_fSPCPow2Tex;
- BOOL m_fSPCAllowAnimationWhenBuffering;
- int m_nSubDelayInterval;
+ BOOL m_fOverridePlacement;
+ int m_nHorPos;
+ CEdit m_nHorPosEdit;
+ CSpinButtonCtrl m_nHorPosCtrl;
+ int m_nVerPos;
+ CEdit m_nVerPosEdit;
+ CSpinButtonCtrl m_nVerPosCtrl;
+ int m_nSPCSize;
+ CSpinButtonCtrl m_nSPCSizeCtrl;
+ CComboBox m_spmaxres;
+ BOOL m_fSPCPow2Tex;
+ BOOL m_fSPCAllowAnimationWhenBuffering;
+ int m_nSubDelayInterval;
- // Dialog Data
- enum { IDD = IDD_PPAGESUBTITLES };
+ // Dialog Data
+ enum { IDD = IDD_PPAGESUBTITLES };
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
- void OnSubDelayInterval();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
+ void OnSubDelayInterval();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnBnClickedButton1();
- afx_msg void OnUpdatePosOverride(CCmdUI* pCmdUI);
+ afx_msg void OnBnClickedButton1();
+ afx_msg void OnUpdatePosOverride(CCmdUI* pCmdUI);
};
diff --git a/src/mpc-hc/PPageSync.cpp b/src/mpc-hc/PPageSync.cpp
index 97e2ba476..593fed2f6 100644
--- a/src/mpc-hc/PPageSync.cpp
+++ b/src/mpc-hc/PPageSync.cpp
@@ -29,15 +29,15 @@
IMPLEMENT_DYNAMIC(CPPageSync, CPPageBase)
CPPageSync::CPPageSync()
- : CPPageBase(CPPageSync::IDD, CPPageSync::IDD)
- , m_bSynchronizeVideo(0)
- , m_bSynchronizeDisplay(0)
- , m_bSynchronizeNearest(0)
- , m_iLineDelta(0)
- , m_iColumnDelta(0)
- , m_fCycleDelta(0.0012)
- , m_fTargetSyncOffset(10.0)
- , m_fControlLimit(2.0)
+ : CPPageBase(CPPageSync::IDD, CPPageSync::IDD)
+ , m_bSynchronizeVideo(0)
+ , m_bSynchronizeDisplay(0)
+ , m_bSynchronizeNearest(0)
+ , m_iLineDelta(0)
+ , m_iColumnDelta(0)
+ , m_fCycleDelta(0.0012)
+ , m_fTargetSyncOffset(10.0)
+ , m_fControlLimit(2.0)
{
}
@@ -47,115 +47,115 @@ CPPageSync::~CPPageSync()
void CPPageSync::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Check(pDX, IDC_SYNCVIDEO, m_bSynchronizeVideo);
- DDX_Check(pDX, IDC_SYNCDISPLAY, m_bSynchronizeDisplay);
- DDX_Check(pDX, IDC_SYNCNEAREST, m_bSynchronizeNearest);
- DDX_Text(pDX, IDC_CYCLEDELTA, m_fCycleDelta);
- DDX_Text(pDX, IDC_LINEDELTA, m_iLineDelta);
- DDX_Text(pDX, IDC_COLUMNDELTA, m_iColumnDelta);
- DDX_Text(pDX, IDC_TARGETSYNCOFFSET, m_fTargetSyncOffset);
- DDX_Text(pDX, IDC_CONTROLLIMIT, m_fControlLimit);
+ __super::DoDataExchange(pDX);
+ DDX_Check(pDX, IDC_SYNCVIDEO, m_bSynchronizeVideo);
+ DDX_Check(pDX, IDC_SYNCDISPLAY, m_bSynchronizeDisplay);
+ DDX_Check(pDX, IDC_SYNCNEAREST, m_bSynchronizeNearest);
+ DDX_Text(pDX, IDC_CYCLEDELTA, m_fCycleDelta);
+ DDX_Text(pDX, IDC_LINEDELTA, m_iLineDelta);
+ DDX_Text(pDX, IDC_COLUMNDELTA, m_iColumnDelta);
+ DDX_Text(pDX, IDC_TARGETSYNCOFFSET, m_fTargetSyncOffset);
+ DDX_Text(pDX, IDC_CONTROLLIMIT, m_fControlLimit);
}
BOOL CPPageSync::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- InitDialogPrivate();
+ InitDialogPrivate();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageSync::OnSetActive()
{
- InitDialogPrivate();
+ InitDialogPrivate();
- return __super::OnSetActive();
+ return __super::OnSetActive();
}
void CPPageSync::InitDialogPrivate()
{
- AppSettings& s = AfxGetAppSettings();
- CMainFrame * pFrame;
- pFrame = (CMainFrame *)(AfxGetApp()->m_pMainWnd);
- if ((s.iDSVideoRendererType == VIDRNDT_DS_SYNC) && (pFrame->GetPlaybackMode() == PM_NONE)) {
- GetDlgItem(IDC_SYNCVIDEO)->EnableWindow(TRUE);
- GetDlgItem(IDC_SYNCDISPLAY)->EnableWindow(TRUE);
- GetDlgItem(IDC_SYNCNEAREST)->EnableWindow(TRUE);
- } else {
- GetDlgItem(IDC_SYNCVIDEO)->EnableWindow(FALSE);
- GetDlgItem(IDC_SYNCDISPLAY)->EnableWindow(FALSE);
- GetDlgItem(IDC_SYNCNEAREST)->EnableWindow(FALSE);
- }
-
- CRenderersSettings::CRendererSettingsEVR& rendererSettings = s.m_RenderersSettings.m_RenderSettings;
- m_bSynchronizeVideo = rendererSettings.bSynchronizeVideo;
- m_bSynchronizeDisplay = rendererSettings.bSynchronizeDisplay;
- m_bSynchronizeNearest = rendererSettings.bSynchronizeNearest;
- m_iLineDelta = rendererSettings.iLineDelta;
- m_iColumnDelta = rendererSettings.iColumnDelta;
- m_fCycleDelta = rendererSettings.fCycleDelta;
- m_fTargetSyncOffset = rendererSettings.fTargetSyncOffset;
- m_fControlLimit = rendererSettings.fControlLimit;
-
- UpdateData(FALSE);
+ AppSettings& s = AfxGetAppSettings();
+ CMainFrame* pFrame;
+ pFrame = (CMainFrame*)(AfxGetApp()->m_pMainWnd);
+ if ((s.iDSVideoRendererType == VIDRNDT_DS_SYNC) && (pFrame->GetPlaybackMode() == PM_NONE)) {
+ GetDlgItem(IDC_SYNCVIDEO)->EnableWindow(TRUE);
+ GetDlgItem(IDC_SYNCDISPLAY)->EnableWindow(TRUE);
+ GetDlgItem(IDC_SYNCNEAREST)->EnableWindow(TRUE);
+ } else {
+ GetDlgItem(IDC_SYNCVIDEO)->EnableWindow(FALSE);
+ GetDlgItem(IDC_SYNCDISPLAY)->EnableWindow(FALSE);
+ GetDlgItem(IDC_SYNCNEAREST)->EnableWindow(FALSE);
+ }
+
+ CRenderersSettings::CRendererSettingsEVR& rendererSettings = s.m_RenderersSettings.m_RenderSettings;
+ m_bSynchronizeVideo = rendererSettings.bSynchronizeVideo;
+ m_bSynchronizeDisplay = rendererSettings.bSynchronizeDisplay;
+ m_bSynchronizeNearest = rendererSettings.bSynchronizeNearest;
+ m_iLineDelta = rendererSettings.iLineDelta;
+ m_iColumnDelta = rendererSettings.iColumnDelta;
+ m_fCycleDelta = rendererSettings.fCycleDelta;
+ m_fTargetSyncOffset = rendererSettings.fTargetSyncOffset;
+ m_fControlLimit = rendererSettings.fControlLimit;
+
+ UpdateData(FALSE);
}
BOOL CPPageSync::OnApply()
{
- UpdateData();
-
- AppSettings& s = AfxGetAppSettings();
-
- CRenderersSettings::CRendererSettingsEVR& rendererSettings = s.m_RenderersSettings.m_RenderSettings;
- rendererSettings.bSynchronizeVideo = !!m_bSynchronizeVideo;
- rendererSettings.bSynchronizeDisplay = !!m_bSynchronizeDisplay;
- rendererSettings.bSynchronizeNearest = !!m_bSynchronizeNearest;
- rendererSettings.iLineDelta = m_iLineDelta;
- rendererSettings.iColumnDelta = m_iColumnDelta;
- rendererSettings.fCycleDelta = m_fCycleDelta;
- rendererSettings.fTargetSyncOffset = m_fTargetSyncOffset;
- rendererSettings.fControlLimit = m_fControlLimit;
- return __super::OnApply();
+ UpdateData();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ CRenderersSettings::CRendererSettingsEVR& rendererSettings = s.m_RenderersSettings.m_RenderSettings;
+ rendererSettings.bSynchronizeVideo = !!m_bSynchronizeVideo;
+ rendererSettings.bSynchronizeDisplay = !!m_bSynchronizeDisplay;
+ rendererSettings.bSynchronizeNearest = !!m_bSynchronizeNearest;
+ rendererSettings.iLineDelta = m_iLineDelta;
+ rendererSettings.iColumnDelta = m_iColumnDelta;
+ rendererSettings.fCycleDelta = m_fCycleDelta;
+ rendererSettings.fTargetSyncOffset = m_fTargetSyncOffset;
+ rendererSettings.fControlLimit = m_fControlLimit;
+ return __super::OnApply();
}
BEGIN_MESSAGE_MAP(CPPageSync, CPPageBase)
- ON_BN_CLICKED(IDC_SYNCVIDEO, OnBnClickedSyncVideo)
- ON_BN_CLICKED(IDC_SYNCDISPLAY, OnBnClickedSyncDisplay)
- ON_BN_CLICKED(IDC_SYNCNEAREST, OnBnClickedSyncNearest)
+ ON_BN_CLICKED(IDC_SYNCVIDEO, OnBnClickedSyncVideo)
+ ON_BN_CLICKED(IDC_SYNCDISPLAY, OnBnClickedSyncDisplay)
+ ON_BN_CLICKED(IDC_SYNCNEAREST, OnBnClickedSyncNearest)
END_MESSAGE_MAP()
void CPPageSync::OnBnClickedSyncVideo()
{
- m_bSynchronizeVideo = !m_bSynchronizeVideo;
- if (m_bSynchronizeVideo) {
- m_bSynchronizeDisplay = FALSE;
- m_bSynchronizeNearest = FALSE;
- }
- UpdateData(FALSE);
- SetModified();
+ m_bSynchronizeVideo = !m_bSynchronizeVideo;
+ if (m_bSynchronizeVideo) {
+ m_bSynchronizeDisplay = FALSE;
+ m_bSynchronizeNearest = FALSE;
+ }
+ UpdateData(FALSE);
+ SetModified();
}
void CPPageSync::OnBnClickedSyncDisplay()
{
- m_bSynchronizeDisplay = !m_bSynchronizeDisplay;
- if (m_bSynchronizeDisplay) {
- m_bSynchronizeVideo = FALSE;
- m_bSynchronizeNearest = FALSE;
- }
- UpdateData(FALSE);
- SetModified();
+ m_bSynchronizeDisplay = !m_bSynchronizeDisplay;
+ if (m_bSynchronizeDisplay) {
+ m_bSynchronizeVideo = FALSE;
+ m_bSynchronizeNearest = FALSE;
+ }
+ UpdateData(FALSE);
+ SetModified();
}
void CPPageSync::OnBnClickedSyncNearest()
{
- m_bSynchronizeNearest = !m_bSynchronizeNearest;
- if (m_bSynchronizeNearest) {
- m_bSynchronizeVideo = FALSE;
- m_bSynchronizeDisplay = FALSE;
- }
- UpdateData(FALSE);
- SetModified();
+ m_bSynchronizeNearest = !m_bSynchronizeNearest;
+ if (m_bSynchronizeNearest) {
+ m_bSynchronizeVideo = FALSE;
+ m_bSynchronizeDisplay = FALSE;
+ }
+ UpdateData(FALSE);
+ SetModified();
}
diff --git a/src/mpc-hc/PPageSync.h b/src/mpc-hc/PPageSync.h
index 811840ac3..9dce9da2b 100644
--- a/src/mpc-hc/PPageSync.h
+++ b/src/mpc-hc/PPageSync.h
@@ -28,37 +28,37 @@
class CPPageSync: public CPPageBase
{
- DECLARE_DYNAMIC(CPPageSync)
+ DECLARE_DYNAMIC(CPPageSync)
public:
- CPPageSync();
- virtual ~CPPageSync();
+ CPPageSync();
+ virtual ~CPPageSync();
- enum {IDD = IDD_PPAGESYNC};
- BOOL m_bSynchronizeVideo;
- BOOL m_bSynchronizeDisplay;
- BOOL m_bSynchronizeNearest;
+ enum {IDD = IDD_PPAGESYNC};
+ BOOL m_bSynchronizeVideo;
+ BOOL m_bSynchronizeDisplay;
+ BOOL m_bSynchronizeNearest;
- int m_iLineDelta;
- int m_iColumnDelta;
- double m_fCycleDelta;
+ int m_iLineDelta;
+ int m_iColumnDelta;
+ double m_fCycleDelta;
- double m_fTargetSyncOffset;
- double m_fControlLimit;
+ double m_fTargetSyncOffset;
+ double m_fControlLimit;
protected:
- virtual void DoDataExchange(CDataExchange* pDX);
- virtual BOOL OnInitDialog();
- virtual BOOL OnSetActive();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX);
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnSetActive();
+ virtual BOOL OnApply();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnBnClickedSyncVideo();
- afx_msg void OnBnClickedSyncDisplay();
- afx_msg void OnBnClickedSyncNearest();
+ afx_msg void OnBnClickedSyncVideo();
+ afx_msg void OnBnClickedSyncDisplay();
+ afx_msg void OnBnClickedSyncNearest();
private:
- void InitDialogPrivate();
+ void InitDialogPrivate();
};
diff --git a/src/mpc-hc/PPageTweaks.cpp b/src/mpc-hc/PPageTweaks.cpp
index dac49aab3..8b2859ad0 100644
--- a/src/mpc-hc/PPageTweaks.cpp
+++ b/src/mpc-hc/PPageTweaks.cpp
@@ -32,15 +32,15 @@
IMPLEMENT_DYNAMIC(CPPageTweaks, CPPageBase)
CPPageTweaks::CPPageTweaks()
- : CPPageBase(CPPageTweaks::IDD, CPPageTweaks::IDD)
- , m_nJumpDistS(0)
- , m_nJumpDistM(0)
- , m_nJumpDistL(0)
- , m_OSD_Size(0)
- , m_fNotifyMSN(TRUE)
- , m_fPreventMinimize(FALSE)
- , m_fUseWin7TaskBar(TRUE)
- , m_fUseSearchInFolder(FALSE)
+ : CPPageBase(CPPageTweaks::IDD, CPPageTweaks::IDD)
+ , m_nJumpDistS(0)
+ , m_nJumpDistM(0)
+ , m_nJumpDistL(0)
+ , m_OSD_Size(0)
+ , m_fNotifyMSN(TRUE)
+ , m_fPreventMinimize(FALSE)
+ , m_fUseWin7TaskBar(TRUE)
+ , m_fUseSearchInFolder(FALSE)
{
}
@@ -50,135 +50,135 @@ CPPageTweaks::~CPPageTweaks()
void CPPageTweaks::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Text(pDX, IDC_EDIT1, m_nJumpDistS);
- DDX_Text(pDX, IDC_EDIT2, m_nJumpDistM);
- DDX_Text(pDX, IDC_EDIT3, m_nJumpDistL);
- DDX_Check(pDX, IDC_CHECK4, m_fNotifyMSN);
- DDX_Check(pDX, IDC_CHECK6, m_fPreventMinimize);
- DDX_Check(pDX, IDC_CHECK_WIN7, m_fUseWin7TaskBar);
- DDX_Check(pDX, IDC_CHECK7, m_fUseSearchInFolder);
- DDX_Check(pDX, IDC_CHECK8, m_fUseTimeTooltip);
- DDX_Control(pDX, IDC_COMBO3, m_TimeTooltipPosition);
- DDX_Control(pDX, IDC_COMBO1, m_FontType);
- DDX_Control(pDX, IDC_COMBO2, m_FontSize);
- DDX_Check(pDX, IDC_CHECK1, m_fFastSeek);
+ __super::DoDataExchange(pDX);
+ DDX_Text(pDX, IDC_EDIT1, m_nJumpDistS);
+ DDX_Text(pDX, IDC_EDIT2, m_nJumpDistM);
+ DDX_Text(pDX, IDC_EDIT3, m_nJumpDistL);
+ DDX_Check(pDX, IDC_CHECK4, m_fNotifyMSN);
+ DDX_Check(pDX, IDC_CHECK6, m_fPreventMinimize);
+ DDX_Check(pDX, IDC_CHECK_WIN7, m_fUseWin7TaskBar);
+ DDX_Check(pDX, IDC_CHECK7, m_fUseSearchInFolder);
+ DDX_Check(pDX, IDC_CHECK8, m_fUseTimeTooltip);
+ DDX_Control(pDX, IDC_COMBO3, m_TimeTooltipPosition);
+ DDX_Control(pDX, IDC_COMBO1, m_FontType);
+ DDX_Control(pDX, IDC_COMBO2, m_FontSize);
+ DDX_Check(pDX, IDC_CHECK1, m_fFastSeek);
}
int CALLBACK EnumFontProc(ENUMLOGFONT FAR* lf, NEWTEXTMETRIC FAR* tm, int FontType, LPARAM dwData)
{
- CAtlArray<CString>* fntl = (CAtlArray<CString>*)dwData;
- if (FontType == TRUETYPE_FONTTYPE) {
- fntl->Add(lf->elfFullName);
- }
- return true;
+ CAtlArray<CString>* fntl = (CAtlArray<CString>*)dwData;
+ if (FontType == TRUETYPE_FONTTYPE) {
+ fntl->Add(lf->elfFullName);
+ }
+ return true;
}
BOOL CPPageTweaks::OnInitDialog()
{
- __super::OnInitDialog();
-
- SetHandCursor(m_hWnd, IDC_COMBO1);
-
- AppSettings& s = AfxGetAppSettings();
-
- m_nJumpDistS = s.nJumpDistS;
- m_nJumpDistM = s.nJumpDistM;
- m_nJumpDistL = s.nJumpDistL;
- m_fNotifyMSN = s.fNotifyMSN;
-
- m_fPreventMinimize = s.fPreventMinimize;
-
- m_fUseWin7TaskBar = s.fUseWin7TaskBar;
- if (!SysVersion::Is7OrLater()) {
- GetDlgItem(IDC_CHECK_WIN7)->EnableWindow(FALSE);
- }
-
- m_fUseSearchInFolder = s.fUseSearchInFolder;
-
- m_fUseTimeTooltip = s.fUseTimeTooltip;
- m_TimeTooltipPosition.AddString(ResStr(IDS_TIME_TOOLTIP_ABOVE));
- m_TimeTooltipPosition.AddString(ResStr(IDS_TIME_TOOLTIP_BELOW));
- m_TimeTooltipPosition.SetCurSel(s.nTimeTooltipPosition);
- m_TimeTooltipPosition.EnableWindow(m_fUseTimeTooltip);
-
- m_OSD_Size = s.nOSDSize;
- m_OSD_Font = s.strOSDFont;
-
- m_fFastSeek = s.fFastSeek;
-
- m_FontType.Clear();
- m_FontSize.Clear();
- HDC dc = CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
- CAtlArray<CString> fntl;
- EnumFontFamilies(dc, NULL,(FONTENUMPROC)EnumFontProc, (LPARAM)&fntl);
- DeleteDC(dc);
- for (size_t i = 0; i < fntl.GetCount(); ++i) {
- if (i > 0 && fntl[i-1] == fntl[i]) {
- continue;
- }
- m_FontType.AddString(fntl[i]);
- }
- CorrectComboListWidth(m_FontType);
- int iSel = m_FontType.FindStringExact(0, m_OSD_Font);
- if (iSel == CB_ERR) iSel = 0;
- m_FontType.SetCurSel(iSel);
-
- CString str;
- for (int i = 10; i < 26; ++i) {
- str.Format(_T("%d"), i);
- m_FontSize.AddString(str);
- if (m_OSD_Size == i) {
- iSel = i;
- }
- }
- m_FontSize.SetCurSel(iSel - 10);
-
- EnableToolTips(TRUE);
-
- UpdateData(FALSE);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+
+ SetHandCursor(m_hWnd, IDC_COMBO1);
+
+ AppSettings& s = AfxGetAppSettings();
+
+ m_nJumpDistS = s.nJumpDistS;
+ m_nJumpDistM = s.nJumpDistM;
+ m_nJumpDistL = s.nJumpDistL;
+ m_fNotifyMSN = s.fNotifyMSN;
+
+ m_fPreventMinimize = s.fPreventMinimize;
+
+ m_fUseWin7TaskBar = s.fUseWin7TaskBar;
+ if (!SysVersion::Is7OrLater()) {
+ GetDlgItem(IDC_CHECK_WIN7)->EnableWindow(FALSE);
+ }
+
+ m_fUseSearchInFolder = s.fUseSearchInFolder;
+
+ m_fUseTimeTooltip = s.fUseTimeTooltip;
+ m_TimeTooltipPosition.AddString(ResStr(IDS_TIME_TOOLTIP_ABOVE));
+ m_TimeTooltipPosition.AddString(ResStr(IDS_TIME_TOOLTIP_BELOW));
+ m_TimeTooltipPosition.SetCurSel(s.nTimeTooltipPosition);
+ m_TimeTooltipPosition.EnableWindow(m_fUseTimeTooltip);
+
+ m_OSD_Size = s.nOSDSize;
+ m_OSD_Font = s.strOSDFont;
+
+ m_fFastSeek = s.fFastSeek;
+
+ m_FontType.Clear();
+ m_FontSize.Clear();
+ HDC dc = CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
+ CAtlArray<CString> fntl;
+ EnumFontFamilies(dc, NULL, (FONTENUMPROC)EnumFontProc, (LPARAM)&fntl);
+ DeleteDC(dc);
+ for (size_t i = 0; i < fntl.GetCount(); ++i) {
+ if (i > 0 && fntl[i - 1] == fntl[i]) {
+ continue;
+ }
+ m_FontType.AddString(fntl[i]);
+ }
+ CorrectComboListWidth(m_FontType);
+ int iSel = m_FontType.FindStringExact(0, m_OSD_Font);
+ if (iSel == CB_ERR) { iSel = 0; }
+ m_FontType.SetCurSel(iSel);
+
+ CString str;
+ for (int i = 10; i < 26; ++i) {
+ str.Format(_T("%d"), i);
+ m_FontSize.AddString(str);
+ if (m_OSD_Size == i) {
+ iSel = i;
+ }
+ }
+ m_FontSize.SetCurSel(iSel - 10);
+
+ EnableToolTips(TRUE);
+
+ UpdateData(FALSE);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageTweaks::OnApply()
{
- UpdateData();
+ UpdateData();
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- s.nJumpDistS = m_nJumpDistS;
- s.nJumpDistM = m_nJumpDistM;
- s.nJumpDistL = m_nJumpDistL;
- s.fNotifyMSN = !!m_fNotifyMSN;
+ s.nJumpDistS = m_nJumpDistS;
+ s.nJumpDistM = m_nJumpDistM;
+ s.nJumpDistL = m_nJumpDistL;
+ s.fNotifyMSN = !!m_fNotifyMSN;
- s.fPreventMinimize = !!m_fPreventMinimize;
- s.fUseWin7TaskBar = !!m_fUseWin7TaskBar;
- s.fUseSearchInFolder = !!m_fUseSearchInFolder;
- s.fUseTimeTooltip = !!m_fUseTimeTooltip;
- s.nTimeTooltipPosition = m_TimeTooltipPosition.GetCurSel();
- s.nOSDSize = m_OSD_Size;
- m_FontType.GetLBText(m_FontType.GetCurSel(),s.strOSDFont);
+ s.fPreventMinimize = !!m_fPreventMinimize;
+ s.fUseWin7TaskBar = !!m_fUseWin7TaskBar;
+ s.fUseSearchInFolder = !!m_fUseSearchInFolder;
+ s.fUseTimeTooltip = !!m_fUseTimeTooltip;
+ s.nTimeTooltipPosition = m_TimeTooltipPosition.GetCurSel();
+ s.nOSDSize = m_OSD_Size;
+ m_FontType.GetLBText(m_FontType.GetCurSel(), s.strOSDFont);
- s.fFastSeek = !!m_fFastSeek;
+ s.fFastSeek = !!m_fFastSeek;
- CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
- if (m_fUseWin7TaskBar) {
- pFrame->CreateThumbnailToolbar();
- }
- pFrame->UpdateThumbarButton();
+ CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
+ if (m_fUseWin7TaskBar) {
+ pFrame->CreateThumbnailToolbar();
+ }
+ pFrame->UpdateThumbarButton();
- return __super::OnApply();
+ return __super::OnApply();
}
BEGIN_MESSAGE_MAP(CPPageTweaks, CPPageBase)
- ON_UPDATE_COMMAND_UI(IDC_CHECK3, OnUpdateCheck3)
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
- ON_BN_CLICKED(IDC_CHECK8, OnUseTimeTooltipClicked)
- ON_CBN_SELCHANGE(IDC_COMBO1, OnChngOSDCombo)
- ON_CBN_SELCHANGE(IDC_COMBO2, OnChngOSDCombo)
- ON_NOTIFY_EX_RANGE(TTN_NEEDTEXT, 0, 0xFFFF, OnToolTipNotify)
+ ON_UPDATE_COMMAND_UI(IDC_CHECK3, OnUpdateCheck3)
+ ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
+ ON_BN_CLICKED(IDC_CHECK8, OnUseTimeTooltipClicked)
+ ON_CBN_SELCHANGE(IDC_COMBO1, OnChngOSDCombo)
+ ON_CBN_SELCHANGE(IDC_COMBO2, OnChngOSDCombo)
+ ON_NOTIFY_EX_RANGE(TTN_NEEDTEXT, 0, 0xFFFF, OnToolTipNotify)
END_MESSAGE_MAP()
@@ -190,60 +190,60 @@ void CPPageTweaks::OnUpdateCheck3(CCmdUI* pCmdUI)
void CPPageTweaks::OnBnClickedButton1()
{
- m_nJumpDistS = DEFAULT_JUMPDISTANCE_1;
- m_nJumpDistM = DEFAULT_JUMPDISTANCE_2;
- m_nJumpDistL = DEFAULT_JUMPDISTANCE_3;
+ m_nJumpDistS = DEFAULT_JUMPDISTANCE_1;
+ m_nJumpDistM = DEFAULT_JUMPDISTANCE_2;
+ m_nJumpDistL = DEFAULT_JUMPDISTANCE_3;
- UpdateData(FALSE);
- SetModified();
+ UpdateData(FALSE);
+ SetModified();
}
void CPPageTweaks::OnChngOSDCombo()
{
- CString str;
- m_OSD_Size = m_FontSize.GetCurSel()+10;
- m_FontType.GetLBText(m_FontType.GetCurSel(),str);
- ((CMainFrame*)AfxGetMainWnd())->m_OSD.DisplayMessage(OSD_TOPLEFT, _T("Test"), 2000, m_OSD_Size, str);
- SetModified();
+ CString str;
+ m_OSD_Size = m_FontSize.GetCurSel() + 10;
+ m_FontType.GetLBText(m_FontType.GetCurSel(), str);
+ ((CMainFrame*)AfxGetMainWnd())->m_OSD.DisplayMessage(OSD_TOPLEFT, _T("Test"), 2000, m_OSD_Size, str);
+ SetModified();
}
void CPPageTweaks::OnUseTimeTooltipClicked()
{
- m_TimeTooltipPosition.EnableWindow(IsDlgButtonChecked(IDC_CHECK8));
+ m_TimeTooltipPosition.EnableWindow(IsDlgButtonChecked(IDC_CHECK8));
- SetModified();
+ SetModified();
}
BOOL CPPageTweaks::OnToolTipNotify(UINT id, NMHDR* pNMH, LRESULT* pResult)
{
- TOOLTIPTEXT *pTTT = reinterpret_cast<LPTOOLTIPTEXT>(pNMH);
- int cid = ::GetDlgCtrlID((HWND)pNMH->idFrom);
- if (cid == IDC_COMBO1) {
- CDC* pDC = m_FontType.GetDC();
- CFont* pFont = m_FontType.GetFont();
- CFont* pOldFont = pDC->SelectObject(pFont);
- TEXTMETRIC tm;
- pDC->GetTextMetrics(&tm);
- CRect rc;
- m_FontType.GetWindowRect(rc);
- rc.right -= GetSystemMetrics(SM_CXVSCROLL) * GetSystemMetrics(SM_CXEDGE);
- int i = m_FontType.GetCurSel();
- CString str;
- m_FontType.GetLBText(i, str);
- CSize sz;
- sz = pDC->GetTextExtent(str);
- pDC->SelectObject(pOldFont);
- m_FontType.ReleaseDC(pDC);
- sz.cx += tm.tmAveCharWidth;
- str = str.Left(_countof(pTTT->szText));
- if (sz.cx > rc.Width()) {
- _tcscpy_s(pTTT->szText, str);
- pTTT->hinst = NULL;
- }
-
- return TRUE;
- }
-
- return FALSE;
+ TOOLTIPTEXT* pTTT = reinterpret_cast<LPTOOLTIPTEXT>(pNMH);
+ int cid = ::GetDlgCtrlID((HWND)pNMH->idFrom);
+ if (cid == IDC_COMBO1) {
+ CDC* pDC = m_FontType.GetDC();
+ CFont* pFont = m_FontType.GetFont();
+ CFont* pOldFont = pDC->SelectObject(pFont);
+ TEXTMETRIC tm;
+ pDC->GetTextMetrics(&tm);
+ CRect rc;
+ m_FontType.GetWindowRect(rc);
+ rc.right -= GetSystemMetrics(SM_CXVSCROLL) * GetSystemMetrics(SM_CXEDGE);
+ int i = m_FontType.GetCurSel();
+ CString str;
+ m_FontType.GetLBText(i, str);
+ CSize sz;
+ sz = pDC->GetTextExtent(str);
+ pDC->SelectObject(pOldFont);
+ m_FontType.ReleaseDC(pDC);
+ sz.cx += tm.tmAveCharWidth;
+ str = str.Left(_countof(pTTT->szText));
+ if (sz.cx > rc.Width()) {
+ _tcscpy_s(pTTT->szText, str);
+ pTTT->hinst = NULL;
+ }
+
+ return TRUE;
+ }
+
+ return FALSE;
}
diff --git a/src/mpc-hc/PPageTweaks.h b/src/mpc-hc/PPageTweaks.h
index 4ae39d890..5ecd10f7f 100644
--- a/src/mpc-hc/PPageTweaks.h
+++ b/src/mpc-hc/PPageTweaks.h
@@ -30,42 +30,42 @@
class CPPageTweaks : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageTweaks)
+ DECLARE_DYNAMIC(CPPageTweaks)
public:
- CPPageTweaks();
- virtual ~CPPageTweaks();
+ CPPageTweaks();
+ virtual ~CPPageTweaks();
- // Dialog Data
- enum { IDD = IDD_PPAGETWEAKS };
- int m_nJumpDistS;
- int m_nJumpDistM;
- int m_nJumpDistL;
- BOOL m_fNotifyMSN;
+ // Dialog Data
+ enum { IDD = IDD_PPAGETWEAKS };
+ int m_nJumpDistS;
+ int m_nJumpDistM;
+ int m_nJumpDistL;
+ BOOL m_fNotifyMSN;
- BOOL m_fPreventMinimize;
- BOOL m_fUseWin7TaskBar;
- BOOL m_fUseSearchInFolder;
- BOOL m_fUseTimeTooltip;
- CComboBox m_TimeTooltipPosition;
- CComboBox m_FontSize;
- CComboBox m_FontType;
- int m_OSD_Size;
- CString m_OSD_Font;
+ BOOL m_fPreventMinimize;
+ BOOL m_fUseWin7TaskBar;
+ BOOL m_fUseSearchInFolder;
+ BOOL m_fUseTimeTooltip;
+ CComboBox m_TimeTooltipPosition;
+ CComboBox m_FontSize;
+ CComboBox m_FontType;
+ int m_OSD_Size;
+ CString m_OSD_Font;
- BOOL m_fFastSeek;
+ BOOL m_fFastSeek;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg BOOL OnToolTipNotify(UINT id, NMHDR* pNMH, LRESULT* pResult);
- afx_msg void OnUpdateCheck3(CCmdUI* pCmdUI);
- afx_msg void OnBnClickedButton1();
- afx_msg void OnUseTimeTooltipClicked();
- afx_msg void OnChngOSDCombo();
+ afx_msg BOOL OnToolTipNotify(UINT id, NMHDR* pNMH, LRESULT* pResult);
+ afx_msg void OnUpdateCheck3(CCmdUI* pCmdUI);
+ afx_msg void OnBnClickedButton1();
+ afx_msg void OnUseTimeTooltipClicked();
+ afx_msg void OnChngOSDCombo();
};
diff --git a/src/mpc-hc/PPageWebServer.cpp b/src/mpc-hc/PPageWebServer.cpp
index d30b2ff23..be30f9b4f 100644
--- a/src/mpc-hc/PPageWebServer.cpp
+++ b/src/mpc-hc/PPageWebServer.cpp
@@ -32,17 +32,17 @@
IMPLEMENT_DYNAMIC(CPPageWebServer, CPPageBase)
CPPageWebServer::CPPageWebServer()
- : CPPageBase(CPPageWebServer::IDD, CPPageWebServer::IDD)
- , m_fEnableWebServer(FALSE)
- , m_nWebServerPort(0)
- , m_launch(_T("http://localhost:13579/"))
- , m_fWebServerPrintDebugInfo(FALSE)
- , m_fWebServerUseCompression(FALSE)
- , m_fWebRoot(FALSE)
- , m_WebRoot(_T(""))
- , m_fWebServerLocalhostOnly(FALSE)
- , m_WebServerCGI(_T(""))
- , m_WebDefIndex(_T(""))
+ : CPPageBase(CPPageWebServer::IDD, CPPageWebServer::IDD)
+ , m_fEnableWebServer(FALSE)
+ , m_nWebServerPort(0)
+ , m_launch(_T("http://localhost:13579/"))
+ , m_fWebServerPrintDebugInfo(FALSE)
+ , m_fWebServerUseCompression(FALSE)
+ , m_fWebRoot(FALSE)
+ , m_WebRoot(_T(""))
+ , m_fWebServerLocalhostOnly(FALSE)
+ , m_WebServerCGI(_T(""))
+ , m_WebDefIndex(_T(""))
{
}
@@ -52,197 +52,197 @@ CPPageWebServer::~CPPageWebServer()
void CPPageWebServer::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Check(pDX, IDC_CHECK1, m_fEnableWebServer);
- DDX_Text(pDX, IDC_EDIT1, m_nWebServerPort);
- DDX_Control(pDX, IDC_EDIT1, m_nWebServerPortCtrl);
- DDX_Control(pDX, IDC_STATIC1, m_launch);
- DDX_Check(pDX, IDC_CHECK2, m_fWebServerPrintDebugInfo);
- DDX_Check(pDX, IDC_CHECK3, m_fWebServerUseCompression);
- DDX_Check(pDX, IDC_CHECK4, m_fWebRoot);
- DDX_Text(pDX, IDC_EDIT2, m_WebRoot);
- DDX_Check(pDX, IDC_CHECK5, m_fWebServerLocalhostOnly);
- DDX_Text(pDX, IDC_EDIT3, m_WebServerCGI);
- DDX_Text(pDX, IDC_EDIT9, m_WebDefIndex);
+ __super::DoDataExchange(pDX);
+ DDX_Check(pDX, IDC_CHECK1, m_fEnableWebServer);
+ DDX_Text(pDX, IDC_EDIT1, m_nWebServerPort);
+ DDX_Control(pDX, IDC_EDIT1, m_nWebServerPortCtrl);
+ DDX_Control(pDX, IDC_STATIC1, m_launch);
+ DDX_Check(pDX, IDC_CHECK2, m_fWebServerPrintDebugInfo);
+ DDX_Check(pDX, IDC_CHECK3, m_fWebServerUseCompression);
+ DDX_Check(pDX, IDC_CHECK4, m_fWebRoot);
+ DDX_Text(pDX, IDC_EDIT2, m_WebRoot);
+ DDX_Check(pDX, IDC_CHECK5, m_fWebServerLocalhostOnly);
+ DDX_Text(pDX, IDC_EDIT3, m_WebServerCGI);
+ DDX_Text(pDX, IDC_EDIT9, m_WebDefIndex);
}
BOOL CPPageWebServer::PreTranslateMessage(MSG* pMsg)
{
- if (pMsg->message == WM_LBUTTONDOWN && pMsg->hwnd == m_launch.m_hWnd) {
- UpdateData();
-
- AppSettings& s = AfxGetAppSettings();
-
- if (CMainFrame* pWnd = (CMainFrame*)AfxGetMainWnd()) {
- if (m_fEnableWebServer) {
- if (s.nWebServerPort != m_nWebServerPort) {
- AfxMessageBox(IDS_WEBSERVER_ERROR_TEST, MB_ICONEXCLAMATION | MB_OK, 0);
- return TRUE;
- }
- }
- }
- }
-
- return CPPageBase::PreTranslateMessage(pMsg);
+ if (pMsg->message == WM_LBUTTONDOWN && pMsg->hwnd == m_launch.m_hWnd) {
+ UpdateData();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ if (CMainFrame* pWnd = (CMainFrame*)AfxGetMainWnd()) {
+ if (m_fEnableWebServer) {
+ if (s.nWebServerPort != m_nWebServerPort) {
+ AfxMessageBox(IDS_WEBSERVER_ERROR_TEST, MB_ICONEXCLAMATION | MB_OK, 0);
+ return TRUE;
+ }
+ }
+ }
+ }
+
+ return CPPageBase::PreTranslateMessage(pMsg);
}
BOOL CPPageWebServer::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- m_fEnableWebServer = s.fEnableWebServer;
- m_nWebServerPort = s.nWebServerPort;
- m_fWebServerPrintDebugInfo = s.fWebServerPrintDebugInfo;
- m_fWebServerLocalhostOnly = s.fWebServerLocalhostOnly;
- m_fWebServerUseCompression = s.fWebServerUseCompression;
- m_fWebRoot = s.strWebRoot.Find('*') < 0;
- m_WebRoot = s.strWebRoot;
- m_WebRoot.TrimLeft(_T('*'));
- m_WebDefIndex = s.strWebDefIndex;
- m_WebServerCGI = s.strWebServerCGI;
+ m_fEnableWebServer = s.fEnableWebServer;
+ m_nWebServerPort = s.nWebServerPort;
+ m_fWebServerPrintDebugInfo = s.fWebServerPrintDebugInfo;
+ m_fWebServerLocalhostOnly = s.fWebServerLocalhostOnly;
+ m_fWebServerUseCompression = s.fWebServerUseCompression;
+ m_fWebRoot = s.strWebRoot.Find('*') < 0;
+ m_WebRoot = s.strWebRoot;
+ m_WebRoot.TrimLeft(_T('*'));
+ m_WebDefIndex = s.strWebDefIndex;
+ m_WebServerCGI = s.strWebServerCGI;
- UpdateData(FALSE);
+ UpdateData(FALSE);
- OnEnChangeEdit1();
+ OnEnChangeEdit1();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPPageWebServer::OnApply()
{
- UpdateData();
-
- AppSettings& s = AfxGetAppSettings();
-
- CString NewWebRoot = m_WebRoot;
- if (!m_fWebRoot) {
- NewWebRoot = _T("*") + NewWebRoot;
- }
-
- bool fRestart = s.nWebServerPort != m_nWebServerPort
- || s.strWebRoot != NewWebRoot || s.strWebServerCGI != m_WebServerCGI;
-
- s.fEnableWebServer = !!m_fEnableWebServer;
- s.nWebServerPort = m_nWebServerPort;
- s.fWebServerPrintDebugInfo = !!m_fWebServerPrintDebugInfo;
- s.fWebServerLocalhostOnly = !!m_fWebServerLocalhostOnly;
- s.fWebServerUseCompression = !!m_fWebServerUseCompression;
- s.strWebRoot = NewWebRoot;
- s.strWebDefIndex = m_WebDefIndex;
- s.strWebServerCGI = m_WebServerCGI;
-
- if (CMainFrame* pWnd = (CMainFrame*)AfxGetMainWnd()) {
- if (m_fEnableWebServer) {
- if (fRestart) {
- pWnd->StopWebServer();
- }
- pWnd->StartWebServer(m_nWebServerPort);
- } else {
- pWnd->StopWebServer();
- }
- }
-
- return __super::OnApply();
+ UpdateData();
+
+ AppSettings& s = AfxGetAppSettings();
+
+ CString NewWebRoot = m_WebRoot;
+ if (!m_fWebRoot) {
+ NewWebRoot = _T("*") + NewWebRoot;
+ }
+
+ bool fRestart = s.nWebServerPort != m_nWebServerPort
+ || s.strWebRoot != NewWebRoot || s.strWebServerCGI != m_WebServerCGI;
+
+ s.fEnableWebServer = !!m_fEnableWebServer;
+ s.nWebServerPort = m_nWebServerPort;
+ s.fWebServerPrintDebugInfo = !!m_fWebServerPrintDebugInfo;
+ s.fWebServerLocalhostOnly = !!m_fWebServerLocalhostOnly;
+ s.fWebServerUseCompression = !!m_fWebServerUseCompression;
+ s.strWebRoot = NewWebRoot;
+ s.strWebDefIndex = m_WebDefIndex;
+ s.strWebServerCGI = m_WebServerCGI;
+
+ if (CMainFrame* pWnd = (CMainFrame*)AfxGetMainWnd()) {
+ if (m_fEnableWebServer) {
+ if (fRestart) {
+ pWnd->StopWebServer();
+ }
+ pWnd->StartWebServer(m_nWebServerPort);
+ } else {
+ pWnd->StopWebServer();
+ }
+ }
+
+ return __super::OnApply();
}
CString CPPageWebServer::GetMPCDir()
{
- CString dir;
- GetModuleFileName(AfxGetInstanceHandle(), dir.GetBuffer(_MAX_PATH), _MAX_PATH);
- dir.ReleaseBuffer();
- CPath path(dir);
- path.RemoveFileSpec();
- return (LPCTSTR)path;
+ CString dir;
+ GetModuleFileName(AfxGetInstanceHandle(), dir.GetBuffer(_MAX_PATH), _MAX_PATH);
+ dir.ReleaseBuffer();
+ CPath path(dir);
+ path.RemoveFileSpec();
+ return (LPCTSTR)path;
}
CString CPPageWebServer::GetCurWebRoot()
{
- CString WebRoot;
- GetDlgItem(IDC_EDIT2)->GetWindowText(WebRoot);
- WebRoot.Replace('/', '\\');
+ CString WebRoot;
+ GetDlgItem(IDC_EDIT2)->GetWindowText(WebRoot);
+ WebRoot.Replace('/', '\\');
- CPath path;
- path.Combine(GetMPCDir(), WebRoot);
- return path.IsDirectory() ? (LPCTSTR)path : _T("");
+ CPath path;
+ path.Combine(GetMPCDir(), WebRoot);
+ return path.IsDirectory() ? (LPCTSTR)path : _T("");
}
static int __stdcall BrowseCtrlCallback(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
{
- if (uMsg == BFFM_INITIALIZED && lpData) {
- ::SendMessage(hwnd, BFFM_SETSELECTION, TRUE, lpData);
- }
- return 0;
+ if (uMsg == BFFM_INITIALIZED && lpData) {
+ ::SendMessage(hwnd, BFFM_SETSELECTION, TRUE, lpData);
+ }
+ return 0;
}
bool CPPageWebServer::PickDir(CString& dir)
{
- CString strTitle = ResStr(IDS_PPAGEWEBSERVER_0);
- bool success = false;
-
- if (SysVersion::IsVistaOrLater()) {
- CFileDialog dlg(TRUE);
- IFileOpenDialog *openDlgPtr = dlg.GetIFileOpenDialog();
-
- if (openDlgPtr != NULL) {
- openDlgPtr->SetTitle(strTitle);
- openDlgPtr->SetOptions(FOS_PICKFOLDERS | FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST);
-
- // Typedef for function SHCreateItemFromParsingName
- typedef HRESULT (STDAPICALLTYPE * PFN_TYPE_SHCreateItemFromParsingName)(PCWSTR /*pszPath*/, IBindCtx* /*pbc*/, REFIID /*riid*/, void** /*ppv*/);
-
- // Load SHELL32.DLL to get pointer to aforementioned function
- HINSTANCE hDllShell = ::LoadLibrary(_T("Shell32.dll"));
- PFN_TYPE_SHCreateItemFromParsingName pfnSHCreateItemFromParsingName = NULL;
- if (hDllShell != NULL) {
- // Try to get the pointer to that function
- pfnSHCreateItemFromParsingName = reinterpret_cast<PFN_TYPE_SHCreateItemFromParsingName>(::GetProcAddress(hDllShell, "SHCreateItemFromParsingName"));
- }
- if (pfnSHCreateItemFromParsingName != NULL) {
- CComPtr<IShellItem> psiFolder;
- if (SUCCEEDED(pfnSHCreateItemFromParsingName(dir, NULL, IID_PPV_ARGS(&psiFolder)))) {
- openDlgPtr->SetFolder(psiFolder);
- }
- }
-
- if (SUCCEEDED(openDlgPtr->Show(m_hWnd))) {
- dir = dlg.GetFolderPath();
- success = true;
- }
-
- openDlgPtr->Release();
- }
- } else {
- TCHAR buff[_MAX_PATH];
-
- BROWSEINFO bi;
- bi.hwndOwner = m_hWnd;
- bi.pidlRoot = NULL;
- bi.pszDisplayName = buff;
- bi.lpszTitle = strTitle;
- bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_VALIDATE | BIF_USENEWUI;
- bi.lpfn = BrowseCtrlCallback;
- bi.lParam = (LPARAM)(LPCTSTR)dir;
- bi.iImage = 0;
-
- LPITEMIDLIST iil = SHBrowseForFolder(&bi);
- if (iil) {
- SHGetPathFromIDList(iil, buff);
- dir = buff;
- success = true;
- }
- }
-
- return success;
+ CString strTitle = ResStr(IDS_PPAGEWEBSERVER_0);
+ bool success = false;
+
+ if (SysVersion::IsVistaOrLater()) {
+ CFileDialog dlg(TRUE);
+ IFileOpenDialog* openDlgPtr = dlg.GetIFileOpenDialog();
+
+ if (openDlgPtr != NULL) {
+ openDlgPtr->SetTitle(strTitle);
+ openDlgPtr->SetOptions(FOS_PICKFOLDERS | FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST);
+
+ // Typedef for function SHCreateItemFromParsingName
+ typedef HRESULT(STDAPICALLTYPE * PFN_TYPE_SHCreateItemFromParsingName)(PCWSTR /*pszPath*/, IBindCtx* /*pbc*/, REFIID /*riid*/, void** /*ppv*/);
+
+ // Load SHELL32.DLL to get pointer to aforementioned function
+ HINSTANCE hDllShell = ::LoadLibrary(_T("Shell32.dll"));
+ PFN_TYPE_SHCreateItemFromParsingName pfnSHCreateItemFromParsingName = NULL;
+ if (hDllShell != NULL) {
+ // Try to get the pointer to that function
+ pfnSHCreateItemFromParsingName = reinterpret_cast<PFN_TYPE_SHCreateItemFromParsingName>(::GetProcAddress(hDllShell, "SHCreateItemFromParsingName"));
+ }
+ if (pfnSHCreateItemFromParsingName != NULL) {
+ CComPtr<IShellItem> psiFolder;
+ if (SUCCEEDED(pfnSHCreateItemFromParsingName(dir, NULL, IID_PPV_ARGS(&psiFolder)))) {
+ openDlgPtr->SetFolder(psiFolder);
+ }
+ }
+
+ if (SUCCEEDED(openDlgPtr->Show(m_hWnd))) {
+ dir = dlg.GetFolderPath();
+ success = true;
+ }
+
+ openDlgPtr->Release();
+ }
+ } else {
+ TCHAR buff[_MAX_PATH];
+
+ BROWSEINFO bi;
+ bi.hwndOwner = m_hWnd;
+ bi.pidlRoot = NULL;
+ bi.pszDisplayName = buff;
+ bi.lpszTitle = strTitle;
+ bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_VALIDATE | BIF_USENEWUI;
+ bi.lpfn = BrowseCtrlCallback;
+ bi.lParam = (LPARAM)(LPCTSTR)dir;
+ bi.iImage = 0;
+
+ LPITEMIDLIST iil = SHBrowseForFolder(&bi);
+ if (iil) {
+ SHGetPathFromIDList(iil, buff);
+ dir = buff;
+ success = true;
+ }
+ }
+
+ return success;
}
BEGIN_MESSAGE_MAP(CPPageWebServer, CPPageBase)
- ON_EN_CHANGE(IDC_EDIT1, OnEnChangeEdit1)
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
- ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateButton2)
+ ON_EN_CHANGE(IDC_EDIT1, OnEnChangeEdit1)
+ ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
+ ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateButton2)
END_MESSAGE_MAP()
@@ -250,40 +250,40 @@ END_MESSAGE_MAP()
void CPPageWebServer::OnEnChangeEdit1()
{
- UpdateData();
+ UpdateData();
- CString link;
- link.Format(_T("http://localhost:%d/"), m_nWebServerPort);
- m_launch.m_link = link;
+ CString link;
+ link.Format(_T("http://localhost:%d/"), m_nWebServerPort);
+ m_launch.m_link = link;
- SetModified();
+ SetModified();
}
void CPPageWebServer::OnBnClickedButton1()
{
- CString dir = GetCurWebRoot();
- if (PickDir(dir)) {
- CPath path;
- if (path.RelativePathTo(GetMPCDir(), FILE_ATTRIBUTE_DIRECTORY, dir, FILE_ATTRIBUTE_DIRECTORY)) {
- dir = (LPCTSTR)path;
- }
- m_WebRoot = dir;
-
- UpdateData(FALSE);
- SetModified();
- }
+ CString dir = GetCurWebRoot();
+ if (PickDir(dir)) {
+ CPath path;
+ if (path.RelativePathTo(GetMPCDir(), FILE_ATTRIBUTE_DIRECTORY, dir, FILE_ATTRIBUTE_DIRECTORY)) {
+ dir = (LPCTSTR)path;
+ }
+ m_WebRoot = dir;
+
+ UpdateData(FALSE);
+ SetModified();
+ }
}
void CPPageWebServer::OnBnClickedButton2()
{
- CString dir;
- if (PickDir(dir)) {
- dir += _T("\\");
- CWebServer::Deploy(dir);
- }
+ CString dir;
+ if (PickDir(dir)) {
+ dir += _T("\\");
+ CWebServer::Deploy(dir);
+ }
}
void CPPageWebServer::OnUpdateButton2(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(GetDlgItem(IDC_EDIT2)->GetWindowTextLength() > 0);
+ pCmdUI->Enable(GetDlgItem(IDC_EDIT2)->GetWindowTextLength() > 0);
}
diff --git a/src/mpc-hc/PPageWebServer.h b/src/mpc-hc/PPageWebServer.h
index beacca275..ee0727f4d 100644
--- a/src/mpc-hc/PPageWebServer.h
+++ b/src/mpc-hc/PPageWebServer.h
@@ -32,42 +32,42 @@
class CPPageWebServer : public CPPageBase
{
- DECLARE_DYNAMIC(CPPageWebServer)
+ DECLARE_DYNAMIC(CPPageWebServer)
private:
- CString GetMPCDir();
- CString GetCurWebRoot();
- bool PickDir(CString& dir);
+ CString GetMPCDir();
+ CString GetCurWebRoot();
+ bool PickDir(CString& dir);
public:
- CPPageWebServer();
- virtual ~CPPageWebServer();
+ CPPageWebServer();
+ virtual ~CPPageWebServer();
- // Dialog Data
- enum { IDD = IDD_PPAGEWEBSERVER };
- BOOL m_fEnableWebServer;
- int m_nWebServerPort;
- CIntEdit m_nWebServerPortCtrl;
- CStaticLink m_launch;
- BOOL m_fWebServerPrintDebugInfo;
- BOOL m_fWebServerUseCompression;
- BOOL m_fWebServerLocalhostOnly;
- BOOL m_fWebRoot;
- CString m_WebRoot;
- CString m_WebServerCGI;
- CString m_WebDefIndex;
+ // Dialog Data
+ enum { IDD = IDD_PPAGEWEBSERVER };
+ BOOL m_fEnableWebServer;
+ int m_nWebServerPort;
+ CIntEdit m_nWebServerPortCtrl;
+ CStaticLink m_launch;
+ BOOL m_fWebServerPrintDebugInfo;
+ BOOL m_fWebServerUseCompression;
+ BOOL m_fWebServerLocalhostOnly;
+ BOOL m_fWebRoot;
+ CString m_WebRoot;
+ CString m_WebServerCGI;
+ CString m_WebDefIndex;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual BOOL OnApply();
- virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnApply();
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnEnChangeEdit1();
- afx_msg void OnBnClickedButton1();
- afx_msg void OnBnClickedButton2();
- afx_msg void OnUpdateButton2(CCmdUI* pCmdUI);
+ afx_msg void OnEnChangeEdit1();
+ afx_msg void OnBnClickedButton1();
+ afx_msg void OnBnClickedButton2();
+ afx_msg void OnUpdateButton2(CCmdUI* pCmdUI);
};
diff --git a/src/mpc-hc/PlayerBar.cpp b/src/mpc-hc/PlayerBar.cpp
index 92bcf6fcf..090c96756 100644
--- a/src/mpc-hc/PlayerBar.cpp
+++ b/src/mpc-hc/PlayerBar.cpp
@@ -39,65 +39,65 @@ END_MESSAGE_MAP()
BOOL CPlayerBar::Create(LPCTSTR lpszWindowName, CWnd* pParentWnd, UINT nID, UINT defDockBarID, CString const& strSettingName)
{
- m_defDockBarID = defDockBarID;
- m_strSettingName = strSettingName;
+ m_defDockBarID = defDockBarID;
+ m_strSettingName = strSettingName;
- return __super::Create(lpszWindowName, pParentWnd, nID);
+ return __super::Create(lpszWindowName, pParentWnd, nID);
}
-void CPlayerBar::LoadState(CFrameWnd *pParent)
+void CPlayerBar::LoadState(CFrameWnd* pParent)
{
- CWinApp* pApp = AfxGetApp();
-
- CRect r;
- pParent->GetWindowRect(r);
- CRect rDesktop;
- GetDesktopWindow()->GetWindowRect(&rDesktop);
-
- CString section = _T("ToolBars\\") + m_strSettingName;
-
- __super::LoadState(section + _T("\\State"));
-
- UINT dockBarID = pApp->GetProfileInt(section, _T("DockState"), m_defDockBarID);
-
- if (dockBarID == AFX_IDW_DOCKBAR_FLOAT) {
- CPoint p;
- p.x = pApp->GetProfileInt(section, _T("DockPosX"), r.right);
- p.y = pApp->GetProfileInt(section, _T("DockPosY"), r.top);
- if (p.x < rDesktop.left) {
- p.x = rDesktop.left;
- }
- if (p.y < rDesktop.top) {
- p.y = rDesktop.top;
- }
- if (p.x >= rDesktop.right) {
- p.x = rDesktop.right-1;
- }
- if (p.y >= rDesktop.bottom) {
- p.y = rDesktop.bottom-1;
- }
- pParent->FloatControlBar(this, p);
- } else {
- pParent->DockControlBar(this, dockBarID);
- }
+ CWinApp* pApp = AfxGetApp();
+
+ CRect r;
+ pParent->GetWindowRect(r);
+ CRect rDesktop;
+ GetDesktopWindow()->GetWindowRect(&rDesktop);
+
+ CString section = _T("ToolBars\\") + m_strSettingName;
+
+ __super::LoadState(section + _T("\\State"));
+
+ UINT dockBarID = pApp->GetProfileInt(section, _T("DockState"), m_defDockBarID);
+
+ if (dockBarID == AFX_IDW_DOCKBAR_FLOAT) {
+ CPoint p;
+ p.x = pApp->GetProfileInt(section, _T("DockPosX"), r.right);
+ p.y = pApp->GetProfileInt(section, _T("DockPosY"), r.top);
+ if (p.x < rDesktop.left) {
+ p.x = rDesktop.left;
+ }
+ if (p.y < rDesktop.top) {
+ p.y = rDesktop.top;
+ }
+ if (p.x >= rDesktop.right) {
+ p.x = rDesktop.right - 1;
+ }
+ if (p.y >= rDesktop.bottom) {
+ p.y = rDesktop.bottom - 1;
+ }
+ pParent->FloatControlBar(this, p);
+ } else {
+ pParent->DockControlBar(this, dockBarID);
+ }
}
void CPlayerBar::SaveState()
{
- CWinApp* pApp = AfxGetApp();
+ CWinApp* pApp = AfxGetApp();
- CString section = _T("ToolBars\\") + m_strSettingName;
+ CString section = _T("ToolBars\\") + m_strSettingName;
- __super::SaveState(section + _T("\\State"));
+ __super::SaveState(section + _T("\\State"));
- UINT dockBarID = GetParent()->GetDlgCtrlID();
+ UINT dockBarID = GetParent()->GetDlgCtrlID();
- if (dockBarID == AFX_IDW_DOCKBAR_FLOAT) {
- CRect r;
- GetParent()->GetParent()->GetWindowRect(r);
- pApp->WriteProfileInt(section, _T("DockPosX"), r.left);
- pApp->WriteProfileInt(section, _T("DockPosY"), r.top);
- }
+ if (dockBarID == AFX_IDW_DOCKBAR_FLOAT) {
+ CRect r;
+ GetParent()->GetParent()->GetWindowRect(r);
+ pApp->WriteProfileInt(section, _T("DockPosX"), r.left);
+ pApp->WriteProfileInt(section, _T("DockPosY"), r.top);
+ }
- pApp->WriteProfileInt(section, _T("DockState"), dockBarID);
+ pApp->WriteProfileInt(section, _T("DockState"), dockBarID);
}
diff --git a/src/mpc-hc/PlayerBar.h b/src/mpc-hc/PlayerBar.h
index eea7d7bd2..121dbe651 100644
--- a/src/mpc-hc/PlayerBar.h
+++ b/src/mpc-hc/PlayerBar.h
@@ -27,20 +27,20 @@
class CPlayerBar : public CSizingControlBarG
{
- DECLARE_DYNAMIC(CPlayerBar)
+ DECLARE_DYNAMIC(CPlayerBar)
protected :
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
- UINT m_defDockBarID;
- CString m_strSettingName;
+ UINT m_defDockBarID;
+ CString m_strSettingName;
public:
- CPlayerBar(void);
- virtual ~CPlayerBar(void);
+ CPlayerBar(void);
+ virtual ~CPlayerBar(void);
- BOOL Create(LPCTSTR lpszWindowName, CWnd* pParentWnd, UINT nID, UINT defDockBarID, CString const& strSettingName);
+ BOOL Create(LPCTSTR lpszWindowName, CWnd* pParentWnd, UINT nID, UINT defDockBarID, CString const& strSettingName);
- virtual void LoadState(CFrameWnd *pParent);
- virtual void SaveState();
+ virtual void LoadState(CFrameWnd* pParent);
+ virtual void SaveState();
};
diff --git a/src/mpc-hc/PlayerCaptureBar.cpp b/src/mpc-hc/PlayerCaptureBar.cpp
index 7ae41ba78..6eaf00618 100644
--- a/src/mpc-hc/PlayerCaptureBar.cpp
+++ b/src/mpc-hc/PlayerCaptureBar.cpp
@@ -40,33 +40,33 @@ CPlayerCaptureBar::~CPlayerCaptureBar()
BOOL CPlayerCaptureBar::Create(CWnd* pParentWnd, UINT defDockBarID)
{
- if (!__super::Create(ResStr(IDS_CAPTURE_SETTINGS), pParentWnd, ID_VIEW_CAPTURE, defDockBarID, _T("Capture Settings"))) {
- return FALSE;
- }
+ if (!__super::Create(ResStr(IDS_CAPTURE_SETTINGS), pParentWnd, ID_VIEW_CAPTURE, defDockBarID, _T("Capture Settings"))) {
+ return FALSE;
+ }
- m_capdlg.Create(this);
- m_capdlg.ShowWindow(SW_SHOWNORMAL);
+ m_capdlg.Create(this);
+ m_capdlg.ShowWindow(SW_SHOWNORMAL);
- CRect r;
- m_capdlg.GetWindowRect(r);
- m_szMinVert = m_szVert = r.Size();
- m_szMinHorz = m_szHorz = r.Size();
- m_szMinFloat = m_szFloat = r.Size();
- m_bFixedFloat = true;
- m_szFixedFloat = r.Size();
+ CRect r;
+ m_capdlg.GetWindowRect(r);
+ m_szMinVert = m_szVert = r.Size();
+ m_szMinHorz = m_szHorz = r.Size();
+ m_szMinFloat = m_szFloat = r.Size();
+ m_bFixedFloat = true;
+ m_szFixedFloat = r.Size();
- return TRUE;
+ return TRUE;
}
BOOL CPlayerCaptureBar::PreTranslateMessage(MSG* pMsg)
{
- if (IsWindow(pMsg->hwnd) && IsVisible() && pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST) {
- if (IsDialogMessage(pMsg)) {
- return TRUE;
- }
- }
+ if (IsWindow(pMsg->hwnd) && IsVisible() && pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST) {
+ if (IsDialogMessage(pMsg)) {
+ return TRUE;
+ }
+ }
- return __super::PreTranslateMessage(pMsg);
+ return __super::PreTranslateMessage(pMsg);
}
BEGIN_MESSAGE_MAP(CPlayerCaptureBar, CPlayerBar)
diff --git a/src/mpc-hc/PlayerCaptureBar.h b/src/mpc-hc/PlayerCaptureBar.h
index e90b9fa69..968ac2dbb 100644
--- a/src/mpc-hc/PlayerCaptureBar.h
+++ b/src/mpc-hc/PlayerCaptureBar.h
@@ -30,19 +30,19 @@
class CPlayerCaptureBar : public CPlayerBar
{
- DECLARE_DYNAMIC(CPlayerCaptureBar)
+ DECLARE_DYNAMIC(CPlayerCaptureBar)
public:
- CPlayerCaptureBar();
- virtual ~CPlayerCaptureBar();
+ CPlayerCaptureBar();
+ virtual ~CPlayerCaptureBar();
- BOOL Create(CWnd* pParentWnd, UINT defDockBarID);
+ BOOL Create(CWnd* pParentWnd, UINT defDockBarID);
public:
- CPlayerCaptureDialog m_capdlg;
+ CPlayerCaptureDialog m_capdlg;
protected:
- virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
};
diff --git a/src/mpc-hc/PlayerCaptureDialog.cpp b/src/mpc-hc/PlayerCaptureDialog.cpp
index 61765d005..60c267b64 100644
--- a/src/mpc-hc/PlayerCaptureDialog.cpp
+++ b/src/mpc-hc/PlayerCaptureDialog.cpp
@@ -34,1270 +34,1270 @@
static bool LoadMediaType(CStringW DisplayName, AM_MEDIA_TYPE** ppmt)
{
- bool fRet = false;
-
- if (!ppmt) {
- return fRet;
- }
-
- *ppmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
- if (!*ppmt) {
- return fRet;
- }
-
- memset(*ppmt, 0, sizeof(AM_MEDIA_TYPE));
-
- BYTE* pData;
- UINT len;
- if (AfxGetApp()->GetProfileBinary(IDS_RS_CAPTURE _T("\\") + CString(DisplayName), _T("MediaType"), &pData, &len)) {
- if ( len != sizeof(AM_MEDIA_TYPE) ) {
- delete [] pData;
- return fRet;
- }
- memcpy(*ppmt, pData, len);
- delete [] pData;
-
- (*ppmt)->cbFormat = 0;
- (*ppmt)->pbFormat = NULL;
-
- fRet = true;
-
- if (AfxGetApp()->GetProfileBinary(IDS_RS_CAPTURE _T("\\") + CString(DisplayName), _T("Format"), &pData, &len)) {
- if ( !len ) {
- delete [] pData;
- return fRet;
- }
- (*ppmt)->cbFormat = len;
- (*ppmt)->pbFormat = (BYTE*)CoTaskMemAlloc(len);
- memcpy((*ppmt)->pbFormat, pData, len);
- delete [] pData;
-
- }
- }
-
- return fRet;
+ bool fRet = false;
+
+ if (!ppmt) {
+ return fRet;
+ }
+
+ *ppmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
+ if (!*ppmt) {
+ return fRet;
+ }
+
+ memset(*ppmt, 0, sizeof(AM_MEDIA_TYPE));
+
+ BYTE* pData;
+ UINT len;
+ if (AfxGetApp()->GetProfileBinary(IDS_RS_CAPTURE _T("\\") + CString(DisplayName), _T("MediaType"), &pData, &len)) {
+ if (len != sizeof(AM_MEDIA_TYPE)) {
+ delete [] pData;
+ return fRet;
+ }
+ memcpy(*ppmt, pData, len);
+ delete [] pData;
+
+ (*ppmt)->cbFormat = 0;
+ (*ppmt)->pbFormat = NULL;
+
+ fRet = true;
+
+ if (AfxGetApp()->GetProfileBinary(IDS_RS_CAPTURE _T("\\") + CString(DisplayName), _T("Format"), &pData, &len)) {
+ if (!len) {
+ delete [] pData;
+ return fRet;
+ }
+ (*ppmt)->cbFormat = len;
+ (*ppmt)->pbFormat = (BYTE*)CoTaskMemAlloc(len);
+ memcpy((*ppmt)->pbFormat, pData, len);
+ delete [] pData;
+
+ }
+ }
+
+ return fRet;
}
static void SaveMediaType(CStringW DisplayName, AM_MEDIA_TYPE* pmt)
{
- if (DisplayName.IsEmpty() || !pmt) {
- return;
- }
+ if (DisplayName.IsEmpty() || !pmt) {
+ return;
+ }
- AfxGetApp()->WriteProfileBinary(IDS_RS_CAPTURE _T("\\") + CString(DisplayName), _T("MediaType"), (BYTE*)pmt, sizeof(AM_MEDIA_TYPE));
- AfxGetApp()->WriteProfileBinary(IDS_RS_CAPTURE _T("\\") + CString(DisplayName), _T("Format"), pmt->pbFormat, pmt->cbFormat);
+ AfxGetApp()->WriteProfileBinary(IDS_RS_CAPTURE _T("\\") + CString(DisplayName), _T("MediaType"), (BYTE*)pmt, sizeof(AM_MEDIA_TYPE));
+ AfxGetApp()->WriteProfileBinary(IDS_RS_CAPTURE _T("\\") + CString(DisplayName), _T("Format"), pmt->pbFormat, pmt->cbFormat);
}
static void LoadDefaultCodec(CAtlArray<Codec>& codecs, CComboBox& box, const GUID& cat)
{
- int len = box.GetCount();
- if (len >= 0) {
- box.SetCurSel(0);
- }
-
- if (cat == GUID_NULL) {
- return;
- }
-
- CString DisplayName = AfxGetApp()->GetProfileString(IDS_RS_CAPTURE _T("\\") + CStringFromGUID(cat), _T("DisplayName"));
-
- for (int i = 0; i < len; i++) {
- int iSel = box.GetItemData(i);
- if (iSel < 0) {
- continue;
- }
-
- Codec& c = codecs[iSel];
- if (DisplayName == c.DisplayName) {
- box.SetCurSel(i);
- if (!c.pBF) {
- c.pMoniker->BindToObject(NULL, NULL, __uuidof(IBaseFilter), (void**)&c.pBF);
- }
- break;
- }
- }
+ int len = box.GetCount();
+ if (len >= 0) {
+ box.SetCurSel(0);
+ }
+
+ if (cat == GUID_NULL) {
+ return;
+ }
+
+ CString DisplayName = AfxGetApp()->GetProfileString(IDS_RS_CAPTURE _T("\\") + CStringFromGUID(cat), _T("DisplayName"));
+
+ for (int i = 0; i < len; i++) {
+ int iSel = box.GetItemData(i);
+ if (iSel < 0) {
+ continue;
+ }
+
+ Codec& c = codecs[iSel];
+ if (DisplayName == c.DisplayName) {
+ box.SetCurSel(i);
+ if (!c.pBF) {
+ c.pMoniker->BindToObject(NULL, NULL, __uuidof(IBaseFilter), (void**)&c.pBF);
+ }
+ break;
+ }
+ }
}
static void SaveDefaultCodec(CAtlArray<Codec>& codecs, CComboBox& box, const GUID& cat)
{
- if (cat == GUID_NULL) {
- return;
- }
+ if (cat == GUID_NULL) {
+ return;
+ }
- CString guid = CStringFromGUID(cat);
+ CString guid = CStringFromGUID(cat);
- AfxGetApp()->WriteProfileString(IDS_RS_CAPTURE _T("\\") + guid, NULL, NULL);
+ AfxGetApp()->WriteProfileString(IDS_RS_CAPTURE _T("\\") + guid, NULL, NULL);
- int iSel = box.GetCurSel();
- if (iSel < 0) {
- return;
- }
- iSel = box.GetItemData(iSel);
- if (iSel < 0) {
- return;
- }
+ int iSel = box.GetCurSel();
+ if (iSel < 0) {
+ return;
+ }
+ iSel = box.GetItemData(iSel);
+ if (iSel < 0) {
+ return;
+ }
- Codec& codec = codecs[iSel];
+ Codec& codec = codecs[iSel];
- AfxGetApp()->WriteProfileString(IDS_RS_CAPTURE _T("\\") + guid, _T("DisplayName"), CString(codec.DisplayName));
+ AfxGetApp()->WriteProfileString(IDS_RS_CAPTURE _T("\\") + guid, _T("DisplayName"), CString(codec.DisplayName));
}
static void SetupDefaultCaps(AM_MEDIA_TYPE* pmt, VIDEO_STREAM_CONFIG_CAPS& caps)
{
- memset(&caps, 0, sizeof(caps));
-
- if (!pmt) {
- return;
- }
-
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
- UNREFERENCED_PARAMETER(vih);
-
- BITMAPINFOHEADER* bih = (pmt->formattype == FORMAT_VideoInfo)
- ? &((VIDEOINFOHEADER*)pmt->pbFormat)->bmiHeader
- : (pmt->formattype == FORMAT_VideoInfo2)
- ? &((VIDEOINFOHEADER2*)pmt->pbFormat)->bmiHeader
- : NULL;
- if (!bih) {
- return;
- }
-
- caps.guid = GUID_NULL;
- caps.VideoStandard = 0;
- caps.InputSize.cx = bih->biWidth;
- caps.InputSize.cy = abs(bih->biHeight);
- caps.MinCroppingSize = caps.MaxCroppingSize = caps.InputSize;
- caps.CropGranularityX = caps.CropGranularityY = 1;
- caps.CropAlignX = caps.CropAlignY = 1;
- caps.MinOutputSize = CSize(64, 64);
- caps.MaxOutputSize = CSize(768, 576);
- caps.OutputGranularityX = 16;
- caps.OutputGranularityY = 1;
- caps.StretchTapsX = caps.StretchTapsY = 0;
- caps.ShrinkTapsX = caps.ShrinkTapsY = 0;
- caps.MinFrameInterval = 100000i64;
- caps.MaxFrameInterval = 100000000i64;
- caps.MinBitsPerSecond = caps.MaxBitsPerSecond = 0;
+ memset(&caps, 0, sizeof(caps));
+
+ if (!pmt) {
+ return;
+ }
+
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
+ UNREFERENCED_PARAMETER(vih);
+
+ BITMAPINFOHEADER* bih = (pmt->formattype == FORMAT_VideoInfo)
+ ? &((VIDEOINFOHEADER*)pmt->pbFormat)->bmiHeader
+ : (pmt->formattype == FORMAT_VideoInfo2)
+ ? &((VIDEOINFOHEADER2*)pmt->pbFormat)->bmiHeader
+ : NULL;
+ if (!bih) {
+ return;
+ }
+
+ caps.guid = GUID_NULL;
+ caps.VideoStandard = 0;
+ caps.InputSize.cx = bih->biWidth;
+ caps.InputSize.cy = abs(bih->biHeight);
+ caps.MinCroppingSize = caps.MaxCroppingSize = caps.InputSize;
+ caps.CropGranularityX = caps.CropGranularityY = 1;
+ caps.CropAlignX = caps.CropAlignY = 1;
+ caps.MinOutputSize = CSize(64, 64);
+ caps.MaxOutputSize = CSize(768, 576);
+ caps.OutputGranularityX = 16;
+ caps.OutputGranularityY = 1;
+ caps.StretchTapsX = caps.StretchTapsY = 0;
+ caps.ShrinkTapsX = caps.ShrinkTapsY = 0;
+ caps.MinFrameInterval = 100000i64;
+ caps.MaxFrameInterval = 100000000i64;
+ caps.MinBitsPerSecond = caps.MaxBitsPerSecond = 0;
}
static void SetupDefaultCaps(AM_MEDIA_TYPE* pmt, AUDIO_STREAM_CONFIG_CAPS& caps)
{
- memset(&caps, 0, sizeof(caps));
+ memset(&caps, 0, sizeof(caps));
- if (!pmt) {
- return;
- }
+ if (!pmt) {
+ return;
+ }
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->pbFormat;
+ WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->pbFormat;
- caps.guid = GUID_NULL;
- caps.MinimumChannels = caps.MaximumChannels = wfe->nChannels;
- caps.ChannelsGranularity = 1;
- caps.MinimumBitsPerSample = caps.MaximumBitsPerSample = wfe->wBitsPerSample;
- caps.BitsPerSampleGranularity = 1;
- caps.MinimumSampleFrequency = caps.MaximumSampleFrequency = wfe->nSamplesPerSec;
- caps.SampleFrequencyGranularity = 1;
+ caps.guid = GUID_NULL;
+ caps.MinimumChannels = caps.MaximumChannels = wfe->nChannels;
+ caps.ChannelsGranularity = 1;
+ caps.MinimumBitsPerSample = caps.MaximumBitsPerSample = wfe->wBitsPerSample;
+ caps.BitsPerSampleGranularity = 1;
+ caps.MinimumSampleFrequency = caps.MaximumSampleFrequency = wfe->nSamplesPerSec;
+ caps.SampleFrequencyGranularity = 1;
}
template<class T>
static void SetupMediaTypes(IAMStreamConfig* pAMSC, CFormatArray<T>& tfa, CComboBox& type, CComboBox& dim, CMediaType& mt)
{
- tfa.RemoveAll();
- type.ResetContent();
- dim.ResetContent();
- type.EnableWindow(FALSE);
- dim.EnableWindow(FALSE);
-
- if (!pAMSC) {
- return;
- }
-
- AM_MEDIA_TYPE* pcurmt = NULL;
- pAMSC->GetFormat(&pcurmt);
-
- int iCount = 0, iSize;
- if (SUCCEEDED(pAMSC->GetNumberOfCapabilities(&iCount, &iSize))
- && iSize == sizeof(T) && iCount > 0) {
- for (int i = 0; i < iCount; i++) {
- T caps;
- AM_MEDIA_TYPE* pmt = NULL;
- if (SUCCEEDED(pAMSC->GetStreamCaps(i, &pmt, (BYTE*)&caps))) {
- tfa.AddFormat(pmt, caps);
- }
- }
-
- if (iSize == sizeof(VIDEO_STREAM_CONFIG_CAPS)) {
- for (size_t i = 0, cnt = tfa.GetCount(); i < cnt; i++) {
- if (tfa[i]->GetCount() != 1) {
- continue;
- }
-
- CFormatElem<T>* pfe = tfa[i]->GetAt(0);
-
- if (pfe->mt.formattype != FORMAT_VideoInfo
- && pfe->mt.formattype != FORMAT_VideoInfo2) {
- continue;
- }
-
- static SIZE presets[] = {
- {160, 120}, {192, 144},
- {320, 240}, {384, 288},
- {480, 240}, {512, 288},
- {480, 360}, {512, 384},
- {640, 240}, {768, 288},
- {640, 480}, {768, 576},
- {704, 240}, {704, 288},
- {704, 480}, {704, 576},
- {720, 240}, {720, 288},
- {720, 480}, {720, 576},
- {768, 240}, {768, 288},
- {768, 480}, {768, 576},
- };
-
- VIDEO_STREAM_CONFIG_CAPS* pcaps = (VIDEO_STREAM_CONFIG_CAPS*)&pfe->caps;
- BITMAPINFOHEADER bihCur;
- ExtractBIH(&pfe->mt, &bihCur);
-
- for (size_t j = 0; j < _countof(presets); j++) {
- if (presets[j].cx == bihCur.biWidth
- && presets[j].cy == abs(bihCur.biHeight)
- || presets[j].cx < pcaps->MinOutputSize.cx
- || presets[j].cx > pcaps->MaxOutputSize.cx
- || presets[j].cy < pcaps->MinOutputSize.cy
- || presets[j].cy > pcaps->MaxOutputSize.cy
- || presets[j].cx % pcaps->OutputGranularityX
- || presets[j].cy % pcaps->OutputGranularityY) {
- continue;
- }
-
- CMediaType mt = pfe->mt;
-
- if (mt.formattype == FORMAT_VideoInfo) {
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mt.pbFormat;
- if (!vih->bmiHeader.biHeight) {
- vih->bmiHeader.biHeight = 1;
- }
- vih->bmiHeader.biWidth = presets[j].cx;
- vih->bmiHeader.biHeight = presets[j].cy*(vih->bmiHeader.biHeight/vih->bmiHeader.biHeight);
- vih->bmiHeader.biSizeImage = presets[j].cx*presets[j].cy*vih->bmiHeader.biBitCount>>3;
-
- AM_MEDIA_TYPE* pmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
- CopyMediaType(pmt, &mt);
- tfa.AddFormat(pmt, pcaps, sizeof(*pcaps));
-
- if (presets[j].cx*3 != presets[j].cy*4) {
- int extra = mt.cbFormat - sizeof(VIDEOINFOHEADER);
- int bmiHeaderSize = sizeof(vih->bmiHeader) + extra;
- BYTE* pbmiHeader = DNew BYTE[bmiHeaderSize];
- memcpy(pbmiHeader, &vih->bmiHeader, bmiHeaderSize);
- mt.ReallocFormatBuffer(FIELD_OFFSET(VIDEOINFOHEADER2, bmiHeader) + bmiHeaderSize);
- VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.pbFormat;
- memcpy(&vih2->bmiHeader, pbmiHeader, bmiHeaderSize);
- delete [] pbmiHeader;
- vih2->dwInterlaceFlags = vih2->dwCopyProtectFlags = 0;
- vih2->dwReserved1 = vih2->dwReserved2 = 0;
- vih2->dwPictAspectRatioX = 4;
- vih2->dwPictAspectRatioY = 3;
-
- AM_MEDIA_TYPE* pmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
- CopyMediaType(pmt, &mt);
- tfa.AddFormat(pmt, pcaps, sizeof(*pcaps));
- }
- } else if (mt.formattype == FORMAT_VideoInfo2) {
- VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.pbFormat;
- if (!vih2->bmiHeader.biHeight) {
- vih2->bmiHeader.biHeight = 1;
- }
- vih2->bmiHeader.biWidth = presets[j].cx;
- vih2->bmiHeader.biHeight = presets[j].cy*(vih2->bmiHeader.biHeight/vih2->bmiHeader.biHeight);
- vih2->bmiHeader.biSizeImage = presets[j].cx*presets[j].cy*vih2->bmiHeader.biBitCount>>3;
- vih2->dwPictAspectRatioX = 4;
- vih2->dwPictAspectRatioY = 3;
-
- AM_MEDIA_TYPE* pmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
- CopyMediaType(pmt, &mt);
- tfa.AddFormat(pmt, pcaps, sizeof(*pcaps));
- }
- }
- }
- }
- }
-
- if (tfa.GetCount() == 0) {
- if (pcurmt && (pcurmt->majortype == MEDIATYPE_Video || pcurmt->majortype == MEDIATYPE_Audio)) {
- AM_MEDIA_TYPE* pmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
- CopyMediaType(pmt, pcurmt);
- T caps;
- SetupDefaultCaps(pmt, caps);
- tfa.AddFormat(pmt, caps);
- } else {
- mt.majortype = GUID_NULL;
- if (pcurmt) {
- DeleteMediaType(pcurmt);
- }
- return;
- }
- }
-
- for (size_t i = 0, cnt = tfa.GetCount(); i < cnt; i++) {
- CFormat<T>* pf = tfa[i];
- int j = type.AddString(pf->name);
- type.SetItemData(j, (DWORD_PTR)pf);
- }
-
- CFormat<T>* pf = NULL;
- CFormatElem<T>* pfe = NULL;
-
- if (!pcurmt) {
- pf = tfa[0];
- pfe = pf->GetAt(0);
- } else if (!tfa.FindFormat(pcurmt, NULL, &pf, &pfe) && !tfa.FindFormat(pcurmt, &pf)) {
- if (pcurmt) {
- DeleteMediaType(pcurmt);
- }
- return;
- }
-
- for (size_t i = 0, cnt = pf->GetCount(); i < cnt; i++) {
- CFormatElem<T>* pfe = pf->GetAt(i);
- int j = dim.AddString(tfa.MakeDimensionName(pfe));
- dim.SetItemData(j, (DWORD_PTR)pfe);
- }
-
- int iType = type.SetCurSel(type.FindStringExact(0, pf->name));
- if (iType < 0 && type.GetCount()) {
- type.SetCurSel(0);
- }
- int iDim = dim.SetCurSel(dim.FindStringExact(0, tfa.MakeDimensionName(pfe)));
- // if (iDim < 0 && dim.GetCount()) dim.SetCurSel(iDim = 0);
-
- CorrectComboListWidth(type);
- CorrectComboListWidth(dim);
-
- if (iDim >= 0) {
- mt = ((CFormatElem<T>*)dim.GetItemData(iDim))->mt;
- } else if (pcurmt) {
- mt = *pcurmt;
- }
-
- type.EnableWindow(type.GetCount() > 0);
- dim.EnableWindow(dim.GetCount() > 0);
-
- if (pcurmt) {
- DeleteMediaType(pcurmt);
- }
+ tfa.RemoveAll();
+ type.ResetContent();
+ dim.ResetContent();
+ type.EnableWindow(FALSE);
+ dim.EnableWindow(FALSE);
+
+ if (!pAMSC) {
+ return;
+ }
+
+ AM_MEDIA_TYPE* pcurmt = NULL;
+ pAMSC->GetFormat(&pcurmt);
+
+ int iCount = 0, iSize;
+ if (SUCCEEDED(pAMSC->GetNumberOfCapabilities(&iCount, &iSize))
+ && iSize == sizeof(T) && iCount > 0) {
+ for (int i = 0; i < iCount; i++) {
+ T caps;
+ AM_MEDIA_TYPE* pmt = NULL;
+ if (SUCCEEDED(pAMSC->GetStreamCaps(i, &pmt, (BYTE*)&caps))) {
+ tfa.AddFormat(pmt, caps);
+ }
+ }
+
+ if (iSize == sizeof(VIDEO_STREAM_CONFIG_CAPS)) {
+ for (size_t i = 0, cnt = tfa.GetCount(); i < cnt; i++) {
+ if (tfa[i]->GetCount() != 1) {
+ continue;
+ }
+
+ CFormatElem<T>* pfe = tfa[i]->GetAt(0);
+
+ if (pfe->mt.formattype != FORMAT_VideoInfo
+ && pfe->mt.formattype != FORMAT_VideoInfo2) {
+ continue;
+ }
+
+ static SIZE presets[] = {
+ {160, 120}, {192, 144},
+ {320, 240}, {384, 288},
+ {480, 240}, {512, 288},
+ {480, 360}, {512, 384},
+ {640, 240}, {768, 288},
+ {640, 480}, {768, 576},
+ {704, 240}, {704, 288},
+ {704, 480}, {704, 576},
+ {720, 240}, {720, 288},
+ {720, 480}, {720, 576},
+ {768, 240}, {768, 288},
+ {768, 480}, {768, 576},
+ };
+
+ VIDEO_STREAM_CONFIG_CAPS* pcaps = (VIDEO_STREAM_CONFIG_CAPS*)&pfe->caps;
+ BITMAPINFOHEADER bihCur;
+ ExtractBIH(&pfe->mt, &bihCur);
+
+ for (size_t j = 0; j < _countof(presets); j++) {
+ if (presets[j].cx == bihCur.biWidth
+ && presets[j].cy == abs(bihCur.biHeight)
+ || presets[j].cx < pcaps->MinOutputSize.cx
+ || presets[j].cx > pcaps->MaxOutputSize.cx
+ || presets[j].cy < pcaps->MinOutputSize.cy
+ || presets[j].cy > pcaps->MaxOutputSize.cy
+ || presets[j].cx % pcaps->OutputGranularityX
+ || presets[j].cy % pcaps->OutputGranularityY) {
+ continue;
+ }
+
+ CMediaType mt = pfe->mt;
+
+ if (mt.formattype == FORMAT_VideoInfo) {
+ VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mt.pbFormat;
+ if (!vih->bmiHeader.biHeight) {
+ vih->bmiHeader.biHeight = 1;
+ }
+ vih->bmiHeader.biWidth = presets[j].cx;
+ vih->bmiHeader.biHeight = presets[j].cy * (vih->bmiHeader.biHeight / vih->bmiHeader.biHeight);
+ vih->bmiHeader.biSizeImage = presets[j].cx * presets[j].cy * vih->bmiHeader.biBitCount >> 3;
+
+ AM_MEDIA_TYPE* pmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
+ CopyMediaType(pmt, &mt);
+ tfa.AddFormat(pmt, pcaps, sizeof(*pcaps));
+
+ if (presets[j].cx * 3 != presets[j].cy * 4) {
+ int extra = mt.cbFormat - sizeof(VIDEOINFOHEADER);
+ int bmiHeaderSize = sizeof(vih->bmiHeader) + extra;
+ BYTE* pbmiHeader = DNew BYTE[bmiHeaderSize];
+ memcpy(pbmiHeader, &vih->bmiHeader, bmiHeaderSize);
+ mt.ReallocFormatBuffer(FIELD_OFFSET(VIDEOINFOHEADER2, bmiHeader) + bmiHeaderSize);
+ VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.pbFormat;
+ memcpy(&vih2->bmiHeader, pbmiHeader, bmiHeaderSize);
+ delete [] pbmiHeader;
+ vih2->dwInterlaceFlags = vih2->dwCopyProtectFlags = 0;
+ vih2->dwReserved1 = vih2->dwReserved2 = 0;
+ vih2->dwPictAspectRatioX = 4;
+ vih2->dwPictAspectRatioY = 3;
+
+ AM_MEDIA_TYPE* pmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
+ CopyMediaType(pmt, &mt);
+ tfa.AddFormat(pmt, pcaps, sizeof(*pcaps));
+ }
+ } else if (mt.formattype == FORMAT_VideoInfo2) {
+ VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.pbFormat;
+ if (!vih2->bmiHeader.biHeight) {
+ vih2->bmiHeader.biHeight = 1;
+ }
+ vih2->bmiHeader.biWidth = presets[j].cx;
+ vih2->bmiHeader.biHeight = presets[j].cy * (vih2->bmiHeader.biHeight / vih2->bmiHeader.biHeight);
+ vih2->bmiHeader.biSizeImage = presets[j].cx * presets[j].cy * vih2->bmiHeader.biBitCount >> 3;
+ vih2->dwPictAspectRatioX = 4;
+ vih2->dwPictAspectRatioY = 3;
+
+ AM_MEDIA_TYPE* pmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
+ CopyMediaType(pmt, &mt);
+ tfa.AddFormat(pmt, pcaps, sizeof(*pcaps));
+ }
+ }
+ }
+ }
+ }
+
+ if (tfa.GetCount() == 0) {
+ if (pcurmt && (pcurmt->majortype == MEDIATYPE_Video || pcurmt->majortype == MEDIATYPE_Audio)) {
+ AM_MEDIA_TYPE* pmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
+ CopyMediaType(pmt, pcurmt);
+ T caps;
+ SetupDefaultCaps(pmt, caps);
+ tfa.AddFormat(pmt, caps);
+ } else {
+ mt.majortype = GUID_NULL;
+ if (pcurmt) {
+ DeleteMediaType(pcurmt);
+ }
+ return;
+ }
+ }
+
+ for (size_t i = 0, cnt = tfa.GetCount(); i < cnt; i++) {
+ CFormat<T>* pf = tfa[i];
+ int j = type.AddString(pf->name);
+ type.SetItemData(j, (DWORD_PTR)pf);
+ }
+
+ CFormat<T>* pf = NULL;
+ CFormatElem<T>* pfe = NULL;
+
+ if (!pcurmt) {
+ pf = tfa[0];
+ pfe = pf->GetAt(0);
+ } else if (!tfa.FindFormat(pcurmt, NULL, &pf, &pfe) && !tfa.FindFormat(pcurmt, &pf)) {
+ if (pcurmt) {
+ DeleteMediaType(pcurmt);
+ }
+ return;
+ }
+
+ for (size_t i = 0, cnt = pf->GetCount(); i < cnt; i++) {
+ CFormatElem<T>* pfe = pf->GetAt(i);
+ int j = dim.AddString(tfa.MakeDimensionName(pfe));
+ dim.SetItemData(j, (DWORD_PTR)pfe);
+ }
+
+ int iType = type.SetCurSel(type.FindStringExact(0, pf->name));
+ if (iType < 0 && type.GetCount()) {
+ type.SetCurSel(0);
+ }
+ int iDim = dim.SetCurSel(dim.FindStringExact(0, tfa.MakeDimensionName(pfe)));
+ // if (iDim < 0 && dim.GetCount()) dim.SetCurSel(iDim = 0);
+
+ CorrectComboListWidth(type);
+ CorrectComboListWidth(dim);
+
+ if (iDim >= 0) {
+ mt = ((CFormatElem<T>*)dim.GetItemData(iDim))->mt;
+ } else if (pcurmt) {
+ mt = *pcurmt;
+ }
+
+ type.EnableWindow(type.GetCount() > 0);
+ dim.EnableWindow(dim.GetCount() > 0);
+
+ if (pcurmt) {
+ DeleteMediaType(pcurmt);
+ }
}
template<class T>
static bool SetupDimension(CFormatArray<T>& tfa, CComboBox& type, CComboBox& dim)
{
- CString str;
- dim.GetWindowText(str);
+ CString str;
+ dim.GetWindowText(str);
- dim.ResetContent();
- dim.EnableWindow(FALSE);
+ dim.ResetContent();
+ dim.EnableWindow(FALSE);
- int iSel = type.GetCurSel();
- if (iSel < 0) {
- return false;
- }
+ int iSel = type.GetCurSel();
+ if (iSel < 0) {
+ return false;
+ }
- CFormat<T>* pf = (CFormat<T>*)type.GetItemData(iSel);
+ CFormat<T>* pf = (CFormat<T>*)type.GetItemData(iSel);
- for (int i = 0; i < (int)pf->GetCount(); i++) {
- CFormatElem<T>* pfe = pf->GetAt(i);
- dim.SetItemData(dim.AddString(tfa.MakeDimensionName(pfe)), (DWORD_PTR)pfe);
- }
+ for (int i = 0; i < (int)pf->GetCount(); i++) {
+ CFormatElem<T>* pfe = pf->GetAt(i);
+ dim.SetItemData(dim.AddString(tfa.MakeDimensionName(pfe)), (DWORD_PTR)pfe);
+ }
- CorrectComboListWidth(dim);
+ CorrectComboListWidth(dim);
- dim.SetCurSel(dim.FindStringExact(0, str));
- dim.EnableWindow(dim.GetCount() > 0);
+ dim.SetCurSel(dim.FindStringExact(0, str));
+ dim.EnableWindow(dim.GetCount() > 0);
- return (dim.GetCurSel() >= 0);
+ return (dim.GetCurSel() >= 0);
}
static void InitCodecList(CAtlArray<Codec>& codecs, CComboBox& box, const GUID& cat)
{
- codecs.RemoveAll();
- box.ResetContent();
- box.EnableWindow(FALSE);
+ codecs.RemoveAll();
+ box.ResetContent();
+ box.EnableWindow(FALSE);
- box.SetItemData(box.AddString(_T("Uncompressed")), (DWORD_PTR)-1);
+ box.SetItemData(box.AddString(_T("Uncompressed")), (DWORD_PTR) - 1);
- BeginEnumSysDev(cat, pMoniker) {
- Codec c;
+ BeginEnumSysDev(cat, pMoniker) {
+ Codec c;
- c.pMoniker = pMoniker;
- /*
- CComPtr<IBaseFilter> pBF;
- if (FAILED(pMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF)
- continue;
+ c.pMoniker = pMoniker;
+ /*
+ CComPtr<IBaseFilter> pBF;
+ if (FAILED(pMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF)
+ continue;
- c.pBF = pBF;
- */
- LPOLESTR strName = NULL;
- if (FAILED(pMoniker->GetDisplayName(NULL, NULL, &strName))) {
- continue;
- }
+ c.pBF = pBF;
+ */
+ LPOLESTR strName = NULL;
+ if (FAILED(pMoniker->GetDisplayName(NULL, NULL, &strName))) {
+ continue;
+ }
- c.DisplayName = strName;
- CoTaskMemFree(strName);
+ c.DisplayName = strName;
+ CoTaskMemFree(strName);
- CComPtr<IPropertyBag> pPB;
- pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
+ CComPtr<IPropertyBag> pPB;
+ pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
- CComVariant var;
- if (FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
- continue;
- }
+ CComVariant var;
+ if (FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
+ continue;
+ }
- c.FriendlyName = var.bstrVal;
+ c.FriendlyName = var.bstrVal;
- CStringW str = CStringW(c.DisplayName).MakeLower();
- if (str.Find(L"@device:dmo:") == 0) {
- c.FriendlyName = _T("(DMO) ") + c.FriendlyName;
- } else if (str.Find(L"@device:sw:") == 0) {
- c.FriendlyName = _T("(DS) ") + c.FriendlyName;
- } else if (str.Find(L"@device:cm:") == 0) {
- c.FriendlyName = _T("(VfW) ") + c.FriendlyName;
- }
+ CStringW str = CStringW(c.DisplayName).MakeLower();
+ if (str.Find(L"@device:dmo:") == 0) {
+ c.FriendlyName = _T("(DMO) ") + c.FriendlyName;
+ } else if (str.Find(L"@device:sw:") == 0) {
+ c.FriendlyName = _T("(DS) ") + c.FriendlyName;
+ } else if (str.Find(L"@device:cm:") == 0) {
+ c.FriendlyName = _T("(VfW) ") + c.FriendlyName;
+ }
- box.SetItemData(
- box.AddString(c.FriendlyName),
- (DWORD_PTR)codecs.Add(c));
- }
- EndEnumSysDev
+ box.SetItemData(
+ box.AddString(c.FriendlyName),
+ (DWORD_PTR)codecs.Add(c));
+ }
+ EndEnumSysDev
- box.EnableWindow(box.GetCount() > 1);
+ box.EnableWindow(box.GetCount() > 1);
- CorrectComboListWidth(box);
+ CorrectComboListWidth(box);
- LoadDefaultCodec(codecs, box, cat);
+ LoadDefaultCodec(codecs, box, cat);
}
static int ShowPPage(CAtlArray<Codec>& codecs, CComboBox& box, HWND hWnd = NULL)
{
- int iSel = box.GetCurSel();
- if (iSel < 0) {
- return -1;
- }
-
- iSel = box.GetItemData(iSel);
- if (iSel < 0) {
- return -1;
- }
-
- Codec& c = codecs[iSel];
-
- if (!c.pBF) {
- c.pMoniker->BindToObject(NULL, NULL, __uuidof(IBaseFilter), (void**)&c.pBF);
- }
-
- if (CComQIPtr<ISpecifyPropertyPages> pSPP = c.pBF) {
- CAUUID caGUID;
- caGUID.pElems = NULL;
- if (SUCCEEDED(pSPP->GetPages(&caGUID))) {
- IUnknown* lpUnk = NULL;
- pSPP.QueryInterface(&lpUnk);
- OleCreatePropertyFrame(
- hWnd, 0, 0, CStringW(c.FriendlyName),
- 1, (IUnknown**)&lpUnk,
- caGUID.cElems, caGUID.pElems,
- 0, 0, NULL);
- lpUnk->Release();
-
- if (caGUID.pElems) {
- CoTaskMemFree(caGUID.pElems);
- }
- }
- } else if (CComQIPtr<IAMVfwCompressDialogs> pAMVfWCD = c.pBF) {
- if (pAMVfWCD->ShowDialog(VfwCompressDialog_QueryConfig, NULL) == S_OK) {
- pAMVfWCD->ShowDialog(VfwCompressDialog_Config, hWnd);
- }
- }
-
- return iSel;
+ int iSel = box.GetCurSel();
+ if (iSel < 0) {
+ return -1;
+ }
+
+ iSel = box.GetItemData(iSel);
+ if (iSel < 0) {
+ return -1;
+ }
+
+ Codec& c = codecs[iSel];
+
+ if (!c.pBF) {
+ c.pMoniker->BindToObject(NULL, NULL, __uuidof(IBaseFilter), (void**)&c.pBF);
+ }
+
+ if (CComQIPtr<ISpecifyPropertyPages> pSPP = c.pBF) {
+ CAUUID caGUID;
+ caGUID.pElems = NULL;
+ if (SUCCEEDED(pSPP->GetPages(&caGUID))) {
+ IUnknown* lpUnk = NULL;
+ pSPP.QueryInterface(&lpUnk);
+ OleCreatePropertyFrame(
+ hWnd, 0, 0, CStringW(c.FriendlyName),
+ 1, (IUnknown**)&lpUnk,
+ caGUID.cElems, caGUID.pElems,
+ 0, 0, NULL);
+ lpUnk->Release();
+
+ if (caGUID.pElems) {
+ CoTaskMemFree(caGUID.pElems);
+ }
+ }
+ } else if (CComQIPtr<IAMVfwCompressDialogs> pAMVfWCD = c.pBF) {
+ if (pAMVfWCD->ShowDialog(VfwCompressDialog_QueryConfig, NULL) == S_OK) {
+ pAMVfWCD->ShowDialog(VfwCompressDialog_Config, hWnd);
+ }
+ }
+
+ return iSel;
}
// CPlayerCaptureDialog dialog
//IMPLEMENT_DYNAMIC(CPlayerCaptureDialog, CResizableDialog)
CPlayerCaptureDialog::CPlayerCaptureDialog()
- : CResizableDialog(CPlayerCaptureDialog::IDD, NULL)
- , m_vidfps(0)
- , m_file(_T(""))
- , m_fVidOutput(TRUE)
- , m_fAudOutput(TRUE)
- , m_fVidPreview(FALSE)
- , m_fAudPreview(FALSE)
- , m_nVidBuffers(0)
- , m_nAudBuffers(0)
- , m_pVidBuffer(NULL)
- , m_pAudBuffer(NULL)
- , m_fSepAudio(FALSE)
- , m_muxtype(0)
+ : CResizableDialog(CPlayerCaptureDialog::IDD, NULL)
+ , m_vidfps(0)
+ , m_file(_T(""))
+ , m_fVidOutput(TRUE)
+ , m_fAudOutput(TRUE)
+ , m_fVidPreview(FALSE)
+ , m_fAudPreview(FALSE)
+ , m_nVidBuffers(0)
+ , m_nAudBuffers(0)
+ , m_pVidBuffer(NULL)
+ , m_pAudBuffer(NULL)
+ , m_fSepAudio(FALSE)
+ , m_muxtype(0)
{
}
CPlayerCaptureDialog::~CPlayerCaptureDialog()
{
- EmptyVideo();
- EmptyAudio();
+ EmptyVideo();
+ EmptyAudio();
}
BOOL CPlayerCaptureDialog::Create(CWnd* pParent)
{
- if (!__super::Create(IDD, pParent)) {
- return FALSE;
- }
+ if (!__super::Create(IDD, pParent)) {
+ return FALSE;
+ }
- EmptyVideo();
- EmptyAudio();
+ EmptyVideo();
+ EmptyAudio();
- return TRUE;
+ return TRUE;
}
void CPlayerCaptureDialog::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_COMBO4, m_vidinput);
- DDX_Control(pDX, IDC_COMBO1, m_vidtype);
- DDX_Control(pDX, IDC_COMBO5, m_viddimension);
- DDX_Control(pDX, IDC_SPIN1, m_vidhor);
- DDX_Control(pDX, IDC_SPIN2, m_vidver);
- DDX_Control(pDX, IDC_EDIT1, m_vidhoredit);
- DDX_Control(pDX, IDC_EDIT2, m_vidveredit);
- DDX_Control(pDX, IDC_EDIT3, m_vidfpsedit);
- DDX_Control(pDX, IDC_BUTTON1, m_vidsetres);
- DDX_Control(pDX, IDC_COMBO3, m_audinput);
- DDX_Control(pDX, IDC_COMBO2, m_audtype);
- DDX_Control(pDX, IDC_COMBO6, m_auddimension);
- DDX_Control(pDX, IDC_COMBO7, m_vidcodec);
- DDX_Control(pDX, IDC_COMBO9, m_vidcodectype);
- DDX_Control(pDX, IDC_COMBO10, m_vidcodecdimension);
- DDX_Check(pDX, IDC_CHECK1, m_fVidOutput);
- DDX_Control(pDX, IDC_CHECK1, m_vidoutput);
- DDX_Check(pDX, IDC_CHECK2, m_fVidPreview);
- DDX_Control(pDX, IDC_CHECK2, m_vidpreview);
- DDX_Control(pDX, IDC_COMBO8, m_audcodec);
- DDX_Control(pDX, IDC_COMBO12, m_audcodectype);
- DDX_Control(pDX, IDC_COMBO11, m_audcodecdimension);
- DDX_Check(pDX, IDC_CHECK3, m_fAudOutput);
- DDX_Control(pDX, IDC_CHECK3, m_audoutput);
- DDX_Check(pDX, IDC_CHECK4, m_fAudPreview);
- DDX_Control(pDX, IDC_CHECK4, m_audpreview);
- DDX_Text(pDX, IDC_EDIT4, m_file);
- DDX_Control(pDX, IDC_BUTTON2, m_recordbtn);
- DDX_Text(pDX, IDC_EDIT5, m_nVidBuffers);
- DDX_Text(pDX, IDC_EDIT6, m_nAudBuffers);
- DDX_Check(pDX, IDC_CHECK5, m_fSepAudio);
- DDX_CBIndex(pDX, IDC_COMBO14, m_muxtype);
- DDX_Control(pDX, IDC_COMBO14, m_muxctrl);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_COMBO4, m_vidinput);
+ DDX_Control(pDX, IDC_COMBO1, m_vidtype);
+ DDX_Control(pDX, IDC_COMBO5, m_viddimension);
+ DDX_Control(pDX, IDC_SPIN1, m_vidhor);
+ DDX_Control(pDX, IDC_SPIN2, m_vidver);
+ DDX_Control(pDX, IDC_EDIT1, m_vidhoredit);
+ DDX_Control(pDX, IDC_EDIT2, m_vidveredit);
+ DDX_Control(pDX, IDC_EDIT3, m_vidfpsedit);
+ DDX_Control(pDX, IDC_BUTTON1, m_vidsetres);
+ DDX_Control(pDX, IDC_COMBO3, m_audinput);
+ DDX_Control(pDX, IDC_COMBO2, m_audtype);
+ DDX_Control(pDX, IDC_COMBO6, m_auddimension);
+ DDX_Control(pDX, IDC_COMBO7, m_vidcodec);
+ DDX_Control(pDX, IDC_COMBO9, m_vidcodectype);
+ DDX_Control(pDX, IDC_COMBO10, m_vidcodecdimension);
+ DDX_Check(pDX, IDC_CHECK1, m_fVidOutput);
+ DDX_Control(pDX, IDC_CHECK1, m_vidoutput);
+ DDX_Check(pDX, IDC_CHECK2, m_fVidPreview);
+ DDX_Control(pDX, IDC_CHECK2, m_vidpreview);
+ DDX_Control(pDX, IDC_COMBO8, m_audcodec);
+ DDX_Control(pDX, IDC_COMBO12, m_audcodectype);
+ DDX_Control(pDX, IDC_COMBO11, m_audcodecdimension);
+ DDX_Check(pDX, IDC_CHECK3, m_fAudOutput);
+ DDX_Control(pDX, IDC_CHECK3, m_audoutput);
+ DDX_Check(pDX, IDC_CHECK4, m_fAudPreview);
+ DDX_Control(pDX, IDC_CHECK4, m_audpreview);
+ DDX_Text(pDX, IDC_EDIT4, m_file);
+ DDX_Control(pDX, IDC_BUTTON2, m_recordbtn);
+ DDX_Text(pDX, IDC_EDIT5, m_nVidBuffers);
+ DDX_Text(pDX, IDC_EDIT6, m_nAudBuffers);
+ DDX_Check(pDX, IDC_CHECK5, m_fSepAudio);
+ DDX_CBIndex(pDX, IDC_COMBO14, m_muxtype);
+ DDX_Control(pDX, IDC_COMBO14, m_muxctrl);
}
BOOL CPlayerCaptureDialog::PreTranslateMessage(MSG* pMsg)
{
- if (pMsg->message == WM_KEYDOWN) {
- if (pMsg->wParam == VK_RETURN) {
- CWnd* pFocused = GetFocus();
- if (pFocused && pFocused->m_hWnd == m_vidfpsedit.m_hWnd) {
- UpdateGraph();
- }
- }
- }
-
- return __super::PreTranslateMessage(pMsg);
+ if (pMsg->message == WM_KEYDOWN) {
+ if (pMsg->wParam == VK_RETURN) {
+ CWnd* pFocused = GetFocus();
+ if (pFocused && pFocused->m_hWnd == m_vidfpsedit.m_hWnd) {
+ UpdateGraph();
+ }
+ }
+ }
+
+ return __super::PreTranslateMessage(pMsg);
}
void CPlayerCaptureDialog::EmptyVideo()
{
- // first save channel from previous session
-
- if (m_pAMTuner && !m_VidDisplayName.IsEmpty()) {
- long lChannel = 0, lVivSub = 0, lAudSub = 0;
- m_pAMTuner->get_Channel(&lChannel, &lVivSub, &lAudSub);
- AfxGetApp()->WriteProfileInt(IDS_RS_CAPTURE _T("\\") + CString(m_VidDisplayName), _T("Channel"), lChannel);
- }
-
- //
-
- m_vfa.RemoveAll();
-
- m_pAMXB = NULL;
- m_pAMTuner = NULL;
- m_pAMVSC = NULL;
-
- if (IsWindow(m_hWnd)) {
- m_vidinput.ResetContent();
- m_vidinput.EnableWindow(FALSE);
- m_vidtype.ResetContent();
- m_vidtype.EnableWindow(FALSE);
- m_viddimension.ResetContent();
- m_viddimension.EnableWindow(FALSE);
- m_vidhor.EnableWindow(FALSE);
- m_vidver.EnableWindow(FALSE);
- m_vidhoredit.EnableWindow(FALSE);
- m_vidveredit.EnableWindow(FALSE);
- m_vidfpsedit.EnableWindow(FALSE);
- m_vidfps = 0;
- m_vidsetres.EnableWindow(FALSE);
- UpdateData(FALSE);
- }
+ // first save channel from previous session
+
+ if (m_pAMTuner && !m_VidDisplayName.IsEmpty()) {
+ long lChannel = 0, lVivSub = 0, lAudSub = 0;
+ m_pAMTuner->get_Channel(&lChannel, &lVivSub, &lAudSub);
+ AfxGetApp()->WriteProfileInt(IDS_RS_CAPTURE _T("\\") + CString(m_VidDisplayName), _T("Channel"), lChannel);
+ }
+
+ //
+
+ m_vfa.RemoveAll();
+
+ m_pAMXB = NULL;
+ m_pAMTuner = NULL;
+ m_pAMVSC = NULL;
+
+ if (IsWindow(m_hWnd)) {
+ m_vidinput.ResetContent();
+ m_vidinput.EnableWindow(FALSE);
+ m_vidtype.ResetContent();
+ m_vidtype.EnableWindow(FALSE);
+ m_viddimension.ResetContent();
+ m_viddimension.EnableWindow(FALSE);
+ m_vidhor.EnableWindow(FALSE);
+ m_vidver.EnableWindow(FALSE);
+ m_vidhoredit.EnableWindow(FALSE);
+ m_vidveredit.EnableWindow(FALSE);
+ m_vidfpsedit.EnableWindow(FALSE);
+ m_vidfps = 0;
+ m_vidsetres.EnableWindow(FALSE);
+ UpdateData(FALSE);
+ }
}
void CPlayerCaptureDialog::EmptyAudio()
{
- m_afa.RemoveAll();
-
- m_pAMASC = NULL;
- m_pAMAIM.RemoveAll();
-
- if (IsWindow(m_hWnd)) {
- m_audinput.ResetContent();
- m_audinput.EnableWindow(FALSE);
- m_audtype.ResetContent();
- m_audtype.EnableWindow(FALSE);
- m_auddimension.ResetContent();
- m_auddimension.EnableWindow(FALSE);
- UpdateData(FALSE);
- }
+ m_afa.RemoveAll();
+
+ m_pAMASC = NULL;
+ m_pAMAIM.RemoveAll();
+
+ if (IsWindow(m_hWnd)) {
+ m_audinput.ResetContent();
+ m_audinput.EnableWindow(FALSE);
+ m_audtype.ResetContent();
+ m_audtype.EnableWindow(FALSE);
+ m_auddimension.ResetContent();
+ m_auddimension.EnableWindow(FALSE);
+ UpdateData(FALSE);
+ }
}
void CPlayerCaptureDialog::UpdateMediaTypes()
{
- UpdateData();
-
- // fps
-
- CString fps;
- m_vidfpsedit.GetWindowText(fps);
- if (!fps.IsEmpty()) {
- float ffps;
- _stscanf_s(fps, _T("%f"), &ffps);
- if (ffps > 0) {
- m_vidfps = ffps;
- }
- }
-
- // video
-
- {
- AM_MEDIA_TYPE* pmt = NULL;
- VIDEO_STREAM_CONFIG_CAPS* pcaps = NULL;
-
- int i = m_viddimension.GetCurSel();
- if (i >= 0) {
- pmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
- CopyMediaType(pmt, &((CVidFormatElem*)m_viddimension.GetItemData(i))->mt);
- pcaps = &((CVidFormatElem*)m_viddimension.GetItemData(i))->caps;
- } else if (m_pAMVSC) {
- m_pAMVSC->GetFormat(&pmt);
- }
-
- if (pmt) {
- if (m_vidfps > 0) {
- REFERENCE_TIME atpf = (REFERENCE_TIME)(10000000.0 / m_vidfps);
-
- if (pcaps) {
- // FIXME: some drivers do not set the interval right and they still accept the preferable but unfortunately out-of-range fps
- // atpf = min(max(atpf, pcaps->MinFrameInterval), pcaps->MaxFrameInterval);
- }
-
- if (pmt->formattype == FORMAT_VideoInfo) {
- ((VIDEOINFOHEADER*)pmt->pbFormat)->AvgTimePerFrame = atpf;
- } else if (pmt->formattype == FORMAT_VideoInfo2) {
- ((VIDEOINFOHEADER2*)pmt->pbFormat)->AvgTimePerFrame = atpf;
- }
- }
-
- BITMAPINFOHEADER* bih = (pmt->formattype == FORMAT_VideoInfo)
- ? &((VIDEOINFOHEADER*)pmt->pbFormat)->bmiHeader
- : (pmt->formattype == FORMAT_VideoInfo2)
- ? &((VIDEOINFOHEADER2*)pmt->pbFormat)->bmiHeader
- : NULL;
- if (bih) {
- bih->biWidth = m_vidhor.GetPos();
- bih->biHeight = m_vidver.GetPos();
- bih->biSizeImage = bih->biWidth*bih->biHeight*bih->biBitCount>>3;
- }
- SaveMediaType(m_VidDisplayName, pmt);
-
- m_mtv = *pmt;
- DeleteMediaType(pmt);
- }
- }
-
- // audio
-
- {
- AM_MEDIA_TYPE* pmt = NULL;
-
- int i = m_auddimension.GetCurSel();
- if (i >= 0) {
- pmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
- CopyMediaType(pmt, &((CAudFormatElem*)m_auddimension.GetItemData(i))->mt);
- } else if (m_pAMASC) {
- m_pAMASC->GetFormat(&pmt);
- }
-
- if (pmt) {
- SaveMediaType(m_AudDisplayName, pmt);
-
- m_mta = *pmt;
- DeleteMediaType(pmt);
- }
- }
+ UpdateData();
+
+ // fps
+
+ CString fps;
+ m_vidfpsedit.GetWindowText(fps);
+ if (!fps.IsEmpty()) {
+ float ffps;
+ _stscanf_s(fps, _T("%f"), &ffps);
+ if (ffps > 0) {
+ m_vidfps = ffps;
+ }
+ }
+
+ // video
+
+ {
+ AM_MEDIA_TYPE* pmt = NULL;
+ VIDEO_STREAM_CONFIG_CAPS* pcaps = NULL;
+
+ int i = m_viddimension.GetCurSel();
+ if (i >= 0) {
+ pmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
+ CopyMediaType(pmt, &((CVidFormatElem*)m_viddimension.GetItemData(i))->mt);
+ pcaps = &((CVidFormatElem*)m_viddimension.GetItemData(i))->caps;
+ } else if (m_pAMVSC) {
+ m_pAMVSC->GetFormat(&pmt);
+ }
+
+ if (pmt) {
+ if (m_vidfps > 0) {
+ REFERENCE_TIME atpf = (REFERENCE_TIME)(10000000.0 / m_vidfps);
+
+ if (pcaps) {
+ // FIXME: some drivers do not set the interval right and they still accept the preferable but unfortunately out-of-range fps
+ // atpf = min(max(atpf, pcaps->MinFrameInterval), pcaps->MaxFrameInterval);
+ }
+
+ if (pmt->formattype == FORMAT_VideoInfo) {
+ ((VIDEOINFOHEADER*)pmt->pbFormat)->AvgTimePerFrame = atpf;
+ } else if (pmt->formattype == FORMAT_VideoInfo2) {
+ ((VIDEOINFOHEADER2*)pmt->pbFormat)->AvgTimePerFrame = atpf;
+ }
+ }
+
+ BITMAPINFOHEADER* bih = (pmt->formattype == FORMAT_VideoInfo)
+ ? &((VIDEOINFOHEADER*)pmt->pbFormat)->bmiHeader
+ : (pmt->formattype == FORMAT_VideoInfo2)
+ ? &((VIDEOINFOHEADER2*)pmt->pbFormat)->bmiHeader
+ : NULL;
+ if (bih) {
+ bih->biWidth = m_vidhor.GetPos();
+ bih->biHeight = m_vidver.GetPos();
+ bih->biSizeImage = bih->biWidth * bih->biHeight * bih->biBitCount >> 3;
+ }
+ SaveMediaType(m_VidDisplayName, pmt);
+
+ m_mtv = *pmt;
+ DeleteMediaType(pmt);
+ }
+ }
+
+ // audio
+
+ {
+ AM_MEDIA_TYPE* pmt = NULL;
+
+ int i = m_auddimension.GetCurSel();
+ if (i >= 0) {
+ pmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
+ CopyMediaType(pmt, &((CAudFormatElem*)m_auddimension.GetItemData(i))->mt);
+ } else if (m_pAMASC) {
+ m_pAMASC->GetFormat(&pmt);
+ }
+
+ if (pmt) {
+ SaveMediaType(m_AudDisplayName, pmt);
+
+ m_mta = *pmt;
+ DeleteMediaType(pmt);
+ }
+ }
}
void CPlayerCaptureDialog::UpdateUserDefinableControls()
{
- int iSel = m_viddimension.GetCurSel();
- if (iSel < 0) {
- return;
- }
-
- CVidFormatElem* pvfe = (CVidFormatElem*)m_viddimension.GetItemData(iSel);
- if (!pvfe) {
- return;
- }
-
- if (!m_pAMVSC) {
- return;
- }
-
- AM_MEDIA_TYPE* pmt = NULL;
- m_pAMVSC->GetFormat(&pmt);
- if (!pmt) {
- return;
- }
-
- BITMAPINFOHEADER* bih = (pmt->formattype == FORMAT_VideoInfo)
- ? &((VIDEOINFOHEADER*)pmt->pbFormat)->bmiHeader
- : (pmt->formattype == FORMAT_VideoInfo2)
- ? &((VIDEOINFOHEADER2*)pmt->pbFormat)->bmiHeader
- : NULL;
-
- if (!bih) {
- return;
- }
-
- UDACCEL ua[3] = {{0,0},{2,0},{4,0}};
-
- int w = m_vidhor.GetPos(), h = m_vidver.GetPos();
- UNREFERENCED_PARAMETER(w);
- UNREFERENCED_PARAMETER(h);
-
- m_vidhor.SetRange((short)pvfe->caps.MinOutputSize.cx, (short)pvfe->caps.MaxOutputSize.cx);
- /* if (bih->biCompression == mmioFOURCC('Y','U','Y','2')) // FIXME: bt8x8 drivers seem to crop the right side in yuv2 mode if the width is not dividable by 64
- pvfe->caps.OutputGranularityX = 64;
- */
- ua[0].nInc = pvfe->caps.OutputGranularityX;
- ua[1].nInc = pvfe->caps.OutputGranularityX*2;
- ua[2].nInc = pvfe->caps.OutputGranularityX*4;
- m_vidhor.SetAccel(3, ua);
-
- m_vidver.SetRange((short)pvfe->caps.MinOutputSize.cy, (short)pvfe->caps.MaxOutputSize.cy);
- ua[0].nInc = pvfe->caps.OutputGranularityY;
- ua[1].nInc = pvfe->caps.OutputGranularityY*2;
- ua[2].nInc = pvfe->caps.OutputGranularityY*4;
- m_vidver.SetAccel(3, ua);
-
- m_vidhor.SetPos(bih->biWidth);
- m_vidver.SetPos(abs(bih->biHeight));
-
- CString fps;
- fps.Format(_T("%.4f"), (float)(10000000.0 / ((VIDEOINFOHEADER*)pmt->pbFormat)->AvgTimePerFrame));
- m_vidfpsedit.SetWindowText(fps);
-
- DeleteMediaType(pmt);
+ int iSel = m_viddimension.GetCurSel();
+ if (iSel < 0) {
+ return;
+ }
+
+ CVidFormatElem* pvfe = (CVidFormatElem*)m_viddimension.GetItemData(iSel);
+ if (!pvfe) {
+ return;
+ }
+
+ if (!m_pAMVSC) {
+ return;
+ }
+
+ AM_MEDIA_TYPE* pmt = NULL;
+ m_pAMVSC->GetFormat(&pmt);
+ if (!pmt) {
+ return;
+ }
+
+ BITMAPINFOHEADER* bih = (pmt->formattype == FORMAT_VideoInfo)
+ ? &((VIDEOINFOHEADER*)pmt->pbFormat)->bmiHeader
+ : (pmt->formattype == FORMAT_VideoInfo2)
+ ? &((VIDEOINFOHEADER2*)pmt->pbFormat)->bmiHeader
+ : NULL;
+
+ if (!bih) {
+ return;
+ }
+
+ UDACCEL ua[3] = {{0, 0}, {2, 0}, {4, 0}};
+
+ int w = m_vidhor.GetPos(), h = m_vidver.GetPos();
+ UNREFERENCED_PARAMETER(w);
+ UNREFERENCED_PARAMETER(h);
+
+ m_vidhor.SetRange((short)pvfe->caps.MinOutputSize.cx, (short)pvfe->caps.MaxOutputSize.cx);
+ /* if (bih->biCompression == mmioFOURCC('Y','U','Y','2')) // FIXME: bt8x8 drivers seem to crop the right side in yuv2 mode if the width is not dividable by 64
+ pvfe->caps.OutputGranularityX = 64;
+ */
+ ua[0].nInc = pvfe->caps.OutputGranularityX;
+ ua[1].nInc = pvfe->caps.OutputGranularityX * 2;
+ ua[2].nInc = pvfe->caps.OutputGranularityX * 4;
+ m_vidhor.SetAccel(3, ua);
+
+ m_vidver.SetRange((short)pvfe->caps.MinOutputSize.cy, (short)pvfe->caps.MaxOutputSize.cy);
+ ua[0].nInc = pvfe->caps.OutputGranularityY;
+ ua[1].nInc = pvfe->caps.OutputGranularityY * 2;
+ ua[2].nInc = pvfe->caps.OutputGranularityY * 4;
+ m_vidver.SetAccel(3, ua);
+
+ m_vidhor.SetPos(bih->biWidth);
+ m_vidver.SetPos(abs(bih->biHeight));
+
+ CString fps;
+ fps.Format(_T("%.4f"), (float)(10000000.0 / ((VIDEOINFOHEADER*)pmt->pbFormat)->AvgTimePerFrame));
+ m_vidfpsedit.SetWindowText(fps);
+
+ DeleteMediaType(pmt);
}
void CPlayerCaptureDialog::UpdateVideoCodec()
{
- int iSel = m_vidcodec.GetCurSel();
- if (iSel >= 0) {
- iSel = m_vidcodec.GetItemData(iSel);
- }
+ int iSel = m_vidcodec.GetCurSel();
+ if (iSel >= 0) {
+ iSel = m_vidcodec.GetItemData(iSel);
+ }
- m_pVidEnc = iSel < 0 ? NULL : m_pVidEncArray[iSel].pBF;
- m_pVidEncMoniker = iSel < 0 ? NULL : m_pVidEncArray[iSel].pMoniker;
+ m_pVidEnc = iSel < 0 ? NULL : m_pVidEncArray[iSel].pBF;
+ m_pVidEncMoniker = iSel < 0 ? NULL : m_pVidEncArray[iSel].pMoniker;
- // CString DisplayName = iSel < 0 ? _T("") : CString(m_pVidEncArray[iSel].DisplayName.m_str);
- CComQIPtr<IAMStreamConfig> pAMSC = GetFirstPin(m_pVidEnc, PINDIR_OUTPUT);
+ // CString DisplayName = iSel < 0 ? _T("") : CString(m_pVidEncArray[iSel].DisplayName.m_str);
+ CComQIPtr<IAMStreamConfig> pAMSC = GetFirstPin(m_pVidEnc, PINDIR_OUTPUT);
- SetupMediaTypes(pAMSC, m_vcfa, m_vidcodectype, m_vidcodecdimension, m_mtcv);
+ SetupMediaTypes(pAMSC, m_vcfa, m_vidcodectype, m_vidcodecdimension, m_mtcv);
- SaveDefaultCodec(m_pVidEncArray, m_vidcodec, CLSID_VideoCompressorCategory);
+ SaveDefaultCodec(m_pVidEncArray, m_vidcodec, CLSID_VideoCompressorCategory);
- // SaveMediaType(DisplayName, &m_mtcv);
+ // SaveMediaType(DisplayName, &m_mtcv);
}
void CPlayerCaptureDialog::UpdateAudioCodec()
{
- int iSel = m_audcodec.GetCurSel();
- if (iSel >= 0) {
- iSel = m_audcodec.GetItemData(iSel);
- }
+ int iSel = m_audcodec.GetCurSel();
+ if (iSel >= 0) {
+ iSel = m_audcodec.GetItemData(iSel);
+ }
- m_pAudEnc = iSel < 0 ? NULL : m_pAudEncArray[iSel].pBF;
- m_pAudEncMoniker = iSel < 0 ? NULL : m_pAudEncArray[iSel].pMoniker;
+ m_pAudEnc = iSel < 0 ? NULL : m_pAudEncArray[iSel].pBF;
+ m_pAudEncMoniker = iSel < 0 ? NULL : m_pAudEncArray[iSel].pMoniker;
- // CString DisplayName = iSel < 0 ? _T("") : CString(m_pAudEncArray[iSel].DisplayName.m_str);
- CComQIPtr<IAMStreamConfig> pAMSC = GetFirstPin(m_pAudEnc, PINDIR_OUTPUT);
+ // CString DisplayName = iSel < 0 ? _T("") : CString(m_pAudEncArray[iSel].DisplayName.m_str);
+ CComQIPtr<IAMStreamConfig> pAMSC = GetFirstPin(m_pAudEnc, PINDIR_OUTPUT);
- SetupMediaTypes(pAMSC, m_acfa, m_audcodectype, m_audcodecdimension, m_mtca);
+ SetupMediaTypes(pAMSC, m_acfa, m_audcodectype, m_audcodecdimension, m_mtca);
- SaveDefaultCodec(m_pAudEncArray, m_audcodec, CLSID_AudioCompressorCategory);
+ SaveDefaultCodec(m_pAudEncArray, m_audcodec, CLSID_AudioCompressorCategory);
- // SaveMediaType(DisplayName, &m_mtca);
+ // SaveMediaType(DisplayName, &m_mtca);
}
void CPlayerCaptureDialog::UpdateMuxer()
{
- m_pMux = NULL;
- m_pAudMux = NULL;
-
- UpdateData();
-
- HRESULT hr;
-
- if (m_muxtype == 0) {
- m_pMux.CoCreateInstance(CLSID_AviDest);
- } else if (m_muxtype == 1) {
- m_pMux.CoCreateInstance(CLSID_OggMux);
- } else if (m_muxtype == 2) {
- m_pMux = DNew CMatroskaMuxerFilter(NULL, &hr);
- } else if (m_muxtype == 3) {
- m_pMux = DNew CDSMMuxerFilter(NULL, &hr);
- } else {
- return;
- }
-
- if (m_fSepAudio) {
- m_pAudMux = DNew CWavDestFilter(NULL, &hr);
- }
+ m_pMux = NULL;
+ m_pAudMux = NULL;
+
+ UpdateData();
+
+ HRESULT hr;
+
+ if (m_muxtype == 0) {
+ m_pMux.CoCreateInstance(CLSID_AviDest);
+ } else if (m_muxtype == 1) {
+ m_pMux.CoCreateInstance(CLSID_OggMux);
+ } else if (m_muxtype == 2) {
+ m_pMux = DNew CMatroskaMuxerFilter(NULL, &hr);
+ } else if (m_muxtype == 3) {
+ m_pMux = DNew CDSMMuxerFilter(NULL, &hr);
+ } else {
+ return;
+ }
+
+ if (m_fSepAudio) {
+ m_pAudMux = DNew CWavDestFilter(NULL, &hr);
+ }
}
void CPlayerCaptureDialog::UpdateOutputControls()
{
- UpdateData();
+ UpdateData();
- m_recordbtn.EnableWindow(!m_file.IsEmpty() && (m_pAMVSC && m_fVidOutput || m_pAMASC && m_fAudOutput));
- m_vidcodec.EnableWindow(TRUE);
- m_audcodec.EnableWindow(TRUE);
+ m_recordbtn.EnableWindow(!m_file.IsEmpty() && (m_pAMVSC && m_fVidOutput || m_pAMASC && m_fAudOutput));
+ m_vidcodec.EnableWindow(TRUE);
+ m_audcodec.EnableWindow(TRUE);
}
void CPlayerCaptureDialog::UpdateGraph()
{
- UpdateMediaTypes();
+ UpdateMediaTypes();
- // UpdateMuxer();
+ // UpdateMuxer();
- ((CMainFrame*)AfxGetMainWnd())->BuildGraphVideoAudio(m_fVidPreview, false, m_fAudPreview, false);
+ ((CMainFrame*)AfxGetMainWnd())->BuildGraphVideoAudio(m_fVidPreview, false, m_fAudPreview, false);
- UpdateUserDefinableControls();
+ UpdateUserDefinableControls();
}
void CPlayerCaptureDialog::EnableControls(CWnd* pWnd, bool fEnable)
{
- if (fEnable) {
- for (CWnd* pChild = pWnd->GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow()) {
- BOOL fEnabled;
- if (m_wndenabledmap.Lookup(pChild->m_hWnd, fEnabled)) {
- pChild->EnableWindow(fEnabled);
- }
- EnableControls(pChild, fEnable);
- }
-
- if (pWnd->m_hWnd == m_hWnd) {
- m_wndenabledmap.RemoveAll();
- }
-
- m_recordbtn.SetWindowText(_T("Record"));
- } else {
- if (pWnd->m_hWnd == m_hWnd) {
- m_wndenabledmap.RemoveAll();
- }
-
- for (CWnd* pChild = pWnd->GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow()) {
- m_wndenabledmap[pChild->m_hWnd] = pChild->IsWindowEnabled();
- pChild->EnableWindow(FALSE);
- EnableControls(pChild, fEnable);
- }
-
- m_recordbtn.EnableWindow(TRUE);
- m_recordbtn.SetWindowText(_T("Stop"));
- }
+ if (fEnable) {
+ for (CWnd* pChild = pWnd->GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow()) {
+ BOOL fEnabled;
+ if (m_wndenabledmap.Lookup(pChild->m_hWnd, fEnabled)) {
+ pChild->EnableWindow(fEnabled);
+ }
+ EnableControls(pChild, fEnable);
+ }
+
+ if (pWnd->m_hWnd == m_hWnd) {
+ m_wndenabledmap.RemoveAll();
+ }
+
+ m_recordbtn.SetWindowText(_T("Record"));
+ } else {
+ if (pWnd->m_hWnd == m_hWnd) {
+ m_wndenabledmap.RemoveAll();
+ }
+
+ for (CWnd* pChild = pWnd->GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow()) {
+ m_wndenabledmap[pChild->m_hWnd] = pChild->IsWindowEnabled();
+ pChild->EnableWindow(FALSE);
+ EnableControls(pChild, fEnable);
+ }
+
+ m_recordbtn.EnableWindow(TRUE);
+ m_recordbtn.SetWindowText(_T("Stop"));
+ }
}
void CPlayerCaptureDialog::SetupVideoControls(
- CStringW DisplayName,
- IAMStreamConfig* pAMSC, IAMCrossbar* pAMXB, IAMTVTuner* pAMTuner)
+ CStringW DisplayName,
+ IAMStreamConfig* pAMSC, IAMCrossbar* pAMXB, IAMTVTuner* pAMTuner)
{
- EmptyVideo();
-
- // crossbar
-
- if (m_pAMXB = pAMXB) {
- long OutputPinCount, InputPinCount;
- if (SUCCEEDED(pAMXB->get_PinCounts(&OutputPinCount, &InputPinCount))) {
- for (int i = 0; i < InputPinCount; i++) {
- long PinIndexRelated, PhysicalType;
- if (FAILED(pAMXB->get_CrossbarPinInfo(TRUE, i, &PinIndexRelated, &PhysicalType))) {
- continue;
- }
-
- if (PhysicalType >= PhysConn_Audio_Tuner) {
- continue;
- }
-
- CString str;
- switch (PhysicalType) {
- case PhysConn_Video_Tuner:
- str = _T("Tuner");
- break;
- case PhysConn_Video_Composite:
- str = _T("Composite");
- break;
- case PhysConn_Video_SVideo:
- str = _T("SVideo");
- break;
- case PhysConn_Video_RGB:
- str = _T("RGB");
- break;
- case PhysConn_Video_YRYBY:
- str = _T("YRYBY");
- break;
- case PhysConn_Video_SerialDigital:
- str = _T("SerialDigital");
- break;
- case PhysConn_Video_ParallelDigital:
- str = _T("ParallelDigital");
- break;
- case PhysConn_Video_SCSI:
- str = _T("SCSI");
- break;
- case PhysConn_Video_AUX:
- str = _T("AUX");
- break;
- case PhysConn_Video_1394:
- str = _T("1394");
- break;
- case PhysConn_Video_USB:
- str = _T("USB");
- break;
- case PhysConn_Video_VideoDecoder:
- str = _T("VideoDecoder");
- break;
- case PhysConn_Video_VideoEncoder:
- str = _T("VideoEncoder");
- break;
- case PhysConn_Video_SCART:
- str = _T("SCART");
- break;
- default:
- str.Format(_T("PhysicalType %d"), PhysicalType);
- break;
- }
-
- m_vidinput.SetItemData(m_vidinput.AddString(str), i);
- }
- }
- }
-
- if (m_vidinput.GetCount() > 0) {
- m_vidinput.EnableWindow(TRUE);
-
- long OutputPinCount, InputPinCount;
- if (SUCCEEDED(pAMXB->get_PinCounts(&OutputPinCount, &InputPinCount))) {
- for (int i = 0; i < OutputPinCount; i++) {
- long InputPinIndex;
- if (S_OK == pAMXB->get_IsRoutedTo(i, &InputPinIndex)) {
- for (int j = 0; j < m_vidinput.GetCount(); j++) {
- if (m_vidinput.GetItemData(j) == (DWORD_PTR)InputPinIndex) {
- m_vidinput.SetCurSel(j);
- i = OutputPinCount;
- break;
- }
- }
- }
- }
- }
- OnVideoInput();
- }
-
- // tuner
-
- if (m_pAMTuner = pAMTuner) {
- // TODO:...
- }
-
- // streamconfig
-
- if (m_pAMVSC = pAMSC) {
- m_VidDisplayName = DisplayName;
-
- AM_MEDIA_TYPE* pmt;
- if (LoadMediaType(DisplayName, &pmt)) {
- pAMSC->SetFormat(pmt);
- DeleteMediaType(pmt);
- }
-
- SetupMediaTypes(pAMSC, m_vfa, m_vidtype, m_viddimension, m_mtv);
- }
-
- if (m_vidtype.GetCount() > 0) {
- m_vidfpsedit.EnableWindow(TRUE);
- m_vidhor.EnableWindow(TRUE);
- m_vidver.EnableWindow(TRUE);
- m_vidhoredit.EnableWindow(TRUE);
- m_vidveredit.EnableWindow(TRUE);
- m_vidsetres.EnableWindow(TRUE);
- }
-
- {
- m_vidoutput.EnableWindow(TRUE);
- m_vidpreview.EnableWindow(TRUE);
- }
-
- UpdateMediaTypes();
-
- UpdateUserDefinableControls();
-
- UpdateOutputControls();
+ EmptyVideo();
+
+ // crossbar
+
+ if (m_pAMXB = pAMXB) {
+ long OutputPinCount, InputPinCount;
+ if (SUCCEEDED(pAMXB->get_PinCounts(&OutputPinCount, &InputPinCount))) {
+ for (int i = 0; i < InputPinCount; i++) {
+ long PinIndexRelated, PhysicalType;
+ if (FAILED(pAMXB->get_CrossbarPinInfo(TRUE, i, &PinIndexRelated, &PhysicalType))) {
+ continue;
+ }
+
+ if (PhysicalType >= PhysConn_Audio_Tuner) {
+ continue;
+ }
+
+ CString str;
+ switch (PhysicalType) {
+ case PhysConn_Video_Tuner:
+ str = _T("Tuner");
+ break;
+ case PhysConn_Video_Composite:
+ str = _T("Composite");
+ break;
+ case PhysConn_Video_SVideo:
+ str = _T("SVideo");
+ break;
+ case PhysConn_Video_RGB:
+ str = _T("RGB");
+ break;
+ case PhysConn_Video_YRYBY:
+ str = _T("YRYBY");
+ break;
+ case PhysConn_Video_SerialDigital:
+ str = _T("SerialDigital");
+ break;
+ case PhysConn_Video_ParallelDigital:
+ str = _T("ParallelDigital");
+ break;
+ case PhysConn_Video_SCSI:
+ str = _T("SCSI");
+ break;
+ case PhysConn_Video_AUX:
+ str = _T("AUX");
+ break;
+ case PhysConn_Video_1394:
+ str = _T("1394");
+ break;
+ case PhysConn_Video_USB:
+ str = _T("USB");
+ break;
+ case PhysConn_Video_VideoDecoder:
+ str = _T("VideoDecoder");
+ break;
+ case PhysConn_Video_VideoEncoder:
+ str = _T("VideoEncoder");
+ break;
+ case PhysConn_Video_SCART:
+ str = _T("SCART");
+ break;
+ default:
+ str.Format(_T("PhysicalType %d"), PhysicalType);
+ break;
+ }
+
+ m_vidinput.SetItemData(m_vidinput.AddString(str), i);
+ }
+ }
+ }
+
+ if (m_vidinput.GetCount() > 0) {
+ m_vidinput.EnableWindow(TRUE);
+
+ long OutputPinCount, InputPinCount;
+ if (SUCCEEDED(pAMXB->get_PinCounts(&OutputPinCount, &InputPinCount))) {
+ for (int i = 0; i < OutputPinCount; i++) {
+ long InputPinIndex;
+ if (S_OK == pAMXB->get_IsRoutedTo(i, &InputPinIndex)) {
+ for (int j = 0; j < m_vidinput.GetCount(); j++) {
+ if (m_vidinput.GetItemData(j) == (DWORD_PTR)InputPinIndex) {
+ m_vidinput.SetCurSel(j);
+ i = OutputPinCount;
+ break;
+ }
+ }
+ }
+ }
+ }
+ OnVideoInput();
+ }
+
+ // tuner
+
+ if (m_pAMTuner = pAMTuner) {
+ // TODO:...
+ }
+
+ // streamconfig
+
+ if (m_pAMVSC = pAMSC) {
+ m_VidDisplayName = DisplayName;
+
+ AM_MEDIA_TYPE* pmt;
+ if (LoadMediaType(DisplayName, &pmt)) {
+ pAMSC->SetFormat(pmt);
+ DeleteMediaType(pmt);
+ }
+
+ SetupMediaTypes(pAMSC, m_vfa, m_vidtype, m_viddimension, m_mtv);
+ }
+
+ if (m_vidtype.GetCount() > 0) {
+ m_vidfpsedit.EnableWindow(TRUE);
+ m_vidhor.EnableWindow(TRUE);
+ m_vidver.EnableWindow(TRUE);
+ m_vidhoredit.EnableWindow(TRUE);
+ m_vidveredit.EnableWindow(TRUE);
+ m_vidsetres.EnableWindow(TRUE);
+ }
+
+ {
+ m_vidoutput.EnableWindow(TRUE);
+ m_vidpreview.EnableWindow(TRUE);
+ }
+
+ UpdateMediaTypes();
+
+ UpdateUserDefinableControls();
+
+ UpdateOutputControls();
}
void CPlayerCaptureDialog::SetupVideoControls(
- CStringW DisplayName,
- IAMStreamConfig* pAMSC, IAMVfwCaptureDialogs* pAMVfwCD)
+ CStringW DisplayName,
+ IAMStreamConfig* pAMSC, IAMVfwCaptureDialogs* pAMVfwCD)
{
- EmptyVideo();
-
- if (m_pAMVfwCD = pAMVfwCD) {
- if (S_OK == m_pAMVfwCD->HasDialog(VfwCaptureDialog_Source)) {
- m_vidinput.SetItemData(m_vidinput.AddString(_T("Source")), (DWORD_PTR)VfwCaptureDialog_Source);
- }
- if (S_OK == m_pAMVfwCD->HasDialog(VfwCaptureDialog_Format)) {
- m_vidinput.SetItemData(m_vidinput.AddString(_T("Format")), (DWORD_PTR)VfwCaptureDialog_Format);
- }
- if (S_OK == m_pAMVfwCD->HasDialog(VfwCaptureDialog_Display)) {
- m_vidinput.SetItemData(m_vidinput.AddString(_T("Display")), (DWORD_PTR)VfwCaptureDialog_Display);
- }
-
- if (m_vidinput.GetCount() > 0) {
- m_vidinput.EnableWindow(TRUE);
- m_vidinput.SetCurSel(0);
- }
- }
-
- // streamconfig
-
- if (m_pAMVSC = pAMSC) {
- m_VidDisplayName = DisplayName;
-
- AM_MEDIA_TYPE* pmt;
- if (LoadMediaType(DisplayName, &pmt)) {
- pAMSC->SetFormat(pmt);
- DeleteMediaType(pmt);
- }
-
- SetupMediaTypes(pAMSC, m_vfa, m_vidtype, m_viddimension, m_mtv);
- }
-
- if (m_vidtype.GetCount() > 0) {
- m_vidfpsedit.EnableWindow(TRUE);
- m_vidhor.EnableWindow(TRUE);
- m_vidver.EnableWindow(TRUE);
- m_vidhoredit.EnableWindow(TRUE);
- m_vidveredit.EnableWindow(TRUE);
- m_vidsetres.EnableWindow(TRUE);
- }
-
- {
- m_vidoutput.EnableWindow(TRUE);
- m_vidpreview.EnableWindow(TRUE);
- }
-
- UpdateMediaTypes();
-
- UpdateUserDefinableControls();
-
- UpdateOutputControls();
+ EmptyVideo();
+
+ if (m_pAMVfwCD = pAMVfwCD) {
+ if (S_OK == m_pAMVfwCD->HasDialog(VfwCaptureDialog_Source)) {
+ m_vidinput.SetItemData(m_vidinput.AddString(_T("Source")), (DWORD_PTR)VfwCaptureDialog_Source);
+ }
+ if (S_OK == m_pAMVfwCD->HasDialog(VfwCaptureDialog_Format)) {
+ m_vidinput.SetItemData(m_vidinput.AddString(_T("Format")), (DWORD_PTR)VfwCaptureDialog_Format);
+ }
+ if (S_OK == m_pAMVfwCD->HasDialog(VfwCaptureDialog_Display)) {
+ m_vidinput.SetItemData(m_vidinput.AddString(_T("Display")), (DWORD_PTR)VfwCaptureDialog_Display);
+ }
+
+ if (m_vidinput.GetCount() > 0) {
+ m_vidinput.EnableWindow(TRUE);
+ m_vidinput.SetCurSel(0);
+ }
+ }
+
+ // streamconfig
+
+ if (m_pAMVSC = pAMSC) {
+ m_VidDisplayName = DisplayName;
+
+ AM_MEDIA_TYPE* pmt;
+ if (LoadMediaType(DisplayName, &pmt)) {
+ pAMSC->SetFormat(pmt);
+ DeleteMediaType(pmt);
+ }
+
+ SetupMediaTypes(pAMSC, m_vfa, m_vidtype, m_viddimension, m_mtv);
+ }
+
+ if (m_vidtype.GetCount() > 0) {
+ m_vidfpsedit.EnableWindow(TRUE);
+ m_vidhor.EnableWindow(TRUE);
+ m_vidver.EnableWindow(TRUE);
+ m_vidhoredit.EnableWindow(TRUE);
+ m_vidveredit.EnableWindow(TRUE);
+ m_vidsetres.EnableWindow(TRUE);
+ }
+
+ {
+ m_vidoutput.EnableWindow(TRUE);
+ m_vidpreview.EnableWindow(TRUE);
+ }
+
+ UpdateMediaTypes();
+
+ UpdateUserDefinableControls();
+
+ UpdateOutputControls();
}
void CPlayerCaptureDialog::SetupAudioControls(
- CStringW DisplayName,
- IAMStreamConfig* pAMSC, const CInterfaceArray<IAMAudioInputMixer>& pAMAIM)
+ CStringW DisplayName,
+ IAMStreamConfig* pAMSC, const CInterfaceArray<IAMAudioInputMixer>& pAMAIM)
{
- EmptyAudio();
+ EmptyAudio();
- // input selection
+ // input selection
- if (pAMAIM.GetCount() > 0) {
- m_pAMAIM.Copy(pAMAIM);
+ if (pAMAIM.GetCount() > 0) {
+ m_pAMAIM.Copy(pAMAIM);
- int iSel = -1;
+ int iSel = -1;
- for (size_t i = 0; i < m_pAMAIM.GetCount(); i++) {
- CComQIPtr<IPin> pPin = m_pAMAIM[i];
- m_audinput.SetItemData(m_audinput.AddString(CString(GetPinName(pPin))), i);
+ for (size_t i = 0; i < m_pAMAIM.GetCount(); i++) {
+ CComQIPtr<IPin> pPin = m_pAMAIM[i];
+ m_audinput.SetItemData(m_audinput.AddString(CString(GetPinName(pPin))), i);
- BOOL fEnable;
- if (SUCCEEDED(m_pAMAIM[i]->get_Enable(&fEnable)) && fEnable) {
- iSel = i;
- }
- }
+ BOOL fEnable;
+ if (SUCCEEDED(m_pAMAIM[i]->get_Enable(&fEnable)) && fEnable) {
+ iSel = i;
+ }
+ }
- if (m_audinput.GetCount() > 0) {
- for (int i = 0; i < m_audinput.GetCount(); i++) {
- if (m_audinput.GetItemData(i) == iSel) {
- m_audinput.SetCurSel(i);
- break;
- }
- }
+ if (m_audinput.GetCount() > 0) {
+ for (int i = 0; i < m_audinput.GetCount(); i++) {
+ if (m_audinput.GetItemData(i) == iSel) {
+ m_audinput.SetCurSel(i);
+ break;
+ }
+ }
- m_audinput.EnableWindow(TRUE);
- }
- }
+ m_audinput.EnableWindow(TRUE);
+ }
+ }
- // stream config
+ // stream config
- if (m_pAMASC = pAMSC) {
- m_AudDisplayName = DisplayName;
+ if (m_pAMASC = pAMSC) {
+ m_AudDisplayName = DisplayName;
- AM_MEDIA_TYPE* pmt;
- if (LoadMediaType(DisplayName, &pmt)) {
- pAMSC->SetFormat(pmt);
- DeleteMediaType(pmt);
- }
+ AM_MEDIA_TYPE* pmt;
+ if (LoadMediaType(DisplayName, &pmt)) {
+ pAMSC->SetFormat(pmt);
+ DeleteMediaType(pmt);
+ }
- SetupMediaTypes(pAMSC, m_afa, m_audtype, m_auddimension, m_mta);
- }
+ SetupMediaTypes(pAMSC, m_afa, m_audtype, m_auddimension, m_mta);
+ }
- // if (m_audtype.GetCount() > 0)
- {
- m_audoutput.EnableWindow(TRUE);
- m_audpreview.EnableWindow(TRUE);
- }
+ // if (m_audtype.GetCount() > 0)
+ {
+ m_audoutput.EnableWindow(TRUE);
+ m_audpreview.EnableWindow(TRUE);
+ }
- UpdateMediaTypes();
+ UpdateMediaTypes();
- UpdateUserDefinableControls();
+ UpdateUserDefinableControls();
- UpdateOutputControls();
+ UpdateOutputControls();
}
bool CPlayerCaptureDialog::IsTunerActive()
{
- int iSel = m_vidinput.GetCurSel();
- if (iSel < 0) {
- return false;
- }
- iSel = m_vidinput.GetItemData(iSel);
- if (iSel < 0) {
- return false;
- }
-
- long PinIndexRelated = -1, PhysicalType = -1;
- return (m_pAMXB
- && SUCCEEDED(m_pAMXB->get_CrossbarPinInfo(TRUE, iSel, &PinIndexRelated, &PhysicalType))
- && PhysicalType == PhysConn_Video_Tuner);
+ int iSel = m_vidinput.GetCurSel();
+ if (iSel < 0) {
+ return false;
+ }
+ iSel = m_vidinput.GetItemData(iSel);
+ if (iSel < 0) {
+ return false;
+ }
+
+ long PinIndexRelated = -1, PhysicalType = -1;
+ return (m_pAMXB
+ && SUCCEEDED(m_pAMXB->get_CrossbarPinInfo(TRUE, iSel, &PinIndexRelated, &PhysicalType))
+ && PhysicalType == PhysConn_Video_Tuner);
}
bool CPlayerCaptureDialog::SetVideoInput(int input)
{
- if (!m_pAMXB || input < 0) {
- return false;
- }
-
- for (int i = 0; i < m_vidinput.GetCount(); i++) {
- if (m_vidinput.GetItemData(i) == (DWORD_PTR)input) {
- m_vidinput.SetCurSel(i);
- OnVideoInput();
- return true;
- }
- }
-
- return false;
+ if (!m_pAMXB || input < 0) {
+ return false;
+ }
+
+ for (int i = 0; i < m_vidinput.GetCount(); i++) {
+ if (m_vidinput.GetItemData(i) == (DWORD_PTR)input) {
+ m_vidinput.SetCurSel(i);
+ OnVideoInput();
+ return true;
+ }
+ }
+
+ return false;
}
bool CPlayerCaptureDialog::SetVideoChannel(int channel)
{
- if (!m_pAMTuner || channel < 0) {
- return false;
- }
+ if (!m_pAMTuner || channel < 0) {
+ return false;
+ }
- return SUCCEEDED(m_pAMTuner->put_Channel(channel, AMTUNER_SUBCHAN_DEFAULT, AMTUNER_SUBCHAN_DEFAULT));
+ return SUCCEEDED(m_pAMTuner->put_Channel(channel, AMTUNER_SUBCHAN_DEFAULT, AMTUNER_SUBCHAN_DEFAULT));
}
bool CPlayerCaptureDialog::SetAudioInput(int input)
{
- if (input < 0) {
- return false;
- }
-
- for (int i = 0; i < m_audinput.GetCount(); i++) {
- if (m_audinput.GetItemData(i) == (DWORD_PTR)input) {
- m_audinput.SetCurSel(i);
- OnAudioInput();
- return true;
- }
- }
-
- return false;
+ if (input < 0) {
+ return false;
+ }
+
+ for (int i = 0; i < m_audinput.GetCount(); i++) {
+ if (m_audinput.GetItemData(i) == (DWORD_PTR)input) {
+ m_audinput.SetCurSel(i);
+ OnAudioInput();
+ return true;
+ }
+ }
+
+ return false;
}
int CPlayerCaptureDialog::GetVideoInput()
{
- int i = m_vidinput.GetCurSel();
- if (i < 0) {
- return -1;
- }
- return m_vidinput.GetItemData(i);
+ int i = m_vidinput.GetCurSel();
+ if (i < 0) {
+ return -1;
+ }
+ return m_vidinput.GetItemData(i);
}
int CPlayerCaptureDialog::GetVideoChannel()
{
- long lChannel = -1, lVivSub = -1, lAudSub = -1;
- return m_pAMTuner && SUCCEEDED(m_pAMTuner->get_Channel(&lChannel, &lVivSub, &lAudSub)) ? lChannel : -1;
+ long lChannel = -1, lVivSub = -1, lAudSub = -1;
+ return m_pAMTuner && SUCCEEDED(m_pAMTuner->get_Channel(&lChannel, &lVivSub, &lAudSub)) ? lChannel : -1;
}
int CPlayerCaptureDialog::GetAudioInput()
{
- int i = m_audinput.GetCurSel();
- if (i < 0) {
- return -1;
- }
- return m_audinput.GetItemData(i);
+ int i = m_audinput.GetCurSel();
+ if (i < 0) {
+ return -1;
+ }
+ return m_audinput.GetItemData(i);
}
BEGIN_MESSAGE_MAP(CPlayerCaptureDialog, CResizableDialog)
- ON_WM_DESTROY()
- ON_CBN_SELCHANGE(IDC_COMBO4, OnVideoInput)
- ON_CBN_SELCHANGE(IDC_COMBO1, OnVideoType)
- ON_CBN_SELCHANGE(IDC_COMBO5, OnVideoDimension)
- ON_BN_CLICKED(IDC_BUTTON1, OnOverrideVideoDimension)
- ON_CBN_SELCHANGE(IDC_COMBO3, OnAudioInput)
- ON_CBN_SELCHANGE(IDC_COMBO2, OnAudioType)
- ON_CBN_SELCHANGE(IDC_COMBO6, OnAudioDimension)
- ON_BN_CLICKED(IDC_CHECK1, OnRecordVideo)
- ON_CBN_SELCHANGE(IDC_COMBO7, OnVideoCodec)
- ON_CBN_SELCHANGE(IDC_COMBO9, OnVideoCodecType)
- ON_CBN_SELCHANGE(IDC_COMBO10, OnVideoCodecDimension)
- ON_BN_CLICKED(IDC_CHECK3, OnRecordAudio)
- ON_CBN_SELCHANGE(IDC_COMBO8, OnAudioCodec)
- ON_CBN_SELCHANGE(IDC_COMBO12, OnAudioCodecType)
- ON_CBN_SELCHANGE(IDC_COMBO11, OnAudioCodecDimension)
- ON_BN_CLICKED(IDC_BUTTON3, OnOpenFile)
- ON_BN_CLICKED(IDC_BUTTON2, OnRecord)
- ON_EN_CHANGE(IDC_EDIT5, OnEnChangeEdit9)
- ON_EN_CHANGE(IDC_EDIT6, OnEnChangeEdit12)
- ON_WM_TIMER()
- ON_BN_CLICKED(IDC_CHECK2, OnBnClickedVidAudPreview)
- ON_BN_CLICKED(IDC_CHECK4, OnBnClickedVidAudPreview)
- ON_BN_CLICKED(IDC_CHECK5, OnBnClickedCheck7)
- ON_CBN_SELCHANGE(IDC_COMBO14, OnCbnSelchangeCombo14)
+ ON_WM_DESTROY()
+ ON_CBN_SELCHANGE(IDC_COMBO4, OnVideoInput)
+ ON_CBN_SELCHANGE(IDC_COMBO1, OnVideoType)
+ ON_CBN_SELCHANGE(IDC_COMBO5, OnVideoDimension)
+ ON_BN_CLICKED(IDC_BUTTON1, OnOverrideVideoDimension)
+ ON_CBN_SELCHANGE(IDC_COMBO3, OnAudioInput)
+ ON_CBN_SELCHANGE(IDC_COMBO2, OnAudioType)
+ ON_CBN_SELCHANGE(IDC_COMBO6, OnAudioDimension)
+ ON_BN_CLICKED(IDC_CHECK1, OnRecordVideo)
+ ON_CBN_SELCHANGE(IDC_COMBO7, OnVideoCodec)
+ ON_CBN_SELCHANGE(IDC_COMBO9, OnVideoCodecType)
+ ON_CBN_SELCHANGE(IDC_COMBO10, OnVideoCodecDimension)
+ ON_BN_CLICKED(IDC_CHECK3, OnRecordAudio)
+ ON_CBN_SELCHANGE(IDC_COMBO8, OnAudioCodec)
+ ON_CBN_SELCHANGE(IDC_COMBO12, OnAudioCodecType)
+ ON_CBN_SELCHANGE(IDC_COMBO11, OnAudioCodecDimension)
+ ON_BN_CLICKED(IDC_BUTTON3, OnOpenFile)
+ ON_BN_CLICKED(IDC_BUTTON2, OnRecord)
+ ON_EN_CHANGE(IDC_EDIT5, OnEnChangeEdit9)
+ ON_EN_CHANGE(IDC_EDIT6, OnEnChangeEdit12)
+ ON_WM_TIMER()
+ ON_BN_CLICKED(IDC_CHECK2, OnBnClickedVidAudPreview)
+ ON_BN_CLICKED(IDC_CHECK4, OnBnClickedVidAudPreview)
+ ON_BN_CLICKED(IDC_CHECK5, OnBnClickedCheck7)
+ ON_CBN_SELCHANGE(IDC_COMBO14, OnCbnSelchangeCombo14)
END_MESSAGE_MAP()
@@ -1305,424 +1305,424 @@ END_MESSAGE_MAP()
BOOL CPlayerCaptureDialog::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- InitCodecList(m_pVidEncArray, m_vidcodec, CLSID_VideoCompressorCategory);
- UpdateVideoCodec();
+ InitCodecList(m_pVidEncArray, m_vidcodec, CLSID_VideoCompressorCategory);
+ UpdateVideoCodec();
- InitCodecList(m_pAudEncArray, m_audcodec, CLSID_AudioCompressorCategory);
- UpdateAudioCodec();
+ InitCodecList(m_pAudEncArray, m_audcodec, CLSID_AudioCompressorCategory);
+ UpdateAudioCodec();
- m_fEnableOgm = IsCLSIDRegistered(_T("{8cae96b7-85b1-4605-b23c-17ff5262b296}"));
+ m_fEnableOgm = IsCLSIDRegistered(_T("{8cae96b7-85b1-4605-b23c-17ff5262b296}"));
- m_nVidBuffers = AfxGetApp()->GetProfileInt(IDS_RS_CAPTURE, _T("VidBuffers"), 50);
- m_nAudBuffers = AfxGetApp()->GetProfileInt(IDS_RS_CAPTURE, _T("AudBuffers"), 50);
- m_fVidOutput = !!AfxGetApp()->GetProfileInt(IDS_RS_CAPTURE, _T("VidOutput"), TRUE);
- m_fAudOutput = !!AfxGetApp()->GetProfileInt(IDS_RS_CAPTURE, _T("AudOutput"), TRUE);
- m_fVidPreview = AfxGetApp()->GetProfileInt(IDS_RS_CAPTURE, _T("VidPreview"), TRUE);
- m_fAudPreview = AfxGetApp()->GetProfileInt(IDS_RS_CAPTURE, _T("AudPreview"), TRUE);
- m_muxtype = AfxGetApp()->GetProfileInt(IDS_RS_CAPTURE, _T("FileFormat"), 0);
- m_file = AfxGetApp()->GetProfileString(IDS_RS_CAPTURE, _T("FileName"), _T(""));
- m_fSepAudio = AfxGetApp()->GetProfileInt(IDS_RS_CAPTURE, _T("SepAudio"), TRUE);
+ m_nVidBuffers = AfxGetApp()->GetProfileInt(IDS_RS_CAPTURE, _T("VidBuffers"), 50);
+ m_nAudBuffers = AfxGetApp()->GetProfileInt(IDS_RS_CAPTURE, _T("AudBuffers"), 50);
+ m_fVidOutput = !!AfxGetApp()->GetProfileInt(IDS_RS_CAPTURE, _T("VidOutput"), TRUE);
+ m_fAudOutput = !!AfxGetApp()->GetProfileInt(IDS_RS_CAPTURE, _T("AudOutput"), TRUE);
+ m_fVidPreview = AfxGetApp()->GetProfileInt(IDS_RS_CAPTURE, _T("VidPreview"), TRUE);
+ m_fAudPreview = AfxGetApp()->GetProfileInt(IDS_RS_CAPTURE, _T("AudPreview"), TRUE);
+ m_muxtype = AfxGetApp()->GetProfileInt(IDS_RS_CAPTURE, _T("FileFormat"), 0);
+ m_file = AfxGetApp()->GetProfileString(IDS_RS_CAPTURE, _T("FileName"), _T(""));
+ m_fSepAudio = AfxGetApp()->GetProfileInt(IDS_RS_CAPTURE, _T("SepAudio"), TRUE);
- m_muxctrl.AddString(_T("AVI"));
- m_muxctrl.AddString(_T("Ogg Media"));
- m_muxctrl.AddString(_T("Matroska"));
- m_muxctrl.AddString(_T("DirectShow Media"));
+ m_muxctrl.AddString(_T("AVI"));
+ m_muxctrl.AddString(_T("Ogg Media"));
+ m_muxctrl.AddString(_T("Matroska"));
+ m_muxctrl.AddString(_T("DirectShow Media"));
- // UpdateMuxer();
+ // UpdateMuxer();
- UpdateData(FALSE);
+ UpdateData(FALSE);
- OnCbnSelchangeCombo14();
+ OnCbnSelchangeCombo14();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CPlayerCaptureDialog::OnDestroy()
{
- UpdateData();
+ UpdateData();
- AfxGetApp()->WriteProfileInt(IDS_RS_CAPTURE, _T("VidOutput"), m_fVidOutput);
- AfxGetApp()->WriteProfileInt(IDS_RS_CAPTURE, _T("AudOutput"), m_fAudOutput);
- AfxGetApp()->WriteProfileInt(IDS_RS_CAPTURE, _T("VidPreview"), m_fVidPreview);
- AfxGetApp()->WriteProfileInt(IDS_RS_CAPTURE, _T("AudPreview"), m_fAudPreview);
- AfxGetApp()->WriteProfileInt(IDS_RS_CAPTURE, _T("FileFormat"), m_muxtype);
- AfxGetApp()->WriteProfileString(IDS_RS_CAPTURE, _T("FileName"), m_file);
- AfxGetApp()->WriteProfileInt(IDS_RS_CAPTURE, _T("SepAudio"), m_fSepAudio);
+ AfxGetApp()->WriteProfileInt(IDS_RS_CAPTURE, _T("VidOutput"), m_fVidOutput);
+ AfxGetApp()->WriteProfileInt(IDS_RS_CAPTURE, _T("AudOutput"), m_fAudOutput);
+ AfxGetApp()->WriteProfileInt(IDS_RS_CAPTURE, _T("VidPreview"), m_fVidPreview);
+ AfxGetApp()->WriteProfileInt(IDS_RS_CAPTURE, _T("AudPreview"), m_fAudPreview);
+ AfxGetApp()->WriteProfileInt(IDS_RS_CAPTURE, _T("FileFormat"), m_muxtype);
+ AfxGetApp()->WriteProfileString(IDS_RS_CAPTURE, _T("FileName"), m_file);
+ AfxGetApp()->WriteProfileInt(IDS_RS_CAPTURE, _T("SepAudio"), m_fSepAudio);
- __super::OnDestroy();
+ __super::OnDestroy();
}
void CPlayerCaptureDialog::OnVideoInput()
{
- int iSel = m_vidinput.GetCurSel();
- if (iSel < 0) {
- return;
- }
- iSel = m_vidinput.GetItemData(iSel);
- if (iSel < 0) {
- return;
- }
-
- if (m_pAMXB) {
- long PinIndexRelated, PhysicalType;
- if (FAILED(m_pAMXB->get_CrossbarPinInfo(TRUE, iSel, &PinIndexRelated, &PhysicalType))) {
- return;
- }
-
- long OutputPinCount, InputPinCount;
- if (FAILED(m_pAMXB->get_PinCounts(&OutputPinCount, &InputPinCount))) {
- return;
- }
-
- for (int i = 0; i < OutputPinCount; i++) {
- if (S_OK == m_pAMXB->CanRoute(i, iSel)) {
- m_pAMXB->Route(i, iSel);
- break;
- }
- }
-
- if (PinIndexRelated >= 0) {
- for (int i = 0; i < OutputPinCount; i++) {
- if (S_OK == m_pAMXB->CanRoute(i, PinIndexRelated)) {
- m_pAMXB->Route(i, PinIndexRelated);
- break;
- }
- }
- }
- } else if (m_pAMVfwCD) {
- if (S_OK == m_pAMVfwCD->HasDialog(iSel)) {
- HRESULT hr = m_pAMVfwCD->ShowDialog(iSel, m_hWnd);
-
- if (VFW_E_NOT_STOPPED == hr) {
- ((CMainFrame*)AfxGetMainWnd())->SendMessage(WM_COMMAND, ID_PLAY_STOP);
- hr = m_pAMVfwCD->ShowDialog(iSel, m_hWnd);
- ((CMainFrame*)AfxGetMainWnd())->SendMessage(WM_COMMAND, ID_PLAY_PLAY);
- }
-
- if (VFW_E_CANNOT_CONNECT == hr) {
- UpdateGraph();
- }
- }
- }
+ int iSel = m_vidinput.GetCurSel();
+ if (iSel < 0) {
+ return;
+ }
+ iSel = m_vidinput.GetItemData(iSel);
+ if (iSel < 0) {
+ return;
+ }
+
+ if (m_pAMXB) {
+ long PinIndexRelated, PhysicalType;
+ if (FAILED(m_pAMXB->get_CrossbarPinInfo(TRUE, iSel, &PinIndexRelated, &PhysicalType))) {
+ return;
+ }
+
+ long OutputPinCount, InputPinCount;
+ if (FAILED(m_pAMXB->get_PinCounts(&OutputPinCount, &InputPinCount))) {
+ return;
+ }
+
+ for (int i = 0; i < OutputPinCount; i++) {
+ if (S_OK == m_pAMXB->CanRoute(i, iSel)) {
+ m_pAMXB->Route(i, iSel);
+ break;
+ }
+ }
+
+ if (PinIndexRelated >= 0) {
+ for (int i = 0; i < OutputPinCount; i++) {
+ if (S_OK == m_pAMXB->CanRoute(i, PinIndexRelated)) {
+ m_pAMXB->Route(i, PinIndexRelated);
+ break;
+ }
+ }
+ }
+ } else if (m_pAMVfwCD) {
+ if (S_OK == m_pAMVfwCD->HasDialog(iSel)) {
+ HRESULT hr = m_pAMVfwCD->ShowDialog(iSel, m_hWnd);
+
+ if (VFW_E_NOT_STOPPED == hr) {
+ ((CMainFrame*)AfxGetMainWnd())->SendMessage(WM_COMMAND, ID_PLAY_STOP);
+ hr = m_pAMVfwCD->ShowDialog(iSel, m_hWnd);
+ ((CMainFrame*)AfxGetMainWnd())->SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ }
+
+ if (VFW_E_CANNOT_CONNECT == hr) {
+ UpdateGraph();
+ }
+ }
+ }
}
void CPlayerCaptureDialog::OnVideoType()
{
- if (SetupDimension(m_vfa, m_vidtype, m_viddimension)) {
- OnVideoDimension();
- }
+ if (SetupDimension(m_vfa, m_vidtype, m_viddimension)) {
+ OnVideoDimension();
+ }
}
void CPlayerCaptureDialog::OnVideoDimension()
{
- int iSel = m_viddimension.GetCurSel();
- if (iSel < 0) {
- return;
- }
-
- CVidFormatElem* pvfe = (CVidFormatElem*)m_viddimension.GetItemData(iSel);
- if (!pvfe) {
- return;
- }
-
- BITMAPINFOHEADER* bih = (pvfe->mt.formattype == FORMAT_VideoInfo)
- ? &((VIDEOINFOHEADER*)pvfe->mt.pbFormat)->bmiHeader
- : (pvfe->mt.formattype == FORMAT_VideoInfo2)
- ? &((VIDEOINFOHEADER2*)pvfe->mt.pbFormat)->bmiHeader
- : NULL;
- if (!bih) {
- return;
- }
-
- m_vidhor.SetRange(0, 32767);
- m_vidver.SetRange(0, 32767);
- m_vidhor.SetPos(bih->biWidth);
- m_vidver.SetPos(abs(bih->biHeight));
- CString fps;
- fps.Format(_T("%.4f"), (float)(10000000.0 / ((VIDEOINFOHEADER*)pvfe->mt.pbFormat)->AvgTimePerFrame));
- m_vidfpsedit.SetWindowText(fps);
-
- UpdateGraph();
+ int iSel = m_viddimension.GetCurSel();
+ if (iSel < 0) {
+ return;
+ }
+
+ CVidFormatElem* pvfe = (CVidFormatElem*)m_viddimension.GetItemData(iSel);
+ if (!pvfe) {
+ return;
+ }
+
+ BITMAPINFOHEADER* bih = (pvfe->mt.formattype == FORMAT_VideoInfo)
+ ? &((VIDEOINFOHEADER*)pvfe->mt.pbFormat)->bmiHeader
+ : (pvfe->mt.formattype == FORMAT_VideoInfo2)
+ ? &((VIDEOINFOHEADER2*)pvfe->mt.pbFormat)->bmiHeader
+ : NULL;
+ if (!bih) {
+ return;
+ }
+
+ m_vidhor.SetRange(0, 32767);
+ m_vidver.SetRange(0, 32767);
+ m_vidhor.SetPos(bih->biWidth);
+ m_vidver.SetPos(abs(bih->biHeight));
+ CString fps;
+ fps.Format(_T("%.4f"), (float)(10000000.0 / ((VIDEOINFOHEADER*)pvfe->mt.pbFormat)->AvgTimePerFrame));
+ m_vidfpsedit.SetWindowText(fps);
+
+ UpdateGraph();
}
void CPlayerCaptureDialog::OnOverrideVideoDimension()
{
- UpdateGraph();
+ UpdateGraph();
}
void CPlayerCaptureDialog::OnAudioInput()
{
- int iSel = m_audinput.GetCurSel();
+ int iSel = m_audinput.GetCurSel();
- for (int i = 0; i < (int)m_pAMAIM.GetCount(); i++) {
- m_pAMAIM[m_audinput.GetItemData(i)]->put_Enable(i == iSel ? TRUE : FALSE);
- }
+ for (int i = 0; i < (int)m_pAMAIM.GetCount(); i++) {
+ m_pAMAIM[m_audinput.GetItemData(i)]->put_Enable(i == iSel ? TRUE : FALSE);
+ }
}
void CPlayerCaptureDialog::OnAudioType()
{
- if (SetupDimension(m_afa, m_audtype, m_auddimension)) {
- OnAudioDimension();
- }
+ if (SetupDimension(m_afa, m_audtype, m_auddimension)) {
+ OnAudioDimension();
+ }
}
void CPlayerCaptureDialog::OnAudioDimension()
{
- UpdateGraph();
+ UpdateGraph();
}
void CPlayerCaptureDialog::OnRecordVideo()
{
- UpdateOutputControls();
+ UpdateOutputControls();
}
void CPlayerCaptureDialog::OnVideoCodec()
{
- ShowPPage(m_pVidEncArray, m_vidcodec, m_hWnd);
- UpdateVideoCodec();
+ ShowPPage(m_pVidEncArray, m_vidcodec, m_hWnd);
+ UpdateVideoCodec();
}
void CPlayerCaptureDialog::OnVideoCodecType()
{
- if (SetupDimension(m_vcfa, m_vidcodectype, m_vidcodecdimension)) {
- OnVideoCodecDimension();
- }
+ if (SetupDimension(m_vcfa, m_vidcodectype, m_vidcodecdimension)) {
+ OnVideoCodecDimension();
+ }
}
void CPlayerCaptureDialog::OnVideoCodecDimension()
{
- int i = m_vidcodecdimension.GetCurSel();
- if (i >= 0) {
- m_mtcv = ((CVidFormatElem*)m_vidcodecdimension.GetItemData(i))->mt;
-
- // we have to recreate the encoder, otherwise it will accept the new media type for only the first time
- m_pVidEnc = NULL;
- m_pVidEncMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)&m_pVidEnc);
- }
+ int i = m_vidcodecdimension.GetCurSel();
+ if (i >= 0) {
+ m_mtcv = ((CVidFormatElem*)m_vidcodecdimension.GetItemData(i))->mt;
+
+ // we have to recreate the encoder, otherwise it will accept the new media type for only the first time
+ m_pVidEnc = NULL;
+ m_pVidEncMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)&m_pVidEnc);
+ }
}
void CPlayerCaptureDialog::OnRecordAudio()
{
- UpdateOutputControls();
+ UpdateOutputControls();
}
void CPlayerCaptureDialog::OnAudioCodec()
{
- ShowPPage(m_pAudEncArray, m_audcodec, m_hWnd);
- UpdateAudioCodec();
+ ShowPPage(m_pAudEncArray, m_audcodec, m_hWnd);
+ UpdateAudioCodec();
}
void CPlayerCaptureDialog::OnAudioCodecType()
{
- if (SetupDimension(m_acfa, m_audcodectype, m_audcodecdimension)) {
- OnAudioCodecDimension();
- }
+ if (SetupDimension(m_acfa, m_audcodectype, m_audcodecdimension)) {
+ OnAudioCodecDimension();
+ }
}
void CPlayerCaptureDialog::OnAudioCodecDimension()
{
- int i = m_audcodecdimension.GetCurSel();
- if (i >= 0) {
- m_mtca = ((CAudFormatElem*)m_audcodecdimension.GetItemData(i))->mt;
-
- // we have to recreate the encoder, otherwise it will accept the new media type for only the first time
- m_pAudEnc = NULL;
- m_pAudEncMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)&m_pAudEnc);
- /*
- SaveMediaType(
- CString(m_pAudEncArray[m_audcodec.GetItemData(m_audcodec.GetCurSel())].DisplayName.m_str),
- &m_mtca);
- */
- }
+ int i = m_audcodecdimension.GetCurSel();
+ if (i >= 0) {
+ m_mtca = ((CAudFormatElem*)m_audcodecdimension.GetItemData(i))->mt;
+
+ // we have to recreate the encoder, otherwise it will accept the new media type for only the first time
+ m_pAudEnc = NULL;
+ m_pAudEncMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)&m_pAudEnc);
+ /*
+ SaveMediaType(
+ CString(m_pAudEncArray[m_audcodec.GetItemData(m_audcodec.GetCurSel())].DisplayName.m_str),
+ &m_mtca);
+ */
+ }
}
void CPlayerCaptureDialog::OnOpenFile()
{
- CFileDialog fd(FALSE, NULL, NULL,
- OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_NOCHANGEDIR,
- _T("Media files (*.avi,*.ogm,*.mkv,*.dsm)|*.avi;*.ogm;*.mkv;*.dsm|"), this, 0);
-
- if (fd.DoModal() == IDOK) {
- CString str = fd.GetPathName();
-
- CString ext = str.Mid(str.ReverseFind('.')+1).MakeLower();
- if (ext == _T("avi")) {
- m_muxtype = 0;
- } else if (ext == _T("ogm")) {
- m_muxtype = 1;
- } else if (ext == _T("mkv")) {
- m_muxtype = 2;
- } else if (ext == _T("dsm")) {
- m_muxtype = 3;
- } else {
- if (m_muxtype == 0) {
- str += _T(".avi");
- } else if (m_muxtype == 1) {
- str += _T(".ogm");
- } else if (m_muxtype == 2) {
- str += _T(".mkv");
- } else if (m_muxtype == 3) {
- str += _T(".dsm");
- }
- }
-
- m_file = str;
-
- UpdateData(FALSE);
- }
-
- UpdateOutputControls();
+ CFileDialog fd(FALSE, NULL, NULL,
+ OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR,
+ _T("Media files (*.avi,*.ogm,*.mkv,*.dsm)|*.avi;*.ogm;*.mkv;*.dsm|"), this, 0);
+
+ if (fd.DoModal() == IDOK) {
+ CString str = fd.GetPathName();
+
+ CString ext = str.Mid(str.ReverseFind('.') + 1).MakeLower();
+ if (ext == _T("avi")) {
+ m_muxtype = 0;
+ } else if (ext == _T("ogm")) {
+ m_muxtype = 1;
+ } else if (ext == _T("mkv")) {
+ m_muxtype = 2;
+ } else if (ext == _T("dsm")) {
+ m_muxtype = 3;
+ } else {
+ if (m_muxtype == 0) {
+ str += _T(".avi");
+ } else if (m_muxtype == 1) {
+ str += _T(".ogm");
+ } else if (m_muxtype == 2) {
+ str += _T(".mkv");
+ } else if (m_muxtype == 3) {
+ str += _T(".dsm");
+ }
+ }
+
+ m_file = str;
+
+ UpdateData(FALSE);
+ }
+
+ UpdateOutputControls();
}
void CPlayerCaptureDialog::OnRecord()
{
- UpdateData();
-
- CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
- if (!pFrame) {
- return;
- }
-
- if (!pFrame->m_fCapturing) {
- UpdateMuxer();
-
- CComQIPtr<IFileSinkFilter2> pFSF = m_pMux;
- if (pFSF) {
- m_pDst = m_pMux;
- } else {
- m_pDst = NULL;
- m_pDst.CoCreateInstance(CLSID_FileWriter);
- pFSF = m_pDst;
- }
-
- if (!pFSF
- || FAILED(pFSF->SetFileName(CStringW(m_file), NULL))
- || FAILED(pFSF->SetMode(AM_FILE_OVERWRITE))) {
- MessageBox(ResStr(IDS_CAPTURE_ERROR_OUT_FILE), ResStr(IDS_CAPTURE_ERROR), MB_ICONERROR | MB_OK);
- return;
- }
-
- CString audfn = m_file.Left(m_file.ReverseFind('.')+1);
- if (m_fSepAudio && m_fAudOutput && m_pAudMux && !audfn.IsEmpty()) {
- audfn += _T("wav");
-
- CComQIPtr<IFileSinkFilter2> pFSF = m_pAudMux;
- if (pFSF) {
- m_pAudDst = m_pAudMux;
- } else {
- m_pAudDst = NULL;
- m_pAudDst.CoCreateInstance(CLSID_FileWriter);
- pFSF = m_pAudDst;
- }
-
- if (!pFSF
- || FAILED(pFSF->SetFileName(CStringW(audfn), NULL))
- || FAILED(pFSF->SetMode(AM_FILE_OVERWRITE))) {
- MessageBox(ResStr(IDS_CAPTURE_ERROR_AUD_OUT_FILE), ResStr(IDS_CAPTURE_ERROR), MB_ICONERROR | MB_OK);
- return;
- }
- }
-
- m_pVidBuffer = m_fVidOutput && m_nVidBuffers > 0 && m_muxtype != 2 && m_muxtype != 3 ? DNew CBufferFilter(NULL, NULL) : NULL;
- if (CComQIPtr<IBufferFilter> pVB = m_pVidBuffer) {
- pVB->SetBuffers(m_nVidBuffers);
- pVB->SetPriority(THREAD_PRIORITY_NORMAL);
- }
-
- m_pAudBuffer = m_fAudOutput && m_nAudBuffers > 0 && m_muxtype != 2 && m_muxtype != 3 ? DNew CBufferFilter(NULL, NULL) : NULL;
- if (CComQIPtr<IBufferFilter> pAB = m_pAudBuffer) {
- pAB->SetBuffers(m_nAudBuffers);
- pAB->SetPriority(THREAD_PRIORITY_ABOVE_NORMAL);
- }
-
- EnableControls(this, false);
-
- pFrame->StartCapture();
-
- SetTimer(1, 100, NULL);
- } else {
- KillTimer(1);
-
- pFrame->StopCapture();
- /*
- {
- if (FILE* f = _tfopen(m_file, _T("rb+")))
- {
- fseek(f, 0x20, SEEK_SET);
- unsigned short mspf = (unsigned short)(((VIDEOINFOHEADER*)m_mtv.pbFormat)->AvgTimePerFrame / 10);
- fwrite(&mspf, 1, 2, f);
- fclose(f);
- }
- }
- */
- EnableControls(this, true);
-
- m_pVidBuffer = NULL;
- m_pAudBuffer = NULL;
- }
+ UpdateData();
+
+ CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
+ if (!pFrame) {
+ return;
+ }
+
+ if (!pFrame->m_fCapturing) {
+ UpdateMuxer();
+
+ CComQIPtr<IFileSinkFilter2> pFSF = m_pMux;
+ if (pFSF) {
+ m_pDst = m_pMux;
+ } else {
+ m_pDst = NULL;
+ m_pDst.CoCreateInstance(CLSID_FileWriter);
+ pFSF = m_pDst;
+ }
+
+ if (!pFSF
+ || FAILED(pFSF->SetFileName(CStringW(m_file), NULL))
+ || FAILED(pFSF->SetMode(AM_FILE_OVERWRITE))) {
+ MessageBox(ResStr(IDS_CAPTURE_ERROR_OUT_FILE), ResStr(IDS_CAPTURE_ERROR), MB_ICONERROR | MB_OK);
+ return;
+ }
+
+ CString audfn = m_file.Left(m_file.ReverseFind('.') + 1);
+ if (m_fSepAudio && m_fAudOutput && m_pAudMux && !audfn.IsEmpty()) {
+ audfn += _T("wav");
+
+ CComQIPtr<IFileSinkFilter2> pFSF = m_pAudMux;
+ if (pFSF) {
+ m_pAudDst = m_pAudMux;
+ } else {
+ m_pAudDst = NULL;
+ m_pAudDst.CoCreateInstance(CLSID_FileWriter);
+ pFSF = m_pAudDst;
+ }
+
+ if (!pFSF
+ || FAILED(pFSF->SetFileName(CStringW(audfn), NULL))
+ || FAILED(pFSF->SetMode(AM_FILE_OVERWRITE))) {
+ MessageBox(ResStr(IDS_CAPTURE_ERROR_AUD_OUT_FILE), ResStr(IDS_CAPTURE_ERROR), MB_ICONERROR | MB_OK);
+ return;
+ }
+ }
+
+ m_pVidBuffer = m_fVidOutput && m_nVidBuffers > 0 && m_muxtype != 2 && m_muxtype != 3 ? DNew CBufferFilter(NULL, NULL) : NULL;
+ if (CComQIPtr<IBufferFilter> pVB = m_pVidBuffer) {
+ pVB->SetBuffers(m_nVidBuffers);
+ pVB->SetPriority(THREAD_PRIORITY_NORMAL);
+ }
+
+ m_pAudBuffer = m_fAudOutput && m_nAudBuffers > 0 && m_muxtype != 2 && m_muxtype != 3 ? DNew CBufferFilter(NULL, NULL) : NULL;
+ if (CComQIPtr<IBufferFilter> pAB = m_pAudBuffer) {
+ pAB->SetBuffers(m_nAudBuffers);
+ pAB->SetPriority(THREAD_PRIORITY_ABOVE_NORMAL);
+ }
+
+ EnableControls(this, false);
+
+ pFrame->StartCapture();
+
+ SetTimer(1, 100, NULL);
+ } else {
+ KillTimer(1);
+
+ pFrame->StopCapture();
+ /*
+ {
+ if (FILE* f = _tfopen(m_file, _T("rb+")))
+ {
+ fseek(f, 0x20, SEEK_SET);
+ unsigned short mspf = (unsigned short)(((VIDEOINFOHEADER*)m_mtv.pbFormat)->AvgTimePerFrame / 10);
+ fwrite(&mspf, 1, 2, f);
+ fclose(f);
+ }
+ }
+ */
+ EnableControls(this, true);
+
+ m_pVidBuffer = NULL;
+ m_pAudBuffer = NULL;
+ }
}
void CPlayerCaptureDialog::OnEnChangeEdit9()
{
- UpdateData();
- AfxGetApp()->WriteProfileInt(IDS_RS_CAPTURE, _T("VidBuffers"), max(m_nVidBuffers, 0));
+ UpdateData();
+ AfxGetApp()->WriteProfileInt(IDS_RS_CAPTURE, _T("VidBuffers"), max(m_nVidBuffers, 0));
}
void CPlayerCaptureDialog::OnEnChangeEdit12()
{
- UpdateData();
- AfxGetApp()->WriteProfileInt(IDS_RS_CAPTURE, _T("AudBuffers"), max(m_nAudBuffers, 0));
+ UpdateData();
+ AfxGetApp()->WriteProfileInt(IDS_RS_CAPTURE, _T("AudBuffers"), max(m_nAudBuffers, 0));
}
void CPlayerCaptureDialog::OnTimer(UINT_PTR nIDEvent)
{
- if (nIDEvent == 1) {
- if (((CMainFrame*)AfxGetMainWnd())->m_fCapturing) {
- ULARGE_INTEGER FreeBytesAvailable, TotalNumberOfBytes, TotalNumberOfFreeBytes;
- if (GetDiskFreeSpaceEx(m_file.Left(m_file.ReverseFind('\\')+1), &FreeBytesAvailable, &TotalNumberOfBytes, &TotalNumberOfFreeBytes)
- && FreeBytesAvailable.QuadPart < 1024i64*1024*10) {
- OnRecord();
- }
- }
- }
-
- __super::OnTimer(nIDEvent);
+ if (nIDEvent == 1) {
+ if (((CMainFrame*)AfxGetMainWnd())->m_fCapturing) {
+ ULARGE_INTEGER FreeBytesAvailable, TotalNumberOfBytes, TotalNumberOfFreeBytes;
+ if (GetDiskFreeSpaceEx(m_file.Left(m_file.ReverseFind('\\') + 1), &FreeBytesAvailable, &TotalNumberOfBytes, &TotalNumberOfFreeBytes)
+ && FreeBytesAvailable.QuadPart < 1024i64 * 1024 * 10) {
+ OnRecord();
+ }
+ }
+ }
+
+ __super::OnTimer(nIDEvent);
}
void CPlayerCaptureDialog::OnBnClickedVidAudPreview()
{
- UpdateData();
- UpdateGraph();
+ UpdateData();
+ UpdateGraph();
}
void CPlayerCaptureDialog::OnBnClickedCheck7()
{
- // UpdateMuxer();
+ // UpdateMuxer();
}
void CPlayerCaptureDialog::OnCbnSelchangeCombo14()
{
- UpdateData();
+ UpdateData();
- CString ext = m_file.Mid(m_file.ReverseFind('.')+1).MakeLower();
+ CString ext = m_file.Mid(m_file.ReverseFind('.') + 1).MakeLower();
- if (m_muxtype == 0 && ext != _T("avi")) {
- m_file = m_file.Left(m_file.GetLength()-4) + _T(".avi");
- } else if (m_muxtype == 1 && ext != _T("ogm")) {
- m_file = m_file.Left(m_file.GetLength()-4) + _T(".ogm");
- } else if (m_muxtype == 2 && ext != _T("mkv")) {
- m_file = m_file.Left(m_file.GetLength()-4) + _T(".mkv");
- } else if (m_muxtype == 3 && ext != _T("dsm")) {
- m_file = m_file.Left(m_file.GetLength()-4) + _T(".dsm");
- }
+ if (m_muxtype == 0 && ext != _T("avi")) {
+ m_file = m_file.Left(m_file.GetLength() - 4) + _T(".avi");
+ } else if (m_muxtype == 1 && ext != _T("ogm")) {
+ m_file = m_file.Left(m_file.GetLength() - 4) + _T(".ogm");
+ } else if (m_muxtype == 2 && ext != _T("mkv")) {
+ m_file = m_file.Left(m_file.GetLength() - 4) + _T(".mkv");
+ } else if (m_muxtype == 3 && ext != _T("dsm")) {
+ m_file = m_file.Left(m_file.GetLength() - 4) + _T(".dsm");
+ }
- UpdateData(FALSE);
+ UpdateData(FALSE);
- GetDlgItem(IDC_EDIT5)->EnableWindow(m_muxtype != 2 && m_muxtype != 3);
- GetDlgItem(IDC_EDIT6)->EnableWindow(m_muxtype != 2 && m_muxtype != 3);
+ GetDlgItem(IDC_EDIT5)->EnableWindow(m_muxtype != 2 && m_muxtype != 3);
+ GetDlgItem(IDC_EDIT6)->EnableWindow(m_muxtype != 2 && m_muxtype != 3);
- m_recordbtn.EnableWindow(m_muxtype != 1 || m_fEnableOgm);
+ m_recordbtn.EnableWindow(m_muxtype != 1 || m_fEnableOgm);
}
diff --git a/src/mpc-hc/PlayerCaptureDialog.h b/src/mpc-hc/PlayerCaptureDialog.h
index ceca674a1..59ef79f4b 100644
--- a/src/mpc-hc/PlayerCaptureDialog.h
+++ b/src/mpc-hc/PlayerCaptureDialog.h
@@ -36,124 +36,124 @@ template<class T>
class CFormatElem
{
public:
- CMediaType mt;
- T caps;
+ CMediaType mt;
+ T caps;
};
template<class T>
class CFormat : public CAutoPtrArray<CFormatElem<T> >
{
public:
- CString name;
- CFormat(CString name = _T("")) {
- this->name = name;
- }
- virtual ~CFormat() {}
+ CString name;
+ CFormat(CString name = _T("")) {
+ this->name = name;
+ }
+ virtual ~CFormat() {}
};
template<class T>
class CFormatArray : public CAutoPtrArray<CFormat<T> >
{
public:
- virtual ~CFormatArray() {}
-
- CFormat<T>* Find(CString name, bool fCreate = false) {
- for (size_t i = 0; i < GetCount(); ++i) {
- if (GetAt(i)->name == name) {
- return GetAt(i);
- }
- }
-
- if (fCreate) {
- CAutoPtr<CFormat<T> > pf(DNew CFormat<T>(name));
- CFormat<T>* tmp = pf;
- Add(pf);
- return tmp;
- }
-
- return NULL;
- }
-
- bool FindFormat(AM_MEDIA_TYPE* pmt, CFormat<T>** ppf) {
- if (!pmt) {
- return false;
- }
-
- for (size_t i = 0; i < GetCount(); ++i) {
- CFormat<T>* pf = GetAt(i);
- for (size_t j = 0; j < pf->GetCount(); ++j) {
- CFormatElem<T>* pfe = pf->GetAt(j);
- if (!pmt || (pfe->mt.majortype == pmt->majortype && pfe->mt.subtype == pmt->subtype)) {
- if (ppf) {
- *ppf = pf;
- }
- return true;
- }
- }
- }
-
- return false;
- }
-
- bool FindFormat(AM_MEDIA_TYPE* pmt, T* pcaps, CFormat<T>** ppf, CFormatElem<T>** ppfe) {
- if (!pmt && !pcaps) {
- return false;
- }
-
- for (size_t i = 0; i < GetCount(); ++i) {
- CFormat<T>* pf = GetAt(i);
- for (size_t j = 0; j < pf->GetCount(); ++j) {
- CFormatElem<T>* pfe = pf->GetAt(j);
- if ((!pmt || pfe->mt == *pmt) && (!pcaps || !memcmp(pcaps, &pfe->caps, sizeof(T)))) {
- if (ppf) {
- *ppf = pf;
- }
- if (ppfe) {
- *ppfe = pfe;
- }
- return true;
- }
- }
- }
-
- return false;
- }
-
- bool AddFormat(AM_MEDIA_TYPE* pmt, T caps) {
- if (!pmt) {
- return false;
- }
-
- if (FindFormat(pmt, NULL, NULL, NULL)) {
- DeleteMediaType(pmt);
- return false;
- }
- // if (pmt->formattype == FORMAT_VideoInfo2) {DeleteMediaType(pmt); return false;} // TODO
-
- CFormat<T>* pf = Find(MakeFormatName(pmt), true);
- if (!pf) {
- DeleteMediaType(pmt);
- return false;
- }
-
- CAutoPtr<CFormatElem<T> > pfe(DNew CFormatElem<T>());
- pfe->mt = *pmt;
- pfe->caps = caps;
- pf->Add(pfe);
-
- return true;
- }
-
- bool AddFormat(AM_MEDIA_TYPE* pmt, void* pcaps, int size) {
- if (!pcaps) {
- return false;
- }
- ASSERT(size == sizeof(T));
- return AddFormat(pmt, *(T*)pcaps);
- }
-
- virtual CString MakeFormatName(AM_MEDIA_TYPE* pmt) = 0;
- virtual CString MakeDimensionName(CFormatElem<T>* pfe) = 0;
+ virtual ~CFormatArray() {}
+
+ CFormat<T>* Find(CString name, bool fCreate = false) {
+ for (size_t i = 0; i < GetCount(); ++i) {
+ if (GetAt(i)->name == name) {
+ return GetAt(i);
+ }
+ }
+
+ if (fCreate) {
+ CAutoPtr<CFormat<T> > pf(DNew CFormat<T>(name));
+ CFormat<T>* tmp = pf;
+ Add(pf);
+ return tmp;
+ }
+
+ return NULL;
+ }
+
+ bool FindFormat(AM_MEDIA_TYPE* pmt, CFormat<T>** ppf) {
+ if (!pmt) {
+ return false;
+ }
+
+ for (size_t i = 0; i < GetCount(); ++i) {
+ CFormat<T>* pf = GetAt(i);
+ for (size_t j = 0; j < pf->GetCount(); ++j) {
+ CFormatElem<T>* pfe = pf->GetAt(j);
+ if (!pmt || (pfe->mt.majortype == pmt->majortype && pfe->mt.subtype == pmt->subtype)) {
+ if (ppf) {
+ *ppf = pf;
+ }
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ bool FindFormat(AM_MEDIA_TYPE* pmt, T* pcaps, CFormat<T>** ppf, CFormatElem<T>** ppfe) {
+ if (!pmt && !pcaps) {
+ return false;
+ }
+
+ for (size_t i = 0; i < GetCount(); ++i) {
+ CFormat<T>* pf = GetAt(i);
+ for (size_t j = 0; j < pf->GetCount(); ++j) {
+ CFormatElem<T>* pfe = pf->GetAt(j);
+ if ((!pmt || pfe->mt == *pmt) && (!pcaps || !memcmp(pcaps, &pfe->caps, sizeof(T)))) {
+ if (ppf) {
+ *ppf = pf;
+ }
+ if (ppfe) {
+ *ppfe = pfe;
+ }
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ bool AddFormat(AM_MEDIA_TYPE* pmt, T caps) {
+ if (!pmt) {
+ return false;
+ }
+
+ if (FindFormat(pmt, NULL, NULL, NULL)) {
+ DeleteMediaType(pmt);
+ return false;
+ }
+ // if (pmt->formattype == FORMAT_VideoInfo2) {DeleteMediaType(pmt); return false;} // TODO
+
+ CFormat<T>* pf = Find(MakeFormatName(pmt), true);
+ if (!pf) {
+ DeleteMediaType(pmt);
+ return false;
+ }
+
+ CAutoPtr<CFormatElem<T> > pfe(DNew CFormatElem<T>());
+ pfe->mt = *pmt;
+ pfe->caps = caps;
+ pf->Add(pfe);
+
+ return true;
+ }
+
+ bool AddFormat(AM_MEDIA_TYPE* pmt, void* pcaps, int size) {
+ if (!pcaps) {
+ return false;
+ }
+ ASSERT(size == sizeof(T));
+ return AddFormat(pmt, *(T*)pcaps);
+ }
+
+ virtual CString MakeFormatName(AM_MEDIA_TYPE* pmt) = 0;
+ virtual CString MakeDimensionName(CFormatElem<T>* pfe) = 0;
};
typedef CFormatElem<VIDEO_STREAM_CONFIG_CAPS> CVidFormatElem;
@@ -162,92 +162,92 @@ typedef CFormat<VIDEO_STREAM_CONFIG_CAPS> CVidFormat;
class CVidFormatArray : public CFormatArray<VIDEO_STREAM_CONFIG_CAPS>
{
public:
- CString MakeFormatName(AM_MEDIA_TYPE* pmt) {
- CString str(_T("Default"));
-
- if (!pmt) {
- return str;
- }
-
- BITMAPINFOHEADER* bih = (pmt->formattype == FORMAT_VideoInfo)
- ? &((VIDEOINFOHEADER*)pmt->pbFormat)->bmiHeader
- : (pmt->formattype == FORMAT_VideoInfo2)
- ? &((VIDEOINFOHEADER2*)pmt->pbFormat)->bmiHeader
- : NULL;
-
- if (!bih) {
- // it may have a fourcc in the mediasubtype, let's check that
-
- WCHAR guid[100];
- memset(guid, 0, 100*sizeof(WCHAR));
- StringFromGUID2(pmt->subtype, guid, 100);
-
- if (CStringW(guid).MakeUpper().Find(L"0000-0010-8000-00AA00389B71") >= 0) {
- str.Format(_T("%c%c%c%c"),
- (TCHAR)((pmt->subtype.Data1>>0)&0xff), (TCHAR)((pmt->subtype.Data1>>8)&0xff),
- (TCHAR)((pmt->subtype.Data1>>16)&0xff), (TCHAR)((pmt->subtype.Data1>>24)&0xff));
- }
-
- return str;
- }
-
- switch (bih->biCompression) {
- case BI_RGB:
- str.Format(_T("RGB%d"), bih->biBitCount);
- break;
- case BI_RLE8:
- str = _T("RLE8");
- break;
- case BI_RLE4:
- str = _T("RLE4");
- break;
- case BI_BITFIELDS:
- str.Format(_T("BITF%d"), bih->biBitCount);
- break;
- case BI_JPEG:
- str = _T("JPEG");
- break;
- case BI_PNG:
- str = _T("PNG");
- break;
- default:
- str.Format(_T("%c%c%c%c"),
- (TCHAR)((bih->biCompression>>0)&0xff), (TCHAR)((bih->biCompression>>8)&0xff),
- (TCHAR)((bih->biCompression>>16)&0xff), (TCHAR)((bih->biCompression>>24)&0xff));
- break;
- }
-
- return str;
- }
-
- CString MakeDimensionName(CVidFormatElem* pfe) {
- CString str(_T("Default"));
-
- if (!pfe) {
- return str;
- }
-
- BITMAPINFOHEADER* bih = (pfe->mt.formattype == FORMAT_VideoInfo)
- ? &((VIDEOINFOHEADER*)pfe->mt.pbFormat)->bmiHeader
- : (pfe->mt.formattype == FORMAT_VideoInfo2)
- ? &((VIDEOINFOHEADER2*)pfe->mt.pbFormat)->bmiHeader
- : NULL;
-
- if (bih == NULL) {
- return str;
- }
-
- str.Format(_T("%dx%d %.2f"), bih->biWidth, bih->biHeight, (float)10000000/((VIDEOINFOHEADER*)pfe->mt.pbFormat)->AvgTimePerFrame);
-
- if (pfe->mt.formattype == FORMAT_VideoInfo2) {
- VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)pfe->mt.pbFormat;
- CString str2;
- str2.Format(_T(" i%02x %d:%d"), vih2->dwInterlaceFlags, vih2->dwPictAspectRatioX, vih2->dwPictAspectRatioY);
- str += str2;
- }
-
- return str;
- }
+ CString MakeFormatName(AM_MEDIA_TYPE* pmt) {
+ CString str(_T("Default"));
+
+ if (!pmt) {
+ return str;
+ }
+
+ BITMAPINFOHEADER* bih = (pmt->formattype == FORMAT_VideoInfo)
+ ? &((VIDEOINFOHEADER*)pmt->pbFormat)->bmiHeader
+ : (pmt->formattype == FORMAT_VideoInfo2)
+ ? &((VIDEOINFOHEADER2*)pmt->pbFormat)->bmiHeader
+ : NULL;
+
+ if (!bih) {
+ // it may have a fourcc in the mediasubtype, let's check that
+
+ WCHAR guid[100];
+ memset(guid, 0, 100 * sizeof(WCHAR));
+ StringFromGUID2(pmt->subtype, guid, 100);
+
+ if (CStringW(guid).MakeUpper().Find(L"0000-0010-8000-00AA00389B71") >= 0) {
+ str.Format(_T("%c%c%c%c"),
+ (TCHAR)((pmt->subtype.Data1 >> 0) & 0xff), (TCHAR)((pmt->subtype.Data1 >> 8) & 0xff),
+ (TCHAR)((pmt->subtype.Data1 >> 16) & 0xff), (TCHAR)((pmt->subtype.Data1 >> 24) & 0xff));
+ }
+
+ return str;
+ }
+
+ switch (bih->biCompression) {
+ case BI_RGB:
+ str.Format(_T("RGB%d"), bih->biBitCount);
+ break;
+ case BI_RLE8:
+ str = _T("RLE8");
+ break;
+ case BI_RLE4:
+ str = _T("RLE4");
+ break;
+ case BI_BITFIELDS:
+ str.Format(_T("BITF%d"), bih->biBitCount);
+ break;
+ case BI_JPEG:
+ str = _T("JPEG");
+ break;
+ case BI_PNG:
+ str = _T("PNG");
+ break;
+ default:
+ str.Format(_T("%c%c%c%c"),
+ (TCHAR)((bih->biCompression >> 0) & 0xff), (TCHAR)((bih->biCompression >> 8) & 0xff),
+ (TCHAR)((bih->biCompression >> 16) & 0xff), (TCHAR)((bih->biCompression >> 24) & 0xff));
+ break;
+ }
+
+ return str;
+ }
+
+ CString MakeDimensionName(CVidFormatElem* pfe) {
+ CString str(_T("Default"));
+
+ if (!pfe) {
+ return str;
+ }
+
+ BITMAPINFOHEADER* bih = (pfe->mt.formattype == FORMAT_VideoInfo)
+ ? &((VIDEOINFOHEADER*)pfe->mt.pbFormat)->bmiHeader
+ : (pfe->mt.formattype == FORMAT_VideoInfo2)
+ ? &((VIDEOINFOHEADER2*)pfe->mt.pbFormat)->bmiHeader
+ : NULL;
+
+ if (bih == NULL) {
+ return str;
+ }
+
+ str.Format(_T("%dx%d %.2f"), bih->biWidth, bih->biHeight, (float)10000000 / ((VIDEOINFOHEADER*)pfe->mt.pbFormat)->AvgTimePerFrame);
+
+ if (pfe->mt.formattype == FORMAT_VideoInfo2) {
+ VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)pfe->mt.pbFormat;
+ CString str2;
+ str2.Format(_T(" i%02x %d:%d"), vih2->dwInterlaceFlags, vih2->dwPictAspectRatioX, vih2->dwPictAspectRatioY);
+ str += str2;
+ }
+
+ return str;
+ }
};
typedef CFormatElem<AUDIO_STREAM_CONFIG_CAPS> CAudFormatElem;
@@ -256,92 +256,92 @@ typedef CFormat<AUDIO_STREAM_CONFIG_CAPS> CAudFormat;
class CAudFormatArray : public CFormatArray<AUDIO_STREAM_CONFIG_CAPS>
{
public:
- CString MakeFormatName(AM_MEDIA_TYPE* pmt) {
- CString str(_T("Unknown"));
-
- if (!pmt) {
- return str;
- }
-
- WAVEFORMATEX* wfe = (pmt->formattype == FORMAT_WaveFormatEx)
- ? (WAVEFORMATEX*)pmt->pbFormat
- : NULL;
-
- if (!wfe) {
- WCHAR guid[100];
- memset(guid, 0, 100*sizeof(WCHAR));
- StringFromGUID2(pmt->subtype, guid, 100);
-
- if (CStringW(guid).MakeUpper().Find(L"0000-0010-8000-00AA00389B71") >= 0) {
- str.Format(_T("0x%04x"), pmt->subtype.Data1);
- }
-
- return str;
- }
-
- switch (wfe->wFormatTag) {
- case 1:
- str = _T("PCM ");
- break;
- default:
- str.Format(_T("0x%03x "), wfe->wFormatTag);
- break;
- }
-
- return str;
- }
-
- CString MakeDimensionName(CAudFormatElem* pfe) {
- CString str(_T("Unknown"));
-
- if (!pfe) {
- return str;
- }
-
- WAVEFORMATEX* wfe = (pfe->mt.formattype == FORMAT_WaveFormatEx)
- ? (WAVEFORMATEX*)pfe->mt.pbFormat
- : NULL;
-
- if (!wfe) {
- return str;
- }
-
- str.Empty();
- CString str2;
-
- str2.Format(_T("%6dKHz "), wfe->nSamplesPerSec);
- str += str2;
-
- str2.Format(_T("%dbps "), wfe->wBitsPerSample);
- str += str2;
-
- switch (wfe->nChannels) {
- case 1:
- str += _T("mono ");
- break;
- case 2:
- str += _T("stereo ");
- break;
- default:
- str2.Format(_T("%d channels "), wfe->nChannels);
- str += str2;
- break;
- }
-
- str2.Format(_T("%3dkbps "), wfe->nAvgBytesPerSec*8/1000);
- str += str2;
-
- return str;
- }
+ CString MakeFormatName(AM_MEDIA_TYPE* pmt) {
+ CString str(_T("Unknown"));
+
+ if (!pmt) {
+ return str;
+ }
+
+ WAVEFORMATEX* wfe = (pmt->formattype == FORMAT_WaveFormatEx)
+ ? (WAVEFORMATEX*)pmt->pbFormat
+ : NULL;
+
+ if (!wfe) {
+ WCHAR guid[100];
+ memset(guid, 0, 100 * sizeof(WCHAR));
+ StringFromGUID2(pmt->subtype, guid, 100);
+
+ if (CStringW(guid).MakeUpper().Find(L"0000-0010-8000-00AA00389B71") >= 0) {
+ str.Format(_T("0x%04x"), pmt->subtype.Data1);
+ }
+
+ return str;
+ }
+
+ switch (wfe->wFormatTag) {
+ case 1:
+ str = _T("PCM ");
+ break;
+ default:
+ str.Format(_T("0x%03x "), wfe->wFormatTag);
+ break;
+ }
+
+ return str;
+ }
+
+ CString MakeDimensionName(CAudFormatElem* pfe) {
+ CString str(_T("Unknown"));
+
+ if (!pfe) {
+ return str;
+ }
+
+ WAVEFORMATEX* wfe = (pfe->mt.formattype == FORMAT_WaveFormatEx)
+ ? (WAVEFORMATEX*)pfe->mt.pbFormat
+ : NULL;
+
+ if (!wfe) {
+ return str;
+ }
+
+ str.Empty();
+ CString str2;
+
+ str2.Format(_T("%6dKHz "), wfe->nSamplesPerSec);
+ str += str2;
+
+ str2.Format(_T("%dbps "), wfe->wBitsPerSample);
+ str += str2;
+
+ switch (wfe->nChannels) {
+ case 1:
+ str += _T("mono ");
+ break;
+ case 2:
+ str += _T("stereo ");
+ break;
+ default:
+ str2.Format(_T("%d channels "), wfe->nChannels);
+ str += str2;
+ break;
+ }
+
+ str2.Format(_T("%3dkbps "), wfe->nAvgBytesPerSec * 8 / 1000);
+ str += str2;
+
+ return str;
+ }
};
//
typedef struct {
- CComPtr<IMoniker> pMoniker;
- CComPtr<IBaseFilter> pBF;
- CString FriendlyName;
- CComBSTR DisplayName;
+ CComPtr<IMoniker> pMoniker;
+ CComPtr<IBaseFilter> pBF;
+ CString FriendlyName;
+ CComBSTR DisplayName;
} Codec;
typedef CAtlArray<Codec> CCodecArray;
@@ -350,143 +350,143 @@ typedef CAtlArray<Codec> CCodecArray;
class CPlayerCaptureDialog : public CResizableDialog //CDialog
{
- //DECLARE_DYNAMIC(CPlayerCaptureDialog)
+ //DECLARE_DYNAMIC(CPlayerCaptureDialog)
- // video input
- CStringW m_VidDisplayName;
- CComPtr<IAMStreamConfig> m_pAMVSC;
- CComPtr<IAMCrossbar> m_pAMXB;
- CComPtr<IAMTVTuner> m_pAMTuner;
- CComPtr<IAMVfwCaptureDialogs> m_pAMVfwCD;
- CVidFormatArray m_vfa;
+ // video input
+ CStringW m_VidDisplayName;
+ CComPtr<IAMStreamConfig> m_pAMVSC;
+ CComPtr<IAMCrossbar> m_pAMXB;
+ CComPtr<IAMTVTuner> m_pAMTuner;
+ CComPtr<IAMVfwCaptureDialogs> m_pAMVfwCD;
+ CVidFormatArray m_vfa;
- // audio input
- CStringW m_AudDisplayName;
- CComPtr<IAMStreamConfig> m_pAMASC;
- CInterfaceArray<IAMAudioInputMixer> m_pAMAIM;
- CAudFormatArray m_afa;
+ // audio input
+ CStringW m_AudDisplayName;
+ CComPtr<IAMStreamConfig> m_pAMASC;
+ CInterfaceArray<IAMAudioInputMixer> m_pAMAIM;
+ CAudFormatArray m_afa;
- // video codec
- CCodecArray m_pVidEncArray;
- CVidFormatArray m_vcfa;
+ // video codec
+ CCodecArray m_pVidEncArray;
+ CVidFormatArray m_vcfa;
- // audio codec
- CCodecArray m_pAudEncArray;
- CAudFormatArray m_acfa;
+ // audio codec
+ CCodecArray m_pAudEncArray;
+ CAudFormatArray m_acfa;
- void EmptyVideo();
- void EmptyAudio();
+ void EmptyVideo();
+ void EmptyAudio();
- void UpdateMediaTypes();
- void UpdateUserDefinableControls();
- void UpdateVideoCodec();
- void UpdateAudioCodec();
- void UpdateMuxer();
- void UpdateOutputControls();
+ void UpdateMediaTypes();
+ void UpdateUserDefinableControls();
+ void UpdateVideoCodec();
+ void UpdateAudioCodec();
+ void UpdateMuxer();
+ void UpdateOutputControls();
- void UpdateGraph();
+ void UpdateGraph();
- CMap<HWND, HWND&, BOOL, BOOL&> m_wndenabledmap;
- void EnableControls(CWnd* pWnd, bool fEnable);
+ CMap<HWND, HWND&, BOOL, BOOL&> m_wndenabledmap;
+ void EnableControls(CWnd* pWnd, bool fEnable);
- bool m_fEnableOgm;
+ bool m_fEnableOgm;
public:
- CPlayerCaptureDialog(); // standard constructor
- virtual ~CPlayerCaptureDialog();
-
- BOOL Create(CWnd* pParent = NULL);
-
- // Dialog Data
- enum { IDD = IDD_CAPTURE_DLG };
-
- CComboBox m_vidinput;
- CComboBox m_vidtype;
- CComboBox m_viddimension;
- CSpinButtonCtrl m_vidhor;
- CSpinButtonCtrl m_vidver;
- CEdit m_vidhoredit;
- CEdit m_vidveredit;
- CFloatEdit m_vidfpsedit;
- float m_vidfps;
- CButton m_vidsetres;
- CComboBox m_audinput;
- CComboBox m_audtype;
- CComboBox m_auddimension;
- CComboBox m_vidcodec;
- CComboBox m_vidcodectype;
- CComboBox m_vidcodecdimension;
- BOOL m_fVidOutput;
- CButton m_vidoutput;
- int m_fVidPreview;
- CButton m_vidpreview;
- CComboBox m_audcodec;
- CComboBox m_audcodectype;
- CComboBox m_audcodecdimension;
- BOOL m_fAudOutput;
- CButton m_audoutput;
- int m_fAudPreview;
- CButton m_audpreview;
- int m_nVidBuffers;
- int m_nAudBuffers;
- CString m_file;
- CButton m_recordbtn;
- BOOL m_fSepAudio;
- int m_muxtype;
- CComboBox m_muxctrl;
-
- CMediaType m_mtv, m_mta, m_mtcv, m_mtca;
- CComPtr<IBaseFilter> m_pVidEnc, m_pAudEnc, m_pMux, m_pDst, m_pAudMux, m_pAudDst;
- CComPtr<IMoniker> m_pVidEncMoniker, m_pAudEncMoniker;
- CComPtr<IBaseFilter> m_pVidBuffer, m_pAudBuffer;
+ CPlayerCaptureDialog(); // standard constructor
+ virtual ~CPlayerCaptureDialog();
+
+ BOOL Create(CWnd* pParent = NULL);
+
+ // Dialog Data
+ enum { IDD = IDD_CAPTURE_DLG };
+
+ CComboBox m_vidinput;
+ CComboBox m_vidtype;
+ CComboBox m_viddimension;
+ CSpinButtonCtrl m_vidhor;
+ CSpinButtonCtrl m_vidver;
+ CEdit m_vidhoredit;
+ CEdit m_vidveredit;
+ CFloatEdit m_vidfpsedit;
+ float m_vidfps;
+ CButton m_vidsetres;
+ CComboBox m_audinput;
+ CComboBox m_audtype;
+ CComboBox m_auddimension;
+ CComboBox m_vidcodec;
+ CComboBox m_vidcodectype;
+ CComboBox m_vidcodecdimension;
+ BOOL m_fVidOutput;
+ CButton m_vidoutput;
+ int m_fVidPreview;
+ CButton m_vidpreview;
+ CComboBox m_audcodec;
+ CComboBox m_audcodectype;
+ CComboBox m_audcodecdimension;
+ BOOL m_fAudOutput;
+ CButton m_audoutput;
+ int m_fAudPreview;
+ CButton m_audpreview;
+ int m_nVidBuffers;
+ int m_nAudBuffers;
+ CString m_file;
+ CButton m_recordbtn;
+ BOOL m_fSepAudio;
+ int m_muxtype;
+ CComboBox m_muxctrl;
+
+ CMediaType m_mtv, m_mta, m_mtcv, m_mtca;
+ CComPtr<IBaseFilter> m_pVidEnc, m_pAudEnc, m_pMux, m_pDst, m_pAudMux, m_pAudDst;
+ CComPtr<IMoniker> m_pVidEncMoniker, m_pAudEncMoniker;
+ CComPtr<IBaseFilter> m_pVidBuffer, m_pAudBuffer;
public:
- void SetupVideoControls(CStringW DisplayName, IAMStreamConfig* pAMSC, IAMCrossbar* pAMXB, IAMTVTuner* pAMTuner);
- void SetupVideoControls(CStringW DisplayName, IAMStreamConfig* pAMSC, IAMVfwCaptureDialogs* pAMVfwCD);
- void SetupAudioControls(CStringW DisplayName, IAMStreamConfig* pAMSC, const CInterfaceArray<IAMAudioInputMixer>& pAMAIM);
+ void SetupVideoControls(CStringW DisplayName, IAMStreamConfig* pAMSC, IAMCrossbar* pAMXB, IAMTVTuner* pAMTuner);
+ void SetupVideoControls(CStringW DisplayName, IAMStreamConfig* pAMSC, IAMVfwCaptureDialogs* pAMVfwCD);
+ void SetupAudioControls(CStringW DisplayName, IAMStreamConfig* pAMSC, const CInterfaceArray<IAMAudioInputMixer>& pAMAIM);
- bool IsTunerActive();
+ bool IsTunerActive();
- bool SetVideoInput(int input);
- bool SetVideoChannel(int channel);
- bool SetAudioInput(int input);
+ bool SetVideoInput(int input);
+ bool SetVideoChannel(int channel);
+ bool SetAudioInput(int input);
- int GetVideoInput();
- int GetVideoChannel();
- int GetAudioInput();
+ int GetVideoInput();
+ int GetVideoChannel();
+ int GetAudioInput();
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- virtual BOOL OnInitDialog();
- virtual void OnOK() {}
- virtual void OnCancel() {}
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL OnInitDialog();
+ virtual void OnOK() {}
+ virtual void OnCancel() {}
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnDestroy();
- afx_msg void OnVideoInput();
- afx_msg void OnVideoType();
- afx_msg void OnVideoDimension();
- afx_msg void OnOverrideVideoDimension();
- afx_msg void OnAudioInput();
- afx_msg void OnAudioType();
- afx_msg void OnAudioDimension();
- afx_msg void OnRecordVideo();
- afx_msg void OnVideoCodec();
- afx_msg void OnVideoCodecType();
- afx_msg void OnVideoCodecDimension();
- afx_msg void OnRecordAudio();
- afx_msg void OnAudioCodec();
- afx_msg void OnAudioCodecType();
- afx_msg void OnAudioCodecDimension();
- afx_msg void OnOpenFile();
- afx_msg void OnRecord();
- afx_msg void OnEnChangeEdit9();
- afx_msg void OnEnChangeEdit12();
- afx_msg void OnTimer(UINT_PTR nIDEvent);
- afx_msg void OnBnClickedVidAudPreview();
- afx_msg void OnBnClickedCheck7();
- afx_msg void OnCbnSelchangeCombo14();
+ afx_msg void OnDestroy();
+ afx_msg void OnVideoInput();
+ afx_msg void OnVideoType();
+ afx_msg void OnVideoDimension();
+ afx_msg void OnOverrideVideoDimension();
+ afx_msg void OnAudioInput();
+ afx_msg void OnAudioType();
+ afx_msg void OnAudioDimension();
+ afx_msg void OnRecordVideo();
+ afx_msg void OnVideoCodec();
+ afx_msg void OnVideoCodecType();
+ afx_msg void OnVideoCodecDimension();
+ afx_msg void OnRecordAudio();
+ afx_msg void OnAudioCodec();
+ afx_msg void OnAudioCodecType();
+ afx_msg void OnAudioCodecDimension();
+ afx_msg void OnOpenFile();
+ afx_msg void OnRecord();
+ afx_msg void OnEnChangeEdit9();
+ afx_msg void OnEnChangeEdit12();
+ afx_msg void OnTimer(UINT_PTR nIDEvent);
+ afx_msg void OnBnClickedVidAudPreview();
+ afx_msg void OnBnClickedCheck7();
+ afx_msg void OnCbnSelchangeCombo14();
};
diff --git a/src/mpc-hc/PlayerInfoBar.cpp b/src/mpc-hc/PlayerInfoBar.cpp
index 6d13ec918..027d3329d 100644
--- a/src/mpc-hc/PlayerInfoBar.cpp
+++ b/src/mpc-hc/PlayerInfoBar.cpp
@@ -40,122 +40,122 @@ CPlayerInfoBar::~CPlayerInfoBar()
void CPlayerInfoBar::SetLine(CString label, CString info)
{
- if (info.IsEmpty()) {
- RemoveLine(label);
- return;
- }
-
- for (size_t idx = 0; idx < m_label.GetCount(); idx++) {
- CString tmp;
- m_label[idx]->GetWindowText(tmp);
- if (label == tmp) {
- m_info[idx]->GetWindowText(tmp);
- if (info != tmp) {
- m_info[idx]->SetWindowText(info);
- }
- return;
- }
- }
-
- CAutoPtr<CStatusLabel> l(DNew CStatusLabel(true, false));
- l->Create(label, WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS|SS_OWNERDRAW, CRect(0,0,0,0), this);
- m_label.Add(l);
-
- CAutoPtr<CStatusLabel> i(DNew CStatusLabel(false, true));
- i->Create(info, WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS|SS_OWNERDRAW, CRect(0,0,0,0), this);
- m_info.Add(i);
-
- Relayout();
+ if (info.IsEmpty()) {
+ RemoveLine(label);
+ return;
+ }
+
+ for (size_t idx = 0; idx < m_label.GetCount(); idx++) {
+ CString tmp;
+ m_label[idx]->GetWindowText(tmp);
+ if (label == tmp) {
+ m_info[idx]->GetWindowText(tmp);
+ if (info != tmp) {
+ m_info[idx]->SetWindowText(info);
+ }
+ return;
+ }
+ }
+
+ CAutoPtr<CStatusLabel> l(DNew CStatusLabel(true, false));
+ l->Create(label, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | SS_OWNERDRAW, CRect(0, 0, 0, 0), this);
+ m_label.Add(l);
+
+ CAutoPtr<CStatusLabel> i(DNew CStatusLabel(false, true));
+ i->Create(info, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | SS_OWNERDRAW, CRect(0, 0, 0, 0), this);
+ m_info.Add(i);
+
+ Relayout();
}
void CPlayerInfoBar::GetLine(CString label, CString& info)
{
- info.Empty();
-
- for (size_t idx = 0; idx < m_label.GetCount(); idx++) {
- CString tmp;
- m_label[idx]->GetWindowText(tmp);
- if (label == tmp) {
- m_info[idx]->GetWindowText(tmp);
- info = tmp;
- return;
- }
- }
+ info.Empty();
+
+ for (size_t idx = 0; idx < m_label.GetCount(); idx++) {
+ CString tmp;
+ m_label[idx]->GetWindowText(tmp);
+ if (label == tmp) {
+ m_info[idx]->GetWindowText(tmp);
+ info = tmp;
+ return;
+ }
+ }
}
void CPlayerInfoBar::RemoveLine(CString label)
{
- for (size_t i = 0; i < m_label.GetCount(); i++) {
- CString tmp;
- m_label[i]->GetWindowText(tmp);
- if (label == tmp) {
- m_label.RemoveAt(i);
- m_info.RemoveAt(i);
- break;
- }
- }
-
- Relayout();
+ for (size_t i = 0; i < m_label.GetCount(); i++) {
+ CString tmp;
+ m_label[i]->GetWindowText(tmp);
+ if (label == tmp) {
+ m_label.RemoveAt(i);
+ m_info.RemoveAt(i);
+ break;
+ }
+ }
+
+ Relayout();
}
void CPlayerInfoBar::RemoveAllLines()
{
- m_label.RemoveAll();
- m_info.RemoveAll();
+ m_label.RemoveAll();
+ m_info.RemoveAll();
- Relayout();
+ Relayout();
}
BOOL CPlayerInfoBar::Create(CWnd* pParentWnd)
{
- return CDialogBar::Create(pParentWnd, IDD_PLAYERINFOBAR, WS_CHILD|WS_VISIBLE|CBRS_ALIGN_BOTTOM, IDD_PLAYERINFOBAR);
+ return CDialogBar::Create(pParentWnd, IDD_PLAYERINFOBAR, WS_CHILD | WS_VISIBLE | CBRS_ALIGN_BOTTOM, IDD_PLAYERINFOBAR);
}
BOOL CPlayerInfoBar::PreCreateWindow(CREATESTRUCT& cs)
{
- if (!CDialogBar::PreCreateWindow(cs)) {
- return FALSE;
- }
+ if (!CDialogBar::PreCreateWindow(cs)) {
+ return FALSE;
+ }
- m_dwStyle &= ~CBRS_BORDER_TOP;
- m_dwStyle &= ~CBRS_BORDER_BOTTOM;
+ m_dwStyle &= ~CBRS_BORDER_TOP;
+ m_dwStyle &= ~CBRS_BORDER_BOTTOM;
- return TRUE;
+ return TRUE;
}
CSize CPlayerInfoBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz)
{
- CRect r;
- GetParent()->GetClientRect(&r);
- r.bottom = r.top + (LONG)m_label.GetCount() * 17 + (m_label.GetCount() ? 4 : 0);
- return r.Size();
+ CRect r;
+ GetParent()->GetClientRect(&r);
+ r.bottom = r.top + (LONG)m_label.GetCount() * 17 + (m_label.GetCount() ? 4 : 0);
+ return r.Size();
}
void CPlayerInfoBar::Relayout()
{
- CRect r;
- GetParent()->GetClientRect(&r);
-
- int w = m_nFirstColWidth, h = 17, y = 2;
-
- for (size_t i = 0; i < m_label.GetCount(); i++) {
- CDC* pDC = m_label[i]->GetDC();
- CString str;
- m_label[i]->GetWindowText(str);
- w = max(w, pDC->GetTextExtent(str).cx);
- m_label[i]->ReleaseDC(pDC);
- }
-
- for (size_t i = 0; i < m_label.GetCount(); i++, y += h) {
- m_label[i]->MoveWindow(1, y, w - 10, h);
- m_info[i]->MoveWindow(w + 10, y, r.Width()-(w+10)-1, h);
- }
+ CRect r;
+ GetParent()->GetClientRect(&r);
+
+ int w = m_nFirstColWidth, h = 17, y = 2;
+
+ for (size_t i = 0; i < m_label.GetCount(); i++) {
+ CDC* pDC = m_label[i]->GetDC();
+ CString str;
+ m_label[i]->GetWindowText(str);
+ w = max(w, pDC->GetTextExtent(str).cx);
+ m_label[i]->ReleaseDC(pDC);
+ }
+
+ for (size_t i = 0; i < m_label.GetCount(); i++, y += h) {
+ m_label[i]->MoveWindow(1, y, w - 10, h);
+ m_info[i]->MoveWindow(w + 10, y, r.Width() - (w + 10) - 1, h);
+ }
}
BEGIN_MESSAGE_MAP(CPlayerInfoBar, CDialogBar)
- ON_WM_ERASEBKGND()
- ON_WM_SIZE()
- ON_WM_LBUTTONDOWN()
+ ON_WM_ERASEBKGND()
+ ON_WM_SIZE()
+ ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()
@@ -164,49 +164,49 @@ END_MESSAGE_MAP()
BOOL CPlayerInfoBar::OnEraseBkgnd(CDC* pDC)
{
- for (CWnd* pChild = GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow()) {
- CRect r;
- pChild->GetClientRect(&r);
- pChild->MapWindowPoints(this, &r);
- pDC->ExcludeClipRect(&r);
- }
+ for (CWnd* pChild = GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow()) {
+ CRect r;
+ pChild->GetClientRect(&r);
+ pChild->MapWindowPoints(this, &r);
+ pDC->ExcludeClipRect(&r);
+ }
- CRect r;
- GetClientRect(&r);
+ CRect r;
+ GetClientRect(&r);
- CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
+ CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
- if (pFrame->m_pLastBar != this || pFrame->m_fFullScreen) {
- r.InflateRect(0, 0, 0, 1);
- }
+ if (pFrame->m_pLastBar != this || pFrame->m_fFullScreen) {
+ r.InflateRect(0, 0, 0, 1);
+ }
- if (pFrame->m_fFullScreen) {
- r.InflateRect(1, 0, 1, 0);
- }
+ if (pFrame->m_fFullScreen) {
+ r.InflateRect(1, 0, 1, 0);
+ }
- pDC->Draw3dRect(&r, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
+ pDC->Draw3dRect(&r, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
- r.DeflateRect(1, 1);
+ r.DeflateRect(1, 1);
- pDC->FillSolidRect(&r, 0);
+ pDC->FillSolidRect(&r, 0);
- return TRUE;
+ return TRUE;
}
void CPlayerInfoBar::OnSize(UINT nType, int cx, int cy)
{
- CDialogBar::OnSize(nType, cx, cy);
+ CDialogBar::OnSize(nType, cx, cy);
- Relayout();
+ Relayout();
- Invalidate();
+ Invalidate();
}
void CPlayerInfoBar::OnLButtonDown(UINT nFlags, CPoint point)
{
- CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
- if (!pFrame->m_fFullScreen) {
- MapWindowPoints(pFrame, &point, 1);
- pFrame->PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y));
- }
+ CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
+ if (!pFrame->m_fFullScreen) {
+ MapWindowPoints(pFrame, &point, 1);
+ pFrame->PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y));
+ }
}
diff --git a/src/mpc-hc/PlayerInfoBar.h b/src/mpc-hc/PlayerInfoBar.h
index 92ccdf140..dde3024bb 100644
--- a/src/mpc-hc/PlayerInfoBar.h
+++ b/src/mpc-hc/PlayerInfoBar.h
@@ -31,35 +31,35 @@
class CPlayerInfoBar : public CDialogBar
{
- DECLARE_DYNAMIC(CPlayerInfoBar)
+ DECLARE_DYNAMIC(CPlayerInfoBar)
private:
- CAutoPtrArray<CStatusLabel> m_label;
- CAutoPtrArray<CStatusLabel> m_info;
+ CAutoPtrArray<CStatusLabel> m_label;
+ CAutoPtrArray<CStatusLabel> m_info;
- int m_nFirstColWidth;
+ int m_nFirstColWidth;
- void Relayout();
+ void Relayout();
public:
- CPlayerInfoBar(int nFirstColWidth = 100);
- virtual ~CPlayerInfoBar();
+ CPlayerInfoBar(int nFirstColWidth = 100);
+ virtual ~CPlayerInfoBar();
- BOOL Create(CWnd* pParentWnd);
+ BOOL Create(CWnd* pParentWnd);
- void SetLine(CString label, CString info);
- void GetLine(CString label, CString& info);
- void RemoveLine(CString label);
- void RemoveAllLines();
+ void SetLine(CString label, CString info);
+ void GetLine(CString label, CString& info);
+ void RemoveLine(CString label);
+ void RemoveAllLines();
protected:
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
+ virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
+ virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
public:
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
- afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg BOOL OnEraseBkgnd(CDC* pDC);
+ afx_msg void OnSize(UINT nType, int cx, int cy);
- DECLARE_MESSAGE_MAP()
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
+ DECLARE_MESSAGE_MAP()
+ afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
};
diff --git a/src/mpc-hc/PlayerListCtrl.cpp b/src/mpc-hc/PlayerListCtrl.cpp
index 16b12eb2f..6e346b91d 100644
--- a/src/mpc-hc/PlayerListCtrl.cpp
+++ b/src/mpc-hc/PlayerListCtrl.cpp
@@ -29,11 +29,11 @@
// CInPlaceHotKey
CInPlaceWinHotkey::CInPlaceWinHotkey(int iItem, int iSubItem, CString sInitText)
- : m_sInitText( sInitText )
+ : m_sInitText(sInitText)
{
- m_iItem = iItem;
- m_iSubItem = iSubItem;
- m_bESC = FALSE;
+ m_iItem = iItem;
+ m_iSubItem = iSubItem;
+ m_bESC = FALSE;
}
CInPlaceWinHotkey::~CInPlaceWinHotkey()
@@ -41,95 +41,95 @@ CInPlaceWinHotkey::~CInPlaceWinHotkey()
}
BEGIN_MESSAGE_MAP(CInPlaceWinHotkey, CWinHotkeyCtrl)
- ON_WM_KILLFOCUS()
- ON_WM_NCDESTROY()
- ON_WM_CHAR()
- ON_WM_CREATE()
+ ON_WM_KILLFOCUS()
+ ON_WM_NCDESTROY()
+ ON_WM_CHAR()
+ ON_WM_CREATE()
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CInPlaceHotKey message handlers
BOOL CInPlaceWinHotkey::PreTranslateMessage(MSG* pMsg)
{
- if (pMsg->message == WM_KEYDOWN) {
- if (pMsg->wParam == VK_RETURN
- || pMsg->wParam == VK_DELETE
- || pMsg->wParam == VK_ESCAPE
- || GetKeyState(VK_CONTROL)) {
- ::TranslateMessage(pMsg);
- ::DispatchMessage(pMsg);
- return TRUE; // DO NOT process further
- }
- }
-
- return CWinHotkeyCtrl::PreTranslateMessage(pMsg);
+ if (pMsg->message == WM_KEYDOWN) {
+ if (pMsg->wParam == VK_RETURN
+ || pMsg->wParam == VK_DELETE
+ || pMsg->wParam == VK_ESCAPE
+ || GetKeyState(VK_CONTROL)) {
+ ::TranslateMessage(pMsg);
+ ::DispatchMessage(pMsg);
+ return TRUE; // DO NOT process further
+ }
+ }
+
+ return CWinHotkeyCtrl::PreTranslateMessage(pMsg);
}
void CInPlaceWinHotkey::OnKillFocus(CWnd* pNewWnd)
{
- CWinHotkeyCtrl::OnKillFocus(pNewWnd);
-
- CString str;
- GetWindowText(str);
-
- LV_DISPINFO dispinfo;
- dispinfo.hdr.hwndFrom = GetParent()->m_hWnd;
- dispinfo.hdr.idFrom = GetDlgCtrlID();
- dispinfo.hdr.code = LVN_ENDLABELEDIT;
- dispinfo.item.mask = LVIF_TEXT;
- dispinfo.item.iItem = m_iItem;
- dispinfo.item.iSubItem = m_iSubItem;
- dispinfo.item.pszText = m_bESC ? NULL : LPTSTR((LPCTSTR)str);
- dispinfo.item.cchTextMax = str.GetLength();
- GetParent()->GetParent()->SendMessage(WM_NOTIFY, GetParent()->GetDlgCtrlID(), (LPARAM)&dispinfo);
-
- DestroyWindow();
+ CWinHotkeyCtrl::OnKillFocus(pNewWnd);
+
+ CString str;
+ GetWindowText(str);
+
+ LV_DISPINFO dispinfo;
+ dispinfo.hdr.hwndFrom = GetParent()->m_hWnd;
+ dispinfo.hdr.idFrom = GetDlgCtrlID();
+ dispinfo.hdr.code = LVN_ENDLABELEDIT;
+ dispinfo.item.mask = LVIF_TEXT;
+ dispinfo.item.iItem = m_iItem;
+ dispinfo.item.iSubItem = m_iSubItem;
+ dispinfo.item.pszText = m_bESC ? NULL : LPTSTR((LPCTSTR)str);
+ dispinfo.item.cchTextMax = str.GetLength();
+ GetParent()->GetParent()->SendMessage(WM_NOTIFY, GetParent()->GetDlgCtrlID(), (LPARAM)&dispinfo);
+
+ DestroyWindow();
}
void CInPlaceWinHotkey::OnNcDestroy()
{
- CWinHotkeyCtrl::OnNcDestroy();
+ CWinHotkeyCtrl::OnNcDestroy();
- delete this;
+ delete this;
}
void CInPlaceWinHotkey::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
- if (nChar == VK_ESCAPE || nChar == VK_RETURN) {
- if (nChar == VK_ESCAPE) {
- m_bESC = TRUE;
- }
- GetParent()->SetFocus();
- return;
- }
-
- CWinHotkeyCtrl::OnChar(nChar, nRepCnt, nFlags);
+ if (nChar == VK_ESCAPE || nChar == VK_RETURN) {
+ if (nChar == VK_ESCAPE) {
+ m_bESC = TRUE;
+ }
+ GetParent()->SetFocus();
+ return;
+ }
+
+ CWinHotkeyCtrl::OnChar(nChar, nRepCnt, nFlags);
}
int CInPlaceWinHotkey::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
- if (CWinHotkeyCtrl::OnCreate(lpCreateStruct) == -1) {
- return -1;
- }
-
- // Set the proper font
- CFont* font = GetParent()->GetFont();
- SetFont(font);
-
- SetWindowText(m_sInitText);
- SetFocus();
- SetSel(0, -1);
- return 0;
+ if (CWinHotkeyCtrl::OnCreate(lpCreateStruct) == -1) {
+ return -1;
+ }
+
+ // Set the proper font
+ CFont* font = GetParent()->GetFont();
+ SetFont(font);
+
+ SetWindowText(m_sInitText);
+ SetFocus();
+ SetSel(0, -1);
+ return 0;
}
// CInPlaceEdit
CInPlaceEdit::CInPlaceEdit(int iItem, int iSubItem, CString sInitText)
- : m_sInitText( sInitText )
+ : m_sInitText(sInitText)
{
- m_iItem = iItem;
- m_iSubItem = iSubItem;
- m_bESC = FALSE;
+ m_iItem = iItem;
+ m_iSubItem = iSubItem;
+ m_bESC = FALSE;
}
CInPlaceEdit::~CInPlaceEdit()
@@ -137,12 +137,12 @@ CInPlaceEdit::~CInPlaceEdit()
}
BEGIN_MESSAGE_MAP(CInPlaceEdit, CEdit)
- //{{AFX_MSG_MAP(CInPlaceEdit)
- ON_WM_KILLFOCUS()
- ON_WM_NCDESTROY()
- ON_WM_CHAR()
- ON_WM_CREATE()
- //}}AFX_MSG_MAP
+ //{{AFX_MSG_MAP(CInPlaceEdit)
+ ON_WM_KILLFOCUS()
+ ON_WM_NCDESTROY()
+ ON_WM_CHAR()
+ ON_WM_CREATE()
+ //}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
@@ -150,88 +150,88 @@ END_MESSAGE_MAP()
BOOL CInPlaceEdit::PreTranslateMessage(MSG* pMsg)
{
- if (pMsg->message == WM_KEYDOWN) {
- if (pMsg->wParam == VK_RETURN
- || pMsg->wParam == VK_DELETE
- || pMsg->wParam == VK_ESCAPE
- || GetKeyState(VK_CONTROL)) {
- ::TranslateMessage(pMsg);
- ::DispatchMessage(pMsg);
- return TRUE; // DO NOT process further
- }
- }
-
- return CEdit::PreTranslateMessage(pMsg);
+ if (pMsg->message == WM_KEYDOWN) {
+ if (pMsg->wParam == VK_RETURN
+ || pMsg->wParam == VK_DELETE
+ || pMsg->wParam == VK_ESCAPE
+ || GetKeyState(VK_CONTROL)) {
+ ::TranslateMessage(pMsg);
+ ::DispatchMessage(pMsg);
+ return TRUE; // DO NOT process further
+ }
+ }
+
+ return CEdit::PreTranslateMessage(pMsg);
}
void CInPlaceEdit::OnKillFocus(CWnd* pNewWnd)
{
- CEdit::OnKillFocus(pNewWnd);
-
- CString str;
- GetWindowText(str);
-
- LV_DISPINFO dispinfo;
- dispinfo.hdr.hwndFrom = GetParent()->m_hWnd;
- dispinfo.hdr.idFrom = GetDlgCtrlID();
- dispinfo.hdr.code = LVN_ENDLABELEDIT;
- dispinfo.item.mask = LVIF_TEXT;
- dispinfo.item.iItem = m_iItem;
- dispinfo.item.iSubItem = m_iSubItem;
- dispinfo.item.pszText = m_bESC ? NULL : LPTSTR((LPCTSTR)str);
- dispinfo.item.cchTextMax = str.GetLength();
- GetParent()->GetParent()->SendMessage(WM_NOTIFY, GetParent()->GetDlgCtrlID(), (LPARAM)&dispinfo);
-
- DestroyWindow();
+ CEdit::OnKillFocus(pNewWnd);
+
+ CString str;
+ GetWindowText(str);
+
+ LV_DISPINFO dispinfo;
+ dispinfo.hdr.hwndFrom = GetParent()->m_hWnd;
+ dispinfo.hdr.idFrom = GetDlgCtrlID();
+ dispinfo.hdr.code = LVN_ENDLABELEDIT;
+ dispinfo.item.mask = LVIF_TEXT;
+ dispinfo.item.iItem = m_iItem;
+ dispinfo.item.iSubItem = m_iSubItem;
+ dispinfo.item.pszText = m_bESC ? NULL : LPTSTR((LPCTSTR)str);
+ dispinfo.item.cchTextMax = str.GetLength();
+ GetParent()->GetParent()->SendMessage(WM_NOTIFY, GetParent()->GetDlgCtrlID(), (LPARAM)&dispinfo);
+
+ DestroyWindow();
}
void CInPlaceEdit::OnNcDestroy()
{
- CEdit::OnNcDestroy();
+ CEdit::OnNcDestroy();
- delete this;
+ delete this;
}
void CInPlaceEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
- if (nChar == VK_ESCAPE || nChar == VK_RETURN) {
- if (nChar == VK_ESCAPE) {
- m_bESC = TRUE;
- }
- GetParent()->SetFocus();
- return;
- }
-
- CEdit::OnChar(nChar, nRepCnt, nFlags);
+ if (nChar == VK_ESCAPE || nChar == VK_RETURN) {
+ if (nChar == VK_ESCAPE) {
+ m_bESC = TRUE;
+ }
+ GetParent()->SetFocus();
+ return;
+ }
+
+ CEdit::OnChar(nChar, nRepCnt, nFlags);
}
int CInPlaceEdit::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
- if (CEdit::OnCreate(lpCreateStruct) == -1) {
- return -1;
- }
-
- // Set the proper font
- CFont* font = GetParent()->GetFont();
- SetFont(font);
-
- SetWindowText(m_sInitText);
- SetFocus();
- SetSel(0, -1);
- return 0;
+ if (CEdit::OnCreate(lpCreateStruct) == -1) {
+ return -1;
+ }
+
+ // Set the proper font
+ CFont* font = GetParent()->GetFont();
+ SetFont(font);
+
+ SetWindowText(m_sInitText);
+ SetFocus();
+ SetSel(0, -1);
+ return 0;
}
// CInPlaceFloatEdit
CInPlaceFloatEdit::CInPlaceFloatEdit(int iItem, int iSubItem, CString sInitText)
- : CInPlaceEdit (iItem, iSubItem, sInitText) {}
+ : CInPlaceEdit(iItem, iSubItem, sInitText) {}
CInPlaceFloatEdit::~CInPlaceFloatEdit()
{
}
BEGIN_MESSAGE_MAP(CInPlaceFloatEdit, CInPlaceEdit)
- ON_WM_CHAR()
+ ON_WM_CHAR()
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
@@ -239,47 +239,47 @@ END_MESSAGE_MAP()
void CInPlaceFloatEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
- if (nChar == VK_ESCAPE || nChar == VK_RETURN) {
- if (nChar == VK_ESCAPE) {
- m_bESC = TRUE;
- }
- GetParent()->SetFocus();
- return;
- }
-
- if (nChar == ',') {
- nChar = '.';
- }
-
- if (!(nChar >= '0' && nChar <= '9' || nChar == '.' || nChar == '\b')) {
- return;
- }
-
- CString str;
- GetWindowText(str);
-
- if ((nChar == '.') && str.Find('.') >= 0) {
- int nStartChar, nEndChar;
- GetSel(nStartChar, nEndChar);
- if (!(nStartChar < nEndChar && str.Mid(nStartChar, nEndChar-nStartChar).Find('.') >= 0)) {
- return;
- }
- }
-
- //CEdit::OnChar(nChar, nRepCnt, nFlags);
- DefWindowProc(WM_CHAR, nChar, MAKELONG(nRepCnt, nFlags));
+ if (nChar == VK_ESCAPE || nChar == VK_RETURN) {
+ if (nChar == VK_ESCAPE) {
+ m_bESC = TRUE;
+ }
+ GetParent()->SetFocus();
+ return;
+ }
+
+ if (nChar == ',') {
+ nChar = '.';
+ }
+
+ if (!(nChar >= '0' && nChar <= '9' || nChar == '.' || nChar == '\b')) {
+ return;
+ }
+
+ CString str;
+ GetWindowText(str);
+
+ if ((nChar == '.') && str.Find('.') >= 0) {
+ int nStartChar, nEndChar;
+ GetSel(nStartChar, nEndChar);
+ if (!(nStartChar < nEndChar && str.Mid(nStartChar, nEndChar - nStartChar).Find('.') >= 0)) {
+ return;
+ }
+ }
+
+ //CEdit::OnChar(nChar, nRepCnt, nFlags);
+ DefWindowProc(WM_CHAR, nChar, MAKELONG(nRepCnt, nFlags));
}
// CInPlaceComboBox
CInPlaceComboBox::CInPlaceComboBox(int iItem, int iSubItem, CAtlList<CString>& lstItems, int nSel)
{
- m_iItem = iItem;
- m_iSubItem = iSubItem;
+ m_iItem = iItem;
+ m_iSubItem = iSubItem;
- m_lstItems.AddTailList(&lstItems);
- m_nSel = nSel;
- m_bESC = FALSE;
+ m_lstItems.AddTailList(&lstItems);
+ m_nSel = nSel;
+ m_bESC = FALSE;
}
CInPlaceComboBox::~CInPlaceComboBox()
@@ -287,13 +287,13 @@ CInPlaceComboBox::~CInPlaceComboBox()
}
BEGIN_MESSAGE_MAP(CInPlaceComboBox, CComboBox)
- //{{AFX_MSG_MAP(CInPlaceComboBox)
- ON_WM_CREATE()
- ON_WM_KILLFOCUS()
- ON_WM_CHAR()
- ON_WM_NCDESTROY()
- ON_CONTROL_REFLECT(CBN_CLOSEUP, OnCloseup)
- //}}AFX_MSG_MAP
+ //{{AFX_MSG_MAP(CInPlaceComboBox)
+ ON_WM_CREATE()
+ ON_WM_KILLFOCUS()
+ ON_WM_CHAR()
+ ON_WM_NCDESTROY()
+ ON_CONTROL_REFLECT(CBN_CLOSEUP, OnCloseup)
+ //}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
@@ -301,94 +301,94 @@ END_MESSAGE_MAP()
int CInPlaceComboBox::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
- if (CComboBox::OnCreate(lpCreateStruct) == -1) {
- return -1;
- }
+ if (CComboBox::OnCreate(lpCreateStruct) == -1) {
+ return -1;
+ }
- // Set the proper font
- CFont* font = GetParent()->GetFont();
- SetFont(font);
+ // Set the proper font
+ CFont* font = GetParent()->GetFont();
+ SetFont(font);
- for (POSITION pos = m_lstItems.GetHeadPosition(); pos != NULL;) {
- AddString((LPCTSTR)(m_lstItems.GetNext(pos)));
- }
+ for (POSITION pos = m_lstItems.GetHeadPosition(); pos != NULL;) {
+ AddString((LPCTSTR)(m_lstItems.GetNext(pos)));
+ }
- SetFocus();
- SetCurSel(m_nSel);
- return 0;
+ SetFocus();
+ SetCurSel(m_nSel);
+ return 0;
}
BOOL CInPlaceComboBox::PreTranslateMessage(MSG* pMsg)
{
- if (pMsg->message == WM_KEYDOWN) {
- if (pMsg->wParam == VK_RETURN
- || pMsg->wParam == VK_ESCAPE) {
- ::TranslateMessage(pMsg);
- ::DispatchMessage(pMsg);
- return TRUE; // DO NOT process further
- }
- }
-
- return CComboBox::PreTranslateMessage(pMsg);
+ if (pMsg->message == WM_KEYDOWN) {
+ if (pMsg->wParam == VK_RETURN
+ || pMsg->wParam == VK_ESCAPE) {
+ ::TranslateMessage(pMsg);
+ ::DispatchMessage(pMsg);
+ return TRUE; // DO NOT process further
+ }
+ }
+
+ return CComboBox::PreTranslateMessage(pMsg);
}
void CInPlaceComboBox::OnKillFocus(CWnd* pNewWnd)
{
- CComboBox::OnKillFocus(pNewWnd);
-
- CString str;
- GetWindowText(str);
-
- LV_DISPINFO dispinfo;
- dispinfo.hdr.hwndFrom = GetParent()->m_hWnd;
- dispinfo.hdr.idFrom = GetDlgCtrlID();
- dispinfo.hdr.code = LVN_ENDLABELEDIT;
- dispinfo.item.mask = LVIF_TEXT|LVIF_PARAM;
- dispinfo.item.iItem = m_iItem;
- dispinfo.item.iSubItem = m_iSubItem;
- dispinfo.item.pszText = m_bESC ? NULL : LPTSTR((LPCTSTR)str);
- dispinfo.item.cchTextMax = str.GetLength();
- dispinfo.item.lParam = GetCurSel();
- GetParent()->GetParent()->SendMessage(WM_NOTIFY, GetParent()->GetDlgCtrlID(), (LPARAM)&dispinfo);
-
- PostMessage(WM_CLOSE);
+ CComboBox::OnKillFocus(pNewWnd);
+
+ CString str;
+ GetWindowText(str);
+
+ LV_DISPINFO dispinfo;
+ dispinfo.hdr.hwndFrom = GetParent()->m_hWnd;
+ dispinfo.hdr.idFrom = GetDlgCtrlID();
+ dispinfo.hdr.code = LVN_ENDLABELEDIT;
+ dispinfo.item.mask = LVIF_TEXT | LVIF_PARAM;
+ dispinfo.item.iItem = m_iItem;
+ dispinfo.item.iSubItem = m_iSubItem;
+ dispinfo.item.pszText = m_bESC ? NULL : LPTSTR((LPCTSTR)str);
+ dispinfo.item.cchTextMax = str.GetLength();
+ dispinfo.item.lParam = GetCurSel();
+ GetParent()->GetParent()->SendMessage(WM_NOTIFY, GetParent()->GetDlgCtrlID(), (LPARAM)&dispinfo);
+
+ PostMessage(WM_CLOSE);
}
void CInPlaceComboBox::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
- if (nChar == VK_ESCAPE || nChar == VK_RETURN) {
- if (nChar == VK_ESCAPE) {
- m_bESC = TRUE;
- }
- GetParent()->SetFocus();
- return;
- }
-
- CComboBox::OnChar(nChar, nRepCnt, nFlags);
+ if (nChar == VK_ESCAPE || nChar == VK_RETURN) {
+ if (nChar == VK_ESCAPE) {
+ m_bESC = TRUE;
+ }
+ GetParent()->SetFocus();
+ return;
+ }
+
+ CComboBox::OnChar(nChar, nRepCnt, nFlags);
}
void CInPlaceComboBox::OnNcDestroy()
{
- CComboBox::OnNcDestroy();
+ CComboBox::OnNcDestroy();
- delete this;
+ delete this;
}
void CInPlaceComboBox::OnCloseup()
{
- GetParent()->SetFocus();
+ GetParent()->SetFocus();
}
// CInPlaceListBox
CInPlaceListBox::CInPlaceListBox(int iItem, int iSubItem, CAtlList<CString>& lstItems, int nSel)
{
- m_iItem = iItem;
- m_iSubItem = iSubItem;
+ m_iItem = iItem;
+ m_iSubItem = iSubItem;
- m_lstItems.AddTailList(&lstItems);
- m_nSel = nSel;
- m_bESC = FALSE;
+ m_lstItems.AddTailList(&lstItems);
+ m_nSel = nSel;
+ m_bESC = FALSE;
}
CInPlaceListBox::~CInPlaceListBox()
@@ -396,12 +396,12 @@ CInPlaceListBox::~CInPlaceListBox()
}
BEGIN_MESSAGE_MAP(CInPlaceListBox, CListBox)
- //{{AFX_MSG_MAP(CInPlaceListBox)
- ON_WM_CREATE()
- ON_WM_KILLFOCUS()
- ON_WM_CHAR()
- ON_WM_NCDESTROY()
- //}}AFX_MSG_MAP
+ //{{AFX_MSG_MAP(CInPlaceListBox)
+ ON_WM_CREATE()
+ ON_WM_KILLFOCUS()
+ ON_WM_CHAR()
+ ON_WM_NCDESTROY()
+ //}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
@@ -409,76 +409,76 @@ END_MESSAGE_MAP()
int CInPlaceListBox::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
- if (CListBox::OnCreate(lpCreateStruct) == -1) {
- return -1;
- }
-
- // Set the proper font
- CFont* font = GetParent()->GetFont();
- SetFont(font);
-
- for (POSITION pos = m_lstItems.GetHeadPosition(); pos != NULL;) {
- AddString( (LPCTSTR) (m_lstItems.GetNext( pos )) );
- }
- SetCurSel( m_nSel );
- SetFocus();
- return 0;
+ if (CListBox::OnCreate(lpCreateStruct) == -1) {
+ return -1;
+ }
+
+ // Set the proper font
+ CFont* font = GetParent()->GetFont();
+ SetFont(font);
+
+ for (POSITION pos = m_lstItems.GetHeadPosition(); pos != NULL;) {
+ AddString((LPCTSTR)(m_lstItems.GetNext(pos)));
+ }
+ SetCurSel(m_nSel);
+ SetFocus();
+ return 0;
}
BOOL CInPlaceListBox::PreTranslateMessage(MSG* pMsg)
{
- if (pMsg->message == WM_KEYDOWN) {
- if (pMsg->wParam == VK_RETURN
- || pMsg->wParam == VK_ESCAPE) {
- ::TranslateMessage(pMsg);
- ::DispatchMessage(pMsg);
- return TRUE; // DO NOT process further
- }
- }
-
- return CListBox::PreTranslateMessage(pMsg);
+ if (pMsg->message == WM_KEYDOWN) {
+ if (pMsg->wParam == VK_RETURN
+ || pMsg->wParam == VK_ESCAPE) {
+ ::TranslateMessage(pMsg);
+ ::DispatchMessage(pMsg);
+ return TRUE; // DO NOT process further
+ }
+ }
+
+ return CListBox::PreTranslateMessage(pMsg);
}
void CInPlaceListBox::OnKillFocus(CWnd* pNewWnd)
{
- CListBox::OnKillFocus(pNewWnd);
-
- CString str;
- GetWindowText(str);
-
- LV_DISPINFO dispinfo;
- dispinfo.hdr.hwndFrom = GetParent()->m_hWnd;
- dispinfo.hdr.idFrom = GetDlgCtrlID();
- dispinfo.hdr.code = LVN_ENDLABELEDIT;
- dispinfo.item.mask = LVIF_TEXT|LVIF_PARAM;
- dispinfo.item.iItem = m_iItem;
- dispinfo.item.iSubItem = m_iSubItem;
- dispinfo.item.pszText = m_bESC ? NULL : LPTSTR((LPCTSTR)str);
- dispinfo.item.cchTextMax = str.GetLength();
- dispinfo.item.lParam = GetCurSel();
- GetParent()->GetParent()->SendMessage(WM_NOTIFY, GetParent()->GetDlgCtrlID(), (LPARAM)&dispinfo);
-
- PostMessage(WM_CLOSE);
+ CListBox::OnKillFocus(pNewWnd);
+
+ CString str;
+ GetWindowText(str);
+
+ LV_DISPINFO dispinfo;
+ dispinfo.hdr.hwndFrom = GetParent()->m_hWnd;
+ dispinfo.hdr.idFrom = GetDlgCtrlID();
+ dispinfo.hdr.code = LVN_ENDLABELEDIT;
+ dispinfo.item.mask = LVIF_TEXT | LVIF_PARAM;
+ dispinfo.item.iItem = m_iItem;
+ dispinfo.item.iSubItem = m_iSubItem;
+ dispinfo.item.pszText = m_bESC ? NULL : LPTSTR((LPCTSTR)str);
+ dispinfo.item.cchTextMax = str.GetLength();
+ dispinfo.item.lParam = GetCurSel();
+ GetParent()->GetParent()->SendMessage(WM_NOTIFY, GetParent()->GetDlgCtrlID(), (LPARAM)&dispinfo);
+
+ PostMessage(WM_CLOSE);
}
void CInPlaceListBox::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
- if (nChar == VK_ESCAPE || nChar == VK_RETURN) {
- if (nChar == VK_ESCAPE) {
- m_bESC = TRUE;
- }
- GetParent()->SetFocus();
- return;
- }
-
- CListBox::OnChar(nChar, nRepCnt, nFlags);
+ if (nChar == VK_ESCAPE || nChar == VK_RETURN) {
+ if (nChar == VK_ESCAPE) {
+ m_bESC = TRUE;
+ }
+ GetParent()->SetFocus();
+ return;
+ }
+
+ CListBox::OnChar(nChar, nRepCnt, nFlags);
}
void CInPlaceListBox::OnNcDestroy()
{
- CListBox::OnNcDestroy();
+ CListBox::OnNcDestroy();
- delete this;
+ delete this;
}
@@ -486,8 +486,8 @@ void CInPlaceListBox::OnNcDestroy()
IMPLEMENT_DYNAMIC(CPlayerListCtrl, CListCtrl)
CPlayerListCtrl::CPlayerListCtrl(int tStartEditingDelay)
- : m_tStartEditingDelay(tStartEditingDelay)
- , m_nItemClicked(-1)
+ : m_tStartEditingDelay(tStartEditingDelay)
+ , m_nItemClicked(-1)
{
}
@@ -497,568 +497,568 @@ CPlayerListCtrl::~CPlayerListCtrl()
void CPlayerListCtrl::PreSubclassWindow()
{
- EnableToolTips(TRUE);
+ EnableToolTips(TRUE);
- CListCtrl::PreSubclassWindow();
+ CListCtrl::PreSubclassWindow();
}
int CPlayerListCtrl::HitTestEx(CPoint& point, int* col) const
{
- if (col) {
- *col = 0;
- }
+ if (col) {
+ *col = 0;
+ }
- int row = HitTest(CPoint(0, point.y), NULL);
+ int row = HitTest(CPoint(0, point.y), NULL);
- if ((GetWindowLongPtr(m_hWnd, GWL_STYLE) & LVS_TYPEMASK) != LVS_REPORT) {
- return row;
- }
+ if ((GetWindowLongPtr(m_hWnd, GWL_STYLE) & LVS_TYPEMASK) != LVS_REPORT) {
+ return row;
+ }
- int nColumnCount = ((CHeaderCtrl*)GetDlgItem(0))->GetItemCount();
+ int nColumnCount = ((CHeaderCtrl*)GetDlgItem(0))->GetItemCount();
- for (int top = GetTopIndex(), bottom = GetBottomIndex(); top <= bottom; top++) {
- CRect r;
- GetItemRect(top, &r, LVIR_BOUNDS);
+ for (int top = GetTopIndex(), bottom = GetBottomIndex(); top <= bottom; top++) {
+ CRect r;
+ GetItemRect(top, &r, LVIR_BOUNDS);
- if (r.top <= point.y && point.y < r.bottom) {
- for (int colnum = 0; colnum < nColumnCount; colnum++) {
- int colwidth = GetColumnWidth(colnum);
+ if (r.top <= point.y && point.y < r.bottom) {
+ for (int colnum = 0; colnum < nColumnCount; colnum++) {
+ int colwidth = GetColumnWidth(colnum);
- if (point.x >= r.left && point.x <= (r.left + colwidth)) {
- if (col) {
- *col = colnum;
- }
- return top;
- }
+ if (point.x >= r.left && point.x <= (r.left + colwidth)) {
+ if (col) {
+ *col = colnum;
+ }
+ return top;
+ }
- r.left += colwidth;
- }
- }
- }
+ r.left += colwidth;
+ }
+ }
+ }
- return -1;
+ return -1;
}
int CPlayerListCtrl::GetBottomIndex() const
{
- CRect r;
- GetClientRect(r);
+ CRect r;
+ GetClientRect(r);
- int nBottomIndex = GetTopIndex() + GetCountPerPage() - 1;
+ int nBottomIndex = GetTopIndex() + GetCountPerPage() - 1;
- if (nBottomIndex >= GetItemCount()) {
- nBottomIndex = GetItemCount() - 1;
- } else if (nBottomIndex < GetItemCount()) {
- CRect br;
- GetItemRect(nBottomIndex, br, LVIR_BOUNDS);
+ if (nBottomIndex >= GetItemCount()) {
+ nBottomIndex = GetItemCount() - 1;
+ } else if (nBottomIndex < GetItemCount()) {
+ CRect br;
+ GetItemRect(nBottomIndex, br, LVIR_BOUNDS);
- if (br.bottom < r.bottom) {
- nBottomIndex++;
- }
- }
+ if (br.bottom < r.bottom) {
+ nBottomIndex++;
+ }
+ }
- return nBottomIndex;
+ return nBottomIndex;
}
CImageList* CPlayerListCtrl::CreateDragImageEx(LPPOINT lpPoint)
{
- if (GetSelectedCount() <= 0) {
- return NULL;
- }
-
- CRect cSingleRect, cCompleteRect(0, 0, 0, 0);
- GetClientRect(cSingleRect);
- int nWidth = cSingleRect.Width();
-
- // Start and Stop index in view area
- int nIndex = GetTopIndex() - 1;
- int nBottomIndex = GetBottomIndex();
-
- // Determine the size of the drag image (limited for
- // rows visible and Client width)
- while ((nIndex = GetNextItem(nIndex, LVNI_SELECTED)) != -1 && nIndex <= nBottomIndex) {
- GetItemRect(nIndex, cSingleRect, LVIR_BOUNDS);
- /*
- CRect r;
- GetItemRect(nIndex, r, LVIR_LABEL);
- cSingleRect.left = r.left;
- */
- if (cSingleRect.left < 0) {
- cSingleRect.left = 0;
- }
- if (cSingleRect.right > nWidth) {
- cSingleRect.right = nWidth;
- }
-
- cCompleteRect |= cSingleRect;
- }
-
- //
- // Create bitmap in memory DC
- //
- CClientDC cDc(this);
- CDC cMemDC;
- CBitmap cBitmap;
-
- if (!cMemDC.CreateCompatibleDC(&cDc)) {
- return NULL;
- }
-
- if (!cBitmap.CreateCompatibleBitmap(&cDc, cCompleteRect.Width(), cCompleteRect.Height())) {
- return NULL;
- }
-
- CBitmap* pOldMemDCBitmap = cMemDC.SelectObject(&cBitmap);
- // Here green is used as mask color
- cMemDC.FillSolidRect(0, 0, cCompleteRect.Width(), cCompleteRect.Height(), RGB(0, 255, 0));
-
- // Paint each DragImage in the DC
- nIndex = GetTopIndex() - 1;
- while ((nIndex = GetNextItem(nIndex, LVNI_SELECTED)) != -1 && nIndex <= nBottomIndex) {
- CPoint pt;
- CImageList* pSingleImageList = CreateDragImage(nIndex, &pt);
-
- if (pSingleImageList) {
- GetItemRect(nIndex, cSingleRect, LVIR_BOUNDS);
-
- pSingleImageList->Draw(&cMemDC,
- 0,
- CPoint(cSingleRect.left - cCompleteRect.left, cSingleRect.top - cCompleteRect.top),
- ILD_MASK);
-
- pSingleImageList->DeleteImageList();
- delete pSingleImageList;
- }
- }
-
- cMemDC.SelectObject(pOldMemDCBitmap);
-
- //
- // Create the image list with the merged drag images
- //
- CImageList* pCompleteImageList = DNew CImageList;
-
- pCompleteImageList->Create(cCompleteRect.Width(),
- cCompleteRect.Height(),
- ILC_COLOR | ILC_MASK, 0, 1);
-
- // Here green is used as mask color
- pCompleteImageList->Add(&cBitmap, RGB(0, 255, 0));
-
- //
- // as an optional service:
- // Find the offset of the current mouse cursor to the image list
- // this we can use in BeginDrag()
- //
- if (lpPoint) {
- lpPoint->x = cCompleteRect.left;
- lpPoint->y = cCompleteRect.top;
- }
-
- return pCompleteImageList;
+ if (GetSelectedCount() <= 0) {
+ return NULL;
+ }
+
+ CRect cSingleRect, cCompleteRect(0, 0, 0, 0);
+ GetClientRect(cSingleRect);
+ int nWidth = cSingleRect.Width();
+
+ // Start and Stop index in view area
+ int nIndex = GetTopIndex() - 1;
+ int nBottomIndex = GetBottomIndex();
+
+ // Determine the size of the drag image (limited for
+ // rows visible and Client width)
+ while ((nIndex = GetNextItem(nIndex, LVNI_SELECTED)) != -1 && nIndex <= nBottomIndex) {
+ GetItemRect(nIndex, cSingleRect, LVIR_BOUNDS);
+ /*
+ CRect r;
+ GetItemRect(nIndex, r, LVIR_LABEL);
+ cSingleRect.left = r.left;
+ */
+ if (cSingleRect.left < 0) {
+ cSingleRect.left = 0;
+ }
+ if (cSingleRect.right > nWidth) {
+ cSingleRect.right = nWidth;
+ }
+
+ cCompleteRect |= cSingleRect;
+ }
+
+ //
+ // Create bitmap in memory DC
+ //
+ CClientDC cDc(this);
+ CDC cMemDC;
+ CBitmap cBitmap;
+
+ if (!cMemDC.CreateCompatibleDC(&cDc)) {
+ return NULL;
+ }
+
+ if (!cBitmap.CreateCompatibleBitmap(&cDc, cCompleteRect.Width(), cCompleteRect.Height())) {
+ return NULL;
+ }
+
+ CBitmap* pOldMemDCBitmap = cMemDC.SelectObject(&cBitmap);
+ // Here green is used as mask color
+ cMemDC.FillSolidRect(0, 0, cCompleteRect.Width(), cCompleteRect.Height(), RGB(0, 255, 0));
+
+ // Paint each DragImage in the DC
+ nIndex = GetTopIndex() - 1;
+ while ((nIndex = GetNextItem(nIndex, LVNI_SELECTED)) != -1 && nIndex <= nBottomIndex) {
+ CPoint pt;
+ CImageList* pSingleImageList = CreateDragImage(nIndex, &pt);
+
+ if (pSingleImageList) {
+ GetItemRect(nIndex, cSingleRect, LVIR_BOUNDS);
+
+ pSingleImageList->Draw(&cMemDC,
+ 0,
+ CPoint(cSingleRect.left - cCompleteRect.left, cSingleRect.top - cCompleteRect.top),
+ ILD_MASK);
+
+ pSingleImageList->DeleteImageList();
+ delete pSingleImageList;
+ }
+ }
+
+ cMemDC.SelectObject(pOldMemDCBitmap);
+
+ //
+ // Create the image list with the merged drag images
+ //
+ CImageList* pCompleteImageList = DNew CImageList;
+
+ pCompleteImageList->Create(cCompleteRect.Width(),
+ cCompleteRect.Height(),
+ ILC_COLOR | ILC_MASK, 0, 1);
+
+ // Here green is used as mask color
+ pCompleteImageList->Add(&cBitmap, RGB(0, 255, 0));
+
+ //
+ // as an optional service:
+ // Find the offset of the current mouse cursor to the image list
+ // this we can use in BeginDrag()
+ //
+ if (lpPoint) {
+ lpPoint->x = cCompleteRect.left;
+ lpPoint->y = cCompleteRect.top;
+ }
+
+ return pCompleteImageList;
}
bool CPlayerListCtrl::PrepareInPlaceControl(int nRow, int nCol, CRect& rect)
{
- if (!EnsureVisible(nRow, TRUE)) {
- return false;
- }
-
- int nColumnCount = ((CHeaderCtrl*)GetDlgItem(0))->GetItemCount();
- if (nCol >= nColumnCount || GetColumnWidth(nCol) < 5) {
- return false;
- }
-
- int offset = 0;
- for (int i = 0; i < nCol; i++) {
- offset += GetColumnWidth(i);
- }
-
- GetItemRect(nRow, &rect, LVIR_BOUNDS);
-
- CRect rcClient;
- GetClientRect(&rcClient);
- if (offset + rect.left < 0 || offset + rect.left > rcClient.right) {
- CSize size(offset + rect.left, 0);
- Scroll(size);
- rect.left -= size.cx;
- }
-
- rect.left += offset;
- rect.right = rect.left + GetColumnWidth(nCol);
- if (rect.right > rcClient.right) {
- rect.right = rcClient.right;
- }
-
- rect.DeflateRect(1, 0, 0, 1);
-
- if (nCol == 0) {
- CRect r;
- GetItemRect(nRow, r, LVIR_LABEL);
- rect.left = r.left-1;
- }
-
- return true;
+ if (!EnsureVisible(nRow, TRUE)) {
+ return false;
+ }
+
+ int nColumnCount = ((CHeaderCtrl*)GetDlgItem(0))->GetItemCount();
+ if (nCol >= nColumnCount || GetColumnWidth(nCol) < 5) {
+ return false;
+ }
+
+ int offset = 0;
+ for (int i = 0; i < nCol; i++) {
+ offset += GetColumnWidth(i);
+ }
+
+ GetItemRect(nRow, &rect, LVIR_BOUNDS);
+
+ CRect rcClient;
+ GetClientRect(&rcClient);
+ if (offset + rect.left < 0 || offset + rect.left > rcClient.right) {
+ CSize size(offset + rect.left, 0);
+ Scroll(size);
+ rect.left -= size.cx;
+ }
+
+ rect.left += offset;
+ rect.right = rect.left + GetColumnWidth(nCol);
+ if (rect.right > rcClient.right) {
+ rect.right = rcClient.right;
+ }
+
+ rect.DeflateRect(1, 0, 0, 1);
+
+ if (nCol == 0) {
+ CRect r;
+ GetItemRect(nRow, r, LVIR_LABEL);
+ rect.left = r.left - 1;
+ }
+
+ return true;
}
CWinHotkeyCtrl* CPlayerListCtrl::ShowInPlaceWinHotkey(int nItem, int nCol)
{
- CRect rect;
- if (!PrepareInPlaceControl(nItem, nCol, rect)) {
- return NULL;
- }
+ CRect rect;
+ if (!PrepareInPlaceControl(nItem, nCol, rect)) {
+ return NULL;
+ }
- DWORD dwStyle = /*WS_BORDER|*/WS_CHILD|WS_VISIBLE|ES_AUTOHSCROLL|ES_LEFT;
+ DWORD dwStyle = /*WS_BORDER|*/WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | ES_LEFT;
- CWinHotkeyCtrl* pWinHotkey = DNew CInPlaceWinHotkey(nItem, nCol, GetItemText(nItem, nCol));
- pWinHotkey->Create(dwStyle, rect, this, IDC_WINHOTKEY1);
+ CWinHotkeyCtrl* pWinHotkey = DNew CInPlaceWinHotkey(nItem, nCol, GetItemText(nItem, nCol));
+ pWinHotkey->Create(dwStyle, rect, this, IDC_WINHOTKEY1);
- m_fInPlaceDirty = false;
+ m_fInPlaceDirty = false;
- return pWinHotkey;
+ return pWinHotkey;
}
void CPlayerListCtrl::OnEnChangeWinHotkey1()
{
- m_fInPlaceDirty = true;
+ m_fInPlaceDirty = true;
}
CEdit* CPlayerListCtrl::ShowInPlaceEdit(int nItem, int nCol)
{
- CRect rect;
- if (!PrepareInPlaceControl(nItem, nCol, rect)) {
- return NULL;
- }
+ CRect rect;
+ if (!PrepareInPlaceControl(nItem, nCol, rect)) {
+ return NULL;
+ }
- DWORD dwStyle = /*WS_BORDER|*/WS_CHILD|WS_VISIBLE|ES_AUTOHSCROLL;
+ DWORD dwStyle = /*WS_BORDER|*/WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL;
- LV_COLUMN lvcol;
- lvcol.mask = LVCF_FMT;
- GetColumn(nCol, &lvcol);
- dwStyle |= (lvcol.fmt&LVCFMT_JUSTIFYMASK) == LVCFMT_LEFT ? ES_LEFT
- : (lvcol.fmt&LVCFMT_JUSTIFYMASK) == LVCFMT_RIGHT ? ES_RIGHT
- : ES_CENTER;
+ LV_COLUMN lvcol;
+ lvcol.mask = LVCF_FMT;
+ GetColumn(nCol, &lvcol);
+ dwStyle |= (lvcol.fmt & LVCFMT_JUSTIFYMASK) == LVCFMT_LEFT ? ES_LEFT
+ : (lvcol.fmt & LVCFMT_JUSTIFYMASK) == LVCFMT_RIGHT ? ES_RIGHT
+ : ES_CENTER;
- CEdit* pEdit = DNew CInPlaceEdit(nItem, nCol, GetItemText(nItem, nCol));
- pEdit->Create(dwStyle, rect, this, IDC_EDIT1);
+ CEdit* pEdit = DNew CInPlaceEdit(nItem, nCol, GetItemText(nItem, nCol));
+ pEdit->Create(dwStyle, rect, this, IDC_EDIT1);
- m_fInPlaceDirty = false;
+ m_fInPlaceDirty = false;
- return pEdit;
+ return pEdit;
}
CEdit* CPlayerListCtrl::ShowInPlaceFloatEdit(int nItem, int nCol)
{
- CRect rect;
- if (!PrepareInPlaceControl(nItem, nCol, rect)) {
- return NULL;
- }
+ CRect rect;
+ if (!PrepareInPlaceControl(nItem, nCol, rect)) {
+ return NULL;
+ }
- DWORD dwStyle = /*WS_BORDER|*/WS_CHILD|WS_VISIBLE|ES_AUTOHSCROLL|ES_RIGHT;
+ DWORD dwStyle = /*WS_BORDER|*/WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | ES_RIGHT;
- CEdit* pFloatEdit = DNew CInPlaceFloatEdit(nItem, nCol, GetItemText(nItem, nCol));
- pFloatEdit->Create(dwStyle, rect, this, IDC_EDIT1);
+ CEdit* pFloatEdit = DNew CInPlaceFloatEdit(nItem, nCol, GetItemText(nItem, nCol));
+ pFloatEdit->Create(dwStyle, rect, this, IDC_EDIT1);
- m_fInPlaceDirty = false;
+ m_fInPlaceDirty = false;
- return pFloatEdit;
+ return pFloatEdit;
}
CComboBox* CPlayerListCtrl::ShowInPlaceComboBox(int nItem, int nCol, CAtlList<CString>& lstItems, int nSel, bool bShowDropDown)
{
- CRect rect;
- if (!PrepareInPlaceControl(nItem, nCol, rect)) {
- return NULL;
- }
+ CRect rect;
+ if (!PrepareInPlaceControl(nItem, nCol, rect)) {
+ return NULL;
+ }
- DWORD dwStyle = /*WS_BORDER|*/WS_CHILD|WS_VISIBLE|WS_VSCROLL/*|WS_HSCROLL*/
- |CBS_DROPDOWNLIST|CBS_DISABLENOSCROLL/*|CBS_NOINTEGRALHEIGHT*/;
- CComboBox* pComboBox = DNew CInPlaceComboBox(nItem, nCol, lstItems, nSel);
- pComboBox->Create(dwStyle, rect, this, IDC_COMBO1);
+ DWORD dwStyle = /*WS_BORDER|*/WS_CHILD | WS_VISIBLE | WS_VSCROLL /*|WS_HSCROLL*/
+ | CBS_DROPDOWNLIST | CBS_DISABLENOSCROLL/*|CBS_NOINTEGRALHEIGHT*/;
+ CComboBox* pComboBox = DNew CInPlaceComboBox(nItem, nCol, lstItems, nSel);
+ pComboBox->Create(dwStyle, rect, this, IDC_COMBO1);
- CorrectComboListWidth(*pComboBox);
+ CorrectComboListWidth(*pComboBox);
- int width = GetColumnWidth(nCol);
- if (pComboBox->GetDroppedWidth() < width) {
- pComboBox->SetDroppedWidth(width);
- }
+ int width = GetColumnWidth(nCol);
+ if (pComboBox->GetDroppedWidth() < width) {
+ pComboBox->SetDroppedWidth(width);
+ }
- if (bShowDropDown) {
- pComboBox->ShowDropDown();
- }
+ if (bShowDropDown) {
+ pComboBox->ShowDropDown();
+ }
- m_fInPlaceDirty = false;
+ m_fInPlaceDirty = false;
- return pComboBox;
+ return pComboBox;
}
CListBox* CPlayerListCtrl::ShowInPlaceListBox(int nItem, int nCol, CAtlList<CString>& lstItems, int nSel)
{
- CRect rect;
- if (!PrepareInPlaceControl(nItem, nCol, rect)) {
- return NULL;
- }
-
- DWORD dwStyle = WS_BORDER|WS_CHILD|WS_VISIBLE|WS_VSCROLL/*|WS_HSCROLL*/|LBS_NOTIFY;
- CListBox* pListBox = DNew CInPlaceListBox(nItem, nCol, lstItems, nSel);
- pListBox->Create(dwStyle, rect, this, IDC_LIST1);
-
- CRect ir;
- GetItemRect(m_nItemClicked, &ir, LVIR_BOUNDS);
-
- pListBox->SetItemHeight(-1, ir.Height());
-
- CDC* pDC = pListBox->GetDC();
- CFont* pWndFont = GetFont();
- pDC->SelectObject(pWndFont);
- int width = GetColumnWidth(nCol);
- POSITION pos = lstItems.GetHeadPosition();
- while (pos) {
- int w = pDC->GetTextExtent(lstItems.GetNext(pos)).cx + 16;
- if (width < w) {
- width = w;
- }
- }
- ReleaseDC(pDC);
-
- CRect r;
- pListBox->GetWindowRect(r);
- ScreenToClient(r);
- r.top = ir.bottom;
- r.bottom = r.top + pListBox->GetItemHeight(0) * (pListBox->GetCount() + 1);
- r.right = r.left + width;
- pListBox->MoveWindow(r);
-
- m_fInPlaceDirty = false;
-
- return pListBox;
+ CRect rect;
+ if (!PrepareInPlaceControl(nItem, nCol, rect)) {
+ return NULL;
+ }
+
+ DWORD dwStyle = WS_BORDER | WS_CHILD | WS_VISIBLE | WS_VSCROLL/*|WS_HSCROLL*/ | LBS_NOTIFY;
+ CListBox* pListBox = DNew CInPlaceListBox(nItem, nCol, lstItems, nSel);
+ pListBox->Create(dwStyle, rect, this, IDC_LIST1);
+
+ CRect ir;
+ GetItemRect(m_nItemClicked, &ir, LVIR_BOUNDS);
+
+ pListBox->SetItemHeight(-1, ir.Height());
+
+ CDC* pDC = pListBox->GetDC();
+ CFont* pWndFont = GetFont();
+ pDC->SelectObject(pWndFont);
+ int width = GetColumnWidth(nCol);
+ POSITION pos = lstItems.GetHeadPosition();
+ while (pos) {
+ int w = pDC->GetTextExtent(lstItems.GetNext(pos)).cx + 16;
+ if (width < w) {
+ width = w;
+ }
+ }
+ ReleaseDC(pDC);
+
+ CRect r;
+ pListBox->GetWindowRect(r);
+ ScreenToClient(r);
+ r.top = ir.bottom;
+ r.bottom = r.top + pListBox->GetItemHeight(0) * (pListBox->GetCount() + 1);
+ r.right = r.left + width;
+ pListBox->MoveWindow(r);
+
+ m_fInPlaceDirty = false;
+
+ return pListBox;
}
BEGIN_MESSAGE_MAP(CPlayerListCtrl, CListCtrl)
- ON_WM_VSCROLL()
- ON_WM_HSCROLL()
- ON_WM_MOUSEWHEEL()
- ON_WM_LBUTTONDOWN()
- ON_WM_TIMER()
- ON_WM_LBUTTONDBLCLK()
- ON_NOTIFY_REFLECT(LVN_MARQUEEBEGIN, OnLvnMarqueeBegin)
- ON_NOTIFY_REFLECT(LVN_INSERTITEM, OnLvnInsertitem)
- ON_NOTIFY_REFLECT(LVN_DELETEITEM, OnLvnDeleteitem)
- ON_EN_CHANGE(IDC_EDIT1, OnEnChangeEdit1)
- ON_EN_CHANGE(IDC_WINHOTKEY1, OnEnChangeWinHotkey1)
- ON_CBN_DROPDOWN(IDC_COMBO1, OnCbnDropdownCombo1)
- ON_CBN_SELENDOK(IDC_COMBO1, OnCbnSelendokCombo1)
- ON_LBN_SELCHANGE(IDC_LIST1, OnLbnSelChangeList1)
- ON_NOTIFY_EX(HDN_ITEMCHANGINGA, 0, OnHdnItemchanging)
- ON_NOTIFY_EX(HDN_ITEMCHANGINGW, 0, OnHdnItemchanging)
- ON_NOTIFY_EX_RANGE(TTN_NEEDTEXT, 0, 0xFFFF, OnToolTipNotify)
+ ON_WM_VSCROLL()
+ ON_WM_HSCROLL()
+ ON_WM_MOUSEWHEEL()
+ ON_WM_LBUTTONDOWN()
+ ON_WM_TIMER()
+ ON_WM_LBUTTONDBLCLK()
+ ON_NOTIFY_REFLECT(LVN_MARQUEEBEGIN, OnLvnMarqueeBegin)
+ ON_NOTIFY_REFLECT(LVN_INSERTITEM, OnLvnInsertitem)
+ ON_NOTIFY_REFLECT(LVN_DELETEITEM, OnLvnDeleteitem)
+ ON_EN_CHANGE(IDC_EDIT1, OnEnChangeEdit1)
+ ON_EN_CHANGE(IDC_WINHOTKEY1, OnEnChangeWinHotkey1)
+ ON_CBN_DROPDOWN(IDC_COMBO1, OnCbnDropdownCombo1)
+ ON_CBN_SELENDOK(IDC_COMBO1, OnCbnSelendokCombo1)
+ ON_LBN_SELCHANGE(IDC_LIST1, OnLbnSelChangeList1)
+ ON_NOTIFY_EX(HDN_ITEMCHANGINGA, 0, OnHdnItemchanging)
+ ON_NOTIFY_EX(HDN_ITEMCHANGINGW, 0, OnHdnItemchanging)
+ ON_NOTIFY_EX_RANGE(TTN_NEEDTEXT, 0, 0xFFFF, OnToolTipNotify)
END_MESSAGE_MAP()
// CPlayerListCtrl message handlers
void CPlayerListCtrl::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
- if (GetFocus() != this) {
- SetFocus();
- }
- CListCtrl::OnVScroll(nSBCode, nPos, pScrollBar);
+ if (GetFocus() != this) {
+ SetFocus();
+ }
+ CListCtrl::OnVScroll(nSBCode, nPos, pScrollBar);
}
void CPlayerListCtrl::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
- if (GetFocus() != this) {
- SetFocus();
- }
- CListCtrl::OnHScroll(nSBCode, nPos, pScrollBar);
+ if (GetFocus() != this) {
+ SetFocus();
+ }
+ CListCtrl::OnHScroll(nSBCode, nPos, pScrollBar);
}
BOOL CPlayerListCtrl::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
- if (GetFocus() != this) {
- SetFocus();
- }
- return CListCtrl::OnMouseWheel(nFlags, zDelta, pt);
+ if (GetFocus() != this) {
+ SetFocus();
+ }
+ return CListCtrl::OnMouseWheel(nFlags, zDelta, pt);
}
void CPlayerListCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
- CListCtrl::OnLButtonDown(nFlags, point);
-
- if (GetFocus() != this) {
- SetFocus();
- }
-
- KillTimer(1);
-
- int m_nItemClickedNow, m_nSubItemClickedNow;
-
- if ((m_nItemClickedNow = HitTestEx(point, &m_nSubItemClickedNow)) < 0) {
- m_nItemClicked = -1;
- } else if (m_nItemClicked == m_nItemClickedNow /*&& m_nSubItemClicked == m_nSubItemClickedNow*/) {
- m_nSubItemClicked = m_nSubItemClickedNow;
-
- LV_DISPINFO dispinfo;
- dispinfo.hdr.hwndFrom = m_hWnd;
- dispinfo.hdr.idFrom = GetDlgCtrlID();
- dispinfo.hdr.code = LVN_BEGINLABELEDIT;
- dispinfo.item.mask = 0;
- dispinfo.item.iItem = m_nItemClicked;
- dispinfo.item.iSubItem = m_nSubItemClicked;
- if (GetParent()->SendMessage(WM_NOTIFY, GetDlgCtrlID(), (LPARAM)&dispinfo)) {
- if (m_tStartEditingDelay > 0) {
- SetTimer(1, m_tStartEditingDelay, NULL);
- } else {
- dispinfo.hdr.code = LVN_DOLABELEDIT;
- GetParent()->SendMessage(WM_NOTIFY, GetDlgCtrlID(), (LPARAM)&dispinfo);
- }
- }
- } else {
- m_nItemClicked = m_nItemClickedNow;
- m_nSubItemClicked = m_nSubItemClickedNow;
-
- SetItemState(m_nItemClicked, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
- }
+ CListCtrl::OnLButtonDown(nFlags, point);
+
+ if (GetFocus() != this) {
+ SetFocus();
+ }
+
+ KillTimer(1);
+
+ int m_nItemClickedNow, m_nSubItemClickedNow;
+
+ if ((m_nItemClickedNow = HitTestEx(point, &m_nSubItemClickedNow)) < 0) {
+ m_nItemClicked = -1;
+ } else if (m_nItemClicked == m_nItemClickedNow /*&& m_nSubItemClicked == m_nSubItemClickedNow*/) {
+ m_nSubItemClicked = m_nSubItemClickedNow;
+
+ LV_DISPINFO dispinfo;
+ dispinfo.hdr.hwndFrom = m_hWnd;
+ dispinfo.hdr.idFrom = GetDlgCtrlID();
+ dispinfo.hdr.code = LVN_BEGINLABELEDIT;
+ dispinfo.item.mask = 0;
+ dispinfo.item.iItem = m_nItemClicked;
+ dispinfo.item.iSubItem = m_nSubItemClicked;
+ if (GetParent()->SendMessage(WM_NOTIFY, GetDlgCtrlID(), (LPARAM)&dispinfo)) {
+ if (m_tStartEditingDelay > 0) {
+ SetTimer(1, m_tStartEditingDelay, NULL);
+ } else {
+ dispinfo.hdr.code = LVN_DOLABELEDIT;
+ GetParent()->SendMessage(WM_NOTIFY, GetDlgCtrlID(), (LPARAM)&dispinfo);
+ }
+ }
+ } else {
+ m_nItemClicked = m_nItemClickedNow;
+ m_nSubItemClicked = m_nSubItemClickedNow;
+
+ SetItemState(m_nItemClicked, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
+ }
}
void CPlayerListCtrl::OnTimer(UINT_PTR nIDEvent)
{
- if (nIDEvent == 1) {
- KillTimer(1);
-
- UINT flag = LVIS_FOCUSED;
- if ((GetItemState(m_nItemClicked, flag) & flag) == flag && m_nSubItemClicked >= 0) {
- LV_DISPINFO dispinfo;
- dispinfo.hdr.hwndFrom = m_hWnd;
- dispinfo.hdr.idFrom = GetDlgCtrlID();
- dispinfo.hdr.code = LVN_DOLABELEDIT;
- dispinfo.item.mask = 0;
- dispinfo.item.iItem = m_nItemClicked;
- dispinfo.item.iSubItem = m_nSubItemClicked;
- GetParent()->SendMessage(WM_NOTIFY, GetDlgCtrlID(), (LPARAM)&dispinfo);
- }
- }
+ if (nIDEvent == 1) {
+ KillTimer(1);
+
+ UINT flag = LVIS_FOCUSED;
+ if ((GetItemState(m_nItemClicked, flag) & flag) == flag && m_nSubItemClicked >= 0) {
+ LV_DISPINFO dispinfo;
+ dispinfo.hdr.hwndFrom = m_hWnd;
+ dispinfo.hdr.idFrom = GetDlgCtrlID();
+ dispinfo.hdr.code = LVN_DOLABELEDIT;
+ dispinfo.item.mask = 0;
+ dispinfo.item.iItem = m_nItemClicked;
+ dispinfo.item.iSubItem = m_nSubItemClicked;
+ GetParent()->SendMessage(WM_NOTIFY, GetDlgCtrlID(), (LPARAM)&dispinfo);
+ }
+ }
}
void CPlayerListCtrl::OnLButtonDblClk(UINT nFlags, CPoint point)
{
- KillTimer(1);
+ KillTimer(1);
- CListCtrl::OnLButtonDblClk(nFlags, point);
+ CListCtrl::OnLButtonDblClk(nFlags, point);
}
void CPlayerListCtrl::OnLvnMarqueeBegin(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
- UNREFERENCED_PARAMETER(pNMLV);
- *pResult = 1;
+ LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
+ UNREFERENCED_PARAMETER(pNMLV);
+ *pResult = 1;
}
void CPlayerListCtrl::OnLvnInsertitem(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
- UNREFERENCED_PARAMETER(pNMLV);
- m_nItemClicked = -1;
- *pResult = 0;
+ LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
+ UNREFERENCED_PARAMETER(pNMLV);
+ m_nItemClicked = -1;
+ *pResult = 0;
}
void CPlayerListCtrl::OnLvnDeleteitem(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
- UNREFERENCED_PARAMETER(pNMLV);
- m_nItemClicked = -1;
- *pResult = 0;
+ LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
+ UNREFERENCED_PARAMETER(pNMLV);
+ m_nItemClicked = -1;
+ *pResult = 0;
}
void CPlayerListCtrl::OnEnChangeEdit1()
{
- m_fInPlaceDirty = true;
+ m_fInPlaceDirty = true;
}
void CPlayerListCtrl::OnCbnDropdownCombo1()
{
- CComboBox* pCombo = (CComboBox*)GetDlgItem(IDC_COMBO1);
+ CComboBox* pCombo = (CComboBox*)GetDlgItem(IDC_COMBO1);
- CRect ir;
- GetItemRect(m_nItemClicked, &ir, LVIR_BOUNDS);
+ CRect ir;
+ GetItemRect(m_nItemClicked, &ir, LVIR_BOUNDS);
- CRect r;
- pCombo->GetWindowRect(r);
- ScreenToClient(r);
- r.bottom = r.top + ir.Height() + pCombo->GetItemHeight(0)*10;
- pCombo->MoveWindow(r);
+ CRect r;
+ pCombo->GetWindowRect(r);
+ ScreenToClient(r);
+ r.bottom = r.top + ir.Height() + pCombo->GetItemHeight(0) * 10;
+ pCombo->MoveWindow(r);
}
void CPlayerListCtrl::OnCbnSelendokCombo1()
{
- m_fInPlaceDirty = true;
+ m_fInPlaceDirty = true;
}
void CPlayerListCtrl::OnLbnSelChangeList1()
{
- m_fInPlaceDirty = true;
- SetFocus();
+ m_fInPlaceDirty = true;
+ SetFocus();
}
BOOL CPlayerListCtrl::OnHdnItemchanging(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMHEADER phdr = reinterpret_cast<LPNMHEADER>(pNMHDR);
- UNREFERENCED_PARAMETER(phdr);
- // SetFocus();
- *pResult = 0;
- return FALSE;
+ LPNMHEADER phdr = reinterpret_cast<LPNMHEADER>(pNMHDR);
+ UNREFERENCED_PARAMETER(phdr);
+ // SetFocus();
+ *pResult = 0;
+ return FALSE;
}
INT_PTR CPlayerListCtrl::OnToolHitTest(CPoint point, TOOLINFO* pTI) const
{
- int col;
- int row = HitTestEx(point, &col);
- if (row == -1) {
- return -1;
- }
+ int col;
+ int row = HitTestEx(point, &col);
+ if (row == -1) {
+ return -1;
+ }
- CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
- int nColumnCount = pHeader->GetItemCount();
+ CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
+ int nColumnCount = pHeader->GetItemCount();
- CRect rect;
- GetItemRect(row, &rect, LVIR_BOUNDS);
+ CRect rect;
+ GetItemRect(row, &rect, LVIR_BOUNDS);
- for (int colnum = 0; colnum < nColumnCount; colnum++) {
- int colwidth = GetColumnWidth(colnum);
+ for (int colnum = 0; colnum < nColumnCount; colnum++) {
+ int colwidth = GetColumnWidth(colnum);
- if (colnum == col) {
- rect.right = rect.left + colwidth;
- break;
- }
+ if (colnum == col) {
+ rect.right = rect.left + colwidth;
+ break;
+ }
- rect.left += colwidth;
- }
+ rect.left += colwidth;
+ }
- pTI->hwnd = m_hWnd;
- pTI->uId = (UINT)((row<<10)+(col&0x3ff)+1);
- pTI->lpszText = LPSTR_TEXTCALLBACK;
- pTI->rect = rect;
+ pTI->hwnd = m_hWnd;
+ pTI->uId = (UINT)((row << 10) + (col & 0x3ff) + 1);
+ pTI->lpszText = LPSTR_TEXTCALLBACK;
+ pTI->rect = rect;
- return pTI->uId;
+ return pTI->uId;
}
BOOL CPlayerListCtrl::OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
{
- TOOLTIPTEXT* pTTT = (TOOLTIPTEXT*)pNMHDR;
+ TOOLTIPTEXT* pTTT = (TOOLTIPTEXT*)pNMHDR;
- UINT_PTR nID = pNMHDR->idFrom;
+ UINT_PTR nID = pNMHDR->idFrom;
- if (pTTT->uFlags & TTF_IDISHWND) {
- // idFrom is actually the HWND of the tool
- nID = ::GetDlgCtrlID((HWND)nID);
- }
+ if (pTTT->uFlags & TTF_IDISHWND) {
+ // idFrom is actually the HWND of the tool
+ nID = ::GetDlgCtrlID((HWND)nID);
+ }
- if (nID == 0) { // Notification in NT from automatically
- return FALSE; // created tooltip
- }
+ if (nID == 0) { // Notification in NT from automatically
+ return FALSE; // created tooltip
+ }
- pTTT->lParam = (LPARAM)m_hWnd;
+ pTTT->lParam = (LPARAM)m_hWnd;
- *pResult = 0;
+ *pResult = 0;
- return !!GetParent()->SendMessage(WM_NOTIFY, id, (LPARAM)pNMHDR);
+ return !!GetParent()->SendMessage(WM_NOTIFY, id, (LPARAM)pNMHDR);
}
diff --git a/src/mpc-hc/PlayerListCtrl.h b/src/mpc-hc/PlayerListCtrl.h
index a3fb6c064..dc88330a5 100644
--- a/src/mpc-hc/PlayerListCtrl.h
+++ b/src/mpc-hc/PlayerListCtrl.h
@@ -31,165 +31,165 @@
class CInPlaceWinHotkey : public CWinHotkeyCtrl
{
private:
- int m_iItem;
- int m_iSubItem;
- CString m_sInitText;
- BOOL m_bESC; // To indicate whether ESC key was pressed
+ int m_iItem;
+ int m_iSubItem;
+ CString m_sInitText;
+ BOOL m_bESC; // To indicate whether ESC key was pressed
public:
- CInPlaceWinHotkey(int iItem, int iSubItem, CString sInitText);
- virtual ~CInPlaceWinHotkey();
+ CInPlaceWinHotkey(int iItem, int iSubItem, CString sInitText);
+ virtual ~CInPlaceWinHotkey();
protected:
- virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnKillFocus(CWnd* pNewWnd);
- afx_msg void OnNcDestroy();
- afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
+ afx_msg void OnKillFocus(CWnd* pNewWnd);
+ afx_msg void OnNcDestroy();
+ afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
+ afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
};
class CInPlaceEdit : public CEdit
{
protected:
- int m_iItem;
- int m_iSubItem;
- CString m_sInitText;
- BOOL m_bESC; // To indicate whether ESC key was pressed
+ int m_iItem;
+ int m_iSubItem;
+ CString m_sInitText;
+ BOOL m_bESC; // To indicate whether ESC key was pressed
public:
- CInPlaceEdit(int iItem, int iSubItem, CString sInitText);
- virtual ~CInPlaceEdit();
+ CInPlaceEdit(int iItem, int iSubItem, CString sInitText);
+ virtual ~CInPlaceEdit();
protected:
- virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnKillFocus(CWnd* pNewWnd);
- afx_msg void OnNcDestroy();
- afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
+ afx_msg void OnKillFocus(CWnd* pNewWnd);
+ afx_msg void OnNcDestroy();
+ afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
+ afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
};
class CInPlaceFloatEdit : public CInPlaceEdit
{
public:
- CInPlaceFloatEdit(int iItem, int iSubItem, CString sInitText);
- virtual ~CInPlaceFloatEdit();
+ CInPlaceFloatEdit(int iItem, int iSubItem, CString sInitText);
+ virtual ~CInPlaceFloatEdit();
protected:
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
+ afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
};
class CInPlaceComboBox : public CComboBox
{
private:
- int m_iItem;
- int m_iSubItem;
- CAtlList<CString> m_lstItems;
- int m_nSel;
- BOOL m_bESC; // To indicate whether ESC key was pressed
+ int m_iItem;
+ int m_iSubItem;
+ CAtlList<CString> m_lstItems;
+ int m_nSel;
+ BOOL m_bESC; // To indicate whether ESC key was pressed
public:
- CInPlaceComboBox(int iItem, int iSubItem, CAtlList<CString>& plstItems, int nSel);
- virtual ~CInPlaceComboBox();
+ CInPlaceComboBox(int iItem, int iSubItem, CAtlList<CString>& plstItems, int nSel);
+ virtual ~CInPlaceComboBox();
protected:
- virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnKillFocus(CWnd* pNewWnd);
- afx_msg void OnNcDestroy();
- afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
- afx_msg void OnCloseup();
+ afx_msg void OnKillFocus(CWnd* pNewWnd);
+ afx_msg void OnNcDestroy();
+ afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
+ afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
+ afx_msg void OnCloseup();
};
class CInPlaceListBox : public CListBox
{
private:
- int m_iItem;
- int m_iSubItem;
- CAtlList<CString> m_lstItems;
- int m_nSel;
- BOOL m_bESC; // To indicate whether ESC key was pressed
+ int m_iItem;
+ int m_iSubItem;
+ CAtlList<CString> m_lstItems;
+ int m_nSel;
+ BOOL m_bESC; // To indicate whether ESC key was pressed
public:
- CInPlaceListBox(int iItem, int iSubItem, CAtlList<CString>& plstItems, int nSel);
- virtual ~CInPlaceListBox();
+ CInPlaceListBox(int iItem, int iSubItem, CAtlList<CString>& plstItems, int nSel);
+ virtual ~CInPlaceListBox();
protected:
- virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnKillFocus(CWnd* pNewWnd);
- afx_msg void OnNcDestroy();
- afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
+ afx_msg void OnKillFocus(CWnd* pNewWnd);
+ afx_msg void OnNcDestroy();
+ afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
+ afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
};
// CPlayerListCtrl
class CPlayerListCtrl : public CListCtrl
{
- DECLARE_DYNAMIC(CPlayerListCtrl)
+ DECLARE_DYNAMIC(CPlayerListCtrl)
private:
- int m_nItemClicked, m_nSubItemClicked;
- int m_tStartEditingDelay;
+ int m_nItemClicked, m_nSubItemClicked;
+ int m_tStartEditingDelay;
- bool PrepareInPlaceControl(int nRow, int nCol, CRect& rect);
+ bool PrepareInPlaceControl(int nRow, int nCol, CRect& rect);
public:
- CPlayerListCtrl(int tStartEditingDelay = 500);
- virtual ~CPlayerListCtrl();
+ CPlayerListCtrl(int tStartEditingDelay = 500);
+ virtual ~CPlayerListCtrl();
- int HitTestEx(CPoint& point, int* col) const;
- CImageList* CreateDragImageEx(LPPOINT lpPoint);
+ int HitTestEx(CPoint& point, int* col) const;
+ CImageList* CreateDragImageEx(LPPOINT lpPoint);
- int GetBottomIndex() const;
+ int GetBottomIndex() const;
- CWinHotkeyCtrl* ShowInPlaceWinHotkey(int nItem, int nCol);
- CEdit* ShowInPlaceEdit(int nItem, int nCol);
- CEdit* ShowInPlaceFloatEdit(int nItem, int nCol);
- CComboBox* ShowInPlaceComboBox(int nItem, int nCol, CAtlList<CString>& lstItems, int nSel, bool bShowDropDown=false);
- CListBox* ShowInPlaceListBox(int nItem, int nCol, CAtlList<CString>& lstItems, int nSel);
+ CWinHotkeyCtrl* ShowInPlaceWinHotkey(int nItem, int nCol);
+ CEdit* ShowInPlaceEdit(int nItem, int nCol);
+ CEdit* ShowInPlaceFloatEdit(int nItem, int nCol);
+ CComboBox* ShowInPlaceComboBox(int nItem, int nCol, CAtlList<CString>& lstItems, int nSel, bool bShowDropDown = false);
+ CListBox* ShowInPlaceListBox(int nItem, int nCol, CAtlList<CString>& lstItems, int nSel);
- bool m_fInPlaceDirty;
+ bool m_fInPlaceDirty;
protected:
- virtual void PreSubclassWindow();
- virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
+ virtual void PreSubclassWindow();
+ virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
- afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
- afx_msg void OnTimer(UINT_PTR nIDEvent);
- afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
- afx_msg void OnLvnMarqueeBegin(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnLvnInsertitem(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnLvnDeleteitem(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnEnChangeEdit1();
- afx_msg void OnEnChangeWinHotkey1();
- afx_msg void OnCbnDropdownCombo1();
- afx_msg void OnCbnSelendokCombo1();
- afx_msg void OnLbnSelChangeList1();
- afx_msg BOOL OnHdnItemchanging(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg BOOL OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
+ afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
+ afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
+ afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
+ afx_msg void OnTimer(UINT_PTR nIDEvent);
+ afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
+ afx_msg void OnLvnMarqueeBegin(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnLvnInsertitem(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnLvnDeleteitem(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnEnChangeEdit1();
+ afx_msg void OnEnChangeWinHotkey1();
+ afx_msg void OnCbnDropdownCombo1();
+ afx_msg void OnCbnSelendokCombo1();
+ afx_msg void OnLbnSelChangeList1();
+ afx_msg BOOL OnHdnItemchanging(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg BOOL OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
};
diff --git a/src/mpc-hc/PlayerNavigationBar.cpp b/src/mpc-hc/PlayerNavigationBar.cpp
index d78edcd58..adb96fc41 100644
--- a/src/mpc-hc/PlayerNavigationBar.cpp
+++ b/src/mpc-hc/PlayerNavigationBar.cpp
@@ -40,92 +40,92 @@ CPlayerNavigationBar::~CPlayerNavigationBar()
BOOL CPlayerNavigationBar::Create(CWnd* pParentWnd, UINT defDockBarID)
{
- if (!CPlayerBar::Create(ResStr(IDS_NAVIGATION_BAR), pParentWnd, ID_VIEW_NAVIGATION, defDockBarID, _T("Navigation Bar"))) {
- return FALSE;
- }
-
- m_pParent = pParentWnd;
- m_navdlg.Create(this);
- m_navdlg.ShowWindow(SW_SHOWNORMAL);
-
- CRect r;
- m_navdlg.GetWindowRect(r);
- m_szMinVert = m_szVert = r.Size();
- m_szMinHorz = m_szHorz = r.Size();
- m_szMinFloat = m_szFloat = r.Size();
- m_bFixedFloat = true;
- m_szFixedFloat = r.Size();
-
- return TRUE;
+ if (!CPlayerBar::Create(ResStr(IDS_NAVIGATION_BAR), pParentWnd, ID_VIEW_NAVIGATION, defDockBarID, _T("Navigation Bar"))) {
+ return FALSE;
+ }
+
+ m_pParent = pParentWnd;
+ m_navdlg.Create(this);
+ m_navdlg.ShowWindow(SW_SHOWNORMAL);
+
+ CRect r;
+ m_navdlg.GetWindowRect(r);
+ m_szMinVert = m_szVert = r.Size();
+ m_szMinHorz = m_szHorz = r.Size();
+ m_szMinFloat = m_szFloat = r.Size();
+ m_bFixedFloat = true;
+ m_szFixedFloat = r.Size();
+
+ return TRUE;
}
BOOL CPlayerNavigationBar::PreTranslateMessage(MSG* pMsg)
{
- if (IsWindow(pMsg->hwnd) && IsVisible() && pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST) {
- if (IsDialogMessage(pMsg)) {
- return TRUE;
- }
- }
+ if (IsWindow(pMsg->hwnd) && IsVisible() && pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST) {
+ if (IsDialogMessage(pMsg)) {
+ return TRUE;
+ }
+ }
- return __super::PreTranslateMessage(pMsg);
+ return __super::PreTranslateMessage(pMsg);
}
BEGIN_MESSAGE_MAP(CPlayerNavigationBar, CPlayerBar)
- ON_WM_SIZE()
- ON_WM_NCLBUTTONUP()
+ ON_WM_SIZE()
+ ON_WM_NCLBUTTONUP()
END_MESSAGE_MAP()
// CPlayerShaderEditorBar message handlers
void CPlayerNavigationBar::OnSize(UINT nType, int cx, int cy)
{
- __super::OnSize(nType, cx, cy);
-
- if (::IsWindow(m_navdlg.m_hWnd)) {
- CRect r, rectComboAudio, rectButtonInfo, rectButtonScan;
- LONG totalsize, separation, sizeComboAudio, sizeButtonInfo, sizeButtonScan;
- GetClientRect(r);
- m_navdlg.MoveWindow(r);
- r.DeflateRect(8,8,8,50);
- m_navdlg.m_ChannelList.MoveWindow(r);
-
- m_navdlg.m_ComboAudio.GetClientRect(rectComboAudio);
- m_navdlg.m_ButtonInfo.GetClientRect(rectButtonInfo);
- m_navdlg.m_ButtonScan.GetClientRect(rectButtonScan);
- sizeComboAudio = rectComboAudio.right - rectComboAudio.left;
- sizeButtonInfo = rectButtonInfo.right - rectButtonInfo.left;
- sizeButtonScan = rectButtonScan.right - rectButtonScan.left;
- totalsize = r.right - r.left;
- separation = (totalsize - sizeComboAudio - sizeButtonInfo - sizeButtonScan) / 2;
- if (separation < 0) {
- separation = 0;
- }
- m_navdlg.m_ComboAudio.SetWindowPos(NULL, r.left, r.bottom+6, 0,0, SWP_NOSIZE | SWP_NOZORDER);
- m_navdlg.m_ButtonInfo.SetWindowPos(NULL, r.left + sizeComboAudio + separation, r.bottom +5, 0,0, SWP_NOSIZE | SWP_NOZORDER);
- m_navdlg.m_ButtonScan.SetWindowPos(NULL, r.left + sizeComboAudio + sizeButtonInfo + 2 * separation, r.bottom +5, 0,0, SWP_NOSIZE | SWP_NOZORDER);
- m_navdlg.m_ButtonFilterStations.SetWindowPos(NULL, r.left,r.bottom +30, totalsize, 20, SWP_NOZORDER);
- }
+ __super::OnSize(nType, cx, cy);
+
+ if (::IsWindow(m_navdlg.m_hWnd)) {
+ CRect r, rectComboAudio, rectButtonInfo, rectButtonScan;
+ LONG totalsize, separation, sizeComboAudio, sizeButtonInfo, sizeButtonScan;
+ GetClientRect(r);
+ m_navdlg.MoveWindow(r);
+ r.DeflateRect(8, 8, 8, 50);
+ m_navdlg.m_ChannelList.MoveWindow(r);
+
+ m_navdlg.m_ComboAudio.GetClientRect(rectComboAudio);
+ m_navdlg.m_ButtonInfo.GetClientRect(rectButtonInfo);
+ m_navdlg.m_ButtonScan.GetClientRect(rectButtonScan);
+ sizeComboAudio = rectComboAudio.right - rectComboAudio.left;
+ sizeButtonInfo = rectButtonInfo.right - rectButtonInfo.left;
+ sizeButtonScan = rectButtonScan.right - rectButtonScan.left;
+ totalsize = r.right - r.left;
+ separation = (totalsize - sizeComboAudio - sizeButtonInfo - sizeButtonScan) / 2;
+ if (separation < 0) {
+ separation = 0;
+ }
+ m_navdlg.m_ComboAudio.SetWindowPos(NULL, r.left, r.bottom + 6, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
+ m_navdlg.m_ButtonInfo.SetWindowPos(NULL, r.left + sizeComboAudio + separation, r.bottom + 5, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
+ m_navdlg.m_ButtonScan.SetWindowPos(NULL, r.left + sizeComboAudio + sizeButtonInfo + 2 * separation, r.bottom + 5, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
+ m_navdlg.m_ButtonFilterStations.SetWindowPos(NULL, r.left, r.bottom + 30, totalsize, 20, SWP_NOZORDER);
+ }
}
void CPlayerNavigationBar::OnNcLButtonUp(UINT nHitTest, CPoint point)
{
- __super::OnNcLButtonUp(nHitTest, point);
+ __super::OnNcLButtonUp(nHitTest, point);
- if (nHitTest == HTCLOSE) {
- AfxGetAppSettings().fHideNavigation = true;
- }
+ if (nHitTest == HTCLOSE) {
+ AfxGetAppSettings().fHideNavigation = true;
+ }
}
void CPlayerNavigationBar::ShowControls(CWnd* pMainfrm, bool bShow)
{
- CSize s = this->CalcFixedLayout(FALSE, TRUE);
- ((CMainFrame*) pMainfrm) ->ShowControlBar(this, bShow, TRUE);
+ CSize s = this->CalcFixedLayout(FALSE, TRUE);
+ ((CMainFrame*) pMainfrm) ->ShowControlBar(this, bShow, TRUE);
- WINDOWPLACEMENT wp;
- wp.length = sizeof(wp);
- GetWindowPlacement(&wp);
+ WINDOWPLACEMENT wp;
+ wp.length = sizeof(wp);
+ GetWindowPlacement(&wp);
- ((CMainFrame*) pMainfrm)->RecalcLayout();
+ ((CMainFrame*) pMainfrm)->RecalcLayout();
}
diff --git a/src/mpc-hc/PlayerNavigationBar.h b/src/mpc-hc/PlayerNavigationBar.h
index be8ce1f02..583383f7d 100644
--- a/src/mpc-hc/PlayerNavigationBar.h
+++ b/src/mpc-hc/PlayerNavigationBar.h
@@ -29,24 +29,24 @@
class CPlayerNavigationBar : public CPlayerBar
{
- DECLARE_DYNAMIC(CPlayerNavigationBar)
+ DECLARE_DYNAMIC(CPlayerNavigationBar)
public:
- CWnd* m_pParent;
- CPlayerNavigationBar();
- virtual ~CPlayerNavigationBar();
- BOOL Create(CWnd* pParentWnd, UINT defDockBarID);
- void ShowControls(CWnd* pMainfrm, bool bShow);
+ CWnd* m_pParent;
+ CPlayerNavigationBar();
+ virtual ~CPlayerNavigationBar();
+ BOOL Create(CWnd* pParentWnd, UINT defDockBarID);
+ void ShowControls(CWnd* pMainfrm, bool bShow);
public:
- CPlayerNavigationDialog m_navdlg;
+ CPlayerNavigationDialog m_navdlg;
protected:
- virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point);
+ afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point);
};
diff --git a/src/mpc-hc/PlayerNavigationDialog.cpp b/src/mpc-hc/PlayerNavigationDialog.cpp
index cee2637e1..7a785d75c 100644
--- a/src/mpc-hc/PlayerNavigationDialog.cpp
+++ b/src/mpc-hc/PlayerNavigationDialog.cpp
@@ -32,7 +32,7 @@
// IMPLEMENT_DYNAMIC(CPlayerNavigationDialog, CResizableDialog)
CPlayerNavigationDialog::CPlayerNavigationDialog()
- : CResizableDialog(CPlayerNavigationDialog::IDD, NULL)
+ : CResizableDialog(CPlayerNavigationDialog::IDD, NULL)
{
}
@@ -43,43 +43,43 @@ CPlayerNavigationDialog::~CPlayerNavigationDialog()
BOOL CPlayerNavigationDialog::Create(CWnd* pParent)
{
- if (!__super::Create(IDD, pParent)) {
- return FALSE;
- }
- m_pParent = pParent;
- return TRUE;
+ if (!__super::Create(IDD, pParent)) {
+ return FALSE;
+ }
+ m_pParent = pParent;
+ return TRUE;
}
void CPlayerNavigationDialog::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_LISTCHANNELS, m_ChannelList);
- DDX_Control(pDX, IDC_NAVIGATION_AUDIO, m_ComboAudio);
- DDX_Control(pDX, IDC_NAVIGATION_INFO, m_ButtonInfo);
- DDX_Control(pDX, IDC_NAVIGATION_SCAN, m_ButtonScan);
- DDX_Control(pDX, IDC_NAVIGATION_FILTERSTATIONS, m_ButtonFilterStations);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_LISTCHANNELS, m_ChannelList);
+ DDX_Control(pDX, IDC_NAVIGATION_AUDIO, m_ComboAudio);
+ DDX_Control(pDX, IDC_NAVIGATION_INFO, m_ButtonInfo);
+ DDX_Control(pDX, IDC_NAVIGATION_SCAN, m_ButtonScan);
+ DDX_Control(pDX, IDC_NAVIGATION_FILTERSTATIONS, m_ButtonFilterStations);
}
BOOL CPlayerNavigationDialog::PreTranslateMessage(MSG* pMsg)
{
- if (pMsg->message == WM_KEYDOWN) {
- if (pMsg->wParam == VK_RETURN) {
- CWnd* pFocused = GetFocus();
- if (pFocused && pFocused->m_hWnd == m_ChannelList.m_hWnd) {
- return TRUE;
- }
- }
- }
- return __super::PreTranslateMessage(pMsg);
+ if (pMsg->message == WM_KEYDOWN) {
+ if (pMsg->wParam == VK_RETURN) {
+ CWnd* pFocused = GetFocus();
+ if (pFocused && pFocused->m_hWnd == m_ChannelList.m_hWnd) {
+ return TRUE;
+ }
+ }
+ }
+ return __super::PreTranslateMessage(pMsg);
}
BEGIN_MESSAGE_MAP(CPlayerNavigationDialog, CResizableDialog)
- ON_WM_DESTROY()
- ON_LBN_SELCHANGE(IDC_LISTCHANNELS, OnChangeChannel)
- ON_CBN_SELCHANGE(IDC_NAVIGATION_AUDIO, OnSelChangeComboAudio)
- ON_BN_CLICKED (IDC_NAVIGATION_INFO, OnButtonInfo)
- ON_BN_CLICKED(IDC_NAVIGATION_SCAN, OnTunerScan)
- ON_BN_CLICKED(IDC_NAVIGATION_FILTERSTATIONS, OnTvRadioStations)
+ ON_WM_DESTROY()
+ ON_LBN_SELCHANGE(IDC_LISTCHANNELS, OnChangeChannel)
+ ON_CBN_SELCHANGE(IDC_NAVIGATION_AUDIO, OnSelChangeComboAudio)
+ ON_BN_CLICKED(IDC_NAVIGATION_INFO, OnButtonInfo)
+ ON_BN_CLICKED(IDC_NAVIGATION_SCAN, OnTunerScan)
+ ON_BN_CLICKED(IDC_NAVIGATION_FILTERSTATIONS, OnTvRadioStations)
END_MESSAGE_MAP()
@@ -88,141 +88,141 @@ END_MESSAGE_MAP()
BOOL CPlayerNavigationDialog::OnInitDialog()
{
- __super::OnInitDialog();
- m_bTVStations = true;
- m_ButtonFilterStations.SetWindowText(ResStr(IDS_DVB_TVNAV_SEERADIO));
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ __super::OnInitDialog();
+ m_bTVStations = true;
+ m_ButtonFilterStations.SetWindowText(ResStr(IDS_DVB_TVNAV_SEERADIO));
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CPlayerNavigationDialog::OnDestroy()
{
- m_ChannelList.ResetContent();
- __super::OnDestroy();
+ m_ChannelList.ResetContent();
+ __super::OnDestroy();
}
void CPlayerNavigationDialog::OnChangeChannel()
{
- CWnd* TempWnd;
- int nItem;
+ CWnd* TempWnd;
+ int nItem;
- TempWnd = static_cast<CPlayerNavigationBar*> (m_pParent) -> m_pParent;
- nItem = p_nItems[m_ChannelList.GetCurSel()] + ID_NAVIGATE_CHAP_SUBITEM_START;
- static_cast<CMainFrame*> (TempWnd) -> OnNavigateChapters(nItem);
- SetupAudioSwitcherSubMenu();
+ TempWnd = static_cast<CPlayerNavigationBar*>(m_pParent) -> m_pParent;
+ nItem = p_nItems[m_ChannelList.GetCurSel()] + ID_NAVIGATE_CHAP_SUBITEM_START;
+ static_cast<CMainFrame*>(TempWnd) -> OnNavigateChapters(nItem);
+ SetupAudioSwitcherSubMenu();
}
void CPlayerNavigationDialog::SetupAudioSwitcherSubMenu(CDVBChannel* pChannel)
{
- bool bFound = (pChannel != NULL);
- int nCurrentChannel;
- AppSettings& s = AfxGetAppSettings();
-
- if (!bFound) {
- nCurrentChannel = s.nDVBLastChannel;
- POSITION pos = s.m_DVBChannels.GetHeadPosition();
- while (pos && !bFound) {
- pChannel = &s.m_DVBChannels.GetNext(pos);
- if (nCurrentChannel == pChannel->GetPrefNumber()) {
- bFound = true;
- }
- }
- }
-
- if (bFound) {
- m_ButtonInfo.EnableWindow(pChannel->GetNowNextFlag());
- m_ComboAudio.ResetContent();
- for (int i=0; i < pChannel->GetAudioCount(); i++) {
- m_ComboAudio.AddString(pChannel->GetAudio(i)->Language);
- m_audios[i].PID = pChannel->GetAudio(i)-> PID;
- m_audios[i].Type = pChannel->GetAudio(i)->Type;
- m_audios[i].PesType = pChannel->GetAudio(i) -> PesType;
- m_audios[i].Language = pChannel->GetAudio(i) -> Language;
- }
-
- m_ComboAudio.SetCurSel(pChannel->GetDefaultAudio());
- }
+ bool bFound = (pChannel != NULL);
+ int nCurrentChannel;
+ AppSettings& s = AfxGetAppSettings();
+
+ if (!bFound) {
+ nCurrentChannel = s.nDVBLastChannel;
+ POSITION pos = s.m_DVBChannels.GetHeadPosition();
+ while (pos && !bFound) {
+ pChannel = &s.m_DVBChannels.GetNext(pos);
+ if (nCurrentChannel == pChannel->GetPrefNumber()) {
+ bFound = true;
+ }
+ }
+ }
+
+ if (bFound) {
+ m_ButtonInfo.EnableWindow(pChannel->GetNowNextFlag());
+ m_ComboAudio.ResetContent();
+ for (int i = 0; i < pChannel->GetAudioCount(); i++) {
+ m_ComboAudio.AddString(pChannel->GetAudio(i)->Language);
+ m_audios[i].PID = pChannel->GetAudio(i)-> PID;
+ m_audios[i].Type = pChannel->GetAudio(i)->Type;
+ m_audios[i].PesType = pChannel->GetAudio(i) -> PesType;
+ m_audios[i].Language = pChannel->GetAudio(i) -> Language;
+ }
+
+ m_ComboAudio.SetCurSel(pChannel->GetDefaultAudio());
+ }
}
void CPlayerNavigationDialog::UpdateElementList()
{
- AppSettings& s = AfxGetAppSettings();
-
- if (s.iDefaultCaptureDevice == 1) {
- m_ChannelList.ResetContent();
-
- int nCurrentChannel = s.nDVBLastChannel;
-
- POSITION pos = s.m_DVBChannels.GetHeadPosition();
- while (pos) {
- CDVBChannel& Channel = s.m_DVBChannels.GetNext(pos);
- if ((m_bTVStations && (Channel.GetVideoPID() != 0)) ||
- (!m_bTVStations && (Channel.GetAudioCount() > 0)) && (Channel.GetVideoPID() == 0)) {
- int nItem = m_ChannelList.AddString (Channel.GetName());
- if (nItem < MAX_CHANNELS_ALLOWED) {
- p_nItems [nItem] = Channel.GetPrefNumber();
- }
- if (nCurrentChannel == Channel.GetPrefNumber()) {
- m_ChannelList.SetCurSel(nItem);
- SetupAudioSwitcherSubMenu(&Channel);
- }
- }
- }
- }
+ AppSettings& s = AfxGetAppSettings();
+
+ if (s.iDefaultCaptureDevice == 1) {
+ m_ChannelList.ResetContent();
+
+ int nCurrentChannel = s.nDVBLastChannel;
+
+ POSITION pos = s.m_DVBChannels.GetHeadPosition();
+ while (pos) {
+ CDVBChannel& Channel = s.m_DVBChannels.GetNext(pos);
+ if ((m_bTVStations && (Channel.GetVideoPID() != 0)) ||
+ (!m_bTVStations && (Channel.GetAudioCount() > 0)) && (Channel.GetVideoPID() == 0)) {
+ int nItem = m_ChannelList.AddString(Channel.GetName());
+ if (nItem < MAX_CHANNELS_ALLOWED) {
+ p_nItems [nItem] = Channel.GetPrefNumber();
+ }
+ if (nCurrentChannel == Channel.GetPrefNumber()) {
+ m_ChannelList.SetCurSel(nItem);
+ SetupAudioSwitcherSubMenu(&Channel);
+ }
+ }
+ }
+ }
}
void CPlayerNavigationDialog::UpdatePos(int nID)
{
- for (int i=0; i < MAX_CHANNELS_ALLOWED; i++) {
- if (p_nItems [i] == nID) {
- m_ChannelList.SetCurSel(i);
- break;
- }
+ for (int i = 0; i < MAX_CHANNELS_ALLOWED; i++) {
+ if (p_nItems [i] == nID) {
+ m_ChannelList.SetCurSel(i);
+ break;
+ }
- }
+ }
}
void CPlayerNavigationDialog::OnTunerScan()
{
- CWnd* TempWnd;
+ CWnd* TempWnd;
- TempWnd = static_cast<CPlayerNavigationBar*> (m_pParent) -> m_pParent;
- static_cast<CMainFrame*> (TempWnd) -> OnTunerScan();
- UpdateElementList();
+ TempWnd = static_cast<CPlayerNavigationBar*>(m_pParent) -> m_pParent;
+ static_cast<CMainFrame*>(TempWnd) -> OnTunerScan();
+ UpdateElementList();
}
void CPlayerNavigationDialog::OnSelChangeComboAudio()
{
- UINT nID;
- CWnd* TempWnd;
- AppSettings& s = AfxGetAppSettings();
- CDVBChannel* pChannel = s.FindChannelByPref(s.nDVBLastChannel);
+ UINT nID;
+ CWnd* TempWnd;
+ AppSettings& s = AfxGetAppSettings();
+ CDVBChannel* pChannel = s.FindChannelByPref(s.nDVBLastChannel);
- nID = m_ComboAudio.GetCurSel() + ID_NAVIGATE_AUDIO_SUBITEM_START;
+ nID = m_ComboAudio.GetCurSel() + ID_NAVIGATE_AUDIO_SUBITEM_START;
- TempWnd = static_cast<CPlayerNavigationBar*> (m_pParent) -> m_pParent;
- static_cast<CMainFrame*> (TempWnd) -> OnNavigateAudio(nID);
+ TempWnd = static_cast<CPlayerNavigationBar*>(m_pParent) -> m_pParent;
+ static_cast<CMainFrame*>(TempWnd) -> OnNavigateAudio(nID);
- pChannel->SetDefaultAudio(m_ComboAudio.GetCurSel());
- pChannel->ToString();
+ pChannel->SetDefaultAudio(m_ComboAudio.GetCurSel());
+ pChannel->ToString();
}
void CPlayerNavigationDialog::OnButtonInfo()
{
- CWnd* TempWnd;
+ CWnd* TempWnd;
- TempWnd = static_cast<CPlayerNavigationBar*> (m_pParent) -> m_pParent;
- static_cast<CMainFrame*> (TempWnd) -> DisplayCurrentChannelInfo();
+ TempWnd = static_cast<CPlayerNavigationBar*>(m_pParent) -> m_pParent;
+ static_cast<CMainFrame*>(TempWnd) -> DisplayCurrentChannelInfo();
}
void CPlayerNavigationDialog::OnTvRadioStations()
{
- m_bTVStations = !m_bTVStations;
- UpdateElementList();
- if (m_bTVStations) {
- m_ButtonFilterStations.SetWindowText(ResStr(IDS_DVB_TVNAV_SEERADIO));
- } else {
- m_ButtonFilterStations.SetWindowText(ResStr(IDS_DVB_TVNAV_SEETV));
- }
+ m_bTVStations = !m_bTVStations;
+ UpdateElementList();
+ if (m_bTVStations) {
+ m_ButtonFilterStations.SetWindowText(ResStr(IDS_DVB_TVNAV_SEERADIO));
+ } else {
+ m_ButtonFilterStations.SetWindowText(ResStr(IDS_DVB_TVNAV_SEETV));
+ }
}
diff --git a/src/mpc-hc/PlayerNavigationDialog.h b/src/mpc-hc/PlayerNavigationDialog.h
index fdd0895ce..e4c9167d7 100644
--- a/src/mpc-hc/PlayerNavigationDialog.h
+++ b/src/mpc-hc/PlayerNavigationDialog.h
@@ -38,41 +38,41 @@ class CPlayerNavigationDialog : public CResizableDialog //CDialog
{
public:
- CPlayerNavigationDialog(); // standard constructor
- virtual ~CPlayerNavigationDialog();
+ CPlayerNavigationDialog(); // standard constructor
+ virtual ~CPlayerNavigationDialog();
- BOOL Create(CWnd* pParent = NULL);
- void UpdateElementList();
- void UpdatePos(int nID);
- void SetupAudioSwitcherSubMenu(CDVBChannel* Channel = NULL);
- int p_nItems[MAX_CHANNELS_ALLOWED];
- DVBStreamInfo m_audios[DVB_MAX_AUDIO];
- bool m_bTVStations;
+ BOOL Create(CWnd* pParent = NULL);
+ void UpdateElementList();
+ void UpdatePos(int nID);
+ void SetupAudioSwitcherSubMenu(CDVBChannel* Channel = NULL);
+ int p_nItems[MAX_CHANNELS_ALLOWED];
+ DVBStreamInfo m_audios[DVB_MAX_AUDIO];
+ bool m_bTVStations;
- // Dialog Data
- enum { IDD = IDD_NAVIGATION_DLG };
+ // Dialog Data
+ enum { IDD = IDD_NAVIGATION_DLG };
- CListBox m_ChannelList;
- CComboBox m_ComboAudio;
- CButton m_ButtonInfo;
- CButton m_ButtonScan;
- CButton m_ButtonFilterStations;
- CWnd* m_pParent;
- // CMenu m_subtitles, m_audios;
+ CListBox m_ChannelList;
+ CComboBox m_ComboAudio;
+ CButton m_ButtonInfo;
+ CButton m_ButtonScan;
+ CButton m_ButtonFilterStations;
+ CWnd* m_pParent;
+ // CMenu m_subtitles, m_audios;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- virtual BOOL OnInitDialog();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL OnInitDialog();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnDestroy();
- afx_msg void OnChangeChannel();
- afx_msg void OnTunerScan();
- afx_msg void OnSelChangeComboAudio();
- afx_msg void OnButtonInfo();
- afx_msg void OnTvRadioStations();
+ afx_msg void OnDestroy();
+ afx_msg void OnChangeChannel();
+ afx_msg void OnTunerScan();
+ afx_msg void OnSelChangeComboAudio();
+ afx_msg void OnButtonInfo();
+ afx_msg void OnTvRadioStations();
};
diff --git a/src/mpc-hc/PlayerPlaylistBar.cpp b/src/mpc-hc/PlayerPlaylistBar.cpp
index 7c48c7ac5..885101dd1 100644
--- a/src/mpc-hc/PlayerPlaylistBar.cpp
+++ b/src/mpc-hc/PlayerPlaylistBar.cpp
@@ -37,10 +37,10 @@
IMPLEMENT_DYNAMIC(CPlayerPlaylistBar, CPlayerBar)
CPlayerPlaylistBar::CPlayerPlaylistBar()
- : m_list(0)
- , m_nTimeColWidth(0)
- , m_bDragging(FALSE)
- , m_bHiddenDueToFullscreen(false)
+ : m_list(0)
+ , m_nTimeColWidth(0)
+ , m_bDragging(FALSE)
+ , m_bHiddenDueToFullscreen(false)
{
}
@@ -50,813 +50,813 @@ CPlayerPlaylistBar::~CPlayerPlaylistBar()
BOOL CPlayerPlaylistBar::Create(CWnd* pParentWnd, UINT defDockBarID)
{
- if (!__super::Create(ResStr(IDS_PLAYLIST_CAPTION), pParentWnd, ID_VIEW_PLAYLIST, defDockBarID, _T("Playlist"))) {
- return FALSE;
- }
+ if (!__super::Create(ResStr(IDS_PLAYLIST_CAPTION), pParentWnd, ID_VIEW_PLAYLIST, defDockBarID, _T("Playlist"))) {
+ return FALSE;
+ }
- m_list.CreateEx(
- WS_EX_DLGMODALFRAME|WS_EX_CLIENTEDGE,
- WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_TABSTOP
- |LVS_OWNERDRAWFIXED
- |LVS_NOCOLUMNHEADER
- |LVS_EDITLABELS
- |LVS_REPORT|LVS_SINGLESEL|LVS_AUTOARRANGE|LVS_NOSORTHEADER, // TODO: remove LVS_SINGLESEL and implement multiple item repositioning (dragging is ready)
- CRect(0,0,100,100), this, IDC_PLAYLIST);
+ m_list.CreateEx(
+ WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE,
+ WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP
+ | LVS_OWNERDRAWFIXED
+ | LVS_NOCOLUMNHEADER
+ | LVS_EDITLABELS
+ | LVS_REPORT | LVS_SINGLESEL | LVS_AUTOARRANGE | LVS_NOSORTHEADER, // TODO: remove LVS_SINGLESEL and implement multiple item repositioning (dragging is ready)
+ CRect(0, 0, 100, 100), this, IDC_PLAYLIST);
- m_list.SetExtendedStyle(m_list.GetExtendedStyle()|LVS_EX_FULLROWSELECT|LVS_EX_DOUBLEBUFFER);
+ m_list.SetExtendedStyle(m_list.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);
- m_list.InsertColumn(COL_NAME, _T("Name"), LVCFMT_LEFT, 380);
+ m_list.InsertColumn(COL_NAME, _T("Name"), LVCFMT_LEFT, 380);
- CDC* pDC = m_list.GetDC();
- CFont* old = pDC->SelectObject(GetFont());
- m_nTimeColWidth = pDC->GetTextExtent(_T("000:00:00")).cx + 5;
- pDC->SelectObject(old);
- m_list.ReleaseDC(pDC);
- m_list.InsertColumn(COL_TIME, _T("Time"), LVCFMT_RIGHT, m_nTimeColWidth);
+ CDC* pDC = m_list.GetDC();
+ CFont* old = pDC->SelectObject(GetFont());
+ m_nTimeColWidth = pDC->GetTextExtent(_T("000:00:00")).cx + 5;
+ pDC->SelectObject(old);
+ m_list.ReleaseDC(pDC);
+ m_list.InsertColumn(COL_TIME, _T("Time"), LVCFMT_RIGHT, m_nTimeColWidth);
- m_fakeImageList.Create(1, 16, ILC_COLOR4, 10, 10);
- m_list.SetImageList(&m_fakeImageList, LVSIL_SMALL);
+ m_fakeImageList.Create(1, 16, ILC_COLOR4, 10, 10);
+ m_list.SetImageList(&m_fakeImageList, LVSIL_SMALL);
- return TRUE;
+ return TRUE;
}
BOOL CPlayerPlaylistBar::PreCreateWindow(CREATESTRUCT& cs)
{
- if (!CSizingControlBarG::PreCreateWindow(cs)) {
- return FALSE;
- }
+ if (!CSizingControlBarG::PreCreateWindow(cs)) {
+ return FALSE;
+ }
- cs.dwExStyle |= WS_EX_ACCEPTFILES;
+ cs.dwExStyle |= WS_EX_ACCEPTFILES;
- return TRUE;
+ return TRUE;
}
BOOL CPlayerPlaylistBar::PreTranslateMessage(MSG* pMsg)
{
- if (IsWindow(pMsg->hwnd) && IsVisible() && pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST) {
- if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE) {
- GetParentFrame()->ShowControlBar(this, FALSE, TRUE);
- return TRUE;
- }
+ if (IsWindow(pMsg->hwnd) && IsVisible() && pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST) {
+ if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE) {
+ GetParentFrame()->ShowControlBar(this, FALSE, TRUE);
+ return TRUE;
+ }
- if (IsDialogMessage(pMsg)) {
- return TRUE;
- }
- }
+ if (IsDialogMessage(pMsg)) {
+ return TRUE;
+ }
+ }
- return CSizingControlBarG::PreTranslateMessage(pMsg);
+ return CSizingControlBarG::PreTranslateMessage(pMsg);
}
-void CPlayerPlaylistBar::LoadState(CFrameWnd *pParent)
+void CPlayerPlaylistBar::LoadState(CFrameWnd* pParent)
{
- CString section = _T("ToolBars\\") + m_strSettingName;
+ CString section = _T("ToolBars\\") + m_strSettingName;
- if (AfxGetApp()->GetProfileInt(section, _T("Visible"), FALSE)) {
- ShowWindow(SW_SHOW);
- }
+ if (AfxGetApp()->GetProfileInt(section, _T("Visible"), FALSE)) {
+ ShowWindow(SW_SHOW);
+ }
- __super::LoadState(pParent);
+ __super::LoadState(pParent);
}
void CPlayerPlaylistBar::SaveState()
{
- __super::SaveState();
+ __super::SaveState();
- CString section = _T("ToolBars\\") + m_strSettingName;
+ CString section = _T("ToolBars\\") + m_strSettingName;
- AfxGetApp()->WriteProfileInt(section, _T("Visible"),
- IsWindowVisible() || (AfxGetAppSettings().bHidePlaylistFullScreen && m_bHiddenDueToFullscreen));
+ AfxGetApp()->WriteProfileInt(section, _T("Visible"),
+ IsWindowVisible() || (AfxGetAppSettings().bHidePlaylistFullScreen && m_bHiddenDueToFullscreen));
}
bool CPlayerPlaylistBar::IsHiddenDueToFullscreen() const
{
- return m_bHiddenDueToFullscreen;
+ return m_bHiddenDueToFullscreen;
}
void CPlayerPlaylistBar::SetHiddenDueToFullscreen(bool bHiddenDueToFullscreen)
{
- m_bHiddenDueToFullscreen = bHiddenDueToFullscreen;
+ m_bHiddenDueToFullscreen = bHiddenDueToFullscreen;
}
void CPlayerPlaylistBar::AddItem(CString fn, CAtlList<CString>* subs)
{
- CAtlList<CString> sl;
- sl.AddTail(fn);
- AddItem(sl, subs);
+ CAtlList<CString> sl;
+ sl.AddTail(fn);
+ AddItem(sl, subs);
}
void CPlayerPlaylistBar::AddItem(CAtlList<CString>& fns, CAtlList<CString>* subs)
{
- CPlaylistItem pli;
+ CPlaylistItem pli;
- POSITION pos = fns.GetHeadPosition();
- while (pos) {
- CString fn = fns.GetNext(pos);
- if (!fn.Trim().IsEmpty()) {
- pli.m_fns.AddTail(fn);
- }
- }
+ POSITION pos = fns.GetHeadPosition();
+ while (pos) {
+ CString fn = fns.GetNext(pos);
+ if (!fn.Trim().IsEmpty()) {
+ pli.m_fns.AddTail(fn);
+ }
+ }
- if (subs) {
- POSITION pos = subs->GetHeadPosition();
- while (pos) {
- CString fn = subs->GetNext(pos);
- if (!fn.Trim().IsEmpty()) {
- pli.m_subs.AddTail(fn);
- }
- }
- }
+ if (subs) {
+ POSITION pos = subs->GetHeadPosition();
+ while (pos) {
+ CString fn = subs->GetNext(pos);
+ if (!fn.Trim().IsEmpty()) {
+ pli.m_subs.AddTail(fn);
+ }
+ }
+ }
- pli.AutoLoadFiles();
+ pli.AutoLoadFiles();
- m_pl.AddTail(pli);
+ m_pl.AddTail(pli);
}
static bool SearchFiles(CString mask, CAtlList<CString>& sl)
{
- if (mask.Find(_T("://")) >= 0) {
- return false;
- }
+ if (mask.Find(_T("://")) >= 0) {
+ return false;
+ }
- mask.Trim();
- sl.RemoveAll();
+ mask.Trim();
+ sl.RemoveAll();
- CMediaFormats& mf = AfxGetAppSettings().m_Formats;
+ CMediaFormats& mf = AfxGetAppSettings().m_Formats;
- WIN32_FILE_ATTRIBUTE_DATA fad;
- bool fFilterKnownExts = (GetFileAttributesEx(mask, GetFileExInfoStandard, &fad)
- && (fad.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY));
- if (fFilterKnownExts) {
- mask = CString(mask).TrimRight(_T("\\/")) + _T("\\*.*");
- }
+ WIN32_FILE_ATTRIBUTE_DATA fad;
+ bool fFilterKnownExts = (GetFileAttributesEx(mask, GetFileExInfoStandard, &fad)
+ && (fad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY));
+ if (fFilterKnownExts) {
+ mask = CString(mask).TrimRight(_T("\\/")) + _T("\\*.*");
+ }
- {
- CString dir = mask.Left(max(mask.ReverseFind('\\'), mask.ReverseFind('/'))+1);
+ {
+ CString dir = mask.Left(max(mask.ReverseFind('\\'), mask.ReverseFind('/')) + 1);
- WIN32_FIND_DATA fd;
- HANDLE h = FindFirstFile(mask, &fd);
- if (h != INVALID_HANDLE_VALUE) {
- do {
- if (fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) {
- continue;
- }
+ WIN32_FIND_DATA fd;
+ HANDLE h = FindFirstFile(mask, &fd);
+ if (h != INVALID_HANDLE_VALUE) {
+ do {
+ if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+ continue;
+ }
- CString fn = fd.cFileName;
- //CString ext = fn.Mid(fn.ReverseFind('.')+1).MakeLower();
- CString ext = fn.Mid(fn.ReverseFind('.')).MakeLower();
- CString path = dir + fd.cFileName;
+ CString fn = fd.cFileName;
+ //CString ext = fn.Mid(fn.ReverseFind('.')+1).MakeLower();
+ CString ext = fn.Mid(fn.ReverseFind('.')).MakeLower();
+ CString path = dir + fd.cFileName;
- if (!fFilterKnownExts || mf.FindExt(ext)) {
- for (size_t i = 0; i < mf.GetCount(); i++) {
- CMediaFormatCategory& mfc = mf.GetAt(i);
- /* playlist files are skipped when playing the contents of an entire directory */
- if ((mfc.FindExt(ext)) && (mf[i].GetLabel().CompareNoCase(_T("pls")) != 0)) {
- sl.AddTail(path);
- break;
- }
- }
- }
+ if (!fFilterKnownExts || mf.FindExt(ext)) {
+ for (size_t i = 0; i < mf.GetCount(); i++) {
+ CMediaFormatCategory& mfc = mf.GetAt(i);
+ /* playlist files are skipped when playing the contents of an entire directory */
+ if ((mfc.FindExt(ext)) && (mf[i].GetLabel().CompareNoCase(_T("pls")) != 0)) {
+ sl.AddTail(path);
+ break;
+ }
+ }
+ }
- } while (FindNextFile(h, &fd));
+ } while (FindNextFile(h, &fd));
- FindClose(h);
+ FindClose(h);
- if (sl.GetCount() == 0 && mask.Find(_T(":\\")) == 1) {
- GetCDROMType(mask[0], sl);
- }
- }
- }
+ if (sl.GetCount() == 0 && mask.Find(_T(":\\")) == 1) {
+ GetCDROMType(mask[0], sl);
+ }
+ }
+ }
- return (sl.GetCount() > 1
- || sl.GetCount() == 1 && sl.GetHead().CompareNoCase(mask)
- || sl.GetCount() == 0 && mask.FindOneOf(_T("?*")) >= 0);
+ return (sl.GetCount() > 1
+ || sl.GetCount() == 1 && sl.GetHead().CompareNoCase(mask)
+ || sl.GetCount() == 0 && mask.FindOneOf(_T("?*")) >= 0);
}
void CPlayerPlaylistBar::ParsePlayList(CString fn, CAtlList<CString>* subs)
{
- CAtlList<CString> sl;
- sl.AddTail(fn);
- ParsePlayList(sl, subs);
+ CAtlList<CString> sl;
+ sl.AddTail(fn);
+ ParsePlayList(sl, subs);
}
-void CPlayerPlaylistBar::ResolveLinkFiles( CAtlList<CString> &fns )
+void CPlayerPlaylistBar::ResolveLinkFiles(CAtlList<CString>& fns)
{
- // resolve .lnk files
+ // resolve .lnk files
- CComPtr<IShellLink> pSL;
- pSL.CoCreateInstance(CLSID_ShellLink);
- CComQIPtr<IPersistFile> pPF = pSL;
+ CComPtr<IShellLink> pSL;
+ pSL.CoCreateInstance(CLSID_ShellLink);
+ CComQIPtr<IPersistFile> pPF = pSL;
- POSITION pos = fns.GetHeadPosition();
- while (pSL && pPF && pos) {
- CString& fn = fns.GetNext(pos);
- TCHAR buff[_MAX_PATH];
- if (CPath(fn).GetExtension().MakeLower() != _T(".lnk")
- || FAILED(pPF->Load(CStringW(fn), STGM_READ))
- || FAILED(pSL->Resolve(NULL, SLR_ANY_MATCH|SLR_NO_UI))
- || FAILED(pSL->GetPath(buff, _countof(buff), NULL, 0))) {
- continue;
- }
+ POSITION pos = fns.GetHeadPosition();
+ while (pSL && pPF && pos) {
+ CString& fn = fns.GetNext(pos);
+ TCHAR buff[_MAX_PATH];
+ if (CPath(fn).GetExtension().MakeLower() != _T(".lnk")
+ || FAILED(pPF->Load(CStringW(fn), STGM_READ))
+ || FAILED(pSL->Resolve(NULL, SLR_ANY_MATCH | SLR_NO_UI))
+ || FAILED(pSL->GetPath(buff, _countof(buff), NULL, 0))) {
+ continue;
+ }
- fn = buff;
- }
+ fn = buff;
+ }
}
void CPlayerPlaylistBar::ParsePlayList(CAtlList<CString>& fns, CAtlList<CString>* subs)
{
- if (fns.IsEmpty()) {
- return;
- }
-
- AppSettings& s = AfxGetAppSettings();
-
- ResolveLinkFiles(fns);
-
- CAtlList<CString> sl;
- if (SearchFiles(fns.GetHead(), sl)) {
- if (sl.GetCount() > 1) {
- subs = NULL;
- }
- POSITION pos = sl.GetHeadPosition();
- while (pos) {
- ParsePlayList(sl.GetNext(pos), subs);
- }
- return;
- }
-
- CAtlList<CString> redir;
- CStringA ct = GetContentType(fns.GetHead(), &redir);
- if (!redir.IsEmpty()) {
- POSITION pos = redir.GetHeadPosition();
- while (pos) {
- ParsePlayList(sl.GetNext(pos), subs);
- }
- return;
- }
-
- if (ct == "application/x-mpc-playlist") {
- ParseMPCPlayList(fns.GetHead());
- return;
- } else {
+ if (fns.IsEmpty()) {
+ return;
+ }
+
+ AppSettings& s = AfxGetAppSettings();
+
+ ResolveLinkFiles(fns);
+
+ CAtlList<CString> sl;
+ if (SearchFiles(fns.GetHead(), sl)) {
+ if (sl.GetCount() > 1) {
+ subs = NULL;
+ }
+ POSITION pos = sl.GetHeadPosition();
+ while (pos) {
+ ParsePlayList(sl.GetNext(pos), subs);
+ }
+ return;
+ }
+
+ CAtlList<CString> redir;
+ CStringA ct = GetContentType(fns.GetHead(), &redir);
+ if (!redir.IsEmpty()) {
+ POSITION pos = redir.GetHeadPosition();
+ while (pos) {
+ ParsePlayList(sl.GetNext(pos), subs);
+ }
+ return;
+ }
+
+ if (ct == "application/x-mpc-playlist") {
+ ParseMPCPlayList(fns.GetHead());
+ return;
+ } else {
#if INTERNAL_SOURCEFILTER_MPEG
- if (ct == "application/x-bdmv-playlist" && s.SrcFilters[SRC_MPEG]) {
- ParseBDMVPlayList(fns.GetHead());
- return;
- }
+ if (ct == "application/x-bdmv-playlist" && s.SrcFilters[SRC_MPEG]) {
+ ParseBDMVPlayList(fns.GetHead());
+ return;
+ }
#endif
- }
+ }
- AddItem(fns, subs);
+ AddItem(fns, subs);
}
static int s_int_comp(const void* i1, const void* i2)
{
- return (int)i1 - (int)i2;
+ return (int)i1 - (int)i2;
}
static CString CombinePath(CPath p, CString fn)
{
- if (fn.Find(':') >= 0 || fn.Find(_T("\\")) == 0) {
- return fn;
- }
- p.Append(CPath(fn));
- return (LPCTSTR)p;
+ if (fn.Find(':') >= 0 || fn.Find(_T("\\")) == 0) {
+ return fn;
+ }
+ p.Append(CPath(fn));
+ return (LPCTSTR)p;
}
bool CPlayerPlaylistBar::ParseBDMVPlayList(CString fn)
{
- CHdmvClipInfo ClipInfo;
- CString strPlaylistFile;
- CAtlList<CHdmvClipInfo::PlaylistItem> MainPlaylist;
+ CHdmvClipInfo ClipInfo;
+ CString strPlaylistFile;
+ CAtlList<CHdmvClipInfo::PlaylistItem> MainPlaylist;
- CPath Path(fn);
- Path.RemoveFileSpec();
- Path.RemoveFileSpec();
+ CPath Path(fn);
+ Path.RemoveFileSpec();
+ Path.RemoveFileSpec();
- if (SUCCEEDED (ClipInfo.FindMainMovie (Path + L"\\", strPlaylistFile, MainPlaylist, ((CMainFrame*)GetParentFrame())->m_MPLSPlaylist))) {
- CAtlList<CString> strFiles;
- strFiles.AddHead (strPlaylistFile);
- Append(strFiles, MainPlaylist.GetCount()>1, NULL);
- }
+ if (SUCCEEDED(ClipInfo.FindMainMovie(Path + L"\\", strPlaylistFile, MainPlaylist, ((CMainFrame*)GetParentFrame())->m_MPLSPlaylist))) {
+ CAtlList<CString> strFiles;
+ strFiles.AddHead(strPlaylistFile);
+ Append(strFiles, MainPlaylist.GetCount() > 1, NULL);
+ }
- return m_pl.GetCount() > 0;
+ return m_pl.GetCount() > 0;
}
bool CPlayerPlaylistBar::ParseMPCPlayList(CString fn)
{
- CString str;
- CAtlMap<int, CPlaylistItem> pli;
- CAtlArray<int> idx;
-
- CWebTextFile f;
- if (!f.Open(fn) || !f.ReadString(str) || str != _T("MPCPLAYLIST")) {
- return false;
- }
-
- if (f.GetEncoding() == CTextFile::ASCII) {
- f.SetEncoding(CTextFile::ANSI);
- }
-
- CPath base(fn);
- base.RemoveFileSpec();
-
- while (f.ReadString(str)) {
- CAtlList<CString> sl;
- Explode(str, sl, ',', 3);
- if (sl.GetCount() != 3) {
- continue;
- }
-
- if (int i = _ttoi(sl.RemoveHead())) {
- CString key = sl.RemoveHead();
- CString value = sl.RemoveHead();
-
- if (key == _T("type")) {
- pli[i].m_type = (CPlaylistItem::type_t)_ttol(value);
- idx.Add(i);
- } else if (key == _T("label")) {
- pli[i].m_label = value;
- } else if (key == _T("filename")) {
- value = CombinePath(base, value);
- pli[i].m_fns.AddTail(value);
- } else if (key == _T("subtitle")) {
- value = CombinePath(base, value);
- pli[i].m_subs.AddTail(value);
- } else if (key == _T("video")) {
- while (pli[i].m_fns.GetCount() < 2) {
- pli[i].m_fns.AddTail(_T(""));
- }
- pli[i].m_fns.GetHead() = value;
- } else if (key == _T("audio")) {
- while (pli[i].m_fns.GetCount() < 2) {
- pli[i].m_fns.AddTail(_T(""));
- }
- pli[i].m_fns.GetTail() = value;
- } else if (key == _T("vinput")) {
- pli[i].m_vinput = _ttol(value);
- } else if (key == _T("vchannel")) {
- pli[i].m_vchannel = _ttol(value);
- } else if (key == _T("ainput")) {
- pli[i].m_ainput = _ttol(value);
- } else if (key == _T("country")) {
- pli[i].m_country = _ttol(value);
- }
- }
- }
-
- qsort(idx.GetData(), idx.GetCount(), sizeof(int), s_int_comp);
- for (size_t i = 0; i < idx.GetCount(); i++) {
- m_pl.AddTail(pli[idx[i]]);
- }
-
- return pli.GetCount() > 0;
+ CString str;
+ CAtlMap<int, CPlaylistItem> pli;
+ CAtlArray<int> idx;
+
+ CWebTextFile f;
+ if (!f.Open(fn) || !f.ReadString(str) || str != _T("MPCPLAYLIST")) {
+ return false;
+ }
+
+ if (f.GetEncoding() == CTextFile::ASCII) {
+ f.SetEncoding(CTextFile::ANSI);
+ }
+
+ CPath base(fn);
+ base.RemoveFileSpec();
+
+ while (f.ReadString(str)) {
+ CAtlList<CString> sl;
+ Explode(str, sl, ',', 3);
+ if (sl.GetCount() != 3) {
+ continue;
+ }
+
+ if (int i = _ttoi(sl.RemoveHead())) {
+ CString key = sl.RemoveHead();
+ CString value = sl.RemoveHead();
+
+ if (key == _T("type")) {
+ pli[i].m_type = (CPlaylistItem::type_t)_ttol(value);
+ idx.Add(i);
+ } else if (key == _T("label")) {
+ pli[i].m_label = value;
+ } else if (key == _T("filename")) {
+ value = CombinePath(base, value);
+ pli[i].m_fns.AddTail(value);
+ } else if (key == _T("subtitle")) {
+ value = CombinePath(base, value);
+ pli[i].m_subs.AddTail(value);
+ } else if (key == _T("video")) {
+ while (pli[i].m_fns.GetCount() < 2) {
+ pli[i].m_fns.AddTail(_T(""));
+ }
+ pli[i].m_fns.GetHead() = value;
+ } else if (key == _T("audio")) {
+ while (pli[i].m_fns.GetCount() < 2) {
+ pli[i].m_fns.AddTail(_T(""));
+ }
+ pli[i].m_fns.GetTail() = value;
+ } else if (key == _T("vinput")) {
+ pli[i].m_vinput = _ttol(value);
+ } else if (key == _T("vchannel")) {
+ pli[i].m_vchannel = _ttol(value);
+ } else if (key == _T("ainput")) {
+ pli[i].m_ainput = _ttol(value);
+ } else if (key == _T("country")) {
+ pli[i].m_country = _ttol(value);
+ }
+ }
+ }
+
+ qsort(idx.GetData(), idx.GetCount(), sizeof(int), s_int_comp);
+ for (size_t i = 0; i < idx.GetCount(); i++) {
+ m_pl.AddTail(pli[idx[i]]);
+ }
+
+ return pli.GetCount() > 0;
}
bool CPlayerPlaylistBar::SaveMPCPlayList(CString fn, CTextFile::enc e, bool fRemovePath)
{
- CTextFile f;
- if (!f.Save(fn, e)) {
- return false;
- }
-
- f.WriteString(_T("MPCPLAYLIST\n"));
-
- POSITION pos = m_pl.GetHeadPosition(), pos2;
- for (int i = 1; pos; i++) {
- CPlaylistItem& pli = m_pl.GetNext(pos);
-
- CString idx;
- idx.Format(_T("%d"), i);
-
- CString str;
- str.Format(_T("%d,type,%d"), i, pli.m_type);
- f.WriteString(str + _T("\n"));
-
- if (!pli.m_label.IsEmpty()) {
- f.WriteString(idx + _T(",label,") + pli.m_label + _T("\n"));
- }
-
- if (pli.m_type == CPlaylistItem::file) {
- pos2 = pli.m_fns.GetHeadPosition();
- while (pos2) {
- CString fn = pli.m_fns.GetNext(pos2);
- if (fRemovePath) {
- CPath p(fn);
- p.StripPath();
- fn = (LPCTSTR)p;
- }
- f.WriteString(idx + _T(",filename,") + fn + _T("\n"));
- }
-
- pos2 = pli.m_subs.GetHeadPosition();
- while (pos2) {
- CString fn = pli.m_subs.GetNext(pos2);
- if (fRemovePath) {
- CPath p(fn);
- p.StripPath();
- fn = (LPCTSTR)p;
- }
- f.WriteString(idx + _T(",subtitle,") + fn + _T("\n"));
- }
- } else if (pli.m_type == CPlaylistItem::device && pli.m_fns.GetCount() == 2) {
- f.WriteString(idx + _T(",video,") + pli.m_fns.GetHead() + _T("\n"));
- f.WriteString(idx + _T(",audio,") + pli.m_fns.GetTail() + _T("\n"));
- str.Format(_T("%d,vinput,%d"), i, pli.m_vinput);
- f.WriteString(str + _T("\n"));
- str.Format(_T("%d,vchannel,%d"), i, pli.m_vchannel);
- f.WriteString(str + _T("\n"));
- str.Format(_T("%d,ainput,%d"), i, pli.m_ainput);
- f.WriteString(str + _T("\n"));
- str.Format(_T("%d,country,%d"), i, pli.m_country);
- f.WriteString(str + _T("\n"));
- }
- }
-
- return true;
+ CTextFile f;
+ if (!f.Save(fn, e)) {
+ return false;
+ }
+
+ f.WriteString(_T("MPCPLAYLIST\n"));
+
+ POSITION pos = m_pl.GetHeadPosition(), pos2;
+ for (int i = 1; pos; i++) {
+ CPlaylistItem& pli = m_pl.GetNext(pos);
+
+ CString idx;
+ idx.Format(_T("%d"), i);
+
+ CString str;
+ str.Format(_T("%d,type,%d"), i, pli.m_type);
+ f.WriteString(str + _T("\n"));
+
+ if (!pli.m_label.IsEmpty()) {
+ f.WriteString(idx + _T(",label,") + pli.m_label + _T("\n"));
+ }
+
+ if (pli.m_type == CPlaylistItem::file) {
+ pos2 = pli.m_fns.GetHeadPosition();
+ while (pos2) {
+ CString fn = pli.m_fns.GetNext(pos2);
+ if (fRemovePath) {
+ CPath p(fn);
+ p.StripPath();
+ fn = (LPCTSTR)p;
+ }
+ f.WriteString(idx + _T(",filename,") + fn + _T("\n"));
+ }
+
+ pos2 = pli.m_subs.GetHeadPosition();
+ while (pos2) {
+ CString fn = pli.m_subs.GetNext(pos2);
+ if (fRemovePath) {
+ CPath p(fn);
+ p.StripPath();
+ fn = (LPCTSTR)p;
+ }
+ f.WriteString(idx + _T(",subtitle,") + fn + _T("\n"));
+ }
+ } else if (pli.m_type == CPlaylistItem::device && pli.m_fns.GetCount() == 2) {
+ f.WriteString(idx + _T(",video,") + pli.m_fns.GetHead() + _T("\n"));
+ f.WriteString(idx + _T(",audio,") + pli.m_fns.GetTail() + _T("\n"));
+ str.Format(_T("%d,vinput,%d"), i, pli.m_vinput);
+ f.WriteString(str + _T("\n"));
+ str.Format(_T("%d,vchannel,%d"), i, pli.m_vchannel);
+ f.WriteString(str + _T("\n"));
+ str.Format(_T("%d,ainput,%d"), i, pli.m_ainput);
+ f.WriteString(str + _T("\n"));
+ str.Format(_T("%d,country,%d"), i, pli.m_country);
+ f.WriteString(str + _T("\n"));
+ }
+ }
+
+ return true;
}
void CPlayerPlaylistBar::Refresh()
{
- SetupList();
- ResizeListColumn();
+ SetupList();
+ ResizeListColumn();
}
bool CPlayerPlaylistBar::Empty()
{
- bool bWasPlaying = m_pl.RemoveAll();
- m_list.DeleteAllItems();
- SavePlaylist();
+ bool bWasPlaying = m_pl.RemoveAll();
+ m_list.DeleteAllItems();
+ SavePlaylist();
- return bWasPlaying;
+ return bWasPlaying;
}
void CPlayerPlaylistBar::Open(CAtlList<CString>& fns, bool fMulti, CAtlList<CString>* subs)
{
- ResolveLinkFiles(fns);
- Empty();
- Append(fns, fMulti, subs);
+ ResolveLinkFiles(fns);
+ Empty();
+ Append(fns, fMulti, subs);
}
void CPlayerPlaylistBar::Append(CAtlList<CString>& fns, bool fMulti, CAtlList<CString>* subs)
{
- if (fMulti) {
- ASSERT(subs == NULL || subs->GetCount() == 0);
- POSITION pos = fns.GetHeadPosition();
- while (pos) {
- ParsePlayList(fns.GetNext(pos), NULL);
- }
- } else {
- ParsePlayList(fns, subs);
- }
+ if (fMulti) {
+ ASSERT(subs == NULL || subs->GetCount() == 0);
+ POSITION pos = fns.GetHeadPosition();
+ while (pos) {
+ ParsePlayList(fns.GetNext(pos), NULL);
+ }
+ } else {
+ ParsePlayList(fns, subs);
+ }
- Refresh();
- SavePlaylist();
+ Refresh();
+ SavePlaylist();
}
void CPlayerPlaylistBar::Open(CStringW vdn, CStringW adn, int vinput, int vchannel, int ainput)
{
- Empty();
- Append(vdn, adn, vinput, vchannel, ainput);
+ Empty();
+ Append(vdn, adn, vinput, vchannel, ainput);
}
void CPlayerPlaylistBar::Append(CStringW vdn, CStringW adn, int vinput, int vchannel, int ainput)
{
- CPlaylistItem pli;
- pli.m_type = CPlaylistItem::device;
- pli.m_fns.AddTail(CString(vdn));
- pli.m_fns.AddTail(CString(adn));
- pli.m_vinput = vinput;
- pli.m_vchannel = vchannel;
- pli.m_ainput = ainput;
- CAtlList<CStringW> sl;
- CStringW vfn = GetFriendlyName(vdn);
- CStringW afn = GetFriendlyName(adn);
- if (!vfn.IsEmpty()) {
- sl.AddTail(vfn);
- }
- if (!afn.IsEmpty()) {
- sl.AddTail(afn);
- }
- CStringW label = Implode(sl, '|');
- label.Replace(L"|", L" - ");
- pli.m_label = CString(label);
- m_pl.AddTail(pli);
-
- Refresh();
- SavePlaylist();
+ CPlaylistItem pli;
+ pli.m_type = CPlaylistItem::device;
+ pli.m_fns.AddTail(CString(vdn));
+ pli.m_fns.AddTail(CString(adn));
+ pli.m_vinput = vinput;
+ pli.m_vchannel = vchannel;
+ pli.m_ainput = ainput;
+ CAtlList<CStringW> sl;
+ CStringW vfn = GetFriendlyName(vdn);
+ CStringW afn = GetFriendlyName(adn);
+ if (!vfn.IsEmpty()) {
+ sl.AddTail(vfn);
+ }
+ if (!afn.IsEmpty()) {
+ sl.AddTail(afn);
+ }
+ CStringW label = Implode(sl, '|');
+ label.Replace(L"|", L" - ");
+ pli.m_label = CString(label);
+ m_pl.AddTail(pli);
+
+ Refresh();
+ SavePlaylist();
}
void CPlayerPlaylistBar::SetupList()
{
- m_list.DeleteAllItems();
+ m_list.DeleteAllItems();
- POSITION pos = m_pl.GetHeadPosition();
- for (int i = 0; pos; i++) {
- CPlaylistItem& pli = m_pl.GetAt(pos);
- m_list.SetItemData(m_list.InsertItem(i, pli.GetLabel()), (DWORD_PTR)pos);
- m_list.SetItemText(i, COL_TIME, pli.GetLabel(1));
- m_pl.GetNext(pos);
- }
+ POSITION pos = m_pl.GetHeadPosition();
+ for (int i = 0; pos; i++) {
+ CPlaylistItem& pli = m_pl.GetAt(pos);
+ m_list.SetItemData(m_list.InsertItem(i, pli.GetLabel()), (DWORD_PTR)pos);
+ m_list.SetItemText(i, COL_TIME, pli.GetLabel(1));
+ m_pl.GetNext(pos);
+ }
}
void CPlayerPlaylistBar::UpdateList()
{
- POSITION pos = m_pl.GetHeadPosition();
- for (int i = 0, j = m_list.GetItemCount(); pos && i < j; i++) {
- CPlaylistItem& pli = m_pl.GetAt(pos);
- m_list.SetItemData(i, (DWORD_PTR)pos);
- m_list.SetItemText(i, COL_NAME, pli.GetLabel(0));
- m_list.SetItemText(i, COL_TIME, pli.GetLabel(1));
- m_pl.GetNext(pos);
- }
+ POSITION pos = m_pl.GetHeadPosition();
+ for (int i = 0, j = m_list.GetItemCount(); pos && i < j; i++) {
+ CPlaylistItem& pli = m_pl.GetAt(pos);
+ m_list.SetItemData(i, (DWORD_PTR)pos);
+ m_list.SetItemText(i, COL_NAME, pli.GetLabel(0));
+ m_list.SetItemText(i, COL_TIME, pli.GetLabel(1));
+ m_pl.GetNext(pos);
+ }
}
void CPlayerPlaylistBar::EnsureVisible(POSITION pos)
{
- int i = FindItem(m_pl.GetPos());
- if (i < 0) {
- return;
- }
- m_list.EnsureVisible(i, TRUE);
- m_list.Invalidate();
+ int i = FindItem(m_pl.GetPos());
+ if (i < 0) {
+ return;
+ }
+ m_list.EnsureVisible(i, TRUE);
+ m_list.Invalidate();
}
int CPlayerPlaylistBar::FindItem(POSITION pos) const
{
- for (int i = 0; i < m_list.GetItemCount(); i++)
- if ((POSITION)m_list.GetItemData(i) == pos) {
- return (i);
- }
- return -1;
+ for (int i = 0; i < m_list.GetItemCount(); i++)
+ if ((POSITION)m_list.GetItemData(i) == pos) {
+ return (i);
+ }
+ return -1;
}
POSITION CPlayerPlaylistBar::FindPos(int i)
{
- if (i < 0) {
- return NULL;
- }
- return (POSITION)m_list.GetItemData(i);
+ if (i < 0) {
+ return NULL;
+ }
+ return (POSITION)m_list.GetItemData(i);
}
INT_PTR CPlayerPlaylistBar::GetCount() const
{
- return m_pl.GetCount(); // TODO: n - .fInvalid
+ return m_pl.GetCount(); // TODO: n - .fInvalid
}
int CPlayerPlaylistBar::GetSelIdx() const
{
- return FindItem(m_pl.GetPos());
+ return FindItem(m_pl.GetPos());
}
void CPlayerPlaylistBar::SetSelIdx(int i)
{
- m_pl.SetPos(FindPos(i));
+ m_pl.SetPos(FindPos(i));
}
bool CPlayerPlaylistBar::IsAtEnd()
{
- POSITION pos = m_pl.GetPos(), tail = m_pl.GetTailPosition();
- bool isAtEnd = (pos && pos == tail);
+ POSITION pos = m_pl.GetPos(), tail = m_pl.GetTailPosition();
+ bool isAtEnd = (pos && pos == tail);
- if (!isAtEnd && pos) {
- isAtEnd = m_pl.GetNextWrap(pos).m_fInvalid;
- while (isAtEnd && pos && pos != tail) {
- isAtEnd = m_pl.GetNextWrap(pos).m_fInvalid;
- }
- }
+ if (!isAtEnd && pos) {
+ isAtEnd = m_pl.GetNextWrap(pos).m_fInvalid;
+ while (isAtEnd && pos && pos != tail) {
+ isAtEnd = m_pl.GetNextWrap(pos).m_fInvalid;
+ }
+ }
- return isAtEnd;
+ return isAtEnd;
}
bool CPlayerPlaylistBar::GetCur(CPlaylistItem& pli) const
{
- if (!m_pl.GetPos()) {
- return false;
- }
- pli = m_pl.GetAt(m_pl.GetPos());
- return true;
+ if (!m_pl.GetPos()) {
+ return false;
+ }
+ pli = m_pl.GetAt(m_pl.GetPos());
+ return true;
}
CPlaylistItem* CPlayerPlaylistBar::GetCur()
{
- if (!m_pl.GetPos()) {
- return NULL;
- }
- return &m_pl.GetAt(m_pl.GetPos());
+ if (!m_pl.GetPos()) {
+ return NULL;
+ }
+ return &m_pl.GetAt(m_pl.GetPos());
}
CString CPlayerPlaylistBar::GetCurFileName()
{
- CString fn;
- CPlaylistItem* pli = GetCur();
- if (pli && !pli->m_fns.IsEmpty()) {
- fn = pli->m_fns.GetHead();
- }
- return fn;
+ CString fn;
+ CPlaylistItem* pli = GetCur();
+ if (pli && !pli->m_fns.IsEmpty()) {
+ fn = pli->m_fns.GetHead();
+ }
+ return fn;
}
bool CPlayerPlaylistBar::SetNext()
{
- POSITION pos = m_pl.GetPos(), org = pos;
- while (m_pl.GetNextWrap(pos).m_fInvalid && pos != org) {
- ;
- }
- UpdateList();
- m_pl.SetPos(pos);
- EnsureVisible(pos);
+ POSITION pos = m_pl.GetPos(), org = pos;
+ while (m_pl.GetNextWrap(pos).m_fInvalid && pos != org) {
+ ;
+ }
+ UpdateList();
+ m_pl.SetPos(pos);
+ EnsureVisible(pos);
- return (pos != org);
+ return (pos != org);
}
bool CPlayerPlaylistBar::SetPrev()
{
- POSITION pos = m_pl.GetPos(), org = pos;
- while (m_pl.GetPrevWrap(pos).m_fInvalid && pos != org) {
- ;
- }
- m_pl.SetPos(pos);
- EnsureVisible(pos);
+ POSITION pos = m_pl.GetPos(), org = pos;
+ while (m_pl.GetPrevWrap(pos).m_fInvalid && pos != org) {
+ ;
+ }
+ m_pl.SetPos(pos);
+ EnsureVisible(pos);
- return (pos != org);
+ return (pos != org);
}
void CPlayerPlaylistBar::SetFirstSelected()
{
- POSITION pos = m_list.GetFirstSelectedItemPosition();
- if (pos) {
- pos = FindPos(m_list.GetNextSelectedItem(pos));
- } else {
- pos = m_pl.GetTailPosition();
- POSITION org = pos;
- while (m_pl.GetNextWrap(pos).m_fInvalid && pos != org) {
- ;
- }
- }
- UpdateList();
- m_pl.SetPos(pos);
- EnsureVisible(pos);
+ POSITION pos = m_list.GetFirstSelectedItemPosition();
+ if (pos) {
+ pos = FindPos(m_list.GetNextSelectedItem(pos));
+ } else {
+ pos = m_pl.GetTailPosition();
+ POSITION org = pos;
+ while (m_pl.GetNextWrap(pos).m_fInvalid && pos != org) {
+ ;
+ }
+ }
+ UpdateList();
+ m_pl.SetPos(pos);
+ EnsureVisible(pos);
}
void CPlayerPlaylistBar::SetFirst()
{
- POSITION pos = m_pl.GetTailPosition(), org = pos;
- while (m_pl.GetNextWrap(pos).m_fInvalid && pos != org) {
- ;
- }
- UpdateList();
- m_pl.SetPos(pos);
- EnsureVisible(pos);
+ POSITION pos = m_pl.GetTailPosition(), org = pos;
+ while (m_pl.GetNextWrap(pos).m_fInvalid && pos != org) {
+ ;
+ }
+ UpdateList();
+ m_pl.SetPos(pos);
+ EnsureVisible(pos);
}
void CPlayerPlaylistBar::SetLast()
{
- POSITION pos = m_pl.GetHeadPosition(), org = pos;
- while (m_pl.GetPrevWrap(pos).m_fInvalid && pos != org) {
- ;
- }
- m_pl.SetPos(pos);
- EnsureVisible(pos);
+ POSITION pos = m_pl.GetHeadPosition(), org = pos;
+ while (m_pl.GetPrevWrap(pos).m_fInvalid && pos != org) {
+ ;
+ }
+ m_pl.SetPos(pos);
+ EnsureVisible(pos);
}
void CPlayerPlaylistBar::SetCurValid(bool fValid)
{
- POSITION pos = m_pl.GetPos();
- if (pos) {
- m_pl.GetAt(pos).m_fInvalid = !fValid;
- if (!fValid) {
- int i = FindItem(pos);
- m_list.RedrawItems(i, i);
- }
- }
+ POSITION pos = m_pl.GetPos();
+ if (pos) {
+ m_pl.GetAt(pos).m_fInvalid = !fValid;
+ if (!fValid) {
+ int i = FindItem(pos);
+ m_list.RedrawItems(i, i);
+ }
+ }
}
void CPlayerPlaylistBar::SetCurTime(REFERENCE_TIME rt)
{
- POSITION pos = m_pl.GetPos();
- if (pos) {
- CPlaylistItem& pli = m_pl.GetAt(pos);
- pli.m_duration = rt;
- m_list.SetItemText(FindItem(pos), COL_TIME, pli.GetLabel(1));
- }
+ POSITION pos = m_pl.GetPos();
+ if (pos) {
+ CPlaylistItem& pli = m_pl.GetAt(pos);
+ pli.m_duration = rt;
+ m_list.SetItemText(FindItem(pos), COL_TIME, pli.GetLabel(1));
+ }
}
OpenMediaData* CPlayerPlaylistBar::GetCurOMD(REFERENCE_TIME rtStart)
{
- CPlaylistItem* pli = GetCur();
- if (pli == NULL) {
- return NULL;
- }
-
- pli->AutoLoadFiles();
-
- CString fn = CString(pli->m_fns.GetHead()).MakeLower();
-
- if (fn.Find(_T("video_ts.ifo")) >= 0
- || fn.Find(_T(".ratdvd")) >= 0) {
- if (OpenDVDData* p = DNew OpenDVDData()) {
- p->path = pli->m_fns.GetHead();
- p->subs.AddTailList(&pli->m_subs);
- return p;
- }
- }
-
- if (pli->m_type == CPlaylistItem::device) {
- if (OpenDeviceData* p = DNew OpenDeviceData()) {
- POSITION pos = pli->m_fns.GetHeadPosition();
- for (int i = 0; i < _countof(p->DisplayName) && pos; i++) {
- p->DisplayName[i] = pli->m_fns.GetNext(pos);
- }
- p->vinput = pli->m_vinput;
- p->vchannel = pli->m_vchannel;
- p->ainput = pli->m_ainput;
- return p;
- }
- } else {
- if (OpenFileData* p = DNew OpenFileData()) {
- p->fns.AddTailList(&pli->m_fns);
- p->subs.AddTailList(&pli->m_subs);
- p->rtStart = rtStart;
- return p;
- }
- }
-
- return NULL;
+ CPlaylistItem* pli = GetCur();
+ if (pli == NULL) {
+ return NULL;
+ }
+
+ pli->AutoLoadFiles();
+
+ CString fn = CString(pli->m_fns.GetHead()).MakeLower();
+
+ if (fn.Find(_T("video_ts.ifo")) >= 0
+ || fn.Find(_T(".ratdvd")) >= 0) {
+ if (OpenDVDData* p = DNew OpenDVDData()) {
+ p->path = pli->m_fns.GetHead();
+ p->subs.AddTailList(&pli->m_subs);
+ return p;
+ }
+ }
+
+ if (pli->m_type == CPlaylistItem::device) {
+ if (OpenDeviceData* p = DNew OpenDeviceData()) {
+ POSITION pos = pli->m_fns.GetHeadPosition();
+ for (int i = 0; i < _countof(p->DisplayName) && pos; i++) {
+ p->DisplayName[i] = pli->m_fns.GetNext(pos);
+ }
+ p->vinput = pli->m_vinput;
+ p->vchannel = pli->m_vchannel;
+ p->ainput = pli->m_ainput;
+ return p;
+ }
+ } else {
+ if (OpenFileData* p = DNew OpenFileData()) {
+ p->fns.AddTailList(&pli->m_fns);
+ p->subs.AddTailList(&pli->m_subs);
+ p->rtStart = rtStart;
+ return p;
+ }
+ }
+
+ return NULL;
}
bool CPlayerPlaylistBar::SelectFileInPlaylist(LPCTSTR filename)
{
- if (!filename) {
- return false;
- }
- POSITION pos = m_pl.GetHeadPosition();
- while (pos) {
- CPlaylistItem& pli = m_pl.GetAt(pos);
- if (pli.FindFile(filename)) {
- m_pl.SetPos(pos);
- EnsureVisible(pos);
- return true;
- }
- m_pl.GetNext(pos);
- }
- return false;
+ if (!filename) {
+ return false;
+ }
+ POSITION pos = m_pl.GetHeadPosition();
+ while (pos) {
+ CPlaylistItem& pli = m_pl.GetAt(pos);
+ if (pli.FindFile(filename)) {
+ m_pl.SetPos(pos);
+ EnsureVisible(pos);
+ return true;
+ }
+ m_pl.GetNext(pos);
+ }
+ return false;
}
void CPlayerPlaylistBar::LoadPlaylist(LPCTSTR filename)
{
- CString base;
+ CString base;
- if (AfxGetMyApp()->GetAppSavePath(base)) {
- CPath p;
- p.Combine(base, _T("default.mpcpl"));
+ if (AfxGetMyApp()->GetAppSavePath(base)) {
+ CPath p;
+ p.Combine(base, _T("default.mpcpl"));
- if (p.FileExists()) {
- if (AfxGetAppSettings().bRememberPlaylistItems) {
- ParseMPCPlayList(p);
- Refresh();
- SelectFileInPlaylist(filename);
- } else {
- ::DeleteFile(p);
- }
- }
- }
+ if (p.FileExists()) {
+ if (AfxGetAppSettings().bRememberPlaylistItems) {
+ ParseMPCPlayList(p);
+ Refresh();
+ SelectFileInPlaylist(filename);
+ } else {
+ ::DeleteFile(p);
+ }
+ }
+ }
}
void CPlayerPlaylistBar::SavePlaylist()
{
- CString base;
+ CString base;
- if (AfxGetMyApp()->GetAppSavePath(base)) {
- CPath p;
- p.Combine(base, _T("default.mpcpl"));
+ if (AfxGetMyApp()->GetAppSavePath(base)) {
+ CPath p;
+ p.Combine(base, _T("default.mpcpl"));
- if (AfxGetAppSettings().bRememberPlaylistItems) {
- // Only create this folder when needed
- if (!::PathFileExists(base)) {
- ::CreateDirectory(base, NULL);
- }
+ if (AfxGetAppSettings().bRememberPlaylistItems) {
+ // Only create this folder when needed
+ if (!::PathFileExists(base)) {
+ ::CreateDirectory(base, NULL);
+ }
- SaveMPCPlayList(p, CTextFile::UTF8, false);
- } else if (p.FileExists()) {
- ::DeleteFile(p);
- }
- }
+ SaveMPCPlayList(p, CTextFile::UTF8, false);
+ } else if (p.FileExists()) {
+ ::DeleteFile(p);
+ }
+ }
}
BEGIN_MESSAGE_MAP(CPlayerPlaylistBar, CSizingControlBarG)
- ON_WM_SIZE()
- ON_NOTIFY(LVN_KEYDOWN, IDC_PLAYLIST, OnLvnKeyDown)
- ON_NOTIFY(NM_DBLCLK, IDC_PLAYLIST, OnNMDblclkList)
- //ON_NOTIFY(NM_CUSTOMDRAW, IDC_PLAYLIST, OnCustomdrawList)
- ON_WM_DRAWITEM()
- ON_COMMAND_EX(ID_PLAY_PLAY, OnPlayPlay)
- ON_WM_DROPFILES()
- ON_NOTIFY(LVN_BEGINDRAG, IDC_PLAYLIST, OnBeginDrag)
- ON_WM_MOUSEMOVE()
- ON_WM_LBUTTONUP()
- ON_NOTIFY_EX_RANGE(TTN_NEEDTEXT, 0, 0xFFFF, OnToolTipNotify)
- ON_WM_TIMER()
- ON_WM_CONTEXTMENU()
- ON_NOTIFY(LVN_ENDLABELEDIT, IDC_PLAYLIST, OnLvnEndlabeleditList)
+ ON_WM_SIZE()
+ ON_NOTIFY(LVN_KEYDOWN, IDC_PLAYLIST, OnLvnKeyDown)
+ ON_NOTIFY(NM_DBLCLK, IDC_PLAYLIST, OnNMDblclkList)
+ //ON_NOTIFY(NM_CUSTOMDRAW, IDC_PLAYLIST, OnCustomdrawList)
+ ON_WM_DRAWITEM()
+ ON_COMMAND_EX(ID_PLAY_PLAY, OnPlayPlay)
+ ON_WM_DROPFILES()
+ ON_NOTIFY(LVN_BEGINDRAG, IDC_PLAYLIST, OnBeginDrag)
+ ON_WM_MOUSEMOVE()
+ ON_WM_LBUTTONUP()
+ ON_NOTIFY_EX_RANGE(TTN_NEEDTEXT, 0, 0xFFFF, OnToolTipNotify)
+ ON_WM_TIMER()
+ ON_WM_CONTEXTMENU()
+ ON_NOTIFY(LVN_ENDLABELEDIT, IDC_PLAYLIST, OnLvnEndlabeleditList)
END_MESSAGE_MAP()
@@ -864,697 +864,697 @@ END_MESSAGE_MAP()
void CPlayerPlaylistBar::ResizeListColumn()
{
- if (::IsWindow(m_list.m_hWnd)) {
- CRect r;
- GetClientRect(r);
- r.DeflateRect(2, 2);
- m_list.SetRedraw(FALSE);
- m_list.MoveWindow(r);
- m_list.GetClientRect(r);
- m_list.SetColumnWidth(COL_NAME, r.Width()-m_nTimeColWidth); //LVSCW_AUTOSIZE_USEHEADER
- m_list.SetRedraw(TRUE);
- }
+ if (::IsWindow(m_list.m_hWnd)) {
+ CRect r;
+ GetClientRect(r);
+ r.DeflateRect(2, 2);
+ m_list.SetRedraw(FALSE);
+ m_list.MoveWindow(r);
+ m_list.GetClientRect(r);
+ m_list.SetColumnWidth(COL_NAME, r.Width() - m_nTimeColWidth); //LVSCW_AUTOSIZE_USEHEADER
+ m_list.SetRedraw(TRUE);
+ }
}
void CPlayerPlaylistBar::OnSize(UINT nType, int cx, int cy)
{
- CSizingControlBarG::OnSize(nType, cx, cy);
+ CSizingControlBarG::OnSize(nType, cx, cy);
- ResizeListColumn();
+ ResizeListColumn();
}
void CPlayerPlaylistBar::OnLvnKeyDown(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMLVKEYDOWN pLVKeyDown = reinterpret_cast<LPNMLVKEYDOWN>(pNMHDR);
+ LPNMLVKEYDOWN pLVKeyDown = reinterpret_cast<LPNMLVKEYDOWN>(pNMHDR);
- *pResult = FALSE;
+ *pResult = FALSE;
- CList<int> items;
- POSITION pos = m_list.GetFirstSelectedItemPosition();
- while (pos) {
- items.AddHead(m_list.GetNextSelectedItem(pos));
- }
+ CList<int> items;
+ POSITION pos = m_list.GetFirstSelectedItemPosition();
+ while (pos) {
+ items.AddHead(m_list.GetNextSelectedItem(pos));
+ }
- if (pLVKeyDown->wVKey == VK_DELETE && items.GetCount() > 0) {
- pos = items.GetHeadPosition();
- while (pos) {
- int i = items.GetNext(pos);
- if (m_pl.RemoveAt(FindPos(i))) {
- ((CMainFrame*)AfxGetMainWnd())->CloseMedia();
- }
- m_list.DeleteItem(i);
- }
+ if (pLVKeyDown->wVKey == VK_DELETE && items.GetCount() > 0) {
+ pos = items.GetHeadPosition();
+ while (pos) {
+ int i = items.GetNext(pos);
+ if (m_pl.RemoveAt(FindPos(i))) {
+ ((CMainFrame*)AfxGetMainWnd())->CloseMedia();
+ }
+ m_list.DeleteItem(i);
+ }
- m_list.SetItemState(-1, 0, LVIS_SELECTED);
- m_list.SetItemState(
- max(min(items.GetTail(), m_list.GetItemCount()-1), 0),
- LVIS_SELECTED, LVIS_SELECTED);
+ m_list.SetItemState(-1, 0, LVIS_SELECTED);
+ m_list.SetItemState(
+ max(min(items.GetTail(), m_list.GetItemCount() - 1), 0),
+ LVIS_SELECTED, LVIS_SELECTED);
- ResizeListColumn();
+ ResizeListColumn();
- *pResult = TRUE;
- } else if (pLVKeyDown->wVKey == VK_SPACE && items.GetCount() == 1) {
- m_pl.SetPos(FindPos(items.GetHead()));
+ *pResult = TRUE;
+ } else if (pLVKeyDown->wVKey == VK_SPACE && items.GetCount() == 1) {
+ m_pl.SetPos(FindPos(items.GetHead()));
- ((CMainFrame*)AfxGetMainWnd())->OpenCurPlaylistItem();
+ ((CMainFrame*)AfxGetMainWnd())->OpenCurPlaylistItem();
- AfxGetMainWnd()->SetFocus();
+ AfxGetMainWnd()->SetFocus();
- *pResult = TRUE;
- }
+ *pResult = TRUE;
+ }
}
void CPlayerPlaylistBar::OnNMDblclkList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
+ LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
- if (lpnmlv->iItem >= 0 && lpnmlv->iSubItem >= 0) {
- AppSettings& s = AfxGetAppSettings();
- FILE_POSITION* FilePosition = s.CurrentFilePosition();
- if (FilePosition) {
- FilePosition->llPosition = 0;
- }
+ if (lpnmlv->iItem >= 0 && lpnmlv->iSubItem >= 0) {
+ AppSettings& s = AfxGetAppSettings();
+ FILE_POSITION* FilePosition = s.CurrentFilePosition();
+ if (FilePosition) {
+ FilePosition->llPosition = 0;
+ }
- m_pl.SetPos(FindPos(lpnmlv->iItem));
- m_list.Invalidate();
- ((CMainFrame*)AfxGetMainWnd())->OpenCurPlaylistItem();
- }
+ m_pl.SetPos(FindPos(lpnmlv->iItem));
+ m_list.Invalidate();
+ ((CMainFrame*)AfxGetMainWnd())->OpenCurPlaylistItem();
+ }
- AfxGetMainWnd()->SetFocus();
+ AfxGetMainWnd()->SetFocus();
- *pResult = 0;
+ *pResult = 0;
}
/*
void CPlayerPlaylistBar::OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult)
{
- NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
-
- *pResult = CDRF_DODEFAULT;
-
- if (CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage)
- {
- *pResult = CDRF_NOTIFYPOSTPAINT|CDRF_NOTIFYITEMDRAW;
- }
- else if (CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage)
- {
- pLVCD->nmcd.uItemState &= ~CDIS_SELECTED;
- pLVCD->nmcd.uItemState &= ~CDIS_FOCUS;
-
- pLVCD->clrText = (pLVCD->nmcd.dwItemSpec == m_playList.m_idx) ? 0x0000ff : CLR_DEFAULT;
- pLVCD->clrTextBk = m_list.GetItemState(pLVCD->nmcd.dwItemSpec, LVIS_SELECTED) ? 0xf1dacc : CLR_DEFAULT;
-
- *pResult = CDRF_NOTIFYPOSTPAINT;
- }
- else if (CDDS_ITEMPOSTPAINT == pLVCD->nmcd.dwDrawStage)
- {
- int nItem = static_cast<int>(pLVCD->nmcd.dwItemSpec);
-
- if (m_list.GetItemState(pLVCD->nmcd.dwItemSpec, LVIS_SELECTED))
- {
- CRect r, r2;
- m_list.GetItemRect(nItem, &r, LVIR_BOUNDS);
- m_list.GetItemRect(nItem, &r2, LVIR_LABEL);
- r.left = r2.left;
- FrameRect(pLVCD->nmcd.hdc, &r, CBrush(0xc56a31));
- }
-
- *pResult = CDRF_SKIPDEFAULT;
- }
- else if (CDDS_POSTPAINT == pLVCD->nmcd.dwDrawStage)
- {
- }
+ NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
+
+ *pResult = CDRF_DODEFAULT;
+
+ if (CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage)
+ {
+ *pResult = CDRF_NOTIFYPOSTPAINT|CDRF_NOTIFYITEMDRAW;
+ }
+ else if (CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage)
+ {
+ pLVCD->nmcd.uItemState &= ~CDIS_SELECTED;
+ pLVCD->nmcd.uItemState &= ~CDIS_FOCUS;
+
+ pLVCD->clrText = (pLVCD->nmcd.dwItemSpec == m_playList.m_idx) ? 0x0000ff : CLR_DEFAULT;
+ pLVCD->clrTextBk = m_list.GetItemState(pLVCD->nmcd.dwItemSpec, LVIS_SELECTED) ? 0xf1dacc : CLR_DEFAULT;
+
+ *pResult = CDRF_NOTIFYPOSTPAINT;
+ }
+ else if (CDDS_ITEMPOSTPAINT == pLVCD->nmcd.dwDrawStage)
+ {
+ int nItem = static_cast<int>(pLVCD->nmcd.dwItemSpec);
+
+ if (m_list.GetItemState(pLVCD->nmcd.dwItemSpec, LVIS_SELECTED))
+ {
+ CRect r, r2;
+ m_list.GetItemRect(nItem, &r, LVIR_BOUNDS);
+ m_list.GetItemRect(nItem, &r2, LVIR_LABEL);
+ r.left = r2.left;
+ FrameRect(pLVCD->nmcd.hdc, &r, CBrush(0xc56a31));
+ }
+
+ *pResult = CDRF_SKIPDEFAULT;
+ }
+ else if (CDDS_POSTPAINT == pLVCD->nmcd.dwDrawStage)
+ {
+ }
}
*/
void CPlayerPlaylistBar::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
- if (nIDCtl != IDC_PLAYLIST) {
- return;
- }
-
- int nItem = lpDrawItemStruct->itemID;
- CRect rcItem = lpDrawItemStruct->rcItem;
- POSITION pos = FindPos(nItem);
- bool fSelected = pos == m_pl.GetPos();
- CPlaylistItem& pli = m_pl.GetAt(pos);
-
- CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
-
- if (!!m_list.GetItemState(nItem, LVIS_SELECTED)) {
- FillRect(pDC->m_hDC, rcItem, CBrush(0xf1dacc));
- FrameRect(pDC->m_hDC, rcItem, CBrush(0xc56a31));
- } else {
- FillRect(pDC->m_hDC, rcItem, CBrush(GetSysColor(COLOR_WINDOW)));
- }
-
- COLORREF textcolor = fSelected?0xff:0;
- if (pli.m_fInvalid) {
- textcolor |= 0xA0A0A0;
- }
-
- CString time = !pli.m_fInvalid ? m_list.GetItemText(nItem, COL_TIME) : _T("Invalid");
- CSize timesize(0, 0);
- CPoint timept(rcItem.right, 0);
- if (time.GetLength() > 0) {
- timesize = pDC->GetTextExtent(time);
- if ((3+timesize.cx+3) < rcItem.Width()/2) {
- timept = CPoint(rcItem.right-(3+timesize.cx+3), (rcItem.top+rcItem.bottom-timesize.cy)/2);
-
- pDC->SetTextColor(textcolor);
- pDC->TextOut(timept.x, timept.y, time);
- }
- }
-
- CString fmt, file;
- fmt.Format(_T("%%0%dd. %%s"), (int)log10(0.1+m_pl.GetCount())+1);
- file.Format(fmt, nItem+1, m_list.GetItemText(nItem, COL_NAME));
- CSize filesize = pDC->GetTextExtent(file);
- while (3+filesize.cx+6 > timept.x && file.GetLength() > 3) {
- file = file.Left(file.GetLength()-4) + _T("...");
- filesize = pDC->GetTextExtent(file);
- }
-
- if (file.GetLength() > 3) {
- pDC->SetTextColor(textcolor);
- pDC->TextOut(rcItem.left+3, (rcItem.top+rcItem.bottom-filesize.cy)/2, file);
- }
+ if (nIDCtl != IDC_PLAYLIST) {
+ return;
+ }
+
+ int nItem = lpDrawItemStruct->itemID;
+ CRect rcItem = lpDrawItemStruct->rcItem;
+ POSITION pos = FindPos(nItem);
+ bool fSelected = pos == m_pl.GetPos();
+ CPlaylistItem& pli = m_pl.GetAt(pos);
+
+ CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
+
+ if (!!m_list.GetItemState(nItem, LVIS_SELECTED)) {
+ FillRect(pDC->m_hDC, rcItem, CBrush(0xf1dacc));
+ FrameRect(pDC->m_hDC, rcItem, CBrush(0xc56a31));
+ } else {
+ FillRect(pDC->m_hDC, rcItem, CBrush(GetSysColor(COLOR_WINDOW)));
+ }
+
+ COLORREF textcolor = fSelected ? 0xff : 0;
+ if (pli.m_fInvalid) {
+ textcolor |= 0xA0A0A0;
+ }
+
+ CString time = !pli.m_fInvalid ? m_list.GetItemText(nItem, COL_TIME) : _T("Invalid");
+ CSize timesize(0, 0);
+ CPoint timept(rcItem.right, 0);
+ if (time.GetLength() > 0) {
+ timesize = pDC->GetTextExtent(time);
+ if ((3 + timesize.cx + 3) < rcItem.Width() / 2) {
+ timept = CPoint(rcItem.right - (3 + timesize.cx + 3), (rcItem.top + rcItem.bottom - timesize.cy) / 2);
+
+ pDC->SetTextColor(textcolor);
+ pDC->TextOut(timept.x, timept.y, time);
+ }
+ }
+
+ CString fmt, file;
+ fmt.Format(_T("%%0%dd. %%s"), (int)log10(0.1 + m_pl.GetCount()) + 1);
+ file.Format(fmt, nItem + 1, m_list.GetItemText(nItem, COL_NAME));
+ CSize filesize = pDC->GetTextExtent(file);
+ while (3 + filesize.cx + 6 > timept.x && file.GetLength() > 3) {
+ file = file.Left(file.GetLength() - 4) + _T("...");
+ filesize = pDC->GetTextExtent(file);
+ }
+
+ if (file.GetLength() > 3) {
+ pDC->SetTextColor(textcolor);
+ pDC->TextOut(rcItem.left + 3, (rcItem.top + rcItem.bottom - filesize.cy) / 2, file);
+ }
}
BOOL CPlayerPlaylistBar::OnPlayPlay(UINT nID)
{
- m_list.Invalidate();
- return FALSE;
+ m_list.Invalidate();
+ return FALSE;
}
void CPlayerPlaylistBar::OnDropFiles(HDROP hDropInfo)
{
- SetActiveWindow();
+ SetActiveWindow();
- CAtlList<CString> sl;
+ CAtlList<CString> sl;
- UINT nFiles = ::DragQueryFile(hDropInfo, (UINT)-1, NULL, 0);
- for (UINT iFile = 0; iFile < nFiles; iFile++) {
- TCHAR szFileName[_MAX_PATH];
- ::DragQueryFile(hDropInfo, iFile, szFileName, _MAX_PATH);
- sl.AddTail(szFileName);
- }
- ::DragFinish(hDropInfo);
+ UINT nFiles = ::DragQueryFile(hDropInfo, (UINT) - 1, NULL, 0);
+ for (UINT iFile = 0; iFile < nFiles; iFile++) {
+ TCHAR szFileName[_MAX_PATH];
+ ::DragQueryFile(hDropInfo, iFile, szFileName, _MAX_PATH);
+ sl.AddTail(szFileName);
+ }
+ ::DragFinish(hDropInfo);
- Append(sl, true);
+ Append(sl, true);
}
void CPlayerPlaylistBar::OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult)
{
- ModifyStyle(WS_EX_ACCEPTFILES, 0);
+ ModifyStyle(WS_EX_ACCEPTFILES, 0);
- m_nDragIndex = ((LPNMLISTVIEW)pNMHDR)->iItem;
+ m_nDragIndex = ((LPNMLISTVIEW)pNMHDR)->iItem;
- CPoint p(0, 0);
- m_pDragImage = m_list.CreateDragImageEx(&p);
+ CPoint p(0, 0);
+ m_pDragImage = m_list.CreateDragImageEx(&p);
- CPoint p2 = ((LPNMLISTVIEW)pNMHDR)->ptAction;
+ CPoint p2 = ((LPNMLISTVIEW)pNMHDR)->ptAction;
- m_pDragImage->BeginDrag(0, p2 - p);
- m_pDragImage->DragEnter(GetDesktopWindow(), ((LPNMLISTVIEW)pNMHDR)->ptAction);
+ m_pDragImage->BeginDrag(0, p2 - p);
+ m_pDragImage->DragEnter(GetDesktopWindow(), ((LPNMLISTVIEW)pNMHDR)->ptAction);
- m_bDragging = TRUE;
- m_nDropIndex = -1;
+ m_bDragging = TRUE;
+ m_nDropIndex = -1;
- SetCapture();
+ SetCapture();
}
void CPlayerPlaylistBar::OnMouseMove(UINT nFlags, CPoint point)
{
- if (m_bDragging) {
- m_ptDropPoint = point;
- ClientToScreen(&m_ptDropPoint);
+ if (m_bDragging) {
+ m_ptDropPoint = point;
+ ClientToScreen(&m_ptDropPoint);
- m_pDragImage->DragMove(m_ptDropPoint);
- m_pDragImage->DragShowNolock(FALSE);
+ m_pDragImage->DragMove(m_ptDropPoint);
+ m_pDragImage->DragShowNolock(FALSE);
- WindowFromPoint(m_ptDropPoint)->ScreenToClient(&m_ptDropPoint);
+ WindowFromPoint(m_ptDropPoint)->ScreenToClient(&m_ptDropPoint);
- m_pDragImage->DragShowNolock(TRUE);
+ m_pDragImage->DragShowNolock(TRUE);
- {
- int iOverItem = m_list.HitTest(m_ptDropPoint);
- int iTopItem = m_list.GetTopIndex();
- int iBottomItem = m_list.GetBottomIndex();
+ {
+ int iOverItem = m_list.HitTest(m_ptDropPoint);
+ int iTopItem = m_list.GetTopIndex();
+ int iBottomItem = m_list.GetBottomIndex();
- if (iOverItem == iTopItem && iTopItem != 0) { // top of list
- SetTimer(1, 100, NULL);
- } else {
- KillTimer(1);
- }
+ if (iOverItem == iTopItem && iTopItem != 0) { // top of list
+ SetTimer(1, 100, NULL);
+ } else {
+ KillTimer(1);
+ }
- if (iOverItem >= iBottomItem && iBottomItem != (m_list.GetItemCount() - 1)) { // bottom of list
- SetTimer(2, 100, NULL);
- } else {
- KillTimer(2);
- }
- }
- }
+ if (iOverItem >= iBottomItem && iBottomItem != (m_list.GetItemCount() - 1)) { // bottom of list
+ SetTimer(2, 100, NULL);
+ } else {
+ KillTimer(2);
+ }
+ }
+ }
- __super::OnMouseMove(nFlags, point);
+ __super::OnMouseMove(nFlags, point);
}
void CPlayerPlaylistBar::OnTimer(UINT_PTR nIDEvent)
{
- int iTopItem = m_list.GetTopIndex();
- int iBottomItem = iTopItem + m_list.GetCountPerPage() - 1;
+ int iTopItem = m_list.GetTopIndex();
+ int iBottomItem = iTopItem + m_list.GetCountPerPage() - 1;
- if (m_bDragging) {
- m_pDragImage->DragShowNolock(FALSE);
+ if (m_bDragging) {
+ m_pDragImage->DragShowNolock(FALSE);
- if (nIDEvent == 1) {
- m_list.EnsureVisible(iTopItem - 1, false);
- m_list.UpdateWindow();
- if (m_list.GetTopIndex() == 0) {
- KillTimer(1);
- }
- } else if (nIDEvent == 2) {
- m_list.EnsureVisible(iBottomItem + 1, false);
- m_list.UpdateWindow();
- if (m_list.GetBottomIndex() == (m_list.GetItemCount() - 1)) {
- KillTimer(2);
- }
- }
+ if (nIDEvent == 1) {
+ m_list.EnsureVisible(iTopItem - 1, false);
+ m_list.UpdateWindow();
+ if (m_list.GetTopIndex() == 0) {
+ KillTimer(1);
+ }
+ } else if (nIDEvent == 2) {
+ m_list.EnsureVisible(iBottomItem + 1, false);
+ m_list.UpdateWindow();
+ if (m_list.GetBottomIndex() == (m_list.GetItemCount() - 1)) {
+ KillTimer(2);
+ }
+ }
- m_pDragImage->DragShowNolock(TRUE);
- }
+ m_pDragImage->DragShowNolock(TRUE);
+ }
- __super::OnTimer(nIDEvent);
+ __super::OnTimer(nIDEvent);
}
void CPlayerPlaylistBar::OnLButtonUp(UINT nFlags, CPoint point)
{
- if (m_bDragging) {
- ::ReleaseCapture();
+ if (m_bDragging) {
+ ::ReleaseCapture();
- m_bDragging = FALSE;
- m_pDragImage->DragLeave(GetDesktopWindow());
- m_pDragImage->EndDrag();
+ m_bDragging = FALSE;
+ m_pDragImage->DragLeave(GetDesktopWindow());
+ m_pDragImage->EndDrag();
- delete m_pDragImage;
- m_pDragImage = NULL;
+ delete m_pDragImage;
+ m_pDragImage = NULL;
- KillTimer(1);
- KillTimer(2);
+ KillTimer(1);
+ KillTimer(2);
- CPoint pt(point);
- ClientToScreen(&pt);
+ CPoint pt(point);
+ ClientToScreen(&pt);
- if (WindowFromPoint(pt) == &m_list) {
- DropItemOnList();
- }
- }
+ if (WindowFromPoint(pt) == &m_list) {
+ DropItemOnList();
+ }
+ }
- ModifyStyle(0, WS_EX_ACCEPTFILES);
+ ModifyStyle(0, WS_EX_ACCEPTFILES);
- __super::OnLButtonUp(nFlags, point);
+ __super::OnLButtonUp(nFlags, point);
}
void CPlayerPlaylistBar::DropItemOnList()
{
- m_ptDropPoint.y += 10;
- m_nDropIndex = m_list.HitTest(CPoint(10, m_ptDropPoint.y));
-
- TCHAR szLabel[_MAX_PATH];
- LV_ITEM lvi;
- ZeroMemory(&lvi, sizeof(LV_ITEM));
- lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE | LVIF_PARAM;
- lvi.stateMask = LVIS_DROPHILITED | LVIS_FOCUSED | LVIS_SELECTED;
- lvi.pszText = szLabel;
- lvi.iItem = m_nDragIndex;
- lvi.cchTextMax = _MAX_PATH;
- m_list.GetItem(&lvi);
-
- if (m_nDropIndex < 0) {
- m_nDropIndex = m_list.GetItemCount();
- }
- lvi.iItem = m_nDropIndex;
- m_list.InsertItem(&lvi);
-
- CHeaderCtrl* pHeader = (CHeaderCtrl*)m_list.GetDlgItem(0);
- int nColumnCount = pHeader->GetItemCount();
- lvi.mask = LVIF_TEXT;
- lvi.iItem = m_nDropIndex;
- //INDEX OF DRAGGED ITEM WILL CHANGE IF ITEM IS DROPPED ABOVE ITSELF
- if (m_nDropIndex < m_nDragIndex) {
- m_nDragIndex++;
- }
- for (int col=1; col < nColumnCount; col++) {
- _tcscpy_s(lvi.pszText, _MAX_PATH, (LPCTSTR)(m_list.GetItemText(m_nDragIndex, col)));
- lvi.iSubItem = col;
- m_list.SetItem(&lvi);
- }
-
- m_list.DeleteItem(m_nDragIndex);
-
- CList<CPlaylistItem> tmp;
- UINT id = (UINT)-1;
- for (int i = 0; i < m_list.GetItemCount(); i++) {
- POSITION pos = (POSITION)m_list.GetItemData(i);
- CPlaylistItem& pli = m_pl.GetAt(pos);
- tmp.AddTail(pli);
- if (pos == m_pl.GetPos()) {
- id = pli.m_id;
- }
- }
- m_pl.RemoveAll();
- POSITION pos = tmp.GetHeadPosition();
- for (int i = 0; pos; i++) {
- CPlaylistItem& pli = tmp.GetNext(pos);
- m_pl.AddTail(pli);
- if (pli.m_id == id) {
- m_pl.SetPos(m_pl.GetTailPosition());
- }
- m_list.SetItemData(i, (DWORD_PTR)m_pl.GetTailPosition());
- }
-
- ResizeListColumn();
+ m_ptDropPoint.y += 10;
+ m_nDropIndex = m_list.HitTest(CPoint(10, m_ptDropPoint.y));
+
+ TCHAR szLabel[_MAX_PATH];
+ LV_ITEM lvi;
+ ZeroMemory(&lvi, sizeof(LV_ITEM));
+ lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE | LVIF_PARAM;
+ lvi.stateMask = LVIS_DROPHILITED | LVIS_FOCUSED | LVIS_SELECTED;
+ lvi.pszText = szLabel;
+ lvi.iItem = m_nDragIndex;
+ lvi.cchTextMax = _MAX_PATH;
+ m_list.GetItem(&lvi);
+
+ if (m_nDropIndex < 0) {
+ m_nDropIndex = m_list.GetItemCount();
+ }
+ lvi.iItem = m_nDropIndex;
+ m_list.InsertItem(&lvi);
+
+ CHeaderCtrl* pHeader = (CHeaderCtrl*)m_list.GetDlgItem(0);
+ int nColumnCount = pHeader->GetItemCount();
+ lvi.mask = LVIF_TEXT;
+ lvi.iItem = m_nDropIndex;
+ //INDEX OF DRAGGED ITEM WILL CHANGE IF ITEM IS DROPPED ABOVE ITSELF
+ if (m_nDropIndex < m_nDragIndex) {
+ m_nDragIndex++;
+ }
+ for (int col = 1; col < nColumnCount; col++) {
+ _tcscpy_s(lvi.pszText, _MAX_PATH, (LPCTSTR)(m_list.GetItemText(m_nDragIndex, col)));
+ lvi.iSubItem = col;
+ m_list.SetItem(&lvi);
+ }
+
+ m_list.DeleteItem(m_nDragIndex);
+
+ CList<CPlaylistItem> tmp;
+ UINT id = (UINT) - 1;
+ for (int i = 0; i < m_list.GetItemCount(); i++) {
+ POSITION pos = (POSITION)m_list.GetItemData(i);
+ CPlaylistItem& pli = m_pl.GetAt(pos);
+ tmp.AddTail(pli);
+ if (pos == m_pl.GetPos()) {
+ id = pli.m_id;
+ }
+ }
+ m_pl.RemoveAll();
+ POSITION pos = tmp.GetHeadPosition();
+ for (int i = 0; pos; i++) {
+ CPlaylistItem& pli = tmp.GetNext(pos);
+ m_pl.AddTail(pli);
+ if (pli.m_id == id) {
+ m_pl.SetPos(m_pl.GetTailPosition());
+ }
+ m_list.SetItemData(i, (DWORD_PTR)m_pl.GetTailPosition());
+ }
+
+ ResizeListColumn();
}
BOOL CPlayerPlaylistBar::OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
{
- TOOLTIPTEXT* pTTT = (TOOLTIPTEXT*)pNMHDR;
+ TOOLTIPTEXT* pTTT = (TOOLTIPTEXT*)pNMHDR;
- if ((HWND)pTTT->lParam != m_list.m_hWnd) {
- return FALSE;
- }
+ if ((HWND)pTTT->lParam != m_list.m_hWnd) {
+ return FALSE;
+ }
- int row = ((pNMHDR->idFrom-1) >> 10) & 0x3fffff;
- int col = (pNMHDR->idFrom-1) & 0x3ff;
+ int row = ((pNMHDR->idFrom - 1) >> 10) & 0x3fffff;
+ int col = (pNMHDR->idFrom - 1) & 0x3ff;
- if (row < 0 || row >= m_pl.GetCount()) {
- return FALSE;
- }
+ if (row < 0 || row >= m_pl.GetCount()) {
+ return FALSE;
+ }
- CPlaylistItem& pli = m_pl.GetAt(FindPos(row));
+ CPlaylistItem& pli = m_pl.GetAt(FindPos(row));
- static CString strTipText; // static string
- strTipText.Empty();
+ static CString strTipText; // static string
+ strTipText.Empty();
- if (col == COL_NAME) {
- POSITION pos = pli.m_fns.GetHeadPosition();
- while (pos) {
- strTipText += _T("\n") + pli.m_fns.GetNext(pos);
- }
- strTipText.Trim();
+ if (col == COL_NAME) {
+ POSITION pos = pli.m_fns.GetHeadPosition();
+ while (pos) {
+ strTipText += _T("\n") + pli.m_fns.GetNext(pos);
+ }
+ strTipText.Trim();
- if (pli.m_type == CPlaylistItem::device) {
- if (pli.m_vinput >= 0) {
- strTipText.AppendFormat(_T("\nVideo Input %d"), pli.m_vinput);
- }
- if (pli.m_vchannel >= 0) {
- strTipText.AppendFormat(_T("\nVideo Channel %d"), pli.m_vchannel);
- }
- if (pli.m_ainput >= 0) {
- strTipText.AppendFormat(_T("\nAudio Input %d"), pli.m_ainput);
- }
- }
+ if (pli.m_type == CPlaylistItem::device) {
+ if (pli.m_vinput >= 0) {
+ strTipText.AppendFormat(_T("\nVideo Input %d"), pli.m_vinput);
+ }
+ if (pli.m_vchannel >= 0) {
+ strTipText.AppendFormat(_T("\nVideo Channel %d"), pli.m_vchannel);
+ }
+ if (pli.m_ainput >= 0) {
+ strTipText.AppendFormat(_T("\nAudio Input %d"), pli.m_ainput);
+ }
+ }
- ::SendMessage(pNMHDR->hwndFrom, TTM_SETMAXTIPWIDTH, 0, (LPARAM)(INT)1000);
- } else if (col == COL_TIME) {
- return FALSE;
- }
+ ::SendMessage(pNMHDR->hwndFrom, TTM_SETMAXTIPWIDTH, 0, (LPARAM)(INT)1000);
+ } else if (col == COL_TIME) {
+ return FALSE;
+ }
- pTTT->lpszText = (LPWSTR)(LPCWSTR)strTipText;
+ pTTT->lpszText = (LPWSTR)(LPCWSTR)strTipText;
- *pResult = 0;
+ *pResult = 0;
- return TRUE; // message was handled
+ return TRUE; // message was handled
}
void CPlayerPlaylistBar::OnContextMenu(CWnd* /*pWnd*/, CPoint p)
{
- LVHITTESTINFO lvhti;
- lvhti.pt = p;
- m_list.ScreenToClient(&lvhti.pt);
- m_list.SubItemHitTest(&lvhti);
-
- POSITION pos = FindPos(lvhti.iItem);
- //bool fSelected = (pos == m_pl.GetPos());
- bool fOnItem = !!(lvhti.flags&LVHT_ONITEM);
-
- CMenu m;
- m.CreatePopupMenu();
-
- enum {
- M_OPEN=1, M_ADD, M_REMOVE, M_CLEAR, M_CLIPBOARD, M_SAVEAS,
- M_SORTBYNAME, M_SORTBYPATH, M_RANDOMIZE, M_SORTBYID,
- M_REMEMBERPLAYLIST, M_SHUFFLE, M_HIDEFULLSCREEN
- };
-
- AppSettings& s = AfxGetAppSettings();
-
- m.AppendMenu(MF_STRING|(!fOnItem?(MF_DISABLED|MF_GRAYED):MF_ENABLED), M_OPEN, ResStr(IDS_PLAYLIST_OPEN));
- if (((CMainFrame*)AfxGetMainWnd())->GetPlaybackMode() == PM_CAPTURE) {
- m.AppendMenu(MF_STRING|MF_ENABLED, M_ADD, ResStr(IDS_PLAYLIST_ADD));
- }
- m.AppendMenu(MF_STRING|(/*fSelected||*/!fOnItem?(MF_DISABLED|MF_GRAYED):MF_ENABLED), M_REMOVE, ResStr(IDS_PLAYLIST_REMOVE));
- m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING|(!m_pl.GetCount()?(MF_DISABLED|MF_GRAYED):MF_ENABLED), M_CLEAR, ResStr(IDS_PLAYLIST_CLEAR));
- m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING|(!fOnItem?(MF_DISABLED|MF_GRAYED):MF_ENABLED), M_CLIPBOARD, ResStr(IDS_PLAYLIST_COPYTOCLIPBOARD));
- m.AppendMenu(MF_STRING|(!m_pl.GetCount()?(MF_DISABLED|MF_GRAYED):MF_ENABLED), M_SAVEAS, ResStr(IDS_PLAYLIST_SAVEAS));
- m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING|(!m_pl.GetCount()?(MF_DISABLED|MF_GRAYED):MF_ENABLED), M_SORTBYNAME, ResStr(IDS_PLAYLIST_SORTBYLABEL));
- m.AppendMenu(MF_STRING|(!m_pl.GetCount()?(MF_DISABLED|MF_GRAYED):MF_ENABLED), M_SORTBYPATH, ResStr(IDS_PLAYLIST_SORTBYPATH));
- m.AppendMenu(MF_STRING|(!m_pl.GetCount()?(MF_DISABLED|MF_GRAYED):MF_ENABLED), M_RANDOMIZE, ResStr(IDS_PLAYLIST_RANDOMIZE));
- m.AppendMenu(MF_STRING|(!m_pl.GetCount()?(MF_DISABLED|MF_GRAYED):MF_ENABLED), M_SORTBYID, ResStr(IDS_PLAYLIST_RESTORE));
- m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING|MF_ENABLED|(s.bShufflePlaylistItems?MF_CHECKED:MF_UNCHECKED), M_SHUFFLE, ResStr(IDS_PLAYLIST_SHUFFLE));
- m.AppendMenu(MF_STRING|MF_ENABLED|(s.bRememberPlaylistItems?MF_CHECKED:MF_UNCHECKED), M_REMEMBERPLAYLIST, ResStr(IDS_PLAYLIST_REMEBERITEMS));
- m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING|MF_ENABLED|(s.bHidePlaylistFullScreen?MF_CHECKED:MF_UNCHECKED), M_HIDEFULLSCREEN, ResStr(IDS_PLAYLIST_HIDEFS));
-
- CMainFrame* pMainFrm = (CMainFrame*)AfxGetMainWnd();
-
- int nID = (int)m.TrackPopupMenu(TPM_LEFTBUTTON|TPM_RETURNCMD, p.x, p.y, this);
- switch (nID) {
- case M_OPEN:
- m_pl.SetPos(pos);
- m_list.Invalidate();
- pMainFrm->OpenCurPlaylistItem();
- break;
- case M_ADD:
- pMainFrm->AddCurDevToPlaylist();
- m_pl.SetPos(m_pl.GetTailPosition());
- break;
- case M_REMOVE:
- if (m_pl.RemoveAt(pos)) {
- pMainFrm->CloseMedia();
- }
- m_list.DeleteItem(lvhti.iItem);
- SavePlaylist();
- break;
- case M_CLEAR:
- if (Empty()) {
- pMainFrm->CloseMedia();
- }
- break;
- case M_SORTBYID:
- m_pl.SortById();
- SetupList();
- SavePlaylist();
- break;
- case M_SORTBYNAME:
- m_pl.SortByName();
- SetupList();
- SavePlaylist();
- break;
- case M_SORTBYPATH:
- m_pl.SortByPath();
- SetupList();
- SavePlaylist();
- break;
- case M_RANDOMIZE:
- m_pl.Randomize();
- SetupList();
- SavePlaylist();
- break;
- case M_CLIPBOARD:
- if (OpenClipboard() && EmptyClipboard()) {
- CString str;
-
- CPlaylistItem& pli = m_pl.GetAt(pos);
- POSITION pos = pli.m_fns.GetHeadPosition();
- while (pos) {
- str += _T("\r\n") + pli.m_fns.GetNext(pos);
- }
- str.Trim();
-
- if (HGLOBAL h = GlobalAlloc(GMEM_MOVEABLE, (str.GetLength()+1)*sizeof(TCHAR))) {
- if (TCHAR* s = (TCHAR*)GlobalLock(h)) {
- _tcscpy_s(s, str.GetLength() + 1, str);
- GlobalUnlock(h);
- SetClipboardData(CF_UNICODETEXT, h);
- }
- }
- CloseClipboard();
- }
- break;
- case M_SAVEAS: {
- CSaveTextFileDialog fd(
- CTextFile::ASCII, NULL, NULL,
- _T("Media Player Classic playlist (*.mpcpl)|*.mpcpl|Playlist (*.pls)|*.pls|Winamp playlist (*.m3u)|*.m3u|Windows Media playlist (*.asx)|*.asx||"),
- this);
-
- if (fd.DoModal() != IDOK) {
- break;
- }
-
- CTextFile::enc encoding = (CTextFile::enc)fd.GetEncoding();
- if (encoding == CTextFile::ASCII) {
- encoding = CTextFile::ANSI;
- }
-
- int idx = fd.m_pOFN->nFilterIndex;
-
- CPath path(fd.GetPathName());
-
- switch (idx) {
- case 1:
- path.AddExtension(_T(".mpcpl"));
- break;
- case 2:
- path.AddExtension(_T(".pls"));
- break;
- case 3:
- path.AddExtension(_T(".m3u"));
- break;
- case 4:
- path.AddExtension(_T(".asx"));
- break;
- default:
- break;
- }
-
- bool fRemovePath = true;
-
- CPath p(path);
- p.RemoveFileSpec();
- CString base = (LPCTSTR)p;
-
- pos = m_pl.GetHeadPosition();
- while (pos && fRemovePath) {
- CPlaylistItem& pli = m_pl.GetNext(pos);
-
- if (pli.m_type != CPlaylistItem::file) {
- fRemovePath = false;
- } else {
- POSITION pos;
-
- pos = pli.m_fns.GetHeadPosition();
- while (pos && fRemovePath) {
- CString fn = pli.m_fns.GetNext(pos);
-
- CPath p(fn);
- p.RemoveFileSpec();
- if (base != (LPCTSTR)p) {
- fRemovePath = false;
- }
- }
-
- pos = pli.m_subs.GetHeadPosition();
- while (pos && fRemovePath) {
- CString fn = pli.m_subs.GetNext(pos);
-
- CPath p(fn);
- p.RemoveFileSpec();
- if (base != (LPCTSTR)p) {
- fRemovePath = false;
- }
- }
- }
- }
-
- if (idx == 1) {
- SaveMPCPlayList(path, encoding, fRemovePath);
- break;
- }
-
- CTextFile f;
- if (!f.Save(path, encoding)) {
- break;
- }
-
- if (idx == 2) {
- f.WriteString(_T("[playlist]\n"));
- } else if (idx == 4) {
- f.WriteString(_T("<ASX version = \"3.0\">\n"));
- }
-
- pos = m_pl.GetHeadPosition();
- CString str;
- int i;
- for (i = 0; pos; i++) {
- CPlaylistItem& pli = m_pl.GetNext(pos);
-
- if (pli.m_type != CPlaylistItem::file) {
- continue;
- }
-
- CString fn = pli.m_fns.GetHead();
-
- /*
- if (fRemovePath)
- {
- CPath p(path);
- p.StripPath();
- fn = (LPCTSTR)p;
- }
- */
-
- switch (idx) {
- case 2:
- str.Format(_T("File%d=%s\n"), i+1, fn);
- break;
- case 3:
- str.Format(_T("%s\n"), fn);
- break;
- case 4:
- str.Format(_T("<Entry><Ref href = \"%s\"/></Entry>\n"), fn);
- break;
- default:
- break;
- }
- f.WriteString(str);
- }
-
- if (idx == 2) {
- str.Format(_T("NumberOfEntries=%d\n"), i);
- f.WriteString(str);
- f.WriteString(_T("Version=2\n"));
- } else if (idx == 4) {
- f.WriteString(_T("</ASX>\n"));
- }
- }
- break;
- case M_REMEMBERPLAYLIST:
- s.bRememberPlaylistItems = !s.bRememberPlaylistItems;
- break;
- case M_SHUFFLE:
- s.bShufflePlaylistItems = !s.bShufflePlaylistItems;
- break;
- case M_HIDEFULLSCREEN:
- s.bHidePlaylistFullScreen = !s.bHidePlaylistFullScreen;
- break;
- default:
- break;
- }
+ LVHITTESTINFO lvhti;
+ lvhti.pt = p;
+ m_list.ScreenToClient(&lvhti.pt);
+ m_list.SubItemHitTest(&lvhti);
+
+ POSITION pos = FindPos(lvhti.iItem);
+ //bool fSelected = (pos == m_pl.GetPos());
+ bool fOnItem = !!(lvhti.flags & LVHT_ONITEM);
+
+ CMenu m;
+ m.CreatePopupMenu();
+
+ enum {
+ M_OPEN = 1, M_ADD, M_REMOVE, M_CLEAR, M_CLIPBOARD, M_SAVEAS,
+ M_SORTBYNAME, M_SORTBYPATH, M_RANDOMIZE, M_SORTBYID,
+ M_REMEMBERPLAYLIST, M_SHUFFLE, M_HIDEFULLSCREEN
+ };
+
+ AppSettings& s = AfxGetAppSettings();
+
+ m.AppendMenu(MF_STRING | (!fOnItem ? (MF_DISABLED | MF_GRAYED) : MF_ENABLED), M_OPEN, ResStr(IDS_PLAYLIST_OPEN));
+ if (((CMainFrame*)AfxGetMainWnd())->GetPlaybackMode() == PM_CAPTURE) {
+ m.AppendMenu(MF_STRING | MF_ENABLED, M_ADD, ResStr(IDS_PLAYLIST_ADD));
+ }
+ m.AppendMenu(MF_STRING | (/*fSelected||*/!fOnItem ? (MF_DISABLED | MF_GRAYED) : MF_ENABLED), M_REMOVE, ResStr(IDS_PLAYLIST_REMOVE));
+ m.AppendMenu(MF_SEPARATOR);
+ m.AppendMenu(MF_STRING | (!m_pl.GetCount() ? (MF_DISABLED | MF_GRAYED) : MF_ENABLED), M_CLEAR, ResStr(IDS_PLAYLIST_CLEAR));
+ m.AppendMenu(MF_SEPARATOR);
+ m.AppendMenu(MF_STRING | (!fOnItem ? (MF_DISABLED | MF_GRAYED) : MF_ENABLED), M_CLIPBOARD, ResStr(IDS_PLAYLIST_COPYTOCLIPBOARD));
+ m.AppendMenu(MF_STRING | (!m_pl.GetCount() ? (MF_DISABLED | MF_GRAYED) : MF_ENABLED), M_SAVEAS, ResStr(IDS_PLAYLIST_SAVEAS));
+ m.AppendMenu(MF_SEPARATOR);
+ m.AppendMenu(MF_STRING | (!m_pl.GetCount() ? (MF_DISABLED | MF_GRAYED) : MF_ENABLED), M_SORTBYNAME, ResStr(IDS_PLAYLIST_SORTBYLABEL));
+ m.AppendMenu(MF_STRING | (!m_pl.GetCount() ? (MF_DISABLED | MF_GRAYED) : MF_ENABLED), M_SORTBYPATH, ResStr(IDS_PLAYLIST_SORTBYPATH));
+ m.AppendMenu(MF_STRING | (!m_pl.GetCount() ? (MF_DISABLED | MF_GRAYED) : MF_ENABLED), M_RANDOMIZE, ResStr(IDS_PLAYLIST_RANDOMIZE));
+ m.AppendMenu(MF_STRING | (!m_pl.GetCount() ? (MF_DISABLED | MF_GRAYED) : MF_ENABLED), M_SORTBYID, ResStr(IDS_PLAYLIST_RESTORE));
+ m.AppendMenu(MF_SEPARATOR);
+ m.AppendMenu(MF_STRING | MF_ENABLED | (s.bShufflePlaylistItems ? MF_CHECKED : MF_UNCHECKED), M_SHUFFLE, ResStr(IDS_PLAYLIST_SHUFFLE));
+ m.AppendMenu(MF_STRING | MF_ENABLED | (s.bRememberPlaylistItems ? MF_CHECKED : MF_UNCHECKED), M_REMEMBERPLAYLIST, ResStr(IDS_PLAYLIST_REMEBERITEMS));
+ m.AppendMenu(MF_SEPARATOR);
+ m.AppendMenu(MF_STRING | MF_ENABLED | (s.bHidePlaylistFullScreen ? MF_CHECKED : MF_UNCHECKED), M_HIDEFULLSCREEN, ResStr(IDS_PLAYLIST_HIDEFS));
+
+ CMainFrame* pMainFrm = (CMainFrame*)AfxGetMainWnd();
+
+ int nID = (int)m.TrackPopupMenu(TPM_LEFTBUTTON | TPM_RETURNCMD, p.x, p.y, this);
+ switch (nID) {
+ case M_OPEN:
+ m_pl.SetPos(pos);
+ m_list.Invalidate();
+ pMainFrm->OpenCurPlaylistItem();
+ break;
+ case M_ADD:
+ pMainFrm->AddCurDevToPlaylist();
+ m_pl.SetPos(m_pl.GetTailPosition());
+ break;
+ case M_REMOVE:
+ if (m_pl.RemoveAt(pos)) {
+ pMainFrm->CloseMedia();
+ }
+ m_list.DeleteItem(lvhti.iItem);
+ SavePlaylist();
+ break;
+ case M_CLEAR:
+ if (Empty()) {
+ pMainFrm->CloseMedia();
+ }
+ break;
+ case M_SORTBYID:
+ m_pl.SortById();
+ SetupList();
+ SavePlaylist();
+ break;
+ case M_SORTBYNAME:
+ m_pl.SortByName();
+ SetupList();
+ SavePlaylist();
+ break;
+ case M_SORTBYPATH:
+ m_pl.SortByPath();
+ SetupList();
+ SavePlaylist();
+ break;
+ case M_RANDOMIZE:
+ m_pl.Randomize();
+ SetupList();
+ SavePlaylist();
+ break;
+ case M_CLIPBOARD:
+ if (OpenClipboard() && EmptyClipboard()) {
+ CString str;
+
+ CPlaylistItem& pli = m_pl.GetAt(pos);
+ POSITION pos = pli.m_fns.GetHeadPosition();
+ while (pos) {
+ str += _T("\r\n") + pli.m_fns.GetNext(pos);
+ }
+ str.Trim();
+
+ if (HGLOBAL h = GlobalAlloc(GMEM_MOVEABLE, (str.GetLength() + 1) * sizeof(TCHAR))) {
+ if (TCHAR* s = (TCHAR*)GlobalLock(h)) {
+ _tcscpy_s(s, str.GetLength() + 1, str);
+ GlobalUnlock(h);
+ SetClipboardData(CF_UNICODETEXT, h);
+ }
+ }
+ CloseClipboard();
+ }
+ break;
+ case M_SAVEAS: {
+ CSaveTextFileDialog fd(
+ CTextFile::ASCII, NULL, NULL,
+ _T("Media Player Classic playlist (*.mpcpl)|*.mpcpl|Playlist (*.pls)|*.pls|Winamp playlist (*.m3u)|*.m3u|Windows Media playlist (*.asx)|*.asx||"),
+ this);
+
+ if (fd.DoModal() != IDOK) {
+ break;
+ }
+
+ CTextFile::enc encoding = (CTextFile::enc)fd.GetEncoding();
+ if (encoding == CTextFile::ASCII) {
+ encoding = CTextFile::ANSI;
+ }
+
+ int idx = fd.m_pOFN->nFilterIndex;
+
+ CPath path(fd.GetPathName());
+
+ switch (idx) {
+ case 1:
+ path.AddExtension(_T(".mpcpl"));
+ break;
+ case 2:
+ path.AddExtension(_T(".pls"));
+ break;
+ case 3:
+ path.AddExtension(_T(".m3u"));
+ break;
+ case 4:
+ path.AddExtension(_T(".asx"));
+ break;
+ default:
+ break;
+ }
+
+ bool fRemovePath = true;
+
+ CPath p(path);
+ p.RemoveFileSpec();
+ CString base = (LPCTSTR)p;
+
+ pos = m_pl.GetHeadPosition();
+ while (pos && fRemovePath) {
+ CPlaylistItem& pli = m_pl.GetNext(pos);
+
+ if (pli.m_type != CPlaylistItem::file) {
+ fRemovePath = false;
+ } else {
+ POSITION pos;
+
+ pos = pli.m_fns.GetHeadPosition();
+ while (pos && fRemovePath) {
+ CString fn = pli.m_fns.GetNext(pos);
+
+ CPath p(fn);
+ p.RemoveFileSpec();
+ if (base != (LPCTSTR)p) {
+ fRemovePath = false;
+ }
+ }
+
+ pos = pli.m_subs.GetHeadPosition();
+ while (pos && fRemovePath) {
+ CString fn = pli.m_subs.GetNext(pos);
+
+ CPath p(fn);
+ p.RemoveFileSpec();
+ if (base != (LPCTSTR)p) {
+ fRemovePath = false;
+ }
+ }
+ }
+ }
+
+ if (idx == 1) {
+ SaveMPCPlayList(path, encoding, fRemovePath);
+ break;
+ }
+
+ CTextFile f;
+ if (!f.Save(path, encoding)) {
+ break;
+ }
+
+ if (idx == 2) {
+ f.WriteString(_T("[playlist]\n"));
+ } else if (idx == 4) {
+ f.WriteString(_T("<ASX version = \"3.0\">\n"));
+ }
+
+ pos = m_pl.GetHeadPosition();
+ CString str;
+ int i;
+ for (i = 0; pos; i++) {
+ CPlaylistItem& pli = m_pl.GetNext(pos);
+
+ if (pli.m_type != CPlaylistItem::file) {
+ continue;
+ }
+
+ CString fn = pli.m_fns.GetHead();
+
+ /*
+ if (fRemovePath)
+ {
+ CPath p(path);
+ p.StripPath();
+ fn = (LPCTSTR)p;
+ }
+ */
+
+ switch (idx) {
+ case 2:
+ str.Format(_T("File%d=%s\n"), i + 1, fn);
+ break;
+ case 3:
+ str.Format(_T("%s\n"), fn);
+ break;
+ case 4:
+ str.Format(_T("<Entry><Ref href = \"%s\"/></Entry>\n"), fn);
+ break;
+ default:
+ break;
+ }
+ f.WriteString(str);
+ }
+
+ if (idx == 2) {
+ str.Format(_T("NumberOfEntries=%d\n"), i);
+ f.WriteString(str);
+ f.WriteString(_T("Version=2\n"));
+ } else if (idx == 4) {
+ f.WriteString(_T("</ASX>\n"));
+ }
+ }
+ break;
+ case M_REMEMBERPLAYLIST:
+ s.bRememberPlaylistItems = !s.bRememberPlaylistItems;
+ break;
+ case M_SHUFFLE:
+ s.bShufflePlaylistItems = !s.bShufflePlaylistItems;
+ break;
+ case M_HIDEFULLSCREEN:
+ s.bHidePlaylistFullScreen = !s.bHidePlaylistFullScreen;
+ break;
+ default:
+ break;
+ }
}
void CPlayerPlaylistBar::OnLvnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- NMLVDISPINFO* pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
+ NMLVDISPINFO* pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
- if (pDispInfo->item.iItem >= 0 && pDispInfo->item.pszText) {
- CPlaylistItem& pli = m_pl.GetAt((POSITION)m_list.GetItemData(pDispInfo->item.iItem));
- pli.m_label = pDispInfo->item.pszText;
- m_list.SetItemText(pDispInfo->item.iItem, 0, pDispInfo->item.pszText);
- }
+ if (pDispInfo->item.iItem >= 0 && pDispInfo->item.pszText) {
+ CPlaylistItem& pli = m_pl.GetAt((POSITION)m_list.GetItemData(pDispInfo->item.iItem));
+ pli.m_label = pDispInfo->item.pszText;
+ m_list.SetItemText(pDispInfo->item.iItem, 0, pDispInfo->item.pszText);
+ }
- *pResult = 0;
+ *pResult = 0;
}
diff --git a/src/mpc-hc/PlayerPlaylistBar.h b/src/mpc-hc/PlayerPlaylistBar.h
index 51aae232c..0f0b6a423 100644
--- a/src/mpc-hc/PlayerPlaylistBar.h
+++ b/src/mpc-hc/PlayerPlaylistBar.h
@@ -33,108 +33,108 @@ class OpenMediaData;
class CPlayerPlaylistBar : public CPlayerBar
{
- DECLARE_DYNAMIC(CPlayerPlaylistBar)
+ DECLARE_DYNAMIC(CPlayerPlaylistBar)
private:
- enum {COL_NAME, COL_TIME};
+ enum {COL_NAME, COL_TIME};
- CImageList m_fakeImageList;
- CPlayerListCtrl m_list;
+ CImageList m_fakeImageList;
+ CPlayerListCtrl m_list;
- int m_nTimeColWidth;
- void ResizeListColumn();
+ int m_nTimeColWidth;
+ void ResizeListColumn();
- void AddItem(CString fn, CAtlList<CString>* subs);
- void AddItem(CAtlList<CString>& fns, CAtlList<CString>* subs);
- void ParsePlayList(CString fn, CAtlList<CString>* subs);
- void ParsePlayList(CAtlList<CString>& fns, CAtlList<CString>* subs);
- void ResolveLinkFiles( CAtlList<CString> &fns );
+ void AddItem(CString fn, CAtlList<CString>* subs);
+ void AddItem(CAtlList<CString>& fns, CAtlList<CString>* subs);
+ void ParsePlayList(CString fn, CAtlList<CString>* subs);
+ void ParsePlayList(CAtlList<CString>& fns, CAtlList<CString>* subs);
+ void ResolveLinkFiles(CAtlList<CString>& fns);
- bool ParseBDMVPlayList(CString fn);
+ bool ParseBDMVPlayList(CString fn);
- bool ParseMPCPlayList(CString fn);
- bool SaveMPCPlayList(CString fn, CTextFile::enc e, bool fRemovePath);
+ bool ParseMPCPlayList(CString fn);
+ bool SaveMPCPlayList(CString fn, CTextFile::enc e, bool fRemovePath);
- void SetupList();
- void UpdateList();
- void EnsureVisible(POSITION pos);
- int FindItem(POSITION pos) const;
- POSITION FindPos(int i);
+ void SetupList();
+ void UpdateList();
+ void EnsureVisible(POSITION pos);
+ int FindItem(POSITION pos) const;
+ POSITION FindPos(int i);
- CImageList* m_pDragImage;
- BOOL m_bDragging;
- int m_nDragIndex, m_nDropIndex;
- CPoint m_ptDropPoint;
+ CImageList* m_pDragImage;
+ BOOL m_bDragging;
+ int m_nDragIndex, m_nDropIndex;
+ CPoint m_ptDropPoint;
- void DropItemOnList();
+ void DropItemOnList();
- bool m_bHiddenDueToFullscreen;
+ bool m_bHiddenDueToFullscreen;
public:
- CPlayerPlaylistBar();
- virtual ~CPlayerPlaylistBar();
+ CPlayerPlaylistBar();
+ virtual ~CPlayerPlaylistBar();
- BOOL Create(CWnd* pParentWnd, UINT defDockBarID);
+ BOOL Create(CWnd* pParentWnd, UINT defDockBarID);
- virtual void LoadState(CFrameWnd *pParent);
- virtual void SaveState();
+ virtual void LoadState(CFrameWnd* pParent);
+ virtual void SaveState();
- bool IsHiddenDueToFullscreen() const;
- void SetHiddenDueToFullscreen(bool bHidenDueToFullscreen);
+ bool IsHiddenDueToFullscreen() const;
+ void SetHiddenDueToFullscreen(bool bHidenDueToFullscreen);
- CPlaylist m_pl;
+ CPlaylist m_pl;
- INT_PTR GetCount() const;
- int GetSelIdx() const;
- void SetSelIdx(int i);
- bool IsAtEnd();
- bool GetCur(CPlaylistItem& pli) const;
- CPlaylistItem* GetCur();
- CString GetCurFileName();
- bool SetNext();
- bool SetPrev();
- void SetFirstSelected();
- void SetFirst();
- void SetLast();
- void SetCurValid(bool fValid);
- void SetCurTime(REFERENCE_TIME rt);
+ INT_PTR GetCount() const;
+ int GetSelIdx() const;
+ void SetSelIdx(int i);
+ bool IsAtEnd();
+ bool GetCur(CPlaylistItem& pli) const;
+ CPlaylistItem* GetCur();
+ CString GetCurFileName();
+ bool SetNext();
+ bool SetPrev();
+ void SetFirstSelected();
+ void SetFirst();
+ void SetLast();
+ void SetCurValid(bool fValid);
+ void SetCurTime(REFERENCE_TIME rt);
- void Refresh();
- bool Empty();
+ void Refresh();
+ bool Empty();
- void Open(CAtlList<CString>& fns, bool fMulti, CAtlList<CString>* subs = NULL);
- void Append(CAtlList<CString>& fns, bool fMulti, CAtlList<CString>* subs = NULL);
+ void Open(CAtlList<CString>& fns, bool fMulti, CAtlList<CString>* subs = NULL);
+ void Append(CAtlList<CString>& fns, bool fMulti, CAtlList<CString>* subs = NULL);
- void Open(CStringW vdn, CStringW adn, int vinput, int vchannel, int ainput);
- void Append(CStringW vdn, CStringW adn, int vinput, int vchannel, int ainput);
+ void Open(CStringW vdn, CStringW adn, int vinput, int vchannel, int ainput);
+ void Append(CStringW vdn, CStringW adn, int vinput, int vchannel, int ainput);
- OpenMediaData* GetCurOMD(REFERENCE_TIME rtStart = 0);
+ OpenMediaData* GetCurOMD(REFERENCE_TIME rtStart = 0);
- void LoadPlaylist(LPCTSTR filename);
- void SavePlaylist();
+ void LoadPlaylist(LPCTSTR filename);
+ void SavePlaylist();
- bool SelectFileInPlaylist(LPCTSTR filename);
+ bool SelectFileInPlaylist(LPCTSTR filename);
protected:
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg void OnLvnKeyDown(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnNMDblclkList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnLvnKeydownList(NMHDR* pNMHDR, LRESULT* pResult);
- // afx_msg void OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
- afx_msg BOOL OnPlayPlay(UINT nID);
- afx_msg void OnDropFiles(HDROP hDropInfo);
- afx_msg void OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnMouseMove(UINT nFlags, CPoint point);
- afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
- afx_msg BOOL OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnTimer(UINT_PTR nIDEvent);
- afx_msg void OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/);
- afx_msg void OnLvnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg void OnLvnKeyDown(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnNMDblclkList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnLvnKeydownList(NMHDR* pNMHDR, LRESULT* pResult);
+ // afx_msg void OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
+ afx_msg BOOL OnPlayPlay(UINT nID);
+ afx_msg void OnDropFiles(HDROP hDropInfo);
+ afx_msg void OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnMouseMove(UINT nFlags, CPoint point);
+ afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
+ afx_msg BOOL OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnTimer(UINT_PTR nIDEvent);
+ afx_msg void OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/);
+ afx_msg void OnLvnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
};
diff --git a/src/mpc-hc/PlayerSeekBar.cpp b/src/mpc-hc/PlayerSeekBar.cpp
index f49a3e38a..ca7db7cba 100644
--- a/src/mpc-hc/PlayerSeekBar.cpp
+++ b/src/mpc-hc/PlayerSeekBar.cpp
@@ -32,9 +32,9 @@
IMPLEMENT_DYNAMIC(CPlayerSeekBar, CDialogBar)
CPlayerSeekBar::CPlayerSeekBar() :
- m_start(0), m_stop(100), m_pos(0), m_posreal(0),
- m_fEnabled(false),
- m_tooltipState(TOOLTIP_HIDDEN), m_tooltipLastPos(-1), m_tooltipTimer(1)
+ m_start(0), m_stop(100), m_pos(0), m_posreal(0),
+ m_fEnabled(false),
+ m_tooltipState(TOOLTIP_HIDDEN), m_tooltipLastPos(-1), m_tooltipTimer(1)
{
}
@@ -44,189 +44,188 @@ CPlayerSeekBar::~CPlayerSeekBar()
BOOL CPlayerSeekBar::Create(CWnd* pParentWnd)
{
- if (!CDialogBar::Create(pParentWnd, IDD_PLAYERSEEKBAR, WS_CHILD|WS_VISIBLE|CBRS_ALIGN_BOTTOM, IDD_PLAYERSEEKBAR)) {
- return FALSE;
- }
+ if (!CDialogBar::Create(pParentWnd, IDD_PLAYERSEEKBAR, WS_CHILD | WS_VISIBLE | CBRS_ALIGN_BOTTOM, IDD_PLAYERSEEKBAR)) {
+ return FALSE;
+ }
- // Should never be RTLed
- ModifyStyleEx(WS_EX_LAYOUTRTL, WS_EX_NOINHERITLAYOUT);
+ // Should never be RTLed
+ ModifyStyleEx(WS_EX_LAYOUTRTL, WS_EX_NOINHERITLAYOUT);
- m_tooltip.Create(this, TTS_NOPREFIX | TTS_ALWAYSTIP);
+ m_tooltip.Create(this, TTS_NOPREFIX | TTS_ALWAYSTIP);
- m_tooltip.SetMaxTipWidth(SHRT_MAX);
- // SetDelayTime seems to be ignored but we set it anyway for safety.
- m_tooltip.SetDelayTime(TTDT_AUTOPOP, SHRT_MAX);
- m_tooltip.SetDelayTime(TTDT_INITIAL, 0);
- m_tooltip.SetDelayTime(TTDT_RESHOW, 0);
+ m_tooltip.SetMaxTipWidth(SHRT_MAX);
+ // SetDelayTime seems to be ignored but we set it anyway for safety.
+ m_tooltip.SetDelayTime(TTDT_AUTOPOP, SHRT_MAX);
+ m_tooltip.SetDelayTime(TTDT_INITIAL, 0);
+ m_tooltip.SetDelayTime(TTDT_RESHOW, 0);
- memset(&m_ti, 0, sizeof(TOOLINFO));
- m_ti.cbSize = sizeof(TOOLINFO);
- m_ti.uFlags = TTF_IDISHWND | TTF_TRACK | TTF_ABSOLUTE;
- m_ti.hwnd = m_hWnd;
- m_ti.hinst = AfxGetInstanceHandle();
- m_ti.lpszText = NULL;
- m_ti.uId = (UINT_PTR)m_hWnd;
+ memset(&m_ti, 0, sizeof(TOOLINFO));
+ m_ti.cbSize = sizeof(TOOLINFO);
+ m_ti.uFlags = TTF_IDISHWND | TTF_TRACK | TTF_ABSOLUTE;
+ m_ti.hwnd = m_hWnd;
+ m_ti.hinst = AfxGetInstanceHandle();
+ m_ti.lpszText = NULL;
+ m_ti.uId = (UINT_PTR)m_hWnd;
- m_tooltip.SendMessage(TTM_ADDTOOL, 0, (LPARAM)&m_ti);
+ m_tooltip.SendMessage(TTM_ADDTOOL, 0, (LPARAM)&m_ti);
- return TRUE;
+ return TRUE;
}
BOOL CPlayerSeekBar::PreCreateWindow(CREATESTRUCT& cs)
{
- if (!CDialogBar::PreCreateWindow(cs)) {
- return FALSE;
- }
+ if (!CDialogBar::PreCreateWindow(cs)) {
+ return FALSE;
+ }
- m_dwStyle &= ~CBRS_BORDER_TOP;
- m_dwStyle &= ~CBRS_BORDER_BOTTOM;
- m_dwStyle |= CBRS_SIZE_FIXED;
+ m_dwStyle &= ~CBRS_BORDER_TOP;
+ m_dwStyle &= ~CBRS_BORDER_BOTTOM;
+ m_dwStyle |= CBRS_SIZE_FIXED;
- return TRUE;
+ return TRUE;
}
void CPlayerSeekBar::Enable(bool fEnable)
{
- m_fEnabled = fEnable;
- Invalidate();
+ m_fEnabled = fEnable;
+ Invalidate();
}
void CPlayerSeekBar::GetRange(__int64& start, __int64& stop) const
{
- start = m_start;
- stop = m_stop;
+ start = m_start;
+ stop = m_stop;
}
void CPlayerSeekBar::SetRange(__int64 start, __int64 stop)
{
- if (start > stop) {
- start ^= stop, stop ^= start, start ^= stop;
- }
- m_start = start;
- m_stop = stop;
- if (m_pos < m_start || m_pos >= m_stop) {
- SetPos(m_start);
- }
+ if (start > stop) {
+ start ^= stop, stop ^= start, start ^= stop;
+ }
+ m_start = start;
+ m_stop = stop;
+ if (m_pos < m_start || m_pos >= m_stop) {
+ SetPos(m_start);
+ }
}
__int64 CPlayerSeekBar::GetPos() const
{
- return m_pos;
+ return m_pos;
}
__int64 CPlayerSeekBar::GetPosReal() const
{
- return m_posreal;
+ return m_posreal;
}
void CPlayerSeekBar::SetPos(__int64 pos)
{
- CWnd* w = GetCapture();
- if (w && w->m_hWnd == m_hWnd) {
- return;
- }
+ CWnd* w = GetCapture();
+ if (w && w->m_hWnd == m_hWnd) {
+ return;
+ }
- SetPosInternal(pos);
+ SetPosInternal(pos);
}
void CPlayerSeekBar::SetPosInternal(__int64 pos)
{
- if (m_pos == pos) {
- return;
- }
-
- CRect before = GetThumbRect();
- m_pos = min(max(pos, m_start), m_stop);
- m_posreal = pos;
- CRect after = GetThumbRect();
-
- if (before != after) {
- InvalidateRect(before | after);
-
- CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
- if (pFrame && (AfxGetAppSettings().fUseWin7TaskBar && pFrame->m_pTaskbarList)) {
- pFrame->m_pTaskbarList->SetProgressValue ( pFrame->m_hWnd, pos, m_stop );
- }
- }
+ if (m_pos == pos) {
+ return;
+ }
+
+ CRect before = GetThumbRect();
+ m_pos = min(max(pos, m_start), m_stop);
+ m_posreal = pos;
+ CRect after = GetThumbRect();
+
+ if (before != after) {
+ InvalidateRect(before | after);
+
+ CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
+ if (pFrame && (AfxGetAppSettings().fUseWin7TaskBar && pFrame->m_pTaskbarList)) {
+ pFrame->m_pTaskbarList->SetProgressValue(pFrame->m_hWnd, pos, m_stop);
+ }
+ }
}
CRect CPlayerSeekBar::GetChannelRect() const
{
- CRect r;
- GetClientRect(&r);
- r.DeflateRect(8, 9, 9, 0);
- r.bottom = r.top + 5;
- return r;
+ CRect r;
+ GetClientRect(&r);
+ r.DeflateRect(8, 9, 9, 0);
+ r.bottom = r.top + 5;
+ return r;
}
CRect CPlayerSeekBar::GetThumbRect() const
{
- // bool fEnabled = m_fEnabled || m_start >= m_stop;
+ // bool fEnabled = m_fEnabled || m_start >= m_stop;
- CRect r = GetChannelRect();
+ CRect r = GetChannelRect();
- int x = r.left + (int)((m_start < m_stop /*&& fEnabled*/) ? (__int64)r.Width() * (m_pos - m_start) / (m_stop - m_start) : 0);
- int y = r.CenterPoint().y;
+ int x = r.left + (int)((m_start < m_stop /*&& fEnabled*/) ? (__int64)r.Width() * (m_pos - m_start) / (m_stop - m_start) : 0);
+ int y = r.CenterPoint().y;
- r.SetRect(x, y, x, y);
- r.InflateRect(6, 7, 7, 8);
+ r.SetRect(x, y, x, y);
+ r.InflateRect(6, 7, 7, 8);
- return r;
+ return r;
}
CRect CPlayerSeekBar::GetInnerThumbRect() const
{
- CRect r = GetThumbRect();
+ CRect r = GetThumbRect();
- bool fEnabled = m_fEnabled && m_start < m_stop;
- r.DeflateRect(3, fEnabled ? 5 : 4, 3, fEnabled ? 5 : 4);
+ bool fEnabled = m_fEnabled && m_start < m_stop;
+ r.DeflateRect(3, fEnabled ? 5 : 4, 3, fEnabled ? 5 : 4);
- return r;
+ return r;
}
__int64 CPlayerSeekBar::CalculatePosition(CPoint point)
{
- __int64 pos = -1;
- CRect r = GetChannelRect();
-
- if (r.left >= r.right) {
- pos = -1;
- }
- else if (point.x < r.left) {
- pos = m_start;
- } else if (point.x >= r.right) {
- pos = m_stop;
- } else {
- __int64 w = r.right - r.left;
- if (m_start < m_stop) {
- pos = m_start + ((m_stop - m_start) * (point.x - r.left) + (w/2)) / w;
- }
- }
-
- return pos;
+ __int64 pos = -1;
+ CRect r = GetChannelRect();
+
+ if (r.left >= r.right) {
+ pos = -1;
+ } else if (point.x < r.left) {
+ pos = m_start;
+ } else if (point.x >= r.right) {
+ pos = m_stop;
+ } else {
+ __int64 w = r.right - r.left;
+ if (m_start < m_stop) {
+ pos = m_start + ((m_stop - m_start) * (point.x - r.left) + (w / 2)) / w;
+ }
+ }
+
+ return pos;
}
void CPlayerSeekBar::MoveThumb(CPoint point)
{
- __int64 pos = CalculatePosition(point);
+ __int64 pos = CalculatePosition(point);
- if (pos >= 0) {
- SetPosInternal(pos);
- }
+ if (pos >= 0) {
+ SetPosInternal(pos);
+ }
}
BEGIN_MESSAGE_MAP(CPlayerSeekBar, CDialogBar)
- //{{AFX_MSG_MAP(CPlayerSeekBar)
- ON_WM_PAINT()
- ON_WM_SIZE()
- ON_WM_LBUTTONDOWN()
- ON_WM_LBUTTONUP()
- ON_WM_MOUSEMOVE()
- ON_WM_ERASEBKGND()
- ON_WM_SETCURSOR()
- ON_WM_TIMER()
- //}}AFX_MSG_MAP
- ON_COMMAND_EX(ID_PLAY_STOP, OnPlayStop)
+ //{{AFX_MSG_MAP(CPlayerSeekBar)
+ ON_WM_PAINT()
+ ON_WM_SIZE()
+ ON_WM_LBUTTONDOWN()
+ ON_WM_LBUTTONUP()
+ ON_WM_MOUSEMOVE()
+ ON_WM_ERASEBKGND()
+ ON_WM_SETCURSOR()
+ ON_WM_TIMER()
+ //}}AFX_MSG_MAP
+ ON_COMMAND_EX(ID_PLAY_STOP, OnPlayStop)
END_MESSAGE_MAP()
@@ -234,268 +233,267 @@ END_MESSAGE_MAP()
void CPlayerSeekBar::OnPaint()
{
- CPaintDC dc(this); // device context for painting
-
- bool fEnabled = m_fEnabled && m_start < m_stop;
-
- COLORREF
- white = GetSysColor(COLOR_WINDOW),
- shadow = GetSysColor(COLOR_3DSHADOW),
- light = GetSysColor(COLOR_3DHILIGHT),
- bkg = GetSysColor(COLOR_BTNFACE);
-
- // thumb
- {
- CRect r = GetThumbRect(), r2 = GetInnerThumbRect();
- CRect rt = r, rit = r2;
-
- dc.Draw3dRect(&r, light, 0);
- r.DeflateRect(0, 0, 1, 1);
- dc.Draw3dRect(&r, light, shadow);
- r.DeflateRect(1, 1, 1, 1);
-
- CBrush b(bkg);
-
- dc.FrameRect(&r, &b);
- r.DeflateRect(0, 1, 0, 1);
- dc.FrameRect(&r, &b);
-
- r.DeflateRect(1, 1, 0, 0);
- dc.Draw3dRect(&r, shadow, bkg);
-
- if (fEnabled) {
- r.DeflateRect(1, 1, 1, 2);
- CPen white(PS_INSIDEFRAME, 1, white);
- CPen* old = dc.SelectObject(&white);
- dc.MoveTo(r.left, r.top);
- dc.LineTo(r.right, r.top);
- dc.MoveTo(r.left, r.bottom);
- dc.LineTo(r.right, r.bottom);
- dc.SelectObject(old);
- dc.SetPixel(r.CenterPoint().x, r.top, 0);
- dc.SetPixel(r.CenterPoint().x, r.bottom, 0);
- }
-
- dc.SetPixel(r.CenterPoint().x+5, r.top-4, bkg);
-
- {
- CRgn rgn1, rgn2;
- rgn1.CreateRectRgnIndirect(&rt);
- rgn2.CreateRectRgnIndirect(&rit);
- ExtSelectClipRgn(dc, rgn1, RGN_DIFF);
- ExtSelectClipRgn(dc, rgn2, RGN_OR);
- }
- }
-
- // channel
- {
- CRect r = GetChannelRect();
-
- dc.FillSolidRect(&r, fEnabled ? white : bkg);
- r.InflateRect(1, 1);
- dc.Draw3dRect(&r, shadow, light);
- dc.ExcludeClipRect(&r);
- }
-
- // background
- {
- CRect r;
- GetClientRect(&r);
- CBrush b(bkg);
- dc.FillRect(&r, &b);
- }
-
-
- // Do not call CDialogBar::OnPaint() for painting messages
+ CPaintDC dc(this); // device context for painting
+
+ bool fEnabled = m_fEnabled && m_start < m_stop;
+
+ COLORREF
+ white = GetSysColor(COLOR_WINDOW),
+ shadow = GetSysColor(COLOR_3DSHADOW),
+ light = GetSysColor(COLOR_3DHILIGHT),
+ bkg = GetSysColor(COLOR_BTNFACE);
+
+ // thumb
+ {
+ CRect r = GetThumbRect(), r2 = GetInnerThumbRect();
+ CRect rt = r, rit = r2;
+
+ dc.Draw3dRect(&r, light, 0);
+ r.DeflateRect(0, 0, 1, 1);
+ dc.Draw3dRect(&r, light, shadow);
+ r.DeflateRect(1, 1, 1, 1);
+
+ CBrush b(bkg);
+
+ dc.FrameRect(&r, &b);
+ r.DeflateRect(0, 1, 0, 1);
+ dc.FrameRect(&r, &b);
+
+ r.DeflateRect(1, 1, 0, 0);
+ dc.Draw3dRect(&r, shadow, bkg);
+
+ if (fEnabled) {
+ r.DeflateRect(1, 1, 1, 2);
+ CPen white(PS_INSIDEFRAME, 1, white);
+ CPen* old = dc.SelectObject(&white);
+ dc.MoveTo(r.left, r.top);
+ dc.LineTo(r.right, r.top);
+ dc.MoveTo(r.left, r.bottom);
+ dc.LineTo(r.right, r.bottom);
+ dc.SelectObject(old);
+ dc.SetPixel(r.CenterPoint().x, r.top, 0);
+ dc.SetPixel(r.CenterPoint().x, r.bottom, 0);
+ }
+
+ dc.SetPixel(r.CenterPoint().x + 5, r.top - 4, bkg);
+
+ {
+ CRgn rgn1, rgn2;
+ rgn1.CreateRectRgnIndirect(&rt);
+ rgn2.CreateRectRgnIndirect(&rit);
+ ExtSelectClipRgn(dc, rgn1, RGN_DIFF);
+ ExtSelectClipRgn(dc, rgn2, RGN_OR);
+ }
+ }
+
+ // channel
+ {
+ CRect r = GetChannelRect();
+
+ dc.FillSolidRect(&r, fEnabled ? white : bkg);
+ r.InflateRect(1, 1);
+ dc.Draw3dRect(&r, shadow, light);
+ dc.ExcludeClipRect(&r);
+ }
+
+ // background
+ {
+ CRect r;
+ GetClientRect(&r);
+ CBrush b(bkg);
+ dc.FillRect(&r, &b);
+ }
+
+
+ // Do not call CDialogBar::OnPaint() for painting messages
}
void CPlayerSeekBar::OnSize(UINT nType, int cx, int cy)
{
- HideToolTip();
+ HideToolTip();
- CDialogBar::OnSize(nType, cx, cy);
+ CDialogBar::OnSize(nType, cx, cy);
- Invalidate();
+ Invalidate();
}
void CPlayerSeekBar::OnLButtonDown(UINT nFlags, CPoint point)
{
- if (m_fEnabled && (GetChannelRect() | GetThumbRect()).PtInRect(point)) {
- SetCapture();
- MoveThumb(point);
- GetParent()->PostMessage(WM_HSCROLL, MAKEWPARAM((short)m_pos, SB_THUMBPOSITION), (LPARAM)m_hWnd);
- } else {
- CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
- if (!pFrame->m_fFullScreen) {
- MapWindowPoints(pFrame, &point, 1);
- pFrame->PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y));
- }
- }
-
- CDialogBar::OnLButtonDown(nFlags, point);
+ if (m_fEnabled && (GetChannelRect() | GetThumbRect()).PtInRect(point)) {
+ SetCapture();
+ MoveThumb(point);
+ GetParent()->PostMessage(WM_HSCROLL, MAKEWPARAM((short)m_pos, SB_THUMBPOSITION), (LPARAM)m_hWnd);
+ } else {
+ CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
+ if (!pFrame->m_fFullScreen) {
+ MapWindowPoints(pFrame, &point, 1);
+ pFrame->PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y));
+ }
+ }
+
+ CDialogBar::OnLButtonDown(nFlags, point);
}
void CPlayerSeekBar::OnLButtonUp(UINT nFlags, CPoint point)
{
- ReleaseCapture();
+ ReleaseCapture();
- CDialogBar::OnLButtonUp(nFlags, point);
+ CDialogBar::OnLButtonUp(nFlags, point);
}
void CPlayerSeekBar::UpdateTooltip(CPoint point)
{
- m_tooltipPos = CalculatePosition(point);
-
- if (m_fEnabled && m_start < m_stop && (GetChannelRect() | GetThumbRect()).PtInRect(point)) {
- if (m_tooltipState == TOOLTIP_HIDDEN && m_tooltipPos != m_tooltipLastPos) {
- // Request notification when the mouse leaves.
- TRACKMOUSEEVENT tme = { sizeof(TRACKMOUSEEVENT) };
- tme.hwndTrack = m_hWnd;
- tme.dwFlags = TME_LEAVE;
- TrackMouseEvent(&tme);
-
- m_tooltipState = TOOLTIP_TRIGGERED;
- m_tooltipTimer = SetTimer(m_tooltipTimer, SHOW_DELAY, NULL);
- }
- } else {
- HideToolTip();
- }
-
- if (m_tooltipState == TOOLTIP_VISIBLE && m_tooltipPos != m_tooltipLastPos) {
- UpdateToolTipText();
- UpdateToolTipPosition(point);
- // Reset the timer
- m_tooltipTimer = SetTimer(m_tooltipTimer, AUTOPOP_DELAY, NULL);
- }
+ m_tooltipPos = CalculatePosition(point);
+
+ if (m_fEnabled && m_start < m_stop && (GetChannelRect() | GetThumbRect()).PtInRect(point)) {
+ if (m_tooltipState == TOOLTIP_HIDDEN && m_tooltipPos != m_tooltipLastPos) {
+ // Request notification when the mouse leaves.
+ TRACKMOUSEEVENT tme = { sizeof(TRACKMOUSEEVENT) };
+ tme.hwndTrack = m_hWnd;
+ tme.dwFlags = TME_LEAVE;
+ TrackMouseEvent(&tme);
+
+ m_tooltipState = TOOLTIP_TRIGGERED;
+ m_tooltipTimer = SetTimer(m_tooltipTimer, SHOW_DELAY, NULL);
+ }
+ } else {
+ HideToolTip();
+ }
+
+ if (m_tooltipState == TOOLTIP_VISIBLE && m_tooltipPos != m_tooltipLastPos) {
+ UpdateToolTipText();
+ UpdateToolTipPosition(point);
+ // Reset the timer
+ m_tooltipTimer = SetTimer(m_tooltipTimer, AUTOPOP_DELAY, NULL);
+ }
}
void CPlayerSeekBar::OnMouseMove(UINT nFlags, CPoint point)
{
- CWnd* w = GetCapture();
- if (w && w->m_hWnd == m_hWnd && (nFlags & MK_LBUTTON)) {
- MoveThumb(point);
- GetParent()->PostMessage(WM_HSCROLL, MAKEWPARAM((short)m_pos, SB_THUMBTRACK), (LPARAM)m_hWnd);
- }
+ CWnd* w = GetCapture();
+ if (w && w->m_hWnd == m_hWnd && (nFlags & MK_LBUTTON)) {
+ MoveThumb(point);
+ GetParent()->PostMessage(WM_HSCROLL, MAKEWPARAM((short)m_pos, SB_THUMBTRACK), (LPARAM)m_hWnd);
+ }
- if (AfxGetAppSettings().fUseTimeTooltip) {
- UpdateTooltip(point);
- }
+ if (AfxGetAppSettings().fUseTimeTooltip) {
+ UpdateTooltip(point);
+ }
- CDialogBar::OnMouseMove(nFlags, point);
+ CDialogBar::OnMouseMove(nFlags, point);
}
LRESULT CPlayerSeekBar::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
- if (message == WM_MOUSELEAVE) {
- HideToolTip();
- }
+ if (message == WM_MOUSELEAVE) {
+ HideToolTip();
+ }
- return CWnd::WindowProc(message, wParam, lParam);
+ return CWnd::WindowProc(message, wParam, lParam);
}
BOOL CPlayerSeekBar::PreTranslateMessage(MSG* pMsg)
{
- POINT ptWnd(pMsg->pt);
- this->ScreenToClient(&ptWnd);
- if (m_fEnabled && AfxGetAppSettings().fUseTimeTooltip && m_start < m_stop && (GetChannelRect() | GetThumbRect()).PtInRect(ptWnd)) {
- m_tooltip.RelayEvent(pMsg);
- }
+ POINT ptWnd(pMsg->pt);
+ this->ScreenToClient(&ptWnd);
+ if (m_fEnabled && AfxGetAppSettings().fUseTimeTooltip && m_start < m_stop && (GetChannelRect() | GetThumbRect()).PtInRect(ptWnd)) {
+ m_tooltip.RelayEvent(pMsg);
+ }
- return CDialogBar::PreTranslateMessage(pMsg);
+ return CDialogBar::PreTranslateMessage(pMsg);
}
BOOL CPlayerSeekBar::OnEraseBkgnd(CDC* pDC)
{
- return TRUE;
+ return TRUE;
}
BOOL CPlayerSeekBar::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
- if (m_fEnabled && m_start < m_stop && m_stop != 100) {
- ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_HAND));
- return TRUE;
- }
+ if (m_fEnabled && m_start < m_stop && m_stop != 100) {
+ ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_HAND));
+ return TRUE;
+ }
- return CWnd::OnSetCursor(pWnd, nHitTest, message);
+ return CWnd::OnSetCursor(pWnd, nHitTest, message);
}
BOOL CPlayerSeekBar::OnPlayStop(UINT nID)
{
- SetPos(0);
- return FALSE;
+ SetPos(0);
+ return FALSE;
}
void CPlayerSeekBar::OnTimer(UINT_PTR nIDEvent)
{
- if (nIDEvent == m_tooltipTimer) {
- switch (m_tooltipState) {
- case TOOLTIP_TRIGGERED:
- {
- CPoint point;
-
- GetCursorPos(&point);
- ScreenToClient(&point);
-
- if (m_fEnabled && m_start < m_stop && (GetChannelRect() | GetThumbRect()).PtInRect(point)) {
- m_tooltipTimer = SetTimer(m_tooltipTimer, AUTOPOP_DELAY, NULL);
- m_tooltipPos = CalculatePosition(point);
- UpdateToolTipText();
- m_tooltip.SendMessage(TTM_TRACKACTIVATE, TRUE, (LPARAM)&m_ti);
- UpdateToolTipPosition(point);
- m_tooltipState = TOOLTIP_VISIBLE;
- }
- }
- break;
- case TOOLTIP_VISIBLE:
- HideToolTip();
- break;
- }
-
- }
-
- CWnd::OnTimer(nIDEvent);
+ if (nIDEvent == m_tooltipTimer) {
+ switch (m_tooltipState) {
+ case TOOLTIP_TRIGGERED: {
+ CPoint point;
+
+ GetCursorPos(&point);
+ ScreenToClient(&point);
+
+ if (m_fEnabled && m_start < m_stop && (GetChannelRect() | GetThumbRect()).PtInRect(point)) {
+ m_tooltipTimer = SetTimer(m_tooltipTimer, AUTOPOP_DELAY, NULL);
+ m_tooltipPos = CalculatePosition(point);
+ UpdateToolTipText();
+ m_tooltip.SendMessage(TTM_TRACKACTIVATE, TRUE, (LPARAM)&m_ti);
+ UpdateToolTipPosition(point);
+ m_tooltipState = TOOLTIP_VISIBLE;
+ }
+ }
+ break;
+ case TOOLTIP_VISIBLE:
+ HideToolTip();
+ break;
+ }
+
+ }
+
+ CWnd::OnTimer(nIDEvent);
}
void CPlayerSeekBar::HideToolTip()
{
- if (m_tooltipState > TOOLTIP_HIDDEN) {
- KillTimer(m_tooltipTimer);
- m_tooltip.SendMessage(TTM_TRACKACTIVATE, FALSE, (LPARAM)&m_ti);
- m_tooltipState = TOOLTIP_HIDDEN;
- }
+ if (m_tooltipState > TOOLTIP_HIDDEN) {
+ KillTimer(m_tooltipTimer);
+ m_tooltip.SendMessage(TTM_TRACKACTIVATE, FALSE, (LPARAM)&m_ti);
+ m_tooltipState = TOOLTIP_HIDDEN;
+ }
}
void CPlayerSeekBar::UpdateToolTipPosition(CPoint& point)
{
- static CSize size;
- static CRect r;
- size = m_tooltip.GetBubbleSize(&m_ti);
- GetWindowRect(r);
-
- if (AfxGetAppSettings().nTimeTooltipPosition == TIME_TOOLTIP_ABOVE_SEEKBAR) {
- point.x -= size.cx / 2 - 2;
- point.y = GetChannelRect().TopLeft().y - (size.cy + 13);
- } else {
- point.x += 10;
- point.y += 20;
- }
- point.x = max(0, min(point.x, r.Width() - size.cx));
- ClientToScreen(&point);
-
- m_tooltip.SendMessage(TTM_TRACKPOSITION, 0, MAKELPARAM(point.x, point.y));
- m_tooltipLastPos = m_tooltipPos;
+ static CSize size;
+ static CRect r;
+ size = m_tooltip.GetBubbleSize(&m_ti);
+ GetWindowRect(r);
+
+ if (AfxGetAppSettings().nTimeTooltipPosition == TIME_TOOLTIP_ABOVE_SEEKBAR) {
+ point.x -= size.cx / 2 - 2;
+ point.y = GetChannelRect().TopLeft().y - (size.cy + 13);
+ } else {
+ point.x += 10;
+ point.y += 20;
+ }
+ point.x = max(0, min(point.x, r.Width() - size.cx));
+ ClientToScreen(&point);
+
+ m_tooltip.SendMessage(TTM_TRACKPOSITION, 0, MAKELPARAM(point.x, point.y));
+ m_tooltipLastPos = m_tooltipPos;
}
void CPlayerSeekBar::UpdateToolTipText()
{
- DVD_HMSF_TIMECODE tcNow = RT2HMS_r(m_tooltipPos);
+ DVD_HMSF_TIMECODE tcNow = RT2HMS_r(m_tooltipPos);
- if (tcNow.bHours > 0) {
- m_tooltipText.Format(_T("%02d:%02d:%02d"), tcNow.bHours, tcNow.bMinutes, tcNow.bSeconds);
- } else {
- m_tooltipText.Format(_T("%02d:%02d"), tcNow.bMinutes, tcNow.bSeconds);
- }
+ if (tcNow.bHours > 0) {
+ m_tooltipText.Format(_T("%02d:%02d:%02d"), tcNow.bHours, tcNow.bMinutes, tcNow.bSeconds);
+ } else {
+ m_tooltipText.Format(_T("%02d:%02d"), tcNow.bMinutes, tcNow.bSeconds);
+ }
- m_ti.lpszText = (LPTSTR)(LPCTSTR)m_tooltipText;
- m_tooltip.SendMessage(TTM_SETTOOLINFO, 0, (LPARAM)&m_ti);
+ m_ti.lpszText = (LPTSTR)(LPCTSTR)m_tooltipText;
+ m_tooltip.SendMessage(TTM_SETTOOLINFO, 0, (LPARAM)&m_ti);
}
diff --git a/src/mpc-hc/PlayerSeekBar.h b/src/mpc-hc/PlayerSeekBar.h
index 2e7d86e69..7da8ba45c 100644
--- a/src/mpc-hc/PlayerSeekBar.h
+++ b/src/mpc-hc/PlayerSeekBar.h
@@ -30,68 +30,68 @@
class CPlayerSeekBar : public CDialogBar
{
- DECLARE_DYNAMIC(CPlayerSeekBar)
+ DECLARE_DYNAMIC(CPlayerSeekBar)
private:
- enum tooltip_state_t { TOOLTIP_HIDDEN, TOOLTIP_TRIGGERED, TOOLTIP_VISIBLE };
+ enum tooltip_state_t { TOOLTIP_HIDDEN, TOOLTIP_TRIGGERED, TOOLTIP_VISIBLE };
- __int64 m_start, m_stop, m_pos, m_posreal;
- bool m_fEnabled;
- CToolTipCtrl m_tooltip;
- TOOLINFO m_ti;
- tooltip_state_t m_tooltipState;
- __int64 m_tooltipPos, m_tooltipLastPos;
- CString m_tooltipText;
- UINT_PTR m_tooltipTimer;
+ __int64 m_start, m_stop, m_pos, m_posreal;
+ bool m_fEnabled;
+ CToolTipCtrl m_tooltip;
+ TOOLINFO m_ti;
+ tooltip_state_t m_tooltipState;
+ __int64 m_tooltipPos, m_tooltipLastPos;
+ CString m_tooltipText;
+ UINT_PTR m_tooltipTimer;
- void MoveThumb(CPoint point);
- __int64 CalculatePosition(CPoint point);
- void SetPosInternal(__int64 pos);
+ void MoveThumb(CPoint point);
+ __int64 CalculatePosition(CPoint point);
+ void SetPosInternal(__int64 pos);
- void UpdateTooltip(CPoint point);
+ void UpdateTooltip(CPoint point);
- CRect GetChannelRect() const;
- CRect GetThumbRect() const;
- CRect GetInnerThumbRect() const;
+ CRect GetChannelRect() const;
+ CRect GetThumbRect() const;
+ CRect GetInnerThumbRect() const;
public:
- CPlayerSeekBar();
- virtual ~CPlayerSeekBar();
+ CPlayerSeekBar();
+ virtual ~CPlayerSeekBar();
- void Enable(bool fEnable);
+ void Enable(bool fEnable);
- void GetRange(__int64& start, __int64& stop) const;
- void SetRange(__int64 start, __int64 stop);
- __int64 GetPos() const;
- __int64 GetPosReal() const;
- void SetPos(__int64 pos);
+ void GetRange(__int64& start, __int64& stop) const;
+ void SetRange(__int64 start, __int64 stop);
+ __int64 GetPos() const;
+ __int64 GetPosReal() const;
+ void SetPos(__int64 pos);
- void HideToolTip();
- void UpdateToolTipPosition(CPoint& point);
- void UpdateToolTipText();
+ void HideToolTip();
+ void UpdateToolTipPosition(CPoint& point);
+ void UpdateToolTipText();
- // Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CPlayerSeekBar)
- virtual BOOL Create(CWnd* pParentWnd);
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- //}}AFX_VIRTUAL
+ // Overrides
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CPlayerSeekBar)
+ virtual BOOL Create(CWnd* pParentWnd);
+ virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
+ //}}AFX_VIRTUAL
- // Generated message map functions
+ // Generated message map functions
protected:
- //{{AFX_MSG(CPlayerSeekBar)
- afx_msg void OnPaint();
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
- afx_msg void OnMouseMove(UINT nFlags, CPoint point);
- afx_msg LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
- afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
- afx_msg void OnTimer(UINT_PTR nIDEvent);
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
+ //{{AFX_MSG(CPlayerSeekBar)
+ afx_msg void OnPaint();
+ afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
+ afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
+ afx_msg void OnMouseMove(UINT nFlags, CPoint point);
+ afx_msg LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
+ afx_msg BOOL OnEraseBkgnd(CDC* pDC);
+ afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
+ afx_msg void OnTimer(UINT_PTR nIDEvent);
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg BOOL OnPlayStop(UINT nID);
+ afx_msg BOOL OnPlayStop(UINT nID);
};
diff --git a/src/mpc-hc/PlayerShaderEditorBar.cpp b/src/mpc-hc/PlayerShaderEditorBar.cpp
index fdb32b319..f967ce4f4 100644
--- a/src/mpc-hc/PlayerShaderEditorBar.cpp
+++ b/src/mpc-hc/PlayerShaderEditorBar.cpp
@@ -38,52 +38,52 @@ CPlayerShaderEditorBar::~CPlayerShaderEditorBar()
BOOL CPlayerShaderEditorBar::Create(CWnd* pParentWnd, UINT defDockBarID)
{
- if (!__super::Create(ResStr(IDS_SHADER_EDITOR), pParentWnd, ID_VIEW_SHADEREDITOR, defDockBarID, _T("Shader Editor"))) {
- return FALSE;
- }
+ if (!__super::Create(ResStr(IDS_SHADER_EDITOR), pParentWnd, ID_VIEW_SHADEREDITOR, defDockBarID, _T("Shader Editor"))) {
+ return FALSE;
+ }
- m_dlg.Create(this);
- m_dlg.ShowWindow(SW_SHOWNORMAL);
+ m_dlg.Create(this);
+ m_dlg.ShowWindow(SW_SHOWNORMAL);
- CRect r;
- m_dlg.GetWindowRect(r);
- m_szMinVert = m_szVert = r.Size();
- m_szMinHorz = m_szHorz = r.Size();
- m_szMinFloat = m_szFloat = r.Size();
- m_bFixedFloat = false;
+ CRect r;
+ m_dlg.GetWindowRect(r);
+ m_szMinVert = m_szVert = r.Size();
+ m_szMinHorz = m_szHorz = r.Size();
+ m_szMinFloat = m_szFloat = r.Size();
+ m_bFixedFloat = false;
- return TRUE;
+ return TRUE;
}
BOOL CPlayerShaderEditorBar::PreTranslateMessage(MSG* pMsg)
{
- if (IsWindow(pMsg->hwnd) && IsVisible() && pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST) {
- if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE) {
- GetParentFrame()->ShowControlBar(this, FALSE, TRUE);
- return TRUE;
- }
-
- if (IsDialogMessage(pMsg)) {
- return TRUE;
- }
- }
-
- return __super::PreTranslateMessage(pMsg);
+ if (IsWindow(pMsg->hwnd) && IsVisible() && pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST) {
+ if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE) {
+ GetParentFrame()->ShowControlBar(this, FALSE, TRUE);
+ return TRUE;
+ }
+
+ if (IsDialogMessage(pMsg)) {
+ return TRUE;
+ }
+ }
+
+ return __super::PreTranslateMessage(pMsg);
}
BEGIN_MESSAGE_MAP(CPlayerShaderEditorBar, CPlayerBar)
- ON_WM_SIZE()
+ ON_WM_SIZE()
END_MESSAGE_MAP()
// CPlayerShaderEditorBar message handlers
void CPlayerShaderEditorBar::OnSize(UINT nType, int cx, int cy)
{
- __super::OnSize(nType, cx, cy);
+ __super::OnSize(nType, cx, cy);
- if (::IsWindow(m_dlg.m_hWnd)) {
- CRect r;
- GetClientRect(r);
- m_dlg.MoveWindow(r);
- }
+ if (::IsWindow(m_dlg.m_hWnd)) {
+ CRect r;
+ GetClientRect(r);
+ m_dlg.MoveWindow(r);
+ }
}
diff --git a/src/mpc-hc/PlayerShaderEditorBar.h b/src/mpc-hc/PlayerShaderEditorBar.h
index f6f6d8e56..5ce04441d 100644
--- a/src/mpc-hc/PlayerShaderEditorBar.h
+++ b/src/mpc-hc/PlayerShaderEditorBar.h
@@ -31,22 +31,22 @@
class CPlayerShaderEditorBar : public CPlayerBar
{
- DECLARE_DYNAMIC(CPlayerShaderEditorBar)
+ DECLARE_DYNAMIC(CPlayerShaderEditorBar)
public:
- CPlayerShaderEditorBar();
- virtual ~CPlayerShaderEditorBar();
+ CPlayerShaderEditorBar();
+ virtual ~CPlayerShaderEditorBar();
- BOOL Create(CWnd* pParentWnd, UINT defDockBarID);
+ BOOL Create(CWnd* pParentWnd, UINT defDockBarID);
public:
- CShaderEditorDlg m_dlg;
+ CShaderEditorDlg m_dlg;
protected:
- virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg void OnSize(UINT nType, int cx, int cy);
};
diff --git a/src/mpc-hc/PlayerStatusBar.cpp b/src/mpc-hc/PlayerStatusBar.cpp
index dfa2e2b20..0ccf053e7 100644
--- a/src/mpc-hc/PlayerStatusBar.cpp
+++ b/src/mpc-hc/PlayerStatusBar.cpp
@@ -33,255 +33,255 @@
IMPLEMENT_DYNAMIC(CPlayerStatusBar, CDialogBar)
CPlayerStatusBar::CPlayerStatusBar()
- : m_status(false, false)
- , m_time(true, false)
- , m_bmid(0)
- , m_hIcon(0)
- , m_time_rect(-1, -1, -1, -1)
+ : m_status(false, false)
+ , m_time(true, false)
+ , m_bmid(0)
+ , m_hIcon(0)
+ , m_time_rect(-1, -1, -1, -1)
{
}
CPlayerStatusBar::~CPlayerStatusBar()
{
- if (m_hIcon) {
- DestroyIcon(m_hIcon);
- }
+ if (m_hIcon) {
+ DestroyIcon(m_hIcon);
+ }
}
BOOL CPlayerStatusBar::Create(CWnd* pParentWnd)
{
- BOOL ret = CDialogBar::Create(pParentWnd, IDD_PLAYERSTATUSBAR, WS_CHILD|WS_VISIBLE|CBRS_ALIGN_BOTTOM, IDD_PLAYERSTATUSBAR);
+ BOOL ret = CDialogBar::Create(pParentWnd, IDD_PLAYERSTATUSBAR, WS_CHILD | WS_VISIBLE | CBRS_ALIGN_BOTTOM, IDD_PLAYERSTATUSBAR);
- m_tooltip.Create(this, TTS_NOPREFIX | TTS_ALWAYSTIP);
+ m_tooltip.Create(this, TTS_NOPREFIX | TTS_ALWAYSTIP);
- m_tooltip.SetDelayTime(TTDT_INITIAL, 0);
- m_tooltip.SetDelayTime(TTDT_AUTOPOP, 2500);
- m_tooltip.SetDelayTime(TTDT_RESHOW, 0);
+ m_tooltip.SetDelayTime(TTDT_INITIAL, 0);
+ m_tooltip.SetDelayTime(TTDT_AUTOPOP, 2500);
+ m_tooltip.SetDelayTime(TTDT_RESHOW, 0);
- m_time.ModifyStyle(0, SS_NOTIFY);
+ m_time.ModifyStyle(0, SS_NOTIFY);
- m_tooltip.AddTool(&m_time, IDS_TOOLTIP_REMAINING_TIME);
+ m_tooltip.AddTool(&m_time, IDS_TOOLTIP_REMAINING_TIME);
- return ret;
+ return ret;
}
BOOL CPlayerStatusBar::PreCreateWindow(CREATESTRUCT& cs)
{
- if (!CDialogBar::PreCreateWindow(cs)) {
- return FALSE;
- }
+ if (!CDialogBar::PreCreateWindow(cs)) {
+ return FALSE;
+ }
- m_dwStyle &= ~CBRS_BORDER_TOP;
- m_dwStyle &= ~CBRS_BORDER_BOTTOM;
+ m_dwStyle &= ~CBRS_BORDER_TOP;
+ m_dwStyle &= ~CBRS_BORDER_BOTTOM;
- return TRUE;
+ return TRUE;
}
int CPlayerStatusBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
- if (CDialogBar::OnCreate(lpCreateStruct) == -1) {
- return -1;
- }
+ if (CDialogBar::OnCreate(lpCreateStruct) == -1) {
+ return -1;
+ }
- CRect r;
- r.SetRectEmpty();
+ CRect r;
+ r.SetRectEmpty();
- m_type.Create(_T(""), WS_CHILD|WS_VISIBLE|SS_ICON,
- r, this, IDC_STATIC1);
+ m_type.Create(_T(""), WS_CHILD | WS_VISIBLE | SS_ICON,
+ r, this, IDC_STATIC1);
- m_status.Create(_T(""), WS_CHILD|WS_VISIBLE|SS_OWNERDRAW,
- r, this, IDC_PLAYERSTATUS);
+ m_status.Create(_T(""), WS_CHILD | WS_VISIBLE | SS_OWNERDRAW,
+ r, this, IDC_PLAYERSTATUS);
- m_time.Create(_T(""), WS_CHILD|WS_VISIBLE|SS_OWNERDRAW,
- r, this, IDC_PLAYERTIME);
+ m_time.Create(_T(""), WS_CHILD | WS_VISIBLE | SS_OWNERDRAW,
+ r, this, IDC_PLAYERTIME);
- m_status.SetWindowPos(&m_time, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
+ m_status.SetWindowPos(&m_time, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
- Relayout();
+ Relayout();
- return 0;
+ return 0;
}
void CPlayerStatusBar::Relayout()
{
- BITMAP bm;
- memset(&bm, 0, sizeof(bm));
- if (m_bm.m_hObject) {
- m_bm.GetBitmap(&bm);
- }
-
- CRect r, r2;
- GetClientRect(r);
-
- r.DeflateRect(27, 5, bm.bmWidth + 8, 4);
- int div = r.right - (m_time.IsWindowVisible() ? 140 : 0);
-
- CString str;
- m_time.GetWindowText(str);
- if (CDC* pDC = m_time.GetDC()) {
- CFont* pOld = pDC->SelectObject(&m_time.GetFont());
- div = r.right - pDC->GetTextExtent(str).cx;
- pDC->SelectObject(pOld);
- m_time.ReleaseDC(pDC);
- }
-
- r2 = r;
- r2.right = div - 2;
- m_status.MoveWindow(&r2);
-
- r2 = r;
- r2.left = div;
- m_time.MoveWindow(&r2);
- m_time_rect = r2;
-
- GetClientRect(r);
- r.SetRect(6, r.top+4, 22, r.bottom-4);
- m_type.MoveWindow(r);
-
- Invalidate();
+ BITMAP bm;
+ memset(&bm, 0, sizeof(bm));
+ if (m_bm.m_hObject) {
+ m_bm.GetBitmap(&bm);
+ }
+
+ CRect r, r2;
+ GetClientRect(r);
+
+ r.DeflateRect(27, 5, bm.bmWidth + 8, 4);
+ int div = r.right - (m_time.IsWindowVisible() ? 140 : 0);
+
+ CString str;
+ m_time.GetWindowText(str);
+ if (CDC* pDC = m_time.GetDC()) {
+ CFont* pOld = pDC->SelectObject(&m_time.GetFont());
+ div = r.right - pDC->GetTextExtent(str).cx;
+ pDC->SelectObject(pOld);
+ m_time.ReleaseDC(pDC);
+ }
+
+ r2 = r;
+ r2.right = div - 2;
+ m_status.MoveWindow(&r2);
+
+ r2 = r;
+ r2.left = div;
+ m_time.MoveWindow(&r2);
+ m_time_rect = r2;
+
+ GetClientRect(r);
+ r.SetRect(6, r.top + 4, 22, r.bottom - 4);
+ m_type.MoveWindow(r);
+
+ Invalidate();
}
void CPlayerStatusBar::Clear()
{
- m_status.SetWindowText(_T(""));
- m_time.SetWindowText(_T(""));
- SetStatusBitmap(0);
- SetStatusTypeIcon(0);
+ m_status.SetWindowText(_T(""));
+ m_time.SetWindowText(_T(""));
+ SetStatusBitmap(0);
+ SetStatusTypeIcon(0);
- Relayout();
+ Relayout();
}
void CPlayerStatusBar::SetStatusBitmap(UINT id)
{
- if (m_bmid == id) {
- return;
- }
-
- if (m_bm.m_hObject) {
- m_bm.DeleteObject();
- }
- if (id) {
- m_bm.LoadBitmap(id);
- }
- m_bmid = id;
-
- Relayout();
+ if (m_bmid == id) {
+ return;
+ }
+
+ if (m_bm.m_hObject) {
+ m_bm.DeleteObject();
+ }
+ if (id) {
+ m_bm.LoadBitmap(id);
+ }
+ m_bmid = id;
+
+ Relayout();
}
void CPlayerStatusBar::SetStatusTypeIcon(HICON hIcon)
{
- if (m_hIcon == hIcon) {
- return;
- }
+ if (m_hIcon == hIcon) {
+ return;
+ }
- if (m_hIcon) {
- DestroyIcon(m_hIcon);
- }
- m_type.SetIcon(m_hIcon = hIcon);
+ if (m_hIcon) {
+ DestroyIcon(m_hIcon);
+ }
+ m_type.SetIcon(m_hIcon = hIcon);
- Relayout();
+ Relayout();
}
void CPlayerStatusBar::SetStatusMessage(CString str)
{
- str.Trim();
- m_status.SetWindowText(str);
+ str.Trim();
+ m_status.SetWindowText(str);
}
CString CPlayerStatusBar::GetStatusTimer()
{
- CString strResult;
+ CString strResult;
- m_time.GetWindowText(strResult);
+ m_time.GetWindowText(strResult);
- return strResult;
+ return strResult;
}
void CPlayerStatusBar::SetStatusTimer(CString str)
{
- CString tmp;
- m_time.GetWindowText(tmp);
- if (tmp == str) {
- return;
- }
+ CString tmp;
+ m_time.GetWindowText(tmp);
+ if (tmp == str) {
+ return;
+ }
- str.Trim();
- m_time.SetWindowText(str);
+ str.Trim();
+ m_time.SetWindowText(str);
- Relayout();
+ Relayout();
}
void CPlayerStatusBar::SetStatusTimer(REFERENCE_TIME rtNow, REFERENCE_TIME rtDur, bool fHighPrecision, const GUID* pTimeFormat)
{
- ASSERT(pTimeFormat);
- ASSERT(rtNow <= rtDur);
-
- CString str;
- CString posstr, durstr, rstr;
-
- if (*pTimeFormat == TIME_FORMAT_MEDIA_TIME) {
- DVD_HMSF_TIMECODE tcNow, tcDur, tcRt;
-
- if (fHighPrecision) {
- tcNow = RT2HMSF(rtNow);
- tcDur = RT2HMSF(rtDur);
- tcRt = RT2HMSF(rtDur-rtNow);
- } else {
- tcNow = RT2HMS_r(rtNow);
- tcDur = RT2HMS_r(rtDur);
- tcRt = RT2HMS_r(rtDur-rtNow);
- }
-
- if (tcDur.bHours > 0 || (rtNow >= rtDur && tcNow.bHours > 0)) {
- posstr.Format(_T("%02d:%02d:%02d"), tcNow.bHours, tcNow.bMinutes, tcNow.bSeconds);
- rstr.Format(_T("%02d:%02d:%02d"), tcRt.bHours, tcRt.bMinutes, tcRt.bSeconds);
- } else {
- posstr.Format(_T("%02d:%02d"), tcNow.bMinutes, tcNow.bSeconds);
- rstr.Format(_T("%02d:%02d"), tcRt.bMinutes, tcRt.bSeconds);
- }
-
- if (tcDur.bHours > 0) {
- durstr.Format(_T("%02d:%02d:%02d"), tcDur.bHours, tcDur.bMinutes, tcDur.bSeconds);
- } else {
- durstr.Format(_T("%02d:%02d"), tcDur.bMinutes, tcDur.bSeconds);
- }
-
- if (fHighPrecision) {
- posstr.AppendFormat(_T(".%03d"), (rtNow/10000)%1000);
- durstr.AppendFormat(_T(".%03d"), (rtDur/10000)%1000);
- rstr.AppendFormat(_T(".%03d"), ((rtDur - rtNow)/10000)%1000);
- }
- } else if (*pTimeFormat == TIME_FORMAT_FRAME) {
- posstr.Format(_T("%I64d"), rtNow);
- durstr.Format(_T("%I64d"), rtDur);
- rstr.Format(_T("%I64d"), rtDur - rtNow);
- }
-
- if (!AfxGetAppSettings().fRemainingTime) {
- str = ((rtDur <= 0) || (rtDur < rtNow)) ? posstr : posstr + _T(" / ") + durstr;
- } else {
- str = ((rtDur <= 0) || (rtDur < rtNow)) ? posstr : _T("- ") + rstr + _T(" / ") + durstr;
- }
-
- SetStatusTimer(str);
+ ASSERT(pTimeFormat);
+ ASSERT(rtNow <= rtDur);
+
+ CString str;
+ CString posstr, durstr, rstr;
+
+ if (*pTimeFormat == TIME_FORMAT_MEDIA_TIME) {
+ DVD_HMSF_TIMECODE tcNow, tcDur, tcRt;
+
+ if (fHighPrecision) {
+ tcNow = RT2HMSF(rtNow);
+ tcDur = RT2HMSF(rtDur);
+ tcRt = RT2HMSF(rtDur - rtNow);
+ } else {
+ tcNow = RT2HMS_r(rtNow);
+ tcDur = RT2HMS_r(rtDur);
+ tcRt = RT2HMS_r(rtDur - rtNow);
+ }
+
+ if (tcDur.bHours > 0 || (rtNow >= rtDur && tcNow.bHours > 0)) {
+ posstr.Format(_T("%02d:%02d:%02d"), tcNow.bHours, tcNow.bMinutes, tcNow.bSeconds);
+ rstr.Format(_T("%02d:%02d:%02d"), tcRt.bHours, tcRt.bMinutes, tcRt.bSeconds);
+ } else {
+ posstr.Format(_T("%02d:%02d"), tcNow.bMinutes, tcNow.bSeconds);
+ rstr.Format(_T("%02d:%02d"), tcRt.bMinutes, tcRt.bSeconds);
+ }
+
+ if (tcDur.bHours > 0) {
+ durstr.Format(_T("%02d:%02d:%02d"), tcDur.bHours, tcDur.bMinutes, tcDur.bSeconds);
+ } else {
+ durstr.Format(_T("%02d:%02d"), tcDur.bMinutes, tcDur.bSeconds);
+ }
+
+ if (fHighPrecision) {
+ posstr.AppendFormat(_T(".%03d"), (rtNow / 10000) % 1000);
+ durstr.AppendFormat(_T(".%03d"), (rtDur / 10000) % 1000);
+ rstr.AppendFormat(_T(".%03d"), ((rtDur - rtNow) / 10000) % 1000);
+ }
+ } else if (*pTimeFormat == TIME_FORMAT_FRAME) {
+ posstr.Format(_T("%I64d"), rtNow);
+ durstr.Format(_T("%I64d"), rtDur);
+ rstr.Format(_T("%I64d"), rtDur - rtNow);
+ }
+
+ if (!AfxGetAppSettings().fRemainingTime) {
+ str = ((rtDur <= 0) || (rtDur < rtNow)) ? posstr : posstr + _T(" / ") + durstr;
+ } else {
+ str = ((rtDur <= 0) || (rtDur < rtNow)) ? posstr : _T("- ") + rstr + _T(" / ") + durstr;
+ }
+
+ SetStatusTimer(str);
}
void CPlayerStatusBar::ShowTimer(bool fShow)
{
- m_time.ShowWindow(fShow ? SW_SHOW : SW_HIDE);
+ m_time.ShowWindow(fShow ? SW_SHOW : SW_HIDE);
- Relayout();
+ Relayout();
}
BEGIN_MESSAGE_MAP(CPlayerStatusBar, CDialogBar)
- ON_WM_ERASEBKGND()
- ON_WM_PAINT()
- ON_WM_SIZE()
- ON_WM_CREATE()
- ON_WM_LBUTTONDOWN()
- ON_WM_SETCURSOR()
- ON_WM_CTLCOLOR()
- ON_STN_CLICKED(IDC_PLAYERTIME, OnTimeDisplayClicked)
+ ON_WM_ERASEBKGND()
+ ON_WM_PAINT()
+ ON_WM_SIZE()
+ ON_WM_CREATE()
+ ON_WM_LBUTTONDOWN()
+ ON_WM_SETCURSOR()
+ ON_WM_CTLCOLOR()
+ ON_STN_CLICKED(IDC_PLAYERTIME, OnTimeDisplayClicked)
END_MESSAGE_MAP()
@@ -289,149 +289,149 @@ END_MESSAGE_MAP()
BOOL CPlayerStatusBar::OnEraseBkgnd(CDC* pDC)
{
- for (CWnd* pChild = GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow()) {
- if (!pChild->IsWindowVisible()) {
- continue;
- }
+ for (CWnd* pChild = GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow()) {
+ if (!pChild->IsWindowVisible()) {
+ continue;
+ }
- CRect r;
- pChild->GetClientRect(&r);
- pChild->MapWindowPoints(this, &r);
- pDC->ExcludeClipRect(&r);
- }
+ CRect r;
+ pChild->GetClientRect(&r);
+ pChild->MapWindowPoints(this, &r);
+ pDC->ExcludeClipRect(&r);
+ }
- CRect r;
- GetClientRect(&r);
+ CRect r;
+ GetClientRect(&r);
- CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
+ CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
- if (pFrame->m_pLastBar != this || pFrame->m_fFullScreen) {
- r.InflateRect(0, 0, 0, 1);
- }
+ if (pFrame->m_pLastBar != this || pFrame->m_fFullScreen) {
+ r.InflateRect(0, 0, 0, 1);
+ }
- if (pFrame->m_fFullScreen) {
- r.InflateRect(1, 0, 1, 0);
- }
+ if (pFrame->m_fFullScreen) {
+ r.InflateRect(1, 0, 1, 0);
+ }
- pDC->Draw3dRect(&r, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
+ pDC->Draw3dRect(&r, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
- r.DeflateRect(1, 1);
+ r.DeflateRect(1, 1);
- pDC->FillSolidRect(&r, 0);
+ pDC->FillSolidRect(&r, 0);
- return TRUE;
+ return TRUE;
}
void CPlayerStatusBar::OnPaint()
{
- CPaintDC dc(this); // device context for painting
-
- CRect r;
-
- if (m_bm.m_hObject) {
- BITMAP bm;
- m_bm.GetBitmap(&bm);
- CDC memdc;
- memdc.CreateCompatibleDC(&dc);
- memdc.SelectObject(&m_bm);
- GetClientRect(&r);
- dc.BitBlt(r.right-bm.bmWidth-1, (r.Height() - bm.bmHeight)/2, bm.bmWidth, bm.bmHeight, &memdc, 0, 0, SRCCOPY);
-
- //
- }
- /*
- if (m_hIcon)
- {
- GetClientRect(&r);
- r.SetRect(6, r.top+4, 22-1, r.bottom-4-1);
- DrawIconEx(dc, r.left, r.top, m_hIcon, r.Width(), r.Height(), 0, NULL, DI_NORMAL|DI_COMPAT);
- }
- */
- // Do not call CDialogBar::OnPaint() for painting messages
+ CPaintDC dc(this); // device context for painting
+
+ CRect r;
+
+ if (m_bm.m_hObject) {
+ BITMAP bm;
+ m_bm.GetBitmap(&bm);
+ CDC memdc;
+ memdc.CreateCompatibleDC(&dc);
+ memdc.SelectObject(&m_bm);
+ GetClientRect(&r);
+ dc.BitBlt(r.right - bm.bmWidth - 1, (r.Height() - bm.bmHeight) / 2, bm.bmWidth, bm.bmHeight, &memdc, 0, 0, SRCCOPY);
+
+ //
+ }
+ /*
+ if (m_hIcon)
+ {
+ GetClientRect(&r);
+ r.SetRect(6, r.top+4, 22-1, r.bottom-4-1);
+ DrawIconEx(dc, r.left, r.top, m_hIcon, r.Width(), r.Height(), 0, NULL, DI_NORMAL|DI_COMPAT);
+ }
+ */
+ // Do not call CDialogBar::OnPaint() for painting messages
}
void CPlayerStatusBar::OnSize(UINT nType, int cx, int cy)
{
- CDialogBar::OnSize(nType, cx, cy);
+ CDialogBar::OnSize(nType, cx, cy);
- Relayout();
+ Relayout();
}
void CPlayerStatusBar::OnLButtonDown(UINT nFlags, CPoint point)
{
- CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
+ CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
- WINDOWPLACEMENT wp;
- wp.length = sizeof(wp);
- pFrame->GetWindowPlacement(&wp);
+ WINDOWPLACEMENT wp;
+ wp.length = sizeof(wp);
+ pFrame->GetWindowPlacement(&wp);
- if (!pFrame->m_fFullScreen && wp.showCmd != SW_SHOWMAXIMIZED) {
- CRect r;
- GetClientRect(r);
- CPoint p = point;
+ if (!pFrame->m_fFullScreen && wp.showCmd != SW_SHOWMAXIMIZED) {
+ CRect r;
+ GetClientRect(r);
+ CPoint p = point;
- MapWindowPoints(pFrame, &point, 1);
+ MapWindowPoints(pFrame, &point, 1);
- pFrame->PostMessage(WM_NCLBUTTONDOWN,
- (p.x >= r.Width()-r.Height() && !pFrame->IsCaptionHidden()) ? HTBOTTOMRIGHT :
- HTCAPTION,
- MAKELPARAM(point.x, point.y));
- }
+ pFrame->PostMessage(WM_NCLBUTTONDOWN,
+ (p.x >= r.Width() - r.Height() && !pFrame->IsCaptionHidden()) ? HTBOTTOMRIGHT :
+ HTCAPTION,
+ MAKELPARAM(point.x, point.y));
+ }
}
BOOL CPlayerStatusBar::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
- CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
-
- WINDOWPLACEMENT wp;
- wp.length = sizeof(wp);
- pFrame->GetWindowPlacement(&wp);
-
- CPoint p;
- GetCursorPos(&p);
- ScreenToClient(&p);
-
- if (m_time_rect.PtInRect(p)) {
- SetCursor(LoadCursor(NULL, IDC_HAND));
- return TRUE;
- }
-
- if (!pFrame->m_fFullScreen && wp.showCmd != SW_SHOWMAXIMIZED) {
- CRect r;
- GetClientRect(r);
- if (p.x >= r.Width()-r.Height() && !pFrame->IsCaptionHidden()) {
- SetCursor(LoadCursor(NULL, IDC_SIZENWSE));
- return TRUE;
- }
- }
-
- return CDialogBar::OnSetCursor(pWnd, nHitTest, message);
+ CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
+
+ WINDOWPLACEMENT wp;
+ wp.length = sizeof(wp);
+ pFrame->GetWindowPlacement(&wp);
+
+ CPoint p;
+ GetCursorPos(&p);
+ ScreenToClient(&p);
+
+ if (m_time_rect.PtInRect(p)) {
+ SetCursor(LoadCursor(NULL, IDC_HAND));
+ return TRUE;
+ }
+
+ if (!pFrame->m_fFullScreen && wp.showCmd != SW_SHOWMAXIMIZED) {
+ CRect r;
+ GetClientRect(r);
+ if (p.x >= r.Width() - r.Height() && !pFrame->IsCaptionHidden()) {
+ SetCursor(LoadCursor(NULL, IDC_SIZENWSE));
+ return TRUE;
+ }
+ }
+
+ return CDialogBar::OnSetCursor(pWnd, nHitTest, message);
}
HBRUSH CPlayerStatusBar::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
- HBRUSH hbr = CDialogBar::OnCtlColor(pDC, pWnd, nCtlColor);
+ HBRUSH hbr = CDialogBar::OnCtlColor(pDC, pWnd, nCtlColor);
- if (*pWnd == m_type) {
- hbr = GetStockBrush(BLACK_BRUSH);
- }
+ if (*pWnd == m_type) {
+ hbr = GetStockBrush(BLACK_BRUSH);
+ }
- // TODO: Return a different brush if the default is not desired
- return hbr;
+ // TODO: Return a different brush if the default is not desired
+ return hbr;
}
BOOL CPlayerStatusBar::PreTranslateMessage(MSG* pMsg)
{
- m_tooltip.RelayEvent(pMsg);
+ m_tooltip.RelayEvent(pMsg);
- return __super::PreTranslateMessage(pMsg);
+ return __super::PreTranslateMessage(pMsg);
}
void CPlayerStatusBar::OnTimeDisplayClicked()
{
- CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
+ CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
- AfxGetAppSettings().fRemainingTime = !AfxGetAppSettings().fRemainingTime;
- // This isn't particularly nice...
- pFrame->OnTimer(2);
+ AfxGetAppSettings().fRemainingTime = !AfxGetAppSettings().fRemainingTime;
+ // This isn't particularly nice...
+ pFrame->OnTimer(2);
} \ No newline at end of file
diff --git a/src/mpc-hc/PlayerStatusBar.h b/src/mpc-hc/PlayerStatusBar.h
index 7dd671ad4..300816d7b 100644
--- a/src/mpc-hc/PlayerStatusBar.h
+++ b/src/mpc-hc/PlayerStatusBar.h
@@ -30,49 +30,49 @@
class CPlayerStatusBar : public CDialogBar
{
- DECLARE_DYNAMIC(CPlayerStatusBar)
+ DECLARE_DYNAMIC(CPlayerStatusBar)
- CStatic m_type;
- CStatusLabel m_status, m_time;
- CBitmap m_bm;
- UINT m_bmid;
- HICON m_hIcon;
+ CStatic m_type;
+ CStatusLabel m_status, m_time;
+ CBitmap m_bm;
+ UINT m_bmid;
+ HICON m_hIcon;
- CRect m_time_rect;
+ CRect m_time_rect;
- CToolTipCtrl m_tooltip;
+ CToolTipCtrl m_tooltip;
- void Relayout();
+ void Relayout();
public:
- CPlayerStatusBar();
- virtual ~CPlayerStatusBar();
+ CPlayerStatusBar();
+ virtual ~CPlayerStatusBar();
- void Clear();
+ void Clear();
- void SetStatusBitmap(UINT id);
- void SetStatusTypeIcon(HICON hIcon);
- void SetStatusMessage(CString str);
- void SetStatusTimer(CString str);
- void SetStatusTimer(REFERENCE_TIME rtNow, REFERENCE_TIME rtDur, bool fHighPrecision, const GUID* pTimeFormat = &TIME_FORMAT_MEDIA_TIME);
+ void SetStatusBitmap(UINT id);
+ void SetStatusTypeIcon(HICON hIcon);
+ void SetStatusMessage(CString str);
+ void SetStatusTimer(CString str);
+ void SetStatusTimer(REFERENCE_TIME rtNow, REFERENCE_TIME rtDur, bool fHighPrecision, const GUID* pTimeFormat = &TIME_FORMAT_MEDIA_TIME);
- CString GetStatusTimer();
- void ShowTimer(bool fShow);
+ CString GetStatusTimer();
+ void ShowTimer(bool fShow);
- // Overrides
- virtual BOOL Create(CWnd* pParentWnd);
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
+ // Overrides
+ virtual BOOL Create(CWnd* pParentWnd);
+ virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
protected:
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
- afx_msg void OnPaint();
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
- afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
- afx_msg BOOL PreTranslateMessage(MSG* pMsg);
- afx_msg void OnTimeDisplayClicked();
+ afx_msg BOOL OnEraseBkgnd(CDC* pDC);
+ afx_msg void OnPaint();
+ afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
+ afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
+ afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
+ afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
+ afx_msg BOOL PreTranslateMessage(MSG* pMsg);
+ afx_msg void OnTimeDisplayClicked();
};
diff --git a/src/mpc-hc/PlayerSubresyncBar.cpp b/src/mpc-hc/PlayerSubresyncBar.cpp
index 69e30f4b5..8ff8c1f02 100644
--- a/src/mpc-hc/PlayerSubresyncBar.cpp
+++ b/src/mpc-hc/PlayerSubresyncBar.cpp
@@ -32,9 +32,9 @@
IMPLEMENT_DYNAMIC(CPlayerSubresyncBar, CPlayerBar)
CPlayerSubresyncBar::CPlayerSubresyncBar()
{
- m_rt = 0;
- m_fUnlink = false;
- m_lastSegment = -1;
+ m_rt = 0;
+ m_fUnlink = false;
+ m_lastSegment = -1;
}
CPlayerSubresyncBar::~CPlayerSubresyncBar()
@@ -43,519 +43,519 @@ CPlayerSubresyncBar::~CPlayerSubresyncBar()
BOOL CPlayerSubresyncBar::Create(CWnd* pParentWnd, UINT defDockBarID, CCritSec* pSubLock)
{
- if (!__super::Create(ResStr(IDS_SUBRESYNC_CAPTION), pParentWnd, ID_VIEW_SUBRESYNC, defDockBarID, _T("Subresync"))) {
- return FALSE;
- }
+ if (!__super::Create(ResStr(IDS_SUBRESYNC_CAPTION), pParentWnd, ID_VIEW_SUBRESYNC, defDockBarID, _T("Subresync"))) {
+ return FALSE;
+ }
- m_pSubLock = pSubLock;
+ m_pSubLock = pSubLock;
- m_list.CreateEx(
- WS_EX_DLGMODALFRAME|WS_EX_CLIENTEDGE,
- WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_TABSTOP|LVS_REPORT/*|LVS_SHOWSELALWAYS*/|LVS_AUTOARRANGE|LVS_NOSORTHEADER,
- CRect(0,0,100,100), this, IDC_SUBRESYNCLIST);
+ m_list.CreateEx(
+ WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE,
+ WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP | LVS_REPORT/*|LVS_SHOWSELALWAYS*/ | LVS_AUTOARRANGE | LVS_NOSORTHEADER,
+ CRect(0, 0, 100, 100), this, IDC_SUBRESYNCLIST);
- m_list.SetExtendedStyle(m_list.GetExtendedStyle()|LVS_EX_FULLROWSELECT|LVS_EX_DOUBLEBUFFER);
+ m_list.SetExtendedStyle(m_list.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);
- return TRUE;
+ return TRUE;
}
BOOL CPlayerSubresyncBar::PreCreateWindow(CREATESTRUCT& cs)
{
- if (!CSizingControlBarG::PreCreateWindow(cs)) {
- return FALSE;
- }
+ if (!CSizingControlBarG::PreCreateWindow(cs)) {
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
BOOL CPlayerSubresyncBar::PreTranslateMessage(MSG* pMsg)
{
- if (IsWindow(pMsg->hwnd) && IsVisible() && pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST) {
- if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE) {
- GetParentFrame()->ShowControlBar(this, FALSE, TRUE);
- return TRUE;
- }
-
- if (IsShortCut(pMsg) || IsDialogMessage(pMsg)) {
- return TRUE;
- }
- }
-
- return CSizingControlBarG::PreTranslateMessage(pMsg);
+ if (IsWindow(pMsg->hwnd) && IsVisible() && pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST) {
+ if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE) {
+ GetParentFrame()->ShowControlBar(this, FALSE, TRUE);
+ return TRUE;
+ }
+
+ if (IsShortCut(pMsg) || IsDialogMessage(pMsg)) {
+ return TRUE;
+ }
+ }
+
+ return CSizingControlBarG::PreTranslateMessage(pMsg);
}
void CPlayerSubresyncBar::SetTime(__int64 rt)
{
- m_rt = rt;
+ m_rt = rt;
- int curSegment;
+ int curSegment;
- if (!m_sts.SearchSubs((int)(rt/10000), 25, &curSegment)) {
- curSegment = -1;
- }
+ if (!m_sts.SearchSubs((int)(rt / 10000), 25, &curSegment)) {
+ curSegment = -1;
+ }
- if (m_lastSegment != curSegment) {
- m_list.Invalidate();
- }
- m_lastSegment = curSegment;
+ if (m_lastSegment != curSegment) {
+ m_list.Invalidate();
+ }
+ m_lastSegment = curSegment;
}
void CPlayerSubresyncBar::SetSubtitle(ISubStream* pSubStream, double fps)
{
- m_pSubStream = pSubStream;
-
- m_mode = NONE;
- m_lastSegment = -1;
- m_sts.Empty();
-
- ResetSubtitle();
-
- if (!m_pSubStream) {
- return;
- }
-
- CLSID clsid;
- m_pSubStream->GetClassID(&clsid);
-
- if (clsid == __uuidof(CVobSubFile)) {
- CVobSubFile* pVSF = (CVobSubFile*)(ISubStream*)m_pSubStream;
-
- m_mode = VOBSUB;
-
- _ASSERT(pVSF->m_iLang >= 0);
- CAtlArray<CVobSubFile::SubPos>& sp = pVSF->m_langs[pVSF->m_iLang].subpos;
-
- for (size_t i = 0, j = sp.GetCount(); i < j; i++) {
- CString str;
- str.Format(_T("%d,%d,%d,%Iu"), sp[i].vobid, sp[i].cellid, sp[i].fForced, i);
- m_sts.Add(TToW(str), false, (int)sp[i].start, (int)sp[i].stop);
- }
-
- m_sts.CreateDefaultStyle(DEFAULT_CHARSET);
-
- pVSF->m_fOnlyShowForcedSubs = false;
-
- for (int i = 0, j = m_list.GetHeaderCtrl()->GetItemCount(); i < j; i++) {
- m_list.DeleteColumn(0);
- }
- m_list.InsertColumn(COL_START, ResStr(IDS_SUBRESYNC_CLN_TIME), LVCFMT_LEFT, 80);
- m_list.InsertColumn(COL_END, ResStr(IDS_SUBRESYNC_CLN_END), LVCFMT_LEFT, 80);
- m_list.InsertColumn(COL_PREVSTART, ResStr(IDS_SUBRESYNC_CLN_PREVIEW), LVCFMT_LEFT, 80);
- m_list.InsertColumn(COL_PREVEND, ResStr(IDS_SUBRESYNC_CLN_END), LVCFMT_LEFT, 80);
- m_list.InsertColumn(COL_VOBID, ResStr(IDS_SUBRESYNC_CLN_VOB_ID), LVCFMT_CENTER, 60);
- m_list.InsertColumn(COL_CELLID, ResStr(IDS_SUBRESYNC_CLN_CELL_ID), LVCFMT_CENTER, 60);
- m_list.InsertColumn(COL_FORCED, ResStr(IDS_SUBRESYNC_CLN_FORCED), LVCFMT_CENTER, 60);
- } else if (clsid == __uuidof(CRenderedTextSubtitle)) {
- CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
-
- m_mode = TEXTSUB;
-
- m_sts.Copy(*pRTS);
- m_sts.ConvertToTimeBased(fps);
- m_sts.Sort(true); /*!!m_fUnlink*/
-
- for (int i = 0, j = m_list.GetHeaderCtrl()->GetItemCount(); i < j; i++) {
- m_list.DeleteColumn(0);
- }
- m_list.InsertColumn(COL_START, ResStr(IDS_SUBRESYNC_CLN_TIME), LVCFMT_LEFT, 90);
- m_list.InsertColumn(COL_END, ResStr(IDS_SUBRESYNC_CLN_END), LVCFMT_LEFT, 4);
- m_list.InsertColumn(COL_PREVSTART, ResStr(IDS_SUBRESYNC_CLN_PREVIEW), LVCFMT_LEFT, 80);
- m_list.InsertColumn(COL_PREVEND, ResStr(IDS_SUBRESYNC_CLN_END), LVCFMT_LEFT, 4);
- m_list.InsertColumn(COL_TEXT, ResStr(IDS_SUBRESYNC_CLN_TEXT), LVCFMT_LEFT, 275);
- m_list.InsertColumn(COL_STYLE, ResStr(IDS_SUBRESYNC_CLN_STYLE), LVCFMT_LEFT, 80);
- m_list.InsertColumn(COL_FONT, ResStr(IDS_SUBRESYNC_CLN_FONT), LVCFMT_LEFT, 60);
- m_list.InsertColumn(COL_CHARSET, ResStr(IDS_SUBRESYNC_CLN_CHARTSET), LVCFMT_CENTER, 20);
- m_list.InsertColumn(COL_UNICODE, ResStr(IDS_SUBRESYNC_CLN_UNICODE), LVCFMT_CENTER, 40);
- m_list.InsertColumn(COL_LAYER, ResStr(IDS_SUBRESYNC_CLN_LAYER), LVCFMT_CENTER, 50);
- m_list.InsertColumn(COL_ACTOR, ResStr(IDS_SUBRESYNC_CLN_ACTOR), LVCFMT_LEFT, 80);
- m_list.InsertColumn(COL_EFFECT, ResStr(IDS_SUBRESYNC_CLN_EFFECT), LVCFMT_LEFT, 80);
- }
-
- m_subtimes.SetCount(m_sts.GetCount());
-
- for (size_t i = 0, j = m_sts.GetCount(); i < j; i++) {
- m_subtimes[i].orgstart = m_sts[i].start;
- m_subtimes[i].orgend = m_sts[i].end;
- }
-
- ResetSubtitle();
+ m_pSubStream = pSubStream;
+
+ m_mode = NONE;
+ m_lastSegment = -1;
+ m_sts.Empty();
+
+ ResetSubtitle();
+
+ if (!m_pSubStream) {
+ return;
+ }
+
+ CLSID clsid;
+ m_pSubStream->GetClassID(&clsid);
+
+ if (clsid == __uuidof(CVobSubFile)) {
+ CVobSubFile* pVSF = (CVobSubFile*)(ISubStream*)m_pSubStream;
+
+ m_mode = VOBSUB;
+
+ _ASSERT(pVSF->m_iLang >= 0);
+ CAtlArray<CVobSubFile::SubPos>& sp = pVSF->m_langs[pVSF->m_iLang].subpos;
+
+ for (size_t i = 0, j = sp.GetCount(); i < j; i++) {
+ CString str;
+ str.Format(_T("%d,%d,%d,%Iu"), sp[i].vobid, sp[i].cellid, sp[i].fForced, i);
+ m_sts.Add(TToW(str), false, (int)sp[i].start, (int)sp[i].stop);
+ }
+
+ m_sts.CreateDefaultStyle(DEFAULT_CHARSET);
+
+ pVSF->m_fOnlyShowForcedSubs = false;
+
+ for (int i = 0, j = m_list.GetHeaderCtrl()->GetItemCount(); i < j; i++) {
+ m_list.DeleteColumn(0);
+ }
+ m_list.InsertColumn(COL_START, ResStr(IDS_SUBRESYNC_CLN_TIME), LVCFMT_LEFT, 80);
+ m_list.InsertColumn(COL_END, ResStr(IDS_SUBRESYNC_CLN_END), LVCFMT_LEFT, 80);
+ m_list.InsertColumn(COL_PREVSTART, ResStr(IDS_SUBRESYNC_CLN_PREVIEW), LVCFMT_LEFT, 80);
+ m_list.InsertColumn(COL_PREVEND, ResStr(IDS_SUBRESYNC_CLN_END), LVCFMT_LEFT, 80);
+ m_list.InsertColumn(COL_VOBID, ResStr(IDS_SUBRESYNC_CLN_VOB_ID), LVCFMT_CENTER, 60);
+ m_list.InsertColumn(COL_CELLID, ResStr(IDS_SUBRESYNC_CLN_CELL_ID), LVCFMT_CENTER, 60);
+ m_list.InsertColumn(COL_FORCED, ResStr(IDS_SUBRESYNC_CLN_FORCED), LVCFMT_CENTER, 60);
+ } else if (clsid == __uuidof(CRenderedTextSubtitle)) {
+ CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
+
+ m_mode = TEXTSUB;
+
+ m_sts.Copy(*pRTS);
+ m_sts.ConvertToTimeBased(fps);
+ m_sts.Sort(true); /*!!m_fUnlink*/
+
+ for (int i = 0, j = m_list.GetHeaderCtrl()->GetItemCount(); i < j; i++) {
+ m_list.DeleteColumn(0);
+ }
+ m_list.InsertColumn(COL_START, ResStr(IDS_SUBRESYNC_CLN_TIME), LVCFMT_LEFT, 90);
+ m_list.InsertColumn(COL_END, ResStr(IDS_SUBRESYNC_CLN_END), LVCFMT_LEFT, 4);
+ m_list.InsertColumn(COL_PREVSTART, ResStr(IDS_SUBRESYNC_CLN_PREVIEW), LVCFMT_LEFT, 80);
+ m_list.InsertColumn(COL_PREVEND, ResStr(IDS_SUBRESYNC_CLN_END), LVCFMT_LEFT, 4);
+ m_list.InsertColumn(COL_TEXT, ResStr(IDS_SUBRESYNC_CLN_TEXT), LVCFMT_LEFT, 275);
+ m_list.InsertColumn(COL_STYLE, ResStr(IDS_SUBRESYNC_CLN_STYLE), LVCFMT_LEFT, 80);
+ m_list.InsertColumn(COL_FONT, ResStr(IDS_SUBRESYNC_CLN_FONT), LVCFMT_LEFT, 60);
+ m_list.InsertColumn(COL_CHARSET, ResStr(IDS_SUBRESYNC_CLN_CHARTSET), LVCFMT_CENTER, 20);
+ m_list.InsertColumn(COL_UNICODE, ResStr(IDS_SUBRESYNC_CLN_UNICODE), LVCFMT_CENTER, 40);
+ m_list.InsertColumn(COL_LAYER, ResStr(IDS_SUBRESYNC_CLN_LAYER), LVCFMT_CENTER, 50);
+ m_list.InsertColumn(COL_ACTOR, ResStr(IDS_SUBRESYNC_CLN_ACTOR), LVCFMT_LEFT, 80);
+ m_list.InsertColumn(COL_EFFECT, ResStr(IDS_SUBRESYNC_CLN_EFFECT), LVCFMT_LEFT, 80);
+ }
+
+ m_subtimes.SetCount(m_sts.GetCount());
+
+ for (size_t i = 0, j = m_sts.GetCount(); i < j; i++) {
+ m_subtimes[i].orgstart = m_sts[i].start;
+ m_subtimes[i].orgend = m_sts[i].end;
+ }
+
+ ResetSubtitle();
}
void CPlayerSubresyncBar::ResetSubtitle()
{
- m_list.DeleteAllItems();
+ m_list.DeleteAllItems();
- if (m_mode == VOBSUB || m_mode == TEXTSUB) {
- TCHAR buff[32];
+ if (m_mode == VOBSUB || m_mode == TEXTSUB) {
+ TCHAR buff[32];
- int prevstart = INT_MIN;
+ int prevstart = INT_MIN;
- for (int i = 0, j = m_sts.GetCount(); i < j; i++) {
- m_subtimes[i].newstart = m_subtimes[i].orgstart;
- m_subtimes[i].newend = m_subtimes[i].orgend;
- FormatTime(i, buff, _countof(buff), 0, false);
- m_list.InsertItem(i, buff, COL_START);
- FormatTime(i, buff, _countof(buff), 0, true);
- m_list.SetItemText(i, COL_END, buff);
+ for (int i = 0, j = m_sts.GetCount(); i < j; i++) {
+ m_subtimes[i].newstart = m_subtimes[i].orgstart;
+ m_subtimes[i].newend = m_subtimes[i].orgend;
+ FormatTime(i, buff, _countof(buff), 0, false);
+ m_list.InsertItem(i, buff, COL_START);
+ FormatTime(i, buff, _countof(buff), 0, true);
+ m_list.SetItemText(i, COL_END, buff);
- if (prevstart > m_subtimes[i].orgstart) {
- m_list.SetItemData(i, (DWORD_PTR)TSEP);
- }
- prevstart = m_subtimes[i].orgstart;
+ if (prevstart > m_subtimes[i].orgstart) {
+ m_list.SetItemData(i, (DWORD_PTR)TSEP);
+ }
+ prevstart = m_subtimes[i].orgstart;
- SetCheck(i, false, false);
- }
+ SetCheck(i, false, false);
+ }
- UpdatePreview();
+ UpdatePreview();
- m_list.SetColumnWidth(COL_START, LVSCW_AUTOSIZE);
- m_list.SetColumnWidth(COL_PREVSTART, LVSCW_AUTOSIZE);
- }
+ m_list.SetColumnWidth(COL_START, LVSCW_AUTOSIZE);
+ m_list.SetColumnWidth(COL_PREVSTART, LVSCW_AUTOSIZE);
+ }
- UpdateStrings();
+ UpdateStrings();
}
void CPlayerSubresyncBar::SaveSubtitle()
{
- CMainFrame* pFrame = ((CMainFrame*)AfxGetMainWnd());
- if (!pFrame) {
- return;
- }
-
- CLSID clsid;
- m_pSubStream->GetClassID(&clsid);
-
- if (clsid == __uuidof(CVobSubFile) && m_mode == VOBSUB) {
- CVobSubFile* pVSF = (CVobSubFile*)(ISubStream*)m_pSubStream;
-
- CAutoLock cAutoLock(m_pSubLock);
-
- _ASSERT(pVSF->m_iLang >= 0);
- CAtlArray<CVobSubFile::SubPos>& sp = pVSF->m_langs[pVSF->m_iLang].subpos;
-
- for (size_t i = 0, j = sp.GetCount(); i < j; i++) {
- sp[i].fValid = false;
- }
-
- for (int i = 0, j = m_sts.GetCount(); i < j; i++) {
- int vobid, cellid, forced, spnum;
- TCHAR c;
- if (_stscanf_s(m_sts.GetStr(i), _T("%d%c%d%c%d%c%d"), &vobid,
- &c, sizeof(TCHAR), &cellid, &c, sizeof(TCHAR), &forced,
- &c, sizeof(TCHAR), &spnum) != 7) {
- continue;
- }
- sp[spnum].start = m_sts[i].start;
- sp[spnum].stop = m_sts[i].end;
- sp[spnum].fValid = true;
- }
- } else if (clsid == __uuidof(CRenderedTextSubtitle) && m_mode == TEXTSUB) {
- CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
-
- CAutoLock cAutoLock(m_pSubLock);
-
- pRTS->Copy(m_sts);
- } else {
- return;
- }
-
- pFrame->InvalidateSubtitle();
+ CMainFrame* pFrame = ((CMainFrame*)AfxGetMainWnd());
+ if (!pFrame) {
+ return;
+ }
+
+ CLSID clsid;
+ m_pSubStream->GetClassID(&clsid);
+
+ if (clsid == __uuidof(CVobSubFile) && m_mode == VOBSUB) {
+ CVobSubFile* pVSF = (CVobSubFile*)(ISubStream*)m_pSubStream;
+
+ CAutoLock cAutoLock(m_pSubLock);
+
+ _ASSERT(pVSF->m_iLang >= 0);
+ CAtlArray<CVobSubFile::SubPos>& sp = pVSF->m_langs[pVSF->m_iLang].subpos;
+
+ for (size_t i = 0, j = sp.GetCount(); i < j; i++) {
+ sp[i].fValid = false;
+ }
+
+ for (int i = 0, j = m_sts.GetCount(); i < j; i++) {
+ int vobid, cellid, forced, spnum;
+ TCHAR c;
+ if (_stscanf_s(m_sts.GetStr(i), _T("%d%c%d%c%d%c%d"), &vobid,
+ &c, sizeof(TCHAR), &cellid, &c, sizeof(TCHAR), &forced,
+ &c, sizeof(TCHAR), &spnum) != 7) {
+ continue;
+ }
+ sp[spnum].start = m_sts[i].start;
+ sp[spnum].stop = m_sts[i].end;
+ sp[spnum].fValid = true;
+ }
+ } else if (clsid == __uuidof(CRenderedTextSubtitle) && m_mode == TEXTSUB) {
+ CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
+
+ CAutoLock cAutoLock(m_pSubLock);
+
+ pRTS->Copy(m_sts);
+ } else {
+ return;
+ }
+
+ pFrame->InvalidateSubtitle();
}
void CPlayerSubresyncBar::UpdatePreview()
{
- if (m_mode == VOBSUB || m_mode == TEXTSUB) {
- if (0/*m_fUnlink*/) {
- for (int i = 0, j = m_sts.GetCount(); i < j; i++) {
- bool fStartMod, fEndMod, fStartAdj, fEndAdj;
- GetCheck(i, fStartMod, fEndMod, fStartAdj, fEndAdj);
- m_sts[i].start = (fStartMod||fStartAdj) ? m_subtimes[i].newstart : m_subtimes[i].orgstart;
- m_sts[i].end = (fEndMod||fEndAdj) ? m_subtimes[i].newend : m_subtimes[i].orgend;
- }
- } else {
- CAtlArray<int> schk;
-
- for (int i = 0, j = m_sts.GetCount(); i < j;) {
- schk.RemoveAll();
-
- int start = i, end;
-
- for (end = i; end < j; end++) {
- int data = (int)m_list.GetItemData(end);
- if ((data&TSEP) && end > i) {
- break;
- }
- if (data&(TSMOD|TSADJ)) {
- schk.Add(end);
- }
- }
-
- if (schk.GetCount() == 0) {
- for (; start < end; start++) {
- m_sts[start].start = m_subtimes[start].orgstart;
- m_sts[start].end = m_subtimes[start].orgend;
- }
- } else if (schk.GetCount() == 1) {
- int k = schk[0];
- int dt = m_subtimes[k].newstart - m_subtimes[k].orgstart;
- for (; start < end; start++) {
- m_sts[start].start = m_subtimes[start].orgstart + dt;
- m_sts[start].end = (m_list.GetItemData(start)&TEMOD)
- ? m_subtimes[start].newend
- : (m_subtimes[start].orgend + dt);
- }
- } else if (schk.GetCount() >= 2) {
- int i0 = 0;
- int i1 = 0;
- int ti0 = 0;
- int ds = 0;
- double m = 0;
-
- int k, l;
- for (k = 0, l = schk.GetCount()-1; k < l; k++) {
- i0 = schk[k];
- i1 = schk[k+1];
-
- ti0 = m_subtimes[i0].orgstart;
- ds = m_subtimes[i1].orgstart - ti0;
-
- if (ds == 0) {
- SetSTS0(start, i1, ti0);
- } else {
- m = double(m_subtimes[i1].newstart - m_subtimes[i0].newstart) / ds;
- SetSTS1(start, i1, ti0, m, i0);
- }
-
- }
-
- ASSERT(k > 0);
- if (ds == 0) {
- SetSTS0(start, end, ti0);
- } else {
- SetSTS1(start, end, ti0, m, i0);
- }
- }
-
- i = end;
- }
- }
-
- m_sts.CreateSegments();
-
- for (int i = 0, j = m_sts.GetCount(); i < j; i++) {
- TCHAR buff[32];
- FormatTime(i, buff, _countof(buff), 2, false);
- m_list.SetItemText(i, COL_PREVSTART, buff);
- FormatTime(i, buff, _countof(buff), 2, true);
- m_list.SetItemText(i, COL_PREVEND, buff);
- }
-
- if (IsWindowVisible()) {
- SaveSubtitle();
- }
- }
+ if (m_mode == VOBSUB || m_mode == TEXTSUB) {
+ if (0/*m_fUnlink*/) {
+ for (int i = 0, j = m_sts.GetCount(); i < j; i++) {
+ bool fStartMod, fEndMod, fStartAdj, fEndAdj;
+ GetCheck(i, fStartMod, fEndMod, fStartAdj, fEndAdj);
+ m_sts[i].start = (fStartMod || fStartAdj) ? m_subtimes[i].newstart : m_subtimes[i].orgstart;
+ m_sts[i].end = (fEndMod || fEndAdj) ? m_subtimes[i].newend : m_subtimes[i].orgend;
+ }
+ } else {
+ CAtlArray<int> schk;
+
+ for (int i = 0, j = m_sts.GetCount(); i < j;) {
+ schk.RemoveAll();
+
+ int start = i, end;
+
+ for (end = i; end < j; end++) {
+ int data = (int)m_list.GetItemData(end);
+ if ((data & TSEP) && end > i) {
+ break;
+ }
+ if (data & (TSMOD | TSADJ)) {
+ schk.Add(end);
+ }
+ }
+
+ if (schk.GetCount() == 0) {
+ for (; start < end; start++) {
+ m_sts[start].start = m_subtimes[start].orgstart;
+ m_sts[start].end = m_subtimes[start].orgend;
+ }
+ } else if (schk.GetCount() == 1) {
+ int k = schk[0];
+ int dt = m_subtimes[k].newstart - m_subtimes[k].orgstart;
+ for (; start < end; start++) {
+ m_sts[start].start = m_subtimes[start].orgstart + dt;
+ m_sts[start].end = (m_list.GetItemData(start)&TEMOD)
+ ? m_subtimes[start].newend
+ : (m_subtimes[start].orgend + dt);
+ }
+ } else if (schk.GetCount() >= 2) {
+ int i0 = 0;
+ int i1 = 0;
+ int ti0 = 0;
+ int ds = 0;
+ double m = 0;
+
+ int k, l;
+ for (k = 0, l = schk.GetCount() - 1; k < l; k++) {
+ i0 = schk[k];
+ i1 = schk[k + 1];
+
+ ti0 = m_subtimes[i0].orgstart;
+ ds = m_subtimes[i1].orgstart - ti0;
+
+ if (ds == 0) {
+ SetSTS0(start, i1, ti0);
+ } else {
+ m = double(m_subtimes[i1].newstart - m_subtimes[i0].newstart) / ds;
+ SetSTS1(start, i1, ti0, m, i0);
+ }
+
+ }
+
+ ASSERT(k > 0);
+ if (ds == 0) {
+ SetSTS0(start, end, ti0);
+ } else {
+ SetSTS1(start, end, ti0, m, i0);
+ }
+ }
+
+ i = end;
+ }
+ }
+
+ m_sts.CreateSegments();
+
+ for (int i = 0, j = m_sts.GetCount(); i < j; i++) {
+ TCHAR buff[32];
+ FormatTime(i, buff, _countof(buff), 2, false);
+ m_list.SetItemText(i, COL_PREVSTART, buff);
+ FormatTime(i, buff, _countof(buff), 2, true);
+ m_list.SetItemText(i, COL_PREVEND, buff);
+ }
+
+ if (IsWindowVisible()) {
+ SaveSubtitle();
+ }
+ }
}
-void CPlayerSubresyncBar::SetSTS0( int &start, int end, int ti0 )
+void CPlayerSubresyncBar::SetSTS0(int& start, int end, int ti0)
{
- for (; start < end; start++) {
- m_sts[start].start = ti0;
- int endpos;
- if (m_list.GetItemData(start)&TEMOD) {
- endpos = m_subtimes[start].newend;
- } else {
- endpos = ti0 + m_subtimes[start].orgend - m_subtimes[start].orgstart;
- }
- m_sts[start].end = endpos;
- }
+ for (; start < end; start++) {
+ m_sts[start].start = ti0;
+ int endpos;
+ if (m_list.GetItemData(start)&TEMOD) {
+ endpos = m_subtimes[start].newend;
+ } else {
+ endpos = ti0 + m_subtimes[start].orgend - m_subtimes[start].orgstart;
+ }
+ m_sts[start].end = endpos;
+ }
}
-void CPlayerSubresyncBar::SetSTS1( int &start, int end, int ti0, double m, int i0 )
+void CPlayerSubresyncBar::SetSTS1(int& start, int end, int ti0, double m, int i0)
{
- for (; start < end; start++) {
- m_sts[start].start = int((m_subtimes[start].orgstart - ti0)*m + m_subtimes[i0].newstart);
- int endpos;
- if (m_list.GetItemData(start)&TEMOD) {
- endpos = m_subtimes[start].newend;
- } else {
- int diff = m_subtimes[start].orgend - m_subtimes[start].orgstart;
- if (m_mode == VOBSUB) {
- endpos = m_sts[start].start + diff;
- } else {
- endpos = m_sts[start].start + int(diff*m);
- }
- }
- m_sts[start].end = endpos;
- }
+ for (; start < end; start++) {
+ m_sts[start].start = int((m_subtimes[start].orgstart - ti0) * m + m_subtimes[i0].newstart);
+ int endpos;
+ if (m_list.GetItemData(start)&TEMOD) {
+ endpos = m_subtimes[start].newend;
+ } else {
+ int diff = m_subtimes[start].orgend - m_subtimes[start].orgstart;
+ if (m_mode == VOBSUB) {
+ endpos = m_sts[start].start + diff;
+ } else {
+ endpos = m_sts[start].start + int(diff * m);
+ }
+ }
+ m_sts[start].end = endpos;
+ }
}
void CPlayerSubresyncBar::UpdateStrings()
{
- CString str;
-
- if (m_mode == TEXTSUB) {
- for (int i = 0, j = m_sts.GetCount(); i < j; i++) {
- STSStyle stss;
- m_sts.GetStyle(i, stss);
-
- m_list.SetItemText(i, COL_TEXT, m_sts.GetStr(i, true));
- m_list.SetItemText(i, COL_STYLE, m_sts[i].style);
- m_list.SetItemText(i, COL_FONT, stss.fontName);
- str.Format(_T("%d"), stss.charSet);
- m_list.SetItemText(i, COL_CHARSET, str);
- m_list.SetItemText(i, COL_UNICODE, m_sts.IsEntryUnicode(i) ? _T("yes") : _T("no"));
- str.Format(_T("%d"), m_sts[i].layer);
- m_list.SetItemText(i, COL_LAYER, str);
- m_list.SetItemText(i, COL_ACTOR, m_sts[i].actor);
- m_list.SetItemText(i, COL_EFFECT, m_sts[i].effect);
- }
- } else if (m_mode == VOBSUB) {
- for (int i = 0, j = m_sts.GetCount(); i < j; i++) {
- int vobid, cellid, forced;
- TCHAR c;
- if (_stscanf_s(m_sts.GetStr(i), _T("%d%c%d%c%d"), &vobid,
- &c, sizeof(TCHAR), &cellid,
- &c, sizeof(TCHAR), &forced) != 5) {
- continue;
- }
- if (vobid < 0) {
- str = _T("-");
- } else {
- str.Format(_T("%d"), vobid);
- }
- m_list.SetItemText(i, COL_VOBID, str);
- if (cellid < 0) {
- str = _T("-");
- } else {
- str.Format(_T("%d"), cellid);
- }
- m_list.SetItemText(i, COL_CELLID, str);
- str = forced?_T("Yes"):_T("");
- m_list.SetItemText(i, COL_FORCED, str);
- }
- }
+ CString str;
+
+ if (m_mode == TEXTSUB) {
+ for (int i = 0, j = m_sts.GetCount(); i < j; i++) {
+ STSStyle stss;
+ m_sts.GetStyle(i, stss);
+
+ m_list.SetItemText(i, COL_TEXT, m_sts.GetStr(i, true));
+ m_list.SetItemText(i, COL_STYLE, m_sts[i].style);
+ m_list.SetItemText(i, COL_FONT, stss.fontName);
+ str.Format(_T("%d"), stss.charSet);
+ m_list.SetItemText(i, COL_CHARSET, str);
+ m_list.SetItemText(i, COL_UNICODE, m_sts.IsEntryUnicode(i) ? _T("yes") : _T("no"));
+ str.Format(_T("%d"), m_sts[i].layer);
+ m_list.SetItemText(i, COL_LAYER, str);
+ m_list.SetItemText(i, COL_ACTOR, m_sts[i].actor);
+ m_list.SetItemText(i, COL_EFFECT, m_sts[i].effect);
+ }
+ } else if (m_mode == VOBSUB) {
+ for (int i = 0, j = m_sts.GetCount(); i < j; i++) {
+ int vobid, cellid, forced;
+ TCHAR c;
+ if (_stscanf_s(m_sts.GetStr(i), _T("%d%c%d%c%d"), &vobid,
+ &c, sizeof(TCHAR), &cellid,
+ &c, sizeof(TCHAR), &forced) != 5) {
+ continue;
+ }
+ if (vobid < 0) {
+ str = _T("-");
+ } else {
+ str.Format(_T("%d"), vobid);
+ }
+ m_list.SetItemText(i, COL_VOBID, str);
+ if (cellid < 0) {
+ str = _T("-");
+ } else {
+ str.Format(_T("%d"), cellid);
+ }
+ m_list.SetItemText(i, COL_CELLID, str);
+ str = forced ? _T("Yes") : _T("");
+ m_list.SetItemText(i, COL_FORCED, str);
+ }
+ }
}
void CPlayerSubresyncBar::GetCheck(int iItem, bool& fStartMod, bool& fEndMod, bool& fStartAdj, bool& fEndAdj)
{
- if (0 <= iItem && (size_t)iItem < m_sts.GetCount()) {
- int nCheck = (int)m_list.GetItemData(iItem);
- fStartMod = !!(nCheck&TSMOD);
- fEndMod = !!(nCheck&TEMOD);
- fStartAdj = !!(nCheck&TSADJ);
- fEndAdj = !!(nCheck&TEADJ);
- }
+ if (0 <= iItem && (size_t)iItem < m_sts.GetCount()) {
+ int nCheck = (int)m_list.GetItemData(iItem);
+ fStartMod = !!(nCheck & TSMOD);
+ fEndMod = !!(nCheck & TEMOD);
+ fStartAdj = !!(nCheck & TSADJ);
+ fEndAdj = !!(nCheck & TEADJ);
+ }
}
void CPlayerSubresyncBar::SetCheck(int iItem, bool fStart, bool fEnd)
{
- if (0 <= iItem && (size_t)iItem < m_sts.GetCount()) {
- SubTime& st = m_subtimes[iItem];
-
- int nCheck = (int)m_list.GetItemData(iItem) & TSEP;
-
- if (fStart) {
- nCheck |= TSMOD;
- } else if (abs(st.orgstart-st.newstart)) {
- nCheck |= TSADJ;
- }
- if (fEnd) {
- nCheck |= TEMOD;
- } else if (abs(st.orgend-st.newend)) {
- nCheck |= TEADJ;
- }
-
- m_list.SetItemData(iItem, (DWORD)nCheck);
-
- TCHAR buff[32];
- FormatTime(iItem, buff, _countof(buff), fStart, false);
- m_list.SetItemText(iItem, COL_START, buff);
- FormatTime(iItem, buff, _countof(buff), fEnd, true);
- m_list.SetItemText(iItem, COL_END, buff);
- }
+ if (0 <= iItem && (size_t)iItem < m_sts.GetCount()) {
+ SubTime& st = m_subtimes[iItem];
+
+ int nCheck = (int)m_list.GetItemData(iItem) & TSEP;
+
+ if (fStart) {
+ nCheck |= TSMOD;
+ } else if (abs(st.orgstart - st.newstart)) {
+ nCheck |= TSADJ;
+ }
+ if (fEnd) {
+ nCheck |= TEMOD;
+ } else if (abs(st.orgend - st.newend)) {
+ nCheck |= TEADJ;
+ }
+
+ m_list.SetItemData(iItem, (DWORD)nCheck);
+
+ TCHAR buff[32];
+ FormatTime(iItem, buff, _countof(buff), fStart, false);
+ m_list.SetItemText(iItem, COL_START, buff);
+ FormatTime(iItem, buff, _countof(buff), fEnd, true);
+ m_list.SetItemText(iItem, COL_END, buff);
+ }
}
bool CPlayerSubresyncBar::ModStart(int iItem, int t, bool fReset)
{
- bool fRet = false;
+ bool fRet = false;
- bool fStartMod, fEndMod, fStartAdj, fEndAdj;
- GetCheck(iItem, fStartMod, fEndMod, fStartAdj, fEndAdj);
+ bool fStartMod, fEndMod, fStartAdj, fEndAdj;
+ GetCheck(iItem, fStartMod, fEndMod, fStartAdj, fEndAdj);
- SubTime& st = m_subtimes[iItem];
+ SubTime& st = m_subtimes[iItem];
- //if (fStartMod || fStartAdj || st.orgstart != t || fReset)
- {
- fRet = (st.newstart != t);
+ //if (fStartMod || fStartAdj || st.orgstart != t || fReset)
+ {
+ fRet = (st.newstart != t);
- st.newstart = t;
- if (!fEndMod) {
- st.newend = st.newstart + (st.orgend - st.orgstart);
- } else if (fReset) {
- st.newstart = st.newend - (st.orgend - st.orgstart);
- }
+ st.newstart = t;
+ if (!fEndMod) {
+ st.newend = st.newstart + (st.orgend - st.orgstart);
+ } else if (fReset) {
+ st.newstart = st.newend - (st.orgend - st.orgstart);
+ }
- SetCheck(iItem, !fReset, fEndMod);
- }
+ SetCheck(iItem, !fReset, fEndMod);
+ }
- return fRet;
+ return fRet;
}
bool CPlayerSubresyncBar::ModEnd(int iItem, int t, bool fReset)
{
- bool fRet = false;
+ bool fRet = false;
- bool fStartMod, fEndMod, fStartAdj, fEndAdj;
- GetCheck(iItem, fStartMod, fEndMod, fStartAdj, fEndAdj);
+ bool fStartMod, fEndMod, fStartAdj, fEndAdj;
+ GetCheck(iItem, fStartMod, fEndMod, fStartAdj, fEndAdj);
- SubTime& st = m_subtimes[iItem];
+ SubTime& st = m_subtimes[iItem];
- //if (fEndMod || fEndAdj || st.orgend != t || fReset)
- {
- fRet = (st.newend != t);
+ //if (fEndMod || fEndAdj || st.orgend != t || fReset)
+ {
+ fRet = (st.newend != t);
- st.newend = t;
- if (!fStartMod) {
- st.newstart = st.newend - (st.orgend - st.orgstart);
- } else if (fReset) {
- st.newend = st.newstart + (st.orgend - st.orgstart);
- }
+ st.newend = t;
+ if (!fStartMod) {
+ st.newstart = st.newend - (st.orgend - st.orgstart);
+ } else if (fReset) {
+ st.newend = st.newstart + (st.orgend - st.orgstart);
+ }
- SetCheck(iItem, fStartMod, !fReset);
- }
+ SetCheck(iItem, fStartMod, !fReset);
+ }
- return fRet;
+ return fRet;
}
void CPlayerSubresyncBar::FormatTime(int iItem, TCHAR* buff, size_t buffLen, int time, bool fEnd)
{
- int t = !fEnd
- ?(time == 2 ? m_sts[iItem].start
- : time == 1 ? m_subtimes[iItem].newstart
- : m_subtimes[iItem].orgstart)
- : (time == 2 ? m_sts[iItem].end
- : time == 1 ? m_subtimes[iItem].newend
- : m_subtimes[iItem].orgend);
-
- _stprintf_s(buff, buffLen, t >= 0
- ? _T("%02d:%02d:%02d.%03d")
- : _T("-%02d:%02d:%02d.%03d"),
- abs(t)/60/60/1000,
- (abs(t)/60/1000)%60,
- (abs(t)/1000)%60,
- abs(t)%1000);
+ int t = !fEnd
+ ? (time == 2 ? m_sts[iItem].start
+ : time == 1 ? m_subtimes[iItem].newstart
+ : m_subtimes[iItem].orgstart)
+ : (time == 2 ? m_sts[iItem].end
+ : time == 1 ? m_subtimes[iItem].newend
+ : m_subtimes[iItem].orgend);
+
+ _stprintf_s(buff, buffLen, t >= 0
+ ? _T("%02d:%02d:%02d.%03d")
+ : _T("-%02d:%02d:%02d.%03d"),
+ abs(t) / 60 / 60 / 1000,
+ (abs(t) / 60 / 1000) % 60,
+ (abs(t) / 1000) % 60,
+ abs(t) % 1000);
}
BEGIN_MESSAGE_MAP(CPlayerSubresyncBar, CSizingControlBarG)
- ON_WM_SIZE()
- ON_NOTIFY(LVN_BEGINLABELEDIT, IDC_SUBRESYNCLIST, OnBeginlabeleditList)
- ON_NOTIFY(LVN_DOLABELEDIT, IDC_SUBRESYNCLIST, OnDolabeleditList)
- ON_NOTIFY(LVN_ENDLABELEDIT, IDC_SUBRESYNCLIST, OnEndlabeleditList)
- ON_NOTIFY(NM_RCLICK, IDC_SUBRESYNCLIST, OnRclickList)
- ON_NOTIFY(NM_DBLCLK, IDC_SUBRESYNCLIST, OnNMDblclkList)
- ON_NOTIFY(LVN_KEYDOWN, IDC_SUBRESYNCLIST, OnLvnKeydownList)
- ON_NOTIFY(NM_CUSTOMDRAW, IDC_SUBRESYNCLIST, OnCustomdrawList)
+ ON_WM_SIZE()
+ ON_NOTIFY(LVN_BEGINLABELEDIT, IDC_SUBRESYNCLIST, OnBeginlabeleditList)
+ ON_NOTIFY(LVN_DOLABELEDIT, IDC_SUBRESYNCLIST, OnDolabeleditList)
+ ON_NOTIFY(LVN_ENDLABELEDIT, IDC_SUBRESYNCLIST, OnEndlabeleditList)
+ ON_NOTIFY(NM_RCLICK, IDC_SUBRESYNCLIST, OnRclickList)
+ ON_NOTIFY(NM_DBLCLK, IDC_SUBRESYNCLIST, OnNMDblclkList)
+ ON_NOTIFY(LVN_KEYDOWN, IDC_SUBRESYNCLIST, OnLvnKeydownList)
+ ON_NOTIFY(NM_CUSTOMDRAW, IDC_SUBRESYNCLIST, OnCustomdrawList)
END_MESSAGE_MAP()
@@ -563,568 +563,568 @@ END_MESSAGE_MAP()
void CPlayerSubresyncBar::OnSize(UINT nType, int cx, int cy)
{
- CSizingControlBarG::OnSize(nType, cx, cy);
-
- if (::IsWindow(m_list.m_hWnd)) {
- CRect r;
- GetClientRect(r);
- r.DeflateRect(2, 2);
- m_list.MoveWindow(r);
- }
+ CSizingControlBarG::OnSize(nType, cx, cy);
+
+ if (::IsWindow(m_list.m_hWnd)) {
+ CRect r;
+ GetClientRect(r);
+ r.DeflateRect(2, 2);
+ m_list.MoveWindow(r);
+ }
}
static bool ParseTime(CString str, int& ret, bool fWarn = true)
{
- int sign = 1, h, m, s, ms;
- TCHAR c;
-
- str.Trim();
- if (str.GetLength() > 0 && str[0] == '-') {
- sign = -1;
- }
-
- int n = _stscanf_s(str, _T("%d%c%d%c%d%c%d"), &h, &c, sizeof(TCHAR),
- &m, &c, sizeof(TCHAR), &s, &c, sizeof(TCHAR), &ms);
-
- h = abs(h);
-
- if (n == 7
- && 0 <= h && h < 24
- && 0 <= m && m < 60
- && 0 <= s && s < 60
- && 0 <= ms && ms < 1000) {
- ret = sign*(h*60*60*1000+m*60*1000+s*1000+ms);
- return true;
- }
-
- if (fWarn) {
- AfxMessageBox(IDS_SUBRESYNC_TIME_FORMAT, MB_ICONEXCLAMATION | MB_OK, 0);
- }
- return false;
+ int sign = 1, h, m, s, ms;
+ TCHAR c;
+
+ str.Trim();
+ if (str.GetLength() > 0 && str[0] == '-') {
+ sign = -1;
+ }
+
+ int n = _stscanf_s(str, _T("%d%c%d%c%d%c%d"), &h, &c, sizeof(TCHAR),
+ &m, &c, sizeof(TCHAR), &s, &c, sizeof(TCHAR), &ms);
+
+ h = abs(h);
+
+ if (n == 7
+ && 0 <= h && h < 24
+ && 0 <= m && m < 60
+ && 0 <= s && s < 60
+ && 0 <= ms && ms < 1000) {
+ ret = sign * (h * 60 * 60 * 1000 + m * 60 * 1000 + s * 1000 + ms);
+ return true;
+ }
+
+ if (fWarn) {
+ AfxMessageBox(IDS_SUBRESYNC_TIME_FORMAT, MB_ICONEXCLAMATION | MB_OK, 0);
+ }
+ return false;
}
void CPlayerSubresyncBar::OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- LV_ITEM* pItem = &pDispInfo->item;
-
- *pResult = FALSE;
-
- if (pItem->iItem >= 0) {
- if ((pItem->iSubItem == COL_START || pItem->iSubItem == COL_END || pItem->iSubItem == COL_TEXT
- || pItem->iSubItem == COL_STYLE || pItem->iSubItem == COL_LAYER
- || pItem->iSubItem == COL_ACTOR || pItem->iSubItem == COL_EFFECT)
- && m_mode == TEXTSUB) {
- *pResult = TRUE;
- } else if ((pItem->iSubItem == COL_START)
- && m_mode == VOBSUB) {
- *pResult = TRUE;
- }
- }
+ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
+ LV_ITEM* pItem = &pDispInfo->item;
+
+ *pResult = FALSE;
+
+ if (pItem->iItem >= 0) {
+ if ((pItem->iSubItem == COL_START || pItem->iSubItem == COL_END || pItem->iSubItem == COL_TEXT
+ || pItem->iSubItem == COL_STYLE || pItem->iSubItem == COL_LAYER
+ || pItem->iSubItem == COL_ACTOR || pItem->iSubItem == COL_EFFECT)
+ && m_mode == TEXTSUB) {
+ *pResult = TRUE;
+ } else if ((pItem->iSubItem == COL_START)
+ && m_mode == VOBSUB) {
+ *pResult = TRUE;
+ }
+ }
}
void CPlayerSubresyncBar::OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- LV_ITEM* pItem = &pDispInfo->item;
-
- *pResult = FALSE;
-
- if (pItem->iItem >= 0) {
- if ((pItem->iSubItem == COL_START || pItem->iSubItem == COL_END || pItem->iSubItem == COL_TEXT
- || pItem->iSubItem == COL_STYLE || pItem->iSubItem == COL_LAYER
- || pItem->iSubItem == COL_ACTOR || pItem->iSubItem == COL_EFFECT)
- && m_mode == TEXTSUB) {
- m_list.ShowInPlaceEdit(pItem->iItem, pItem->iSubItem);
- *pResult = TRUE;
- } else if ((pItem->iSubItem == COL_START)
- && m_mode == VOBSUB) {
- m_list.ShowInPlaceEdit(pItem->iItem, pItem->iSubItem);
- *pResult = TRUE;
- }
- }
+ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
+ LV_ITEM* pItem = &pDispInfo->item;
+
+ *pResult = FALSE;
+
+ if (pItem->iItem >= 0) {
+ if ((pItem->iSubItem == COL_START || pItem->iSubItem == COL_END || pItem->iSubItem == COL_TEXT
+ || pItem->iSubItem == COL_STYLE || pItem->iSubItem == COL_LAYER
+ || pItem->iSubItem == COL_ACTOR || pItem->iSubItem == COL_EFFECT)
+ && m_mode == TEXTSUB) {
+ m_list.ShowInPlaceEdit(pItem->iItem, pItem->iSubItem);
+ *pResult = TRUE;
+ } else if ((pItem->iSubItem == COL_START)
+ && m_mode == VOBSUB) {
+ m_list.ShowInPlaceEdit(pItem->iItem, pItem->iSubItem);
+ *pResult = TRUE;
+ }
+ }
}
void CPlayerSubresyncBar::OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- LV_ITEM* pItem = &pDispInfo->item;
-
- *pResult = FALSE;
-
- if (!m_list.m_fInPlaceDirty) {
- return;
- }
-
- bool fNeedsUpdate = false;
-
- if (pItem->iItem >= 0 && pItem->pszText && (m_mode == VOBSUB || m_mode == TEXTSUB)) {
- switch (pItem->iSubItem) {
- case COL_START: {
- int t;
- if (ParseTime(pItem->pszText, t)) {
- fNeedsUpdate = ModStart(pItem->iItem, t);
-
- *pResult = TRUE;
- }
- }
- break;
- case COL_END:
- if (m_mode == TEXTSUB) {
- int t;
- if (ParseTime(pItem->pszText, t)) {
- fNeedsUpdate = ModEnd(pItem->iItem, t);
-
- *pResult = TRUE;
- }
- }
- break;
- case COL_TEXT:
- if (m_mode == TEXTSUB) {
- CString str = m_sts.GetStr(pItem->iItem, true);
-
- if (str != pItem->pszText) {
- fNeedsUpdate = true;
- m_sts.SetStr(pItem->iItem, CString(pItem->pszText), true);
- m_list.SetItemText(pItem->iItem, pItem->iSubItem, m_sts.GetStr(pItem->iItem, true));
- }
- }
- break;
- case COL_STYLE:
- if (m_mode == TEXTSUB) {
- CString str(pItem->pszText);
- str.Trim();
-
- if (!str.IsEmpty() && m_sts[pItem->iItem].style != str) {
- fNeedsUpdate = true;
-
- if (!m_sts.m_styles.Lookup(str)) {
- m_sts.AddStyle(str, DNew STSStyle());
- }
-
- m_sts[pItem->iItem].style = str;
-
- m_list.SetItemText(pItem->iItem, pItem->iSubItem, pItem->pszText);
- }
- }
- break;
- case COL_LAYER:
- if (m_mode == TEXTSUB) {
- int l;
- if (_stscanf_s(pItem->pszText, _T("%d"), &l) == 1) {
- fNeedsUpdate = true;
- m_sts[pItem->iItem].layer = l;
- CString str;
- str.Format(_T("%d"), l);
- m_list.SetItemText(pItem->iItem, pItem->iSubItem, str);
- }
- }
- break;
- case COL_ACTOR:
- if (m_mode == TEXTSUB) {
- CString str(pItem->pszText);
- str.Trim();
- if (!str.IsEmpty()) {
- fNeedsUpdate = true;
- m_sts[pItem->iItem].actor = str;
- m_list.SetItemText(pItem->iItem, pItem->iSubItem, str);
- }
- }
- break;
- case COL_EFFECT:
- if (m_mode == TEXTSUB) {
- CString str(pItem->pszText);
- str.Trim();
- if (!str.IsEmpty()) {
- fNeedsUpdate = true;
- m_sts[pItem->iItem].effect = str;
- m_list.SetItemText(pItem->iItem, pItem->iSubItem, str);
- }
- }
- break;
- }
- }
-
- if (fNeedsUpdate) {
- UpdatePreview();
- }
+ LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
+ LV_ITEM* pItem = &pDispInfo->item;
+
+ *pResult = FALSE;
+
+ if (!m_list.m_fInPlaceDirty) {
+ return;
+ }
+
+ bool fNeedsUpdate = false;
+
+ if (pItem->iItem >= 0 && pItem->pszText && (m_mode == VOBSUB || m_mode == TEXTSUB)) {
+ switch (pItem->iSubItem) {
+ case COL_START: {
+ int t;
+ if (ParseTime(pItem->pszText, t)) {
+ fNeedsUpdate = ModStart(pItem->iItem, t);
+
+ *pResult = TRUE;
+ }
+ }
+ break;
+ case COL_END:
+ if (m_mode == TEXTSUB) {
+ int t;
+ if (ParseTime(pItem->pszText, t)) {
+ fNeedsUpdate = ModEnd(pItem->iItem, t);
+
+ *pResult = TRUE;
+ }
+ }
+ break;
+ case COL_TEXT:
+ if (m_mode == TEXTSUB) {
+ CString str = m_sts.GetStr(pItem->iItem, true);
+
+ if (str != pItem->pszText) {
+ fNeedsUpdate = true;
+ m_sts.SetStr(pItem->iItem, CString(pItem->pszText), true);
+ m_list.SetItemText(pItem->iItem, pItem->iSubItem, m_sts.GetStr(pItem->iItem, true));
+ }
+ }
+ break;
+ case COL_STYLE:
+ if (m_mode == TEXTSUB) {
+ CString str(pItem->pszText);
+ str.Trim();
+
+ if (!str.IsEmpty() && m_sts[pItem->iItem].style != str) {
+ fNeedsUpdate = true;
+
+ if (!m_sts.m_styles.Lookup(str)) {
+ m_sts.AddStyle(str, DNew STSStyle());
+ }
+
+ m_sts[pItem->iItem].style = str;
+
+ m_list.SetItemText(pItem->iItem, pItem->iSubItem, pItem->pszText);
+ }
+ }
+ break;
+ case COL_LAYER:
+ if (m_mode == TEXTSUB) {
+ int l;
+ if (_stscanf_s(pItem->pszText, _T("%d"), &l) == 1) {
+ fNeedsUpdate = true;
+ m_sts[pItem->iItem].layer = l;
+ CString str;
+ str.Format(_T("%d"), l);
+ m_list.SetItemText(pItem->iItem, pItem->iSubItem, str);
+ }
+ }
+ break;
+ case COL_ACTOR:
+ if (m_mode == TEXTSUB) {
+ CString str(pItem->pszText);
+ str.Trim();
+ if (!str.IsEmpty()) {
+ fNeedsUpdate = true;
+ m_sts[pItem->iItem].actor = str;
+ m_list.SetItemText(pItem->iItem, pItem->iSubItem, str);
+ }
+ }
+ break;
+ case COL_EFFECT:
+ if (m_mode == TEXTSUB) {
+ CString str(pItem->pszText);
+ str.Trim();
+ if (!str.IsEmpty()) {
+ fNeedsUpdate = true;
+ m_sts[pItem->iItem].effect = str;
+ m_list.SetItemText(pItem->iItem, pItem->iSubItem, str);
+ }
+ }
+ break;
+ }
+ }
+
+ if (fNeedsUpdate) {
+ UpdatePreview();
+ }
}
static int uintcomp(const void* i1, const void* i2)
{
- return (*((UINT*)i2) - *((UINT*)i1));
+ return (*((UINT*)i2) - * ((UINT*)i1));
}
void CPlayerSubresyncBar::OnRclickList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
-
- if (lpnmlv->iItem >= 0 && lpnmlv->iSubItem >= 0) {
- enum {
- TOGSEP=1,
- DUPITEM, DELITEM,
- RESETS, SETOS, SETCS, RESETE, SETOE, SETCE,
- STYLEFIRST, STYLELAST=STYLEFIRST+1000, STYLEEDIT,
- UNICODEYES, UNICODENO,
- LAYERDEC, LAYERINC,
- ACTORFIRST, ACTORLAST=ACTORFIRST+1000,
- EFFECTFIRST, EFFECTLAST=EFFECTFIRST+1000
- };
-
- CStringArray styles;
- CStringArray actors;
- CStringArray effects;
-
- CMenu m;
- m.CreatePopupMenu();
-
- if (m_mode == VOBSUB || m_mode == TEXTSUB) {
- m.AppendMenu(MF_STRING|MF_ENABLED, TOGSEP, ResStr(IDS_SUBRESYNC_SEPARATOR));
- m.AppendMenu(MF_SEPARATOR);
- if (m_mode == TEXTSUB) {
- m.AppendMenu(MF_STRING|MF_ENABLED, DUPITEM, ResStr(IDS_SUBRESYNC_DUPLICATE));
- }
- m.AppendMenu(MF_STRING|MF_ENABLED, DELITEM, ResStr(IDS_SUBRESYNC_DELETE));
- }
-
- switch (lpnmlv->iSubItem) {
- case COL_START:
- if (m_mode == VOBSUB || m_mode == TEXTSUB) {
- m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING|MF_ENABLED, RESETS, ResStr(IDS_SUBRESYNC_RESET) + _T("\tF1"));
- m.AppendMenu(MF_STRING|MF_ENABLED, SETOS, ResStr(IDS_SUBRESYNC_ORIGINAL) + _T("\tF3"));
- m.AppendMenu(MF_STRING|MF_ENABLED, SETCS, ResStr(IDS_SUBRESYNC_CURRENT) + _T("\tF5"));
- }
- break;
- case COL_END:
- if (m_mode == TEXTSUB) {
- m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING|MF_ENABLED, RESETE, ResStr(IDS_SUBRESYNC_RESET) + _T("\tF2"));
- m.AppendMenu(MF_STRING|MF_ENABLED, SETOE, ResStr(IDS_SUBRESYNC_ORIGINAL) + _T("\tF4"));
- m.AppendMenu(MF_STRING|MF_ENABLED, SETCE, ResStr(IDS_SUBRESYNC_CURRENT) + _T("\tF6"));
- }
- break;
- case COL_STYLE:
- if (m_mode == TEXTSUB) {
- m.AppendMenu(MF_SEPARATOR);
-
- int id = STYLEFIRST;
-
- POSITION pos = m_sts.m_styles.GetStartPosition();
- while (pos && id <= STYLELAST) {
- CString key;
- STSStyle* val;
- m_sts.m_styles.GetNextAssoc(pos, key, val);
- styles.Add(key);
- m.AppendMenu(MF_STRING|MF_ENABLED, id++, key);
- }
-
- if (id > STYLEFIRST && m_list.GetSelectedCount() == 1) {
- m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING|MF_ENABLED, STYLEEDIT, ResStr(IDS_SUBRESYNC_EDIT));
- }
- }
- break;
- case COL_UNICODE:
- if (m_mode == TEXTSUB) {
- m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING|MF_ENABLED, UNICODEYES, ResStr(IDS_SUBRESYNC_YES));
- m.AppendMenu(MF_STRING|MF_ENABLED, UNICODENO, ResStr(IDS_SUBRESYNC_NO));
- }
- break;
- case COL_LAYER:
- if (m_mode == TEXTSUB) {
- m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING|MF_ENABLED, LAYERDEC, ResStr(IDS_SUBRESYNC_DECREASE));
- m.AppendMenu(MF_STRING|MF_ENABLED, LAYERINC, ResStr(IDS_SUBRESYNC_INCREASE));
- }
- break;
- case COL_ACTOR:
- if (m_mode == TEXTSUB) {
- CMapStringToPtr actormap;
-
- for (size_t i = 0, j = m_sts.GetCount(); i < j; i++) {
- actormap[m_sts[i].actor] = NULL;
- }
-
- actormap.RemoveKey(_T(""));
-
- if (actormap.GetCount() > 0) {
- m.AppendMenu(MF_SEPARATOR);
-
- int id = ACTORFIRST;
-
- POSITION pos = actormap.GetStartPosition();
- while (pos && id <= ACTORLAST) {
- CString key;
- void* val;
- actormap.GetNextAssoc(pos, key, val);
-
- actors.Add(key);
-
- m.AppendMenu(MF_STRING|MF_ENABLED, id++, key);
- }
- }
- }
- break;
- case COL_EFFECT:
- if (m_mode == TEXTSUB) {
- CMapStringToPtr effectmap;
-
- for (size_t i = 0, j = m_sts.GetCount(); i < j; i++) {
- effectmap[m_sts[i].effect] = NULL;
- }
-
- effectmap.RemoveKey(_T(""));
-
- if (effectmap.GetCount() > 0) {
- m.AppendMenu(MF_SEPARATOR);
-
- int id = EFFECTFIRST;
-
- POSITION pos = effectmap.GetStartPosition();
- while (pos && id <= EFFECTLAST) {
- CString key;
- void* val;
- effectmap.GetNextAssoc(pos, key, val);
-
- effects.Add(key);
-
- m.AppendMenu(MF_STRING|MF_ENABLED, id++, key);
- }
- }
- }
- break;
- }
-
- CPoint p = lpnmlv->ptAction;
- ::MapWindowPoints(pNMHDR->hwndFrom, HWND_DESKTOP, &p, 1);
-
- UINT id = m.TrackPopupMenu(TPM_LEFTBUTTON|TPM_RETURNCMD, p.x, p.y, this);
-
- bool fNeedsUpdate = false;
-
- POSITION pos = m_list.GetFirstSelectedItemPosition();
- while (pos) {
- int iItem = m_list.GetNextSelectedItem(pos);
-
- SubTime& st = m_subtimes[iItem];
-
- switch (id) {
- case TOGSEP:
- m_list.SetItemData(iItem, m_list.GetItemData(iItem)^TSEP);
- m_list.Invalidate();
- fNeedsUpdate = true;
- break;
- case DUPITEM: {
- CUIntArray items;
- pos = m_list.GetFirstSelectedItemPosition();
- while (pos) {
- items.Add(m_list.GetNextSelectedItem(pos));
- }
-
- qsort(items.GetData(), items.GetCount(), sizeof(UINT), uintcomp);
-
- for (INT_PTR i = 0, l = items.GetCount(); i < l; i++) {
- iItem = items[i];
-
- STSEntry stse = m_sts[iItem];
- m_sts.InsertAt(iItem+1, stse);
-
- SubTime st = m_subtimes[iItem];
- m_subtimes.InsertAt(iItem+1, st);
-
- CHeaderCtrl* pHeader = (CHeaderCtrl*)m_list.GetDlgItem(0);
- int nColumnCount = pHeader->GetItemCount();
-
- CStringArray sa;
- sa.SetSize(nColumnCount);
- for (int col = 0; col < nColumnCount; col++) {
- sa[col] = m_list.GetItemText(iItem, col);
- }
-
- DWORD_PTR data = m_list.GetItemData(iItem);
- m_list.InsertItem(iItem+1, sa[0]);
- m_list.SetItemData(iItem+1, data);
- for (int col = 1; col < nColumnCount; col++) {
- m_list.SetItemText(iItem+1, col, sa[col]);
- }
- }
- }
-
- fNeedsUpdate = true;
- break;
- case DELITEM: {
- CUIntArray items;
- pos = m_list.GetFirstSelectedItemPosition();
- while (pos) {
- items.Add(m_list.GetNextSelectedItem(pos));
- }
-
- qsort(items.GetData(), items.GetCount(), sizeof(UINT), uintcomp);
-
- for (INT_PTR i = 0, l = items.GetCount(); i < l; i++) {
- iItem = items[i];
- m_sts.RemoveAt(iItem);
- m_subtimes.RemoveAt(iItem);
- m_list.DeleteItem(iItem);
- }
-
- iItem = items[items.GetCount()-1];
- if (iItem >= m_list.GetItemCount()) {
- iItem = m_list.GetItemCount()-1;
- }
-
- m_list.SetSelectionMark(iItem);
- }
- fNeedsUpdate = true;
- break;
- case RESETS: /*if (*/
- ModStart(iItem, st.orgstart, true);/*)*/
- fNeedsUpdate = true;
- break;
- case SETOS: /*if (*/
- ModStart(iItem, st.orgstart);/*)*/
- fNeedsUpdate = true;
- break;
- case SETCS: /*if (*/
- ModStart(iItem, (int)(m_rt/10000));/*)*/
- fNeedsUpdate = true;
- break;
- case RESETE: /*if (*/
- ModEnd(iItem, st.orgend, true);/*)*/
- fNeedsUpdate = true;
- break;
- case SETOE: /*if (*/
- ModEnd(iItem, st.orgend);/*)*/
- fNeedsUpdate = true;
- break;
- case SETCE: /*if (*/
- ModEnd(iItem, (int)(m_rt/10000));/*)*/
- fNeedsUpdate = true;
- break;
- default:
- if (STYLEFIRST <= id && id <= STYLELAST) {
- CString s = styles[id - STYLEFIRST];
- if (m_sts[iItem].style != s) {
- fNeedsUpdate = true;
- }
- m_sts[iItem].style = s;
- m_list.SetItemText(iItem, lpnmlv->iSubItem, s);
- } else if (id == STYLEEDIT) {
- CAutoPtrArray<CPPageSubStyle> pages;
- CAtlArray<STSStyle*> styles;
-
- STSStyle* stss = m_sts.GetStyle(iItem);
- int iSelPage = 0;
-
- POSITION pos = m_sts.m_styles.GetStartPosition();
- for (int i = 0; pos; i++) {
- CString key;
- STSStyle* val;
- m_sts.m_styles.GetNextAssoc(pos, key, val);
-
- CAutoPtr<CPPageSubStyle> page(DNew CPPageSubStyle());
- page->InitStyle(key, *val);
- pages.Add(page);
- styles.Add(val);
-
- if (stss == val) {
- iSelPage = i;
- }
- }
-
- CPropertySheet dlg(_T("Styles..."), this, iSelPage);
- for (size_t i = 0, l = pages.GetCount(); i < l; i++) {
- dlg.AddPage(pages[i]);
- }
-
- if (dlg.DoModal() == IDOK) {
- for (size_t j = 0, l = pages.GetCount(); j < l; j++) {
- stss = styles[j];
- pages[j]->GetStyle(*stss);
-
- for (size_t i = 0; i < m_sts.GetCount(); i++) {
- if (m_sts.GetStyle(i) == stss) {
- CString str;
- m_list.SetItemText(i, COL_TEXT, m_sts.GetStr(i, true));
- m_list.SetItemText(i, COL_FONT, stss->fontName);
- str.Format(_T("%d"), stss->charSet);
- m_list.SetItemText(i, COL_CHARSET, str);
- str.Format(_T("%d"), m_sts[i].layer);
- }
- }
- }
-
- fNeedsUpdate = true;
- }
- } else if (id == UNICODEYES || id == UNICODENO) {
- m_sts.ConvertUnicode(iItem, id == UNICODEYES);
- m_list.SetItemText(iItem, COL_TEXT, m_sts.GetStr(iItem, true));
- m_list.SetItemText(iItem, COL_UNICODE, m_sts.IsEntryUnicode(iItem) ? _T("yes") : _T("no"));
- fNeedsUpdate = true;
- } else if (id == LAYERDEC || id == LAYERINC) {
- int d = (id == LAYERDEC) ? -1 : (id == LAYERINC) ? +1 : 0;
- if (d != 0) {
- fNeedsUpdate = true;
- }
- m_sts[iItem].layer += d;
- CString s;
- s.Format(_T("%d"), m_sts[iItem].layer);
- m_list.SetItemText(iItem, lpnmlv->iSubItem, s);
- } else if (ACTORFIRST <= id && id <= ACTORLAST) {
- CString s = actors[id - ACTORFIRST];
- if (m_sts[iItem].actor != s) {
- fNeedsUpdate = true;
- }
- m_sts[iItem].actor = s;
- m_list.SetItemText(iItem, lpnmlv->iSubItem, s);
- } else if (EFFECTFIRST <= id && id <= EFFECTLAST) {
- CString s = effects[id - EFFECTFIRST];
- if (m_sts[iItem].effect != s) {
- fNeedsUpdate = true;
- }
- m_sts[iItem].effect = s;
- m_list.SetItemText(iItem, lpnmlv->iSubItem, s);
- }
- break;
- }
- }
-
- if (fNeedsUpdate) {
- UpdatePreview();
- }
- }
-
- *pResult = 0;
+ LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
+
+ if (lpnmlv->iItem >= 0 && lpnmlv->iSubItem >= 0) {
+ enum {
+ TOGSEP = 1,
+ DUPITEM, DELITEM,
+ RESETS, SETOS, SETCS, RESETE, SETOE, SETCE,
+ STYLEFIRST, STYLELAST = STYLEFIRST + 1000, STYLEEDIT,
+ UNICODEYES, UNICODENO,
+ LAYERDEC, LAYERINC,
+ ACTORFIRST, ACTORLAST = ACTORFIRST + 1000,
+ EFFECTFIRST, EFFECTLAST = EFFECTFIRST + 1000
+ };
+
+ CStringArray styles;
+ CStringArray actors;
+ CStringArray effects;
+
+ CMenu m;
+ m.CreatePopupMenu();
+
+ if (m_mode == VOBSUB || m_mode == TEXTSUB) {
+ m.AppendMenu(MF_STRING | MF_ENABLED, TOGSEP, ResStr(IDS_SUBRESYNC_SEPARATOR));
+ m.AppendMenu(MF_SEPARATOR);
+ if (m_mode == TEXTSUB) {
+ m.AppendMenu(MF_STRING | MF_ENABLED, DUPITEM, ResStr(IDS_SUBRESYNC_DUPLICATE));
+ }
+ m.AppendMenu(MF_STRING | MF_ENABLED, DELITEM, ResStr(IDS_SUBRESYNC_DELETE));
+ }
+
+ switch (lpnmlv->iSubItem) {
+ case COL_START:
+ if (m_mode == VOBSUB || m_mode == TEXTSUB) {
+ m.AppendMenu(MF_SEPARATOR);
+ m.AppendMenu(MF_STRING | MF_ENABLED, RESETS, ResStr(IDS_SUBRESYNC_RESET) + _T("\tF1"));
+ m.AppendMenu(MF_STRING | MF_ENABLED, SETOS, ResStr(IDS_SUBRESYNC_ORIGINAL) + _T("\tF3"));
+ m.AppendMenu(MF_STRING | MF_ENABLED, SETCS, ResStr(IDS_SUBRESYNC_CURRENT) + _T("\tF5"));
+ }
+ break;
+ case COL_END:
+ if (m_mode == TEXTSUB) {
+ m.AppendMenu(MF_SEPARATOR);
+ m.AppendMenu(MF_STRING | MF_ENABLED, RESETE, ResStr(IDS_SUBRESYNC_RESET) + _T("\tF2"));
+ m.AppendMenu(MF_STRING | MF_ENABLED, SETOE, ResStr(IDS_SUBRESYNC_ORIGINAL) + _T("\tF4"));
+ m.AppendMenu(MF_STRING | MF_ENABLED, SETCE, ResStr(IDS_SUBRESYNC_CURRENT) + _T("\tF6"));
+ }
+ break;
+ case COL_STYLE:
+ if (m_mode == TEXTSUB) {
+ m.AppendMenu(MF_SEPARATOR);
+
+ int id = STYLEFIRST;
+
+ POSITION pos = m_sts.m_styles.GetStartPosition();
+ while (pos && id <= STYLELAST) {
+ CString key;
+ STSStyle* val;
+ m_sts.m_styles.GetNextAssoc(pos, key, val);
+ styles.Add(key);
+ m.AppendMenu(MF_STRING | MF_ENABLED, id++, key);
+ }
+
+ if (id > STYLEFIRST && m_list.GetSelectedCount() == 1) {
+ m.AppendMenu(MF_SEPARATOR);
+ m.AppendMenu(MF_STRING | MF_ENABLED, STYLEEDIT, ResStr(IDS_SUBRESYNC_EDIT));
+ }
+ }
+ break;
+ case COL_UNICODE:
+ if (m_mode == TEXTSUB) {
+ m.AppendMenu(MF_SEPARATOR);
+ m.AppendMenu(MF_STRING | MF_ENABLED, UNICODEYES, ResStr(IDS_SUBRESYNC_YES));
+ m.AppendMenu(MF_STRING | MF_ENABLED, UNICODENO, ResStr(IDS_SUBRESYNC_NO));
+ }
+ break;
+ case COL_LAYER:
+ if (m_mode == TEXTSUB) {
+ m.AppendMenu(MF_SEPARATOR);
+ m.AppendMenu(MF_STRING | MF_ENABLED, LAYERDEC, ResStr(IDS_SUBRESYNC_DECREASE));
+ m.AppendMenu(MF_STRING | MF_ENABLED, LAYERINC, ResStr(IDS_SUBRESYNC_INCREASE));
+ }
+ break;
+ case COL_ACTOR:
+ if (m_mode == TEXTSUB) {
+ CMapStringToPtr actormap;
+
+ for (size_t i = 0, j = m_sts.GetCount(); i < j; i++) {
+ actormap[m_sts[i].actor] = NULL;
+ }
+
+ actormap.RemoveKey(_T(""));
+
+ if (actormap.GetCount() > 0) {
+ m.AppendMenu(MF_SEPARATOR);
+
+ int id = ACTORFIRST;
+
+ POSITION pos = actormap.GetStartPosition();
+ while (pos && id <= ACTORLAST) {
+ CString key;
+ void* val;
+ actormap.GetNextAssoc(pos, key, val);
+
+ actors.Add(key);
+
+ m.AppendMenu(MF_STRING | MF_ENABLED, id++, key);
+ }
+ }
+ }
+ break;
+ case COL_EFFECT:
+ if (m_mode == TEXTSUB) {
+ CMapStringToPtr effectmap;
+
+ for (size_t i = 0, j = m_sts.GetCount(); i < j; i++) {
+ effectmap[m_sts[i].effect] = NULL;
+ }
+
+ effectmap.RemoveKey(_T(""));
+
+ if (effectmap.GetCount() > 0) {
+ m.AppendMenu(MF_SEPARATOR);
+
+ int id = EFFECTFIRST;
+
+ POSITION pos = effectmap.GetStartPosition();
+ while (pos && id <= EFFECTLAST) {
+ CString key;
+ void* val;
+ effectmap.GetNextAssoc(pos, key, val);
+
+ effects.Add(key);
+
+ m.AppendMenu(MF_STRING | MF_ENABLED, id++, key);
+ }
+ }
+ }
+ break;
+ }
+
+ CPoint p = lpnmlv->ptAction;
+ ::MapWindowPoints(pNMHDR->hwndFrom, HWND_DESKTOP, &p, 1);
+
+ UINT id = m.TrackPopupMenu(TPM_LEFTBUTTON | TPM_RETURNCMD, p.x, p.y, this);
+
+ bool fNeedsUpdate = false;
+
+ POSITION pos = m_list.GetFirstSelectedItemPosition();
+ while (pos) {
+ int iItem = m_list.GetNextSelectedItem(pos);
+
+ SubTime& st = m_subtimes[iItem];
+
+ switch (id) {
+ case TOGSEP:
+ m_list.SetItemData(iItem, m_list.GetItemData(iItem) ^ TSEP);
+ m_list.Invalidate();
+ fNeedsUpdate = true;
+ break;
+ case DUPITEM: {
+ CUIntArray items;
+ pos = m_list.GetFirstSelectedItemPosition();
+ while (pos) {
+ items.Add(m_list.GetNextSelectedItem(pos));
+ }
+
+ qsort(items.GetData(), items.GetCount(), sizeof(UINT), uintcomp);
+
+ for (INT_PTR i = 0, l = items.GetCount(); i < l; i++) {
+ iItem = items[i];
+
+ STSEntry stse = m_sts[iItem];
+ m_sts.InsertAt(iItem + 1, stse);
+
+ SubTime st = m_subtimes[iItem];
+ m_subtimes.InsertAt(iItem + 1, st);
+
+ CHeaderCtrl* pHeader = (CHeaderCtrl*)m_list.GetDlgItem(0);
+ int nColumnCount = pHeader->GetItemCount();
+
+ CStringArray sa;
+ sa.SetSize(nColumnCount);
+ for (int col = 0; col < nColumnCount; col++) {
+ sa[col] = m_list.GetItemText(iItem, col);
+ }
+
+ DWORD_PTR data = m_list.GetItemData(iItem);
+ m_list.InsertItem(iItem + 1, sa[0]);
+ m_list.SetItemData(iItem + 1, data);
+ for (int col = 1; col < nColumnCount; col++) {
+ m_list.SetItemText(iItem + 1, col, sa[col]);
+ }
+ }
+ }
+
+ fNeedsUpdate = true;
+ break;
+ case DELITEM: {
+ CUIntArray items;
+ pos = m_list.GetFirstSelectedItemPosition();
+ while (pos) {
+ items.Add(m_list.GetNextSelectedItem(pos));
+ }
+
+ qsort(items.GetData(), items.GetCount(), sizeof(UINT), uintcomp);
+
+ for (INT_PTR i = 0, l = items.GetCount(); i < l; i++) {
+ iItem = items[i];
+ m_sts.RemoveAt(iItem);
+ m_subtimes.RemoveAt(iItem);
+ m_list.DeleteItem(iItem);
+ }
+
+ iItem = items[items.GetCount() - 1];
+ if (iItem >= m_list.GetItemCount()) {
+ iItem = m_list.GetItemCount() - 1;
+ }
+
+ m_list.SetSelectionMark(iItem);
+ }
+ fNeedsUpdate = true;
+ break;
+ case RESETS: /*if (*/
+ ModStart(iItem, st.orgstart, true);/*)*/
+ fNeedsUpdate = true;
+ break;
+ case SETOS: /*if (*/
+ ModStart(iItem, st.orgstart);/*)*/
+ fNeedsUpdate = true;
+ break;
+ case SETCS: /*if (*/
+ ModStart(iItem, (int)(m_rt / 10000)); /*)*/
+ fNeedsUpdate = true;
+ break;
+ case RESETE: /*if (*/
+ ModEnd(iItem, st.orgend, true);/*)*/
+ fNeedsUpdate = true;
+ break;
+ case SETOE: /*if (*/
+ ModEnd(iItem, st.orgend);/*)*/
+ fNeedsUpdate = true;
+ break;
+ case SETCE: /*if (*/
+ ModEnd(iItem, (int)(m_rt / 10000)); /*)*/
+ fNeedsUpdate = true;
+ break;
+ default:
+ if (STYLEFIRST <= id && id <= STYLELAST) {
+ CString s = styles[id - STYLEFIRST];
+ if (m_sts[iItem].style != s) {
+ fNeedsUpdate = true;
+ }
+ m_sts[iItem].style = s;
+ m_list.SetItemText(iItem, lpnmlv->iSubItem, s);
+ } else if (id == STYLEEDIT) {
+ CAutoPtrArray<CPPageSubStyle> pages;
+ CAtlArray<STSStyle*> styles;
+
+ STSStyle* stss = m_sts.GetStyle(iItem);
+ int iSelPage = 0;
+
+ POSITION pos = m_sts.m_styles.GetStartPosition();
+ for (int i = 0; pos; i++) {
+ CString key;
+ STSStyle* val;
+ m_sts.m_styles.GetNextAssoc(pos, key, val);
+
+ CAutoPtr<CPPageSubStyle> page(DNew CPPageSubStyle());
+ page->InitStyle(key, *val);
+ pages.Add(page);
+ styles.Add(val);
+
+ if (stss == val) {
+ iSelPage = i;
+ }
+ }
+
+ CPropertySheet dlg(_T("Styles..."), this, iSelPage);
+ for (size_t i = 0, l = pages.GetCount(); i < l; i++) {
+ dlg.AddPage(pages[i]);
+ }
+
+ if (dlg.DoModal() == IDOK) {
+ for (size_t j = 0, l = pages.GetCount(); j < l; j++) {
+ stss = styles[j];
+ pages[j]->GetStyle(*stss);
+
+ for (size_t i = 0; i < m_sts.GetCount(); i++) {
+ if (m_sts.GetStyle(i) == stss) {
+ CString str;
+ m_list.SetItemText(i, COL_TEXT, m_sts.GetStr(i, true));
+ m_list.SetItemText(i, COL_FONT, stss->fontName);
+ str.Format(_T("%d"), stss->charSet);
+ m_list.SetItemText(i, COL_CHARSET, str);
+ str.Format(_T("%d"), m_sts[i].layer);
+ }
+ }
+ }
+
+ fNeedsUpdate = true;
+ }
+ } else if (id == UNICODEYES || id == UNICODENO) {
+ m_sts.ConvertUnicode(iItem, id == UNICODEYES);
+ m_list.SetItemText(iItem, COL_TEXT, m_sts.GetStr(iItem, true));
+ m_list.SetItemText(iItem, COL_UNICODE, m_sts.IsEntryUnicode(iItem) ? _T("yes") : _T("no"));
+ fNeedsUpdate = true;
+ } else if (id == LAYERDEC || id == LAYERINC) {
+ int d = (id == LAYERDEC) ? -1 : (id == LAYERINC) ? +1 : 0;
+ if (d != 0) {
+ fNeedsUpdate = true;
+ }
+ m_sts[iItem].layer += d;
+ CString s;
+ s.Format(_T("%d"), m_sts[iItem].layer);
+ m_list.SetItemText(iItem, lpnmlv->iSubItem, s);
+ } else if (ACTORFIRST <= id && id <= ACTORLAST) {
+ CString s = actors[id - ACTORFIRST];
+ if (m_sts[iItem].actor != s) {
+ fNeedsUpdate = true;
+ }
+ m_sts[iItem].actor = s;
+ m_list.SetItemText(iItem, lpnmlv->iSubItem, s);
+ } else if (EFFECTFIRST <= id && id <= EFFECTLAST) {
+ CString s = effects[id - EFFECTFIRST];
+ if (m_sts[iItem].effect != s) {
+ fNeedsUpdate = true;
+ }
+ m_sts[iItem].effect = s;
+ m_list.SetItemText(iItem, lpnmlv->iSubItem, s);
+ }
+ break;
+ }
+ }
+
+ if (fNeedsUpdate) {
+ UpdatePreview();
+ }
+ }
+
+ *pResult = 0;
}
void CPlayerSubresyncBar::OnNMDblclkList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
+ LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
- if (lpnmlv->iItem >= 0 && lpnmlv->iSubItem >= 0 && (m_mode == VOBSUB || m_mode == TEXTSUB)) {
- if (CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd()) {
- int t = 0;
- if (lpnmlv->iSubItem > COL_PREVEND || !ParseTime(m_list.GetItemText(lpnmlv->iItem, lpnmlv->iSubItem), t, false)) {
- t = m_sts[lpnmlv->iItem].start;
- }
+ if (lpnmlv->iItem >= 0 && lpnmlv->iSubItem >= 0 && (m_mode == VOBSUB || m_mode == TEXTSUB)) {
+ if (CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd()) {
+ int t = 0;
+ if (lpnmlv->iSubItem > COL_PREVEND || !ParseTime(m_list.GetItemText(lpnmlv->iItem, lpnmlv->iSubItem), t, false)) {
+ t = m_sts[lpnmlv->iItem].start;
+ }
- REFERENCE_TIME rt = (REFERENCE_TIME)t*10000;
+ REFERENCE_TIME rt = (REFERENCE_TIME)t * 10000;
- pFrame->SeekTo(rt);
- }
- }
+ pFrame->SeekTo(rt);
+ }
+ }
- *pResult = 0;
+ *pResult = 0;
}
void CPlayerSubresyncBar::OnLvnKeydownList(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMLVKEYDOWN pLVKeyDown = reinterpret_cast<LPNMLVKEYDOWN>(pNMHDR);
- UNREFERENCED_PARAMETER(pLVKeyDown);
+ LPNMLVKEYDOWN pLVKeyDown = reinterpret_cast<LPNMLVKEYDOWN>(pNMHDR);
+ UNREFERENCED_PARAMETER(pLVKeyDown);
- *pResult = 0;
+ *pResult = 0;
}
static CUIntArray m_itemGroups;
@@ -1132,220 +1132,220 @@ static int m_totalGroups;
void CPlayerSubresyncBar::OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult)
{
- NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
-
- *pResult = CDRF_DODEFAULT;
-
- if (CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage) {
- m_itemGroups.SetSize(m_list.GetItemCount());
- m_totalGroups = 0;
- for (int i = 0, j = m_list.GetItemCount(); i < j; i++) {
- if (m_list.GetItemData(i)&TSEP) {
- m_totalGroups++;
- }
- m_itemGroups[i] = m_totalGroups;
- }
-
- *pResult = CDRF_NOTIFYPOSTPAINT|CDRF_NOTIFYITEMDRAW;
- } else if (CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage) {
- pLVCD->nmcd.uItemState &= ~CDIS_FOCUS;
-
- *pResult = CDRF_NOTIFYPOSTPAINT|CDRF_NOTIFYSUBITEMDRAW;
- } else if ((CDDS_ITEMPREPAINT|CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage) {
- COLORREF clrText;
- COLORREF clrTextBk;
-
- if ((pLVCD->iSubItem == COL_START || pLVCD->iSubItem == COL_END || pLVCD->iSubItem == COL_TEXT || pLVCD->iSubItem == COL_STYLE
- || pLVCD->iSubItem == COL_LAYER || pLVCD->iSubItem == COL_ACTOR || pLVCD->iSubItem == COL_EFFECT)
- && m_mode == TEXTSUB) {
- clrText = 0;
- } else if ((pLVCD->iSubItem == COL_START)
- && m_mode == VOBSUB) {
- clrText = 0;
- } else {
- clrText = 0x606060;
- }
-
- clrTextBk = 0xffffff;
- // if (m_totalGroups > 0)
- clrTextBk -= ((m_itemGroups[pLVCD->nmcd.dwItemSpec]&1) ? 0x100010 : 0x200020);
-
- if (m_sts[pLVCD->nmcd.dwItemSpec].start <= m_rt/10000 && m_rt/10000 < m_sts[pLVCD->nmcd.dwItemSpec].end) {
- clrText |= 0xFF;
- }
-
- int nCheck = (int)m_list.GetItemData((int)pLVCD->nmcd.dwItemSpec);
-
- if ((nCheck&1) && (pLVCD->iSubItem == COL_START || pLVCD->iSubItem == COL_PREVSTART)) {
- clrTextBk = 0xffddbb;
- } else if ((nCheck&4) && (/*pLVCD->iSubItem == COL_START ||*/ pLVCD->iSubItem == COL_PREVSTART)) {
- clrTextBk = 0xffeedd;
- }
-
- if ((nCheck&2) && (pLVCD->iSubItem == COL_END || pLVCD->iSubItem == COL_PREVEND)) {
- clrTextBk = 0xffddbb;
- } else if ((nCheck&8) && (/*pLVCD->iSubItem == COL_END ||*/ pLVCD->iSubItem == COL_PREVEND)) {
- clrTextBk = 0xffeedd;
- }
-
- pLVCD->clrText = clrText;
- pLVCD->clrTextBk = clrTextBk;
-
- *pResult = CDRF_NOTIFYPOSTPAINT;
- } else if ((CDDS_ITEMPOSTPAINT|CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage) {
- // *pResult = CDRF_DODEFAULT;
- } else if (CDDS_ITEMPOSTPAINT == pLVCD->nmcd.dwDrawStage) {
- int nItem = static_cast<int>(pLVCD->nmcd.dwItemSpec);
-
- LVITEM rItem;
- ZeroMemory(&rItem, sizeof(LVITEM));
- rItem.mask = LVIF_IMAGE | LVIF_STATE;
- rItem.iItem = nItem;
- rItem.stateMask = LVIS_SELECTED;
- m_list.GetItem(&rItem);
-
- {
- CDC* pDC = CDC::FromHandle(pLVCD->nmcd.hdc);
-
- CRect rcItem;
- m_list.GetItemRect(nItem, &rcItem, LVIR_BOUNDS);
-
- {
- bool fSeparator = nItem < m_list.GetItemCount()-1 && (m_list.GetItemData(nItem+1)&TSEP);
- CPen p(PS_INSIDEFRAME, 1, fSeparator ? 0x404040 : 0xe0e0e0);
- CPen* old = pDC->SelectObject(&p);
- pDC->MoveTo(CPoint(rcItem.left, rcItem.bottom-1));
- pDC->LineTo(CPoint(rcItem.right, rcItem.bottom-1));
- pDC->SelectObject(old);
- }
-
- {
- CPen p(PS_INSIDEFRAME, 1, 0xe0e0e0);
- CPen* old = pDC->SelectObject(&p);
-
- CHeaderCtrl* pHeader = (CHeaderCtrl*)m_list.GetDlgItem(0);
- int nColumnCount = pHeader->GetItemCount();
-
- // Get the column offset
- int offset = rcItem.left;
- for (int i = 0; i < nColumnCount; i++) {
- offset += m_list.GetColumnWidth(i);
- pDC->MoveTo(CPoint(offset, rcItem.top));
- pDC->LineTo(CPoint(offset, rcItem.bottom));
- }
-
- pDC->SelectObject(old);
- }
-
- *pResult = CDRF_SKIPDEFAULT;
- }
- } else if (CDDS_POSTPAINT == pLVCD->nmcd.dwDrawStage) {
- }
+ NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
+
+ *pResult = CDRF_DODEFAULT;
+
+ if (CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage) {
+ m_itemGroups.SetSize(m_list.GetItemCount());
+ m_totalGroups = 0;
+ for (int i = 0, j = m_list.GetItemCount(); i < j; i++) {
+ if (m_list.GetItemData(i)&TSEP) {
+ m_totalGroups++;
+ }
+ m_itemGroups[i] = m_totalGroups;
+ }
+
+ *pResult = CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYITEMDRAW;
+ } else if (CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage) {
+ pLVCD->nmcd.uItemState &= ~CDIS_FOCUS;
+
+ *pResult = CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYSUBITEMDRAW;
+ } else if ((CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage) {
+ COLORREF clrText;
+ COLORREF clrTextBk;
+
+ if ((pLVCD->iSubItem == COL_START || pLVCD->iSubItem == COL_END || pLVCD->iSubItem == COL_TEXT || pLVCD->iSubItem == COL_STYLE
+ || pLVCD->iSubItem == COL_LAYER || pLVCD->iSubItem == COL_ACTOR || pLVCD->iSubItem == COL_EFFECT)
+ && m_mode == TEXTSUB) {
+ clrText = 0;
+ } else if ((pLVCD->iSubItem == COL_START)
+ && m_mode == VOBSUB) {
+ clrText = 0;
+ } else {
+ clrText = 0x606060;
+ }
+
+ clrTextBk = 0xffffff;
+ // if (m_totalGroups > 0)
+ clrTextBk -= ((m_itemGroups[pLVCD->nmcd.dwItemSpec] & 1) ? 0x100010 : 0x200020);
+
+ if (m_sts[pLVCD->nmcd.dwItemSpec].start <= m_rt / 10000 && m_rt / 10000 < m_sts[pLVCD->nmcd.dwItemSpec].end) {
+ clrText |= 0xFF;
+ }
+
+ int nCheck = (int)m_list.GetItemData((int)pLVCD->nmcd.dwItemSpec);
+
+ if ((nCheck & 1) && (pLVCD->iSubItem == COL_START || pLVCD->iSubItem == COL_PREVSTART)) {
+ clrTextBk = 0xffddbb;
+ } else if ((nCheck & 4) && (/*pLVCD->iSubItem == COL_START ||*/ pLVCD->iSubItem == COL_PREVSTART)) {
+ clrTextBk = 0xffeedd;
+ }
+
+ if ((nCheck & 2) && (pLVCD->iSubItem == COL_END || pLVCD->iSubItem == COL_PREVEND)) {
+ clrTextBk = 0xffddbb;
+ } else if ((nCheck & 8) && (/*pLVCD->iSubItem == COL_END ||*/ pLVCD->iSubItem == COL_PREVEND)) {
+ clrTextBk = 0xffeedd;
+ }
+
+ pLVCD->clrText = clrText;
+ pLVCD->clrTextBk = clrTextBk;
+
+ *pResult = CDRF_NOTIFYPOSTPAINT;
+ } else if ((CDDS_ITEMPOSTPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage) {
+ // *pResult = CDRF_DODEFAULT;
+ } else if (CDDS_ITEMPOSTPAINT == pLVCD->nmcd.dwDrawStage) {
+ int nItem = static_cast<int>(pLVCD->nmcd.dwItemSpec);
+
+ LVITEM rItem;
+ ZeroMemory(&rItem, sizeof(LVITEM));
+ rItem.mask = LVIF_IMAGE | LVIF_STATE;
+ rItem.iItem = nItem;
+ rItem.stateMask = LVIS_SELECTED;
+ m_list.GetItem(&rItem);
+
+ {
+ CDC* pDC = CDC::FromHandle(pLVCD->nmcd.hdc);
+
+ CRect rcItem;
+ m_list.GetItemRect(nItem, &rcItem, LVIR_BOUNDS);
+
+ {
+ bool fSeparator = nItem < m_list.GetItemCount() - 1 && (m_list.GetItemData(nItem + 1)&TSEP);
+ CPen p(PS_INSIDEFRAME, 1, fSeparator ? 0x404040 : 0xe0e0e0);
+ CPen* old = pDC->SelectObject(&p);
+ pDC->MoveTo(CPoint(rcItem.left, rcItem.bottom - 1));
+ pDC->LineTo(CPoint(rcItem.right, rcItem.bottom - 1));
+ pDC->SelectObject(old);
+ }
+
+ {
+ CPen p(PS_INSIDEFRAME, 1, 0xe0e0e0);
+ CPen* old = pDC->SelectObject(&p);
+
+ CHeaderCtrl* pHeader = (CHeaderCtrl*)m_list.GetDlgItem(0);
+ int nColumnCount = pHeader->GetItemCount();
+
+ // Get the column offset
+ int offset = rcItem.left;
+ for (int i = 0; i < nColumnCount; i++) {
+ offset += m_list.GetColumnWidth(i);
+ pDC->MoveTo(CPoint(offset, rcItem.top));
+ pDC->LineTo(CPoint(offset, rcItem.bottom));
+ }
+
+ pDC->SelectObject(old);
+ }
+
+ *pResult = CDRF_SKIPDEFAULT;
+ }
+ } else if (CDDS_POSTPAINT == pLVCD->nmcd.dwDrawStage) {
+ }
}
bool CPlayerSubresyncBar::IsShortCut(MSG* pMsg)
{
- if (pMsg->message == WM_KEYDOWN && VK_F1 <= pMsg->wParam && pMsg->wParam <= VK_F6) {
- int iItem = -1;
-
- bool fNeedsUpdate = false;
- bool fStep = false;
-
- POSITION pos = m_list.GetFirstSelectedItemPosition();
- while (pos) {
- iItem = m_list.GetNextSelectedItem(pos);
-
- SubTime& st = m_subtimes[iItem];
-
- switch (pMsg->wParam) {
- case VK_F1: /*if (*/
- ModStart(iItem, st.orgstart, true);/*)*/
- fNeedsUpdate = true;
- break;
- case VK_F3: /*if (*/
- ModStart(iItem, st.orgstart);/*)*/
- fNeedsUpdate = true;
- break;
- case VK_F5: /*if (*/
- ModStart(iItem, (int)(m_rt/10000));/*)*/
- fNeedsUpdate = true;
- break;
- case VK_F2: /*if (*/
- ModEnd(iItem, st.orgend, true);/*)*/
- fNeedsUpdate = true;
- break;
- case VK_F4: /*if (*/
- ModEnd(iItem, st.orgend);/*)*/
- fNeedsUpdate = true;
- break;
- case VK_F6: /*if (*/
- ModEnd(iItem, (int)(m_rt/10000));/*)*/
- fNeedsUpdate = fStep = true;
- break;
- }
- }
-
- if (fNeedsUpdate) {
- if (fStep && m_list.GetSelectedCount() == 1 && iItem < m_list.GetItemCount()-1) {
- m_list.SetItemState(iItem, 0, LVIS_SELECTED);
- m_list.SetItemState(iItem+1, LVIS_SELECTED, LVIS_SELECTED);
- m_list.SetSelectionMark(iItem+1);
- m_list.EnsureVisible(iItem+1, false);
- }
-
- UpdatePreview();
-
- return true;
- }
- }
-
- return false;
+ if (pMsg->message == WM_KEYDOWN && VK_F1 <= pMsg->wParam && pMsg->wParam <= VK_F6) {
+ int iItem = -1;
+
+ bool fNeedsUpdate = false;
+ bool fStep = false;
+
+ POSITION pos = m_list.GetFirstSelectedItemPosition();
+ while (pos) {
+ iItem = m_list.GetNextSelectedItem(pos);
+
+ SubTime& st = m_subtimes[iItem];
+
+ switch (pMsg->wParam) {
+ case VK_F1: /*if (*/
+ ModStart(iItem, st.orgstart, true);/*)*/
+ fNeedsUpdate = true;
+ break;
+ case VK_F3: /*if (*/
+ ModStart(iItem, st.orgstart);/*)*/
+ fNeedsUpdate = true;
+ break;
+ case VK_F5: /*if (*/
+ ModStart(iItem, (int)(m_rt / 10000)); /*)*/
+ fNeedsUpdate = true;
+ break;
+ case VK_F2: /*if (*/
+ ModEnd(iItem, st.orgend, true);/*)*/
+ fNeedsUpdate = true;
+ break;
+ case VK_F4: /*if (*/
+ ModEnd(iItem, st.orgend);/*)*/
+ fNeedsUpdate = true;
+ break;
+ case VK_F6: /*if (*/
+ ModEnd(iItem, (int)(m_rt / 10000)); /*)*/
+ fNeedsUpdate = fStep = true;
+ break;
+ }
+ }
+
+ if (fNeedsUpdate) {
+ if (fStep && m_list.GetSelectedCount() == 1 && iItem < m_list.GetItemCount() - 1) {
+ m_list.SetItemState(iItem, 0, LVIS_SELECTED);
+ m_list.SetItemState(iItem + 1, LVIS_SELECTED, LVIS_SELECTED);
+ m_list.SetSelectionMark(iItem + 1);
+ m_list.EnsureVisible(iItem + 1, false);
+ }
+
+ UpdatePreview();
+
+ return true;
+ }
+ }
+
+ return false;
}
int CPlayerSubresyncBar::FindNearestSub(__int64& rtPos, bool bForward)
{
- int lCurTime = (int)(rtPos / 10000) + (bForward ? 1 : -1);
-
- if (m_subtimes.GetCount() == 0) {
- rtPos = max (0, rtPos + (bForward ? 1 : -1) * 50000000);
- return -2;
- }
-
- if (lCurTime < m_subtimes[0].newstart) {
- rtPos = m_subtimes[0].newstart * 10000;
- return 0;
- }
-
- for (int i = 1, j = m_sts.GetCount(); i < j; i++) {
- if ((lCurTime >= m_subtimes[i-1].newstart) && (lCurTime < m_subtimes[i].newstart)) {
- rtPos = bForward ? (__int64)m_subtimes[i].newstart * 10000 : (__int64)m_subtimes[i-1].newstart * 10000;
- return bForward ? i : i-1;
- }
- }
-
- return -1;
+ int lCurTime = (int)(rtPos / 10000) + (bForward ? 1 : -1);
+
+ if (m_subtimes.GetCount() == 0) {
+ rtPos = max(0, rtPos + (bForward ? 1 : -1) * 50000000);
+ return -2;
+ }
+
+ if (lCurTime < m_subtimes[0].newstart) {
+ rtPos = m_subtimes[0].newstart * 10000;
+ return 0;
+ }
+
+ for (int i = 1, j = m_sts.GetCount(); i < j; i++) {
+ if ((lCurTime >= m_subtimes[i - 1].newstart) && (lCurTime < m_subtimes[i].newstart)) {
+ rtPos = bForward ? (__int64)m_subtimes[i].newstart * 10000 : (__int64)m_subtimes[i - 1].newstart * 10000;
+ return bForward ? i : i - 1;
+ }
+ }
+
+ return -1;
}
bool CPlayerSubresyncBar::ShiftSubtitle(int nItem, long lValue, __int64& rtPos)
{
- bool bRet = false;
-
- if ((nItem == 0) || (m_subtimes[nItem-1].newend < m_subtimes[nItem].newstart + lValue)) {
- for (size_t i= nItem; i<m_sts.GetCount(); i++) {
- m_subtimes[i].newstart += lValue;
- m_subtimes[i].newend += lValue;
- m_subtimes[i].orgstart += lValue;
- m_subtimes[i].orgend += lValue;
- }
- UpdatePreview();
- SaveSubtitle();
- bRet = true;
- rtPos = (__int64)m_subtimes[nItem].newstart * 10000;
- }
- return bRet;
+ bool bRet = false;
+
+ if ((nItem == 0) || (m_subtimes[nItem - 1].newend < m_subtimes[nItem].newstart + lValue)) {
+ for (size_t i = nItem; i < m_sts.GetCount(); i++) {
+ m_subtimes[i].newstart += lValue;
+ m_subtimes[i].newend += lValue;
+ m_subtimes[i].orgstart += lValue;
+ m_subtimes[i].orgend += lValue;
+ }
+ UpdatePreview();
+ SaveSubtitle();
+ bRet = true;
+ rtPos = (__int64)m_subtimes[nItem].newstart * 10000;
+ }
+ return bRet;
}
bool CPlayerSubresyncBar::SaveToDisk()
{
- return m_sts.SaveAs (m_sts.m_path, m_sts.m_exttype);
+ return m_sts.SaveAs(m_sts.m_path, m_sts.m_exttype);
}
diff --git a/src/mpc-hc/PlayerSubresyncBar.h b/src/mpc-hc/PlayerSubresyncBar.h
index d6ac3f9fd..32f02e64e 100644
--- a/src/mpc-hc/PlayerSubresyncBar.h
+++ b/src/mpc-hc/PlayerSubresyncBar.h
@@ -34,87 +34,87 @@
class CPlayerSubresyncBar : public CPlayerBar
{
- DECLARE_DYNAMIC(CPlayerSubresyncBar)
+ DECLARE_DYNAMIC(CPlayerSubresyncBar)
private:
- CPlayerListCtrl m_list;
+ CPlayerListCtrl m_list;
- CFont m_font;
+ CFont m_font;
- CCritSec* m_pSubLock;
- CComPtr<ISubStream> m_pSubStream;
+ CCritSec* m_pSubLock;
+ CComPtr<ISubStream> m_pSubStream;
- int m_lastSegment;
- __int64 m_rt;
+ int m_lastSegment;
+ __int64 m_rt;
- enum {
- // TEXTSUB
- COL_START=0, COL_END, COL_PREVSTART, COL_PREVEND, COL_TEXT, COL_STYLE, COL_FONT, COL_CHARSET, COL_UNICODE, COL_LAYER, COL_ACTOR, COL_EFFECT,
- // VOBSUB
- /* ........... same as TEXTSUB ............. */ COL_VOBID=COL_TEXT, COL_CELLID, COL_FORCED,
- };
+ enum {
+ // TEXTSUB
+ COL_START = 0, COL_END, COL_PREVSTART, COL_PREVEND, COL_TEXT, COL_STYLE, COL_FONT, COL_CHARSET, COL_UNICODE, COL_LAYER, COL_ACTOR, COL_EFFECT,
+ // VOBSUB
+ /* ........... same as TEXTSUB ............. */ COL_VOBID = COL_TEXT, COL_CELLID, COL_FORCED,
+ };
- enum {NONE = 0, VOBSUB, TEXTSUB};
- int m_mode;
+ enum {NONE = 0, VOBSUB, TEXTSUB};
+ int m_mode;
- bool m_fUnlink;
+ bool m_fUnlink;
- typedef struct {
- int orgstart, newstart, orgend, newend;
- } SubTime;
- CAtlArray<SubTime> m_subtimes;
+ typedef struct {
+ int orgstart, newstart, orgend, newend;
+ } SubTime;
+ CAtlArray<SubTime> m_subtimes;
- // CRenderedTextSubtitle m_sts;
- CSimpleTextSubtitle m_sts;
+ // CRenderedTextSubtitle m_sts;
+ CSimpleTextSubtitle m_sts;
- int GetStartTime(int iItem), GetEndTime(int iItem);
- void FormatTime(int iItem, TCHAR* buff, size_t buffLen, int time /* 0:start, 1:newstart, 2:preview */, bool fEnd);
+ int GetStartTime(int iItem), GetEndTime(int iItem);
+ void FormatTime(int iItem, TCHAR* buff, size_t buffLen, int time /* 0:start, 1:newstart, 2:preview */, bool fEnd);
- void UpdatePreview(), UpdateStrings();
+ void UpdatePreview(), UpdateStrings();
- enum {TSMOD=1, TEMOD=2, TSADJ=4, TEADJ=8, TSEP=0x80000000};
+ enum {TSMOD = 1, TEMOD = 2, TSADJ = 4, TEADJ = 8, TSEP = 0x80000000};
- void SetSTS0( int &start, int end, int ti0 );
- void SetSTS1( int &start, int end, int ti0, double m, int i0 );
+ void SetSTS0(int& start, int end, int ti0);
+ void SetSTS1(int& start, int end, int ti0, double m, int i0);
- void GetCheck(int iItem, bool& fStartMod, bool& fEndMod, bool& fStartAdj, bool& fEndAdj);
- void SetCheck(int iItem, bool fStart, bool fEnd);
+ void GetCheck(int iItem, bool& fStartMod, bool& fEndMod, bool& fStartAdj, bool& fEndAdj);
+ void SetCheck(int iItem, bool fStart, bool fEnd);
- bool ModStart(int iItem, int t, bool fReset = false);
- bool ModEnd(int iItem, int t, bool fReset = false);
+ bool ModStart(int iItem, int t, bool fReset = false);
+ bool ModEnd(int iItem, int t, bool fReset = false);
public:
- CPlayerSubresyncBar();
- virtual ~CPlayerSubresyncBar();
+ CPlayerSubresyncBar();
+ virtual ~CPlayerSubresyncBar();
- BOOL Create(CWnd* pParentWnd, UINT defDockBarID, CCritSec* pSubLock);
+ BOOL Create(CWnd* pParentWnd, UINT defDockBarID, CCritSec* pSubLock);
- void SetTime(__int64 rt);
+ void SetTime(__int64 rt);
- void SetSubtitle(ISubStream* pSubStream, double fps);
- void ResetSubtitle();
- void SaveSubtitle();
+ void SetSubtitle(ISubStream* pSubStream, double fps);
+ void ResetSubtitle();
+ void SaveSubtitle();
- int FindNearestSub(__int64& rtPos, bool bForward);
- bool ShiftSubtitle(int nItem, long lValue, __int64& rtPos);
- bool SaveToDisk();
+ int FindNearestSub(__int64& rtPos, bool bForward);
+ bool ShiftSubtitle(int nItem, long lValue, __int64& rtPos);
+ bool SaveToDisk();
protected:
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
- bool IsShortCut(MSG* pMsg);
+ bool IsShortCut(MSG* pMsg);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg void OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnRclickList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnNMDblclkList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnLvnKeydownList(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg void OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnRclickList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnNMDblclkList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnLvnKeydownList(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult);
};
diff --git a/src/mpc-hc/PlayerToolBar.cpp b/src/mpc-hc/PlayerToolBar.cpp
index 3ae1c1ed2..b19af76d9 100644
--- a/src/mpc-hc/PlayerToolBar.cpp
+++ b/src/mpc-hc/PlayerToolBar.cpp
@@ -34,322 +34,322 @@
IMPLEMENT_DYNAMIC(CPlayerToolBar, CToolBar)
CPlayerToolBar::CPlayerToolBar()
- : m_nButtonHeight(16), m_pButtonsImages(NULL)
+ : m_nButtonHeight(16), m_pButtonsImages(NULL)
{
}
CPlayerToolBar::~CPlayerToolBar()
{
- if (NULL != m_pButtonsImages) {
- delete m_pButtonsImages;
- m_pButtonsImages = NULL;
- }
+ if (NULL != m_pButtonsImages) {
+ delete m_pButtonsImages;
+ m_pButtonsImages = NULL;
+ }
}
void CPlayerToolBar::LoadExternalToolBar(CImage* image)
{
- CString path;
- GetModuleFileName(AfxGetInstanceHandle(), path.GetBuffer(_MAX_PATH), _MAX_PATH);
- path.ReleaseBuffer();
- path = path.Left(path.ReverseFind('\\') + 1);
-
- if (SUCCEEDED(image->Load(path + _T("toolbar.png")))) {
- ;
- } else { // toolbar.bmp
- HBITMAP hBmp = (HBITMAP)LoadImage(NULL, path + _T("toolbar.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
- if (!!hBmp) {
- image->Attach(hBmp);
- }
- }
+ CString path;
+ GetModuleFileName(AfxGetInstanceHandle(), path.GetBuffer(_MAX_PATH), _MAX_PATH);
+ path.ReleaseBuffer();
+ path = path.Left(path.ReverseFind('\\') + 1);
+
+ if (SUCCEEDED(image->Load(path + _T("toolbar.png")))) {
+ ;
+ } else { // toolbar.bmp
+ HBITMAP hBmp = (HBITMAP)LoadImage(NULL, path + _T("toolbar.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
+ if (!!hBmp) {
+ image->Attach(hBmp);
+ }
+ }
}
BOOL CPlayerToolBar::Create(CWnd* pParentWnd)
{
- VERIFY(__super::CreateEx(pParentWnd,
- TBSTYLE_FLAT|TBSTYLE_TRANSPARENT|TBSTYLE_AUTOSIZE|TBSTYLE_CUSTOMERASE,
- WS_CHILD|WS_VISIBLE|CBRS_BOTTOM|CBRS_TOOLTIPS, CRect(2,2,0,1)));
-
- VERIFY(LoadToolBar(IDB_PLAYERTOOLBAR));
-
- // Should never be RTLed
- ModifyStyleEx(WS_EX_LAYOUTRTL, WS_EX_NOINHERITLAYOUT);
-
- CToolBarCtrl& tb = GetToolBarCtrl();
- tb.DeleteButton(tb.GetButtonCount()-1);
- tb.DeleteButton(tb.GetButtonCount()-1);
-
- SetMute(AfxGetAppSettings().fMute);
-
- UINT styles[] = {
- TBBS_CHECKGROUP, TBBS_CHECKGROUP, TBBS_CHECKGROUP,
- TBBS_SEPARATOR,
- TBBS_BUTTON, TBBS_BUTTON, TBBS_BUTTON, TBBS_BUTTON,
- TBBS_SEPARATOR,
- TBBS_BUTTON,
- TBBS_SEPARATOR,
- TBBS_SEPARATOR,
- TBBS_CHECKBOX,
- };
-
- for (int i = 0; i < _countof(styles); ++i) {
- SetButtonStyle(i, styles[i] | TBBS_DISABLED);
- }
-
- m_volctrl.Create(this);
- m_volctrl.SetRange(0, 100);
-
- m_nButtonHeight = 16; //reset m_nButtonHeight
- CImage image;
- LoadExternalToolBar(&image);
- if (!image.IsNull()) {
- CBitmap *bmp = CBitmap::FromHandle((HBITMAP)image);
- int width = image.GetWidth();
- int height = image.GetHeight();
- int bpp = image.GetBPP();
- if (width == height * 15) {
- // the manual specifies that sizeButton should be sizeImage inflated by (7, 6)
- SetSizes(CSize(height + 7, height + 6), CSize(height, height));
-
- m_pButtonsImages = DNew CImageList();
- if (bpp == 32) {
- m_pButtonsImages->Create(height, height, ILC_COLOR32 | ILC_MASK, 1, 0);
- m_pButtonsImages->Add(bmp, static_cast<CBitmap*>(0)); // alpha is the mask
- } else {
- m_pButtonsImages->Create(height, height, ILC_COLOR24 | ILC_MASK, 1, 0);
- m_pButtonsImages->Add(bmp, RGB(255, 0, 255));
- }
- m_nButtonHeight = height;
- GetToolBarCtrl().SetImageList(m_pButtonsImages);
- }
- image.Destroy();
- }
-
- return TRUE;
+ VERIFY(__super::CreateEx(pParentWnd,
+ TBSTYLE_FLAT | TBSTYLE_TRANSPARENT | TBSTYLE_AUTOSIZE | TBSTYLE_CUSTOMERASE,
+ WS_CHILD | WS_VISIBLE | CBRS_BOTTOM | CBRS_TOOLTIPS, CRect(2, 2, 0, 1)));
+
+ VERIFY(LoadToolBar(IDB_PLAYERTOOLBAR));
+
+ // Should never be RTLed
+ ModifyStyleEx(WS_EX_LAYOUTRTL, WS_EX_NOINHERITLAYOUT);
+
+ CToolBarCtrl& tb = GetToolBarCtrl();
+ tb.DeleteButton(tb.GetButtonCount() - 1);
+ tb.DeleteButton(tb.GetButtonCount() - 1);
+
+ SetMute(AfxGetAppSettings().fMute);
+
+ UINT styles[] = {
+ TBBS_CHECKGROUP, TBBS_CHECKGROUP, TBBS_CHECKGROUP,
+ TBBS_SEPARATOR,
+ TBBS_BUTTON, TBBS_BUTTON, TBBS_BUTTON, TBBS_BUTTON,
+ TBBS_SEPARATOR,
+ TBBS_BUTTON,
+ TBBS_SEPARATOR,
+ TBBS_SEPARATOR,
+ TBBS_CHECKBOX,
+ };
+
+ for (int i = 0; i < _countof(styles); ++i) {
+ SetButtonStyle(i, styles[i] | TBBS_DISABLED);
+ }
+
+ m_volctrl.Create(this);
+ m_volctrl.SetRange(0, 100);
+
+ m_nButtonHeight = 16; //reset m_nButtonHeight
+ CImage image;
+ LoadExternalToolBar(&image);
+ if (!image.IsNull()) {
+ CBitmap* bmp = CBitmap::FromHandle((HBITMAP)image);
+ int width = image.GetWidth();
+ int height = image.GetHeight();
+ int bpp = image.GetBPP();
+ if (width == height * 15) {
+ // the manual specifies that sizeButton should be sizeImage inflated by (7, 6)
+ SetSizes(CSize(height + 7, height + 6), CSize(height, height));
+
+ m_pButtonsImages = DNew CImageList();
+ if (bpp == 32) {
+ m_pButtonsImages->Create(height, height, ILC_COLOR32 | ILC_MASK, 1, 0);
+ m_pButtonsImages->Add(bmp, static_cast<CBitmap*>(0)); // alpha is the mask
+ } else {
+ m_pButtonsImages->Create(height, height, ILC_COLOR24 | ILC_MASK, 1, 0);
+ m_pButtonsImages->Add(bmp, RGB(255, 0, 255));
+ }
+ m_nButtonHeight = height;
+ GetToolBarCtrl().SetImageList(m_pButtonsImages);
+ }
+ image.Destroy();
+ }
+
+ return TRUE;
}
void CPlayerToolBar::ArrangeControls()
{
- if (!::IsWindow(m_volctrl.m_hWnd)) {
- return;
- }
+ if (!::IsWindow(m_volctrl.m_hWnd)) {
+ return;
+ }
- CRect r;
- GetClientRect(&r);
+ CRect r;
+ GetClientRect(&r);
- CRect br = GetBorders();
+ CRect br = GetBorders();
- CRect r10;
- GetItemRect(10, &r10);
+ CRect r10;
+ GetItemRect(10, &r10);
- CRect vr;
- m_volctrl.GetClientRect(&vr);
- CRect vr2(r.right + br.right - 60, r.bottom - 25, r.right + br.right + 6, r.bottom);
- m_volctrl.MoveWindow(vr2);
+ CRect vr;
+ m_volctrl.GetClientRect(&vr);
+ CRect vr2(r.right + br.right - 60, r.bottom - 25, r.right + br.right + 6, r.bottom);
+ m_volctrl.MoveWindow(vr2);
- UINT nID;
- UINT nStyle;
- int iImage;
- GetButtonInfo(12, nID, nStyle, iImage);
- SetButtonInfo(11, GetItemID(11), TBBS_SEPARATOR, vr2.left - iImage - r10.right - (r10.bottom - r10.top) + 11);
+ UINT nID;
+ UINT nStyle;
+ int iImage;
+ GetButtonInfo(12, nID, nStyle, iImage);
+ SetButtonInfo(11, GetItemID(11), TBBS_SEPARATOR, vr2.left - iImage - r10.right - (r10.bottom - r10.top) + 11);
}
void CPlayerToolBar::SetMute(bool fMute)
{
- CToolBarCtrl& tb = GetToolBarCtrl();
- TBBUTTONINFO bi;
- bi.cbSize = sizeof(bi);
- bi.dwMask = TBIF_IMAGE;
- bi.iImage = fMute ? 13 : 12;
- tb.SetButtonInfo(ID_VOLUME_MUTE, &bi);
-
- AfxGetAppSettings().fMute = fMute;
+ CToolBarCtrl& tb = GetToolBarCtrl();
+ TBBUTTONINFO bi;
+ bi.cbSize = sizeof(bi);
+ bi.dwMask = TBIF_IMAGE;
+ bi.iImage = fMute ? 13 : 12;
+ tb.SetButtonInfo(ID_VOLUME_MUTE, &bi);
+
+ AfxGetAppSettings().fMute = fMute;
}
bool CPlayerToolBar::IsMuted() const
{
- CToolBarCtrl& tb = GetToolBarCtrl();
- TBBUTTONINFO bi;
- bi.cbSize = sizeof(bi);
- bi.dwMask = TBIF_IMAGE;
- tb.GetButtonInfo(ID_VOLUME_MUTE, &bi);
- return (bi.iImage == 13);
+ CToolBarCtrl& tb = GetToolBarCtrl();
+ TBBUTTONINFO bi;
+ bi.cbSize = sizeof(bi);
+ bi.dwMask = TBIF_IMAGE;
+ tb.GetButtonInfo(ID_VOLUME_MUTE, &bi);
+ return (bi.iImage == 13);
}
int CPlayerToolBar::GetVolume() const
{
- int volume = m_volctrl.GetPos(); // [0..100]
- if (IsMuted() || volume <= 0) {
- volume = -10000;
- } else {
- volume = min((int)(4000 * log10(volume / 100.0f)), 0); // 4000=2.0*100*20, where 2.0 is a special factor
- }
-
- return volume;
+ int volume = m_volctrl.GetPos(); // [0..100]
+ if (IsMuted() || volume <= 0) {
+ volume = -10000;
+ } else {
+ volume = min((int)(4000 * log10(volume / 100.0f)), 0); // 4000=2.0*100*20, where 2.0 is a special factor
+ }
+
+ return volume;
}
int CPlayerToolBar::GetMinWidth() const
{
- return m_nButtonHeight * 9 + 155;
+ return m_nButtonHeight * 9 + 155;
}
void CPlayerToolBar::SetVolume(int volume)
{
- m_volctrl.SetPosInternal(volume);
+ m_volctrl.SetPosInternal(volume);
}
BEGIN_MESSAGE_MAP(CPlayerToolBar, CToolBar)
- ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw)
- ON_WM_SIZE()
- ON_MESSAGE_VOID(WM_INITIALUPDATE, OnInitialUpdate)
- ON_COMMAND_EX(ID_VOLUME_MUTE, OnVolumeMute)
- ON_UPDATE_COMMAND_UI(ID_VOLUME_MUTE, OnUpdateVolumeMute)
- ON_COMMAND_EX(ID_VOLUME_UP, OnVolumeUp)
- ON_COMMAND_EX(ID_VOLUME_DOWN, OnVolumeDown)
- ON_WM_NCPAINT()
- ON_WM_LBUTTONDOWN()
- ON_WM_MOUSEMOVE()
+ ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw)
+ ON_WM_SIZE()
+ ON_MESSAGE_VOID(WM_INITIALUPDATE, OnInitialUpdate)
+ ON_COMMAND_EX(ID_VOLUME_MUTE, OnVolumeMute)
+ ON_UPDATE_COMMAND_UI(ID_VOLUME_MUTE, OnUpdateVolumeMute)
+ ON_COMMAND_EX(ID_VOLUME_UP, OnVolumeUp)
+ ON_COMMAND_EX(ID_VOLUME_DOWN, OnVolumeDown)
+ ON_WM_NCPAINT()
+ ON_WM_LBUTTONDOWN()
+ ON_WM_MOUSEMOVE()
END_MESSAGE_MAP()
// CPlayerToolBar message handlers
-void CPlayerToolBar::OnCustomDraw(NMHDR *pNMHDR, LRESULT *pResult)
+void CPlayerToolBar::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMTBCUSTOMDRAW pTBCD = reinterpret_cast<LPNMTBCUSTOMDRAW>(pNMHDR);
- LRESULT lr = CDRF_DODEFAULT;
- switch (pTBCD->nmcd.dwDrawStage) {
- case CDDS_PREERASE:
- m_volctrl.Invalidate();
- lr = CDRF_DODEFAULT;
- break;
- case CDDS_PREPAINT: {
- // paint the control background, this is needed for XP
- CDC dc;
- dc.Attach(pTBCD->nmcd.hdc);
- RECT r;
- GetClientRect(&r);
- dc.FillSolidRect(&r, ::GetSysColor(COLOR_BTNFACE));
- dc.Detach();
- }
- lr |= CDRF_NOTIFYITEMDRAW;
- break;
- case CDDS_ITEMPREPAINT:
- // notify we want to paint after the system's paint cycle
- lr |= CDRF_NOTIFYPOSTPAINT;
- lr |= CDRF_NOTIFYITEMDRAW;
- break;
- case CDDS_ITEMPOSTPAINT:
- // paint over the duplicated separator
- CDC dc;
- dc.Attach(pTBCD->nmcd.hdc);
- RECT r;
- GetItemRect(11, &r);
- dc.FillSolidRect(&r, GetSysColor(COLOR_BTNFACE));
- dc.Detach();
- lr |= CDRF_SKIPDEFAULT;
- break;
- }
-
- *pResult = lr;
+ LPNMTBCUSTOMDRAW pTBCD = reinterpret_cast<LPNMTBCUSTOMDRAW>(pNMHDR);
+ LRESULT lr = CDRF_DODEFAULT;
+ switch (pTBCD->nmcd.dwDrawStage) {
+ case CDDS_PREERASE:
+ m_volctrl.Invalidate();
+ lr = CDRF_DODEFAULT;
+ break;
+ case CDDS_PREPAINT: {
+ // paint the control background, this is needed for XP
+ CDC dc;
+ dc.Attach(pTBCD->nmcd.hdc);
+ RECT r;
+ GetClientRect(&r);
+ dc.FillSolidRect(&r, ::GetSysColor(COLOR_BTNFACE));
+ dc.Detach();
+ }
+ lr |= CDRF_NOTIFYITEMDRAW;
+ break;
+ case CDDS_ITEMPREPAINT:
+ // notify we want to paint after the system's paint cycle
+ lr |= CDRF_NOTIFYPOSTPAINT;
+ lr |= CDRF_NOTIFYITEMDRAW;
+ break;
+ case CDDS_ITEMPOSTPAINT:
+ // paint over the duplicated separator
+ CDC dc;
+ dc.Attach(pTBCD->nmcd.hdc);
+ RECT r;
+ GetItemRect(11, &r);
+ dc.FillSolidRect(&r, GetSysColor(COLOR_BTNFACE));
+ dc.Detach();
+ lr |= CDRF_SKIPDEFAULT;
+ break;
+ }
+
+ *pResult = lr;
}
void CPlayerToolBar::OnSize(UINT nType, int cx, int cy)
{
- __super::OnSize(nType, cx, cy);
+ __super::OnSize(nType, cx, cy);
- ArrangeControls();
+ ArrangeControls();
}
void CPlayerToolBar::OnInitialUpdate()
{
- ArrangeControls();
+ ArrangeControls();
}
BOOL CPlayerToolBar::OnVolumeMute(UINT nID)
{
- SetMute(!IsMuted());
- return FALSE;
+ SetMute(!IsMuted());
+ return FALSE;
}
void CPlayerToolBar::OnUpdateVolumeMute(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(true);
- pCmdUI->SetCheck(IsMuted());
+ pCmdUI->Enable(true);
+ pCmdUI->SetCheck(IsMuted());
}
BOOL CPlayerToolBar::OnVolumeUp(UINT nID)
{
- m_volctrl.IncreaseVolume();
- return FALSE;
+ m_volctrl.IncreaseVolume();
+ return FALSE;
}
BOOL CPlayerToolBar::OnVolumeDown(UINT nID)
{
- m_volctrl.DecreaseVolume();
- return FALSE;
+ m_volctrl.DecreaseVolume();
+ return FALSE;
}
void CPlayerToolBar::OnNcPaint() // when using XP styles the NC area isn't drawn for our toolbar...
{
- CRect wr, cr;
-
- CWindowDC dc(this);
- GetClientRect(&cr);
- ClientToScreen(&cr);
- GetWindowRect(&wr);
- cr.OffsetRect(-wr.left, -wr.top);
- wr.OffsetRect(-wr.left, -wr.top);
- dc.ExcludeClipRect(&cr);
- dc.FillSolidRect(wr, GetSysColor(COLOR_BTNFACE));
-
- // Do not call CToolBar::OnNcPaint() for painting messages
+ CRect wr, cr;
+
+ CWindowDC dc(this);
+ GetClientRect(&cr);
+ ClientToScreen(&cr);
+ GetWindowRect(&wr);
+ cr.OffsetRect(-wr.left, -wr.top);
+ wr.OffsetRect(-wr.left, -wr.top);
+ dc.ExcludeClipRect(&cr);
+ dc.FillSolidRect(wr, GetSysColor(COLOR_BTNFACE));
+
+ // Do not call CToolBar::OnNcPaint() for painting messages
}
void CPlayerToolBar::OnMouseMove(UINT nFlags, CPoint point)
{
- int i = getHitButtonIdx(point);
-
- if (i == -1 || (GetButtonStyle(i) & (TBBS_SEPARATOR | TBBS_DISABLED))) {
- ;
- } else {
- if (i != 10 && i != 11) {
- ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_HAND));
- }
- }
- __super::OnMouseMove(nFlags, point);
+ int i = getHitButtonIdx(point);
+
+ if (i == -1 || (GetButtonStyle(i) & (TBBS_SEPARATOR | TBBS_DISABLED))) {
+ ;
+ } else {
+ if (i != 10 && i != 11) {
+ ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_HAND));
+ }
+ }
+ __super::OnMouseMove(nFlags, point);
}
void CPlayerToolBar::OnLButtonDown(UINT nFlags, CPoint point)
{
- int i = getHitButtonIdx(point);
- CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
-
- if (i == -1 || (GetButtonStyle(i) & (TBBS_SEPARATOR | TBBS_DISABLED))) {
- if (!pFrame->m_fFullScreen) {
- MapWindowPoints(pFrame, &point, 1);
- pFrame->PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y));
- }
- } else {
- if (i != 10 && i != 11) {
- ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_HAND));
- }
-
- __super::OnLButtonDown(nFlags, point);
- }
+ int i = getHitButtonIdx(point);
+ CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
+
+ if (i == -1 || (GetButtonStyle(i) & (TBBS_SEPARATOR | TBBS_DISABLED))) {
+ if (!pFrame->m_fFullScreen) {
+ MapWindowPoints(pFrame, &point, 1);
+ pFrame->PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y));
+ }
+ } else {
+ if (i != 10 && i != 11) {
+ ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_HAND));
+ }
+
+ __super::OnLButtonDown(nFlags, point);
+ }
}
int CPlayerToolBar::getHitButtonIdx(CPoint point)
{
- int hit = -1; // -1 means not on any buttons, mute button is 12/13, others < 10, 11 is empty space between
- CRect r;
+ int hit = -1; // -1 means not on any buttons, mute button is 12/13, others < 10, 11 is empty space between
+ CRect r;
- for (int i = 0, j = GetToolBarCtrl().GetButtonCount(); i < j; i++) {
- GetItemRect(i, r);
+ for (int i = 0, j = GetToolBarCtrl().GetButtonCount(); i < j; i++) {
+ GetItemRect(i, r);
- if (r.PtInRect(point)) {
- hit = i;
- break;
- }
- }
+ if (r.PtInRect(point)) {
+ hit = i;
+ break;
+ }
+ }
- return hit;
+ return hit;
}
diff --git a/src/mpc-hc/PlayerToolBar.h b/src/mpc-hc/PlayerToolBar.h
index 4dc8fdb2f..8005c48b6 100644
--- a/src/mpc-hc/PlayerToolBar.h
+++ b/src/mpc-hc/PlayerToolBar.h
@@ -29,49 +29,49 @@
class CPlayerToolBar : public CToolBar
{
- DECLARE_DYNAMIC(CPlayerToolBar)
+ DECLARE_DYNAMIC(CPlayerToolBar)
private:
- bool IsMuted() const;
- void SetMute(bool fMute = true);
- int getHitButtonIdx(CPoint point);
- void LoadExternalToolBar(CImage* bmp);
+ bool IsMuted() const;
+ void SetMute(bool fMute = true);
+ int getHitButtonIdx(CPoint point);
+ void LoadExternalToolBar(CImage* bmp);
- int m_nButtonHeight;
- CImageList *m_pButtonsImages;
+ int m_nButtonHeight;
+ CImageList* m_pButtonsImages;
public:
- CPlayerToolBar();
- virtual ~CPlayerToolBar();
+ CPlayerToolBar();
+ virtual ~CPlayerToolBar();
- int GetVolume() const;
- int GetMinWidth() const;
- void SetVolume(int volume);
- __declspec(property(get=GetVolume, put=SetVolume)) int Volume;
+ int GetVolume() const;
+ int GetMinWidth() const;
+ void SetVolume(int volume);
+ __declspec(property(get = GetVolume, put = SetVolume)) int Volume;
- void ArrangeControls();
+ void ArrangeControls();
- CVolumeCtrl m_volctrl;
+ CVolumeCtrl m_volctrl;
- // Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CPlayerToolBar)
- virtual BOOL Create(CWnd* pParentWnd);
- //}}AFX_VIRTUAL
+ // Overrides
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CPlayerToolBar)
+ virtual BOOL Create(CWnd* pParentWnd);
+ //}}AFX_VIRTUAL
- // Generated message map functions
+ // Generated message map functions
protected:
- //{{AFX_MSG(CPlayerToolBar)
- afx_msg void OnCustomDraw(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg void OnInitialUpdate();
- afx_msg BOOL OnVolumeMute(UINT nID);
- afx_msg void OnUpdateVolumeMute(CCmdUI* pCmdUI);
- afx_msg BOOL OnVolumeUp(UINT nID);
- afx_msg BOOL OnVolumeDown(UINT nID);
- afx_msg void OnNcPaint();
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnMouseMove(UINT nFlags, CPoint point);
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
+ //{{AFX_MSG(CPlayerToolBar)
+ afx_msg void OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg void OnInitialUpdate();
+ afx_msg BOOL OnVolumeMute(UINT nID);
+ afx_msg void OnUpdateVolumeMute(CCmdUI* pCmdUI);
+ afx_msg BOOL OnVolumeUp(UINT nID);
+ afx_msg BOOL OnVolumeDown(UINT nID);
+ afx_msg void OnNcPaint();
+ afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
+ afx_msg void OnMouseMove(UINT nFlags, CPoint point);
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
};
diff --git a/src/mpc-hc/Playlist.cpp b/src/mpc-hc/Playlist.cpp
index 6a693eab9..e2bd188ee 100644
--- a/src/mpc-hc/Playlist.cpp
+++ b/src/mpc-hc/Playlist.cpp
@@ -33,15 +33,15 @@
UINT CPlaylistItem::m_globalid = 0;
CPlaylistItem::CPlaylistItem()
- : m_type(file)
- , m_fInvalid(false)
- , m_duration(0)
- , m_vinput(-1)
- , m_vchannel(-1)
- , m_ainput(-1)
- , m_country(0)
+ : m_type(file)
+ , m_fInvalid(false)
+ , m_duration(0)
+ , m_vinput(-1)
+ , m_vchannel(-1)
+ , m_ainput(-1)
+ , m_country(0)
{
- m_id = m_globalid++;
+ m_id = m_globalid++;
}
CPlaylistItem::~CPlaylistItem()
@@ -50,171 +50,171 @@ CPlaylistItem::~CPlaylistItem()
CPlaylistItem::CPlaylistItem(const CPlaylistItem& pli)
{
- *this = pli;
+ *this = pli;
}
CPlaylistItem& CPlaylistItem::operator = (const CPlaylistItem& pli)
{
- if (this != &pli) {
- m_id = pli.m_id;
- m_label = pli.m_label;
- m_fns.RemoveAll();
- m_fns.AddTailList(&pli.m_fns);
- m_subs.RemoveAll();
- m_subs.AddTailList(&pli.m_subs);
- m_type = pli.m_type;
- m_fInvalid = pli.m_fInvalid;
- m_duration = pli.m_duration;
- m_vinput = pli.m_vinput;
- m_vchannel = pli.m_vchannel;
- m_ainput = pli.m_ainput;
- m_country = pli.m_country;
- }
- return *this;
+ if (this != &pli) {
+ m_id = pli.m_id;
+ m_label = pli.m_label;
+ m_fns.RemoveAll();
+ m_fns.AddTailList(&pli.m_fns);
+ m_subs.RemoveAll();
+ m_subs.AddTailList(&pli.m_subs);
+ m_type = pli.m_type;
+ m_fInvalid = pli.m_fInvalid;
+ m_duration = pli.m_duration;
+ m_vinput = pli.m_vinput;
+ m_vchannel = pli.m_vchannel;
+ m_ainput = pli.m_ainput;
+ m_country = pli.m_country;
+ }
+ return *this;
}
POSITION CPlaylistItem::FindFile(LPCTSTR path)
{
- POSITION pos = m_fns.GetHeadPosition();
- while (pos) {
- if (m_fns.GetAt(pos).CompareNoCase(path) == 0) {
- return pos;
- }
- m_fns.GetNext(pos);
- }
- return NULL;
+ POSITION pos = m_fns.GetHeadPosition();
+ while (pos) {
+ if (m_fns.GetAt(pos).CompareNoCase(path) == 0) {
+ return pos;
+ }
+ m_fns.GetNext(pos);
+ }
+ return NULL;
}
static CString StripPath(CString path)
{
- CString p = path;
- p.Replace('\\', '/');
- p = p.Mid(p.ReverseFind('/')+1);
- return (p.IsEmpty() ? path : p);
+ CString p = path;
+ p.Replace('\\', '/');
+ p = p.Mid(p.ReverseFind('/') + 1);
+ return (p.IsEmpty() ? path : p);
}
CString CPlaylistItem::GetLabel(int i)
{
- CString str;
-
- if (i == 0) {
- if (!m_label.IsEmpty()) {
- str = m_label;
- } else if (!m_fns.IsEmpty()) {
- str = StripPath(m_fns.GetHead());
- }
- } else if (i == 1) {
- if (m_fInvalid) {
- return _T("Invalid");
- }
-
- if (m_type == file) {
- REFERENCE_TIME rt = m_duration;
-
- if (rt > 0) {
- rt = (rt + 5000000) / 10000000;
- int ss = int(rt%60);
- rt /= 60;
- int mm = int(rt%60);
- rt /= 60;
- int hh = int(rt);
-
- str.Format(_T("%02d:%02d:%02d"), hh, mm, ss);
- }
- } else if (m_type == device) {
- // TODO
- }
-
- }
-
- return str;
+ CString str;
+
+ if (i == 0) {
+ if (!m_label.IsEmpty()) {
+ str = m_label;
+ } else if (!m_fns.IsEmpty()) {
+ str = StripPath(m_fns.GetHead());
+ }
+ } else if (i == 1) {
+ if (m_fInvalid) {
+ return _T("Invalid");
+ }
+
+ if (m_type == file) {
+ REFERENCE_TIME rt = m_duration;
+
+ if (rt > 0) {
+ rt = (rt + 5000000) / 10000000;
+ int ss = int(rt % 60);
+ rt /= 60;
+ int mm = int(rt % 60);
+ rt /= 60;
+ int hh = int(rt);
+
+ str.Format(_T("%02d:%02d:%02d"), hh, mm, ss);
+ }
+ } else if (m_type == device) {
+ // TODO
+ }
+
+ }
+
+ return str;
}
bool FindFileInList(CAtlList<CString>& sl, CString fn)
{
- bool fFound = false;
- POSITION pos = sl.GetHeadPosition();
- while (pos && !fFound) {
- if (!sl.GetNext(pos).CompareNoCase(fn)) {
- fFound = true;
- }
- }
- return fFound;
+ bool fFound = false;
+ POSITION pos = sl.GetHeadPosition();
+ while (pos && !fFound) {
+ if (!sl.GetNext(pos).CompareNoCase(fn)) {
+ fFound = true;
+ }
+ }
+ return fFound;
}
void CPlaylistItem::AutoLoadFiles()
{
- if (m_fns.IsEmpty()) {
- return;
- }
-
- CString fn = m_fns.GetHead();
-
- if (AfxGetAppSettings().fAutoloadAudio && fn.Find(_T("://")) < 0) {
- int i = fn.ReverseFind('.');
- if (i > 0) {
- CMediaFormats& mf = AfxGetAppSettings().m_Formats;
-
- CString ext = fn.Mid(i+1).MakeLower();
-
- if (!mf.FindExt(ext, true)) {
- CString path = fn;
- path.Replace('/', '\\');
- path = path.Left(path.ReverseFind('\\')+1);
-
- WIN32_FIND_DATA fd = {0};
- HANDLE hFind = FindFirstFile(fn.Left(i) + _T("*.*"), &fd);
- if (hFind != INVALID_HANDLE_VALUE) {
- do {
- if (fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) {
- continue;
- }
-
- CString fullpath = path + fd.cFileName;
- CString ext2 = fullpath.Mid(fullpath.ReverseFind('.')+1).MakeLower();
- if (!FindFileInList(m_fns, fullpath) && ext != ext2
- && mf.FindExt(ext2, true) && mf.IsUsingEngine(fullpath, DirectShow)) {
- m_fns.AddTail(fullpath);
- }
- } while (FindNextFile(hFind, &fd));
-
- FindClose(hFind);
- }
- }
- }
- }
-
- if (AfxGetAppSettings().fAutoloadSubtitles) {
- CString& pathList = AfxGetAppSettings().strSubtitlePaths;
-
- CAtlArray<CString> paths;
-
- int pos = 0;
- do {
- CString path = pathList.Tokenize(_T(";"), pos);
- paths.Add(path);
- } while (pos != -1);
-
- CString dir = fn;
- dir.Replace('\\', '/');
- int l = fn.GetLength(), l2 = l;
- l2 = dir.ReverseFind('.');
- l = dir.ReverseFind('/') + 1;
- if (l2 < l) {
- l2 = l;
- }
- CString title = dir.Mid(l, l2-l);
- paths.Add(title.GetString());
-
- CAtlArray<SubFile> ret;
- GetSubFileNames(fn, paths, ret);
-
- for (size_t i = 0; i < ret.GetCount(); i++) {
- if (!FindFileInList(m_subs, ret[i].fn)) {
- m_subs.AddTail(ret[i].fn);
- }
- }
- }
+ if (m_fns.IsEmpty()) {
+ return;
+ }
+
+ CString fn = m_fns.GetHead();
+
+ if (AfxGetAppSettings().fAutoloadAudio && fn.Find(_T("://")) < 0) {
+ int i = fn.ReverseFind('.');
+ if (i > 0) {
+ CMediaFormats& mf = AfxGetAppSettings().m_Formats;
+
+ CString ext = fn.Mid(i + 1).MakeLower();
+
+ if (!mf.FindExt(ext, true)) {
+ CString path = fn;
+ path.Replace('/', '\\');
+ path = path.Left(path.ReverseFind('\\') + 1);
+
+ WIN32_FIND_DATA fd = {0};
+ HANDLE hFind = FindFirstFile(fn.Left(i) + _T("*.*"), &fd);
+ if (hFind != INVALID_HANDLE_VALUE) {
+ do {
+ if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+ continue;
+ }
+
+ CString fullpath = path + fd.cFileName;
+ CString ext2 = fullpath.Mid(fullpath.ReverseFind('.') + 1).MakeLower();
+ if (!FindFileInList(m_fns, fullpath) && ext != ext2
+ && mf.FindExt(ext2, true) && mf.IsUsingEngine(fullpath, DirectShow)) {
+ m_fns.AddTail(fullpath);
+ }
+ } while (FindNextFile(hFind, &fd));
+
+ FindClose(hFind);
+ }
+ }
+ }
+ }
+
+ if (AfxGetAppSettings().fAutoloadSubtitles) {
+ CString& pathList = AfxGetAppSettings().strSubtitlePaths;
+
+ CAtlArray<CString> paths;
+
+ int pos = 0;
+ do {
+ CString path = pathList.Tokenize(_T(";"), pos);
+ paths.Add(path);
+ } while (pos != -1);
+
+ CString dir = fn;
+ dir.Replace('\\', '/');
+ int l = fn.GetLength(), l2 = l;
+ l2 = dir.ReverseFind('.');
+ l = dir.ReverseFind('/') + 1;
+ if (l2 < l) {
+ l2 = l;
+ }
+ CString title = dir.Mid(l, l2 - l);
+ paths.Add(title.GetString());
+
+ CAtlArray<SubFile> ret;
+ GetSubFileNames(fn, paths, ret);
+
+ for (size_t i = 0; i < ret.GetCount(); i++) {
+ if (!FindFileInList(m_subs, ret[i].fn)) {
+ m_subs.AddTail(ret[i].fn);
+ }
+ }
+ }
}
//
@@ -222,7 +222,7 @@ void CPlaylistItem::AutoLoadFiles()
//
CPlaylist::CPlaylist()
- : m_pos(NULL)
+ : m_pos(NULL)
{
}
@@ -232,183 +232,183 @@ CPlaylist::~CPlaylist()
bool CPlaylist::RemoveAll()
{
- __super::RemoveAll();
- bool bWasPlaying = (m_pos != NULL);
- m_pos = NULL;
- return bWasPlaying;
+ __super::RemoveAll();
+ bool bWasPlaying = (m_pos != NULL);
+ m_pos = NULL;
+ return bWasPlaying;
}
bool CPlaylist::RemoveAt(POSITION pos)
{
- if (pos) {
- __super::RemoveAt(pos);
- if (m_pos == pos) {
- m_pos = NULL;
- return true;
- }
- }
-
- return false;
+ if (pos) {
+ __super::RemoveAt(pos);
+ if (m_pos == pos) {
+ m_pos = NULL;
+ return true;
+ }
+ }
+
+ return false;
}
typedef struct {
- UINT n;
- POSITION pos;
+ UINT n;
+ POSITION pos;
} plsort_t;
static int compare(const void* arg1, const void* arg2)
{
- UINT a1 = ((plsort_t*)arg1)->n;
- UINT a2 = ((plsort_t*)arg2)->n;
- return a1 > a2 ? 1 : a1 < a2 ? -1 : 0;
+ UINT a1 = ((plsort_t*)arg1)->n;
+ UINT a2 = ((plsort_t*)arg2)->n;
+ return a1 > a2 ? 1 : a1 < a2 ? -1 : 0;
}
typedef struct {
- LPCTSTR str;
- POSITION pos;
+ LPCTSTR str;
+ POSITION pos;
} plsort2_t;
int compare2(const void* arg1, const void* arg2)
{
- return StrCmpLogicalW(((plsort2_t*)arg1)->str, ((plsort2_t*)arg2)->str);
+ return StrCmpLogicalW(((plsort2_t*)arg1)->str, ((plsort2_t*)arg2)->str);
}
void CPlaylist::SortById()
{
- CAtlArray<plsort_t> a;
- a.SetCount(GetCount());
- POSITION pos = GetHeadPosition();
- for (int i = 0; pos; i++, GetNext(pos)) {
- a[i].n = GetAt(pos).m_id, a[i].pos = pos;
- }
- qsort(a.GetData(), a.GetCount(), sizeof(plsort_t), compare);
- for (size_t i = 0; i < a.GetCount(); i++) {
- AddTail(GetAt(a[i].pos));
- __super::RemoveAt(a[i].pos);
- if (m_pos == a[i].pos) {
- m_pos = GetTailPosition();
- }
- }
+ CAtlArray<plsort_t> a;
+ a.SetCount(GetCount());
+ POSITION pos = GetHeadPosition();
+ for (int i = 0; pos; i++, GetNext(pos)) {
+ a[i].n = GetAt(pos).m_id, a[i].pos = pos;
+ }
+ qsort(a.GetData(), a.GetCount(), sizeof(plsort_t), compare);
+ for (size_t i = 0; i < a.GetCount(); i++) {
+ AddTail(GetAt(a[i].pos));
+ __super::RemoveAt(a[i].pos);
+ if (m_pos == a[i].pos) {
+ m_pos = GetTailPosition();
+ }
+ }
}
void CPlaylist::SortByName()
{
- CAtlArray<plsort2_t> a;
- a.SetCount(GetCount());
- POSITION pos = GetHeadPosition();
- for (int i = 0; pos; i++, GetNext(pos)) {
- CString& fn = GetAt(pos).m_fns.GetHead();
- a[i].str = (LPCTSTR)fn + max(fn.ReverseFind('/'), fn.ReverseFind('\\')) + 1;
- a[i].pos = pos;
- }
- qsort(a.GetData(), a.GetCount(), sizeof(plsort2_t), compare2);
- for (size_t i = 0; i < a.GetCount(); i++) {
- AddTail(GetAt(a[i].pos));
- __super::RemoveAt(a[i].pos);
- if (m_pos == a[i].pos) {
- m_pos = GetTailPosition();
- }
- }
+ CAtlArray<plsort2_t> a;
+ a.SetCount(GetCount());
+ POSITION pos = GetHeadPosition();
+ for (int i = 0; pos; i++, GetNext(pos)) {
+ CString& fn = GetAt(pos).m_fns.GetHead();
+ a[i].str = (LPCTSTR)fn + max(fn.ReverseFind('/'), fn.ReverseFind('\\')) + 1;
+ a[i].pos = pos;
+ }
+ qsort(a.GetData(), a.GetCount(), sizeof(plsort2_t), compare2);
+ for (size_t i = 0; i < a.GetCount(); i++) {
+ AddTail(GetAt(a[i].pos));
+ __super::RemoveAt(a[i].pos);
+ if (m_pos == a[i].pos) {
+ m_pos = GetTailPosition();
+ }
+ }
}
void CPlaylist::SortByPath()
{
- CAtlArray<plsort2_t> a;
- a.SetCount(GetCount());
- POSITION pos = GetHeadPosition();
- for (int i = 0; pos; i++, GetNext(pos)) {
- a[i].str = GetAt(pos).m_fns.GetHead(), a[i].pos = pos;
- }
- qsort(a.GetData(), a.GetCount(), sizeof(plsort2_t), compare2);
- for (size_t i = 0; i < a.GetCount(); i++) {
- AddTail(GetAt(a[i].pos));
- __super::RemoveAt(a[i].pos);
- if (m_pos == a[i].pos) {
- m_pos = GetTailPosition();
- }
- }
+ CAtlArray<plsort2_t> a;
+ a.SetCount(GetCount());
+ POSITION pos = GetHeadPosition();
+ for (int i = 0; pos; i++, GetNext(pos)) {
+ a[i].str = GetAt(pos).m_fns.GetHead(), a[i].pos = pos;
+ }
+ qsort(a.GetData(), a.GetCount(), sizeof(plsort2_t), compare2);
+ for (size_t i = 0; i < a.GetCount(); i++) {
+ AddTail(GetAt(a[i].pos));
+ __super::RemoveAt(a[i].pos);
+ if (m_pos == a[i].pos) {
+ m_pos = GetTailPosition();
+ }
+ }
}
void CPlaylist::Randomize()
{
- CAtlArray<plsort_t> a;
- a.SetCount(GetCount());
- srand((unsigned int)time(NULL));
- POSITION pos = GetHeadPosition();
- for (int i = 0; pos; i++, GetNext(pos)) {
- a[i].n = rand(), a[i].pos = pos;
- }
- qsort(a.GetData(), a.GetCount(), sizeof(plsort_t), compare);
- CList<CPlaylistItem> pl;
- for (size_t i = 0; i < a.GetCount(); i++) {
- AddTail(GetAt(a[i].pos));
- __super::RemoveAt(a[i].pos);
- if (m_pos == a[i].pos) {
- m_pos = GetTailPosition();
- }
- }
+ CAtlArray<plsort_t> a;
+ a.SetCount(GetCount());
+ srand((unsigned int)time(NULL));
+ POSITION pos = GetHeadPosition();
+ for (int i = 0; pos; i++, GetNext(pos)) {
+ a[i].n = rand(), a[i].pos = pos;
+ }
+ qsort(a.GetData(), a.GetCount(), sizeof(plsort_t), compare);
+ CList<CPlaylistItem> pl;
+ for (size_t i = 0; i < a.GetCount(); i++) {
+ AddTail(GetAt(a[i].pos));
+ __super::RemoveAt(a[i].pos);
+ if (m_pos == a[i].pos) {
+ m_pos = GetTailPosition();
+ }
+ }
}
POSITION CPlaylist::GetPos() const
{
- return m_pos;
+ return m_pos;
}
void CPlaylist::SetPos(POSITION pos)
{
- m_pos = pos;
+ m_pos = pos;
}
POSITION CPlaylist::Shuffle()
{
- static INT_PTR idx = 0;
- static INT_PTR count = 0;
- static CAtlArray<plsort_t> a;
-
- ASSERT(GetCount() > 2);
- // insert or remove items in playlist, or index out of bounds then recalculate
- if ((count != GetCount()) || (idx >= GetCount())) {
- a.RemoveAll();
- idx = 0;
- a.SetCount(count = GetCount());
-
- POSITION pos = GetHeadPosition();
- for (INT_PTR i = 0; pos; i++, GetNext(pos)) {
- a[i].pos = pos; // initialize position array
- }
-
- //Use Fisher-Yates shuffle algorithm
- srand((unsigned)time(NULL));
- for (INT_PTR i=0; i<(count-1); i++) {
- INT_PTR r = i + (rand() % (count-i));
- POSITION temp = a[i].pos;
- a[i].pos = a[r].pos;
- a[r].pos = temp;
- }
- }
-
- return a[idx++].pos;
+ static INT_PTR idx = 0;
+ static INT_PTR count = 0;
+ static CAtlArray<plsort_t> a;
+
+ ASSERT(GetCount() > 2);
+ // insert or remove items in playlist, or index out of bounds then recalculate
+ if ((count != GetCount()) || (idx >= GetCount())) {
+ a.RemoveAll();
+ idx = 0;
+ a.SetCount(count = GetCount());
+
+ POSITION pos = GetHeadPosition();
+ for (INT_PTR i = 0; pos; i++, GetNext(pos)) {
+ a[i].pos = pos; // initialize position array
+ }
+
+ //Use Fisher-Yates shuffle algorithm
+ srand((unsigned)time(NULL));
+ for (INT_PTR i = 0; i < (count - 1); i++) {
+ INT_PTR r = i + (rand() % (count - i));
+ POSITION temp = a[i].pos;
+ a[i].pos = a[r].pos;
+ a[r].pos = temp;
+ }
+ }
+
+ return a[idx++].pos;
}
CPlaylistItem& CPlaylist::GetNextWrap(POSITION& pos)
{
- if (AfxGetAppSettings().bShufflePlaylistItems && GetCount() > 2) {
- pos = Shuffle();
- } else {
- GetNext(pos);
- if (!pos) {
- pos = GetHeadPosition();
- }
- }
-
- return GetAt(pos);
+ if (AfxGetAppSettings().bShufflePlaylistItems && GetCount() > 2) {
+ pos = Shuffle();
+ } else {
+ GetNext(pos);
+ if (!pos) {
+ pos = GetHeadPosition();
+ }
+ }
+
+ return GetAt(pos);
}
CPlaylistItem& CPlaylist::GetPrevWrap(POSITION& pos)
{
- GetPrev(pos);
- if (!pos) {
- pos = GetTailPosition();
- }
- return GetAt(pos);
+ GetPrev(pos);
+ if (!pos) {
+ pos = GetTailPosition();
+ }
+ return GetAt(pos);
}
diff --git a/src/mpc-hc/Playlist.h b/src/mpc-hc/Playlist.h
index 2ee2b6edb..14dd11790 100644
--- a/src/mpc-hc/Playlist.h
+++ b/src/mpc-hc/Playlist.h
@@ -28,52 +28,52 @@
class CPlaylistItem
{
- static UINT m_globalid;
+ static UINT m_globalid;
public:
- UINT m_id;
- CString m_label;
- CAtlList<CString> m_fns;
- CAtlList<CString> m_subs;
- enum type_t {file, device} m_type;
- REFERENCE_TIME m_duration;
- int m_vinput, m_vchannel;
- int m_ainput;
- long m_country;
-
- bool m_fInvalid;
+ UINT m_id;
+ CString m_label;
+ CAtlList<CString> m_fns;
+ CAtlList<CString> m_subs;
+ enum type_t {file, device} m_type;
+ REFERENCE_TIME m_duration;
+ int m_vinput, m_vchannel;
+ int m_ainput;
+ long m_country;
+
+ bool m_fInvalid;
public:
- CPlaylistItem();
- virtual ~CPlaylistItem();
+ CPlaylistItem();
+ virtual ~CPlaylistItem();
- CPlaylistItem(const CPlaylistItem& pli);
- CPlaylistItem& operator = (const CPlaylistItem& pli);
+ CPlaylistItem(const CPlaylistItem& pli);
+ CPlaylistItem& operator = (const CPlaylistItem& pli);
- POSITION FindFile(LPCTSTR path);
- void AutoLoadFiles();
+ POSITION FindFile(LPCTSTR path);
+ void AutoLoadFiles();
- CString GetLabel(int i = 0);
+ CString GetLabel(int i = 0);
};
class CPlaylist : public CList<CPlaylistItem>
{
protected:
- POSITION m_pos;
+ POSITION m_pos;
public:
- CPlaylist();
- virtual ~CPlaylist();
+ CPlaylist();
+ virtual ~CPlaylist();
- bool RemoveAll();
- bool RemoveAt(POSITION pos);
+ bool RemoveAll();
+ bool RemoveAt(POSITION pos);
- void SortById(), SortByName(), SortByPath(), Randomize();
+ void SortById(), SortByName(), SortByPath(), Randomize();
- POSITION GetPos() const;
- void SetPos(POSITION pos);
- CPlaylistItem& GetNextWrap(POSITION& pos);
- CPlaylistItem& GetPrevWrap(POSITION& pos);
+ POSITION GetPos() const;
+ void SetPos(POSITION pos);
+ CPlaylistItem& GetNextWrap(POSITION& pos);
+ CPlaylistItem& GetPrevWrap(POSITION& pos);
- POSITION Shuffle();
+ POSITION Shuffle();
};
diff --git a/src/mpc-hc/PnSPresetsDlg.cpp b/src/mpc-hc/PnSPresetsDlg.cpp
index 895ec6575..805105d6c 100644
--- a/src/mpc-hc/PnSPresetsDlg.cpp
+++ b/src/mpc-hc/PnSPresetsDlg.cpp
@@ -30,8 +30,8 @@
IMPLEMENT_DYNAMIC(CPnSPresetsDlg, CCmdUIDialog)
CPnSPresetsDlg::CPnSPresetsDlg(CWnd* pParent /*=NULL*/)
- : CCmdUIDialog(CPnSPresetsDlg::IDD, pParent)
- , m_label(_T(""))
+ : CCmdUIDialog(CPnSPresetsDlg::IDD, pParent)
+ , m_label(_T(""))
{
}
@@ -41,214 +41,214 @@ CPnSPresetsDlg::~CPnSPresetsDlg()
void CPnSPresetsDlg::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_EDIT2, m_PosX);
- DDX_Control(pDX, IDC_EDIT3, m_PosY);
- DDX_Control(pDX, IDC_EDIT4, m_ZoomX);
- DDX_Control(pDX, IDC_EDIT5, m_ZoomY);
- DDX_Text(pDX, IDC_EDIT1, m_label);
- DDX_Control(pDX, IDC_LIST1, m_list);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_EDIT2, m_PosX);
+ DDX_Control(pDX, IDC_EDIT3, m_PosY);
+ DDX_Control(pDX, IDC_EDIT4, m_ZoomX);
+ DDX_Control(pDX, IDC_EDIT5, m_ZoomY);
+ DDX_Text(pDX, IDC_EDIT1, m_label);
+ DDX_Control(pDX, IDC_LIST1, m_list);
}
BOOL CPnSPresetsDlg::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- for (INT_PTR i = 0, j = m_pnspresets.GetCount(); i < j; i++) {
- CString label;
- double PosX, PosY, ZoomX, ZoomY;
- StringToParams(m_pnspresets[i], label, PosX, PosY, ZoomX, ZoomY);
+ for (INT_PTR i = 0, j = m_pnspresets.GetCount(); i < j; i++) {
+ CString label;
+ double PosX, PosY, ZoomX, ZoomY;
+ StringToParams(m_pnspresets[i], label, PosX, PosY, ZoomX, ZoomY);
- m_list.AddString(label);
+ m_list.AddString(label);
- if (i == 0) {
- m_list.SetCurSel(0);
- OnLbnSelchangeList1();
- }
- }
+ if (i == 0) {
+ m_list.SetCurSel(0);
+ OnLbnSelchangeList1();
+ }
+ }
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CPnSPresetsDlg::StringToParams(CString str, CString& label, double& PosX, double& PosY, double& ZoomX, double& ZoomY)
{
- int i = 0, j = 0;
-
- for (CString token = str.Tokenize(_T(","), i); !token.IsEmpty(); token = str.Tokenize(_T(","), i), j++) {
- if (j == 0) {
- label = token;
- } else {
- float f = 0;
- if (_stscanf_s(token, _T("%f"), &f) != 1) {
- continue;
- }
-
- switch (j) {
- case 1:
- PosX = f;
- break;
- case 2:
- PosY = f;
- break;
- case 3:
- ZoomX = f;
- break;
- case 4:
- ZoomY = f;
- break;
- default:
- break;
- }
- }
- }
+ int i = 0, j = 0;
+
+ for (CString token = str.Tokenize(_T(","), i); !token.IsEmpty(); token = str.Tokenize(_T(","), i), j++) {
+ if (j == 0) {
+ label = token;
+ } else {
+ float f = 0;
+ if (_stscanf_s(token, _T("%f"), &f) != 1) {
+ continue;
+ }
+
+ switch (j) {
+ case 1:
+ PosX = f;
+ break;
+ case 2:
+ PosY = f;
+ break;
+ case 3:
+ ZoomX = f;
+ break;
+ case 4:
+ ZoomY = f;
+ break;
+ default:
+ break;
+ }
+ }
+ }
}
CString CPnSPresetsDlg::ParamsToString(CString label, double PosX, double PosY, double ZoomX, double ZoomY)
{
- CString str;
- str.Format(_T("%s,%.3f,%.3f,%.3f,%.3f"), label, PosX, PosY, ZoomX, ZoomY);
- return str;
+ CString str;
+ str.Format(_T("%s,%.3f,%.3f,%.3f,%.3f"), label, PosX, PosY, ZoomX, ZoomY);
+ return str;
}
BEGIN_MESSAGE_MAP(CPnSPresetsDlg, CCmdUIDialog)
- ON_LBN_SELCHANGE(IDC_LIST1, OnLbnSelchangeList1)
- ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON2, OnUpdateButton2)
- ON_BN_CLICKED(IDC_BUTTON3, OnBnClickedButton6)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON3, OnUpdateButton6)
- ON_BN_CLICKED(IDC_BUTTON4, OnBnClickedButton9)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON4, OnUpdateButton9)
- ON_BN_CLICKED(IDC_BUTTON5, OnBnClickedButton10)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON5, OnUpdateButton10)
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
- ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateButton1)
+ ON_LBN_SELCHANGE(IDC_LIST1, OnLbnSelchangeList1)
+ ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON2, OnUpdateButton2)
+ ON_BN_CLICKED(IDC_BUTTON3, OnBnClickedButton6)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON3, OnUpdateButton6)
+ ON_BN_CLICKED(IDC_BUTTON4, OnBnClickedButton9)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON4, OnUpdateButton9)
+ ON_BN_CLICKED(IDC_BUTTON5, OnBnClickedButton10)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON5, OnUpdateButton10)
+ ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateButton1)
END_MESSAGE_MAP()
// CPnSPresetsDlg message handlers
void CPnSPresetsDlg::OnLbnSelchangeList1()
{
- int i = m_list.GetCurSel();
- if (i >= 0 && i < m_pnspresets.GetCount()) {
- double PosX, PosY, ZoomX, ZoomY;
- StringToParams(m_pnspresets[i], m_label, PosX, PosY, ZoomX, ZoomY);
- m_PosX = PosX;
- m_PosY = PosY;
- m_ZoomX = ZoomX;
- m_ZoomY = ZoomY;
- } else {
- m_label.Empty();
- m_PosX.SetWindowText(_T(""));
- m_PosY.SetWindowText(_T(""));
- m_ZoomX.SetWindowText(_T(""));
- m_ZoomY.SetWindowText(_T(""));
- }
-
- UpdateData(FALSE);
+ int i = m_list.GetCurSel();
+ if (i >= 0 && i < m_pnspresets.GetCount()) {
+ double PosX, PosY, ZoomX, ZoomY;
+ StringToParams(m_pnspresets[i], m_label, PosX, PosY, ZoomX, ZoomY);
+ m_PosX = PosX;
+ m_PosY = PosY;
+ m_ZoomX = ZoomX;
+ m_ZoomY = ZoomY;
+ } else {
+ m_label.Empty();
+ m_PosX.SetWindowText(_T(""));
+ m_PosY.SetWindowText(_T(""));
+ m_ZoomX.SetWindowText(_T(""));
+ m_ZoomY.SetWindowText(_T(""));
+ }
+
+ UpdateData(FALSE);
}
void CPnSPresetsDlg::OnBnClickedButton2() // new
{
- m_pnspresets.Add(_T("New,0.5,0.5,1.0,1.0"));
- m_list.SetCurSel(m_list.AddString(_T("New")));
- OnLbnSelchangeList1();
+ m_pnspresets.Add(_T("New,0.5,0.5,1.0,1.0"));
+ m_list.SetCurSel(m_list.AddString(_T("New")));
+ OnLbnSelchangeList1();
}
void CPnSPresetsDlg::OnUpdateButton2(CCmdUI* pCmdUI)
{
- CString str;
- int len = m_list.GetCount();
- if (len > 0) {
- m_list.GetText(len-1, str);
- }
- pCmdUI->Enable(str != _T("New"));
+ CString str;
+ int len = m_list.GetCount();
+ if (len > 0) {
+ m_list.GetText(len - 1, str);
+ }
+ pCmdUI->Enable(str != _T("New"));
}
void CPnSPresetsDlg::OnBnClickedButton6() // del
{
- int i = m_list.GetCurSel();
- m_list.DeleteString(i);
- m_pnspresets.RemoveAt(i);
- if (i == m_list.GetCount()) {
- i--;
- }
- m_list.SetCurSel(i);
- OnLbnSelchangeList1();
+ int i = m_list.GetCurSel();
+ m_list.DeleteString(i);
+ m_pnspresets.RemoveAt(i);
+ if (i == m_list.GetCount()) {
+ i--;
+ }
+ m_list.SetCurSel(i);
+ OnLbnSelchangeList1();
}
void CPnSPresetsDlg::OnUpdateButton6(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_list.GetCurSel() >= 0);
+ pCmdUI->Enable(m_list.GetCurSel() >= 0);
}
void CPnSPresetsDlg::OnBnClickedButton9() // up
{
- int i = m_list.GetCurSel();
- CString str, str2;
- m_list.GetText(i, str);
- str2 = m_pnspresets.GetAt(i);
- m_list.DeleteString(i);
- m_pnspresets.RemoveAt(i);
- i--;
- m_list.InsertString(i, str);
- m_pnspresets.InsertAt(i, str2);
- m_list.SetCurSel(i);
+ int i = m_list.GetCurSel();
+ CString str, str2;
+ m_list.GetText(i, str);
+ str2 = m_pnspresets.GetAt(i);
+ m_list.DeleteString(i);
+ m_pnspresets.RemoveAt(i);
+ i--;
+ m_list.InsertString(i, str);
+ m_pnspresets.InsertAt(i, str2);
+ m_list.SetCurSel(i);
}
void CPnSPresetsDlg::OnUpdateButton9(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_list.GetCurSel() > 0 && m_list.GetCurSel() < m_list.GetCount());
+ pCmdUI->Enable(m_list.GetCurSel() > 0 && m_list.GetCurSel() < m_list.GetCount());
}
void CPnSPresetsDlg::OnBnClickedButton10() // down
{
- int i = m_list.GetCurSel();
- CString str, str2;
- m_list.GetText(i, str);
- str2 = m_pnspresets.GetAt(i);
- m_list.DeleteString(i);
- m_pnspresets.RemoveAt(i);
- i++;
- m_list.InsertString(i, str);
- m_pnspresets.InsertAt(i, str2);
- m_list.SetCurSel(i);
+ int i = m_list.GetCurSel();
+ CString str, str2;
+ m_list.GetText(i, str);
+ str2 = m_pnspresets.GetAt(i);
+ m_list.DeleteString(i);
+ m_pnspresets.RemoveAt(i);
+ i++;
+ m_list.InsertString(i, str);
+ m_pnspresets.InsertAt(i, str2);
+ m_list.SetCurSel(i);
}
void CPnSPresetsDlg::OnUpdateButton10(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(m_list.GetCurSel() >= 0 && m_list.GetCurSel() < m_list.GetCount()-1);
+ pCmdUI->Enable(m_list.GetCurSel() >= 0 && m_list.GetCurSel() < m_list.GetCount() - 1);
}
void CPnSPresetsDlg::OnBnClickedButton1() // set
{
- int i = m_list.GetCurSel();
- UpdateData();
- /*if (m_label.Remove(',') > 0)
- UpdateData(FALSE);*/
- m_label.Replace(',', '.'); // Replace any ',' with '.' as ',' is used as tokeniser
- m_pnspresets[i] = ParamsToString(m_label, m_PosX, m_PosY, m_ZoomX, m_ZoomY);
- m_list.DeleteString(i);
- m_list.InsertString(i, m_label);
- m_list.SetCurSel(i);
+ int i = m_list.GetCurSel();
+ UpdateData();
+ /*if (m_label.Remove(',') > 0)
+ UpdateData(FALSE);*/
+ m_label.Replace(',', '.'); // Replace any ',' with '.' as ',' is used as tokeniser
+ m_pnspresets[i] = ParamsToString(m_label, m_PosX, m_PosY, m_ZoomX, m_ZoomY);
+ m_list.DeleteString(i);
+ m_list.InsertString(i, m_label);
+ m_list.SetCurSel(i);
}
void CPnSPresetsDlg::OnUpdateButton1(CCmdUI* pCmdUI)
{
- UpdateData();
- pCmdUI->Enable(m_list.GetCurSel() >= 0
- && !m_label.IsEmpty() // && m_label.Find(',') < 0
- && m_PosX >= 0 && m_PosX <= 1
- && m_PosY >= 0 && m_PosY <= 1
- && m_ZoomX >= 0.2 && m_ZoomX <= 3.0
- && m_ZoomY >= 0.2 && m_ZoomY <= 3.0);
+ UpdateData();
+ pCmdUI->Enable(m_list.GetCurSel() >= 0
+ && !m_label.IsEmpty() // && m_label.Find(',') < 0
+ && m_PosX >= 0 && m_PosX <= 1
+ && m_PosY >= 0 && m_PosY <= 1
+ && m_ZoomX >= 0.2 && m_ZoomX <= 3.0
+ && m_ZoomY >= 0.2 && m_ZoomY <= 3.0);
}
void CPnSPresetsDlg::OnOK()
{
- if (m_list.GetCurSel() >= 0) {
- OnBnClickedButton1();
- }
+ if (m_list.GetCurSel() >= 0) {
+ OnBnClickedButton1();
+ }
- __super::OnOK();
+ __super::OnOK();
}
diff --git a/src/mpc-hc/PnSPresetsDlg.h b/src/mpc-hc/PnSPresetsDlg.h
index c1e0f3ad0..674f0cfde 100644
--- a/src/mpc-hc/PnSPresetsDlg.h
+++ b/src/mpc-hc/PnSPresetsDlg.h
@@ -31,43 +31,43 @@
class CPnSPresetsDlg : public CCmdUIDialog
{
- DECLARE_DYNAMIC(CPnSPresetsDlg)
+ DECLARE_DYNAMIC(CPnSPresetsDlg)
private:
- void StringToParams(CString str, CString& label, double& PosX, double& PosY, double& ZoomX, double& ZoomY);
- CString ParamsToString(CString label, double PosX, double PosY, double ZoomX, double ZoomY);
+ void StringToParams(CString str, CString& label, double& PosX, double& PosY, double& ZoomX, double& ZoomY);
+ CString ParamsToString(CString label, double PosX, double PosY, double ZoomX, double ZoomY);
public:
- CPnSPresetsDlg(CWnd* pParent = NULL); // standard constructor
- virtual ~CPnSPresetsDlg();
+ CPnSPresetsDlg(CWnd* pParent = NULL); // standard constructor
+ virtual ~CPnSPresetsDlg();
- CStringArray m_pnspresets;
+ CStringArray m_pnspresets;
- // Dialog Data
- enum { IDD = IDD_PNSPRESET_DLG };
- CFloatEdit m_PosX;
- CFloatEdit m_PosY;
- CFloatEdit m_ZoomX;
- CFloatEdit m_ZoomY;
- CString m_label;
- CListBox m_list;
+ // Dialog Data
+ enum { IDD = IDD_PNSPRESET_DLG };
+ CFloatEdit m_PosX;
+ CFloatEdit m_PosY;
+ CFloatEdit m_ZoomX;
+ CFloatEdit m_ZoomY;
+ CString m_label;
+ CListBox m_list;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual void OnOK();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual void OnOK();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnLbnSelchangeList1();
- afx_msg void OnBnClickedButton2();
- afx_msg void OnUpdateButton2(CCmdUI* pCmdUI);
- afx_msg void OnBnClickedButton6();
- afx_msg void OnUpdateButton6(CCmdUI* pCmdUI);
- afx_msg void OnBnClickedButton9();
- afx_msg void OnUpdateButton9(CCmdUI* pCmdUI);
- afx_msg void OnBnClickedButton10();
- afx_msg void OnUpdateButton10(CCmdUI* pCmdUI);
- afx_msg void OnBnClickedButton1();
- afx_msg void OnUpdateButton1(CCmdUI* pCmdUI);
+ afx_msg void OnLbnSelchangeList1();
+ afx_msg void OnBnClickedButton2();
+ afx_msg void OnUpdateButton2(CCmdUI* pCmdUI);
+ afx_msg void OnBnClickedButton6();
+ afx_msg void OnUpdateButton6(CCmdUI* pCmdUI);
+ afx_msg void OnBnClickedButton9();
+ afx_msg void OnUpdateButton9(CCmdUI* pCmdUI);
+ afx_msg void OnBnClickedButton10();
+ afx_msg void OnUpdateButton10(CCmdUI* pCmdUI);
+ afx_msg void OnBnClickedButton1();
+ afx_msg void OnUpdateButton1(CCmdUI* pCmdUI);
};
diff --git a/src/mpc-hc/QuicktimeGraph.cpp b/src/mpc-hc/QuicktimeGraph.cpp
index 62575eb3f..c4babb55b 100644
--- a/src/mpc-hc/QuicktimeGraph.cpp
+++ b/src/mpc-hc/QuicktimeGraph.cpp
@@ -39,340 +39,340 @@ using namespace DSObjects;
using namespace QT;
CQuicktimeGraph::CQuicktimeGraph(HWND hWndParent, HRESULT& hr)
- : CBaseGraph()
- , m_wndDestFrame(this)
- , m_fQtInitialized(false)
-{
- hr = S_OK;
-
- DWORD dwStyle = WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN;
-
- AppSettings& s = AfxGetAppSettings();
-
- if (s.iQTVideoRendererType == VIDRNDT_QT_DX7) {
- if (SUCCEEDED(CreateAP7(CLSID_QT7AllocatorPresenter, hWndParent, &m_pQTAP))) {
- dwStyle &= ~WS_VISIBLE;
- }
- } else if (s.iQTVideoRendererType == VIDRNDT_QT_DX9) {
- bool bFullscreen = (AfxGetApp()->m_pMainWnd != NULL) && (((CMainFrame*)AfxGetApp()->m_pMainWnd)->IsD3DFullScreenMode());
- if (SUCCEEDED(CreateAP9(CLSID_QT9AllocatorPresenter, hWndParent, bFullscreen, &m_pQTAP))) {
- dwStyle &= ~WS_VISIBLE;
- }
- }
-
- m_fQtInitialized = false;
- if (InitializeQTML(0) != 0) {
- hr = E_FAIL;
- return;
- }
- if (EnterMovies() != 0) {
- TerminateQTML();
- hr = E_FAIL;
- return;
- }
- m_fQtInitialized = true;
-
- if (!m_wndWindowFrame.CreateEx(WS_EX_NOPARENTNOTIFY, NULL, NULL, dwStyle, CRect(0, 0, 0, 0), CWnd::FromHandle(hWndParent), 0)) {
- hr = E_FAIL;
- return;
- }
-
- if (!m_wndDestFrame.Create(NULL, NULL, dwStyle, CRect(0, 0, 0, 0), &m_wndWindowFrame, 0)) {
- hr = E_FAIL;
- return;
- }
+ : CBaseGraph()
+ , m_wndDestFrame(this)
+ , m_fQtInitialized(false)
+{
+ hr = S_OK;
+
+ DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
+
+ AppSettings& s = AfxGetAppSettings();
+
+ if (s.iQTVideoRendererType == VIDRNDT_QT_DX7) {
+ if (SUCCEEDED(CreateAP7(CLSID_QT7AllocatorPresenter, hWndParent, &m_pQTAP))) {
+ dwStyle &= ~WS_VISIBLE;
+ }
+ } else if (s.iQTVideoRendererType == VIDRNDT_QT_DX9) {
+ bool bFullscreen = (AfxGetApp()->m_pMainWnd != NULL) && (((CMainFrame*)AfxGetApp()->m_pMainWnd)->IsD3DFullScreenMode());
+ if (SUCCEEDED(CreateAP9(CLSID_QT9AllocatorPresenter, hWndParent, bFullscreen, &m_pQTAP))) {
+ dwStyle &= ~WS_VISIBLE;
+ }
+ }
+
+ m_fQtInitialized = false;
+ if (InitializeQTML(0) != 0) {
+ hr = E_FAIL;
+ return;
+ }
+ if (EnterMovies() != 0) {
+ TerminateQTML();
+ hr = E_FAIL;
+ return;
+ }
+ m_fQtInitialized = true;
+
+ if (!m_wndWindowFrame.CreateEx(WS_EX_NOPARENTNOTIFY, NULL, NULL, dwStyle, CRect(0, 0, 0, 0), CWnd::FromHandle(hWndParent), 0)) {
+ hr = E_FAIL;
+ return;
+ }
+
+ if (!m_wndDestFrame.Create(NULL, NULL, dwStyle, CRect(0, 0, 0, 0), &m_wndWindowFrame, 0)) {
+ hr = E_FAIL;
+ return;
+ }
}
CQuicktimeGraph::~CQuicktimeGraph()
{
- m_wndDestFrame.DestroyWindow();
- m_wndWindowFrame.DestroyWindow();
+ m_wndDestFrame.DestroyWindow();
+ m_wndWindowFrame.DestroyWindow();
- if (m_fQtInitialized) {
- ExitMovies();
- TerminateQTML();
- }
+ if (m_fQtInitialized) {
+ ExitMovies();
+ TerminateQTML();
+ }
}
STDMETHODIMP CQuicktimeGraph::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- QI(IVideoFrameStep)
- (m_pQTAP && (riid == __uuidof(ISubPicAllocatorPresenter) || riid == __uuidof(IQTVideoSurface))) ? m_pQTAP->QueryInterface(riid, ppv) :
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI(IVideoFrameStep)
+ (m_pQTAP && (riid == __uuidof(ISubPicAllocatorPresenter) || riid == __uuidof(IQTVideoSurface))) ? m_pQTAP->QueryInterface(riid, ppv) :
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// IGraphBuilder
STDMETHODIMP CQuicktimeGraph::RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList)
{
- bool fRet = m_wndDestFrame.OpenMovie(CString(lpcwstrFile));
+ bool fRet = m_wndDestFrame.OpenMovie(CString(lpcwstrFile));
- if (fRet) {
- for (int i = 1, cnt = GetMovieTrackCount(m_wndDestFrame.theMovie); i <= cnt; i++) {
- Track aTrack = GetMovieIndTrack(m_wndDestFrame.theMovie, i);
- Media aMedia = GetTrackMedia(aTrack);
+ if (fRet) {
+ for (int i = 1, cnt = GetMovieTrackCount(m_wndDestFrame.theMovie); i <= cnt; i++) {
+ Track aTrack = GetMovieIndTrack(m_wndDestFrame.theMovie, i);
+ Media aMedia = GetTrackMedia(aTrack);
- OSType aTrackType;
- GetMediaHandlerDescription(aMedia, &aTrackType, 0, 0);
- if (aTrackType == SoundMediaType) {
- SampleDescriptionHandle aDesc = (SampleDescriptionHandle)NewHandle(sizeof(aDesc));
- GetMediaSampleDescription(aMedia, 1, aDesc);
- if (GetMoviesError() == noErr) {
- SoundDescription& desc = **(SoundDescriptionHandle)aDesc;
- NotifyEvent(EC_BG_AUDIO_CHANGED, desc.numChannels, 0);
- i = cnt;
- }
- DisposeHandle((Handle)aDesc);
- }
- }
- }
+ OSType aTrackType;
+ GetMediaHandlerDescription(aMedia, &aTrackType, 0, 0);
+ if (aTrackType == SoundMediaType) {
+ SampleDescriptionHandle aDesc = (SampleDescriptionHandle)NewHandle(sizeof(aDesc));
+ GetMediaSampleDescription(aMedia, 1, aDesc);
+ if (GetMoviesError() == noErr) {
+ SoundDescription& desc = **(SoundDescriptionHandle)aDesc;
+ NotifyEvent(EC_BG_AUDIO_CHANGED, desc.numChannels, 0);
+ i = cnt;
+ }
+ DisposeHandle((Handle)aDesc);
+ }
+ }
+ }
- return fRet ? S_OK : E_FAIL;
+ return fRet ? S_OK : E_FAIL;
}
// IMediaControl
STDMETHODIMP CQuicktimeGraph::Run()
{
- m_wndDestFrame.Run();
- return S_OK;
+ m_wndDestFrame.Run();
+ return S_OK;
}
STDMETHODIMP CQuicktimeGraph::Pause()
{
- m_wndDestFrame.Pause();
- return S_OK;
+ m_wndDestFrame.Pause();
+ return S_OK;
}
STDMETHODIMP CQuicktimeGraph::Stop()
{
- m_wndDestFrame.Stop();
- return S_OK;
+ m_wndDestFrame.Stop();
+ return S_OK;
}
STDMETHODIMP CQuicktimeGraph::GetState(LONG msTimeout, OAFilterState* pfs)
{
- // TODO: this seems to deadlock when opening from the net
- return pfs ? *pfs = m_wndDestFrame.GetState(), S_OK : E_POINTER;
+ // TODO: this seems to deadlock when opening from the net
+ return pfs ? *pfs = m_wndDestFrame.GetState(), S_OK : E_POINTER;
}
// IMediaSeeking
STDMETHODIMP CQuicktimeGraph::GetDuration(LONGLONG* pDuration)
{
- CheckPointer(pDuration, E_POINTER);
+ CheckPointer(pDuration, E_POINTER);
- *pDuration = 0;
+ *pDuration = 0;
- if (!m_wndDestFrame.theMovie) {
- return E_UNEXPECTED;
- }
+ if (!m_wndDestFrame.theMovie) {
+ return E_UNEXPECTED;
+ }
- TimeScale ts = GetMovieTimeScale(m_wndDestFrame.theMovie);
- if (ts == 0) {
- return E_FAIL;
- }
+ TimeScale ts = GetMovieTimeScale(m_wndDestFrame.theMovie);
+ if (ts == 0) {
+ return E_FAIL;
+ }
- *pDuration = 10000i64*GetMovieDuration(m_wndDestFrame.theMovie)/ts*1000;
+ *pDuration = 10000i64 * GetMovieDuration(m_wndDestFrame.theMovie) / ts * 1000;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CQuicktimeGraph::GetCurrentPosition(LONGLONG* pCurrent)
{
- CheckPointer(pCurrent, E_POINTER);
+ CheckPointer(pCurrent, E_POINTER);
- *pCurrent = 0;
+ *pCurrent = 0;
- if (!m_wndDestFrame.theMovie) {
- return E_UNEXPECTED;
- }
+ if (!m_wndDestFrame.theMovie) {
+ return E_UNEXPECTED;
+ }
- TimeScale ts = GetMovieTimeScale(m_wndDestFrame.theMovie);
- if (ts == 0) {
- return E_FAIL;
- }
+ TimeScale ts = GetMovieTimeScale(m_wndDestFrame.theMovie);
+ if (ts == 0) {
+ return E_FAIL;
+ }
- TimeRecord tr;
- *pCurrent = 10000i64*GetMovieTime(m_wndDestFrame.theMovie, &tr)/ts*1000;
+ TimeRecord tr;
+ *pCurrent = 10000i64 * GetMovieTime(m_wndDestFrame.theMovie, &tr) / ts * 1000;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CQuicktimeGraph::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags)
{
- CheckPointer(pCurrent, E_POINTER);
+ CheckPointer(pCurrent, E_POINTER);
- if (!(dwCurrentFlags&AM_SEEKING_AbsolutePositioning)) {
- return E_INVALIDARG;
- }
+ if (!(dwCurrentFlags & AM_SEEKING_AbsolutePositioning)) {
+ return E_INVALIDARG;
+ }
- if (!m_wndDestFrame.theMovie) {
- return E_UNEXPECTED;
- }
+ if (!m_wndDestFrame.theMovie) {
+ return E_UNEXPECTED;
+ }
- TimeScale ts = GetMovieTimeScale(m_wndDestFrame.theMovie);
- if (ts == 0) {
- return E_FAIL;
- }
+ TimeScale ts = GetMovieTimeScale(m_wndDestFrame.theMovie);
+ if (ts == 0) {
+ return E_FAIL;
+ }
- SetMovieTimeValue(m_wndDestFrame.theMovie, (TimeValue)(*pCurrent*ts/1000/10000i64));
+ SetMovieTimeValue(m_wndDestFrame.theMovie, (TimeValue)(*pCurrent * ts / 1000 / 10000i64));
- if (!m_wndDestFrame.theMC) {
- UpdateMovie(m_wndDestFrame.theMovie);
- MoviesTask(m_wndDestFrame.theMovie, 0L);
- }
+ if (!m_wndDestFrame.theMC) {
+ UpdateMovie(m_wndDestFrame.theMovie);
+ MoviesTask(m_wndDestFrame.theMovie, 0L);
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CQuicktimeGraph::SetRate(double dRate)
{
- return m_wndDestFrame.theMovie ? SetMovieRate(m_wndDestFrame.theMovie, (Fixed)(dRate * 0x10000)), S_OK : E_UNEXPECTED;
+ return m_wndDestFrame.theMovie ? SetMovieRate(m_wndDestFrame.theMovie, (Fixed)(dRate * 0x10000)), S_OK : E_UNEXPECTED;
}
STDMETHODIMP CQuicktimeGraph::GetRate(double* pdRate)
{
- CheckPointer(pdRate, E_POINTER);
- *pdRate = 1.0;
- return m_wndDestFrame.theMovie ? *pdRate = (double)GetMovieRate(m_wndDestFrame.theMovie) / 0x10000, S_OK : E_UNEXPECTED;
+ CheckPointer(pdRate, E_POINTER);
+ *pdRate = 1.0;
+ return m_wndDestFrame.theMovie ? *pdRate = (double)GetMovieRate(m_wndDestFrame.theMovie) / 0x10000, S_OK : E_UNEXPECTED;
}
// IVideoWindow
STDMETHODIMP CQuicktimeGraph::SetWindowPosition(long Left, long Top, long Width, long Height)
{
- if (IsWindow(m_wndWindowFrame.m_hWnd)) {
- m_wndWindowFrame.MoveWindow(Left, Top, Width, Height);
- }
+ if (IsWindow(m_wndWindowFrame.m_hWnd)) {
+ m_wndWindowFrame.MoveWindow(Left, Top, Width, Height);
+ }
- return S_OK;
+ return S_OK;
}
// IBasicVideo
STDMETHODIMP CQuicktimeGraph::SetDestinationPosition(long Left, long Top, long Width, long Height)// {return E_NOTIMPL;}
{
- if (!m_pQTAP && IsWindow(m_wndDestFrame.m_hWnd)) {
- m_wndDestFrame.MoveWindow(Left, Top, Width, Height);
+ if (!m_pQTAP && IsWindow(m_wndDestFrame.m_hWnd)) {
+ m_wndDestFrame.MoveWindow(Left, Top, Width, Height);
- if (m_wndDestFrame.theMC) {
- Rect bounds = {0,0,(short)Height,(short)Width};
- MCPositionController(m_wndDestFrame.theMC, &bounds, NULL, mcTopLeftMovie|mcScaleMovieToFit);
- }
- }
+ if (m_wndDestFrame.theMC) {
+ Rect bounds = {0, 0, (short)Height, (short)Width};
+ MCPositionController(m_wndDestFrame.theMC, &bounds, NULL, mcTopLeftMovie | mcScaleMovieToFit);
+ }
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CQuicktimeGraph::GetVideoSize(long* pWidth, long* pHeight)
{
- if (!pWidth || !pHeight) {
- return E_POINTER;
- }
+ if (!pWidth || !pHeight) {
+ return E_POINTER;
+ }
- *pWidth = m_wndDestFrame.m_size.cx;
- *pHeight = m_wndDestFrame.m_size.cy;
+ *pWidth = m_wndDestFrame.m_size.cx;
+ *pHeight = m_wndDestFrame.m_size.cy;
- return S_OK;
+ return S_OK;
}
// IBasicAudio
STDMETHODIMP CQuicktimeGraph::put_Volume(long lVolume)
{
- if (m_wndDestFrame.theMovie) {
- short volume = (lVolume <= -10000) ? 0 : (short)(pow(10.0, lVolume/4000.0)*256);
- volume = max(min(volume, 256), 0);
- SetMovieVolume(m_wndDestFrame.theMovie, volume);
- return S_OK;
- }
+ if (m_wndDestFrame.theMovie) {
+ short volume = (lVolume <= -10000) ? 0 : (short)(pow(10.0, lVolume / 4000.0) * 256);
+ volume = max(min(volume, 256), 0);
+ SetMovieVolume(m_wndDestFrame.theMovie, volume);
+ return S_OK;
+ }
- return E_UNEXPECTED;
+ return E_UNEXPECTED;
}
STDMETHODIMP CQuicktimeGraph::get_Volume(long* plVolume)
{
- CheckPointer(plVolume, E_POINTER);
+ CheckPointer(plVolume, E_POINTER);
- if (m_wndDestFrame.theMovie) {
- *plVolume = (long)GetMovieVolume(m_wndDestFrame.theMovie); // [?..256]
- if (*plVolume > 0) {
- *plVolume = min((long)(4000*log10(*plVolume/256.0f)), 0);
- } else {
- *plVolume = -10000;
- }
- return S_OK;
- }
+ if (m_wndDestFrame.theMovie) {
+ *plVolume = (long)GetMovieVolume(m_wndDestFrame.theMovie); // [?..256]
+ if (*plVolume > 0) {
+ *plVolume = min((long)(4000 * log10(*plVolume / 256.0f)), 0);
+ } else {
+ *plVolume = -10000;
+ }
+ return S_OK;
+ }
- return E_UNEXPECTED;
+ return E_UNEXPECTED;
}
// IVideoFrameStep
STDMETHODIMP CQuicktimeGraph::Step(DWORD dwFrames, IUnknown* pStepObject)
{
- if (pStepObject) {
- return E_INVALIDARG;
- }
- if (dwFrames == 0) {
- return S_OK;
- }
- if (!m_wndDestFrame.theMovie) {
- return E_UNEXPECTED;
- }
-
- // w/o m_wndDestFrame.theMC
-
- OSType myTypes[] = {VisualMediaCharacteristic};
- TimeValue myCurrTime = GetMovieTime(m_wndDestFrame.theMovie, NULL);
- Fixed theRate = (int)dwFrames > 0 ? 0x00010000 : 0xffff0000;
-
- for (int nSteps = abs((int)dwFrames); nSteps > 0; nSteps--) {
- TimeValue myNextTime;
- GetMovieNextInterestingTime(m_wndDestFrame.theMovie, nextTimeStep, 1, myTypes, myCurrTime, theRate, &myNextTime, NULL);
- if (GetMoviesError() != noErr) {
- return E_FAIL;
- }
- myCurrTime = myNextTime;
- }
-
- if (myCurrTime >= 0 && myCurrTime < GetMovieDuration(m_wndDestFrame.theMovie)) {
- SetMovieTimeValue(m_wndDestFrame.theMovie, myCurrTime);
- if (GetMoviesError() != noErr) {
- return E_FAIL;
- }
- // the rest is not needed when we also have m_wndDestFrame.theMC:
- UpdateMovie(m_wndDestFrame.theMovie);
- if (GetMoviesError() != noErr) {
- return E_FAIL;
- }
- MoviesTask(m_wndDestFrame.theMovie, 0L);
- }
-
- NotifyEvent(EC_STEP_COMPLETE);
-
- return S_OK;
-
- /*
- // w/ m_wndDestFrame.theMC
-
- short myStep = (short)(long)dwFrames;
- return noErr == MCDoAction(m_wndDestFrame.theMC, mcActionStep, (Ptr)myStep)
- ? NotifyEvent(EC_STEP_COMPLETE), S_OK : E_FAIL;
- */
+ if (pStepObject) {
+ return E_INVALIDARG;
+ }
+ if (dwFrames == 0) {
+ return S_OK;
+ }
+ if (!m_wndDestFrame.theMovie) {
+ return E_UNEXPECTED;
+ }
+
+ // w/o m_wndDestFrame.theMC
+
+ OSType myTypes[] = {VisualMediaCharacteristic};
+ TimeValue myCurrTime = GetMovieTime(m_wndDestFrame.theMovie, NULL);
+ Fixed theRate = (int)dwFrames > 0 ? 0x00010000 : 0xffff0000;
+
+ for (int nSteps = abs((int)dwFrames); nSteps > 0; nSteps--) {
+ TimeValue myNextTime;
+ GetMovieNextInterestingTime(m_wndDestFrame.theMovie, nextTimeStep, 1, myTypes, myCurrTime, theRate, &myNextTime, NULL);
+ if (GetMoviesError() != noErr) {
+ return E_FAIL;
+ }
+ myCurrTime = myNextTime;
+ }
+
+ if (myCurrTime >= 0 && myCurrTime < GetMovieDuration(m_wndDestFrame.theMovie)) {
+ SetMovieTimeValue(m_wndDestFrame.theMovie, myCurrTime);
+ if (GetMoviesError() != noErr) {
+ return E_FAIL;
+ }
+ // the rest is not needed when we also have m_wndDestFrame.theMC:
+ UpdateMovie(m_wndDestFrame.theMovie);
+ if (GetMoviesError() != noErr) {
+ return E_FAIL;
+ }
+ MoviesTask(m_wndDestFrame.theMovie, 0L);
+ }
+
+ NotifyEvent(EC_STEP_COMPLETE);
+
+ return S_OK;
+
+ /*
+ // w/ m_wndDestFrame.theMC
+
+ short myStep = (short)(long)dwFrames;
+ return noErr == MCDoAction(m_wndDestFrame.theMC, mcActionStep, (Ptr)myStep)
+ ? NotifyEvent(EC_STEP_COMPLETE), S_OK : E_FAIL;
+ */
}
STDMETHODIMP CQuicktimeGraph::CanStep(long bMultiple, IUnknown* pStepObject)
{
- return m_wndDestFrame.theMovie ? S_OK : S_FALSE;
+ return m_wndDestFrame.theMovie ? S_OK : S_FALSE;
}
STDMETHODIMP CQuicktimeGraph::CancelStep()
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
// IGraphEngine
STDMETHODIMP_(engine_t) CQuicktimeGraph::GetEngine()
{
- return QuickTime;
+ return QuickTime;
}
//
@@ -380,318 +380,318 @@ STDMETHODIMP_(engine_t) CQuicktimeGraph::GetEngine()
//
CQuicktimeWindow::CQuicktimeWindow(CQuicktimeGraph* pGraph)
- : m_pGraph(pGraph)
- , theMovie(NULL)
- , theMC(NULL)
- , m_size(0, 0)
- , m_idEndPoller(0)
- , m_fs(State_Stopped)
- , m_offscreenGWorld(NULL)
+ : m_pGraph(pGraph)
+ , theMovie(NULL)
+ , theMC(NULL)
+ , m_size(0, 0)
+ , m_idEndPoller(0)
+ , m_fs(State_Stopped)
+ , m_offscreenGWorld(NULL)
{
}
void CQuicktimeWindow::ProcessMovieEvent(unsigned int message, unsigned int wParam, long lParam)
{
- if (message >= WM_MOUSEFIRST && message <= WM_MOUSELAST
- || message >= WM_KEYFIRST && message <= WM_KEYLAST) {
- return;
- }
+ if (message >= WM_MOUSEFIRST && message <= WM_MOUSELAST
+ || message >= WM_KEYFIRST && message <= WM_KEYLAST) {
+ return;
+ }
- // Convert the Windows event to a QTML event
- MSG theMsg;
- EventRecord macEvent;
- LONG thePoints = GetMessagePos();
+ // Convert the Windows event to a QTML event
+ MSG theMsg;
+ EventRecord macEvent;
+ LONG thePoints = GetMessagePos();
- theMsg.hwnd = m_hWnd;
- theMsg.message = message;
- theMsg.wParam = wParam;
- theMsg.lParam = lParam;
- theMsg.time = GetMessageTime();
- theMsg.pt.x = LOWORD(thePoints);
- theMsg.pt.y = HIWORD(thePoints);
+ theMsg.hwnd = m_hWnd;
+ theMsg.message = message;
+ theMsg.wParam = wParam;
+ theMsg.lParam = lParam;
+ theMsg.time = GetMessageTime();
+ theMsg.pt.x = LOWORD(thePoints);
+ theMsg.pt.y = HIWORD(thePoints);
- // tranlate a windows event to a mac event
- WinEventToMacEvent(&theMsg, &macEvent);
+ // tranlate a windows event to a mac event
+ WinEventToMacEvent(&theMsg, &macEvent);
- // Pump messages as mac event
- MCIsPlayerEvent(theMC, (const EventRecord*)&macEvent);
+ // Pump messages as mac event
+ MCIsPlayerEvent(theMC, (const EventRecord*)&macEvent);
}
LRESULT CQuicktimeWindow::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
- if (message == WM_ERASEBKGND) {
- LRESULT theResult = __super::WindowProc(message, wParam, lParam);
- ProcessMovieEvent(message, wParam, lParam);
- return theResult;
- } else {
- ProcessMovieEvent(message, wParam, lParam);
- return __super::WindowProc(message, wParam, lParam);
- }
+ if (message == WM_ERASEBKGND) {
+ LRESULT theResult = __super::WindowProc(message, wParam, lParam);
+ ProcessMovieEvent(message, wParam, lParam);
+ return theResult;
+ } else {
+ ProcessMovieEvent(message, wParam, lParam);
+ return __super::WindowProc(message, wParam, lParam);
+ }
}
OSErr CQuicktimeWindow::MyMovieDrawingCompleteProc(Movie theMovie, long refCon)
{
- CQuicktimeWindow* pQW = (CQuicktimeWindow*)refCon;
- if (!pQW) {
- return noErr;
- }
+ CQuicktimeWindow* pQW = (CQuicktimeWindow*)refCon;
+ if (!pQW) {
+ return noErr;
+ }
- CQuicktimeGraph* pGraph = pQW->m_pGraph;
- if (!pGraph) {
- return noErr;
- }
+ CQuicktimeGraph* pGraph = pQW->m_pGraph;
+ if (!pGraph) {
+ return noErr;
+ }
- if (CComQIPtr<IQTVideoSurface> pQTVS = (IUnknown*)(INonDelegatingUnknown*)pGraph) {
- BITMAP bm;
- pQW->m_bm.GetObject(sizeof(bm), &bm);
- bm.bmWidth = pQW->m_size.cx;
- pQTVS->DoBlt(bm);
- }
- /*
- else
- {
- pQW->Invalidate();
- }*/
+ if (CComQIPtr<IQTVideoSurface> pQTVS = (IUnknown*)(INonDelegatingUnknown*)pGraph) {
+ BITMAP bm;
+ pQW->m_bm.GetObject(sizeof(bm), &bm);
+ bm.bmWidth = pQW->m_size.cx;
+ pQTVS->DoBlt(bm);
+ }
+ /*
+ else
+ {
+ pQW->Invalidate();
+ }*/
- return noErr;
+ return noErr;
}
bool CQuicktimeWindow::OpenMovie(CString fn)
{
- CloseMovie();
-
- CComQIPtr<IQTVideoSurface> pQTVS = (IUnknown*)(INonDelegatingUnknown*)m_pGraph;
-
- if (!pQTVS) {
- // Set the port
- SetGWorld((CGrafPtr)GetHWNDPort(m_hWnd), NULL);
- }
-
- if (fn.Find(_T("://")) > 0) {
- Handle myHandle = NULL;
- Size mySize = fn.GetLength()+1;
- myHandle = NewHandleClear(mySize);
- if (!myHandle) {
- return false;
- }
-
- BlockMove((LPSTR)(LPCSTR)CStringA(fn), *myHandle, mySize);
-
- OSErr err = NewMovieFromDataRef(&theMovie, newMovieActive, NULL, myHandle, URLDataHandlerSubType);
-
- DisposeHandle(myHandle);
-
- if (err != noErr) {
- return false;
- }
- } else {
- if (!(fn.GetLength() > 0 && fn.GetLength() < 255)) {
- return false;
- }
-
- CHAR buff[_MAX_PATH] = {0, 0};
- WideCharToMultiByte(GetACP(), 0, fn, -1, buff+1, _MAX_PATH-1, 0, 0);
- buff[0] = strlen(buff+1);
-
- // Make a FSSpec with a pascal string filename
- FSSpec sfFile;
- FSMakeFSSpec(0, 0L, (BYTE*)buff, &sfFile);
-
- // Open the movie file
- short movieResFile;
- OSErr err = OpenMovieFile(&sfFile, &movieResFile, fsRdPerm);
- if (err == noErr) {
- err = NewMovieFromFile(&theMovie, movieResFile, 0, 0, newMovieActive, 0);
- CloseMovieFile(movieResFile);
- }
- if (err != noErr) {
- return false;
- }
- }
-
- Rect rect;
- GetMovieBox(theMovie, &rect);
- MacOffsetRect(&rect, -rect.left, -rect.top);
- SetMovieBox(theMovie, &rect);
- m_size.SetSize(rect.right - rect.left, rect.bottom - rect.top);
-
- Rect nrect;
- GetMovieNaturalBoundsRect(theMovie, &nrect);
-
- if (!pQTVS) {
- theMC = NewMovieController(theMovie, &rect, mcTopLeftMovie|mcNotVisible);
- } else if (m_size.cx > 0 && m_size.cy > 0) {
- SetMovieDrawingCompleteProc(theMovie,
- movieDrawingCallWhenChanged,//|movieDrawingCallAlways,
- MyMovieDrawingCompleteProc, (long)this);
-
- if (CDC* pDC = GetDC()) {
- m_dc.CreateCompatibleDC(pDC);
- ReleaseDC(pDC);
-
- struct {
- BITMAPINFOHEADER bmiHeader;
- long bmiColors[256];
- } bmi;
-
- memset(&bmi, 0, sizeof(bmi));
-
- //int bpp = m_dc.GetDeviceCaps(BITSPIXEL);
- bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bmi.bmiHeader.biCompression = BI_BITFIELDS/*BI_RGB*/;
- LONG pitch = (m_size.cx + 0xF) & ~0xF;
- bmi.bmiHeader.biWidth = pitch;
- bmi.bmiHeader.biHeight = -m_size.cy;
- bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biBitCount = 32/*bpp*/;
-
- bmi.bmiColors[0] = /*bpp == 16 ? 0xf800 :*/ 0xff0000;
- bmi.bmiColors[1] = /*bpp == 16 ? 0x07e0 :*/ 0x00ff00;
- bmi.bmiColors[2] = /*bpp == 16 ? 0x001f :*/ 0x0000ff;
-
- void* bits;
- m_bm.Attach(CreateDIBSection(m_dc, (BITMAPINFO*)&bmi, DIB_RGB_COLORS, &bits, NULL, 0));
-
- QDErr err = NewGWorldFromHBITMAP(&m_offscreenGWorld, NULL, NULL, 0, m_bm.m_hObject, m_dc.m_hDC);
- UNREFERENCED_PARAMETER(err);
-
- SetMovieGWorld(theMovie, m_offscreenGWorld, GetGWorldDevice(m_offscreenGWorld));
-
- BITMAP bm;
- m_bm.GetObject(sizeof(bm), &bm);
- bm.bmWidth = m_size.cx;
- pQTVS->BeginBlt(bm);
- }
- }
-
- return (theMovie != NULL);
+ CloseMovie();
+
+ CComQIPtr<IQTVideoSurface> pQTVS = (IUnknown*)(INonDelegatingUnknown*)m_pGraph;
+
+ if (!pQTVS) {
+ // Set the port
+ SetGWorld((CGrafPtr)GetHWNDPort(m_hWnd), NULL);
+ }
+
+ if (fn.Find(_T("://")) > 0) {
+ Handle myHandle = NULL;
+ Size mySize = fn.GetLength() + 1;
+ myHandle = NewHandleClear(mySize);
+ if (!myHandle) {
+ return false;
+ }
+
+ BlockMove((LPSTR)(LPCSTR)CStringA(fn), *myHandle, mySize);
+
+ OSErr err = NewMovieFromDataRef(&theMovie, newMovieActive, NULL, myHandle, URLDataHandlerSubType);
+
+ DisposeHandle(myHandle);
+
+ if (err != noErr) {
+ return false;
+ }
+ } else {
+ if (!(fn.GetLength() > 0 && fn.GetLength() < 255)) {
+ return false;
+ }
+
+ CHAR buff[_MAX_PATH] = {0, 0};
+ WideCharToMultiByte(GetACP(), 0, fn, -1, buff + 1, _MAX_PATH - 1, 0, 0);
+ buff[0] = strlen(buff + 1);
+
+ // Make a FSSpec with a pascal string filename
+ FSSpec sfFile;
+ FSMakeFSSpec(0, 0L, (BYTE*)buff, &sfFile);
+
+ // Open the movie file
+ short movieResFile;
+ OSErr err = OpenMovieFile(&sfFile, &movieResFile, fsRdPerm);
+ if (err == noErr) {
+ err = NewMovieFromFile(&theMovie, movieResFile, 0, 0, newMovieActive, 0);
+ CloseMovieFile(movieResFile);
+ }
+ if (err != noErr) {
+ return false;
+ }
+ }
+
+ Rect rect;
+ GetMovieBox(theMovie, &rect);
+ MacOffsetRect(&rect, -rect.left, -rect.top);
+ SetMovieBox(theMovie, &rect);
+ m_size.SetSize(rect.right - rect.left, rect.bottom - rect.top);
+
+ Rect nrect;
+ GetMovieNaturalBoundsRect(theMovie, &nrect);
+
+ if (!pQTVS) {
+ theMC = NewMovieController(theMovie, &rect, mcTopLeftMovie | mcNotVisible);
+ } else if (m_size.cx > 0 && m_size.cy > 0) {
+ SetMovieDrawingCompleteProc(theMovie,
+ movieDrawingCallWhenChanged,//|movieDrawingCallAlways,
+ MyMovieDrawingCompleteProc, (long)this);
+
+ if (CDC* pDC = GetDC()) {
+ m_dc.CreateCompatibleDC(pDC);
+ ReleaseDC(pDC);
+
+ struct {
+ BITMAPINFOHEADER bmiHeader;
+ long bmiColors[256];
+ } bmi;
+
+ memset(&bmi, 0, sizeof(bmi));
+
+ //int bpp = m_dc.GetDeviceCaps(BITSPIXEL);
+ bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ bmi.bmiHeader.biCompression = BI_BITFIELDS/*BI_RGB*/;
+ LONG pitch = (m_size.cx + 0xF) & ~0xF;
+ bmi.bmiHeader.biWidth = pitch;
+ bmi.bmiHeader.biHeight = -m_size.cy;
+ bmi.bmiHeader.biPlanes = 1;
+ bmi.bmiHeader.biBitCount = 32/*bpp*/;
+
+ bmi.bmiColors[0] = /*bpp == 16 ? 0xf800 :*/ 0xff0000;
+ bmi.bmiColors[1] = /*bpp == 16 ? 0x07e0 :*/ 0x00ff00;
+ bmi.bmiColors[2] = /*bpp == 16 ? 0x001f :*/ 0x0000ff;
+
+ void* bits;
+ m_bm.Attach(CreateDIBSection(m_dc, (BITMAPINFO*)&bmi, DIB_RGB_COLORS, &bits, NULL, 0));
+
+ QDErr err = NewGWorldFromHBITMAP(&m_offscreenGWorld, NULL, NULL, 0, m_bm.m_hObject, m_dc.m_hDC);
+ UNREFERENCED_PARAMETER(err);
+
+ SetMovieGWorld(theMovie, m_offscreenGWorld, GetGWorldDevice(m_offscreenGWorld));
+
+ BITMAP bm;
+ m_bm.GetObject(sizeof(bm), &bm);
+ bm.bmWidth = m_size.cx;
+ pQTVS->BeginBlt(bm);
+ }
+ }
+
+ return (theMovie != NULL);
}
void CQuicktimeWindow::CloseMovie()
{
- if (theMC) {
- DisposeMovieController(theMC), theMC = NULL;
- }
- if (theMovie) {
- DisposeMovie(theMovie), theMovie = NULL;
- }
- m_size.SetSize(0, 0);
- m_fs = State_Stopped;
+ if (theMC) {
+ DisposeMovieController(theMC), theMC = NULL;
+ }
+ if (theMovie) {
+ DisposeMovie(theMovie), theMovie = NULL;
+ }
+ m_size.SetSize(0, 0);
+ m_fs = State_Stopped;
- if (m_offscreenGWorld) {
- DisposeGWorld(m_offscreenGWorld), m_offscreenGWorld = NULL;
- }
- m_dc.DeleteDC();
- m_bm.DeleteObject();
+ if (m_offscreenGWorld) {
+ DisposeGWorld(m_offscreenGWorld), m_offscreenGWorld = NULL;
+ }
+ m_dc.DeleteDC();
+ m_bm.DeleteObject();
}
void CQuicktimeWindow::Run()
{
- if (theMovie) {
- StartMovie(theMovie);
- if (!m_idEndPoller) {
- m_idEndPoller = SetTimer(1, 10, NULL); // 10ms -> 100fps max
- }
- }
+ if (theMovie) {
+ StartMovie(theMovie);
+ if (!m_idEndPoller) {
+ m_idEndPoller = SetTimer(1, 10, NULL); // 10ms -> 100fps max
+ }
+ }
- m_fs = State_Running;
+ m_fs = State_Running;
}
void CQuicktimeWindow::Pause()
{
- if (theMovie) {
- StopMovie(theMovie);
- if (m_idEndPoller) {
- KillTimer(m_idEndPoller), m_idEndPoller = 0;
- }
- }
+ if (theMovie) {
+ StopMovie(theMovie);
+ if (m_idEndPoller) {
+ KillTimer(m_idEndPoller), m_idEndPoller = 0;
+ }
+ }
- m_fs = State_Paused;
+ m_fs = State_Paused;
}
void CQuicktimeWindow::Stop()
{
- if (theMovie) {
- StopMovie(theMovie);
- GoToBeginningOfMovie(theMovie);
- if (m_idEndPoller) {
- KillTimer(m_idEndPoller), m_idEndPoller = 0;
- }
- }
+ if (theMovie) {
+ StopMovie(theMovie);
+ GoToBeginningOfMovie(theMovie);
+ if (m_idEndPoller) {
+ KillTimer(m_idEndPoller), m_idEndPoller = 0;
+ }
+ }
- m_fs = State_Stopped;
+ m_fs = State_Stopped;
}
FILTER_STATE CQuicktimeWindow::GetState()
{
- return m_fs;
+ return m_fs;
}
BEGIN_MESSAGE_MAP(CQuicktimeWindow, CPlayerWindow)
- ON_WM_CREATE()
- ON_WM_DESTROY()
- ON_WM_ERASEBKGND()
- ON_WM_TIMER()
+ ON_WM_CREATE()
+ ON_WM_DESTROY()
+ ON_WM_ERASEBKGND()
+ ON_WM_TIMER()
END_MESSAGE_MAP()
int CQuicktimeWindow::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
- if (__super::OnCreate(lpCreateStruct) == -1) {
- return -1;
- }
+ if (__super::OnCreate(lpCreateStruct) == -1) {
+ return -1;
+ }
- CComQIPtr<IQTVideoSurface> pQTVS = (IUnknown*)(INonDelegatingUnknown*)m_pGraph;
+ CComQIPtr<IQTVideoSurface> pQTVS = (IUnknown*)(INonDelegatingUnknown*)m_pGraph;
- if (!pQTVS) {
- // Create GrafPort <-> HWND association
- CreatePortAssociation(m_hWnd, NULL, 0);
- }
+ if (!pQTVS) {
+ // Create GrafPort <-> HWND association
+ CreatePortAssociation(m_hWnd, NULL, 0);
+ }
- return 0;
+ return 0;
}
void CQuicktimeWindow::OnDestroy()
{
- CPlayerWindow::OnDestroy();
+ CPlayerWindow::OnDestroy();
- // close any movies before destroying PortAssocation
- CloseMovie();
+ // close any movies before destroying PortAssocation
+ CloseMovie();
- CComQIPtr<IQTVideoSurface> pQTVS = (IUnknown*)(INonDelegatingUnknown*)m_pGraph;
+ CComQIPtr<IQTVideoSurface> pQTVS = (IUnknown*)(INonDelegatingUnknown*)m_pGraph;
- if (!pQTVS) {
- // Destroy the view's GrafPort <-> HWND association
- if (m_hWnd)
- if (CGrafPtr windowPort = (CGrafPtr)GetHWNDPort(m_hWnd)) {
- DestroyPortAssociation(windowPort);
- }
- }
+ if (!pQTVS) {
+ // Destroy the view's GrafPort <-> HWND association
+ if (m_hWnd)
+ if (CGrafPtr windowPort = (CGrafPtr)GetHWNDPort(m_hWnd)) {
+ DestroyPortAssociation(windowPort);
+ }
+ }
}
BOOL CQuicktimeWindow::OnEraseBkgnd(CDC* pDC)
{
- return m_fs != State_Stopped && theMovie ? TRUE : __super::OnEraseBkgnd(pDC);
+ return m_fs != State_Stopped && theMovie ? TRUE : __super::OnEraseBkgnd(pDC);
}
void CQuicktimeWindow::OnTimer(UINT_PTR nIDEvent)
{
- if (nIDEvent == m_idEndPoller && theMovie) {
- if (IsMovieDone(theMovie)) {
- Pause();
- m_pGraph->NotifyEvent(EC_COMPLETE);
- } else if (CComQIPtr<IQTVideoSurface> pQTVS = (IUnknown*)(INonDelegatingUnknown*)m_pGraph) {
- MoviesTask(theMovie, 0);
- /*
- long duration = 0, scale = 1000;
- OSErr err = QTGetTimeUntilNextTask(&duration, scale);
-
- // err is 0 but still doesn't seem to work... returns duration=0 always
- TRACE(_T("%d\n"), duration);
- KillTimer(m_idEndPoller);
- m_idEndPoller = SetTimer(m_idEndPoller, duration, NULL);
- */
- }
- }
-
- __super::OnTimer(nIDEvent);
+ if (nIDEvent == m_idEndPoller && theMovie) {
+ if (IsMovieDone(theMovie)) {
+ Pause();
+ m_pGraph->NotifyEvent(EC_COMPLETE);
+ } else if (CComQIPtr<IQTVideoSurface> pQTVS = (IUnknown*)(INonDelegatingUnknown*)m_pGraph) {
+ MoviesTask(theMovie, 0);
+ /*
+ long duration = 0, scale = 1000;
+ OSErr err = QTGetTimeUntilNextTask(&duration, scale);
+
+ // err is 0 but still doesn't seem to work... returns duration=0 always
+ TRACE(_T("%d\n"), duration);
+ KillTimer(m_idEndPoller);
+ m_idEndPoller = SetTimer(m_idEndPoller, duration, NULL);
+ */
+ }
+ }
+
+ __super::OnTimer(nIDEvent);
}
diff --git a/src/mpc-hc/QuicktimeGraph.h b/src/mpc-hc/QuicktimeGraph.h
index 290f9a8b5..eeb650b92 100644
--- a/src/mpc-hc/QuicktimeGraph.h
+++ b/src/mpc-hc/QuicktimeGraph.h
@@ -35,98 +35,98 @@
namespace DSObjects
{
- class CQuicktimeGraph;
+ class CQuicktimeGraph;
- class CQuicktimeWindow : public CPlayerWindow
- {
- CDC m_dc;
- CBitmap m_bm;
- QT::GWorldPtr m_offscreenGWorld;
+ class CQuicktimeWindow : public CPlayerWindow
+ {
+ CDC m_dc;
+ CBitmap m_bm;
+ QT::GWorldPtr m_offscreenGWorld;
- CQuicktimeGraph* m_pGraph;
- FILTER_STATE m_fs;
- UINT m_idEndPoller;
+ CQuicktimeGraph* m_pGraph;
+ FILTER_STATE m_fs;
+ UINT m_idEndPoller;
- static QT::OSErr MyMovieDrawingCompleteProc(QT::Movie theMovie, long refCon);
+ static QT::OSErr MyMovieDrawingCompleteProc(QT::Movie theMovie, long refCon);
- void ProcessMovieEvent(unsigned int message, unsigned int wParam, long lParam);
+ void ProcessMovieEvent(unsigned int message, unsigned int wParam, long lParam);
- protected:
- virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
+ protected:
+ virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
- public:
- CQuicktimeWindow(CQuicktimeGraph* pGraph);
+ public:
+ CQuicktimeWindow(CQuicktimeGraph* pGraph);
- bool OpenMovie(CString fn);
- void CloseMovie();
+ bool OpenMovie(CString fn);
+ void CloseMovie();
- void Run(), Pause(), Stop();
- FILTER_STATE GetState();
+ void Run(), Pause(), Stop();
+ FILTER_STATE GetState();
- QT::Movie theMovie;
- QT::MovieController theMC;
- CSize m_size;
+ QT::Movie theMovie;
+ QT::MovieController theMC;
+ CSize m_size;
- public:
- DECLARE_MESSAGE_MAP()
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
- afx_msg void OnDestroy();
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
- afx_msg void OnTimer(UINT_PTR nIDEvent);
- };
+ public:
+ DECLARE_MESSAGE_MAP()
+ afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
+ afx_msg void OnDestroy();
+ afx_msg BOOL OnEraseBkgnd(CDC* pDC);
+ afx_msg void OnTimer(UINT_PTR nIDEvent);
+ };
- class CQuicktimeGraph : public CBaseGraph, public IVideoFrameStep
- {
- protected:
- bool m_fQtInitialized;
+ class CQuicktimeGraph : public CBaseGraph, public IVideoFrameStep
+ {
+ protected:
+ bool m_fQtInitialized;
- CPlayerWindow m_wndWindowFrame;
- CQuicktimeWindow m_wndDestFrame;
+ CPlayerWindow m_wndWindowFrame;
+ CQuicktimeWindow m_wndDestFrame;
- CComPtr<ISubPicAllocatorPresenter> m_pQTAP;
+ CComPtr<ISubPicAllocatorPresenter> m_pQTAP;
- public:
- CQuicktimeGraph(HWND hParent, HRESULT& hr);
- virtual ~CQuicktimeGraph();
+ public:
+ CQuicktimeGraph(HWND hParent, HRESULT& hr);
+ virtual ~CQuicktimeGraph();
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- protected:
- // IGraphBuilder
- STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
+ protected:
+ // IGraphBuilder
+ STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
- // IMediaControl
- STDMETHODIMP Run();
- STDMETHODIMP Pause();
- STDMETHODIMP Stop();
- STDMETHODIMP GetState(LONG msTimeout, OAFilterState* pfs);
+ // IMediaControl
+ STDMETHODIMP Run();
+ STDMETHODIMP Pause();
+ STDMETHODIMP Stop();
+ STDMETHODIMP GetState(LONG msTimeout, OAFilterState* pfs);
- // IMediaSeeking
- STDMETHODIMP GetDuration(LONGLONG* pDuration);
- STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
- STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
- STDMETHODIMP SetRate(double dRate);
- STDMETHODIMP GetRate(double* pdRate);
+ // IMediaSeeking
+ STDMETHODIMP GetDuration(LONGLONG* pDuration);
+ STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
+ STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
+ STDMETHODIMP SetRate(double dRate);
+ STDMETHODIMP GetRate(double* pdRate);
- // IVideoWindow
- STDMETHODIMP SetWindowPosition(long Left, long Top, long Width, long Height);
+ // IVideoWindow
+ STDMETHODIMP SetWindowPosition(long Left, long Top, long Width, long Height);
- // IBasicVideo
- STDMETHODIMP SetDestinationPosition(long Left, long Top, long Width, long Height);
- STDMETHODIMP GetVideoSize(long* pWidth, long* pHeight);
+ // IBasicVideo
+ STDMETHODIMP SetDestinationPosition(long Left, long Top, long Width, long Height);
+ STDMETHODIMP GetVideoSize(long* pWidth, long* pHeight);
- // IBasicAudio
- STDMETHODIMP put_Volume(long lVolume);
- STDMETHODIMP get_Volume(long* plVolume);
+ // IBasicAudio
+ STDMETHODIMP put_Volume(long lVolume);
+ STDMETHODIMP get_Volume(long* plVolume);
- // IVideoFrameStep
- STDMETHODIMP Step(DWORD dwFrames, IUnknown* pStepObject);
- STDMETHODIMP CanStep(long bMultiple, IUnknown* pStepObject);
- STDMETHODIMP CancelStep();
+ // IVideoFrameStep
+ STDMETHODIMP Step(DWORD dwFrames, IUnknown* pStepObject);
+ STDMETHODIMP CanStep(long bMultiple, IUnknown* pStepObject);
+ STDMETHODIMP CancelStep();
- // IGraphEngine
- STDMETHODIMP_(engine_t) GetEngine();
- };
+ // IGraphEngine
+ STDMETHODIMP_(engine_t) GetEngine();
+ };
}
diff --git a/src/mpc-hc/RealMediaGraph.cpp b/src/mpc-hc/RealMediaGraph.cpp
index 7725584f0..2b5701509 100644
--- a/src/mpc-hc/RealMediaGraph.cpp
+++ b/src/mpc-hc/RealMediaGraph.cpp
@@ -41,438 +41,438 @@ using namespace DSObjects;
// CRealMediaPlayer
CRealMediaPlayer::CRealMediaPlayer(HWND hWndParent, CRealMediaGraph* pRMG)
- : CUnknown(NAME("CRealMediaPlayer"), NULL)
- , m_pRMG(pRMG)
- , m_hWndParent(hWndParent)
- , m_fpCreateEngine(NULL), m_fpCloseEngine(NULL), m_hRealMediaCore(NULL)
- , m_State(State_Stopped), m_UserState(State_Stopped), m_nCurrent(0), m_nDuration(0)
- , m_VideoSize(0, 0)
- , m_fVideoSizeChanged(true)
+ : CUnknown(NAME("CRealMediaPlayer"), NULL)
+ , m_pRMG(pRMG)
+ , m_hWndParent(hWndParent)
+ , m_fpCreateEngine(NULL), m_fpCloseEngine(NULL), m_hRealMediaCore(NULL)
+ , m_State(State_Stopped), m_UserState(State_Stopped), m_nCurrent(0), m_nDuration(0)
+ , m_VideoSize(0, 0)
+ , m_fVideoSizeChanged(true)
{
}
CRealMediaPlayer::~CRealMediaPlayer()
{
- Deinit();
+ Deinit();
}
bool CRealMediaPlayer::Init()
{
- CString prefs(_T("Software\\RealNetworks\\Preferences"));
-
- CRegKey key;
-
- if (ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, prefs + _T("\\DT_Common"), KEY_READ)) {
- return false;
- }
-
- TCHAR buff[_MAX_PATH];
- ULONG len = _countof(buff);
- if (ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len)) {
- return false;
- }
-
- key.Close();
-
- m_hRealMediaCore = LoadLibrary(CString(buff) + _T("pnen3260.dll"));
- if (!m_hRealMediaCore) {
- return false;
- }
-
- m_fpCreateEngine = (FPRMCREATEENGINE)GetProcAddress(m_hRealMediaCore, "CreateEngine");
- m_fpCloseEngine = (FPRMCLOSEENGINE)GetProcAddress(m_hRealMediaCore, "CloseEngine");
- m_fpSetDLLAccessPath = (FPRMSETDLLACCESSPATH)GetProcAddress(m_hRealMediaCore, "SetDLLAccessPath");
-
- if (!m_fpCreateEngine || !m_fpCloseEngine || !m_fpSetDLLAccessPath) {
- return false;
- }
-
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, prefs, KEY_READ)) {
- CString dllpaths;
-
- len = _countof(buff);
- for (int i = 0; ERROR_SUCCESS == key.EnumKey(i, buff, &len); i++,len = _countof(buff)) {
- CRegKey key2;
- TCHAR buff2[_MAX_PATH];
- ULONG len2 = _countof(buff2);
- if (ERROR_SUCCESS != key2.Open(HKEY_CLASSES_ROOT, prefs + _T("\\") + buff, KEY_READ)
- || ERROR_SUCCESS != key2.QueryStringValue(NULL, buff2, &len2)) {
- continue;
- }
-
- dllpaths += CString(buff) + '=' + buff2 + '|';
- }
-
- key.Close();
-
- if (!dllpaths.IsEmpty()) {
- char* s = DNew char[dllpaths.GetLength()+1];
- strcpy_s(s, dllpaths.GetLength() + 1, CStringA(dllpaths));
- for (size_t i = 0, j = strlen(s); i < j; i++) {
- if (s[i] == '|') {
- s[i] = '\0';
- }
- }
- m_fpSetDLLAccessPath(s);
- delete [] s;
- }
- }
-
- if (PNR_OK != m_fpCreateEngine(&m_pEngine)) {
- return false;
- }
-
- if (PNR_OK != m_pEngine->CreatePlayer(*&m_pPlayer)) {
- return false;
- }
-
- if (!(m_pSiteManager = m_pPlayer) || !(m_pCommonClassFactory = m_pPlayer)) {
- return false;
- }
-
- m_pAudioPlayer = m_pPlayer;
- m_pAudioPlayer->AddPostMixHook(static_cast<IRMAAudioHook*>(this), FALSE, FALSE);
- // m_pVolume = m_pAudioPlayer->GetDeviceVolume();
- m_pVolume = m_pAudioPlayer->GetAudioVolume();
-
- // IRMAVolume::SetVolume has a huge latency when used via GetAudioVolume,
- // but by lowering this audio pushdown thing it can get better
- CComQIPtr<IRMAAudioPushdown, &IID_IRMAAudioPushdown> pAP = m_pAudioPlayer;
- if (pAP) {
- pAP->SetAudioPushdown(300); // 100ms makes the playback sound choppy, 200ms looks ok, but for safety we set this to 300ms... :P
- }
-
- CComQIPtr<IRMAErrorSinkControl, &IID_IRMAErrorSinkControl> pErrorSinkControl = m_pPlayer;
- if (pErrorSinkControl) {
- pErrorSinkControl->AddErrorSink(static_cast<IRMAErrorSink*>(this), PNLOG_EMERG, PNLOG_INFO);
- }
-
- if (PNR_OK != m_pPlayer->AddAdviseSink(static_cast<IRMAClientAdviseSink*>(this))) {
- return false;
- }
-
- if (PNR_OK != m_pPlayer->SetClientContext((IUnknown*)(INonDelegatingUnknown*)(this))) {
- return false;
- }
-
- // TODO
- /*
- if (CComQIPtr<IRMAPreferences, &IID_IRMAPreferences> pPrefs = m_pPlayer)
- {
- CComPtr<IRMABuffer> pBuffer;
- HRESULT hr = pPrefs->ReadPref("HTTPProxyHost", *&pBuffer);
-
- UCHAR* pData = NULL;
- ULONG32 ulLength = 0;
- hr = pBuffer->Get(pData, ulLength);
-
- pBuffer = NULL;
- hr = m_pCommonClassFactory->CreateInstance(CLSID_IRMABuffer, (void**)&pBuffer);
- hr = pBuffer->SetSize(strlen("localhost")+1);
- pData = pBuffer->GetBuffer();
- strcpy_s((char*)pData, "localhost");
- hr = pBuffer->Set(pData, strlen("localhost")+1);
-
- pData = NULL;
- ulLength = 0;
- hr = pBuffer->Get(pData, ulLength);
-
- hr = pPrefs->WritePref("HTTPProxyHost", pBuffer);
-
- hr = hr;
- }
- */
- return true;
+ CString prefs(_T("Software\\RealNetworks\\Preferences"));
+
+ CRegKey key;
+
+ if (ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, prefs + _T("\\DT_Common"), KEY_READ)) {
+ return false;
+ }
+
+ TCHAR buff[_MAX_PATH];
+ ULONG len = _countof(buff);
+ if (ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len)) {
+ return false;
+ }
+
+ key.Close();
+
+ m_hRealMediaCore = LoadLibrary(CString(buff) + _T("pnen3260.dll"));
+ if (!m_hRealMediaCore) {
+ return false;
+ }
+
+ m_fpCreateEngine = (FPRMCREATEENGINE)GetProcAddress(m_hRealMediaCore, "CreateEngine");
+ m_fpCloseEngine = (FPRMCLOSEENGINE)GetProcAddress(m_hRealMediaCore, "CloseEngine");
+ m_fpSetDLLAccessPath = (FPRMSETDLLACCESSPATH)GetProcAddress(m_hRealMediaCore, "SetDLLAccessPath");
+
+ if (!m_fpCreateEngine || !m_fpCloseEngine || !m_fpSetDLLAccessPath) {
+ return false;
+ }
+
+ if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, prefs, KEY_READ)) {
+ CString dllpaths;
+
+ len = _countof(buff);
+ for (int i = 0; ERROR_SUCCESS == key.EnumKey(i, buff, &len); i++, len = _countof(buff)) {
+ CRegKey key2;
+ TCHAR buff2[_MAX_PATH];
+ ULONG len2 = _countof(buff2);
+ if (ERROR_SUCCESS != key2.Open(HKEY_CLASSES_ROOT, prefs + _T("\\") + buff, KEY_READ)
+ || ERROR_SUCCESS != key2.QueryStringValue(NULL, buff2, &len2)) {
+ continue;
+ }
+
+ dllpaths += CString(buff) + '=' + buff2 + '|';
+ }
+
+ key.Close();
+
+ if (!dllpaths.IsEmpty()) {
+ char* s = DNew char[dllpaths.GetLength() + 1];
+ strcpy_s(s, dllpaths.GetLength() + 1, CStringA(dllpaths));
+ for (size_t i = 0, j = strlen(s); i < j; i++) {
+ if (s[i] == '|') {
+ s[i] = '\0';
+ }
+ }
+ m_fpSetDLLAccessPath(s);
+ delete [] s;
+ }
+ }
+
+ if (PNR_OK != m_fpCreateEngine(&m_pEngine)) {
+ return false;
+ }
+
+ if (PNR_OK != m_pEngine->CreatePlayer(*& m_pPlayer)) {
+ return false;
+ }
+
+ if (!(m_pSiteManager = m_pPlayer) || !(m_pCommonClassFactory = m_pPlayer)) {
+ return false;
+ }
+
+ m_pAudioPlayer = m_pPlayer;
+ m_pAudioPlayer->AddPostMixHook(static_cast<IRMAAudioHook*>(this), FALSE, FALSE);
+ // m_pVolume = m_pAudioPlayer->GetDeviceVolume();
+ m_pVolume = m_pAudioPlayer->GetAudioVolume();
+
+ // IRMAVolume::SetVolume has a huge latency when used via GetAudioVolume,
+ // but by lowering this audio pushdown thing it can get better
+ CComQIPtr<IRMAAudioPushdown, &IID_IRMAAudioPushdown> pAP = m_pAudioPlayer;
+ if (pAP) {
+ pAP->SetAudioPushdown(300); // 100ms makes the playback sound choppy, 200ms looks ok, but for safety we set this to 300ms... :P
+ }
+
+ CComQIPtr<IRMAErrorSinkControl, &IID_IRMAErrorSinkControl> pErrorSinkControl = m_pPlayer;
+ if (pErrorSinkControl) {
+ pErrorSinkControl->AddErrorSink(static_cast<IRMAErrorSink*>(this), PNLOG_EMERG, PNLOG_INFO);
+ }
+
+ if (PNR_OK != m_pPlayer->AddAdviseSink(static_cast<IRMAClientAdviseSink*>(this))) {
+ return false;
+ }
+
+ if (PNR_OK != m_pPlayer->SetClientContext((IUnknown*)(INonDelegatingUnknown*)(this))) {
+ return false;
+ }
+
+ // TODO
+ /*
+ if (CComQIPtr<IRMAPreferences, &IID_IRMAPreferences> pPrefs = m_pPlayer)
+ {
+ CComPtr<IRMABuffer> pBuffer;
+ HRESULT hr = pPrefs->ReadPref("HTTPProxyHost", *&pBuffer);
+
+ UCHAR* pData = NULL;
+ ULONG32 ulLength = 0;
+ hr = pBuffer->Get(pData, ulLength);
+
+ pBuffer = NULL;
+ hr = m_pCommonClassFactory->CreateInstance(CLSID_IRMABuffer, (void**)&pBuffer);
+ hr = pBuffer->SetSize(strlen("localhost")+1);
+ pData = pBuffer->GetBuffer();
+ strcpy_s((char*)pData, "localhost");
+ hr = pBuffer->Set(pData, strlen("localhost")+1);
+
+ pData = NULL;
+ ulLength = 0;
+ hr = pBuffer->Get(pData, ulLength);
+
+ hr = pPrefs->WritePref("HTTPProxyHost", pBuffer);
+
+ hr = hr;
+ }
+ */
+ return true;
}
void CRealMediaPlayer::Deinit()
{
- if (m_pPlayer) {
- m_pPlayer->Stop();
+ if (m_pPlayer) {
+ m_pPlayer->Stop();
- CComQIPtr<IRMAErrorSinkControl, &IID_IRMAErrorSinkControl> pErrorSinkControl = m_pPlayer;
- if (pErrorSinkControl) {
- pErrorSinkControl->RemoveErrorSink(static_cast<IRMAErrorSink*>(this));
- }
+ CComQIPtr<IRMAErrorSinkControl, &IID_IRMAErrorSinkControl> pErrorSinkControl = m_pPlayer;
+ if (pErrorSinkControl) {
+ pErrorSinkControl->RemoveErrorSink(static_cast<IRMAErrorSink*>(this));
+ }
- m_pPlayer->RemoveAdviseSink(static_cast<IRMAClientAdviseSink*>(this));
+ m_pPlayer->RemoveAdviseSink(static_cast<IRMAClientAdviseSink*>(this));
- m_pVolume = NULL;
- m_pAudioPlayer->RemovePostMixHook(static_cast<IRMAAudioHook*>(this));
- m_pAudioPlayer.Release();
+ m_pVolume = NULL;
+ m_pAudioPlayer->RemovePostMixHook(static_cast<IRMAAudioHook*>(this));
+ m_pAudioPlayer.Release();
- m_pEngine->ClosePlayer(m_pPlayer);
+ m_pEngine->ClosePlayer(m_pPlayer);
- m_pSiteManager.Release();
- m_pCommonClassFactory.Release();
+ m_pSiteManager.Release();
+ m_pCommonClassFactory.Release();
- m_pPlayer = NULL;
- }
+ m_pPlayer = NULL;
+ }
- if (m_pEngine) {
- m_fpCloseEngine(m_pEngine);
- m_pEngine.Detach();
- }
+ if (m_pEngine) {
+ m_fpCloseEngine(m_pEngine);
+ m_pEngine.Detach();
+ }
- if (m_hRealMediaCore) {
- FreeLibrary(m_hRealMediaCore);
- m_hRealMediaCore = NULL;
- }
+ if (m_hRealMediaCore) {
+ FreeLibrary(m_hRealMediaCore);
+ m_hRealMediaCore = NULL;
+ }
}
STDMETHODIMP CRealMediaPlayer::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- QI2(IRMAErrorSink)
- QI2(IRMAClientAdviseSink)
- QI2(IRMAAuthenticationManager)
- QI2(IRMASiteSupplier)
- QI2(IRMAPassiveSiteWatcher)
- QI2(IRMAAudioHook)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI2(IRMAErrorSink)
+ QI2(IRMAClientAdviseSink)
+ QI2(IRMAAuthenticationManager)
+ QI2(IRMASiteSupplier)
+ QI2(IRMAPassiveSiteWatcher)
+ QI2(IRMAAudioHook)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
char* AllocateErrorMessage(const char* msg)
{
- char* errmsg = NULL;
- size_t len = strlen(msg);
- if (len > 0) {
- errmsg = (char*)CoTaskMemAlloc(len+1);
- if (errmsg) {
- strcpy_s(errmsg, len + 1, msg);
- }
- }
- return errmsg;
+ char* errmsg = NULL;
+ size_t len = strlen(msg);
+ if (len > 0) {
+ errmsg = (char*)CoTaskMemAlloc(len + 1);
+ if (errmsg) {
+ strcpy_s(errmsg, len + 1, msg);
+ }
+ }
+ return errmsg;
}
// IRMAErrorSink
STDMETHODIMP CRealMediaPlayer::ErrorOccurred(const UINT8 unSeverity, const UINT32 ulRMACode, const UINT32 ulUserCode, const char* pUserString, const char* pMoreInfoURL)
{
- char* errmsg = NULL;
+ char* errmsg = NULL;
- if (unSeverity < 5) {
- if (CComQIPtr<IRMAErrorMessages, &IID_IRMAErrorMessages> pErrorMessages = m_pPlayer) {
- CComPtr<IRMABuffer> pBuffer = pErrorMessages->GetErrorText(ulRMACode);
- if (pBuffer) {
- char* buff = (char*)pBuffer->GetBuffer();
- errmsg = AllocateErrorMessage(buff);
- }
- }
+ if (unSeverity < 5) {
+ if (CComQIPtr<IRMAErrorMessages, &IID_IRMAErrorMessages> pErrorMessages = m_pPlayer) {
+ CComPtr<IRMABuffer> pBuffer = pErrorMessages->GetErrorText(ulRMACode);
+ if (pBuffer) {
+ char* buff = (char*)pBuffer->GetBuffer();
+ errmsg = AllocateErrorMessage(buff);
+ }
+ }
- if (!errmsg) {
- errmsg = AllocateErrorMessage("RealMedia error");
- TRACE("RealMedia error\n");
- }
+ if (!errmsg) {
+ errmsg = AllocateErrorMessage("RealMedia error");
+ TRACE("RealMedia error\n");
+ }
- m_pRMG->NotifyEvent(EC_BG_ERROR, (LONG_PTR)errmsg, 0);
- }
+ m_pRMG->NotifyEvent(EC_BG_ERROR, (LONG_PTR)errmsg, 0);
+ }
- return PNR_OK;
+ return PNR_OK;
}
// IRMAClientAdviseSink
STDMETHODIMP CRealMediaPlayer::OnPosLength(UINT32 ulPosition, UINT32 ulLength)
{
- m_nCurrent = (REFERENCE_TIME)ulPosition*10000;
- m_nDuration = (REFERENCE_TIME)ulLength*10000;
- return PNR_OK;
+ m_nCurrent = (REFERENCE_TIME)ulPosition * 10000;
+ m_nDuration = (REFERENCE_TIME)ulLength * 10000;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaPlayer::OnPresentationOpened()
{
- return PNR_OK;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaPlayer::OnPresentationClosed()
{
- return PNR_OK;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaPlayer::OnStatisticsChanged()
{
- m_pRMG->NotifyEvent(EC_LENGTH_CHANGED);
- return PNR_OK;
+ m_pRMG->NotifyEvent(EC_LENGTH_CHANGED);
+ return PNR_OK;
}
STDMETHODIMP CRealMediaPlayer::OnPreSeek(UINT32 ulOldTime, UINT32 ulNewTime)
{
- m_nCurrent = (REFERENCE_TIME)ulNewTime*10000;
- return PNR_OK;
+ m_nCurrent = (REFERENCE_TIME)ulNewTime * 10000;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaPlayer::OnPostSeek(UINT32 ulOldTime, UINT32 ulNewTime)
{
- m_nCurrent = (REFERENCE_TIME)ulNewTime*10000;
- return PNR_OK;
+ m_nCurrent = (REFERENCE_TIME)ulNewTime * 10000;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaPlayer::OnStop()
{
- m_nCurrent = 0;
- m_State = State_Stopped;
- if (m_UserState != State_Stopped) {
- m_pRMG->NotifyEvent(EC_COMPLETE);
- }
- return PNR_OK;
+ m_nCurrent = 0;
+ m_State = State_Stopped;
+ if (m_UserState != State_Stopped) {
+ m_pRMG->NotifyEvent(EC_COMPLETE);
+ }
+ return PNR_OK;
}
STDMETHODIMP CRealMediaPlayer::OnPause(UINT32 ulTime)
{
- m_State = State_Paused;
- return PNR_OK;
+ m_State = State_Paused;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaPlayer::OnBegin(UINT32 ulTime)
{
- m_State = State_Running;
- return PNR_OK;
+ m_State = State_Running;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaPlayer::OnBuffering(UINT32 ulFlags, UINT16 unPercentComplete)
{
- m_unPercentComplete = unPercentComplete;
- return PNR_OK;
+ m_unPercentComplete = unPercentComplete;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaPlayer::OnContacting(const char* pHostName)
{
- return PNR_OK;
+ return PNR_OK;
}
// IRMAAuthenticationManager
STDMETHODIMP CRealMediaPlayer::HandleAuthenticationRequest(IRMAAuthenticationManagerResponse* pResponse)
{
- CAuthDlg dlg;
+ CAuthDlg dlg;
- if (dlg.DoModal() == IDOK) {
- pResponse->AuthenticationRequestDone(
- PNR_OK, CStringA(dlg.m_username), CStringA(dlg.m_password));
- return PNR_OK;
- }
+ if (dlg.DoModal() == IDOK) {
+ pResponse->AuthenticationRequestDone(
+ PNR_OK, CStringA(dlg.m_username), CStringA(dlg.m_password));
+ return PNR_OK;
+ }
- return pResponse->AuthenticationRequestDone(PNR_NOT_AUTHORIZED, NULL, NULL);
+ return pResponse->AuthenticationRequestDone(PNR_NOT_AUTHORIZED, NULL, NULL);
}
// IRMASiteSupplier
STDMETHODIMP CRealMediaPlayer::SitesNeeded(UINT32 uRequestID, IRMAValues* pProps)
{
- if (!pProps) {
- return PNR_INVALID_PARAMETER;
- }
+ if (!pProps) {
+ return PNR_INVALID_PARAMETER;
+ }
- if (m_pTheSite || m_pTheSite2 || !m_hWndParent) {
- return PNR_UNEXPECTED;
- }
+ if (m_pTheSite || m_pTheSite2 || !m_hWndParent) {
+ return PNR_UNEXPECTED;
+ }
- HRESULT hr = PNR_OK;
+ HRESULT hr = PNR_OK;
- if (!CreateSite(&m_pTheSite)) {
- return E_FAIL;
- }
+ if (!CreateSite(&m_pTheSite)) {
+ return E_FAIL;
+ }
- ULONG refc = ((IRMASite*)m_pTheSite)->AddRef();
- refc = ((IRMASite*)m_pTheSite)->Release();
+ ULONG refc = ((IRMASite*)m_pTheSite)->AddRef();
+ refc = ((IRMASite*)m_pTheSite)->Release();
- if (!(m_pTheSite2 = m_pTheSite)) {
- return E_NOINTERFACE;
- }
+ if (!(m_pTheSite2 = m_pTheSite)) {
+ return E_NOINTERFACE;
+ }
- CComQIPtr<IRMAValues, &IID_IRMAValues> pSiteProps = m_pTheSite;
- if (!pSiteProps) {
- return E_NOINTERFACE;
- }
+ CComQIPtr<IRMAValues, &IID_IRMAValues> pSiteProps = m_pTheSite;
+ if (!pSiteProps) {
+ return E_NOINTERFACE;
+ }
- IRMABuffer* pValue;
+ IRMABuffer* pValue;
- // no idea what these supposed to do... but they were in the example
- hr = pProps->GetPropertyCString("playto", pValue);
- if (PNR_OK == hr) {
- pSiteProps->SetPropertyCString("channel", pValue);
- pValue->Release();
- } else {
- hr = pProps->GetPropertyCString("name", pValue);
- if (PNR_OK == hr) {
- pSiteProps->SetPropertyCString("LayoutGroup", pValue);
- pValue->Release();
- }
- }
+ // no idea what these supposed to do... but they were in the example
+ hr = pProps->GetPropertyCString("playto", pValue);
+ if (PNR_OK == hr) {
+ pSiteProps->SetPropertyCString("channel", pValue);
+ pValue->Release();
+ } else {
+ hr = pProps->GetPropertyCString("name", pValue);
+ if (PNR_OK == hr) {
+ pSiteProps->SetPropertyCString("LayoutGroup", pValue);
+ pValue->Release();
+ }
+ }
- m_pTheSite2->AddPassiveSiteWatcher(static_cast<IRMAPassiveSiteWatcher*>(this));
+ m_pTheSite2->AddPassiveSiteWatcher(static_cast<IRMAPassiveSiteWatcher*>(this));
- hr = m_pSiteManager->AddSite(m_pTheSite);
- if (PNR_OK != hr) {
- return hr;
- }
+ hr = m_pSiteManager->AddSite(m_pTheSite);
+ if (PNR_OK != hr) {
+ return hr;
+ }
- m_CreatedSites[uRequestID] = m_pTheSite;
+ m_CreatedSites[uRequestID] = m_pTheSite;
- return hr;
+ return hr;
}
STDMETHODIMP CRealMediaPlayer::SitesNotNeeded(UINT32 uRequestID)
{
- IRMASite* pSite;
- if (!m_CreatedSites.Lookup(uRequestID, pSite)) {
- return PNR_INVALID_PARAMETER;
- }
+ IRMASite* pSite;
+ if (!m_CreatedSites.Lookup(uRequestID, pSite)) {
+ return PNR_INVALID_PARAMETER;
+ }
- m_CreatedSites.RemoveKey(uRequestID);
+ m_CreatedSites.RemoveKey(uRequestID);
- m_pSiteManager->RemoveSite(pSite);
+ m_pSiteManager->RemoveSite(pSite);
- m_pTheSite2->RemovePassiveSiteWatcher(static_cast<IRMAPassiveSiteWatcher*>(this));
+ m_pTheSite2->RemovePassiveSiteWatcher(static_cast<IRMAPassiveSiteWatcher*>(this));
- m_pTheSite.Release();
- m_pTheSite2.Release();
+ m_pTheSite.Release();
+ m_pTheSite2.Release();
- DestroySite(pSite);
+ DestroySite(pSite);
- return PNR_OK;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaPlayer::BeginChangeLayout()
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CRealMediaPlayer::DoneChangeLayout()
{
- if (m_fVideoSizeChanged) {
- m_pRMG->NotifyEvent(EC_VIDEO_SIZE_CHANGED, MAKELPARAM(m_VideoSize.cx, m_VideoSize.cy), 0);
- m_fVideoSizeChanged = false;
- }
+ if (m_fVideoSizeChanged) {
+ m_pRMG->NotifyEvent(EC_VIDEO_SIZE_CHANGED, MAKELPARAM(m_VideoSize.cx, m_VideoSize.cy), 0);
+ m_fVideoSizeChanged = false;
+ }
- return PNR_OK;
+ return PNR_OK;
}
// IRMAPassiveSiteWatcher
STDMETHODIMP CRealMediaPlayer::PositionChanged(PNxPoint* pos)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CRealMediaPlayer::SizeChanged(PNxSize* size)
{
- if (m_VideoSize.cx == 0 || m_VideoSize.cy == 0) {
- m_fVideoSizeChanged = true;
- m_VideoSize.cx = size->cx;
- m_VideoSize.cy = size->cy;
- }
- return PNR_OK;
+ if (m_VideoSize.cx == 0 || m_VideoSize.cy == 0) {
+ m_fVideoSizeChanged = true;
+ m_VideoSize.cx = size->cx;
+ m_VideoSize.cy = size->cy;
+ }
+ return PNR_OK;
}
// IRMAAudioHook
STDMETHODIMP CRealMediaPlayer::OnBuffer(RMAAudioData* pAudioInData, RMAAudioData* pAudioOutData)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
STDMETHODIMP CRealMediaPlayer::OnInit(RMAAudioFormat* pFormat)
{
- m_pRMG->NotifyEvent(EC_BG_AUDIO_CHANGED, pFormat->uChannels, 0);
- return PNR_OK;
+ m_pRMG->NotifyEvent(EC_BG_AUDIO_CHANGED, pFormat->uChannels, 0);
+ return PNR_OK;
}
//
@@ -480,96 +480,96 @@ STDMETHODIMP CRealMediaPlayer::OnInit(RMAAudioFormat* pFormat)
//
CRealMediaPlayerWindowed::CRealMediaPlayerWindowed(HWND hWndParent, CRealMediaGraph* pRMG)
- : CRealMediaPlayer(hWndParent, pRMG)
+ : CRealMediaPlayer(hWndParent, pRMG)
{
- if (!m_wndWindowFrame.CreateEx(WS_EX_NOPARENTNOTIFY, NULL, NULL, WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,
- CRect(0, 0, 0, 0), CWnd::FromHandle(m_hWndParent), 0, NULL)) {
- return;
- }
+ if (!m_wndWindowFrame.CreateEx(WS_EX_NOPARENTNOTIFY, NULL, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
+ CRect(0, 0, 0, 0), CWnd::FromHandle(m_hWndParent), 0, NULL)) {
+ return;
+ }
- if (!m_wndDestFrame.Create(NULL, NULL, WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,
- CRect(0, 0, 0, 0), &m_wndWindowFrame, 0, NULL)) {
- return;
- }
+ if (!m_wndDestFrame.Create(NULL, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
+ CRect(0, 0, 0, 0), &m_wndWindowFrame, 0, NULL)) {
+ return;
+ }
}
CRealMediaPlayerWindowed::~CRealMediaPlayerWindowed()
{
- m_wndDestFrame.DestroyWindow();
- m_wndWindowFrame.DestroyWindow();
+ m_wndDestFrame.DestroyWindow();
+ m_wndWindowFrame.DestroyWindow();
}
void CRealMediaPlayerWindowed::SetWindowRect(CRect r)
{
- if (IsWindow(m_wndWindowFrame.m_hWnd)) {
- m_wndWindowFrame.MoveWindow(r);
- }
+ if (IsWindow(m_wndWindowFrame.m_hWnd)) {
+ m_wndWindowFrame.MoveWindow(r);
+ }
}
void CRealMediaPlayerWindowed::SetDestRect(CRect r)
{
- if (IsWindow(m_wndDestFrame.m_hWnd)) {
- m_wndDestFrame.MoveWindow(r);
- }
+ if (IsWindow(m_wndDestFrame.m_hWnd)) {
+ m_wndDestFrame.MoveWindow(r);
+ }
- if (m_pTheSite) {
- PNxSize s = {r.Width(), r.Height()};
- m_pTheSite->SetSize(s);
- }
+ if (m_pTheSite) {
+ PNxSize s = {r.Width(), r.Height()};
+ m_pTheSite->SetSize(s);
+ }
}
bool CRealMediaPlayerWindowed::CreateSite(IRMASite** ppSite)
{
- if (!ppSite) {
- return false;
- }
+ if (!ppSite) {
+ return false;
+ }
- CComPtr<IRMASiteWindowed> pSiteWindowed;
- if (PNR_OK != m_pCommonClassFactory->CreateInstance(CLSID_IRMASiteWindowed, (void**)&pSiteWindowed)) {
- return false;
- }
+ CComPtr<IRMASiteWindowed> pSiteWindowed;
+ if (PNR_OK != m_pCommonClassFactory->CreateInstance(CLSID_IRMASiteWindowed, (void**)&pSiteWindowed)) {
+ return false;
+ }
- DWORD style = WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN;
- if (!AfxGetAppSettings().fIntRealMedia) {
- style |= WS_DISABLED;
- }
- if (PNR_OK != pSiteWindowed->Create(m_wndDestFrame.m_hWnd, style)) {
- return false;
- }
+ DWORD style = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
+ if (!AfxGetAppSettings().fIntRealMedia) {
+ style |= WS_DISABLED;
+ }
+ if (PNR_OK != pSiteWindowed->Create(m_wndDestFrame.m_hWnd, style)) {
+ return false;
+ }
- *ppSite = CComQIPtr<IRMASite, &IID_IRMASite>(pSiteWindowed).Detach();
- return !!(*ppSite);
+ *ppSite = CComQIPtr<IRMASite, &IID_IRMASite>(pSiteWindowed).Detach();
+ return !!(*ppSite);
}
void CRealMediaPlayerWindowed::DestroySite(IRMASite* pSite)
{
- if (CComQIPtr<IRMASiteWindowed, &IID_IRMASiteWindowed> pRMASiteWindowed = pSite) {
- pRMASiteWindowed->Destroy();
- }
+ if (CComQIPtr<IRMASiteWindowed, &IID_IRMASiteWindowed> pRMASiteWindowed = pSite) {
+ pRMASiteWindowed->Destroy();
+ }
}
//
// CRealMediaPlayerWindowless
//
CRealMediaPlayerWindowless::CRealMediaPlayerWindowless(HWND hWndParent, CRealMediaGraph* pRMG)
- : CRealMediaPlayer(hWndParent, pRMG)
-{
- AppSettings& s = AfxGetAppSettings();
-
- bool bFullscreen = (AfxGetApp()->m_pMainWnd != NULL) && (((CMainFrame*)AfxGetApp()->m_pMainWnd)->IsD3DFullScreenMode());
- switch (s.iRMVideoRendererType) {
- default:
- case VIDRNDT_RM_DX7:
- if (FAILED(CreateAP7(CLSID_RM7AllocatorPresenter, hWndParent, &m_pRMAP))) {
- return;
- }
- break;
- case VIDRNDT_RM_DX9:
- if (FAILED(CreateAP9(CLSID_RM9AllocatorPresenter, hWndParent, bFullscreen, &m_pRMAP))) {
- return;
- }
- break;
- }
+ : CRealMediaPlayer(hWndParent, pRMG)
+{
+ AppSettings& s = AfxGetAppSettings();
+
+ bool bFullscreen = (AfxGetApp()->m_pMainWnd != NULL) && (((CMainFrame*)AfxGetApp()->m_pMainWnd)->IsD3DFullScreenMode());
+ switch (s.iRMVideoRendererType) {
+ default:
+ case VIDRNDT_RM_DX7:
+ if (FAILED(CreateAP7(CLSID_RM7AllocatorPresenter, hWndParent, &m_pRMAP))) {
+ return;
+ }
+ break;
+ case VIDRNDT_RM_DX9:
+ if (FAILED(CreateAP9(CLSID_RM9AllocatorPresenter, hWndParent, bFullscreen, &m_pRMAP))) {
+ return;
+ }
+ break;
+ }
}
CRealMediaPlayerWindowless::~CRealMediaPlayerWindowless()
@@ -578,33 +578,33 @@ CRealMediaPlayerWindowless::~CRealMediaPlayerWindowless()
STDMETHODIMP CRealMediaPlayerWindowless::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- (m_pRMAP && (riid == __uuidof(ISubPicAllocatorPresenter) || riid == IID_IRMAVideoSurface)) ? m_pRMAP->QueryInterface(riid, ppv) :
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ (m_pRMAP && (riid == __uuidof(ISubPicAllocatorPresenter) || riid == IID_IRMAVideoSurface)) ? m_pRMAP->QueryInterface(riid, ppv) :
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
bool CRealMediaPlayerWindowless::CreateSite(IRMASite** ppSite)
{
- if (!ppSite || !m_pRMAP) {
- return false;
- }
+ if (!ppSite || !m_pRMAP) {
+ return false;
+ }
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- CRealMediaWindowlessSite* pWMWlS;
+ CRealMediaWindowlessSite* pWMWlS;
- CComPtr<IRMASiteWindowless> pSiteWindowless;
- pSiteWindowless = (IRMASiteWindowless*)(pWMWlS = DNew CRealMediaWindowlessSite(hr, m_pPlayer, NULL, NULL));
- if (FAILED(hr)) {
- return false;
- }
+ CComPtr<IRMASiteWindowless> pSiteWindowless;
+ pSiteWindowless = (IRMASiteWindowless*)(pWMWlS = DNew CRealMediaWindowlessSite(hr, m_pPlayer, NULL, NULL));
+ if (FAILED(hr)) {
+ return false;
+ }
- pWMWlS->SetBltService(CComQIPtr<IRMAVideoSurface, &IID_IRMAVideoSurface>(m_pRMAP));
+ pWMWlS->SetBltService(CComQIPtr<IRMAVideoSurface, &IID_IRMAVideoSurface>(m_pRMAP));
- *ppSite = CComQIPtr<IRMASite, &IID_IRMASite>(pSiteWindowless).Detach();
- return !!(*ppSite);
+ *ppSite = CComQIPtr<IRMASite, &IID_IRMASite>(pSiteWindowless).Detach();
+ return !!(*ppSite);
}
void CRealMediaPlayerWindowless::DestroySite(IRMASite* pSite)
@@ -613,199 +613,199 @@ void CRealMediaPlayerWindowless::DestroySite(IRMASite* pSite)
STDMETHODIMP CRealMediaPlayerWindowless::SizeChanged(PNxSize* size)
{
- if (CComQIPtr<IRMAVideoSurface, &IID_IRMAVideoSurface> pRMAVS = m_pRMAP) {
- RMABitmapInfoHeader BitmapInfo;
- memset(&BitmapInfo, 0, sizeof(BitmapInfo));
- BitmapInfo.biWidth = size->cx;
- BitmapInfo.biHeight = size->cy;
- pRMAVS->BeginOptimizedBlt(&BitmapInfo);
- }
+ if (CComQIPtr<IRMAVideoSurface, &IID_IRMAVideoSurface> pRMAVS = m_pRMAP) {
+ RMABitmapInfoHeader BitmapInfo;
+ memset(&BitmapInfo, 0, sizeof(BitmapInfo));
+ BitmapInfo.biWidth = size->cx;
+ BitmapInfo.biHeight = size->cy;
+ pRMAVS->BeginOptimizedBlt(&BitmapInfo);
+ }
- return __super::SizeChanged(size);
+ return __super::SizeChanged(size);
}
////////////////
CRealMediaGraph::CRealMediaGraph(HWND hWndParent, HRESULT& hr)
- : CBaseGraph()
+ : CBaseGraph()
{
- hr = S_OK;
+ hr = S_OK;
- m_pRMP = AfxGetAppSettings().iRMVideoRendererType == VIDRNDT_RM_DEFAULT
- ? (CRealMediaPlayer*)DNew CRealMediaPlayerWindowed(hWndParent, this)
- : (CRealMediaPlayer*)DNew CRealMediaPlayerWindowless(hWndParent, this);
+ m_pRMP = AfxGetAppSettings().iRMVideoRendererType == VIDRNDT_RM_DEFAULT
+ ? (CRealMediaPlayer*)DNew CRealMediaPlayerWindowed(hWndParent, this)
+ : (CRealMediaPlayer*)DNew CRealMediaPlayerWindowless(hWndParent, this);
- if (!m_pRMP) {
- hr = E_OUTOFMEMORY;
- return;
- }
+ if (!m_pRMP) {
+ hr = E_OUTOFMEMORY;
+ return;
+ }
- if (!m_pRMP->Init()) {
- delete m_pRMP, m_pRMP = NULL;
- hr = E_FAIL;
- return;
- }
+ if (!m_pRMP->Init()) {
+ delete m_pRMP, m_pRMP = NULL;
+ hr = E_FAIL;
+ return;
+ }
- m_pRMP->AddRef();
+ m_pRMP->AddRef();
}
CRealMediaGraph::~CRealMediaGraph()
{
- if (m_pRMP) {
- m_pRMP->Deinit();
- m_pRMP->Release();
- m_pRMP = NULL;
- }
+ if (m_pRMP) {
+ m_pRMP->Deinit();
+ m_pRMP->Release();
+ m_pRMP = NULL;
+ }
}
STDMETHODIMP CRealMediaGraph::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- (m_pRMP && (riid == __uuidof(ISubPicAllocatorPresenter) || riid == __uuidof(ISubPicAllocatorPresenter))) ? m_pRMP->QueryInterface(riid, ppv) :
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ (m_pRMP && (riid == __uuidof(ISubPicAllocatorPresenter) || riid == __uuidof(ISubPicAllocatorPresenter))) ? m_pRMP->QueryInterface(riid, ppv) :
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// IGraphBuilder
STDMETHODIMP CRealMediaGraph::RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList)
{
- m_fn = lpcwstrFile;
+ m_fn = lpcwstrFile;
- CHAR buff[_MAX_PATH] = {0};
- WideCharToMultiByte(GetACP(), 0, lpcwstrFile, -1, buff, _MAX_PATH, 0, 0);
+ CHAR buff[_MAX_PATH] = {0};
+ WideCharToMultiByte(GetACP(), 0, lpcwstrFile, -1, buff, _MAX_PATH, 0, 0);
- CStringA fn(buff);
- if (fn.Find("://") < 0) {
- fn = "file://" + fn;
- }
+ CStringA fn(buff);
+ if (fn.Find("://") < 0) {
+ fn = "file://" + fn;
+ }
- m_pRMP->m_unPercentComplete = 100;
+ m_pRMP->m_unPercentComplete = 100;
- ClearMessageQueue();
+ ClearMessageQueue();
- if (PNR_OK != m_pRMP->m_pPlayer->OpenURL(fn)) {
- return E_FAIL;
- }
+ if (PNR_OK != m_pRMP->m_pPlayer->OpenURL(fn)) {
+ return E_FAIL;
+ }
- m_pRMP->m_pPlayer->Pause()/*Stop()*/; // please, don't start just yet
+ m_pRMP->m_pPlayer->Pause()/*Stop()*/; // please, don't start just yet
- return S_OK;
+ return S_OK;
}
// IMediaControl
STDMETHODIMP CRealMediaGraph::Run()
{
- if (m_pRMP->m_pPlayer->IsDone()) {
- RenderFile(m_fn, NULL);
- }
+ if (m_pRMP->m_pPlayer->IsDone()) {
+ RenderFile(m_fn, NULL);
+ }
- m_pRMP->m_UserState = State_Running;
- return (PNR_OK == m_pRMP->m_pPlayer->Begin()) ? S_OK : E_FAIL;
+ m_pRMP->m_UserState = State_Running;
+ return (PNR_OK == m_pRMP->m_pPlayer->Begin()) ? S_OK : E_FAIL;
}
STDMETHODIMP CRealMediaGraph::Pause()
{
- m_pRMP->m_UserState = State_Paused;
- return (PNR_OK == m_pRMP->m_pPlayer->Pause()) ? S_OK : E_FAIL;
+ m_pRMP->m_UserState = State_Paused;
+ return (PNR_OK == m_pRMP->m_pPlayer->Pause()) ? S_OK : E_FAIL;
}
STDMETHODIMP CRealMediaGraph::Stop()
{
- m_pRMP->m_UserState = State_Stopped;
- return (PNR_OK == m_pRMP->m_pPlayer->Stop()) ? S_OK : E_FAIL;
+ m_pRMP->m_UserState = State_Stopped;
+ return (PNR_OK == m_pRMP->m_pPlayer->Stop()) ? S_OK : E_FAIL;
}
STDMETHODIMP CRealMediaGraph::GetState(LONG msTimeout, OAFilterState* pfs)
{
- return pfs ? *pfs = m_pRMP->m_State, S_OK : E_POINTER;
+ return pfs ? *pfs = m_pRMP->m_State, S_OK : E_POINTER;
}
// IMediaSeeking
STDMETHODIMP CRealMediaGraph::GetDuration(LONGLONG* pDuration)
{
- return pDuration ? *pDuration = m_pRMP->m_nDuration, S_OK : E_POINTER;
+ return pDuration ? *pDuration = m_pRMP->m_nDuration, S_OK : E_POINTER;
}
STDMETHODIMP CRealMediaGraph::GetCurrentPosition(LONGLONG* pCurrent)
{
- return pCurrent ? *pCurrent = m_pRMP->m_nCurrent, S_OK : E_POINTER;
+ return pCurrent ? *pCurrent = m_pRMP->m_nCurrent, S_OK : E_POINTER;
}
STDMETHODIMP CRealMediaGraph::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags)
{
- return (dwCurrentFlags&AM_SEEKING_AbsolutePositioning)
- && (PNR_OK == m_pRMP->m_pPlayer->Seek((ULONG)(*pCurrent / 10000))) ? S_OK : E_FAIL;
+ return (dwCurrentFlags & AM_SEEKING_AbsolutePositioning)
+ && (PNR_OK == m_pRMP->m_pPlayer->Seek((ULONG)(*pCurrent / 10000))) ? S_OK : E_FAIL;
}
// IVideoWindow
STDMETHODIMP CRealMediaGraph::SetWindowPosition(long Left, long Top, long Width, long Height)
{
- if (m_pRMP) {
- m_pRMP->SetWindowRect(CRect(CPoint(Left, Top), CSize(Width, Height)));
- }
+ if (m_pRMP) {
+ m_pRMP->SetWindowRect(CRect(CPoint(Left, Top), CSize(Width, Height)));
+ }
- return S_OK;
+ return S_OK;
}
// IBasicVideo
STDMETHODIMP CRealMediaGraph::SetDestinationPosition(long Left, long Top, long Width, long Height)// {return E_NOTIMPL;}
{
- m_pRMP->SetDestRect(CRect(CPoint(Left, Top), CSize(Width, Height)));
- return S_OK;
+ m_pRMP->SetDestRect(CRect(CPoint(Left, Top), CSize(Width, Height)));
+ return S_OK;
}
STDMETHODIMP CRealMediaGraph::GetVideoSize(long* pWidth, long* pHeight)
{
- if (!pWidth || !pHeight) {
- return E_POINTER;
- }
- *pWidth = m_pRMP->GetVideoSize().cx;
- *pHeight = m_pRMP->GetVideoSize().cy;
- return S_OK;
+ if (!pWidth || !pHeight) {
+ return E_POINTER;
+ }
+ *pWidth = m_pRMP->GetVideoSize().cx;
+ *pHeight = m_pRMP->GetVideoSize().cy;
+ return S_OK;
}
// IBasicAudio
STDMETHODIMP CRealMediaGraph::put_Volume(long lVolume)
{
- if (!m_pRMP->m_pVolume) {
- return E_UNEXPECTED;
- }
+ if (!m_pRMP->m_pVolume) {
+ return E_UNEXPECTED;
+ }
- UINT16 volume = (lVolume <= -10000) ? 0 : (UINT16)(pow(10.0, lVolume/4000.0)*100);
- volume = max(min(volume, 100), 0);
+ UINT16 volume = (lVolume <= -10000) ? 0 : (UINT16)(pow(10.0, lVolume / 4000.0) * 100);
+ volume = max(min(volume, 100), 0);
- return PNR_OK == m_pRMP->m_pVolume->SetVolume(volume) ? S_OK : E_FAIL;
+ return PNR_OK == m_pRMP->m_pVolume->SetVolume(volume) ? S_OK : E_FAIL;
}
STDMETHODIMP CRealMediaGraph::get_Volume(long* plVolume)
{
- if (!m_pRMP->m_pVolume) {
- return E_UNEXPECTED;
- }
+ if (!m_pRMP->m_pVolume) {
+ return E_UNEXPECTED;
+ }
- CheckPointer(plVolume, E_POINTER);
+ CheckPointer(plVolume, E_POINTER);
- *plVolume = (long)m_pRMP->m_pVolume->GetVolume(); // [?..100]
- if (*plVolume > 0) {
- *plVolume = min((long)(4000*log10(*plVolume/100.0f)), 0);
- } else {
- *plVolume = -10000;
- }
- return S_OK;
+ *plVolume = (long)m_pRMP->m_pVolume->GetVolume(); // [?..100]
+ if (*plVolume > 0) {
+ *plVolume = min((long)(4000 * log10(*plVolume / 100.0f)), 0);
+ } else {
+ *plVolume = -10000;
+ }
+ return S_OK;
}
// IAMOpenProgress
STDMETHODIMP CRealMediaGraph::QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent)
{
- *pllTotal = 100;
- *pllCurrent = m_pRMP->m_unPercentComplete > 0 ? m_pRMP->m_unPercentComplete : 100; // after seeking it drops to 0 and would show annoying "Buffering... (0%)" messages on the status line
- return S_OK;
+ *pllTotal = 100;
+ *pllCurrent = m_pRMP->m_unPercentComplete > 0 ? m_pRMP->m_unPercentComplete : 100; // after seeking it drops to 0 and would show annoying "Buffering... (0%)" messages on the status line
+ return S_OK;
}
// IGraphEngine
STDMETHODIMP_(engine_t) CRealMediaGraph::GetEngine()
{
- return RealMedia;
+ return RealMedia;
}
diff --git a/src/mpc-hc/RealMediaGraph.h b/src/mpc-hc/RealMediaGraph.h
index aad9a5f4a..66e184c1d 100644
--- a/src/mpc-hc/RealMediaGraph.h
+++ b/src/mpc-hc/RealMediaGraph.h
@@ -48,185 +48,185 @@
namespace DSObjects
{
- class CRealMediaGraph;
-
- class CRealMediaPlayer
- : public CUnknown
- , public IRMAErrorSink
- , public IRMAClientAdviseSink
- , public IRMAAuthenticationManager
- , public IRMASiteSupplier
- , public IRMAPassiveSiteWatcher
- , public IRMAAudioHook
-
- {
- protected:
- friend class CRealMediaGraph;
- CRealMediaGraph* m_pRMG; // IMPORTANT: do not ever AddRef on this from here
-
- HWND m_hWndParent;
- CSize m_VideoSize;
- bool m_fVideoSizeChanged;
-
- //
-
- DWORD m_wndStyle;
- CPlayerWindow m_wndWindowFrame, m_wndDestFrame;
-
- //
-
- FPRMCREATEENGINE m_fpCreateEngine;
- FPRMCLOSEENGINE m_fpCloseEngine;
- FPRMSETDLLACCESSPATH m_fpSetDLLAccessPath;
- HMODULE m_hRealMediaCore;
-
- CComPtr<IRMAClientEngine> m_pEngine;
- CComPtr<IRMAPlayer> m_pPlayer;
- CComQIPtr<IRMAAudioPlayer, &IID_IRMAAudioPlayer> m_pAudioPlayer;
- CComPtr<IRMAVolume> m_pVolume;
- CComQIPtr<IRMASiteManager, &IID_IRMASiteManager> m_pSiteManager;
- CComQIPtr<IRMACommonClassFactory, &IID_IRMACommonClassFactory> m_pCommonClassFactory;
-
- CComQIPtr<IRMASite, &IID_IRMASite> m_pTheSite;
- CComQIPtr<IRMASite2, &IID_IRMASite2> m_pTheSite2;
- CMap<UINT32, UINT32&, IRMASite*, IRMASite*&> m_CreatedSites;
-
- //
-
- OAFilterState m_State, m_UserState;
- REFERENCE_TIME m_nCurrent, m_nDuration;
-
- UINT16 m_unPercentComplete;
-
- //
-
- public:
- CRealMediaPlayer(HWND hWndParent, CRealMediaGraph* pRMG);
- virtual ~CRealMediaPlayer();
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- bool Init();
- void Deinit();
-
- virtual CSize GetVideoSize() {
- return m_VideoSize;
- }
- virtual void SetWindowRect(CRect r) {}
- virtual void SetDestRect(CRect r) {}
- virtual bool CreateSite(IRMASite** pSite) = 0;
- virtual void DestroySite(IRMASite* pSite) = 0;
-
- // IRMAErrorSink
- STDMETHODIMP ErrorOccurred(const UINT8 unSeverity, const UINT32 ulRMACode, const UINT32 ulUserCode, const char* pUserString, const char* pMoreInfoURL);
-
- // IRMAClientAdviseSink
- STDMETHODIMP OnPosLength(UINT32 ulPosition, UINT32 ulLength);
- STDMETHODIMP OnPresentationOpened();
- STDMETHODIMP OnPresentationClosed();
- STDMETHODIMP OnStatisticsChanged();
- STDMETHODIMP OnPreSeek(UINT32 ulOldTime, UINT32 ulNewTime);
- STDMETHODIMP OnPostSeek(UINT32 ulOldTime, UINT32 ulNewTime);
- STDMETHODIMP OnStop();
- STDMETHODIMP OnPause(UINT32 ulTime);
- STDMETHODIMP OnBegin(UINT32 ulTime);
- STDMETHODIMP OnBuffering(UINT32 ulFlags, UINT16 unPercentComplete);
- STDMETHODIMP OnContacting(const char* pHostName);
-
- // IRMAAuthenticationManager
- STDMETHODIMP HandleAuthenticationRequest(IRMAAuthenticationManagerResponse* pResponse);
-
- // IRMASiteSupplier
- STDMETHODIMP SitesNeeded(UINT32 uRequestID, IRMAValues* pSiteProps);
- STDMETHODIMP SitesNotNeeded(UINT32 uRequestID);
- STDMETHODIMP BeginChangeLayout();
- STDMETHODIMP DoneChangeLayout();
-
- // IRMAPassiveSiteWatcher
- STDMETHODIMP PositionChanged(PNxPoint* pos);
- STDMETHODIMP SizeChanged(PNxSize* size);
-
- // IRMAAudioHook
- STDMETHODIMP OnBuffer(RMAAudioData* pAudioInData, RMAAudioData* pAudioOutData);
- STDMETHODIMP OnInit(RMAAudioFormat* pFormat);
- };
-
- class CRealMediaPlayerWindowed
- : public CRealMediaPlayer
- {
- public:
- CRealMediaPlayerWindowed(HWND hWndParent, CRealMediaGraph* pRMG);
- virtual ~CRealMediaPlayerWindowed();
+ class CRealMediaGraph;
+
+ class CRealMediaPlayer
+ : public CUnknown
+ , public IRMAErrorSink
+ , public IRMAClientAdviseSink
+ , public IRMAAuthenticationManager
+ , public IRMASiteSupplier
+ , public IRMAPassiveSiteWatcher
+ , public IRMAAudioHook
+
+ {
+ protected:
+ friend class CRealMediaGraph;
+ CRealMediaGraph* m_pRMG; // IMPORTANT: do not ever AddRef on this from here
+
+ HWND m_hWndParent;
+ CSize m_VideoSize;
+ bool m_fVideoSizeChanged;
+
+ //
+
+ DWORD m_wndStyle;
+ CPlayerWindow m_wndWindowFrame, m_wndDestFrame;
+
+ //
+
+ FPRMCREATEENGINE m_fpCreateEngine;
+ FPRMCLOSEENGINE m_fpCloseEngine;
+ FPRMSETDLLACCESSPATH m_fpSetDLLAccessPath;
+ HMODULE m_hRealMediaCore;
+
+ CComPtr<IRMAClientEngine> m_pEngine;
+ CComPtr<IRMAPlayer> m_pPlayer;
+ CComQIPtr<IRMAAudioPlayer, &IID_IRMAAudioPlayer> m_pAudioPlayer;
+ CComPtr<IRMAVolume> m_pVolume;
+ CComQIPtr<IRMASiteManager, &IID_IRMASiteManager> m_pSiteManager;
+ CComQIPtr<IRMACommonClassFactory, &IID_IRMACommonClassFactory> m_pCommonClassFactory;
+
+ CComQIPtr<IRMASite, &IID_IRMASite> m_pTheSite;
+ CComQIPtr<IRMASite2, &IID_IRMASite2> m_pTheSite2;
+ CMap<UINT32, UINT32&, IRMASite*, IRMASite*&> m_CreatedSites;
+
+ //
+
+ OAFilterState m_State, m_UserState;
+ REFERENCE_TIME m_nCurrent, m_nDuration;
+
+ UINT16 m_unPercentComplete;
+
+ //
+
+ public:
+ CRealMediaPlayer(HWND hWndParent, CRealMediaGraph* pRMG);
+ virtual ~CRealMediaPlayer();
+
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ bool Init();
+ void Deinit();
+
+ virtual CSize GetVideoSize() {
+ return m_VideoSize;
+ }
+ virtual void SetWindowRect(CRect r) {}
+ virtual void SetDestRect(CRect r) {}
+ virtual bool CreateSite(IRMASite** pSite) = 0;
+ virtual void DestroySite(IRMASite* pSite) = 0;
+
+ // IRMAErrorSink
+ STDMETHODIMP ErrorOccurred(const UINT8 unSeverity, const UINT32 ulRMACode, const UINT32 ulUserCode, const char* pUserString, const char* pMoreInfoURL);
+
+ // IRMAClientAdviseSink
+ STDMETHODIMP OnPosLength(UINT32 ulPosition, UINT32 ulLength);
+ STDMETHODIMP OnPresentationOpened();
+ STDMETHODIMP OnPresentationClosed();
+ STDMETHODIMP OnStatisticsChanged();
+ STDMETHODIMP OnPreSeek(UINT32 ulOldTime, UINT32 ulNewTime);
+ STDMETHODIMP OnPostSeek(UINT32 ulOldTime, UINT32 ulNewTime);
+ STDMETHODIMP OnStop();
+ STDMETHODIMP OnPause(UINT32 ulTime);
+ STDMETHODIMP OnBegin(UINT32 ulTime);
+ STDMETHODIMP OnBuffering(UINT32 ulFlags, UINT16 unPercentComplete);
+ STDMETHODIMP OnContacting(const char* pHostName);
+
+ // IRMAAuthenticationManager
+ STDMETHODIMP HandleAuthenticationRequest(IRMAAuthenticationManagerResponse* pResponse);
+
+ // IRMASiteSupplier
+ STDMETHODIMP SitesNeeded(UINT32 uRequestID, IRMAValues* pSiteProps);
+ STDMETHODIMP SitesNotNeeded(UINT32 uRequestID);
+ STDMETHODIMP BeginChangeLayout();
+ STDMETHODIMP DoneChangeLayout();
+
+ // IRMAPassiveSiteWatcher
+ STDMETHODIMP PositionChanged(PNxPoint* pos);
+ STDMETHODIMP SizeChanged(PNxSize* size);
+
+ // IRMAAudioHook
+ STDMETHODIMP OnBuffer(RMAAudioData* pAudioInData, RMAAudioData* pAudioOutData);
+ STDMETHODIMP OnInit(RMAAudioFormat* pFormat);
+ };
+
+ class CRealMediaPlayerWindowed
+ : public CRealMediaPlayer
+ {
+ public:
+ CRealMediaPlayerWindowed(HWND hWndParent, CRealMediaGraph* pRMG);
+ virtual ~CRealMediaPlayerWindowed();
- void SetWindowRect(CRect r);
- void SetDestRect(CRect r);
+ void SetWindowRect(CRect r);
+ void SetDestRect(CRect r);
- bool CreateSite(IRMASite** pSite);
- void DestroySite(IRMASite* pSite);
- };
+ bool CreateSite(IRMASite** pSite);
+ void DestroySite(IRMASite* pSite);
+ };
- class CRealMediaPlayerWindowless
- : public CRealMediaPlayer
- {
- CComPtr<ISubPicAllocatorPresenter> m_pRMAP;
-
- public:
- CRealMediaPlayerWindowless(HWND hWndParent, CRealMediaGraph* pRMG);
- virtual ~CRealMediaPlayerWindowless();
-
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- bool CreateSite(IRMASite** pSite);
- void DestroySite(IRMASite* pSite);
-
- STDMETHODIMP SizeChanged(PNxSize* size);
- };
-
- class CRealMediaGraph : public CBaseGraph
- {
- CRealMediaPlayer* m_pRMP; // TODO: access m_pRMP through a private interface
+ class CRealMediaPlayerWindowless
+ : public CRealMediaPlayer
+ {
+ CComPtr<ISubPicAllocatorPresenter> m_pRMAP;
+
+ public:
+ CRealMediaPlayerWindowless(HWND hWndParent, CRealMediaGraph* pRMG);
+ virtual ~CRealMediaPlayerWindowless();
+
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ bool CreateSite(IRMASite** pSite);
+ void DestroySite(IRMASite* pSite);
+
+ STDMETHODIMP SizeChanged(PNxSize* size);
+ };
+
+ class CRealMediaGraph : public CBaseGraph
+ {
+ CRealMediaPlayer* m_pRMP; // TODO: access m_pRMP through a private interface
- CStringW m_fn;
-
- public:
- CRealMediaGraph(HWND hWndParent, HRESULT& hr); // in windowless mode IVideoWindow::* will return E_NOTIMPL, use ISubPicAllocatorPresenter instead
- virtual ~CRealMediaGraph();
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- protected:
- // IGraphBuilder
- STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
-
- // IMediaControl
- STDMETHODIMP Run();
- STDMETHODIMP Pause();
- STDMETHODIMP Stop();
- STDMETHODIMP GetState(LONG msTimeout, OAFilterState* pfs);
-
- // IMediaSeeking
- STDMETHODIMP GetDuration(LONGLONG* pDuration);
- STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
- STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
-
- // IVideoWindow
- STDMETHODIMP SetWindowPosition(long Left, long Top, long Width, long Height);
-
- // IBasicVideo
- STDMETHODIMP SetDestinationPosition(long Left, long Top, long Width, long Height);
- STDMETHODIMP GetVideoSize(long* pWidth, long* pHeight);
-
- // IBasicAudio
- STDMETHODIMP put_Volume(long lVolume);
- STDMETHODIMP get_Volume(long* plVolume);
-
- // IAMOpenProgress
- STDMETHODIMP QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent);
-
- // IGraphEngine
- STDMETHODIMP_(engine_t) GetEngine();
- };
+ CStringW m_fn;
+
+ public:
+ CRealMediaGraph(HWND hWndParent, HRESULT& hr); // in windowless mode IVideoWindow::* will return E_NOTIMPL, use ISubPicAllocatorPresenter instead
+ virtual ~CRealMediaGraph();
+
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ protected:
+ // IGraphBuilder
+ STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
+
+ // IMediaControl
+ STDMETHODIMP Run();
+ STDMETHODIMP Pause();
+ STDMETHODIMP Stop();
+ STDMETHODIMP GetState(LONG msTimeout, OAFilterState* pfs);
+
+ // IMediaSeeking
+ STDMETHODIMP GetDuration(LONGLONG* pDuration);
+ STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
+ STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
+
+ // IVideoWindow
+ STDMETHODIMP SetWindowPosition(long Left, long Top, long Width, long Height);
+
+ // IBasicVideo
+ STDMETHODIMP SetDestinationPosition(long Left, long Top, long Width, long Height);
+ STDMETHODIMP GetVideoSize(long* pWidth, long* pHeight);
+
+ // IBasicAudio
+ STDMETHODIMP put_Volume(long lVolume);
+ STDMETHODIMP get_Volume(long* plVolume);
+
+ // IAMOpenProgress
+ STDMETHODIMP QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent);
+
+ // IGraphEngine
+ STDMETHODIMP_(engine_t) GetEngine();
+ };
}
diff --git a/src/mpc-hc/RealMediaWindowlessSite.cpp b/src/mpc-hc/RealMediaWindowlessSite.cpp
index 316d39314..bbaa144ad 100644
--- a/src/mpc-hc/RealMediaWindowlessSite.cpp
+++ b/src/mpc-hc/RealMediaWindowlessSite.cpp
@@ -34,81 +34,81 @@ using namespace DSObjects;
void DSObjects::ExtractRects(REGION* pRegion)
{
- LPRGNDATA lpRgnData;
+ LPRGNDATA lpRgnData;
- DWORD sizeNeeed = GetRegionData((HRGN)pRegion->pOSRegion, 0, NULL);
+ DWORD sizeNeeed = GetRegionData((HRGN)pRegion->pOSRegion, 0, NULL);
- lpRgnData = (LPRGNDATA)DNew char[sizeNeeed];
- DWORD returnValue = GetRegionData((HRGN)pRegion->pOSRegion, sizeNeeed, lpRgnData);
- UNREFERENCED_PARAMETER(returnValue);
+ lpRgnData = (LPRGNDATA)DNew char[sizeNeeed];
+ DWORD returnValue = GetRegionData((HRGN)pRegion->pOSRegion, sizeNeeed, lpRgnData);
+ UNREFERENCED_PARAMETER(returnValue);
- PN_VECTOR_DELETE(pRegion->rects);
+ PN_VECTOR_DELETE(pRegion->rects);
- pRegion->numRects = lpRgnData->rdh.nCount;
- pRegion->extents.left = lpRgnData->rdh.rcBound.left;
- pRegion->extents.top = lpRgnData->rdh.rcBound.top;
- pRegion->extents.right = lpRgnData->rdh.rcBound.right;
- pRegion->extents.bottom = lpRgnData->rdh.rcBound.bottom;
+ pRegion->numRects = lpRgnData->rdh.nCount;
+ pRegion->extents.left = lpRgnData->rdh.rcBound.left;
+ pRegion->extents.top = lpRgnData->rdh.rcBound.top;
+ pRegion->extents.right = lpRgnData->rdh.rcBound.right;
+ pRegion->extents.bottom = lpRgnData->rdh.rcBound.bottom;
- if (lpRgnData->rdh.nCount) {
- pRegion->rects = DNew PNxRect[lpRgnData->rdh.nCount];
+ if (lpRgnData->rdh.nCount) {
+ pRegion->rects = DNew PNxRect[lpRgnData->rdh.nCount];
- // now extract the information.
+ // now extract the information.
- for (int j = 0; j < (int) lpRgnData->rdh.nCount; j++) {
- RECT* pRect = (RECT*)lpRgnData->Buffer;
- pRegion->rects[j].left = pRect[j].left;
- pRegion->rects[j].top = pRect[j].top;
- pRegion->rects[j].right = pRect[j].right;
- pRegion->rects[j].bottom = pRect[j].bottom;
- }
- }
+ for (int j = 0; j < (int) lpRgnData->rdh.nCount; j++) {
+ RECT* pRect = (RECT*)lpRgnData->Buffer;
+ pRegion->rects[j].left = pRect[j].left;
+ pRegion->rects[j].top = pRect[j].top;
+ pRegion->rects[j].right = pRect[j].right;
+ pRegion->rects[j].bottom = pRect[j].bottom;
+ }
+ }
- PN_VECTOR_DELETE(lpRgnData);
+ PN_VECTOR_DELETE(lpRgnData);
}
REGION* DSObjects::RMACreateRectRegion(int left, int top, int right, int bottom)
{
- REGION* retVal = DNew REGION;
- retVal->pOSRegion = (void*)CreateRectRgn(left, top, right, bottom);
- ExtractRects(retVal);
- return retVal;
+ REGION* retVal = DNew REGION;
+ retVal->pOSRegion = (void*)CreateRectRgn(left, top, right, bottom);
+ ExtractRects(retVal);
+ return retVal;
}
void DSObjects::RMASubtractRegion(REGION* regM, REGION* regS, REGION* regD)
{
- CombineRgn((HRGN)regD->pOSRegion, (HRGN)regM->pOSRegion, (HRGN)regS->pOSRegion, RGN_DIFF);
- ExtractRects(regD);
+ CombineRgn((HRGN)regD->pOSRegion, (HRGN)regM->pOSRegion, (HRGN)regS->pOSRegion, RGN_DIFF);
+ ExtractRects(regD);
}
void DSObjects::RMAUnionRegion(REGION* reg1, REGION* reg2, REGION* regD)
{
- CombineRgn((HRGN)regD->pOSRegion, (HRGN)reg1->pOSRegion, (HRGN)reg2->pOSRegion, RGN_OR);
- ExtractRects(regD);
+ CombineRgn((HRGN)regD->pOSRegion, (HRGN)reg1->pOSRegion, (HRGN)reg2->pOSRegion, RGN_OR);
+ ExtractRects(regD);
}
void DSObjects::RMAIntersectRegion(REGION* reg1, REGION* reg2, REGION* regD)
{
- CombineRgn((HRGN)regD->pOSRegion, (HRGN)reg1->pOSRegion, (HRGN)reg2->pOSRegion, RGN_AND);
- ExtractRects(regD);
+ CombineRgn((HRGN)regD->pOSRegion, (HRGN)reg1->pOSRegion, (HRGN)reg2->pOSRegion, RGN_AND);
+ ExtractRects(regD);
}
BOOL DSObjects::RMAEqualRegion(REGION* reg1, REGION* reg2)
{
- return EqualRgn((HRGN)reg1->pOSRegion, (HRGN)reg2->pOSRegion)
- && !memcmp(&reg1->extents, &reg2->extents, sizeof(PNxRect)) ? TRUE : FALSE;
+ return EqualRgn((HRGN)reg1->pOSRegion, (HRGN)reg2->pOSRegion)
+ && !memcmp(&reg1->extents, &reg2->extents, sizeof(PNxRect)) ? TRUE : FALSE;
}
void DSObjects::RMADestroyRegion(REGION* reg)
{
- if (reg) DeleteObject((HRGN)reg->pOSRegion),
- PN_VECTOR_DELETE(reg->rects);
- PN_DELETE(reg);
+ if (reg) DeleteObject((HRGN)reg->pOSRegion),
+ PN_VECTOR_DELETE(reg->rects);
+ PN_DELETE(reg);
}
REGION* DSObjects::RMACreateRegion()
{
- return RMACreateRectRegion(0,0,0,0);
+ return RMACreateRectRegion(0, 0, 0, 0);
}
//
@@ -116,612 +116,612 @@ REGION* DSObjects::RMACreateRegion()
//
CRealMediaWindowlessSite::CRealMediaWindowlessSite(HRESULT& hr, IUnknown* pContext, CRealMediaWindowlessSite* pParentSite, IUnknown* pUnkOuter)
- : CUnknown(NAME("CRealMediaWindowlessSite"), pUnkOuter, &hr)
- , m_pContext(pContext)
- , m_pParentSite(pParentSite)
- , m_pCCF(pContext)
- , m_fDamaged(false), m_fInRedraw(false), m_fIsVisible(true)
- , m_lZOrder(0)
- , m_pRegion(NULL), m_pRegionWithoutChildren(NULL)
+ : CUnknown(NAME("CRealMediaWindowlessSite"), pUnkOuter, &hr)
+ , m_pContext(pContext)
+ , m_pParentSite(pParentSite)
+ , m_pCCF(pContext)
+ , m_fDamaged(false), m_fInRedraw(false), m_fIsVisible(true)
+ , m_lZOrder(0)
+ , m_pRegion(NULL), m_pRegionWithoutChildren(NULL)
{
- m_size.cx = m_size.cy = 0;
- m_position.x = m_position.y = 0;
+ m_size.cx = m_size.cy = 0;
+ m_position.x = m_position.y = 0;
- memset(&m_lastBitmapInfo, 0, sizeof(m_lastBitmapInfo));
+ memset(&m_lastBitmapInfo, 0, sizeof(m_lastBitmapInfo));
- hr = S_OK;
+ hr = S_OK;
- if (!m_pContext || !m_pCCF) {
- hr = E_POINTER;
- return;
- }
+ if (!m_pContext || !m_pCCF) {
+ hr = E_POINTER;
+ return;
+ }
- m_pCCF->CreateInstance(CLSID_IRMAValues, (void**)&m_pValues);
+ m_pCCF->CreateInstance(CLSID_IRMAValues, (void**)&m_pValues);
}
CRealMediaWindowlessSite::~CRealMediaWindowlessSite()
{
- POSITION pos = m_pChildren.GetHeadPosition();
- while (pos) {
- DestroyChild(m_pChildren.GetNext(pos));
- }
+ POSITION pos = m_pChildren.GetHeadPosition();
+ while (pos) {
+ DestroyChild(m_pChildren.GetNext(pos));
+ }
- RMADestroyRegion(m_pRegion);
- RMADestroyRegion(m_pRegionWithoutChildren);
+ RMADestroyRegion(m_pRegion);
+ RMADestroyRegion(m_pRegionWithoutChildren);
}
STDMETHODIMP CRealMediaWindowlessSite::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- return
- QI2(IRMASite)
- QI2(IRMASite2)
- QI2(IRMASiteWindowless)
- QI2(IRMAVideoSurface)
- (m_pValues && m_pValues->QueryInterface(riid, ppv) == PNR_OK) ? PNR_OK :
- CUnknown::NonDelegatingQueryInterface(riid, ppv);
+ return
+ QI2(IRMASite)
+ QI2(IRMASite2)
+ QI2(IRMASiteWindowless)
+ QI2(IRMAVideoSurface)
+ (m_pValues && m_pValues->QueryInterface(riid, ppv) == PNR_OK) ? PNR_OK :
+ CUnknown::NonDelegatingQueryInterface(riid, ppv);
}
// public
void CRealMediaWindowlessSite::GetTopLeft(PNxPoint* pPoint)
{
- pPoint->x += m_position.x;
- pPoint->y += m_position.y;
+ pPoint->x += m_position.x;
+ pPoint->y += m_position.y;
- if (m_pParentSite) {
- m_pParentSite->GetTopLeft(pPoint);
- }
+ if (m_pParentSite) {
+ m_pParentSite->GetTopLeft(pPoint);
+ }
}
REGION* CRealMediaWindowlessSite::GetRegion()
{
- return m_pRegion;
+ return m_pRegion;
}
// private
void CRealMediaWindowlessSite::RecomputeRegion()
{
- if (m_pParentSite) {
- m_pParentSite->RecomputeRegion();
- } else {
- InternalRecomputeRegion();
- }
+ if (m_pParentSite) {
+ m_pParentSite->RecomputeRegion();
+ } else {
+ InternalRecomputeRegion();
+ }
}
void CRealMediaWindowlessSite::InternalRecomputeRegion()
{
- ComputeRegion();
+ ComputeRegion();
- POSITION pos = m_pChildren.GetHeadPosition();
- while (pos) {
- CRealMediaWindowlessSite* pSite = (CRealMediaWindowlessSite*)(IRMASite*)m_pChildren.GetNext(pos);
- if (pSite) {
- pSite->InternalRecomputeRegion();
- }
- }
+ POSITION pos = m_pChildren.GetHeadPosition();
+ while (pos) {
+ CRealMediaWindowlessSite* pSite = (CRealMediaWindowlessSite*)(IRMASite*)m_pChildren.GetNext(pos);
+ if (pSite) {
+ pSite->InternalRecomputeRegion();
+ }
+ }
}
void CRealMediaWindowlessSite::ComputeRegion()
{
- REGION* pTempRegion = NULL;
+ REGION* pTempRegion = NULL;
- if (m_pRegion) {
- pTempRegion = RMACreateRegion();
- RMAUnionRegion(pTempRegion, m_pRegion, pTempRegion);
- RMADestroyRegion(m_pRegion);
- }
+ if (m_pRegion) {
+ pTempRegion = RMACreateRegion();
+ RMAUnionRegion(pTempRegion, m_pRegion, pTempRegion);
+ RMADestroyRegion(m_pRegion);
+ }
- if (m_pRegionWithoutChildren) {
- RMADestroyRegion(m_pRegionWithoutChildren);
- }
+ if (m_pRegionWithoutChildren) {
+ RMADestroyRegion(m_pRegionWithoutChildren);
+ }
- PNxPoint topleft = {0,0};
- GetTopLeft(&topleft);
+ PNxPoint topleft = {0, 0};
+ GetTopLeft(&topleft);
- if (IsSiteVisible()) {
- m_pRegionWithoutChildren = RMACreateRectRegion(topleft.x, topleft.y, topleft.x + m_size.cx, topleft.y + m_size.cy);
+ if (IsSiteVisible()) {
+ m_pRegionWithoutChildren = RMACreateRectRegion(topleft.x, topleft.y, topleft.x + m_size.cx, topleft.y + m_size.cy);
- if (m_pParentSite) {
- RMAIntersectRegion(m_pRegionWithoutChildren, m_pParentSite->m_pRegionWithoutChildren, m_pRegionWithoutChildren);
+ if (m_pParentSite) {
+ RMAIntersectRegion(m_pRegionWithoutChildren, m_pParentSite->m_pRegionWithoutChildren, m_pRegionWithoutChildren);
- POSITION pos = m_pParentSite->m_pChildren.GetHeadPosition();
- while (pos) {
- CRealMediaWindowlessSite* pSiblingSite = (CRealMediaWindowlessSite*)(IRMASite*)m_pParentSite->m_pChildren.GetNext(pos);
- if (pSiblingSite != this) {
- INT32 zOrder;
- pSiblingSite->GetZOrder(zOrder);
+ POSITION pos = m_pParentSite->m_pChildren.GetHeadPosition();
+ while (pos) {
+ CRealMediaWindowlessSite* pSiblingSite = (CRealMediaWindowlessSite*)(IRMASite*)m_pParentSite->m_pChildren.GetNext(pos);
+ if (pSiblingSite != this) {
+ INT32 zOrder;
+ pSiblingSite->GetZOrder(zOrder);
- if (zOrder > m_lZOrder && pSiblingSite->IsSiteVisible()) {
- pSiblingSite->SubtractSite(m_pRegionWithoutChildren);
- }
- }
- }
- }
+ if (zOrder > m_lZOrder && pSiblingSite->IsSiteVisible()) {
+ pSiblingSite->SubtractSite(m_pRegionWithoutChildren);
+ }
+ }
+ }
+ }
- m_pRegion = RMACreateRegion();
- RMAUnionRegion(m_pRegion, m_pRegionWithoutChildren, m_pRegion);
+ m_pRegion = RMACreateRegion();
+ RMAUnionRegion(m_pRegion, m_pRegionWithoutChildren, m_pRegion);
- POSITION pos = m_pChildren.GetHeadPosition();
- while (pos) {
- CRealMediaWindowlessSite* pChildSite = (CRealMediaWindowlessSite*)(IRMASite*)m_pChildren.GetNext(pos);
- if (pChildSite->IsSiteVisible()) {
- pChildSite->SubtractSite(m_pRegion);
- }
- }
- } else {
- m_pRegionWithoutChildren = RMACreateRectRegion(0,0,0,0);
- m_pRegion = RMACreateRectRegion(0,0,0,0);
- }
+ POSITION pos = m_pChildren.GetHeadPosition();
+ while (pos) {
+ CRealMediaWindowlessSite* pChildSite = (CRealMediaWindowlessSite*)(IRMASite*)m_pChildren.GetNext(pos);
+ if (pChildSite->IsSiteVisible()) {
+ pChildSite->SubtractSite(m_pRegion);
+ }
+ }
+ } else {
+ m_pRegionWithoutChildren = RMACreateRectRegion(0, 0, 0, 0);
+ m_pRegion = RMACreateRectRegion(0, 0, 0, 0);
+ }
- if (pTempRegion && !RMAEqualRegion(m_pRegion, pTempRegion)) {
- ForceRedraw();
- }
+ if (pTempRegion && !RMAEqualRegion(m_pRegion, pTempRegion)) {
+ ForceRedraw();
+ }
- RMADestroyRegion(pTempRegion);
+ RMADestroyRegion(pTempRegion);
}
void CRealMediaWindowlessSite::SubtractSite(REGION* pRegion)
{
- PNxPoint topLeft;
- memset(&topLeft, 0, sizeof(PNxPoint));
- GetTopLeft(&topLeft);
+ PNxPoint topLeft;
+ memset(&topLeft, 0, sizeof(PNxPoint));
+ GetTopLeft(&topLeft);
- REGION* pTempRegion = RMACreateRectRegion(topLeft.x, topLeft.y, topLeft.x + m_size.cx, topLeft.y + m_size.cy);
+ REGION* pTempRegion = RMACreateRectRegion(topLeft.x, topLeft.y, topLeft.x + m_size.cx, topLeft.y + m_size.cy);
- RMASubtractRegion(pRegion, pTempRegion, pRegion);
- RMADestroyRegion(pTempRegion);
+ RMASubtractRegion(pRegion, pTempRegion, pRegion);
+ RMADestroyRegion(pTempRegion);
}
void CRealMediaWindowlessSite::UpdateZOrder(CRealMediaWindowlessSite* pUpdatedChildSite, INT32 lOldZOrder, INT32 lNewZOrder)
{
- POSITION pos = m_pChildren.GetHeadPosition();
- while (pos) {
- CRealMediaWindowlessSite* pSite = (CRealMediaWindowlessSite*)(IRMASite*)m_pChildren.GetNext(pos);
-
- INT32 lItsOldZOrder;
- pSite->GetZOrder(lItsOldZOrder);
-
- if (pSite != pUpdatedChildSite) {
- if (lOldZOrder < lNewZOrder) {
- if (lItsOldZOrder >= lOldZOrder && lItsOldZOrder < lNewZOrder) {
- pSite->SetInternalZOrder(lItsOldZOrder-1);
- }
- } else {
- if (lItsOldZOrder >= lNewZOrder && lItsOldZOrder < lOldZOrder) {
- pSite->SetInternalZOrder(lItsOldZOrder+1);
- }
- }
- } else {
- pSite->SetInternalZOrder(lNewZOrder);
- }
- }
+ POSITION pos = m_pChildren.GetHeadPosition();
+ while (pos) {
+ CRealMediaWindowlessSite* pSite = (CRealMediaWindowlessSite*)(IRMASite*)m_pChildren.GetNext(pos);
+
+ INT32 lItsOldZOrder;
+ pSite->GetZOrder(lItsOldZOrder);
+
+ if (pSite != pUpdatedChildSite) {
+ if (lOldZOrder < lNewZOrder) {
+ if (lItsOldZOrder >= lOldZOrder && lItsOldZOrder < lNewZOrder) {
+ pSite->SetInternalZOrder(lItsOldZOrder - 1);
+ }
+ } else {
+ if (lItsOldZOrder >= lNewZOrder && lItsOldZOrder < lOldZOrder) {
+ pSite->SetInternalZOrder(lItsOldZOrder + 1);
+ }
+ }
+ } else {
+ pSite->SetInternalZOrder(lNewZOrder);
+ }
+ }
}
void CRealMediaWindowlessSite::SetInternalZOrder(INT32 lZOrder)
{
- m_lZOrder = lZOrder;
+ m_lZOrder = lZOrder;
}
// IRMASiteWindowless
STDMETHODIMP CRealMediaWindowlessSite::EventOccurred(PNxEvent* /*IN*/ pEvent)
{
- return PNR_NOTIMPL; /* not necessary within our implementation */
+ return PNR_NOTIMPL; /* not necessary within our implementation */
}
STDMETHODIMP_(PNxWindow*) CRealMediaWindowlessSite::GetParentWindow()
{
- return NULL;
+ return NULL;
}
// IRMASite
STDMETHODIMP CRealMediaWindowlessSite::AttachUser(IRMASiteUser* /*IN*/ pUser)
{
- HRESULT hr = PNR_FAIL;
+ HRESULT hr = PNR_FAIL;
- if (m_pUser) {
- return PNR_UNEXPECTED;
- }
+ if (m_pUser) {
+ return PNR_UNEXPECTED;
+ }
- if (CComQIPtr<IRMASite, &IID_IRMASite> pOuterSite = GetOwner()) {
- hr = pUser->AttachSite(pOuterSite);
- }
+ if (CComQIPtr<IRMASite, &IID_IRMASite> pOuterSite = GetOwner()) {
+ hr = pUser->AttachSite(pOuterSite);
+ }
- if (PNR_OK == hr) {
- m_pUser = pUser;
- }
+ if (PNR_OK == hr) {
+ m_pUser = pUser;
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CRealMediaWindowlessSite::DetachUser()
{
- HRESULT hr = PNR_OK;
+ HRESULT hr = PNR_OK;
- if (!m_pUser) {
- return PNR_UNEXPECTED;
- }
+ if (!m_pUser) {
+ return PNR_UNEXPECTED;
+ }
- hr = m_pUser->DetachSite();
+ hr = m_pUser->DetachSite();
- if (PNR_OK == hr) {
- m_pUser = NULL;
- }
+ if (PNR_OK == hr) {
+ m_pUser = NULL;
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CRealMediaWindowlessSite::GetUser(REF(IRMASiteUser*) /*OUT*/ pUser)
{
- HRESULT hr = PNR_OK;
+ HRESULT hr = PNR_OK;
- if (!m_pUser) {
- return PNR_UNEXPECTED;
- }
+ if (!m_pUser) {
+ return PNR_UNEXPECTED;
+ }
- (pUser = m_pUser)->AddRef();
+ (pUser = m_pUser)->AddRef();
- return hr;
+ return hr;
}
STDMETHODIMP CRealMediaWindowlessSite::CreateChild(REF(IRMASite*) /*OUT*/ pChildSite)
{
- HRESULT hr = PNR_OK;
+ HRESULT hr = PNR_OK;
- CComPtr<IRMASite> pSite =
- (IRMASite*)DNew CRealMediaWindowlessSite(hr, m_pContext, this);
+ CComPtr<IRMASite> pSite =
+ (IRMASite*)DNew CRealMediaWindowlessSite(hr, m_pContext, this);
- if (FAILED(hr) || !pSite) {
- return E_FAIL;
- }
+ if (FAILED(hr) || !pSite) {
+ return E_FAIL;
+ }
- pChildSite = pSite.Detach();
+ pChildSite = pSite.Detach();
- m_pChildren.AddTail(pChildSite);
+ m_pChildren.AddTail(pChildSite);
- return hr;
+ return hr;
}
STDMETHODIMP CRealMediaWindowlessSite::DestroyChild(IRMASite* /*IN*/ pChildSite)
{
- if (POSITION pos = m_pChildren.Find(pChildSite)) {
- m_pChildren.RemoveAt(pos);
- return PNR_OK;
- }
+ if (POSITION pos = m_pChildren.Find(pChildSite)) {
+ m_pChildren.RemoveAt(pos);
+ return PNR_OK;
+ }
- return PNR_UNEXPECTED;
+ return PNR_UNEXPECTED;
}
STDMETHODIMP CRealMediaWindowlessSite::AttachWatcher(IRMASiteWatcher* /*IN*/ pWatcher)
{
- if (m_pWatcher) {
- return PNR_UNEXPECTED;
- }
+ if (m_pWatcher) {
+ return PNR_UNEXPECTED;
+ }
- if (m_pWatcher = pWatcher) {
- m_pWatcher->AttachSite((IRMASite*)this);
- }
+ if (m_pWatcher = pWatcher) {
+ m_pWatcher->AttachSite((IRMASite*)this);
+ }
- return PNR_OK;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::DetachWatcher()
{
- if (!m_pWatcher) {
- return PNR_UNEXPECTED;
- }
+ if (!m_pWatcher) {
+ return PNR_UNEXPECTED;
+ }
- m_pWatcher->DetachSite();
- m_pWatcher = NULL;
+ m_pWatcher->DetachSite();
+ m_pWatcher = NULL;
- return PNR_OK;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::SetPosition(PNxPoint position)
{
- HRESULT hr = PNR_OK;
+ HRESULT hr = PNR_OK;
- if (m_pWatcher) {
- hr = m_pWatcher->ChangingPosition(m_position, position);
- }
+ if (m_pWatcher) {
+ hr = m_pWatcher->ChangingPosition(m_position, position);
+ }
- if (PNR_OK == hr) {
- m_position = position;
+ if (PNR_OK == hr) {
+ m_position = position;
- POSITION pos = m_pPassiveWatchers.GetHeadPosition();
- while (pos) {
- m_pPassiveWatchers.GetNext(pos)->PositionChanged(&position);
- }
+ POSITION pos = m_pPassiveWatchers.GetHeadPosition();
+ while (pos) {
+ m_pPassiveWatchers.GetNext(pos)->PositionChanged(&position);
+ }
- RecomputeRegion();
- }
+ RecomputeRegion();
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CRealMediaWindowlessSite::GetPosition(REF(PNxPoint) position)
{
- position = m_position;
- return PNR_OK;
+ position = m_position;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::SetSize(PNxSize size)
{
- HRESULT hr = PNR_OK;
+ HRESULT hr = PNR_OK;
- if (m_pWatcher) {
- hr = m_pWatcher->ChangingSize(m_size, size);
- }
+ if (m_pWatcher) {
+ hr = m_pWatcher->ChangingSize(m_size, size);
+ }
- if (PNR_OK == hr && size.cx != 0 && size.cy != 0) {
- m_size = size;
+ if (PNR_OK == hr && size.cx != 0 && size.cy != 0) {
+ m_size = size;
- POSITION pos = m_pPassiveWatchers.GetHeadPosition();
- while (pos) {
- m_pPassiveWatchers.GetNext(pos)->SizeChanged(&size);
- }
+ POSITION pos = m_pPassiveWatchers.GetHeadPosition();
+ while (pos) {
+ m_pPassiveWatchers.GetNext(pos)->SizeChanged(&size);
+ }
- RecomputeRegion();
- }
+ RecomputeRegion();
+ }
- return hr;
+ return hr;
}
STDMETHODIMP CRealMediaWindowlessSite::GetSize(REF(PNxSize) size)
{
- size = m_size;
- return PNR_OK;
+ size = m_size;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::DamageRect(PNxRect rect)
{
- m_fDamaged = TRUE;
- return PNR_OK;
+ m_fDamaged = TRUE;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::DamageRegion(PNxRegion region)
{
- m_fDamaged = TRUE;
- return PNR_OK;
+ m_fDamaged = TRUE;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::ForceRedraw()
{
- // make sure we have a visible window and are not re-entering and we have damage
- if (!m_fInRedraw && m_fDamaged && m_fIsVisible) {
- m_fInRedraw = TRUE;
+ // make sure we have a visible window and are not re-entering and we have damage
+ if (!m_fInRedraw && m_fDamaged && m_fIsVisible) {
+ m_fInRedraw = TRUE;
- PNxEvent event = {RMA_SURFACE_UPDATE, NULL, (IRMAVideoSurface*)this, NULL, 0, 0};
- m_pUser->HandleEvent(&event);
+ PNxEvent event = {RMA_SURFACE_UPDATE, NULL, (IRMAVideoSurface*)this, NULL, 0, 0};
+ m_pUser->HandleEvent(&event);
- m_fInRedraw = FALSE;
- m_fDamaged = FALSE;
- }
+ m_fInRedraw = FALSE;
+ m_fDamaged = FALSE;
+ }
- return PNR_OK;
+ return PNR_OK;
}
// IRMASite2
STDMETHODIMP CRealMediaWindowlessSite::UpdateSiteWindow(PNxWindow* /*IN*/ pWindow)
{
- return PNR_OK;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::ShowSite(BOOL bShow)
{
- m_fIsVisible = !!bShow;
- RecomputeRegion();
- return PNR_OK;
+ m_fIsVisible = !!bShow;
+ RecomputeRegion();
+ return PNR_OK;
}
STDMETHODIMP_(BOOL) CRealMediaWindowlessSite::IsSiteVisible()
{
- BOOL fIsVisible = m_fIsVisible;
- if (m_pParentSite) {
- fIsVisible = fIsVisible && m_pParentSite->IsSiteVisible();
- }
- return fIsVisible;
+ BOOL fIsVisible = m_fIsVisible;
+ if (m_pParentSite) {
+ fIsVisible = fIsVisible && m_pParentSite->IsSiteVisible();
+ }
+ return fIsVisible;
}
STDMETHODIMP CRealMediaWindowlessSite::SetZOrder(INT32 lZOrder)
{
- if (!m_pParentSite) {
- return PNR_UNEXPECTED;
- }
+ if (!m_pParentSite) {
+ return PNR_UNEXPECTED;
+ }
- if (lZOrder == -1 || lZOrder >= (INT32)m_pParentSite->GetNumberOfChildSites()) {
- lZOrder = m_pParentSite->GetNumberOfChildSites() - 1;
- }
+ if (lZOrder == -1 || lZOrder >= (INT32)m_pParentSite->GetNumberOfChildSites()) {
+ lZOrder = m_pParentSite->GetNumberOfChildSites() - 1;
+ }
- if (m_lZOrder != lZOrder) {
- m_pParentSite->UpdateZOrder(this, m_lZOrder, lZOrder);
- }
+ if (m_lZOrder != lZOrder) {
+ m_pParentSite->UpdateZOrder(this, m_lZOrder, lZOrder);
+ }
- m_lZOrder = lZOrder;
+ m_lZOrder = lZOrder;
- return PNR_OK;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::GetZOrder(REF(INT32) lZOrder)
{
- if (!m_pParentSite) {
- return PNR_UNEXPECTED;
- }
- lZOrder = m_lZOrder;
- return PNR_OK;
+ if (!m_pParentSite) {
+ return PNR_UNEXPECTED;
+ }
+ lZOrder = m_lZOrder;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::MoveSiteToTop()
{
- if (!m_pParentSite) {
- return PNR_UNEXPECTED;
- }
- return PNR_NOTIMPL;
+ if (!m_pParentSite) {
+ return PNR_UNEXPECTED;
+ }
+ return PNR_NOTIMPL;
}
STDMETHODIMP CRealMediaWindowlessSite::GetVideoSurface(REF(IRMAVideoSurface*) pSurface)
{
- (pSurface = (IRMAVideoSurface*)this)->AddRef();
- return PNR_OK;
+ (pSurface = (IRMAVideoSurface*)this)->AddRef();
+ return PNR_OK;
}
STDMETHODIMP_(UINT32) CRealMediaWindowlessSite::GetNumberOfChildSites()
{
- return (UINT32)m_pChildren.GetCount();
+ return (UINT32)m_pChildren.GetCount();
}
STDMETHODIMP CRealMediaWindowlessSite::AddPassiveSiteWatcher(IRMAPassiveSiteWatcher* pWatcher)
{
- m_pPassiveWatchers.AddTail(pWatcher);
- return PNR_OK;
+ m_pPassiveWatchers.AddTail(pWatcher);
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::RemovePassiveSiteWatcher(IRMAPassiveSiteWatcher* pWatcher)
{
- if (POSITION pos = m_pPassiveWatchers.Find(pWatcher)) {
- m_pPassiveWatchers.RemoveAt(pos);
- return PNR_OK;
- }
+ if (POSITION pos = m_pPassiveWatchers.Find(pWatcher)) {
+ m_pPassiveWatchers.RemoveAt(pos);
+ return PNR_OK;
+ }
- return PNR_UNEXPECTED;
+ return PNR_UNEXPECTED;
}
STDMETHODIMP CRealMediaWindowlessSite::SetCursor(PNxCursor cursor, REF(PNxCursor) oldCursor)
{
- return PNR_NOTIMPL;
+ return PNR_NOTIMPL;
}
// private
void CRealMediaWindowlessSite::IntersectRect(PNxRect* pRect, PNxRect* pBox, PNxRect* pRetVal)
{
- pRetVal->left = max(pRect->left, pBox->left);
- pRetVal->top = max(pRect->top, pBox->top);
- pRetVal->right = min(pRect->right, pBox->right);
- pRetVal->bottom = min(pRect->bottom, pBox->bottom);
+ pRetVal->left = max(pRect->left, pBox->left);
+ pRetVal->top = max(pRect->top, pBox->top);
+ pRetVal->right = min(pRect->right, pBox->right);
+ pRetVal->bottom = min(pRect->bottom, pBox->bottom);
}
// protected
bool CRealMediaWindowlessSite::GetBltService(IRMAVideoSurface** ppBltService)
{
- bool fRet = false;
+ bool fRet = false;
- if (ppBltService) {
- if (m_pParentSite) {
- fRet = m_pParentSite->GetBltService(ppBltService);
- } else if (m_pBltService) {
- (*ppBltService = m_pBltService)->AddRef();
- fRet = true;
- }
- }
+ if (ppBltService) {
+ if (m_pParentSite) {
+ fRet = m_pParentSite->GetBltService(ppBltService);
+ } else if (m_pBltService) {
+ (*ppBltService = m_pBltService)->AddRef();
+ fRet = true;
+ }
+ }
- return fRet;
+ return fRet;
}
void CRealMediaWindowlessSite::SetBltService(IRMAVideoSurface* pBltService)
{
- m_pBltService = pBltService;
+ m_pBltService = pBltService;
}
// IRMAVideoSurface
-STDMETHODIMP CRealMediaWindowlessSite::Blt(UCHAR* /*IN*/ pImageData, RMABitmapInfoHeader* /*IN*/ pBitmapInfo, REF(PNxRect) /*IN*/ inDestRect, REF(PNxRect) /*IN*/ inSrcRect)
+STDMETHODIMP CRealMediaWindowlessSite::Blt(UCHAR* /*IN*/ pImageData, RMABitmapInfoHeader* /*IN*/ pBitmapInfo, REF(PNxRect) /*IN*/ inDestRect, REF(PNxRect) /*IN*/ inSrcRect)
{
- BeginOptimizedBlt(pBitmapInfo);
- return OptimizedBlt(pImageData, inDestRect, inSrcRect);
+ BeginOptimizedBlt(pBitmapInfo);
+ return OptimizedBlt(pImageData, inDestRect, inSrcRect);
}
STDMETHODIMP CRealMediaWindowlessSite::BeginOptimizedBlt(RMABitmapInfoHeader* /*IN*/ pBitmapInfo)
{
- if (memcmp(&m_bitmapInfo, pBitmapInfo, sizeof(RMABitmapInfoHeader))) {
- memcpy(&m_bitmapInfo, pBitmapInfo, sizeof(RMABitmapInfoHeader));
+ if (memcmp(&m_bitmapInfo, pBitmapInfo, sizeof(RMABitmapInfoHeader))) {
+ memcpy(&m_bitmapInfo, pBitmapInfo, sizeof(RMABitmapInfoHeader));
- // format of image has changed somehow.
- // do something here if this affects you.
- }
+ // format of image has changed somehow.
+ // do something here if this affects you.
+ }
- /*
- CComPtr<IRMAVideoSurface> pBltService;
- GetBltService(&pBltService);
- if (!pBltService)
- return PNR_UNEXPECTED;
+ /*
+ CComPtr<IRMAVideoSurface> pBltService;
+ GetBltService(&pBltService);
+ if (!pBltService)
+ return PNR_UNEXPECTED;
- RMA_COMPRESSION_TYPE ulType = (RMA_COMPRESSION_TYPE)-1;
- pBltService->GetPreferredFormat(ulType);
+ RMA_COMPRESSION_TYPE ulType = (RMA_COMPRESSION_TYPE)-1;
+ pBltService->GetPreferredFormat(ulType);
- if (pBitmapInfo->biCompression != ulType)
- return PNR_UNEXPECTED;
- */
- return PNR_OK;
+ if (pBitmapInfo->biCompression != ulType)
+ return PNR_UNEXPECTED;
+ */
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::OptimizedBlt(UCHAR* /*IN*/ pImageBits, REF(PNxRect) /*IN*/ rDestRect, REF(PNxRect) /*IN*/ rSrcRect)
{
- CComPtr<IRMAVideoSurface> pBltService;
- GetBltService(&pBltService);
+ CComPtr<IRMAVideoSurface> pBltService;
+ GetBltService(&pBltService);
- REGION* pRegion = GetRegion();
+ REGION* pRegion = GetRegion();
- if (!pBltService || !pRegion) {
- return PNR_UNEXPECTED;
- }
+ if (!pBltService || !pRegion) {
+ return PNR_UNEXPECTED;
+ }
- PNxPoint origin;
- memset(&origin, 0, sizeof(PNxPoint));
- GetTopLeft(&origin);
- PNxRect adjustedDestRect;
- adjustedDestRect.left = rDestRect.left + origin.x;
- adjustedDestRect.top = rDestRect.top + origin.y;
- adjustedDestRect.right = rDestRect.right + origin.x;
- adjustedDestRect.bottom = rDestRect.bottom + origin.y;
+ PNxPoint origin;
+ memset(&origin, 0, sizeof(PNxPoint));
+ GetTopLeft(&origin);
+ PNxRect adjustedDestRect;
+ adjustedDestRect.left = rDestRect.left + origin.x;
+ adjustedDestRect.top = rDestRect.top + origin.y;
+ adjustedDestRect.right = rDestRect.right + origin.x;
+ adjustedDestRect.bottom = rDestRect.bottom + origin.y;
- for (int i = 0; i < pRegion->numRects; i++) {
- PNxRect* pRect = pRegion->rects+i;
+ for (int i = 0; i < pRegion->numRects; i++) {
+ PNxRect* pRect = pRegion->rects + i;
- // intersect the dest rect with the rect from the
- // region to get the final dest rect.
- PNxRect finalDestRect;
- IntersectRect(&adjustedDestRect, pRect, &finalDestRect);
+ // intersect the dest rect with the rect from the
+ // region to get the final dest rect.
+ PNxRect finalDestRect;
+ IntersectRect(&adjustedDestRect, pRect, &finalDestRect);
- // now compute the src rect for this blt.
- double xStretch = (double) (rDestRect.right - rDestRect.left) / (double) (rSrcRect.right - rSrcRect.left);
- double yStretch = (double) (rDestRect.bottom - rDestRect.top) / (double) (rSrcRect.bottom - rSrcRect.top);
+ // now compute the src rect for this blt.
+ double xStretch = (double)(rDestRect.right - rDestRect.left) / (double)(rSrcRect.right - rSrcRect.left);
+ double yStretch = (double)(rDestRect.bottom - rDestRect.top) / (double)(rSrcRect.bottom - rSrcRect.top);
- PNxRect finalSrcRect;
- finalSrcRect.left = (INT32)((double)(finalDestRect.left-origin.x) / xStretch + 0.5);
- finalSrcRect.top = (INT32)((double)(finalDestRect.top-origin.y) / yStretch + 0.5);
- finalSrcRect.right = (INT32)((double)(finalDestRect.right-origin.x) / xStretch + 0.5);
- finalSrcRect.bottom = (INT32)((double)(finalDestRect.bottom-origin.y) / yStretch + 0.5);
+ PNxRect finalSrcRect;
+ finalSrcRect.left = (INT32)((double)(finalDestRect.left - origin.x) / xStretch + 0.5);
+ finalSrcRect.top = (INT32)((double)(finalDestRect.top - origin.y) / yStretch + 0.5);
+ finalSrcRect.right = (INT32)((double)(finalDestRect.right - origin.x) / xStretch + 0.5);
+ finalSrcRect.bottom = (INT32)((double)(finalDestRect.bottom - origin.y) / yStretch + 0.5);
- pBltService->Blt(pImageBits, &m_bitmapInfo, finalDestRect, finalSrcRect);
- }
+ pBltService->Blt(pImageBits, &m_bitmapInfo, finalDestRect, finalSrcRect);
+ }
- return PNR_OK;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::EndOptimizedBlt()
{
- memset(&m_bitmapInfo, 0, sizeof(m_bitmapInfo));
- return PNR_OK;
+ memset(&m_bitmapInfo, 0, sizeof(m_bitmapInfo));
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::GetOptimizedFormat(REF(RMA_COMPRESSION_TYPE) /*OUT*/ ulType)
{
- ulType = m_bitmapInfo.biCompression;
- return PNR_OK;
+ ulType = m_bitmapInfo.biCompression;
+ return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::GetPreferredFormat(REF(RMA_COMPRESSION_TYPE) /*OUT*/ ulType)
{
- CComPtr<IRMAVideoSurface> pBltService;
- GetBltService(&pBltService);
- if (!pBltService) {
- return PNR_UNEXPECTED;
- }
+ CComPtr<IRMAVideoSurface> pBltService;
+ GetBltService(&pBltService);
+ if (!pBltService) {
+ return PNR_UNEXPECTED;
+ }
- return pBltService->GetPreferredFormat(ulType);
+ return pBltService->GetPreferredFormat(ulType);
}
diff --git a/src/mpc-hc/RealMediaWindowlessSite.h b/src/mpc-hc/RealMediaWindowlessSite.h
index 46ffc5e66..15ac94b2c 100644
--- a/src/mpc-hc/RealMediaWindowlessSite.h
+++ b/src/mpc-hc/RealMediaWindowlessSite.h
@@ -45,175 +45,175 @@
namespace DSObjects
{
- struct REGION {
- REGION() : rects(0), pOSRegion(0) {}
- long size;
- long numRects;
- PNxRect* rects;
- PNxRect extents;
- void* pOSRegion;
- };
-
- void ExtractRects(REGION* pRegion);
- REGION* RMACreateRectRegion(int left, int top, int right, int bottom);
- void RMASubtractRegion(REGION* regM, REGION* regS, REGION* regD);
- void RMAUnionRegion(REGION* reg1, REGION* reg2, REGION* regD);
- void RMAIntersectRegion(REGION* reg1, REGION* reg2, REGION* regD);
- BOOL RMAEqualRegion(REGION* reg1, REGION* reg2);
- void RMADestroyRegion(REGION* reg);
- REGION* RMACreateRegion();
-
- class CRealMediaWindowlessSite;
-
- //
- // CRealMediaVideoSurface
- //
-
- class CRealMediaWindowlessSite;
-
- class CRealMediaVideoSurface
- : public CUnknown
- , public IRMAVideoSurface
- {
- void IntersectRect(PNxRect* pRect, PNxRect* pBox, PNxRect* pRetVal);
-
- protected:
- CComPtr<IUnknown> m_pContext;
- CRealMediaWindowlessSite* m_pSiteWindowless;
- RMABitmapInfoHeader m_bitmapInfo;
- RMABitmapInfoHeader m_lastBitmapInfo;
-
- public:
- CRealMediaVideoSurface(IUnknown* pContext, CRealMediaWindowlessSite* pSiteWindowless);
- virtual ~CRealMediaVideoSurface();
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // IRMAVideoSurface
-
- STDMETHODIMP Blt(UCHAR* /*IN*/ pImageData, RMABitmapInfoHeader* /*IN*/ pBitmapInfo, REF(PNxRect) /*IN*/ inDestRect, REF(PNxRect) /*IN*/ inSrcRect);
- STDMETHODIMP BeginOptimizedBlt(RMABitmapInfoHeader* /*IN*/ pBitmapInfo);
- STDMETHODIMP OptimizedBlt(UCHAR* /*IN*/ pImageBits, REF(PNxRect) /*IN*/ rDestRect, REF(PNxRect) /*IN*/ rSrcRect);
- STDMETHODIMP EndOptimizedBlt();
- STDMETHODIMP GetOptimizedFormat(REF(RMA_COMPRESSION_TYPE) /*OUT*/ ulType);
- STDMETHODIMP GetPreferredFormat(REF(RMA_COMPRESSION_TYPE) /*OUT*/ ulType);
- };
+ struct REGION {
+ REGION() : rects(0), pOSRegion(0) {}
+ long size;
+ long numRects;
+ PNxRect* rects;
+ PNxRect extents;
+ void* pOSRegion;
+ };
+
+ void ExtractRects(REGION* pRegion);
+ REGION* RMACreateRectRegion(int left, int top, int right, int bottom);
+ void RMASubtractRegion(REGION* regM, REGION* regS, REGION* regD);
+ void RMAUnionRegion(REGION* reg1, REGION* reg2, REGION* regD);
+ void RMAIntersectRegion(REGION* reg1, REGION* reg2, REGION* regD);
+ BOOL RMAEqualRegion(REGION* reg1, REGION* reg2);
+ void RMADestroyRegion(REGION* reg);
+ REGION* RMACreateRegion();
+
+ class CRealMediaWindowlessSite;
+
+ //
+ // CRealMediaVideoSurface
+ //
+
+ class CRealMediaWindowlessSite;
+
+ class CRealMediaVideoSurface
+ : public CUnknown
+ , public IRMAVideoSurface
+ {
+ void IntersectRect(PNxRect* pRect, PNxRect* pBox, PNxRect* pRetVal);
+
+ protected:
+ CComPtr<IUnknown> m_pContext;
+ CRealMediaWindowlessSite* m_pSiteWindowless;
+ RMABitmapInfoHeader m_bitmapInfo;
+ RMABitmapInfoHeader m_lastBitmapInfo;
+
+ public:
+ CRealMediaVideoSurface(IUnknown* pContext, CRealMediaWindowlessSite* pSiteWindowless);
+ virtual ~CRealMediaVideoSurface();
+
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ // IRMAVideoSurface
+
+ STDMETHODIMP Blt(UCHAR* /*IN*/ pImageData, RMABitmapInfoHeader* /*IN*/ pBitmapInfo, REF(PNxRect) /*IN*/ inDestRect, REF(PNxRect) /*IN*/ inSrcRect);
+ STDMETHODIMP BeginOptimizedBlt(RMABitmapInfoHeader* /*IN*/ pBitmapInfo);
+ STDMETHODIMP OptimizedBlt(UCHAR* /*IN*/ pImageBits, REF(PNxRect) /*IN*/ rDestRect, REF(PNxRect) /*IN*/ rSrcRect);
+ STDMETHODIMP EndOptimizedBlt();
+ STDMETHODIMP GetOptimizedFormat(REF(RMA_COMPRESSION_TYPE) /*OUT*/ ulType);
+ STDMETHODIMP GetPreferredFormat(REF(RMA_COMPRESSION_TYPE) /*OUT*/ ulType);
+ };
- //
- // CRealMediaWindowlessSite
- //
+ //
+ // CRealMediaWindowlessSite
+ //
- class CRealMediaWindowlessSite
- : public CUnknown
- , public IRMASite
- , public IRMASite2
- , public IRMASiteWindowless
- , public IRMAVideoSurface
- {
- CComQIPtr<IRMACommonClassFactory, &IID_IRMACommonClassFactory> m_pCCF;
- CComPtr<IUnknown> m_pContext;
- CComPtr<IRMAValues> m_pValues;
-
- CComPtr<IRMASiteUser> m_pUser;
-
- CRealMediaWindowlessSite* m_pParentSite;
- CInterfaceList<IRMASite, &IID_IRMASite> m_pChildren;
-
- CComPtr<IRMASiteWatcher> m_pWatcher;
- CInterfaceList<IRMAPassiveSiteWatcher, &IID_IRMAPassiveSiteWatcher> m_pPassiveWatchers;
-
- PNxSize m_size;
- PNxPoint m_position;
- bool m_fDamaged, m_fInRedraw, m_fIsVisible;
- INT32 m_lZOrder;
-
- //
-
- REGION* m_pRegion;
- REGION* m_pRegionWithoutChildren;
-
- void RecomputeRegion();
- void InternalRecomputeRegion();
- void ComputeRegion();
- void SubtractSite(REGION* pRegion);
-
- void UpdateZOrder(CRealMediaWindowlessSite* pUpdatedChildSite, INT32 lOldZOrder, INT32 lNewZOrder);
- void SetInternalZOrder(INT32 lZOrder);
-
- public:
- CRealMediaWindowlessSite(HRESULT& hr, IUnknown* pContext, CRealMediaWindowlessSite* pParentSite = NULL, IUnknown* pUnkOuter = NULL);
- virtual ~CRealMediaWindowlessSite();
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- void GetTopLeft(PNxPoint* pPoint);
- REGION* GetRegion();
+ class CRealMediaWindowlessSite
+ : public CUnknown
+ , public IRMASite
+ , public IRMASite2
+ , public IRMASiteWindowless
+ , public IRMAVideoSurface
+ {
+ CComQIPtr<IRMACommonClassFactory, &IID_IRMACommonClassFactory> m_pCCF;
+ CComPtr<IUnknown> m_pContext;
+ CComPtr<IRMAValues> m_pValues;
+
+ CComPtr<IRMASiteUser> m_pUser;
+
+ CRealMediaWindowlessSite* m_pParentSite;
+ CInterfaceList<IRMASite, &IID_IRMASite> m_pChildren;
+
+ CComPtr<IRMASiteWatcher> m_pWatcher;
+ CInterfaceList<IRMAPassiveSiteWatcher, &IID_IRMAPassiveSiteWatcher> m_pPassiveWatchers;
+
+ PNxSize m_size;
+ PNxPoint m_position;
+ bool m_fDamaged, m_fInRedraw, m_fIsVisible;
+ INT32 m_lZOrder;
+
+ //
+
+ REGION* m_pRegion;
+ REGION* m_pRegionWithoutChildren;
+
+ void RecomputeRegion();
+ void InternalRecomputeRegion();
+ void ComputeRegion();
+ void SubtractSite(REGION* pRegion);
+
+ void UpdateZOrder(CRealMediaWindowlessSite* pUpdatedChildSite, INT32 lOldZOrder, INT32 lNewZOrder);
+ void SetInternalZOrder(INT32 lZOrder);
+
+ public:
+ CRealMediaWindowlessSite(HRESULT& hr, IUnknown* pContext, CRealMediaWindowlessSite* pParentSite = NULL, IUnknown* pUnkOuter = NULL);
+ virtual ~CRealMediaWindowlessSite();
+
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ void GetTopLeft(PNxPoint* pPoint);
+ REGION* GetRegion();
- // IRMASiteWindowless
+ // IRMASiteWindowless
- STDMETHODIMP EventOccurred(PNxEvent* /*IN*/ pEvent);
- STDMETHODIMP_(PNxWindow*) GetParentWindow();
+ STDMETHODIMP EventOccurred(PNxEvent* /*IN*/ pEvent);
+ STDMETHODIMP_(PNxWindow*) GetParentWindow();
- // IRMASite
+ // IRMASite
- STDMETHODIMP AttachUser(IRMASiteUser* /*IN*/ pUser);
- STDMETHODIMP DetachUser();
- STDMETHODIMP GetUser(REF(IRMASiteUser*) /*OUT*/ pUser);
+ STDMETHODIMP AttachUser(IRMASiteUser* /*IN*/ pUser);
+ STDMETHODIMP DetachUser();
+ STDMETHODIMP GetUser(REF(IRMASiteUser*) /*OUT*/ pUser);
- STDMETHODIMP CreateChild(REF(IRMASite*) /*OUT*/ pChildSite);
- STDMETHODIMP DestroyChild(IRMASite* /*IN*/ pChildSite);
+ STDMETHODIMP CreateChild(REF(IRMASite*) /*OUT*/ pChildSite);
+ STDMETHODIMP DestroyChild(IRMASite* /*IN*/ pChildSite);
- STDMETHODIMP AttachWatcher(IRMASiteWatcher* /*IN*/ pWatcher);
- STDMETHODIMP DetachWatcher();
+ STDMETHODIMP AttachWatcher(IRMASiteWatcher* /*IN*/ pWatcher);
+ STDMETHODIMP DetachWatcher();
- STDMETHODIMP SetPosition(PNxPoint position);
- STDMETHODIMP GetPosition(REF(PNxPoint) position);
- STDMETHODIMP SetSize(PNxSize size);
- STDMETHODIMP GetSize(REF(PNxSize) size);
+ STDMETHODIMP SetPosition(PNxPoint position);
+ STDMETHODIMP GetPosition(REF(PNxPoint) position);
+ STDMETHODIMP SetSize(PNxSize size);
+ STDMETHODIMP GetSize(REF(PNxSize) size);
- STDMETHODIMP DamageRect(PNxRect rect);
- STDMETHODIMP DamageRegion(PNxRegion region);
- STDMETHODIMP ForceRedraw();
+ STDMETHODIMP DamageRect(PNxRect rect);
+ STDMETHODIMP DamageRegion(PNxRegion region);
+ STDMETHODIMP ForceRedraw();
- // IRMASite2
+ // IRMASite2
- STDMETHODIMP UpdateSiteWindow(PNxWindow* /*IN*/ pWindow);
- STDMETHODIMP ShowSite(BOOL bShow);
- STDMETHODIMP_(BOOL) IsSiteVisible();
- STDMETHODIMP SetZOrder(INT32 lZOrder);
- STDMETHODIMP GetZOrder(REF(INT32) lZOrder);
- STDMETHODIMP MoveSiteToTop();
- STDMETHODIMP GetVideoSurface(REF(IRMAVideoSurface*) pSurface);
- STDMETHODIMP_(UINT32) GetNumberOfChildSites();
+ STDMETHODIMP UpdateSiteWindow(PNxWindow* /*IN*/ pWindow);
+ STDMETHODIMP ShowSite(BOOL bShow);
+ STDMETHODIMP_(BOOL) IsSiteVisible();
+ STDMETHODIMP SetZOrder(INT32 lZOrder);
+ STDMETHODIMP GetZOrder(REF(INT32) lZOrder);
+ STDMETHODIMP MoveSiteToTop();
+ STDMETHODIMP GetVideoSurface(REF(IRMAVideoSurface*) pSurface);
+ STDMETHODIMP_(UINT32) GetNumberOfChildSites();
- STDMETHODIMP AddPassiveSiteWatcher(IRMAPassiveSiteWatcher* pWatcher);
- STDMETHODIMP RemovePassiveSiteWatcher(IRMAPassiveSiteWatcher* pWatcher);
+ STDMETHODIMP AddPassiveSiteWatcher(IRMAPassiveSiteWatcher* pWatcher);
+ STDMETHODIMP RemovePassiveSiteWatcher(IRMAPassiveSiteWatcher* pWatcher);
- STDMETHODIMP SetCursor(PNxCursor cursor, REF(PNxCursor) oldCursor);
+ STDMETHODIMP SetCursor(PNxCursor cursor, REF(PNxCursor) oldCursor);
- private:
- void IntersectRect(PNxRect* pRect, PNxRect* pBox, PNxRect* pRetVal);
+ private:
+ void IntersectRect(PNxRect* pRect, PNxRect* pBox, PNxRect* pRetVal);
- protected:
- RMABitmapInfoHeader m_bitmapInfo;
- RMABitmapInfoHeader m_lastBitmapInfo;
+ protected:
+ RMABitmapInfoHeader m_bitmapInfo;
+ RMABitmapInfoHeader m_lastBitmapInfo;
- CComPtr<IRMAVideoSurface> m_pBltService;
+ CComPtr<IRMAVideoSurface> m_pBltService;
- public:
- bool GetBltService(IRMAVideoSurface** ppBltService);
- void SetBltService(IRMAVideoSurface* ppBltService);
+ public:
+ bool GetBltService(IRMAVideoSurface** ppBltService);
+ void SetBltService(IRMAVideoSurface* ppBltService);
- // IRMAVideoSurface
+ // IRMAVideoSurface
- STDMETHODIMP Blt(UCHAR* /*IN*/ pImageData, RMABitmapInfoHeader* /*IN*/ pBitmapInfo, REF(PNxRect) /*IN*/ inDestRect, REF(PNxRect) /*IN*/ inSrcRect);
- STDMETHODIMP BeginOptimizedBlt(RMABitmapInfoHeader* /*IN*/ pBitmapInfo);
- STDMETHODIMP OptimizedBlt(UCHAR* /*IN*/ pImageBits, REF(PNxRect) /*IN*/ rDestRect, REF(PNxRect) /*IN*/ rSrcRect);
- STDMETHODIMP EndOptimizedBlt();
- STDMETHODIMP GetOptimizedFormat(REF(RMA_COMPRESSION_TYPE) /*OUT*/ ulType);
- STDMETHODIMP GetPreferredFormat(REF(RMA_COMPRESSION_TYPE) /*OUT*/ ulType);
- };
+ STDMETHODIMP Blt(UCHAR* /*IN*/ pImageData, RMABitmapInfoHeader* /*IN*/ pBitmapInfo, REF(PNxRect) /*IN*/ inDestRect, REF(PNxRect) /*IN*/ inSrcRect);
+ STDMETHODIMP BeginOptimizedBlt(RMABitmapInfoHeader* /*IN*/ pBitmapInfo);
+ STDMETHODIMP OptimizedBlt(UCHAR* /*IN*/ pImageBits, REF(PNxRect) /*IN*/ rDestRect, REF(PNxRect) /*IN*/ rSrcRect);
+ STDMETHODIMP EndOptimizedBlt();
+ STDMETHODIMP GetOptimizedFormat(REF(RMA_COMPRESSION_TYPE) /*OUT*/ ulType);
+ STDMETHODIMP GetPreferredFormat(REF(RMA_COMPRESSION_TYPE) /*OUT*/ ulType);
+ };
}
diff --git a/src/mpc-hc/RegFilterChooserDlg.cpp b/src/mpc-hc/RegFilterChooserDlg.cpp
index 87c2101ac..8311cfd38 100644
--- a/src/mpc-hc/RegFilterChooserDlg.cpp
+++ b/src/mpc-hc/RegFilterChooserDlg.cpp
@@ -33,45 +33,45 @@
//IMPLEMENT_DYNAMIC(CRegFilterChooserDlg, CResizableDialog)
CRegFilterChooserDlg::CRegFilterChooserDlg(CWnd* pParent /*=NULL*/)
- : CResizableDialog(CRegFilterChooserDlg::IDD, pParent)
+ : CResizableDialog(CRegFilterChooserDlg::IDD, pParent)
{
}
CRegFilterChooserDlg::~CRegFilterChooserDlg()
{
- POSITION pos = m_filters.GetHeadPosition();
- while (pos) {
- delete m_filters.GetNext(pos);
- }
+ POSITION pos = m_filters.GetHeadPosition();
+ while (pos) {
+ delete m_filters.GetNext(pos);
+ }
}
void CRegFilterChooserDlg::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_LIST2, m_list);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_LIST2, m_list);
}
void CRegFilterChooserDlg::AddToList(IMoniker* pMoniker)
{
- CComPtr<IPropertyBag> pPB;
- if (SUCCEEDED(pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB))) {
- CComVariant var;
- if (SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
- m_list.SetItemData(
- m_list.InsertItem(-1, CString(CStringW(var.bstrVal))),
- (DWORD_PTR)m_monikers.AddTail(pMoniker));
- }
- }
+ CComPtr<IPropertyBag> pPB;
+ if (SUCCEEDED(pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB))) {
+ CComVariant var;
+ if (SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
+ m_list.SetItemData(
+ m_list.InsertItem(-1, CString(CStringW(var.bstrVal))),
+ (DWORD_PTR)m_monikers.AddTail(pMoniker));
+ }
+ }
}
BEGIN_MESSAGE_MAP(CRegFilterChooserDlg, CResizableDialog)
- ON_LBN_DBLCLK(IDC_LIST1, OnLbnDblclkList1)
- ON_UPDATE_COMMAND_UI(IDOK, OnUpdateOK)
- ON_BN_CLICKED(IDOK, OnBnClickedOk)
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
- ON_NOTIFY(NM_DBLCLK, IDC_LIST2, OnNMDblclkList2)
+ ON_LBN_DBLCLK(IDC_LIST1, OnLbnDblclkList1)
+ ON_UPDATE_COMMAND_UI(IDOK, OnUpdateOK)
+ ON_BN_CLICKED(IDOK, OnBnClickedOk)
+ ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
+ ON_NOTIFY(NM_DBLCLK, IDC_LIST2, OnNMDblclkList2)
END_MESSAGE_MAP()
@@ -79,93 +79,93 @@ END_MESSAGE_MAP()
BOOL CRegFilterChooserDlg::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- BeginEnumSysDev(CLSID_LegacyAmFilterCategory, pMoniker) {
- AddToList(pMoniker);
- }
- EndEnumSysDev
+ BeginEnumSysDev(CLSID_LegacyAmFilterCategory, pMoniker) {
+ AddToList(pMoniker);
+ }
+ EndEnumSysDev
- BeginEnumSysDev(DMOCATEGORY_VIDEO_EFFECT, pMoniker) {
- AddToList(pMoniker);
- }
- EndEnumSysDev
+ BeginEnumSysDev(DMOCATEGORY_VIDEO_EFFECT, pMoniker) {
+ AddToList(pMoniker);
+ }
+ EndEnumSysDev
- BeginEnumSysDev(DMOCATEGORY_AUDIO_EFFECT, pMoniker) {
- AddToList(pMoniker);
- }
- EndEnumSysDev
+ BeginEnumSysDev(DMOCATEGORY_AUDIO_EFFECT, pMoniker) {
+ AddToList(pMoniker);
+ }
+ EndEnumSysDev
- AddAnchor(IDC_LIST2, TOP_LEFT, BOTTOM_RIGHT);
- AddAnchor(IDC_BUTTON1, BOTTOM_LEFT);
- AddAnchor(IDOK, BOTTOM_RIGHT);
- AddAnchor(IDCANCEL, BOTTOM_RIGHT);
+ AddAnchor(IDC_LIST2, TOP_LEFT, BOTTOM_RIGHT);
+ AddAnchor(IDC_BUTTON1, BOTTOM_LEFT);
+ AddAnchor(IDOK, BOTTOM_RIGHT);
+ AddAnchor(IDCANCEL, BOTTOM_RIGHT);
- SetMinTrackSize(CSize(300,100));
+ SetMinTrackSize(CSize(300, 100));
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CRegFilterChooserDlg::OnLbnDblclkList1()
{
- SendMessage(WM_COMMAND, IDOK);
+ SendMessage(WM_COMMAND, IDOK);
}
void CRegFilterChooserDlg::OnUpdateOK(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!!m_list.GetFirstSelectedItemPosition());
+ pCmdUI->Enable(!!m_list.GetFirstSelectedItemPosition());
}
void CRegFilterChooserDlg::OnBnClickedOk()
{
- CComPtr<IMoniker> pMoniker;
-
- POSITION pos = m_list.GetFirstSelectedItemPosition();
- if (pos) {
- pos = (POSITION)m_list.GetItemData(m_list.GetNextSelectedItem(pos));
- }
- if (pos) {
- pMoniker = m_monikers.GetAt(pos);
- }
- if (pMoniker) {
- CFGFilterRegistry fgf(pMoniker);
- FilterOverride* f = DNew FilterOverride;
- f->fDisabled = false;
- f->type = FilterOverride::REGISTERED;
- f->name = fgf.GetName();
- f->dispname = fgf.GetDisplayName();
- f->guids.AddTailList(&fgf.GetTypes());
- f->backup.AddTailList(&fgf.GetTypes());
- f->dwMerit = fgf.GetMeritForDirectShow();
- f->iLoadType = FilterOverride::MERIT;
- m_filters.AddTail(f);
- }
-
- __super::OnOK();
+ CComPtr<IMoniker> pMoniker;
+
+ POSITION pos = m_list.GetFirstSelectedItemPosition();
+ if (pos) {
+ pos = (POSITION)m_list.GetItemData(m_list.GetNextSelectedItem(pos));
+ }
+ if (pos) {
+ pMoniker = m_monikers.GetAt(pos);
+ }
+ if (pMoniker) {
+ CFGFilterRegistry fgf(pMoniker);
+ FilterOverride* f = DNew FilterOverride;
+ f->fDisabled = false;
+ f->type = FilterOverride::REGISTERED;
+ f->name = fgf.GetName();
+ f->dispname = fgf.GetDisplayName();
+ f->guids.AddTailList(&fgf.GetTypes());
+ f->backup.AddTailList(&fgf.GetTypes());
+ f->dwMerit = fgf.GetMeritForDirectShow();
+ f->iLoadType = FilterOverride::MERIT;
+ m_filters.AddTail(f);
+ }
+
+ __super::OnOK();
}
void CRegFilterChooserDlg::OnBnClickedButton1()
{
- CFileDialog dlg(TRUE, NULL, NULL,
- OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_NOCHANGEDIR,
- _T("DirectShow Filters (*.ax,*.dll)|*.ax;*.dll|"), this, 0);
-
- if (dlg.DoModal() == IDOK) {
- CFilterMapper2 fm2(false);
- fm2.Register(dlg.GetPathName());
- m_filters.AddTail(&fm2.m_filters);
- fm2.m_filters.RemoveAll();
-
- __super::OnOK();
- }
+ CFileDialog dlg(TRUE, NULL, NULL,
+ OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_NOCHANGEDIR,
+ _T("DirectShow Filters (*.ax,*.dll)|*.ax;*.dll|"), this, 0);
+
+ if (dlg.DoModal() == IDOK) {
+ CFilterMapper2 fm2(false);
+ fm2.Register(dlg.GetPathName());
+ m_filters.AddTail(&fm2.m_filters);
+ fm2.m_filters.RemoveAll();
+
+ __super::OnOK();
+ }
}
-void CRegFilterChooserDlg::OnNMDblclkList2(NMHDR *pNMHDR, LRESULT *pResult)
+void CRegFilterChooserDlg::OnNMDblclkList2(NMHDR* pNMHDR, LRESULT* pResult)
{
- if (m_list.GetFirstSelectedItemPosition()) {
- OnBnClickedOk();
- }
+ if (m_list.GetFirstSelectedItemPosition()) {
+ OnBnClickedOk();
+ }
- *pResult = 0;
+ *pResult = 0;
}
diff --git a/src/mpc-hc/RegFilterChooserDlg.h b/src/mpc-hc/RegFilterChooserDlg.h
index 0d9e96b0c..de5474873 100644
--- a/src/mpc-hc/RegFilterChooserDlg.h
+++ b/src/mpc-hc/RegFilterChooserDlg.h
@@ -31,31 +31,31 @@
class CRegFilterChooserDlg : public CResizableDialog
{
- // DECLARE_DYNAMIC(CRegFilterChooserDlg)
+ // DECLARE_DYNAMIC(CRegFilterChooserDlg)
- CInterfaceList<IMoniker> m_monikers;
- void AddToList(IMoniker* pMoniker);
+ CInterfaceList<IMoniker> m_monikers;
+ void AddToList(IMoniker* pMoniker);
public:
- CRegFilterChooserDlg(CWnd* pParent = NULL); // standard constructor
- virtual ~CRegFilterChooserDlg();
+ CRegFilterChooserDlg(CWnd* pParent = NULL); // standard constructor
+ virtual ~CRegFilterChooserDlg();
- CList<FilterOverride*> m_filters;
+ CList<FilterOverride*> m_filters;
- // Dialog Data
- enum { IDD = IDD_ADDREGFILTER };
- CListCtrl m_list;
+ // Dialog Data
+ enum { IDD = IDD_ADDREGFILTER };
+ CListCtrl m_list;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnLbnDblclkList1();
- afx_msg void OnUpdateOK(CCmdUI* pCmdUI);
- afx_msg void OnBnClickedOk();
- afx_msg void OnBnClickedButton1();
- afx_msg void OnNMDblclkList2(NMHDR *pNMHDR, LRESULT *pResult);
+ afx_msg void OnLbnDblclkList1();
+ afx_msg void OnUpdateOK(CCmdUI* pCmdUI);
+ afx_msg void OnBnClickedOk();
+ afx_msg void OnBnClickedButton1();
+ afx_msg void OnNMDblclkList2(NMHDR* pNMHDR, LRESULT* pResult);
};
diff --git a/src/mpc-hc/SaveDlg.cpp b/src/mpc-hc/SaveDlg.cpp
index 10a857e71..964a8baa0 100644
--- a/src/mpc-hc/SaveDlg.cpp
+++ b/src/mpc-hc/SaveDlg.cpp
@@ -31,9 +31,9 @@
IMPLEMENT_DYNAMIC(CSaveDlg, CCmdUIDialog)
CSaveDlg::CSaveDlg(CString in, CString out, CWnd* pParent /*=NULL*/)
- : CCmdUIDialog(CSaveDlg::IDD, pParent)
- , m_in(in), m_out(out)
- , m_nIDTimerEvent((UINT_PTR)-1)
+ : CCmdUIDialog(CSaveDlg::IDD, pParent)
+ , m_in(in), m_out(out)
+ , m_nIDTimerEvent((UINT_PTR) - 1)
{
}
@@ -43,18 +43,18 @@ CSaveDlg::~CSaveDlg()
void CSaveDlg::DoDataExchange(CDataExchange* pDX)
{
- CCmdUIDialog::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_ANIMATE1, m_anim);
- DDX_Control(pDX, IDC_PROGRESS1, m_progress);
- DDX_Control(pDX, IDC_REPORT, m_report);
- DDX_Control(pDX, IDC_FROMTO, m_fromto);
+ CCmdUIDialog::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_ANIMATE1, m_anim);
+ DDX_Control(pDX, IDC_PROGRESS1, m_progress);
+ DDX_Control(pDX, IDC_REPORT, m_report);
+ DDX_Control(pDX, IDC_FROMTO, m_fromto);
}
BEGIN_MESSAGE_MAP(CSaveDlg, CCmdUIDialog)
- ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel)
- ON_MESSAGE(WM_GRAPHNOTIFY, OnGraphNotify)
- ON_WM_TIMER()
+ ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel)
+ ON_MESSAGE(WM_GRAPHNOTIFY, OnGraphNotify)
+ ON_WM_TIMER()
END_MESSAGE_MAP()
@@ -62,206 +62,206 @@ END_MESSAGE_MAP()
BOOL CSaveDlg::OnInitDialog()
{
- CCmdUIDialog::OnInitDialog();
+ CCmdUIDialog::OnInitDialog();
- m_anim.Open(IDR_AVI_FILECOPY);
- m_anim.Play(0, (UINT)-1, (UINT)-1);
+ m_anim.Open(IDR_AVI_FILECOPY);
+ m_anim.Play(0, (UINT) - 1, (UINT) - 1);
- CString str, in = m_in, out = m_out;
- if (in.GetLength() > 60) {
- in = in.Left(17) + _T("..") + in.Right(43);
- }
- if (out.GetLength() > 60) {
- out = out.Left(17) + _T("..") + out.Right(43);
- }
- str.Format(_T("%s\r\n%s"), in, out);
- m_fromto.SetWindowText(str);
+ CString str, in = m_in, out = m_out;
+ if (in.GetLength() > 60) {
+ in = in.Left(17) + _T("..") + in.Right(43);
+ }
+ if (out.GetLength() > 60) {
+ out = out.Left(17) + _T("..") + out.Right(43);
+ }
+ str.Format(_T("%s\r\n%s"), in, out);
+ m_fromto.SetWindowText(str);
- m_progress.SetRange(0, 100);
+ m_progress.SetRange(0, 100);
- if (FAILED(pGB.CoCreateInstance(CLSID_FilterGraph)) || !(pMC = pGB) || !(pME = pGB) || !(pMS = pGB)
- || FAILED(pME->SetNotifyWindow((OAHWND)m_hWnd, WM_GRAPHNOTIFY, 0))) {
- m_report.SetWindowText(_T("Error"));
- return FALSE;
- }
+ if (FAILED(pGB.CoCreateInstance(CLSID_FilterGraph)) || !(pMC = pGB) || !(pME = pGB) || !(pMS = pGB)
+ || FAILED(pME->SetNotifyWindow((OAHWND)m_hWnd, WM_GRAPHNOTIFY, 0))) {
+ m_report.SetWindowText(_T("Error"));
+ return FALSE;
+ }
- HRESULT hr;
+ HRESULT hr;
- CStringW fnw = m_in;
- CComPtr<IFileSourceFilter> pReader;
+ CStringW fnw = m_in;
+ CComPtr<IFileSourceFilter> pReader;
#if INTERNAL_SOURCEFILTER_CDDA
- if (!pReader && m_in.Mid(m_in.ReverseFind('.')+1).MakeLower() == _T("cda")) {
- hr = S_OK;
- CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CCDDAReader(NULL, &hr);
- if (FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL))) {
- pReader.Release();
- }
- }
+ if (!pReader && m_in.Mid(m_in.ReverseFind('.') + 1).MakeLower() == _T("cda")) {
+ hr = S_OK;
+ CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CCDDAReader(NULL, &hr);
+ if (FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL))) {
+ pReader.Release();
+ }
+ }
#endif
#if INTERNAL_SOURCEFILTER_CDXA
- if (!pReader) {
- hr = S_OK;
- CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CCDXAReader(NULL, &hr);
- if (FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL))) {
- pReader.Release();
- }
- }
+ if (!pReader) {
+ hr = S_OK;
+ CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CCDXAReader(NULL, &hr);
+ if (FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL))) {
+ pReader.Release();
+ }
+ }
#endif
#if INTERNAL_SOURCEFILTER_VTS
- if (!pReader /*&& ext == _T("ifo")*/) {
- hr = S_OK;
- CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CVTSReader(NULL, &hr);
- if (FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL))) {
- pReader.Release();
- } else {
- CPath pout(m_out);
- pout.RenameExtension(_T(".ifo"));
- CopyFile(m_in, pout, FALSE);
- }
- }
+ if (!pReader /*&& ext == _T("ifo")*/) {
+ hr = S_OK;
+ CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CVTSReader(NULL, &hr);
+ if (FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL))) {
+ pReader.Release();
+ } else {
+ CPath pout(m_out);
+ pout.RenameExtension(_T(".ifo"));
+ CopyFile(m_in, pout, FALSE);
+ }
+ }
#endif
- if (!pReader) {
- hr = S_OK;
- CComPtr<IUnknown> pUnk;
- pUnk.CoCreateInstance(CLSID_AsyncReader);
- if (FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL))) {
- pReader.Release();
- }
- }
-
- if (!pReader) {
- hr = S_OK;
- CComPtr<IUnknown> pUnk;
- pUnk.CoCreateInstance(CLSID_URLReader);
- if (CComQIPtr<IBaseFilter> pSrc = pUnk) { // url reader has to be in the graph to load the file
- pGB->AddFilter(pSrc, fnw);
- if (FAILED(hr) || !(pReader = pUnk) || FAILED(hr = pReader->Load(fnw, NULL))) {
- pReader.Release();
- pGB->RemoveFilter(pSrc);
- }
- }
- }
-
- CComQIPtr<IBaseFilter> pSrc = pReader;
- if (FAILED(pGB->AddFilter(pSrc, fnw))) {
- m_report.SetWindowText(_T("Sorry, can't save this file, press cancel"));
- return FALSE;
- }
-
- CComQIPtr<IBaseFilter> pMid = DNew CStreamDriveThruFilter(NULL, &hr);
- if (FAILED(pGB->AddFilter(pMid, L"StreamDriveThru"))) {
- m_report.SetWindowText(_T("Error"));
- return FALSE;
- }
-
- CComQIPtr<IBaseFilter> pDst;
- pDst.CoCreateInstance(CLSID_FileWriter);
- CComQIPtr<IFileSinkFilter2> pFSF = pDst;
- pFSF->SetFileName(CStringW(m_out), NULL);
- pFSF->SetMode(AM_FILE_OVERWRITE);
- if (FAILED(pGB->AddFilter(pDst, L"File Writer"))) {
- m_report.SetWindowText(_T("Error"));
- return FALSE;
- }
-
- hr = pGB->Connect(
- GetFirstPin((pSrc), PINDIR_OUTPUT),
- GetFirstPin((pMid), PINDIR_INPUT));
-
- if (FAILED(hr)) {
- m_report.SetWindowText(_T("Error Connect pSrc / pMid"));
- return FALSE;
- }
-
- hr = pGB->Connect(
- GetFirstPin((pMid), PINDIR_OUTPUT),
- GetFirstPin((pDst), PINDIR_INPUT));
- if (FAILED(hr)) {
- m_report.SetWindowText(_T("Error Connect pMid / pDst"));
- return FALSE;
- }
-
- pMS = pMid;
-
- pMC->Run();
-
- m_nIDTimerEvent = SetTimer(1, 500, NULL);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ if (!pReader) {
+ hr = S_OK;
+ CComPtr<IUnknown> pUnk;
+ pUnk.CoCreateInstance(CLSID_AsyncReader);
+ if (FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL))) {
+ pReader.Release();
+ }
+ }
+
+ if (!pReader) {
+ hr = S_OK;
+ CComPtr<IUnknown> pUnk;
+ pUnk.CoCreateInstance(CLSID_URLReader);
+ if (CComQIPtr<IBaseFilter> pSrc = pUnk) { // url reader has to be in the graph to load the file
+ pGB->AddFilter(pSrc, fnw);
+ if (FAILED(hr) || !(pReader = pUnk) || FAILED(hr = pReader->Load(fnw, NULL))) {
+ pReader.Release();
+ pGB->RemoveFilter(pSrc);
+ }
+ }
+ }
+
+ CComQIPtr<IBaseFilter> pSrc = pReader;
+ if (FAILED(pGB->AddFilter(pSrc, fnw))) {
+ m_report.SetWindowText(_T("Sorry, can't save this file, press cancel"));
+ return FALSE;
+ }
+
+ CComQIPtr<IBaseFilter> pMid = DNew CStreamDriveThruFilter(NULL, &hr);
+ if (FAILED(pGB->AddFilter(pMid, L"StreamDriveThru"))) {
+ m_report.SetWindowText(_T("Error"));
+ return FALSE;
+ }
+
+ CComQIPtr<IBaseFilter> pDst;
+ pDst.CoCreateInstance(CLSID_FileWriter);
+ CComQIPtr<IFileSinkFilter2> pFSF = pDst;
+ pFSF->SetFileName(CStringW(m_out), NULL);
+ pFSF->SetMode(AM_FILE_OVERWRITE);
+ if (FAILED(pGB->AddFilter(pDst, L"File Writer"))) {
+ m_report.SetWindowText(_T("Error"));
+ return FALSE;
+ }
+
+ hr = pGB->Connect(
+ GetFirstPin((pSrc), PINDIR_OUTPUT),
+ GetFirstPin((pMid), PINDIR_INPUT));
+
+ if (FAILED(hr)) {
+ m_report.SetWindowText(_T("Error Connect pSrc / pMid"));
+ return FALSE;
+ }
+
+ hr = pGB->Connect(
+ GetFirstPin((pMid), PINDIR_OUTPUT),
+ GetFirstPin((pDst), PINDIR_INPUT));
+ if (FAILED(hr)) {
+ m_report.SetWindowText(_T("Error Connect pMid / pDst"));
+ return FALSE;
+ }
+
+ pMS = pMid;
+
+ pMC->Run();
+
+ m_nIDTimerEvent = SetTimer(1, 500, NULL);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CSaveDlg::OnBnClickedCancel()
{
- if (pMC) {
- pMC->Stop();
- }
+ if (pMC) {
+ pMC->Stop();
+ }
- OnCancel();
+ OnCancel();
}
LRESULT CSaveDlg::OnGraphNotify(WPARAM wParam, LPARAM lParam)
{
- LONG evCode, evParam1, evParam2;
- while (pME && SUCCEEDED(pME->GetEvent(&evCode, (LONG_PTR*)&evParam1, (LONG_PTR*)&evParam2, 0))) {
- HRESULT hr = pME->FreeEventParams(evCode, evParam1, evParam2);
- UNREFERENCED_PARAMETER(hr);
-
- if (EC_COMPLETE == evCode) {
- EndDialog(IDOK);
- } else if (EC_ERRORABORT == evCode) {
- TRACE(_T("CSaveDlg::OnGraphNotify / EC_ERRORABORT, hr = %08x\n"), (HRESULT)evParam1);
- m_report.SetWindowText(_T("Copying unexpectedly terminated!"));
- }
- }
-
- return 0;
+ LONG evCode, evParam1, evParam2;
+ while (pME && SUCCEEDED(pME->GetEvent(&evCode, (LONG_PTR*)&evParam1, (LONG_PTR*)&evParam2, 0))) {
+ HRESULT hr = pME->FreeEventParams(evCode, evParam1, evParam2);
+ UNREFERENCED_PARAMETER(hr);
+
+ if (EC_COMPLETE == evCode) {
+ EndDialog(IDOK);
+ } else if (EC_ERRORABORT == evCode) {
+ TRACE(_T("CSaveDlg::OnGraphNotify / EC_ERRORABORT, hr = %08x\n"), (HRESULT)evParam1);
+ m_report.SetWindowText(_T("Copying unexpectedly terminated!"));
+ }
+ }
+
+ return 0;
}
static unsigned int AdaptUnit(double& val, size_t unitsNb)
{
- unsigned int unit = 0;
+ unsigned int unit = 0;
- while (val > 1024 && unit < unitsNb) {
- val /= 1024;
- unit++;
- }
+ while (val > 1024 && unit < unitsNb) {
+ val /= 1024;
+ unit++;
+ }
- return unit;
+ return unit;
}
void CSaveDlg::OnTimer(UINT_PTR nIDEvent)
{
- static UINT sizeUnits[] = { IDS_SIZE_UNIT_K, IDS_SIZE_UNIT_M, IDS_SIZE_UNIT_G };
- static UINT speedUnits[] = { IDS_SPEED_UNIT_K, IDS_SPEED_UNIT_M, IDS_SPEED_UNIT_G };
-
- if (nIDEvent == m_nIDTimerEvent && pGB && pMS) {
- CString str;
- REFERENCE_TIME pos = 0, dur = 0;
- pMS->GetCurrentPosition(&pos);
- pMS->GetDuration(&dur);
- REFERENCE_TIME time = 0;
- CComQIPtr<IMediaSeeking>(pGB)->GetCurrentPosition(&time);
- REFERENCE_TIME speed = time > 0 ? pos*10000000/time : 0;
-
- double dPos = pos / 1024.;
- unsigned int unitPos = AdaptUnit(dPos, _countof(sizeUnits));
- double dDur = dur / 1024.;
- unsigned int unitDur = AdaptUnit(dDur, _countof(sizeUnits));
- double dSpeed = speed / 1024.;
- unsigned int unitSpeed = AdaptUnit(dSpeed, _countof(speedUnits));
-
- str.Format(_T("%.2lf %s / %.2lf %s, %.2lf %s, %I64d s"),
- dPos, ResStr(sizeUnits[unitPos]), dDur, ResStr(sizeUnits[unitDur]),
- dSpeed, ResStr(speedUnits[unitSpeed]), speed > 0 ? (dur-pos) / speed : 0);
- m_report.SetWindowText(str);
-
- m_progress.SetPos(dur > 0 ? (int)(100*pos/dur) : 0);
- }
-
- CCmdUIDialog::OnTimer(nIDEvent);
+ static UINT sizeUnits[] = { IDS_SIZE_UNIT_K, IDS_SIZE_UNIT_M, IDS_SIZE_UNIT_G };
+ static UINT speedUnits[] = { IDS_SPEED_UNIT_K, IDS_SPEED_UNIT_M, IDS_SPEED_UNIT_G };
+
+ if (nIDEvent == m_nIDTimerEvent && pGB && pMS) {
+ CString str;
+ REFERENCE_TIME pos = 0, dur = 0;
+ pMS->GetCurrentPosition(&pos);
+ pMS->GetDuration(&dur);
+ REFERENCE_TIME time = 0;
+ CComQIPtr<IMediaSeeking>(pGB)->GetCurrentPosition(&time);
+ REFERENCE_TIME speed = time > 0 ? pos * 10000000 / time : 0;
+
+ double dPos = pos / 1024.;
+ unsigned int unitPos = AdaptUnit(dPos, _countof(sizeUnits));
+ double dDur = dur / 1024.;
+ unsigned int unitDur = AdaptUnit(dDur, _countof(sizeUnits));
+ double dSpeed = speed / 1024.;
+ unsigned int unitSpeed = AdaptUnit(dSpeed, _countof(speedUnits));
+
+ str.Format(_T("%.2lf %s / %.2lf %s, %.2lf %s, %I64d s"),
+ dPos, ResStr(sizeUnits[unitPos]), dDur, ResStr(sizeUnits[unitDur]),
+ dSpeed, ResStr(speedUnits[unitSpeed]), speed > 0 ? (dur - pos) / speed : 0);
+ m_report.SetWindowText(str);
+
+ m_progress.SetPos(dur > 0 ? (int)(100 * pos / dur) : 0);
+ }
+
+ CCmdUIDialog::OnTimer(nIDEvent);
}
diff --git a/src/mpc-hc/SaveDlg.h b/src/mpc-hc/SaveDlg.h
index 2d41bc960..2679b41eb 100644
--- a/src/mpc-hc/SaveDlg.h
+++ b/src/mpc-hc/SaveDlg.h
@@ -32,34 +32,34 @@
class CSaveDlg : public CCmdUIDialog
{
- DECLARE_DYNAMIC(CSaveDlg)
+ DECLARE_DYNAMIC(CSaveDlg)
private:
- CString m_in, m_out;
- CComPtr<IGraphBuilder> pGB;
- CComQIPtr<IMediaControl> pMC;
- CComQIPtr<IMediaEventEx> pME;
- CComQIPtr<IMediaSeeking> pMS;
- UINT_PTR m_nIDTimerEvent;
+ CString m_in, m_out;
+ CComPtr<IGraphBuilder> pGB;
+ CComQIPtr<IMediaControl> pMC;
+ CComQIPtr<IMediaEventEx> pME;
+ CComQIPtr<IMediaSeeking> pMS;
+ UINT_PTR m_nIDTimerEvent;
public:
- CSaveDlg(CString in, CString out, CWnd* pParent = NULL); // standard constructor
- virtual ~CSaveDlg();
+ CSaveDlg(CString in, CString out, CWnd* pParent = NULL); // standard constructor
+ virtual ~CSaveDlg();
- // Dialog Data
- enum { IDD = IDD_SAVE_DLG };
- CAnimateCtrl m_anim;
- CProgressCtrl m_progress;
- CStatic m_report;
- CStatic m_fromto;
+ // Dialog Data
+ enum { IDD = IDD_SAVE_DLG };
+ CAnimateCtrl m_anim;
+ CProgressCtrl m_progress;
+ CStatic m_report;
+ CStatic m_fromto;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnBnClickedCancel();
- afx_msg void OnTimer(UINT_PTR nIDEvent);
- afx_msg LRESULT OnGraphNotify(WPARAM wParam, LPARAM lParam);
+ afx_msg void OnBnClickedCancel();
+ afx_msg void OnTimer(UINT_PTR nIDEvent);
+ afx_msg LRESULT OnGraphNotify(WPARAM wParam, LPARAM lParam);
};
diff --git a/src/mpc-hc/SaveTextFileDialog.cpp b/src/mpc-hc/SaveTextFileDialog.cpp
index 9382dd5fd..4236f92cf 100644
--- a/src/mpc-hc/SaveTextFileDialog.cpp
+++ b/src/mpc-hc/SaveTextFileDialog.cpp
@@ -30,15 +30,15 @@
IMPLEMENT_DYNAMIC(CSaveTextFileDialog, CFileDialog)
CSaveTextFileDialog::CSaveTextFileDialog(
- CTextFile::enc e,
- LPCTSTR lpszDefExt, LPCTSTR lpszFileName,
- LPCTSTR lpszFilter, CWnd* pParentWnd) :
- CFileDialog(FALSE, lpszDefExt, lpszFileName,
- OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST|OFN_NOCHANGEDIR,
- lpszFilter, pParentWnd, 0, FALSE),
- m_e(e)
+ CTextFile::enc e,
+ LPCTSTR lpszDefExt, LPCTSTR lpszFileName,
+ LPCTSTR lpszFilter, CWnd* pParentWnd) :
+ CFileDialog(FALSE, lpszDefExt, lpszFileName,
+ OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR,
+ lpszFilter, pParentWnd, 0, FALSE),
+ m_e(e)
{
- SetTemplate(0, IDD_SAVETEXTFILEDIALOGTEMPL);
+ SetTemplate(0, IDD_SAVETEXTFILEDIALOGTEMPL);
}
CSaveTextFileDialog::~CSaveTextFileDialog()
@@ -47,37 +47,37 @@ CSaveTextFileDialog::~CSaveTextFileDialog()
void CSaveTextFileDialog::DoDataExchange(CDataExchange* pDX)
{
- DDX_Control(pDX, IDC_COMBO1, m_encoding);
- __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_COMBO1, m_encoding);
+ __super::DoDataExchange(pDX);
}
BOOL CSaveTextFileDialog::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- m_encoding.SetItemData(m_encoding.AddString(_T("ANSI")), CTextFile::ASCII);
- m_encoding.SetItemData(m_encoding.AddString(_T("Unicode 16-LE")), CTextFile::LE16);
- m_encoding.SetItemData(m_encoding.AddString(_T("Unicode 16-BE")), CTextFile::BE16);
- m_encoding.SetItemData(m_encoding.AddString(_T("UTF-8")), CTextFile::UTF8);
+ m_encoding.SetItemData(m_encoding.AddString(_T("ANSI")), CTextFile::ASCII);
+ m_encoding.SetItemData(m_encoding.AddString(_T("Unicode 16-LE")), CTextFile::LE16);
+ m_encoding.SetItemData(m_encoding.AddString(_T("Unicode 16-BE")), CTextFile::BE16);
+ m_encoding.SetItemData(m_encoding.AddString(_T("UTF-8")), CTextFile::UTF8);
- switch (m_e) {
- default:
- case CTextFile::ASCII:
- m_encoding.SetCurSel(0);
- break;
- case CTextFile::LE16:
- m_encoding.SetCurSel(1);
- break;
- case CTextFile::BE16:
- m_encoding.SetCurSel(2);
- break;
- case CTextFile::UTF8:
- m_encoding.SetCurSel(3);
- break;
- }
+ switch (m_e) {
+ default:
+ case CTextFile::ASCII:
+ m_encoding.SetCurSel(0);
+ break;
+ case CTextFile::LE16:
+ m_encoding.SetCurSel(1);
+ break;
+ case CTextFile::BE16:
+ m_encoding.SetCurSel(2);
+ break;
+ case CTextFile::UTF8:
+ m_encoding.SetCurSel(3);
+ break;
+ }
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BEGIN_MESSAGE_MAP(CSaveTextFileDialog, CFileDialog)
@@ -87,6 +87,6 @@ END_MESSAGE_MAP()
BOOL CSaveTextFileDialog::OnFileNameOK()
{
- m_e = (CTextFile::enc)m_encoding.GetItemData(m_encoding.GetCurSel());
- return __super::OnFileNameOK();
+ m_e = (CTextFile::enc)m_encoding.GetItemData(m_encoding.GetCurSel());
+ return __super::OnFileNameOK();
}
diff --git a/src/mpc-hc/SaveTextFileDialog.h b/src/mpc-hc/SaveTextFileDialog.h
index 47797978c..ddc99db0f 100644
--- a/src/mpc-hc/SaveTextFileDialog.h
+++ b/src/mpc-hc/SaveTextFileDialog.h
@@ -30,30 +30,30 @@
class CSaveTextFileDialog : public CFileDialog
{
- DECLARE_DYNAMIC(CSaveTextFileDialog)
+ DECLARE_DYNAMIC(CSaveTextFileDialog)
private:
- CTextFile::enc m_e;
+ CTextFile::enc m_e;
public:
- CSaveTextFileDialog(
- CTextFile::enc e,
- LPCTSTR lpszDefExt = NULL, LPCTSTR lpszFileName = NULL,
- LPCTSTR lpszFilter = NULL, CWnd* pParentWnd = NULL);
- virtual ~CSaveTextFileDialog();
+ CSaveTextFileDialog(
+ CTextFile::enc e,
+ LPCTSTR lpszDefExt = NULL, LPCTSTR lpszFileName = NULL,
+ LPCTSTR lpszFilter = NULL, CWnd* pParentWnd = NULL);
+ virtual ~CSaveTextFileDialog();
- CComboBox m_encoding;
+ CComboBox m_encoding;
- CTextFile::enc GetEncoding() {
- return m_e;
- }
+ CTextFile::enc GetEncoding() {
+ return m_e;
+ }
protected:
- DECLARE_MESSAGE_MAP()
- virtual void DoDataExchange(CDataExchange* pDX);
- virtual BOOL OnInitDialog();
- virtual BOOL OnFileNameOK();
+ DECLARE_MESSAGE_MAP()
+ virtual void DoDataExchange(CDataExchange* pDX);
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnFileNameOK();
public:
- afx_msg void OnEncodingChange();
+ afx_msg void OnEncodingChange();
};
diff --git a/src/mpc-hc/SaveThumbnailsDialog.cpp b/src/mpc-hc/SaveThumbnailsDialog.cpp
index 8447b6790..9be7c18d8 100644
--- a/src/mpc-hc/SaveThumbnailsDialog.cpp
+++ b/src/mpc-hc/SaveThumbnailsDialog.cpp
@@ -30,15 +30,15 @@
IMPLEMENT_DYNAMIC(CSaveThumbnailsDialog, CFileDialog)
CSaveThumbnailsDialog::CSaveThumbnailsDialog(
- int rows, int cols, int width,
- LPCTSTR lpszDefExt, LPCTSTR lpszFileName,
- LPCTSTR lpszFilter, CWnd* pParentWnd) :
- CFileDialog(FALSE, lpszDefExt, lpszFileName,
- OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST|OFN_NOCHANGEDIR,
- lpszFilter, pParentWnd, 0, FALSE),
- m_rows(rows), m_cols(cols), m_width(width)
+ int rows, int cols, int width,
+ LPCTSTR lpszDefExt, LPCTSTR lpszFileName,
+ LPCTSTR lpszFilter, CWnd* pParentWnd) :
+ CFileDialog(FALSE, lpszDefExt, lpszFileName,
+ OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR,
+ lpszFilter, pParentWnd, 0, FALSE),
+ m_rows(rows), m_cols(cols), m_width(width)
{
- SetTemplate(0, IDD_SAVETHUMBSDIALOGTEMPL);
+ SetTemplate(0, IDD_SAVETHUMBSDIALOGTEMPL);
}
CSaveThumbnailsDialog::~CSaveThumbnailsDialog()
@@ -47,25 +47,25 @@ CSaveThumbnailsDialog::~CSaveThumbnailsDialog()
void CSaveThumbnailsDialog::DoDataExchange(CDataExchange* pDX)
{
- DDX_Control(pDX, IDC_SPIN1, m_rowsctrl);
- DDX_Control(pDX, IDC_SPIN2, m_colsctrl);
- DDX_Control(pDX, IDC_SPIN3, m_widthctrl);
- __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_SPIN1, m_rowsctrl);
+ DDX_Control(pDX, IDC_SPIN2, m_colsctrl);
+ DDX_Control(pDX, IDC_SPIN3, m_widthctrl);
+ __super::DoDataExchange(pDX);
}
BOOL CSaveThumbnailsDialog::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- m_rowsctrl.SetRange(1, 20);
- m_colsctrl.SetRange(1, 10);
- m_widthctrl.SetRange(256, 2560);
- m_rowsctrl.SetPos(m_rows);
- m_colsctrl.SetPos(m_cols);
- m_widthctrl.SetPos(m_width);
+ m_rowsctrl.SetRange(1, 20);
+ m_colsctrl.SetRange(1, 10);
+ m_widthctrl.SetRange(256, 2560);
+ m_rowsctrl.SetPos(m_rows);
+ m_colsctrl.SetPos(m_cols);
+ m_widthctrl.SetPos(m_width);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
BEGIN_MESSAGE_MAP(CSaveThumbnailsDialog, CFileDialog)
@@ -75,9 +75,9 @@ END_MESSAGE_MAP()
BOOL CSaveThumbnailsDialog::OnFileNameOK()
{
- m_rows = m_rowsctrl.GetPos();
- m_cols = m_colsctrl.GetPos();
- m_width = m_widthctrl.GetPos();
+ m_rows = m_rowsctrl.GetPos();
+ m_cols = m_colsctrl.GetPos();
+ m_width = m_widthctrl.GetPos();
- return __super::OnFileNameOK();
+ return __super::OnFileNameOK();
}
diff --git a/src/mpc-hc/SaveThumbnailsDialog.h b/src/mpc-hc/SaveThumbnailsDialog.h
index f58464bb1..f2d2685e5 100644
--- a/src/mpc-hc/SaveThumbnailsDialog.h
+++ b/src/mpc-hc/SaveThumbnailsDialog.h
@@ -28,24 +28,24 @@
class CSaveThumbnailsDialog : public CFileDialog
{
- DECLARE_DYNAMIC(CSaveThumbnailsDialog)
+ DECLARE_DYNAMIC(CSaveThumbnailsDialog)
public:
- CSaveThumbnailsDialog(
- int rows, int cols, int width,
- LPCTSTR lpszDefExt = NULL, LPCTSTR lpszFileName = NULL,
- LPCTSTR lpszFilter = NULL, CWnd* pParentWnd = NULL);
- virtual ~CSaveThumbnailsDialog();
+ CSaveThumbnailsDialog(
+ int rows, int cols, int width,
+ LPCTSTR lpszDefExt = NULL, LPCTSTR lpszFileName = NULL,
+ LPCTSTR lpszFilter = NULL, CWnd* pParentWnd = NULL);
+ virtual ~CSaveThumbnailsDialog();
protected:
- DECLARE_MESSAGE_MAP()
- virtual void DoDataExchange(CDataExchange* pDX);
- virtual BOOL OnInitDialog();
- virtual BOOL OnFileNameOK();
+ DECLARE_MESSAGE_MAP()
+ virtual void DoDataExchange(CDataExchange* pDX);
+ virtual BOOL OnInitDialog();
+ virtual BOOL OnFileNameOK();
public:
- int m_rows, m_cols, m_width;
- CSpinButtonCtrl m_rowsctrl;
- CSpinButtonCtrl m_colsctrl;
- CSpinButtonCtrl m_widthctrl;
+ int m_rows, m_cols, m_width;
+ CSpinButtonCtrl m_rowsctrl;
+ CSpinButtonCtrl m_colsctrl;
+ CSpinButtonCtrl m_widthctrl;
};
diff --git a/src/mpc-hc/SelectMediaType.cpp b/src/mpc-hc/SelectMediaType.cpp
index 32f0b9467..b4a77cb16 100644
--- a/src/mpc-hc/SelectMediaType.cpp
+++ b/src/mpc-hc/SelectMediaType.cpp
@@ -31,10 +31,10 @@
IMPLEMENT_DYNAMIC(CSelectMediaType, CCmdUIDialog)
CSelectMediaType::CSelectMediaType(CAtlArray<GUID>& guids, GUID guid, CWnd* pParent /*=NULL*/)
- : CCmdUIDialog(CSelectMediaType::IDD, pParent)
- , m_guids(guids), m_guid(guid)
+ : CCmdUIDialog(CSelectMediaType::IDD, pParent)
+ , m_guids(guids), m_guid(guid)
{
- m_guidstr = CStringFromGUID(guid);
+ m_guidstr = CStringFromGUID(guid);
}
CSelectMediaType::~CSelectMediaType()
@@ -43,15 +43,15 @@ CSelectMediaType::~CSelectMediaType()
void CSelectMediaType::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_CBString(pDX, IDC_COMBO1, m_guidstr);
- DDX_Control(pDX, IDC_COMBO1, m_guidsctrl);
+ __super::DoDataExchange(pDX);
+ DDX_CBString(pDX, IDC_COMBO1, m_guidstr);
+ DDX_Control(pDX, IDC_COMBO1, m_guidsctrl);
}
BEGIN_MESSAGE_MAP(CSelectMediaType, CCmdUIDialog)
- ON_CBN_EDITCHANGE(IDC_COMBO1, OnCbnEditchangeCombo1)
- ON_UPDATE_COMMAND_UI(IDOK, OnUpdateOK)
+ ON_CBN_EDITCHANGE(IDC_COMBO1, OnCbnEditchangeCombo1)
+ ON_UPDATE_COMMAND_UI(IDOK, OnUpdateOK)
END_MESSAGE_MAP()
@@ -59,40 +59,40 @@ END_MESSAGE_MAP()
BOOL CSelectMediaType::OnInitDialog()
{
- CCmdUIDialog::OnInitDialog();
+ CCmdUIDialog::OnInitDialog();
- for (size_t i = 0; i < m_guids.GetCount(); i++) {
- m_guidsctrl.AddString(GetMediaTypeName(m_guids[i]));
- }
+ for (size_t i = 0; i < m_guids.GetCount(); i++) {
+ m_guidsctrl.AddString(GetMediaTypeName(m_guids[i]));
+ }
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CSelectMediaType::OnCbnEditchangeCombo1()
{
- UpdateData();
- int i = m_guidsctrl.FindStringExact(0, m_guidstr);
- if (i >= 0) {
- DWORD sel = m_guidsctrl.GetEditSel();
- m_guidsctrl.SetCurSel(i);
- m_guidsctrl.SetEditSel(sel,sel);
- }
+ UpdateData();
+ int i = m_guidsctrl.FindStringExact(0, m_guidstr);
+ if (i >= 0) {
+ DWORD sel = m_guidsctrl.GetEditSel();
+ m_guidsctrl.SetCurSel(i);
+ m_guidsctrl.SetEditSel(sel, sel);
+ }
}
void CSelectMediaType::OnUpdateOK(CCmdUI* pCmdUI)
{
- UpdateData();
+ UpdateData();
- pCmdUI->Enable(!m_guidstr.IsEmpty() && (m_guidsctrl.GetCurSel() >= 0 || GUIDFromCString(m_guidstr) != GUID_NULL));
+ pCmdUI->Enable(!m_guidstr.IsEmpty() && (m_guidsctrl.GetCurSel() >= 0 || GUIDFromCString(m_guidstr) != GUID_NULL));
}
void CSelectMediaType::OnOK()
{
- UpdateData();
+ UpdateData();
- int i = m_guidsctrl.GetCurSel();
- m_guid = i >= 0 ? m_guids[i] : GUIDFromCString(m_guidstr);
+ int i = m_guidsctrl.GetCurSel();
+ m_guid = i >= 0 ? m_guids[i] : GUIDFromCString(m_guidstr);
- CCmdUIDialog::OnOK();
+ CCmdUIDialog::OnOK();
}
diff --git a/src/mpc-hc/SelectMediaType.h b/src/mpc-hc/SelectMediaType.h
index f5ca7623e..5eb6146f5 100644
--- a/src/mpc-hc/SelectMediaType.h
+++ b/src/mpc-hc/SelectMediaType.h
@@ -31,29 +31,29 @@
class CSelectMediaType : public CCmdUIDialog
{
- DECLARE_DYNAMIC(CSelectMediaType)
+ DECLARE_DYNAMIC(CSelectMediaType)
private:
- CAtlArray<GUID>& m_guids;
+ CAtlArray<GUID>& m_guids;
public:
- CSelectMediaType(CAtlArray<GUID>& guids, GUID guid, CWnd* pParent = NULL); // standard constructor
- virtual ~CSelectMediaType();
+ CSelectMediaType(CAtlArray<GUID>& guids, GUID guid, CWnd* pParent = NULL); // standard constructor
+ virtual ~CSelectMediaType();
- GUID m_guid;
+ GUID m_guid;
- // Dialog Data
- enum { IDD = IDD_SELECTMEDIATYPE };
- CString m_guidstr;
- CComboBox m_guidsctrl;
+ // Dialog Data
+ enum { IDD = IDD_SELECTMEDIATYPE };
+ CString m_guidstr;
+ CComboBox m_guidsctrl;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
- virtual void OnOK();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
+ virtual void OnOK();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnCbnEditchangeCombo1();
- afx_msg void OnUpdateOK(CCmdUI* pCmdUI);
+ afx_msg void OnCbnEditchangeCombo1();
+ afx_msg void OnUpdateOK(CCmdUI* pCmdUI);
};
diff --git a/src/mpc-hc/SettingsDefines.h b/src/mpc-hc/SettingsDefines.h
index e46912c08..2aaab0e74 100644
--- a/src/mpc-hc/SettingsDefines.h
+++ b/src/mpc-hc/SettingsDefines.h
@@ -23,237 +23,237 @@
#pragma once
-#define IDS_R_SETTINGS _T("Settings")
-#define IDS_R_FILTERS _T("Filters")
-#define IDS_R_INTERNAL_FILTERS _T("Internal Filters")
-#define IDS_R_FAVFILES _T("Favorites\\Files")
-#define IDS_R_FAVDVDS _T("Favorites\\DVDs")
-#define IDS_R_FAVDEVICES _T("Favorites\\Devices")
-#define IDS_R_COMMANDS _T("Commands2")
-#define IDS_R_LOGINS _T("Logins")
-#define IDS_R_FAVORITES _T("Favorites")
-#define IDS_R_SHADERS _T("Shaders")
+#define IDS_R_SETTINGS _T("Settings")
+#define IDS_R_FILTERS _T("Filters")
+#define IDS_R_INTERNAL_FILTERS _T("Internal Filters")
+#define IDS_R_FAVFILES _T("Favorites\\Files")
+#define IDS_R_FAVDVDS _T("Favorites\\DVDs")
+#define IDS_R_FAVDEVICES _T("Favorites\\Devices")
+#define IDS_R_COMMANDS _T("Commands2")
+#define IDS_R_LOGINS _T("Logins")
+#define IDS_R_FAVORITES _T("Favorites")
+#define IDS_R_SHADERS _T("Shaders")
-#define IDS_RS_FAV_REMEMBERPOS _T("RememberPosition")
-#define IDS_RS_FAV_RELATIVEDRIVE _T("RelativeDrive")
-#define IDS_RS_DVDPOS _T("Remember DVD Pos")
-#define IDS_RS_FILEPOS _T("Remember File Pos")
-#define IDS_RS_LASTFULLSCREEN _T("LastFullScreen")
-#define IDS_RS_EVR_BUFFERS _T("EVRBuffers")
-#define IDS_RS_SHOWOSD _T("Show OSD")
-#define IDS_RS_LANGUAGE _T("InterfaceLanguage")
-#define IDS_RS_GLOBALMEDIA _T("UseGlobalMedia")
-#define IDS_RS_DXVAFILTERS _T("DXVAFilters")
-#define IDS_RS_FFMPEGFILTERS _T("FFmpegFilters")
-#define IDS_RS_TITLEBARTEXTSTYLE _T("TitleBarTextStyle")
-#define IDS_RS_CONTROLSTATE _T("ControlState")
-#define IDS_RS_LOOP _T("Loop")
-#define IDS_RS_LOOPNUM _T("LoopNum")
-#define IDS_RS_SNAPTODESKTOPEDGES _T("SnapToDesktopEdges")
-#define IDS_RS_ENABLESUBTITLES _T("EnableSubtitles")
-#define IDS_RS_PRIORITIZEEXTERNALSUBTITLES _T("PrioritizeExternalSubtitles")
-#define IDS_RS_DISABLEINTERNALSUBTITLES _T("DisableInternalSubtitles")
-#define IDS_RS_SUBTITLEPATHS _T("SubtitlePaths")
-#define IDS_RS_USEDEFAULTSUBTITLESSTYLE _T("UseDefaultsubtitlesStyle")
-#define IDS_RS_MPEGINTERLACED _T("MPEGInterlaced")
-#define IDS_RS_THUMBWIDTH _T("ThumbWidth")
-#define IDS_RS_D3DFULLSCREEN _T("D3DFullScreen")
-#define IDS_RS_MONITOR_AUTOREFRESHRATE _T("MonitorAutoRefreshRate")
+#define IDS_RS_FAV_REMEMBERPOS _T("RememberPosition")
+#define IDS_RS_FAV_RELATIVEDRIVE _T("RelativeDrive")
+#define IDS_RS_DVDPOS _T("Remember DVD Pos")
+#define IDS_RS_FILEPOS _T("Remember File Pos")
+#define IDS_RS_LASTFULLSCREEN _T("LastFullScreen")
+#define IDS_RS_EVR_BUFFERS _T("EVRBuffers")
+#define IDS_RS_SHOWOSD _T("Show OSD")
+#define IDS_RS_LANGUAGE _T("InterfaceLanguage")
+#define IDS_RS_GLOBALMEDIA _T("UseGlobalMedia")
+#define IDS_RS_DXVAFILTERS _T("DXVAFilters")
+#define IDS_RS_FFMPEGFILTERS _T("FFmpegFilters")
+#define IDS_RS_TITLEBARTEXTSTYLE _T("TitleBarTextStyle")
+#define IDS_RS_CONTROLSTATE _T("ControlState")
+#define IDS_RS_LOOP _T("Loop")
+#define IDS_RS_LOOPNUM _T("LoopNum")
+#define IDS_RS_SNAPTODESKTOPEDGES _T("SnapToDesktopEdges")
+#define IDS_RS_ENABLESUBTITLES _T("EnableSubtitles")
+#define IDS_RS_PRIORITIZEEXTERNALSUBTITLES _T("PrioritizeExternalSubtitles")
+#define IDS_RS_DISABLEINTERNALSUBTITLES _T("DisableInternalSubtitles")
+#define IDS_RS_SUBTITLEPATHS _T("SubtitlePaths")
+#define IDS_RS_USEDEFAULTSUBTITLESSTYLE _T("UseDefaultsubtitlesStyle")
+#define IDS_RS_MPEGINTERLACED _T("MPEGInterlaced")
+#define IDS_RS_THUMBWIDTH _T("ThumbWidth")
+#define IDS_RS_D3DFULLSCREEN _T("D3DFullScreen")
+#define IDS_RS_MONITOR_AUTOREFRESHRATE _T("MonitorAutoRefreshRate")
// Audio
-#define IDS_RS_VOLUME _T("Volume")
-#define IDS_RS_MUTE _T("Mute")
-#define IDS_RS_BALANCE _T("Balance")
+#define IDS_RS_VOLUME _T("Volume")
+#define IDS_RS_MUTE _T("Mute")
+#define IDS_RS_BALANCE _T("Balance")
// AudioSwitcher
-#define IDS_RS_ENABLEAUDIOSWITCHER _T("EnableAudioSwitcher")
-#define IDS_RS_AUDIONORMALIZE _T("AudioNormalize")
-#define IDS_RS_AUDIONORMALIZERECOVER _T("AudioNormalizeRecover")
-#define IDS_RS_AUDIOBOOST _T("AudioBoost")
-#define IDS_RS_DOWNSAMPLETO441 _T("DownSampleTo441")
-#define IDS_RS_ENABLEAUDIOTIMESHIFT _T("EnableAudioTimeShift")
-#define IDS_RS_AUDIOTIMESHIFT _T("AudioTimeShift")
-#define IDS_RS_CUSTOMCHANNELMAPPING _T("CustomChannelMapping")
-#define IDS_RS_SPEAKERCHANNELS _T("SpeakerChannels")
-#define IDS_RS_SPEAKERTOCHANNELMAPPING _T("SpeakerToChannelMapping")
+#define IDS_RS_ENABLEAUDIOSWITCHER _T("EnableAudioSwitcher")
+#define IDS_RS_AUDIONORMALIZE _T("AudioNormalize")
+#define IDS_RS_AUDIONORMALIZERECOVER _T("AudioNormalizeRecover")
+#define IDS_RS_AUDIOBOOST _T("AudioBoost")
+#define IDS_RS_DOWNSAMPLETO441 _T("DownSampleTo441")
+#define IDS_RS_ENABLEAUDIOTIMESHIFT _T("EnableAudioTimeShift")
+#define IDS_RS_AUDIOTIMESHIFT _T("AudioTimeShift")
+#define IDS_RS_CUSTOMCHANNELMAPPING _T("CustomChannelMapping")
+#define IDS_RS_SPEAKERCHANNELS _T("SpeakerChannels")
+#define IDS_RS_SPEAKERTOCHANNELMAPPING _T("SpeakerToChannelMapping")
// Video
-#define IDS_RS_COLOR_BRIGHTNESS _T("VideoBrightness")
-#define IDS_RS_COLOR_CONTRAST _T("VideoContrast")
-#define IDS_RS_COLOR_HUE _T("VideoHue")
-#define IDS_RS_COLOR_SATURATION _T("VideoSaturation")
+#define IDS_RS_COLOR_BRIGHTNESS _T("VideoBrightness")
+#define IDS_RS_COLOR_CONTRAST _T("VideoContrast")
+#define IDS_RS_COLOR_HUE _T("VideoHue")
+#define IDS_RS_COLOR_SATURATION _T("VideoSaturation")
// DVD/OGM
-#define IDS_RS_DVDPATH _T("DVDPath")
-#define IDS_RS_USEDVDPATH _T("UseDVDPath")
-#define IDS_RS_MENULANG _T("MenuLang")
-#define IDS_RS_AUDIOLANG _T("AudioLang")
-#define IDS_RS_SUBTITLESLANG _T("SubtitlesLang")
-#define IDS_RS_AUTOSPEAKERCONF _T("AutoSpeakerConf")
-#define IDS_RS_CLOSEDCAPTIONS _T("ClosedCaptions")
+#define IDS_RS_DVDPATH _T("DVDPath")
+#define IDS_RS_USEDVDPATH _T("UseDVDPath")
+#define IDS_RS_MENULANG _T("MenuLang")
+#define IDS_RS_AUDIOLANG _T("AudioLang")
+#define IDS_RS_SUBTITLESLANG _T("SubtitlesLang")
+#define IDS_RS_AUTOSPEAKERCONF _T("AutoSpeakerConf")
+#define IDS_RS_CLOSEDCAPTIONS _T("ClosedCaptions")
//
-#define IDS_RS_SHADERLIST _T("Shaders List")
-#define IDS_RS_TITLEBARTEXTTITLE _T("TitleBarTextTitle")
-#define IDS_RS_VMR9MIXERYUV _T("VMRMixerYUV")
-#define IDS_RS_REWIND _T("Rewind")
-#define IDS_RS_ZOOM _T("Zoom")
-#define IDS_RS_MULTIINST _T("AllowMultipleInstances")
-#define IDS_RS_ALWAYSONTOP _T("AlwaysOnTop")
-#define IDS_RS_AUTOZOOM _T("AutoZoom")
-#define IDS_RS_FULLSCREENCTRLS _T("FullScreenCtrls")
-#define IDS_RS_FULLSCREENCTRLSTIMEOUT _T("FullScreenCtrlsTimeOut")
-#define IDS_RS_VMRFLIP _T("VMRFlip")
-#define IDS_RS_SPLOGFONT _T("SPDefaultStyle")
-#define IDS_RS_SPOVERRIDEPLACEMENT _T("SPOverridePlacement")
-#define IDS_RS_SPHORPOS _T("SPHorPos")
-#define IDS_RS_SPVERPOS _T("SPVerPos")
-#define IDS_RS_SPCSIZE _T("SPCSize")
-#define IDS_RS_SPCMAXRES _T("SPCMaxRes")
-#define IDS_RS_INTREALMEDIA _T("IntRealMedia")
-#define IDS_RS_USEDEDYNAMIC _T("UseDeDynamic")
-#define IDS_RS_DBLCLICKFULLSCREEN _T("DblClickFullScreen")
-#define IDS_RS_EXITFULLSCREENATTHEEND _T("ExitFullscreenAtTheEnd")
-#define IDS_RS_RESTORERESAFTEREXIT _T("RestoreResAfterExit")
-#define IDS_RS_REMEMBERWINDOWPOS _T("RememberWindowPos")
-#define IDS_RS_LASTWINDOWRECT _T("LastWindowRect")
-#define IDS_RS_AUDIORENDERERTYPE _T("AudioRendererType")
-#define IDS_RS_HIDECAPTIONMENU _T("HideCaptionMenu")
-#define IDS_RS_HIDENAVIGATION _T("HideNavigation")
-#define IDS_RS_DEFAULTVIDEOFRAME _T("DefaultVideoFrame")
-#define IDS_RS_REMEMBERWINDOWSIZE _T("RememberWindowSize")
-#define IDS_RS_PANSCANZOOM _T("PanScanZoom")
-#define IDS_RS_REALMEDIARENDERLESS _T("RealMediaRenderless")
-#define IDS_RS_QUICKTIMERENDERER _T("QuickTimeRenderer")
-#define IDS_RS_REALMEDIAFPS _T("RealMediaFPS")
-#define IDS_RS_SUBDELAYINTERVAL _T("SubDelayInterval")
-#define IDS_RS_LOGOFILE _T("LogoFile")
-#define IDS_RS_ENABLEWORKERTHREADFOROPENING _T("EnableWorkerThreadForOpening")
-#define IDS_RS_PNSPRESETS _T("PnSPresets")
-#define IDS_RS_AUTOLOADAUDIO _T("AutoloadAudio")
-#define IDS_RS_AUTOLOADSUBTITLES _T("AutoloadSubtitles")
-#define IDS_RS_SUBTITLESLANGORDER _T("SubtitlesLanguageOrder")
-#define IDS_RS_AUDIOSLANGORDER _T("AudiosLanguageOrder")
-#define IDS_RS_BLOCKVSFILTER _T("BlockVSFilter")
-#define IDS_RS_SEARCHKEYFRAMES _T("SearchKeyframes")
-#define IDS_RS_ACCELTBL _T("AccelTbl")
-#define IDS_RS_SETFULLSCREENRES _T("SetFullscreenRes")
-#define IDS_RS_FULLSCREENRES _T("FullscreenRes")
-#define IDS_RS_WINLIRCADDR _T("WinLircAddr")
-#define IDS_RS_WINLIRC _T("UseWinLirc")
-#define IDS_RS_TRAYICON _T("TrayIcon")
-#define IDS_RS_KEEPASPECTRATIO _T("KeepAspectRatio")
-#define IDS_RS_UICEADDR _T("UICEAddr")
-#define IDS_RS_UICE _T("UseUICE")
-#define IDS_RS_JUMPDISTS _T("JumpDistS")
-#define IDS_RS_JUMPDISTM _T("JumpDistM")
-#define IDS_RS_JUMPDISTL _T("JumpDistL")
-#define IDS_RS_REPORTFAILEDPINS _T("ReportFailedPins")
-#define IDS_RS_SRCFILTERS _T("SrcFilters")
-#define IDS_RS_KEEPHISTORY _T("KeepHistory")
-#define IDS_RS_LOGOID _T("LogoID2")
-#define IDS_RS_LOGOEXT _T("LogoExt")
-#define IDS_RS_TRAFILTERS _T("TraFilters")
-#define IDS_RS_MPEGDI _T("MPEGDI")
-#define IDS_RS_MPEGBRIGHT _T("MPEGBright")
-#define IDS_RS_MPEGCONT _T("MPEGCont")
-#define IDS_RS_MPEGHUE _T("MPEGHue")
-#define IDS_RS_MPEGSAT _T("MPEGSat")
-#define IDS_RS_MPEGFORCEDSUBS _T("MPEGForcedSubs")
-#define IDS_RS_MPEGPLANARYUV _T("MPEGPlanarYUV")
-#define IDS_RS_COMPMONDESKARDIFF _T("CompMonDeskARDiff")
-#define IDS_RS_HIDECDROMSSUBMENU _T("HideCDROMsSubMenu")
-#define IDS_RS_VMRTEXTURE _T("VMRTexture")
-#define IDS_RS_VMR3D _T("VMR3D")
-#define IDS_RS_DSVIDEORENDERERTYPE _T("DSVidRen")
-#define IDS_RS_RMVIDEORENDERERTYPE _T("RMVidRen")
-#define IDS_RS_QTVIDEORENDERERTYPE _T("QTVidRen")
-#define IDS_RS_SHUFFLEPLAYLISTITEMS _T("ShufflePlaylistItems")
-#define IDS_RS_REMEMBERPLAYLISTITEMS _T("RememberPlaylistItems")
-#define IDS_RS_HIDEPLAYLISTFULLSCREEN _T("HidePlaylistFullScreen")
-#define IDS_RS_APSURACEFUSAGE _T("APSurfaceUsage")
-#define IDS_RS_ENABLEWEBSERVER _T("EnableWebServer")
-#define IDS_RS_WEBSERVERPORT _T("WebServerPort")
-#define IDS_RS_LASTWINDOWTYPE _T("LastWindowType")
-#define IDS_RS_ONTOP _T("OnTop")
-#define IDS_RS_MPASF _T("MPASampleFormat")
-#define IDS_RS_AC3SC _T("AC3SpeakerConfig")
-#define IDS_RS_AC3DRC _T("AC3DynamicRangeControl")
-#define IDS_RS_WEBSERVERPRINTDEBUGINFO _T("WebServerPrintDebugIfo")
-#define IDS_RS_WEBSERVERUSECOMPRESSION _T("WebServerUseCompression")
-#define IDS_RS_MPANORMALIZE _T("MPANormalize")
-#define IDS_RS_DTSSC _T("DTSSpeakerConfig")
-#define IDS_RS_DTSDRC _T("DTSDynamicRangeControl")
-#define IDS_RS_SNAPSHOTPATH _T("SnapShotPath")
-#define IDS_RS_PRIORITY _T("Priority")
-#define IDS_RS_SNAPSHOTEXT _T("SnapShotExt")
-#define IDS_RS_LAUNCHFULLSCREEN _T("LaunchFullScreen")
-#define IDS_RS_MPABOOST _T("MpaBoost")
-#define IDS_RS_AACSC _T("AACSpeakerConfig")
-#define IDS_RS_ISDB _T("ISDb")
-#define IDS_RS_POW2TEX _T("SPCPow2Tex")
-#define IDS_RS_WEBROOT _T("WebRoot")
-#define IDS_RS_WEBSERVERLOCALHOSTONLY _T("WebServerLocalhostOnly")
-#define IDS_RS_ASPECTRATIO_X _T("AspectRatioX")
-#define IDS_RS_ASPECTRATIO_Y _T("AspectRatioY")
-#define IDS_RS_DX9_RESIZER _T("DX9Resizer")
-#define IDS_RS_WEBSERVERCGI _T("WebServerCGI")
-#define IDS_RS_WEBDEFINDEX _T("WebDefIndex")
-#define IDS_RS_LIMITWINDOWPROPORTIONS _T("LimitWindowProportions")
-#define IDS_RS_NOTIFYMSN _T("NotifyMSN2")
-#define IDS_RS_LASTUSEDPAGE _T("LastUsedPage")
-#define IDS_RS_VMR9MIXERMODE _T("VMR9MixerMode")
-#define IDS_RS_THUMBROWS _T("ThumbRows")
-#define IDS_RS_THUMBCOLS _T("ThumbCols")
-#define IDS_RS_ENABLEEDLEDITOR _T("EnableEDLEditor")
-#define IDS_RS_SHADERLISTSCREENSPACE _T("ShaderListScreenSpace")
-#define IDS_RS_FULLSCREENMONITOR _T("FullScreenMonitor")
-#define IDS_RS_MPC_PREVENT_MINIMIZE _T("PreventMinimize")
-#define IDS_RS_MPC_WIN7TASKBAR _T("UseWin7TaskBar")
-#define IDS_RS_MPC_EXIT_AFTER_PB _T("ExitAfterPlayBack")
-#define IDS_RS_MPC_NEXT_AFTER_PB _T("SearchInDirAfterPlayBack")
-#define IDS_RS_MPC_NO_SEARCH_IN_FOLDER _T("DontUseSearchInFolder")
-#define IDS_RS_USE_TIME_TOOLTIP _T("UseTimeTooltip")
-#define IDS_RS_TIME_TOOLTIP_POSITION _T("TimeTooltipPosition")
-#define IDS_RS_MPC_OSD_SIZE _T("OSD_Size")
-#define IDS_RS_MPC_OSD_FONT _T("OSD_Font")
-#define IDS_RS_LAST_OPEN_DIR _T("LastOpenDir")
-#define IDS_RS_ASSOCIATED_WITH_ICON _T("AssociatedWithIcon")
+#define IDS_RS_SHADERLIST _T("Shaders List")
+#define IDS_RS_TITLEBARTEXTTITLE _T("TitleBarTextTitle")
+#define IDS_RS_VMR9MIXERYUV _T("VMRMixerYUV")
+#define IDS_RS_REWIND _T("Rewind")
+#define IDS_RS_ZOOM _T("Zoom")
+#define IDS_RS_MULTIINST _T("AllowMultipleInstances")
+#define IDS_RS_ALWAYSONTOP _T("AlwaysOnTop")
+#define IDS_RS_AUTOZOOM _T("AutoZoom")
+#define IDS_RS_FULLSCREENCTRLS _T("FullScreenCtrls")
+#define IDS_RS_FULLSCREENCTRLSTIMEOUT _T("FullScreenCtrlsTimeOut")
+#define IDS_RS_VMRFLIP _T("VMRFlip")
+#define IDS_RS_SPLOGFONT _T("SPDefaultStyle")
+#define IDS_RS_SPOVERRIDEPLACEMENT _T("SPOverridePlacement")
+#define IDS_RS_SPHORPOS _T("SPHorPos")
+#define IDS_RS_SPVERPOS _T("SPVerPos")
+#define IDS_RS_SPCSIZE _T("SPCSize")
+#define IDS_RS_SPCMAXRES _T("SPCMaxRes")
+#define IDS_RS_INTREALMEDIA _T("IntRealMedia")
+#define IDS_RS_USEDEDYNAMIC _T("UseDeDynamic")
+#define IDS_RS_DBLCLICKFULLSCREEN _T("DblClickFullScreen")
+#define IDS_RS_EXITFULLSCREENATTHEEND _T("ExitFullscreenAtTheEnd")
+#define IDS_RS_RESTORERESAFTEREXIT _T("RestoreResAfterExit")
+#define IDS_RS_REMEMBERWINDOWPOS _T("RememberWindowPos")
+#define IDS_RS_LASTWINDOWRECT _T("LastWindowRect")
+#define IDS_RS_AUDIORENDERERTYPE _T("AudioRendererType")
+#define IDS_RS_HIDECAPTIONMENU _T("HideCaptionMenu")
+#define IDS_RS_HIDENAVIGATION _T("HideNavigation")
+#define IDS_RS_DEFAULTVIDEOFRAME _T("DefaultVideoFrame")
+#define IDS_RS_REMEMBERWINDOWSIZE _T("RememberWindowSize")
+#define IDS_RS_PANSCANZOOM _T("PanScanZoom")
+#define IDS_RS_REALMEDIARENDERLESS _T("RealMediaRenderless")
+#define IDS_RS_QUICKTIMERENDERER _T("QuickTimeRenderer")
+#define IDS_RS_REALMEDIAFPS _T("RealMediaFPS")
+#define IDS_RS_SUBDELAYINTERVAL _T("SubDelayInterval")
+#define IDS_RS_LOGOFILE _T("LogoFile")
+#define IDS_RS_ENABLEWORKERTHREADFOROPENING _T("EnableWorkerThreadForOpening")
+#define IDS_RS_PNSPRESETS _T("PnSPresets")
+#define IDS_RS_AUTOLOADAUDIO _T("AutoloadAudio")
+#define IDS_RS_AUTOLOADSUBTITLES _T("AutoloadSubtitles")
+#define IDS_RS_SUBTITLESLANGORDER _T("SubtitlesLanguageOrder")
+#define IDS_RS_AUDIOSLANGORDER _T("AudiosLanguageOrder")
+#define IDS_RS_BLOCKVSFILTER _T("BlockVSFilter")
+#define IDS_RS_SEARCHKEYFRAMES _T("SearchKeyframes")
+#define IDS_RS_ACCELTBL _T("AccelTbl")
+#define IDS_RS_SETFULLSCREENRES _T("SetFullscreenRes")
+#define IDS_RS_FULLSCREENRES _T("FullscreenRes")
+#define IDS_RS_WINLIRCADDR _T("WinLircAddr")
+#define IDS_RS_WINLIRC _T("UseWinLirc")
+#define IDS_RS_TRAYICON _T("TrayIcon")
+#define IDS_RS_KEEPASPECTRATIO _T("KeepAspectRatio")
+#define IDS_RS_UICEADDR _T("UICEAddr")
+#define IDS_RS_UICE _T("UseUICE")
+#define IDS_RS_JUMPDISTS _T("JumpDistS")
+#define IDS_RS_JUMPDISTM _T("JumpDistM")
+#define IDS_RS_JUMPDISTL _T("JumpDistL")
+#define IDS_RS_REPORTFAILEDPINS _T("ReportFailedPins")
+#define IDS_RS_SRCFILTERS _T("SrcFilters")
+#define IDS_RS_KEEPHISTORY _T("KeepHistory")
+#define IDS_RS_LOGOID _T("LogoID2")
+#define IDS_RS_LOGOEXT _T("LogoExt")
+#define IDS_RS_TRAFILTERS _T("TraFilters")
+#define IDS_RS_MPEGDI _T("MPEGDI")
+#define IDS_RS_MPEGBRIGHT _T("MPEGBright")
+#define IDS_RS_MPEGCONT _T("MPEGCont")
+#define IDS_RS_MPEGHUE _T("MPEGHue")
+#define IDS_RS_MPEGSAT _T("MPEGSat")
+#define IDS_RS_MPEGFORCEDSUBS _T("MPEGForcedSubs")
+#define IDS_RS_MPEGPLANARYUV _T("MPEGPlanarYUV")
+#define IDS_RS_COMPMONDESKARDIFF _T("CompMonDeskARDiff")
+#define IDS_RS_HIDECDROMSSUBMENU _T("HideCDROMsSubMenu")
+#define IDS_RS_VMRTEXTURE _T("VMRTexture")
+#define IDS_RS_VMR3D _T("VMR3D")
+#define IDS_RS_DSVIDEORENDERERTYPE _T("DSVidRen")
+#define IDS_RS_RMVIDEORENDERERTYPE _T("RMVidRen")
+#define IDS_RS_QTVIDEORENDERERTYPE _T("QTVidRen")
+#define IDS_RS_SHUFFLEPLAYLISTITEMS _T("ShufflePlaylistItems")
+#define IDS_RS_REMEMBERPLAYLISTITEMS _T("RememberPlaylistItems")
+#define IDS_RS_HIDEPLAYLISTFULLSCREEN _T("HidePlaylistFullScreen")
+#define IDS_RS_APSURACEFUSAGE _T("APSurfaceUsage")
+#define IDS_RS_ENABLEWEBSERVER _T("EnableWebServer")
+#define IDS_RS_WEBSERVERPORT _T("WebServerPort")
+#define IDS_RS_LASTWINDOWTYPE _T("LastWindowType")
+#define IDS_RS_ONTOP _T("OnTop")
+#define IDS_RS_MPASF _T("MPASampleFormat")
+#define IDS_RS_AC3SC _T("AC3SpeakerConfig")
+#define IDS_RS_AC3DRC _T("AC3DynamicRangeControl")
+#define IDS_RS_WEBSERVERPRINTDEBUGINFO _T("WebServerPrintDebugIfo")
+#define IDS_RS_WEBSERVERUSECOMPRESSION _T("WebServerUseCompression")
+#define IDS_RS_MPANORMALIZE _T("MPANormalize")
+#define IDS_RS_DTSSC _T("DTSSpeakerConfig")
+#define IDS_RS_DTSDRC _T("DTSDynamicRangeControl")
+#define IDS_RS_SNAPSHOTPATH _T("SnapShotPath")
+#define IDS_RS_PRIORITY _T("Priority")
+#define IDS_RS_SNAPSHOTEXT _T("SnapShotExt")
+#define IDS_RS_LAUNCHFULLSCREEN _T("LaunchFullScreen")
+#define IDS_RS_MPABOOST _T("MpaBoost")
+#define IDS_RS_AACSC _T("AACSpeakerConfig")
+#define IDS_RS_ISDB _T("ISDb")
+#define IDS_RS_POW2TEX _T("SPCPow2Tex")
+#define IDS_RS_WEBROOT _T("WebRoot")
+#define IDS_RS_WEBSERVERLOCALHOSTONLY _T("WebServerLocalhostOnly")
+#define IDS_RS_ASPECTRATIO_X _T("AspectRatioX")
+#define IDS_RS_ASPECTRATIO_Y _T("AspectRatioY")
+#define IDS_RS_DX9_RESIZER _T("DX9Resizer")
+#define IDS_RS_WEBSERVERCGI _T("WebServerCGI")
+#define IDS_RS_WEBDEFINDEX _T("WebDefIndex")
+#define IDS_RS_LIMITWINDOWPROPORTIONS _T("LimitWindowProportions")
+#define IDS_RS_NOTIFYMSN _T("NotifyMSN2")
+#define IDS_RS_LASTUSEDPAGE _T("LastUsedPage")
+#define IDS_RS_VMR9MIXERMODE _T("VMR9MixerMode")
+#define IDS_RS_THUMBROWS _T("ThumbRows")
+#define IDS_RS_THUMBCOLS _T("ThumbCols")
+#define IDS_RS_ENABLEEDLEDITOR _T("EnableEDLEditor")
+#define IDS_RS_SHADERLISTSCREENSPACE _T("ShaderListScreenSpace")
+#define IDS_RS_FULLSCREENMONITOR _T("FullScreenMonitor")
+#define IDS_RS_MPC_PREVENT_MINIMIZE _T("PreventMinimize")
+#define IDS_RS_MPC_WIN7TASKBAR _T("UseWin7TaskBar")
+#define IDS_RS_MPC_EXIT_AFTER_PB _T("ExitAfterPlayBack")
+#define IDS_RS_MPC_NEXT_AFTER_PB _T("SearchInDirAfterPlayBack")
+#define IDS_RS_MPC_NO_SEARCH_IN_FOLDER _T("DontUseSearchInFolder")
+#define IDS_RS_USE_TIME_TOOLTIP _T("UseTimeTooltip")
+#define IDS_RS_TIME_TOOLTIP_POSITION _T("TimeTooltipPosition")
+#define IDS_RS_MPC_OSD_SIZE _T("OSD_Size")
+#define IDS_RS_MPC_OSD_FONT _T("OSD_Font")
+#define IDS_RS_LAST_OPEN_DIR _T("LastOpenDir")
+#define IDS_RS_ASSOCIATED_WITH_ICON _T("AssociatedWithIcon")
-#define IDS_RS_TOGGLESHADER _T("ToggleShader")
-#define IDS_RS_TOGGLESHADERSSCREENSPACE _T("ToggleShaderScreenSpace")
+#define IDS_RS_TOGGLESHADER _T("ToggleShader")
+#define IDS_RS_TOGGLESHADERSSCREENSPACE _T("ToggleShaderScreenSpace")
-#define IDS_RS_DEFAULT_CAPTURE _T("DefaultCapture")
-#define IDS_RS_CAPTURE _T("Capture")
-#define IDS_RS_VIDEO_DISP_NAME _T("VidDispName")
-#define IDS_RS_AUDIO_DISP_NAME _T("AudDispName")
-#define IDS_RS_COUNTRY _T("Country")
+#define IDS_RS_DEFAULT_CAPTURE _T("DefaultCapture")
+#define IDS_RS_CAPTURE _T("Capture")
+#define IDS_RS_VIDEO_DISP_NAME _T("VidDispName")
+#define IDS_RS_AUDIO_DISP_NAME _T("AudDispName")
+#define IDS_RS_COUNTRY _T("Country")
-#define IDS_RS_DVB _T("DVB configuration")
-#define IDS_RS_BDA_NETWORKPROVIDER _T("BDANetworkProvider")
-#define IDS_RS_BDA_TUNER _T("BDATuner")
-#define IDS_RS_BDA_RECEIVER _T("BDAReceiver")
-#define IDS_RS_BDA_STANDARD _T("BDAStandard")
-#define IDS_RS_BDA_SCAN_FREQ_START _T("BDAScanFreqStart")
-#define IDS_RS_BDA_SCAN_FREQ_END _T("BDAScanFreqEnd")
-#define IDS_RS_BDA_BANDWIDTH _T("BDABandWidth")
-#define IDS_RS_BDA_USE_OFFSET _T("BDAUseOffset")
-#define IDS_RS_BDA_OFFSET _T("BDAOffset")
+#define IDS_RS_DVB _T("DVB configuration")
+#define IDS_RS_BDA_NETWORKPROVIDER _T("BDANetworkProvider")
+#define IDS_RS_BDA_TUNER _T("BDATuner")
+#define IDS_RS_BDA_RECEIVER _T("BDAReceiver")
+#define IDS_RS_BDA_STANDARD _T("BDAStandard")
+#define IDS_RS_BDA_SCAN_FREQ_START _T("BDAScanFreqStart")
+#define IDS_RS_BDA_SCAN_FREQ_END _T("BDAScanFreqEnd")
+#define IDS_RS_BDA_BANDWIDTH _T("BDABandWidth")
+#define IDS_RS_BDA_USE_OFFSET _T("BDAUseOffset")
+#define IDS_RS_BDA_OFFSET _T("BDAOffset")
#define IDS_RS_BDA_IGNORE_ENCRYPTED_CHANNELS _T("BDAIgnoreEncryptedChannels")
-#define IDS_RS_DVB_LAST_CHANNEL _T("LastChannel")
+#define IDS_RS_DVB_LAST_CHANNEL _T("LastChannel")
-#define IDS_D3D9RENDERDEVICE _T("D3D9RenderDevice")
+#define IDS_D3D9RENDERDEVICE _T("D3D9RenderDevice")
-#define IDS_FASTSEEK_KEYFRAME _T("FastSeek")
+#define IDS_FASTSEEK_KEYFRAME _T("FastSeek")
-#define IDS_REMAINING_TIME _T("RemainingTime")
+#define IDS_REMAINING_TIME _T("RemainingTime")
-#define IDS_RS_UPDATER_AUTO_CHECK _T("UpdaterAutoCheck")
-#define IDS_RS_UPDATER_LAST_CHECK _T("UpdaterLastCheck")
-#define IDS_RS_UPDATER_DELAY _T("UpdaterDelay")
-#define IDS_RS_UPDATER_IGNORE_VERSION _T("UpdaterIgnoreVersion")
+#define IDS_RS_UPDATER_AUTO_CHECK _T("UpdaterAutoCheck")
+#define IDS_RS_UPDATER_LAST_CHECK _T("UpdaterLastCheck")
+#define IDS_RS_UPDATER_DELAY _T("UpdaterDelay")
+#define IDS_RS_UPDATER_IGNORE_VERSION _T("UpdaterIgnoreVersion")
-#define IDS_R_SHADERS_INITIALIZED _T("Initialized")
-#define IDS_R_SHADERS_COMBINE _T("Combine")
-#define IDS_R_SHADERS_COMBINESCREENSPACE _T("CombineScreenSpace")
+#define IDS_R_SHADERS_INITIALIZED _T("Initialized")
+#define IDS_R_SHADERS_COMBINE _T("Combine")
+#define IDS_R_SHADERS_COMBINESCREENSPACE _T("CombineScreenSpace")
-#define IDS_R_DLG_SUBTITLEDL _T("Dialogs\\SubtitleDl")
-#define IDS_RS_DLG_SUBTITLEDL_COLWIDTH _T("ColWidth")
+#define IDS_R_DLG_SUBTITLEDL _T("Dialogs\\SubtitleDl")
+#define IDS_RS_DLG_SUBTITLEDL_COLWIDTH _T("ColWidth")
-#define IDS_R_DLG_ORGANIZE_FAV _T("Dialogs\\OrganizeFavorites")
+#define IDS_R_DLG_ORGANIZE_FAV _T("Dialogs\\OrganizeFavorites")
diff --git a/src/mpc-hc/ShaderAutoCompleteDlg.cpp b/src/mpc-hc/ShaderAutoCompleteDlg.cpp
index a12d7292c..30f6da33b 100644
--- a/src/mpc-hc/ShaderAutoCompleteDlg.cpp
+++ b/src/mpc-hc/ShaderAutoCompleteDlg.cpp
@@ -29,89 +29,89 @@
// CShaderAutoCompleteDlg dialog
CShaderAutoCompleteDlg::CShaderAutoCompleteDlg(CWnd* pParent /*=NULL*/)
- : CResizableDialog(CShaderAutoCompleteDlg::IDD, pParent)
+ : CResizableDialog(CShaderAutoCompleteDlg::IDD, pParent)
{
- m_text[0] = 0;
-
- m_inst[_T("abs")] = _T("abs(value a)|Absolute value (per component). ");
- m_inst[_T("acos")] = _T("acos(x)|Returns the arccosine of each component of x. Each component should be in the range [-1, 1]. ");
- m_inst[_T("all")] = _T("all(x)|Test if all components of x are nonzero. ");
- m_inst[_T("any")] = _T("any(x)|Test is any component of x is nonzero. ");
- m_inst[_T("asin")] = _T("asin(x)|Returns the arcsine of each component of x. Each component should be in the range [-pi/2, pi/2]. ");
- m_inst[_T("atan")] = _T("atan(x)|Returns the arctangent of x. The return values are in the range [-pi/2, pi/2]. ");
- m_inst[_T("atan2")] = _T("atan2(y, x)|Returns the arctangent of y/x. The signs of y and x are used to determine the quadrant of the return values in the range [-pi, pi]. atan2 is well-defined for every point other than the origin, even if x equals 0 and y does not equal 0. ");
- m_inst[_T("ceil")] = _T("ceil(x)|Returns the smallest integer which is greater than or equal to x. ");
- m_inst[_T("clamp")] = _T("clamp(x, min, max)|Clamps x to the range [min, max]. ");
- m_inst[_T("clip")] = _T("clip(x)|Discards the current pixel, if any component of x is less than zero. This can be used to simulate clip planes, if each component of x represents the distance from a plane. ");
- m_inst[_T("cos")] = _T("cos(x)|Returns the cosine of x. ");
- m_inst[_T("cosh")] = _T("cosh(x)|Returns the hyperbolic cosine of x. ");
- m_inst[_T("cross")] = _T("cross(a, b)|Returns the cross product of two 3-D vectors a and b. ");
- m_inst[_T("d3dcolortoubyte4")] = _T("D3DCOLORtoUBYTE4(x)|Swizzles and scales components of the 4-D vector x to compensate for the lack of UBYTE4 support in some hardware. ");
- m_inst[_T("ddx")] = _T("ddx(x)|Returns the partial derivative of x with respect to the screen-space x-coordinate. ");
- m_inst[_T("ddy")] = _T("ddy(x)|Returns the partial derivative of x with respect to the screen-space y-coordinate. ");
- m_inst[_T("degrees")] = _T("degrees(x)|Converts x from radians to degrees. ");
- m_inst[_T("determinant")] = _T("determinant(m)|Returns the determinant of the square matrix m. ");
- m_inst[_T("distance")] = _T("distance(a, b)|Returns the distance between two points a and b. ");
- m_inst[_T("dot")] = _T("dot(a, b)|Returns the dot product of two vectors a and b. ");
- m_inst[_T("exp")] = _T("exp(x)|Returns the base-e exponent ex. ");
- m_inst[_T("exp2")] = _T("exp2(value a)|Base 2 Exp (per component). ");
- m_inst[_T("faceforward")] = _T("faceforward(n, i, ng)|Returns -n * sign(dot(i, ng)). ");
- m_inst[_T("floor")] = _T("floor(x)|Returns the greatest integer which is less than or equal to x. ");
- m_inst[_T("fmod")] = _T("fmod(a, b)|Returns the floating point remainder f of a / b such that a = i * b + f, where i is an integer, f has the same sign as x, and the absolute value of f is less than the absolute value of b. ");
- m_inst[_T("frac")] = _T("frac(x)|Returns the fractional part f of x, such that f is a value greater than or equal to 0, and less than 1. ");
- m_inst[_T("frc")] = _T("frc(value a)|Fractional part (per component). ");
- m_inst[_T("frexp")] = _T("frexp(x, out exp)|Returns the mantissa and exponent of x. frexp returns the mantissa, and the exponent is stored in the output parameter exp. If x is 0, the function returns 0 for both the mantissa and the exponent. ");
- m_inst[_T("fwidth")] = _T("fwidth(x)|Returns abs(ddx(x))+abs(ddy(x)). ");
- m_inst[_T("isfinite")] = _T("isfinite(x)|Returns true if x is finite, false otherwise. ");
- m_inst[_T("isinf")] = _T("isinf(x)|Returns true if x is +INF or -INF, false otherwise. ");
- m_inst[_T("isnan")] = _T("isnan(x)|Returns true if x is NAN or QNAN, false otherwise. ");
- m_inst[_T("ldexp")] = _T("ldexp(x, exp)|Returns x * 2exp. ");
- m_inst[_T("len")] = _T("len(value a)|Vector length. ");
- m_inst[_T("length")] = _T("length(v)|Returns the length of the vector v. ");
- m_inst[_T("lerp")] = _T("lerp(a, b, s)|Returns a + s(b - a). This linearly interpolates between a and b, such that the return value is a when s is 0, and b when s is 1. ");
- m_inst[_T("lit")] = _T("lit(ndotl, ndoth, m)|Returns a lighting vector (ambient, diffuse, specular, 1): ambient = 1; diffuse = (ndotl < 0) ? 0 : ndotl; specular = (ndotl < 0) || (ndoth < 0) ? 0 : (ndoth * m); ");
- m_inst[_T("log")] = _T("log(x)|Returns the base-e logarithm of x. If x is negative, the function returns indefinite. If x is 0, the function returns +INF. ");
- m_inst[_T("log10")] = _T("log10(x)|Returns the base-10 logarithm of x. If x is negative, the function returns indefinite. If x is 0, the function returns +INF. ");
- m_inst[_T("log2")] = _T("log2(x)|Returns the base-2 logarithm of x. If x is negative, the function returns indefinite. If x is 0, the function returns +INF. ");
- m_inst[_T("max")] = _T("max(a, b)|Selects the greater of a and b. ");
- m_inst[_T("min")] = _T("min(a, b)|Selects the lesser of a and b. ");
- m_inst[_T("modf")] = _T("modf(x, out ip)|Splits the value x into fractional and integer parts, each of which has the same sign and x. The signed fractional portion of x is returned. The integer portion is stored in the output parameter ip. ");
- m_inst[_T("mul")] = _T("mul(a, b)|Performs matrix multiplication between a and b. If a is a vector, it treated as a row vector. If b is a vector, it is treated as a column vector. The inner dimension acolumns and brows must be equal. The result has the dimension arows x bcolumns. ");
- m_inst[_T("noise")] = _T("noise(x)|Not yet implemented. ");
- m_inst[_T("normalize")] = _T("normalize(v)|Returns the normalized vector v / length(v). If the length of v is 0, the result is indefinite. ");
- m_inst[_T("pow")] = _T("pow(x, y)|Returns xy. ");
- m_inst[_T("radians")] = _T("radians(x)|Converts x from degrees to radians. ");
- m_inst[_T("reflect")] = _T("reflect(i, n)|Returns the reflection vector v, given the entering ray direction i, and the surface normal n. Such that v = i - 2 * dot(i, n) * n ");
- m_inst[_T("refract")] = _T("refract(i, n, eta)|Returns the refraction vector v, given the entering ray direction i, the surface normal n, and the relative index of refraction eta. If the angle between i and n is too great for a given eta, refract returns (0,0,0). ");
- m_inst[_T("round")] = _T("round(x)|Rounds x to the nearest integer. ");
- m_inst[_T("rsqrt")] = _T("rsqrt(x)|Returns 1 / sqrt(x). ");
- m_inst[_T("saturate")] = _T("saturate(x)|Clamps x to the range [0, 1]. ");
- m_inst[_T("sign")] = _T("sign(x)|Computes the sign of x. Returns -1 if x is less than 0, 0 if x equals 0, and 1 if x is greater than zero. ");
- m_inst[_T("sin")] = _T("sin(x)|Returns the sine of x. ");
- m_inst[_T("sincos")] = _T("sincos(x, out s, out c)|Returns the sine and cosine of x. sin(x) is stored in the output parameter s. cos(x) is stored in the output parameter c. ");
- m_inst[_T("sinh")] = _T("sinh(x)|Returns the hyperbolic sine of x. ");
- m_inst[_T("smoothstep")] = _T("smoothstep(min, max, x)|Returns 0 if x < min. Returns 1 if x > max. Returns a smooth Hermite interpolation between 0 and 1, if x is in the range [min, max]. ");
- m_inst[_T("sqrt")] = _T("sqrt(value a)|Square root (per component). ");
- m_inst[_T("step")] = _T("step(a, x)|Returns (x >= a) ? 1 : 0. ");
- m_inst[_T("tan")] = _T("tan(x)|Returns the tangent of x. ");
- m_inst[_T("tanh")] = _T("tanh(x)|Returns the hyperbolic tangent of x. ");
- m_inst[_T("tex1d")] = _T("tex1D(s, t)|1-D texture lookup. s is a sampler or a sampler1D object. t is a scalar. ");
- m_inst[_T("tex1d(")] = _T("tex1D(s, t, ddx, ddy)|1-D texture lookup, with derivatives. s is a sampler or sampler1D object. t, ddx, and ddy are scalars. ");
- m_inst[_T("tex1dproj")] = _T("tex1Dproj(s, t)|1-D projective texture lookup. s is a sampler or sampler1D object. t is a 4-D vector. t is divided by its last component before the lookup takes place. ");
- m_inst[_T("tex1dbias")] = _T("tex1Dbias(s, t)|1-D biased texture lookup. s is a sampler or sampler1D object. t is a 4-D vector. The mip level is biased by t.w before the lookup takes place. ");
- m_inst[_T("tex2d")] = _T("tex2D(s, t)|2-D texture lookup. s is a sampler or a sampler2D object. t is a 2-D texture coordinate. ");
- m_inst[_T("tex2d(")] = _T("tex2D(s, t, ddx, ddy)|2-D texture lookup, with derivatives. s is a sampler or sampler2D object. t, ddx, and ddy are 2-D vectors. ");
- m_inst[_T("tex2dproj")] = _T("tex2Dproj(s, t)|2-D projective texture lookup. s is a sampler or sampler2D object. t is a 4-D vector. t is divided by its last component before the lookup takes place. ");
- m_inst[_T("tex2dbias")] = _T("tex2Dbias(s, t)|2-D biased texture lookup. s is a sampler or sampler2D object. t is a 4-D vector. The mip level is biased by t.w before the lookup takes place. ");
- m_inst[_T("tex3d")] = _T("tex3D(s, t)|3-D volume texture lookup. s is a sampler or a sampler3D object. t is a 3-D texture coordinate. ");
- m_inst[_T("tex3d(")] = _T("tex3D(s, t, ddx, ddy)|3-D volume texture lookup, with derivatives. s is a sampler or sampler3D object. t, ddx, and ddy are 3-D vectors. ");
- m_inst[_T("tex3dproj")] = _T("tex3Dproj(s, t)|3-D projective volume texture lookup. s is a sampler or sampler3D object. t is a 4-D vector. t is divided by its last component before the lookup takes place. ");
- m_inst[_T("tex3dbias")] = _T("tex3Dbias(s, t)|3-D biased texture lookup. s is a sampler or sampler3D object. t is a 4-D vector. The mip level is biased by t.w before the lookup takes place. ");
- m_inst[_T("texcube")] = _T("texCUBE(s, t)|3-D cube texture lookup. s is a sampler or a samplerCUBE object. t is a 3-D texture coordinate. ");
- m_inst[_T("texcube(")] = _T("texCUBE(s, t, ddx, ddy)|3-D cube texture lookup, with derivatives. s is a sampler or samplerCUBE object. t, ddx, and ddy are 3-D vectors. ");
- m_inst[_T("texcubeproj")] = _T("texCUBEproj(s, t)|3-D projective cube texture lookup. s is a sampler or samplerCUBE object. t is a 4-D vector. t is divided by its last component before the lookup takes place. ");
- m_inst[_T("texcubebias")] = _T("texCUBEbias(s, t)|3-D biased cube texture lookup. s is a sampler or samplerCUBE object. t is a 4-dimensional vector. The mip level is biased by t.w before the lookup takes place. ");
- m_inst[_T("transpose")] = _T("transpose(m)|Returns the transpose of the matrix m. If the source is dimension mrows x mcolumns, the result is dimension mcolumns x mrows. ");
+ m_text[0] = 0;
+
+ m_inst[_T("abs")] = _T("abs(value a)|Absolute value (per component). ");
+ m_inst[_T("acos")] = _T("acos(x)|Returns the arccosine of each component of x. Each component should be in the range [-1, 1]. ");
+ m_inst[_T("all")] = _T("all(x)|Test if all components of x are nonzero. ");
+ m_inst[_T("any")] = _T("any(x)|Test is any component of x is nonzero. ");
+ m_inst[_T("asin")] = _T("asin(x)|Returns the arcsine of each component of x. Each component should be in the range [-pi/2, pi/2]. ");
+ m_inst[_T("atan")] = _T("atan(x)|Returns the arctangent of x. The return values are in the range [-pi/2, pi/2]. ");
+ m_inst[_T("atan2")] = _T("atan2(y, x)|Returns the arctangent of y/x. The signs of y and x are used to determine the quadrant of the return values in the range [-pi, pi]. atan2 is well-defined for every point other than the origin, even if x equals 0 and y does not equal 0. ");
+ m_inst[_T("ceil")] = _T("ceil(x)|Returns the smallest integer which is greater than or equal to x. ");
+ m_inst[_T("clamp")] = _T("clamp(x, min, max)|Clamps x to the range [min, max]. ");
+ m_inst[_T("clip")] = _T("clip(x)|Discards the current pixel, if any component of x is less than zero. This can be used to simulate clip planes, if each component of x represents the distance from a plane. ");
+ m_inst[_T("cos")] = _T("cos(x)|Returns the cosine of x. ");
+ m_inst[_T("cosh")] = _T("cosh(x)|Returns the hyperbolic cosine of x. ");
+ m_inst[_T("cross")] = _T("cross(a, b)|Returns the cross product of two 3-D vectors a and b. ");
+ m_inst[_T("d3dcolortoubyte4")] = _T("D3DCOLORtoUBYTE4(x)|Swizzles and scales components of the 4-D vector x to compensate for the lack of UBYTE4 support in some hardware. ");
+ m_inst[_T("ddx")] = _T("ddx(x)|Returns the partial derivative of x with respect to the screen-space x-coordinate. ");
+ m_inst[_T("ddy")] = _T("ddy(x)|Returns the partial derivative of x with respect to the screen-space y-coordinate. ");
+ m_inst[_T("degrees")] = _T("degrees(x)|Converts x from radians to degrees. ");
+ m_inst[_T("determinant")] = _T("determinant(m)|Returns the determinant of the square matrix m. ");
+ m_inst[_T("distance")] = _T("distance(a, b)|Returns the distance between two points a and b. ");
+ m_inst[_T("dot")] = _T("dot(a, b)|Returns the dot product of two vectors a and b. ");
+ m_inst[_T("exp")] = _T("exp(x)|Returns the base-e exponent ex. ");
+ m_inst[_T("exp2")] = _T("exp2(value a)|Base 2 Exp (per component). ");
+ m_inst[_T("faceforward")] = _T("faceforward(n, i, ng)|Returns -n * sign(dot(i, ng)). ");
+ m_inst[_T("floor")] = _T("floor(x)|Returns the greatest integer which is less than or equal to x. ");
+ m_inst[_T("fmod")] = _T("fmod(a, b)|Returns the floating point remainder f of a / b such that a = i * b + f, where i is an integer, f has the same sign as x, and the absolute value of f is less than the absolute value of b. ");
+ m_inst[_T("frac")] = _T("frac(x)|Returns the fractional part f of x, such that f is a value greater than or equal to 0, and less than 1. ");
+ m_inst[_T("frc")] = _T("frc(value a)|Fractional part (per component). ");
+ m_inst[_T("frexp")] = _T("frexp(x, out exp)|Returns the mantissa and exponent of x. frexp returns the mantissa, and the exponent is stored in the output parameter exp. If x is 0, the function returns 0 for both the mantissa and the exponent. ");
+ m_inst[_T("fwidth")] = _T("fwidth(x)|Returns abs(ddx(x))+abs(ddy(x)). ");
+ m_inst[_T("isfinite")] = _T("isfinite(x)|Returns true if x is finite, false otherwise. ");
+ m_inst[_T("isinf")] = _T("isinf(x)|Returns true if x is +INF or -INF, false otherwise. ");
+ m_inst[_T("isnan")] = _T("isnan(x)|Returns true if x is NAN or QNAN, false otherwise. ");
+ m_inst[_T("ldexp")] = _T("ldexp(x, exp)|Returns x * 2exp. ");
+ m_inst[_T("len")] = _T("len(value a)|Vector length. ");
+ m_inst[_T("length")] = _T("length(v)|Returns the length of the vector v. ");
+ m_inst[_T("lerp")] = _T("lerp(a, b, s)|Returns a + s(b - a). This linearly interpolates between a and b, such that the return value is a when s is 0, and b when s is 1. ");
+ m_inst[_T("lit")] = _T("lit(ndotl, ndoth, m)|Returns a lighting vector (ambient, diffuse, specular, 1): ambient = 1; diffuse = (ndotl < 0) ? 0 : ndotl; specular = (ndotl < 0) || (ndoth < 0) ? 0 : (ndoth * m); ");
+ m_inst[_T("log")] = _T("log(x)|Returns the base-e logarithm of x. If x is negative, the function returns indefinite. If x is 0, the function returns +INF. ");
+ m_inst[_T("log10")] = _T("log10(x)|Returns the base-10 logarithm of x. If x is negative, the function returns indefinite. If x is 0, the function returns +INF. ");
+ m_inst[_T("log2")] = _T("log2(x)|Returns the base-2 logarithm of x. If x is negative, the function returns indefinite. If x is 0, the function returns +INF. ");
+ m_inst[_T("max")] = _T("max(a, b)|Selects the greater of a and b. ");
+ m_inst[_T("min")] = _T("min(a, b)|Selects the lesser of a and b. ");
+ m_inst[_T("modf")] = _T("modf(x, out ip)|Splits the value x into fractional and integer parts, each of which has the same sign and x. The signed fractional portion of x is returned. The integer portion is stored in the output parameter ip. ");
+ m_inst[_T("mul")] = _T("mul(a, b)|Performs matrix multiplication between a and b. If a is a vector, it treated as a row vector. If b is a vector, it is treated as a column vector. The inner dimension acolumns and brows must be equal. The result has the dimension arows x bcolumns. ");
+ m_inst[_T("noise")] = _T("noise(x)|Not yet implemented. ");
+ m_inst[_T("normalize")] = _T("normalize(v)|Returns the normalized vector v / length(v). If the length of v is 0, the result is indefinite. ");
+ m_inst[_T("pow")] = _T("pow(x, y)|Returns xy. ");
+ m_inst[_T("radians")] = _T("radians(x)|Converts x from degrees to radians. ");
+ m_inst[_T("reflect")] = _T("reflect(i, n)|Returns the reflection vector v, given the entering ray direction i, and the surface normal n. Such that v = i - 2 * dot(i, n) * n ");
+ m_inst[_T("refract")] = _T("refract(i, n, eta)|Returns the refraction vector v, given the entering ray direction i, the surface normal n, and the relative index of refraction eta. If the angle between i and n is too great for a given eta, refract returns (0,0,0). ");
+ m_inst[_T("round")] = _T("round(x)|Rounds x to the nearest integer. ");
+ m_inst[_T("rsqrt")] = _T("rsqrt(x)|Returns 1 / sqrt(x). ");
+ m_inst[_T("saturate")] = _T("saturate(x)|Clamps x to the range [0, 1]. ");
+ m_inst[_T("sign")] = _T("sign(x)|Computes the sign of x. Returns -1 if x is less than 0, 0 if x equals 0, and 1 if x is greater than zero. ");
+ m_inst[_T("sin")] = _T("sin(x)|Returns the sine of x. ");
+ m_inst[_T("sincos")] = _T("sincos(x, out s, out c)|Returns the sine and cosine of x. sin(x) is stored in the output parameter s. cos(x) is stored in the output parameter c. ");
+ m_inst[_T("sinh")] = _T("sinh(x)|Returns the hyperbolic sine of x. ");
+ m_inst[_T("smoothstep")] = _T("smoothstep(min, max, x)|Returns 0 if x < min. Returns 1 if x > max. Returns a smooth Hermite interpolation between 0 and 1, if x is in the range [min, max]. ");
+ m_inst[_T("sqrt")] = _T("sqrt(value a)|Square root (per component). ");
+ m_inst[_T("step")] = _T("step(a, x)|Returns (x >= a) ? 1 : 0. ");
+ m_inst[_T("tan")] = _T("tan(x)|Returns the tangent of x. ");
+ m_inst[_T("tanh")] = _T("tanh(x)|Returns the hyperbolic tangent of x. ");
+ m_inst[_T("tex1d")] = _T("tex1D(s, t)|1-D texture lookup. s is a sampler or a sampler1D object. t is a scalar. ");
+ m_inst[_T("tex1d(")] = _T("tex1D(s, t, ddx, ddy)|1-D texture lookup, with derivatives. s is a sampler or sampler1D object. t, ddx, and ddy are scalars. ");
+ m_inst[_T("tex1dproj")] = _T("tex1Dproj(s, t)|1-D projective texture lookup. s is a sampler or sampler1D object. t is a 4-D vector. t is divided by its last component before the lookup takes place. ");
+ m_inst[_T("tex1dbias")] = _T("tex1Dbias(s, t)|1-D biased texture lookup. s is a sampler or sampler1D object. t is a 4-D vector. The mip level is biased by t.w before the lookup takes place. ");
+ m_inst[_T("tex2d")] = _T("tex2D(s, t)|2-D texture lookup. s is a sampler or a sampler2D object. t is a 2-D texture coordinate. ");
+ m_inst[_T("tex2d(")] = _T("tex2D(s, t, ddx, ddy)|2-D texture lookup, with derivatives. s is a sampler or sampler2D object. t, ddx, and ddy are 2-D vectors. ");
+ m_inst[_T("tex2dproj")] = _T("tex2Dproj(s, t)|2-D projective texture lookup. s is a sampler or sampler2D object. t is a 4-D vector. t is divided by its last component before the lookup takes place. ");
+ m_inst[_T("tex2dbias")] = _T("tex2Dbias(s, t)|2-D biased texture lookup. s is a sampler or sampler2D object. t is a 4-D vector. The mip level is biased by t.w before the lookup takes place. ");
+ m_inst[_T("tex3d")] = _T("tex3D(s, t)|3-D volume texture lookup. s is a sampler or a sampler3D object. t is a 3-D texture coordinate. ");
+ m_inst[_T("tex3d(")] = _T("tex3D(s, t, ddx, ddy)|3-D volume texture lookup, with derivatives. s is a sampler or sampler3D object. t, ddx, and ddy are 3-D vectors. ");
+ m_inst[_T("tex3dproj")] = _T("tex3Dproj(s, t)|3-D projective volume texture lookup. s is a sampler or sampler3D object. t is a 4-D vector. t is divided by its last component before the lookup takes place. ");
+ m_inst[_T("tex3dbias")] = _T("tex3Dbias(s, t)|3-D biased texture lookup. s is a sampler or sampler3D object. t is a 4-D vector. The mip level is biased by t.w before the lookup takes place. ");
+ m_inst[_T("texcube")] = _T("texCUBE(s, t)|3-D cube texture lookup. s is a sampler or a samplerCUBE object. t is a 3-D texture coordinate. ");
+ m_inst[_T("texcube(")] = _T("texCUBE(s, t, ddx, ddy)|3-D cube texture lookup, with derivatives. s is a sampler or samplerCUBE object. t, ddx, and ddy are 3-D vectors. ");
+ m_inst[_T("texcubeproj")] = _T("texCUBEproj(s, t)|3-D projective cube texture lookup. s is a sampler or samplerCUBE object. t is a 4-D vector. t is divided by its last component before the lookup takes place. ");
+ m_inst[_T("texcubebias")] = _T("texCUBEbias(s, t)|3-D biased cube texture lookup. s is a sampler or samplerCUBE object. t is a 4-dimensional vector. The mip level is biased by t.w before the lookup takes place. ");
+ m_inst[_T("transpose")] = _T("transpose(m)|Returns the transpose of the matrix m. If the source is dimension mrows x mcolumns, the result is dimension mcolumns x mrows. ");
}
CShaderAutoCompleteDlg::~CShaderAutoCompleteDlg()
@@ -120,15 +120,15 @@ CShaderAutoCompleteDlg::~CShaderAutoCompleteDlg()
void CShaderAutoCompleteDlg::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_LIST1, m_list);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_LIST1, m_list);
}
BEGIN_MESSAGE_MAP(CShaderAutoCompleteDlg, CResizableDialog)
- ON_WM_SETFOCUS()
- ON_LBN_SELCHANGE(IDC_LIST1, OnLbnSelchangeList1)
- ON_WM_SHOWWINDOW()
+ ON_WM_SETFOCUS()
+ ON_LBN_SELCHANGE(IDC_LIST1, OnLbnSelchangeList1)
+ ON_WM_SHOWWINDOW()
END_MESSAGE_MAP()
@@ -136,66 +136,66 @@ END_MESSAGE_MAP()
BOOL CShaderAutoCompleteDlg::OnInitDialog()
{
- CResizableDialog::OnInitDialog();
+ CResizableDialog::OnInitDialog();
- AddAnchor(IDC_LIST1, TOP_LEFT, BOTTOM_RIGHT);
+ AddAnchor(IDC_LIST1, TOP_LEFT, BOTTOM_RIGHT);
- m_hToolTipWnd = CreateWindowEx(
- WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, TTS_NOPREFIX | TTS_ALWAYSTIP,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
- NULL, NULL, NULL, NULL);
+ m_hToolTipWnd = CreateWindowEx(
+ WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, TTS_NOPREFIX | TTS_ALWAYSTIP,
+ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
+ NULL, NULL, NULL, NULL);
- memset(&m_ti, 0, sizeof(m_ti));
- m_ti.cbSize = sizeof(TOOLINFO);
- m_ti.uFlags = TTF_ABSOLUTE|TTF_TRACK;
- m_ti.hwnd = m_hWnd;
- m_ti.lpszText = m_text;
+ memset(&m_ti, 0, sizeof(m_ti));
+ m_ti.cbSize = sizeof(TOOLINFO);
+ m_ti.uFlags = TTF_ABSOLUTE | TTF_TRACK;
+ m_ti.hwnd = m_hWnd;
+ m_ti.lpszText = m_text;
- ::SendMessage(m_hToolTipWnd, TTM_ADDTOOL, 0, (LPARAM)&m_ti);
- ::SendMessage(m_hToolTipWnd, TTM_SETMAXTIPWIDTH, 0, (LPARAM)400);
+ ::SendMessage(m_hToolTipWnd, TTM_ADDTOOL, 0, (LPARAM)&m_ti);
+ ::SendMessage(m_hToolTipWnd, TTM_SETMAXTIPWIDTH, 0, (LPARAM)400);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CShaderAutoCompleteDlg::OnSetFocus(CWnd* pOldWnd)
{
- __super::OnSetFocus(pOldWnd);
+ __super::OnSetFocus(pOldWnd);
- GetParent()->SetFocus();
+ GetParent()->SetFocus();
}
void CShaderAutoCompleteDlg::OnLbnSelchangeList1()
{
- ::SendMessage(m_hToolTipWnd, TTM_TRACKACTIVATE, FALSE, (LPARAM)&m_ti);
-
- int i = m_list.GetCurSel();
- if (i < 0) {
- return;
- }
-
- if (POSITION pos = (POSITION)m_list.GetItemData(i)) {
- CString str, desc;
- m_inst.GetNextAssoc(pos, str, desc);
- CAtlList<CString> sl;
- Explode(desc, sl, '|', 2);
- if (sl.GetCount() != 2) {
- return;
- }
- _tcscpy_s(m_ti.lpszText, _countof(m_text), sl.RemoveTail());
- CRect r;
- GetWindowRect(r);
- ::SendMessage(m_hToolTipWnd, TTM_UPDATETIPTEXT, 0, (LPARAM)&m_ti);
- ::SendMessage(m_hToolTipWnd, TTM_TRACKPOSITION, 0, (LPARAM)MAKELONG(r.left, r.bottom+1));
- ::SendMessage(m_hToolTipWnd, TTM_TRACKACTIVATE, TRUE, (LPARAM)&m_ti);
- }
+ ::SendMessage(m_hToolTipWnd, TTM_TRACKACTIVATE, FALSE, (LPARAM)&m_ti);
+
+ int i = m_list.GetCurSel();
+ if (i < 0) {
+ return;
+ }
+
+ if (POSITION pos = (POSITION)m_list.GetItemData(i)) {
+ CString str, desc;
+ m_inst.GetNextAssoc(pos, str, desc);
+ CAtlList<CString> sl;
+ Explode(desc, sl, '|', 2);
+ if (sl.GetCount() != 2) {
+ return;
+ }
+ _tcscpy_s(m_ti.lpszText, _countof(m_text), sl.RemoveTail());
+ CRect r;
+ GetWindowRect(r);
+ ::SendMessage(m_hToolTipWnd, TTM_UPDATETIPTEXT, 0, (LPARAM)&m_ti);
+ ::SendMessage(m_hToolTipWnd, TTM_TRACKPOSITION, 0, (LPARAM)MAKELONG(r.left, r.bottom + 1));
+ ::SendMessage(m_hToolTipWnd, TTM_TRACKACTIVATE, TRUE, (LPARAM)&m_ti);
+ }
}
void CShaderAutoCompleteDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
- CResizableDialog::OnShowWindow(bShow, nStatus);
+ CResizableDialog::OnShowWindow(bShow, nStatus);
- if (!bShow) {
- ::SendMessage(m_hToolTipWnd, TTM_TRACKACTIVATE, FALSE, (LPARAM)&m_ti);
- }
+ if (!bShow) {
+ ::SendMessage(m_hToolTipWnd, TTM_TRACKACTIVATE, FALSE, (LPARAM)&m_ti);
+ }
}
diff --git a/src/mpc-hc/ShaderAutoCompleteDlg.h b/src/mpc-hc/ShaderAutoCompleteDlg.h
index 0e485028c..a90b66bc2 100644
--- a/src/mpc-hc/ShaderAutoCompleteDlg.h
+++ b/src/mpc-hc/ShaderAutoCompleteDlg.h
@@ -31,28 +31,28 @@
class CShaderAutoCompleteDlg : public CResizableDialog
{
- TOOLINFO m_ti;
- HWND m_hToolTipWnd;
- TCHAR m_text[1024];
+ TOOLINFO m_ti;
+ HWND m_hToolTipWnd;
+ TCHAR m_text[1024];
public:
- CShaderAutoCompleteDlg(CWnd* pParent = NULL); // standard constructor
- virtual ~CShaderAutoCompleteDlg();
+ CShaderAutoCompleteDlg(CWnd* pParent = NULL); // standard constructor
+ virtual ~CShaderAutoCompleteDlg();
- CMap<CString, LPCTSTR, CString, CString> m_inst;
+ CMap<CString, LPCTSTR, CString, CString> m_inst;
- // Dialog Data
- enum { IDD = IDD_SHADERAUTOCOMPLETE_DLG };
+ // Dialog Data
+ enum { IDD = IDD_SHADERAUTOCOMPLETE_DLG };
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- CListBox m_list;
- virtual BOOL OnInitDialog();
- afx_msg void OnSetFocus(CWnd* pOldWnd);
- afx_msg void OnLbnSelchangeList1();
- afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
+ CListBox m_list;
+ virtual BOOL OnInitDialog();
+ afx_msg void OnSetFocus(CWnd* pOldWnd);
+ afx_msg void OnLbnSelchangeList1();
+ afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
};
diff --git a/src/mpc-hc/ShaderCombineDlg.cpp b/src/mpc-hc/ShaderCombineDlg.cpp
index e89e9d2b6..c98a9a33d 100644
--- a/src/mpc-hc/ShaderCombineDlg.cpp
+++ b/src/mpc-hc/ShaderCombineDlg.cpp
@@ -29,11 +29,11 @@
// CShaderCombineDlg dialog
CShaderCombineDlg::CShaderCombineDlg(CAtlList<CString>& labels1, CAtlList<CString>& labels2, CWnd* pParent)
- : CCmdUIDialog(CShaderCombineDlg::IDD, pParent)
- , m_fcheck1(FALSE)
- , m_fcheck2(FALSE)
- , m_labels1(labels1)
- , m_labels2(labels2)
+ : CCmdUIDialog(CShaderCombineDlg::IDD, pParent)
+ , m_fcheck1(FALSE)
+ , m_fcheck2(FALSE)
+ , m_labels1(labels1)
+ , m_labels2(labels2)
{
}
@@ -43,258 +43,258 @@ CShaderCombineDlg::~CShaderCombineDlg()
void CShaderCombineDlg::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Check(pDX, IDC_CHECK1, m_fcheck1);
- DDX_Control(pDX, IDC_LIST1, m_list1);
+ __super::DoDataExchange(pDX);
+ DDX_Check(pDX, IDC_CHECK1, m_fcheck1);
+ DDX_Control(pDX, IDC_LIST1, m_list1);
- DDX_Check(pDX, IDC_CHECK2, m_fcheck2);
- DDX_Control(pDX, IDC_LIST2, m_list2);
+ DDX_Check(pDX, IDC_CHECK2, m_fcheck2);
+ DDX_Control(pDX, IDC_LIST2, m_list2);
- DDX_Control(pDX, IDC_COMBO1, m_combo);
+ DDX_Control(pDX, IDC_COMBO1, m_combo);
}
BEGIN_MESSAGE_MAP(CShaderCombineDlg, CCmdUIDialog)
- ON_BN_CLICKED(IDC_CHECK1, OnUpdateCheck1)
- ON_LBN_SETFOCUS(IDC_LIST1, OnSetFocusList1)
+ ON_BN_CLICKED(IDC_CHECK1, OnUpdateCheck1)
+ ON_LBN_SETFOCUS(IDC_LIST1, OnSetFocusList1)
- ON_BN_CLICKED(IDC_CHECK2, OnUpdateCheck2)
- ON_LBN_SETFOCUS(IDC_LIST2, OnSetFocusList2)
+ ON_BN_CLICKED(IDC_CHECK2, OnUpdateCheck2)
+ ON_LBN_SETFOCUS(IDC_LIST2, OnSetFocusList2)
- ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedAdd)
- ON_BN_CLICKED(IDC_BUTTON3, OnBnClickedDel)
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedUp)
- ON_BN_CLICKED(IDC_BUTTON4, OnBnClickedDown)
+ ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedAdd)
+ ON_BN_CLICKED(IDC_BUTTON3, OnBnClickedDel)
+ ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedUp)
+ ON_BN_CLICKED(IDC_BUTTON4, OnBnClickedDown)
END_MESSAGE_MAP()
// CShaderCombineDlg message handlers
BOOL CShaderCombineDlg::OnInitDialog()
{
- __super::OnInitDialog();
+ __super::OnInitDialog();
- //AddAnchor(IDOK, TOP_RIGHT);
- //AddAnchor(IDCANCEL, TOP_RIGHT);
+ //AddAnchor(IDOK, TOP_RIGHT);
+ //AddAnchor(IDCANCEL, TOP_RIGHT);
- AppSettings& s = AfxGetAppSettings();
+ AppSettings& s = AfxGetAppSettings();
- // remember the initial state
- m_fcheck1 = m_oldcheck1 = ((CMainFrame*)AfxGetMainWnd())->m_bToggleShader;
- m_fcheck2 = m_oldcheck2 = ((CMainFrame*)AfxGetMainWnd())->m_bToggleShaderScreenSpace;
- m_oldlabels1.AddTailList(&m_labels1);
- m_oldlabels2.AddTailList(&m_labels2);
+ // remember the initial state
+ m_fcheck1 = m_oldcheck1 = ((CMainFrame*)AfxGetMainWnd())->m_bToggleShader;
+ m_fcheck2 = m_oldcheck2 = ((CMainFrame*)AfxGetMainWnd())->m_bToggleShaderScreenSpace;
+ m_oldlabels1.AddTailList(&m_labels1);
+ m_oldlabels2.AddTailList(&m_labels2);
- POSITION pos;
+ POSITION pos;
- pos = m_labels1.GetHeadPosition();
- while (pos) {
- m_list1.AddString(m_labels1.GetNext(pos));
- }
- m_list1.AddString(_T(""));
+ pos = m_labels1.GetHeadPosition();
+ while (pos) {
+ m_list1.AddString(m_labels1.GetNext(pos));
+ }
+ m_list1.AddString(_T(""));
- pos = m_labels2.GetHeadPosition();
- while (pos) {
- m_list2.AddString(m_labels2.GetNext(pos));
- }
- m_list2.AddString(_T(""));
+ pos = m_labels2.GetHeadPosition();
+ while (pos) {
+ m_list2.AddString(m_labels2.GetNext(pos));
+ }
+ m_list2.AddString(_T(""));
- pos = s.m_shaders.GetHeadPosition();
- CString str;
- while (pos) {
- str = s.m_shaders.GetNext(pos).label;
- m_combo.AddString(str);
- }
+ pos = s.m_shaders.GetHeadPosition();
+ CString str;
+ while (pos) {
+ str = s.m_shaders.GetNext(pos).label;
+ m_combo.AddString(str);
+ }
- if (m_combo.GetCount()) {
- m_combo.SetCurSel(0);
- CorrectComboListWidth(m_combo);
- }
+ if (m_combo.GetCount()) {
+ m_combo.SetCurSel(0);
+ CorrectComboListWidth(m_combo);
+ }
- UpdateData(FALSE);
+ UpdateData(FALSE);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void CShaderCombineDlg::OnOK()
{
- __super::OnOK();
+ __super::OnOK();
}
void CShaderCombineDlg::OnCancel()
{
- m_labels1.RemoveAll();
- m_labels1.AddTailList(&m_oldlabels1);
- ((CMainFrame*)AfxGetMainWnd())->EnableShaders1(m_oldcheck1);
+ m_labels1.RemoveAll();
+ m_labels1.AddTailList(&m_oldlabels1);
+ ((CMainFrame*)AfxGetMainWnd())->EnableShaders1(m_oldcheck1);
- m_labels2.RemoveAll();
- m_labels2.AddTailList(&m_oldlabels2);
- ((CMainFrame*)AfxGetMainWnd())->EnableShaders2(m_oldcheck2);
+ m_labels2.RemoveAll();
+ m_labels2.AddTailList(&m_oldlabels2);
+ ((CMainFrame*)AfxGetMainWnd())->EnableShaders2(m_oldcheck2);
- __super::OnCancel();
+ __super::OnCancel();
}
void CShaderCombineDlg::OnUpdateCheck1()
{
- UpdateData();
+ UpdateData();
- ((CMainFrame*)AfxGetMainWnd())->EnableShaders1(!!m_fcheck1);
+ ((CMainFrame*)AfxGetMainWnd())->EnableShaders1(!!m_fcheck1);
}
void CShaderCombineDlg::OnUpdateCheck2()
{
- UpdateData();
+ UpdateData();
- ((CMainFrame*)AfxGetMainWnd())->EnableShaders2(!!m_fcheck2);
+ ((CMainFrame*)AfxGetMainWnd())->EnableShaders2(!!m_fcheck2);
}
void CShaderCombineDlg::OnSetFocusList1()
{
- m_list2.SetCurSel(-1);
- if (m_list1.GetCurSel() < 0) {
- m_list1.SetCurSel(m_list1.GetCount()-1);
- }
+ m_list2.SetCurSel(-1);
+ if (m_list1.GetCurSel() < 0) {
+ m_list1.SetCurSel(m_list1.GetCount() - 1);
+ }
}
void CShaderCombineDlg::OnSetFocusList2()
{
- m_list1.SetCurSel(-1);
- if (m_list2.GetCurSel() < 0) {
- m_list2.SetCurSel(m_list2.GetCount()-1);
- }
+ m_list1.SetCurSel(-1);
+ if (m_list2.GetCurSel() < 0) {
+ m_list2.SetCurSel(m_list2.GetCount() - 1);
+ }
}
void CShaderCombineDlg::OnBnClickedAdd()
{
- int i = m_combo.GetCurSel();
- if (i < 0) {
- return;
- }
- CString label;
- m_combo.GetLBText(i, label);
-
- i = m_list1.GetCurSel();
- if (i >= 0) {
- m_list1.InsertString(i, label);
- UpdateShaders(SHADER1);
- return;
- }
-
- i = m_list2.GetCurSel();
- if (i >= 0) {
- m_list2.InsertString(i, label);
- UpdateShaders(SHADER2);
- //return;
- }
+ int i = m_combo.GetCurSel();
+ if (i < 0) {
+ return;
+ }
+ CString label;
+ m_combo.GetLBText(i, label);
+
+ i = m_list1.GetCurSel();
+ if (i >= 0) {
+ m_list1.InsertString(i, label);
+ UpdateShaders(SHADER1);
+ return;
+ }
+
+ i = m_list2.GetCurSel();
+ if (i >= 0) {
+ m_list2.InsertString(i, label);
+ UpdateShaders(SHADER2);
+ //return;
+ }
}
void CShaderCombineDlg::OnBnClickedDel()
{
- int i = m_list1.GetCurSel();
- if (i >= 0 && i < m_list1.GetCount()-1) {
- m_list1.DeleteString(i);
- if (i == m_list1.GetCount()-1 && i > 0) {
- i--;
- }
- m_list1.SetCurSel(i);
-
- UpdateShaders(SHADER1);
- return;
- }
-
- i = m_list2.GetCurSel();
- if (i >= 0 && i < m_list2.GetCount()-1) {
- m_list2.DeleteString(i);
- if (i == m_list2.GetCount()-1 && i > 0) {
- i--;
- }
- m_list2.SetCurSel(i);
-
- UpdateShaders(SHADER2);
- //return;
- }
+ int i = m_list1.GetCurSel();
+ if (i >= 0 && i < m_list1.GetCount() - 1) {
+ m_list1.DeleteString(i);
+ if (i == m_list1.GetCount() - 1 && i > 0) {
+ i--;
+ }
+ m_list1.SetCurSel(i);
+
+ UpdateShaders(SHADER1);
+ return;
+ }
+
+ i = m_list2.GetCurSel();
+ if (i >= 0 && i < m_list2.GetCount() - 1) {
+ m_list2.DeleteString(i);
+ if (i == m_list2.GetCount() - 1 && i > 0) {
+ i--;
+ }
+ m_list2.SetCurSel(i);
+
+ UpdateShaders(SHADER2);
+ //return;
+ }
}
void CShaderCombineDlg::OnBnClickedUp()
{
- int i = m_list1.GetCurSel();
- if (i >= 1 && i < m_list1.GetCount()-1) {
- CString label;
- m_list1.GetText(i, label);
- m_list1.DeleteString(i);
- i--;
- m_list1.InsertString(i, label);
- m_list1.SetCurSel(i);
-
- UpdateShaders(SHADER1);
- return;
- }
-
- i = m_list2.GetCurSel();
- if (i >= 1 && i < m_list2.GetCount()-1) {
- CString label;
- m_list2.GetText(i, label);
- m_list2.DeleteString(i);
- i--;
- m_list2.InsertString(i, label);
- m_list2.SetCurSel(i);
-
- UpdateShaders(SHADER2);
- //return;
- }
+ int i = m_list1.GetCurSel();
+ if (i >= 1 && i < m_list1.GetCount() - 1) {
+ CString label;
+ m_list1.GetText(i, label);
+ m_list1.DeleteString(i);
+ i--;
+ m_list1.InsertString(i, label);
+ m_list1.SetCurSel(i);
+
+ UpdateShaders(SHADER1);
+ return;
+ }
+
+ i = m_list2.GetCurSel();
+ if (i >= 1 && i < m_list2.GetCount() - 1) {
+ CString label;
+ m_list2.GetText(i, label);
+ m_list2.DeleteString(i);
+ i--;
+ m_list2.InsertString(i, label);
+ m_list2.SetCurSel(i);
+
+ UpdateShaders(SHADER2);
+ //return;
+ }
}
void CShaderCombineDlg::OnBnClickedDown()
{
- int i = m_list1.GetCurSel();
- if (i >= 0 && i < m_list1.GetCount()-2) {
- CString label;
- m_list1.GetText(i, label);
- m_list1.DeleteString(i);
- i++;
- m_list1.InsertString(i, label);
- m_list1.SetCurSel(i);
-
- UpdateShaders(SHADER1);
- return;
- }
-
- i = m_list2.GetCurSel();
- if (i >= 0 && i < m_list2.GetCount()-2) {
- CString label;
- m_list2.GetText(i, label);
- m_list2.DeleteString(i);
- i++;
- m_list2.InsertString(i, label);
- m_list2.SetCurSel(i);
-
- UpdateShaders(SHADER2);
- //return;
- }
+ int i = m_list1.GetCurSel();
+ if (i >= 0 && i < m_list1.GetCount() - 2) {
+ CString label;
+ m_list1.GetText(i, label);
+ m_list1.DeleteString(i);
+ i++;
+ m_list1.InsertString(i, label);
+ m_list1.SetCurSel(i);
+
+ UpdateShaders(SHADER1);
+ return;
+ }
+
+ i = m_list2.GetCurSel();
+ if (i >= 0 && i < m_list2.GetCount() - 2) {
+ CString label;
+ m_list2.GetText(i, label);
+ m_list2.DeleteString(i);
+ i++;
+ m_list2.InsertString(i, label);
+ m_list2.SetCurSel(i);
+
+ UpdateShaders(SHADER2);
+ //return;
+ }
}
// Update shaders
void CShaderCombineDlg::UpdateShaders(unsigned char type)
{
- if (type & SHADER1) {
- m_labels1.RemoveAll();
- for (int i = 0, j = m_list1.GetCount()-1; i < j; i++) {
- CString label;
- m_list1.GetText(i, label);
- m_labels1.AddTail(label);
- }
-
- ((CMainFrame*)AfxGetMainWnd())->EnableShaders1(!!m_fcheck1);
- }
-
- if (type & SHADER2) {
- m_labels2.RemoveAll();
- for (int m = 0, n = m_list2.GetCount()-1; m < n; m++) {
- CString label;
- m_list2.GetText(m, label);
- m_labels2.AddTail(label);
- }
-
- ((CMainFrame*)AfxGetMainWnd())->EnableShaders2(!!m_fcheck2);
- }
+ if (type & SHADER1) {
+ m_labels1.RemoveAll();
+ for (int i = 0, j = m_list1.GetCount() - 1; i < j; i++) {
+ CString label;
+ m_list1.GetText(i, label);
+ m_labels1.AddTail(label);
+ }
+
+ ((CMainFrame*)AfxGetMainWnd())->EnableShaders1(!!m_fcheck1);
+ }
+
+ if (type & SHADER2) {
+ m_labels2.RemoveAll();
+ for (int m = 0, n = m_list2.GetCount() - 1; m < n; m++) {
+ CString label;
+ m_list2.GetText(m, label);
+ m_labels2.AddTail(label);
+ }
+
+ ((CMainFrame*)AfxGetMainWnd())->EnableShaders2(!!m_fcheck2);
+ }
}
diff --git a/src/mpc-hc/ShaderCombineDlg.h b/src/mpc-hc/ShaderCombineDlg.h
index e842af076..b11b695f9 100644
--- a/src/mpc-hc/ShaderCombineDlg.h
+++ b/src/mpc-hc/ShaderCombineDlg.h
@@ -35,44 +35,44 @@ class CShaderCombineDlg : public CCmdUIDialog
#define SHADER2 2
#define SHADERS (SHADER1 | SHADER2)
- CListBox m_list1, m_list2;
- CComboBox m_combo;
+ CListBox m_list1, m_list2;
+ CComboBox m_combo;
- BOOL m_fcheck1, m_fcheck2;
- CAtlList<CString>& m_labels1;
- CAtlList<CString>& m_labels2;
+ BOOL m_fcheck1, m_fcheck2;
+ CAtlList<CString>& m_labels1;
+ CAtlList<CString>& m_labels2;
- bool m_oldcheck1, m_oldcheck2;
- CAtlList<CString> m_oldlabels1;
- CAtlList<CString> m_oldlabels2;
+ bool m_oldcheck1, m_oldcheck2;
+ CAtlList<CString> m_oldlabels1;
+ CAtlList<CString> m_oldlabels2;
- void UpdateShaders(unsigned char type = SHADERS);
+ void UpdateShaders(unsigned char type = SHADERS);
public:
- CShaderCombineDlg(CAtlList<CString>& labels1, CAtlList<CString>& labels2, CWnd* pParent); // standard constructor
- virtual ~CShaderCombineDlg();
+ CShaderCombineDlg(CAtlList<CString>& labels1, CAtlList<CString>& labels2, CWnd* pParent); // standard constructor
+ virtual ~CShaderCombineDlg();
- // Dialog Data
- enum { IDD = IDD_SHADERCOMBINE_DLG };
+ // Dialog Data
+ enum { IDD = IDD_SHADERCOMBINE_DLG };
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL OnInitDialog();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL OnInitDialog();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
protected:
- virtual void OnOK();
- virtual void OnCancel();
+ virtual void OnOK();
+ virtual void OnCancel();
public:
- afx_msg void OnUpdateCheck1();
- afx_msg void OnSetFocusList1();
- afx_msg void OnUpdateCheck2();
- afx_msg void OnSetFocusList2();
-
- afx_msg void OnBnClickedAdd();
- afx_msg void OnBnClickedDel();
- afx_msg void OnBnClickedUp();
- afx_msg void OnBnClickedDown();
+ afx_msg void OnUpdateCheck1();
+ afx_msg void OnSetFocusList1();
+ afx_msg void OnUpdateCheck2();
+ afx_msg void OnSetFocusList2();
+
+ afx_msg void OnBnClickedAdd();
+ afx_msg void OnBnClickedDel();
+ afx_msg void OnBnClickedUp();
+ afx_msg void OnBnClickedDown();
}; \ No newline at end of file
diff --git a/src/mpc-hc/ShaderEditorDlg.cpp b/src/mpc-hc/ShaderEditorDlg.cpp
index e0204571b..ae1a741c1 100644
--- a/src/mpc-hc/ShaderEditorDlg.cpp
+++ b/src/mpc-hc/ShaderEditorDlg.cpp
@@ -33,459 +33,459 @@
// CShaderLabelComboBox
BEGIN_MESSAGE_MAP(CShaderLabelComboBox, CComboBox)
- ON_WM_CTLCOLOR()
- ON_WM_DESTROY()
+ ON_WM_CTLCOLOR()
+ ON_WM_DESTROY()
END_MESSAGE_MAP()
HBRUSH CShaderLabelComboBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
- if (nCtlColor == CTLCOLOR_EDIT) {
- if (m_edit.GetSafeHwnd() == NULL) {
- m_edit.SubclassWindow(pWnd->GetSafeHwnd());
- }
- }
+ if (nCtlColor == CTLCOLOR_EDIT) {
+ if (m_edit.GetSafeHwnd() == NULL) {
+ m_edit.SubclassWindow(pWnd->GetSafeHwnd());
+ }
+ }
- return __super::OnCtlColor(pDC, pWnd, nCtlColor);
+ return __super::OnCtlColor(pDC, pWnd, nCtlColor);
}
void CShaderLabelComboBox::OnDestroy()
{
- if (m_edit.GetSafeHwnd() != NULL) {
- m_edit.UnsubclassWindow();
- }
+ if (m_edit.GetSafeHwnd() != NULL) {
+ m_edit.UnsubclassWindow();
+ }
- __super::OnDestroy();
+ __super::OnDestroy();
}
// CShaderEdit
CShaderEdit::CShaderEdit()
{
- m_acdlg.Create(CShaderAutoCompleteDlg::IDD, NULL);
+ m_acdlg.Create(CShaderAutoCompleteDlg::IDD, NULL);
- m_nEndChar = -1;
- m_nIDEvent = (UINT_PTR)-1;
+ m_nEndChar = -1;
+ m_nIDEvent = (UINT_PTR) - 1;
}
CShaderEdit::~CShaderEdit()
{
- m_acdlg.DestroyWindow();
+ m_acdlg.DestroyWindow();
}
BOOL CShaderEdit::PreTranslateMessage(MSG* pMsg)
{
- if (m_acdlg.IsWindowVisible()
- && pMsg->message == WM_KEYDOWN
- && (pMsg->wParam == VK_UP || pMsg->wParam == VK_DOWN
- || pMsg->wParam == VK_PRIOR || pMsg->wParam == VK_NEXT
- || pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE)) {
- int i = m_acdlg.m_list.GetCurSel();
-
- if (pMsg->wParam == VK_RETURN && i >= 0) {
- CString str;
- m_acdlg.m_list.GetText(i, str);
- i = str.Find('(')+1;
- if (i > 0) {
- str = str.Left(i);
- }
-
- int nStartChar = 0, nEndChar = -1;
- GetSel(nStartChar, nEndChar);
-
- CString text;
- GetWindowText(text);
- while (nStartChar > 0 && _istalnum(text.GetAt(nStartChar-1))) {
- nStartChar--;
- }
-
- SetSel(nStartChar, nEndChar);
- ReplaceSel(str, TRUE);
- } else if (pMsg->wParam == VK_ESCAPE) {
- m_acdlg.ShowWindow(SW_HIDE);
- return GetParent()->PreTranslateMessage(pMsg);
- } else {
- m_acdlg.m_list.SendMessage(pMsg->message, pMsg->wParam, pMsg->lParam);
- }
-
- return TRUE;
- }
-
- return __super::PreTranslateMessage(pMsg);
+ if (m_acdlg.IsWindowVisible()
+ && pMsg->message == WM_KEYDOWN
+ && (pMsg->wParam == VK_UP || pMsg->wParam == VK_DOWN
+ || pMsg->wParam == VK_PRIOR || pMsg->wParam == VK_NEXT
+ || pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE)) {
+ int i = m_acdlg.m_list.GetCurSel();
+
+ if (pMsg->wParam == VK_RETURN && i >= 0) {
+ CString str;
+ m_acdlg.m_list.GetText(i, str);
+ i = str.Find('(') + 1;
+ if (i > 0) {
+ str = str.Left(i);
+ }
+
+ int nStartChar = 0, nEndChar = -1;
+ GetSel(nStartChar, nEndChar);
+
+ CString text;
+ GetWindowText(text);
+ while (nStartChar > 0 && _istalnum(text.GetAt(nStartChar - 1))) {
+ nStartChar--;
+ }
+
+ SetSel(nStartChar, nEndChar);
+ ReplaceSel(str, TRUE);
+ } else if (pMsg->wParam == VK_ESCAPE) {
+ m_acdlg.ShowWindow(SW_HIDE);
+ return GetParent()->PreTranslateMessage(pMsg);
+ } else {
+ m_acdlg.m_list.SendMessage(pMsg->message, pMsg->wParam, pMsg->lParam);
+ }
+
+ return TRUE;
+ }
+
+ return __super::PreTranslateMessage(pMsg);
}
BEGIN_MESSAGE_MAP(CShaderEdit, CLineNumberEdit)
- ON_CONTROL_REFLECT(EN_UPDATE, OnUpdate)
- ON_WM_KILLFOCUS()
- ON_WM_TIMER()
+ ON_CONTROL_REFLECT(EN_UPDATE, OnUpdate)
+ ON_WM_KILLFOCUS()
+ ON_WM_TIMER()
END_MESSAGE_MAP()
void CShaderEdit::OnUpdate()
{
- if (m_nIDEvent == (UINT_PTR)-1) {
- m_nIDEvent = SetTimer(1, 100, NULL);
- }
-
- CString text;
- int nStartChar = 0, nEndChar = -1;
- GetSel(nStartChar, nEndChar);
-
- if (nStartChar == nEndChar) {
- GetWindowText(text);
- while (nStartChar > 0 && _istalnum(text.GetAt(nStartChar-1))) {
- nStartChar--;
- }
- }
-
- if (nStartChar < nEndChar) {
- text = text.Mid(nStartChar, nEndChar - nStartChar);
- text.TrimRight('(');
- text.MakeLower();
-
- m_acdlg.m_list.ResetContent();
-
- CString key, value;
- POSITION pos = m_acdlg.m_inst.GetStartPosition();
- while (pos) {
- POSITION cur = pos;
- m_acdlg.m_inst.GetNextAssoc(pos, key, value);
-
- if (key.Find(text) == 0) {
- CAtlList<CString> sl;
- Explode(value, sl, '|', 2);
- if (sl.GetCount() != 2) {
- continue;
- }
- CString name = sl.RemoveHead();
- CString description = sl.RemoveHead();
- int i = m_acdlg.m_list.AddString(name);
- m_acdlg.m_list.SetItemDataPtr(i, cur);
- }
- }
-
- if (m_acdlg.m_list.GetCount() > 0) {
- int lineheight = GetLineHeight();
-
- CPoint p = PosFromChar(nStartChar);
- p.y += lineheight;
- ClientToScreen(&p);
- CRect r(p, CSize(100, 100));
-
- m_acdlg.MoveWindow(r);
- m_acdlg.SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
- m_acdlg.ShowWindow(SW_SHOWNOACTIVATE);
-
- m_nEndChar = nEndChar;
-
- return;
- }
- }
-
- m_acdlg.ShowWindow(SW_HIDE);
+ if (m_nIDEvent == (UINT_PTR) - 1) {
+ m_nIDEvent = SetTimer(1, 100, NULL);
+ }
+
+ CString text;
+ int nStartChar = 0, nEndChar = -1;
+ GetSel(nStartChar, nEndChar);
+
+ if (nStartChar == nEndChar) {
+ GetWindowText(text);
+ while (nStartChar > 0 && _istalnum(text.GetAt(nStartChar - 1))) {
+ nStartChar--;
+ }
+ }
+
+ if (nStartChar < nEndChar) {
+ text = text.Mid(nStartChar, nEndChar - nStartChar);
+ text.TrimRight('(');
+ text.MakeLower();
+
+ m_acdlg.m_list.ResetContent();
+
+ CString key, value;
+ POSITION pos = m_acdlg.m_inst.GetStartPosition();
+ while (pos) {
+ POSITION cur = pos;
+ m_acdlg.m_inst.GetNextAssoc(pos, key, value);
+
+ if (key.Find(text) == 0) {
+ CAtlList<CString> sl;
+ Explode(value, sl, '|', 2);
+ if (sl.GetCount() != 2) {
+ continue;
+ }
+ CString name = sl.RemoveHead();
+ CString description = sl.RemoveHead();
+ int i = m_acdlg.m_list.AddString(name);
+ m_acdlg.m_list.SetItemDataPtr(i, cur);
+ }
+ }
+
+ if (m_acdlg.m_list.GetCount() > 0) {
+ int lineheight = GetLineHeight();
+
+ CPoint p = PosFromChar(nStartChar);
+ p.y += lineheight;
+ ClientToScreen(&p);
+ CRect r(p, CSize(100, 100));
+
+ m_acdlg.MoveWindow(r);
+ m_acdlg.SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+ m_acdlg.ShowWindow(SW_SHOWNOACTIVATE);
+
+ m_nEndChar = nEndChar;
+
+ return;
+ }
+ }
+
+ m_acdlg.ShowWindow(SW_HIDE);
}
void CShaderEdit::OnKillFocus(CWnd* pNewWnd)
{
- CString text;
- GetWindowText(text);
- __super::OnKillFocus(pNewWnd);
- GetWindowText(text);
+ CString text;
+ GetWindowText(text);
+ __super::OnKillFocus(pNewWnd);
+ GetWindowText(text);
- m_acdlg.ShowWindow(SW_HIDE);
+ m_acdlg.ShowWindow(SW_HIDE);
}
void CShaderEdit::OnTimer(UINT_PTR nIDEvent)
{
- if (m_nIDEvent == nIDEvent) {
- int nStartChar = 0, nEndChar = -1;
- GetSel(nStartChar, nEndChar);
- if (nStartChar != nEndChar || m_nEndChar != nEndChar) {
- m_acdlg.ShowWindow(SW_HIDE);
- }
- }
-
- __super::OnTimer(nIDEvent);
+ if (m_nIDEvent == nIDEvent) {
+ int nStartChar = 0, nEndChar = -1;
+ GetSel(nStartChar, nEndChar);
+ if (nStartChar != nEndChar || m_nEndChar != nEndChar) {
+ m_acdlg.ShowWindow(SW_HIDE);
+ }
+ }
+
+ __super::OnTimer(nIDEvent);
}
// CShaderEditorDlg dialog
CShaderEditorDlg::CShaderEditorDlg()
- : CResizableDialog(CShaderEditorDlg::IDD, NULL)
- , m_fSplitterGrabbed(false)
- , m_pPSC(NULL)
- , m_pShader(NULL)
+ : CResizableDialog(CShaderEditorDlg::IDD, NULL)
+ , m_fSplitterGrabbed(false)
+ , m_pPSC(NULL)
+ , m_pShader(NULL)
{
}
CShaderEditorDlg::~CShaderEditorDlg()
{
- delete m_pPSC;
+ delete m_pPSC;
}
BOOL CShaderEditorDlg::Create(CWnd* pParent)
{
- if (!__super::Create(IDD, pParent)) {
- return FALSE;
- }
+ if (!__super::Create(IDD, pParent)) {
+ return FALSE;
+ }
- AddAnchor(IDC_COMBO1, TOP_LEFT, TOP_RIGHT);
- AddAnchor(IDC_COMBO2, TOP_RIGHT);
- AddAnchor(IDC_EDIT1, TOP_LEFT, BOTTOM_RIGHT);
- AddAnchor(IDC_EDIT2, BOTTOM_LEFT, BOTTOM_RIGHT);
- AddAnchor(IDC_BUTTON1, TOP_RIGHT);
+ AddAnchor(IDC_COMBO1, TOP_LEFT, TOP_RIGHT);
+ AddAnchor(IDC_COMBO2, TOP_RIGHT);
+ AddAnchor(IDC_EDIT1, TOP_LEFT, BOTTOM_RIGHT);
+ AddAnchor(IDC_EDIT2, BOTTOM_LEFT, BOTTOM_RIGHT);
+ AddAnchor(IDC_BUTTON1, TOP_RIGHT);
- m_srcdata.SetTabStops(16);
+ m_srcdata.SetTabStops(16);
- SetMinTrackSize(CSize(250, 40));
+ SetMinTrackSize(CSize(250, 40));
- m_targets.AddString(_T("ps_2_0"));
- m_targets.AddString(_T("ps_2_a"));
- m_targets.AddString(_T("ps_2_sw"));
- m_targets.AddString(_T("ps_3_0"));
- m_targets.AddString(_T("ps_3_sw"));
+ m_targets.AddString(_T("ps_2_0"));
+ m_targets.AddString(_T("ps_2_a"));
+ m_targets.AddString(_T("ps_2_sw"));
+ m_targets.AddString(_T("ps_3_0"));
+ m_targets.AddString(_T("ps_3_sw"));
- POSITION pos = AfxGetAppSettings().m_shaders.GetHeadPosition();
- while (pos) {
- const AppSettings::Shader& s = AfxGetAppSettings().m_shaders.GetNext(pos);
- m_labels.SetItemDataPtr(m_labels.AddString(s.label), (void*)&s);
- }
- CorrectComboListWidth(m_labels);
+ POSITION pos = AfxGetAppSettings().m_shaders.GetHeadPosition();
+ while (pos) {
+ const AppSettings::Shader& s = AfxGetAppSettings().m_shaders.GetNext(pos);
+ m_labels.SetItemDataPtr(m_labels.AddString(s.label), (void*)&s);
+ }
+ CorrectComboListWidth(m_labels);
- m_nIDEventShader = SetTimer(1, 1000, NULL);
+ m_nIDEventShader = SetTimer(1, 1000, NULL);
- return TRUE;
+ return TRUE;
}
void CShaderEditorDlg::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_COMBO1, m_labels);
- DDX_Control(pDX, IDC_COMBO2, m_targets);
- DDX_Control(pDX, IDC_EDIT1, m_srcdata);
- DDX_Control(pDX, IDC_EDIT2, m_output);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_COMBO1, m_labels);
+ DDX_Control(pDX, IDC_COMBO2, m_targets);
+ DDX_Control(pDX, IDC_EDIT1, m_srcdata);
+ DDX_Control(pDX, IDC_EDIT2, m_output);
}
bool CShaderEditorDlg::HitTestSplitter(CPoint p)
{
- CRect r, rs, ro;
- m_srcdata.GetWindowRect(&rs);
- m_output.GetWindowRect(&ro);
- ScreenToClient(&rs);
- ScreenToClient(&ro);
- GetClientRect(&r);
- r.left = ro.left;
- r.right = ro.right;
- r.top = rs.bottom;
- r.bottom = ro.top;
- return !!r.PtInRect(p);
+ CRect r, rs, ro;
+ m_srcdata.GetWindowRect(&rs);
+ m_output.GetWindowRect(&ro);
+ ScreenToClient(&rs);
+ ScreenToClient(&ro);
+ GetClientRect(&r);
+ r.left = ro.left;
+ r.right = ro.right;
+ r.top = rs.bottom;
+ r.bottom = ro.top;
+ return !!r.PtInRect(p);
}
BEGIN_MESSAGE_MAP(CShaderEditorDlg, CResizableDialog)
- ON_CBN_SELCHANGE(IDC_COMBO1, OnCbnSelchangeCombo1)
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton2)
- ON_WM_TIMER()
- ON_WM_LBUTTONDOWN()
- ON_WM_LBUTTONUP()
- ON_WM_MOUSEMOVE()
- ON_WM_SETCURSOR()
+ ON_CBN_SELCHANGE(IDC_COMBO1, OnCbnSelchangeCombo1)
+ ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton2)
+ ON_WM_TIMER()
+ ON_WM_LBUTTONDOWN()
+ ON_WM_LBUTTONUP()
+ ON_WM_MOUSEMOVE()
+ ON_WM_SETCURSOR()
END_MESSAGE_MAP()
// CShaderEditorDlg message handlers
BOOL CShaderEditorDlg::PreTranslateMessage(MSG* pMsg)
{
- if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN
- && pMsg->hwnd == m_labels.m_edit.GetSafeHwnd()) {
- OnCbnSelchangeCombo1();
-
- return TRUE;
- } else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_TAB
- && pMsg->hwnd == m_srcdata.GetSafeHwnd()) {
- int nStartChar, nEndChar;
- m_srcdata.GetSel(nStartChar, nEndChar);
- if (nStartChar == nEndChar) {
- m_srcdata.ReplaceSel(_T("\t"));
- }
- return TRUE;
- } else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE) {
- return GetParent()->PreTranslateMessage(pMsg);
- }
-
- return __super::PreTranslateMessage(pMsg);
+ if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN
+ && pMsg->hwnd == m_labels.m_edit.GetSafeHwnd()) {
+ OnCbnSelchangeCombo1();
+
+ return TRUE;
+ } else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_TAB
+ && pMsg->hwnd == m_srcdata.GetSafeHwnd()) {
+ int nStartChar, nEndChar;
+ m_srcdata.GetSel(nStartChar, nEndChar);
+ if (nStartChar == nEndChar) {
+ m_srcdata.ReplaceSel(_T("\t"));
+ }
+ return TRUE;
+ } else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE) {
+ return GetParent()->PreTranslateMessage(pMsg);
+ }
+
+ return __super::PreTranslateMessage(pMsg);
}
void CShaderEditorDlg::OnCbnSelchangeCombo1()
{
- int i = m_labels.GetCurSel();
+ int i = m_labels.GetCurSel();
- if (i < 0) {
- CString label;
- m_labels.GetWindowText(label);
- label.Trim();
+ if (i < 0) {
+ CString label;
+ m_labels.GetWindowText(label);
+ label.Trim();
- if (label.IsEmpty()) {
- return;
- }
+ if (label.IsEmpty()) {
+ return;
+ }
- CStringA srcdata;
- LoadResource(IDF_SHADER_EMPTY, srcdata, _T("FILE"));
+ CStringA srcdata;
+ LoadResource(IDF_SHADER_EMPTY, srcdata, _T("FILE"));
- AppSettings::Shader s;
- s.label = label;
- s.target = _T("ps_2_0");
- s.srcdata = CString(srcdata);
+ AppSettings::Shader s;
+ s.label = label;
+ s.target = _T("ps_2_0");
+ s.srcdata = CString(srcdata);
- POSITION pos = AfxGetAppSettings().m_shaders.AddTail(s);
+ POSITION pos = AfxGetAppSettings().m_shaders.AddTail(s);
- i = m_labels.AddString(s.label);
- m_labels.SetCurSel(i);
- m_labels.SetItemDataPtr(i, (void*)&AfxGetAppSettings().m_shaders.GetAt(pos));
- }
+ i = m_labels.AddString(s.label);
+ m_labels.SetCurSel(i);
+ m_labels.SetItemDataPtr(i, (void*)&AfxGetAppSettings().m_shaders.GetAt(pos));
+ }
- m_pShader = (AppSettings::Shader*)m_labels.GetItemDataPtr(i);
+ m_pShader = (AppSettings::Shader*)m_labels.GetItemDataPtr(i);
- m_targets.SetWindowText(m_pShader->target);
+ m_targets.SetWindowText(m_pShader->target);
- CString srcdata = m_pShader->srcdata;
- srcdata.Replace(_T("\n"), _T("\r\n"));
- m_srcdata.SetWindowText(srcdata);
+ CString srcdata = m_pShader->srcdata;
+ srcdata.Replace(_T("\n"), _T("\r\n"));
+ m_srcdata.SetWindowText(srcdata);
- ((CMainFrame*)AfxGetMainWnd())->UpdateShaders(m_pShader->label);
+ ((CMainFrame*)AfxGetMainWnd())->UpdateShaders(m_pShader->label);
}
void CShaderEditorDlg::OnBnClickedButton2()
{
- if (!m_pShader) {
- return;
- }
-
- if (IDYES != AfxMessageBox(IDS_SHADEREDITORDLG_0, MB_ICONQUESTION | MB_YESNO, 0)) {
- return;
- }
-
- AppSettings& s = AfxGetAppSettings();
-
- for (POSITION pos = s.m_shaders.GetHeadPosition(); pos; s.m_shaders.GetNext(pos)) {
- if (m_pShader == &s.m_shaders.GetAt(pos)) {
- m_pShader = NULL;
- s.m_shaders.RemoveAt(pos);
- int i = m_labels.GetCurSel();
- if (i >= 0) {
- m_labels.DeleteString(i);
- }
- m_labels.SetWindowText(_T(""));
- m_targets.SetWindowText(_T(""));
- m_srcdata.SetWindowText(_T(""));
- m_output.SetWindowText(_T(""));
- ((CMainFrame*)AfxGetMainWnd())->UpdateShaders(_T(""));
- break;
- }
- }
+ if (!m_pShader) {
+ return;
+ }
+
+ if (IDYES != AfxMessageBox(IDS_SHADEREDITORDLG_0, MB_ICONQUESTION | MB_YESNO, 0)) {
+ return;
+ }
+
+ AppSettings& s = AfxGetAppSettings();
+
+ for (POSITION pos = s.m_shaders.GetHeadPosition(); pos; s.m_shaders.GetNext(pos)) {
+ if (m_pShader == &s.m_shaders.GetAt(pos)) {
+ m_pShader = NULL;
+ s.m_shaders.RemoveAt(pos);
+ int i = m_labels.GetCurSel();
+ if (i >= 0) {
+ m_labels.DeleteString(i);
+ }
+ m_labels.SetWindowText(_T(""));
+ m_targets.SetWindowText(_T(""));
+ m_srcdata.SetWindowText(_T(""));
+ m_output.SetWindowText(_T(""));
+ ((CMainFrame*)AfxGetMainWnd())->UpdateShaders(_T(""));
+ break;
+ }
+ }
}
void CShaderEditorDlg::OnTimer(UINT_PTR nIDEvent)
{
- if (nIDEvent == m_nIDEventShader && IsWindowVisible() && m_pShader) {
- CString srcdata;
- m_srcdata.GetWindowText(srcdata);
- srcdata.Replace(_T("\r"), _T(""));
- srcdata.Trim();
+ if (nIDEvent == m_nIDEventShader && IsWindowVisible() && m_pShader) {
+ CString srcdata;
+ m_srcdata.GetWindowText(srcdata);
+ srcdata.Replace(_T("\r"), _T(""));
+ srcdata.Trim();
- CString target;
- m_targets.GetWindowText(target);
- target.Trim();
+ CString target;
+ m_targets.GetWindowText(target);
+ target.Trim();
- if (!srcdata.IsEmpty() && !target.IsEmpty() && (m_pShader->srcdata != srcdata || m_pShader->target != target)) {
- KillTimer(m_nIDEventShader);
+ if (!srcdata.IsEmpty() && !target.IsEmpty() && (m_pShader->srcdata != srcdata || m_pShader->target != target)) {
+ KillTimer(m_nIDEventShader);
- m_pShader->srcdata = srcdata;
- m_pShader->target = target;
+ m_pShader->srcdata = srcdata;
+ m_pShader->target = target;
- if (!m_pPSC) {
- m_pPSC = DNew CPixelShaderCompiler(NULL);
- }
+ if (!m_pPSC) {
+ m_pPSC = DNew CPixelShaderCompiler(NULL);
+ }
- CString disasm, errmsg;
- HRESULT hr = m_pPSC->CompileShader(CStringA(srcdata), "main", CStringA(target), D3DXSHADER_DEBUG, NULL, &disasm, &errmsg);
+ CString disasm, errmsg;
+ HRESULT hr = m_pPSC->CompileShader(CStringA(srcdata), "main", CStringA(target), D3DXSHADER_DEBUG, NULL, &disasm, &errmsg);
- if (SUCCEEDED(hr)) {
- errmsg = _T("D3DXCompileShader succeeded\n");
- errmsg += _T("\n");
- errmsg += disasm;
+ if (SUCCEEDED(hr)) {
+ errmsg = _T("D3DXCompileShader succeeded\n");
+ errmsg += _T("\n");
+ errmsg += disasm;
- ((CMainFrame*)AfxGetMainWnd())->UpdateShaders(m_pShader->label);
- }
+ ((CMainFrame*)AfxGetMainWnd())->UpdateShaders(m_pShader->label);
+ }
- errmsg.Replace(_T("\n"), _T("\r\n"));
+ errmsg.Replace(_T("\n"), _T("\r\n"));
- m_output.SetWindowText(errmsg);
+ m_output.SetWindowText(errmsg);
- // TODO: autosave
+ // TODO: autosave
- m_nIDEventShader = SetTimer(1, 1000, NULL);
- }
- }
+ m_nIDEventShader = SetTimer(1, 1000, NULL);
+ }
+ }
- __super::OnTimer(nIDEvent);
+ __super::OnTimer(nIDEvent);
}
void CShaderEditorDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
- if (HitTestSplitter(point)) {
- m_fSplitterGrabbed = true;
- SetCapture();
- }
+ if (HitTestSplitter(point)) {
+ m_fSplitterGrabbed = true;
+ SetCapture();
+ }
- __super::OnLButtonDown(nFlags, point);
+ __super::OnLButtonDown(nFlags, point);
}
void CShaderEditorDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
- if (m_fSplitterGrabbed) {
- ReleaseCapture();
- m_fSplitterGrabbed = false;
- }
+ if (m_fSplitterGrabbed) {
+ ReleaseCapture();
+ m_fSplitterGrabbed = false;
+ }
- __super::OnLButtonUp(nFlags, point);
+ __super::OnLButtonUp(nFlags, point);
}
void CShaderEditorDlg::OnMouseMove(UINT nFlags, CPoint point)
{
- if (m_fSplitterGrabbed) {
- CRect r, rs, ro;
- GetClientRect(&r);
- m_srcdata.GetWindowRect(&rs);
- m_output.GetWindowRect(&ro);
- ScreenToClient(&rs);
- ScreenToClient(&ro);
-
- int dist = ro.top - rs.bottom;
- int avgdist = dist / 2;
-
- rs.bottom = min(max(point.y, rs.top + 40), ro.bottom - 40) - avgdist;
- ro.top = rs.bottom + dist;
- m_srcdata.MoveWindow(&rs);
- m_output.MoveWindow(&ro);
-
- int div = 100 * ((rs.bottom + ro.top) / 2) / (ro.bottom - rs.top);
-
- RemoveAnchor(IDC_EDIT1);
- RemoveAnchor(IDC_EDIT2);
- AddAnchor(IDC_EDIT1, TOP_LEFT, CSize(100, div)/*BOTTOM_RIGHT*/);
- AddAnchor(IDC_EDIT2, CSize(0, div)/*BOTTOM_LEFT*/, BOTTOM_RIGHT);
- }
-
- __super::OnMouseMove(nFlags, point);
+ if (m_fSplitterGrabbed) {
+ CRect r, rs, ro;
+ GetClientRect(&r);
+ m_srcdata.GetWindowRect(&rs);
+ m_output.GetWindowRect(&ro);
+ ScreenToClient(&rs);
+ ScreenToClient(&ro);
+
+ int dist = ro.top - rs.bottom;
+ int avgdist = dist / 2;
+
+ rs.bottom = min(max(point.y, rs.top + 40), ro.bottom - 40) - avgdist;
+ ro.top = rs.bottom + dist;
+ m_srcdata.MoveWindow(&rs);
+ m_output.MoveWindow(&ro);
+
+ int div = 100 * ((rs.bottom + ro.top) / 2) / (ro.bottom - rs.top);
+
+ RemoveAnchor(IDC_EDIT1);
+ RemoveAnchor(IDC_EDIT2);
+ AddAnchor(IDC_EDIT1, TOP_LEFT, CSize(100, div)/*BOTTOM_RIGHT*/);
+ AddAnchor(IDC_EDIT2, CSize(0, div)/*BOTTOM_LEFT*/, BOTTOM_RIGHT);
+ }
+
+ __super::OnMouseMove(nFlags, point);
}
BOOL CShaderEditorDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
- CPoint p;
- GetCursorPos(&p);
- ScreenToClient(&p);
- if (HitTestSplitter(p)) {
- ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZENS));
- return TRUE;
- }
-
- return __super::OnSetCursor(pWnd, nHitTest, message);
+ CPoint p;
+ GetCursorPos(&p);
+ ScreenToClient(&p);
+ if (HitTestSplitter(p)) {
+ ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZENS));
+ return TRUE;
+ }
+
+ return __super::OnSetCursor(pWnd, nHitTest, message);
}
diff --git a/src/mpc-hc/ShaderEditorDlg.h b/src/mpc-hc/ShaderEditorDlg.h
index 96889d3cf..a5c4c32d0 100644
--- a/src/mpc-hc/ShaderEditorDlg.h
+++ b/src/mpc-hc/ShaderEditorDlg.h
@@ -34,29 +34,29 @@
class CShaderLabelComboBox : public CComboBox
{
public:
- CEdit m_edit;
+ CEdit m_edit;
- DECLARE_MESSAGE_MAP()
- afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
- afx_msg void OnDestroy();
+ DECLARE_MESSAGE_MAP()
+ afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
+ afx_msg void OnDestroy();
};
class CShaderEdit : public CLineNumberEdit
{
- int m_nEndChar;
- UINT_PTR m_nIDEvent;
+ int m_nEndChar;
+ UINT_PTR m_nIDEvent;
public:
- CShaderEdit();
- ~CShaderEdit();
+ CShaderEdit();
+ ~CShaderEdit();
- CShaderAutoCompleteDlg m_acdlg;
+ CShaderAutoCompleteDlg m_acdlg;
- DECLARE_MESSAGE_MAP()
- afx_msg void OnUpdate();
- afx_msg void OnKillFocus(CWnd* pNewWnd);
- afx_msg void OnTimer(UINT_PTR nIDEvent);
- virtual BOOL PreTranslateMessage(MSG* pMsg);
+ DECLARE_MESSAGE_MAP()
+ afx_msg void OnUpdate();
+ afx_msg void OnKillFocus(CWnd* pNewWnd);
+ afx_msg void OnTimer(UINT_PTR nIDEvent);
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
};
// CShaderEditorDlg dialog
@@ -66,42 +66,42 @@ class CPixelShaderCompiler;
class CShaderEditorDlg : public CResizableDialog
{
private:
- UINT_PTR m_nIDEventShader;
+ UINT_PTR m_nIDEventShader;
- bool m_fSplitterGrabbed;
- bool HitTestSplitter(CPoint p);
+ bool m_fSplitterGrabbed;
+ bool HitTestSplitter(CPoint p);
- CPixelShaderCompiler* m_pPSC;
- AppSettings::Shader* m_pShader;
+ CPixelShaderCompiler* m_pPSC;
+ AppSettings::Shader* m_pShader;
public:
- CShaderEditorDlg(); // standard constructor
- virtual ~CShaderEditorDlg();
+ CShaderEditorDlg(); // standard constructor
+ virtual ~CShaderEditorDlg();
- BOOL Create(CWnd* pParent = NULL);
+ BOOL Create(CWnd* pParent = NULL);
- // Dialog Data
- enum { IDD = IDD_SHADEREDITOR_DLG };
- CShaderLabelComboBox m_labels;
- CComboBox m_targets;
- CShaderEdit m_srcdata;
- CEdit m_output;
+ // Dialog Data
+ enum { IDD = IDD_SHADEREDITOR_DLG };
+ CShaderLabelComboBox m_labels;
+ CComboBox m_targets;
+ CShaderEdit m_srcdata;
+ CEdit m_output;
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- virtual void OnOK() {}
- virtual void OnCancel() {}
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
+ virtual void OnOK() {}
+ virtual void OnCancel() {}
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnCbnSelchangeCombo1();
- afx_msg void OnBnClickedButton2();
- afx_msg void OnTimer(UINT_PTR nIDEvent);
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
- afx_msg void OnMouseMove(UINT nFlags, CPoint point);
- afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
- afx_msg void OnKillFocus(CWnd* pNewWnd);
+ afx_msg void OnCbnSelchangeCombo1();
+ afx_msg void OnBnClickedButton2();
+ afx_msg void OnTimer(UINT_PTR nIDEvent);
+ afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
+ afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
+ afx_msg void OnMouseMove(UINT nFlags, CPoint point);
+ afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
+ afx_msg void OnKillFocus(CWnd* pNewWnd);
};
diff --git a/src/mpc-hc/ShockwaveGraph.cpp b/src/mpc-hc/ShockwaveGraph.cpp
index c63e73dba..e904541ac 100644
--- a/src/mpc-hc/ShockwaveGraph.cpp
+++ b/src/mpc-hc/ShockwaveGraph.cpp
@@ -31,177 +31,177 @@ using namespace DSObjects;
CShockwaveGraph::CShockwaveGraph(HWND hParent, HRESULT& hr)
- : m_fs(State_Stopped)
+ : m_fs(State_Stopped)
{
- hr = S_OK;
-
- if (!m_wndWindowFrame.Create(NULL, NULL, WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,
- CRect(0, 0, 0, 0), CWnd::FromHandle(hParent), 0, NULL)) {
- hr = E_FAIL;
- return;
- }
-
- if (!m_wndDestFrame.Create(NULL, WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS,
- CRect(0, 0, 0, 0), &m_wndWindowFrame, 0)) {
- hr = E_FAIL;
- return;
- }
- m_wndDestFrame.put_BackgroundColor(0);
+ hr = S_OK;
+
+ if (!m_wndWindowFrame.Create(NULL, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
+ CRect(0, 0, 0, 0), CWnd::FromHandle(hParent), 0, NULL)) {
+ hr = E_FAIL;
+ return;
+ }
+
+ if (!m_wndDestFrame.Create(NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
+ CRect(0, 0, 0, 0), &m_wndWindowFrame, 0)) {
+ hr = E_FAIL;
+ return;
+ }
+ m_wndDestFrame.put_BackgroundColor(0);
}
CShockwaveGraph::~CShockwaveGraph()
{
- m_wndDestFrame.DestroyWindow();
- m_wndWindowFrame.DestroyWindow();
+ m_wndDestFrame.DestroyWindow();
+ m_wndWindowFrame.DestroyWindow();
}
// IGraphBuilder
STDMETHODIMP CShockwaveGraph::RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList)
{
- try {
- m_wndDestFrame.LoadMovie(0, CString(lpcwstrFile));
- } catch (CException* e) {
- e->Delete();
- return E_FAIL;
- }
- return S_OK;
+ try {
+ m_wndDestFrame.LoadMovie(0, CString(lpcwstrFile));
+ } catch (CException* e) {
+ e->Delete();
+ return E_FAIL;
+ }
+ return S_OK;
}
// IMediaControl
STDMETHODIMP CShockwaveGraph::Run()
{
- try {
- // XXX - Does the following line have some side effect
- // or is the variable unused?
- /*long scale_mode = */this->m_wndDestFrame.get_ScaleMode();
-
- if (m_fs != State_Running) {
- m_wndDestFrame.Play();
- }
- } catch (CException* e) {
- e->Delete();
- return E_FAIL;
- }
- m_fs = State_Running;
- m_wndWindowFrame.EnableWindow();
- // m_wndDestFrame.EnableWindow();
- return S_OK;
+ try {
+ // XXX - Does the following line have some side effect
+ // or is the variable unused?
+ /*long scale_mode = */this->m_wndDestFrame.get_ScaleMode();
+
+ if (m_fs != State_Running) {
+ m_wndDestFrame.Play();
+ }
+ } catch (CException* e) {
+ e->Delete();
+ return E_FAIL;
+ }
+ m_fs = State_Running;
+ m_wndWindowFrame.EnableWindow();
+ // m_wndDestFrame.EnableWindow();
+ return S_OK;
}
STDMETHODIMP CShockwaveGraph::Pause()
{
- try {
- if (m_fs == State_Running) {
- m_wndDestFrame.Stop();
- }
- } catch (CException* e) {
- e->Delete();
- return E_FAIL;
- }
- m_fs = State_Paused;
- return S_OK;
+ try {
+ if (m_fs == State_Running) {
+ m_wndDestFrame.Stop();
+ }
+ } catch (CException* e) {
+ e->Delete();
+ return E_FAIL;
+ }
+ m_fs = State_Paused;
+ return S_OK;
}
STDMETHODIMP CShockwaveGraph::Stop()
{
- try {
- m_wndDestFrame.Stop();
- } catch (CException* e) {
- e->Delete();
- return E_FAIL;
- }
- m_fs = State_Stopped;
- return S_OK;
+ try {
+ m_wndDestFrame.Stop();
+ } catch (CException* e) {
+ e->Delete();
+ return E_FAIL;
+ }
+ m_fs = State_Stopped;
+ return S_OK;
}
STDMETHODIMP CShockwaveGraph::GetState(LONG msTimeout, OAFilterState* pfs)
{
- OAFilterState fs = m_fs;
-
- try {
- if (m_wndDestFrame.IsPlaying() && m_fs == State_Stopped) {
- m_fs = State_Running;
- } else if (!m_wndDestFrame.IsPlaying() && m_fs == State_Running) {
- m_fs = State_Stopped;
- }
- fs = m_fs;
- // HACK : Make sure that the movie is running in "show all".
- m_wndDestFrame.SendMessage( WM_COMMAND, MAKEWPARAM(20034, 0), 0 );
- } catch (CException* e) {
- e->Delete();
- return E_FAIL;
- }
-
- return pfs ? *pfs = fs, S_OK : E_POINTER;
+ OAFilterState fs = m_fs;
+
+ try {
+ if (m_wndDestFrame.IsPlaying() && m_fs == State_Stopped) {
+ m_fs = State_Running;
+ } else if (!m_wndDestFrame.IsPlaying() && m_fs == State_Running) {
+ m_fs = State_Stopped;
+ }
+ fs = m_fs;
+ // HACK : Make sure that the movie is running in "show all".
+ m_wndDestFrame.SendMessage(WM_COMMAND, MAKEWPARAM(20034, 0), 0);
+ } catch (CException* e) {
+ e->Delete();
+ return E_FAIL;
+ }
+
+ return pfs ? *pfs = fs, S_OK : E_POINTER;
}
// IMediaSeeking
STDMETHODIMP CShockwaveGraph::IsFormatSupported(const GUID* pFormat)
{
- return !pFormat ? E_POINTER : *pFormat == TIME_FORMAT_FRAME ? S_OK : S_FALSE;
+ return !pFormat ? E_POINTER : *pFormat == TIME_FORMAT_FRAME ? S_OK : S_FALSE;
}
STDMETHODIMP CShockwaveGraph::GetTimeFormat(GUID* pFormat)
{
- return pFormat ? *pFormat = TIME_FORMAT_FRAME, S_OK : E_POINTER;
+ return pFormat ? *pFormat = TIME_FORMAT_FRAME, S_OK : E_POINTER;
}
STDMETHODIMP CShockwaveGraph::GetDuration(LONGLONG* pDuration)
{
- CheckPointer(pDuration, E_POINTER);
- *pDuration = 0;
- try {
- if (m_wndDestFrame.get_ReadyState() >= READYSTATE_COMPLETE) {
- *pDuration = m_wndDestFrame.get_TotalFrames();
- }
- } catch (CException* e) {
- e->Delete();
- return E_FAIL;
- }
- return S_OK;
+ CheckPointer(pDuration, E_POINTER);
+ *pDuration = 0;
+ try {
+ if (m_wndDestFrame.get_ReadyState() >= READYSTATE_COMPLETE) {
+ *pDuration = m_wndDestFrame.get_TotalFrames();
+ }
+ } catch (CException* e) {
+ e->Delete();
+ return E_FAIL;
+ }
+ return S_OK;
}
STDMETHODIMP CShockwaveGraph::GetCurrentPosition(LONGLONG* pCurrent)
{
- CheckPointer(pCurrent, E_POINTER);
- *pCurrent = 0;
- try {
- if (m_wndDestFrame.get_ReadyState() >= READYSTATE_COMPLETE) {
- *pCurrent = m_wndDestFrame.get_FrameNum();
- }
- } catch (CException* e) {
- e->Delete();
- return E_FAIL;
- }
- return S_OK;
+ CheckPointer(pCurrent, E_POINTER);
+ *pCurrent = 0;
+ try {
+ if (m_wndDestFrame.get_ReadyState() >= READYSTATE_COMPLETE) {
+ *pCurrent = m_wndDestFrame.get_FrameNum();
+ }
+ } catch (CException* e) {
+ e->Delete();
+ return E_FAIL;
+ }
+ return S_OK;
}
STDMETHODIMP CShockwaveGraph::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags)
{
- if (dwCurrentFlags&AM_SEEKING_AbsolutePositioning) {
- m_wndDestFrame.put_FrameNum(*pCurrent);
+ if (dwCurrentFlags & AM_SEEKING_AbsolutePositioning) {
+ m_wndDestFrame.put_FrameNum(*pCurrent);
- if (m_fs == State_Running && !m_wndDestFrame.IsPlaying()) {
- m_wndDestFrame.Play();
- } else if ((m_fs == State_Paused || m_fs == State_Stopped) && m_wndDestFrame.IsPlaying()) {
- m_wndDestFrame.Stop();
- }
+ if (m_fs == State_Running && !m_wndDestFrame.IsPlaying()) {
+ m_wndDestFrame.Play();
+ } else if ((m_fs == State_Paused || m_fs == State_Stopped) && m_wndDestFrame.IsPlaying()) {
+ m_wndDestFrame.Stop();
+ }
- m_wndDestFrame.put_Quality(1); // 0=Low, 1=High, 2=AutoLow, 3=AutoHigh
+ m_wndDestFrame.put_Quality(1); // 0=Low, 1=High, 2=AutoLow, 3=AutoHigh
- return S_OK;
- }
+ return S_OK;
+ }
- return E_INVALIDARG;
+ return E_INVALIDARG;
}
// IVideoWindow
STDMETHODIMP CShockwaveGraph::put_Visible(long Visible)
{
- if (IsWindow(m_wndDestFrame.m_hWnd)) {
- m_wndDestFrame.ShowWindow(Visible == OATRUE ? SW_SHOWNORMAL : SW_HIDE);
- }
- return S_OK;
+ if (IsWindow(m_wndDestFrame.m_hWnd)) {
+ m_wndDestFrame.ShowWindow(Visible == OATRUE ? SW_SHOWNORMAL : SW_HIDE);
+ }
+ return S_OK;
}
STDMETHODIMP CShockwaveGraph::get_Visible(long* pVisible)
@@ -211,81 +211,81 @@ return pVisible ? *pVisible = (m_wndDestFrame.IsWindowVisible() ? OATRUE : OAFAL
STDMETHODIMP CShockwaveGraph::SetWindowPosition(long Left, long Top, long Width, long Height)
{
- if (IsWindow(m_wndWindowFrame.m_hWnd)) {
- m_wndWindowFrame.MoveWindow(Left, Top, Width, Height);
- }
+ if (IsWindow(m_wndWindowFrame.m_hWnd)) {
+ m_wndWindowFrame.MoveWindow(Left, Top, Width, Height);
+ }
- return S_OK;
+ return S_OK;
}
// IBasicVideo
STDMETHODIMP CShockwaveGraph::SetDestinationPosition(long Left, long Top, long Width, long Height)// {return E_NOTIMPL;}
{
- if (IsWindow(m_wndDestFrame.m_hWnd)) {
- m_wndDestFrame.MoveWindow(Left, Top, Width, Height);
- }
+ if (IsWindow(m_wndDestFrame.m_hWnd)) {
+ m_wndDestFrame.MoveWindow(Left, Top, Width, Height);
+ }
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CShockwaveGraph::GetVideoSize(long* pWidth, long* pHeight)
{
- if (!pWidth || !pHeight) {
- return E_POINTER;
- }
-
- CRect r;
- m_wndWindowFrame.GetWindowRect(r);
- if (!r.IsRectEmpty()) {
- *pWidth = r.Width();
- *pHeight = r.Height();
- } else {
- // no call exists to determine these...
- *pWidth = 384;//m_wndDestFrame.get_;
- *pHeight = 288;
-
- NotifyEvent(EC_BG_AUDIO_CHANGED, 2, 0);
- }
-
- return S_OK;
+ if (!pWidth || !pHeight) {
+ return E_POINTER;
+ }
+
+ CRect r;
+ m_wndWindowFrame.GetWindowRect(r);
+ if (!r.IsRectEmpty()) {
+ *pWidth = r.Width();
+ *pHeight = r.Height();
+ } else {
+ // no call exists to determine these...
+ *pWidth = 384;//m_wndDestFrame.get_;
+ *pHeight = 288;
+
+ NotifyEvent(EC_BG_AUDIO_CHANGED, 2, 0);
+ }
+
+ return S_OK;
}
// IBasicAudio
STDMETHODIMP CShockwaveGraph::put_Volume(long lVolume)
{
- lVolume = (lVolume <= -10000) ? 0 : (long)(pow(10.0, lVolume/4000.0)*100);
- lVolume = lVolume*0x10000/100;
- lVolume = max(min(lVolume, 0xffff), 0);
- waveOutSetVolume(0, (lVolume<<16)|lVolume);
+ lVolume = (lVolume <= -10000) ? 0 : (long)(pow(10.0, lVolume / 4000.0) * 100);
+ lVolume = lVolume * 0x10000 / 100;
+ lVolume = max(min(lVolume, 0xffff), 0);
+ waveOutSetVolume(0, (lVolume << 16) | lVolume);
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CShockwaveGraph::get_Volume(long* plVolume)
{
- CheckPointer(plVolume, E_POINTER);
+ CheckPointer(plVolume, E_POINTER);
- waveOutGetVolume(0, (DWORD*)plVolume);
- *plVolume = (*plVolume&0xffff + ((*plVolume>>16)&0xffff)) / 2 * 100/0x10000;
- if (*plVolume > 0) {
- *plVolume = min((long)(4000*log10(*plVolume/100.0f)), 0);
- } else {
- *plVolume = -10000;
- }
+ waveOutGetVolume(0, (DWORD*)plVolume);
+ *plVolume = (*plVolume & 0xffff + ((*plVolume >> 16) & 0xffff)) / 2 * 100 / 0x10000;
+ if (*plVolume > 0) {
+ *plVolume = min((long)(4000 * log10(*plVolume / 100.0f)), 0);
+ } else {
+ *plVolume = -10000;
+ }
- return S_OK;
+ return S_OK;
}
// IAMOpenProgress
STDMETHODIMP CShockwaveGraph::QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent)
{
- *pllTotal = 100;
- *pllCurrent = m_wndDestFrame.PercentLoaded();
- return S_OK;
+ *pllTotal = 100;
+ *pllCurrent = m_wndDestFrame.PercentLoaded();
+ return S_OK;
}
// IGraphEngine
STDMETHODIMP_(engine_t) CShockwaveGraph::GetEngine()
{
- return ShockWave;
+ return ShockWave;
}
diff --git a/src/mpc-hc/ShockwaveGraph.h b/src/mpc-hc/ShockwaveGraph.h
index ac3d10b13..db34181a4 100644
--- a/src/mpc-hc/ShockwaveGraph.h
+++ b/src/mpc-hc/ShockwaveGraph.h
@@ -30,52 +30,52 @@
namespace DSObjects
{
- class CShockwaveGraph : public CBaseGraph
- {
- CPlayerWindow m_wndWindowFrame;
- CShockwaveFlash m_wndDestFrame;
-
- FILTER_STATE m_fs;
-
- public:
- CShockwaveGraph(HWND hParent, HRESULT& hr);
- virtual ~CShockwaveGraph();
-
- protected:
- // IGraphBuilder
- STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
-
- // IMediaControl
- STDMETHODIMP Run();
- STDMETHODIMP Pause();
- STDMETHODIMP Stop();
- STDMETHODIMP GetState(LONG msTimeout, OAFilterState* pfs);
-
- // IMediaSeeking
- STDMETHODIMP IsFormatSupported(const GUID* pFormat);
- STDMETHODIMP GetTimeFormat(GUID* pFormat);
- STDMETHODIMP GetDuration(LONGLONG* pDuration);
- STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
- STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
-
- // IVideoWindow
- STDMETHODIMP put_Visible(long Visible);
- STDMETHODIMP get_Visible(long* pVisible);
- STDMETHODIMP SetWindowPosition(long Left, long Top, long Width, long Height);
-
- // IBasicVideo
- STDMETHODIMP SetDestinationPosition(long Left, long Top, long Width, long Height);
- STDMETHODIMP GetVideoSize(long* pWidth, long* pHeight);
-
- // IBasicAudio
- STDMETHODIMP put_Volume(long lVolume);
- STDMETHODIMP get_Volume(long* plVolume);
-
- // IAMOpenProgress
- STDMETHODIMP QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent);
-
- // IGraphEngine
- STDMETHODIMP_(engine_t) GetEngine();
- };
+ class CShockwaveGraph : public CBaseGraph
+ {
+ CPlayerWindow m_wndWindowFrame;
+ CShockwaveFlash m_wndDestFrame;
+
+ FILTER_STATE m_fs;
+
+ public:
+ CShockwaveGraph(HWND hParent, HRESULT& hr);
+ virtual ~CShockwaveGraph();
+
+ protected:
+ // IGraphBuilder
+ STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
+
+ // IMediaControl
+ STDMETHODIMP Run();
+ STDMETHODIMP Pause();
+ STDMETHODIMP Stop();
+ STDMETHODIMP GetState(LONG msTimeout, OAFilterState* pfs);
+
+ // IMediaSeeking
+ STDMETHODIMP IsFormatSupported(const GUID* pFormat);
+ STDMETHODIMP GetTimeFormat(GUID* pFormat);
+ STDMETHODIMP GetDuration(LONGLONG* pDuration);
+ STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
+ STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
+
+ // IVideoWindow
+ STDMETHODIMP put_Visible(long Visible);
+ STDMETHODIMP get_Visible(long* pVisible);
+ STDMETHODIMP SetWindowPosition(long Left, long Top, long Width, long Height);
+
+ // IBasicVideo
+ STDMETHODIMP SetDestinationPosition(long Left, long Top, long Width, long Height);
+ STDMETHODIMP GetVideoSize(long* pWidth, long* pHeight);
+
+ // IBasicAudio
+ STDMETHODIMP put_Volume(long lVolume);
+ STDMETHODIMP get_Volume(long* plVolume);
+
+ // IAMOpenProgress
+ STDMETHODIMP QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent);
+
+ // IGraphEngine
+ STDMETHODIMP_(engine_t) GetEngine();
+ };
}
diff --git a/src/mpc-hc/StaticLink.cpp b/src/mpc-hc/StaticLink.cpp
index b7f1a77e3..266a58993 100644
--- a/src/mpc-hc/StaticLink.cpp
+++ b/src/mpc-hc/StaticLink.cpp
@@ -28,16 +28,16 @@
// CStaticLink
-COLORREF CStaticLink::g_colorUnvisited = RGB(0,0,255); // blue
-COLORREF CStaticLink::g_colorVisited = RGB(128,0,128); // purple
+COLORREF CStaticLink::g_colorUnvisited = RGB(0, 0, 255); // blue
+COLORREF CStaticLink::g_colorVisited = RGB(128, 0, 128); // purple
IMPLEMENT_DYNAMIC(CStaticLink, CStatic)
BEGIN_MESSAGE_MAP(CStaticLink, CStatic)
- ON_WM_NCHITTEST()
- ON_WM_CTLCOLOR_REFLECT()
- ON_WM_LBUTTONDOWN()
- ON_WM_SETCURSOR()
+ ON_WM_NCHITTEST()
+ ON_WM_CTLCOLOR_REFLECT()
+ ON_WM_LBUTTONDOWN()
+ ON_WM_SETCURSOR()
END_MESSAGE_MAP()
///////////////////
@@ -46,9 +46,9 @@ END_MESSAGE_MAP()
//
CStaticLink::CStaticLink(LPCTSTR lpText, bool bDeleteOnDestroy)
{
- m_link = lpText; // link text (NULL ==> window text)
- m_color = g_colorUnvisited; // not visited yet
- m_bDeleteOnDestroy = bDeleteOnDestroy; // delete object with window?
+ m_link = lpText; // link text (NULL ==> window text)
+ m_color = g_colorUnvisited; // not visited yet
+ m_bDeleteOnDestroy = bDeleteOnDestroy; // delete object with window?
}
//////////////////
@@ -59,7 +59,7 @@ CStaticLink::CStaticLink(LPCTSTR lpText, bool bDeleteOnDestroy)
//
LRESULT CStaticLink::OnNcHitTest(CPoint point)
{
- return HTCLIENT;
+ return HTCLIENT;
}
//////////////////
@@ -69,30 +69,30 @@ LRESULT CStaticLink::OnNcHitTest(CPoint point)
//
HBRUSH CStaticLink::CtlColor(CDC* pDC, UINT nCtlColor)
{
- ASSERT(nCtlColor == CTLCOLOR_STATIC);
- DWORD dwStyle = GetStyle();
-
- HBRUSH hbr = NULL;
- if ((dwStyle & 0xFF) <= SS_RIGHT) {
-
- // this is a text control: set up font and colors
- if (!(HFONT)m_font) {
- // first time init: create font
- LOGFONT lf;
- GetFont()->GetObject(sizeof(lf), &lf);
- lf.lfUnderline = TRUE;
- m_font.CreateFontIndirect(&lf);
- }
-
- // use underline font and visited/unvisited colors
- pDC->SelectObject(&m_font);
- pDC->SetTextColor(m_color);
- pDC->SetBkMode(TRANSPARENT);
-
- // return hollow brush to preserve parent background color
- hbr = (HBRUSH)::GetStockObject(HOLLOW_BRUSH);
- }
- return hbr;
+ ASSERT(nCtlColor == CTLCOLOR_STATIC);
+ DWORD dwStyle = GetStyle();
+
+ HBRUSH hbr = NULL;
+ if ((dwStyle & 0xFF) <= SS_RIGHT) {
+
+ // this is a text control: set up font and colors
+ if (!(HFONT)m_font) {
+ // first time init: create font
+ LOGFONT lf;
+ GetFont()->GetObject(sizeof(lf), &lf);
+ lf.lfUnderline = TRUE;
+ m_font.CreateFontIndirect(&lf);
+ }
+
+ // use underline font and visited/unvisited colors
+ pDC->SelectObject(&m_font);
+ pDC->SetTextColor(m_color);
+ pDC->SetBkMode(TRANSPARENT);
+
+ // return hollow brush to preserve parent background color
+ hbr = (HBRUSH)::GetStockObject(HOLLOW_BRUSH);
+ }
+ return hbr;
}
/////////////////
@@ -100,26 +100,26 @@ HBRUSH CStaticLink::CtlColor(CDC* pDC, UINT nCtlColor)
//
void CStaticLink::OnLButtonDown(UINT nFlags, CPoint point)
{
- if (m_link.IsEmpty()) {
- // no link: try to load from resource string or window text
- m_link.LoadString(GetDlgCtrlID()) || (GetWindowText(m_link),1);
- if (m_link.IsEmpty()) {
- return;
- }
- }
-
- // Call ShellExecute to run the file.
- // For an URL, this means opening it in the browser.
- //
- HINSTANCE h = m_link.Navigate();
- if ((UINT_PTR)h > 32) { // success!
- m_color = g_colorVisited; // change color
- Invalidate(); // repaint
- } else {
- MessageBeep(0); // unable to execute file!
- TRACE(_T("*** WARNING: CStaticLink: unable to navigate link %s\n"),
- (LPCTSTR)m_link);
- }
+ if (m_link.IsEmpty()) {
+ // no link: try to load from resource string or window text
+ m_link.LoadString(GetDlgCtrlID()) || (GetWindowText(m_link), 1);
+ if (m_link.IsEmpty()) {
+ return;
+ }
+ }
+
+ // Call ShellExecute to run the file.
+ // For an URL, this means opening it in the browser.
+ //
+ HINSTANCE h = m_link.Navigate();
+ if ((UINT_PTR)h > 32) { // success!
+ m_color = g_colorVisited; // change color
+ Invalidate(); // repaint
+ } else {
+ MessageBeep(0); // unable to execute file!
+ TRACE(_T("*** WARNING: CStaticLink: unable to navigate link %s\n"),
+ (LPCTSTR)m_link);
+ }
}
//////////////////
@@ -127,8 +127,8 @@ void CStaticLink::OnLButtonDown(UINT nFlags, CPoint point)
//
BOOL CStaticLink::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
- ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_HAND));
- return TRUE;
+ ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_HAND));
+ return TRUE;
}
//////////////////
@@ -141,7 +141,7 @@ BOOL CStaticLink::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
//
void CStaticLink::PostNcDestroy()
{
- if (m_bDeleteOnDestroy) {
- delete this;
- }
+ if (m_bDeleteOnDestroy) {
+ delete this;
+ }
}
diff --git a/src/mpc-hc/StaticLink.h b/src/mpc-hc/StaticLink.h
index ffd98bdb5..f05327aee 100644
--- a/src/mpc-hc/StaticLink.h
+++ b/src/mpc-hc/StaticLink.h
@@ -29,19 +29,19 @@
class CHyperlink : public CString
{
public:
- CHyperlink(LPCTSTR lpLink = NULL) : CString(lpLink) { }
- ~CHyperlink() { }
- const CHyperlink& operator=(LPCTSTR lpsz) {
- CString::operator=(lpsz);
- return *this;
- }
- operator LPCTSTR() {
- return CString::operator LPCTSTR();
- }
- /*virtual*/ HINSTANCE Navigate() {
- return IsEmpty() ? NULL :
- ShellExecute(0, _T("open"), *this, 0, 0, SW_SHOWNORMAL);
- }
+ CHyperlink(LPCTSTR lpLink = NULL) : CString(lpLink) { }
+ ~CHyperlink() { }
+ const CHyperlink& operator=(LPCTSTR lpsz) {
+ CString::operator=(lpsz);
+ return *this;
+ }
+ operator LPCTSTR() {
+ return CString::operator LPCTSTR();
+ }
+ /*virtual*/ HINSTANCE Navigate() {
+ return IsEmpty() ? NULL :
+ ShellExecute(0, _T("open"), *this, 0, 0, SW_SHOWNORMAL);
+ }
};
// CStaticLink
@@ -49,30 +49,30 @@ public:
class CStaticLink : public CStatic
{
public:
- DECLARE_DYNAMIC(CStaticLink)
- CStaticLink(LPCTSTR lpText = NULL, bool bDeleteOnDestroy = false);
- ~CStaticLink() { }
+ DECLARE_DYNAMIC(CStaticLink)
+ CStaticLink(LPCTSTR lpText = NULL, bool bDeleteOnDestroy = false);
+ ~CStaticLink() { }
- // Hyperlink contains URL/filename. If NULL, I will use the window text.
- // (GetWindowText) to get the target.
- CHyperlink m_link;
- COLORREF m_color;
+ // Hyperlink contains URL/filename. If NULL, I will use the window text.
+ // (GetWindowText) to get the target.
+ CHyperlink m_link;
+ COLORREF m_color;
- // Default colors you can change
- // These are global, so they're the same for all links.
- static COLORREF g_colorUnvisited;
- static COLORREF g_colorVisited;
+ // Default colors you can change
+ // These are global, so they're the same for all links.
+ static COLORREF g_colorUnvisited;
+ static COLORREF g_colorVisited;
protected:
- CFont m_font; // underline font for text control
- bool m_bDeleteOnDestroy; // delete object when window destroyed?
+ CFont m_font; // underline font for text control
+ bool m_bDeleteOnDestroy; // delete object when window destroyed?
- virtual void PostNcDestroy();
+ virtual void PostNcDestroy();
- // message handlers
- DECLARE_MESSAGE_MAP()
- afx_msg LRESULT OnNcHitTest(CPoint point);
- afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
+ // message handlers
+ DECLARE_MESSAGE_MAP()
+ afx_msg LRESULT OnNcHitTest(CPoint point);
+ afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
+ afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
+ afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
};
diff --git a/src/mpc-hc/StatusLabel.cpp b/src/mpc-hc/StatusLabel.cpp
index 8f185c1ac..b72d30b1e 100644
--- a/src/mpc-hc/StatusLabel.cpp
+++ b/src/mpc-hc/StatusLabel.cpp
@@ -32,23 +32,22 @@
IMPLEMENT_DYNAMIC(CStatusLabel, CStatic)
CStatusLabel::CStatusLabel(bool fRightAlign, bool fAddEllipses)
- : m_fRightAlign(fRightAlign)
- , m_fAddEllipses(fAddEllipses)
+ : m_fRightAlign(fRightAlign)
+ , m_fAddEllipses(fAddEllipses)
{
- m_font.m_hObject = NULL;
- if (SysVersion::IsVistaOrLater()) {
- LOGFONT lf;
- GetStatusFont(&lf);
- VERIFY(m_font.CreateFontIndirect(&lf));
- }
- else {
- HDC hdc = ::GetDC(NULL);
- double scale = 1.0*GetDeviceCaps(hdc, LOGPIXELSY) / 96.0;
- ::ReleaseDC(0, hdc);
- VERIFY(m_font.CreateFont(int(14 * scale), 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET,
- OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE,
- _T("Microsoft Sans Serif")));
- }
+ m_font.m_hObject = NULL;
+ if (SysVersion::IsVistaOrLater()) {
+ LOGFONT lf;
+ GetStatusFont(&lf);
+ VERIFY(m_font.CreateFontIndirect(&lf));
+ } else {
+ HDC hdc = ::GetDC(NULL);
+ double scale = 1.0 * GetDeviceCaps(hdc, LOGPIXELSY) / 96.0;
+ ::ReleaseDC(0, hdc);
+ VERIFY(m_font.CreateFont(int(14 * scale), 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET,
+ OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
+ _T("Microsoft Sans Serif")));
+ }
}
CStatusLabel::~CStatusLabel()
@@ -56,42 +55,42 @@ CStatusLabel::~CStatusLabel()
}
BEGIN_MESSAGE_MAP(CStatusLabel, CStatic)
- ON_WM_ERASEBKGND()
+ ON_WM_ERASEBKGND()
END_MESSAGE_MAP()
// CStatusLabel message handlers
void CStatusLabel::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
- CDC dc;
- dc.Attach(lpDrawItemStruct->hDC);
- CString str;
- GetWindowText(str);
- CRect r;
- GetClientRect(&r);
- CFont* old = dc.SelectObject(&m_font);
- dc.SetTextColor(0xffffff);
- dc.SetBkColor(0);
- CSize size = dc.GetTextExtent(str);
- CPoint p = CPoint(m_fRightAlign ? r.Width() - size.cx : 0, (r.Height()-size.cy)/2);
+ CDC dc;
+ dc.Attach(lpDrawItemStruct->hDC);
+ CString str;
+ GetWindowText(str);
+ CRect r;
+ GetClientRect(&r);
+ CFont* old = dc.SelectObject(&m_font);
+ dc.SetTextColor(0xffffff);
+ dc.SetBkColor(0);
+ CSize size = dc.GetTextExtent(str);
+ CPoint p = CPoint(m_fRightAlign ? r.Width() - size.cx : 0, (r.Height() - size.cy) / 2);
- if (m_fAddEllipses)
- while (size.cx > r.Width()-3 && str.GetLength() > 3) {
- str = str.Left(str.GetLength()-4) + _T("...");
- size = dc.GetTextExtent(str);
- }
+ if (m_fAddEllipses)
+ while (size.cx > r.Width() - 3 && str.GetLength() > 3) {
+ str = str.Left(str.GetLength() - 4) + _T("...");
+ size = dc.GetTextExtent(str);
+ }
- dc.TextOut(p.x, p.y, str);
- dc.ExcludeClipRect(CRect(p, size));
- dc.SelectObject(&old);
- dc.FillSolidRect(&r, 0);
- dc.Detach();
+ dc.TextOut(p.x, p.y, str);
+ dc.ExcludeClipRect(CRect(p, size));
+ dc.SelectObject(&old);
+ dc.FillSolidRect(&r, 0);
+ dc.Detach();
}
BOOL CStatusLabel::OnEraseBkgnd(CDC* pDC)
{
- CRect r;
- GetClientRect(&r);
- pDC->FillSolidRect(&r, 0);
- return TRUE;
+ CRect r;
+ GetClientRect(&r);
+ pDC->FillSolidRect(&r, 0);
+ return TRUE;
}
diff --git a/src/mpc-hc/StatusLabel.h b/src/mpc-hc/StatusLabel.h
index 1fb535def..6f0398af6 100644
--- a/src/mpc-hc/StatusLabel.h
+++ b/src/mpc-hc/StatusLabel.h
@@ -28,23 +28,23 @@
class CStatusLabel : public CStatic
{
- DECLARE_DYNAMIC(CStatusLabel)
+ DECLARE_DYNAMIC(CStatusLabel)
private:
- bool m_fRightAlign, m_fAddEllipses;
- CFont m_font;
+ bool m_fRightAlign, m_fAddEllipses;
+ CFont m_font;
public:
- CStatusLabel(bool fRightAlign, bool fAddEllipses);
- virtual ~CStatusLabel();
+ CStatusLabel(bool fRightAlign, bool fAddEllipses);
+ virtual ~CStatusLabel();
- CFont& GetFont() {return m_font;}
+ CFont& GetFont() {return m_font;}
- void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
+ void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
protected:
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
+ afx_msg BOOL OnEraseBkgnd(CDC* pDC);
};
diff --git a/src/mpc-hc/SubtitleDlDlg.cpp b/src/mpc-hc/SubtitleDlDlg.cpp
index 039b24730..d3b31af3e 100644
--- a/src/mpc-hc/SubtitleDlDlg.cpp
+++ b/src/mpc-hc/SubtitleDlDlg.cpp
@@ -31,353 +31,353 @@
#define UWM_FAILED (WM_USER + 101)
CSubtitleDlDlg::CSubtitleDlDlg(CWnd* pParent, const CStringA& url)
- : CResizableDialog(CSubtitleDlDlg::IDD, pParent),
- m_url(url), ps(m_list.GetSafeHwnd(), 0, TRUE), m_status()
+ : CResizableDialog(CSubtitleDlDlg::IDD, pParent),
+ m_url(url), ps(m_list.GetSafeHwnd(), 0, TRUE), m_status()
{
}
CSubtitleDlDlg::~CSubtitleDlDlg()
{
- delete m_pTA;
+ delete m_pTA;
}
void CSubtitleDlDlg::DoDataExchange(CDataExchange* pDX)
{
- __super::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_LIST1, m_list);
+ __super::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_LIST1, m_list);
}
void CSubtitleDlDlg::LoadList()
{
- m_list.SetRedraw(FALSE);
- for (int i = 0; i < m_parsed_movies.GetCount(); ++i) {
- isdb_movie_parsed& m = m_parsed_movies[i];
-
- int iItem = m_list.InsertItem(i, _T(""));
- m_list.SetItemData(iItem, m.ptr);
- m_list.SetItemText(iItem, COL_FILENAME, m.name);
- m_list.SetItemText(iItem, COL_LANGUAGE, m.language);
- m_list.SetItemText(iItem, COL_FORMAT, m.format);
- m_list.SetItemText(iItem, COL_DISC, m.disc);
- m_list.SetItemText(iItem, COL_TITLES, m.titles);
- m_list.SetCheck(iItem, m.checked);
- }
-
- m_list.SetRedraw(TRUE);
- m_list.Invalidate();
- m_list.UpdateWindow();
+ m_list.SetRedraw(FALSE);
+ for (int i = 0; i < m_parsed_movies.GetCount(); ++i) {
+ isdb_movie_parsed& m = m_parsed_movies[i];
+
+ int iItem = m_list.InsertItem(i, _T(""));
+ m_list.SetItemData(iItem, m.ptr);
+ m_list.SetItemText(iItem, COL_FILENAME, m.name);
+ m_list.SetItemText(iItem, COL_LANGUAGE, m.language);
+ m_list.SetItemText(iItem, COL_FORMAT, m.format);
+ m_list.SetItemText(iItem, COL_DISC, m.disc);
+ m_list.SetItemText(iItem, COL_TITLES, m.titles);
+ m_list.SetCheck(iItem, m.checked);
+ }
+
+ m_list.SetRedraw(TRUE);
+ m_list.Invalidate();
+ m_list.UpdateWindow();
}
bool CSubtitleDlDlg::Parse()
{
- // Parse raw list
- isdb_movie m;
- isdb_subtitle sub;
-
- CAtlList<CStringA> sl;
- Explode(m_pTA->raw_list, sl, '\n');
- CString str;
-
- POSITION pos = sl.GetHeadPosition();
- while (pos) {
- str = sl.GetNext(pos);
-
- CStringA param = str.Left(max(0, str.Find('=')));
- CStringA value = str.Mid(str.Find('=')+1);
-
- if (param == "ticket") {
- m_pTA->ticket = value;
- } else if (param == "movie") {
- m.reset();
- Explode(value, m.titles, '|');
- } else if (param == "subtitle") {
- sub.reset();
- sub.id = atoi(value);
- } else if (param == "name") {
- sub.name = value;
- } else if (param == "discs") {
- sub.discs = atoi(value);
- } else if (param == "disc_no") {
- sub.disc_no = atoi(value);
- } else if (param == "format") {
- sub.format = value;
- } else if (param == "iso639_2") {
- sub.iso639_2 = value;
- } else if (param == "language") {
- sub.language = value;
- } else if (param == "nick") {
- sub.nick = value;
- } else if (param == "email") {
- sub.email = value;
- } else if (param == "" && value == "endsubtitle") {
- m.subs.AddTail(sub);
- } else if (param == "" && value == "endmovie") {
- m_pTA->raw_movies.AddTail(m);
- } else if (param == "" && value == "end") {
- break;
- }
- }
-
- // Parse movies
- pos = m_pTA->raw_movies.GetHeadPosition();
- while (pos) {
- isdb_movie& m = m_pTA->raw_movies.GetNext(pos);
- isdb_movie_parsed p;
-
- CStringA titlesA = Implode(m.titles, '|');
- titlesA.Replace("|", ", ");
- p.titles = UTF8To16(titlesA);
- p.checked = false;
-
- POSITION pos2 = m.subs.GetHeadPosition();
- while (pos2) {
- const isdb_subtitle& s = m.subs.GetNext(pos2);
- p.name = UTF8To16(s.name);
- p.language = s.language;
- p.format = s.format;
- p.disc.Format(_T("%d/%d"), s.disc_no, s.discs);
- p.ptr = reinterpret_cast<DWORD_PTR>(&s);
-
- m_parsed_movies.Add(p);
- }
- }
-
- bool ret = true;
- if (m_parsed_movies.GetCount() == 0) {
- ret = false;
- }
-
- return ret;
+ // Parse raw list
+ isdb_movie m;
+ isdb_subtitle sub;
+
+ CAtlList<CStringA> sl;
+ Explode(m_pTA->raw_list, sl, '\n');
+ CString str;
+
+ POSITION pos = sl.GetHeadPosition();
+ while (pos) {
+ str = sl.GetNext(pos);
+
+ CStringA param = str.Left(max(0, str.Find('=')));
+ CStringA value = str.Mid(str.Find('=') + 1);
+
+ if (param == "ticket") {
+ m_pTA->ticket = value;
+ } else if (param == "movie") {
+ m.reset();
+ Explode(value, m.titles, '|');
+ } else if (param == "subtitle") {
+ sub.reset();
+ sub.id = atoi(value);
+ } else if (param == "name") {
+ sub.name = value;
+ } else if (param == "discs") {
+ sub.discs = atoi(value);
+ } else if (param == "disc_no") {
+ sub.disc_no = atoi(value);
+ } else if (param == "format") {
+ sub.format = value;
+ } else if (param == "iso639_2") {
+ sub.iso639_2 = value;
+ } else if (param == "language") {
+ sub.language = value;
+ } else if (param == "nick") {
+ sub.nick = value;
+ } else if (param == "email") {
+ sub.email = value;
+ } else if (param == "" && value == "endsubtitle") {
+ m.subs.AddTail(sub);
+ } else if (param == "" && value == "endmovie") {
+ m_pTA->raw_movies.AddTail(m);
+ } else if (param == "" && value == "end") {
+ break;
+ }
+ }
+
+ // Parse movies
+ pos = m_pTA->raw_movies.GetHeadPosition();
+ while (pos) {
+ isdb_movie& m = m_pTA->raw_movies.GetNext(pos);
+ isdb_movie_parsed p;
+
+ CStringA titlesA = Implode(m.titles, '|');
+ titlesA.Replace("|", ", ");
+ p.titles = UTF8To16(titlesA);
+ p.checked = false;
+
+ POSITION pos2 = m.subs.GetHeadPosition();
+ while (pos2) {
+ const isdb_subtitle& s = m.subs.GetNext(pos2);
+ p.name = UTF8To16(s.name);
+ p.language = s.language;
+ p.format = s.format;
+ p.disc.Format(_T("%d/%d"), s.disc_no, s.discs);
+ p.ptr = reinterpret_cast<DWORD_PTR>(&s);
+
+ m_parsed_movies.Add(p);
+ }
+ }
+
+ bool ret = true;
+ if (m_parsed_movies.GetCount() == 0) {
+ ret = false;
+ }
+
+ return ret;
}
void CSubtitleDlDlg::SetStatus(const CString& status)
{
- m_status.SetText(status, 0, 0);
+ m_status.SetText(status, 0, 0);
}
-UINT CSubtitleDlDlg::RunThread(LPVOID pParam) {
- PTHREADSTRUCT pTA = reinterpret_cast<PTHREADSTRUCT>(pParam);
+UINT CSubtitleDlDlg::RunThread(LPVOID pParam)
+{
+ PTHREADSTRUCT pTA = reinterpret_cast<PTHREADSTRUCT>(pParam);
- if (!OpenUrl(pTA->is, CString(pTA->url), pTA->raw_list)) {
- ::PostMessage(pTA->hWND, UWM_FAILED, (WPARAM)0, (LPARAM)0);
- AfxEndThread(1, TRUE);
- }
+ if (!OpenUrl(pTA->is, CString(pTA->url), pTA->raw_list)) {
+ ::PostMessage(pTA->hWND, UWM_FAILED, (WPARAM)0, (LPARAM)0);
+ AfxEndThread(1, TRUE);
+ }
- ::PostMessage(pTA->hWND, UWM_PARSE, (WPARAM)0, (LPARAM)0);
+ ::PostMessage(pTA->hWND, UWM_PARSE, (WPARAM)0, (LPARAM)0);
- return 0;
+ return 0;
};
int CALLBACK CSubtitleDlDlg::SortCompare(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
- PPARAMSORT ps = reinterpret_cast<PPARAMSORT>(lParamSort);
- TCHAR left[256] = _T(""), right[256] = _T("");
+ PPARAMSORT ps = reinterpret_cast<PPARAMSORT>(lParamSort);
+ TCHAR left[256] = _T(""), right[256] = _T("");
- ListView_GetItemText(ps->m_hWnd, lParam1, ps->m_colIndex, left, sizeof(left));
- ListView_GetItemText(ps->m_hWnd, lParam2, ps->m_colIndex, right, sizeof(right));
+ ListView_GetItemText(ps->m_hWnd, lParam1, ps->m_colIndex, left, sizeof(left));
+ ListView_GetItemText(ps->m_hWnd, lParam2, ps->m_colIndex, right, sizeof(right));
- if (ps->m_ascending) {
- return _tcscmp(left, right);
- } else {
- return _tcscmp(right, left);
- }
+ if (ps->m_ascending) {
+ return _tcscmp(left, right);
+ } else {
+ return _tcscmp(right, left);
+ }
}
BOOL CSubtitleDlDlg::OnInitDialog()
{
- __super::OnInitDialog();
-
- m_status.Create(WS_CHILD|WS_VISIBLE|CCS_BOTTOM, CRect(0,0,0,0), this, IDC_STATUSBAR);
-
- int n, curPos = 0;
- CArray<int> columnWidth;
-
- CString strColumnWidth = AfxGetApp()->GetProfileString(IDS_R_DLG_SUBTITLEDL, IDS_RS_DLG_SUBTITLEDL_COLWIDTH, _T(""));
- CString token = strColumnWidth.Tokenize(_T(","), curPos);
- while (!token.IsEmpty()) {
- if (_stscanf_s(token, L"%i", &n) == 1) {
- columnWidth.Add(n);
- token = strColumnWidth.Tokenize(_T(","), curPos);
- } else {
- throw 1;
- }
- }
-
- m_list.SetExtendedStyle(m_list.GetExtendedStyle()
- | LVS_EX_DOUBLEBUFFER | LVS_EX_FULLROWSELECT
- | LVS_EX_CHECKBOXES | LVS_EX_LABELTIP);
-
- if (columnWidth.GetCount() != 5) {
- // default sizes
- columnWidth.RemoveAll();
- columnWidth.Add(290);
- columnWidth.Add(70);
- columnWidth.Add(50);
- columnWidth.Add(50);
- columnWidth.Add(270);
- }
-
- m_list.InsertColumn(COL_FILENAME, ResStr(IDS_SUBDL_DLG_FILENAME_COL), LVCFMT_LEFT, columnWidth[0]);
- m_list.InsertColumn(COL_LANGUAGE, ResStr(IDS_SUBDL_DLG_LANGUAGE_COL), LVCFMT_CENTER, columnWidth[1]);
- m_list.InsertColumn(COL_FORMAT, ResStr(IDS_SUBDL_DLG_FORMAT_COL), LVCFMT_CENTER, columnWidth[2]);
- m_list.InsertColumn(COL_DISC, ResStr(IDS_SUBDL_DLG_DISC_COL), LVCFMT_CENTER, columnWidth[3]);
- m_list.InsertColumn(COL_TITLES, ResStr(IDS_SUBDL_DLG_TITLES_COL), LVCFMT_LEFT, columnWidth[4]);
-
- AddAnchor(IDC_LIST1, TOP_LEFT, BOTTOM_RIGHT);
- AddAnchor(IDC_CHECK1, BOTTOM_LEFT);
- AddAnchor(IDOK, BOTTOM_RIGHT);
- AddAnchor(IDC_STATUSBAR, BOTTOM_LEFT, BOTTOM_RIGHT);
-
- const CSize s(420, 200);
- SetMinTrackSize(s);
- EnableSaveRestore(IDS_R_DLG_SUBTITLEDL);
-
- // start new worker thread to download the list of subtitles
- m_pTA = DNew THREADSTRUCT;
- m_pTA->url = m_url;
- m_pTA->hWND = GetSafeHwnd();
-
- SetStatus(ResStr(IDS_SUBDL_DLG_DOWNLOADING));
- AfxBeginThread(RunThread, static_cast<LPVOID>(m_pTA));
-
- return TRUE;
+ __super::OnInitDialog();
+
+ m_status.Create(WS_CHILD | WS_VISIBLE | CCS_BOTTOM, CRect(0, 0, 0, 0), this, IDC_STATUSBAR);
+
+ int n, curPos = 0;
+ CArray<int> columnWidth;
+
+ CString strColumnWidth = AfxGetApp()->GetProfileString(IDS_R_DLG_SUBTITLEDL, IDS_RS_DLG_SUBTITLEDL_COLWIDTH, _T(""));
+ CString token = strColumnWidth.Tokenize(_T(","), curPos);
+ while (!token.IsEmpty()) {
+ if (_stscanf_s(token, L"%i", &n) == 1) {
+ columnWidth.Add(n);
+ token = strColumnWidth.Tokenize(_T(","), curPos);
+ } else {
+ throw 1;
+ }
+ }
+
+ m_list.SetExtendedStyle(m_list.GetExtendedStyle()
+ | LVS_EX_DOUBLEBUFFER | LVS_EX_FULLROWSELECT
+ | LVS_EX_CHECKBOXES | LVS_EX_LABELTIP);
+
+ if (columnWidth.GetCount() != 5) {
+ // default sizes
+ columnWidth.RemoveAll();
+ columnWidth.Add(290);
+ columnWidth.Add(70);
+ columnWidth.Add(50);
+ columnWidth.Add(50);
+ columnWidth.Add(270);
+ }
+
+ m_list.InsertColumn(COL_FILENAME, ResStr(IDS_SUBDL_DLG_FILENAME_COL), LVCFMT_LEFT, columnWidth[0]);
+ m_list.InsertColumn(COL_LANGUAGE, ResStr(IDS_SUBDL_DLG_LANGUAGE_COL), LVCFMT_CENTER, columnWidth[1]);
+ m_list.InsertColumn(COL_FORMAT, ResStr(IDS_SUBDL_DLG_FORMAT_COL), LVCFMT_CENTER, columnWidth[2]);
+ m_list.InsertColumn(COL_DISC, ResStr(IDS_SUBDL_DLG_DISC_COL), LVCFMT_CENTER, columnWidth[3]);
+ m_list.InsertColumn(COL_TITLES, ResStr(IDS_SUBDL_DLG_TITLES_COL), LVCFMT_LEFT, columnWidth[4]);
+
+ AddAnchor(IDC_LIST1, TOP_LEFT, BOTTOM_RIGHT);
+ AddAnchor(IDC_CHECK1, BOTTOM_LEFT);
+ AddAnchor(IDOK, BOTTOM_RIGHT);
+ AddAnchor(IDC_STATUSBAR, BOTTOM_LEFT, BOTTOM_RIGHT);
+
+ const CSize s(420, 200);
+ SetMinTrackSize(s);
+ EnableSaveRestore(IDS_R_DLG_SUBTITLEDL);
+
+ // start new worker thread to download the list of subtitles
+ m_pTA = DNew THREADSTRUCT;
+ m_pTA->url = m_url;
+ m_pTA->hWND = GetSafeHwnd();
+
+ SetStatus(ResStr(IDS_SUBDL_DLG_DOWNLOADING));
+ AfxBeginThread(RunThread, static_cast<LPVOID>(m_pTA));
+
+ return TRUE;
}
void CSubtitleDlDlg::OnOK()
{
- SetStatus(ResStr(IDS_SUBDL_DLG_DOWNLOADING));
-
- for (int i = 0; i < m_list.GetItemCount(); ++i) {
- if (m_list.GetCheck(i)) {
- m_selsubs.AddTail(*reinterpret_cast<isdb_subtitle*>(m_list.GetItemData(i)));
- }
- }
-
- m_fReplaceSubs = IsDlgButtonChecked(IDC_CHECK1) == BST_CHECKED;
-
- CMainFrame* pMF = static_cast<CMainFrame*>(GetParentFrame());
-
- if (m_fReplaceSubs) {
- pMF->m_pSubStreams.RemoveAll();
- }
-
- CComPtr<ISubStream> pSubStreamToSet;
-
- POSITION pos = m_selsubs.GetHeadPosition();
- while (pos) {
- const isdb_subtitle& sub = m_selsubs.GetNext(pos);
- AppSettings& s = AfxGetAppSettings();
- CInternetSession is;
- CStringA url = "http://" + s.strISDb + "/dl.php?";
- CStringA args, ticket, str;
- args.Format("id=%d&ticket=%s", sub.id, UrlEncode(ticket));
- url.Append(args);
-
- if (OpenUrl(is, CString(url), str)) {
- CAutoPtr<CRenderedTextSubtitle> pRTS(DNew CRenderedTextSubtitle(&pMF->m_csSubLock, &s.subdefstyle, s.fUseDefaultSubtitlesStyle));
- if (pRTS && pRTS->Open((BYTE*)(LPCSTR)str, str.GetLength(), DEFAULT_CHARSET, CString(sub.name)) && pRTS->GetStreamCount() > 0) {
- CComPtr<ISubStream> pSubStream = pRTS.Detach();
- pMF->m_pSubStreams.AddTail(pSubStream);
- if (!pSubStreamToSet) {
- pSubStreamToSet = pSubStream;
- }
- }
- }
- }
-
- if (pSubStreamToSet) {
- pMF->SetSubtitle(pSubStreamToSet);
- }
-
- __super::OnOK();
+ SetStatus(ResStr(IDS_SUBDL_DLG_DOWNLOADING));
+
+ for (int i = 0; i < m_list.GetItemCount(); ++i) {
+ if (m_list.GetCheck(i)) {
+ m_selsubs.AddTail(*reinterpret_cast<isdb_subtitle*>(m_list.GetItemData(i)));
+ }
+ }
+
+ m_fReplaceSubs = IsDlgButtonChecked(IDC_CHECK1) == BST_CHECKED;
+
+ CMainFrame* pMF = static_cast<CMainFrame*>(GetParentFrame());
+
+ if (m_fReplaceSubs) {
+ pMF->m_pSubStreams.RemoveAll();
+ }
+
+ CComPtr<ISubStream> pSubStreamToSet;
+
+ POSITION pos = m_selsubs.GetHeadPosition();
+ while (pos) {
+ const isdb_subtitle& sub = m_selsubs.GetNext(pos);
+ AppSettings& s = AfxGetAppSettings();
+ CInternetSession is;
+ CStringA url = "http://" + s.strISDb + "/dl.php?";
+ CStringA args, ticket, str;
+ args.Format("id=%d&ticket=%s", sub.id, UrlEncode(ticket));
+ url.Append(args);
+
+ if (OpenUrl(is, CString(url), str)) {
+ CAutoPtr<CRenderedTextSubtitle> pRTS(DNew CRenderedTextSubtitle(&pMF->m_csSubLock, &s.subdefstyle, s.fUseDefaultSubtitlesStyle));
+ if (pRTS && pRTS->Open((BYTE*)(LPCSTR)str, str.GetLength(), DEFAULT_CHARSET, CString(sub.name)) && pRTS->GetStreamCount() > 0) {
+ CComPtr<ISubStream> pSubStream = pRTS.Detach();
+ pMF->m_pSubStreams.AddTail(pSubStream);
+ if (!pSubStreamToSet) {
+ pSubStreamToSet = pSubStream;
+ }
+ }
+ }
+ }
+
+ if (pSubStreamToSet) {
+ pMF->SetSubtitle(pSubStreamToSet);
+ }
+
+ __super::OnOK();
}
void CSubtitleDlDlg::OnUpdateOk(CCmdUI* pCmdUI)
{
- bool fEnable = false;
- for (int i = 0; !fEnable && i < m_list.GetItemCount(); ++i) {
- fEnable = !!m_list.GetCheck(i);
- }
+ bool fEnable = false;
+ for (int i = 0; !fEnable && i < m_list.GetItemCount(); ++i) {
+ fEnable = !!m_list.GetCheck(i);
+ }
- pCmdUI->Enable(fEnable);
+ pCmdUI->Enable(fEnable);
}
void CSubtitleDlDlg::OnFailedConnection()
{
- SetStatus(ResStr(IDS_SUBDL_DLG_CONNECT_ERROR));
+ SetStatus(ResStr(IDS_SUBDL_DLG_CONNECT_ERROR));
}
void CSubtitleDlDlg::OnParse()
{
- SetStatus(ResStr(IDS_SUBDL_DLG_PARSING));
- if (Parse()) {
- LoadList();
- CString msg;
- msg.Format(IDS_SUBDL_DLG_SUBS_AVAIL, m_list.GetItemCount());
- SetStatus(msg);
- }
- else {
- SetStatus(ResStr(IDS_SUBDL_DLG_NOT_FOUND));
- }
+ SetStatus(ResStr(IDS_SUBDL_DLG_PARSING));
+ if (Parse()) {
+ LoadList();
+ CString msg;
+ msg.Format(IDS_SUBDL_DLG_SUBS_AVAIL, m_list.GetItemCount());
+ SetStatus(msg);
+ } else {
+ SetStatus(ResStr(IDS_SUBDL_DLG_NOT_FOUND));
+ }
}
-void CSubtitleDlDlg::OnColumnClick(NMHDR *pNMHDR, LRESULT *pResult)
+void CSubtitleDlDlg::OnColumnClick(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMHEADER phdr = reinterpret_cast<LPNMHEADER>(pNMHDR);
- *pResult = 0;
-
- if (phdr->iItem == ps.m_colIndex) {
- ps.m_ascending = !ps.m_ascending;
- } else {
- ps.m_ascending = TRUE;
- }
- ps.m_colIndex = phdr->iItem;
- ps.m_hWnd = m_list.GetSafeHwnd();
-
- SetRedraw(FALSE);
- ListView_SortItemsEx(m_list.GetSafeHwnd(), SortCompare, &ps);
- SetRedraw(TRUE);
- m_list.Invalidate();
- m_list.UpdateWindow();
+ LPNMHEADER phdr = reinterpret_cast<LPNMHEADER>(pNMHDR);
+ *pResult = 0;
+
+ if (phdr->iItem == ps.m_colIndex) {
+ ps.m_ascending = !ps.m_ascending;
+ } else {
+ ps.m_ascending = TRUE;
+ }
+ ps.m_colIndex = phdr->iItem;
+ ps.m_hWnd = m_list.GetSafeHwnd();
+
+ SetRedraw(FALSE);
+ ListView_SortItemsEx(m_list.GetSafeHwnd(), SortCompare, &ps);
+ SetRedraw(TRUE);
+ m_list.Invalidate();
+ m_list.UpdateWindow();
}
void CSubtitleDlDlg::OnSize(UINT nType, int cx, int cy)
{
- __super::OnSize(nType, cx, cy);
+ __super::OnSize(nType, cx, cy);
- ArrangeLayout();
+ ArrangeLayout();
}
void CSubtitleDlDlg::OnDestroy()
{
- RemoveAllAnchors();
+ RemoveAllAnchors();
- const CHeaderCtrl& pHC = *m_list.GetHeaderCtrl();
- CString strColumnWidth;
- int w;
+ const CHeaderCtrl& pHC = *m_list.GetHeaderCtrl();
+ CString strColumnWidth;
+ int w;
- for (int i = 0; i < pHC.GetItemCount(); ++i) {
- w = m_list.GetColumnWidth(i);
- strColumnWidth.AppendFormat(L"%d,", w);
- }
- AfxGetApp()->WriteProfileString(IDS_R_DLG_SUBTITLEDL, IDS_RS_DLG_SUBTITLEDL_COLWIDTH, strColumnWidth);
+ for (int i = 0; i < pHC.GetItemCount(); ++i) {
+ w = m_list.GetColumnWidth(i);
+ strColumnWidth.AppendFormat(L"%d,", w);
+ }
+ AfxGetApp()->WriteProfileString(IDS_R_DLG_SUBTITLEDL, IDS_RS_DLG_SUBTITLEDL_COLWIDTH, strColumnWidth);
- __super::OnDestroy();
+ __super::OnDestroy();
}
BOOL CSubtitleDlDlg::OnEraseBkgnd(CDC* pDC)
{
- EraseBackground(pDC);
+ EraseBackground(pDC);
- return TRUE;
+ return TRUE;
}
BEGIN_MESSAGE_MAP(CSubtitleDlDlg, CResizableDialog)
- ON_WM_ERASEBKGND()
- ON_WM_SIZE()
- ON_MESSAGE_VOID(UWM_PARSE, OnParse)
- ON_MESSAGE_VOID(UWM_FAILED, OnFailedConnection)
- ON_UPDATE_COMMAND_UI(IDOK, OnUpdateOk)
- ON_NOTIFY(HDN_ITEMCLICK, 0, OnColumnClick)
- ON_WM_DESTROY()
+ ON_WM_ERASEBKGND()
+ ON_WM_SIZE()
+ ON_MESSAGE_VOID(UWM_PARSE, OnParse)
+ ON_MESSAGE_VOID(UWM_FAILED, OnFailedConnection)
+ ON_UPDATE_COMMAND_UI(IDOK, OnUpdateOk)
+ ON_NOTIFY(HDN_ITEMCLICK, 0, OnColumnClick)
+ ON_WM_DESTROY()
END_MESSAGE_MAP()
diff --git a/src/mpc-hc/SubtitleDlDlg.h b/src/mpc-hc/SubtitleDlDlg.h
index 56915ca6e..f58ca9659 100644
--- a/src/mpc-hc/SubtitleDlDlg.h
+++ b/src/mpc-hc/SubtitleDlDlg.h
@@ -32,72 +32,72 @@ class CInternetSession;
class CSubtitleDlDlg : public CResizableDialog
{
private:
- struct isdb_movie_parsed {
- CString titles;
- CString name;
- CString language;
- CString format;
- CString disc;
- DWORD_PTR ptr;
- bool checked;
- };
+ struct isdb_movie_parsed {
+ CString titles;
+ CString name;
+ CString language;
+ CString format;
+ CString disc;
+ DWORD_PTR ptr;
+ bool checked;
+ };
- typedef struct THREADSTRUCT {
- HWND hWND;
- CInternetSession is;
- CStringA url;
- CStringA raw_list;
- CStringA ticket;
- CList<isdb_movie> raw_movies;
- } THREADSTRUCT, *PTHREADSTRUCT;
+ typedef struct THREADSTRUCT {
+ HWND hWND;
+ CInternetSession is;
+ CStringA url;
+ CStringA raw_list;
+ CStringA ticket;
+ CList<isdb_movie> raw_movies;
+ } THREADSTRUCT, *PTHREADSTRUCT;
- typedef struct PARAMSORT {
- PARAMSORT(HWND hWnd, UINT colIndex, BOOL ascending) :
- m_hWnd(hWnd),
- m_colIndex(colIndex),
- m_ascending(ascending)
- {}
- HWND m_hWnd;
- UINT m_colIndex;
- BOOL m_ascending;
- } PARAMSORT, *PPARAMSORT;
+ typedef struct PARAMSORT {
+ PARAMSORT(HWND hWnd, UINT colIndex, BOOL ascending) :
+ m_hWnd(hWnd),
+ m_colIndex(colIndex),
+ m_ascending(ascending)
+ {}
+ HWND m_hWnd;
+ UINT m_colIndex;
+ BOOL m_ascending;
+ } PARAMSORT, *PPARAMSORT;
- enum {COL_FILENAME, COL_LANGUAGE, COL_FORMAT, COL_DISC, COL_TITLES};
- PARAMSORT ps;
- PTHREADSTRUCT m_pTA;
+ enum {COL_FILENAME, COL_LANGUAGE, COL_FORMAT, COL_DISC, COL_TITLES};
+ PARAMSORT ps;
+ PTHREADSTRUCT m_pTA;
- CArray<isdb_movie_parsed> m_parsed_movies;
- CString m_url;
- bool m_fReplaceSubs;
+ CArray<isdb_movie_parsed> m_parsed_movies;
+ CString m_url;
+ bool m_fReplaceSubs;
- CListCtrl m_list;
- CList<isdb_subtitle> m_selsubs;
- CStatusBarCtrl m_status;
+ CListCtrl m_list;
+ CList<isdb_subtitle> m_selsubs;
+ CStatusBarCtrl m_status;
- void SetStatus(const CString& status);
- bool Parse();
- void LoadList();
+ void SetStatus(const CString& status);
+ bool Parse();
+ void LoadList();
- static UINT RunThread(LPVOID pParam);
- static int CALLBACK SortCompare(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
+ static UINT RunThread(LPVOID pParam);
+ static int CALLBACK SortCompare(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
public:
- explicit CSubtitleDlDlg(CWnd* pParent, const CStringA& url);
- virtual ~CSubtitleDlDlg();
+ explicit CSubtitleDlDlg(CWnd* pParent, const CStringA& url);
+ virtual ~CSubtitleDlDlg();
- enum { IDD = IDD_SUBTITLEDL_DLG };
+ enum { IDD = IDD_SUBTITLEDL_DLG };
protected:
- virtual void DoDataExchange(CDataExchange* pDX);
- virtual BOOL OnInitDialog();
- virtual void OnOK();
+ virtual void DoDataExchange(CDataExchange* pDX);
+ virtual BOOL OnInitDialog();
+ virtual void OnOK();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg void OnParse();
- afx_msg void OnFailedConnection();
- afx_msg void OnUpdateOk(CCmdUI* pCmdUI);
- afx_msg void OnColumnClick(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnDestroy();
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
+ afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg void OnParse();
+ afx_msg void OnFailedConnection();
+ afx_msg void OnUpdateOk(CCmdUI* pCmdUI);
+ afx_msg void OnColumnClick(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnDestroy();
+ afx_msg BOOL OnEraseBkgnd(CDC* pDC);
};
diff --git a/src/mpc-hc/TextPassThruFilter.cpp b/src/mpc-hc/TextPassThruFilter.cpp
index 860d4d706..3ddf7bc17 100644
--- a/src/mpc-hc/TextPassThruFilter.cpp
+++ b/src/mpc-hc/TextPassThruFilter.cpp
@@ -37,36 +37,36 @@
class CTextPassThruInputPin : public CSubtitleInputPin
{
- CTextPassThruFilter* m_pTPTFilter;
- CComPtr<ISubStream> m_pSubStreamOld;
+ CTextPassThruFilter* m_pTPTFilter;
+ CComPtr<ISubStream> m_pSubStreamOld;
protected:
- void AddSubStream(ISubStream* pSubStream) {
- if (m_pSubStreamOld) {
- if (pSubStream) {
- m_pTPTFilter->m_pMainFrame->ReplaceSubtitle(m_pSubStreamOld, pSubStream);
- }
- m_pSubStreamOld = NULL;
- }
- }
-
- void RemoveSubStream(ISubStream* pSubStream) {
- m_pSubStreamOld = pSubStream;
- }
-
- void InvalidateSubtitle(REFERENCE_TIME rtStart, ISubStream* pSubStream) {
- m_pTPTFilter->m_pMainFrame->InvalidateSubtitle((DWORD_PTR)pSubStream, rtStart);
- }
+ void AddSubStream(ISubStream* pSubStream) {
+ if (m_pSubStreamOld) {
+ if (pSubStream) {
+ m_pTPTFilter->m_pMainFrame->ReplaceSubtitle(m_pSubStreamOld, pSubStream);
+ }
+ m_pSubStreamOld = NULL;
+ }
+ }
+
+ void RemoveSubStream(ISubStream* pSubStream) {
+ m_pSubStreamOld = pSubStream;
+ }
+
+ void InvalidateSubtitle(REFERENCE_TIME rtStart, ISubStream* pSubStream) {
+ m_pTPTFilter->m_pMainFrame->InvalidateSubtitle((DWORD_PTR)pSubStream, rtStart);
+ }
public:
- CTextPassThruInputPin(CTextPassThruFilter* pTPTFilter, CCritSec* pLock, CCritSec* pSubLock, HRESULT* phr);
- STDMETHODIMP NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
- STDMETHODIMP Receive(IMediaSample* pSample);
- STDMETHODIMP EndOfStream();
- STDMETHODIMP BeginFlush();
- STDMETHODIMP EndFlush();
-
- HRESULT CompleteConnect(IPin* pReceivePin);
+ CTextPassThruInputPin(CTextPassThruFilter* pTPTFilter, CCritSec* pLock, CCritSec* pSubLock, HRESULT* phr);
+ STDMETHODIMP NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ STDMETHODIMP Receive(IMediaSample* pSample);
+ STDMETHODIMP EndOfStream();
+ STDMETHODIMP BeginFlush();
+ STDMETHODIMP EndFlush();
+
+ HRESULT CompleteConnect(IPin* pReceivePin);
};
//
@@ -75,138 +75,138 @@ public:
class CTextPassThruOutputPin : public CBaseOutputPin
{
- CTextPassThruFilter* m_pTPTFilter;
+ CTextPassThruFilter* m_pTPTFilter;
public:
- CTextPassThruOutputPin(CTextPassThruFilter* pTPTFilter, CCritSec* pLock, HRESULT* phr);
-
- HRESULT CheckMediaType(const CMediaType* mtOut);
- HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
- STDMETHODIMP Notify(IBaseFilter* pSender, Quality q) {
- return S_OK;
- }
+ CTextPassThruOutputPin(CTextPassThruFilter* pTPTFilter, CCritSec* pLock, HRESULT* phr);
+
+ HRESULT CheckMediaType(const CMediaType* mtOut);
+ HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT GetMediaType(int iPosition, CMediaType* pmt);
+ STDMETHODIMP Notify(IBaseFilter* pSender, Quality q) {
+ return S_OK;
+ }
};
///////////
CTextPassThruInputPin::CTextPassThruInputPin(CTextPassThruFilter* pTPTFilter, CCritSec* pLock, CCritSec* pSubLock, HRESULT* phr)
- : CSubtitleInputPin(pTPTFilter, pLock, pSubLock, phr)
- , m_pTPTFilter(pTPTFilter)
+ : CSubtitleInputPin(pTPTFilter, pLock, pSubLock, phr)
+ , m_pTPTFilter(pTPTFilter)
{
}
STDMETHODIMP CTextPassThruInputPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- HRESULT hr = __super::NewSegment(tStart, tStop, dRate);
- if (FAILED(hr)) {
- return hr;
- }
- return m_pTPTFilter->m_pOutput->DeliverNewSegment(tStart, tStop, dRate);
+ HRESULT hr = __super::NewSegment(tStart, tStop, dRate);
+ if (FAILED(hr)) {
+ return hr;
+ }
+ return m_pTPTFilter->m_pOutput->DeliverNewSegment(tStart, tStop, dRate);
}
STDMETHODIMP CTextPassThruInputPin::Receive(IMediaSample* pSample)
{
- HRESULT hr = __super::Receive(pSample);
- if (FAILED(hr)) {
- return hr;
- }
- return m_pTPTFilter->m_pOutput->Deliver(pSample);
+ HRESULT hr = __super::Receive(pSample);
+ if (FAILED(hr)) {
+ return hr;
+ }
+ return m_pTPTFilter->m_pOutput->Deliver(pSample);
}
STDMETHODIMP CTextPassThruInputPin::EndOfStream()
{
- HRESULT hr = __super::EndOfStream();
- if (FAILED(hr)) {
- return hr;
- }
- return m_pTPTFilter->m_pOutput->DeliverEndOfStream();
+ HRESULT hr = __super::EndOfStream();
+ if (FAILED(hr)) {
+ return hr;
+ }
+ return m_pTPTFilter->m_pOutput->DeliverEndOfStream();
}
STDMETHODIMP CTextPassThruInputPin::BeginFlush()
{
- HRESULT hr = __super::BeginFlush();
- if (FAILED(hr)) {
- return hr;
- }
- return m_pTPTFilter->m_pOutput->DeliverBeginFlush();
+ HRESULT hr = __super::BeginFlush();
+ if (FAILED(hr)) {
+ return hr;
+ }
+ return m_pTPTFilter->m_pOutput->DeliverBeginFlush();
}
STDMETHODIMP CTextPassThruInputPin::EndFlush()
{
- HRESULT hr = __super::EndFlush();
- if (FAILED(hr)) {
- return hr;
- }
- return m_pTPTFilter->m_pOutput->DeliverEndFlush();
+ HRESULT hr = __super::EndFlush();
+ if (FAILED(hr)) {
+ return hr;
+ }
+ return m_pTPTFilter->m_pOutput->DeliverEndFlush();
}
HRESULT CTextPassThruInputPin::CompleteConnect(IPin* pReceivePin)
{
- HRESULT hr = __super::CompleteConnect(pReceivePin);
- if (FAILED(hr) || !m_pTPTFilter->m_pOutput->IsConnected()) {
- return hr;
- }
- return m_pTPTFilter->ReconnectPin(m_pTPTFilter->m_pOutput, &m_mt);
+ HRESULT hr = __super::CompleteConnect(pReceivePin);
+ if (FAILED(hr) || !m_pTPTFilter->m_pOutput->IsConnected()) {
+ return hr;
+ }
+ return m_pTPTFilter->ReconnectPin(m_pTPTFilter->m_pOutput, &m_mt);
}
//
CTextPassThruOutputPin::CTextPassThruOutputPin(CTextPassThruFilter* pTPTFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseOutputPin(NAME(""), pTPTFilter, pLock, phr, L"Out")
- , m_pTPTFilter(pTPTFilter)
+ : CBaseOutputPin(NAME(""), pTPTFilter, pLock, phr, L"Out")
+ , m_pTPTFilter(pTPTFilter)
{
}
HRESULT CTextPassThruOutputPin::CheckMediaType(const CMediaType* mtOut)
{
- CMediaType mt;
- return S_OK == m_pTPTFilter->m_pInput->ConnectionMediaType(&mt) && mt == *mtOut
- ? S_OK
- : E_FAIL;
+ CMediaType mt;
+ return S_OK == m_pTPTFilter->m_pInput->ConnectionMediaType(&mt) && mt == *mtOut
+ ? S_OK
+ : E_FAIL;
}
HRESULT CTextPassThruOutputPin::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if (m_pTPTFilter->m_pInput->IsConnected() == FALSE) {
- return E_UNEXPECTED;
- }
-
- CComPtr<IMemAllocator> pAllocatorIn;
- m_pTPTFilter->m_pInput->GetAllocator(&pAllocatorIn);
- if (!pAllocatorIn) {
- return E_UNEXPECTED;
- }
-
- pAllocatorIn->GetProperties(pProperties);
-
- HRESULT hr;
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
- return hr;
- }
-
- return (pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
- ? E_FAIL
- : NOERROR);
+ if (m_pTPTFilter->m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
+
+ CComPtr<IMemAllocator> pAllocatorIn;
+ m_pTPTFilter->m_pInput->GetAllocator(&pAllocatorIn);
+ if (!pAllocatorIn) {
+ return E_UNEXPECTED;
+ }
+
+ pAllocatorIn->GetProperties(pProperties);
+
+ HRESULT hr;
+ ALLOCATOR_PROPERTIES Actual;
+ if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
+
+ return (pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
+ ? E_FAIL
+ : NOERROR);
}
HRESULT CTextPassThruOutputPin::GetMediaType(int iPosition, CMediaType* pmt)
{
- if (m_pTPTFilter->m_pInput->IsConnected() == FALSE) {
- return E_UNEXPECTED;
- }
+ if (m_pTPTFilter->m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
- if (iPosition < 0) {
- return E_INVALIDARG;
- }
- if (iPosition > 0) {
- return VFW_S_NO_MORE_ITEMS;
- }
+ if (iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if (iPosition > 0) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
- m_pTPTFilter->m_pInput->ConnectionMediaType(pmt);
+ m_pTPTFilter->m_pInput->ConnectionMediaType(pmt);
- return S_OK;
+ return S_OK;
}
//
@@ -214,45 +214,45 @@ HRESULT CTextPassThruOutputPin::GetMediaType(int iPosition, CMediaType* pmt)
//
CTextPassThruFilter::CTextPassThruFilter(CMainFrame* pMainFrame)
- : CBaseFilter(NAME("CTextPassThruFilter"), NULL, this, __uuidof(this))
- , m_pMainFrame(pMainFrame)
+ : CBaseFilter(NAME("CTextPassThruFilter"), NULL, this, __uuidof(this))
+ , m_pMainFrame(pMainFrame)
{
- HRESULT hr;
- m_pInput = DNew CTextPassThruInputPin(this, this, &m_pMainFrame->m_csSubLock, &hr);
- m_pOutput = DNew CTextPassThruOutputPin(this, this, &hr);
+ HRESULT hr;
+ m_pInput = DNew CTextPassThruInputPin(this, this, &m_pMainFrame->m_csSubLock, &hr);
+ m_pOutput = DNew CTextPassThruOutputPin(this, this, &hr);
}
CTextPassThruFilter::~CTextPassThruFilter()
{
- delete m_pInput;
- m_pInput = NULL;
- delete m_pOutput;
- m_pOutput = NULL;
+ delete m_pInput;
+ m_pInput = NULL;
+ delete m_pOutput;
+ m_pOutput = NULL;
}
STDMETHODIMP CTextPassThruFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- if (m_pInput && riid == __uuidof(ISubStream)) {
- if (CComPtr<ISubStream> pSubStream = m_pInput->GetSubStream()) {
- *ppv = pSubStream.Detach();
- return S_OK;
- }
- }
-
- return __super::NonDelegatingQueryInterface(riid, ppv);
+ if (m_pInput && riid == __uuidof(ISubStream)) {
+ if (CComPtr<ISubStream> pSubStream = m_pInput->GetSubStream()) {
+ *ppv = pSubStream.Detach();
+ return S_OK;
+ }
+ }
+
+ return __super::NonDelegatingQueryInterface(riid, ppv);
}
int CTextPassThruFilter::GetPinCount()
{
- return 2;
+ return 2;
}
CBasePin* CTextPassThruFilter::GetPin(int n)
{
- if (n == 0) {
- return m_pInput;
- } else if (n == 1) {
- return m_pOutput;
- }
- return NULL;
+ if (n == 0) {
+ return m_pInput;
+ } else if (n == 1) {
+ return m_pOutput;
+ }
+ return NULL;
}
diff --git a/src/mpc-hc/TextPassThruFilter.h b/src/mpc-hc/TextPassThruFilter.h
index 9aa3b7953..4d5f40296 100644
--- a/src/mpc-hc/TextPassThruFilter.h
+++ b/src/mpc-hc/TextPassThruFilter.h
@@ -27,23 +27,23 @@
class CTextPassThruInputPin;
class __declspec(uuid("E2BA9B7B-B65D-4804-ACB2-89C3E55511DB"))
- CTextPassThruFilter : public CBaseFilter, public CCritSec
+ CTextPassThruFilter : public CBaseFilter, public CCritSec
{
- friend class CTextPassThruInputPin;
- friend class CTextPassThruOutputPin;
+ friend class CTextPassThruInputPin;
+ friend class CTextPassThruOutputPin;
- CTextPassThruInputPin* m_pInput;
- CTextPassThruOutputPin* m_pOutput;
+ CTextPassThruInputPin* m_pInput;
+ CTextPassThruOutputPin* m_pOutput;
- CMainFrame* m_pMainFrame;
+ CMainFrame* m_pMainFrame;
public:
- CTextPassThruFilter(CMainFrame* pMainFrame);
- virtual ~CTextPassThruFilter();
+ CTextPassThruFilter(CMainFrame* pMainFrame);
+ virtual ~CTextPassThruFilter();
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- int GetPinCount();
- CBasePin* GetPin(int n);
+ int GetPinCount();
+ CBasePin* GetPin(int n);
};
diff --git a/src/mpc-hc/TunerScanDlg.cpp b/src/mpc-hc/TunerScanDlg.cpp
index d540e4c08..17e88e693 100644
--- a/src/mpc-hc/TunerScanDlg.cpp
+++ b/src/mpc-hc/TunerScanDlg.cpp
@@ -31,11 +31,11 @@
enum TSC_COLUMN {
- TSCC_NUMBER,
- TSCC_NAME,
- TSCC_FREQUENCY,
- TSCC_ENCRYPTED,
- TSCC_CHANNEL
+ TSCC_NUMBER,
+ TSCC_NAME,
+ TSCC_FREQUENCY,
+ TSCC_ENCRYPTED,
+ TSCC_CHANNEL
};
// CTunerScanDlg dialog
@@ -43,17 +43,17 @@ enum TSC_COLUMN {
IMPLEMENT_DYNAMIC(CTunerScanDlg, CDialog)
CTunerScanDlg::CTunerScanDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CTunerScanDlg::IDD, pParent)
- , m_bInProgress(false)
+ : CDialog(CTunerScanDlg::IDD, pParent)
+ , m_bInProgress(false)
{
- AppSettings& s = AfxGetAppSettings();
-
- m_ulFrequencyStart = s.iBDAScanFreqStart;
- m_ulFrequencyEnd = s.iBDAScanFreqEnd;
- m_ulBandwidth = s.iBDABandwidth*1000;
- m_bUseOffset = s.fBDAUseOffset;
- m_lOffset = s.iBDAOffset;
- m_bIgnoreEncryptedChannels = s.fBDAIgnoreEncryptedChannels;
+ AppSettings& s = AfxGetAppSettings();
+
+ m_ulFrequencyStart = s.iBDAScanFreqStart;
+ m_ulFrequencyEnd = s.iBDAScanFreqEnd;
+ m_ulBandwidth = s.iBDABandwidth * 1000;
+ m_bUseOffset = s.fBDAUseOffset;
+ m_lOffset = s.iBDAOffset;
+ m_bIgnoreEncryptedChannels = s.fBDAIgnoreEncryptedChannels;
}
CTunerScanDlg::~CTunerScanDlg()
@@ -62,53 +62,53 @@ CTunerScanDlg::~CTunerScanDlg()
BOOL CTunerScanDlg::OnInitDialog()
{
- CDialog::OnInitDialog();
+ CDialog::OnInitDialog();
- m_OffsetEditBox.EnableWindow(m_bUseOffset);
+ m_OffsetEditBox.EnableWindow(m_bUseOffset);
- m_ChannelList.InsertColumn(TSCC_NUMBER, ResStr(IDS_DVB_CHANNEL_NUMBER), LVCFMT_LEFT, 50);
- m_ChannelList.InsertColumn(TSCC_NAME, ResStr(IDS_DVB_CHANNEL_NAME), LVCFMT_LEFT, 250);
- m_ChannelList.InsertColumn(TSCC_FREQUENCY, ResStr(IDS_DVB_CHANNEL_FREQUENCY), LVCFMT_LEFT, 100);
- m_ChannelList.InsertColumn(TSCC_ENCRYPTED, ResStr(IDS_DVB_CHANNEL_ENCRYPTION), LVCFMT_LEFT, 80);
- m_ChannelList.InsertColumn(TSCC_CHANNEL, _T("Channel"), LVCFMT_LEFT, 0);
+ m_ChannelList.InsertColumn(TSCC_NUMBER, ResStr(IDS_DVB_CHANNEL_NUMBER), LVCFMT_LEFT, 50);
+ m_ChannelList.InsertColumn(TSCC_NAME, ResStr(IDS_DVB_CHANNEL_NAME), LVCFMT_LEFT, 250);
+ m_ChannelList.InsertColumn(TSCC_FREQUENCY, ResStr(IDS_DVB_CHANNEL_FREQUENCY), LVCFMT_LEFT, 100);
+ m_ChannelList.InsertColumn(TSCC_ENCRYPTED, ResStr(IDS_DVB_CHANNEL_ENCRYPTION), LVCFMT_LEFT, 80);
+ m_ChannelList.InsertColumn(TSCC_CHANNEL, _T("Channel"), LVCFMT_LEFT, 0);
- m_Progress.SetRange(0, 100);
- m_Strength.SetRange(0, 100);
- m_Quality.SetRange(0, 100);
- m_btnSave.EnableWindow(FALSE);
+ m_Progress.SetRange(0, 100);
+ m_Strength.SetRange(0, 100);
+ m_Quality.SetRange(0, 100);
+ m_btnSave.EnableWindow(FALSE);
- return TRUE;
+ return TRUE;
}
void CTunerScanDlg::DoDataExchange(CDataExchange* pDX)
{
- CDialog::DoDataExchange(pDX);
- DDX_Text(pDX, IDC_FREQ_START, m_ulFrequencyStart);
- DDX_Text(pDX, IDC_FREQ_END, m_ulFrequencyEnd);
- DDX_Text(pDX, IDC_BANDWIDTH, m_ulBandwidth);
- DDX_Text(pDX, IDC_OFFSET, m_lOffset);
- DDX_Check(pDX, IDC_CHECK_OFFSET, m_bUseOffset);
- DDX_Check(pDX, IDC_CHECK_IGNORE_ENCRYPTED, m_bIgnoreEncryptedChannels);
- DDX_Control(pDX, IDC_PROGRESS, m_Progress);
- DDX_Control(pDX, IDC_STRENGTH, m_Strength);
- DDX_Control(pDX, IDC_QUALITY, m_Quality);
- DDX_Control(pDX, IDC_CHANNEL_LIST, m_ChannelList);
- DDX_Control(pDX, ID_START, m_btnStart);
- DDX_Control(pDX, ID_SAVE, m_btnSave);
- DDX_Control(pDX, IDCANCEL, m_btnCancel);
- DDX_Control(pDX, IDC_OFFSET, m_OffsetEditBox);
+ CDialog::DoDataExchange(pDX);
+ DDX_Text(pDX, IDC_FREQ_START, m_ulFrequencyStart);
+ DDX_Text(pDX, IDC_FREQ_END, m_ulFrequencyEnd);
+ DDX_Text(pDX, IDC_BANDWIDTH, m_ulBandwidth);
+ DDX_Text(pDX, IDC_OFFSET, m_lOffset);
+ DDX_Check(pDX, IDC_CHECK_OFFSET, m_bUseOffset);
+ DDX_Check(pDX, IDC_CHECK_IGNORE_ENCRYPTED, m_bIgnoreEncryptedChannels);
+ DDX_Control(pDX, IDC_PROGRESS, m_Progress);
+ DDX_Control(pDX, IDC_STRENGTH, m_Strength);
+ DDX_Control(pDX, IDC_QUALITY, m_Quality);
+ DDX_Control(pDX, IDC_CHANNEL_LIST, m_ChannelList);
+ DDX_Control(pDX, ID_START, m_btnStart);
+ DDX_Control(pDX, ID_SAVE, m_btnSave);
+ DDX_Control(pDX, IDCANCEL, m_btnCancel);
+ DDX_Control(pDX, IDC_OFFSET, m_OffsetEditBox);
}
BEGIN_MESSAGE_MAP(CTunerScanDlg, CDialog)
- ON_MESSAGE(WM_TUNER_SCAN_PROGRESS, OnScanProgress)
- ON_MESSAGE(WM_TUNER_SCAN_END, OnScanEnd)
- ON_MESSAGE(WM_TUNER_STATS, OnStats)
- ON_MESSAGE(WM_TUNER_NEW_CHANNEL, OnNewChannel)
- ON_BN_CLICKED(ID_SAVE, &CTunerScanDlg::OnBnClickedSave)
- ON_BN_CLICKED(ID_START, &CTunerScanDlg::OnBnClickedStart)
- ON_BN_CLICKED(IDCANCEL, &CTunerScanDlg::OnBnClickedCancel)
- ON_BN_CLICKED(IDC_CHECK_OFFSET, &CTunerScanDlg::OnBnClickedCheckOffset)
+ ON_MESSAGE(WM_TUNER_SCAN_PROGRESS, OnScanProgress)
+ ON_MESSAGE(WM_TUNER_SCAN_END, OnScanEnd)
+ ON_MESSAGE(WM_TUNER_STATS, OnStats)
+ ON_MESSAGE(WM_TUNER_NEW_CHANNEL, OnNewChannel)
+ ON_BN_CLICKED(ID_SAVE, &CTunerScanDlg::OnBnClickedSave)
+ ON_BN_CLICKED(ID_START, &CTunerScanDlg::OnBnClickedStart)
+ ON_BN_CLICKED(IDCANCEL, &CTunerScanDlg::OnBnClickedCancel)
+ ON_BN_CLICKED(IDC_CHECK_OFFSET, &CTunerScanDlg::OnBnClickedCheckOffset)
END_MESSAGE_MAP()
@@ -116,137 +116,137 @@ END_MESSAGE_MAP()
void CTunerScanDlg::OnBnClickedSave()
{
- AppSettings& s = AfxGetAppSettings();
- s.m_DVBChannels.RemoveAll();
+ AppSettings& s = AfxGetAppSettings();
+ s.m_DVBChannels.RemoveAll();
- for (int i = 0; i < m_ChannelList.GetItemCount(); i++) {
- CDVBChannel Channel;
- Channel.FromString (m_ChannelList.GetItemText (i, TSCC_CHANNEL));
- Channel.SetPrefNumber(i);
- s.m_DVBChannels.AddTail (Channel);
- }
+ for (int i = 0; i < m_ChannelList.GetItemCount(); i++) {
+ CDVBChannel Channel;
+ Channel.FromString(m_ChannelList.GetItemText(i, TSCC_CHANNEL));
+ Channel.SetPrefNumber(i);
+ s.m_DVBChannels.AddTail(Channel);
+ }
- OnOK();
+ OnOK();
}
void CTunerScanDlg::OnBnClickedStart()
{
- if (!m_bInProgress) {
- UpdateData(true);
- CAutoPtr<TunerScanData> pTSD (DNew TunerScanData);
- pTSD->Hwnd = m_hWnd;
- pTSD->FrequencyStart = m_ulFrequencyStart;
- pTSD->FrequencyStop = m_ulFrequencyEnd;
- pTSD->Bandwidth = m_ulBandwidth;
- pTSD->Offset = m_bUseOffset ? m_lOffset : 0;
- SaveScanSettings();
-
- m_ChannelList.DeleteAllItems();
- ((CMainFrame*)AfxGetMainWnd())->StartTunerScan (pTSD);
-
- SetProgress (true);
- } else {
- ((CMainFrame*)AfxGetMainWnd())->StopTunerScan();
- }
+ if (!m_bInProgress) {
+ UpdateData(true);
+ CAutoPtr<TunerScanData> pTSD(DNew TunerScanData);
+ pTSD->Hwnd = m_hWnd;
+ pTSD->FrequencyStart = m_ulFrequencyStart;
+ pTSD->FrequencyStop = m_ulFrequencyEnd;
+ pTSD->Bandwidth = m_ulBandwidth;
+ pTSD->Offset = m_bUseOffset ? m_lOffset : 0;
+ SaveScanSettings();
+
+ m_ChannelList.DeleteAllItems();
+ ((CMainFrame*)AfxGetMainWnd())->StartTunerScan(pTSD);
+
+ SetProgress(true);
+ } else {
+ ((CMainFrame*)AfxGetMainWnd())->StopTunerScan();
+ }
}
void CTunerScanDlg::OnBnClickedCancel()
{
- if (m_bInProgress) {
- ((CMainFrame*)AfxGetMainWnd())->StopTunerScan();
- }
+ if (m_bInProgress) {
+ ((CMainFrame*)AfxGetMainWnd())->StopTunerScan();
+ }
- OnCancel();
+ OnCancel();
}
void CTunerScanDlg::OnBnClickedCheckOffset()
{
- UpdateData(true);
- m_OffsetEditBox.EnableWindow(m_bUseOffset);
+ UpdateData(true);
+ m_OffsetEditBox.EnableWindow(m_bUseOffset);
}
LRESULT CTunerScanDlg::OnScanProgress(WPARAM wParam, LPARAM lParam)
{
- m_Progress.SetPos(static_cast<int>(wParam));
- return TRUE;
+ m_Progress.SetPos(static_cast<int>(wParam));
+ return TRUE;
}
LRESULT CTunerScanDlg::OnScanEnd(WPARAM wParam, LPARAM lParam)
{
- SetProgress (false);
- return TRUE;
+ SetProgress(false);
+ return TRUE;
}
LRESULT CTunerScanDlg::OnStats(WPARAM wParam, LPARAM lParam)
{
- m_Strength.SetPos ((int)wParam);
- m_Quality.SetPos ((int)lParam);
- return TRUE;
+ m_Strength.SetPos((int)wParam);
+ m_Quality.SetPos((int)lParam);
+ return TRUE;
}
LRESULT CTunerScanDlg::OnNewChannel(WPARAM wParam, LPARAM lParam)
{
- CDVBChannel Channel;
- CString strTemp;
- Channel.FromString ((LPCTSTR) lParam);
+ CDVBChannel Channel;
+ CString strTemp;
+ Channel.FromString((LPCTSTR) lParam);
- if (!m_bIgnoreEncryptedChannels || !Channel.IsEncrypted()) {
- int nItem, nChannelNumber;
+ if (!m_bIgnoreEncryptedChannels || !Channel.IsEncrypted()) {
+ int nItem, nChannelNumber;
- if (Channel.GetOriginNumber() != 0) { // LCN is available
- nChannelNumber = Channel.GetOriginNumber();
- // Insert new channel so that channels are sorted by their logical number
- for (nItem=0; nItem<m_ChannelList.GetItemCount(); nItem++) {
- if ((int)m_ChannelList.GetItemData(nItem) > nChannelNumber) {
- break;
- }
- }
- } else {
- nChannelNumber = nItem = m_ChannelList.GetItemCount();
- }
+ if (Channel.GetOriginNumber() != 0) { // LCN is available
+ nChannelNumber = Channel.GetOriginNumber();
+ // Insert new channel so that channels are sorted by their logical number
+ for (nItem = 0; nItem < m_ChannelList.GetItemCount(); nItem++) {
+ if ((int)m_ChannelList.GetItemData(nItem) > nChannelNumber) {
+ break;
+ }
+ }
+ } else {
+ nChannelNumber = nItem = m_ChannelList.GetItemCount();
+ }
- strTemp.Format(_T("%d"), nChannelNumber);
- nItem = m_ChannelList.InsertItem (nItem, strTemp);
+ strTemp.Format(_T("%d"), nChannelNumber);
+ nItem = m_ChannelList.InsertItem(nItem, strTemp);
- m_ChannelList.SetItemData (nItem, Channel.GetOriginNumber());
+ m_ChannelList.SetItemData(nItem, Channel.GetOriginNumber());
- m_ChannelList.SetItemText (nItem, TSCC_NAME, Channel.GetName());
+ m_ChannelList.SetItemText(nItem, TSCC_NAME, Channel.GetName());
- strTemp.Format(_T("%d"), Channel.GetFrequency());
- m_ChannelList.SetItemText (nItem, TSCC_FREQUENCY, strTemp);
+ strTemp.Format(_T("%d"), Channel.GetFrequency());
+ m_ChannelList.SetItemText(nItem, TSCC_FREQUENCY, strTemp);
- strTemp = Channel.IsEncrypted() ? ResStr(IDS_DVB_CHANNEL_ENCRYPTED) : ResStr(IDS_DVB_CHANNEL_NOT_ENCRYPTED);
- m_ChannelList.SetItemText (nItem, TSCC_ENCRYPTED, strTemp);
+ strTemp = Channel.IsEncrypted() ? ResStr(IDS_DVB_CHANNEL_ENCRYPTED) : ResStr(IDS_DVB_CHANNEL_NOT_ENCRYPTED);
+ m_ChannelList.SetItemText(nItem, TSCC_ENCRYPTED, strTemp);
- m_ChannelList.SetItemText (nItem, TSCC_CHANNEL, (LPCTSTR) lParam);
- }
+ m_ChannelList.SetItemText(nItem, TSCC_CHANNEL, (LPCTSTR) lParam);
+ }
- return TRUE;
+ return TRUE;
}
-void CTunerScanDlg::SetProgress (bool bState)
+void CTunerScanDlg::SetProgress(bool bState)
{
- if (bState) {
- m_btnStart.SetWindowTextW(_T("Stop"));
- m_btnSave.EnableWindow(FALSE);
- } else {
- m_btnStart.SetWindowTextW(_T("Start"));
- m_Progress.SetPos (0);
- m_btnSave.EnableWindow(TRUE);
- }
-
- m_bInProgress = bState;
+ if (bState) {
+ m_btnStart.SetWindowTextW(_T("Stop"));
+ m_btnSave.EnableWindow(FALSE);
+ } else {
+ m_btnStart.SetWindowTextW(_T("Start"));
+ m_Progress.SetPos(0);
+ m_btnSave.EnableWindow(TRUE);
+ }
+
+ m_bInProgress = bState;
}
void CTunerScanDlg::SaveScanSettings()
{
- AppSettings& s = AfxGetAppSettings();
-
- s.iBDAScanFreqStart = m_ulFrequencyStart;
- s.iBDAScanFreqEnd = m_ulFrequencyEnd;
- div_t bdw = div(m_ulBandwidth, 1000);
- s.iBDABandwidth = bdw.quot;
- s.fBDAUseOffset = !!m_bUseOffset;
- s.iBDAOffset = m_lOffset;
- s.fBDAIgnoreEncryptedChannels = !!m_bIgnoreEncryptedChannels;
+ AppSettings& s = AfxGetAppSettings();
+
+ s.iBDAScanFreqStart = m_ulFrequencyStart;
+ s.iBDAScanFreqEnd = m_ulFrequencyEnd;
+ div_t bdw = div(m_ulBandwidth, 1000);
+ s.iBDABandwidth = bdw.quot;
+ s.fBDAUseOffset = !!m_bUseOffset;
+ s.iBDAOffset = m_lOffset;
+ s.fBDAIgnoreEncryptedChannels = !!m_bIgnoreEncryptedChannels;
}
diff --git a/src/mpc-hc/TunerScanDlg.h b/src/mpc-hc/TunerScanDlg.h
index 0de8d6c07..154fa1917 100644
--- a/src/mpc-hc/TunerScanDlg.h
+++ b/src/mpc-hc/TunerScanDlg.h
@@ -30,46 +30,46 @@
class CTunerScanDlg : public CDialog
{
- DECLARE_DYNAMIC(CTunerScanDlg)
+ DECLARE_DYNAMIC(CTunerScanDlg)
public:
- CTunerScanDlg(CWnd* pParent = NULL); // standard constructor
- virtual ~CTunerScanDlg();
+ CTunerScanDlg(CWnd* pParent = NULL); // standard constructor
+ virtual ~CTunerScanDlg();
- // Dialog Data
- enum { IDD = IDD_TUNER_SCAN };
+ // Dialog Data
+ enum { IDD = IDD_TUNER_SCAN };
protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- void SetProgress (bool bState);
- void SaveScanSettings();
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ void SetProgress(bool bState);
+ void SaveScanSettings();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- ULONG m_ulFrequencyStart;
- ULONG m_ulFrequencyEnd;
- ULONG m_ulBandwidth;
- LONG m_lOffset;
- CEdit m_OffsetEditBox;
- BOOL m_bUseOffset;
- BOOL m_bIgnoreEncryptedChannels;
- CProgressCtrl m_Progress;
- CProgressCtrl m_Strength;
- CProgressCtrl m_Quality;
- CListCtrl m_ChannelList;
- bool m_bInProgress;
+ ULONG m_ulFrequencyStart;
+ ULONG m_ulFrequencyEnd;
+ ULONG m_ulBandwidth;
+ LONG m_lOffset;
+ CEdit m_OffsetEditBox;
+ BOOL m_bUseOffset;
+ BOOL m_bIgnoreEncryptedChannels;
+ CProgressCtrl m_Progress;
+ CProgressCtrl m_Strength;
+ CProgressCtrl m_Quality;
+ CListCtrl m_ChannelList;
+ bool m_bInProgress;
- afx_msg LRESULT OnScanProgress(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnScanEnd(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnStats(WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnNewChannel(WPARAM wParam, LPARAM lParam);
+ afx_msg LRESULT OnScanProgress(WPARAM wParam, LPARAM lParam);
+ afx_msg LRESULT OnScanEnd(WPARAM wParam, LPARAM lParam);
+ afx_msg LRESULT OnStats(WPARAM wParam, LPARAM lParam);
+ afx_msg LRESULT OnNewChannel(WPARAM wParam, LPARAM lParam);
- afx_msg void OnBnClickedCheckOffset();
- afx_msg void OnBnClickedSave();
- afx_msg void OnBnClickedStart();
- afx_msg void OnBnClickedCancel();
- virtual BOOL OnInitDialog();
- CButton m_btnStart;
- CButton m_btnSave;
- CButton m_btnCancel;
+ afx_msg void OnBnClickedCheckOffset();
+ afx_msg void OnBnClickedSave();
+ afx_msg void OnBnClickedStart();
+ afx_msg void OnBnClickedCancel();
+ virtual BOOL OnInitDialog();
+ CButton m_btnStart;
+ CButton m_btnSave;
+ CButton m_btnCancel;
};
diff --git a/src/mpc-hc/UpdateChecker.cpp b/src/mpc-hc/UpdateChecker.cpp
index 6d81afd08..2d2a8a1e8 100644
--- a/src/mpc-hc/UpdateChecker.cpp
+++ b/src/mpc-hc/UpdateChecker.cpp
@@ -34,7 +34,7 @@ const Version UpdateChecker::MPC_HC_VERSION = { MPC_VERSION_NUM };
const LPCTSTR UpdateChecker::MPC_HC_UPDATE_URL = _T("http://mpc-hc.sourceforge.net/version.txt");
UpdateChecker::UpdateChecker(CString versionFileURL)
- : versionFileURL(versionFileURL)
+ : versionFileURL(versionFileURL)
{
}
@@ -44,184 +44,184 @@ UpdateChecker::~UpdateChecker(void)
Update_Status UpdateChecker::IsUpdateAvailable(const Version& currentVersion)
{
- Update_Status updateAvailable = UPDATER_LATEST_STABLE;
-
- try {
- CInternetSession internet;
- CHttpFile* versionFile = (CHttpFile*) internet.OpenURL(versionFileURL,
- 1,
- INTERNET_FLAG_TRANSFER_ASCII | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_RELOAD,
- NULL,
- 0);
-
- if (versionFile) {
- CString latestVersionStr;
- char buffer[101];
- UINT br = 0;
-
- while ((br = versionFile->Read(buffer, 50)) > 0) {
- buffer[br] = '\0';
- latestVersionStr += buffer;
- }
-
- if (!ParseVersion(latestVersionStr, latestVersion)) {
- updateAvailable = UPDATER_ERROR;
- } else {
- time_t lastCheck = time(NULL);
- AfxGetApp()->WriteProfileBinary(IDS_R_SETTINGS, IDS_RS_UPDATER_LAST_CHECK, (LPBYTE)&lastCheck, sizeof(time_t));
-
- int comp = CompareVersion(currentVersion, latestVersion);
-
- if (comp < 0) {
- CString ignoredVersionStr = AfxGetApp()->GetProfileString(IDS_R_SETTINGS, IDS_RS_UPDATER_IGNORE_VERSION, _T("0.0.0.0"));
- Version ignoredVersion;
- bool ignored = false;
-
- if (ParseVersion(ignoredVersionStr, ignoredVersion)) {
- ignored = (CompareVersion(ignoredVersion, latestVersion) >= 0);
- }
-
- updateAvailable = ignored ? UPDATER_UPDATE_AVAILABLE_IGNORED : UPDATER_UPDATE_AVAILABLE;
- } else if (comp > 0) {
- updateAvailable = UPDATER_NEWER_VERSION;
- }
- }
-
- delete versionFile;
- } else {
- updateAvailable = UPDATER_ERROR;
- }
- } catch (CInternetException* pEx) {
- updateAvailable = UPDATER_ERROR;
- pEx->Delete();
- }
-
- return updateAvailable;
+ Update_Status updateAvailable = UPDATER_LATEST_STABLE;
+
+ try {
+ CInternetSession internet;
+ CHttpFile* versionFile = (CHttpFile*) internet.OpenURL(versionFileURL,
+ 1,
+ INTERNET_FLAG_TRANSFER_ASCII | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_RELOAD,
+ NULL,
+ 0);
+
+ if (versionFile) {
+ CString latestVersionStr;
+ char buffer[101];
+ UINT br = 0;
+
+ while ((br = versionFile->Read(buffer, 50)) > 0) {
+ buffer[br] = '\0';
+ latestVersionStr += buffer;
+ }
+
+ if (!ParseVersion(latestVersionStr, latestVersion)) {
+ updateAvailable = UPDATER_ERROR;
+ } else {
+ time_t lastCheck = time(NULL);
+ AfxGetApp()->WriteProfileBinary(IDS_R_SETTINGS, IDS_RS_UPDATER_LAST_CHECK, (LPBYTE)&lastCheck, sizeof(time_t));
+
+ int comp = CompareVersion(currentVersion, latestVersion);
+
+ if (comp < 0) {
+ CString ignoredVersionStr = AfxGetApp()->GetProfileString(IDS_R_SETTINGS, IDS_RS_UPDATER_IGNORE_VERSION, _T("0.0.0.0"));
+ Version ignoredVersion;
+ bool ignored = false;
+
+ if (ParseVersion(ignoredVersionStr, ignoredVersion)) {
+ ignored = (CompareVersion(ignoredVersion, latestVersion) >= 0);
+ }
+
+ updateAvailable = ignored ? UPDATER_UPDATE_AVAILABLE_IGNORED : UPDATER_UPDATE_AVAILABLE;
+ } else if (comp > 0) {
+ updateAvailable = UPDATER_NEWER_VERSION;
+ }
+ }
+
+ delete versionFile;
+ } else {
+ updateAvailable = UPDATER_ERROR;
+ }
+ } catch (CInternetException* pEx) {
+ updateAvailable = UPDATER_ERROR;
+ pEx->Delete();
+ }
+
+ return updateAvailable;
}
Update_Status UpdateChecker::IsUpdateAvailable()
{
- return IsUpdateAvailable(MPC_HC_VERSION);
+ return IsUpdateAvailable(MPC_HC_VERSION);
}
void UpdateChecker::IgnoreLatestVersion()
{
- CString ignoredVersionStr;
- ignoredVersionStr.Format(_T("%u.%u.%u.%u"), latestVersion.major, latestVersion.minor, latestVersion.patch, latestVersion.revision);
+ CString ignoredVersionStr;
+ ignoredVersionStr.Format(_T("%u.%u.%u.%u"), latestVersion.major, latestVersion.minor, latestVersion.patch, latestVersion.revision);
- AfxGetApp()->WriteProfileString(IDS_R_SETTINGS, IDS_RS_UPDATER_IGNORE_VERSION, ignoredVersionStr);
+ AfxGetApp()->WriteProfileString(IDS_R_SETTINGS, IDS_RS_UPDATER_IGNORE_VERSION, ignoredVersionStr);
}
bool UpdateChecker::ParseVersion(const CString& versionStr, Version& version)
{
- bool success = false;
+ bool success = false;
- if (!versionStr.IsEmpty()) {
- UINT v[4];
- int curPos = 0;
- UINT i = 0;
- CString resToken = versionStr.Tokenize(_T("."), curPos);
+ if (!versionStr.IsEmpty()) {
+ UINT v[4];
+ int curPos = 0;
+ UINT i = 0;
+ CString resToken = versionStr.Tokenize(_T("."), curPos);
- success = !resToken.IsEmpty();
+ success = !resToken.IsEmpty();
- while (!resToken.IsEmpty() && i < _countof(v) && success) {
- if (1 != _stscanf_s(resToken, _T("%u"), v + i)) {
- success = false;
- }
+ while (!resToken.IsEmpty() && i < _countof(v) && success) {
+ if (1 != _stscanf_s(resToken, _T("%u"), v + i)) {
+ success = false;
+ }
- resToken = versionStr.Tokenize(_T("."), curPos);
- i++;
- }
+ resToken = versionStr.Tokenize(_T("."), curPos);
+ i++;
+ }
- success = success && (i == _countof(v));
+ success = success && (i == _countof(v));
- if (success) {
- version.major = v[0];
- version.minor = v[1];
- version.patch = v[2];
- version.revision = v[3];
- }
- }
+ if (success) {
+ version.major = v[0];
+ version.minor = v[1];
+ version.patch = v[2];
+ version.revision = v[3];
+ }
+ }
- return success;
+ return success;
}
int UpdateChecker::CompareVersion(const Version& v1, const Version& v2)
{
- if (v1.major > v2.major) {
- return 1;
- } else if (v1.major < v2.major) {
- return -1;
- } else if (v1.minor > v2.minor) {
- return 1;
- } else if (v1.minor < v2.minor) {
- return -1;
- } else if (v1.patch > v2.patch) {
- return 1;
- } else if (v1.patch < v2.patch) {
- return -1;
- } else if (v1.revision > v2.revision) {
- return 1;
- } else if (v1.revision < v2.revision) {
- return -1;
- } else {
- return 0;
- }
+ if (v1.major > v2.major) {
+ return 1;
+ } else if (v1.major < v2.major) {
+ return -1;
+ } else if (v1.minor > v2.minor) {
+ return 1;
+ } else if (v1.minor < v2.minor) {
+ return -1;
+ } else if (v1.patch > v2.patch) {
+ return 1;
+ } else if (v1.patch < v2.patch) {
+ return -1;
+ } else if (v1.revision > v2.revision) {
+ return 1;
+ } else if (v1.revision < v2.revision) {
+ return -1;
+ } else {
+ return 0;
+ }
}
bool UpdateChecker::IsAutoUpdateEnabled()
{
- int& status = AfxGetAppSettings().nUpdaterAutoCheck;
+ int& status = AfxGetAppSettings().nUpdaterAutoCheck;
- if (status == AUTOUPDATE_UNKNOWN) { // First run
- status = (AfxMessageBox(IDS_UPDATE_CONFIG_AUTO_CHECK, MB_ICONQUESTION | MB_YESNO, 0) == IDYES) ? AUTOUPDATE_ENABLE : AUTOUPDATE_DISABLE;
- }
+ if (status == AUTOUPDATE_UNKNOWN) { // First run
+ status = (AfxMessageBox(IDS_UPDATE_CONFIG_AUTO_CHECK, MB_ICONQUESTION | MB_YESNO, 0) == IDYES) ? AUTOUPDATE_ENABLE : AUTOUPDATE_DISABLE;
+ }
- return (status == AUTOUPDATE_ENABLE);
+ return (status == AUTOUPDATE_ENABLE);
}
bool UpdateChecker::IsTimeToAutoUpdate()
{
- time_t *lastCheck = NULL;
- UINT nRead;
+ time_t* lastCheck = NULL;
+ UINT nRead;
- if (!AfxGetApp()->GetProfileBinary(IDS_R_SETTINGS, IDS_RS_UPDATER_LAST_CHECK, (LPBYTE*)&lastCheck, &nRead) || nRead != sizeof(time_t)) {
- if (lastCheck) {
- delete[] lastCheck;
- }
+ if (!AfxGetApp()->GetProfileBinary(IDS_R_SETTINGS, IDS_RS_UPDATER_LAST_CHECK, (LPBYTE*)&lastCheck, &nRead) || nRead != sizeof(time_t)) {
+ if (lastCheck) {
+ delete[] lastCheck;
+ }
- return true;
- }
+ return true;
+ }
- bool isTimeToAutoUpdate = (time(NULL) >= *lastCheck + AfxGetAppSettings().nUpdaterDelay*24*3600);
+ bool isTimeToAutoUpdate = (time(NULL) >= *lastCheck + AfxGetAppSettings().nUpdaterDelay * 24 * 3600);
- delete[] lastCheck;
+ delete[] lastCheck;
- return isTimeToAutoUpdate;
+ return isTimeToAutoUpdate;
}
UINT RunCheckForUpdateThread(LPVOID pParam)
{
- bool autoCheck = !!pParam;
+ bool autoCheck = !!pParam;
- if (!autoCheck || UpdateChecker::IsTimeToAutoUpdate()) {
- UpdateChecker updateChecker(UpdateChecker::MPC_HC_UPDATE_URL);
+ if (!autoCheck || UpdateChecker::IsTimeToAutoUpdate()) {
+ UpdateChecker updateChecker(UpdateChecker::MPC_HC_UPDATE_URL);
- Update_Status status = updateChecker.IsUpdateAvailable();
+ Update_Status status = updateChecker.IsUpdateAvailable();
- if (!autoCheck || status == UPDATER_UPDATE_AVAILABLE) {
- UpdateCheckerDlg dlg(status, updateChecker.GetLatestVersion());
+ if (!autoCheck || status == UPDATER_UPDATE_AVAILABLE) {
+ UpdateCheckerDlg dlg(status, updateChecker.GetLatestVersion());
- if (dlg.DoModal() == IDC_UPDATE_IGNORE_BUTTON) {
- updateChecker.IgnoreLatestVersion();
- }
- }
- }
+ if (dlg.DoModal() == IDC_UPDATE_IGNORE_BUTTON) {
+ updateChecker.IgnoreLatestVersion();
+ }
+ }
+ }
- return 0;
+ return 0;
}
void UpdateChecker::CheckForUpdate(bool autoCheck /*= false*/)
{
- AfxBeginThread(RunCheckForUpdateThread, (LPVOID)autoCheck);
+ AfxBeginThread(RunCheckForUpdateThread, (LPVOID)autoCheck);
}
diff --git a/src/mpc-hc/UpdateChecker.h b/src/mpc-hc/UpdateChecker.h
index a7a3f331d..394050f2a 100644
--- a/src/mpc-hc/UpdateChecker.h
+++ b/src/mpc-hc/UpdateChecker.h
@@ -25,52 +25,49 @@
#include <afxwin.h>
-struct Version
-{
- UINT major;
- UINT minor;
- UINT patch;
- UINT revision;
+struct Version {
+ UINT major;
+ UINT minor;
+ UINT patch;
+ UINT revision;
};
-enum Update_Status
-{
- UPDATER_ERROR = -1,
- UPDATER_LATEST_STABLE,
- UPDATER_NEWER_VERSION,
- UPDATER_UPDATE_AVAILABLE,
- UPDATER_UPDATE_AVAILABLE_IGNORED
+enum Update_Status {
+ UPDATER_ERROR = -1,
+ UPDATER_LATEST_STABLE,
+ UPDATER_NEWER_VERSION,
+ UPDATER_UPDATE_AVAILABLE,
+ UPDATER_UPDATE_AVAILABLE_IGNORED
};
-enum AutoUpdate_Status
-{
- AUTOUPDATE_UNKNOWN = -1,
- AUTOUPDATE_DISABLE,
- AUTOUPDATE_ENABLE
+enum AutoUpdate_Status {
+ AUTOUPDATE_UNKNOWN = -1,
+ AUTOUPDATE_DISABLE,
+ AUTOUPDATE_ENABLE
};
class UpdateChecker
{
public:
- static const Version MPC_HC_VERSION;
- static const LPCTSTR MPC_HC_UPDATE_URL;
+ static const Version MPC_HC_VERSION;
+ static const LPCTSTR MPC_HC_UPDATE_URL;
- UpdateChecker(CString versionFileURL);
- ~UpdateChecker(void);
+ UpdateChecker(CString versionFileURL);
+ ~UpdateChecker(void);
- Update_Status IsUpdateAvailable(const Version& currentVersion);
- Update_Status IsUpdateAvailable();
- const Version& GetLatestVersion() const { return latestVersion; };
- void IgnoreLatestVersion();
+ Update_Status IsUpdateAvailable(const Version& currentVersion);
+ Update_Status IsUpdateAvailable();
+ const Version& GetLatestVersion() const { return latestVersion; };
+ void IgnoreLatestVersion();
- static bool IsAutoUpdateEnabled();
- static bool IsTimeToAutoUpdate();
- static void CheckForUpdate(bool autoCheck = false);
+ static bool IsAutoUpdateEnabled();
+ static bool IsTimeToAutoUpdate();
+ static void CheckForUpdate(bool autoCheck = false);
private :
- CString versionFileURL;
- Version latestVersion;
+ CString versionFileURL;
+ Version latestVersion;
- static bool ParseVersion(const CString& versionStr, Version& version);
- static int CompareVersion(const Version& v1, const Version& v2);
+ static bool ParseVersion(const CString& versionStr, Version& version);
+ static int CompareVersion(const Version& v1, const Version& v2);
};
diff --git a/src/mpc-hc/UpdateCheckerDlg.cpp b/src/mpc-hc/UpdateCheckerDlg.cpp
index 35b04f922..0f4cbfc23 100644
--- a/src/mpc-hc/UpdateCheckerDlg.cpp
+++ b/src/mpc-hc/UpdateCheckerDlg.cpp
@@ -28,29 +28,29 @@
IMPLEMENT_DYNAMIC(UpdateCheckerDlg, CDialog)
UpdateCheckerDlg::UpdateCheckerDlg(Update_Status updateStatus, const Version& latestVersion, CWnd* pParent /*=NULL*/)
- : CDialog(UpdateCheckerDlg::IDD, pParent), m_updateStatus(updateStatus)
+ : CDialog(UpdateCheckerDlg::IDD, pParent), m_updateStatus(updateStatus)
{
- switch (updateStatus) {
- case UPDATER_UPDATE_AVAILABLE:
- case UPDATER_UPDATE_AVAILABLE_IGNORED:
- m_text.Format(IDS_NEW_UPDATE_AVAILABLE,
- latestVersion.major, latestVersion.minor, latestVersion.patch, latestVersion.revision,
- UpdateChecker::MPC_HC_VERSION.major, UpdateChecker::MPC_HC_VERSION.minor, UpdateChecker::MPC_HC_VERSION.patch, UpdateChecker::MPC_HC_VERSION.revision);
- break;
- case UPDATER_LATEST_STABLE:
- m_text.LoadString(IDS_USING_LATEST_STABLE);
- break;
- case UPDATER_NEWER_VERSION:
- m_text.Format(IDS_USING_NEWER_VERSION,
- UpdateChecker::MPC_HC_VERSION.major, UpdateChecker::MPC_HC_VERSION.minor, UpdateChecker::MPC_HC_VERSION.patch, UpdateChecker::MPC_HC_VERSION.revision,
- latestVersion.major, latestVersion.minor, latestVersion.patch, latestVersion.revision);
- break;
- case UPDATER_ERROR:
- m_text.LoadString(IDS_UPDATE_ERROR);
- break;
- default:
- ASSERT(0); // should never happen
- }
+ switch (updateStatus) {
+ case UPDATER_UPDATE_AVAILABLE:
+ case UPDATER_UPDATE_AVAILABLE_IGNORED:
+ m_text.Format(IDS_NEW_UPDATE_AVAILABLE,
+ latestVersion.major, latestVersion.minor, latestVersion.patch, latestVersion.revision,
+ UpdateChecker::MPC_HC_VERSION.major, UpdateChecker::MPC_HC_VERSION.minor, UpdateChecker::MPC_HC_VERSION.patch, UpdateChecker::MPC_HC_VERSION.revision);
+ break;
+ case UPDATER_LATEST_STABLE:
+ m_text.LoadString(IDS_USING_LATEST_STABLE);
+ break;
+ case UPDATER_NEWER_VERSION:
+ m_text.Format(IDS_USING_NEWER_VERSION,
+ UpdateChecker::MPC_HC_VERSION.major, UpdateChecker::MPC_HC_VERSION.minor, UpdateChecker::MPC_HC_VERSION.patch, UpdateChecker::MPC_HC_VERSION.revision,
+ latestVersion.major, latestVersion.minor, latestVersion.patch, latestVersion.revision);
+ break;
+ case UPDATER_ERROR:
+ m_text.LoadString(IDS_UPDATE_ERROR);
+ break;
+ default:
+ ASSERT(0); // should never happen
+ }
}
UpdateCheckerDlg::~UpdateCheckerDlg()
@@ -59,73 +59,73 @@ UpdateCheckerDlg::~UpdateCheckerDlg()
void UpdateCheckerDlg::DoDataExchange(CDataExchange* pDX)
{
- CDialog::DoDataExchange(pDX);
- DDX_Text(pDX, IDC_UPDATE_DLG_TEXT, m_text);
- DDX_Control(pDX, IDC_UPDATE_ICON, m_icon);
- DDX_Control(pDX, IDC_UPDATE_DL_BUTTON, m_dlButton);
- DDX_Control(pDX, IDC_UPDATE_LATER_BUTTON, m_laterButton);
- DDX_Control(pDX, IDC_UPDATE_IGNORE_BUTTON, m_ignoreButton);
+ CDialog::DoDataExchange(pDX);
+ DDX_Text(pDX, IDC_UPDATE_DLG_TEXT, m_text);
+ DDX_Control(pDX, IDC_UPDATE_ICON, m_icon);
+ DDX_Control(pDX, IDC_UPDATE_DL_BUTTON, m_dlButton);
+ DDX_Control(pDX, IDC_UPDATE_LATER_BUTTON, m_laterButton);
+ DDX_Control(pDX, IDC_UPDATE_IGNORE_BUTTON, m_ignoreButton);
}
BEGIN_MESSAGE_MAP(UpdateCheckerDlg, CDialog)
- ON_BN_CLICKED(IDC_UPDATE_DL_BUTTON, OnOpenDownloadPage)
- ON_BN_CLICKED(IDC_UPDATE_LATER_BUTTON, OnUpdateLater)
- ON_BN_CLICKED(IDC_UPDATE_IGNORE_BUTTON, OnIgnoreUpdate)
+ ON_BN_CLICKED(IDC_UPDATE_DL_BUTTON, OnOpenDownloadPage)
+ ON_BN_CLICKED(IDC_UPDATE_LATER_BUTTON, OnUpdateLater)
+ ON_BN_CLICKED(IDC_UPDATE_IGNORE_BUTTON, OnIgnoreUpdate)
END_MESSAGE_MAP()
BOOL UpdateCheckerDlg::OnInitDialog()
{
- BOOL ret = __super::OnInitDialog();
-
- switch (m_updateStatus) {
- case UPDATER_UPDATE_AVAILABLE:
- case UPDATER_UPDATE_AVAILABLE_IGNORED:
- m_icon.SetIcon(LoadIcon(NULL, IDI_QUESTION));
- break;
- case UPDATER_LATEST_STABLE:
- case UPDATER_NEWER_VERSION:
- case UPDATER_ERROR: {
- m_icon.SetIcon(LoadIcon(NULL, (m_updateStatus == UPDATER_ERROR) ? IDI_WARNING : IDI_INFORMATION));
- m_dlButton.ShowWindow(SW_HIDE);
- m_laterButton.ShowWindow(SW_HIDE);
- m_ignoreButton.SetWindowText(ResStr(IDS_UPDATE_CLOSE));
-
- CRect buttonRect, windowRect;
- m_ignoreButton.GetWindowRect(&buttonRect);
- ScreenToClient(&buttonRect);
- // Reduce the button width
- buttonRect.left += 30;
- // Center the button
- GetWindowRect(&windowRect);
- buttonRect.MoveToX((windowRect.Width() - buttonRect.Width()) / 2);
- m_ignoreButton.MoveWindow(&buttonRect);
-
- // Change the default button
- SetDefID(IDC_UPDATE_IGNORE_BUTTON);
- ret = FALSE; // Focus has been set explicitly
- }
- break;
- default:
- ASSERT(0); // should never happen
- }
-
- return ret;
+ BOOL ret = __super::OnInitDialog();
+
+ switch (m_updateStatus) {
+ case UPDATER_UPDATE_AVAILABLE:
+ case UPDATER_UPDATE_AVAILABLE_IGNORED:
+ m_icon.SetIcon(LoadIcon(NULL, IDI_QUESTION));
+ break;
+ case UPDATER_LATEST_STABLE:
+ case UPDATER_NEWER_VERSION:
+ case UPDATER_ERROR: {
+ m_icon.SetIcon(LoadIcon(NULL, (m_updateStatus == UPDATER_ERROR) ? IDI_WARNING : IDI_INFORMATION));
+ m_dlButton.ShowWindow(SW_HIDE);
+ m_laterButton.ShowWindow(SW_HIDE);
+ m_ignoreButton.SetWindowText(ResStr(IDS_UPDATE_CLOSE));
+
+ CRect buttonRect, windowRect;
+ m_ignoreButton.GetWindowRect(&buttonRect);
+ ScreenToClient(&buttonRect);
+ // Reduce the button width
+ buttonRect.left += 30;
+ // Center the button
+ GetWindowRect(&windowRect);
+ buttonRect.MoveToX((windowRect.Width() - buttonRect.Width()) / 2);
+ m_ignoreButton.MoveWindow(&buttonRect);
+
+ // Change the default button
+ SetDefID(IDC_UPDATE_IGNORE_BUTTON);
+ ret = FALSE; // Focus has been set explicitly
+ }
+ break;
+ default:
+ ASSERT(0); // should never happen
+ }
+
+ return ret;
}
void UpdateCheckerDlg::OnOpenDownloadPage()
{
- ShellExecute(NULL, _T("open"), _T("http://mpc-hc.sourceforge.net/download-media-player-classic-hc.html"), NULL, NULL, SW_SHOWNORMAL);
+ ShellExecute(NULL, _T("open"), _T("http://mpc-hc.sourceforge.net/download-media-player-classic-hc.html"), NULL, NULL, SW_SHOWNORMAL);
- EndDialog(IDC_UPDATE_DL_BUTTON);
+ EndDialog(IDC_UPDATE_DL_BUTTON);
}
void UpdateCheckerDlg::OnUpdateLater()
{
- EndDialog(IDC_UPDATE_LATER_BUTTON);
+ EndDialog(IDC_UPDATE_LATER_BUTTON);
}
void UpdateCheckerDlg::OnIgnoreUpdate()
{
- EndDialog((m_updateStatus == UPDATER_UPDATE_AVAILABLE) ? IDC_UPDATE_IGNORE_BUTTON : 0);
+ EndDialog((m_updateStatus == UPDATER_UPDATE_AVAILABLE) ? IDC_UPDATE_IGNORE_BUTTON : 0);
}
diff --git a/src/mpc-hc/UpdateCheckerDlg.h b/src/mpc-hc/UpdateCheckerDlg.h
index d2d4bffb8..b78ef322e 100644
--- a/src/mpc-hc/UpdateCheckerDlg.h
+++ b/src/mpc-hc/UpdateCheckerDlg.h
@@ -28,27 +28,27 @@
class UpdateCheckerDlg : public CDialog
{
- DECLARE_DYNAMIC(UpdateCheckerDlg)
+ DECLARE_DYNAMIC(UpdateCheckerDlg)
public:
- UpdateCheckerDlg(Update_Status updateStatus, const Version& latestVersion, CWnd* pParent = NULL);
- virtual ~UpdateCheckerDlg();
+ UpdateCheckerDlg(Update_Status updateStatus, const Version& latestVersion, CWnd* pParent = NULL);
+ virtual ~UpdateCheckerDlg();
- enum { IDD = IDD_UPDATE_DIALOG };
+ enum { IDD = IDD_UPDATE_DIALOG };
protected:
- virtual void DoDataExchange(CDataExchange* pDX);
- afx_msg virtual BOOL OnInitDialog();
- afx_msg void OnOpenDownloadPage();
- afx_msg void OnUpdateLater();
- afx_msg void OnIgnoreUpdate();
+ virtual void DoDataExchange(CDataExchange* pDX);
+ afx_msg virtual BOOL OnInitDialog();
+ afx_msg void OnOpenDownloadPage();
+ afx_msg void OnUpdateLater();
+ afx_msg void OnIgnoreUpdate();
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
private:
- Update_Status m_updateStatus;
- CString m_text;
- CStatic m_icon;
- CButton m_dlButton;
- CButton m_laterButton;
- CButton m_ignoreButton;
+ Update_Status m_updateStatus;
+ CString m_text;
+ CStatic m_icon;
+ CButton m_dlButton;
+ CButton m_laterButton;
+ CButton m_ignoreButton;
};
diff --git a/src/mpc-hc/VMROSD.cpp b/src/mpc-hc/VMROSD.cpp
index f37fad41b..2201fe420 100644
--- a/src/mpc-hc/VMROSD.cpp
+++ b/src/mpc-hc/VMROSD.cpp
@@ -24,495 +24,495 @@
#include "VMROSD.h"
#include "mplayerc.h"
-#define SEEKBAR_HEIGHT 60
-#define SLIDER_BAR_HEIGHT 10
-#define SLIDER_CURSOR_HEIGHT 30
-#define SLIDER_CURSOR_WIDTH 15
+#define SEEKBAR_HEIGHT 60
+#define SLIDER_BAR_HEIGHT 10
+#define SLIDER_CURSOR_HEIGHT 30
+#define SLIDER_CURSOR_WIDTH 15
CVMROSD::CVMROSD(void)
{
- m_Color[OSD_TRANSPARENT] = RGB( 0, 0, 0);
- m_Color[OSD_BACKGROUND] = RGB( 32, 40, 48);
- m_Color[OSD_BORDER] = RGB( 48, 56, 62);
- m_Color[OSD_TEXT] = RGB(224, 224, 224);
- m_Color[OSD_BAR] = RGB( 64, 72, 80);
- m_Color[OSD_CURSOR] = RGB(192, 200, 208);
- m_Color[OSD_DEBUGCLR] = RGB(128, 136, 144);
-
- m_penBorder.CreatePen(PS_SOLID, 1, m_Color[OSD_BORDER]);
- m_penCursor.CreatePen(PS_SOLID, 4, m_Color[OSD_CURSOR]);
- m_brushBack.CreateSolidBrush(m_Color[OSD_BACKGROUND]);
- m_brushBar.CreateSolidBrush (m_Color[OSD_BAR]);
- m_debugBrushBack.CreateSolidBrush(m_Color[OSD_DEBUGCLR]);
- m_debugPenBorder.CreatePen(PS_SOLID, 1, m_Color[OSD_BORDER]);
-
- m_nMessagePos = OSD_NOMESSAGE;
- m_bSeekBarVisible = false;
- m_bCursorMoving = false;
- m_pMFVMB = NULL;
- m_pVMB = NULL;
- m_pMVTO = NULL;
- memset(&m_BitmapInfo, 0, sizeof(m_BitmapInfo));
-
- m_FontSize = 0;
- m_OSD_Font = _T("");
-
- m_bShowMessage = true;
+ m_Color[OSD_TRANSPARENT] = RGB(0, 0, 0);
+ m_Color[OSD_BACKGROUND] = RGB(32, 40, 48);
+ m_Color[OSD_BORDER] = RGB(48, 56, 62);
+ m_Color[OSD_TEXT] = RGB(224, 224, 224);
+ m_Color[OSD_BAR] = RGB(64, 72, 80);
+ m_Color[OSD_CURSOR] = RGB(192, 200, 208);
+ m_Color[OSD_DEBUGCLR] = RGB(128, 136, 144);
+
+ m_penBorder.CreatePen(PS_SOLID, 1, m_Color[OSD_BORDER]);
+ m_penCursor.CreatePen(PS_SOLID, 4, m_Color[OSD_CURSOR]);
+ m_brushBack.CreateSolidBrush(m_Color[OSD_BACKGROUND]);
+ m_brushBar.CreateSolidBrush(m_Color[OSD_BAR]);
+ m_debugBrushBack.CreateSolidBrush(m_Color[OSD_DEBUGCLR]);
+ m_debugPenBorder.CreatePen(PS_SOLID, 1, m_Color[OSD_BORDER]);
+
+ m_nMessagePos = OSD_NOMESSAGE;
+ m_bSeekBarVisible = false;
+ m_bCursorMoving = false;
+ m_pMFVMB = NULL;
+ m_pVMB = NULL;
+ m_pMVTO = NULL;
+ memset(&m_BitmapInfo, 0, sizeof(m_BitmapInfo));
+
+ m_FontSize = 0;
+ m_OSD_Font = _T("");
+
+ m_bShowMessage = true;
}
CVMROSD::~CVMROSD(void)
{
- m_MemDC.DeleteDC();
+ m_MemDC.DeleteDC();
}
void CVMROSD::OnSize(UINT nType, int cx, int cy)
{
- if (m_pWnd && (m_pVMB || m_pMFVMB)) {
- if (m_bSeekBarVisible) {
- m_bCursorMoving = false;
- m_bSeekBarVisible = false;
- Invalidate();
- }
- UpdateBitmap();
- }
+ if (m_pWnd && (m_pVMB || m_pMFVMB)) {
+ if (m_bSeekBarVisible) {
+ m_bCursorMoving = false;
+ m_bSeekBarVisible = false;
+ Invalidate();
+ }
+ UpdateBitmap();
+ }
}
void CVMROSD::UpdateBitmap()
{
- CAutoLock Lock(&m_Lock);
- CRect rc;
- CWindowDC dc (m_pWnd);
-
- CalcRect();
-
- m_MemDC.DeleteDC();
- memset(&m_BitmapInfo, 0, sizeof(m_BitmapInfo));
-
- if (m_MemDC.CreateCompatibleDC (&dc)) {
- BITMAPINFO bmi = {0};
- HBITMAP hbmpRender;
-
- ZeroMemory( &bmi.bmiHeader, sizeof(BITMAPINFOHEADER) );
- bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bmi.bmiHeader.biWidth = m_rectWnd.Width();
- bmi.bmiHeader.biHeight = - (int) m_rectWnd.Height(); // top-down
- bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biBitCount = 32;
- bmi.bmiHeader.biCompression = BI_RGB;
-
- hbmpRender = CreateDIBSection( m_MemDC, &bmi, DIB_RGB_COLORS, NULL, NULL, NULL );
- m_MemDC.SelectObject (hbmpRender);
-
- if (::GetObject(hbmpRender, sizeof(BITMAP), &m_BitmapInfo) != 0) {
- // Configure the VMR's bitmap structure
- if (m_pVMB) {
- ZeroMemory(&m_VMR9AlphaBitmap, sizeof(m_VMR9AlphaBitmap) );
- m_VMR9AlphaBitmap.dwFlags = VMRBITMAP_HDC | VMRBITMAP_SRCCOLORKEY;
- m_VMR9AlphaBitmap.hdc = m_MemDC;
- m_VMR9AlphaBitmap.rSrc = m_rectWnd;
- m_VMR9AlphaBitmap.rDest.left = 0;
- m_VMR9AlphaBitmap.rDest.top = 0;
- m_VMR9AlphaBitmap.rDest.right = 1.0;
- m_VMR9AlphaBitmap.rDest.bottom = 1.0;
- m_VMR9AlphaBitmap.fAlpha = 1.0;
- m_VMR9AlphaBitmap.clrSrcKey = m_Color[OSD_TRANSPARENT];
- } else if (m_pMFVMB) {
- ZeroMemory(&m_MFVideoAlphaBitmap, sizeof(m_MFVideoAlphaBitmap) );
- m_MFVideoAlphaBitmap.params.dwFlags = MFVideoAlphaBitmap_SrcColorKey;
- m_MFVideoAlphaBitmap.params.clrSrcKey = m_Color[OSD_TRANSPARENT];
- m_MFVideoAlphaBitmap.params.rcSrc = m_rectWnd;
- m_MFVideoAlphaBitmap.params.nrcDest.right = 1;
- m_MFVideoAlphaBitmap.params.nrcDest.bottom = 1;
- m_MFVideoAlphaBitmap.GetBitmapFromDC = TRUE;
- m_MFVideoAlphaBitmap.bitmap.hdc = m_MemDC;
- }
- m_MemDC.SetTextColor(m_Color[OSD_TEXT]);
- m_MemDC.SetBkMode(TRANSPARENT);
- }
-
- if (m_MainFont.GetSafeHandle()) {
- m_MemDC.SelectObject(m_MainFont);
- }
-
- DeleteObject(hbmpRender);
- }
+ CAutoLock Lock(&m_Lock);
+ CRect rc;
+ CWindowDC dc(m_pWnd);
+
+ CalcRect();
+
+ m_MemDC.DeleteDC();
+ memset(&m_BitmapInfo, 0, sizeof(m_BitmapInfo));
+
+ if (m_MemDC.CreateCompatibleDC(&dc)) {
+ BITMAPINFO bmi = {0};
+ HBITMAP hbmpRender;
+
+ ZeroMemory(&bmi.bmiHeader, sizeof(BITMAPINFOHEADER));
+ bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ bmi.bmiHeader.biWidth = m_rectWnd.Width();
+ bmi.bmiHeader.biHeight = - (int) m_rectWnd.Height(); // top-down
+ bmi.bmiHeader.biPlanes = 1;
+ bmi.bmiHeader.biBitCount = 32;
+ bmi.bmiHeader.biCompression = BI_RGB;
+
+ hbmpRender = CreateDIBSection(m_MemDC, &bmi, DIB_RGB_COLORS, NULL, NULL, NULL);
+ m_MemDC.SelectObject(hbmpRender);
+
+ if (::GetObject(hbmpRender, sizeof(BITMAP), &m_BitmapInfo) != 0) {
+ // Configure the VMR's bitmap structure
+ if (m_pVMB) {
+ ZeroMemory(&m_VMR9AlphaBitmap, sizeof(m_VMR9AlphaBitmap));
+ m_VMR9AlphaBitmap.dwFlags = VMRBITMAP_HDC | VMRBITMAP_SRCCOLORKEY;
+ m_VMR9AlphaBitmap.hdc = m_MemDC;
+ m_VMR9AlphaBitmap.rSrc = m_rectWnd;
+ m_VMR9AlphaBitmap.rDest.left = 0;
+ m_VMR9AlphaBitmap.rDest.top = 0;
+ m_VMR9AlphaBitmap.rDest.right = 1.0;
+ m_VMR9AlphaBitmap.rDest.bottom = 1.0;
+ m_VMR9AlphaBitmap.fAlpha = 1.0;
+ m_VMR9AlphaBitmap.clrSrcKey = m_Color[OSD_TRANSPARENT];
+ } else if (m_pMFVMB) {
+ ZeroMemory(&m_MFVideoAlphaBitmap, sizeof(m_MFVideoAlphaBitmap));
+ m_MFVideoAlphaBitmap.params.dwFlags = MFVideoAlphaBitmap_SrcColorKey;
+ m_MFVideoAlphaBitmap.params.clrSrcKey = m_Color[OSD_TRANSPARENT];
+ m_MFVideoAlphaBitmap.params.rcSrc = m_rectWnd;
+ m_MFVideoAlphaBitmap.params.nrcDest.right = 1;
+ m_MFVideoAlphaBitmap.params.nrcDest.bottom = 1;
+ m_MFVideoAlphaBitmap.GetBitmapFromDC = TRUE;
+ m_MFVideoAlphaBitmap.bitmap.hdc = m_MemDC;
+ }
+ m_MemDC.SetTextColor(m_Color[OSD_TEXT]);
+ m_MemDC.SetBkMode(TRANSPARENT);
+ }
+
+ if (m_MainFont.GetSafeHandle()) {
+ m_MemDC.SelectObject(m_MainFont);
+ }
+
+ DeleteObject(hbmpRender);
+ }
}
-void CVMROSD::Start (CWnd* pWnd, IVMRMixerBitmap9* pVMB)
+void CVMROSD::Start(CWnd* pWnd, IVMRMixerBitmap9* pVMB)
{
- m_pVMB = pVMB;
- m_pMFVMB = NULL;
- m_pMVTO = NULL;
- m_pWnd = pWnd;
- UpdateBitmap();
+ m_pVMB = pVMB;
+ m_pMFVMB = NULL;
+ m_pMVTO = NULL;
+ m_pWnd = pWnd;
+ UpdateBitmap();
}
-void CVMROSD::Start (CWnd* pWnd, IMFVideoMixerBitmap* pMFVMB)
+void CVMROSD::Start(CWnd* pWnd, IMFVideoMixerBitmap* pMFVMB)
{
- m_pMFVMB = pMFVMB;
- m_pVMB = NULL;
- m_pMVTO = NULL;
- m_pWnd = pWnd;
- UpdateBitmap();
+ m_pMFVMB = pMFVMB;
+ m_pVMB = NULL;
+ m_pMVTO = NULL;
+ m_pWnd = pWnd;
+ UpdateBitmap();
}
-void CVMROSD::Start (CWnd* pWnd, IMadVRTextOsd* pMVTO)
+void CVMROSD::Start(CWnd* pWnd, IMadVRTextOsd* pMVTO)
{
- m_pMFVMB = NULL;
- m_pVMB = NULL;
- m_pMVTO = pMVTO;
- m_pWnd = pWnd;
+ m_pMFVMB = NULL;
+ m_pVMB = NULL;
+ m_pMVTO = pMVTO;
+ m_pWnd = pWnd;
}
void CVMROSD::Stop()
{
- if (m_pVMB) {
- m_pVMB.Release();
- }
- if (m_pMFVMB) {
- m_pMFVMB.Release();
- }
- if (m_pMVTO) {
- m_pMVTO.Release();
- }
- m_pWnd = NULL;
+ if (m_pVMB) {
+ m_pVMB.Release();
+ }
+ if (m_pMFVMB) {
+ m_pMFVMB.Release();
+ }
+ if (m_pMVTO) {
+ m_pMVTO.Release();
+ }
+ m_pWnd = NULL;
}
void CVMROSD::CalcRect()
{
- if (m_pWnd) {
- m_pWnd->GetClientRect(&m_rectWnd);
-
- m_rectSeekBar.left = m_rectWnd.left + 10;
- m_rectSeekBar.right = m_rectWnd.right - 10;
- m_rectSeekBar.top = m_rectWnd.bottom - SEEKBAR_HEIGHT;
- m_rectSeekBar.bottom = m_rectSeekBar.top + SEEKBAR_HEIGHT;
- }
+ if (m_pWnd) {
+ m_pWnd->GetClientRect(&m_rectWnd);
+
+ m_rectSeekBar.left = m_rectWnd.left + 10;
+ m_rectSeekBar.right = m_rectWnd.right - 10;
+ m_rectSeekBar.top = m_rectWnd.bottom - SEEKBAR_HEIGHT;
+ m_rectSeekBar.bottom = m_rectSeekBar.top + SEEKBAR_HEIGHT;
+ }
}
void CVMROSD::DrawRect(CRect* rect, CBrush* pBrush, CPen* pPen)
{
- if (pPen) {
- m_MemDC.SelectObject (pPen);
- } else {
- m_MemDC.SelectStockObject(NULL_PEN);
- }
-
- if (pBrush) {
- m_MemDC.SelectObject (pBrush);
- } else {
- m_MemDC.SelectStockObject(HOLLOW_BRUSH);
- }
-
- m_MemDC.Rectangle (rect);
+ if (pPen) {
+ m_MemDC.SelectObject(pPen);
+ } else {
+ m_MemDC.SelectStockObject(NULL_PEN);
+ }
+
+ if (pBrush) {
+ m_MemDC.SelectObject(pBrush);
+ } else {
+ m_MemDC.SelectStockObject(HOLLOW_BRUSH);
+ }
+
+ m_MemDC.Rectangle(rect);
}
void CVMROSD::DrawSlider(CRect* rect, __int64 llMin, __int64 llMax, __int64 llPos)
{
- m_rectBar.left = rect->left + 10;
- m_rectBar.right = rect->right - 10;
- m_rectBar.top = rect->top + (rect->Height() - SLIDER_BAR_HEIGHT) / 2;
- m_rectBar.bottom = m_rectBar.top + SLIDER_BAR_HEIGHT;
-
- if (llMax == llMin) {
- m_rectCursor.left = m_rectBar.left;
- } else {
- m_rectCursor.left = m_rectBar.left + (long)((m_rectBar.Width() - SLIDER_CURSOR_WIDTH) * llPos / (llMax-llMin));
- }
- m_rectCursor.right = m_rectCursor.left + SLIDER_CURSOR_WIDTH;
- m_rectCursor.top = rect->top + (rect->Height() - SLIDER_CURSOR_HEIGHT) / 2;
- m_rectCursor.bottom = m_rectCursor.top + SLIDER_CURSOR_HEIGHT;
-
- DrawRect (rect, &m_brushBack, &m_penBorder);
- DrawRect (&m_rectBar, &m_brushBar);
- DrawRect (&m_rectCursor, NULL, &m_penCursor);
+ m_rectBar.left = rect->left + 10;
+ m_rectBar.right = rect->right - 10;
+ m_rectBar.top = rect->top + (rect->Height() - SLIDER_BAR_HEIGHT) / 2;
+ m_rectBar.bottom = m_rectBar.top + SLIDER_BAR_HEIGHT;
+
+ if (llMax == llMin) {
+ m_rectCursor.left = m_rectBar.left;
+ } else {
+ m_rectCursor.left = m_rectBar.left + (long)((m_rectBar.Width() - SLIDER_CURSOR_WIDTH) * llPos / (llMax - llMin));
+ }
+ m_rectCursor.right = m_rectCursor.left + SLIDER_CURSOR_WIDTH;
+ m_rectCursor.top = rect->top + (rect->Height() - SLIDER_CURSOR_HEIGHT) / 2;
+ m_rectCursor.bottom = m_rectCursor.top + SLIDER_CURSOR_HEIGHT;
+
+ DrawRect(rect, &m_brushBack, &m_penBorder);
+ DrawRect(&m_rectBar, &m_brushBar);
+ DrawRect(&m_rectCursor, NULL, &m_penCursor);
}
void CVMROSD::DrawMessage()
{
- if (m_BitmapInfo.bmWidth*m_BitmapInfo.bmHeight*(m_BitmapInfo.bmBitsPixel/8) == 0) {
- return;
- }
- if (m_nMessagePos != OSD_NOMESSAGE) {
- CRect rectText (0,0,0,0);
- CRect rectMessages;
-
- m_MemDC.DrawText (m_strMessage, &rectText, DT_CALCRECT);
- rectText.InflateRect(20, 10);
- switch (m_nMessagePos) {
- case OSD_TOPLEFT :
- rectMessages = CRect (10, 10, min((rectText.right + 10),(m_rectWnd.right - 10)), (rectText.bottom + 10));
- break;
- case OSD_TOPRIGHT :
- default :
- rectMessages = CRect (max(10,m_rectWnd.right-10-rectText.Width()), 10, m_rectWnd.right-10, rectText.bottom + 10);
- break;
- }
- DrawRect (&rectMessages, &m_brushBack, &m_penBorder);
- DWORD uFormat = DT_SINGLELINE|DT_CENTER|DT_VCENTER|DT_NOPREFIX;
- if (rectText.right > (m_rectWnd.right - 20)) {
- m_strMessage = _T(" ") + m_strMessage;
- uFormat = uFormat|DT_END_ELLIPSIS;
- }
- m_MemDC.DrawText (m_strMessage, &rectMessages, uFormat);
- }
+ if (m_BitmapInfo.bmWidth * m_BitmapInfo.bmHeight * (m_BitmapInfo.bmBitsPixel / 8) == 0) {
+ return;
+ }
+ if (m_nMessagePos != OSD_NOMESSAGE) {
+ CRect rectText(0, 0, 0, 0);
+ CRect rectMessages;
+
+ m_MemDC.DrawText(m_strMessage, &rectText, DT_CALCRECT);
+ rectText.InflateRect(20, 10);
+ switch (m_nMessagePos) {
+ case OSD_TOPLEFT :
+ rectMessages = CRect(10, 10, min((rectText.right + 10), (m_rectWnd.right - 10)), (rectText.bottom + 10));
+ break;
+ case OSD_TOPRIGHT :
+ default :
+ rectMessages = CRect(max(10, m_rectWnd.right - 10 - rectText.Width()), 10, m_rectWnd.right - 10, rectText.bottom + 10);
+ break;
+ }
+ DrawRect(&rectMessages, &m_brushBack, &m_penBorder);
+ DWORD uFormat = DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_NOPREFIX;
+ if (rectText.right > (m_rectWnd.right - 20)) {
+ m_strMessage = _T(" ") + m_strMessage;
+ uFormat = uFormat | DT_END_ELLIPSIS;
+ }
+ m_MemDC.DrawText(m_strMessage, &rectMessages, uFormat);
+ }
}
void CVMROSD::DrawDebug()
{
- if ( !m_debugMessages.IsEmpty() ) {
- CString msg, tmp;
- POSITION pos;
- pos = m_debugMessages.GetHeadPosition();
- msg.Format(_T("%s"), m_debugMessages.GetNext(pos));
-
- while (pos) {
- tmp = m_debugMessages.GetNext(pos);
- if ( !tmp.IsEmpty() ) {
- msg.AppendFormat(_T("\r\n%s"), tmp);
- }
- }
-
- CRect rectText(0,0,0,0);
- CRect rectMessages;
- m_MemDC.DrawText(msg, &rectText, DT_CALCRECT);
- rectText.InflateRect(20, 10);
-
- int l, r, t, b;
- l = (m_rectWnd.Width() >> 1) - (rectText.Width() >> 1) - 10;
- r = (m_rectWnd.Width() >> 1) + (rectText.Width() >> 1) + 10;
- t = (m_rectWnd.Height() >> 1) - (rectText.Height() >> 1) - 10;
- b = (m_rectWnd.Height() >> 1) + (rectText.Height() >> 1) + 10;
- rectMessages = CRect(l, t, r, b);
- DrawRect(&rectMessages, &m_debugBrushBack, &m_debugPenBorder);
- m_MemDC.DrawText(msg, &rectMessages, DT_CENTER | DT_VCENTER);
- }
+ if (!m_debugMessages.IsEmpty()) {
+ CString msg, tmp;
+ POSITION pos;
+ pos = m_debugMessages.GetHeadPosition();
+ msg.Format(_T("%s"), m_debugMessages.GetNext(pos));
+
+ while (pos) {
+ tmp = m_debugMessages.GetNext(pos);
+ if (!tmp.IsEmpty()) {
+ msg.AppendFormat(_T("\r\n%s"), tmp);
+ }
+ }
+
+ CRect rectText(0, 0, 0, 0);
+ CRect rectMessages;
+ m_MemDC.DrawText(msg, &rectText, DT_CALCRECT);
+ rectText.InflateRect(20, 10);
+
+ int l, r, t, b;
+ l = (m_rectWnd.Width() >> 1) - (rectText.Width() >> 1) - 10;
+ r = (m_rectWnd.Width() >> 1) + (rectText.Width() >> 1) + 10;
+ t = (m_rectWnd.Height() >> 1) - (rectText.Height() >> 1) - 10;
+ b = (m_rectWnd.Height() >> 1) + (rectText.Height() >> 1) + 10;
+ rectMessages = CRect(l, t, r, b);
+ DrawRect(&rectMessages, &m_debugBrushBack, &m_debugPenBorder);
+ m_MemDC.DrawText(msg, &rectMessages, DT_CENTER | DT_VCENTER);
+ }
}
void CVMROSD::Invalidate()
{
- CAutoLock Lock(&m_Lock);
- if (m_BitmapInfo.bmWidth*m_BitmapInfo.bmHeight*(m_BitmapInfo.bmBitsPixel/8) == 0) {
- return;
- }
- memsetd(m_BitmapInfo.bmBits, 0xff000000, m_BitmapInfo.bmWidth*m_BitmapInfo.bmHeight*(m_BitmapInfo.bmBitsPixel/8));
-
- if (m_bSeekBarVisible) {
- DrawSlider(&m_rectSeekBar, m_llSeekMin, m_llSeekMax, m_llSeekPos);
- }
- DrawMessage();
- DrawDebug();
-
- if (m_pVMB) {
- m_VMR9AlphaBitmap.dwFlags &= ~VMRBITMAP_DISABLE;
- m_pVMB->SetAlphaBitmap(&m_VMR9AlphaBitmap);
- } else if (m_pMFVMB) {
- m_pMFVMB->SetAlphaBitmap (&m_MFVideoAlphaBitmap);
- }
+ CAutoLock Lock(&m_Lock);
+ if (m_BitmapInfo.bmWidth * m_BitmapInfo.bmHeight * (m_BitmapInfo.bmBitsPixel / 8) == 0) {
+ return;
+ }
+ memsetd(m_BitmapInfo.bmBits, 0xff000000, m_BitmapInfo.bmWidth * m_BitmapInfo.bmHeight * (m_BitmapInfo.bmBitsPixel / 8));
+
+ if (m_bSeekBarVisible) {
+ DrawSlider(&m_rectSeekBar, m_llSeekMin, m_llSeekMax, m_llSeekPos);
+ }
+ DrawMessage();
+ DrawDebug();
+
+ if (m_pVMB) {
+ m_VMR9AlphaBitmap.dwFlags &= ~VMRBITMAP_DISABLE;
+ m_pVMB->SetAlphaBitmap(&m_VMR9AlphaBitmap);
+ } else if (m_pMFVMB) {
+ m_pMFVMB->SetAlphaBitmap(&m_MFVideoAlphaBitmap);
+ }
}
void CVMROSD::UpdateSeekBarPos(CPoint point)
{
- m_llSeekPos = (point.x - m_rectBar.left) * (m_llSeekMax-m_llSeekMin) / (m_rectBar.Width() - SLIDER_CURSOR_WIDTH);
- m_llSeekPos = max (m_llSeekPos, m_llSeekMin);
- m_llSeekPos = min (m_llSeekPos, m_llSeekMax);
+ m_llSeekPos = (point.x - m_rectBar.left) * (m_llSeekMax - m_llSeekMin) / (m_rectBar.Width() - SLIDER_CURSOR_WIDTH);
+ m_llSeekPos = max(m_llSeekPos, m_llSeekMin);
+ m_llSeekPos = min(m_llSeekPos, m_llSeekMax);
- if (m_pWnd) {
- AfxGetApp()->GetMainWnd()->PostMessage(WM_HSCROLL, MAKEWPARAM((short)m_llSeekPos, SB_THUMBTRACK), (LPARAM)m_pWnd->m_hWnd);
- }
+ if (m_pWnd) {
+ AfxGetApp()->GetMainWnd()->PostMessage(WM_HSCROLL, MAKEWPARAM((short)m_llSeekPos, SB_THUMBTRACK), (LPARAM)m_pWnd->m_hWnd);
+ }
}
bool CVMROSD::OnMouseMove(UINT nFlags, CPoint point)
{
- bool bRet = false;
-
- if (m_pVMB || m_pMFVMB) {
- if (m_bCursorMoving) {
- UpdateSeekBarPos(point);
- Invalidate();
- } else if (!m_bSeekBarVisible && AfxGetAppSettings().IsD3DFullscreen() && m_rectSeekBar.PtInRect(point)) {
- m_bSeekBarVisible = true;
- Invalidate();
- } else if (m_bSeekBarVisible && !m_rectSeekBar.PtInRect(point)) {
- m_bSeekBarVisible = false;
- // Add new timer for removing any messages
- if (m_pWnd) {
- KillTimer(m_pWnd->m_hWnd, (UINT_PTR)this);
- SetTimer(m_pWnd->m_hWnd, (UINT_PTR)this, 1000, (TIMERPROC)TimerFunc);
- }
- Invalidate();
- } else {
- bRet = false;
- }
- }
-
- return bRet;
+ bool bRet = false;
+
+ if (m_pVMB || m_pMFVMB) {
+ if (m_bCursorMoving) {
+ UpdateSeekBarPos(point);
+ Invalidate();
+ } else if (!m_bSeekBarVisible && AfxGetAppSettings().IsD3DFullscreen() && m_rectSeekBar.PtInRect(point)) {
+ m_bSeekBarVisible = true;
+ Invalidate();
+ } else if (m_bSeekBarVisible && !m_rectSeekBar.PtInRect(point)) {
+ m_bSeekBarVisible = false;
+ // Add new timer for removing any messages
+ if (m_pWnd) {
+ KillTimer(m_pWnd->m_hWnd, (UINT_PTR)this);
+ SetTimer(m_pWnd->m_hWnd, (UINT_PTR)this, 1000, (TIMERPROC)TimerFunc);
+ }
+ Invalidate();
+ } else {
+ bRet = false;
+ }
+ }
+
+ return bRet;
}
bool CVMROSD::OnLButtonDown(UINT nFlags, CPoint point)
{
- bool bRet = false;
- if (m_pVMB || m_pMFVMB) {
- if (m_rectCursor.PtInRect (point)) {
- m_bCursorMoving = true;
- bRet = true;
- } else if (m_rectSeekBar.PtInRect(point)) {
- bRet = true;
- UpdateSeekBarPos(point);
- Invalidate();
- }
- }
-
- return bRet;
+ bool bRet = false;
+ if (m_pVMB || m_pMFVMB) {
+ if (m_rectCursor.PtInRect(point)) {
+ m_bCursorMoving = true;
+ bRet = true;
+ } else if (m_rectSeekBar.PtInRect(point)) {
+ bRet = true;
+ UpdateSeekBarPos(point);
+ Invalidate();
+ }
+ }
+
+ return bRet;
}
bool CVMROSD::OnLButtonUp(UINT nFlags, CPoint point)
{
- bool bRet = false;
+ bool bRet = false;
- if (m_pVMB || m_pMFVMB) {
- m_bCursorMoving = false;
+ if (m_pVMB || m_pMFVMB) {
+ m_bCursorMoving = false;
- bRet = (m_rectCursor.PtInRect (point) || m_rectSeekBar.PtInRect(point));
- }
- return bRet;
+ bRet = (m_rectCursor.PtInRect(point) || m_rectSeekBar.PtInRect(point));
+ }
+ return bRet;
}
__int64 CVMROSD::GetPos() const
{
- return m_llSeekPos;
+ return m_llSeekPos;
}
void CVMROSD::SetPos(__int64 pos)
{
- m_llSeekPos = pos;
+ m_llSeekPos = pos;
}
void CVMROSD::SetRange(__int64 start, __int64 stop)
{
- m_llSeekMin = start;
- m_llSeekMax = stop;
+ m_llSeekMin = start;
+ m_llSeekMax = stop;
}
void CVMROSD::GetRange(__int64& start, __int64& stop)
{
- start = m_llSeekMin;
- stop = m_llSeekMax;
+ start = m_llSeekMin;
+ stop = m_llSeekMax;
}
void CVMROSD::TimerFunc(HWND hWnd, UINT nMsg, UINT nIDEvent, DWORD dwTime)
{
- CVMROSD* pVMROSD = (CVMROSD*) nIDEvent;
- if (pVMROSD) {
- pVMROSD->ClearMessage();
- }
- KillTimer(hWnd, nIDEvent);
+ CVMROSD* pVMROSD = (CVMROSD*) nIDEvent;
+ if (pVMROSD) {
+ pVMROSD->ClearMessage();
+ }
+ KillTimer(hWnd, nIDEvent);
}
void CVMROSD::ClearMessage(bool hide)
{
- CAutoLock Lock(&m_Lock);
- if (m_bSeekBarVisible) {
- return;
- }
-
- if (!hide) {
- m_nMessagePos = OSD_NOMESSAGE;
- }
-
- if (m_pVMB) {
- DWORD dwBackup = (m_VMR9AlphaBitmap.dwFlags | VMRBITMAP_DISABLE);
- m_VMR9AlphaBitmap.dwFlags = VMRBITMAP_DISABLE;
- m_pVMB->SetAlphaBitmap(&m_VMR9AlphaBitmap);
- m_VMR9AlphaBitmap.dwFlags = dwBackup;
- } else if (m_pMFVMB) {
- m_pMFVMB->ClearAlphaBitmap();
- } else if (m_pMVTO) {
- m_pMVTO->OsdClearMessage();
- }
+ CAutoLock Lock(&m_Lock);
+ if (m_bSeekBarVisible) {
+ return;
+ }
+
+ if (!hide) {
+ m_nMessagePos = OSD_NOMESSAGE;
+ }
+
+ if (m_pVMB) {
+ DWORD dwBackup = (m_VMR9AlphaBitmap.dwFlags | VMRBITMAP_DISABLE);
+ m_VMR9AlphaBitmap.dwFlags = VMRBITMAP_DISABLE;
+ m_pVMB->SetAlphaBitmap(&m_VMR9AlphaBitmap);
+ m_VMR9AlphaBitmap.dwFlags = dwBackup;
+ } else if (m_pMFVMB) {
+ m_pMFVMB->ClearAlphaBitmap();
+ } else if (m_pMVTO) {
+ m_pMVTO->OsdClearMessage();
+ }
}
-void CVMROSD::DisplayMessage (OSD_MESSAGEPOS nPos, LPCTSTR strMsg, int nDuration, int FontSize, CString OSD_Font)
+void CVMROSD::DisplayMessage(OSD_MESSAGEPOS nPos, LPCTSTR strMsg, int nDuration, int FontSize, CString OSD_Font)
{
- if (!m_bShowMessage) {
- return;
- }
-
- if (m_pVMB || m_pMFVMB) {
- if ( nPos != OSD_DEBUG ) {
- m_nMessagePos = nPos;
- m_strMessage = strMsg;
- } else {
- m_debugMessages.AddTail(strMsg);
- if ( m_debugMessages.GetCount() > 20 ) {
- m_debugMessages.RemoveHead();
- }
- nDuration = -1;
- }
-
- int temp_m_FontSize = m_FontSize;
- CString temp_m_OSD_Font = m_OSD_Font;
-
- if (FontSize == 0) {
- m_FontSize = AfxGetAppSettings().nOSDSize;
- } else {
- m_FontSize = FontSize;
- }
- if (m_FontSize<10 || m_FontSize>26) {
- m_FontSize=20;
- }
- if (OSD_Font == _T("")) {
- m_OSD_Font = AfxGetAppSettings().strOSDFont;
- } else {
- m_OSD_Font = OSD_Font;
- }
-
- if ((temp_m_FontSize != m_FontSize) || (temp_m_OSD_Font != m_OSD_Font)) {
- if (m_MainFont.GetSafeHandle()) {
- m_MainFont.DeleteObject();
- }
-
- m_MainFont.CreatePointFont(m_FontSize*10, m_OSD_Font);
- m_MemDC.SelectObject(m_MainFont);
- }
-
- if (m_pWnd) {
- KillTimer(m_pWnd->m_hWnd, (UINT_PTR)this);
- if (nDuration != -1) {
- SetTimer(m_pWnd->m_hWnd, (UINT_PTR)this, nDuration, (TIMERPROC)TimerFunc);
- }
- }
- Invalidate();
- } else if (m_pMVTO) {
- m_pMVTO->OsdDisplayMessage(strMsg, nDuration);
- }
+ if (!m_bShowMessage) {
+ return;
+ }
+
+ if (m_pVMB || m_pMFVMB) {
+ if (nPos != OSD_DEBUG) {
+ m_nMessagePos = nPos;
+ m_strMessage = strMsg;
+ } else {
+ m_debugMessages.AddTail(strMsg);
+ if (m_debugMessages.GetCount() > 20) {
+ m_debugMessages.RemoveHead();
+ }
+ nDuration = -1;
+ }
+
+ int temp_m_FontSize = m_FontSize;
+ CString temp_m_OSD_Font = m_OSD_Font;
+
+ if (FontSize == 0) {
+ m_FontSize = AfxGetAppSettings().nOSDSize;
+ } else {
+ m_FontSize = FontSize;
+ }
+ if (m_FontSize < 10 || m_FontSize > 26) {
+ m_FontSize = 20;
+ }
+ if (OSD_Font == _T("")) {
+ m_OSD_Font = AfxGetAppSettings().strOSDFont;
+ } else {
+ m_OSD_Font = OSD_Font;
+ }
+
+ if ((temp_m_FontSize != m_FontSize) || (temp_m_OSD_Font != m_OSD_Font)) {
+ if (m_MainFont.GetSafeHandle()) {
+ m_MainFont.DeleteObject();
+ }
+
+ m_MainFont.CreatePointFont(m_FontSize * 10, m_OSD_Font);
+ m_MemDC.SelectObject(m_MainFont);
+ }
+
+ if (m_pWnd) {
+ KillTimer(m_pWnd->m_hWnd, (UINT_PTR)this);
+ if (nDuration != -1) {
+ SetTimer(m_pWnd->m_hWnd, (UINT_PTR)this, nDuration, (TIMERPROC)TimerFunc);
+ }
+ }
+ Invalidate();
+ } else if (m_pMVTO) {
+ m_pMVTO->OsdDisplayMessage(strMsg, nDuration);
+ }
}
-void CVMROSD::DebugMessage( LPCTSTR format, ... )
+void CVMROSD::DebugMessage(LPCTSTR format, ...)
{
- CString tmp;
- va_list argList;
- va_start(argList, format);
- tmp.FormatV(format, argList);
- va_end(argList);
+ CString tmp;
+ va_list argList;
+ va_start(argList, format);
+ tmp.FormatV(format, argList);
+ va_end(argList);
- DisplayMessage(OSD_DEBUG, tmp);
+ DisplayMessage(OSD_DEBUG, tmp);
}
void CVMROSD::HideMessage(bool hide)
{
- if (m_pVMB || m_pMFVMB) {
- if (hide) {
- ClearMessage(true);
- } else {
- Invalidate();
- }
- }
+ if (m_pVMB || m_pMFVMB) {
+ if (hide) {
+ ClearMessage(true);
+ } else {
+ Invalidate();
+ }
+ }
}
void CVMROSD::EnableShowMessage(bool enabled)
{
- m_bShowMessage = enabled;
+ m_bShowMessage = enabled;
} \ No newline at end of file
diff --git a/src/mpc-hc/VMROSD.h b/src/mpc-hc/VMROSD.h
index b8c29ef41..e973e6cdf 100644
--- a/src/mpc-hc/VMROSD.h
+++ b/src/mpc-hc/VMROSD.h
@@ -30,103 +30,103 @@
typedef enum {
- OSD_TRANSPARENT,
- OSD_BACKGROUND,
- OSD_BORDER,
- OSD_TEXT,
- OSD_BAR,
- OSD_CURSOR,
- OSD_DEBUGCLR,
- OSD_LAST
+ OSD_TRANSPARENT,
+ OSD_BACKGROUND,
+ OSD_BORDER,
+ OSD_TEXT,
+ OSD_BAR,
+ OSD_CURSOR,
+ OSD_DEBUGCLR,
+ OSD_LAST
} OSD_COLORS;
typedef enum {
- OSD_NOMESSAGE,
- OSD_TOPLEFT,
- OSD_TOPRIGHT,
- OSD_DEBUG,
+ OSD_NOMESSAGE,
+ OSD_TOPLEFT,
+ OSD_TOPRIGHT,
+ OSD_DEBUG,
} OSD_MESSAGEPOS;
class CVMROSD
{
public:
- CVMROSD(void);
- ~CVMROSD(void);
-
- void Start (CWnd* pWnd, IVMRMixerBitmap9* pVMB);
- void Start (CWnd* pWnd, IMFVideoMixerBitmap* pVMB);
- void Start (CWnd* pWnd, IMadVRTextOsd* pMVTO);
- void Stop();
-
- void DisplayMessage (OSD_MESSAGEPOS nPos, LPCTSTR strMsg, int nDuration = 5000, int FontSize = 0, CString OSD_Font = _T(""));
- void DebugMessage( LPCTSTR format, ... );
- void ClearMessage(bool hide=false);
- void HideMessage(bool hide);
- void EnableShowMessage(bool enabled = true);
-
- __int64 GetPos() const;
- void SetPos(__int64 pos);
- void SetRange(__int64 start, __int64 stop);
- void GetRange(__int64& start, __int64& stop);
-
- void OnSize(UINT nType, int cx, int cy);
- bool OnMouseMove(UINT nFlags, CPoint point);
- bool OnLButtonDown(UINT nFlags, CPoint point);
- bool OnLButtonUp(UINT nFlags, CPoint point);
+ CVMROSD(void);
+ ~CVMROSD(void);
+
+ void Start(CWnd* pWnd, IVMRMixerBitmap9* pVMB);
+ void Start(CWnd* pWnd, IMFVideoMixerBitmap* pVMB);
+ void Start(CWnd* pWnd, IMadVRTextOsd* pMVTO);
+ void Stop();
+
+ void DisplayMessage(OSD_MESSAGEPOS nPos, LPCTSTR strMsg, int nDuration = 5000, int FontSize = 0, CString OSD_Font = _T(""));
+ void DebugMessage(LPCTSTR format, ...);
+ void ClearMessage(bool hide = false);
+ void HideMessage(bool hide);
+ void EnableShowMessage(bool enabled = true);
+
+ __int64 GetPos() const;
+ void SetPos(__int64 pos);
+ void SetRange(__int64 start, __int64 stop);
+ void GetRange(__int64& start, __int64& stop);
+
+ void OnSize(UINT nType, int cx, int cy);
+ bool OnMouseMove(UINT nFlags, CPoint point);
+ bool OnLButtonDown(UINT nFlags, CPoint point);
+ bool OnLButtonUp(UINT nFlags, CPoint point);
private :
- CComPtr<IVMRMixerBitmap9> m_pVMB;
- CComPtr<IMFVideoMixerBitmap> m_pMFVMB;
- CComPtr<IMadVRTextOsd> m_pMVTO;
-
- CWnd* m_pWnd;
-
- CCritSec m_Lock;
- CDC m_MemDC;
- VMR9AlphaBitmap m_VMR9AlphaBitmap;
- MFVideoAlphaBitmap m_MFVideoAlphaBitmap;
- BITMAP m_BitmapInfo;
-
- CFont m_MainFont;
- CPen m_penBorder;
- CPen m_penCursor;
- CBrush m_brushBack;
- CBrush m_brushBar;
- CPen m_debugPenBorder;
- CBrush m_debugBrushBack;
- int m_FontSize;
- CString m_OSD_Font;
-
- CRect m_rectWnd;
- COLORREF m_Color[OSD_LAST];
-
- // Curseur de calage
- CRect m_rectSeekBar;
- CRect m_rectCursor;
- CRect m_rectBar;
- bool m_bCursorMoving;
- bool m_bSeekBarVisible;
- __int64 m_llSeekMin;
- __int64 m_llSeekMax;
- __int64 m_llSeekPos;
-
- bool m_bShowMessage;
-
- // Messages
- CString m_strMessage;
- OSD_MESSAGEPOS m_nMessagePos;
- CList<CString> m_debugMessages;
-
- void UpdateBitmap();
- void CalcRect();
- void UpdateSeekBarPos(CPoint point);
- void DrawSlider(CRect* rect, __int64 llMin, __int64 llMax, __int64 llPos);
- void DrawRect(CRect* rect, CBrush* pBrush = NULL, CPen* pPen = NULL);
- void Invalidate();
- void DrawMessage();
- void DrawDebug();
-
- static void CALLBACK TimerFunc(HWND hWnd, UINT nMsg, UINT nIDEvent, DWORD dwTime);
+ CComPtr<IVMRMixerBitmap9> m_pVMB;
+ CComPtr<IMFVideoMixerBitmap> m_pMFVMB;
+ CComPtr<IMadVRTextOsd> m_pMVTO;
+
+ CWnd* m_pWnd;
+
+ CCritSec m_Lock;
+ CDC m_MemDC;
+ VMR9AlphaBitmap m_VMR9AlphaBitmap;
+ MFVideoAlphaBitmap m_MFVideoAlphaBitmap;
+ BITMAP m_BitmapInfo;
+
+ CFont m_MainFont;
+ CPen m_penBorder;
+ CPen m_penCursor;
+ CBrush m_brushBack;
+ CBrush m_brushBar;
+ CPen m_debugPenBorder;
+ CBrush m_debugBrushBack;
+ int m_FontSize;
+ CString m_OSD_Font;
+
+ CRect m_rectWnd;
+ COLORREF m_Color[OSD_LAST];
+
+ // Curseur de calage
+ CRect m_rectSeekBar;
+ CRect m_rectCursor;
+ CRect m_rectBar;
+ bool m_bCursorMoving;
+ bool m_bSeekBarVisible;
+ __int64 m_llSeekMin;
+ __int64 m_llSeekMax;
+ __int64 m_llSeekPos;
+
+ bool m_bShowMessage;
+
+ // Messages
+ CString m_strMessage;
+ OSD_MESSAGEPOS m_nMessagePos;
+ CList<CString> m_debugMessages;
+
+ void UpdateBitmap();
+ void CalcRect();
+ void UpdateSeekBarPos(CPoint point);
+ void DrawSlider(CRect* rect, __int64 llMin, __int64 llMax, __int64 llPos);
+ void DrawRect(CRect* rect, CBrush* pBrush = NULL, CPen* pPen = NULL);
+ void Invalidate();
+ void DrawMessage();
+ void DrawDebug();
+
+ static void CALLBACK TimerFunc(HWND hWnd, UINT nMsg, UINT nIDEvent, DWORD dwTime);
};
diff --git a/src/mpc-hc/VolumeCtrl.cpp b/src/mpc-hc/VolumeCtrl.cpp
index 491be62e6..2ec4a3fc6 100644
--- a/src/mpc-hc/VolumeCtrl.cpp
+++ b/src/mpc-hc/VolumeCtrl.cpp
@@ -39,167 +39,167 @@ CVolumeCtrl::~CVolumeCtrl()
bool CVolumeCtrl::Create(CWnd* pParentWnd)
{
- if (!CSliderCtrl::Create(WS_CHILD|WS_VISIBLE|TBS_NOTICKS|TBS_HORZ|TBS_TOOLTIPS, CRect(0,0,0,0), pParentWnd, IDC_SLIDER1)) {
- return false;
- }
- EnableToolTips(TRUE);
- SetRange(0, 100);
- SetPosInternal(AfxGetAppSettings().nVolume);
- SetPageSize(5);
- SetLineSize(0);
-
- return true;
+ if (!CSliderCtrl::Create(WS_CHILD | WS_VISIBLE | TBS_NOTICKS | TBS_HORZ | TBS_TOOLTIPS, CRect(0, 0, 0, 0), pParentWnd, IDC_SLIDER1)) {
+ return false;
+ }
+ EnableToolTips(TRUE);
+ SetRange(0, 100);
+ SetPosInternal(AfxGetAppSettings().nVolume);
+ SetPageSize(5);
+ SetLineSize(0);
+
+ return true;
}
void CVolumeCtrl::SetPosInternal(int pos)
{
- SetPos(pos);
- GetParent()->PostMessage(WM_HSCROLL, MAKEWPARAM((short)pos, SB_THUMBPOSITION), (LPARAM)m_hWnd); // this will be reflected back on us
+ SetPos(pos);
+ GetParent()->PostMessage(WM_HSCROLL, MAKEWPARAM((short)pos, SB_THUMBPOSITION), (LPARAM)m_hWnd); // this will be reflected back on us
}
void CVolumeCtrl::IncreaseVolume()
{
- SetPosInternal(GetPos() + GetPageSize());
+ SetPosInternal(GetPos() + GetPageSize());
}
void CVolumeCtrl::DecreaseVolume()
{
- SetPosInternal(GetPos() - GetPageSize());
+ SetPosInternal(GetPos() - GetPageSize());
}
BEGIN_MESSAGE_MAP(CVolumeCtrl, CSliderCtrl)
- ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnNMCustomdraw)
- ON_WM_LBUTTONDOWN()
- ON_WM_SETFOCUS()
- ON_WM_HSCROLL_REFLECT()
- ON_WM_SETCURSOR()
- ON_NOTIFY_EX(TTN_NEEDTEXT, 0, OnToolTipNotify)
+ ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnNMCustomdraw)
+ ON_WM_LBUTTONDOWN()
+ ON_WM_SETFOCUS()
+ ON_WM_HSCROLL_REFLECT()
+ ON_WM_SETCURSOR()
+ ON_NOTIFY_EX(TTN_NEEDTEXT, 0, OnToolTipNotify)
END_MESSAGE_MAP()
// CVolumeCtrl message handlers
void CVolumeCtrl::OnNMCustomdraw(NMHDR* pNMHDR, LRESULT* pResult)
{
- LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR);
-
- LRESULT lr = CDRF_DODEFAULT;
-
- if (m_fSelfDrawn)
- switch (pNMCD->dwDrawStage) {
- case CDDS_PREPAINT:
- lr = CDRF_NOTIFYITEMDRAW;
- break;
-
- case CDDS_ITEMPREPAINT:
- if (pNMCD->dwItemSpec == TBCD_CHANNEL) {
- CDC dc;
- dc.Attach(pNMCD->hdc);
-
- CRect r;
- GetClientRect(r);
- r.DeflateRect(8, 4, 10, 6);
- CopyRect(&pNMCD->rc, &r);
- CPen shadow(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW));
- CPen light(PS_SOLID, 1, GetSysColor(COLOR_3DHILIGHT));
- CPen* old = dc.SelectObject(&light);
- dc.MoveTo(pNMCD->rc.right, pNMCD->rc.top);
- dc.LineTo(pNMCD->rc.right, pNMCD->rc.bottom);
- dc.LineTo(pNMCD->rc.left, pNMCD->rc.bottom);
- dc.SelectObject(&shadow);
- dc.LineTo(pNMCD->rc.right, pNMCD->rc.top);
- dc.SelectObject(old);
-
- dc.Detach();
- lr = CDRF_SKIPDEFAULT;
- } else if (pNMCD->dwItemSpec == TBCD_THUMB) {
- CDC dc;
- dc.Attach(pNMCD->hdc);
- pNMCD->rc.bottom--;
- CRect r(pNMCD->rc);
- r.DeflateRect(0, 0, 1, 0);
-
- COLORREF shadow = GetSysColor(COLOR_3DSHADOW);
- COLORREF light = GetSysColor(COLOR_3DHILIGHT);
- dc.Draw3dRect(&r, light, 0);
- r.DeflateRect(0, 0, 1, 1);
- dc.Draw3dRect(&r, light, shadow);
- r.DeflateRect(1, 1, 1, 1);
- dc.FillSolidRect(&r, GetSysColor(COLOR_BTNFACE));
- dc.SetPixel(r.left+7, r.top-1, GetSysColor(COLOR_BTNFACE));
-
- dc.Detach();
- lr = CDRF_SKIPDEFAULT;
- }
-
- break;
- };
-
- pNMCD->uItemState &= ~CDIS_FOCUS;
-
- *pResult = lr;
+ LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR);
+
+ LRESULT lr = CDRF_DODEFAULT;
+
+ if (m_fSelfDrawn)
+ switch (pNMCD->dwDrawStage) {
+ case CDDS_PREPAINT:
+ lr = CDRF_NOTIFYITEMDRAW;
+ break;
+
+ case CDDS_ITEMPREPAINT:
+ if (pNMCD->dwItemSpec == TBCD_CHANNEL) {
+ CDC dc;
+ dc.Attach(pNMCD->hdc);
+
+ CRect r;
+ GetClientRect(r);
+ r.DeflateRect(8, 4, 10, 6);
+ CopyRect(&pNMCD->rc, &r);
+ CPen shadow(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW));
+ CPen light(PS_SOLID, 1, GetSysColor(COLOR_3DHILIGHT));
+ CPen* old = dc.SelectObject(&light);
+ dc.MoveTo(pNMCD->rc.right, pNMCD->rc.top);
+ dc.LineTo(pNMCD->rc.right, pNMCD->rc.bottom);
+ dc.LineTo(pNMCD->rc.left, pNMCD->rc.bottom);
+ dc.SelectObject(&shadow);
+ dc.LineTo(pNMCD->rc.right, pNMCD->rc.top);
+ dc.SelectObject(old);
+
+ dc.Detach();
+ lr = CDRF_SKIPDEFAULT;
+ } else if (pNMCD->dwItemSpec == TBCD_THUMB) {
+ CDC dc;
+ dc.Attach(pNMCD->hdc);
+ pNMCD->rc.bottom--;
+ CRect r(pNMCD->rc);
+ r.DeflateRect(0, 0, 1, 0);
+
+ COLORREF shadow = GetSysColor(COLOR_3DSHADOW);
+ COLORREF light = GetSysColor(COLOR_3DHILIGHT);
+ dc.Draw3dRect(&r, light, 0);
+ r.DeflateRect(0, 0, 1, 1);
+ dc.Draw3dRect(&r, light, shadow);
+ r.DeflateRect(1, 1, 1, 1);
+ dc.FillSolidRect(&r, GetSysColor(COLOR_BTNFACE));
+ dc.SetPixel(r.left + 7, r.top - 1, GetSysColor(COLOR_BTNFACE));
+
+ dc.Detach();
+ lr = CDRF_SKIPDEFAULT;
+ }
+
+ break;
+ };
+
+ pNMCD->uItemState &= ~CDIS_FOCUS;
+
+ *pResult = lr;
}
void CVolumeCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
- CRect r;
- GetChannelRect(&r);
-
- if (r.left >= r.right) {
- return;
- }
-
- int start, stop;
- GetRange(start, stop);
-
- r.left += 3;
- r.right -= 4;
-
- if (point.x < r.left) {
- SetPos(start);
- } else if (point.x >= r.right) {
- SetPos(stop);
- } else {
- int w = r.right - r.left;
- if (start < stop) {
- SetPosInternal(start + ((stop - start) * (point.x - r.left) + (w/2)) / w);
- }
- }
-
- CSliderCtrl::OnLButtonDown(nFlags, point);
+ CRect r;
+ GetChannelRect(&r);
+
+ if (r.left >= r.right) {
+ return;
+ }
+
+ int start, stop;
+ GetRange(start, stop);
+
+ r.left += 3;
+ r.right -= 4;
+
+ if (point.x < r.left) {
+ SetPos(start);
+ } else if (point.x >= r.right) {
+ SetPos(stop);
+ } else {
+ int w = r.right - r.left;
+ if (start < stop) {
+ SetPosInternal(start + ((stop - start) * (point.x - r.left) + (w / 2)) / w);
+ }
+ }
+
+ CSliderCtrl::OnLButtonDown(nFlags, point);
}
void CVolumeCtrl::OnSetFocus(CWnd* pOldWnd)
{
- CSliderCtrl::OnSetFocus(pOldWnd);
+ CSliderCtrl::OnSetFocus(pOldWnd);
- AfxGetMainWnd()->SetFocus(); // don't focus on us, parents will take care of our positioning
+ AfxGetMainWnd()->SetFocus(); // don't focus on us, parents will take care of our positioning
}
void CVolumeCtrl::HScroll(UINT nSBCode, UINT nPos)
{
- AfxGetAppSettings().nVolume = GetPos();
+ AfxGetAppSettings().nVolume = GetPos();
- CFrameWnd* pFrame = GetParentFrame();
- if (pFrame && pFrame != GetParent()) {
- pFrame->PostMessage(WM_HSCROLL, MAKEWPARAM((short)nPos, nSBCode), (LPARAM)m_hWnd);
- }
+ CFrameWnd* pFrame = GetParentFrame();
+ if (pFrame && pFrame != GetParent()) {
+ pFrame->PostMessage(WM_HSCROLL, MAKEWPARAM((short)nPos, nSBCode), (LPARAM)m_hWnd);
+ }
}
BOOL CVolumeCtrl::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
- ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_HAND));
- return TRUE;
+ ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_HAND));
+ return TRUE;
}
BOOL CVolumeCtrl::OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
{
- TOOLTIPTEXT *pTTT = reinterpret_cast<LPTOOLTIPTEXT>(pNMHDR);
- CString str;
- str.Format(_T("%d%%"), GetPos());
- _tcscpy_s(pTTT->szText, str);
- pTTT->hinst = NULL;
+ TOOLTIPTEXT* pTTT = reinterpret_cast<LPTOOLTIPTEXT>(pNMHDR);
+ CString str;
+ str.Format(_T("%d%%"), GetPos());
+ _tcscpy_s(pTTT->szText, str);
+ pTTT->hinst = NULL;
- *pResult = 0;
+ *pResult = 0;
- return TRUE;
+ return TRUE;
}
diff --git a/src/mpc-hc/VolumeCtrl.h b/src/mpc-hc/VolumeCtrl.h
index 6553b1425..802fb0a90 100644
--- a/src/mpc-hc/VolumeCtrl.h
+++ b/src/mpc-hc/VolumeCtrl.h
@@ -28,30 +28,30 @@
class CVolumeCtrl : public CSliderCtrl
{
- DECLARE_DYNAMIC(CVolumeCtrl)
+ DECLARE_DYNAMIC(CVolumeCtrl)
private:
- bool m_fSelfDrawn;
+ bool m_fSelfDrawn;
public:
- CVolumeCtrl(bool fSelfDrawn = true);
- virtual ~CVolumeCtrl();
+ CVolumeCtrl(bool fSelfDrawn = true);
+ virtual ~CVolumeCtrl();
- bool Create(CWnd* pParentWnd);
+ bool Create(CWnd* pParentWnd);
- void IncreaseVolume(), DecreaseVolume();
+ void IncreaseVolume(), DecreaseVolume();
- void SetPosInternal(int pos);
+ void SetPosInternal(int pos);
protected:
- afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
+ afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg BOOL OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnSetFocus(CWnd* pOldWnd);
- afx_msg void HScroll(UINT nSBCode, UINT nPos);
+ afx_msg BOOL OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnNMCustomdraw(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
+ afx_msg void OnSetFocus(CWnd* pOldWnd);
+ afx_msg void HScroll(UINT nSBCode, UINT nPos);
};
diff --git a/src/mpc-hc/WebClientSocket.cpp b/src/mpc-hc/WebClientSocket.cpp
index f13c6f78f..b26378062 100644
--- a/src/mpc-hc/WebClientSocket.cpp
+++ b/src/mpc-hc/WebClientSocket.cpp
@@ -31,8 +31,8 @@
#include "WebClientSocket.h"
CWebClientSocket::CWebClientSocket(CWebServer* pWebServer, CMainFrame* pMainFrame)
- : m_pWebServer(pWebServer)
- , m_pMainFrame(pMainFrame)
+ : m_pWebServer(pWebServer)
+ , m_pMainFrame(pMainFrame)
{
}
@@ -42,869 +42,869 @@ CWebClientSocket::~CWebClientSocket()
bool CWebClientSocket::SetCookie(CString name, CString value, __time64_t expire, CString path, CString domain)
{
- if (name.IsEmpty()) {
- return false;
- }
- if (value.IsEmpty()) {
- m_cookie.RemoveKey(name);
- return true;
- }
-
- m_cookie[name] = value;
-
- m_cookieattribs[name].path = path;
- m_cookieattribs[name].domain = domain;
-
- if (expire >= 0) {
- CTime t(expire);
- SYSTEMTIME st;
- t.GetAsSystemTime(st);
- CStringA str;
- SystemTimeToHttpDate(st, str);
- m_cookieattribs[name].expire = str;
- }
-
- return true;
+ if (name.IsEmpty()) {
+ return false;
+ }
+ if (value.IsEmpty()) {
+ m_cookie.RemoveKey(name);
+ return true;
+ }
+
+ m_cookie[name] = value;
+
+ m_cookieattribs[name].path = path;
+ m_cookieattribs[name].domain = domain;
+
+ if (expire >= 0) {
+ CTime t(expire);
+ SYSTEMTIME st;
+ t.GetAsSystemTime(st);
+ CStringA str;
+ SystemTimeToHttpDate(st, str);
+ m_cookieattribs[name].expire = str;
+ }
+
+ return true;
}
void CWebClientSocket::Clear()
{
- m_hdr.Empty();
- m_hdrlines.RemoveAll();
- m_data.Empty();
-
- m_cmd.Empty();
- m_path.Empty();
- m_ver.Empty();
- m_get.RemoveAll();
- m_post.RemoveAll();
- m_cookie.RemoveAll();
- m_request.RemoveAll();
+ m_hdr.Empty();
+ m_hdrlines.RemoveAll();
+ m_data.Empty();
+
+ m_cmd.Empty();
+ m_path.Empty();
+ m_ver.Empty();
+ m_get.RemoveAll();
+ m_post.RemoveAll();
+ m_cookie.RemoveAll();
+ m_request.RemoveAll();
}
void CWebClientSocket::Header()
{
- if (m_cmd.IsEmpty()) {
- if (m_hdr.IsEmpty()) {
- return;
- }
-
- CAtlList<CString> lines;
- Explode(m_hdr, lines, '\n');
- CString str = lines.RemoveHead();
-
- CAtlList<CString> sl;
- ExplodeMin(str, sl, ' ', 3);
- m_cmd = sl.RemoveHead().MakeUpper();
- CString pathTmp = sl.RemoveHead();
- DWORD strLen = pathTmp.GetLength()+1;
- AtlUnescapeUrl(pathTmp, m_path.GetBuffer(strLen), &strLen, strLen);
- m_path.ReleaseBuffer();
- m_ver = sl.RemoveHead().MakeUpper();
- ASSERT(sl.GetCount() == 0);
-
- POSITION pos = lines.GetHeadPosition();
- while (pos) {
- Explode(lines.GetNext(pos), sl, ':', 2);
- if (sl.GetCount() == 2) {
- m_hdrlines[sl.GetHead().MakeLower()] = sl.GetTail();
- }
- }
- }
-
- // remember new cookies
-
- POSITION pos = m_hdrlines.GetStartPosition();
- while (pos) {
- CString key, value;
- m_hdrlines.GetNextAssoc(pos, key, value);
-
- if (key == _T("cookie")) {
- CAtlList<CString> sl;
- Explode(value, sl, ';');
- POSITION pos2 = sl.GetHeadPosition();
- while (pos2) {
- CAtlList<CString> sl2;
- Explode(sl.GetNext(pos2), sl2, '=', 2);
- m_cookie[sl2.GetHead()] = sl2.GetCount() == 2 ? sl2.GetTail() : _T("");
- }
- }
- }
-
- // start new session
-
- if (!m_cookie.Lookup(_T("MPCSESSIONID"), m_sessid)) {
- srand((unsigned int)time(NULL));
- m_sessid.Format(_T("%08x"), rand()*0x12345678);
- SetCookie(_T("MPCSESSIONID"), m_sessid);
- } else {
- // TODO: load session
- }
-
- CStringA reshdr, resbody;
-
- if (m_cmd == _T("POST")) {
- CString str;
- if (m_hdrlines.Lookup(_T("content-length"), str)) {
- int len = _tcstol(str, NULL, 10);
- str.Empty();
-
- int err = 0;
- char c;
-
- int timeout = 1000;
-
- do {
- for (; len > 0 && (err = Receive(&c, 1)) > 0; len--) {
- m_data += c;
- if (c == '\r') {
- continue;
- }
- str += c;
- if (c == '\n' || len == 1) {
- CAtlList<CString> sl;
- Explode(AToT(UrlDecode(TToA(str))), sl, '&'); // FIXME
- POSITION pos = sl.GetHeadPosition();
- while (pos) {
- CAtlList<CString> sl2;
- Explode(sl.GetNext(pos), sl2, '=', 2);
- m_post[sl2.GetHead().MakeLower()] = sl2.GetCount() == 2 ? sl2.GetTail() : _T("");
- }
- str.Empty();
- }
- }
-
- if (err == SOCKET_ERROR) {
- Sleep(1);
- }
- } while (err == SOCKET_ERROR && GetLastError() == WSAEWOULDBLOCK
- && timeout-- > 0); // FIXME: this is just a dirty fix now
-
- // FIXME: with IE it will only work if I read +2 bytes (?), btw Receive will just return -1
- Receive(&c, 1);
- Receive(&c, 1);
- }
- }
-
- if (m_cmd == _T("GET") || m_cmd == _T("HEAD") || m_cmd == _T("POST")) {
- CAtlList<CString> sl;
-
- Explode(m_path, sl, '?', 2);
- m_path = sl.RemoveHead();
- m_query.Empty();
-
- if (!sl.IsEmpty()) {
- m_query = sl.GetTail();
-
- Explode(Explode(m_query, sl, '#', 2), sl, '&'); // oh yeah
- // Explode(AToT(UrlDecode(TToA(Explode(m_query, sl, '#', 2)))), sl, '&'); // oh yeah
- POSITION pos = sl.GetHeadPosition();
- while (pos) {
- CAtlList<CString> sl2;
- Explode(AToT(UrlDecode(TToA(sl.GetNext(pos)))), sl2, '=', 2);
- // Explode(sl.GetNext(pos), sl2, '=', 2);
- m_get[sl2.GetHead()] = sl2.GetCount() == 2 ? sl2.GetTail() : _T("");
- }
- }
-
- // m_request <-- m_get+m_post+m_cookie
- {
- CString key, value;
- POSITION pos;
- pos = m_get.GetStartPosition();
- while (pos) {
- m_get.GetNextAssoc(pos, key, value);
- m_request[key] = value;
- }
- pos = m_post.GetStartPosition();
- while (pos) {
- m_post.GetNextAssoc(pos, key, value);
- m_request[key] = value;
- }
- pos = m_cookie.GetStartPosition();
- while (pos) {
- m_cookie.GetNextAssoc(pos, key, value);
- m_request[key] = value;
- }
- }
-
- m_pWebServer->OnRequest(this, reshdr, resbody);
- } else {
- reshdr = "HTTP/1.0 400 Bad Request\r\n";
- }
-
- if (!reshdr.IsEmpty()) {
- // cookies
- {
- POSITION pos = m_cookie.GetStartPosition();
- while (pos) {
- CString key, value;
- m_cookie.GetNextAssoc(pos, key, value);
- reshdr += "Set-Cookie: " + key + "=" + value;
- POSITION pos2 = m_cookieattribs.GetStartPosition();
- while (pos2) {
- CString key;
- cookie_attribs value;
- m_cookieattribs.GetNextAssoc(pos2, key, value);
- if (!value.path.IsEmpty()) {
- reshdr += "; path=" + value.path;
- }
- if (!value.expire.IsEmpty()) {
- reshdr += "; expire=" + value.expire;
- }
- if (!value.domain.IsEmpty()) {
- reshdr += "; domain=" + value.domain;
- }
- }
- reshdr += "\r\n";
- }
- }
-
- reshdr +=
- "Server: MPC-HC WebServer\r\n"
- "Connection: close\r\n"
- "\r\n";
-
- Send(reshdr, reshdr.GetLength());
-
- if (m_cmd != _T("HEAD") && reshdr.Find("HTTP/1.0 200 OK") == 0 && !resbody.IsEmpty()) {
- Send(resbody, resbody.GetLength());
- }
-
- CString connection = _T("close");
- m_hdrlines.Lookup(_T("connection"), connection);
-
- Clear();
-
- // TODO
- // if (connection == _T("close"))
- OnClose(0);
- }
+ if (m_cmd.IsEmpty()) {
+ if (m_hdr.IsEmpty()) {
+ return;
+ }
+
+ CAtlList<CString> lines;
+ Explode(m_hdr, lines, '\n');
+ CString str = lines.RemoveHead();
+
+ CAtlList<CString> sl;
+ ExplodeMin(str, sl, ' ', 3);
+ m_cmd = sl.RemoveHead().MakeUpper();
+ CString pathTmp = sl.RemoveHead();
+ DWORD strLen = pathTmp.GetLength() + 1;
+ AtlUnescapeUrl(pathTmp, m_path.GetBuffer(strLen), &strLen, strLen);
+ m_path.ReleaseBuffer();
+ m_ver = sl.RemoveHead().MakeUpper();
+ ASSERT(sl.GetCount() == 0);
+
+ POSITION pos = lines.GetHeadPosition();
+ while (pos) {
+ Explode(lines.GetNext(pos), sl, ':', 2);
+ if (sl.GetCount() == 2) {
+ m_hdrlines[sl.GetHead().MakeLower()] = sl.GetTail();
+ }
+ }
+ }
+
+ // remember new cookies
+
+ POSITION pos = m_hdrlines.GetStartPosition();
+ while (pos) {
+ CString key, value;
+ m_hdrlines.GetNextAssoc(pos, key, value);
+
+ if (key == _T("cookie")) {
+ CAtlList<CString> sl;
+ Explode(value, sl, ';');
+ POSITION pos2 = sl.GetHeadPosition();
+ while (pos2) {
+ CAtlList<CString> sl2;
+ Explode(sl.GetNext(pos2), sl2, '=', 2);
+ m_cookie[sl2.GetHead()] = sl2.GetCount() == 2 ? sl2.GetTail() : _T("");
+ }
+ }
+ }
+
+ // start new session
+
+ if (!m_cookie.Lookup(_T("MPCSESSIONID"), m_sessid)) {
+ srand((unsigned int)time(NULL));
+ m_sessid.Format(_T("%08x"), rand() * 0x12345678);
+ SetCookie(_T("MPCSESSIONID"), m_sessid);
+ } else {
+ // TODO: load session
+ }
+
+ CStringA reshdr, resbody;
+
+ if (m_cmd == _T("POST")) {
+ CString str;
+ if (m_hdrlines.Lookup(_T("content-length"), str)) {
+ int len = _tcstol(str, NULL, 10);
+ str.Empty();
+
+ int err = 0;
+ char c;
+
+ int timeout = 1000;
+
+ do {
+ for (; len > 0 && (err = Receive(&c, 1)) > 0; len--) {
+ m_data += c;
+ if (c == '\r') {
+ continue;
+ }
+ str += c;
+ if (c == '\n' || len == 1) {
+ CAtlList<CString> sl;
+ Explode(AToT(UrlDecode(TToA(str))), sl, '&'); // FIXME
+ POSITION pos = sl.GetHeadPosition();
+ while (pos) {
+ CAtlList<CString> sl2;
+ Explode(sl.GetNext(pos), sl2, '=', 2);
+ m_post[sl2.GetHead().MakeLower()] = sl2.GetCount() == 2 ? sl2.GetTail() : _T("");
+ }
+ str.Empty();
+ }
+ }
+
+ if (err == SOCKET_ERROR) {
+ Sleep(1);
+ }
+ } while (err == SOCKET_ERROR && GetLastError() == WSAEWOULDBLOCK
+ && timeout-- > 0); // FIXME: this is just a dirty fix now
+
+ // FIXME: with IE it will only work if I read +2 bytes (?), btw Receive will just return -1
+ Receive(&c, 1);
+ Receive(&c, 1);
+ }
+ }
+
+ if (m_cmd == _T("GET") || m_cmd == _T("HEAD") || m_cmd == _T("POST")) {
+ CAtlList<CString> sl;
+
+ Explode(m_path, sl, '?', 2);
+ m_path = sl.RemoveHead();
+ m_query.Empty();
+
+ if (!sl.IsEmpty()) {
+ m_query = sl.GetTail();
+
+ Explode(Explode(m_query, sl, '#', 2), sl, '&'); // oh yeah
+ // Explode(AToT(UrlDecode(TToA(Explode(m_query, sl, '#', 2)))), sl, '&'); // oh yeah
+ POSITION pos = sl.GetHeadPosition();
+ while (pos) {
+ CAtlList<CString> sl2;
+ Explode(AToT(UrlDecode(TToA(sl.GetNext(pos)))), sl2, '=', 2);
+ // Explode(sl.GetNext(pos), sl2, '=', 2);
+ m_get[sl2.GetHead()] = sl2.GetCount() == 2 ? sl2.GetTail() : _T("");
+ }
+ }
+
+ // m_request <-- m_get+m_post+m_cookie
+ {
+ CString key, value;
+ POSITION pos;
+ pos = m_get.GetStartPosition();
+ while (pos) {
+ m_get.GetNextAssoc(pos, key, value);
+ m_request[key] = value;
+ }
+ pos = m_post.GetStartPosition();
+ while (pos) {
+ m_post.GetNextAssoc(pos, key, value);
+ m_request[key] = value;
+ }
+ pos = m_cookie.GetStartPosition();
+ while (pos) {
+ m_cookie.GetNextAssoc(pos, key, value);
+ m_request[key] = value;
+ }
+ }
+
+ m_pWebServer->OnRequest(this, reshdr, resbody);
+ } else {
+ reshdr = "HTTP/1.0 400 Bad Request\r\n";
+ }
+
+ if (!reshdr.IsEmpty()) {
+ // cookies
+ {
+ POSITION pos = m_cookie.GetStartPosition();
+ while (pos) {
+ CString key, value;
+ m_cookie.GetNextAssoc(pos, key, value);
+ reshdr += "Set-Cookie: " + key + "=" + value;
+ POSITION pos2 = m_cookieattribs.GetStartPosition();
+ while (pos2) {
+ CString key;
+ cookie_attribs value;
+ m_cookieattribs.GetNextAssoc(pos2, key, value);
+ if (!value.path.IsEmpty()) {
+ reshdr += "; path=" + value.path;
+ }
+ if (!value.expire.IsEmpty()) {
+ reshdr += "; expire=" + value.expire;
+ }
+ if (!value.domain.IsEmpty()) {
+ reshdr += "; domain=" + value.domain;
+ }
+ }
+ reshdr += "\r\n";
+ }
+ }
+
+ reshdr +=
+ "Server: MPC-HC WebServer\r\n"
+ "Connection: close\r\n"
+ "\r\n";
+
+ Send(reshdr, reshdr.GetLength());
+
+ if (m_cmd != _T("HEAD") && reshdr.Find("HTTP/1.0 200 OK") == 0 && !resbody.IsEmpty()) {
+ Send(resbody, resbody.GetLength());
+ }
+
+ CString connection = _T("close");
+ m_hdrlines.Lookup(_T("connection"), connection);
+
+ Clear();
+
+ // TODO
+ // if (connection == _T("close"))
+ OnClose(0);
+ }
}
//
void CWebClientSocket::OnReceive(int nErrorCode)
{
- if (nErrorCode == 0) {
- char c;
- while (Receive(&c, 1) > 0) {
- if (c == '\r') {
- continue;
- } else {
- m_hdr += c;
- }
-
- int len = m_hdr.GetLength();
- if (len >= 2 && m_hdr[len-2] == '\n' && m_hdr[len-1] == '\n') {
- Header();
- return;
- }
- }
- }
-
- __super::OnReceive(nErrorCode);
+ if (nErrorCode == 0) {
+ char c;
+ while (Receive(&c, 1) > 0) {
+ if (c == '\r') {
+ continue;
+ } else {
+ m_hdr += c;
+ }
+
+ int len = m_hdr.GetLength();
+ if (len >= 2 && m_hdr[len - 2] == '\n' && m_hdr[len - 1] == '\n') {
+ Header();
+ return;
+ }
+ }
+ }
+
+ __super::OnReceive(nErrorCode);
}
void CWebClientSocket::OnClose(int nErrorCode)
{
- // TODO: save session
- m_pWebServer->OnClose(this);
- __super::OnClose(nErrorCode);
+ // TODO: save session
+ m_pWebServer->OnClose(this);
+ __super::OnClose(nErrorCode);
}
////////////////////
bool CWebClientSocket::OnCommand(CStringA& hdr, CStringA& body, CStringA& mime)
{
- CString arg;
- if (m_request.Lookup(_T("wm_command"), arg)) {
- int id = _ttol(arg);
-
- if (id > 0) {
- if (id == ID_FILE_EXIT) {
- m_pMainFrame->PostMessage(WM_COMMAND, id);
- } else {
- m_pMainFrame->SendMessage(WM_COMMAND, id);
- }
- } else {
- if (arg == CMD_SETPOS && m_request.Lookup(_T("position"), arg)) {
- int h, m, s, ms = 0;
- TCHAR c;
- if (_stscanf_s(arg, _T("%d%c%d%c%d%c%d"), &h, &c, sizeof(TCHAR),
- &m, &c, sizeof(TCHAR), &s, &c, sizeof(TCHAR), &ms) >= 5) {
- REFERENCE_TIME rtPos = 10000i64*(((h*60+m)*60+s)*1000+ms);
- m_pMainFrame->SeekTo(rtPos);
- for (int retries = 20; retries-- > 0; Sleep(50)) {
- if (abs((int)((rtPos - m_pMainFrame->GetPos())/10000)) < 100) {
- break;
- }
- }
- }
- } else if (arg == CMD_SETPOS && m_request.Lookup(_T("percent"), arg)) {
- float percent = 0;
- if (_stscanf_s(arg, _T("%f"), &percent) == 1) {
- m_pMainFrame->SeekTo((REFERENCE_TIME)(percent / 100 * m_pMainFrame->GetDur()));
- }
- } else if (arg == CMD_SETVOLUME && m_request.Lookup(_T("volume"), arg)) {
- int volume = _tcstol(arg, NULL, 10);
- m_pMainFrame->m_wndToolBar.Volume = min(max(volume, 0), 100);
- m_pMainFrame->OnPlayVolume(0);
- }
- }
- }
-
- CString ref;
- if (!m_hdrlines.Lookup(_T("referer"), ref)) {
- return true;
- }
-
- hdr =
- "HTTP/1.0 302 Found\r\n"
- "Location: " + CStringA(ref) + "\r\n";
-
- return true;
+ CString arg;
+ if (m_request.Lookup(_T("wm_command"), arg)) {
+ int id = _ttol(arg);
+
+ if (id > 0) {
+ if (id == ID_FILE_EXIT) {
+ m_pMainFrame->PostMessage(WM_COMMAND, id);
+ } else {
+ m_pMainFrame->SendMessage(WM_COMMAND, id);
+ }
+ } else {
+ if (arg == CMD_SETPOS && m_request.Lookup(_T("position"), arg)) {
+ int h, m, s, ms = 0;
+ TCHAR c;
+ if (_stscanf_s(arg, _T("%d%c%d%c%d%c%d"), &h, &c, sizeof(TCHAR),
+ &m, &c, sizeof(TCHAR), &s, &c, sizeof(TCHAR), &ms) >= 5) {
+ REFERENCE_TIME rtPos = 10000i64 * (((h * 60 + m) * 60 + s) * 1000 + ms);
+ m_pMainFrame->SeekTo(rtPos);
+ for (int retries = 20; retries-- > 0; Sleep(50)) {
+ if (abs((int)((rtPos - m_pMainFrame->GetPos()) / 10000)) < 100) {
+ break;
+ }
+ }
+ }
+ } else if (arg == CMD_SETPOS && m_request.Lookup(_T("percent"), arg)) {
+ float percent = 0;
+ if (_stscanf_s(arg, _T("%f"), &percent) == 1) {
+ m_pMainFrame->SeekTo((REFERENCE_TIME)(percent / 100 * m_pMainFrame->GetDur()));
+ }
+ } else if (arg == CMD_SETVOLUME && m_request.Lookup(_T("volume"), arg)) {
+ int volume = _tcstol(arg, NULL, 10);
+ m_pMainFrame->m_wndToolBar.Volume = min(max(volume, 0), 100);
+ m_pMainFrame->OnPlayVolume(0);
+ }
+ }
+ }
+
+ CString ref;
+ if (!m_hdrlines.Lookup(_T("referer"), ref)) {
+ return true;
+ }
+
+ hdr =
+ "HTTP/1.0 302 Found\r\n"
+ "Location: " + CStringA(ref) + "\r\n";
+
+ return true;
}
bool CWebClientSocket::OnIndex(CStringA& hdr, CStringA& body, CStringA& mime)
{
- CStringA wmcoptions;
+ CStringA wmcoptions;
- // generate page
+ // generate page
- AppSettings& s = AfxGetAppSettings();
- POSITION pos = s.wmcmds.GetHeadPosition();
- while (pos) {
- wmcmd& wc = s.wmcmds.GetNext(pos);
- CStringA str;
- str.Format("%d", wc.cmd);
- CStringA valueName(wc.GetName());
- valueName.Replace("&", "&amp;");
- wmcoptions += "<option value=\"" + str + "\">" + valueName + "</option>\r\n";
- }
+ AppSettings& s = AfxGetAppSettings();
+ POSITION pos = s.wmcmds.GetHeadPosition();
+ while (pos) {
+ wmcmd& wc = s.wmcmds.GetNext(pos);
+ CStringA str;
+ str.Format("%d", wc.cmd);
+ CStringA valueName(wc.GetName());
+ valueName.Replace("&", "&amp;");
+ wmcoptions += "<option value=\"" + str + "\">" + valueName + "</option>\r\n";
+ }
- m_pWebServer->LoadPage(IDR_HTML_INDEX, body, m_path);
- body.Replace("[wmcoptions]", wmcoptions);
+ m_pWebServer->LoadPage(IDR_HTML_INDEX, body, m_path);
+ body.Replace("[wmcoptions]", wmcoptions);
- return true;
+ return true;
}
bool CWebClientSocket::OnInfo(CStringA& hdr, CStringA& body, CStringA& mime)
{
- int pos = (int)(m_pMainFrame->GetPos()/10000);
- int dur = (int)(m_pMainFrame->GetDur()/10000);
-
- CString positionstring, durationstring, versionstring, sizestring;
- versionstring.Format(L"%s", AfxGetMyApp()->m_strVersion);
- CPath file(m_pMainFrame->m_wndPlaylistBar.GetCurFileName());
- file.StripPath();
- file.RemoveExtension();
-
- positionstring.Format(_T("%02d:%02d:%02d"), (pos/3600000), (pos/60000)%60, (pos/1000)%60);
- durationstring.Format(_T("%02d:%02d:%02d"), (dur/3600000), (dur/60000)%60, (dur/1000)%60);
-
- WIN32_FIND_DATA wfd;
- HANDLE hFind = FindFirstFile(m_pMainFrame->m_wndPlaylistBar.GetCurFileName(), &wfd);
- if (hFind != INVALID_HANDLE_VALUE) {
- FindClose(hFind);
- __int64 size = (__int64(wfd.nFileSizeHigh)<<32)|wfd.nFileSizeLow;
- const int MAX_FILE_SIZE_BUFFER = 65;
- TCHAR szFileSize[MAX_FILE_SIZE_BUFFER];
- StrFormatByteSizeW(size, szFileSize, MAX_FILE_SIZE_BUFFER);
- sizestring.Format(L"%s", szFileSize);
- }
-
- m_pWebServer->LoadPage(IDR_HTML_INFO, body, m_path);
- body.Replace("[version]", UTF8(versionstring));
- body.Replace("[file]", UTF8(file));
- body.Replace("[position]", UTF8(positionstring));
- body.Replace("[duration]", UTF8(durationstring));
- body.Replace("[size]", UTF8(sizestring));
- return true;
+ int pos = (int)(m_pMainFrame->GetPos() / 10000);
+ int dur = (int)(m_pMainFrame->GetDur() / 10000);
+
+ CString positionstring, durationstring, versionstring, sizestring;
+ versionstring.Format(L"%s", AfxGetMyApp()->m_strVersion);
+ CPath file(m_pMainFrame->m_wndPlaylistBar.GetCurFileName());
+ file.StripPath();
+ file.RemoveExtension();
+
+ positionstring.Format(_T("%02d:%02d:%02d"), (pos / 3600000), (pos / 60000) % 60, (pos / 1000) % 60);
+ durationstring.Format(_T("%02d:%02d:%02d"), (dur / 3600000), (dur / 60000) % 60, (dur / 1000) % 60);
+
+ WIN32_FIND_DATA wfd;
+ HANDLE hFind = FindFirstFile(m_pMainFrame->m_wndPlaylistBar.GetCurFileName(), &wfd);
+ if (hFind != INVALID_HANDLE_VALUE) {
+ FindClose(hFind);
+ __int64 size = (__int64(wfd.nFileSizeHigh) << 32) | wfd.nFileSizeLow;
+ const int MAX_FILE_SIZE_BUFFER = 65;
+ TCHAR szFileSize[MAX_FILE_SIZE_BUFFER];
+ StrFormatByteSizeW(size, szFileSize, MAX_FILE_SIZE_BUFFER);
+ sizestring.Format(L"%s", szFileSize);
+ }
+
+ m_pWebServer->LoadPage(IDR_HTML_INFO, body, m_path);
+ body.Replace("[version]", UTF8(versionstring));
+ body.Replace("[file]", UTF8(file));
+ body.Replace("[position]", UTF8(positionstring));
+ body.Replace("[duration]", UTF8(durationstring));
+ body.Replace("[size]", UTF8(sizestring));
+ return true;
}
bool CWebClientSocket::OnBrowser(CStringA& hdr, CStringA& body, CStringA& mime)
{
- CAtlList<CStringA> rootdrives;
- for (TCHAR drive[] = _T("A:"); drive[0] <= 'Z'; drive[0]++)
- if (GetDriveType(drive) != DRIVE_NO_ROOT_DIR) {
- rootdrives.AddTail(CStringA(drive) + '\\');
- }
-
- // process GET
-
- CString path;
- CFileStatus fs;
- if (m_get.Lookup(_T("path"), path)) {
- path = WToT(UTF8To16(TToA(path)));
-
- if (CFileGetStatus(path, fs) && !(fs.m_attribute&CFile::directory)) {
- // TODO: make a new message for just opening files, this is a bit overkill now...
-
- CAtlList<CString> cmdln;
-
- cmdln.AddTail(path);
-
- CString focus;
- if (m_get.Lookup(_T("focus"), focus) && !focus.CompareNoCase(_T("no"))) {
- cmdln.AddTail(_T("/nofocus"));
- }
-
- int len = 0;
-
- POSITION pos = cmdln.GetHeadPosition();
- while (pos) {
- CString& str = cmdln.GetNext(pos);
- len += (str.GetLength()+1)*sizeof(TCHAR);
- }
-
- CAutoVectorPtr<BYTE> buff;
- if (buff.Allocate(4+len)) {
- BYTE* p = buff;
- *(DWORD*)p = (DWORD)cmdln.GetCount();
- p += sizeof(DWORD);
-
- POSITION pos = cmdln.GetHeadPosition();
- while (pos) {
- CString& str = cmdln.GetNext(pos);
- len = (str.GetLength()+1)*sizeof(TCHAR);
- memcpy(p, (LPCTSTR)str, len);
- p += len;
- }
-
- COPYDATASTRUCT cds;
- cds.dwData = 0x6ABE51;
- cds.cbData = DWORD(p - buff);
- cds.lpData = (void*)(BYTE*)buff;
- m_pMainFrame->SendMessage(WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
- }
-
- CPath p(path);
- p.RemoveFileSpec();
- path = (LPCTSTR)p;
- }
- } else {
- path = m_pMainFrame->m_wndPlaylistBar.GetCurFileName();
-
- if (CFileGetStatus(path, fs) && !(fs.m_attribute&CFile::directory)) {
- CPath p(path);
- p.RemoveFileSpec();
- path = (LPCTSTR)p;
- }
- }
-
- if (path.Find(_T("://")) >= 0) {
- path.Empty();
- }
-
- if (CFileGetStatus(path, fs) && (fs.m_attribute&CFile::directory)
- || path.Find(_T("\\")) == 0) { // FIXME
- CPath p(path);
- p.Canonicalize();
- p.MakePretty();
- p.AddBackslash();
- path = (LPCTSTR)p;
- }
-
- CStringA files;
-
- if (path.IsEmpty()) {
- POSITION pos = rootdrives.GetHeadPosition();
- while (pos) {
- CStringA& drive = rootdrives.GetNext(pos);
-
- files += "<tr class=\"dir\">\r\n";
- files +=
- "<td class=\"dirname\"><a href=\"[path]?path=" + UrlEncode(drive) + "\">" + drive + "</a></td>"
- "<td class=\"dirtype\">Directory</td>"
- "<td class=\"dirsize\">&nbsp</td>\r\n"
- "<td class=\"dirdate\">&nbsp</td>";
- files += "</tr>\r\n";
- }
-
- path = "Root";
- } else {
- CString parent;
-
- if (path.GetLength() > 3) {
- CPath p(path + "..");
- p.Canonicalize();
- p.AddBackslash();
- parent = (LPCTSTR)p;
- }
-
- files += "<tr class=\"dir\">\r\n";
- files +=
- "<td class=\"dirname\"><a href=\"[path]?path=" + parent + "\">..</a></td>"
- "<td class=\"dirtype\">Directory</td>"
- "<td class=\"dirsize\">&nbsp</td>\r\n"
- "<td class=\"dirdate\">&nbsp</td>";
- files += "</tr>\r\n";
-
- WIN32_FIND_DATA fd = {0};
-
- HANDLE hFind = FindFirstFile(path + "*.*", &fd);
- if (hFind != INVALID_HANDLE_VALUE) {
- do {
- if (!(fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) || fd.cFileName[0] == '.') {
- continue;
- }
-
- CString fullpath = path + fd.cFileName;
-
- files += "<tr class=\"dir\">\r\n";
- files +=
- "<td class=\"dirname\"><a href=\"[path]?path=" + UTF8Arg(fullpath) + "\">" + UTF8(fd.cFileName) + "</a></td>"
- "<td class=\"dirtype\">Directory</td>"
- "<td class=\"dirsize\">&nbsp</td>\r\n"
- "<td class=\"dirdate\"><span class=\"nobr\">" + CStringA(CTime(fd.ftLastWriteTime).Format(_T("%Y.%m.%d %H:%M"))) + "</span></td>";
- files += "</tr>\r\n";
- } while (FindNextFile(hFind, &fd));
-
- FindClose(hFind);
- }
-
- hFind = FindFirstFile(path + "*.*", &fd);
- if (hFind != INVALID_HANDLE_VALUE) {
- do {
- if (fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) {
- continue;
- }
-
- CString fullpath = path + fd.cFileName;
- TCHAR *ext = _tcsrchr(fd.cFileName, '.');
- if (ext != NULL) {
- ext++;
- }
-
- CStringA size;
- size.Format("%I64dK", ((UINT64)fd.nFileSizeHigh<<22)|(fd.nFileSizeLow>>10));
-
- CString type(_T("&nbsp"));
- LoadType(fullpath, type);
-
- if (ext != NULL) {
- files += "<tr class=\"" + UTF8(ext) + "\">\r\n";
- } else {
- files += "<tr class=\"noext\">\r\n";
- }
- files +=
- "<td class=\"filename\"><a href=\"[path]?path=" + UTF8Arg(fullpath) + "\">" + UTF8(fd.cFileName) + "</a></td>"
- "<td class=\"filetype\"><span class=\"nobr\">" + UTF8(type) + "</span></td>"
- "<td class=\"filesize\" align=\"right\"><span class=\"nobr\">" + size + "</span></td>\r\n"
- "<td class=\"filedate\"><span class=\"nobr\">" + CStringA(CTime(fd.ftLastWriteTime).Format(_T("%Y.%m.%d %H:%M"))) + "</span></td>";
- files += "</tr>\r\n";
- } while (FindNextFile(hFind, &fd));
-
- FindClose(hFind);
- }
- }
-
- m_pWebServer->LoadPage(IDR_HTML_BROWSER, body, m_path);
- body.Replace("[currentdir]", UTF8(path));
- body.Replace("[currentfiles]", files);
-
- return true;
+ CAtlList<CStringA> rootdrives;
+ for (TCHAR drive[] = _T("A:"); drive[0] <= 'Z'; drive[0]++)
+ if (GetDriveType(drive) != DRIVE_NO_ROOT_DIR) {
+ rootdrives.AddTail(CStringA(drive) + '\\');
+ }
+
+ // process GET
+
+ CString path;
+ CFileStatus fs;
+ if (m_get.Lookup(_T("path"), path)) {
+ path = WToT(UTF8To16(TToA(path)));
+
+ if (CFileGetStatus(path, fs) && !(fs.m_attribute & CFile::directory)) {
+ // TODO: make a new message for just opening files, this is a bit overkill now...
+
+ CAtlList<CString> cmdln;
+
+ cmdln.AddTail(path);
+
+ CString focus;
+ if (m_get.Lookup(_T("focus"), focus) && !focus.CompareNoCase(_T("no"))) {
+ cmdln.AddTail(_T("/nofocus"));
+ }
+
+ int len = 0;
+
+ POSITION pos = cmdln.GetHeadPosition();
+ while (pos) {
+ CString& str = cmdln.GetNext(pos);
+ len += (str.GetLength() + 1) * sizeof(TCHAR);
+ }
+
+ CAutoVectorPtr<BYTE> buff;
+ if (buff.Allocate(4 + len)) {
+ BYTE* p = buff;
+ *(DWORD*)p = (DWORD)cmdln.GetCount();
+ p += sizeof(DWORD);
+
+ POSITION pos = cmdln.GetHeadPosition();
+ while (pos) {
+ CString& str = cmdln.GetNext(pos);
+ len = (str.GetLength() + 1) * sizeof(TCHAR);
+ memcpy(p, (LPCTSTR)str, len);
+ p += len;
+ }
+
+ COPYDATASTRUCT cds;
+ cds.dwData = 0x6ABE51;
+ cds.cbData = DWORD(p - buff);
+ cds.lpData = (void*)(BYTE*)buff;
+ m_pMainFrame->SendMessage(WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
+ }
+
+ CPath p(path);
+ p.RemoveFileSpec();
+ path = (LPCTSTR)p;
+ }
+ } else {
+ path = m_pMainFrame->m_wndPlaylistBar.GetCurFileName();
+
+ if (CFileGetStatus(path, fs) && !(fs.m_attribute & CFile::directory)) {
+ CPath p(path);
+ p.RemoveFileSpec();
+ path = (LPCTSTR)p;
+ }
+ }
+
+ if (path.Find(_T("://")) >= 0) {
+ path.Empty();
+ }
+
+ if (CFileGetStatus(path, fs) && (fs.m_attribute & CFile::directory)
+ || path.Find(_T("\\")) == 0) { // FIXME
+ CPath p(path);
+ p.Canonicalize();
+ p.MakePretty();
+ p.AddBackslash();
+ path = (LPCTSTR)p;
+ }
+
+ CStringA files;
+
+ if (path.IsEmpty()) {
+ POSITION pos = rootdrives.GetHeadPosition();
+ while (pos) {
+ CStringA& drive = rootdrives.GetNext(pos);
+
+ files += "<tr class=\"dir\">\r\n";
+ files +=
+ "<td class=\"dirname\"><a href=\"[path]?path=" + UrlEncode(drive) + "\">" + drive + "</a></td>"
+ "<td class=\"dirtype\">Directory</td>"
+ "<td class=\"dirsize\">&nbsp</td>\r\n"
+ "<td class=\"dirdate\">&nbsp</td>";
+ files += "</tr>\r\n";
+ }
+
+ path = "Root";
+ } else {
+ CString parent;
+
+ if (path.GetLength() > 3) {
+ CPath p(path + "..");
+ p.Canonicalize();
+ p.AddBackslash();
+ parent = (LPCTSTR)p;
+ }
+
+ files += "<tr class=\"dir\">\r\n";
+ files +=
+ "<td class=\"dirname\"><a href=\"[path]?path=" + parent + "\">..</a></td>"
+ "<td class=\"dirtype\">Directory</td>"
+ "<td class=\"dirsize\">&nbsp</td>\r\n"
+ "<td class=\"dirdate\">&nbsp</td>";
+ files += "</tr>\r\n";
+
+ WIN32_FIND_DATA fd = {0};
+
+ HANDLE hFind = FindFirstFile(path + "*.*", &fd);
+ if (hFind != INVALID_HANDLE_VALUE) {
+ do {
+ if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) || fd.cFileName[0] == '.') {
+ continue;
+ }
+
+ CString fullpath = path + fd.cFileName;
+
+ files += "<tr class=\"dir\">\r\n";
+ files +=
+ "<td class=\"dirname\"><a href=\"[path]?path=" + UTF8Arg(fullpath) + "\">" + UTF8(fd.cFileName) + "</a></td>"
+ "<td class=\"dirtype\">Directory</td>"
+ "<td class=\"dirsize\">&nbsp</td>\r\n"
+ "<td class=\"dirdate\"><span class=\"nobr\">" + CStringA(CTime(fd.ftLastWriteTime).Format(_T("%Y.%m.%d %H:%M"))) + "</span></td>";
+ files += "</tr>\r\n";
+ } while (FindNextFile(hFind, &fd));
+
+ FindClose(hFind);
+ }
+
+ hFind = FindFirstFile(path + "*.*", &fd);
+ if (hFind != INVALID_HANDLE_VALUE) {
+ do {
+ if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+ continue;
+ }
+
+ CString fullpath = path + fd.cFileName;
+ TCHAR* ext = _tcsrchr(fd.cFileName, '.');
+ if (ext != NULL) {
+ ext++;
+ }
+
+ CStringA size;
+ size.Format("%I64dK", ((UINT64)fd.nFileSizeHigh << 22) | (fd.nFileSizeLow >> 10));
+
+ CString type(_T("&nbsp"));
+ LoadType(fullpath, type);
+
+ if (ext != NULL) {
+ files += "<tr class=\"" + UTF8(ext) + "\">\r\n";
+ } else {
+ files += "<tr class=\"noext\">\r\n";
+ }
+ files +=
+ "<td class=\"filename\"><a href=\"[path]?path=" + UTF8Arg(fullpath) + "\">" + UTF8(fd.cFileName) + "</a></td>"
+ "<td class=\"filetype\"><span class=\"nobr\">" + UTF8(type) + "</span></td>"
+ "<td class=\"filesize\" align=\"right\"><span class=\"nobr\">" + size + "</span></td>\r\n"
+ "<td class=\"filedate\"><span class=\"nobr\">" + CStringA(CTime(fd.ftLastWriteTime).Format(_T("%Y.%m.%d %H:%M"))) + "</span></td>";
+ files += "</tr>\r\n";
+ } while (FindNextFile(hFind, &fd));
+
+ FindClose(hFind);
+ }
+ }
+
+ m_pWebServer->LoadPage(IDR_HTML_BROWSER, body, m_path);
+ body.Replace("[currentdir]", UTF8(path));
+ body.Replace("[currentfiles]", files);
+
+ return true;
}
bool CWebClientSocket::OnControls(CStringA& hdr, CStringA& body, CStringA& mime)
{
- CString path = m_pMainFrame->m_wndPlaylistBar.GetCurFileName();
- CString dir;
-
- if (!path.IsEmpty()) {
- CPath p(path);
- p.RemoveFileSpec();
- dir = (LPCTSTR)p;
- }
-
- OAFilterState fs = m_pMainFrame->GetMediaState();
- CString state;
- state.Format(_T("%d"), fs);
- CString statestring;
- switch (fs) {
- case State_Stopped:
- statestring.LoadString(IDS_CONTROLS_STOPPED);
- break;
- case State_Paused:
- statestring.LoadString(IDS_CONTROLS_PAUSED);
- break;
- case State_Running:
- statestring.LoadString(IDS_CONTROLS_PLAYING);
- break;
- default:
- statestring = _T("n/a");
- break;
- }
-
- int pos = (int)(m_pMainFrame->GetPos()/10000);
- int dur = (int)(m_pMainFrame->GetDur()/10000);
-
- CString position, duration;
- position.Format(_T("%d"), pos);
- duration.Format(_T("%d"), dur);
-
- CString positionstring, durationstring, playbackrate;
- // positionstring.Format(_T("%02d:%02d:%02d.%03d"), (pos/3600000), (pos/60000)%60, (pos/1000)%60, pos%1000);
- // durationstring.Format(_T("%02d:%02d:%02d.%03d"), (dur/3600000), (dur/60000)%60, (dur/1000)%60, dur%1000);
- positionstring.Format(_T("%02d:%02d:%02d"), (pos/3600000), (pos/60000)%60, (pos/1000)%60);
- durationstring.Format(_T("%02d:%02d:%02d"), (dur/3600000), (dur/60000)%60, (dur/1000)%60);
- playbackrate = _T("1"); // TODO
-
- CString volumelevel, muted;
- volumelevel.Format(_T("%d"), m_pMainFrame->m_wndToolBar.m_volctrl.GetPos());
- muted.Format(_T("%d"), m_pMainFrame->m_wndToolBar.Volume == -10000 ? 1 : 0);
-
- CString reloadtime(_T("0")); // TODO
-
- m_pWebServer->LoadPage(IDR_HTML_CONTROLS, body, m_path);
- body.Replace("[filepatharg]", UTF8Arg(path));
- body.Replace("[filepath]", UTF8(path));
- body.Replace("[filedirarg]", UTF8Arg(dir));
- body.Replace("[filedir]", UTF8(dir));
- body.Replace("[state]", UTF8(state));
- body.Replace("[statestring]", UTF8(statestring));
- body.Replace("[position]", UTF8(position));
- body.Replace("[positionstring]", UTF8(positionstring));
- body.Replace("[duration]", UTF8(duration));
- body.Replace("[durationstring]", UTF8(durationstring));
- body.Replace("[volumelevel]", UTF8(volumelevel));
- body.Replace("[muted]", UTF8(muted));
- body.Replace("[playbackrate]", UTF8(playbackrate));
- body.Replace("[reloadtime]", UTF8(reloadtime));
-
- return true;
+ CString path = m_pMainFrame->m_wndPlaylistBar.GetCurFileName();
+ CString dir;
+
+ if (!path.IsEmpty()) {
+ CPath p(path);
+ p.RemoveFileSpec();
+ dir = (LPCTSTR)p;
+ }
+
+ OAFilterState fs = m_pMainFrame->GetMediaState();
+ CString state;
+ state.Format(_T("%d"), fs);
+ CString statestring;
+ switch (fs) {
+ case State_Stopped:
+ statestring.LoadString(IDS_CONTROLS_STOPPED);
+ break;
+ case State_Paused:
+ statestring.LoadString(IDS_CONTROLS_PAUSED);
+ break;
+ case State_Running:
+ statestring.LoadString(IDS_CONTROLS_PLAYING);
+ break;
+ default:
+ statestring = _T("n/a");
+ break;
+ }
+
+ int pos = (int)(m_pMainFrame->GetPos() / 10000);
+ int dur = (int)(m_pMainFrame->GetDur() / 10000);
+
+ CString position, duration;
+ position.Format(_T("%d"), pos);
+ duration.Format(_T("%d"), dur);
+
+ CString positionstring, durationstring, playbackrate;
+ // positionstring.Format(_T("%02d:%02d:%02d.%03d"), (pos/3600000), (pos/60000)%60, (pos/1000)%60, pos%1000);
+ // durationstring.Format(_T("%02d:%02d:%02d.%03d"), (dur/3600000), (dur/60000)%60, (dur/1000)%60, dur%1000);
+ positionstring.Format(_T("%02d:%02d:%02d"), (pos / 3600000), (pos / 60000) % 60, (pos / 1000) % 60);
+ durationstring.Format(_T("%02d:%02d:%02d"), (dur / 3600000), (dur / 60000) % 60, (dur / 1000) % 60);
+ playbackrate = _T("1"); // TODO
+
+ CString volumelevel, muted;
+ volumelevel.Format(_T("%d"), m_pMainFrame->m_wndToolBar.m_volctrl.GetPos());
+ muted.Format(_T("%d"), m_pMainFrame->m_wndToolBar.Volume == -10000 ? 1 : 0);
+
+ CString reloadtime(_T("0")); // TODO
+
+ m_pWebServer->LoadPage(IDR_HTML_CONTROLS, body, m_path);
+ body.Replace("[filepatharg]", UTF8Arg(path));
+ body.Replace("[filepath]", UTF8(path));
+ body.Replace("[filedirarg]", UTF8Arg(dir));
+ body.Replace("[filedir]", UTF8(dir));
+ body.Replace("[state]", UTF8(state));
+ body.Replace("[statestring]", UTF8(statestring));
+ body.Replace("[position]", UTF8(position));
+ body.Replace("[positionstring]", UTF8(positionstring));
+ body.Replace("[duration]", UTF8(duration));
+ body.Replace("[durationstring]", UTF8(durationstring));
+ body.Replace("[volumelevel]", UTF8(volumelevel));
+ body.Replace("[muted]", UTF8(muted));
+ body.Replace("[playbackrate]", UTF8(playbackrate));
+ body.Replace("[reloadtime]", UTF8(reloadtime));
+
+ return true;
}
bool CWebClientSocket::OnVariables(CStringA& hdr, CStringA& body, CStringA& mime)
{
- CString path = m_pMainFrame->m_wndPlaylistBar.GetCurFileName();
- CString dir;
-
- if (!path.IsEmpty()) {
- CPath p(path);
- p.RemoveFileSpec();
- dir = (LPCTSTR)p;
- }
-
- OAFilterState fs = m_pMainFrame->GetMediaState();
- CString state;
- state.Format(_T("%d"), fs);
- CString statestring;
- switch (fs) {
- case State_Stopped:
- statestring.LoadString(IDS_CONTROLS_STOPPED);
- break;
- case State_Paused:
- statestring.LoadString(IDS_CONTROLS_PAUSED);
- break;
- case State_Running:
- statestring.LoadString(IDS_CONTROLS_PLAYING);
- break;
- default:
- statestring = _T("n/a");
- break;
- }
-
- int pos = (int)(m_pMainFrame->GetPos()/10000);
- int dur = (int)(m_pMainFrame->GetDur()/10000);
-
- CString position, duration;
- position.Format(_T("%d"), pos);
- duration.Format(_T("%d"), dur);
-
- CString positionstring, durationstring, playbackrate;
- // positionstring.Format(_T("%02d:%02d:%02d.%03d"), (pos/3600000), (pos/60000)%60, (pos/1000)%60, pos%1000);
- // durationstring.Format(_T("%02d:%02d:%02d.%03d"), (dur/3600000), (dur/60000)%60, (dur/1000)%60, dur%1000);
- positionstring.Format(_T("%02d:%02d:%02d"), (pos/3600000), (pos/60000)%60, (pos/1000)%60);
- durationstring.Format(_T("%02d:%02d:%02d"), (dur/3600000), (dur/60000)%60, (dur/1000)%60);
- playbackrate = _T("1"); // TODO
-
- CString volumelevel, muted;
- volumelevel.Format(_T("%d"), m_pMainFrame->m_wndToolBar.m_volctrl.GetPos());
- muted.Format(_T("%d"), m_pMainFrame->m_wndToolBar.Volume == -10000 ? 1 : 0);
-
- CString reloadtime(_T("0")); // TODO
-
- m_pWebServer->LoadPage(IDR_HTML_VARIABLES, body, m_path);
- body.Replace("[filepatharg]", UTF8Arg(path));
- body.Replace("[filepath]", UTF8(path));
- body.Replace("[filedirarg]", UTF8Arg(dir));
- body.Replace("[filedir]", UTF8(dir));
- body.Replace("[state]", UTF8(state));
- body.Replace("[statestring]", UTF8(statestring));
- body.Replace("[position]", UTF8(position));
- body.Replace("[positionstring]", UTF8(positionstring));
- body.Replace("[duration]", UTF8(duration));
- body.Replace("[durationstring]", UTF8(durationstring));
- body.Replace("[volumelevel]", UTF8(volumelevel));
- body.Replace("[muted]", UTF8(muted));
- body.Replace("[playbackrate]", UTF8(playbackrate));
- body.Replace("[reloadtime]", UTF8(reloadtime));
-
- return true;
+ CString path = m_pMainFrame->m_wndPlaylistBar.GetCurFileName();
+ CString dir;
+
+ if (!path.IsEmpty()) {
+ CPath p(path);
+ p.RemoveFileSpec();
+ dir = (LPCTSTR)p;
+ }
+
+ OAFilterState fs = m_pMainFrame->GetMediaState();
+ CString state;
+ state.Format(_T("%d"), fs);
+ CString statestring;
+ switch (fs) {
+ case State_Stopped:
+ statestring.LoadString(IDS_CONTROLS_STOPPED);
+ break;
+ case State_Paused:
+ statestring.LoadString(IDS_CONTROLS_PAUSED);
+ break;
+ case State_Running:
+ statestring.LoadString(IDS_CONTROLS_PLAYING);
+ break;
+ default:
+ statestring = _T("n/a");
+ break;
+ }
+
+ int pos = (int)(m_pMainFrame->GetPos() / 10000);
+ int dur = (int)(m_pMainFrame->GetDur() / 10000);
+
+ CString position, duration;
+ position.Format(_T("%d"), pos);
+ duration.Format(_T("%d"), dur);
+
+ CString positionstring, durationstring, playbackrate;
+ // positionstring.Format(_T("%02d:%02d:%02d.%03d"), (pos/3600000), (pos/60000)%60, (pos/1000)%60, pos%1000);
+ // durationstring.Format(_T("%02d:%02d:%02d.%03d"), (dur/3600000), (dur/60000)%60, (dur/1000)%60, dur%1000);
+ positionstring.Format(_T("%02d:%02d:%02d"), (pos / 3600000), (pos / 60000) % 60, (pos / 1000) % 60);
+ durationstring.Format(_T("%02d:%02d:%02d"), (dur / 3600000), (dur / 60000) % 60, (dur / 1000) % 60);
+ playbackrate = _T("1"); // TODO
+
+ CString volumelevel, muted;
+ volumelevel.Format(_T("%d"), m_pMainFrame->m_wndToolBar.m_volctrl.GetPos());
+ muted.Format(_T("%d"), m_pMainFrame->m_wndToolBar.Volume == -10000 ? 1 : 0);
+
+ CString reloadtime(_T("0")); // TODO
+
+ m_pWebServer->LoadPage(IDR_HTML_VARIABLES, body, m_path);
+ body.Replace("[filepatharg]", UTF8Arg(path));
+ body.Replace("[filepath]", UTF8(path));
+ body.Replace("[filedirarg]", UTF8Arg(dir));
+ body.Replace("[filedir]", UTF8(dir));
+ body.Replace("[state]", UTF8(state));
+ body.Replace("[statestring]", UTF8(statestring));
+ body.Replace("[position]", UTF8(position));
+ body.Replace("[positionstring]", UTF8(positionstring));
+ body.Replace("[duration]", UTF8(duration));
+ body.Replace("[durationstring]", UTF8(durationstring));
+ body.Replace("[volumelevel]", UTF8(volumelevel));
+ body.Replace("[muted]", UTF8(muted));
+ body.Replace("[playbackrate]", UTF8(playbackrate));
+ body.Replace("[reloadtime]", UTF8(reloadtime));
+
+ return true;
}
bool CWebClientSocket::OnStatus(CStringA& hdr, CStringA& body, CStringA& mime)
{
- /*
- CString path = m_pMainFrame->m_wndPlaylistBar.GetCur(), dir;
- if (!path.IsEmpty()) {CPath p(path); p.RemoveFileSpec(); dir = (LPCTSTR)p;}
- path.Replace(_T("'"), _T("\\'"));
- dir.Replace(_T("'"), _T("\\'"));
-
- CString volumelevel, muted;
- volumelevel.Format(_T("%d"), m_pMainFrame->m_wndToolBar.m_volctrl.GetPos());
- muted.Format(_T("%d"), m_pMainFrame->m_wndToolBar.Volume == -10000 ? 1 : 0);
- body.Replace("[volumelevel]", UTF8(volumelevel));
- body.Replace("[muted]", UTF8(muted));
- */
- CString title;
- m_pMainFrame->GetWindowText(title);
-
- CPath file(m_pMainFrame->m_wndPlaylistBar.GetCurFileName());
-
- CString status;// = m_pMainFrame->GetStatusMessage();
- OAFilterState fs = m_pMainFrame->GetMediaState();
- switch (fs) {
- case State_Stopped:
- status.LoadString(IDS_CONTROLS_STOPPED);
- break;
- case State_Paused:
- status.LoadString(IDS_CONTROLS_PAUSED);
- break;
- case State_Running:
- status.LoadString(IDS_CONTROLS_PLAYING);
- break;
- default:
- status = _T("n/a");
- break;
- }
-
- int pos = (int)(m_pMainFrame->GetPos()/10000);
- int dur = (int)(m_pMainFrame->GetDur()/10000);
-
- CString posstr, durstr;
- posstr.Format(_T("%02d:%02d:%02d"), (pos/3600000), (pos/60000)%60, (pos/1000)%60);
- durstr.Format(_T("%02d:%02d:%02d"), (dur/3600000), (dur/60000)%60, (dur/1000)%60);
-
- title.Replace(_T("'"), _T("\\'"));
- status.Replace(_T("'"), _T("\\'"));
-
- body.Format("OnStatus('%s', '%s', %d, '%s', %d, '%s', %d, %d, '%s')", // , '%s'
- UTF8(title), UTF8(status),
- pos, UTF8(posstr), dur, UTF8(durstr),
- m_pMainFrame->IsMuted(), m_pMainFrame->GetVolume(),
- UTF8(file)/*, UTF8(dir)*/);
-
- return true;
+ /*
+ CString path = m_pMainFrame->m_wndPlaylistBar.GetCur(), dir;
+ if (!path.IsEmpty()) {CPath p(path); p.RemoveFileSpec(); dir = (LPCTSTR)p;}
+ path.Replace(_T("'"), _T("\\'"));
+ dir.Replace(_T("'"), _T("\\'"));
+
+ CString volumelevel, muted;
+ volumelevel.Format(_T("%d"), m_pMainFrame->m_wndToolBar.m_volctrl.GetPos());
+ muted.Format(_T("%d"), m_pMainFrame->m_wndToolBar.Volume == -10000 ? 1 : 0);
+ body.Replace("[volumelevel]", UTF8(volumelevel));
+ body.Replace("[muted]", UTF8(muted));
+ */
+ CString title;
+ m_pMainFrame->GetWindowText(title);
+
+ CPath file(m_pMainFrame->m_wndPlaylistBar.GetCurFileName());
+
+ CString status;// = m_pMainFrame->GetStatusMessage();
+ OAFilterState fs = m_pMainFrame->GetMediaState();
+ switch (fs) {
+ case State_Stopped:
+ status.LoadString(IDS_CONTROLS_STOPPED);
+ break;
+ case State_Paused:
+ status.LoadString(IDS_CONTROLS_PAUSED);
+ break;
+ case State_Running:
+ status.LoadString(IDS_CONTROLS_PLAYING);
+ break;
+ default:
+ status = _T("n/a");
+ break;
+ }
+
+ int pos = (int)(m_pMainFrame->GetPos() / 10000);
+ int dur = (int)(m_pMainFrame->GetDur() / 10000);
+
+ CString posstr, durstr;
+ posstr.Format(_T("%02d:%02d:%02d"), (pos / 3600000), (pos / 60000) % 60, (pos / 1000) % 60);
+ durstr.Format(_T("%02d:%02d:%02d"), (dur / 3600000), (dur / 60000) % 60, (dur / 1000) % 60);
+
+ title.Replace(_T("'"), _T("\\'"));
+ status.Replace(_T("'"), _T("\\'"));
+
+ body.Format("OnStatus('%s', '%s', %d, '%s', %d, '%s', %d, %d, '%s')", // , '%s'
+ UTF8(title), UTF8(status),
+ pos, UTF8(posstr), dur, UTF8(durstr),
+ m_pMainFrame->IsMuted(), m_pMainFrame->GetVolume(),
+ UTF8(file)/*, UTF8(dir)*/);
+
+ return true;
}
bool CWebClientSocket::OnError404(CStringA& hdr, CStringA& body, CStringA& mime)
{
- m_pWebServer->LoadPage(IDR_HTML_404, body, m_path);
- return true;
+ m_pWebServer->LoadPage(IDR_HTML_404, body, m_path);
+ return true;
}
bool CWebClientSocket::OnPlayer(CStringA& hdr, CStringA& body, CStringA& mime)
{
- m_pWebServer->LoadPage(IDR_HTML_PLAYER, body, m_path);
- return true;
+ m_pWebServer->LoadPage(IDR_HTML_PLAYER, body, m_path);
+ return true;
}
bool CWebClientSocket::OnSnapShotJpeg(CStringA& hdr, CStringA& body, CStringA& mime)
{
- // TODO: add quality control and return logo when nothing is loaded
-
- bool fRet = false;
-
- BYTE* pData = NULL;
- long size = 0;
- if (m_pMainFrame->GetDIB(&pData, size, true)) {
- PBITMAPINFO bi = reinterpret_cast<PBITMAPINFO>(pData);
- PBITMAPINFOHEADER bih = &bi->bmiHeader;
-
- int bpp = bih->biBitCount;
- if (bpp != 16 && bpp != 24 && bpp != 32) { return false; }
- int w = bih->biWidth;
- int h = abs(bih->biHeight);
- BYTE* p = DNew BYTE[w * h * 4];
-
- const BYTE* src = pData + sizeof(*bih);
- if (bpp <= 8) {
- if (bih->biClrUsed) {
- src += bih->biClrUsed * sizeof(bi->bmiColors[0]);
- } else {
- src += (1 << bpp) * DWORD(sizeof(bi->bmiColors[0]));
- }
- }
-
- int srcpitch = w * (bpp >> 3);
- int dstpitch = w * 4;
-
- BitBltFromRGBToRGB(w, h, p, dstpitch, 32, (BYTE*)src + srcpitch * (h - 1), -srcpitch, bpp);
-
- {
- CBitmap bmp;
- bmp.CreateBitmap(w, h, bih->biPlanes, bpp, p);
- delete [] p;
-
- CImage img;
- img.Attach(bmp);
- IStream *pStream = NULL;
- CByteArray ba;
- if (SUCCEEDED(CreateStreamOnHGlobal(NULL, TRUE, &pStream))) {
- if (SUCCEEDED(img.Save(pStream, Gdiplus::ImageFormatJPEG))) {
- ULARGE_INTEGER ulnSize;
- LARGE_INTEGER lnOffset;
- lnOffset.QuadPart = 0;
- if (SUCCEEDED(pStream->Seek(lnOffset, STREAM_SEEK_END, &ulnSize))) {
- if (SUCCEEDED(pStream->Seek(lnOffset, STREAM_SEEK_SET, 0))) {
- ULONG ulBytesRead;
- ba.SetSize((INT_PTR)ulnSize.QuadPart);
- pStream->Read(ba.GetData(), (INT_PTR)ulnSize.QuadPart, &ulBytesRead);
- }
- }
- }
- }
-
- pStream->Release();
- delete [] pData;
-
- hdr +=
- "Expires: Thu, 19 Nov 1981 08:52:00 GMT\r\n"
- "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\r\n"
- "Pragma: no-cache\r\n";
- body = CStringA((char*)ba.GetData(), ba.GetCount());
- mime = "image/jpeg";
- fRet = true;
- }
- }
-
- return fRet;
+ // TODO: add quality control and return logo when nothing is loaded
+
+ bool fRet = false;
+
+ BYTE* pData = NULL;
+ long size = 0;
+ if (m_pMainFrame->GetDIB(&pData, size, true)) {
+ PBITMAPINFO bi = reinterpret_cast<PBITMAPINFO>(pData);
+ PBITMAPINFOHEADER bih = &bi->bmiHeader;
+
+ int bpp = bih->biBitCount;
+ if (bpp != 16 && bpp != 24 && bpp != 32) { return false; }
+ int w = bih->biWidth;
+ int h = abs(bih->biHeight);
+ BYTE* p = DNew BYTE[w * h * 4];
+
+ const BYTE* src = pData + sizeof(*bih);
+ if (bpp <= 8) {
+ if (bih->biClrUsed) {
+ src += bih->biClrUsed * sizeof(bi->bmiColors[0]);
+ } else {
+ src += (1 << bpp) * DWORD(sizeof(bi->bmiColors[0]));
+ }
+ }
+
+ int srcpitch = w * (bpp >> 3);
+ int dstpitch = w * 4;
+
+ BitBltFromRGBToRGB(w, h, p, dstpitch, 32, (BYTE*)src + srcpitch * (h - 1), -srcpitch, bpp);
+
+ {
+ CBitmap bmp;
+ bmp.CreateBitmap(w, h, bih->biPlanes, bpp, p);
+ delete [] p;
+
+ CImage img;
+ img.Attach(bmp);
+ IStream* pStream = NULL;
+ CByteArray ba;
+ if (SUCCEEDED(CreateStreamOnHGlobal(NULL, TRUE, &pStream))) {
+ if (SUCCEEDED(img.Save(pStream, Gdiplus::ImageFormatJPEG))) {
+ ULARGE_INTEGER ulnSize;
+ LARGE_INTEGER lnOffset;
+ lnOffset.QuadPart = 0;
+ if (SUCCEEDED(pStream->Seek(lnOffset, STREAM_SEEK_END, &ulnSize))) {
+ if (SUCCEEDED(pStream->Seek(lnOffset, STREAM_SEEK_SET, 0))) {
+ ULONG ulBytesRead;
+ ba.SetSize((INT_PTR)ulnSize.QuadPart);
+ pStream->Read(ba.GetData(), (INT_PTR)ulnSize.QuadPart, &ulBytesRead);
+ }
+ }
+ }
+ }
+
+ pStream->Release();
+ delete [] pData;
+
+ hdr +=
+ "Expires: Thu, 19 Nov 1981 08:52:00 GMT\r\n"
+ "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\r\n"
+ "Pragma: no-cache\r\n";
+ body = CStringA((char*)ba.GetData(), ba.GetCount());
+ mime = "image/jpeg";
+ fRet = true;
+ }
+ }
+
+ return fRet;
}
bool CWebClientSocket::OnConvRes(CStringA& hdr, CStringA& body, CStringA& mime)
{
- CString id;
- if (!m_get.Lookup(_T("id"), id)) {
- return false;
- }
+ CString id;
+ if (!m_get.Lookup(_T("id"), id)) {
+ return false;
+ }
- uintptr_t key = 0;
- if (1 != _stscanf_s(id, _T("%Ix"), &key) || key == 0) {
- return false;
- }
+ uintptr_t key = 0;
+ if (1 != _stscanf_s(id, _T("%Ix"), &key) || key == 0) {
+ return false;
+ }
- CAutoLock cAutoLock(&CDSMResource::m_csResources);
+ CAutoLock cAutoLock(&CDSMResource::m_csResources);
- CDSMResource* res = NULL;
- if (!CDSMResource::m_resources.Lookup(key, res) || !res) {
- return false;
- }
+ CDSMResource* res = NULL;
+ if (!CDSMResource::m_resources.Lookup(key, res) || !res) {
+ return false;
+ }
- body = CStringA((const char*)res->data.GetData(), res->data.GetCount());
- mime = CString(res->mime);
+ body = CStringA((const char*)res->data.GetData(), res->data.GetCount());
+ mime = CString(res->mime);
- return true;
+ return true;
}
diff --git a/src/mpc-hc/WebClientSocket.h b/src/mpc-hc/WebClientSocket.h
index c3f4ea02d..8363e5d0b 100644
--- a/src/mpc-hc/WebClientSocket.h
+++ b/src/mpc-hc/WebClientSocket.h
@@ -28,45 +28,45 @@ class CWebServer;
class CWebClientSocket : public CAsyncSocket
{
- CWebServer* m_pWebServer;
- CMainFrame* m_pMainFrame;
+ CWebServer* m_pWebServer;
+ CMainFrame* m_pMainFrame;
- CString m_hdr;
+ CString m_hdr;
- struct cookie_attribs {
- CString path, expire, domain;
- };
- CAtlStringMap<cookie_attribs> m_cookieattribs;
+ struct cookie_attribs {
+ CString path, expire, domain;
+ };
+ CAtlStringMap<cookie_attribs> m_cookieattribs;
- void Clear();
- void Header();
+ void Clear();
+ void Header();
protected:
- void OnReceive(int nErrorCode);
- void OnClose(int nErrorCode);
+ void OnReceive(int nErrorCode);
+ void OnClose(int nErrorCode);
public:
- CWebClientSocket(CWebServer* pWebServer, CMainFrame* pMainFrame);
- virtual ~CWebClientSocket();
+ CWebClientSocket(CWebServer* pWebServer, CMainFrame* pMainFrame);
+ virtual ~CWebClientSocket();
- bool SetCookie(CString name, CString value = _T(""), __time64_t expire = -1, CString path = _T("/"), CString domain = _T(""));
+ bool SetCookie(CString name, CString value = _T(""), __time64_t expire = -1, CString path = _T("/"), CString domain = _T(""));
- CString m_sessid;
- CString m_cmd, m_path, m_query, m_ver;
- CStringA m_data;
- CAtlStringMap<> m_hdrlines;
- CAtlStringMap<> m_get, m_post, m_cookie;
- CAtlStringMap<> m_request;
+ CString m_sessid;
+ CString m_cmd, m_path, m_query, m_ver;
+ CStringA m_data;
+ CAtlStringMap<> m_hdrlines;
+ CAtlStringMap<> m_get, m_post, m_cookie;
+ CAtlStringMap<> m_request;
- bool OnCommand(CStringA& hdr, CStringA& body, CStringA& mime);
- bool OnIndex(CStringA& hdr, CStringA& body, CStringA& mime);
- bool OnInfo(CStringA& hdr, CStringA& body, CStringA& mime);
- bool OnBrowser(CStringA& hdr, CStringA& body, CStringA& mime);
- bool OnControls(CStringA& hdr, CStringA& body, CStringA& mime);
- bool OnVariables(CStringA& hdr, CStringA& body, CStringA& mime);
- bool OnStatus(CStringA& hdr, CStringA& body, CStringA& mime);
- bool OnError404(CStringA& hdr, CStringA& body, CStringA& mime);
- bool OnPlayer(CStringA& hdr, CStringA& body, CStringA& mime);
- bool OnSnapShotJpeg(CStringA& hdr, CStringA& body, CStringA& mime);
- bool OnConvRes(CStringA& hdr, CStringA& body, CStringA& mime);
+ bool OnCommand(CStringA& hdr, CStringA& body, CStringA& mime);
+ bool OnIndex(CStringA& hdr, CStringA& body, CStringA& mime);
+ bool OnInfo(CStringA& hdr, CStringA& body, CStringA& mime);
+ bool OnBrowser(CStringA& hdr, CStringA& body, CStringA& mime);
+ bool OnControls(CStringA& hdr, CStringA& body, CStringA& mime);
+ bool OnVariables(CStringA& hdr, CStringA& body, CStringA& mime);
+ bool OnStatus(CStringA& hdr, CStringA& body, CStringA& mime);
+ bool OnError404(CStringA& hdr, CStringA& body, CStringA& mime);
+ bool OnPlayer(CStringA& hdr, CStringA& body, CStringA& mime);
+ bool OnSnapShotJpeg(CStringA& hdr, CStringA& body, CStringA& mime);
+ bool OnConvRes(CStringA& hdr, CStringA& body, CStringA& mime);
};
diff --git a/src/mpc-hc/WebServer.cpp b/src/mpc-hc/WebServer.cpp
index 8c2186eff..e181590a2 100644
--- a/src/mpc-hc/WebServer.cpp
+++ b/src/mpc-hc/WebServer.cpp
@@ -38,644 +38,644 @@ CAtlStringMap<UINT> CWebServer::m_downloads;
CAtlStringMap<CStringA, CStringA> CWebServer::m_mimes;
CWebServer::CWebServer(CMainFrame* pMainFrame, int nPort)
- : m_pMainFrame(pMainFrame)
- , m_nPort(nPort)
+ : m_pMainFrame(pMainFrame)
+ , m_nPort(nPort)
{
- if (m_internalpages.IsEmpty()) {
- m_internalpages[_T("/")] = &CWebClientSocket::OnIndex;
- m_internalpages[_T("/index.html")] = &CWebClientSocket::OnIndex;
- m_internalpages[_T("/info.html")] = &CWebClientSocket::OnInfo;
- m_internalpages[_T("/browser.html")] = &CWebClientSocket::OnBrowser;
- m_internalpages[_T("/controls.html")] = &CWebClientSocket::OnControls;
- m_internalpages[_T("/command.html")] = &CWebClientSocket::OnCommand;
- m_internalpages[_T("/status.html")] = &CWebClientSocket::OnStatus;
- m_internalpages[_T("/player.html")] = &CWebClientSocket::OnPlayer;
- m_internalpages[_T("/variables.html")] = &CWebClientSocket::OnVariables;
- m_internalpages[_T("/snapshot.jpg")] = &CWebClientSocket::OnSnapShotJpeg;
- m_internalpages[_T("/404.html")] = &CWebClientSocket::OnError404;
- m_internalpages[_T("/convres.html")] = &CWebClientSocket::OnConvRes;
- }
-
- if (m_downloads.IsEmpty()) {
- m_downloads[_T("/default.css")] = IDF_DEFAULT_CSS;
- m_downloads[_T("/vbg.png")] = IDF_VBR_PNG;
- m_downloads[_T("/vbs.png")] = IDF_VBS_PNG;
- m_downloads[_T("/sliderbar.gif")] = IDF_SLIDERBAR_GIF;
- m_downloads[_T("/slidergrip.gif")] = IDF_SLIDERGRIP_GIF;
- m_downloads[_T("/sliderback.png")] = IDF_SLIDERBACK_PNG;
- m_downloads[_T("/1pix.gif")] = IDF_1PIX_GIF;
- m_downloads[_T("/headericon.png")] = IDF_HEADERICON_PNG;
- m_downloads[_T("/headerback.png")] = IDF_HEADERBACK_PNG;
- m_downloads[_T("/headerclose.png")] = IDF_HEADERCLOSE_PNG;
- m_downloads[_T("/leftside.png")] = IDF_LEFTSIDE_PNG;
- m_downloads[_T("/rightside.png")] = IDF_RIGHTSIDE_PNG;
- m_downloads[_T("/bottomside.png")] = IDF_BOTTOMSIDE_PNG;
- m_downloads[_T("/leftbottomside.png")] = IDF_LEFTBOTTOMSIDE_PNG;
- m_downloads[_T("/rightbottomside.png")] = IDF_RIGHTBOTTOMSIDE_PNG;
- m_downloads[_T("/seekbarleft.png")] = IDF_SEEKBARLEFT_PNG;
- m_downloads[_T("/seekbarmid.png")] = IDF_SEEKBARMID_PNG;
- m_downloads[_T("/seekbarright.png")] = IDF_SEEKBARRIGHT_PNG;
- m_downloads[_T("/seekbargrip.png")] = IDF_SEEKBARGRIP_PNG;
- m_downloads[_T("/logo.png")] = DEF_LOGO;
- m_downloads[_T("/controlback.png")] = IDF_CONTROLBACK_PNG;
- m_downloads[_T("/controlbuttonplay.png")] = IDF_CONTROLBUTTONPLAY_PNG;
- m_downloads[_T("/controlbuttonpause.png")] = IDF_CONTROLBUTTONPAUSE_PNG;
- m_downloads[_T("/controlbuttonstop.png")] = IDF_CONTROLBUTTONSTOP_PNG;
- m_downloads[_T("/controlbuttonskipback.png")] = IDF_CONTROLBUTTONSKIPBACK_PNG;
- m_downloads[_T("/controlbuttondecrate.png")] = IDF_CONTROLBUTTONDECRATE_PNG;
- m_downloads[_T("/controlbuttonincrate.png")] = IDF_CONTROLBUTTONINCRATE_PNG;
- m_downloads[_T("/controlbuttonskipforward.png")] = IDF_CONTROLBUTTONSKIPFORWARD_PNG;
- m_downloads[_T("/controlbuttonstep.png")] = IDF_CONTROLBUTTONSTEP_PNG;
- m_downloads[_T("/controlvolumeon.png")] = IDF_CONTROLVOLUMEON_PNG;
- m_downloads[_T("/controlvolumeoff.png")] = IDF_CONTROLVOLUMEOFF_PNG;
- m_downloads[_T("/controlvolumebar.png")] = IDF_CONTROLVOLUMEBAR_PNG;
- m_downloads[_T("/controlvolumegrip.png")] = IDF_CONTROLVOLUMEGRIP_PNG;
- }
-
- CRegKey key;
- CString str(_T("MIME\\Database\\Content Type"));
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, str, KEY_READ)) {
- TCHAR buff[256];
- DWORD len = _countof(buff);
- for (int i = 0; ERROR_SUCCESS == key.EnumKey(i, buff, &len); i++, len = _countof(buff)) {
- CRegKey mime;
- TCHAR ext[64];
- ULONG len = _countof(ext);
- if (ERROR_SUCCESS == mime.Open(HKEY_CLASSES_ROOT, str + _T("\\") + buff, KEY_READ)
- && ERROR_SUCCESS == mime.QueryStringValue(_T("Extension"), ext, &len)) {
- m_mimes[CStringA(ext).MakeLower()] = CStringA(buff).MakeLower();
- }
- }
- }
-
- m_mimes[".html"] = "text/html";
- m_mimes[".txt"] = "text/plain";
- m_mimes[".css"] = "text/css";
- m_mimes[".gif"] = "image/gif";
- m_mimes[".jpeg"] = "image/jpeg";
- m_mimes[".jpg"] = "image/jpeg";
- m_mimes[".png"] = "image/png";
- m_mimes[".js"] = "text/javascript";
-
- GetModuleFileName(AfxGetInstanceHandle(), str.GetBuffer(_MAX_PATH), _MAX_PATH);
- str.ReleaseBuffer();
- m_webroot = CPath(str);
- m_webroot.RemoveFileSpec();
-
- CString WebRoot = AfxGetAppSettings().strWebRoot;
- WebRoot.Replace('/', '\\');
- WebRoot.Trim();
- CPath p(WebRoot);
- if (WebRoot.Find(_T(":\\")) < 0 && WebRoot.Find(_T("\\\\")) < 0) {
- m_webroot.Append(WebRoot);
- } else {
- m_webroot = p;
- }
- m_webroot.Canonicalize();
- m_webroot.MakePretty();
- if (!m_webroot.IsDirectory()) {
- m_webroot = CPath();
- }
-
- CAtlList<CString> sl;
- Explode(AfxGetAppSettings().strWebServerCGI, sl, ';');
- POSITION pos = sl.GetHeadPosition();
- while (pos) {
- CAtlList<CString> sl2;
- CString ext = Explode(sl.GetNext(pos), sl2, '=', 2);
- if (sl2.GetCount() < 2) {
- continue;
- }
- m_cgi[ext] = sl2.GetTail();
- }
-
- m_ThreadId = 0;
- m_hThread = ::CreateThread(NULL, 0, StaticThreadProc, (LPVOID)this, 0, &m_ThreadId);
+ if (m_internalpages.IsEmpty()) {
+ m_internalpages[_T("/")] = &CWebClientSocket::OnIndex;
+ m_internalpages[_T("/index.html")] = &CWebClientSocket::OnIndex;
+ m_internalpages[_T("/info.html")] = &CWebClientSocket::OnInfo;
+ m_internalpages[_T("/browser.html")] = &CWebClientSocket::OnBrowser;
+ m_internalpages[_T("/controls.html")] = &CWebClientSocket::OnControls;
+ m_internalpages[_T("/command.html")] = &CWebClientSocket::OnCommand;
+ m_internalpages[_T("/status.html")] = &CWebClientSocket::OnStatus;
+ m_internalpages[_T("/player.html")] = &CWebClientSocket::OnPlayer;
+ m_internalpages[_T("/variables.html")] = &CWebClientSocket::OnVariables;
+ m_internalpages[_T("/snapshot.jpg")] = &CWebClientSocket::OnSnapShotJpeg;
+ m_internalpages[_T("/404.html")] = &CWebClientSocket::OnError404;
+ m_internalpages[_T("/convres.html")] = &CWebClientSocket::OnConvRes;
+ }
+
+ if (m_downloads.IsEmpty()) {
+ m_downloads[_T("/default.css")] = IDF_DEFAULT_CSS;
+ m_downloads[_T("/vbg.png")] = IDF_VBR_PNG;
+ m_downloads[_T("/vbs.png")] = IDF_VBS_PNG;
+ m_downloads[_T("/sliderbar.gif")] = IDF_SLIDERBAR_GIF;
+ m_downloads[_T("/slidergrip.gif")] = IDF_SLIDERGRIP_GIF;
+ m_downloads[_T("/sliderback.png")] = IDF_SLIDERBACK_PNG;
+ m_downloads[_T("/1pix.gif")] = IDF_1PIX_GIF;
+ m_downloads[_T("/headericon.png")] = IDF_HEADERICON_PNG;
+ m_downloads[_T("/headerback.png")] = IDF_HEADERBACK_PNG;
+ m_downloads[_T("/headerclose.png")] = IDF_HEADERCLOSE_PNG;
+ m_downloads[_T("/leftside.png")] = IDF_LEFTSIDE_PNG;
+ m_downloads[_T("/rightside.png")] = IDF_RIGHTSIDE_PNG;
+ m_downloads[_T("/bottomside.png")] = IDF_BOTTOMSIDE_PNG;
+ m_downloads[_T("/leftbottomside.png")] = IDF_LEFTBOTTOMSIDE_PNG;
+ m_downloads[_T("/rightbottomside.png")] = IDF_RIGHTBOTTOMSIDE_PNG;
+ m_downloads[_T("/seekbarleft.png")] = IDF_SEEKBARLEFT_PNG;
+ m_downloads[_T("/seekbarmid.png")] = IDF_SEEKBARMID_PNG;
+ m_downloads[_T("/seekbarright.png")] = IDF_SEEKBARRIGHT_PNG;
+ m_downloads[_T("/seekbargrip.png")] = IDF_SEEKBARGRIP_PNG;
+ m_downloads[_T("/logo.png")] = DEF_LOGO;
+ m_downloads[_T("/controlback.png")] = IDF_CONTROLBACK_PNG;
+ m_downloads[_T("/controlbuttonplay.png")] = IDF_CONTROLBUTTONPLAY_PNG;
+ m_downloads[_T("/controlbuttonpause.png")] = IDF_CONTROLBUTTONPAUSE_PNG;
+ m_downloads[_T("/controlbuttonstop.png")] = IDF_CONTROLBUTTONSTOP_PNG;
+ m_downloads[_T("/controlbuttonskipback.png")] = IDF_CONTROLBUTTONSKIPBACK_PNG;
+ m_downloads[_T("/controlbuttondecrate.png")] = IDF_CONTROLBUTTONDECRATE_PNG;
+ m_downloads[_T("/controlbuttonincrate.png")] = IDF_CONTROLBUTTONINCRATE_PNG;
+ m_downloads[_T("/controlbuttonskipforward.png")] = IDF_CONTROLBUTTONSKIPFORWARD_PNG;
+ m_downloads[_T("/controlbuttonstep.png")] = IDF_CONTROLBUTTONSTEP_PNG;
+ m_downloads[_T("/controlvolumeon.png")] = IDF_CONTROLVOLUMEON_PNG;
+ m_downloads[_T("/controlvolumeoff.png")] = IDF_CONTROLVOLUMEOFF_PNG;
+ m_downloads[_T("/controlvolumebar.png")] = IDF_CONTROLVOLUMEBAR_PNG;
+ m_downloads[_T("/controlvolumegrip.png")] = IDF_CONTROLVOLUMEGRIP_PNG;
+ }
+
+ CRegKey key;
+ CString str(_T("MIME\\Database\\Content Type"));
+ if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, str, KEY_READ)) {
+ TCHAR buff[256];
+ DWORD len = _countof(buff);
+ for (int i = 0; ERROR_SUCCESS == key.EnumKey(i, buff, &len); i++, len = _countof(buff)) {
+ CRegKey mime;
+ TCHAR ext[64];
+ ULONG len = _countof(ext);
+ if (ERROR_SUCCESS == mime.Open(HKEY_CLASSES_ROOT, str + _T("\\") + buff, KEY_READ)
+ && ERROR_SUCCESS == mime.QueryStringValue(_T("Extension"), ext, &len)) {
+ m_mimes[CStringA(ext).MakeLower()] = CStringA(buff).MakeLower();
+ }
+ }
+ }
+
+ m_mimes[".html"] = "text/html";
+ m_mimes[".txt"] = "text/plain";
+ m_mimes[".css"] = "text/css";
+ m_mimes[".gif"] = "image/gif";
+ m_mimes[".jpeg"] = "image/jpeg";
+ m_mimes[".jpg"] = "image/jpeg";
+ m_mimes[".png"] = "image/png";
+ m_mimes[".js"] = "text/javascript";
+
+ GetModuleFileName(AfxGetInstanceHandle(), str.GetBuffer(_MAX_PATH), _MAX_PATH);
+ str.ReleaseBuffer();
+ m_webroot = CPath(str);
+ m_webroot.RemoveFileSpec();
+
+ CString WebRoot = AfxGetAppSettings().strWebRoot;
+ WebRoot.Replace('/', '\\');
+ WebRoot.Trim();
+ CPath p(WebRoot);
+ if (WebRoot.Find(_T(":\\")) < 0 && WebRoot.Find(_T("\\\\")) < 0) {
+ m_webroot.Append(WebRoot);
+ } else {
+ m_webroot = p;
+ }
+ m_webroot.Canonicalize();
+ m_webroot.MakePretty();
+ if (!m_webroot.IsDirectory()) {
+ m_webroot = CPath();
+ }
+
+ CAtlList<CString> sl;
+ Explode(AfxGetAppSettings().strWebServerCGI, sl, ';');
+ POSITION pos = sl.GetHeadPosition();
+ while (pos) {
+ CAtlList<CString> sl2;
+ CString ext = Explode(sl.GetNext(pos), sl2, '=', 2);
+ if (sl2.GetCount() < 2) {
+ continue;
+ }
+ m_cgi[ext] = sl2.GetTail();
+ }
+
+ m_ThreadId = 0;
+ m_hThread = ::CreateThread(NULL, 0, StaticThreadProc, (LPVOID)this, 0, &m_ThreadId);
}
CWebServer::~CWebServer()
{
- if (m_hThread != NULL) {
- PostThreadMessage(m_ThreadId, WM_QUIT, 0, 0);
- if (WaitForSingleObject(m_hThread, 10000) == WAIT_TIMEOUT) {
- TerminateThread (m_hThread, 0xDEAD);
- }
- EXECUTE_ASSERT(CloseHandle(m_hThread));
- }
+ if (m_hThread != NULL) {
+ PostThreadMessage(m_ThreadId, WM_QUIT, 0, 0);
+ if (WaitForSingleObject(m_hThread, 10000) == WAIT_TIMEOUT) {
+ TerminateThread(m_hThread, 0xDEAD);
+ }
+ EXECUTE_ASSERT(CloseHandle(m_hThread));
+ }
}
DWORD WINAPI CWebServer::StaticThreadProc(LPVOID lpParam)
{
- return ((CWebServer*)lpParam)->ThreadProc();
+ return ((CWebServer*)lpParam)->ThreadProc();
}
DWORD CWebServer::ThreadProc()
{
- if (!AfxSocketInit(NULL)) {
- return (DWORD)-1;
- }
+ if (!AfxSocketInit(NULL)) {
+ return (DWORD) - 1;
+ }
- CWebServerSocket s(this, m_nPort);
+ CWebServerSocket s(this, m_nPort);
- MSG msg;
- while ((int)GetMessage(&msg, NULL, 0, 0) > 0) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
+ MSG msg;
+ while ((int)GetMessage(&msg, NULL, 0, 0) > 0) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
- return 0;
+ return 0;
}
static void PutFileContents(LPCTSTR fn, const CStringA& data)
{
- FILE* f = NULL;
- if (!_tfopen_s(&f, fn, _T("wb"))) {
- fwrite((LPCSTR)data, 1, data.GetLength(), f);
- fclose(f);
- }
+ FILE* f = NULL;
+ if (!_tfopen_s(&f, fn, _T("wb"))) {
+ fwrite((LPCSTR)data, 1, data.GetLength(), f);
+ fclose(f);
+ }
}
void CWebServer::Deploy(CString dir)
{
- CStringA data;
- if (LoadResource(IDR_HTML_INDEX, data, RT_HTML)) {
- PutFileContents(dir + _T("index.html"), data);
- }
- if (LoadResource(IDR_HTML_INFO, data, RT_HTML)) {
- PutFileContents(dir + _T("info.html"), data);
- }
- if (LoadResource(IDR_HTML_BROWSER, data, RT_HTML)) {
- PutFileContents(dir + _T("browser.html"), data);
- }
- if (LoadResource(IDR_HTML_CONTROLS, data, RT_HTML)) {
- PutFileContents(dir + _T("controls.html"), data);
- }
- if (LoadResource(IDR_HTML_VARIABLES, data, RT_HTML)) {
- PutFileContents(dir + _T("variables.html"), data);
- }
- if (LoadResource(IDR_HTML_404, data, RT_HTML)) {
- PutFileContents(dir + _T("404.html"), data);
- }
- if (LoadResource(IDR_HTML_PLAYER, data, RT_HTML)) {
- PutFileContents(dir + _T("player.html"), data);
- }
-
- POSITION pos = m_downloads.GetStartPosition();
- while (pos) {
- CString fn;
- UINT id;
- m_downloads.GetNextAssoc(pos, fn, id);
- if (LoadResource(id, data, _T("FILE"))) {
- PutFileContents(dir + fn, data);
- }
- }
+ CStringA data;
+ if (LoadResource(IDR_HTML_INDEX, data, RT_HTML)) {
+ PutFileContents(dir + _T("index.html"), data);
+ }
+ if (LoadResource(IDR_HTML_INFO, data, RT_HTML)) {
+ PutFileContents(dir + _T("info.html"), data);
+ }
+ if (LoadResource(IDR_HTML_BROWSER, data, RT_HTML)) {
+ PutFileContents(dir + _T("browser.html"), data);
+ }
+ if (LoadResource(IDR_HTML_CONTROLS, data, RT_HTML)) {
+ PutFileContents(dir + _T("controls.html"), data);
+ }
+ if (LoadResource(IDR_HTML_VARIABLES, data, RT_HTML)) {
+ PutFileContents(dir + _T("variables.html"), data);
+ }
+ if (LoadResource(IDR_HTML_404, data, RT_HTML)) {
+ PutFileContents(dir + _T("404.html"), data);
+ }
+ if (LoadResource(IDR_HTML_PLAYER, data, RT_HTML)) {
+ PutFileContents(dir + _T("player.html"), data);
+ }
+
+ POSITION pos = m_downloads.GetStartPosition();
+ while (pos) {
+ CString fn;
+ UINT id;
+ m_downloads.GetNextAssoc(pos, fn, id);
+ if (LoadResource(id, data, _T("FILE"))) {
+ PutFileContents(dir + fn, data);
+ }
+ }
}
bool CWebServer::ToLocalPath(CString& path, CString& redir)
{
- if (!path.IsEmpty() && m_webroot.IsDirectory()) {
- CString str = path;
- str.Replace('/', '\\');
- str.TrimLeft('\\');
-
- CPath p;
- p.Combine(m_webroot, str);
- p.Canonicalize();
-
- if (p.IsDirectory()) {
- CAtlList<CString> sl;
- Explode(AfxGetAppSettings().strWebDefIndex, sl, ';');
- POSITION pos = sl.GetHeadPosition();
- while (pos) {
- str = sl.GetNext(pos);
- CPath p2 = p;
- p2.Append(str);
- if (p2.FileExists()) {
- p = p2;
- redir = path;
- if (redir.GetAt(redir.GetLength()-1) != '/') {
- redir += '/';
- }
- redir += str;
- break;
- }
- }
- }
-
- if (_tcslen(p) > _tcslen(m_webroot) && p.FileExists()) {
- path = (LPCTSTR)p;
- return true;
- }
- }
-
- return false;
+ if (!path.IsEmpty() && m_webroot.IsDirectory()) {
+ CString str = path;
+ str.Replace('/', '\\');
+ str.TrimLeft('\\');
+
+ CPath p;
+ p.Combine(m_webroot, str);
+ p.Canonicalize();
+
+ if (p.IsDirectory()) {
+ CAtlList<CString> sl;
+ Explode(AfxGetAppSettings().strWebDefIndex, sl, ';');
+ POSITION pos = sl.GetHeadPosition();
+ while (pos) {
+ str = sl.GetNext(pos);
+ CPath p2 = p;
+ p2.Append(str);
+ if (p2.FileExists()) {
+ p = p2;
+ redir = path;
+ if (redir.GetAt(redir.GetLength() - 1) != '/') {
+ redir += '/';
+ }
+ redir += str;
+ break;
+ }
+ }
+ }
+
+ if (_tcslen(p) > _tcslen(m_webroot) && p.FileExists()) {
+ path = (LPCTSTR)p;
+ return true;
+ }
+ }
+
+ return false;
}
bool CWebServer::LoadPage(UINT resid, CStringA& str, CString path)
{
- CString redir;
- if (ToLocalPath(path, redir)) {
- FILE* f = NULL;
- if (!_tfopen_s(&f, path, _T("rb"))) {
- fseek(f, 0, 2);
- char* buff = str.GetBufferSetLength(ftell(f));
- fseek(f, 0, 0);
- int len = (int)fread(buff, 1, str.GetLength(), f);
- fclose(f);
- return len == str.GetLength();
- }
- }
-
- return LoadResource(resid, str, RT_HTML);
+ CString redir;
+ if (ToLocalPath(path, redir)) {
+ FILE* f = NULL;
+ if (!_tfopen_s(&f, path, _T("rb"))) {
+ fseek(f, 0, 2);
+ char* buff = str.GetBufferSetLength(ftell(f));
+ fseek(f, 0, 0);
+ int len = (int)fread(buff, 1, str.GetLength(), f);
+ fclose(f);
+ return len == str.GetLength();
+ }
+ }
+
+ return LoadResource(resid, str, RT_HTML);
}
void CWebServer::OnAccept(CWebServerSocket* pServer)
{
- CAutoPtr<CWebClientSocket> p(DNew CWebClientSocket(this, m_pMainFrame));
- if (pServer->Accept(*p)) {
- CString name;
- UINT port;
- if (AfxGetAppSettings().fWebServerLocalhostOnly && p->GetPeerName(name, port) && name != _T("127.0.0.1")) {
- p->Close();
- return;
- }
-
- m_clients.AddTail(p);
- }
+ CAutoPtr<CWebClientSocket> p(DNew CWebClientSocket(this, m_pMainFrame));
+ if (pServer->Accept(*p)) {
+ CString name;
+ UINT port;
+ if (AfxGetAppSettings().fWebServerLocalhostOnly && p->GetPeerName(name, port) && name != _T("127.0.0.1")) {
+ p->Close();
+ return;
+ }
+
+ m_clients.AddTail(p);
+ }
}
void CWebServer::OnClose(CWebClientSocket* pClient)
{
- POSITION pos = m_clients.GetHeadPosition();
- while (pos) {
- POSITION cur = pos;
- if (m_clients.GetNext(pos) == pClient) {
- m_clients.RemoveAt(cur);
- break;
- }
- }
+ POSITION pos = m_clients.GetHeadPosition();
+ while (pos) {
+ POSITION cur = pos;
+ if (m_clients.GetNext(pos) == pClient) {
+ m_clients.RemoveAt(cur);
+ break;
+ }
+ }
}
void CWebServer::OnRequest(CWebClientSocket* pClient, CStringA& hdr, CStringA& body)
{
- CPath p(pClient->m_path);
- CStringA ext = p.GetExtension().MakeLower();
- CStringA mime;
- if (ext.IsEmpty()) {
- mime = "text/html";
- } else {
- m_mimes.Lookup(ext, mime);
- }
-
- hdr = "HTTP/1.0 200 OK\r\n";
-
- bool fHandled = false, fCGI = false;
-
- if (!fHandled && m_webroot.IsDirectory()) {
- CStringA tmphdr;
- fHandled = fCGI = CallCGI(pClient, tmphdr, body, mime);
-
- if (fHandled) {
- tmphdr.Replace("\r\n", "\n");
- CAtlList<CStringA> hdrlines;
- ExplodeMin(tmphdr, hdrlines, '\n');
- POSITION pos = hdrlines.GetHeadPosition();
- while (pos) {
- POSITION cur = pos;
- CAtlList<CStringA> sl;
- CStringA key = Explode(hdrlines.GetNext(pos), sl, ':', 2);
- if (sl.GetCount() < 2) {
- continue;
- }
- key.Trim().MakeLower();
- if (key == "content-type") {
- mime = sl.GetTail().Trim();
- hdrlines.RemoveAt(cur);
- } else if (key == "content-length") {
- hdrlines.RemoveAt(cur);
- }
- }
- tmphdr = Implode(hdrlines, '\n');
- tmphdr.Replace("\n", "\r\n");
- hdr += tmphdr + "\r\n";
- }
- }
-
- RequestHandler rh = NULL;
- if (!fHandled && m_internalpages.Lookup(pClient->m_path, rh) && (pClient->*rh)(hdr, body, mime)) {
- if (mime.IsEmpty()) {
- mime = "text/html";
- }
-
- CString redir;
- if (pClient->m_get.Lookup(_T("redir"), redir)
- || pClient->m_post.Lookup(_T("redir"), redir)) {
- if (redir.IsEmpty()) {
- redir = '/';
- }
-
- hdr =
- "HTTP/1.0 302 Found\r\n"
- "Location: " + CStringA(redir) + "\r\n";
- return;
- }
-
- fHandled = true;
- }
-
- if (!fHandled && m_webroot.IsDirectory()) {
- fHandled = LoadPage(0, body, pClient->m_path);
- }
-
- UINT resid;
- CStringA res;
- if (!fHandled && m_downloads.Lookup(pClient->m_path, resid) && LoadResource(resid, res, _T("FILE"))) {
- if (mime.IsEmpty()) {
- mime = "application/octet-stream";
- }
- memcpy(body.GetBufferSetLength(res.GetLength()), res.GetBuffer(), res.GetLength());
- fHandled = true;
- }
-
- if (!fHandled) {
- hdr = mime == "text/html"
- ? "HTTP/1.0 301 Moved Permanently\r\n" "Location: /404.html\r\n"
- : "HTTP/1.0 404 Not Found\r\n";
- return;
- }
-
- if (mime == "text/html" && !fCGI) {
- hdr +=
- "Expires: Thu, 19 Nov 1981 08:52:00 GMT\r\n"
- "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\r\n"
- "Pragma: no-cache\r\n";
-
- CStringA debug;
- if (AfxGetAppSettings().fWebServerPrintDebugInfo) {
- debug += "<hr>\r\n";
- CString key, value;
- POSITION pos;
- pos = pClient->m_hdrlines.GetStartPosition();
- while (pos) {
- pClient->m_hdrlines.GetNextAssoc(pos, key, value);
- debug += "HEADER[" + key + "] = " + value + "<br>\r\n";
- }
- debug += "cmd: " + pClient->m_cmd + "<br>\r\n";
- debug += "path: " + pClient->m_path + "<br>\r\n";
- debug += "ver: " + pClient->m_ver + "<br>\r\n";
- pos = pClient->m_get.GetStartPosition();
- while (pos) {
- pClient->m_get.GetNextAssoc(pos, key, value);
- debug += "GET[" + key + "] = " + value + "<br>\r\n";
- }
- pos = pClient->m_post.GetStartPosition();
- while (pos) {
- pClient->m_post.GetNextAssoc(pos, key, value);
- debug += "POST[" + key + "] = " + value + "<br>\r\n";
- }
- pos = pClient->m_cookie.GetStartPosition();
- while (pos) {
- pClient->m_cookie.GetNextAssoc(pos, key, value);
- debug += "COOKIE[" + key + "] = " + value + "<br>\r\n";
- }
- pos = pClient->m_request.GetStartPosition();
- while (pos) {
- pClient->m_request.GetNextAssoc(pos, key, value);
- debug += "REQUEST[" + key + "] = " + value + "<br>\r\n";
- }
- }
-
- body.Replace("[path]", CStringA(pClient->m_path));
- body.Replace("[indexpath]", "/index.html");
- body.Replace("[commandpath]", "/command.html");
- body.Replace("[browserpath]", "/browser.html");
- body.Replace("[controlspath]", "/controls.html");
- body.Replace("[wmcname]", "wm_command");
- body.Replace("[setposcommand]", CMD_SETPOS);
- body.Replace("[setvolumecommand]", CMD_SETVOLUME);
- body.Replace("[debug]", debug);
- // TODO: add more general tags to replace
- }
-
- // gzip
- if (AfxGetAppSettings().fWebServerUseCompression && hdr.Find("Content-Encoding:") < 0)
- do {
- CString accept_encoding;
- pClient->m_hdrlines.Lookup(_T("accept-encoding"), accept_encoding);
- accept_encoding.MakeLower();
- CAtlList<CString> sl;
- ExplodeMin(accept_encoding, sl, ',');
- if (!sl.Find(_T("gzip"))) {
- break;
- }
-
- CHAR path[_MAX_PATH], fn[_MAX_PATH];
- if (!GetTempPathA(_MAX_PATH, path) || !GetTempFileNameA(path, "mpc_gz", 0, fn)) {
- break;
- }
-
- gzFile gf = gzopen(fn, "wb9");
- if (!gf || gzwrite(gf, (LPVOID)(LPCSTR)body, body.GetLength()) != body.GetLength()) {
- if (gf) {
- gzclose(gf);
- }
- DeleteFileA(fn);
- break;
- }
- gzclose(gf);
-
- FILE* f = NULL;
- if (fopen_s(&f, fn, "rb")) {
- DeleteFileA(fn);
- break;
- }
- fseek(f, 0, 2);
- CHAR* s = body.GetBufferSetLength(ftell(f));
- fseek(f, 0, 0);
- int len = (int)fread(s, 1, body.GetLength(), f);
- ASSERT(len == body.GetLength());
+ CPath p(pClient->m_path);
+ CStringA ext = p.GetExtension().MakeLower();
+ CStringA mime;
+ if (ext.IsEmpty()) {
+ mime = "text/html";
+ } else {
+ m_mimes.Lookup(ext, mime);
+ }
+
+ hdr = "HTTP/1.0 200 OK\r\n";
+
+ bool fHandled = false, fCGI = false;
+
+ if (!fHandled && m_webroot.IsDirectory()) {
+ CStringA tmphdr;
+ fHandled = fCGI = CallCGI(pClient, tmphdr, body, mime);
+
+ if (fHandled) {
+ tmphdr.Replace("\r\n", "\n");
+ CAtlList<CStringA> hdrlines;
+ ExplodeMin(tmphdr, hdrlines, '\n');
+ POSITION pos = hdrlines.GetHeadPosition();
+ while (pos) {
+ POSITION cur = pos;
+ CAtlList<CStringA> sl;
+ CStringA key = Explode(hdrlines.GetNext(pos), sl, ':', 2);
+ if (sl.GetCount() < 2) {
+ continue;
+ }
+ key.Trim().MakeLower();
+ if (key == "content-type") {
+ mime = sl.GetTail().Trim();
+ hdrlines.RemoveAt(cur);
+ } else if (key == "content-length") {
+ hdrlines.RemoveAt(cur);
+ }
+ }
+ tmphdr = Implode(hdrlines, '\n');
+ tmphdr.Replace("\n", "\r\n");
+ hdr += tmphdr + "\r\n";
+ }
+ }
+
+ RequestHandler rh = NULL;
+ if (!fHandled && m_internalpages.Lookup(pClient->m_path, rh) && (pClient->*rh)(hdr, body, mime)) {
+ if (mime.IsEmpty()) {
+ mime = "text/html";
+ }
+
+ CString redir;
+ if (pClient->m_get.Lookup(_T("redir"), redir)
+ || pClient->m_post.Lookup(_T("redir"), redir)) {
+ if (redir.IsEmpty()) {
+ redir = '/';
+ }
+
+ hdr =
+ "HTTP/1.0 302 Found\r\n"
+ "Location: " + CStringA(redir) + "\r\n";
+ return;
+ }
+
+ fHandled = true;
+ }
+
+ if (!fHandled && m_webroot.IsDirectory()) {
+ fHandled = LoadPage(0, body, pClient->m_path);
+ }
+
+ UINT resid;
+ CStringA res;
+ if (!fHandled && m_downloads.Lookup(pClient->m_path, resid) && LoadResource(resid, res, _T("FILE"))) {
+ if (mime.IsEmpty()) {
+ mime = "application/octet-stream";
+ }
+ memcpy(body.GetBufferSetLength(res.GetLength()), res.GetBuffer(), res.GetLength());
+ fHandled = true;
+ }
+
+ if (!fHandled) {
+ hdr = mime == "text/html"
+ ? "HTTP/1.0 301 Moved Permanently\r\n" "Location: /404.html\r\n"
+ : "HTTP/1.0 404 Not Found\r\n";
+ return;
+ }
+
+ if (mime == "text/html" && !fCGI) {
+ hdr +=
+ "Expires: Thu, 19 Nov 1981 08:52:00 GMT\r\n"
+ "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\r\n"
+ "Pragma: no-cache\r\n";
+
+ CStringA debug;
+ if (AfxGetAppSettings().fWebServerPrintDebugInfo) {
+ debug += "<hr>\r\n";
+ CString key, value;
+ POSITION pos;
+ pos = pClient->m_hdrlines.GetStartPosition();
+ while (pos) {
+ pClient->m_hdrlines.GetNextAssoc(pos, key, value);
+ debug += "HEADER[" + key + "] = " + value + "<br>\r\n";
+ }
+ debug += "cmd: " + pClient->m_cmd + "<br>\r\n";
+ debug += "path: " + pClient->m_path + "<br>\r\n";
+ debug += "ver: " + pClient->m_ver + "<br>\r\n";
+ pos = pClient->m_get.GetStartPosition();
+ while (pos) {
+ pClient->m_get.GetNextAssoc(pos, key, value);
+ debug += "GET[" + key + "] = " + value + "<br>\r\n";
+ }
+ pos = pClient->m_post.GetStartPosition();
+ while (pos) {
+ pClient->m_post.GetNextAssoc(pos, key, value);
+ debug += "POST[" + key + "] = " + value + "<br>\r\n";
+ }
+ pos = pClient->m_cookie.GetStartPosition();
+ while (pos) {
+ pClient->m_cookie.GetNextAssoc(pos, key, value);
+ debug += "COOKIE[" + key + "] = " + value + "<br>\r\n";
+ }
+ pos = pClient->m_request.GetStartPosition();
+ while (pos) {
+ pClient->m_request.GetNextAssoc(pos, key, value);
+ debug += "REQUEST[" + key + "] = " + value + "<br>\r\n";
+ }
+ }
+
+ body.Replace("[path]", CStringA(pClient->m_path));
+ body.Replace("[indexpath]", "/index.html");
+ body.Replace("[commandpath]", "/command.html");
+ body.Replace("[browserpath]", "/browser.html");
+ body.Replace("[controlspath]", "/controls.html");
+ body.Replace("[wmcname]", "wm_command");
+ body.Replace("[setposcommand]", CMD_SETPOS);
+ body.Replace("[setvolumecommand]", CMD_SETVOLUME);
+ body.Replace("[debug]", debug);
+ // TODO: add more general tags to replace
+ }
+
+ // gzip
+ if (AfxGetAppSettings().fWebServerUseCompression && hdr.Find("Content-Encoding:") < 0)
+ do {
+ CString accept_encoding;
+ pClient->m_hdrlines.Lookup(_T("accept-encoding"), accept_encoding);
+ accept_encoding.MakeLower();
+ CAtlList<CString> sl;
+ ExplodeMin(accept_encoding, sl, ',');
+ if (!sl.Find(_T("gzip"))) {
+ break;
+ }
+
+ CHAR path[_MAX_PATH], fn[_MAX_PATH];
+ if (!GetTempPathA(_MAX_PATH, path) || !GetTempFileNameA(path, "mpc_gz", 0, fn)) {
+ break;
+ }
+
+ gzFile gf = gzopen(fn, "wb9");
+ if (!gf || gzwrite(gf, (LPVOID)(LPCSTR)body, body.GetLength()) != body.GetLength()) {
+ if (gf) {
+ gzclose(gf);
+ }
+ DeleteFileA(fn);
+ break;
+ }
+ gzclose(gf);
+
+ FILE* f = NULL;
+ if (fopen_s(&f, fn, "rb")) {
+ DeleteFileA(fn);
+ break;
+ }
+ fseek(f, 0, 2);
+ CHAR* s = body.GetBufferSetLength(ftell(f));
+ fseek(f, 0, 0);
+ int len = (int)fread(s, 1, body.GetLength(), f);
+ ASSERT(len == body.GetLength());
#ifndef _DEBUG
- UNREFERENCED_PARAMETER(len);
+ UNREFERENCED_PARAMETER(len);
#endif
- fclose(f);
- DeleteFileA(fn);
-
- hdr += "Content-Encoding: gzip\r\n";
- } while (0);
-
- CStringA content;
- content.Format(
- "Content-Type: %s\r\n"
- "Content-Length: %d\r\n",
- mime, body.GetLength());
- hdr += content;
+ fclose(f);
+ DeleteFileA(fn);
+
+ hdr += "Content-Encoding: gzip\r\n";
+ } while (0);
+
+ CStringA content;
+ content.Format(
+ "Content-Type: %s\r\n"
+ "Content-Length: %d\r\n",
+ mime, body.GetLength());
+ hdr += content;
}
static DWORD WINAPI KillCGI(LPVOID lParam)
{
- HANDLE hProcess = (HANDLE)lParam;
- if (WaitForSingleObject(hProcess, 30000) == WAIT_TIMEOUT) {
- TerminateProcess(hProcess, 0);
- }
- return 0;
+ HANDLE hProcess = (HANDLE)lParam;
+ if (WaitForSingleObject(hProcess, 30000) == WAIT_TIMEOUT) {
+ TerminateProcess(hProcess, 0);
+ }
+ return 0;
}
bool CWebServer::CallCGI(CWebClientSocket* pClient, CStringA& hdr, CStringA& body, CStringA& mime)
{
- CString path = pClient->m_path, redir = path;
- if (!ToLocalPath(path, redir)) {
- return false;
- }
- CString ext = CPath(path).GetExtension().MakeLower();
- CPath dir(path);
- dir.RemoveFileSpec();
-
- CString cgi;
- if (!m_cgi.Lookup(ext, cgi) || !CPath(cgi).FileExists()) {
- return false;
- }
-
- HANDLE hProcess = GetCurrentProcess();
- HANDLE hChildStdinRd, hChildStdinWr, hChildStdinWrDup = NULL;
- HANDLE hChildStdoutRd, hChildStdoutWr, hChildStdoutRdDup = NULL;
-
- SECURITY_ATTRIBUTES saAttr;
- ZeroMemory(&saAttr, sizeof(saAttr));
- saAttr.nLength = sizeof(saAttr);
- saAttr.bInheritHandle = TRUE;
-
- if (CreatePipe(&hChildStdoutRd, &hChildStdoutWr, &saAttr, 0)) {
- BOOL fSuccess = DuplicateHandle(hProcess, hChildStdoutRd, hProcess, &hChildStdoutRdDup, 0, FALSE, DUPLICATE_SAME_ACCESS);
- UNREFERENCED_PARAMETER(fSuccess);
- CloseHandle(hChildStdoutRd);
- }
-
- if (CreatePipe(&hChildStdinRd, &hChildStdinWr, &saAttr, 0)) {
- BOOL fSuccess = DuplicateHandle(hProcess, hChildStdinWr, hProcess, &hChildStdinWrDup, 0, FALSE, DUPLICATE_SAME_ACCESS);
- UNREFERENCED_PARAMETER(fSuccess);
- CloseHandle(hChildStdinWr);
- }
-
- STARTUPINFO siStartInfo;
- ZeroMemory(&siStartInfo, sizeof(siStartInfo));
- siStartInfo.cb = sizeof(siStartInfo);
- siStartInfo.hStdError = hChildStdoutWr;
- siStartInfo.hStdOutput = hChildStdoutWr;
- siStartInfo.hStdInput = hChildStdinRd;
- siStartInfo.dwFlags |= STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;
- siStartInfo.wShowWindow = SW_HIDE;
-
- PROCESS_INFORMATION piProcInfo;
- ZeroMemory(&piProcInfo, sizeof(piProcInfo));
-
- CStringA envstr;
-
- LPVOID lpvEnv = GetEnvironmentStrings();
- if (lpvEnv) {
- CString str;
-
- CAtlList<CString> env;
- for (LPTSTR lpszVariable = (LPTSTR)lpvEnv; *lpszVariable; lpszVariable += _tcslen(lpszVariable)+1)
- if (lpszVariable != (LPTSTR)lpvEnv) {
- env.AddTail(lpszVariable);
- }
-
- env.AddTail(_T("GATEWAY_INTERFACE=CGI/1.1"));
- env.AddTail(_T("SERVER_SOFTWARE=Media Player Classic - Home Cinema/1.6.2.x"));
- env.AddTail(_T("SERVER_PROTOCOL=") + pClient->m_ver);
- env.AddTail(_T("REQUEST_METHOD=") + pClient->m_cmd);
- env.AddTail(_T("PATH_INFO=") + redir);
- env.AddTail(_T("PATH_TRANSLATED=") + path);
- env.AddTail(_T("SCRIPT_NAME=") + redir);
- env.AddTail(_T("QUERY_STRING=") + pClient->m_query);
-
- if (pClient->m_hdrlines.Lookup(_T("content-type"), str)) {
- env.AddTail(_T("CONTENT_TYPE=") + str);
- }
- if (pClient->m_hdrlines.Lookup(_T("content-length"), str)) {
- env.AddTail(_T("CONTENT_LENGTH=") + str);
- }
-
- POSITION pos = pClient->m_hdrlines.GetStartPosition();
- while (pos) {
- CString key = pClient->m_hdrlines.GetKeyAt(pos);
- CString value = pClient->m_hdrlines.GetNextValue(pos);
- key.Replace(_T("-"), _T("_"));
- key.MakeUpper();
- env.AddTail(_T("HTTP_") + key + _T("=") + value);
- }
-
- CString name;
- UINT port;
-
- if (pClient->GetPeerName(name, port)) {
- str.Format(_T("%d"), port);
- env.AddTail(_T("REMOTE_ADDR=")+name);
- env.AddTail(_T("REMOTE_HOST=")+name);
- env.AddTail(_T("REMOTE_PORT=")+str);
- }
-
- if (pClient->GetSockName(name, port)) {
- str.Format(_T("%d"), port);
- env.AddTail(_T("SERVER_NAME=")+name);
- env.AddTail(_T("SERVER_PORT=")+str);
- }
-
- env.AddTail(_T("\0"));
-
- str = Implode(env, '\0');
- envstr = CStringA(str, str.GetLength());
-
- FreeEnvironmentStrings((LPTSTR)lpvEnv);
- }
-
- TCHAR* cmdln = DNew TCHAR[32768];
- _sntprintf_s(cmdln, 32768, 32768, _T("\"%s\" \"%s\""), cgi, path);
-
- if (hChildStdinRd && hChildStdoutWr)
- if (CreateProcess(
- NULL, cmdln, NULL, NULL, TRUE, 0,
- envstr.GetLength() ? (LPVOID)(LPCSTR)envstr : NULL,
- dir, &siStartInfo, &piProcInfo)) {
- DWORD ThreadId;
- CreateThread(NULL, 0, KillCGI, (LPVOID)piProcInfo.hProcess, 0, &ThreadId);
-
- static const int BUFFSIZE = 1024;
- DWORD dwRead, dwWritten = 0;
-
- int i = 0, len = pClient->m_data.GetLength();
- for (; i < len; i += dwWritten)
- if (!WriteFile(hChildStdinWrDup, (LPCSTR)pClient->m_data + i, min(len - i, BUFFSIZE), &dwWritten, NULL)) {
- break;
- }
-
- CloseHandle(hChildStdinWrDup);
- CloseHandle(hChildStdoutWr);
-
- body.Empty();
-
- CStringA buff;
- while (i == len && ReadFile(hChildStdoutRdDup, buff.GetBuffer(BUFFSIZE), BUFFSIZE, &dwRead, NULL) && dwRead) {
- buff.ReleaseBufferSetLength(dwRead);
- body += buff;
- }
-
- int hdrend = body.Find("\r\n\r\n");
- if (hdrend >= 0) {
- hdr = body.Left(hdrend+2);
- body = body.Mid(hdrend+4);
- }
-
- CloseHandle(hChildStdinRd);
- CloseHandle(hChildStdoutRdDup);
-
- CloseHandle(piProcInfo.hProcess);
- CloseHandle(piProcInfo.hThread);
- } else {
- body = _T("CGI Error");
- }
-
- delete [] cmdln;
-
- return true;
+ CString path = pClient->m_path, redir = path;
+ if (!ToLocalPath(path, redir)) {
+ return false;
+ }
+ CString ext = CPath(path).GetExtension().MakeLower();
+ CPath dir(path);
+ dir.RemoveFileSpec();
+
+ CString cgi;
+ if (!m_cgi.Lookup(ext, cgi) || !CPath(cgi).FileExists()) {
+ return false;
+ }
+
+ HANDLE hProcess = GetCurrentProcess();
+ HANDLE hChildStdinRd, hChildStdinWr, hChildStdinWrDup = NULL;
+ HANDLE hChildStdoutRd, hChildStdoutWr, hChildStdoutRdDup = NULL;
+
+ SECURITY_ATTRIBUTES saAttr;
+ ZeroMemory(&saAttr, sizeof(saAttr));
+ saAttr.nLength = sizeof(saAttr);
+ saAttr.bInheritHandle = TRUE;
+
+ if (CreatePipe(&hChildStdoutRd, &hChildStdoutWr, &saAttr, 0)) {
+ BOOL fSuccess = DuplicateHandle(hProcess, hChildStdoutRd, hProcess, &hChildStdoutRdDup, 0, FALSE, DUPLICATE_SAME_ACCESS);
+ UNREFERENCED_PARAMETER(fSuccess);
+ CloseHandle(hChildStdoutRd);
+ }
+
+ if (CreatePipe(&hChildStdinRd, &hChildStdinWr, &saAttr, 0)) {
+ BOOL fSuccess = DuplicateHandle(hProcess, hChildStdinWr, hProcess, &hChildStdinWrDup, 0, FALSE, DUPLICATE_SAME_ACCESS);
+ UNREFERENCED_PARAMETER(fSuccess);
+ CloseHandle(hChildStdinWr);
+ }
+
+ STARTUPINFO siStartInfo;
+ ZeroMemory(&siStartInfo, sizeof(siStartInfo));
+ siStartInfo.cb = sizeof(siStartInfo);
+ siStartInfo.hStdError = hChildStdoutWr;
+ siStartInfo.hStdOutput = hChildStdoutWr;
+ siStartInfo.hStdInput = hChildStdinRd;
+ siStartInfo.dwFlags |= STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
+ siStartInfo.wShowWindow = SW_HIDE;
+
+ PROCESS_INFORMATION piProcInfo;
+ ZeroMemory(&piProcInfo, sizeof(piProcInfo));
+
+ CStringA envstr;
+
+ LPVOID lpvEnv = GetEnvironmentStrings();
+ if (lpvEnv) {
+ CString str;
+
+ CAtlList<CString> env;
+ for (LPTSTR lpszVariable = (LPTSTR)lpvEnv; *lpszVariable; lpszVariable += _tcslen(lpszVariable) + 1)
+ if (lpszVariable != (LPTSTR)lpvEnv) {
+ env.AddTail(lpszVariable);
+ }
+
+ env.AddTail(_T("GATEWAY_INTERFACE=CGI/1.1"));
+ env.AddTail(_T("SERVER_SOFTWARE=Media Player Classic - Home Cinema/1.6.2.x"));
+ env.AddTail(_T("SERVER_PROTOCOL=") + pClient->m_ver);
+ env.AddTail(_T("REQUEST_METHOD=") + pClient->m_cmd);
+ env.AddTail(_T("PATH_INFO=") + redir);
+ env.AddTail(_T("PATH_TRANSLATED=") + path);
+ env.AddTail(_T("SCRIPT_NAME=") + redir);
+ env.AddTail(_T("QUERY_STRING=") + pClient->m_query);
+
+ if (pClient->m_hdrlines.Lookup(_T("content-type"), str)) {
+ env.AddTail(_T("CONTENT_TYPE=") + str);
+ }
+ if (pClient->m_hdrlines.Lookup(_T("content-length"), str)) {
+ env.AddTail(_T("CONTENT_LENGTH=") + str);
+ }
+
+ POSITION pos = pClient->m_hdrlines.GetStartPosition();
+ while (pos) {
+ CString key = pClient->m_hdrlines.GetKeyAt(pos);
+ CString value = pClient->m_hdrlines.GetNextValue(pos);
+ key.Replace(_T("-"), _T("_"));
+ key.MakeUpper();
+ env.AddTail(_T("HTTP_") + key + _T("=") + value);
+ }
+
+ CString name;
+ UINT port;
+
+ if (pClient->GetPeerName(name, port)) {
+ str.Format(_T("%d"), port);
+ env.AddTail(_T("REMOTE_ADDR=") + name);
+ env.AddTail(_T("REMOTE_HOST=") + name);
+ env.AddTail(_T("REMOTE_PORT=") + str);
+ }
+
+ if (pClient->GetSockName(name, port)) {
+ str.Format(_T("%d"), port);
+ env.AddTail(_T("SERVER_NAME=") + name);
+ env.AddTail(_T("SERVER_PORT=") + str);
+ }
+
+ env.AddTail(_T("\0"));
+
+ str = Implode(env, '\0');
+ envstr = CStringA(str, str.GetLength());
+
+ FreeEnvironmentStrings((LPTSTR)lpvEnv);
+ }
+
+ TCHAR* cmdln = DNew TCHAR[32768];
+ _sntprintf_s(cmdln, 32768, 32768, _T("\"%s\" \"%s\""), cgi, path);
+
+ if (hChildStdinRd && hChildStdoutWr)
+ if (CreateProcess(
+ NULL, cmdln, NULL, NULL, TRUE, 0,
+ envstr.GetLength() ? (LPVOID)(LPCSTR)envstr : NULL,
+ dir, &siStartInfo, &piProcInfo)) {
+ DWORD ThreadId;
+ CreateThread(NULL, 0, KillCGI, (LPVOID)piProcInfo.hProcess, 0, &ThreadId);
+
+ static const int BUFFSIZE = 1024;
+ DWORD dwRead, dwWritten = 0;
+
+ int i = 0, len = pClient->m_data.GetLength();
+ for (; i < len; i += dwWritten)
+ if (!WriteFile(hChildStdinWrDup, (LPCSTR)pClient->m_data + i, min(len - i, BUFFSIZE), &dwWritten, NULL)) {
+ break;
+ }
+
+ CloseHandle(hChildStdinWrDup);
+ CloseHandle(hChildStdoutWr);
+
+ body.Empty();
+
+ CStringA buff;
+ while (i == len && ReadFile(hChildStdoutRdDup, buff.GetBuffer(BUFFSIZE), BUFFSIZE, &dwRead, NULL) && dwRead) {
+ buff.ReleaseBufferSetLength(dwRead);
+ body += buff;
+ }
+
+ int hdrend = body.Find("\r\n\r\n");
+ if (hdrend >= 0) {
+ hdr = body.Left(hdrend + 2);
+ body = body.Mid(hdrend + 4);
+ }
+
+ CloseHandle(hChildStdinRd);
+ CloseHandle(hChildStdoutRdDup);
+
+ CloseHandle(piProcInfo.hProcess);
+ CloseHandle(piProcInfo.hThread);
+ } else {
+ body = _T("CGI Error");
+ }
+
+ delete [] cmdln;
+
+ return true;
}
diff --git a/src/mpc-hc/WebServer.h b/src/mpc-hc/WebServer.h
index c0279b78a..86b1e9352 100644
--- a/src/mpc-hc/WebServer.h
+++ b/src/mpc-hc/WebServer.h
@@ -40,35 +40,35 @@ class CMainFrame;
class CWebServer
{
- CMainFrame* m_pMainFrame;
- int m_nPort;
+ CMainFrame* m_pMainFrame;
+ int m_nPort;
- DWORD ThreadProc();
- static DWORD WINAPI StaticThreadProc(LPVOID lpParam);
- DWORD m_ThreadId;
- HANDLE m_hThread;
+ DWORD ThreadProc();
+ static DWORD WINAPI StaticThreadProc(LPVOID lpParam);
+ DWORD m_ThreadId;
+ HANDLE m_hThread;
- CAutoPtrList<CWebClientSocket> m_clients;
+ CAutoPtrList<CWebClientSocket> m_clients;
- typedef bool (CWebClientSocket::*RequestHandler)(CStringA& hdr, CStringA& body, CStringA& mime);
- static CAtlStringMap<RequestHandler> m_internalpages;
- static CAtlStringMap<UINT> m_downloads;
- static CAtlStringMap<CStringA, CStringA> m_mimes;
- CPath m_webroot;
+ typedef bool (CWebClientSocket::*RequestHandler)(CStringA& hdr, CStringA& body, CStringA& mime);
+ static CAtlStringMap<RequestHandler> m_internalpages;
+ static CAtlStringMap<UINT> m_downloads;
+ static CAtlStringMap<CStringA, CStringA> m_mimes;
+ CPath m_webroot;
- CAtlStringMap<> m_cgi;
- bool CallCGI(CWebClientSocket* pClient, CStringA& hdr, CStringA& body, CStringA& mime);
+ CAtlStringMap<> m_cgi;
+ bool CallCGI(CWebClientSocket* pClient, CStringA& hdr, CStringA& body, CStringA& mime);
public:
- CWebServer(CMainFrame* pMainFrame, int nPort = 13579);
- virtual ~CWebServer();
+ CWebServer(CMainFrame* pMainFrame, int nPort = 13579);
+ virtual ~CWebServer();
- static void Deploy(CString dir);
+ static void Deploy(CString dir);
- bool ToLocalPath(CString& path, CString& redir);
- bool LoadPage(UINT resid, CStringA& str, CString path = _T(""));
+ bool ToLocalPath(CString& path, CString& redir);
+ bool LoadPage(UINT resid, CStringA& str, CString path = _T(""));
- void OnAccept(CWebServerSocket* pServer);
- void OnClose(CWebClientSocket* pClient);
- void OnRequest(CWebClientSocket* pClient, CStringA& reshdr, CStringA& resbody);
+ void OnAccept(CWebServerSocket* pServer);
+ void OnClose(CWebClientSocket* pClient);
+ void OnRequest(CWebClientSocket* pClient, CStringA& reshdr, CStringA& resbody);
};
diff --git a/src/mpc-hc/WebServerSocket.cpp b/src/mpc-hc/WebServerSocket.cpp
index 6569c4a82..968d5c4e3 100644
--- a/src/mpc-hc/WebServerSocket.cpp
+++ b/src/mpc-hc/WebServerSocket.cpp
@@ -27,10 +27,10 @@
CWebServerSocket::CWebServerSocket(CWebServer* pWebServer, int port)
- : m_pWebServer(pWebServer)
+ : m_pWebServer(pWebServer)
{
- Create(port);
- Listen();
+ Create(port);
+ Listen();
}
CWebServerSocket::~CWebServerSocket()
@@ -39,9 +39,9 @@ CWebServerSocket::~CWebServerSocket()
void CWebServerSocket::OnAccept(int nErrorCode)
{
- if (nErrorCode == 0 && m_pWebServer) {
- m_pWebServer->OnAccept(this);
- }
+ if (nErrorCode == 0 && m_pWebServer) {
+ m_pWebServer->OnAccept(this);
+ }
- __super::OnAccept(nErrorCode);
+ __super::OnAccept(nErrorCode);
}
diff --git a/src/mpc-hc/WebServerSocket.h b/src/mpc-hc/WebServerSocket.h
index 736506301..b2f173b86 100644
--- a/src/mpc-hc/WebServerSocket.h
+++ b/src/mpc-hc/WebServerSocket.h
@@ -28,12 +28,12 @@ class CWebServer;
class CWebServerSocket : public CAsyncSocket
{
- CWebServer* m_pWebServer;
+ CWebServer* m_pWebServer;
protected:
- void OnAccept(int nErrorCode);
+ void OnAccept(int nErrorCode);
public:
- CWebServerSocket(CWebServer* pWebServer, int port = 13579);
- virtual ~CWebServerSocket();
+ CWebServerSocket(CWebServer* pWebServer, int port = 13579);
+ virtual ~CWebServerSocket();
};
diff --git a/src/mpc-hc/WinHotkeyCtrl.cpp b/src/mpc-hc/WinHotkeyCtrl.cpp
index addeaf22e..76f2f9ace 100644
--- a/src/mpc-hc/WinHotkeyCtrl.cpp
+++ b/src/mpc-hc/WinHotkeyCtrl.cpp
@@ -35,12 +35,12 @@ CWinHotkeyCtrl* CWinHotkeyCtrl::sm_pwhcFocus = NULL;
IMPLEMENT_DYNAMIC(CWinHotkeyCtrl, CEdit)
CWinHotkeyCtrl::CWinHotkeyCtrl():
- m_vkCode(0),
- m_fModSet(0),
- m_fModRel(0),
- m_vkCode_def(0),
- m_fModSet_def(0),
- m_fIsPressed(FALSE)
+ m_vkCode(0),
+ m_fModSet(0),
+ m_fModRel(0),
+ m_vkCode_def(0),
+ m_fModSet_def(0),
+ m_fIsPressed(FALSE)
{
}
@@ -49,178 +49,178 @@ CWinHotkeyCtrl::~CWinHotkeyCtrl()
}
BEGIN_MESSAGE_MAP(CWinHotkeyCtrl, CEditWithButton)
- ON_MESSAGE(WM_KEY, OnKey)
- ON_WM_CHAR()
- ON_WM_SETCURSOR()
- ON_WM_SETFOCUS()
- ON_WM_KILLFOCUS()
- ON_WM_CONTEXTMENU()
- ON_WM_DESTROY()
- ON_MESSAGE(EDIT_BUTTON_LEFTCLICKED, OnLeftClick)
+ ON_MESSAGE(WM_KEY, OnKey)
+ ON_WM_CHAR()
+ ON_WM_SETCURSOR()
+ ON_WM_SETFOCUS()
+ ON_WM_KILLFOCUS()
+ ON_WM_CONTEXTMENU()
+ ON_WM_DESTROY()
+ ON_MESSAGE(EDIT_BUTTON_LEFTCLICKED, OnLeftClick)
END_MESSAGE_MAP()
// CWinHotkeyCtrl
void CWinHotkeyCtrl::PreSubclassWindow()
{
- CEditWithButton::PreSubclassWindow();
- UpdateText();
+ CEditWithButton::PreSubclassWindow();
+ UpdateText();
}
LRESULT CALLBACK CWinHotkeyCtrl::LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
- LRESULT lResult = 1;
+ LRESULT lResult = 1;
- if (nCode == HC_ACTION && (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN ||
- wParam == WM_KEYUP || wParam == WM_SYSKEYUP) && sm_pwhcFocus) {
- sm_pwhcFocus->PostMessage(WM_KEY, ((PKBDLLHOOKSTRUCT)lParam)->vkCode, (wParam & 1));
- }
- return lResult;
+ if (nCode == HC_ACTION && (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN ||
+ wParam == WM_KEYUP || wParam == WM_SYSKEYUP) && sm_pwhcFocus) {
+ sm_pwhcFocus->PostMessage(WM_KEY, ((PKBDLLHOOKSTRUCT)lParam)->vkCode, (wParam & 1));
+ }
+ return lResult;
}
BOOL CWinHotkeyCtrl::InstallKbHook()
{
- if (sm_pwhcFocus && sm_hhookKb) {
- sm_pwhcFocus->UninstallKbHook();
- }
- sm_pwhcFocus = this;
+ if (sm_pwhcFocus && sm_hhookKb) {
+ sm_pwhcFocus->UninstallKbHook();
+ }
+ sm_pwhcFocus = this;
- sm_hhookKb = ::SetWindowsHookEx(WH_KEYBOARD_LL, (HOOKPROC)LowLevelKeyboardProc, GetModuleHandle(NULL), NULL);
+ sm_hhookKb = ::SetWindowsHookEx(WH_KEYBOARD_LL, (HOOKPROC)LowLevelKeyboardProc, GetModuleHandle(NULL), NULL);
- return (sm_hhookKb != NULL);
+ return (sm_hhookKb != NULL);
}
BOOL CWinHotkeyCtrl::UninstallKbHook()
{
- BOOL fOk = FALSE;
- if (sm_hhookKb) {
- fOk = ::UnhookWindowsHookEx(sm_hhookKb);
- sm_hhookKb = NULL;
- }
- sm_pwhcFocus = NULL;
- return fOk;
+ BOOL fOk = FALSE;
+ if (sm_hhookKb) {
+ fOk = ::UnhookWindowsHookEx(sm_hhookKb);
+ sm_hhookKb = NULL;
+ }
+ sm_pwhcFocus = NULL;
+ return fOk;
}
void CWinHotkeyCtrl::UpdateText()
{
- CString sText;
- HotkeyToString(m_vkCode, m_fModSet, sText);
- SetWindowText((LPCTSTR)sText);
- SetSel(0x8fffffff, 0x8fffffff, FALSE);
+ CString sText;
+ HotkeyToString(m_vkCode, m_fModSet, sText);
+ SetWindowText((LPCTSTR)sText);
+ SetSel(0x8fffffff, 0x8fffffff, FALSE);
}
DWORD CWinHotkeyCtrl::GetWinHotkey()
{
- return MAKEWORD(m_vkCode, m_fModSet);
+ return MAKEWORD(m_vkCode, m_fModSet);
}
BOOL CWinHotkeyCtrl::GetWinHotkey(UINT* pvkCode, UINT* pfModifiers)
{
- *pvkCode = m_vkCode;
- *pfModifiers = m_fModSet;
- return (m_vkCode != 0);
+ *pvkCode = m_vkCode;
+ *pfModifiers = m_fModSet;
+ return (m_vkCode != 0);
}
void CWinHotkeyCtrl::SetWinHotkey(DWORD dwHk)
{
- SetWinHotkey(LOBYTE(LOWORD(dwHk)), HIBYTE(LOWORD(dwHk)));
+ SetWinHotkey(LOBYTE(LOWORD(dwHk)), HIBYTE(LOWORD(dwHk)));
}
void CWinHotkeyCtrl::SetWinHotkey(UINT vkCode, UINT fModifiers)
{
- m_vkCode = m_vkCode_def = vkCode;
- m_fModSet = m_fModSet_def = m_fModRel = fModifiers;
- m_fIsPressed = FALSE;
+ m_vkCode = m_vkCode_def = vkCode;
+ m_fModSet = m_fModSet_def = m_fModRel = fModifiers;
+ m_fIsPressed = FALSE;
- UpdateText();
+ UpdateText();
}
LRESULT CWinHotkeyCtrl::OnKey(WPARAM wParam, LPARAM lParam)
{
- DWORD fMod = 0;
- BOOL fRedraw = TRUE;
-
- switch (wParam) {
- case VK_CONTROL:
- case VK_LCONTROL:
- case VK_RCONTROL:
- fMod = MOD_CONTROL;
- break;
- case VK_MENU:
- case VK_LMENU:
- case VK_RMENU:
- fMod = MOD_ALT;
- break;
- case VK_SHIFT:
- case VK_LSHIFT:
- case VK_RSHIFT:
- fMod = MOD_SHIFT;
- break;
- }
-
- if (fMod) { // modifier
- if (!lParam) { // press
- if (!m_fIsPressed && m_vkCode) {
- m_fModSet = m_fModRel = 0;
- m_vkCode = 0;
- }
- m_fModRel &= ~fMod;
- } else if (m_fModSet & fMod) { // release
- m_fModRel |= fMod;
- }
-
- if (m_fIsPressed || !m_vkCode) {
- if (!lParam) { // press
- if (!(m_fModSet & fMod)) { // new modifier
- m_fModSet |= fMod;
- } else {
- fRedraw = FALSE;
- }
- } else {
- m_fModSet &= ~fMod;
- }
- }
- } else { // another key
- if (wParam == VK_DELETE && m_fModSet == (MOD_CONTROL | MOD_ALT) // skip "Ctrl+Alt+Del"
- || wParam == VK_LWIN || wParam == VK_RWIN // skip "Win"
- || wParam == VK_SNAPSHOT // skip "PrintScreen"
- || wParam == VK_APPS // skip "Menu key"
- || wParam == VK_ESCAPE && (m_fModSet == MOD_CONTROL || m_fModSet == MOD_ALT) // skip "Ctrl+Esc", "Alt+Esc"
- || wParam == VK_TAB && m_fModSet == MOD_ALT) { // skip "Alt+Tab"
- m_fModSet = m_fModRel = 0;
- m_vkCode = 0;
- m_fIsPressed = FALSE;
- } else if (wParam == m_vkCode && lParam) {
- m_fIsPressed = FALSE;
- fRedraw = FALSE;
- } else {
- if (!m_fIsPressed && !lParam) { // pressed a another key
- if (m_fModRel & m_fModSet) {
- m_fModSet = m_fModRel = 0;
- }
- m_vkCode = (UINT)wParam;
- m_fIsPressed = TRUE;
- }
- }
- }
- if (fRedraw) {
- UpdateText();
- }
-
- return 0L;
+ DWORD fMod = 0;
+ BOOL fRedraw = TRUE;
+
+ switch (wParam) {
+ case VK_CONTROL:
+ case VK_LCONTROL:
+ case VK_RCONTROL:
+ fMod = MOD_CONTROL;
+ break;
+ case VK_MENU:
+ case VK_LMENU:
+ case VK_RMENU:
+ fMod = MOD_ALT;
+ break;
+ case VK_SHIFT:
+ case VK_LSHIFT:
+ case VK_RSHIFT:
+ fMod = MOD_SHIFT;
+ break;
+ }
+
+ if (fMod) { // modifier
+ if (!lParam) { // press
+ if (!m_fIsPressed && m_vkCode) {
+ m_fModSet = m_fModRel = 0;
+ m_vkCode = 0;
+ }
+ m_fModRel &= ~fMod;
+ } else if (m_fModSet & fMod) { // release
+ m_fModRel |= fMod;
+ }
+
+ if (m_fIsPressed || !m_vkCode) {
+ if (!lParam) { // press
+ if (!(m_fModSet & fMod)) { // new modifier
+ m_fModSet |= fMod;
+ } else {
+ fRedraw = FALSE;
+ }
+ } else {
+ m_fModSet &= ~fMod;
+ }
+ }
+ } else { // another key
+ if (wParam == VK_DELETE && m_fModSet == (MOD_CONTROL | MOD_ALT) // skip "Ctrl+Alt+Del"
+ || wParam == VK_LWIN || wParam == VK_RWIN // skip "Win"
+ || wParam == VK_SNAPSHOT // skip "PrintScreen"
+ || wParam == VK_APPS // skip "Menu key"
+ || wParam == VK_ESCAPE && (m_fModSet == MOD_CONTROL || m_fModSet == MOD_ALT) // skip "Ctrl+Esc", "Alt+Esc"
+ || wParam == VK_TAB && m_fModSet == MOD_ALT) { // skip "Alt+Tab"
+ m_fModSet = m_fModRel = 0;
+ m_vkCode = 0;
+ m_fIsPressed = FALSE;
+ } else if (wParam == m_vkCode && lParam) {
+ m_fIsPressed = FALSE;
+ fRedraw = FALSE;
+ } else {
+ if (!m_fIsPressed && !lParam) { // pressed a another key
+ if (m_fModRel & m_fModSet) {
+ m_fModSet = m_fModRel = 0;
+ }
+ m_vkCode = (UINT)wParam;
+ m_fIsPressed = TRUE;
+ }
+ }
+ }
+ if (fRedraw) {
+ UpdateText();
+ }
+
+ return 0L;
}
LRESULT CWinHotkeyCtrl::OnLeftClick(WPARAM wParam, LPARAM lParam)
{
- CRect r;
- CPoint pt;
- CEditWithButton::GetWindowRect(r);
- CRect rectButton = GetButtonRect(r);
- pt = rectButton.BottomRight();
- pt.x = pt.x-(rectButton.Width());
- OnContextMenu(this, pt);
- return 0;
+ CRect r;
+ CPoint pt;
+ CEditWithButton::GetWindowRect(r);
+ CRect rectButton = GetButtonRect(r);
+ pt = rectButton.BottomRight();
+ pt.x = pt.x - (rectButton.Width());
+ OnContextMenu(this, pt);
+ return 0;
}
// CWinHotkeyCtrl message handlers
@@ -231,65 +231,65 @@ void CWinHotkeyCtrl::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
BOOL CWinHotkeyCtrl::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
- return FALSE;
+ return FALSE;
}
void CWinHotkeyCtrl::OnSetFocus(CWnd* pOldWnd)
{
- InstallKbHook();
- CEditWithButton::OnSetFocus(pOldWnd);
+ InstallKbHook();
+ CEditWithButton::OnSetFocus(pOldWnd);
}
void CWinHotkeyCtrl::OnKillFocus(CWnd* pNewWnd)
{
- UninstallKbHook();
- CEditWithButton::OnKillFocus(pNewWnd);
+ UninstallKbHook();
+ CEditWithButton::OnKillFocus(pNewWnd);
}
void CWinHotkeyCtrl::OnContextMenu(CWnd*, CPoint pt)
{
- HMENU hmenu = CreatePopupMenu();
- UINT cod = 0, mod = 0;
- AppendMenu(hmenu, MF_STRING, 1, ResStr(IDS_APPLY));
- AppendMenu(hmenu, MF_STRING, 2, ResStr(IDS_CLEAR));
- AppendMenu(hmenu, MF_STRING, 3, ResStr(IDS_CANCEL));
-
- UINT uMenuID = TrackPopupMenu(hmenu,
- TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_VERPOSANIMATION | TPM_NONOTIFY | TPM_RETURNCMD,
- pt.x, pt.y, 0, GetSafeHwnd(), NULL);
-
- if (uMenuID) {
- switch (uMenuID) {
- case 1:
- GetWinHotkey(&cod, &mod);
- if (cod == 0 || m_vkCode == 0) {
- mod = m_fModSet = m_fModRel = 0;
- }
- SetWinHotkey(cod, mod);
- m_fIsPressed = FALSE;
- break;
- case 2:
- m_fModSet = m_fModRel = 0;
- m_vkCode = 0;
- m_fIsPressed = FALSE;
- break;
- case 3:
- m_fModSet = m_fModRel = m_fModSet_def;
- m_vkCode = m_vkCode_def;
- m_fIsPressed = FALSE;
- break;
- }
- UpdateText();
- GetParent() ->SetFocus();
- }
-
- DestroyMenu(hmenu);
+ HMENU hmenu = CreatePopupMenu();
+ UINT cod = 0, mod = 0;
+ AppendMenu(hmenu, MF_STRING, 1, ResStr(IDS_APPLY));
+ AppendMenu(hmenu, MF_STRING, 2, ResStr(IDS_CLEAR));
+ AppendMenu(hmenu, MF_STRING, 3, ResStr(IDS_CANCEL));
+
+ UINT uMenuID = TrackPopupMenu(hmenu,
+ TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_VERPOSANIMATION | TPM_NONOTIFY | TPM_RETURNCMD,
+ pt.x, pt.y, 0, GetSafeHwnd(), NULL);
+
+ if (uMenuID) {
+ switch (uMenuID) {
+ case 1:
+ GetWinHotkey(&cod, &mod);
+ if (cod == 0 || m_vkCode == 0) {
+ mod = m_fModSet = m_fModRel = 0;
+ }
+ SetWinHotkey(cod, mod);
+ m_fIsPressed = FALSE;
+ break;
+ case 2:
+ m_fModSet = m_fModRel = 0;
+ m_vkCode = 0;
+ m_fIsPressed = FALSE;
+ break;
+ case 3:
+ m_fModSet = m_fModRel = m_fModSet_def;
+ m_vkCode = m_vkCode_def;
+ m_fIsPressed = FALSE;
+ break;
+ }
+ UpdateText();
+ GetParent() ->SetFocus();
+ }
+
+ DestroyMenu(hmenu);
}
void CWinHotkeyCtrl::OnDestroy()
{
- if (sm_pwhcFocus == this) {
- sm_pwhcFocus->UninstallKbHook();
- }
- CEditWithButton::OnDestroy();
+ if (sm_pwhcFocus == this) {
+ sm_pwhcFocus->UninstallKbHook();
+ }
+ CEditWithButton::OnDestroy();
}
diff --git a/src/mpc-hc/WinHotkeyCtrl.h b/src/mpc-hc/WinHotkeyCtrl.h
index f81b65405..ddf4d871c 100644
--- a/src/mpc-hc/WinHotkeyCtrl.h
+++ b/src/mpc-hc/WinHotkeyCtrl.h
@@ -28,44 +28,44 @@
class CWinHotkeyCtrl : public CEditWithButton
{
- DECLARE_DYNAMIC(CWinHotkeyCtrl)
+ DECLARE_DYNAMIC(CWinHotkeyCtrl)
public:
- CWinHotkeyCtrl();
- virtual ~CWinHotkeyCtrl();
+ CWinHotkeyCtrl();
+ virtual ~CWinHotkeyCtrl();
- void UpdateText();
- DWORD GetWinHotkey();
- BOOL GetWinHotkey(UINT* pvkCode, UINT* pfModifiers);
- void SetWinHotkey(DWORD dwHk);
- void SetWinHotkey(UINT vkCode, UINT fModifiers);
+ void UpdateText();
+ DWORD GetWinHotkey();
+ BOOL GetWinHotkey(UINT* pvkCode, UINT* pfModifiers);
+ void SetWinHotkey(DWORD dwHk);
+ void SetWinHotkey(UINT vkCode, UINT fModifiers);
private:
- static HHOOK sm_hhookKb;
- static CWinHotkeyCtrl* sm_pwhcFocus;
+ static HHOOK sm_hhookKb;
+ static CWinHotkeyCtrl* sm_pwhcFocus;
- UINT m_vkCode, m_vkCode_def;
- DWORD m_fModSet, m_fModRel, m_fModSet_def;
- BOOL m_fIsPressed;
+ UINT m_vkCode, m_vkCode_def;
+ DWORD m_fModSet, m_fModRel, m_fModSet_def;
+ BOOL m_fIsPressed;
private:
- BOOL InstallKbHook();
- BOOL UninstallKbHook();
+ BOOL InstallKbHook();
+ BOOL UninstallKbHook();
- static LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);
+ static LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);
- afx_msg LRESULT OnKey(WPARAM wParam, LPARAM lParam);
+ afx_msg LRESULT OnKey(WPARAM wParam, LPARAM lParam);
protected:
- DECLARE_MESSAGE_MAP()
+ DECLARE_MESSAGE_MAP()
public:
- afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
- afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
- afx_msg void OnSetFocus(CWnd* pOldWnd);
- afx_msg void OnKillFocus(CWnd* pNewWnd);
- afx_msg void OnContextMenu(CWnd*, CPoint pt);
- afx_msg void OnDestroy();
- afx_msg LRESULT OnLeftClick(WPARAM wParam, LPARAM lParam);
+ afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
+ afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
+ afx_msg void OnSetFocus(CWnd* pOldWnd);
+ afx_msg void OnKillFocus(CWnd* pNewWnd);
+ afx_msg void OnContextMenu(CWnd*, CPoint pt);
+ afx_msg void OnDestroy();
+ afx_msg LRESULT OnLeftClick(WPARAM wParam, LPARAM lParam);
protected:
- virtual void PreSubclassWindow();
+ virtual void PreSubclassWindow();
};
diff --git a/src/mpc-hc/mpciconlib/mpciconlib.cpp b/src/mpc-hc/mpciconlib/mpciconlib.cpp
index bd4190b1e..9f6edab0e 100644
--- a/src/mpc-hc/mpciconlib/mpciconlib.cpp
+++ b/src/mpc-hc/mpciconlib/mpciconlib.cpp
@@ -26,236 +26,236 @@
int main()
{
- return 0;
+ return 0;
}
int get_icon_index(CString ext)
{
- int iconindex = -1;// IDI_NONE
+ int iconindex = -1;// IDI_NONE
- if (ext.CompareNoCase(_T(".3g2")) == 0) {
- iconindex = IDI_MOV_ICON;
- } else if (ext.CompareNoCase(_T(".3gp")) == 0) {
- iconindex = IDI_MP4_ICON;
- } else if (ext.CompareNoCase(_T(".3gp2")) == 0) {
- iconindex = IDI_MOV_ICON;
- } else if (ext.CompareNoCase(_T(".3gpp")) == 0) {
- iconindex = IDI_MP4_ICON;
- } else if (ext.CompareNoCase(_T(".aac")) == 0) {
- iconindex = IDI_AAC_ICON;
- } else if (ext.CompareNoCase(_T(".ac3")) == 0) {
- iconindex = IDI_AC3_ICON;
- } else if (ext.CompareNoCase(_T(".aif")) == 0) {
- iconindex = IDI_AIFF_ICON;
- } else if (ext.CompareNoCase(_T(".aifc")) == 0) {
- iconindex = IDI_AIFF_ICON;
- } else if (ext.CompareNoCase(_T(".aiff")) == 0) {
- iconindex = IDI_AIFF_ICON;
- } else if (ext.CompareNoCase(_T(".alac")) == 0) {
- iconindex = IDI_ALAC_ICON;
- } else if (ext.CompareNoCase(_T(".amr")) == 0) {
- iconindex = IDI_AMR_ICON;
- } else if (ext.CompareNoCase(_T(".amv")) == 0) {
- iconindex = IDI_OTHER_ICON;
- } else if (ext.CompareNoCase(_T(".ape")) == 0) {
- iconindex = IDI_APE_ICON;
- } else if (ext.CompareNoCase(_T(".apl")) == 0) {
- iconindex = IDI_APE_ICON;
- } else if (ext.CompareNoCase(_T(".asf")) == 0) {
- iconindex = IDI_WMV_ICON;
- } else if (ext.CompareNoCase(_T(".asx")) == 0) {
- iconindex = IDI_PLAYLIST_ICON;
- } else if (ext.CompareNoCase(_T(".au")) == 0) {
- iconindex = IDI_AU_ICON;
- } else if (ext.CompareNoCase(_T(".avi")) == 0) {
- iconindex = IDI_AVI_ICON;
- } else if (ext.CompareNoCase(_T(".bdmv")) == 0) {
- iconindex = IDI_PLAYLIST_ICON;
- } else if (ext.CompareNoCase(_T(".bik")) == 0) {
- iconindex = IDI_BINK_ICON;
- } else if (ext.CompareNoCase(_T(".cda")) == 0) {
- iconindex = IDI_CDA_ICON;
- } else if (ext.CompareNoCase(_T(".d2v")) == 0) {
- iconindex = IDI_D2V_ICON;
- } else if (ext.CompareNoCase(_T(".dat")) == 0) {
- iconindex = IDI_DAT_ICON;
- } else if (ext.CompareNoCase(_T(".divx")) == 0) {
- iconindex = IDI_OTHER_ICON;
- } else if (ext.CompareNoCase(_T(".dsa")) == 0) {
- iconindex = IDI_DSM_ICON;
- } else if (ext.CompareNoCase(_T(".dsm")) == 0) {
- iconindex = IDI_DSM_ICON;
- } else if (ext.CompareNoCase(_T(".dss")) == 0) {
- iconindex = IDI_DSM_ICON;
- } else if (ext.CompareNoCase(_T(".dsv")) == 0) {
- iconindex = IDI_DSM_ICON;
- } else if (ext.CompareNoCase(_T(".dts")) == 0) {
- iconindex = IDI_DTS_ICON;
- } else if (ext.CompareNoCase(_T(".evo")) == 0) {
- iconindex = IDI_MPEG_ICON;
- } else if (ext.CompareNoCase(_T(".f4v")) == 0) {
- iconindex = IDI_FLV_ICON;
- } else if (ext.CompareNoCase(_T(".flac")) == 0) {
- iconindex = IDI_FLAC_ICON;
- } else if (ext.CompareNoCase(_T(".flc")) == 0) {
- iconindex = IDI_FLIC_ICON;
- } else if (ext.CompareNoCase(_T(".fli")) == 0) {
- iconindex = IDI_FLIC_ICON;
- } else if (ext.CompareNoCase(_T(".flic")) == 0) {
- iconindex = IDI_FLIC_ICON;
- } else if (ext.CompareNoCase(_T(".flv")) == 0) {
- iconindex = IDI_FLV_ICON;
- } else if (ext.CompareNoCase(_T(".hdmov")) == 0) {
- iconindex = IDI_MP4_ICON;
- } else if (ext.CompareNoCase(_T(".iflv")) == 0) {
- iconindex = IDI_FLV_ICON;
- } else if (ext.CompareNoCase(_T(".ifo")) == 0) {
- iconindex = IDI_IFO_ICON;
- } else if (ext.CompareNoCase(_T(".ivf")) == 0) {
- iconindex = IDI_IVF_ICON;
- } else if (ext.CompareNoCase(_T(".m1a")) == 0) {
- iconindex = IDI_MPA_ICON;
- } else if (ext.CompareNoCase(_T(".m1v")) == 0) {
- iconindex = IDI_MPEG_ICON;
- } else if (ext.CompareNoCase(_T(".m2a")) == 0) {
- iconindex = IDI_MPA_ICON;
- } else if (ext.CompareNoCase(_T(".m2p")) == 0) {
- iconindex = IDI_MPEG_ICON;
- } else if (ext.CompareNoCase(_T(".m2t")) == 0) {
- iconindex = IDI_TS_ICON;
- } else if (ext.CompareNoCase(_T(".m2ts")) == 0) {
- iconindex = IDI_TS_ICON;
- } else if (ext.CompareNoCase(_T(".m2v")) == 0) {
- iconindex = IDI_MPEG_ICON;
- } else if (ext.CompareNoCase(_T(".m3u")) == 0) {
- iconindex = IDI_PLAYLIST_ICON;
- } else if (ext.CompareNoCase(_T(".m3u8")) == 0) {
- iconindex = IDI_PLAYLIST_ICON;
- } else if (ext.CompareNoCase(_T(".m4a")) == 0) {
- iconindex = IDI_AAC_ICON;
- } else if (ext.CompareNoCase(_T(".m4b")) == 0) {
- iconindex = IDI_AAC_ICON;
- } else if (ext.CompareNoCase(_T(".m4v")) == 0) {
- iconindex = IDI_MP4_ICON;
- } else if (ext.CompareNoCase(_T(".mid")) == 0) {
- iconindex = IDI_MIDI_ICON;
- } else if (ext.CompareNoCase(_T(".midi")) == 0) {
- iconindex = IDI_MIDI_ICON;
- } else if (ext.CompareNoCase(_T(".mka")) == 0) {
- iconindex = IDI_MKA_ICON;
- } else if (ext.CompareNoCase(_T(".mkv")) == 0) {
- iconindex = IDI_MKV_ICON;
- } else if (ext.CompareNoCase(_T(".mov")) == 0) {
- iconindex = IDI_MOV_ICON;
- } else if (ext.CompareNoCase(_T(".mp2")) == 0) {
- iconindex = IDI_MPA_ICON;
- } else if (ext.CompareNoCase(_T(".mp2v")) == 0) {
- iconindex = IDI_MPEG_ICON;
- } else if (ext.CompareNoCase(_T(".mp3")) == 0) {
- iconindex = IDI_MP3_ICON;
- } else if (ext.CompareNoCase(_T(".mp4")) == 0) {
- iconindex = IDI_MP4_ICON;
- } else if (ext.CompareNoCase(_T(".mp4v")) == 0) {
- iconindex = IDI_MP4_ICON;
- } else if (ext.CompareNoCase(_T(".mpa")) == 0) {
- iconindex = IDI_MPA_ICON;
- } else if (ext.CompareNoCase(_T(".mpc")) == 0) {
- iconindex = IDI_MPC_ICON;
- } else if (ext.CompareNoCase(_T(".mpcpl")) == 0) {
- iconindex = IDI_PLAYLIST_ICON;
- } else if (ext.CompareNoCase(_T(".mpe")) == 0) {
- iconindex = IDI_MPEG_ICON;
- } else if (ext.CompareNoCase(_T(".mpeg")) == 0) {
- iconindex = IDI_MPEG_ICON;
- } else if (ext.CompareNoCase(_T(".mpg")) == 0) {
- iconindex = IDI_MPEG_ICON;
- } else if (ext.CompareNoCase(_T(".mpls")) == 0) {
- iconindex = IDI_PLAYLIST_ICON;
- } else if (ext.CompareNoCase(_T(".mpv2")) == 0) {
- iconindex = IDI_MPEG_ICON;
- } else if (ext.CompareNoCase(_T(".mpv4")) == 0) {
- iconindex = IDI_MP4_ICON;
- } else if (ext.CompareNoCase(_T(".mts")) == 0) {
- iconindex = IDI_TS_ICON;
- } else if (ext.CompareNoCase(_T(".ofr")) == 0) {
- iconindex = IDI_OFR_ICON;
- } else if (ext.CompareNoCase(_T(".ofs")) == 0) {
- iconindex = IDI_OFR_ICON;
- } else if (ext.CompareNoCase(_T(".oga")) == 0) {
- iconindex = IDI_OGG_ICON;
- } else if (ext.CompareNoCase(_T(".ogg")) == 0) {
- iconindex = IDI_OGG_ICON;
- } else if (ext.CompareNoCase(_T(".ogm")) == 0) {
- iconindex = IDI_OGM_ICON;
- } else if (ext.CompareNoCase(_T(".ogv")) == 0) {
- iconindex = IDI_OGM_ICON;
- } else if (ext.CompareNoCase(_T(".pls")) == 0) {
- iconindex = IDI_PLAYLIST_ICON;
- } else if (ext.CompareNoCase(_T(".pva")) == 0) {
- iconindex = IDI_MPEG_ICON;
- } else if (ext.CompareNoCase(_T(".ra")) == 0) {
- iconindex = IDI_RA_ICON;
- } else if (ext.CompareNoCase(_T(".ram")) == 0) {
- iconindex = IDI_RM_ICON;
- } else if (ext.CompareNoCase(_T(".rm")) == 0) {
- iconindex = IDI_RM_ICON;
- } else if (ext.CompareNoCase(_T(".rmi")) == 0) {
- iconindex = IDI_MIDI_ICON;
- } else if (ext.CompareNoCase(_T(".rmm")) == 0) {
- iconindex = IDI_RM_ICON;
- } else if (ext.CompareNoCase(_T(".rmvb")) == 0) {
- iconindex = IDI_OTHER_ICON;
- } else if (ext.CompareNoCase(_T(".rp")) == 0) {
- iconindex = IDI_RT_ICON;
- } else if (ext.CompareNoCase(_T(".rpm")) == 0) {
- iconindex = IDI_RM_ICON;
- } else if (ext.CompareNoCase(_T(".rt")) == 0) {
- iconindex = IDI_RT_ICON;
- } else if (ext.CompareNoCase(_T(".smi")) == 0) {
- iconindex = IDI_RT_ICON;
- } else if (ext.CompareNoCase(_T(".smil")) == 0) {
- iconindex = IDI_RT_ICON;
- } else if (ext.CompareNoCase(_T(".smk")) == 0) {
- iconindex = IDI_SMK_ICON;
- } else if (ext.CompareNoCase(_T(".snd")) == 0) {
- iconindex = IDI_AU_ICON;
- } else if (ext.CompareNoCase(_T(".swf")) == 0) {
- iconindex = IDI_SWF_ICON;
- } else if (ext.CompareNoCase(_T(".tp")) == 0) {
- iconindex = IDI_TS_ICON;
- } else if (ext.CompareNoCase(_T(".trp")) == 0) {
- iconindex = IDI_TS_ICON;
- } else if (ext.CompareNoCase(_T(".ts")) == 0) {
- iconindex = IDI_TS_ICON;
- } else if (ext.CompareNoCase(_T(".rec")) == 0) {
- iconindex = IDI_TS_ICON;
- } else if (ext.CompareNoCase(_T(".tak")) == 0) {
- iconindex = IDI_OTHER_ICON;
- } else if (ext.CompareNoCase(_T(".tta")) == 0) {
- iconindex = IDI_TTA_ICON;
- } else if (ext.CompareNoCase(_T(".vob")) == 0) {
- iconindex = IDI_VOB_ICON;
- } else if (ext.CompareNoCase(_T(".wav")) == 0) {
- iconindex = IDI_WAV_ICON;
- } else if (ext.CompareNoCase(_T(".wax")) == 0) {
- iconindex = IDI_PLAYLIST_ICON;
- } else if (ext.CompareNoCase(_T(".webm")) == 0) {
- iconindex = IDI_WEBM_ICON;
- } else if (ext.CompareNoCase(_T(".wm")) == 0) {
- iconindex = IDI_WMV_ICON;
- } else if (ext.CompareNoCase(_T(".wma")) == 0) {
- iconindex = IDI_WMA_ICON;
- } else if (ext.CompareNoCase(_T(".wmp")) == 0) {
- iconindex = IDI_WMV_ICON;
- } else if (ext.CompareNoCase(_T(".wmv")) == 0) {
- iconindex = IDI_WMV_ICON;
- } else if (ext.CompareNoCase(_T(".wmx")) == 0) {
- iconindex = IDI_PLAYLIST_ICON;
- } else if (ext.CompareNoCase(_T(".wv")) == 0) {
- iconindex = IDI_WV_ICON;
- } else if (ext.CompareNoCase(_T(".wvx")) == 0) {
- iconindex = IDI_PLAYLIST_ICON;
- }
+ if (ext.CompareNoCase(_T(".3g2")) == 0) {
+ iconindex = IDI_MOV_ICON;
+ } else if (ext.CompareNoCase(_T(".3gp")) == 0) {
+ iconindex = IDI_MP4_ICON;
+ } else if (ext.CompareNoCase(_T(".3gp2")) == 0) {
+ iconindex = IDI_MOV_ICON;
+ } else if (ext.CompareNoCase(_T(".3gpp")) == 0) {
+ iconindex = IDI_MP4_ICON;
+ } else if (ext.CompareNoCase(_T(".aac")) == 0) {
+ iconindex = IDI_AAC_ICON;
+ } else if (ext.CompareNoCase(_T(".ac3")) == 0) {
+ iconindex = IDI_AC3_ICON;
+ } else if (ext.CompareNoCase(_T(".aif")) == 0) {
+ iconindex = IDI_AIFF_ICON;
+ } else if (ext.CompareNoCase(_T(".aifc")) == 0) {
+ iconindex = IDI_AIFF_ICON;
+ } else if (ext.CompareNoCase(_T(".aiff")) == 0) {
+ iconindex = IDI_AIFF_ICON;
+ } else if (ext.CompareNoCase(_T(".alac")) == 0) {
+ iconindex = IDI_ALAC_ICON;
+ } else if (ext.CompareNoCase(_T(".amr")) == 0) {
+ iconindex = IDI_AMR_ICON;
+ } else if (ext.CompareNoCase(_T(".amv")) == 0) {
+ iconindex = IDI_OTHER_ICON;
+ } else if (ext.CompareNoCase(_T(".ape")) == 0) {
+ iconindex = IDI_APE_ICON;
+ } else if (ext.CompareNoCase(_T(".apl")) == 0) {
+ iconindex = IDI_APE_ICON;
+ } else if (ext.CompareNoCase(_T(".asf")) == 0) {
+ iconindex = IDI_WMV_ICON;
+ } else if (ext.CompareNoCase(_T(".asx")) == 0) {
+ iconindex = IDI_PLAYLIST_ICON;
+ } else if (ext.CompareNoCase(_T(".au")) == 0) {
+ iconindex = IDI_AU_ICON;
+ } else if (ext.CompareNoCase(_T(".avi")) == 0) {
+ iconindex = IDI_AVI_ICON;
+ } else if (ext.CompareNoCase(_T(".bdmv")) == 0) {
+ iconindex = IDI_PLAYLIST_ICON;
+ } else if (ext.CompareNoCase(_T(".bik")) == 0) {
+ iconindex = IDI_BINK_ICON;
+ } else if (ext.CompareNoCase(_T(".cda")) == 0) {
+ iconindex = IDI_CDA_ICON;
+ } else if (ext.CompareNoCase(_T(".d2v")) == 0) {
+ iconindex = IDI_D2V_ICON;
+ } else if (ext.CompareNoCase(_T(".dat")) == 0) {
+ iconindex = IDI_DAT_ICON;
+ } else if (ext.CompareNoCase(_T(".divx")) == 0) {
+ iconindex = IDI_OTHER_ICON;
+ } else if (ext.CompareNoCase(_T(".dsa")) == 0) {
+ iconindex = IDI_DSM_ICON;
+ } else if (ext.CompareNoCase(_T(".dsm")) == 0) {
+ iconindex = IDI_DSM_ICON;
+ } else if (ext.CompareNoCase(_T(".dss")) == 0) {
+ iconindex = IDI_DSM_ICON;
+ } else if (ext.CompareNoCase(_T(".dsv")) == 0) {
+ iconindex = IDI_DSM_ICON;
+ } else if (ext.CompareNoCase(_T(".dts")) == 0) {
+ iconindex = IDI_DTS_ICON;
+ } else if (ext.CompareNoCase(_T(".evo")) == 0) {
+ iconindex = IDI_MPEG_ICON;
+ } else if (ext.CompareNoCase(_T(".f4v")) == 0) {
+ iconindex = IDI_FLV_ICON;
+ } else if (ext.CompareNoCase(_T(".flac")) == 0) {
+ iconindex = IDI_FLAC_ICON;
+ } else if (ext.CompareNoCase(_T(".flc")) == 0) {
+ iconindex = IDI_FLIC_ICON;
+ } else if (ext.CompareNoCase(_T(".fli")) == 0) {
+ iconindex = IDI_FLIC_ICON;
+ } else if (ext.CompareNoCase(_T(".flic")) == 0) {
+ iconindex = IDI_FLIC_ICON;
+ } else if (ext.CompareNoCase(_T(".flv")) == 0) {
+ iconindex = IDI_FLV_ICON;
+ } else if (ext.CompareNoCase(_T(".hdmov")) == 0) {
+ iconindex = IDI_MP4_ICON;
+ } else if (ext.CompareNoCase(_T(".iflv")) == 0) {
+ iconindex = IDI_FLV_ICON;
+ } else if (ext.CompareNoCase(_T(".ifo")) == 0) {
+ iconindex = IDI_IFO_ICON;
+ } else if (ext.CompareNoCase(_T(".ivf")) == 0) {
+ iconindex = IDI_IVF_ICON;
+ } else if (ext.CompareNoCase(_T(".m1a")) == 0) {
+ iconindex = IDI_MPA_ICON;
+ } else if (ext.CompareNoCase(_T(".m1v")) == 0) {
+ iconindex = IDI_MPEG_ICON;
+ } else if (ext.CompareNoCase(_T(".m2a")) == 0) {
+ iconindex = IDI_MPA_ICON;
+ } else if (ext.CompareNoCase(_T(".m2p")) == 0) {
+ iconindex = IDI_MPEG_ICON;
+ } else if (ext.CompareNoCase(_T(".m2t")) == 0) {
+ iconindex = IDI_TS_ICON;
+ } else if (ext.CompareNoCase(_T(".m2ts")) == 0) {
+ iconindex = IDI_TS_ICON;
+ } else if (ext.CompareNoCase(_T(".m2v")) == 0) {
+ iconindex = IDI_MPEG_ICON;
+ } else if (ext.CompareNoCase(_T(".m3u")) == 0) {
+ iconindex = IDI_PLAYLIST_ICON;
+ } else if (ext.CompareNoCase(_T(".m3u8")) == 0) {
+ iconindex = IDI_PLAYLIST_ICON;
+ } else if (ext.CompareNoCase(_T(".m4a")) == 0) {
+ iconindex = IDI_AAC_ICON;
+ } else if (ext.CompareNoCase(_T(".m4b")) == 0) {
+ iconindex = IDI_AAC_ICON;
+ } else if (ext.CompareNoCase(_T(".m4v")) == 0) {
+ iconindex = IDI_MP4_ICON;
+ } else if (ext.CompareNoCase(_T(".mid")) == 0) {
+ iconindex = IDI_MIDI_ICON;
+ } else if (ext.CompareNoCase(_T(".midi")) == 0) {
+ iconindex = IDI_MIDI_ICON;
+ } else if (ext.CompareNoCase(_T(".mka")) == 0) {
+ iconindex = IDI_MKA_ICON;
+ } else if (ext.CompareNoCase(_T(".mkv")) == 0) {
+ iconindex = IDI_MKV_ICON;
+ } else if (ext.CompareNoCase(_T(".mov")) == 0) {
+ iconindex = IDI_MOV_ICON;
+ } else if (ext.CompareNoCase(_T(".mp2")) == 0) {
+ iconindex = IDI_MPA_ICON;
+ } else if (ext.CompareNoCase(_T(".mp2v")) == 0) {
+ iconindex = IDI_MPEG_ICON;
+ } else if (ext.CompareNoCase(_T(".mp3")) == 0) {
+ iconindex = IDI_MP3_ICON;
+ } else if (ext.CompareNoCase(_T(".mp4")) == 0) {
+ iconindex = IDI_MP4_ICON;
+ } else if (ext.CompareNoCase(_T(".mp4v")) == 0) {
+ iconindex = IDI_MP4_ICON;
+ } else if (ext.CompareNoCase(_T(".mpa")) == 0) {
+ iconindex = IDI_MPA_ICON;
+ } else if (ext.CompareNoCase(_T(".mpc")) == 0) {
+ iconindex = IDI_MPC_ICON;
+ } else if (ext.CompareNoCase(_T(".mpcpl")) == 0) {
+ iconindex = IDI_PLAYLIST_ICON;
+ } else if (ext.CompareNoCase(_T(".mpe")) == 0) {
+ iconindex = IDI_MPEG_ICON;
+ } else if (ext.CompareNoCase(_T(".mpeg")) == 0) {
+ iconindex = IDI_MPEG_ICON;
+ } else if (ext.CompareNoCase(_T(".mpg")) == 0) {
+ iconindex = IDI_MPEG_ICON;
+ } else if (ext.CompareNoCase(_T(".mpls")) == 0) {
+ iconindex = IDI_PLAYLIST_ICON;
+ } else if (ext.CompareNoCase(_T(".mpv2")) == 0) {
+ iconindex = IDI_MPEG_ICON;
+ } else if (ext.CompareNoCase(_T(".mpv4")) == 0) {
+ iconindex = IDI_MP4_ICON;
+ } else if (ext.CompareNoCase(_T(".mts")) == 0) {
+ iconindex = IDI_TS_ICON;
+ } else if (ext.CompareNoCase(_T(".ofr")) == 0) {
+ iconindex = IDI_OFR_ICON;
+ } else if (ext.CompareNoCase(_T(".ofs")) == 0) {
+ iconindex = IDI_OFR_ICON;
+ } else if (ext.CompareNoCase(_T(".oga")) == 0) {
+ iconindex = IDI_OGG_ICON;
+ } else if (ext.CompareNoCase(_T(".ogg")) == 0) {
+ iconindex = IDI_OGG_ICON;
+ } else if (ext.CompareNoCase(_T(".ogm")) == 0) {
+ iconindex = IDI_OGM_ICON;
+ } else if (ext.CompareNoCase(_T(".ogv")) == 0) {
+ iconindex = IDI_OGM_ICON;
+ } else if (ext.CompareNoCase(_T(".pls")) == 0) {
+ iconindex = IDI_PLAYLIST_ICON;
+ } else if (ext.CompareNoCase(_T(".pva")) == 0) {
+ iconindex = IDI_MPEG_ICON;
+ } else if (ext.CompareNoCase(_T(".ra")) == 0) {
+ iconindex = IDI_RA_ICON;
+ } else if (ext.CompareNoCase(_T(".ram")) == 0) {
+ iconindex = IDI_RM_ICON;
+ } else if (ext.CompareNoCase(_T(".rm")) == 0) {
+ iconindex = IDI_RM_ICON;
+ } else if (ext.CompareNoCase(_T(".rmi")) == 0) {
+ iconindex = IDI_MIDI_ICON;
+ } else if (ext.CompareNoCase(_T(".rmm")) == 0) {
+ iconindex = IDI_RM_ICON;
+ } else if (ext.CompareNoCase(_T(".rmvb")) == 0) {
+ iconindex = IDI_OTHER_ICON;
+ } else if (ext.CompareNoCase(_T(".rp")) == 0) {
+ iconindex = IDI_RT_ICON;
+ } else if (ext.CompareNoCase(_T(".rpm")) == 0) {
+ iconindex = IDI_RM_ICON;
+ } else if (ext.CompareNoCase(_T(".rt")) == 0) {
+ iconindex = IDI_RT_ICON;
+ } else if (ext.CompareNoCase(_T(".smi")) == 0) {
+ iconindex = IDI_RT_ICON;
+ } else if (ext.CompareNoCase(_T(".smil")) == 0) {
+ iconindex = IDI_RT_ICON;
+ } else if (ext.CompareNoCase(_T(".smk")) == 0) {
+ iconindex = IDI_SMK_ICON;
+ } else if (ext.CompareNoCase(_T(".snd")) == 0) {
+ iconindex = IDI_AU_ICON;
+ } else if (ext.CompareNoCase(_T(".swf")) == 0) {
+ iconindex = IDI_SWF_ICON;
+ } else if (ext.CompareNoCase(_T(".tp")) == 0) {
+ iconindex = IDI_TS_ICON;
+ } else if (ext.CompareNoCase(_T(".trp")) == 0) {
+ iconindex = IDI_TS_ICON;
+ } else if (ext.CompareNoCase(_T(".ts")) == 0) {
+ iconindex = IDI_TS_ICON;
+ } else if (ext.CompareNoCase(_T(".rec")) == 0) {
+ iconindex = IDI_TS_ICON;
+ } else if (ext.CompareNoCase(_T(".tak")) == 0) {
+ iconindex = IDI_OTHER_ICON;
+ } else if (ext.CompareNoCase(_T(".tta")) == 0) {
+ iconindex = IDI_TTA_ICON;
+ } else if (ext.CompareNoCase(_T(".vob")) == 0) {
+ iconindex = IDI_VOB_ICON;
+ } else if (ext.CompareNoCase(_T(".wav")) == 0) {
+ iconindex = IDI_WAV_ICON;
+ } else if (ext.CompareNoCase(_T(".wax")) == 0) {
+ iconindex = IDI_PLAYLIST_ICON;
+ } else if (ext.CompareNoCase(_T(".webm")) == 0) {
+ iconindex = IDI_WEBM_ICON;
+ } else if (ext.CompareNoCase(_T(".wm")) == 0) {
+ iconindex = IDI_WMV_ICON;
+ } else if (ext.CompareNoCase(_T(".wma")) == 0) {
+ iconindex = IDI_WMA_ICON;
+ } else if (ext.CompareNoCase(_T(".wmp")) == 0) {
+ iconindex = IDI_WMV_ICON;
+ } else if (ext.CompareNoCase(_T(".wmv")) == 0) {
+ iconindex = IDI_WMV_ICON;
+ } else if (ext.CompareNoCase(_T(".wmx")) == 0) {
+ iconindex = IDI_PLAYLIST_ICON;
+ } else if (ext.CompareNoCase(_T(".wv")) == 0) {
+ iconindex = IDI_WV_ICON;
+ } else if (ext.CompareNoCase(_T(".wvx")) == 0) {
+ iconindex = IDI_PLAYLIST_ICON;
+ }
- return iconindex;
+ return iconindex;
}
diff --git a/src/mpc-hc/mplayerc.cpp b/src/mpc-hc/mplayerc.cpp
index 788c7e329..12cfb9398 100644
--- a/src/mpc-hc/mplayerc.cpp
+++ b/src/mpc-hc/mplayerc.cpp
@@ -45,281 +45,281 @@
extern "C" {
- int mingw_app_type = 1;
+ int mingw_app_type = 1;
}
const LanguageResource CMPlayerCApp::languageResources[] = {
- {ID_LANGUAGE_ARMENIAN, 1067, _T("Armenian"), _T("Lang\\mpcresources.hy.dll")},
- {ID_LANGUAGE_BASQUE, 1069, _T("Basque"), _T("Lang\\mpcresources.eu.dll")},
- {ID_LANGUAGE_BELARUSIAN, 1059, _T("Belarusian"), _T("Lang\\mpcresources.by.dll")},
- {ID_LANGUAGE_CATALAN, 1027, _T("Catalan"), _T("Lang\\mpcresources.ca.dll")},
- {ID_LANGUAGE_CHINESE_SIMPLIFIED, 2052, _T("Chinese (Simplified)"), _T("Lang\\mpcresources.sc.dll")},
- {ID_LANGUAGE_CHINESE_TRADITIONAL, 3076, _T("Chinese (Traditional)"), _T("Lang\\mpcresources.tc.dll")},
- {ID_LANGUAGE_CZECH, 1029, _T("Czech"), _T("Lang\\mpcresources.cz.dll")},
- {ID_LANGUAGE_DUTCH, 1043, _T("Dutch"), _T("Lang\\mpcresources.nl.dll")},
- {ID_LANGUAGE_ENGLISH, 0, _T("English"), NULL},
- {ID_LANGUAGE_FRENCH, 1036, _T("French"), _T("Lang\\mpcresources.fr.dll")},
- {ID_LANGUAGE_GERMAN, 1031, _T("German"), _T("Lang\\mpcresources.de.dll")},
- {ID_LANGUAGE_HEBREW, 1037, _T("Hebrew"), _T("Lang\\mpcresources.he.dll")},
- {ID_LANGUAGE_HUNGARIAN, 1042, _T("Hungarian"), _T("Lang\\mpcresources.hu.dll")},
- {ID_LANGUAGE_ITALIAN, 1040, _T("Italian"), _T("Lang\\mpcresources.it.dll")},
- {ID_LANGUAGE_JAPANESE, 1041, _T("Japanese"), _T("Lang\\mpcresources.ja.dll")},
- {ID_LANGUAGE_KOREAN, 1038, _T("Korean"), _T("Lang\\mpcresources.kr.dll")},
- {ID_LANGUAGE_POLISH, 1045, _T("Polish"), _T("Lang\\mpcresources.pl.dll")},
- {ID_LANGUAGE_PORTUGUESE_BR, 1046, _T("Portuguese (Brazil)"), _T("Lang\\mpcresources.br.dll")},
- {ID_LANGUAGE_RUSSIAN, 1049, _T("Russian"), _T("Lang\\mpcresources.ru.dll")},
- {ID_LANGUAGE_SLOVAK, 1053, _T("Slovak"), _T("Lang\\mpcresources.sk.dll")},
- {ID_LANGUAGE_SWEDISH, 1051, _T("Swedish"), _T("Lang\\mpcresources.sv.dll")},
- {ID_LANGUAGE_SPANISH, 1034, _T("Spanish"), _T("Lang\\mpcresources.es.dll")},
- {ID_LANGUAGE_TURKISH, 1055, _T("Turkish"), _T("Lang\\mpcresources.tr.dll")},
- {ID_LANGUAGE_UKRAINIAN, 1058, _T("Ukrainian"), _T("Lang\\mpcresources.ua.dll")}
+ {ID_LANGUAGE_ARMENIAN, 1067, _T("Armenian"), _T("Lang\\mpcresources.hy.dll")},
+ {ID_LANGUAGE_BASQUE, 1069, _T("Basque"), _T("Lang\\mpcresources.eu.dll")},
+ {ID_LANGUAGE_BELARUSIAN, 1059, _T("Belarusian"), _T("Lang\\mpcresources.by.dll")},
+ {ID_LANGUAGE_CATALAN, 1027, _T("Catalan"), _T("Lang\\mpcresources.ca.dll")},
+ {ID_LANGUAGE_CHINESE_SIMPLIFIED, 2052, _T("Chinese (Simplified)"), _T("Lang\\mpcresources.sc.dll")},
+ {ID_LANGUAGE_CHINESE_TRADITIONAL, 3076, _T("Chinese (Traditional)"), _T("Lang\\mpcresources.tc.dll")},
+ {ID_LANGUAGE_CZECH, 1029, _T("Czech"), _T("Lang\\mpcresources.cz.dll")},
+ {ID_LANGUAGE_DUTCH, 1043, _T("Dutch"), _T("Lang\\mpcresources.nl.dll")},
+ {ID_LANGUAGE_ENGLISH, 0, _T("English"), NULL},
+ {ID_LANGUAGE_FRENCH, 1036, _T("French"), _T("Lang\\mpcresources.fr.dll")},
+ {ID_LANGUAGE_GERMAN, 1031, _T("German"), _T("Lang\\mpcresources.de.dll")},
+ {ID_LANGUAGE_HEBREW, 1037, _T("Hebrew"), _T("Lang\\mpcresources.he.dll")},
+ {ID_LANGUAGE_HUNGARIAN, 1042, _T("Hungarian"), _T("Lang\\mpcresources.hu.dll")},
+ {ID_LANGUAGE_ITALIAN, 1040, _T("Italian"), _T("Lang\\mpcresources.it.dll")},
+ {ID_LANGUAGE_JAPANESE, 1041, _T("Japanese"), _T("Lang\\mpcresources.ja.dll")},
+ {ID_LANGUAGE_KOREAN, 1038, _T("Korean"), _T("Lang\\mpcresources.kr.dll")},
+ {ID_LANGUAGE_POLISH, 1045, _T("Polish"), _T("Lang\\mpcresources.pl.dll")},
+ {ID_LANGUAGE_PORTUGUESE_BR, 1046, _T("Portuguese (Brazil)"), _T("Lang\\mpcresources.br.dll")},
+ {ID_LANGUAGE_RUSSIAN, 1049, _T("Russian"), _T("Lang\\mpcresources.ru.dll")},
+ {ID_LANGUAGE_SLOVAK, 1053, _T("Slovak"), _T("Lang\\mpcresources.sk.dll")},
+ {ID_LANGUAGE_SWEDISH, 1051, _T("Swedish"), _T("Lang\\mpcresources.sv.dll")},
+ {ID_LANGUAGE_SPANISH, 1034, _T("Spanish"), _T("Lang\\mpcresources.es.dll")},
+ {ID_LANGUAGE_TURKISH, 1055, _T("Turkish"), _T("Lang\\mpcresources.tr.dll")},
+ {ID_LANGUAGE_UKRAINIAN, 1058, _T("Ukrainian"), _T("Lang\\mpcresources.ua.dll")}
};
const size_t CMPlayerCApp::languageResourcesCount = _countof(CMPlayerCApp::languageResources);
HICON LoadIcon(CString fn, bool fSmall)
{
- if (fn.IsEmpty()) {
- return NULL;
- }
+ if (fn.IsEmpty()) {
+ return NULL;
+ }
- CString ext = fn.Left(fn.Find(_T("://"))+1).TrimRight(':');
- if (ext.IsEmpty() || !ext.CompareNoCase(_T("file"))) {
- ext = _T(".") + fn.Mid(fn.ReverseFind('.')+1);
- }
+ CString ext = fn.Left(fn.Find(_T("://")) + 1).TrimRight(':');
+ if (ext.IsEmpty() || !ext.CompareNoCase(_T("file"))) {
+ ext = _T(".") + fn.Mid(fn.ReverseFind('.') + 1);
+ }
- CSize size(fSmall?16:32,fSmall?16:32);
+ CSize size(fSmall ? 16 : 32, fSmall ? 16 : 32);
- if (!ext.CompareNoCase(_T(".ifo"))) {
- if (HICON hIcon = (HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_DVD), IMAGE_ICON, size.cx, size.cy, 0)) {
- return hIcon;
- }
- }
+ if (!ext.CompareNoCase(_T(".ifo"))) {
+ if (HICON hIcon = (HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_DVD), IMAGE_ICON, size.cx, size.cy, 0)) {
+ return hIcon;
+ }
+ }
- if (!ext.CompareNoCase(_T(".cda"))) {
- if (HICON hIcon = (HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_AUDIOCD), IMAGE_ICON, size.cx, size.cy, 0)) {
- return hIcon;
- }
- }
+ if (!ext.CompareNoCase(_T(".cda"))) {
+ if (HICON hIcon = (HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_AUDIOCD), IMAGE_ICON, size.cx, size.cy, 0)) {
+ return hIcon;
+ }
+ }
- do {
- CRegKey key;
+ do {
+ CRegKey key;
- TCHAR buff[256];
- ULONG len;
+ TCHAR buff[256];
+ ULONG len;
- if (ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, ext + _T("\\DefaultIcon"), KEY_READ)) {
- if (ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, ext, KEY_READ)) {
- break;
- }
+ if (ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, ext + _T("\\DefaultIcon"), KEY_READ)) {
+ if (ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, ext, KEY_READ)) {
+ break;
+ }
- len = _countof(buff);
- memset(buff, 0, sizeof(buff));
- if (ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len) || (ext = buff).Trim().IsEmpty()) {
- break;
- }
+ len = _countof(buff);
+ memset(buff, 0, sizeof(buff));
+ if (ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len) || (ext = buff).Trim().IsEmpty()) {
+ break;
+ }
- if (ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, ext + _T("\\DefaultIcon"), KEY_READ)) {
- break;
- }
- }
+ if (ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, ext + _T("\\DefaultIcon"), KEY_READ)) {
+ break;
+ }
+ }
- CString icon;
+ CString icon;
- len = _countof(buff);
- memset(buff, 0, sizeof(buff));
- if (ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len) || (icon = buff).Trim().IsEmpty()) {
- break;
- }
+ len = _countof(buff);
+ memset(buff, 0, sizeof(buff));
+ if (ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len) || (icon = buff).Trim().IsEmpty()) {
+ break;
+ }
- int i = icon.ReverseFind(',');
- if (i < 0) {
- break;
- }
+ int i = icon.ReverseFind(',');
+ if (i < 0) {
+ break;
+ }
- int id = 0;
- if (_stscanf_s(icon.Mid(i+1), _T("%d"), &id) != 1) {
- break;
- }
+ int id = 0;
+ if (_stscanf_s(icon.Mid(i + 1), _T("%d"), &id) != 1) {
+ break;
+ }
- icon = icon.Left(i);
+ icon = icon.Left(i);
- HICON hIcon = NULL;
- UINT cnt = fSmall
- ? ExtractIconEx(icon, id, NULL, &hIcon, 1)
- : ExtractIconEx(icon, id, &hIcon, NULL, 1);
- UNREFERENCED_PARAMETER(cnt);
- if (hIcon) {
- return hIcon;
- }
- } while (0);
+ HICON hIcon = NULL;
+ UINT cnt = fSmall
+ ? ExtractIconEx(icon, id, NULL, &hIcon, 1)
+ : ExtractIconEx(icon, id, &hIcon, NULL, 1);
+ UNREFERENCED_PARAMETER(cnt);
+ if (hIcon) {
+ return hIcon;
+ }
+ } while (0);
- return (HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_UNKNOWN), IMAGE_ICON, size.cx, size.cy, 0);
+ return (HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_UNKNOWN), IMAGE_ICON, size.cx, size.cy, 0);
}
bool LoadType(CString fn, CString& type)
{
- bool found = false;
+ bool found = false;
- if (!fn.IsEmpty()) {
- CString ext = fn.Left(fn.Find(_T("://"))+1).TrimRight(':');
- if (ext.IsEmpty() || !ext.CompareNoCase(_T("file"))) {
- ext = _T(".") + fn.Mid(fn.ReverseFind('.')+1);
- }
+ if (!fn.IsEmpty()) {
+ CString ext = fn.Left(fn.Find(_T("://")) + 1).TrimRight(':');
+ if (ext.IsEmpty() || !ext.CompareNoCase(_T("file"))) {
+ ext = _T(".") + fn.Mid(fn.ReverseFind('.') + 1);
+ }
- // Try MPC-HC's internal formats list
- CMediaFormatCategory* mfc = AfxGetAppSettings().m_Formats.FindMediaByExt(ext);
+ // Try MPC-HC's internal formats list
+ CMediaFormatCategory* mfc = AfxGetAppSettings().m_Formats.FindMediaByExt(ext);
- if (mfc != NULL) {
- found = true;
- type = mfc->GetDescription();
- } else { // Fallback to registry
- CRegKey key;
+ if (mfc != NULL) {
+ found = true;
+ type = mfc->GetDescription();
+ } else { // Fallback to registry
+ CRegKey key;
- TCHAR buff[256];
- ULONG len;
+ TCHAR buff[256];
+ ULONG len;
- CString tmp = _T("");
- CString mplayerc_ext = _T("mplayerc") + ext;
+ CString tmp = _T("");
+ CString mplayerc_ext = _T("mplayerc") + ext;
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, mplayerc_ext)) {
- tmp = mplayerc_ext;
- }
+ if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, mplayerc_ext)) {
+ tmp = mplayerc_ext;
+ }
- if (!tmp.IsEmpty() || ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, ext)) {
- found = true;
+ if (!tmp.IsEmpty() || ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, ext)) {
+ found = true;
- if (tmp.IsEmpty()) {
- tmp = ext;
- }
+ if (tmp.IsEmpty()) {
+ tmp = ext;
+ }
- while (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, tmp)) {
- len = _countof(buff);
- memset(buff, 0, sizeof(buff));
+ while (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, tmp)) {
+ len = _countof(buff);
+ memset(buff, 0, sizeof(buff));
- if (ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len)) {
- break;
- }
+ if (ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len)) {
+ break;
+ }
- CString str(buff);
- str.Trim();
+ CString str(buff);
+ str.Trim();
- if (str.IsEmpty() || str == tmp) {
- break;
- }
+ if (str.IsEmpty() || str == tmp) {
+ break;
+ }
- tmp = str;
- }
+ tmp = str;
+ }
- type = tmp;
- }
- }
- }
+ type = tmp;
+ }
+ }
+ }
- return found;
+ return found;
}
bool LoadResource(UINT resid, CStringA& str, LPCTSTR restype)
{
- str.Empty();
- HRSRC hrsrc = FindResource(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(resid), restype);
- if (!hrsrc) {
- return false;
- }
- HGLOBAL hGlobal = LoadResource(AfxGetApp()->m_hInstance, hrsrc);
- if (!hGlobal) {
- return false;
- }
- DWORD size = SizeofResource(AfxGetApp()->m_hInstance, hrsrc);
- if (!size) {
- return false;
- }
- memcpy(str.GetBufferSetLength(size), LockResource(hGlobal), size);
- return true;
+ str.Empty();
+ HRSRC hrsrc = FindResource(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(resid), restype);
+ if (!hrsrc) {
+ return false;
+ }
+ HGLOBAL hGlobal = LoadResource(AfxGetApp()->m_hInstance, hrsrc);
+ if (!hGlobal) {
+ return false;
+ }
+ DWORD size = SizeofResource(AfxGetApp()->m_hInstance, hrsrc);
+ if (!size) {
+ return false;
+ }
+ memcpy(str.GetBufferSetLength(size), LockResource(hGlobal), size);
+ return true;
}
WORD AssignedToCmd(UINT keyOrMouseValue, bool bIsFullScreen, bool bCheckMouse)
{
- WORD assignTo = 0;
- AppSettings& s = AfxGetAppSettings();
+ WORD assignTo = 0;
+ AppSettings& s = AfxGetAppSettings();
- POSITION pos = s.wmcmds.GetHeadPosition();
- while (pos && !assignTo) {
- wmcmd& wc = s.wmcmds.GetNext(pos);
+ POSITION pos = s.wmcmds.GetHeadPosition();
+ while (pos && !assignTo) {
+ wmcmd& wc = s.wmcmds.GetNext(pos);
- if (bCheckMouse) {
- if (bIsFullScreen) {
- if (wc.mouseFS == keyOrMouseValue) {
- assignTo = wc.cmd;
- }
- } else if (wc.mouse == keyOrMouseValue) {
- assignTo = wc.cmd;
- }
- } else if (wc.key == keyOrMouseValue) {
- assignTo = wc.cmd;
- }
- }
+ if (bCheckMouse) {
+ if (bIsFullScreen) {
+ if (wc.mouseFS == keyOrMouseValue) {
+ assignTo = wc.cmd;
+ }
+ } else if (wc.mouse == keyOrMouseValue) {
+ assignTo = wc.cmd;
+ }
+ } else if (wc.key == keyOrMouseValue) {
+ assignTo = wc.cmd;
+ }
+ }
- return assignTo;
+ return assignTo;
}
/////////////////////////////////////////////////////////////////////////////
// CMPlayerCApp
BEGIN_MESSAGE_MAP(CMPlayerCApp, CWinApp)
- //{{AFX_MSG_MAP(CMPlayerCApp)
- ON_COMMAND(ID_HELP_ABOUT, OnAppAbout)
- ON_COMMAND(ID_FILE_EXIT, OnFileExit)
- //}}AFX_MSG_MAP
- ON_COMMAND(ID_HELP_SHOWCOMMANDLINESWITCHES, OnHelpShowcommandlineswitches)
+ //{{AFX_MSG_MAP(CMPlayerCApp)
+ ON_COMMAND(ID_HELP_ABOUT, OnAppAbout)
+ ON_COMMAND(ID_FILE_EXIT, OnFileExit)
+ //}}AFX_MSG_MAP
+ ON_COMMAND(ID_HELP_SHOWCOMMANDLINESWITCHES, OnHelpShowcommandlineswitches)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMPlayerCApp construction
CMPlayerCApp::CMPlayerCApp()
-// : m_hMutexOneInstance(NULL)
+// : m_hMutexOneInstance(NULL)
{
- CFileVersionInfo Version;
- TCHAR strApp [_MAX_PATH];
+ CFileVersionInfo Version;
+ TCHAR strApp [_MAX_PATH];
- GetModuleFileNameEx (GetCurrentProcess(), AfxGetMyApp()->m_hInstance, strApp, _MAX_PATH);
- Version.Create (strApp);
- m_strVersion = Version.GetFileVersionEx();
+ GetModuleFileNameEx(GetCurrentProcess(), AfxGetMyApp()->m_hInstance, strApp, _MAX_PATH);
+ Version.Create(strApp);
+ m_strVersion = Version.GetFileVersionEx();
- memset (&m_ColorControl, 0, sizeof(m_ColorControl));
- ResetColorControlRange();
+ memset(&m_ColorControl, 0, sizeof(m_ColorControl));
+ ResetColorControlRange();
- memset (&m_VMR9ColorControl, 0, sizeof(m_VMR9ColorControl));
- m_VMR9ColorControl[0].dwSize = sizeof (VMR9ProcAmpControlRange);
- m_VMR9ColorControl[0].dwProperty = ProcAmpControl9_Brightness;
- m_VMR9ColorControl[1].dwSize = sizeof (VMR9ProcAmpControlRange);
- m_VMR9ColorControl[1].dwProperty = ProcAmpControl9_Contrast;
- m_VMR9ColorControl[2].dwSize = sizeof (VMR9ProcAmpControlRange);
- m_VMR9ColorControl[2].dwProperty = ProcAmpControl9_Hue;
- m_VMR9ColorControl[3].dwSize = sizeof (VMR9ProcAmpControlRange);
- m_VMR9ColorControl[3].dwProperty = ProcAmpControl9_Saturation;
+ memset(&m_VMR9ColorControl, 0, sizeof(m_VMR9ColorControl));
+ m_VMR9ColorControl[0].dwSize = sizeof(VMR9ProcAmpControlRange);
+ m_VMR9ColorControl[0].dwProperty = ProcAmpControl9_Brightness;
+ m_VMR9ColorControl[1].dwSize = sizeof(VMR9ProcAmpControlRange);
+ m_VMR9ColorControl[1].dwProperty = ProcAmpControl9_Contrast;
+ m_VMR9ColorControl[2].dwSize = sizeof(VMR9ProcAmpControlRange);
+ m_VMR9ColorControl[2].dwProperty = ProcAmpControl9_Hue;
+ m_VMR9ColorControl[3].dwSize = sizeof(VMR9ProcAmpControlRange);
+ m_VMR9ColorControl[3].dwProperty = ProcAmpControl9_Saturation;
- memset (&m_EVRColorControl, 0, sizeof(m_EVRColorControl));
+ memset(&m_EVRColorControl, 0, sizeof(m_EVRColorControl));
- GetRemoteControlCode = GetRemoteControlCodeMicrosoft;
+ GetRemoteControlCode = GetRemoteControlCodeMicrosoft;
}
void CMPlayerCApp::ShowCmdlnSwitches() const
{
- CString s;
+ CString s;
- if (m_s.nCLSwitches&CLSW_UNRECOGNIZEDSWITCH) {
- CAtlList<CString> sl;
- for (int i = 0; i < __argc; i++) {
- sl.AddTail(__targv[i]);
- }
- s += ResStr(IDS_UNKNOWN_SWITCH) + Implode(sl, ' ') + _T("\n\n");
- }
+ if (m_s.nCLSwitches & CLSW_UNRECOGNIZEDSWITCH) {
+ CAtlList<CString> sl;
+ for (int i = 0; i < __argc; i++) {
+ sl.AddTail(__targv[i]);
+ }
+ s += ResStr(IDS_UNKNOWN_SWITCH) + Implode(sl, ' ') + _T("\n\n");
+ }
- s += ResStr(IDS_USAGE);
+ s += ResStr(IDS_USAGE);
- AfxMessageBox(s, MB_ICONINFORMATION | MB_OK);
+ AfxMessageBox(s, MB_ICONINFORMATION | MB_OK);
}
/////////////////////////////////////////////////////////////////////////////
@@ -331,962 +331,961 @@ HWND g_hWnd = NULL;
bool CMPlayerCApp::StoreSettingsToIni()
{
- CString ini = GetIniPath();
- /*
- FILE* f;
- if (!(f = _tfopen(ini, _T("r+"))) && !(f = _tfopen(ini, _T("w"))))
- return StoreSettingsToRegistry();
- fclose(f);
- */
- free((void*)m_pszRegistryKey);
- m_pszRegistryKey = NULL;
- free((void*)m_pszProfileName);
- m_pszProfileName = _tcsdup(ini);
-
- // We can only use UTF16-LE for unicode ini files in windows. UTF8/UTF16-BE do not work.
- // So to ensure we have correct encoding for ini files, create a file with right BOM first,
- // then add some comments in first line to make sure it's not empty.
- if (!::PathFileExists(m_pszProfileName)) { // don't overwrite existing ini file
- const TCHAR pszComments[] = _T("; Media Player Classic - Home Cinema");
- WORD wBOM = 0xFEFF; // UTF16-LE BOM (FFFE)
- DWORD nBytes;
-
- HANDLE hFile = ::CreateFile(m_pszProfileName, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
- if (hFile != INVALID_HANDLE_VALUE)
- {
- ::WriteFile(hFile, &wBOM, sizeof(WORD), &nBytes, NULL);
- ::WriteFile(hFile, pszComments, sizeof(pszComments), &nBytes, NULL);
- ::CloseHandle(hFile);
- }
- }
-
- return true;
+ CString ini = GetIniPath();
+ /*
+ FILE* f;
+ if (!(f = _tfopen(ini, _T("r+"))) && !(f = _tfopen(ini, _T("w"))))
+ return StoreSettingsToRegistry();
+ fclose(f);
+ */
+ free((void*)m_pszRegistryKey);
+ m_pszRegistryKey = NULL;
+ free((void*)m_pszProfileName);
+ m_pszProfileName = _tcsdup(ini);
+
+ // We can only use UTF16-LE for unicode ini files in windows. UTF8/UTF16-BE do not work.
+ // So to ensure we have correct encoding for ini files, create a file with right BOM first,
+ // then add some comments in first line to make sure it's not empty.
+ if (!::PathFileExists(m_pszProfileName)) { // don't overwrite existing ini file
+ const TCHAR pszComments[] = _T("; Media Player Classic - Home Cinema");
+ WORD wBOM = 0xFEFF; // UTF16-LE BOM (FFFE)
+ DWORD nBytes;
+
+ HANDLE hFile = ::CreateFile(m_pszProfileName, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
+ if (hFile != INVALID_HANDLE_VALUE) {
+ ::WriteFile(hFile, &wBOM, sizeof(WORD), &nBytes, NULL);
+ ::WriteFile(hFile, pszComments, sizeof(pszComments), &nBytes, NULL);
+ ::CloseHandle(hFile);
+ }
+ }
+
+ return true;
}
bool CMPlayerCApp::StoreSettingsToRegistry()
{
- free((void*)m_pszRegistryKey);
- m_pszRegistryKey = NULL;
+ free((void*)m_pszRegistryKey);
+ m_pszRegistryKey = NULL;
- SetRegistryKey(_T("Gabest"));
+ SetRegistryKey(_T("Gabest"));
- return true;
+ return true;
}
CString CMPlayerCApp::GetIniPath() const
{
- CString path;
- GetModuleFileName(AfxGetInstanceHandle(), path.GetBuffer(_MAX_PATH), _MAX_PATH);
- path.ReleaseBuffer();
- path = path.Left(path.ReverseFind('.')+1) + _T("ini");
- return path;
+ CString path;
+ GetModuleFileName(AfxGetInstanceHandle(), path.GetBuffer(_MAX_PATH), _MAX_PATH);
+ path.ReleaseBuffer();
+ path = path.Left(path.ReverseFind('.') + 1) + _T("ini");
+ return path;
}
bool CMPlayerCApp::IsIniValid() const
{
- CFileStatus fs;
- return !!CFile::GetStatus(GetIniPath(), fs);
+ CFileStatus fs;
+ return !!CFile::GetStatus(GetIniPath(), fs);
}
bool CMPlayerCApp::IsIniUTF16LE() const
{
- bool isUTF16LE = false;
-
- try {
- CFile f(GetIniPath(), CFile::modeRead);
-
- if (f) {
- WORD bom;
- if (f.Read(&bom, sizeof(bom)) == sizeof(bom)) {
- isUTF16LE = (bom == 0xFEFF);
- }
- }
- } catch (CFileException* e) {
- // If something goes wrong, we try to recreate the ini file
- // instead of crashing because it seems to work in most of
- // the cases but maybe we could do something better.
+ bool isUTF16LE = false;
+
+ try {
+ CFile f(GetIniPath(), CFile::modeRead);
+
+ if (f) {
+ WORD bom;
+ if (f.Read(&bom, sizeof(bom)) == sizeof(bom)) {
+ isUTF16LE = (bom == 0xFEFF);
+ }
+ }
+ } catch (CFileException* e) {
+ // If something goes wrong, we try to recreate the ini file
+ // instead of crashing because it seems to work in most of
+ // the cases but maybe we could do something better.
#ifdef _DEBUG
- TCHAR szCause[500];
- e->GetErrorMessage(szCause, 500);
- AfxMessageBox(szCause);
+ TCHAR szCause[500];
+ e->GetErrorMessage(szCause, 500);
+ AfxMessageBox(szCause);
#endif // _DEBUG
- e->Delete();
- }
+ e->Delete();
+ }
- return isUTF16LE;
+ return isUTF16LE;
}
bool CMPlayerCApp::GetAppSavePath(CString& path)
{
- path.Empty();
+ path.Empty();
- if (IsIniValid()) { // If settings ini file found, store stuff in the same folder as the exe file
- GetModuleFileName(AfxGetInstanceHandle(), path.GetBuffer(_MAX_PATH), _MAX_PATH);
- path.ReleaseBuffer();
- path.Truncate(path.ReverseFind('\\'));
- } else {
- HRESULT hr = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, path.GetBuffer(_MAX_PATH));
- path.ReleaseBuffer();
- if (FAILED(hr)) {
- return false;
- }
- CPath p;
- p.Combine(path, _T("Media Player Classic"));
- path = (LPCTSTR)p;
- }
+ if (IsIniValid()) { // If settings ini file found, store stuff in the same folder as the exe file
+ GetModuleFileName(AfxGetInstanceHandle(), path.GetBuffer(_MAX_PATH), _MAX_PATH);
+ path.ReleaseBuffer();
+ path.Truncate(path.ReverseFind('\\'));
+ } else {
+ HRESULT hr = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, path.GetBuffer(_MAX_PATH));
+ path.ReleaseBuffer();
+ if (FAILED(hr)) {
+ return false;
+ }
+ CPath p;
+ p.Combine(path, _T("Media Player Classic"));
+ path = (LPCTSTR)p;
+ }
- return true;
+ return true;
}
bool CMPlayerCApp::ChangeSettingsLocation(bool useIni)
{
- bool success;
+ bool success;
- // Load favorites so that they can be correctly saved to the new location
- CAtlList<CString> filesFav, DVDsFav, devicesFav;
- AfxGetAppSettings().GetFav(FAV_FILE, filesFav);
- AfxGetAppSettings().GetFav(FAV_DVD, DVDsFav);
- AfxGetAppSettings().GetFav(FAV_DEVICE, devicesFav);
+ // Load favorites so that they can be correctly saved to the new location
+ CAtlList<CString> filesFav, DVDsFav, devicesFav;
+ AfxGetAppSettings().GetFav(FAV_FILE, filesFav);
+ AfxGetAppSettings().GetFav(FAV_DVD, DVDsFav);
+ AfxGetAppSettings().GetFav(FAV_DEVICE, devicesFav);
- // In case an ini file is present, we remove it so that it will be recreated
- _tremove(GetIniPath());
+ // In case an ini file is present, we remove it so that it will be recreated
+ _tremove(GetIniPath());
- if (useIni) {
- success = StoreSettingsToIni();
- } else {
- success = StoreSettingsToRegistry();
- }
+ if (useIni) {
+ success = StoreSettingsToIni();
+ } else {
+ success = StoreSettingsToRegistry();
+ }
- // Write settings immediately
- m_s.UpdateData(true);
+ // Write settings immediately
+ m_s.UpdateData(true);
- // Save favorites to the new location
- AfxGetAppSettings().SetFav(FAV_FILE, filesFav);
- AfxGetAppSettings().SetFav(FAV_DVD, DVDsFav);
- AfxGetAppSettings().SetFav(FAV_DEVICE, devicesFav);
+ // Save favorites to the new location
+ AfxGetAppSettings().SetFav(FAV_FILE, filesFav);
+ AfxGetAppSettings().SetFav(FAV_DVD, DVDsFav);
+ AfxGetAppSettings().SetFav(FAV_DEVICE, devicesFav);
- return success;
+ return success;
}
void CMPlayerCApp::ExportSettings()
{
- CString ext = IsIniValid() ? _T("ini") : _T("reg");
- CFileDialog fileSaveDialog(FALSE, ext, _T("mpc-hc-settings.")+ext);
+ CString ext = IsIniValid() ? _T("ini") : _T("reg");
+ CFileDialog fileSaveDialog(FALSE, ext, _T("mpc-hc-settings.") + ext);
- if (fileSaveDialog.DoModal() == IDOK) {
- CString savePath = fileSaveDialog.GetPathName();
- bool success;
+ if (fileSaveDialog.DoModal() == IDOK) {
+ CString savePath = fileSaveDialog.GetPathName();
+ bool success;
- AfxGetAppSettings().UpdateData(true);
+ AfxGetAppSettings().UpdateData(true);
- if (IsIniValid()) {
- success = !!CopyFile(GetIniPath(), savePath, FALSE);
- } else {
- CString regKey;
- regKey.Format(_T("Software\\%s\\%s"), m_pszRegistryKey, m_pszProfileName);
+ if (IsIniValid()) {
+ success = !!CopyFile(GetIniPath(), savePath, FALSE);
+ } else {
+ CString regKey;
+ regKey.Format(_T("Software\\%s\\%s"), m_pszRegistryKey, m_pszProfileName);
- FILE* fStream;
- errno_t error = _tfopen_s(&fStream, savePath, _T("wt,ccs=UNICODE"));
- CStdioFile file(fStream);
- file.WriteString(_T("Windows Registry Editor Version 5.00\n\n"));
+ FILE* fStream;
+ errno_t error = _tfopen_s(&fStream, savePath, _T("wt,ccs=UNICODE"));
+ CStdioFile file(fStream);
+ file.WriteString(_T("Windows Registry Editor Version 5.00\n\n"));
- success = !error && ExportRegistryKey(file, HKEY_CURRENT_USER, regKey);
+ success = !error && ExportRegistryKey(file, HKEY_CURRENT_USER, regKey);
- file.Close();
- }
+ file.Close();
+ }
- if (success) {
- MessageBox(GetMainWnd()->m_hWnd, ResStr(IDS_EXPORT_SETTINGS_SUCCESS), ResStr(IDS_EXPORT_SETTINGS), MB_ICONINFORMATION | MB_OK);
- } else {
- MessageBox(GetMainWnd()->m_hWnd, ResStr(IDS_EXPORT_SETTINGS_FAILED), ResStr(IDS_EXPORT_SETTINGS), MB_ICONERROR | MB_OK);
- }
- }
+ if (success) {
+ MessageBox(GetMainWnd()->m_hWnd, ResStr(IDS_EXPORT_SETTINGS_SUCCESS), ResStr(IDS_EXPORT_SETTINGS), MB_ICONINFORMATION | MB_OK);
+ } else {
+ MessageBox(GetMainWnd()->m_hWnd, ResStr(IDS_EXPORT_SETTINGS_FAILED), ResStr(IDS_EXPORT_SETTINGS), MB_ICONERROR | MB_OK);
+ }
+ }
}
void CMPlayerCApp::PreProcessCommandLine()
{
- m_cmdln.RemoveAll();
+ m_cmdln.RemoveAll();
- for (int i = 1; i < __argc; i++) {
- m_cmdln.AddTail(CString(__targv[i]).Trim(_T(" \"")));
- }
+ for (int i = 1; i < __argc; i++) {
+ m_cmdln.AddTail(CString(__targv[i]).Trim(_T(" \"")));
+ }
}
bool CMPlayerCApp::SendCommandLine(HWND hWnd)
{
- if (m_cmdln.IsEmpty()) {
- return false;
- }
+ if (m_cmdln.IsEmpty()) {
+ return false;
+ }
- int bufflen = sizeof(DWORD);
+ int bufflen = sizeof(DWORD);
- POSITION pos = m_cmdln.GetHeadPosition();
- while (pos) {
- bufflen += (m_cmdln.GetNext(pos).GetLength() + 1) * sizeof(TCHAR);
- }
+ POSITION pos = m_cmdln.GetHeadPosition();
+ while (pos) {
+ bufflen += (m_cmdln.GetNext(pos).GetLength() + 1) * sizeof(TCHAR);
+ }
- CAutoVectorPtr<BYTE> buff;
- if (!buff.Allocate(bufflen)) {
- return FALSE;
- }
+ CAutoVectorPtr<BYTE> buff;
+ if (!buff.Allocate(bufflen)) {
+ return FALSE;
+ }
- BYTE* p = buff;
+ BYTE* p = buff;
- *(DWORD*)p = (DWORD)m_cmdln.GetCount();
- p += sizeof(DWORD);
+ *(DWORD*)p = (DWORD)m_cmdln.GetCount();
+ p += sizeof(DWORD);
- pos = m_cmdln.GetHeadPosition();
- while (pos) {
- const CString& s = m_cmdln.GetNext(pos);
- int len = (s.GetLength() + 1) * sizeof(TCHAR);
- memcpy(p, s, len);
- p += len;
- }
+ pos = m_cmdln.GetHeadPosition();
+ while (pos) {
+ const CString& s = m_cmdln.GetNext(pos);
+ int len = (s.GetLength() + 1) * sizeof(TCHAR);
+ memcpy(p, s, len);
+ p += len;
+ }
- COPYDATASTRUCT cds;
- cds.dwData = 0x6ABE51;
- cds.cbData = bufflen;
- cds.lpData = (void*)(BYTE*)buff;
+ COPYDATASTRUCT cds;
+ cds.dwData = 0x6ABE51;
+ cds.cbData = bufflen;
+ cds.lpData = (void*)(BYTE*)buff;
- return !!SendMessage(hWnd, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
+ return !!SendMessage(hWnd, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
}
/////////////////////////////////////////////////////////////////////////////
// CMPlayerCApp initialization
-BOOL (__stdcall * Real_IsDebuggerPresent)(void)
- = IsDebuggerPresent;
-
-LONG (__stdcall * Real_ChangeDisplaySettingsExA)(LPCSTR a0,
- LPDEVMODEA a1,
- HWND a2,
- DWORD a3,
- LPVOID a4)
- = ChangeDisplaySettingsExA;
-
-LONG (__stdcall * Real_ChangeDisplaySettingsExW)(LPCWSTR a0,
- LPDEVMODEW a1,
- HWND a2,
- DWORD a3,
- LPVOID a4)
- = ChangeDisplaySettingsExW;
-
-HANDLE (__stdcall * Real_CreateFileA)(LPCSTR a0,
- DWORD a1,
- DWORD a2,
- LPSECURITY_ATTRIBUTES a3,
- DWORD a4,
- DWORD a5,
- HANDLE a6)
- = CreateFileA;
-
-HANDLE (__stdcall * Real_CreateFileW)(LPCWSTR a0,
- DWORD a1,
- DWORD a2,
- LPSECURITY_ATTRIBUTES a3,
- DWORD a4,
- DWORD a5,
- HANDLE a6)
- = CreateFileW;
-
-BOOL (__stdcall * Real_DeviceIoControl)(HANDLE a0,
- DWORD a1,
- LPVOID a2,
- DWORD a3,
- LPVOID a4,
- DWORD a5,
- LPDWORD a6,
- LPOVERLAPPED a7)
- = DeviceIoControl;
-
-MMRESULT (__stdcall * Real_mixerSetControlDetails)( HMIXEROBJ hmxobj,
- LPMIXERCONTROLDETAILS pmxcd,
- DWORD fdwDetails)
- = mixerSetControlDetails;
-
-
-typedef NTSTATUS (WINAPI *FUNC_NTQUERYINFORMATIONPROCESS)(HANDLE ProcessHandle, PROCESSINFOCLASS ProcessInformationClass, PVOID ProcessInformation, ULONG ProcessInformationLength, PULONG ReturnLength);
-static FUNC_NTQUERYINFORMATIONPROCESS Real_NtQueryInformationProcess = NULL;
+BOOL (__stdcall* Real_IsDebuggerPresent)(void)
+ = IsDebuggerPresent;
+
+LONG(__stdcall* Real_ChangeDisplaySettingsExA)(LPCSTR a0,
+ LPDEVMODEA a1,
+ HWND a2,
+ DWORD a3,
+ LPVOID a4)
+ = ChangeDisplaySettingsExA;
+
+LONG(__stdcall* Real_ChangeDisplaySettingsExW)(LPCWSTR a0,
+ LPDEVMODEW a1,
+ HWND a2,
+ DWORD a3,
+ LPVOID a4)
+ = ChangeDisplaySettingsExW;
+
+HANDLE(__stdcall* Real_CreateFileA)(LPCSTR a0,
+ DWORD a1,
+ DWORD a2,
+ LPSECURITY_ATTRIBUTES a3,
+ DWORD a4,
+ DWORD a5,
+ HANDLE a6)
+ = CreateFileA;
+
+HANDLE(__stdcall* Real_CreateFileW)(LPCWSTR a0,
+ DWORD a1,
+ DWORD a2,
+ LPSECURITY_ATTRIBUTES a3,
+ DWORD a4,
+ DWORD a5,
+ HANDLE a6)
+ = CreateFileW;
+
+BOOL (__stdcall* Real_DeviceIoControl)(HANDLE a0,
+ DWORD a1,
+ LPVOID a2,
+ DWORD a3,
+ LPVOID a4,
+ DWORD a5,
+ LPDWORD a6,
+ LPOVERLAPPED a7)
+ = DeviceIoControl;
+
+MMRESULT(__stdcall* Real_mixerSetControlDetails)(HMIXEROBJ hmxobj,
+ LPMIXERCONTROLDETAILS pmxcd,
+ DWORD fdwDetails)
+ = mixerSetControlDetails;
+
+
+typedef NTSTATUS(WINAPI* FUNC_NTQUERYINFORMATIONPROCESS)(HANDLE ProcessHandle, PROCESSINFOCLASS ProcessInformationClass, PVOID ProcessInformation, ULONG ProcessInformationLength, PULONG ReturnLength);
+static FUNC_NTQUERYINFORMATIONPROCESS Real_NtQueryInformationProcess = NULL;
/*
-NTSTATUS (* Real_NtQueryInformationProcess) (HANDLE ProcessHandle,
- PROCESSINFOCLASS ProcessInformationClass,
- PVOID ProcessInformation,
- ULONG ProcessInformationLength,
- PULONG ReturnLength)
- = NULL;
+NTSTATUS (* Real_NtQueryInformationProcess) (HANDLE ProcessHandle,
+ PROCESSINFOCLASS ProcessInformationClass,
+ PVOID ProcessInformation,
+ ULONG ProcessInformationLength,
+ PULONG ReturnLength)
+ = NULL;
*/
BOOL WINAPI Mine_IsDebuggerPresent()
{
- TRACE(_T("Oops, somebody was trying to be naughty! (called IsDebuggerPresent)\n"));
- return FALSE;
+ TRACE(_T("Oops, somebody was trying to be naughty! (called IsDebuggerPresent)\n"));
+ return FALSE;
}
NTSTATUS WINAPI Mine_NtQueryInformationProcess(HANDLE ProcessHandle, PROCESSINFOCLASS ProcessInformationClass, PVOID ProcessInformation, ULONG ProcessInformationLength, PULONG ReturnLength)
{
- NTSTATUS nRet;
+ NTSTATUS nRet;
- nRet = Real_NtQueryInformationProcess(ProcessHandle, ProcessInformationClass, ProcessInformation, ProcessInformationLength, ReturnLength);
+ nRet = Real_NtQueryInformationProcess(ProcessHandle, ProcessInformationClass, ProcessInformation, ProcessInformationLength, ReturnLength);
- if (ProcessInformationClass == ProcessBasicInformation) {
- PROCESS_BASIC_INFORMATION* pbi = (PROCESS_BASIC_INFORMATION*)ProcessInformation;
- PEB_NT* pPEB;
- PEB_NT PEB;
+ if (ProcessInformationClass == ProcessBasicInformation) {
+ PROCESS_BASIC_INFORMATION* pbi = (PROCESS_BASIC_INFORMATION*)ProcessInformation;
+ PEB_NT* pPEB;
+ PEB_NT PEB;
- pPEB = (PEB_NT*)pbi->PebBaseAddress;
- ReadProcessMemory(ProcessHandle, pPEB, &PEB, sizeof(PEB), NULL);
- PEB.BeingDebugged = 0;
- WriteProcessMemory(ProcessHandle, pPEB, &PEB, sizeof(PEB), NULL);
- } else if (ProcessInformationClass == 7) { // ProcessDebugPort
- BOOL* pDebugPort = (BOOL*)ProcessInformation;
- *pDebugPort = FALSE;
- }
+ pPEB = (PEB_NT*)pbi->PebBaseAddress;
+ ReadProcessMemory(ProcessHandle, pPEB, &PEB, sizeof(PEB), NULL);
+ PEB.BeingDebugged = 0;
+ WriteProcessMemory(ProcessHandle, pPEB, &PEB, sizeof(PEB), NULL);
+ } else if (ProcessInformationClass == 7) { // ProcessDebugPort
+ BOOL* pDebugPort = (BOOL*)ProcessInformation;
+ *pDebugPort = FALSE;
+ }
- return nRet;
+ return nRet;
}
LONG WINAPI Mine_ChangeDisplaySettingsEx(LONG ret, DWORD dwFlags, LPVOID lParam)
{
- if (dwFlags&CDS_VIDEOPARAMETERS) {
- VIDEOPARAMETERS* vp = (VIDEOPARAMETERS*)lParam;
+ if (dwFlags & CDS_VIDEOPARAMETERS) {
+ VIDEOPARAMETERS* vp = (VIDEOPARAMETERS*)lParam;
- if (vp->Guid == GUIDFromCString(_T("{02C62061-1097-11d1-920F-00A024DF156E}"))
- && (vp->dwFlags&VP_FLAGS_COPYPROTECT)) {
- if (vp->dwCommand == VP_COMMAND_GET) {
- if ((vp->dwTVStandard&VP_TV_STANDARD_WIN_VGA)
- && vp->dwTVStandard != VP_TV_STANDARD_WIN_VGA) {
- TRACE(_T("Ooops, tv-out enabled? macrovision checks suck..."));
- vp->dwTVStandard = VP_TV_STANDARD_WIN_VGA;
- }
- } else if (vp->dwCommand == VP_COMMAND_SET) {
- TRACE(_T("Ooops, as I already told ya, no need for any macrovision bs here"));
- return 0;
- }
- }
- }
+ if (vp->Guid == GUIDFromCString(_T("{02C62061-1097-11d1-920F-00A024DF156E}"))
+ && (vp->dwFlags & VP_FLAGS_COPYPROTECT)) {
+ if (vp->dwCommand == VP_COMMAND_GET) {
+ if ((vp->dwTVStandard & VP_TV_STANDARD_WIN_VGA)
+ && vp->dwTVStandard != VP_TV_STANDARD_WIN_VGA) {
+ TRACE(_T("Ooops, tv-out enabled? macrovision checks suck..."));
+ vp->dwTVStandard = VP_TV_STANDARD_WIN_VGA;
+ }
+ } else if (vp->dwCommand == VP_COMMAND_SET) {
+ TRACE(_T("Ooops, as I already told ya, no need for any macrovision bs here"));
+ return 0;
+ }
+ }
+ }
- return ret;
+ return ret;
}
LONG WINAPI Mine_ChangeDisplaySettingsExA(LPCSTR lpszDeviceName, LPDEVMODEA lpDevMode, HWND hwnd, DWORD dwFlags, LPVOID lParam)
{
- return Mine_ChangeDisplaySettingsEx(
- Real_ChangeDisplaySettingsExA(lpszDeviceName, lpDevMode, hwnd, dwFlags, lParam),
- dwFlags,
- lParam);
+ return Mine_ChangeDisplaySettingsEx(
+ Real_ChangeDisplaySettingsExA(lpszDeviceName, lpDevMode, hwnd, dwFlags, lParam),
+ dwFlags,
+ lParam);
}
LONG WINAPI Mine_ChangeDisplaySettingsExW(LPCWSTR lpszDeviceName, LPDEVMODEW lpDevMode, HWND hwnd, DWORD dwFlags, LPVOID lParam)
{
- return Mine_ChangeDisplaySettingsEx(
- Real_ChangeDisplaySettingsExW(lpszDeviceName, lpDevMode, hwnd, dwFlags, lParam),
- dwFlags,
- lParam);
+ return Mine_ChangeDisplaySettingsEx(
+ Real_ChangeDisplaySettingsExW(lpszDeviceName, lpDevMode, hwnd, dwFlags, lParam),
+ dwFlags,
+ lParam);
}
HANDLE WINAPI Mine_CreateFileA(LPCSTR p1, DWORD p2, DWORD p3, LPSECURITY_ATTRIBUTES p4, DWORD p5, DWORD p6, HANDLE p7)
{
- //CStringA fn(p1);
- //fn.MakeLower();
- //int i = fn.Find(".part");
- //if (i > 0 && i == fn.GetLength() - 5)
- p3 |= FILE_SHARE_WRITE;
+ //CStringA fn(p1);
+ //fn.MakeLower();
+ //int i = fn.Find(".part");
+ //if (i > 0 && i == fn.GetLength() - 5)
+ p3 |= FILE_SHARE_WRITE;
- return Real_CreateFileA(p1, p2, p3, p4, p5, p6, p7);
+ return Real_CreateFileA(p1, p2, p3, p4, p5, p6, p7);
}
BOOL CreateFakeVideoTS(LPCWSTR strIFOPath, LPWSTR strFakeFile, size_t nFakeFileSize)
{
- BOOL bRet = FALSE;
- WCHAR szTempPath[_MAX_PATH];
- WCHAR strFileName[_MAX_PATH];
- WCHAR strExt[_MAX_EXT];
- CIfo Ifo;
+ BOOL bRet = FALSE;
+ WCHAR szTempPath[_MAX_PATH];
+ WCHAR strFileName[_MAX_PATH];
+ WCHAR strExt[_MAX_EXT];
+ CIfo Ifo;
- if (!GetTempPathW(_MAX_PATH, szTempPath)) {
- return FALSE;
- }
+ if (!GetTempPathW(_MAX_PATH, szTempPath)) {
+ return FALSE;
+ }
- _wsplitpath_s (strIFOPath, NULL, 0, NULL, 0, strFileName, _countof(strFileName), strExt, _countof(strExt));
- _snwprintf_s (strFakeFile, nFakeFileSize, _TRUNCATE, L"%sMPC%s%s", szTempPath, strFileName, strExt);
+ _wsplitpath_s(strIFOPath, NULL, 0, NULL, 0, strFileName, _countof(strFileName), strExt, _countof(strExt));
+ _snwprintf_s(strFakeFile, nFakeFileSize, _TRUNCATE, L"%sMPC%s%s", szTempPath, strFileName, strExt);
- if (Ifo.OpenFile (strIFOPath) &&
- Ifo.RemoveUOPs() &&
- Ifo.SaveFile (strFakeFile)) {
- bRet = TRUE;
- }
+ if (Ifo.OpenFile(strIFOPath) &&
+ Ifo.RemoveUOPs() &&
+ Ifo.SaveFile(strFakeFile)) {
+ bRet = TRUE;
+ }
- return bRet;
+ return bRet;
}
HANDLE WINAPI Mine_CreateFileW(LPCWSTR p1, DWORD p2, DWORD p3, LPSECURITY_ATTRIBUTES p4, DWORD p5, DWORD p6, HANDLE p7)
{
- HANDLE hFile = INVALID_HANDLE_VALUE;
- WCHAR strFakeFile[_MAX_PATH];
- size_t nLen = wcslen(p1);
+ HANDLE hFile = INVALID_HANDLE_VALUE;
+ WCHAR strFakeFile[_MAX_PATH];
+ size_t nLen = wcslen(p1);
- p3 |= FILE_SHARE_WRITE;
+ p3 |= FILE_SHARE_WRITE;
- if (nLen >= 4 && _wcsicmp(p1 + nLen - 4, L".ifo") == 0) {
- if (CreateFakeVideoTS(p1, strFakeFile, _countof(strFakeFile))) {
- hFile = Real_CreateFileW(strFakeFile, p2, p3, p4, p5, p6, p7);
- }
- }
+ if (nLen >= 4 && _wcsicmp(p1 + nLen - 4, L".ifo") == 0) {
+ if (CreateFakeVideoTS(p1, strFakeFile, _countof(strFakeFile))) {
+ hFile = Real_CreateFileW(strFakeFile, p2, p3, p4, p5, p6, p7);
+ }
+ }
- if (hFile == INVALID_HANDLE_VALUE) {
- hFile = Real_CreateFileW(p1, p2, p3, p4, p5, p6, p7);
- }
+ if (hFile == INVALID_HANDLE_VALUE) {
+ hFile = Real_CreateFileW(p1, p2, p3, p4, p5, p6, p7);
+ }
- return hFile;
+ return hFile;
}
MMRESULT WINAPI Mine_mixerSetControlDetails(HMIXEROBJ hmxobj, LPMIXERCONTROLDETAILS pmxcd, DWORD fdwDetails)
{
- if (fdwDetails == (MIXER_OBJECTF_HMIXER|MIXER_SETCONTROLDETAILSF_VALUE)) {
- return MMSYSERR_NOERROR; // don't touch the mixer, kthx
- }
- return Real_mixerSetControlDetails(hmxobj, pmxcd, fdwDetails);
+ if (fdwDetails == (MIXER_OBJECTF_HMIXER | MIXER_SETCONTROLDETAILSF_VALUE)) {
+ return MMSYSERR_NOERROR; // don't touch the mixer, kthx
+ }
+ return Real_mixerSetControlDetails(hmxobj, pmxcd, fdwDetails);
}
BOOL WINAPI Mine_DeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped)
{
- BOOL ret = Real_DeviceIoControl(hDevice, dwIoControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpOverlapped);
+ BOOL ret = Real_DeviceIoControl(hDevice, dwIoControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpOverlapped);
- if (IOCTL_DVD_GET_REGION == dwIoControlCode && lpOutBuffer
- && lpBytesReturned && *lpBytesReturned == sizeof(DVD_REGION)) {
- DVD_REGION* pDVDRegion = (DVD_REGION*)lpOutBuffer;
- pDVDRegion->SystemRegion = ~pDVDRegion->RegionData;
- }
+ if (IOCTL_DVD_GET_REGION == dwIoControlCode && lpOutBuffer
+ && lpBytesReturned && *lpBytesReturned == sizeof(DVD_REGION)) {
+ DVD_REGION* pDVDRegion = (DVD_REGION*)lpOutBuffer;
+ pDVDRegion->SystemRegion = ~pDVDRegion->RegionData;
+ }
- return ret;
+ return ret;
}
BOOL SetHeapOptions()
{
- HMODULE hLib = LoadLibrary(L"kernel32.dll");
- if (hLib == NULL) {
- return FALSE;
- }
+ HMODULE hLib = LoadLibrary(L"kernel32.dll");
+ if (hLib == NULL) {
+ return FALSE;
+ }
- typedef BOOL (WINAPI *HSI)
- (HANDLE, HEAP_INFORMATION_CLASS ,PVOID, SIZE_T);
- HSI pHsi = (HSI)GetProcAddress(hLib,"HeapSetInformation");
- if (!pHsi) {
- FreeLibrary(hLib);
- return FALSE;
- }
+ typedef BOOL (WINAPI * HSI)
+ (HANDLE, HEAP_INFORMATION_CLASS , PVOID, SIZE_T);
+ HSI pHsi = (HSI)GetProcAddress(hLib, "HeapSetInformation");
+ if (!pHsi) {
+ FreeLibrary(hLib);
+ return FALSE;
+ }
#ifndef HeapEnableTerminationOnCorruption
-# define HeapEnableTerminationOnCorruption (HEAP_INFORMATION_CLASS)1
+# define HeapEnableTerminationOnCorruption (HEAP_INFORMATION_CLASS)1
#endif
- BOOL fRet = (pHsi)(NULL,HeapEnableTerminationOnCorruption,NULL,0)
- ? TRUE
- : FALSE;
- if (hLib) {
- FreeLibrary(hLib);
- }
+ BOOL fRet = (pHsi)(NULL, HeapEnableTerminationOnCorruption, NULL, 0)
+ ? TRUE
+ : FALSE;
+ if (hLib) {
+ FreeLibrary(hLib);
+ }
- return fRet;
+ return fRet;
}
BOOL CMPlayerCApp::InitInstance()
{
- // Remove the working directory from the search path to work around the DLL preloading vulnerability
- SetDllDirectory(_T(""));
+ // Remove the working directory from the search path to work around the DLL preloading vulnerability
+ SetDllDirectory(_T(""));
- long lError;
+ long lError;
#ifdef GOTHTRACE
- // Used for tracing when debugger can't be used, e.g. when using some commercial decoders
- // Print traces usint _tprintf_s()
- if (AllocConsole()) {
- FILE * foo; // Not used
- freopen_s(&foo, "conin$", "r", stdin); // Redirect stdin etc. to console
- freopen_s(&foo, "conout$", "w", stdout);
- freopen_s(&foo, "conout$", "w", stderr);
- } else {
- AfxMessageBox(_T("Could not create console"));
- }
+ // Used for tracing when debugger can't be used, e.g. when using some commercial decoders
+ // Print traces usint _tprintf_s()
+ if (AllocConsole()) {
+ FILE* foo; // Not used
+ freopen_s(&foo, "conin$", "r", stdin); // Redirect stdin etc. to console
+ freopen_s(&foo, "conout$", "w", stdout);
+ freopen_s(&foo, "conout$", "w", stderr);
+ } else {
+ AfxMessageBox(_T("Could not create console"));
+ }
#endif
- if (SetHeapOptions()) {
- TRACE(_T("Terminate on corruption enabled\n"));
- } else {
- CString heap_err;
- heap_err.Format(_T("Terminate on corruption error = %d\n"), GetLastError());
- TRACE(heap_err);
- }
-
- DetourRestoreAfterWith();
- DetourTransactionBegin();
- DetourUpdateThread(GetCurrentThread());
-
- DetourAttach(&(PVOID&)Real_IsDebuggerPresent, (PVOID)Mine_IsDebuggerPresent);
- DetourAttach(&(PVOID&)Real_ChangeDisplaySettingsExA, (PVOID)Mine_ChangeDisplaySettingsExA);
- DetourAttach(&(PVOID&)Real_ChangeDisplaySettingsExW, (PVOID)Mine_ChangeDisplaySettingsExW);
- DetourAttach(&(PVOID&)Real_CreateFileA, (PVOID)Mine_CreateFileA);
- DetourAttach(&(PVOID&)Real_CreateFileW, (PVOID)Mine_CreateFileW);
- DetourAttach(&(PVOID&)Real_mixerSetControlDetails, (PVOID)Mine_mixerSetControlDetails);
- DetourAttach(&(PVOID&)Real_DeviceIoControl, (PVOID)Mine_DeviceIoControl);
-
- HMODULE hNTDLL = LoadLibrary (_T("ntdll.dll"));
-#ifndef _DEBUG // Disable NtQueryInformationProcess in debug (prevent VS debugger to stop on crash address)
- if (hNTDLL) {
- Real_NtQueryInformationProcess = (FUNC_NTQUERYINFORMATIONPROCESS)GetProcAddress (hNTDLL, "NtQueryInformationProcess");
-
- if (Real_NtQueryInformationProcess) {
- DetourAttach(&(PVOID&)Real_NtQueryInformationProcess, (PVOID)Mine_NtQueryInformationProcess);
- }
- }
+ if (SetHeapOptions()) {
+ TRACE(_T("Terminate on corruption enabled\n"));
+ } else {
+ CString heap_err;
+ heap_err.Format(_T("Terminate on corruption error = %d\n"), GetLastError());
+ TRACE(heap_err);
+ }
+
+ DetourRestoreAfterWith();
+ DetourTransactionBegin();
+ DetourUpdateThread(GetCurrentThread());
+
+ DetourAttach(&(PVOID&)Real_IsDebuggerPresent, (PVOID)Mine_IsDebuggerPresent);
+ DetourAttach(&(PVOID&)Real_ChangeDisplaySettingsExA, (PVOID)Mine_ChangeDisplaySettingsExA);
+ DetourAttach(&(PVOID&)Real_ChangeDisplaySettingsExW, (PVOID)Mine_ChangeDisplaySettingsExW);
+ DetourAttach(&(PVOID&)Real_CreateFileA, (PVOID)Mine_CreateFileA);
+ DetourAttach(&(PVOID&)Real_CreateFileW, (PVOID)Mine_CreateFileW);
+ DetourAttach(&(PVOID&)Real_mixerSetControlDetails, (PVOID)Mine_mixerSetControlDetails);
+ DetourAttach(&(PVOID&)Real_DeviceIoControl, (PVOID)Mine_DeviceIoControl);
+
+ HMODULE hNTDLL = LoadLibrary(_T("ntdll.dll"));
+#ifndef _DEBUG // Disable NtQueryInformationProcess in debug (prevent VS debugger to stop on crash address)
+ if (hNTDLL) {
+ Real_NtQueryInformationProcess = (FUNC_NTQUERYINFORMATIONPROCESS)GetProcAddress(hNTDLL, "NtQueryInformationProcess");
+
+ if (Real_NtQueryInformationProcess) {
+ DetourAttach(&(PVOID&)Real_NtQueryInformationProcess, (PVOID)Mine_NtQueryInformationProcess);
+ }
+ }
#endif
- CFilterMapper2::Init();
-
- lError = DetourTransactionCommit();
- ASSERT (lError == NOERROR);
-
- HRESULT hr;
- if (FAILED(hr = OleInitialize(0))) {
- AfxMessageBox(_T("OleInitialize failed!"));
- return FALSE;
- }
-
- WNDCLASS wndcls;
- memset(&wndcls, 0, sizeof(WNDCLASS));
- wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
- wndcls.lpfnWndProc = ::DefWindowProc;
- wndcls.hInstance = AfxGetInstanceHandle();
- wndcls.hIcon = LoadIcon(IDR_MAINFRAME);
- wndcls.hCursor = LoadCursor(IDC_ARROW);
- wndcls.hbrBackground = 0;//(HBRUSH)(COLOR_WINDOW + 1); // no bkg brush, the view and the bars should always fill the whole client area
- wndcls.lpszMenuName = NULL;
- wndcls.lpszClassName = MPC_WND_CLASS_NAME;
-
- if (!AfxRegisterClass(&wndcls)) {
- AfxMessageBox(_T("MainFrm class registration failed!"));
- return FALSE;
- }
-
- if (!AfxSocketInit(NULL)) {
- AfxMessageBox(_T("AfxSocketInit failed!"));
- return FALSE;
- }
-
- PreProcessCommandLine();
-
- if (IsIniValid()) {
- StoreSettingsToIni();
- } else {
- StoreSettingsToRegistry();
- }
-
- m_s.ParseCommandLine(m_cmdln);
-
- if (m_s.nCLSwitches & (CLSW_HELP | CLSW_UNRECOGNIZEDSWITCH)) { // show comandline help window
- m_s.UpdateData(false);
- ShowCmdlnSwitches();
- return FALSE;
- }
-
- if (m_s.nCLSwitches & CLSW_RESET) { // reset settings
- // We want the other instances to be closed before resetting the settings.
- HWND hWnd = FindWindow(MPC_WND_CLASS_NAME, NULL);
-
- while (hWnd) {
- Sleep(500);
-
- hWnd = FindWindow(MPC_WND_CLASS_NAME, NULL);
-
- if (hWnd && MessageBox(NULL, ResStr(IDS_RESET_SETTINGS_MUTEX), ResStr(IDS_RESET_SETTINGS), MB_ICONEXCLAMATION | MB_RETRYCANCEL) == IDCANCEL) {
- return FALSE;
- }
- }
-
- // Remove the settings
- if (IsIniValid()) {
- CFile::Remove(GetIniPath());
- } else {
- HKEY reg = GetAppRegistryKey();
- SHDeleteKey(reg, _T(""));
- RegCloseKey(reg);
- }
-
- // Remove the current playlist if it exists
- CString strSavePath;
- if (AfxGetMyApp()->GetAppSavePath(strSavePath)) {
- CPath playlistPath;
- playlistPath.Combine(strSavePath, _T("default.mpcpl"));
-
- CFileStatus status;
- if (CFile::GetStatus(playlistPath, status)) {
- CFile::Remove(playlistPath);
- }
- }
- }
-
- if ((m_s.nCLSwitches&CLSW_CLOSE) && m_s.slFiles.IsEmpty()) { // "/close" switch and empty file list
- return FALSE;
- }
-
- if (m_s.nCLSwitches & (CLSW_REGEXTVID | CLSW_REGEXTAUD | CLSW_REGEXTPL)) { // register file types
- CPPageFormats::RegisterApp();
-
- CMediaFormats& mf = m_s.m_Formats;
- mf.UpdateData(false);
-
- bool bAudioOnly, bPlaylist;
-
- for (unsigned int i = 0; i < mf.GetCount(); i++) {
- bPlaylist = !mf[i].GetLabel().CompareNoCase(_T("pls"));
-
- if (bPlaylist && !(m_s.nCLSwitches & CLSW_REGEXTPL)) {
- continue;
- }
-
- bAudioOnly = mf[i].IsAudioOnly();
-
- int j = 0;
- CString str = mf[i].GetExtsWithPeriod();
- for (CString ext = str.Tokenize(_T(" "), j); !ext.IsEmpty(); ext = str.Tokenize(_T(" "), j)) {
- if (((m_s.nCLSwitches & CLSW_REGEXTVID) && !bAudioOnly) ||
- ((m_s.nCLSwitches & CLSW_REGEXTAUD) && bAudioOnly) ||
- ((m_s.nCLSwitches & CLSW_REGEXTPL) && bPlaylist)) {
- CPPageFormats::RegisterExt(ext, mf[i].GetDescription(), true);
- }
- }
- }
- SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
-
- return FALSE;
- }
-
- if ((m_s.nCLSwitches&CLSW_UNREGEXT)) { // unregistered file types
- CMediaFormats& mf = m_s.m_Formats;
- mf.UpdateData(false);
-
- for (unsigned int i = 0; i < mf.GetCount(); i++) {
- int j = 0;
- CString str = mf[i].GetExtsWithPeriod();
- for (CString ext = str.Tokenize(_T(" "), j); !ext.IsEmpty(); ext = str.Tokenize(_T(" "), j)) {
- CPPageFormats::RegisterExt(ext, mf[i].GetDescription(), false);
- }
- }
- SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
-
- return FALSE;
- }
-
- // Enable to open options with administrator privilege (for Vista UAC)
- if (m_s.nCLSwitches & CLSW_ADMINOPTION) {
- m_s.UpdateData(false); // read all settings. long time but not critical at this point
-
- switch (m_s.iAdminOption) {
- case CPPageFormats::IDD : {
- CPPageSheet options(ResStr(IDS_OPTIONS_CAPTION), NULL, NULL, m_s.iAdminOption);
- options.LockPage();
- options.DoModal();
- }
- break;
-
- default :
- ASSERT (FALSE);
- }
- return FALSE;
- }
-
- m_mutexOneInstance.Create(NULL, TRUE, MPC_WND_CLASS_NAME);
-
- if ( GetLastError() == ERROR_ALREADY_EXISTS &&
- (!(m_s.GetAllowMultiInst() || m_s.nCLSwitches&CLSW_NEW || m_cmdln.IsEmpty()) || m_s.nCLSwitches&CLSW_ADD) ) {
-
- DWORD res = WaitForSingleObject(m_mutexOneInstance.m_h, 5000);
- if (res==WAIT_OBJECT_0 || res==WAIT_ABANDONED) {
- HWND hWnd = ::FindWindow(MPC_WND_CLASS_NAME, NULL);
- if (hWnd) {
- SetForegroundWindow(hWnd);
- if (!(m_s.nCLSwitches&CLSW_MINIMIZED) && IsIconic(hWnd)) {
- ShowWindow(hWnd, SW_RESTORE);
- }
- if (SendCommandLine(hWnd)) {
- m_mutexOneInstance.Close();
- return FALSE;
- }
- }
- }
- }
-
- m_s.UpdateData(false); // read settings
-
- // If we use an ASCII ini file, let's recreate it to switch to UTF-16LE
- if (IsIniValid() && !IsIniUTF16LE()) {
- ChangeSettingsLocation(true);
- }
-
- AfxGetMyApp()->m_AudioRendererDisplayName_CL = _T("");
-
- if (!__super::InitInstance()) {
- AfxMessageBox(_T("InitInstance failed!"));
- return FALSE;
- }
-
- CRegKey key;
- if (ERROR_SUCCESS == key.Create(HKEY_LOCAL_MACHINE, _T("Software\\Gabest\\Media Player Classic"))) {
- CString path;
- GetModuleFileName(AfxGetInstanceHandle(), path.GetBuffer(_MAX_PATH), _MAX_PATH);
- path.ReleaseBuffer();
- key.SetStringValue(_T("ExePath"), path);
- }
-
- AfxEnableControlContainer();
-
- CMainFrame* pFrame = DNew CMainFrame;
- m_pMainWnd = pFrame;
- if ( !pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW|FWS_ADDTOTITLE, NULL, NULL) ) {
- AfxMessageBox(_T("CMainFrame::LoadFrame failed!"));
- return FALSE;
- }
- pFrame->SetDefaultWindowRect((m_s.nCLSwitches&CLSW_MONITOR)?m_s.iMonitor:0);
- pFrame->RestoreControlBars();
- pFrame->SetDefaultFullscreenState();
- pFrame->SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME), TRUE);
- pFrame->DragAcceptFiles();
- pFrame->ShowWindow((m_s.nCLSwitches&CLSW_MINIMIZED)?SW_SHOWMINIMIZED:SW_SHOW);
- pFrame->UpdateWindow();
- pFrame->m_hAccelTable = m_s.hAccel;
- m_s.WinLircClient.SetHWND(m_pMainWnd->m_hWnd);
- if (m_s.fWinLirc) {
- m_s.WinLircClient.Connect(m_s.strWinLircAddr);
- }
- m_s.UIceClient.SetHWND(m_pMainWnd->m_hWnd);
- if (m_s.fUIce) {
- m_s.UIceClient.Connect(m_s.strUIceAddr);
- }
-
- SendCommandLine(m_pMainWnd->m_hWnd);
- RegisterHotkeys();
-
- pFrame->SetFocus();
-
- // set HIGH I/O Priority for better playback perfomance
- if (hNTDLL) {
- typedef NTSTATUS (WINAPI *FUNC_NTSETINFORMATIONPROCESS)(HANDLE, ULONG, PVOID, ULONG);
- FUNC_NTSETINFORMATIONPROCESS NtSetInformationProcess = (FUNC_NTSETINFORMATIONPROCESS)GetProcAddress (hNTDLL, "NtSetInformationProcess");
-
- if (NtSetInformationProcess && SetPrivilege(SE_INC_BASE_PRIORITY_NAME)) {
- ULONG IoPriority = 3;
- ULONG ProcessIoPriority = 0x21;
- NTSTATUS NtStatus = NtSetInformationProcess(GetCurrentProcess(), ProcessIoPriority, &IoPriority, sizeof(ULONG));
- TRACE(_T("Set I/O Priority - %d\n"), NtStatus);
+ CFilterMapper2::Init();
+
+ lError = DetourTransactionCommit();
+ ASSERT(lError == NOERROR);
+
+ HRESULT hr;
+ if (FAILED(hr = OleInitialize(0))) {
+ AfxMessageBox(_T("OleInitialize failed!"));
+ return FALSE;
+ }
+
+ WNDCLASS wndcls;
+ memset(&wndcls, 0, sizeof(WNDCLASS));
+ wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
+ wndcls.lpfnWndProc = ::DefWindowProc;
+ wndcls.hInstance = AfxGetInstanceHandle();
+ wndcls.hIcon = LoadIcon(IDR_MAINFRAME);
+ wndcls.hCursor = LoadCursor(IDC_ARROW);
+ wndcls.hbrBackground = 0;//(HBRUSH)(COLOR_WINDOW + 1); // no bkg brush, the view and the bars should always fill the whole client area
+ wndcls.lpszMenuName = NULL;
+ wndcls.lpszClassName = MPC_WND_CLASS_NAME;
+
+ if (!AfxRegisterClass(&wndcls)) {
+ AfxMessageBox(_T("MainFrm class registration failed!"));
+ return FALSE;
+ }
+
+ if (!AfxSocketInit(NULL)) {
+ AfxMessageBox(_T("AfxSocketInit failed!"));
+ return FALSE;
+ }
+
+ PreProcessCommandLine();
+
+ if (IsIniValid()) {
+ StoreSettingsToIni();
+ } else {
+ StoreSettingsToRegistry();
+ }
+
+ m_s.ParseCommandLine(m_cmdln);
+
+ if (m_s.nCLSwitches & (CLSW_HELP | CLSW_UNRECOGNIZEDSWITCH)) { // show comandline help window
+ m_s.UpdateData(false);
+ ShowCmdlnSwitches();
+ return FALSE;
+ }
+
+ if (m_s.nCLSwitches & CLSW_RESET) { // reset settings
+ // We want the other instances to be closed before resetting the settings.
+ HWND hWnd = FindWindow(MPC_WND_CLASS_NAME, NULL);
+
+ while (hWnd) {
+ Sleep(500);
+
+ hWnd = FindWindow(MPC_WND_CLASS_NAME, NULL);
+
+ if (hWnd && MessageBox(NULL, ResStr(IDS_RESET_SETTINGS_MUTEX), ResStr(IDS_RESET_SETTINGS), MB_ICONEXCLAMATION | MB_RETRYCANCEL) == IDCANCEL) {
+ return FALSE;
+ }
+ }
+
+ // Remove the settings
+ if (IsIniValid()) {
+ CFile::Remove(GetIniPath());
+ } else {
+ HKEY reg = GetAppRegistryKey();
+ SHDeleteKey(reg, _T(""));
+ RegCloseKey(reg);
+ }
+
+ // Remove the current playlist if it exists
+ CString strSavePath;
+ if (AfxGetMyApp()->GetAppSavePath(strSavePath)) {
+ CPath playlistPath;
+ playlistPath.Combine(strSavePath, _T("default.mpcpl"));
+
+ CFileStatus status;
+ if (CFile::GetStatus(playlistPath, status)) {
+ CFile::Remove(playlistPath);
+ }
+ }
+ }
+
+ if ((m_s.nCLSwitches & CLSW_CLOSE) && m_s.slFiles.IsEmpty()) { // "/close" switch and empty file list
+ return FALSE;
+ }
+
+ if (m_s.nCLSwitches & (CLSW_REGEXTVID | CLSW_REGEXTAUD | CLSW_REGEXTPL)) { // register file types
+ CPPageFormats::RegisterApp();
+
+ CMediaFormats& mf = m_s.m_Formats;
+ mf.UpdateData(false);
+
+ bool bAudioOnly, bPlaylist;
+
+ for (unsigned int i = 0; i < mf.GetCount(); i++) {
+ bPlaylist = !mf[i].GetLabel().CompareNoCase(_T("pls"));
+
+ if (bPlaylist && !(m_s.nCLSwitches & CLSW_REGEXTPL)) {
+ continue;
+ }
+
+ bAudioOnly = mf[i].IsAudioOnly();
+
+ int j = 0;
+ CString str = mf[i].GetExtsWithPeriod();
+ for (CString ext = str.Tokenize(_T(" "), j); !ext.IsEmpty(); ext = str.Tokenize(_T(" "), j)) {
+ if (((m_s.nCLSwitches & CLSW_REGEXTVID) && !bAudioOnly) ||
+ ((m_s.nCLSwitches & CLSW_REGEXTAUD) && bAudioOnly) ||
+ ((m_s.nCLSwitches & CLSW_REGEXTPL) && bPlaylist)) {
+ CPPageFormats::RegisterExt(ext, mf[i].GetDescription(), true);
+ }
+ }
+ }
+ SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
+
+ return FALSE;
+ }
+
+ if ((m_s.nCLSwitches & CLSW_UNREGEXT)) { // unregistered file types
+ CMediaFormats& mf = m_s.m_Formats;
+ mf.UpdateData(false);
+
+ for (unsigned int i = 0; i < mf.GetCount(); i++) {
+ int j = 0;
+ CString str = mf[i].GetExtsWithPeriod();
+ for (CString ext = str.Tokenize(_T(" "), j); !ext.IsEmpty(); ext = str.Tokenize(_T(" "), j)) {
+ CPPageFormats::RegisterExt(ext, mf[i].GetDescription(), false);
+ }
+ }
+ SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
+
+ return FALSE;
+ }
+
+ // Enable to open options with administrator privilege (for Vista UAC)
+ if (m_s.nCLSwitches & CLSW_ADMINOPTION) {
+ m_s.UpdateData(false); // read all settings. long time but not critical at this point
+
+ switch (m_s.iAdminOption) {
+ case CPPageFormats::IDD : {
+ CPPageSheet options(ResStr(IDS_OPTIONS_CAPTION), NULL, NULL, m_s.iAdminOption);
+ options.LockPage();
+ options.DoModal();
+ }
+ break;
+
+ default :
+ ASSERT(FALSE);
+ }
+ return FALSE;
+ }
+
+ m_mutexOneInstance.Create(NULL, TRUE, MPC_WND_CLASS_NAME);
+
+ if (GetLastError() == ERROR_ALREADY_EXISTS &&
+ (!(m_s.GetAllowMultiInst() || m_s.nCLSwitches & CLSW_NEW || m_cmdln.IsEmpty()) || m_s.nCLSwitches & CLSW_ADD)) {
+
+ DWORD res = WaitForSingleObject(m_mutexOneInstance.m_h, 5000);
+ if (res == WAIT_OBJECT_0 || res == WAIT_ABANDONED) {
+ HWND hWnd = ::FindWindow(MPC_WND_CLASS_NAME, NULL);
+ if (hWnd) {
+ SetForegroundWindow(hWnd);
+ if (!(m_s.nCLSwitches & CLSW_MINIMIZED) && IsIconic(hWnd)) {
+ ShowWindow(hWnd, SW_RESTORE);
+ }
+ if (SendCommandLine(hWnd)) {
+ m_mutexOneInstance.Close();
+ return FALSE;
+ }
+ }
+ }
+ }
+
+ m_s.UpdateData(false); // read settings
+
+ // If we use an ASCII ini file, let's recreate it to switch to UTF-16LE
+ if (IsIniValid() && !IsIniUTF16LE()) {
+ ChangeSettingsLocation(true);
+ }
+
+ AfxGetMyApp()->m_AudioRendererDisplayName_CL = _T("");
+
+ if (!__super::InitInstance()) {
+ AfxMessageBox(_T("InitInstance failed!"));
+ return FALSE;
+ }
+
+ CRegKey key;
+ if (ERROR_SUCCESS == key.Create(HKEY_LOCAL_MACHINE, _T("Software\\Gabest\\Media Player Classic"))) {
+ CString path;
+ GetModuleFileName(AfxGetInstanceHandle(), path.GetBuffer(_MAX_PATH), _MAX_PATH);
+ path.ReleaseBuffer();
+ key.SetStringValue(_T("ExePath"), path);
+ }
+
+ AfxEnableControlContainer();
+
+ CMainFrame* pFrame = DNew CMainFrame;
+ m_pMainWnd = pFrame;
+ if (!pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, NULL)) {
+ AfxMessageBox(_T("CMainFrame::LoadFrame failed!"));
+ return FALSE;
+ }
+ pFrame->SetDefaultWindowRect((m_s.nCLSwitches & CLSW_MONITOR) ? m_s.iMonitor : 0);
+ pFrame->RestoreControlBars();
+ pFrame->SetDefaultFullscreenState();
+ pFrame->SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME), TRUE);
+ pFrame->DragAcceptFiles();
+ pFrame->ShowWindow((m_s.nCLSwitches & CLSW_MINIMIZED) ? SW_SHOWMINIMIZED : SW_SHOW);
+ pFrame->UpdateWindow();
+ pFrame->m_hAccelTable = m_s.hAccel;
+ m_s.WinLircClient.SetHWND(m_pMainWnd->m_hWnd);
+ if (m_s.fWinLirc) {
+ m_s.WinLircClient.Connect(m_s.strWinLircAddr);
+ }
+ m_s.UIceClient.SetHWND(m_pMainWnd->m_hWnd);
+ if (m_s.fUIce) {
+ m_s.UIceClient.Connect(m_s.strUIceAddr);
+ }
+
+ SendCommandLine(m_pMainWnd->m_hWnd);
+ RegisterHotkeys();
+
+ pFrame->SetFocus();
+
+ // set HIGH I/O Priority for better playback perfomance
+ if (hNTDLL) {
+ typedef NTSTATUS(WINAPI * FUNC_NTSETINFORMATIONPROCESS)(HANDLE, ULONG, PVOID, ULONG);
+ FUNC_NTSETINFORMATIONPROCESS NtSetInformationProcess = (FUNC_NTSETINFORMATIONPROCESS)GetProcAddress(hNTDLL, "NtSetInformationProcess");
+
+ if (NtSetInformationProcess && SetPrivilege(SE_INC_BASE_PRIORITY_NAME)) {
+ ULONG IoPriority = 3;
+ ULONG ProcessIoPriority = 0x21;
+ NTSTATUS NtStatus = NtSetInformationProcess(GetCurrentProcess(), ProcessIoPriority, &IoPriority, sizeof(ULONG));
+ TRACE(_T("Set I/O Priority - %d\n"), NtStatus);
#ifndef _DEBUG
- UNREFERENCED_PARAMETER(NtStatus);
+ UNREFERENCED_PARAMETER(NtStatus);
#endif
- }
+ }
- FreeLibrary( hNTDLL );
- hNTDLL = NULL;
- }
+ FreeLibrary(hNTDLL);
+ hNTDLL = NULL;
+ }
- m_mutexOneInstance.Release();
+ m_mutexOneInstance.Release();
- if (UpdateChecker::IsAutoUpdateEnabled()) {
- UpdateChecker::CheckForUpdate(true);
- }
+ if (UpdateChecker::IsAutoUpdateEnabled()) {
+ UpdateChecker::CheckForUpdate(true);
+ }
- return TRUE;
+ return TRUE;
}
UINT CMPlayerCApp::GetRemoteControlCodeMicrosoft(UINT nInputcode, HRAWINPUT hRawInput)
{
- UINT dwSize = 0;
- BYTE* pRawBuffer = NULL;
- UINT nMceCmd = 0;
+ UINT dwSize = 0;
+ BYTE* pRawBuffer = NULL;
+ UINT nMceCmd = 0;
- // Support for MCE remote control
- GetRawInputData(hRawInput, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER));
- if (dwSize > 0) {
- pRawBuffer = DNew BYTE[dwSize];
- if (GetRawInputData(hRawInput, RID_INPUT, pRawBuffer, &dwSize, sizeof(RAWINPUTHEADER)) != -1) {
- RAWINPUT* raw = (RAWINPUT*) pRawBuffer;
- if (raw->header.dwType == RIM_TYPEHID) {
- nMceCmd = 0x10000 + (raw->data.hid.bRawData[1] | raw->data.hid.bRawData[2] << 8);
- }
- }
- delete [] pRawBuffer;
- }
+ // Support for MCE remote control
+ GetRawInputData(hRawInput, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER));
+ if (dwSize > 0) {
+ pRawBuffer = DNew BYTE[dwSize];
+ if (GetRawInputData(hRawInput, RID_INPUT, pRawBuffer, &dwSize, sizeof(RAWINPUTHEADER)) != -1) {
+ RAWINPUT* raw = (RAWINPUT*) pRawBuffer;
+ if (raw->header.dwType == RIM_TYPEHID) {
+ nMceCmd = 0x10000 + (raw->data.hid.bRawData[1] | raw->data.hid.bRawData[2] << 8);
+ }
+ }
+ delete [] pRawBuffer;
+ }
- return nMceCmd;
+ return nMceCmd;
}
UINT CMPlayerCApp::GetRemoteControlCodeSRM7500(UINT nInputcode, HRAWINPUT hRawInput)
{
- UINT dwSize = 0;
- BYTE* pRawBuffer = NULL;
- UINT nMceCmd = 0;
-
- GetRawInputData(hRawInput, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER));
- if (dwSize > 21) {
- pRawBuffer = DNew BYTE[dwSize];
- if (GetRawInputData(hRawInput, RID_INPUT, pRawBuffer, &dwSize, sizeof(RAWINPUTHEADER)) != -1) {
- RAWINPUT* raw = (RAWINPUT*) pRawBuffer;
-
- // data.hid.bRawData[21] set to one when key is pressed
- if (raw->header.dwType == RIM_TYPEHID && raw->data.hid.bRawData[21] == 1) {
- // data.hid.bRawData[21] has keycode
- switch (raw->data.hid.bRawData[20]) {
- case 0x0033 :
- nMceCmd = MCE_DETAILS;
- break;
- case 0x0022 :
- nMceCmd = MCE_GUIDE;
- break;
- case 0x0036 :
- nMceCmd = MCE_MYTV;
- break;
- case 0x0026 :
- nMceCmd = MCE_RECORDEDTV;
- break;
- case 0x0005 :
- nMceCmd = MCE_RED;
- break;
- case 0x0002 :
- nMceCmd = MCE_GREEN;
- break;
- case 0x0045 :
- nMceCmd = MCE_YELLOW;
- break;
- case 0x0046 :
- nMceCmd = MCE_BLUE;
- break;
- case 0x000A :
- nMceCmd = MCE_MEDIA_PREVIOUSTRACK;
- break;
- case 0x004A :
- nMceCmd = MCE_MEDIA_NEXTTRACK;
- break;
- }
- }
- }
- delete [] pRawBuffer;
- }
-
- return nMceCmd;
+ UINT dwSize = 0;
+ BYTE* pRawBuffer = NULL;
+ UINT nMceCmd = 0;
+
+ GetRawInputData(hRawInput, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER));
+ if (dwSize > 21) {
+ pRawBuffer = DNew BYTE[dwSize];
+ if (GetRawInputData(hRawInput, RID_INPUT, pRawBuffer, &dwSize, sizeof(RAWINPUTHEADER)) != -1) {
+ RAWINPUT* raw = (RAWINPUT*) pRawBuffer;
+
+ // data.hid.bRawData[21] set to one when key is pressed
+ if (raw->header.dwType == RIM_TYPEHID && raw->data.hid.bRawData[21] == 1) {
+ // data.hid.bRawData[21] has keycode
+ switch (raw->data.hid.bRawData[20]) {
+ case 0x0033 :
+ nMceCmd = MCE_DETAILS;
+ break;
+ case 0x0022 :
+ nMceCmd = MCE_GUIDE;
+ break;
+ case 0x0036 :
+ nMceCmd = MCE_MYTV;
+ break;
+ case 0x0026 :
+ nMceCmd = MCE_RECORDEDTV;
+ break;
+ case 0x0005 :
+ nMceCmd = MCE_RED;
+ break;
+ case 0x0002 :
+ nMceCmd = MCE_GREEN;
+ break;
+ case 0x0045 :
+ nMceCmd = MCE_YELLOW;
+ break;
+ case 0x0046 :
+ nMceCmd = MCE_BLUE;
+ break;
+ case 0x000A :
+ nMceCmd = MCE_MEDIA_PREVIOUSTRACK;
+ break;
+ case 0x004A :
+ nMceCmd = MCE_MEDIA_NEXTTRACK;
+ break;
+ }
+ }
+ }
+ delete [] pRawBuffer;
+ }
+
+ return nMceCmd;
}
void CMPlayerCApp::RegisterHotkeys()
{
- RAWINPUTDEVICELIST InputDeviceList[50];
- UINT nInputDeviceCount = _countof(InputDeviceList);
- RID_DEVICE_INFO DevInfo;
- RAWINPUTDEVICE MCEInputDevice[] = {
- // usUsagePage usUsage dwFlags hwndTarget
- { 0xFFBC, 0x88, 0, NULL},
- { 0x000C, 0x01, 0, NULL},
- { 0x000C, 0x80, 0, NULL}
- };
+ RAWINPUTDEVICELIST InputDeviceList[50];
+ UINT nInputDeviceCount = _countof(InputDeviceList);
+ RID_DEVICE_INFO DevInfo;
+ RAWINPUTDEVICE MCEInputDevice[] = {
+ // usUsagePage usUsage dwFlags hwndTarget
+ { 0xFFBC, 0x88, 0, NULL},
+ { 0x000C, 0x01, 0, NULL},
+ { 0x000C, 0x80, 0, NULL}
+ };
- // Register MCE Remote Control raw input
- for (unsigned int i=0; i<_countof(MCEInputDevice); i++) {
- MCEInputDevice[i].hwndTarget = m_pMainWnd->m_hWnd;
- }
+ // Register MCE Remote Control raw input
+ for (unsigned int i = 0; i < _countof(MCEInputDevice); i++) {
+ MCEInputDevice[i].hwndTarget = m_pMainWnd->m_hWnd;
+ }
- nInputDeviceCount = GetRawInputDeviceList (InputDeviceList, &nInputDeviceCount, sizeof(RAWINPUTDEVICELIST));
- for (UINT i=0; i<nInputDeviceCount; i++) {
- UINT nTemp = sizeof(DevInfo);
+ nInputDeviceCount = GetRawInputDeviceList(InputDeviceList, &nInputDeviceCount, sizeof(RAWINPUTDEVICELIST));
+ for (UINT i = 0; i < nInputDeviceCount; i++) {
+ UINT nTemp = sizeof(DevInfo);
- if (GetRawInputDeviceInfo (InputDeviceList[i].hDevice, RIDI_DEVICEINFO, &DevInfo, &nTemp)>0) {
- if (DevInfo.hid.dwVendorId == 0x00000471 && // Philips HID vendor id
- DevInfo.hid.dwProductId == 0x00000617) { // IEEE802.15.4 RF Dongle (SRM 7500)
- MCEInputDevice[0].usUsagePage = DevInfo.hid.usUsagePage;
- MCEInputDevice[0].usUsage = DevInfo.hid.usUsage;
- GetRemoteControlCode = GetRemoteControlCodeSRM7500;
- }
- }
- }
+ if (GetRawInputDeviceInfo(InputDeviceList[i].hDevice, RIDI_DEVICEINFO, &DevInfo, &nTemp) > 0) {
+ if (DevInfo.hid.dwVendorId == 0x00000471 && // Philips HID vendor id
+ DevInfo.hid.dwProductId == 0x00000617) { // IEEE802.15.4 RF Dongle (SRM 7500)
+ MCEInputDevice[0].usUsagePage = DevInfo.hid.usUsagePage;
+ MCEInputDevice[0].usUsage = DevInfo.hid.usUsage;
+ GetRemoteControlCode = GetRemoteControlCodeSRM7500;
+ }
+ }
+ }
- RegisterRawInputDevices (MCEInputDevice, _countof(MCEInputDevice), sizeof(RAWINPUTDEVICE));
+ RegisterRawInputDevices(MCEInputDevice, _countof(MCEInputDevice), sizeof(RAWINPUTDEVICE));
- if (m_s.fGlobalMedia) {
- POSITION pos = m_s.wmcmds.GetHeadPosition();
+ if (m_s.fGlobalMedia) {
+ POSITION pos = m_s.wmcmds.GetHeadPosition();
- while (pos) {
- wmcmd& wc = m_s.wmcmds.GetNext(pos);
- if (wc.appcmd != 0) {
- RegisterHotKey(m_pMainWnd->m_hWnd, wc.appcmd, 0, GetVKFromAppCommand (wc.appcmd));
- }
- }
- }
+ while (pos) {
+ wmcmd& wc = m_s.wmcmds.GetNext(pos);
+ if (wc.appcmd != 0) {
+ RegisterHotKey(m_pMainWnd->m_hWnd, wc.appcmd, 0, GetVKFromAppCommand(wc.appcmd));
+ }
+ }
+ }
}
void CMPlayerCApp::UnregisterHotkeys()
{
- if (m_s.fGlobalMedia) {
- POSITION pos = m_s.wmcmds.GetHeadPosition();
+ if (m_s.fGlobalMedia) {
+ POSITION pos = m_s.wmcmds.GetHeadPosition();
- while (pos) {
- wmcmd& wc = m_s.wmcmds.GetNext(pos);
- if (wc.appcmd != 0) {
- UnregisterHotKey(m_pMainWnd->m_hWnd, wc.appcmd);
- }
- }
- }
+ while (pos) {
+ wmcmd& wc = m_s.wmcmds.GetNext(pos);
+ if (wc.appcmd != 0) {
+ UnregisterHotKey(m_pMainWnd->m_hWnd, wc.appcmd);
+ }
+ }
+ }
}
UINT CMPlayerCApp::GetVKFromAppCommand(UINT nAppCommand)
{
- switch (nAppCommand) {
- case APPCOMMAND_BROWSER_BACKWARD :
- return VK_BROWSER_BACK;
- case APPCOMMAND_BROWSER_FORWARD :
- return VK_BROWSER_FORWARD;
- case APPCOMMAND_BROWSER_REFRESH :
- return VK_BROWSER_REFRESH;
- case APPCOMMAND_BROWSER_STOP :
- return VK_BROWSER_STOP;
- case APPCOMMAND_BROWSER_SEARCH :
- return VK_BROWSER_SEARCH;
- case APPCOMMAND_BROWSER_FAVORITES :
- return VK_BROWSER_FAVORITES;
- case APPCOMMAND_BROWSER_HOME :
- return VK_BROWSER_HOME;
- case APPCOMMAND_VOLUME_MUTE :
- return VK_VOLUME_MUTE;
- case APPCOMMAND_VOLUME_DOWN :
- return VK_VOLUME_DOWN;
- case APPCOMMAND_VOLUME_UP :
- return VK_VOLUME_UP;
- case APPCOMMAND_MEDIA_NEXTTRACK :
- return VK_MEDIA_NEXT_TRACK;
- case APPCOMMAND_MEDIA_PREVIOUSTRACK :
- return VK_MEDIA_PREV_TRACK;
- case APPCOMMAND_MEDIA_STOP :
- return VK_MEDIA_STOP;
- case APPCOMMAND_MEDIA_PLAY_PAUSE :
- return VK_MEDIA_PLAY_PAUSE;
- case APPCOMMAND_LAUNCH_MAIL :
- return VK_LAUNCH_MAIL;
- case APPCOMMAND_LAUNCH_MEDIA_SELECT :
- return VK_LAUNCH_MEDIA_SELECT;
- case APPCOMMAND_LAUNCH_APP1 :
- return VK_LAUNCH_APP1;
- case APPCOMMAND_LAUNCH_APP2 :
- return VK_LAUNCH_APP2;
- }
-
- return 0;
+ switch (nAppCommand) {
+ case APPCOMMAND_BROWSER_BACKWARD :
+ return VK_BROWSER_BACK;
+ case APPCOMMAND_BROWSER_FORWARD :
+ return VK_BROWSER_FORWARD;
+ case APPCOMMAND_BROWSER_REFRESH :
+ return VK_BROWSER_REFRESH;
+ case APPCOMMAND_BROWSER_STOP :
+ return VK_BROWSER_STOP;
+ case APPCOMMAND_BROWSER_SEARCH :
+ return VK_BROWSER_SEARCH;
+ case APPCOMMAND_BROWSER_FAVORITES :
+ return VK_BROWSER_FAVORITES;
+ case APPCOMMAND_BROWSER_HOME :
+ return VK_BROWSER_HOME;
+ case APPCOMMAND_VOLUME_MUTE :
+ return VK_VOLUME_MUTE;
+ case APPCOMMAND_VOLUME_DOWN :
+ return VK_VOLUME_DOWN;
+ case APPCOMMAND_VOLUME_UP :
+ return VK_VOLUME_UP;
+ case APPCOMMAND_MEDIA_NEXTTRACK :
+ return VK_MEDIA_NEXT_TRACK;
+ case APPCOMMAND_MEDIA_PREVIOUSTRACK :
+ return VK_MEDIA_PREV_TRACK;
+ case APPCOMMAND_MEDIA_STOP :
+ return VK_MEDIA_STOP;
+ case APPCOMMAND_MEDIA_PLAY_PAUSE :
+ return VK_MEDIA_PLAY_PAUSE;
+ case APPCOMMAND_LAUNCH_MAIL :
+ return VK_LAUNCH_MAIL;
+ case APPCOMMAND_LAUNCH_MEDIA_SELECT :
+ return VK_LAUNCH_MEDIA_SELECT;
+ case APPCOMMAND_LAUNCH_APP1 :
+ return VK_LAUNCH_APP1;
+ case APPCOMMAND_LAUNCH_APP2 :
+ return VK_LAUNCH_APP2;
+ }
+
+ return 0;
}
int CMPlayerCApp::ExitInstance()
{
- m_s.UpdateData(true);
+ m_s.UpdateData(true);
- OleUninitialize();
+ OleUninitialize();
- return CWinApp::ExitInstance();
+ return CWinApp::ExitInstance();
}
/////////////////////////////////////////////////////////////////////////////
@@ -1295,133 +1294,133 @@ int CMPlayerCApp::ExitInstance()
void CMPlayerCApp::OnAppAbout()
{
- CAboutDlg aboutDlg;
- aboutDlg.DoModal();
+ CAboutDlg aboutDlg;
+ aboutDlg.DoModal();
}
void CMPlayerCApp::OnFileExit()
{
- OnAppExit();
+ OnAppExit();
}
// CRemoteCtrlClient
CRemoteCtrlClient::CRemoteCtrlClient()
- : m_pWnd(NULL)
- , m_nStatus(DISCONNECTED)
+ : m_pWnd(NULL)
+ , m_nStatus(DISCONNECTED)
{
}
void CRemoteCtrlClient::SetHWND(HWND hWnd)
{
- CAutoLock cAutoLock(&m_csLock);
+ CAutoLock cAutoLock(&m_csLock);
- m_pWnd = CWnd::FromHandle(hWnd);
+ m_pWnd = CWnd::FromHandle(hWnd);
}
void CRemoteCtrlClient::Connect(CString addr)
{
- CAutoLock cAutoLock(&m_csLock);
+ CAutoLock cAutoLock(&m_csLock);
- if (m_nStatus == CONNECTING && m_addr == addr) {
- TRACE(_T("CRemoteCtrlClient (Connect): already connecting to %s\n"), addr);
- return;
- }
+ if (m_nStatus == CONNECTING && m_addr == addr) {
+ TRACE(_T("CRemoteCtrlClient (Connect): already connecting to %s\n"), addr);
+ return;
+ }
- if (m_nStatus == CONNECTED && m_addr == addr) {
- TRACE(_T("CRemoteCtrlClient (Connect): already connected to %s\n"), addr);
- return;
- }
+ if (m_nStatus == CONNECTED && m_addr == addr) {
+ TRACE(_T("CRemoteCtrlClient (Connect): already connected to %s\n"), addr);
+ return;
+ }
- m_nStatus = CONNECTING;
+ m_nStatus = CONNECTING;
- TRACE(_T("CRemoteCtrlClient (Connect): connecting to %s\n"), addr);
+ TRACE(_T("CRemoteCtrlClient (Connect): connecting to %s\n"), addr);
- Close();
+ Close();
- Create();
+ Create();
- CString ip = addr.Left(addr.Find(':')+1).TrimRight(':');
- int port = _tcstol(addr.Mid(addr.Find(':')+1), NULL, 10);
+ CString ip = addr.Left(addr.Find(':') + 1).TrimRight(':');
+ int port = _tcstol(addr.Mid(addr.Find(':') + 1), NULL, 10);
- __super::Connect(ip, port);
+ __super::Connect(ip, port);
- m_addr = addr;
+ m_addr = addr;
}
void CRemoteCtrlClient::DisConnect()
{
- CAutoLock cAutoLock(&m_csLock);
+ CAutoLock cAutoLock(&m_csLock);
- ShutDown(2);
- Close();
+ ShutDown(2);
+ Close();
}
void CRemoteCtrlClient::OnConnect(int nErrorCode)
{
- CAutoLock cAutoLock(&m_csLock);
+ CAutoLock cAutoLock(&m_csLock);
- m_nStatus = (nErrorCode == 0 ? CONNECTED : DISCONNECTED);
+ m_nStatus = (nErrorCode == 0 ? CONNECTED : DISCONNECTED);
- TRACE(_T("CRemoteCtrlClient (OnConnect): %d\n"), nErrorCode);
+ TRACE(_T("CRemoteCtrlClient (OnConnect): %d\n"), nErrorCode);
}
void CRemoteCtrlClient::OnClose(int nErrorCode)
{
- CAutoLock cAutoLock(&m_csLock);
+ CAutoLock cAutoLock(&m_csLock);
- if (m_hSocket != INVALID_SOCKET && m_nStatus == CONNECTED) {
- TRACE(_T("CRemoteCtrlClient (OnClose): connection lost\n"));
- }
+ if (m_hSocket != INVALID_SOCKET && m_nStatus == CONNECTED) {
+ TRACE(_T("CRemoteCtrlClient (OnClose): connection lost\n"));
+ }
- m_nStatus = DISCONNECTED;
+ m_nStatus = DISCONNECTED;
- TRACE(_T("CRemoteCtrlClient (OnClose): %d\n"), nErrorCode);
+ TRACE(_T("CRemoteCtrlClient (OnClose): %d\n"), nErrorCode);
}
void CRemoteCtrlClient::OnReceive(int nErrorCode)
{
- if (nErrorCode != 0 || !m_pWnd) {
- return;
- }
+ if (nErrorCode != 0 || !m_pWnd) {
+ return;
+ }
- CStringA str;
- int ret = Receive(str.GetBuffer(256), 255, 0);
- if (ret <= 0) {
- return;
- }
- str.ReleaseBuffer(ret);
+ CStringA str;
+ int ret = Receive(str.GetBuffer(256), 255, 0);
+ if (ret <= 0) {
+ return;
+ }
+ str.ReleaseBuffer(ret);
- TRACE(_T("CRemoteCtrlClient (OnReceive): %s\n"), CString(str));
+ TRACE(_T("CRemoteCtrlClient (OnReceive): %s\n"), CString(str));
- OnCommand(str);
+ OnCommand(str);
- __super::OnReceive(nErrorCode);
+ __super::OnReceive(nErrorCode);
}
void CRemoteCtrlClient::ExecuteCommand(CStringA cmd, int repcnt)
{
- cmd.Trim();
- if (cmd.IsEmpty()) {
- return;
- }
- cmd.Replace(' ', '_');
-
- CAppSettings& s = AfxGetAppSettings();
-
- POSITION pos = s.wmcmds.GetHeadPosition();
- while (pos) {
- wmcmd wc = s.wmcmds.GetNext(pos);
- CStringA name = TToA(wc.GetName());
- name.Replace(' ', '_');
- if ((repcnt == 0 && wc.rmrepcnt == 0 || wc.rmrepcnt > 0 && (repcnt%wc.rmrepcnt) == 0)
- && (!name.CompareNoCase(cmd) || !wc.rmcmd.CompareNoCase(cmd) || wc.cmd == (WORD)strtol(cmd, NULL, 10))) {
- CAutoLock cAutoLock(&m_csLock);
- TRACE(_T("CRemoteCtrlClient (calling command): %s\n"), wc.GetName());
- m_pWnd->SendMessage(WM_COMMAND, wc.cmd);
- break;
- }
- }
+ cmd.Trim();
+ if (cmd.IsEmpty()) {
+ return;
+ }
+ cmd.Replace(' ', '_');
+
+ CAppSettings& s = AfxGetAppSettings();
+
+ POSITION pos = s.wmcmds.GetHeadPosition();
+ while (pos) {
+ wmcmd wc = s.wmcmds.GetNext(pos);
+ CStringA name = TToA(wc.GetName());
+ name.Replace(' ', '_');
+ if ((repcnt == 0 && wc.rmrepcnt == 0 || wc.rmrepcnt > 0 && (repcnt % wc.rmrepcnt) == 0)
+ && (!name.CompareNoCase(cmd) || !wc.rmcmd.CompareNoCase(cmd) || wc.cmd == (WORD)strtol(cmd, NULL, 10))) {
+ CAutoLock cAutoLock(&m_csLock);
+ TRACE(_T("CRemoteCtrlClient (calling command): %s\n"), wc.GetName());
+ m_pWnd->SendMessage(WM_COMMAND, wc.cmd);
+ break;
+ }
+ }
}
// CWinLircClient
@@ -1432,18 +1431,18 @@ CWinLircClient::CWinLircClient()
void CWinLircClient::OnCommand(CStringA str)
{
- TRACE(_T("CWinLircClient (OnCommand): %s\n"), CString(str));
+ TRACE(_T("CWinLircClient (OnCommand): %s\n"), CString(str));
- int i = 0, j = 0, repcnt = 0;
- for (CStringA token = str.Tokenize(" ", i);
- !token.IsEmpty();
- token = str.Tokenize(" ", i), j++) {
- if (j == 1) {
- repcnt = strtol(token, NULL, 16);
- } else if (j == 2) {
- ExecuteCommand(token, repcnt);
- }
- }
+ int i = 0, j = 0, repcnt = 0;
+ for (CStringA token = str.Tokenize(" ", i);
+ !token.IsEmpty();
+ token = str.Tokenize(" ", i), j++) {
+ if (j == 1) {
+ repcnt = strtol(token, NULL, 16);
+ } else if (j == 2) {
+ ExecuteCommand(token, repcnt);
+ }
+ }
}
// CUIceClient
@@ -1454,134 +1453,134 @@ CUIceClient::CUIceClient()
void CUIceClient::OnCommand(CStringA str)
{
- TRACE(_T("CUIceClient (OnCommand): %s\n"), CString(str));
+ TRACE(_T("CUIceClient (OnCommand): %s\n"), CString(str));
- CStringA cmd;
- int i = 0, j = 0;
- for (CStringA token = str.Tokenize("|", i);
- !token.IsEmpty();
- token = str.Tokenize("|", i), j++) {
- if (j == 0) {
- cmd = token;
- } else if (j == 1) {
- ExecuteCommand(cmd, strtol(token, NULL, 16));
- }
- }
+ CStringA cmd;
+ int i = 0, j = 0;
+ for (CStringA token = str.Tokenize("|", i);
+ !token.IsEmpty();
+ token = str.Tokenize("|", i), j++) {
+ if (j == 0) {
+ cmd = token;
+ } else if (j == 1) {
+ ExecuteCommand(cmd, strtol(token, NULL, 16));
+ }
+ }
}
void CMPlayerCApp::OnHelpShowcommandlineswitches()
{
- ShowCmdlnSwitches();
+ ShowCmdlnSwitches();
}
//
void GetCurDispMode(dispmode& dm, CString& DisplayName)
{
- HDC hDC;
- CString DisplayName1 = DisplayName;
- if ((DisplayName == _T("Current")) || (DisplayName == _T(""))) {
- CMonitor monitor;
- CMonitors monitors;
- monitor = monitors.GetNearestMonitor(AfxGetApp()->m_pMainWnd);
- monitor.GetName(DisplayName1);
- }
- hDC = CreateDC(DisplayName1, NULL, NULL, NULL);
- if (hDC) {
- dm.fValid = true;
- dm.size = CSize(GetDeviceCaps(hDC, HORZRES), GetDeviceCaps(hDC, VERTRES));
- dm.bpp = GetDeviceCaps(hDC, BITSPIXEL);
- dm.freq = GetDeviceCaps(hDC, VREFRESH);
- DeleteDC(hDC);
- }
+ HDC hDC;
+ CString DisplayName1 = DisplayName;
+ if ((DisplayName == _T("Current")) || (DisplayName == _T(""))) {
+ CMonitor monitor;
+ CMonitors monitors;
+ monitor = monitors.GetNearestMonitor(AfxGetApp()->m_pMainWnd);
+ monitor.GetName(DisplayName1);
+ }
+ hDC = CreateDC(DisplayName1, NULL, NULL, NULL);
+ if (hDC) {
+ dm.fValid = true;
+ dm.size = CSize(GetDeviceCaps(hDC, HORZRES), GetDeviceCaps(hDC, VERTRES));
+ dm.bpp = GetDeviceCaps(hDC, BITSPIXEL);
+ dm.freq = GetDeviceCaps(hDC, VREFRESH);
+ DeleteDC(hDC);
+ }
}
bool GetDispMode(int i, dispmode& dm, CString& DisplayName)
{
- DEVMODE devmode;
- CString DisplayName1 = DisplayName;
- devmode.dmSize = sizeof(DEVMODE);
- if ((DisplayName == _T("Current")) || (DisplayName == _T(""))) {
- CMonitor monitor;
- CMonitors monitors;
- monitor = monitors.GetNearestMonitor(AfxGetApp()->m_pMainWnd);
- monitor.GetName(DisplayName1);
- }
- if (!EnumDisplaySettings(DisplayName1, i, &devmode)) {
- return false;
- }
- dm.fValid = true;
- dm.size = CSize(devmode.dmPelsWidth, devmode.dmPelsHeight);
- dm.bpp = devmode.dmBitsPerPel;
- dm.freq = devmode.dmDisplayFrequency;
- dm.dmDisplayFlags = devmode.dmDisplayFlags;
- return true;
+ DEVMODE devmode;
+ CString DisplayName1 = DisplayName;
+ devmode.dmSize = sizeof(DEVMODE);
+ if ((DisplayName == _T("Current")) || (DisplayName == _T(""))) {
+ CMonitor monitor;
+ CMonitors monitors;
+ monitor = monitors.GetNearestMonitor(AfxGetApp()->m_pMainWnd);
+ monitor.GetName(DisplayName1);
+ }
+ if (!EnumDisplaySettings(DisplayName1, i, &devmode)) {
+ return false;
+ }
+ dm.fValid = true;
+ dm.size = CSize(devmode.dmPelsWidth, devmode.dmPelsHeight);
+ dm.bpp = devmode.dmBitsPerPel;
+ dm.freq = devmode.dmDisplayFrequency;
+ dm.dmDisplayFlags = devmode.dmDisplayFlags;
+ return true;
}
void SetDispMode(dispmode& dm, CString& DisplayName)
{
- dispmode dm1;
- GetCurDispMode(dm1, DisplayName);
- if ((dm.size == dm1.size) && (dm.bpp == dm1.bpp) && (dm.freq == dm1.freq)) {
- return;
- }
-
- if (!dm.fValid) {
- return;
- }
- DEVMODE dmScreenSettings;
- memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
- dmScreenSettings.dmSize = sizeof(dmScreenSettings);
- dmScreenSettings.dmPelsWidth = dm.size.cx;
- dmScreenSettings.dmPelsHeight = dm.size.cy;
- dmScreenSettings.dmBitsPerPel = dm.bpp;
- dmScreenSettings.dmDisplayFrequency = dm.freq;
- dmScreenSettings.dmDisplayFlags = dm.dmDisplayFlags;
- dmScreenSettings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY | DM_DISPLAYFLAGS;
- CString DisplayName1 = DisplayName;
- if ((DisplayName == _T("Current")) || (DisplayName == _T(""))) {
- CMonitor monitor;
- CMonitors monitors;
- monitor = monitors.GetNearestMonitor(AfxGetApp()->m_pMainWnd);
- monitor.GetName(DisplayName1);
- }
- if (AfxGetAppSettings().fRestoreResAfterExit) {
- ChangeDisplaySettingsEx(DisplayName1, &dmScreenSettings, NULL, CDS_FULLSCREEN, NULL);
- } else {
- ChangeDisplaySettingsEx(DisplayName1, &dmScreenSettings, NULL, NULL, NULL);
- }
+ dispmode dm1;
+ GetCurDispMode(dm1, DisplayName);
+ if ((dm.size == dm1.size) && (dm.bpp == dm1.bpp) && (dm.freq == dm1.freq)) {
+ return;
+ }
+
+ if (!dm.fValid) {
+ return;
+ }
+ DEVMODE dmScreenSettings;
+ memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
+ dmScreenSettings.dmSize = sizeof(dmScreenSettings);
+ dmScreenSettings.dmPelsWidth = dm.size.cx;
+ dmScreenSettings.dmPelsHeight = dm.size.cy;
+ dmScreenSettings.dmBitsPerPel = dm.bpp;
+ dmScreenSettings.dmDisplayFrequency = dm.freq;
+ dmScreenSettings.dmDisplayFlags = dm.dmDisplayFlags;
+ dmScreenSettings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY | DM_DISPLAYFLAGS;
+ CString DisplayName1 = DisplayName;
+ if ((DisplayName == _T("Current")) || (DisplayName == _T(""))) {
+ CMonitor monitor;
+ CMonitors monitors;
+ monitor = monitors.GetNearestMonitor(AfxGetApp()->m_pMainWnd);
+ monitor.GetName(DisplayName1);
+ }
+ if (AfxGetAppSettings().fRestoreResAfterExit) {
+ ChangeDisplaySettingsEx(DisplayName1, &dmScreenSettings, NULL, CDS_FULLSCREEN, NULL);
+ } else {
+ ChangeDisplaySettingsEx(DisplayName1, &dmScreenSettings, NULL, NULL, NULL);
+ }
}
void SetAudioRenderer(int AudioDevNo)
{
- CStringArray m_AudioRendererDisplayNames;
- AfxGetMyApp()->m_AudioRendererDisplayName_CL = _T("");
- m_AudioRendererDisplayNames.Add(_T(""));
- int i=2;
-
- BeginEnumSysDev(CLSID_AudioRendererCategory, pMoniker) {
- LPOLESTR olestr = NULL;
- if (FAILED(pMoniker->GetDisplayName(0, 0, &olestr))) {
- continue;
- }
- CStringW str(olestr);
- CoTaskMemFree(olestr);
- m_AudioRendererDisplayNames.Add(CString(str));
- i++;
- }
- EndEnumSysDev
-
- m_AudioRendererDisplayNames.Add(AUDRNDT_NULL_COMP);
- m_AudioRendererDisplayNames.Add(AUDRNDT_NULL_UNCOMP);
- m_AudioRendererDisplayNames.Add(AUDRNDT_MPC);
- i+=3;
- if (AudioDevNo>=1 && AudioDevNo<=i) {
- AfxGetMyApp()->m_AudioRendererDisplayName_CL = m_AudioRendererDisplayNames[AudioDevNo-1];
- }
+ CStringArray m_AudioRendererDisplayNames;
+ AfxGetMyApp()->m_AudioRendererDisplayName_CL = _T("");
+ m_AudioRendererDisplayNames.Add(_T(""));
+ int i = 2;
+
+ BeginEnumSysDev(CLSID_AudioRendererCategory, pMoniker) {
+ LPOLESTR olestr = NULL;
+ if (FAILED(pMoniker->GetDisplayName(0, 0, &olestr))) {
+ continue;
+ }
+ CStringW str(olestr);
+ CoTaskMemFree(olestr);
+ m_AudioRendererDisplayNames.Add(CString(str));
+ i++;
+ }
+ EndEnumSysDev
+
+ m_AudioRendererDisplayNames.Add(AUDRNDT_NULL_COMP);
+ m_AudioRendererDisplayNames.Add(AUDRNDT_NULL_UNCOMP);
+ m_AudioRendererDisplayNames.Add(AUDRNDT_MPC);
+ i += 3;
+ if (AudioDevNo >= 1 && AudioDevNo <= i) {
+ AfxGetMyApp()->m_AudioRendererDisplayName_CL = m_AudioRendererDisplayNames[AudioDevNo - 1];
+ }
}
void SetHandCursor(HWND m_hWnd, UINT nID)
{
- SetClassLongPtr(GetDlgItem(m_hWnd, nID), GCLP_HCURSOR, (LONG_PTR)AfxGetApp()->LoadStandardCursor(IDC_HAND));
+ SetClassLongPtr(GetDlgItem(m_hWnd, nID), GCLP_HCURSOR, (LONG_PTR)AfxGetApp()->LoadStandardCursor(IDC_HAND));
}
@@ -1590,640 +1589,638 @@ typedef CAtlREMatchContext<CAtlRECharTraits> CAtlREMatchContextT;
bool FindRedir(CUrl& src, CString ct, CString& body, CAtlList<CString>& urls, CAutoPtrList<CAtlRegExpT>& res)
{
- POSITION pos = res.GetHeadPosition();
- while (pos) {
- CAtlRegExpT* re = res.GetNext(pos);
-
- CAtlREMatchContextT mc;
- const CAtlREMatchContextT::RECHAR* s = (LPCTSTR)body;
- const CAtlREMatchContextT::RECHAR* e = NULL;
- for (; s && re->Match(s, &mc, &e); s = e) {
- const CAtlREMatchContextT::RECHAR* szStart = 0;
- const CAtlREMatchContextT::RECHAR* szEnd = 0;
- mc.GetMatch(0, &szStart, &szEnd);
-
- CString url;
- url.Format(_T("%.*s"), szEnd - szStart, szStart);
- url.Trim();
-
- if (url.CompareNoCase(_T("asf path")) == 0) {
- continue;
- }
-
- CUrl dst;
- dst.CrackUrl(CString(url));
- if (_tcsicmp(src.GetSchemeName(), dst.GetSchemeName())
- || _tcsicmp(src.GetHostName(), dst.GetHostName())
- || _tcsicmp(src.GetUrlPath(), dst.GetUrlPath())) {
- urls.AddTail(url);
- } else {
- // recursive
- urls.RemoveAll();
- break;
- }
- }
- }
-
- return urls.GetCount() > 0;
+ POSITION pos = res.GetHeadPosition();
+ while (pos) {
+ CAtlRegExpT* re = res.GetNext(pos);
+
+ CAtlREMatchContextT mc;
+ const CAtlREMatchContextT::RECHAR* s = (LPCTSTR)body;
+ const CAtlREMatchContextT::RECHAR* e = NULL;
+ for (; s && re->Match(s, &mc, &e); s = e) {
+ const CAtlREMatchContextT::RECHAR* szStart = 0;
+ const CAtlREMatchContextT::RECHAR* szEnd = 0;
+ mc.GetMatch(0, &szStart, &szEnd);
+
+ CString url;
+ url.Format(_T("%.*s"), szEnd - szStart, szStart);
+ url.Trim();
+
+ if (url.CompareNoCase(_T("asf path")) == 0) {
+ continue;
+ }
+
+ CUrl dst;
+ dst.CrackUrl(CString(url));
+ if (_tcsicmp(src.GetSchemeName(), dst.GetSchemeName())
+ || _tcsicmp(src.GetHostName(), dst.GetHostName())
+ || _tcsicmp(src.GetUrlPath(), dst.GetUrlPath())) {
+ urls.AddTail(url);
+ } else {
+ // recursive
+ urls.RemoveAll();
+ break;
+ }
+ }
+ }
+
+ return urls.GetCount() > 0;
}
bool FindRedir(CString& fn, CString ct, CAtlList<CString>& fns, CAutoPtrList<CAtlRegExpT>& res)
{
- CString body;
+ CString body;
- CTextFile f(CTextFile::ANSI);
- if (f.Open(fn)) for (CString tmp; f.ReadString(tmp); body += tmp + '\n') {
- ;
- }
+ CTextFile f(CTextFile::ANSI);
+ if (f.Open(fn)) for (CString tmp; f.ReadString(tmp); body += tmp + '\n') {
+ ;
+ }
- CString dir = fn.Left(max(fn.ReverseFind('/'), fn.ReverseFind('\\'))+1); // "ReverseFindOneOf"
+ CString dir = fn.Left(max(fn.ReverseFind('/'), fn.ReverseFind('\\')) + 1); // "ReverseFindOneOf"
- POSITION pos = res.GetHeadPosition();
- while (pos) {
- CAtlRegExpT* re = res.GetNext(pos);
+ POSITION pos = res.GetHeadPosition();
+ while (pos) {
+ CAtlRegExpT* re = res.GetNext(pos);
- CAtlREMatchContextT mc;
- const CAtlREMatchContextT::RECHAR* s = (LPCTSTR)body;
- const CAtlREMatchContextT::RECHAR* e = NULL;
- for (; s && re->Match(s, &mc, &e); s = e) {
- const CAtlREMatchContextT::RECHAR* szStart = 0;
- const CAtlREMatchContextT::RECHAR* szEnd = 0;
- mc.GetMatch(0, &szStart, &szEnd);
+ CAtlREMatchContextT mc;
+ const CAtlREMatchContextT::RECHAR* s = (LPCTSTR)body;
+ const CAtlREMatchContextT::RECHAR* e = NULL;
+ for (; s && re->Match(s, &mc, &e); s = e) {
+ const CAtlREMatchContextT::RECHAR* szStart = 0;
+ const CAtlREMatchContextT::RECHAR* szEnd = 0;
+ mc.GetMatch(0, &szStart, &szEnd);
- CString fn2;
- fn2.Format(_T("%.*s"), szEnd - szStart, szStart);
- fn2.Trim();
+ CString fn2;
+ fn2.Format(_T("%.*s"), szEnd - szStart, szStart);
+ fn2.Trim();
- if (!fn2.CompareNoCase(_T("asf path"))) {
- continue;
- }
- if (fn2.Find(_T("EXTM3U")) == 0 || fn2.Find(_T("#EXTINF")) == 0) {
- continue;
- }
+ if (!fn2.CompareNoCase(_T("asf path"))) {
+ continue;
+ }
+ if (fn2.Find(_T("EXTM3U")) == 0 || fn2.Find(_T("#EXTINF")) == 0) {
+ continue;
+ }
- if (fn2.Find(_T(":")) < 0 && fn2.Find(_T("\\\\")) != 0 && fn2.Find(_T("//")) != 0) {
- CPath p;
- p.Combine(dir, fn2);
- fn2 = (LPCTSTR)p;
- }
+ if (fn2.Find(_T(":")) < 0 && fn2.Find(_T("\\\\")) != 0 && fn2.Find(_T("//")) != 0) {
+ CPath p;
+ p.Combine(dir, fn2);
+ fn2 = (LPCTSTR)p;
+ }
- if (!fn2.CompareNoCase(fn)) {
- continue;
- }
+ if (!fn2.CompareNoCase(fn)) {
+ continue;
+ }
- fns.AddTail(fn2);
- }
- }
+ fns.AddTail(fn2);
+ }
+ }
- return fns.GetCount() > 0;
+ return fns.GetCount() > 0;
}
CStringA GetContentType(CString fn, CAtlList<CString>* redir)
{
- CUrl url;
- CString ct, body;
-
- if (fn.Find(_T("://")) >= 0) {
- url.CrackUrl(fn);
-
- if (_tcsicmp(url.GetSchemeName(), _T("pnm")) == 0) {
- return "audio/x-pn-realaudio";
- }
-
- if (_tcsicmp(url.GetSchemeName(), _T("mms")) == 0) {
- return "video/x-ms-asf";
- }
-
- if (_tcsicmp(url.GetSchemeName(), _T("http")) != 0) {
- return "";
- }
-
- DWORD ProxyEnable = 0;
- CString ProxyServer;
- DWORD ProxyPort = 0;
-
- ULONG len = 256+1;
- CRegKey key;
- if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"), KEY_READ)
- && ERROR_SUCCESS == key.QueryDWORDValue(_T("ProxyEnable"), ProxyEnable) && ProxyEnable
- && ERROR_SUCCESS == key.QueryStringValue(_T("ProxyServer"), ProxyServer.GetBufferSetLength(256), &len)) {
- ProxyServer.ReleaseBufferSetLength(len);
-
- CAtlList<CString> sl;
- ProxyServer = Explode(ProxyServer, sl, ';');
- if (sl.GetCount() > 1) {
- POSITION pos = sl.GetHeadPosition();
- while (pos) {
- CAtlList<CString> sl2;
- if (!Explode(sl.GetNext(pos), sl2, '=', 2).CompareNoCase(_T("http"))
- && sl2.GetCount() == 2) {
- ProxyServer = sl2.GetTail();
- break;
- }
- }
- }
-
- ProxyServer = Explode(ProxyServer, sl, ':');
- if (sl.GetCount() > 1) {
- ProxyPort = _tcstol(sl.GetTail(), NULL, 10);
- }
- }
-
- CSocket s;
- s.Create();
- if (s.Connect(
- ProxyEnable ? ProxyServer : url.GetHostName(),
- ProxyEnable ? ProxyPort : url.GetPortNumber())) {
- CStringA host = CStringA(url.GetHostName());
- CStringA path = CStringA(url.GetUrlPath()) + CStringA(url.GetExtraInfo());
-
- if (ProxyEnable) {
- path = "http://" + host + path;
- }
-
- CStringA hdr;
- hdr.Format(
- "GET %s HTTP/1.0\r\n"
- "User-Agent: Media Player Classic\r\n"
- "Host: %s\r\n"
- "Accept: */*\r\n"
- "\r\n", path, host);
-
- // MessageBox(NULL, CString(hdr), _T("Sending..."), MB_OK);
-
- if (s.Send((LPCSTR)hdr, hdr.GetLength()) < hdr.GetLength()) {
- return "";
- }
-
- hdr.Empty();
- for (;;) {
- CStringA str;
- str.ReleaseBuffer(s.Receive(str.GetBuffer(256), 256)); // SOCKET_ERROR == -1, also suitable for ReleaseBuffer
- if (str.IsEmpty()) {
- break;
- }
- hdr += str;
- int hdrend = hdr.Find("\r\n\r\n");
- if (hdrend >= 0) {
- body = hdr.Mid(hdrend+4);
- hdr = hdr.Left(hdrend);
- break;
- }
- }
-
- // MessageBox(NULL, CString(hdr), _T("Received..."), MB_OK);
-
- CAtlList<CStringA> sl;
- Explode(hdr, sl, '\n');
- POSITION pos = sl.GetHeadPosition();
- while (pos) {
- CStringA& hdrline = sl.GetNext(pos);
- CAtlList<CStringA> sl2;
- Explode(hdrline, sl2, ':', 2);
- CStringA field = sl2.RemoveHead().MakeLower();
- if (field == "location" && !sl2.IsEmpty()) {
- return GetContentType(CString(sl2.GetHead()), redir);
- }
- if (field == "content-type" && !sl2.IsEmpty()) {
- ct = sl2.GetHead();
- }
- }
-
- while (body.GetLength() < 256) {
- CStringA str;
- str.ReleaseBuffer(s.Receive(str.GetBuffer(256), 256)); // SOCKET_ERROR == -1, also suitable for ReleaseBuffer
- if (str.IsEmpty()) {
- break;
- }
- body += str;
- }
-
- if (body.GetLength() >= 8) {
- CStringA str = TToA(body);
- if (!strncmp((LPCSTR)str, ".ra", 3)) {
- return "audio/x-pn-realaudio";
- }
- if (!strncmp((LPCSTR)str, ".RMF", 4)) {
- return "audio/x-pn-realaudio";
- }
- if (*(DWORD*)(LPCSTR)str == 0x75b22630) {
- return "video/x-ms-wmv";
- }
- if (!strncmp((LPCSTR)str+4, "moov", 4)) {
- return "video/quicktime";
- }
- }
-
- if (redir && (ct == _T("audio/x-scpls") || ct == _T("audio/x-mpegurl"))) {
- while (body.GetLength() < 4*1024) { // should be enough for a playlist...
- CStringA str;
- str.ReleaseBuffer(s.Receive(str.GetBuffer(256), 256)); // SOCKET_ERROR == -1, also suitable for ReleaseBuffer
- if (str.IsEmpty()) {
- break;
- }
- body += str;
- }
- }
- }
- } else if (!fn.IsEmpty()) {
- CPath p(fn);
- CString ext = p.GetExtension().MakeLower();
- if (ext == _T(".asx")) {
- ct = _T("video/x-ms-asf");
- } else if (ext == _T(".pls")) {
- ct = _T("audio/x-scpls");
- } else if (ext == _T(".m3u") || ext == _T(".m3u8")) {
- ct = _T("audio/x-mpegurl");
- } else if (ext == _T(".qtl")) {
- ct = _T("application/x-quicktimeplayer");
- } else if (ext == _T(".mpcpl")) {
- ct = _T("application/x-mpc-playlist");
- } else if (ext == _T(".bdmv")) {
- ct = _T("application/x-bdmv-playlist");
- }
-
- FILE* f = NULL;
- if (!_tfopen_s(&f, fn, _T("rb"))) {
- CStringA str;
- str.ReleaseBufferSetLength((int)fread(str.GetBuffer(10240), 1, 10240, f));
- body = AToT(str);
- fclose(f);
- }
- }
-
- if (body.GetLength() >= 4) { // here only those which cannot be opened through dshow
- CStringA str = TToA(body);
- if (!strncmp((LPCSTR)str, ".ra", 3)) {
- return "audio/x-pn-realaudio";
- }
- if (!strncmp((LPCSTR)str, "FWS", 3)) {
- return "application/x-shockwave-flash";
- }
-
- }
-
- if (redir && !ct.IsEmpty()) {
- CAutoPtrList<CAtlRegExpT> res;
- CAutoPtr<CAtlRegExpT> re;
-
- if (ct == _T("video/x-ms-asf")) {
- // ...://..."/>
- re.Attach(DNew CAtlRegExpT());
- if (re && REPARSE_ERROR_OK == re->Parse(_T("{[a-zA-Z]+://[^\n\">]*}"), FALSE)) {
- res.AddTail(re);
- }
- // Ref#n= ...://...\n
- re.Attach(DNew CAtlRegExpT());
- if (re && REPARSE_ERROR_OK == re->Parse(_T("Ref\\z\\b*=\\b*[\"]*{([a-zA-Z]+://[^\n\"]+}"), FALSE)) {
- res.AddTail(re);
- }
- } else if (ct == _T("audio/x-scpls")) {
- // File1=...\n
- re.Attach(DNew CAtlRegExp<>());
- if (re && REPARSE_ERROR_OK == re->Parse(_T("file\\z\\b*=\\b*[\"]*{[^\n\"]+}"), FALSE)) {
- res.AddTail(re);
- }
- } else if (ct == _T("audio/x-mpegurl")) {
- // #comment
- // ...
- re.Attach(DNew CAtlRegExp<>());
- if (re && REPARSE_ERROR_OK == re->Parse(_T("{[^#][^\n]+}"), FALSE)) {
- res.AddTail(re);
- }
- } else if (ct == _T("audio/x-pn-realaudio")) {
- // rtsp://...
- re.Attach(DNew CAtlRegExp<>());
- if (re && REPARSE_ERROR_OK == re->Parse(_T("{rtsp://[^\n]+}"), FALSE)) {
- res.AddTail(re);
- }
- }
-
- if (!body.IsEmpty()) {
- if (fn.Find(_T("://")) >= 0) {
- FindRedir(url, ct, body, *redir, res);
- } else {
- FindRedir(fn, ct, *redir, res);
- }
- }
- }
-
- return TToA(ct);
+ CUrl url;
+ CString ct, body;
+
+ if (fn.Find(_T("://")) >= 0) {
+ url.CrackUrl(fn);
+
+ if (_tcsicmp(url.GetSchemeName(), _T("pnm")) == 0) {
+ return "audio/x-pn-realaudio";
+ }
+
+ if (_tcsicmp(url.GetSchemeName(), _T("mms")) == 0) {
+ return "video/x-ms-asf";
+ }
+
+ if (_tcsicmp(url.GetSchemeName(), _T("http")) != 0) {
+ return "";
+ }
+
+ DWORD ProxyEnable = 0;
+ CString ProxyServer;
+ DWORD ProxyPort = 0;
+
+ ULONG len = 256 + 1;
+ CRegKey key;
+ if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"), KEY_READ)
+ && ERROR_SUCCESS == key.QueryDWORDValue(_T("ProxyEnable"), ProxyEnable) && ProxyEnable
+ && ERROR_SUCCESS == key.QueryStringValue(_T("ProxyServer"), ProxyServer.GetBufferSetLength(256), &len)) {
+ ProxyServer.ReleaseBufferSetLength(len);
+
+ CAtlList<CString> sl;
+ ProxyServer = Explode(ProxyServer, sl, ';');
+ if (sl.GetCount() > 1) {
+ POSITION pos = sl.GetHeadPosition();
+ while (pos) {
+ CAtlList<CString> sl2;
+ if (!Explode(sl.GetNext(pos), sl2, '=', 2).CompareNoCase(_T("http"))
+ && sl2.GetCount() == 2) {
+ ProxyServer = sl2.GetTail();
+ break;
+ }
+ }
+ }
+
+ ProxyServer = Explode(ProxyServer, sl, ':');
+ if (sl.GetCount() > 1) {
+ ProxyPort = _tcstol(sl.GetTail(), NULL, 10);
+ }
+ }
+
+ CSocket s;
+ s.Create();
+ if (s.Connect(
+ ProxyEnable ? ProxyServer : url.GetHostName(),
+ ProxyEnable ? ProxyPort : url.GetPortNumber())) {
+ CStringA host = CStringA(url.GetHostName());
+ CStringA path = CStringA(url.GetUrlPath()) + CStringA(url.GetExtraInfo());
+
+ if (ProxyEnable) {
+ path = "http://" + host + path;
+ }
+
+ CStringA hdr;
+ hdr.Format(
+ "GET %s HTTP/1.0\r\n"
+ "User-Agent: Media Player Classic\r\n"
+ "Host: %s\r\n"
+ "Accept: */*\r\n"
+ "\r\n", path, host);
+
+ // MessageBox(NULL, CString(hdr), _T("Sending..."), MB_OK);
+
+ if (s.Send((LPCSTR)hdr, hdr.GetLength()) < hdr.GetLength()) {
+ return "";
+ }
+
+ hdr.Empty();
+ for (;;) {
+ CStringA str;
+ str.ReleaseBuffer(s.Receive(str.GetBuffer(256), 256)); // SOCKET_ERROR == -1, also suitable for ReleaseBuffer
+ if (str.IsEmpty()) {
+ break;
+ }
+ hdr += str;
+ int hdrend = hdr.Find("\r\n\r\n");
+ if (hdrend >= 0) {
+ body = hdr.Mid(hdrend + 4);
+ hdr = hdr.Left(hdrend);
+ break;
+ }
+ }
+
+ // MessageBox(NULL, CString(hdr), _T("Received..."), MB_OK);
+
+ CAtlList<CStringA> sl;
+ Explode(hdr, sl, '\n');
+ POSITION pos = sl.GetHeadPosition();
+ while (pos) {
+ CStringA& hdrline = sl.GetNext(pos);
+ CAtlList<CStringA> sl2;
+ Explode(hdrline, sl2, ':', 2);
+ CStringA field = sl2.RemoveHead().MakeLower();
+ if (field == "location" && !sl2.IsEmpty()) {
+ return GetContentType(CString(sl2.GetHead()), redir);
+ }
+ if (field == "content-type" && !sl2.IsEmpty()) {
+ ct = sl2.GetHead();
+ }
+ }
+
+ while (body.GetLength() < 256) {
+ CStringA str;
+ str.ReleaseBuffer(s.Receive(str.GetBuffer(256), 256)); // SOCKET_ERROR == -1, also suitable for ReleaseBuffer
+ if (str.IsEmpty()) {
+ break;
+ }
+ body += str;
+ }
+
+ if (body.GetLength() >= 8) {
+ CStringA str = TToA(body);
+ if (!strncmp((LPCSTR)str, ".ra", 3)) {
+ return "audio/x-pn-realaudio";
+ }
+ if (!strncmp((LPCSTR)str, ".RMF", 4)) {
+ return "audio/x-pn-realaudio";
+ }
+ if (*(DWORD*)(LPCSTR)str == 0x75b22630) {
+ return "video/x-ms-wmv";
+ }
+ if (!strncmp((LPCSTR)str + 4, "moov", 4)) {
+ return "video/quicktime";
+ }
+ }
+
+ if (redir && (ct == _T("audio/x-scpls") || ct == _T("audio/x-mpegurl"))) {
+ while (body.GetLength() < 4 * 1024) { // should be enough for a playlist...
+ CStringA str;
+ str.ReleaseBuffer(s.Receive(str.GetBuffer(256), 256)); // SOCKET_ERROR == -1, also suitable for ReleaseBuffer
+ if (str.IsEmpty()) {
+ break;
+ }
+ body += str;
+ }
+ }
+ }
+ } else if (!fn.IsEmpty()) {
+ CPath p(fn);
+ CString ext = p.GetExtension().MakeLower();
+ if (ext == _T(".asx")) {
+ ct = _T("video/x-ms-asf");
+ } else if (ext == _T(".pls")) {
+ ct = _T("audio/x-scpls");
+ } else if (ext == _T(".m3u") || ext == _T(".m3u8")) {
+ ct = _T("audio/x-mpegurl");
+ } else if (ext == _T(".qtl")) {
+ ct = _T("application/x-quicktimeplayer");
+ } else if (ext == _T(".mpcpl")) {
+ ct = _T("application/x-mpc-playlist");
+ } else if (ext == _T(".bdmv")) {
+ ct = _T("application/x-bdmv-playlist");
+ }
+
+ FILE* f = NULL;
+ if (!_tfopen_s(&f, fn, _T("rb"))) {
+ CStringA str;
+ str.ReleaseBufferSetLength((int)fread(str.GetBuffer(10240), 1, 10240, f));
+ body = AToT(str);
+ fclose(f);
+ }
+ }
+
+ if (body.GetLength() >= 4) { // here only those which cannot be opened through dshow
+ CStringA str = TToA(body);
+ if (!strncmp((LPCSTR)str, ".ra", 3)) {
+ return "audio/x-pn-realaudio";
+ }
+ if (!strncmp((LPCSTR)str, "FWS", 3)) {
+ return "application/x-shockwave-flash";
+ }
+
+ }
+
+ if (redir && !ct.IsEmpty()) {
+ CAutoPtrList<CAtlRegExpT> res;
+ CAutoPtr<CAtlRegExpT> re;
+
+ if (ct == _T("video/x-ms-asf")) {
+ // ...://..."/>
+ re.Attach(DNew CAtlRegExpT());
+ if (re && REPARSE_ERROR_OK == re->Parse(_T("{[a-zA-Z]+://[^\n\">]*}"), FALSE)) {
+ res.AddTail(re);
+ }
+ // Ref#n= ...://...\n
+ re.Attach(DNew CAtlRegExpT());
+ if (re && REPARSE_ERROR_OK == re->Parse(_T("Ref\\z\\b*=\\b*[\"]*{([a-zA-Z]+://[^\n\"]+}"), FALSE)) {
+ res.AddTail(re);
+ }
+ } else if (ct == _T("audio/x-scpls")) {
+ // File1=...\n
+ re.Attach(DNew CAtlRegExp<>());
+ if (re && REPARSE_ERROR_OK == re->Parse(_T("file\\z\\b*=\\b*[\"]*{[^\n\"]+}"), FALSE)) {
+ res.AddTail(re);
+ }
+ } else if (ct == _T("audio/x-mpegurl")) {
+ // #comment
+ // ...
+ re.Attach(DNew CAtlRegExp<>());
+ if (re && REPARSE_ERROR_OK == re->Parse(_T("{[^#][^\n]+}"), FALSE)) {
+ res.AddTail(re);
+ }
+ } else if (ct == _T("audio/x-pn-realaudio")) {
+ // rtsp://...
+ re.Attach(DNew CAtlRegExp<>());
+ if (re && REPARSE_ERROR_OK == re->Parse(_T("{rtsp://[^\n]+}"), FALSE)) {
+ res.AddTail(re);
+ }
+ }
+
+ if (!body.IsEmpty()) {
+ if (fn.Find(_T("://")) >= 0) {
+ FindRedir(url, ct, body, *redir, res);
+ } else {
+ FindRedir(fn, ct, *redir, res);
+ }
+ }
+ }
+
+ return TToA(ct);
}
COLORPROPERTY_RANGE* CMPlayerCApp::GetColorControl(ControlType nFlag)
{
- switch (nFlag) {
- case ProcAmp_Brightness :
- return &m_ColorControl[0];
- case ProcAmp_Contrast :
- return &m_ColorControl[1];
- case ProcAmp_Hue :
- return &m_ColorControl[2];
- case ProcAmp_Saturation :
- return &m_ColorControl[3];
- }
- return NULL;
+ switch (nFlag) {
+ case ProcAmp_Brightness :
+ return &m_ColorControl[0];
+ case ProcAmp_Contrast :
+ return &m_ColorControl[1];
+ case ProcAmp_Hue :
+ return &m_ColorControl[2];
+ case ProcAmp_Saturation :
+ return &m_ColorControl[3];
+ }
+ return NULL;
}
void CMPlayerCApp::ResetColorControlRange()
{
- m_ColorControl[0].dwProperty = ProcAmp_Brightness;
- m_ColorControl[0].MinValue = -100;
- m_ColorControl[0].MaxValue = 100;
- m_ColorControl[0].DefaultValue = 0;
- m_ColorControl[0].StepSize = 1;
- m_ColorControl[1].dwProperty = ProcAmp_Contrast;
- m_ColorControl[1].MinValue = -100;
- m_ColorControl[1].MaxValue = 100;
- m_ColorControl[1].DefaultValue = 0;
- m_ColorControl[1].StepSize = 1;
- m_ColorControl[2].dwProperty = ProcAmp_Hue;
- m_ColorControl[2].MinValue = -180;
- m_ColorControl[2].MaxValue = 180;
- m_ColorControl[2].DefaultValue = 0;
- m_ColorControl[2].StepSize = 1;
- m_ColorControl[3].dwProperty = ProcAmp_Saturation;
- m_ColorControl[3].MinValue = -100;
- m_ColorControl[3].MaxValue = 100;
- m_ColorControl[3].DefaultValue = 0;
- m_ColorControl[3].StepSize = 1;
+ m_ColorControl[0].dwProperty = ProcAmp_Brightness;
+ m_ColorControl[0].MinValue = -100;
+ m_ColorControl[0].MaxValue = 100;
+ m_ColorControl[0].DefaultValue = 0;
+ m_ColorControl[0].StepSize = 1;
+ m_ColorControl[1].dwProperty = ProcAmp_Contrast;
+ m_ColorControl[1].MinValue = -100;
+ m_ColorControl[1].MaxValue = 100;
+ m_ColorControl[1].DefaultValue = 0;
+ m_ColorControl[1].StepSize = 1;
+ m_ColorControl[2].dwProperty = ProcAmp_Hue;
+ m_ColorControl[2].MinValue = -180;
+ m_ColorControl[2].MaxValue = 180;
+ m_ColorControl[2].DefaultValue = 0;
+ m_ColorControl[2].StepSize = 1;
+ m_ColorControl[3].dwProperty = ProcAmp_Saturation;
+ m_ColorControl[3].MinValue = -100;
+ m_ColorControl[3].MaxValue = 100;
+ m_ColorControl[3].DefaultValue = 0;
+ m_ColorControl[3].StepSize = 1;
}
void CMPlayerCApp::UpdateColorControlRange(bool isEVR)
{
- if (isEVR) {
- // Brightness
- m_ColorControl[0].MinValue = FixedToInt(m_EVRColorControl[0].MinValue);
- m_ColorControl[0].MaxValue = FixedToInt(m_EVRColorControl[0].MaxValue);
- m_ColorControl[0].DefaultValue = FixedToInt(m_EVRColorControl[0].DefaultValue);
- m_ColorControl[0].StepSize = max(1, FixedToInt(m_EVRColorControl[0].StepSize));
- // Contrast
- m_ColorControl[1].MinValue = FixedToInt(m_EVRColorControl[1].MinValue,100) - 100;
- m_ColorControl[1].MaxValue = FixedToInt(m_EVRColorControl[1].MaxValue,100) - 100;
- m_ColorControl[1].DefaultValue = FixedToInt(m_EVRColorControl[1].DefaultValue,100) - 100;
- m_ColorControl[1].StepSize = max(1, FixedToInt(m_EVRColorControl[1].StepSize,100));
- // Hue
- m_ColorControl[2].MinValue = FixedToInt(m_EVRColorControl[2].MinValue);
- m_ColorControl[2].MaxValue = FixedToInt(m_EVRColorControl[2].MaxValue);
- m_ColorControl[2].DefaultValue = FixedToInt(m_EVRColorControl[2].DefaultValue);
- m_ColorControl[2].StepSize = max(1, FixedToInt(m_EVRColorControl[2].StepSize));
- // Saturation
- m_ColorControl[3].MinValue = FixedToInt(m_EVRColorControl[3].MinValue,100) - 100;
- m_ColorControl[3].MaxValue = FixedToInt(m_EVRColorControl[3].MaxValue,100) - 100;
- m_ColorControl[3].DefaultValue = FixedToInt(m_EVRColorControl[3].DefaultValue,100) - 100;
- m_ColorControl[3].StepSize = max(1, FixedToInt(m_EVRColorControl[3].StepSize,100));
- }
- else {
- // Brightness
- m_ColorControl[0].MinValue = (int)floor(m_VMR9ColorControl[0].MinValue+0.5);
- m_ColorControl[0].MaxValue = (int)floor(m_VMR9ColorControl[0].MaxValue+0.5);
- m_ColorControl[0].DefaultValue = (int)floor(m_VMR9ColorControl[0].DefaultValue+0.5);
- m_ColorControl[0].StepSize = max(1,(int)(m_VMR9ColorControl[0].StepSize+0.5));
- // Contrast
- //if (m_VMR9ColorControl[1].MinValue == 0.0999908447265625) m_VMR9ColorControl[1].MinValue = 0.11; //fix nvidia bug
- if (*(int*)&m_VMR9ColorControl[1].MinValue == 1036830720) m_VMR9ColorControl[1].MinValue = 0.11f; //fix nvidia bug
- m_ColorControl[1].MinValue = (int)floor(m_VMR9ColorControl[1].MinValue*100+0.5) - 100;
- m_ColorControl[1].MaxValue = (int)floor(m_VMR9ColorControl[1].MaxValue*100+0.5) - 100;
- m_ColorControl[1].DefaultValue = (int)floor(m_VMR9ColorControl[1].DefaultValue*100+0.5) - 100;
- m_ColorControl[1].StepSize = max(1, (int)(m_VMR9ColorControl[1].StepSize*100+0.5));
- // Hue
- m_ColorControl[2].MinValue = (int)floor(m_VMR9ColorControl[2].MinValue+0.5);
- m_ColorControl[2].MaxValue = (int)floor(m_VMR9ColorControl[2].MaxValue+0.5);
- m_ColorControl[2].DefaultValue = (int)floor(m_VMR9ColorControl[2].DefaultValue+0.5);
- m_ColorControl[2].StepSize = max(1,(int)(m_VMR9ColorControl[2].StepSize+0.5));
- // Saturation
- m_ColorControl[3].MinValue = (int)floor(m_VMR9ColorControl[3].MinValue*100+0.5) - 100;
- m_ColorControl[3].MaxValue = (int)floor(m_VMR9ColorControl[3].MaxValue*100+0.5) - 100;
- m_ColorControl[3].DefaultValue = (int)floor(m_VMR9ColorControl[3].DefaultValue*100+0.5) - 100;
- m_ColorControl[3].StepSize = max(1, (int)(m_VMR9ColorControl[3].StepSize*100+0.5));
- }
-
- // Brightness
- if (m_ColorControl[0].MinValue < -100) m_ColorControl[0].MinValue = -100;
- if (m_ColorControl[0].MaxValue > 100) m_ColorControl[0].MaxValue = 100;
- // Contrast
- if (m_ColorControl[1].MinValue < -100) m_ColorControl[0].MinValue = -100;
- if (m_ColorControl[1].MaxValue > 100) m_ColorControl[0].MaxValue = 100;
- // Hue
- if (m_ColorControl[2].MinValue < -180) m_ColorControl[0].MinValue = -180;
- if (m_ColorControl[2].MaxValue > 180) m_ColorControl[0].MaxValue = 180;
- // Saturation
- if (m_ColorControl[3].MinValue < -100) m_ColorControl[0].MinValue = -100;
- if (m_ColorControl[3].MaxValue > 100) m_ColorControl[0].MaxValue = 100;
+ if (isEVR) {
+ // Brightness
+ m_ColorControl[0].MinValue = FixedToInt(m_EVRColorControl[0].MinValue);
+ m_ColorControl[0].MaxValue = FixedToInt(m_EVRColorControl[0].MaxValue);
+ m_ColorControl[0].DefaultValue = FixedToInt(m_EVRColorControl[0].DefaultValue);
+ m_ColorControl[0].StepSize = max(1, FixedToInt(m_EVRColorControl[0].StepSize));
+ // Contrast
+ m_ColorControl[1].MinValue = FixedToInt(m_EVRColorControl[1].MinValue, 100) - 100;
+ m_ColorControl[1].MaxValue = FixedToInt(m_EVRColorControl[1].MaxValue, 100) - 100;
+ m_ColorControl[1].DefaultValue = FixedToInt(m_EVRColorControl[1].DefaultValue, 100) - 100;
+ m_ColorControl[1].StepSize = max(1, FixedToInt(m_EVRColorControl[1].StepSize, 100));
+ // Hue
+ m_ColorControl[2].MinValue = FixedToInt(m_EVRColorControl[2].MinValue);
+ m_ColorControl[2].MaxValue = FixedToInt(m_EVRColorControl[2].MaxValue);
+ m_ColorControl[2].DefaultValue = FixedToInt(m_EVRColorControl[2].DefaultValue);
+ m_ColorControl[2].StepSize = max(1, FixedToInt(m_EVRColorControl[2].StepSize));
+ // Saturation
+ m_ColorControl[3].MinValue = FixedToInt(m_EVRColorControl[3].MinValue, 100) - 100;
+ m_ColorControl[3].MaxValue = FixedToInt(m_EVRColorControl[3].MaxValue, 100) - 100;
+ m_ColorControl[3].DefaultValue = FixedToInt(m_EVRColorControl[3].DefaultValue, 100) - 100;
+ m_ColorControl[3].StepSize = max(1, FixedToInt(m_EVRColorControl[3].StepSize, 100));
+ } else {
+ // Brightness
+ m_ColorControl[0].MinValue = (int)floor(m_VMR9ColorControl[0].MinValue + 0.5);
+ m_ColorControl[0].MaxValue = (int)floor(m_VMR9ColorControl[0].MaxValue + 0.5);
+ m_ColorControl[0].DefaultValue = (int)floor(m_VMR9ColorControl[0].DefaultValue + 0.5);
+ m_ColorControl[0].StepSize = max(1, (int)(m_VMR9ColorControl[0].StepSize + 0.5));
+ // Contrast
+ //if (m_VMR9ColorControl[1].MinValue == 0.0999908447265625) m_VMR9ColorControl[1].MinValue = 0.11; //fix nvidia bug
+ if (*(int*)&m_VMR9ColorControl[1].MinValue == 1036830720) { m_VMR9ColorControl[1].MinValue = 0.11f; } //fix nvidia bug
+ m_ColorControl[1].MinValue = (int)floor(m_VMR9ColorControl[1].MinValue * 100 + 0.5) - 100;
+ m_ColorControl[1].MaxValue = (int)floor(m_VMR9ColorControl[1].MaxValue * 100 + 0.5) - 100;
+ m_ColorControl[1].DefaultValue = (int)floor(m_VMR9ColorControl[1].DefaultValue * 100 + 0.5) - 100;
+ m_ColorControl[1].StepSize = max(1, (int)(m_VMR9ColorControl[1].StepSize * 100 + 0.5));
+ // Hue
+ m_ColorControl[2].MinValue = (int)floor(m_VMR9ColorControl[2].MinValue + 0.5);
+ m_ColorControl[2].MaxValue = (int)floor(m_VMR9ColorControl[2].MaxValue + 0.5);
+ m_ColorControl[2].DefaultValue = (int)floor(m_VMR9ColorControl[2].DefaultValue + 0.5);
+ m_ColorControl[2].StepSize = max(1, (int)(m_VMR9ColorControl[2].StepSize + 0.5));
+ // Saturation
+ m_ColorControl[3].MinValue = (int)floor(m_VMR9ColorControl[3].MinValue * 100 + 0.5) - 100;
+ m_ColorControl[3].MaxValue = (int)floor(m_VMR9ColorControl[3].MaxValue * 100 + 0.5) - 100;
+ m_ColorControl[3].DefaultValue = (int)floor(m_VMR9ColorControl[3].DefaultValue * 100 + 0.5) - 100;
+ m_ColorControl[3].StepSize = max(1, (int)(m_VMR9ColorControl[3].StepSize * 100 + 0.5));
+ }
+
+ // Brightness
+ if (m_ColorControl[0].MinValue < -100) { m_ColorControl[0].MinValue = -100; }
+ if (m_ColorControl[0].MaxValue > 100) { m_ColorControl[0].MaxValue = 100; }
+ // Contrast
+ if (m_ColorControl[1].MinValue < -100) { m_ColorControl[0].MinValue = -100; }
+ if (m_ColorControl[1].MaxValue > 100) { m_ColorControl[0].MaxValue = 100; }
+ // Hue
+ if (m_ColorControl[2].MinValue < -180) { m_ColorControl[0].MinValue = -180; }
+ if (m_ColorControl[2].MaxValue > 180) { m_ColorControl[0].MaxValue = 180; }
+ // Saturation
+ if (m_ColorControl[3].MinValue < -100) { m_ColorControl[0].MinValue = -100; }
+ if (m_ColorControl[3].MaxValue > 100) { m_ColorControl[0].MaxValue = 100; }
}
VMR9ProcAmpControlRange* CMPlayerCApp::GetVMR9ColorControl(ControlType nFlag)
{
- switch (nFlag) {
- case ProcAmp_Brightness :
- return &m_VMR9ColorControl[0];
- case ProcAmp_Contrast :
- return &m_VMR9ColorControl[1];
- case ProcAmp_Hue :
- return &m_VMR9ColorControl[2];
- case ProcAmp_Saturation :
- return &m_VMR9ColorControl[3];
- }
- return NULL;
+ switch (nFlag) {
+ case ProcAmp_Brightness :
+ return &m_VMR9ColorControl[0];
+ case ProcAmp_Contrast :
+ return &m_VMR9ColorControl[1];
+ case ProcAmp_Hue :
+ return &m_VMR9ColorControl[2];
+ case ProcAmp_Saturation :
+ return &m_VMR9ColorControl[3];
+ }
+ return NULL;
}
DXVA2_ValueRange* CMPlayerCApp::GetEVRColorControl(ControlType nFlag)
{
- switch (nFlag) {
- case ProcAmp_Brightness :
- return &m_EVRColorControl[0];
- case ProcAmp_Contrast :
- return &m_EVRColorControl[1];
- case ProcAmp_Hue :
- return &m_EVRColorControl[2];
- case ProcAmp_Saturation :
- return &m_EVRColorControl[3];
- }
- return NULL;
+ switch (nFlag) {
+ case ProcAmp_Brightness :
+ return &m_EVRColorControl[0];
+ case ProcAmp_Contrast :
+ return &m_EVRColorControl[1];
+ case ProcAmp_Hue :
+ return &m_EVRColorControl[2];
+ case ProcAmp_Saturation :
+ return &m_EVRColorControl[3];
+ }
+ return NULL;
}
const LanguageResource& CMPlayerCApp::GetLanguageResourceByResourceID(UINT resourceID)
{
- size_t defaultResource = 0;
+ size_t defaultResource = 0;
- for (size_t i = 0; i < languageResourcesCount; i++) {
- if (resourceID == languageResources[i].resourceID) {
- return languageResources[i];
- } else if (ID_LANGUAGE_ENGLISH == languageResources[i].resourceID) {
- defaultResource = i;
- }
- }
+ for (size_t i = 0; i < languageResourcesCount; i++) {
+ if (resourceID == languageResources[i].resourceID) {
+ return languageResources[i];
+ } else if (ID_LANGUAGE_ENGLISH == languageResources[i].resourceID) {
+ defaultResource = i;
+ }
+ }
- return languageResources[defaultResource];
+ return languageResources[defaultResource];
}
const LanguageResource& CMPlayerCApp::GetLanguageResourceByLocaleID(LANGID localeID)
{
- size_t defaultResource = 0;
+ size_t defaultResource = 0;
- for (size_t i = 0; i < languageResourcesCount; i++) {
- if (localeID == languageResources[i].localeID) {
- return languageResources[i];
- } else if (0 == languageResources[i].localeID) {
- defaultResource = i;
- }
- }
+ for (size_t i = 0; i < languageResourcesCount; i++) {
+ if (localeID == languageResources[i].localeID) {
+ return languageResources[i];
+ } else if (0 == languageResources[i].localeID) {
+ defaultResource = i;
+ }
+ }
- return languageResources[defaultResource];
+ return languageResources[defaultResource];
}
void CMPlayerCApp::SetDefaultLanguage()
{
- const LanguageResource& languageResource = GetLanguageResourceByLocaleID(GetUserDefaultUILanguage());
+ const LanguageResource& languageResource = GetLanguageResourceByLocaleID(GetUserDefaultUILanguage());
- // Try to set the language resource but don't fail if it can't be loaded
- // English will we used instead in case of error
- SetLanguage(languageResource, false);
+ // Try to set the language resource but don't fail if it can't be loaded
+ // English will we used instead in case of error
+ SetLanguage(languageResource, false);
}
LRESULT CALLBACK RTLWindowsLayoutCbtFilterHook(int code, WPARAM wParam, LPARAM lParam)
{
- if (code == HCBT_CREATEWND)
- {
- //LPCREATESTRUCT lpcs = ((LPCBT_CREATEWND)lParam)->lpcs;
+ if (code == HCBT_CREATEWND) {
+ //LPCREATESTRUCT lpcs = ((LPCBT_CREATEWND)lParam)->lpcs;
- //if ((lpcs->style & WS_CHILD) == 0)
- // lpcs->dwExStyle |= WS_EX_LAYOUTRTL; // doesn't seem to have any effect, but shouldn't hurt
+ //if ((lpcs->style & WS_CHILD) == 0)
+ // lpcs->dwExStyle |= WS_EX_LAYOUTRTL; // doesn't seem to have any effect, but shouldn't hurt
- HWND hWnd = (HWND)wParam;
- if ((GetWindowLongPtr(hWnd, GWL_STYLE) & WS_CHILD) == 0) {
- SetWindowLongPtr(hWnd, GWL_EXSTYLE, GetWindowLongPtr(hWnd, GWL_EXSTYLE) | WS_EX_LAYOUTRTL);
- }
- }
- return CallNextHookEx(NULL, code, wParam, lParam);
+ HWND hWnd = (HWND)wParam;
+ if ((GetWindowLongPtr(hWnd, GWL_STYLE) & WS_CHILD) == 0) {
+ SetWindowLongPtr(hWnd, GWL_EXSTYLE, GetWindowLongPtr(hWnd, GWL_EXSTYLE) | WS_EX_LAYOUTRTL);
+ }
+ }
+ return CallNextHookEx(NULL, code, wParam, lParam);
}
bool CMPlayerCApp::SetLanguage(const LanguageResource& languageResource, bool showErrorMsg /*= true*/)
{
- AppSettings& s = AfxGetAppSettings();
- HMODULE hMod = NULL;
- bool success = false;
-
- // Try to load the resource dll if any
- if (languageResource.dllPath) {
- hMod = LoadLibrary(languageResource.dllPath);
- if (hMod == NULL) { // The dll failed to load for some reason
- if (showErrorMsg) {
- MessageBox(NULL, _T("Error loading the chosen language.\n\nPlease reinstall MPC-HC."),
- _T("Media Player Classic - Home Cinema"), MB_ICONWARNING | MB_OK);
- }
- } else { // Check if the version of the resource dll is correct
- CFileVersionInfo Version;
- CString strSatVersion;
-
- if (Version.Create(languageResource.dllPath)) {
- strSatVersion = Version.GetFileVersionEx();
-
- CString strNeededVersion = MPC_VERSION_STR;
- strNeededVersion.Replace(_T(", "), _T("."));
-
- if (strSatVersion == strNeededVersion) {
- s.language = languageResource.localeID;
- success = true;
- }
- }
-
- if (!success) { // The version wasn't correct
- if (showErrorMsg) {
- // This message should stay in English!
- MessageBox(NULL, _T("Your language pack will not work with this version. Please download a compatible one from the MPC-HC homepage."),
- _T("Media Player Classic - Home Cinema"), MB_ICONWARNING | MB_OK);
- }
- // Free the loaded resource dll
- FreeLibrary(hMod);
- hMod = NULL;
- }
- }
- }
-
- // In case no dll was loaded, load the English translation from the executable
- if (hMod == NULL) {
- hMod = AfxGetApp()->m_hInstance;
- s.language = 0;
- // If a resource dll was supposed to be loaded we had an error
- success = (languageResource.dllPath == NULL);
- }
- // In case a dll was loaded, check if some special action is needed
- else if (languageResource.resourceID == ID_LANGUAGE_HEBREW) {
- // Hebrew needs the RTL flag.
- SetProcessDefaultLayout(LAYOUT_RTL);
- SetWindowsHookEx(WH_CBT, RTLWindowsLayoutCbtFilterHook, NULL, GetCurrentThreadId());
- }
-
- // Free the old resource if it was a dll
- if (AfxGetResourceHandle() != AfxGetApp()->m_hInstance) {
- FreeLibrary(AfxGetResourceHandle());
- }
- // Set the new resource
- AfxSetResourceHandle(hMod);
-
- return success;
+ AppSettings& s = AfxGetAppSettings();
+ HMODULE hMod = NULL;
+ bool success = false;
+
+ // Try to load the resource dll if any
+ if (languageResource.dllPath) {
+ hMod = LoadLibrary(languageResource.dllPath);
+ if (hMod == NULL) { // The dll failed to load for some reason
+ if (showErrorMsg) {
+ MessageBox(NULL, _T("Error loading the chosen language.\n\nPlease reinstall MPC-HC."),
+ _T("Media Player Classic - Home Cinema"), MB_ICONWARNING | MB_OK);
+ }
+ } else { // Check if the version of the resource dll is correct
+ CFileVersionInfo Version;
+ CString strSatVersion;
+
+ if (Version.Create(languageResource.dllPath)) {
+ strSatVersion = Version.GetFileVersionEx();
+
+ CString strNeededVersion = MPC_VERSION_STR;
+ strNeededVersion.Replace(_T(", "), _T("."));
+
+ if (strSatVersion == strNeededVersion) {
+ s.language = languageResource.localeID;
+ success = true;
+ }
+ }
+
+ if (!success) { // The version wasn't correct
+ if (showErrorMsg) {
+ // This message should stay in English!
+ MessageBox(NULL, _T("Your language pack will not work with this version. Please download a compatible one from the MPC-HC homepage."),
+ _T("Media Player Classic - Home Cinema"), MB_ICONWARNING | MB_OK);
+ }
+ // Free the loaded resource dll
+ FreeLibrary(hMod);
+ hMod = NULL;
+ }
+ }
+ }
+
+ // In case no dll was loaded, load the English translation from the executable
+ if (hMod == NULL) {
+ hMod = AfxGetApp()->m_hInstance;
+ s.language = 0;
+ // If a resource dll was supposed to be loaded we had an error
+ success = (languageResource.dllPath == NULL);
+ }
+ // In case a dll was loaded, check if some special action is needed
+ else if (languageResource.resourceID == ID_LANGUAGE_HEBREW) {
+ // Hebrew needs the RTL flag.
+ SetProcessDefaultLayout(LAYOUT_RTL);
+ SetWindowsHookEx(WH_CBT, RTLWindowsLayoutCbtFilterHook, NULL, GetCurrentThreadId());
+ }
+
+ // Free the old resource if it was a dll
+ if (AfxGetResourceHandle() != AfxGetApp()->m_hInstance) {
+ FreeLibrary(AfxGetResourceHandle());
+ }
+ // Set the new resource
+ AfxSetResourceHandle(hMod);
+
+ return success;
}
/*HRESULT CMPlayerCApp::GetElevationType(TOKEN_ELEVATION_TYPE* ptet )
{
- ASSERT( SysVersion::IsVistaOrLater() );
- ASSERT( ptet );
-
- HRESULT hResult = E_FAIL; // assume an error occurred
- HANDLE hToken = NULL;
-
- if ( !::OpenProcessToken(
- ::GetCurrentProcess(),
- TOKEN_QUERY,
- &hToken ) ) {
- ASSERT( FALSE );
- return hResult;
- }
-
- DWORD dwReturnLength = 0;
-
- if ( !::GetTokenInformation(
- hToken,
- TokenElevationType,
- ptet,
- sizeof( *ptet ),
- &dwReturnLength ) ) {
- ASSERT( FALSE );
- } else {
- ASSERT( dwReturnLength == sizeof( *ptet ) );
- hResult = S_OK;
- }
-
- ::CloseHandle( hToken );
-
- return hResult;
+ ASSERT( SysVersion::IsVistaOrLater() );
+ ASSERT( ptet );
+
+ HRESULT hResult = E_FAIL; // assume an error occurred
+ HANDLE hToken = NULL;
+
+ if ( !::OpenProcessToken(
+ ::GetCurrentProcess(),
+ TOKEN_QUERY,
+ &hToken ) ) {
+ ASSERT( FALSE );
+ return hResult;
+ }
+
+ DWORD dwReturnLength = 0;
+
+ if ( !::GetTokenInformation(
+ hToken,
+ TokenElevationType,
+ ptet,
+ sizeof( *ptet ),
+ &dwReturnLength ) ) {
+ ASSERT( FALSE );
+ } else {
+ ASSERT( dwReturnLength == sizeof( *ptet ) );
+ hResult = S_OK;
+ }
+
+ ::CloseHandle( hToken );
+
+ return hResult;
}*/
void CMPlayerCApp::RunAsAdministrator(LPCTSTR strCommand, LPCTSTR strArgs, bool bWaitProcess)
{
- SHELLEXECUTEINFO execinfo;
- memset(&execinfo, 0, sizeof(execinfo));
- execinfo.lpFile = strCommand;
- execinfo.cbSize = sizeof(execinfo);
- execinfo.lpVerb = _T("runas");
- execinfo.fMask = SEE_MASK_NOCLOSEPROCESS;
- execinfo.nShow = SW_SHOWDEFAULT;
- execinfo.lpParameters = strArgs;
+ SHELLEXECUTEINFO execinfo;
+ memset(&execinfo, 0, sizeof(execinfo));
+ execinfo.lpFile = strCommand;
+ execinfo.cbSize = sizeof(execinfo);
+ execinfo.lpVerb = _T("runas");
+ execinfo.fMask = SEE_MASK_NOCLOSEPROCESS;
+ execinfo.nShow = SW_SHOWDEFAULT;
+ execinfo.lpParameters = strArgs;
- ShellExecuteEx(&execinfo);
+ ShellExecuteEx(&execinfo);
- if (bWaitProcess) {
- WaitForSingleObject(execinfo.hProcess, INFINITE);
- }
+ if (bWaitProcess) {
+ WaitForSingleObject(execinfo.hProcess, INFINITE);
+ }
}
CRenderersData* GetRenderersData()
{
- return &AfxGetMyApp()->m_Renderers;
+ return &AfxGetMyApp()->m_Renderers;
}
CRenderersSettings& GetRenderersSettings()
{
- return AfxGetAppSettings().m_RenderersSettings;
+ return AfxGetAppSettings().m_RenderersSettings;
}
diff --git a/src/mpc-hc/mplayerc.h b/src/mpc-hc/mplayerc.h
index c94a75e79..4766a4fbe 100644
--- a/src/mpc-hc/mplayerc.h
+++ b/src/mpc-hc/mplayerc.h
@@ -44,12 +44,12 @@
enum {
- WM_GRAPHNOTIFY = WM_RESET_DEVICE+1,
- WM_RESUMEFROMSTATE,
- WM_TUNER_SCAN_PROGRESS,
- WM_TUNER_SCAN_END,
- WM_TUNER_STATS,
- WM_TUNER_NEW_CHANNEL
+ WM_GRAPHNOTIFY = WM_RESET_DEVICE + 1,
+ WM_RESUMEFROMSTATE,
+ WM_TUNER_SCAN_PROGRESS,
+ WM_TUNER_SCAN_END,
+ WM_TUNER_STATS,
+ WM_TUNER_NEW_CHANNEL
};
#define WM_MYMOUSELAST WM_XBUTTONDBLCLK
@@ -66,32 +66,34 @@ extern WORD AssignedToCmd(UINT keyOrMouseValue, bool bIsFullScreen = false, bool
// Casimir666
//
typedef enum {
- ProcAmp_Brightness = 0x1,
- ProcAmp_Contrast = 0x2,
- ProcAmp_Hue = 0x4,
- ProcAmp_Saturation = 0x8,
- ProcAmp_All = ProcAmp_Brightness | ProcAmp_Contrast | ProcAmp_Hue | ProcAmp_Saturation,
+ ProcAmp_Brightness = 0x1,
+ ProcAmp_Contrast = 0x2,
+ ProcAmp_Hue = 0x4,
+ ProcAmp_Saturation = 0x8,
+ ProcAmp_All = ProcAmp_Brightness | ProcAmp_Contrast | ProcAmp_Hue | ProcAmp_Saturation,
} ControlType;
typedef struct {
- DWORD dwProperty;
- int MinValue;
- int MaxValue;
- int DefaultValue;
- int StepSize;
+ DWORD dwProperty;
+ int MinValue;
+ int MaxValue;
+ int DefaultValue;
+ int StepSize;
} COLORPROPERTY_RANGE;
__inline DXVA2_Fixed32 IntToFixed(__in const int _int_, __in const SHORT divisor = 1)
-{ // special converter that is resistant to MS bugs
- DXVA2_Fixed32 _fixed_;
- _fixed_.Value = _int_ / divisor;
- _fixed_.Fraction = (_int_ % divisor * 0x10000 + divisor/2) / divisor;
- return _fixed_;
+{
+ // special converter that is resistant to MS bugs
+ DXVA2_Fixed32 _fixed_;
+ _fixed_.Value = _int_ / divisor;
+ _fixed_.Fraction = (_int_ % divisor * 0x10000 + divisor / 2) / divisor;
+ return _fixed_;
}
__inline int FixedToInt(__in const DXVA2_Fixed32 _fixed_, __in const SHORT factor = 1)
-{ // special converter that is resistant to MS bugs
- return (int)_fixed_.Value * factor + ((int)_fixed_.Fraction * factor + 0x8000) / 0x10000;
+{
+ // special converter that is resistant to MS bugs
+ return (int)_fixed_.Value * factor + ((int)_fixed_.Fraction * factor + 0x8000) / 0x10000;
}
/////////////////////////////////////////////////////////////////////////////
@@ -107,90 +109,89 @@ extern void SetAudioRenderer(int AudioDevNo);
extern void SetHandCursor(HWND m_hWnd, UINT nID);
-struct LanguageResource
-{
- const UINT resourceID;
- const LANGID localeID; // Check http://msdn.microsoft.com/en-us/goglobal/bb964664
- const LPCTSTR name;
- const LPCTSTR dllPath;
+struct LanguageResource {
+ const UINT resourceID;
+ const LANGID localeID; // Check http://msdn.microsoft.com/en-us/goglobal/bb964664
+ const LPCTSTR name;
+ const LPCTSTR dllPath;
};
class CMPlayerCApp : public CWinApp
{
- ATL::CMutex m_mutexOneInstance;
+ ATL::CMutex m_mutexOneInstance;
- CAtlList<CString> m_cmdln;
- void PreProcessCommandLine();
- bool SendCommandLine(HWND hWnd);
- UINT GetVKFromAppCommand(UINT nAppCommand);
+ CAtlList<CString> m_cmdln;
+ void PreProcessCommandLine();
+ bool SendCommandLine(HWND hWnd);
+ UINT GetVKFromAppCommand(UINT nAppCommand);
- // Casimir666 : new in CMPlayerCApp
- COLORPROPERTY_RANGE m_ColorControl[4];
- VMR9ProcAmpControlRange m_VMR9ColorControl[4];
- DXVA2_ValueRange m_EVRColorControl[4];
+ // Casimir666 : new in CMPlayerCApp
+ COLORPROPERTY_RANGE m_ColorControl[4];
+ VMR9ProcAmpControlRange m_VMR9ColorControl[4];
+ DXVA2_ValueRange m_EVRColorControl[4];
- static UINT GetRemoteControlCodeMicrosoft(UINT nInputcode, HRAWINPUT hRawInput);
- static UINT GetRemoteControlCodeSRM7500(UINT nInputcode, HRAWINPUT hRawInput);
+ static UINT GetRemoteControlCodeMicrosoft(UINT nInputcode, HRAWINPUT hRawInput);
+ static UINT GetRemoteControlCodeSRM7500(UINT nInputcode, HRAWINPUT hRawInput);
public:
- CMPlayerCApp();
+ CMPlayerCApp();
- void ShowCmdlnSwitches() const;
+ void ShowCmdlnSwitches() const;
- bool StoreSettingsToIni();
- bool StoreSettingsToRegistry();
- CString GetIniPath() const;
- bool IsIniValid() const;
- bool IsIniUTF16LE() const;
- bool ChangeSettingsLocation(bool useIni);
- void ExportSettings();
+ bool StoreSettingsToIni();
+ bool StoreSettingsToRegistry();
+ CString GetIniPath() const;
+ bool IsIniValid() const;
+ bool IsIniUTF16LE() const;
+ bool ChangeSettingsLocation(bool useIni);
+ void ExportSettings();
- bool GetAppSavePath(CString& path);
+ bool GetAppSavePath(CString& path);
- // Casimir666 : new in CMPlayerCApp
- CRenderersData m_Renderers;
- CString m_strVersion;
- CString m_AudioRendererDisplayName_CL;
+ // Casimir666 : new in CMPlayerCApp
+ CRenderersData m_Renderers;
+ CString m_strVersion;
+ CString m_AudioRendererDisplayName_CL;
- CAppSettings m_s;
+ CAppSettings m_s;
- typedef UINT (*PTR_GetRemoteControlCode)(UINT nInputcode, HRAWINPUT hRawInput);
+ typedef UINT(*PTR_GetRemoteControlCode)(UINT nInputcode, HRAWINPUT hRawInput);
- PTR_GetRemoteControlCode GetRemoteControlCode;
- COLORPROPERTY_RANGE* GetColorControl(ControlType nFlag);
- void ResetColorControlRange();
- void UpdateColorControlRange(bool isEVR);
- VMR9ProcAmpControlRange* GetVMR9ColorControl(ControlType nFlag);
- DXVA2_ValueRange* GetEVRColorControl(ControlType nFlag);
+ PTR_GetRemoteControlCode GetRemoteControlCode;
+ COLORPROPERTY_RANGE* GetColorControl(ControlType nFlag);
+ void ResetColorControlRange();
+ void UpdateColorControlRange(bool isEVR);
+ VMR9ProcAmpControlRange* GetVMR9ColorControl(ControlType nFlag);
+ DXVA2_ValueRange* GetEVRColorControl(ControlType nFlag);
- static const LanguageResource languageResources[];
- static const size_t languageResourcesCount;
+ static const LanguageResource languageResources[];
+ static const size_t languageResourcesCount;
- static const LanguageResource& GetLanguageResourceByResourceID(UINT resourceID);
- static const LanguageResource& GetLanguageResourceByLocaleID(LANGID localeID);
- static bool SetLanguage(const LanguageResource& languageResource, bool showErrorMsg = true);
- static void SetDefaultLanguage();
+ static const LanguageResource& GetLanguageResourceByResourceID(UINT resourceID);
+ static const LanguageResource& GetLanguageResourceByLocaleID(LANGID localeID);
+ static bool SetLanguage(const LanguageResource& languageResource, bool showErrorMsg = true);
+ static void SetDefaultLanguage();
- //static HRESULT GetElevationType(TOKEN_ELEVATION_TYPE* ptet);
- static void RunAsAdministrator(LPCTSTR strCommand, LPCTSTR strArgs, bool bWaitProcess);
+ //static HRESULT GetElevationType(TOKEN_ELEVATION_TYPE* ptet);
+ static void RunAsAdministrator(LPCTSTR strCommand, LPCTSTR strArgs, bool bWaitProcess);
- void RegisterHotkeys();
- void UnregisterHotkeys();
- // Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CMPlayerCApp)
+ void RegisterHotkeys();
+ void UnregisterHotkeys();
+ // Overrides
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CMPlayerCApp)
public:
- virtual BOOL InitInstance();
- virtual int ExitInstance();
- //}}AFX_VIRTUAL
+ virtual BOOL InitInstance();
+ virtual int ExitInstance();
+ //}}AFX_VIRTUAL
- // Implementation
+ // Implementation
public:
- DECLARE_MESSAGE_MAP()
- afx_msg void OnAppAbout();
- afx_msg void OnFileExit();
- afx_msg void OnHelpShowcommandlineswitches();
+ DECLARE_MESSAGE_MAP()
+ afx_msg void OnAppAbout();
+ afx_msg void OnFileExit();
+ afx_msg void OnHelpShowcommandlineswitches();
};
#define AfxGetMyApp() static_cast<CMPlayerCApp*>(AfxGetApp())
diff --git a/src/mpc-hc/vkCodes.cpp b/src/mpc-hc/vkCodes.cpp
index 27526efc8..571e01466 100644
--- a/src/mpc-hc/vkCodes.cpp
+++ b/src/mpc-hc/vkCodes.cpp
@@ -26,313 +26,315 @@
PCTSTR GetKeyName(UINT vkCode)
{
- ASSERT(vkCode < 256);
- vkCode &= 0xff;
+ ASSERT(vkCode < 256);
+ vkCode &= 0xff;
- static PCTSTR s_pszKeys[256] = {
- _T("Unused"),
- _T("Left mouse button"),
- _T("Right mouse button"),
- _T("Control-break"),
- _T("Middle mouse button"),
- _T("X1 mouse button"),
- _T("X2 mouse button"),
- _T("Undefined"),
- _T("Backspace"),
- _T("Tab"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Clear"),
- _T("Enter"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Shift"),
- _T("Control"),
- _T("Alt"),
- _T("Pause"),
- _T("Caps Lock"),
- _T("IME Kana mode"),
- _T("Unknown"),
- _T("IME Junja mode"),
- _T("IME final mode"),
- _T("IME Hanja mode"),
- _T("Unknown"),
- _T("Esc"),
- _T("IME convert"),
- _T("IME nonconvert"),
- _T("IME accept"),
- _T("IME mode change"),
- _T("Space"),
- _T("Page Up"),
- _T("Page Down"),
- _T("End"),
- _T("Home"),
- _T("Left Arrow"),
- _T("Up Arrow"),
- _T("Right Arrow"),
- _T("Down Arrow"),
- _T("Select"),
- _T("Print"),
- _T("Execute"),
- _T("Print Screen"),
- _T("Ins"),
- _T("Del"),
- _T("Help"),
- _T("0"),
- _T("1"),
- _T("2"),
- _T("3"),
- _T("4"),
- _T("5"),
- _T("6"),
- _T("7"),
- _T("8"),
- _T("9"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("A"),
- _T("B"),
- _T("C"),
- _T("D"),
- _T("E"),
- _T("F"),
- _T("G"),
- _T("H"),
- _T("I"),
- _T("J"),
- _T("K"),
- _T("L"),
- _T("M"),
- _T("N"),
- _T("O"),
- _T("P"),
- _T("Q"),
- _T("R"),
- _T("S"),
- _T("T"),
- _T("U"),
- _T("V"),
- _T("W"),
- _T("X"),
- _T("Y"),
- _T("Z"),
- _T("Left Win"),
- _T("Right Win"),
- _T("App"),
- _T("Unknown"),
- _T("Sleep"),
- _T("Num 0"),
- _T("Num 1"),
- _T("Num 2"),
- _T("Num 3"),
- _T("Num 4"),
- _T("Num 5"),
- _T("Num 6"),
- _T("Num 7"),
- _T("Num 8"),
- _T("Num 9"),
- _T("Mul"),
- _T("Add"),
- _T("Separator"),
- _T("Sub"),
- _T("Decimal"),
- _T("Div"),
- _T("F1"),
- _T("F2"),
- _T("F3"),
- _T("F4"),
- _T("F5"),
- _T("F6"),
- _T("F7"),
- _T("F8"),
- _T("F9"),
- _T("F10"),
- _T("F11"),
- _T("F12"),
- _T("F13"),
- _T("F14"),
- _T("F15"),
- _T("F16"),
- _T("F17"),
- _T("F18"),
- _T("F19"),
- _T("F20"),
- _T("F21"),
- _T("F22"),
- _T("F23"),
- _T("F24"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Num Lock"),
- _T("Scroll Lock"),
- _T("OEM"),
- _T("OEM"),
- _T("OEM"),
- _T("OEM"),
- _T("OEM"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Left Shift"),
- _T("Right Shift"),
- _T("Left Control"),
- _T("Right Control"),
- _T("Left Alt"),
- _T("Right Alt"),
- _T("Browser Back"),
- _T("Browser Forward"),
- _T("Browser Refresh"),
- _T("Browser Stop"),
- _T("Browser Search"),
- _T("Browser Favorites"),
- _T("Browser Home"),
- _T("Volume Mute"),
- _T("Volume Down"),
- _T("Volume Up"),
- _T("Next Track"),
- _T("Previous Track"),
- _T("Stop Media"),
- _T("Play/Pause Media"),
- _T("Start Mail"),
- _T("Select Media"),
- _T("Start App 1"),
- _T("Start App 2"),
- _T("Unknown"),
- _T("Unknown"),
- _T(";"),
- _T("="),
- _T(","),
- _T("_"),
- _T("."),
- _T("/"),
- _T("`"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("Unknown"),
- _T("["),
- _T("\\"),
- _T("]"),
- _T("'"),
- _T("OEM"),
- _T("Unknown"),
- _T("OEM"),
- _T("<> or \\|"),
- _T("OEM"),
- _T("OEM"),
- _T("IME Process key"),
- _T("OEM"),
- _T("VK_PACKET"),
- _T("Unknown"),
- _T("OEM"),
- _T("OEM"),
- _T("OEM"),
- _T("OEM"),
- _T("OEM"),
- _T("OEM"),
- _T("OEM"),
- _T("OEM"),
- _T("OEM"),
- _T("OEM"),
- _T("OEM"),
- _T("OEM"),
- _T("OEM"),
- _T("Attn"),
- _T("CrSel"),
- _T("ExSel"),
- _T("Erase EOF"),
- _T("Play"),
- _T("Zoom"),
- _T("Unknown"),
- _T("PA1"),
- _T("Clear"),
- _T("Unknown")
- };
+ static PCTSTR s_pszKeys[256] = {
+ _T("Unused"),
+ _T("Left mouse button"),
+ _T("Right mouse button"),
+ _T("Control-break"),
+ _T("Middle mouse button"),
+ _T("X1 mouse button"),
+ _T("X2 mouse button"),
+ _T("Undefined"),
+ _T("Backspace"),
+ _T("Tab"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Clear"),
+ _T("Enter"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Shift"),
+ _T("Control"),
+ _T("Alt"),
+ _T("Pause"),
+ _T("Caps Lock"),
+ _T("IME Kana mode"),
+ _T("Unknown"),
+ _T("IME Junja mode"),
+ _T("IME final mode"),
+ _T("IME Hanja mode"),
+ _T("Unknown"),
+ _T("Esc"),
+ _T("IME convert"),
+ _T("IME nonconvert"),
+ _T("IME accept"),
+ _T("IME mode change"),
+ _T("Space"),
+ _T("Page Up"),
+ _T("Page Down"),
+ _T("End"),
+ _T("Home"),
+ _T("Left Arrow"),
+ _T("Up Arrow"),
+ _T("Right Arrow"),
+ _T("Down Arrow"),
+ _T("Select"),
+ _T("Print"),
+ _T("Execute"),
+ _T("Print Screen"),
+ _T("Ins"),
+ _T("Del"),
+ _T("Help"),
+ _T("0"),
+ _T("1"),
+ _T("2"),
+ _T("3"),
+ _T("4"),
+ _T("5"),
+ _T("6"),
+ _T("7"),
+ _T("8"),
+ _T("9"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("A"),
+ _T("B"),
+ _T("C"),
+ _T("D"),
+ _T("E"),
+ _T("F"),
+ _T("G"),
+ _T("H"),
+ _T("I"),
+ _T("J"),
+ _T("K"),
+ _T("L"),
+ _T("M"),
+ _T("N"),
+ _T("O"),
+ _T("P"),
+ _T("Q"),
+ _T("R"),
+ _T("S"),
+ _T("T"),
+ _T("U"),
+ _T("V"),
+ _T("W"),
+ _T("X"),
+ _T("Y"),
+ _T("Z"),
+ _T("Left Win"),
+ _T("Right Win"),
+ _T("App"),
+ _T("Unknown"),
+ _T("Sleep"),
+ _T("Num 0"),
+ _T("Num 1"),
+ _T("Num 2"),
+ _T("Num 3"),
+ _T("Num 4"),
+ _T("Num 5"),
+ _T("Num 6"),
+ _T("Num 7"),
+ _T("Num 8"),
+ _T("Num 9"),
+ _T("Mul"),
+ _T("Add"),
+ _T("Separator"),
+ _T("Sub"),
+ _T("Decimal"),
+ _T("Div"),
+ _T("F1"),
+ _T("F2"),
+ _T("F3"),
+ _T("F4"),
+ _T("F5"),
+ _T("F6"),
+ _T("F7"),
+ _T("F8"),
+ _T("F9"),
+ _T("F10"),
+ _T("F11"),
+ _T("F12"),
+ _T("F13"),
+ _T("F14"),
+ _T("F15"),
+ _T("F16"),
+ _T("F17"),
+ _T("F18"),
+ _T("F19"),
+ _T("F20"),
+ _T("F21"),
+ _T("F22"),
+ _T("F23"),
+ _T("F24"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Num Lock"),
+ _T("Scroll Lock"),
+ _T("OEM"),
+ _T("OEM"),
+ _T("OEM"),
+ _T("OEM"),
+ _T("OEM"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Left Shift"),
+ _T("Right Shift"),
+ _T("Left Control"),
+ _T("Right Control"),
+ _T("Left Alt"),
+ _T("Right Alt"),
+ _T("Browser Back"),
+ _T("Browser Forward"),
+ _T("Browser Refresh"),
+ _T("Browser Stop"),
+ _T("Browser Search"),
+ _T("Browser Favorites"),
+ _T("Browser Home"),
+ _T("Volume Mute"),
+ _T("Volume Down"),
+ _T("Volume Up"),
+ _T("Next Track"),
+ _T("Previous Track"),
+ _T("Stop Media"),
+ _T("Play/Pause Media"),
+ _T("Start Mail"),
+ _T("Select Media"),
+ _T("Start App 1"),
+ _T("Start App 2"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T(";"),
+ _T("="),
+ _T(","),
+ _T("_"),
+ _T("."),
+ _T("/"),
+ _T("`"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("Unknown"),
+ _T("["),
+ _T("\\"),
+ _T("]"),
+ _T("'"),
+ _T("OEM"),
+ _T("Unknown"),
+ _T("OEM"),
+ _T("<> or \\|"),
+ _T("OEM"),
+ _T("OEM"),
+ _T("IME Process key"),
+ _T("OEM"),
+ _T("VK_PACKET"),
+ _T("Unknown"),
+ _T("OEM"),
+ _T("OEM"),
+ _T("OEM"),
+ _T("OEM"),
+ _T("OEM"),
+ _T("OEM"),
+ _T("OEM"),
+ _T("OEM"),
+ _T("OEM"),
+ _T("OEM"),
+ _T("OEM"),
+ _T("OEM"),
+ _T("OEM"),
+ _T("Attn"),
+ _T("CrSel"),
+ _T("ExSel"),
+ _T("Erase EOF"),
+ _T("Play"),
+ _T("Zoom"),
+ _T("Unknown"),
+ _T("PA1"),
+ _T("Clear"),
+ _T("Unknown")
+ };
- return s_pszKeys[vkCode];
+ return s_pszKeys[vkCode];
}
//-----------------------------------------------------------------
-BOOL HotkeyToString(UINT vkCode, UINT fModifiers, CString& s) {
+BOOL HotkeyToString(UINT vkCode, UINT fModifiers, CString& s)
+{
- s.Empty();
- if (fModifiers & MOD_CONTROL) {
- s += _T("Ctrl + ");
- }
- if (fModifiers & MOD_ALT) {
- s += _T("Alt + ");
- }
- if (fModifiers & MOD_SHIFT) {
- s += _T("Shift + ");
- }
+ s.Empty();
+ if (fModifiers & MOD_CONTROL) {
+ s += _T("Ctrl + ");
+ }
+ if (fModifiers & MOD_ALT) {
+ s += _T("Alt + ");
+ }
+ if (fModifiers & MOD_SHIFT) {
+ s += _T("Shift + ");
+ }
- if (vkCode) {
- s.Format(_T("%s%s"), (LPCTSTR)s, GetKeyName(vkCode));
- }
+ if (vkCode) {
+ s.Format(_T("%s%s"), (LPCTSTR)s, GetKeyName(vkCode));
+ }
- return !s.IsEmpty();
+ return !s.IsEmpty();
}
BOOL HotkeyModToString(UINT vkCode, BYTE fModifiers, CString& s)
{
- s.Empty();
+ s.Empty();
- if (fModifiers & FCONTROL) {
- s += _T("Ctrl + ");
- }
- if (fModifiers & FALT) {
- s += _T("Alt + ");
- }
- if (fModifiers & FSHIFT) {
- s += _T("Shift + ");
- }
- if (vkCode) {
- s.Format(_T("%s%s"), (LPCTSTR)s, GetKeyName(vkCode));
- }
+ if (fModifiers & FCONTROL) {
+ s += _T("Ctrl + ");
+ }
+ if (fModifiers & FALT) {
+ s += _T("Alt + ");
+ }
+ if (fModifiers & FSHIFT) {
+ s += _T("Shift + ");
+ }
+ if (vkCode) {
+ s.Format(_T("%s%s"), (LPCTSTR)s, GetKeyName(vkCode));
+ }
- return !s.IsEmpty();
+ return !s.IsEmpty();
}
-BOOL HotkeyToString(DWORD dwHk, CString& s) {
- return HotkeyToString(LOBYTE(LOWORD(dwHk)), HIBYTE(LOWORD(dwHk)), s);
+BOOL HotkeyToString(DWORD dwHk, CString& s)
+{
+ return HotkeyToString(LOBYTE(LOWORD(dwHk)), HIBYTE(LOWORD(dwHk)), s);
}